diff --git a/PseuWoW.sln b/PseuWoW.sln index 546e2d2..37666df 100644 --- a/PseuWoW.sln +++ b/PseuWoW.sln @@ -1,96 +1,96 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PseuWoW", "src\PseuWoW.vcproj", "{EFFE60F4-DA39-41E8-9E53-E462000A2D91}" - ProjectSection(ProjectDependencies) = postProject - {E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F} - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} - {F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270} - {262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "src\zlib.vcproj", "{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zthread", "src\zthread.vcproj", "{262199E8-EEDF-4700-A1D1-E9CC901CF480}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared", "src\shared.vcproj", "{F548FC51-24A4-45FF-A381-BEBC39F18270}" - ProjectSection(ProjectDependencies) = postProject - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} - {262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "src\dep\src\irrlicht\Irrlicht7.1.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}" - ProjectSection(ProjectDependencies) = postProject - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StuffExtract", "src\tools\stuffextract.vcproj", "{EFFE60F4-DA39-41E8-9E53-E462000A2D91}" - ProjectSection(ProjectDependencies) = postProject - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} - {F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Relase - Fast FPU = Relase - Fast FPU - Release = Release - Release - Fast FPU DebugInfo = Release - Fast FPU DebugInfo - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.ActiveCfg = Debug|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.Build.0 = Debug|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.ActiveCfg = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.Build.0 = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.ActiveCfg = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.Build.0 = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug.ActiveCfg = Debug|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug.Build.0 = Debug|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU.ActiveCfg = Release|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU.Build.0 = Release|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release.ActiveCfg = Release|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release.Build.0 = Release|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug.ActiveCfg = Debug|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug.Build.0 = Debug|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU.ActiveCfg = Release|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU.Build.0 = Release|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release.ActiveCfg = Release|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release.Build.0 = Release|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug.ActiveCfg = Debug|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug.Build.0 = Debug|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU.ActiveCfg = Release|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU.Build.0 = Release|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release.ActiveCfg = Release|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release.Build.0 = Release|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.ActiveCfg = Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.Build.0 = Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU.ActiveCfg = Relase - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU.Build.0 = Relase - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release.ActiveCfg = Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release.Build.0 = Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo.ActiveCfg = Release - Fast FPU DebugInfo|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo.Build.0 = Release - Fast FPU DebugInfo|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.ActiveCfg = Debug|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.Build.0 = Debug|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.ActiveCfg = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.Build.0 = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.ActiveCfg = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.Build.0 = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PseuWoW", "src\PseuWoW.vcproj", "{EFFE60F4-DA39-41E8-9E53-E462000A2D91}" + ProjectSection(ProjectDependencies) = postProject + {E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F} + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} + {F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270} + {262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "src\zlib.vcproj", "{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zthread", "src\zthread.vcproj", "{262199E8-EEDF-4700-A1D1-E9CC901CF480}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared", "src\shared.vcproj", "{F548FC51-24A4-45FF-A381-BEBC39F18270}" + ProjectSection(ProjectDependencies) = postProject + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} + {262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "src\dep\src\irrlicht\Irrlicht7.1.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}" + ProjectSection(ProjectDependencies) = postProject + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StuffExtract", "src\tools\stuffextract.vcproj", "{EFFE60F4-DA39-41E8-9E53-E462000A2D91}" + ProjectSection(ProjectDependencies) = postProject + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} + {F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Relase - Fast FPU = Relase - Fast FPU + Release = Release + Release - Fast FPU DebugInfo = Release - Fast FPU DebugInfo + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.ActiveCfg = Debug|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.Build.0 = Debug|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.ActiveCfg = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.Build.0 = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.ActiveCfg = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.Build.0 = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug.ActiveCfg = Debug|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug.Build.0 = Debug|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU.ActiveCfg = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU.Build.0 = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release.ActiveCfg = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release.Build.0 = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug.ActiveCfg = Debug|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug.Build.0 = Debug|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU.ActiveCfg = Release|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU.Build.0 = Release|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release.ActiveCfg = Release|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release.Build.0 = Release|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug.ActiveCfg = Debug|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug.Build.0 = Debug|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU.ActiveCfg = Release|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU.Build.0 = Release|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release.ActiveCfg = Release|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release.Build.0 = Release|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.ActiveCfg = Debug|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.Build.0 = Debug|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU.ActiveCfg = Relase - Fast FPU|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU.Build.0 = Relase - Fast FPU|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Release.ActiveCfg = Release|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Release.Build.0 = Release|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo.ActiveCfg = Release - Fast FPU DebugInfo|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo.Build.0 = Release - Fast FPU DebugInfo|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.ActiveCfg = Debug|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.Build.0 = Debug|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.ActiveCfg = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.Build.0 = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.ActiveCfg = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.Build.0 = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/PseuWoW_VC80.sln b/PseuWoW_VC80.sln index 02ecdda..0bb39c7 100644 --- a/PseuWoW_VC80.sln +++ b/PseuWoW_VC80.sln @@ -1,88 +1,88 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PseuWoW_VC80", "src\PseuWoW_VC80.vcproj", "{EFFE60F4-DA39-41E8-9E53-E462000A2D91}" - ProjectSection(ProjectDependencies) = postProject - {E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F} - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} - {F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270} - {262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "src\zlib_VC80.vcproj", "{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zthread", "src\zthread_VC80.vcproj", "{262199E8-EEDF-4700-A1D1-E9CC901CF480}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared", "src\shared_VC80.vcproj", "{F548FC51-24A4-45FF-A381-BEBC39F18270}" - ProjectSection(ProjectDependencies) = postProject - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} - {262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "src\dep\src\irrlicht\Irrlicht8.0.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}" - ProjectSection(ProjectDependencies) = postProject - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StuffExtract", "src\tools\stuffextract_VC80.vcproj", "{FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}" - ProjectSection(ProjectDependencies) = postProject - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} - {F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Relase - Fast FPU|Win32 = Relase - Fast FPU|Win32 - Release - Fast FPU DebugInfo|Win32 = Release - Fast FPU DebugInfo|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug|Win32.ActiveCfg = Debug|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug|Win32.Build.0 = Debug|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU|Win32.Build.0 = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release|Win32.ActiveCfg = Release|Win32 - {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release|Win32.Build.0 = Release|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.ActiveCfg = Debug|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.Build.0 = Debug|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU|Win32.Build.0 = Release|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.ActiveCfg = Release|Win32 - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.Build.0 = Release|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug|Win32.ActiveCfg = Debug|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug|Win32.Build.0 = Debug|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU|Win32.Build.0 = Release|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release|Win32.ActiveCfg = Release|Win32 - {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release|Win32.Build.0 = Release|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug|Win32.ActiveCfg = Debug|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug|Win32.Build.0 = Debug|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU|Win32.Build.0 = Release|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release|Win32.ActiveCfg = Release|Win32 - {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release|Win32.Build.0 = Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.ActiveCfg = Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.Build.0 = Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU|Win32.ActiveCfg = Relase - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU|Win32.Build.0 = Relase - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release - Fast FPU DebugInfo|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release - Fast FPU DebugInfo|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.ActiveCfg = Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.Build.0 = Release|Win32 - {FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Debug|Win32.ActiveCfg = Debug|Win32 - {FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32 - {FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32 - {FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Release|Win32.ActiveCfg = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PseuWoW_VC80", "src\PseuWoW_VC80.vcproj", "{EFFE60F4-DA39-41E8-9E53-E462000A2D91}" + ProjectSection(ProjectDependencies) = postProject + {E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F} + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} + {F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270} + {262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "src\zlib_VC80.vcproj", "{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zthread", "src\zthread_VC80.vcproj", "{262199E8-EEDF-4700-A1D1-E9CC901CF480}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared", "src\shared_VC80.vcproj", "{F548FC51-24A4-45FF-A381-BEBC39F18270}" + ProjectSection(ProjectDependencies) = postProject + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} + {262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "src\dep\src\irrlicht\Irrlicht8.0.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}" + ProjectSection(ProjectDependencies) = postProject + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StuffExtract", "src\tools\stuffextract_VC80.vcproj", "{FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}" + ProjectSection(ProjectDependencies) = postProject + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} + {F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Relase - Fast FPU|Win32 = Relase - Fast FPU|Win32 + Release - Fast FPU DebugInfo|Win32 = Release - Fast FPU DebugInfo|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug|Win32.ActiveCfg = Debug|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug|Win32.Build.0 = Debug|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU|Win32.Build.0 = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release|Win32.ActiveCfg = Release|Win32 + {EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release|Win32.Build.0 = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.ActiveCfg = Debug|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.Build.0 = Debug|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU|Win32.Build.0 = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.ActiveCfg = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.Build.0 = Release|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug|Win32.ActiveCfg = Debug|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug|Win32.Build.0 = Debug|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU|Win32.Build.0 = Release|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release|Win32.ActiveCfg = Release|Win32 + {262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release|Win32.Build.0 = Release|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug|Win32.ActiveCfg = Debug|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug|Win32.Build.0 = Debug|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU|Win32.Build.0 = Release|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release|Win32.ActiveCfg = Release|Win32 + {F548FC51-24A4-45FF-A381-BEBC39F18270}.Release|Win32.Build.0 = Release|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.ActiveCfg = Debug|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.Build.0 = Debug|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU|Win32.ActiveCfg = Relase - Fast FPU|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU|Win32.Build.0 = Relase - Fast FPU|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release - Fast FPU DebugInfo|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release - Fast FPU DebugInfo|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.ActiveCfg = Release|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.Build.0 = Release|Win32 + {FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Debug|Win32.ActiveCfg = Debug|Win32 + {FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32 + {FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32 + {FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Release|Win32.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/bin/_startup.def b/bin/_startup.def index ec23a2d..fd0c06e 100644 --- a/bin/_startup.def +++ b/bin/_startup.def @@ -1,51 +1,51 @@ -// PSEUWOW DEF_SCRIPT STARTUP FILE - -// this is for debugging which scripts are loaded -// set to false to disable output -SET,LoadDebug true - -LOG *** DefScript StartUp [${@version_short}]... - -// first, load all scripts in path 'scripts' with extension .def -SET,fcount ?{LGETFILES,scriptlist,def scripts} -LSORT scriptlist -LOG *** Loading ${fcount} script files. -// iterate over all files and load them; if counter i is equal to the amount of files we are done. -SET,i 0 -SET,errors 0 -LOOP - IF ?{EQUAL,${i} ${fcount}} - EXITLOOP - ENDIF - SET,fn ./scripts/?{LINDEX,scriptlist ${i}} - IF ?{AND,?{IsSet LoadDebug} ${LoadDebug}} - LOG * Loading script file [${fn}] - ENDIF - IF ?{NOT ?{LOADDEF ${fn}}} - LOGERROR * Error loading [${fn}] - ADD,errors 1 - ENDIF - ADD,i 1 -ENDLOOP - -UNSET tmp -UNSET fcount -UNSET i -UNSET fn -LDELETE scriptlist - -IF ?{NOT ${errors}} - LOG *** All files loaded without errors. -ELSE - LOG *** All files loaded, ${errors} errors. -ENDIF -UNSET errors - -// Load some SCP files -LOADALLSCP - -// do more stuff here in future... - -LOG * StartUp complete! - - +// PSEUWOW DEF_SCRIPT STARTUP FILE + +// this is for debugging which scripts are loaded +// set to false to disable output +SET,LoadDebug true + +LOG *** DefScript StartUp [${@version_short}]... + +// first, load all scripts in path 'scripts' with extension .def +SET,fcount ?{LGETFILES,scriptlist,def scripts} +LSORT scriptlist +LOG *** Loading ${fcount} script files. +// iterate over all files and load them; if counter i is equal to the amount of files we are done. +SET,i 0 +SET,errors 0 +LOOP + IF ?{EQUAL,${i} ${fcount}} + EXITLOOP + ENDIF + SET,fn ./scripts/?{LINDEX,scriptlist ${i}} + IF ?{AND,?{IsSet LoadDebug} ${LoadDebug}} + LOG * Loading script file [${fn}] + ENDIF + IF ?{NOT ?{LOADDEF ${fn}}} + LOGERROR * Error loading [${fn}] + ADD,errors 1 + ENDIF + ADD,i 1 +ENDLOOP + +UNSET tmp +UNSET fcount +UNSET i +UNSET fn +LDELETE scriptlist + +IF ?{NOT ${errors}} + LOG *** All files loaded without errors. +ELSE + LOG *** All files loaded, ${errors} errors. +ENDIF +UNSET errors + +// Load some SCP files +LOADALLSCP + +// do more stuff here in future... + +LOG * StartUp complete! + + diff --git a/bin/conf/PseuWoW.conf.default b/bin/conf/PseuWoW.conf.default index 00c3104..6b298dc 100644 --- a/bin/conf/PseuWoW.conf.default +++ b/bin/conf/PseuWoW.conf.default @@ -1,125 +1,125 @@ -////////////////////////////////////////////////////////////////////////// -// PseuWoW config file -// -// still under development :D -/////////////////////////////////////////////////////////////////////////// -// -// use // for comments (C++ style) - -// its important to read & store the main conf variables UPPERCASED!! -[#uppercase] -[#noprefix] - -// 3=max, 0=no debug output -debug=0 - -// defines if the program should quit on error/exception or stay opened (for debugging) -exitonerror=0 - -// reconnect on failure/disconnect -// 0 = dont't reconnect -// everything else: delay (in ms) until the next connection attempt. -// default: 5000 ms (5 secs) -reconnect=5000 - -// 0 - show none -// 1 - show only known/handled -// 2 - show only unknown/unhandled -// 3 - show all -showopcodes=0 - - -// Hide opcodes which is coming very frequently? -// Has only an effect if you have showopcodes > 0 -// 1 - yes -// 0 - No -hidefreqopcodes=1 - -// Hide disabled (= unhandled, but known) opcodes? -// 1 - Yes -// 0 - No -HideDisabledOpcodes=0 - -// the IP or hostname the realm server is running on -realmlist=localhost - -// port on which the realm server is listening (default=3724) -realmport=3724 - -// PseuWoW will login on this realm -// Case sensitive! -realmname=My WoW Realm - -// your account name -accname=test - -// your account password -accpass=test - -// the character name PseuWoW should choose to enter the world. -// case sensitive! -charname=Pseuwow - - -// Client emulation configuration -ClientVersion=2.3.3 -ClientBuild=7799 -ClientLanguage=enUS -// or change to enGB, deDE, ... - - -// packets get fetched every xx msecs. default=50 -// setting this to 0 will let PseuWoW eat up all CPU power -// 1 is a good setting for maximum network performance and lowest ping times -NetworkSleepTime=1 - -// defines if players may say/yell/whisper commands to PseuWoW -// set this to 0 and PseuWoW will not react to given commands -allowgamecmd=1 - -// enable this if you plan to enter commands on the console -enablecli=1 - -// enable's chat ai which makes you bot respond to simple senteces -// like "Hi" and "What do you think of x" etc. -enablechatai=1 - -// show ping responses -notifyping=1 - -// shows the opcodes pseuwow sends to the server -showmyopcodes=0 - -// disable the check for learned spells. -// if you disable it, you can cast spells you do not have in your spellbook! -// WARNING: most servers will consider this as CHEATING! -// DO NOT put 1 here! -disablespellcheck=0 - -// will be used for all sendchatmessage calls. remove number/leave blank -// to use the default language for your race (defined in race.scp) -defaultlang=0 - -// set this to 1 if you want to have a 3D-window showing stuff -// NOTE: this is only to activate the window for now, 3D-stuff will come later!! -// until some frame-limiter is implemented, it will always use 100% CPU usage when -// the GUI is enabled and activated. (if its in background - way less CPU load.) -enablegui=0 - -// options for remote control: -// port beeing listened on. set to 0 do disable. -rmcontrolport=8101 -// IP or hostname that is allowed to connect. leave blank to allow connections from everywhere (dangerous!) -rmcontrolhost=localhost - -// if you have exported and copied data from your original client, -// set this to 1 to enable movement and everything map related. -// PseuWoW will need more memory with maps enabled! -useMaps=0 - -// Addon language is usually not shown by client -// Since addons are far from beeing used in PseuWoW, we can completely ignore addon chat messages. -// Sometimes they even cause problems, like make the console window beep... -SkipAddonChat=1 - - +////////////////////////////////////////////////////////////////////////// +// PseuWoW config file +// +// still under development :D +/////////////////////////////////////////////////////////////////////////// +// +// use // for comments (C++ style) + +// its important to read & store the main conf variables UPPERCASED!! +[#uppercase] +[#noprefix] + +// 3=max, 0=no debug output +debug=0 + +// defines if the program should quit on error/exception or stay opened (for debugging) +exitonerror=0 + +// reconnect on failure/disconnect +// 0 = dont't reconnect +// everything else: delay (in ms) until the next connection attempt. +// default: 5000 ms (5 secs) +reconnect=5000 + +// 0 - show none +// 1 - show only known/handled +// 2 - show only unknown/unhandled +// 3 - show all +showopcodes=0 + + +// Hide opcodes which is coming very frequently? +// Has only an effect if you have showopcodes > 0 +// 1 - yes +// 0 - No +hidefreqopcodes=1 + +// Hide disabled (= unhandled, but known) opcodes? +// 1 - Yes +// 0 - No +HideDisabledOpcodes=0 + +// the IP or hostname the realm server is running on +realmlist=localhost + +// port on which the realm server is listening (default=3724) +realmport=3724 + +// PseuWoW will login on this realm +// Case sensitive! +realmname=My WoW Realm + +// your account name +accname=test + +// your account password +accpass=test + +// the character name PseuWoW should choose to enter the world. +// case sensitive! +charname=Pseuwow + + +// Client emulation configuration +ClientVersion=2.3.3 +ClientBuild=7799 +ClientLanguage=enUS +// or change to enGB, deDE, ... + + +// packets get fetched every xx msecs. default=50 +// setting this to 0 will let PseuWoW eat up all CPU power +// 1 is a good setting for maximum network performance and lowest ping times +NetworkSleepTime=1 + +// defines if players may say/yell/whisper commands to PseuWoW +// set this to 0 and PseuWoW will not react to given commands +allowgamecmd=1 + +// enable this if you plan to enter commands on the console +enablecli=1 + +// enable's chat ai which makes you bot respond to simple senteces +// like "Hi" and "What do you think of x" etc. +enablechatai=1 + +// show ping responses +notifyping=1 + +// shows the opcodes pseuwow sends to the server +showmyopcodes=0 + +// disable the check for learned spells. +// if you disable it, you can cast spells you do not have in your spellbook! +// WARNING: most servers will consider this as CHEATING! +// DO NOT put 1 here! +disablespellcheck=0 + +// will be used for all sendchatmessage calls. remove number/leave blank +// to use the default language for your race (defined in race.scp) +defaultlang=0 + +// set this to 1 if you want to have a 3D-window showing stuff +// NOTE: this is only to activate the window for now, 3D-stuff will come later!! +// until some frame-limiter is implemented, it will always use 100% CPU usage when +// the GUI is enabled and activated. (if its in background - way less CPU load.) +enablegui=0 + +// options for remote control: +// port beeing listened on. set to 0 do disable. +rmcontrolport=8101 +// IP or hostname that is allowed to connect. leave blank to allow connections from everywhere (dangerous!) +rmcontrolhost=localhost + +// if you have exported and copied data from your original client, +// set this to 1 to enable movement and everything map related. +// PseuWoW will need more memory with maps enabled! +useMaps=0 + +// Addon language is usually not shown by client +// Since addons are far from beeing used in PseuWoW, we can completely ignore addon chat messages. +// Sometimes they even cause problems, like make the console window beep... +SkipAddonChat=1 + + diff --git a/bin/conf/ScriptConfig.conf.default b/bin/conf/ScriptConfig.conf.default index 0dc7f7a..c5725e0 100644 --- a/bin/conf/ScriptConfig.conf.default +++ b/bin/conf/ScriptConfig.conf.default @@ -1,44 +1,44 @@ - -// this config file has no effect on the core. -// store variable definitions for scripts only! - - -// ## GLOBAL SECTION ## - -[#uppercase] -[#noprefix] -// special char that is used to trigger server commands (for example ".goname Player") -// (WoWEmu="." MaNGOS="." or "!") -// other servers might be different -cmdchar=. - -// MaNGOS does also accept ! as cmd identifier. put here all identifiers that can trigger a server command! -other_cmd_chars=.! - -// Set to 1 if PseuWoW should exit after the GUI is closed (if there is a GUI) -ExitOnGUIClose=0 - - - -[#normal] -// ## END OF GLOBAL SECTION ## - - - - -// -- section for individual scripts -- - -[autobroadcast] -enable=0 -// 20 mins by default -secs=1200 -// the command the server uses to broadcast (.broadcast, .announce, .bc or whatever) -// do NOT put a trailing "." or "!" , only the plain command name! -cmd=announce -// configure your texts here -textcount=3 -text1=This is PseuWoW autobroadcast #1 -text2=And another one! Autobroadcast #2 -text3=The world is round, and so am I! - - + +// this config file has no effect on the core. +// store variable definitions for scripts only! + + +// ## GLOBAL SECTION ## + +[#uppercase] +[#noprefix] +// special char that is used to trigger server commands (for example ".goname Player") +// (WoWEmu="." MaNGOS="." or "!") +// other servers might be different +cmdchar=. + +// MaNGOS does also accept ! as cmd identifier. put here all identifiers that can trigger a server command! +other_cmd_chars=.! + +// Set to 1 if PseuWoW should exit after the GUI is closed (if there is a GUI) +ExitOnGUIClose=0 + + + +[#normal] +// ## END OF GLOBAL SECTION ## + + + + +// -- section for individual scripts -- + +[autobroadcast] +enable=0 +// 20 mins by default +secs=1200 +// the command the server uses to broadcast (.broadcast, .announce, .bc or whatever) +// do NOT put a trailing "." or "!" , only the plain command name! +cmd=announce +// configure your texts here +textcount=3 +text1=This is PseuWoW autobroadcast #1 +text2=And another one! Autobroadcast #2 +text3=The world is round, and so am I! + + diff --git a/bin/conf/gui.conf.default b/bin/conf/gui.conf.default index e906d55..54a30d7 100644 --- a/bin/conf/gui.conf.default +++ b/bin/conf/gui.conf.default @@ -1,24 +1,24 @@ -[#uppercase] -[GUI] - -// drivers: -// 0: Nulldevice (no graphics) -// 1: fast but crappy software driver -// 2: good software driver, but slower -// 3: OpenGL -// 4: DirectX 8.1 -// 5: DirectX 9.0c -driver=5 - -// resolution and more -resx=1024 -resy=768 -windowed=1 -vsync=0 - -// use realtime shadows? -// works only with DirectX or OpenGL -shadows=1 - -// color depth; 16 or 32 bit +[#uppercase] +[GUI] + +// drivers: +// 0: Nulldevice (no graphics) +// 1: fast but crappy software driver +// 2: good software driver, but slower +// 3: OpenGL +// 4: DirectX 8.1 +// 5: DirectX 9.0c +driver=5 + +// resolution and more +resx=1024 +resy=768 +windowed=1 +vsync=0 + +// use realtime shadows? +// works only with DirectX or OpenGL +shadows=1 + +// color depth; 16 or 32 bit depth=32 \ No newline at end of file diff --git a/bin/conf/users.conf.default b/bin/conf/users.conf.default index 4986202..139c918 100644 --- a/bin/conf/users.conf.default +++ b/bin/conf/users.conf.default @@ -1,18 +1,18 @@ -///////////////////////////////////////////////////////////// -// Player Permission Configuration file -///////////////////////////////////////////////////////////// -// Permission reaches from 0 to 255 - -[USERS] - -Gamemaster=100 -Admin=255 -Trusted=30 -Niceplayer=10 -Falsegenesis=150 -//... -// Add your names here - - - +///////////////////////////////////////////////////////////// +// Player Permission Configuration file +///////////////////////////////////////////////////////////// +// Permission reaches from 0 to 255 + +[USERS] + +Gamemaster=100 +Admin=255 +Trusted=30 +Niceplayer=10 +Falsegenesis=150 +//... +// Add your names here + + + // rest is 0 automatically \ No newline at end of file diff --git a/bin/data/scp/class.scp b/bin/data/scp/class.scp index ca6505c..d5cc748 100644 --- a/bin/data/scp/class.scp +++ b/bin/data/scp/class.scp @@ -1,32 +1,32 @@ -[1] -name=Warrior - -[2] -name=Paladin - -[3] -name=Hunter - -[4] -name=Rogue - -[5] -name=Priest - -[6] -name=UNKNOWN CLASS(6) - -[7] -name=Shaman - -[8] -name=Mage - -[9] -name=Warlock - -[10] -name=UNKNOWN CLASS(10) - -[11] -name=Druid +[1] +name=Warrior + +[2] +name=Paladin + +[3] +name=Hunter + +[4] +name=Rogue + +[5] +name=Priest + +[6] +name=UNKNOWN CLASS(6) + +[7] +name=Shaman + +[8] +name=Mage + +[9] +name=Warlock + +[10] +name=UNKNOWN CLASS(10) + +[11] +name=Druid diff --git a/bin/data/scp/gender.scp b/bin/data/scp/gender.scp index 14a9f05..cc91951 100644 --- a/bin/data/scp/gender.scp +++ b/bin/data/scp/gender.scp @@ -1,10 +1,10 @@ -// define names of genders - -[0] -name=male - -[1] -name=female - -[2] -name=none +// define names of genders + +[0] +name=male + +[1] +name=female + +[2] +name=none diff --git a/bin/data/scp/language.scp b/bin/data/scp/language.scp index 18d37dd..17cf722 100644 --- a/bin/data/scp/language.scp +++ b/bin/data/scp/language.scp @@ -1,41 +1,41 @@ -[0] -name=Global - -[1] -name=Orcish - -[2] -name=Darnassian - -[3] -name=Taurahe - -[6] -name=Dwarvish - -[7] -name=Common - -[8] -name=Demonic - -[9] -name=Titan - -[10] -name=Thalassian - -[11] -name=Draconic - -[12] -name=Kalimag - -[13] -name=Gnomish - -[14] -name=Troll - -[33] -name=Gutterspeak +[0] +name=Global + +[1] +name=Orcish + +[2] +name=Darnassian + +[3] +name=Taurahe + +[6] +name=Dwarvish + +[7] +name=Common + +[8] +name=Demonic + +[9] +name=Titan + +[10] +name=Thalassian + +[11] +name=Draconic + +[12] +name=Kalimag + +[13] +name=Gnomish + +[14] +name=Troll + +[33] +name=Gutterspeak diff --git a/bin/data/scp/map.scp b/bin/data/scp/map.scp index e30f5d8..0a8c600 100644 --- a/bin/data/scp/map.scp +++ b/bin/data/scp/map.scp @@ -1,321 +1,321 @@ -#dbname=map -[0] -name_general=Azeroth -name=Eastern Kingdoms - -[1] -name_general=Kalimdor -name=Kalimdor - -[13] -name_general=test -name=Testing - -[25] -name_general=ScottTest -name=Scott Test - -[29] -name_general=Test -name=CashTest - -[30] -name_general=PVPZone01 -name=Alterac Valley - -[33] -name_general=Shadowfang -name=Shadowfang Keep - -[34] -name_general=StormwindJail -name=Stormwind Stockade - -[35] -name_general=StormwindPrison -name=StormwindPrison - -[36] -name_general=DeadminesInstance -name=Deadmines - -[37] -name_general=PVPZone02 -name=Azshara Crater - -[42] -name_general=Collin -name=Collin's Test - -[43] -name_general=WailingCaverns -name=Wailing Caverns - -[44] -name_general=Monastery -name= Monastery - -[47] -name_general=RazorfenKraulInstance -name=Razorfen Kraul - -[48] -name_general=Blackfathom -name=Blackfathom Deeps - -[70] -name_general=Uldaman -name=Uldaman - -[90] -name_general=GnomeragonInstance -name=Gnomeregan - -[109] -name_general=SunkenTemple -name=Sunken Temple - -[129] -name_general=RazorfenDowns -name=Razorfen Downs - -[169] -name_general=EmeraldDream -name=Emerald Dream - -[189] -name_general=MonasteryInstances -name=Scarlet Monastery - -[209] -name_general=TanarisInstance -name=Zul'Farrak - -[229] -name_general=BlackRockSpire -name=Blackrock Spire - -[230] -name_general=BlackrockDepths -name=Blackrock Depths - -[249] -name_general=OnyxiaLairInstance -name=Onyxia's Lair - -[269] -name_general=CavernsOfTime -name=Opening of the Dark Portal - -[289] -name_general=SchoolofNecromancy -name=Scholomance - -[309] -name_general=Zul'gurub -name=Zul'Gurub - -[329] -name_general=Stratholme -name=Stratholme - -[349] -name_general=Mauradon -name=Maraudon - -[369] -name_general=DeeprunTram -name=Deeprun Tram - -[389] -name_general=OrgrimmarInstance -name=Ragefire Chasm - -[409] -name_general=MoltenCore -name=Molten Core - -[429] -name_general=DireMaul -name=Dire Maul - -[449] -name_general=AlliancePVPBarracks -name=Alliance PVP Barracks - -[450] -name_general=HordePVPBarracks -name=Horde PVP Barracks - -[451] -name_general=development -name=Development Land - -[469] -name_general=BlackwingLair -name=Blackwing Lair - -[489] -name_general=PVPZone03 -name=Warsong Gulch - -[509] -name_general=AhnQiraj -name=Ruins of Ahn'Qiraj - -[529] -name_general=PVPZone04 -name=Arathi Basin - -[530] -name_general=Expansion01 -name=Outland - -[531] -name_general=AhnQirajTemple -name=Ahn'Qiraj Temple - -[532] -name_general=Karazahn -name=Karazhan - -[533] -name_general=Stratholme Raid -name=Naxxramas - -[534] -name_general=HyjalPast -name=The Battle for Mount Hyjal - -[540] -name_general=HellfireMilitary -name=Hellfire Citadel: The Shattered Halls - -[542] -name_general=HellfireDemon -name=Hellfire Citadel: The Blood Furnace - -[543] -name_general=HellfireRampart -name=Hellfire Citadel: Ramparts - -[544] -name_general=HellfireRaid -name=Magtheridon's Lair - -[545] -name_general=CoilfangPumping -name=Coilfang: The Steamvault - -[546] -name_general=CoilfangMarsh -name=Coilfang: The Underbog - -[547] -name_general=CoilfangDraenei -name=Coilfang: The Slave Pens - -[548] -name_general=CoilfangRaid -name=Coilfang: Serpentshrine Cavern - -[550] -name_general=TempestKeepRaid -name=Tempest Keep - -[552] -name_general=TempestKeepArcane -name=Tempest Keep: The Arcatraz - -[553] -name_general=TempestKeepAtrium -name=Tempest Keep: The Botanica - -[554] -name_general=TempestKeepFactory -name=Tempest Keep: The Mechanar - -[555] -name_general=AuchindounShadow -name=Auchindoun: Shadow Labyrinth - -[556] -name_general=AuchindounDemon -name=Auchindoun: Sethekk Halls - -[557] -name_general=AuchindounEthereal -name=Auchindoun: Mana-Tombs - -[558] -name_general=AuchindounDraenei -name=Auchindoun: Auchenai Crypts - -[559] -name_general=PVPZone05 -name=Nagrand Arena - -[560] -name_general=HillsbradPast -name=The Escape From Durnholde - -[562] -name_general=bladesedgearena -name=Blade's Edge Arena - -[564] -name_general=BlackTemple -name=Black Temple - -[565] -name_general=GruulsLair -name=Gruul's Lair - -[566] -name_general=NetherstormBG -name=Eye of the Storm - -[568] -name_general=ZulAman -name=Zul'Aman - -[572] -name_general=PVPLordaeron -name=Ruins of Lordaeron - -[582] -name_general=Transport176244 -name=Transport: Rut'theran to Auberdine - -[584] -name_general=Transport176231 -name=Transport: Menethil to Theramore - -[586] -name_general=Transport181645 -name=Transport: Exodar to Auberdine - -[587] -name_general=Transport177233 -name=Transport: Feathermoon Ferry - -[588] -name_general=Transport176310 -name=Transport: Menethil to Auberdine - -[589] -name_general=Transport175080 -name=Transport: Orgrimmar to Grom'Gol - -[590] -name_general=Transport176495 -name=Transport: Grom'Gol to Undercity - -[591] -name_general=Transport164871 -name=Transport: Undercity to Orgrimmar - -[593] -name_general=Transport20808 -name=Transport: Booty Bay to Ratchet - +#dbname=map +[0] +name_general=Azeroth +name=Eastern Kingdoms + +[1] +name_general=Kalimdor +name=Kalimdor + +[13] +name_general=test +name=Testing + +[25] +name_general=ScottTest +name=Scott Test + +[29] +name_general=Test +name=CashTest + +[30] +name_general=PVPZone01 +name=Alterac Valley + +[33] +name_general=Shadowfang +name=Shadowfang Keep + +[34] +name_general=StormwindJail +name=Stormwind Stockade + +[35] +name_general=StormwindPrison +name=StormwindPrison + +[36] +name_general=DeadminesInstance +name=Deadmines + +[37] +name_general=PVPZone02 +name=Azshara Crater + +[42] +name_general=Collin +name=Collin's Test + +[43] +name_general=WailingCaverns +name=Wailing Caverns + +[44] +name_general=Monastery +name= Monastery + +[47] +name_general=RazorfenKraulInstance +name=Razorfen Kraul + +[48] +name_general=Blackfathom +name=Blackfathom Deeps + +[70] +name_general=Uldaman +name=Uldaman + +[90] +name_general=GnomeragonInstance +name=Gnomeregan + +[109] +name_general=SunkenTemple +name=Sunken Temple + +[129] +name_general=RazorfenDowns +name=Razorfen Downs + +[169] +name_general=EmeraldDream +name=Emerald Dream + +[189] +name_general=MonasteryInstances +name=Scarlet Monastery + +[209] +name_general=TanarisInstance +name=Zul'Farrak + +[229] +name_general=BlackRockSpire +name=Blackrock Spire + +[230] +name_general=BlackrockDepths +name=Blackrock Depths + +[249] +name_general=OnyxiaLairInstance +name=Onyxia's Lair + +[269] +name_general=CavernsOfTime +name=Opening of the Dark Portal + +[289] +name_general=SchoolofNecromancy +name=Scholomance + +[309] +name_general=Zul'gurub +name=Zul'Gurub + +[329] +name_general=Stratholme +name=Stratholme + +[349] +name_general=Mauradon +name=Maraudon + +[369] +name_general=DeeprunTram +name=Deeprun Tram + +[389] +name_general=OrgrimmarInstance +name=Ragefire Chasm + +[409] +name_general=MoltenCore +name=Molten Core + +[429] +name_general=DireMaul +name=Dire Maul + +[449] +name_general=AlliancePVPBarracks +name=Alliance PVP Barracks + +[450] +name_general=HordePVPBarracks +name=Horde PVP Barracks + +[451] +name_general=development +name=Development Land + +[469] +name_general=BlackwingLair +name=Blackwing Lair + +[489] +name_general=PVPZone03 +name=Warsong Gulch + +[509] +name_general=AhnQiraj +name=Ruins of Ahn'Qiraj + +[529] +name_general=PVPZone04 +name=Arathi Basin + +[530] +name_general=Expansion01 +name=Outland + +[531] +name_general=AhnQirajTemple +name=Ahn'Qiraj Temple + +[532] +name_general=Karazahn +name=Karazhan + +[533] +name_general=Stratholme Raid +name=Naxxramas + +[534] +name_general=HyjalPast +name=The Battle for Mount Hyjal + +[540] +name_general=HellfireMilitary +name=Hellfire Citadel: The Shattered Halls + +[542] +name_general=HellfireDemon +name=Hellfire Citadel: The Blood Furnace + +[543] +name_general=HellfireRampart +name=Hellfire Citadel: Ramparts + +[544] +name_general=HellfireRaid +name=Magtheridon's Lair + +[545] +name_general=CoilfangPumping +name=Coilfang: The Steamvault + +[546] +name_general=CoilfangMarsh +name=Coilfang: The Underbog + +[547] +name_general=CoilfangDraenei +name=Coilfang: The Slave Pens + +[548] +name_general=CoilfangRaid +name=Coilfang: Serpentshrine Cavern + +[550] +name_general=TempestKeepRaid +name=Tempest Keep + +[552] +name_general=TempestKeepArcane +name=Tempest Keep: The Arcatraz + +[553] +name_general=TempestKeepAtrium +name=Tempest Keep: The Botanica + +[554] +name_general=TempestKeepFactory +name=Tempest Keep: The Mechanar + +[555] +name_general=AuchindounShadow +name=Auchindoun: Shadow Labyrinth + +[556] +name_general=AuchindounDemon +name=Auchindoun: Sethekk Halls + +[557] +name_general=AuchindounEthereal +name=Auchindoun: Mana-Tombs + +[558] +name_general=AuchindounDraenei +name=Auchindoun: Auchenai Crypts + +[559] +name_general=PVPZone05 +name=Nagrand Arena + +[560] +name_general=HillsbradPast +name=The Escape From Durnholde + +[562] +name_general=bladesedgearena +name=Blade's Edge Arena + +[564] +name_general=BlackTemple +name=Black Temple + +[565] +name_general=GruulsLair +name=Gruul's Lair + +[566] +name_general=NetherstormBG +name=Eye of the Storm + +[568] +name_general=ZulAman +name=Zul'Aman + +[572] +name_general=PVPLordaeron +name=Ruins of Lordaeron + +[582] +name_general=Transport176244 +name=Transport: Rut'theran to Auberdine + +[584] +name_general=Transport176231 +name=Transport: Menethil to Theramore + +[586] +name_general=Transport181645 +name=Transport: Exodar to Auberdine + +[587] +name_general=Transport177233 +name=Transport: Feathermoon Ferry + +[588] +name_general=Transport176310 +name=Transport: Menethil to Auberdine + +[589] +name_general=Transport175080 +name=Transport: Orgrimmar to Grom'Gol + +[590] +name_general=Transport176495 +name=Transport: Grom'Gol to Undercity + +[591] +name_general=Transport164871 +name=Transport: Undercity to Orgrimmar + +[593] +name_general=Transport20808 +name=Transport: Booty Bay to Ratchet + diff --git a/bin/data/scp/race.scp b/bin/data/scp/race.scp index 71eef42..1170896 100644 --- a/bin/data/scp/race.scp +++ b/bin/data/scp/race.scp @@ -1,129 +1,129 @@ -#dbname=race -[1] -model_m=49 -model_f=50 -name_short=Hu -faction=7 -name_general=Human -name=Human - -[2] -model_m=51 -model_f=52 -name_short=Or -faction=1 -name_general=Orc -name=Orc - -[3] -model_m=53 -model_f=54 -name_short=Dw -faction=7 -name_general=Dwarf -name=Dwarf - -[4] -model_m=55 -model_f=56 -name_short=Ni -faction=7 -name_general=NightElf -name=Night Elf - -[5] -model_m=57 -model_f=58 -name_short=Sc -faction=1 -name_general=Scourge -name=Undead - -[6] -model_m=59 -model_f=60 -name_short=Ta -faction=1 -name_general=Tauren -name=Tauren - -[7] -model_m=1563 -model_f=1564 -name_short=Gn -faction=7 -name_general=Gnome -name=Gnome - -[8] -model_m=1478 -model_f=1479 -name_short=Tr -faction=1 -name_general=Troll -name=Troll - -[9] -model_m=6894 -model_f=6895 -name_short=Go -faction=7 -name_general=Goblin -name=Goblin - -[10] -model_m=15476 -model_f=15475 -name_short=Be -faction=1 -name_general=BloodElf -name=Blood Elf - -[11] -model_m=16125 -model_f=16126 -name_short=Dr -faction=7 -name_general=Draenei -name=Draenei - -[12] -model_m=16981 -model_f=16980 -name_short=Fo -faction=7 -name_general=FelOrc -name=Fel Orc - -[13] -model_m=17402 -model_f=17403 -name_short=Na -faction=7 -name_general=Naga_ -name=Naga - -[14] -model_m=17576 -model_f=17577 -name_short=Br -faction=7 -name_general=Broken -name=Broken - -[15] -model_m=17578 -model_f=17579 -name_short=Sk -faction=7 -name_general=Skeleton -name=Skeleton - -[18] -model_m=21963 -model_f=21964 -name_short=Ft -faction=7 -name_general=ForestTroll -name=Forest Troll - +#dbname=race +[1] +model_m=49 +model_f=50 +name_short=Hu +faction=7 +name_general=Human +name=Human + +[2] +model_m=51 +model_f=52 +name_short=Or +faction=1 +name_general=Orc +name=Orc + +[3] +model_m=53 +model_f=54 +name_short=Dw +faction=7 +name_general=Dwarf +name=Dwarf + +[4] +model_m=55 +model_f=56 +name_short=Ni +faction=7 +name_general=NightElf +name=Night Elf + +[5] +model_m=57 +model_f=58 +name_short=Sc +faction=1 +name_general=Scourge +name=Undead + +[6] +model_m=59 +model_f=60 +name_short=Ta +faction=1 +name_general=Tauren +name=Tauren + +[7] +model_m=1563 +model_f=1564 +name_short=Gn +faction=7 +name_general=Gnome +name=Gnome + +[8] +model_m=1478 +model_f=1479 +name_short=Tr +faction=1 +name_general=Troll +name=Troll + +[9] +model_m=6894 +model_f=6895 +name_short=Go +faction=7 +name_general=Goblin +name=Goblin + +[10] +model_m=15476 +model_f=15475 +name_short=Be +faction=1 +name_general=BloodElf +name=Blood Elf + +[11] +model_m=16125 +model_f=16126 +name_short=Dr +faction=7 +name_general=Draenei +name=Draenei + +[12] +model_m=16981 +model_f=16980 +name_short=Fo +faction=7 +name_general=FelOrc +name=Fel Orc + +[13] +model_m=17402 +model_f=17403 +name_short=Na +faction=7 +name_general=Naga_ +name=Naga + +[14] +model_m=17576 +model_f=17577 +name_short=Br +faction=7 +name_general=Broken +name=Broken + +[15] +model_m=17578 +model_f=17579 +name_short=Sk +faction=7 +name_general=Skeleton +name=Skeleton + +[18] +model_m=21963 +model_f=21964 +name_short=Ft +faction=7 +name_general=ForestTroll +name=Forest Troll + diff --git a/bin/scripts/__core_chat.def b/bin/scripts/__core_chat.def index 57eb262..58e7aca 100644 --- a/bin/scripts/__core_chat.def +++ b/bin/scripts/__core_chat.def @@ -1,229 +1,229 @@ - -//----------------------------------------------------------- -#script=chan -//----------------------------------------------------------- -// Script to write on channels -// Arguments: -// ========== -// @def: text to write -// @0: channel name -// @1: language name/number - -#permission=10 -SET,lang ${@1} -DEFAULT,lang 0 -SENDCHATMESSAGE,14,{${lang}},{${@def}},{${@0}} -UNSET lang - - -//----------------------------------------------------------- -#script=cmd -#permission=255 -//----------------------------------------------------------- -// purpose: send a server command. -// args: -// @def: command to send - -SAY ${#CMDCHAR}${@def} - - -//----------------------------------------------------------- -#script=reply -#permission=255 -//----------------------------------------------------------- -// purpose: reply to the player that whispered last - -SET,player ${@thiswhisper_name} -SET,lang ${@0} -DEFAULT,lang 0 -SET,msg ${@def} - -WHISPER,{${player}},{${lang}} ${msg} - -UNSET player -UNSET lang -UNSET msg - - -//----------------------------------------------------------- -#script=s -#permission=0 -//----------------------------------------------------------- -// is the char equal to the char we use for commands? does the player have a permission lvl below 255? -IF ?{AND,?{string_is_command ${@def}} ?{SMALLER,?{GETPLAYERPERM ${@thiscmd_name}} 255}} - // yes: say a warning and the command the player wanted to use - SAY ${@thiscmd_name}: no permission to use commands [${@def}] - RETURN false -ELSE - // no: say the text as usual. - SAY,{${@0}} ${@def} - RETURN true -ENDIF - - -//----------------------------------------------------------- -#script=say -#permission=255 -//----------------------------------------------------------- -// purpose: say something. @0: language ID or name, @def: text to say -// setup some default values -SET,lang ${@0} -SET,msg ${@def} - -DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction} -DEFAULT,lang ${#DEFAULTLANG} - -LOGDEBUG * Saying '${msg}' in lang ${lang} - -SENDCHATMESSAGE,0,${lang},{${msg}} -UNSET lang -UNSET msg - - -//----------------------------------------------------------- -#script=sayguild -#permission=255 -//----------------------------------------------------------- -// purpose: say something to guild channel -// setup some default values -SET,lang ${@0} -SET,msg ${@def} - -default,lang 0 - -LOGDEBUG * Saying '${msg}' in lang ${lang} to guild - -SENDCHATMESSAGE,3,${lang},{${msg}} -UNSET lang -UNSET msg - -//----------------------------------------------------------- -#script=sayitem -#permission=0 -//----------------------------------------------------------- -// example script to "say" a clickable item -SAY ?{getchatitem ${@def}} - - -//----------------------------------------------------------- -#script=sayparty -#permission=255 -//----------------------------------------------------------- -// purpose: say something to party channel -// setup some default values -SET,lang ${@0} -SET,msg ${@def} - -default,lang 0 - -LOGDEBUG * Saying '${msg}' in lang ${lang} to party - -SENDCHATMESSAGE,1,${lang},{${msg}} -UNSET lang -UNSET msg - -//----------------------------------------------------------- -#script=sayred -//----------------------------------------------------------- -// example script how to output colored text -#permission=0 -SAY,{${@0}} |cffFF0000${@def} - -//----------------------------------------------------------- -#script=sayv -#permission=0 -//----------------------------------------------------------- -// purpose: say the value of a variable -// args: @0: language ID or name, @def: var name -SET,vn #${@caller}::${@def} -SET,vl ${@0} -DEFAULT,vl 0 - -IF ?{NOT ?{ISSET ${vn}}} - SAY,{${vl}} * Var '${@def}' not defined. -ELSE - SET,vv ${${vn}} - SAY,{${vl}} * Var '${@def}' = '${vv}' -ENDIF - -UNSET vv -UNSET vn -UNSET vl - - -//----------------------------------------------------------- -#script=whisper -#permission=255 -//----------------------------------------------------------- -// purpose: whisper text to a player. -// args: @0: player name to whisper to; @1: language to use; @def: text - -// setup some default values -SET,msg ${@def} -SET,player ${@0} -SET,lang ${@1} - -DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction} -DEFAULT,lang ${#DEFAULTLANG} - -LOGDEBUG * Whisp to '{${player}}' '{${msg}}' in lang '${lang}' - -SENDCHATMESSAGE,6,{${lang}},{${msg}},{${player}} -UNSET lang -UNSET msg -UNSET player - - -//------------------------------------------------------------- -#script=yell -#permission=255 -//------------------------------------------------------------- -// purpose: SHOUT! - -// setup some default values -SET,lang ${@0} -SET,msg ${@def} - -DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction} -DEFAULT,lang ${#DEFAULTLANG} - -LOGDEBUG * Yelling '${msg}' in lang ${lang} - -SENDCHATMESSAGE,5,${lang},{${msg}} -UNSET lang -UNSET msg - - -//----------------------------------------------------------- -#script=y -#permission=0 -//----------------------------------------------------------- -// is the char equal to the char we use for commands? does the player have a permission lvl below 255? -IF ?{AND,?{string_is_command ${@def}} ?{SMALLER,?{GETPLAYERPERM ${@thiscmd_name}} 255}} - // yes: say a warning and the command the player wanted to use - YELL ${@thiscmd_name}: no permission to use commands [${@def}] - RETURN false -ELSE - // no: say the text as usual. - YELL,{${@0}} ${@def} - RETURN true -ENDIF - - -//---------------------------------------------------------- -#script=me -#permission=0 -//---------------------------------------------------------- -// Send text emote. example: "me feels lolo" will result in "Pseuwow feels lolo" at other clients -SET,lang ${@0} -SET,msg ${@def} - -DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction} -DEFAULT,lang ${#DEFAULTLANG} - -LOGDEBUG * Me ${msg} (in lang ${lang}) - -SENDCHATMESSAGE,8,${lang},{${msg}} -UNSET lang -UNSET msg - + +//----------------------------------------------------------- +#script=chan +//----------------------------------------------------------- +// Script to write on channels +// Arguments: +// ========== +// @def: text to write +// @0: channel name +// @1: language name/number + +#permission=10 +SET,lang ${@1} +DEFAULT,lang 0 +SENDCHATMESSAGE,14,{${lang}},{${@def}},{${@0}} +UNSET lang + + +//----------------------------------------------------------- +#script=cmd +#permission=255 +//----------------------------------------------------------- +// purpose: send a server command. +// args: +// @def: command to send + +SAY ${#CMDCHAR}${@def} + + +//----------------------------------------------------------- +#script=reply +#permission=255 +//----------------------------------------------------------- +// purpose: reply to the player that whispered last + +SET,player ${@thiswhisper_name} +SET,lang ${@0} +DEFAULT,lang 0 +SET,msg ${@def} + +WHISPER,{${player}},{${lang}} ${msg} + +UNSET player +UNSET lang +UNSET msg + + +//----------------------------------------------------------- +#script=s +#permission=0 +//----------------------------------------------------------- +// is the char equal to the char we use for commands? does the player have a permission lvl below 255? +IF ?{AND,?{string_is_command ${@def}} ?{SMALLER,?{GETPLAYERPERM ${@thiscmd_name}} 255}} + // yes: say a warning and the command the player wanted to use + SAY ${@thiscmd_name}: no permission to use commands [${@def}] + RETURN false +ELSE + // no: say the text as usual. + SAY,{${@0}} ${@def} + RETURN true +ENDIF + + +//----------------------------------------------------------- +#script=say +#permission=255 +//----------------------------------------------------------- +// purpose: say something. @0: language ID or name, @def: text to say +// setup some default values +SET,lang ${@0} +SET,msg ${@def} + +DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction} +DEFAULT,lang ${#DEFAULTLANG} + +LOGDEBUG * Saying '${msg}' in lang ${lang} + +SENDCHATMESSAGE,0,${lang},{${msg}} +UNSET lang +UNSET msg + + +//----------------------------------------------------------- +#script=sayguild +#permission=255 +//----------------------------------------------------------- +// purpose: say something to guild channel +// setup some default values +SET,lang ${@0} +SET,msg ${@def} + +default,lang 0 + +LOGDEBUG * Saying '${msg}' in lang ${lang} to guild + +SENDCHATMESSAGE,3,${lang},{${msg}} +UNSET lang +UNSET msg + +//----------------------------------------------------------- +#script=sayitem +#permission=0 +//----------------------------------------------------------- +// example script to "say" a clickable item +SAY ?{getchatitem ${@def}} + + +//----------------------------------------------------------- +#script=sayparty +#permission=255 +//----------------------------------------------------------- +// purpose: say something to party channel +// setup some default values +SET,lang ${@0} +SET,msg ${@def} + +default,lang 0 + +LOGDEBUG * Saying '${msg}' in lang ${lang} to party + +SENDCHATMESSAGE,1,${lang},{${msg}} +UNSET lang +UNSET msg + +//----------------------------------------------------------- +#script=sayred +//----------------------------------------------------------- +// example script how to output colored text +#permission=0 +SAY,{${@0}} |cffFF0000${@def} + +//----------------------------------------------------------- +#script=sayv +#permission=0 +//----------------------------------------------------------- +// purpose: say the value of a variable +// args: @0: language ID or name, @def: var name +SET,vn #${@caller}::${@def} +SET,vl ${@0} +DEFAULT,vl 0 + +IF ?{NOT ?{ISSET ${vn}}} + SAY,{${vl}} * Var '${@def}' not defined. +ELSE + SET,vv ${${vn}} + SAY,{${vl}} * Var '${@def}' = '${vv}' +ENDIF + +UNSET vv +UNSET vn +UNSET vl + + +//----------------------------------------------------------- +#script=whisper +#permission=255 +//----------------------------------------------------------- +// purpose: whisper text to a player. +// args: @0: player name to whisper to; @1: language to use; @def: text + +// setup some default values +SET,msg ${@def} +SET,player ${@0} +SET,lang ${@1} + +DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction} +DEFAULT,lang ${#DEFAULTLANG} + +LOGDEBUG * Whisp to '{${player}}' '{${msg}}' in lang '${lang}' + +SENDCHATMESSAGE,6,{${lang}},{${msg}},{${player}} +UNSET lang +UNSET msg +UNSET player + + +//------------------------------------------------------------- +#script=yell +#permission=255 +//------------------------------------------------------------- +// purpose: SHOUT! + +// setup some default values +SET,lang ${@0} +SET,msg ${@def} + +DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction} +DEFAULT,lang ${#DEFAULTLANG} + +LOGDEBUG * Yelling '${msg}' in lang ${lang} + +SENDCHATMESSAGE,5,${lang},{${msg}} +UNSET lang +UNSET msg + + +//----------------------------------------------------------- +#script=y +#permission=0 +//----------------------------------------------------------- +// is the char equal to the char we use for commands? does the player have a permission lvl below 255? +IF ?{AND,?{string_is_command ${@def}} ?{SMALLER,?{GETPLAYERPERM ${@thiscmd_name}} 255}} + // yes: say a warning and the command the player wanted to use + YELL ${@thiscmd_name}: no permission to use commands [${@def}] + RETURN false +ELSE + // no: say the text as usual. + YELL,{${@0}} ${@def} + RETURN true +ENDIF + + +//---------------------------------------------------------- +#script=me +#permission=0 +//---------------------------------------------------------- +// Send text emote. example: "me feels lolo" will result in "Pseuwow feels lolo" at other clients +SET,lang ${@0} +SET,msg ${@def} + +DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction} +DEFAULT,lang ${#DEFAULTLANG} + +LOGDEBUG * Me ${msg} (in lang ${lang}) + +SENDCHATMESSAGE,8,${lang},{${msg}} +UNSET lang +UNSET msg + diff --git a/bin/scripts/__core_chatAI.def b/bin/scripts/__core_chatAI.def index 6ce586e..118d88f 100644 --- a/bin/scripts/__core_chatAI.def +++ b/bin/scripts/__core_chatAI.def @@ -1,177 +1,177 @@ - -// ----------------------------------- -#script=FlushChatAI -#permission=255 -// ----------------------------------- -// purpose: remove all registered chat AI scripts. usable as command. -logdebug flushing chat AI scripts. -lclean #processchatai::pattern_list -lclean #processchatai::script_list -lclean #processchatai::cond_list -lclean #processchatai::register_list - -// ---------------------------------- -#script=DropChatAIScript -// ---------------------------------- -// purpose: drop all entries registered to call the script specified in @def -set,amount 0 -loop - set,pos ?{lfind,#processchatai::script_list,true ${@def}} - if ?{not ?{strlen ${pos}}} - exitloop - endif - set,what_sc ?{lerase,#processchatai::script_list ${pos}} - set,what_cond ?{lerase,#processchatai::cond_list ${pos}} - set,what_ptn ?{lerase,#processchatai::pattern_list ${pos}} - lerase,#processchatai::register_list ${pos} - logdetail Dropped ChatAI for script '${what_sc}', cond [${what_cond}], pattern [${what_ptn}] - add,amount 1 -endloop -unset what_sc -unset what_cond -unset what_ptn -unset pos -return ${amount} - - -// ---------------------------------- -#script=processchatai -// ---------------------------------- -// purpose: iterate over registered AI scripts, test if the chat message matches a given condition, -// and execute appropriate script with predefined arguments. -// returns: false if the incoming chatmessage was invalid, else true -// TODO: get object name (player or creature) and pass it to the called scripts - -// if the list doesnt exist, it will return "", but this counts as false also -if ?{not ?{llen pattern_list}} - return -endif - -// filter out chat messages that came from us -if ?{equal,${@myguid} ${@2}} - return false -endif - -// filter out CHAT_MSG_WHISPER_INFORM ("whisper to ... : blah blah") -if ?{equal,${@0} 7} - return false -endif - -set,msg ?{lowercase ${@def}} - -default,filter { !?,;.:-_\\/<>()[]"$=+&#'*~`´^°} - -// split the msg into a list containing only words. remove special characters also. -lcsplit,wlist,{${filter}} ${msg} - -// remove empty entries -lclean,wlist - - -// obtain name of the language that was used -set,langname ?{GetSCPValue,language,${@1} name} -default,langname UNKNOWN - - -set,i 0 -set,len ?{llen pattern_list} - -loop - if ?{bigger_eq,${i} ${len}} - exitloop - endif - - set,script ?{lindex,script_list ${i}} - set,cond ?{lindex,cond_list ${i}} - set,pattern ?{lindex,pattern_list ${i}} - - set,call false - - if ?{equal,NONE ${cond}} - set,call true - else - if ?{equal,ANY ${cond}} - set,call ?{lcontains_ext,wlist,{ } ${pattern}} - else - if ?{equal,EXACT ${cond}} - set,call ?{equal,{${pattern}} ${msg}} - else - if ?{equal,EXACT_PARTIAL ${cond}} - set,call ?{strlen ?{strfind,{${pattern}} ${msg}}} - else - if ?{equal,ALL ${cond}} - // split the pattern into a list, then get its size. the amount of words matching the pattern list must be - // equal or greater then the amount of words in the pattern list - lcsplit,tmpl,{${filter}} ${pattern} - lclean,tmpl - set,pattln ?{llen tmpl} - set,matched ?{lcontains_ext,wlist,{ } ${pattern}} - set,call ?{greater_eq,${matched} ${pattln}} - unset pattln - unset matched - ldelete tmpl - endif - endif - endif - endif - endif - - if ${call} - // logdebug DEBUG: ChatAI: calling script ${script}, condition ${cond} matched. - ${script},{${@0}},{${@1}},{${@2}},{${@3}},{${langname}} ${@def} - //else - // logdebug DEBUG: ChatAI: NOT called script ${script}, condition ${cond} not matched. - endif - - add,i 1 -endloop - - - -// cleanup -ldelete wlist - -return true - - -// ---------------------------------- -#script=RegisterChatAIScript -// ---------------------------------- -// purpose: registers a custom script to handle an incoming chat message if a condition is matched. -// args: -// @def: word pattern (words are delimited with spaces) -// @0: script name that has to be called if the condition is matched -// @1: condition. allowed values are: -// ALL - the chat message must contain all words provided -// ANY - the chat message must contain any word provided -// ALL_ORDER - same like all, but in the order provided -- NOT YET IMPLEMENTED -// ALL_CONSECUTIVE - same like ALL_ORDER, but the words must follow exactly one after another -- NOT YET IMPLEMENTED -// EXACT - the chat message must be exactly equal to the string supplied. -// EXACT_PARTIAL - the chat message must contain the string supplied. -// NONE - the script will be always called; no testing is done. its up to the user how to deal with it. (default) -// note that @def is not case sensitive! - -if ?{not ?{strlen ${@0}}} - logerror Script error: RegisterChatAIScript: no function defined (called by '${@caller}') - return false -endif - -set,pattern ?{lowercase ${@def}} - -set,cond ?{uppercase ${@1}} -default,cond NONE - - -if ?{lcontains,#processchatai::register_list {[${@0};${pattern};${cond}]}} - logdebug Chat AI script already registered. script: '${@0}', condition: ${cond}, pattern: '${@def}' - return false -endif - -lpushback,#processchatai::pattern_list ${pattern} -lpushback,#processchatai::script_list ${@0} -lpushback,#processchatai::cond_list ${cond} -lpushback,#processchatai::register_list {[${@0};${pattern};${cond}]} - -logdetail Chat AI script registered. script: '${@0}', condition: ${cond}, pattern: '${pattern}' [now ?{llen #processchatai::pattern_list} registered] - -return true + +// ----------------------------------- +#script=FlushChatAI +#permission=255 +// ----------------------------------- +// purpose: remove all registered chat AI scripts. usable as command. +logdebug flushing chat AI scripts. +lclean #processchatai::pattern_list +lclean #processchatai::script_list +lclean #processchatai::cond_list +lclean #processchatai::register_list + +// ---------------------------------- +#script=DropChatAIScript +// ---------------------------------- +// purpose: drop all entries registered to call the script specified in @def +set,amount 0 +loop + set,pos ?{lfind,#processchatai::script_list,true ${@def}} + if ?{not ?{strlen ${pos}}} + exitloop + endif + set,what_sc ?{lerase,#processchatai::script_list ${pos}} + set,what_cond ?{lerase,#processchatai::cond_list ${pos}} + set,what_ptn ?{lerase,#processchatai::pattern_list ${pos}} + lerase,#processchatai::register_list ${pos} + logdetail Dropped ChatAI for script '${what_sc}', cond [${what_cond}], pattern [${what_ptn}] + add,amount 1 +endloop +unset what_sc +unset what_cond +unset what_ptn +unset pos +return ${amount} + + +// ---------------------------------- +#script=processchatai +// ---------------------------------- +// purpose: iterate over registered AI scripts, test if the chat message matches a given condition, +// and execute appropriate script with predefined arguments. +// returns: false if the incoming chatmessage was invalid, else true +// TODO: get object name (player or creature) and pass it to the called scripts + +// if the list doesnt exist, it will return "", but this counts as false also +if ?{not ?{llen pattern_list}} + return +endif + +// filter out chat messages that came from us +if ?{equal,${@myguid} ${@2}} + return false +endif + +// filter out CHAT_MSG_WHISPER_INFORM ("whisper to ... : blah blah") +if ?{equal,${@0} 7} + return false +endif + +set,msg ?{lowercase ${@def}} + +default,filter { !?,;.:-_\\/<>()[]"$=+&#'*~`´^°} + +// split the msg into a list containing only words. remove special characters also. +lcsplit,wlist,{${filter}} ${msg} + +// remove empty entries +lclean,wlist + + +// obtain name of the language that was used +set,langname ?{GetSCPValue,language,${@1} name} +default,langname UNKNOWN + + +set,i 0 +set,len ?{llen pattern_list} + +loop + if ?{bigger_eq,${i} ${len}} + exitloop + endif + + set,script ?{lindex,script_list ${i}} + set,cond ?{lindex,cond_list ${i}} + set,pattern ?{lindex,pattern_list ${i}} + + set,call false + + if ?{equal,NONE ${cond}} + set,call true + else + if ?{equal,ANY ${cond}} + set,call ?{lcontains_ext,wlist,{ } ${pattern}} + else + if ?{equal,EXACT ${cond}} + set,call ?{equal,{${pattern}} ${msg}} + else + if ?{equal,EXACT_PARTIAL ${cond}} + set,call ?{strlen ?{strfind,{${pattern}} ${msg}}} + else + if ?{equal,ALL ${cond}} + // split the pattern into a list, then get its size. the amount of words matching the pattern list must be + // equal or greater then the amount of words in the pattern list + lcsplit,tmpl,{${filter}} ${pattern} + lclean,tmpl + set,pattln ?{llen tmpl} + set,matched ?{lcontains_ext,wlist,{ } ${pattern}} + set,call ?{greater_eq,${matched} ${pattln}} + unset pattln + unset matched + ldelete tmpl + endif + endif + endif + endif + endif + + if ${call} + // logdebug DEBUG: ChatAI: calling script ${script}, condition ${cond} matched. + ${script},{${@0}},{${@1}},{${@2}},{${@3}},{${langname}} ${@def} + //else + // logdebug DEBUG: ChatAI: NOT called script ${script}, condition ${cond} not matched. + endif + + add,i 1 +endloop + + + +// cleanup +ldelete wlist + +return true + + +// ---------------------------------- +#script=RegisterChatAIScript +// ---------------------------------- +// purpose: registers a custom script to handle an incoming chat message if a condition is matched. +// args: +// @def: word pattern (words are delimited with spaces) +// @0: script name that has to be called if the condition is matched +// @1: condition. allowed values are: +// ALL - the chat message must contain all words provided +// ANY - the chat message must contain any word provided +// ALL_ORDER - same like all, but in the order provided -- NOT YET IMPLEMENTED +// ALL_CONSECUTIVE - same like ALL_ORDER, but the words must follow exactly one after another -- NOT YET IMPLEMENTED +// EXACT - the chat message must be exactly equal to the string supplied. +// EXACT_PARTIAL - the chat message must contain the string supplied. +// NONE - the script will be always called; no testing is done. its up to the user how to deal with it. (default) +// note that @def is not case sensitive! + +if ?{not ?{strlen ${@0}}} + logerror Script error: RegisterChatAIScript: no function defined (called by '${@caller}') + return false +endif + +set,pattern ?{lowercase ${@def}} + +set,cond ?{uppercase ${@1}} +default,cond NONE + + +if ?{lcontains,#processchatai::register_list {[${@0};${pattern};${cond}]}} + logdebug Chat AI script already registered. script: '${@0}', condition: ${cond}, pattern: '${@def}' + return false +endif + +lpushback,#processchatai::pattern_list ${pattern} +lpushback,#processchatai::script_list ${@0} +lpushback,#processchatai::cond_list ${cond} +lpushback,#processchatai::register_list {[${@0};${pattern};${cond}]} + +logdetail Chat AI script registered. script: '${@0}', condition: ${cond}, pattern: '${pattern}' [now ?{llen #processchatai::pattern_list} registered] + +return true diff --git a/bin/scripts/__core_eventstubs.def b/bin/scripts/__core_eventstubs.def index 3f34d44..8045c84 100644 --- a/bin/scripts/__core_eventstubs.def +++ b/bin/scripts/__core_eventstubs.def @@ -1,114 +1,114 @@ - -// ----==== CHAT MESSAGES ====---- -// ------------------------------------------- -#script=_onchatmessage -// purpose: do something if specific chat messages are recieved. -// args: -// @def: chat message text -// @0: message type id (check ChatMsg enum in src/Client/SharedDefines.h) -// @1: language id (also defined in SharedDefines.h), alternatively look up bin/data/scp/language.scp -// @2: GUID of the player or creature this msg came from -// @3: channel name. empty string if the chat message was not sent in a channel (for example say, yell or whisper) -//-------------------------------------------- -processchatai,{${@0}},{${@1}},{${@2}},{${@3}} ${@def} // this is required for the ChatAI script to work - -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - - -// ----==== TELEPORTATION ====---- - -#script=_onteleport -// @def: [far teleport=true, else false] -// @0: [far teleport: map ID, else teleported GUID] -// @1: X position -// @2: Y position -// @3: Z position -// @4: Orientation - -//- script content here... - - -// ----==== GUI RELATED ====---- - -#script=_onguiclose -// no args. gets called when the GUI is closed. -if ?{GetVar #EXITONGUICLOSE} - exit -endif - - -// ----==== OBJECT HANDLING ====---- - -#script=_onobjectcreate -// @def: GUID of created object -// @0 TypeID of created object -// The object can be accessed with GetName, GetEntry, GetObjectType, GetObjectValue, GetRace, GetClass, ... via the guid - -//- script content here... - - - -#script=_onobjectdelete -// @def: GUID of deleted object -// @0: TypeID of deleted object -// @1: [out of range object deletion=true, else false] -// The object can be accessed with the object handling functions listed above. -// It will be deleted right after handling this script. - -//- script content here... - - - - -// ----==== ENTERING/LEAVING WORLD ====---- - -#script=_leaveworld -// no args. gets called when the world is left. - -//- script content here... - - -#script=_enterworld -// no args. called when the world is entered -log * World entered! -say [${@version_short}] login successful. -emote 126 // = TEXTEMOTE_READY -joinchannel General -joinchannel Trade -joinchannel LookingForGroup -castspell 836 // LoginEffect - - - -// ----==== IN-GAME SCRIPT COMMANDS ====---- - -#script=_nopermission -// this script gets executed if a player tries to give pseuwow a command but is not allowed to -// Arguments: -// ========== -// @0 : name of the player who wanted to execute a command -// @1 : permission level of this user -// @2 : permission level needed to execute the script -// @3 : name of the script that should get executed - -SAY Forget it, ${@0}, you have only permission ${@1} but need ${@2} to run the script '${@3}' -LOG Player '${@0}' (p:${@1}) wanted to execute '${@3}' (p:${@2}) -EMOTE 66 // say NO! - - - -// ----==== INTERNAL/MISC ====---- - -#script=_onworldsessioncreate -// no args. called when an instance of the WorldSession class is created - -//- script content here - - -#script=_onworldsessiondelete -// no args. called when an instance of the WorldSession class is deleted - -//- script content here - - - + +// ----==== CHAT MESSAGES ====---- +// ------------------------------------------- +#script=_onchatmessage +// purpose: do something if specific chat messages are recieved. +// args: +// @def: chat message text +// @0: message type id (check ChatMsg enum in src/Client/SharedDefines.h) +// @1: language id (also defined in SharedDefines.h), alternatively look up bin/data/scp/language.scp +// @2: GUID of the player or creature this msg came from +// @3: channel name. empty string if the chat message was not sent in a channel (for example say, yell or whisper) +//-------------------------------------------- +processchatai,{${@0}},{${@1}},{${@2}},{${@3}} ${@def} // this is required for the ChatAI script to work + +// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + + +// ----==== TELEPORTATION ====---- + +#script=_onteleport +// @def: [far teleport=true, else false] +// @0: [far teleport: map ID, else teleported GUID] +// @1: X position +// @2: Y position +// @3: Z position +// @4: Orientation + +//- script content here... + + +// ----==== GUI RELATED ====---- + +#script=_onguiclose +// no args. gets called when the GUI is closed. +if ?{GetVar #EXITONGUICLOSE} + exit +endif + + +// ----==== OBJECT HANDLING ====---- + +#script=_onobjectcreate +// @def: GUID of created object +// @0 TypeID of created object +// The object can be accessed with GetName, GetEntry, GetObjectType, GetObjectValue, GetRace, GetClass, ... via the guid + +//- script content here... + + + +#script=_onobjectdelete +// @def: GUID of deleted object +// @0: TypeID of deleted object +// @1: [out of range object deletion=true, else false] +// The object can be accessed with the object handling functions listed above. +// It will be deleted right after handling this script. + +//- script content here... + + + + +// ----==== ENTERING/LEAVING WORLD ====---- + +#script=_leaveworld +// no args. gets called when the world is left. + +//- script content here... + + +#script=_enterworld +// no args. called when the world is entered +log * World entered! +say [${@version_short}] login successful. +emote 126 // = TEXTEMOTE_READY +joinchannel General +joinchannel Trade +joinchannel LookingForGroup +castspell 836 // LoginEffect + + + +// ----==== IN-GAME SCRIPT COMMANDS ====---- + +#script=_nopermission +// this script gets executed if a player tries to give pseuwow a command but is not allowed to +// Arguments: +// ========== +// @0 : name of the player who wanted to execute a command +// @1 : permission level of this user +// @2 : permission level needed to execute the script +// @3 : name of the script that should get executed + +SAY Forget it, ${@0}, you have only permission ${@1} but need ${@2} to run the script '${@3}' +LOG Player '${@0}' (p:${@1}) wanted to execute '${@3}' (p:${@2}) +EMOTE 66 // say NO! + + + +// ----==== INTERNAL/MISC ====---- + +#script=_onworldsessioncreate +// no args. called when an instance of the WorldSession class is created + +//- script content here + + +#script=_onworldsessiondelete +// no args. called when an instance of the WorldSession class is deleted + +//- script content here + + + diff --git a/bin/scripts/__core_func.def b/bin/scripts/__core_func.def index 006f59b..11156ec 100644 --- a/bin/scripts/__core_func.def +++ b/bin/scripts/__core_func.def @@ -1,176 +1,176 @@ -// core functions. required by other scripts to run! -#onload - log * Loading core scripts... -#/onload - - -//-------------------------------------------------------- -#script=append -//-------------------------------------------------------- -// usage: append text to a string. -// args: -// @def: text to append -// @0: variable to which the text should be appended - -// get the var name if the original variable -SET,v #${@caller}::${@0} -// if it has not been set before, init it now -DEFAULT,${v} -// append to the original var. inner ${..} gets the var name, outer ${..} get the value of the var name we just got. -SET,${v} ${${v}}${@def} -// remove the name placeholder -UNSET v - - -//-------------------------------------------------------- -#script=exloadscp -#permission=255 -//-------------------------------------------------------- -if ?{fileexists ${@def}} - loadscp,{${@0}} ${@def} -else - logdebug skipped loading of non-existent file '${@def}' -endif - - -//-------------------------------------------------------- -#script=loadallscp -#permission=255 -//-------------------------------------------------------- -LOG * Loading SCP data storages... - -// example: -// LOADSCP,test data/test.scp - -// load default databases -LOADSCP,class data/scp/class.scp -LOADSCP,gender data/scp/gender.scp -LOADSCP,language data/scp/language.scp -LOADSCP,map data/scp/map.scp -LOADSCP,race data/scp/race.scp - -// load extended databases if present. -EXLOADSCP,sound data/scp/sound.scp -EXLOADSCP,emote data/scp/emote.scp -EXLOADSCP,zone data/scp/zone.scp - -LOG * SCP loaded. - - -//------------------------------------------------- -#script=string_is_command -//------------------------------------------------- -// purpose: detect if @def might be a server command. - -// split all chars we have set in the config files to a list. -lsplit,#CMDCHARLIST ${#OTHER_CMD_CHARS} - -// find out the first char of the string -SET,c ?{SUBSTR,1 ${@def}} - -// does the char list contain our first char? if yes it can trigger a server command. -if ?{lcontains,#CMDCHARLIST ${c}} - unset c - return true -endif -unset c -return false - - -//-------------------------------------------------------- -#script=normalize_name -//-------------------------------------------------------- -// uppercases first char, lowercases rest -set,name ?{uppercase ?{substr,1 ${@def}}} -set,len ?{strlen ${@def}} -sub,len 1 -append,name ?{lowercase ?{substr,${len},1 ${@def}}} -return ${name} - -//--------------------------------------------------------- -#script=globname -//--------------------------------------------------------- -// purpose: returns the global name of a variable -// args: @def: var name, @0 (optional): name of the intended parent func -set,c ?{substr,1 ${@def}} -// it is a global var if the varname starts with # or there is no caller script -if ?{or,?{equal,# ${c}} ?{not ${@caller}}} - return ${@def} -endif -set,top ${@0} -default,top ${@caller} -return #${top}::${@def} - -//--------------------------------------------------------- -#script=sclistname -//--------------------------------------------------------- -// purpose: returns the global name of a script list -// args: @def: script name -set,c ?{substr,1 ${@def}} -// it is a global name already if the script name starts with # or there is no caller script -if ?{or,?{equal,# ${c}} ?{not ${@caller}}} - return ${@def} -endif -return #DEFSCRIPT::SCRIPT::${@def} - -//--------------------------------------------------------- -#script=getvar -//--------------------------------------------------------- -// purpose: returns the value of a variable. if the variable hasnt been set return empty string. -set,top ${@caller} -default,top # -set,v ?{globname,${top} ${@def}} -unset top -//out getvar: v=${v} -> ${${v}} -if ?{isset ${v}} - return ${${v}} -endif -return - -//--------------------------------------------------------- -#script=reverse -//--------------------------------------------------------- -// purpose: reverse a srtring -// args: @def: string to reverse -// returns: reversed string - -set,outstr -set,elems ?{lsplit,mylist ${@def}} -set,i ${elems} -loop - sub,i 1 - if ?{equal,${i} -1} - exitloop - endif - append,outstr ?{lindex,mylist ${i}} -endloop -ldelete mylist -return ${outstr} - -//-------------------------------------------------------- -#script=appenddef -//-------------------------------------------------------- -// purpose: append a line of code to a script -// args: @0: script name; @def: code -// be sure that the code you append is valid and working DefScript code! (no if/loop block mismatches, etc) -// if you need to use { or }, escape them: "appenddef,myscript log Myscript: finished, @def=$\{@def\}" -set,sc ?{lowercase ${@0}} -if ?{and,{?{strlen ${@def}}} ?{strlen ${sc}}} - if ?{not ?{ScriptExists ${sc}}} - createdef ${sc} - endif - - lpushback,{?{sclistname ${sc}}} ${@def} - unset cmd -endif - -//--------------------------------------------------------- -#script=scripthasline -//--------------------------------------------------------- -// purpose: check if a script has a certain line of code (exact match) -// args: -// @0: script name -// @def: line of text to look for - -return ?{lcontains,{?{sclistname ?{lowercase ${@0}}}} ${@def}} - +// core functions. required by other scripts to run! +#onload + log * Loading core scripts... +#/onload + + +//-------------------------------------------------------- +#script=append +//-------------------------------------------------------- +// usage: append text to a string. +// args: +// @def: text to append +// @0: variable to which the text should be appended + +// get the var name if the original variable +SET,v #${@caller}::${@0} +// if it has not been set before, init it now +DEFAULT,${v} +// append to the original var. inner ${..} gets the var name, outer ${..} get the value of the var name we just got. +SET,${v} ${${v}}${@def} +// remove the name placeholder +UNSET v + + +//-------------------------------------------------------- +#script=exloadscp +#permission=255 +//-------------------------------------------------------- +if ?{fileexists ${@def}} + loadscp,{${@0}} ${@def} +else + logdebug skipped loading of non-existent file '${@def}' +endif + + +//-------------------------------------------------------- +#script=loadallscp +#permission=255 +//-------------------------------------------------------- +LOG * Loading SCP data storages... + +// example: +// LOADSCP,test data/test.scp + +// load default databases +LOADSCP,class data/scp/class.scp +LOADSCP,gender data/scp/gender.scp +LOADSCP,language data/scp/language.scp +LOADSCP,map data/scp/map.scp +LOADSCP,race data/scp/race.scp + +// load extended databases if present. +EXLOADSCP,sound data/scp/sound.scp +EXLOADSCP,emote data/scp/emote.scp +EXLOADSCP,zone data/scp/zone.scp + +LOG * SCP loaded. + + +//------------------------------------------------- +#script=string_is_command +//------------------------------------------------- +// purpose: detect if @def might be a server command. + +// split all chars we have set in the config files to a list. +lsplit,#CMDCHARLIST ${#OTHER_CMD_CHARS} + +// find out the first char of the string +SET,c ?{SUBSTR,1 ${@def}} + +// does the char list contain our first char? if yes it can trigger a server command. +if ?{lcontains,#CMDCHARLIST ${c}} + unset c + return true +endif +unset c +return false + + +//-------------------------------------------------------- +#script=normalize_name +//-------------------------------------------------------- +// uppercases first char, lowercases rest +set,name ?{uppercase ?{substr,1 ${@def}}} +set,len ?{strlen ${@def}} +sub,len 1 +append,name ?{lowercase ?{substr,${len},1 ${@def}}} +return ${name} + +//--------------------------------------------------------- +#script=globname +//--------------------------------------------------------- +// purpose: returns the global name of a variable +// args: @def: var name, @0 (optional): name of the intended parent func +set,c ?{substr,1 ${@def}} +// it is a global var if the varname starts with # or there is no caller script +if ?{or,?{equal,# ${c}} ?{not ${@caller}}} + return ${@def} +endif +set,top ${@0} +default,top ${@caller} +return #${top}::${@def} + +//--------------------------------------------------------- +#script=sclistname +//--------------------------------------------------------- +// purpose: returns the global name of a script list +// args: @def: script name +set,c ?{substr,1 ${@def}} +// it is a global name already if the script name starts with # or there is no caller script +if ?{or,?{equal,# ${c}} ?{not ${@caller}}} + return ${@def} +endif +return #DEFSCRIPT::SCRIPT::${@def} + +//--------------------------------------------------------- +#script=getvar +//--------------------------------------------------------- +// purpose: returns the value of a variable. if the variable hasnt been set return empty string. +set,top ${@caller} +default,top # +set,v ?{globname,${top} ${@def}} +unset top +//out getvar: v=${v} -> ${${v}} +if ?{isset ${v}} + return ${${v}} +endif +return + +//--------------------------------------------------------- +#script=reverse +//--------------------------------------------------------- +// purpose: reverse a srtring +// args: @def: string to reverse +// returns: reversed string + +set,outstr +set,elems ?{lsplit,mylist ${@def}} +set,i ${elems} +loop + sub,i 1 + if ?{equal,${i} -1} + exitloop + endif + append,outstr ?{lindex,mylist ${i}} +endloop +ldelete mylist +return ${outstr} + +//-------------------------------------------------------- +#script=appenddef +//-------------------------------------------------------- +// purpose: append a line of code to a script +// args: @0: script name; @def: code +// be sure that the code you append is valid and working DefScript code! (no if/loop block mismatches, etc) +// if you need to use { or }, escape them: "appenddef,myscript log Myscript: finished, @def=$\{@def\}" +set,sc ?{lowercase ${@0}} +if ?{and,{?{strlen ${@def}}} ?{strlen ${sc}}} + if ?{not ?{ScriptExists ${sc}}} + createdef ${sc} + endif + + lpushback,{?{sclistname ${sc}}} ${@def} + unset cmd +endif + +//--------------------------------------------------------- +#script=scripthasline +//--------------------------------------------------------- +// purpose: check if a script has a certain line of code (exact match) +// args: +// @0: script name +// @def: line of text to look for + +return ?{lcontains,{?{sclistname ?{lowercase ${@0}}}} ${@def}} + diff --git a/bin/scripts/__core_funstuff.def b/bin/scripts/__core_funstuff.def index 70c7f6d..20a2cdb 100644 --- a/bin/scripts/__core_funstuff.def +++ b/bin/scripts/__core_funstuff.def @@ -1,125 +1,125 @@ - - -//------------------------------------------------- -#script=slap -#permission=255 -//------------------------------------------------- -// purpose: let a player fly. (at least works on MaNGOS) -// args: @def: player name -// returns: guid of the targeted player, else false. empty string if we are not in the world. - -// we can use this script only if we are in the world -if ?{not ${@inworld}} - logerror Can't slap anything if i am not in the world! - return -endif - -// normalize player name. first char uppercased, rest lowercased. -set,name ?{normalize_name ${@def}} - -// target the player. if targeting was successful, cast spell "Knockback 500". -set,t ?{target ${name}} -if ${t} - logdebug slapping player '${name}' - castspell 11027 - target -else - logerror Can't target player '${name}' -endif - -unset name - -return ${t} - - - -//------------------------------------------------ -#script=toleet -//------------------------------------------------ -// purpose: convert any text into leetspeak [1337sp34k] -// args: @def: the text to convert -// returns: leetspeak^^ - -#onload - // this can be used by other scripts to check if we have loaded this script - set,#HAVE_LEET true -#endonload - -// empty the string where the leet will be stored -set,str -// total length of the string to convert -set,l ?{strlen ${@def}} -// position counter -set,x 0 - -loop - - // check if we have reached the end of the string - if ?{bigger,${x} ${l}} - exitloop - endif - - // c stores current char (@def at position x); c2 is the same char but always lowercased - set,c ?{substr,1,${x} ${@def}} - set,c2 ?{lowercase ${c}} - - // conversion functions: - - // note that "+" is a variable name here! - // it will store the "new" char if c/c2 could be converted - - if ?{equal,${c2} a} - set,+ 4 - endif - if ?{equal,${c2} e} - set,+ 3 - endif - if ?{equal,${c2} i} - set,+ ! - endif - if ?{equal,${c2} l} - set,+ 1 - endif - if ?{equal,${c2} t} - set,+ 7 - endif - if ?{equal,${c2} s} - set,+ 5 - endif - if ?{equal,${c2} o} - set,+ 0 - endif - if ?{equal,${c2} f} - set,+ ph - endif - if ?{equal,${c2} h} - set,+ # - endif - if ?{equal,${c} Z} - set,+ 7 - endif - if ?{equal,${c} R} - set,+ 2 - endif - if ?{equal,${c} B} - set,+ <3 - endif - - // if var "+" is still empty, default it to our current char - default,+ ${c} - // and append it to the final output - append,str ${+} - // finally delete it again - unset + - // and increase the counter by 1 - add,x 1 -endloop - -unset l -unset x -unset c -unset c2 - -return ${str} - - + + +//------------------------------------------------- +#script=slap +#permission=255 +//------------------------------------------------- +// purpose: let a player fly. (at least works on MaNGOS) +// args: @def: player name +// returns: guid of the targeted player, else false. empty string if we are not in the world. + +// we can use this script only if we are in the world +if ?{not ${@inworld}} + logerror Can't slap anything if i am not in the world! + return +endif + +// normalize player name. first char uppercased, rest lowercased. +set,name ?{normalize_name ${@def}} + +// target the player. if targeting was successful, cast spell "Knockback 500". +set,t ?{target ${name}} +if ${t} + logdebug slapping player '${name}' + castspell 11027 + target +else + logerror Can't target player '${name}' +endif + +unset name + +return ${t} + + + +//------------------------------------------------ +#script=toleet +//------------------------------------------------ +// purpose: convert any text into leetspeak [1337sp34k] +// args: @def: the text to convert +// returns: leetspeak^^ + +#onload + // this can be used by other scripts to check if we have loaded this script + set,#HAVE_LEET true +#endonload + +// empty the string where the leet will be stored +set,str +// total length of the string to convert +set,l ?{strlen ${@def}} +// position counter +set,x 0 + +loop + + // check if we have reached the end of the string + if ?{bigger,${x} ${l}} + exitloop + endif + + // c stores current char (@def at position x); c2 is the same char but always lowercased + set,c ?{substr,1,${x} ${@def}} + set,c2 ?{lowercase ${c}} + + // conversion functions: + + // note that "+" is a variable name here! + // it will store the "new" char if c/c2 could be converted + + if ?{equal,${c2} a} + set,+ 4 + endif + if ?{equal,${c2} e} + set,+ 3 + endif + if ?{equal,${c2} i} + set,+ ! + endif + if ?{equal,${c2} l} + set,+ 1 + endif + if ?{equal,${c2} t} + set,+ 7 + endif + if ?{equal,${c2} s} + set,+ 5 + endif + if ?{equal,${c2} o} + set,+ 0 + endif + if ?{equal,${c2} f} + set,+ ph + endif + if ?{equal,${c2} h} + set,+ # + endif + if ?{equal,${c} Z} + set,+ 7 + endif + if ?{equal,${c} R} + set,+ 2 + endif + if ?{equal,${c} B} + set,+ <3 + endif + + // if var "+" is still empty, default it to our current char + default,+ ${c} + // and append it to the final output + append,str ${+} + // finally delete it again + unset + + // and increase the counter by 1 + add,x 1 +endloop + +unset l +unset x +unset c +unset c2 + +return ${str} + + diff --git a/bin/scripts/__core_hookHelper.def b/bin/scripts/__core_hookHelper.def index 8ce1bd0..0081ca6 100644 --- a/bin/scripts/__core_hookHelper.def +++ b/bin/scripts/__core_hookHelper.def @@ -1,150 +1,150 @@ - -#script=hookhelper -#onload -set,CurScript -#/onload - -#script=IsHooked -// @def: script name -// [@0: hook name / name of script that hooked script in @def] -set,sc ${@0} -default,sc ${@caller} -return ?{ScriptHasLine,{${@def}} #tag:hook:${sc}} - -#script=HookStart -// @def: script name -// [@0: calling script] -set,c ${@0} -default,c ${@caller} -appenddef,{${@def}} #tag:hook:${c} -set,{#hookhelper::CurScript} ${@def} - -#script=HookEnd -// [@def: name of script that was hooked] -// [@0: name of calling script] -set,sc ${@def} -default,sc ${#hookhelper::CurScript} -set,c ${@0} -default,c ${@caller} -appenddef,{${sc}} #tag:hook-end -set,#hookhelper::CurScript -unset ${sc} -unset sc - -#script=HookAdd -// @def: script line -// [@0: script name. default: last script passed to HookStart] -set,sc ${@0} -default,sc ${#hookhelper::CurScript} -if ?{not ?{strlen ${sc}}} - return -endif -appenddef,{${sc}} ${@def} -unset sc - -#script=HookAddList -// @def: list name -// [@0: script name. default: last script passed to HookStart] -// [@1: name of calling script] -set,sc ${@0} -set,c ${@1} -default,c ${@caller} -set,l ?{globname,{${c}} ${@def}} -default,sc ${#hookhelper::CurScript} -if ?{not ?{strlen ${sc}}} - return -endif -set,i 0 -loop - if ?{bigger_eq,${i} ?{llen ${l}}} - exitloop - endif - HookAdd,{${sc}} ?{lindex,{${l}} ${i}} - add,i 1 -endloop -unset sc - -#script=HookStartOpcode -// @def: opcode name -// [@0: calling script] -set,c ${@0} -default,c ${@caller} -HookStart,{${c}} OPCODE::${@def} - -#script=UnHook -// @def: name of script where to remove hook from -// [@0: hook name (usually name of script that installed the hook). default: name of calling script] -set,target ?{lowercase ${@def}} -if ?{not ?{scriptexists ${target}}} - logerror UnHook called for nonexisting script '${target}' by '${@caller}' -endif -set,sc ${@0} -default,sc ${@caller} -set,sc ?{lowercase ${sc}} -set,sl ?{sclistname ${target}} -set,hn #tag:hook:${sc} -set,hne #tag:hook-end -//logdebug -- sl='${sl}' hn='${hn}' hne='${hne}' -loop - if ?{not ?{IsHooked,{${sc}} ${target}}} - //logdebug -- unhook done - exitloop - endif - set,p ?{lfind,{${sl}} ${hn}} - set,line ?{lindex,{${sl}} ${p}} - //logdebug -- line[${p}] = ${line} - if ?{strlen ${p}} // p is empty string if the line wasnt found - loop - set,line2 ?{lerase,{${sl}} ${p}} - //logdebug -- removed: '${line2}' - if ?{equal,{${line2}} ${hne}} - exitloop - endif - endloop - endif -endloop -unset sl -unset hn -unset hne -unset sc - -#script=UnHookOpcode -// @def: opcode name -// [@0: name of calling script] -set,sc ${@0} -default,sc ${@caller} -UnHook,{${sc}} OPCODE::${@def} - -#script=UnHookAll -// @def: name of script to remove all hooks from -// [@0: name of calling script] -set,sc ${@0} -set,sl ?{sclistname ${@def}} -set,hn #tag:hook: -set,hne #tag:hook-end -set,i 0 -set,hookcode false -loop - set,erased false - if ?{bigger_eq,${i} ?{llen ${sl}}} - exitloop - endif - set,line ?{lindex,{${sl}} ${i}} - if ?{equal,{${hn}} ?{substr,?{strlen ${hn}} ${line}}} - set,hookcode true - else - if ?{equal,{${hne}} ?{substr,?{strlen ${hn}} ${line}}} - lerase,{${sl}} ${i} - set,hookcode false - set,erased true - endif - endif - - if ${hookcode} - lerase,{${sl}} ${i} - set,erased true - endif - if ?{not ${erased}} - add,i 1 - endif -endloop + +#script=hookhelper +#onload +set,CurScript +#/onload + +#script=IsHooked +// @def: script name +// [@0: hook name / name of script that hooked script in @def] +set,sc ${@0} +default,sc ${@caller} +return ?{ScriptHasLine,{${@def}} #tag:hook:${sc}} + +#script=HookStart +// @def: script name +// [@0: calling script] +set,c ${@0} +default,c ${@caller} +appenddef,{${@def}} #tag:hook:${c} +set,{#hookhelper::CurScript} ${@def} + +#script=HookEnd +// [@def: name of script that was hooked] +// [@0: name of calling script] +set,sc ${@def} +default,sc ${#hookhelper::CurScript} +set,c ${@0} +default,c ${@caller} +appenddef,{${sc}} #tag:hook-end +set,#hookhelper::CurScript +unset ${sc} +unset sc + +#script=HookAdd +// @def: script line +// [@0: script name. default: last script passed to HookStart] +set,sc ${@0} +default,sc ${#hookhelper::CurScript} +if ?{not ?{strlen ${sc}}} + return +endif +appenddef,{${sc}} ${@def} +unset sc + +#script=HookAddList +// @def: list name +// [@0: script name. default: last script passed to HookStart] +// [@1: name of calling script] +set,sc ${@0} +set,c ${@1} +default,c ${@caller} +set,l ?{globname,{${c}} ${@def}} +default,sc ${#hookhelper::CurScript} +if ?{not ?{strlen ${sc}}} + return +endif +set,i 0 +loop + if ?{bigger_eq,${i} ?{llen ${l}}} + exitloop + endif + HookAdd,{${sc}} ?{lindex,{${l}} ${i}} + add,i 1 +endloop +unset sc + +#script=HookStartOpcode +// @def: opcode name +// [@0: calling script] +set,c ${@0} +default,c ${@caller} +HookStart,{${c}} OPCODE::${@def} + +#script=UnHook +// @def: name of script where to remove hook from +// [@0: hook name (usually name of script that installed the hook). default: name of calling script] +set,target ?{lowercase ${@def}} +if ?{not ?{scriptexists ${target}}} + logerror UnHook called for nonexisting script '${target}' by '${@caller}' +endif +set,sc ${@0} +default,sc ${@caller} +set,sc ?{lowercase ${sc}} +set,sl ?{sclistname ${target}} +set,hn #tag:hook:${sc} +set,hne #tag:hook-end +//logdebug -- sl='${sl}' hn='${hn}' hne='${hne}' +loop + if ?{not ?{IsHooked,{${sc}} ${target}}} + //logdebug -- unhook done + exitloop + endif + set,p ?{lfind,{${sl}} ${hn}} + set,line ?{lindex,{${sl}} ${p}} + //logdebug -- line[${p}] = ${line} + if ?{strlen ${p}} // p is empty string if the line wasnt found + loop + set,line2 ?{lerase,{${sl}} ${p}} + //logdebug -- removed: '${line2}' + if ?{equal,{${line2}} ${hne}} + exitloop + endif + endloop + endif +endloop +unset sl +unset hn +unset hne +unset sc + +#script=UnHookOpcode +// @def: opcode name +// [@0: name of calling script] +set,sc ${@0} +default,sc ${@caller} +UnHook,{${sc}} OPCODE::${@def} + +#script=UnHookAll +// @def: name of script to remove all hooks from +// [@0: name of calling script] +set,sc ${@0} +set,sl ?{sclistname ${@def}} +set,hn #tag:hook: +set,hne #tag:hook-end +set,i 0 +set,hookcode false +loop + set,erased false + if ?{bigger_eq,${i} ?{llen ${sl}}} + exitloop + endif + set,line ?{lindex,{${sl}} ${i}} + if ?{equal,{${hn}} ?{substr,?{strlen ${hn}} ${line}}} + set,hookcode true + else + if ?{equal,{${hne}} ?{substr,?{strlen ${hn}} ${line}}} + lerase,{${sl}} ${i} + set,hookcode false + set,erased true + endif + endif + + if ${hookcode} + lerase,{${sl}} ${i} + set,erased true + endif + if ?{not ${erased}} + add,i 1 + endif +endloop diff --git a/bin/scripts/__core_internal.def b/bin/scripts/__core_internal.def index 8149060..6d03222 100644 --- a/bin/scripts/__core_internal.def +++ b/bin/scripts/__core_internal.def @@ -1,118 +1,118 @@ -// scripts used for configuration! DO NOT MODIFY unless you know what you do!! - -#onload - log * Loading core scripts (internal config)... -#/onload - -//-------------------------------------------------------- -#script=exit -#permission=255 -//-------------------------------------------------------- -// just a name alternative -QUIT - - -//-------------------------------------------------------- -#script=quit -#permission=255 -//-------------------------------------------------------- -// quit PseuWoW, say goodbye when logged in -IF ${@inworld} - SAY Terminating proc... -ENDIF -SHDN - - -//----------------------------------------------- -#script=cleanupvars -//----------------------------------------------- -// purpose: unset all variables that could be abused by someone -LOGDETAIL * Cleaning up variables... -UNSET #ACCPASS -UNSET #ACCNAME -LOGDETAIL * Dangerous variables removed. - - -//----------------------------------------------- -#script=config -#permission=255 -//----------------------------------------------- -#onload - // create empty variable. stores if config script was already run successfully once. - SET,DONE -#/onload -// Load all conf files from directory /conf/ -// get all *.conf file names from /conf/ directory, store the names in list 'fl' and the amount in 'fcount' -LOG ** Configuring PseuWoW... -SET,fcount ?{LGETFILES,fl,conf conf} -// sort the list, load conf files alphabetically. -LSORT fl - -IF ?{NOT ${fcount}} - LOGERROR No conf file found! Can't load. - RETURN -ENDIF - -LOG * Loading ${fcount} conf files. -// iterate over all files and load them; if counter i is equal to the amount of files we are done. -SET,i 0 -LOOP - IF ?{EQUAL,${i} ${fcount}} - EXITLOOP - ENDIF - SET,fn ?{LINDEX,fl ${i}} - LOG * Loading conf file [ ${fn} ] - LOADCONF ${fn} - ADD,i 1 -ENDLOOP - -UNSET fcount -UNSET i -UNSET fn -LDELETE fl - -// Apply the configuration -APPLYCONF -LOG * Configuration applied. - -// Apply user permissions -APPLYPERMISSIONS - -// remove dangerous variables -CLEANUPVARS - -// set permissions for internal functions -INTERNAL_PERM - -// if its not set in the conf file, default it to "." (WoWEmu & MaNGOS style) -DEFAULT,#CMDCHAR . - -LOG ** All Config done. -SET,DONE true - - -//-------------------------------------------------- -#script=internal_perm -#permission=255 -//-------------------------------------------------- -// purpose: set script permissions for internal functions that cant be set otherwise. -// if you don't set a permission for a script manually, it will have permission 255 (highest) - -LOG * Assigning permissions for internal functions... -// emotes are hard to abuse, allow for everyone -setscriptpermission,emote 0 -// ... set more permissions here ... - - -// this dummy script does nothing actually but since its loaded last in this file it causes the config -// script to be run before all .def files are loaded -// (this is important for scripts that depend on the config already existing during load-time) -//------------------------------------------------- -#script=dummy -//------------------------------------------------- -#onload -if ?{not ${#config::DONE}} - config -endif -#/onload - +// scripts used for configuration! DO NOT MODIFY unless you know what you do!! + +#onload + log * Loading core scripts (internal config)... +#/onload + +//-------------------------------------------------------- +#script=exit +#permission=255 +//-------------------------------------------------------- +// just a name alternative +QUIT + + +//-------------------------------------------------------- +#script=quit +#permission=255 +//-------------------------------------------------------- +// quit PseuWoW, say goodbye when logged in +IF ${@inworld} + SAY Terminating proc... +ENDIF +SHDN + + +//----------------------------------------------- +#script=cleanupvars +//----------------------------------------------- +// purpose: unset all variables that could be abused by someone +LOGDETAIL * Cleaning up variables... +UNSET #ACCPASS +UNSET #ACCNAME +LOGDETAIL * Dangerous variables removed. + + +//----------------------------------------------- +#script=config +#permission=255 +//----------------------------------------------- +#onload + // create empty variable. stores if config script was already run successfully once. + SET,DONE +#/onload +// Load all conf files from directory /conf/ +// get all *.conf file names from /conf/ directory, store the names in list 'fl' and the amount in 'fcount' +LOG ** Configuring PseuWoW... +SET,fcount ?{LGETFILES,fl,conf conf} +// sort the list, load conf files alphabetically. +LSORT fl + +IF ?{NOT ${fcount}} + LOGERROR No conf file found! Can't load. + RETURN +ENDIF + +LOG * Loading ${fcount} conf files. +// iterate over all files and load them; if counter i is equal to the amount of files we are done. +SET,i 0 +LOOP + IF ?{EQUAL,${i} ${fcount}} + EXITLOOP + ENDIF + SET,fn ?{LINDEX,fl ${i}} + LOG * Loading conf file [ ${fn} ] + LOADCONF ${fn} + ADD,i 1 +ENDLOOP + +UNSET fcount +UNSET i +UNSET fn +LDELETE fl + +// Apply the configuration +APPLYCONF +LOG * Configuration applied. + +// Apply user permissions +APPLYPERMISSIONS + +// remove dangerous variables +CLEANUPVARS + +// set permissions for internal functions +INTERNAL_PERM + +// if its not set in the conf file, default it to "." (WoWEmu & MaNGOS style) +DEFAULT,#CMDCHAR . + +LOG ** All Config done. +SET,DONE true + + +//-------------------------------------------------- +#script=internal_perm +#permission=255 +//-------------------------------------------------- +// purpose: set script permissions for internal functions that cant be set otherwise. +// if you don't set a permission for a script manually, it will have permission 255 (highest) + +LOG * Assigning permissions for internal functions... +// emotes are hard to abuse, allow for everyone +setscriptpermission,emote 0 +// ... set more permissions here ... + + +// this dummy script does nothing actually but since its loaded last in this file it causes the config +// script to be run before all .def files are loaded +// (this is important for scripts that depend on the config already existing during load-time) +//------------------------------------------------- +#script=dummy +//------------------------------------------------- +#onload +if ?{not ${#config::DONE}} + config +endif +#/onload + diff --git a/bin/scripts/__core_list_extensions.def b/bin/scripts/__core_list_extensions.def index fe8c49c..6464ba5 100644 --- a/bin/scripts/__core_list_extensions.def +++ b/bin/scripts/__core_list_extensions.def @@ -1,136 +1,136 @@ - - -//-------------------------------------------- -#script=lcontains -//-------------------------------------------- -// return true if any list element matches @def, else return false. -// @0: list name, @def: search string - -set,i 0 -set,l ?{globname,{${@caller}} ${@0}} - -if ?{not ?{llen ${l}}} - return -endif - -set,result false -loop - if ?{equal,${i} ?{llen ${l}}} - exitloop - endif - set,elem ?{lindex,{${l}} ${i}} - if ?{equal,{${elem}} ${@def}} - set,result true - exitloop - endif - add,i 1 -endloop -unset i -unset l -unset elem -return ${result} - - -// ----------------------------------------- -#script=lcontains_ext -// ----------------------------------------- -// returns the amount of matched substrings of @def in list @0. -// default delimiter is space, override with @1. -// by default, any char in @1 serves as delimiter. -// if you set @2 to true, the exact string @1 is used as delimiter (no default is set) -// to check for individual chars in @def, use the following: "lcontains_ex,,,true string_of_chars_for_example" - -set,i 0 -set,j 0 -set,l ?{globname,{${@caller}} ${@0}} -set,delim ${@1} - -if ${@2} - set,engine lsplit -else - set,engine lcsplit - // take care of the whitespaces: we use space as delimiter! - default,delim { } -endif - -${engine},myl,{${delim}} ${@def} - -// list to check must at least contain 1 element -if ?{not ?{llen ${l}}} - return 0 -endif - -// and our pattern list must contain 1 element also -if ?{not ?{llen myl}} - return 0 -endif - -set,result 0 - -loop - if ?{equal,${i} ?{llen ${l}}} - exitloop - endif - set,elem ?{lindex,{${l}} ${i}} - set,j 0 - loop - if ?{equal,${j} ?{llen myl}} - exitloop - endif - set,myelem ?{lindex,myl ${j}} - if ?{equal,{${elem}} ${myelem}} - add,result 1 - endif - add,j 1 - endloop - add,i 1 -endloop - -unset i -unset j -unset l -unset engine -unset elem -unset myelem -ldelete myl -unset delim - -return ${result} - - -//-------------------------------------------- -#script=lfind -//-------------------------------------------- -// return the position of the first element matching @def -// @0: list name, @def: search string -// @1: ignore case? -// if nothing is found, return empty string - -set,i 0 -set,l ?{globname,{${@caller}} ${@0}} - -if ?{not ?{llen ${l}}} - return -endif - -set,result -loop - if ?{equal,${i} ?{llen ${l}}} - exitloop - endif - set,elem ?{lindex,{${l}} ${i}} - if ${@1} - set,eq ?{equal,{?{lowercase ${elem}}} ?{lowercase ${@def}}} - else - set,eq ?{equal,{${elem}} ${@def}} - endif - if ${eq} - set,result ${i} - exitloop - endif - add,i 1 -endloop -unset i -unset l -unset elem -return ${result} + + +//-------------------------------------------- +#script=lcontains +//-------------------------------------------- +// return true if any list element matches @def, else return false. +// @0: list name, @def: search string + +set,i 0 +set,l ?{globname,{${@caller}} ${@0}} + +if ?{not ?{llen ${l}}} + return +endif + +set,result false +loop + if ?{equal,${i} ?{llen ${l}}} + exitloop + endif + set,elem ?{lindex,{${l}} ${i}} + if ?{equal,{${elem}} ${@def}} + set,result true + exitloop + endif + add,i 1 +endloop +unset i +unset l +unset elem +return ${result} + + +// ----------------------------------------- +#script=lcontains_ext +// ----------------------------------------- +// returns the amount of matched substrings of @def in list @0. +// default delimiter is space, override with @1. +// by default, any char in @1 serves as delimiter. +// if you set @2 to true, the exact string @1 is used as delimiter (no default is set) +// to check for individual chars in @def, use the following: "lcontains_ex,,,true string_of_chars_for_example" + +set,i 0 +set,j 0 +set,l ?{globname,{${@caller}} ${@0}} +set,delim ${@1} + +if ${@2} + set,engine lsplit +else + set,engine lcsplit + // take care of the whitespaces: we use space as delimiter! + default,delim { } +endif + +${engine},myl,{${delim}} ${@def} + +// list to check must at least contain 1 element +if ?{not ?{llen ${l}}} + return 0 +endif + +// and our pattern list must contain 1 element also +if ?{not ?{llen myl}} + return 0 +endif + +set,result 0 + +loop + if ?{equal,${i} ?{llen ${l}}} + exitloop + endif + set,elem ?{lindex,{${l}} ${i}} + set,j 0 + loop + if ?{equal,${j} ?{llen myl}} + exitloop + endif + set,myelem ?{lindex,myl ${j}} + if ?{equal,{${elem}} ${myelem}} + add,result 1 + endif + add,j 1 + endloop + add,i 1 +endloop + +unset i +unset j +unset l +unset engine +unset elem +unset myelem +ldelete myl +unset delim + +return ${result} + + +//-------------------------------------------- +#script=lfind +//-------------------------------------------- +// return the position of the first element matching @def +// @0: list name, @def: search string +// @1: ignore case? +// if nothing is found, return empty string + +set,i 0 +set,l ?{globname,{${@caller}} ${@0}} + +if ?{not ?{llen ${l}}} + return +endif + +set,result +loop + if ?{equal,${i} ?{llen ${l}}} + exitloop + endif + set,elem ?{lindex,{${l}} ${i}} + if ${@1} + set,eq ?{equal,{?{lowercase ${elem}}} ?{lowercase ${@def}}} + else + set,eq ?{equal,{${elem}} ${@def}} + endif + if ${eq} + set,result ${i} + exitloop + endif + add,i 1 +endloop +unset i +unset l +unset elem +return ${result} diff --git a/bin/scripts/__core_misc.def b/bin/scripts/__core_misc.def index 2e3b03e..b84ffca 100644 --- a/bin/scripts/__core_misc.def +++ b/bin/scripts/__core_misc.def @@ -1,57 +1,57 @@ - - -//----------------------------------------------- -#script=getchatitem -#permission=255 -//----------------------------------------------- -// expected args: -// @def: item id -// @0 (optional): color (in RGB hex format: 00FF00 = pure green) -// returns: clickable item link to use it chat messages - -SET,i ${@def} -SET,color ${@0} -DEFAULT,i 0 -TOINT,i ${i} -DEFAULT,color 6679FF -SET,link |cff${color}|Hitem:${i}:0:0:0:0:0:0:0|h[Item ${i}]|h|r - -UNSET i -UNSET color - -RETURN ${link} - - -//----------------------------------------------- -#script=makechatitem -#permission=255 -//----------------------------------------------- -// purpose: write the text of a clickable item link into a variable -// expected args: -// @def: item id -// @0: variable name to write into -// @1 (optional): color (in hex format: 00FF00 = pure green) -SET,v #${@caller}::${target} -SET,{${v}} ?{getchatitem,{${@1}} ${@def}} -UNSET v - - -//----------------------------------------------- -#script=outv -#permission=0 -//----------------------------------------------- -// purpose: output a variable's value to the console. -// usage: "outv x" - -SET,vn #${@caller}::${@def} - -IF ?{NOT ?{ISSET ${vn}}} - OUT * Var '${@def}' not defined. - RETURN -ENDIF - -SET,vv ${${vn}} -OUT * Var '${@def}' = '${vv}' - -UNSET vv -UNSET vn + + +//----------------------------------------------- +#script=getchatitem +#permission=255 +//----------------------------------------------- +// expected args: +// @def: item id +// @0 (optional): color (in RGB hex format: 00FF00 = pure green) +// returns: clickable item link to use it chat messages + +SET,i ${@def} +SET,color ${@0} +DEFAULT,i 0 +TOINT,i ${i} +DEFAULT,color 6679FF +SET,link |cff${color}|Hitem:${i}:0:0:0:0:0:0:0|h[Item ${i}]|h|r + +UNSET i +UNSET color + +RETURN ${link} + + +//----------------------------------------------- +#script=makechatitem +#permission=255 +//----------------------------------------------- +// purpose: write the text of a clickable item link into a variable +// expected args: +// @def: item id +// @0: variable name to write into +// @1 (optional): color (in hex format: 00FF00 = pure green) +SET,v #${@caller}::${target} +SET,{${v}} ?{getchatitem,{${@1}} ${@def}} +UNSET v + + +//----------------------------------------------- +#script=outv +#permission=0 +//----------------------------------------------- +// purpose: output a variable's value to the console. +// usage: "outv x" + +SET,vn #${@caller}::${@def} + +IF ?{NOT ?{ISSET ${vn}}} + OUT * Var '${@def}' not defined. + RETURN +ENDIF + +SET,vv ${${vn}} +OUT * Var '${@def}' = '${vv}' + +UNSET vv +UNSET vn diff --git a/bin/scripts/__core_wrappers.def b/bin/scripts/__core_wrappers.def index c3da773..594352e 100644 --- a/bin/scripts/__core_wrappers.def +++ b/bin/scripts/__core_wrappers.def @@ -1,40 +1,40 @@ -// example file. wrap a few functions together. - -//------------------------------------------------ -#script=gc -#permission=0 -//------------------------------------------------ -// example script to write into channel "generalchat" -// usage: "gc bla bla..." -chan,generalchat ${@def} - - -//------------------------------------------------ -#script=gcl -#permission=0 -//------------------------------------------------ -// write leetspeak to channel generalchat (see "gc" script) -// usage: "gcl moo, cow syndrome!" -gc ?{toleet ${@def}} - - -//------------------------------------------------ -#script=selfheal -#permission=0 -//------------------------------------------------ -// purpose: heal self with full hp. GM-ONLY!! -// be sure you have this spell in your spellbook! -// DO NOT USE THIS SCRIPT IF YOU ARE NO GM! - -// target self (the name we used to login) -TARGET ${#CHARNAME} -// 23965 = instant heal -CASTSPELL 23965 - -//------------------------------------------------ -#script=sl -#permission=0 -//------------------------------------------------ -// say leetspeak text. gm-commands can't be executed this way -s,{${@0}} ?{toleet ${@def}} - +// example file. wrap a few functions together. + +//------------------------------------------------ +#script=gc +#permission=0 +//------------------------------------------------ +// example script to write into channel "generalchat" +// usage: "gc bla bla..." +chan,generalchat ${@def} + + +//------------------------------------------------ +#script=gcl +#permission=0 +//------------------------------------------------ +// write leetspeak to channel generalchat (see "gc" script) +// usage: "gcl moo, cow syndrome!" +gc ?{toleet ${@def}} + + +//------------------------------------------------ +#script=selfheal +#permission=0 +//------------------------------------------------ +// purpose: heal self with full hp. GM-ONLY!! +// be sure you have this spell in your spellbook! +// DO NOT USE THIS SCRIPT IF YOU ARE NO GM! + +// target self (the name we used to login) +TARGET ${#CHARNAME} +// 23965 = instant heal +CASTSPELL 23965 + +//------------------------------------------------ +#script=sl +#permission=0 +//------------------------------------------------ +// say leetspeak text. gm-commands can't be executed this way +s,{${@0}} ?{toleet ${@def}} + diff --git a/bin/scripts/autobroadcast.def b/bin/scripts/autobroadcast.def index 8eaa602..4f63886 100644 --- a/bin/scripts/autobroadcast.def +++ b/bin/scripts/autobroadcast.def @@ -1,46 +1,46 @@ -// -- using conf/ScriptConfig.conf - -// run this file to broadcast immediately (the timer will not change if you do!) - -#permission=255 - -#onload - - // check if this script should be loaded. - if ?{or,?{not ?{isset enable}} ?{not ${enable}}} - log ** AutoBroadcast: skipped loading. - return - endif - - // convert secs into msecs - set,timer ${secs} - mul,timer 1000 - - // we need this variable later as "array-index" - set,x 0 - - // unregister the timer if it has been registered before - removeevent event_{${@myname}} - - // register the timer. - // script name is "autobroadcast", so the event name will be "event_autobroadcast" and the script command to call will be "autobroadcast" - // so we basically register ourselves - addevent,event_{${@myname}},${timer} ${@myname} - - // yay we are loaded :) - log ** AutoBroadcast loaded. ${textcount} Texts. - -#endonload - -// --- begin of the script body --- - -// every call the value of x gets increased by 1 -add,x 1 - -// broadcast the text number x -CMD ${cmd} ${text${x}} - -// if x = textcount: reset text counter x to 0 (using the modulo operator) -mod,x ${textcount} - - +// -- using conf/ScriptConfig.conf + +// run this file to broadcast immediately (the timer will not change if you do!) + +#permission=255 + +#onload + + // check if this script should be loaded. + if ?{or,?{not ?{isset enable}} ?{not ${enable}}} + log ** AutoBroadcast: skipped loading. + return + endif + + // convert secs into msecs + set,timer ${secs} + mul,timer 1000 + + // we need this variable later as "array-index" + set,x 0 + + // unregister the timer if it has been registered before + removeevent event_{${@myname}} + + // register the timer. + // script name is "autobroadcast", so the event name will be "event_autobroadcast" and the script command to call will be "autobroadcast" + // so we basically register ourselves + addevent,event_{${@myname}},${timer} ${@myname} + + // yay we are loaded :) + log ** AutoBroadcast loaded. ${textcount} Texts. + +#endonload + +// --- begin of the script body --- + +// every call the value of x gets increased by 1 +add,x 1 + +// broadcast the text number x +CMD ${cmd} ${text${x}} + +// if x = textcount: reset text counter x to 0 (using the modulo operator) +mod,x ${textcount} + + diff --git a/bin/scripts/deprecated/_enterworld.def b/bin/scripts/deprecated/_enterworld.def index ce769e9..c9aa898 100644 --- a/bin/scripts/deprecated/_enterworld.def +++ b/bin/scripts/deprecated/_enterworld.def @@ -1,36 +1,36 @@ -#permission=255 - -// PSEUWOW DEF_SCRIPT WORLD-ENTER FILE - -LOG * World entered, executing appropriate script... - -// MaNGOS: make PseuWoW invincible -// CMD gmon - -// you can also teleport on every startup to a certain player... -// simple: use the .goname command as usual. -// SAY .goname Gamemaster -// or teleport to a specific loacation... -// CMD tele gmisland - -// to know everything worked fine, etc -SAY [${@version_short}] login successful. - -// yaay we are online. Ready! -// 126 = TEXTEMOTE_READY -EMOTE 126 - -// join some channels... -JOINCHANNEL General -JOINCHANNEL LookingForGroup -// and a custom channel -JOINCHANNEL generlachat - -// Spell 836 = LoginEffect -CASTSPELL 836 - -// add your own stuff here -// ... - - +#permission=255 + +// PSEUWOW DEF_SCRIPT WORLD-ENTER FILE + +LOG * World entered, executing appropriate script... + +// MaNGOS: make PseuWoW invincible +// CMD gmon + +// you can also teleport on every startup to a certain player... +// simple: use the .goname command as usual. +// SAY .goname Gamemaster +// or teleport to a specific loacation... +// CMD tele gmisland + +// to know everything worked fine, etc +SAY [${@version_short}] login successful. + +// yaay we are online. Ready! +// 126 = TEXTEMOTE_READY +EMOTE 126 + +// join some channels... +JOINCHANNEL General +JOINCHANNEL LookingForGroup +// and a custom channel +JOINCHANNEL generlachat + +// Spell 836 = LoginEffect +CASTSPELL 836 + +// add your own stuff here +// ... + + LOG * finished executing script. \ No newline at end of file diff --git a/bin/scripts/deprecated/_leaveworld.def b/bin/scripts/deprecated/_leaveworld.def index 4f60efd..825e501 100644 --- a/bin/scripts/deprecated/_leaveworld.def +++ b/bin/scripts/deprecated/_leaveworld.def @@ -1,3 +1,3 @@ -#permission=255 - +#permission=255 + // EXECUTED WHEN THE WORLD IS LEFT \ No newline at end of file diff --git a/bin/scripts/deprecated/_nopermission.def b/bin/scripts/deprecated/_nopermission.def index 5549556..597cb51 100644 --- a/bin/scripts/deprecated/_nopermission.def +++ b/bin/scripts/deprecated/_nopermission.def @@ -1,14 +1,14 @@ -// this script gets executed if a player tries to give pseuwow a command but is not allowed to - -// Arguments: -// ========== -// @0 : name of the player who wanted to execute a command -// @1 : permission level of this user -// @2 : permission level needed to execute the script -// @3 : name of the script that should get executed - -SAY Forget it, ${@0}, you have only permission ${@1} but need ${@2} to run the script '${@3}' -LOG Player '${@0}' (p:${@1}) wanted to execute '${@3}' (p:${@2}) - -// say NO! +// this script gets executed if a player tries to give pseuwow a command but is not allowed to + +// Arguments: +// ========== +// @0 : name of the player who wanted to execute a command +// @1 : permission level of this user +// @2 : permission level needed to execute the script +// @3 : name of the script that should get executed + +SAY Forget it, ${@0}, you have only permission ${@1} but need ${@2} to run the script '${@3}' +LOG Player '${@0}' (p:${@1}) wanted to execute '${@3}' (p:${@2}) + +// say NO! EMOTE 66 \ No newline at end of file diff --git a/bin/scripts/deprecated/_onwhisper.def b/bin/scripts/deprecated/_onwhisper.def index ba68371..2470c4a 100644 --- a/bin/scripts/deprecated/_onwhisper.def +++ b/bin/scripts/deprecated/_onwhisper.def @@ -1,4 +1,4 @@ -// EXECUTED EVERYTIME A WHISPER IS BEEING RECIEVED - -// comment out the following line if you dont need it +// EXECUTED EVERYTIME A WHISPER IS BEEING RECIEVED + +// comment out the following line if you dont need it //REPLY,0 [BOT] No need to whisper, nobody is here who could read what you wrote. \ No newline at end of file diff --git a/bin/scripts/deprecated/opcode_who_forplayer.def b/bin/scripts/deprecated/opcode_who_forplayer.def index 97fc608..14cefb0 100644 --- a/bin/scripts/deprecated/opcode_who_forplayer.def +++ b/bin/scripts/deprecated/opcode_who_forplayer.def @@ -1,22 +1,22 @@ -// temporary wrapper for requesting info about a certain player until implemented into the core -#script=SendWhoForPlayer - -// minlvl 0 -bbappend,pkt,uint32 0 -// maxlvl 100 -bbappend,pkt,uint32 100 -// player name, case-sensitive string -bbappend,pkt,string ${@def} -// no guild, empty string -bbappend,pkt,string -// racemask - all races -bbappend,pkt,uint32 0xFFFFFFFF -// classmask - all classes -bbappend,pkt,uint32 0xFFFFFFFF -// 0 zones to check -bbappend,pkt,uint32 0 -// 0 additional strings -bbappend,pkt,uint32 0 - -SendWorldPacket,{?{GetOpcodeID CMSG_WHO}} pkt +// temporary wrapper for requesting info about a certain player until implemented into the core +#script=SendWhoForPlayer + +// minlvl 0 +bbappend,pkt,uint32 0 +// maxlvl 100 +bbappend,pkt,uint32 100 +// player name, case-sensitive string +bbappend,pkt,string ${@def} +// no guild, empty string +bbappend,pkt,string +// racemask - all races +bbappend,pkt,uint32 0xFFFFFFFF +// classmask - all classes +bbappend,pkt,uint32 0xFFFFFFFF +// 0 zones to check +bbappend,pkt,uint32 0 +// 0 additional strings +bbappend,pkt,uint32 0 + +SendWorldPacket,{?{GetOpcodeID CMSG_WHO}} pkt bbdelete pkt \ No newline at end of file diff --git a/bin/scripts/optional/bbExample.def b/bin/scripts/optional/bbExample.def index 8fd3d28..7871cf7 100644 --- a/bin/scripts/optional/bbExample.def +++ b/bin/scripts/optional/bbExample.def @@ -1,29 +1,29 @@ -#script=bbexample -bbinit,50 mybb -bbappend,mybb,uint32 123456 -bbappend,mybb,uint8 255 -bbappend,mybb,float 3.141592 -bbappend,mybb,string Hello World! -bbappend,mybb,uint32 0xDEADBABE -bbappend,mybb,uint16 1024 -bbappend,mybb,uint64 0 -bbappend,mybb,uint64 0 - -out ByteBuffer Example: -bbhexlike mybb -bbtextlike mybb - -bbrpos,mybb 0 -out Reading uint32 - ?{bbread,mybb uint32} -out Reading uint8 - ?{bbread,mybb uint8} -out Reading float - ?{bbread,mybb float} -out Reading string - ?{bbread,mybb string} -set,t ?{bbread,mybb uint32} -out Reading uint32 - ${t} hex: ?{tohex ${t}} -out Reading uint16 - ?{bbread,mybb uint16} -out skipping 16 bytes -bbread,mybb uint64 -bbread,mybb uint64 -out read from invalid position: result='?{bbread,mybb uint8}' - -bbdelete mybb +#script=bbexample +bbinit,50 mybb +bbappend,mybb,uint32 123456 +bbappend,mybb,uint8 255 +bbappend,mybb,float 3.141592 +bbappend,mybb,string Hello World! +bbappend,mybb,uint32 0xDEADBABE +bbappend,mybb,uint16 1024 +bbappend,mybb,uint64 0 +bbappend,mybb,uint64 0 + +out ByteBuffer Example: +bbhexlike mybb +bbtextlike mybb + +bbrpos,mybb 0 +out Reading uint32 - ?{bbread,mybb uint32} +out Reading uint8 - ?{bbread,mybb uint8} +out Reading float - ?{bbread,mybb float} +out Reading string - ?{bbread,mybb string} +set,t ?{bbread,mybb uint32} +out Reading uint32 - ${t} hex: ?{tohex ${t}} +out Reading uint16 - ?{bbread,mybb uint16} +out skipping 16 bytes +bbread,mybb uint64 +bbread,mybb uint64 +out read from invalid position: result='?{bbread,mybb uint8}' + +bbdelete mybb diff --git a/bin/scripts/optional/chatAI_HelloWorld.def b/bin/scripts/optional/chatAI_HelloWorld.def index 175617f..bd82387 100644 --- a/bin/scripts/optional/chatAI_HelloWorld.def +++ b/bin/scripts/optional/chatAI_HelloWorld.def @@ -1,39 +1,39 @@ -// example script that registers itself to get called on incoming chat messages. -// args passed to this script are as follows: -// @def: chat msg -// @0: message type -// @1: lang id -// @2: guid of sender -// @3: channel name -// @4: language name - -// --------------------------------------- -#script=chat_ai_helloworld -// --------------------------------------- -#onload -// call us only if somebody says a text containing "hello" and "world" -RegisterChatAIScript,{${@myname}},ALL hello world -set,counter 0 -#/onload - -if ?{equal,${@0} 0} - // say some stuff is the language that was used by the sender - say,${@1} Hello World! This is an example! You used ${@4} language. -else - // or shout back in our default language - if ?{equal,${@0} 5} - yell Yah "Hello World!" is widely used to proof that something is working!! You used ${@4} language. - else - if ?{equal,${@0} 14} - chan,{${@3}} Recieved a nice "Hello World" in channel ${@3} ;) - endif - endif -endif - -add,counter 1 - -// after 5 times of calling this script, it might get annoying, drop it -if ?{greater_eq,${counter} 5} - DropChatAIScript ${@myname} -endif - +// example script that registers itself to get called on incoming chat messages. +// args passed to this script are as follows: +// @def: chat msg +// @0: message type +// @1: lang id +// @2: guid of sender +// @3: channel name +// @4: language name + +// --------------------------------------- +#script=chat_ai_helloworld +// --------------------------------------- +#onload +// call us only if somebody says a text containing "hello" and "world" +RegisterChatAIScript,{${@myname}},ALL hello world +set,counter 0 +#/onload + +if ?{equal,${@0} 0} + // say some stuff is the language that was used by the sender + say,${@1} Hello World! This is an example! You used ${@4} language. +else + // or shout back in our default language + if ?{equal,${@0} 5} + yell Yah "Hello World!" is widely used to proof that something is working!! You used ${@4} language. + else + if ?{equal,${@0} 14} + chan,{${@3}} Recieved a nice "Hello World" in channel ${@3} ;) + endif + endif +endif + +add,counter 1 + +// after 5 times of calling this script, it might get annoying, drop it +if ?{greater_eq,${counter} 5} + DropChatAIScript ${@myname} +endif + diff --git a/bin/scripts/optional/dump_playercache.def b/bin/scripts/optional/dump_playercache.def index 17dd87f..da68f35 100644 --- a/bin/scripts/optional/dump_playercache.def +++ b/bin/scripts/optional/dump_playercache.def @@ -1,21 +1,21 @@ -#script=dumppcache -fopen,fh,rb ./cache/playernames.cache -freadbb,fh bb -set,size ?{bbread,bb uint32} -log PlayerNameCache: ${size} entries. -set,i 0 -loop - if ?{bigger_eq,${i} ${size}} - exitloop - endif - set,guid ?{bbread,bb uint64} - set,len ?{bbread,bb uint8} - set,name ?{bbread,bb,${len} strnz} - log PlayerNameCache[${i}]: ${guid} = ${name} (${len}) - add,i 1 -endloop - -#script=dummy -#onload -dumppcache -#/onload +#script=dumppcache +fopen,fh,rb ./cache/playernames.cache +freadbb,fh bb +set,size ?{bbread,bb uint32} +log PlayerNameCache: ${size} entries. +set,i 0 +loop + if ?{bigger_eq,${i} ${size}} + exitloop + endif + set,guid ?{bbread,bb uint64} + set,len ?{bbread,bb uint8} + set,name ?{bbread,bb,${len} strnz} + log PlayerNameCache[${i}]: ${guid} = ${name} (${len}) + add,i 1 +endloop + +#script=dummy +#onload +dumppcache +#/onload diff --git a/bin/scripts/optional/example_scriptHook.def b/bin/scripts/optional/example_scriptHook.def index 2a395fe..4b08603 100644 --- a/bin/scripts/optional/example_scriptHook.def +++ b/bin/scripts/optional/example_scriptHook.def @@ -1,56 +1,56 @@ -//---------------------------------- -#script=hook_example_base -//---------------------------------- -// just do some random stuff here -set,var 0 -set,x hello world -add,var 15 -out base: var=${var} - - - -//---------------------------------- -#script=hook_example_hooker -//---------------------------------- -#onload -set,counter 0 -#/onload - -// check if we have already added our code -if ?{ScriptHasLine,hook_example_base #tag:hook:${@myname}} - out Hook Example: code already added, skipping. -else - set,somevar some text - - // this is a custom "tag" to indicate the modification. its necessary because a 'reloaddef' on base script removes our custom content, - // so we can check if our added lines are still there; and a reloaddef on this script would cause the lines to get added twice or more. - appenddef,hook_example_base #tag:hook:${@myname} - - appenddef,hook_example_base out == this is the hooked part == - appenddef,hook_example_base out text copied from hooking script: ${somevar} - appenddef,hook_example_base out x in base script: $\{x\} - appenddef,hook_example_base out add,a 10 - appenddef,hook_example_base out var=$\{var\} - out Hook Example: ++ code appended. -endif - -// everytine this script gets executed, add the same line of code to a "new" script (its not defined if you call this first time) -appenddef,hook_example_new out line of text [${counter}] -add,counter 1 - - - -//---------------------------------- -#script=hook_example_cleanup -//---------------------------------- -unloaddef hook_example_new -// other possible, but wrong way: delete DEFSCRIPT::SCRIPT::hook_example_new - - - -//----------------------------------- -// dummy for running scripts as soon as all scripts in this file are loaded -#script=dummy -#onload -hook_example_hooker -#/onload +//---------------------------------- +#script=hook_example_base +//---------------------------------- +// just do some random stuff here +set,var 0 +set,x hello world +add,var 15 +out base: var=${var} + + + +//---------------------------------- +#script=hook_example_hooker +//---------------------------------- +#onload +set,counter 0 +#/onload + +// check if we have already added our code +if ?{ScriptHasLine,hook_example_base #tag:hook:${@myname}} + out Hook Example: code already added, skipping. +else + set,somevar some text + + // this is a custom "tag" to indicate the modification. its necessary because a 'reloaddef' on base script removes our custom content, + // so we can check if our added lines are still there; and a reloaddef on this script would cause the lines to get added twice or more. + appenddef,hook_example_base #tag:hook:${@myname} + + appenddef,hook_example_base out == this is the hooked part == + appenddef,hook_example_base out text copied from hooking script: ${somevar} + appenddef,hook_example_base out x in base script: $\{x\} + appenddef,hook_example_base out add,a 10 + appenddef,hook_example_base out var=$\{var\} + out Hook Example: ++ code appended. +endif + +// everytine this script gets executed, add the same line of code to a "new" script (its not defined if you call this first time) +appenddef,hook_example_new out line of text [${counter}] +add,counter 1 + + + +//---------------------------------- +#script=hook_example_cleanup +//---------------------------------- +unloaddef hook_example_new +// other possible, but wrong way: delete DEFSCRIPT::SCRIPT::hook_example_new + + + +//----------------------------------- +// dummy for running scripts as soon as all scripts in this file are loaded +#script=dummy +#onload +hook_example_hooker +#/onload diff --git a/bin/scripts/optional/item_debugger.def b/bin/scripts/optional/item_debugger.def index 768caf6..1247fc6 100644 --- a/bin/scripts/optional/item_debugger.def +++ b/bin/scripts/optional/item_debugger.def @@ -1,113 +1,113 @@ -// Item/Inventory debugger -// Using Player/Item fields -// Works for 2.3.x -// Usage: As soon as this file is loaded, the debugger will be attached automatically (put this file in /scripts/ directory) -// Known problems: If player/item names are not yet known, this script will display empty names. At second time everything will be fine. - -#script=itemdebugger_loader -#onload -if ?{not ?{ishooked _onobjectcreate}} - hookstart _onobjectcreate -#escape-all=1 - hookadd if ?{equal,4 ${@0}} // MaNGOS creates the player object after all items are created, so just need to check for that and read everything out of the player fields - hookadd playeritemdebugger ${@def} - hookadd endif -#escape-all=0 - hookend -endif -if ?{not ?{ishooked _onobjectdelete}} - hookstart _onobjectdelete -#escape-all=1 - hookadd if ?{or,?{equal,1 ${@0}} ?{equal,2 ${@0}}} - hookadd itemdebugger_del ${@def} - hookadd endif -#escape-all=0 - hookend -endif -#/onload -logdetail Item debugger attached - - - -#script=playeritemdebugger -// @def: player guid - -set,pguid ${@def} -set,pname ?{getname,guid ${pguid}} - -// between these fields all item guids are stored (check UpdateFields.h) -set,fstart 0x26E // PLAYER_FIELD_INV_SLOT_HEAD -set,fend 0x35A // PLAYER_FIELD_KEYRING_SLOT_1 + 64 - -set,f ${fstart} -set,slot 0 -loop - if ?{bigger_eq,${f} ${fend}} - exitloop - endif - set,iguid ?{getobjectvalue,${f},i64 ${pguid}} - if ${iguid} - //-- show info about item - itemdebugger,{Player '${pname}' Slot ${slot} (field ${f}): } ${iguid} - - //-- Iterate over bags -- - if ?{equal,2 ?{getobjecttype ${iguid}}} - bagitemdebugger ${iguid} - endif - endif - - add,f 2 - add,slot 1 -endloop - - -#script=bagitemdebugger -set,bagslots ?{getobjectvalue,60 ${@def}} // CONTAINER_FIELD_NUM_SLOTS -set,j 0 -loop - set,t ${j} - mul,t 2 - if ?{bigger,${t} ${bagslots}} // max. bag size = 36 slots - exitloop - endif - set,field 62 // CONTAINER_FIELD_SLOT_1 - 36 - add,field ${t} - set,itemguid ?{getobjectvalue,${field},i64 ${@def}} - itemdebugger,{Bag slot ${j} (field: ${field}) -> } ${itemguid} - - add,j 1 -endloop - - -#script=itemdebugger -// @def: item guid -// @0: text prefix -set,itemguid ${@def} -if ?{not ?{objectknown ${itemguid}}} - return -endif - -if ${itemguid} - set,itemname ?{getname,guid ${itemguid}} - set,itementry ?{getentry ${itemguid}} - log ${@0}Item: '${itemname}' (${itementry}) [${itemguid}] -endif - - -#script=itemdebugger_del -// @def: item guid - -set,itemguid ${@def} -//if ?{not ?{objectknown ${itemguid}}} -// return -//endif - -if ${itemguid} - set,itemname ?{getname,guid ${itemguid}} - set,itementry ?{getentry ${itemguid}} - set,owner ?{getobjectvalue,6,i64 ${itemguid}} - set,ownername ?{getname,guid ${owner}} - - log Delete Item: '${itemname}' (${itementry}) (${ownername}) [${itemguid}] -endif - +// Item/Inventory debugger +// Using Player/Item fields +// Works for 2.3.x +// Usage: As soon as this file is loaded, the debugger will be attached automatically (put this file in /scripts/ directory) +// Known problems: If player/item names are not yet known, this script will display empty names. At second time everything will be fine. + +#script=itemdebugger_loader +#onload +if ?{not ?{ishooked _onobjectcreate}} + hookstart _onobjectcreate +#escape-all=1 + hookadd if ?{equal,4 ${@0}} // MaNGOS creates the player object after all items are created, so just need to check for that and read everything out of the player fields + hookadd playeritemdebugger ${@def} + hookadd endif +#escape-all=0 + hookend +endif +if ?{not ?{ishooked _onobjectdelete}} + hookstart _onobjectdelete +#escape-all=1 + hookadd if ?{or,?{equal,1 ${@0}} ?{equal,2 ${@0}}} + hookadd itemdebugger_del ${@def} + hookadd endif +#escape-all=0 + hookend +endif +#/onload +logdetail Item debugger attached + + + +#script=playeritemdebugger +// @def: player guid + +set,pguid ${@def} +set,pname ?{getname,guid ${pguid}} + +// between these fields all item guids are stored (check UpdateFields.h) +set,fstart 0x26E // PLAYER_FIELD_INV_SLOT_HEAD +set,fend 0x35A // PLAYER_FIELD_KEYRING_SLOT_1 + 64 + +set,f ${fstart} +set,slot 0 +loop + if ?{bigger_eq,${f} ${fend}} + exitloop + endif + set,iguid ?{getobjectvalue,${f},i64 ${pguid}} + if ${iguid} + //-- show info about item + itemdebugger,{Player '${pname}' Slot ${slot} (field ${f}): } ${iguid} + + //-- Iterate over bags -- + if ?{equal,2 ?{getobjecttype ${iguid}}} + bagitemdebugger ${iguid} + endif + endif + + add,f 2 + add,slot 1 +endloop + + +#script=bagitemdebugger +set,bagslots ?{getobjectvalue,60 ${@def}} // CONTAINER_FIELD_NUM_SLOTS +set,j 0 +loop + set,t ${j} + mul,t 2 + if ?{bigger,${t} ${bagslots}} // max. bag size = 36 slots + exitloop + endif + set,field 62 // CONTAINER_FIELD_SLOT_1 - 36 + add,field ${t} + set,itemguid ?{getobjectvalue,${field},i64 ${@def}} + itemdebugger,{Bag slot ${j} (field: ${field}) -> } ${itemguid} + + add,j 1 +endloop + + +#script=itemdebugger +// @def: item guid +// @0: text prefix +set,itemguid ${@def} +if ?{not ?{objectknown ${itemguid}}} + return +endif + +if ${itemguid} + set,itemname ?{getname,guid ${itemguid}} + set,itementry ?{getentry ${itemguid}} + log ${@0}Item: '${itemname}' (${itementry}) [${itemguid}] +endif + + +#script=itemdebugger_del +// @def: item guid + +set,itemguid ${@def} +//if ?{not ?{objectknown ${itemguid}}} +// return +//endif + +if ${itemguid} + set,itemname ?{getname,guid ${itemguid}} + set,itementry ?{getentry ${itemguid}} + set,owner ?{getobjectvalue,6,i64 ${itemguid}} + set,ownername ?{getname,guid ${owner}} + + log Delete Item: '${itemname}' (${itementry}) (${ownername}) [${itemguid}] +endif + diff --git a/bin/scripts/uptime.def b/bin/scripts/uptime.def index 9771ae1..8eb4395 100644 --- a/bin/scripts/uptime.def +++ b/bin/scripts/uptime.def @@ -1,38 +1,38 @@ -#script=getuptime -// purpose: pseuwow uptime counter -// args: @def: "say", "yell", "chan,General", etc. any command that accepts a string in @def and does something with it. - -// returns: uptime formatted as 0h 0m 0s - -set,s ${@clock} -div,s 1000 -set,s ?{toint ${s}} -set,secs ${s} - -set,h ${s} -div,h 3600 -toint,h ${h} -mod,s 3600 - -set,m ${s} -div,m 60 -toint,m ${m} -mod,s 60 -toint,s ${s} -set,str ${h}h ${m}m ${s}s -out UPTIME: ${secs} secs = ${str} - -if ?{strlen ${@def}} - ${@def} UPTIME: ${h} hours, ${m} minutes, ${s} seconds -endif - -unset h -unset m -unset s -unset secs - -return ${str} - -#script=uptime -#permission=0 +#script=getuptime +// purpose: pseuwow uptime counter +// args: @def: "say", "yell", "chan,General", etc. any command that accepts a string in @def and does something with it. + +// returns: uptime formatted as 0h 0m 0s + +set,s ${@clock} +div,s 1000 +set,s ?{toint ${s}} +set,secs ${s} + +set,h ${s} +div,h 3600 +toint,h ${h} +mod,s 3600 + +set,m ${s} +div,m 60 +toint,m ${m} +mod,s 60 +toint,s ${s} +set,str ${h}h ${m}m ${s}s +out UPTIME: ${secs} secs = ${str} + +if ?{strlen ${@def}} + ${@def} UPTIME: ${h} hours, ${m} minutes, ${s} seconds +endif + +unset h +unset m +unset s +unset secs + +return ${str} + +#script=uptime +#permission=0 return ?{getuptime say} \ No newline at end of file diff --git a/license.txt b/license.txt index 7b35e74..afe9059 100644 --- a/license.txt +++ b/license.txt @@ -1,24 +1,24 @@ -Find the full license at: -http://www.gnu.org/licenses/gpl.html - - -Summary: - -Copyright (C) 2006 False.Genesis @ SnowStom Software - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Every part of program code belongs to its respective owner. +Find the full license at: +http://www.gnu.org/licenses/gpl.html + + +Summary: + +Copyright (C) 2006 False.Genesis @ SnowStom Software + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Every part of program code belongs to its respective owner. diff --git a/src/Client/Cli.h b/src/Client/Cli.h index e7547f3..8011a42 100644 --- a/src/Client/Cli.h +++ b/src/Client/Cli.h @@ -1,18 +1,18 @@ -#ifndef _CLI_H -#define _CLI_H - -class PseuInstance; - -class CliRunnable : public ZThread::Runnable -{ -public: - CliRunnable(PseuInstance*); - void run(void); - void stop() { _stop=true; } - -private: - bool _stop; - PseuInstance *_instance; -}; - +#ifndef _CLI_H +#define _CLI_H + +class PseuInstance; + +class CliRunnable : public ZThread::Runnable +{ +public: + CliRunnable(PseuInstance*); + void run(void); + void stop() { _stop=true; } + +private: + bool _stop; + PseuInstance *_instance; +}; + #endif \ No newline at end of file diff --git a/src/Client/ControlSocket.cpp b/src/Client/ControlSocket.cpp index c72d2b5..56370cd 100644 --- a/src/Client/ControlSocket.cpp +++ b/src/Client/ControlSocket.cpp @@ -1,59 +1,59 @@ -#include "common.h" -#include "PseuWoW.h" -#include "RemoteController.h" -#include "ControlSocket.h" - -ControlSocket::ControlSocket(SocketHandler& h) : TcpSocket(h) -{ - _ok = false; - DEBUG(logdebug("ControlSocket created")); -} - -void ControlSocket::OnAccept(void) -{ - logdetail("ControlSocket: Incoming connection from %s:%u [host:%s]",GetRemoteAddress().c_str(),GetRemotePort(),GetRemoteHostname().c_str()); - - // must perform some crappy ptr conversion here, doesnt want to typecast SocketHandler -> ControlSocketHandler directly - SocketHandler& hnd = Handler(); - ControlSocketHandler *chnd = static_cast(&hnd); - _instance = chnd->GetInstance(); - DEBUG(logdebug("ControlSocket: setting instance = %X",_instance)); - - // accept only connections from one host for now, if set - if(_instance->GetConf()->rmcontrolhost.length() - && !(GetRemoteAddress() == _instance->GetConf()->rmcontrolhost || GetRemoteHostname() == _instance->GetConf()->rmcontrolhost)) - { - logdetail("ControlSocket: connection rejected. closing."); - SetCloseAndDelete(true); - return; - } - - _ok = true; -} - -void ControlSocket::OnRead(void) -{ - if(!_ok) - return; - TcpSocket::OnRead(); - uint32 len = ibuf.GetLength(); - if(!len) - { - logdetail("ControlSocket: connection to %s:%u closed.",GetRemoteAddress().c_str(),GetRemotePort()); - return; - } - - char *buf = new char[len]; - ibuf.Read(buf,len); - if(buf[0]==0) - { - // reserved for future applications - } - else - { - if(_instance && _instance->GetScripts()) - _instance->GetScripts()->RunSingleLine(&buf[0]); - } - - delete [] buf; -} +#include "common.h" +#include "PseuWoW.h" +#include "RemoteController.h" +#include "ControlSocket.h" + +ControlSocket::ControlSocket(SocketHandler& h) : TcpSocket(h) +{ + _ok = false; + DEBUG(logdebug("ControlSocket created")); +} + +void ControlSocket::OnAccept(void) +{ + logdetail("ControlSocket: Incoming connection from %s:%u [host:%s]",GetRemoteAddress().c_str(),GetRemotePort(),GetRemoteHostname().c_str()); + + // must perform some crappy ptr conversion here, doesnt want to typecast SocketHandler -> ControlSocketHandler directly + SocketHandler& hnd = Handler(); + ControlSocketHandler *chnd = static_cast(&hnd); + _instance = chnd->GetInstance(); + DEBUG(logdebug("ControlSocket: setting instance = %X",_instance)); + + // accept only connections from one host for now, if set + if(_instance->GetConf()->rmcontrolhost.length() + && !(GetRemoteAddress() == _instance->GetConf()->rmcontrolhost || GetRemoteHostname() == _instance->GetConf()->rmcontrolhost)) + { + logdetail("ControlSocket: connection rejected. closing."); + SetCloseAndDelete(true); + return; + } + + _ok = true; +} + +void ControlSocket::OnRead(void) +{ + if(!_ok) + return; + TcpSocket::OnRead(); + uint32 len = ibuf.GetLength(); + if(!len) + { + logdetail("ControlSocket: connection to %s:%u closed.",GetRemoteAddress().c_str(),GetRemotePort()); + return; + } + + char *buf = new char[len]; + ibuf.Read(buf,len); + if(buf[0]==0) + { + // reserved for future applications + } + else + { + if(_instance && _instance->GetScripts()) + _instance->GetScripts()->RunSingleLine(&buf[0]); + } + + delete [] buf; +} diff --git a/src/Client/ControlSocket.h b/src/Client/ControlSocket.h index 213cba1..3fac151 100644 --- a/src/Client/ControlSocket.h +++ b/src/Client/ControlSocket.h @@ -1,23 +1,23 @@ -#ifndef CONTROLSOCKET_H -#define CONTROLSOCKET_H - -#include "Network/TcpSocket.h" -#include "RemoteController.h" - -class ControlSocket : public TcpSocket -{ -public: - ControlSocket(SocketHandler& h); - - void SetInstance(PseuInstance *in) { _instance = in; } - - void OnAccept(); - void OnRead(); - -private: - PseuInstance *_instance; - bool _ok; -}; - - -#endif +#ifndef CONTROLSOCKET_H +#define CONTROLSOCKET_H + +#include "Network/TcpSocket.h" +#include "RemoteController.h" + +class ControlSocket : public TcpSocket +{ +public: + ControlSocket(SocketHandler& h); + + void SetInstance(PseuInstance *in) { _instance = in; } + + void OnAccept(); + void OnRead(); + +private: + PseuInstance *_instance; + bool _ok; +}; + + +#endif diff --git a/src/Client/DefScript/DefScript.cpp b/src/Client/DefScript/DefScript.cpp index aa20896..ffb5272 100644 --- a/src/Client/DefScript/DefScript.cpp +++ b/src/Client/DefScript/DefScript.cpp @@ -1,1265 +1,1265 @@ -#include -#include -#include -#include -#include -#include -#include -#include "VarSet.h" -#include "DefScript.h" - -using namespace DefScriptTools; - -#define SN_ONLOAD "?onload?" - -enum DefScriptBlockType -{ - BLOCK_IF, - BLOCK_LOOP -}; - -// --- SECTION FOR SCRIPT PACKAGES --- -DefScriptPackage::DefScriptPackage() -{ - SetLog(printf); - SetDebugLog(printf); - SetErrorLog(printf); - _DEFSC_DEBUG - ( - hLogfile.open("DefScriptLog.txt",std::ios_base::out); - hLogfile << "DefScript engine execution log, compilation date: " __DATE__ " " __TIME__ "\n\n" ; - ) - _eventmgr=new DefScript_DynamicEventMgr(this); - _InitFunctions(); -# ifdef USING_DEFSCRIPT_EXTENSIONS - _InitDefScriptInterface(); -# endif -} - -DefScriptPackage::~DefScriptPackage() -{ - if(_eventmgr) - delete _eventmgr; - Clear(); - _DEFSC_DEBUG(hLogfile.close()); -} - -void DefScriptPackage::Log(const char* fmt,...) -{ - va_list ap; - va_start(ap, fmt); - (*_slog)(fmt,ap); - va_end(ap); -} - -void DefScriptPackage::DebugLog(const char* fmt,...) -{ - va_list ap; - va_start(ap, fmt); - (*_sdebuglog)(fmt,ap); - va_end(ap); -} - -void DefScriptPackage::ErrorLog(const char* fmt,...) -{ - va_list ap; - va_start(ap, fmt); - (*_serrorlog)(fmt,ap); - va_end(ap); -} - -void DefScriptPackage::SetParentMethod(void *p) -{ - parentMethod = p; -} - -void DefScriptPackage::Clear(void) -{ - for(std::map::iterator i = Script.begin(); i != Script.end(); i++) - { - lists.Unlink(SCRIPT_NAMESPACE + i->first); // remove name from the list storage - delete i->second; // delete each script - } - - Script.empty(); -} - -void DefScriptPackage::_InitFunctions(void) -{ - AddFunc("out",&DefScriptPackage::func_out); - AddFunc("set",&DefScriptPackage::func_set,false); - AddFunc("default",&DefScriptPackage::func_default,false); - AddFunc("unset",&DefScriptPackage::func_unset); - AddFunc("shdn",&DefScriptPackage::func_shdn,false); - AddFunc("loaddef",&DefScriptPackage::func_loaddef); - AddFunc("reloaddef",&DefScriptPackage::func_reloaddef); - AddFunc("createdef",&DefScriptPackage::func_createdef); - AddFunc("unloaddef",&DefScriptPackage::func_unloaddef); - AddFunc("setscriptpermission",&DefScriptPackage::func_setscriptpermission); - AddFunc("toint",&DefScriptPackage::func_toint); - AddFunc("add",&DefScriptPackage::func_add); - AddFunc("sub",&DefScriptPackage::func_sub); - AddFunc("mul",&DefScriptPackage::func_mul); - AddFunc("div",&DefScriptPackage::func_div); - AddFunc("mod",&DefScriptPackage::func_mod); - AddFunc("pow",&DefScriptPackage::func_pow); - AddFunc("bitor",&DefScriptPackage::func_bitor); - AddFunc("bitand",&DefScriptPackage::func_bitand); - AddFunc("bitxor",&DefScriptPackage::func_bitxor); - AddFunc("addevent",&DefScriptPackage::func_addevent); - AddFunc("removeevent",&DefScriptPackage::func_removeevent); - AddFunc("abs",&DefScriptPackage::func_abs); - AddFunc("greater",&DefScriptPackage::func_bigger); - AddFunc("greater_eq",&DefScriptPackage::func_bigger_eq); - AddFunc("bigger",&DefScriptPackage::func_bigger); - AddFunc("bigger_eq",&DefScriptPackage::func_bigger_eq); - AddFunc("equal",&DefScriptPackage::func_equal); - AddFunc("isset",&DefScriptPackage::func_isset); - AddFunc("not",&DefScriptPackage::func_not); - AddFunc("smaller",&DefScriptPackage::func_smaller); - AddFunc("smaller_eq",&DefScriptPackage::func_smaller_eq); - AddFunc("strlen",&DefScriptPackage::func_strlen); - AddFunc("tohex",&DefScriptPackage::func_tohex); - AddFunc("and",&DefScriptPackage::func_and); - AddFunc("or",&DefScriptPackage::func_or); - AddFunc("xor",&DefScriptPackage::func_xor); - AddFunc("substr",&DefScriptPackage::func_substr); - AddFunc("uppercase",&DefScriptPackage::func_uppercase); - AddFunc("lowercase",&DefScriptPackage::func_lowercase); - AddFunc("random",&DefScriptPackage::func_random); - AddFunc("fileexists",&DefScriptPackage::func_fileexists); - AddFunc("strfind",&DefScriptPackage::func_strfind); - AddFunc("funcexists",&DefScriptPackage::func_funcexists); - AddFunc("scriptexists",&DefScriptPackage::func_scriptexists); - - // list functions - AddFunc("lpushback",&DefScriptPackage::func_lpushback); - AddFunc("lappend",&DefScriptPackage::func_lpushback); // alias for lpushback - AddFunc("lpushfront",&DefScriptPackage::func_lpushfront); - AddFunc("lpopback",&DefScriptPackage::func_lpopback); - AddFunc("lpopfront",&DefScriptPackage::func_lpopfront); - AddFunc("ldelete",&DefScriptPackage::func_ldelete); - AddFunc("lexists",&DefScriptPackage::func_lexists); - AddFunc("llen",&DefScriptPackage::func_llen); - AddFunc("linsert",&DefScriptPackage::func_linsert); - AddFunc("lsplit",&DefScriptPackage::func_lsplit); - AddFunc("lcsplit",&DefScriptPackage::func_lcsplit); - AddFunc("ljoin",&DefScriptPackage::func_ljoin); - AddFunc("lindex",&DefScriptPackage::func_lindex); - AddFunc("lclean",&DefScriptPackage::func_lclean); - AddFunc("lmclean",&DefScriptPackage::func_lmclean); - AddFunc("lerase",&DefScriptPackage::func_lerase); - AddFunc("lsort",&DefScriptPackage::func_lsort); - - // ByteBuffer functions - AddFunc("bbinit",&DefScriptPackage::func_bbinit); - AddFunc("bbdelete",&DefScriptPackage::func_bbdelete); - AddFunc("bbappend",&DefScriptPackage::func_bbappend); - AddFunc("bbread",&DefScriptPackage::func_bbread); - AddFunc("bbhexlike",&DefScriptPackage::func_bbhexlike); - AddFunc("bbtextlike",&DefScriptPackage::func_bbtextlike); - AddFunc("bbsetrpos",&DefScriptPackage::func_bbsetrpos); - AddFunc("bbsetwpos",&DefScriptPackage::func_bbsetwpos); - AddFunc("bbsize",&DefScriptPackage::func_bbsize); - - // file functions - AddFunc("fopen",&DefScriptPackage::func_fopen); - AddFunc("fclose",&DefScriptPackage::func_fclose); - AddFunc("fisopen",&DefScriptPackage::func_fisopen); - AddFunc("feof",&DefScriptPackage::func_feof); - AddFunc("frpos",&DefScriptPackage::func_frpos); - AddFunc("fwpos",&DefScriptPackage::func_fwpos); - AddFunc("fdel",&DefScriptPackage::func_fdel); - AddFunc("fflush",&DefScriptPackage::func_fflush); - AddFunc("fwrite",&DefScriptPackage::func_fwrite); - AddFunc("fread",&DefScriptPackage::func_fread); - AddFunc("freadb",&DefScriptPackage::func_freadb); - AddFunc("fwriteb",&DefScriptPackage::func_fwriteb); - AddFunc("freadbb",&DefScriptPackage::func_freadbb); - AddFunc("fwritebb",&DefScriptPackage::func_fwritebb); - AddFunc("fsize",&DefScriptPackage::func_fsize); - AddFunc("fexists",&DefScriptPackage::func_fileexists); // name alternative for "fileexists" - AddFunc("freadline",&DefScriptPackage::func_freadline); - AddFunc("fseekw",&DefScriptPackage::func_fseekw); - AddFunc("fseekr",&DefScriptPackage::func_fseekr); -} - -void DefScriptPackage::AddFunc(std::string n,DefReturnResult (DefScriptPackage::*f)(CmdSet& Set), bool esc) -{ - DefScriptFunctionEntry e(n,f,esc); - AddFunc(e); -} - -void DefScriptPackage::AddFunc(DefScriptFunctionEntry e) -{ - if( (!e.name.empty()) && (!HasFunc(e.name)) ) - _functable.push_back(e); -} - -bool DefScriptPackage::HasFunc(std::string n) -{ - for(DefScriptFunctionTable::iterator i=_functable.begin();i!=_functable.end();i++) - if(i->name==n) - return true; - return false; -} - -void DefScriptPackage::DelFunc(std::string n) -{ - for(DefScriptFunctionTable::iterator i=_functable.begin();i!=_functable.end();i++) - if(i->name==n) - { - _functable.erase(i); - break; - } -} - -void DefScriptPackage::SetPath(std::string p){ - scPath=p; -} - -DefScript *DefScriptPackage::GetScript(std::string scname){ - return ScriptExists(scname) ? Script[scname] : NULL; -} - -unsigned int DefScriptPackage::GetScripts(void){ - return Script.size(); -} - -DefScript_DynamicEventMgr *DefScriptPackage::GetEventMgr(void) -{ - return _eventmgr; -} - -bool DefScriptPackage::ScriptExists(std::string name) -{ - for (std::map::iterator i = Script.begin();i != Script.end();i++) - if(i->first == name && i->second != NULL) - return true; - return false; -} - -void DefScriptPackage::DeleteScript(std::string sn) -{ - lists.Unlink(SCRIPT_NAMESPACE + sn); // remove name from the list storage - if(ScriptExists(sn)) - { - - delete GetScript(sn); // delete the script itself - Script.erase(sn); // remove reference - } -} - -bool DefScriptPackage::LoadByName(std::string name){ - return LoadScriptFromFile((scPath+name).append(".def")); -} - -bool DefScriptPackage::LoadScriptFromFile(std::string fn){ - if(fn.empty()) - return false; - - std::string label, value, line, sn; - std::fstream f; - bool load_debug=false,load_notify=false,cantload=false; - bool line_strip = true; // true by default - bool commented = false; - bool escape_all = false; - char z; - unsigned int absline=0; - DefScript *curScript = NULL; - - f.open(fn.c_str(),std::ios_base::in); - if(!f.is_open()) - return false; - - std::deque Blocks; - - // auto-assign the scriptname as the plain filename without extension. can be changed while loading - unsigned int slashpos = fn.find_last_of("\\/"); - if(slashpos == std::string::npos) - slashpos = 0; - unsigned int ppos = fn.find_last_of("."); - if(ppos == std::string::npos) - ppos = fn.length(); - sn = stringToLower(fn.substr(slashpos+1,(ppos-slashpos-1))); - _UpdateOrCreateScriptByName(sn); - curScript=Script[sn]; - - DeleteScript(SN_ONLOAD); - - while(!f.eof()) - { - line.clear(); - while (true) - { - f.get(z); - if(z=='\n' || f.eof()) - break; - line+=z; - } - absline++; - if(line.empty()) - continue; // line is empty, proceed with next line - - while( !line.empty() && (line.at(0)==' ' || line.at(0)=='\t') ) - line.erase(0,1); - if(line.empty()) - continue; - if(line.at(0)=='/' && line.at(1)=='/') - continue; // line is comment, proceed with next line - - if(line_strip) - { - // strip comments at the end of the line - unsigned int cmpos = 0; - while(true) - { - // note: this must also cover lines like: "out blah \// no-comment // comment" - cmpos = line.find("//",cmpos+1); // start searching at one position later then previous - if(cmpos != std::string::npos) - { - if(line[cmpos-1] == '\\') - continue; - line = line.substr(0,cmpos); - break; - } - else - break; - } - - // strip spaces at the end of the line - while(line.at(line.length()-1) == ' ' || line.at(line.length()-1) == '\t') - { - line.erase(line.length()-1,1); - } - } - - // need to check comments-end seperatedly - if(line=="#ce" || line=="#comments-end") - { - commented = false; - continue; - } - - // commented lines will not be loaded nor have any #-tags evaluated (except the one above!) - if(commented) - continue; - - if(line.at(0)=='#') - { - line.erase(0,1); // remove # - label=line.substr(0,line.find('=',0)); - value=line.substr(line.find('=',0)+1,line.length()); - if(label=="permission") - { - scriptPermissionMap[sn] = atoi(value.c_str()); - } - else if(label=="script") - { - if(!curScript->GetLines()) // delete script if unused - DeleteScript(curScript->GetName()); - sn = stringToLower(value); - _UpdateOrCreateScriptByName(sn); - _DEFSC_DEBUG(printf("DefScript: now loading '%s'\n",sn.c_str())); - curScript=Script[sn]; - } - else if(label=="linestrip") - { - line_strip = isTrue(value); - } - else if(label=="escape-all") - { - escape_all = isTrue(value); - } - else if(line=="debug") - { - if(curScript) - curScript->SetDebug(true); - } - else if(line=="onload") - { - _UpdateOrCreateScriptByName(SN_ONLOAD); - curScript=Script[SN_ONLOAD]; - } - else if(line=="endonload" || line=="/onload") - { - RunScript(SN_ONLOAD,NULL,sn); - DeleteScript(SN_ONLOAD); - curScript=Script[sn]; - } - else if(line=="cs" || line=="comments-start") - { - commented = true; - } - else if(strncmp(line.c_str(),"tag",3)==0 || strncmp(line.c_str(),"mark",4)==0) - { - curScript->AddLine("#" + line); - } - - //... - continue; // line was an option, not script content - } - - if(escape_all) - { - line = EscapeString(line); - } - - // help with loading lines where a space or tab have accidently been put after the cmd - std::string tline=stringToLower(line); - if(memcmp(tline.c_str(),"else ",5)==0 || memcmp(tline.c_str(),"else\t",5)==0) tline="else"; - else if(memcmp(tline.c_str(),"endif ",6)==0 || memcmp(tline.c_str(),"endif\t",5)==0) tline="endif"; - else if(memcmp(tline.c_str(),"loop ",5)==0 || memcmp(tline.c_str(),"loop\t",5)==0) tline="loop"; - else if(memcmp(tline.c_str(),"endloop ",8)==0 || memcmp(tline.c_str(),"endloop\t",8)==0) tline="endloop"; - if(tline=="else" || tline=="endif" || tline=="loop" || tline=="endloop") - line=tline; - - // check for correct block match - if(memcmp(tline.c_str(),"if ",3)==0) // need to check lowercased line! (IF may be uppercased) - Blocks.push_back(BLOCK_IF); - else if(line=="else") - { - if(Blocks.empty() || Blocks.back()!=BLOCK_IF) - { - cantload=true; - break; - } - } - else if(line=="endif") - { - if(Blocks.empty() || Blocks.back()!=BLOCK_IF) - { - cantload=true; - break; - } - Blocks.pop_back(); - } - else if(line=="loop") - Blocks.push_back(BLOCK_LOOP); - else if(line=="exitloop" && !Blocks.size()) // TODO: check: at least one BLOCK_LOOP must be opened - { - cantload=true; - break; - } - else if(line=="endloop") - { - if(Blocks.empty() || Blocks.back()!=BLOCK_LOOP) - { - cantload=true; - break; - } - Blocks.pop_back(); - } - - // check for correct bracket match - unsigned int bopen=0; - bool mismatch=false; - for(unsigned int bpos=0;bposAddLine(line); - } - f.close(); - if(cantload || Blocks.size()) - { - printf("DefScript: Error loading file '%s'. block mismatch?\n",fn.c_str()); - DeleteScript(sn); - return false; - } - - // ... - return true; -} - - -// --- SECTION FOR THE INDIVIDUAL SCRIPTS IN A PACKAGE --- - -DefScript::DefScript(DefScriptPackage *p) -{ - _parent=p; - scriptname="{NONAME}"; - debugmode=false; -} - -DefScript::~DefScript() -{ - Clear(); -} - -void DefScript::Clear(void) -{ - Line.clear(); -} - -void DefScript::SetDebug(bool d) -{ - debugmode=d; -} - -bool DefScript::GetDebug(void) -{ - return debugmode; -} - -void DefScript::SetName(std::string name) -{ - scriptname=name; -} - -std::string DefScript::GetName(void) -{ - return scriptname; -} - -bool DefScript::AddLine(std::string l){ - if(l.empty()) - return false; - Line.push_back(l); - return true; -} - - -// --- SECTION FOR COMMAND SETS --- - -CmdSet::CmdSet() -{ -} - -CmdSet::~CmdSet() -{ -} - -void CmdSet::Clear() -{ - arg.clear(); - cmd=""; - defaultarg=""; - caller=""; - myname=""; -} - - -// --- FUNCTIONS TO PARSE AND EXECUTE A SCRIPT --- PARENT: DefScriptPackage! - - -// the referred pSet is the parent from which RunScript() has been called -bool DefScriptPackage::BoolRunScript(std::string name, CmdSet *pSet) -{ - DefReturnResult r = RunScript(name,pSet); - return r.ok; -} - -// the referred pSet is the parent from which RunScript() has been called -DefReturnResult DefScriptPackage::RunScript(std::string name, CmdSet *pSet,std::string override_name) -{ - DefReturnResult r; - if( (!ScriptExists(name)) && (!HasFunc(name)) ) - { - r.ok=false; // doesnt exist - r.ret=""; - return r; - } - - DefScript *sc = GetScript(name); - if(!sc) - { - r.ok=false; - r.ret=""; - return r; - } - - if(!override_name.empty()) - name=override_name; - - CmdSet temp; - if(!pSet) - { - pSet = &temp; - } - pSet->caller=pSet->myname; - pSet->myname=name; - - std::deque Blocks; - CmdSet mySet; - std::string line; - - for(unsigned int i=0;iGetLines();i++) - { - line=sc->GetLine(i); - if(line.empty() || line[0] == '#') // skip markers and preload statements if not removed before - continue; - if(line=="else") - { - if(!Blocks.size()) - { - printf("DEBUG: else-block without any block?! [%s:%u]\n",name.c_str(),i); - r.ok=false; - break; - } - Def_Block b=Blocks.back(); - if(b.type==BLOCK_IF && b.istrue) - { - unsigned int other_ifs=0; - for(i=b.startline+1;;i++) - { - if(memcmp(sc->GetLine(i).c_str(),"if ",3)==0) - other_ifs++; - else if(sc->GetLine(i)=="endif") - { - if(!other_ifs) - break; - other_ifs--; - } - } - i--; // next line read will be "endif", decide then what to do - } - continue; - } - else if(line=="endif") - { - if(!Blocks.size()) - { - printf("DEBUG: endif without any block [%s:%u]\n",name.c_str(),i); - r.ok=false; - break; - } - if(Blocks.back().type!=BLOCK_IF) - { - printf("DEBUG: endif: closed block is not an if block! [%s:%u]\n",name.c_str(),i); - r.ok=false; - break; - } - Blocks.pop_back(); - continue; - } - else if(line=="loop") - { - Def_Block b; - b.startline=i; - b.type=BLOCK_LOOP; - b.istrue=true; - Blocks.push_back(b); - continue; - } - else if(line=="endloop") - { - if(!Blocks.size()) - { - printf("DEBUG: endloop without any block [%s:%u]\n",name.c_str(),i); - r.ok=false; - break; - } - if(Blocks.back().type!=BLOCK_LOOP) - { - printf("DEBUG: endloop: closed block is not a loop block! [%s:%u]\n",name.c_str(),i); - r.ok=false; - break; - } - i=Blocks.back().startline; // next line executed will be the line after "loop" - continue; - } - //_DEFSC_DEBUG(printf("DefScript before: \"%s\"\n",line.c_str())); - DefXChgResult final=ReplaceVars(line,pSet,0,true); - //_DEFSC_DEBUG(printf("DefScript parsed: \"%s\"\n",final.str.c_str())); - mySet.Clear(); - SplitLine(mySet,final.str); - if(mySet.cmd=="if") - { - Def_Block b; - b.startline=i; - b.type=BLOCK_IF; - b.istrue=isTrue(mySet.defaultarg); - Blocks.push_back(b); - if(!b.istrue) - { - unsigned int other_ifs=0; - for(i=b.startline+1; i < sc->GetLines() ;i++) - { - if(!memcmp(sc->GetLine(i).c_str(),"if ",3)) - other_ifs++; - if(sc->GetLine(i)=="else" || sc->GetLine(i)=="endif") - { - if(!other_ifs) - break; - if(sc->GetLine(i)=="endif") - other_ifs--; - } - } - i--; // next line read will be either "else" or "endif", decide then what to do - } - continue; // and read line after "else" - } - else if(mySet.cmd=="exitloop") - { - // skip some ifs if they are present - while(Blocks.back().type!=BLOCK_LOOP) - Blocks.pop_back(); - Blocks.pop_back(); - unsigned int other_loops=0; - - while(true) - { - if(sc->GetLine(i)=="loop") - other_loops++; - if(sc->GetLine(i)=="endloop") - { - if(!other_loops) - break; - other_loops--; - } - i++; // go until next endloop - } - // next line read will be the line after "endloop" - continue; - } - - mySet.myname=name; - mySet.caller=pSet?pSet->myname:""; - r=Interpret(mySet); - if(r.mustreturn) - { - r.mustreturn=false; - break; - } - } - return r; -} - -DefReturnResult DefScriptPackage::RunSingleLine(std::string line) -{ - DefXChgResult final=ReplaceVars(line,NULL,0,true); - CmdSet Set; - SplitLine(Set,final.str); - return Interpret(Set); -} - -DefReturnResult DefScriptPackage::RunSingleLineFromScript(std::string line, DefScript *pScript) -{ - CmdSet Set; - Set.myname=pScript->GetName(); - DefXChgResult final=ReplaceVars(line,&Set,0,true); - SplitLine(Set,final.str); - return Interpret(Set); -} - -void DefScriptPackage::SplitLine(CmdSet& Set,std::string line) -{ - - unsigned int i=0; - unsigned int bracketsOpen=0,curParam=0; - bool cmdDefined=false; - std::string tempLine; - -// extract cmd+params and txt - for(i=0;i0 && (t[i-1]=='$' || t[i-1]=='?') ) - isVar=true; - if(!bo) - ob=i; - bo++; - } - else if(t[i]=='}') - { - bo--; - if(!bo) - { - if(!isVar) - { - unsigned int blen=i-ob+1; - std::string subStr=t.substr(ob,blen); - std::string retStr=RemoveBracketsFromString(subStr); - t.erase(ob,blen); - t.insert(ob,retStr); - i=ob-1; - - } - isVar=false; - } - } - else if(t[i]=='\\') - { - i++; - continue; - } - - } - - return t; -} - -void DefScriptPackage::RemoveBrackets(CmdSet& Set) -{ - Set.defaultarg=RemoveBracketsFromString(Set.defaultarg); - Set.cmd=RemoveBracketsFromString(Set.cmd); - for(_CmdSetArgMap::iterator i=Set.arg.begin(); i!=Set.arg.end(); i++) - { - i->second=RemoveBracketsFromString(i->second); - } -} - -void DefScriptPackage::UnescapeSet(CmdSet& Set) -{ - Set.defaultarg=UnescapeString(Set.defaultarg); - //Set.cmd=UnescapeString(Set.cmd); // this is done already in SplitLine() ! - for(_CmdSetArgMap::iterator i=Set.arg.begin(); i!=Set.arg.end(); i++) - { - i->second=UnescapeString(i->second); - } -} - - -DefXChgResult DefScriptPackage::ReplaceVars(std::string str, CmdSet *pSet, unsigned char VarType, bool run_embedded) -{ - - unsigned int - openingBracket=0, // defines the position from where the recursive call is started - closingBracket=0, // the closing bracket - bracketsOpen=0, // amount of brackets opened - bLen=0; // the lenth of the string in brackets, e.g. ${abc} == 3 - - unsigned char - nextVar=DEFSCRIPT_NONE; // '$' or '?' - bool - hasChanged=false, // additional helper. once true, xchg.result will be true later also - hasVar=false, // true if openingBracket (= the first bracket) was preceded by '$' or '?' - escaped=false; - - std::string subStr; - DefXChgResult xchg; - - for(unsigned int i=0;i0 && str[i-1]=='$') - { - hasVar=true; - if(!bracketsOpen) - nextVar=DEFSCRIPT_VAR; - } - if(i>0 && str[i-1]=='?') - { - hasVar=true; - if(!bracketsOpen) - nextVar=DEFSCRIPT_FUNC; - } - bracketsOpen++; - } - else if(str[i]=='}') - { - if(bracketsOpen) - bracketsOpen--; - if(!bracketsOpen) - { - closingBracket=i; - if(nextVar==DEFSCRIPT_NONE && VarType==DEFSCRIPT_VAR && !hasVar) // remove brackets in var names, like ${var{ia}ble} - { - str.erase(closingBracket,1); - str.erase(openingBracket,1); - i=openingBracket; // jump to the pos where the opening bracket was - continue; - } - else - { - bLen=closingBracket-openingBracket-1; - subStr=str.substr(openingBracket+1,bLen); - //printf("SUBSTR: \"%s\"\n",subStr.c_str()); - xchg=ReplaceVars(subStr,pSet,nextVar,run_embedded); - if( nextVar==DEFSCRIPT_NONE && hasVar && xchg.changed ) - { - str.erase(openingBracket+1,subStr.length()); - str.insert(openingBracket+1,xchg.str); - hasVar=false; - i-=(subStr.length()+1); - hasChanged=true; - } - else if( nextVar!=DEFSCRIPT_NONE && hasVar && xchg.changed ) - { - str.erase(openingBracket-1,bLen+3); // remove ${...} (+3 because of '${}') - i-=(bLen+2); // adjust position - str.insert(i,xchg.str); - if(str[i]=='\\') // workaround, since i will be increased 1 too high - escaped=true; - hasVar=false; - nextVar=DEFSCRIPT_NONE; - } - } - } - } // end if '}' - else if(str[i]=='\\') // if escape char \ found, skip parsing next char - { - i++; - continue; - } - } // end for - if(!bracketsOpen && VarType!=DEFSCRIPT_NONE) - { - // fix for empty var: ${} - if(str.empty()) - { - xchg.str=""; - xchg.changed=true; - return xchg; - } - if(VarType==DEFSCRIPT_VAR) - { - std::string vname=_NormalizeVarName(str, (pSet==NULL) ? "" : pSet->myname); - if(vname[0]=='@') - { - std::stringstream vns; - std::string subs=vname.substr(1,str.length()-1); - unsigned int vn=atoi( subs.c_str() ); - vns << vn; - if(pSet && vns.str()==subs) // resolve arg macros @0 - @4294967295 - str=pSet->arg[vn]; - else if(pSet && subs=="def") - str=pSet->defaultarg; - else if(pSet && subs=="myname") - str=pSet->myname; - else if(pSet && subs=="cmd") - str=pSet->cmd; - else if(pSet && subs=="caller") - str=pSet->caller; - else if(subs=="n") - str="\n"; - else if(subs=="clock") - { - std::stringstream clock_s; - clock_s << clock(); - str = clock_s.str(); - } - else if(subs=="time") - { - std::stringstream time_s; - time_s << time(NULL); - str = time_s.str(); - } - else if(variables.Exists(vname)) - str=variables.Get(vname); - else - { - // TODO: call custom macro table - //... - str.clear(); - } - xchg.changed=true; - } - else - { - if(variables.Exists(vname)) - { - str=variables.Get(vname); - xchg.changed=true; - } - } - } - else if(VarType==DEFSCRIPT_FUNC) - { - if(run_embedded) - { - DefReturnResult res; - if(pSet) - res=RunSingleLineFromScript(str,GetScript(pSet->myname)); - else - res=RunSingleLine(str); - str=res.ret; // returns empty string on invalid function!! - xchg.result.ok=res.ok; - xchg.changed=true; - //xchg.result.err += res.err; - } - else // if not allowed to run scripts via ?{...} - { - str=""; // just replace with 0 - xchg.changed=true; // yes we have changed something - xchg.result.ok=true; // change ok, insert our (empty) return value - } - } - } - - xchg.str = str; - if(hasChanged) - xchg.changed=true; - return xchg; -} - -std::string DefScriptPackage::_NormalizeVarName(std::string vn_in, std::string sn){ - if(vn_in.empty()) - return vn_in; - std::string vn=vn_in; - bool global=false; - if(sn.empty()) - global = true; - while(true) - { - if(vn.at(0)=='#') - global = true; - if(vn.at(0)=='#' || vn.at(0)==':') - vn.erase(0,1); - else - break; - } - - if( (!global) && (vn.at(0)!='@') ) - vn=sn+"::"+vn; - - return vn; -} - -DefReturnResult DefScriptPackage::Interpret(CmdSet& Set) -{ - // TODO: remove this debug block again as soon as the interpreter bugs are fixed. - _DEFSC_DEBUG - ( - hLogfile << "PARENT: '" << Set.caller << "'\n"; - hLogfile << "cmd = '" << Set.cmd << "'\n"; - unsigned int ctr=0; - for(_CmdSetArgMap::iterator i=Set.arg.begin(); i!=Set.arg.end(); i++) - hLogfile << "arg[" << ctr++ << "] = '" << i->second << "'\n"; - hLogfile << "defaultarg = '" << Set.defaultarg << "'\n\n"; - ); - - DefReturnResult result; - - // first search if the script is defined in the internal functions - for(unsigned int i=0;i<_functable.size();i++) - { - if(Set.cmd==_functable[i].name) - { - if(_functable[i].escape) // if we are going to use a C++ function, unescape the whole set, if supposed to do so. - UnescapeSet(Set); // it will not have any bad side effects, we leave the func within this block! - - result=(this->*(_functable[i].func))(Set); - if(_functable[i].escape) - result.ret = EscapeString(result.ret); // and since we are returning a string into the engine, escape it again, if set. - return result; - } - } - - if(Set.cmd=="return") - { - result.mustreturn=true; - result.ret=Set.defaultarg; - return result; - } - - // if nothing has been found its maybe an external script file to run - result=RunScript(Set.cmd, &Set); - if((!result.ok) /*&& Script[Set.cmd]->GetDebug()*/) - std::cout << "Could not execute script command '" << Set.cmd << "'\n"; - - - return result; -} - -void DefScriptPackage::_UpdateOrCreateScriptByName(std::string sn) -{ - if(GetScript(sn)) - DeleteScript(sn); - DefScript *newscript = new DefScript(this); - newscript->SetName(sn); // necessary that the script knows its own name - Script[sn] = newscript; - lists.Assign(SCRIPT_NAMESPACE + sn, &(newscript->Line)); -} - -std::string DefScriptPackage::SecureString(std::string s) -{ - std::string out; - for(unsigned int i = 0; i < s.length(); i++) - { - if(s[i] == '{') - out += '['; - else if(s[i] == '}') - out += ']'; - else - out += s[i]; - } - return out; -} - -// escapes whole string, which can no longer be parsed & interpreted -std::string DefScriptPackage::EscapeString(std::string s) -{ - std::string out; - out.reserve(s.length()+8); - for(unsigned int i = 0; i < s.length(); i++) - { - switch(s[i]) - { - case '{': - case '}': - case '\\': - out += '\\'; - out += s[i]; - break; - - case '\n': - out += "\\n"; - break; - - case '\t': - out += "\\t"; - break; - - default: - out += s[i]; - } - - } - return out; -} - -// converts a string into a printable form, with all escape sequences resolved -std::string DefScriptPackage::UnescapeString(std::string s) -{ - std::string out; - out.reserve(s.length()); - for(unsigned int i = 0; i < s.length(); i++) - { - if(s[i] == '\\' && i+1 < s.length()) - { - switch(s[i+1]) - { // if any of these are found, append to output string and skip this byte - case '{': - case '}': - case '\\': - out += s[++i]; - break; - - case 'n': - out += '\n'; - i++; - break; - - case 't': - out += '\t'; - i++; - break; - - case 'x': - if(i+4 <= s.length()) - { - std::string xd = s.substr(i+2,2); - char c = (char)strtoul(s.substr(i+2,2).c_str(),NULL,16); - out += c; - i += 3; - } - } - } - else - { - out += s[i]; - } - } - return out; -} - -std::string DefScriptPackage::GetUnescapedVar(std::string n) -{ - return UnescapeString(variables.Get(n)); -} - -bool DefScriptPackage::RunScriptIfExists(std::string name,CmdSet *pSet) -{ - if(ScriptExists(name)) - { - return BoolRunScript(name,pSet); - } - return false; -} +#include +#include +#include +#include +#include +#include +#include +#include "VarSet.h" +#include "DefScript.h" + +using namespace DefScriptTools; + +#define SN_ONLOAD "?onload?" + +enum DefScriptBlockType +{ + BLOCK_IF, + BLOCK_LOOP +}; + +// --- SECTION FOR SCRIPT PACKAGES --- +DefScriptPackage::DefScriptPackage() +{ + SetLog(printf); + SetDebugLog(printf); + SetErrorLog(printf); + _DEFSC_DEBUG + ( + hLogfile.open("DefScriptLog.txt",std::ios_base::out); + hLogfile << "DefScript engine execution log, compilation date: " __DATE__ " " __TIME__ "\n\n" ; + ) + _eventmgr=new DefScript_DynamicEventMgr(this); + _InitFunctions(); +# ifdef USING_DEFSCRIPT_EXTENSIONS + _InitDefScriptInterface(); +# endif +} + +DefScriptPackage::~DefScriptPackage() +{ + if(_eventmgr) + delete _eventmgr; + Clear(); + _DEFSC_DEBUG(hLogfile.close()); +} + +void DefScriptPackage::Log(const char* fmt,...) +{ + va_list ap; + va_start(ap, fmt); + (*_slog)(fmt,ap); + va_end(ap); +} + +void DefScriptPackage::DebugLog(const char* fmt,...) +{ + va_list ap; + va_start(ap, fmt); + (*_sdebuglog)(fmt,ap); + va_end(ap); +} + +void DefScriptPackage::ErrorLog(const char* fmt,...) +{ + va_list ap; + va_start(ap, fmt); + (*_serrorlog)(fmt,ap); + va_end(ap); +} + +void DefScriptPackage::SetParentMethod(void *p) +{ + parentMethod = p; +} + +void DefScriptPackage::Clear(void) +{ + for(std::map::iterator i = Script.begin(); i != Script.end(); i++) + { + lists.Unlink(SCRIPT_NAMESPACE + i->first); // remove name from the list storage + delete i->second; // delete each script + } + + Script.empty(); +} + +void DefScriptPackage::_InitFunctions(void) +{ + AddFunc("out",&DefScriptPackage::func_out); + AddFunc("set",&DefScriptPackage::func_set,false); + AddFunc("default",&DefScriptPackage::func_default,false); + AddFunc("unset",&DefScriptPackage::func_unset); + AddFunc("shdn",&DefScriptPackage::func_shdn,false); + AddFunc("loaddef",&DefScriptPackage::func_loaddef); + AddFunc("reloaddef",&DefScriptPackage::func_reloaddef); + AddFunc("createdef",&DefScriptPackage::func_createdef); + AddFunc("unloaddef",&DefScriptPackage::func_unloaddef); + AddFunc("setscriptpermission",&DefScriptPackage::func_setscriptpermission); + AddFunc("toint",&DefScriptPackage::func_toint); + AddFunc("add",&DefScriptPackage::func_add); + AddFunc("sub",&DefScriptPackage::func_sub); + AddFunc("mul",&DefScriptPackage::func_mul); + AddFunc("div",&DefScriptPackage::func_div); + AddFunc("mod",&DefScriptPackage::func_mod); + AddFunc("pow",&DefScriptPackage::func_pow); + AddFunc("bitor",&DefScriptPackage::func_bitor); + AddFunc("bitand",&DefScriptPackage::func_bitand); + AddFunc("bitxor",&DefScriptPackage::func_bitxor); + AddFunc("addevent",&DefScriptPackage::func_addevent); + AddFunc("removeevent",&DefScriptPackage::func_removeevent); + AddFunc("abs",&DefScriptPackage::func_abs); + AddFunc("greater",&DefScriptPackage::func_bigger); + AddFunc("greater_eq",&DefScriptPackage::func_bigger_eq); + AddFunc("bigger",&DefScriptPackage::func_bigger); + AddFunc("bigger_eq",&DefScriptPackage::func_bigger_eq); + AddFunc("equal",&DefScriptPackage::func_equal); + AddFunc("isset",&DefScriptPackage::func_isset); + AddFunc("not",&DefScriptPackage::func_not); + AddFunc("smaller",&DefScriptPackage::func_smaller); + AddFunc("smaller_eq",&DefScriptPackage::func_smaller_eq); + AddFunc("strlen",&DefScriptPackage::func_strlen); + AddFunc("tohex",&DefScriptPackage::func_tohex); + AddFunc("and",&DefScriptPackage::func_and); + AddFunc("or",&DefScriptPackage::func_or); + AddFunc("xor",&DefScriptPackage::func_xor); + AddFunc("substr",&DefScriptPackage::func_substr); + AddFunc("uppercase",&DefScriptPackage::func_uppercase); + AddFunc("lowercase",&DefScriptPackage::func_lowercase); + AddFunc("random",&DefScriptPackage::func_random); + AddFunc("fileexists",&DefScriptPackage::func_fileexists); + AddFunc("strfind",&DefScriptPackage::func_strfind); + AddFunc("funcexists",&DefScriptPackage::func_funcexists); + AddFunc("scriptexists",&DefScriptPackage::func_scriptexists); + + // list functions + AddFunc("lpushback",&DefScriptPackage::func_lpushback); + AddFunc("lappend",&DefScriptPackage::func_lpushback); // alias for lpushback + AddFunc("lpushfront",&DefScriptPackage::func_lpushfront); + AddFunc("lpopback",&DefScriptPackage::func_lpopback); + AddFunc("lpopfront",&DefScriptPackage::func_lpopfront); + AddFunc("ldelete",&DefScriptPackage::func_ldelete); + AddFunc("lexists",&DefScriptPackage::func_lexists); + AddFunc("llen",&DefScriptPackage::func_llen); + AddFunc("linsert",&DefScriptPackage::func_linsert); + AddFunc("lsplit",&DefScriptPackage::func_lsplit); + AddFunc("lcsplit",&DefScriptPackage::func_lcsplit); + AddFunc("ljoin",&DefScriptPackage::func_ljoin); + AddFunc("lindex",&DefScriptPackage::func_lindex); + AddFunc("lclean",&DefScriptPackage::func_lclean); + AddFunc("lmclean",&DefScriptPackage::func_lmclean); + AddFunc("lerase",&DefScriptPackage::func_lerase); + AddFunc("lsort",&DefScriptPackage::func_lsort); + + // ByteBuffer functions + AddFunc("bbinit",&DefScriptPackage::func_bbinit); + AddFunc("bbdelete",&DefScriptPackage::func_bbdelete); + AddFunc("bbappend",&DefScriptPackage::func_bbappend); + AddFunc("bbread",&DefScriptPackage::func_bbread); + AddFunc("bbhexlike",&DefScriptPackage::func_bbhexlike); + AddFunc("bbtextlike",&DefScriptPackage::func_bbtextlike); + AddFunc("bbsetrpos",&DefScriptPackage::func_bbsetrpos); + AddFunc("bbsetwpos",&DefScriptPackage::func_bbsetwpos); + AddFunc("bbsize",&DefScriptPackage::func_bbsize); + + // file functions + AddFunc("fopen",&DefScriptPackage::func_fopen); + AddFunc("fclose",&DefScriptPackage::func_fclose); + AddFunc("fisopen",&DefScriptPackage::func_fisopen); + AddFunc("feof",&DefScriptPackage::func_feof); + AddFunc("frpos",&DefScriptPackage::func_frpos); + AddFunc("fwpos",&DefScriptPackage::func_fwpos); + AddFunc("fdel",&DefScriptPackage::func_fdel); + AddFunc("fflush",&DefScriptPackage::func_fflush); + AddFunc("fwrite",&DefScriptPackage::func_fwrite); + AddFunc("fread",&DefScriptPackage::func_fread); + AddFunc("freadb",&DefScriptPackage::func_freadb); + AddFunc("fwriteb",&DefScriptPackage::func_fwriteb); + AddFunc("freadbb",&DefScriptPackage::func_freadbb); + AddFunc("fwritebb",&DefScriptPackage::func_fwritebb); + AddFunc("fsize",&DefScriptPackage::func_fsize); + AddFunc("fexists",&DefScriptPackage::func_fileexists); // name alternative for "fileexists" + AddFunc("freadline",&DefScriptPackage::func_freadline); + AddFunc("fseekw",&DefScriptPackage::func_fseekw); + AddFunc("fseekr",&DefScriptPackage::func_fseekr); +} + +void DefScriptPackage::AddFunc(std::string n,DefReturnResult (DefScriptPackage::*f)(CmdSet& Set), bool esc) +{ + DefScriptFunctionEntry e(n,f,esc); + AddFunc(e); +} + +void DefScriptPackage::AddFunc(DefScriptFunctionEntry e) +{ + if( (!e.name.empty()) && (!HasFunc(e.name)) ) + _functable.push_back(e); +} + +bool DefScriptPackage::HasFunc(std::string n) +{ + for(DefScriptFunctionTable::iterator i=_functable.begin();i!=_functable.end();i++) + if(i->name==n) + return true; + return false; +} + +void DefScriptPackage::DelFunc(std::string n) +{ + for(DefScriptFunctionTable::iterator i=_functable.begin();i!=_functable.end();i++) + if(i->name==n) + { + _functable.erase(i); + break; + } +} + +void DefScriptPackage::SetPath(std::string p){ + scPath=p; +} + +DefScript *DefScriptPackage::GetScript(std::string scname){ + return ScriptExists(scname) ? Script[scname] : NULL; +} + +unsigned int DefScriptPackage::GetScripts(void){ + return Script.size(); +} + +DefScript_DynamicEventMgr *DefScriptPackage::GetEventMgr(void) +{ + return _eventmgr; +} + +bool DefScriptPackage::ScriptExists(std::string name) +{ + for (std::map::iterator i = Script.begin();i != Script.end();i++) + if(i->first == name && i->second != NULL) + return true; + return false; +} + +void DefScriptPackage::DeleteScript(std::string sn) +{ + lists.Unlink(SCRIPT_NAMESPACE + sn); // remove name from the list storage + if(ScriptExists(sn)) + { + + delete GetScript(sn); // delete the script itself + Script.erase(sn); // remove reference + } +} + +bool DefScriptPackage::LoadByName(std::string name){ + return LoadScriptFromFile((scPath+name).append(".def")); +} + +bool DefScriptPackage::LoadScriptFromFile(std::string fn){ + if(fn.empty()) + return false; + + std::string label, value, line, sn; + std::fstream f; + bool load_debug=false,load_notify=false,cantload=false; + bool line_strip = true; // true by default + bool commented = false; + bool escape_all = false; + char z; + unsigned int absline=0; + DefScript *curScript = NULL; + + f.open(fn.c_str(),std::ios_base::in); + if(!f.is_open()) + return false; + + std::deque Blocks; + + // auto-assign the scriptname as the plain filename without extension. can be changed while loading + unsigned int slashpos = fn.find_last_of("\\/"); + if(slashpos == std::string::npos) + slashpos = 0; + unsigned int ppos = fn.find_last_of("."); + if(ppos == std::string::npos) + ppos = fn.length(); + sn = stringToLower(fn.substr(slashpos+1,(ppos-slashpos-1))); + _UpdateOrCreateScriptByName(sn); + curScript=Script[sn]; + + DeleteScript(SN_ONLOAD); + + while(!f.eof()) + { + line.clear(); + while (true) + { + f.get(z); + if(z=='\n' || f.eof()) + break; + line+=z; + } + absline++; + if(line.empty()) + continue; // line is empty, proceed with next line + + while( !line.empty() && (line.at(0)==' ' || line.at(0)=='\t') ) + line.erase(0,1); + if(line.empty()) + continue; + if(line.at(0)=='/' && line.at(1)=='/') + continue; // line is comment, proceed with next line + + if(line_strip) + { + // strip comments at the end of the line + unsigned int cmpos = 0; + while(true) + { + // note: this must also cover lines like: "out blah \// no-comment // comment" + cmpos = line.find("//",cmpos+1); // start searching at one position later then previous + if(cmpos != std::string::npos) + { + if(line[cmpos-1] == '\\') + continue; + line = line.substr(0,cmpos); + break; + } + else + break; + } + + // strip spaces at the end of the line + while(line.at(line.length()-1) == ' ' || line.at(line.length()-1) == '\t') + { + line.erase(line.length()-1,1); + } + } + + // need to check comments-end seperatedly + if(line=="#ce" || line=="#comments-end") + { + commented = false; + continue; + } + + // commented lines will not be loaded nor have any #-tags evaluated (except the one above!) + if(commented) + continue; + + if(line.at(0)=='#') + { + line.erase(0,1); // remove # + label=line.substr(0,line.find('=',0)); + value=line.substr(line.find('=',0)+1,line.length()); + if(label=="permission") + { + scriptPermissionMap[sn] = atoi(value.c_str()); + } + else if(label=="script") + { + if(!curScript->GetLines()) // delete script if unused + DeleteScript(curScript->GetName()); + sn = stringToLower(value); + _UpdateOrCreateScriptByName(sn); + _DEFSC_DEBUG(printf("DefScript: now loading '%s'\n",sn.c_str())); + curScript=Script[sn]; + } + else if(label=="linestrip") + { + line_strip = isTrue(value); + } + else if(label=="escape-all") + { + escape_all = isTrue(value); + } + else if(line=="debug") + { + if(curScript) + curScript->SetDebug(true); + } + else if(line=="onload") + { + _UpdateOrCreateScriptByName(SN_ONLOAD); + curScript=Script[SN_ONLOAD]; + } + else if(line=="endonload" || line=="/onload") + { + RunScript(SN_ONLOAD,NULL,sn); + DeleteScript(SN_ONLOAD); + curScript=Script[sn]; + } + else if(line=="cs" || line=="comments-start") + { + commented = true; + } + else if(strncmp(line.c_str(),"tag",3)==0 || strncmp(line.c_str(),"mark",4)==0) + { + curScript->AddLine("#" + line); + } + + //... + continue; // line was an option, not script content + } + + if(escape_all) + { + line = EscapeString(line); + } + + // help with loading lines where a space or tab have accidently been put after the cmd + std::string tline=stringToLower(line); + if(memcmp(tline.c_str(),"else ",5)==0 || memcmp(tline.c_str(),"else\t",5)==0) tline="else"; + else if(memcmp(tline.c_str(),"endif ",6)==0 || memcmp(tline.c_str(),"endif\t",5)==0) tline="endif"; + else if(memcmp(tline.c_str(),"loop ",5)==0 || memcmp(tline.c_str(),"loop\t",5)==0) tline="loop"; + else if(memcmp(tline.c_str(),"endloop ",8)==0 || memcmp(tline.c_str(),"endloop\t",8)==0) tline="endloop"; + if(tline=="else" || tline=="endif" || tline=="loop" || tline=="endloop") + line=tline; + + // check for correct block match + if(memcmp(tline.c_str(),"if ",3)==0) // need to check lowercased line! (IF may be uppercased) + Blocks.push_back(BLOCK_IF); + else if(line=="else") + { + if(Blocks.empty() || Blocks.back()!=BLOCK_IF) + { + cantload=true; + break; + } + } + else if(line=="endif") + { + if(Blocks.empty() || Blocks.back()!=BLOCK_IF) + { + cantload=true; + break; + } + Blocks.pop_back(); + } + else if(line=="loop") + Blocks.push_back(BLOCK_LOOP); + else if(line=="exitloop" && !Blocks.size()) // TODO: check: at least one BLOCK_LOOP must be opened + { + cantload=true; + break; + } + else if(line=="endloop") + { + if(Blocks.empty() || Blocks.back()!=BLOCK_LOOP) + { + cantload=true; + break; + } + Blocks.pop_back(); + } + + // check for correct bracket match + unsigned int bopen=0; + bool mismatch=false; + for(unsigned int bpos=0;bposAddLine(line); + } + f.close(); + if(cantload || Blocks.size()) + { + printf("DefScript: Error loading file '%s'. block mismatch?\n",fn.c_str()); + DeleteScript(sn); + return false; + } + + // ... + return true; +} + + +// --- SECTION FOR THE INDIVIDUAL SCRIPTS IN A PACKAGE --- + +DefScript::DefScript(DefScriptPackage *p) +{ + _parent=p; + scriptname="{NONAME}"; + debugmode=false; +} + +DefScript::~DefScript() +{ + Clear(); +} + +void DefScript::Clear(void) +{ + Line.clear(); +} + +void DefScript::SetDebug(bool d) +{ + debugmode=d; +} + +bool DefScript::GetDebug(void) +{ + return debugmode; +} + +void DefScript::SetName(std::string name) +{ + scriptname=name; +} + +std::string DefScript::GetName(void) +{ + return scriptname; +} + +bool DefScript::AddLine(std::string l){ + if(l.empty()) + return false; + Line.push_back(l); + return true; +} + + +// --- SECTION FOR COMMAND SETS --- + +CmdSet::CmdSet() +{ +} + +CmdSet::~CmdSet() +{ +} + +void CmdSet::Clear() +{ + arg.clear(); + cmd=""; + defaultarg=""; + caller=""; + myname=""; +} + + +// --- FUNCTIONS TO PARSE AND EXECUTE A SCRIPT --- PARENT: DefScriptPackage! + + +// the referred pSet is the parent from which RunScript() has been called +bool DefScriptPackage::BoolRunScript(std::string name, CmdSet *pSet) +{ + DefReturnResult r = RunScript(name,pSet); + return r.ok; +} + +// the referred pSet is the parent from which RunScript() has been called +DefReturnResult DefScriptPackage::RunScript(std::string name, CmdSet *pSet,std::string override_name) +{ + DefReturnResult r; + if( (!ScriptExists(name)) && (!HasFunc(name)) ) + { + r.ok=false; // doesnt exist + r.ret=""; + return r; + } + + DefScript *sc = GetScript(name); + if(!sc) + { + r.ok=false; + r.ret=""; + return r; + } + + if(!override_name.empty()) + name=override_name; + + CmdSet temp; + if(!pSet) + { + pSet = &temp; + } + pSet->caller=pSet->myname; + pSet->myname=name; + + std::deque Blocks; + CmdSet mySet; + std::string line; + + for(unsigned int i=0;iGetLines();i++) + { + line=sc->GetLine(i); + if(line.empty() || line[0] == '#') // skip markers and preload statements if not removed before + continue; + if(line=="else") + { + if(!Blocks.size()) + { + printf("DEBUG: else-block without any block?! [%s:%u]\n",name.c_str(),i); + r.ok=false; + break; + } + Def_Block b=Blocks.back(); + if(b.type==BLOCK_IF && b.istrue) + { + unsigned int other_ifs=0; + for(i=b.startline+1;;i++) + { + if(memcmp(sc->GetLine(i).c_str(),"if ",3)==0) + other_ifs++; + else if(sc->GetLine(i)=="endif") + { + if(!other_ifs) + break; + other_ifs--; + } + } + i--; // next line read will be "endif", decide then what to do + } + continue; + } + else if(line=="endif") + { + if(!Blocks.size()) + { + printf("DEBUG: endif without any block [%s:%u]\n",name.c_str(),i); + r.ok=false; + break; + } + if(Blocks.back().type!=BLOCK_IF) + { + printf("DEBUG: endif: closed block is not an if block! [%s:%u]\n",name.c_str(),i); + r.ok=false; + break; + } + Blocks.pop_back(); + continue; + } + else if(line=="loop") + { + Def_Block b; + b.startline=i; + b.type=BLOCK_LOOP; + b.istrue=true; + Blocks.push_back(b); + continue; + } + else if(line=="endloop") + { + if(!Blocks.size()) + { + printf("DEBUG: endloop without any block [%s:%u]\n",name.c_str(),i); + r.ok=false; + break; + } + if(Blocks.back().type!=BLOCK_LOOP) + { + printf("DEBUG: endloop: closed block is not a loop block! [%s:%u]\n",name.c_str(),i); + r.ok=false; + break; + } + i=Blocks.back().startline; // next line executed will be the line after "loop" + continue; + } + //_DEFSC_DEBUG(printf("DefScript before: \"%s\"\n",line.c_str())); + DefXChgResult final=ReplaceVars(line,pSet,0,true); + //_DEFSC_DEBUG(printf("DefScript parsed: \"%s\"\n",final.str.c_str())); + mySet.Clear(); + SplitLine(mySet,final.str); + if(mySet.cmd=="if") + { + Def_Block b; + b.startline=i; + b.type=BLOCK_IF; + b.istrue=isTrue(mySet.defaultarg); + Blocks.push_back(b); + if(!b.istrue) + { + unsigned int other_ifs=0; + for(i=b.startline+1; i < sc->GetLines() ;i++) + { + if(!memcmp(sc->GetLine(i).c_str(),"if ",3)) + other_ifs++; + if(sc->GetLine(i)=="else" || sc->GetLine(i)=="endif") + { + if(!other_ifs) + break; + if(sc->GetLine(i)=="endif") + other_ifs--; + } + } + i--; // next line read will be either "else" or "endif", decide then what to do + } + continue; // and read line after "else" + } + else if(mySet.cmd=="exitloop") + { + // skip some ifs if they are present + while(Blocks.back().type!=BLOCK_LOOP) + Blocks.pop_back(); + Blocks.pop_back(); + unsigned int other_loops=0; + + while(true) + { + if(sc->GetLine(i)=="loop") + other_loops++; + if(sc->GetLine(i)=="endloop") + { + if(!other_loops) + break; + other_loops--; + } + i++; // go until next endloop + } + // next line read will be the line after "endloop" + continue; + } + + mySet.myname=name; + mySet.caller=pSet?pSet->myname:""; + r=Interpret(mySet); + if(r.mustreturn) + { + r.mustreturn=false; + break; + } + } + return r; +} + +DefReturnResult DefScriptPackage::RunSingleLine(std::string line) +{ + DefXChgResult final=ReplaceVars(line,NULL,0,true); + CmdSet Set; + SplitLine(Set,final.str); + return Interpret(Set); +} + +DefReturnResult DefScriptPackage::RunSingleLineFromScript(std::string line, DefScript *pScript) +{ + CmdSet Set; + Set.myname=pScript->GetName(); + DefXChgResult final=ReplaceVars(line,&Set,0,true); + SplitLine(Set,final.str); + return Interpret(Set); +} + +void DefScriptPackage::SplitLine(CmdSet& Set,std::string line) +{ + + unsigned int i=0; + unsigned int bracketsOpen=0,curParam=0; + bool cmdDefined=false; + std::string tempLine; + +// extract cmd+params and txt + for(i=0;i0 && (t[i-1]=='$' || t[i-1]=='?') ) + isVar=true; + if(!bo) + ob=i; + bo++; + } + else if(t[i]=='}') + { + bo--; + if(!bo) + { + if(!isVar) + { + unsigned int blen=i-ob+1; + std::string subStr=t.substr(ob,blen); + std::string retStr=RemoveBracketsFromString(subStr); + t.erase(ob,blen); + t.insert(ob,retStr); + i=ob-1; + + } + isVar=false; + } + } + else if(t[i]=='\\') + { + i++; + continue; + } + + } + + return t; +} + +void DefScriptPackage::RemoveBrackets(CmdSet& Set) +{ + Set.defaultarg=RemoveBracketsFromString(Set.defaultarg); + Set.cmd=RemoveBracketsFromString(Set.cmd); + for(_CmdSetArgMap::iterator i=Set.arg.begin(); i!=Set.arg.end(); i++) + { + i->second=RemoveBracketsFromString(i->second); + } +} + +void DefScriptPackage::UnescapeSet(CmdSet& Set) +{ + Set.defaultarg=UnescapeString(Set.defaultarg); + //Set.cmd=UnescapeString(Set.cmd); // this is done already in SplitLine() ! + for(_CmdSetArgMap::iterator i=Set.arg.begin(); i!=Set.arg.end(); i++) + { + i->second=UnescapeString(i->second); + } +} + + +DefXChgResult DefScriptPackage::ReplaceVars(std::string str, CmdSet *pSet, unsigned char VarType, bool run_embedded) +{ + + unsigned int + openingBracket=0, // defines the position from where the recursive call is started + closingBracket=0, // the closing bracket + bracketsOpen=0, // amount of brackets opened + bLen=0; // the lenth of the string in brackets, e.g. ${abc} == 3 + + unsigned char + nextVar=DEFSCRIPT_NONE; // '$' or '?' + bool + hasChanged=false, // additional helper. once true, xchg.result will be true later also + hasVar=false, // true if openingBracket (= the first bracket) was preceded by '$' or '?' + escaped=false; + + std::string subStr; + DefXChgResult xchg; + + for(unsigned int i=0;i0 && str[i-1]=='$') + { + hasVar=true; + if(!bracketsOpen) + nextVar=DEFSCRIPT_VAR; + } + if(i>0 && str[i-1]=='?') + { + hasVar=true; + if(!bracketsOpen) + nextVar=DEFSCRIPT_FUNC; + } + bracketsOpen++; + } + else if(str[i]=='}') + { + if(bracketsOpen) + bracketsOpen--; + if(!bracketsOpen) + { + closingBracket=i; + if(nextVar==DEFSCRIPT_NONE && VarType==DEFSCRIPT_VAR && !hasVar) // remove brackets in var names, like ${var{ia}ble} + { + str.erase(closingBracket,1); + str.erase(openingBracket,1); + i=openingBracket; // jump to the pos where the opening bracket was + continue; + } + else + { + bLen=closingBracket-openingBracket-1; + subStr=str.substr(openingBracket+1,bLen); + //printf("SUBSTR: \"%s\"\n",subStr.c_str()); + xchg=ReplaceVars(subStr,pSet,nextVar,run_embedded); + if( nextVar==DEFSCRIPT_NONE && hasVar && xchg.changed ) + { + str.erase(openingBracket+1,subStr.length()); + str.insert(openingBracket+1,xchg.str); + hasVar=false; + i-=(subStr.length()+1); + hasChanged=true; + } + else if( nextVar!=DEFSCRIPT_NONE && hasVar && xchg.changed ) + { + str.erase(openingBracket-1,bLen+3); // remove ${...} (+3 because of '${}') + i-=(bLen+2); // adjust position + str.insert(i,xchg.str); + if(str[i]=='\\') // workaround, since i will be increased 1 too high + escaped=true; + hasVar=false; + nextVar=DEFSCRIPT_NONE; + } + } + } + } // end if '}' + else if(str[i]=='\\') // if escape char \ found, skip parsing next char + { + i++; + continue; + } + } // end for + if(!bracketsOpen && VarType!=DEFSCRIPT_NONE) + { + // fix for empty var: ${} + if(str.empty()) + { + xchg.str=""; + xchg.changed=true; + return xchg; + } + if(VarType==DEFSCRIPT_VAR) + { + std::string vname=_NormalizeVarName(str, (pSet==NULL) ? "" : pSet->myname); + if(vname[0]=='@') + { + std::stringstream vns; + std::string subs=vname.substr(1,str.length()-1); + unsigned int vn=atoi( subs.c_str() ); + vns << vn; + if(pSet && vns.str()==subs) // resolve arg macros @0 - @4294967295 + str=pSet->arg[vn]; + else if(pSet && subs=="def") + str=pSet->defaultarg; + else if(pSet && subs=="myname") + str=pSet->myname; + else if(pSet && subs=="cmd") + str=pSet->cmd; + else if(pSet && subs=="caller") + str=pSet->caller; + else if(subs=="n") + str="\n"; + else if(subs=="clock") + { + std::stringstream clock_s; + clock_s << clock(); + str = clock_s.str(); + } + else if(subs=="time") + { + std::stringstream time_s; + time_s << time(NULL); + str = time_s.str(); + } + else if(variables.Exists(vname)) + str=variables.Get(vname); + else + { + // TODO: call custom macro table + //... + str.clear(); + } + xchg.changed=true; + } + else + { + if(variables.Exists(vname)) + { + str=variables.Get(vname); + xchg.changed=true; + } + } + } + else if(VarType==DEFSCRIPT_FUNC) + { + if(run_embedded) + { + DefReturnResult res; + if(pSet) + res=RunSingleLineFromScript(str,GetScript(pSet->myname)); + else + res=RunSingleLine(str); + str=res.ret; // returns empty string on invalid function!! + xchg.result.ok=res.ok; + xchg.changed=true; + //xchg.result.err += res.err; + } + else // if not allowed to run scripts via ?{...} + { + str=""; // just replace with 0 + xchg.changed=true; // yes we have changed something + xchg.result.ok=true; // change ok, insert our (empty) return value + } + } + } + + xchg.str = str; + if(hasChanged) + xchg.changed=true; + return xchg; +} + +std::string DefScriptPackage::_NormalizeVarName(std::string vn_in, std::string sn){ + if(vn_in.empty()) + return vn_in; + std::string vn=vn_in; + bool global=false; + if(sn.empty()) + global = true; + while(true) + { + if(vn.at(0)=='#') + global = true; + if(vn.at(0)=='#' || vn.at(0)==':') + vn.erase(0,1); + else + break; + } + + if( (!global) && (vn.at(0)!='@') ) + vn=sn+"::"+vn; + + return vn; +} + +DefReturnResult DefScriptPackage::Interpret(CmdSet& Set) +{ + // TODO: remove this debug block again as soon as the interpreter bugs are fixed. + _DEFSC_DEBUG + ( + hLogfile << "PARENT: '" << Set.caller << "'\n"; + hLogfile << "cmd = '" << Set.cmd << "'\n"; + unsigned int ctr=0; + for(_CmdSetArgMap::iterator i=Set.arg.begin(); i!=Set.arg.end(); i++) + hLogfile << "arg[" << ctr++ << "] = '" << i->second << "'\n"; + hLogfile << "defaultarg = '" << Set.defaultarg << "'\n\n"; + ); + + DefReturnResult result; + + // first search if the script is defined in the internal functions + for(unsigned int i=0;i<_functable.size();i++) + { + if(Set.cmd==_functable[i].name) + { + if(_functable[i].escape) // if we are going to use a C++ function, unescape the whole set, if supposed to do so. + UnescapeSet(Set); // it will not have any bad side effects, we leave the func within this block! + + result=(this->*(_functable[i].func))(Set); + if(_functable[i].escape) + result.ret = EscapeString(result.ret); // and since we are returning a string into the engine, escape it again, if set. + return result; + } + } + + if(Set.cmd=="return") + { + result.mustreturn=true; + result.ret=Set.defaultarg; + return result; + } + + // if nothing has been found its maybe an external script file to run + result=RunScript(Set.cmd, &Set); + if((!result.ok) /*&& Script[Set.cmd]->GetDebug()*/) + std::cout << "Could not execute script command '" << Set.cmd << "'\n"; + + + return result; +} + +void DefScriptPackage::_UpdateOrCreateScriptByName(std::string sn) +{ + if(GetScript(sn)) + DeleteScript(sn); + DefScript *newscript = new DefScript(this); + newscript->SetName(sn); // necessary that the script knows its own name + Script[sn] = newscript; + lists.Assign(SCRIPT_NAMESPACE + sn, &(newscript->Line)); +} + +std::string DefScriptPackage::SecureString(std::string s) +{ + std::string out; + for(unsigned int i = 0; i < s.length(); i++) + { + if(s[i] == '{') + out += '['; + else if(s[i] == '}') + out += ']'; + else + out += s[i]; + } + return out; +} + +// escapes whole string, which can no longer be parsed & interpreted +std::string DefScriptPackage::EscapeString(std::string s) +{ + std::string out; + out.reserve(s.length()+8); + for(unsigned int i = 0; i < s.length(); i++) + { + switch(s[i]) + { + case '{': + case '}': + case '\\': + out += '\\'; + out += s[i]; + break; + + case '\n': + out += "\\n"; + break; + + case '\t': + out += "\\t"; + break; + + default: + out += s[i]; + } + + } + return out; +} + +// converts a string into a printable form, with all escape sequences resolved +std::string DefScriptPackage::UnescapeString(std::string s) +{ + std::string out; + out.reserve(s.length()); + for(unsigned int i = 0; i < s.length(); i++) + { + if(s[i] == '\\' && i+1 < s.length()) + { + switch(s[i+1]) + { // if any of these are found, append to output string and skip this byte + case '{': + case '}': + case '\\': + out += s[++i]; + break; + + case 'n': + out += '\n'; + i++; + break; + + case 't': + out += '\t'; + i++; + break; + + case 'x': + if(i+4 <= s.length()) + { + std::string xd = s.substr(i+2,2); + char c = (char)strtoul(s.substr(i+2,2).c_str(),NULL,16); + out += c; + i += 3; + } + } + } + else + { + out += s[i]; + } + } + return out; +} + +std::string DefScriptPackage::GetUnescapedVar(std::string n) +{ + return UnescapeString(variables.Get(n)); +} + +bool DefScriptPackage::RunScriptIfExists(std::string name,CmdSet *pSet) +{ + if(ScriptExists(name)) + { + return BoolRunScript(name,pSet); + } + return false; +} diff --git a/src/Client/DefScript/DefScript.h b/src/Client/DefScript/DefScript.h index 52f8f6f..c8143ba 100644 --- a/src/Client/DefScript/DefScript.h +++ b/src/Client/DefScript/DefScript.h @@ -1,288 +1,288 @@ - -#ifndef __DEFSCRIPT_H -#define __DEFSCRIPT_H - -#include "DefScriptDefines.h" -#include -#include -#include -#include "VarSet.h" -#include "ByteBuffer.h" -#include "DynamicEvent.h" -#include "TypeStorage.h" -#include "DefScriptTools.h" - -class DefScriptPackage; -class DefScript; - -typedef void (*_slog_func)(const char*,...); - -// general struct for if..else..endif / loop..endloop blocks -struct Def_Block -{ - unsigned char type; // stores DefScriptBlockType - bool istrue; // only relevant for if-statements - unsigned int startline; // line where loop-statement started -}; - -struct DefReturnResult -{ - DefReturnResult() { ok=true; mustreturn=false; ret="true"; } - DefReturnResult(bool b) { ok=true; mustreturn=false; ret=b?"true":"false"; } - DefReturnResult(std::string s) { ok=true; mustreturn=false; ret=s; } - DefReturnResult(const char *s) { DefReturnResult(std::string(s)); } - bool ok; // true if the execution of the current statement was successful - bool mustreturn; - std::string ret; // return value used by ?{..} - //bool abrt; // true if ALL current script execution must be aborted. - //std::string err; // error string, including tracestack, etc. -}; - -#define DEF_RETURN_ERROR { DefReturnResult __defreturnresult(false); __defreturnresult.ok=false; return __defreturnresult; } - -struct DefXChgResult -{ - DefXChgResult() { changed=false; } - bool changed; - std::string str; - DefReturnResult result; -}; - -typedef std::map _CmdSetArgMap; - -class CmdSet { - public: - CmdSet(); - ~CmdSet(); - void Clear(); - std::string cmd; - _CmdSetArgMap arg; - std::string defaultarg; - std::string myname; - std::string caller; -}; - -struct DefScriptFunctionEntry { - DefScriptFunctionEntry(std::string n,DefReturnResult (DefScriptPackage::*f)(CmdSet& Set), bool esc) - { - name=n; - func=f; - escape=esc; - } - std::string name; - DefReturnResult (DefScriptPackage::*func)(CmdSet& Set); - bool escape; -}; - -typedef std::deque DefScriptFunctionTable; - -typedef std::deque DefList; -typedef std::map DefListMap; - -class DefScript { - friend class DefScriptPackage; -public: - DefScript(DefScriptPackage *p); - ~DefScript(); - - inline std::string GetLine(unsigned int id) { return Line[id]; } - inline unsigned int GetLines(void) { return Line.size(); } - bool AddLine(std::string ); - std::string GetName(void); - void SetName(std::string); - void SetPermission(unsigned char); - unsigned char GetPermission(void); - void Clear(void); - void SetDebug(bool); - bool GetDebug(void); - //DefScriptPackage *GetParent(void); - - -private: - DefList Line; - unsigned int lines; - std::string scriptname; - unsigned char permission; - bool debugmode; - - DefScriptPackage *_parent; -}; - - -class DefScriptPackage { - friend class DefScript; -public: - DefScriptPackage(); - ~DefScriptPackage(); - void SetParentMethod(void*); // used to extend the scripts with own c++ interface functions - void Clear(void); - DefScript *GetScript(std::string); - unsigned int GetScripts(void); - bool LoadScriptFromFile(std::string); - DefReturnResult RunScript(std::string name,CmdSet* pSet,std::string override_name=""); - bool BoolRunScript(std::string,CmdSet*); - bool RunScriptIfExists(std::string name, CmdSet *pSet = NULL); - unsigned int GetScriptID(std::string); - DefReturnResult RunSingleLine(std::string); - bool ScriptExists(std::string); - void DeleteScript(std::string); - VarSet variables; - void SetPath(std::string); - bool LoadByName(std::string); - std::string _NormalizeVarName(std::string, std::string); - DefReturnResult RunSingleLineFromScript(std::string line, DefScript *pScript); - DefScript_DynamicEventMgr *GetEventMgr(void); - void AddFunc(DefScriptFunctionEntry); - void AddFunc(std::string n,DefReturnResult (DefScriptPackage::*)(CmdSet& Set), bool esc=true); - bool HasFunc(std::string); - void DelFunc(std::string); - TypeStorage lists; - TypeStorage bytebuffers; - TypeStorage files; - std::string SecureString(std::string); - std::string EscapeString(std::string); - std::string UnescapeString(std::string); - std::string GetUnescapedVar(std::string); - - - // own logging functions. default is printf. - // DO NOT USE THEM YET! THEY DO NOT WORK CORRECTLY! - // need some help with this [FG] - inline void SetLog(void *ptr) { _slog=(_slog_func)ptr; } - inline void SetDebugLog(void *ptr) { _sdebuglog=(_slog_func)ptr; } - inline void SetErrorLog(void *ptr) { _serrorlog=(_slog_func)ptr; } - void Log(const char*,...); - void DebugLog(const char*,...); - void ErrorLog(const char*,...); - - - std::string scPath; - - // Own executor functions - void My_LoadUserPermissions(VarSet&); - void My_Run(std::string line,std::string username); - -private: - void _UpdateOrCreateScriptByName(std::string); - void _InitFunctions(void); - DefXChgResult ReplaceVars(std::string str, CmdSet* pSet, unsigned char VarType, bool run_embedded); - void SplitLine(CmdSet&,std::string); - DefReturnResult Interpret(CmdSet&); - void RemoveBrackets(CmdSet&); - void UnescapeSet(CmdSet&); - std::string RemoveBracketsFromString(std::string); - void *parentMethod; - DefScript_DynamicEventMgr *_eventmgr; - std::map Script; - std::map scriptPermissionMap; - DefScriptFunctionTable _functable; - _slog_func _slog,_serrorlog,_sdebuglog; - _DEFSC_DEBUG(std::fstream hLogfile); - - // Usable internal basic functions: - DefReturnResult func_default(CmdSet&); - DefReturnResult func_set(CmdSet&); - DefReturnResult func_unset(CmdSet&); - DefReturnResult func_loaddef(CmdSet&); - DefReturnResult func_reloaddef(CmdSet&); - DefReturnResult func_createdef(CmdSet&); - DefReturnResult func_unloaddef(CmdSet&); - DefReturnResult func_out(CmdSet&); - DefReturnResult func_eof(CmdSet&); - DefReturnResult func_shdn(CmdSet&); - DefReturnResult func_setscriptpermission(CmdSet&); - DefReturnResult func_toint(CmdSet&); - DefReturnResult func_add(CmdSet&); - DefReturnResult func_sub(CmdSet&); - DefReturnResult func_mul(CmdSet&); - DefReturnResult func_div(CmdSet&); - DefReturnResult func_mod(CmdSet&); - DefReturnResult func_pow(CmdSet&); - DefReturnResult func_bitor(CmdSet&); - DefReturnResult func_bitand(CmdSet&); - DefReturnResult func_bitxor(CmdSet&); - DefReturnResult func_addevent(CmdSet&); - DefReturnResult func_removeevent(CmdSet&); - DefReturnResult func_abs(CmdSet&); - DefReturnResult func_bigger(CmdSet&); - DefReturnResult func_bigger_eq(CmdSet&); - DefReturnResult func_equal(CmdSet&); - DefReturnResult func_isset(CmdSet&); - DefReturnResult func_not(CmdSet&); - DefReturnResult func_smaller(CmdSet&); - DefReturnResult func_smaller_eq(CmdSet&); - DefReturnResult func_strlen(CmdSet&); - DefReturnResult func_tohex(CmdSet&); - DefReturnResult func_and(CmdSet&); - DefReturnResult func_or(CmdSet&); - DefReturnResult func_xor(CmdSet&); - DefReturnResult func_substr(CmdSet&); - DefReturnResult func_uppercase(CmdSet&); - DefReturnResult func_lowercase(CmdSet&); - DefReturnResult func_random(CmdSet&); - DefReturnResult func_fileexists(CmdSet&); - DefReturnResult func_strfind(CmdSet&); - DefReturnResult func_scriptexists(CmdSet&); - DefReturnResult func_funcexists(CmdSet&); - - - // list functions - DefReturnResult func_lpushback(CmdSet&); - DefReturnResult func_lpushfront(CmdSet&); - DefReturnResult func_lpopback(CmdSet&); - DefReturnResult func_lpopfront(CmdSet&); - DefReturnResult func_ldelete(CmdSet&); - DefReturnResult func_lexists(CmdSet&); - DefReturnResult func_llen(CmdSet&); - DefReturnResult func_linsert(CmdSet&); - DefReturnResult func_lsplit(CmdSet&); - DefReturnResult func_lcsplit(CmdSet&); - DefReturnResult func_ljoin(CmdSet&); - DefReturnResult func_lindex(CmdSet&); - DefReturnResult func_lclean(CmdSet&); - DefReturnResult func_lmclean(CmdSet&); - DefReturnResult func_lerase(CmdSet&); - DefReturnResult func_lsort(CmdSet&); - - // ByteBuffer functions - DefReturnResult func_bbinit(CmdSet&); - DefReturnResult func_bbdelete(CmdSet&); - DefReturnResult func_bbappend(CmdSet&); - DefReturnResult func_bbread(CmdSet&); - DefReturnResult func_bbsetrpos(CmdSet&); - DefReturnResult func_bbsetwpos(CmdSet&); - DefReturnResult func_bbhexlike(CmdSet&); - DefReturnResult func_bbtextlike(CmdSet&); - DefReturnResult func_bbsize(CmdSet&); - - // file functions - DefReturnResult func_fopen(CmdSet&); - DefReturnResult func_fclose(CmdSet&); - DefReturnResult func_fisopen(CmdSet&); - DefReturnResult func_feof(CmdSet&); - DefReturnResult func_frpos(CmdSet&); - DefReturnResult func_fwpos(CmdSet&); - DefReturnResult func_fdel(CmdSet&); - DefReturnResult func_fflush(CmdSet&); - DefReturnResult func_fwrite(CmdSet&); - DefReturnResult func_fread(CmdSet&); - DefReturnResult func_freadb(CmdSet&); - DefReturnResult func_fwriteb(CmdSet&); - DefReturnResult func_freadbb(CmdSet&); - DefReturnResult func_fwritebb(CmdSet&); - DefReturnResult func_fsize(CmdSet&); - DefReturnResult func_freadline(CmdSet&); - DefReturnResult func_fseekw(CmdSet&); - DefReturnResult func_fseekr(CmdSet&); - - // setup own function declarations here -# include "DefScriptInterfaceInclude.h" - - // Own variable declarations - std::map my_usrPermissionMap; - -}; - - - -#endif + +#ifndef __DEFSCRIPT_H +#define __DEFSCRIPT_H + +#include "DefScriptDefines.h" +#include +#include +#include +#include "VarSet.h" +#include "ByteBuffer.h" +#include "DynamicEvent.h" +#include "TypeStorage.h" +#include "DefScriptTools.h" + +class DefScriptPackage; +class DefScript; + +typedef void (*_slog_func)(const char*,...); + +// general struct for if..else..endif / loop..endloop blocks +struct Def_Block +{ + unsigned char type; // stores DefScriptBlockType + bool istrue; // only relevant for if-statements + unsigned int startline; // line where loop-statement started +}; + +struct DefReturnResult +{ + DefReturnResult() { ok=true; mustreturn=false; ret="true"; } + DefReturnResult(bool b) { ok=true; mustreturn=false; ret=b?"true":"false"; } + DefReturnResult(std::string s) { ok=true; mustreturn=false; ret=s; } + DefReturnResult(const char *s) { DefReturnResult(std::string(s)); } + bool ok; // true if the execution of the current statement was successful + bool mustreturn; + std::string ret; // return value used by ?{..} + //bool abrt; // true if ALL current script execution must be aborted. + //std::string err; // error string, including tracestack, etc. +}; + +#define DEF_RETURN_ERROR { DefReturnResult __defreturnresult(false); __defreturnresult.ok=false; return __defreturnresult; } + +struct DefXChgResult +{ + DefXChgResult() { changed=false; } + bool changed; + std::string str; + DefReturnResult result; +}; + +typedef std::map _CmdSetArgMap; + +class CmdSet { + public: + CmdSet(); + ~CmdSet(); + void Clear(); + std::string cmd; + _CmdSetArgMap arg; + std::string defaultarg; + std::string myname; + std::string caller; +}; + +struct DefScriptFunctionEntry { + DefScriptFunctionEntry(std::string n,DefReturnResult (DefScriptPackage::*f)(CmdSet& Set), bool esc) + { + name=n; + func=f; + escape=esc; + } + std::string name; + DefReturnResult (DefScriptPackage::*func)(CmdSet& Set); + bool escape; +}; + +typedef std::deque DefScriptFunctionTable; + +typedef std::deque DefList; +typedef std::map DefListMap; + +class DefScript { + friend class DefScriptPackage; +public: + DefScript(DefScriptPackage *p); + ~DefScript(); + + inline std::string GetLine(unsigned int id) { return Line[id]; } + inline unsigned int GetLines(void) { return Line.size(); } + bool AddLine(std::string ); + std::string GetName(void); + void SetName(std::string); + void SetPermission(unsigned char); + unsigned char GetPermission(void); + void Clear(void); + void SetDebug(bool); + bool GetDebug(void); + //DefScriptPackage *GetParent(void); + + +private: + DefList Line; + unsigned int lines; + std::string scriptname; + unsigned char permission; + bool debugmode; + + DefScriptPackage *_parent; +}; + + +class DefScriptPackage { + friend class DefScript; +public: + DefScriptPackage(); + ~DefScriptPackage(); + void SetParentMethod(void*); // used to extend the scripts with own c++ interface functions + void Clear(void); + DefScript *GetScript(std::string); + unsigned int GetScripts(void); + bool LoadScriptFromFile(std::string); + DefReturnResult RunScript(std::string name,CmdSet* pSet,std::string override_name=""); + bool BoolRunScript(std::string,CmdSet*); + bool RunScriptIfExists(std::string name, CmdSet *pSet = NULL); + unsigned int GetScriptID(std::string); + DefReturnResult RunSingleLine(std::string); + bool ScriptExists(std::string); + void DeleteScript(std::string); + VarSet variables; + void SetPath(std::string); + bool LoadByName(std::string); + std::string _NormalizeVarName(std::string, std::string); + DefReturnResult RunSingleLineFromScript(std::string line, DefScript *pScript); + DefScript_DynamicEventMgr *GetEventMgr(void); + void AddFunc(DefScriptFunctionEntry); + void AddFunc(std::string n,DefReturnResult (DefScriptPackage::*)(CmdSet& Set), bool esc=true); + bool HasFunc(std::string); + void DelFunc(std::string); + TypeStorage lists; + TypeStorage bytebuffers; + TypeStorage files; + std::string SecureString(std::string); + std::string EscapeString(std::string); + std::string UnescapeString(std::string); + std::string GetUnescapedVar(std::string); + + + // own logging functions. default is printf. + // DO NOT USE THEM YET! THEY DO NOT WORK CORRECTLY! + // need some help with this [FG] + inline void SetLog(void *ptr) { _slog=(_slog_func)ptr; } + inline void SetDebugLog(void *ptr) { _sdebuglog=(_slog_func)ptr; } + inline void SetErrorLog(void *ptr) { _serrorlog=(_slog_func)ptr; } + void Log(const char*,...); + void DebugLog(const char*,...); + void ErrorLog(const char*,...); + + + std::string scPath; + + // Own executor functions + void My_LoadUserPermissions(VarSet&); + void My_Run(std::string line,std::string username); + +private: + void _UpdateOrCreateScriptByName(std::string); + void _InitFunctions(void); + DefXChgResult ReplaceVars(std::string str, CmdSet* pSet, unsigned char VarType, bool run_embedded); + void SplitLine(CmdSet&,std::string); + DefReturnResult Interpret(CmdSet&); + void RemoveBrackets(CmdSet&); + void UnescapeSet(CmdSet&); + std::string RemoveBracketsFromString(std::string); + void *parentMethod; + DefScript_DynamicEventMgr *_eventmgr; + std::map Script; + std::map scriptPermissionMap; + DefScriptFunctionTable _functable; + _slog_func _slog,_serrorlog,_sdebuglog; + _DEFSC_DEBUG(std::fstream hLogfile); + + // Usable internal basic functions: + DefReturnResult func_default(CmdSet&); + DefReturnResult func_set(CmdSet&); + DefReturnResult func_unset(CmdSet&); + DefReturnResult func_loaddef(CmdSet&); + DefReturnResult func_reloaddef(CmdSet&); + DefReturnResult func_createdef(CmdSet&); + DefReturnResult func_unloaddef(CmdSet&); + DefReturnResult func_out(CmdSet&); + DefReturnResult func_eof(CmdSet&); + DefReturnResult func_shdn(CmdSet&); + DefReturnResult func_setscriptpermission(CmdSet&); + DefReturnResult func_toint(CmdSet&); + DefReturnResult func_add(CmdSet&); + DefReturnResult func_sub(CmdSet&); + DefReturnResult func_mul(CmdSet&); + DefReturnResult func_div(CmdSet&); + DefReturnResult func_mod(CmdSet&); + DefReturnResult func_pow(CmdSet&); + DefReturnResult func_bitor(CmdSet&); + DefReturnResult func_bitand(CmdSet&); + DefReturnResult func_bitxor(CmdSet&); + DefReturnResult func_addevent(CmdSet&); + DefReturnResult func_removeevent(CmdSet&); + DefReturnResult func_abs(CmdSet&); + DefReturnResult func_bigger(CmdSet&); + DefReturnResult func_bigger_eq(CmdSet&); + DefReturnResult func_equal(CmdSet&); + DefReturnResult func_isset(CmdSet&); + DefReturnResult func_not(CmdSet&); + DefReturnResult func_smaller(CmdSet&); + DefReturnResult func_smaller_eq(CmdSet&); + DefReturnResult func_strlen(CmdSet&); + DefReturnResult func_tohex(CmdSet&); + DefReturnResult func_and(CmdSet&); + DefReturnResult func_or(CmdSet&); + DefReturnResult func_xor(CmdSet&); + DefReturnResult func_substr(CmdSet&); + DefReturnResult func_uppercase(CmdSet&); + DefReturnResult func_lowercase(CmdSet&); + DefReturnResult func_random(CmdSet&); + DefReturnResult func_fileexists(CmdSet&); + DefReturnResult func_strfind(CmdSet&); + DefReturnResult func_scriptexists(CmdSet&); + DefReturnResult func_funcexists(CmdSet&); + + + // list functions + DefReturnResult func_lpushback(CmdSet&); + DefReturnResult func_lpushfront(CmdSet&); + DefReturnResult func_lpopback(CmdSet&); + DefReturnResult func_lpopfront(CmdSet&); + DefReturnResult func_ldelete(CmdSet&); + DefReturnResult func_lexists(CmdSet&); + DefReturnResult func_llen(CmdSet&); + DefReturnResult func_linsert(CmdSet&); + DefReturnResult func_lsplit(CmdSet&); + DefReturnResult func_lcsplit(CmdSet&); + DefReturnResult func_ljoin(CmdSet&); + DefReturnResult func_lindex(CmdSet&); + DefReturnResult func_lclean(CmdSet&); + DefReturnResult func_lmclean(CmdSet&); + DefReturnResult func_lerase(CmdSet&); + DefReturnResult func_lsort(CmdSet&); + + // ByteBuffer functions + DefReturnResult func_bbinit(CmdSet&); + DefReturnResult func_bbdelete(CmdSet&); + DefReturnResult func_bbappend(CmdSet&); + DefReturnResult func_bbread(CmdSet&); + DefReturnResult func_bbsetrpos(CmdSet&); + DefReturnResult func_bbsetwpos(CmdSet&); + DefReturnResult func_bbhexlike(CmdSet&); + DefReturnResult func_bbtextlike(CmdSet&); + DefReturnResult func_bbsize(CmdSet&); + + // file functions + DefReturnResult func_fopen(CmdSet&); + DefReturnResult func_fclose(CmdSet&); + DefReturnResult func_fisopen(CmdSet&); + DefReturnResult func_feof(CmdSet&); + DefReturnResult func_frpos(CmdSet&); + DefReturnResult func_fwpos(CmdSet&); + DefReturnResult func_fdel(CmdSet&); + DefReturnResult func_fflush(CmdSet&); + DefReturnResult func_fwrite(CmdSet&); + DefReturnResult func_fread(CmdSet&); + DefReturnResult func_freadb(CmdSet&); + DefReturnResult func_fwriteb(CmdSet&); + DefReturnResult func_freadbb(CmdSet&); + DefReturnResult func_fwritebb(CmdSet&); + DefReturnResult func_fsize(CmdSet&); + DefReturnResult func_freadline(CmdSet&); + DefReturnResult func_fseekw(CmdSet&); + DefReturnResult func_fseekr(CmdSet&); + + // setup own function declarations here +# include "DefScriptInterfaceInclude.h" + + // Own variable declarations + std::map my_usrPermissionMap; + +}; + + + +#endif diff --git a/src/Client/DefScript/DefScriptBBFunctions.cpp b/src/Client/DefScript/DefScriptBBFunctions.cpp index 7e534c8..fab405c 100644 --- a/src/Client/DefScript/DefScriptBBFunctions.cpp +++ b/src/Client/DefScript/DefScriptBBFunctions.cpp @@ -1,177 +1,177 @@ -#include -#include -#include -#include -#include "DefScript.h" -#include "DefScriptTools.h" -#include "SysDefs.h" -#include "ByteBuffer.h" - -using namespace DefScriptTools; - -// Helper macros for insert/extract various datatypes that need type casting -#define BB_CAN_READ(bytebuffer, _ty) ((*(bytebuffer)).size() - (*(bytebuffer)).rpos() >= sizeof(_ty)) -#define BB_MACRO_INSERT_I(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) ) { *(bytebuffer) << (_ty)toUint64(Set.defaultarg); return true; } -#define BB_MACRO_INSERT_F(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) ) { *(bytebuffer) << (_ty)toNumber(Set.defaultarg); return true; } -#define BB_MACRO_EXTRACT_I(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) && BB_CAN_READ(bytebuffer,_ty) ) {_ty _var; *(bytebuffer) >> _var; return DefScriptTools::toString((uint64)_var); } -#define BB_MACRO_EXTRACT_F(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) && BB_CAN_READ(bytebuffer,_ty) ) {_ty _var; *(bytebuffer) >> _var; return DefScriptTools::toString((ldbl)_var); } - - -// Initializes bytebuffer with initial capacity (reserved, not resized) -// @def - bytebuffer identifier -// @0 - if set, initial capacity -DefReturnResult DefScriptPackage::func_bbinit(CmdSet& Set) -{ - ByteBuffer *bb = bytebuffers.Get(_NormalizeVarName(Set.defaultarg,Set.myname)); - bb->clear(); // also resets wpos & rpos - if (!Set.arg[0].empty()) - bb->reserve((size_t)DefScriptTools::toUint64(Set.arg[0])); - return true; -} - -// Cleans memory and deletes ByteBuffer from storage -DefReturnResult DefScriptPackage::func_bbdelete(CmdSet& Set) -{ - bytebuffers.Delete(_NormalizeVarName(Set.defaultarg,Set.myname)); - return true; -} - -// Appends data to ByteBuffer -// @def - data -// @0 - bytebuffer identifier -// @1 - datatype of added data (uint8,uint16,uint32,uint64,float,double,string,strnz) -DefReturnResult DefScriptPackage::func_bbappend(CmdSet& Set) -{ - ByteBuffer *bb = bytebuffers.Get(_NormalizeVarName(Set.arg[0],Set.myname)); - - std::string dtype = DefScriptTools::stringToLower(Set.arg[1]); - - if (dtype == "string") - { - *bb << Set.defaultarg; - return true; - } - else if(dtype == "strnz") - { - bb->append(Set.defaultarg.c_str(), Set.defaultarg.length()); // append the string skipping \0 - return true; - } - - BB_MACRO_INSERT_I(bb, dtype, uint8); - BB_MACRO_INSERT_I(bb, dtype, uint16); - BB_MACRO_INSERT_I(bb, dtype, uint32); - BB_MACRO_INSERT_I(bb, dtype, uint64); - BB_MACRO_INSERT_F(bb, dtype, float); - BB_MACRO_INSERT_F(bb, dtype, double); - - return false; -} - -// Extracts data from bytebuffer -// @def - datatype to extract (uint8,uint16,uint32,uint64,float,double,string) -// @0 - bytebuffer identifier -DefReturnResult DefScriptPackage::func_bbread(CmdSet& Set) -{ - ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if (!bb) - return false; - - std::string dtype = DefScriptTools::stringToLower(Set.defaultarg); - - if (dtype == "string") { - std::string g; - *bb >> g; - return g; - } - else if(dtype == "strnz") // extract some amount of bytes not terminated by \0 - { - uint32 bytes = (uint32)toUint64(Set.arg[1]); - if(bytes) - { - std::string g; - char *buf = new char[bytes+1]; // +1 for \0 - buf[bytes] = 0; - bb->read((uint8*)buf,bytes); - g = buf; - delete [] buf; - return g; - } - return ""; - } - - BB_MACRO_EXTRACT_I(bb, dtype, uint8); - BB_MACRO_EXTRACT_I(bb, dtype, uint16); - BB_MACRO_EXTRACT_I(bb, dtype, uint32); - BB_MACRO_EXTRACT_I(bb, dtype, uint64); - BB_MACRO_EXTRACT_F(bb, dtype, float); - BB_MACRO_EXTRACT_F(bb, dtype, double); - - return ""; // if extraction unsuccessful, return empty string -} - -// Sets read position in bytebuffer -// @0 - bytebuffer identifier -// @def - setted rpos (if "end", automatically set at end) -DefReturnResult DefScriptPackage::func_bbsetrpos(CmdSet& Set) -{ - ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if (!bb) - return false; - - if (Set.defaultarg == "end") - bb->rpos( bb->size() ); - else - bb->rpos( (unsigned int)toNumber(Set.defaultarg) ); - return true; -} - -// Sets write position in bytebuffer -// @0 - bytebuffer identifier -// @def - setted wpos (if "end", automatically set at end) -DefReturnResult DefScriptPackage::func_bbsetwpos(CmdSet& Set) -{ - ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if (!bb) - return false; - - if (Set.defaultarg == "end") - bb->wpos( bb->size() ); - else - bb->wpos( (unsigned int)toNumber(Set.defaultarg) ); - return true; -} - -// Hexlike output of bytebuffer to console -// @def - bytebuffer identifier -DefReturnResult DefScriptPackage::func_bbhexlike(CmdSet& Set) -{ - ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if (!bb) - return false; - - bb->hexlike(); - return true; -} - -// Textlike output of bytebuffer to console -// @def - bytebuffer identifier -DefReturnResult DefScriptPackage::func_bbtextlike(CmdSet& Set) -{ - ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if (!bb) - return false; - - bb->textlike(); - return true; -} - -// Returns size of bytebuffer -// @def - bytebuffer identifier -DefReturnResult DefScriptPackage::func_bbsize(CmdSet& Set) -{ - ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if (!bb) - return false; - - return DefScriptTools::toString((uint64)bb->size()); -} +#include +#include +#include +#include +#include "DefScript.h" +#include "DefScriptTools.h" +#include "SysDefs.h" +#include "ByteBuffer.h" + +using namespace DefScriptTools; + +// Helper macros for insert/extract various datatypes that need type casting +#define BB_CAN_READ(bytebuffer, _ty) ((*(bytebuffer)).size() - (*(bytebuffer)).rpos() >= sizeof(_ty)) +#define BB_MACRO_INSERT_I(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) ) { *(bytebuffer) << (_ty)toUint64(Set.defaultarg); return true; } +#define BB_MACRO_INSERT_F(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) ) { *(bytebuffer) << (_ty)toNumber(Set.defaultarg); return true; } +#define BB_MACRO_EXTRACT_I(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) && BB_CAN_READ(bytebuffer,_ty) ) {_ty _var; *(bytebuffer) >> _var; return DefScriptTools::toString((uint64)_var); } +#define BB_MACRO_EXTRACT_F(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) && BB_CAN_READ(bytebuffer,_ty) ) {_ty _var; *(bytebuffer) >> _var; return DefScriptTools::toString((ldbl)_var); } + + +// Initializes bytebuffer with initial capacity (reserved, not resized) +// @def - bytebuffer identifier +// @0 - if set, initial capacity +DefReturnResult DefScriptPackage::func_bbinit(CmdSet& Set) +{ + ByteBuffer *bb = bytebuffers.Get(_NormalizeVarName(Set.defaultarg,Set.myname)); + bb->clear(); // also resets wpos & rpos + if (!Set.arg[0].empty()) + bb->reserve((size_t)DefScriptTools::toUint64(Set.arg[0])); + return true; +} + +// Cleans memory and deletes ByteBuffer from storage +DefReturnResult DefScriptPackage::func_bbdelete(CmdSet& Set) +{ + bytebuffers.Delete(_NormalizeVarName(Set.defaultarg,Set.myname)); + return true; +} + +// Appends data to ByteBuffer +// @def - data +// @0 - bytebuffer identifier +// @1 - datatype of added data (uint8,uint16,uint32,uint64,float,double,string,strnz) +DefReturnResult DefScriptPackage::func_bbappend(CmdSet& Set) +{ + ByteBuffer *bb = bytebuffers.Get(_NormalizeVarName(Set.arg[0],Set.myname)); + + std::string dtype = DefScriptTools::stringToLower(Set.arg[1]); + + if (dtype == "string") + { + *bb << Set.defaultarg; + return true; + } + else if(dtype == "strnz") + { + bb->append(Set.defaultarg.c_str(), Set.defaultarg.length()); // append the string skipping \0 + return true; + } + + BB_MACRO_INSERT_I(bb, dtype, uint8); + BB_MACRO_INSERT_I(bb, dtype, uint16); + BB_MACRO_INSERT_I(bb, dtype, uint32); + BB_MACRO_INSERT_I(bb, dtype, uint64); + BB_MACRO_INSERT_F(bb, dtype, float); + BB_MACRO_INSERT_F(bb, dtype, double); + + return false; +} + +// Extracts data from bytebuffer +// @def - datatype to extract (uint8,uint16,uint32,uint64,float,double,string) +// @0 - bytebuffer identifier +DefReturnResult DefScriptPackage::func_bbread(CmdSet& Set) +{ + ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if (!bb) + return false; + + std::string dtype = DefScriptTools::stringToLower(Set.defaultarg); + + if (dtype == "string") { + std::string g; + *bb >> g; + return g; + } + else if(dtype == "strnz") // extract some amount of bytes not terminated by \0 + { + uint32 bytes = (uint32)toUint64(Set.arg[1]); + if(bytes) + { + std::string g; + char *buf = new char[bytes+1]; // +1 for \0 + buf[bytes] = 0; + bb->read((uint8*)buf,bytes); + g = buf; + delete [] buf; + return g; + } + return ""; + } + + BB_MACRO_EXTRACT_I(bb, dtype, uint8); + BB_MACRO_EXTRACT_I(bb, dtype, uint16); + BB_MACRO_EXTRACT_I(bb, dtype, uint32); + BB_MACRO_EXTRACT_I(bb, dtype, uint64); + BB_MACRO_EXTRACT_F(bb, dtype, float); + BB_MACRO_EXTRACT_F(bb, dtype, double); + + return ""; // if extraction unsuccessful, return empty string +} + +// Sets read position in bytebuffer +// @0 - bytebuffer identifier +// @def - setted rpos (if "end", automatically set at end) +DefReturnResult DefScriptPackage::func_bbsetrpos(CmdSet& Set) +{ + ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if (!bb) + return false; + + if (Set.defaultarg == "end") + bb->rpos( bb->size() ); + else + bb->rpos( (unsigned int)toNumber(Set.defaultarg) ); + return true; +} + +// Sets write position in bytebuffer +// @0 - bytebuffer identifier +// @def - setted wpos (if "end", automatically set at end) +DefReturnResult DefScriptPackage::func_bbsetwpos(CmdSet& Set) +{ + ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if (!bb) + return false; + + if (Set.defaultarg == "end") + bb->wpos( bb->size() ); + else + bb->wpos( (unsigned int)toNumber(Set.defaultarg) ); + return true; +} + +// Hexlike output of bytebuffer to console +// @def - bytebuffer identifier +DefReturnResult DefScriptPackage::func_bbhexlike(CmdSet& Set) +{ + ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if (!bb) + return false; + + bb->hexlike(); + return true; +} + +// Textlike output of bytebuffer to console +// @def - bytebuffer identifier +DefReturnResult DefScriptPackage::func_bbtextlike(CmdSet& Set) +{ + ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if (!bb) + return false; + + bb->textlike(); + return true; +} + +// Returns size of bytebuffer +// @def - bytebuffer identifier +DefReturnResult DefScriptPackage::func_bbsize(CmdSet& Set) +{ + ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if (!bb) + return false; + + return DefScriptTools::toString((uint64)bb->size()); +} diff --git a/src/Client/DefScript/DefScriptDefines.h b/src/Client/DefScript/DefScriptDefines.h index ae0ad2e..672b14d 100644 --- a/src/Client/DefScript/DefScriptDefines.h +++ b/src/Client/DefScript/DefScriptDefines.h @@ -1,40 +1,40 @@ -#ifndef DEFSCRIPTDEFINES_H -#define DEFSCRIPTDEFINES_H - -#include "SysDefs.h" - -// use this directive to check if the parser is working correctly -#define DEF_DEBUG_SCRIPT_CALLS - -#ifdef _DEBUG -# define _DEFSC_DEBUG(code) code; -# define _DEFSC_DEBUG_LOG DebugLog // does NOT YET work!! -#else -# define _DEFSC_DEBUG(code) -# define _DEFSC_DEBUG_LOG -#endif - -// now included in SysDefs.h -/* -#if COMPILER == COMPILER_MICROSOFT -typedef __int64 int64; -typedef unsigned __int64 uint64; -#else -typedef __int64_t int64; -typedef __uint64_t uint64; -// TODO: correct ATOI64 for linux if necessary -#endif -*/ - -enum VariableType -{ - DEFSCRIPT_NONE=0, - DEFSCRIPT_VAR, - DEFSCRIPT_FUNC -}; - -typedef long double ldbl; - -#define SCRIPT_NAMESPACE "DEFSCRIPT::SCRIPT::" - +#ifndef DEFSCRIPTDEFINES_H +#define DEFSCRIPTDEFINES_H + +#include "SysDefs.h" + +// use this directive to check if the parser is working correctly +#define DEF_DEBUG_SCRIPT_CALLS + +#ifdef _DEBUG +# define _DEFSC_DEBUG(code) code; +# define _DEFSC_DEBUG_LOG DebugLog // does NOT YET work!! +#else +# define _DEFSC_DEBUG(code) +# define _DEFSC_DEBUG_LOG +#endif + +// now included in SysDefs.h +/* +#if COMPILER == COMPILER_MICROSOFT +typedef __int64 int64; +typedef unsigned __int64 uint64; +#else +typedef __int64_t int64; +typedef __uint64_t uint64; +// TODO: correct ATOI64 for linux if necessary +#endif +*/ + +enum VariableType +{ + DEFSCRIPT_NONE=0, + DEFSCRIPT_VAR, + DEFSCRIPT_FUNC +}; + +typedef long double ldbl; + +#define SCRIPT_NAMESPACE "DEFSCRIPT::SCRIPT::" + #endif \ No newline at end of file diff --git a/src/Client/DefScript/DefScriptFileFunctions.cpp b/src/Client/DefScript/DefScriptFileFunctions.cpp index 25ff680..c16f616 100644 --- a/src/Client/DefScript/DefScriptFileFunctions.cpp +++ b/src/Client/DefScript/DefScriptFileFunctions.cpp @@ -1,361 +1,361 @@ -#include -#include -#include -#include -#include "DefScript.h" -#include "DefScriptTools.h" -#include "SysDefs.h" - -using namespace DefScriptTools; - -#define FH_MACRO_READ_I(_f,_sty,_ty) if(_sty==(#_ty)) { _ty _in; (_f)->read((char*)&_in,sizeof(_ty)); return toString((uint64)_in); } -#define FH_MACRO_READ_F(_f,_sty,_ty) if(_sty==(#_ty)) { _ty _in; (_f)->read((char*)&_in,sizeof(_ty)); return toString((ldbl)_in); } - -DefReturnResult DefScriptPackage::func_fopen(CmdSet& Set) -{ - std::fstream *fh = files.Get(_NormalizeVarName(Set.arg[0],Set.myname)); - if(fh->is_open()) - return ""; - std::string mode = stringToLower(Set.arg[1]); - std::ios::openmode m = 0; - if(mode.find('b') != std::string::npos) - m |= std::ios_base::binary; - if(mode.find('a') != std::string::npos) - m |= std::ios_base::app; - if(mode.find('r') != std::string::npos) - m |= std::ios_base::in; - if(mode.find('w') != std::string::npos) - m |= std::ios_base::out; - - // sort out some possible errors with bad open modes - if(m & std::ios_base::app) - m |= std::ios_base::out; // always open for writing when appending - if(m == 0 || m == std::ios_base::binary) - m |= std::ios_base::out | std::ios_base::in; // if no openmode or binary only specified, use both r+w additionally - - fh->open(Set.defaultarg.c_str(), m); - - // if the file didnt open properly, like if a not existing file opened in read+write mode, - // try fallback mode with write mode only - if(!fh->is_open() && (m & std::ios_base::in)) - { - m &= (~std::ios_base::in); - fh->open(Set.defaultarg.c_str(), m); - } - _DEFSC_DEBUG( if(!fh->is_open()) printf("DefScript: Can't open file '%s'\n",Set.defaultarg.c_str())); - return fh->is_open(); -} - -DefReturnResult DefScriptPackage::func_fclose(CmdSet& Set) -{ - std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if(fh) - { - fh->flush(); - fh->close(); - files.DeleteByPtr(fh); - return true; - } - return false; -} - -DefReturnResult DefScriptPackage::func_fisopen(CmdSet& Set) -{ - std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - return fh && fh->good() && fh->is_open(); -} - -DefReturnResult DefScriptPackage::func_feof(CmdSet& Set) -{ - std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - return (!fh) || fh->eof(); -} - -DefReturnResult DefScriptPackage::func_frpos(CmdSet& Set) -{ - std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if(!fh) - return ""; - return toString((uint64)fh->tellg()); -} - -DefReturnResult DefScriptPackage::func_fwpos(CmdSet& Set) -{ - std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if(!fh) - return ""; - return toString((uint64)fh->tellp()); -} - -DefReturnResult DefScriptPackage::func_fdel(CmdSet& Set) -{ - return (remove(Set.defaultarg.c_str()) == 0); -} - -DefReturnResult DefScriptPackage::func_fflush(CmdSet& Set) -{ - std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if(fh && fh->is_open()) - fh->flush(); - return ""; -} - -DefReturnResult DefScriptPackage::func_fwrite(CmdSet& Set) -{ - std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if(fh && fh->is_open()) - { - *fh << Set.defaultarg; - return true; - } - return false; -} - -DefReturnResult DefScriptPackage::func_fread(CmdSet& Set) -{ - std::string fn = _NormalizeVarName(Set.arg[0],Set.myname); - std::fstream *fh = files.GetNoCreate(fn); - if(fh && fh->is_open()) - { - uint64 bytes; - uint64 read = 0; - if(stringToLower(Set.defaultarg) == "all") - { - std::fstream::pos_type begin_pos, end_pos, old_pos = fh->tellg(); - fh->seekg(0, std::ios_base::beg); - begin_pos=fh->tellg(); - fh->seekg(0, std::ios_base::end); - end_pos = fh->tellg(); - fh->seekg(old_pos, std::ios_base::beg); - bytes = (end_pos - begin_pos); - } - else - bytes = toUint64(Set.defaultarg); - std::string ret; - ret.reserve(bytes); - for(uint64 i = 0; i < bytes && !fh->eof(); i++) - { - ret += fh->get(); - read++; - } - return toString(read); - } - return ""; -} - -DefReturnResult DefScriptPackage::func_freadb(CmdSet& Set) -{ - std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if(fh && fh->is_open()) - { - std::string t = stringToLower(Set.defaultarg); - if(t == "string") - { - std::string ret; - while(char c = fh->get() && !fh->eof()) - ret += c; - return ret; - } - else if(t == "strnz") - { - uint32 bytes = (uint32)toUint64(Set.arg[1]); - if(bytes) - { - std::string g; - for(uint32 i = 0; i < bytes; i++) - { - g += fh->get(); - } - return g; - } - return ""; - } - FH_MACRO_READ_I(fh,t,uint8); - FH_MACRO_READ_I(fh,t,uint16); - FH_MACRO_READ_I(fh,t,uint32); - FH_MACRO_READ_I(fh,t,uint64); - FH_MACRO_READ_F(fh,t,float); - FH_MACRO_READ_F(fh,t,double); - } - return ""; -} - -DefReturnResult DefScriptPackage::func_fwriteb(CmdSet& Set) -{ - std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if(fh && fh->is_open()) - { - std::string t = stringToLower(Set.arg[1]); - if(t == "string") - { - fh->write(Set.defaultarg.c_str(), Set.defaultarg.size() + 1); // also put \0 - return true; - } - else if(t == "strnz") - { - fh->write(Set.defaultarg.c_str(), Set.defaultarg.size()); // skip \0 - return true; - } - else if(t == "uint8") - { - uint8 o = (uint8)toUint64(Set.defaultarg); - fh->write((char*)&o,sizeof(uint8)); - return true; - } - else if(t == "uint16") - { - uint16 o = (uint16)toUint64(Set.defaultarg); - fh->write((char*)&o,sizeof(uint16)); - return true; - } - else if(t == "uint32") - { - uint32 o = (uint32)toUint64(Set.defaultarg); - fh->write((char*)&o,sizeof(uint32)); - return true; - } - else if(t == "uint64") - { - uint64 o = toUint64(Set.defaultarg); - fh->write((char*)&o,sizeof(uint64)); - return true; - } - else if(t == "float") - { - float o = (float)toNumber(Set.defaultarg); - fh->write((char*)&o,sizeof(float)); - return true; - } - else if(t == "double") - { - double o = (double)toNumber(Set.defaultarg); - fh->write((char*)&o,sizeof(double)); - return true; - } - - } - return false; -} - -DefReturnResult DefScriptPackage::func_fwritebb(CmdSet& Set) -{ - std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if(fh && fh->is_open()) - { - ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if(bb) - { - uint32 bytes = (uint32)toUint64(Set.arg[1]); - if(!bytes) - { - bytes = bb->size(); - } - if(bytes) - { - fh->write((char*)bb->contents(), bytes); - } - return toString((uint64)bytes); - } - } - return ""; -} - -DefReturnResult DefScriptPackage::func_freadbb(CmdSet& Set) -{ - std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if(fh && fh->is_open()) - { - ByteBuffer *bb = bytebuffers.Get(_NormalizeVarName(Set.defaultarg,Set.myname)); - uint32 bytes = (uint32)toUint64(Set.arg[1]); - if(!bytes) - { - // get amount of remaining bytes - std::ios::pos_type oldpos = fh->tellg(); - fh->seekg(0,std::ios_base::end); - bytes = uint32(fh->tellg() - oldpos); - fh->seekg(oldpos,std::ios_base::beg); - } - if(bytes) - { - bb->resize(bb->size() + bytes); - fh->read((char*)bb->contents(), bytes); - } - return toString((uint64)bytes); - } - return ""; -} - -DefReturnResult DefScriptPackage::func_fsize(CmdSet& Set) -{ - std::ifstream f; - f.open(Set.defaultarg.c_str(), std::ios_base::binary | std::ios_base::in); - if (!f.good() || f.eof() || !f.is_open()) { return ""; } - f.seekg(0, std::ios_base::beg); - std::ifstream::pos_type begin_pos = f.tellg(), end_pos; - f.seekg(0, std::ios_base::end); - end_pos = f.tellg(); - f.close(); - return toString((uint64)(end_pos - begin_pos)); -} - -DefReturnResult DefScriptPackage::func_freadline(CmdSet& Set) -{ - std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if(fh && fh->is_open()) - { - char c; - std::string line; - line.reserve(30); // rough guess to speedup appending - while(!fh->eof()) - { - c = fh->get(); - if(c == '\n' || fh->eof()) - return line; - else - line += c; - } - } - return ""; -} - -DefReturnResult DefScriptPackage::func_fseekw(CmdSet& Set) -{ - std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if(fh && fh->is_open()) - { - std::string w = stringToLower(Set.arg[1]); - uint32 pos = (uint32)toUint64(Set.defaultarg); - if(w.empty() || w == "begin") - { - fh->seekp(pos, std::ios_base::beg); - return true; - } - else if(w == "end") - { - fh->seekp(pos, std::ios_base::end); - return true; - } - } - return false; -} - -DefReturnResult DefScriptPackage::func_fseekr(CmdSet& Set) -{ - std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if(fh && fh->is_open()) - { - std::string w = stringToLower(Set.arg[1]); - uint32 pos = (uint32)toUint64(Set.defaultarg); - if(w.empty() || w == "begin") - { - fh->seekg(pos, std::ios_base::beg); - return true; - } - else if(w == "end") - { - fh->seekg(pos, std::ios_base::end); - return true; - } - } - return false; +#include +#include +#include +#include +#include "DefScript.h" +#include "DefScriptTools.h" +#include "SysDefs.h" + +using namespace DefScriptTools; + +#define FH_MACRO_READ_I(_f,_sty,_ty) if(_sty==(#_ty)) { _ty _in; (_f)->read((char*)&_in,sizeof(_ty)); return toString((uint64)_in); } +#define FH_MACRO_READ_F(_f,_sty,_ty) if(_sty==(#_ty)) { _ty _in; (_f)->read((char*)&_in,sizeof(_ty)); return toString((ldbl)_in); } + +DefReturnResult DefScriptPackage::func_fopen(CmdSet& Set) +{ + std::fstream *fh = files.Get(_NormalizeVarName(Set.arg[0],Set.myname)); + if(fh->is_open()) + return ""; + std::string mode = stringToLower(Set.arg[1]); + std::ios::openmode m = 0; + if(mode.find('b') != std::string::npos) + m |= std::ios_base::binary; + if(mode.find('a') != std::string::npos) + m |= std::ios_base::app; + if(mode.find('r') != std::string::npos) + m |= std::ios_base::in; + if(mode.find('w') != std::string::npos) + m |= std::ios_base::out; + + // sort out some possible errors with bad open modes + if(m & std::ios_base::app) + m |= std::ios_base::out; // always open for writing when appending + if(m == 0 || m == std::ios_base::binary) + m |= std::ios_base::out | std::ios_base::in; // if no openmode or binary only specified, use both r+w additionally + + fh->open(Set.defaultarg.c_str(), m); + + // if the file didnt open properly, like if a not existing file opened in read+write mode, + // try fallback mode with write mode only + if(!fh->is_open() && (m & std::ios_base::in)) + { + m &= (~std::ios_base::in); + fh->open(Set.defaultarg.c_str(), m); + } + _DEFSC_DEBUG( if(!fh->is_open()) printf("DefScript: Can't open file '%s'\n",Set.defaultarg.c_str())); + return fh->is_open(); +} + +DefReturnResult DefScriptPackage::func_fclose(CmdSet& Set) +{ + std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if(fh) + { + fh->flush(); + fh->close(); + files.DeleteByPtr(fh); + return true; + } + return false; +} + +DefReturnResult DefScriptPackage::func_fisopen(CmdSet& Set) +{ + std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + return fh && fh->good() && fh->is_open(); +} + +DefReturnResult DefScriptPackage::func_feof(CmdSet& Set) +{ + std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + return (!fh) || fh->eof(); +} + +DefReturnResult DefScriptPackage::func_frpos(CmdSet& Set) +{ + std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if(!fh) + return ""; + return toString((uint64)fh->tellg()); +} + +DefReturnResult DefScriptPackage::func_fwpos(CmdSet& Set) +{ + std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if(!fh) + return ""; + return toString((uint64)fh->tellp()); +} + +DefReturnResult DefScriptPackage::func_fdel(CmdSet& Set) +{ + return (remove(Set.defaultarg.c_str()) == 0); +} + +DefReturnResult DefScriptPackage::func_fflush(CmdSet& Set) +{ + std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if(fh && fh->is_open()) + fh->flush(); + return ""; +} + +DefReturnResult DefScriptPackage::func_fwrite(CmdSet& Set) +{ + std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if(fh && fh->is_open()) + { + *fh << Set.defaultarg; + return true; + } + return false; +} + +DefReturnResult DefScriptPackage::func_fread(CmdSet& Set) +{ + std::string fn = _NormalizeVarName(Set.arg[0],Set.myname); + std::fstream *fh = files.GetNoCreate(fn); + if(fh && fh->is_open()) + { + uint64 bytes; + uint64 read = 0; + if(stringToLower(Set.defaultarg) == "all") + { + std::fstream::pos_type begin_pos, end_pos, old_pos = fh->tellg(); + fh->seekg(0, std::ios_base::beg); + begin_pos=fh->tellg(); + fh->seekg(0, std::ios_base::end); + end_pos = fh->tellg(); + fh->seekg(old_pos, std::ios_base::beg); + bytes = (end_pos - begin_pos); + } + else + bytes = toUint64(Set.defaultarg); + std::string ret; + ret.reserve(bytes); + for(uint64 i = 0; i < bytes && !fh->eof(); i++) + { + ret += fh->get(); + read++; + } + return toString(read); + } + return ""; +} + +DefReturnResult DefScriptPackage::func_freadb(CmdSet& Set) +{ + std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if(fh && fh->is_open()) + { + std::string t = stringToLower(Set.defaultarg); + if(t == "string") + { + std::string ret; + while(char c = fh->get() && !fh->eof()) + ret += c; + return ret; + } + else if(t == "strnz") + { + uint32 bytes = (uint32)toUint64(Set.arg[1]); + if(bytes) + { + std::string g; + for(uint32 i = 0; i < bytes; i++) + { + g += fh->get(); + } + return g; + } + return ""; + } + FH_MACRO_READ_I(fh,t,uint8); + FH_MACRO_READ_I(fh,t,uint16); + FH_MACRO_READ_I(fh,t,uint32); + FH_MACRO_READ_I(fh,t,uint64); + FH_MACRO_READ_F(fh,t,float); + FH_MACRO_READ_F(fh,t,double); + } + return ""; +} + +DefReturnResult DefScriptPackage::func_fwriteb(CmdSet& Set) +{ + std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if(fh && fh->is_open()) + { + std::string t = stringToLower(Set.arg[1]); + if(t == "string") + { + fh->write(Set.defaultarg.c_str(), Set.defaultarg.size() + 1); // also put \0 + return true; + } + else if(t == "strnz") + { + fh->write(Set.defaultarg.c_str(), Set.defaultarg.size()); // skip \0 + return true; + } + else if(t == "uint8") + { + uint8 o = (uint8)toUint64(Set.defaultarg); + fh->write((char*)&o,sizeof(uint8)); + return true; + } + else if(t == "uint16") + { + uint16 o = (uint16)toUint64(Set.defaultarg); + fh->write((char*)&o,sizeof(uint16)); + return true; + } + else if(t == "uint32") + { + uint32 o = (uint32)toUint64(Set.defaultarg); + fh->write((char*)&o,sizeof(uint32)); + return true; + } + else if(t == "uint64") + { + uint64 o = toUint64(Set.defaultarg); + fh->write((char*)&o,sizeof(uint64)); + return true; + } + else if(t == "float") + { + float o = (float)toNumber(Set.defaultarg); + fh->write((char*)&o,sizeof(float)); + return true; + } + else if(t == "double") + { + double o = (double)toNumber(Set.defaultarg); + fh->write((char*)&o,sizeof(double)); + return true; + } + + } + return false; +} + +DefReturnResult DefScriptPackage::func_fwritebb(CmdSet& Set) +{ + std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if(fh && fh->is_open()) + { + ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if(bb) + { + uint32 bytes = (uint32)toUint64(Set.arg[1]); + if(!bytes) + { + bytes = bb->size(); + } + if(bytes) + { + fh->write((char*)bb->contents(), bytes); + } + return toString((uint64)bytes); + } + } + return ""; +} + +DefReturnResult DefScriptPackage::func_freadbb(CmdSet& Set) +{ + std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if(fh && fh->is_open()) + { + ByteBuffer *bb = bytebuffers.Get(_NormalizeVarName(Set.defaultarg,Set.myname)); + uint32 bytes = (uint32)toUint64(Set.arg[1]); + if(!bytes) + { + // get amount of remaining bytes + std::ios::pos_type oldpos = fh->tellg(); + fh->seekg(0,std::ios_base::end); + bytes = uint32(fh->tellg() - oldpos); + fh->seekg(oldpos,std::ios_base::beg); + } + if(bytes) + { + bb->resize(bb->size() + bytes); + fh->read((char*)bb->contents(), bytes); + } + return toString((uint64)bytes); + } + return ""; +} + +DefReturnResult DefScriptPackage::func_fsize(CmdSet& Set) +{ + std::ifstream f; + f.open(Set.defaultarg.c_str(), std::ios_base::binary | std::ios_base::in); + if (!f.good() || f.eof() || !f.is_open()) { return ""; } + f.seekg(0, std::ios_base::beg); + std::ifstream::pos_type begin_pos = f.tellg(), end_pos; + f.seekg(0, std::ios_base::end); + end_pos = f.tellg(); + f.close(); + return toString((uint64)(end_pos - begin_pos)); +} + +DefReturnResult DefScriptPackage::func_freadline(CmdSet& Set) +{ + std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if(fh && fh->is_open()) + { + char c; + std::string line; + line.reserve(30); // rough guess to speedup appending + while(!fh->eof()) + { + c = fh->get(); + if(c == '\n' || fh->eof()) + return line; + else + line += c; + } + } + return ""; +} + +DefReturnResult DefScriptPackage::func_fseekw(CmdSet& Set) +{ + std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if(fh && fh->is_open()) + { + std::string w = stringToLower(Set.arg[1]); + uint32 pos = (uint32)toUint64(Set.defaultarg); + if(w.empty() || w == "begin") + { + fh->seekp(pos, std::ios_base::beg); + return true; + } + else if(w == "end") + { + fh->seekp(pos, std::ios_base::end); + return true; + } + } + return false; +} + +DefReturnResult DefScriptPackage::func_fseekr(CmdSet& Set) +{ + std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if(fh && fh->is_open()) + { + std::string w = stringToLower(Set.arg[1]); + uint32 pos = (uint32)toUint64(Set.defaultarg); + if(w.empty() || w == "begin") + { + fh->seekg(pos, std::ios_base::beg); + return true; + } + else if(w == "end") + { + fh->seekg(pos, std::ios_base::end); + return true; + } + } + return false; } \ No newline at end of file diff --git a/src/Client/DefScript/DefScriptFunctions.cpp b/src/Client/DefScript/DefScriptFunctions.cpp index d9aef04..1e74c99 100644 --- a/src/Client/DefScript/DefScriptFunctions.cpp +++ b/src/Client/DefScript/DefScriptFunctions.cpp @@ -1,542 +1,542 @@ -#include -#include -#include -#include -#include -#include -#include -#include "DefScript.h" - -using namespace DefScriptTools; - - -DefReturnResult DefScriptPackage::func_shdn(CmdSet& Set){ - DefReturnResult r; - //exit(0); - // need to define own - SCshdn(Set); - return r; -} - -DefReturnResult DefScriptPackage::func_out(CmdSet& Set){ - DefReturnResult r; - printf("%s\n",Set.defaultarg.c_str()); - r.ret=Set.defaultarg; - return r; -} - -DefReturnResult DefScriptPackage::func_loaddef(CmdSet& Set){ - if( ScriptExists(Set.defaultarg) ) - { - return "exists"; - } - return func_reloaddef(Set); -} - -// supply either the filename in default scripts directory, without extension, -// OR provide the full file path WITH extension -DefReturnResult DefScriptPackage::func_reloaddef(CmdSet& Set){ - DefReturnResult r; - bool result=false; - std::string fn; - - // if the filename does NOT contain any path, load from default script dir - std::string::size_type slashpos = Set.defaultarg.find_last_of("\\/"); - std::string::size_type ppos = Set.defaultarg.find_last_of("."); - if(slashpos == std::string::npos) - { - fn=scPath+Set.defaultarg; - } - else - { - fn=Set.defaultarg; - } - if(ppos==std::string::npos || ppos < slashpos) // even if there was neither / nor . they will be equal - fn+=".def"; - - result=LoadScriptFromFile(fn); - - r.ret=fn; - if(!result) - { - //std::cout << "Could not load script '" << Set.defaultarg << "' [" << fn << "]\n"; - r.ret=""; - } - return r; -} - -DefReturnResult DefScriptPackage::func_unloaddef(CmdSet& Set) -{ - if(!ScriptExists(Set.defaultarg)) - return false; - this->DeleteScript(Set.defaultarg); - return true; -} - -DefReturnResult DefScriptPackage::func_createdef(CmdSet& Set) -{ - std::string sn = stringToLower(Set.defaultarg); - if(!ScriptExists(sn)) - { - _UpdateOrCreateScriptByName(sn); - return true; - } - return false; -} - -DefReturnResult DefScriptPackage::func_unset(CmdSet& Set){ - DefReturnResult r; - r.ret=Set.defaultarg; - if(Set.defaultarg.empty()){ - //if(curIsDebug) - // printf("Can't unset, no variable name given.\n"); - return r; - } - if(Set.defaultarg.at(0)=='@'){ - //if(curIsDebug) - // printf("Can't unset macros!\n"); - return r; - } - std::string vn=_NormalizeVarName(Set.defaultarg, Set.caller); - variables.Unset(vn); - //std::cout<<"Unset var '"<defaultarg<<"'\n"; - return r; -} - -DefReturnResult DefScriptPackage::func_set(CmdSet& Set) -{ - DefReturnResult r; - if(Set.arg[0].empty()) - { - //if(curIsDebug) - // printf("Can't assign value, no variable name given.\n"); - return r; - } - Set.arg[0]=UnescapeString(Set.arg[0]); - if(Set.arg[0].at(0)=='@') - { - //if(curIsDebug) - // printf("Can't assign value to a macro!\n"); - return r; - } - std::string vname,vval=Set.defaultarg; - vname=_NormalizeVarName(Set.arg[0], Set.myname); - - //if(!stricmp(Set.arg[1].c_str(),"onfail") && vval.find("${")!=std::string::npos) - // vval=Set.arg[2]; - - variables.Set(vname,vval); - r.ret=vval; - - DefScript *sc = GetScript(Set.myname); - if(sc && sc->GetDebug()) - printf("VAR: %s = '%s'\n",vname.c_str(),vval.c_str()); - - return r; -} - -DefReturnResult DefScriptPackage::func_default(CmdSet& Set) -{ - DefReturnResult r; - if(Set.arg[0].empty()) - { - //if(curIsDebug) - // printf("Can't assign value, no variable name given.\n"); - return r; - } - Set.arg[0]=UnescapeString(Set.arg[0]); - if(Set.arg[0].at(0)=='@') - { - //if(curIsDebug) - // printf("Can't assign value to a macro!\n"); - return r; - } - std::string vname,vval=Set.defaultarg; - vname=_NormalizeVarName(Set.arg[0], Set.caller); - - if(variables.Get(vname).empty()) - { - variables.Set(vname,vval); // set only if it has no value or the var doesnt exist - r.ret=vval; - } - else - { - r.ret=variables.Get(vname); - } - - return r; -} - -DefReturnResult DefScriptPackage::func_setscriptpermission(CmdSet& Set) -{ - DefReturnResult r; - if(Set.defaultarg.empty() || Set.arg[0].empty()) - return r; - - scriptPermissionMap[Set.arg[0]] = (unsigned char)toUint64(Set.defaultarg); - return r; -} - -DefReturnResult DefScriptPackage::func_toint(CmdSet& Set) -{ - DefReturnResult r; - std::string num=toString(toUint64(Set.defaultarg)); - if(!Set.arg[0].empty()) - { - std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); - variables.Set(vname,num); - } - r.ret=num; - return r; -} - -DefReturnResult DefScriptPackage::func_add(CmdSet& Set) -{ - DefReturnResult r; - if(Set.arg[0].empty()) - { - return r; - } - - std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); - ldbl a=toNumber(variables.Get(vname)); - ldbl b=toNumber(Set.defaultarg); - a+=b; - variables.Set(vname,toString(a)); - r.ret=toString(a); - return r; -} - -DefReturnResult DefScriptPackage::func_sub(CmdSet& Set) -{ - DefReturnResult r; - if(Set.arg[0].empty()) - { - return r; - } - - std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); - ldbl a=toNumber(variables.Get(vname)); - ldbl b=toNumber(Set.defaultarg); - a-=b; - variables.Set(vname,toString(a)); - r.ret=toString(a); - return r; -} - -DefReturnResult DefScriptPackage::func_mul(CmdSet& Set) -{ - DefReturnResult r; - if(Set.arg[0].empty()) - { - return r; - } - - std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); - ldbl a=toNumber(variables.Get(vname)); - ldbl b=toNumber(Set.defaultarg); - a*=b; - variables.Set(vname,toString(a)); - r.ret=toString(a); - return r; -} - -DefReturnResult DefScriptPackage::func_div(CmdSet& Set) -{ - DefReturnResult r; - if(Set.arg[0].empty()) - { - return r; - } - - std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); - ldbl a=toNumber(variables.Get(vname)); - ldbl b=toNumber(Set.defaultarg); - if(b==0) - a=0; - else - a/=b; - variables.Set(vname,toString(a)); - r.ret=toString(a); - return r; -} - -DefReturnResult DefScriptPackage::func_mod(CmdSet& Set) -{ - DefReturnResult r; - if(Set.arg[0].empty()) - { - return r; - } - - std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); - uint64 a=toUint64(variables.Get(vname)); - uint64 b=toUint64(Set.defaultarg); - if(b==0) - a=0; - else - a%=b; - variables.Set(vname,toString(a)); - r.ret=toString(a); - return r; -} - -DefReturnResult DefScriptPackage::func_pow(CmdSet& Set) -{ - DefReturnResult r; - if(Set.arg[0].empty()) - { - return r; - } - - std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); - ldbl a=toNumber(variables.Get(vname)); - ldbl b=toNumber(Set.defaultarg); - a=pow(a,b); - variables.Set(vname,toString(a)); - r.ret=toString(a); - return r; -} - -DefReturnResult DefScriptPackage::func_bitor(CmdSet& Set) -{ - DefReturnResult r; - if(Set.arg[0].empty()) - { - return r; - } - - std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); - uint64 a=toUint64(variables.Get(vname)); - uint64 b=toUint64(Set.defaultarg); - a|=b; - variables.Set(vname,toString(a)); - r.ret=toString(a); - return r; -} - -DefReturnResult DefScriptPackage::func_bitand(CmdSet& Set) -{ - DefReturnResult r; - if(Set.arg[0].empty()) - { - return r; - } - - std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); - uint64 a=toUint64(variables.Get(vname)); - uint64 b=toUint64(Set.defaultarg); - a&=b; - variables.Set(vname,toString(a)); - r.ret=toString(a); - return r; -} - -DefReturnResult DefScriptPackage::func_bitxor(CmdSet& Set) -{ - DefReturnResult r; - if(Set.arg[0].empty()) - { - return r; - } - - std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); - uint64 a=toUint64(variables.Get(vname)); - uint64 b=toUint64(Set.defaultarg); - a^=b; - variables.Set(vname,toString(a)); - r.ret=toString(a); - return r; -} - -DefReturnResult DefScriptPackage::func_addevent(CmdSet& Set) -{ - GetEventMgr()->Add(Set.arg[0],Set.defaultarg,(clock_t)toNumber(Set.arg[1]),Set.myname.c_str(),isTrue(Set.arg[2])); - return true; -} - -DefReturnResult DefScriptPackage::func_removeevent(CmdSet& Set) -{ - GetEventMgr()->Remove(Set.defaultarg); - return true; -} - -DefReturnResult DefScriptPackage::func_strlen(CmdSet& Set) -{ - DefReturnResult r; - r.ret=toString((uint64)Set.defaultarg.length()); - return r; -} - -DefReturnResult DefScriptPackage::func_equal(CmdSet& Set) -{ - bool result; - if(stringToLower(Set.arg[1])=="ignore") - { - result=stringToLower(Set.defaultarg)==stringToLower(Set.arg[0]); - } - else - { - result=Set.defaultarg==Set.arg[0]; - } - - // for debugging - _DEFSC_DEBUG - ( - char tmp[500]; - sprintf(tmp,"DEFSCRIPT: func_equal: ['%s'=='%s'] = %s\n",Set.arg[0].c_str(),Set.defaultarg.c_str(),result?"true":"false"); - hLogfile << tmp; - ); - return result; -} - - -DefReturnResult DefScriptPackage::func_smaller(CmdSet& Set) -{ - return toNumber(Set.arg[0]) < toNumber(Set.defaultarg); -} - -DefReturnResult DefScriptPackage::func_bigger(CmdSet& Set) -{ - return toNumber(Set.arg[0]) > toNumber(Set.defaultarg); -} - -DefReturnResult DefScriptPackage::func_smaller_eq(CmdSet& Set) -{ - return toNumber(Set.arg[0]) <= toNumber(Set.defaultarg); -} - -DefReturnResult DefScriptPackage::func_bigger_eq(CmdSet& Set) -{ - return toNumber(Set.arg[0]) >= toNumber(Set.defaultarg); -} - -DefReturnResult DefScriptPackage::func_not(CmdSet& Set) -{ - return !isTrue(Set.defaultarg); -} - -DefReturnResult DefScriptPackage::func_isset(CmdSet& Set) -{ - std::string vname=_NormalizeVarName(Set.defaultarg,Set.myname); - return variables.Exists(vname); -} - -DefReturnResult DefScriptPackage::func_tohex(CmdSet& Set) -{ - DefReturnResult r; - char buf[50]; - bool full=stringToLower(Set.arg[0])=="full"; - uint64 u=toUint64(Set.defaultarg); -#if COMPILER == COMPILER_MICROSOFT - sprintf(buf,"%016I64X",u); -#else - sprintf(buf,"%016llX",u); -#endif - std::string str=buf; - if(!full) - while(str.length() && str.at(0)=='0') - str.erase(0,1); - r.ret = std::string("0x").append(str); - return r; -} - -DefReturnResult DefScriptPackage::func_abs(CmdSet& Set) -{ - DefReturnResult r; - r.ret=toString(fabs(toNumber(Set.defaultarg))); - return r; -} - -DefReturnResult DefScriptPackage::func_and(CmdSet& Set) -{ - return isTrue(Set.defaultarg) && isTrue(Set.arg[0]); -} - -DefReturnResult DefScriptPackage::func_or(CmdSet& Set) -{ - return isTrue(Set.defaultarg) || isTrue(Set.arg[0]); -} - -DefReturnResult DefScriptPackage::func_xor(CmdSet& Set) -{ - return (isTrue(Set.defaultarg) && isTrue(Set.arg[0])) || ( (!isTrue(Set.defaultarg)) && (!isTrue(Set.arg[0]) ) ); -} - -DefReturnResult DefScriptPackage::func_substr(CmdSet& Set) -{ - DefReturnResult r; - if(Set.defaultarg.empty()) - { - r.ret=""; - } - else - { - unsigned int start,len; - len=(unsigned int)toNumber(Set.arg[0]); - start=(unsigned int)toNumber(Set.arg[1]); - if(start+len>Set.defaultarg.length()) - len=Set.defaultarg.length()-start; - r.ret=Set.defaultarg.substr(start,len); - } - return r; -} - -DefReturnResult DefScriptPackage::func_uppercase(CmdSet& Set) -{ - DefReturnResult r; - r.ret=stringToUpper(Set.defaultarg); - return r; -} - -DefReturnResult DefScriptPackage::func_lowercase(CmdSet& Set) -{ - DefReturnResult r; - r.ret=stringToLower(Set.defaultarg); - return r; -} - -DefReturnResult DefScriptPackage::func_random(CmdSet& Set) -{ - DefReturnResult r; - int min,max; - min=(int)toUint64(Set.arg[0]); - max=(int)toUint64(Set.defaultarg); - r.ret=toString(ldbl( min + ( rand() % (max - min + 1)) )); - return r; -} - -DefReturnResult DefScriptPackage::func_fileexists(CmdSet& Set) -{ - std::fstream f; - f.open(Set.defaultarg.c_str(),std::ios_base::in); - if (f.is_open()) - { - f.close(); - return true; - } - return false; -} - -DefReturnResult DefScriptPackage::func_strfind(CmdSet& Set) -{ - unsigned int pos = Set.defaultarg.find(Set.arg[0],(unsigned int)toNumber(Set.arg[1])); - if(pos == std::string::npos) - return ""; - return toString((uint64)pos); -} - -DefReturnResult DefScriptPackage::func_scriptexists(CmdSet& Set) -{ - return ScriptExists(stringToLower(Set.defaultarg)); -} - -DefReturnResult DefScriptPackage::func_funcexists(CmdSet& Set) -{ - for(DefScriptFunctionTable::iterator i = _functable.begin(); i != _functable.end(); i++) - { - if(i->name == stringToLower(Set.defaultarg)) - return true; - } - return false; -} +#include +#include +#include +#include +#include +#include +#include +#include "DefScript.h" + +using namespace DefScriptTools; + + +DefReturnResult DefScriptPackage::func_shdn(CmdSet& Set){ + DefReturnResult r; + //exit(0); + // need to define own + SCshdn(Set); + return r; +} + +DefReturnResult DefScriptPackage::func_out(CmdSet& Set){ + DefReturnResult r; + printf("%s\n",Set.defaultarg.c_str()); + r.ret=Set.defaultarg; + return r; +} + +DefReturnResult DefScriptPackage::func_loaddef(CmdSet& Set){ + if( ScriptExists(Set.defaultarg) ) + { + return "exists"; + } + return func_reloaddef(Set); +} + +// supply either the filename in default scripts directory, without extension, +// OR provide the full file path WITH extension +DefReturnResult DefScriptPackage::func_reloaddef(CmdSet& Set){ + DefReturnResult r; + bool result=false; + std::string fn; + + // if the filename does NOT contain any path, load from default script dir + std::string::size_type slashpos = Set.defaultarg.find_last_of("\\/"); + std::string::size_type ppos = Set.defaultarg.find_last_of("."); + if(slashpos == std::string::npos) + { + fn=scPath+Set.defaultarg; + } + else + { + fn=Set.defaultarg; + } + if(ppos==std::string::npos || ppos < slashpos) // even if there was neither / nor . they will be equal + fn+=".def"; + + result=LoadScriptFromFile(fn); + + r.ret=fn; + if(!result) + { + //std::cout << "Could not load script '" << Set.defaultarg << "' [" << fn << "]\n"; + r.ret=""; + } + return r; +} + +DefReturnResult DefScriptPackage::func_unloaddef(CmdSet& Set) +{ + if(!ScriptExists(Set.defaultarg)) + return false; + this->DeleteScript(Set.defaultarg); + return true; +} + +DefReturnResult DefScriptPackage::func_createdef(CmdSet& Set) +{ + std::string sn = stringToLower(Set.defaultarg); + if(!ScriptExists(sn)) + { + _UpdateOrCreateScriptByName(sn); + return true; + } + return false; +} + +DefReturnResult DefScriptPackage::func_unset(CmdSet& Set){ + DefReturnResult r; + r.ret=Set.defaultarg; + if(Set.defaultarg.empty()){ + //if(curIsDebug) + // printf("Can't unset, no variable name given.\n"); + return r; + } + if(Set.defaultarg.at(0)=='@'){ + //if(curIsDebug) + // printf("Can't unset macros!\n"); + return r; + } + std::string vn=_NormalizeVarName(Set.defaultarg, Set.caller); + variables.Unset(vn); + //std::cout<<"Unset var '"<defaultarg<<"'\n"; + return r; +} + +DefReturnResult DefScriptPackage::func_set(CmdSet& Set) +{ + DefReturnResult r; + if(Set.arg[0].empty()) + { + //if(curIsDebug) + // printf("Can't assign value, no variable name given.\n"); + return r; + } + Set.arg[0]=UnescapeString(Set.arg[0]); + if(Set.arg[0].at(0)=='@') + { + //if(curIsDebug) + // printf("Can't assign value to a macro!\n"); + return r; + } + std::string vname,vval=Set.defaultarg; + vname=_NormalizeVarName(Set.arg[0], Set.myname); + + //if(!stricmp(Set.arg[1].c_str(),"onfail") && vval.find("${")!=std::string::npos) + // vval=Set.arg[2]; + + variables.Set(vname,vval); + r.ret=vval; + + DefScript *sc = GetScript(Set.myname); + if(sc && sc->GetDebug()) + printf("VAR: %s = '%s'\n",vname.c_str(),vval.c_str()); + + return r; +} + +DefReturnResult DefScriptPackage::func_default(CmdSet& Set) +{ + DefReturnResult r; + if(Set.arg[0].empty()) + { + //if(curIsDebug) + // printf("Can't assign value, no variable name given.\n"); + return r; + } + Set.arg[0]=UnescapeString(Set.arg[0]); + if(Set.arg[0].at(0)=='@') + { + //if(curIsDebug) + // printf("Can't assign value to a macro!\n"); + return r; + } + std::string vname,vval=Set.defaultarg; + vname=_NormalizeVarName(Set.arg[0], Set.caller); + + if(variables.Get(vname).empty()) + { + variables.Set(vname,vval); // set only if it has no value or the var doesnt exist + r.ret=vval; + } + else + { + r.ret=variables.Get(vname); + } + + return r; +} + +DefReturnResult DefScriptPackage::func_setscriptpermission(CmdSet& Set) +{ + DefReturnResult r; + if(Set.defaultarg.empty() || Set.arg[0].empty()) + return r; + + scriptPermissionMap[Set.arg[0]] = (unsigned char)toUint64(Set.defaultarg); + return r; +} + +DefReturnResult DefScriptPackage::func_toint(CmdSet& Set) +{ + DefReturnResult r; + std::string num=toString(toUint64(Set.defaultarg)); + if(!Set.arg[0].empty()) + { + std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); + variables.Set(vname,num); + } + r.ret=num; + return r; +} + +DefReturnResult DefScriptPackage::func_add(CmdSet& Set) +{ + DefReturnResult r; + if(Set.arg[0].empty()) + { + return r; + } + + std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); + ldbl a=toNumber(variables.Get(vname)); + ldbl b=toNumber(Set.defaultarg); + a+=b; + variables.Set(vname,toString(a)); + r.ret=toString(a); + return r; +} + +DefReturnResult DefScriptPackage::func_sub(CmdSet& Set) +{ + DefReturnResult r; + if(Set.arg[0].empty()) + { + return r; + } + + std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); + ldbl a=toNumber(variables.Get(vname)); + ldbl b=toNumber(Set.defaultarg); + a-=b; + variables.Set(vname,toString(a)); + r.ret=toString(a); + return r; +} + +DefReturnResult DefScriptPackage::func_mul(CmdSet& Set) +{ + DefReturnResult r; + if(Set.arg[0].empty()) + { + return r; + } + + std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); + ldbl a=toNumber(variables.Get(vname)); + ldbl b=toNumber(Set.defaultarg); + a*=b; + variables.Set(vname,toString(a)); + r.ret=toString(a); + return r; +} + +DefReturnResult DefScriptPackage::func_div(CmdSet& Set) +{ + DefReturnResult r; + if(Set.arg[0].empty()) + { + return r; + } + + std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); + ldbl a=toNumber(variables.Get(vname)); + ldbl b=toNumber(Set.defaultarg); + if(b==0) + a=0; + else + a/=b; + variables.Set(vname,toString(a)); + r.ret=toString(a); + return r; +} + +DefReturnResult DefScriptPackage::func_mod(CmdSet& Set) +{ + DefReturnResult r; + if(Set.arg[0].empty()) + { + return r; + } + + std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); + uint64 a=toUint64(variables.Get(vname)); + uint64 b=toUint64(Set.defaultarg); + if(b==0) + a=0; + else + a%=b; + variables.Set(vname,toString(a)); + r.ret=toString(a); + return r; +} + +DefReturnResult DefScriptPackage::func_pow(CmdSet& Set) +{ + DefReturnResult r; + if(Set.arg[0].empty()) + { + return r; + } + + std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); + ldbl a=toNumber(variables.Get(vname)); + ldbl b=toNumber(Set.defaultarg); + a=pow(a,b); + variables.Set(vname,toString(a)); + r.ret=toString(a); + return r; +} + +DefReturnResult DefScriptPackage::func_bitor(CmdSet& Set) +{ + DefReturnResult r; + if(Set.arg[0].empty()) + { + return r; + } + + std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); + uint64 a=toUint64(variables.Get(vname)); + uint64 b=toUint64(Set.defaultarg); + a|=b; + variables.Set(vname,toString(a)); + r.ret=toString(a); + return r; +} + +DefReturnResult DefScriptPackage::func_bitand(CmdSet& Set) +{ + DefReturnResult r; + if(Set.arg[0].empty()) + { + return r; + } + + std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); + uint64 a=toUint64(variables.Get(vname)); + uint64 b=toUint64(Set.defaultarg); + a&=b; + variables.Set(vname,toString(a)); + r.ret=toString(a); + return r; +} + +DefReturnResult DefScriptPackage::func_bitxor(CmdSet& Set) +{ + DefReturnResult r; + if(Set.arg[0].empty()) + { + return r; + } + + std::string vname=_NormalizeVarName(Set.arg[0], Set.myname); + uint64 a=toUint64(variables.Get(vname)); + uint64 b=toUint64(Set.defaultarg); + a^=b; + variables.Set(vname,toString(a)); + r.ret=toString(a); + return r; +} + +DefReturnResult DefScriptPackage::func_addevent(CmdSet& Set) +{ + GetEventMgr()->Add(Set.arg[0],Set.defaultarg,(clock_t)toNumber(Set.arg[1]),Set.myname.c_str(),isTrue(Set.arg[2])); + return true; +} + +DefReturnResult DefScriptPackage::func_removeevent(CmdSet& Set) +{ + GetEventMgr()->Remove(Set.defaultarg); + return true; +} + +DefReturnResult DefScriptPackage::func_strlen(CmdSet& Set) +{ + DefReturnResult r; + r.ret=toString((uint64)Set.defaultarg.length()); + return r; +} + +DefReturnResult DefScriptPackage::func_equal(CmdSet& Set) +{ + bool result; + if(stringToLower(Set.arg[1])=="ignore") + { + result=stringToLower(Set.defaultarg)==stringToLower(Set.arg[0]); + } + else + { + result=Set.defaultarg==Set.arg[0]; + } + + // for debugging + _DEFSC_DEBUG + ( + char tmp[500]; + sprintf(tmp,"DEFSCRIPT: func_equal: ['%s'=='%s'] = %s\n",Set.arg[0].c_str(),Set.defaultarg.c_str(),result?"true":"false"); + hLogfile << tmp; + ); + return result; +} + + +DefReturnResult DefScriptPackage::func_smaller(CmdSet& Set) +{ + return toNumber(Set.arg[0]) < toNumber(Set.defaultarg); +} + +DefReturnResult DefScriptPackage::func_bigger(CmdSet& Set) +{ + return toNumber(Set.arg[0]) > toNumber(Set.defaultarg); +} + +DefReturnResult DefScriptPackage::func_smaller_eq(CmdSet& Set) +{ + return toNumber(Set.arg[0]) <= toNumber(Set.defaultarg); +} + +DefReturnResult DefScriptPackage::func_bigger_eq(CmdSet& Set) +{ + return toNumber(Set.arg[0]) >= toNumber(Set.defaultarg); +} + +DefReturnResult DefScriptPackage::func_not(CmdSet& Set) +{ + return !isTrue(Set.defaultarg); +} + +DefReturnResult DefScriptPackage::func_isset(CmdSet& Set) +{ + std::string vname=_NormalizeVarName(Set.defaultarg,Set.myname); + return variables.Exists(vname); +} + +DefReturnResult DefScriptPackage::func_tohex(CmdSet& Set) +{ + DefReturnResult r; + char buf[50]; + bool full=stringToLower(Set.arg[0])=="full"; + uint64 u=toUint64(Set.defaultarg); +#if COMPILER == COMPILER_MICROSOFT + sprintf(buf,"%016I64X",u); +#else + sprintf(buf,"%016llX",u); +#endif + std::string str=buf; + if(!full) + while(str.length() && str.at(0)=='0') + str.erase(0,1); + r.ret = std::string("0x").append(str); + return r; +} + +DefReturnResult DefScriptPackage::func_abs(CmdSet& Set) +{ + DefReturnResult r; + r.ret=toString(fabs(toNumber(Set.defaultarg))); + return r; +} + +DefReturnResult DefScriptPackage::func_and(CmdSet& Set) +{ + return isTrue(Set.defaultarg) && isTrue(Set.arg[0]); +} + +DefReturnResult DefScriptPackage::func_or(CmdSet& Set) +{ + return isTrue(Set.defaultarg) || isTrue(Set.arg[0]); +} + +DefReturnResult DefScriptPackage::func_xor(CmdSet& Set) +{ + return (isTrue(Set.defaultarg) && isTrue(Set.arg[0])) || ( (!isTrue(Set.defaultarg)) && (!isTrue(Set.arg[0]) ) ); +} + +DefReturnResult DefScriptPackage::func_substr(CmdSet& Set) +{ + DefReturnResult r; + if(Set.defaultarg.empty()) + { + r.ret=""; + } + else + { + unsigned int start,len; + len=(unsigned int)toNumber(Set.arg[0]); + start=(unsigned int)toNumber(Set.arg[1]); + if(start+len>Set.defaultarg.length()) + len=Set.defaultarg.length()-start; + r.ret=Set.defaultarg.substr(start,len); + } + return r; +} + +DefReturnResult DefScriptPackage::func_uppercase(CmdSet& Set) +{ + DefReturnResult r; + r.ret=stringToUpper(Set.defaultarg); + return r; +} + +DefReturnResult DefScriptPackage::func_lowercase(CmdSet& Set) +{ + DefReturnResult r; + r.ret=stringToLower(Set.defaultarg); + return r; +} + +DefReturnResult DefScriptPackage::func_random(CmdSet& Set) +{ + DefReturnResult r; + int min,max; + min=(int)toUint64(Set.arg[0]); + max=(int)toUint64(Set.defaultarg); + r.ret=toString(ldbl( min + ( rand() % (max - min + 1)) )); + return r; +} + +DefReturnResult DefScriptPackage::func_fileexists(CmdSet& Set) +{ + std::fstream f; + f.open(Set.defaultarg.c_str(),std::ios_base::in); + if (f.is_open()) + { + f.close(); + return true; + } + return false; +} + +DefReturnResult DefScriptPackage::func_strfind(CmdSet& Set) +{ + unsigned int pos = Set.defaultarg.find(Set.arg[0],(unsigned int)toNumber(Set.arg[1])); + if(pos == std::string::npos) + return ""; + return toString((uint64)pos); +} + +DefReturnResult DefScriptPackage::func_scriptexists(CmdSet& Set) +{ + return ScriptExists(stringToLower(Set.defaultarg)); +} + +DefReturnResult DefScriptPackage::func_funcexists(CmdSet& Set) +{ + for(DefScriptFunctionTable::iterator i = _functable.begin(); i != _functable.end(); i++) + { + if(i->name == stringToLower(Set.defaultarg)) + return true; + } + return false; +} diff --git a/src/Client/DefScript/DefScriptListFunctions.cpp b/src/Client/DefScript/DefScriptListFunctions.cpp index 758df8b..688bed9 100644 --- a/src/Client/DefScript/DefScriptListFunctions.cpp +++ b/src/Client/DefScript/DefScriptListFunctions.cpp @@ -1,296 +1,296 @@ -#include -#include -#include -#include -#include "DefScript.h" - -using namespace DefScriptTools; - -DefReturnResult DefScriptPackage::func_lpushback(CmdSet& Set) -{ - DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname)); - l->push_back(Set.defaultarg); - return true; -} - -DefReturnResult DefScriptPackage::func_lpushfront(CmdSet& Set) -{ - DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname)); - l->push_front(Set.defaultarg); - return true; -} - -DefReturnResult DefScriptPackage::func_lpopback(CmdSet& Set) -{ - std::string r; - DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if( (!l) || (!l->size()) ) // cant pop any element if the list doesnt exist or is empty - return ""; - r= l->back(); - l->pop_back(); - return r; -} - -DefReturnResult DefScriptPackage::func_lpopfront(CmdSet& Set) -{ - std::string r; - DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if( (!l) || (!l->size()) ) // cant pop any element if the list doesnt exist or is empty - return ""; - r = l->front(); - l->pop_front(); - return r; -} - -// delete a list and all its elements -DefReturnResult DefScriptPackage::func_ldelete(CmdSet& Set) -{ - std::string lname = _NormalizeVarName(Set.defaultarg,Set.myname); - if(strncmp(lname.c_str(), SCRIPT_NAMESPACE,strlen(SCRIPT_NAMESPACE))==0) - { - printf("DefScript: WARNING: ldelete used on a script list, clearing instead! (called by '%s', list '%s')\n",Set.myname.c_str(), lname.c_str()); - DefList *l = lists.GetNoCreate(lname); - if(l) - l->clear(); - return true; - } - lists.Delete(lname); - return true; -} - -// returns true if a list with the given name exists, else false -DefReturnResult DefScriptPackage::func_lexists(CmdSet& Set) -{ - return lists.Exists(_NormalizeVarName(Set.defaultarg,Set.myname)); -} - -// return list element count -DefReturnResult DefScriptPackage::func_llen(CmdSet& Set) -{ - DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if(!l) - return ""; // return nothing if list doesnt exist - return toString((uint64)l->size()); // return any number -} - -// insert item at some position in the list -DefReturnResult DefScriptPackage::func_linsert(CmdSet& Set) -{ - bool result; - DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname)); - unsigned int pos = (unsigned int)toNumber(Set.arg[1]); - if(pos > l->size()) // if the list is too short to insert at that pos... - { - l->push_back(Set.defaultarg); // ... just append at the end - result = false; - } - else - { - DefList::iterator it = l->begin(); - advance(it,pos); - l->insert(it,Set.defaultarg); // ... else insert at correct position - result = true; - } - return result; -} - -// returns the amount of string fragments added to the list -// arg0: list name; arg1: delimiter string; defaultarg: string to split -DefReturnResult DefScriptPackage::func_lsplit(CmdSet& Set) -{ - // 1st create a new list, or get an already existing one and clear it - DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname)); - l->clear(); - if(Set.defaultarg.empty()) // we cant split an empty string, return nothing, and keep empty list - return ""; - - // special case: empty delimiter -> split in chars - if(Set.arg[1].empty()) - { - for(unsigned int i=0; ipush_back(tmp); - } - return toString((uint64)l->size()); - } - - unsigned int p,q=0; // p=position of substr; q=next pos to start searching at - while( (p = Set.defaultarg.find(Set.arg[1].c_str(),q)) != std::string::npos) - { - l->push_back( Set.defaultarg.substr(q,p - q) ); - q = p + Set.arg[1].length(); - } - if(q < Set.defaultarg.length()) // also append the last string fragment (that has no delimiter) - { - l->push_back(Set.defaultarg.c_str() + q); - } - return toString((uint64)l->size()); -} - -// multi-split by chars -// returns the amount of string fragments added to the list -// arg0: list name; args: delimit; defaultarg: string to split -DefReturnResult DefScriptPackage::func_lcsplit(CmdSet& Set) -{ - // 1st create a new list, or get an already existing one and clear it - DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname)); - l->clear(); - if(Set.defaultarg.empty()) // we cant split an empty string, return nothing, and keep empty list - return ""; - - unsigned int p,q=0; // p=position of substr; q=next pos to start searching at - while( (p = Set.defaultarg.find_first_of(Set.arg[1].c_str(),q)) != std::string::npos) - { - l->push_back( Set.defaultarg.substr(q,p - q) ); - q = p + 1; - } - if(q < Set.defaultarg.length()) // also append the last string fragment (that has no delimiter) - { - l->push_back(Set.defaultarg.c_str() + q); - } - return toString((uint64)l->size()); -} - -// create a string from a list, using as delimiter -DefReturnResult DefScriptPackage::func_ljoin(CmdSet& Set) -{ - std::string r; - DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if(!l) - return ""; - for(unsigned int i = 0; i < l->size(); i++) - { - r += (*l)[i]; - if( i+1 != l->size() ) - r += Set.defaultarg; - } - return r; -} - -// return list item at position xx -DefReturnResult DefScriptPackage::func_lindex(CmdSet& Set) -{ - DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if(!l) - return ""; - unsigned int pos = (unsigned int)toNumber(Set.defaultarg); - if(pos+1 > l->size()) // ot of bounds? - return ""; - return (*l)[pos]; -} - -// clean list: remove every element that matches @def -// use _only_ this function to remove empty strings from a list -DefReturnResult DefScriptPackage::func_lclean(CmdSet& Set) -{ - unsigned int r=0; - DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if(!l) - return ""; - for(DefList::iterator i=l->begin(); i!=l->end(); ) - { - if(*i == Set.defaultarg) - { - i = l->erase(i); - r++; - continue; - } - i++; - } - return toString((uint64)r); -} - -// multi-clean list: remove every element that matches any of the args, if it isn't empty -// NOTE: arg0 = list name, this one is skipped! -// this func does NOT remove empty strings from a list, use lclean instead!! -DefReturnResult DefScriptPackage::func_lmclean(CmdSet& Set) -{ - unsigned int r=0; - DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if(!l) - return ""; - - _CmdSetArgMap::iterator it=Set.arg.begin(); - advance(it,1); // skip list name - - for( ; it != Set.arg.end(); it++) - { - if(it->second.length()) - { - for(DefList::iterator i=l->begin(); i!=l->end(); i++) - { - if(*i == it->second) - { - l->erase(i); - r++; - if(i==l->end()) // must be checked here, else causing crash (?!) - break; - } - } - } - } - - // erase defaultarg if given - if(Set.defaultarg.length()) - { - for(DefList::iterator i=l->begin(); i!=l->end(); i++) - { - if(*i == Set.defaultarg) - { - l->erase(i); - r++; - } - } - } - return toString((uint64)r); -} - -// erase element at position @def, return erased element -DefReturnResult DefScriptPackage::func_lerase(CmdSet& Set) -{ - DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); - if(!l) - return ""; - std::string r; - unsigned int pos = (unsigned int)toNumber(Set.defaultarg); - if(pos > l->size()) // if the list is too short to erase at that pos... - return ""; // ... return nothing - - DefList::iterator it = l->begin(); - advance(it,pos); - r = *it; - l->erase(it); // ... else erase at correct position - - return r; -} - -DefReturnResult DefScriptPackage::func_lsort(CmdSet& Set) -{ - DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if(!l) - return false; - sort(l->begin(),l->end()); - return true; -} - - - - - - -//DefReturnResult DefScriptPackage::func_lmerge(CmdSet& Set) -//{ - -// to be continued... - - - - - - - - - - +#include +#include +#include +#include +#include "DefScript.h" + +using namespace DefScriptTools; + +DefReturnResult DefScriptPackage::func_lpushback(CmdSet& Set) +{ + DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname)); + l->push_back(Set.defaultarg); + return true; +} + +DefReturnResult DefScriptPackage::func_lpushfront(CmdSet& Set) +{ + DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname)); + l->push_front(Set.defaultarg); + return true; +} + +DefReturnResult DefScriptPackage::func_lpopback(CmdSet& Set) +{ + std::string r; + DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if( (!l) || (!l->size()) ) // cant pop any element if the list doesnt exist or is empty + return ""; + r= l->back(); + l->pop_back(); + return r; +} + +DefReturnResult DefScriptPackage::func_lpopfront(CmdSet& Set) +{ + std::string r; + DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if( (!l) || (!l->size()) ) // cant pop any element if the list doesnt exist or is empty + return ""; + r = l->front(); + l->pop_front(); + return r; +} + +// delete a list and all its elements +DefReturnResult DefScriptPackage::func_ldelete(CmdSet& Set) +{ + std::string lname = _NormalizeVarName(Set.defaultarg,Set.myname); + if(strncmp(lname.c_str(), SCRIPT_NAMESPACE,strlen(SCRIPT_NAMESPACE))==0) + { + printf("DefScript: WARNING: ldelete used on a script list, clearing instead! (called by '%s', list '%s')\n",Set.myname.c_str(), lname.c_str()); + DefList *l = lists.GetNoCreate(lname); + if(l) + l->clear(); + return true; + } + lists.Delete(lname); + return true; +} + +// returns true if a list with the given name exists, else false +DefReturnResult DefScriptPackage::func_lexists(CmdSet& Set) +{ + return lists.Exists(_NormalizeVarName(Set.defaultarg,Set.myname)); +} + +// return list element count +DefReturnResult DefScriptPackage::func_llen(CmdSet& Set) +{ + DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if(!l) + return ""; // return nothing if list doesnt exist + return toString((uint64)l->size()); // return any number +} + +// insert item at some position in the list +DefReturnResult DefScriptPackage::func_linsert(CmdSet& Set) +{ + bool result; + DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname)); + unsigned int pos = (unsigned int)toNumber(Set.arg[1]); + if(pos > l->size()) // if the list is too short to insert at that pos... + { + l->push_back(Set.defaultarg); // ... just append at the end + result = false; + } + else + { + DefList::iterator it = l->begin(); + advance(it,pos); + l->insert(it,Set.defaultarg); // ... else insert at correct position + result = true; + } + return result; +} + +// returns the amount of string fragments added to the list +// arg0: list name; arg1: delimiter string; defaultarg: string to split +DefReturnResult DefScriptPackage::func_lsplit(CmdSet& Set) +{ + // 1st create a new list, or get an already existing one and clear it + DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname)); + l->clear(); + if(Set.defaultarg.empty()) // we cant split an empty string, return nothing, and keep empty list + return ""; + + // special case: empty delimiter -> split in chars + if(Set.arg[1].empty()) + { + for(unsigned int i=0; ipush_back(tmp); + } + return toString((uint64)l->size()); + } + + unsigned int p,q=0; // p=position of substr; q=next pos to start searching at + while( (p = Set.defaultarg.find(Set.arg[1].c_str(),q)) != std::string::npos) + { + l->push_back( Set.defaultarg.substr(q,p - q) ); + q = p + Set.arg[1].length(); + } + if(q < Set.defaultarg.length()) // also append the last string fragment (that has no delimiter) + { + l->push_back(Set.defaultarg.c_str() + q); + } + return toString((uint64)l->size()); +} + +// multi-split by chars +// returns the amount of string fragments added to the list +// arg0: list name; args: delimit; defaultarg: string to split +DefReturnResult DefScriptPackage::func_lcsplit(CmdSet& Set) +{ + // 1st create a new list, or get an already existing one and clear it + DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname)); + l->clear(); + if(Set.defaultarg.empty()) // we cant split an empty string, return nothing, and keep empty list + return ""; + + unsigned int p,q=0; // p=position of substr; q=next pos to start searching at + while( (p = Set.defaultarg.find_first_of(Set.arg[1].c_str(),q)) != std::string::npos) + { + l->push_back( Set.defaultarg.substr(q,p - q) ); + q = p + 1; + } + if(q < Set.defaultarg.length()) // also append the last string fragment (that has no delimiter) + { + l->push_back(Set.defaultarg.c_str() + q); + } + return toString((uint64)l->size()); +} + +// create a string from a list, using as delimiter +DefReturnResult DefScriptPackage::func_ljoin(CmdSet& Set) +{ + std::string r; + DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if(!l) + return ""; + for(unsigned int i = 0; i < l->size(); i++) + { + r += (*l)[i]; + if( i+1 != l->size() ) + r += Set.defaultarg; + } + return r; +} + +// return list item at position xx +DefReturnResult DefScriptPackage::func_lindex(CmdSet& Set) +{ + DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if(!l) + return ""; + unsigned int pos = (unsigned int)toNumber(Set.defaultarg); + if(pos+1 > l->size()) // ot of bounds? + return ""; + return (*l)[pos]; +} + +// clean list: remove every element that matches @def +// use _only_ this function to remove empty strings from a list +DefReturnResult DefScriptPackage::func_lclean(CmdSet& Set) +{ + unsigned int r=0; + DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if(!l) + return ""; + for(DefList::iterator i=l->begin(); i!=l->end(); ) + { + if(*i == Set.defaultarg) + { + i = l->erase(i); + r++; + continue; + } + i++; + } + return toString((uint64)r); +} + +// multi-clean list: remove every element that matches any of the args, if it isn't empty +// NOTE: arg0 = list name, this one is skipped! +// this func does NOT remove empty strings from a list, use lclean instead!! +DefReturnResult DefScriptPackage::func_lmclean(CmdSet& Set) +{ + unsigned int r=0; + DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if(!l) + return ""; + + _CmdSetArgMap::iterator it=Set.arg.begin(); + advance(it,1); // skip list name + + for( ; it != Set.arg.end(); it++) + { + if(it->second.length()) + { + for(DefList::iterator i=l->begin(); i!=l->end(); i++) + { + if(*i == it->second) + { + l->erase(i); + r++; + if(i==l->end()) // must be checked here, else causing crash (?!) + break; + } + } + } + } + + // erase defaultarg if given + if(Set.defaultarg.length()) + { + for(DefList::iterator i=l->begin(); i!=l->end(); i++) + { + if(*i == Set.defaultarg) + { + l->erase(i); + r++; + } + } + } + return toString((uint64)r); +} + +// erase element at position @def, return erased element +DefReturnResult DefScriptPackage::func_lerase(CmdSet& Set) +{ + DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname)); + if(!l) + return ""; + std::string r; + unsigned int pos = (unsigned int)toNumber(Set.defaultarg); + if(pos > l->size()) // if the list is too short to erase at that pos... + return ""; // ... return nothing + + DefList::iterator it = l->begin(); + advance(it,pos); + r = *it; + l->erase(it); // ... else erase at correct position + + return r; +} + +DefReturnResult DefScriptPackage::func_lsort(CmdSet& Set) +{ + DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if(!l) + return false; + sort(l->begin(),l->end()); + return true; +} + + + + + + +//DefReturnResult DefScriptPackage::func_lmerge(CmdSet& Set) +//{ + +// to be continued... + + + + + + + + + + diff --git a/src/Client/DefScript/DefScriptTools.h b/src/Client/DefScript/DefScriptTools.h index 47603e3..8922fba 100644 --- a/src/Client/DefScript/DefScriptTools.h +++ b/src/Client/DefScript/DefScriptTools.h @@ -1,30 +1,30 @@ -#ifndef _DEFSCRIPTTOOLS_H -#define _DEFSCRIPTTOOLS_H - -#include - -namespace DefScriptTools -{ - std::string stringToUpper(std::string); - std::string stringToLower(std::string); - std::string toString(ldbl); - inline std::string toString(double num) { return toString(ldbl(num)); } - inline std::string toString(float num) { return toString(ldbl(num)); } - - template inline std::string toString(T num) - { - std::stringstream ss; - ss << num; - return ss.str(); - } - - ldbl toNumber(std::string&); - bool isTrue(std::string&); - uint64 toUint64(std::string&); - uint64 atoi64(std::string&); - inline long double Round(long double z,unsigned int n); -} - - - -#endif +#ifndef _DEFSCRIPTTOOLS_H +#define _DEFSCRIPTTOOLS_H + +#include + +namespace DefScriptTools +{ + std::string stringToUpper(std::string); + std::string stringToLower(std::string); + std::string toString(ldbl); + inline std::string toString(double num) { return toString(ldbl(num)); } + inline std::string toString(float num) { return toString(ldbl(num)); } + + template inline std::string toString(T num) + { + std::stringstream ss; + ss << num; + return ss.str(); + } + + ldbl toNumber(std::string&); + bool isTrue(std::string&); + uint64 toUint64(std::string&); + uint64 atoi64(std::string&); + inline long double Round(long double z,unsigned int n); +} + + + +#endif diff --git a/src/Client/DefScript/DynamicEvent.h b/src/Client/DefScript/DynamicEvent.h index 8df9c2f..40cc5fc 100644 --- a/src/Client/DefScript/DynamicEvent.h +++ b/src/Client/DefScript/DynamicEvent.h @@ -1,31 +1,31 @@ -#ifndef _DEF_DYNAMICEVENT_H -#define _DEF_DYNAMICEVENT_H - -#include -#include -#include - -#include "TypeStorage.h" - -struct DefScript_DynamicEvent; -class DefScript; -class DefScriptPackage; -typedef TypeStorage DefDynamicEventStorage; - -class DefScript_DynamicEventMgr -{ -public: - DefScript_DynamicEventMgr(DefScriptPackage *pack); - ~DefScript_DynamicEventMgr(); - void Add(std::string name, std::string script, clock_t interval, const char *parent, bool force = false); - void Remove(std::string name); - void Update(void); - -private: - DefDynamicEventStorage _storage; - clock_t _lastclock; - DefScriptPackage *_pack; - bool _events_changed; // this one helps to detect if a script called from an event has modified the event storage (risk of iterator invalidation!) -}; - -#endif +#ifndef _DEF_DYNAMICEVENT_H +#define _DEF_DYNAMICEVENT_H + +#include +#include +#include + +#include "TypeStorage.h" + +struct DefScript_DynamicEvent; +class DefScript; +class DefScriptPackage; +typedef TypeStorage DefDynamicEventStorage; + +class DefScript_DynamicEventMgr +{ +public: + DefScript_DynamicEventMgr(DefScriptPackage *pack); + ~DefScript_DynamicEventMgr(); + void Add(std::string name, std::string script, clock_t interval, const char *parent, bool force = false); + void Remove(std::string name); + void Update(void); + +private: + DefDynamicEventStorage _storage; + clock_t _lastclock; + DefScriptPackage *_pack; + bool _events_changed; // this one helps to detect if a script called from an event has modified the event storage (risk of iterator invalidation!) +}; + +#endif diff --git a/src/Client/DefScript/TypeStorage.h b/src/Client/DefScript/TypeStorage.h index d4e2d7a..691b523 100644 --- a/src/Client/DefScript/TypeStorage.h +++ b/src/Client/DefScript/TypeStorage.h @@ -1,148 +1,148 @@ -#ifndef DEFSCRIPT_TYPESTORAGE_H -#define DEFSCRIPT_TYPESTORAGE_H - -#include -#include - -template class TypeStorage -{ -public: - typedef typename std::map _TypeMap; - typedef typename _TypeMap::iterator _TypeIter; - TypeStorage() { _keep = false; } - ~TypeStorage(); - bool Exists(std::string); - void Delete(std::string); - void DeleteByPtr(T*); - T *Get(std::string); - T *GetNoCreate(std::string); - void Assign(std::string,T*); - void Unlink(std::string); - void UnlinkByPtr(T*); - std::string GetNameByPtr(T*); - inline std::map &GetMap(void) { return _storage; } - inline void SetKeepOnDestruct(bool b = true) { _keep = true; } - inline unsigned int Size(void) { return _storage.size(); } - void Clear(bool keep = false); - -private: - T *_Create(std::string); - _TypeMap _storage; - bool _keep; -}; - -// check whether an object with this name is already present -template bool TypeStorage::Exists(std::string s) -{ - return _storage.find(s) != _storage.end(); -} - -// helper to create and assign a new object -template T *TypeStorage::_Create(std::string s) -{ - T *elem = new T; - _storage[s] = elem; - return elem; -} - -// delete object with that name, if present -template void TypeStorage::Delete(std::string s) -{ - _TypeIter it = _storage.find(s); - if(it != _storage.end()) - { - delete it->second; - _storage.erase(it); - } -} - -// delete object with that ptr, if present -template void TypeStorage::DeleteByPtr(T *ptr) -{ - for(_TypeIter it = _storage.begin(); it != _storage.end(); it++) - { - if(it->second == ptr) - { - delete it->second; - _storage.erase(it); - return; - } - } -} - -// return the the object with that name. return NULL if not found -template T *TypeStorage::GetNoCreate(std::string s) -{ - _TypeIter it = _storage.find(s); - if(it != _storage.end()) - return it->second; - return NULL; -} - -// return the the object with that name. create and return new object if not found -template T *TypeStorage::Get(std::string s) -{ - T *elem = GetNoCreate(s); - return elem ? elem : _Create(s); -} - -// when destroying the TypeStorage, delete all stored objects -template TypeStorage::~TypeStorage() -{ - Clear(_keep); -} - -template void TypeStorage::Clear(bool keep) -{ - if(keep) - { - _storage.clear(); - return; - } - for(_TypeIter it = _storage.begin(); it != _storage.end();) - { - delete it->second; - _storage.erase(it++); - } -} - -// stores an already existing object's pointer under a specific name; deletes and overwrites old of present -template void TypeStorage::Assign(std::string s,T *elem) -{ - if(Exists(s)) - Delete(s); - _storage[s] = elem; -} - -// removes the pointer from the storage without deleting it -template void TypeStorage::Unlink(std::string s) -{ - _storage.erase(s); -} - -// removes the pointer from the storage without deleting it, if name is unknown -template void TypeStorage::UnlinkByPtr(T *ptr) -{ - for(_TypeIter it = _storage.begin(); it != _storage.end();) - { - if(it->second == ptr) - { - Unlink(it->first); - return; - } - } -} - -template std::string TypeStorage::GetNameByPtr(T *ptr) -{ - for(_TypeIter it = _storage.begin(); it != _storage.end();) - { - if(it->second == ptr) - { - return it->first; - } - } - return ""; -} - -#endif +#ifndef DEFSCRIPT_TYPESTORAGE_H +#define DEFSCRIPT_TYPESTORAGE_H + +#include +#include + +template class TypeStorage +{ +public: + typedef typename std::map _TypeMap; + typedef typename _TypeMap::iterator _TypeIter; + TypeStorage() { _keep = false; } + ~TypeStorage(); + bool Exists(std::string); + void Delete(std::string); + void DeleteByPtr(T*); + T *Get(std::string); + T *GetNoCreate(std::string); + void Assign(std::string,T*); + void Unlink(std::string); + void UnlinkByPtr(T*); + std::string GetNameByPtr(T*); + inline std::map &GetMap(void) { return _storage; } + inline void SetKeepOnDestruct(bool b = true) { _keep = true; } + inline unsigned int Size(void) { return _storage.size(); } + void Clear(bool keep = false); + +private: + T *_Create(std::string); + _TypeMap _storage; + bool _keep; +}; + +// check whether an object with this name is already present +template bool TypeStorage::Exists(std::string s) +{ + return _storage.find(s) != _storage.end(); +} + +// helper to create and assign a new object +template T *TypeStorage::_Create(std::string s) +{ + T *elem = new T; + _storage[s] = elem; + return elem; +} + +// delete object with that name, if present +template void TypeStorage::Delete(std::string s) +{ + _TypeIter it = _storage.find(s); + if(it != _storage.end()) + { + delete it->second; + _storage.erase(it); + } +} + +// delete object with that ptr, if present +template void TypeStorage::DeleteByPtr(T *ptr) +{ + for(_TypeIter it = _storage.begin(); it != _storage.end(); it++) + { + if(it->second == ptr) + { + delete it->second; + _storage.erase(it); + return; + } + } +} + +// return the the object with that name. return NULL if not found +template T *TypeStorage::GetNoCreate(std::string s) +{ + _TypeIter it = _storage.find(s); + if(it != _storage.end()) + return it->second; + return NULL; +} + +// return the the object with that name. create and return new object if not found +template T *TypeStorage::Get(std::string s) +{ + T *elem = GetNoCreate(s); + return elem ? elem : _Create(s); +} + +// when destroying the TypeStorage, delete all stored objects +template TypeStorage::~TypeStorage() +{ + Clear(_keep); +} + +template void TypeStorage::Clear(bool keep) +{ + if(keep) + { + _storage.clear(); + return; + } + for(_TypeIter it = _storage.begin(); it != _storage.end();) + { + delete it->second; + _storage.erase(it++); + } +} + +// stores an already existing object's pointer under a specific name; deletes and overwrites old of present +template void TypeStorage::Assign(std::string s,T *elem) +{ + if(Exists(s)) + Delete(s); + _storage[s] = elem; +} + +// removes the pointer from the storage without deleting it +template void TypeStorage::Unlink(std::string s) +{ + _storage.erase(s); +} + +// removes the pointer from the storage without deleting it, if name is unknown +template void TypeStorage::UnlinkByPtr(T *ptr) +{ + for(_TypeIter it = _storage.begin(); it != _storage.end();) + { + if(it->second == ptr) + { + Unlink(it->first); + return; + } + } +} + +template std::string TypeStorage::GetNameByPtr(T *ptr) +{ + for(_TypeIter it = _storage.begin(); it != _storage.end();) + { + if(it->second == ptr) + { + return it->first; + } + } + return ""; +} + +#endif diff --git a/src/Client/DefScriptInterface.cpp b/src/Client/DefScriptInterface.cpp index 5b71037..68309f6 100644 --- a/src/Client/DefScriptInterface.cpp +++ b/src/Client/DefScriptInterface.cpp @@ -1,1241 +1,1241 @@ - -#include "common.h" -#include "PseuWoW.h" -#include "DefScript/DefScript.h" -#include "DefScript/DefScriptTools.h" -#include "Player.h" -#include "Opcodes.h" -#include "SharedDefines.h" -#include "WorldSession.h" -#include "Channel.h" -#include "CacheHandler.h" -#include "SCPDatabase.h" - - -void DefScriptPackage::_InitDefScriptInterface(void) -{ - AddFunc("pause",&DefScriptPackage::SCpause); - AddFunc("emote",&DefScriptPackage::SCemote); - AddFunc("follow",&DefScriptPackage::SCfollow); - AddFunc("savecache",&DefScriptPackage::SCsavecache); - AddFunc("sendchatmessage",&DefScriptPackage::SCSendChatMessage); - AddFunc("joinchannel",&DefScriptPackage::SCjoinchannel); - AddFunc("leavechannel",&DefScriptPackage::SCleavechannel); - AddFunc("listchannel",&DefScriptPackage::SClistchannel); - AddFunc("loadconf",&DefScriptPackage::SCloadconf); - AddFunc("applyconf",&DefScriptPackage::SCapplyconf); - AddFunc("applypermissions",&DefScriptPackage::SCapplypermissions); - AddFunc("log",&DefScriptPackage::SClog); - AddFunc("logdetail",&DefScriptPackage::SClogdetail); - AddFunc("logerror",&DefScriptPackage::SClogerror); - AddFunc("logdebug",&DefScriptPackage::SClogdebug); - AddFunc("castspell",&DefScriptPackage::SCcastspell); - AddFunc("queryitem",&DefScriptPackage::SCqueryitem); - AddFunc("target",&DefScriptPackage::SCtarget); - AddFunc("loadscp",&DefScriptPackage::SCloadscp); - AddFunc("scpexists",&DefScriptPackage::SCScpExists); - AddFunc("scpsectionexists",&DefScriptPackage::SCScpSectionExists); - AddFunc("scpentryexists",&DefScriptPackage::SCScpEntryExists); - AddFunc("getscpvalue",&DefScriptPackage::SCGetScpValue); - AddFunc("getplayerguid",&DefScriptPackage::SCGetPlayerGuid); - AddFunc("getname",&DefScriptPackage::SCGetName); - AddFunc("getentry",&DefScriptPackage::SCGetEntry); - AddFunc("getitemprotovalue",&DefScriptPackage::SCGetItemProtoValue); - AddFunc("getobjecttype",&DefScriptPackage::SCGetObjectType); - AddFunc("objectknown",&DefScriptPackage::SCObjectKnown); - AddFunc("getplayerperm",&DefScriptPackage::SCGetPlayerPerm); - AddFunc("getscriptperm",&DefScriptPackage::SCGetScriptPerm); - AddFunc("lgetfiles",&DefScriptPackage::SCGetFileList); - AddFunc("printscript",&DefScriptPackage::SCPrintScript); - AddFunc("getobjectvalue",&DefScriptPackage::SCGetObjectValue); - AddFunc("getrace",&DefScriptPackage::SCGetRace); - AddFunc("getclass",&DefScriptPackage::SCGetClass); - AddFunc("sendworldpacket",&DefScriptPackage::SCSendWorldPacket); - AddFunc("getopcodename",&DefScriptPackage::SCGetOpcodeName); - AddFunc("getopcodeid",&DefScriptPackage::SCGetOpcodeID); - AddFunc("bbgetpackedguid",&DefScriptPackage::SCBBGetPackedGuid); - AddFunc("bbputpackedguid",&DefScriptPackage::SCBBPutPackedGuid); - AddFunc("gui",&DefScriptPackage::SCGui); - AddFunc("sendwho",&DefScriptPackage::SCSendWho); - AddFunc("getobjectdist",&DefScriptPackage::SCGetObjectDistance); - AddFunc("switchopcodehandler",&DefScriptPackage::SCSwitchOpcodeHandler); - AddFunc("opcodedisabled",&DefScriptPackage::SCOpcodeDisabled); - AddFunc("spoofworldpacket",&DefScriptPackage::SCSpoofWorldPacket); -} - -DefReturnResult DefScriptPackage::SCshdn(CmdSet& Set) -{ - ((PseuInstance*)parentMethod)->Stop(); - return true; -} - -DefReturnResult DefScriptPackage::SCpause(CmdSet& Set){ - ((PseuInstance*)parentMethod)->Sleep(atoi(Set.defaultarg.c_str())); - return true; -} - -DefReturnResult DefScriptPackage::SCSendChatMessage(CmdSet& Set){ - if(!(((PseuInstance*)parentMethod)->GetWSession())) - { - logerror("Invalid Script call: SCSendChatMessage: WorldSession not valid"); - DEF_RETURN_ERROR; - } - std::stringstream ss; - uint32 type=atoi(Set.arg[0].c_str()); - uint32 lang=atoi(Set.arg[1].c_str()); - - ss << lang; - if(ss.str()!=Set.arg[1]) // given lang is NOT a number - { - uint32 dblang; - dblang = ((PseuInstance*)parentMethod)->dbmgr.GetDB("language").GetFieldByValue("name",Set.arg[1]); - logdev("looking up language id for lang '%s', found %i",Set.arg[1].c_str(),dblang); - if(dblang != -1) - lang = dblang; - } - - std::string msg=Set.arg[2]; - std::string to=Set.arg[3]; - ((PseuInstance*)parentMethod)->GetWSession()->SendChatMessage(type,lang,msg,to); - return true; -} - -DefReturnResult DefScriptPackage::SCsavecache(CmdSet& Set){ - ((PseuInstance*)parentMethod)->SaveAllCache(); - if(DefScriptTools::isTrue(Set.defaultarg)) - { - std::stringstream str; - if(((PseuInstance*)parentMethod)->GetWSession()) - { - str << "Cache saved. [ "; - str << ((PseuInstance*)parentMethod)->GetWSession()->plrNameCache.GetSize(); - str << " Playernames, "; - str << ((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetItemProtoCount(); - str << " Item Prototypes, "; - str << ((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetCreatureTemplateCount(); - str << " Creature Templates"; - str << " ]"; - - ((PseuInstance*)parentMethod)->GetWSession()->SendChatMessage(CHAT_MSG_SAY,0,str.str(),""); - } - } - return true; -} - -DefReturnResult DefScriptPackage::SCemote(CmdSet& Set){ - if(Set.defaultarg.empty()) - return false; - if(!(((PseuInstance*)parentMethod)->GetWSession())) - { - logerror("Invalid Script call: SCEmote: WorldSession not valid"); - DEF_RETURN_ERROR; - } - - // check if the given name exists in the database, if it does, use its record id; if not, convert emote name into a number. - // this supports calls like "emote 126" and "emote ready" - uint32 id = uint32(-1); - SCPDatabaseMgr& dbmgr = ((PseuInstance*)parentMethod)->dbmgr; - if(dbmgr.HasDB("emote")) - { - SCPDatabase& db = dbmgr.GetDB("emote"); - id = db.GetFieldByValue("name",DefScriptTools::stringToUpper(Set.defaultarg)); // emote names are always uppercased - } - if(id == uint32(-1)) - { - id=atoi(Set.defaultarg.c_str()); - if(!id) - { - logerror("SCEmote: Invalid emote!"); - return true; - } - } - ((PseuInstance*)parentMethod)->GetWSession()->SendEmote(id); - return true; -} - - -DefReturnResult DefScriptPackage::SCfollow(CmdSet& Set) -{ - DEF_RETURN_ERROR; // prevent execution for now - /* - WorldSession *ws=((PseuInstance*)parentMethod)->GetWSession(); - if(Set.defaultarg.empty()){ - ws->SendChatMessage(CHAT_MSG_SAY,0,"Stopping! (Please give me a Playername to follow!)",""); - ws->SetFollowTarget(0); - return true; - } - ws->SetFollowTarget(ws->plrNameCache.GetGuid(Set.defaultarg)); - std::stringstream ss; - if(ws->GetFollowTarget()) - ss << "Following player '"<SendChatMessage(CHAT_MSG_SAY,0,ss.str(),""); - */ - return true; - -} - -DefReturnResult DefScriptPackage::SCjoinchannel(CmdSet& Set){ - if(Set.defaultarg.empty()) - return false; - if(!(((PseuInstance*)parentMethod)->GetWSession())) - { - logerror("Invalid Script call: SCjoinchannel: WorldSession not valid"); - DEF_RETURN_ERROR; - } - ((PseuInstance*)parentMethod)->GetWSession()->GetChannels()->Join(Set.defaultarg,Set.arg[0]); - return true; -} - -DefReturnResult DefScriptPackage::SClistchannel(CmdSet& Set){ - if(Set.defaultarg.empty()) - return false; - if(!(((PseuInstance*)parentMethod)->GetWSession())) - { - logerror("Invalid Script call: SClistchannel: WorldSession not valid"); - DEF_RETURN_ERROR; - } - ((PseuInstance*)parentMethod)->GetWSession()->GetChannels()->RequestList(Set.defaultarg); - return true; -} - -DefReturnResult DefScriptPackage::SCleavechannel(CmdSet& Set){ - if(Set.defaultarg.empty()) - return false; - if(!(((PseuInstance*)parentMethod)->GetWSession())) - { - logerror("Invalid Script call: SCleavechannel: WorldSession not valid"); - DEF_RETURN_ERROR; - } - ((PseuInstance*)parentMethod)->GetWSession()->GetChannels()->Leave(Set.defaultarg); - return true; -} - -DefReturnResult DefScriptPackage::SCloadconf(CmdSet& Set){ - if(Set.defaultarg.empty()) - return false; - std::string fn; - if(Set.defaultarg.find('/')==std::string::npos && Set.defaultarg.find('\\')==std::string::npos) - fn += ((PseuInstance*)parentMethod)->GetConfDir(); - fn += Set.defaultarg; - - if(variables.ReadVarsFromFile(fn)) - { - logdev("Loaded conf file [%s]",fn.c_str()); - return true; - } - - log("Error loading conf file [%s]",fn.c_str()); - return false; -} - -DefReturnResult DefScriptPackage::SCapplypermissions(CmdSet& Set){ - this->My_LoadUserPermissions(variables); - return true; -} - -DefReturnResult DefScriptPackage::SCapplyconf(CmdSet& Set){ - ((PseuInstance*)parentMethod)->GetConf()->ApplyFromVarSet(variables); - return true; -} - -DefReturnResult DefScriptPackage::SClog(CmdSet& Set){ - log(Set.defaultarg.c_str()); - return true; -} - -DefReturnResult DefScriptPackage::SClogdetail(CmdSet& Set){ - logdetail(Set.defaultarg.c_str()); - return true; -} - -DefReturnResult DefScriptPackage::SClogdebug(CmdSet& Set){ - logdebug(Set.defaultarg.c_str()); - return true; -} - -DefReturnResult DefScriptPackage::SClogerror(CmdSet& Set){ - logerror(Set.defaultarg.c_str()); - return true; -} - -DefReturnResult DefScriptPackage::SCcastspell(CmdSet& Set) -{ - if(Set.defaultarg.empty()) - return false; - if(!(((PseuInstance*)parentMethod)->GetWSession())) - { - logerror("Invalid Script call: SCcastspell: WorldSession not valid"); - DEF_RETURN_ERROR; - } - - uint32 spellId = atoi(Set.defaultarg.c_str()); - - if (spellId <= 0) - { - return false; - } - - ((PseuInstance*)parentMethod)->GetWSession()->SendCastSpell(spellId); - return true; -} - -DefReturnResult DefScriptPackage::SCqueryitem(CmdSet& Set) -{ - if(!(((PseuInstance*)parentMethod)->GetWSession())) - { - logerror("Invalid Script call: SCqueryitem: WorldSession not valid"); - DEF_RETURN_ERROR; - } - - uint32 id = atoi(Set.defaultarg.c_str()); - if(!id) - return false; - - ((PseuInstance*)parentMethod)->GetWSession()->SendQueryItem(id,0); - return true; -} - -DefReturnResult DefScriptPackage::SCtarget(CmdSet& Set) -{ - // TODO: special targets: _self _pet _nearest ... - WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); - if(!ws) - { - logerror("Invalid Script call: SCtarget: WorldSession not valid"); - DEF_RETURN_ERROR; - } - - if(Set.defaultarg.empty()) - { - ((PseuInstance*)parentMethod)->GetWSession()->SendSetSelection(0); // no target - return true; - } - - std::string what = stringToLower(Set.arg[0]); - uint64 guid = 0; - if(what == "guid") - { - guid = DefScriptTools::toUint64(Set.defaultarg); - } - else if(what.empty() || what == "player") - { - // TODO: search through all objects. for now only allow to target player - guid = ws->plrNameCache.GetGuid(Set.defaultarg); - } - - Object *obj = ws->objmgr.GetObj(guid); - if(obj && (obj->IsUnit() || obj->IsCorpse())) // only units and corpses are targetable - { - ws->SendSetSelection(guid); // will also set the target for myCharacter - return DefScriptTools::toString(guid); - } - else - { - logdetail("Target '%s' not found!",Set.defaultarg.c_str()); - return false; - } - return ""; -} - -DefReturnResult DefScriptPackage::SCloadscp(CmdSet& Set) -{ - SCPDatabaseMgr& dbmgr = ((PseuInstance*)parentMethod)->dbmgr; - if(Set.defaultarg.empty()) // exit if no filename was given - return false; - std::string dbname = stringToLower(Set.arg[0]); - uint32 sections = 0; - if(dbname.empty()) // if no db name was supplied, try to find it automatically in the file ("#dbname=...") - { - sections = dbmgr.AutoLoadFile((char*)Set.defaultarg.c_str()); - if(!sections) - { - logerror("Tried to auto-load SCP file: \"%s\", but no name tag found. skipped."); - } - } - else - { - sections = dbmgr.GetDB(dbname).LoadFromFile((char*)Set.defaultarg.c_str()); - if(sections) - { - logdetail("Loaded SCP: \"%s\" [%s] (%u sections)",dbname.c_str(),Set.defaultarg.c_str(),sections); - } - else - { - logerror("Failed to load SCP: \"%s\" [%s]",dbname.c_str(),Set.defaultarg.c_str()); - } - } - return DefScriptTools::toString((uint64)sections);; -} - -DefReturnResult DefScriptPackage::SCScpExists(CmdSet& Set) -{ - return (!Set.defaultarg.empty()) && ((PseuInstance*)parentMethod)->dbmgr.HasDB(Set.defaultarg); -} - -DefReturnResult DefScriptPackage::SCScpSectionExists(CmdSet& Set) -{ - static std::string dbname; - if(!Set.arg[0].empty()) - dbname=Set.arg[0]; - return (!Set.defaultarg.empty()) && (!dbname.empty()) - && ((PseuInstance*)parentMethod)->dbmgr.HasDB(dbname) - && ((PseuInstance*)parentMethod)->dbmgr.GetDB(dbname).HasField((uint32)DefScriptTools::toUint64(Set.defaultarg)); -} - -DefReturnResult DefScriptPackage::SCScpEntryExists(CmdSet& Set) -{ - static std::string dbname; - static uint32 keyid; - if(!Set.arg[0].empty()) - dbname=Set.arg[0]; - if(!Set.arg[1].empty()) - keyid=(uint32)DefScriptTools::toUint64(Set.arg[1]); - return (!Set.defaultarg.empty()) && (!dbname.empty()) - && ((PseuInstance*)parentMethod)->dbmgr.HasDB(dbname) - && ((PseuInstance*)parentMethod)->dbmgr.GetDB(dbname).HasField(keyid) - && ((PseuInstance*)parentMethod)->dbmgr.GetDB(dbname).GetField(keyid).HasEntry(Set.defaultarg); -} - - -// GetScpValue,db,key entry -// db & key will be stored, that multiple calls like GetScpValue entryxyz are possible -DefReturnResult DefScriptPackage::SCGetScpValue(CmdSet& Set) -{ - static std::string dbname; - static uint32 keyid; - std::string entry; - DefReturnResult r; - - if(!Set.arg[0].empty()) - dbname=Set.arg[0]; - if(!Set.arg[1].empty()) - keyid=(uint32)DefScriptTools::toUint64(Set.arg[1]); - if(!Set.defaultarg.empty()) - entry=Set.defaultarg; - if( (!entry.empty()) && (!dbname.empty()) - && ((PseuInstance*)parentMethod)->dbmgr.HasDB(dbname) - && ((PseuInstance*)parentMethod)->dbmgr.GetDB(dbname).HasField(keyid) - && ((PseuInstance*)parentMethod)->dbmgr.GetDB(dbname).GetField(keyid).HasEntry(entry)) - { - r.ret = ((PseuInstance*)parentMethod)->dbmgr.GetDB(dbname).GetField(keyid).GetString(entry); - } - else - { - r.ret = ""; - } - return r; -} - -DefReturnResult DefScriptPackage::SCGetPlayerGuid(CmdSet& Set) -{ - if(!(((PseuInstance*)parentMethod)->GetWSession())) - { - logerror("Invalid Script call: SCGetPlayerGuid: WorldSession not valid"); - DEF_RETURN_ERROR; - } - DefReturnResult r; - if(Set.defaultarg.empty()) - { - r.ret="0"; - } - else - { - uint64 guid=((PseuInstance*)parentMethod)->GetWSession()->plrNameCache.GetGuid(Set.defaultarg); - r.ret=DefScriptTools::toString(guid); - } - return r; -} - -DefReturnResult DefScriptPackage::SCGetName(CmdSet& Set) -{ - WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); - if(!ws) - { - logerror("Invalid Script call: SCGetName: WorldSession not valid"); - DEF_RETURN_ERROR; - } - uint64 id = DefScriptTools::toUint64(Set.defaultarg); - std::string source = DefScriptTools::stringToLower(Set.arg[0]); - - // "guid" type can be everything - item, player, unit, gameobject... whatever has this guid. - if(source.empty() || source == "guid") - { - Object *o = ws->objmgr.GetObj(id); - std::string n; - if(o) - { - n = o->GetName(); - if(!n.empty()) - return n; - } - - if(!o || n.empty()) - { - // fallback if that guid is player guid, its maybe stored, so check that - if(IS_PLAYER_GUID(id)) - { - if(ws->plrNameCache.IsKnown(id)) - return ws->plrNameCache.GetName(id); - } - } - } - else if(source == "player") - { - if(ws->plrNameCache.IsKnown(id)) - return ws->plrNameCache.GetName(id); - else - return ""; - - } - else if(source == "item") - { - ItemProto *iproto = ws->objmgr.GetItemProto((uint32)id); - return iproto ? iproto->Name : ""; - } - else if(source == "unit") - { - CreatureTemplate *ct = ws->objmgr.GetCreatureTemplate((uint32)id); - return ct ? ct->name : ""; - } - // TODO: add gameobject, dynamicobject - - return ""; -} - -DefReturnResult DefScriptPackage::SCGetEntry(CmdSet& Set) -{ - if(!(((PseuInstance*)parentMethod)->GetWSession())) - { - logerror("Invalid Script call: SCGetEntry: WorldSession not valid"); - DEF_RETURN_ERROR; - } - DefReturnResult r; - uint64 guid=DefScriptTools::toUint64(Set.defaultarg); - r.ret="0"; - Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid); - if(o) - { - r.ret=DefScriptTools::toString((uint64)o->GetEntry()); - } - else - { - logerror("SCGetEntry: Object "I64FMT" not known",guid); - } - return r; -} - -DefReturnResult DefScriptPackage::SCGetObjectType(CmdSet& Set) -{ - if(!(((PseuInstance*)parentMethod)->GetWSession())) - { - logerror("Invalid Script call: SCGetObjectType: WorldSession not valid"); - DEF_RETURN_ERROR; - } - DefReturnResult r; - uint64 guid=DefScriptTools::toUint64(Set.defaultarg); - r.ret="0"; - Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid); - if(o) - { - r.ret=DefScriptTools::toString((uint64)o->GetTypeId()); - } - else - { - logerror("SCGetObjectType: Object "I64FMT" not known",guid); - } - return r; -} - -DefReturnResult DefScriptPackage::SCObjectKnown(CmdSet& Set) -{ - if(!(((PseuInstance*)parentMethod)->GetWSession())) - { - logerror("Invalid Script call: SCObjectIsKnown: WorldSession not valid"); - DEF_RETURN_ERROR; - } - uint64 guid=DefScriptTools::toUint64(Set.defaultarg); - Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid); - return o!=NULL; -} - -DefReturnResult DefScriptPackage::SCGetPlayerPerm(CmdSet& Set) -{ - DefReturnResult r; - uint8 perm=0; - for (std::map::iterator i = my_usrPermissionMap.begin(); i != my_usrPermissionMap.end(); i++) - if(i->first == Set.defaultarg) - perm = i->second; - r.ret = toString(perm); - return r; -} - -DefReturnResult DefScriptPackage::SCGetScriptPerm(CmdSet& Set) -{ - DefReturnResult r; - uint8 perm=0; - for (std::map::iterator i = scriptPermissionMap.begin(); i != scriptPermissionMap.end(); i++) - if(i->first == Set.defaultarg) - perm = i->second; - r.ret = toString(perm); - return r; -} - -DefReturnResult DefScriptPackage::SCGetItemProtoValue(CmdSet& Set) -{ - if(!(((PseuInstance*)parentMethod)->GetWSession())) - { - logerror("Invalid Script call: SCGetItemProtoValue: WorldSession not valid"); - DEF_RETURN_ERROR; - } - DefReturnResult r; - uint32 entry=DefScriptTools::toUint64(Set.arg[0]); - ItemProto *proto=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetItemProto(entry); - if(proto) - { - std::string t=stringToLower(Set.defaultarg); - uint32 tmp=0; - if(t=="class") r.ret=toString(proto->Class); - else if(t=="subclass") r.ret=toString(proto->SubClass); - else if(t=="name") r.ret=proto->Name; - else if(t=="model" || t=="displayid") r.ret=toString(proto->DisplayInfoID); - else if(t=="quality") r.ret=toString(proto->Quality); - else if(t=="flags") r.ret=toString(proto->Flags); - else if(t=="buycount") r.ret=toString(proto->BuyCount); - else if(t=="buyprice") r.ret=toString(proto->BuyPrice); - else if(t=="sellprice") r.ret=toString(proto->SellPrice); - else if(t=="inventorytype") r.ret=toString(proto->InventoryType); - else if(t=="allowableclass") r.ret=toString(proto->AllowableClass); - else if(t=="allowablerace") r.ret=toString(proto->AllowableRace); - else if(t=="itemlevel") r.ret=toString(proto->ItemLevel); - else if(t=="reqlevel") r.ret=toString(proto->RequiredLevel); - else if(t=="reqskill") r.ret=toString(proto->RequiredSkill); - else if(t=="reqskillrank") r.ret=toString(proto->RequiredSkillRank); - else if(t=="reqspell") r.ret=toString(proto->RequiredSpell); - else if(t=="reqhonorrank") r.ret=toString(proto->RequiredHonorRank); - else if(t=="reqcityrank") r.ret=toString(proto->RequiredCityRank); - else if(t=="reqrepfaction") r.ret=toString(proto->RequiredReputationFaction); - else if(t=="reqreprank") r.ret=toString(proto->RequiredReputationRank); - else if(t=="maxcount") r.ret=toString(proto->MaxCount); - else if(t=="stackable") r.ret=toString(proto->Stackable); - else if(t=="slots") r.ret=toString(proto->ContainerSlots); - else if(t=="str") - { - for(uint32 i=0;i<10;i++) - if(proto->ItemStat[i].ItemStatType==ITEM_STAT_STRENGTH) - tmp+=proto->ItemStat[i].ItemStatValue; - r.ret = toString((uint64)tmp); - } - else if(t=="agi") - { - for(uint32 i=0;i<10;i++) - if(proto->ItemStat[i].ItemStatType==ITEM_STAT_AGILITY) - tmp+=proto->ItemStat[i].ItemStatValue; - r.ret = toString((uint64)tmp); - } - else if(t=="sta") - { - for(uint32 i=0;i<10;i++) - if(proto->ItemStat[i].ItemStatType==ITEM_STAT_STAMINA) - tmp+=proto->ItemStat[i].ItemStatValue; - r.ret = toString((uint64)tmp); - } - else if(t=="int") - { - for(uint32 i=0;i<10;i++) - if(proto->ItemStat[i].ItemStatType==ITEM_STAT_INTELLECT) - tmp+=proto->ItemStat[i].ItemStatValue; - r.ret = toString((uint64)tmp); - } - else if(t=="spi") - { - for(uint32 i=0;i<10;i++) - if(proto->ItemStat[i].ItemStatType==ITEM_STAT_SPIRIT) - tmp+=proto->ItemStat[i].ItemStatValue; - r.ret = toString((uint64)tmp); - } - else if(t=="hp" || t=="health") - { - for(uint32 i=0;i<10;i++) - if(proto->ItemStat[i].ItemStatType==ITEM_STAT_HEALTH) - tmp+=proto->ItemStat[i].ItemStatValue; - r.ret = toString((uint64)tmp); - } - else if(t=="mindmg") - { - for(uint32 i=0;i<5;i++) - if(proto->Damage[i].DamageType==NORMAL_DAMAGE) - tmp+=proto->Damage[i].DamageMin; - r.ret = toString((uint64)tmp); - } - else if(t=="maxdmg") - { - for(uint32 i=0;i<5;i++) - if(proto->Damage[i].DamageType==NORMAL_DAMAGE) - tmp+=proto->Damage[i].DamageMax; - r.ret = toString((uint64)tmp); - } - else if(t=="mindmg_holy") - { - for(uint32 i=0;i<5;i++) - if(proto->Damage[i].DamageType==HOLY_DAMAGE) - tmp+=proto->Damage[i].DamageMin; - r.ret = toString((uint64)tmp); - } - else if(t=="maxdmg_holy") - { - for(uint32 i=0;i<5;i++) - if(proto->Damage[i].DamageType==HOLY_DAMAGE) - tmp+=proto->Damage[i].DamageMax; - r.ret = toString((uint64)tmp); - } - else if(t=="mindmg_fire") - { - for(uint32 i=0;i<5;i++) - if(proto->Damage[i].DamageType==FIRE_DAMAGE) - tmp+=proto->Damage[i].DamageMin; - r.ret = toString((uint64)tmp); - } - else if(t=="maxdmg_fire") - { - for(uint32 i=0;i<5;i++) - if(proto->Damage[i].DamageType==FIRE_DAMAGE) - tmp+=proto->Damage[i].DamageMax; - r.ret = toString((uint64)tmp); - } - else if(t=="mindmg_nature") - { - for(uint32 i=0;i<5;i++) - if(proto->Damage[i].DamageType==NATURE_DAMAGE) - tmp+=proto->Damage[i].DamageMin; - r.ret = toString((uint64)tmp); - } - else if(t=="maxdmg_nature") - { - for(uint32 i=0;i<5;i++) - if(proto->Damage[i].DamageType==NATURE_DAMAGE) - tmp+=proto->Damage[i].DamageMax; - r.ret = toString((uint64)tmp); - } - else if(t=="mindmg_frost") - { - for(uint32 i=0;i<5;i++) - if(proto->Damage[i].DamageType==FROST_DAMAGE) - tmp+=proto->Damage[i].DamageMin; - r.ret = toString((uint64)tmp); - } - else if(t=="maxdmg_frost") - { - for(uint32 i=0;i<5;i++) - if(proto->Damage[i].DamageType==FROST_DAMAGE) - tmp+=proto->Damage[i].DamageMax; - r.ret = toString((uint64)tmp); - } - else if(t=="mindmg_shadow") - { - for(uint32 i=0;i<5;i++) - if(proto->Damage[i].DamageType==SHADOW_DAMAGE) - tmp+=proto->Damage[i].DamageMin; - r.ret = toString((uint64)tmp); - } - else if(t=="maxdmg_shadow") - { - for(uint32 i=0;i<5;i++) - if(proto->Damage[i].DamageType==SHADOW_DAMAGE) - tmp+=proto->Damage[i].DamageMax; - r.ret = toString((uint64)tmp); - } - else if(t=="mindmg_arcane") - { - for(uint32 i=0;i<5;i++) - if(proto->Damage[i].DamageType==ARCANE_DAMAGE) - tmp+=proto->Damage[i].DamageMin; - r.ret = toString((uint64)tmp); - } - else if(t=="maxdmg_arcane") - { - for(uint32 i=0;i<5;i++) - if(proto->Damage[i].DamageType==ARCANE_DAMAGE) - tmp+=proto->Damage[i].DamageMax; - r.ret = toString((uint64)tmp); - } - else if(t=="armor") r.ret=toString(proto->Armor); - else if(t=="holyres") r.ret=toString(proto->HolyRes); - else if(t=="fireres") r.ret=toString(proto->FireRes); - else if(t=="natureres") r.ret=toString(proto->NatureRes); - else if(t=="frostres") r.ret=toString(proto->FrostRes); - else if(t=="shadowres") r.ret=toString(proto->ShadowRes); - else if(t=="arcaneres") r.ret=toString(proto->ArcaneRes); - else if(t=="delay") r.ret=toString(proto->Delay); - else if(t=="ammotype") r.ret=toString(proto->Ammo_type); - else if(t=="range") r.ret=toString(proto->RangedModRange); - else if(t=="bonding") r.ret=toString(proto->Bonding); - else if(t=="desc") r.ret=proto->Description; - else if(t=="pagetext") r.ret=toString(proto->PageText); - else if(t=="languageid") r.ret=toString(proto->LanguageID); - else if(t=="pagematerial") r.ret=toString(proto->PageMaterial); - else if(t=="startquest") r.ret=toString(proto->StartQuest); - else if(t=="lockid") r.ret=toString(proto->LockID); - else if(t=="material") r.ret=toString(proto->Material); - else if(t=="sheath") r.ret=toString(proto->Sheath); - else if(t=="extra") r.ret=toString(proto->Extra); - else if(t=="block") r.ret=toString(proto->Block); - else if(t=="itemset") r.ret=toString(proto->ItemSet); - else if(t=="maxdur") r.ret=toString(proto->MaxDurability); - else if(t=="area") r.ret=toString(proto->Area); - else if(t=="bagfamily") r.ret=toString(proto->BagFamily); - // TODO: add item spells - else - { - logerror("SCGetItemProtoValue: Unknown property \"%s\" for Item Prototype %u",t.c_str(),entry); - } - } - else - { - logerror("SCGetItemProtoValue: Item Prototype %u not known",entry); - } - return r; -} - -DefReturnResult DefScriptPackage::SCGetFileList(CmdSet& Set) -{ - DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname)); - l->clear(); - *l = (DefList)GetFileList(Set.defaultarg); - if(Set.arg[1].length()) - { - std::string ext = "."; - ext += Set.arg[1]; - ext = stringToLower(ext); - for(DefList::iterator i = l->begin(); i != l->end(); ) - { - std::string tmp = stringToLower(i->c_str() + (i->length() - ext.length())); - if( tmp != ext ) - { - i = l->erase(i); - continue; - } - i++; - } - } - return toString((uint64)l->size()); -} - -DefReturnResult DefScriptPackage::SCPrintScript(CmdSet &Set) -{ - DefScript *sc = GetScript(DefScriptTools::stringToLower(Set.defaultarg)); - if(sc) - { - logcustom(0,GREEN,"== DefScript \"%s\", %u lines: ==",sc->GetName().c_str(),sc->GetLines()); - for(uint32 i = 0; i < sc->GetLines(); i++) - { - logcustom(0,GREEN,sc->GetLine(i).c_str()); - } - } - return ""; -} - -DefReturnResult DefScriptPackage::SCGetObjectValue(CmdSet &Set) -{ - WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); - if(!ws) - { - logerror("Invalid Script call: SCGetObjectValue: WorldSession not valid"); - DEF_RETURN_ERROR; - } - - uint64 guid = DefScriptTools::toUint64(Set.defaultarg); - Object *o = ws->objmgr.GetObj(guid); - if(o) - { - uint32 v = (uint32)DefScriptTools::toUint64(Set.arg[0]); - if(v > o->GetValuesCount()) - { - logerror("SCGetObjectValue ["I64FMTD", type %u]: invalid value index: %u",guid,o->GetTypeId(),v); - return ""; - } - else - { - if(DefScriptTools::stringToLower(Set.arg[1]) == "f") - return toString((ldbl)o->GetFloatValue(v)); - else if(DefScriptTools::stringToLower(Set.arg[1]) == "i64") - return toString(o->GetUInt64Value(v)); - else - return toString((uint64)o->GetUInt32Value(v)); - } - } - return ""; -} - -DefReturnResult DefScriptPackage::SCGetRace(CmdSet &Set) -{ - WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); - if(!ws) - { - logerror("Invalid Script call: SCGetObjectValue: WorldSession not valid"); - DEF_RETURN_ERROR; - } - - uint64 guid = DefScriptTools::toUint64(Set.defaultarg); - Object *o = ws->objmgr.GetObj(guid); - if(o && (o->GetTypeId() == TYPEID_UNIT || o->GetTypeId() == TYPEID_PLAYER)) - { - return DefScriptTools::toString((uint64)((Unit*)o)->GetRace()); - } - return ""; -} - -DefReturnResult DefScriptPackage::SCGetClass(CmdSet &Set) -{ - WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); - if(!ws) - { - logerror("Invalid Script call: SCGetObjectValue: WorldSession not valid"); - DEF_RETURN_ERROR; - } - - uint64 guid = DefScriptTools::toUint64(Set.defaultarg); - Object *o = ws->objmgr.GetObj(guid); - if(o && (o->GetTypeId() == TYPEID_UNIT || o->GetTypeId() == TYPEID_PLAYER)) - { - return DefScriptTools::toString((uint64)((Unit*)o)->GetClass()); - } - return ""; -} - -DefReturnResult DefScriptPackage::SCSendWorldPacket(CmdSet &Set) -{ - WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); - if(!ws) - { - logerror("Invalid Script call: SCSendWorldPacket: WorldSession not valid"); - DEF_RETURN_ERROR; - } - ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if(bb) - { - uint16 opc = (uint16)DefScriptTools::toUint64(Set.arg[0]); - if(!opc) - { - opc = (uint16)GetOpcodeID(Set.arg[0].c_str()); - if(opc == uint16(-1)) - return false; - } - if(opc) // prevent sending CMSG_NULL_ACTION - { - WorldPacket wp(opc, bb->size()); - if(bb->size()) - wp.append(bb->contents(), bb->size()); - ws->SendWorldPacket(wp); - return true; - } - } - return false; -} - -DefReturnResult DefScriptPackage::SCGetOpcodeID(CmdSet &Set) -{ - uint32 id = GetOpcodeID(Set.defaultarg.c_str()); - return id != (uint32)(-1) ? toString(id) : ""; -} - -DefReturnResult DefScriptPackage::SCGetOpcodeName(CmdSet &Set) -{ - return GetOpcodeName((uint32)DefScriptTools::toUint64(Set.defaultarg)); -} - -DefReturnResult DefScriptPackage::SCBBGetPackedGuid(CmdSet &Set) -{ - ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if (!bb) - return false; - - if (bb->size() - bb->rpos() < sizeof(uint8)) - return false; - - uint8 mask; - *bb >> mask; - uint64 guid=0; - for(uint8 i=0;i<8;i++) - { - if(mask & (1<size() - bb->rpos() < sizeof(uint8)) - return false; - - *bb >> ((uint8*)&guid)[i]; - } - } - - return toString(guid); -} - -DefReturnResult DefScriptPackage::SCBBPutPackedGuid(CmdSet &Set) -{ - ByteBuffer *bb = bytebuffers.Get(_NormalizeVarName(Set.arg[0],Set.myname)); - - uint64 guid = DefScriptTools::toUint64(Set.defaultarg); - if (!guid) // fast check if guid is empty (in this case mask must be 0 with no extra data) - { - *bb << uint8(0); - return false; - } - - ByteBuffer bbmask; - uint8 mask = 0; - - for(uint8 i = 0; i < 8; i++) - { - if(guid & 0xFF) - { - mask |= (1<>= 8; - } - - *bb << mask; - bb->append(bbmask); - - return true; -} - -DefReturnResult DefScriptPackage::SCGui(CmdSet &Set) -{ - PseuInstance *ins = (PseuInstance*)parentMethod; - if(ins->InitGUI()) - logdebug("SCGui: gui created"); - else - { - logerror("SCGui: failed"); - return false; - } - while(!ins->GetGUI() && !ins->GetGUI()->IsInitialized()) - ins->GetRunnable()->sleep(1); - - // TODO: not sure if this piece of code will work as intended, needs some testing - if(ins->GetWSession() && ins->GetWSession()->InWorld()) - ins->GetGUI()->SetSceneState(SCENESTATE_WORLD); - else - ins->GetGUI()->SetSceneState(SCENESTATE_GUISTART); - - return true; -} - -DefReturnResult DefScriptPackage::SCSendWho(CmdSet &Set) -{ - WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); - if(!ws) - { - logerror("Invalid Script call: SCSendWho: WorldSession not valid"); - DEF_RETURN_ERROR; - } - uint32 minlvl = (uint32)DefScriptTools::toUint64(Set.arg[0]); - uint32 maxlvl = (uint32)DefScriptTools::toUint64(Set.arg[1]); - uint32 racemask = (uint32)DefScriptTools::toUint64(Set.arg[2]); - uint32 classmask = (uint32)DefScriptTools::toUint64(Set.arg[3]); - std::string name = Set.arg[4]; - std::string guildname = Set.arg[5]; - // TODO: implement zonelist - - // convert empty string (default: 0) to default expected by server (-1 = 0xFFFFFFFF = all) - // and do some values cleanup - if(!racemask) - racemask = -1; - if(!classmask) - classmask = -1; - if(!maxlvl) - maxlvl = 100; - else if(maxlvl > 255) - maxlvl = 255; - if(minlvl > 255) - minlvl = 255; - if(minlvl > maxlvl) - minlvl = maxlvl; - - ws->SendWhoListRequest(minlvl,maxlvl,racemask,classmask,name,guildname); - return ""; -} - -DefReturnResult DefScriptPackage::SCGetObjectDistance(CmdSet &Set) -{ - WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); - if(!ws) - { - logerror("Invalid Script call: SCGetObjectDistance: WorldSession not valid"); - DEF_RETURN_ERROR; - } - uint64 guid1 = DefScriptTools::toUint64(Set.defaultarg); - uint64 guid2 = DefScriptTools::toUint64(Set.arg[0]); - std::string s = stringToLower(Set.arg[1]); - Object *o1, *o2; - float dist = 0; - o1 = ws->objmgr.GetObj(guid1); - o2 = ws->objmgr.GetObj(guid2); - if(o1 && o2 && o1->IsWorldObject() && o2->IsWorldObject()) - { - if(s.empty() || s == "2d") - dist = ((WorldObject*)o1)->GetDistance2d((WorldObject*)o2); - else if(s == "3d") - dist = ((WorldObject*)o1)->GetDistance((WorldObject*)o2); - - return toString(ldbl(dist)); - } - - return ""; -} - -DefReturnResult DefScriptPackage::SCSwitchOpcodeHandler(CmdSet &Set) -{ - WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); - if(!ws) - { - logerror("Invalid Script call: SCRemoveOpcodeHandler: WorldSession not valid"); - DEF_RETURN_ERROR; - } - uint16 opc = (uint16)DefScriptTools::toUint64(Set.arg[0]); - bool switchon = DefScriptTools::isTrue(Set.defaultarg); - if(!opc) // ok we cant turn off MSG_NULL_ACTION with this, but who needs it anyway... - { - opc = (uint16)GetOpcodeID(Set.arg[0].c_str()); - if(opc == uint16(-1)) - return false; - } - else if(opc >= MAX_OPCODE_ID) - { - logerror("Can't enable/disable opcode handling of %u", opc); - return false; - } - if(switchon) - ws->EnableOpcode(opc); - else - ws->DisableOpcode(opc); - - logdebug("Opcode handler for %s (%u) %s",GetOpcodeName(opc), opc, switchon ? "enabled" : "disabled"); - return true; -} - -DefReturnResult DefScriptPackage::SCOpcodeDisabled(CmdSet &Set) -{ - WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); - if(!ws) - { - logerror("Invalid Script call: SCOpcodeDisabled: WorldSession not valid"); - DEF_RETURN_ERROR; - } - uint16 opc = (uint16)DefScriptTools::toUint64(Set.defaultarg); - if(!opc) - { - opc = (uint16)GetOpcodeID(Set.arg[0].c_str()); - if(opc == uint16(-1)) - return false; - } - else if(opc >= MAX_OPCODE_ID) - { - logerror("SCOpcodeDisabled: Opcode %u out of range", opc); - return false; // we can NEVER handle out of range opcode, but since its not disabled, return false - } - return ws->IsOpcodeDisabled(opc); -} - -DefReturnResult DefScriptPackage::SCSpoofWorldPacket(CmdSet &Set) -{ - WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); - if(!ws) - { - logerror("Invalid Script call: SCSpoofWorldPacket: WorldSession not valid"); - DEF_RETURN_ERROR; - } - ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); - if(bb) - { - uint32 opcode = (uint32)DefScriptTools::toUint64(Set.arg[0]); - if(opcode) // ok, here again CMSG_NULL_ACTION doesnt work, but who cares - { - WorldPacket *wp = new WorldPacket(opcode, bb->size()); // will be deleted by the opcode handler later - if(bb->size()) - wp->append(bb->contents(), bb->size()); - logdebug("Spoofing WorldPacket with opcode %s (%u), size %u",GetOpcodeName(opcode),opcode,wp->size()); - ws->AddToPktQueue(wp); // handle this packet as if it was sent by the server - return true; - } - } - return false; -} - -void DefScriptPackage::My_LoadUserPermissions(VarSet &vs) -{ - static char *prefix = "USERS::"; - std::string sub,usr; - for(uint32 i=0;i::iterator i = my_usrPermissionMap.begin(); i != my_usrPermissionMap.end(); i++) - { - if(i->first == username) - { - usrperm = i->second; - } - } - - DefXChgResult final; - if(usrperm < 255 && line.find("?{")!=std::string::npos) - { - logerror("WARNING: %s wanted to exec \"%s\"",username.c_str(),line.c_str()); - final=ReplaceVars(line,NULL,0,false); // prevent execution of embedded scripts (= using return values) that could trigger dangerous stuff. - } - else - final=ReplaceVars(line,NULL,0,true); // exec as usual - - - CmdSet curSet; - SplitLine(curSet,final.str); - - for (std::map::iterator i = scriptPermissionMap.begin(); i != scriptPermissionMap.end(); i++) - { - if(i->first == curSet.cmd) - { - scperm = i->second; - } - } - - - if(scperm >= 0) // skip "invisible" scripts (without any permission set) completely. - { - if(usrperm < scperm) - { - CmdSet Set; - Set.arg[0] = username; - Set.arg[1] = DefScriptTools::toString(usrperm); - Set.arg[2] = DefScriptTools::toString(scperm); - Set.arg[3] = curSet.cmd; - RunScript("_nopermission",&Set); - return; - } - else - { - Interpret(curSet); - } - } - -} - - - - - + +#include "common.h" +#include "PseuWoW.h" +#include "DefScript/DefScript.h" +#include "DefScript/DefScriptTools.h" +#include "Player.h" +#include "Opcodes.h" +#include "SharedDefines.h" +#include "WorldSession.h" +#include "Channel.h" +#include "CacheHandler.h" +#include "SCPDatabase.h" + + +void DefScriptPackage::_InitDefScriptInterface(void) +{ + AddFunc("pause",&DefScriptPackage::SCpause); + AddFunc("emote",&DefScriptPackage::SCemote); + AddFunc("follow",&DefScriptPackage::SCfollow); + AddFunc("savecache",&DefScriptPackage::SCsavecache); + AddFunc("sendchatmessage",&DefScriptPackage::SCSendChatMessage); + AddFunc("joinchannel",&DefScriptPackage::SCjoinchannel); + AddFunc("leavechannel",&DefScriptPackage::SCleavechannel); + AddFunc("listchannel",&DefScriptPackage::SClistchannel); + AddFunc("loadconf",&DefScriptPackage::SCloadconf); + AddFunc("applyconf",&DefScriptPackage::SCapplyconf); + AddFunc("applypermissions",&DefScriptPackage::SCapplypermissions); + AddFunc("log",&DefScriptPackage::SClog); + AddFunc("logdetail",&DefScriptPackage::SClogdetail); + AddFunc("logerror",&DefScriptPackage::SClogerror); + AddFunc("logdebug",&DefScriptPackage::SClogdebug); + AddFunc("castspell",&DefScriptPackage::SCcastspell); + AddFunc("queryitem",&DefScriptPackage::SCqueryitem); + AddFunc("target",&DefScriptPackage::SCtarget); + AddFunc("loadscp",&DefScriptPackage::SCloadscp); + AddFunc("scpexists",&DefScriptPackage::SCScpExists); + AddFunc("scpsectionexists",&DefScriptPackage::SCScpSectionExists); + AddFunc("scpentryexists",&DefScriptPackage::SCScpEntryExists); + AddFunc("getscpvalue",&DefScriptPackage::SCGetScpValue); + AddFunc("getplayerguid",&DefScriptPackage::SCGetPlayerGuid); + AddFunc("getname",&DefScriptPackage::SCGetName); + AddFunc("getentry",&DefScriptPackage::SCGetEntry); + AddFunc("getitemprotovalue",&DefScriptPackage::SCGetItemProtoValue); + AddFunc("getobjecttype",&DefScriptPackage::SCGetObjectType); + AddFunc("objectknown",&DefScriptPackage::SCObjectKnown); + AddFunc("getplayerperm",&DefScriptPackage::SCGetPlayerPerm); + AddFunc("getscriptperm",&DefScriptPackage::SCGetScriptPerm); + AddFunc("lgetfiles",&DefScriptPackage::SCGetFileList); + AddFunc("printscript",&DefScriptPackage::SCPrintScript); + AddFunc("getobjectvalue",&DefScriptPackage::SCGetObjectValue); + AddFunc("getrace",&DefScriptPackage::SCGetRace); + AddFunc("getclass",&DefScriptPackage::SCGetClass); + AddFunc("sendworldpacket",&DefScriptPackage::SCSendWorldPacket); + AddFunc("getopcodename",&DefScriptPackage::SCGetOpcodeName); + AddFunc("getopcodeid",&DefScriptPackage::SCGetOpcodeID); + AddFunc("bbgetpackedguid",&DefScriptPackage::SCBBGetPackedGuid); + AddFunc("bbputpackedguid",&DefScriptPackage::SCBBPutPackedGuid); + AddFunc("gui",&DefScriptPackage::SCGui); + AddFunc("sendwho",&DefScriptPackage::SCSendWho); + AddFunc("getobjectdist",&DefScriptPackage::SCGetObjectDistance); + AddFunc("switchopcodehandler",&DefScriptPackage::SCSwitchOpcodeHandler); + AddFunc("opcodedisabled",&DefScriptPackage::SCOpcodeDisabled); + AddFunc("spoofworldpacket",&DefScriptPackage::SCSpoofWorldPacket); +} + +DefReturnResult DefScriptPackage::SCshdn(CmdSet& Set) +{ + ((PseuInstance*)parentMethod)->Stop(); + return true; +} + +DefReturnResult DefScriptPackage::SCpause(CmdSet& Set){ + ((PseuInstance*)parentMethod)->Sleep(atoi(Set.defaultarg.c_str())); + return true; +} + +DefReturnResult DefScriptPackage::SCSendChatMessage(CmdSet& Set){ + if(!(((PseuInstance*)parentMethod)->GetWSession())) + { + logerror("Invalid Script call: SCSendChatMessage: WorldSession not valid"); + DEF_RETURN_ERROR; + } + std::stringstream ss; + uint32 type=atoi(Set.arg[0].c_str()); + uint32 lang=atoi(Set.arg[1].c_str()); + + ss << lang; + if(ss.str()!=Set.arg[1]) // given lang is NOT a number + { + uint32 dblang; + dblang = ((PseuInstance*)parentMethod)->dbmgr.GetDB("language").GetFieldByValue("name",Set.arg[1]); + logdev("looking up language id for lang '%s', found %i",Set.arg[1].c_str(),dblang); + if(dblang != -1) + lang = dblang; + } + + std::string msg=Set.arg[2]; + std::string to=Set.arg[3]; + ((PseuInstance*)parentMethod)->GetWSession()->SendChatMessage(type,lang,msg,to); + return true; +} + +DefReturnResult DefScriptPackage::SCsavecache(CmdSet& Set){ + ((PseuInstance*)parentMethod)->SaveAllCache(); + if(DefScriptTools::isTrue(Set.defaultarg)) + { + std::stringstream str; + if(((PseuInstance*)parentMethod)->GetWSession()) + { + str << "Cache saved. [ "; + str << ((PseuInstance*)parentMethod)->GetWSession()->plrNameCache.GetSize(); + str << " Playernames, "; + str << ((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetItemProtoCount(); + str << " Item Prototypes, "; + str << ((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetCreatureTemplateCount(); + str << " Creature Templates"; + str << " ]"; + + ((PseuInstance*)parentMethod)->GetWSession()->SendChatMessage(CHAT_MSG_SAY,0,str.str(),""); + } + } + return true; +} + +DefReturnResult DefScriptPackage::SCemote(CmdSet& Set){ + if(Set.defaultarg.empty()) + return false; + if(!(((PseuInstance*)parentMethod)->GetWSession())) + { + logerror("Invalid Script call: SCEmote: WorldSession not valid"); + DEF_RETURN_ERROR; + } + + // check if the given name exists in the database, if it does, use its record id; if not, convert emote name into a number. + // this supports calls like "emote 126" and "emote ready" + uint32 id = uint32(-1); + SCPDatabaseMgr& dbmgr = ((PseuInstance*)parentMethod)->dbmgr; + if(dbmgr.HasDB("emote")) + { + SCPDatabase& db = dbmgr.GetDB("emote"); + id = db.GetFieldByValue("name",DefScriptTools::stringToUpper(Set.defaultarg)); // emote names are always uppercased + } + if(id == uint32(-1)) + { + id=atoi(Set.defaultarg.c_str()); + if(!id) + { + logerror("SCEmote: Invalid emote!"); + return true; + } + } + ((PseuInstance*)parentMethod)->GetWSession()->SendEmote(id); + return true; +} + + +DefReturnResult DefScriptPackage::SCfollow(CmdSet& Set) +{ + DEF_RETURN_ERROR; // prevent execution for now + /* + WorldSession *ws=((PseuInstance*)parentMethod)->GetWSession(); + if(Set.defaultarg.empty()){ + ws->SendChatMessage(CHAT_MSG_SAY,0,"Stopping! (Please give me a Playername to follow!)",""); + ws->SetFollowTarget(0); + return true; + } + ws->SetFollowTarget(ws->plrNameCache.GetGuid(Set.defaultarg)); + std::stringstream ss; + if(ws->GetFollowTarget()) + ss << "Following player '"<SendChatMessage(CHAT_MSG_SAY,0,ss.str(),""); + */ + return true; + +} + +DefReturnResult DefScriptPackage::SCjoinchannel(CmdSet& Set){ + if(Set.defaultarg.empty()) + return false; + if(!(((PseuInstance*)parentMethod)->GetWSession())) + { + logerror("Invalid Script call: SCjoinchannel: WorldSession not valid"); + DEF_RETURN_ERROR; + } + ((PseuInstance*)parentMethod)->GetWSession()->GetChannels()->Join(Set.defaultarg,Set.arg[0]); + return true; +} + +DefReturnResult DefScriptPackage::SClistchannel(CmdSet& Set){ + if(Set.defaultarg.empty()) + return false; + if(!(((PseuInstance*)parentMethod)->GetWSession())) + { + logerror("Invalid Script call: SClistchannel: WorldSession not valid"); + DEF_RETURN_ERROR; + } + ((PseuInstance*)parentMethod)->GetWSession()->GetChannels()->RequestList(Set.defaultarg); + return true; +} + +DefReturnResult DefScriptPackage::SCleavechannel(CmdSet& Set){ + if(Set.defaultarg.empty()) + return false; + if(!(((PseuInstance*)parentMethod)->GetWSession())) + { + logerror("Invalid Script call: SCleavechannel: WorldSession not valid"); + DEF_RETURN_ERROR; + } + ((PseuInstance*)parentMethod)->GetWSession()->GetChannels()->Leave(Set.defaultarg); + return true; +} + +DefReturnResult DefScriptPackage::SCloadconf(CmdSet& Set){ + if(Set.defaultarg.empty()) + return false; + std::string fn; + if(Set.defaultarg.find('/')==std::string::npos && Set.defaultarg.find('\\')==std::string::npos) + fn += ((PseuInstance*)parentMethod)->GetConfDir(); + fn += Set.defaultarg; + + if(variables.ReadVarsFromFile(fn)) + { + logdev("Loaded conf file [%s]",fn.c_str()); + return true; + } + + log("Error loading conf file [%s]",fn.c_str()); + return false; +} + +DefReturnResult DefScriptPackage::SCapplypermissions(CmdSet& Set){ + this->My_LoadUserPermissions(variables); + return true; +} + +DefReturnResult DefScriptPackage::SCapplyconf(CmdSet& Set){ + ((PseuInstance*)parentMethod)->GetConf()->ApplyFromVarSet(variables); + return true; +} + +DefReturnResult DefScriptPackage::SClog(CmdSet& Set){ + log(Set.defaultarg.c_str()); + return true; +} + +DefReturnResult DefScriptPackage::SClogdetail(CmdSet& Set){ + logdetail(Set.defaultarg.c_str()); + return true; +} + +DefReturnResult DefScriptPackage::SClogdebug(CmdSet& Set){ + logdebug(Set.defaultarg.c_str()); + return true; +} + +DefReturnResult DefScriptPackage::SClogerror(CmdSet& Set){ + logerror(Set.defaultarg.c_str()); + return true; +} + +DefReturnResult DefScriptPackage::SCcastspell(CmdSet& Set) +{ + if(Set.defaultarg.empty()) + return false; + if(!(((PseuInstance*)parentMethod)->GetWSession())) + { + logerror("Invalid Script call: SCcastspell: WorldSession not valid"); + DEF_RETURN_ERROR; + } + + uint32 spellId = atoi(Set.defaultarg.c_str()); + + if (spellId <= 0) + { + return false; + } + + ((PseuInstance*)parentMethod)->GetWSession()->SendCastSpell(spellId); + return true; +} + +DefReturnResult DefScriptPackage::SCqueryitem(CmdSet& Set) +{ + if(!(((PseuInstance*)parentMethod)->GetWSession())) + { + logerror("Invalid Script call: SCqueryitem: WorldSession not valid"); + DEF_RETURN_ERROR; + } + + uint32 id = atoi(Set.defaultarg.c_str()); + if(!id) + return false; + + ((PseuInstance*)parentMethod)->GetWSession()->SendQueryItem(id,0); + return true; +} + +DefReturnResult DefScriptPackage::SCtarget(CmdSet& Set) +{ + // TODO: special targets: _self _pet _nearest ... + WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); + if(!ws) + { + logerror("Invalid Script call: SCtarget: WorldSession not valid"); + DEF_RETURN_ERROR; + } + + if(Set.defaultarg.empty()) + { + ((PseuInstance*)parentMethod)->GetWSession()->SendSetSelection(0); // no target + return true; + } + + std::string what = stringToLower(Set.arg[0]); + uint64 guid = 0; + if(what == "guid") + { + guid = DefScriptTools::toUint64(Set.defaultarg); + } + else if(what.empty() || what == "player") + { + // TODO: search through all objects. for now only allow to target player + guid = ws->plrNameCache.GetGuid(Set.defaultarg); + } + + Object *obj = ws->objmgr.GetObj(guid); + if(obj && (obj->IsUnit() || obj->IsCorpse())) // only units and corpses are targetable + { + ws->SendSetSelection(guid); // will also set the target for myCharacter + return DefScriptTools::toString(guid); + } + else + { + logdetail("Target '%s' not found!",Set.defaultarg.c_str()); + return false; + } + return ""; +} + +DefReturnResult DefScriptPackage::SCloadscp(CmdSet& Set) +{ + SCPDatabaseMgr& dbmgr = ((PseuInstance*)parentMethod)->dbmgr; + if(Set.defaultarg.empty()) // exit if no filename was given + return false; + std::string dbname = stringToLower(Set.arg[0]); + uint32 sections = 0; + if(dbname.empty()) // if no db name was supplied, try to find it automatically in the file ("#dbname=...") + { + sections = dbmgr.AutoLoadFile((char*)Set.defaultarg.c_str()); + if(!sections) + { + logerror("Tried to auto-load SCP file: \"%s\", but no name tag found. skipped."); + } + } + else + { + sections = dbmgr.GetDB(dbname).LoadFromFile((char*)Set.defaultarg.c_str()); + if(sections) + { + logdetail("Loaded SCP: \"%s\" [%s] (%u sections)",dbname.c_str(),Set.defaultarg.c_str(),sections); + } + else + { + logerror("Failed to load SCP: \"%s\" [%s]",dbname.c_str(),Set.defaultarg.c_str()); + } + } + return DefScriptTools::toString((uint64)sections);; +} + +DefReturnResult DefScriptPackage::SCScpExists(CmdSet& Set) +{ + return (!Set.defaultarg.empty()) && ((PseuInstance*)parentMethod)->dbmgr.HasDB(Set.defaultarg); +} + +DefReturnResult DefScriptPackage::SCScpSectionExists(CmdSet& Set) +{ + static std::string dbname; + if(!Set.arg[0].empty()) + dbname=Set.arg[0]; + return (!Set.defaultarg.empty()) && (!dbname.empty()) + && ((PseuInstance*)parentMethod)->dbmgr.HasDB(dbname) + && ((PseuInstance*)parentMethod)->dbmgr.GetDB(dbname).HasField((uint32)DefScriptTools::toUint64(Set.defaultarg)); +} + +DefReturnResult DefScriptPackage::SCScpEntryExists(CmdSet& Set) +{ + static std::string dbname; + static uint32 keyid; + if(!Set.arg[0].empty()) + dbname=Set.arg[0]; + if(!Set.arg[1].empty()) + keyid=(uint32)DefScriptTools::toUint64(Set.arg[1]); + return (!Set.defaultarg.empty()) && (!dbname.empty()) + && ((PseuInstance*)parentMethod)->dbmgr.HasDB(dbname) + && ((PseuInstance*)parentMethod)->dbmgr.GetDB(dbname).HasField(keyid) + && ((PseuInstance*)parentMethod)->dbmgr.GetDB(dbname).GetField(keyid).HasEntry(Set.defaultarg); +} + + +// GetScpValue,db,key entry +// db & key will be stored, that multiple calls like GetScpValue entryxyz are possible +DefReturnResult DefScriptPackage::SCGetScpValue(CmdSet& Set) +{ + static std::string dbname; + static uint32 keyid; + std::string entry; + DefReturnResult r; + + if(!Set.arg[0].empty()) + dbname=Set.arg[0]; + if(!Set.arg[1].empty()) + keyid=(uint32)DefScriptTools::toUint64(Set.arg[1]); + if(!Set.defaultarg.empty()) + entry=Set.defaultarg; + if( (!entry.empty()) && (!dbname.empty()) + && ((PseuInstance*)parentMethod)->dbmgr.HasDB(dbname) + && ((PseuInstance*)parentMethod)->dbmgr.GetDB(dbname).HasField(keyid) + && ((PseuInstance*)parentMethod)->dbmgr.GetDB(dbname).GetField(keyid).HasEntry(entry)) + { + r.ret = ((PseuInstance*)parentMethod)->dbmgr.GetDB(dbname).GetField(keyid).GetString(entry); + } + else + { + r.ret = ""; + } + return r; +} + +DefReturnResult DefScriptPackage::SCGetPlayerGuid(CmdSet& Set) +{ + if(!(((PseuInstance*)parentMethod)->GetWSession())) + { + logerror("Invalid Script call: SCGetPlayerGuid: WorldSession not valid"); + DEF_RETURN_ERROR; + } + DefReturnResult r; + if(Set.defaultarg.empty()) + { + r.ret="0"; + } + else + { + uint64 guid=((PseuInstance*)parentMethod)->GetWSession()->plrNameCache.GetGuid(Set.defaultarg); + r.ret=DefScriptTools::toString(guid); + } + return r; +} + +DefReturnResult DefScriptPackage::SCGetName(CmdSet& Set) +{ + WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); + if(!ws) + { + logerror("Invalid Script call: SCGetName: WorldSession not valid"); + DEF_RETURN_ERROR; + } + uint64 id = DefScriptTools::toUint64(Set.defaultarg); + std::string source = DefScriptTools::stringToLower(Set.arg[0]); + + // "guid" type can be everything - item, player, unit, gameobject... whatever has this guid. + if(source.empty() || source == "guid") + { + Object *o = ws->objmgr.GetObj(id); + std::string n; + if(o) + { + n = o->GetName(); + if(!n.empty()) + return n; + } + + if(!o || n.empty()) + { + // fallback if that guid is player guid, its maybe stored, so check that + if(IS_PLAYER_GUID(id)) + { + if(ws->plrNameCache.IsKnown(id)) + return ws->plrNameCache.GetName(id); + } + } + } + else if(source == "player") + { + if(ws->plrNameCache.IsKnown(id)) + return ws->plrNameCache.GetName(id); + else + return ""; + + } + else if(source == "item") + { + ItemProto *iproto = ws->objmgr.GetItemProto((uint32)id); + return iproto ? iproto->Name : ""; + } + else if(source == "unit") + { + CreatureTemplate *ct = ws->objmgr.GetCreatureTemplate((uint32)id); + return ct ? ct->name : ""; + } + // TODO: add gameobject, dynamicobject + + return ""; +} + +DefReturnResult DefScriptPackage::SCGetEntry(CmdSet& Set) +{ + if(!(((PseuInstance*)parentMethod)->GetWSession())) + { + logerror("Invalid Script call: SCGetEntry: WorldSession not valid"); + DEF_RETURN_ERROR; + } + DefReturnResult r; + uint64 guid=DefScriptTools::toUint64(Set.defaultarg); + r.ret="0"; + Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid); + if(o) + { + r.ret=DefScriptTools::toString((uint64)o->GetEntry()); + } + else + { + logerror("SCGetEntry: Object "I64FMT" not known",guid); + } + return r; +} + +DefReturnResult DefScriptPackage::SCGetObjectType(CmdSet& Set) +{ + if(!(((PseuInstance*)parentMethod)->GetWSession())) + { + logerror("Invalid Script call: SCGetObjectType: WorldSession not valid"); + DEF_RETURN_ERROR; + } + DefReturnResult r; + uint64 guid=DefScriptTools::toUint64(Set.defaultarg); + r.ret="0"; + Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid); + if(o) + { + r.ret=DefScriptTools::toString((uint64)o->GetTypeId()); + } + else + { + logerror("SCGetObjectType: Object "I64FMT" not known",guid); + } + return r; +} + +DefReturnResult DefScriptPackage::SCObjectKnown(CmdSet& Set) +{ + if(!(((PseuInstance*)parentMethod)->GetWSession())) + { + logerror("Invalid Script call: SCObjectIsKnown: WorldSession not valid"); + DEF_RETURN_ERROR; + } + uint64 guid=DefScriptTools::toUint64(Set.defaultarg); + Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid); + return o!=NULL; +} + +DefReturnResult DefScriptPackage::SCGetPlayerPerm(CmdSet& Set) +{ + DefReturnResult r; + uint8 perm=0; + for (std::map::iterator i = my_usrPermissionMap.begin(); i != my_usrPermissionMap.end(); i++) + if(i->first == Set.defaultarg) + perm = i->second; + r.ret = toString(perm); + return r; +} + +DefReturnResult DefScriptPackage::SCGetScriptPerm(CmdSet& Set) +{ + DefReturnResult r; + uint8 perm=0; + for (std::map::iterator i = scriptPermissionMap.begin(); i != scriptPermissionMap.end(); i++) + if(i->first == Set.defaultarg) + perm = i->second; + r.ret = toString(perm); + return r; +} + +DefReturnResult DefScriptPackage::SCGetItemProtoValue(CmdSet& Set) +{ + if(!(((PseuInstance*)parentMethod)->GetWSession())) + { + logerror("Invalid Script call: SCGetItemProtoValue: WorldSession not valid"); + DEF_RETURN_ERROR; + } + DefReturnResult r; + uint32 entry=DefScriptTools::toUint64(Set.arg[0]); + ItemProto *proto=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetItemProto(entry); + if(proto) + { + std::string t=stringToLower(Set.defaultarg); + uint32 tmp=0; + if(t=="class") r.ret=toString(proto->Class); + else if(t=="subclass") r.ret=toString(proto->SubClass); + else if(t=="name") r.ret=proto->Name; + else if(t=="model" || t=="displayid") r.ret=toString(proto->DisplayInfoID); + else if(t=="quality") r.ret=toString(proto->Quality); + else if(t=="flags") r.ret=toString(proto->Flags); + else if(t=="buycount") r.ret=toString(proto->BuyCount); + else if(t=="buyprice") r.ret=toString(proto->BuyPrice); + else if(t=="sellprice") r.ret=toString(proto->SellPrice); + else if(t=="inventorytype") r.ret=toString(proto->InventoryType); + else if(t=="allowableclass") r.ret=toString(proto->AllowableClass); + else if(t=="allowablerace") r.ret=toString(proto->AllowableRace); + else if(t=="itemlevel") r.ret=toString(proto->ItemLevel); + else if(t=="reqlevel") r.ret=toString(proto->RequiredLevel); + else if(t=="reqskill") r.ret=toString(proto->RequiredSkill); + else if(t=="reqskillrank") r.ret=toString(proto->RequiredSkillRank); + else if(t=="reqspell") r.ret=toString(proto->RequiredSpell); + else if(t=="reqhonorrank") r.ret=toString(proto->RequiredHonorRank); + else if(t=="reqcityrank") r.ret=toString(proto->RequiredCityRank); + else if(t=="reqrepfaction") r.ret=toString(proto->RequiredReputationFaction); + else if(t=="reqreprank") r.ret=toString(proto->RequiredReputationRank); + else if(t=="maxcount") r.ret=toString(proto->MaxCount); + else if(t=="stackable") r.ret=toString(proto->Stackable); + else if(t=="slots") r.ret=toString(proto->ContainerSlots); + else if(t=="str") + { + for(uint32 i=0;i<10;i++) + if(proto->ItemStat[i].ItemStatType==ITEM_STAT_STRENGTH) + tmp+=proto->ItemStat[i].ItemStatValue; + r.ret = toString((uint64)tmp); + } + else if(t=="agi") + { + for(uint32 i=0;i<10;i++) + if(proto->ItemStat[i].ItemStatType==ITEM_STAT_AGILITY) + tmp+=proto->ItemStat[i].ItemStatValue; + r.ret = toString((uint64)tmp); + } + else if(t=="sta") + { + for(uint32 i=0;i<10;i++) + if(proto->ItemStat[i].ItemStatType==ITEM_STAT_STAMINA) + tmp+=proto->ItemStat[i].ItemStatValue; + r.ret = toString((uint64)tmp); + } + else if(t=="int") + { + for(uint32 i=0;i<10;i++) + if(proto->ItemStat[i].ItemStatType==ITEM_STAT_INTELLECT) + tmp+=proto->ItemStat[i].ItemStatValue; + r.ret = toString((uint64)tmp); + } + else if(t=="spi") + { + for(uint32 i=0;i<10;i++) + if(proto->ItemStat[i].ItemStatType==ITEM_STAT_SPIRIT) + tmp+=proto->ItemStat[i].ItemStatValue; + r.ret = toString((uint64)tmp); + } + else if(t=="hp" || t=="health") + { + for(uint32 i=0;i<10;i++) + if(proto->ItemStat[i].ItemStatType==ITEM_STAT_HEALTH) + tmp+=proto->ItemStat[i].ItemStatValue; + r.ret = toString((uint64)tmp); + } + else if(t=="mindmg") + { + for(uint32 i=0;i<5;i++) + if(proto->Damage[i].DamageType==NORMAL_DAMAGE) + tmp+=proto->Damage[i].DamageMin; + r.ret = toString((uint64)tmp); + } + else if(t=="maxdmg") + { + for(uint32 i=0;i<5;i++) + if(proto->Damage[i].DamageType==NORMAL_DAMAGE) + tmp+=proto->Damage[i].DamageMax; + r.ret = toString((uint64)tmp); + } + else if(t=="mindmg_holy") + { + for(uint32 i=0;i<5;i++) + if(proto->Damage[i].DamageType==HOLY_DAMAGE) + tmp+=proto->Damage[i].DamageMin; + r.ret = toString((uint64)tmp); + } + else if(t=="maxdmg_holy") + { + for(uint32 i=0;i<5;i++) + if(proto->Damage[i].DamageType==HOLY_DAMAGE) + tmp+=proto->Damage[i].DamageMax; + r.ret = toString((uint64)tmp); + } + else if(t=="mindmg_fire") + { + for(uint32 i=0;i<5;i++) + if(proto->Damage[i].DamageType==FIRE_DAMAGE) + tmp+=proto->Damage[i].DamageMin; + r.ret = toString((uint64)tmp); + } + else if(t=="maxdmg_fire") + { + for(uint32 i=0;i<5;i++) + if(proto->Damage[i].DamageType==FIRE_DAMAGE) + tmp+=proto->Damage[i].DamageMax; + r.ret = toString((uint64)tmp); + } + else if(t=="mindmg_nature") + { + for(uint32 i=0;i<5;i++) + if(proto->Damage[i].DamageType==NATURE_DAMAGE) + tmp+=proto->Damage[i].DamageMin; + r.ret = toString((uint64)tmp); + } + else if(t=="maxdmg_nature") + { + for(uint32 i=0;i<5;i++) + if(proto->Damage[i].DamageType==NATURE_DAMAGE) + tmp+=proto->Damage[i].DamageMax; + r.ret = toString((uint64)tmp); + } + else if(t=="mindmg_frost") + { + for(uint32 i=0;i<5;i++) + if(proto->Damage[i].DamageType==FROST_DAMAGE) + tmp+=proto->Damage[i].DamageMin; + r.ret = toString((uint64)tmp); + } + else if(t=="maxdmg_frost") + { + for(uint32 i=0;i<5;i++) + if(proto->Damage[i].DamageType==FROST_DAMAGE) + tmp+=proto->Damage[i].DamageMax; + r.ret = toString((uint64)tmp); + } + else if(t=="mindmg_shadow") + { + for(uint32 i=0;i<5;i++) + if(proto->Damage[i].DamageType==SHADOW_DAMAGE) + tmp+=proto->Damage[i].DamageMin; + r.ret = toString((uint64)tmp); + } + else if(t=="maxdmg_shadow") + { + for(uint32 i=0;i<5;i++) + if(proto->Damage[i].DamageType==SHADOW_DAMAGE) + tmp+=proto->Damage[i].DamageMax; + r.ret = toString((uint64)tmp); + } + else if(t=="mindmg_arcane") + { + for(uint32 i=0;i<5;i++) + if(proto->Damage[i].DamageType==ARCANE_DAMAGE) + tmp+=proto->Damage[i].DamageMin; + r.ret = toString((uint64)tmp); + } + else if(t=="maxdmg_arcane") + { + for(uint32 i=0;i<5;i++) + if(proto->Damage[i].DamageType==ARCANE_DAMAGE) + tmp+=proto->Damage[i].DamageMax; + r.ret = toString((uint64)tmp); + } + else if(t=="armor") r.ret=toString(proto->Armor); + else if(t=="holyres") r.ret=toString(proto->HolyRes); + else if(t=="fireres") r.ret=toString(proto->FireRes); + else if(t=="natureres") r.ret=toString(proto->NatureRes); + else if(t=="frostres") r.ret=toString(proto->FrostRes); + else if(t=="shadowres") r.ret=toString(proto->ShadowRes); + else if(t=="arcaneres") r.ret=toString(proto->ArcaneRes); + else if(t=="delay") r.ret=toString(proto->Delay); + else if(t=="ammotype") r.ret=toString(proto->Ammo_type); + else if(t=="range") r.ret=toString(proto->RangedModRange); + else if(t=="bonding") r.ret=toString(proto->Bonding); + else if(t=="desc") r.ret=proto->Description; + else if(t=="pagetext") r.ret=toString(proto->PageText); + else if(t=="languageid") r.ret=toString(proto->LanguageID); + else if(t=="pagematerial") r.ret=toString(proto->PageMaterial); + else if(t=="startquest") r.ret=toString(proto->StartQuest); + else if(t=="lockid") r.ret=toString(proto->LockID); + else if(t=="material") r.ret=toString(proto->Material); + else if(t=="sheath") r.ret=toString(proto->Sheath); + else if(t=="extra") r.ret=toString(proto->Extra); + else if(t=="block") r.ret=toString(proto->Block); + else if(t=="itemset") r.ret=toString(proto->ItemSet); + else if(t=="maxdur") r.ret=toString(proto->MaxDurability); + else if(t=="area") r.ret=toString(proto->Area); + else if(t=="bagfamily") r.ret=toString(proto->BagFamily); + // TODO: add item spells + else + { + logerror("SCGetItemProtoValue: Unknown property \"%s\" for Item Prototype %u",t.c_str(),entry); + } + } + else + { + logerror("SCGetItemProtoValue: Item Prototype %u not known",entry); + } + return r; +} + +DefReturnResult DefScriptPackage::SCGetFileList(CmdSet& Set) +{ + DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname)); + l->clear(); + *l = (DefList)GetFileList(Set.defaultarg); + if(Set.arg[1].length()) + { + std::string ext = "."; + ext += Set.arg[1]; + ext = stringToLower(ext); + for(DefList::iterator i = l->begin(); i != l->end(); ) + { + std::string tmp = stringToLower(i->c_str() + (i->length() - ext.length())); + if( tmp != ext ) + { + i = l->erase(i); + continue; + } + i++; + } + } + return toString((uint64)l->size()); +} + +DefReturnResult DefScriptPackage::SCPrintScript(CmdSet &Set) +{ + DefScript *sc = GetScript(DefScriptTools::stringToLower(Set.defaultarg)); + if(sc) + { + logcustom(0,GREEN,"== DefScript \"%s\", %u lines: ==",sc->GetName().c_str(),sc->GetLines()); + for(uint32 i = 0; i < sc->GetLines(); i++) + { + logcustom(0,GREEN,sc->GetLine(i).c_str()); + } + } + return ""; +} + +DefReturnResult DefScriptPackage::SCGetObjectValue(CmdSet &Set) +{ + WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); + if(!ws) + { + logerror("Invalid Script call: SCGetObjectValue: WorldSession not valid"); + DEF_RETURN_ERROR; + } + + uint64 guid = DefScriptTools::toUint64(Set.defaultarg); + Object *o = ws->objmgr.GetObj(guid); + if(o) + { + uint32 v = (uint32)DefScriptTools::toUint64(Set.arg[0]); + if(v > o->GetValuesCount()) + { + logerror("SCGetObjectValue ["I64FMTD", type %u]: invalid value index: %u",guid,o->GetTypeId(),v); + return ""; + } + else + { + if(DefScriptTools::stringToLower(Set.arg[1]) == "f") + return toString((ldbl)o->GetFloatValue(v)); + else if(DefScriptTools::stringToLower(Set.arg[1]) == "i64") + return toString(o->GetUInt64Value(v)); + else + return toString((uint64)o->GetUInt32Value(v)); + } + } + return ""; +} + +DefReturnResult DefScriptPackage::SCGetRace(CmdSet &Set) +{ + WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); + if(!ws) + { + logerror("Invalid Script call: SCGetObjectValue: WorldSession not valid"); + DEF_RETURN_ERROR; + } + + uint64 guid = DefScriptTools::toUint64(Set.defaultarg); + Object *o = ws->objmgr.GetObj(guid); + if(o && (o->GetTypeId() == TYPEID_UNIT || o->GetTypeId() == TYPEID_PLAYER)) + { + return DefScriptTools::toString((uint64)((Unit*)o)->GetRace()); + } + return ""; +} + +DefReturnResult DefScriptPackage::SCGetClass(CmdSet &Set) +{ + WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); + if(!ws) + { + logerror("Invalid Script call: SCGetObjectValue: WorldSession not valid"); + DEF_RETURN_ERROR; + } + + uint64 guid = DefScriptTools::toUint64(Set.defaultarg); + Object *o = ws->objmgr.GetObj(guid); + if(o && (o->GetTypeId() == TYPEID_UNIT || o->GetTypeId() == TYPEID_PLAYER)) + { + return DefScriptTools::toString((uint64)((Unit*)o)->GetClass()); + } + return ""; +} + +DefReturnResult DefScriptPackage::SCSendWorldPacket(CmdSet &Set) +{ + WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); + if(!ws) + { + logerror("Invalid Script call: SCSendWorldPacket: WorldSession not valid"); + DEF_RETURN_ERROR; + } + ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if(bb) + { + uint16 opc = (uint16)DefScriptTools::toUint64(Set.arg[0]); + if(!opc) + { + opc = (uint16)GetOpcodeID(Set.arg[0].c_str()); + if(opc == uint16(-1)) + return false; + } + if(opc) // prevent sending CMSG_NULL_ACTION + { + WorldPacket wp(opc, bb->size()); + if(bb->size()) + wp.append(bb->contents(), bb->size()); + ws->SendWorldPacket(wp); + return true; + } + } + return false; +} + +DefReturnResult DefScriptPackage::SCGetOpcodeID(CmdSet &Set) +{ + uint32 id = GetOpcodeID(Set.defaultarg.c_str()); + return id != (uint32)(-1) ? toString(id) : ""; +} + +DefReturnResult DefScriptPackage::SCGetOpcodeName(CmdSet &Set) +{ + return GetOpcodeName((uint32)DefScriptTools::toUint64(Set.defaultarg)); +} + +DefReturnResult DefScriptPackage::SCBBGetPackedGuid(CmdSet &Set) +{ + ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if (!bb) + return false; + + if (bb->size() - bb->rpos() < sizeof(uint8)) + return false; + + uint8 mask; + *bb >> mask; + uint64 guid=0; + for(uint8 i=0;i<8;i++) + { + if(mask & (1<size() - bb->rpos() < sizeof(uint8)) + return false; + + *bb >> ((uint8*)&guid)[i]; + } + } + + return toString(guid); +} + +DefReturnResult DefScriptPackage::SCBBPutPackedGuid(CmdSet &Set) +{ + ByteBuffer *bb = bytebuffers.Get(_NormalizeVarName(Set.arg[0],Set.myname)); + + uint64 guid = DefScriptTools::toUint64(Set.defaultarg); + if (!guid) // fast check if guid is empty (in this case mask must be 0 with no extra data) + { + *bb << uint8(0); + return false; + } + + ByteBuffer bbmask; + uint8 mask = 0; + + for(uint8 i = 0; i < 8; i++) + { + if(guid & 0xFF) + { + mask |= (1<>= 8; + } + + *bb << mask; + bb->append(bbmask); + + return true; +} + +DefReturnResult DefScriptPackage::SCGui(CmdSet &Set) +{ + PseuInstance *ins = (PseuInstance*)parentMethod; + if(ins->InitGUI()) + logdebug("SCGui: gui created"); + else + { + logerror("SCGui: failed"); + return false; + } + while(!ins->GetGUI() && !ins->GetGUI()->IsInitialized()) + ins->GetRunnable()->sleep(1); + + // TODO: not sure if this piece of code will work as intended, needs some testing + if(ins->GetWSession() && ins->GetWSession()->InWorld()) + ins->GetGUI()->SetSceneState(SCENESTATE_WORLD); + else + ins->GetGUI()->SetSceneState(SCENESTATE_GUISTART); + + return true; +} + +DefReturnResult DefScriptPackage::SCSendWho(CmdSet &Set) +{ + WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); + if(!ws) + { + logerror("Invalid Script call: SCSendWho: WorldSession not valid"); + DEF_RETURN_ERROR; + } + uint32 minlvl = (uint32)DefScriptTools::toUint64(Set.arg[0]); + uint32 maxlvl = (uint32)DefScriptTools::toUint64(Set.arg[1]); + uint32 racemask = (uint32)DefScriptTools::toUint64(Set.arg[2]); + uint32 classmask = (uint32)DefScriptTools::toUint64(Set.arg[3]); + std::string name = Set.arg[4]; + std::string guildname = Set.arg[5]; + // TODO: implement zonelist + + // convert empty string (default: 0) to default expected by server (-1 = 0xFFFFFFFF = all) + // and do some values cleanup + if(!racemask) + racemask = -1; + if(!classmask) + classmask = -1; + if(!maxlvl) + maxlvl = 100; + else if(maxlvl > 255) + maxlvl = 255; + if(minlvl > 255) + minlvl = 255; + if(minlvl > maxlvl) + minlvl = maxlvl; + + ws->SendWhoListRequest(minlvl,maxlvl,racemask,classmask,name,guildname); + return ""; +} + +DefReturnResult DefScriptPackage::SCGetObjectDistance(CmdSet &Set) +{ + WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); + if(!ws) + { + logerror("Invalid Script call: SCGetObjectDistance: WorldSession not valid"); + DEF_RETURN_ERROR; + } + uint64 guid1 = DefScriptTools::toUint64(Set.defaultarg); + uint64 guid2 = DefScriptTools::toUint64(Set.arg[0]); + std::string s = stringToLower(Set.arg[1]); + Object *o1, *o2; + float dist = 0; + o1 = ws->objmgr.GetObj(guid1); + o2 = ws->objmgr.GetObj(guid2); + if(o1 && o2 && o1->IsWorldObject() && o2->IsWorldObject()) + { + if(s.empty() || s == "2d") + dist = ((WorldObject*)o1)->GetDistance2d((WorldObject*)o2); + else if(s == "3d") + dist = ((WorldObject*)o1)->GetDistance((WorldObject*)o2); + + return toString(ldbl(dist)); + } + + return ""; +} + +DefReturnResult DefScriptPackage::SCSwitchOpcodeHandler(CmdSet &Set) +{ + WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); + if(!ws) + { + logerror("Invalid Script call: SCRemoveOpcodeHandler: WorldSession not valid"); + DEF_RETURN_ERROR; + } + uint16 opc = (uint16)DefScriptTools::toUint64(Set.arg[0]); + bool switchon = DefScriptTools::isTrue(Set.defaultarg); + if(!opc) // ok we cant turn off MSG_NULL_ACTION with this, but who needs it anyway... + { + opc = (uint16)GetOpcodeID(Set.arg[0].c_str()); + if(opc == uint16(-1)) + return false; + } + else if(opc >= MAX_OPCODE_ID) + { + logerror("Can't enable/disable opcode handling of %u", opc); + return false; + } + if(switchon) + ws->EnableOpcode(opc); + else + ws->DisableOpcode(opc); + + logdebug("Opcode handler for %s (%u) %s",GetOpcodeName(opc), opc, switchon ? "enabled" : "disabled"); + return true; +} + +DefReturnResult DefScriptPackage::SCOpcodeDisabled(CmdSet &Set) +{ + WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); + if(!ws) + { + logerror("Invalid Script call: SCOpcodeDisabled: WorldSession not valid"); + DEF_RETURN_ERROR; + } + uint16 opc = (uint16)DefScriptTools::toUint64(Set.defaultarg); + if(!opc) + { + opc = (uint16)GetOpcodeID(Set.arg[0].c_str()); + if(opc == uint16(-1)) + return false; + } + else if(opc >= MAX_OPCODE_ID) + { + logerror("SCOpcodeDisabled: Opcode %u out of range", opc); + return false; // we can NEVER handle out of range opcode, but since its not disabled, return false + } + return ws->IsOpcodeDisabled(opc); +} + +DefReturnResult DefScriptPackage::SCSpoofWorldPacket(CmdSet &Set) +{ + WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); + if(!ws) + { + logerror("Invalid Script call: SCSpoofWorldPacket: WorldSession not valid"); + DEF_RETURN_ERROR; + } + ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if(bb) + { + uint32 opcode = (uint32)DefScriptTools::toUint64(Set.arg[0]); + if(opcode) // ok, here again CMSG_NULL_ACTION doesnt work, but who cares + { + WorldPacket *wp = new WorldPacket(opcode, bb->size()); // will be deleted by the opcode handler later + if(bb->size()) + wp->append(bb->contents(), bb->size()); + logdebug("Spoofing WorldPacket with opcode %s (%u), size %u",GetOpcodeName(opcode),opcode,wp->size()); + ws->AddToPktQueue(wp); // handle this packet as if it was sent by the server + return true; + } + } + return false; +} + +void DefScriptPackage::My_LoadUserPermissions(VarSet &vs) +{ + static char *prefix = "USERS::"; + std::string sub,usr; + for(uint32 i=0;i::iterator i = my_usrPermissionMap.begin(); i != my_usrPermissionMap.end(); i++) + { + if(i->first == username) + { + usrperm = i->second; + } + } + + DefXChgResult final; + if(usrperm < 255 && line.find("?{")!=std::string::npos) + { + logerror("WARNING: %s wanted to exec \"%s\"",username.c_str(),line.c_str()); + final=ReplaceVars(line,NULL,0,false); // prevent execution of embedded scripts (= using return values) that could trigger dangerous stuff. + } + else + final=ReplaceVars(line,NULL,0,true); // exec as usual + + + CmdSet curSet; + SplitLine(curSet,final.str); + + for (std::map::iterator i = scriptPermissionMap.begin(); i != scriptPermissionMap.end(); i++) + { + if(i->first == curSet.cmd) + { + scperm = i->second; + } + } + + + if(scperm >= 0) // skip "invisible" scripts (without any permission set) completely. + { + if(usrperm < scperm) + { + CmdSet Set; + Set.arg[0] = username; + Set.arg[1] = DefScriptTools::toString(usrperm); + Set.arg[2] = DefScriptTools::toString(scperm); + Set.arg[3] = curSet.cmd; + RunScript("_nopermission",&Set); + return; + } + else + { + Interpret(curSet); + } + } + +} + + + + + diff --git a/src/Client/DefScriptInterfaceInclude.h b/src/Client/DefScriptInterfaceInclude.h index 5e8d228..0844877 100644 --- a/src/Client/DefScriptInterfaceInclude.h +++ b/src/Client/DefScriptInterfaceInclude.h @@ -1,56 +1,56 @@ -#ifndef DEFSCRIPTINTERFACEINCLUDE_H -#define DEFSCRIPTINTERFACEINCLUDE_H -#define USING_DEFSCRIPT_EXTENSIONS true - -void _InitDefScriptInterface(void); -// Usable own internal functions: -DefReturnResult SCpause(CmdSet&); -DefReturnResult SCSendChatMessage(CmdSet&); -DefReturnResult SCsavecache(CmdSet&); -DefReturnResult SCemote(CmdSet&); -DefReturnResult SCfollow(CmdSet&); -DefReturnResult SCshdn(CmdSet&); -DefReturnResult SCjoinchannel(CmdSet&); -DefReturnResult SCleavechannel(CmdSet&); -DefReturnResult SClistchannel(CmdSet&); -DefReturnResult SCloadconf(CmdSet&); -DefReturnResult SCapplypermissions(CmdSet&); -DefReturnResult SCapplyconf(CmdSet&); -DefReturnResult SClog(CmdSet&); -DefReturnResult SClogdetail(CmdSet&); -DefReturnResult SClogdebug(CmdSet&); -DefReturnResult SClogerror(CmdSet&); -DefReturnResult SCcastspell(CmdSet&); -DefReturnResult SCqueryitem(CmdSet&); -DefReturnResult SCtarget(CmdSet&); -DefReturnResult SCloadscp(CmdSet&); -DefReturnResult SCScpExists(CmdSet&); -DefReturnResult SCScpSectionExists(CmdSet&); -DefReturnResult SCScpEntryExists(CmdSet&); -DefReturnResult SCGetScpValue(CmdSet&); -DefReturnResult SCGetName(CmdSet&); -DefReturnResult SCGetPlayerGuid(CmdSet&); -DefReturnResult SCGetEntry(CmdSet&); -DefReturnResult SCGetItemProtoValue(CmdSet&); -DefReturnResult SCGetObjectType(CmdSet&); -DefReturnResult SCObjectKnown(CmdSet&); -DefReturnResult SCGetPlayerPerm(CmdSet&); -DefReturnResult SCGetScriptPerm(CmdSet&); -DefReturnResult SCGetFileList(CmdSet&); -DefReturnResult SCPrintScript(CmdSet&); -DefReturnResult SCGetObjectValue(CmdSet&); -DefReturnResult SCGetRace(CmdSet&); -DefReturnResult SCGetClass(CmdSet&); -DefReturnResult SCSendWorldPacket(CmdSet&); -DefReturnResult SCGetOpcodeName(CmdSet&); -DefReturnResult SCGetOpcodeID(CmdSet&); -DefReturnResult SCBBGetPackedGuid(CmdSet&); -DefReturnResult SCBBPutPackedGuid(CmdSet&); -DefReturnResult SCGui(CmdSet&); -DefReturnResult SCSendWho(CmdSet&); -DefReturnResult SCGetObjectDistance(CmdSet&); -DefReturnResult SCSwitchOpcodeHandler(CmdSet&); -DefReturnResult SCOpcodeDisabled(CmdSet&); -DefReturnResult SCSpoofWorldPacket(CmdSet&); - -#endif +#ifndef DEFSCRIPTINTERFACEINCLUDE_H +#define DEFSCRIPTINTERFACEINCLUDE_H +#define USING_DEFSCRIPT_EXTENSIONS true + +void _InitDefScriptInterface(void); +// Usable own internal functions: +DefReturnResult SCpause(CmdSet&); +DefReturnResult SCSendChatMessage(CmdSet&); +DefReturnResult SCsavecache(CmdSet&); +DefReturnResult SCemote(CmdSet&); +DefReturnResult SCfollow(CmdSet&); +DefReturnResult SCshdn(CmdSet&); +DefReturnResult SCjoinchannel(CmdSet&); +DefReturnResult SCleavechannel(CmdSet&); +DefReturnResult SClistchannel(CmdSet&); +DefReturnResult SCloadconf(CmdSet&); +DefReturnResult SCapplypermissions(CmdSet&); +DefReturnResult SCapplyconf(CmdSet&); +DefReturnResult SClog(CmdSet&); +DefReturnResult SClogdetail(CmdSet&); +DefReturnResult SClogdebug(CmdSet&); +DefReturnResult SClogerror(CmdSet&); +DefReturnResult SCcastspell(CmdSet&); +DefReturnResult SCqueryitem(CmdSet&); +DefReturnResult SCtarget(CmdSet&); +DefReturnResult SCloadscp(CmdSet&); +DefReturnResult SCScpExists(CmdSet&); +DefReturnResult SCScpSectionExists(CmdSet&); +DefReturnResult SCScpEntryExists(CmdSet&); +DefReturnResult SCGetScpValue(CmdSet&); +DefReturnResult SCGetName(CmdSet&); +DefReturnResult SCGetPlayerGuid(CmdSet&); +DefReturnResult SCGetEntry(CmdSet&); +DefReturnResult SCGetItemProtoValue(CmdSet&); +DefReturnResult SCGetObjectType(CmdSet&); +DefReturnResult SCObjectKnown(CmdSet&); +DefReturnResult SCGetPlayerPerm(CmdSet&); +DefReturnResult SCGetScriptPerm(CmdSet&); +DefReturnResult SCGetFileList(CmdSet&); +DefReturnResult SCPrintScript(CmdSet&); +DefReturnResult SCGetObjectValue(CmdSet&); +DefReturnResult SCGetRace(CmdSet&); +DefReturnResult SCGetClass(CmdSet&); +DefReturnResult SCSendWorldPacket(CmdSet&); +DefReturnResult SCGetOpcodeName(CmdSet&); +DefReturnResult SCGetOpcodeID(CmdSet&); +DefReturnResult SCBBGetPackedGuid(CmdSet&); +DefReturnResult SCBBPutPackedGuid(CmdSet&); +DefReturnResult SCGui(CmdSet&); +DefReturnResult SCSendWho(CmdSet&); +DefReturnResult SCGetObjectDistance(CmdSet&); +DefReturnResult SCSwitchOpcodeHandler(CmdSet&); +DefReturnResult SCOpcodeDisabled(CmdSet&); +DefReturnResult SCSpoofWorldPacket(CmdSet&); + +#endif diff --git a/src/Client/GUI/MCamera.h b/src/Client/GUI/MCamera.h index 187c6a6..b859641 100644 --- a/src/Client/GUI/MCamera.h +++ b/src/Client/GUI/MCamera.h @@ -1,392 +1,392 @@ -/*-----------------------------------------------------------------------------* -| headerfile MCamera.h | -| | -| version 1.20 | -| date: (29.04.2007) | -| | -| author: Michal Švantner | -| | -| for Irrlicht engine | -| firsth person and orbiting cameras | -*-----------------------------------------------------------------------------*/ - -#ifndef MCAMERA_H -#define MCAMERA_H - -#include "irrlicht/irrlicht.h" -using namespace irr; - -class MCameraFPS -{ - scene::ICameraSceneNode* camera; - f32 rotationX; - f32 rotationY; - core::vector3df direction; - -public: - MCameraFPS(scene::ISceneManager* smgr) - { - camera = smgr->addCameraSceneNode(); - rotationX = 0.0f; - rotationY = 0.0f; - direction = core::vector3df(0,0,1); - } - - ~MCameraFPS(){} - - void turnRight(f32 i) - { - rotationY += i; - if(rotationY>=360)rotationY-=360; - if(rotationY<0)rotationY+=360; - - direction = core::vector3df(0,0,1); - - core::matrix4 matrix; - matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0)); - matrix.rotateVect(direction); - - camera->setTarget(camera->getPosition() + direction); - camera->updateAbsolutePosition(); - } - - void turnLeft(f32 i) - { - rotationY -= i; - if(rotationY>=360)rotationY-=360; - if(rotationY<0)rotationY+=360; - - direction = core::vector3df(0,0,1); - - core::matrix4 matrix; - matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0)); - matrix.rotateVect(direction); - - camera->setTarget(camera->getPosition() + direction); - camera->updateAbsolutePosition(); - } - - void turnUp(f32 i) - { - rotationX += i; - if(rotationX>=360)rotationX-=360; - if(rotationX<0)rotationX+=360; - - direction = core::vector3df(0,0,1); - - core::matrix4 matrix; - matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0)); - matrix.rotateVect(direction); - - camera->setTarget(camera->getPosition() + direction); - camera->updateAbsolutePosition(); - } - - void turnDown(f32 i) - { - rotationX -= i; - if(rotationX>=360)rotationX-=360; - if(rotationX<0)rotationX+=360; - - direction = core::vector3df(0,0,1); - - core::matrix4 matrix; - matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0)); - matrix.rotateVect(direction); - - camera->setTarget(camera->getPosition() + direction); - camera->updateAbsolutePosition(); - } - - void moveForward(f32 i) - { - core::vector3df step = core::vector3df(0,0,i); - - core::matrix4 matrix; - matrix.setRotationDegrees(core::vector3df (0,rotationY,0)); - matrix.rotateVect(step); - - camera->setPosition(camera->getPosition() + step); - camera->setTarget(camera->getPosition() + direction); - camera->updateAbsolutePosition(); - } - - void moveBack(f32 i) - { - core::vector3df step = core::vector3df(0,0,-i); - - core::matrix4 matrix; - matrix.setRotationDegrees(core::vector3df (0,rotationY,0)); - matrix.rotateVect(step); - - camera->setPosition(camera->getPosition() + step); - camera->setTarget(camera->getPosition() + direction); - camera->updateAbsolutePosition(); - } - - void moveRight(f32 i) - { - core::vector3df step = core::vector3df(i,0,0); - - core::matrix4 matrix; - matrix.setRotationDegrees(core::vector3df (0,rotationY,0)); - matrix.rotateVect(step); - - camera->setPosition(camera->getPosition() + step); - camera->setTarget(camera->getPosition() + direction); - camera->updateAbsolutePosition(); - } - - void moveLeft(f32 i) - { - core::vector3df step = core::vector3df(-i,0,0); - - core::matrix4 matrix; - matrix.setRotationDegrees(core::vector3df (0,rotationY,0)); - matrix.rotateVect(step); - - camera->setPosition(camera->getPosition() + step); - camera->setTarget(camera->getPosition() + direction); - camera->updateAbsolutePosition(); - } - - void setHeight(f32 i) - { - camera->setPosition(core::vector3df(camera->getPosition().X, i, camera->getPosition().Z)); - camera->setTarget(camera->getPosition() + direction); - camera->updateAbsolutePosition(); - } - - void setPosition(core::vector3df pos) - { - camera->setPosition(pos); - camera->updateAbsolutePosition(); - } - - core::vector3df getPosition() - { - return camera->getPosition(); - } - - core::vector3df getDirection() - { - return direction; - } - - core::vector3df getTarget() - { - return camera->getTarget(); - } - - f32 getHeading() - { - return rotationY; - } - - f32 getPitch() - { - return rotationX; - } - - f32 getFarValue() - { - return camera->getFarValue(); - } - - void setFarValue(f32 f) - { - camera->setFarValue(f); - } - - f32 getNearValue() - { - return camera->getNearValue(); - } - - void setNearValue(f32 n) - { - camera->setNearValue(n); - } - - f32 getFOV() - { - return camera->getFOV(); - } - - void setFOV(f32 v) - { - camera->setFOV(v); - } - - f32 getAspectRatio() - { - return camera->getAspectRatio(); - } - - void setAspectRatio(f32 a) - { - camera->setAspectRatio(a); - } - - scene::ISceneNode* getNode() - { - return camera; - } -}; - - - - -class MCameraOrbit -{ - scene::ICameraSceneNode* camera; - f32 rotationX; - f32 rotationY; - f32 distance; - - void update() - { - core::vector3df direction = core::vector3df(0,0,distance); - - core::matrix4 matrix; - matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0)); - matrix.rotateVect(direction); - - camera->setPosition(camera->getTarget() + direction); - camera->updateAbsolutePosition(); - } - -public: - MCameraOrbit(scene::ISceneManager* smgr) - { - camera = smgr->addCameraSceneNode(); - rotationX = 0.0f; - rotationY = 0.0f; - distance = 1.0f; - camera->setTarget(core::vector3df(0,0,0)); - update(); - } - - ~MCameraOrbit(){} - - void turnRight(f32 i) - { - rotationY += i; - if(rotationY>=360)rotationY-=360; - if(rotationY<0)rotationY+=360; - update(); - } - - void turnLeft(f32 i) - { - rotationY -= i; - if(rotationY>=360)rotationY-=360; - if(rotationY<0)rotationY+=360; - update(); - } - - void turnUp(f32 i) - { - rotationX += i; - if(rotationX>=360)rotationX-=360; - if(rotationX<0)rotationX+=360; - update(); - } - - void turnDown(f32 i) - { - rotationX -= i; - if(rotationX>=360)rotationX-=360; - if(rotationX<0)rotationX+=360; - update(); - } - - core::vector3df getTarget() - { - return camera->getTarget(); - } - - void setTarget(core::vector3df target) - { - camera->setTarget(target); - update(); - } - - core::vector3df getPosition() - { - return camera->getPosition(); - } - - f32 getDistance() - { - return distance; - } - - void setDistance(f32 i) - { - distance = i; - update(); - } - - void adjustDistance(f32 i) - { - distance += i; - update(); - } - - f32 getHeading() - { - return rotationY; - } - - f32 getPitch() - { - return rotationX; - } - - f32 getFarValue() - { - return camera->getFarValue(); - } - - void setFarValue(f32 f) - { - camera->setFarValue(f); - } - - f32 getNearValue() - { - return camera->getNearValue(); - } - - void setNearValue(f32 n) - { - camera->setNearValue(n); - } - - f32 getFOV() - { - return camera->getFOV(); - } - - void setFOV(f32 v) - { - camera->setFOV(v); - } - - f32 getAspectRatio() - { - return camera->getAspectRatio(); - } - - void setAspectRatio(f32 a) - { - camera->setAspectRatio(a); - } - - scene::ISceneNode* getNode() - { - return camera; - } -}; -#endif +/*-----------------------------------------------------------------------------* +| headerfile MCamera.h | +| | +| version 1.20 | +| date: (29.04.2007) | +| | +| author: Michal Švantner | +| | +| for Irrlicht engine | +| firsth person and orbiting cameras | +*-----------------------------------------------------------------------------*/ + +#ifndef MCAMERA_H +#define MCAMERA_H + +#include "irrlicht/irrlicht.h" +using namespace irr; + +class MCameraFPS +{ + scene::ICameraSceneNode* camera; + f32 rotationX; + f32 rotationY; + core::vector3df direction; + +public: + MCameraFPS(scene::ISceneManager* smgr) + { + camera = smgr->addCameraSceneNode(); + rotationX = 0.0f; + rotationY = 0.0f; + direction = core::vector3df(0,0,1); + } + + ~MCameraFPS(){} + + void turnRight(f32 i) + { + rotationY += i; + if(rotationY>=360)rotationY-=360; + if(rotationY<0)rotationY+=360; + + direction = core::vector3df(0,0,1); + + core::matrix4 matrix; + matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0)); + matrix.rotateVect(direction); + + camera->setTarget(camera->getPosition() + direction); + camera->updateAbsolutePosition(); + } + + void turnLeft(f32 i) + { + rotationY -= i; + if(rotationY>=360)rotationY-=360; + if(rotationY<0)rotationY+=360; + + direction = core::vector3df(0,0,1); + + core::matrix4 matrix; + matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0)); + matrix.rotateVect(direction); + + camera->setTarget(camera->getPosition() + direction); + camera->updateAbsolutePosition(); + } + + void turnUp(f32 i) + { + rotationX += i; + if(rotationX>=360)rotationX-=360; + if(rotationX<0)rotationX+=360; + + direction = core::vector3df(0,0,1); + + core::matrix4 matrix; + matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0)); + matrix.rotateVect(direction); + + camera->setTarget(camera->getPosition() + direction); + camera->updateAbsolutePosition(); + } + + void turnDown(f32 i) + { + rotationX -= i; + if(rotationX>=360)rotationX-=360; + if(rotationX<0)rotationX+=360; + + direction = core::vector3df(0,0,1); + + core::matrix4 matrix; + matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0)); + matrix.rotateVect(direction); + + camera->setTarget(camera->getPosition() + direction); + camera->updateAbsolutePosition(); + } + + void moveForward(f32 i) + { + core::vector3df step = core::vector3df(0,0,i); + + core::matrix4 matrix; + matrix.setRotationDegrees(core::vector3df (0,rotationY,0)); + matrix.rotateVect(step); + + camera->setPosition(camera->getPosition() + step); + camera->setTarget(camera->getPosition() + direction); + camera->updateAbsolutePosition(); + } + + void moveBack(f32 i) + { + core::vector3df step = core::vector3df(0,0,-i); + + core::matrix4 matrix; + matrix.setRotationDegrees(core::vector3df (0,rotationY,0)); + matrix.rotateVect(step); + + camera->setPosition(camera->getPosition() + step); + camera->setTarget(camera->getPosition() + direction); + camera->updateAbsolutePosition(); + } + + void moveRight(f32 i) + { + core::vector3df step = core::vector3df(i,0,0); + + core::matrix4 matrix; + matrix.setRotationDegrees(core::vector3df (0,rotationY,0)); + matrix.rotateVect(step); + + camera->setPosition(camera->getPosition() + step); + camera->setTarget(camera->getPosition() + direction); + camera->updateAbsolutePosition(); + } + + void moveLeft(f32 i) + { + core::vector3df step = core::vector3df(-i,0,0); + + core::matrix4 matrix; + matrix.setRotationDegrees(core::vector3df (0,rotationY,0)); + matrix.rotateVect(step); + + camera->setPosition(camera->getPosition() + step); + camera->setTarget(camera->getPosition() + direction); + camera->updateAbsolutePosition(); + } + + void setHeight(f32 i) + { + camera->setPosition(core::vector3df(camera->getPosition().X, i, camera->getPosition().Z)); + camera->setTarget(camera->getPosition() + direction); + camera->updateAbsolutePosition(); + } + + void setPosition(core::vector3df pos) + { + camera->setPosition(pos); + camera->updateAbsolutePosition(); + } + + core::vector3df getPosition() + { + return camera->getPosition(); + } + + core::vector3df getDirection() + { + return direction; + } + + core::vector3df getTarget() + { + return camera->getTarget(); + } + + f32 getHeading() + { + return rotationY; + } + + f32 getPitch() + { + return rotationX; + } + + f32 getFarValue() + { + return camera->getFarValue(); + } + + void setFarValue(f32 f) + { + camera->setFarValue(f); + } + + f32 getNearValue() + { + return camera->getNearValue(); + } + + void setNearValue(f32 n) + { + camera->setNearValue(n); + } + + f32 getFOV() + { + return camera->getFOV(); + } + + void setFOV(f32 v) + { + camera->setFOV(v); + } + + f32 getAspectRatio() + { + return camera->getAspectRatio(); + } + + void setAspectRatio(f32 a) + { + camera->setAspectRatio(a); + } + + scene::ISceneNode* getNode() + { + return camera; + } +}; + + + + +class MCameraOrbit +{ + scene::ICameraSceneNode* camera; + f32 rotationX; + f32 rotationY; + f32 distance; + + void update() + { + core::vector3df direction = core::vector3df(0,0,distance); + + core::matrix4 matrix; + matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0)); + matrix.rotateVect(direction); + + camera->setPosition(camera->getTarget() + direction); + camera->updateAbsolutePosition(); + } + +public: + MCameraOrbit(scene::ISceneManager* smgr) + { + camera = smgr->addCameraSceneNode(); + rotationX = 0.0f; + rotationY = 0.0f; + distance = 1.0f; + camera->setTarget(core::vector3df(0,0,0)); + update(); + } + + ~MCameraOrbit(){} + + void turnRight(f32 i) + { + rotationY += i; + if(rotationY>=360)rotationY-=360; + if(rotationY<0)rotationY+=360; + update(); + } + + void turnLeft(f32 i) + { + rotationY -= i; + if(rotationY>=360)rotationY-=360; + if(rotationY<0)rotationY+=360; + update(); + } + + void turnUp(f32 i) + { + rotationX += i; + if(rotationX>=360)rotationX-=360; + if(rotationX<0)rotationX+=360; + update(); + } + + void turnDown(f32 i) + { + rotationX -= i; + if(rotationX>=360)rotationX-=360; + if(rotationX<0)rotationX+=360; + update(); + } + + core::vector3df getTarget() + { + return camera->getTarget(); + } + + void setTarget(core::vector3df target) + { + camera->setTarget(target); + update(); + } + + core::vector3df getPosition() + { + return camera->getPosition(); + } + + f32 getDistance() + { + return distance; + } + + void setDistance(f32 i) + { + distance = i; + update(); + } + + void adjustDistance(f32 i) + { + distance += i; + update(); + } + + f32 getHeading() + { + return rotationY; + } + + f32 getPitch() + { + return rotationX; + } + + f32 getFarValue() + { + return camera->getFarValue(); + } + + void setFarValue(f32 f) + { + camera->setFarValue(f); + } + + f32 getNearValue() + { + return camera->getNearValue(); + } + + void setNearValue(f32 n) + { + camera->setNearValue(n); + } + + f32 getFOV() + { + return camera->getFOV(); + } + + void setFOV(f32 v) + { + camera->setFOV(v); + } + + f32 getAspectRatio() + { + return camera->getAspectRatio(); + } + + void setAspectRatio(f32 a) + { + camera->setAspectRatio(a); + } + + scene::ISceneNode* getNode() + { + return camera; + } +}; +#endif diff --git a/src/Client/GUI/MInput.h b/src/Client/GUI/MInput.h index 88bb028..9abc0a8 100644 --- a/src/Client/GUI/MInput.h +++ b/src/Client/GUI/MInput.h @@ -1,160 +1,160 @@ -/*-----------------------------------------------------------------------------* -| headerfile MInput.h | -| | -| version 1.10 | -| date: (29.04.2007) | -| | -| author: Michal Švantner | -| | -| for Irrlicht engine | -| store keyboard and mouse input in structures "key" and "mouse" | -*-----------------------------------------------------------------------------*/ - -#ifndef MINPUT_H -#define MINPUT_H - -#include "irrlicht/irrlicht.h" -using namespace irr; - -struct IKeys -{ - bool pressed(EKEY_CODE keycode) - { - return code[keycode]; - } - - bool pressed_once(EKEY_CODE keycode) - { - if(code[keycode]) - { - code[keycode] = false; - return true; - } - return false; - } - - void reset() - { - for(s32 i=0; iRun(); -} - -PseuGUI *PseuGUIRunnable::GetGUI(void) -{ - return _gui; -} - -PseuGUIRunnable::~PseuGUIRunnable() -{ - delete _gui; -} - -PseuGUI::PseuGUI() -{ - _xres = 640; - _yres = 480; - _colordepth = 32; - _shadows = false; - _windowed = true; - _vsync = false; - _initialized = false; - _mustdie = false; - _driverType = video::EDT_BURNINGSVIDEO; // nulldevice makes not really a sense to display stuff - _scenestate = _scenestate_new = SCENESTATE_NULL; - _smgr = NULL; - _device = NULL; - _guienv = NULL; - _scene = NULL; - _passtime = _lastpasstime = _passtimediff = 0; - _updateWorldPos = false; -} - -PseuGUI::~PseuGUI() -{ - this->Cancel(); - _instance->DeleteGUI(); // this makes the instance set its gui ptr to NULL - logdebug("PseuGUI::~PseuGUI()"); -} - -void PseuGUI::SetDriver(uint8 driverId) -{ - switch(driverId) - { - case DIRECTX9: _driverType = video::EDT_DIRECT3D9; break; - case DIRECTX8: _driverType = video::EDT_DIRECT3D8; break; - case OPENGL: _driverType = video::EDT_OPENGL; break; - case SOFTWARE: _driverType = video::EDT_SOFTWARE; break; - case BURNINGSVIDEO: _driverType = video::EDT_BURNINGSVIDEO; break; - case NULLDEVICE: _driverType = video::EDT_NULL; break; - default: _driverType = video::EDT_BURNINGSVIDEO; // if no valid driver detected, use software - } - - // TODO: add support for changing driver during runtime? -} - -void PseuGUI::SetResolution(uint16 x, uint16 y, uint16 depth) -{ - _xres = x; - _yres = y; - _colordepth = depth; -} - -void PseuGUI::SetWindowed(bool b) -{ - _windowed = b; - // see PseuGUI::Init(): !_windowed == fullscreen -} - -void PseuGUI::SetVSync(bool b) -{ - _vsync = b; -} - -void PseuGUI::UseShadows(bool b) -{ - _shadows = b; -} - -// if this fuction is called from another thread the device will not work correctly. o_O -void PseuGUI::_Init(void) -{ - _device = createDevice(_driverType,dimension2d(_xres,_yres),_colordepth,!_windowed,_shadows,_vsync); - if(!_device) - { - logerror("PseuGUI: Can't use specified video driver, trying software mode..."); - _device = createDevice(video::EDT_SOFTWARE,dimension2d(_xres,_yres),_colordepth,!_windowed,false,false); - if(!_device) - { - logerror("ERROR: PseuGUI::_Init() failed, no video driver available!"); - return; - } - else - { - logerror("PseuGUI: Software mode OK!"); - } - } - DEBUG(logdebug("PseuGUI::Init() _device=%X",_device)); - _device->setWindowCaption(L"PseuWoW - Initializing"); - _device->setResizeAble(true); - _driver = _device->getVideoDriver(); - _smgr = _device->getSceneManager(); - _guienv = _device->getGUIEnvironment(); - _timer = _device->getTimer(); - //... - _initialized = true; -} - -void PseuGUI::Cancel(void) -{ - DEBUG(logdebug("PseuGUI::Cancel()")); - - if(_scene) - { - _scene->OnDelete(); - delete _scene; - _scene = NULL; - } - if(_device) - { - _device->drop(); - _device = NULL; - - } - _mustdie = true; -} - -void PseuGUI::Shutdown(void) -{ - DEBUG(logdebug("PseuGUI::Shutdown()")); - _mustdie = true; -} - -void PseuGUI::Run(void) -{ - if(!_initialized) - this->_Init(); - if(!_initialized) // recheck - { - logerror("PseuGUI: not initialized, using non-GUI mode"); - Cancel(); - return; - } - - DEBUG(logdebug("PseuGUI::Run() _device=%X",_device)); - - int lastFPS = -1, fps = -1; - - while(_device && _device->run() && !_mustdie) - { - _lastpasstime = _passtime; - _passtime = _timer->getTime(); - _passtimediff = _passtime - _lastpasstime; - // _HandleWindowResize(); // not yet used; doesnt work - - if (!_device->isWindowActive()) - { - _device->sleep(10); // save cpu & gpu power if not focused - } - - try - { - _UpdateSceneState(); - - if(_scene && _initialized) - { - if(_updateWorldPos) - SetWorldPosition(_worldpos_tmp); - _scene->OnUpdate(_passtimediff); - } - - _driver->beginScene(true, true, 0); - - DrawCurrentScene(); - - _smgr->drawAll(); - _guienv->drawAll(); - - _driver->endScene(); - } - catch(...) - { - logerror("Unhandled exception in PseuGUI::Run() device=%X smgr=%X objects:%u", _device, _smgr, domgr.StorageSize()); - } - - fps = _driver->getFPS(); - - if (lastFPS != fps) - { - core::stringw str = L"PseuWoW ["; - str += _driver->getName(); - str += "] FPS:"; - str += fps; - - _device->setWindowCaption(str.c_str()); - - lastFPS = fps; - } - - } - DEBUG(logdebug("PseuGUI::Run() finished")); - Cancel(); // already got shut down somehow, we can now safely cancel and drop the device -} - -// called from ObjMgr::Remove(guid) -void PseuGUI::NotifyObjectDeletion(uint64 guid) -{ - domgr.Delete(guid); -} - -// called from ObjMgr::Add(Object*) -void PseuGUI::NotifyObjectCreation(Object *o) -{ - DrawObject *d = new DrawObject(_smgr,o); - domgr.Add(o->GetGUID(),d); -} - -void PseuGUI::SetInstance(PseuInstance* in) -{ - _instance = in; -} - -void PseuGUI::SetSceneState(SceneState state) -{ - _scenestate_new = state; // will be applied at next cycle -} - -void PseuGUI::_UpdateSceneState(void) -{ - if(_scenestate != _scenestate_new && _smgr) - { - if(_scene) - { - _scene->OnDelete(); - delete _scene; - } - _smgr->clear(); - _guienv->clear(); - - _scenestate = _scenestate_new; - - logdebug("PseuGUI: switched to SceneState %u", _scenestate); - - switch (_scenestate) - { - case SCENESTATE_GUISTART: _scene = new SceneGuiStart(this); break; - case SCENESTATE_WORLD: _scene = new SceneWorld(this); break; - default: _scene = new Scene(this); // will draw nothing, just yield the gui - } - _scene->SetState(_scenestate); - - logdebug("PseuGUI: scene created."); - } -} - -void PseuGUI::DrawCurrentScene(void) -{ - if(_scene && _initialized) - _scene->OnDraw(); -} - -// used to get our current WorldPosition -WorldPosition PseuGUI::GetWorldPosition(void) -{ - if(_scene && _scene->GetState() == SCENESTATE_WORLD) - { - return ((SceneWorld*)_scene)->GetWorldPosition(); - } - return WorldPosition(); -} - -// used to notify the SceneWorld about a position change the server sent to us -void PseuGUI::SetWorldPosition(WorldPosition wp) -{ - // buffer new position if the scene is not (yet) a world scene - _worldpos_tmp = wp; - if(_scene && _scene->GetState() == SCENESTATE_WORLD) - { - _updateWorldPos = false; - ((SceneWorld*)_scene)->SetWorldPosition(wp); - } - else - { - _updateWorldPos = true; - } -} - -void PseuGUI::_HandleWindowResize(void) -{ - dimension2d scrn = _driver->getScreenSize(); - if(_screendimension.Width != scrn.Width) - { - scrn.Height = s32(scrn.Width * 0.8f); // for now use aspect ratio 5:4 - _screendimension = scrn; - _driver->OnResize(scrn); - DEBUG(logdebug("DEBUG: Width resize handled, Height adjusted")); - - } - else if(_screendimension.Height != scrn.Height) - { - scrn.Width = s32(scrn.Height * 1.25); // 5:4 here too - _screendimension = scrn; - _driver->OnResize(scrn); - DEBUG(logdebug("DEBUG: Height resize handled, Width adjusted")); - - } - // TODO: how to set irrlicht window size ?! - -} +#include "common.h" +#include "irrlicht/irrlicht.h" +#include "Object.h" +#include "DrawObject.h" +#include "PseuWoW.h" +#include "Scene.h" +#include "PseuGUI.h" + +PseuGUIRunnable::PseuGUIRunnable() +{ + _gui = new PseuGUI(); +} + +void PseuGUIRunnable::run(void) +{ + _gui->Run(); +} + +PseuGUI *PseuGUIRunnable::GetGUI(void) +{ + return _gui; +} + +PseuGUIRunnable::~PseuGUIRunnable() +{ + delete _gui; +} + +PseuGUI::PseuGUI() +{ + _xres = 640; + _yres = 480; + _colordepth = 32; + _shadows = false; + _windowed = true; + _vsync = false; + _initialized = false; + _mustdie = false; + _driverType = video::EDT_BURNINGSVIDEO; // nulldevice makes not really a sense to display stuff + _scenestate = _scenestate_new = SCENESTATE_NULL; + _smgr = NULL; + _device = NULL; + _guienv = NULL; + _scene = NULL; + _passtime = _lastpasstime = _passtimediff = 0; + _updateWorldPos = false; +} + +PseuGUI::~PseuGUI() +{ + this->Cancel(); + _instance->DeleteGUI(); // this makes the instance set its gui ptr to NULL + logdebug("PseuGUI::~PseuGUI()"); +} + +void PseuGUI::SetDriver(uint8 driverId) +{ + switch(driverId) + { + case DIRECTX9: _driverType = video::EDT_DIRECT3D9; break; + case DIRECTX8: _driverType = video::EDT_DIRECT3D8; break; + case OPENGL: _driverType = video::EDT_OPENGL; break; + case SOFTWARE: _driverType = video::EDT_SOFTWARE; break; + case BURNINGSVIDEO: _driverType = video::EDT_BURNINGSVIDEO; break; + case NULLDEVICE: _driverType = video::EDT_NULL; break; + default: _driverType = video::EDT_BURNINGSVIDEO; // if no valid driver detected, use software + } + + // TODO: add support for changing driver during runtime? +} + +void PseuGUI::SetResolution(uint16 x, uint16 y, uint16 depth) +{ + _xres = x; + _yres = y; + _colordepth = depth; +} + +void PseuGUI::SetWindowed(bool b) +{ + _windowed = b; + // see PseuGUI::Init(): !_windowed == fullscreen +} + +void PseuGUI::SetVSync(bool b) +{ + _vsync = b; +} + +void PseuGUI::UseShadows(bool b) +{ + _shadows = b; +} + +// if this fuction is called from another thread the device will not work correctly. o_O +void PseuGUI::_Init(void) +{ + _device = createDevice(_driverType,dimension2d(_xres,_yres),_colordepth,!_windowed,_shadows,_vsync); + if(!_device) + { + logerror("PseuGUI: Can't use specified video driver, trying software mode..."); + _device = createDevice(video::EDT_SOFTWARE,dimension2d(_xres,_yres),_colordepth,!_windowed,false,false); + if(!_device) + { + logerror("ERROR: PseuGUI::_Init() failed, no video driver available!"); + return; + } + else + { + logerror("PseuGUI: Software mode OK!"); + } + } + DEBUG(logdebug("PseuGUI::Init() _device=%X",_device)); + _device->setWindowCaption(L"PseuWoW - Initializing"); + _device->setResizeAble(true); + _driver = _device->getVideoDriver(); + _smgr = _device->getSceneManager(); + _guienv = _device->getGUIEnvironment(); + _timer = _device->getTimer(); + //... + _initialized = true; +} + +void PseuGUI::Cancel(void) +{ + DEBUG(logdebug("PseuGUI::Cancel()")); + + if(_scene) + { + _scene->OnDelete(); + delete _scene; + _scene = NULL; + } + if(_device) + { + _device->drop(); + _device = NULL; + + } + _mustdie = true; +} + +void PseuGUI::Shutdown(void) +{ + DEBUG(logdebug("PseuGUI::Shutdown()")); + _mustdie = true; +} + +void PseuGUI::Run(void) +{ + if(!_initialized) + this->_Init(); + if(!_initialized) // recheck + { + logerror("PseuGUI: not initialized, using non-GUI mode"); + Cancel(); + return; + } + + DEBUG(logdebug("PseuGUI::Run() _device=%X",_device)); + + int lastFPS = -1, fps = -1; + + while(_device && _device->run() && !_mustdie) + { + _lastpasstime = _passtime; + _passtime = _timer->getTime(); + _passtimediff = _passtime - _lastpasstime; + // _HandleWindowResize(); // not yet used; doesnt work + + if (!_device->isWindowActive()) + { + _device->sleep(10); // save cpu & gpu power if not focused + } + + try + { + _UpdateSceneState(); + + if(_scene && _initialized) + { + if(_updateWorldPos) + SetWorldPosition(_worldpos_tmp); + _scene->OnUpdate(_passtimediff); + } + + _driver->beginScene(true, true, 0); + + DrawCurrentScene(); + + _smgr->drawAll(); + _guienv->drawAll(); + + _driver->endScene(); + } + catch(...) + { + logerror("Unhandled exception in PseuGUI::Run() device=%X smgr=%X objects:%u", _device, _smgr, domgr.StorageSize()); + } + + fps = _driver->getFPS(); + + if (lastFPS != fps) + { + core::stringw str = L"PseuWoW ["; + str += _driver->getName(); + str += "] FPS:"; + str += fps; + + _device->setWindowCaption(str.c_str()); + + lastFPS = fps; + } + + } + DEBUG(logdebug("PseuGUI::Run() finished")); + Cancel(); // already got shut down somehow, we can now safely cancel and drop the device +} + +// called from ObjMgr::Remove(guid) +void PseuGUI::NotifyObjectDeletion(uint64 guid) +{ + domgr.Delete(guid); +} + +// called from ObjMgr::Add(Object*) +void PseuGUI::NotifyObjectCreation(Object *o) +{ + DrawObject *d = new DrawObject(_smgr,o); + domgr.Add(o->GetGUID(),d); +} + +void PseuGUI::SetInstance(PseuInstance* in) +{ + _instance = in; +} + +void PseuGUI::SetSceneState(SceneState state) +{ + _scenestate_new = state; // will be applied at next cycle +} + +void PseuGUI::_UpdateSceneState(void) +{ + if(_scenestate != _scenestate_new && _smgr) + { + if(_scene) + { + _scene->OnDelete(); + delete _scene; + } + _smgr->clear(); + _guienv->clear(); + + _scenestate = _scenestate_new; + + logdebug("PseuGUI: switched to SceneState %u", _scenestate); + + switch (_scenestate) + { + case SCENESTATE_GUISTART: _scene = new SceneGuiStart(this); break; + case SCENESTATE_WORLD: _scene = new SceneWorld(this); break; + default: _scene = new Scene(this); // will draw nothing, just yield the gui + } + _scene->SetState(_scenestate); + + logdebug("PseuGUI: scene created."); + } +} + +void PseuGUI::DrawCurrentScene(void) +{ + if(_scene && _initialized) + _scene->OnDraw(); +} + +// used to get our current WorldPosition +WorldPosition PseuGUI::GetWorldPosition(void) +{ + if(_scene && _scene->GetState() == SCENESTATE_WORLD) + { + return ((SceneWorld*)_scene)->GetWorldPosition(); + } + return WorldPosition(); +} + +// used to notify the SceneWorld about a position change the server sent to us +void PseuGUI::SetWorldPosition(WorldPosition wp) +{ + // buffer new position if the scene is not (yet) a world scene + _worldpos_tmp = wp; + if(_scene && _scene->GetState() == SCENESTATE_WORLD) + { + _updateWorldPos = false; + ((SceneWorld*)_scene)->SetWorldPosition(wp); + } + else + { + _updateWorldPos = true; + } +} + +void PseuGUI::_HandleWindowResize(void) +{ + dimension2d scrn = _driver->getScreenSize(); + if(_screendimension.Width != scrn.Width) + { + scrn.Height = s32(scrn.Width * 0.8f); // for now use aspect ratio 5:4 + _screendimension = scrn; + _driver->OnResize(scrn); + DEBUG(logdebug("DEBUG: Width resize handled, Height adjusted")); + + } + else if(_screendimension.Height != scrn.Height) + { + scrn.Width = s32(scrn.Height * 1.25); // 5:4 here too + _screendimension = scrn; + _driver->OnResize(scrn); + DEBUG(logdebug("DEBUG: Height resize handled, Width adjusted")); + + } + // TODO: how to set irrlicht window size ?! + +} diff --git a/src/Client/GUI/PseuGUI.h b/src/Client/GUI/PseuGUI.h index 17e4e9a..e338aa9 100644 --- a/src/Client/GUI/PseuGUI.h +++ b/src/Client/GUI/PseuGUI.h @@ -1,110 +1,110 @@ -#ifndef PSEUGUI_H -#define PSEUGUI_H - -#include "irrlicht/irrlicht.h" -#include "DrawObjMgr.h" -#include "World.h" - -class PseuGUI; -class Object; -class PseuInstance; -class Scene; - -enum SceneState -{ - SCENESTATE_NULL, - SCENESTATE_GUISTART, - SCENESTATE_LOGINSCREEN, - SCENESTATE_CHARACTERSELECTION, - SCENESTATE_LOADING, - SCENESTATE_WORLD -}; - -enum DriverIDs -{ - NULLDEVICE = 0, - SOFTWARE = 1, - BURNINGSVIDEO = 2, - OPENGL = 3, - DIRECTX8 = 4, - DIRECTX9 = 5, -}; - -class PseuGUIRunnable : public ZThread::Runnable -{ -public: - PseuGUIRunnable(); - ~PseuGUIRunnable(); - void run(void); - PseuGUI *GetGUI(void); -private: - PseuGUI* _gui; -}; - - -class PseuGUI -{ - // too bad friends are not inherited... - friend class Scene; - friend class SceneWorld; - friend class SceneGuiStart; - // ... - -public: - PseuGUI(); - ~PseuGUI(); - - void SetInstance(PseuInstance*); - inline PseuInstance *GetInstance(void) { return _instance; } - void Run(void); - void SetDriver(uint8); - void SetResolution(uint16 x, uint16 y, uint16 depth=32); - void SetWindowed(bool); - void SetVSync(bool); - void UseShadows(bool); - void Cancel(void); - void Shutdown(void); - inline bool IsInitialized(void) { return _initialized; } - - inline bool MustDie(void) { return _mustdie; } - - // interfaces to tell the gui what to draw - void NotifyObjectDeletion(uint64 guid); - void NotifyObjectCreation(Object *o); - - // scenes - void DrawCurrentScene(void); - void SetSceneState(SceneState); - - // helpers - WorldPosition GetWorldPosition(void); - void SetWorldPosition(WorldPosition); - -private: - void _Init(void); - void _UpdateSceneState(void); - void _HandleWindowResize(void); - uint16 _xres,_yres,_colordepth; - bool _windowed,_vsync,_shadows; - bool _initialized,_mustdie; - irr::IrrlichtDevice *_device; - irr::video::IVideoDriver* _driver; - irr::scene::ISceneManager* _smgr; - irr::gui::IGUIEnvironment* _guienv; - irr::video::E_DRIVER_TYPE _driverType; - DrawObjMgr domgr; - PseuInstance *_instance; - SceneState _scenestate, _scenestate_new; - Scene *_scene; - irr::ITimer *_timer; - uint32 _passtime, _lastpasstime, _passtimediff; - irr::core::dimension2d _screendimension; - WorldPosition _worldpos_tmp; - bool _updateWorldPos; - -}; - - - -#endif - +#ifndef PSEUGUI_H +#define PSEUGUI_H + +#include "irrlicht/irrlicht.h" +#include "DrawObjMgr.h" +#include "World.h" + +class PseuGUI; +class Object; +class PseuInstance; +class Scene; + +enum SceneState +{ + SCENESTATE_NULL, + SCENESTATE_GUISTART, + SCENESTATE_LOGINSCREEN, + SCENESTATE_CHARACTERSELECTION, + SCENESTATE_LOADING, + SCENESTATE_WORLD +}; + +enum DriverIDs +{ + NULLDEVICE = 0, + SOFTWARE = 1, + BURNINGSVIDEO = 2, + OPENGL = 3, + DIRECTX8 = 4, + DIRECTX9 = 5, +}; + +class PseuGUIRunnable : public ZThread::Runnable +{ +public: + PseuGUIRunnable(); + ~PseuGUIRunnable(); + void run(void); + PseuGUI *GetGUI(void); +private: + PseuGUI* _gui; +}; + + +class PseuGUI +{ + // too bad friends are not inherited... + friend class Scene; + friend class SceneWorld; + friend class SceneGuiStart; + // ... + +public: + PseuGUI(); + ~PseuGUI(); + + void SetInstance(PseuInstance*); + inline PseuInstance *GetInstance(void) { return _instance; } + void Run(void); + void SetDriver(uint8); + void SetResolution(uint16 x, uint16 y, uint16 depth=32); + void SetWindowed(bool); + void SetVSync(bool); + void UseShadows(bool); + void Cancel(void); + void Shutdown(void); + inline bool IsInitialized(void) { return _initialized; } + + inline bool MustDie(void) { return _mustdie; } + + // interfaces to tell the gui what to draw + void NotifyObjectDeletion(uint64 guid); + void NotifyObjectCreation(Object *o); + + // scenes + void DrawCurrentScene(void); + void SetSceneState(SceneState); + + // helpers + WorldPosition GetWorldPosition(void); + void SetWorldPosition(WorldPosition); + +private: + void _Init(void); + void _UpdateSceneState(void); + void _HandleWindowResize(void); + uint16 _xres,_yres,_colordepth; + bool _windowed,_vsync,_shadows; + bool _initialized,_mustdie; + irr::IrrlichtDevice *_device; + irr::video::IVideoDriver* _driver; + irr::scene::ISceneManager* _smgr; + irr::gui::IGUIEnvironment* _guienv; + irr::video::E_DRIVER_TYPE _driverType; + DrawObjMgr domgr; + PseuInstance *_instance; + SceneState _scenestate, _scenestate_new; + Scene *_scene; + irr::ITimer *_timer; + uint32 _passtime, _lastpasstime, _passtimediff; + irr::core::dimension2d _screendimension; + WorldPosition _worldpos_tmp; + bool _updateWorldPos; + +}; + + + +#endif + diff --git a/src/Client/GUI/Scene.cpp b/src/Client/GUI/Scene.cpp index c9c83a3..b99b314 100644 --- a/src/Client/GUI/Scene.cpp +++ b/src/Client/GUI/Scene.cpp @@ -1,31 +1,31 @@ -#include "common.h" -#include "PseuGUI.h" -#include "PseuWoW.h" -#include "Scene.h" - -Scene::Scene(PseuGUI *g) -{ - gui = g; - device = gui->_device; - driver = gui->_driver; - smgr = gui->_smgr; - guienv = gui->_guienv; -} - -void Scene::OnDraw(void) -{ - device->yield(); -} - -void Scene::OnDelete(void) -{ -} - -void Scene::OnUpdate(s32) -{ -} - -Scene::~Scene() -{ - DEBUG(logdebug("Scene::~Scene()")); -} +#include "common.h" +#include "PseuGUI.h" +#include "PseuWoW.h" +#include "Scene.h" + +Scene::Scene(PseuGUI *g) +{ + gui = g; + device = gui->_device; + driver = gui->_driver; + smgr = gui->_smgr; + guienv = gui->_guienv; +} + +void Scene::OnDraw(void) +{ + device->yield(); +} + +void Scene::OnDelete(void) +{ +} + +void Scene::OnUpdate(s32) +{ +} + +Scene::~Scene() +{ + DEBUG(logdebug("Scene::~Scene()")); +} diff --git a/src/Client/GUI/SceneGuiStart.cpp b/src/Client/GUI/SceneGuiStart.cpp index 8370abd..a736d03 100644 --- a/src/Client/GUI/SceneGuiStart.cpp +++ b/src/Client/GUI/SceneGuiStart.cpp @@ -1,33 +1,33 @@ -#include "common.h" -#include "PseuGUI.h" -#include "PseuWoW.h" -#include "Scene.h" - - -SceneGuiStart::SceneGuiStart(PseuGUI *gui) : Scene(gui) -{ - - irrlogo = guienv->addImage(driver->getTexture("data/misc/irrlichtlogo.png"), core::position2d(5,5)); - char *fn; - switch(gui->_driverType) - { - case DIRECTX8: - case DIRECTX9: - fn = "data/misc/directxlogo.png"; - break; - - case OPENGL: - fn = "data/misc/opengllogo.png"; - break; - - default: - fn = "data/misc/burninglogo.png"; - } - driverlogo = guienv->addImage(driver->getTexture(fn), core::position2d(50,50)); - -} - -void SceneGuiStart::OnDelete(void) -{ - // not necessary to delete the images, because they are deleted by guienv->clear() -} +#include "common.h" +#include "PseuGUI.h" +#include "PseuWoW.h" +#include "Scene.h" + + +SceneGuiStart::SceneGuiStart(PseuGUI *gui) : Scene(gui) +{ + + irrlogo = guienv->addImage(driver->getTexture("data/misc/irrlichtlogo.png"), core::position2d(5,5)); + char *fn; + switch(gui->_driverType) + { + case DIRECTX8: + case DIRECTX9: + fn = "data/misc/directxlogo.png"; + break; + + case OPENGL: + fn = "data/misc/opengllogo.png"; + break; + + default: + fn = "data/misc/burninglogo.png"; + } + driverlogo = guienv->addImage(driver->getTexture(fn), core::position2d(50,50)); + +} + +void SceneGuiStart::OnDelete(void) +{ + // not necessary to delete the images, because they are deleted by guienv->clear() +} diff --git a/src/Client/GUI/SceneWorld.cpp b/src/Client/GUI/SceneWorld.cpp index 813cc60..7ff78fb 100644 --- a/src/Client/GUI/SceneWorld.cpp +++ b/src/Client/GUI/SceneWorld.cpp @@ -1,376 +1,376 @@ -#include -#include -#include "common.h" -#include "PseuGUI.h" -#include "PseuWoW.h" -#include "Scene.h" -#include "MapTile.h" -#include "MapMgr.h" -#include "ShTlTerrainSceneNode.h" -#include "MCamera.h" -#include "MInput.h" -#include "WorldSession.h" -#include "World.h" - -#define MOUSE_SENSIVITY 0.5f -#define ANGLE_STEP (M_PI/180) -#define DEG_TO_RAD(x) ((x)*ANGLE_STEP) -#define RAD_TO_DEG(x) ((x)/ANGLE_STEP) -#define RAD_FIX(x) ( (x)>(2*M_PI) ? ((x)-(2*M_PI)) : (x) ) -#define DEG_FIX(x) ( (x)>360 ? ((x)-360) : (x) ) - -#define COORD_SCALE_VALUE_X 0.336f -#define COORD_SCALE_VALUE_Y 0.2f - - - -SceneWorld::SceneWorld(PseuGUI *g) : Scene(g) -{ - DEBUG(logdebug("SceneWorld: Initializing...")); - debugmode = false; - - // store some pointers right now to prevent repeated ptr dereferencing later (speeds up code) - gui = g; - wsession = gui->GetInstance()->GetWSession(); - mapmgr = wsession->GetWorld()->GetMapMgr(); - - // TODO: hardcoded for now, make this adjustable later - float fogdist = 150; - - ILightSceneNode* light = smgr->addLightSceneNode(0, core::vector3df(0,0,0), SColorf(255, 255, 255, 255), 1000.0f); - SLight ldata = light->getLightData(); - ldata.AmbientColor = video::SColorf(0.2f,0.2f,0.2f); - ldata.DiffuseColor = video::SColorf(1.0f,1.0f,1.0f); - ldata.Type = video::ELT_DIRECTIONAL; - ldata.Position = core::vector3df(-10,5,-5); - light->setLightData(ldata); - - eventrecv = new MyEventReceiver(); - device->setEventReceiver(eventrecv); - - camera = new MCameraFPS(smgr); - camera->setNearValue(0.1f); - camera->setFarValue(12000); // TODO: adjust - - debugText = guienv->addStaticText(L"< debug text >",rect(0,0,driver->getScreenSize().Width,30),true,true,0,-1,true); - - smgr->addSkyDomeSceneNode(driver->getTexture("data/misc/sky.jpg"),64,64,1.0f,2.0f); - - driver->setFog(video::SColor(0,100,101,190), true, fogdist, fogdist + 30, 0.02f); - - // setup cursor - device->getCursorControl()->setVisible(false); - - InitTerrain(); - UpdateTerrain(); - - DEBUG(logdebug("SceneWorld: Init done!")); -} - -void SceneWorld::OnUpdate(s32 timediff) -{ - static position2d mouse_pos; - - UpdateTerrain(); - - bool mouse_pressed_left = eventrecv->mouse.left_pressed(); - bool mouse_pressed_right = eventrecv->mouse.right_pressed(); - float timediff_f = timediff / 1000.0f; - - if(eventrecv->key.pressed(KEY_KEY_W) || (mouse_pressed_left && mouse_pressed_right)) - camera->moveForward(50 * timediff_f); - if(eventrecv->key.pressed(KEY_KEY_S)) - camera->moveBack(50 * timediff_f); - if(eventrecv->key.pressed(KEY_KEY_E)) - camera->moveRight(50 * timediff_f); - if(eventrecv->key.pressed(KEY_KEY_Q)) - camera->moveLeft(50 * timediff_f); - - // if right mouse button pressed, move in axis, if not, turn camera - if(eventrecv->key.pressed(KEY_KEY_D)) - { - if(mouse_pressed_right) - camera->moveRight(50 * timediff_f); - else - camera->turnRight(timediff_f * M_PI * 25); - } - if(eventrecv->key.pressed(KEY_KEY_A)) - { - if(mouse_pressed_right) - camera->moveLeft(50 * timediff_f); - else - camera->turnLeft(timediff_f * M_PI * 25); - } - - if(eventrecv->key.pressed_once(KEY_BACK)) - { - debugmode = !debugmode; - if(debugmode) - { - terrain->setDebugDataVisible(EDS_FULL); - } - else - { - terrain->setDebugDataVisible(EDS_OFF); - } - } - - if(eventrecv->key.pressed_once(KEY_INSERT)) - { - IImage *scrnshot = driver->createScreenShot(); - if(scrnshot) - { - CreateDir("screenshots"); - std::string date = getDateString(); - for(uint32 i = 0; i < date.length(); i++) - { - if(date[i] == ':') - date[i] = '_'; - } - if(date[date.length()-1] == ' ') - { - date = date.substr(0,date.length()-2); - } - driver->writeImageToFile(scrnshot, ("screenshots/PseuWoW " + date + ".jpg").c_str(), device->getTimer()->getRealTime()); - scrnshot->drop(); - } - } - - if(mouse_pressed_left || mouse_pressed_right) - { - //if(device->getCursorControl()->isVisible()) - //device->getCursorControl()->setVisible(false); - if(mouse_pos != device->getCursorControl()->getPosition()) - { - camera->turnRight(MOUSE_SENSIVITY * (device->getCursorControl()->getPosition().X - mouse_pos.X)); - // check if new camera pitch would cause camera to flip over; if thats the case keep current pitch - f32 upval = MOUSE_SENSIVITY * (device->getCursorControl()->getPosition().Y - mouse_pos.Y); - f32 newval = camera->getPitch() + upval; - if( newval > 270.1f || newval < 89.9f) - { - camera->turnUp(upval); - } - device->getCursorControl()->setPosition(mouse_pos); - } - } - else - { - device->getCursorControl()->setPosition(device->getCursorControl()->getPosition()); - //if(!device->getCursorControl()->isVisible()) - //device->getCursorControl()->setVisible(true); - mouse_pos = device->getCursorControl()->getPosition(); - } - - // camera height control - if (eventrecv->mouse.wheel < 10) eventrecv->mouse.wheel = 10; - camera->setHeight( eventrecv->mouse.wheel + terrain->getHeight(camera->getPosition()) ); - - WorldPosition wp = GetWorldPosition(); - core::stringw str = L"Camera: pitch:"; - str += camera->getPitch(); - str += L" c pos:"; - str += camera->getPosition().X; - str += L","; - str += camera->getPosition().Y; - str += L","; - str += camera->getPosition().Z; - str += " ## HEAD: "; - str += DEG_TO_RAD(camera->getHeading()); - str += L" Pos: "; - str = ((((((str + wp.x) + L" | ") + wp.y) + L" | ") + wp.z) + L" | OR:") + wp.o; - str += L" -- Terrain: Sectors: "; - str += (int)terrain->getSectorsRendered(); - str += L" / "; - str += (int)terrain->getSectorCount(); - debugText->setText(str.c_str()); - -} - -void SceneWorld::OnDraw(void) -{ - // draw all objects - gui->domgr.Update(); // iterate over DrawObjects, draw them and clean up -} - -void SceneWorld::OnDelete(void) -{ - DEBUG(logdebug("~SceneWorld()")); -} - -void SceneWorld::InitTerrain(void) -{ - if(!mapmgr) - { - logerror("SceneWorld: MapMgr not present, cant create World GUI. Switching back GUI to idle."); - gui->SetSceneState(SCENESTATE_GUISTART); - return; - } - - mapsize = 8 * 16 * 3; // 9-1 height floats in 16 chunks per tile per axis in 3 MapTiles - tilesize = UNITSIZE; - meshsize = (s32)CHUNKSIZE*3; - vector3df terrainPos(0.0f, 0.0f, 0.0f); // TODO: use PseuWoW's world coords here? - - camera->setPosition(core::vector3df(mapsize*tilesize/2, 0, mapsize*tilesize/2) + terrainPos); - - terrain = new ShTlTerrainSceneNode(smgr,mapsize,mapsize,tilesize,meshsize); - terrain->drop(); - terrain->follow(camera->getNode()); - terrain->setMaterialTexture(0, driver->getTexture("data/misc/dirt_test.jpg")); - terrain->setMaterialFlag(video::EMF_LIGHTING, true); - terrain->setMaterialFlag(video::EMF_FOG_ENABLE, true); - terrain->setPosition(terrainPos); - -} - - -void SceneWorld::UpdateTerrain(void) -{ - // check if we changed the maptile - if(map_gridX == mapmgr->GetGridX() && map_gridY == mapmgr->GetGridY()) - return; // grid not changed, not necessary to update tile data - - // ... if changed, do necessary stuff... - map_gridX = mapmgr->GetGridX(); - map_gridY = mapmgr->GetGridY(); - - // TODO: better to do this with some ZThread Condition or FastMutex, but dont know how to. help plz! [FG] - if(!mapmgr->Loaded()) - { - logdebug("SceneWorld: Waiting until maps are loaded..."); - while(!mapmgr->Loaded()) - device->sleep(1); - } - - // TODO: as soon as WMO-only worlds are implemented, remove this!! - if(!mapmgr->GetLoadedMapsCount()) - { - logerror("SceneWorld: Error: No maps loaded, not able to draw any terrain. Switching back GUI to idle."); - logerror("SceneWorld: Hint: Be sure you are not in an WMO-only world (e.g. human capital city or most instances)!"); - gui->SetSceneState(SCENESTATE_GUISTART); - return; - } - - // something is not good here. we have terrain, but the chunks are read incorrectly. - // need to find out where which formula is wrong - // the current terrain renderer code is just a test to see if ADT files are read correctly. - // EDIT: it seems to display fine now, but i am still not sure if the way it is done is correct... - mutex.acquire(); // prevent other threads from deleting the maptile - logdebug("SceneWorld: Displaying MapTiles near grids x:%u y:%u",mapmgr->GetGridX(),mapmgr->GetGridY()); - for(s32 tiley = 0; tiley < 3; tiley++) - { - for(s32 tilex = 0; tilex < 3; tilex++) - { - MapTile *maptile = mapmgr->GetNearTile(tilex - 1, tiley - 1); - if(maptile) - { - // apply map height data - for(uint32 chy = 0; chy < 16; chy++) - for(uint32 chx = 0; chx < 16; chx++) - { - MapChunk *chunk = maptile->GetChunk(chx, chy); - for(uint32 hy = 0; hy < 8; hy++) - { - for(uint32 hx = 0; hx < 8; hx++) - { - f32 h = chunk->hmap_rough[hy * 9 + hx] + chunk->baseheight; // not sure if hx and hy are used correctly here - u32 terrainx = (128 * tilex) + (8 * chx) + hx; - u32 terrainy = (128 * tiley) + (8 * chy) + hy; - terrain->setHeight(terrainy, terrainx, h); - } - } - } - } - else - { - logerror("SceneWorld: MapTile not loaded, can't apply heightmap!"); - } - } - } - mutex.release(); - - // find out highest/lowest spot - f32 highest = terrain->getHeight(0,0); - f32 lowest = terrain->getHeight(0,0); - f32 curheight; - for(s32 j=0; jgetSize().Height+1; j++) - for(s32 i=0; igetSize().Width+1; i++) - { - curheight = terrain->getHeight(i,j); - highest = max(highest,curheight); - lowest = min(lowest,curheight); - } -// f32 heightdiff = highest - lowest; - - // randomize terrain color depending on height - for(s32 j=0; jgetSize().Height+1; j++) - for(s32 i=0; igetSize().Width+1; i++) - { - curheight = terrain->getHeight(i,j); - u32 g = (u32)(curheight / highest * 120) + 125; - u32 r = (u32)(curheight / highest * 120) + 60; - u32 b = (u32)(curheight / highest * 120) + 60; - - terrain->setColor(i,j, video::SColor(255,r,g,b)); - } - - logdebug("SceneWorld: Smoothing terrain normals..."); - terrain->smoothNormals(); -} - -WorldPosition SceneWorld::GetWorldPosition(void) -{ - // TODO: later do not use CAMERA, but CHARACTER position, as soon as camera is changed from 1st to 3rd person view - // and floating around character in the middle - vector3df cam = camera->getPosition(); - // TODO: need to correct camera values, the coords irrlicht returns are not suitable - - // get the current maptile and use the coords of the top-left corner as relative positions - MapTile *tile = mapmgr->GetCurrentTile(); - if(!tile) - { - logerror("SceneWorld::GetWorldPosition failed, MapTile not loaded!"); - return WorldPosition(); - } - - float mapx = tile->GetBaseX(); - float mapy = tile->GetBaseY(); - - // the following formulas are NOT correct, just estimated. in most places they will differ from real expected values a lot! - float relx = cam.X * COORD_SCALE_VALUE_X + CHUNKSIZE; - float rely = cam.Z * COORD_SCALE_VALUE_Y + CHUNKSIZE; - - float o = DEG_TO_RAD(camera->getHeading()) + ((M_PI*3.0f)/2.0f); - return WorldPosition(mapx - relx, mapy - rely, cam.Y, RAD_FIX(o) ); -} - -void SceneWorld::SetWorldPosition(WorldPosition wp) -{ - UpdateTerrain(); - vector3df cam; - dimension2d tsize = terrain->getSize(); - MapTile *tile = mapmgr->GetTile(MapMgr::GetGridCoord(wp.x), MapMgr::GetGridCoord(wp.y)); - ASSERT(tile == mapmgr->GetCurrentTile()); // for debugging; we should already be located on the new tile - if(!tile) - { - logerror("SceneWorld::SetWorldPosition(): MapTile not loaded!"); - return; - } - cam.X = tile->GetBaseX() - wp.x + (tsize.Width * UNITSIZE); - cam.Z = tile->GetBaseX() - wp.y + (tsize.Height * UNITSIZE); - float heading = RAD_TO_DEG(((M_PI*3.0f)/2.0f) - wp.o); - float heading_diff = camera->getHeading() - heading; - logdebug("Setting camera to x: %3f y: %3f z:%3f head: %3f", cam.X, cam.Y, cam.Z, heading); - camera->turnLeft(heading_diff); - - // TODO: - // - correct the above formulas - // - find out terrain height where the camera should be set - // - set camera to correct position - // - correct camera turning - //camera->setPosition(cam); - //camera->turnRight(heading_diff); -} - - - +#include +#include +#include "common.h" +#include "PseuGUI.h" +#include "PseuWoW.h" +#include "Scene.h" +#include "MapTile.h" +#include "MapMgr.h" +#include "ShTlTerrainSceneNode.h" +#include "MCamera.h" +#include "MInput.h" +#include "WorldSession.h" +#include "World.h" + +#define MOUSE_SENSIVITY 0.5f +#define ANGLE_STEP (M_PI/180) +#define DEG_TO_RAD(x) ((x)*ANGLE_STEP) +#define RAD_TO_DEG(x) ((x)/ANGLE_STEP) +#define RAD_FIX(x) ( (x)>(2*M_PI) ? ((x)-(2*M_PI)) : (x) ) +#define DEG_FIX(x) ( (x)>360 ? ((x)-360) : (x) ) + +#define COORD_SCALE_VALUE_X 0.336f +#define COORD_SCALE_VALUE_Y 0.2f + + + +SceneWorld::SceneWorld(PseuGUI *g) : Scene(g) +{ + DEBUG(logdebug("SceneWorld: Initializing...")); + debugmode = false; + + // store some pointers right now to prevent repeated ptr dereferencing later (speeds up code) + gui = g; + wsession = gui->GetInstance()->GetWSession(); + mapmgr = wsession->GetWorld()->GetMapMgr(); + + // TODO: hardcoded for now, make this adjustable later + float fogdist = 150; + + ILightSceneNode* light = smgr->addLightSceneNode(0, core::vector3df(0,0,0), SColorf(255, 255, 255, 255), 1000.0f); + SLight ldata = light->getLightData(); + ldata.AmbientColor = video::SColorf(0.2f,0.2f,0.2f); + ldata.DiffuseColor = video::SColorf(1.0f,1.0f,1.0f); + ldata.Type = video::ELT_DIRECTIONAL; + ldata.Position = core::vector3df(-10,5,-5); + light->setLightData(ldata); + + eventrecv = new MyEventReceiver(); + device->setEventReceiver(eventrecv); + + camera = new MCameraFPS(smgr); + camera->setNearValue(0.1f); + camera->setFarValue(12000); // TODO: adjust + + debugText = guienv->addStaticText(L"< debug text >",rect(0,0,driver->getScreenSize().Width,30),true,true,0,-1,true); + + smgr->addSkyDomeSceneNode(driver->getTexture("data/misc/sky.jpg"),64,64,1.0f,2.0f); + + driver->setFog(video::SColor(0,100,101,190), true, fogdist, fogdist + 30, 0.02f); + + // setup cursor + device->getCursorControl()->setVisible(false); + + InitTerrain(); + UpdateTerrain(); + + DEBUG(logdebug("SceneWorld: Init done!")); +} + +void SceneWorld::OnUpdate(s32 timediff) +{ + static position2d mouse_pos; + + UpdateTerrain(); + + bool mouse_pressed_left = eventrecv->mouse.left_pressed(); + bool mouse_pressed_right = eventrecv->mouse.right_pressed(); + float timediff_f = timediff / 1000.0f; + + if(eventrecv->key.pressed(KEY_KEY_W) || (mouse_pressed_left && mouse_pressed_right)) + camera->moveForward(50 * timediff_f); + if(eventrecv->key.pressed(KEY_KEY_S)) + camera->moveBack(50 * timediff_f); + if(eventrecv->key.pressed(KEY_KEY_E)) + camera->moveRight(50 * timediff_f); + if(eventrecv->key.pressed(KEY_KEY_Q)) + camera->moveLeft(50 * timediff_f); + + // if right mouse button pressed, move in axis, if not, turn camera + if(eventrecv->key.pressed(KEY_KEY_D)) + { + if(mouse_pressed_right) + camera->moveRight(50 * timediff_f); + else + camera->turnRight(timediff_f * M_PI * 25); + } + if(eventrecv->key.pressed(KEY_KEY_A)) + { + if(mouse_pressed_right) + camera->moveLeft(50 * timediff_f); + else + camera->turnLeft(timediff_f * M_PI * 25); + } + + if(eventrecv->key.pressed_once(KEY_BACK)) + { + debugmode = !debugmode; + if(debugmode) + { + terrain->setDebugDataVisible(EDS_FULL); + } + else + { + terrain->setDebugDataVisible(EDS_OFF); + } + } + + if(eventrecv->key.pressed_once(KEY_INSERT)) + { + IImage *scrnshot = driver->createScreenShot(); + if(scrnshot) + { + CreateDir("screenshots"); + std::string date = getDateString(); + for(uint32 i = 0; i < date.length(); i++) + { + if(date[i] == ':') + date[i] = '_'; + } + if(date[date.length()-1] == ' ') + { + date = date.substr(0,date.length()-2); + } + driver->writeImageToFile(scrnshot, ("screenshots/PseuWoW " + date + ".jpg").c_str(), device->getTimer()->getRealTime()); + scrnshot->drop(); + } + } + + if(mouse_pressed_left || mouse_pressed_right) + { + //if(device->getCursorControl()->isVisible()) + //device->getCursorControl()->setVisible(false); + if(mouse_pos != device->getCursorControl()->getPosition()) + { + camera->turnRight(MOUSE_SENSIVITY * (device->getCursorControl()->getPosition().X - mouse_pos.X)); + // check if new camera pitch would cause camera to flip over; if thats the case keep current pitch + f32 upval = MOUSE_SENSIVITY * (device->getCursorControl()->getPosition().Y - mouse_pos.Y); + f32 newval = camera->getPitch() + upval; + if( newval > 270.1f || newval < 89.9f) + { + camera->turnUp(upval); + } + device->getCursorControl()->setPosition(mouse_pos); + } + } + else + { + device->getCursorControl()->setPosition(device->getCursorControl()->getPosition()); + //if(!device->getCursorControl()->isVisible()) + //device->getCursorControl()->setVisible(true); + mouse_pos = device->getCursorControl()->getPosition(); + } + + // camera height control + if (eventrecv->mouse.wheel < 10) eventrecv->mouse.wheel = 10; + camera->setHeight( eventrecv->mouse.wheel + terrain->getHeight(camera->getPosition()) ); + + WorldPosition wp = GetWorldPosition(); + core::stringw str = L"Camera: pitch:"; + str += camera->getPitch(); + str += L" c pos:"; + str += camera->getPosition().X; + str += L","; + str += camera->getPosition().Y; + str += L","; + str += camera->getPosition().Z; + str += " ## HEAD: "; + str += DEG_TO_RAD(camera->getHeading()); + str += L" Pos: "; + str = ((((((str + wp.x) + L" | ") + wp.y) + L" | ") + wp.z) + L" | OR:") + wp.o; + str += L" -- Terrain: Sectors: "; + str += (int)terrain->getSectorsRendered(); + str += L" / "; + str += (int)terrain->getSectorCount(); + debugText->setText(str.c_str()); + +} + +void SceneWorld::OnDraw(void) +{ + // draw all objects + gui->domgr.Update(); // iterate over DrawObjects, draw them and clean up +} + +void SceneWorld::OnDelete(void) +{ + DEBUG(logdebug("~SceneWorld()")); +} + +void SceneWorld::InitTerrain(void) +{ + if(!mapmgr) + { + logerror("SceneWorld: MapMgr not present, cant create World GUI. Switching back GUI to idle."); + gui->SetSceneState(SCENESTATE_GUISTART); + return; + } + + mapsize = 8 * 16 * 3; // 9-1 height floats in 16 chunks per tile per axis in 3 MapTiles + tilesize = UNITSIZE; + meshsize = (s32)CHUNKSIZE*3; + vector3df terrainPos(0.0f, 0.0f, 0.0f); // TODO: use PseuWoW's world coords here? + + camera->setPosition(core::vector3df(mapsize*tilesize/2, 0, mapsize*tilesize/2) + terrainPos); + + terrain = new ShTlTerrainSceneNode(smgr,mapsize,mapsize,tilesize,meshsize); + terrain->drop(); + terrain->follow(camera->getNode()); + terrain->setMaterialTexture(0, driver->getTexture("data/misc/dirt_test.jpg")); + terrain->setMaterialFlag(video::EMF_LIGHTING, true); + terrain->setMaterialFlag(video::EMF_FOG_ENABLE, true); + terrain->setPosition(terrainPos); + +} + + +void SceneWorld::UpdateTerrain(void) +{ + // check if we changed the maptile + if(map_gridX == mapmgr->GetGridX() && map_gridY == mapmgr->GetGridY()) + return; // grid not changed, not necessary to update tile data + + // ... if changed, do necessary stuff... + map_gridX = mapmgr->GetGridX(); + map_gridY = mapmgr->GetGridY(); + + // TODO: better to do this with some ZThread Condition or FastMutex, but dont know how to. help plz! [FG] + if(!mapmgr->Loaded()) + { + logdebug("SceneWorld: Waiting until maps are loaded..."); + while(!mapmgr->Loaded()) + device->sleep(1); + } + + // TODO: as soon as WMO-only worlds are implemented, remove this!! + if(!mapmgr->GetLoadedMapsCount()) + { + logerror("SceneWorld: Error: No maps loaded, not able to draw any terrain. Switching back GUI to idle."); + logerror("SceneWorld: Hint: Be sure you are not in an WMO-only world (e.g. human capital city or most instances)!"); + gui->SetSceneState(SCENESTATE_GUISTART); + return; + } + + // something is not good here. we have terrain, but the chunks are read incorrectly. + // need to find out where which formula is wrong + // the current terrain renderer code is just a test to see if ADT files are read correctly. + // EDIT: it seems to display fine now, but i am still not sure if the way it is done is correct... + mutex.acquire(); // prevent other threads from deleting the maptile + logdebug("SceneWorld: Displaying MapTiles near grids x:%u y:%u",mapmgr->GetGridX(),mapmgr->GetGridY()); + for(s32 tiley = 0; tiley < 3; tiley++) + { + for(s32 tilex = 0; tilex < 3; tilex++) + { + MapTile *maptile = mapmgr->GetNearTile(tilex - 1, tiley - 1); + if(maptile) + { + // apply map height data + for(uint32 chy = 0; chy < 16; chy++) + for(uint32 chx = 0; chx < 16; chx++) + { + MapChunk *chunk = maptile->GetChunk(chx, chy); + for(uint32 hy = 0; hy < 8; hy++) + { + for(uint32 hx = 0; hx < 8; hx++) + { + f32 h = chunk->hmap_rough[hy * 9 + hx] + chunk->baseheight; // not sure if hx and hy are used correctly here + u32 terrainx = (128 * tilex) + (8 * chx) + hx; + u32 terrainy = (128 * tiley) + (8 * chy) + hy; + terrain->setHeight(terrainy, terrainx, h); + } + } + } + } + else + { + logerror("SceneWorld: MapTile not loaded, can't apply heightmap!"); + } + } + } + mutex.release(); + + // find out highest/lowest spot + f32 highest = terrain->getHeight(0,0); + f32 lowest = terrain->getHeight(0,0); + f32 curheight; + for(s32 j=0; jgetSize().Height+1; j++) + for(s32 i=0; igetSize().Width+1; i++) + { + curheight = terrain->getHeight(i,j); + highest = max(highest,curheight); + lowest = min(lowest,curheight); + } +// f32 heightdiff = highest - lowest; + + // randomize terrain color depending on height + for(s32 j=0; jgetSize().Height+1; j++) + for(s32 i=0; igetSize().Width+1; i++) + { + curheight = terrain->getHeight(i,j); + u32 g = (u32)(curheight / highest * 120) + 125; + u32 r = (u32)(curheight / highest * 120) + 60; + u32 b = (u32)(curheight / highest * 120) + 60; + + terrain->setColor(i,j, video::SColor(255,r,g,b)); + } + + logdebug("SceneWorld: Smoothing terrain normals..."); + terrain->smoothNormals(); +} + +WorldPosition SceneWorld::GetWorldPosition(void) +{ + // TODO: later do not use CAMERA, but CHARACTER position, as soon as camera is changed from 1st to 3rd person view + // and floating around character in the middle + vector3df cam = camera->getPosition(); + // TODO: need to correct camera values, the coords irrlicht returns are not suitable + + // get the current maptile and use the coords of the top-left corner as relative positions + MapTile *tile = mapmgr->GetCurrentTile(); + if(!tile) + { + logerror("SceneWorld::GetWorldPosition failed, MapTile not loaded!"); + return WorldPosition(); + } + + float mapx = tile->GetBaseX(); + float mapy = tile->GetBaseY(); + + // the following formulas are NOT correct, just estimated. in most places they will differ from real expected values a lot! + float relx = cam.X * COORD_SCALE_VALUE_X + CHUNKSIZE; + float rely = cam.Z * COORD_SCALE_VALUE_Y + CHUNKSIZE; + + float o = DEG_TO_RAD(camera->getHeading()) + ((M_PI*3.0f)/2.0f); + return WorldPosition(mapx - relx, mapy - rely, cam.Y, RAD_FIX(o) ); +} + +void SceneWorld::SetWorldPosition(WorldPosition wp) +{ + UpdateTerrain(); + vector3df cam; + dimension2d tsize = terrain->getSize(); + MapTile *tile = mapmgr->GetTile(MapMgr::GetGridCoord(wp.x), MapMgr::GetGridCoord(wp.y)); + ASSERT(tile == mapmgr->GetCurrentTile()); // for debugging; we should already be located on the new tile + if(!tile) + { + logerror("SceneWorld::SetWorldPosition(): MapTile not loaded!"); + return; + } + cam.X = tile->GetBaseX() - wp.x + (tsize.Width * UNITSIZE); + cam.Z = tile->GetBaseX() - wp.y + (tsize.Height * UNITSIZE); + float heading = RAD_TO_DEG(((M_PI*3.0f)/2.0f) - wp.o); + float heading_diff = camera->getHeading() - heading; + logdebug("Setting camera to x: %3f y: %3f z:%3f head: %3f", cam.X, cam.Y, cam.Z, heading); + camera->turnLeft(heading_diff); + + // TODO: + // - correct the above formulas + // - find out terrain height where the camera should be set + // - set camera to correct position + // - correct camera turning + //camera->setPosition(cam); + //camera->turnRight(heading_diff); +} + + + diff --git a/src/Client/GUI/ShTlTerrainSceneNode.cpp b/src/Client/GUI/ShTlTerrainSceneNode.cpp index bbc8072..b2a9740 100644 --- a/src/Client/GUI/ShTlTerrainSceneNode.cpp +++ b/src/Client/GUI/ShTlTerrainSceneNode.cpp @@ -1,1323 +1,1323 @@ -#include "ShTlTerrainSceneNode.h" - -// constructor -ShTlTerrainSceneNode::ShTlTerrainSceneNode(scene::ISceneManager* pSceneManager, - s32 width, s32 height, f32 tilesize, s32 visiblesize, - scene::ISceneNode* parent, s32 id) - : scene::ISceneNode(pSceneManager->getRootSceneNode(), pSceneManager, id) -{ - Size.Width = width; - Size.Height = height; - - TileSize = tilesize; - - // make sure rendered terrain mesh is not larger than terrain itself - if(visiblesize > Size.Width) visiblesize = Size.Width; - if(visiblesize > Size.Height) visiblesize = Size.Height; - - MeshSize.Width = visiblesize; - MeshSize.Height = visiblesize; - - MeshPosition = core::vector2d(0,0); - - Fnode = NULL; - - ShStep = 1; - - // create data array - - Data.reset(Size.Width+1, Size.Height+1); - - for(s32 j=0; j(0,1); - UVdata(i,j).Vertex[1] = core::vector2d(0,0); - UVdata(i,j).Vertex[2] = core::vector2d(1,0); - UVdata(i,j).Vertex[3] = core::vector2d(1,1); - } - - // calculate number of sectors - // terrain mesh will be split to 1 or 3 or 5 sectors on each axis depending on size - s32 w = 1; - s32 h = 1; - if(MeshSize.Width >= 30) w = 3; - if(MeshSize.Height >= 30) h = 3; - if(MeshSize.Width >= 50) w = 5; - if(MeshSize.Height >= 50) h = 5; - - // create sectors - Sector.reset(w, h); - - // find size of sectors in tiles - w = MeshSize.Width / Sector.width(); - h = MeshSize.Height / Sector.height(); - - for(s32 j=0; j(w, h); - - // find size of center sector in tiles - w = MeshSize.Width - Sector(0,0).Size.Width * (Sector.width()-1); - h = MeshSize.Height - Sector(0,0).Size.Height * (Sector.height()-1); - - {s32 j= Sector.height()/2; - for(s32 i=0; i0) Sector(i,j).Offset.X = Sector(i-1,j).Offset.X + Sector(i-1,j).Size.Width; - else Sector(i,j).Offset.X = 0; - if(j>0) Sector(i,j).Offset.Y = Sector(i,j-1).Offset.Y + Sector(i,j-1).Size.Height; - else Sector(i,j).Offset.Y = 0; - } - - // fill sectors with tiles - for(s32 j=0; jColor = video::SColor(255,255,255,255); - Tile(i,j).Vertex[1]->Color = video::SColor(255,255,255,255); - Tile(i,j).Vertex[2]->Color = video::SColor(255,255,255,255); - Tile(i,j).Vertex[3]->Color = video::SColor(255,255,255,255); - } - - // setup material - video::SMaterial material; - material.AmbientColor = video::SColor(255,255,255,255); - material.DiffuseColor = video::SColor(255,255,255,255); - material.EmissiveColor = video::SColor(255,0,0,0); - material.Shininess = 0.0f; - material.SpecularColor = video::SColor(255,0,0,0); - material.MaterialType = video::EMT_DETAIL_MAP; - - Material.push_back(material); - - // create 2nd texture layer - - // find size of texture, must be power of two - s32 tw = 2; - while(tw < MeshSize.Width) tw = tw + tw; - s32 th = 2; - while(th < MeshSize.Height) th = th + th; - - // create texture - // turn of mipmaps othervise they would need to be regenerated each time texture is updated - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - bool mmflag = driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); - - CTexture = driver->addTexture(core::dimension2d(tw, th), "colortexture", video::ECF_A8R8G8B8); - - driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mmflag); - - // irrlicht 1.4 - /* - Material[0].TextureLayer[1].Texture = CTexture; - Material[0].TextureLayer[1].TextureWrap = video::ETC_CLAMP_TO_EDGE; - */ - // irrlicht 1.3: - Material[0].Textures[1] = CTexture; - Material[0].TextureWrap[1] = video::ETC_CLAMP_TO_EDGE; - - // setup UV coordinates of vertices on 2nd texture layer - f32 ax = (f32)MeshSize.Width / CTexture->getSize().Width / MeshSize.Width; - f32 ay = (f32)MeshSize.Height/ CTexture->getSize().Height / MeshSize.Height; - f32 ry = 1.0f - (f32)MeshSize.Height/ CTexture->getSize().Height; - - u32 n = MeshSize.Height-1; - for(s32 j=0; jTCoords2 = core::vector2d(i*ax, ry+(j+1)*ay); - Tile(i,n).Vertex[1]->TCoords2 = core::vector2d(i*ax, ry+j*ay); - Tile(i,n).Vertex[3]->TCoords2 = core::vector2d((i+1)*ax, ry+(j+1)*ay); - Tile(i,n).Vertex[2]->TCoords2 = core::vector2d((i+1)*ax, ry+j*ay); - } - n--; - } - - // set update vertices flag for sectors - for(s32 j=0; jregisterNodeForRendering(this); - - ISceneNode::OnRegisterSceneNode(); -} - - - -// renders terrain -void ShTlTerrainSceneNode::render() -{ - // update position if needed - if(Fnode) centerAt(Fnode->getPosition()); - - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - if (!driver) return; - - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - - driver->setMaterial(Material[0]); - - SectorsRendered = 0; - - // test if sectors are vissible - for(s32 j=0; jlock(); - - updateTexture(p, Sector(i,j)); - - Sector(i,j).UpdateTexture = false; - } - if(p) CTexture->unlock(); - - // render geometry - for(s32 j=0; jdrawIndexedTriangleList - (&Sector(i,j).Vertex[0], Sector(i,j).Vertex.size(), - &Sector(i,j).Index[0], Sector(i,j).Index.size()/3); - } - - // for debuging - if( DebugDataVisible == scene::EDS_OFF ) return; - - // wireframe overlay - if (DebugDataVisible == scene::EDS_MESH_WIRE_OVERLAY || DebugDataVisible == scene::EDS_FULL) - { - video::SMaterial m; - m.Lighting = false; - m.Wireframe = true; - m.BackfaceCulling = false; - m.AmbientColor = video::SColor(255,0,255,0); - m.DiffuseColor = video::SColor(255,0,255,0); - driver->setMaterial(m); - - for(s32 j=0; jdrawIndexedTriangleList - (&Sector(i,j).Vertex[0], Sector(i,j).Vertex.size(), - &Sector(i,j).Index[0], Sector(i,j).Index.size()/3); - } - } - } - - // terrain bounding box - if (DebugDataVisible == scene::EDS_BBOX || DebugDataVisible == scene::EDS_FULL) - { - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - - driver->draw3DBox(BoundingBox, video::SColor(0,255,255,255)); - } - - // sectors bounding boxes - if (DebugDataVisible == scene::EDS_BBOX_BUFFERS || DebugDataVisible == scene::EDS_FULL) - { - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - - for(s32 j=0; jdraw3DBox(Sector(i,j).BoundingBox, video::SColor(0,255,255,255)); - } - } - - // normals - if (DebugDataVisible == scene::EDS_NORMALS || DebugDataVisible == scene::EDS_FULL) - { - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - - for(s32 j=0; jdraw3DLine ( v[n].Pos, v[n].Pos + h, c ); - } - } - } -} - - - -// returns the axis aligned bounding box of terrain -const core::aabbox3d& ShTlTerrainSceneNode::getBoundingBox() const -{ - return BoundingBox; -} - - - -// recalculate terrain bounding box -void ShTlTerrainSceneNode::recalculateBoundingBox() -{ - BoundingBox.MinEdge.X = TileSize * MeshPosition.X; - BoundingBox.MinEdge.Y = Data(0,0).Height; - BoundingBox.MinEdge.Z = TileSize * MeshPosition.Y; - - BoundingBox.MaxEdge.X = TileSize * (MeshPosition.X + MeshSize.Width); - BoundingBox.MaxEdge.Y = Data(0,0).Height; - BoundingBox.MaxEdge.Z = TileSize * (MeshPosition.Y + MeshSize.Height); - - for(s32 j=0; j Data(i,j).Height) BoundingBox.MinEdge.Y = Data(i,j).Height; - if(BoundingBox.MaxEdge.Y < Data(i,j).Height) BoundingBox.MaxEdge.Y = Data(i,j).Height; - } - - - for(s32 j=0; j ShTlTerrainSceneNode::getSize() -{ - return Size; -} - - - -// return dimension of terrain tile -f32 ShTlTerrainSceneNode::getTileSize() -{ - return TileSize; -} - - - -// set new dimensions of terrain tiles -void ShTlTerrainSceneNode::setTileSize(f32 newsize) -{ - if(newsize != TileSize) - { - TileSize = newsize; - - update(); - } -} - - - -// returns dimension of rendered mesh in tiles -core::dimension2d ShTlTerrainSceneNode::getRenderedSize() -{ - return MeshSize; -} - - - -// return number of sectors -u32 ShTlTerrainSceneNode::getSectorCount() -{ - return Sector.width() * Sector.height(); -} - - - -// returns numner of sectors rendered last frame -u32 ShTlTerrainSceneNode::getSectorsRendered() -{ - return SectorsRendered; -} - - - -// return height of terrain spot at terrain coordinates -f32 ShTlTerrainSceneNode::getHeight(u32 w, u32 h) -{ - return Data(w,h).Height; -} - - - -// return height of terrain at any position -f32 ShTlTerrainSceneNode::getHeight(core::vector3df pos) -{ - // find position relative to terrain - pos = pos - getPosition(); - - if(pos.X>=0 && pos.X<(f32)Size.Width*TileSize && pos.Z>=0 && pos.Z<(f32)Size.Height*TileSize) - { - // calculatin coordinates of tile - s32 x = (s32) (pos.X / TileSize); - s32 y = (s32) (pos.Z / TileSize); - - // calculating position relative to tile - f32 xtil = pos.X - (x*TileSize); - f32 ytil = pos.Z - (y*TileSize); - - // finding trianle of tile - core::triangle3df triangle; - if(xtil<=ytil) - { - // upper left triangle of tile - triangle.pointA = core::vector3df(0, getHeight(x,y), 0); - triangle.pointB = core::vector3df(0, getHeight(x,y+1), TileSize); - triangle.pointC = core::vector3df(TileSize, getHeight(x+1,y+1), TileSize); - } - else - { - // lower right triangle of tile - triangle.pointA = core::vector3df(0, getHeight(x,y), 0); - triangle.pointB = core::vector3df(TileSize, getHeight(x+1,y+1), TileSize); - triangle.pointC = core::vector3df(TileSize, getHeight(x+1,y), 0); - } - - // calculating intersection with triangle - core::vector3df intersection; - triangle.getIntersectionWithLine(core::vector3df(xtil,0,ytil),core::vector3df(0,1,0),intersection); - - return intersection.Y + getPosition().Y; - } - else - return 0; -} - - - -// set relative height of terrain spot at terrain coordinates -void ShTlTerrainSceneNode::setHeight(u32 w, u32 h, f32 newheight) -{ - Data(w,h).Height = newheight; - - // recalculate bounding boxes - - if(newheight > BoundingBox.MaxEdge.Y) - { - BoundingBox.MaxEdge.Y = newheight; - - for(s32 j=0; j 0) // check if not out of array - v0 = core::vector3df(0, getHeight(w,h-1)-getHeight(w,h), -TileSize); - else - v0 = core::vector3df(0, 0, -TileSize); - // calculate vector to point -1,-1 - if(w > 0 && h > 0) // check if not out of array - v1 = core::vector3df(-TileSize, getHeight(w-1,h-1)-getHeight(w,h), -TileSize); - else - v1 = core::vector3df(-TileSize, 0, -TileSize); - n0 = v0.crossProduct(v1); - - // calculate vector to point -1,-1 - v0 = v1; - // calculate vector to point -1,0 - if(w > 0) - v1 = core::vector3df(-TileSize, getHeight(w-1,h)-getHeight(w,h), 0); - else - v1 = core::vector3df(-TileSize, 0, 0); - n1 = v0.crossProduct(v1); - - // calculate vector to point -1,0 - v0 = v1; - // calculate vector to point 0,1 - if(h < Size.Height) - v1 = core::vector3df(0, getHeight(w,h+1)-getHeight(w,h), TileSize); - else - v1 = core::vector3df(0, 0, TileSize); - n2 = v0.crossProduct(v1); - - // calculate vector to point 0,1 - v0 = v1; - // calculate vector to point 1,1 - if(w < Size.Width && h < Size.Height) - v1 = core::vector3df(TileSize, getHeight(w+1,h+1)-getHeight(w,h), TileSize); - else - v1 = core::vector3df(TileSize, 0, TileSize); - n3 = v0.crossProduct(v1); - - // calculate vector to point 1,1 - v0 = v1; - // calculate vector to point 1,0 - if(w < Size.Width) - v1 = core::vector3df(TileSize, getHeight(w+1,h)-getHeight(w,h), 0); - else - v1 = core::vector3df(TileSize, 0, 0); - n4 = v0.crossProduct(v1); - - // calculate vector to point 1,0 - v0 = v1; - // calculate vector to point 0,-1 - if(h > 0) - v1 = core::vector3df(0, getHeight(w,h-1)-getHeight(w,h), -TileSize); - else - v1 = core::vector3df(0, 0, -TileSize); - n5 = v0.crossProduct(v1); - - // calculate normals of 4 tiles around point - core::vector3df m0, m1, m2, m3; - m0 = (n1 - n0) /2 + n0; - m1 = n2; - m2 = (n4 - n3) /2 + n3; - m3 = n5; - - // calculate normals between oposing tiles - core::vector3df k0, k1; - k0 = (m2 - m0) /2 + m0; - k1 = (m3 - m1) /2 + m1; - - // calculate normal of point - core::vector3df n = (k1 - k0) /2 + k0; - n.normalize(); - setNormal(w,h,n); -} - -// recalculare normals of whole terrain making it look smooth under light -void ShTlTerrainSceneNode::smoothNormals() -{ - for(s32 j=0; j ShTlTerrainSceneNode::getTileUV(u32 w, u32 h, TILE_VERTEX corner) -{ - return UVdata(w,h).Vertex[corner]; -} - - - -// set texture coordinates of tile -void ShTlTerrainSceneNode::setTileUV(u32 w, u32 h, core::vector2d UVlowerLeft, - core::vector2d UVupperLeft, core::vector2d UVupperRight, - core::vector2d UVlowerRight) -{ - UVdata(w,h).Vertex[0] = UVlowerLeft; - UVdata(w,h).Vertex[1] = UVupperLeft; - UVdata(w,h).Vertex[2] = UVupperRight; - UVdata(w,h).Vertex[3] = UVlowerRight; -} - - - -// stretch texture over whole terrain -void ShTlTerrainSceneNode::stretchTexture(core::vector2d scale) -{ - f32 ax = scale.X / Size.Width; - f32 ay = scale.X / Size.Height; - - u32 n = Size.Height-1; - for(s32 j=0; j(i*ax, j*ay); - UVdata(i,n).Vertex[0] = core::vector2d(i*ax, j*ay+ay); - UVdata(i,n).Vertex[3] = core::vector2d(i*ax+ax, j*ay+ay); - UVdata(i,n).Vertex[2] = core::vector2d(i*ax+ax, j*ay); - } - n--; - } -} - - - -// stretch texture over every tile individualy -void ShTlTerrainSceneNode::stretchTextureOverTile(core::vector2d scale) -{ - for(s32 j=0; j(0, 0); - UVdata(i,j).Vertex[0] = core::vector2d(0, scale.Y); - UVdata(i,j).Vertex[3] = core::vector2d(scale.X, scale.Y); - UVdata(i,j).Vertex[2] = core::vector2d(scale.X, 0); - } -} - - - -// rotate texture of tile 90 degrees -void ShTlTerrainSceneNode::rotateTileTexture90(u32 w, u32 h) -{ - core::vector2d tmp = UVdata(w,h).Vertex[3]; - - UVdata(w,h).Vertex[3] = UVdata(w,h).Vertex[2]; - UVdata(w,h).Vertex[2] = UVdata(w,h).Vertex[1]; - UVdata(w,h).Vertex[1] = UVdata(w,h).Vertex[0]; - UVdata(w,h).Vertex[0] = tmp; -} - - - -// rotate texture of tile 180 degrees -void ShTlTerrainSceneNode::rotateTileTexture180(u32 w, u32 h) -{ - core::vector2d tmp = UVdata(w,h).Vertex[3]; - - UVdata(w,h).Vertex[3] = UVdata(w,h).Vertex[1]; - UVdata(w,h).Vertex[1] = tmp; - - tmp = UVdata(w,h).Vertex[2]; - - UVdata(w,h).Vertex[2] = UVdata(w,h).Vertex[0]; - UVdata(w,h).Vertex[0] = tmp; -} - - - -// rotate texture of tile 270 degrees -void ShTlTerrainSceneNode::rotateTileTexture270(u32 w, u32 h) -{ - core::vector2d tmp = UVdata(w,h).Vertex[3]; - - UVdata(w,h).Vertex[3] = UVdata(w,h).Vertex[0]; - UVdata(w,h).Vertex[0] = UVdata(w,h).Vertex[1]; - UVdata(w,h).Vertex[1] = UVdata(w,h).Vertex[2]; - UVdata(w,h).Vertex[2] = tmp; -} - - - -// flip (mirror) texture of tile horizontaly -void ShTlTerrainSceneNode::flipTileTextureHorizontal(u32 w, u32 h) -{ - core::vector2d tmp = UVdata(w,h).Vertex[3]; - - UVdata(w,h).Vertex[3] = UVdata(w,h).Vertex[0]; - UVdata(w,h).Vertex[0] = tmp; - - tmp = UVdata(w,h).Vertex[2]; - - UVdata(w,h).Vertex[2] = UVdata(w,h).Vertex[1]; - UVdata(w,h).Vertex[1] = tmp; -} - - - -// flip (mirror) texture of tile verticaly -void ShTlTerrainSceneNode::flipTileTextureVertical(u32 w, u32 h) -{ - core::vector2d tmp = UVdata(w,h).Vertex[3]; - - UVdata(w,h).Vertex[3] = UVdata(w,h).Vertex[2]; - UVdata(w,h).Vertex[2] = tmp; - - tmp = UVdata(w,h).Vertex[0]; - - UVdata(w,h).Vertex[0] = UVdata(w,h).Vertex[1]; - UVdata(w,h).Vertex[1] = tmp; -} - - - -// get color of tile at terrain coordinates -video::SColor ShTlTerrainSceneNode::getColor(u32 w, u32 h) -{ - return Data(w,h).Color; -} - - - -// set color of tile at terrain coordinates -void ShTlTerrainSceneNode::setColor(u32 w, u32 h, video::SColor newcolor) -{ - Data(w,h).Color = newcolor; -} - - - -// set rendered mesh position relative to terrain -void ShTlTerrainSceneNode::setMeshPosition(core::vector2d pos) -{ - // correct if out of terrain bounds - if(pos.X < 0) pos.X = 0; - if(pos.Y < 0) pos.Y = 0; - - if(pos.X > (s32)(Size.Width - MeshSize.Width)) pos.X = (s32)(Size.Width - MeshSize.Width); - if(pos.Y > (s32)(Size.Height - MeshSize.Height)) pos.Y = (s32)(Size.Height - MeshSize.Height); - - // update - if(pos.X > MeshPosition.X + ShStep || pos.X < MeshPosition.X - ShStep || - pos.Y > MeshPosition.Y + ShStep || pos.Y < MeshPosition.Y - ShStep) - { - MeshPosition = pos; - - update(); - } -} - - - -// center rendered mesh at 3d coordinates -void ShTlTerrainSceneNode::centerAt(core::vector3d pos) -{ - // find position relative to terrain - pos.X = pos.X - getPosition().X; - pos.Z = pos.Z - getPosition().Z; - - // offset center - pos.X = pos.X - TileSize * MeshSize.Width/2; - pos.Z = pos.Z - TileSize * MeshSize.Height/2; - - // find equivalent in tiles - s32 x = (s32)(pos.X / TileSize); - s32 y = (s32)(pos.Z / TileSize); - - setMeshPosition(core::vector2d(x,y)); -} - - - -// update rendered mesh -void ShTlTerrainSceneNode::update() -{ - // update position of bounding boxes - BoundingBox.MinEdge = core::vector3df(MeshPosition.X*TileSize, BoundingBox.MinEdge.Y, MeshPosition.Y*TileSize); - BoundingBox.MaxEdge = core::vector3df( (MeshPosition.X+MeshSize.Width)*TileSize, BoundingBox.MaxEdge.Y, (MeshPosition.Y+MeshSize.Height)*TileSize); - - for(s32 j=0; j line, core::vector3df &outIntersection) -{ - //get relative position of line to terrain - line.start = line.start - getPosition(); - line.end = line.end - getPosition(); - - // find 2d vector of line - core::vector2d vector; - vector.X = line.end.X - line.start.X; - vector.Y = line.end.Z - line.start.Z; - - // calculate variables used later in calculating coordinates on line - // used equations are: "x = y * a + c" and "y = x * b + d" - // where "a = x / y" and "b = y / x" - f32 a = 0; - if(vector.Y != 0) a = vector.X / vector.Y; - - f32 b = 0; - if(vector.X != 0) b = vector.Y / vector.X; - - // calculate starting and ending tiles - core::vector3d start; - start.X = (s32)(line.start.X / TileSize); - start.Y = (s32)(line.start.Z / TileSize); - - core::vector3d end; - end.X = (s32)(line.end.X / TileSize); - end.Y = (s32)(line.end.Z / TileSize); - - // some variables dependant on line orientation - s32 xs = 1; - s32 xc = 0; - if(vector.X < 0) - { - xs = -1; - xc = 1; - } - - s32 ys = 1; - s32 yc = 0; - if(vector.Y < 0) - { - ys = -1; - yc = 1; - } - - // calculate tiles which can intersect with line based on their 2d position - // then test for intersection - - // take y and calculate x coordinates of tile - if( core::abs_(vector.X) > core::abs_(vector.Y) ) - { - s32 x = start.X; - s32 y; - - for(y=start.Y+yc; y!=end.Y+yc; y+=ys) - { - f32 tmp = (f32)(y+ys) * TileSize - line.start.Z; - tmp = a * tmp + line.start.X; - s32 xn = (s32)(tmp / TileSize); - - for(x; x!=xn+xs; x+=xs) - if( getIntersectionWithTile(x, y-yc, line, outIntersection) ) - { - outIntersection += getPosition(); - return true; - } - - x = xn; - } - - for(x; x!=end.X+xs; x+=xs) - if( getIntersectionWithTile(x, y-yc, line, outIntersection) ) - { - outIntersection += getPosition(); - return true; - } - } - // take x and calculate y coordinates of tile - else - { - s32 y = start.Y; - s32 x; - - for(x=start.X+xc; x!=end.X+xc; x+=xs) - { - f32 tmp = (f32)(x+xs) * TileSize - line.start.X; - tmp = b * tmp + line.start.Z; - s32 yn = (s32)(tmp / TileSize); - - for(y; y!=yn+ys; y+=ys) - if( getIntersectionWithTile(x-xc, y, line, outIntersection) ) - { - outIntersection += getPosition(); - return true; - } - - y = yn; - } - - for(y; y!=end.Y+ys; y+=ys) - if( getIntersectionWithTile(x-xc, y, line, outIntersection) ) - { - outIntersection += getPosition(); - return true; - } - } - - return false; -} - - - -// load height data from texture -void ShTlTerrainSceneNode::loadHeightMap(const c8 *filename, f32 scale, u32 w, u32 h) -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - if(!driver) return; - - video::IImage *image = driver->createImageFromFile(filename); - if(!image) return; - - s32 tw = image->getDimension().Width; - s32 th = image->getDimension().Height; - - s32 we = w + tw; - if(we > Size.Width+1) we = Size.Width+1; - s32 he = h + th; - if(he > Size.Height+1) he = Size.Height+1; - - tw = 0; - th = 0; - - for(s32 j=h; jgetPixel(tw, th); - - Data(i,j).Height = (f32)color.getLuminance()/255 * scale; - - tw++; - } - tw = 0; - th++; - } - - image->drop(); - - recalculateBoundingBox(); - - smoothNormals(); -} - - - -// load color data from texture -void ShTlTerrainSceneNode::loadColorMap(const c8 *filename, u32 w, u32 h) -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - if(!driver) return; - - video::IImage *image = driver->createImageFromFile(filename); - if(!image) return; - - s32 tw = (u32)image->getDimension().Width; - s32 th = (u32)image->getDimension().Height; - - s32 we = w + tw; - if(we > Size.Width+1) we = Size.Width+1; - s32 he = h + th; - if(he > Size.Height+1) he = Size.Height+1; - - tw = 0; - th = 0; - - for(s32 j=h; jgetPixel(tw, th); - - Data(i,j).Color = color; - - tw++; - } - tw = 0; - th++; - } - - image->drop(); -} - - - -// return true if sector is on screen -bool ShTlTerrainSceneNode::isSectorOnScreen(TlTSector* sctr) -{ - // bounding box of sector - core::aabbox3d box = sctr->BoundingBox; - - // get absolute position of bounding box - box.MinEdge = box.MinEdge + getPosition(); - box.MaxEdge = box.MaxEdge + getPosition(); - - // get camera frustrum planes - const scene::SViewFrustum* frustrum = SceneManager->getActiveCamera()->getViewFrustum(); - core::plane3d Left = frustrum->planes[scene::SViewFrustum::VF_LEFT_PLANE]; - core::plane3d Right = frustrum->planes[scene::SViewFrustum::VF_RIGHT_PLANE]; - core::plane3d Top = frustrum->planes[scene::SViewFrustum::VF_TOP_PLANE]; - core::plane3d Bottom = frustrum->planes[scene::SViewFrustum::VF_BOTTOM_PLANE]; - core::plane3d Near = frustrum->planes[scene::SViewFrustum::VF_NEAR_PLANE]; - core::plane3d Far = frustrum->planes[scene::SViewFrustum::VF_FAR_PLANE]; - - // test sector bounding box against planes - s32 leftRel, rightRel, topRel, bottomRel, nearRel, farRel; - - nearRel = box.classifyPlaneRelation(Near); - if(nearRel == core::ISREL3D_FRONT) return false; - - leftRel = box.classifyPlaneRelation(Left); - if(leftRel == core::ISREL3D_FRONT) return false; - - rightRel = box.classifyPlaneRelation(Right); - if(rightRel == core::ISREL3D_FRONT) return false; - - bottomRel = box.classifyPlaneRelation(Bottom); - if(bottomRel == core::ISREL3D_FRONT) return false; - - farRel = box.classifyPlaneRelation(Far); - if(farRel == core::ISREL3D_FRONT) return false; - - topRel = box.classifyPlaneRelation(Top); - if(topRel == core::ISREL3D_FRONT) return false; - - return true; -} - - - -// update vertices of sector -void ShTlTerrainSceneNode::updateVertices(TlTSector §or) -{ - scene::SMeshBuffer* MeshBuffer=new scene::SMeshBuffer(); - scene::SMesh* Mesh=new scene::SMesh(); - - for(u32 j=sector.Offset.Y; jPos = core::vector3df(x*TileSize, Data(x,y).Height, y*TileSize); - Tile(i,j).Vertex[1]->Pos = core::vector3df(x*TileSize, Data(x,y+1).Height, (y+1)*TileSize); - Tile(i,j).Vertex[2]->Pos = core::vector3df( (x+1)*TileSize, Data(x+1,y+1).Height, (y+1)*TileSize); - Tile(i,j).Vertex[3]->Pos = core::vector3df( (x+1)*TileSize, Data(x+1,y).Height, y*TileSize); - - // update normals - Tile(i,j).Vertex[0]->Normal = Data(x,y).Normal; - Tile(i,j).Vertex[1]->Normal = Data(x,y+1).Normal; - Tile(i,j).Vertex[2]->Normal = Data(x+1,y+1).Normal; - Tile(i,j).Vertex[3]->Normal = Data(x+1,y).Normal; - - // update texture coordinates - Tile(i,j).Vertex[0]->TCoords = UVdata(x,y).Vertex[0]; - Tile(i,j).Vertex[1]->TCoords = UVdata(x,y).Vertex[1]; - Tile(i,j).Vertex[2]->TCoords = UVdata(x,y).Vertex[2]; - Tile(i,j).Vertex[3]->TCoords = UVdata(x,y).Vertex[3]; - - for (int z=0;z<4;z++) - MeshBuffer->Vertices.push_back(video::S3DVertex( - Tile(i,j).Vertex[z]->Pos, - core::vector3df(0,0,0), video::SColor(0,0,0,0), core::vector2df(0,0))); - } - - for (u32 z=0;zIndices.push_back( - sector.Index[z]); - } - - Mesh->addMeshBuffer(MeshBuffer); - MeshBuffer->drop(); - - Mesh->drop(); -} - - - -// update 2nd texture layer -void ShTlTerrainSceneNode::updateTexture(u32* p, TlTSector §or) -{ - u32 x, y; - - // in case created texure is larger than terrain mesh, update one more pixel - // on each axis to get rid of unused pixels at the border blended in to used ones - u32 w = 0; - if(MeshSize.Width < CTexture->getSize().Width) w = 1; - u32 h = 0; - if(MeshSize.Height < CTexture->getSize().Height) h = 1; - - for(u32 j=sector.Offset.Y; jgetSize().Height-1 - j; - for(u32 i=sector.Offset.X; igetSize().Width + i] = Data(x,y).Color.color; - } - } -} - - - -// test if 3d line colide with tile -// returns true if yes, false if not and store intersection in "outIntersection" vector -bool ShTlTerrainSceneNode::getIntersectionWithTile(s32 w, s32 h, core::line3d line, core::vector3df &outIntersection) -{ - // test if not out of terrain bounds - if(w < 0) return false; - if(h < 0) return false; - if(w > Size.Width-1) return false; - if(h > Size.Height-1) return false; - - // vertices - core::vector3df v0(w*TileSize, getHeight(w,h), h*TileSize); - core::vector3df v1(w*TileSize, getHeight(w,h+1), (h+1)*TileSize); - core::vector3df v2((w+1)*TileSize, getHeight(w+1,h+1), (h+1)*TileSize); - core::vector3df v3((w+1)*TileSize, getHeight(w+1,h), h*TileSize); - - // firsth test collision with tile bounding box - core::aabbox3d box; - box.reset(v0); - box.addInternalPoint(v1); - box.addInternalPoint(v2); - box.addInternalPoint(v3); - - if (!box.intersectsWithLine(line)) return false;; - - // test collision with tile itself - - core::triangle3df triangle; - - // test upper left trialgle of tile - triangle.set(v0,v1,v2); - bool collision1 = triangle.getIntersectionWithLimitedLine(line, outIntersection); - - // test lower right triangle of tile - triangle.set(v0,v2,v3); - core::vector3df intersect2; - bool collision2 = triangle.getIntersectionWithLimitedLine(line, intersect2); - - // compare results and decide what to return - if(collision2) - { - // if line collide with both triangles, test which colision is closer to start of line - if(collision1) - { - f32 distance1 = line.start.getDistanceFromSQ(outIntersection); - f32 distance2 = line.start.getDistanceFromSQ(intersect2); - if(distance2 < distance1) outIntersection = intersect2; - return true; - } - // if it collide only with second one - else - { - outIntersection = intersect2; - return true; - } - } - - return collision1; -} +#include "ShTlTerrainSceneNode.h" + +// constructor +ShTlTerrainSceneNode::ShTlTerrainSceneNode(scene::ISceneManager* pSceneManager, + s32 width, s32 height, f32 tilesize, s32 visiblesize, + scene::ISceneNode* parent, s32 id) + : scene::ISceneNode(pSceneManager->getRootSceneNode(), pSceneManager, id) +{ + Size.Width = width; + Size.Height = height; + + TileSize = tilesize; + + // make sure rendered terrain mesh is not larger than terrain itself + if(visiblesize > Size.Width) visiblesize = Size.Width; + if(visiblesize > Size.Height) visiblesize = Size.Height; + + MeshSize.Width = visiblesize; + MeshSize.Height = visiblesize; + + MeshPosition = core::vector2d(0,0); + + Fnode = NULL; + + ShStep = 1; + + // create data array + + Data.reset(Size.Width+1, Size.Height+1); + + for(s32 j=0; j(0,1); + UVdata(i,j).Vertex[1] = core::vector2d(0,0); + UVdata(i,j).Vertex[2] = core::vector2d(1,0); + UVdata(i,j).Vertex[3] = core::vector2d(1,1); + } + + // calculate number of sectors + // terrain mesh will be split to 1 or 3 or 5 sectors on each axis depending on size + s32 w = 1; + s32 h = 1; + if(MeshSize.Width >= 30) w = 3; + if(MeshSize.Height >= 30) h = 3; + if(MeshSize.Width >= 50) w = 5; + if(MeshSize.Height >= 50) h = 5; + + // create sectors + Sector.reset(w, h); + + // find size of sectors in tiles + w = MeshSize.Width / Sector.width(); + h = MeshSize.Height / Sector.height(); + + for(s32 j=0; j(w, h); + + // find size of center sector in tiles + w = MeshSize.Width - Sector(0,0).Size.Width * (Sector.width()-1); + h = MeshSize.Height - Sector(0,0).Size.Height * (Sector.height()-1); + + {s32 j= Sector.height()/2; + for(s32 i=0; i0) Sector(i,j).Offset.X = Sector(i-1,j).Offset.X + Sector(i-1,j).Size.Width; + else Sector(i,j).Offset.X = 0; + if(j>0) Sector(i,j).Offset.Y = Sector(i,j-1).Offset.Y + Sector(i,j-1).Size.Height; + else Sector(i,j).Offset.Y = 0; + } + + // fill sectors with tiles + for(s32 j=0; jColor = video::SColor(255,255,255,255); + Tile(i,j).Vertex[1]->Color = video::SColor(255,255,255,255); + Tile(i,j).Vertex[2]->Color = video::SColor(255,255,255,255); + Tile(i,j).Vertex[3]->Color = video::SColor(255,255,255,255); + } + + // setup material + video::SMaterial material; + material.AmbientColor = video::SColor(255,255,255,255); + material.DiffuseColor = video::SColor(255,255,255,255); + material.EmissiveColor = video::SColor(255,0,0,0); + material.Shininess = 0.0f; + material.SpecularColor = video::SColor(255,0,0,0); + material.MaterialType = video::EMT_DETAIL_MAP; + + Material.push_back(material); + + // create 2nd texture layer + + // find size of texture, must be power of two + s32 tw = 2; + while(tw < MeshSize.Width) tw = tw + tw; + s32 th = 2; + while(th < MeshSize.Height) th = th + th; + + // create texture + // turn of mipmaps othervise they would need to be regenerated each time texture is updated + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + + bool mmflag = driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); + driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); + + CTexture = driver->addTexture(core::dimension2d(tw, th), "colortexture", video::ECF_A8R8G8B8); + + driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mmflag); + + // irrlicht 1.4 + /* + Material[0].TextureLayer[1].Texture = CTexture; + Material[0].TextureLayer[1].TextureWrap = video::ETC_CLAMP_TO_EDGE; + */ + // irrlicht 1.3: + Material[0].Textures[1] = CTexture; + Material[0].TextureWrap[1] = video::ETC_CLAMP_TO_EDGE; + + // setup UV coordinates of vertices on 2nd texture layer + f32 ax = (f32)MeshSize.Width / CTexture->getSize().Width / MeshSize.Width; + f32 ay = (f32)MeshSize.Height/ CTexture->getSize().Height / MeshSize.Height; + f32 ry = 1.0f - (f32)MeshSize.Height/ CTexture->getSize().Height; + + u32 n = MeshSize.Height-1; + for(s32 j=0; jTCoords2 = core::vector2d(i*ax, ry+(j+1)*ay); + Tile(i,n).Vertex[1]->TCoords2 = core::vector2d(i*ax, ry+j*ay); + Tile(i,n).Vertex[3]->TCoords2 = core::vector2d((i+1)*ax, ry+(j+1)*ay); + Tile(i,n).Vertex[2]->TCoords2 = core::vector2d((i+1)*ax, ry+j*ay); + } + n--; + } + + // set update vertices flag for sectors + for(s32 j=0; jregisterNodeForRendering(this); + + ISceneNode::OnRegisterSceneNode(); +} + + + +// renders terrain +void ShTlTerrainSceneNode::render() +{ + // update position if needed + if(Fnode) centerAt(Fnode->getPosition()); + + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + if (!driver) return; + + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + + driver->setMaterial(Material[0]); + + SectorsRendered = 0; + + // test if sectors are vissible + for(s32 j=0; jlock(); + + updateTexture(p, Sector(i,j)); + + Sector(i,j).UpdateTexture = false; + } + if(p) CTexture->unlock(); + + // render geometry + for(s32 j=0; jdrawIndexedTriangleList + (&Sector(i,j).Vertex[0], Sector(i,j).Vertex.size(), + &Sector(i,j).Index[0], Sector(i,j).Index.size()/3); + } + + // for debuging + if( DebugDataVisible == scene::EDS_OFF ) return; + + // wireframe overlay + if (DebugDataVisible == scene::EDS_MESH_WIRE_OVERLAY || DebugDataVisible == scene::EDS_FULL) + { + video::SMaterial m; + m.Lighting = false; + m.Wireframe = true; + m.BackfaceCulling = false; + m.AmbientColor = video::SColor(255,0,255,0); + m.DiffuseColor = video::SColor(255,0,255,0); + driver->setMaterial(m); + + for(s32 j=0; jdrawIndexedTriangleList + (&Sector(i,j).Vertex[0], Sector(i,j).Vertex.size(), + &Sector(i,j).Index[0], Sector(i,j).Index.size()/3); + } + } + } + + // terrain bounding box + if (DebugDataVisible == scene::EDS_BBOX || DebugDataVisible == scene::EDS_FULL) + { + video::SMaterial m; + m.Lighting = false; + driver->setMaterial(m); + + driver->draw3DBox(BoundingBox, video::SColor(0,255,255,255)); + } + + // sectors bounding boxes + if (DebugDataVisible == scene::EDS_BBOX_BUFFERS || DebugDataVisible == scene::EDS_FULL) + { + video::SMaterial m; + m.Lighting = false; + driver->setMaterial(m); + + for(s32 j=0; jdraw3DBox(Sector(i,j).BoundingBox, video::SColor(0,255,255,255)); + } + } + + // normals + if (DebugDataVisible == scene::EDS_NORMALS || DebugDataVisible == scene::EDS_FULL) + { + video::SMaterial m; + m.Lighting = false; + driver->setMaterial(m); + + for(s32 j=0; jdraw3DLine ( v[n].Pos, v[n].Pos + h, c ); + } + } + } +} + + + +// returns the axis aligned bounding box of terrain +const core::aabbox3d& ShTlTerrainSceneNode::getBoundingBox() const +{ + return BoundingBox; +} + + + +// recalculate terrain bounding box +void ShTlTerrainSceneNode::recalculateBoundingBox() +{ + BoundingBox.MinEdge.X = TileSize * MeshPosition.X; + BoundingBox.MinEdge.Y = Data(0,0).Height; + BoundingBox.MinEdge.Z = TileSize * MeshPosition.Y; + + BoundingBox.MaxEdge.X = TileSize * (MeshPosition.X + MeshSize.Width); + BoundingBox.MaxEdge.Y = Data(0,0).Height; + BoundingBox.MaxEdge.Z = TileSize * (MeshPosition.Y + MeshSize.Height); + + for(s32 j=0; j Data(i,j).Height) BoundingBox.MinEdge.Y = Data(i,j).Height; + if(BoundingBox.MaxEdge.Y < Data(i,j).Height) BoundingBox.MaxEdge.Y = Data(i,j).Height; + } + + + for(s32 j=0; j ShTlTerrainSceneNode::getSize() +{ + return Size; +} + + + +// return dimension of terrain tile +f32 ShTlTerrainSceneNode::getTileSize() +{ + return TileSize; +} + + + +// set new dimensions of terrain tiles +void ShTlTerrainSceneNode::setTileSize(f32 newsize) +{ + if(newsize != TileSize) + { + TileSize = newsize; + + update(); + } +} + + + +// returns dimension of rendered mesh in tiles +core::dimension2d ShTlTerrainSceneNode::getRenderedSize() +{ + return MeshSize; +} + + + +// return number of sectors +u32 ShTlTerrainSceneNode::getSectorCount() +{ + return Sector.width() * Sector.height(); +} + + + +// returns numner of sectors rendered last frame +u32 ShTlTerrainSceneNode::getSectorsRendered() +{ + return SectorsRendered; +} + + + +// return height of terrain spot at terrain coordinates +f32 ShTlTerrainSceneNode::getHeight(u32 w, u32 h) +{ + return Data(w,h).Height; +} + + + +// return height of terrain at any position +f32 ShTlTerrainSceneNode::getHeight(core::vector3df pos) +{ + // find position relative to terrain + pos = pos - getPosition(); + + if(pos.X>=0 && pos.X<(f32)Size.Width*TileSize && pos.Z>=0 && pos.Z<(f32)Size.Height*TileSize) + { + // calculatin coordinates of tile + s32 x = (s32) (pos.X / TileSize); + s32 y = (s32) (pos.Z / TileSize); + + // calculating position relative to tile + f32 xtil = pos.X - (x*TileSize); + f32 ytil = pos.Z - (y*TileSize); + + // finding trianle of tile + core::triangle3df triangle; + if(xtil<=ytil) + { + // upper left triangle of tile + triangle.pointA = core::vector3df(0, getHeight(x,y), 0); + triangle.pointB = core::vector3df(0, getHeight(x,y+1), TileSize); + triangle.pointC = core::vector3df(TileSize, getHeight(x+1,y+1), TileSize); + } + else + { + // lower right triangle of tile + triangle.pointA = core::vector3df(0, getHeight(x,y), 0); + triangle.pointB = core::vector3df(TileSize, getHeight(x+1,y+1), TileSize); + triangle.pointC = core::vector3df(TileSize, getHeight(x+1,y), 0); + } + + // calculating intersection with triangle + core::vector3df intersection; + triangle.getIntersectionWithLine(core::vector3df(xtil,0,ytil),core::vector3df(0,1,0),intersection); + + return intersection.Y + getPosition().Y; + } + else + return 0; +} + + + +// set relative height of terrain spot at terrain coordinates +void ShTlTerrainSceneNode::setHeight(u32 w, u32 h, f32 newheight) +{ + Data(w,h).Height = newheight; + + // recalculate bounding boxes + + if(newheight > BoundingBox.MaxEdge.Y) + { + BoundingBox.MaxEdge.Y = newheight; + + for(s32 j=0; j 0) // check if not out of array + v0 = core::vector3df(0, getHeight(w,h-1)-getHeight(w,h), -TileSize); + else + v0 = core::vector3df(0, 0, -TileSize); + // calculate vector to point -1,-1 + if(w > 0 && h > 0) // check if not out of array + v1 = core::vector3df(-TileSize, getHeight(w-1,h-1)-getHeight(w,h), -TileSize); + else + v1 = core::vector3df(-TileSize, 0, -TileSize); + n0 = v0.crossProduct(v1); + + // calculate vector to point -1,-1 + v0 = v1; + // calculate vector to point -1,0 + if(w > 0) + v1 = core::vector3df(-TileSize, getHeight(w-1,h)-getHeight(w,h), 0); + else + v1 = core::vector3df(-TileSize, 0, 0); + n1 = v0.crossProduct(v1); + + // calculate vector to point -1,0 + v0 = v1; + // calculate vector to point 0,1 + if(h < Size.Height) + v1 = core::vector3df(0, getHeight(w,h+1)-getHeight(w,h), TileSize); + else + v1 = core::vector3df(0, 0, TileSize); + n2 = v0.crossProduct(v1); + + // calculate vector to point 0,1 + v0 = v1; + // calculate vector to point 1,1 + if(w < Size.Width && h < Size.Height) + v1 = core::vector3df(TileSize, getHeight(w+1,h+1)-getHeight(w,h), TileSize); + else + v1 = core::vector3df(TileSize, 0, TileSize); + n3 = v0.crossProduct(v1); + + // calculate vector to point 1,1 + v0 = v1; + // calculate vector to point 1,0 + if(w < Size.Width) + v1 = core::vector3df(TileSize, getHeight(w+1,h)-getHeight(w,h), 0); + else + v1 = core::vector3df(TileSize, 0, 0); + n4 = v0.crossProduct(v1); + + // calculate vector to point 1,0 + v0 = v1; + // calculate vector to point 0,-1 + if(h > 0) + v1 = core::vector3df(0, getHeight(w,h-1)-getHeight(w,h), -TileSize); + else + v1 = core::vector3df(0, 0, -TileSize); + n5 = v0.crossProduct(v1); + + // calculate normals of 4 tiles around point + core::vector3df m0, m1, m2, m3; + m0 = (n1 - n0) /2 + n0; + m1 = n2; + m2 = (n4 - n3) /2 + n3; + m3 = n5; + + // calculate normals between oposing tiles + core::vector3df k0, k1; + k0 = (m2 - m0) /2 + m0; + k1 = (m3 - m1) /2 + m1; + + // calculate normal of point + core::vector3df n = (k1 - k0) /2 + k0; + n.normalize(); + setNormal(w,h,n); +} + +// recalculare normals of whole terrain making it look smooth under light +void ShTlTerrainSceneNode::smoothNormals() +{ + for(s32 j=0; j ShTlTerrainSceneNode::getTileUV(u32 w, u32 h, TILE_VERTEX corner) +{ + return UVdata(w,h).Vertex[corner]; +} + + + +// set texture coordinates of tile +void ShTlTerrainSceneNode::setTileUV(u32 w, u32 h, core::vector2d UVlowerLeft, + core::vector2d UVupperLeft, core::vector2d UVupperRight, + core::vector2d UVlowerRight) +{ + UVdata(w,h).Vertex[0] = UVlowerLeft; + UVdata(w,h).Vertex[1] = UVupperLeft; + UVdata(w,h).Vertex[2] = UVupperRight; + UVdata(w,h).Vertex[3] = UVlowerRight; +} + + + +// stretch texture over whole terrain +void ShTlTerrainSceneNode::stretchTexture(core::vector2d scale) +{ + f32 ax = scale.X / Size.Width; + f32 ay = scale.X / Size.Height; + + u32 n = Size.Height-1; + for(s32 j=0; j(i*ax, j*ay); + UVdata(i,n).Vertex[0] = core::vector2d(i*ax, j*ay+ay); + UVdata(i,n).Vertex[3] = core::vector2d(i*ax+ax, j*ay+ay); + UVdata(i,n).Vertex[2] = core::vector2d(i*ax+ax, j*ay); + } + n--; + } +} + + + +// stretch texture over every tile individualy +void ShTlTerrainSceneNode::stretchTextureOverTile(core::vector2d scale) +{ + for(s32 j=0; j(0, 0); + UVdata(i,j).Vertex[0] = core::vector2d(0, scale.Y); + UVdata(i,j).Vertex[3] = core::vector2d(scale.X, scale.Y); + UVdata(i,j).Vertex[2] = core::vector2d(scale.X, 0); + } +} + + + +// rotate texture of tile 90 degrees +void ShTlTerrainSceneNode::rotateTileTexture90(u32 w, u32 h) +{ + core::vector2d tmp = UVdata(w,h).Vertex[3]; + + UVdata(w,h).Vertex[3] = UVdata(w,h).Vertex[2]; + UVdata(w,h).Vertex[2] = UVdata(w,h).Vertex[1]; + UVdata(w,h).Vertex[1] = UVdata(w,h).Vertex[0]; + UVdata(w,h).Vertex[0] = tmp; +} + + + +// rotate texture of tile 180 degrees +void ShTlTerrainSceneNode::rotateTileTexture180(u32 w, u32 h) +{ + core::vector2d tmp = UVdata(w,h).Vertex[3]; + + UVdata(w,h).Vertex[3] = UVdata(w,h).Vertex[1]; + UVdata(w,h).Vertex[1] = tmp; + + tmp = UVdata(w,h).Vertex[2]; + + UVdata(w,h).Vertex[2] = UVdata(w,h).Vertex[0]; + UVdata(w,h).Vertex[0] = tmp; +} + + + +// rotate texture of tile 270 degrees +void ShTlTerrainSceneNode::rotateTileTexture270(u32 w, u32 h) +{ + core::vector2d tmp = UVdata(w,h).Vertex[3]; + + UVdata(w,h).Vertex[3] = UVdata(w,h).Vertex[0]; + UVdata(w,h).Vertex[0] = UVdata(w,h).Vertex[1]; + UVdata(w,h).Vertex[1] = UVdata(w,h).Vertex[2]; + UVdata(w,h).Vertex[2] = tmp; +} + + + +// flip (mirror) texture of tile horizontaly +void ShTlTerrainSceneNode::flipTileTextureHorizontal(u32 w, u32 h) +{ + core::vector2d tmp = UVdata(w,h).Vertex[3]; + + UVdata(w,h).Vertex[3] = UVdata(w,h).Vertex[0]; + UVdata(w,h).Vertex[0] = tmp; + + tmp = UVdata(w,h).Vertex[2]; + + UVdata(w,h).Vertex[2] = UVdata(w,h).Vertex[1]; + UVdata(w,h).Vertex[1] = tmp; +} + + + +// flip (mirror) texture of tile verticaly +void ShTlTerrainSceneNode::flipTileTextureVertical(u32 w, u32 h) +{ + core::vector2d tmp = UVdata(w,h).Vertex[3]; + + UVdata(w,h).Vertex[3] = UVdata(w,h).Vertex[2]; + UVdata(w,h).Vertex[2] = tmp; + + tmp = UVdata(w,h).Vertex[0]; + + UVdata(w,h).Vertex[0] = UVdata(w,h).Vertex[1]; + UVdata(w,h).Vertex[1] = tmp; +} + + + +// get color of tile at terrain coordinates +video::SColor ShTlTerrainSceneNode::getColor(u32 w, u32 h) +{ + return Data(w,h).Color; +} + + + +// set color of tile at terrain coordinates +void ShTlTerrainSceneNode::setColor(u32 w, u32 h, video::SColor newcolor) +{ + Data(w,h).Color = newcolor; +} + + + +// set rendered mesh position relative to terrain +void ShTlTerrainSceneNode::setMeshPosition(core::vector2d pos) +{ + // correct if out of terrain bounds + if(pos.X < 0) pos.X = 0; + if(pos.Y < 0) pos.Y = 0; + + if(pos.X > (s32)(Size.Width - MeshSize.Width)) pos.X = (s32)(Size.Width - MeshSize.Width); + if(pos.Y > (s32)(Size.Height - MeshSize.Height)) pos.Y = (s32)(Size.Height - MeshSize.Height); + + // update + if(pos.X > MeshPosition.X + ShStep || pos.X < MeshPosition.X - ShStep || + pos.Y > MeshPosition.Y + ShStep || pos.Y < MeshPosition.Y - ShStep) + { + MeshPosition = pos; + + update(); + } +} + + + +// center rendered mesh at 3d coordinates +void ShTlTerrainSceneNode::centerAt(core::vector3d pos) +{ + // find position relative to terrain + pos.X = pos.X - getPosition().X; + pos.Z = pos.Z - getPosition().Z; + + // offset center + pos.X = pos.X - TileSize * MeshSize.Width/2; + pos.Z = pos.Z - TileSize * MeshSize.Height/2; + + // find equivalent in tiles + s32 x = (s32)(pos.X / TileSize); + s32 y = (s32)(pos.Z / TileSize); + + setMeshPosition(core::vector2d(x,y)); +} + + + +// update rendered mesh +void ShTlTerrainSceneNode::update() +{ + // update position of bounding boxes + BoundingBox.MinEdge = core::vector3df(MeshPosition.X*TileSize, BoundingBox.MinEdge.Y, MeshPosition.Y*TileSize); + BoundingBox.MaxEdge = core::vector3df( (MeshPosition.X+MeshSize.Width)*TileSize, BoundingBox.MaxEdge.Y, (MeshPosition.Y+MeshSize.Height)*TileSize); + + for(s32 j=0; j line, core::vector3df &outIntersection) +{ + //get relative position of line to terrain + line.start = line.start - getPosition(); + line.end = line.end - getPosition(); + + // find 2d vector of line + core::vector2d vector; + vector.X = line.end.X - line.start.X; + vector.Y = line.end.Z - line.start.Z; + + // calculate variables used later in calculating coordinates on line + // used equations are: "x = y * a + c" and "y = x * b + d" + // where "a = x / y" and "b = y / x" + f32 a = 0; + if(vector.Y != 0) a = vector.X / vector.Y; + + f32 b = 0; + if(vector.X != 0) b = vector.Y / vector.X; + + // calculate starting and ending tiles + core::vector3d start; + start.X = (s32)(line.start.X / TileSize); + start.Y = (s32)(line.start.Z / TileSize); + + core::vector3d end; + end.X = (s32)(line.end.X / TileSize); + end.Y = (s32)(line.end.Z / TileSize); + + // some variables dependant on line orientation + s32 xs = 1; + s32 xc = 0; + if(vector.X < 0) + { + xs = -1; + xc = 1; + } + + s32 ys = 1; + s32 yc = 0; + if(vector.Y < 0) + { + ys = -1; + yc = 1; + } + + // calculate tiles which can intersect with line based on their 2d position + // then test for intersection + + // take y and calculate x coordinates of tile + if( core::abs_(vector.X) > core::abs_(vector.Y) ) + { + s32 x = start.X; + s32 y; + + for(y=start.Y+yc; y!=end.Y+yc; y+=ys) + { + f32 tmp = (f32)(y+ys) * TileSize - line.start.Z; + tmp = a * tmp + line.start.X; + s32 xn = (s32)(tmp / TileSize); + + for(x; x!=xn+xs; x+=xs) + if( getIntersectionWithTile(x, y-yc, line, outIntersection) ) + { + outIntersection += getPosition(); + return true; + } + + x = xn; + } + + for(x; x!=end.X+xs; x+=xs) + if( getIntersectionWithTile(x, y-yc, line, outIntersection) ) + { + outIntersection += getPosition(); + return true; + } + } + // take x and calculate y coordinates of tile + else + { + s32 y = start.Y; + s32 x; + + for(x=start.X+xc; x!=end.X+xc; x+=xs) + { + f32 tmp = (f32)(x+xs) * TileSize - line.start.X; + tmp = b * tmp + line.start.Z; + s32 yn = (s32)(tmp / TileSize); + + for(y; y!=yn+ys; y+=ys) + if( getIntersectionWithTile(x-xc, y, line, outIntersection) ) + { + outIntersection += getPosition(); + return true; + } + + y = yn; + } + + for(y; y!=end.Y+ys; y+=ys) + if( getIntersectionWithTile(x-xc, y, line, outIntersection) ) + { + outIntersection += getPosition(); + return true; + } + } + + return false; +} + + + +// load height data from texture +void ShTlTerrainSceneNode::loadHeightMap(const c8 *filename, f32 scale, u32 w, u32 h) +{ + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + if(!driver) return; + + video::IImage *image = driver->createImageFromFile(filename); + if(!image) return; + + s32 tw = image->getDimension().Width; + s32 th = image->getDimension().Height; + + s32 we = w + tw; + if(we > Size.Width+1) we = Size.Width+1; + s32 he = h + th; + if(he > Size.Height+1) he = Size.Height+1; + + tw = 0; + th = 0; + + for(s32 j=h; jgetPixel(tw, th); + + Data(i,j).Height = (f32)color.getLuminance()/255 * scale; + + tw++; + } + tw = 0; + th++; + } + + image->drop(); + + recalculateBoundingBox(); + + smoothNormals(); +} + + + +// load color data from texture +void ShTlTerrainSceneNode::loadColorMap(const c8 *filename, u32 w, u32 h) +{ + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + if(!driver) return; + + video::IImage *image = driver->createImageFromFile(filename); + if(!image) return; + + s32 tw = (u32)image->getDimension().Width; + s32 th = (u32)image->getDimension().Height; + + s32 we = w + tw; + if(we > Size.Width+1) we = Size.Width+1; + s32 he = h + th; + if(he > Size.Height+1) he = Size.Height+1; + + tw = 0; + th = 0; + + for(s32 j=h; jgetPixel(tw, th); + + Data(i,j).Color = color; + + tw++; + } + tw = 0; + th++; + } + + image->drop(); +} + + + +// return true if sector is on screen +bool ShTlTerrainSceneNode::isSectorOnScreen(TlTSector* sctr) +{ + // bounding box of sector + core::aabbox3d box = sctr->BoundingBox; + + // get absolute position of bounding box + box.MinEdge = box.MinEdge + getPosition(); + box.MaxEdge = box.MaxEdge + getPosition(); + + // get camera frustrum planes + const scene::SViewFrustum* frustrum = SceneManager->getActiveCamera()->getViewFrustum(); + core::plane3d Left = frustrum->planes[scene::SViewFrustum::VF_LEFT_PLANE]; + core::plane3d Right = frustrum->planes[scene::SViewFrustum::VF_RIGHT_PLANE]; + core::plane3d Top = frustrum->planes[scene::SViewFrustum::VF_TOP_PLANE]; + core::plane3d Bottom = frustrum->planes[scene::SViewFrustum::VF_BOTTOM_PLANE]; + core::plane3d Near = frustrum->planes[scene::SViewFrustum::VF_NEAR_PLANE]; + core::plane3d Far = frustrum->planes[scene::SViewFrustum::VF_FAR_PLANE]; + + // test sector bounding box against planes + s32 leftRel, rightRel, topRel, bottomRel, nearRel, farRel; + + nearRel = box.classifyPlaneRelation(Near); + if(nearRel == core::ISREL3D_FRONT) return false; + + leftRel = box.classifyPlaneRelation(Left); + if(leftRel == core::ISREL3D_FRONT) return false; + + rightRel = box.classifyPlaneRelation(Right); + if(rightRel == core::ISREL3D_FRONT) return false; + + bottomRel = box.classifyPlaneRelation(Bottom); + if(bottomRel == core::ISREL3D_FRONT) return false; + + farRel = box.classifyPlaneRelation(Far); + if(farRel == core::ISREL3D_FRONT) return false; + + topRel = box.classifyPlaneRelation(Top); + if(topRel == core::ISREL3D_FRONT) return false; + + return true; +} + + + +// update vertices of sector +void ShTlTerrainSceneNode::updateVertices(TlTSector §or) +{ + scene::SMeshBuffer* MeshBuffer=new scene::SMeshBuffer(); + scene::SMesh* Mesh=new scene::SMesh(); + + for(u32 j=sector.Offset.Y; jPos = core::vector3df(x*TileSize, Data(x,y).Height, y*TileSize); + Tile(i,j).Vertex[1]->Pos = core::vector3df(x*TileSize, Data(x,y+1).Height, (y+1)*TileSize); + Tile(i,j).Vertex[2]->Pos = core::vector3df( (x+1)*TileSize, Data(x+1,y+1).Height, (y+1)*TileSize); + Tile(i,j).Vertex[3]->Pos = core::vector3df( (x+1)*TileSize, Data(x+1,y).Height, y*TileSize); + + // update normals + Tile(i,j).Vertex[0]->Normal = Data(x,y).Normal; + Tile(i,j).Vertex[1]->Normal = Data(x,y+1).Normal; + Tile(i,j).Vertex[2]->Normal = Data(x+1,y+1).Normal; + Tile(i,j).Vertex[3]->Normal = Data(x+1,y).Normal; + + // update texture coordinates + Tile(i,j).Vertex[0]->TCoords = UVdata(x,y).Vertex[0]; + Tile(i,j).Vertex[1]->TCoords = UVdata(x,y).Vertex[1]; + Tile(i,j).Vertex[2]->TCoords = UVdata(x,y).Vertex[2]; + Tile(i,j).Vertex[3]->TCoords = UVdata(x,y).Vertex[3]; + + for (int z=0;z<4;z++) + MeshBuffer->Vertices.push_back(video::S3DVertex( + Tile(i,j).Vertex[z]->Pos, + core::vector3df(0,0,0), video::SColor(0,0,0,0), core::vector2df(0,0))); + } + + for (u32 z=0;zIndices.push_back( + sector.Index[z]); + } + + Mesh->addMeshBuffer(MeshBuffer); + MeshBuffer->drop(); + + Mesh->drop(); +} + + + +// update 2nd texture layer +void ShTlTerrainSceneNode::updateTexture(u32* p, TlTSector §or) +{ + u32 x, y; + + // in case created texure is larger than terrain mesh, update one more pixel + // on each axis to get rid of unused pixels at the border blended in to used ones + u32 w = 0; + if(MeshSize.Width < CTexture->getSize().Width) w = 1; + u32 h = 0; + if(MeshSize.Height < CTexture->getSize().Height) h = 1; + + for(u32 j=sector.Offset.Y; jgetSize().Height-1 - j; + for(u32 i=sector.Offset.X; igetSize().Width + i] = Data(x,y).Color.color; + } + } +} + + + +// test if 3d line colide with tile +// returns true if yes, false if not and store intersection in "outIntersection" vector +bool ShTlTerrainSceneNode::getIntersectionWithTile(s32 w, s32 h, core::line3d line, core::vector3df &outIntersection) +{ + // test if not out of terrain bounds + if(w < 0) return false; + if(h < 0) return false; + if(w > Size.Width-1) return false; + if(h > Size.Height-1) return false; + + // vertices + core::vector3df v0(w*TileSize, getHeight(w,h), h*TileSize); + core::vector3df v1(w*TileSize, getHeight(w,h+1), (h+1)*TileSize); + core::vector3df v2((w+1)*TileSize, getHeight(w+1,h+1), (h+1)*TileSize); + core::vector3df v3((w+1)*TileSize, getHeight(w+1,h), h*TileSize); + + // firsth test collision with tile bounding box + core::aabbox3d box; + box.reset(v0); + box.addInternalPoint(v1); + box.addInternalPoint(v2); + box.addInternalPoint(v3); + + if (!box.intersectsWithLine(line)) return false;; + + // test collision with tile itself + + core::triangle3df triangle; + + // test upper left trialgle of tile + triangle.set(v0,v1,v2); + bool collision1 = triangle.getIntersectionWithLimitedLine(line, outIntersection); + + // test lower right triangle of tile + triangle.set(v0,v2,v3); + core::vector3df intersect2; + bool collision2 = triangle.getIntersectionWithLimitedLine(line, intersect2); + + // compare results and decide what to return + if(collision2) + { + // if line collide with both triangles, test which colision is closer to start of line + if(collision1) + { + f32 distance1 = line.start.getDistanceFromSQ(outIntersection); + f32 distance2 = line.start.getDistanceFromSQ(intersect2); + if(distance2 < distance1) outIntersection = intersect2; + return true; + } + // if it collide only with second one + else + { + outIntersection = intersect2; + return true; + } + } + + return collision1; +} diff --git a/src/Client/GUI/ShTlTerrainSceneNode.h b/src/Client/GUI/ShTlTerrainSceneNode.h index 75d9c9e..beb2ae9 100644 --- a/src/Client/GUI/ShTlTerrainSceneNode.h +++ b/src/Client/GUI/ShTlTerrainSceneNode.h @@ -1,317 +1,317 @@ -/*-----------------------------------------------------------------------------* -| headerfile ShTlTerrainSceneNode.h | -| | -| version 2.00 | -| date: (29.04.2007) | -| | -| author: Michal Švantner | -| | -| Shifting Tiled Terrain Scene Node | -| | -| This node can render quit large terrain consisting of tiles by storing data | -| of individual tiles in array and rendering only part of terrain around | -| defined position and in defined size. This can be position of another scene | -| node defined by user and terrain node can be set to render around it | -| automaticaly. | -| It is done by creating mesh of given size which then glide over invisible | -| data skelet like a peace of soft cloth, updating its atributes from data | -| arrays each time it shifts to a new position. | -| | -| Diferent atributes of individual tiles can be adjusted, most of them on run | -| time. Namely texture coordinates, position of tile vertices, normals and | -| color. | -| | -| Scene node use 2 texture layers. | -| Firsth texture is standard texture which gives detail to terrain close by | -| and can by assigned to individual tiles by setting their UV coordinates. | -| User have complete freedom as howe to apply this texture to tiles. Texture | -| can for example consist of seweral subtextures and each can be set to | -| diferent tiles using UV coordinates. | -| | -| Second texture is created by terrain node internaly and is used to render | -| color of individual tiles. This adds some variability to terrain at distance.| -| Both textures are blended together using EMT_DETAIL_MAP material type. | -| | -| Normaly textures should be set in oposite order but there are some bugs with | -| updating texture under OpenGL so until it gets solved I have to stick with | -| detailmap applyed as firsth texture layer. Not perfect but working. | -| | -| This scene node also provide user with functions to get height at given | -| coordinates and test 3d line for collision useful for line of sight or bullet| -| collision testing. | -| | -| Rendered mesh is split in to seweral sectors which are culled individualy. | -| This exclude around 60% of polygoons from rendering. | -| | -| Writen for Irrlicht engine version 1.3 | -*-----------------------------------------------------------------------------*/ - -#ifndef SHTLTERRAINSCENENODE_H -#define SHTLTERRAINSCENENODE_H - -#include "irrlicht/irrlicht.h" -using namespace irr; - -#include "TlTMesh.h" - -// Shifting Tiled Terrain Scene Node class -class ShTlTerrainSceneNode : public scene::ISceneNode -{ - // dimensions of whole terrain - core::dimension2d Size; - - // bounding box of terrain mesh - core::aabbox3d BoundingBox; - - // terrain vertex data - array2d Data; - - // terrain tile UV data for 1th texture layer - array2d UVdata; - - // terrain mesh sectors - array2d Sector; - - // array of pointers to vertices of tiles - array2d Tile; - - // size of vissible terrain mesh - core::dimension2d MeshSize; - - // position of vissible terrain mesh relative to whole terrain in tiles - core::vector2d MeshPosition; - - // material - core::array Material; - - // size of terrain tiles - f32 TileSize; - - // node terrain mesh should be rendered around - scene::ISceneNode* Fnode; - - // color texture set as 2nd texture layer - video::ITexture* CTexture; - - // number of sectors rendered last frame - u32 SectorsRendered; - - // howe many tiles should be skiped before terrain mesh gets updated - s32 ShStep; - - // return true if sector is on screen - virtual bool isSectorOnScreen(TlTSector* sctr); - - // update vertices of sector - virtual void updateVertices(TlTSector §or); - - // update 2nd texture layer - virtual void updateTexture(u32* p, TlTSector §or); - - // return true if 3d line colide with tile - virtual bool getIntersectionWithTile(s32 w, s32 h, core::line3d line, - core::vector3df &outIntersection); - -public: - - // constructor - // \param smgr -pointer to scene manager - // \param width - width of terrain in tiles - // \param height - heighth of terrain in tiles - // \param tilesize -size of tile - // \param rendersize -size of rendered terrain mesh in tiles - // \param parent -parent scene node - // \param id -ID number - ShTlTerrainSceneNode(scene::ISceneManager* pSceneManager, s32 width, s32 height, - f32 tilesize, s32 rendersize, scene::ISceneNode* parent = 0, s32 id = -1); - - // destructor - ~ShTlTerrainSceneNode(); - - // frame - virtual void OnRegisterSceneNode(); - - // renders terrain - virtual void render(); - - // returns the axis aligned bounding box of terrain - virtual const core::aabbox3d& getBoundingBox() const; - - // recalculate terrain bounding box - virtual void recalculateBoundingBox(); - - // returns amount of materials used by terrain - // this terrain uses only one material - virtual u32 getMaterialCount(); - - // returns the material of terrain based on the zero based index - // \param i -index of material to return - virtual video::SMaterial& getMaterial(u32 i); - - // return number of tiles to skip before terrain mesh gets updated - virtual s32 getStep(); - - // set number of tiles to skip before terrain mesh gets updated, default is 1 - // updating slows down rendering and seting step higher will cause terrain to update less ofthen - // \param newstep -amount of tiles to skip before updating - virtual void setStep(u32 newstep); - - // return dimensions of whole terrain in tiles - virtual core::dimension2d getSize(); - - // return dimension of terrain tile - virtual f32 getTileSize(); - - // set new dimensions of terrain tile - // \param newsize -new size of tile - virtual void setTileSize(f32 newsize); - - // returns dimension of rendered mesh in tiles - virtual core::dimension2d getRenderedSize(); - - // return number of sectors into which terrain mesh is divided - virtual u32 getSectorCount(); - - // returns sectors rendered last frame - virtual u32 getSectorsRendered(); - - // return relative height of terrain spot at terrain coordinates - // \param w -width coordinate of spot in tiles - // \param h -height coordinate of spot in tiles - virtual f32 getHeight(u32 w, u32 h); - - // return height of terrain at any position - // \param pos -3d coordinates at which to get height of terrain - virtual f32 getHeight(core::vector3df pos); - - // set relative height of terrain spot at terrain coordinates - // \param w -width coordinate of spot in tiles - // \param h -height coordinate of spot in tiles - // \param newheight -new height of spot - virtual void setHeight(u32 w, u32 h, f32 newheight); - - // return normal of terrain at terrain coordinates - // \param w -width coordinate of spot in tiles - // \param h -height coordinate of spot in tiles - virtual core::vector3df getNormal(u32 w, u32 h); - - // set normal of terrain at terrain coordinates - // \param w -width coordinate of spot in tiles - // \param h -height coordinate of spot in tiles - // \param newnormal -new normal vector terrain spot - virtual void setNormal(s32 w, s32 h, core::vector3df newnormal); - - // recalculate normal at terrain coordinates - // \param w -width coordinate of spot in tiles - // \param h -height coordinate of spot in tiles - virtual void recalculateNormal(s32 w, s32 h); - - // recalculare normals of whole terrain making it look smooth under light - virtual void smoothNormals(); - - // get texture coordinates of tile corner - // \param w -width coordinate of tile - // \param h -height coordinate of tile - // \param corner -tile corner, can be LOWER_LEFT, UPPER_LEFT, UPPER_RIGHT, LOWER_RIGHT - virtual core::vector2d getTileUV(u32 w, u32 h, TILE_VERTEX corner); - - // set texture coordinates of tile - // \param w -width coordinate of tile - // \param h -height coordinate of tile - // \param UVLowerLeft -UV coordinates of lower left corner - // \param UVUpperLeft -UV coordinates of upper left corner - // \param UVUpperRight -UV coordinates of upper right corner - // \param UVLowerRight -UV coordinates of lower right corner - virtual void setTileUV(u32 w, u32 h, core::vector2d UVLowerLeft, - core::vector2d UVUpperLeft, core::vector2d UVUpperRight, - core::vector2d UVLowerRight); - - // stretch texture over whole terrain - // \param scale -scale of the texture stretched, 2,2 would stretch it twice - virtual void stretchTexture(core::vector2d scale = core::vector2d(1,1)); - - // stretch texture over every tile individualy - // \param scale -scale of the texture stretched, 0.5,0.5 would display half of texture over each tile - virtual void stretchTextureOverTile(core::vector2d scale = core::vector2d(1,1)); - - // rotate texture of tile 90 degrees - // \param w -width coordinate of tile - // \param h -height coordinate of tile - virtual void rotateTileTexture90(u32 w, u32 h); - - // rotate texture of tile 180 degrees - // \param w -width coordinate of tile - // \param h -height coordinate of tile - virtual void rotateTileTexture180(u32 w, u32 h); - - // rotate texture of tile 270 degrees - // \param w -width coordinate of tile - // \param h -height coordinate of tile - virtual void rotateTileTexture270(u32 w, u32 h); - - // flip (mirror) texture of tile horizontaly - // \param w -width coordinate of tile - // \param h -height coordinate of tile - virtual void flipTileTextureHorizontal(u32 w, u32 h); - - // flip (mirror) texture of tile verticaly - // \param w -width coordinate of tile - // \param h -height coordinate of tile - virtual void flipTileTextureVertical(u32 w, u32 h); - - // get color of tile at terrain coordinates - // \param w -width coordinate of tile - // \param h -height coordinate of tile - virtual video::SColor getColor(u32 w, u32 h); - - // set color of tile at terrain coordinates - // \param w -width coordinate of tile - // \param h -height coordinate of tile - // \param newcolor -new color of tile - virtual void setColor(u32 w, u32 h, video::SColor newcolor); - - // set rendered mesh position relative to terrain - // note that origin of mesh is in its lower left corner - // \param pos -new position of mesh relative to terrain in tiles - virtual void setMeshPosition(core::vector2d pos); - - // center rendered mesh at 3d coordinates - // \param pos -new position mesh should be rendered around - virtual void centerAt(core::vector3d pos); - - // update rendered mesh - virtual void update(); - - // set scene node terrain mesh should be automaticly rendered arround - // can be camera or player node for example - // \param node -scene node to automaticaly follow - virtual void follow(scene::ISceneNode* node); - - // cancel pervious function - // stop following scene node if any - virtual void stop(); - - // test if 3d line colide with terrain - // returns true if yes, false if not and store intersection in "outIntersection" vector - // \param line -3d line - // \param outIntersection -vector to store intersection point if any - virtual bool getIntersectionWithLine( core::line3d line, core::vector3df &outIntersection); - - // load height data from texture - // parameters allow to specify place where to load data, which makes possible - // to load terrain from seweral smaller textures - // \param filename -filename of texture - // \param scale -scale to apply at height data, if you want white color to be height of 10.5 set scale to 10.5 - // \param w -width coordinate of tile were to start loading - // \param h -height coordinate of tile were to start loading - virtual void loadHeightMap(const c8 *filename, f32 scale, u32 w = 0, u32 h = 0); - - // load color data from texture - // parameters allow to specify place where to load data, which makes possible - // to load terrain from seweral smaller textures - // \param filename -filename of texture - // \param w -width coordinate of tile were to start loading - // \param h -height coordinate of tile were to start loading - virtual void loadColorMap(const c8 *filename, u32 w = 0, u32 h = 0); -}; -#endif +/*-----------------------------------------------------------------------------* +| headerfile ShTlTerrainSceneNode.h | +| | +| version 2.00 | +| date: (29.04.2007) | +| | +| author: Michal Švantner | +| | +| Shifting Tiled Terrain Scene Node | +| | +| This node can render quit large terrain consisting of tiles by storing data | +| of individual tiles in array and rendering only part of terrain around | +| defined position and in defined size. This can be position of another scene | +| node defined by user and terrain node can be set to render around it | +| automaticaly. | +| It is done by creating mesh of given size which then glide over invisible | +| data skelet like a peace of soft cloth, updating its atributes from data | +| arrays each time it shifts to a new position. | +| | +| Diferent atributes of individual tiles can be adjusted, most of them on run | +| time. Namely texture coordinates, position of tile vertices, normals and | +| color. | +| | +| Scene node use 2 texture layers. | +| Firsth texture is standard texture which gives detail to terrain close by | +| and can by assigned to individual tiles by setting their UV coordinates. | +| User have complete freedom as howe to apply this texture to tiles. Texture | +| can for example consist of seweral subtextures and each can be set to | +| diferent tiles using UV coordinates. | +| | +| Second texture is created by terrain node internaly and is used to render | +| color of individual tiles. This adds some variability to terrain at distance.| +| Both textures are blended together using EMT_DETAIL_MAP material type. | +| | +| Normaly textures should be set in oposite order but there are some bugs with | +| updating texture under OpenGL so until it gets solved I have to stick with | +| detailmap applyed as firsth texture layer. Not perfect but working. | +| | +| This scene node also provide user with functions to get height at given | +| coordinates and test 3d line for collision useful for line of sight or bullet| +| collision testing. | +| | +| Rendered mesh is split in to seweral sectors which are culled individualy. | +| This exclude around 60% of polygoons from rendering. | +| | +| Writen for Irrlicht engine version 1.3 | +*-----------------------------------------------------------------------------*/ + +#ifndef SHTLTERRAINSCENENODE_H +#define SHTLTERRAINSCENENODE_H + +#include "irrlicht/irrlicht.h" +using namespace irr; + +#include "TlTMesh.h" + +// Shifting Tiled Terrain Scene Node class +class ShTlTerrainSceneNode : public scene::ISceneNode +{ + // dimensions of whole terrain + core::dimension2d Size; + + // bounding box of terrain mesh + core::aabbox3d BoundingBox; + + // terrain vertex data + array2d Data; + + // terrain tile UV data for 1th texture layer + array2d UVdata; + + // terrain mesh sectors + array2d Sector; + + // array of pointers to vertices of tiles + array2d Tile; + + // size of vissible terrain mesh + core::dimension2d MeshSize; + + // position of vissible terrain mesh relative to whole terrain in tiles + core::vector2d MeshPosition; + + // material + core::array Material; + + // size of terrain tiles + f32 TileSize; + + // node terrain mesh should be rendered around + scene::ISceneNode* Fnode; + + // color texture set as 2nd texture layer + video::ITexture* CTexture; + + // number of sectors rendered last frame + u32 SectorsRendered; + + // howe many tiles should be skiped before terrain mesh gets updated + s32 ShStep; + + // return true if sector is on screen + virtual bool isSectorOnScreen(TlTSector* sctr); + + // update vertices of sector + virtual void updateVertices(TlTSector §or); + + // update 2nd texture layer + virtual void updateTexture(u32* p, TlTSector §or); + + // return true if 3d line colide with tile + virtual bool getIntersectionWithTile(s32 w, s32 h, core::line3d line, + core::vector3df &outIntersection); + +public: + + // constructor + // \param smgr -pointer to scene manager + // \param width - width of terrain in tiles + // \param height - heighth of terrain in tiles + // \param tilesize -size of tile + // \param rendersize -size of rendered terrain mesh in tiles + // \param parent -parent scene node + // \param id -ID number + ShTlTerrainSceneNode(scene::ISceneManager* pSceneManager, s32 width, s32 height, + f32 tilesize, s32 rendersize, scene::ISceneNode* parent = 0, s32 id = -1); + + // destructor + ~ShTlTerrainSceneNode(); + + // frame + virtual void OnRegisterSceneNode(); + + // renders terrain + virtual void render(); + + // returns the axis aligned bounding box of terrain + virtual const core::aabbox3d& getBoundingBox() const; + + // recalculate terrain bounding box + virtual void recalculateBoundingBox(); + + // returns amount of materials used by terrain + // this terrain uses only one material + virtual u32 getMaterialCount(); + + // returns the material of terrain based on the zero based index + // \param i -index of material to return + virtual video::SMaterial& getMaterial(u32 i); + + // return number of tiles to skip before terrain mesh gets updated + virtual s32 getStep(); + + // set number of tiles to skip before terrain mesh gets updated, default is 1 + // updating slows down rendering and seting step higher will cause terrain to update less ofthen + // \param newstep -amount of tiles to skip before updating + virtual void setStep(u32 newstep); + + // return dimensions of whole terrain in tiles + virtual core::dimension2d getSize(); + + // return dimension of terrain tile + virtual f32 getTileSize(); + + // set new dimensions of terrain tile + // \param newsize -new size of tile + virtual void setTileSize(f32 newsize); + + // returns dimension of rendered mesh in tiles + virtual core::dimension2d getRenderedSize(); + + // return number of sectors into which terrain mesh is divided + virtual u32 getSectorCount(); + + // returns sectors rendered last frame + virtual u32 getSectorsRendered(); + + // return relative height of terrain spot at terrain coordinates + // \param w -width coordinate of spot in tiles + // \param h -height coordinate of spot in tiles + virtual f32 getHeight(u32 w, u32 h); + + // return height of terrain at any position + // \param pos -3d coordinates at which to get height of terrain + virtual f32 getHeight(core::vector3df pos); + + // set relative height of terrain spot at terrain coordinates + // \param w -width coordinate of spot in tiles + // \param h -height coordinate of spot in tiles + // \param newheight -new height of spot + virtual void setHeight(u32 w, u32 h, f32 newheight); + + // return normal of terrain at terrain coordinates + // \param w -width coordinate of spot in tiles + // \param h -height coordinate of spot in tiles + virtual core::vector3df getNormal(u32 w, u32 h); + + // set normal of terrain at terrain coordinates + // \param w -width coordinate of spot in tiles + // \param h -height coordinate of spot in tiles + // \param newnormal -new normal vector terrain spot + virtual void setNormal(s32 w, s32 h, core::vector3df newnormal); + + // recalculate normal at terrain coordinates + // \param w -width coordinate of spot in tiles + // \param h -height coordinate of spot in tiles + virtual void recalculateNormal(s32 w, s32 h); + + // recalculare normals of whole terrain making it look smooth under light + virtual void smoothNormals(); + + // get texture coordinates of tile corner + // \param w -width coordinate of tile + // \param h -height coordinate of tile + // \param corner -tile corner, can be LOWER_LEFT, UPPER_LEFT, UPPER_RIGHT, LOWER_RIGHT + virtual core::vector2d getTileUV(u32 w, u32 h, TILE_VERTEX corner); + + // set texture coordinates of tile + // \param w -width coordinate of tile + // \param h -height coordinate of tile + // \param UVLowerLeft -UV coordinates of lower left corner + // \param UVUpperLeft -UV coordinates of upper left corner + // \param UVUpperRight -UV coordinates of upper right corner + // \param UVLowerRight -UV coordinates of lower right corner + virtual void setTileUV(u32 w, u32 h, core::vector2d UVLowerLeft, + core::vector2d UVUpperLeft, core::vector2d UVUpperRight, + core::vector2d UVLowerRight); + + // stretch texture over whole terrain + // \param scale -scale of the texture stretched, 2,2 would stretch it twice + virtual void stretchTexture(core::vector2d scale = core::vector2d(1,1)); + + // stretch texture over every tile individualy + // \param scale -scale of the texture stretched, 0.5,0.5 would display half of texture over each tile + virtual void stretchTextureOverTile(core::vector2d scale = core::vector2d(1,1)); + + // rotate texture of tile 90 degrees + // \param w -width coordinate of tile + // \param h -height coordinate of tile + virtual void rotateTileTexture90(u32 w, u32 h); + + // rotate texture of tile 180 degrees + // \param w -width coordinate of tile + // \param h -height coordinate of tile + virtual void rotateTileTexture180(u32 w, u32 h); + + // rotate texture of tile 270 degrees + // \param w -width coordinate of tile + // \param h -height coordinate of tile + virtual void rotateTileTexture270(u32 w, u32 h); + + // flip (mirror) texture of tile horizontaly + // \param w -width coordinate of tile + // \param h -height coordinate of tile + virtual void flipTileTextureHorizontal(u32 w, u32 h); + + // flip (mirror) texture of tile verticaly + // \param w -width coordinate of tile + // \param h -height coordinate of tile + virtual void flipTileTextureVertical(u32 w, u32 h); + + // get color of tile at terrain coordinates + // \param w -width coordinate of tile + // \param h -height coordinate of tile + virtual video::SColor getColor(u32 w, u32 h); + + // set color of tile at terrain coordinates + // \param w -width coordinate of tile + // \param h -height coordinate of tile + // \param newcolor -new color of tile + virtual void setColor(u32 w, u32 h, video::SColor newcolor); + + // set rendered mesh position relative to terrain + // note that origin of mesh is in its lower left corner + // \param pos -new position of mesh relative to terrain in tiles + virtual void setMeshPosition(core::vector2d pos); + + // center rendered mesh at 3d coordinates + // \param pos -new position mesh should be rendered around + virtual void centerAt(core::vector3d pos); + + // update rendered mesh + virtual void update(); + + // set scene node terrain mesh should be automaticly rendered arround + // can be camera or player node for example + // \param node -scene node to automaticaly follow + virtual void follow(scene::ISceneNode* node); + + // cancel pervious function + // stop following scene node if any + virtual void stop(); + + // test if 3d line colide with terrain + // returns true if yes, false if not and store intersection in "outIntersection" vector + // \param line -3d line + // \param outIntersection -vector to store intersection point if any + virtual bool getIntersectionWithLine( core::line3d line, core::vector3df &outIntersection); + + // load height data from texture + // parameters allow to specify place where to load data, which makes possible + // to load terrain from seweral smaller textures + // \param filename -filename of texture + // \param scale -scale to apply at height data, if you want white color to be height of 10.5 set scale to 10.5 + // \param w -width coordinate of tile were to start loading + // \param h -height coordinate of tile were to start loading + virtual void loadHeightMap(const c8 *filename, f32 scale, u32 w = 0, u32 h = 0); + + // load color data from texture + // parameters allow to specify place where to load data, which makes possible + // to load terrain from seweral smaller textures + // \param filename -filename of texture + // \param w -width coordinate of tile were to start loading + // \param h -height coordinate of tile were to start loading + virtual void loadColorMap(const c8 *filename, u32 w = 0, u32 h = 0); +}; +#endif diff --git a/src/Client/GUI/TlTMesh.h b/src/Client/GUI/TlTMesh.h index f274475..66d0424 100644 --- a/src/Client/GUI/TlTMesh.h +++ b/src/Client/GUI/TlTMesh.h @@ -1,148 +1,148 @@ -/*-----------------------------------------------------------------------------* -| headerfile TLTMesh.h | -| | -| version 1.00 | -| date: (17.04.2007) | -| | -| author: Michal Švantner | -| | -| Some structures used for Tiled Terrain | -| Writen for Irrlicht engine version 1.3 | -*-----------------------------------------------------------------------------*/ - -#ifndef TLTMESH_H -#define TLTMESH_H - -#include -using namespace irr; - - - -// dynamic 2d array -template class array2d -{ - T** data; - s32 w, h; - -public: - array2d() : w(0), h(0) {} - - array2d(int width, int height) : w(width), h(height) - { - data = new T*[w]; - for(int i=0; i Vertex[4]; -}; - - - -// structure which holds some data about spot on tiled terrain -struct TlTData -{ - f32 Height; - core::vector3df Normal; - video::SColor Color; -}; - - - -// structure which is used as meshbuffer for Tiled Terrain -class TlTSector -{ -public: - TlTSector() {}; - ~TlTSector() {}; - // position relative to whole mesh of which sector is part in tiles - core::vector2d Offset; - - // dimension of sector in tiles - core::dimension2d Size; - - // array of vertices - core::array Vertex; - - // array of indices - core::array Index; - - // axis aligned bounding box - core::aabbox3d BoundingBox; - - // update texture flag - bool UpdateTexture; - - // update vertices flag - bool UpdateVertices; - - // vissibility flag - bool isVissible; -}; -#endif +/*-----------------------------------------------------------------------------* +| headerfile TLTMesh.h | +| | +| version 1.00 | +| date: (17.04.2007) | +| | +| author: Michal Švantner | +| | +| Some structures used for Tiled Terrain | +| Writen for Irrlicht engine version 1.3 | +*-----------------------------------------------------------------------------*/ + +#ifndef TLTMESH_H +#define TLTMESH_H + +#include +using namespace irr; + + + +// dynamic 2d array +template class array2d +{ + T** data; + s32 w, h; + +public: + array2d() : w(0), h(0) {} + + array2d(int width, int height) : w(width), h(height) + { + data = new T*[w]; + for(int i=0; i Vertex[4]; +}; + + + +// structure which holds some data about spot on tiled terrain +struct TlTData +{ + f32 Height; + core::vector3df Normal; + video::SColor Color; +}; + + + +// structure which is used as meshbuffer for Tiled Terrain +class TlTSector +{ +public: + TlTSector() {}; + ~TlTSector() {}; + // position relative to whole mesh of which sector is part in tiles + core::vector2d Offset; + + // dimension of sector in tiles + core::dimension2d Size; + + // array of vertices + core::array Vertex; + + // array of indices + core::array Index; + + // axis aligned bounding box + core::aabbox3d BoundingBox; + + // update texture flag + bool UpdateTexture; + + // update vertices flag + bool UpdateVertices; + + // vissibility flag + bool isVissible; +}; +#endif diff --git a/src/Client/HelperDefs.h b/src/Client/HelperDefs.h index bbd7249..1fc1589 100644 --- a/src/Client/HelperDefs.h +++ b/src/Client/HelperDefs.h @@ -1,10 +1,10 @@ -#ifndef _HELPERDEFS_H -#define _HELPERDEFS_H - -#define GUID_HIPART(x) (*(((uint32*)&(x))+1)) -#define GUID_LOPART(x) (*((uint32*)&(x))) -#define MAKE_GUID(l, h) uint64( uint32(l) | ( uint64(h) << 32 ) ) - -#define CHAT_ITEM_BEGIN_STRING "|Hitem:" - -#endif +#ifndef _HELPERDEFS_H +#define _HELPERDEFS_H + +#define GUID_HIPART(x) (*(((uint32*)&(x))+1)) +#define GUID_LOPART(x) (*((uint32*)&(x))) +#define MAKE_GUID(l, h) uint64( uint32(l) | ( uint64(h) << 32 ) ) + +#define CHAT_ITEM_BEGIN_STRING "|Hitem:" + +#endif diff --git a/src/Client/MemoryDataHolder.cpp b/src/Client/MemoryDataHolder.cpp index e6dca1d..fdaed8b 100644 --- a/src/Client/MemoryDataHolder.cpp +++ b/src/Client/MemoryDataHolder.cpp @@ -1,143 +1,143 @@ -#include -#include "MemoryDataHolder.h" -#include "DefScript/TypeStorage.h" - -namespace MemoryDataHolder -{ - class DataLoaderRunnable; - - ZThread::FastMutex mutex; - TypeStorage storage; - TypeStorage loaders; - - // instances of this class MUST be created with new-operator, or Destroy() will cause a crash! - class DataLoaderRunnable : public ZThread::Runnable - { - public: - DataLoaderRunnable() - { - _buf = NULL; - _threaded = false; - } - // the threaded part - void run() - { - uint32 size = GetFileSize(_name.c_str()); - // couldnt open file if size is 0 - if(!size) - { - logerror("DataLoaderRunnable: Error opening file: '%s'",_name.c_str()); - DoCallbacks(false); // call callback func, 'false' to indicate file coulsnt be loaded - Destroy(); - return; - } - _buf = new uint8[size]; - std::ifstream fh; - fh.open(_name.c_str(), std::ios_base::in | std::ios_base::binary); - if(!fh.is_open()) - { - logerror("DataLoaderRunnable: Error opening file: '%s'",_name.c_str()); - delete _buf; - _buf = NULL; - DoCallbacks(false); - Destroy(); - return; - } - fh.read((char*)_buf,size); - fh.close(); - storage.Assign(_name,&_buf); - loaders.UnlinkByPtr(this); // must be unlinked after the file is fully loaded, but before the callbacks are processed! - DoCallbacks(true); - Destroy(); - } - - inline void AddCallback(callback_func func, void *ptr = NULL) - { - _callbacks[func] = ptr; - } - inline void SetName(std::string name) - { - _name = name; - } - // if this class has done its work, delete self - inline void Destroy(void) - { - delete this; - } - inline uint8 *GetBuf(void) - { - return _buf; - } - inline void DoCallbacks(bool success = true) - { - for(std::map::iterator it = _callbacks.begin(); it != _callbacks.end(); it++) - { - (*(it->first))(it->second,success); - } - } - inline void SetThreaded(bool t) - { - _threaded = t; - } - inline bool IsThreaded(void) - { - return _threaded; - } - inline bool HasCallbackFunc(callback_func f) - { - return _callbacks.find(f) != _callbacks.end(); - } - - - private: - std::string _name; - std::map _callbacks; - uint8 *_buf; - bool _threaded; - }; - - - uint8 *GetFile(std::string s, bool threaded = false, callback_func func = NULL,void *ptr = NULL) - { - mutex.acquire(); // we need excusive access, other threads might unload the requested file during checking - if(uint8 **buf = storage.GetNoCreate(s)) - { - // the file was requested some other time, is still present in memory and the pointer can simply be returned - mutex.release(); // everything ok, mutex can be unloaded safely before returning - return *buf; - } - else - { - DataLoaderRunnable *r = loaders.GetNoCreate(s); - if(r == NULL) - { - // no loader thread is working on that file... - r = new DataLoaderRunnable(); - loaders.Assign(s,r); - r->AddCallback(func,ptr); // not threadsafe! - // after assigning/registering a new loader to the file, the mutex can be released safely - mutex.release(); - r->SetName(s); - r->SetThreaded(threaded); - if(threaded) - { - ZThread::Thread t(r); // start thread - } - else - { - r->run(); // will exit after the whole file is loaded and the (one) callback is run - return r->GetBuf(); - } - } - else // if a loader is already existing, add callbacks to that loader. - { - r->AddCallback(func,ptr); - mutex.release(); - } - } - return NULL; - } - - - -}; +#include +#include "MemoryDataHolder.h" +#include "DefScript/TypeStorage.h" + +namespace MemoryDataHolder +{ + class DataLoaderRunnable; + + ZThread::FastMutex mutex; + TypeStorage storage; + TypeStorage loaders; + + // instances of this class MUST be created with new-operator, or Destroy() will cause a crash! + class DataLoaderRunnable : public ZThread::Runnable + { + public: + DataLoaderRunnable() + { + _buf = NULL; + _threaded = false; + } + // the threaded part + void run() + { + uint32 size = GetFileSize(_name.c_str()); + // couldnt open file if size is 0 + if(!size) + { + logerror("DataLoaderRunnable: Error opening file: '%s'",_name.c_str()); + DoCallbacks(false); // call callback func, 'false' to indicate file coulsnt be loaded + Destroy(); + return; + } + _buf = new uint8[size]; + std::ifstream fh; + fh.open(_name.c_str(), std::ios_base::in | std::ios_base::binary); + if(!fh.is_open()) + { + logerror("DataLoaderRunnable: Error opening file: '%s'",_name.c_str()); + delete _buf; + _buf = NULL; + DoCallbacks(false); + Destroy(); + return; + } + fh.read((char*)_buf,size); + fh.close(); + storage.Assign(_name,&_buf); + loaders.UnlinkByPtr(this); // must be unlinked after the file is fully loaded, but before the callbacks are processed! + DoCallbacks(true); + Destroy(); + } + + inline void AddCallback(callback_func func, void *ptr = NULL) + { + _callbacks[func] = ptr; + } + inline void SetName(std::string name) + { + _name = name; + } + // if this class has done its work, delete self + inline void Destroy(void) + { + delete this; + } + inline uint8 *GetBuf(void) + { + return _buf; + } + inline void DoCallbacks(bool success = true) + { + for(std::map::iterator it = _callbacks.begin(); it != _callbacks.end(); it++) + { + (*(it->first))(it->second,success); + } + } + inline void SetThreaded(bool t) + { + _threaded = t; + } + inline bool IsThreaded(void) + { + return _threaded; + } + inline bool HasCallbackFunc(callback_func f) + { + return _callbacks.find(f) != _callbacks.end(); + } + + + private: + std::string _name; + std::map _callbacks; + uint8 *_buf; + bool _threaded; + }; + + + uint8 *GetFile(std::string s, bool threaded = false, callback_func func = NULL,void *ptr = NULL) + { + mutex.acquire(); // we need excusive access, other threads might unload the requested file during checking + if(uint8 **buf = storage.GetNoCreate(s)) + { + // the file was requested some other time, is still present in memory and the pointer can simply be returned + mutex.release(); // everything ok, mutex can be unloaded safely before returning + return *buf; + } + else + { + DataLoaderRunnable *r = loaders.GetNoCreate(s); + if(r == NULL) + { + // no loader thread is working on that file... + r = new DataLoaderRunnable(); + loaders.Assign(s,r); + r->AddCallback(func,ptr); // not threadsafe! + // after assigning/registering a new loader to the file, the mutex can be released safely + mutex.release(); + r->SetName(s); + r->SetThreaded(threaded); + if(threaded) + { + ZThread::Thread t(r); // start thread + } + else + { + r->run(); // will exit after the whole file is loaded and the (one) callback is run + return r->GetBuf(); + } + } + else // if a loader is already existing, add callbacks to that loader. + { + r->AddCallback(func,ptr); + mutex.release(); + } + } + return NULL; + } + + + +}; diff --git a/src/Client/MemoryDataHolder.h b/src/Client/MemoryDataHolder.h index a5af5d3..b609340 100644 --- a/src/Client/MemoryDataHolder.h +++ b/src/Client/MemoryDataHolder.h @@ -1,14 +1,14 @@ -#ifndef MEMORYDATAHOLDER_H -#define MEMORYDATAHOLDER_H - -#include "common.h" - -namespace MemoryDataHolder -{ - typedef void (*callback_func)(void*,bool); - - - uint8 *GetFile(std::string&,bool,callback_func,void*); -}; - -#endif +#ifndef MEMORYDATAHOLDER_H +#define MEMORYDATAHOLDER_H + +#include "common.h" + +namespace MemoryDataHolder +{ + typedef void (*callback_func)(void*,bool); + + + uint8 *GetFile(std::string&,bool,callback_func,void*); +}; + +#endif diff --git a/src/Client/PseuWoW.cpp b/src/Client/PseuWoW.cpp index 20a90ff..ec78072 100644 --- a/src/Client/PseuWoW.cpp +++ b/src/Client/PseuWoW.cpp @@ -1,451 +1,451 @@ -#include "common.h" -#include "PseuWoW.h" -#include -#include - -#include "ByteBuffer.h" -#include "DefScript/DefScript.h" -#include "DefScriptInterface.h" -#include "Auth/BigNumber.h" -#include "DefScript/DefScript.h" -#include "RealmSession.h" -#include "WorldSession.h" -#include "CacheHandler.h" -#include "GUI/PseuGUI.h" -#include "RemoteController.h" -#include "Cli.h" - - -//###### Start of program code ####### - -PseuInstanceRunnable::PseuInstanceRunnable() -{ -} - -void PseuInstanceRunnable::run(void) -{ - _i = new PseuInstance(this); - _i->SetConfDir("./conf/"); - _i->SetScpDir("./scripts/"); - if(_i->Init()) - { - _i->Run(); - } - else - { - getchar(); // if init failed, wait for keypress before exit - } - delete _i; -} - -void PseuInstanceRunnable::sleep(uint32 msecs) -{ - ZThread::Thread::sleep(msecs); -} - -PseuInstance::PseuInstance(PseuInstanceRunnable *run) -{ - _runnable=run; - _ver="PseuWoW Alpha Build 13.51" DEBUG_APPENDIX; - _ver_short="A13.51" DEBUG_APPENDIX; - _wsession=NULL; - _rsession=NULL; - _scp=NULL; - _conf=NULL; - _cli=NULL; - _rmcontrol=NULL; - _gui=NULL; - _guithread=NULL; - _stop=false; - _fastquit=false; - _startrealm=true; - _createws=false; - _error=false; - _initialized=false; - -} - -PseuInstance::~PseuInstance() -{ - if(_cli) - { - _cli->stop(); - // delete _cli; // ok this is a little mem leak... can be fixed sometime in future - } - - if(_gui) - _gui->Shutdown(); - if(_guithread) - _guithread->wait(); - - if(_rmcontrol) - delete _rmcontrol; - if(_rsession) - delete _rsession; - if(_wsession) - delete _wsession; - - delete _scp; - delete _conf; - - log("--- Instance shut down ---"); -} - -bool PseuInstance::Init(void) -{ - log_setloglevel(0); - log(""); - log("--- Initializing Instance ---"); - - if(_confdir.empty()) - _confdir="./conf/"; - if(_scpdir.empty()) - _scpdir="./scripts/"; - - srand((unsigned)time(NULL)); - RAND_set_rand_method(RAND_SSLeay()); // init openssl randomizer - - _scp=new DefScriptPackage(); - _scp->SetParentMethod((void*)this); - _conf=new PseuInstanceConf(); - - _scp->SetPath(_scpdir); - _scp->SetLog(logdetail); // does anyone have an idea why log() is not accepted here? - _scp->SetDebugLog(logdebug); - _scp->SetErrorLog(logerror); - - _scp->variables.Set("@version_short",_ver_short); - _scp->variables.Set("@version",_ver); - _scp->variables.Set("@inworld","false"); - - if(!_scp->LoadScriptFromFile("./_startup.def")) - { - logerror("Error loading '_startup.def'"); - SetError(); - } - else if(!_scp->BoolRunScript("_startup",NULL)) - { - logerror("Error executing '_startup.def'"); - SetError(); - } - - // TODO: find a better loaction where to place this block! - if(GetConf()->enablegui) - { - if(InitGUI()) - logdebug("GUI: Init successful."); - else - logerror("GUI: Init failed!"); - } - - if(GetConf()->rmcontrolport) - { - _rmcontrol = new RemoteController(this,GetConf()->rmcontrolport); - } - - if(GetConf()->enablecli) - { - log("Starting CLI..."); - _cli = new CliRunnable(this); - ZThread::Thread t(_cli); - } - - if(_error) - { - logcritical("Errors while initializing!"); - return false; - } - - log("Init complete."); - _initialized=true; - return true; -} - -bool PseuInstance::InitGUI(void) -{ - if(GetGUI()) - { - logerror("GUI: Aborting init, GUI already exists!"); - return false; - } - uint16 x,y,depth; - uint8 driver; - bool shadows,vsync,win; - - driver=(uint8)atoi(GetScripts()->variables.Get("GUI::DRIVER").c_str()); - vsync=(bool)atoi(GetScripts()->variables.Get("GUI::VSYNC").c_str()); - depth=(uint8)atoi(GetScripts()->variables.Get("GUI::DEPTH").c_str()); - x=(uint16)atoi(GetScripts()->variables.Get("GUI::RESX").c_str()); - y=(uint16)atoi(GetScripts()->variables.Get("GUI::RESY").c_str()); - win=(bool)atoi(GetScripts()->variables.Get("GUI::WINDOWED").c_str()); - shadows=(bool)atoi(GetScripts()->variables.Get("GUI::SHADOWS").c_str()); - log("GUI settings: driver=%u, depth=%u, res=%ux%u, windowed=%u, shadows=%u",driver,depth,x,y,win,shadows); - if(x>0 && y>0 && (depth==16 || depth==32) && driver>0 && driver<=5) - { - PseuGUIRunnable *rgui = new PseuGUIRunnable(); - _gui = rgui->GetGUI(); - _gui->SetInstance(this); - _gui->SetDriver(driver); - _gui->SetResolution(x,y,depth); - _gui->SetVSync(vsync); - _gui->UseShadows(shadows); - _guithread = new ZThread::Thread(rgui); - return true; - } - else - logerror("GUI: incorrect settings!"); - return false; -} - -void PseuInstance::Run(void) -{ - if(!_initialized) - return; - - logdetail("PseuInstance: Initialized and running!"); - - if(GetGUI()) - { - while(!GetGUI()->IsInitialized()) - Sleep(1); // wait until the gui is ready. it will crash otherwise - logdebug("GUI: switching to startup display..."); - GetGUI()->SetSceneState(SCENESTATE_GUISTART); - } - // TODO: as soon as username and password can be inputted into the gui, wait until it was set by user. - - if(GetConf()->realmlist.empty() || GetConf()->realmport==0) - { - logcritical("Realmlist address not set, can't connect."); - SetError(); - } - else - { - // for now: create the realmsession only on startup. - // may be extended to a script command later on. - // then try to connect - _rsession = new RealmSession(this); - _rsession->Connect(); - _rsession->SendLogonChallenge(); - - // this is the mainloop - while(!_stop) - { - Update(); - if(_error) - _stop=true; - } - - - } - - // fastquit is defined if we clicked [X] (on windows) - if(_fastquit) - { - log("Aborting Instance..."); - return; - } - - log("Shutting down instance..."); - - // if there was an error, better dont save, as the data might be damaged - if(!_error) - { - SaveAllCache(); - //... - } - - if(GetConf()->exitonerror == false && _error) - { - log("Exiting on error is disabled, PseuWoW is now IDLE"); - log("-- Press enter to exit --"); - char crap[100]; - fgets(crap,sizeof(crap),stdin); // workaround, need to press enter 2x for now - } - -} - -void PseuInstance::Update() -{ - // if the user typed anything into the console, process it before anything else. - // note that it can also be used for simulated cli commands sent by other threads, so it needs to be checked even if cli is disabled - ProcessCliQueue(); - - // delete sessions if they are no longer needed - if(_rsession && _rsession->MustDie()) - { - delete _rsession; - _rsession = NULL; - } - - if(_wsession && _wsession->MustDie()) - { - delete _wsession; - _wsession = NULL; - } - - if(_createws) - { - _createws = false; - if(_wsession) - delete _wsession; - _wsession = new WorldSession(this); - _wsession->Start(); - } - - // if we have no active sessions, we may reconnect - if((!_rsession) && (!_wsession) && GetConf()->reconnect) - { - logdetail("Waiting %u ms before reconnecting.",GetConf()->reconnect); - for(uint32 t = 0; t < GetConf()->reconnect && !this->Stopped(); t+=100) Sleep(100); - this->Sleep(1000); // wait 1 sec before reconnecting - _rsession = new RealmSession(this); - _rsession->Connect(); - _rsession->SendLogonChallenge(); // and login again - } - - // update currently existing/active sessions - if(_rsession) - _rsession->Update(); - if(_wsession) - try { _wsession->Update(); } catch (...) - { - logerror("Unhandled exception in WorldSession::Update()"); - } - - - if(_rmcontrol) - { - _rmcontrol->Update(); - if(_rmcontrol->MustDie()) - { - delete _rmcontrol; - _rmcontrol = NULL; - } - } - - GetScripts()->GetEventMgr()->Update(); - - this->Sleep(GetConf()->networksleeptime); -} - -void PseuInstance::ProcessCliQueue(void) -{ - std::string cmd; - while(_cliQueue.size()) - { - cmd = _cliQueue.next(); - try - { - GetScripts()->RunSingleLine(cmd); - } - catch(...) - { - logerror("Exception while executing CLI command: \"%s\"",cmd.c_str()); - } - } -} - -void PseuInstance::AddCliCommand(std::string cmd) -{ - _cliQueue.add(cmd); -} - -void PseuInstance::SaveAllCache(void) -{ - //... - if(GetWSession()) - { - GetWSession()->plrNameCache.SaveToFile(); - ItemProtoCache_WriteDataToCache(GetWSession()); - CreatureTemplateCache_WriteDataToCache(GetWSession()); - //... - } -} - -void PseuInstance::Sleep(uint32 msecs) -{ - GetRunnable()->sleep(msecs); -} - -void PseuInstance::DeleteGUI(void) -{ - _gui = NULL; - delete _guithread; // since it was allocated with new - _guithread = NULL; - if(GetScripts()->ScriptExists("_onguiclose")) - AddCliCommand("_onguiclose"); // since this func is called from another thread, use threadsafe variant via CLI -} - -PseuInstanceConf::PseuInstanceConf() -{ - enablecli=false; - enablegui=false; - exitonerror=false; - debug=0; - rmcontrolport=0; -} - -void PseuInstanceConf::ApplyFromVarSet(VarSet &v) -{ - debug=atoi(v.Get("DEBUG").c_str()); - realmlist=v.Get("REALMLIST"); - accname=v.Get("ACCNAME"); - accpass=v.Get("ACCPASS"); - exitonerror=(bool)atoi(v.Get("EXITONERROR").c_str()); - reconnect=atoi(v.Get("RECONNECT").c_str()); - realmport=atoi(v.Get("REALMPORT").c_str()); - clientversion_string=v.Get("CLIENTVERSION"); - clientbuild=atoi(v.Get("CLIENTBUILD").c_str()); - clientlang=v.Get("CLIENTLANGUAGE"); - realmname=v.Get("REALMNAME"); - charname=v.Get("CHARNAME"); - networksleeptime=atoi(v.Get("NETWORKSLEEPTIME").c_str()); - showopcodes=atoi(v.Get("SHOWOPCODES").c_str()); - hidefreqopcodes=(bool)atoi(v.Get("HIDEFREQOPCODES").c_str()); - hideDisabledOpcodes=(bool)atoi(v.Get("HIDEDISABLEDOPCODES").c_str()); - enablecli=(bool)atoi(v.Get("ENABLECLI").c_str()); - allowgamecmd=(bool)atoi(v.Get("ALLOWGAMECMD").c_str()); - enablechatai=(bool)atoi(v.Get("ENABLECHATAI").c_str()); - notifyping=(bool)atoi(v.Get("NOTIFYPING").c_str()); - showmyopcodes=(bool)atoi(v.Get("SHOWMYOPCODES").c_str()); - disablespellcheck=(bool)atoi(v.Get("DISABLESPELLCHECK").c_str()); - enablegui=(bool)atoi(v.Get("ENABLEGUI").c_str()); - rmcontrolport=atoi(v.Get("RMCONTROLPORT").c_str()); - rmcontrolhost=v.Get("RMCONTROLHOST"); - useMaps=(bool)atoi(v.Get("USEMAPS").c_str()); - skipaddonchat=(bool)atoi(v.Get("SKIPADDONCHAT").c_str()); - - // clientversion is a bit more complicated to add - { - std::string opt=clientversion_string + "."; - std::string num; - uint8 p=0; - for(uint8 i=0;i2) - break; - continue; - } - num+=opt.at(i); - } - } - - log_setloglevel(debug); -} - - - - -PseuInstanceConf::~PseuInstanceConf() -{ - //... -} - - - - +#include "common.h" +#include "PseuWoW.h" +#include +#include + +#include "ByteBuffer.h" +#include "DefScript/DefScript.h" +#include "DefScriptInterface.h" +#include "Auth/BigNumber.h" +#include "DefScript/DefScript.h" +#include "RealmSession.h" +#include "WorldSession.h" +#include "CacheHandler.h" +#include "GUI/PseuGUI.h" +#include "RemoteController.h" +#include "Cli.h" + + +//###### Start of program code ####### + +PseuInstanceRunnable::PseuInstanceRunnable() +{ +} + +void PseuInstanceRunnable::run(void) +{ + _i = new PseuInstance(this); + _i->SetConfDir("./conf/"); + _i->SetScpDir("./scripts/"); + if(_i->Init()) + { + _i->Run(); + } + else + { + getchar(); // if init failed, wait for keypress before exit + } + delete _i; +} + +void PseuInstanceRunnable::sleep(uint32 msecs) +{ + ZThread::Thread::sleep(msecs); +} + +PseuInstance::PseuInstance(PseuInstanceRunnable *run) +{ + _runnable=run; + _ver="PseuWoW Alpha Build 13.51" DEBUG_APPENDIX; + _ver_short="A13.51" DEBUG_APPENDIX; + _wsession=NULL; + _rsession=NULL; + _scp=NULL; + _conf=NULL; + _cli=NULL; + _rmcontrol=NULL; + _gui=NULL; + _guithread=NULL; + _stop=false; + _fastquit=false; + _startrealm=true; + _createws=false; + _error=false; + _initialized=false; + +} + +PseuInstance::~PseuInstance() +{ + if(_cli) + { + _cli->stop(); + // delete _cli; // ok this is a little mem leak... can be fixed sometime in future + } + + if(_gui) + _gui->Shutdown(); + if(_guithread) + _guithread->wait(); + + if(_rmcontrol) + delete _rmcontrol; + if(_rsession) + delete _rsession; + if(_wsession) + delete _wsession; + + delete _scp; + delete _conf; + + log("--- Instance shut down ---"); +} + +bool PseuInstance::Init(void) +{ + log_setloglevel(0); + log(""); + log("--- Initializing Instance ---"); + + if(_confdir.empty()) + _confdir="./conf/"; + if(_scpdir.empty()) + _scpdir="./scripts/"; + + srand((unsigned)time(NULL)); + RAND_set_rand_method(RAND_SSLeay()); // init openssl randomizer + + _scp=new DefScriptPackage(); + _scp->SetParentMethod((void*)this); + _conf=new PseuInstanceConf(); + + _scp->SetPath(_scpdir); + _scp->SetLog(logdetail); // does anyone have an idea why log() is not accepted here? + _scp->SetDebugLog(logdebug); + _scp->SetErrorLog(logerror); + + _scp->variables.Set("@version_short",_ver_short); + _scp->variables.Set("@version",_ver); + _scp->variables.Set("@inworld","false"); + + if(!_scp->LoadScriptFromFile("./_startup.def")) + { + logerror("Error loading '_startup.def'"); + SetError(); + } + else if(!_scp->BoolRunScript("_startup",NULL)) + { + logerror("Error executing '_startup.def'"); + SetError(); + } + + // TODO: find a better loaction where to place this block! + if(GetConf()->enablegui) + { + if(InitGUI()) + logdebug("GUI: Init successful."); + else + logerror("GUI: Init failed!"); + } + + if(GetConf()->rmcontrolport) + { + _rmcontrol = new RemoteController(this,GetConf()->rmcontrolport); + } + + if(GetConf()->enablecli) + { + log("Starting CLI..."); + _cli = new CliRunnable(this); + ZThread::Thread t(_cli); + } + + if(_error) + { + logcritical("Errors while initializing!"); + return false; + } + + log("Init complete."); + _initialized=true; + return true; +} + +bool PseuInstance::InitGUI(void) +{ + if(GetGUI()) + { + logerror("GUI: Aborting init, GUI already exists!"); + return false; + } + uint16 x,y,depth; + uint8 driver; + bool shadows,vsync,win; + + driver=(uint8)atoi(GetScripts()->variables.Get("GUI::DRIVER").c_str()); + vsync=(bool)atoi(GetScripts()->variables.Get("GUI::VSYNC").c_str()); + depth=(uint8)atoi(GetScripts()->variables.Get("GUI::DEPTH").c_str()); + x=(uint16)atoi(GetScripts()->variables.Get("GUI::RESX").c_str()); + y=(uint16)atoi(GetScripts()->variables.Get("GUI::RESY").c_str()); + win=(bool)atoi(GetScripts()->variables.Get("GUI::WINDOWED").c_str()); + shadows=(bool)atoi(GetScripts()->variables.Get("GUI::SHADOWS").c_str()); + log("GUI settings: driver=%u, depth=%u, res=%ux%u, windowed=%u, shadows=%u",driver,depth,x,y,win,shadows); + if(x>0 && y>0 && (depth==16 || depth==32) && driver>0 && driver<=5) + { + PseuGUIRunnable *rgui = new PseuGUIRunnable(); + _gui = rgui->GetGUI(); + _gui->SetInstance(this); + _gui->SetDriver(driver); + _gui->SetResolution(x,y,depth); + _gui->SetVSync(vsync); + _gui->UseShadows(shadows); + _guithread = new ZThread::Thread(rgui); + return true; + } + else + logerror("GUI: incorrect settings!"); + return false; +} + +void PseuInstance::Run(void) +{ + if(!_initialized) + return; + + logdetail("PseuInstance: Initialized and running!"); + + if(GetGUI()) + { + while(!GetGUI()->IsInitialized()) + Sleep(1); // wait until the gui is ready. it will crash otherwise + logdebug("GUI: switching to startup display..."); + GetGUI()->SetSceneState(SCENESTATE_GUISTART); + } + // TODO: as soon as username and password can be inputted into the gui, wait until it was set by user. + + if(GetConf()->realmlist.empty() || GetConf()->realmport==0) + { + logcritical("Realmlist address not set, can't connect."); + SetError(); + } + else + { + // for now: create the realmsession only on startup. + // may be extended to a script command later on. + // then try to connect + _rsession = new RealmSession(this); + _rsession->Connect(); + _rsession->SendLogonChallenge(); + + // this is the mainloop + while(!_stop) + { + Update(); + if(_error) + _stop=true; + } + + + } + + // fastquit is defined if we clicked [X] (on windows) + if(_fastquit) + { + log("Aborting Instance..."); + return; + } + + log("Shutting down instance..."); + + // if there was an error, better dont save, as the data might be damaged + if(!_error) + { + SaveAllCache(); + //... + } + + if(GetConf()->exitonerror == false && _error) + { + log("Exiting on error is disabled, PseuWoW is now IDLE"); + log("-- Press enter to exit --"); + char crap[100]; + fgets(crap,sizeof(crap),stdin); // workaround, need to press enter 2x for now + } + +} + +void PseuInstance::Update() +{ + // if the user typed anything into the console, process it before anything else. + // note that it can also be used for simulated cli commands sent by other threads, so it needs to be checked even if cli is disabled + ProcessCliQueue(); + + // delete sessions if they are no longer needed + if(_rsession && _rsession->MustDie()) + { + delete _rsession; + _rsession = NULL; + } + + if(_wsession && _wsession->MustDie()) + { + delete _wsession; + _wsession = NULL; + } + + if(_createws) + { + _createws = false; + if(_wsession) + delete _wsession; + _wsession = new WorldSession(this); + _wsession->Start(); + } + + // if we have no active sessions, we may reconnect + if((!_rsession) && (!_wsession) && GetConf()->reconnect) + { + logdetail("Waiting %u ms before reconnecting.",GetConf()->reconnect); + for(uint32 t = 0; t < GetConf()->reconnect && !this->Stopped(); t+=100) Sleep(100); + this->Sleep(1000); // wait 1 sec before reconnecting + _rsession = new RealmSession(this); + _rsession->Connect(); + _rsession->SendLogonChallenge(); // and login again + } + + // update currently existing/active sessions + if(_rsession) + _rsession->Update(); + if(_wsession) + try { _wsession->Update(); } catch (...) + { + logerror("Unhandled exception in WorldSession::Update()"); + } + + + if(_rmcontrol) + { + _rmcontrol->Update(); + if(_rmcontrol->MustDie()) + { + delete _rmcontrol; + _rmcontrol = NULL; + } + } + + GetScripts()->GetEventMgr()->Update(); + + this->Sleep(GetConf()->networksleeptime); +} + +void PseuInstance::ProcessCliQueue(void) +{ + std::string cmd; + while(_cliQueue.size()) + { + cmd = _cliQueue.next(); + try + { + GetScripts()->RunSingleLine(cmd); + } + catch(...) + { + logerror("Exception while executing CLI command: \"%s\"",cmd.c_str()); + } + } +} + +void PseuInstance::AddCliCommand(std::string cmd) +{ + _cliQueue.add(cmd); +} + +void PseuInstance::SaveAllCache(void) +{ + //... + if(GetWSession()) + { + GetWSession()->plrNameCache.SaveToFile(); + ItemProtoCache_WriteDataToCache(GetWSession()); + CreatureTemplateCache_WriteDataToCache(GetWSession()); + //... + } +} + +void PseuInstance::Sleep(uint32 msecs) +{ + GetRunnable()->sleep(msecs); +} + +void PseuInstance::DeleteGUI(void) +{ + _gui = NULL; + delete _guithread; // since it was allocated with new + _guithread = NULL; + if(GetScripts()->ScriptExists("_onguiclose")) + AddCliCommand("_onguiclose"); // since this func is called from another thread, use threadsafe variant via CLI +} + +PseuInstanceConf::PseuInstanceConf() +{ + enablecli=false; + enablegui=false; + exitonerror=false; + debug=0; + rmcontrolport=0; +} + +void PseuInstanceConf::ApplyFromVarSet(VarSet &v) +{ + debug=atoi(v.Get("DEBUG").c_str()); + realmlist=v.Get("REALMLIST"); + accname=v.Get("ACCNAME"); + accpass=v.Get("ACCPASS"); + exitonerror=(bool)atoi(v.Get("EXITONERROR").c_str()); + reconnect=atoi(v.Get("RECONNECT").c_str()); + realmport=atoi(v.Get("REALMPORT").c_str()); + clientversion_string=v.Get("CLIENTVERSION"); + clientbuild=atoi(v.Get("CLIENTBUILD").c_str()); + clientlang=v.Get("CLIENTLANGUAGE"); + realmname=v.Get("REALMNAME"); + charname=v.Get("CHARNAME"); + networksleeptime=atoi(v.Get("NETWORKSLEEPTIME").c_str()); + showopcodes=atoi(v.Get("SHOWOPCODES").c_str()); + hidefreqopcodes=(bool)atoi(v.Get("HIDEFREQOPCODES").c_str()); + hideDisabledOpcodes=(bool)atoi(v.Get("HIDEDISABLEDOPCODES").c_str()); + enablecli=(bool)atoi(v.Get("ENABLECLI").c_str()); + allowgamecmd=(bool)atoi(v.Get("ALLOWGAMECMD").c_str()); + enablechatai=(bool)atoi(v.Get("ENABLECHATAI").c_str()); + notifyping=(bool)atoi(v.Get("NOTIFYPING").c_str()); + showmyopcodes=(bool)atoi(v.Get("SHOWMYOPCODES").c_str()); + disablespellcheck=(bool)atoi(v.Get("DISABLESPELLCHECK").c_str()); + enablegui=(bool)atoi(v.Get("ENABLEGUI").c_str()); + rmcontrolport=atoi(v.Get("RMCONTROLPORT").c_str()); + rmcontrolhost=v.Get("RMCONTROLHOST"); + useMaps=(bool)atoi(v.Get("USEMAPS").c_str()); + skipaddonchat=(bool)atoi(v.Get("SKIPADDONCHAT").c_str()); + + // clientversion is a bit more complicated to add + { + std::string opt=clientversion_string + "."; + std::string num; + uint8 p=0; + for(uint8 i=0;i2) + break; + continue; + } + num+=opt.at(i); + } + } + + log_setloglevel(debug); +} + + + + +PseuInstanceConf::~PseuInstanceConf() +{ + //... +} + + + + diff --git a/src/Client/PseuWoW.h b/src/Client/PseuWoW.h index bce54ce..90c11a9 100644 --- a/src/Client/PseuWoW.h +++ b/src/Client/PseuWoW.h @@ -1,145 +1,145 @@ - -#ifndef _PSEUWOW_H -#define _PSEUWOW_H - -#include "common.h" -#include "HelperDefs.h" -#include "log.h" -#include "Auth/BigNumber.h" -#include "DefScript/DefScript.h" -#include "Network/SocketHandler.h" -#include "SCPDatabase.h" -#include "GUI/PseuGUI.h" - -class RealmSession; -class WorldSession; -class Sockethandler; -class PseuInstanceRunnable; -class CliRunnable; -class RemoteController; - -class PseuInstanceConf -{ - public: - - PseuInstanceConf(); - ~PseuInstanceConf(); - void ApplyFromVarSet(VarSet &v); - - - uint8 debug; - std::string realmlist; - std::string accname; - std::string accpass; - bool exitonerror; - uint32 reconnect; - uint16 realmport; - uint16 worldport; - uint8 clientversion[3]; - std::string clientversion_string; - uint16 clientbuild; - std::string clientlang; - std::string realmname; - std::string charname; - std::string worldhost; - uint16 networksleeptime; - uint8 showopcodes; - bool hidefreqopcodes; - bool hideDisabledOpcodes; - bool allowgamecmd; - bool enablecli; - bool enablechatai; - bool notifyping; - bool showmyopcodes; - bool disablespellcheck; - uint32 rmcontrolport; - std::string rmcontrolhost; - bool useMaps; - bool skipaddonchat; - - // gui related - bool enablegui; - // need more here - - -}; - - -class PseuInstance -{ -public: - - PseuInstance(PseuInstanceRunnable *run); - ~PseuInstance(); - - - inline WorldSession *GetWSession(void) { return _wsession; } - inline RealmSession *GetRSession(void) { return _rsession; } - inline PseuInstanceConf *GetConf(void) { return _conf; } - inline DefScriptPackage *GetScripts(void) { return _scp; } - inline PseuInstanceRunnable *GetRunnable(void) { return _runnable; } - inline PseuGUI *GetGUI(void) { return _gui; } - void DeleteGUI(void); - - inline void SetConfDir(std::string dir) { _confdir = dir; } - inline std::string GetConfDir(void) { return _confdir; } - inline void SetScpDir(std::string dir) { _scpdir = dir; } - inline void SetSessionKey(BigNumber key) { _sessionkey = key; } - inline BigNumber *GetSessionKey(void) { return &_sessionkey; } - inline void SetError(void) { _error = true; } - SCPDatabaseMgr dbmgr; - - bool Init(void); - bool InitGUI(void); - void SaveAllCache(void); - inline void Stop(void) { _stop = true; } - inline bool Stopped(void) { return _stop; } - inline void SetFastQuit(bool q=true) { _fastquit=true; } - void Run(void); - void Update(void); - void Sleep(uint32 msecs); - - inline void CreateWorldSession(void) { _createws = true; } - - void ProcessCliQueue(void); - void AddCliCommand(std::string); - -private: - - PseuInstanceRunnable *_runnable; - RealmSession *_rsession; - WorldSession *_wsession; - PseuInstanceConf *_conf; - DefScriptPackage *_scp; - std::string _confdir,_scpdir; // _scpdir is the scripts dir, and NOT where SCP files are stored!! - bool _initialized; - bool _stop,_fastquit; - bool _startrealm; - bool _error; - bool _createws; - BigNumber _sessionkey; - char *_ver,*_ver_short; - SocketHandler _sh; - CliRunnable *_cli; - ZThread::Thread _clithread; - RemoteController *_rmcontrol; - ZThread::LockedQueue _cliQueue; - PseuGUI *_gui; - ZThread::Thread *_guithread; - -}; - -class PseuInstanceRunnable : public ZThread::Runnable -{ -public: - PseuInstanceRunnable(); - void run(void); - void sleep(uint32); - inline PseuInstance *GetInstance(void) { return _i; } - -private: - PseuInstance *_i; -}; - - -#endif + +#ifndef _PSEUWOW_H +#define _PSEUWOW_H + +#include "common.h" +#include "HelperDefs.h" +#include "log.h" +#include "Auth/BigNumber.h" +#include "DefScript/DefScript.h" +#include "Network/SocketHandler.h" +#include "SCPDatabase.h" +#include "GUI/PseuGUI.h" + +class RealmSession; +class WorldSession; +class Sockethandler; +class PseuInstanceRunnable; +class CliRunnable; +class RemoteController; + +class PseuInstanceConf +{ + public: + + PseuInstanceConf(); + ~PseuInstanceConf(); + void ApplyFromVarSet(VarSet &v); + + + uint8 debug; + std::string realmlist; + std::string accname; + std::string accpass; + bool exitonerror; + uint32 reconnect; + uint16 realmport; + uint16 worldport; + uint8 clientversion[3]; + std::string clientversion_string; + uint16 clientbuild; + std::string clientlang; + std::string realmname; + std::string charname; + std::string worldhost; + uint16 networksleeptime; + uint8 showopcodes; + bool hidefreqopcodes; + bool hideDisabledOpcodes; + bool allowgamecmd; + bool enablecli; + bool enablechatai; + bool notifyping; + bool showmyopcodes; + bool disablespellcheck; + uint32 rmcontrolport; + std::string rmcontrolhost; + bool useMaps; + bool skipaddonchat; + + // gui related + bool enablegui; + // need more here + + +}; + + +class PseuInstance +{ +public: + + PseuInstance(PseuInstanceRunnable *run); + ~PseuInstance(); + + + inline WorldSession *GetWSession(void) { return _wsession; } + inline RealmSession *GetRSession(void) { return _rsession; } + inline PseuInstanceConf *GetConf(void) { return _conf; } + inline DefScriptPackage *GetScripts(void) { return _scp; } + inline PseuInstanceRunnable *GetRunnable(void) { return _runnable; } + inline PseuGUI *GetGUI(void) { return _gui; } + void DeleteGUI(void); + + inline void SetConfDir(std::string dir) { _confdir = dir; } + inline std::string GetConfDir(void) { return _confdir; } + inline void SetScpDir(std::string dir) { _scpdir = dir; } + inline void SetSessionKey(BigNumber key) { _sessionkey = key; } + inline BigNumber *GetSessionKey(void) { return &_sessionkey; } + inline void SetError(void) { _error = true; } + SCPDatabaseMgr dbmgr; + + bool Init(void); + bool InitGUI(void); + void SaveAllCache(void); + inline void Stop(void) { _stop = true; } + inline bool Stopped(void) { return _stop; } + inline void SetFastQuit(bool q=true) { _fastquit=true; } + void Run(void); + void Update(void); + void Sleep(uint32 msecs); + + inline void CreateWorldSession(void) { _createws = true; } + + void ProcessCliQueue(void); + void AddCliCommand(std::string); + +private: + + PseuInstanceRunnable *_runnable; + RealmSession *_rsession; + WorldSession *_wsession; + PseuInstanceConf *_conf; + DefScriptPackage *_scp; + std::string _confdir,_scpdir; // _scpdir is the scripts dir, and NOT where SCP files are stored!! + bool _initialized; + bool _stop,_fastquit; + bool _startrealm; + bool _error; + bool _createws; + BigNumber _sessionkey; + char *_ver,*_ver_short; + SocketHandler _sh; + CliRunnable *_cli; + ZThread::Thread _clithread; + RemoteController *_rmcontrol; + ZThread::LockedQueue _cliQueue; + PseuGUI *_gui; + ZThread::Thread *_guithread; + +}; + +class PseuInstanceRunnable : public ZThread::Runnable +{ +public: + PseuInstanceRunnable(); + void run(void); + void sleep(uint32); + inline PseuInstance *GetInstance(void) { return _i; } + +private: + PseuInstance *_i; +}; + + +#endif diff --git a/src/Client/PseuWoW.rc b/src/Client/PseuWoW.rc index 896d885..5ba7524 100644 --- a/src/Client/PseuWoW.rc +++ b/src/Client/PseuWoW.rc @@ -1,71 +1,71 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -///////////////////////////////////////////////////////////////////////////// -// German (Germany) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -#ifdef _WIN32 -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ICON1 ICON "Pseu1.ico" -#endif // German (Germany) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +///////////////////////////////////////////////////////////////////////////// +// German (Germany) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_ICON1 ICON "Pseu1.ico" +#endif // German (Germany) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/Client/Realm/RealmSession.cpp b/src/Client/Realm/RealmSession.cpp index 56bca4b..bdbe2d3 100644 --- a/src/Client/Realm/RealmSession.cpp +++ b/src/Client/Realm/RealmSession.cpp @@ -1,704 +1,704 @@ -#include "common.h" -#include "Auth/Sha1.h" -#include "Auth/BigNumber.h" -#include "PseuWoW.h" -#include "RealmSocket.h" -#include "RealmSession.h" - -enum AuthCmd -{ - //AUTH_NO_CMD = 0xFF, - AUTH_LOGON_CHALLENGE = 0x00, - AUTH_LOGON_PROOF = 0x01, - //AUTH_RECONNECT_CHALLENGE = 0x02, - //AUTH_RECONNECT_PROOF = 0x03, - //update srv =4 - REALM_LIST = 0x10, - XFER_INITIATE = 0x30, - XFER_DATA = 0x31, - XFER_ACCEPT = 0x32, - XFER_RESUME = 0x33, - XFER_CANCEL = 0x34 -}; - -enum eAuthResults -{ - REALM_AUTH_SUCCESS = 0, - REALM_AUTH_FAILURE=0x01, ///< Unable to connect - REALM_AUTH_UNKNOWN1=0x02, ///< Unable to connect - REALM_AUTH_ACCOUNT_BANNED=0x03, ///< This account has been closed and is no longer available for use. Please go to /banned.html for further information. - REALM_AUTH_NO_MATCH=0x04, ///< The information you have entered is not valid. Please check the spelling of the account name and password. If you need help in retrieving a lost or stolen password, see for more information - REALM_AUTH_UNKNOWN2=0x05, ///< The information you have entered is not valid. Please check the spelling of the account name and password. If you need help in retrieving a lost or stolen password, see for more information - REALM_AUTH_ACCOUNT_IN_USE=0x06, ///< This account is already logged into . Please check the spelling and try again. - REALM_AUTH_PREPAID_TIME_LIMIT=0x07, ///< You have used up your prepaid time for this account. Please purchase more to continue playing - REALM_AUTH_SERVER_FULL=0x08, ///< Could not log in to at this time. Please try again later. - REALM_AUTH_WRONG_BUILD_NUMBER=0x09, ///< Unable to validate game version. This may be caused by file corruption or interference of another program. Please visit for more information and possible solutions to this issue. - REALM_AUTH_UPDATE_CLIENT=0x0a, ///< Downloading - REALM_AUTH_UNKNOWN3=0x0b, ///< Unable to connect - REALM_AUTH_ACCOUNT_FREEZED=0x0c, ///< This account has been temporarily suspended. Please go to /banned.html for further information - REALM_AUTH_UNKNOWN4=0x0d, ///< Unable to connect - REALM_AUTH_UNKNOWN5=0x0e, ///< Connected. - REALM_AUTH_PARENTAL_CONTROL=0x0f ///< Access to this account has been blocked by parental controls. Your settings may be changed in your account preferences at -}; - -#define ChunkSize 2048 - -struct SRealmHeader -{ - uint8 cmd; // OP code = CMD_REALM_LIST - uint16 size; // size of the rest of packet, without this part - uint32 unknown; // 0x00 00 00 00 - uint8 count; // quantity of realms -}; - -struct SRealmInfo -{ - uint8 icon; // icon near realm - uint8 locked; // added in 2.0.x - uint8 color; // color of record - std::string name; // Text zero terminated name of Realm - std::string addr_port; // Text zero terminated address of Realm ("ip:port") - float population; // 1.6 -> population value. lower == lower population and vice versa - uint8 chars_here; // number of characters on this server - uint8 timezone; // timezone - uint8 unknown; // -}; - -struct AuthHandler -{ - uint32 cmd; - void (RealmSession::*handler)(ByteBuffer&); -}; - -struct sAuthLogonChallenge_S -{ - uint8 cmd; - uint8 unk2; - uint8 error; - uint8 B[32]; - uint8 g_len; - uint8 g[1]; - uint8 N_len; - uint8 N[32]; - uint8 salt[32]; - uint8 unk3[16]; -}; - -struct sAuthLogonProof_S -{ - uint8 cmd; - uint8 error; - uint8 M2[20]; - uint32 unk2; -}; - -RealmSession::RealmSession(PseuInstance* instance) -{ - _instance = instance; - _socket = NULL; - _mustdie = false; - _filetransfer = false; - _file_size = 0; - _sh.SetAutoCloseSockets(false); -} - -RealmSession::~RealmSession() -{ - // drop the socket - ClearSocket(); - - // clear the queue - ByteBuffer *packet; - while(!pktQueue.empty()) - { - packet = pktQueue.next(); - delete packet; - } - memset(_m2,0,20); - _key=0; -} - -void RealmSession::Connect(void) -{ - ClearSocket(); - _socket = new RealmSocket(_sh); - _socket->SetSession(this); - _socket->Open(GetInstance()->GetConf()->realmlist,GetInstance()->GetConf()->realmport); - _sh.Add(_socket); - _sh.Select(3,0); -} - -void RealmSession::ClearSocket(void) -{ - if(_socket) - { - delete _socket; - _socket = NULL; - } -} - -void RealmSession::SetMustDie(void) -{ - _mustdie = true; - logdebug("RealmSession: Must die now."); -} - -bool RealmSession::MustDie(void) -{ - return _mustdie; -} - -AuthHandler *RealmSession::_GetAuthHandlerTable(void) const -{ - static AuthHandler table[] = - { - {AUTH_LOGON_CHALLENGE,&RealmSession::_HandleLogonChallenge}, - {AUTH_LOGON_PROOF,&RealmSession::_HandleLogonProof}, - {REALM_LIST,&RealmSession::_HandleRealmList}, - {XFER_INITIATE,&RealmSession::_HandleTransferInit}, - {XFER_DATA,&RealmSession::_HandleTransferData}, - {0,NULL} - }; - return table; -} - -void RealmSession::AddToPktQueue(ByteBuffer *pkt) -{ - pktQueue.add(pkt); -} - -void RealmSession::Update(void) -{ - AuthHandler *table = _GetAuthHandlerTable(); - ByteBuffer *pkt; - uint8 cmd; - bool valid = true; - - if( _sh.GetCount() ) // the socket will remove itself from the handler if it got closed - _sh.Select(0,0); - else // so we just need to check if the socket doesnt exist or if it exists but isnt valid anymore. - { // if thats the case, we dont need the session anymore either - if(!_socket || (_socket && !_socket->IsOk())) - { - SetMustDie(); - } - } - - while(pktQueue.size()) - { - valid = false; - pkt = pktQueue.next(); - cmd = (*pkt)[0]; - - // this is a dirty hack for oversize/splitted up packets that are buffered wrongly by realmd - if(_filetransfer) - { - _HandleTransferData(*pkt); - } - // if we dont expect a file transfer select packets as usual - else - { - for(uint8 i=0;table[i].handler!=NULL;i++) - { - if(table[i].cmd==cmd) - { - valid = true; - (this->*table[i].handler)(*pkt); - if(pkt->rpos() < pkt->size()) - { - uint32 len = pkt->size() - pkt->rpos(); - uint8 *data = new uint8[len]; - pkt->read(data,len); // if we have data crap left on the buf, delete it - logdebug("Data left on RealmSocket, Hexdump:"); - logdebug(toHexDump(data,len).c_str()); - delete [] data; - } - break; - } - } - if(!valid) - { - logerror("Invalid realm packet, unknown opcode 0x%X",cmd); - //logerror(toHexDump((uint8*)pkt->contents(),pkt->size()).c_str()); - } - } - delete pkt; - } -} - -PseuInstance *RealmSession::GetInstance(void) -{ - return _instance; -} - -void RealmSession::_HandleRealmList(ByteBuffer& pkt) -{ - std::string realmAddr; - - uint32 unk; - uint16 len,count; - uint8 cmd; - pkt >> cmd >> len >> unk >> count; - - // no realm? - if(count==0) - return; - - // alloc space for as many realms as needed - SRealmInfo *realms=new SRealmInfo[count]; - - // readout realms - for(uint8 i=0;i> realms[i].icon; - pkt >> realms[i].locked; - pkt >> realms[i].color; - pkt >> realms[i].name; - pkt >> realms[i].addr_port; - pkt >> realms[i].population; - pkt >> realms[i].chars_here; - pkt >> realms[i].timezone; - pkt >> realms[i].unknown; - } - - // the rest of the packet is not interesting - - for(uint8 i=0;iGetConf()->realmname) - { - realmAddr=realms[i].addr_port; - } - logcustom(0,LGREEN,"Realm: %s (%s)",realms[i].name.c_str(),realms[i].addr_port.c_str()); - logdetail(" [chars:%d][population:%f][timezone:%d]",realms[i].chars_here,realms[i].population,realms[i].timezone); - } - delete [] realms; - - // now setup where the worldserver is and how to login there - if(realmAddr.empty()){ - log("Realm \"%s\" was not found on the realmlist!",GetInstance()->GetConf()->realmname.c_str()); - return; - } - - // transform "hostname:port" into something useful - // -> convert the worldserver port from string to int - // -> write it into the config & set appropriate vars - - uint16 colonpos=realmAddr.find(":"); - GetInstance()->GetConf()->worldhost=realmAddr.substr(0,colonpos); - GetInstance()->GetConf()->worldport=atoi(realmAddr.substr(colonpos+1,realmAddr.length()-colonpos-1).c_str()); - // set vars - GetInstance()->GetScripts()->variables.Set("WORLDHOST",GetInstance()->GetConf()->worldhost); - GetInstance()->GetScripts()->variables.Set("WORLDPORT",DefScriptTools::toString((uint64)(GetInstance()->GetConf()->worldport))); - - // now we have the correct addr/port, time to create the WorldSession - GetInstance()->CreateWorldSession(); // will be done at next PseuInstance::Update() -} - -void RealmSession::SendLogonChallenge(void) -{ - if(!_socket) - { - logerror("Can't send logon challenge, socket doesn't exist"); - return; - } - if( GetInstance()->GetConf()->accname.empty() || GetInstance()->GetConf()->clientversion_string.empty() - || GetInstance()->GetConf()->clientbuild==0 || GetInstance()->GetConf()->clientlang.empty() ) - { - logcritical("Missing data, can't send Login challenge to Realm Server! (check your conf files)"); - GetInstance()->SetError(); - return; - } - std::string acc = stringToUpper(GetInstance()->GetConf()->accname); - ByteBuffer packet; - packet << (uint8)AUTH_LOGON_CHALLENGE; - packet << (uint8)6; - packet << (uint8)(acc.length()+30); // length of the rest of the packet - packet << (uint8)0; - packet << "WoW"; - packet.append(GetInstance()->GetConf()->clientversion,3); // 1.12.2 etc - packet << (uint16)(GetInstance()->GetConf()->clientbuild); // (uint16) 5875 - packet << "68x" << "niW"; // "x86" - platform; "Win" - Operating system; both reversed and zero terminated - for(uint8 i=0;i<4;i++) - packet << (uint8)(GetInstance()->GetConf()->clientlang[3-i]); // "enUS" -> "SUne" : reversed and NOT zero terminated - packet << (uint32)0x3c; // timezone - packet << (uint32)_socket->GetMyIP(); // my IP address - packet << (uint8)acc.length(); // length of acc name without \0 - packet.append(acc.c_str(),acc.length()); // append accname, skip \0 - - SendRealmPacket(packet); - -} - -void RealmSession::_HandleLogonChallenge(ByteBuffer& pkt) -{ - logdebug("RealmSocket: Got AUTH_LOGON_CHALLENGE [%u of %u bytes]",pkt.size(),sizeof(sAuthLogonChallenge_S)); - if(pkt.size() < 3) - { - logerror("AUTH_LOGON_CHALLENGE: Recieved incorrect/unknown packet. Hexdump:"); - DumpInvalidPacket(pkt); - return; - } - - sAuthLogonChallenge_S lc; - lc.error = pkt[2]; // pre-set error (before copying whole challenge) - - switch (lc.error) - { - case 4: - logerror("Realm Server did not find account \"%s\"!",GetInstance()->GetConf()->accname.c_str()); - break; - case 6: - logerror("Account \"%s\" is already logged in!",GetInstance()->GetConf()->accname.c_str()); - // TODO: wait a certain amount of time before reconnecting? conf option? - break; - case 9: - logerror("Realm Server doesn't accept this version!"); - break; - case 0: - { - pkt.read((uint8*)&lc, sizeof(sAuthLogonChallenge_S)); - logdetail("Login successful, now calculating proof packet..."); - - // now lets start calculating - BigNumber N,A,B,a,u,x,v,S,salt,unk1,g,k(3); // init BNs, default k to 3 - std::string user=stringToUpper( GetInstance()->GetConf()->accname ); - std::string _authstr=stringToUpper( user +":"+GetInstance()->GetConf()->accpass ); - - B.SetBinary(lc.B,32); - g.SetBinary(lc.g,lc.g_len); - N.SetBinary(lc.N,lc.N_len); - salt.SetBinary(lc.salt,32); - unk1.SetBinary(lc.unk3,16); - - logdebug("== Server Bignums =="); - logdebug("--> B=%s",B.AsHexStr()); - logdebug("--> g=%s",g.AsHexStr()); - logdebug("--> N=%s",N.AsHexStr()); - logdebug("--> salt=%s",salt.AsHexStr()); - logdebug("--> unk=%s",unk1.AsHexStr()); - - logdebug("== My Bignums =="); - a.SetRand(19*8); - ASSERT(a.AsDword() > 0); - logdebug("--> a=%s",a.AsHexStr()); - Sha1Hash userhash,xhash,uhash; - userhash.UpdateData(_authstr); - userhash.Finalize(); - xhash.UpdateData(salt.AsByteArray(),salt.GetNumBytes()); - xhash.UpdateData(userhash.GetDigest(),userhash.GetLength()); - xhash.Finalize(); - x.SetBinary(xhash.GetDigest(),xhash.GetLength()); - logdebug("--> x=%s",x.AsHexStr()); - v=g.ModExp(x,N); - logdebug("--> v=%s",v.AsHexStr()); - A=g.ModExp(a,N); - logdebug("--> A=%s",A.AsHexStr()); - uhash.UpdateBigNumbers(&A, &B, NULL); - uhash.Finalize(); - u.SetBinary(uhash.GetDigest(), 20); - logdebug("--> u=%s",u.AsHexStr()); - S=(B - k*g.ModExp(x,N) ).ModExp((a + u * x),N); - logdebug("--> S=%s",S.AsHexStr()); - ASSERT(S.AsDword() > 0); - - - // calc M1 & M2 - unsigned int i=0; - char S1[16+1],S2[16+1]; // 32/2=16 :) +1 for \0 - // split it into 2 seperate strings, interleaved - for(i=0;i<16;i++){ - S1[i]=S.AsByteArray()[i*2]; - S2[i]=S.AsByteArray()[i*2+1]; - } - - // hash each one: - Sha1Hash S1hash,S2hash; - S1hash.UpdateData((const uint8*)S1,16); - S1hash.Finalize(); - S2hash.UpdateData((const uint8*)S2,16); - S2hash.Finalize(); - // Re-combine them - char S_hash[40]; - for(i=0;i<20;i++){ - S_hash[i*2]=S1hash.GetDigest()[i]; - S_hash[i*2+1]=S2hash.GetDigest()[i]; - } - _key.SetBinary((uint8*)S_hash,40); // used later when authing to world - logdebug("--> SessionKey=%s",_key.AsHexStr()); - - char Ng_hash[20]; - Sha1Hash userhash2,Nhash,ghash; - userhash2.UpdateData((const uint8*)user.c_str(),user.length()); - userhash2.Finalize(); - //printchex((char*)userhash2.GetDigest(),userhash2.GetLength(),true); - Nhash.UpdateBigNumbers(&N,NULL); - Nhash.Finalize(); - ghash.UpdateBigNumbers(&g,NULL); - ghash.Finalize(); - for(i=0;i<20;i++)Ng_hash[i] = Nhash.GetDigest()[i]^ghash.GetDigest()[i]; - //printchex(Ng_hash,20,true); - - BigNumber t_acc,t_Ng_hash; - t_acc.SetBinary((const uint8*)userhash2.GetDigest(),userhash2.GetLength()); - t_Ng_hash.SetBinary((const uint8*)Ng_hash,20); - - - Sha1Hash M1hash,M2hash; - - M1hash.UpdateBigNumbers(&t_Ng_hash,&t_acc,&salt,&A,&B,NULL); - M1hash.UpdateData((const uint8*)S_hash,40); - M1hash.Finalize(); - - M2hash.UpdateBigNumbers(&A,NULL); - M2hash.UpdateData((const uint8*)M1hash.GetDigest(),M1hash.GetLength()); - M2hash.UpdateData((const uint8*)S_hash,40); - M2hash.Finalize(); - - logdebug("== Common Hashes =="); - logdebug("--> M1=%s",toHexDump(M1hash.GetDigest(),M1hash.GetLength(),false).c_str()); - logdebug("--> M2=%s",toHexDump(M2hash.GetDigest(),M2hash.GetLength(),false).c_str()); - - // Calc CRC & CRC_hash - // i don't know yet how to calc it, so set it to zero - char crc_hash[20]; - memset(crc_hash,0,20); - - logdebug("--> CRC=%s",toHexDump((uint8*)crc_hash,20,false).c_str()); - - - // now lets prepare the packet - ByteBuffer packet; - packet << (uint8)AUTH_LOGON_PROOF; - packet.append(A.AsByteArray(),A.GetNumBytes()); - packet.append(M1hash.GetDigest(),M1hash.GetLength()); - packet.append(crc_hash,20); - packet << (uint8)0; // number of keys = 0 - - if(GetInstance()->GetConf()->clientbuild > 5302) - packet << (uint8)0; // 1.11.x compatibility (needs one more 0) - - GetInstance()->SetSessionKey(_key); - memcpy(this->_m2,M2hash.GetDigest(),M2hash.GetLength()); // save M2 to an extern var to check it later - - SendRealmPacket(packet); - } - break; - - default: - logerror("Unknown realm server response! opcode=0x%x\n",(unsigned char)lc.error); - DumpInvalidPacket(pkt); - break; - } -} - - -void RealmSession::_HandleLogonProof(ByteBuffer& pkt) -{ - logdebug("RealmSocket: Got AUTH_LOGON_PROOF [%u of %u bytes]",pkt.size(),26); - if(pkt.size() < 2) - { - logerror("AUTH_LOGON_PROOF: Recieved incorrect/unknown packet. Hexdump:"); - DumpInvalidPacket(pkt); - DieOrReconnect(true); - return; - } - uint8 error = pkt[1]; - - // handle error codes - switch(error) - { - case REALM_AUTH_UPDATE_CLIENT: - log("The realm server requested client update."); - DieOrReconnect(true); - return; - - case REALM_AUTH_NO_MATCH: - case REALM_AUTH_UNKNOWN2: - logerror("Wrong password or invalid account information or authentication error"); - DieOrReconnect(true); - return; - - // cover all other cases. continue only if success. - default: - if(error != REALM_AUTH_SUCCESS) - { - logerror("AUTH_LOGON_PROOF: unk error = 0x%X",error); - pkt.rpos(2); - DieOrReconnect(true); - return; - } - } - - - sAuthLogonProof_S lp; - pkt.read((uint8*)&lp, 26); // the compiler didnt like 'sizeof(sAuthLogonProof_S)', said it was 28 - //printchex((char*)&lp, sizeof(sAuthLogonProof_S),true); - if(!memcmp(lp.M2,this->_m2,20)) - { - // auth successful - ByteBuffer packet; - packet << (uint8)REALM_LIST; - packet << (uint32)0; - SendRealmPacket(packet); - } - else - { - logcritical("Auth failed, M2 differs!"); - printf("My M2 :"); printchex((char*)_m2,20,true); - printf("Srv M2:"); printchex((char*)lp.M2,20,true); - - DieOrReconnect(true); - } -} - -void RealmSession::_HandleTransferInit(ByteBuffer& pkt) -{ - _filebuf.clear(); - _transbuf.clear(); - _file_done = 0; - _filetransfer = true; - - uint8 cmd; - uint8 type_size; - uint8 *type_str; - - pkt >> cmd >> type_size; - type_str = new uint8[type_size+1]; - type_str[type_size] = 0; - pkt.read(type_str,type_size); - pkt >> _file_size; - pkt.read(_file_md5,MD5_DIGEST_LENGTH); - logcustom(0,GREEN,"TransferInit [%s]: File size: "I64FMTD" KB (MD5: %s)", (char*)type_str, _file_size / 1024L, toHexDump(&_file_md5[0],MD5_DIGEST_LENGTH,false).c_str()); - delete [] type_str; - ByteBuffer bb(1); - bb << uint8(XFER_ACCEPT); - SendRealmPacket(bb); - logdebug("XFER_ACCEPT sent"); -} - -void RealmSession::_HandleTransferData(ByteBuffer& pkt) -{ - if(!_file_size) - { - logerror("Realm server attempted to transfer a file, but didn't init!"); - DieOrReconnect(false); - return; - } - - uint8 cmd; - uint16 size; - uint8 *data; - - _transbuf.append(pkt.contents(),pkt.size()); // append everything to the transfer buffer, which may also store incomplete bytes from the packet before - pkt.rpos(pkt.size()); // set rpos to the end of the packet to indicate that we used all data - - logdev("transbuf size=%u rpos=%u diff=%u",_transbuf.size(),_transbuf.rpos(),_transbuf.size() - _transbuf.rpos()); - - while( _transbuf.size() - _transbuf.rpos() >= 3) // 3 = sizeof(uint32)+sizeof(uint8) - { - _transbuf >> cmd >> size; - if(_transbuf.size()-_transbuf.rpos() < size) - { - _transbuf.rpos(_transbuf.rpos()-3); // read the header next time again - break; // packet parts missing, continue after recieving next packet - } - data = new uint8[size]; - _transbuf.read(data,size); - _filebuf.append(data,size); - _file_done += size; - delete [] data; - float pct = ((float)_file_done / (float)_file_size * 100.0f); - - // use better output formatting in debug level - if(GetInstance()->GetConf()->debug >= 2) - logdebug("Got data packet, %u data bytes. [%.2f%% done] cmd 0x%X",size,pct,cmd); - else - { - _log_setcolor(true,GREEN); - printf("\r[%.2f%% done]",pct); - _log_resetcolor(true); - } - - } - - // finalize file - if(_file_done >= _file_size) - { - log(""); - log("File transfer finished."); - _filetransfer = false; - MD5Hash md5h; - md5h.Update((uint8*)_filebuf.contents(),_filebuf.size()); - md5h.Finalize(); - std::string md5hex = toHexDump(md5h.GetDigest(),md5h.GetLength(),false); - logdebug("MD5 hash: %s", md5hex.c_str()); - if(!memcmp(_file_md5, md5h.GetDigest(), md5h.GetLength())) - { - std::fstream fh; - char namebuf[100]; - sprintf(namebuf,"%u_%s.mpq",GetInstance()->GetConf()->clientbuild,GetInstance()->GetConf()->clientlang.c_str()); - fh.open(namebuf,std::ios_base::out | std::ios_base::binary); - if(fh.is_open()) - { - fh.write((const char*)_filebuf.contents(),_filebuf.size()); - fh.close(); - log("File saved as \"%s\"",namebuf); - } - else - { - logerror("Could not save \"%s\"",namebuf); - } - } - else - { - logerror("File corruption! Transfer failed! (MD5: %s",md5hex.c_str()); - } - _transbuf.clear(); - - // client sends cancel after successful file transfer also - ByteBuffer bb(1); - bb << uint8(XFER_CANCEL); - SendRealmPacket(bb); - - log("Now modify your conf files and restart PseuWoW."); - for(int8 x = 3; x > -1; x--) // add little delay - { - printf("exiting in... [%u]\r",x); - GetInstance()->Sleep(1000); - } - SetMustDie(); - GetInstance()->Stop(); - } -} - -void RealmSession::DumpInvalidPacket(ByteBuffer& pkt) -{ - if(pkt.size()) - logerror( toHexDump((uint8*)pkt.contents(),pkt.size()).c_str() ); -} - -void RealmSession::SendRealmPacket(ByteBuffer& pkt) -{ - if(_socket && _socket->IsOk()) - { - if(pkt.size()) // dont send packets with no data - _socket->SendBuf((const char*)pkt.contents(),pkt.size()); - } - else - { - logerror("Can't send realm packet, socket does not exist or is not ready!"); - } -} - -// err=true will close PseuWoW if ExitOnError=1 -void RealmSession::DieOrReconnect(bool err) -{ - if(GetInstance()->GetConf()->reconnect) - SetMustDie(); - else if(err) - { - SetMustDie(); - GetInstance()->SetError(); - } -} +#include "common.h" +#include "Auth/Sha1.h" +#include "Auth/BigNumber.h" +#include "PseuWoW.h" +#include "RealmSocket.h" +#include "RealmSession.h" + +enum AuthCmd +{ + //AUTH_NO_CMD = 0xFF, + AUTH_LOGON_CHALLENGE = 0x00, + AUTH_LOGON_PROOF = 0x01, + //AUTH_RECONNECT_CHALLENGE = 0x02, + //AUTH_RECONNECT_PROOF = 0x03, + //update srv =4 + REALM_LIST = 0x10, + XFER_INITIATE = 0x30, + XFER_DATA = 0x31, + XFER_ACCEPT = 0x32, + XFER_RESUME = 0x33, + XFER_CANCEL = 0x34 +}; + +enum eAuthResults +{ + REALM_AUTH_SUCCESS = 0, + REALM_AUTH_FAILURE=0x01, ///< Unable to connect + REALM_AUTH_UNKNOWN1=0x02, ///< Unable to connect + REALM_AUTH_ACCOUNT_BANNED=0x03, ///< This account has been closed and is no longer available for use. Please go to /banned.html for further information. + REALM_AUTH_NO_MATCH=0x04, ///< The information you have entered is not valid. Please check the spelling of the account name and password. If you need help in retrieving a lost or stolen password, see for more information + REALM_AUTH_UNKNOWN2=0x05, ///< The information you have entered is not valid. Please check the spelling of the account name and password. If you need help in retrieving a lost or stolen password, see for more information + REALM_AUTH_ACCOUNT_IN_USE=0x06, ///< This account is already logged into . Please check the spelling and try again. + REALM_AUTH_PREPAID_TIME_LIMIT=0x07, ///< You have used up your prepaid time for this account. Please purchase more to continue playing + REALM_AUTH_SERVER_FULL=0x08, ///< Could not log in to at this time. Please try again later. + REALM_AUTH_WRONG_BUILD_NUMBER=0x09, ///< Unable to validate game version. This may be caused by file corruption or interference of another program. Please visit for more information and possible solutions to this issue. + REALM_AUTH_UPDATE_CLIENT=0x0a, ///< Downloading + REALM_AUTH_UNKNOWN3=0x0b, ///< Unable to connect + REALM_AUTH_ACCOUNT_FREEZED=0x0c, ///< This account has been temporarily suspended. Please go to /banned.html for further information + REALM_AUTH_UNKNOWN4=0x0d, ///< Unable to connect + REALM_AUTH_UNKNOWN5=0x0e, ///< Connected. + REALM_AUTH_PARENTAL_CONTROL=0x0f ///< Access to this account has been blocked by parental controls. Your settings may be changed in your account preferences at +}; + +#define ChunkSize 2048 + +struct SRealmHeader +{ + uint8 cmd; // OP code = CMD_REALM_LIST + uint16 size; // size of the rest of packet, without this part + uint32 unknown; // 0x00 00 00 00 + uint8 count; // quantity of realms +}; + +struct SRealmInfo +{ + uint8 icon; // icon near realm + uint8 locked; // added in 2.0.x + uint8 color; // color of record + std::string name; // Text zero terminated name of Realm + std::string addr_port; // Text zero terminated address of Realm ("ip:port") + float population; // 1.6 -> population value. lower == lower population and vice versa + uint8 chars_here; // number of characters on this server + uint8 timezone; // timezone + uint8 unknown; // +}; + +struct AuthHandler +{ + uint32 cmd; + void (RealmSession::*handler)(ByteBuffer&); +}; + +struct sAuthLogonChallenge_S +{ + uint8 cmd; + uint8 unk2; + uint8 error; + uint8 B[32]; + uint8 g_len; + uint8 g[1]; + uint8 N_len; + uint8 N[32]; + uint8 salt[32]; + uint8 unk3[16]; +}; + +struct sAuthLogonProof_S +{ + uint8 cmd; + uint8 error; + uint8 M2[20]; + uint32 unk2; +}; + +RealmSession::RealmSession(PseuInstance* instance) +{ + _instance = instance; + _socket = NULL; + _mustdie = false; + _filetransfer = false; + _file_size = 0; + _sh.SetAutoCloseSockets(false); +} + +RealmSession::~RealmSession() +{ + // drop the socket + ClearSocket(); + + // clear the queue + ByteBuffer *packet; + while(!pktQueue.empty()) + { + packet = pktQueue.next(); + delete packet; + } + memset(_m2,0,20); + _key=0; +} + +void RealmSession::Connect(void) +{ + ClearSocket(); + _socket = new RealmSocket(_sh); + _socket->SetSession(this); + _socket->Open(GetInstance()->GetConf()->realmlist,GetInstance()->GetConf()->realmport); + _sh.Add(_socket); + _sh.Select(3,0); +} + +void RealmSession::ClearSocket(void) +{ + if(_socket) + { + delete _socket; + _socket = NULL; + } +} + +void RealmSession::SetMustDie(void) +{ + _mustdie = true; + logdebug("RealmSession: Must die now."); +} + +bool RealmSession::MustDie(void) +{ + return _mustdie; +} + +AuthHandler *RealmSession::_GetAuthHandlerTable(void) const +{ + static AuthHandler table[] = + { + {AUTH_LOGON_CHALLENGE,&RealmSession::_HandleLogonChallenge}, + {AUTH_LOGON_PROOF,&RealmSession::_HandleLogonProof}, + {REALM_LIST,&RealmSession::_HandleRealmList}, + {XFER_INITIATE,&RealmSession::_HandleTransferInit}, + {XFER_DATA,&RealmSession::_HandleTransferData}, + {0,NULL} + }; + return table; +} + +void RealmSession::AddToPktQueue(ByteBuffer *pkt) +{ + pktQueue.add(pkt); +} + +void RealmSession::Update(void) +{ + AuthHandler *table = _GetAuthHandlerTable(); + ByteBuffer *pkt; + uint8 cmd; + bool valid = true; + + if( _sh.GetCount() ) // the socket will remove itself from the handler if it got closed + _sh.Select(0,0); + else // so we just need to check if the socket doesnt exist or if it exists but isnt valid anymore. + { // if thats the case, we dont need the session anymore either + if(!_socket || (_socket && !_socket->IsOk())) + { + SetMustDie(); + } + } + + while(pktQueue.size()) + { + valid = false; + pkt = pktQueue.next(); + cmd = (*pkt)[0]; + + // this is a dirty hack for oversize/splitted up packets that are buffered wrongly by realmd + if(_filetransfer) + { + _HandleTransferData(*pkt); + } + // if we dont expect a file transfer select packets as usual + else + { + for(uint8 i=0;table[i].handler!=NULL;i++) + { + if(table[i].cmd==cmd) + { + valid = true; + (this->*table[i].handler)(*pkt); + if(pkt->rpos() < pkt->size()) + { + uint32 len = pkt->size() - pkt->rpos(); + uint8 *data = new uint8[len]; + pkt->read(data,len); // if we have data crap left on the buf, delete it + logdebug("Data left on RealmSocket, Hexdump:"); + logdebug(toHexDump(data,len).c_str()); + delete [] data; + } + break; + } + } + if(!valid) + { + logerror("Invalid realm packet, unknown opcode 0x%X",cmd); + //logerror(toHexDump((uint8*)pkt->contents(),pkt->size()).c_str()); + } + } + delete pkt; + } +} + +PseuInstance *RealmSession::GetInstance(void) +{ + return _instance; +} + +void RealmSession::_HandleRealmList(ByteBuffer& pkt) +{ + std::string realmAddr; + + uint32 unk; + uint16 len,count; + uint8 cmd; + pkt >> cmd >> len >> unk >> count; + + // no realm? + if(count==0) + return; + + // alloc space for as many realms as needed + SRealmInfo *realms=new SRealmInfo[count]; + + // readout realms + for(uint8 i=0;i> realms[i].icon; + pkt >> realms[i].locked; + pkt >> realms[i].color; + pkt >> realms[i].name; + pkt >> realms[i].addr_port; + pkt >> realms[i].population; + pkt >> realms[i].chars_here; + pkt >> realms[i].timezone; + pkt >> realms[i].unknown; + } + + // the rest of the packet is not interesting + + for(uint8 i=0;iGetConf()->realmname) + { + realmAddr=realms[i].addr_port; + } + logcustom(0,LGREEN,"Realm: %s (%s)",realms[i].name.c_str(),realms[i].addr_port.c_str()); + logdetail(" [chars:%d][population:%f][timezone:%d]",realms[i].chars_here,realms[i].population,realms[i].timezone); + } + delete [] realms; + + // now setup where the worldserver is and how to login there + if(realmAddr.empty()){ + log("Realm \"%s\" was not found on the realmlist!",GetInstance()->GetConf()->realmname.c_str()); + return; + } + + // transform "hostname:port" into something useful + // -> convert the worldserver port from string to int + // -> write it into the config & set appropriate vars + + uint16 colonpos=realmAddr.find(":"); + GetInstance()->GetConf()->worldhost=realmAddr.substr(0,colonpos); + GetInstance()->GetConf()->worldport=atoi(realmAddr.substr(colonpos+1,realmAddr.length()-colonpos-1).c_str()); + // set vars + GetInstance()->GetScripts()->variables.Set("WORLDHOST",GetInstance()->GetConf()->worldhost); + GetInstance()->GetScripts()->variables.Set("WORLDPORT",DefScriptTools::toString((uint64)(GetInstance()->GetConf()->worldport))); + + // now we have the correct addr/port, time to create the WorldSession + GetInstance()->CreateWorldSession(); // will be done at next PseuInstance::Update() +} + +void RealmSession::SendLogonChallenge(void) +{ + if(!_socket) + { + logerror("Can't send logon challenge, socket doesn't exist"); + return; + } + if( GetInstance()->GetConf()->accname.empty() || GetInstance()->GetConf()->clientversion_string.empty() + || GetInstance()->GetConf()->clientbuild==0 || GetInstance()->GetConf()->clientlang.empty() ) + { + logcritical("Missing data, can't send Login challenge to Realm Server! (check your conf files)"); + GetInstance()->SetError(); + return; + } + std::string acc = stringToUpper(GetInstance()->GetConf()->accname); + ByteBuffer packet; + packet << (uint8)AUTH_LOGON_CHALLENGE; + packet << (uint8)6; + packet << (uint8)(acc.length()+30); // length of the rest of the packet + packet << (uint8)0; + packet << "WoW"; + packet.append(GetInstance()->GetConf()->clientversion,3); // 1.12.2 etc + packet << (uint16)(GetInstance()->GetConf()->clientbuild); // (uint16) 5875 + packet << "68x" << "niW"; // "x86" - platform; "Win" - Operating system; both reversed and zero terminated + for(uint8 i=0;i<4;i++) + packet << (uint8)(GetInstance()->GetConf()->clientlang[3-i]); // "enUS" -> "SUne" : reversed and NOT zero terminated + packet << (uint32)0x3c; // timezone + packet << (uint32)_socket->GetMyIP(); // my IP address + packet << (uint8)acc.length(); // length of acc name without \0 + packet.append(acc.c_str(),acc.length()); // append accname, skip \0 + + SendRealmPacket(packet); + +} + +void RealmSession::_HandleLogonChallenge(ByteBuffer& pkt) +{ + logdebug("RealmSocket: Got AUTH_LOGON_CHALLENGE [%u of %u bytes]",pkt.size(),sizeof(sAuthLogonChallenge_S)); + if(pkt.size() < 3) + { + logerror("AUTH_LOGON_CHALLENGE: Recieved incorrect/unknown packet. Hexdump:"); + DumpInvalidPacket(pkt); + return; + } + + sAuthLogonChallenge_S lc; + lc.error = pkt[2]; // pre-set error (before copying whole challenge) + + switch (lc.error) + { + case 4: + logerror("Realm Server did not find account \"%s\"!",GetInstance()->GetConf()->accname.c_str()); + break; + case 6: + logerror("Account \"%s\" is already logged in!",GetInstance()->GetConf()->accname.c_str()); + // TODO: wait a certain amount of time before reconnecting? conf option? + break; + case 9: + logerror("Realm Server doesn't accept this version!"); + break; + case 0: + { + pkt.read((uint8*)&lc, sizeof(sAuthLogonChallenge_S)); + logdetail("Login successful, now calculating proof packet..."); + + // now lets start calculating + BigNumber N,A,B,a,u,x,v,S,salt,unk1,g,k(3); // init BNs, default k to 3 + std::string user=stringToUpper( GetInstance()->GetConf()->accname ); + std::string _authstr=stringToUpper( user +":"+GetInstance()->GetConf()->accpass ); + + B.SetBinary(lc.B,32); + g.SetBinary(lc.g,lc.g_len); + N.SetBinary(lc.N,lc.N_len); + salt.SetBinary(lc.salt,32); + unk1.SetBinary(lc.unk3,16); + + logdebug("== Server Bignums =="); + logdebug("--> B=%s",B.AsHexStr()); + logdebug("--> g=%s",g.AsHexStr()); + logdebug("--> N=%s",N.AsHexStr()); + logdebug("--> salt=%s",salt.AsHexStr()); + logdebug("--> unk=%s",unk1.AsHexStr()); + + logdebug("== My Bignums =="); + a.SetRand(19*8); + ASSERT(a.AsDword() > 0); + logdebug("--> a=%s",a.AsHexStr()); + Sha1Hash userhash,xhash,uhash; + userhash.UpdateData(_authstr); + userhash.Finalize(); + xhash.UpdateData(salt.AsByteArray(),salt.GetNumBytes()); + xhash.UpdateData(userhash.GetDigest(),userhash.GetLength()); + xhash.Finalize(); + x.SetBinary(xhash.GetDigest(),xhash.GetLength()); + logdebug("--> x=%s",x.AsHexStr()); + v=g.ModExp(x,N); + logdebug("--> v=%s",v.AsHexStr()); + A=g.ModExp(a,N); + logdebug("--> A=%s",A.AsHexStr()); + uhash.UpdateBigNumbers(&A, &B, NULL); + uhash.Finalize(); + u.SetBinary(uhash.GetDigest(), 20); + logdebug("--> u=%s",u.AsHexStr()); + S=(B - k*g.ModExp(x,N) ).ModExp((a + u * x),N); + logdebug("--> S=%s",S.AsHexStr()); + ASSERT(S.AsDword() > 0); + + + // calc M1 & M2 + unsigned int i=0; + char S1[16+1],S2[16+1]; // 32/2=16 :) +1 for \0 + // split it into 2 seperate strings, interleaved + for(i=0;i<16;i++){ + S1[i]=S.AsByteArray()[i*2]; + S2[i]=S.AsByteArray()[i*2+1]; + } + + // hash each one: + Sha1Hash S1hash,S2hash; + S1hash.UpdateData((const uint8*)S1,16); + S1hash.Finalize(); + S2hash.UpdateData((const uint8*)S2,16); + S2hash.Finalize(); + // Re-combine them + char S_hash[40]; + for(i=0;i<20;i++){ + S_hash[i*2]=S1hash.GetDigest()[i]; + S_hash[i*2+1]=S2hash.GetDigest()[i]; + } + _key.SetBinary((uint8*)S_hash,40); // used later when authing to world + logdebug("--> SessionKey=%s",_key.AsHexStr()); + + char Ng_hash[20]; + Sha1Hash userhash2,Nhash,ghash; + userhash2.UpdateData((const uint8*)user.c_str(),user.length()); + userhash2.Finalize(); + //printchex((char*)userhash2.GetDigest(),userhash2.GetLength(),true); + Nhash.UpdateBigNumbers(&N,NULL); + Nhash.Finalize(); + ghash.UpdateBigNumbers(&g,NULL); + ghash.Finalize(); + for(i=0;i<20;i++)Ng_hash[i] = Nhash.GetDigest()[i]^ghash.GetDigest()[i]; + //printchex(Ng_hash,20,true); + + BigNumber t_acc,t_Ng_hash; + t_acc.SetBinary((const uint8*)userhash2.GetDigest(),userhash2.GetLength()); + t_Ng_hash.SetBinary((const uint8*)Ng_hash,20); + + + Sha1Hash M1hash,M2hash; + + M1hash.UpdateBigNumbers(&t_Ng_hash,&t_acc,&salt,&A,&B,NULL); + M1hash.UpdateData((const uint8*)S_hash,40); + M1hash.Finalize(); + + M2hash.UpdateBigNumbers(&A,NULL); + M2hash.UpdateData((const uint8*)M1hash.GetDigest(),M1hash.GetLength()); + M2hash.UpdateData((const uint8*)S_hash,40); + M2hash.Finalize(); + + logdebug("== Common Hashes =="); + logdebug("--> M1=%s",toHexDump(M1hash.GetDigest(),M1hash.GetLength(),false).c_str()); + logdebug("--> M2=%s",toHexDump(M2hash.GetDigest(),M2hash.GetLength(),false).c_str()); + + // Calc CRC & CRC_hash + // i don't know yet how to calc it, so set it to zero + char crc_hash[20]; + memset(crc_hash,0,20); + + logdebug("--> CRC=%s",toHexDump((uint8*)crc_hash,20,false).c_str()); + + + // now lets prepare the packet + ByteBuffer packet; + packet << (uint8)AUTH_LOGON_PROOF; + packet.append(A.AsByteArray(),A.GetNumBytes()); + packet.append(M1hash.GetDigest(),M1hash.GetLength()); + packet.append(crc_hash,20); + packet << (uint8)0; // number of keys = 0 + + if(GetInstance()->GetConf()->clientbuild > 5302) + packet << (uint8)0; // 1.11.x compatibility (needs one more 0) + + GetInstance()->SetSessionKey(_key); + memcpy(this->_m2,M2hash.GetDigest(),M2hash.GetLength()); // save M2 to an extern var to check it later + + SendRealmPacket(packet); + } + break; + + default: + logerror("Unknown realm server response! opcode=0x%x\n",(unsigned char)lc.error); + DumpInvalidPacket(pkt); + break; + } +} + + +void RealmSession::_HandleLogonProof(ByteBuffer& pkt) +{ + logdebug("RealmSocket: Got AUTH_LOGON_PROOF [%u of %u bytes]",pkt.size(),26); + if(pkt.size() < 2) + { + logerror("AUTH_LOGON_PROOF: Recieved incorrect/unknown packet. Hexdump:"); + DumpInvalidPacket(pkt); + DieOrReconnect(true); + return; + } + uint8 error = pkt[1]; + + // handle error codes + switch(error) + { + case REALM_AUTH_UPDATE_CLIENT: + log("The realm server requested client update."); + DieOrReconnect(true); + return; + + case REALM_AUTH_NO_MATCH: + case REALM_AUTH_UNKNOWN2: + logerror("Wrong password or invalid account information or authentication error"); + DieOrReconnect(true); + return; + + // cover all other cases. continue only if success. + default: + if(error != REALM_AUTH_SUCCESS) + { + logerror("AUTH_LOGON_PROOF: unk error = 0x%X",error); + pkt.rpos(2); + DieOrReconnect(true); + return; + } + } + + + sAuthLogonProof_S lp; + pkt.read((uint8*)&lp, 26); // the compiler didnt like 'sizeof(sAuthLogonProof_S)', said it was 28 + //printchex((char*)&lp, sizeof(sAuthLogonProof_S),true); + if(!memcmp(lp.M2,this->_m2,20)) + { + // auth successful + ByteBuffer packet; + packet << (uint8)REALM_LIST; + packet << (uint32)0; + SendRealmPacket(packet); + } + else + { + logcritical("Auth failed, M2 differs!"); + printf("My M2 :"); printchex((char*)_m2,20,true); + printf("Srv M2:"); printchex((char*)lp.M2,20,true); + + DieOrReconnect(true); + } +} + +void RealmSession::_HandleTransferInit(ByteBuffer& pkt) +{ + _filebuf.clear(); + _transbuf.clear(); + _file_done = 0; + _filetransfer = true; + + uint8 cmd; + uint8 type_size; + uint8 *type_str; + + pkt >> cmd >> type_size; + type_str = new uint8[type_size+1]; + type_str[type_size] = 0; + pkt.read(type_str,type_size); + pkt >> _file_size; + pkt.read(_file_md5,MD5_DIGEST_LENGTH); + logcustom(0,GREEN,"TransferInit [%s]: File size: "I64FMTD" KB (MD5: %s)", (char*)type_str, _file_size / 1024L, toHexDump(&_file_md5[0],MD5_DIGEST_LENGTH,false).c_str()); + delete [] type_str; + ByteBuffer bb(1); + bb << uint8(XFER_ACCEPT); + SendRealmPacket(bb); + logdebug("XFER_ACCEPT sent"); +} + +void RealmSession::_HandleTransferData(ByteBuffer& pkt) +{ + if(!_file_size) + { + logerror("Realm server attempted to transfer a file, but didn't init!"); + DieOrReconnect(false); + return; + } + + uint8 cmd; + uint16 size; + uint8 *data; + + _transbuf.append(pkt.contents(),pkt.size()); // append everything to the transfer buffer, which may also store incomplete bytes from the packet before + pkt.rpos(pkt.size()); // set rpos to the end of the packet to indicate that we used all data + + logdev("transbuf size=%u rpos=%u diff=%u",_transbuf.size(),_transbuf.rpos(),_transbuf.size() - _transbuf.rpos()); + + while( _transbuf.size() - _transbuf.rpos() >= 3) // 3 = sizeof(uint32)+sizeof(uint8) + { + _transbuf >> cmd >> size; + if(_transbuf.size()-_transbuf.rpos() < size) + { + _transbuf.rpos(_transbuf.rpos()-3); // read the header next time again + break; // packet parts missing, continue after recieving next packet + } + data = new uint8[size]; + _transbuf.read(data,size); + _filebuf.append(data,size); + _file_done += size; + delete [] data; + float pct = ((float)_file_done / (float)_file_size * 100.0f); + + // use better output formatting in debug level + if(GetInstance()->GetConf()->debug >= 2) + logdebug("Got data packet, %u data bytes. [%.2f%% done] cmd 0x%X",size,pct,cmd); + else + { + _log_setcolor(true,GREEN); + printf("\r[%.2f%% done]",pct); + _log_resetcolor(true); + } + + } + + // finalize file + if(_file_done >= _file_size) + { + log(""); + log("File transfer finished."); + _filetransfer = false; + MD5Hash md5h; + md5h.Update((uint8*)_filebuf.contents(),_filebuf.size()); + md5h.Finalize(); + std::string md5hex = toHexDump(md5h.GetDigest(),md5h.GetLength(),false); + logdebug("MD5 hash: %s", md5hex.c_str()); + if(!memcmp(_file_md5, md5h.GetDigest(), md5h.GetLength())) + { + std::fstream fh; + char namebuf[100]; + sprintf(namebuf,"%u_%s.mpq",GetInstance()->GetConf()->clientbuild,GetInstance()->GetConf()->clientlang.c_str()); + fh.open(namebuf,std::ios_base::out | std::ios_base::binary); + if(fh.is_open()) + { + fh.write((const char*)_filebuf.contents(),_filebuf.size()); + fh.close(); + log("File saved as \"%s\"",namebuf); + } + else + { + logerror("Could not save \"%s\"",namebuf); + } + } + else + { + logerror("File corruption! Transfer failed! (MD5: %s",md5hex.c_str()); + } + _transbuf.clear(); + + // client sends cancel after successful file transfer also + ByteBuffer bb(1); + bb << uint8(XFER_CANCEL); + SendRealmPacket(bb); + + log("Now modify your conf files and restart PseuWoW."); + for(int8 x = 3; x > -1; x--) // add little delay + { + printf("exiting in... [%u]\r",x); + GetInstance()->Sleep(1000); + } + SetMustDie(); + GetInstance()->Stop(); + } +} + +void RealmSession::DumpInvalidPacket(ByteBuffer& pkt) +{ + if(pkt.size()) + logerror( toHexDump((uint8*)pkt.contents(),pkt.size()).c_str() ); +} + +void RealmSession::SendRealmPacket(ByteBuffer& pkt) +{ + if(_socket && _socket->IsOk()) + { + if(pkt.size()) // dont send packets with no data + _socket->SendBuf((const char*)pkt.contents(),pkt.size()); + } + else + { + logerror("Can't send realm packet, socket does not exist or is not ready!"); + } +} + +// err=true will close PseuWoW if ExitOnError=1 +void RealmSession::DieOrReconnect(bool err) +{ + if(GetInstance()->GetConf()->reconnect) + SetMustDie(); + else if(err) + { + SetMustDie(); + GetInstance()->SetError(); + } +} diff --git a/src/Client/Realm/RealmSocket.cpp b/src/Client/Realm/RealmSocket.cpp index ef72134..53b8270 100644 --- a/src/Client/Realm/RealmSocket.cpp +++ b/src/Client/Realm/RealmSocket.cpp @@ -1,96 +1,96 @@ -#include "common.h" -#include "PseuWoW.h" -#include "ByteBuffer.h" -#include "RealmSession.h" -#include "RealmSocket.h" -#include "Network/Utility.h" - - - - -RealmSocket::RealmSocket(SocketHandler& h) : TcpSocket(h) -{ - _session = NULL; - _ok = false; -} - -RealmSocket::~RealmSocket() -{ - this->Close(); -} - -bool RealmSocket::IsOk(void) -{ - return _ok; -} - -void RealmSocket::SetSession(RealmSession *rs) -{ - _session = rs; -} - -int RealmSocket::Close(void) -{ - _ok = false; - return TcpSocket::Close(); -} - - -void RealmSocket::OnRead(void) -{ - TcpSocket::OnRead(); - uint32 len = ibuf.GetLength(); - logdev("RealmSocket::OnRead() %u bytes",len); - if(!len) - return; - ByteBuffer *pkt = new ByteBuffer(len); - uint8* data = new uint8[len]; - ibuf.Read((char*)data,len); - pkt->append(data,len); - delete [] data; - _session->AddToPktQueue(pkt); -} - - -RealmSession *RealmSocket::GetSession(void) -{ - return _session; -} - -void RealmSocket::OnAccept(void) -{ - logdev("RealmSocket accepted."); -} - -void RealmSocket::OnConnect(void) -{ - logdetail("RealmSocket connected!"); - _ok = true; -} - -void RealmSocket::OnConnectFailed(void) -{ - logerror("Connecting to Realm failed!"); - _ok = false; -} - -void RealmSocket::OnException(void) -{ - if(_ok) - { - logerror("RealmSocket: Exception!"); - _ok = false; - } -} - -void RealmSocket::OnDelete(void) -{ - _ok = false; - _session->SetMustDie(); -} - -uint32 RealmSocket::GetMyIP(void) -{ - return GetRemoteIP4(); -} - +#include "common.h" +#include "PseuWoW.h" +#include "ByteBuffer.h" +#include "RealmSession.h" +#include "RealmSocket.h" +#include "Network/Utility.h" + + + + +RealmSocket::RealmSocket(SocketHandler& h) : TcpSocket(h) +{ + _session = NULL; + _ok = false; +} + +RealmSocket::~RealmSocket() +{ + this->Close(); +} + +bool RealmSocket::IsOk(void) +{ + return _ok; +} + +void RealmSocket::SetSession(RealmSession *rs) +{ + _session = rs; +} + +int RealmSocket::Close(void) +{ + _ok = false; + return TcpSocket::Close(); +} + + +void RealmSocket::OnRead(void) +{ + TcpSocket::OnRead(); + uint32 len = ibuf.GetLength(); + logdev("RealmSocket::OnRead() %u bytes",len); + if(!len) + return; + ByteBuffer *pkt = new ByteBuffer(len); + uint8* data = new uint8[len]; + ibuf.Read((char*)data,len); + pkt->append(data,len); + delete [] data; + _session->AddToPktQueue(pkt); +} + + +RealmSession *RealmSocket::GetSession(void) +{ + return _session; +} + +void RealmSocket::OnAccept(void) +{ + logdev("RealmSocket accepted."); +} + +void RealmSocket::OnConnect(void) +{ + logdetail("RealmSocket connected!"); + _ok = true; +} + +void RealmSocket::OnConnectFailed(void) +{ + logerror("Connecting to Realm failed!"); + _ok = false; +} + +void RealmSocket::OnException(void) +{ + if(_ok) + { + logerror("RealmSocket: Exception!"); + _ok = false; + } +} + +void RealmSocket::OnDelete(void) +{ + _ok = false; + _session->SetMustDie(); +} + +uint32 RealmSocket::GetMyIP(void) +{ + return GetRemoteIP4(); +} + diff --git a/src/Client/RemoteController.cpp b/src/Client/RemoteController.cpp index 421c20c..ccb7855 100644 --- a/src/Client/RemoteController.cpp +++ b/src/Client/RemoteController.cpp @@ -1,38 +1,38 @@ -#include "common.h" -#include "log.h" -#include "ControlSocket.h" -#include "Network/ListenSocket.h" -#include "RemoteController.h" - -RemoteController::RemoteController(PseuInstance *in,uint32 port) -{ - DEBUG(logdebug("RemoteController: setting instance = %X",in)); - h.SetInstance(in); - _mustdie = false; - _instance = in; - ListenSocket *ls = new ListenSocket(h); - if(ls->Bind(port)) - { - logerror("RemoteController: Can't bind to port %u",port); - _mustdie = true; - return; - } - h.Add(ls); - log("RemoteController: listening on port %u",port); -} - -RemoteController::~RemoteController() -{ - DEBUG(logdebug("~RemoteController()")); -} - -void RemoteController::Update(void) -{ - if(_mustdie) - return; - h.Select(0,0); -} - - - - +#include "common.h" +#include "log.h" +#include "ControlSocket.h" +#include "Network/ListenSocket.h" +#include "RemoteController.h" + +RemoteController::RemoteController(PseuInstance *in,uint32 port) +{ + DEBUG(logdebug("RemoteController: setting instance = %X",in)); + h.SetInstance(in); + _mustdie = false; + _instance = in; + ListenSocket *ls = new ListenSocket(h); + if(ls->Bind(port)) + { + logerror("RemoteController: Can't bind to port %u",port); + _mustdie = true; + return; + } + h.Add(ls); + log("RemoteController: listening on port %u",port); +} + +RemoteController::~RemoteController() +{ + DEBUG(logdebug("~RemoteController()")); +} + +void RemoteController::Update(void) +{ + if(_mustdie) + return; + h.Select(0,0); +} + + + + diff --git a/src/Client/SCPDatabase.cpp b/src/Client/SCPDatabase.cpp index 55be06a..8b37759 100644 --- a/src/Client/SCPDatabase.cpp +++ b/src/Client/SCPDatabase.cpp @@ -1,210 +1,210 @@ -#include -#include "common.h" -#include "SCPDatabase.h" - - -uint32 SCPDatabase::LoadFromFile(char *fn) -{ - std::fstream fh; - uint32 size = GetFileSize(fn); - if(!size) - return 0; - - fh.open(fn,std::ios_base::in | std::ios_base::binary); - if( !fh.is_open() ) - return 0; - - char *buf = new char[size]; - fh.read(buf,size); - fh.close(); - - uint32 sections = LoadFromMem(buf,size); - delete [] buf; - return sections; -} - - -uint32 SCPDatabase::LoadFromMem(char *buf, uint32 size) -{ - std::string line,value,entry,storage; - uint32 id=0,sections=0; - - for(uint32 pos = 0; pos < size; pos++) - { - if(buf[pos] == '\n') - { - if(line.empty()) - continue; - while(line[0]==' ' || line[0]=='\t') - line.erase(0,1); - if(line.empty() || (line.length() > 1 && (line[0]=='#' || (line[0]=='/' && line[1]=='/'))) ) - { - line.clear(); - continue; - } - if(line[line.size()-1] == 13 || line[line.size()-1] == 10) // this fixes the annoying newline problems on windows + binary mode - line[line.size()-1] = 0; - if(line[0]=='[') - { - id=(uint32)toInt(line.c_str()+1); // start reading after '[' - sections++; - } - else - { - uint32 pos=line.find("="); - if(pos!=std::string::npos) - { - entry=stringToLower(line.substr(0,pos)); - value=line.substr(pos+1,line.length()-1); - _map[id].Set(entry,value); - } - // else invalid line, must have '=' - } - line.clear(); - } - else - line += buf[pos]; // fill up line until a newline is reached (see above) - } - return sections; -} - -bool SCPDatabase::HasField(uint32 id) -{ - for(SCPFieldMap::iterator i = _map.begin(); i != _map.end(); i++) - if(i->first == id) - return true; - return false; -} - -bool SCPField::HasEntry(std::string e) -{ - for(SCPEntryMap::iterator i = _map.begin(); i != _map.end(); i++) - { - std::string ch = i->first; - if(ch == e) - return true; - } - return false; -} - -std::string SCPField::GetString(std::string entry) -{ - //return HasEntry(entry) ? _map[entry] : ""; - return _map[entry]; -} - -// note that this can take a while depending on the size of the database! -uint32 SCPDatabase::GetFieldByValue(std::string entry, std::string value) -{ - for(SCPFieldMap::iterator fm = _map.begin(); fm != _map.end(); fm++) - if(fm->second.HasEntry(entry) && fm->second.GetString(entry)==value) - return fm->first; - return uint32(-1); -} - -bool SCPDatabaseMgr::HasDB(std::string n) -{ - for(SCPDatabaseMap::iterator i = _map.begin(); i != _map.end(); i++) - if(i->first == n) - return true; - return false; -} - -SCPDatabase& SCPDatabaseMgr::GetDB(std::string n) -{ - return _map[n]; -} - -uint32 SCPDatabaseMgr::AutoLoadFile(char *fn) -{ - std::fstream fh; - uint32 size = GetFileSize(fn); - if(!size) - return 0; - - fh.open(fn,std::ios_base::in | std::ios_base::binary); - if( !fh.is_open() ) - return 0; - - char *buf = new char[size]; - - fh.read(buf,size); - fh.close(); - - std::string line,dbname; - for(uint32 pos = 0; pos < size; pos++) - { - if(buf[pos] == '\n') - { - if(line.empty()) - continue; - while(line[0]==' ' || line[0]=='\t') - line.erase(0,1); - if(line[0] == '#') - { - uint32 eq = line.find("="); - if(eq != std::string::npos) - { - std::string info = stringToLower(line.substr(0,pos)); - std::string value = stringToLower(line.substr(pos+1,line.length()-1)); - if(info == "#dbname") - { - dbname = value; - break; - } - } - } - } - else - line += buf[pos]; - } - delete [] buf; - - if(dbname.empty()) - return 0; - - uint32 sections = GetDB(dbname).LoadFromMem(buf,size); - return sections; - -} - -// -- helper functions -- // - -std::string SCPDatabaseMgr::GetZoneName(uint32 id) -{ - return GetDB("zone").GetField(id).GetString("name"); -} - -std::string SCPDatabaseMgr::GetRaceName(uint32 id) -{ - std::string r = GetDB("race").GetField(id).GetString("name"); - //if(r.empty()) - // r = raceName[id]; - return r; -} - -std::string SCPDatabaseMgr::GetMapName(uint32 id) -{ - return GetDB("map").GetField(id).GetString("name"); -} - -std::string SCPDatabaseMgr::GetClassName_(uint32 id) -{ - std::string r = GetDB("class").GetField(id).GetString("name"); - //if(r.empty()) - // r = className[id]; - return r; -} - -std::string SCPDatabaseMgr::GetGenderName(uint32 id) -{ - return GetDB("gender").GetField(id).GetString("name"); -} - -std::string SCPDatabaseMgr::GetLangName(uint32 id) -{ - std::string r = GetDB("language").GetField(id).GetString("name"); - //if(r.empty()) - // r = LookupName(id,langNames); - return r; -} +#include +#include "common.h" +#include "SCPDatabase.h" + + +uint32 SCPDatabase::LoadFromFile(char *fn) +{ + std::fstream fh; + uint32 size = GetFileSize(fn); + if(!size) + return 0; + + fh.open(fn,std::ios_base::in | std::ios_base::binary); + if( !fh.is_open() ) + return 0; + + char *buf = new char[size]; + fh.read(buf,size); + fh.close(); + + uint32 sections = LoadFromMem(buf,size); + delete [] buf; + return sections; +} + + +uint32 SCPDatabase::LoadFromMem(char *buf, uint32 size) +{ + std::string line,value,entry,storage; + uint32 id=0,sections=0; + + for(uint32 pos = 0; pos < size; pos++) + { + if(buf[pos] == '\n') + { + if(line.empty()) + continue; + while(line[0]==' ' || line[0]=='\t') + line.erase(0,1); + if(line.empty() || (line.length() > 1 && (line[0]=='#' || (line[0]=='/' && line[1]=='/'))) ) + { + line.clear(); + continue; + } + if(line[line.size()-1] == 13 || line[line.size()-1] == 10) // this fixes the annoying newline problems on windows + binary mode + line[line.size()-1] = 0; + if(line[0]=='[') + { + id=(uint32)toInt(line.c_str()+1); // start reading after '[' + sections++; + } + else + { + uint32 pos=line.find("="); + if(pos!=std::string::npos) + { + entry=stringToLower(line.substr(0,pos)); + value=line.substr(pos+1,line.length()-1); + _map[id].Set(entry,value); + } + // else invalid line, must have '=' + } + line.clear(); + } + else + line += buf[pos]; // fill up line until a newline is reached (see above) + } + return sections; +} + +bool SCPDatabase::HasField(uint32 id) +{ + for(SCPFieldMap::iterator i = _map.begin(); i != _map.end(); i++) + if(i->first == id) + return true; + return false; +} + +bool SCPField::HasEntry(std::string e) +{ + for(SCPEntryMap::iterator i = _map.begin(); i != _map.end(); i++) + { + std::string ch = i->first; + if(ch == e) + return true; + } + return false; +} + +std::string SCPField::GetString(std::string entry) +{ + //return HasEntry(entry) ? _map[entry] : ""; + return _map[entry]; +} + +// note that this can take a while depending on the size of the database! +uint32 SCPDatabase::GetFieldByValue(std::string entry, std::string value) +{ + for(SCPFieldMap::iterator fm = _map.begin(); fm != _map.end(); fm++) + if(fm->second.HasEntry(entry) && fm->second.GetString(entry)==value) + return fm->first; + return uint32(-1); +} + +bool SCPDatabaseMgr::HasDB(std::string n) +{ + for(SCPDatabaseMap::iterator i = _map.begin(); i != _map.end(); i++) + if(i->first == n) + return true; + return false; +} + +SCPDatabase& SCPDatabaseMgr::GetDB(std::string n) +{ + return _map[n]; +} + +uint32 SCPDatabaseMgr::AutoLoadFile(char *fn) +{ + std::fstream fh; + uint32 size = GetFileSize(fn); + if(!size) + return 0; + + fh.open(fn,std::ios_base::in | std::ios_base::binary); + if( !fh.is_open() ) + return 0; + + char *buf = new char[size]; + + fh.read(buf,size); + fh.close(); + + std::string line,dbname; + for(uint32 pos = 0; pos < size; pos++) + { + if(buf[pos] == '\n') + { + if(line.empty()) + continue; + while(line[0]==' ' || line[0]=='\t') + line.erase(0,1); + if(line[0] == '#') + { + uint32 eq = line.find("="); + if(eq != std::string::npos) + { + std::string info = stringToLower(line.substr(0,pos)); + std::string value = stringToLower(line.substr(pos+1,line.length()-1)); + if(info == "#dbname") + { + dbname = value; + break; + } + } + } + } + else + line += buf[pos]; + } + delete [] buf; + + if(dbname.empty()) + return 0; + + uint32 sections = GetDB(dbname).LoadFromMem(buf,size); + return sections; + +} + +// -- helper functions -- // + +std::string SCPDatabaseMgr::GetZoneName(uint32 id) +{ + return GetDB("zone").GetField(id).GetString("name"); +} + +std::string SCPDatabaseMgr::GetRaceName(uint32 id) +{ + std::string r = GetDB("race").GetField(id).GetString("name"); + //if(r.empty()) + // r = raceName[id]; + return r; +} + +std::string SCPDatabaseMgr::GetMapName(uint32 id) +{ + return GetDB("map").GetField(id).GetString("name"); +} + +std::string SCPDatabaseMgr::GetClassName_(uint32 id) +{ + std::string r = GetDB("class").GetField(id).GetString("name"); + //if(r.empty()) + // r = className[id]; + return r; +} + +std::string SCPDatabaseMgr::GetGenderName(uint32 id) +{ + return GetDB("gender").GetField(id).GetString("name"); +} + +std::string SCPDatabaseMgr::GetLangName(uint32 id) +{ + std::string r = GetDB("language").GetField(id).GetString("name"); + //if(r.empty()) + // r = LookupName(id,langNames); + return r; +} diff --git a/src/Client/SCPDatabase.h b/src/Client/SCPDatabase.h index f27c119..01e0bc1 100644 --- a/src/Client/SCPDatabase.h +++ b/src/Client/SCPDatabase.h @@ -1,116 +1,116 @@ -#ifndef _SCPDATABASE_H -#define _SCPDATABASE_H - -#include - -/* - * Some preparations for compiled databases. i will continue this later. [FG] - -enum SCPTypes -{ - SCP_TYPE_STRING = 0, - SCP_TYPE_INT, - SCP_TYPE_UINT, - SCP_TYPE_FLOAT -}; - -class SCPEntry -{ -private: - char *str; - -public: - - SCPEntry() { str = NULL; } - ~SCPEntry() { if(str) delete [] str; } - - union - { - int32 intvalue - uint32 uintvalue; - float floatvalue; - }; - - inline char *GetString(uint8 type) - { - if(str) - return str; - else - { - char buf[25]; - char *fmt; - switch (type) - { - case SCP_TYPE_INT: sprintf(buf,"%d",intvalue); break; - case SCP_TYPE_UINT: sprintf(buf,"%u",uintvalue); break; - case SCP_TYPE_FLOAT: sprintf(buf,"%f",floatvalue); break; - } - str = new char[strlen(buf) + 1]; - memcpy(str,buf,strlen(buf) + 1); - return str; - } - } -}; - -*/ - -typedef std::map SCPEntryMap; - -class SCPField -{ -public: - std::string GetString(std::string); - inline uint64 GetInteger(std::string entry) { return toInt(GetString(entry)); } - inline double GetDouble(std::string entry) { return strtod(GetString(entry).c_str(),NULL); } - inline void Set(std::string entry,std::string value) { _map[entry]=value; } - bool HasEntry(std::string); - -private: - SCPEntryMap _map; -}; - -typedef std::map SCPFieldMap; - - -class SCPDatabase -{ -public: - inline SCPField& GetField(uint32 id) { return _map[id]; } - bool HasField(uint32 id); - uint32 LoadFromFile(char*); - uint32 LoadFromMem(char*,uint32); - uint32 GetFieldByValue(std::string entry, std::string value); - -private: - SCPFieldMap _map; - -}; - -typedef std::map SCPDatabaseMap; - -class SCPDatabaseMgr -{ -public: - bool HasDB(std::string); - SCPDatabase& GetDB(std::string); - uint32 AutoLoadFile(char *fn); - inline void DropDB(std::string s) { _map.erase(stringToLower(s)); } - - ////////////////////// - // helper functions // - ////////////////////// - std::string GetZoneName(uint32 id); - std::string GetRaceName(uint32 id); - std::string GetClassName_(uint32 id); - std::string GetGenderName(uint32 id); - std::string GetMapName(uint32 id); - std::string GetLangName(uint32 id); - -private: - SCPDatabaseMap _map; -}; - - - - -#endif +#ifndef _SCPDATABASE_H +#define _SCPDATABASE_H + +#include + +/* + * Some preparations for compiled databases. i will continue this later. [FG] + +enum SCPTypes +{ + SCP_TYPE_STRING = 0, + SCP_TYPE_INT, + SCP_TYPE_UINT, + SCP_TYPE_FLOAT +}; + +class SCPEntry +{ +private: + char *str; + +public: + + SCPEntry() { str = NULL; } + ~SCPEntry() { if(str) delete [] str; } + + union + { + int32 intvalue + uint32 uintvalue; + float floatvalue; + }; + + inline char *GetString(uint8 type) + { + if(str) + return str; + else + { + char buf[25]; + char *fmt; + switch (type) + { + case SCP_TYPE_INT: sprintf(buf,"%d",intvalue); break; + case SCP_TYPE_UINT: sprintf(buf,"%u",uintvalue); break; + case SCP_TYPE_FLOAT: sprintf(buf,"%f",floatvalue); break; + } + str = new char[strlen(buf) + 1]; + memcpy(str,buf,strlen(buf) + 1); + return str; + } + } +}; + +*/ + +typedef std::map SCPEntryMap; + +class SCPField +{ +public: + std::string GetString(std::string); + inline uint64 GetInteger(std::string entry) { return toInt(GetString(entry)); } + inline double GetDouble(std::string entry) { return strtod(GetString(entry).c_str(),NULL); } + inline void Set(std::string entry,std::string value) { _map[entry]=value; } + bool HasEntry(std::string); + +private: + SCPEntryMap _map; +}; + +typedef std::map SCPFieldMap; + + +class SCPDatabase +{ +public: + inline SCPField& GetField(uint32 id) { return _map[id]; } + bool HasField(uint32 id); + uint32 LoadFromFile(char*); + uint32 LoadFromMem(char*,uint32); + uint32 GetFieldByValue(std::string entry, std::string value); + +private: + SCPFieldMap _map; + +}; + +typedef std::map SCPDatabaseMap; + +class SCPDatabaseMgr +{ +public: + bool HasDB(std::string); + SCPDatabase& GetDB(std::string); + uint32 AutoLoadFile(char *fn); + inline void DropDB(std::string s) { _map.erase(stringToLower(s)); } + + ////////////////////// + // helper functions // + ////////////////////// + std::string GetZoneName(uint32 id); + std::string GetRaceName(uint32 id); + std::string GetClassName_(uint32 id); + std::string GetGenderName(uint32 id); + std::string GetMapName(uint32 id); + std::string GetLangName(uint32 id); + +private: + SCPDatabaseMap _map; +}; + + + + +#endif diff --git a/src/Client/World/Bag.h b/src/Client/World/Bag.h index b59d380..7d6a394 100644 --- a/src/Client/World/Bag.h +++ b/src/Client/World/Bag.h @@ -1,18 +1,18 @@ -#ifndef _BAG_H -#define _BAG_H - -#include "common.h" -#include "Item.h" - -class Bag : public Item -{ -public: - Bag(); - void Create(uint64); - -private: - -}; - - -#endif +#ifndef _BAG_H +#define _BAG_H + +#include "common.h" +#include "Item.h" + +class Bag : public Item +{ +public: + Bag(); + void Create(uint64); + +private: + +}; + + +#endif diff --git a/src/Client/World/CMSGConstructor.cpp b/src/Client/World/CMSGConstructor.cpp index 078d37f..bde505e 100644 --- a/src/Client/World/CMSGConstructor.cpp +++ b/src/Client/World/CMSGConstructor.cpp @@ -1,196 +1,196 @@ -#include "common.h" -#include "PseuWoW.h" -#include "WorldPacket.h" -#include "Opcodes.h" -#include "Player.h" -#include "WorldSession.h" -#include "Channel.h" - -void WorldSession::SendChatMessage(uint32 type, uint32 lang, std::string msg, std::string to) -{ - if((!_logged) || msg.empty()) - return; - WorldPacket packet; - packet << type << lang; - switch(type){ - case CHAT_MSG_WHISPER: - if(to.empty()) - return; - packet << to << msg; - break; - case CHAT_MSG_CHANNEL: - if(to.empty() /*|| !_channels->IsOnChannel(to)*/) - return; - packet << to << msg; - break; - default: - packet << msg; - } - packet.SetOpcode(CMSG_MESSAGECHAT); - SendWorldPacket(packet); -} - -void WorldSession::SendQueryPlayerName(uint64 guid) -{ - if((!_logged) || guid==0) - return; - WorldPacket packet; - packet << guid; - packet.SetOpcode(CMSG_NAME_QUERY); - SendWorldPacket(packet); - // to prevent opcode spam, we need to make a list with already requested names -} - -void WorldSession::SendPing(uint32 ping) -{ - if(!_logged) - return; - WorldPacket packet; - packet << ping; - packet << GetLagMS(); - packet.SetOpcode(CMSG_PING); - SendWorldPacket(packet); -} - -void WorldSession::SendEmote(uint32 id) -{ - if(!_logged) - return; - WorldPacket packet; - int32 variation = 0; // randomized usually - packet << id << (uint32)variation << GetMyChar()->GetTarget(); - packet.SetOpcode(CMSG_TEXT_EMOTE); - SendWorldPacket(packet); -} - -void WorldSession::SendQueryItem(uint32 entry, uint64 guid) // is it a guid? not sure -{ - if(objmgr.ItemNonExistent(entry)) - { - logdebug("Skipped query of item %u (was marked as nonexistent before)",entry); - return; - } - logdebug("Sending Item query, id=%u",entry); - WorldPacket packet; - packet << entry << guid; - packet.SetOpcode(CMSG_ITEM_QUERY_SINGLE); - SendWorldPacket(packet); -} - -// use ONLY this function to target objects and notify the server about it. -// (server & client need to stay synced) -void WorldSession::SendSetSelection(uint64 guid) -{ - ASSERT(GetMyChar()) // we need to be logged in to select something - if(guid==GetMyChar()->GetTarget()) - return; // no need to select already selected target - GetMyChar()->SetTarget(guid); - logdebug("SetSelection GUID="I64FMT,guid); - WorldPacket packet; - packet << guid; - packet.SetOpcode(CMSG_SET_SELECTION); - SendWorldPacket(packet); -} - -void WorldSession::SendCastSpell(uint32 spellid, bool nocheck) -{ - if(!spellid) - return; - MyCharacter *my = GetMyChar(); - bool known = nocheck ? true : my->HasSpell(spellid); - - //-- TEMP FIX --// TODO: need a list of spells that is excluded from the check and can always be casted. - // settable via DefScript? - if(spellid==836) - known=true; - - if( (!known) && (!GetInstance()->GetConf()->disablespellcheck) ) - { - logerror("Attempt to cast not-known spell %u",spellid); - return; - } - - Object *target = objmgr.GetObj(my->GetTarget()); - - //if(!target) // this is wrong, some spells dont require a target (areaspells, self-only spells) - // return; // but for now, this should be ok, until a db is used that provides spell info - - WorldPacket packet; - ByteBuffer temp; - uint16 flags=TARGET_FLAG_SELF; // target mask. spellcast implementeation needs to be changed if TARGET_MASK_SELF is != 0 - packet << spellid; - packet << (uint8)0; // unk - if(target && my->GetTarget() != GetGuid()) // self cast? - { - if(target->GetTypeId() == TYPEID_PLAYER || target->GetTypeId() == TYPEID_UNIT) - { - flags |= TARGET_FLAG_UNIT; - temp << (uint8)0xFF << my->GetTarget(); // need to send packed guid? - } - if(target->GetTypeId() == TYPEID_OBJECT) - { - flags |= TARGET_FLAG_OBJECT; - temp << (uint8)0xFF <GetTarget(); // need to send packed guid? - } - // TODO: need implementation of areaspells & item targets (enchant) here (temp << itemGUID)! - // TODO: append floats x,y,z according to target type srcloc & dstloc to temp - // TODO: append string to temp if TARGET_FLAG_STRING is set. what string for what purpose?? - // and whats with TARGET_CORPSE? - } - packet << flags; - packet.append(temp); - - // cast it - packet.SetOpcode(CMSG_CAST_SPELL); - SendWorldPacket(packet); - logdetail("Casting spell %u on target "I64FMT,spellid,my->GetTarget()); - if(!known) - logcustom(1,LRED," - WARNING: spell is NOT known!"); -} - -void WorldSession::SendWhoListRequest(uint32 minlvl, uint32 maxlvl, uint32 racemask, uint32 classmask, std::string name, std::string guildname, std::vector *zonelist, std::vector *strlist) -{ - WorldPacket pkt(CMSG_WHO, 50); // guess size - pkt << minlvl; - pkt << maxlvl; - pkt << name; - pkt << guildname; - pkt << racemask; - pkt << classmask; - - if(zonelist) - { - pkt << (uint32)zonelist->size(); - for(uint32 i = 0; i < zonelist->size(); i++) - pkt << (*zonelist)[i]; - } - else - pkt << uint32(0); - - if(strlist) - { - pkt << (uint32)strlist->size(); - for(uint32 i = 0; i < strlist->size(); i++) - pkt << (*strlist)[i]; - } - else - pkt << uint32(0); - - SendWorldPacket(pkt); -} - -void WorldSession::SendQueryCreature(uint32 entry, uint64 guid) -{ - if(objmgr.CreatureNonExistent(entry)) - { - logdebug("Skipped query of creature %u (was marked as nonexistent before)",entry); - return; - } - logdebug("Sending creature query, id=%u",entry); - WorldPacket wp(CMSG_CREATURE_QUERY,4+8); - wp << entry << guid; - SendWorldPacket(wp); -} - - - +#include "common.h" +#include "PseuWoW.h" +#include "WorldPacket.h" +#include "Opcodes.h" +#include "Player.h" +#include "WorldSession.h" +#include "Channel.h" + +void WorldSession::SendChatMessage(uint32 type, uint32 lang, std::string msg, std::string to) +{ + if((!_logged) || msg.empty()) + return; + WorldPacket packet; + packet << type << lang; + switch(type){ + case CHAT_MSG_WHISPER: + if(to.empty()) + return; + packet << to << msg; + break; + case CHAT_MSG_CHANNEL: + if(to.empty() /*|| !_channels->IsOnChannel(to)*/) + return; + packet << to << msg; + break; + default: + packet << msg; + } + packet.SetOpcode(CMSG_MESSAGECHAT); + SendWorldPacket(packet); +} + +void WorldSession::SendQueryPlayerName(uint64 guid) +{ + if((!_logged) || guid==0) + return; + WorldPacket packet; + packet << guid; + packet.SetOpcode(CMSG_NAME_QUERY); + SendWorldPacket(packet); + // to prevent opcode spam, we need to make a list with already requested names +} + +void WorldSession::SendPing(uint32 ping) +{ + if(!_logged) + return; + WorldPacket packet; + packet << ping; + packet << GetLagMS(); + packet.SetOpcode(CMSG_PING); + SendWorldPacket(packet); +} + +void WorldSession::SendEmote(uint32 id) +{ + if(!_logged) + return; + WorldPacket packet; + int32 variation = 0; // randomized usually + packet << id << (uint32)variation << GetMyChar()->GetTarget(); + packet.SetOpcode(CMSG_TEXT_EMOTE); + SendWorldPacket(packet); +} + +void WorldSession::SendQueryItem(uint32 entry, uint64 guid) // is it a guid? not sure +{ + if(objmgr.ItemNonExistent(entry)) + { + logdebug("Skipped query of item %u (was marked as nonexistent before)",entry); + return; + } + logdebug("Sending Item query, id=%u",entry); + WorldPacket packet; + packet << entry << guid; + packet.SetOpcode(CMSG_ITEM_QUERY_SINGLE); + SendWorldPacket(packet); +} + +// use ONLY this function to target objects and notify the server about it. +// (server & client need to stay synced) +void WorldSession::SendSetSelection(uint64 guid) +{ + ASSERT(GetMyChar()) // we need to be logged in to select something + if(guid==GetMyChar()->GetTarget()) + return; // no need to select already selected target + GetMyChar()->SetTarget(guid); + logdebug("SetSelection GUID="I64FMT,guid); + WorldPacket packet; + packet << guid; + packet.SetOpcode(CMSG_SET_SELECTION); + SendWorldPacket(packet); +} + +void WorldSession::SendCastSpell(uint32 spellid, bool nocheck) +{ + if(!spellid) + return; + MyCharacter *my = GetMyChar(); + bool known = nocheck ? true : my->HasSpell(spellid); + + //-- TEMP FIX --// TODO: need a list of spells that is excluded from the check and can always be casted. + // settable via DefScript? + if(spellid==836) + known=true; + + if( (!known) && (!GetInstance()->GetConf()->disablespellcheck) ) + { + logerror("Attempt to cast not-known spell %u",spellid); + return; + } + + Object *target = objmgr.GetObj(my->GetTarget()); + + //if(!target) // this is wrong, some spells dont require a target (areaspells, self-only spells) + // return; // but for now, this should be ok, until a db is used that provides spell info + + WorldPacket packet; + ByteBuffer temp; + uint16 flags=TARGET_FLAG_SELF; // target mask. spellcast implementeation needs to be changed if TARGET_MASK_SELF is != 0 + packet << spellid; + packet << (uint8)0; // unk + if(target && my->GetTarget() != GetGuid()) // self cast? + { + if(target->GetTypeId() == TYPEID_PLAYER || target->GetTypeId() == TYPEID_UNIT) + { + flags |= TARGET_FLAG_UNIT; + temp << (uint8)0xFF << my->GetTarget(); // need to send packed guid? + } + if(target->GetTypeId() == TYPEID_OBJECT) + { + flags |= TARGET_FLAG_OBJECT; + temp << (uint8)0xFF <GetTarget(); // need to send packed guid? + } + // TODO: need implementation of areaspells & item targets (enchant) here (temp << itemGUID)! + // TODO: append floats x,y,z according to target type srcloc & dstloc to temp + // TODO: append string to temp if TARGET_FLAG_STRING is set. what string for what purpose?? + // and whats with TARGET_CORPSE? + } + packet << flags; + packet.append(temp); + + // cast it + packet.SetOpcode(CMSG_CAST_SPELL); + SendWorldPacket(packet); + logdetail("Casting spell %u on target "I64FMT,spellid,my->GetTarget()); + if(!known) + logcustom(1,LRED," - WARNING: spell is NOT known!"); +} + +void WorldSession::SendWhoListRequest(uint32 minlvl, uint32 maxlvl, uint32 racemask, uint32 classmask, std::string name, std::string guildname, std::vector *zonelist, std::vector *strlist) +{ + WorldPacket pkt(CMSG_WHO, 50); // guess size + pkt << minlvl; + pkt << maxlvl; + pkt << name; + pkt << guildname; + pkt << racemask; + pkt << classmask; + + if(zonelist) + { + pkt << (uint32)zonelist->size(); + for(uint32 i = 0; i < zonelist->size(); i++) + pkt << (*zonelist)[i]; + } + else + pkt << uint32(0); + + if(strlist) + { + pkt << (uint32)strlist->size(); + for(uint32 i = 0; i < strlist->size(); i++) + pkt << (*strlist)[i]; + } + else + pkt << uint32(0); + + SendWorldPacket(pkt); +} + +void WorldSession::SendQueryCreature(uint32 entry, uint64 guid) +{ + if(objmgr.CreatureNonExistent(entry)) + { + logdebug("Skipped query of creature %u (was marked as nonexistent before)",entry); + return; + } + logdebug("Sending creature query, id=%u",entry); + WorldPacket wp(CMSG_CREATURE_QUERY,4+8); + wp << entry << guid; + SendWorldPacket(wp); +} + + + diff --git a/src/Client/World/CacheHandler.cpp b/src/Client/World/CacheHandler.cpp index 47735e8..783144d 100644 --- a/src/Client/World/CacheHandler.cpp +++ b/src/Client/World/CacheHandler.cpp @@ -1,530 +1,530 @@ -#include -#include -#include "common.h" -#include "PseuWoW.h" -#include "Opcodes.h" -#include "SharedDefines.h" -#include "Player.h" -#include "DefScript/DefScript.h" -#include "WorldSession.h" -#include "CacheHandler.h" -#include "Item.h" - -// increase this number whenever you change something that makes old files unusable -uint32 ITEMPROTOTYPES_CACHE_VERSION = 3; -uint32 CREATURETEMPLATES_CACHE_VERSION = 0; - -PlayerNameCache::~PlayerNameCache() -{ - for(std::vector::iterator i=_cache.begin(); i!=_cache.end(); i++) - { - delete *i; - } -} - -bool PlayerNameCache::AddInfo(uint64 guid, std::string name){ - PlayerNameCacheItem *cacheItem=new PlayerNameCacheItem; - cacheItem->_name=name; - cacheItem->_guid=guid; - return AddInfo(cacheItem); -} - -bool PlayerNameCache::IsKnown(uint64 guid) -{ - for(std::vector::iterator i=_cache.begin(); i!=_cache.end(); i++) - if(guid==(*i)->_guid) - return true; - return false; -} - -bool PlayerNameCache::AddInfo(PlayerNameCacheItem* cacheItem) -{ - for(std::vector::iterator i=_cache.begin(); i!=_cache.end(); i++) - if(cacheItem->_guid==(*i)->_guid) - { - delete cacheItem; - return false; - } - _cache.push_back(cacheItem); - return true; -} - -std::string PlayerNameCache::GetName(uint64 guid) -{ - for(std::vector::iterator i=_cache.begin(); i!=_cache.end(); i++) - if(guid==(*i)->_guid) - return (*i)->_name; - return ""; -} - -uint64 PlayerNameCache::GetGuid(std::string name) -{ - for(std::vector::iterator i=_cache.begin(); i!=_cache.end(); i++) - if(name==(*i)->_name) - return (*i)->_guid; - return 0; -} - -bool PlayerNameCache::SaveToFile(void) -{ - log("Saving PlayerNameCache..."); - char *fn="./cache/playernames.cache"; - std::fstream fh; - fh.open(fn, std::ios_base::out | std::ios_base::binary); - if(!fh) - { - logerror("PlayerNameCache: Could not write to file '%s'!",fn); - return false; - } - uint32 size=_cache.size(); - if(size==0) - return false; - uint8 len; - fh.write((char*)&size,sizeof(uint32)); - - for(std::vector::iterator i=_cache.begin(); i!=_cache.end(); i++) - { - fh.write( (char*)&((*i)->_guid),sizeof(uint64) ); - len=(*i)->_name.length(); - fh.write( (char*)&len,sizeof(uint8) ); - fh.write( (char*)(*i)->_name.c_str(),len ); - DEBUG(log( "PlayerNameCache << " I64FMT " -> %s", (*i)->_guid, (*i)->_name.c_str());); - } - fh.close(); - log("PlayerNameCache saved successfully."); - return true; -} - -bool PlayerNameCache::ReadFromFile(void) -{ - char *fn="./cache/playernames.cache"; - log("Loading PlayerNameCache..."); - bool success=true; - std::fstream fh; - fh.open(fn, std::ios_base::in | std::ios_base::binary); - if(!fh.is_open()) - { - logerror("PlayerNameCache: Could not open file '%s'!",fn); - return false; - } - if(fh.eof()) - { - logdetail("PlayerNameCache: Can't load empty file '%s'",fn); - return false; - } - uint32 size; - fh.read((char*)&size,sizeof(uint32)); - std::string tmp; - uint8 len; - char *nameptr=new char[13]; - for(unsigned int i=0;i_guid),sizeof(uint64)); - fh.read((char*)&len,sizeof(uint8)); - if(len > MAX_PLAYERNAME_LENGTH || len < MIN_PLAYERNAME_LENGTH) - { - logerror("PlayerNameCache data seem corrupt [namelength=%d, should be <=%u]",len,MAX_PLAYERNAME_LENGTH); - log("-> Clearing cache, creating new."); - _cache.clear(); - success=false; - break; - } - fh.read(nameptr,len); - cacheItem->_name=nameptr; - AddInfo(cacheItem); - printf("\rPlayerNameCache [ %u / %u ] items loaded",i+1,size); - DEBUG(printf( " >> " I64FMT " -> %s\n", cacheItem->_guid, nameptr);); - } - printf("\n"); - delete nameptr; - fh.flush(); - fh.close(); - if(success) - log("PlayerNameCache successfully loaded."); - return success; -} - -uint32 PlayerNameCache::GetSize(void) -{ - return _cache.size(); -} - -void ItemProtoCache_InsertDataToSession(WorldSession *session) -{ - logdetail("ItemProtoCache: Loading..."); - char* fn = "./cache/ItemPrototypes.cache"; - std::fstream fh; - fh.open(fn, std::ios_base::in | std::ios_base::binary); - if(!fh) - { - logerror("ItemProtoCache: Could not open file '%s'!",fn); - return; - } - - uint32 cacheversion, total; - - try - { - - fh.read((char*)&cacheversion,4); - if(cacheversion != ITEMPROTOTYPES_CACHE_VERSION) - { - logerror("ItemProtoCache is outdated! Creating new cache."); - fh.close(); - return; - } - fh.read((char*)&total,4); - logdetail("ItemProtoCache: %u item prototypes stored",total); - - uint32 datasize, counter = 0; - ByteBuffer buf; - for(uint32 i = 0; i < total && !fh.eof(); i++) - { - buf.clear(); - fh.read((char*)&datasize,sizeof(uint32)); - DEBUG(logdebug("ItemProtoCache: (%u/%u) - datasize=%u",i,total,datasize)); - buf.resize(datasize); - fh.read((char*)buf.contents(),datasize); - ItemProto *proto = new ItemProto(); - buf >> proto->Id; - buf >> proto->Class; - buf >> proto->SubClass; - buf >> proto->Name; - buf >> proto->DisplayInfoID; - buf >> proto->Quality; - buf >> proto->Flags; - buf >> proto->BuyPrice; - buf >> proto->SellPrice; - buf >> proto->InventoryType; - buf >> proto->AllowableClass; - buf >> proto->AllowableRace; - buf >> proto->ItemLevel; - buf >> proto->RequiredLevel; - buf >> proto->RequiredSkill; - buf >> proto->RequiredSkillRank; - buf >> proto->RequiredSpell; - buf >> proto->RequiredHonorRank; - buf >> proto->RequiredCityRank; - buf >> proto->RequiredReputationFaction; - buf >> proto->RequiredReputationRank; - buf >> proto->MaxCount; - buf >> proto->Stackable; - buf >> proto->ContainerSlots; - for(int i = 0; i < 10; i++) - { - buf >> proto->ItemStat[i].ItemStatType; - buf >> proto->ItemStat[i].ItemStatValue; - } - for(int i = 0; i < 5; i++) - { - buf >> proto->Damage[i].DamageMin; - buf >> proto->Damage[i].DamageMax; - buf >> proto->Damage[i].DamageType; - } - buf >> proto->Armor; - buf >> proto->HolyRes; - buf >> proto->FireRes; - buf >> proto->NatureRes; - buf >> proto->FrostRes; - buf >> proto->ShadowRes; - buf >> proto->ArcaneRes; - buf >> proto->Delay; - buf >> proto->Ammo_type; - - buf >> proto->RangedModRange; - for(int s = 0; s < 5; s++) - { - buf >> proto->Spells[s].SpellId; - buf >> proto->Spells[s].SpellTrigger; - buf >> proto->Spells[s].SpellCharges; - buf >> proto->Spells[s].SpellCooldown; - buf >> proto->Spells[s].SpellCategory; - buf >> proto->Spells[s].SpellCategoryCooldown; - } - buf >> proto->Bonding; - buf >> proto->Description; - buf >> proto->PageText; - buf >> proto->LanguageID; - buf >> proto->PageMaterial; - buf >> proto->StartQuest; - buf >> proto->LockID; - buf >> proto->Material; - buf >> proto->Sheath; - buf >> proto->Extra; - buf >> proto->Unk1; // added in 2.0.3 - buf >> proto->Block; - buf >> proto->ItemSet; - buf >> proto->MaxDurability; - buf >> proto->Area; - buf >> proto->Map; - buf >> proto->BagFamily; - buf >> proto->TotemCategory; // Added in 1.12.x client branch - for(uint32 s = 0; s < 3; s++) - { - buf >> proto->Socket[s].Color; - buf >> proto->Socket[s].Content; - } - buf >> proto->socketBonus; - buf >> proto->GemProperties; - buf >> proto->ExtendedCost; - buf >> proto->RequiredArenaRank; - buf >> proto->RequiredDisenchantSkill; - buf >> proto->ArmorDamageModifier; - - if(proto->Id) - { - //DEBUG(logdebug("ItemProtoCache: Loaded %u [%s]",proto->Id, proto->Name[0].c_str())); - session->objmgr.Add(proto); - counter++; - } else - delete proto; - } - - } - catch (ByteBufferException bbe) - { - logerror("ByteBuffer exception: attempt to \"%s\" %u bytes at position %u out of total %u bytes. (wpos=%u)", - bbe.action, bbe.readsize, bbe.rpos, bbe.cursize, bbe.wpos); - } - - fh.close(); - logdetail("ItemProtoCache: Loaded %u Item Prototypes",total); -} - -void ItemProtoCache_WriteDataToCache(WorldSession *session) -{ - if (!session->objmgr.GetItemProtoCount()) - return; - - char* fn = "./cache/ItemPrototypes.cache"; - std::fstream fh; - fh.open(fn, std::ios_base::out | std::ios_base::binary); - if(!fh) - { - logerror("ItemProtoCache: Could not write to file '%s'!",fn); - return; - } - - uint32 total = session->objmgr.GetItemProtoCount(); - fh.write((char*)&ITEMPROTOTYPES_CACHE_VERSION,4); - fh.write((char*)&total,4); - - uint32 counter=0; - ByteBuffer buf; - for(ItemProtoMap::iterator it = session->objmgr.GetItemProtoStorage()->begin(); it != session->objmgr.GetItemProtoStorage()->end(); it++) - { - buf.clear(); - ItemProto *proto = it->second; - buf << proto->Id; - buf << proto->Class; - buf << proto->SubClass; - buf << proto->Name; - buf << proto->DisplayInfoID; - buf << proto->Quality; - buf << proto->Flags; - buf << proto->BuyPrice; - buf << proto->SellPrice; - buf << proto->InventoryType; - buf << proto->AllowableClass; - buf << proto->AllowableRace; - buf << proto->ItemLevel; - buf << proto->RequiredLevel; - buf << proto->RequiredSkill; - buf << proto->RequiredSkillRank; - buf << proto->RequiredSpell; - buf << proto->RequiredHonorRank; - buf << proto->RequiredCityRank; - buf << proto->RequiredReputationFaction; - buf << proto->RequiredReputationRank; - buf << proto->MaxCount; - buf << proto->Stackable; - buf << proto->ContainerSlots; - for(int i = 0; i < 10; i++) - { - buf << proto->ItemStat[i].ItemStatType; - buf << proto->ItemStat[i].ItemStatValue; - } - for(int i = 0; i < 5; i++) - { - buf << proto->Damage[i].DamageMin; - buf << proto->Damage[i].DamageMax; - buf << proto->Damage[i].DamageType; - } - buf << proto->Armor; - buf << proto->HolyRes; - buf << proto->FireRes; - buf << proto->NatureRes; - buf << proto->FrostRes; - buf << proto->ShadowRes; - buf << proto->ArcaneRes; - buf << proto->Delay; - buf << proto->Ammo_type; - - buf << (float)proto->RangedModRange; - for(int s = 0; s < 5; s++) - { - buf << proto->Spells[s].SpellId; - buf << proto->Spells[s].SpellTrigger; - buf << proto->Spells[s].SpellCharges; - buf << proto->Spells[s].SpellCooldown; - buf << proto->Spells[s].SpellCategory; - buf << proto->Spells[s].SpellCategoryCooldown; - } - buf << proto->Bonding; - buf << proto->Description; - buf << proto->PageText; - buf << proto->LanguageID; - buf << proto->PageMaterial; - buf << proto->StartQuest; - buf << proto->LockID; - buf << proto->Material; - buf << proto->Sheath; - buf << proto->Extra; - buf << proto->Unk1; // added in 2.0.3 - buf << proto->Block; - buf << proto->ItemSet; - buf << proto->MaxDurability; - buf << proto->Area; - buf << proto->Map; - buf << proto->BagFamily; - buf << proto->TotemCategory; // Added in 1.12.x client branch - for(uint32 s = 0; s < 3; s++) - { - buf << proto->Socket[s].Color; - buf << proto->Socket[s].Content; - } - buf << proto->socketBonus; - buf << proto->GemProperties; - buf << proto->ExtendedCost; - buf << proto->RequiredArenaRank; - buf << proto->RequiredDisenchantSkill; - buf << proto->ArmorDamageModifier; - - //DEBUG(logdebug("ItemProtoCache: Saved %u [%s]",proto->Id, proto->Name[0].c_str())); - uint32 size = buf.size(); - fh.write((char*)&size,sizeof(uint32)); - fh.write((char*)buf.contents(),buf.size()); - counter++; - } - fh.flush(); - fh.close(); - log("ItemProtoCache: Saved %u Item Prototypes",counter); -} - -void CreatureTemplateCache_InsertDataToSession(WorldSession *session) -{ - logdetail("CreatureTemplateCache: Loading..."); - char* fn = "./cache/CreatureTemplates.cache"; - std::fstream fh; - fh.open(fn, std::ios_base::in | std::ios_base::binary); - if(!fh) - { - logerror("CreatureTemplateCache: Could not open file '%s'!",fn); - return; - } - - uint32 cacheversion, total, counter = 0; - - try - { - - fh.read((char*)&cacheversion,4); - if(cacheversion != CREATURETEMPLATES_CACHE_VERSION) - { - logerror("CreatureTemplateCache is outdated! Creating new cache."); - fh.close(); - return; - } - fh.read((char*)&total,4); - logdetail("CreatureTemplateCache: %u creature templates stored",total); - - uint32 datasize; - ByteBuffer buf; - for(uint32 i = 0; i < total && !fh.eof(); i++) - { - buf.clear(); - fh.read((char*)&datasize,sizeof(uint32)); - buf.resize(datasize); - fh.read((char*)buf.contents(),datasize); - CreatureTemplate *ct = new CreatureTemplate(); - buf >> ct->entry; - buf >> ct->name; - buf >> ct->subname; - buf >> ct->flag1; - buf >> ct->type; - buf >> ct->family; - buf >> ct->rank; - buf >> ct->SpellDataId; - buf >> ct->displayid_A; - buf >> ct->displayid_H; - buf >> ct->displayid_AF; - buf >> ct->displayid_HF; - buf >> ct->RacialLeader; - - if(ct->entry) - { - session->objmgr.Add(ct); - counter++; - } else - delete ct; - } - - } - catch (ByteBufferException bbe) - { - logerror("ByteBuffer exception: attempt to \"%s\" %u bytes at position %u out of total %u bytes. (wpos=%u)", - bbe.action, bbe.readsize, bbe.rpos, bbe.cursize, bbe.wpos); - } - - fh.close(); - logdetail("CreatureTemplateCache: Loaded %u Creature Templates",counter); -} - -void CreatureTemplateCache_WriteDataToCache(WorldSession *session) -{ - if (!session->objmgr.GetCreatureTemplateCount()) - return; - - char* fn = "./cache/CreatureTemplates.cache"; - std::fstream fh; - fh.open(fn, std::ios_base::out | std::ios_base::binary); - if(!fh) - { - logerror("CreatureTemplateCache: Could not write to file '%s'!",fn); - return; - } - uint32 total = session->objmgr.GetCreatureTemplateCount(); - fh.write((char*)&CREATURETEMPLATES_CACHE_VERSION,4); - fh.write((char*)&total,4); - uint32 counter=0; - ByteBuffer buf; - for(CreatureTemplateMap::iterator it = session->objmgr.GetCreatureTemplateStorage()->begin(); it != session->objmgr.GetCreatureTemplateStorage()->end(); it++) - { - buf.clear(); - CreatureTemplate *ct = it->second; - buf << ct->entry; - buf << ct->name; - buf << ct->subname; - buf << ct->flag1; - buf << ct->type; - buf << ct->family; - buf << ct->rank; - buf << ct->SpellDataId; - buf << ct->displayid_A; - buf << ct->displayid_H; - buf << ct->displayid_AF; - buf << ct->displayid_HF; - buf << ct->RacialLeader; - - uint32 size = buf.size(); - fh.write((char*)&size,sizeof(uint32)); - fh.write((char*)buf.contents(),buf.size()); - counter++; - } - fh.flush(); - fh.close(); - log("CreatureTemplateCache: Saved %u Creature Templates",counter); -} +#include +#include +#include "common.h" +#include "PseuWoW.h" +#include "Opcodes.h" +#include "SharedDefines.h" +#include "Player.h" +#include "DefScript/DefScript.h" +#include "WorldSession.h" +#include "CacheHandler.h" +#include "Item.h" + +// increase this number whenever you change something that makes old files unusable +uint32 ITEMPROTOTYPES_CACHE_VERSION = 3; +uint32 CREATURETEMPLATES_CACHE_VERSION = 0; + +PlayerNameCache::~PlayerNameCache() +{ + for(std::vector::iterator i=_cache.begin(); i!=_cache.end(); i++) + { + delete *i; + } +} + +bool PlayerNameCache::AddInfo(uint64 guid, std::string name){ + PlayerNameCacheItem *cacheItem=new PlayerNameCacheItem; + cacheItem->_name=name; + cacheItem->_guid=guid; + return AddInfo(cacheItem); +} + +bool PlayerNameCache::IsKnown(uint64 guid) +{ + for(std::vector::iterator i=_cache.begin(); i!=_cache.end(); i++) + if(guid==(*i)->_guid) + return true; + return false; +} + +bool PlayerNameCache::AddInfo(PlayerNameCacheItem* cacheItem) +{ + for(std::vector::iterator i=_cache.begin(); i!=_cache.end(); i++) + if(cacheItem->_guid==(*i)->_guid) + { + delete cacheItem; + return false; + } + _cache.push_back(cacheItem); + return true; +} + +std::string PlayerNameCache::GetName(uint64 guid) +{ + for(std::vector::iterator i=_cache.begin(); i!=_cache.end(); i++) + if(guid==(*i)->_guid) + return (*i)->_name; + return ""; +} + +uint64 PlayerNameCache::GetGuid(std::string name) +{ + for(std::vector::iterator i=_cache.begin(); i!=_cache.end(); i++) + if(name==(*i)->_name) + return (*i)->_guid; + return 0; +} + +bool PlayerNameCache::SaveToFile(void) +{ + log("Saving PlayerNameCache..."); + char *fn="./cache/playernames.cache"; + std::fstream fh; + fh.open(fn, std::ios_base::out | std::ios_base::binary); + if(!fh) + { + logerror("PlayerNameCache: Could not write to file '%s'!",fn); + return false; + } + uint32 size=_cache.size(); + if(size==0) + return false; + uint8 len; + fh.write((char*)&size,sizeof(uint32)); + + for(std::vector::iterator i=_cache.begin(); i!=_cache.end(); i++) + { + fh.write( (char*)&((*i)->_guid),sizeof(uint64) ); + len=(*i)->_name.length(); + fh.write( (char*)&len,sizeof(uint8) ); + fh.write( (char*)(*i)->_name.c_str(),len ); + DEBUG(log( "PlayerNameCache << " I64FMT " -> %s", (*i)->_guid, (*i)->_name.c_str());); + } + fh.close(); + log("PlayerNameCache saved successfully."); + return true; +} + +bool PlayerNameCache::ReadFromFile(void) +{ + char *fn="./cache/playernames.cache"; + log("Loading PlayerNameCache..."); + bool success=true; + std::fstream fh; + fh.open(fn, std::ios_base::in | std::ios_base::binary); + if(!fh.is_open()) + { + logerror("PlayerNameCache: Could not open file '%s'!",fn); + return false; + } + if(fh.eof()) + { + logdetail("PlayerNameCache: Can't load empty file '%s'",fn); + return false; + } + uint32 size; + fh.read((char*)&size,sizeof(uint32)); + std::string tmp; + uint8 len; + char *nameptr=new char[13]; + for(unsigned int i=0;i_guid),sizeof(uint64)); + fh.read((char*)&len,sizeof(uint8)); + if(len > MAX_PLAYERNAME_LENGTH || len < MIN_PLAYERNAME_LENGTH) + { + logerror("PlayerNameCache data seem corrupt [namelength=%d, should be <=%u]",len,MAX_PLAYERNAME_LENGTH); + log("-> Clearing cache, creating new."); + _cache.clear(); + success=false; + break; + } + fh.read(nameptr,len); + cacheItem->_name=nameptr; + AddInfo(cacheItem); + printf("\rPlayerNameCache [ %u / %u ] items loaded",i+1,size); + DEBUG(printf( " >> " I64FMT " -> %s\n", cacheItem->_guid, nameptr);); + } + printf("\n"); + delete nameptr; + fh.flush(); + fh.close(); + if(success) + log("PlayerNameCache successfully loaded."); + return success; +} + +uint32 PlayerNameCache::GetSize(void) +{ + return _cache.size(); +} + +void ItemProtoCache_InsertDataToSession(WorldSession *session) +{ + logdetail("ItemProtoCache: Loading..."); + char* fn = "./cache/ItemPrototypes.cache"; + std::fstream fh; + fh.open(fn, std::ios_base::in | std::ios_base::binary); + if(!fh) + { + logerror("ItemProtoCache: Could not open file '%s'!",fn); + return; + } + + uint32 cacheversion, total; + + try + { + + fh.read((char*)&cacheversion,4); + if(cacheversion != ITEMPROTOTYPES_CACHE_VERSION) + { + logerror("ItemProtoCache is outdated! Creating new cache."); + fh.close(); + return; + } + fh.read((char*)&total,4); + logdetail("ItemProtoCache: %u item prototypes stored",total); + + uint32 datasize, counter = 0; + ByteBuffer buf; + for(uint32 i = 0; i < total && !fh.eof(); i++) + { + buf.clear(); + fh.read((char*)&datasize,sizeof(uint32)); + DEBUG(logdebug("ItemProtoCache: (%u/%u) - datasize=%u",i,total,datasize)); + buf.resize(datasize); + fh.read((char*)buf.contents(),datasize); + ItemProto *proto = new ItemProto(); + buf >> proto->Id; + buf >> proto->Class; + buf >> proto->SubClass; + buf >> proto->Name; + buf >> proto->DisplayInfoID; + buf >> proto->Quality; + buf >> proto->Flags; + buf >> proto->BuyPrice; + buf >> proto->SellPrice; + buf >> proto->InventoryType; + buf >> proto->AllowableClass; + buf >> proto->AllowableRace; + buf >> proto->ItemLevel; + buf >> proto->RequiredLevel; + buf >> proto->RequiredSkill; + buf >> proto->RequiredSkillRank; + buf >> proto->RequiredSpell; + buf >> proto->RequiredHonorRank; + buf >> proto->RequiredCityRank; + buf >> proto->RequiredReputationFaction; + buf >> proto->RequiredReputationRank; + buf >> proto->MaxCount; + buf >> proto->Stackable; + buf >> proto->ContainerSlots; + for(int i = 0; i < 10; i++) + { + buf >> proto->ItemStat[i].ItemStatType; + buf >> proto->ItemStat[i].ItemStatValue; + } + for(int i = 0; i < 5; i++) + { + buf >> proto->Damage[i].DamageMin; + buf >> proto->Damage[i].DamageMax; + buf >> proto->Damage[i].DamageType; + } + buf >> proto->Armor; + buf >> proto->HolyRes; + buf >> proto->FireRes; + buf >> proto->NatureRes; + buf >> proto->FrostRes; + buf >> proto->ShadowRes; + buf >> proto->ArcaneRes; + buf >> proto->Delay; + buf >> proto->Ammo_type; + + buf >> proto->RangedModRange; + for(int s = 0; s < 5; s++) + { + buf >> proto->Spells[s].SpellId; + buf >> proto->Spells[s].SpellTrigger; + buf >> proto->Spells[s].SpellCharges; + buf >> proto->Spells[s].SpellCooldown; + buf >> proto->Spells[s].SpellCategory; + buf >> proto->Spells[s].SpellCategoryCooldown; + } + buf >> proto->Bonding; + buf >> proto->Description; + buf >> proto->PageText; + buf >> proto->LanguageID; + buf >> proto->PageMaterial; + buf >> proto->StartQuest; + buf >> proto->LockID; + buf >> proto->Material; + buf >> proto->Sheath; + buf >> proto->Extra; + buf >> proto->Unk1; // added in 2.0.3 + buf >> proto->Block; + buf >> proto->ItemSet; + buf >> proto->MaxDurability; + buf >> proto->Area; + buf >> proto->Map; + buf >> proto->BagFamily; + buf >> proto->TotemCategory; // Added in 1.12.x client branch + for(uint32 s = 0; s < 3; s++) + { + buf >> proto->Socket[s].Color; + buf >> proto->Socket[s].Content; + } + buf >> proto->socketBonus; + buf >> proto->GemProperties; + buf >> proto->ExtendedCost; + buf >> proto->RequiredArenaRank; + buf >> proto->RequiredDisenchantSkill; + buf >> proto->ArmorDamageModifier; + + if(proto->Id) + { + //DEBUG(logdebug("ItemProtoCache: Loaded %u [%s]",proto->Id, proto->Name[0].c_str())); + session->objmgr.Add(proto); + counter++; + } else + delete proto; + } + + } + catch (ByteBufferException bbe) + { + logerror("ByteBuffer exception: attempt to \"%s\" %u bytes at position %u out of total %u bytes. (wpos=%u)", + bbe.action, bbe.readsize, bbe.rpos, bbe.cursize, bbe.wpos); + } + + fh.close(); + logdetail("ItemProtoCache: Loaded %u Item Prototypes",total); +} + +void ItemProtoCache_WriteDataToCache(WorldSession *session) +{ + if (!session->objmgr.GetItemProtoCount()) + return; + + char* fn = "./cache/ItemPrototypes.cache"; + std::fstream fh; + fh.open(fn, std::ios_base::out | std::ios_base::binary); + if(!fh) + { + logerror("ItemProtoCache: Could not write to file '%s'!",fn); + return; + } + + uint32 total = session->objmgr.GetItemProtoCount(); + fh.write((char*)&ITEMPROTOTYPES_CACHE_VERSION,4); + fh.write((char*)&total,4); + + uint32 counter=0; + ByteBuffer buf; + for(ItemProtoMap::iterator it = session->objmgr.GetItemProtoStorage()->begin(); it != session->objmgr.GetItemProtoStorage()->end(); it++) + { + buf.clear(); + ItemProto *proto = it->second; + buf << proto->Id; + buf << proto->Class; + buf << proto->SubClass; + buf << proto->Name; + buf << proto->DisplayInfoID; + buf << proto->Quality; + buf << proto->Flags; + buf << proto->BuyPrice; + buf << proto->SellPrice; + buf << proto->InventoryType; + buf << proto->AllowableClass; + buf << proto->AllowableRace; + buf << proto->ItemLevel; + buf << proto->RequiredLevel; + buf << proto->RequiredSkill; + buf << proto->RequiredSkillRank; + buf << proto->RequiredSpell; + buf << proto->RequiredHonorRank; + buf << proto->RequiredCityRank; + buf << proto->RequiredReputationFaction; + buf << proto->RequiredReputationRank; + buf << proto->MaxCount; + buf << proto->Stackable; + buf << proto->ContainerSlots; + for(int i = 0; i < 10; i++) + { + buf << proto->ItemStat[i].ItemStatType; + buf << proto->ItemStat[i].ItemStatValue; + } + for(int i = 0; i < 5; i++) + { + buf << proto->Damage[i].DamageMin; + buf << proto->Damage[i].DamageMax; + buf << proto->Damage[i].DamageType; + } + buf << proto->Armor; + buf << proto->HolyRes; + buf << proto->FireRes; + buf << proto->NatureRes; + buf << proto->FrostRes; + buf << proto->ShadowRes; + buf << proto->ArcaneRes; + buf << proto->Delay; + buf << proto->Ammo_type; + + buf << (float)proto->RangedModRange; + for(int s = 0; s < 5; s++) + { + buf << proto->Spells[s].SpellId; + buf << proto->Spells[s].SpellTrigger; + buf << proto->Spells[s].SpellCharges; + buf << proto->Spells[s].SpellCooldown; + buf << proto->Spells[s].SpellCategory; + buf << proto->Spells[s].SpellCategoryCooldown; + } + buf << proto->Bonding; + buf << proto->Description; + buf << proto->PageText; + buf << proto->LanguageID; + buf << proto->PageMaterial; + buf << proto->StartQuest; + buf << proto->LockID; + buf << proto->Material; + buf << proto->Sheath; + buf << proto->Extra; + buf << proto->Unk1; // added in 2.0.3 + buf << proto->Block; + buf << proto->ItemSet; + buf << proto->MaxDurability; + buf << proto->Area; + buf << proto->Map; + buf << proto->BagFamily; + buf << proto->TotemCategory; // Added in 1.12.x client branch + for(uint32 s = 0; s < 3; s++) + { + buf << proto->Socket[s].Color; + buf << proto->Socket[s].Content; + } + buf << proto->socketBonus; + buf << proto->GemProperties; + buf << proto->ExtendedCost; + buf << proto->RequiredArenaRank; + buf << proto->RequiredDisenchantSkill; + buf << proto->ArmorDamageModifier; + + //DEBUG(logdebug("ItemProtoCache: Saved %u [%s]",proto->Id, proto->Name[0].c_str())); + uint32 size = buf.size(); + fh.write((char*)&size,sizeof(uint32)); + fh.write((char*)buf.contents(),buf.size()); + counter++; + } + fh.flush(); + fh.close(); + log("ItemProtoCache: Saved %u Item Prototypes",counter); +} + +void CreatureTemplateCache_InsertDataToSession(WorldSession *session) +{ + logdetail("CreatureTemplateCache: Loading..."); + char* fn = "./cache/CreatureTemplates.cache"; + std::fstream fh; + fh.open(fn, std::ios_base::in | std::ios_base::binary); + if(!fh) + { + logerror("CreatureTemplateCache: Could not open file '%s'!",fn); + return; + } + + uint32 cacheversion, total, counter = 0; + + try + { + + fh.read((char*)&cacheversion,4); + if(cacheversion != CREATURETEMPLATES_CACHE_VERSION) + { + logerror("CreatureTemplateCache is outdated! Creating new cache."); + fh.close(); + return; + } + fh.read((char*)&total,4); + logdetail("CreatureTemplateCache: %u creature templates stored",total); + + uint32 datasize; + ByteBuffer buf; + for(uint32 i = 0; i < total && !fh.eof(); i++) + { + buf.clear(); + fh.read((char*)&datasize,sizeof(uint32)); + buf.resize(datasize); + fh.read((char*)buf.contents(),datasize); + CreatureTemplate *ct = new CreatureTemplate(); + buf >> ct->entry; + buf >> ct->name; + buf >> ct->subname; + buf >> ct->flag1; + buf >> ct->type; + buf >> ct->family; + buf >> ct->rank; + buf >> ct->SpellDataId; + buf >> ct->displayid_A; + buf >> ct->displayid_H; + buf >> ct->displayid_AF; + buf >> ct->displayid_HF; + buf >> ct->RacialLeader; + + if(ct->entry) + { + session->objmgr.Add(ct); + counter++; + } else + delete ct; + } + + } + catch (ByteBufferException bbe) + { + logerror("ByteBuffer exception: attempt to \"%s\" %u bytes at position %u out of total %u bytes. (wpos=%u)", + bbe.action, bbe.readsize, bbe.rpos, bbe.cursize, bbe.wpos); + } + + fh.close(); + logdetail("CreatureTemplateCache: Loaded %u Creature Templates",counter); +} + +void CreatureTemplateCache_WriteDataToCache(WorldSession *session) +{ + if (!session->objmgr.GetCreatureTemplateCount()) + return; + + char* fn = "./cache/CreatureTemplates.cache"; + std::fstream fh; + fh.open(fn, std::ios_base::out | std::ios_base::binary); + if(!fh) + { + logerror("CreatureTemplateCache: Could not write to file '%s'!",fn); + return; + } + uint32 total = session->objmgr.GetCreatureTemplateCount(); + fh.write((char*)&CREATURETEMPLATES_CACHE_VERSION,4); + fh.write((char*)&total,4); + uint32 counter=0; + ByteBuffer buf; + for(CreatureTemplateMap::iterator it = session->objmgr.GetCreatureTemplateStorage()->begin(); it != session->objmgr.GetCreatureTemplateStorage()->end(); it++) + { + buf.clear(); + CreatureTemplate *ct = it->second; + buf << ct->entry; + buf << ct->name; + buf << ct->subname; + buf << ct->flag1; + buf << ct->type; + buf << ct->family; + buf << ct->rank; + buf << ct->SpellDataId; + buf << ct->displayid_A; + buf << ct->displayid_H; + buf << ct->displayid_AF; + buf << ct->displayid_HF; + buf << ct->RacialLeader; + + uint32 size = buf.size(); + fh.write((char*)&size,sizeof(uint32)); + fh.write((char*)buf.contents(),buf.size()); + counter++; + } + fh.flush(); + fh.close(); + log("CreatureTemplateCache: Saved %u Creature Templates",counter); +} diff --git a/src/Client/World/CacheHandler.h b/src/Client/World/CacheHandler.h index 16b5d90..8bb11e4 100644 --- a/src/Client/World/CacheHandler.h +++ b/src/Client/World/CacheHandler.h @@ -1,31 +1,31 @@ -#ifndef _CACHEHANDLER_H -#define _CACHEHANDLER_H - -struct PlayerNameCacheItem { - uint64 _guid; - std::string _name; -}; - -class PlayerNameCache { -public: - ~PlayerNameCache(); - - std::string GetName(uint64); - bool IsKnown(uint64); - uint64 GetGuid(std::string); - bool AddInfo(uint64 guid, std::string name); - bool AddInfo(PlayerNameCacheItem*); - bool SaveToFile(void); - bool ReadFromFile(void); - uint32 GetSize(void); -private: - std::vector _cache; -}; - -void ItemProtoCache_InsertDataToSession(WorldSession *session); -void ItemProtoCache_WriteDataToCache(WorldSession *session); - -void CreatureTemplateCache_InsertDataToSession(WorldSession *session); -void CreatureTemplateCache_WriteDataToCache(WorldSession *session); - -#endif +#ifndef _CACHEHANDLER_H +#define _CACHEHANDLER_H + +struct PlayerNameCacheItem { + uint64 _guid; + std::string _name; +}; + +class PlayerNameCache { +public: + ~PlayerNameCache(); + + std::string GetName(uint64); + bool IsKnown(uint64); + uint64 GetGuid(std::string); + bool AddInfo(uint64 guid, std::string name); + bool AddInfo(PlayerNameCacheItem*); + bool SaveToFile(void); + bool ReadFromFile(void); + uint32 GetSize(void); +private: + std::vector _cache; +}; + +void ItemProtoCache_InsertDataToSession(WorldSession *session); +void ItemProtoCache_WriteDataToCache(WorldSession *session); + +void CreatureTemplateCache_InsertDataToSession(WorldSession *session); +void CreatureTemplateCache_WriteDataToCache(WorldSession *session); + +#endif diff --git a/src/Client/World/Channel.cpp b/src/Client/World/Channel.cpp index 932229c..400c917 100644 --- a/src/Client/World/Channel.cpp +++ b/src/Client/World/Channel.cpp @@ -1,273 +1,273 @@ -#include "common.h" -#include "PseuWoW.h" -#include -#include "Channel.h" - -enum NotifyTypes -{ - JOINED = 0x00, - LEFT = 0x01, - YOUJOINED = 0x02, - YOULEFT = 0x03, - WRONGPASS = 0x04, - NOTON1 = 0x05, // Not on channel channel name. - NOTMOD = 0x06, - SETPASS = 0x07, - CHANGEOWNER = 0x08, - NOTON2 = 0x09, // Player %s is not on channel. - NOTOWNER = 0x0A, - WHOOWNER = 0x0B, - MODECHANGE = 0x0C, - ANNOUNCEON = 0x0D, - ANNOUNCEOFF = 0x0E, - MODERATED = 0x0F, - UNMODERATED = 0x10, - YOUCANTSPEAK = 0x11, - KICKED = 0x12, - YOUAREBANNED = 0x13, - BANNED = 0x14, - UNBANNED = 0x15, - UNKNOWN1 = 0x16, // is not banned - ALREADYON = 0x17, - INVITED = 0x18, - WRONGALLIANCE = 0x19, // target is in the wrong alliance for channel name - UNKNOWN2 = 0x1A, // wrong alliance for channel name - UNKNOWN3 = 0x1B, // invalid channel name - ISNOTMODERATED = 0x1C, - YOUINVITED = 0x1D, - UNKNOWN4 = 0x1E, // %s has been banned. - UNKNOWN5 = 0x1F, // The number of messages that can be sent to this channel is limited, please wait to send another message. - UNKNOWN6 = 0x20 // You are in not the correct area for this channel. -}; - -enum ChannelFlags -{ - CHANNEL_FLAG_CUSTOM = 0x01, - // 0x02 - CHANNEL_FLAG_TRADE = 0x04, - CHANNEL_FLAG_NOT_LFG = 0x08, - CHANNEL_FLAG_GENERAL = 0x10, - CHANNEL_FLAG_CITY = 0x20, - CHANNEL_FLAG_LFG = 0x40, - CHANNEL_FLAG_VOICE = 0x80 - // General 0x18 = 0x10 | 0x08 - // Trade 0x3C = 0x20 | 0x10 | 0x08 | 0x04 - // LocalDefence 0x18 = 0x10 | 0x08 - // GuildRecruitment 0x38 = 0x20 | 0x10 | 0x08 - // LookingForGroup 0x50 = 0x40 | 0x10 -}; - -enum ChannelMemberFlags -{ - MEMBER_FLAG_NONE = 0x00, - MEMBER_FLAG_OWNER = 0x01, - MEMBER_FLAG_MODERATOR = 0x02, - MEMBER_FLAG_VOICED = 0x04, - MEMBER_FLAG_MUTED = 0x08, - MEMBER_FLAG_CUSTOM = 0x10, - MEMBER_FLAG_MIC_MUTED = 0x20, - // 0x40 - // 0x80 -}; - -typedef std::map ChannelPlayerList; - - -void Channel::Join(std::string channel, std::string password) -{ - if (IsOnChannel(channel)) - return; - - // Send join channel request - WorldPacket worldPacket; - worldPacket.SetOpcode(CMSG_JOIN_CHANNEL); - worldPacket << (uint32)0; // new since 2.0.x, some channel ID? server answers us with that number later if channel joined - worldPacket << (uint8)0; // unk - worldPacket << (uint8)0; // unk, new since 2.2.x - worldPacket << channel << password; - _worldSession->SendWorldPacket(worldPacket); -} - -void Channel::Leave(std::string channel) -{ - for(std::vector::iterator i = channels.begin(); i != channels.end(); i++) - { - if (*i == channel) - { - // Send leave channel request - WorldPacket worldPacket; - worldPacket.SetOpcode(CMSG_LEAVE_CHANNEL); - worldPacket << (uint32)0; // new since 2.0.x, maybe channel id - worldPacket << channel; - _worldSession->SendWorldPacket(worldPacket); - return; - } - } - log("Can't leave channel \"%s\": not joined",channel.c_str()); -} - -void Channel::Say(std::string channel, std::string text, uint32 lang) -{ - _worldSession->SendChatMessage(CHAT_MSG_CHANNEL, lang, text, channel); -} - -bool Channel::IsOnChannel(std::string channel) -{ - for(std::vector::iterator i = channels.begin(); i != channels.end(); i++) - { - if (*i == channel) - { - return true; - } - } - return false; -} - -void Channel::HandleNotifyOpcode(WorldPacket &packet) -{ - uint8 code; - uint64 guid; - - std::string channel, name; - - packet >> code >> channel; - - switch (code) - { - // Player joined channel you are on - case JOINED: - packet >> guid; - if(guid) - { - name = _worldSession->GetOrRequestPlayerName(guid); - if (name.empty()) - { - _worldSession->_DelayWorldPacket(packet, uint32(_worldSession->GetLagMS() * 1.2f)); - return; - } - } - - log("%s joined channel %s",name.c_str(),channel.c_str()); - break; - - // Player leaved channel you are on - case LEFT: - packet >> guid; - if(guid) - { - name = _worldSession->GetOrRequestPlayerName(guid); - if (name.empty()) - { - _worldSession->_DelayWorldPacket(packet, uint32(_worldSession->GetLagMS() * 1.2f)); - return; - } - } - - log("%s left channel %s", name.c_str(), channel.c_str()); - break; - - // You joined channel successfully - case YOUJOINED: - log("Joined channel %s", channel.c_str()); - channels.push_back(channel); - break; - - // You leaved channel successfully - case YOULEFT: - for(std::vector::iterator i = channels.begin(); i != channels.end(); i++) - { - if(*i == channel) - { - channels.erase(i); - break; - } - } - log("Left channel %s", channel.c_str()); - break; - - // Wrong password while trying to join channel - case WRONGPASS: - log("Could not join channel %s (Wrong password)", channel.c_str()); - break; - - // Not on channel while trying to write to channel etc. - case NOTON1: - log("You are not on channel %s", channel.c_str()); - break; - } - - // TODO: Even more channel notices to handle - /* - printf("Channel notice not handled! Code: %d - Channel name: %s\nData:\n", code, channel.c_str()); - packet.textlike(); - printf("\n"); - */ -} - -void Channel::RequestList(std::string ch) -{ - if(!IsOnChannel(ch)) - logdebug("Requesting list of not joined channel '%s'",ch.c_str()); - WorldPacket wp; - wp.SetOpcode(CMSG_CHANNEL_LIST); - wp << ch; - _worldSession->SendWorldPacket(wp); -} - -void Channel::HandleListRequest(WorldPacket& recvPacket) -{ - ChannelPlayerList cpl; - uint8 unk; - uint32 size; - uint64 guid; - uint8 mode, flags; // mode: player flags; flags: channel flags - std::string name; - bool must_delay = false; - - recvPacket >> unk >> name >> flags >> size; - - for(uint32 i = 0; i < size; i++) - { - recvPacket >> guid >> mode; - // all player names in this packet must be known before - if(_worldSession->GetOrRequestPlayerName(guid).empty()) - { - _worldSession->_DelayWorldPacket(recvPacket, uint32(_worldSession->GetLagMS() * 1.2f)); - must_delay = true; - } - cpl[guid] = mode; - } - if(must_delay) - return; - - // store list of GUIDs in: @ChannelList - see below - DefList *l = _worldSession->GetInstance()->GetScripts()->lists.Get("@ChannelList"); - l->clear(); - - std::string pname; - bool muted,mod; - logcustom(0,WHITE,"Player channel list, %u players:",size); - for(ChannelPlayerList::iterator i = cpl.begin(); i != cpl.end(); i++) - { - pname = _worldSession->GetOrRequestPlayerName(i->first); // all names should be known now - mode = i->second; - if(pname.empty()) - pname = ""; - - muted = mode & MEMBER_FLAG_MUTED; - mod = mode & MEMBER_FLAG_MODERATOR; - - while(pname.length() < MAX_PLAYERNAME_LENGTH) - pname += " "; // for better formatting - - logcustom(0,WHITE,"%s ["I64FMT"] %s %s",pname.c_str(),i->first,muted?"(muted)":"",mod?"(moderator)":""); - - // DefScript binding - l->push_back(DefScriptTools::toString(guid)); - } -} - - - - - +#include "common.h" +#include "PseuWoW.h" +#include +#include "Channel.h" + +enum NotifyTypes +{ + JOINED = 0x00, + LEFT = 0x01, + YOUJOINED = 0x02, + YOULEFT = 0x03, + WRONGPASS = 0x04, + NOTON1 = 0x05, // Not on channel channel name. + NOTMOD = 0x06, + SETPASS = 0x07, + CHANGEOWNER = 0x08, + NOTON2 = 0x09, // Player %s is not on channel. + NOTOWNER = 0x0A, + WHOOWNER = 0x0B, + MODECHANGE = 0x0C, + ANNOUNCEON = 0x0D, + ANNOUNCEOFF = 0x0E, + MODERATED = 0x0F, + UNMODERATED = 0x10, + YOUCANTSPEAK = 0x11, + KICKED = 0x12, + YOUAREBANNED = 0x13, + BANNED = 0x14, + UNBANNED = 0x15, + UNKNOWN1 = 0x16, // is not banned + ALREADYON = 0x17, + INVITED = 0x18, + WRONGALLIANCE = 0x19, // target is in the wrong alliance for channel name + UNKNOWN2 = 0x1A, // wrong alliance for channel name + UNKNOWN3 = 0x1B, // invalid channel name + ISNOTMODERATED = 0x1C, + YOUINVITED = 0x1D, + UNKNOWN4 = 0x1E, // %s has been banned. + UNKNOWN5 = 0x1F, // The number of messages that can be sent to this channel is limited, please wait to send another message. + UNKNOWN6 = 0x20 // You are in not the correct area for this channel. +}; + +enum ChannelFlags +{ + CHANNEL_FLAG_CUSTOM = 0x01, + // 0x02 + CHANNEL_FLAG_TRADE = 0x04, + CHANNEL_FLAG_NOT_LFG = 0x08, + CHANNEL_FLAG_GENERAL = 0x10, + CHANNEL_FLAG_CITY = 0x20, + CHANNEL_FLAG_LFG = 0x40, + CHANNEL_FLAG_VOICE = 0x80 + // General 0x18 = 0x10 | 0x08 + // Trade 0x3C = 0x20 | 0x10 | 0x08 | 0x04 + // LocalDefence 0x18 = 0x10 | 0x08 + // GuildRecruitment 0x38 = 0x20 | 0x10 | 0x08 + // LookingForGroup 0x50 = 0x40 | 0x10 +}; + +enum ChannelMemberFlags +{ + MEMBER_FLAG_NONE = 0x00, + MEMBER_FLAG_OWNER = 0x01, + MEMBER_FLAG_MODERATOR = 0x02, + MEMBER_FLAG_VOICED = 0x04, + MEMBER_FLAG_MUTED = 0x08, + MEMBER_FLAG_CUSTOM = 0x10, + MEMBER_FLAG_MIC_MUTED = 0x20, + // 0x40 + // 0x80 +}; + +typedef std::map ChannelPlayerList; + + +void Channel::Join(std::string channel, std::string password) +{ + if (IsOnChannel(channel)) + return; + + // Send join channel request + WorldPacket worldPacket; + worldPacket.SetOpcode(CMSG_JOIN_CHANNEL); + worldPacket << (uint32)0; // new since 2.0.x, some channel ID? server answers us with that number later if channel joined + worldPacket << (uint8)0; // unk + worldPacket << (uint8)0; // unk, new since 2.2.x + worldPacket << channel << password; + _worldSession->SendWorldPacket(worldPacket); +} + +void Channel::Leave(std::string channel) +{ + for(std::vector::iterator i = channels.begin(); i != channels.end(); i++) + { + if (*i == channel) + { + // Send leave channel request + WorldPacket worldPacket; + worldPacket.SetOpcode(CMSG_LEAVE_CHANNEL); + worldPacket << (uint32)0; // new since 2.0.x, maybe channel id + worldPacket << channel; + _worldSession->SendWorldPacket(worldPacket); + return; + } + } + log("Can't leave channel \"%s\": not joined",channel.c_str()); +} + +void Channel::Say(std::string channel, std::string text, uint32 lang) +{ + _worldSession->SendChatMessage(CHAT_MSG_CHANNEL, lang, text, channel); +} + +bool Channel::IsOnChannel(std::string channel) +{ + for(std::vector::iterator i = channels.begin(); i != channels.end(); i++) + { + if (*i == channel) + { + return true; + } + } + return false; +} + +void Channel::HandleNotifyOpcode(WorldPacket &packet) +{ + uint8 code; + uint64 guid; + + std::string channel, name; + + packet >> code >> channel; + + switch (code) + { + // Player joined channel you are on + case JOINED: + packet >> guid; + if(guid) + { + name = _worldSession->GetOrRequestPlayerName(guid); + if (name.empty()) + { + _worldSession->_DelayWorldPacket(packet, uint32(_worldSession->GetLagMS() * 1.2f)); + return; + } + } + + log("%s joined channel %s",name.c_str(),channel.c_str()); + break; + + // Player leaved channel you are on + case LEFT: + packet >> guid; + if(guid) + { + name = _worldSession->GetOrRequestPlayerName(guid); + if (name.empty()) + { + _worldSession->_DelayWorldPacket(packet, uint32(_worldSession->GetLagMS() * 1.2f)); + return; + } + } + + log("%s left channel %s", name.c_str(), channel.c_str()); + break; + + // You joined channel successfully + case YOUJOINED: + log("Joined channel %s", channel.c_str()); + channels.push_back(channel); + break; + + // You leaved channel successfully + case YOULEFT: + for(std::vector::iterator i = channels.begin(); i != channels.end(); i++) + { + if(*i == channel) + { + channels.erase(i); + break; + } + } + log("Left channel %s", channel.c_str()); + break; + + // Wrong password while trying to join channel + case WRONGPASS: + log("Could not join channel %s (Wrong password)", channel.c_str()); + break; + + // Not on channel while trying to write to channel etc. + case NOTON1: + log("You are not on channel %s", channel.c_str()); + break; + } + + // TODO: Even more channel notices to handle + /* + printf("Channel notice not handled! Code: %d - Channel name: %s\nData:\n", code, channel.c_str()); + packet.textlike(); + printf("\n"); + */ +} + +void Channel::RequestList(std::string ch) +{ + if(!IsOnChannel(ch)) + logdebug("Requesting list of not joined channel '%s'",ch.c_str()); + WorldPacket wp; + wp.SetOpcode(CMSG_CHANNEL_LIST); + wp << ch; + _worldSession->SendWorldPacket(wp); +} + +void Channel::HandleListRequest(WorldPacket& recvPacket) +{ + ChannelPlayerList cpl; + uint8 unk; + uint32 size; + uint64 guid; + uint8 mode, flags; // mode: player flags; flags: channel flags + std::string name; + bool must_delay = false; + + recvPacket >> unk >> name >> flags >> size; + + for(uint32 i = 0; i < size; i++) + { + recvPacket >> guid >> mode; + // all player names in this packet must be known before + if(_worldSession->GetOrRequestPlayerName(guid).empty()) + { + _worldSession->_DelayWorldPacket(recvPacket, uint32(_worldSession->GetLagMS() * 1.2f)); + must_delay = true; + } + cpl[guid] = mode; + } + if(must_delay) + return; + + // store list of GUIDs in: @ChannelList - see below + DefList *l = _worldSession->GetInstance()->GetScripts()->lists.Get("@ChannelList"); + l->clear(); + + std::string pname; + bool muted,mod; + logcustom(0,WHITE,"Player channel list, %u players:",size); + for(ChannelPlayerList::iterator i = cpl.begin(); i != cpl.end(); i++) + { + pname = _worldSession->GetOrRequestPlayerName(i->first); // all names should be known now + mode = i->second; + if(pname.empty()) + pname = ""; + + muted = mode & MEMBER_FLAG_MUTED; + mod = mode & MEMBER_FLAG_MODERATOR; + + while(pname.length() < MAX_PLAYERNAME_LENGTH) + pname += " "; // for better formatting + + logcustom(0,WHITE,"%s ["I64FMT"] %s %s",pname.c_str(),i->first,muted?"(muted)":"",mod?"(moderator)":""); + + // DefScript binding + l->push_back(DefScriptTools::toString(guid)); + } +} + + + + + diff --git a/src/Client/World/Corpse.h b/src/Client/World/Corpse.h index 389d075..538b12e 100644 --- a/src/Client/World/Corpse.h +++ b/src/Client/World/Corpse.h @@ -1,16 +1,16 @@ -#ifndef _CORPSE_H -#define _CORPSE_H - -#include "Object.h" - -class Corpse : public WorldObject -{ -public: - Corpse(); - void Create(uint64); - -private: - -}; - -#endif +#ifndef _CORPSE_H +#define _CORPSE_H + +#include "Object.h" + +class Corpse : public WorldObject +{ +public: + Corpse(); + void Create(uint64); + +private: + +}; + +#endif diff --git a/src/Client/World/DynamicObject.h b/src/Client/World/DynamicObject.h index 6066039..42cd24d 100644 --- a/src/Client/World/DynamicObject.h +++ b/src/Client/World/DynamicObject.h @@ -1,16 +1,16 @@ -#ifndef _DYNAMICOBJECT_H -#define _DYNAMICOBJECT_H - -#include "Object.h" - -class DynamicObject : public WorldObject -{ -public: - DynamicObject(); - void Create(uint64); - -private: - -}; - -#endif +#ifndef _DYNAMICOBJECT_H +#define _DYNAMICOBJECT_H + +#include "Object.h" + +class DynamicObject : public WorldObject +{ +public: + DynamicObject(); + void Create(uint64); + +private: + +}; + +#endif diff --git a/src/Client/World/GameObject.h b/src/Client/World/GameObject.h index eeb07dc..7b5af61 100644 --- a/src/Client/World/GameObject.h +++ b/src/Client/World/GameObject.h @@ -1,16 +1,16 @@ -#ifndef _GAMEOBJECT_H -#define _GAMEOBJECT_H - -#include "Object.h" - -class GameObject : public WorldObject -{ -public: - GameObject(); - void Create(uint64); - -private: - -}; - -#endif +#ifndef _GAMEOBJECT_H +#define _GAMEOBJECT_H + +#include "Object.h" + +class GameObject : public WorldObject +{ +public: + GameObject(); + void Create(uint64); + +private: + +}; + +#endif diff --git a/src/Client/World/Item.cpp b/src/Client/World/Item.cpp index a93ab3e..8c20de5 100644 --- a/src/Client/World/Item.cpp +++ b/src/Client/World/Item.cpp @@ -1,129 +1,129 @@ -#include "WorldSession.h" -#include "UpdateFields.h" - -#include "Item.h" -#include "Bag.h" - -void WorldSession::_HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket) -{ - ItemProto *proto = new ItemProto(); - recvPacket >> proto->Id; - uint8 field[64]; - uint32 unk; - std::string s; - memset(field,0,64); - if(memcmp(recvPacket.contents()+sizeof(uint32),field,64)) - { - recvPacket >> proto->Class; - recvPacket >> proto->SubClass; - recvPacket >> unk; // dont need that value? - recvPacket >> proto->Name; - recvPacket >> s >> s >> s; // strip name2-4 - recvPacket >> proto->DisplayInfoID; - recvPacket >> proto->Quality; - recvPacket >> proto->Flags; - recvPacket >> proto->BuyPrice; - recvPacket >> proto->SellPrice; - recvPacket >> proto->InventoryType; - recvPacket >> proto->AllowableClass; - recvPacket >> proto->AllowableRace; - recvPacket >> proto->ItemLevel; - recvPacket >> proto->RequiredLevel; - recvPacket >> proto->RequiredSkill; - recvPacket >> proto->RequiredSkillRank; - recvPacket >> proto->RequiredSpell; - recvPacket >> proto->RequiredHonorRank; - recvPacket >> proto->RequiredCityRank; - recvPacket >> proto->RequiredReputationFaction; - recvPacket >> proto->RequiredReputationRank; - recvPacket >> proto->MaxCount; - recvPacket >> proto->Stackable; - recvPacket >> proto->ContainerSlots; - for(int i = 0; i < 10; i++) - { - recvPacket >> proto->ItemStat[i].ItemStatType; - recvPacket >> proto->ItemStat[i].ItemStatValue; - } - for(int i = 0; i < 5; i++) - { - recvPacket >> proto->Damage[i].DamageMin; - recvPacket >> proto->Damage[i].DamageMax; - recvPacket >> proto->Damage[i].DamageType; - } - recvPacket >> proto->Armor; - recvPacket >> proto->HolyRes; - recvPacket >> proto->FireRes; - recvPacket >> proto->NatureRes; - recvPacket >> proto->FrostRes; - recvPacket >> proto->ShadowRes; - recvPacket >> proto->ArcaneRes; - recvPacket >> proto->Delay; - recvPacket >> proto->Ammo_type; - - recvPacket >> proto->RangedModRange; - for(int s = 0; s < 5; s++) - { - recvPacket >> proto->Spells[s].SpellId; - recvPacket >> proto->Spells[s].SpellTrigger; - recvPacket >> proto->Spells[s].SpellCharges; - recvPacket >> proto->Spells[s].SpellCooldown; - recvPacket >> proto->Spells[s].SpellCategory; - recvPacket >> proto->Spells[s].SpellCategoryCooldown; - } - recvPacket >> proto->Bonding; - recvPacket >> proto->Description; - recvPacket >> proto->PageText; - recvPacket >> proto->LanguageID; - recvPacket >> proto->PageMaterial; - recvPacket >> proto->StartQuest; - recvPacket >> proto->LockID; - recvPacket >> proto->Material; - recvPacket >> proto->Sheath; - recvPacket >> proto->Extra; - recvPacket >> proto->Block; - recvPacket >> proto->ItemSet; - recvPacket >> proto->MaxDurability; - recvPacket >> proto->Area; - recvPacket >> proto->Map; - recvPacket >> proto->BagFamily; - recvPacket >> proto->TotemCategory; // Added in 1.12.x client branch - for(uint32 s = 0; s < 3; s++) - { - recvPacket >> proto->Socket[s].Color; - recvPacket >> proto->Socket[s].Content; - } - recvPacket >> proto->socketBonus; - recvPacket >> proto->GemProperties; - recvPacket >> proto->ExtendedCost; - recvPacket >> proto->RequiredDisenchantSkill; - recvPacket >> proto->ArmorDamageModifier; - - logdetail("Got Item Info: Id=%u Name='%s' ReqLevel=%u Armor=%u Desc='%s'", - proto->Id, proto->Name.c_str(), proto->RequiredLevel, proto->Armor, proto->Description.c_str()); - objmgr.Add(proto); - objmgr.AssignNameToObj(proto->Id, TYPEID_ITEM, proto->Name); - objmgr.AssignNameToObj(proto->Id, TYPEID_CONTAINER, proto->Name); - } - else - { - logdetail("Got info of nonexistent Item %u",proto->Id); - objmgr.AddNonexistentItem(proto->Id); - delete proto; - } -} - -Item::Item() -{ - _type |= TYPE_ITEM; - _typeid = TYPEID_ITEM; - - _valuescount = ITEM_END; - _slot = 0; - //_bag = NULL; // not yet implemented -} - -void Item::Create(uint64 guid) -{ - Object::Create(guid); - // what else? -} +#include "WorldSession.h" +#include "UpdateFields.h" + +#include "Item.h" +#include "Bag.h" + +void WorldSession::_HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket) +{ + ItemProto *proto = new ItemProto(); + recvPacket >> proto->Id; + uint8 field[64]; + uint32 unk; + std::string s; + memset(field,0,64); + if(memcmp(recvPacket.contents()+sizeof(uint32),field,64)) + { + recvPacket >> proto->Class; + recvPacket >> proto->SubClass; + recvPacket >> unk; // dont need that value? + recvPacket >> proto->Name; + recvPacket >> s >> s >> s; // strip name2-4 + recvPacket >> proto->DisplayInfoID; + recvPacket >> proto->Quality; + recvPacket >> proto->Flags; + recvPacket >> proto->BuyPrice; + recvPacket >> proto->SellPrice; + recvPacket >> proto->InventoryType; + recvPacket >> proto->AllowableClass; + recvPacket >> proto->AllowableRace; + recvPacket >> proto->ItemLevel; + recvPacket >> proto->RequiredLevel; + recvPacket >> proto->RequiredSkill; + recvPacket >> proto->RequiredSkillRank; + recvPacket >> proto->RequiredSpell; + recvPacket >> proto->RequiredHonorRank; + recvPacket >> proto->RequiredCityRank; + recvPacket >> proto->RequiredReputationFaction; + recvPacket >> proto->RequiredReputationRank; + recvPacket >> proto->MaxCount; + recvPacket >> proto->Stackable; + recvPacket >> proto->ContainerSlots; + for(int i = 0; i < 10; i++) + { + recvPacket >> proto->ItemStat[i].ItemStatType; + recvPacket >> proto->ItemStat[i].ItemStatValue; + } + for(int i = 0; i < 5; i++) + { + recvPacket >> proto->Damage[i].DamageMin; + recvPacket >> proto->Damage[i].DamageMax; + recvPacket >> proto->Damage[i].DamageType; + } + recvPacket >> proto->Armor; + recvPacket >> proto->HolyRes; + recvPacket >> proto->FireRes; + recvPacket >> proto->NatureRes; + recvPacket >> proto->FrostRes; + recvPacket >> proto->ShadowRes; + recvPacket >> proto->ArcaneRes; + recvPacket >> proto->Delay; + recvPacket >> proto->Ammo_type; + + recvPacket >> proto->RangedModRange; + for(int s = 0; s < 5; s++) + { + recvPacket >> proto->Spells[s].SpellId; + recvPacket >> proto->Spells[s].SpellTrigger; + recvPacket >> proto->Spells[s].SpellCharges; + recvPacket >> proto->Spells[s].SpellCooldown; + recvPacket >> proto->Spells[s].SpellCategory; + recvPacket >> proto->Spells[s].SpellCategoryCooldown; + } + recvPacket >> proto->Bonding; + recvPacket >> proto->Description; + recvPacket >> proto->PageText; + recvPacket >> proto->LanguageID; + recvPacket >> proto->PageMaterial; + recvPacket >> proto->StartQuest; + recvPacket >> proto->LockID; + recvPacket >> proto->Material; + recvPacket >> proto->Sheath; + recvPacket >> proto->Extra; + recvPacket >> proto->Block; + recvPacket >> proto->ItemSet; + recvPacket >> proto->MaxDurability; + recvPacket >> proto->Area; + recvPacket >> proto->Map; + recvPacket >> proto->BagFamily; + recvPacket >> proto->TotemCategory; // Added in 1.12.x client branch + for(uint32 s = 0; s < 3; s++) + { + recvPacket >> proto->Socket[s].Color; + recvPacket >> proto->Socket[s].Content; + } + recvPacket >> proto->socketBonus; + recvPacket >> proto->GemProperties; + recvPacket >> proto->ExtendedCost; + recvPacket >> proto->RequiredDisenchantSkill; + recvPacket >> proto->ArmorDamageModifier; + + logdetail("Got Item Info: Id=%u Name='%s' ReqLevel=%u Armor=%u Desc='%s'", + proto->Id, proto->Name.c_str(), proto->RequiredLevel, proto->Armor, proto->Description.c_str()); + objmgr.Add(proto); + objmgr.AssignNameToObj(proto->Id, TYPEID_ITEM, proto->Name); + objmgr.AssignNameToObj(proto->Id, TYPEID_CONTAINER, proto->Name); + } + else + { + logdetail("Got info of nonexistent Item %u",proto->Id); + objmgr.AddNonexistentItem(proto->Id); + delete proto; + } +} + +Item::Item() +{ + _type |= TYPE_ITEM; + _typeid = TYPEID_ITEM; + + _valuescount = ITEM_END; + _slot = 0; + //_bag = NULL; // not yet implemented +} + +void Item::Create(uint64 guid) +{ + Object::Create(guid); + // what else? +} diff --git a/src/Client/World/Item.h b/src/Client/World/Item.h index 71a6bcf..d3ab916 100644 --- a/src/Client/World/Item.h +++ b/src/Client/World/Item.h @@ -1,440 +1,440 @@ -#ifndef _ITEM_H -#define _ITEM_H - -#include "common.h" -#include "Object.h" - -class Bag; - -enum InventoryChangeFailure -{ - EQUIP_ERR_OK = 0, - EQUIP_ERR_YOU_MUST_REACH_LEVEL_N = 1, - EQUIP_ERR_SKILL_ISNT_HIGH_ENOUGH = 2, - EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT = 3, - EQUIP_ERR_BAG_FULL = 4, - EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG = 5, - EQUIP_ERR_CANT_TRADE_EQUIP_BAGS = 6, - EQUIP_ERR_ONLY_AMMO_CAN_GO_HERE = 7, - EQUIP_ERR_NO_REQUIRED_PROFICIENCY = 8, - EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE = 9, - EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM = 10, - EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM2 = 11, - EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE2 = 12, - EQUIP_ERR_CANT_EQUIP_WITH_TWOHANDED = 13, - EQUIP_ERR_CANT_DUAL_WIELD = 14, - EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG = 15, - EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG2 = 16, - EQUIP_ERR_CANT_CARRY_MORE_OF_THIS = 17, - EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE3 = 18, - EQUIP_ERR_ITEM_CANT_STACK = 19, - EQUIP_ERR_ITEM_CANT_BE_EQUIPPED = 20, - EQUIP_ERR_ITEMS_CANT_BE_SWAPPED = 21, - EQUIP_ERR_SLOT_IS_EMPTY = 22, - EQUIP_ERR_ITEM_NOT_FOUND = 23, - EQUIP_ERR_CANT_DROP_SOULBOUND = 24, - EQUIP_ERR_OUT_OF_RANGE = 25, - EQUIP_ERR_TRIED_TO_SPLIT_MORE_THAN_COUNT = 26, - EQUIP_ERR_COULDNT_SPLIT_ITEMS = 27, - EQUIP_ERR_MISSING_REAGENT = 28, - EQUIP_ERR_NOT_ENOUGH_MONEY = 29, - EQUIP_ERR_NOT_A_BAG = 30, - EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS = 31, - EQUIP_ERR_DONT_OWN_THAT_ITEM = 32, - EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER = 33, - EQUIP_ERR_MUST_PURCHASE_THAT_BAG_SLOT = 34, - EQUIP_ERR_TOO_FAR_AWAY_FROM_BANK = 35, - EQUIP_ERR_ITEM_LOCKED = 36, - EQUIP_ERR_YOU_ARE_STUNNED = 37, - EQUIP_ERR_YOU_ARE_DEAD = 38, - EQUIP_ERR_CANT_DO_RIGHT_NOW = 39, - EQUIP_ERR_BAG_FULL2 = 40, - EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER2 = 41, - EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH = 42, - EQUIP_ERR_STACKABLE_CANT_BE_WRAPPED = 43, - EQUIP_ERR_EQUIPPED_CANT_BE_WRAPPED = 44, - EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED = 45, - EQUIP_ERR_BOUND_CANT_BE_WRAPPED = 46, - EQUIP_ERR_UNIQUE_CANT_BE_WRAPPED = 47, - EQUIP_ERR_BAGS_CANT_BE_WRAPPED = 48, - EQUIP_ERR_ALREADY_LOOTED = 49, - EQUIP_ERR_INVENTORY_FULL = 50, - EQUIP_ERR_BANK_FULL = 51, - EQUIP_ERR_ITEM_IS_CURRENTLY_SOLD_OUT = 52, - EQUIP_ERR_BAG_FULL3 = 53, - EQUIP_ERR_ITEM_NOT_FOUND2 = 54, - EQUIP_ERR_ITEM_CANT_STACK2 = 55, - EQUIP_ERR_BAG_FULL4 = 56, - EQUIP_ERR_ITEM_SOLD_OUT = 57, - EQUIP_ERR_OBJECT_IS_BUSY = 58, - EQUIP_ERR_NONE = 59, - EQUIP_ERR_CANT_DO_IN_COMBAT = 60, - EQUIP_CANT_DO_WHILE_DISARMED = 61, - EQUIP_ERR_BAG_FULL6 = 62, - EQUIP_ITEM_RANK_NOT_ENOUGH = 63, - EQUIP_ITEM_REPUTATION_NOT_ENOUGH = 64, - EQUIP_MORE_THAN1_SPECIAL_BAG = 65 -}; - -enum BuyFailure -{ - BUY_ERR_CANT_FIND_ITEM = 0, - BUY_ERR_ITEM_ALREADY_SOLD = 1, - BUY_ERR_NOT_ENOUGHT_MONEY = 2, - BUY_ERR_SELLER_DONT_LIKE_YOU = 4, - BUY_ERR_DISTANCE_TOO_FAR = 5, - BUY_ERR_CANT_CARRY_MORE = 8, - BUY_ERR_LEVEL_REQUIRE = 11, - BUY_ERR_REPUTATION_REQUIRE = 12 -}; - -enum SellFailure -{ - SELL_ERR_CANT_FIND_ITEM = 1, - SELL_ERR_CANT_SELL_ITEM = 2, - SELL_ERR_CANT_FIND_VENDOR = 3 -}; - -enum ITEM_STAT_TYPE -{ - ITEM_STAT_POWER = 0, - ITEM_STAT_HEALTH = 1, - ITEM_STAT_UNKNOWN = 2, - ITEM_STAT_AGILITY = 3, - ITEM_STAT_STRENGTH = 4, - ITEM_STAT_INTELLECT = 5, - ITEM_STAT_SPIRIT = 6, - ITEM_STAT_STAMINA = 7 -}; - -enum ITEM_DAMAGE_TYPE -{ - NORMAL_DAMAGE = 0, - HOLY_DAMAGE = 1, - FIRE_DAMAGE = 2, - NATURE_DAMAGE = 3, - FROST_DAMAGE = 4, - SHADOW_DAMAGE = 5, - ARCANE_DAMAGE = 6 -}; - -enum ITEM_SPELLTRIGGER_TYPE -{ - USE = 0, - ON_EQUIP = 1, - CHANCE_ON_HIT = 2, - SOULSTONE = 4 -}; - -enum ITEM_BONDING_TYPE -{ - NO_BIND = 0, - BIND_WHEN_PICKED_UP = 1, - BIND_WHEN_EQUIPED = 2, - BIND_WHEN_USE = 3, - //TODO: Better name these - QUEST_ITEM = 4, - QUEST_ITEM1 = 5 -}; - -// masks for ITEM_FIELD_FLAGS field -enum ITEM_FLAGS -{ - ITEM_FLAGS_BINDED = 1 -}; - -enum BAG_FAMILY -{ - BAG_FAMILY_NONE = 0, - BAG_FAMILY_ARROWS = 1, - BAG_FAMILY_BULLETS = 2, - BAG_FAMILY_SOUL_SHARDS = 3, - //BAG_FAMILY_UNK1 = 4, - //BAG_FAMILY_UNK1 = 5, - BAG_FAMILY_HERBS = 6, - BAG_FAMILY_ENCHANTING_SUPP = 7, - BAG_FAMILY_ENGINEERING_SUPP = 8, - BAG_FAMILY_KEYS = 9, - BAG_FAMILY_GEMS = 10, - //BAG_FAMILY_UNK3 = 11, - BAG_FAMILY_MINING_SUPP = 12 -}; - -enum INVENTORY_TYPES -{ - INVTYPE_NON_EQUIP = 0, - INVTYPE_HEAD = 1, - INVTYPE_NECK = 2, - INVTYPE_SHOULDERS = 3, - INVTYPE_BODY = 4, - INVTYPE_CHEST = 5, - INVTYPE_WAIST = 6, - INVTYPE_LEGS = 7, - INVTYPE_FEET = 8, - INVTYPE_WRISTS = 9, - INVTYPE_HANDS = 10, - INVTYPE_FINGER = 11, - INVTYPE_TRINKET = 12, - INVTYPE_WEAPON = 13, - INVTYPE_SHIELD = 14, - INVTYPE_RANGED = 15, - INVTYPE_CLOAK = 16, - INVTYPE_2HWEAPON = 17, - INVTYPE_BAG = 18, - INVTYPE_TABARD = 19, - INVTYPE_ROBE = 20, - INVTYPE_WEAPONMAINHAND = 21, - INVTYPE_WEAPONOFFHAND = 22, - INVTYPE_HOLDABLE = 23, - INVTYPE_AMMO = 24, - INVTYPE_THROWN = 25, - INVTYPE_RANGEDRIGHT = 26, - INVTYPE_SLOT_ITEM = 27, - INVTYPE_RELIC = 28, - NUM_INVENTORY_TYPES = 29 -}; - -enum INVENTORY_CLASS -{ - ITEM_CLASS_CONSUMABLE = 0, - ITEM_CLASS_CONTAINER = 1, - ITEM_CLASS_WEAPON = 2, - ITEM_CLASS_JEWELRY = 3, - ITEM_CLASS_ARMOR = 4, - ITEM_CLASS_REAGENT = 5, - ITEM_CLASS_PROJECTILE = 6, - ITEM_CLASS_TRADE_GOODS = 7, - ITEM_CLASS_GENERIC = 8, - ITEM_CLASS_BOOK = 9, - ITEM_CLASS_MONEY = 10, - ITEM_CLASS_QUIVER = 11, - ITEM_CLASS_QUEST = 12, - ITEM_CLASS_KEY = 13, - ITEM_CLASS_PERMANENT = 14, - ITEM_CLASS_JUNK = 15 -}; - -// Client understand only 0 subclass for ITEM_CLASS_CONSUMABLE -// but this value used in code as implementation workaround -enum ITEM_SUBCLASS_CONSUMABLE -{ - ITEM_SUBCLASS_POTION = 1, - ITEM_SUBCLASS_ELIXIR = 2, - ITEM_SUBCLASS_FLASK = 3, - ITEM_SUBCLASS_SCROLL = 4, - ITEM_SUBCLASS_FOOD = 5, - ITEM_SUBCLASS_ITEM_ENHANCEMENT = 6, - ITEM_SUBCLASS_BANDAGE = 7 -}; - -enum ITEM_SUBCLASS_CONTAINER -{ - ITEM_SUBCLASS_CONTAINER = 0, - ITEM_SUBCLASS_SOUL_CONTAINER = 1, - ITEM_SUBCLASS_HERB_CONTAINER = 2, - ITEM_SUBCLASS_ENCHANTING_CONTAINER = 3, - ITEM_SUBCLASS_ENGINEERING_CONTAINER = 4, - ITEM_SUBCLASS_GEM_CONTAINER = 5, - ITEM_SUBCLASS_MINING_CONTAINER = 6, - ITEM_SUBCLASS_LEATHERWORKING_CONTAINER = 7 -}; - -enum INVENTORY_SUBCLASS_WEAPON -{ - ITEM_SUBCLASS_WEAPON_AXE = 0, - ITEM_SUBCLASS_WEAPON_AXE2 = 1, - ITEM_SUBCLASS_WEAPON_BOW = 2, - ITEM_SUBCLASS_WEAPON_GUN = 3, - ITEM_SUBCLASS_WEAPON_MACE = 4, - ITEM_SUBCLASS_WEAPON_MACE2 = 5, - ITEM_SUBCLASS_WEAPON_POLEARM = 6, - ITEM_SUBCLASS_WEAPON_SWORD = 7, - ITEM_SUBCLASS_WEAPON_SWORD2 = 8, - ITEM_SUBCLASS_WEAPON_obsolete = 9, - ITEM_SUBCLASS_WEAPON_STAFF = 10, - ITEM_SUBCLASS_WEAPON_EXOTIC = 11, - ITEM_SUBCLASS_WEAPON_EXOTIC2 = 12, - ITEM_SUBCLASS_WEAPON_UNARMED = 13, - ITEM_SUBCLASS_WEAPON_GENERIC = 14, - ITEM_SUBCLASS_WEAPON_DAGGER = 15, - ITEM_SUBCLASS_WEAPON_THROWN = 16, - ITEM_SUBCLASS_WEAPON_SPEAR = 17, - ITEM_SUBCLASS_WEAPON_CROSSBOW = 18, - ITEM_SUBCLASS_WEAPON_WAND = 19, - ITEM_SUBCLASS_WEAPON_FISHING_POLE = 20 -}; - -enum ITEM_SUBCLASS_ARMOR -{ - ITEM_SUBCLASS_ARMOR_GENERIC = 0, - ITEM_SUBCLASS_ARMOR_CLOTH = 1, - ITEM_SUBCLASS_ARMOR_LEATHER = 2, - ITEM_SUBCLASS_ARMOR_MAIL = 3, - ITEM_SUBCLASS_ARMOR_PLATE = 4, - ITEM_SUBCLASS_ARMOR_BUCKLER = 5, - ITEM_SUBCLASS_ARMOR_SHIELD = 6 -}; - -enum ITEM_SUBCLASS_PROJECTILE -{ - ITEM_SUBCLASS_ARROW = 2, - ITEM_SUBCLASS_BULLET = 3 -}; - -enum ITEM_SUBCLASS_TRADE_GOODS -{ - ITEM_SUBCLASS_TRADE_GOODS = 0, - ITEM_SUBCLASS_PARTS = 1, - ITEM_SUBCLASS_EXPLOSIVES = 2, - ITEM_SUBCLASS_DEVICES = 3, - ITEM_SUBCLASS_JEWELCRAFTING = 4, - ITEM_SUBCLASS_CLOTH = 5, - ITEM_SUBCLASS_LEATHER = 6, - ITEM_SUBCLASS_METAL_STONE = 7, - ITEM_SUBCLASS_MEAT = 8, - ITEM_SUBCLASS_HERB = 9, - ITEM_SUBCLASS_ELEMENTAZL = 10, - ITEM_SUBCLASS_TRADE_GOODS_OTHER = 11, - ITEM_SUBCLASS_ENCHANTING = 12 -}; - -enum ITEM_SUBCLASS_BOOK -{ - ITEM_SUBCLASS_BOOK = 0, - ITEM_SUBCLASS_LEATHERWORKING_PATTERN = 1, - ITEM_SUBCLASS_TAILORING_PATTERN = 2, - ITEM_SUBCLASS_ENGINEERING_SCHEMATIC = 3, - ITEM_SUBCLASS_COOKING_RECIPE = 5, - ITEM_SUBCLASS_ALCHEMY_RECIPE = 6, - ITEM_SUBCLASS_FIRST_AID_MANUAL = 7, - ITEM_SUBCLASS_ENCHANTING_FORMULA = 8, - ITEM_SUBCLASS_FISHING_MANUAL = 9 -}; - -enum ITEM_SUBCLASS_QUIVER -{ - ITEM_SUBCLASS_QUIVER = 2, - ITEM_SUBCLASS_AMMO_POUCH = 3 -}; - -struct _ItemStat -{ - uint32 ItemStatType; - uint32 ItemStatValue; - -}; - -struct _ItemSpell -{ - uint32 SpellId; - uint32 SpellTrigger; - uint32 SpellCharges; - uint32 SpellCooldown; - uint32 SpellCategory; - uint32 SpellCategoryCooldown; - -}; - -struct _ItemSocket -{ - uint32 Color; - uint32 Content; -}; - -struct _ItemDamage -{ - float DamageMin; - float DamageMax; - uint32 DamageType; - -}; - -struct ItemProto -{ - uint32 Id; - uint32 Class; - uint32 SubClass; - std::string Name; - uint32 DisplayInfoID; - uint32 Quality; - uint32 Flags; - uint32 BuyCount; - uint32 BuyPrice; - uint32 SellPrice; - uint32 InventoryType; - uint32 AllowableClass; - uint32 AllowableRace; - uint32 ItemLevel; - uint32 RequiredLevel; - uint32 RequiredSkill; - uint32 RequiredSkillRank; - uint32 RequiredSpell; - uint32 RequiredHonorRank; - uint32 RequiredCityRank; - uint32 RequiredReputationFaction; - uint32 RequiredReputationRank; - uint32 MaxCount; - uint32 Stackable; - uint32 ContainerSlots; - _ItemStat ItemStat[10]; - _ItemDamage Damage[5]; - uint32 Armor; - uint32 HolyRes; - uint32 FireRes; - uint32 NatureRes; - uint32 FrostRes; - uint32 ShadowRes; - uint32 ArcaneRes; - uint32 Delay; - uint32 Ammo_type; - float RangedModRange; - _ItemSpell Spells[5]; - uint32 Bonding; - std::string Description; - uint32 PageText; - uint32 LanguageID; - uint32 PageMaterial; - uint32 StartQuest; - uint32 LockID; - uint32 Material; - uint32 Sheath; - uint32 Extra; - uint32 Unk1; - uint32 Block; - uint32 ItemSet; - uint32 MaxDurability; - uint32 Area; - uint32 Map; - uint32 BagFamily; - uint32 TotemCategory; - _ItemSocket Socket[3]; - uint32 socketBonus; - uint32 GemProperties; - uint32 ExtendedCost; - uint32 RequiredArenaRank; - uint32 RequiredDisenchantSkill; - float ArmorDamageModifier; -}; - -class Item : public Object -{ -public: - Item(); - void Create(uint64); - uint8 GetSlot(void) { return _slot; } - void SetSlot(uint8 nr) { _slot = nr; } - uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); } - uint32 GetCount() const { return GetUInt32Value(ITEM_FIELD_STACK_COUNT); } - Bag *GetBag(void) { return _bag; } - bool IsInBag() const { return _bag != NULL; } - -protected: - uint8 _slot; - Bag *_bag; - -}; - - - - -#endif +#ifndef _ITEM_H +#define _ITEM_H + +#include "common.h" +#include "Object.h" + +class Bag; + +enum InventoryChangeFailure +{ + EQUIP_ERR_OK = 0, + EQUIP_ERR_YOU_MUST_REACH_LEVEL_N = 1, + EQUIP_ERR_SKILL_ISNT_HIGH_ENOUGH = 2, + EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT = 3, + EQUIP_ERR_BAG_FULL = 4, + EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG = 5, + EQUIP_ERR_CANT_TRADE_EQUIP_BAGS = 6, + EQUIP_ERR_ONLY_AMMO_CAN_GO_HERE = 7, + EQUIP_ERR_NO_REQUIRED_PROFICIENCY = 8, + EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE = 9, + EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM = 10, + EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM2 = 11, + EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE2 = 12, + EQUIP_ERR_CANT_EQUIP_WITH_TWOHANDED = 13, + EQUIP_ERR_CANT_DUAL_WIELD = 14, + EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG = 15, + EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG2 = 16, + EQUIP_ERR_CANT_CARRY_MORE_OF_THIS = 17, + EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE3 = 18, + EQUIP_ERR_ITEM_CANT_STACK = 19, + EQUIP_ERR_ITEM_CANT_BE_EQUIPPED = 20, + EQUIP_ERR_ITEMS_CANT_BE_SWAPPED = 21, + EQUIP_ERR_SLOT_IS_EMPTY = 22, + EQUIP_ERR_ITEM_NOT_FOUND = 23, + EQUIP_ERR_CANT_DROP_SOULBOUND = 24, + EQUIP_ERR_OUT_OF_RANGE = 25, + EQUIP_ERR_TRIED_TO_SPLIT_MORE_THAN_COUNT = 26, + EQUIP_ERR_COULDNT_SPLIT_ITEMS = 27, + EQUIP_ERR_MISSING_REAGENT = 28, + EQUIP_ERR_NOT_ENOUGH_MONEY = 29, + EQUIP_ERR_NOT_A_BAG = 30, + EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS = 31, + EQUIP_ERR_DONT_OWN_THAT_ITEM = 32, + EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER = 33, + EQUIP_ERR_MUST_PURCHASE_THAT_BAG_SLOT = 34, + EQUIP_ERR_TOO_FAR_AWAY_FROM_BANK = 35, + EQUIP_ERR_ITEM_LOCKED = 36, + EQUIP_ERR_YOU_ARE_STUNNED = 37, + EQUIP_ERR_YOU_ARE_DEAD = 38, + EQUIP_ERR_CANT_DO_RIGHT_NOW = 39, + EQUIP_ERR_BAG_FULL2 = 40, + EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER2 = 41, + EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH = 42, + EQUIP_ERR_STACKABLE_CANT_BE_WRAPPED = 43, + EQUIP_ERR_EQUIPPED_CANT_BE_WRAPPED = 44, + EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED = 45, + EQUIP_ERR_BOUND_CANT_BE_WRAPPED = 46, + EQUIP_ERR_UNIQUE_CANT_BE_WRAPPED = 47, + EQUIP_ERR_BAGS_CANT_BE_WRAPPED = 48, + EQUIP_ERR_ALREADY_LOOTED = 49, + EQUIP_ERR_INVENTORY_FULL = 50, + EQUIP_ERR_BANK_FULL = 51, + EQUIP_ERR_ITEM_IS_CURRENTLY_SOLD_OUT = 52, + EQUIP_ERR_BAG_FULL3 = 53, + EQUIP_ERR_ITEM_NOT_FOUND2 = 54, + EQUIP_ERR_ITEM_CANT_STACK2 = 55, + EQUIP_ERR_BAG_FULL4 = 56, + EQUIP_ERR_ITEM_SOLD_OUT = 57, + EQUIP_ERR_OBJECT_IS_BUSY = 58, + EQUIP_ERR_NONE = 59, + EQUIP_ERR_CANT_DO_IN_COMBAT = 60, + EQUIP_CANT_DO_WHILE_DISARMED = 61, + EQUIP_ERR_BAG_FULL6 = 62, + EQUIP_ITEM_RANK_NOT_ENOUGH = 63, + EQUIP_ITEM_REPUTATION_NOT_ENOUGH = 64, + EQUIP_MORE_THAN1_SPECIAL_BAG = 65 +}; + +enum BuyFailure +{ + BUY_ERR_CANT_FIND_ITEM = 0, + BUY_ERR_ITEM_ALREADY_SOLD = 1, + BUY_ERR_NOT_ENOUGHT_MONEY = 2, + BUY_ERR_SELLER_DONT_LIKE_YOU = 4, + BUY_ERR_DISTANCE_TOO_FAR = 5, + BUY_ERR_CANT_CARRY_MORE = 8, + BUY_ERR_LEVEL_REQUIRE = 11, + BUY_ERR_REPUTATION_REQUIRE = 12 +}; + +enum SellFailure +{ + SELL_ERR_CANT_FIND_ITEM = 1, + SELL_ERR_CANT_SELL_ITEM = 2, + SELL_ERR_CANT_FIND_VENDOR = 3 +}; + +enum ITEM_STAT_TYPE +{ + ITEM_STAT_POWER = 0, + ITEM_STAT_HEALTH = 1, + ITEM_STAT_UNKNOWN = 2, + ITEM_STAT_AGILITY = 3, + ITEM_STAT_STRENGTH = 4, + ITEM_STAT_INTELLECT = 5, + ITEM_STAT_SPIRIT = 6, + ITEM_STAT_STAMINA = 7 +}; + +enum ITEM_DAMAGE_TYPE +{ + NORMAL_DAMAGE = 0, + HOLY_DAMAGE = 1, + FIRE_DAMAGE = 2, + NATURE_DAMAGE = 3, + FROST_DAMAGE = 4, + SHADOW_DAMAGE = 5, + ARCANE_DAMAGE = 6 +}; + +enum ITEM_SPELLTRIGGER_TYPE +{ + USE = 0, + ON_EQUIP = 1, + CHANCE_ON_HIT = 2, + SOULSTONE = 4 +}; + +enum ITEM_BONDING_TYPE +{ + NO_BIND = 0, + BIND_WHEN_PICKED_UP = 1, + BIND_WHEN_EQUIPED = 2, + BIND_WHEN_USE = 3, + //TODO: Better name these + QUEST_ITEM = 4, + QUEST_ITEM1 = 5 +}; + +// masks for ITEM_FIELD_FLAGS field +enum ITEM_FLAGS +{ + ITEM_FLAGS_BINDED = 1 +}; + +enum BAG_FAMILY +{ + BAG_FAMILY_NONE = 0, + BAG_FAMILY_ARROWS = 1, + BAG_FAMILY_BULLETS = 2, + BAG_FAMILY_SOUL_SHARDS = 3, + //BAG_FAMILY_UNK1 = 4, + //BAG_FAMILY_UNK1 = 5, + BAG_FAMILY_HERBS = 6, + BAG_FAMILY_ENCHANTING_SUPP = 7, + BAG_FAMILY_ENGINEERING_SUPP = 8, + BAG_FAMILY_KEYS = 9, + BAG_FAMILY_GEMS = 10, + //BAG_FAMILY_UNK3 = 11, + BAG_FAMILY_MINING_SUPP = 12 +}; + +enum INVENTORY_TYPES +{ + INVTYPE_NON_EQUIP = 0, + INVTYPE_HEAD = 1, + INVTYPE_NECK = 2, + INVTYPE_SHOULDERS = 3, + INVTYPE_BODY = 4, + INVTYPE_CHEST = 5, + INVTYPE_WAIST = 6, + INVTYPE_LEGS = 7, + INVTYPE_FEET = 8, + INVTYPE_WRISTS = 9, + INVTYPE_HANDS = 10, + INVTYPE_FINGER = 11, + INVTYPE_TRINKET = 12, + INVTYPE_WEAPON = 13, + INVTYPE_SHIELD = 14, + INVTYPE_RANGED = 15, + INVTYPE_CLOAK = 16, + INVTYPE_2HWEAPON = 17, + INVTYPE_BAG = 18, + INVTYPE_TABARD = 19, + INVTYPE_ROBE = 20, + INVTYPE_WEAPONMAINHAND = 21, + INVTYPE_WEAPONOFFHAND = 22, + INVTYPE_HOLDABLE = 23, + INVTYPE_AMMO = 24, + INVTYPE_THROWN = 25, + INVTYPE_RANGEDRIGHT = 26, + INVTYPE_SLOT_ITEM = 27, + INVTYPE_RELIC = 28, + NUM_INVENTORY_TYPES = 29 +}; + +enum INVENTORY_CLASS +{ + ITEM_CLASS_CONSUMABLE = 0, + ITEM_CLASS_CONTAINER = 1, + ITEM_CLASS_WEAPON = 2, + ITEM_CLASS_JEWELRY = 3, + ITEM_CLASS_ARMOR = 4, + ITEM_CLASS_REAGENT = 5, + ITEM_CLASS_PROJECTILE = 6, + ITEM_CLASS_TRADE_GOODS = 7, + ITEM_CLASS_GENERIC = 8, + ITEM_CLASS_BOOK = 9, + ITEM_CLASS_MONEY = 10, + ITEM_CLASS_QUIVER = 11, + ITEM_CLASS_QUEST = 12, + ITEM_CLASS_KEY = 13, + ITEM_CLASS_PERMANENT = 14, + ITEM_CLASS_JUNK = 15 +}; + +// Client understand only 0 subclass for ITEM_CLASS_CONSUMABLE +// but this value used in code as implementation workaround +enum ITEM_SUBCLASS_CONSUMABLE +{ + ITEM_SUBCLASS_POTION = 1, + ITEM_SUBCLASS_ELIXIR = 2, + ITEM_SUBCLASS_FLASK = 3, + ITEM_SUBCLASS_SCROLL = 4, + ITEM_SUBCLASS_FOOD = 5, + ITEM_SUBCLASS_ITEM_ENHANCEMENT = 6, + ITEM_SUBCLASS_BANDAGE = 7 +}; + +enum ITEM_SUBCLASS_CONTAINER +{ + ITEM_SUBCLASS_CONTAINER = 0, + ITEM_SUBCLASS_SOUL_CONTAINER = 1, + ITEM_SUBCLASS_HERB_CONTAINER = 2, + ITEM_SUBCLASS_ENCHANTING_CONTAINER = 3, + ITEM_SUBCLASS_ENGINEERING_CONTAINER = 4, + ITEM_SUBCLASS_GEM_CONTAINER = 5, + ITEM_SUBCLASS_MINING_CONTAINER = 6, + ITEM_SUBCLASS_LEATHERWORKING_CONTAINER = 7 +}; + +enum INVENTORY_SUBCLASS_WEAPON +{ + ITEM_SUBCLASS_WEAPON_AXE = 0, + ITEM_SUBCLASS_WEAPON_AXE2 = 1, + ITEM_SUBCLASS_WEAPON_BOW = 2, + ITEM_SUBCLASS_WEAPON_GUN = 3, + ITEM_SUBCLASS_WEAPON_MACE = 4, + ITEM_SUBCLASS_WEAPON_MACE2 = 5, + ITEM_SUBCLASS_WEAPON_POLEARM = 6, + ITEM_SUBCLASS_WEAPON_SWORD = 7, + ITEM_SUBCLASS_WEAPON_SWORD2 = 8, + ITEM_SUBCLASS_WEAPON_obsolete = 9, + ITEM_SUBCLASS_WEAPON_STAFF = 10, + ITEM_SUBCLASS_WEAPON_EXOTIC = 11, + ITEM_SUBCLASS_WEAPON_EXOTIC2 = 12, + ITEM_SUBCLASS_WEAPON_UNARMED = 13, + ITEM_SUBCLASS_WEAPON_GENERIC = 14, + ITEM_SUBCLASS_WEAPON_DAGGER = 15, + ITEM_SUBCLASS_WEAPON_THROWN = 16, + ITEM_SUBCLASS_WEAPON_SPEAR = 17, + ITEM_SUBCLASS_WEAPON_CROSSBOW = 18, + ITEM_SUBCLASS_WEAPON_WAND = 19, + ITEM_SUBCLASS_WEAPON_FISHING_POLE = 20 +}; + +enum ITEM_SUBCLASS_ARMOR +{ + ITEM_SUBCLASS_ARMOR_GENERIC = 0, + ITEM_SUBCLASS_ARMOR_CLOTH = 1, + ITEM_SUBCLASS_ARMOR_LEATHER = 2, + ITEM_SUBCLASS_ARMOR_MAIL = 3, + ITEM_SUBCLASS_ARMOR_PLATE = 4, + ITEM_SUBCLASS_ARMOR_BUCKLER = 5, + ITEM_SUBCLASS_ARMOR_SHIELD = 6 +}; + +enum ITEM_SUBCLASS_PROJECTILE +{ + ITEM_SUBCLASS_ARROW = 2, + ITEM_SUBCLASS_BULLET = 3 +}; + +enum ITEM_SUBCLASS_TRADE_GOODS +{ + ITEM_SUBCLASS_TRADE_GOODS = 0, + ITEM_SUBCLASS_PARTS = 1, + ITEM_SUBCLASS_EXPLOSIVES = 2, + ITEM_SUBCLASS_DEVICES = 3, + ITEM_SUBCLASS_JEWELCRAFTING = 4, + ITEM_SUBCLASS_CLOTH = 5, + ITEM_SUBCLASS_LEATHER = 6, + ITEM_SUBCLASS_METAL_STONE = 7, + ITEM_SUBCLASS_MEAT = 8, + ITEM_SUBCLASS_HERB = 9, + ITEM_SUBCLASS_ELEMENTAZL = 10, + ITEM_SUBCLASS_TRADE_GOODS_OTHER = 11, + ITEM_SUBCLASS_ENCHANTING = 12 +}; + +enum ITEM_SUBCLASS_BOOK +{ + ITEM_SUBCLASS_BOOK = 0, + ITEM_SUBCLASS_LEATHERWORKING_PATTERN = 1, + ITEM_SUBCLASS_TAILORING_PATTERN = 2, + ITEM_SUBCLASS_ENGINEERING_SCHEMATIC = 3, + ITEM_SUBCLASS_COOKING_RECIPE = 5, + ITEM_SUBCLASS_ALCHEMY_RECIPE = 6, + ITEM_SUBCLASS_FIRST_AID_MANUAL = 7, + ITEM_SUBCLASS_ENCHANTING_FORMULA = 8, + ITEM_SUBCLASS_FISHING_MANUAL = 9 +}; + +enum ITEM_SUBCLASS_QUIVER +{ + ITEM_SUBCLASS_QUIVER = 2, + ITEM_SUBCLASS_AMMO_POUCH = 3 +}; + +struct _ItemStat +{ + uint32 ItemStatType; + uint32 ItemStatValue; + +}; + +struct _ItemSpell +{ + uint32 SpellId; + uint32 SpellTrigger; + uint32 SpellCharges; + uint32 SpellCooldown; + uint32 SpellCategory; + uint32 SpellCategoryCooldown; + +}; + +struct _ItemSocket +{ + uint32 Color; + uint32 Content; +}; + +struct _ItemDamage +{ + float DamageMin; + float DamageMax; + uint32 DamageType; + +}; + +struct ItemProto +{ + uint32 Id; + uint32 Class; + uint32 SubClass; + std::string Name; + uint32 DisplayInfoID; + uint32 Quality; + uint32 Flags; + uint32 BuyCount; + uint32 BuyPrice; + uint32 SellPrice; + uint32 InventoryType; + uint32 AllowableClass; + uint32 AllowableRace; + uint32 ItemLevel; + uint32 RequiredLevel; + uint32 RequiredSkill; + uint32 RequiredSkillRank; + uint32 RequiredSpell; + uint32 RequiredHonorRank; + uint32 RequiredCityRank; + uint32 RequiredReputationFaction; + uint32 RequiredReputationRank; + uint32 MaxCount; + uint32 Stackable; + uint32 ContainerSlots; + _ItemStat ItemStat[10]; + _ItemDamage Damage[5]; + uint32 Armor; + uint32 HolyRes; + uint32 FireRes; + uint32 NatureRes; + uint32 FrostRes; + uint32 ShadowRes; + uint32 ArcaneRes; + uint32 Delay; + uint32 Ammo_type; + float RangedModRange; + _ItemSpell Spells[5]; + uint32 Bonding; + std::string Description; + uint32 PageText; + uint32 LanguageID; + uint32 PageMaterial; + uint32 StartQuest; + uint32 LockID; + uint32 Material; + uint32 Sheath; + uint32 Extra; + uint32 Unk1; + uint32 Block; + uint32 ItemSet; + uint32 MaxDurability; + uint32 Area; + uint32 Map; + uint32 BagFamily; + uint32 TotemCategory; + _ItemSocket Socket[3]; + uint32 socketBonus; + uint32 GemProperties; + uint32 ExtendedCost; + uint32 RequiredArenaRank; + uint32 RequiredDisenchantSkill; + float ArmorDamageModifier; +}; + +class Item : public Object +{ +public: + Item(); + void Create(uint64); + uint8 GetSlot(void) { return _slot; } + void SetSlot(uint8 nr) { _slot = nr; } + uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); } + uint32 GetCount() const { return GetUInt32Value(ITEM_FIELD_STACK_COUNT); } + Bag *GetBag(void) { return _bag; } + bool IsInBag() const { return _bag != NULL; } + +protected: + uint8 _slot; + Bag *_bag; + +}; + + + + +#endif diff --git a/src/Client/World/MapMgr.cpp b/src/Client/World/MapMgr.cpp index a6757b1..226c6f9 100644 --- a/src/Client/World/MapMgr.cpp +++ b/src/Client/World/MapMgr.cpp @@ -1,181 +1,181 @@ -#include "common.h" -#include "log.h" -#include "MapTile.h" -#include "MapMgr.h" - -MapMgr::MapMgr() -{ - DEBUG(logdebug("Creating MapMgr with TILESIZE=%.3f CHUNKSIZE=%.3f UNITSIZE=%.3f",TILESIZE,CHUNKSIZE,UNITSIZE)); - _tiles = new MapTileStorage(); - _gridx = _gridy = _mapid = (-1); - _mapsLoaded = false; -} - -MapMgr::~MapMgr() -{ - Flush(); - delete _tiles; -} - -void MapMgr::Update(float x, float y, uint32 m) -{ - if(m != _mapid) - { - Flush(); // we teleported to a new map, drop all loaded maps - WDTFile *wdt = new WDTFile(); - char buf[100]; - sprintf(buf,"data/maps/%u.wdt",m); - if(!wdt->Load(buf)) - { - logerror("MAPMGR: Could not load WDT file '%s'",buf); - } - _tiles->ImportTileMap(wdt); - delete wdt; - _mapid = m; - _gridx = _gridy = (-1); // must load tiles now - } - GridCoordPair gcoords = GetTransformGridCoordPair(x,y); - if(gcoords.x != _gridx || gcoords.y != _gridy) - { - _gridx = gcoords.x; - _gridy = gcoords.y; - _LoadNearTiles(_gridx,_gridy,m); - _UnloadOldTiles(); - } -} - -void MapMgr::Flush(void) -{ - _mapsLoaded = false; - for(uint32 i = 0; i < 4096; i++) - _tiles->UnloadMapTile(i); - logdebug("MAPMGR: Flushed all maps"); -} - -void MapMgr::_LoadNearTiles(uint32 gx, uint32 gy, uint32 m) -{ - logdebug("MAPMGR: Loading near tiles for (%u, %u) map %u",gx,gy,m); - for(uint32 v = gy-1; v <= gy+1; v++) - { - for(uint32 h = gx-1; h <= gx+1; h++) - { - _LoadTile(h,v,m); - } - } - _mapsLoaded = true; -} - -void MapMgr::_LoadTile(uint32 gx, uint32 gy, uint32 m) -{ - if(!_tiles->TileExists(gx,gy)) - { - logerror("MAPMGR: Not loading MapTile (%u, %u) map %u, no entry in WDT tile map",gx,gy,m); - return; - } - - if( !_tiles->GetTile(gx,gy) ) - { - ADTFile *adt = new ADTFile(); - char buf[300]; - sprintf(buf,"data/maps/%u_%u_%u.adt",m,gx,gy); - if(adt->Load(buf)) - { - logdebug("MAPMGR: Loaded ADT '%s'",buf); - MapTile *tile = new MapTile(); - tile->ImportFromADT(adt); - _tiles->SetTile(tile,gx,gy); - logdebug("MAPMGR: Imported MapTile (%u, %u) for map %u",gx,gy,m); - } - else - { - logerror("MAPMGR: Loading ADT '%s' failed!",buf); - } - delete adt; - } - else - { - logdebug("MAPMGR: No need to load MapTile (%u, %u) map %u",gx,gy,m); - } -} - -void MapMgr::_UnloadOldTiles(void) -{ - for(uint32 gy=0; gy<64; gy++) - { - for(uint32 gx=0; gx<64; gx++) - { - if( (_gridx < gx-1 || _gridx > gx+1) && (_gridy < gy-1 || _gridy > gy+1) ) - { - if(_tiles->GetTile(gx,gy)) - { - logdebug("MAPMGR: Unloading old MapTile (%u, %u) map %u",gx,gy,_mapid); - _tiles->UnloadMapTile(gx,gy); - } - } - } - } -} - -// Using forceLoad is VERY ineffective here, because the tile is removed again after the next Update() call! -MapTile *MapMgr::GetTile(uint32 xg, uint32 yg, bool forceLoad) -{ - MapTile *tile = _tiles->GetTile(xg,yg); - if(!tile) - { - _LoadTile(xg,yg,_mapid); - tile = _tiles->GetTile(xg,yg); - } - return tile; -} - -MapTile *MapMgr::GetCurrentTile(void) -{ - return GetTile(_gridx,_gridy); -} - -MapTile *MapMgr::GetNearTile(int32 xoffs, int32 yoffs) -{ - return GetTile(_gridx + xoffs, _gridy + yoffs); -} - -uint32 MapMgr::GetGridCoord(float f) -{ - return (ZEROPOINT - f) / TILESIZE; -} - -GridCoordPair MapMgr::GetTransformGridCoordPair(float x, float y) -{ - return GridCoordPair(GetGridCoord(x), GetGridCoord(y)); -} - -uint32 MapMgr::GetLoadedMapsCount(void) -{ - uint32 counter = 0; - for(uint32 i = 0; i < 4096; i++) - { - if(_tiles->GetTile(i)) - { - counter++; - } - } - return counter; -} - -float MapMgr::GetZ(float x, float y) -{ - return -99999.0f; // for now return lowest possible number, GetZ() will be implemented correctly later -/* GridCoordPair gcoords = GetTransformGridCoordPair(x,y); - MapTile *tile = _tiles->GetTile(gcoords.x,gcoords.y); - if(tile) - { -#ifdef _DEBUG - tile->DebugDumpToFile(); - logdebug("DEBUG: tile dumped"); -#endif - return tile->GetZ(x,y); - } - - logerror("MapMgr::GetZ() called for not loaded MapTile (%u, %u) for (%f, %f)",gcoords.x,gcoords.y,x,y); - return 0;*/ -} - +#include "common.h" +#include "log.h" +#include "MapTile.h" +#include "MapMgr.h" + +MapMgr::MapMgr() +{ + DEBUG(logdebug("Creating MapMgr with TILESIZE=%.3f CHUNKSIZE=%.3f UNITSIZE=%.3f",TILESIZE,CHUNKSIZE,UNITSIZE)); + _tiles = new MapTileStorage(); + _gridx = _gridy = _mapid = (-1); + _mapsLoaded = false; +} + +MapMgr::~MapMgr() +{ + Flush(); + delete _tiles; +} + +void MapMgr::Update(float x, float y, uint32 m) +{ + if(m != _mapid) + { + Flush(); // we teleported to a new map, drop all loaded maps + WDTFile *wdt = new WDTFile(); + char buf[100]; + sprintf(buf,"data/maps/%u.wdt",m); + if(!wdt->Load(buf)) + { + logerror("MAPMGR: Could not load WDT file '%s'",buf); + } + _tiles->ImportTileMap(wdt); + delete wdt; + _mapid = m; + _gridx = _gridy = (-1); // must load tiles now + } + GridCoordPair gcoords = GetTransformGridCoordPair(x,y); + if(gcoords.x != _gridx || gcoords.y != _gridy) + { + _gridx = gcoords.x; + _gridy = gcoords.y; + _LoadNearTiles(_gridx,_gridy,m); + _UnloadOldTiles(); + } +} + +void MapMgr::Flush(void) +{ + _mapsLoaded = false; + for(uint32 i = 0; i < 4096; i++) + _tiles->UnloadMapTile(i); + logdebug("MAPMGR: Flushed all maps"); +} + +void MapMgr::_LoadNearTiles(uint32 gx, uint32 gy, uint32 m) +{ + logdebug("MAPMGR: Loading near tiles for (%u, %u) map %u",gx,gy,m); + for(uint32 v = gy-1; v <= gy+1; v++) + { + for(uint32 h = gx-1; h <= gx+1; h++) + { + _LoadTile(h,v,m); + } + } + _mapsLoaded = true; +} + +void MapMgr::_LoadTile(uint32 gx, uint32 gy, uint32 m) +{ + if(!_tiles->TileExists(gx,gy)) + { + logerror("MAPMGR: Not loading MapTile (%u, %u) map %u, no entry in WDT tile map",gx,gy,m); + return; + } + + if( !_tiles->GetTile(gx,gy) ) + { + ADTFile *adt = new ADTFile(); + char buf[300]; + sprintf(buf,"data/maps/%u_%u_%u.adt",m,gx,gy); + if(adt->Load(buf)) + { + logdebug("MAPMGR: Loaded ADT '%s'",buf); + MapTile *tile = new MapTile(); + tile->ImportFromADT(adt); + _tiles->SetTile(tile,gx,gy); + logdebug("MAPMGR: Imported MapTile (%u, %u) for map %u",gx,gy,m); + } + else + { + logerror("MAPMGR: Loading ADT '%s' failed!",buf); + } + delete adt; + } + else + { + logdebug("MAPMGR: No need to load MapTile (%u, %u) map %u",gx,gy,m); + } +} + +void MapMgr::_UnloadOldTiles(void) +{ + for(uint32 gy=0; gy<64; gy++) + { + for(uint32 gx=0; gx<64; gx++) + { + if( (_gridx < gx-1 || _gridx > gx+1) && (_gridy < gy-1 || _gridy > gy+1) ) + { + if(_tiles->GetTile(gx,gy)) + { + logdebug("MAPMGR: Unloading old MapTile (%u, %u) map %u",gx,gy,_mapid); + _tiles->UnloadMapTile(gx,gy); + } + } + } + } +} + +// Using forceLoad is VERY ineffective here, because the tile is removed again after the next Update() call! +MapTile *MapMgr::GetTile(uint32 xg, uint32 yg, bool forceLoad) +{ + MapTile *tile = _tiles->GetTile(xg,yg); + if(!tile) + { + _LoadTile(xg,yg,_mapid); + tile = _tiles->GetTile(xg,yg); + } + return tile; +} + +MapTile *MapMgr::GetCurrentTile(void) +{ + return GetTile(_gridx,_gridy); +} + +MapTile *MapMgr::GetNearTile(int32 xoffs, int32 yoffs) +{ + return GetTile(_gridx + xoffs, _gridy + yoffs); +} + +uint32 MapMgr::GetGridCoord(float f) +{ + return (ZEROPOINT - f) / TILESIZE; +} + +GridCoordPair MapMgr::GetTransformGridCoordPair(float x, float y) +{ + return GridCoordPair(GetGridCoord(x), GetGridCoord(y)); +} + +uint32 MapMgr::GetLoadedMapsCount(void) +{ + uint32 counter = 0; + for(uint32 i = 0; i < 4096; i++) + { + if(_tiles->GetTile(i)) + { + counter++; + } + } + return counter; +} + +float MapMgr::GetZ(float x, float y) +{ + return -99999.0f; // for now return lowest possible number, GetZ() will be implemented correctly later +/* GridCoordPair gcoords = GetTransformGridCoordPair(x,y); + MapTile *tile = _tiles->GetTile(gcoords.x,gcoords.y); + if(tile) + { +#ifdef _DEBUG + tile->DebugDumpToFile(); + logdebug("DEBUG: tile dumped"); +#endif + return tile->GetZ(x,y); + } + + logerror("MapMgr::GetZ() called for not loaded MapTile (%u, %u) for (%f, %f)",gcoords.x,gcoords.y,x,y); + return 0;*/ +} + diff --git a/src/Client/World/MovementMgr.cpp b/src/Client/World/MovementMgr.cpp index ec38992..3e7778b 100644 --- a/src/Client/World/MovementMgr.cpp +++ b/src/Client/World/MovementMgr.cpp @@ -1,171 +1,171 @@ -#include "PseuWoW.h" -#include "WorldSession.h" -#include "World.h" -#include "MovementMgr.h" -#include "Player.h" - -MovementMgr::MovementMgr() -{ - _moveFlags = 0; - _instance = NULL; - _optime = 0; - _updatetime = 0; -} - -MovementMgr::~MovementMgr() -{ -} - -void MovementMgr::SetInstance(PseuInstance *inst) -{ - _movemode = MOVEMODE_MANUAL; - _instance = inst; - _mychar = inst->GetWSession()->GetMyChar(); -} - -void MovementMgr::_BuildPacket(uint16 opcode) -{ - WorldPacket wp(opcode,4+1+4+12); // it can be larger, if we are juming, on transport or swimming - wp << _moveFlags; - wp << (uint8)0; // unk - wp << getMSTime(); - wp << _mychar->GetPosition(); - // TODO: transport not yet handled/done - if(_moveFlags & MOVEMENTFLAG_ONTRANSPORT) - { - wp << (uint64)0; // transport guid - wp << WorldPosition(); // transport position - wp << getMSTime(); // transport time (??) - } - // TODO: swimming not yet done - if(_moveFlags & MOVEMENTFLAG_SWIMMING) - { - wp << (float)0; // angle; 1.55=looking up, -1.55=looking down, 0=looking forward - } - wp << (uint32)0; // last fall time (also used when jumping) - // TODO: jumping not yet done - // TODO: spline not yet done - - - _optime = getMSTime(); - -} - -void MovementMgr::Update(bool calcpos) -{ - uint32 curtime = getMSTime(); - uint32 timediff = curtime - _updatetime; - _updatetime = curtime; - - if(_movemode == MOVEMODE_AUTO) - { - WorldPosition& pos = _mychar->GetPosition(); - float turnspeed = _mychar->GetSpeed(MOVE_TURN) / 1000.0f * timediff; - float runspeed = _mychar->GetSpeed(MOVE_RUN) / 1000.0f * timediff; - float movespeed = runspeed; // or use walkspeed, depending on setting. for now use only runspeed - // TODO: calc other speeds as soon as implemented - - /* - if(_moveFlags & MOVEMENTFLAG_FORWARD) - { - pos.x += movespeed * sin(pos.o); - pos.y += movespeed * cos(pos.o); - } - // ... - if(_moveFlags & MOVEMENTFLAG_LEFT) - { - pos.o -= turnspeed; - } - if(_moveFlags & MOVEMENTFLAG_RIGHT) - { - pos.o += turnspeed; - } - if(pos.o < 0) - pos.o += 2 * M_PI; - else if(pos.o > 2 * M_PI) - pos.o -= 2 * M_PI; - - pos.z = _instance->GetWSession()->GetWorld()->GetPosZ(pos.x,pos.y); - */ - // ^ It should look like this later on, but its not finished, and formulas are not tested. - // see it as some future plans that need a lot of finetuning ;) - } - - // if we are moving, and 500ms have passed, send an heartbeat packet - if( (_moveFlags & MOVEMENTFLAG_ANY_MOVE) && _optime + MOVE_HEARTBEAT_DELAY < getMSTime()) - { - _BuildPacket(MSG_MOVE_HEARTBEAT); - } - - // TODO: apply gravity, handle falling, swimming, etc. -} - -void MovementMgr::MoveStop(void) -{ - _moveFlags &= ~(MOVEMENTFLAG_ANY_MOVE); - Update(false); - _BuildPacket(MSG_MOVE_STOP); -} - -void MovementMgr::MoveStartForward(void) -{ - _moveFlags |= MOVEMENTFLAG_FORWARD; - _moveFlags &= ~MOVEMENTFLAG_BACKWARD; - Update(false); - _BuildPacket(MSG_MOVE_START_FORWARD); -} - -void MovementMgr::MoveStartBackward(void) -{ - _moveFlags |= MOVEMENTFLAG_BACKWARD; - _moveFlags &= ~MOVEMENTFLAG_FORWARD; - Update(false); - _BuildPacket(MSG_MOVE_START_BACKWARD); -} - -void MovementMgr::MoveStartStrafeLeft(void) -{ - _moveFlags |= MOVEMENTFLAG_STRAFE_LEFT; - _moveFlags &= ~MOVEMENTFLAG_STRAFE_RIGHT; - Update(false); - _BuildPacket(MSG_MOVE_START_STRAFE_LEFT); -} - -void MovementMgr::MoveStartStrafeRight(void) -{ - _moveFlags |= MOVEMENTFLAG_STRAFE_RIGHT; - _moveFlags &= ~MOVEMENTFLAG_STRAFE_LEFT; - Update(false); - _BuildPacket(MSG_MOVE_START_STRAFE_RIGHT); -} - -void MovementMgr::MoveStartTurnLeft(void) -{ - _moveFlags |= MOVEMENTFLAG_LEFT; - _moveFlags &= ~MOVEMENTFLAG_RIGHT; - Update(false); - _BuildPacket(MSG_MOVE_START_TURN_LEFT); -} - -void MovementMgr::MoveStartTurnRight(void) -{ - _moveFlags |= MOVEMENTFLAG_RIGHT; - _moveFlags &= ~MOVEMENTFLAG_LEFT; - Update(false); - _BuildPacket(MSG_MOVE_START_TURN_RIGHT); -} - -void MovementMgr::MoveStopTurn(void) -{ - _moveFlags &= ~(MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT); - Update(false); - _BuildPacket(MSG_MOVE_STOP_TURN); -} - -void MovementMgr::MoveSetFacing(float o) -{ - _mychar->SetPosition(_mychar->GetX(), _mychar->GetY(), _mychar->GetZ(), o); - Update(true); - _BuildPacket(MSG_MOVE_SET_FACING); -} - +#include "PseuWoW.h" +#include "WorldSession.h" +#include "World.h" +#include "MovementMgr.h" +#include "Player.h" + +MovementMgr::MovementMgr() +{ + _moveFlags = 0; + _instance = NULL; + _optime = 0; + _updatetime = 0; +} + +MovementMgr::~MovementMgr() +{ +} + +void MovementMgr::SetInstance(PseuInstance *inst) +{ + _movemode = MOVEMODE_MANUAL; + _instance = inst; + _mychar = inst->GetWSession()->GetMyChar(); +} + +void MovementMgr::_BuildPacket(uint16 opcode) +{ + WorldPacket wp(opcode,4+1+4+12); // it can be larger, if we are juming, on transport or swimming + wp << _moveFlags; + wp << (uint8)0; // unk + wp << getMSTime(); + wp << _mychar->GetPosition(); + // TODO: transport not yet handled/done + if(_moveFlags & MOVEMENTFLAG_ONTRANSPORT) + { + wp << (uint64)0; // transport guid + wp << WorldPosition(); // transport position + wp << getMSTime(); // transport time (??) + } + // TODO: swimming not yet done + if(_moveFlags & MOVEMENTFLAG_SWIMMING) + { + wp << (float)0; // angle; 1.55=looking up, -1.55=looking down, 0=looking forward + } + wp << (uint32)0; // last fall time (also used when jumping) + // TODO: jumping not yet done + // TODO: spline not yet done + + + _optime = getMSTime(); + +} + +void MovementMgr::Update(bool calcpos) +{ + uint32 curtime = getMSTime(); + uint32 timediff = curtime - _updatetime; + _updatetime = curtime; + + if(_movemode == MOVEMODE_AUTO) + { + WorldPosition& pos = _mychar->GetPosition(); + float turnspeed = _mychar->GetSpeed(MOVE_TURN) / 1000.0f * timediff; + float runspeed = _mychar->GetSpeed(MOVE_RUN) / 1000.0f * timediff; + float movespeed = runspeed; // or use walkspeed, depending on setting. for now use only runspeed + // TODO: calc other speeds as soon as implemented + + /* + if(_moveFlags & MOVEMENTFLAG_FORWARD) + { + pos.x += movespeed * sin(pos.o); + pos.y += movespeed * cos(pos.o); + } + // ... + if(_moveFlags & MOVEMENTFLAG_LEFT) + { + pos.o -= turnspeed; + } + if(_moveFlags & MOVEMENTFLAG_RIGHT) + { + pos.o += turnspeed; + } + if(pos.o < 0) + pos.o += 2 * M_PI; + else if(pos.o > 2 * M_PI) + pos.o -= 2 * M_PI; + + pos.z = _instance->GetWSession()->GetWorld()->GetPosZ(pos.x,pos.y); + */ + // ^ It should look like this later on, but its not finished, and formulas are not tested. + // see it as some future plans that need a lot of finetuning ;) + } + + // if we are moving, and 500ms have passed, send an heartbeat packet + if( (_moveFlags & MOVEMENTFLAG_ANY_MOVE) && _optime + MOVE_HEARTBEAT_DELAY < getMSTime()) + { + _BuildPacket(MSG_MOVE_HEARTBEAT); + } + + // TODO: apply gravity, handle falling, swimming, etc. +} + +void MovementMgr::MoveStop(void) +{ + _moveFlags &= ~(MOVEMENTFLAG_ANY_MOVE); + Update(false); + _BuildPacket(MSG_MOVE_STOP); +} + +void MovementMgr::MoveStartForward(void) +{ + _moveFlags |= MOVEMENTFLAG_FORWARD; + _moveFlags &= ~MOVEMENTFLAG_BACKWARD; + Update(false); + _BuildPacket(MSG_MOVE_START_FORWARD); +} + +void MovementMgr::MoveStartBackward(void) +{ + _moveFlags |= MOVEMENTFLAG_BACKWARD; + _moveFlags &= ~MOVEMENTFLAG_FORWARD; + Update(false); + _BuildPacket(MSG_MOVE_START_BACKWARD); +} + +void MovementMgr::MoveStartStrafeLeft(void) +{ + _moveFlags |= MOVEMENTFLAG_STRAFE_LEFT; + _moveFlags &= ~MOVEMENTFLAG_STRAFE_RIGHT; + Update(false); + _BuildPacket(MSG_MOVE_START_STRAFE_LEFT); +} + +void MovementMgr::MoveStartStrafeRight(void) +{ + _moveFlags |= MOVEMENTFLAG_STRAFE_RIGHT; + _moveFlags &= ~MOVEMENTFLAG_STRAFE_LEFT; + Update(false); + _BuildPacket(MSG_MOVE_START_STRAFE_RIGHT); +} + +void MovementMgr::MoveStartTurnLeft(void) +{ + _moveFlags |= MOVEMENTFLAG_LEFT; + _moveFlags &= ~MOVEMENTFLAG_RIGHT; + Update(false); + _BuildPacket(MSG_MOVE_START_TURN_LEFT); +} + +void MovementMgr::MoveStartTurnRight(void) +{ + _moveFlags |= MOVEMENTFLAG_RIGHT; + _moveFlags &= ~MOVEMENTFLAG_LEFT; + Update(false); + _BuildPacket(MSG_MOVE_START_TURN_RIGHT); +} + +void MovementMgr::MoveStopTurn(void) +{ + _moveFlags &= ~(MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT); + Update(false); + _BuildPacket(MSG_MOVE_STOP_TURN); +} + +void MovementMgr::MoveSetFacing(float o) +{ + _mychar->SetPosition(_mychar->GetX(), _mychar->GetY(), _mychar->GetZ(), o); + Update(true); + _BuildPacket(MSG_MOVE_SET_FACING); +} + diff --git a/src/Client/World/MovementMgr.h b/src/Client/World/MovementMgr.h index a1255a1..d98d50c 100644 --- a/src/Client/World/MovementMgr.h +++ b/src/Client/World/MovementMgr.h @@ -1,85 +1,85 @@ -#ifndef MOVEMENTMGR_H -#define MOVEMENTMGR_H - -#include "common.h" - -#define MOVE_HEARTBEAT_DELAY 500 - -enum MovementFlags -{ - MOVEMENTFLAG_NONE = 0x00000000, - MOVEMENTFLAG_FORWARD = 0x00000001, - MOVEMENTFLAG_BACKWARD = 0x00000002, - MOVEMENTFLAG_STRAFE_LEFT = 0x00000004, - MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008, - MOVEMENTFLAG_LEFT = 0x00000010, - MOVEMENTFLAG_RIGHT = 0x00000020, - MOVEMENTFLAG_PITCH_UP = 0x00000040, - MOVEMENTFLAG_PITCH_DOWN = 0x00000080, - MOVEMENTFLAG_WALK = 0x00000100, - MOVEMENTFLAG_ONTRANSPORT = 0x00000200, - MOVEMENTFLAG_UNK1 = 0x00000400, - MOVEMENTFLAG_FLY_UNK1 = 0x00000800, - MOVEMENTFLAG_JUMPING = 0x00001000, - MOVEMENTFLAG_UNK4 = 0x00002000, - MOVEMENTFLAG_FALLING = 0x00004000, - // 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000 - MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also - MOVEMENTFLAG_FLY_UP = 0x00400000, - MOVEMENTFLAG_CAN_FLY = 0x00800000, - MOVEMENTFLAG_FLYING = 0x01000000, - MOVEMENTFLAG_UNK5 = 0x02000000, - MOVEMENTFLAG_SPLINE = 0x04000000, // probably wrong name - MOVEMENTFLAG_SPLINE2 = 0x08000000, - MOVEMENTFLAG_WATERWALKING = 0x10000000, - MOVEMENTFLAG_SAFE_FALL = 0x20000000, // active rogue safe fall spell (passive) - MOVEMENTFLAG_UNK3 = 0x40000000, - - // custom flags - MOVEMENTFLAG_ANY_MOVE = (MOVEMENTFLAG_BACKWARD | MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_STRAFE_LEFT | MOVEMENTFLAG_STRAFE_RIGHT - | MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT) -}; - -enum MoveModes -{ - MOVEMODE_AUTO, // CPU controlling movement, MyCharacter must be updated - MOVEMODE_MANUAL, // user controlling movement, MyCharacter is updated by the GUI already -}; - -class PseuInstance; -class MyCharacter; - - -class MovementMgr -{ -public: - MovementMgr(); - ~MovementMgr(); - void SetInstance(PseuInstance*); - inline void SetMoveMode(uint8 mode) { _movemode = mode; } - void Update(bool); - void MoveStartForward(void); - void MoveStartBackward(void); - void MoveStop(void); - void MoveStartStrafeLeft(void); - void MoveStartStrafeRight(void); - void MoveStartTurnLeft(void); - void MoveStartTurnRight(void); - void MoveStopTurn(void); - void MoveFallLand(void); - void MoveSetFacing(float); - -private: - void _BuildPacket(uint16); - PseuInstance *_instance; - MyCharacter *_mychar; - uint32 _moveFlags; // server relevant flags (move forward/backward/swim/fly/jump/etc) - uint32 _updatetime; // timeMS of last update cycle - uint32 _optime; // timeMS when last opcode was sent - uint8 _movemode; // automatic or manual - UnitMoveType _movetype; // index used for speed selection - - -}; - +#ifndef MOVEMENTMGR_H +#define MOVEMENTMGR_H + +#include "common.h" + +#define MOVE_HEARTBEAT_DELAY 500 + +enum MovementFlags +{ + MOVEMENTFLAG_NONE = 0x00000000, + MOVEMENTFLAG_FORWARD = 0x00000001, + MOVEMENTFLAG_BACKWARD = 0x00000002, + MOVEMENTFLAG_STRAFE_LEFT = 0x00000004, + MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008, + MOVEMENTFLAG_LEFT = 0x00000010, + MOVEMENTFLAG_RIGHT = 0x00000020, + MOVEMENTFLAG_PITCH_UP = 0x00000040, + MOVEMENTFLAG_PITCH_DOWN = 0x00000080, + MOVEMENTFLAG_WALK = 0x00000100, + MOVEMENTFLAG_ONTRANSPORT = 0x00000200, + MOVEMENTFLAG_UNK1 = 0x00000400, + MOVEMENTFLAG_FLY_UNK1 = 0x00000800, + MOVEMENTFLAG_JUMPING = 0x00001000, + MOVEMENTFLAG_UNK4 = 0x00002000, + MOVEMENTFLAG_FALLING = 0x00004000, + // 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000 + MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also + MOVEMENTFLAG_FLY_UP = 0x00400000, + MOVEMENTFLAG_CAN_FLY = 0x00800000, + MOVEMENTFLAG_FLYING = 0x01000000, + MOVEMENTFLAG_UNK5 = 0x02000000, + MOVEMENTFLAG_SPLINE = 0x04000000, // probably wrong name + MOVEMENTFLAG_SPLINE2 = 0x08000000, + MOVEMENTFLAG_WATERWALKING = 0x10000000, + MOVEMENTFLAG_SAFE_FALL = 0x20000000, // active rogue safe fall spell (passive) + MOVEMENTFLAG_UNK3 = 0x40000000, + + // custom flags + MOVEMENTFLAG_ANY_MOVE = (MOVEMENTFLAG_BACKWARD | MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_STRAFE_LEFT | MOVEMENTFLAG_STRAFE_RIGHT + | MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT) +}; + +enum MoveModes +{ + MOVEMODE_AUTO, // CPU controlling movement, MyCharacter must be updated + MOVEMODE_MANUAL, // user controlling movement, MyCharacter is updated by the GUI already +}; + +class PseuInstance; +class MyCharacter; + + +class MovementMgr +{ +public: + MovementMgr(); + ~MovementMgr(); + void SetInstance(PseuInstance*); + inline void SetMoveMode(uint8 mode) { _movemode = mode; } + void Update(bool); + void MoveStartForward(void); + void MoveStartBackward(void); + void MoveStop(void); + void MoveStartStrafeLeft(void); + void MoveStartStrafeRight(void); + void MoveStartTurnLeft(void); + void MoveStartTurnRight(void); + void MoveStopTurn(void); + void MoveFallLand(void); + void MoveSetFacing(float); + +private: + void _BuildPacket(uint16); + PseuInstance *_instance; + MyCharacter *_mychar; + uint32 _moveFlags; // server relevant flags (move forward/backward/swim/fly/jump/etc) + uint32 _updatetime; // timeMS of last update cycle + uint32 _optime; // timeMS when last opcode was sent + uint8 _movemode; // automatic or manual + UnitMoveType _movetype; // index used for speed selection + + +}; + #endif \ No newline at end of file diff --git a/src/Client/World/ObjMgr.cpp b/src/Client/World/ObjMgr.cpp index 57b98c0..76d88bb 100644 --- a/src/Client/World/ObjMgr.cpp +++ b/src/Client/World/ObjMgr.cpp @@ -1,153 +1,153 @@ -#include "common.h" -#include "log.h" -#include "PseuWoW.h" -#include "ObjMgr.h" -#include "GUI/PseuGUI.h" - -ObjMgr::ObjMgr() -{ - DEBUG(logdebug("DEBUG: ObjMgr created")); -} - -ObjMgr::~ObjMgr() -{ - RemoveAll(); -} - -void ObjMgr::SetInstance(PseuInstance *i) -{ - _instance = i; - DEBUG(logdebug("DEBUG: ObjMgr instance set to 0x%X",i)); -} - -void ObjMgr::RemoveAll(void) -{ - for(ItemProtoMap::iterator i = _iproto.begin(); i!=_iproto.end(); i++) - { - delete i->second; - } - for(CreatureTemplateMap::iterator i = _creature_templ.begin(); i!=_creature_templ.end(); i++) - { - delete i->second; - } - while(_obj.size()) - { - Remove(_obj.begin()->first); - } -} - -void ObjMgr::Remove(uint64 guid) -{ - Object *o = GetObj(guid); - if(o) - { - PseuGUI *gui = _instance->GetGUI(); - if(gui) - gui->NotifyObjectDeletion(guid); // we have a gui, which must delete linked DrawObject - _obj.erase(guid); // now delete the obj from the mgr - delete o; // and delete the obj itself - } - else - { - _obj.erase(guid); - logcustom(2,LRED,"ObjMgr::Remove("I64FMT") - not existing",guid); - } -} - -// -- Object part -- - -void ObjMgr::Add(Object *o) -{ - _obj[o->GetGUID()] = o; - - PseuGUI *gui = _instance->GetGUI(); - if(gui) - gui->NotifyObjectCreation(o); -} - -Object *ObjMgr::GetObj(uint64 guid) -{ - if(!guid) - return NULL; - for(ObjectMap::iterator i = _obj.begin(); i!=_obj.end(); i++) - if(i->second->GetGUID() == guid) - return i->second; - return NULL; -} - -// iterate over all objects and assign a name to all matching the entry and typeid -uint32 ObjMgr::AssignNameToObj(uint32 entry, uint8 type, std::string name) -{ - uint32 changed = 0; - for(ObjectMap::iterator it = _obj.begin(); it != _obj.end(); it++) - { - if(it->second->GetEntry() && (it->second->GetTypeId() == type)) - { - it->second->SetName(name); - changed++; - } - } - return changed; -} - -// -- Item part -- - -void ObjMgr::Add(ItemProto *proto) -{ - _iproto[proto->Id] = proto; -} - -ItemProto *ObjMgr::GetItemProto(uint32 entry) -{ - ItemProtoMap::iterator it = _iproto.find(entry); - if(it != _iproto.end()) - return it->second; - return NULL; -} - -void ObjMgr::AddNonexistentItem(uint32 id) -{ - _noitem.insert(id); -} - -bool ObjMgr::ItemNonExistent(uint32 id) -{ - return _noitem.find(id) != _noitem.end(); -} - -// -- Creature part -- - -void ObjMgr::Add(CreatureTemplate *cr) -{ - _creature_templ[cr->entry] = cr; -} - -CreatureTemplate *ObjMgr::GetCreatureTemplate(uint32 entry) -{ - CreatureTemplateMap::iterator it = _creature_templ.find(entry); - if(it != _creature_templ.end()) - return it->second; - return NULL; -} - -void ObjMgr::AddNonexistentCreature(uint32 id) -{ - _nocreature.insert(id); -} - -bool ObjMgr::CreatureNonExistent(uint32 id) -{ - return _nocreature.find(id) != _nocreature.end(); -} - -// -- misc part -- - -void ObjMgr::AddRequestedPlayerGUID(uint32 loguid) -{ - _reqpnames.insert(loguid); -} - -bool ObjMgr::IsRequestedPlayerGUID(uint32 loguid) -{ - return _reqpnames.find(loguid) != _reqpnames.end(); -} +#include "common.h" +#include "log.h" +#include "PseuWoW.h" +#include "ObjMgr.h" +#include "GUI/PseuGUI.h" + +ObjMgr::ObjMgr() +{ + DEBUG(logdebug("DEBUG: ObjMgr created")); +} + +ObjMgr::~ObjMgr() +{ + RemoveAll(); +} + +void ObjMgr::SetInstance(PseuInstance *i) +{ + _instance = i; + DEBUG(logdebug("DEBUG: ObjMgr instance set to 0x%X",i)); +} + +void ObjMgr::RemoveAll(void) +{ + for(ItemProtoMap::iterator i = _iproto.begin(); i!=_iproto.end(); i++) + { + delete i->second; + } + for(CreatureTemplateMap::iterator i = _creature_templ.begin(); i!=_creature_templ.end(); i++) + { + delete i->second; + } + while(_obj.size()) + { + Remove(_obj.begin()->first); + } +} + +void ObjMgr::Remove(uint64 guid) +{ + Object *o = GetObj(guid); + if(o) + { + PseuGUI *gui = _instance->GetGUI(); + if(gui) + gui->NotifyObjectDeletion(guid); // we have a gui, which must delete linked DrawObject + _obj.erase(guid); // now delete the obj from the mgr + delete o; // and delete the obj itself + } + else + { + _obj.erase(guid); + logcustom(2,LRED,"ObjMgr::Remove("I64FMT") - not existing",guid); + } +} + +// -- Object part -- + +void ObjMgr::Add(Object *o) +{ + _obj[o->GetGUID()] = o; + + PseuGUI *gui = _instance->GetGUI(); + if(gui) + gui->NotifyObjectCreation(o); +} + +Object *ObjMgr::GetObj(uint64 guid) +{ + if(!guid) + return NULL; + for(ObjectMap::iterator i = _obj.begin(); i!=_obj.end(); i++) + if(i->second->GetGUID() == guid) + return i->second; + return NULL; +} + +// iterate over all objects and assign a name to all matching the entry and typeid +uint32 ObjMgr::AssignNameToObj(uint32 entry, uint8 type, std::string name) +{ + uint32 changed = 0; + for(ObjectMap::iterator it = _obj.begin(); it != _obj.end(); it++) + { + if(it->second->GetEntry() && (it->second->GetTypeId() == type)) + { + it->second->SetName(name); + changed++; + } + } + return changed; +} + +// -- Item part -- + +void ObjMgr::Add(ItemProto *proto) +{ + _iproto[proto->Id] = proto; +} + +ItemProto *ObjMgr::GetItemProto(uint32 entry) +{ + ItemProtoMap::iterator it = _iproto.find(entry); + if(it != _iproto.end()) + return it->second; + return NULL; +} + +void ObjMgr::AddNonexistentItem(uint32 id) +{ + _noitem.insert(id); +} + +bool ObjMgr::ItemNonExistent(uint32 id) +{ + return _noitem.find(id) != _noitem.end(); +} + +// -- Creature part -- + +void ObjMgr::Add(CreatureTemplate *cr) +{ + _creature_templ[cr->entry] = cr; +} + +CreatureTemplate *ObjMgr::GetCreatureTemplate(uint32 entry) +{ + CreatureTemplateMap::iterator it = _creature_templ.find(entry); + if(it != _creature_templ.end()) + return it->second; + return NULL; +} + +void ObjMgr::AddNonexistentCreature(uint32 id) +{ + _nocreature.insert(id); +} + +bool ObjMgr::CreatureNonExistent(uint32 id) +{ + return _nocreature.find(id) != _nocreature.end(); +} + +// -- misc part -- + +void ObjMgr::AddRequestedPlayerGUID(uint32 loguid) +{ + _reqpnames.insert(loguid); +} + +bool ObjMgr::IsRequestedPlayerGUID(uint32 loguid) +{ + return _reqpnames.find(loguid) != _reqpnames.end(); +} diff --git a/src/Client/World/Object.h b/src/Client/World/Object.h index 1e9cf9b..9119cf7 100644 --- a/src/Client/World/Object.h +++ b/src/Client/World/Object.h @@ -1,177 +1,177 @@ -#ifndef _OBJECT_H -#define _OBJECT_H - -#include "UpdateFields.h" -#include "ObjectDefines.h" -#include "common.h" -#include "HelperDefs.h" -#include "World.h" - -enum TYPE -{ - TYPE_OBJECT = 1, - TYPE_ITEM = 2, - TYPE_CONTAINER = 6, // a container is ALWAYS an item! - TYPE_UNIT = 8, - TYPE_PLAYER = 16, - TYPE_GAMEOBJECT = 32, - TYPE_DYNAMICOBJECT = 64, - TYPE_CORPSE = 128, - TYPE_AIGROUP = 256, - TYPE_AREATRIGGER = 512 -}; - -enum TYPEID -{ - TYPEID_OBJECT = 0, - TYPEID_ITEM = 1, - TYPEID_CONTAINER = 2, - TYPEID_UNIT = 3, - TYPEID_PLAYER = 4, - TYPEID_GAMEOBJECT = 5, - TYPEID_DYNAMICOBJECT = 6, - TYPEID_CORPSE = 7, - TYPEID_AIGROUP = 8, - TYPEID_AREATRIGGER = 9 -}; - -class Object -{ -public: - virtual ~Object(); - inline const uint64 GetGUID() const { return GetUInt64Value(0); } - inline const uint32 GetGUIDLow() const { return GetUInt32Value(0); } - inline const uint32 GetGUIDHigh() const { return GetUInt32Value(1); } - inline uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); } - inline uint16 GetValuesCount(void) { return _valuescount; } - - inline const uint8 GetTypeId() { return _typeid; } - inline const uint8 GetTypeMask() { return _type; } - inline bool IsType(uint8 mask) { return (mask & _type) ? true : false; } - inline bool IsPlayer(void) { return _typeid == TYPEID_PLAYER; } // specific - inline bool IsUnit(void) { return _type & TYPE_UNIT; } // generic (unit = creature or player) - inline bool IsCreature(void) { return IsUnit() && !IsPlayer(); } // specific - inline bool IsItem(void) { return _type & TYPE_ITEM; } // generic (item or container) - inline bool IsContainer(void) { return _typeid == TYPEID_CONTAINER; } // specific - inline bool IsCorpse(void) { return _typeid == TYPEID_CORPSE; } // specific - inline bool IsDynObject(void) { return _typeid == TYPEID_DYNAMICOBJECT; } // specific - inline bool IsWorldObject(void) { return _type & (TYPE_PLAYER | TYPE_UNIT | TYPE_CORPSE | TYPE_DYNAMICOBJECT | TYPE_GAMEOBJECT); } - inline const uint32 GetUInt32Value( uint16 index ) const - { - return _uint32values[ index ]; - } - - inline const uint64 GetUInt64Value( uint16 index ) const - { - return *((uint64*)&(_uint32values[ index ])); - } - - inline bool HasFlag( uint16 index, uint32 flag ) const - { - return (_uint32values[ index ] & flag) != 0; - } - inline const float GetFloatValue( uint16 index ) const - { - return _floatvalues[ index ]; - } - inline void SetFloatValue( uint16 index, float value ) - { - _floatvalues[ index ] = value; - } - inline void SetUInt32Value( uint16 index, uint32 value ) - { - _uint32values[ index ] = value; - } - - inline void SetName(std::string name) { _name = name; } - inline std::string GetName(void) { return _name; } - - inline float GetObjectSize() const - { - return ( _valuescount > UNIT_FIELD_BOUNDINGRADIUS ) ? _floatvalues[UNIT_FIELD_BOUNDINGRADIUS] : 0.39f; - } - - void Create(uint64 guid); - -protected: - Object(); - void _InitValues(void); - - uint16 _valuescount; - union - { - uint32 *_uint32values; - float *_floatvalues; - }; - uint8 _type; - uint8 _typeid; - std::string _name; -}; - -class WorldObject : public Object -{ -public: - virtual ~WorldObject ( ) {} - void SetPosition(float x, float y, float z, float o, uint16 _map); - void SetPosition(float x, float y, float z, float o); - inline void SetPosition(WorldPosition& wp) { _wpos = wp; } - inline void SetPosition(WorldPosition& wp, uint16 mapid) { SetPosition(wp); _m = mapid; } - inline WorldPosition GetPosition(void) {return _wpos; } - inline float GetX(void) { return _wpos.x; } - inline float GetY(void) { return _wpos.y; } - inline float GetZ(void) { return _wpos.z; } - inline float GetO(void) { return _wpos.o; } - float GetDistance(WorldObject *obj); - float GetDistance2d(float x, float y); - float GetDistance(float x, float y, float z); - float GetDistance2d(WorldObject *obj); - float GetDistanceZ(WorldObject *obj); - -protected: - WorldObject(); - WorldPosition _wpos; // coords, orientation - uint16 _m; // map - -}; - -inline uint32 GetValuesCountByTypeId(uint8 tid) -{ - switch(tid) - { - case TYPEID_OBJECT: return OBJECT_END; - case TYPEID_UNIT: return UNIT_END; - case TYPEID_PLAYER: return PLAYER_END; - case TYPEID_ITEM: return ITEM_END; - case TYPEID_CONTAINER: return CONTAINER_END; - case TYPEID_GAMEOBJECT: return GAMEOBJECT_END; - case TYPEID_DYNAMICOBJECT: return DYNAMICOBJECT_END; - case TYPEID_CORPSE: return CORPSE_END; - } - return 0; -} - -inline uint8 GetTypeIdByGuid(uint64 guid) -{ - switch(GUID_HIPART(guid)) - { - case HIGHGUID_PLAYER: - return TYPEID_PLAYER; - case HIGHGUID_CORPSE: - case HIGHGUID_PLAYER_CORPSE: // not sure - return TYPEID_CORPSE; - case HIGHGUID_ITEM: // == HIGHGUID_CONTAINER - return TYPEID_ITEM; - case HIGHGUID_DYNAMICOBJECT: - return TYPEID_DYNAMICOBJECT; - case HIGHGUID_GAMEOBJECT: - case HIGHGUID_TRANSPORT: // not sure - return TYPEID_GAMEOBJECT; - case HIGHGUID_UNIT: - return TYPEID_UNIT; - } - return TYPEID_OBJECT; -} - - - -#endif +#ifndef _OBJECT_H +#define _OBJECT_H + +#include "UpdateFields.h" +#include "ObjectDefines.h" +#include "common.h" +#include "HelperDefs.h" +#include "World.h" + +enum TYPE +{ + TYPE_OBJECT = 1, + TYPE_ITEM = 2, + TYPE_CONTAINER = 6, // a container is ALWAYS an item! + TYPE_UNIT = 8, + TYPE_PLAYER = 16, + TYPE_GAMEOBJECT = 32, + TYPE_DYNAMICOBJECT = 64, + TYPE_CORPSE = 128, + TYPE_AIGROUP = 256, + TYPE_AREATRIGGER = 512 +}; + +enum TYPEID +{ + TYPEID_OBJECT = 0, + TYPEID_ITEM = 1, + TYPEID_CONTAINER = 2, + TYPEID_UNIT = 3, + TYPEID_PLAYER = 4, + TYPEID_GAMEOBJECT = 5, + TYPEID_DYNAMICOBJECT = 6, + TYPEID_CORPSE = 7, + TYPEID_AIGROUP = 8, + TYPEID_AREATRIGGER = 9 +}; + +class Object +{ +public: + virtual ~Object(); + inline const uint64 GetGUID() const { return GetUInt64Value(0); } + inline const uint32 GetGUIDLow() const { return GetUInt32Value(0); } + inline const uint32 GetGUIDHigh() const { return GetUInt32Value(1); } + inline uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); } + inline uint16 GetValuesCount(void) { return _valuescount; } + + inline const uint8 GetTypeId() { return _typeid; } + inline const uint8 GetTypeMask() { return _type; } + inline bool IsType(uint8 mask) { return (mask & _type) ? true : false; } + inline bool IsPlayer(void) { return _typeid == TYPEID_PLAYER; } // specific + inline bool IsUnit(void) { return _type & TYPE_UNIT; } // generic (unit = creature or player) + inline bool IsCreature(void) { return IsUnit() && !IsPlayer(); } // specific + inline bool IsItem(void) { return _type & TYPE_ITEM; } // generic (item or container) + inline bool IsContainer(void) { return _typeid == TYPEID_CONTAINER; } // specific + inline bool IsCorpse(void) { return _typeid == TYPEID_CORPSE; } // specific + inline bool IsDynObject(void) { return _typeid == TYPEID_DYNAMICOBJECT; } // specific + inline bool IsWorldObject(void) { return _type & (TYPE_PLAYER | TYPE_UNIT | TYPE_CORPSE | TYPE_DYNAMICOBJECT | TYPE_GAMEOBJECT); } + inline const uint32 GetUInt32Value( uint16 index ) const + { + return _uint32values[ index ]; + } + + inline const uint64 GetUInt64Value( uint16 index ) const + { + return *((uint64*)&(_uint32values[ index ])); + } + + inline bool HasFlag( uint16 index, uint32 flag ) const + { + return (_uint32values[ index ] & flag) != 0; + } + inline const float GetFloatValue( uint16 index ) const + { + return _floatvalues[ index ]; + } + inline void SetFloatValue( uint16 index, float value ) + { + _floatvalues[ index ] = value; + } + inline void SetUInt32Value( uint16 index, uint32 value ) + { + _uint32values[ index ] = value; + } + + inline void SetName(std::string name) { _name = name; } + inline std::string GetName(void) { return _name; } + + inline float GetObjectSize() const + { + return ( _valuescount > UNIT_FIELD_BOUNDINGRADIUS ) ? _floatvalues[UNIT_FIELD_BOUNDINGRADIUS] : 0.39f; + } + + void Create(uint64 guid); + +protected: + Object(); + void _InitValues(void); + + uint16 _valuescount; + union + { + uint32 *_uint32values; + float *_floatvalues; + }; + uint8 _type; + uint8 _typeid; + std::string _name; +}; + +class WorldObject : public Object +{ +public: + virtual ~WorldObject ( ) {} + void SetPosition(float x, float y, float z, float o, uint16 _map); + void SetPosition(float x, float y, float z, float o); + inline void SetPosition(WorldPosition& wp) { _wpos = wp; } + inline void SetPosition(WorldPosition& wp, uint16 mapid) { SetPosition(wp); _m = mapid; } + inline WorldPosition GetPosition(void) {return _wpos; } + inline float GetX(void) { return _wpos.x; } + inline float GetY(void) { return _wpos.y; } + inline float GetZ(void) { return _wpos.z; } + inline float GetO(void) { return _wpos.o; } + float GetDistance(WorldObject *obj); + float GetDistance2d(float x, float y); + float GetDistance(float x, float y, float z); + float GetDistance2d(WorldObject *obj); + float GetDistanceZ(WorldObject *obj); + +protected: + WorldObject(); + WorldPosition _wpos; // coords, orientation + uint16 _m; // map + +}; + +inline uint32 GetValuesCountByTypeId(uint8 tid) +{ + switch(tid) + { + case TYPEID_OBJECT: return OBJECT_END; + case TYPEID_UNIT: return UNIT_END; + case TYPEID_PLAYER: return PLAYER_END; + case TYPEID_ITEM: return ITEM_END; + case TYPEID_CONTAINER: return CONTAINER_END; + case TYPEID_GAMEOBJECT: return GAMEOBJECT_END; + case TYPEID_DYNAMICOBJECT: return DYNAMICOBJECT_END; + case TYPEID_CORPSE: return CORPSE_END; + } + return 0; +} + +inline uint8 GetTypeIdByGuid(uint64 guid) +{ + switch(GUID_HIPART(guid)) + { + case HIGHGUID_PLAYER: + return TYPEID_PLAYER; + case HIGHGUID_CORPSE: + case HIGHGUID_PLAYER_CORPSE: // not sure + return TYPEID_CORPSE; + case HIGHGUID_ITEM: // == HIGHGUID_CONTAINER + return TYPEID_ITEM; + case HIGHGUID_DYNAMICOBJECT: + return TYPEID_DYNAMICOBJECT; + case HIGHGUID_GAMEOBJECT: + case HIGHGUID_TRANSPORT: // not sure + return TYPEID_GAMEOBJECT; + case HIGHGUID_UNIT: + return TYPEID_UNIT; + } + return TYPEID_OBJECT; +} + + + +#endif diff --git a/src/Client/World/Opcodes.cpp b/src/Client/World/Opcodes.cpp index 79cc669..48e53e1 100644 --- a/src/Client/World/Opcodes.cpp +++ b/src/Client/World/Opcodes.cpp @@ -1,1075 +1,1075 @@ -/* - * Copyright (C) 2005,2006,2007 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/** \file - \ingroup u2w -*/ -#include "common.h" -#include "Opcodes.h" - - -/// Correspondance between opcodes and their names -// this is an string array, for more opcode comments look to opcodes.h -// do not change order of lines! -// when renaming opcodes, replace old name by the new one -const char* worldOpcodeNames[] = -{ - "MSG_NULL_ACTION", // MSG_NULL_ACTION - "CMSG_BOOTME", // CMSG_BOOTME - "CMSG_DBLOOKUP", // CMSG_DBLOOKUP - "SMSG_DBLOOKUP", // SMSG_DBLOOKUP - "CMSG_QUERY_OBJECT_POSITION", // CMSG_QUERY_OBJECT_POSITION - "SMSG_QUERY_OBJECT_POSITION", // SMSG_QUERY_OBJECT_POSITION - "CMSG_QUERY_OBJECT_ROTATION", // CMSG_QUERY_OBJECT_ROTATION - "SMSG_QUERY_OBJECT_ROTATION", // SMSG_QUERY_OBJECT_ROTATION - "CMSG_WORLD_TELEPORT", // CMSG_WORLD_TELEPORT - "CMSG_TELEPORT_TO_UNIT", // CMSG_TELEPORT_TO_UNIT - "CMSG_ZONE_MAP", // CMSG_ZONE_MAP - "SMSG_ZONE_MAP", // SMSG_ZONE_MAP - "CMSG_DEBUG_CHANGECELLZONE", // CMSG_DEBUG_CHANGECELLZONE - "CMSG_EMBLAZON_TABARD_OBSOLETE", // CMSG_EMBLAZON_TABARD_OBSOLETE - "CMSG_UNEMBLAZON_TABARD_OBSOLETE", // CMSG_UNEMBLAZON_TABARD_OBSOLETE - "CMSG_RECHARGE", // CMSG_RECHARGE - "CMSG_LEARN_SPELL", // CMSG_LEARN_SPELL - "CMSG_CREATEMONSTER", // CMSG_CREATEMONSTER - "CMSG_DESTROYMONSTER", // CMSG_DESTROYMONSTER - "CMSG_CREATEITEM", // CMSG_CREATEITEM - "CMSG_CREATEGAMEOBJECT", // CMSG_CREATEGAMEOBJECT - "CMSG_MAKEMONSTERATTACKME_OBSOLETE", // CMSG_MAKEMONSTERATTACKME_OBSOLETE - "CMSG_MAKEMONSTERATTACKGUID", // CMSG_MAKEMONSTERATTACKGUID - "CMSG_ENABLEDEBUGCOMBATLOGGING_OBSOLETE", // CMSG_ENABLEDEBUGCOMBATLOGGING_OBSOLETE - "CMSG_FORCEACTION", // CMSG_FORCEACTION - "CMSG_FORCEACTIONONOTHER", // CMSG_FORCEACTIONONOTHER - "CMSG_FORCEACTIONSHOW", // CMSG_FORCEACTIONSHOW - "SMSG_FORCEACTIONSHOW", // SMSG_FORCEACTIONSHOW - "SMSG_ATTACKERSTATEUPDATEDEBUGINFO_OBSOLETE", // SMSG_ATTACKERSTATEUPDATEDEBUGINFO_OBSOLETE - "SMSG_DEBUGINFOSPELL_OBSOLETE", // SMSG_DEBUGINFOSPELL_OBSOLETE - "SMSG_DEBUGINFOSPELLMISS_OBSOLETE", // SMSG_DEBUGINFOSPELLMISS_OBSOLETE - "SMSG_DEBUG_PLAYER_RANGE_OBSOLETE", // SMSG_DEBUG_PLAYER_RANGE_OBSOLETE - "CMSG_UNDRESSPLAYER", // CMSG_UNDRESSPLAYER - "CMSG_BEASTMASTER", // CMSG_BEASTMASTER - "CMSG_GODMODE", // CMSG_GODMODE - "SMSG_GODMODE", // SMSG_GODMODE - "CMSG_CHEAT_SETMONEY", // CMSG_CHEAT_SETMONEY - "CMSG_LEVEL_CHEAT", // CMSG_LEVEL_CHEAT - "CMSG_PET_LEVEL_CHEAT", // CMSG_PET_LEVEL_CHEAT - "CMSG_LEVELUP_CHEAT_OBSOLETE", // CMSG_LEVELUP_CHEAT_OBSOLETE - "CMSG_COOLDOWN_CHEAT", // CMSG_COOLDOWN_CHEAT - "CMSG_USE_SKILL_CHEAT", // CMSG_USE_SKILL_CHEAT - "CMSG_FLAG_QUEST", // CMSG_FLAG_QUEST - "CMSG_FLAG_QUEST_FINISH", // CMSG_FLAG_QUEST_FINISH - "CMSG_CLEAR_QUEST", // CMSG_CLEAR_QUEST - "CMSG_SEND_EVENT", // CMSG_SEND_EVENT - "CMSG_DEBUG_AISTATE", // CMSG_DEBUG_AISTATE - "SMSG_DEBUG_AISTATE", // SMSG_DEBUG_AISTATE - "CMSG_DISABLE_PVP_CHEAT", // CMSG_DISABLE_PVP_CHEAT - "CMSG_ADVANCE_SPAWN_TIME", // CMSG_ADVANCE_SPAWN_TIME - "CMSG_PVP_PORT_OBSOLETE", // CMSG_PVP_PORT_OBSOLETE - "CMSG_AUTH_SRP6_BEGIN", // CMSG_AUTH_SRP6_BEGIN - "CMSG_AUTH_SRP6_PROOF", // CMSG_AUTH_SRP6_PROOF - "CMSG_AUTH_SRP6_RECODE", // CMSG_AUTH_SRP6_RECODE - "CMSG_CHAR_CREATE", // CMSG_CHAR_CREATE - "CMSG_CHAR_ENUM", // CMSG_CHAR_ENUM - "CMSG_CHAR_DELETE", // CMSG_CHAR_DELETE - "SMSG_AUTH_SRP6_RESPONSE", // SMSG_AUTH_SRP6_RESPONSE - "SMSG_CHAR_CREATE", // SMSG_CHAR_CREATE - "SMSG_CHAR_ENUM", // SMSG_CHAR_ENUM - "SMSG_CHAR_DELETE", // SMSG_CHAR_DELETE - "CMSG_PLAYER_LOGIN", // CMSG_PLAYER_LOGIN - "SMSG_NEW_WORLD", // SMSG_NEW_WORLD - "SMSG_TRANSFER_PENDING", // SMSG_TRANSFER_PENDING - "SMSG_TRANSFER_ABORTED", // SMSG_TRANSFER_ABORTED - "SMSG_CHARACTER_LOGIN_FAILED", // SMSG_CHARACTER_LOGIN_FAILED - "SMSG_LOGIN_SETTIMESPEED", // SMSG_LOGIN_SETTIMESPEED - "SMSG_GAMETIME_UPDATE", // SMSG_GAMETIME_UPDATE - "CMSG_GAMETIME_SET", // CMSG_GAMETIME_SET - "SMSG_GAMETIME_SET", // SMSG_GAMETIME_SET - "CMSG_GAMESPEED_SET", // CMSG_GAMESPEED_SET - "SMSG_GAMESPEED_SET", // SMSG_GAMESPEED_SET - "CMSG_SERVERTIME", // CMSG_SERVERTIME - "SMSG_SERVERTIME", // SMSG_SERVERTIME - "CMSG_PLAYER_LOGOUT", // CMSG_PLAYER_LOGOUT - "CMSG_LOGOUT_REQUEST", // CMSG_LOGOUT_REQUEST - "SMSG_LOGOUT_RESPONSE", // SMSG_LOGOUT_RESPONSE - "SMSG_LOGOUT_COMPLETE", // SMSG_LOGOUT_COMPLETE - "CMSG_LOGOUT_CANCEL", // CMSG_LOGOUT_CANCEL - "SMSG_LOGOUT_CANCEL_ACK", // SMSG_LOGOUT_CANCEL_ACK - "CMSG_NAME_QUERY", // CMSG_NAME_QUERY - "SMSG_NAME_QUERY_RESPONSE", // SMSG_NAME_QUERY_RESPONSE - "CMSG_PET_NAME_QUERY", // CMSG_PET_NAME_QUERY - "SMSG_PET_NAME_QUERY_RESPONSE", // SMSG_PET_NAME_QUERY_RESPONSE - "CMSG_GUILD_QUERY", // CMSG_GUILD_QUERY - "SMSG_GUILD_QUERY_RESPONSE", // SMSG_GUILD_QUERY_RESPONSE - "CMSG_ITEM_QUERY_SINGLE", // CMSG_ITEM_QUERY_SINGLE - "CMSG_ITEM_QUERY_MULTIPLE", // CMSG_ITEM_QUERY_MULTIPLE - "SMSG_ITEM_QUERY_SINGLE_RESPONSE", // SMSG_ITEM_QUERY_SINGLE_RESPONSE - "SMSG_ITEM_QUERY_MULTIPLE_RESPONSE", // SMSG_ITEM_QUERY_MULTIPLE_RESPONSE - "CMSG_PAGE_TEXT_QUERY", // CMSG_PAGE_TEXT_QUERY - "SMSG_PAGE_TEXT_QUERY_RESPONSE", // SMSG_PAGE_TEXT_QUERY_RESPONSE - "CMSG_QUEST_QUERY", // CMSG_QUEST_QUERY - "SMSG_QUEST_QUERY_RESPONSE", // SMSG_QUEST_QUERY_RESPONSE - "CMSG_GAMEOBJECT_QUERY", // CMSG_GAMEOBJECT_QUERY - "SMSG_GAMEOBJECT_QUERY_RESPONSE", // SMSG_GAMEOBJECT_QUERY_RESPONSE - "CMSG_CREATURE_QUERY", // CMSG_CREATURE_QUERY - "SMSG_CREATURE_QUERY_RESPONSE", // SMSG_CREATURE_QUERY_RESPONSE - "CMSG_WHO", // CMSG_WHO - "SMSG_WHO", // SMSG_WHO - "CMSG_WHOIS", // CMSG_WHOIS - "SMSG_WHOIS", // SMSG_WHOIS - "CMSG_FRIEND_LIST", // CMSG_FRIEND_LIST - "SMSG_FRIEND_LIST", // SMSG_FRIEND_LIST - "SMSG_FRIEND_STATUS", // SMSG_FRIEND_STATUS - "CMSG_ADD_FRIEND", // CMSG_ADD_FRIEND - "CMSG_DEL_FRIEND", // CMSG_DEL_FRIEND - "SMSG_IGNORE_LIST", // SMSG_IGNORE_LIST - "CMSG_ADD_IGNORE", // CMSG_ADD_IGNORE - "CMSG_DEL_IGNORE", // CMSG_DEL_IGNORE - "CMSG_GROUP_INVITE", // CMSG_GROUP_INVITE - "SMSG_GROUP_INVITE", // SMSG_GROUP_INVITE - "CMSG_GROUP_CANCEL", // CMSG_GROUP_CANCEL - "SMSG_GROUP_CANCEL", // SMSG_GROUP_CANCEL - "CMSG_GROUP_ACCEPT", // CMSG_GROUP_ACCEPT - "CMSG_GROUP_DECLINE", // CMSG_GROUP_DECLINE - "SMSG_GROUP_DECLINE", // SMSG_GROUP_DECLINE - "CMSG_GROUP_UNINVITE", // CMSG_GROUP_UNINVITE - "CMSG_GROUP_UNINVITE_GUID", // CMSG_GROUP_UNINVITE_GUID - "SMSG_GROUP_UNINVITE", // SMSG_GROUP_UNINVITE - "CMSG_GROUP_SET_LEADER", // CMSG_GROUP_SET_LEADER - "SMSG_GROUP_SET_LEADER", // SMSG_GROUP_SET_LEADER - "CMSG_LOOT_METHOD", // CMSG_LOOT_METHOD - "CMSG_GROUP_DISBAND", // CMSG_GROUP_DISBAND - "SMSG_GROUP_DESTROYED", // SMSG_GROUP_DESTROYED - "SMSG_GROUP_LIST", // SMSG_GROUP_LIST - "SMSG_PARTY_MEMBER_STATS", // SMSG_PARTY_MEMBER_STATS - "SMSG_PARTY_COMMAND_RESULT", // SMSG_PARTY_COMMAND_RESULT - "UMSG_UPDATE_GROUP_MEMBERS", // UMSG_UPDATE_GROUP_MEMBERS - "CMSG_GUILD_CREATE", // CMSG_GUILD_CREATE - "CMSG_GUILD_INVITE", // CMSG_GUILD_INVITE - "SMSG_GUILD_INVITE", // SMSG_GUILD_INVITE - "CMSG_GUILD_ACCEPT", // CMSG_GUILD_ACCEPT - "CMSG_GUILD_DECLINE", // CMSG_GUILD_DECLINE - "SMSG_GUILD_DECLINE", // SMSG_GUILD_DECLINE - "CMSG_GUILD_INFO", // CMSG_GUILD_INFO - "SMSG_GUILD_INFO", // SMSG_GUILD_INFO - "CMSG_GUILD_ROSTER", // CMSG_GUILD_ROSTER - "SMSG_GUILD_ROSTER", // SMSG_GUILD_ROSTER - "CMSG_GUILD_PROMOTE", // CMSG_GUILD_PROMOTE - "CMSG_GUILD_DEMOTE", // CMSG_GUILD_DEMOTE - "CMSG_GUILD_LEAVE", // CMSG_GUILD_LEAVE - "CMSG_GUILD_REMOVE", // CMSG_GUILD_REMOVE - "CMSG_GUILD_DISBAND", // CMSG_GUILD_DISBAND - "CMSG_GUILD_LEADER", // CMSG_GUILD_LEADER - "CMSG_GUILD_MOTD", // CMSG_GUILD_MOTD - "SMSG_GUILD_EVENT", // SMSG_GUILD_EVENT - "SMSG_GUILD_COMMAND_RESULT", // SMSG_GUILD_COMMAND_RESULT - "UMSG_UPDATE_GUILD", // UMSG_UPDATE_GUILD - "CMSG_MESSAGECHAT", // CMSG_MESSAGECHAT - "SMSG_MESSAGECHAT", // SMSG_MESSAGECHAT - "CMSG_JOIN_CHANNEL", // CMSG_JOIN_CHANNEL - "CMSG_LEAVE_CHANNEL", // CMSG_LEAVE_CHANNEL - "SMSG_CHANNEL_NOTIFY", // SMSG_CHANNEL_NOTIFY - "CMSG_CHANNEL_LIST", // CMSG_CHANNEL_LIST - "SMSG_CHANNEL_LIST", // SMSG_CHANNEL_LIST - "CMSG_CHANNEL_PASSWORD", // CMSG_CHANNEL_PASSWORD - "CMSG_CHANNEL_SET_OWNER", // CMSG_CHANNEL_SET_OWNER - "CMSG_CHANNEL_OWNER", // CMSG_CHANNEL_OWNER - "CMSG_CHANNEL_MODERATOR", // CMSG_CHANNEL_MODERATOR - "CMSG_CHANNEL_UNMODERATOR", // CMSG_CHANNEL_UNMODERATOR - "CMSG_CHANNEL_MUTE", // CMSG_CHANNEL_MUTE - "CMSG_CHANNEL_UNMUTE", // CMSG_CHANNEL_UNMUTE - "CMSG_CHANNEL_INVITE", // CMSG_CHANNEL_INVITE - "CMSG_CHANNEL_KICK", // CMSG_CHANNEL_KICK - "CMSG_CHANNEL_BAN", // CMSG_CHANNEL_BAN - "CMSG_CHANNEL_UNBAN", // CMSG_CHANNEL_UNBAN - "CMSG_CHANNEL_ANNOUNCEMENTS", // CMSG_CHANNEL_ANNOUNCEMENTS - "CMSG_CHANNEL_MODERATE", // CMSG_CHANNEL_MODERATE - "SMSG_UPDATE_OBJECT", // SMSG_UPDATE_OBJECT - "SMSG_DESTROY_OBJECT", // SMSG_DESTROY_OBJECT - "CMSG_USE_ITEM", // CMSG_USE_ITEM - "CMSG_OPEN_ITEM", // CMSG_OPEN_ITEM - "CMSG_READ_ITEM", // CMSG_READ_ITEM - "SMSG_READ_ITEM_OK", // SMSG_READ_ITEM_OK - "SMSG_READ_ITEM_FAILED", // SMSG_READ_ITEM_FAILED - "SMSG_ITEM_COOLDOWN", // SMSG_ITEM_COOLDOWN - "CMSG_GAMEOBJ_USE", // CMSG_GAMEOBJ_USE - "CMSG_GAMEOBJ_CHAIR_USE_OBSOLETE", // CMSG_GAMEOBJ_CHAIR_USE_OBSOLETE - "SMSG_GAMEOBJECT_CUSTOM_ANIM", // SMSG_GAMEOBJECT_CUSTOM_ANIM - "CMSG_AREATRIGGER", // CMSG_AREATRIGGER - "MSG_MOVE_START_FORWARD", // MSG_MOVE_START_FORWARD - "MSG_MOVE_START_BACKWARD", // MSG_MOVE_START_BACKWARD - "MSG_MOVE_STOP", // MSG_MOVE_STOP - "MSG_MOVE_START_STRAFE_LEFT", // MSG_MOVE_START_STRAFE_LEFT - "MSG_MOVE_START_STRAFE_RIGHT", // MSG_MOVE_START_STRAFE_RIGHT - "MSG_MOVE_STOP_STRAFE", // MSG_MOVE_STOP_STRAFE - "MSG_MOVE_JUMP", // MSG_MOVE_JUMP - "MSG_MOVE_START_TURN_LEFT", // MSG_MOVE_START_TURN_LEFT - "MSG_MOVE_START_TURN_RIGHT", // MSG_MOVE_START_TURN_RIGHT - "MSG_MOVE_STOP_TURN", // MSG_MOVE_STOP_TURN - "MSG_MOVE_START_PITCH_UP", // MSG_MOVE_START_PITCH_UP - "MSG_MOVE_START_PITCH_DOWN", // MSG_MOVE_START_PITCH_DOWN - "MSG_MOVE_STOP_PITCH", // MSG_MOVE_STOP_PITCH - "MSG_MOVE_SET_RUN_MODE", // MSG_MOVE_SET_RUN_MODE - "MSG_MOVE_SET_WALK_MODE", // MSG_MOVE_SET_WALK_MODE - "MSG_MOVE_TOGGLE_LOGGING", // MSG_MOVE_TOGGLE_LOGGING - "MSG_MOVE_TELEPORT", // MSG_MOVE_TELEPORT - "MSG_MOVE_TELEPORT_CHEAT", // MSG_MOVE_TELEPORT_CHEAT - "MSG_MOVE_TELEPORT_ACK", // MSG_MOVE_TELEPORT_ACK - "MSG_MOVE_TOGGLE_FALL_LOGGING", // MSG_MOVE_TOGGLE_FALL_LOGGING - "MSG_MOVE_FALL_LAND", // MSG_MOVE_FALL_LAND - "MSG_MOVE_START_SWIM", // MSG_MOVE_START_SWIM - "MSG_MOVE_STOP_SWIM", // MSG_MOVE_STOP_SWIM - "MSG_MOVE_SET_RUN_SPEED_CHEAT", // MSG_MOVE_SET_RUN_SPEED_CHEAT - "MSG_MOVE_SET_RUN_SPEED", // MSG_MOVE_SET_RUN_SPEED - "MSG_MOVE_SET_RUN_BACK_SPEED_CHEAT", // MSG_MOVE_SET_RUN_BACK_SPEED_CHEAT - "MSG_MOVE_SET_RUN_BACK_SPEED", // MSG_MOVE_SET_RUN_BACK_SPEED - "MSG_MOVE_SET_WALK_SPEED_CHEAT", // MSG_MOVE_SET_WALK_SPEED_CHEAT - "MSG_MOVE_SET_WALK_SPEED", // MSG_MOVE_SET_WALK_SPEED - "MSG_MOVE_SET_SWIM_SPEED_CHEAT", // MSG_MOVE_SET_SWIM_SPEED_CHEAT - "MSG_MOVE_SET_SWIM_SPEED", // MSG_MOVE_SET_SWIM_SPEED - "MSG_MOVE_SET_SWIM_BACK_SPEED_CHEAT", // MSG_MOVE_SET_SWIM_BACK_SPEED_CHEAT - "MSG_MOVE_SET_SWIM_BACK_SPEED", // MSG_MOVE_SET_SWIM_BACK_SPEED - "MSG_MOVE_SET_ALL_SPEED_CHEAT", // MSG_MOVE_SET_ALL_SPEED_CHEAT - "MSG_MOVE_SET_TURN_RATE_CHEAT", // MSG_MOVE_SET_TURN_RATE_CHEAT - "MSG_MOVE_SET_TURN_RATE", // MSG_MOVE_SET_TURN_RATE - "MSG_MOVE_TOGGLE_COLLISION_CHEAT", // MSG_MOVE_TOGGLE_COLLISION_CHEAT - "MSG_MOVE_SET_FACING", // MSG_MOVE_SET_FACING - "MSG_MOVE_SET_PITCH", // MSG_MOVE_SET_PITCH - "MSG_MOVE_WORLDPORT_ACK", // MSG_MOVE_WORLDPORT_ACK - "SMSG_MONSTER_MOVE", // SMSG_MONSTER_MOVE - "SMSG_MOVE_WATER_WALK", // SMSG_MOVE_WATER_WALK - "SMSG_MOVE_LAND_WALK", // SMSG_MOVE_LAND_WALK - "MSG_MOVE_SET_RAW_POSITION_ACK", // MSG_MOVE_SET_RAW_POSITION_ACK - "CMSG_MOVE_SET_RAW_POSITION", // CMSG_MOVE_SET_RAW_POSITION - "SMSG_FORCE_RUN_SPEED_CHANGE", // SMSG_FORCE_RUN_SPEED_CHANGE - "CMSG_FORCE_RUN_SPEED_CHANGE_ACK", // CMSG_FORCE_RUN_SPEED_CHANGE_ACK - "SMSG_FORCE_RUN_BACK_SPEED_CHANGE", // SMSG_FORCE_RUN_BACK_SPEED_CHANGE - "CMSG_FORCE_RUN_BACK_SPEED_CHANGE_ACK", // CMSG_FORCE_RUN_BACK_SPEED_CHANGE_ACK - "SMSG_FORCE_SWIM_SPEED_CHANGE", // SMSG_FORCE_SWIM_SPEED_CHANGE - "CMSG_FORCE_SWIM_SPEED_CHANGE_ACK", // CMSG_FORCE_SWIM_SPEED_CHANGE_ACK - "SMSG_FORCE_MOVE_ROOT", // SMSG_FORCE_MOVE_ROOT - "CMSG_FORCE_MOVE_ROOT_ACK", // CMSG_FORCE_MOVE_ROOT_ACK - "SMSG_FORCE_MOVE_UNROOT", // SMSG_FORCE_MOVE_UNROOT - "CMSG_FORCE_MOVE_UNROOT_ACK", // CMSG_FORCE_MOVE_UNROOT_ACK - "MSG_MOVE_ROOT", // MSG_MOVE_ROOT - "MSG_MOVE_UNROOT", // MSG_MOVE_UNROOT - "MSG_MOVE_HEARTBEAT", // MSG_MOVE_HEARTBEAT - "SMSG_MOVE_KNOCK_BACK", // SMSG_MOVE_KNOCK_BACK - "CMSG_MOVE_KNOCK_BACK_ACK", // CMSG_MOVE_KNOCK_BACK_ACK - "MSG_MOVE_KNOCK_BACK", // MSG_MOVE_KNOCK_BACK - "SMSG_MOVE_FEATHER_FALL", // SMSG_MOVE_FEATHER_FALL - "SMSG_MOVE_NORMAL_FALL", // SMSG_MOVE_NORMAL_FALL - "SMSG_MOVE_SET_HOVER", // SMSG_MOVE_SET_HOVER - "SMSG_MOVE_UNSET_HOVER", // SMSG_MOVE_UNSET_HOVER - "CMSG_MOVE_HOVER_ACK", // CMSG_MOVE_HOVER_ACK - "MSG_MOVE_HOVER", // MSG_MOVE_HOVER - "CMSG_TRIGGER_CINEMATIC_CHEAT", // CMSG_TRIGGER_CINEMATIC_CHEAT - "CMSG_OPENING_CINEMATIC", // CMSG_OPENING_CINEMATIC - "SMSG_TRIGGER_CINEMATIC", // SMSG_TRIGGER_CINEMATIC - "CMSG_NEXT_CINEMATIC_CAMERA", // CMSG_NEXT_CINEMATIC_CAMERA - "CMSG_COMPLETE_CINEMATIC", // CMSG_COMPLETE_CINEMATIC - "SMSG_TUTORIAL_FLAGS", // SMSG_TUTORIAL_FLAGS - "CMSG_TUTORIAL_FLAG", // CMSG_TUTORIAL_FLAG - "CMSG_TUTORIAL_CLEAR", // CMSG_TUTORIAL_CLEAR - "CMSG_TUTORIAL_RESET", // CMSG_TUTORIAL_RESET - "CMSG_STANDSTATECHANGE", // CMSG_STANDSTATECHANGE - "CMSG_EMOTE", // CMSG_EMOTE - "SMSG_EMOTE", // SMSG_EMOTE - "CMSG_TEXT_EMOTE", // CMSG_TEXT_EMOTE - "SMSG_TEXT_EMOTE", // SMSG_TEXT_EMOTE - "CMSG_AUTOEQUIP_GROUND_ITEM", // CMSG_AUTOEQUIP_GROUND_ITEM - "CMSG_AUTOSTORE_GROUND_ITEM", // CMSG_AUTOSTORE_GROUND_ITEM - "CMSG_AUTOSTORE_LOOT_ITEM", // CMSG_AUTOSTORE_LOOT_ITEM - "CMSG_STORE_LOOT_IN_SLOT", // CMSG_STORE_LOOT_IN_SLOT - "CMSG_AUTOEQUIP_ITEM", // CMSG_AUTOEQUIP_ITEM - "CMSG_AUTOSTORE_BAG_ITEM", // CMSG_AUTOSTORE_BAG_ITEM - "CMSG_SWAP_ITEM", // CMSG_SWAP_ITEM - "CMSG_SWAP_INV_ITEM", // CMSG_SWAP_INV_ITEM - "CMSG_SPLIT_ITEM", // CMSG_SPLIT_ITEM - "CMSG_PICKUP_ITEM", // CMSG_PICKUP_ITEM - "CMSG_DROP_ITEM", // CMSG_DROP_ITEM - "CMSG_DESTROYITEM", // CMSG_DESTROYITEM - "SMSG_INVENTORY_CHANGE_FAILURE", // SMSG_INVENTORY_CHANGE_FAILURE - "SMSG_OPEN_CONTAINER", // SMSG_OPEN_CONTAINER - "CMSG_INSPECT", // CMSG_INSPECT - "SMSG_INSPECT", // SMSG_INSPECT - "CMSG_INITIATE_TRADE", // CMSG_INITIATE_TRADE - "CMSG_BEGIN_TRADE", // CMSG_BEGIN_TRADE - "CMSG_BUSY_TRADE", // CMSG_BUSY_TRADE - "CMSG_IGNORE_TRADE", // CMSG_IGNORE_TRADE - "CMSG_ACCEPT_TRADE", // CMSG_ACCEPT_TRADE - "CMSG_UNACCEPT_TRADE", // CMSG_UNACCEPT_TRADE - "CMSG_CANCEL_TRADE", // CMSG_CANCEL_TRADE - "CMSG_SET_TRADE_ITEM", // CMSG_SET_TRADE_ITEM - "CMSG_CLEAR_TRADE_ITEM", // CMSG_CLEAR_TRADE_ITEM - "CMSG_SET_TRADE_GOLD", // CMSG_SET_TRADE_GOLD - "SMSG_TRADE_STATUS", // SMSG_TRADE_STATUS - "SMSG_TRADE_STATUS_EXTENDED", // SMSG_TRADE_STATUS_EXTENDED - "SMSG_INITIALIZE_FACTIONS", // SMSG_INITIALIZE_FACTIONS - "SMSG_SET_FACTION_VISIBLE", // SMSG_SET_FACTION_VISIBLE - "SMSG_SET_FACTION_STANDING", // SMSG_SET_FACTION_STANDING - "CMSG_SET_FACTION_ATWAR", // CMSG_SET_FACTION_ATWAR - "CMSG_SET_FACTION_CHEAT", // CMSG_SET_FACTION_CHEAT - "SMSG_SET_PROFICIENCY", // SMSG_SET_PROFICIENCY - "CMSG_SET_ACTION_BUTTON", // CMSG_SET_ACTION_BUTTON - "SMSG_ACTION_BUTTONS", // SMSG_ACTION_BUTTONS - "SMSG_INITIAL_SPELLS", // SMSG_INITIAL_SPELLS - "SMSG_LEARNED_SPELL", // SMSG_LEARNED_SPELL - "SMSG_SUPERCEDED_SPELL", // SMSG_SUPERCEDED_SPELL - "CMSG_NEW_SPELL_SLOT", // CMSG_NEW_SPELL_SLOT - "CMSG_CAST_SPELL", // CMSG_CAST_SPELL - "CMSG_CANCEL_CAST", // CMSG_CANCEL_CAST - "SMSG_CAST_RESULT", // SMSG_CAST_RESULT - "SMSG_SPELL_START", // SMSG_SPELL_START - "SMSG_SPELL_GO", // SMSG_SPELL_GO - "SMSG_SPELL_FAILURE", // SMSG_SPELL_FAILURE - "SMSG_SPELL_COOLDOWN", // SMSG_SPELL_COOLDOWN - "SMSG_COOLDOWN_EVENT", // SMSG_COOLDOWN_EVENT - "CMSG_CANCEL_AURA", // CMSG_CANCEL_AURA - "SMSG_UPDATE_AURA_DURATION", // SMSG_UPDATE_AURA_DURATION - "SMSG_PET_CAST_FAILED", // SMSG_PET_CAST_FAILED - "MSG_CHANNEL_START", // MSG_CHANNEL_START - "MSG_CHANNEL_UPDATE", // MSG_CHANNEL_UPDATE - "CMSG_CANCEL_CHANNELLING", // CMSG_CANCEL_CHANNELLING - "SMSG_AI_REACTION", // SMSG_AI_REACTION - "CMSG_SET_SELECTION", // CMSG_SET_SELECTION - "CMSG_SET_TARGET_OBSOLETE", // CMSG_SET_TARGET_OBSOLETE - "CMSG_UNUSED", // CMSG_UNUSED - "CMSG_UNUSED2", // CMSG_UNUSED2 - "CMSG_ATTACKSWING", // CMSG_ATTACKSWING - "CMSG_ATTACKSTOP", // CMSG_ATTACKSTOP - "SMSG_ATTACKSTART", // SMSG_ATTACKSTART - "SMSG_ATTACKSTOP", // SMSG_ATTACKSTOP - "SMSG_ATTACKSWING_NOTINRANGE", // SMSG_ATTACKSWING_NOTINRANGE - "SMSG_ATTACKSWING_BADFACING", // SMSG_ATTACKSWING_BADFACING - "SMSG_ATTACKSWING_NOTSTANDING", // SMSG_ATTACKSWING_NOTSTANDING - "SMSG_ATTACKSWING_DEADTARGET", // SMSG_ATTACKSWING_DEADTARGET - "SMSG_ATTACKSWING_CANT_ATTACK", // SMSG_ATTACKSWING_CANT_ATTACK - "SMSG_ATTACKERSTATEUPDATE", // SMSG_ATTACKERSTATEUPDATE - "SMSG_VICTIMSTATEUPDATE_OBSOLETE", // SMSG_VICTIMSTATEUPDATE_OBSOLETE - "SMSG_DAMAGE_DONE_OBSOLETE", // SMSG_DAMAGE_DONE_OBSOLETE - "SMSG_DAMAGE_TAKEN_OBSOLETE", // SMSG_DAMAGE_TAKEN_OBSOLETE - "SMSG_CANCEL_COMBAT", // SMSG_CANCEL_COMBAT - "SMSG_PLAYER_COMBAT_XP_GAIN_OBSOLETE", // SMSG_PLAYER_COMBAT_XP_GAIN_OBSOLETE - "SMSG_HEALSPELL_ON_PLAYER_OBSOLETE", // SMSG_HEALSPELL_ON_PLAYER_OBSOLETE - "SMSG_HEALSPELL_ON_PLAYERS_PET_OBSOLETE", // SMSG_HEALSPELL_ON_PLAYERS_PET_OBSOLETE - "CMSG_SHEATHE_OBSOLETE", // CMSG_SHEATHE_OBSOLETE - "CMSG_SAVE_PLAYER", // CMSG_SAVE_PLAYER - "CMSG_SETDEATHBINDPOINT", // CMSG_SETDEATHBINDPOINT - "SMSG_BINDPOINTUPDATE", // SMSG_BINDPOINTUPDATE - "CMSG_GETDEATHBINDZONE", // CMSG_GETDEATHBINDZONE - "SMSG_BINDZONEREPLY", // SMSG_BINDZONEREPLY - "SMSG_PLAYERBOUND", // SMSG_PLAYERBOUND - "SMSG_DEATH_NOTIFY_OBSOLETE", // SMSG_DEATH_NOTIFY_OBSOLETE - "CMSG_REPOP_REQUEST", // CMSG_REPOP_REQUEST - "SMSG_RESURRECT_REQUEST", // SMSG_RESURRECT_REQUEST - "CMSG_RESURRECT_RESPONSE", // CMSG_RESURRECT_RESPONSE - "CMSG_LOOT", // CMSG_LOOT - "CMSG_LOOT_MONEY", // CMSG_LOOT_MONEY - "CMSG_LOOT_RELEASE", // CMSG_LOOT_RELEASE - "SMSG_LOOT_RESPONSE", // SMSG_LOOT_RESPONSE - "SMSG_LOOT_RELEASE_RESPONSE", // SMSG_LOOT_RELEASE_RESPONSE - "SMSG_LOOT_REMOVED", // SMSG_LOOT_REMOVED - "SMSG_LOOT_MONEY_NOTIFY", // SMSG_LOOT_MONEY_NOTIFY - "SMSG_LOOT_ITEM_NOTIFY", // SMSG_LOOT_ITEM_NOTIFY - "SMSG_LOOT_CLEAR_MONEY", // SMSG_LOOT_CLEAR_MONEY - "SMSG_ITEM_PUSH_RESULT", // SMSG_ITEM_PUSH_RESULT - "SMSG_DUEL_REQUESTED", // SMSG_DUEL_REQUESTED - "SMSG_DUEL_OUTOFBOUNDS", // SMSG_DUEL_OUTOFBOUNDS - "SMSG_DUEL_INBOUNDS", // SMSG_DUEL_INBOUNDS - "SMSG_DUEL_COMPLETE", // SMSG_DUEL_COMPLETE - "SMSG_DUEL_WINNER", // SMSG_DUEL_WINNER - "CMSG_DUEL_ACCEPTED", // CMSG_DUEL_ACCEPTED - "CMSG_DUEL_CANCELLED", // CMSG_DUEL_CANCELLED - "SMSG_MOUNTRESULT", // SMSG_MOUNTRESULT - "SMSG_DISMOUNTRESULT", // SMSG_DISMOUNTRESULT - "SMSG_PUREMOUNT_CANCELLED_OBSOLETE", // SMSG_PUREMOUNT_CANCELLED_OBSOLETE - "CMSG_MOUNTSPECIAL_ANIM", // CMSG_MOUNTSPECIAL_ANIM - "SMSG_MOUNTSPECIAL_ANIM", // SMSG_MOUNTSPECIAL_ANIM - "SMSG_PET_TAME_FAILURE", // SMSG_PET_TAME_FAILURE - "CMSG_PET_SET_ACTION", // CMSG_PET_SET_ACTION - "CMSG_PET_ACTION", // CMSG_PET_ACTION - "CMSG_PET_ABANDON", // CMSG_PET_ABANDON - "CMSG_PET_RENAME", // CMSG_PET_RENAME - "SMSG_PET_NAME_INVALID", // SMSG_PET_NAME_INVALID - "SMSG_PET_SPELLS", // SMSG_PET_SPELLS - "SMSG_PET_MODE", // SMSG_PET_MODE - "CMSG_GOSSIP_HELLO", // CMSG_GOSSIP_HELLO - "CMSG_GOSSIP_SELECT_OPTION", // CMSG_GOSSIP_SELECT_OPTION - "SMSG_GOSSIP_MESSAGE", // SMSG_GOSSIP_MESSAGE - "SMSG_GOSSIP_COMPLETE", // SMSG_GOSSIP_COMPLETE - "CMSG_NPC_TEXT_QUERY", // CMSG_NPC_TEXT_QUERY - "SMSG_NPC_TEXT_UPDATE", // SMSG_NPC_TEXT_UPDATE - "SMSG_NPC_WONT_TALK", // SMSG_NPC_WONT_TALK - "CMSG_QUESTGIVER_STATUS_QUERY", // CMSG_QUESTGIVER_STATUS_QUERY - "SMSG_QUESTGIVER_STATUS", // SMSG_QUESTGIVER_STATUS - "CMSG_QUESTGIVER_HELLO", // CMSG_QUESTGIVER_HELLO - "SMSG_QUESTGIVER_QUEST_LIST", // SMSG_QUESTGIVER_QUEST_LIST - "CMSG_QUESTGIVER_QUERY_QUEST", // CMSG_QUESTGIVER_QUERY_QUEST - "CMSG_QUESTGIVER_QUEST_AUTOLAUNCH", // CMSG_QUESTGIVER_QUEST_AUTOLAUNCH - "SMSG_QUESTGIVER_QUEST_DETAILS", // SMSG_QUESTGIVER_QUEST_DETAILS - "CMSG_QUESTGIVER_ACCEPT_QUEST", // CMSG_QUESTGIVER_ACCEPT_QUEST - "CMSG_QUESTGIVER_COMPLETE_QUEST", // CMSG_QUESTGIVER_COMPLETE_QUEST - "SMSG_QUESTGIVER_REQUEST_ITEMS", // SMSG_QUESTGIVER_REQUEST_ITEMS - "CMSG_QUESTGIVER_REQUEST_REWARD", // CMSG_QUESTGIVER_REQUEST_REWARD - "SMSG_QUESTGIVER_OFFER_REWARD", // SMSG_QUESTGIVER_OFFER_REWARD - "CMSG_QUESTGIVER_CHOOSE_REWARD", // CMSG_QUESTGIVER_CHOOSE_REWARD - "SMSG_QUESTGIVER_QUEST_INVALID", // SMSG_QUESTGIVER_QUEST_INVALID - "CMSG_QUESTGIVER_CANCEL", // CMSG_QUESTGIVER_CANCEL - "SMSG_QUESTGIVER_QUEST_COMPLETE", // SMSG_QUESTGIVER_QUEST_COMPLETE - "SMSG_QUESTGIVER_QUEST_FAILED", // SMSG_QUESTGIVER_QUEST_FAILED - "CMSG_QUESTLOG_SWAP_QUEST", // CMSG_QUESTLOG_SWAP_QUEST - "CMSG_QUESTLOG_REMOVE_QUEST", // CMSG_QUESTLOG_REMOVE_QUEST - "SMSG_QUESTLOG_FULL", // SMSG_QUESTLOG_FULL - "SMSG_QUESTUPDATE_FAILED", // SMSG_QUESTUPDATE_FAILED - "SMSG_QUESTUPDATE_FAILEDTIMER", // SMSG_QUESTUPDATE_FAILEDTIMER - "SMSG_QUESTUPDATE_COMPLETE", // SMSG_QUESTUPDATE_COMPLETE - "SMSG_QUESTUPDATE_ADD_KILL", // SMSG_QUESTUPDATE_ADD_KILL - "SMSG_QUESTUPDATE_ADD_ITEM", // SMSG_QUESTUPDATE_ADD_ITEM - "CMSG_QUEST_CONFIRM_ACCEPT", // CMSG_QUEST_CONFIRM_ACCEPT - "SMSG_QUEST_CONFIRM_ACCEPT", // SMSG_QUEST_CONFIRM_ACCEPT - "CMSG_PUSHQUESTTOPARTY", // CMSG_PUSHQUESTTOPARTY - "CMSG_LIST_INVENTORY", // CMSG_LIST_INVENTORY - "SMSG_LIST_INVENTORY", // SMSG_LIST_INVENTORY - "CMSG_SELL_ITEM", // CMSG_SELL_ITEM - "SMSG_SELL_ITEM", // SMSG_SELL_ITEM - "CMSG_BUY_ITEM", // CMSG_BUY_ITEM - "CMSG_BUY_ITEM_IN_SLOT", // CMSG_BUY_ITEM_IN_SLOT - "SMSG_BUY_ITEM", // SMSG_BUY_ITEM - "SMSG_BUY_FAILED", // SMSG_BUY_FAILED - "CMSG_TAXICLEARALLNODES", // CMSG_TAXICLEARALLNODES - "CMSG_TAXIENABLEALLNODES", // CMSG_TAXIENABLEALLNODES - "CMSG_TAXISHOWNODES", // CMSG_TAXISHOWNODES - "SMSG_SHOWTAXINODES", // SMSG_SHOWTAXINODES - "CMSG_TAXINODE_STATUS_QUERY", // CMSG_TAXINODE_STATUS_QUERY - "SMSG_TAXINODE_STATUS", // SMSG_TAXINODE_STATUS - "CMSG_TAXIQUERYAVAILABLENODES", // CMSG_TAXIQUERYAVAILABLENODES - "CMSG_ACTIVATETAXI", // CMSG_ACTIVATETAXI - "SMSG_ACTIVATETAXIREPLY", // SMSG_ACTIVATETAXIREPLY - "SMSG_NEW_TAXI_PATH", // SMSG_NEW_TAXI_PATH - "CMSG_TRAINER_LIST", // CMSG_TRAINER_LIST - "SMSG_TRAINER_LIST", // SMSG_TRAINER_LIST - "CMSG_TRAINER_BUY_SPELL", // CMSG_TRAINER_BUY_SPELL - "SMSG_TRAINER_BUY_SUCCEEDED", // SMSG_TRAINER_BUY_SUCCEEDED - "SMSG_TRAINER_BUY_FAILED", // SMSG_TRAINER_BUY_FAILED - "CMSG_BINDER_ACTIVATE", // CMSG_BINDER_ACTIVATE - "SMSG_PLAYERBINDERROR", // SMSG_PLAYERBINDERROR - "CMSG_BANKER_ACTIVATE", // CMSG_BANKER_ACTIVATE - "SMSG_SHOW_BANK", // SMSG_SHOW_BANK - "CMSG_BUY_BANK_SLOT", // CMSG_BUY_BANK_SLOT - "SMSG_BUY_BANK_SLOT_RESULT", // SMSG_BUY_BANK_SLOT_RESULT - "CMSG_PETITION_SHOWLIST", // CMSG_PETITION_SHOWLIST - "SMSG_PETITION_SHOWLIST", // SMSG_PETITION_SHOWLIST - "CMSG_PETITION_BUY", // CMSG_PETITION_BUY - "CMSG_PETITION_SHOW_SIGNATURES", // CMSG_PETITION_SHOW_SIGNATURES - "SMSG_PETITION_SHOW_SIGNATURES", // SMSG_PETITION_SHOW_SIGNATURES - "CMSG_PETITION_SIGN", // CMSG_PETITION_SIGN - "SMSG_PETITION_SIGN_RESULTS", // SMSG_PETITION_SIGN_RESULTS - "MSG_PETITION_DECLINE", // MSG_PETITION_DECLINE - "CMSG_OFFER_PETITION", // CMSG_OFFER_PETITION - "CMSG_TURN_IN_PETITION", // CMSG_TURN_IN_PETITION - "SMSG_TURN_IN_PETITION_RESULTS", // SMSG_TURN_IN_PETITION_RESULTS - "CMSG_PETITION_QUERY", // CMSG_PETITION_QUERY - "SMSG_PETITION_QUERY_RESPONSE", // SMSG_PETITION_QUERY_RESPONSE - "SMSG_FISH_NOT_HOOKED", // SMSG_FISH_NOT_HOOKED - "SMSG_FISH_ESCAPED", // SMSG_FISH_ESCAPED - "CMSG_BUG", // CMSG_BUG - "SMSG_NOTIFICATION", // SMSG_NOTIFICATION - "CMSG_PLAYED_TIME", // CMSG_PLAYED_TIME - "SMSG_PLAYED_TIME", // SMSG_PLAYED_TIME - "CMSG_QUERY_TIME", // CMSG_QUERY_TIME - "SMSG_QUERY_TIME_RESPONSE", // SMSG_QUERY_TIME_RESPONSE - "SMSG_LOG_XPGAIN", // SMSG_LOG_XPGAIN - "MSG_SPLIT_MONEY", // MSG_SPLIT_MONEY - "CMSG_RECLAIM_CORPSE", // CMSG_RECLAIM_CORPSE - "CMSG_WRAP_ITEM", // CMSG_WRAP_ITEM - "SMSG_LEVELUP_INFO", // SMSG_LEVELUP_INFO - "MSG_MINIMAP_PING", // MSG_MINIMAP_PING - "SMSG_RESISTLOG", // SMSG_RESISTLOG - "SMSG_ENCHANTMENTLOG", // SMSG_ENCHANTMENTLOG - "CMSG_SET_SKILL_CHEAT", // CMSG_SET_SKILL_CHEAT - "SMSG_START_MIRROR_TIMER", // SMSG_START_MIRROR_TIMER - "SMSG_PAUSE_MIRROR_TIMER", // SMSG_PAUSE_MIRROR_TIMER - "SMSG_STOP_MIRROR_TIMER", // SMSG_STOP_MIRROR_TIMER - "CMSG_PING", // CMSG_PING - "SMSG_PONG", // SMSG_PONG - "SMSG_CLEAR_COOLDOWN", // SMSG_CLEAR_COOLDOWN - "SMSG_GAMEOBJECT_PAGETEXT", // SMSG_GAMEOBJECT_PAGETEXT - "CMSG_SETSHEATHED", // CMSG_SETSHEATHED - "SMSG_COOLDOWN_CHEAT", // SMSG_COOLDOWN_CHEAT - "SMSG_SPELL_DELAYED", // SMSG_SPELL_DELAYED - "CMSG_PLAYER_MACRO_OBSOLETE", // CMSG_PLAYER_MACRO_OBSOLETE - "SMSG_PLAYER_MACRO_OBSOLETE", // SMSG_PLAYER_MACRO_OBSOLETE - "CMSG_GHOST", // CMSG_GHOST - "CMSG_GM_INVIS", // CMSG_GM_INVIS - "SMSG_INVALID_PROMOTION_CODE", // SMSG_INVALID_PROMOTION_CODE - "MSG_GM_BIND_OTHER", // MSG_GM_BIND_OTHER - "MSG_GM_SUMMON", // MSG_GM_SUMMON - "SMSG_ITEM_TIME_UPDATE", // SMSG_ITEM_TIME_UPDATE - "SMSG_ITEM_ENCHANT_TIME_UPDATE", // SMSG_ITEM_ENCHANT_TIME_UPDATE - "SMSG_AUTH_CHALLENGE", // SMSG_AUTH_CHALLENGE - "CMSG_AUTH_SESSION", // CMSG_AUTH_SESSION - "SMSG_AUTH_RESPONSE", // SMSG_AUTH_RESPONSE - "MSG_GM_SHOWLABEL", // MSG_GM_SHOWLABEL - "MSG_ADD_DYNAMIC_TARGET_OBSOLETE", // MSG_ADD_DYNAMIC_TARGET_OBSOLETE - "MSG_SAVE_GUILD_EMBLEM", // MSG_SAVE_GUILD_EMBLEM - "MSG_TABARDVENDOR_ACTIVATE", // MSG_TABARDVENDOR_ACTIVATE - "SMSG_PLAY_SPELL_VISUAL", // SMSG_PLAY_SPELL_VISUAL - "CMSG_ZONEUPDATE", // CMSG_ZONEUPDATE - "SMSG_PARTYKILLLOG", // SMSG_PARTYKILLLOG - "SMSG_COMPRESSED_UPDATE_OBJECT", // SMSG_COMPRESSED_UPDATE_OBJECT - "SMSG_OBSOLETE", // SMSG_OBSOLETE - "SMSG_EXPLORATION_EXPERIENCE", // SMSG_EXPLORATION_EXPERIENCE - "CMSG_GM_SET_SECURITY_GROUP", // CMSG_GM_SET_SECURITY_GROUP - "CMSG_GM_NUKE", // CMSG_GM_NUKE - "MSG_RANDOM_ROLL", // MSG_RANDOM_ROLL - "SMSG_ENVIRONMENTALDAMAGELOG", // SMSG_ENVIRONMENTALDAMAGELOG - "CMSG_RWHOIS", // CMSG_RWHOIS - "SMSG_RWHOIS", // SMSG_RWHOIS - "MSG_LOOKING_FOR_GROUP", // MSG_LOOKING_FOR_GROUP - "CMSG_SET_LOOKING_FOR_GROUP", // CMSG_SET_LOOKING_FOR_GROUP - "CMSG_UNLEARN_SPELL", // CMSG_UNLEARN_SPELL - "CMSG_UNLEARN_SKILL", // CMSG_UNLEARN_SKILL - "SMSG_REMOVED_SPELL", // SMSG_REMOVED_SPELL - "CMSG_DECHARGE", // CMSG_DECHARGE - "CMSG_GMTICKET_CREATE", // CMSG_GMTICKET_CREATE - "SMSG_GMTICKET_CREATE", // SMSG_GMTICKET_CREATE - "CMSG_GMTICKET_UPDATETEXT", // CMSG_GMTICKET_UPDATETEXT - "SMSG_GMTICKET_UPDATETEXT", // SMSG_GMTICKET_UPDATETEXT - "SMSG_ACCOUNT_DATA_MD5", // SMSG_ACCOUNT_DATA_MD5 - "CMSG_REQUEST_ACCOUNT_DATA", // CMSG_REQUEST_ACCOUNT_DATA - "CMSG_UPDATE_ACCOUNT_DATA", // CMSG_UPDATE_ACCOUNT_DATA - "SMSG_UPDATE_ACCOUNT_DATA", // SMSG_UPDATE_ACCOUNT_DATA - "SMSG_CLEAR_FAR_SIGHT_IMMEDIATE", // SMSG_CLEAR_FAR_SIGHT_IMMEDIATE - "SMSG_POWERGAINLOG_OBSOLETE", // SMSG_POWERGAINLOG_OBSOLETE - "CMSG_GM_TEACH", // CMSG_GM_TEACH - "CMSG_GM_CREATE_ITEM_TARGET", // CMSG_GM_CREATE_ITEM_TARGET - "CMSG_GMTICKET_GETTICKET", // CMSG_GMTICKET_GETTICKET - "SMSG_GMTICKET_GETTICKET", // SMSG_GMTICKET_GETTICKET - "CMSG_UNLEARN_TALENTS", // CMSG_UNLEARN_TALENTS - "SMSG_GAMEOBJECT_SPAWN_ANIM", // SMSG_GAMEOBJECT_SPAWN_ANIM - "SMSG_GAMEOBJECT_DESPAWN_ANIM", // SMSG_GAMEOBJECT_DESPAWN_ANIM - "MSG_CORPSE_QUERY", // MSG_CORPSE_QUERY - "CMSG_GMTICKET_DELETETICKET", // CMSG_GMTICKET_DELETETICKET - "SMSG_GMTICKET_DELETETICKET", // SMSG_GMTICKET_DELETETICKET - "SMSG_CHAT_WRONG_FACTION", // SMSG_CHAT_WRONG_FACTION - "CMSG_GMTICKET_SYSTEMSTATUS", // CMSG_GMTICKET_SYSTEMSTATUS - "SMSG_GMTICKET_SYSTEMSTATUS", // SMSG_GMTICKET_SYSTEMSTATUS - "CMSG_SPIRIT_HEALER_ACTIVATE", // CMSG_SPIRIT_HEALER_ACTIVATE - "CMSG_SET_STAT_CHEAT", // CMSG_SET_STAT_CHEAT - "SMSG_SET_REST_START", // SMSG_SET_REST_START - "CMSG_SKILL_BUY_STEP", // CMSG_SKILL_BUY_STEP - "CMSG_SKILL_BUY_RANK", // CMSG_SKILL_BUY_RANK - "CMSG_XP_CHEAT", // CMSG_XP_CHEAT - "SMSG_SPIRIT_HEALER_CONFIRM", // SMSG_SPIRIT_HEALER_CONFIRM - "CMSG_CHARACTER_POINT_CHEAT", // CMSG_CHARACTER_POINT_CHEAT - "SMSG_GOSSIP_POI", // SMSG_GOSSIP_POI - "CMSG_CHAT_IGNORED", // CMSG_CHAT_IGNORED - "CMSG_GM_VISION", // CMSG_GM_VISION - "CMSG_SERVER_COMMAND", // CMSG_SERVER_COMMAND - "CMSG_GM_SILENCE", // CMSG_GM_SILENCE - "CMSG_GM_REVEALTO", // CMSG_GM_REVEALTO - "CMSG_GM_RESURRECT", // CMSG_GM_RESURRECT - "CMSG_GM_SUMMONMOB", // CMSG_GM_SUMMONMOB - "CMSG_GM_MOVECORPSE", // CMSG_GM_MOVECORPSE - "CMSG_GM_FREEZE", // CMSG_GM_FREEZE - "CMSG_GM_UBERINVIS", // CMSG_GM_UBERINVIS - "CMSG_GM_REQUEST_PLAYER_INFO", // CMSG_GM_REQUEST_PLAYER_INFO - "SMSG_GM_PLAYER_INFO", // SMSG_GM_PLAYER_INFO - "CMSG_GUILD_RANK", // CMSG_GUILD_RANK - "CMSG_GUILD_ADD_RANK", // CMSG_GUILD_ADD_RANK - "CMSG_GUILD_DEL_RANK", // CMSG_GUILD_DEL_RANK - "CMSG_GUILD_SET_PUBLIC_NOTE", // CMSG_GUILD_SET_PUBLIC_NOTE - "CMSG_GUILD_SET_OFFICER_NOTE", // CMSG_GUILD_SET_OFFICER_NOTE - "SMSG_LOGIN_VERIFY_WORLD", // SMSG_LOGIN_VERIFY_WORLD - "CMSG_CLEAR_EXPLORATION", // CMSG_CLEAR_EXPLORATION - "CMSG_SEND_MAIL", // CMSG_SEND_MAIL - "SMSG_SEND_MAIL_RESULT", // SMSG_SEND_MAIL_RESULT - "CMSG_GET_MAIL_LIST", // CMSG_GET_MAIL_LIST - "SMSG_MAIL_LIST_RESULT", // SMSG_MAIL_LIST_RESULT - "CMSG_BATTLEFIELD_LIST", // CMSG_BATTLEFIELD_LIST - "SMSG_BATTLEFIELD_LIST", // SMSG_BATTLEFIELD_LIST - "CMSG_BATTLEFIELD_JOIN", // CMSG_BATTLEFIELD_JOIN - "SMSG_BATTLEFIELD_WIN", // SMSG_BATTLEFIELD_WIN - "SMSG_BATTLEFIELD_LOSE", // SMSG_BATTLEFIELD_LOSE - "CMSG_TAXICLEARNODE", // CMSG_TAXICLEARNODE - "CMSG_TAXIENABLENODE", // CMSG_TAXIENABLENODE - "CMSG_ITEM_TEXT_QUERY", // CMSG_ITEM_TEXT_QUERY - "SMSG_ITEM_TEXT_QUERY_RESPONSE", // SMSG_ITEM_TEXT_QUERY_RESPONSE - "CMSG_MAIL_TAKE_MONEY", // CMSG_MAIL_TAKE_MONEY - "CMSG_MAIL_TAKE_ITEM", // CMSG_MAIL_TAKE_ITEM - "CMSG_MAIL_MARK_AS_READ", // CMSG_MAIL_MARK_AS_READ - "CMSG_MAIL_RETURN_TO_SENDER", // CMSG_MAIL_RETURN_TO_SENDER - "CMSG_MAIL_DELETE", // CMSG_MAIL_DELETE - "CMSG_MAIL_CREATE_TEXT_ITEM", // CMSG_MAIL_CREATE_TEXT_ITEM - "SMSG_SPELLLOGMISS", // SMSG_SPELLLOGMISS - "SMSG_SPELLLOGEXECUTE", // SMSG_SPELLLOGEXECUTE - "SMSG_DEBUGAURAPROC", // SMSG_DEBUGAURAPROC - "SMSG_PERIODICAURALOG", // SMSG_PERIODICAURALOG - "SMSG_SPELLDAMAGESHIELD", // SMSG_SPELLDAMAGESHIELD - "SMSG_SPELLNONMELEEDAMAGELOG", // SMSG_SPELLNONMELEEDAMAGELOG - "CMSG_LEARN_TALENT", // CMSG_LEARN_TALENT - "SMSG_RESURRECT_FAILED", // SMSG_RESURRECT_FAILED - "CMSG_TOGGLE_PVP", // CMSG_TOGGLE_PVP - "SMSG_ZONE_UNDER_ATTACK", // SMSG_ZONE_UNDER_ATTACK - "MSG_AUCTION_HELLO", // MSG_AUCTION_HELLO - "CMSG_AUCTION_SELL_ITEM", // CMSG_AUCTION_SELL_ITEM - "CMSG_AUCTION_REMOVE_ITEM", // CMSG_AUCTION_REMOVE_ITEM - "CMSG_AUCTION_LIST_ITEMS", // CMSG_AUCTION_LIST_ITEMS - "CMSG_AUCTION_LIST_OWNER_ITEMS", // CMSG_AUCTION_LIST_OWNER_ITEMS - "CMSG_AUCTION_PLACE_BID", // CMSG_AUCTION_PLACE_BID - "SMSG_AUCTION_COMMAND_RESULT", // SMSG_AUCTION_COMMAND_RESULT - "SMSG_AUCTION_LIST_RESULT", // SMSG_AUCTION_LIST_RESULT - "SMSG_AUCTION_OWNER_LIST_RESULT", // SMSG_AUCTION_OWNER_LIST_RESULT - "SMSG_AUCTION_BIDDER_NOTIFICATION", // SMSG_AUCTION_BIDDER_NOTIFICATION - "SMSG_AUCTION_OWNER_NOTIFICATION", // SMSG_AUCTION_OWNER_NOTIFICATION - "SMSG_PROCRESIST", // SMSG_PROCRESIST - "SMSG_STANDSTATE_CHANGE_FAILURE", // SMSG_STANDSTATE_CHANGE_FAILURE - "SMSG_DISPEL_FAILED", // SMSG_DISPEL_FAILED - "SMSG_SPELLORDAMAGE_IMMUNE", // SMSG_SPELLORDAMAGE_IMMUNE - "CMSG_AUCTION_LIST_BIDDER_ITEMS", // CMSG_AUCTION_LIST_BIDDER_ITEMS - "SMSG_AUCTION_BIDDER_LIST_RESULT", // SMSG_AUCTION_BIDDER_LIST_RESULT - "SMSG_SET_FLAT_SPELL_MODIFIER", // SMSG_SET_FLAT_SPELL_MODIFIER - "SMSG_SET_PCT_SPELL_MODIFIER", // SMSG_SET_PCT_SPELL_MODIFIER - "CMSG_SET_AMMO", // CMSG_SET_AMMO - "SMSG_CORPSE_RECLAIM_DELAY", // SMSG_CORPSE_RECLAIM_DELAY - "CMSG_SET_ACTIVE_MOVER", // CMSG_SET_ACTIVE_MOVER - "CMSG_PET_CANCEL_AURA", // CMSG_PET_CANCEL_AURA - "CMSG_PLAYER_AI_CHEAT", // CMSG_PLAYER_AI_CHEAT - "CMSG_CANCEL_AUTO_REPEAT_SPELL", // CMSG_CANCEL_AUTO_REPEAT_SPELL - "MSG_GM_ACCOUNT_ONLINE", // MSG_GM_ACCOUNT_ONLINE - "MSG_LIST_STABLED_PETS", // MSG_LIST_STABLED_PETS - "CMSG_STABLE_PET", // CMSG_STABLE_PET - "CMSG_UNSTABLE_PET", // CMSG_UNSTABLE_PET - "CMSG_BUY_STABLE_SLOT", // CMSG_BUY_STABLE_SLOT - "SMSG_STABLE_RESULT", // SMSG_STABLE_RESULT - "CMSG_STABLE_REVIVE_PET", // CMSG_STABLE_REVIVE_PET - "CMSG_STABLE_SWAP_PET", // CMSG_STABLE_SWAP_PET - "MSG_QUEST_PUSH_RESULT", // MSG_QUEST_PUSH_RESULT - "SMSG_PLAY_MUSIC", // SMSG_PLAY_MUSIC - "SMSG_PLAY_OBJECT_SOUND", // SMSG_PLAY_OBJECT_SOUND - "CMSG_REQUEST_PET_INFO", // CMSG_REQUEST_PET_INFO - "CMSG_FAR_SIGHT", // CMSG_FAR_SIGHT - "SMSG_SPELLDISPELLOG", // SMSG_SPELLDISPELLOG - "SMSG_DAMAGE_CALC_LOG", // SMSG_DAMAGE_CALC_LOG - "CMSG_ENABLE_DAMAGE_LOG", // CMSG_ENABLE_DAMAGE_LOG - "CMSG_GROUP_CHANGE_SUB_GROUP", // CMSG_GROUP_CHANGE_SUB_GROUP - "CMSG_REQUEST_PARTY_MEMBER_STATS", // CMSG_REQUEST_PARTY_MEMBER_STATS - "CMSG_GROUP_SWAP_SUB_GROUP", // CMSG_GROUP_SWAP_SUB_GROUP - "CMSG_RESET_FACTION_CHEAT", // CMSG_RESET_FACTION_CHEAT - "CMSG_AUTOSTORE_BANK_ITEM", // CMSG_AUTOSTORE_BANK_ITEM - "CMSG_AUTOBANK_ITEM", // CMSG_AUTOBANK_ITEM - "MSG_QUERY_NEXT_MAIL_TIME", // MSG_QUERY_NEXT_MAIL_TIME - "SMSG_RECEIVED_MAIL", // SMSG_RECEIVED_MAIL - "SMSG_RAID_GROUP_ONLY", // SMSG_RAID_GROUP_ONLY - "CMSG_SET_DURABILITY_CHEAT", // CMSG_SET_DURABILITY_CHEAT - "CMSG_SET_PVP_RANK_CHEAT", // CMSG_SET_PVP_RANK_CHEAT - "CMSG_ADD_PVP_MEDAL_CHEAT", // CMSG_ADD_PVP_MEDAL_CHEAT - "CMSG_DEL_PVP_MEDAL_CHEAT", // CMSG_DEL_PVP_MEDAL_CHEAT - "CMSG_SET_PVP_TITLE", // CMSG_SET_PVP_TITLE - "SMSG_PVP_CREDIT", // SMSG_PVP_CREDIT - "SMSG_AUCTION_REMOVED_NOTIFICATION", // SMSG_AUCTION_REMOVED_NOTIFICATION - "CMSG_GROUP_RAID_CONVERT", // CMSG_GROUP_RAID_CONVERT - "CMSG_GROUP_ASSISTANT", // CMSG_GROUP_ASSISTANT - "CMSG_BUYBACK_ITEM", // CMSG_BUYBACK_ITEM - "SMSG_SERVER_MESSAGE", // SMSG_SERVER_MESSAGE - "CMSG_MEETINGSTONE_JOIN", // CMSG_MEETINGSTONE_JOIN - "CMSG_MEETINGSTONE_LEAVE", // CMSG_MEETINGSTONE_LEAVE - "CMSG_MEETINGSTONE_CHEAT", // CMSG_MEETINGSTONE_CHEAT - "SMSG_MEETINGSTONE_SETQUEUE", // SMSG_MEETINGSTONE_SETQUEUE - "CMSG_MEETINGSTONE_INFO", // CMSG_MEETINGSTONE_INFO - "SMSG_MEETINGSTONE_COMPLETE", // SMSG_MEETINGSTONE_COMPLETE - "SMSG_MEETINGSTONE_IN_PROGRESS", // SMSG_MEETINGSTONE_IN_PROGRESS - "SMSG_MEETINGSTONE_MEMBER_ADDED", // SMSG_MEETINGSTONE_MEMBER_ADDED - "CMSG_GMTICKETSYSTEM_TOGGLE", // CMSG_GMTICKETSYSTEM_TOGGLE - "CMSG_CANCEL_GROWTH_AURA", // CMSG_CANCEL_GROWTH_AURA - "SMSG_CANCEL_AUTO_REPEAT", // SMSG_CANCEL_AUTO_REPEAT - "SMSG_STANDSTATE_CHANGE_ACK", // SMSG_STANDSTATE_CHANGE_ACK - "SMSG_LOOT_ALL_PASSED", // SMSG_LOOT_ALL_PASSED - "SMSG_LOOT_ROLL_WON", // SMSG_LOOT_ROLL_WON - "CMSG_LOOT_ROLL", // CMSG_LOOT_ROLL - "SMSG_LOOT_START_ROLL", // SMSG_LOOT_START_ROLL - "SMSG_LOOT_ROLL", // SMSG_LOOT_ROLL - "CMSG_LOOT_MASTER_GIVE", // CMSG_LOOT_MASTER_GIVE - "SMSG_LOOT_MASTER_LIST", // SMSG_LOOT_MASTER_LIST - "SMSG_SET_FORCED_REACTIONS", // SMSG_SET_FORCED_REACTIONS - "SMSG_SPELL_FAILED_OTHER", // SMSG_SPELL_FAILED_OTHER - "SMSG_GAMEOBJECT_RESET_STATE", // SMSG_GAMEOBJECT_RESET_STATE - "CMSG_REPAIR_ITEM", // CMSG_REPAIR_ITEM - "SMSG_CHAT_PLAYER_NOT_FOUND", // SMSG_CHAT_PLAYER_NOT_FOUND - "MSG_TALENT_WIPE_CONFIRM", // MSG_TALENT_WIPE_CONFIRM - "SMSG_SUMMON_REQUEST", // SMSG_SUMMON_REQUEST - "CMSG_SUMMON_RESPONSE", // CMSG_SUMMON_RESPONSE - "MSG_MOVE_TOGGLE_GRAVITY_CHEAT", // MSG_MOVE_TOGGLE_GRAVITY_CHEAT - "SMSG_MONSTER_MOVE_TRANSPORT", // SMSG_MONSTER_MOVE_TRANSPORT - "SMSG_PET_BROKEN", // SMSG_PET_BROKEN - "MSG_MOVE_FEATHER_FALL", // MSG_MOVE_FEATHER_FALL - "MSG_MOVE_WATER_WALK", // MSG_MOVE_WATER_WALK - "CMSG_SERVER_BROADCAST", // CMSG_SERVER_BROADCAST - "CMSG_SELF_RES", // CMSG_SELF_RES - "SMSG_FEIGN_DEATH_RESISTED", // SMSG_FEIGN_DEATH_RESISTED - "CMSG_RUN_SCRIPT", // CMSG_RUN_SCRIPT - "SMSG_SCRIPT_MESSAGE", // SMSG_SCRIPT_MESSAGE - "SMSG_DUEL_COUNTDOWN", // SMSG_DUEL_COUNTDOWN - "SMSG_AREA_TRIGGER_MESSAGE", // SMSG_AREA_TRIGGER_MESSAGE - "CMSG_TOGGLE_HELM", // CMSG_TOGGLE_HELM - "CMSG_TOGGLE_CLOAK", // CMSG_TOGGLE_CLOAK - "SMSG_MEETINGSTONE_JOINFAILED", // SMSG_MEETINGSTONE_JOINFAILED - "SMSG_PLAYER_SKINNED", // SMSG_PLAYER_SKINNED - "SMSG_DURABILITY_DAMAGE_DEATH", // SMSG_DURABILITY_DAMAGE_DEATH - "CMSG_SET_EXPLORATION", // CMSG_SET_EXPLORATION - "CMSG_SET_ACTIONBAR_TOGGLES", // CMSG_SET_ACTIONBAR_TOGGLES - "UMSG_DELETE_GUILD_CHARTER", // UMSG_DELETE_GUILD_CHARTER - "MSG_PETITION_RENAME", // MSG_PETITION_RENAME - "SMSG_INIT_WORLD_STATES", // SMSG_INIT_WORLD_STATES - "SMSG_UPDATE_WORLD_STATE", // SMSG_UPDATE_WORLD_STATE - "CMSG_ITEM_NAME_QUERY", // CMSG_ITEM_NAME_QUERY - "SMSG_ITEM_NAME_QUERY_RESPONSE", // SMSG_ITEM_NAME_QUERY_RESPONSE - "SMSG_PET_ACTION_FEEDBACK", // SMSG_PET_ACTION_FEEDBACK - "CMSG_CHAR_RENAME", // CMSG_CHAR_RENAME - "SMSG_CHAR_RENAME", // SMSG_CHAR_RENAME - "CMSG_MOVE_SPLINE_DONE", // CMSG_MOVE_SPLINE_DONE - "CMSG_MOVE_FALL_RESET", // CMSG_MOVE_FALL_RESET - "SMSG_INSTANCE_SAVE_CREATED", // SMSG_INSTANCE_SAVE_CREATED - "SMSG_RAID_INSTANCE_INFO", // SMSG_RAID_INSTANCE_INFO - "CMSG_REQUEST_RAID_INFO", // CMSG_REQUEST_RAID_INFO - "CMSG_MOVE_TIME_SKIPPED", // CMSG_MOVE_TIME_SKIPPED - "CMSG_MOVE_FEATHER_FALL_ACK", // CMSG_MOVE_FEATHER_FALL_ACK - "CMSG_MOVE_WATER_WALK_ACK", // CMSG_MOVE_WATER_WALK_ACK - "CMSG_MOVE_NOT_ACTIVE_MOVER", // CMSG_MOVE_NOT_ACTIVE_MOVER - "SMSG_PLAY_SOUND", // SMSG_PLAY_SOUND - "CMSG_BATTLEFIELD_STATUS", // CMSG_BATTLEFIELD_STATUS - "SMSG_BATTLEFIELD_STATUS", // SMSG_BATTLEFIELD_STATUS - "CMSG_BATTLEFIELD_PORT", // CMSG_BATTLEFIELD_PORT - "MSG_INSPECT_HONOR_STATS", // MSG_INSPECT_HONOR_STATS - "CMSG_BATTLEMASTER_HELLO", // CMSG_BATTLEMASTER_HELLO - "CMSG_MOVE_START_SWIM_CHEAT", // CMSG_MOVE_START_SWIM_CHEAT - "CMSG_MOVE_STOP_SWIM_CHEAT", // CMSG_MOVE_STOP_SWIM_CHEAT - "SMSG_FORCE_WALK_SPEED_CHANGE", // SMSG_FORCE_WALK_SPEED_CHANGE - "CMSG_FORCE_WALK_SPEED_CHANGE_ACK", // CMSG_FORCE_WALK_SPEED_CHANGE_ACK - "SMSG_FORCE_SWIM_BACK_SPEED_CHANGE", // SMSG_FORCE_SWIM_BACK_SPEED_CHANGE - "CMSG_FORCE_SWIM_BACK_SPEED_CHANGE_ACK", // CMSG_FORCE_SWIM_BACK_SPEED_CHANGE_ACK - "SMSG_FORCE_TURN_RATE_CHANGE", // SMSG_FORCE_TURN_RATE_CHANGE - "CMSG_FORCE_TURN_RATE_CHANGE_ACK", // CMSG_FORCE_TURN_RATE_CHANGE_ACK - "MSG_PVP_LOG_DATA", // MSG_PVP_LOG_DATA - "CMSG_LEAVE_BATTLEFIELD", // CMSG_LEAVE_BATTLEFIELD - "CMSG_AREA_SPIRIT_HEALER_QUERY", // CMSG_AREA_SPIRIT_HEALER_QUERY - "CMSG_AREA_SPIRIT_HEALER_QUEUE", // CMSG_AREA_SPIRIT_HEALER_QUEUE - "SMSG_AREA_SPIRIT_HEALER_TIME", // SMSG_AREA_SPIRIT_HEALER_TIME - "CMSG_GM_UNTEACH", // CMSG_GM_UNTEACH - "SMSG_WARDEN_DATA", // SMSG_WARDEN_DATA - "CMSG_WARDEN_DATA", // CMSG_WARDEN_DATA - "SMSG_GROUP_JOINED_BATTLEGROUND", // SMSG_GROUP_JOINED_BATTLEGROUND - "MSG_BATTLEGROUND_PLAYER_POSITIONS", // MSG_BATTLEGROUND_PLAYER_POSITIONS - "CMSG_PET_STOP_ATTACK", // CMSG_PET_STOP_ATTACK - "SMSG_BINDER_CONFIRM", // SMSG_BINDER_CONFIRM - "SMSG_BATTLEGROUND_PLAYER_JOINED", // SMSG_BATTLEGROUND_PLAYER_JOINED - "SMSG_BATTLEGROUND_PLAYER_LEFT", // SMSG_BATTLEGROUND_PLAYER_LEFT - "CMSG_BATTLEMASTER_JOIN", // CMSG_BATTLEMASTER_JOIN - "SMSG_ADDON_INFO", // SMSG_ADDON_INFO - "CMSG_PET_UNLEARN", // CMSG_PET_UNLEARN - "SMSG_PET_UNLEARN_CONFIRM", // SMSG_PET_UNLEARN_CONFIRM - "SMSG_PARTY_MEMBER_STATS_FULL", // SMSG_PARTY_MEMBER_STATS_FULL - "CMSG_PET_SPELL_AUTOCAST", // CMSG_PET_SPELL_AUTOCAST - "SMSG_WEATHER", // SMSG_WEATHER - "SMSG_PLAY_TIME_WARNING", // SMSG_PLAY_TIME_WARNING - "SMSG_MINIGAME_SETUP", // SMSG_MINIGAME_SETUP - "SMSG_MINIGAME_STATE", // SMSG_MINIGAME_STATE - "CMSG_MINIGAME_MOVE", // CMSG_MINIGAME_MOVE - "SMSG_MINIGAME_MOVE_FAILED", // SMSG_MINIGAME_MOVE_FAILED - "SMSG_INSTANCE_RESET_SCHEDULED", // SMSG_INSTANCE_RESET_SCHEDULED - "SMSG_COMPRESSED_MOVE", // SMSG_COMPRESSED_MOVE - "CMSG_GUILD_CHANGEINFO", // CMSG_GUILD_CHANGEINFO - "SMSG_TRIAL_RESTRICTED", // SMSG_TRIAL_RESTRICTED - "SMSG_SET_MOVE_SPEED", // SMSG_SET_MOVE_SPEED - "SMSG_SET_RUN_BACK_SPEED", // SMSG_SET_RUN_BACK_SPEED - "SMSG_SET_SWIM_SPEED", // SMSG_SET_SWIM_SPEED - "UMSG_UNKNOWN_769", // UMSG_UNKNOWN_769 - "SMSG_SET_SWIM_BACK_SPEED", // SMSG_SET_SWIM_BACK_SPEED - "SMSG_SET_TURN_RATE", // SMSG_SET_TURN_RATE - "SMSG_UNKNOWN_772", // SMSG_UNKNOWN_772 - "SMSG_UNKNOWN_773", // SMSG_UNKNOWN_773 - "SMSG_UNKNOWN_774", // SMSG_UNKNOWN_774 - "SMSG_UNKNOWN_775", // SMSG_UNKNOWN_775 - "SMSG_UNKNOWN_776", // SMSG_UNKNOWN_776 - "SMSG_MOVE_SET_WATERWALK", // SMSG_MOVE_SET_WATERWALK - "SMSG_MOVE_STOP_WATERWALK", // SMSG_MOVE_STOP_WATERWALK - "SMSG_UNKNOWN_779", // SMSG_UNKNOWN_779 - "SMSG_UNKNOWN_780", // SMSG_UNKNOWN_780 - "SMSG_MOVE_STOP_WALK", // SMSG_MOVE_STOP_WALK - "SMSG_MOVE_START_WALK", // SMSG_MOVE_START_WALK - "UMSG_UNKNOWN_783", // UMSG_UNKNOWN_783 - "UMSG_UNKNOWN_784", // UMSG_UNKNOWN_784 - "UMSG_UNKNOWN_785", // UMSG_UNKNOWN_785 - "CMSG_ACTIVATETAXI_FAR", // CMSG_ACTIVATETAXI_FAR - "UMSG_UNKNOWN_787", // UMSG_UNKNOWN_787 - "UMSG_UNKNOWN_788", // UMSG_UNKNOWN_788 - "UMSG_UNKNOWN_789", // UMSG_UNKNOWN_789 - "UMSG_UNKNOWN_790", // UMSG_UNKNOWN_790 - "CMSG_FIELD_WATCHED_FACTION_INACTIVE", // CMSG_FIELD_WATCHED_FACTION_INACTIVE - "CMSG_FIELD_WATCHED_FACTION_SHOW_BAR", // CMSG_FIELD_WATCHED_FACTION_SHOW_BAR - "SMSG_UNKNOWN_793", // SMSG_UNKNOWN_793 - "SMSG_UNKNOWN_794", // SMSG_UNKNOWN_794 - "UMSG_UNKNOWN_795", // UMSG_UNKNOWN_795 - "SMSG_UNKNOWN_796", // SMSG_UNKNOWN_796 - "CMSG_RESET_INSTANCES", // CMSG_RESET_INSTANCES - "SMSG_RESET_INSTANCES_SUCCESS", // SMSG_RESET_INSTANCES_SUCCESS - "SMSG_RESET_INSTANCES_FAILED", // SMSG_RESET_INSTANCES_FAILED - "SMSG_UNKNOWN_800", // SMSG_UNKNOWN_800 - "MSG_RAID_ICON_TARGET", // MSG_RAID_ICON_TARGET - "MSG_RAID_READY_CHECK", // MSG_RAID_READY_CHECK - "UMSG_UNKNOWN_803", // UMSG_UNKNOWN_803 - "SMSG_AI_UNKNOWN", // SMSG_AI_UNKNOWN - "SMSG_UNKNOWN_805", // SMSG_UNKNOWN_805 - "UMSG_UNKNOWN_806", // UMSG_UNKNOWN_806 - "UMSG_UNKNOWN_807", // UMSG_UNKNOWN_807 - "SMSG_GM_SURVEY_REQUEST", // SMSG_GM_SURVEY_REQUEST - "MSG_SET_DUNGEON_DIFFICULTY", // MSG_SET_DUNGEON_DIFFICULTY - "CMSG_GM_SURVEY_RESULTS", // CMSG_GM_SURVEY_RESULTS - "SMSG_UNKNOWN_811", // SMSG_UNKNOWN_811 - "UMSG_UNKNOWN_812", // UMSG_UNKNOWN_812 - "UMSG_UNKNOWN_813", // UMSG_UNKNOWN_813 - "UMSG_UNKNOWN_814", // UMSG_UNKNOWN_814 - "SMSG_SPELL_INSTA_KILL_SELF", // SMSG_SPELL_INSTA_KILL_SELF - "SMSG_UNKNOWN_816", // SMSG_UNKNOWN_816 - "UMSG_UNKNOWN_817", // UMSG_UNKNOWN_817 - "SMSG_ANTISPAM", // SMSG_ANTISPAM - "UMSG_UNKNOWN_819", // UMSG_UNKNOWN_819 - "UMSG_UNKNOWN_820", // UMSG_UNKNOWN_820 - "UMSG_UNKNOWN_821", // UMSG_UNKNOWN_821 - "UMSG_UNKNOWN_822", // UMSG_UNKNOWN_822 - "UMSG_UNKNOWN_823", // UMSG_UNKNOWN_823 - "UMSG_UNKNOWN_824", // UMSG_UNKNOWN_824 - "UMSG_UNKNOWN_825", // UMSG_UNKNOWN_825 - "SMSG_OUTDOORPVP_NOTIFY", // SMSG_OUTDOORPVP_NOTIFY - "UMSG_UNKNOWN_827", // UMSG_UNKNOWN_827 - "UMSG_UNKNOWN_828", // UMSG_UNKNOWN_828 - "SMSG_MOTD", // SMSG_MOTD - "UMSG_UNKNOWN_830", // UMSG_UNKNOWN_830 - "UMSG_UNKNOWN_831", // UMSG_UNKNOWN_831 - "UMSG_UNKNOWN_832", // UMSG_UNKNOWN_832 - "SMSG_UNKNOWN_833", // SMSG_UNKNOWN_833 - "SMSG_UNKNOWN_834", // SMSG_UNKNOWN_834 - "SMSG_FLY_MODE_START", // SMSG_FLY_MODE_START - "SMSG_FLY_MODE_STOP", // SMSG_FLY_MODE_STOP - "CMSG_MOVE_FLY_MODE_CHANGE_ACK", // CMSG_MOVE_FLY_MODE_CHANGE_ACK - "MSG_MOVE_FLY_STATE_CHANGE", // MSG_MOVE_FLY_STATE_CHANGE - "CMSG_SOCKET_ITEM", // CMSG_SOCKET_ITEM - "UMSG_UNKNOWN_840, CMSG?", // UMSG_UNKNOWN_840, CMSG? - "SMSG_ARENA_TEAM_COMMAND_RESULT", // SMSG_ARENA_TEAM_COMMAND_RESULT - "UMSG_UNKNOWN_842", // UMSG_UNKNOWN_842 - "CMSG_ARENA_TEAM_QUERY", // CMSG_ARENA_TEAM_QUERY - "SMSG_ARENA_TEAM_QUERY_RESPONSE", // SMSG_ARENA_TEAM_QUERY_RESPONSE - "CMSG_ARENA_TEAM_ROSTER", // CMSG_ARENA_TEAM_ROSTER - "SMSG_ARENA_TEAM_ROSTER", // SMSG_ARENA_TEAM_ROSTER - "CMSG_ARENA_TEAM_INVITE_BYNAME", // CMSG_ARENA_TEAM_INVITE_BYNAME - "SMSG_ARENA_TEAM_INVITE", // SMSG_ARENA_TEAM_INVITE - "CMSG_ARENA_TEAM_ACCEPT", // CMSG_ARENA_TEAM_ACCEPT - "CMSG_ARENA_TEAM_DECLINE", // CMSG_ARENA_TEAM_DECLINE - "CMSG_ARENA_TEAM_LEAVE", // CMSG_ARENA_TEAM_LEAVE - "CMSG_ARENA_TEAM_UNINVITE_BYNAME", // CMSG_ARENA_TEAM_UNINVITE_BYNAME - "CMSG_ARENA_TEAM_DISBAND", // CMSG_ARENA_TEAM_DISBAND - "CMSG_ARENA_TEAM_SET_LEADER_BYNAME", // CMSG_ARENA_TEAM_SET_LEADER_BYNAME - "SMSG_ARENA_TEAM_EVENT", // SMSG_ARENA_TEAM_EVENT - "CMSG_ARENAMASTER_JOIN", // CMSG_ARENAMASTER_JOIN - "MSG_MOVE_START_FLY_UP", // MSG_MOVE_START_FLY_UP - "MSG_MOVE_STOP_FLY_UP", // MSG_MOVE_STOP_FLY_UP - "SMSG_ARENA_TEAM_STATS", // SMSG_ARENA_TEAM_STATS - "CMSG_LFG_SET_AUTOJOIN", // CMSG_LFG_SET_AUTOJOIN - "CMSG_LFG_UNSET_AUTOJOIN", // CMSG_LFG_UNSET_AUTOJOIN - "CMSG_LFM_SET_AUTOADD", // CMSG_LFM_SET_AUTOADD - "CMSG_LFM_UNSET_AUTOADD", // CMSG_LFM_UNSET_AUTOADD - "CMSG_LFG_INVITE_ACCEPT", // CMSG_LFG_INVITE_ACCEPT - "CMSG_LFG_INVITE_CANCEL", // CMSG_LFG_INVITE_CANCEL - "UMSG_UNKNOWN_866", // UMSG_UNKNOWN_866 - "CMSG_LOOKING_FOR_GROUP_CLEAR", // CMSG_LOOKING_FOR_GROUP_CLEAR - "CMSG_SET_LOOKING_FOR_NONE", // CMSG_SET_LOOKING_FOR_NONE - "CMSG_SET_LOOKING_FOR_MORE", // CMSG_SET_LOOKING_FOR_MORE - "CMSG_SET_COMMENTARY", // CMSG_SET_COMMENTARY - "SMSG_LFG_MATCHMAKING_TIMEDOUT", // SMSG_LFG_MATCHMAKING_TIMEDOUT - "SMSG_LFG_MATCHMAKING_OTHER_TIMEDOUT", // SMSG_LFG_MATCHMAKING_OTHER_TIMEDOUT - "SMSG_LFG_MATCHMAKING_AUTOJOIN_FAILED", // SMSG_LFG_MATCHMAKING_AUTOJOIN_FAILED - "SMSG_LFG_MATCHMAKING_AUTOJOIN_FAILED_NO_PLAYER", // SMSG_LFG_MATCHMAKING_AUTOJOIN_FAILED_NO_PLAYER - "UMSG_UNKNOWN_875", // UMSG_UNKNOWN_875 - "SMSG_LFG_876", // SMSG_LFG_876 - "SMSG_LFG_877", // SMSG_LFG_877 - "SMSG_LFG_878", // SMSG_LFG_878 - "SMSG_LFG_879", // SMSG_LFG_879 - "SMSG_LFG_MATCHMAKING_PENDING_INVITE", // SMSG_LFG_MATCHMAKING_PENDING_INVITE - "SMSG_LFG_MATCHMAKING_PENDING_MATCH", // SMSG_LFG_MATCHMAKING_PENDING_MATCH - "UMSG_UNKNOWN_882", // UMSG_UNKNOWN_882 - "SMSG_CHANGE_TITLE", // SMSG_CHANGE_TITLE - "CMSG_CHOOSE_TITLE", // CMSG_CHOOSE_TITLE - "CMSG_DISMOUNT", // CMSG_DISMOUNT - "SMSG_ARENA_NO_TEAM", // SMSG_ARENA_NO_TEAM - "MSG_INSPECT_ARENA_STATS", // MSG_INSPECT_ARENA_STATS - "SMSG_SH_POSITION", // SMSG_SH_POSITION - "CMSG_CANCEL_TEMP_ITEM_ENCHANTMENT", // CMSG_CANCEL_TEMP_ITEM_ENCHANTMENT - "UMSG_UNKNOWN_890", // UMSG_UNKNOWN_890 - "UMSG_UNKNOWN_891", // UMSG_UNKNOWN_891 - "UMSG_UNKNOWN_892", // UMSG_UNKNOWN_892 - "UMSG_UNKNOWN_893", // UMSG_UNKNOWN_893 - "MSG_MOVE_SET_FLY_SPEED", // MSG_MOVE_SET_FLY_SPEED - "UMSG_UNKNOWN_895", // UMSG_UNKNOWN_895 - "MSG_MOVE_SET_FLY_BACK_SPEED", // MSG_MOVE_SET_FLY_BACK_SPEED - "SMSG_FORCE_FLY_SPEED_CHANGE", // SMSG_FORCE_FLY_SPEED_CHANGE - "CMSG_FORCE_FLY_SPEED_CHANGE_ACK", // CMSG_FORCE_FLY_SPEED_CHANGE_ACK - "SMSG_FORCE_FLY_BACK_SPEED_CHANGE", // SMSG_FORCE_FLY_BACK_SPEED_CHANGE - "CMSG_FORCE_FLY_BACK_SPEED_CHANGE_ACK", // CMSG_FORCE_FLY_BACK_SPEED_CHANGE_ACK - "MSG_MOVE_SET_FLY_SPEED2", // MSG_MOVE_SET_FLY_SPEED2 - "SMSG_MOVE_SET_FLY_BACK_SPEED2", // SMSG_MOVE_SET_FLY_BACK_SPEED2 - "UMSG_UNKNOWN_903", // UMSG_UNKNOWN_903 - "SMSG_FLIGHT_SPLINE_SYNC", // SMSG_FLIGHT_SPLINE_SYNC - "CMSG_SET_TAXI_BENCHMARK_MODE", // CMSG_SET_TAXI_BENCHMARK_MODE - "UMSG_UNKNOWN_906", // UMSG_UNKNOWN_906 - "SMSG_REALM_SPLIT_INFO_RESPONSE", // SMSG_REALM_SPLIT_INFO_RESPONSE - "CMSG_REALM_SPLIT_INFO_REQUEST", // CMSG_REALM_SPLIT_INFO_REQUEST - "MSG_MOVE_SHIP_909", // MSG_MOVE_SHIP_909 - "CMSG_GROUP_PROMOTE", // CMSG_GROUP_PROMOTE - "SMSG_ALREADY_IN_ARENA_TEAM", // SMSG_ALREADY_IN_ARENA_TEAM - "SMSG_ALLOW_MOVE", // SMSG_ALLOW_MOVE - "CMSG_ALLOW_MOVE_ACK", // CMSG_ALLOW_MOVE_ACK - "UMSG_UNKNOWN_914", // UMSG_UNKNOWN_914 - "UMSG_UNKNOWN_915", // UMSG_UNKNOWN_915 - "UMSG_UNKNOWN_916", // UMSG_UNKNOWN_916 - "UMSG_UNKNOWN_917", // UMSG_UNKNOWN_917 - "SMSG_RESET_INSTANCE_FAILED_NOTIFY", // SMSG_RESET_INSTANCE_FAILED_NOTIFY - "SMSG_UNKNOWN_919", // SMSG_UNKNOWN_919 - "SMSG_SYSTEM_DISABLED", // SMSG_SYSTEM_DISABLED - "UMSG_UNKNOWN_921", // UMSG_UNKNOWN_921 - "UMSG_UNKNOWN_922", // UMSG_UNKNOWN_922 - "UMSG_UNKNOWN_923", // UMSG_UNKNOWN_923 - "UMSG_UNKNOWN_924", // UMSG_UNKNOWN_924 - "SMSG_SET_COMBO_POINTS", // SMSG_SET_COMBO_POINTS - "SMSG_VOICE_SESSION", // SMSG_VOICE_SESSION - "SMSG_UNKNOWN_927", // SMSG_UNKNOWN_927 - "UMSG_UNKNOWN_928", // UMSG_UNKNOWN_928 - "UMSG_UNKNOWN_929", // UMSG_UNKNOWN_929 - "UMSG_UNKNOWN_930", // UMSG_UNKNOWN_930 - "SMSG_SET_AURA_MULTIPLY", // SMSG_SET_AURA_MULTIPLY - "SMSG_SET_AURA_SINGLE", // SMSG_SET_AURA_SINGLE - "UMSG_UNKNOWN_933", // UMSG_UNKNOWN_933 - "SMSG_CAST_SUCCESS", // SMSG_CAST_SUCCESS - "MSG_UNKNOWN_935", // MSG_UNKNOWN_935 - "UMSG_UNKNOWN_936", // UMSG_UNKNOWN_936 - "UMSG_UNKNOWN_937", // UMSG_UNKNOWN_937 - "SMSG_UNKNOWN_938", // SMSG_UNKNOWN_938 - "UMSG_UNKNOWN_939", // UMSG_UNKNOWN_939 - "SMSG_UNKNOWN_940", // SMSG_UNKNOWN_940 - "SMSG_UNKNOWN_941", // SMSG_UNKNOWN_941 - "SMSG_READY_CHECK_ALL_READY", // SMSG_READY_CHECK_ALL_READY - "CMSG_VOICE_SETTINGS", // CMSG_VOICE_SETTINGS - "SMSG_VOICE_CHAT_PARENTAL_DISABLE_ALL", // SMSG_VOICE_CHAT_PARENTAL_DISABLE_ALL - "UMSG_UNKNOWN_945", // UMSG_UNKNOWN_945 - "UMSG_UNKNOWN_946", // UMSG_UNKNOWN_946 - "UMSG_UNKNOWN_947", // UMSG_UNKNOWN_947 - "CMSG_COMMENTATOR_SET_MODE", // CMSG_COMMENTATOR_SET_MODE - "UMSG_UNKNOWN_949", // UMSG_UNKNOWN_949 - "CMSG_COMMENTATOR_UPDATE_MAP_INFO", // CMSG_COMMENTATOR_UPDATE_MAP_INFO - "UMSG_UNKNOWN_951", // UMSG_UNKNOWN_951 - "CMSG_COMMENTATOR_UPDATE_PLAYER_INFO", // CMSG_COMMENTATOR_UPDATE_PLAYER_INFO - "CMSG_UNKNOWN_953", // CMSG_UNKNOWN_953 - "UMSG_UNKNOWN_954", // UMSG_UNKNOWN_954 - "UMSG_UNKNOWN_955", // UMSG_UNKNOWN_955 - "UMSG_UNKNOWN_956", // UMSG_UNKNOWN_956 - "CMSG_COMMENTATOR_EXIT_INSTANCE", // CMSG_COMMENTATOR_EXIT_INSTANCE - "UMSG_UNKNOWN_958", // UMSG_UNKNOWN_958 - "UMSG_UNKNOWN_959", // UMSG_UNKNOWN_959 - "SMSG_UNKNOWN_960", // SMSG_UNKNOWN_960 - "UMSG_UNKNOWN_961", // UMSG_UNKNOWN_961 - "UMSG_UNKNOWN_962", // UMSG_UNKNOWN_962 - "UMSG_UNKNOWN_963", // UMSG_UNKNOWN_963 - "UMSG_UNKNOWN_964", // UMSG_UNKNOWN_964 - "UMSG_UNKNOWN_965", // UMSG_UNKNOWN_965 - "CMSG_COMPLAINT_CHAT", // CMSG_COMPLAINT_CHAT - "SMSG_COMPLAINT_ADDED", // SMSG_COMPLAINT_ADDED - "SMSG_VOICE_SYSTEM_STATUS", // SMSG_VOICE_SYSTEM_STATUS - "UMSG_UNKNOWN_969", // UMSG_UNKNOWN_969 - "UMSG_UNKNOWN_970", // UMSG_UNKNOWN_970 - "CMSG_CHANNEL_SILENT_VOICE", // CMSG_CHANNEL_SILENT_VOICE - "CMSG_CHANNEL_SILENT_ALL", // CMSG_CHANNEL_SILENT_ALL - "CMSG_CHANNEL_UNSILENT_VOICE", // CMSG_CHANNEL_UNSILENT_VOICE - "CMSG_CHANNEL_UNSILENT_ALL", // CMSG_CHANNEL_UNSILENT_ALL - "UMSG_UNKNOWN_975", // UMSG_UNKNOWN_975 - "UMSG_UNKNOWN_976", // UMSG_UNKNOWN_976 - "CMSG_CHANNEL_ROSTER_QUERY", // CMSG_CHANNEL_ROSTER_QUERY - "CMSG_CHANNEL_VOICE_CHAT_QUERY", // CMSG_CHANNEL_VOICE_CHAT_QUERY - "CMSG_CHANNEL_INFO_QUERY", // CMSG_CHANNEL_INFO_QUERY - "SMSG_CHANNEL_INFO_QUERY_RESPONSE", // SMSG_CHANNEL_INFO_QUERY_RESPONSE - "CMSG_CHANNEL_VOICE_ON", // CMSG_CHANNEL_VOICE_ON - "CMSG_CHANNEL_VOICE_OFF", // CMSG_CHANNEL_VOICE_OFF - "UMSG_UNKNOWN_983", // UMSG_UNKNOWN_983 - "UMSG_UNKNOWN_984", // UMSG_UNKNOWN_984 - "SMSG_CHANNEL_NOTIFY_AVAILABLE_VOICE_SESSION", // SMSG_CHANNEL_NOTIFY_AVAILABLE_VOICE_SESSION - "CMSG_MUTE_PLAYER", // CMSG_MUTE_PLAYER - "CMSG_UNMUTE_PLAYER", // CMSG_UNMUTE_PLAYER - "CMSG_SILENCE_MEMBER", // CMSG_SILENCE_MEMBER - "CMSG_UNSILENCE_MEMBER", // CMSG_UNSILENCE_MEMBER - "SMSG_PLAYER_UNSILENCED", // SMSG_PLAYER_UNSILENCED - "SMSG_COMSAT_RECONNECT_ATTEMPT", // SMSG_COMSAT_RECONNECT_ATTEMPT - "SMSG_COMSAT_DISCONNECT", // SMSG_COMSAT_DISCONNECT - "SMSG_COMSAT_CONNECT_FAIL", // SMSG_COMSAT_CONNECT_FAIL - "UMSG_UNKNOWN_994", // UMSG_UNKNOWN_994 - "UMSG_UNKNOWN_995", // UMSG_UNKNOWN_995 - "UMSG_UNKNOWN_996", // UMSG_UNKNOWN_996 - "CMSG_GUILD_BANK", // CMSG_GUILD_BANK - "CMSG_GUILDBANK_TAB_COLON", // CMSG_GUILDBANK_TAB_COLON - "SMSG_GUILD_BANK_LIST", // SMSG_GUILD_BANK_LIST - "CMSG_UNKNOWN_1000", // CMSG_UNKNOWN_1000 - "CMSG_BUY_GUILDBANK_TAB", // CMSG_BUY_GUILDBANK_TAB - "UMSG_UNKNOWN_1002", // UMSG_UNKNOWN_1002 - "CMSG_GUILDBANK_DEPOSIT", // CMSG_GUILDBANK_DEPOSIT - "CMSG_GUILDBANK_WITHDRAW", // CMSG_GUILDBANK_WITHDRAW - "MSG_GUILDBANK_LOG", // MSG_GUILDBANK_LOG - "CMSG_CHANNEL_WATCH", // CMSG_CHANNEL_WATCH - "SMSG_PLAYER_JOINED_CHANNEL", // SMSG_PLAYER_JOINED_CHANNEL - "SMSG_PLAYER_LEFT_CHANNEL", // SMSG_PLAYER_LEFT_CHANNEL - "SMSG_PLAYER_JOINED_CUSTOM_CHANNEL", // SMSG_PLAYER_JOINED_CUSTOM_CHANNEL - "CMSG_CLEAR_CHANNEL_WATCH", // CMSG_CLEAR_CHANNEL_WATCH - "SMSG_INSPECT_TALENTS", // SMSG_INSPECT_TALENTS - "UMSG_UNKNOWN_1012", // UMSG_UNKNOWN_1012 - "UMSG_UNKNOWN_1013", // UMSG_UNKNOWN_1013 - "UMSG_UNKNOWN_1014", // UMSG_UNKNOWN_1014 - "CMSG_UNKNOWN_1015", // CMSG_UNKNOWN_1015 - "UMSG_UNKNOWN_1016", // UMSG_UNKNOWN_1016 - "UMSG_UNKNOWN_1017", // UMSG_UNKNOWN_1017 - "UMSG_UNKNOWN_1018", // UMSG_UNKNOWN_1018 - "SMSG_VOICESESSION_FULL", // SMSG_VOICESESSION_FULL - "MSG_UNKNOWN_1020", // MSG_UNKNOWN_1020 - "MSG_UNKNOWN_1021", // MSG_UNKNOWN_1021 - "MSG_GUILD_INFO_LOG", // MSG_GUILD_INFO_LOG - "" // last entry should be empty -}; - -const char *GetOpcodeName(unsigned int id) -{ - if(id > MAX_OPCODE_ID) - return ""; - return worldOpcodeNames[id]; -} - -const unsigned int GetOpcodeID(const char *name) -{ - for(unsigned int i=0; strlen(worldOpcodeNames[i]); i++) - { - if(!stricmp(worldOpcodeNames[i], name)) - { - return i; - } - } - return -1; // invalid name -} +/* + * Copyright (C) 2005,2006,2007 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/** \file + \ingroup u2w +*/ +#include "common.h" +#include "Opcodes.h" + + +/// Correspondance between opcodes and their names +// this is an string array, for more opcode comments look to opcodes.h +// do not change order of lines! +// when renaming opcodes, replace old name by the new one +const char* worldOpcodeNames[] = +{ + "MSG_NULL_ACTION", // MSG_NULL_ACTION + "CMSG_BOOTME", // CMSG_BOOTME + "CMSG_DBLOOKUP", // CMSG_DBLOOKUP + "SMSG_DBLOOKUP", // SMSG_DBLOOKUP + "CMSG_QUERY_OBJECT_POSITION", // CMSG_QUERY_OBJECT_POSITION + "SMSG_QUERY_OBJECT_POSITION", // SMSG_QUERY_OBJECT_POSITION + "CMSG_QUERY_OBJECT_ROTATION", // CMSG_QUERY_OBJECT_ROTATION + "SMSG_QUERY_OBJECT_ROTATION", // SMSG_QUERY_OBJECT_ROTATION + "CMSG_WORLD_TELEPORT", // CMSG_WORLD_TELEPORT + "CMSG_TELEPORT_TO_UNIT", // CMSG_TELEPORT_TO_UNIT + "CMSG_ZONE_MAP", // CMSG_ZONE_MAP + "SMSG_ZONE_MAP", // SMSG_ZONE_MAP + "CMSG_DEBUG_CHANGECELLZONE", // CMSG_DEBUG_CHANGECELLZONE + "CMSG_EMBLAZON_TABARD_OBSOLETE", // CMSG_EMBLAZON_TABARD_OBSOLETE + "CMSG_UNEMBLAZON_TABARD_OBSOLETE", // CMSG_UNEMBLAZON_TABARD_OBSOLETE + "CMSG_RECHARGE", // CMSG_RECHARGE + "CMSG_LEARN_SPELL", // CMSG_LEARN_SPELL + "CMSG_CREATEMONSTER", // CMSG_CREATEMONSTER + "CMSG_DESTROYMONSTER", // CMSG_DESTROYMONSTER + "CMSG_CREATEITEM", // CMSG_CREATEITEM + "CMSG_CREATEGAMEOBJECT", // CMSG_CREATEGAMEOBJECT + "CMSG_MAKEMONSTERATTACKME_OBSOLETE", // CMSG_MAKEMONSTERATTACKME_OBSOLETE + "CMSG_MAKEMONSTERATTACKGUID", // CMSG_MAKEMONSTERATTACKGUID + "CMSG_ENABLEDEBUGCOMBATLOGGING_OBSOLETE", // CMSG_ENABLEDEBUGCOMBATLOGGING_OBSOLETE + "CMSG_FORCEACTION", // CMSG_FORCEACTION + "CMSG_FORCEACTIONONOTHER", // CMSG_FORCEACTIONONOTHER + "CMSG_FORCEACTIONSHOW", // CMSG_FORCEACTIONSHOW + "SMSG_FORCEACTIONSHOW", // SMSG_FORCEACTIONSHOW + "SMSG_ATTACKERSTATEUPDATEDEBUGINFO_OBSOLETE", // SMSG_ATTACKERSTATEUPDATEDEBUGINFO_OBSOLETE + "SMSG_DEBUGINFOSPELL_OBSOLETE", // SMSG_DEBUGINFOSPELL_OBSOLETE + "SMSG_DEBUGINFOSPELLMISS_OBSOLETE", // SMSG_DEBUGINFOSPELLMISS_OBSOLETE + "SMSG_DEBUG_PLAYER_RANGE_OBSOLETE", // SMSG_DEBUG_PLAYER_RANGE_OBSOLETE + "CMSG_UNDRESSPLAYER", // CMSG_UNDRESSPLAYER + "CMSG_BEASTMASTER", // CMSG_BEASTMASTER + "CMSG_GODMODE", // CMSG_GODMODE + "SMSG_GODMODE", // SMSG_GODMODE + "CMSG_CHEAT_SETMONEY", // CMSG_CHEAT_SETMONEY + "CMSG_LEVEL_CHEAT", // CMSG_LEVEL_CHEAT + "CMSG_PET_LEVEL_CHEAT", // CMSG_PET_LEVEL_CHEAT + "CMSG_LEVELUP_CHEAT_OBSOLETE", // CMSG_LEVELUP_CHEAT_OBSOLETE + "CMSG_COOLDOWN_CHEAT", // CMSG_COOLDOWN_CHEAT + "CMSG_USE_SKILL_CHEAT", // CMSG_USE_SKILL_CHEAT + "CMSG_FLAG_QUEST", // CMSG_FLAG_QUEST + "CMSG_FLAG_QUEST_FINISH", // CMSG_FLAG_QUEST_FINISH + "CMSG_CLEAR_QUEST", // CMSG_CLEAR_QUEST + "CMSG_SEND_EVENT", // CMSG_SEND_EVENT + "CMSG_DEBUG_AISTATE", // CMSG_DEBUG_AISTATE + "SMSG_DEBUG_AISTATE", // SMSG_DEBUG_AISTATE + "CMSG_DISABLE_PVP_CHEAT", // CMSG_DISABLE_PVP_CHEAT + "CMSG_ADVANCE_SPAWN_TIME", // CMSG_ADVANCE_SPAWN_TIME + "CMSG_PVP_PORT_OBSOLETE", // CMSG_PVP_PORT_OBSOLETE + "CMSG_AUTH_SRP6_BEGIN", // CMSG_AUTH_SRP6_BEGIN + "CMSG_AUTH_SRP6_PROOF", // CMSG_AUTH_SRP6_PROOF + "CMSG_AUTH_SRP6_RECODE", // CMSG_AUTH_SRP6_RECODE + "CMSG_CHAR_CREATE", // CMSG_CHAR_CREATE + "CMSG_CHAR_ENUM", // CMSG_CHAR_ENUM + "CMSG_CHAR_DELETE", // CMSG_CHAR_DELETE + "SMSG_AUTH_SRP6_RESPONSE", // SMSG_AUTH_SRP6_RESPONSE + "SMSG_CHAR_CREATE", // SMSG_CHAR_CREATE + "SMSG_CHAR_ENUM", // SMSG_CHAR_ENUM + "SMSG_CHAR_DELETE", // SMSG_CHAR_DELETE + "CMSG_PLAYER_LOGIN", // CMSG_PLAYER_LOGIN + "SMSG_NEW_WORLD", // SMSG_NEW_WORLD + "SMSG_TRANSFER_PENDING", // SMSG_TRANSFER_PENDING + "SMSG_TRANSFER_ABORTED", // SMSG_TRANSFER_ABORTED + "SMSG_CHARACTER_LOGIN_FAILED", // SMSG_CHARACTER_LOGIN_FAILED + "SMSG_LOGIN_SETTIMESPEED", // SMSG_LOGIN_SETTIMESPEED + "SMSG_GAMETIME_UPDATE", // SMSG_GAMETIME_UPDATE + "CMSG_GAMETIME_SET", // CMSG_GAMETIME_SET + "SMSG_GAMETIME_SET", // SMSG_GAMETIME_SET + "CMSG_GAMESPEED_SET", // CMSG_GAMESPEED_SET + "SMSG_GAMESPEED_SET", // SMSG_GAMESPEED_SET + "CMSG_SERVERTIME", // CMSG_SERVERTIME + "SMSG_SERVERTIME", // SMSG_SERVERTIME + "CMSG_PLAYER_LOGOUT", // CMSG_PLAYER_LOGOUT + "CMSG_LOGOUT_REQUEST", // CMSG_LOGOUT_REQUEST + "SMSG_LOGOUT_RESPONSE", // SMSG_LOGOUT_RESPONSE + "SMSG_LOGOUT_COMPLETE", // SMSG_LOGOUT_COMPLETE + "CMSG_LOGOUT_CANCEL", // CMSG_LOGOUT_CANCEL + "SMSG_LOGOUT_CANCEL_ACK", // SMSG_LOGOUT_CANCEL_ACK + "CMSG_NAME_QUERY", // CMSG_NAME_QUERY + "SMSG_NAME_QUERY_RESPONSE", // SMSG_NAME_QUERY_RESPONSE + "CMSG_PET_NAME_QUERY", // CMSG_PET_NAME_QUERY + "SMSG_PET_NAME_QUERY_RESPONSE", // SMSG_PET_NAME_QUERY_RESPONSE + "CMSG_GUILD_QUERY", // CMSG_GUILD_QUERY + "SMSG_GUILD_QUERY_RESPONSE", // SMSG_GUILD_QUERY_RESPONSE + "CMSG_ITEM_QUERY_SINGLE", // CMSG_ITEM_QUERY_SINGLE + "CMSG_ITEM_QUERY_MULTIPLE", // CMSG_ITEM_QUERY_MULTIPLE + "SMSG_ITEM_QUERY_SINGLE_RESPONSE", // SMSG_ITEM_QUERY_SINGLE_RESPONSE + "SMSG_ITEM_QUERY_MULTIPLE_RESPONSE", // SMSG_ITEM_QUERY_MULTIPLE_RESPONSE + "CMSG_PAGE_TEXT_QUERY", // CMSG_PAGE_TEXT_QUERY + "SMSG_PAGE_TEXT_QUERY_RESPONSE", // SMSG_PAGE_TEXT_QUERY_RESPONSE + "CMSG_QUEST_QUERY", // CMSG_QUEST_QUERY + "SMSG_QUEST_QUERY_RESPONSE", // SMSG_QUEST_QUERY_RESPONSE + "CMSG_GAMEOBJECT_QUERY", // CMSG_GAMEOBJECT_QUERY + "SMSG_GAMEOBJECT_QUERY_RESPONSE", // SMSG_GAMEOBJECT_QUERY_RESPONSE + "CMSG_CREATURE_QUERY", // CMSG_CREATURE_QUERY + "SMSG_CREATURE_QUERY_RESPONSE", // SMSG_CREATURE_QUERY_RESPONSE + "CMSG_WHO", // CMSG_WHO + "SMSG_WHO", // SMSG_WHO + "CMSG_WHOIS", // CMSG_WHOIS + "SMSG_WHOIS", // SMSG_WHOIS + "CMSG_FRIEND_LIST", // CMSG_FRIEND_LIST + "SMSG_FRIEND_LIST", // SMSG_FRIEND_LIST + "SMSG_FRIEND_STATUS", // SMSG_FRIEND_STATUS + "CMSG_ADD_FRIEND", // CMSG_ADD_FRIEND + "CMSG_DEL_FRIEND", // CMSG_DEL_FRIEND + "SMSG_IGNORE_LIST", // SMSG_IGNORE_LIST + "CMSG_ADD_IGNORE", // CMSG_ADD_IGNORE + "CMSG_DEL_IGNORE", // CMSG_DEL_IGNORE + "CMSG_GROUP_INVITE", // CMSG_GROUP_INVITE + "SMSG_GROUP_INVITE", // SMSG_GROUP_INVITE + "CMSG_GROUP_CANCEL", // CMSG_GROUP_CANCEL + "SMSG_GROUP_CANCEL", // SMSG_GROUP_CANCEL + "CMSG_GROUP_ACCEPT", // CMSG_GROUP_ACCEPT + "CMSG_GROUP_DECLINE", // CMSG_GROUP_DECLINE + "SMSG_GROUP_DECLINE", // SMSG_GROUP_DECLINE + "CMSG_GROUP_UNINVITE", // CMSG_GROUP_UNINVITE + "CMSG_GROUP_UNINVITE_GUID", // CMSG_GROUP_UNINVITE_GUID + "SMSG_GROUP_UNINVITE", // SMSG_GROUP_UNINVITE + "CMSG_GROUP_SET_LEADER", // CMSG_GROUP_SET_LEADER + "SMSG_GROUP_SET_LEADER", // SMSG_GROUP_SET_LEADER + "CMSG_LOOT_METHOD", // CMSG_LOOT_METHOD + "CMSG_GROUP_DISBAND", // CMSG_GROUP_DISBAND + "SMSG_GROUP_DESTROYED", // SMSG_GROUP_DESTROYED + "SMSG_GROUP_LIST", // SMSG_GROUP_LIST + "SMSG_PARTY_MEMBER_STATS", // SMSG_PARTY_MEMBER_STATS + "SMSG_PARTY_COMMAND_RESULT", // SMSG_PARTY_COMMAND_RESULT + "UMSG_UPDATE_GROUP_MEMBERS", // UMSG_UPDATE_GROUP_MEMBERS + "CMSG_GUILD_CREATE", // CMSG_GUILD_CREATE + "CMSG_GUILD_INVITE", // CMSG_GUILD_INVITE + "SMSG_GUILD_INVITE", // SMSG_GUILD_INVITE + "CMSG_GUILD_ACCEPT", // CMSG_GUILD_ACCEPT + "CMSG_GUILD_DECLINE", // CMSG_GUILD_DECLINE + "SMSG_GUILD_DECLINE", // SMSG_GUILD_DECLINE + "CMSG_GUILD_INFO", // CMSG_GUILD_INFO + "SMSG_GUILD_INFO", // SMSG_GUILD_INFO + "CMSG_GUILD_ROSTER", // CMSG_GUILD_ROSTER + "SMSG_GUILD_ROSTER", // SMSG_GUILD_ROSTER + "CMSG_GUILD_PROMOTE", // CMSG_GUILD_PROMOTE + "CMSG_GUILD_DEMOTE", // CMSG_GUILD_DEMOTE + "CMSG_GUILD_LEAVE", // CMSG_GUILD_LEAVE + "CMSG_GUILD_REMOVE", // CMSG_GUILD_REMOVE + "CMSG_GUILD_DISBAND", // CMSG_GUILD_DISBAND + "CMSG_GUILD_LEADER", // CMSG_GUILD_LEADER + "CMSG_GUILD_MOTD", // CMSG_GUILD_MOTD + "SMSG_GUILD_EVENT", // SMSG_GUILD_EVENT + "SMSG_GUILD_COMMAND_RESULT", // SMSG_GUILD_COMMAND_RESULT + "UMSG_UPDATE_GUILD", // UMSG_UPDATE_GUILD + "CMSG_MESSAGECHAT", // CMSG_MESSAGECHAT + "SMSG_MESSAGECHAT", // SMSG_MESSAGECHAT + "CMSG_JOIN_CHANNEL", // CMSG_JOIN_CHANNEL + "CMSG_LEAVE_CHANNEL", // CMSG_LEAVE_CHANNEL + "SMSG_CHANNEL_NOTIFY", // SMSG_CHANNEL_NOTIFY + "CMSG_CHANNEL_LIST", // CMSG_CHANNEL_LIST + "SMSG_CHANNEL_LIST", // SMSG_CHANNEL_LIST + "CMSG_CHANNEL_PASSWORD", // CMSG_CHANNEL_PASSWORD + "CMSG_CHANNEL_SET_OWNER", // CMSG_CHANNEL_SET_OWNER + "CMSG_CHANNEL_OWNER", // CMSG_CHANNEL_OWNER + "CMSG_CHANNEL_MODERATOR", // CMSG_CHANNEL_MODERATOR + "CMSG_CHANNEL_UNMODERATOR", // CMSG_CHANNEL_UNMODERATOR + "CMSG_CHANNEL_MUTE", // CMSG_CHANNEL_MUTE + "CMSG_CHANNEL_UNMUTE", // CMSG_CHANNEL_UNMUTE + "CMSG_CHANNEL_INVITE", // CMSG_CHANNEL_INVITE + "CMSG_CHANNEL_KICK", // CMSG_CHANNEL_KICK + "CMSG_CHANNEL_BAN", // CMSG_CHANNEL_BAN + "CMSG_CHANNEL_UNBAN", // CMSG_CHANNEL_UNBAN + "CMSG_CHANNEL_ANNOUNCEMENTS", // CMSG_CHANNEL_ANNOUNCEMENTS + "CMSG_CHANNEL_MODERATE", // CMSG_CHANNEL_MODERATE + "SMSG_UPDATE_OBJECT", // SMSG_UPDATE_OBJECT + "SMSG_DESTROY_OBJECT", // SMSG_DESTROY_OBJECT + "CMSG_USE_ITEM", // CMSG_USE_ITEM + "CMSG_OPEN_ITEM", // CMSG_OPEN_ITEM + "CMSG_READ_ITEM", // CMSG_READ_ITEM + "SMSG_READ_ITEM_OK", // SMSG_READ_ITEM_OK + "SMSG_READ_ITEM_FAILED", // SMSG_READ_ITEM_FAILED + "SMSG_ITEM_COOLDOWN", // SMSG_ITEM_COOLDOWN + "CMSG_GAMEOBJ_USE", // CMSG_GAMEOBJ_USE + "CMSG_GAMEOBJ_CHAIR_USE_OBSOLETE", // CMSG_GAMEOBJ_CHAIR_USE_OBSOLETE + "SMSG_GAMEOBJECT_CUSTOM_ANIM", // SMSG_GAMEOBJECT_CUSTOM_ANIM + "CMSG_AREATRIGGER", // CMSG_AREATRIGGER + "MSG_MOVE_START_FORWARD", // MSG_MOVE_START_FORWARD + "MSG_MOVE_START_BACKWARD", // MSG_MOVE_START_BACKWARD + "MSG_MOVE_STOP", // MSG_MOVE_STOP + "MSG_MOVE_START_STRAFE_LEFT", // MSG_MOVE_START_STRAFE_LEFT + "MSG_MOVE_START_STRAFE_RIGHT", // MSG_MOVE_START_STRAFE_RIGHT + "MSG_MOVE_STOP_STRAFE", // MSG_MOVE_STOP_STRAFE + "MSG_MOVE_JUMP", // MSG_MOVE_JUMP + "MSG_MOVE_START_TURN_LEFT", // MSG_MOVE_START_TURN_LEFT + "MSG_MOVE_START_TURN_RIGHT", // MSG_MOVE_START_TURN_RIGHT + "MSG_MOVE_STOP_TURN", // MSG_MOVE_STOP_TURN + "MSG_MOVE_START_PITCH_UP", // MSG_MOVE_START_PITCH_UP + "MSG_MOVE_START_PITCH_DOWN", // MSG_MOVE_START_PITCH_DOWN + "MSG_MOVE_STOP_PITCH", // MSG_MOVE_STOP_PITCH + "MSG_MOVE_SET_RUN_MODE", // MSG_MOVE_SET_RUN_MODE + "MSG_MOVE_SET_WALK_MODE", // MSG_MOVE_SET_WALK_MODE + "MSG_MOVE_TOGGLE_LOGGING", // MSG_MOVE_TOGGLE_LOGGING + "MSG_MOVE_TELEPORT", // MSG_MOVE_TELEPORT + "MSG_MOVE_TELEPORT_CHEAT", // MSG_MOVE_TELEPORT_CHEAT + "MSG_MOVE_TELEPORT_ACK", // MSG_MOVE_TELEPORT_ACK + "MSG_MOVE_TOGGLE_FALL_LOGGING", // MSG_MOVE_TOGGLE_FALL_LOGGING + "MSG_MOVE_FALL_LAND", // MSG_MOVE_FALL_LAND + "MSG_MOVE_START_SWIM", // MSG_MOVE_START_SWIM + "MSG_MOVE_STOP_SWIM", // MSG_MOVE_STOP_SWIM + "MSG_MOVE_SET_RUN_SPEED_CHEAT", // MSG_MOVE_SET_RUN_SPEED_CHEAT + "MSG_MOVE_SET_RUN_SPEED", // MSG_MOVE_SET_RUN_SPEED + "MSG_MOVE_SET_RUN_BACK_SPEED_CHEAT", // MSG_MOVE_SET_RUN_BACK_SPEED_CHEAT + "MSG_MOVE_SET_RUN_BACK_SPEED", // MSG_MOVE_SET_RUN_BACK_SPEED + "MSG_MOVE_SET_WALK_SPEED_CHEAT", // MSG_MOVE_SET_WALK_SPEED_CHEAT + "MSG_MOVE_SET_WALK_SPEED", // MSG_MOVE_SET_WALK_SPEED + "MSG_MOVE_SET_SWIM_SPEED_CHEAT", // MSG_MOVE_SET_SWIM_SPEED_CHEAT + "MSG_MOVE_SET_SWIM_SPEED", // MSG_MOVE_SET_SWIM_SPEED + "MSG_MOVE_SET_SWIM_BACK_SPEED_CHEAT", // MSG_MOVE_SET_SWIM_BACK_SPEED_CHEAT + "MSG_MOVE_SET_SWIM_BACK_SPEED", // MSG_MOVE_SET_SWIM_BACK_SPEED + "MSG_MOVE_SET_ALL_SPEED_CHEAT", // MSG_MOVE_SET_ALL_SPEED_CHEAT + "MSG_MOVE_SET_TURN_RATE_CHEAT", // MSG_MOVE_SET_TURN_RATE_CHEAT + "MSG_MOVE_SET_TURN_RATE", // MSG_MOVE_SET_TURN_RATE + "MSG_MOVE_TOGGLE_COLLISION_CHEAT", // MSG_MOVE_TOGGLE_COLLISION_CHEAT + "MSG_MOVE_SET_FACING", // MSG_MOVE_SET_FACING + "MSG_MOVE_SET_PITCH", // MSG_MOVE_SET_PITCH + "MSG_MOVE_WORLDPORT_ACK", // MSG_MOVE_WORLDPORT_ACK + "SMSG_MONSTER_MOVE", // SMSG_MONSTER_MOVE + "SMSG_MOVE_WATER_WALK", // SMSG_MOVE_WATER_WALK + "SMSG_MOVE_LAND_WALK", // SMSG_MOVE_LAND_WALK + "MSG_MOVE_SET_RAW_POSITION_ACK", // MSG_MOVE_SET_RAW_POSITION_ACK + "CMSG_MOVE_SET_RAW_POSITION", // CMSG_MOVE_SET_RAW_POSITION + "SMSG_FORCE_RUN_SPEED_CHANGE", // SMSG_FORCE_RUN_SPEED_CHANGE + "CMSG_FORCE_RUN_SPEED_CHANGE_ACK", // CMSG_FORCE_RUN_SPEED_CHANGE_ACK + "SMSG_FORCE_RUN_BACK_SPEED_CHANGE", // SMSG_FORCE_RUN_BACK_SPEED_CHANGE + "CMSG_FORCE_RUN_BACK_SPEED_CHANGE_ACK", // CMSG_FORCE_RUN_BACK_SPEED_CHANGE_ACK + "SMSG_FORCE_SWIM_SPEED_CHANGE", // SMSG_FORCE_SWIM_SPEED_CHANGE + "CMSG_FORCE_SWIM_SPEED_CHANGE_ACK", // CMSG_FORCE_SWIM_SPEED_CHANGE_ACK + "SMSG_FORCE_MOVE_ROOT", // SMSG_FORCE_MOVE_ROOT + "CMSG_FORCE_MOVE_ROOT_ACK", // CMSG_FORCE_MOVE_ROOT_ACK + "SMSG_FORCE_MOVE_UNROOT", // SMSG_FORCE_MOVE_UNROOT + "CMSG_FORCE_MOVE_UNROOT_ACK", // CMSG_FORCE_MOVE_UNROOT_ACK + "MSG_MOVE_ROOT", // MSG_MOVE_ROOT + "MSG_MOVE_UNROOT", // MSG_MOVE_UNROOT + "MSG_MOVE_HEARTBEAT", // MSG_MOVE_HEARTBEAT + "SMSG_MOVE_KNOCK_BACK", // SMSG_MOVE_KNOCK_BACK + "CMSG_MOVE_KNOCK_BACK_ACK", // CMSG_MOVE_KNOCK_BACK_ACK + "MSG_MOVE_KNOCK_BACK", // MSG_MOVE_KNOCK_BACK + "SMSG_MOVE_FEATHER_FALL", // SMSG_MOVE_FEATHER_FALL + "SMSG_MOVE_NORMAL_FALL", // SMSG_MOVE_NORMAL_FALL + "SMSG_MOVE_SET_HOVER", // SMSG_MOVE_SET_HOVER + "SMSG_MOVE_UNSET_HOVER", // SMSG_MOVE_UNSET_HOVER + "CMSG_MOVE_HOVER_ACK", // CMSG_MOVE_HOVER_ACK + "MSG_MOVE_HOVER", // MSG_MOVE_HOVER + "CMSG_TRIGGER_CINEMATIC_CHEAT", // CMSG_TRIGGER_CINEMATIC_CHEAT + "CMSG_OPENING_CINEMATIC", // CMSG_OPENING_CINEMATIC + "SMSG_TRIGGER_CINEMATIC", // SMSG_TRIGGER_CINEMATIC + "CMSG_NEXT_CINEMATIC_CAMERA", // CMSG_NEXT_CINEMATIC_CAMERA + "CMSG_COMPLETE_CINEMATIC", // CMSG_COMPLETE_CINEMATIC + "SMSG_TUTORIAL_FLAGS", // SMSG_TUTORIAL_FLAGS + "CMSG_TUTORIAL_FLAG", // CMSG_TUTORIAL_FLAG + "CMSG_TUTORIAL_CLEAR", // CMSG_TUTORIAL_CLEAR + "CMSG_TUTORIAL_RESET", // CMSG_TUTORIAL_RESET + "CMSG_STANDSTATECHANGE", // CMSG_STANDSTATECHANGE + "CMSG_EMOTE", // CMSG_EMOTE + "SMSG_EMOTE", // SMSG_EMOTE + "CMSG_TEXT_EMOTE", // CMSG_TEXT_EMOTE + "SMSG_TEXT_EMOTE", // SMSG_TEXT_EMOTE + "CMSG_AUTOEQUIP_GROUND_ITEM", // CMSG_AUTOEQUIP_GROUND_ITEM + "CMSG_AUTOSTORE_GROUND_ITEM", // CMSG_AUTOSTORE_GROUND_ITEM + "CMSG_AUTOSTORE_LOOT_ITEM", // CMSG_AUTOSTORE_LOOT_ITEM + "CMSG_STORE_LOOT_IN_SLOT", // CMSG_STORE_LOOT_IN_SLOT + "CMSG_AUTOEQUIP_ITEM", // CMSG_AUTOEQUIP_ITEM + "CMSG_AUTOSTORE_BAG_ITEM", // CMSG_AUTOSTORE_BAG_ITEM + "CMSG_SWAP_ITEM", // CMSG_SWAP_ITEM + "CMSG_SWAP_INV_ITEM", // CMSG_SWAP_INV_ITEM + "CMSG_SPLIT_ITEM", // CMSG_SPLIT_ITEM + "CMSG_PICKUP_ITEM", // CMSG_PICKUP_ITEM + "CMSG_DROP_ITEM", // CMSG_DROP_ITEM + "CMSG_DESTROYITEM", // CMSG_DESTROYITEM + "SMSG_INVENTORY_CHANGE_FAILURE", // SMSG_INVENTORY_CHANGE_FAILURE + "SMSG_OPEN_CONTAINER", // SMSG_OPEN_CONTAINER + "CMSG_INSPECT", // CMSG_INSPECT + "SMSG_INSPECT", // SMSG_INSPECT + "CMSG_INITIATE_TRADE", // CMSG_INITIATE_TRADE + "CMSG_BEGIN_TRADE", // CMSG_BEGIN_TRADE + "CMSG_BUSY_TRADE", // CMSG_BUSY_TRADE + "CMSG_IGNORE_TRADE", // CMSG_IGNORE_TRADE + "CMSG_ACCEPT_TRADE", // CMSG_ACCEPT_TRADE + "CMSG_UNACCEPT_TRADE", // CMSG_UNACCEPT_TRADE + "CMSG_CANCEL_TRADE", // CMSG_CANCEL_TRADE + "CMSG_SET_TRADE_ITEM", // CMSG_SET_TRADE_ITEM + "CMSG_CLEAR_TRADE_ITEM", // CMSG_CLEAR_TRADE_ITEM + "CMSG_SET_TRADE_GOLD", // CMSG_SET_TRADE_GOLD + "SMSG_TRADE_STATUS", // SMSG_TRADE_STATUS + "SMSG_TRADE_STATUS_EXTENDED", // SMSG_TRADE_STATUS_EXTENDED + "SMSG_INITIALIZE_FACTIONS", // SMSG_INITIALIZE_FACTIONS + "SMSG_SET_FACTION_VISIBLE", // SMSG_SET_FACTION_VISIBLE + "SMSG_SET_FACTION_STANDING", // SMSG_SET_FACTION_STANDING + "CMSG_SET_FACTION_ATWAR", // CMSG_SET_FACTION_ATWAR + "CMSG_SET_FACTION_CHEAT", // CMSG_SET_FACTION_CHEAT + "SMSG_SET_PROFICIENCY", // SMSG_SET_PROFICIENCY + "CMSG_SET_ACTION_BUTTON", // CMSG_SET_ACTION_BUTTON + "SMSG_ACTION_BUTTONS", // SMSG_ACTION_BUTTONS + "SMSG_INITIAL_SPELLS", // SMSG_INITIAL_SPELLS + "SMSG_LEARNED_SPELL", // SMSG_LEARNED_SPELL + "SMSG_SUPERCEDED_SPELL", // SMSG_SUPERCEDED_SPELL + "CMSG_NEW_SPELL_SLOT", // CMSG_NEW_SPELL_SLOT + "CMSG_CAST_SPELL", // CMSG_CAST_SPELL + "CMSG_CANCEL_CAST", // CMSG_CANCEL_CAST + "SMSG_CAST_RESULT", // SMSG_CAST_RESULT + "SMSG_SPELL_START", // SMSG_SPELL_START + "SMSG_SPELL_GO", // SMSG_SPELL_GO + "SMSG_SPELL_FAILURE", // SMSG_SPELL_FAILURE + "SMSG_SPELL_COOLDOWN", // SMSG_SPELL_COOLDOWN + "SMSG_COOLDOWN_EVENT", // SMSG_COOLDOWN_EVENT + "CMSG_CANCEL_AURA", // CMSG_CANCEL_AURA + "SMSG_UPDATE_AURA_DURATION", // SMSG_UPDATE_AURA_DURATION + "SMSG_PET_CAST_FAILED", // SMSG_PET_CAST_FAILED + "MSG_CHANNEL_START", // MSG_CHANNEL_START + "MSG_CHANNEL_UPDATE", // MSG_CHANNEL_UPDATE + "CMSG_CANCEL_CHANNELLING", // CMSG_CANCEL_CHANNELLING + "SMSG_AI_REACTION", // SMSG_AI_REACTION + "CMSG_SET_SELECTION", // CMSG_SET_SELECTION + "CMSG_SET_TARGET_OBSOLETE", // CMSG_SET_TARGET_OBSOLETE + "CMSG_UNUSED", // CMSG_UNUSED + "CMSG_UNUSED2", // CMSG_UNUSED2 + "CMSG_ATTACKSWING", // CMSG_ATTACKSWING + "CMSG_ATTACKSTOP", // CMSG_ATTACKSTOP + "SMSG_ATTACKSTART", // SMSG_ATTACKSTART + "SMSG_ATTACKSTOP", // SMSG_ATTACKSTOP + "SMSG_ATTACKSWING_NOTINRANGE", // SMSG_ATTACKSWING_NOTINRANGE + "SMSG_ATTACKSWING_BADFACING", // SMSG_ATTACKSWING_BADFACING + "SMSG_ATTACKSWING_NOTSTANDING", // SMSG_ATTACKSWING_NOTSTANDING + "SMSG_ATTACKSWING_DEADTARGET", // SMSG_ATTACKSWING_DEADTARGET + "SMSG_ATTACKSWING_CANT_ATTACK", // SMSG_ATTACKSWING_CANT_ATTACK + "SMSG_ATTACKERSTATEUPDATE", // SMSG_ATTACKERSTATEUPDATE + "SMSG_VICTIMSTATEUPDATE_OBSOLETE", // SMSG_VICTIMSTATEUPDATE_OBSOLETE + "SMSG_DAMAGE_DONE_OBSOLETE", // SMSG_DAMAGE_DONE_OBSOLETE + "SMSG_DAMAGE_TAKEN_OBSOLETE", // SMSG_DAMAGE_TAKEN_OBSOLETE + "SMSG_CANCEL_COMBAT", // SMSG_CANCEL_COMBAT + "SMSG_PLAYER_COMBAT_XP_GAIN_OBSOLETE", // SMSG_PLAYER_COMBAT_XP_GAIN_OBSOLETE + "SMSG_HEALSPELL_ON_PLAYER_OBSOLETE", // SMSG_HEALSPELL_ON_PLAYER_OBSOLETE + "SMSG_HEALSPELL_ON_PLAYERS_PET_OBSOLETE", // SMSG_HEALSPELL_ON_PLAYERS_PET_OBSOLETE + "CMSG_SHEATHE_OBSOLETE", // CMSG_SHEATHE_OBSOLETE + "CMSG_SAVE_PLAYER", // CMSG_SAVE_PLAYER + "CMSG_SETDEATHBINDPOINT", // CMSG_SETDEATHBINDPOINT + "SMSG_BINDPOINTUPDATE", // SMSG_BINDPOINTUPDATE + "CMSG_GETDEATHBINDZONE", // CMSG_GETDEATHBINDZONE + "SMSG_BINDZONEREPLY", // SMSG_BINDZONEREPLY + "SMSG_PLAYERBOUND", // SMSG_PLAYERBOUND + "SMSG_DEATH_NOTIFY_OBSOLETE", // SMSG_DEATH_NOTIFY_OBSOLETE + "CMSG_REPOP_REQUEST", // CMSG_REPOP_REQUEST + "SMSG_RESURRECT_REQUEST", // SMSG_RESURRECT_REQUEST + "CMSG_RESURRECT_RESPONSE", // CMSG_RESURRECT_RESPONSE + "CMSG_LOOT", // CMSG_LOOT + "CMSG_LOOT_MONEY", // CMSG_LOOT_MONEY + "CMSG_LOOT_RELEASE", // CMSG_LOOT_RELEASE + "SMSG_LOOT_RESPONSE", // SMSG_LOOT_RESPONSE + "SMSG_LOOT_RELEASE_RESPONSE", // SMSG_LOOT_RELEASE_RESPONSE + "SMSG_LOOT_REMOVED", // SMSG_LOOT_REMOVED + "SMSG_LOOT_MONEY_NOTIFY", // SMSG_LOOT_MONEY_NOTIFY + "SMSG_LOOT_ITEM_NOTIFY", // SMSG_LOOT_ITEM_NOTIFY + "SMSG_LOOT_CLEAR_MONEY", // SMSG_LOOT_CLEAR_MONEY + "SMSG_ITEM_PUSH_RESULT", // SMSG_ITEM_PUSH_RESULT + "SMSG_DUEL_REQUESTED", // SMSG_DUEL_REQUESTED + "SMSG_DUEL_OUTOFBOUNDS", // SMSG_DUEL_OUTOFBOUNDS + "SMSG_DUEL_INBOUNDS", // SMSG_DUEL_INBOUNDS + "SMSG_DUEL_COMPLETE", // SMSG_DUEL_COMPLETE + "SMSG_DUEL_WINNER", // SMSG_DUEL_WINNER + "CMSG_DUEL_ACCEPTED", // CMSG_DUEL_ACCEPTED + "CMSG_DUEL_CANCELLED", // CMSG_DUEL_CANCELLED + "SMSG_MOUNTRESULT", // SMSG_MOUNTRESULT + "SMSG_DISMOUNTRESULT", // SMSG_DISMOUNTRESULT + "SMSG_PUREMOUNT_CANCELLED_OBSOLETE", // SMSG_PUREMOUNT_CANCELLED_OBSOLETE + "CMSG_MOUNTSPECIAL_ANIM", // CMSG_MOUNTSPECIAL_ANIM + "SMSG_MOUNTSPECIAL_ANIM", // SMSG_MOUNTSPECIAL_ANIM + "SMSG_PET_TAME_FAILURE", // SMSG_PET_TAME_FAILURE + "CMSG_PET_SET_ACTION", // CMSG_PET_SET_ACTION + "CMSG_PET_ACTION", // CMSG_PET_ACTION + "CMSG_PET_ABANDON", // CMSG_PET_ABANDON + "CMSG_PET_RENAME", // CMSG_PET_RENAME + "SMSG_PET_NAME_INVALID", // SMSG_PET_NAME_INVALID + "SMSG_PET_SPELLS", // SMSG_PET_SPELLS + "SMSG_PET_MODE", // SMSG_PET_MODE + "CMSG_GOSSIP_HELLO", // CMSG_GOSSIP_HELLO + "CMSG_GOSSIP_SELECT_OPTION", // CMSG_GOSSIP_SELECT_OPTION + "SMSG_GOSSIP_MESSAGE", // SMSG_GOSSIP_MESSAGE + "SMSG_GOSSIP_COMPLETE", // SMSG_GOSSIP_COMPLETE + "CMSG_NPC_TEXT_QUERY", // CMSG_NPC_TEXT_QUERY + "SMSG_NPC_TEXT_UPDATE", // SMSG_NPC_TEXT_UPDATE + "SMSG_NPC_WONT_TALK", // SMSG_NPC_WONT_TALK + "CMSG_QUESTGIVER_STATUS_QUERY", // CMSG_QUESTGIVER_STATUS_QUERY + "SMSG_QUESTGIVER_STATUS", // SMSG_QUESTGIVER_STATUS + "CMSG_QUESTGIVER_HELLO", // CMSG_QUESTGIVER_HELLO + "SMSG_QUESTGIVER_QUEST_LIST", // SMSG_QUESTGIVER_QUEST_LIST + "CMSG_QUESTGIVER_QUERY_QUEST", // CMSG_QUESTGIVER_QUERY_QUEST + "CMSG_QUESTGIVER_QUEST_AUTOLAUNCH", // CMSG_QUESTGIVER_QUEST_AUTOLAUNCH + "SMSG_QUESTGIVER_QUEST_DETAILS", // SMSG_QUESTGIVER_QUEST_DETAILS + "CMSG_QUESTGIVER_ACCEPT_QUEST", // CMSG_QUESTGIVER_ACCEPT_QUEST + "CMSG_QUESTGIVER_COMPLETE_QUEST", // CMSG_QUESTGIVER_COMPLETE_QUEST + "SMSG_QUESTGIVER_REQUEST_ITEMS", // SMSG_QUESTGIVER_REQUEST_ITEMS + "CMSG_QUESTGIVER_REQUEST_REWARD", // CMSG_QUESTGIVER_REQUEST_REWARD + "SMSG_QUESTGIVER_OFFER_REWARD", // SMSG_QUESTGIVER_OFFER_REWARD + "CMSG_QUESTGIVER_CHOOSE_REWARD", // CMSG_QUESTGIVER_CHOOSE_REWARD + "SMSG_QUESTGIVER_QUEST_INVALID", // SMSG_QUESTGIVER_QUEST_INVALID + "CMSG_QUESTGIVER_CANCEL", // CMSG_QUESTGIVER_CANCEL + "SMSG_QUESTGIVER_QUEST_COMPLETE", // SMSG_QUESTGIVER_QUEST_COMPLETE + "SMSG_QUESTGIVER_QUEST_FAILED", // SMSG_QUESTGIVER_QUEST_FAILED + "CMSG_QUESTLOG_SWAP_QUEST", // CMSG_QUESTLOG_SWAP_QUEST + "CMSG_QUESTLOG_REMOVE_QUEST", // CMSG_QUESTLOG_REMOVE_QUEST + "SMSG_QUESTLOG_FULL", // SMSG_QUESTLOG_FULL + "SMSG_QUESTUPDATE_FAILED", // SMSG_QUESTUPDATE_FAILED + "SMSG_QUESTUPDATE_FAILEDTIMER", // SMSG_QUESTUPDATE_FAILEDTIMER + "SMSG_QUESTUPDATE_COMPLETE", // SMSG_QUESTUPDATE_COMPLETE + "SMSG_QUESTUPDATE_ADD_KILL", // SMSG_QUESTUPDATE_ADD_KILL + "SMSG_QUESTUPDATE_ADD_ITEM", // SMSG_QUESTUPDATE_ADD_ITEM + "CMSG_QUEST_CONFIRM_ACCEPT", // CMSG_QUEST_CONFIRM_ACCEPT + "SMSG_QUEST_CONFIRM_ACCEPT", // SMSG_QUEST_CONFIRM_ACCEPT + "CMSG_PUSHQUESTTOPARTY", // CMSG_PUSHQUESTTOPARTY + "CMSG_LIST_INVENTORY", // CMSG_LIST_INVENTORY + "SMSG_LIST_INVENTORY", // SMSG_LIST_INVENTORY + "CMSG_SELL_ITEM", // CMSG_SELL_ITEM + "SMSG_SELL_ITEM", // SMSG_SELL_ITEM + "CMSG_BUY_ITEM", // CMSG_BUY_ITEM + "CMSG_BUY_ITEM_IN_SLOT", // CMSG_BUY_ITEM_IN_SLOT + "SMSG_BUY_ITEM", // SMSG_BUY_ITEM + "SMSG_BUY_FAILED", // SMSG_BUY_FAILED + "CMSG_TAXICLEARALLNODES", // CMSG_TAXICLEARALLNODES + "CMSG_TAXIENABLEALLNODES", // CMSG_TAXIENABLEALLNODES + "CMSG_TAXISHOWNODES", // CMSG_TAXISHOWNODES + "SMSG_SHOWTAXINODES", // SMSG_SHOWTAXINODES + "CMSG_TAXINODE_STATUS_QUERY", // CMSG_TAXINODE_STATUS_QUERY + "SMSG_TAXINODE_STATUS", // SMSG_TAXINODE_STATUS + "CMSG_TAXIQUERYAVAILABLENODES", // CMSG_TAXIQUERYAVAILABLENODES + "CMSG_ACTIVATETAXI", // CMSG_ACTIVATETAXI + "SMSG_ACTIVATETAXIREPLY", // SMSG_ACTIVATETAXIREPLY + "SMSG_NEW_TAXI_PATH", // SMSG_NEW_TAXI_PATH + "CMSG_TRAINER_LIST", // CMSG_TRAINER_LIST + "SMSG_TRAINER_LIST", // SMSG_TRAINER_LIST + "CMSG_TRAINER_BUY_SPELL", // CMSG_TRAINER_BUY_SPELL + "SMSG_TRAINER_BUY_SUCCEEDED", // SMSG_TRAINER_BUY_SUCCEEDED + "SMSG_TRAINER_BUY_FAILED", // SMSG_TRAINER_BUY_FAILED + "CMSG_BINDER_ACTIVATE", // CMSG_BINDER_ACTIVATE + "SMSG_PLAYERBINDERROR", // SMSG_PLAYERBINDERROR + "CMSG_BANKER_ACTIVATE", // CMSG_BANKER_ACTIVATE + "SMSG_SHOW_BANK", // SMSG_SHOW_BANK + "CMSG_BUY_BANK_SLOT", // CMSG_BUY_BANK_SLOT + "SMSG_BUY_BANK_SLOT_RESULT", // SMSG_BUY_BANK_SLOT_RESULT + "CMSG_PETITION_SHOWLIST", // CMSG_PETITION_SHOWLIST + "SMSG_PETITION_SHOWLIST", // SMSG_PETITION_SHOWLIST + "CMSG_PETITION_BUY", // CMSG_PETITION_BUY + "CMSG_PETITION_SHOW_SIGNATURES", // CMSG_PETITION_SHOW_SIGNATURES + "SMSG_PETITION_SHOW_SIGNATURES", // SMSG_PETITION_SHOW_SIGNATURES + "CMSG_PETITION_SIGN", // CMSG_PETITION_SIGN + "SMSG_PETITION_SIGN_RESULTS", // SMSG_PETITION_SIGN_RESULTS + "MSG_PETITION_DECLINE", // MSG_PETITION_DECLINE + "CMSG_OFFER_PETITION", // CMSG_OFFER_PETITION + "CMSG_TURN_IN_PETITION", // CMSG_TURN_IN_PETITION + "SMSG_TURN_IN_PETITION_RESULTS", // SMSG_TURN_IN_PETITION_RESULTS + "CMSG_PETITION_QUERY", // CMSG_PETITION_QUERY + "SMSG_PETITION_QUERY_RESPONSE", // SMSG_PETITION_QUERY_RESPONSE + "SMSG_FISH_NOT_HOOKED", // SMSG_FISH_NOT_HOOKED + "SMSG_FISH_ESCAPED", // SMSG_FISH_ESCAPED + "CMSG_BUG", // CMSG_BUG + "SMSG_NOTIFICATION", // SMSG_NOTIFICATION + "CMSG_PLAYED_TIME", // CMSG_PLAYED_TIME + "SMSG_PLAYED_TIME", // SMSG_PLAYED_TIME + "CMSG_QUERY_TIME", // CMSG_QUERY_TIME + "SMSG_QUERY_TIME_RESPONSE", // SMSG_QUERY_TIME_RESPONSE + "SMSG_LOG_XPGAIN", // SMSG_LOG_XPGAIN + "MSG_SPLIT_MONEY", // MSG_SPLIT_MONEY + "CMSG_RECLAIM_CORPSE", // CMSG_RECLAIM_CORPSE + "CMSG_WRAP_ITEM", // CMSG_WRAP_ITEM + "SMSG_LEVELUP_INFO", // SMSG_LEVELUP_INFO + "MSG_MINIMAP_PING", // MSG_MINIMAP_PING + "SMSG_RESISTLOG", // SMSG_RESISTLOG + "SMSG_ENCHANTMENTLOG", // SMSG_ENCHANTMENTLOG + "CMSG_SET_SKILL_CHEAT", // CMSG_SET_SKILL_CHEAT + "SMSG_START_MIRROR_TIMER", // SMSG_START_MIRROR_TIMER + "SMSG_PAUSE_MIRROR_TIMER", // SMSG_PAUSE_MIRROR_TIMER + "SMSG_STOP_MIRROR_TIMER", // SMSG_STOP_MIRROR_TIMER + "CMSG_PING", // CMSG_PING + "SMSG_PONG", // SMSG_PONG + "SMSG_CLEAR_COOLDOWN", // SMSG_CLEAR_COOLDOWN + "SMSG_GAMEOBJECT_PAGETEXT", // SMSG_GAMEOBJECT_PAGETEXT + "CMSG_SETSHEATHED", // CMSG_SETSHEATHED + "SMSG_COOLDOWN_CHEAT", // SMSG_COOLDOWN_CHEAT + "SMSG_SPELL_DELAYED", // SMSG_SPELL_DELAYED + "CMSG_PLAYER_MACRO_OBSOLETE", // CMSG_PLAYER_MACRO_OBSOLETE + "SMSG_PLAYER_MACRO_OBSOLETE", // SMSG_PLAYER_MACRO_OBSOLETE + "CMSG_GHOST", // CMSG_GHOST + "CMSG_GM_INVIS", // CMSG_GM_INVIS + "SMSG_INVALID_PROMOTION_CODE", // SMSG_INVALID_PROMOTION_CODE + "MSG_GM_BIND_OTHER", // MSG_GM_BIND_OTHER + "MSG_GM_SUMMON", // MSG_GM_SUMMON + "SMSG_ITEM_TIME_UPDATE", // SMSG_ITEM_TIME_UPDATE + "SMSG_ITEM_ENCHANT_TIME_UPDATE", // SMSG_ITEM_ENCHANT_TIME_UPDATE + "SMSG_AUTH_CHALLENGE", // SMSG_AUTH_CHALLENGE + "CMSG_AUTH_SESSION", // CMSG_AUTH_SESSION + "SMSG_AUTH_RESPONSE", // SMSG_AUTH_RESPONSE + "MSG_GM_SHOWLABEL", // MSG_GM_SHOWLABEL + "MSG_ADD_DYNAMIC_TARGET_OBSOLETE", // MSG_ADD_DYNAMIC_TARGET_OBSOLETE + "MSG_SAVE_GUILD_EMBLEM", // MSG_SAVE_GUILD_EMBLEM + "MSG_TABARDVENDOR_ACTIVATE", // MSG_TABARDVENDOR_ACTIVATE + "SMSG_PLAY_SPELL_VISUAL", // SMSG_PLAY_SPELL_VISUAL + "CMSG_ZONEUPDATE", // CMSG_ZONEUPDATE + "SMSG_PARTYKILLLOG", // SMSG_PARTYKILLLOG + "SMSG_COMPRESSED_UPDATE_OBJECT", // SMSG_COMPRESSED_UPDATE_OBJECT + "SMSG_OBSOLETE", // SMSG_OBSOLETE + "SMSG_EXPLORATION_EXPERIENCE", // SMSG_EXPLORATION_EXPERIENCE + "CMSG_GM_SET_SECURITY_GROUP", // CMSG_GM_SET_SECURITY_GROUP + "CMSG_GM_NUKE", // CMSG_GM_NUKE + "MSG_RANDOM_ROLL", // MSG_RANDOM_ROLL + "SMSG_ENVIRONMENTALDAMAGELOG", // SMSG_ENVIRONMENTALDAMAGELOG + "CMSG_RWHOIS", // CMSG_RWHOIS + "SMSG_RWHOIS", // SMSG_RWHOIS + "MSG_LOOKING_FOR_GROUP", // MSG_LOOKING_FOR_GROUP + "CMSG_SET_LOOKING_FOR_GROUP", // CMSG_SET_LOOKING_FOR_GROUP + "CMSG_UNLEARN_SPELL", // CMSG_UNLEARN_SPELL + "CMSG_UNLEARN_SKILL", // CMSG_UNLEARN_SKILL + "SMSG_REMOVED_SPELL", // SMSG_REMOVED_SPELL + "CMSG_DECHARGE", // CMSG_DECHARGE + "CMSG_GMTICKET_CREATE", // CMSG_GMTICKET_CREATE + "SMSG_GMTICKET_CREATE", // SMSG_GMTICKET_CREATE + "CMSG_GMTICKET_UPDATETEXT", // CMSG_GMTICKET_UPDATETEXT + "SMSG_GMTICKET_UPDATETEXT", // SMSG_GMTICKET_UPDATETEXT + "SMSG_ACCOUNT_DATA_MD5", // SMSG_ACCOUNT_DATA_MD5 + "CMSG_REQUEST_ACCOUNT_DATA", // CMSG_REQUEST_ACCOUNT_DATA + "CMSG_UPDATE_ACCOUNT_DATA", // CMSG_UPDATE_ACCOUNT_DATA + "SMSG_UPDATE_ACCOUNT_DATA", // SMSG_UPDATE_ACCOUNT_DATA + "SMSG_CLEAR_FAR_SIGHT_IMMEDIATE", // SMSG_CLEAR_FAR_SIGHT_IMMEDIATE + "SMSG_POWERGAINLOG_OBSOLETE", // SMSG_POWERGAINLOG_OBSOLETE + "CMSG_GM_TEACH", // CMSG_GM_TEACH + "CMSG_GM_CREATE_ITEM_TARGET", // CMSG_GM_CREATE_ITEM_TARGET + "CMSG_GMTICKET_GETTICKET", // CMSG_GMTICKET_GETTICKET + "SMSG_GMTICKET_GETTICKET", // SMSG_GMTICKET_GETTICKET + "CMSG_UNLEARN_TALENTS", // CMSG_UNLEARN_TALENTS + "SMSG_GAMEOBJECT_SPAWN_ANIM", // SMSG_GAMEOBJECT_SPAWN_ANIM + "SMSG_GAMEOBJECT_DESPAWN_ANIM", // SMSG_GAMEOBJECT_DESPAWN_ANIM + "MSG_CORPSE_QUERY", // MSG_CORPSE_QUERY + "CMSG_GMTICKET_DELETETICKET", // CMSG_GMTICKET_DELETETICKET + "SMSG_GMTICKET_DELETETICKET", // SMSG_GMTICKET_DELETETICKET + "SMSG_CHAT_WRONG_FACTION", // SMSG_CHAT_WRONG_FACTION + "CMSG_GMTICKET_SYSTEMSTATUS", // CMSG_GMTICKET_SYSTEMSTATUS + "SMSG_GMTICKET_SYSTEMSTATUS", // SMSG_GMTICKET_SYSTEMSTATUS + "CMSG_SPIRIT_HEALER_ACTIVATE", // CMSG_SPIRIT_HEALER_ACTIVATE + "CMSG_SET_STAT_CHEAT", // CMSG_SET_STAT_CHEAT + "SMSG_SET_REST_START", // SMSG_SET_REST_START + "CMSG_SKILL_BUY_STEP", // CMSG_SKILL_BUY_STEP + "CMSG_SKILL_BUY_RANK", // CMSG_SKILL_BUY_RANK + "CMSG_XP_CHEAT", // CMSG_XP_CHEAT + "SMSG_SPIRIT_HEALER_CONFIRM", // SMSG_SPIRIT_HEALER_CONFIRM + "CMSG_CHARACTER_POINT_CHEAT", // CMSG_CHARACTER_POINT_CHEAT + "SMSG_GOSSIP_POI", // SMSG_GOSSIP_POI + "CMSG_CHAT_IGNORED", // CMSG_CHAT_IGNORED + "CMSG_GM_VISION", // CMSG_GM_VISION + "CMSG_SERVER_COMMAND", // CMSG_SERVER_COMMAND + "CMSG_GM_SILENCE", // CMSG_GM_SILENCE + "CMSG_GM_REVEALTO", // CMSG_GM_REVEALTO + "CMSG_GM_RESURRECT", // CMSG_GM_RESURRECT + "CMSG_GM_SUMMONMOB", // CMSG_GM_SUMMONMOB + "CMSG_GM_MOVECORPSE", // CMSG_GM_MOVECORPSE + "CMSG_GM_FREEZE", // CMSG_GM_FREEZE + "CMSG_GM_UBERINVIS", // CMSG_GM_UBERINVIS + "CMSG_GM_REQUEST_PLAYER_INFO", // CMSG_GM_REQUEST_PLAYER_INFO + "SMSG_GM_PLAYER_INFO", // SMSG_GM_PLAYER_INFO + "CMSG_GUILD_RANK", // CMSG_GUILD_RANK + "CMSG_GUILD_ADD_RANK", // CMSG_GUILD_ADD_RANK + "CMSG_GUILD_DEL_RANK", // CMSG_GUILD_DEL_RANK + "CMSG_GUILD_SET_PUBLIC_NOTE", // CMSG_GUILD_SET_PUBLIC_NOTE + "CMSG_GUILD_SET_OFFICER_NOTE", // CMSG_GUILD_SET_OFFICER_NOTE + "SMSG_LOGIN_VERIFY_WORLD", // SMSG_LOGIN_VERIFY_WORLD + "CMSG_CLEAR_EXPLORATION", // CMSG_CLEAR_EXPLORATION + "CMSG_SEND_MAIL", // CMSG_SEND_MAIL + "SMSG_SEND_MAIL_RESULT", // SMSG_SEND_MAIL_RESULT + "CMSG_GET_MAIL_LIST", // CMSG_GET_MAIL_LIST + "SMSG_MAIL_LIST_RESULT", // SMSG_MAIL_LIST_RESULT + "CMSG_BATTLEFIELD_LIST", // CMSG_BATTLEFIELD_LIST + "SMSG_BATTLEFIELD_LIST", // SMSG_BATTLEFIELD_LIST + "CMSG_BATTLEFIELD_JOIN", // CMSG_BATTLEFIELD_JOIN + "SMSG_BATTLEFIELD_WIN", // SMSG_BATTLEFIELD_WIN + "SMSG_BATTLEFIELD_LOSE", // SMSG_BATTLEFIELD_LOSE + "CMSG_TAXICLEARNODE", // CMSG_TAXICLEARNODE + "CMSG_TAXIENABLENODE", // CMSG_TAXIENABLENODE + "CMSG_ITEM_TEXT_QUERY", // CMSG_ITEM_TEXT_QUERY + "SMSG_ITEM_TEXT_QUERY_RESPONSE", // SMSG_ITEM_TEXT_QUERY_RESPONSE + "CMSG_MAIL_TAKE_MONEY", // CMSG_MAIL_TAKE_MONEY + "CMSG_MAIL_TAKE_ITEM", // CMSG_MAIL_TAKE_ITEM + "CMSG_MAIL_MARK_AS_READ", // CMSG_MAIL_MARK_AS_READ + "CMSG_MAIL_RETURN_TO_SENDER", // CMSG_MAIL_RETURN_TO_SENDER + "CMSG_MAIL_DELETE", // CMSG_MAIL_DELETE + "CMSG_MAIL_CREATE_TEXT_ITEM", // CMSG_MAIL_CREATE_TEXT_ITEM + "SMSG_SPELLLOGMISS", // SMSG_SPELLLOGMISS + "SMSG_SPELLLOGEXECUTE", // SMSG_SPELLLOGEXECUTE + "SMSG_DEBUGAURAPROC", // SMSG_DEBUGAURAPROC + "SMSG_PERIODICAURALOG", // SMSG_PERIODICAURALOG + "SMSG_SPELLDAMAGESHIELD", // SMSG_SPELLDAMAGESHIELD + "SMSG_SPELLNONMELEEDAMAGELOG", // SMSG_SPELLNONMELEEDAMAGELOG + "CMSG_LEARN_TALENT", // CMSG_LEARN_TALENT + "SMSG_RESURRECT_FAILED", // SMSG_RESURRECT_FAILED + "CMSG_TOGGLE_PVP", // CMSG_TOGGLE_PVP + "SMSG_ZONE_UNDER_ATTACK", // SMSG_ZONE_UNDER_ATTACK + "MSG_AUCTION_HELLO", // MSG_AUCTION_HELLO + "CMSG_AUCTION_SELL_ITEM", // CMSG_AUCTION_SELL_ITEM + "CMSG_AUCTION_REMOVE_ITEM", // CMSG_AUCTION_REMOVE_ITEM + "CMSG_AUCTION_LIST_ITEMS", // CMSG_AUCTION_LIST_ITEMS + "CMSG_AUCTION_LIST_OWNER_ITEMS", // CMSG_AUCTION_LIST_OWNER_ITEMS + "CMSG_AUCTION_PLACE_BID", // CMSG_AUCTION_PLACE_BID + "SMSG_AUCTION_COMMAND_RESULT", // SMSG_AUCTION_COMMAND_RESULT + "SMSG_AUCTION_LIST_RESULT", // SMSG_AUCTION_LIST_RESULT + "SMSG_AUCTION_OWNER_LIST_RESULT", // SMSG_AUCTION_OWNER_LIST_RESULT + "SMSG_AUCTION_BIDDER_NOTIFICATION", // SMSG_AUCTION_BIDDER_NOTIFICATION + "SMSG_AUCTION_OWNER_NOTIFICATION", // SMSG_AUCTION_OWNER_NOTIFICATION + "SMSG_PROCRESIST", // SMSG_PROCRESIST + "SMSG_STANDSTATE_CHANGE_FAILURE", // SMSG_STANDSTATE_CHANGE_FAILURE + "SMSG_DISPEL_FAILED", // SMSG_DISPEL_FAILED + "SMSG_SPELLORDAMAGE_IMMUNE", // SMSG_SPELLORDAMAGE_IMMUNE + "CMSG_AUCTION_LIST_BIDDER_ITEMS", // CMSG_AUCTION_LIST_BIDDER_ITEMS + "SMSG_AUCTION_BIDDER_LIST_RESULT", // SMSG_AUCTION_BIDDER_LIST_RESULT + "SMSG_SET_FLAT_SPELL_MODIFIER", // SMSG_SET_FLAT_SPELL_MODIFIER + "SMSG_SET_PCT_SPELL_MODIFIER", // SMSG_SET_PCT_SPELL_MODIFIER + "CMSG_SET_AMMO", // CMSG_SET_AMMO + "SMSG_CORPSE_RECLAIM_DELAY", // SMSG_CORPSE_RECLAIM_DELAY + "CMSG_SET_ACTIVE_MOVER", // CMSG_SET_ACTIVE_MOVER + "CMSG_PET_CANCEL_AURA", // CMSG_PET_CANCEL_AURA + "CMSG_PLAYER_AI_CHEAT", // CMSG_PLAYER_AI_CHEAT + "CMSG_CANCEL_AUTO_REPEAT_SPELL", // CMSG_CANCEL_AUTO_REPEAT_SPELL + "MSG_GM_ACCOUNT_ONLINE", // MSG_GM_ACCOUNT_ONLINE + "MSG_LIST_STABLED_PETS", // MSG_LIST_STABLED_PETS + "CMSG_STABLE_PET", // CMSG_STABLE_PET + "CMSG_UNSTABLE_PET", // CMSG_UNSTABLE_PET + "CMSG_BUY_STABLE_SLOT", // CMSG_BUY_STABLE_SLOT + "SMSG_STABLE_RESULT", // SMSG_STABLE_RESULT + "CMSG_STABLE_REVIVE_PET", // CMSG_STABLE_REVIVE_PET + "CMSG_STABLE_SWAP_PET", // CMSG_STABLE_SWAP_PET + "MSG_QUEST_PUSH_RESULT", // MSG_QUEST_PUSH_RESULT + "SMSG_PLAY_MUSIC", // SMSG_PLAY_MUSIC + "SMSG_PLAY_OBJECT_SOUND", // SMSG_PLAY_OBJECT_SOUND + "CMSG_REQUEST_PET_INFO", // CMSG_REQUEST_PET_INFO + "CMSG_FAR_SIGHT", // CMSG_FAR_SIGHT + "SMSG_SPELLDISPELLOG", // SMSG_SPELLDISPELLOG + "SMSG_DAMAGE_CALC_LOG", // SMSG_DAMAGE_CALC_LOG + "CMSG_ENABLE_DAMAGE_LOG", // CMSG_ENABLE_DAMAGE_LOG + "CMSG_GROUP_CHANGE_SUB_GROUP", // CMSG_GROUP_CHANGE_SUB_GROUP + "CMSG_REQUEST_PARTY_MEMBER_STATS", // CMSG_REQUEST_PARTY_MEMBER_STATS + "CMSG_GROUP_SWAP_SUB_GROUP", // CMSG_GROUP_SWAP_SUB_GROUP + "CMSG_RESET_FACTION_CHEAT", // CMSG_RESET_FACTION_CHEAT + "CMSG_AUTOSTORE_BANK_ITEM", // CMSG_AUTOSTORE_BANK_ITEM + "CMSG_AUTOBANK_ITEM", // CMSG_AUTOBANK_ITEM + "MSG_QUERY_NEXT_MAIL_TIME", // MSG_QUERY_NEXT_MAIL_TIME + "SMSG_RECEIVED_MAIL", // SMSG_RECEIVED_MAIL + "SMSG_RAID_GROUP_ONLY", // SMSG_RAID_GROUP_ONLY + "CMSG_SET_DURABILITY_CHEAT", // CMSG_SET_DURABILITY_CHEAT + "CMSG_SET_PVP_RANK_CHEAT", // CMSG_SET_PVP_RANK_CHEAT + "CMSG_ADD_PVP_MEDAL_CHEAT", // CMSG_ADD_PVP_MEDAL_CHEAT + "CMSG_DEL_PVP_MEDAL_CHEAT", // CMSG_DEL_PVP_MEDAL_CHEAT + "CMSG_SET_PVP_TITLE", // CMSG_SET_PVP_TITLE + "SMSG_PVP_CREDIT", // SMSG_PVP_CREDIT + "SMSG_AUCTION_REMOVED_NOTIFICATION", // SMSG_AUCTION_REMOVED_NOTIFICATION + "CMSG_GROUP_RAID_CONVERT", // CMSG_GROUP_RAID_CONVERT + "CMSG_GROUP_ASSISTANT", // CMSG_GROUP_ASSISTANT + "CMSG_BUYBACK_ITEM", // CMSG_BUYBACK_ITEM + "SMSG_SERVER_MESSAGE", // SMSG_SERVER_MESSAGE + "CMSG_MEETINGSTONE_JOIN", // CMSG_MEETINGSTONE_JOIN + "CMSG_MEETINGSTONE_LEAVE", // CMSG_MEETINGSTONE_LEAVE + "CMSG_MEETINGSTONE_CHEAT", // CMSG_MEETINGSTONE_CHEAT + "SMSG_MEETINGSTONE_SETQUEUE", // SMSG_MEETINGSTONE_SETQUEUE + "CMSG_MEETINGSTONE_INFO", // CMSG_MEETINGSTONE_INFO + "SMSG_MEETINGSTONE_COMPLETE", // SMSG_MEETINGSTONE_COMPLETE + "SMSG_MEETINGSTONE_IN_PROGRESS", // SMSG_MEETINGSTONE_IN_PROGRESS + "SMSG_MEETINGSTONE_MEMBER_ADDED", // SMSG_MEETINGSTONE_MEMBER_ADDED + "CMSG_GMTICKETSYSTEM_TOGGLE", // CMSG_GMTICKETSYSTEM_TOGGLE + "CMSG_CANCEL_GROWTH_AURA", // CMSG_CANCEL_GROWTH_AURA + "SMSG_CANCEL_AUTO_REPEAT", // SMSG_CANCEL_AUTO_REPEAT + "SMSG_STANDSTATE_CHANGE_ACK", // SMSG_STANDSTATE_CHANGE_ACK + "SMSG_LOOT_ALL_PASSED", // SMSG_LOOT_ALL_PASSED + "SMSG_LOOT_ROLL_WON", // SMSG_LOOT_ROLL_WON + "CMSG_LOOT_ROLL", // CMSG_LOOT_ROLL + "SMSG_LOOT_START_ROLL", // SMSG_LOOT_START_ROLL + "SMSG_LOOT_ROLL", // SMSG_LOOT_ROLL + "CMSG_LOOT_MASTER_GIVE", // CMSG_LOOT_MASTER_GIVE + "SMSG_LOOT_MASTER_LIST", // SMSG_LOOT_MASTER_LIST + "SMSG_SET_FORCED_REACTIONS", // SMSG_SET_FORCED_REACTIONS + "SMSG_SPELL_FAILED_OTHER", // SMSG_SPELL_FAILED_OTHER + "SMSG_GAMEOBJECT_RESET_STATE", // SMSG_GAMEOBJECT_RESET_STATE + "CMSG_REPAIR_ITEM", // CMSG_REPAIR_ITEM + "SMSG_CHAT_PLAYER_NOT_FOUND", // SMSG_CHAT_PLAYER_NOT_FOUND + "MSG_TALENT_WIPE_CONFIRM", // MSG_TALENT_WIPE_CONFIRM + "SMSG_SUMMON_REQUEST", // SMSG_SUMMON_REQUEST + "CMSG_SUMMON_RESPONSE", // CMSG_SUMMON_RESPONSE + "MSG_MOVE_TOGGLE_GRAVITY_CHEAT", // MSG_MOVE_TOGGLE_GRAVITY_CHEAT + "SMSG_MONSTER_MOVE_TRANSPORT", // SMSG_MONSTER_MOVE_TRANSPORT + "SMSG_PET_BROKEN", // SMSG_PET_BROKEN + "MSG_MOVE_FEATHER_FALL", // MSG_MOVE_FEATHER_FALL + "MSG_MOVE_WATER_WALK", // MSG_MOVE_WATER_WALK + "CMSG_SERVER_BROADCAST", // CMSG_SERVER_BROADCAST + "CMSG_SELF_RES", // CMSG_SELF_RES + "SMSG_FEIGN_DEATH_RESISTED", // SMSG_FEIGN_DEATH_RESISTED + "CMSG_RUN_SCRIPT", // CMSG_RUN_SCRIPT + "SMSG_SCRIPT_MESSAGE", // SMSG_SCRIPT_MESSAGE + "SMSG_DUEL_COUNTDOWN", // SMSG_DUEL_COUNTDOWN + "SMSG_AREA_TRIGGER_MESSAGE", // SMSG_AREA_TRIGGER_MESSAGE + "CMSG_TOGGLE_HELM", // CMSG_TOGGLE_HELM + "CMSG_TOGGLE_CLOAK", // CMSG_TOGGLE_CLOAK + "SMSG_MEETINGSTONE_JOINFAILED", // SMSG_MEETINGSTONE_JOINFAILED + "SMSG_PLAYER_SKINNED", // SMSG_PLAYER_SKINNED + "SMSG_DURABILITY_DAMAGE_DEATH", // SMSG_DURABILITY_DAMAGE_DEATH + "CMSG_SET_EXPLORATION", // CMSG_SET_EXPLORATION + "CMSG_SET_ACTIONBAR_TOGGLES", // CMSG_SET_ACTIONBAR_TOGGLES + "UMSG_DELETE_GUILD_CHARTER", // UMSG_DELETE_GUILD_CHARTER + "MSG_PETITION_RENAME", // MSG_PETITION_RENAME + "SMSG_INIT_WORLD_STATES", // SMSG_INIT_WORLD_STATES + "SMSG_UPDATE_WORLD_STATE", // SMSG_UPDATE_WORLD_STATE + "CMSG_ITEM_NAME_QUERY", // CMSG_ITEM_NAME_QUERY + "SMSG_ITEM_NAME_QUERY_RESPONSE", // SMSG_ITEM_NAME_QUERY_RESPONSE + "SMSG_PET_ACTION_FEEDBACK", // SMSG_PET_ACTION_FEEDBACK + "CMSG_CHAR_RENAME", // CMSG_CHAR_RENAME + "SMSG_CHAR_RENAME", // SMSG_CHAR_RENAME + "CMSG_MOVE_SPLINE_DONE", // CMSG_MOVE_SPLINE_DONE + "CMSG_MOVE_FALL_RESET", // CMSG_MOVE_FALL_RESET + "SMSG_INSTANCE_SAVE_CREATED", // SMSG_INSTANCE_SAVE_CREATED + "SMSG_RAID_INSTANCE_INFO", // SMSG_RAID_INSTANCE_INFO + "CMSG_REQUEST_RAID_INFO", // CMSG_REQUEST_RAID_INFO + "CMSG_MOVE_TIME_SKIPPED", // CMSG_MOVE_TIME_SKIPPED + "CMSG_MOVE_FEATHER_FALL_ACK", // CMSG_MOVE_FEATHER_FALL_ACK + "CMSG_MOVE_WATER_WALK_ACK", // CMSG_MOVE_WATER_WALK_ACK + "CMSG_MOVE_NOT_ACTIVE_MOVER", // CMSG_MOVE_NOT_ACTIVE_MOVER + "SMSG_PLAY_SOUND", // SMSG_PLAY_SOUND + "CMSG_BATTLEFIELD_STATUS", // CMSG_BATTLEFIELD_STATUS + "SMSG_BATTLEFIELD_STATUS", // SMSG_BATTLEFIELD_STATUS + "CMSG_BATTLEFIELD_PORT", // CMSG_BATTLEFIELD_PORT + "MSG_INSPECT_HONOR_STATS", // MSG_INSPECT_HONOR_STATS + "CMSG_BATTLEMASTER_HELLO", // CMSG_BATTLEMASTER_HELLO + "CMSG_MOVE_START_SWIM_CHEAT", // CMSG_MOVE_START_SWIM_CHEAT + "CMSG_MOVE_STOP_SWIM_CHEAT", // CMSG_MOVE_STOP_SWIM_CHEAT + "SMSG_FORCE_WALK_SPEED_CHANGE", // SMSG_FORCE_WALK_SPEED_CHANGE + "CMSG_FORCE_WALK_SPEED_CHANGE_ACK", // CMSG_FORCE_WALK_SPEED_CHANGE_ACK + "SMSG_FORCE_SWIM_BACK_SPEED_CHANGE", // SMSG_FORCE_SWIM_BACK_SPEED_CHANGE + "CMSG_FORCE_SWIM_BACK_SPEED_CHANGE_ACK", // CMSG_FORCE_SWIM_BACK_SPEED_CHANGE_ACK + "SMSG_FORCE_TURN_RATE_CHANGE", // SMSG_FORCE_TURN_RATE_CHANGE + "CMSG_FORCE_TURN_RATE_CHANGE_ACK", // CMSG_FORCE_TURN_RATE_CHANGE_ACK + "MSG_PVP_LOG_DATA", // MSG_PVP_LOG_DATA + "CMSG_LEAVE_BATTLEFIELD", // CMSG_LEAVE_BATTLEFIELD + "CMSG_AREA_SPIRIT_HEALER_QUERY", // CMSG_AREA_SPIRIT_HEALER_QUERY + "CMSG_AREA_SPIRIT_HEALER_QUEUE", // CMSG_AREA_SPIRIT_HEALER_QUEUE + "SMSG_AREA_SPIRIT_HEALER_TIME", // SMSG_AREA_SPIRIT_HEALER_TIME + "CMSG_GM_UNTEACH", // CMSG_GM_UNTEACH + "SMSG_WARDEN_DATA", // SMSG_WARDEN_DATA + "CMSG_WARDEN_DATA", // CMSG_WARDEN_DATA + "SMSG_GROUP_JOINED_BATTLEGROUND", // SMSG_GROUP_JOINED_BATTLEGROUND + "MSG_BATTLEGROUND_PLAYER_POSITIONS", // MSG_BATTLEGROUND_PLAYER_POSITIONS + "CMSG_PET_STOP_ATTACK", // CMSG_PET_STOP_ATTACK + "SMSG_BINDER_CONFIRM", // SMSG_BINDER_CONFIRM + "SMSG_BATTLEGROUND_PLAYER_JOINED", // SMSG_BATTLEGROUND_PLAYER_JOINED + "SMSG_BATTLEGROUND_PLAYER_LEFT", // SMSG_BATTLEGROUND_PLAYER_LEFT + "CMSG_BATTLEMASTER_JOIN", // CMSG_BATTLEMASTER_JOIN + "SMSG_ADDON_INFO", // SMSG_ADDON_INFO + "CMSG_PET_UNLEARN", // CMSG_PET_UNLEARN + "SMSG_PET_UNLEARN_CONFIRM", // SMSG_PET_UNLEARN_CONFIRM + "SMSG_PARTY_MEMBER_STATS_FULL", // SMSG_PARTY_MEMBER_STATS_FULL + "CMSG_PET_SPELL_AUTOCAST", // CMSG_PET_SPELL_AUTOCAST + "SMSG_WEATHER", // SMSG_WEATHER + "SMSG_PLAY_TIME_WARNING", // SMSG_PLAY_TIME_WARNING + "SMSG_MINIGAME_SETUP", // SMSG_MINIGAME_SETUP + "SMSG_MINIGAME_STATE", // SMSG_MINIGAME_STATE + "CMSG_MINIGAME_MOVE", // CMSG_MINIGAME_MOVE + "SMSG_MINIGAME_MOVE_FAILED", // SMSG_MINIGAME_MOVE_FAILED + "SMSG_INSTANCE_RESET_SCHEDULED", // SMSG_INSTANCE_RESET_SCHEDULED + "SMSG_COMPRESSED_MOVE", // SMSG_COMPRESSED_MOVE + "CMSG_GUILD_CHANGEINFO", // CMSG_GUILD_CHANGEINFO + "SMSG_TRIAL_RESTRICTED", // SMSG_TRIAL_RESTRICTED + "SMSG_SET_MOVE_SPEED", // SMSG_SET_MOVE_SPEED + "SMSG_SET_RUN_BACK_SPEED", // SMSG_SET_RUN_BACK_SPEED + "SMSG_SET_SWIM_SPEED", // SMSG_SET_SWIM_SPEED + "UMSG_UNKNOWN_769", // UMSG_UNKNOWN_769 + "SMSG_SET_SWIM_BACK_SPEED", // SMSG_SET_SWIM_BACK_SPEED + "SMSG_SET_TURN_RATE", // SMSG_SET_TURN_RATE + "SMSG_UNKNOWN_772", // SMSG_UNKNOWN_772 + "SMSG_UNKNOWN_773", // SMSG_UNKNOWN_773 + "SMSG_UNKNOWN_774", // SMSG_UNKNOWN_774 + "SMSG_UNKNOWN_775", // SMSG_UNKNOWN_775 + "SMSG_UNKNOWN_776", // SMSG_UNKNOWN_776 + "SMSG_MOVE_SET_WATERWALK", // SMSG_MOVE_SET_WATERWALK + "SMSG_MOVE_STOP_WATERWALK", // SMSG_MOVE_STOP_WATERWALK + "SMSG_UNKNOWN_779", // SMSG_UNKNOWN_779 + "SMSG_UNKNOWN_780", // SMSG_UNKNOWN_780 + "SMSG_MOVE_STOP_WALK", // SMSG_MOVE_STOP_WALK + "SMSG_MOVE_START_WALK", // SMSG_MOVE_START_WALK + "UMSG_UNKNOWN_783", // UMSG_UNKNOWN_783 + "UMSG_UNKNOWN_784", // UMSG_UNKNOWN_784 + "UMSG_UNKNOWN_785", // UMSG_UNKNOWN_785 + "CMSG_ACTIVATETAXI_FAR", // CMSG_ACTIVATETAXI_FAR + "UMSG_UNKNOWN_787", // UMSG_UNKNOWN_787 + "UMSG_UNKNOWN_788", // UMSG_UNKNOWN_788 + "UMSG_UNKNOWN_789", // UMSG_UNKNOWN_789 + "UMSG_UNKNOWN_790", // UMSG_UNKNOWN_790 + "CMSG_FIELD_WATCHED_FACTION_INACTIVE", // CMSG_FIELD_WATCHED_FACTION_INACTIVE + "CMSG_FIELD_WATCHED_FACTION_SHOW_BAR", // CMSG_FIELD_WATCHED_FACTION_SHOW_BAR + "SMSG_UNKNOWN_793", // SMSG_UNKNOWN_793 + "SMSG_UNKNOWN_794", // SMSG_UNKNOWN_794 + "UMSG_UNKNOWN_795", // UMSG_UNKNOWN_795 + "SMSG_UNKNOWN_796", // SMSG_UNKNOWN_796 + "CMSG_RESET_INSTANCES", // CMSG_RESET_INSTANCES + "SMSG_RESET_INSTANCES_SUCCESS", // SMSG_RESET_INSTANCES_SUCCESS + "SMSG_RESET_INSTANCES_FAILED", // SMSG_RESET_INSTANCES_FAILED + "SMSG_UNKNOWN_800", // SMSG_UNKNOWN_800 + "MSG_RAID_ICON_TARGET", // MSG_RAID_ICON_TARGET + "MSG_RAID_READY_CHECK", // MSG_RAID_READY_CHECK + "UMSG_UNKNOWN_803", // UMSG_UNKNOWN_803 + "SMSG_AI_UNKNOWN", // SMSG_AI_UNKNOWN + "SMSG_UNKNOWN_805", // SMSG_UNKNOWN_805 + "UMSG_UNKNOWN_806", // UMSG_UNKNOWN_806 + "UMSG_UNKNOWN_807", // UMSG_UNKNOWN_807 + "SMSG_GM_SURVEY_REQUEST", // SMSG_GM_SURVEY_REQUEST + "MSG_SET_DUNGEON_DIFFICULTY", // MSG_SET_DUNGEON_DIFFICULTY + "CMSG_GM_SURVEY_RESULTS", // CMSG_GM_SURVEY_RESULTS + "SMSG_UNKNOWN_811", // SMSG_UNKNOWN_811 + "UMSG_UNKNOWN_812", // UMSG_UNKNOWN_812 + "UMSG_UNKNOWN_813", // UMSG_UNKNOWN_813 + "UMSG_UNKNOWN_814", // UMSG_UNKNOWN_814 + "SMSG_SPELL_INSTA_KILL_SELF", // SMSG_SPELL_INSTA_KILL_SELF + "SMSG_UNKNOWN_816", // SMSG_UNKNOWN_816 + "UMSG_UNKNOWN_817", // UMSG_UNKNOWN_817 + "SMSG_ANTISPAM", // SMSG_ANTISPAM + "UMSG_UNKNOWN_819", // UMSG_UNKNOWN_819 + "UMSG_UNKNOWN_820", // UMSG_UNKNOWN_820 + "UMSG_UNKNOWN_821", // UMSG_UNKNOWN_821 + "UMSG_UNKNOWN_822", // UMSG_UNKNOWN_822 + "UMSG_UNKNOWN_823", // UMSG_UNKNOWN_823 + "UMSG_UNKNOWN_824", // UMSG_UNKNOWN_824 + "UMSG_UNKNOWN_825", // UMSG_UNKNOWN_825 + "SMSG_OUTDOORPVP_NOTIFY", // SMSG_OUTDOORPVP_NOTIFY + "UMSG_UNKNOWN_827", // UMSG_UNKNOWN_827 + "UMSG_UNKNOWN_828", // UMSG_UNKNOWN_828 + "SMSG_MOTD", // SMSG_MOTD + "UMSG_UNKNOWN_830", // UMSG_UNKNOWN_830 + "UMSG_UNKNOWN_831", // UMSG_UNKNOWN_831 + "UMSG_UNKNOWN_832", // UMSG_UNKNOWN_832 + "SMSG_UNKNOWN_833", // SMSG_UNKNOWN_833 + "SMSG_UNKNOWN_834", // SMSG_UNKNOWN_834 + "SMSG_FLY_MODE_START", // SMSG_FLY_MODE_START + "SMSG_FLY_MODE_STOP", // SMSG_FLY_MODE_STOP + "CMSG_MOVE_FLY_MODE_CHANGE_ACK", // CMSG_MOVE_FLY_MODE_CHANGE_ACK + "MSG_MOVE_FLY_STATE_CHANGE", // MSG_MOVE_FLY_STATE_CHANGE + "CMSG_SOCKET_ITEM", // CMSG_SOCKET_ITEM + "UMSG_UNKNOWN_840, CMSG?", // UMSG_UNKNOWN_840, CMSG? + "SMSG_ARENA_TEAM_COMMAND_RESULT", // SMSG_ARENA_TEAM_COMMAND_RESULT + "UMSG_UNKNOWN_842", // UMSG_UNKNOWN_842 + "CMSG_ARENA_TEAM_QUERY", // CMSG_ARENA_TEAM_QUERY + "SMSG_ARENA_TEAM_QUERY_RESPONSE", // SMSG_ARENA_TEAM_QUERY_RESPONSE + "CMSG_ARENA_TEAM_ROSTER", // CMSG_ARENA_TEAM_ROSTER + "SMSG_ARENA_TEAM_ROSTER", // SMSG_ARENA_TEAM_ROSTER + "CMSG_ARENA_TEAM_INVITE_BYNAME", // CMSG_ARENA_TEAM_INVITE_BYNAME + "SMSG_ARENA_TEAM_INVITE", // SMSG_ARENA_TEAM_INVITE + "CMSG_ARENA_TEAM_ACCEPT", // CMSG_ARENA_TEAM_ACCEPT + "CMSG_ARENA_TEAM_DECLINE", // CMSG_ARENA_TEAM_DECLINE + "CMSG_ARENA_TEAM_LEAVE", // CMSG_ARENA_TEAM_LEAVE + "CMSG_ARENA_TEAM_UNINVITE_BYNAME", // CMSG_ARENA_TEAM_UNINVITE_BYNAME + "CMSG_ARENA_TEAM_DISBAND", // CMSG_ARENA_TEAM_DISBAND + "CMSG_ARENA_TEAM_SET_LEADER_BYNAME", // CMSG_ARENA_TEAM_SET_LEADER_BYNAME + "SMSG_ARENA_TEAM_EVENT", // SMSG_ARENA_TEAM_EVENT + "CMSG_ARENAMASTER_JOIN", // CMSG_ARENAMASTER_JOIN + "MSG_MOVE_START_FLY_UP", // MSG_MOVE_START_FLY_UP + "MSG_MOVE_STOP_FLY_UP", // MSG_MOVE_STOP_FLY_UP + "SMSG_ARENA_TEAM_STATS", // SMSG_ARENA_TEAM_STATS + "CMSG_LFG_SET_AUTOJOIN", // CMSG_LFG_SET_AUTOJOIN + "CMSG_LFG_UNSET_AUTOJOIN", // CMSG_LFG_UNSET_AUTOJOIN + "CMSG_LFM_SET_AUTOADD", // CMSG_LFM_SET_AUTOADD + "CMSG_LFM_UNSET_AUTOADD", // CMSG_LFM_UNSET_AUTOADD + "CMSG_LFG_INVITE_ACCEPT", // CMSG_LFG_INVITE_ACCEPT + "CMSG_LFG_INVITE_CANCEL", // CMSG_LFG_INVITE_CANCEL + "UMSG_UNKNOWN_866", // UMSG_UNKNOWN_866 + "CMSG_LOOKING_FOR_GROUP_CLEAR", // CMSG_LOOKING_FOR_GROUP_CLEAR + "CMSG_SET_LOOKING_FOR_NONE", // CMSG_SET_LOOKING_FOR_NONE + "CMSG_SET_LOOKING_FOR_MORE", // CMSG_SET_LOOKING_FOR_MORE + "CMSG_SET_COMMENTARY", // CMSG_SET_COMMENTARY + "SMSG_LFG_MATCHMAKING_TIMEDOUT", // SMSG_LFG_MATCHMAKING_TIMEDOUT + "SMSG_LFG_MATCHMAKING_OTHER_TIMEDOUT", // SMSG_LFG_MATCHMAKING_OTHER_TIMEDOUT + "SMSG_LFG_MATCHMAKING_AUTOJOIN_FAILED", // SMSG_LFG_MATCHMAKING_AUTOJOIN_FAILED + "SMSG_LFG_MATCHMAKING_AUTOJOIN_FAILED_NO_PLAYER", // SMSG_LFG_MATCHMAKING_AUTOJOIN_FAILED_NO_PLAYER + "UMSG_UNKNOWN_875", // UMSG_UNKNOWN_875 + "SMSG_LFG_876", // SMSG_LFG_876 + "SMSG_LFG_877", // SMSG_LFG_877 + "SMSG_LFG_878", // SMSG_LFG_878 + "SMSG_LFG_879", // SMSG_LFG_879 + "SMSG_LFG_MATCHMAKING_PENDING_INVITE", // SMSG_LFG_MATCHMAKING_PENDING_INVITE + "SMSG_LFG_MATCHMAKING_PENDING_MATCH", // SMSG_LFG_MATCHMAKING_PENDING_MATCH + "UMSG_UNKNOWN_882", // UMSG_UNKNOWN_882 + "SMSG_CHANGE_TITLE", // SMSG_CHANGE_TITLE + "CMSG_CHOOSE_TITLE", // CMSG_CHOOSE_TITLE + "CMSG_DISMOUNT", // CMSG_DISMOUNT + "SMSG_ARENA_NO_TEAM", // SMSG_ARENA_NO_TEAM + "MSG_INSPECT_ARENA_STATS", // MSG_INSPECT_ARENA_STATS + "SMSG_SH_POSITION", // SMSG_SH_POSITION + "CMSG_CANCEL_TEMP_ITEM_ENCHANTMENT", // CMSG_CANCEL_TEMP_ITEM_ENCHANTMENT + "UMSG_UNKNOWN_890", // UMSG_UNKNOWN_890 + "UMSG_UNKNOWN_891", // UMSG_UNKNOWN_891 + "UMSG_UNKNOWN_892", // UMSG_UNKNOWN_892 + "UMSG_UNKNOWN_893", // UMSG_UNKNOWN_893 + "MSG_MOVE_SET_FLY_SPEED", // MSG_MOVE_SET_FLY_SPEED + "UMSG_UNKNOWN_895", // UMSG_UNKNOWN_895 + "MSG_MOVE_SET_FLY_BACK_SPEED", // MSG_MOVE_SET_FLY_BACK_SPEED + "SMSG_FORCE_FLY_SPEED_CHANGE", // SMSG_FORCE_FLY_SPEED_CHANGE + "CMSG_FORCE_FLY_SPEED_CHANGE_ACK", // CMSG_FORCE_FLY_SPEED_CHANGE_ACK + "SMSG_FORCE_FLY_BACK_SPEED_CHANGE", // SMSG_FORCE_FLY_BACK_SPEED_CHANGE + "CMSG_FORCE_FLY_BACK_SPEED_CHANGE_ACK", // CMSG_FORCE_FLY_BACK_SPEED_CHANGE_ACK + "MSG_MOVE_SET_FLY_SPEED2", // MSG_MOVE_SET_FLY_SPEED2 + "SMSG_MOVE_SET_FLY_BACK_SPEED2", // SMSG_MOVE_SET_FLY_BACK_SPEED2 + "UMSG_UNKNOWN_903", // UMSG_UNKNOWN_903 + "SMSG_FLIGHT_SPLINE_SYNC", // SMSG_FLIGHT_SPLINE_SYNC + "CMSG_SET_TAXI_BENCHMARK_MODE", // CMSG_SET_TAXI_BENCHMARK_MODE + "UMSG_UNKNOWN_906", // UMSG_UNKNOWN_906 + "SMSG_REALM_SPLIT_INFO_RESPONSE", // SMSG_REALM_SPLIT_INFO_RESPONSE + "CMSG_REALM_SPLIT_INFO_REQUEST", // CMSG_REALM_SPLIT_INFO_REQUEST + "MSG_MOVE_SHIP_909", // MSG_MOVE_SHIP_909 + "CMSG_GROUP_PROMOTE", // CMSG_GROUP_PROMOTE + "SMSG_ALREADY_IN_ARENA_TEAM", // SMSG_ALREADY_IN_ARENA_TEAM + "SMSG_ALLOW_MOVE", // SMSG_ALLOW_MOVE + "CMSG_ALLOW_MOVE_ACK", // CMSG_ALLOW_MOVE_ACK + "UMSG_UNKNOWN_914", // UMSG_UNKNOWN_914 + "UMSG_UNKNOWN_915", // UMSG_UNKNOWN_915 + "UMSG_UNKNOWN_916", // UMSG_UNKNOWN_916 + "UMSG_UNKNOWN_917", // UMSG_UNKNOWN_917 + "SMSG_RESET_INSTANCE_FAILED_NOTIFY", // SMSG_RESET_INSTANCE_FAILED_NOTIFY + "SMSG_UNKNOWN_919", // SMSG_UNKNOWN_919 + "SMSG_SYSTEM_DISABLED", // SMSG_SYSTEM_DISABLED + "UMSG_UNKNOWN_921", // UMSG_UNKNOWN_921 + "UMSG_UNKNOWN_922", // UMSG_UNKNOWN_922 + "UMSG_UNKNOWN_923", // UMSG_UNKNOWN_923 + "UMSG_UNKNOWN_924", // UMSG_UNKNOWN_924 + "SMSG_SET_COMBO_POINTS", // SMSG_SET_COMBO_POINTS + "SMSG_VOICE_SESSION", // SMSG_VOICE_SESSION + "SMSG_UNKNOWN_927", // SMSG_UNKNOWN_927 + "UMSG_UNKNOWN_928", // UMSG_UNKNOWN_928 + "UMSG_UNKNOWN_929", // UMSG_UNKNOWN_929 + "UMSG_UNKNOWN_930", // UMSG_UNKNOWN_930 + "SMSG_SET_AURA_MULTIPLY", // SMSG_SET_AURA_MULTIPLY + "SMSG_SET_AURA_SINGLE", // SMSG_SET_AURA_SINGLE + "UMSG_UNKNOWN_933", // UMSG_UNKNOWN_933 + "SMSG_CAST_SUCCESS", // SMSG_CAST_SUCCESS + "MSG_UNKNOWN_935", // MSG_UNKNOWN_935 + "UMSG_UNKNOWN_936", // UMSG_UNKNOWN_936 + "UMSG_UNKNOWN_937", // UMSG_UNKNOWN_937 + "SMSG_UNKNOWN_938", // SMSG_UNKNOWN_938 + "UMSG_UNKNOWN_939", // UMSG_UNKNOWN_939 + "SMSG_UNKNOWN_940", // SMSG_UNKNOWN_940 + "SMSG_UNKNOWN_941", // SMSG_UNKNOWN_941 + "SMSG_READY_CHECK_ALL_READY", // SMSG_READY_CHECK_ALL_READY + "CMSG_VOICE_SETTINGS", // CMSG_VOICE_SETTINGS + "SMSG_VOICE_CHAT_PARENTAL_DISABLE_ALL", // SMSG_VOICE_CHAT_PARENTAL_DISABLE_ALL + "UMSG_UNKNOWN_945", // UMSG_UNKNOWN_945 + "UMSG_UNKNOWN_946", // UMSG_UNKNOWN_946 + "UMSG_UNKNOWN_947", // UMSG_UNKNOWN_947 + "CMSG_COMMENTATOR_SET_MODE", // CMSG_COMMENTATOR_SET_MODE + "UMSG_UNKNOWN_949", // UMSG_UNKNOWN_949 + "CMSG_COMMENTATOR_UPDATE_MAP_INFO", // CMSG_COMMENTATOR_UPDATE_MAP_INFO + "UMSG_UNKNOWN_951", // UMSG_UNKNOWN_951 + "CMSG_COMMENTATOR_UPDATE_PLAYER_INFO", // CMSG_COMMENTATOR_UPDATE_PLAYER_INFO + "CMSG_UNKNOWN_953", // CMSG_UNKNOWN_953 + "UMSG_UNKNOWN_954", // UMSG_UNKNOWN_954 + "UMSG_UNKNOWN_955", // UMSG_UNKNOWN_955 + "UMSG_UNKNOWN_956", // UMSG_UNKNOWN_956 + "CMSG_COMMENTATOR_EXIT_INSTANCE", // CMSG_COMMENTATOR_EXIT_INSTANCE + "UMSG_UNKNOWN_958", // UMSG_UNKNOWN_958 + "UMSG_UNKNOWN_959", // UMSG_UNKNOWN_959 + "SMSG_UNKNOWN_960", // SMSG_UNKNOWN_960 + "UMSG_UNKNOWN_961", // UMSG_UNKNOWN_961 + "UMSG_UNKNOWN_962", // UMSG_UNKNOWN_962 + "UMSG_UNKNOWN_963", // UMSG_UNKNOWN_963 + "UMSG_UNKNOWN_964", // UMSG_UNKNOWN_964 + "UMSG_UNKNOWN_965", // UMSG_UNKNOWN_965 + "CMSG_COMPLAINT_CHAT", // CMSG_COMPLAINT_CHAT + "SMSG_COMPLAINT_ADDED", // SMSG_COMPLAINT_ADDED + "SMSG_VOICE_SYSTEM_STATUS", // SMSG_VOICE_SYSTEM_STATUS + "UMSG_UNKNOWN_969", // UMSG_UNKNOWN_969 + "UMSG_UNKNOWN_970", // UMSG_UNKNOWN_970 + "CMSG_CHANNEL_SILENT_VOICE", // CMSG_CHANNEL_SILENT_VOICE + "CMSG_CHANNEL_SILENT_ALL", // CMSG_CHANNEL_SILENT_ALL + "CMSG_CHANNEL_UNSILENT_VOICE", // CMSG_CHANNEL_UNSILENT_VOICE + "CMSG_CHANNEL_UNSILENT_ALL", // CMSG_CHANNEL_UNSILENT_ALL + "UMSG_UNKNOWN_975", // UMSG_UNKNOWN_975 + "UMSG_UNKNOWN_976", // UMSG_UNKNOWN_976 + "CMSG_CHANNEL_ROSTER_QUERY", // CMSG_CHANNEL_ROSTER_QUERY + "CMSG_CHANNEL_VOICE_CHAT_QUERY", // CMSG_CHANNEL_VOICE_CHAT_QUERY + "CMSG_CHANNEL_INFO_QUERY", // CMSG_CHANNEL_INFO_QUERY + "SMSG_CHANNEL_INFO_QUERY_RESPONSE", // SMSG_CHANNEL_INFO_QUERY_RESPONSE + "CMSG_CHANNEL_VOICE_ON", // CMSG_CHANNEL_VOICE_ON + "CMSG_CHANNEL_VOICE_OFF", // CMSG_CHANNEL_VOICE_OFF + "UMSG_UNKNOWN_983", // UMSG_UNKNOWN_983 + "UMSG_UNKNOWN_984", // UMSG_UNKNOWN_984 + "SMSG_CHANNEL_NOTIFY_AVAILABLE_VOICE_SESSION", // SMSG_CHANNEL_NOTIFY_AVAILABLE_VOICE_SESSION + "CMSG_MUTE_PLAYER", // CMSG_MUTE_PLAYER + "CMSG_UNMUTE_PLAYER", // CMSG_UNMUTE_PLAYER + "CMSG_SILENCE_MEMBER", // CMSG_SILENCE_MEMBER + "CMSG_UNSILENCE_MEMBER", // CMSG_UNSILENCE_MEMBER + "SMSG_PLAYER_UNSILENCED", // SMSG_PLAYER_UNSILENCED + "SMSG_COMSAT_RECONNECT_ATTEMPT", // SMSG_COMSAT_RECONNECT_ATTEMPT + "SMSG_COMSAT_DISCONNECT", // SMSG_COMSAT_DISCONNECT + "SMSG_COMSAT_CONNECT_FAIL", // SMSG_COMSAT_CONNECT_FAIL + "UMSG_UNKNOWN_994", // UMSG_UNKNOWN_994 + "UMSG_UNKNOWN_995", // UMSG_UNKNOWN_995 + "UMSG_UNKNOWN_996", // UMSG_UNKNOWN_996 + "CMSG_GUILD_BANK", // CMSG_GUILD_BANK + "CMSG_GUILDBANK_TAB_COLON", // CMSG_GUILDBANK_TAB_COLON + "SMSG_GUILD_BANK_LIST", // SMSG_GUILD_BANK_LIST + "CMSG_UNKNOWN_1000", // CMSG_UNKNOWN_1000 + "CMSG_BUY_GUILDBANK_TAB", // CMSG_BUY_GUILDBANK_TAB + "UMSG_UNKNOWN_1002", // UMSG_UNKNOWN_1002 + "CMSG_GUILDBANK_DEPOSIT", // CMSG_GUILDBANK_DEPOSIT + "CMSG_GUILDBANK_WITHDRAW", // CMSG_GUILDBANK_WITHDRAW + "MSG_GUILDBANK_LOG", // MSG_GUILDBANK_LOG + "CMSG_CHANNEL_WATCH", // CMSG_CHANNEL_WATCH + "SMSG_PLAYER_JOINED_CHANNEL", // SMSG_PLAYER_JOINED_CHANNEL + "SMSG_PLAYER_LEFT_CHANNEL", // SMSG_PLAYER_LEFT_CHANNEL + "SMSG_PLAYER_JOINED_CUSTOM_CHANNEL", // SMSG_PLAYER_JOINED_CUSTOM_CHANNEL + "CMSG_CLEAR_CHANNEL_WATCH", // CMSG_CLEAR_CHANNEL_WATCH + "SMSG_INSPECT_TALENTS", // SMSG_INSPECT_TALENTS + "UMSG_UNKNOWN_1012", // UMSG_UNKNOWN_1012 + "UMSG_UNKNOWN_1013", // UMSG_UNKNOWN_1013 + "UMSG_UNKNOWN_1014", // UMSG_UNKNOWN_1014 + "CMSG_UNKNOWN_1015", // CMSG_UNKNOWN_1015 + "UMSG_UNKNOWN_1016", // UMSG_UNKNOWN_1016 + "UMSG_UNKNOWN_1017", // UMSG_UNKNOWN_1017 + "UMSG_UNKNOWN_1018", // UMSG_UNKNOWN_1018 + "SMSG_VOICESESSION_FULL", // SMSG_VOICESESSION_FULL + "MSG_UNKNOWN_1020", // MSG_UNKNOWN_1020 + "MSG_UNKNOWN_1021", // MSG_UNKNOWN_1021 + "MSG_GUILD_INFO_LOG", // MSG_GUILD_INFO_LOG + "" // last entry should be empty +}; + +const char *GetOpcodeName(unsigned int id) +{ + if(id > MAX_OPCODE_ID) + return ""; + return worldOpcodeNames[id]; +} + +const unsigned int GetOpcodeID(const char *name) +{ + for(unsigned int i=0; strlen(worldOpcodeNames[i]); i++) + { + if(!stricmp(worldOpcodeNames[i], name)) + { + return i; + } + } + return -1; // invalid name +} diff --git a/src/Client/World/Opcodes.h b/src/Client/World/Opcodes.h index 8240f9a..7a2cd8f 100644 --- a/src/Client/World/Opcodes.h +++ b/src/Client/World/Opcodes.h @@ -1,1121 +1,1121 @@ -/* - * Copyright (C) 2005,2006,2007 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/// \addtogroup u2w -/// @{ -/// \file - -#ifndef _OPCODES_H -#define _OPCODES_H - -const char *GetOpcodeName(unsigned int); -const unsigned int GetOpcodeID(const char *); - -/// List of OpCodes -enum OpCodes -{ - MSG_NULL_ACTION = 0, - CMSG_BOOTME = 1, - CMSG_DBLOOKUP = 2, - SMSG_DBLOOKUP = 3, - CMSG_QUERY_OBJECT_POSITION = 4, - SMSG_QUERY_OBJECT_POSITION = 5, - CMSG_QUERY_OBJECT_ROTATION = 6, - SMSG_QUERY_OBJECT_ROTATION = 7, - CMSG_WORLD_TELEPORT = 8, - CMSG_TELEPORT_TO_UNIT = 9, - CMSG_ZONE_MAP = 10, - SMSG_ZONE_MAP = 11, - CMSG_DEBUG_CHANGECELLZONE = 12, - CMSG_EMBLAZON_TABARD_OBSOLETE = 13, - CMSG_UNEMBLAZON_TABARD_OBSOLETE = 14, - CMSG_RECHARGE = 15, - CMSG_LEARN_SPELL = 16, - CMSG_CREATEMONSTER = 17, - CMSG_DESTROYMONSTER = 18, - CMSG_CREATEITEM = 19, - CMSG_CREATEGAMEOBJECT = 20, - CMSG_MAKEMONSTERATTACKME_OBSOLETE = 21, - CMSG_MAKEMONSTERATTACKGUID = 22, - CMSG_ENABLEDEBUGCOMBATLOGGING_OBSOLETE = 23, - CMSG_FORCEACTION = 24, - CMSG_FORCEACTIONONOTHER = 25, - CMSG_FORCEACTIONSHOW = 26, - SMSG_FORCEACTIONSHOW = 27, - SMSG_ATTACKERSTATEUPDATEDEBUGINFO_OBSOLETE = 28, - SMSG_DEBUGINFOSPELL_OBSOLETE = 29, - SMSG_DEBUGINFOSPELLMISS_OBSOLETE = 30, - SMSG_DEBUG_PLAYER_RANGE_OBSOLETE = 31, - CMSG_UNDRESSPLAYER = 32, - CMSG_BEASTMASTER = 33, - CMSG_GODMODE = 34, - SMSG_GODMODE = 35, - CMSG_CHEAT_SETMONEY = 36, - CMSG_LEVEL_CHEAT = 37, - CMSG_PET_LEVEL_CHEAT = 38, - CMSG_LEVELUP_CHEAT_OBSOLETE = 39, - CMSG_COOLDOWN_CHEAT = 40, - CMSG_USE_SKILL_CHEAT = 41, - CMSG_FLAG_QUEST = 42, - CMSG_FLAG_QUEST_FINISH = 43, - CMSG_CLEAR_QUEST = 44, - CMSG_SEND_EVENT = 45, - CMSG_DEBUG_AISTATE = 46, - SMSG_DEBUG_AISTATE = 47, - CMSG_DISABLE_PVP_CHEAT = 48, - CMSG_ADVANCE_SPAWN_TIME = 49, - CMSG_PVP_PORT_OBSOLETE = 50, - CMSG_AUTH_SRP6_BEGIN = 51, - CMSG_AUTH_SRP6_PROOF = 52, - CMSG_AUTH_SRP6_RECODE = 53, - CMSG_CHAR_CREATE = 54, - CMSG_CHAR_ENUM = 55, - CMSG_CHAR_DELETE = 56, - SMSG_AUTH_SRP6_RESPONSE = 57, - SMSG_CHAR_CREATE = 58, - SMSG_CHAR_ENUM = 59, - SMSG_CHAR_DELETE = 60, - CMSG_PLAYER_LOGIN = 61, - SMSG_NEW_WORLD = 62, - SMSG_TRANSFER_PENDING = 63, - SMSG_TRANSFER_ABORTED = 64, - SMSG_CHARACTER_LOGIN_FAILED = 65, // kick client to character select screen and show "World server is down". - SMSG_LOGIN_SETTIMESPEED = 66, - SMSG_GAMETIME_UPDATE = 67, - CMSG_GAMETIME_SET = 68, - SMSG_GAMETIME_SET = 69, - CMSG_GAMESPEED_SET = 70, - SMSG_GAMESPEED_SET = 71, - CMSG_SERVERTIME = 72, - SMSG_SERVERTIME = 73, - CMSG_PLAYER_LOGOUT = 74, - CMSG_LOGOUT_REQUEST = 75, - SMSG_LOGOUT_RESPONSE = 76, - SMSG_LOGOUT_COMPLETE = 77, - CMSG_LOGOUT_CANCEL = 78, - SMSG_LOGOUT_CANCEL_ACK = 79, - CMSG_NAME_QUERY = 80, - SMSG_NAME_QUERY_RESPONSE = 81, - CMSG_PET_NAME_QUERY = 82, - SMSG_PET_NAME_QUERY_RESPONSE = 83, - CMSG_GUILD_QUERY = 84, - SMSG_GUILD_QUERY_RESPONSE = 85, - CMSG_ITEM_QUERY_SINGLE = 86, - CMSG_ITEM_QUERY_MULTIPLE = 87, - SMSG_ITEM_QUERY_SINGLE_RESPONSE = 88, - SMSG_ITEM_QUERY_MULTIPLE_RESPONSE = 89, - CMSG_PAGE_TEXT_QUERY = 90, - SMSG_PAGE_TEXT_QUERY_RESPONSE = 91, - CMSG_QUEST_QUERY = 92, - SMSG_QUEST_QUERY_RESPONSE = 93, - CMSG_GAMEOBJECT_QUERY = 94, - SMSG_GAMEOBJECT_QUERY_RESPONSE = 95, - CMSG_CREATURE_QUERY = 96, - SMSG_CREATURE_QUERY_RESPONSE = 97, - CMSG_WHO = 98, - SMSG_WHO = 99, - CMSG_WHOIS = 100, - SMSG_WHOIS = 101, - CMSG_FRIEND_LIST = 102, - SMSG_FRIEND_LIST = 103, - SMSG_FRIEND_STATUS = 104, - CMSG_ADD_FRIEND = 105, - CMSG_DEL_FRIEND = 106, - SMSG_IGNORE_LIST = 107, - CMSG_ADD_IGNORE = 108, - CMSG_DEL_IGNORE = 109, - CMSG_GROUP_INVITE = 110, - SMSG_GROUP_INVITE = 111, - CMSG_GROUP_CANCEL = 112, - SMSG_GROUP_CANCEL = 113, - CMSG_GROUP_ACCEPT = 114, - CMSG_GROUP_DECLINE = 115, - SMSG_GROUP_DECLINE = 116, - CMSG_GROUP_UNINVITE = 117, - CMSG_GROUP_UNINVITE_GUID = 118, - SMSG_GROUP_UNINVITE = 119, - CMSG_GROUP_SET_LEADER = 120, - SMSG_GROUP_SET_LEADER = 121, - CMSG_LOOT_METHOD = 122, - CMSG_GROUP_DISBAND = 123, - SMSG_GROUP_DESTROYED = 124, - SMSG_GROUP_LIST = 125, - SMSG_PARTY_MEMBER_STATS = 126, - SMSG_PARTY_COMMAND_RESULT = 127, - UMSG_UPDATE_GROUP_MEMBERS = 128, - CMSG_GUILD_CREATE = 129, - CMSG_GUILD_INVITE = 130, - SMSG_GUILD_INVITE = 131, - CMSG_GUILD_ACCEPT = 132, - CMSG_GUILD_DECLINE = 133, - SMSG_GUILD_DECLINE = 134, - CMSG_GUILD_INFO = 135, - SMSG_GUILD_INFO = 136, - CMSG_GUILD_ROSTER = 137, - SMSG_GUILD_ROSTER = 138, - CMSG_GUILD_PROMOTE = 139, - CMSG_GUILD_DEMOTE = 140, - CMSG_GUILD_LEAVE = 141, - CMSG_GUILD_REMOVE = 142, - CMSG_GUILD_DISBAND = 143, - CMSG_GUILD_LEADER = 144, - CMSG_GUILD_MOTD = 145, - SMSG_GUILD_EVENT = 146, - SMSG_GUILD_COMMAND_RESULT = 147, - UMSG_UPDATE_GUILD = 148, - CMSG_MESSAGECHAT = 149, - SMSG_MESSAGECHAT = 150, - CMSG_JOIN_CHANNEL = 151, - CMSG_LEAVE_CHANNEL = 152, - SMSG_CHANNEL_NOTIFY = 153, - CMSG_CHANNEL_LIST = 154, - SMSG_CHANNEL_LIST = 155, - CMSG_CHANNEL_PASSWORD = 156, - CMSG_CHANNEL_SET_OWNER = 157, - CMSG_CHANNEL_OWNER = 158, - CMSG_CHANNEL_MODERATOR = 159, - CMSG_CHANNEL_UNMODERATOR = 160, - CMSG_CHANNEL_MUTE = 161, - CMSG_CHANNEL_UNMUTE = 162, - CMSG_CHANNEL_INVITE = 163, - CMSG_CHANNEL_KICK = 164, - CMSG_CHANNEL_BAN = 165, - CMSG_CHANNEL_UNBAN = 166, - CMSG_CHANNEL_ANNOUNCEMENTS = 167, - CMSG_CHANNEL_MODERATE = 168, - SMSG_UPDATE_OBJECT = 169, - SMSG_DESTROY_OBJECT = 170, - CMSG_USE_ITEM = 171, - CMSG_OPEN_ITEM = 172, - CMSG_READ_ITEM = 173, - SMSG_READ_ITEM_OK = 174, - SMSG_READ_ITEM_FAILED = 175, - SMSG_ITEM_COOLDOWN = 176, - CMSG_GAMEOBJ_USE = 177, - CMSG_GAMEOBJ_CHAIR_USE_OBSOLETE = 178, - SMSG_GAMEOBJECT_CUSTOM_ANIM = 179, - CMSG_AREATRIGGER = 180, - MSG_MOVE_START_FORWARD = 181, - MSG_MOVE_START_BACKWARD = 182, - MSG_MOVE_STOP = 183, - MSG_MOVE_START_STRAFE_LEFT = 184, - MSG_MOVE_START_STRAFE_RIGHT = 185, - MSG_MOVE_STOP_STRAFE = 186, - MSG_MOVE_JUMP = 187, - MSG_MOVE_START_TURN_LEFT = 188, - MSG_MOVE_START_TURN_RIGHT = 189, - MSG_MOVE_STOP_TURN = 190, - MSG_MOVE_START_PITCH_UP = 191, - MSG_MOVE_START_PITCH_DOWN = 192, - MSG_MOVE_STOP_PITCH = 193, - MSG_MOVE_SET_RUN_MODE = 194, - MSG_MOVE_SET_WALK_MODE = 195, - MSG_MOVE_TOGGLE_LOGGING = 196, - MSG_MOVE_TELEPORT = 197, - MSG_MOVE_TELEPORT_CHEAT = 198, - MSG_MOVE_TELEPORT_ACK = 199, - MSG_MOVE_TOGGLE_FALL_LOGGING = 200, - MSG_MOVE_FALL_LAND = 201, - MSG_MOVE_START_SWIM = 202, - MSG_MOVE_STOP_SWIM = 203, - MSG_MOVE_SET_RUN_SPEED_CHEAT = 204, - MSG_MOVE_SET_RUN_SPEED = 205, - MSG_MOVE_SET_RUN_BACK_SPEED_CHEAT = 206, - MSG_MOVE_SET_RUN_BACK_SPEED = 207, - MSG_MOVE_SET_WALK_SPEED_CHEAT = 208, - MSG_MOVE_SET_WALK_SPEED = 209, - MSG_MOVE_SET_SWIM_SPEED_CHEAT = 210, - MSG_MOVE_SET_SWIM_SPEED = 211, - MSG_MOVE_SET_SWIM_BACK_SPEED_CHEAT = 212, - MSG_MOVE_SET_SWIM_BACK_SPEED = 213, - MSG_MOVE_SET_ALL_SPEED_CHEAT = 214, - MSG_MOVE_SET_TURN_RATE_CHEAT = 215, - MSG_MOVE_SET_TURN_RATE = 216, - MSG_MOVE_TOGGLE_COLLISION_CHEAT = 217, - MSG_MOVE_SET_FACING = 218, - MSG_MOVE_SET_PITCH = 219, - MSG_MOVE_WORLDPORT_ACK = 220, - SMSG_MONSTER_MOVE = 221, - SMSG_MOVE_WATER_WALK = 222, - SMSG_MOVE_LAND_WALK = 223, - MSG_MOVE_SET_RAW_POSITION_ACK = 224, - CMSG_MOVE_SET_RAW_POSITION = 225, - SMSG_FORCE_RUN_SPEED_CHANGE = 226, - CMSG_FORCE_RUN_SPEED_CHANGE_ACK = 227, - SMSG_FORCE_RUN_BACK_SPEED_CHANGE = 228, - CMSG_FORCE_RUN_BACK_SPEED_CHANGE_ACK = 229, - SMSG_FORCE_SWIM_SPEED_CHANGE = 230, - CMSG_FORCE_SWIM_SPEED_CHANGE_ACK = 231, - SMSG_FORCE_MOVE_ROOT = 232, - CMSG_FORCE_MOVE_ROOT_ACK = 233, - SMSG_FORCE_MOVE_UNROOT = 234, - CMSG_FORCE_MOVE_UNROOT_ACK = 235, - MSG_MOVE_ROOT = 236, - MSG_MOVE_UNROOT = 237, - MSG_MOVE_HEARTBEAT = 238, - SMSG_MOVE_KNOCK_BACK = 239, - CMSG_MOVE_KNOCK_BACK_ACK = 240, - MSG_MOVE_KNOCK_BACK = 241, - SMSG_MOVE_FEATHER_FALL = 242, - SMSG_MOVE_NORMAL_FALL = 243, - SMSG_MOVE_SET_HOVER = 244, - SMSG_MOVE_UNSET_HOVER = 245, - CMSG_MOVE_HOVER_ACK = 246, - MSG_MOVE_HOVER = 247, - CMSG_TRIGGER_CINEMATIC_CHEAT = 248, - CMSG_OPENING_CINEMATIC = 249, - SMSG_TRIGGER_CINEMATIC = 250, - CMSG_NEXT_CINEMATIC_CAMERA = 251, - CMSG_COMPLETE_CINEMATIC = 252, - SMSG_TUTORIAL_FLAGS = 253, - CMSG_TUTORIAL_FLAG = 254, - CMSG_TUTORIAL_CLEAR = 255, - CMSG_TUTORIAL_RESET = 256, - CMSG_STANDSTATECHANGE = 257, - CMSG_EMOTE = 258, - SMSG_EMOTE = 259, - CMSG_TEXT_EMOTE = 260, - SMSG_TEXT_EMOTE = 261, - CMSG_AUTOEQUIP_GROUND_ITEM = 262, - CMSG_AUTOSTORE_GROUND_ITEM = 263, - CMSG_AUTOSTORE_LOOT_ITEM = 264, - CMSG_STORE_LOOT_IN_SLOT = 265, - CMSG_AUTOEQUIP_ITEM = 266, - CMSG_AUTOSTORE_BAG_ITEM = 267, - CMSG_SWAP_ITEM = 268, - CMSG_SWAP_INV_ITEM = 269, - CMSG_SPLIT_ITEM = 270, - CMSG_PICKUP_ITEM = 271, - CMSG_DROP_ITEM = 272, - CMSG_DESTROYITEM = 273, - SMSG_INVENTORY_CHANGE_FAILURE = 274, - SMSG_OPEN_CONTAINER = 275, - CMSG_INSPECT = 276, - SMSG_INSPECT = 277, - CMSG_INITIATE_TRADE = 278, - CMSG_BEGIN_TRADE = 279, - CMSG_BUSY_TRADE = 280, - CMSG_IGNORE_TRADE = 281, - CMSG_ACCEPT_TRADE = 282, - CMSG_UNACCEPT_TRADE = 283, - CMSG_CANCEL_TRADE = 284, - CMSG_SET_TRADE_ITEM = 285, - CMSG_CLEAR_TRADE_ITEM = 286, - CMSG_SET_TRADE_GOLD = 287, - SMSG_TRADE_STATUS = 288, - SMSG_TRADE_STATUS_EXTENDED = 289, - SMSG_INITIALIZE_FACTIONS = 290, - SMSG_SET_FACTION_VISIBLE = 291, - SMSG_SET_FACTION_STANDING = 292, - CMSG_SET_FACTION_ATWAR = 293, - CMSG_SET_FACTION_CHEAT = 294, - SMSG_SET_PROFICIENCY = 295, - CMSG_SET_ACTION_BUTTON = 296, - SMSG_ACTION_BUTTONS = 297, - SMSG_INITIAL_SPELLS = 298, - SMSG_LEARNED_SPELL = 299, - SMSG_SUPERCEDED_SPELL = 300, - CMSG_NEW_SPELL_SLOT = 301, - CMSG_CAST_SPELL = 302, - CMSG_CANCEL_CAST = 303, - SMSG_CAST_RESULT = 304, - SMSG_SPELL_START = 305, - SMSG_SPELL_GO = 306, - SMSG_SPELL_FAILURE = 307, - SMSG_SPELL_COOLDOWN = 308, - SMSG_COOLDOWN_EVENT = 309, - CMSG_CANCEL_AURA = 310, - SMSG_UPDATE_AURA_DURATION = 311, - SMSG_PET_CAST_FAILED = 312, // Your pet is in combat - MSG_CHANNEL_START = 313, - MSG_CHANNEL_UPDATE = 314, - CMSG_CANCEL_CHANNELLING = 315, - SMSG_AI_REACTION = 316, // may be monser attack sound? - CMSG_SET_SELECTION = 317, - CMSG_SET_TARGET_OBSOLETE = 318, - CMSG_UNUSED = 319, - CMSG_UNUSED2 = 320, - CMSG_ATTACKSWING = 321, - CMSG_ATTACKSTOP = 322, - SMSG_ATTACKSTART = 323, - SMSG_ATTACKSTOP = 324, - SMSG_ATTACKSWING_NOTINRANGE = 325, - SMSG_ATTACKSWING_BADFACING = 326, - SMSG_ATTACKSWING_NOTSTANDING = 327, - SMSG_ATTACKSWING_DEADTARGET = 328, - SMSG_ATTACKSWING_CANT_ATTACK = 329, - SMSG_ATTACKERSTATEUPDATE = 330, - SMSG_VICTIMSTATEUPDATE_OBSOLETE = 331, - SMSG_DAMAGE_DONE_OBSOLETE = 332, - SMSG_DAMAGE_TAKEN_OBSOLETE = 333, - SMSG_CANCEL_COMBAT = 334, - SMSG_PLAYER_COMBAT_XP_GAIN_OBSOLETE = 335, - SMSG_HEALSPELL_ON_PLAYER_OBSOLETE = 336, - SMSG_HEALSPELL_ON_PLAYERS_PET_OBSOLETE = 337, - CMSG_SHEATHE_OBSOLETE = 338, - CMSG_SAVE_PLAYER = 339, - CMSG_SETDEATHBINDPOINT = 340, - SMSG_BINDPOINTUPDATE = 341, - CMSG_GETDEATHBINDZONE = 342, - SMSG_BINDZONEREPLY = 343, - SMSG_PLAYERBOUND = 344, - SMSG_DEATH_NOTIFY_OBSOLETE = 345, - CMSG_REPOP_REQUEST = 346, - SMSG_RESURRECT_REQUEST = 347, - CMSG_RESURRECT_RESPONSE = 348, - CMSG_LOOT = 349, - CMSG_LOOT_MONEY = 350, - CMSG_LOOT_RELEASE = 351, - SMSG_LOOT_RESPONSE = 352, - SMSG_LOOT_RELEASE_RESPONSE = 353, - SMSG_LOOT_REMOVED = 354, - SMSG_LOOT_MONEY_NOTIFY = 355, - SMSG_LOOT_ITEM_NOTIFY = 356, - SMSG_LOOT_CLEAR_MONEY = 357, - SMSG_ITEM_PUSH_RESULT = 358, - SMSG_DUEL_REQUESTED = 359, - SMSG_DUEL_OUTOFBOUNDS = 360, - SMSG_DUEL_INBOUNDS = 361, - SMSG_DUEL_COMPLETE = 362, - SMSG_DUEL_WINNER = 363, - CMSG_DUEL_ACCEPTED = 364, - CMSG_DUEL_CANCELLED = 365, - SMSG_MOUNTRESULT = 366, // 0 - can't mount that unit, 1 - mount too far away, 2 - already mounted, 3 - that unit can't be mounted, 4 - that mount is not our pet, 5 - unknown mount error, 6 - can't mount while looting, 7 - cant mount because your race, 8 - shapeshifted, 9 - you dismount before continuing - SMSG_DISMOUNTRESULT = 367, // 0 - int err, don't have pet to dismount, 1 - not mounted, 2 - int err, dismounting a non-pet - SMSG_PUREMOUNT_CANCELLED_OBSOLETE = 368, - CMSG_MOUNTSPECIAL_ANIM = 369, - SMSG_MOUNTSPECIAL_ANIM = 370, - SMSG_PET_TAME_FAILURE = 371, // uint32: 0 - Unknown taming error, 1 - Creature not found, 2 - too many pets, 3 - creature already controlled, 4 - creature not tameable, 5 - have active summon, 6 - can't tame, 7 - don't have pet to summon, 8 - internal pet error, 9 - high level, 10 - your pet is dead, 11 - your pet is not dead - CMSG_PET_SET_ACTION = 372, - CMSG_PET_ACTION = 373, - CMSG_PET_ABANDON = 374, - CMSG_PET_RENAME = 375, - SMSG_PET_NAME_INVALID = 376, // Error, invalid name entered. - SMSG_PET_SPELLS = 377, - SMSG_PET_MODE = 378, // uint64 pet_guid + uint32 flags? - CMSG_GOSSIP_HELLO = 379, - CMSG_GOSSIP_SELECT_OPTION = 380, - SMSG_GOSSIP_MESSAGE = 381, - SMSG_GOSSIP_COMPLETE = 382, - CMSG_NPC_TEXT_QUERY = 383, - SMSG_NPC_TEXT_UPDATE = 384, - SMSG_NPC_WONT_TALK = 385, - CMSG_QUESTGIVER_STATUS_QUERY = 386, - SMSG_QUESTGIVER_STATUS = 387, - CMSG_QUESTGIVER_HELLO = 388, - SMSG_QUESTGIVER_QUEST_LIST = 389, - CMSG_QUESTGIVER_QUERY_QUEST = 390, - CMSG_QUESTGIVER_QUEST_AUTOLAUNCH = 391, - SMSG_QUESTGIVER_QUEST_DETAILS = 392, - CMSG_QUESTGIVER_ACCEPT_QUEST = 393, - CMSG_QUESTGIVER_COMPLETE_QUEST = 394, - SMSG_QUESTGIVER_REQUEST_ITEMS = 395, - CMSG_QUESTGIVER_REQUEST_REWARD = 396, - SMSG_QUESTGIVER_OFFER_REWARD = 397, - CMSG_QUESTGIVER_CHOOSE_REWARD = 398, - SMSG_QUESTGIVER_QUEST_INVALID = 399, - CMSG_QUESTGIVER_CANCEL = 400, - SMSG_QUESTGIVER_QUEST_COMPLETE = 401, - SMSG_QUESTGIVER_QUEST_FAILED = 402, - CMSG_QUESTLOG_SWAP_QUEST = 403, - CMSG_QUESTLOG_REMOVE_QUEST = 404, - SMSG_QUESTLOG_FULL = 405, - SMSG_QUESTUPDATE_FAILED = 406, - SMSG_QUESTUPDATE_FAILEDTIMER = 407, - SMSG_QUESTUPDATE_COMPLETE = 408, - SMSG_QUESTUPDATE_ADD_KILL = 409, - SMSG_QUESTUPDATE_ADD_ITEM = 410, - CMSG_QUEST_CONFIRM_ACCEPT = 411, - SMSG_QUEST_CONFIRM_ACCEPT = 412, - CMSG_PUSHQUESTTOPARTY = 413, - CMSG_LIST_INVENTORY = 414, - SMSG_LIST_INVENTORY = 415, - CMSG_SELL_ITEM = 416, - SMSG_SELL_ITEM = 417, - CMSG_BUY_ITEM = 418, - CMSG_BUY_ITEM_IN_SLOT = 419, - SMSG_BUY_ITEM = 420, - SMSG_BUY_FAILED = 421, - CMSG_TAXICLEARALLNODES = 422, - CMSG_TAXIENABLEALLNODES = 423, - CMSG_TAXISHOWNODES = 424, - SMSG_SHOWTAXINODES = 425, - CMSG_TAXINODE_STATUS_QUERY = 426, - SMSG_TAXINODE_STATUS = 427, - CMSG_TAXIQUERYAVAILABLENODES = 428, - CMSG_ACTIVATETAXI = 429, - SMSG_ACTIVATETAXIREPLY = 430, - SMSG_NEW_TAXI_PATH = 431, - CMSG_TRAINER_LIST = 432, - SMSG_TRAINER_LIST = 433, - CMSG_TRAINER_BUY_SPELL = 434, - SMSG_TRAINER_BUY_SUCCEEDED = 435, - SMSG_TRAINER_BUY_FAILED = 436, - CMSG_BINDER_ACTIVATE = 437, - SMSG_PLAYERBINDERROR = 438, // You already bound there. - CMSG_BANKER_ACTIVATE = 439, - SMSG_SHOW_BANK = 440, - CMSG_BUY_BANK_SLOT = 441, - SMSG_BUY_BANK_SLOT_RESULT = 442, - CMSG_PETITION_SHOWLIST = 443, - SMSG_PETITION_SHOWLIST = 444, - CMSG_PETITION_BUY = 445, - CMSG_PETITION_SHOW_SIGNATURES = 446, - SMSG_PETITION_SHOW_SIGNATURES = 447, - CMSG_PETITION_SIGN = 448, - SMSG_PETITION_SIGN_RESULTS = 449, - MSG_PETITION_DECLINE = 450, - CMSG_OFFER_PETITION = 451, - CMSG_TURN_IN_PETITION = 452, - SMSG_TURN_IN_PETITION_RESULTS = 453, - CMSG_PETITION_QUERY = 454, - SMSG_PETITION_QUERY_RESPONSE = 455, - SMSG_FISH_NOT_HOOKED = 456, - SMSG_FISH_ESCAPED = 457, - CMSG_BUG = 458, - SMSG_NOTIFICATION = 459, - CMSG_PLAYED_TIME = 460, - SMSG_PLAYED_TIME = 461, - CMSG_QUERY_TIME = 462, - SMSG_QUERY_TIME_RESPONSE = 463, - SMSG_LOG_XPGAIN = 464, - MSG_SPLIT_MONEY = 465, - CMSG_RECLAIM_CORPSE = 466, - CMSG_WRAP_ITEM = 467, - SMSG_LEVELUP_INFO = 468, - MSG_MINIMAP_PING = 469, - SMSG_RESISTLOG = 470, - SMSG_ENCHANTMENTLOG = 471, - CMSG_SET_SKILL_CHEAT = 472, - SMSG_START_MIRROR_TIMER = 473, - SMSG_PAUSE_MIRROR_TIMER = 474, - SMSG_STOP_MIRROR_TIMER = 475, - CMSG_PING = 476, - SMSG_PONG = 477, - SMSG_CLEAR_COOLDOWN = 478, - SMSG_GAMEOBJECT_PAGETEXT = 479, // uint64 guid - CMSG_SETSHEATHED = 480, - SMSG_COOLDOWN_CHEAT = 481, - SMSG_SPELL_DELAYED = 482, - CMSG_PLAYER_MACRO_OBSOLETE = 483, - SMSG_PLAYER_MACRO_OBSOLETE = 484, - CMSG_GHOST = 485, - CMSG_GM_INVIS = 486, - SMSG_INVALID_PROMOTION_CODE = 487, // Couldn't validate code, please try again. - MSG_GM_BIND_OTHER = 488, - MSG_GM_SUMMON = 489, - SMSG_ITEM_TIME_UPDATE = 490, // uint64 guid + uint32 time - SMSG_ITEM_ENCHANT_TIME_UPDATE = 491, - SMSG_AUTH_CHALLENGE = 492, - CMSG_AUTH_SESSION = 493, - SMSG_AUTH_RESPONSE = 494, - MSG_GM_SHOWLABEL = 495, - MSG_ADD_DYNAMIC_TARGET_OBSOLETE = 496, - MSG_SAVE_GUILD_EMBLEM = 497, - MSG_TABARDVENDOR_ACTIVATE = 498, - SMSG_PLAY_SPELL_VISUAL = 499, - CMSG_ZONEUPDATE = 500, - SMSG_PARTYKILLLOG = 501, - SMSG_COMPRESSED_UPDATE_OBJECT = 502, - SMSG_OBSOLETE = 503, - SMSG_EXPLORATION_EXPERIENCE = 504, - CMSG_GM_SET_SECURITY_GROUP = 505, - CMSG_GM_NUKE = 506, - MSG_RANDOM_ROLL = 507, - SMSG_ENVIRONMENTALDAMAGELOG = 508, - CMSG_RWHOIS = 509, - SMSG_RWHOIS = 510, - MSG_LOOKING_FOR_GROUP = 511, - CMSG_SET_LOOKING_FOR_GROUP = 512, - CMSG_UNLEARN_SPELL = 513, - CMSG_UNLEARN_SKILL = 514, - SMSG_REMOVED_SPELL = 515, - CMSG_DECHARGE = 516, - CMSG_GMTICKET_CREATE = 517, - SMSG_GMTICKET_CREATE = 518, - CMSG_GMTICKET_UPDATETEXT = 519, - SMSG_GMTICKET_UPDATETEXT = 520, - SMSG_ACCOUNT_DATA_MD5 = 521, - CMSG_REQUEST_ACCOUNT_DATA = 522, - CMSG_UPDATE_ACCOUNT_DATA = 523, - SMSG_UPDATE_ACCOUNT_DATA = 524, - SMSG_CLEAR_FAR_SIGHT_IMMEDIATE = 525, - SMSG_POWERGAINLOG_OBSOLETE = 526, - CMSG_GM_TEACH = 527, - CMSG_GM_CREATE_ITEM_TARGET = 528, - CMSG_GMTICKET_GETTICKET = 529, - SMSG_GMTICKET_GETTICKET = 530, - CMSG_UNLEARN_TALENTS = 531, - SMSG_GAMEOBJECT_SPAWN_ANIM = 532, - SMSG_GAMEOBJECT_DESPAWN_ANIM = 533, - MSG_CORPSE_QUERY = 534, - CMSG_GMTICKET_DELETETICKET = 535, - SMSG_GMTICKET_DELETETICKET = 536, - SMSG_CHAT_WRONG_FACTION = 537, // You can only whisper to the members of your alliance. - CMSG_GMTICKET_SYSTEMSTATUS = 538, - SMSG_GMTICKET_SYSTEMSTATUS = 539, - CMSG_SPIRIT_HEALER_ACTIVATE = 540, - CMSG_SET_STAT_CHEAT = 541, - SMSG_SET_REST_START = 542, - CMSG_SKILL_BUY_STEP = 543, - CMSG_SKILL_BUY_RANK = 544, - CMSG_XP_CHEAT = 545, - SMSG_SPIRIT_HEALER_CONFIRM = 546, - CMSG_CHARACTER_POINT_CHEAT = 547, - SMSG_GOSSIP_POI = 548, - CMSG_CHAT_IGNORED = 549, - CMSG_GM_VISION = 550, - CMSG_SERVER_COMMAND = 551, - CMSG_GM_SILENCE = 552, - CMSG_GM_REVEALTO = 553, - CMSG_GM_RESURRECT = 554, - CMSG_GM_SUMMONMOB = 555, - CMSG_GM_MOVECORPSE = 556, - CMSG_GM_FREEZE = 557, - CMSG_GM_UBERINVIS = 558, - CMSG_GM_REQUEST_PLAYER_INFO = 559, - SMSG_GM_PLAYER_INFO = 560, - CMSG_GUILD_RANK = 561, - CMSG_GUILD_ADD_RANK = 562, - CMSG_GUILD_DEL_RANK = 563, - CMSG_GUILD_SET_PUBLIC_NOTE = 564, - CMSG_GUILD_SET_OFFICER_NOTE = 565, - SMSG_LOGIN_VERIFY_WORLD = 566, - CMSG_CLEAR_EXPLORATION = 567, - CMSG_SEND_MAIL = 568, - SMSG_SEND_MAIL_RESULT = 569, - CMSG_GET_MAIL_LIST = 570, - SMSG_MAIL_LIST_RESULT = 571, - CMSG_BATTLEFIELD_LIST = 572, - SMSG_BATTLEFIELD_LIST = 573, - CMSG_BATTLEFIELD_JOIN = 574, - SMSG_BATTLEFIELD_WIN = 575, - SMSG_BATTLEFIELD_LOSE = 576, - CMSG_TAXICLEARNODE = 577, - CMSG_TAXIENABLENODE = 578, - CMSG_ITEM_TEXT_QUERY = 579, - SMSG_ITEM_TEXT_QUERY_RESPONSE = 580, - CMSG_MAIL_TAKE_MONEY = 581, - CMSG_MAIL_TAKE_ITEM = 582, - CMSG_MAIL_MARK_AS_READ = 583, - CMSG_MAIL_RETURN_TO_SENDER = 584, - CMSG_MAIL_DELETE = 585, - CMSG_MAIL_CREATE_TEXT_ITEM = 586, - SMSG_SPELLLOGMISS = 587, - SMSG_SPELLLOGEXECUTE = 588, - SMSG_DEBUGAURAPROC = 589, - SMSG_PERIODICAURALOG = 590, - SMSG_SPELLDAMAGESHIELD = 591, - SMSG_SPELLNONMELEEDAMAGELOG = 592, - CMSG_LEARN_TALENT = 593, - SMSG_RESURRECT_FAILED = 594, - CMSG_TOGGLE_PVP = 595, - SMSG_ZONE_UNDER_ATTACK = 596, - MSG_AUCTION_HELLO = 597, - CMSG_AUCTION_SELL_ITEM = 598, - CMSG_AUCTION_REMOVE_ITEM = 599, - CMSG_AUCTION_LIST_ITEMS = 600, - CMSG_AUCTION_LIST_OWNER_ITEMS = 601, - CMSG_AUCTION_PLACE_BID = 602, - SMSG_AUCTION_COMMAND_RESULT = 603, - SMSG_AUCTION_LIST_RESULT = 604, - SMSG_AUCTION_OWNER_LIST_RESULT = 605, - SMSG_AUCTION_BIDDER_NOTIFICATION = 606, - SMSG_AUCTION_OWNER_NOTIFICATION = 607, - SMSG_PROCRESIST = 608, - SMSG_STANDSTATE_CHANGE_FAILURE = 609, - SMSG_DISPEL_FAILED = 610, - SMSG_SPELLORDAMAGE_IMMUNE = 611, - CMSG_AUCTION_LIST_BIDDER_ITEMS = 612, - SMSG_AUCTION_BIDDER_LIST_RESULT = 613, - SMSG_SET_FLAT_SPELL_MODIFIER = 614, - SMSG_SET_PCT_SPELL_MODIFIER = 615, - CMSG_SET_AMMO = 616, - SMSG_CORPSE_RECLAIM_DELAY = 617, - CMSG_SET_ACTIVE_MOVER = 618, - CMSG_PET_CANCEL_AURA = 619, - CMSG_PLAYER_AI_CHEAT = 620, - CMSG_CANCEL_AUTO_REPEAT_SPELL = 621, - MSG_GM_ACCOUNT_ONLINE = 622, - MSG_LIST_STABLED_PETS = 623, - CMSG_STABLE_PET = 624, - CMSG_UNSTABLE_PET = 625, - CMSG_BUY_STABLE_SLOT = 626, - SMSG_STABLE_RESULT = 627, - CMSG_STABLE_REVIVE_PET = 628, - CMSG_STABLE_SWAP_PET = 629, - MSG_QUEST_PUSH_RESULT = 630, - SMSG_PLAY_MUSIC = 631, - SMSG_PLAY_OBJECT_SOUND = 632, - CMSG_REQUEST_PET_INFO = 633, - CMSG_FAR_SIGHT = 634, - SMSG_SPELLDISPELLOG = 635, - SMSG_DAMAGE_CALC_LOG = 636, - CMSG_ENABLE_DAMAGE_LOG = 637, - CMSG_GROUP_CHANGE_SUB_GROUP = 638, - CMSG_REQUEST_PARTY_MEMBER_STATS = 639, - CMSG_GROUP_SWAP_SUB_GROUP = 640, - CMSG_RESET_FACTION_CHEAT = 641, - CMSG_AUTOSTORE_BANK_ITEM = 642, - CMSG_AUTOBANK_ITEM = 643, - MSG_QUERY_NEXT_MAIL_TIME = 644, - SMSG_RECEIVED_MAIL = 645, - SMSG_RAID_GROUP_ONLY = 646, // You are not in this instance group. You will be teleported to %s in %u Minites. uint32 time(milliseconds)+uint32 unk - CMSG_SET_DURABILITY_CHEAT = 647, - CMSG_SET_PVP_RANK_CHEAT = 648, - CMSG_ADD_PVP_MEDAL_CHEAT = 649, - CMSG_DEL_PVP_MEDAL_CHEAT = 650, - CMSG_SET_PVP_TITLE = 651, - SMSG_PVP_CREDIT = 652, - SMSG_AUCTION_REMOVED_NOTIFICATION = 653, - CMSG_GROUP_RAID_CONVERT = 654, - CMSG_GROUP_ASSISTANT = 655, - CMSG_BUYBACK_ITEM = 656, - SMSG_SERVER_MESSAGE = 657, - CMSG_MEETINGSTONE_JOIN = 658, - CMSG_MEETINGSTONE_LEAVE = 659, - CMSG_MEETINGSTONE_CHEAT = 660, - SMSG_MEETINGSTONE_SETQUEUE = 661, // You have left the queue to join a party for %s. - CMSG_MEETINGSTONE_INFO = 662, - SMSG_MEETINGSTONE_COMPLETE = 663, // Your group is complete, you have left the LFG matchmaking system. - SMSG_MEETINGSTONE_IN_PROGRESS = 664, // You still seeking more members through LFG matchmaking system., empty? - SMSG_MEETINGSTONE_MEMBER_ADDED = 665, // %s has been added to the group by the LFG matchmaking system. - CMSG_GMTICKETSYSTEM_TOGGLE = 666, - CMSG_CANCEL_GROWTH_AURA = 667, - SMSG_CANCEL_AUTO_REPEAT = 668, - SMSG_STANDSTATE_CHANGE_ACK = 669, - SMSG_LOOT_ALL_PASSED = 670, - SMSG_LOOT_ROLL_WON = 671, - CMSG_LOOT_ROLL = 672, - SMSG_LOOT_START_ROLL = 673, - SMSG_LOOT_ROLL = 674, - CMSG_LOOT_MASTER_GIVE = 675, - SMSG_LOOT_MASTER_LIST = 676, - SMSG_SET_FORCED_REACTIONS = 677, - SMSG_SPELL_FAILED_OTHER = 678, - SMSG_GAMEOBJECT_RESET_STATE = 679, // uint64 guid - CMSG_REPAIR_ITEM = 680, - SMSG_CHAT_PLAYER_NOT_FOUND = 681, - MSG_TALENT_WIPE_CONFIRM = 682, - SMSG_SUMMON_REQUEST = 683, // uint64 guid + uint32 area/zoneid + uint32 time(milliseconds?) - CMSG_SUMMON_RESPONSE = 684, - MSG_MOVE_TOGGLE_GRAVITY_CHEAT = 685, - SMSG_MONSTER_MOVE_TRANSPORT = 686, - SMSG_PET_BROKEN = 687, // Your pet has run away (:D) - MSG_MOVE_FEATHER_FALL = 688, - MSG_MOVE_WATER_WALK = 689, - CMSG_SERVER_BROADCAST = 690, - CMSG_SELF_RES = 691, // only if PLAYER_SELF_RES_SPELL field != 0 - SMSG_FEIGN_DEATH_RESISTED = 692, // Resisted - CMSG_RUN_SCRIPT = 693, - SMSG_SCRIPT_MESSAGE = 694, - SMSG_DUEL_COUNTDOWN = 695, - SMSG_AREA_TRIGGER_MESSAGE = 696, - CMSG_TOGGLE_HELM = 697, - CMSG_TOGGLE_CLOAK = 698, - SMSG_MEETINGSTONE_JOINFAILED = 699, // 1 - must be party leader, 3 - can't use while in raid - SMSG_PLAYER_SKINNED = 700, // uint8 0x00 Insignia taken - You can only resurrect at the graveyard - SMSG_DURABILITY_DAMAGE_DEATH = 701, - CMSG_SET_EXPLORATION = 702, - CMSG_SET_ACTIONBAR_TOGGLES = 703, - UMSG_DELETE_GUILD_CHARTER = 704, - MSG_PETITION_RENAME = 705, - SMSG_INIT_WORLD_STATES = 706, - SMSG_UPDATE_WORLD_STATE = 707, - CMSG_ITEM_NAME_QUERY = 708, - SMSG_ITEM_NAME_QUERY_RESPONSE = 709, - SMSG_PET_ACTION_FEEDBACK = 710, // uint8 0x04 - unk, 0x01 - pet dead, 0x2 - no target, 0x3 can't attack - CMSG_CHAR_RENAME = 711, - SMSG_CHAR_RENAME = 712, - CMSG_MOVE_SPLINE_DONE = 713, - CMSG_MOVE_FALL_RESET = 714, - SMSG_INSTANCE_SAVE_CREATED = 715, // You are now saved to this instance - SMSG_RAID_INSTANCE_INFO = 716, - CMSG_REQUEST_RAID_INFO = 717, - CMSG_MOVE_TIME_SKIPPED = 718, - CMSG_MOVE_FEATHER_FALL_ACK = 719, - CMSG_MOVE_WATER_WALK_ACK = 720, - CMSG_MOVE_NOT_ACTIVE_MOVER = 721, - SMSG_PLAY_SOUND = 722, - CMSG_BATTLEFIELD_STATUS = 723, - SMSG_BATTLEFIELD_STATUS = 724, - CMSG_BATTLEFIELD_PORT = 725, - MSG_INSPECT_HONOR_STATS = 726, - CMSG_BATTLEMASTER_HELLO = 727, - CMSG_MOVE_START_SWIM_CHEAT = 728, - CMSG_MOVE_STOP_SWIM_CHEAT = 729, - SMSG_FORCE_WALK_SPEED_CHANGE = 730, - CMSG_FORCE_WALK_SPEED_CHANGE_ACK = 731, - SMSG_FORCE_SWIM_BACK_SPEED_CHANGE = 732, - CMSG_FORCE_SWIM_BACK_SPEED_CHANGE_ACK = 733, - SMSG_FORCE_TURN_RATE_CHANGE = 734, - CMSG_FORCE_TURN_RATE_CHANGE_ACK = 735, - MSG_PVP_LOG_DATA = 736, - CMSG_LEAVE_BATTLEFIELD = 737, - CMSG_AREA_SPIRIT_HEALER_QUERY = 738, - CMSG_AREA_SPIRIT_HEALER_QUEUE = 739, - SMSG_AREA_SPIRIT_HEALER_TIME = 740, // uint64 guid+uint32 time - CMSG_GM_UNTEACH = 741, - SMSG_WARDEN_DATA = 742, - CMSG_WARDEN_DATA = 743, - SMSG_GROUP_JOINED_BATTLEGROUND = 744, // uint32 0xfffffffc, probably different error messages... - MSG_BATTLEGROUND_PLAYER_POSITIONS = 745, - CMSG_PET_STOP_ATTACK = 746, - SMSG_BINDER_CONFIRM = 747, - SMSG_BATTLEGROUND_PLAYER_JOINED = 748, - SMSG_BATTLEGROUND_PLAYER_LEFT = 749, - CMSG_BATTLEMASTER_JOIN = 750, - SMSG_ADDON_INFO = 751, - CMSG_PET_UNLEARN = 752, - SMSG_PET_UNLEARN_CONFIRM = 753, - SMSG_PARTY_MEMBER_STATS_FULL = 754, - CMSG_PET_SPELL_AUTOCAST = 755, - SMSG_WEATHER = 756, - SMSG_PLAY_TIME_WARNING = 757, - SMSG_MINIGAME_SETUP = 758, - SMSG_MINIGAME_STATE = 759, - CMSG_MINIGAME_MOVE = 760, - SMSG_MINIGAME_MOVE_FAILED = 761, - SMSG_INSTANCE_RESET_SCHEDULED = 762, // WARNING! %s is scheduled to reset in %u minutes! and other messages... - SMSG_COMPRESSED_MOVE = 763, - CMSG_GUILD_CHANGEINFO = 764, - SMSG_TRIAL_RESTRICTED = 765, // Trial accounts cannot send unlimited tells, you must wait before you can send tells to more players. - SMSG_SET_MOVE_SPEED = 766, // GUID + float speed, move speed, except swim/turn/fly - SMSG_SET_RUN_BACK_SPEED = 767, // GUID + float speed, run back speed - SMSG_SET_SWIM_SPEED = 768, // GUID + float speed, swim and swim back speed - // 769 - SMSG_SET_SWIM_BACK_SPEED = 770, // swim back speed - SMSG_SET_TURN_RATE = 771, // turn rate (note: client crashes if fly mode enabled, and turn rate = 0) - SMSG_UNKNOWN_772 = 772, // packed GUID - SMSG_UNKNOWN_773 = 773, // set movement flag 0x20000000 (safe fall) - SMSG_UNKNOWN_774 = 774, // stop effect of 773 opcode - SMSG_UNKNOWN_775 = 775, // movement related, looks like hover, movement flag 0x40000000, we can't jump if we are lands - SMSG_UNKNOWN_776 = 776, // stop effect of 775 opcode - SMSG_MOVE_SET_WATERWALK = 777, // packed GUID, set movement flag 0x10000000, waterwalking... - SMSG_MOVE_STOP_WATERWALK = 778, // packed GUID, stop effect of 777 opcode - SMSG_UNKNOWN_779 = 779, // packed guid, change animation to swim/fly like - SMSG_UNKNOWN_780 = 780, // packed guid - SMSG_MOVE_STOP_WALK = 781, // packed guid, remove 0x100 movement flag (walk) - SMSG_MOVE_START_WALK = 782, // set 0x100 movement flag (walk) - // 783 - // 784 - // 785 - CMSG_ACTIVATETAXI_FAR = 786, - // 787 causes client crash - // 788 - // 789 - // 790 - CMSG_FIELD_WATCHED_FACTION_INACTIVE = 791, - CMSG_FIELD_WATCHED_FACTION_SHOW_BAR = 792, - SMSG_UNKNOWN_793 = 793, // packed guid + uint32 unk - SMSG_UNKNOWN_794 = 794, // packed guid, movement related, set 0x1000 movement flag, all speed to 0, except turn rate - // 795 - SMSG_UNKNOWN_796 = 796, // uint64, guid, chat related? - CMSG_RESET_INSTANCES = 797, // reset instances, empty - SMSG_RESET_INSTANCES_SUCCESS = 798, // uint32 mapid, chat message: %s has been reset. - SMSG_RESET_INSTANCES_FAILED = 799, // uint32 reason, uint32 mapid - SMSG_UNKNOWN_800 = 800, // uint32 mapid, instance related (save?) - MSG_RAID_ICON_TARGET = 801, // uint8+uint8+uint64 guid or only uint8(0x01) - MSG_RAID_READY_CHECK = 802, // uint64+uint8 - // 803 - SMSG_PET_ACTION_SOUND = 804, // GUID + uint32, looks like SMSG_AI_REACTION (pet action sound?) - SMSG_PET_DISMISS_SOUND = 805, // uint32 unk + x, y, z (pet dismiss sound?) - // 806 - // 807 - SMSG_GM_SURVEY_REQUEST = 808, // uint32, 1 - causes client get ticket request, 2 - hide, 3 - show - MSG_SET_DUNGEON_DIFFICULTY = 809, // uint32+uint32+uint32 - CMSG_GM_SURVEY_RESULTS = 810, // script function named GMSurveySubmit() - SMSG_UNKNOWN_811 = 811, // uint32, 0x0, SMSG_INSTANCE_RESET_ACTIVATE ? - // 812 - // 813 - // 814 - SMSG_SPELL_INSTA_KILL_SELF = 815, // spell related, uint64 guid + spellid (You are killed by %s(spell_name)) - SMSG_UNKNOWN_816 = 816, // spell related, uint64 guid + spellid + uint32 count + for(count) uint64 guid (target?) - // 817 - SMSG_ANTISPAM = 818, // 2.0.8, received before server MOTD, strange regexp sequence, looks like anti spam filter for chat messages... - // 819 - // 820 - // 821 - // 822 - // 823 - // 824 - // 825 - SMSG_OUTDOORPVP_NOTIFY = 826, // looks like chat packets - // 827 - // 828 - SMSG_MOTD = 829, // server MOTD message, uint32 + message - // 830 - // 831 - // 832 - SMSG_UNKNOWN_833 = 833, // teleport/movement opcode - SMSG_UNKNOWN_834 = 834, // teleport/movement opcode - SMSG_FLY_MODE_START = 835, // packed guid + uint32, start fly - SMSG_FLY_MODE_STOP = 836, // packed guid + uint32, stop fly - CMSG_MOVE_FLY_MODE_CHANGE_ACK = 837, // movement related, fly on/off ack - MSG_MOVE_FLY_STATE_CHANGE = 838, // movement related, fly start/stop(land) ack, may be MSG - CMSG_SOCKET_ITEM = 839, // click on "Socket Gems" button in Jewelcrafting UI, contains uint64 item guid + 3 x uint64 gems guid's - // 840, CMSG? - SMSG_ARENA_TEAM_COMMAND_RESULT = 841, // uint32 command, name1, name2, uint32 errorcode - // 842 - CMSG_ARENA_TEAM_QUERY = 843, - SMSG_ARENA_TEAM_QUERY_RESPONSE = 844, - CMSG_ARENA_TEAM_ROSTER = 845, - SMSG_ARENA_TEAM_ROSTER = 846, - CMSG_ARENA_TEAM_INVITE_BYNAME = 847, - SMSG_ARENA_TEAM_INVITE = 848, - CMSG_ARENA_TEAM_ACCEPT = 849, - CMSG_ARENA_TEAM_DECLINE = 850, - CMSG_ARENA_TEAM_LEAVE = 851, - CMSG_ARENA_TEAM_UNINVITE_BYNAME = 852, - CMSG_ARENA_TEAM_DISBAND = 853, - CMSG_ARENA_TEAM_SET_LEADER_BYNAME = 854, // also must be demote opcode... - SMSG_ARENA_TEAM_EVENT = 855, // arena team event - CMSG_ARENAMASTER_JOIN = 856, - MSG_MOVE_START_FLY_UP = 857, // movement related, fly up, possible MSG - MSG_MOVE_STOP_FLY_UP = 858, // movement related, stop fly up, possible MSG - SMSG_ARENA_TEAM_STATS = 859, - CMSG_LFG_SET_AUTOJOIN = 860, - CMSG_LFG_UNSET_AUTOJOIN = 861, - CMSG_LFM_SET_AUTOADD = 862, - CMSG_LFM_UNSET_AUTOADD = 863, - CMSG_LFG_INVITE_ACCEPT = 864, - CMSG_LFG_INVITE_CANCEL = 865, - // 866, CMSG? - CMSG_LOOKING_FOR_GROUP_CLEAR = 867, - CMSG_SET_LOOKING_FOR_NONE = 868, - CMSG_SET_LOOKING_FOR_MORE = 869, - CMSG_SET_COMMENTARY = 870, - SMSG_LFG_MATCHMAKING_TIMEDOUT = 871, // Matchmaking timed out. - SMSG_LFG_MATCHMAKING_OTHER_TIMEDOUT = 872, // Matchmaking timed out waiting for other player. - SMSG_LFG_MATCHMAKING_AUTOJOIN_FAILED = 873, // Group no longer available. - SMSG_LFG_MATCHMAKING_AUTOJOIN_FAILED_NO_PLAYER = 874, // Matched Player(s) have gone offline. - // 875 - SMSG_LFG_876 = 876, // LFM eye, in progress, uint16+uint32+uint8?, 3 x uint8(0x0) - SMSG_LFG_877 = 877, // cause client send CMSG_SET_LOOKING_FOR_GROUP, uint32+uint8? - SMSG_LFG_878 = 878, // cause client send CMSG_SET_LOOKING_FOR_GROUP - SMSG_LFG_879 = 879, // LFG eye, cause client send CMSG_SET_LOOKING_FOR_GROUP - SMSG_LFG_MATCHMAKING_PENDING_INVITE = 880, // The LFG system has matched you to a group for %s. - SMSG_LFG_MATCHMAKING_PENDING_MATCH = 881, // The LFG system is waiting to complete match for %s. - // 882 - SMSG_CHANGE_TITLE = 883, // uint32 title_id, causes message and visual effect - CMSG_CHOOSE_TITLE = 884, // uint32 title_id - CMSG_DISMOUNT = 885, // /dismount command - SMSG_ARENA_NO_TEAM = 886, // uint32(0) + team type - MSG_INSPECT_ARENA_STATS = 887, - SMSG_SH_POSITION = 888, // spirit healer position, map/x/y/z, at player death... - CMSG_CANCEL_TEMP_ITEM_ENCHANTMENT = 889, // cancel temporary item enchantment - // 890 - // 891 - // 892 - // 893 - MSG_MOVE_SET_FLY_SPEED = 894, // all fly speed, packed guid, uint32 movement_flags, time, x,y,z,o,unk,speed... - // 895 - MSG_MOVE_SET_FLY_BACK_SPEED = 896, - SMSG_FORCE_FLY_SPEED_CHANGE = 897, // packed guid, uint32, speed - CMSG_FORCE_FLY_SPEED_CHANGE_ACK = 898, - SMSG_FORCE_FLY_BACK_SPEED_CHANGE = 899, - CMSG_FORCE_FLY_BACK_SPEED_CHANGE_ACK = 900, - SMSG_MOVE_SET_FLY_SPEED2 = 901, // same as 894, strange, packed guid+speed - SMSG_MOVE_SET_FLY_BACK_SPEED2 = 902, // same as 896, strange, - // 903 - SMSG_FLIGHT_SPLINE_SYNC = 904, // uint32 + packed_guid - CMSG_SET_TAXI_BENCHMARK_MODE = 905, - // 906 - SMSG_REALM_SPLIT_INFO_RESPONSE = 907, // response to 908 opcode, uint32+uint32+string(date) - CMSG_REALM_SPLIT_INFO_REQUEST = 908, // realm related, uint32, appears at select character screen, uint32 0xFFFFFFFF by default - MSG_MOVE_SHIP_909 = 909, // movement related, transport related(ships) - CMSG_GROUP_PROMOTE = 910, // make main-tank / main-assistant - SMSG_ALREADY_IN_ARENA_TEAM = 911, // %s is already in an arena team of that size (uint64 guid) - SMSG_ALLOW_MOVE = 912, // uint32, allow player movement, value increments every time and reset to 0 after far teleport, used for client-server synchronization - CMSG_ALLOW_MOVE_ACK = 913, // client response to SMSG_ALLOW_MOVE (counter + client time) - // 914 - // 915 - // 916 - // 917 - SMSG_RESET_INSTANCE_FAILED_NOTIFY = 918, // chat message: The party leader has attempted to reset the instance you are in. Please zone out to allow the instance to reset. - SMSG_UNKNOWN_919 = 919, // uint8(0)+uint32(0/1)+uint64(unk/guid) - SMSG_SYSTEM_DISABLED = 920, // notify message: This system is currently disabled. - // 921 - // 922 - // 923 - // 924 - SMSG_SET_COMBO_POINTS = 925, // set combo points - SMSG_VOICE_SESSION = 926, - SMSG_UNKNOWN_927 = 927, // uint64 guid + uint32 + float?, received after leave voice channel - // 928 - // 929 - // 930 - SMSG_SET_AURA_MULTIPLY = 931, // packed_guid + n * (uint8 slot + uint32 spellid + uint32 duration1 + uint32 duration2) - SMSG_SET_AURA_SINGLE = 932, // packed_guid + uint8 slot + uint32 spellid + uint32 duration1 + uint32 duration2 - // 933 - SMSG_CAST_SUCCESS = 934, - MSG_UNKNOWN_935 = 935, // teleport/movement opcode - // 936 - // 937 - SMSG_UNKNOWN_938 = 938, // uint64, uint64, uint32 spellid, uint32, uint32 - // 939 - SMSG_UNKNOWN_940 = 940, // packed guid (received at spell cast) - SMSG_UNKNOWN_941 = 941, // teleport/movement opcode - SMSG_READY_CHECK_ALL_READY = 942, // Everyone is Ready! (message) - CMSG_VOICE_SETTINGS = 943, // uint8 isVoiceEnabled, uint8 isMicrophoneEnabled (id correct for 2.3.0) - SMSG_VOICE_CHAT_PARENTAL_DISABLE_ALL = 944, // Voice chat has been disabled by parental control - // 945 - // 946 - // 947 - CMSG_COMMENTATOR_SET_MODE = 948, - // 949 - CMSG_COMMENTATOR_UPDATE_MAP_INFO = 950, - // 951 - CMSG_COMMENTATOR_UPDATE_PLAYER_INFO = 952, - CMSG_UNKNOWN_953 = 953, // response to 942 opcode - //CMSG_REPORT_SPAM = 954, // now(2.3.0) CMSG_COMPLAINT_CHAT - //SMSG_REPORT_SPAM_RESPONSE = 955, // now(2.3.0) SMSG_COMPLAINT_ADDED - CMSG_COMMENTATOR_EXIT_INSTANCE = 956, // unk uint8 - // 957 - // 958 clear selection? - // 959 - SMSG_UNKNOWN_960 = 960, // uint64 guid, uint32, uint32 (client sedn CMSG_ITEM_QUERY_SINGLE) - // 961 - // 962 - //SMSG_DISCONNECT_CLIENT = 963, // really?? not - // 964 - // 965 - CMSG_COMPLAINT_CHAT = 966, // Report Spam chat button - SMSG_COMPLAINT_ADDED = 967, // Complaint Registered. (message) - SMSG_VOICE_SYSTEM_STATUS = 968, // uint8, uint8 (id correct for 2.3.0) - // 969 - // 970 - CMSG_CHANNEL_SILENT_VOICE = 971, - CMSG_CHANNEL_SILENT_ALL = 972, - CMSG_CHANNEL_UNSILENT_VOICE = 973, - CMSG_CHANNEL_UNSILENT_ALL = 974, - // 975 - // 976 - CMSG_CHANNEL_ROSTER_QUERY = 977, // string channel name (channel list?) - CMSG_CHANNEL_VOICE_CHAT_QUERY = 978, // uint32, string - CMSG_CHANNEL_INFO_QUERY = 979, // string channel name - SMSG_CHANNEL_INFO_QUERY_RESPONSE = 980, // string channel name, uint8 flags, uint32 count - CMSG_CHANNEL_VOICE_ON = 981, // Enable Voice button in channel context menu - CMSG_CHANNEL_VOICE_OFF = 982, // ?? - // 983 - // 984 - SMSG_CHANNEL_NOTIFY_AVAILABLE_VOICE_SESSION = 985, // 9 bytes unk's + string channel name + uint64 guid, received after join voice channel - CMSG_MUTE_PLAYER = 986, // ?? - CMSG_UNMUTE_PLAYER = 987, // ?? - CMSG_SILENCE_MEMBER = 988, // ?? - CMSG_UNSILENCE_MEMBER = 989, // ?? - SMSG_PLAYER_UNSILENCED = 990, // A group leader has restored your voice privileges - SMSG_COMSAT_RECONNECT_ATTEMPT = 991, // Voice chat service restored! - SMSG_COMSAT_DISCONNECT = 992, // Connection lost to voice chat service. - SMSG_COMSAT_CONNECT_FAIL = 993, // Cannot connect to voice chat service. - // 994 - // 995 - // 996 - CMSG_GUILD_BANK = 997, // click on guildbank object, uint64 guid + uint8 unk - CMSG_GUILDBANK_TAB_COLON = 998, // response to 999, uint64 guid + uint8 + uint8 - SMSG_GUILD_BANK_LIST = 999, // uint32 + uint32 + uint8 + uint8 + uint16 count1 + uint8 + uint8 count2 + for (count2) { uint8 unk } + uint16 + for(count1) { uint32 counter + uint8 unk } - CMSG_UNKNOWN_1000 = 1000, // uint64 guid, uint8, uint8, uint8 count, for(count) uint8 unk - CMSG_BUY_GUILDBANK_TAB = 1001, // uint64 guid + uint8 unk - // 1002 - CMSG_GUILDBANK_DEPOSIT = 1003, // uint64 guid + uint32 - CMSG_GUILDBANK_WITHDRAW = 1004, // uint64 guid + uint32 - MSG_GUILDBANK_LOG = 1005, // guild bank log? client: empty, server: uint8 count, for count (uint8 unk(type?), uint64 guid, uint32 unk(amount?)) - CMSG_CHANNEL_WATCH = 1006, // string channel name - SMSG_PLAYER_JOINED_CHANNEL = 1007, // uint64, uint8, uint8, uint32, string channel name - SMSG_PLAYER_LEFT_CHANNEL = 1008, // uint64, uint8, uint32, string channel name - SMSG_PLAYER_JOINED_CUSTOM_CHANNEL = 1009, // guessed - CMSG_CLEAR_CHANNEL_WATCH = 1010, - SMSG_INSPECT_TALENTS = 1011, // uint32 count, for(count) uint8 unk - // 1012 - // 1013 - // 1014 - CMSG_UNKNOWN_1015 = 1015, // click on NPC with 0x1000000 npc_flag - // 1016 - // 1017 - // 1018 - SMSG_VOICESESSION_FULL = 1019, // The voice session you are attempting to join is full. - MSG_UNKNOWN_1020 = 1020, // probably guild related, client: empty, server: uint32, uint32, uint8, uint32, uint32 - MSG_UNKNOWN_1021 = 1021, // guild related - MSG_GUILD_EVENT_LOG = 1022 -}; - -//if you add new opcode .. Do NOT forget to change the following define MAX_OPCODE_ID and also add new opcode to table in opcodes.cpp -#define MAX_OPCODE_ID 1023 - -/// Results of friend related commands -enum FriendsResult -{ - FRIEND_DB_ERROR = 0x00, - FRIEND_LIST_FULL = 0x01, - FRIEND_ONLINE = 0x02, - FRIEND_OFFLINE = 0x03, - FRIEND_NOT_FOUND = 0x04, - FRIEND_REMOVED = 0x05, - FRIEND_ADDED_ONLINE = 0x06, - FRIEND_ADDED_OFFLINE = 0x07, - FRIEND_ALREADY = 0x08, - FRIEND_SELF = 0x09, - FRIEND_ENEMY = 0x0A, - FRIEND_IGNORE_FULL = 0x0B, - FRIEND_IGNORE_SELF = 0x0C, - FRIEND_IGNORE_NOT_FOUND = 0x0D, - FRIEND_IGNORE_ALREADY = 0x0E, - FRIEND_IGNORE_ADDED = 0x0F, - FRIEND_IGNORE_REMOVED = 0x10, - // 0x11 - // 0x12 - // 0x13 - // 0x14 - // 0x15 - FRIEND_MUTE_ADDED = 0x16, - FRIEND_MUTE_REMOVED = 0x17 -}; - -/// Non Player Character flags -enum NPCFlags -{ - UNIT_NPC_FLAG_NONE = 0x00000000, - UNIT_NPC_FLAG_GOSSIP = 0x00000001, // 100% - UNIT_NPC_FLAG_QUESTGIVER = 0x00000002, // guessed, probably ok - UNIT_NPC_FLAG_UNK1 = 0x00000004, - UNIT_NPC_FLAG_UNK2 = 0x00000008, - UNIT_NPC_FLAG_TRAINER = 0x00000010, // 100% - UNIT_NPC_FLAG_TRAINER_CLASS = 0x00000020, // 100% - UNIT_NPC_FLAG_TRAINER_PROFESSION = 0x00000040, // 100% - UNIT_NPC_FLAG_VENDOR = 0x00000080, // 100% - UNIT_NPC_FLAG_VENDOR_AMMO = 0x00000100, // 100%, general goods vendor - UNIT_NPC_FLAG_VENDOR_FOOD = 0x00000200, // 100% - UNIT_NPC_FLAG_VENDOR_POISON = 0x00000400, // guessed - UNIT_NPC_FLAG_VENDOR_REAGENT = 0x00000800, // 100% - UNIT_NPC_FLAG_REPAIR = 0x00001000, // 100% - UNIT_NPC_FLAG_FLIGHTMASTER = 0x00002000, // 100% - UNIT_NPC_FLAG_SPIRITHEALER = 0x00004000, // guessed - UNIT_NPC_FLAG_SPIRITGUIDE = 0x00008000, // guessed - UNIT_NPC_FLAG_INNKEEPER = 0x00010000, // 100% - UNIT_NPC_FLAG_BANKER = 0x00020000, // 100% - UNIT_NPC_FLAG_PETITIONER = 0x00040000, // 100% 0xC0000 = guild petitions, 0x40000 = arena team petitions - UNIT_NPC_FLAG_TABARDDESIGNER = 0x00080000, // 100% - UNIT_NPC_FLAG_BATTLEMASTER = 0x00100000, // 100% - UNIT_NPC_FLAG_AUCTIONEER = 0x00200000, // 100% - UNIT_NPC_FLAG_STABLEMASTER = 0x00400000, // 100% - UNIT_NPC_FLAG_GUILD_BANKER = 0x00800000, // cause client to send 997 opcode - UNIT_NPC_FLAG_UNK3 = 0x01000000, // cause client to send 1015 opcode - UNIT_NPC_FLAG_GUARD = 0x10000000, // custom flag for guards -}; -#endif -/// @} +/* + * Copyright (C) 2005,2006,2007 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/// \addtogroup u2w +/// @{ +/// \file + +#ifndef _OPCODES_H +#define _OPCODES_H + +const char *GetOpcodeName(unsigned int); +const unsigned int GetOpcodeID(const char *); + +/// List of OpCodes +enum OpCodes +{ + MSG_NULL_ACTION = 0, + CMSG_BOOTME = 1, + CMSG_DBLOOKUP = 2, + SMSG_DBLOOKUP = 3, + CMSG_QUERY_OBJECT_POSITION = 4, + SMSG_QUERY_OBJECT_POSITION = 5, + CMSG_QUERY_OBJECT_ROTATION = 6, + SMSG_QUERY_OBJECT_ROTATION = 7, + CMSG_WORLD_TELEPORT = 8, + CMSG_TELEPORT_TO_UNIT = 9, + CMSG_ZONE_MAP = 10, + SMSG_ZONE_MAP = 11, + CMSG_DEBUG_CHANGECELLZONE = 12, + CMSG_EMBLAZON_TABARD_OBSOLETE = 13, + CMSG_UNEMBLAZON_TABARD_OBSOLETE = 14, + CMSG_RECHARGE = 15, + CMSG_LEARN_SPELL = 16, + CMSG_CREATEMONSTER = 17, + CMSG_DESTROYMONSTER = 18, + CMSG_CREATEITEM = 19, + CMSG_CREATEGAMEOBJECT = 20, + CMSG_MAKEMONSTERATTACKME_OBSOLETE = 21, + CMSG_MAKEMONSTERATTACKGUID = 22, + CMSG_ENABLEDEBUGCOMBATLOGGING_OBSOLETE = 23, + CMSG_FORCEACTION = 24, + CMSG_FORCEACTIONONOTHER = 25, + CMSG_FORCEACTIONSHOW = 26, + SMSG_FORCEACTIONSHOW = 27, + SMSG_ATTACKERSTATEUPDATEDEBUGINFO_OBSOLETE = 28, + SMSG_DEBUGINFOSPELL_OBSOLETE = 29, + SMSG_DEBUGINFOSPELLMISS_OBSOLETE = 30, + SMSG_DEBUG_PLAYER_RANGE_OBSOLETE = 31, + CMSG_UNDRESSPLAYER = 32, + CMSG_BEASTMASTER = 33, + CMSG_GODMODE = 34, + SMSG_GODMODE = 35, + CMSG_CHEAT_SETMONEY = 36, + CMSG_LEVEL_CHEAT = 37, + CMSG_PET_LEVEL_CHEAT = 38, + CMSG_LEVELUP_CHEAT_OBSOLETE = 39, + CMSG_COOLDOWN_CHEAT = 40, + CMSG_USE_SKILL_CHEAT = 41, + CMSG_FLAG_QUEST = 42, + CMSG_FLAG_QUEST_FINISH = 43, + CMSG_CLEAR_QUEST = 44, + CMSG_SEND_EVENT = 45, + CMSG_DEBUG_AISTATE = 46, + SMSG_DEBUG_AISTATE = 47, + CMSG_DISABLE_PVP_CHEAT = 48, + CMSG_ADVANCE_SPAWN_TIME = 49, + CMSG_PVP_PORT_OBSOLETE = 50, + CMSG_AUTH_SRP6_BEGIN = 51, + CMSG_AUTH_SRP6_PROOF = 52, + CMSG_AUTH_SRP6_RECODE = 53, + CMSG_CHAR_CREATE = 54, + CMSG_CHAR_ENUM = 55, + CMSG_CHAR_DELETE = 56, + SMSG_AUTH_SRP6_RESPONSE = 57, + SMSG_CHAR_CREATE = 58, + SMSG_CHAR_ENUM = 59, + SMSG_CHAR_DELETE = 60, + CMSG_PLAYER_LOGIN = 61, + SMSG_NEW_WORLD = 62, + SMSG_TRANSFER_PENDING = 63, + SMSG_TRANSFER_ABORTED = 64, + SMSG_CHARACTER_LOGIN_FAILED = 65, // kick client to character select screen and show "World server is down". + SMSG_LOGIN_SETTIMESPEED = 66, + SMSG_GAMETIME_UPDATE = 67, + CMSG_GAMETIME_SET = 68, + SMSG_GAMETIME_SET = 69, + CMSG_GAMESPEED_SET = 70, + SMSG_GAMESPEED_SET = 71, + CMSG_SERVERTIME = 72, + SMSG_SERVERTIME = 73, + CMSG_PLAYER_LOGOUT = 74, + CMSG_LOGOUT_REQUEST = 75, + SMSG_LOGOUT_RESPONSE = 76, + SMSG_LOGOUT_COMPLETE = 77, + CMSG_LOGOUT_CANCEL = 78, + SMSG_LOGOUT_CANCEL_ACK = 79, + CMSG_NAME_QUERY = 80, + SMSG_NAME_QUERY_RESPONSE = 81, + CMSG_PET_NAME_QUERY = 82, + SMSG_PET_NAME_QUERY_RESPONSE = 83, + CMSG_GUILD_QUERY = 84, + SMSG_GUILD_QUERY_RESPONSE = 85, + CMSG_ITEM_QUERY_SINGLE = 86, + CMSG_ITEM_QUERY_MULTIPLE = 87, + SMSG_ITEM_QUERY_SINGLE_RESPONSE = 88, + SMSG_ITEM_QUERY_MULTIPLE_RESPONSE = 89, + CMSG_PAGE_TEXT_QUERY = 90, + SMSG_PAGE_TEXT_QUERY_RESPONSE = 91, + CMSG_QUEST_QUERY = 92, + SMSG_QUEST_QUERY_RESPONSE = 93, + CMSG_GAMEOBJECT_QUERY = 94, + SMSG_GAMEOBJECT_QUERY_RESPONSE = 95, + CMSG_CREATURE_QUERY = 96, + SMSG_CREATURE_QUERY_RESPONSE = 97, + CMSG_WHO = 98, + SMSG_WHO = 99, + CMSG_WHOIS = 100, + SMSG_WHOIS = 101, + CMSG_FRIEND_LIST = 102, + SMSG_FRIEND_LIST = 103, + SMSG_FRIEND_STATUS = 104, + CMSG_ADD_FRIEND = 105, + CMSG_DEL_FRIEND = 106, + SMSG_IGNORE_LIST = 107, + CMSG_ADD_IGNORE = 108, + CMSG_DEL_IGNORE = 109, + CMSG_GROUP_INVITE = 110, + SMSG_GROUP_INVITE = 111, + CMSG_GROUP_CANCEL = 112, + SMSG_GROUP_CANCEL = 113, + CMSG_GROUP_ACCEPT = 114, + CMSG_GROUP_DECLINE = 115, + SMSG_GROUP_DECLINE = 116, + CMSG_GROUP_UNINVITE = 117, + CMSG_GROUP_UNINVITE_GUID = 118, + SMSG_GROUP_UNINVITE = 119, + CMSG_GROUP_SET_LEADER = 120, + SMSG_GROUP_SET_LEADER = 121, + CMSG_LOOT_METHOD = 122, + CMSG_GROUP_DISBAND = 123, + SMSG_GROUP_DESTROYED = 124, + SMSG_GROUP_LIST = 125, + SMSG_PARTY_MEMBER_STATS = 126, + SMSG_PARTY_COMMAND_RESULT = 127, + UMSG_UPDATE_GROUP_MEMBERS = 128, + CMSG_GUILD_CREATE = 129, + CMSG_GUILD_INVITE = 130, + SMSG_GUILD_INVITE = 131, + CMSG_GUILD_ACCEPT = 132, + CMSG_GUILD_DECLINE = 133, + SMSG_GUILD_DECLINE = 134, + CMSG_GUILD_INFO = 135, + SMSG_GUILD_INFO = 136, + CMSG_GUILD_ROSTER = 137, + SMSG_GUILD_ROSTER = 138, + CMSG_GUILD_PROMOTE = 139, + CMSG_GUILD_DEMOTE = 140, + CMSG_GUILD_LEAVE = 141, + CMSG_GUILD_REMOVE = 142, + CMSG_GUILD_DISBAND = 143, + CMSG_GUILD_LEADER = 144, + CMSG_GUILD_MOTD = 145, + SMSG_GUILD_EVENT = 146, + SMSG_GUILD_COMMAND_RESULT = 147, + UMSG_UPDATE_GUILD = 148, + CMSG_MESSAGECHAT = 149, + SMSG_MESSAGECHAT = 150, + CMSG_JOIN_CHANNEL = 151, + CMSG_LEAVE_CHANNEL = 152, + SMSG_CHANNEL_NOTIFY = 153, + CMSG_CHANNEL_LIST = 154, + SMSG_CHANNEL_LIST = 155, + CMSG_CHANNEL_PASSWORD = 156, + CMSG_CHANNEL_SET_OWNER = 157, + CMSG_CHANNEL_OWNER = 158, + CMSG_CHANNEL_MODERATOR = 159, + CMSG_CHANNEL_UNMODERATOR = 160, + CMSG_CHANNEL_MUTE = 161, + CMSG_CHANNEL_UNMUTE = 162, + CMSG_CHANNEL_INVITE = 163, + CMSG_CHANNEL_KICK = 164, + CMSG_CHANNEL_BAN = 165, + CMSG_CHANNEL_UNBAN = 166, + CMSG_CHANNEL_ANNOUNCEMENTS = 167, + CMSG_CHANNEL_MODERATE = 168, + SMSG_UPDATE_OBJECT = 169, + SMSG_DESTROY_OBJECT = 170, + CMSG_USE_ITEM = 171, + CMSG_OPEN_ITEM = 172, + CMSG_READ_ITEM = 173, + SMSG_READ_ITEM_OK = 174, + SMSG_READ_ITEM_FAILED = 175, + SMSG_ITEM_COOLDOWN = 176, + CMSG_GAMEOBJ_USE = 177, + CMSG_GAMEOBJ_CHAIR_USE_OBSOLETE = 178, + SMSG_GAMEOBJECT_CUSTOM_ANIM = 179, + CMSG_AREATRIGGER = 180, + MSG_MOVE_START_FORWARD = 181, + MSG_MOVE_START_BACKWARD = 182, + MSG_MOVE_STOP = 183, + MSG_MOVE_START_STRAFE_LEFT = 184, + MSG_MOVE_START_STRAFE_RIGHT = 185, + MSG_MOVE_STOP_STRAFE = 186, + MSG_MOVE_JUMP = 187, + MSG_MOVE_START_TURN_LEFT = 188, + MSG_MOVE_START_TURN_RIGHT = 189, + MSG_MOVE_STOP_TURN = 190, + MSG_MOVE_START_PITCH_UP = 191, + MSG_MOVE_START_PITCH_DOWN = 192, + MSG_MOVE_STOP_PITCH = 193, + MSG_MOVE_SET_RUN_MODE = 194, + MSG_MOVE_SET_WALK_MODE = 195, + MSG_MOVE_TOGGLE_LOGGING = 196, + MSG_MOVE_TELEPORT = 197, + MSG_MOVE_TELEPORT_CHEAT = 198, + MSG_MOVE_TELEPORT_ACK = 199, + MSG_MOVE_TOGGLE_FALL_LOGGING = 200, + MSG_MOVE_FALL_LAND = 201, + MSG_MOVE_START_SWIM = 202, + MSG_MOVE_STOP_SWIM = 203, + MSG_MOVE_SET_RUN_SPEED_CHEAT = 204, + MSG_MOVE_SET_RUN_SPEED = 205, + MSG_MOVE_SET_RUN_BACK_SPEED_CHEAT = 206, + MSG_MOVE_SET_RUN_BACK_SPEED = 207, + MSG_MOVE_SET_WALK_SPEED_CHEAT = 208, + MSG_MOVE_SET_WALK_SPEED = 209, + MSG_MOVE_SET_SWIM_SPEED_CHEAT = 210, + MSG_MOVE_SET_SWIM_SPEED = 211, + MSG_MOVE_SET_SWIM_BACK_SPEED_CHEAT = 212, + MSG_MOVE_SET_SWIM_BACK_SPEED = 213, + MSG_MOVE_SET_ALL_SPEED_CHEAT = 214, + MSG_MOVE_SET_TURN_RATE_CHEAT = 215, + MSG_MOVE_SET_TURN_RATE = 216, + MSG_MOVE_TOGGLE_COLLISION_CHEAT = 217, + MSG_MOVE_SET_FACING = 218, + MSG_MOVE_SET_PITCH = 219, + MSG_MOVE_WORLDPORT_ACK = 220, + SMSG_MONSTER_MOVE = 221, + SMSG_MOVE_WATER_WALK = 222, + SMSG_MOVE_LAND_WALK = 223, + MSG_MOVE_SET_RAW_POSITION_ACK = 224, + CMSG_MOVE_SET_RAW_POSITION = 225, + SMSG_FORCE_RUN_SPEED_CHANGE = 226, + CMSG_FORCE_RUN_SPEED_CHANGE_ACK = 227, + SMSG_FORCE_RUN_BACK_SPEED_CHANGE = 228, + CMSG_FORCE_RUN_BACK_SPEED_CHANGE_ACK = 229, + SMSG_FORCE_SWIM_SPEED_CHANGE = 230, + CMSG_FORCE_SWIM_SPEED_CHANGE_ACK = 231, + SMSG_FORCE_MOVE_ROOT = 232, + CMSG_FORCE_MOVE_ROOT_ACK = 233, + SMSG_FORCE_MOVE_UNROOT = 234, + CMSG_FORCE_MOVE_UNROOT_ACK = 235, + MSG_MOVE_ROOT = 236, + MSG_MOVE_UNROOT = 237, + MSG_MOVE_HEARTBEAT = 238, + SMSG_MOVE_KNOCK_BACK = 239, + CMSG_MOVE_KNOCK_BACK_ACK = 240, + MSG_MOVE_KNOCK_BACK = 241, + SMSG_MOVE_FEATHER_FALL = 242, + SMSG_MOVE_NORMAL_FALL = 243, + SMSG_MOVE_SET_HOVER = 244, + SMSG_MOVE_UNSET_HOVER = 245, + CMSG_MOVE_HOVER_ACK = 246, + MSG_MOVE_HOVER = 247, + CMSG_TRIGGER_CINEMATIC_CHEAT = 248, + CMSG_OPENING_CINEMATIC = 249, + SMSG_TRIGGER_CINEMATIC = 250, + CMSG_NEXT_CINEMATIC_CAMERA = 251, + CMSG_COMPLETE_CINEMATIC = 252, + SMSG_TUTORIAL_FLAGS = 253, + CMSG_TUTORIAL_FLAG = 254, + CMSG_TUTORIAL_CLEAR = 255, + CMSG_TUTORIAL_RESET = 256, + CMSG_STANDSTATECHANGE = 257, + CMSG_EMOTE = 258, + SMSG_EMOTE = 259, + CMSG_TEXT_EMOTE = 260, + SMSG_TEXT_EMOTE = 261, + CMSG_AUTOEQUIP_GROUND_ITEM = 262, + CMSG_AUTOSTORE_GROUND_ITEM = 263, + CMSG_AUTOSTORE_LOOT_ITEM = 264, + CMSG_STORE_LOOT_IN_SLOT = 265, + CMSG_AUTOEQUIP_ITEM = 266, + CMSG_AUTOSTORE_BAG_ITEM = 267, + CMSG_SWAP_ITEM = 268, + CMSG_SWAP_INV_ITEM = 269, + CMSG_SPLIT_ITEM = 270, + CMSG_PICKUP_ITEM = 271, + CMSG_DROP_ITEM = 272, + CMSG_DESTROYITEM = 273, + SMSG_INVENTORY_CHANGE_FAILURE = 274, + SMSG_OPEN_CONTAINER = 275, + CMSG_INSPECT = 276, + SMSG_INSPECT = 277, + CMSG_INITIATE_TRADE = 278, + CMSG_BEGIN_TRADE = 279, + CMSG_BUSY_TRADE = 280, + CMSG_IGNORE_TRADE = 281, + CMSG_ACCEPT_TRADE = 282, + CMSG_UNACCEPT_TRADE = 283, + CMSG_CANCEL_TRADE = 284, + CMSG_SET_TRADE_ITEM = 285, + CMSG_CLEAR_TRADE_ITEM = 286, + CMSG_SET_TRADE_GOLD = 287, + SMSG_TRADE_STATUS = 288, + SMSG_TRADE_STATUS_EXTENDED = 289, + SMSG_INITIALIZE_FACTIONS = 290, + SMSG_SET_FACTION_VISIBLE = 291, + SMSG_SET_FACTION_STANDING = 292, + CMSG_SET_FACTION_ATWAR = 293, + CMSG_SET_FACTION_CHEAT = 294, + SMSG_SET_PROFICIENCY = 295, + CMSG_SET_ACTION_BUTTON = 296, + SMSG_ACTION_BUTTONS = 297, + SMSG_INITIAL_SPELLS = 298, + SMSG_LEARNED_SPELL = 299, + SMSG_SUPERCEDED_SPELL = 300, + CMSG_NEW_SPELL_SLOT = 301, + CMSG_CAST_SPELL = 302, + CMSG_CANCEL_CAST = 303, + SMSG_CAST_RESULT = 304, + SMSG_SPELL_START = 305, + SMSG_SPELL_GO = 306, + SMSG_SPELL_FAILURE = 307, + SMSG_SPELL_COOLDOWN = 308, + SMSG_COOLDOWN_EVENT = 309, + CMSG_CANCEL_AURA = 310, + SMSG_UPDATE_AURA_DURATION = 311, + SMSG_PET_CAST_FAILED = 312, // Your pet is in combat + MSG_CHANNEL_START = 313, + MSG_CHANNEL_UPDATE = 314, + CMSG_CANCEL_CHANNELLING = 315, + SMSG_AI_REACTION = 316, // may be monser attack sound? + CMSG_SET_SELECTION = 317, + CMSG_SET_TARGET_OBSOLETE = 318, + CMSG_UNUSED = 319, + CMSG_UNUSED2 = 320, + CMSG_ATTACKSWING = 321, + CMSG_ATTACKSTOP = 322, + SMSG_ATTACKSTART = 323, + SMSG_ATTACKSTOP = 324, + SMSG_ATTACKSWING_NOTINRANGE = 325, + SMSG_ATTACKSWING_BADFACING = 326, + SMSG_ATTACKSWING_NOTSTANDING = 327, + SMSG_ATTACKSWING_DEADTARGET = 328, + SMSG_ATTACKSWING_CANT_ATTACK = 329, + SMSG_ATTACKERSTATEUPDATE = 330, + SMSG_VICTIMSTATEUPDATE_OBSOLETE = 331, + SMSG_DAMAGE_DONE_OBSOLETE = 332, + SMSG_DAMAGE_TAKEN_OBSOLETE = 333, + SMSG_CANCEL_COMBAT = 334, + SMSG_PLAYER_COMBAT_XP_GAIN_OBSOLETE = 335, + SMSG_HEALSPELL_ON_PLAYER_OBSOLETE = 336, + SMSG_HEALSPELL_ON_PLAYERS_PET_OBSOLETE = 337, + CMSG_SHEATHE_OBSOLETE = 338, + CMSG_SAVE_PLAYER = 339, + CMSG_SETDEATHBINDPOINT = 340, + SMSG_BINDPOINTUPDATE = 341, + CMSG_GETDEATHBINDZONE = 342, + SMSG_BINDZONEREPLY = 343, + SMSG_PLAYERBOUND = 344, + SMSG_DEATH_NOTIFY_OBSOLETE = 345, + CMSG_REPOP_REQUEST = 346, + SMSG_RESURRECT_REQUEST = 347, + CMSG_RESURRECT_RESPONSE = 348, + CMSG_LOOT = 349, + CMSG_LOOT_MONEY = 350, + CMSG_LOOT_RELEASE = 351, + SMSG_LOOT_RESPONSE = 352, + SMSG_LOOT_RELEASE_RESPONSE = 353, + SMSG_LOOT_REMOVED = 354, + SMSG_LOOT_MONEY_NOTIFY = 355, + SMSG_LOOT_ITEM_NOTIFY = 356, + SMSG_LOOT_CLEAR_MONEY = 357, + SMSG_ITEM_PUSH_RESULT = 358, + SMSG_DUEL_REQUESTED = 359, + SMSG_DUEL_OUTOFBOUNDS = 360, + SMSG_DUEL_INBOUNDS = 361, + SMSG_DUEL_COMPLETE = 362, + SMSG_DUEL_WINNER = 363, + CMSG_DUEL_ACCEPTED = 364, + CMSG_DUEL_CANCELLED = 365, + SMSG_MOUNTRESULT = 366, // 0 - can't mount that unit, 1 - mount too far away, 2 - already mounted, 3 - that unit can't be mounted, 4 - that mount is not our pet, 5 - unknown mount error, 6 - can't mount while looting, 7 - cant mount because your race, 8 - shapeshifted, 9 - you dismount before continuing + SMSG_DISMOUNTRESULT = 367, // 0 - int err, don't have pet to dismount, 1 - not mounted, 2 - int err, dismounting a non-pet + SMSG_PUREMOUNT_CANCELLED_OBSOLETE = 368, + CMSG_MOUNTSPECIAL_ANIM = 369, + SMSG_MOUNTSPECIAL_ANIM = 370, + SMSG_PET_TAME_FAILURE = 371, // uint32: 0 - Unknown taming error, 1 - Creature not found, 2 - too many pets, 3 - creature already controlled, 4 - creature not tameable, 5 - have active summon, 6 - can't tame, 7 - don't have pet to summon, 8 - internal pet error, 9 - high level, 10 - your pet is dead, 11 - your pet is not dead + CMSG_PET_SET_ACTION = 372, + CMSG_PET_ACTION = 373, + CMSG_PET_ABANDON = 374, + CMSG_PET_RENAME = 375, + SMSG_PET_NAME_INVALID = 376, // Error, invalid name entered. + SMSG_PET_SPELLS = 377, + SMSG_PET_MODE = 378, // uint64 pet_guid + uint32 flags? + CMSG_GOSSIP_HELLO = 379, + CMSG_GOSSIP_SELECT_OPTION = 380, + SMSG_GOSSIP_MESSAGE = 381, + SMSG_GOSSIP_COMPLETE = 382, + CMSG_NPC_TEXT_QUERY = 383, + SMSG_NPC_TEXT_UPDATE = 384, + SMSG_NPC_WONT_TALK = 385, + CMSG_QUESTGIVER_STATUS_QUERY = 386, + SMSG_QUESTGIVER_STATUS = 387, + CMSG_QUESTGIVER_HELLO = 388, + SMSG_QUESTGIVER_QUEST_LIST = 389, + CMSG_QUESTGIVER_QUERY_QUEST = 390, + CMSG_QUESTGIVER_QUEST_AUTOLAUNCH = 391, + SMSG_QUESTGIVER_QUEST_DETAILS = 392, + CMSG_QUESTGIVER_ACCEPT_QUEST = 393, + CMSG_QUESTGIVER_COMPLETE_QUEST = 394, + SMSG_QUESTGIVER_REQUEST_ITEMS = 395, + CMSG_QUESTGIVER_REQUEST_REWARD = 396, + SMSG_QUESTGIVER_OFFER_REWARD = 397, + CMSG_QUESTGIVER_CHOOSE_REWARD = 398, + SMSG_QUESTGIVER_QUEST_INVALID = 399, + CMSG_QUESTGIVER_CANCEL = 400, + SMSG_QUESTGIVER_QUEST_COMPLETE = 401, + SMSG_QUESTGIVER_QUEST_FAILED = 402, + CMSG_QUESTLOG_SWAP_QUEST = 403, + CMSG_QUESTLOG_REMOVE_QUEST = 404, + SMSG_QUESTLOG_FULL = 405, + SMSG_QUESTUPDATE_FAILED = 406, + SMSG_QUESTUPDATE_FAILEDTIMER = 407, + SMSG_QUESTUPDATE_COMPLETE = 408, + SMSG_QUESTUPDATE_ADD_KILL = 409, + SMSG_QUESTUPDATE_ADD_ITEM = 410, + CMSG_QUEST_CONFIRM_ACCEPT = 411, + SMSG_QUEST_CONFIRM_ACCEPT = 412, + CMSG_PUSHQUESTTOPARTY = 413, + CMSG_LIST_INVENTORY = 414, + SMSG_LIST_INVENTORY = 415, + CMSG_SELL_ITEM = 416, + SMSG_SELL_ITEM = 417, + CMSG_BUY_ITEM = 418, + CMSG_BUY_ITEM_IN_SLOT = 419, + SMSG_BUY_ITEM = 420, + SMSG_BUY_FAILED = 421, + CMSG_TAXICLEARALLNODES = 422, + CMSG_TAXIENABLEALLNODES = 423, + CMSG_TAXISHOWNODES = 424, + SMSG_SHOWTAXINODES = 425, + CMSG_TAXINODE_STATUS_QUERY = 426, + SMSG_TAXINODE_STATUS = 427, + CMSG_TAXIQUERYAVAILABLENODES = 428, + CMSG_ACTIVATETAXI = 429, + SMSG_ACTIVATETAXIREPLY = 430, + SMSG_NEW_TAXI_PATH = 431, + CMSG_TRAINER_LIST = 432, + SMSG_TRAINER_LIST = 433, + CMSG_TRAINER_BUY_SPELL = 434, + SMSG_TRAINER_BUY_SUCCEEDED = 435, + SMSG_TRAINER_BUY_FAILED = 436, + CMSG_BINDER_ACTIVATE = 437, + SMSG_PLAYERBINDERROR = 438, // You already bound there. + CMSG_BANKER_ACTIVATE = 439, + SMSG_SHOW_BANK = 440, + CMSG_BUY_BANK_SLOT = 441, + SMSG_BUY_BANK_SLOT_RESULT = 442, + CMSG_PETITION_SHOWLIST = 443, + SMSG_PETITION_SHOWLIST = 444, + CMSG_PETITION_BUY = 445, + CMSG_PETITION_SHOW_SIGNATURES = 446, + SMSG_PETITION_SHOW_SIGNATURES = 447, + CMSG_PETITION_SIGN = 448, + SMSG_PETITION_SIGN_RESULTS = 449, + MSG_PETITION_DECLINE = 450, + CMSG_OFFER_PETITION = 451, + CMSG_TURN_IN_PETITION = 452, + SMSG_TURN_IN_PETITION_RESULTS = 453, + CMSG_PETITION_QUERY = 454, + SMSG_PETITION_QUERY_RESPONSE = 455, + SMSG_FISH_NOT_HOOKED = 456, + SMSG_FISH_ESCAPED = 457, + CMSG_BUG = 458, + SMSG_NOTIFICATION = 459, + CMSG_PLAYED_TIME = 460, + SMSG_PLAYED_TIME = 461, + CMSG_QUERY_TIME = 462, + SMSG_QUERY_TIME_RESPONSE = 463, + SMSG_LOG_XPGAIN = 464, + MSG_SPLIT_MONEY = 465, + CMSG_RECLAIM_CORPSE = 466, + CMSG_WRAP_ITEM = 467, + SMSG_LEVELUP_INFO = 468, + MSG_MINIMAP_PING = 469, + SMSG_RESISTLOG = 470, + SMSG_ENCHANTMENTLOG = 471, + CMSG_SET_SKILL_CHEAT = 472, + SMSG_START_MIRROR_TIMER = 473, + SMSG_PAUSE_MIRROR_TIMER = 474, + SMSG_STOP_MIRROR_TIMER = 475, + CMSG_PING = 476, + SMSG_PONG = 477, + SMSG_CLEAR_COOLDOWN = 478, + SMSG_GAMEOBJECT_PAGETEXT = 479, // uint64 guid + CMSG_SETSHEATHED = 480, + SMSG_COOLDOWN_CHEAT = 481, + SMSG_SPELL_DELAYED = 482, + CMSG_PLAYER_MACRO_OBSOLETE = 483, + SMSG_PLAYER_MACRO_OBSOLETE = 484, + CMSG_GHOST = 485, + CMSG_GM_INVIS = 486, + SMSG_INVALID_PROMOTION_CODE = 487, // Couldn't validate code, please try again. + MSG_GM_BIND_OTHER = 488, + MSG_GM_SUMMON = 489, + SMSG_ITEM_TIME_UPDATE = 490, // uint64 guid + uint32 time + SMSG_ITEM_ENCHANT_TIME_UPDATE = 491, + SMSG_AUTH_CHALLENGE = 492, + CMSG_AUTH_SESSION = 493, + SMSG_AUTH_RESPONSE = 494, + MSG_GM_SHOWLABEL = 495, + MSG_ADD_DYNAMIC_TARGET_OBSOLETE = 496, + MSG_SAVE_GUILD_EMBLEM = 497, + MSG_TABARDVENDOR_ACTIVATE = 498, + SMSG_PLAY_SPELL_VISUAL = 499, + CMSG_ZONEUPDATE = 500, + SMSG_PARTYKILLLOG = 501, + SMSG_COMPRESSED_UPDATE_OBJECT = 502, + SMSG_OBSOLETE = 503, + SMSG_EXPLORATION_EXPERIENCE = 504, + CMSG_GM_SET_SECURITY_GROUP = 505, + CMSG_GM_NUKE = 506, + MSG_RANDOM_ROLL = 507, + SMSG_ENVIRONMENTALDAMAGELOG = 508, + CMSG_RWHOIS = 509, + SMSG_RWHOIS = 510, + MSG_LOOKING_FOR_GROUP = 511, + CMSG_SET_LOOKING_FOR_GROUP = 512, + CMSG_UNLEARN_SPELL = 513, + CMSG_UNLEARN_SKILL = 514, + SMSG_REMOVED_SPELL = 515, + CMSG_DECHARGE = 516, + CMSG_GMTICKET_CREATE = 517, + SMSG_GMTICKET_CREATE = 518, + CMSG_GMTICKET_UPDATETEXT = 519, + SMSG_GMTICKET_UPDATETEXT = 520, + SMSG_ACCOUNT_DATA_MD5 = 521, + CMSG_REQUEST_ACCOUNT_DATA = 522, + CMSG_UPDATE_ACCOUNT_DATA = 523, + SMSG_UPDATE_ACCOUNT_DATA = 524, + SMSG_CLEAR_FAR_SIGHT_IMMEDIATE = 525, + SMSG_POWERGAINLOG_OBSOLETE = 526, + CMSG_GM_TEACH = 527, + CMSG_GM_CREATE_ITEM_TARGET = 528, + CMSG_GMTICKET_GETTICKET = 529, + SMSG_GMTICKET_GETTICKET = 530, + CMSG_UNLEARN_TALENTS = 531, + SMSG_GAMEOBJECT_SPAWN_ANIM = 532, + SMSG_GAMEOBJECT_DESPAWN_ANIM = 533, + MSG_CORPSE_QUERY = 534, + CMSG_GMTICKET_DELETETICKET = 535, + SMSG_GMTICKET_DELETETICKET = 536, + SMSG_CHAT_WRONG_FACTION = 537, // You can only whisper to the members of your alliance. + CMSG_GMTICKET_SYSTEMSTATUS = 538, + SMSG_GMTICKET_SYSTEMSTATUS = 539, + CMSG_SPIRIT_HEALER_ACTIVATE = 540, + CMSG_SET_STAT_CHEAT = 541, + SMSG_SET_REST_START = 542, + CMSG_SKILL_BUY_STEP = 543, + CMSG_SKILL_BUY_RANK = 544, + CMSG_XP_CHEAT = 545, + SMSG_SPIRIT_HEALER_CONFIRM = 546, + CMSG_CHARACTER_POINT_CHEAT = 547, + SMSG_GOSSIP_POI = 548, + CMSG_CHAT_IGNORED = 549, + CMSG_GM_VISION = 550, + CMSG_SERVER_COMMAND = 551, + CMSG_GM_SILENCE = 552, + CMSG_GM_REVEALTO = 553, + CMSG_GM_RESURRECT = 554, + CMSG_GM_SUMMONMOB = 555, + CMSG_GM_MOVECORPSE = 556, + CMSG_GM_FREEZE = 557, + CMSG_GM_UBERINVIS = 558, + CMSG_GM_REQUEST_PLAYER_INFO = 559, + SMSG_GM_PLAYER_INFO = 560, + CMSG_GUILD_RANK = 561, + CMSG_GUILD_ADD_RANK = 562, + CMSG_GUILD_DEL_RANK = 563, + CMSG_GUILD_SET_PUBLIC_NOTE = 564, + CMSG_GUILD_SET_OFFICER_NOTE = 565, + SMSG_LOGIN_VERIFY_WORLD = 566, + CMSG_CLEAR_EXPLORATION = 567, + CMSG_SEND_MAIL = 568, + SMSG_SEND_MAIL_RESULT = 569, + CMSG_GET_MAIL_LIST = 570, + SMSG_MAIL_LIST_RESULT = 571, + CMSG_BATTLEFIELD_LIST = 572, + SMSG_BATTLEFIELD_LIST = 573, + CMSG_BATTLEFIELD_JOIN = 574, + SMSG_BATTLEFIELD_WIN = 575, + SMSG_BATTLEFIELD_LOSE = 576, + CMSG_TAXICLEARNODE = 577, + CMSG_TAXIENABLENODE = 578, + CMSG_ITEM_TEXT_QUERY = 579, + SMSG_ITEM_TEXT_QUERY_RESPONSE = 580, + CMSG_MAIL_TAKE_MONEY = 581, + CMSG_MAIL_TAKE_ITEM = 582, + CMSG_MAIL_MARK_AS_READ = 583, + CMSG_MAIL_RETURN_TO_SENDER = 584, + CMSG_MAIL_DELETE = 585, + CMSG_MAIL_CREATE_TEXT_ITEM = 586, + SMSG_SPELLLOGMISS = 587, + SMSG_SPELLLOGEXECUTE = 588, + SMSG_DEBUGAURAPROC = 589, + SMSG_PERIODICAURALOG = 590, + SMSG_SPELLDAMAGESHIELD = 591, + SMSG_SPELLNONMELEEDAMAGELOG = 592, + CMSG_LEARN_TALENT = 593, + SMSG_RESURRECT_FAILED = 594, + CMSG_TOGGLE_PVP = 595, + SMSG_ZONE_UNDER_ATTACK = 596, + MSG_AUCTION_HELLO = 597, + CMSG_AUCTION_SELL_ITEM = 598, + CMSG_AUCTION_REMOVE_ITEM = 599, + CMSG_AUCTION_LIST_ITEMS = 600, + CMSG_AUCTION_LIST_OWNER_ITEMS = 601, + CMSG_AUCTION_PLACE_BID = 602, + SMSG_AUCTION_COMMAND_RESULT = 603, + SMSG_AUCTION_LIST_RESULT = 604, + SMSG_AUCTION_OWNER_LIST_RESULT = 605, + SMSG_AUCTION_BIDDER_NOTIFICATION = 606, + SMSG_AUCTION_OWNER_NOTIFICATION = 607, + SMSG_PROCRESIST = 608, + SMSG_STANDSTATE_CHANGE_FAILURE = 609, + SMSG_DISPEL_FAILED = 610, + SMSG_SPELLORDAMAGE_IMMUNE = 611, + CMSG_AUCTION_LIST_BIDDER_ITEMS = 612, + SMSG_AUCTION_BIDDER_LIST_RESULT = 613, + SMSG_SET_FLAT_SPELL_MODIFIER = 614, + SMSG_SET_PCT_SPELL_MODIFIER = 615, + CMSG_SET_AMMO = 616, + SMSG_CORPSE_RECLAIM_DELAY = 617, + CMSG_SET_ACTIVE_MOVER = 618, + CMSG_PET_CANCEL_AURA = 619, + CMSG_PLAYER_AI_CHEAT = 620, + CMSG_CANCEL_AUTO_REPEAT_SPELL = 621, + MSG_GM_ACCOUNT_ONLINE = 622, + MSG_LIST_STABLED_PETS = 623, + CMSG_STABLE_PET = 624, + CMSG_UNSTABLE_PET = 625, + CMSG_BUY_STABLE_SLOT = 626, + SMSG_STABLE_RESULT = 627, + CMSG_STABLE_REVIVE_PET = 628, + CMSG_STABLE_SWAP_PET = 629, + MSG_QUEST_PUSH_RESULT = 630, + SMSG_PLAY_MUSIC = 631, + SMSG_PLAY_OBJECT_SOUND = 632, + CMSG_REQUEST_PET_INFO = 633, + CMSG_FAR_SIGHT = 634, + SMSG_SPELLDISPELLOG = 635, + SMSG_DAMAGE_CALC_LOG = 636, + CMSG_ENABLE_DAMAGE_LOG = 637, + CMSG_GROUP_CHANGE_SUB_GROUP = 638, + CMSG_REQUEST_PARTY_MEMBER_STATS = 639, + CMSG_GROUP_SWAP_SUB_GROUP = 640, + CMSG_RESET_FACTION_CHEAT = 641, + CMSG_AUTOSTORE_BANK_ITEM = 642, + CMSG_AUTOBANK_ITEM = 643, + MSG_QUERY_NEXT_MAIL_TIME = 644, + SMSG_RECEIVED_MAIL = 645, + SMSG_RAID_GROUP_ONLY = 646, // You are not in this instance group. You will be teleported to %s in %u Minites. uint32 time(milliseconds)+uint32 unk + CMSG_SET_DURABILITY_CHEAT = 647, + CMSG_SET_PVP_RANK_CHEAT = 648, + CMSG_ADD_PVP_MEDAL_CHEAT = 649, + CMSG_DEL_PVP_MEDAL_CHEAT = 650, + CMSG_SET_PVP_TITLE = 651, + SMSG_PVP_CREDIT = 652, + SMSG_AUCTION_REMOVED_NOTIFICATION = 653, + CMSG_GROUP_RAID_CONVERT = 654, + CMSG_GROUP_ASSISTANT = 655, + CMSG_BUYBACK_ITEM = 656, + SMSG_SERVER_MESSAGE = 657, + CMSG_MEETINGSTONE_JOIN = 658, + CMSG_MEETINGSTONE_LEAVE = 659, + CMSG_MEETINGSTONE_CHEAT = 660, + SMSG_MEETINGSTONE_SETQUEUE = 661, // You have left the queue to join a party for %s. + CMSG_MEETINGSTONE_INFO = 662, + SMSG_MEETINGSTONE_COMPLETE = 663, // Your group is complete, you have left the LFG matchmaking system. + SMSG_MEETINGSTONE_IN_PROGRESS = 664, // You still seeking more members through LFG matchmaking system., empty? + SMSG_MEETINGSTONE_MEMBER_ADDED = 665, // %s has been added to the group by the LFG matchmaking system. + CMSG_GMTICKETSYSTEM_TOGGLE = 666, + CMSG_CANCEL_GROWTH_AURA = 667, + SMSG_CANCEL_AUTO_REPEAT = 668, + SMSG_STANDSTATE_CHANGE_ACK = 669, + SMSG_LOOT_ALL_PASSED = 670, + SMSG_LOOT_ROLL_WON = 671, + CMSG_LOOT_ROLL = 672, + SMSG_LOOT_START_ROLL = 673, + SMSG_LOOT_ROLL = 674, + CMSG_LOOT_MASTER_GIVE = 675, + SMSG_LOOT_MASTER_LIST = 676, + SMSG_SET_FORCED_REACTIONS = 677, + SMSG_SPELL_FAILED_OTHER = 678, + SMSG_GAMEOBJECT_RESET_STATE = 679, // uint64 guid + CMSG_REPAIR_ITEM = 680, + SMSG_CHAT_PLAYER_NOT_FOUND = 681, + MSG_TALENT_WIPE_CONFIRM = 682, + SMSG_SUMMON_REQUEST = 683, // uint64 guid + uint32 area/zoneid + uint32 time(milliseconds?) + CMSG_SUMMON_RESPONSE = 684, + MSG_MOVE_TOGGLE_GRAVITY_CHEAT = 685, + SMSG_MONSTER_MOVE_TRANSPORT = 686, + SMSG_PET_BROKEN = 687, // Your pet has run away (:D) + MSG_MOVE_FEATHER_FALL = 688, + MSG_MOVE_WATER_WALK = 689, + CMSG_SERVER_BROADCAST = 690, + CMSG_SELF_RES = 691, // only if PLAYER_SELF_RES_SPELL field != 0 + SMSG_FEIGN_DEATH_RESISTED = 692, // Resisted + CMSG_RUN_SCRIPT = 693, + SMSG_SCRIPT_MESSAGE = 694, + SMSG_DUEL_COUNTDOWN = 695, + SMSG_AREA_TRIGGER_MESSAGE = 696, + CMSG_TOGGLE_HELM = 697, + CMSG_TOGGLE_CLOAK = 698, + SMSG_MEETINGSTONE_JOINFAILED = 699, // 1 - must be party leader, 3 - can't use while in raid + SMSG_PLAYER_SKINNED = 700, // uint8 0x00 Insignia taken - You can only resurrect at the graveyard + SMSG_DURABILITY_DAMAGE_DEATH = 701, + CMSG_SET_EXPLORATION = 702, + CMSG_SET_ACTIONBAR_TOGGLES = 703, + UMSG_DELETE_GUILD_CHARTER = 704, + MSG_PETITION_RENAME = 705, + SMSG_INIT_WORLD_STATES = 706, + SMSG_UPDATE_WORLD_STATE = 707, + CMSG_ITEM_NAME_QUERY = 708, + SMSG_ITEM_NAME_QUERY_RESPONSE = 709, + SMSG_PET_ACTION_FEEDBACK = 710, // uint8 0x04 - unk, 0x01 - pet dead, 0x2 - no target, 0x3 can't attack + CMSG_CHAR_RENAME = 711, + SMSG_CHAR_RENAME = 712, + CMSG_MOVE_SPLINE_DONE = 713, + CMSG_MOVE_FALL_RESET = 714, + SMSG_INSTANCE_SAVE_CREATED = 715, // You are now saved to this instance + SMSG_RAID_INSTANCE_INFO = 716, + CMSG_REQUEST_RAID_INFO = 717, + CMSG_MOVE_TIME_SKIPPED = 718, + CMSG_MOVE_FEATHER_FALL_ACK = 719, + CMSG_MOVE_WATER_WALK_ACK = 720, + CMSG_MOVE_NOT_ACTIVE_MOVER = 721, + SMSG_PLAY_SOUND = 722, + CMSG_BATTLEFIELD_STATUS = 723, + SMSG_BATTLEFIELD_STATUS = 724, + CMSG_BATTLEFIELD_PORT = 725, + MSG_INSPECT_HONOR_STATS = 726, + CMSG_BATTLEMASTER_HELLO = 727, + CMSG_MOVE_START_SWIM_CHEAT = 728, + CMSG_MOVE_STOP_SWIM_CHEAT = 729, + SMSG_FORCE_WALK_SPEED_CHANGE = 730, + CMSG_FORCE_WALK_SPEED_CHANGE_ACK = 731, + SMSG_FORCE_SWIM_BACK_SPEED_CHANGE = 732, + CMSG_FORCE_SWIM_BACK_SPEED_CHANGE_ACK = 733, + SMSG_FORCE_TURN_RATE_CHANGE = 734, + CMSG_FORCE_TURN_RATE_CHANGE_ACK = 735, + MSG_PVP_LOG_DATA = 736, + CMSG_LEAVE_BATTLEFIELD = 737, + CMSG_AREA_SPIRIT_HEALER_QUERY = 738, + CMSG_AREA_SPIRIT_HEALER_QUEUE = 739, + SMSG_AREA_SPIRIT_HEALER_TIME = 740, // uint64 guid+uint32 time + CMSG_GM_UNTEACH = 741, + SMSG_WARDEN_DATA = 742, + CMSG_WARDEN_DATA = 743, + SMSG_GROUP_JOINED_BATTLEGROUND = 744, // uint32 0xfffffffc, probably different error messages... + MSG_BATTLEGROUND_PLAYER_POSITIONS = 745, + CMSG_PET_STOP_ATTACK = 746, + SMSG_BINDER_CONFIRM = 747, + SMSG_BATTLEGROUND_PLAYER_JOINED = 748, + SMSG_BATTLEGROUND_PLAYER_LEFT = 749, + CMSG_BATTLEMASTER_JOIN = 750, + SMSG_ADDON_INFO = 751, + CMSG_PET_UNLEARN = 752, + SMSG_PET_UNLEARN_CONFIRM = 753, + SMSG_PARTY_MEMBER_STATS_FULL = 754, + CMSG_PET_SPELL_AUTOCAST = 755, + SMSG_WEATHER = 756, + SMSG_PLAY_TIME_WARNING = 757, + SMSG_MINIGAME_SETUP = 758, + SMSG_MINIGAME_STATE = 759, + CMSG_MINIGAME_MOVE = 760, + SMSG_MINIGAME_MOVE_FAILED = 761, + SMSG_INSTANCE_RESET_SCHEDULED = 762, // WARNING! %s is scheduled to reset in %u minutes! and other messages... + SMSG_COMPRESSED_MOVE = 763, + CMSG_GUILD_CHANGEINFO = 764, + SMSG_TRIAL_RESTRICTED = 765, // Trial accounts cannot send unlimited tells, you must wait before you can send tells to more players. + SMSG_SET_MOVE_SPEED = 766, // GUID + float speed, move speed, except swim/turn/fly + SMSG_SET_RUN_BACK_SPEED = 767, // GUID + float speed, run back speed + SMSG_SET_SWIM_SPEED = 768, // GUID + float speed, swim and swim back speed + // 769 + SMSG_SET_SWIM_BACK_SPEED = 770, // swim back speed + SMSG_SET_TURN_RATE = 771, // turn rate (note: client crashes if fly mode enabled, and turn rate = 0) + SMSG_UNKNOWN_772 = 772, // packed GUID + SMSG_UNKNOWN_773 = 773, // set movement flag 0x20000000 (safe fall) + SMSG_UNKNOWN_774 = 774, // stop effect of 773 opcode + SMSG_UNKNOWN_775 = 775, // movement related, looks like hover, movement flag 0x40000000, we can't jump if we are lands + SMSG_UNKNOWN_776 = 776, // stop effect of 775 opcode + SMSG_MOVE_SET_WATERWALK = 777, // packed GUID, set movement flag 0x10000000, waterwalking... + SMSG_MOVE_STOP_WATERWALK = 778, // packed GUID, stop effect of 777 opcode + SMSG_UNKNOWN_779 = 779, // packed guid, change animation to swim/fly like + SMSG_UNKNOWN_780 = 780, // packed guid + SMSG_MOVE_STOP_WALK = 781, // packed guid, remove 0x100 movement flag (walk) + SMSG_MOVE_START_WALK = 782, // set 0x100 movement flag (walk) + // 783 + // 784 + // 785 + CMSG_ACTIVATETAXI_FAR = 786, + // 787 causes client crash + // 788 + // 789 + // 790 + CMSG_FIELD_WATCHED_FACTION_INACTIVE = 791, + CMSG_FIELD_WATCHED_FACTION_SHOW_BAR = 792, + SMSG_UNKNOWN_793 = 793, // packed guid + uint32 unk + SMSG_UNKNOWN_794 = 794, // packed guid, movement related, set 0x1000 movement flag, all speed to 0, except turn rate + // 795 + SMSG_UNKNOWN_796 = 796, // uint64, guid, chat related? + CMSG_RESET_INSTANCES = 797, // reset instances, empty + SMSG_RESET_INSTANCES_SUCCESS = 798, // uint32 mapid, chat message: %s has been reset. + SMSG_RESET_INSTANCES_FAILED = 799, // uint32 reason, uint32 mapid + SMSG_UNKNOWN_800 = 800, // uint32 mapid, instance related (save?) + MSG_RAID_ICON_TARGET = 801, // uint8+uint8+uint64 guid or only uint8(0x01) + MSG_RAID_READY_CHECK = 802, // uint64+uint8 + // 803 + SMSG_PET_ACTION_SOUND = 804, // GUID + uint32, looks like SMSG_AI_REACTION (pet action sound?) + SMSG_PET_DISMISS_SOUND = 805, // uint32 unk + x, y, z (pet dismiss sound?) + // 806 + // 807 + SMSG_GM_SURVEY_REQUEST = 808, // uint32, 1 - causes client get ticket request, 2 - hide, 3 - show + MSG_SET_DUNGEON_DIFFICULTY = 809, // uint32+uint32+uint32 + CMSG_GM_SURVEY_RESULTS = 810, // script function named GMSurveySubmit() + SMSG_UNKNOWN_811 = 811, // uint32, 0x0, SMSG_INSTANCE_RESET_ACTIVATE ? + // 812 + // 813 + // 814 + SMSG_SPELL_INSTA_KILL_SELF = 815, // spell related, uint64 guid + spellid (You are killed by %s(spell_name)) + SMSG_UNKNOWN_816 = 816, // spell related, uint64 guid + spellid + uint32 count + for(count) uint64 guid (target?) + // 817 + SMSG_ANTISPAM = 818, // 2.0.8, received before server MOTD, strange regexp sequence, looks like anti spam filter for chat messages... + // 819 + // 820 + // 821 + // 822 + // 823 + // 824 + // 825 + SMSG_OUTDOORPVP_NOTIFY = 826, // looks like chat packets + // 827 + // 828 + SMSG_MOTD = 829, // server MOTD message, uint32 + message + // 830 + // 831 + // 832 + SMSG_UNKNOWN_833 = 833, // teleport/movement opcode + SMSG_UNKNOWN_834 = 834, // teleport/movement opcode + SMSG_FLY_MODE_START = 835, // packed guid + uint32, start fly + SMSG_FLY_MODE_STOP = 836, // packed guid + uint32, stop fly + CMSG_MOVE_FLY_MODE_CHANGE_ACK = 837, // movement related, fly on/off ack + MSG_MOVE_FLY_STATE_CHANGE = 838, // movement related, fly start/stop(land) ack, may be MSG + CMSG_SOCKET_ITEM = 839, // click on "Socket Gems" button in Jewelcrafting UI, contains uint64 item guid + 3 x uint64 gems guid's + // 840, CMSG? + SMSG_ARENA_TEAM_COMMAND_RESULT = 841, // uint32 command, name1, name2, uint32 errorcode + // 842 + CMSG_ARENA_TEAM_QUERY = 843, + SMSG_ARENA_TEAM_QUERY_RESPONSE = 844, + CMSG_ARENA_TEAM_ROSTER = 845, + SMSG_ARENA_TEAM_ROSTER = 846, + CMSG_ARENA_TEAM_INVITE_BYNAME = 847, + SMSG_ARENA_TEAM_INVITE = 848, + CMSG_ARENA_TEAM_ACCEPT = 849, + CMSG_ARENA_TEAM_DECLINE = 850, + CMSG_ARENA_TEAM_LEAVE = 851, + CMSG_ARENA_TEAM_UNINVITE_BYNAME = 852, + CMSG_ARENA_TEAM_DISBAND = 853, + CMSG_ARENA_TEAM_SET_LEADER_BYNAME = 854, // also must be demote opcode... + SMSG_ARENA_TEAM_EVENT = 855, // arena team event + CMSG_ARENAMASTER_JOIN = 856, + MSG_MOVE_START_FLY_UP = 857, // movement related, fly up, possible MSG + MSG_MOVE_STOP_FLY_UP = 858, // movement related, stop fly up, possible MSG + SMSG_ARENA_TEAM_STATS = 859, + CMSG_LFG_SET_AUTOJOIN = 860, + CMSG_LFG_UNSET_AUTOJOIN = 861, + CMSG_LFM_SET_AUTOADD = 862, + CMSG_LFM_UNSET_AUTOADD = 863, + CMSG_LFG_INVITE_ACCEPT = 864, + CMSG_LFG_INVITE_CANCEL = 865, + // 866, CMSG? + CMSG_LOOKING_FOR_GROUP_CLEAR = 867, + CMSG_SET_LOOKING_FOR_NONE = 868, + CMSG_SET_LOOKING_FOR_MORE = 869, + CMSG_SET_COMMENTARY = 870, + SMSG_LFG_MATCHMAKING_TIMEDOUT = 871, // Matchmaking timed out. + SMSG_LFG_MATCHMAKING_OTHER_TIMEDOUT = 872, // Matchmaking timed out waiting for other player. + SMSG_LFG_MATCHMAKING_AUTOJOIN_FAILED = 873, // Group no longer available. + SMSG_LFG_MATCHMAKING_AUTOJOIN_FAILED_NO_PLAYER = 874, // Matched Player(s) have gone offline. + // 875 + SMSG_LFG_876 = 876, // LFM eye, in progress, uint16+uint32+uint8?, 3 x uint8(0x0) + SMSG_LFG_877 = 877, // cause client send CMSG_SET_LOOKING_FOR_GROUP, uint32+uint8? + SMSG_LFG_878 = 878, // cause client send CMSG_SET_LOOKING_FOR_GROUP + SMSG_LFG_879 = 879, // LFG eye, cause client send CMSG_SET_LOOKING_FOR_GROUP + SMSG_LFG_MATCHMAKING_PENDING_INVITE = 880, // The LFG system has matched you to a group for %s. + SMSG_LFG_MATCHMAKING_PENDING_MATCH = 881, // The LFG system is waiting to complete match for %s. + // 882 + SMSG_CHANGE_TITLE = 883, // uint32 title_id, causes message and visual effect + CMSG_CHOOSE_TITLE = 884, // uint32 title_id + CMSG_DISMOUNT = 885, // /dismount command + SMSG_ARENA_NO_TEAM = 886, // uint32(0) + team type + MSG_INSPECT_ARENA_STATS = 887, + SMSG_SH_POSITION = 888, // spirit healer position, map/x/y/z, at player death... + CMSG_CANCEL_TEMP_ITEM_ENCHANTMENT = 889, // cancel temporary item enchantment + // 890 + // 891 + // 892 + // 893 + MSG_MOVE_SET_FLY_SPEED = 894, // all fly speed, packed guid, uint32 movement_flags, time, x,y,z,o,unk,speed... + // 895 + MSG_MOVE_SET_FLY_BACK_SPEED = 896, + SMSG_FORCE_FLY_SPEED_CHANGE = 897, // packed guid, uint32, speed + CMSG_FORCE_FLY_SPEED_CHANGE_ACK = 898, + SMSG_FORCE_FLY_BACK_SPEED_CHANGE = 899, + CMSG_FORCE_FLY_BACK_SPEED_CHANGE_ACK = 900, + SMSG_MOVE_SET_FLY_SPEED2 = 901, // same as 894, strange, packed guid+speed + SMSG_MOVE_SET_FLY_BACK_SPEED2 = 902, // same as 896, strange, + // 903 + SMSG_FLIGHT_SPLINE_SYNC = 904, // uint32 + packed_guid + CMSG_SET_TAXI_BENCHMARK_MODE = 905, + // 906 + SMSG_REALM_SPLIT_INFO_RESPONSE = 907, // response to 908 opcode, uint32+uint32+string(date) + CMSG_REALM_SPLIT_INFO_REQUEST = 908, // realm related, uint32, appears at select character screen, uint32 0xFFFFFFFF by default + MSG_MOVE_SHIP_909 = 909, // movement related, transport related(ships) + CMSG_GROUP_PROMOTE = 910, // make main-tank / main-assistant + SMSG_ALREADY_IN_ARENA_TEAM = 911, // %s is already in an arena team of that size (uint64 guid) + SMSG_ALLOW_MOVE = 912, // uint32, allow player movement, value increments every time and reset to 0 after far teleport, used for client-server synchronization + CMSG_ALLOW_MOVE_ACK = 913, // client response to SMSG_ALLOW_MOVE (counter + client time) + // 914 + // 915 + // 916 + // 917 + SMSG_RESET_INSTANCE_FAILED_NOTIFY = 918, // chat message: The party leader has attempted to reset the instance you are in. Please zone out to allow the instance to reset. + SMSG_UNKNOWN_919 = 919, // uint8(0)+uint32(0/1)+uint64(unk/guid) + SMSG_SYSTEM_DISABLED = 920, // notify message: This system is currently disabled. + // 921 + // 922 + // 923 + // 924 + SMSG_SET_COMBO_POINTS = 925, // set combo points + SMSG_VOICE_SESSION = 926, + SMSG_UNKNOWN_927 = 927, // uint64 guid + uint32 + float?, received after leave voice channel + // 928 + // 929 + // 930 + SMSG_SET_AURA_MULTIPLY = 931, // packed_guid + n * (uint8 slot + uint32 spellid + uint32 duration1 + uint32 duration2) + SMSG_SET_AURA_SINGLE = 932, // packed_guid + uint8 slot + uint32 spellid + uint32 duration1 + uint32 duration2 + // 933 + SMSG_CAST_SUCCESS = 934, + MSG_UNKNOWN_935 = 935, // teleport/movement opcode + // 936 + // 937 + SMSG_UNKNOWN_938 = 938, // uint64, uint64, uint32 spellid, uint32, uint32 + // 939 + SMSG_UNKNOWN_940 = 940, // packed guid (received at spell cast) + SMSG_UNKNOWN_941 = 941, // teleport/movement opcode + SMSG_READY_CHECK_ALL_READY = 942, // Everyone is Ready! (message) + CMSG_VOICE_SETTINGS = 943, // uint8 isVoiceEnabled, uint8 isMicrophoneEnabled (id correct for 2.3.0) + SMSG_VOICE_CHAT_PARENTAL_DISABLE_ALL = 944, // Voice chat has been disabled by parental control + // 945 + // 946 + // 947 + CMSG_COMMENTATOR_SET_MODE = 948, + // 949 + CMSG_COMMENTATOR_UPDATE_MAP_INFO = 950, + // 951 + CMSG_COMMENTATOR_UPDATE_PLAYER_INFO = 952, + CMSG_UNKNOWN_953 = 953, // response to 942 opcode + //CMSG_REPORT_SPAM = 954, // now(2.3.0) CMSG_COMPLAINT_CHAT + //SMSG_REPORT_SPAM_RESPONSE = 955, // now(2.3.0) SMSG_COMPLAINT_ADDED + CMSG_COMMENTATOR_EXIT_INSTANCE = 956, // unk uint8 + // 957 + // 958 clear selection? + // 959 + SMSG_UNKNOWN_960 = 960, // uint64 guid, uint32, uint32 (client sedn CMSG_ITEM_QUERY_SINGLE) + // 961 + // 962 + //SMSG_DISCONNECT_CLIENT = 963, // really?? not + // 964 + // 965 + CMSG_COMPLAINT_CHAT = 966, // Report Spam chat button + SMSG_COMPLAINT_ADDED = 967, // Complaint Registered. (message) + SMSG_VOICE_SYSTEM_STATUS = 968, // uint8, uint8 (id correct for 2.3.0) + // 969 + // 970 + CMSG_CHANNEL_SILENT_VOICE = 971, + CMSG_CHANNEL_SILENT_ALL = 972, + CMSG_CHANNEL_UNSILENT_VOICE = 973, + CMSG_CHANNEL_UNSILENT_ALL = 974, + // 975 + // 976 + CMSG_CHANNEL_ROSTER_QUERY = 977, // string channel name (channel list?) + CMSG_CHANNEL_VOICE_CHAT_QUERY = 978, // uint32, string + CMSG_CHANNEL_INFO_QUERY = 979, // string channel name + SMSG_CHANNEL_INFO_QUERY_RESPONSE = 980, // string channel name, uint8 flags, uint32 count + CMSG_CHANNEL_VOICE_ON = 981, // Enable Voice button in channel context menu + CMSG_CHANNEL_VOICE_OFF = 982, // ?? + // 983 + // 984 + SMSG_CHANNEL_NOTIFY_AVAILABLE_VOICE_SESSION = 985, // 9 bytes unk's + string channel name + uint64 guid, received after join voice channel + CMSG_MUTE_PLAYER = 986, // ?? + CMSG_UNMUTE_PLAYER = 987, // ?? + CMSG_SILENCE_MEMBER = 988, // ?? + CMSG_UNSILENCE_MEMBER = 989, // ?? + SMSG_PLAYER_UNSILENCED = 990, // A group leader has restored your voice privileges + SMSG_COMSAT_RECONNECT_ATTEMPT = 991, // Voice chat service restored! + SMSG_COMSAT_DISCONNECT = 992, // Connection lost to voice chat service. + SMSG_COMSAT_CONNECT_FAIL = 993, // Cannot connect to voice chat service. + // 994 + // 995 + // 996 + CMSG_GUILD_BANK = 997, // click on guildbank object, uint64 guid + uint8 unk + CMSG_GUILDBANK_TAB_COLON = 998, // response to 999, uint64 guid + uint8 + uint8 + SMSG_GUILD_BANK_LIST = 999, // uint32 + uint32 + uint8 + uint8 + uint16 count1 + uint8 + uint8 count2 + for (count2) { uint8 unk } + uint16 + for(count1) { uint32 counter + uint8 unk } + CMSG_UNKNOWN_1000 = 1000, // uint64 guid, uint8, uint8, uint8 count, for(count) uint8 unk + CMSG_BUY_GUILDBANK_TAB = 1001, // uint64 guid + uint8 unk + // 1002 + CMSG_GUILDBANK_DEPOSIT = 1003, // uint64 guid + uint32 + CMSG_GUILDBANK_WITHDRAW = 1004, // uint64 guid + uint32 + MSG_GUILDBANK_LOG = 1005, // guild bank log? client: empty, server: uint8 count, for count (uint8 unk(type?), uint64 guid, uint32 unk(amount?)) + CMSG_CHANNEL_WATCH = 1006, // string channel name + SMSG_PLAYER_JOINED_CHANNEL = 1007, // uint64, uint8, uint8, uint32, string channel name + SMSG_PLAYER_LEFT_CHANNEL = 1008, // uint64, uint8, uint32, string channel name + SMSG_PLAYER_JOINED_CUSTOM_CHANNEL = 1009, // guessed + CMSG_CLEAR_CHANNEL_WATCH = 1010, + SMSG_INSPECT_TALENTS = 1011, // uint32 count, for(count) uint8 unk + // 1012 + // 1013 + // 1014 + CMSG_UNKNOWN_1015 = 1015, // click on NPC with 0x1000000 npc_flag + // 1016 + // 1017 + // 1018 + SMSG_VOICESESSION_FULL = 1019, // The voice session you are attempting to join is full. + MSG_UNKNOWN_1020 = 1020, // probably guild related, client: empty, server: uint32, uint32, uint8, uint32, uint32 + MSG_UNKNOWN_1021 = 1021, // guild related + MSG_GUILD_EVENT_LOG = 1022 +}; + +//if you add new opcode .. Do NOT forget to change the following define MAX_OPCODE_ID and also add new opcode to table in opcodes.cpp +#define MAX_OPCODE_ID 1023 + +/// Results of friend related commands +enum FriendsResult +{ + FRIEND_DB_ERROR = 0x00, + FRIEND_LIST_FULL = 0x01, + FRIEND_ONLINE = 0x02, + FRIEND_OFFLINE = 0x03, + FRIEND_NOT_FOUND = 0x04, + FRIEND_REMOVED = 0x05, + FRIEND_ADDED_ONLINE = 0x06, + FRIEND_ADDED_OFFLINE = 0x07, + FRIEND_ALREADY = 0x08, + FRIEND_SELF = 0x09, + FRIEND_ENEMY = 0x0A, + FRIEND_IGNORE_FULL = 0x0B, + FRIEND_IGNORE_SELF = 0x0C, + FRIEND_IGNORE_NOT_FOUND = 0x0D, + FRIEND_IGNORE_ALREADY = 0x0E, + FRIEND_IGNORE_ADDED = 0x0F, + FRIEND_IGNORE_REMOVED = 0x10, + // 0x11 + // 0x12 + // 0x13 + // 0x14 + // 0x15 + FRIEND_MUTE_ADDED = 0x16, + FRIEND_MUTE_REMOVED = 0x17 +}; + +/// Non Player Character flags +enum NPCFlags +{ + UNIT_NPC_FLAG_NONE = 0x00000000, + UNIT_NPC_FLAG_GOSSIP = 0x00000001, // 100% + UNIT_NPC_FLAG_QUESTGIVER = 0x00000002, // guessed, probably ok + UNIT_NPC_FLAG_UNK1 = 0x00000004, + UNIT_NPC_FLAG_UNK2 = 0x00000008, + UNIT_NPC_FLAG_TRAINER = 0x00000010, // 100% + UNIT_NPC_FLAG_TRAINER_CLASS = 0x00000020, // 100% + UNIT_NPC_FLAG_TRAINER_PROFESSION = 0x00000040, // 100% + UNIT_NPC_FLAG_VENDOR = 0x00000080, // 100% + UNIT_NPC_FLAG_VENDOR_AMMO = 0x00000100, // 100%, general goods vendor + UNIT_NPC_FLAG_VENDOR_FOOD = 0x00000200, // 100% + UNIT_NPC_FLAG_VENDOR_POISON = 0x00000400, // guessed + UNIT_NPC_FLAG_VENDOR_REAGENT = 0x00000800, // 100% + UNIT_NPC_FLAG_REPAIR = 0x00001000, // 100% + UNIT_NPC_FLAG_FLIGHTMASTER = 0x00002000, // 100% + UNIT_NPC_FLAG_SPIRITHEALER = 0x00004000, // guessed + UNIT_NPC_FLAG_SPIRITGUIDE = 0x00008000, // guessed + UNIT_NPC_FLAG_INNKEEPER = 0x00010000, // 100% + UNIT_NPC_FLAG_BANKER = 0x00020000, // 100% + UNIT_NPC_FLAG_PETITIONER = 0x00040000, // 100% 0xC0000 = guild petitions, 0x40000 = arena team petitions + UNIT_NPC_FLAG_TABARDDESIGNER = 0x00080000, // 100% + UNIT_NPC_FLAG_BATTLEMASTER = 0x00100000, // 100% + UNIT_NPC_FLAG_AUCTIONEER = 0x00200000, // 100% + UNIT_NPC_FLAG_STABLEMASTER = 0x00400000, // 100% + UNIT_NPC_FLAG_GUILD_BANKER = 0x00800000, // cause client to send 997 opcode + UNIT_NPC_FLAG_UNK3 = 0x01000000, // cause client to send 1015 opcode + UNIT_NPC_FLAG_GUARD = 0x10000000, // custom flag for guards +}; +#endif +/// @} diff --git a/src/Client/World/Unit.cpp b/src/Client/World/Unit.cpp index d306429..f667456 100644 --- a/src/Client/World/Unit.cpp +++ b/src/Client/World/Unit.cpp @@ -1,21 +1,21 @@ -#include "common.h" -#include "Unit.h" - -Unit::Unit() : WorldObject() -{ - _type |= TYPE_UNIT; - _typeid = TYPEID_UNIT; - _valuescount = UNIT_END; -} - -void Unit::Create(uint64 guid) -{ - Object::Create(guid); -} - -uint8 Unit::GetGender(void) -{ - uint32 temp = GetUInt32Value(UNIT_FIELD_BYTES_0); - return ((uint8*)&temp)[2]; -} - +#include "common.h" +#include "Unit.h" + +Unit::Unit() : WorldObject() +{ + _type |= TYPE_UNIT; + _typeid = TYPEID_UNIT; + _valuescount = UNIT_END; +} + +void Unit::Create(uint64 guid) +{ + Object::Create(guid); +} + +uint8 Unit::GetGender(void) +{ + uint32 temp = GetUInt32Value(UNIT_FIELD_BYTES_0); + return ((uint8*)&temp)[2]; +} + diff --git a/src/Client/World/UpdateData.cpp b/src/Client/World/UpdateData.cpp index f58f4bb..ef8cb55 100644 --- a/src/Client/World/UpdateData.cpp +++ b/src/Client/World/UpdateData.cpp @@ -1,543 +1,543 @@ -#include "common.h" -#include "ZCompressor.h" -#include "WorldSession.h" -#include "UpdateData.h" -#include "UpdateFields.h" -#include "Object.h" -#include "Unit.h" -#include "Bag.h" -#include "GameObject.h" -#include "Corpse.h" -#include "DynamicObject.h" -#include "ObjMgr.h" -#include "UpdateMask.h" - - -void WorldSession::_HandleCompressedUpdateObjectOpcode(WorldPacket& recvPacket) -{ - uint32 realsize; - recvPacket >> realsize; - ZCompressor z; - z.append(recvPacket.contents() + sizeof(uint32),recvPacket.size() - sizeof(uint32)); - z.Compressed(true); - z.RealSize(realsize); - z.Inflate(); - if(z.Compressed()) - { - logerror("_HandleCompressedUpdateObjectOpcode(): Inflate() failed! size=%u realsize=%u",z.size(),realsize); - return; - } - WorldPacket wp; - wp.SetOpcode(recvPacket.GetOpcode()); - wp.append(z.contents(),z.size()); - - _HandleUpdateObjectOpcode(wp); -} - -void WorldSession::_HandleUpdateObjectOpcode(WorldPacket& recvPacket) -{ - uint8 utype; - uint8 unk8; - uint32 usize, ublocks; - uint64 uguid; - recvPacket >> ublocks >> unk8; - while(recvPacket.rpos() < recvPacket.size()) - { - recvPacket >> utype; - switch(utype) - { - case UPDATETYPE_VALUES: - { - uguid = recvPacket.GetPackedGuid(); - _ValuesUpdate(uguid,recvPacket); - } - break; - - case UPDATETYPE_MOVEMENT: - { - recvPacket >> uguid; // the guid is NOT packed here! - uint8 tyid; - Object *obj = objmgr.GetObj(uguid); - if(obj) - tyid = obj->GetTypeId(); - else // sometimes objects get deleted BEFORE a last update packet arrives, this must be handled also - { - tyid = GetTypeIdByGuid(uguid); - logerror("Got UpdateObject_Movement for unknown object "I64FMT". Using typeid %u",uguid,(uint32)tyid); - } - - if(obj) - this->_MovementUpdate(tyid,uguid,recvPacket); - } - break; - - case UPDATETYPE_CREATE_OBJECT2: // will be sent when our very own character is created - case UPDATETYPE_CREATE_OBJECT: // will be sent on any other object creation - { - uguid = recvPacket.GetPackedGuid(); - uint8 objtypeid; - recvPacket >> objtypeid; - logdebug("Create Object type %u with guid "I64FMT,objtypeid,uguid); - // dont create objects if already present in memory. - // recreate every object except ourself! - if(objmgr.GetObj(uguid)) - { - if(uguid != GetGuid()) - { - logdev("- already exists, deleting old, creating new object"); - objmgr.Remove(uguid); - // do not call script here, since the object does not really get deleted - } - else - { - logdev("- already exists, but not deleted (has our current GUID)"); - } - } - - // only if the obj didnt exist or was just deleted above, create it.... - if(!objmgr.GetObj(uguid)) - { - switch(objtypeid) - { - case TYPEID_OBJECT: // no data to read - { - logerror("Recieved wrong UPDATETYPE_CREATE_OBJECT to create Object base type!"); - logerror("%s",toHexDump((uint8*)recvPacket.contents(),recvPacket.size(),true).c_str()); - } - case TYPEID_ITEM: - { - Item *item = new Item(); - item->Create(uguid); - objmgr.Add(item); - break; - } - case TYPEID_CONTAINER: - { - Bag *bag = new Bag(); - bag->Create(uguid); - objmgr.Add(bag); - break; - } - case TYPEID_UNIT: - { - Unit *unit = new Unit(); - unit->Create(uguid); - objmgr.Add(unit); - break; - } - case TYPEID_PLAYER: - { - Player *player = new Player(); - player->Create(uguid); - objmgr.Add(player); - break; - } - case TYPEID_GAMEOBJECT: - { - GameObject *go = new GameObject(); - go->Create(uguid); - objmgr.Add(go); - break; - } - case TYPEID_CORPSE: - { - Corpse *corpse = new Corpse(); - corpse->Create(uguid); - objmgr.Add(corpse); - break; - } - case TYPEID_DYNAMICOBJECT: - { - DynamicObject *dobj = new DynamicObject(); - dobj->Create(uguid); - objmgr.Add(dobj); - break; - } - } - } - else - { - logdebug("Obj "I64FMT" not created, already exists",uguid); - } - // ...regardless if it was freshly created or already present, update its values and stuff now... - this->_MovementUpdate(objtypeid, uguid, recvPacket); - this->_ValuesUpdate(uguid, recvPacket); - - // ...and ask the server for eventually missing data. - _QueryObjectInfo(uguid); - - - // call script "_OnObjectCreate" - if(GetInstance()->GetScripts()->ScriptExists("_onobjectcreate")) - { - CmdSet Set; - Set.defaultarg = toString(uguid); - Set.arg[0] = toString(objtypeid); - GetInstance()->GetScripts()->RunScript("_onobjectcreate", &Set); - } - - // if our own character got finally created, we have successfully entered the world, - // and should have gotten all info about our char already. - } - break; - - case UPDATETYPE_OUT_OF_RANGE_OBJECTS: - { - recvPacket >> usize; - for(uint16 i=0;iGetScripts()->ScriptExists("_onobjectdelete")) - { - Object *del_obj = objmgr.GetObj(uguid); - CmdSet Set; - Set.defaultarg = toString(uguid); - Set.arg[0] = del_obj ? toString(del_obj->GetTypeId()) : ""; - Set.arg[1] = "true"; // out of range = true - GetInstance()->GetScripts()->RunScript("_onobjectdelete", &Set); - } - - objmgr.Remove(uguid); - } - } - break; - - default: - { - logerror("UPDATE_OBJECT: Got unk updatetype 0x%X",utype); - logerror("UPDATE_OBJECT: Read %u / %u bytes, skipped rest",recvPacket.rpos(),recvPacket.size()); - logerror("%s",toHexDump((uint8*)recvPacket.contents(),recvPacket.size(),true).c_str()); - return; - } - } // switch - } // while - -} // func - -void WorldSession::_MovementUpdate(uint8 objtypeid, uint64 uguid, WorldPacket& recvPacket) -{ - uint8 flags,unk8; - uint32 unk32,flags2,time,transtime,higuid; - float unkfx,unkfy,unkfz,x,y,z,o,tx,ty,tz,to; - uint64 transguid; - // uint64 fullguid; // see below - float speedWalk, speedRun, speedSwimBack, speedSwim, speedWalkBack, speedTurn, speedFly, speedFlyBack; - - Object *obj = (Object*)objmgr.GetObj(uguid); - Unit *u = (Unit*)obj; // only use for Unit:: functions!! - - recvPacket >> flags; - flags2 = 0; // not sure if its correct to set it to 0 (needs some starting flag?) - - if(flags & UPDATEFLAG_LIVING) - { - recvPacket >> flags2 >> unk8 >> time; - } - - logdev("MovementUpdate TypeID=%u GUID="I64FMT" pObj=%X flags=%u flags2=%u",objtypeid,uguid,obj,flags,flags2); - - if(flags & UPDATEFLAG_HASPOSITION) - { - if(flags & UPDATEFLAG_TRANSPORT) - { - recvPacket >> unkfx >> unkfy >> unkfz >> o; // 3x (float)0 followed by orientation - logdev("TRANSPORT_FLOATS @ flags: x=%f y=%f z=%f o=%f",unkfx,unkfy,unkfz,o); - } - else - { - recvPacket >> x >> y >> z >> o; - logdev("FLOATS: x=%f y=%f z=%f o=%f",x,y,z,o); - if(obj->IsWorldObject()) - ((WorldObject*)obj)->SetPosition(x,y,z,o); - } - } - - if(flags & UPDATEFLAG_LIVING) - { - if(flags2 & FLAGS2_TRANSPORT) - { - recvPacket >> transguid >> tx >> ty >> tz >> to; - recvPacket >> unk32; // added in 2.0.3 - logdev("TRANSPORT_FLOATS @ flags2: x=%f y=%f z=%f o=%f",tx,ty,tz,to); - } - - recvPacket >> unk32; - - /* - // not sure if this is/was correct, MaNGOS doesnt use it anymore - if(flags2 & 0x2000) // 0x2000 = ?? - { - recvPacket >> unkf >> unkf >> unkf >> unkf; - } - */ - - recvPacket >> speedWalk >> speedRun >> speedSwimBack >> speedSwim; - recvPacket >> speedWalkBack >> speedFly >> speedFlyBack >> speedTurn; // fly added in 2.0.x - if(u) - { - u->SetPosition(x,y,z,o); - u->SetSpeed(MOVE_WALK,speedWalk); - u->SetSpeed(MOVE_RUN,speedRun); - u->SetSpeed(MOVE_SWIMBACK,speedSwimBack); - u->SetSpeed(MOVE_SWIM,speedSwim); - u->SetSpeed(MOVE_WALKBACK,speedWalkBack); - u->SetSpeed(MOVE_TURN,speedTurn); - u->SetSpeed(MOVE_FLY,speedFly); - u->SetSpeed(MOVE_FLYBACK,speedFlyBack); - } - else - { - logerror("WorldSession::_MovementUpdate for unknown guid "I64FMT" typeid=%u",uguid,objtypeid); - } - } - - if(flags & UPDATEFLAG_ALL) - { - recvPacket >> unk32; - } - - if(flags & UPDATEFLAG_HIGHGUID) - { - recvPacket >> higuid; // 2.0.6 - high guid was there, unk for 2.0.12 - // not sure if this is correct, MaNGOS sends 0 always. - //obj->SetUInt32Value(OBJECT_FIELD_GUID+1,higuid); // note that this sets only the high part of the guid - } - - if(flags & UPDATEFLAG_FULLGUID) - { - // unused in mangos? but what if its needed? - // recvPacket >> fullguid; - } - - if(flags & UPDATEFLAG_TRANSPORT) - { - recvPacket >> transtime; // whats this used for? - } - -} - -void WorldSession::_ValuesUpdate(uint64 uguid, WorldPacket& recvPacket) -{ - Object *obj = objmgr.GetObj(uguid); - uint8 blockcount,tyid; - uint32 value, masksize, valuesCount; - float fvalue; - - if(obj) - { - valuesCount = obj->GetValuesCount(); - tyid = obj->GetTypeId(); - } - else - { - logcustom(1,LRED,"Got UpdateObject_Values for unknown object "I64FMT,uguid); - tyid = GetTypeIdByGuid(uguid); // can cause problems with TYPEID_CONTAINER!! - valuesCount = GetValuesCountByTypeId(tyid); - } - - - recvPacket >> blockcount; - masksize = blockcount << 2; // each sizeof(uint32) == <4> * sizeof(uint8) // 1<<2 == <4> - UpdateMask umask; - uint32 *updateMask = new uint32[blockcount]; - umask.SetCount(masksize); - recvPacket.read((uint8*)updateMask, masksize); - umask.SetMask(updateMask); - //delete [] updateMask; // will be deleted at ~UpdateMask() !!!! - logdev("ValuesUpdate TypeId=%u GUID="I64FMT" pObj=%X Blocks=%u Masksize=%u",tyid,uguid,obj,blockcount,masksize); - - // just in case the object does not exist, and we have really a container instead of an item, and a value in - // the container fields is set, THEN we have a problem. this should never be the case; it can be fixed in a - // more correct way if there is the need. - // (-> valuesCount smaller then it should be might skip a few bytes and corrupt the packet) - for (uint32 i = 0; i < valuesCount; i++) - { - if (umask.GetBit(i)) - { - if(obj) - { - if(IsFloatField(obj->GetTypeMask(),i)) - { - recvPacket >> fvalue; - obj->SetFloatValue(i, fvalue); - logdev("-> Field[%u] = %f",i,fvalue); - } - else - { - recvPacket >> value; - obj->SetUInt32Value(i, value); - logdev("-> Field[%u] = %u",i,value); - } - } - else - { - recvPacket >> value; // drop the value, since object doesnt exist (always 4 bytes) - } - } - } -} - -void WorldSession::_QueryObjectInfo(uint64 guid) -{ - Object *obj = objmgr.GetObj(guid); - if(obj) - { - switch(obj->GetTypeId()) - { - case TYPEID_ITEM: - case TYPEID_CONTAINER: - { - ItemProto *proto = objmgr.GetItemProto(obj->GetEntry()); - if(proto) - { - obj->SetName(proto->Name); - } - else - { - logdebug("Found unknown item: GUID="I64FMT" entry=%u",obj->GetGUID(),obj->GetEntry()); - SendQueryItem(obj->GetEntry(),guid); // not sure if sending GUID is correct - } - break; - } - case TYPEID_PLAYER: - { - std::string name = GetOrRequestPlayerName(obj->GetGUID()); - if(!name.empty()) - { - obj->SetName(name); - } - // else: name will be set when server answers (_HandleNameQueryResponseOpcode) - break; - } - case TYPEID_UNIT: // checked after player; this one here should cover creatures only - { - CreatureTemplate *ct = objmgr.GetCreatureTemplate(obj->GetEntry()); - if(ct) - obj->SetName(ct->name); - else - SendQueryCreature(obj->GetEntry(),guid); - break; - } - //case... - } - } -} - -// helper to determine if an updatefield should store float or int values, depending on TypeId -bool IsFloatField(uint8 ty, uint32 f) -{ - static uint32 floats_object[] = - { - (uint32)OBJECT_FIELD_SCALE_X, - (uint32)-1 - }; - /* - static uint32 floats_item[] = - { - (uint32)-1 - }; - static uint32 floats_container[] = - { - (uint32)-1 - }; - */ - static uint32 floats_unit[] = - { - (uint32)UNIT_FIELD_BOUNDINGRADIUS, - (uint32)UNIT_FIELD_COMBATREACH, - (uint32)UNIT_FIELD_MINDAMAGE, - (uint32)UNIT_FIELD_MAXDAMAGE, - (uint32)UNIT_FIELD_MINOFFHANDDAMAGE, - (uint32)UNIT_FIELD_MINOFFHANDDAMAGE, - (uint32)UNIT_MOD_CAST_SPEED, - (uint32)UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER, - (uint32)UNIT_FIELD_ATTACK_POWER_MULTIPLIER, - (uint32)UNIT_FIELD_MINRANGEDDAMAGE, - (uint32)UNIT_FIELD_MAXRANGEDDAMAGE, - (uint32)UNIT_FIELD_POWER_COST_MULTIPLIER, - (uint32)-1 - }; - static uint32 floats_player[] = - { - (uint32)PLAYER_BLOCK_PERCENTAGE, - (uint32)PLAYER_DODGE_PERCENTAGE, - (uint32)PLAYER_PARRY_PERCENTAGE, - (uint32)PLAYER_RANGED_CRIT_PERCENTAGE, - (uint32)PLAYER_OFFHAND_CRIT_PERCENTAGE, - (uint32)PLAYER_SPELL_CRIT_PERCENTAGE1, - (uint32)PLAYER_HOLY_SPELL_CRIT_PERCENTAGE, - (uint32)PLAYER_FIRE_SPELL_CRIT_PERCENTAGE, - (uint32)PLAYER_NATURE_SPELL_CRIT_PERCENTAGE, - (uint32)PLAYER_FROST_SPELL_CRIT_PERCENTAGE, - (uint32)PLAYER_SHADOW_SPELL_CRIT_PERCENTAGE, - (uint32)PLAYER_ARCANE_SPELL_CRIT_PERCENTAGE, - (uint32)PLAYER_FIELD_MOD_MANA_REGEN, - (uint32)PLAYER_FIELD_MOD_MANA_REGEN_INTERRUPT, - (uint32)-1 - }; - static uint32 floats_gameobject[] = - { - (uint32)GAMEOBJECT_ROTATION, - (uint32)GAMEOBJECT_POS_X, - (uint32)GAMEOBJECT_POS_Y, - (uint32)GAMEOBJECT_POS_Z, - (uint32)GAMEOBJECT_FACING, - (uint32)-1 - }; - static uint32 floats_dynobject[] = - { - (uint32)DYNAMICOBJECT_RADIUS, - (uint32)DYNAMICOBJECT_POS_X, - (uint32)DYNAMICOBJECT_POS_Y, - (uint32)DYNAMICOBJECT_POS_Z, - (uint32)-1 - }; - static uint32 floats_corpse[] = - { - (uint32)CORPSE_FIELD_FACING, - (uint32)CORPSE_FIELD_POS_X, - (uint32)CORPSE_FIELD_POS_Y, - (uint32)CORPSE_FIELD_POS_Z, - (uint32)-1 - }; - - if(ty & TYPE_OBJECT) - for(uint32 i = 0; floats_object[i] != (-1); i++) - if(floats_object[i] == f) - return true; - /* - if(ty & TYPE_ITEM) - for(uint32 i = 0; floats_item[i] != (-1); i++) - if(floats_object[i] == f) - return true; - if(ty & TYPE_CONTAINER) - for(uint32 i = 0; floats_container[i] != (-1); i++) - if(floats_object[i] == f) - return true; - */ - if(ty & TYPE_UNIT) - for(uint32 i = 0; floats_unit[i] != (-1); i++) - if(floats_unit[i] == f) - return true; - if(ty & TYPE_PLAYER) - for(uint32 i = 0; floats_player[i] != (-1); i++) - if(floats_player[i] == f) - return true; - if(ty & TYPE_GAMEOBJECT) - for(uint32 i = 0; floats_gameobject[i] != (-1); i++) - if(floats_gameobject[i] == f) - return true; - if(ty & TYPE_DYNAMICOBJECT) - for(uint32 i = 0; floats_dynobject[i] != (-1); i++) - if(floats_dynobject[i] == f) - return true; - if(ty & TYPE_CORPSE) - for(uint32 i = 0; floats_corpse[i] != (-1); i++) - if(floats_corpse[i] == f) - return true; - - return false; -} +#include "common.h" +#include "ZCompressor.h" +#include "WorldSession.h" +#include "UpdateData.h" +#include "UpdateFields.h" +#include "Object.h" +#include "Unit.h" +#include "Bag.h" +#include "GameObject.h" +#include "Corpse.h" +#include "DynamicObject.h" +#include "ObjMgr.h" +#include "UpdateMask.h" + + +void WorldSession::_HandleCompressedUpdateObjectOpcode(WorldPacket& recvPacket) +{ + uint32 realsize; + recvPacket >> realsize; + ZCompressor z; + z.append(recvPacket.contents() + sizeof(uint32),recvPacket.size() - sizeof(uint32)); + z.Compressed(true); + z.RealSize(realsize); + z.Inflate(); + if(z.Compressed()) + { + logerror("_HandleCompressedUpdateObjectOpcode(): Inflate() failed! size=%u realsize=%u",z.size(),realsize); + return; + } + WorldPacket wp; + wp.SetOpcode(recvPacket.GetOpcode()); + wp.append(z.contents(),z.size()); + + _HandleUpdateObjectOpcode(wp); +} + +void WorldSession::_HandleUpdateObjectOpcode(WorldPacket& recvPacket) +{ + uint8 utype; + uint8 unk8; + uint32 usize, ublocks; + uint64 uguid; + recvPacket >> ublocks >> unk8; + while(recvPacket.rpos() < recvPacket.size()) + { + recvPacket >> utype; + switch(utype) + { + case UPDATETYPE_VALUES: + { + uguid = recvPacket.GetPackedGuid(); + _ValuesUpdate(uguid,recvPacket); + } + break; + + case UPDATETYPE_MOVEMENT: + { + recvPacket >> uguid; // the guid is NOT packed here! + uint8 tyid; + Object *obj = objmgr.GetObj(uguid); + if(obj) + tyid = obj->GetTypeId(); + else // sometimes objects get deleted BEFORE a last update packet arrives, this must be handled also + { + tyid = GetTypeIdByGuid(uguid); + logerror("Got UpdateObject_Movement for unknown object "I64FMT". Using typeid %u",uguid,(uint32)tyid); + } + + if(obj) + this->_MovementUpdate(tyid,uguid,recvPacket); + } + break; + + case UPDATETYPE_CREATE_OBJECT2: // will be sent when our very own character is created + case UPDATETYPE_CREATE_OBJECT: // will be sent on any other object creation + { + uguid = recvPacket.GetPackedGuid(); + uint8 objtypeid; + recvPacket >> objtypeid; + logdebug("Create Object type %u with guid "I64FMT,objtypeid,uguid); + // dont create objects if already present in memory. + // recreate every object except ourself! + if(objmgr.GetObj(uguid)) + { + if(uguid != GetGuid()) + { + logdev("- already exists, deleting old, creating new object"); + objmgr.Remove(uguid); + // do not call script here, since the object does not really get deleted + } + else + { + logdev("- already exists, but not deleted (has our current GUID)"); + } + } + + // only if the obj didnt exist or was just deleted above, create it.... + if(!objmgr.GetObj(uguid)) + { + switch(objtypeid) + { + case TYPEID_OBJECT: // no data to read + { + logerror("Recieved wrong UPDATETYPE_CREATE_OBJECT to create Object base type!"); + logerror("%s",toHexDump((uint8*)recvPacket.contents(),recvPacket.size(),true).c_str()); + } + case TYPEID_ITEM: + { + Item *item = new Item(); + item->Create(uguid); + objmgr.Add(item); + break; + } + case TYPEID_CONTAINER: + { + Bag *bag = new Bag(); + bag->Create(uguid); + objmgr.Add(bag); + break; + } + case TYPEID_UNIT: + { + Unit *unit = new Unit(); + unit->Create(uguid); + objmgr.Add(unit); + break; + } + case TYPEID_PLAYER: + { + Player *player = new Player(); + player->Create(uguid); + objmgr.Add(player); + break; + } + case TYPEID_GAMEOBJECT: + { + GameObject *go = new GameObject(); + go->Create(uguid); + objmgr.Add(go); + break; + } + case TYPEID_CORPSE: + { + Corpse *corpse = new Corpse(); + corpse->Create(uguid); + objmgr.Add(corpse); + break; + } + case TYPEID_DYNAMICOBJECT: + { + DynamicObject *dobj = new DynamicObject(); + dobj->Create(uguid); + objmgr.Add(dobj); + break; + } + } + } + else + { + logdebug("Obj "I64FMT" not created, already exists",uguid); + } + // ...regardless if it was freshly created or already present, update its values and stuff now... + this->_MovementUpdate(objtypeid, uguid, recvPacket); + this->_ValuesUpdate(uguid, recvPacket); + + // ...and ask the server for eventually missing data. + _QueryObjectInfo(uguid); + + + // call script "_OnObjectCreate" + if(GetInstance()->GetScripts()->ScriptExists("_onobjectcreate")) + { + CmdSet Set; + Set.defaultarg = toString(uguid); + Set.arg[0] = toString(objtypeid); + GetInstance()->GetScripts()->RunScript("_onobjectcreate", &Set); + } + + // if our own character got finally created, we have successfully entered the world, + // and should have gotten all info about our char already. + } + break; + + case UPDATETYPE_OUT_OF_RANGE_OBJECTS: + { + recvPacket >> usize; + for(uint16 i=0;iGetScripts()->ScriptExists("_onobjectdelete")) + { + Object *del_obj = objmgr.GetObj(uguid); + CmdSet Set; + Set.defaultarg = toString(uguid); + Set.arg[0] = del_obj ? toString(del_obj->GetTypeId()) : ""; + Set.arg[1] = "true"; // out of range = true + GetInstance()->GetScripts()->RunScript("_onobjectdelete", &Set); + } + + objmgr.Remove(uguid); + } + } + break; + + default: + { + logerror("UPDATE_OBJECT: Got unk updatetype 0x%X",utype); + logerror("UPDATE_OBJECT: Read %u / %u bytes, skipped rest",recvPacket.rpos(),recvPacket.size()); + logerror("%s",toHexDump((uint8*)recvPacket.contents(),recvPacket.size(),true).c_str()); + return; + } + } // switch + } // while + +} // func + +void WorldSession::_MovementUpdate(uint8 objtypeid, uint64 uguid, WorldPacket& recvPacket) +{ + uint8 flags,unk8; + uint32 unk32,flags2,time,transtime,higuid; + float unkfx,unkfy,unkfz,x,y,z,o,tx,ty,tz,to; + uint64 transguid; + // uint64 fullguid; // see below + float speedWalk, speedRun, speedSwimBack, speedSwim, speedWalkBack, speedTurn, speedFly, speedFlyBack; + + Object *obj = (Object*)objmgr.GetObj(uguid); + Unit *u = (Unit*)obj; // only use for Unit:: functions!! + + recvPacket >> flags; + flags2 = 0; // not sure if its correct to set it to 0 (needs some starting flag?) + + if(flags & UPDATEFLAG_LIVING) + { + recvPacket >> flags2 >> unk8 >> time; + } + + logdev("MovementUpdate TypeID=%u GUID="I64FMT" pObj=%X flags=%u flags2=%u",objtypeid,uguid,obj,flags,flags2); + + if(flags & UPDATEFLAG_HASPOSITION) + { + if(flags & UPDATEFLAG_TRANSPORT) + { + recvPacket >> unkfx >> unkfy >> unkfz >> o; // 3x (float)0 followed by orientation + logdev("TRANSPORT_FLOATS @ flags: x=%f y=%f z=%f o=%f",unkfx,unkfy,unkfz,o); + } + else + { + recvPacket >> x >> y >> z >> o; + logdev("FLOATS: x=%f y=%f z=%f o=%f",x,y,z,o); + if(obj->IsWorldObject()) + ((WorldObject*)obj)->SetPosition(x,y,z,o); + } + } + + if(flags & UPDATEFLAG_LIVING) + { + if(flags2 & FLAGS2_TRANSPORT) + { + recvPacket >> transguid >> tx >> ty >> tz >> to; + recvPacket >> unk32; // added in 2.0.3 + logdev("TRANSPORT_FLOATS @ flags2: x=%f y=%f z=%f o=%f",tx,ty,tz,to); + } + + recvPacket >> unk32; + + /* + // not sure if this is/was correct, MaNGOS doesnt use it anymore + if(flags2 & 0x2000) // 0x2000 = ?? + { + recvPacket >> unkf >> unkf >> unkf >> unkf; + } + */ + + recvPacket >> speedWalk >> speedRun >> speedSwimBack >> speedSwim; + recvPacket >> speedWalkBack >> speedFly >> speedFlyBack >> speedTurn; // fly added in 2.0.x + if(u) + { + u->SetPosition(x,y,z,o); + u->SetSpeed(MOVE_WALK,speedWalk); + u->SetSpeed(MOVE_RUN,speedRun); + u->SetSpeed(MOVE_SWIMBACK,speedSwimBack); + u->SetSpeed(MOVE_SWIM,speedSwim); + u->SetSpeed(MOVE_WALKBACK,speedWalkBack); + u->SetSpeed(MOVE_TURN,speedTurn); + u->SetSpeed(MOVE_FLY,speedFly); + u->SetSpeed(MOVE_FLYBACK,speedFlyBack); + } + else + { + logerror("WorldSession::_MovementUpdate for unknown guid "I64FMT" typeid=%u",uguid,objtypeid); + } + } + + if(flags & UPDATEFLAG_ALL) + { + recvPacket >> unk32; + } + + if(flags & UPDATEFLAG_HIGHGUID) + { + recvPacket >> higuid; // 2.0.6 - high guid was there, unk for 2.0.12 + // not sure if this is correct, MaNGOS sends 0 always. + //obj->SetUInt32Value(OBJECT_FIELD_GUID+1,higuid); // note that this sets only the high part of the guid + } + + if(flags & UPDATEFLAG_FULLGUID) + { + // unused in mangos? but what if its needed? + // recvPacket >> fullguid; + } + + if(flags & UPDATEFLAG_TRANSPORT) + { + recvPacket >> transtime; // whats this used for? + } + +} + +void WorldSession::_ValuesUpdate(uint64 uguid, WorldPacket& recvPacket) +{ + Object *obj = objmgr.GetObj(uguid); + uint8 blockcount,tyid; + uint32 value, masksize, valuesCount; + float fvalue; + + if(obj) + { + valuesCount = obj->GetValuesCount(); + tyid = obj->GetTypeId(); + } + else + { + logcustom(1,LRED,"Got UpdateObject_Values for unknown object "I64FMT,uguid); + tyid = GetTypeIdByGuid(uguid); // can cause problems with TYPEID_CONTAINER!! + valuesCount = GetValuesCountByTypeId(tyid); + } + + + recvPacket >> blockcount; + masksize = blockcount << 2; // each sizeof(uint32) == <4> * sizeof(uint8) // 1<<2 == <4> + UpdateMask umask; + uint32 *updateMask = new uint32[blockcount]; + umask.SetCount(masksize); + recvPacket.read((uint8*)updateMask, masksize); + umask.SetMask(updateMask); + //delete [] updateMask; // will be deleted at ~UpdateMask() !!!! + logdev("ValuesUpdate TypeId=%u GUID="I64FMT" pObj=%X Blocks=%u Masksize=%u",tyid,uguid,obj,blockcount,masksize); + + // just in case the object does not exist, and we have really a container instead of an item, and a value in + // the container fields is set, THEN we have a problem. this should never be the case; it can be fixed in a + // more correct way if there is the need. + // (-> valuesCount smaller then it should be might skip a few bytes and corrupt the packet) + for (uint32 i = 0; i < valuesCount; i++) + { + if (umask.GetBit(i)) + { + if(obj) + { + if(IsFloatField(obj->GetTypeMask(),i)) + { + recvPacket >> fvalue; + obj->SetFloatValue(i, fvalue); + logdev("-> Field[%u] = %f",i,fvalue); + } + else + { + recvPacket >> value; + obj->SetUInt32Value(i, value); + logdev("-> Field[%u] = %u",i,value); + } + } + else + { + recvPacket >> value; // drop the value, since object doesnt exist (always 4 bytes) + } + } + } +} + +void WorldSession::_QueryObjectInfo(uint64 guid) +{ + Object *obj = objmgr.GetObj(guid); + if(obj) + { + switch(obj->GetTypeId()) + { + case TYPEID_ITEM: + case TYPEID_CONTAINER: + { + ItemProto *proto = objmgr.GetItemProto(obj->GetEntry()); + if(proto) + { + obj->SetName(proto->Name); + } + else + { + logdebug("Found unknown item: GUID="I64FMT" entry=%u",obj->GetGUID(),obj->GetEntry()); + SendQueryItem(obj->GetEntry(),guid); // not sure if sending GUID is correct + } + break; + } + case TYPEID_PLAYER: + { + std::string name = GetOrRequestPlayerName(obj->GetGUID()); + if(!name.empty()) + { + obj->SetName(name); + } + // else: name will be set when server answers (_HandleNameQueryResponseOpcode) + break; + } + case TYPEID_UNIT: // checked after player; this one here should cover creatures only + { + CreatureTemplate *ct = objmgr.GetCreatureTemplate(obj->GetEntry()); + if(ct) + obj->SetName(ct->name); + else + SendQueryCreature(obj->GetEntry(),guid); + break; + } + //case... + } + } +} + +// helper to determine if an updatefield should store float or int values, depending on TypeId +bool IsFloatField(uint8 ty, uint32 f) +{ + static uint32 floats_object[] = + { + (uint32)OBJECT_FIELD_SCALE_X, + (uint32)-1 + }; + /* + static uint32 floats_item[] = + { + (uint32)-1 + }; + static uint32 floats_container[] = + { + (uint32)-1 + }; + */ + static uint32 floats_unit[] = + { + (uint32)UNIT_FIELD_BOUNDINGRADIUS, + (uint32)UNIT_FIELD_COMBATREACH, + (uint32)UNIT_FIELD_MINDAMAGE, + (uint32)UNIT_FIELD_MAXDAMAGE, + (uint32)UNIT_FIELD_MINOFFHANDDAMAGE, + (uint32)UNIT_FIELD_MINOFFHANDDAMAGE, + (uint32)UNIT_MOD_CAST_SPEED, + (uint32)UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER, + (uint32)UNIT_FIELD_ATTACK_POWER_MULTIPLIER, + (uint32)UNIT_FIELD_MINRANGEDDAMAGE, + (uint32)UNIT_FIELD_MAXRANGEDDAMAGE, + (uint32)UNIT_FIELD_POWER_COST_MULTIPLIER, + (uint32)-1 + }; + static uint32 floats_player[] = + { + (uint32)PLAYER_BLOCK_PERCENTAGE, + (uint32)PLAYER_DODGE_PERCENTAGE, + (uint32)PLAYER_PARRY_PERCENTAGE, + (uint32)PLAYER_RANGED_CRIT_PERCENTAGE, + (uint32)PLAYER_OFFHAND_CRIT_PERCENTAGE, + (uint32)PLAYER_SPELL_CRIT_PERCENTAGE1, + (uint32)PLAYER_HOLY_SPELL_CRIT_PERCENTAGE, + (uint32)PLAYER_FIRE_SPELL_CRIT_PERCENTAGE, + (uint32)PLAYER_NATURE_SPELL_CRIT_PERCENTAGE, + (uint32)PLAYER_FROST_SPELL_CRIT_PERCENTAGE, + (uint32)PLAYER_SHADOW_SPELL_CRIT_PERCENTAGE, + (uint32)PLAYER_ARCANE_SPELL_CRIT_PERCENTAGE, + (uint32)PLAYER_FIELD_MOD_MANA_REGEN, + (uint32)PLAYER_FIELD_MOD_MANA_REGEN_INTERRUPT, + (uint32)-1 + }; + static uint32 floats_gameobject[] = + { + (uint32)GAMEOBJECT_ROTATION, + (uint32)GAMEOBJECT_POS_X, + (uint32)GAMEOBJECT_POS_Y, + (uint32)GAMEOBJECT_POS_Z, + (uint32)GAMEOBJECT_FACING, + (uint32)-1 + }; + static uint32 floats_dynobject[] = + { + (uint32)DYNAMICOBJECT_RADIUS, + (uint32)DYNAMICOBJECT_POS_X, + (uint32)DYNAMICOBJECT_POS_Y, + (uint32)DYNAMICOBJECT_POS_Z, + (uint32)-1 + }; + static uint32 floats_corpse[] = + { + (uint32)CORPSE_FIELD_FACING, + (uint32)CORPSE_FIELD_POS_X, + (uint32)CORPSE_FIELD_POS_Y, + (uint32)CORPSE_FIELD_POS_Z, + (uint32)-1 + }; + + if(ty & TYPE_OBJECT) + for(uint32 i = 0; floats_object[i] != (-1); i++) + if(floats_object[i] == f) + return true; + /* + if(ty & TYPE_ITEM) + for(uint32 i = 0; floats_item[i] != (-1); i++) + if(floats_object[i] == f) + return true; + if(ty & TYPE_CONTAINER) + for(uint32 i = 0; floats_container[i] != (-1); i++) + if(floats_object[i] == f) + return true; + */ + if(ty & TYPE_UNIT) + for(uint32 i = 0; floats_unit[i] != (-1); i++) + if(floats_unit[i] == f) + return true; + if(ty & TYPE_PLAYER) + for(uint32 i = 0; floats_player[i] != (-1); i++) + if(floats_player[i] == f) + return true; + if(ty & TYPE_GAMEOBJECT) + for(uint32 i = 0; floats_gameobject[i] != (-1); i++) + if(floats_gameobject[i] == f) + return true; + if(ty & TYPE_DYNAMICOBJECT) + for(uint32 i = 0; floats_dynobject[i] != (-1); i++) + if(floats_dynobject[i] == f) + return true; + if(ty & TYPE_CORPSE) + for(uint32 i = 0; floats_corpse[i] != (-1); i++) + if(floats_corpse[i] == f) + return true; + + return false; +} diff --git a/src/Client/World/UpdateData.h b/src/Client/World/UpdateData.h index 9a339fa..3ba895b 100644 --- a/src/Client/World/UpdateData.h +++ b/src/Client/World/UpdateData.h @@ -1,34 +1,34 @@ -#ifndef _UPDATEDATA_H -#define _UPDATEDATA_H - -enum OBJECT_UPDATE_TYPE -{ - UPDATETYPE_VALUES = 0, - UPDATETYPE_MOVEMENT = 1, - UPDATETYPE_CREATE_OBJECT = 2, - UPDATETYPE_CREATE_OBJECT2 = 3, - UPDATETYPE_OUT_OF_RANGE_OBJECTS = 4, - UPDATETYPE_NEAR_OBJECTS = 5 -}; - -enum OBJECT_UPDATE_FLAGS -{ - UPDATEFLAG_SELF = 0x01, - UPDATEFLAG_TRANSPORT = 0x02, - UPDATEFLAG_FULLGUID = 0x04, - UPDATEFLAG_HIGHGUID = 0x08, - UPDATEFLAG_ALL = 0x10, - UPDATEFLAG_LIVING = 0x20, - UPDATEFLAG_HASPOSITION = 0x40 -}; - -// not sure about those flags, mangos hasnt a description for it either -enum FLAGS2_UPDATE_FLAGS -{ - FLAGS2_TRANSPORT = 0x200, - FLAGS2_SPIRITHEALER = 0x10000000, -}; - -bool IsFloatField(uint8, uint32); - +#ifndef _UPDATEDATA_H +#define _UPDATEDATA_H + +enum OBJECT_UPDATE_TYPE +{ + UPDATETYPE_VALUES = 0, + UPDATETYPE_MOVEMENT = 1, + UPDATETYPE_CREATE_OBJECT = 2, + UPDATETYPE_CREATE_OBJECT2 = 3, + UPDATETYPE_OUT_OF_RANGE_OBJECTS = 4, + UPDATETYPE_NEAR_OBJECTS = 5 +}; + +enum OBJECT_UPDATE_FLAGS +{ + UPDATEFLAG_SELF = 0x01, + UPDATEFLAG_TRANSPORT = 0x02, + UPDATEFLAG_FULLGUID = 0x04, + UPDATEFLAG_HIGHGUID = 0x08, + UPDATEFLAG_ALL = 0x10, + UPDATEFLAG_LIVING = 0x20, + UPDATEFLAG_HASPOSITION = 0x40 +}; + +// not sure about those flags, mangos hasnt a description for it either +enum FLAGS2_UPDATE_FLAGS +{ + FLAGS2_TRANSPORT = 0x200, + FLAGS2_SPIRITHEALER = 0x10000000, +}; + +bool IsFloatField(uint8, uint32); + #endif \ No newline at end of file diff --git a/src/Client/World/UpdateFields.h b/src/Client/World/UpdateFields.h index 5ce0ab0..1601781 100644 --- a/src/Client/World/UpdateFields.h +++ b/src/Client/World/UpdateFields.h @@ -1,469 +1,469 @@ -/* - * Copyright (C) 2005,2006,2007 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _UPDATEFIELDS_AUTO_H -#define _UPDATEFIELDS_AUTO_H - -// Auto generated for version 0, 3, 2, 7655 - -enum EObjectFields -{ - OBJECT_FIELD_GUID = 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC - OBJECT_FIELD_TYPE = 0x0002, // Size: 1, Type: INT, Flags: PUBLIC - OBJECT_FIELD_ENTRY = 0x0003, // Size: 1, Type: INT, Flags: PUBLIC - OBJECT_FIELD_SCALE_X = 0x0004, // Size: 1, Type: FLOAT, Flags: PUBLIC - OBJECT_FIELD_PADDING = 0x0005, // Size: 1, Type: INT, Flags: NONE - OBJECT_END = 0x0006, -}; - -enum EItemFields -{ - ITEM_FIELD_OWNER = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC - ITEM_FIELD_CONTAINED = OBJECT_END + 0x0002, // Size: 2, Type: LONG, Flags: PUBLIC - ITEM_FIELD_CREATOR = OBJECT_END + 0x0004, // Size: 2, Type: LONG, Flags: PUBLIC - ITEM_FIELD_GIFTCREATOR = OBJECT_END + 0x0006, // Size: 2, Type: LONG, Flags: PUBLIC - ITEM_FIELD_STACK_COUNT = OBJECT_END + 0x0008, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2 - ITEM_FIELD_DURATION = OBJECT_END + 0x0009, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2 - ITEM_FIELD_SPELL_CHARGES = OBJECT_END + 0x000A, // Size: 5, Type: INT, Flags: OWNER_ONLY, UNK2 - ITEM_FIELD_FLAGS = OBJECT_END + 0x000F, // Size: 1, Type: INT, Flags: PUBLIC - ITEM_FIELD_ENCHANTMENT = OBJECT_END + 0x0010, // Size: 33, Type: INT, Flags: PUBLIC - ITEM_FIELD_PROPERTY_SEED = OBJECT_END + 0x0031, // Size: 1, Type: INT, Flags: PUBLIC - - // custom - ITEM_FIELD_SUFFIX_FACTOR = ITEM_FIELD_PROPERTY_SEED, - - ITEM_FIELD_RANDOM_PROPERTIES_ID = OBJECT_END + 0x0032, // Size: 1, Type: INT, Flags: PUBLIC - ITEM_FIELD_ITEM_TEXT_ID = OBJECT_END + 0x0033, // Size: 1, Type: INT, Flags: OWNER_ONLY - ITEM_FIELD_DURABILITY = OBJECT_END + 0x0034, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2 - ITEM_FIELD_MAXDURABILITY = OBJECT_END + 0x0035, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2 - ITEM_END = OBJECT_END + 0x0036, -}; - -enum EContainerFields -{ - CONTAINER_FIELD_NUM_SLOTS = ITEM_END + 0x0000, // Size: 1, Type: INT, Flags: PUBLIC - CONTAINER_ALIGN_PAD = ITEM_END + 0x0001, // Size: 1, Type: BYTES, Flags: NONE - CONTAINER_FIELD_SLOT_1 = ITEM_END + 0x0002, // Size: 72, Type: LONG, Flags: PUBLIC - CONTAINER_END = ITEM_END + 0x004A, -}; - -enum EUnitFields -{ - UNIT_FIELD_CHARM = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC - UNIT_FIELD_SUMMON = OBJECT_END + 0x0002, // Size: 2, Type: LONG, Flags: PUBLIC - UNIT_FIELD_CHARMEDBY = OBJECT_END + 0x0004, // Size: 2, Type: LONG, Flags: PUBLIC - UNIT_FIELD_SUMMONEDBY = OBJECT_END + 0x0006, // Size: 2, Type: LONG, Flags: PUBLIC - UNIT_FIELD_CREATEDBY = OBJECT_END + 0x0008, // Size: 2, Type: LONG, Flags: PUBLIC - UNIT_FIELD_TARGET = OBJECT_END + 0x000A, // Size: 2, Type: LONG, Flags: PUBLIC - UNIT_FIELD_PERSUADED = OBJECT_END + 0x000C, // Size: 2, Type: LONG, Flags: PUBLIC - UNIT_FIELD_CHANNEL_OBJECT = OBJECT_END + 0x000E, // Size: 2, Type: LONG, Flags: PUBLIC - UNIT_FIELD_HEALTH = OBJECT_END + 0x0010, // Size: 1, Type: INT, Flags: DYNAMIC - UNIT_FIELD_POWER1 = OBJECT_END + 0x0011, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_POWER2 = OBJECT_END + 0x0012, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_POWER3 = OBJECT_END + 0x0013, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_POWER4 = OBJECT_END + 0x0014, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_POWER5 = OBJECT_END + 0x0015, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_MAXHEALTH = OBJECT_END + 0x0016, // Size: 1, Type: INT, Flags: DYNAMIC - UNIT_FIELD_MAXPOWER1 = OBJECT_END + 0x0017, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_MAXPOWER2 = OBJECT_END + 0x0018, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_MAXPOWER3 = OBJECT_END + 0x0019, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_MAXPOWER4 = OBJECT_END + 0x001A, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_MAXPOWER5 = OBJECT_END + 0x001B, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_LEVEL = OBJECT_END + 0x001C, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_FACTIONTEMPLATE = OBJECT_END + 0x001D, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_BYTES_0 = OBJECT_END + 0x001E, // Size: 1, Type: BYTES, Flags: PUBLIC - UNIT_VIRTUAL_ITEM_SLOT_DISPLAY = OBJECT_END + 0x001F, // Size: 3, Type: INT, Flags: PUBLIC - UNIT_VIRTUAL_ITEM_INFO = OBJECT_END + 0x0022, // Size: 6, Type: BYTES, Flags: PUBLIC - UNIT_FIELD_FLAGS = OBJECT_END + 0x0028, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_FLAGS_2 = OBJECT_END + 0x0029, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_AURA = OBJECT_END + 0x002A, // Size: 56, Type: INT, Flags: PUBLIC - UNIT_FIELD_AURAFLAGS = OBJECT_END + 0x0062, // Size: 14, Type: BYTES, Flags: PUBLIC - UNIT_FIELD_AURALEVELS = OBJECT_END + 0x0070, // Size: 14, Type: BYTES, Flags: PUBLIC - UNIT_FIELD_AURAAPPLICATIONS = OBJECT_END + 0x007E, // Size: 14, Type: BYTES, Flags: PUBLIC - UNIT_FIELD_AURASTATE = OBJECT_END + 0x008C, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_BASEATTACKTIME = OBJECT_END + 0x008D, // Size: 2, Type: INT, Flags: PUBLIC - - // custom - UNIT_FIELD_OFFHANDATTACKTIME = UNIT_FIELD_BASEATTACKTIME + 1, - - UNIT_FIELD_RANGEDATTACKTIME = OBJECT_END + 0x008F, // Size: 1, Type: INT, Flags: PRIVATE - UNIT_FIELD_BOUNDINGRADIUS = OBJECT_END + 0x0090, // Size: 1, Type: FLOAT, Flags: PUBLIC - UNIT_FIELD_COMBATREACH = OBJECT_END + 0x0091, // Size: 1, Type: FLOAT, Flags: PUBLIC - UNIT_FIELD_DISPLAYID = OBJECT_END + 0x0092, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_NATIVEDISPLAYID = OBJECT_END + 0x0093, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_MOUNTDISPLAYID = OBJECT_END + 0x0094, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_MINDAMAGE = OBJECT_END + 0x0095, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3 - UNIT_FIELD_MAXDAMAGE = OBJECT_END + 0x0096, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3 - UNIT_FIELD_MINOFFHANDDAMAGE = OBJECT_END + 0x0097, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3 - UNIT_FIELD_MAXOFFHANDDAMAGE = OBJECT_END + 0x0098, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3 - UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0099, // Size: 1, Type: BYTES, Flags: PUBLIC - UNIT_FIELD_PETNUMBER = OBJECT_END + 0x009A, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_PET_NAME_TIMESTAMP = OBJECT_END + 0x009B, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_FIELD_PETEXPERIENCE = OBJECT_END + 0x009C, // Size: 1, Type: INT, Flags: OWNER_ONLY - UNIT_FIELD_PETNEXTLEVELEXP = OBJECT_END + 0x009D, // Size: 1, Type: INT, Flags: OWNER_ONLY - UNIT_DYNAMIC_FLAGS = OBJECT_END + 0x009E, // Size: 1, Type: INT, Flags: DYNAMIC - UNIT_CHANNEL_SPELL = OBJECT_END + 0x009F, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_MOD_CAST_SPEED = OBJECT_END + 0x00A0, // Size: 1, Type: FLOAT, Flags: PUBLIC - UNIT_CREATED_BY_SPELL = OBJECT_END + 0x00A1, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_NPC_FLAGS = OBJECT_END + 0x00A2, // Size: 1, Type: INT, Flags: DYNAMIC - UNIT_NPC_EMOTESTATE = OBJECT_END + 0x00A3, // Size: 1, Type: INT, Flags: PUBLIC - UNIT_TRAINING_POINTS = OBJECT_END + 0x00A4, // Size: 1, Type: TWO_SHORT, Flags: OWNER_ONLY - UNIT_FIELD_STAT0 = OBJECT_END + 0x00A5, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_STAT1 = OBJECT_END + 0x00A6, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_STAT2 = OBJECT_END + 0x00A7, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_STAT3 = OBJECT_END + 0x00A8, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_STAT4 = OBJECT_END + 0x00A9, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_POSSTAT0 = OBJECT_END + 0x00AA, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_POSSTAT1 = OBJECT_END + 0x00AB, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_POSSTAT2 = OBJECT_END + 0x00AC, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_POSSTAT3 = OBJECT_END + 0x00AD, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_POSSTAT4 = OBJECT_END + 0x00AE, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_NEGSTAT0 = OBJECT_END + 0x00AF, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_NEGSTAT1 = OBJECT_END + 0x00B0, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_NEGSTAT2 = OBJECT_END + 0x00B1, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_NEGSTAT3 = OBJECT_END + 0x00B2, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_NEGSTAT4 = OBJECT_END + 0x00B3, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_RESISTANCES = OBJECT_END + 0x00B4, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY, UNK3 - UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE = OBJECT_END + 0x00BB, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE = OBJECT_END + 0x00C2, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_BASE_MANA = OBJECT_END + 0x00C9, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_BASE_HEALTH = OBJECT_END + 0x00CA, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_BYTES_2 = OBJECT_END + 0x00CB, // Size: 1, Type: BYTES, Flags: PUBLIC - UNIT_FIELD_ATTACK_POWER = OBJECT_END + 0x00CC, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_ATTACK_POWER_MODS = OBJECT_END + 0x00CD, // Size: 1, Type: TWO_SHORT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_ATTACK_POWER_MULTIPLIER = OBJECT_END + 0x00CE, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_RANGED_ATTACK_POWER = OBJECT_END + 0x00CF, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_RANGED_ATTACK_POWER_MODS = OBJECT_END + 0x00D0, // Size: 1, Type: TWO_SHORT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = OBJECT_END + 0x00D1, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_MINRANGEDDAMAGE = OBJECT_END + 0x00D2, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_MAXRANGEDDAMAGE = OBJECT_END + 0x00D3, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_POWER_COST_MODIFIER = OBJECT_END + 0x00D4, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY - UNIT_FIELD_POWER_COST_MULTIPLIER = OBJECT_END + 0x00DB, // Size: 7, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY - UNIT_END = OBJECT_END + 0x00E2, - - PLAYER_DUEL_ARBITER = UNIT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_FLAGS = UNIT_END + 0x0002, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_GUILDID = UNIT_END + 0x0003, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_GUILDRANK = UNIT_END + 0x0004, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_BYTES = UNIT_END + 0x0005, // Size: 1, Type: BYTES, Flags: PUBLIC - PLAYER_BYTES_2 = UNIT_END + 0x0006, // Size: 1, Type: BYTES, Flags: PUBLIC - PLAYER_BYTES_3 = UNIT_END + 0x0007, // Size: 1, Type: BYTES, Flags: PUBLIC - PLAYER_DUEL_TEAM = UNIT_END + 0x0008, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_GUILD_TIMESTAMP = UNIT_END + 0x0009, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_QUEST_LOG_1_1 = UNIT_END + 0x000A, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_1_2 = UNIT_END + 0x000B, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_2_1 = UNIT_END + 0x000D, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_2_2 = UNIT_END + 0x000E, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_3_1 = UNIT_END + 0x0010, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_3_2 = UNIT_END + 0x0011, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_4_1 = UNIT_END + 0x0013, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_4_2 = UNIT_END + 0x0014, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_5_1 = UNIT_END + 0x0016, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_5_2 = UNIT_END + 0x0017, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_6_1 = UNIT_END + 0x0019, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_6_2 = UNIT_END + 0x001A, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_7_1 = UNIT_END + 0x001C, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_7_2 = UNIT_END + 0x001D, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_8_1 = UNIT_END + 0x001F, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_8_2 = UNIT_END + 0x0020, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_9_1 = UNIT_END + 0x0022, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_9_2 = UNIT_END + 0x0023, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_10_1 = UNIT_END + 0x0025, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_10_2 = UNIT_END + 0x0026, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_11_1 = UNIT_END + 0x0028, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_11_2 = UNIT_END + 0x0029, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_12_1 = UNIT_END + 0x002B, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_12_2 = UNIT_END + 0x002C, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_13_1 = UNIT_END + 0x002E, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_13_2 = UNIT_END + 0x002F, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_14_1 = UNIT_END + 0x0031, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_14_2 = UNIT_END + 0x0032, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_15_1 = UNIT_END + 0x0034, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_15_2 = UNIT_END + 0x0035, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_16_1 = UNIT_END + 0x0037, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_16_2 = UNIT_END + 0x0038, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_17_1 = UNIT_END + 0x003A, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_17_2 = UNIT_END + 0x003B, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_18_1 = UNIT_END + 0x003D, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_18_2 = UNIT_END + 0x003E, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_19_1 = UNIT_END + 0x0040, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_19_2 = UNIT_END + 0x0041, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_20_1 = UNIT_END + 0x0043, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_20_2 = UNIT_END + 0x0044, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_21_1 = UNIT_END + 0x0046, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_21_2 = UNIT_END + 0x0047, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_22_1 = UNIT_END + 0x0049, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_22_2 = UNIT_END + 0x004A, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_23_1 = UNIT_END + 0x004C, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_23_2 = UNIT_END + 0x004D, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_24_1 = UNIT_END + 0x004F, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_24_2 = UNIT_END + 0x0050, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_QUEST_LOG_25_1 = UNIT_END + 0x0052, // Size: 1, Type: INT, Flags: GROUP_ONLY - PLAYER_QUEST_LOG_25_2 = UNIT_END + 0x0053, // Size: 2, Type: INT, Flags: PRIVATE - PLAYER_VISIBLE_ITEM_1_CREATOR = UNIT_END + 0x0055, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_1_0 = UNIT_END + 0x0057, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_1_PROPERTIES = UNIT_END + 0x0063, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_1_PAD = UNIT_END + 0x0064, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_2_CREATOR = UNIT_END + 0x0065, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_2_0 = UNIT_END + 0x0067, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_2_PROPERTIES = UNIT_END + 0x0073, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_2_PAD = UNIT_END + 0x0074, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_3_CREATOR = UNIT_END + 0x0075, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_3_0 = UNIT_END + 0x0077, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_3_PROPERTIES = UNIT_END + 0x0083, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_3_PAD = UNIT_END + 0x0084, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_4_CREATOR = UNIT_END + 0x0085, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_4_0 = UNIT_END + 0x0087, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_4_PROPERTIES = UNIT_END + 0x0093, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_4_PAD = UNIT_END + 0x0094, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_5_CREATOR = UNIT_END + 0x0095, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_5_0 = UNIT_END + 0x0097, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_5_PROPERTIES = UNIT_END + 0x00A3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_5_PAD = UNIT_END + 0x00A4, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_6_CREATOR = UNIT_END + 0x00A5, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_6_0 = UNIT_END + 0x00A7, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_6_PROPERTIES = UNIT_END + 0x00B3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_6_PAD = UNIT_END + 0x00B4, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_7_CREATOR = UNIT_END + 0x00B5, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_7_0 = UNIT_END + 0x00B7, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_7_PROPERTIES = UNIT_END + 0x00C3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_7_PAD = UNIT_END + 0x00C4, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_8_CREATOR = UNIT_END + 0x00C5, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_8_0 = UNIT_END + 0x00C7, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_8_PROPERTIES = UNIT_END + 0x00D3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_8_PAD = UNIT_END + 0x00D4, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_9_CREATOR = UNIT_END + 0x00D5, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_9_0 = UNIT_END + 0x00D7, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_9_PROPERTIES = UNIT_END + 0x00E3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_9_PAD = UNIT_END + 0x00E4, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_10_CREATOR = UNIT_END + 0x00E5, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_10_0 = UNIT_END + 0x00E7, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_10_PROPERTIES = UNIT_END + 0x00F3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_10_PAD = UNIT_END + 0x00F4, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_11_CREATOR = UNIT_END + 0x00F5, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_11_0 = UNIT_END + 0x00F7, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_11_PROPERTIES = UNIT_END + 0x0103, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_11_PAD = UNIT_END + 0x0104, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_12_CREATOR = UNIT_END + 0x0105, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_12_0 = UNIT_END + 0x0107, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_12_PROPERTIES = UNIT_END + 0x0113, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_12_PAD = UNIT_END + 0x0114, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_13_CREATOR = UNIT_END + 0x0115, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_13_0 = UNIT_END + 0x0117, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_13_PROPERTIES = UNIT_END + 0x0123, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_13_PAD = UNIT_END + 0x0124, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_14_CREATOR = UNIT_END + 0x0125, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_14_0 = UNIT_END + 0x0127, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_14_PROPERTIES = UNIT_END + 0x0133, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_14_PAD = UNIT_END + 0x0134, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_15_CREATOR = UNIT_END + 0x0135, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_15_0 = UNIT_END + 0x0137, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_15_PROPERTIES = UNIT_END + 0x0143, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_15_PAD = UNIT_END + 0x0144, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_16_CREATOR = UNIT_END + 0x0145, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_16_0 = UNIT_END + 0x0147, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_16_PROPERTIES = UNIT_END + 0x0153, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_16_PAD = UNIT_END + 0x0154, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_17_CREATOR = UNIT_END + 0x0155, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_17_0 = UNIT_END + 0x0157, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_17_PROPERTIES = UNIT_END + 0x0163, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_17_PAD = UNIT_END + 0x0164, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_18_CREATOR = UNIT_END + 0x0165, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_18_0 = UNIT_END + 0x0167, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_18_PROPERTIES = UNIT_END + 0x0173, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_18_PAD = UNIT_END + 0x0174, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_19_CREATOR = UNIT_END + 0x0175, // Size: 2, Type: LONG, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_19_0 = UNIT_END + 0x0177, // Size: 12, Type: INT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_19_PROPERTIES = UNIT_END + 0x0183, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC - PLAYER_VISIBLE_ITEM_19_PAD = UNIT_END + 0x0184, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_CHOSEN_TITLE = UNIT_END + 0x0185, // Size: 1, Type: INT, Flags: PUBLIC - PLAYER_FIELD_INV_SLOT_HEAD = UNIT_END + 0x0186, // Size: 46, Type: LONG, Flags: PRIVATE - PLAYER_FIELD_PACK_SLOT_1 = UNIT_END + 0x01B4, // Size: 32, Type: LONG, Flags: PRIVATE - PLAYER_FIELD_BANK_SLOT_1 = UNIT_END + 0x01D4, // Size: 56, Type: LONG, Flags: PRIVATE - PLAYER_FIELD_BANKBAG_SLOT_1 = UNIT_END + 0x020C, // Size: 14, Type: LONG, Flags: PRIVATE - PLAYER_FIELD_VENDORBUYBACK_SLOT_1 = UNIT_END + 0x021A, // Size: 24, Type: LONG, Flags: PRIVATE - PLAYER_FIELD_KEYRING_SLOT_1 = UNIT_END + 0x0232, // Size: 64, Type: LONG, Flags: PRIVATE - PLAYER_FARSIGHT = UNIT_END + 0x0272, // Size: 2, Type: LONG, Flags: PRIVATE - PLAYER__FIELD_KNOWN_TITLES = UNIT_END + 0x0274, // Size: 2, Type: LONG, Flags: PRIVATE - PLAYER_XP = UNIT_END + 0x0276, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_NEXT_LEVEL_XP = UNIT_END + 0x0277, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_SKILL_INFO_1_1 = UNIT_END + 0x0278, // Size: 384, Type: TWO_SHORT, Flags: PRIVATE - PLAYER_CHARACTER_POINTS1 = UNIT_END + 0x03F8, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_CHARACTER_POINTS2 = UNIT_END + 0x03F9, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_TRACK_CREATURES = UNIT_END + 0x03FA, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_TRACK_RESOURCES = UNIT_END + 0x03FB, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_BLOCK_PERCENTAGE = UNIT_END + 0x03FC, // Size: 1, Type: FLOAT, Flags: PRIVATE - PLAYER_DODGE_PERCENTAGE = UNIT_END + 0x03FD, // Size: 1, Type: FLOAT, Flags: PRIVATE - PLAYER_PARRY_PERCENTAGE = UNIT_END + 0x03FE, // Size: 1, Type: FLOAT, Flags: PRIVATE - PLAYER_EXPERTISE = UNIT_END + 0x03FF, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_CRIT_PERCENTAGE = UNIT_END + 0x0400, // Size: 1, Type: FLOAT, Flags: PRIVATE - PLAYER_RANGED_CRIT_PERCENTAGE = UNIT_END + 0x0401, // Size: 1, Type: FLOAT, Flags: PRIVATE - PLAYER_OFFHAND_CRIT_PERCENTAGE = UNIT_END + 0x0402, // Size: 1, Type: FLOAT, Flags: PRIVATE - PLAYER_SPELL_CRIT_PERCENTAGE1 = UNIT_END + 0x0403, // Size: 7, Type: FLOAT, Flags: PRIVATE - - // custom - PLAYER_HOLY_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+1, - PLAYER_FIRE_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+2, - PLAYER_NATURE_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+3, - PLAYER_FROST_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+4, - PLAYER_SHADOW_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+5, - PLAYER_ARCANE_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+6, - - PLAYER_SHIELD_BLOCK = UNIT_END + 0x040A, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_EXPLORED_ZONES_1 = UNIT_END + 0x040B, // Size: 64, Type: BYTES, Flags: PRIVATE - PLAYER_REST_STATE_EXPERIENCE = UNIT_END + 0x044B, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_FIELD_COINAGE = UNIT_END + 0x044C, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_FIELD_MOD_DAMAGE_DONE_POS = UNIT_END + 0x044D, // Size: 7, Type: INT, Flags: PRIVATE - PLAYER_FIELD_MOD_DAMAGE_DONE_NEG = UNIT_END + 0x0454, // Size: 7, Type: INT, Flags: PRIVATE - PLAYER_FIELD_MOD_DAMAGE_DONE_PCT = UNIT_END + 0x045B, // Size: 7, Type: INT, Flags: PRIVATE - PLAYER_FIELD_MOD_HEALING_DONE_POS = UNIT_END + 0x0462, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_FIELD_MOD_TARGET_RESISTANCE = UNIT_END + 0x0463, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_FIELD_BYTES = UNIT_END + 0x0464, // Size: 1, Type: BYTES, Flags: PRIVATE - PLAYER_AMMO_ID = UNIT_END + 0x0465, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_SELF_RES_SPELL = UNIT_END + 0x0466, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_FIELD_PVP_MEDALS = UNIT_END + 0x0467, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_FIELD_BUYBACK_PRICE_1 = UNIT_END + 0x0468, // Size: 12, Type: INT, Flags: PRIVATE - PLAYER_FIELD_BUYBACK_TIMESTAMP_1 = UNIT_END + 0x0474, // Size: 12, Type: INT, Flags: PRIVATE - PLAYER_FIELD_KILLS = UNIT_END + 0x0480, // Size: 1, Type: TWO_SHORT, Flags: PRIVATE - PLAYER_FIELD_TODAY_CONTRIBUTION = UNIT_END + 0x0481, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_FIELD_YESTERDAY_CONTRIBUTION = UNIT_END + 0x0482, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_FIELD_LIFETIME_HONORBALE_KILLS = UNIT_END + 0x0483, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_FIELD_BYTES2 = UNIT_END + 0x0484, // Size: 1, Type: BYTES, Flags: PRIVATE - PLAYER_FIELD_WATCHED_FACTION_INDEX = UNIT_END + 0x0485, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_FIELD_COMBAT_RATING_1 = UNIT_END + 0x0486, // Size: 24, Type: INT, Flags: PRIVATE - - // custom // client names: - // CR_WEAPON_SKILL - PLAYER_FIELD_ALL_WEAPONS_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1, - // CR_DEFENSE_SKILL - PLAYER_FIELD_DEFENCE_RATING = PLAYER_FIELD_COMBAT_RATING_1+1, - // CR_DODGE - PLAYER_FIELD_DODGE_RATING = PLAYER_FIELD_COMBAT_RATING_1+2, - // CR_PARRY - PLAYER_FIELD_PARRY_RATING = PLAYER_FIELD_COMBAT_RATING_1+3, - // CR_BLOCK - PLAYER_FIELD_BLOCK_RATING = PLAYER_FIELD_COMBAT_RATING_1+4, - // CR_HIT_MELEE - PLAYER_FIELD_MELEE_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+5, - // CR_HIT_RANGED - PLAYER_FIELD_RANGED_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+6, - // CR_HIT_SPELL - PLAYER_FIELD_SPELL_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+7, - // CR_CRIT_MELEE - PLAYER_FIELD_MELEE_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+8, - // CR_CRIT_RANGED - PLAYER_FIELD_RANGED_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+9, - // CR_CRIT_SPELL - PLAYER_FIELD_SPELL_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+10, - // CR_HIT_TAKEN_MELEE - PLAYER_FIELD_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+11, - // CR_HIT_TAKEN_RANGED - PLAYER_FIELD_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+12, - // CR_HIT_TAKEN_SPELL - PLAYER_FIELD_UNK3_RATING = PLAYER_FIELD_COMBAT_RATING_1+13, - // CR_CRIT_TAKEN_MELEE - PLAYER_FIELD_UNK4_RATING = PLAYER_FIELD_COMBAT_RATING_1+14, - // CR_CRIT_TAKEN_RANGED - PLAYER_FIELD_UNK5_RATING = PLAYER_FIELD_COMBAT_RATING_1+15, - // CR_CRIT_TAKEN_SPELL - PLAYER_FIELD_RESILIENCE_RATING = PLAYER_FIELD_COMBAT_RATING_1+16, - // CR_HASTE_MELEE - PLAYER_FIELD_MELEE_HASTE_RATING = PLAYER_FIELD_COMBAT_RATING_1+17, - // CR_HASTE_RANGED - PLAYER_FIELD_RANGED_HASTE_RATING = PLAYER_FIELD_COMBAT_RATING_1+18, - // CR_HASTE_SPELL - PLAYER_FIELD_SPELL_HASTE_RATING = PLAYER_FIELD_COMBAT_RATING_1+19, - // CR_WEAPON_SKILL_MAINHAND - PLAYER_FIELD_MELEE_WEAPON_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1+20, - // CR_WEAPON_SKILL_OFFHAND - PLAYER_FIELD_OFFHAND_WEAPON_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1+21, - // CR_WEAPON_SKILL_RANGED - PLAYER_FIELD_RANGED_WEAPON_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1+22, - // CR_EXPERTISE - PLAYER_FIELD_EXPERTISE_RATING = PLAYER_FIELD_COMBAT_RATING_1+23, - - PLAYER_FIELD_ARENA_TEAM_INFO_1_1 = UNIT_END + 0x049E, // Size: 18, Type: INT, Flags: PRIVATE - - // custom - PLAYER_FIELD_ARENA_TEAM_ID_2v2 = PLAYER_FIELD_ARENA_TEAM_INFO_1_1, - PLAYER_FIELD_ARENA_TEAM_ID_3v3 = PLAYER_FIELD_ARENA_TEAM_INFO_1_1+6, - PLAYER_FIELD_ARENA_TEAM_ID_5v5 = PLAYER_FIELD_ARENA_TEAM_INFO_1_1+12, - - PLAYER_FIELD_HONOR_CURRENCY = UNIT_END + 0x04B0, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_FIELD_ARENA_CURRENCY = UNIT_END + 0x04B1, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_FIELD_MOD_MANA_REGEN = UNIT_END + 0x04B2, // Size: 1, Type: FLOAT, Flags: PRIVATE - PLAYER_FIELD_MOD_MANA_REGEN_INTERRUPT = UNIT_END + 0x04B3, // Size: 1, Type: FLOAT, Flags: PRIVATE - PLAYER_FIELD_MAX_LEVEL = UNIT_END + 0x04B4, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_FIELD_DAILY_QUESTS_1 = UNIT_END + 0x04B5, // Size: 10, Type: INT, Flags: PRIVATE - PLAYER_FIELD_PADDING = UNIT_END + 0x04BF, // Size: 1, Type: INT, Flags: NONE - PLAYER_END = UNIT_END + 0x04C0, -}; - -enum EGameObjectFields -{ - OBJECT_FIELD_CREATED_BY = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC - GAMEOBJECT_DISPLAYID = OBJECT_END + 0x0002, // Size: 1, Type: INT, Flags: PUBLIC - GAMEOBJECT_FLAGS = OBJECT_END + 0x0003, // Size: 1, Type: INT, Flags: PUBLIC - GAMEOBJECT_ROTATION = OBJECT_END + 0x0004, // Size: 4, Type: FLOAT, Flags: PUBLIC - GAMEOBJECT_STATE = OBJECT_END + 0x0008, // Size: 1, Type: INT, Flags: PUBLIC - GAMEOBJECT_POS_X = OBJECT_END + 0x0009, // Size: 1, Type: FLOAT, Flags: PUBLIC - GAMEOBJECT_POS_Y = OBJECT_END + 0x000A, // Size: 1, Type: FLOAT, Flags: PUBLIC - GAMEOBJECT_POS_Z = OBJECT_END + 0x000B, // Size: 1, Type: FLOAT, Flags: PUBLIC - GAMEOBJECT_FACING = OBJECT_END + 0x000C, // Size: 1, Type: FLOAT, Flags: PUBLIC - GAMEOBJECT_DYN_FLAGS = OBJECT_END + 0x000D, // Size: 1, Type: INT, Flags: DYNAMIC - GAMEOBJECT_FACTION = OBJECT_END + 0x000E, // Size: 1, Type: INT, Flags: PUBLIC - GAMEOBJECT_TYPE_ID = OBJECT_END + 0x000F, // Size: 1, Type: INT, Flags: PUBLIC - GAMEOBJECT_LEVEL = OBJECT_END + 0x0010, // Size: 1, Type: INT, Flags: PUBLIC - GAMEOBJECT_ARTKIT = OBJECT_END + 0x0011, // Size: 1, Type: INT, Flags: PUBLIC - GAMEOBJECT_ANIMPROGRESS = OBJECT_END + 0x0012, // Size: 1, Type: INT, Flags: DYNAMIC - GAMEOBJECT_PADDING = OBJECT_END + 0x0013, // Size: 1, Type: INT, Flags: NONE - GAMEOBJECT_END = OBJECT_END + 0x0014, -}; - -enum EDynamicObjectFields -{ - DYNAMICOBJECT_CASTER = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC - DYNAMICOBJECT_BYTES = OBJECT_END + 0x0002, // Size: 1, Type: BYTES, Flags: PUBLIC - DYNAMICOBJECT_SPELLID = OBJECT_END + 0x0003, // Size: 1, Type: INT, Flags: PUBLIC - DYNAMICOBJECT_RADIUS = OBJECT_END + 0x0004, // Size: 1, Type: FLOAT, Flags: PUBLIC - DYNAMICOBJECT_POS_X = OBJECT_END + 0x0005, // Size: 1, Type: FLOAT, Flags: PUBLIC - DYNAMICOBJECT_POS_Y = OBJECT_END + 0x0006, // Size: 1, Type: FLOAT, Flags: PUBLIC - DYNAMICOBJECT_POS_Z = OBJECT_END + 0x0007, // Size: 1, Type: FLOAT, Flags: PUBLIC - DYNAMICOBJECT_FACING = OBJECT_END + 0x0008, // Size: 1, Type: FLOAT, Flags: PUBLIC - DYNAMICOBJECT_PAD = OBJECT_END + 0x0009, // Size: 1, Type: BYTES, Flags: PUBLIC - DYNAMICOBJECT_END = OBJECT_END + 0x000A, -}; - -enum ECorpseFields -{ - CORPSE_FIELD_OWNER = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC - CORPSE_FIELD_FACING = OBJECT_END + 0x0002, // Size: 1, Type: FLOAT, Flags: PUBLIC - CORPSE_FIELD_POS_X = OBJECT_END + 0x0003, // Size: 1, Type: FLOAT, Flags: PUBLIC - CORPSE_FIELD_POS_Y = OBJECT_END + 0x0004, // Size: 1, Type: FLOAT, Flags: PUBLIC - CORPSE_FIELD_POS_Z = OBJECT_END + 0x0005, // Size: 1, Type: FLOAT, Flags: PUBLIC - CORPSE_FIELD_DISPLAY_ID = OBJECT_END + 0x0006, // Size: 1, Type: INT, Flags: PUBLIC - CORPSE_FIELD_ITEM = OBJECT_END + 0x0007, // Size: 19, Type: INT, Flags: PUBLIC - CORPSE_FIELD_BYTES_1 = OBJECT_END + 0x001A, // Size: 1, Type: BYTES, Flags: PUBLIC - CORPSE_FIELD_BYTES_2 = OBJECT_END + 0x001B, // Size: 1, Type: BYTES, Flags: PUBLIC - CORPSE_FIELD_GUILD = OBJECT_END + 0x001C, // Size: 1, Type: INT, Flags: PUBLIC - CORPSE_FIELD_FLAGS = OBJECT_END + 0x001D, // Size: 1, Type: INT, Flags: PUBLIC - CORPSE_FIELD_DYNAMIC_FLAGS = OBJECT_END + 0x001E, // Size: 1, Type: INT, Flags: DYNAMIC - CORPSE_FIELD_PAD = OBJECT_END + 0x001F, // Size: 1, Type: INT, Flags: NONE - CORPSE_END = OBJECT_END + 0x0020, -}; -#endif +/* + * Copyright (C) 2005,2006,2007 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _UPDATEFIELDS_AUTO_H +#define _UPDATEFIELDS_AUTO_H + +// Auto generated for version 0, 3, 2, 7655 + +enum EObjectFields +{ + OBJECT_FIELD_GUID = 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC + OBJECT_FIELD_TYPE = 0x0002, // Size: 1, Type: INT, Flags: PUBLIC + OBJECT_FIELD_ENTRY = 0x0003, // Size: 1, Type: INT, Flags: PUBLIC + OBJECT_FIELD_SCALE_X = 0x0004, // Size: 1, Type: FLOAT, Flags: PUBLIC + OBJECT_FIELD_PADDING = 0x0005, // Size: 1, Type: INT, Flags: NONE + OBJECT_END = 0x0006, +}; + +enum EItemFields +{ + ITEM_FIELD_OWNER = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC + ITEM_FIELD_CONTAINED = OBJECT_END + 0x0002, // Size: 2, Type: LONG, Flags: PUBLIC + ITEM_FIELD_CREATOR = OBJECT_END + 0x0004, // Size: 2, Type: LONG, Flags: PUBLIC + ITEM_FIELD_GIFTCREATOR = OBJECT_END + 0x0006, // Size: 2, Type: LONG, Flags: PUBLIC + ITEM_FIELD_STACK_COUNT = OBJECT_END + 0x0008, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2 + ITEM_FIELD_DURATION = OBJECT_END + 0x0009, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2 + ITEM_FIELD_SPELL_CHARGES = OBJECT_END + 0x000A, // Size: 5, Type: INT, Flags: OWNER_ONLY, UNK2 + ITEM_FIELD_FLAGS = OBJECT_END + 0x000F, // Size: 1, Type: INT, Flags: PUBLIC + ITEM_FIELD_ENCHANTMENT = OBJECT_END + 0x0010, // Size: 33, Type: INT, Flags: PUBLIC + ITEM_FIELD_PROPERTY_SEED = OBJECT_END + 0x0031, // Size: 1, Type: INT, Flags: PUBLIC + + // custom + ITEM_FIELD_SUFFIX_FACTOR = ITEM_FIELD_PROPERTY_SEED, + + ITEM_FIELD_RANDOM_PROPERTIES_ID = OBJECT_END + 0x0032, // Size: 1, Type: INT, Flags: PUBLIC + ITEM_FIELD_ITEM_TEXT_ID = OBJECT_END + 0x0033, // Size: 1, Type: INT, Flags: OWNER_ONLY + ITEM_FIELD_DURABILITY = OBJECT_END + 0x0034, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2 + ITEM_FIELD_MAXDURABILITY = OBJECT_END + 0x0035, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2 + ITEM_END = OBJECT_END + 0x0036, +}; + +enum EContainerFields +{ + CONTAINER_FIELD_NUM_SLOTS = ITEM_END + 0x0000, // Size: 1, Type: INT, Flags: PUBLIC + CONTAINER_ALIGN_PAD = ITEM_END + 0x0001, // Size: 1, Type: BYTES, Flags: NONE + CONTAINER_FIELD_SLOT_1 = ITEM_END + 0x0002, // Size: 72, Type: LONG, Flags: PUBLIC + CONTAINER_END = ITEM_END + 0x004A, +}; + +enum EUnitFields +{ + UNIT_FIELD_CHARM = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC + UNIT_FIELD_SUMMON = OBJECT_END + 0x0002, // Size: 2, Type: LONG, Flags: PUBLIC + UNIT_FIELD_CHARMEDBY = OBJECT_END + 0x0004, // Size: 2, Type: LONG, Flags: PUBLIC + UNIT_FIELD_SUMMONEDBY = OBJECT_END + 0x0006, // Size: 2, Type: LONG, Flags: PUBLIC + UNIT_FIELD_CREATEDBY = OBJECT_END + 0x0008, // Size: 2, Type: LONG, Flags: PUBLIC + UNIT_FIELD_TARGET = OBJECT_END + 0x000A, // Size: 2, Type: LONG, Flags: PUBLIC + UNIT_FIELD_PERSUADED = OBJECT_END + 0x000C, // Size: 2, Type: LONG, Flags: PUBLIC + UNIT_FIELD_CHANNEL_OBJECT = OBJECT_END + 0x000E, // Size: 2, Type: LONG, Flags: PUBLIC + UNIT_FIELD_HEALTH = OBJECT_END + 0x0010, // Size: 1, Type: INT, Flags: DYNAMIC + UNIT_FIELD_POWER1 = OBJECT_END + 0x0011, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_POWER2 = OBJECT_END + 0x0012, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_POWER3 = OBJECT_END + 0x0013, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_POWER4 = OBJECT_END + 0x0014, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_POWER5 = OBJECT_END + 0x0015, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_MAXHEALTH = OBJECT_END + 0x0016, // Size: 1, Type: INT, Flags: DYNAMIC + UNIT_FIELD_MAXPOWER1 = OBJECT_END + 0x0017, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_MAXPOWER2 = OBJECT_END + 0x0018, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_MAXPOWER3 = OBJECT_END + 0x0019, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_MAXPOWER4 = OBJECT_END + 0x001A, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_MAXPOWER5 = OBJECT_END + 0x001B, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_LEVEL = OBJECT_END + 0x001C, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_FACTIONTEMPLATE = OBJECT_END + 0x001D, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_BYTES_0 = OBJECT_END + 0x001E, // Size: 1, Type: BYTES, Flags: PUBLIC + UNIT_VIRTUAL_ITEM_SLOT_DISPLAY = OBJECT_END + 0x001F, // Size: 3, Type: INT, Flags: PUBLIC + UNIT_VIRTUAL_ITEM_INFO = OBJECT_END + 0x0022, // Size: 6, Type: BYTES, Flags: PUBLIC + UNIT_FIELD_FLAGS = OBJECT_END + 0x0028, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_FLAGS_2 = OBJECT_END + 0x0029, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_AURA = OBJECT_END + 0x002A, // Size: 56, Type: INT, Flags: PUBLIC + UNIT_FIELD_AURAFLAGS = OBJECT_END + 0x0062, // Size: 14, Type: BYTES, Flags: PUBLIC + UNIT_FIELD_AURALEVELS = OBJECT_END + 0x0070, // Size: 14, Type: BYTES, Flags: PUBLIC + UNIT_FIELD_AURAAPPLICATIONS = OBJECT_END + 0x007E, // Size: 14, Type: BYTES, Flags: PUBLIC + UNIT_FIELD_AURASTATE = OBJECT_END + 0x008C, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_BASEATTACKTIME = OBJECT_END + 0x008D, // Size: 2, Type: INT, Flags: PUBLIC + + // custom + UNIT_FIELD_OFFHANDATTACKTIME = UNIT_FIELD_BASEATTACKTIME + 1, + + UNIT_FIELD_RANGEDATTACKTIME = OBJECT_END + 0x008F, // Size: 1, Type: INT, Flags: PRIVATE + UNIT_FIELD_BOUNDINGRADIUS = OBJECT_END + 0x0090, // Size: 1, Type: FLOAT, Flags: PUBLIC + UNIT_FIELD_COMBATREACH = OBJECT_END + 0x0091, // Size: 1, Type: FLOAT, Flags: PUBLIC + UNIT_FIELD_DISPLAYID = OBJECT_END + 0x0092, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_NATIVEDISPLAYID = OBJECT_END + 0x0093, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_MOUNTDISPLAYID = OBJECT_END + 0x0094, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_MINDAMAGE = OBJECT_END + 0x0095, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3 + UNIT_FIELD_MAXDAMAGE = OBJECT_END + 0x0096, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3 + UNIT_FIELD_MINOFFHANDDAMAGE = OBJECT_END + 0x0097, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3 + UNIT_FIELD_MAXOFFHANDDAMAGE = OBJECT_END + 0x0098, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3 + UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0099, // Size: 1, Type: BYTES, Flags: PUBLIC + UNIT_FIELD_PETNUMBER = OBJECT_END + 0x009A, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_PET_NAME_TIMESTAMP = OBJECT_END + 0x009B, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_FIELD_PETEXPERIENCE = OBJECT_END + 0x009C, // Size: 1, Type: INT, Flags: OWNER_ONLY + UNIT_FIELD_PETNEXTLEVELEXP = OBJECT_END + 0x009D, // Size: 1, Type: INT, Flags: OWNER_ONLY + UNIT_DYNAMIC_FLAGS = OBJECT_END + 0x009E, // Size: 1, Type: INT, Flags: DYNAMIC + UNIT_CHANNEL_SPELL = OBJECT_END + 0x009F, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_MOD_CAST_SPEED = OBJECT_END + 0x00A0, // Size: 1, Type: FLOAT, Flags: PUBLIC + UNIT_CREATED_BY_SPELL = OBJECT_END + 0x00A1, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_NPC_FLAGS = OBJECT_END + 0x00A2, // Size: 1, Type: INT, Flags: DYNAMIC + UNIT_NPC_EMOTESTATE = OBJECT_END + 0x00A3, // Size: 1, Type: INT, Flags: PUBLIC + UNIT_TRAINING_POINTS = OBJECT_END + 0x00A4, // Size: 1, Type: TWO_SHORT, Flags: OWNER_ONLY + UNIT_FIELD_STAT0 = OBJECT_END + 0x00A5, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_STAT1 = OBJECT_END + 0x00A6, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_STAT2 = OBJECT_END + 0x00A7, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_STAT3 = OBJECT_END + 0x00A8, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_STAT4 = OBJECT_END + 0x00A9, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_POSSTAT0 = OBJECT_END + 0x00AA, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_POSSTAT1 = OBJECT_END + 0x00AB, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_POSSTAT2 = OBJECT_END + 0x00AC, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_POSSTAT3 = OBJECT_END + 0x00AD, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_POSSTAT4 = OBJECT_END + 0x00AE, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_NEGSTAT0 = OBJECT_END + 0x00AF, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_NEGSTAT1 = OBJECT_END + 0x00B0, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_NEGSTAT2 = OBJECT_END + 0x00B1, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_NEGSTAT3 = OBJECT_END + 0x00B2, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_NEGSTAT4 = OBJECT_END + 0x00B3, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_RESISTANCES = OBJECT_END + 0x00B4, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY, UNK3 + UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE = OBJECT_END + 0x00BB, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE = OBJECT_END + 0x00C2, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_BASE_MANA = OBJECT_END + 0x00C9, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_BASE_HEALTH = OBJECT_END + 0x00CA, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_BYTES_2 = OBJECT_END + 0x00CB, // Size: 1, Type: BYTES, Flags: PUBLIC + UNIT_FIELD_ATTACK_POWER = OBJECT_END + 0x00CC, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_ATTACK_POWER_MODS = OBJECT_END + 0x00CD, // Size: 1, Type: TWO_SHORT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_ATTACK_POWER_MULTIPLIER = OBJECT_END + 0x00CE, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_RANGED_ATTACK_POWER = OBJECT_END + 0x00CF, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_RANGED_ATTACK_POWER_MODS = OBJECT_END + 0x00D0, // Size: 1, Type: TWO_SHORT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = OBJECT_END + 0x00D1, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_MINRANGEDDAMAGE = OBJECT_END + 0x00D2, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_MAXRANGEDDAMAGE = OBJECT_END + 0x00D3, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_POWER_COST_MODIFIER = OBJECT_END + 0x00D4, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY + UNIT_FIELD_POWER_COST_MULTIPLIER = OBJECT_END + 0x00DB, // Size: 7, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY + UNIT_END = OBJECT_END + 0x00E2, + + PLAYER_DUEL_ARBITER = UNIT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_FLAGS = UNIT_END + 0x0002, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_GUILDID = UNIT_END + 0x0003, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_GUILDRANK = UNIT_END + 0x0004, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_BYTES = UNIT_END + 0x0005, // Size: 1, Type: BYTES, Flags: PUBLIC + PLAYER_BYTES_2 = UNIT_END + 0x0006, // Size: 1, Type: BYTES, Flags: PUBLIC + PLAYER_BYTES_3 = UNIT_END + 0x0007, // Size: 1, Type: BYTES, Flags: PUBLIC + PLAYER_DUEL_TEAM = UNIT_END + 0x0008, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_GUILD_TIMESTAMP = UNIT_END + 0x0009, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_QUEST_LOG_1_1 = UNIT_END + 0x000A, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_1_2 = UNIT_END + 0x000B, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_2_1 = UNIT_END + 0x000D, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_2_2 = UNIT_END + 0x000E, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_3_1 = UNIT_END + 0x0010, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_3_2 = UNIT_END + 0x0011, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_4_1 = UNIT_END + 0x0013, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_4_2 = UNIT_END + 0x0014, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_5_1 = UNIT_END + 0x0016, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_5_2 = UNIT_END + 0x0017, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_6_1 = UNIT_END + 0x0019, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_6_2 = UNIT_END + 0x001A, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_7_1 = UNIT_END + 0x001C, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_7_2 = UNIT_END + 0x001D, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_8_1 = UNIT_END + 0x001F, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_8_2 = UNIT_END + 0x0020, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_9_1 = UNIT_END + 0x0022, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_9_2 = UNIT_END + 0x0023, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_10_1 = UNIT_END + 0x0025, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_10_2 = UNIT_END + 0x0026, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_11_1 = UNIT_END + 0x0028, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_11_2 = UNIT_END + 0x0029, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_12_1 = UNIT_END + 0x002B, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_12_2 = UNIT_END + 0x002C, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_13_1 = UNIT_END + 0x002E, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_13_2 = UNIT_END + 0x002F, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_14_1 = UNIT_END + 0x0031, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_14_2 = UNIT_END + 0x0032, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_15_1 = UNIT_END + 0x0034, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_15_2 = UNIT_END + 0x0035, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_16_1 = UNIT_END + 0x0037, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_16_2 = UNIT_END + 0x0038, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_17_1 = UNIT_END + 0x003A, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_17_2 = UNIT_END + 0x003B, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_18_1 = UNIT_END + 0x003D, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_18_2 = UNIT_END + 0x003E, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_19_1 = UNIT_END + 0x0040, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_19_2 = UNIT_END + 0x0041, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_20_1 = UNIT_END + 0x0043, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_20_2 = UNIT_END + 0x0044, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_21_1 = UNIT_END + 0x0046, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_21_2 = UNIT_END + 0x0047, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_22_1 = UNIT_END + 0x0049, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_22_2 = UNIT_END + 0x004A, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_23_1 = UNIT_END + 0x004C, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_23_2 = UNIT_END + 0x004D, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_24_1 = UNIT_END + 0x004F, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_24_2 = UNIT_END + 0x0050, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_QUEST_LOG_25_1 = UNIT_END + 0x0052, // Size: 1, Type: INT, Flags: GROUP_ONLY + PLAYER_QUEST_LOG_25_2 = UNIT_END + 0x0053, // Size: 2, Type: INT, Flags: PRIVATE + PLAYER_VISIBLE_ITEM_1_CREATOR = UNIT_END + 0x0055, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_1_0 = UNIT_END + 0x0057, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_1_PROPERTIES = UNIT_END + 0x0063, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_1_PAD = UNIT_END + 0x0064, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_2_CREATOR = UNIT_END + 0x0065, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_2_0 = UNIT_END + 0x0067, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_2_PROPERTIES = UNIT_END + 0x0073, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_2_PAD = UNIT_END + 0x0074, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_3_CREATOR = UNIT_END + 0x0075, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_3_0 = UNIT_END + 0x0077, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_3_PROPERTIES = UNIT_END + 0x0083, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_3_PAD = UNIT_END + 0x0084, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_4_CREATOR = UNIT_END + 0x0085, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_4_0 = UNIT_END + 0x0087, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_4_PROPERTIES = UNIT_END + 0x0093, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_4_PAD = UNIT_END + 0x0094, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_5_CREATOR = UNIT_END + 0x0095, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_5_0 = UNIT_END + 0x0097, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_5_PROPERTIES = UNIT_END + 0x00A3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_5_PAD = UNIT_END + 0x00A4, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_6_CREATOR = UNIT_END + 0x00A5, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_6_0 = UNIT_END + 0x00A7, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_6_PROPERTIES = UNIT_END + 0x00B3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_6_PAD = UNIT_END + 0x00B4, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_7_CREATOR = UNIT_END + 0x00B5, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_7_0 = UNIT_END + 0x00B7, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_7_PROPERTIES = UNIT_END + 0x00C3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_7_PAD = UNIT_END + 0x00C4, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_8_CREATOR = UNIT_END + 0x00C5, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_8_0 = UNIT_END + 0x00C7, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_8_PROPERTIES = UNIT_END + 0x00D3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_8_PAD = UNIT_END + 0x00D4, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_9_CREATOR = UNIT_END + 0x00D5, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_9_0 = UNIT_END + 0x00D7, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_9_PROPERTIES = UNIT_END + 0x00E3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_9_PAD = UNIT_END + 0x00E4, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_10_CREATOR = UNIT_END + 0x00E5, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_10_0 = UNIT_END + 0x00E7, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_10_PROPERTIES = UNIT_END + 0x00F3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_10_PAD = UNIT_END + 0x00F4, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_11_CREATOR = UNIT_END + 0x00F5, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_11_0 = UNIT_END + 0x00F7, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_11_PROPERTIES = UNIT_END + 0x0103, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_11_PAD = UNIT_END + 0x0104, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_12_CREATOR = UNIT_END + 0x0105, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_12_0 = UNIT_END + 0x0107, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_12_PROPERTIES = UNIT_END + 0x0113, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_12_PAD = UNIT_END + 0x0114, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_13_CREATOR = UNIT_END + 0x0115, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_13_0 = UNIT_END + 0x0117, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_13_PROPERTIES = UNIT_END + 0x0123, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_13_PAD = UNIT_END + 0x0124, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_14_CREATOR = UNIT_END + 0x0125, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_14_0 = UNIT_END + 0x0127, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_14_PROPERTIES = UNIT_END + 0x0133, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_14_PAD = UNIT_END + 0x0134, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_15_CREATOR = UNIT_END + 0x0135, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_15_0 = UNIT_END + 0x0137, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_15_PROPERTIES = UNIT_END + 0x0143, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_15_PAD = UNIT_END + 0x0144, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_16_CREATOR = UNIT_END + 0x0145, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_16_0 = UNIT_END + 0x0147, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_16_PROPERTIES = UNIT_END + 0x0153, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_16_PAD = UNIT_END + 0x0154, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_17_CREATOR = UNIT_END + 0x0155, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_17_0 = UNIT_END + 0x0157, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_17_PROPERTIES = UNIT_END + 0x0163, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_17_PAD = UNIT_END + 0x0164, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_18_CREATOR = UNIT_END + 0x0165, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_18_0 = UNIT_END + 0x0167, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_18_PROPERTIES = UNIT_END + 0x0173, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_18_PAD = UNIT_END + 0x0174, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_19_CREATOR = UNIT_END + 0x0175, // Size: 2, Type: LONG, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_19_0 = UNIT_END + 0x0177, // Size: 12, Type: INT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_19_PROPERTIES = UNIT_END + 0x0183, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC + PLAYER_VISIBLE_ITEM_19_PAD = UNIT_END + 0x0184, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_CHOSEN_TITLE = UNIT_END + 0x0185, // Size: 1, Type: INT, Flags: PUBLIC + PLAYER_FIELD_INV_SLOT_HEAD = UNIT_END + 0x0186, // Size: 46, Type: LONG, Flags: PRIVATE + PLAYER_FIELD_PACK_SLOT_1 = UNIT_END + 0x01B4, // Size: 32, Type: LONG, Flags: PRIVATE + PLAYER_FIELD_BANK_SLOT_1 = UNIT_END + 0x01D4, // Size: 56, Type: LONG, Flags: PRIVATE + PLAYER_FIELD_BANKBAG_SLOT_1 = UNIT_END + 0x020C, // Size: 14, Type: LONG, Flags: PRIVATE + PLAYER_FIELD_VENDORBUYBACK_SLOT_1 = UNIT_END + 0x021A, // Size: 24, Type: LONG, Flags: PRIVATE + PLAYER_FIELD_KEYRING_SLOT_1 = UNIT_END + 0x0232, // Size: 64, Type: LONG, Flags: PRIVATE + PLAYER_FARSIGHT = UNIT_END + 0x0272, // Size: 2, Type: LONG, Flags: PRIVATE + PLAYER__FIELD_KNOWN_TITLES = UNIT_END + 0x0274, // Size: 2, Type: LONG, Flags: PRIVATE + PLAYER_XP = UNIT_END + 0x0276, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_NEXT_LEVEL_XP = UNIT_END + 0x0277, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_SKILL_INFO_1_1 = UNIT_END + 0x0278, // Size: 384, Type: TWO_SHORT, Flags: PRIVATE + PLAYER_CHARACTER_POINTS1 = UNIT_END + 0x03F8, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_CHARACTER_POINTS2 = UNIT_END + 0x03F9, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_TRACK_CREATURES = UNIT_END + 0x03FA, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_TRACK_RESOURCES = UNIT_END + 0x03FB, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_BLOCK_PERCENTAGE = UNIT_END + 0x03FC, // Size: 1, Type: FLOAT, Flags: PRIVATE + PLAYER_DODGE_PERCENTAGE = UNIT_END + 0x03FD, // Size: 1, Type: FLOAT, Flags: PRIVATE + PLAYER_PARRY_PERCENTAGE = UNIT_END + 0x03FE, // Size: 1, Type: FLOAT, Flags: PRIVATE + PLAYER_EXPERTISE = UNIT_END + 0x03FF, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_CRIT_PERCENTAGE = UNIT_END + 0x0400, // Size: 1, Type: FLOAT, Flags: PRIVATE + PLAYER_RANGED_CRIT_PERCENTAGE = UNIT_END + 0x0401, // Size: 1, Type: FLOAT, Flags: PRIVATE + PLAYER_OFFHAND_CRIT_PERCENTAGE = UNIT_END + 0x0402, // Size: 1, Type: FLOAT, Flags: PRIVATE + PLAYER_SPELL_CRIT_PERCENTAGE1 = UNIT_END + 0x0403, // Size: 7, Type: FLOAT, Flags: PRIVATE + + // custom + PLAYER_HOLY_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+1, + PLAYER_FIRE_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+2, + PLAYER_NATURE_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+3, + PLAYER_FROST_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+4, + PLAYER_SHADOW_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+5, + PLAYER_ARCANE_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+6, + + PLAYER_SHIELD_BLOCK = UNIT_END + 0x040A, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_EXPLORED_ZONES_1 = UNIT_END + 0x040B, // Size: 64, Type: BYTES, Flags: PRIVATE + PLAYER_REST_STATE_EXPERIENCE = UNIT_END + 0x044B, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_FIELD_COINAGE = UNIT_END + 0x044C, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_FIELD_MOD_DAMAGE_DONE_POS = UNIT_END + 0x044D, // Size: 7, Type: INT, Flags: PRIVATE + PLAYER_FIELD_MOD_DAMAGE_DONE_NEG = UNIT_END + 0x0454, // Size: 7, Type: INT, Flags: PRIVATE + PLAYER_FIELD_MOD_DAMAGE_DONE_PCT = UNIT_END + 0x045B, // Size: 7, Type: INT, Flags: PRIVATE + PLAYER_FIELD_MOD_HEALING_DONE_POS = UNIT_END + 0x0462, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_FIELD_MOD_TARGET_RESISTANCE = UNIT_END + 0x0463, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_FIELD_BYTES = UNIT_END + 0x0464, // Size: 1, Type: BYTES, Flags: PRIVATE + PLAYER_AMMO_ID = UNIT_END + 0x0465, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_SELF_RES_SPELL = UNIT_END + 0x0466, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_FIELD_PVP_MEDALS = UNIT_END + 0x0467, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_FIELD_BUYBACK_PRICE_1 = UNIT_END + 0x0468, // Size: 12, Type: INT, Flags: PRIVATE + PLAYER_FIELD_BUYBACK_TIMESTAMP_1 = UNIT_END + 0x0474, // Size: 12, Type: INT, Flags: PRIVATE + PLAYER_FIELD_KILLS = UNIT_END + 0x0480, // Size: 1, Type: TWO_SHORT, Flags: PRIVATE + PLAYER_FIELD_TODAY_CONTRIBUTION = UNIT_END + 0x0481, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_FIELD_YESTERDAY_CONTRIBUTION = UNIT_END + 0x0482, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_FIELD_LIFETIME_HONORBALE_KILLS = UNIT_END + 0x0483, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_FIELD_BYTES2 = UNIT_END + 0x0484, // Size: 1, Type: BYTES, Flags: PRIVATE + PLAYER_FIELD_WATCHED_FACTION_INDEX = UNIT_END + 0x0485, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_FIELD_COMBAT_RATING_1 = UNIT_END + 0x0486, // Size: 24, Type: INT, Flags: PRIVATE + + // custom // client names: + // CR_WEAPON_SKILL + PLAYER_FIELD_ALL_WEAPONS_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1, + // CR_DEFENSE_SKILL + PLAYER_FIELD_DEFENCE_RATING = PLAYER_FIELD_COMBAT_RATING_1+1, + // CR_DODGE + PLAYER_FIELD_DODGE_RATING = PLAYER_FIELD_COMBAT_RATING_1+2, + // CR_PARRY + PLAYER_FIELD_PARRY_RATING = PLAYER_FIELD_COMBAT_RATING_1+3, + // CR_BLOCK + PLAYER_FIELD_BLOCK_RATING = PLAYER_FIELD_COMBAT_RATING_1+4, + // CR_HIT_MELEE + PLAYER_FIELD_MELEE_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+5, + // CR_HIT_RANGED + PLAYER_FIELD_RANGED_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+6, + // CR_HIT_SPELL + PLAYER_FIELD_SPELL_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+7, + // CR_CRIT_MELEE + PLAYER_FIELD_MELEE_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+8, + // CR_CRIT_RANGED + PLAYER_FIELD_RANGED_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+9, + // CR_CRIT_SPELL + PLAYER_FIELD_SPELL_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+10, + // CR_HIT_TAKEN_MELEE + PLAYER_FIELD_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+11, + // CR_HIT_TAKEN_RANGED + PLAYER_FIELD_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+12, + // CR_HIT_TAKEN_SPELL + PLAYER_FIELD_UNK3_RATING = PLAYER_FIELD_COMBAT_RATING_1+13, + // CR_CRIT_TAKEN_MELEE + PLAYER_FIELD_UNK4_RATING = PLAYER_FIELD_COMBAT_RATING_1+14, + // CR_CRIT_TAKEN_RANGED + PLAYER_FIELD_UNK5_RATING = PLAYER_FIELD_COMBAT_RATING_1+15, + // CR_CRIT_TAKEN_SPELL + PLAYER_FIELD_RESILIENCE_RATING = PLAYER_FIELD_COMBAT_RATING_1+16, + // CR_HASTE_MELEE + PLAYER_FIELD_MELEE_HASTE_RATING = PLAYER_FIELD_COMBAT_RATING_1+17, + // CR_HASTE_RANGED + PLAYER_FIELD_RANGED_HASTE_RATING = PLAYER_FIELD_COMBAT_RATING_1+18, + // CR_HASTE_SPELL + PLAYER_FIELD_SPELL_HASTE_RATING = PLAYER_FIELD_COMBAT_RATING_1+19, + // CR_WEAPON_SKILL_MAINHAND + PLAYER_FIELD_MELEE_WEAPON_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1+20, + // CR_WEAPON_SKILL_OFFHAND + PLAYER_FIELD_OFFHAND_WEAPON_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1+21, + // CR_WEAPON_SKILL_RANGED + PLAYER_FIELD_RANGED_WEAPON_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1+22, + // CR_EXPERTISE + PLAYER_FIELD_EXPERTISE_RATING = PLAYER_FIELD_COMBAT_RATING_1+23, + + PLAYER_FIELD_ARENA_TEAM_INFO_1_1 = UNIT_END + 0x049E, // Size: 18, Type: INT, Flags: PRIVATE + + // custom + PLAYER_FIELD_ARENA_TEAM_ID_2v2 = PLAYER_FIELD_ARENA_TEAM_INFO_1_1, + PLAYER_FIELD_ARENA_TEAM_ID_3v3 = PLAYER_FIELD_ARENA_TEAM_INFO_1_1+6, + PLAYER_FIELD_ARENA_TEAM_ID_5v5 = PLAYER_FIELD_ARENA_TEAM_INFO_1_1+12, + + PLAYER_FIELD_HONOR_CURRENCY = UNIT_END + 0x04B0, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_FIELD_ARENA_CURRENCY = UNIT_END + 0x04B1, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_FIELD_MOD_MANA_REGEN = UNIT_END + 0x04B2, // Size: 1, Type: FLOAT, Flags: PRIVATE + PLAYER_FIELD_MOD_MANA_REGEN_INTERRUPT = UNIT_END + 0x04B3, // Size: 1, Type: FLOAT, Flags: PRIVATE + PLAYER_FIELD_MAX_LEVEL = UNIT_END + 0x04B4, // Size: 1, Type: INT, Flags: PRIVATE + PLAYER_FIELD_DAILY_QUESTS_1 = UNIT_END + 0x04B5, // Size: 10, Type: INT, Flags: PRIVATE + PLAYER_FIELD_PADDING = UNIT_END + 0x04BF, // Size: 1, Type: INT, Flags: NONE + PLAYER_END = UNIT_END + 0x04C0, +}; + +enum EGameObjectFields +{ + OBJECT_FIELD_CREATED_BY = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC + GAMEOBJECT_DISPLAYID = OBJECT_END + 0x0002, // Size: 1, Type: INT, Flags: PUBLIC + GAMEOBJECT_FLAGS = OBJECT_END + 0x0003, // Size: 1, Type: INT, Flags: PUBLIC + GAMEOBJECT_ROTATION = OBJECT_END + 0x0004, // Size: 4, Type: FLOAT, Flags: PUBLIC + GAMEOBJECT_STATE = OBJECT_END + 0x0008, // Size: 1, Type: INT, Flags: PUBLIC + GAMEOBJECT_POS_X = OBJECT_END + 0x0009, // Size: 1, Type: FLOAT, Flags: PUBLIC + GAMEOBJECT_POS_Y = OBJECT_END + 0x000A, // Size: 1, Type: FLOAT, Flags: PUBLIC + GAMEOBJECT_POS_Z = OBJECT_END + 0x000B, // Size: 1, Type: FLOAT, Flags: PUBLIC + GAMEOBJECT_FACING = OBJECT_END + 0x000C, // Size: 1, Type: FLOAT, Flags: PUBLIC + GAMEOBJECT_DYN_FLAGS = OBJECT_END + 0x000D, // Size: 1, Type: INT, Flags: DYNAMIC + GAMEOBJECT_FACTION = OBJECT_END + 0x000E, // Size: 1, Type: INT, Flags: PUBLIC + GAMEOBJECT_TYPE_ID = OBJECT_END + 0x000F, // Size: 1, Type: INT, Flags: PUBLIC + GAMEOBJECT_LEVEL = OBJECT_END + 0x0010, // Size: 1, Type: INT, Flags: PUBLIC + GAMEOBJECT_ARTKIT = OBJECT_END + 0x0011, // Size: 1, Type: INT, Flags: PUBLIC + GAMEOBJECT_ANIMPROGRESS = OBJECT_END + 0x0012, // Size: 1, Type: INT, Flags: DYNAMIC + GAMEOBJECT_PADDING = OBJECT_END + 0x0013, // Size: 1, Type: INT, Flags: NONE + GAMEOBJECT_END = OBJECT_END + 0x0014, +}; + +enum EDynamicObjectFields +{ + DYNAMICOBJECT_CASTER = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC + DYNAMICOBJECT_BYTES = OBJECT_END + 0x0002, // Size: 1, Type: BYTES, Flags: PUBLIC + DYNAMICOBJECT_SPELLID = OBJECT_END + 0x0003, // Size: 1, Type: INT, Flags: PUBLIC + DYNAMICOBJECT_RADIUS = OBJECT_END + 0x0004, // Size: 1, Type: FLOAT, Flags: PUBLIC + DYNAMICOBJECT_POS_X = OBJECT_END + 0x0005, // Size: 1, Type: FLOAT, Flags: PUBLIC + DYNAMICOBJECT_POS_Y = OBJECT_END + 0x0006, // Size: 1, Type: FLOAT, Flags: PUBLIC + DYNAMICOBJECT_POS_Z = OBJECT_END + 0x0007, // Size: 1, Type: FLOAT, Flags: PUBLIC + DYNAMICOBJECT_FACING = OBJECT_END + 0x0008, // Size: 1, Type: FLOAT, Flags: PUBLIC + DYNAMICOBJECT_PAD = OBJECT_END + 0x0009, // Size: 1, Type: BYTES, Flags: PUBLIC + DYNAMICOBJECT_END = OBJECT_END + 0x000A, +}; + +enum ECorpseFields +{ + CORPSE_FIELD_OWNER = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC + CORPSE_FIELD_FACING = OBJECT_END + 0x0002, // Size: 1, Type: FLOAT, Flags: PUBLIC + CORPSE_FIELD_POS_X = OBJECT_END + 0x0003, // Size: 1, Type: FLOAT, Flags: PUBLIC + CORPSE_FIELD_POS_Y = OBJECT_END + 0x0004, // Size: 1, Type: FLOAT, Flags: PUBLIC + CORPSE_FIELD_POS_Z = OBJECT_END + 0x0005, // Size: 1, Type: FLOAT, Flags: PUBLIC + CORPSE_FIELD_DISPLAY_ID = OBJECT_END + 0x0006, // Size: 1, Type: INT, Flags: PUBLIC + CORPSE_FIELD_ITEM = OBJECT_END + 0x0007, // Size: 19, Type: INT, Flags: PUBLIC + CORPSE_FIELD_BYTES_1 = OBJECT_END + 0x001A, // Size: 1, Type: BYTES, Flags: PUBLIC + CORPSE_FIELD_BYTES_2 = OBJECT_END + 0x001B, // Size: 1, Type: BYTES, Flags: PUBLIC + CORPSE_FIELD_GUILD = OBJECT_END + 0x001C, // Size: 1, Type: INT, Flags: PUBLIC + CORPSE_FIELD_FLAGS = OBJECT_END + 0x001D, // Size: 1, Type: INT, Flags: PUBLIC + CORPSE_FIELD_DYNAMIC_FLAGS = OBJECT_END + 0x001E, // Size: 1, Type: INT, Flags: DYNAMIC + CORPSE_FIELD_PAD = OBJECT_END + 0x001F, // Size: 1, Type: INT, Flags: NONE + CORPSE_END = OBJECT_END + 0x0020, +}; +#endif diff --git a/src/Client/World/World.cpp b/src/Client/World/World.cpp index 9b9d9c1..efa5add 100644 --- a/src/Client/World/World.cpp +++ b/src/Client/World/World.cpp @@ -1,74 +1,74 @@ -#include "common.h" -#include "MapMgr.h" -#include "WorldSession.h" -#include "World.h" - -World::World(WorldSession *s) -{ - _session = s; - _mapId = -1; - _mapmgr = NULL; - if(_session->GetInstance()->GetConf()->useMaps) - _mapmgr = new MapMgr(); -} - -World::~World() -{ - Clear(); - if(_mapmgr) - delete _mapmgr; -} - -// called on SMSG_NEW_WORLD -void World::Clear(void) -{ - if(_mapmgr) - { - _mapmgr->Flush(); - } - // TODO: clear WorldStates (-> SMSG_INIT_WORLD_STATES ?) and everything else thats required -} - - -void World::Update(void) -{ - if(_mapId == uint32(-1)) // to prevent unexpected behaviour - return; - - if(_mapmgr) - { - _mapmgr->Update(_x,_y,_mapId); - } - - // some debug code for testing... - /*if(_mapmgr && _x != _lastx || _y != _lasty) - { - logdetail("WORLD: relocation, to x=%f y=%f, calculated z=%f",_x,_y,this->GetPosZ(_x,_y)); - _lastx = _x; - _lasty = _y; - }*/ - -} - -void World::UpdatePos(float x, float y, uint32 m) -{ - _mapId = m; - UpdatePos(x,y); -} - -void World::UpdatePos(float x, float y) -{ - _x = x; - _y = y; - Update(); -} - -float World::GetPosZ(float x, float y) -{ - if(_mapmgr) - return _mapmgr->GetZ(x,y); - - logdebug("WORLD: GetPosZ() called, but no MapMgr exists (do you really use maps?)"); - return 0; -} +#include "common.h" +#include "MapMgr.h" +#include "WorldSession.h" +#include "World.h" + +World::World(WorldSession *s) +{ + _session = s; + _mapId = -1; + _mapmgr = NULL; + if(_session->GetInstance()->GetConf()->useMaps) + _mapmgr = new MapMgr(); +} + +World::~World() +{ + Clear(); + if(_mapmgr) + delete _mapmgr; +} + +// called on SMSG_NEW_WORLD +void World::Clear(void) +{ + if(_mapmgr) + { + _mapmgr->Flush(); + } + // TODO: clear WorldStates (-> SMSG_INIT_WORLD_STATES ?) and everything else thats required +} + + +void World::Update(void) +{ + if(_mapId == uint32(-1)) // to prevent unexpected behaviour + return; + + if(_mapmgr) + { + _mapmgr->Update(_x,_y,_mapId); + } + + // some debug code for testing... + /*if(_mapmgr && _x != _lastx || _y != _lasty) + { + logdetail("WORLD: relocation, to x=%f y=%f, calculated z=%f",_x,_y,this->GetPosZ(_x,_y)); + _lastx = _x; + _lasty = _y; + }*/ + +} + +void World::UpdatePos(float x, float y, uint32 m) +{ + _mapId = m; + UpdatePos(x,y); +} + +void World::UpdatePos(float x, float y) +{ + _x = x; + _y = y; + Update(); +} + +float World::GetPosZ(float x, float y) +{ + if(_mapmgr) + return _mapmgr->GetZ(x,y); + + logdebug("WORLD: GetPosZ() called, but no MapMgr exists (do you really use maps?)"); + return 0; +} \ No newline at end of file diff --git a/src/Client/World/World.h b/src/Client/World/World.h index d1ba178..76796df 100644 --- a/src/Client/World/World.h +++ b/src/Client/World/World.h @@ -1,52 +1,52 @@ -#ifndef WORLD_H -#define WORLD_H - -class WorldSession; -class MapMgr; - -struct WorldPosition -{ - WorldPosition() : x(0.0f), y(0.0f), z(0.0f), o(0.0f) {}; - WorldPosition(float px, float py) : x(px), y(py), z(0.0f), o(0.0f) {}; - WorldPosition(float px, float py, float pz) : x(px), y(py), z(pz), o(0.0f) {}; - WorldPosition(float px, float py, float pz, float po) : x(px), y(py), z(pz), o(po) {}; - float x,y,z,o; -}; - -inline ByteBuffer& operator<<(ByteBuffer& bb, WorldPosition& p) -{ - bb << p.x << p.y << p.z << p.o; - return bb; -} -inline ByteBuffer& operator>>(ByteBuffer& bb, WorldPosition& p) -{ - bb >> p.x >> p.y >> p.z >> p.o; - return bb; -} - -// used as interface for movement, map data, -class World -{ -public: - World(WorldSession*); - ~World(); - - inline uint32 GetMapId(void) { return _mapId; } - inline WorldSession *GetSession(void) { return _session; } - void Clear(void); - void Update(void); - void UpdatePos(float,float,uint32); - void UpdatePos(float,float); - float GetPosZ(float x, float y); - inline MapMgr *GetMapMgr(void) { return _mapmgr; } - -private: - WorldSession *_session; - MapMgr *_mapmgr; - uint32 _mapId; - float _x,_y; - float _lastx,_lasty; - -}; - -#endif +#ifndef WORLD_H +#define WORLD_H + +class WorldSession; +class MapMgr; + +struct WorldPosition +{ + WorldPosition() : x(0.0f), y(0.0f), z(0.0f), o(0.0f) {}; + WorldPosition(float px, float py) : x(px), y(py), z(0.0f), o(0.0f) {}; + WorldPosition(float px, float py, float pz) : x(px), y(py), z(pz), o(0.0f) {}; + WorldPosition(float px, float py, float pz, float po) : x(px), y(py), z(pz), o(po) {}; + float x,y,z,o; +}; + +inline ByteBuffer& operator<<(ByteBuffer& bb, WorldPosition& p) +{ + bb << p.x << p.y << p.z << p.o; + return bb; +} +inline ByteBuffer& operator>>(ByteBuffer& bb, WorldPosition& p) +{ + bb >> p.x >> p.y >> p.z >> p.o; + return bb; +} + +// used as interface for movement, map data, +class World +{ +public: + World(WorldSession*); + ~World(); + + inline uint32 GetMapId(void) { return _mapId; } + inline WorldSession *GetSession(void) { return _session; } + void Clear(void); + void Update(void); + void UpdatePos(float,float,uint32); + void UpdatePos(float,float); + float GetPosZ(float x, float y); + inline MapMgr *GetMapMgr(void) { return _mapmgr; } + +private: + WorldSession *_session; + MapMgr *_mapmgr; + uint32 _mapId; + float _x,_y; + float _lastx,_lasty; + +}; + +#endif diff --git a/src/Client/World/WorldPacket.cpp b/src/Client/World/WorldPacket.cpp index 3929752..8f26789 100644 --- a/src/Client/World/WorldPacket.cpp +++ b/src/Client/World/WorldPacket.cpp @@ -1,19 +1,19 @@ - -#include "WorldPacket.h" - - -uint64 WorldPacket::GetPackedGuid(void) -{ - uint8 mask; - *this >> mask; - uint64 guid=0; - for(uint8 i=0;i<8;i++) - { - if(mask & (1<> ((uint8*)&guid)[i]; - } - } - return guid; -} - + +#include "WorldPacket.h" + + +uint64 WorldPacket::GetPackedGuid(void) +{ + uint8 mask; + *this >> mask; + uint64 guid=0; + for(uint8 i=0;i<8;i++) + { + if(mask & (1<> ((uint8*)&guid)[i]; + } + } + return guid; +} + diff --git a/src/Client/World/WorldSession.cpp b/src/Client/World/WorldSession.cpp index ce26608..86cb965 100644 --- a/src/Client/World/WorldSession.cpp +++ b/src/Client/World/WorldSession.cpp @@ -1,1273 +1,1273 @@ -#include "common.h" - -#include "Auth/Sha1.h" -#include "Auth/BigNumber.h" -#include "Auth/AuthCrypt.h" -#include "WorldPacket.h" -#include "WorldSocket.h" -#include "RealmSocket.h" -#include "Channel.h" -#include "ObjMgr.h" -#include "World.h" -#include "RealmSession.h" -#include "WorldSession.h" - -struct OpcodeHandler -{ - uint16 opcode; - void (WorldSession::*handler)(WorldPacket& recvPacket); -}; - -WorldSession::WorldSession(PseuInstance *in) -{ - logdebug("-> Starting WorldSession 0x%X from instance 0x%X",this,in); // should never output a null ptr - _instance = in; - _mustdie=false; - _logged=false; - _socket=NULL; - _myGUID=0; // i dont have a guid yet - _channels = new Channel(this); - _world = new World(this); - _sh.SetAutoCloseSockets(false); - objmgr.SetInstance(in); - _lag_ms = 0; - //... - - in->GetScripts()->RunScriptIfExists("_onworldsessioncreate"); - - DEBUG(logdebug("WorldSession 0x%X constructor finished",this)); -} - -WorldSession::~WorldSession() -{ - _instance->GetScripts()->RunScriptIfExists("_onworldsessiondelete"); - - logdebug("~WorldSession(): %u packets left unhandled, and %u delayed. deleting.",pktQueue.size(),delayedPktQueue.size()); - WorldPacket *packet; - // clear the queue - while(pktQueue.size()) - { - packet = pktQueue.next(); - delete packet; - } - // clear the delayed queue - while(delayedPktQueue.size()) - { - packet = delayedPktQueue.back().pkt; - delayedPktQueue.pop_back(); - delete packet; - } - - if(_channels) - delete _channels; - if(_socket) - delete _socket; - if(_world) - delete _world; - DEBUG(logdebug("~WorldSession() this=0x%X _instance=0x%X",this,_instance)); -} - -void WorldSession::SetMustDie(void) -{ - _mustdie = true; - logdebug("WorldSession: Must die now."); -} - -void WorldSession::Start(void) -{ - log("Connecting to '%s' on port %u",GetInstance()->GetConf()->worldhost.c_str(),GetInstance()->GetConf()->worldport); - _socket=new WorldSocket(_sh,this); - _socket->Open(GetInstance()->GetConf()->worldhost,GetInstance()->GetConf()->worldport); - if(GetInstance()->GetRSession()) - { - GetInstance()->GetRSession()->SetMustDie(); // realm session is no longer needed - } - _sh.Add(_socket); - - // if we cant connect, wait until the socket gives up (after 5 secs) - while( (!MustDie()) && (!_socket->IsOk()) && (!GetInstance()->Stopped()) ) - { - logdev("WorldSession::Start(): Socket not ok, waiting..."); - _sh.Select(3,0); - GetInstance()->Sleep(100); - } - logdev("WorldSession::Start() done, mustdie:%u, socket_ok:%u stopped:%u",MustDie(),_socket->IsOk(),GetInstance()->Stopped()); -} - -void WorldSession::_LoadCache(void) -{ - logdetail("Loading Cache..."); - plrNameCache.ReadFromFile(); // load names/guids of known players - ItemProtoCache_InsertDataToSession(this); - CreatureTemplateCache_InsertDataToSession(this); - //... -} - -void WorldSession::AddToPktQueue(WorldPacket *pkt) -{ - pktQueue.add(pkt); -} - -void WorldSession::SendWorldPacket(WorldPacket &pkt) -{ - if(GetInstance()->GetConf()->showmyopcodes) - logcustom(0,BROWN,"<< Opcode %u [%s] (%u bytes)", pkt.GetOpcode(), GetOpcodeName(pkt.GetOpcode()), pkt.size()); - if(_socket && _socket->IsOk()) - _socket->SendWorldPacket(pkt); - else - { - logerror("WorldSession: Can't send WorldPacket, socket doesn't exist or is not ready."); - } -} - -void WorldSession::Update(void) -{ - if( _sh.GetCount() ) // the socket will remove itself from the handler if it got closed - _sh.Select(0,0); - else // so we just need to check if the socket doesnt exist or if it exists but isnt valid anymore. - { // if thats the case, we dont need the session anymore either - if(!_socket || (_socket && !_socket->IsOk())) - { - _OnLeaveWorld(); - SetMustDie(); - } - } - - // while there are packets on the queue, handle them - while(pktQueue.size()) - { - HandleWorldPacket(pktQueue.next()); - } - - // now check if there are packets that couldnt be handled earlier due to missing data - _HandleDelayedPackets(); - - _DoTimedActions(); - - if(_world) - _world->Update(); -} - -// this func will delete the WorldPacket after it is handled! -void WorldSession::HandleWorldPacket(WorldPacket *packet) -{ - static DefScriptPackage *sc = GetInstance()->GetScripts(); - static OpcodeHandler *table = _GetOpcodeHandlerTable(); - - bool known = false; - uint16 hpos; - - for (hpos = 0; table[hpos].handler != NULL; hpos++) - { - if (table[hpos].opcode == packet->GetOpcode()) - { - known=true; - break; - } - } - - bool hideOpcode = false; - bool disabledOpcode = IsOpcodeDisabled(packet->GetOpcode()); - if(disabledOpcode && GetInstance()->GetConf()->hideDisabledOpcodes) - hideOpcode = true; - - // TODO: Maybe make table or something with all the frequently opcodes - if (GetInstance()->GetConf()->hidefreqopcodes) - { - switch(packet->GetOpcode()) - { - case SMSG_MONSTER_MOVE: - hideOpcode = true; - } - } - - if( (known && GetInstance()->GetConf()->showopcodes==1) - || ((!known) && GetInstance()->GetConf()->showopcodes==2) - || (GetInstance()->GetConf()->showopcodes==3) ) - { - if(!hideOpcode) - logcustom(1,YELLOW,">> Opcode %u [%s] (%s, %u bytes)", packet->GetOpcode(), GetOpcodeName(packet->GetOpcode()), (known ? (disabledOpcode ? "Disabled" : "Known") : "UNKNOWN"), packet->size()); - } - - try - { - // if there is a script attached to that opcode, call it now. - // note: the pkt rpos needs to be reset by the scripts! - std::string scname = "opcode::"; - scname += stringToLower(GetOpcodeName(packet->GetOpcode())); - if(sc->ScriptExists(scname)) - { - std::string pktname = "PACKET::"; - pktname += GetOpcodeName(packet->GetOpcode()); - GetInstance()->GetScripts()->bytebuffers.Assign(pktname,packet); - sc->RunScript(scname,NULL); - GetInstance()->GetScripts()->bytebuffers.Unlink(pktname); - } - - // call the opcode handler - if(known && !disabledOpcode) - { - packet->rpos(0); - (this->*table[hpos].handler)(*packet); - } - } - catch (ByteBufferException bbe) - { - logerror("Exception while handling opcode %u [%s]!",packet->GetOpcode(),GetOpcodeName(packet->GetOpcode())); - logerror("WorldSession: ByteBufferException"); - logerror("ByteBuffer reported: attempt to \"%s\" %u bytes at position %u out of total %u bytes. (wpos=%u)", - bbe.action, bbe.readsize, bbe.rpos, bbe.cursize, bbe.wpos); - // copied from below - logerror("Data: pktsize=%u, handler=0x%X queuesize=%u",packet->size(),table[hpos].handler,pktQueue.size()); - logerror("Packet Hexdump:"); - logerror("%s",toHexDump((uint8*)packet->contents(),packet->size(),true).c_str()); - } - catch (...) - { - logerror("Exception while handling opcode %u [%s]!",packet->GetOpcode(),GetOpcodeName(packet->GetOpcode())); - logerror("Data: pktsize=%u, handler=0x%X queuesize=%u",packet->size(),table[hpos].handler,pktQueue.size()); - logerror("Packet Hexdump:"); - logerror("%s",toHexDump((uint8*)packet->contents(),packet->size(),true).c_str()); - } - - delete packet; -} - - -OpcodeHandler *WorldSession::_GetOpcodeHandlerTable() const -{ - static OpcodeHandler table[] = - { - { SMSG_AUTH_CHALLENGE, &WorldSession::_HandleAuthChallengeOpcode }, - { SMSG_AUTH_RESPONSE, &WorldSession::_HandleAuthResponseOpcode }, - {SMSG_CHAR_ENUM, &WorldSession::_HandleCharEnumOpcode}, - {SMSG_SET_PROFICIENCY, &WorldSession::_HandleSetProficiencyOpcode}, - {SMSG_ACCOUNT_DATA_MD5, &WorldSession::_HandleAccountDataMD5Opcode}, - {SMSG_MESSAGECHAT, &WorldSession::_HandleMessageChatOpcode}, - {SMSG_NAME_QUERY_RESPONSE, &WorldSession::_HandleNameQueryResponseOpcode}, - {SMSG_PONG, &WorldSession::_HandlePongOpcode}, - {SMSG_TRADE_STATUS, &WorldSession::_HandleTradeStatusOpcode}, - {SMSG_GROUP_INVITE, &WorldSession::_HandleGroupInviteOpcode}, - {SMSG_CHANNEL_NOTIFY, &WorldSession::_HandleChannelNotifyOpcode}, - - // movement opcodes - {MSG_MOVE_SET_FACING, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_START_FORWARD, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_START_BACKWARD, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_STOP, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_START_STRAFE_LEFT, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_START_STRAFE_RIGHT, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_STOP_STRAFE, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_JUMP, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_START_TURN_LEFT, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_START_TURN_RIGHT, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_STOP_TURN, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_START_SWIM, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_STOP_SWIM, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_HEARTBEAT, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_FALL_LAND, &WorldSession::_HandleMovementOpcode}, - {MSG_MOVE_TELEPORT_ACK, &WorldSession::_HandleTelePortAckOpcode}, - - {SMSG_COMPRESSED_UPDATE_OBJECT, &WorldSession::_HandleCompressedUpdateObjectOpcode}, - {SMSG_UPDATE_OBJECT, &WorldSession::_HandleUpdateObjectOpcode}, - {SMSG_CAST_RESULT, &WorldSession::_HandleCastResultOpcode}, - {SMSG_CAST_SUCCESS, &WorldSession::_HandleCastSuccessOpcode}, - {SMSG_ITEM_QUERY_SINGLE_RESPONSE, &WorldSession::_HandleItemQuerySingleResponseOpcode}, - {SMSG_DESTROY_OBJECT, &WorldSession::_HandleDestroyObjectOpcode}, - {SMSG_INITIAL_SPELLS, &WorldSession::_HandleInitialSpellsOpcode}, - {SMSG_LEARNED_SPELL, &WorldSession::_HandleLearnedSpellOpcode}, - {SMSG_REMOVED_SPELL, &WorldSession::_HandleLearnedSpellOpcode}, - {SMSG_CHANNEL_LIST, &WorldSession::_HandleChannelListOpcode}, - {SMSG_EMOTE, &WorldSession::_HandleEmoteOpcode}, - {SMSG_TEXT_EMOTE, &WorldSession::_HandleTextEmoteOpcode}, - {SMSG_NEW_WORLD, &WorldSession::_HandleNewWorldOpcode}, - {SMSG_LOGIN_VERIFY_WORLD, &WorldSession::_HandleLoginVerifyWorldOpcode}, - {SMSG_MOTD, &WorldSession::_HandleMotdOpcode}, - {SMSG_NOTIFICATION, &WorldSession::_HandleNotificationOpcode}, - {SMSG_WHO, &WorldSession::_HandleWhoOpcode}, - {SMSG_CREATURE_QUERY_RESPONSE, &WorldSession::_HandleCreatureQueryResponseOpcode}, - - // table termination - { 0, NULL } - }; - return table; -} - -void WorldSession::_DelayWorldPacket(WorldPacket& pkt, uint32 ms) -{ - DEBUG(logdebug("DelayWorldPacket (%s, size: %u, ms: %u)",GetOpcodeName(pkt.GetOpcode()),pkt.size(),ms)); - // need to copy the packet, because the current packet will be deleted after it got handled - WorldPacket *pktcopy = new WorldPacket(pkt.GetOpcode(),pkt.size()); - pktcopy->append(pkt.contents(),pkt.size()); - delayedPktQueue.push_back(DelayedWorldPacket(pktcopy,ms)); - DEBUG(logdebug("-> WP ptr = 0x%X",pktcopy)); -} - -void WorldSession::_HandleDelayedPackets(void) -{ - if(delayedPktQueue.size()) - { - DelayedPacketQueue copy(delayedPktQueue); - delayedPktQueue.clear(); // clear original, since it might be filled up by newly delayed packets, which would cause endless loop - while(copy.size()) - { - DelayedWorldPacket d = copy.front(); - copy.pop_front(); // remove packet from front - if(clock() >= d.when) // if its time to handle this packet, do so - { - DEBUG(logdebug("Handling delayed packet (%s [%u], size: %u, ptr: 0x%X)",GetOpcodeName(d.pkt->GetOpcode()),d.pkt->GetOpcode(),d.pkt->size(),d.pkt)); - HandleWorldPacket(d.pkt); - } - else - { - delayedPktQueue.push_back(d); // and if not, put it again onto the queue - } - } - } -} - - -void WorldSession::SetTarget(uint64 guid) -{ - SendSetSelection(guid); -} - -void WorldSession::_OnEnterWorld(void) -{ - if(!InWorld()) - { - _logged=true; - GetInstance()->GetScripts()->variables.Set("@inworld","true"); - GetInstance()->GetScripts()->RunScriptIfExists("_enterworld"); - - } -} - -void WorldSession::_OnLeaveWorld(void) -{ - if(InWorld()) - { - _logged=false; - GetInstance()->GetScripts()->RunScriptIfExists("_leaveworld"); - GetInstance()->GetScripts()->variables.Set("@inworld","false"); - } -} - -void WorldSession::_DoTimedActions(void) -{ - static clock_t pingtime=0; - if(InWorld()) - { - if(pingtime < clock()) - { - pingtime=clock() + 30*CLOCKS_PER_SEC; - SendPing(clock()); - } - //... - } -} - -std::string WorldSession::GetOrRequestPlayerName(uint64 guid) -{ - if(!guid || GUID_HIPART(guid) != HIGHGUID_PLAYER) - { - logerror("WorldSession::GetOrRequestObjectName: "I64FMT" is not player",guid); - return ""; // TODO: temporary, to find bugs with this, if there are any - } - std::string name = plrNameCache.GetName(guid); - if(name.empty()) - { - if(!objmgr.IsRequestedPlayerGUID(guid)) - { - objmgr.AddRequestedPlayerGUID(guid); - SendQueryPlayerName(guid); - } - } - return name; -} - - - - - -/////////////////////////////////////////////////////////////// -// Opcode Handlers -/////////////////////////////////////////////////////////////// - -void WorldSession::_HandleAuthChallengeOpcode(WorldPacket& recvPacket) -{ - std::string acc = stringToUpper(GetInstance()->GetConf()->accname); - uint32 serverseed; - recvPacket >> serverseed; - logdebug("Auth: serverseed=0x%X",serverseed); - Sha1Hash digest; - digest.UpdateData(acc); - uint32 unk=0; - digest.UpdateData((uint8*)&unk,sizeof(uint32)); - BigNumber clientseed; - clientseed.SetRand(8*4); - uint32 clientseed_uint32=clientseed.AsDword(); - digest.UpdateData((uint8*)&clientseed_uint32,sizeof(uint32)); - digest.UpdateData((uint8*)&serverseed,sizeof(uint32)); - digest.UpdateBigNumbers(GetInstance()->GetSessionKey(),NULL); - digest.Finalize(); - WorldPacket auth; - auth<<(uint32)(GetInstance()->GetConf()->clientbuild)<InitCrypt(GetInstance()->GetSessionKey()->AsByteArray(), 40); - -} - -void WorldSession::_HandleAuthResponseOpcode(WorldPacket& recvPacket) -{ - uint8 errcode; - recvPacket >> errcode; - if(errcode==0xC){ - logdetail("World Authentication successful, preparing for char list request..."); - WorldPacket pkt; - pkt.SetOpcode(CMSG_CHAR_ENUM); - SendWorldPacket(pkt); - } else { - logcritical("World Authentication failed, errcode=0x%X",(unsigned char)errcode); - GetInstance()->SetError(); - } -} - -void WorldSession::_HandleCharEnumOpcode(WorldPacket& recvPacket) -{ - uint8 num; - uint8 charId; - PlayerEnum plr[10]; // max characters per realm is 10 - uint8 dummy8; - - recvPacket >> num; - if(num==0) - { - logerror("No chars found!"); - GetInstance()->SetError(); - return; - } - - logdetail("Chars in list: %u",num); - _LoadCache(); // we are about to login, so we need cache data - for(unsigned int i=0;i> plr[i]._guid; - recvPacket >> plr[i]._name; - recvPacket >> plr[i]._race; - recvPacket >> plr[i]._class; - recvPacket >> plr[i]._gender; - recvPacket >> plr[i]._bytes1; - recvPacket >> plr[i]._bytes2; - recvPacket >> plr[i]._bytes3; - recvPacket >> plr[i]._bytes4; - recvPacket >> plr[i]._bytesx; - recvPacket >> plr[i]._level; - recvPacket >> plr[i]._zoneId; - recvPacket >> plr[i]._mapId; - recvPacket >> plr[i]._x; - recvPacket >> plr[i]._y; - recvPacket >> plr[i]._z; - recvPacket >> plr[i]._guildId; - recvPacket >> dummy8; - recvPacket >> plr[i]._flags; - recvPacket >> dummy8 >> dummy8 >> dummy8; - recvPacket >> plr[i]._petInfoId; - recvPacket >> plr[i]._petLevel; - recvPacket >> plr[i]._petFamilyId; - for(unsigned int inv=0;inv<20;inv++) - { - recvPacket >> plr[i]._items[inv].displayId >> plr[i]._items[inv].inventorytype; - } - plrNameCache.AddInfo(plr[i]._guid, plr[i]._name); - } - bool char_found=false; - - for(unsigned int i=0;i coords: map=%u zone=%u x=%f y=%f z=%f", - plr[i]._mapId,plr[i]._zoneId,plr[i]._x,plr[i]._y,plr[i]._z); - - for(unsigned int inv=0;inv<20;inv++) - { - if(plr[i]._items[inv].displayId) - logdebug("-> Has Item: Model=%u InventoryType=%u",plr[i]._items[inv].displayId,plr[i]._items[inv].inventorytype); - } - if(plr[i]._name==GetInstance()->GetConf()->charname) - { - charId = i; - char_found=true; - _myGUID=plr[i]._guid; - GetInstance()->GetScripts()->variables.Set("@myguid",DefScriptTools::toString(plr[i]._guid)); - GetInstance()->GetScripts()->variables.Set("@myrace",DefScriptTools::toString((uint64)plr[i]._race)); - } - - } - if(!char_found) - { - logerror("Character \"%s\" was not found on char list!", plr[charId]._name.c_str()); - GetInstance()->SetError(); - return; - } - else - { - log("Entering World with Character \"%s\"...", plr[charId]._name.c_str()); - - // create the character and add it to the objmgr. - // note: this is the only object that has to stay in memory unless its explicitly deleted by the server! - // that means even if the server sends create object with that guid, do NOT recreate it!! - MyCharacter *my = new MyCharacter(); - my->Create(_myGUID); - objmgr.Add(my); - my->SetName(plr[charId]._name); - - // TODO: initialize the world here, and load required maps. - // must remove appropriate code from _HandleLoginVerifyWorldOpcode() then!! - - WorldPacket pkt(CMSG_PLAYER_LOGIN,8); - pkt << _myGUID; - SendWorldPacket(pkt); - } -} - - -void WorldSession::_HandleSetProficiencyOpcode(WorldPacket& recvPacket) -{ - if(recvPacket.size()) - { - DEBUG( - logdebug("SetProficiency: Hexdump:"); - logdebug(toHexDump((uint8*)recvPacket.contents(),recvPacket.size(),true).c_str()); - ); - } -} - -void WorldSession::_HandleAccountDataMD5Opcode(WorldPacket& recvPacket) -{ - // packet structure not yet known -} - -void WorldSession::_HandleMessageChatOpcode(WorldPacket& recvPacket) -{ - uint8 type=0; - uint32 lang=0; - uint64 source_guid=0; - uint64 target_guid=0; - uint64 npc_guid=0; // for CHAT_MSG_MONSTER_SAY - uint32 msglen=0; - uint32 unk=0; - uint32 npc_name_len; - std::string npc_name; - std::string msg,channel=""; - bool isCmd=false; - - recvPacket >> type >> lang; - - if(lang == CHAT_MSG_MONSTER_SAY) - { - recvPacket >> npc_guid; - recvPacket >> unk; - recvPacket >> npc_name_len; - recvPacket >> npc_name; - } - - if(lang == LANG_ADDON && GetInstance()->GetConf()->skipaddonchat) - return; - - recvPacket >> source_guid >> unk; // added in 2.1.0 - if (type == CHAT_MSG_CHANNEL) - { - recvPacket >> channel; // extract channel name - } - recvPacket >> target_guid >> msglen >> msg; - - std::string langname = GetDBMgr().GetLangName(lang); - const char* ln = langname.c_str(); - std::string name; - - if(type == CHAT_MSG_MONSTER_SAY) - { - name = npc_name; - source_guid = npc_guid; - } - - if(source_guid && IS_PLAYER_GUID(source_guid)) - { - name = GetOrRequestPlayerName(source_guid); - if(name.empty()) - { - _DelayWorldPacket(recvPacket, uint32(GetLagMS() * 1.2f)); // guess time how long it will take until we got player name from the server - return; // handle later - } - } - GetInstance()->GetScripts()->variables.Set("@thismsg_name",name); - GetInstance()->GetScripts()->variables.Set("@thismsg",DefScriptTools::toString(target_guid)); - - - DEBUG(logdebug("Chat packet recieved, type=%u lang=%u src="I64FMT" dst="I64FMT" chn='%s' len=%u", - type,lang,source_guid,target_guid,channel.c_str(),msglen)); - - if (type == CHAT_MSG_SYSTEM) - { - logcustom(0,WHITE,"SYSMSG: \"%s\"",msg.c_str()); - } - else if (type==CHAT_MSG_WHISPER ) - { - logcustom(0,WHITE,"WHISP: %s [%s]: %s",name.c_str(),ln,msg.c_str()); - } - else if (type==CHAT_MSG_CHANNEL ) - { - logcustom(0,WHITE,"CHANNEL: [%s]: %s [%s]: %s",channel.c_str(),name.c_str(),ln,msg.c_str()); - } - else if (type==CHAT_MSG_SAY ) - { - logcustom(0,WHITE,"CHAT: %s [%s]: %s",name.c_str(),ln,msg.c_str()); - } - else if (type==CHAT_MSG_YELL ) - { - logcustom(0,WHITE,"CHAT: %s yells [%s]: %s ",name.c_str(),ln,msg.c_str()); - } - else if (type==CHAT_MSG_WHISPER_INFORM ) - { - logcustom(0,WHITE,"TO %s [%s]: %s",name.c_str(),ln,msg.c_str()); - } - else if (type==CHAT_MSG_GUILD ) - { - logcustom(0,WHITE,"GUILD: %s [%s]: %s",name.c_str(),ln,msg.c_str()); - } - else if (type==CHAT_MSG_PARTY ) - { - logcustom(0,WHITE,"PARTY: %s [%s]: %s",name.c_str(),ln,msg.c_str()); - } - else if (type==CHAT_MSG_EMOTE ) - { - logcustom(0,WHITE,"EMOTE [%s]: %s %s",ln,name.c_str(),msg.c_str()); - } - else if (type==CHAT_MSG_MONSTER_SAY) - { - logcustom(0,WHITE,"NPC: %s [%s]: %s",name.c_str(),ln,msg.c_str()); - } - else - { - logcustom(0,WHITE,"UNK CHAT TYPE (%u): %s [%s]: %s",type,name.c_str(),ln,msg.c_str()); - } - - if(target_guid!=GetGuid() && msg.length()>1 && msg.at(0)=='-' && GetInstance()->GetConf()->allowgamecmd) - isCmd=true; - - // some fun code :P - if(type==CHAT_MSG_SAY && target_guid!=_myGUID && !isCmd) - { - // TODO: insert a good ChatAI here. - if (GetInstance()->GetConf()->enablechatai) - { - if(msg=="lol") - SendChatMessage(CHAT_MSG_SAY,lang,"say \"lol\" if you have nothing else to say... lol xD",""); - else if(msg.length()>4 && msg.find("you?")!=std::string::npos) - SendChatMessage(CHAT_MSG_SAY,lang,GetInstance()->GetScripts()->variables.Get("@version").append(" -- i am a bot, made by False.Genesis, my master."),""); - else if(msg=="hi") - SendChatMessage(CHAT_MSG_SAY,lang,"Hi, wadup?",""); - else if(msg.length()<12 && msg.find("wtf")!=std::string::npos) - SendChatMessage(CHAT_MSG_SAY,lang,"Yeah, WTF is a good way to say you dont understand anything... :P",""); - else if(msg.length()<15 && (msg.find("omg")!=std::string::npos || msg.find("omfg")!=std::string::npos) ) - SendChatMessage(CHAT_MSG_SAY,lang,"OMG a bot logged in, you don't believe it :O",""); - else if(msg.find("from")!=std::string::npos || msg.find("download")!=std::string::npos) - SendChatMessage(CHAT_MSG_SAY,lang,"www.mangosclient.org",""); - else if(msg.find("Genesis")!=std::string::npos || msg.find("genesis")!=std::string::npos) - SendChatMessage(CHAT_MSG_YELL,lang,"False.Genesis, they are calling you!! Come here, master xD",""); - } - } - - if(!isCmd && GetInstance()->GetScripts()->GetScript("_onchatmessage")) - { - CmdSet Set; - Set.arg[0] = DefScriptTools::toString(type); - Set.arg[1] = DefScriptTools::toString(lang); - Set.arg[2] = DefScriptTools::toString(target_guid); - Set.arg[3] = channel; - Set.defaultarg = GetInstance()->GetScripts()->SecureString(msg); - GetInstance()->GetScripts()->RunScript("_onchatmessage",&Set); - } - - if(isCmd) - { - GetInstance()->GetScripts()->variables.Set("@thiscmd_name",name); - GetInstance()->GetScripts()->variables.Set("@thiscmd",DefScriptTools::toString(target_guid)); - std::string lin=msg.substr(1,msg.length()-1); - try - { - GetInstance()->GetScripts()->My_Run(lin,name); - } - catch (...) - { - SendChatMessage(CHAT_MSG_SAY,0,"Exception while trying to execute: [ "+lin+" ]",""); - } - - } - - // the following block searches for items in chat and queries them if they are unknown - if(!isCmd && target_guid!=_myGUID && msg.length()>strlen(CHAT_ITEM_BEGIN_STRING)) - { - for(uint32 pos=0;pos> lines; - for(uint32 i = 0; i < lines; i++) - { - recvPacket >> line; - logcustom(0,YELLOW,"MOTD: %s",line.c_str()); - } -} - -void WorldSession::_HandleNotificationOpcode(WorldPacket& recvPacket) -{ - std::string text; - recvPacket >> text; - logcustom(0,YELLOW,"NOTIFY: %s",text.c_str()); -} - -void WorldSession::_HandleNameQueryResponseOpcode(WorldPacket& recvPacket) -{ - uint64 pguid; - std::string pname; - recvPacket >> pguid >> pname; - if(pname.length()>12 || pname.length()<2) - return; // playernames maxlen=12, minlen=2 - // rest of the packet is not interesting for now - if(plrNameCache.AddInfo(pguid,pname)) - { - logdetail("CACHE: Assigned new player name: '%s' = " I64FMTD ,pname.c_str(),pguid); - //if(GetInstance()->GetConf()->debug > 1) - // SendChatMessage(CHAT_MSG_SAY,0,"Player "+pname+" added to cache.",""); - } - WorldObject *wo = (WorldObject*)objmgr.GetObj(pguid); - if(wo) - wo->SetName(pname); -} - -void WorldSession::_HandlePongOpcode(WorldPacket& recvPacket) -{ - uint32 pong; - recvPacket >> pong; - _lag_ms = clock() - pong; - if(GetInstance()->GetConf()->notifyping) - log("Recieved Ping reply: %u ms latency.", _lag_ms); -} -void WorldSession::_HandleTradeStatusOpcode(WorldPacket& recvPacket) -{ - recvPacket.hexlike(); - uint8 unk; - recvPacket >> unk; - if(unk==1) - { - SendChatMessage(CHAT_MSG_SAY,0,"It has no sense trying to trade with me, that feature is not yet implemented!",""); - WorldPacket pkt; - pkt.SetOpcode(CMSG_CANCEL_TRADE); - SendWorldPacket(pkt); - } -} - -void WorldSession::_HandleGroupInviteOpcode(WorldPacket& recvPacket) -{ - recvPacket.hexlike(); - WorldPacket pkt; - pkt.SetOpcode(CMSG_GROUP_DECLINE); - SendWorldPacket(pkt); -} - -void WorldSession::_HandleMovementOpcode(WorldPacket& recvPacket) -{ - uint32 flags, time, unk32; - float x, y, z, o; - uint64 guid; - uint8 unk8; - guid = recvPacket.GetPackedGuid(); - recvPacket >> flags >> unk8 >> time >> x >> y >> z >> o >> unk32; - DEBUG(logdebug("MOVE: "I64FMT" -> time=%u flags=%u x=%.4f y=%.4f z=%.4f o=%.4f",guid,time,flags,x,y,z,o)); - Object *obj = objmgr.GetObj(guid); - if(obj && obj->IsWorldObject()) - { - ((WorldObject*)obj)->SetPosition(x,y,z,o); - } -} - -void WorldSession::_HandleTelePortAckOpcode(WorldPacket& recvPacket) -{ - uint32 unk32,time; - uint64 guid; - uint8 unk8; - float x, y, z, o; - - guid = recvPacket.GetPackedGuid(); - recvPacket >> unk32 >> unk32 >> unk8 >> time >> x >> y >> z >> o >> unk32; - - logdetail("Got teleported, data: x: %f, y: %f, z: %f, o: %f, guid: "I64FMT, x, y, z, o, guid); - - // TODO: put this into a capsule class later, that autodetects movement flags etc. - WorldPacket response(MSG_MOVE_FALL_LAND,4+1+4+4+4+4+4+4); - response << uint32(0) << (uint8)0; // no flags; unk - response <<(uint32)getMSTime(); // time correct? - response << x << y << z << o << uint32(100); // simulate 100 msec fall time - SendWorldPacket(response); - - _world->UpdatePos(x,y); - - if(PseuGUI *gui = GetInstance()->GetGUI()) - { - gui->SetWorldPosition(WorldPosition(x,y,z,o)); - } - - if(GetInstance()->GetScripts()->ScriptExists("_onteleport")) - { - CmdSet Set; - Set.defaultarg = "false"; // teleported to other map = false - Set.arg[0] = DefScriptTools::toString(guid); - Set.arg[1] = DefScriptTools::toString(x); - Set.arg[2] = DefScriptTools::toString(y); - Set.arg[3] = DefScriptTools::toString(z); - Set.arg[4] = DefScriptTools::toString(o); - GetInstance()->GetScripts()->RunScriptIfExists("_onteleport"); - } -} - -void WorldSession::_HandleNewWorldOpcode(WorldPacket& recvPacket) -{ - DEBUG(logdebug("DEBUG: _HandleNewWorldOpcode() objs:%u mychar: ptr=0x%X, guid="I64FMT,objmgr.GetObjectCount(),GetMyChar(),GetMyChar()->GetGUID())); - uint32 mapid; - float x,y,z,o; - // we assume we are NOT on a transport! - // else we had to do the following before: - // recvPacket >> tmapid >> tx >> ty >> tz >> to; - recvPacket >> mapid >> x >> y >> z >> o; - if(GetMyChar()) - GetMyChar()->ClearSpells(); // will be resent by server - - // when getting teleported, the client sends CMSG_CANCEL_TRADE 2 times.. dont ask me why. - WorldPacket wp(CMSG_CANCEL_TRADE,8); - SendWorldPacket(wp); - SendWorldPacket(wp); - - wp.SetOpcode(MSG_MOVE_WORLDPORT_ACK); - SendWorldPacket(wp); - - wp.SetOpcode(CMSG_SET_ACTIVE_MOVER); - wp << GetGuid(); - SendWorldPacket(wp); - - // TODO: put this into a capsule class later, that autodetects movement flags etc. - WorldPacket response(MSG_MOVE_FALL_LAND,4+1+4+4+4+4+4+4); - response << uint32(0) << (uint8)0; // no flags; unk - response <<(uint32)getMSTime(); // time correct? - response << x << y << z << o << uint32(100); // simulate 100 msec fall time - SendWorldPacket(response); - - - - // TODO: clear action buttons - - // clear world data and load required maps - _world->Clear(); - _world->UpdatePos(x,y,mapid); - _world->Update(); - - // TODO: need to switch to SCENESTATE_LOGINSCREEN here, and after everything is loaded, back to SCENESTATE_WORLD - if(PseuGUI *gui = GetInstance()->GetGUI()) - { - //gui->SetSceneState(SCENESTATE_WORLD); - // commented out, should be world scene anyway at this point... - gui->SetWorldPosition(WorldPosition(x,y,z,o)); - } - - if(GetInstance()->GetScripts()->ScriptExists("_onteleport")) - { - CmdSet Set; - Set.defaultarg = "true"; // teleported to other map = false - Set.arg[0] = DefScriptTools::toString(mapid); - Set.arg[1] = DefScriptTools::toString(x); - Set.arg[2] = DefScriptTools::toString(y); - Set.arg[3] = DefScriptTools::toString(z); - Set.arg[4] = DefScriptTools::toString(o); - GetInstance()->GetScripts()->RunScriptIfExists("_onteleport"); - } -} - -void WorldSession::_HandleChannelNotifyOpcode(WorldPacket& recvPacket) -{ - _channels->HandleNotifyOpcode(recvPacket); -} - -void WorldSession::_HandleCastResultOpcode(WorldPacket& recvPacket) -{ - uint32 spellid,otherr = 0; - uint8 result, castCount; - recvPacket >> spellid >> result >> castCount; - if (recvPacket.rpos()+sizeof(uint32) <= recvPacket.size()) - recvPacket >> otherr; - logdetail("Cast of spell %u failed. result=%u, cast count=%u, additional info=%u",spellid,result,castCount,otherr); -} - -void WorldSession::_HandleCastSuccessOpcode(WorldPacket& recvPacket) -{ - uint32 spellId; - uint64 casterGuid; - - casterGuid = recvPacket.GetPackedGuid(); - recvPacket >> spellId; - - if (GetMyChar()->GetGUID() == casterGuid) - logdetail("Cast of spell %u successful.",spellId); - else - { - Object *caster = objmgr.GetObj(casterGuid); - if(caster) - logdetail("%s casted spell %u", caster->GetName(), spellId); - else - logerror("Caster of spell %u (GUID "I64FMT") is unknown object!",spellId,casterGuid); - } -} - -void WorldSession::_HandleInitialSpellsOpcode(WorldPacket& recvPacket) -{ - uint8 unk; - uint16 spellid,spellslot,count; - recvPacket >> unk >> count; - logdebug("Got initial spells list, %u spells.",count); - for(uint16 i = 0; i < count; i++) - { - recvPacket >> spellid >> spellslot; - logdebug("Initial Spell: id=%u slot=%u",spellid,spellslot); - GetMyChar()->AddSpell(spellid, spellslot); - } -} - -void WorldSession::_HandleLearnedSpellOpcode(WorldPacket& recvPacket) -{ - uint32 spellid; - recvPacket >> spellid; - GetMyChar()->AddSpell(spellid, 0); // other spells must be moved by +1 in slot? - - logdebug("Learned spell: id=%u",spellid); -} - -void WorldSession::_HandleRemovedSpellOpcode(WorldPacket& recvPacket) -{ - uint32 spellid; - recvPacket >> spellid; - GetMyChar()->RemoveSpell(spellid); - logdebug("Unlearned spell: id=%u",spellid); -} - -void WorldSession::_HandleChannelListOpcode(WorldPacket& recvPacket) -{ - _channels->HandleListRequest(recvPacket); -} - -void WorldSession::_HandleEmoteOpcode(WorldPacket& recvPacket) -{ - std::string name; - uint32 anim; // animation id? - uint64 guid; // guid of the unit performing the emote - recvPacket >> anim >> guid; - - if(guid) - { - Object *o = objmgr.GetObj(guid); - if(o) - { - name = o->GetName(); - } - if(name.empty()) - { - if(IS_PLAYER_GUID(guid)) - { - name = GetOrRequestPlayerName(guid); - if(name.empty()) - { - _DelayWorldPacket(recvPacket, uint32(GetLagMS() * 1.2f)); - return; - } - } - } - } - - logdebug(I64FMT " / %s performing emote; anim=%u",guid,name.c_str(),anim); - - // TODO: show emote in GUI :P -} - -void WorldSession::_HandleTextEmoteOpcode(WorldPacket& recvPacket) -{ - std::string name; // name of emote target - std::string name_from; // name of the unit performing the emote - uint32 emotetext; // emote id - int32 emotev; // variation (like different texts on /flirt and so on) - uint32 namelen; // length of name of emote target (without '\0' ) - uint64 guid; // guid of the unit performing the emote - uint8 c; // temp - - recvPacket >> guid >> emotetext >> *((uint32*)&emotev) >> namelen; - - // get the target name, which is NOT null-terminated - for(uint32 i = 0; i < namelen; i++) - { - recvPacket >> c; - if(c) - name += c; - } - - logdebug(I64FMT " Emote: name=%s text=%u variation=%i len=%u",guid,name.c_str(),emotetext,emotev,namelen); - SCPDatabaseMgr& dbmgr = GetInstance()->dbmgr; - if(dbmgr.HasDB("emote")) - { - SCPDatabase& db = dbmgr.GetDB("emote"); - std::string target,target2; - bool targeted=false; // if the emote is directed to anyone around or a specific target - bool targeted_me=false; // if the emote was targeted to us if it was targeted - bool from_me=false; // if we did the emote - bool female=false; // if emote causer is female - - if(GetMyChar()->GetGUID() == guid) // we caused the emote - from_me=true; - - if(name.length()) // is it directed to someone? - { - targeted=true; // if yes, we have a target - if(GetMyChar()->GetName() == name) // if the name is ours, its directed to us - targeted_me=true; - } - - Unit *u = (Unit*)objmgr.GetObj(guid); - if(u) - { - if(u->GetGender() != 0) // female - female=true; - name_from = u->GetName(); - } - - // if we targeted ourself, the general emote is used! - if(targeted && from_me && targeted_me) - targeted_me=false; - - // now build the string that is used to lookup the text in the database - if(from_me) - target += "me"; - else - target += "one"; - - if(targeted) - { - target += "to"; - if(targeted_me) - target += "me"; - else - target += "one"; - } - else - target += "general"; - - // not all emotes have a female version, so check if there is one in the database - if(female && db.GetField(emotetext).HasEntry(target + "female")) - target += "female"; - - logdebug("Looking up 'emote' SCP field %u entry '%s'",emotetext,target.c_str()); - - std::string etext; - etext = db.GetField(emotetext).GetString(target); - - char out[300]; // should be enough - - if(from_me) - sprintf(out,etext.c_str(),name.c_str()); - else - sprintf(out,etext.c_str(),name_from.c_str(),name.c_str()); - - logcustom(0,WHITE,"EMOTE: %s",out); - - } - else - { - logerror("Can't display emote text %u, SCP database \"emote\" not loaded.",emotetext); - } - -} - -void WorldSession::_HandleLoginVerifyWorldOpcode(WorldPacket& recvPacket) -{ - float x,y,z,o; - uint32 m; - recvPacket >> m >> x >> y >> z >> o; - logdebug("LoginVerifyWorld: map=%u x=%f y=%f z=%f o=%f",m,x,y,z,o); - _OnEnterWorld(); - // update the world as soon as the server confirmed that we are where we are. - _world->UpdatePos(x,y,m); - _world->Update(); - - // temp. solution to test terrain rendering - if(PseuGUI *gui = GetInstance()->GetGUI()) - { - gui->SetSceneState(SCENESTATE_WORLD); - gui->SetWorldPosition(WorldPosition(x,y,z,o)); - } -} - -ByteBuffer& operator>>(ByteBuffer& bb, WhoListEntry& e) -{ - bb >> e.name >> e.gname >> e.level >> e.classId >> e.raceId >> e.zoneId; - return bb; -} - -void WorldSession::_HandleWhoOpcode(WorldPacket& recvPacket) -{ - uint32 count, unk; - recvPacket >> count >> unk; - - log("Got WHO-List, %u players. (unk=%u)",count,unk); - - if(count >= 1) - { - log(" Name |Level| Class | Race | Zone; Guild"); - log("--------------+-----+------------+--------------+----------------"); - if(count > 1) - { - _whoList.clear(); // need to clear current list only if requesting more then one player name - } - } - - for(uint32 i = 0; i < count; i++) - { - WhoListEntry wle; - recvPacket >> wle; - - _whoList.push_back(wle); - - // original WhoListEntry is saved, now do some formatting - while(wle.name.length() < 13) - wle.name.append(" "); - - SCPDatabaseMgr& db = GetInstance()->dbmgr; - char classname[20], racename[20]; - std::string zonename; - memset(classname,0,sizeof(classname)); - memset(racename,0,sizeof(racename)); - zonename = db.GetZoneName(wle.zoneId); - strcpy(classname, db.GetClassName_(wle.classId).c_str()); - strcpy(racename, db.GetRaceName(wle.raceId).c_str()); - - for(uint8 i = strlen(classname); strlen(classname) < 10; i++) - classname[i] = ' '; - for(uint8 i = strlen(racename); strlen(racename) < 12; i++) - racename[i] = ' '; - char tmp[12]; - sprintf(tmp,"%u",wle.level); - std::string lvl_str = tmp; - while(lvl_str.length() < 3) - lvl_str = " " + lvl_str; - - log("%s | %s | %s | %s | %s; %s", wle.name.c_str(), lvl_str.c_str(), classname, racename, zonename.c_str(), wle.gname.c_str()); - } -} - -void WorldSession::_HandleCreatureQueryResponseOpcode(WorldPacket& recvPacket) -{ - uint32 entry; - recvPacket >> entry; - if( (!entry) || (entry & 0x80000000) ) // last bit marks that entry is invalid / does not exist on server side - { - uint32 real_entry = entry & ~0x80000000; - logerror("Creature %u does not exist!", real_entry); - objmgr.AddNonexistentCreature(real_entry); - return; - } - - CreatureTemplate *ct = new CreatureTemplate(); - std::string s; - uint32 unk; - float unkf; - ct->entry = entry; - recvPacket >> ct->name; - recvPacket >> s; - recvPacket >> s; - recvPacket >> s; - recvPacket >> ct->subname; - recvPacket >> ct->directions; - recvPacket >> ct->flag1; - recvPacket >> ct->type; - recvPacket >> ct->family; - recvPacket >> ct->rank; - recvPacket >> unk; - recvPacket >> ct->SpellDataId; - recvPacket >> ct->displayid_A; - recvPacket >> ct->displayid_H; - recvPacket >> ct->displayid_AF; - recvPacket >> ct->displayid_HF; - recvPacket >> unkf; - recvPacket >> unkf; - recvPacket >> ct->RacialLeader; - - std::stringstream ss; - ss << "Got info for creature " << entry << ":" << ct->name; - if(!ct->subname.empty()) - ss << " <" << ct->subname << ">"; - ss << " type " << ct->type; - ss << " flags " << ct->flag1; - ss << " models " << ct->displayid_A << "/" << ct->displayid_H; - logdetail("%s",ss.str().c_str()); - - objmgr.Add(ct); - objmgr.AssignNameToObj(entry, TYPEID_UNIT, ct->name); -} - - - -// TODO: delete world on LogoutComplete once implemented - - - - +#include "common.h" + +#include "Auth/Sha1.h" +#include "Auth/BigNumber.h" +#include "Auth/AuthCrypt.h" +#include "WorldPacket.h" +#include "WorldSocket.h" +#include "RealmSocket.h" +#include "Channel.h" +#include "ObjMgr.h" +#include "World.h" +#include "RealmSession.h" +#include "WorldSession.h" + +struct OpcodeHandler +{ + uint16 opcode; + void (WorldSession::*handler)(WorldPacket& recvPacket); +}; + +WorldSession::WorldSession(PseuInstance *in) +{ + logdebug("-> Starting WorldSession 0x%X from instance 0x%X",this,in); // should never output a null ptr + _instance = in; + _mustdie=false; + _logged=false; + _socket=NULL; + _myGUID=0; // i dont have a guid yet + _channels = new Channel(this); + _world = new World(this); + _sh.SetAutoCloseSockets(false); + objmgr.SetInstance(in); + _lag_ms = 0; + //... + + in->GetScripts()->RunScriptIfExists("_onworldsessioncreate"); + + DEBUG(logdebug("WorldSession 0x%X constructor finished",this)); +} + +WorldSession::~WorldSession() +{ + _instance->GetScripts()->RunScriptIfExists("_onworldsessiondelete"); + + logdebug("~WorldSession(): %u packets left unhandled, and %u delayed. deleting.",pktQueue.size(),delayedPktQueue.size()); + WorldPacket *packet; + // clear the queue + while(pktQueue.size()) + { + packet = pktQueue.next(); + delete packet; + } + // clear the delayed queue + while(delayedPktQueue.size()) + { + packet = delayedPktQueue.back().pkt; + delayedPktQueue.pop_back(); + delete packet; + } + + if(_channels) + delete _channels; + if(_socket) + delete _socket; + if(_world) + delete _world; + DEBUG(logdebug("~WorldSession() this=0x%X _instance=0x%X",this,_instance)); +} + +void WorldSession::SetMustDie(void) +{ + _mustdie = true; + logdebug("WorldSession: Must die now."); +} + +void WorldSession::Start(void) +{ + log("Connecting to '%s' on port %u",GetInstance()->GetConf()->worldhost.c_str(),GetInstance()->GetConf()->worldport); + _socket=new WorldSocket(_sh,this); + _socket->Open(GetInstance()->GetConf()->worldhost,GetInstance()->GetConf()->worldport); + if(GetInstance()->GetRSession()) + { + GetInstance()->GetRSession()->SetMustDie(); // realm session is no longer needed + } + _sh.Add(_socket); + + // if we cant connect, wait until the socket gives up (after 5 secs) + while( (!MustDie()) && (!_socket->IsOk()) && (!GetInstance()->Stopped()) ) + { + logdev("WorldSession::Start(): Socket not ok, waiting..."); + _sh.Select(3,0); + GetInstance()->Sleep(100); + } + logdev("WorldSession::Start() done, mustdie:%u, socket_ok:%u stopped:%u",MustDie(),_socket->IsOk(),GetInstance()->Stopped()); +} + +void WorldSession::_LoadCache(void) +{ + logdetail("Loading Cache..."); + plrNameCache.ReadFromFile(); // load names/guids of known players + ItemProtoCache_InsertDataToSession(this); + CreatureTemplateCache_InsertDataToSession(this); + //... +} + +void WorldSession::AddToPktQueue(WorldPacket *pkt) +{ + pktQueue.add(pkt); +} + +void WorldSession::SendWorldPacket(WorldPacket &pkt) +{ + if(GetInstance()->GetConf()->showmyopcodes) + logcustom(0,BROWN,"<< Opcode %u [%s] (%u bytes)", pkt.GetOpcode(), GetOpcodeName(pkt.GetOpcode()), pkt.size()); + if(_socket && _socket->IsOk()) + _socket->SendWorldPacket(pkt); + else + { + logerror("WorldSession: Can't send WorldPacket, socket doesn't exist or is not ready."); + } +} + +void WorldSession::Update(void) +{ + if( _sh.GetCount() ) // the socket will remove itself from the handler if it got closed + _sh.Select(0,0); + else // so we just need to check if the socket doesnt exist or if it exists but isnt valid anymore. + { // if thats the case, we dont need the session anymore either + if(!_socket || (_socket && !_socket->IsOk())) + { + _OnLeaveWorld(); + SetMustDie(); + } + } + + // while there are packets on the queue, handle them + while(pktQueue.size()) + { + HandleWorldPacket(pktQueue.next()); + } + + // now check if there are packets that couldnt be handled earlier due to missing data + _HandleDelayedPackets(); + + _DoTimedActions(); + + if(_world) + _world->Update(); +} + +// this func will delete the WorldPacket after it is handled! +void WorldSession::HandleWorldPacket(WorldPacket *packet) +{ + static DefScriptPackage *sc = GetInstance()->GetScripts(); + static OpcodeHandler *table = _GetOpcodeHandlerTable(); + + bool known = false; + uint16 hpos; + + for (hpos = 0; table[hpos].handler != NULL; hpos++) + { + if (table[hpos].opcode == packet->GetOpcode()) + { + known=true; + break; + } + } + + bool hideOpcode = false; + bool disabledOpcode = IsOpcodeDisabled(packet->GetOpcode()); + if(disabledOpcode && GetInstance()->GetConf()->hideDisabledOpcodes) + hideOpcode = true; + + // TODO: Maybe make table or something with all the frequently opcodes + if (GetInstance()->GetConf()->hidefreqopcodes) + { + switch(packet->GetOpcode()) + { + case SMSG_MONSTER_MOVE: + hideOpcode = true; + } + } + + if( (known && GetInstance()->GetConf()->showopcodes==1) + || ((!known) && GetInstance()->GetConf()->showopcodes==2) + || (GetInstance()->GetConf()->showopcodes==3) ) + { + if(!hideOpcode) + logcustom(1,YELLOW,">> Opcode %u [%s] (%s, %u bytes)", packet->GetOpcode(), GetOpcodeName(packet->GetOpcode()), (known ? (disabledOpcode ? "Disabled" : "Known") : "UNKNOWN"), packet->size()); + } + + try + { + // if there is a script attached to that opcode, call it now. + // note: the pkt rpos needs to be reset by the scripts! + std::string scname = "opcode::"; + scname += stringToLower(GetOpcodeName(packet->GetOpcode())); + if(sc->ScriptExists(scname)) + { + std::string pktname = "PACKET::"; + pktname += GetOpcodeName(packet->GetOpcode()); + GetInstance()->GetScripts()->bytebuffers.Assign(pktname,packet); + sc->RunScript(scname,NULL); + GetInstance()->GetScripts()->bytebuffers.Unlink(pktname); + } + + // call the opcode handler + if(known && !disabledOpcode) + { + packet->rpos(0); + (this->*table[hpos].handler)(*packet); + } + } + catch (ByteBufferException bbe) + { + logerror("Exception while handling opcode %u [%s]!",packet->GetOpcode(),GetOpcodeName(packet->GetOpcode())); + logerror("WorldSession: ByteBufferException"); + logerror("ByteBuffer reported: attempt to \"%s\" %u bytes at position %u out of total %u bytes. (wpos=%u)", + bbe.action, bbe.readsize, bbe.rpos, bbe.cursize, bbe.wpos); + // copied from below + logerror("Data: pktsize=%u, handler=0x%X queuesize=%u",packet->size(),table[hpos].handler,pktQueue.size()); + logerror("Packet Hexdump:"); + logerror("%s",toHexDump((uint8*)packet->contents(),packet->size(),true).c_str()); + } + catch (...) + { + logerror("Exception while handling opcode %u [%s]!",packet->GetOpcode(),GetOpcodeName(packet->GetOpcode())); + logerror("Data: pktsize=%u, handler=0x%X queuesize=%u",packet->size(),table[hpos].handler,pktQueue.size()); + logerror("Packet Hexdump:"); + logerror("%s",toHexDump((uint8*)packet->contents(),packet->size(),true).c_str()); + } + + delete packet; +} + + +OpcodeHandler *WorldSession::_GetOpcodeHandlerTable() const +{ + static OpcodeHandler table[] = + { + { SMSG_AUTH_CHALLENGE, &WorldSession::_HandleAuthChallengeOpcode }, + { SMSG_AUTH_RESPONSE, &WorldSession::_HandleAuthResponseOpcode }, + {SMSG_CHAR_ENUM, &WorldSession::_HandleCharEnumOpcode}, + {SMSG_SET_PROFICIENCY, &WorldSession::_HandleSetProficiencyOpcode}, + {SMSG_ACCOUNT_DATA_MD5, &WorldSession::_HandleAccountDataMD5Opcode}, + {SMSG_MESSAGECHAT, &WorldSession::_HandleMessageChatOpcode}, + {SMSG_NAME_QUERY_RESPONSE, &WorldSession::_HandleNameQueryResponseOpcode}, + {SMSG_PONG, &WorldSession::_HandlePongOpcode}, + {SMSG_TRADE_STATUS, &WorldSession::_HandleTradeStatusOpcode}, + {SMSG_GROUP_INVITE, &WorldSession::_HandleGroupInviteOpcode}, + {SMSG_CHANNEL_NOTIFY, &WorldSession::_HandleChannelNotifyOpcode}, + + // movement opcodes + {MSG_MOVE_SET_FACING, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_START_FORWARD, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_START_BACKWARD, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_STOP, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_START_STRAFE_LEFT, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_START_STRAFE_RIGHT, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_STOP_STRAFE, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_JUMP, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_START_TURN_LEFT, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_START_TURN_RIGHT, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_STOP_TURN, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_START_SWIM, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_STOP_SWIM, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_HEARTBEAT, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_FALL_LAND, &WorldSession::_HandleMovementOpcode}, + {MSG_MOVE_TELEPORT_ACK, &WorldSession::_HandleTelePortAckOpcode}, + + {SMSG_COMPRESSED_UPDATE_OBJECT, &WorldSession::_HandleCompressedUpdateObjectOpcode}, + {SMSG_UPDATE_OBJECT, &WorldSession::_HandleUpdateObjectOpcode}, + {SMSG_CAST_RESULT, &WorldSession::_HandleCastResultOpcode}, + {SMSG_CAST_SUCCESS, &WorldSession::_HandleCastSuccessOpcode}, + {SMSG_ITEM_QUERY_SINGLE_RESPONSE, &WorldSession::_HandleItemQuerySingleResponseOpcode}, + {SMSG_DESTROY_OBJECT, &WorldSession::_HandleDestroyObjectOpcode}, + {SMSG_INITIAL_SPELLS, &WorldSession::_HandleInitialSpellsOpcode}, + {SMSG_LEARNED_SPELL, &WorldSession::_HandleLearnedSpellOpcode}, + {SMSG_REMOVED_SPELL, &WorldSession::_HandleLearnedSpellOpcode}, + {SMSG_CHANNEL_LIST, &WorldSession::_HandleChannelListOpcode}, + {SMSG_EMOTE, &WorldSession::_HandleEmoteOpcode}, + {SMSG_TEXT_EMOTE, &WorldSession::_HandleTextEmoteOpcode}, + {SMSG_NEW_WORLD, &WorldSession::_HandleNewWorldOpcode}, + {SMSG_LOGIN_VERIFY_WORLD, &WorldSession::_HandleLoginVerifyWorldOpcode}, + {SMSG_MOTD, &WorldSession::_HandleMotdOpcode}, + {SMSG_NOTIFICATION, &WorldSession::_HandleNotificationOpcode}, + {SMSG_WHO, &WorldSession::_HandleWhoOpcode}, + {SMSG_CREATURE_QUERY_RESPONSE, &WorldSession::_HandleCreatureQueryResponseOpcode}, + + // table termination + { 0, NULL } + }; + return table; +} + +void WorldSession::_DelayWorldPacket(WorldPacket& pkt, uint32 ms) +{ + DEBUG(logdebug("DelayWorldPacket (%s, size: %u, ms: %u)",GetOpcodeName(pkt.GetOpcode()),pkt.size(),ms)); + // need to copy the packet, because the current packet will be deleted after it got handled + WorldPacket *pktcopy = new WorldPacket(pkt.GetOpcode(),pkt.size()); + pktcopy->append(pkt.contents(),pkt.size()); + delayedPktQueue.push_back(DelayedWorldPacket(pktcopy,ms)); + DEBUG(logdebug("-> WP ptr = 0x%X",pktcopy)); +} + +void WorldSession::_HandleDelayedPackets(void) +{ + if(delayedPktQueue.size()) + { + DelayedPacketQueue copy(delayedPktQueue); + delayedPktQueue.clear(); // clear original, since it might be filled up by newly delayed packets, which would cause endless loop + while(copy.size()) + { + DelayedWorldPacket d = copy.front(); + copy.pop_front(); // remove packet from front + if(clock() >= d.when) // if its time to handle this packet, do so + { + DEBUG(logdebug("Handling delayed packet (%s [%u], size: %u, ptr: 0x%X)",GetOpcodeName(d.pkt->GetOpcode()),d.pkt->GetOpcode(),d.pkt->size(),d.pkt)); + HandleWorldPacket(d.pkt); + } + else + { + delayedPktQueue.push_back(d); // and if not, put it again onto the queue + } + } + } +} + + +void WorldSession::SetTarget(uint64 guid) +{ + SendSetSelection(guid); +} + +void WorldSession::_OnEnterWorld(void) +{ + if(!InWorld()) + { + _logged=true; + GetInstance()->GetScripts()->variables.Set("@inworld","true"); + GetInstance()->GetScripts()->RunScriptIfExists("_enterworld"); + + } +} + +void WorldSession::_OnLeaveWorld(void) +{ + if(InWorld()) + { + _logged=false; + GetInstance()->GetScripts()->RunScriptIfExists("_leaveworld"); + GetInstance()->GetScripts()->variables.Set("@inworld","false"); + } +} + +void WorldSession::_DoTimedActions(void) +{ + static clock_t pingtime=0; + if(InWorld()) + { + if(pingtime < clock()) + { + pingtime=clock() + 30*CLOCKS_PER_SEC; + SendPing(clock()); + } + //... + } +} + +std::string WorldSession::GetOrRequestPlayerName(uint64 guid) +{ + if(!guid || GUID_HIPART(guid) != HIGHGUID_PLAYER) + { + logerror("WorldSession::GetOrRequestObjectName: "I64FMT" is not player",guid); + return ""; // TODO: temporary, to find bugs with this, if there are any + } + std::string name = plrNameCache.GetName(guid); + if(name.empty()) + { + if(!objmgr.IsRequestedPlayerGUID(guid)) + { + objmgr.AddRequestedPlayerGUID(guid); + SendQueryPlayerName(guid); + } + } + return name; +} + + + + + +/////////////////////////////////////////////////////////////// +// Opcode Handlers +/////////////////////////////////////////////////////////////// + +void WorldSession::_HandleAuthChallengeOpcode(WorldPacket& recvPacket) +{ + std::string acc = stringToUpper(GetInstance()->GetConf()->accname); + uint32 serverseed; + recvPacket >> serverseed; + logdebug("Auth: serverseed=0x%X",serverseed); + Sha1Hash digest; + digest.UpdateData(acc); + uint32 unk=0; + digest.UpdateData((uint8*)&unk,sizeof(uint32)); + BigNumber clientseed; + clientseed.SetRand(8*4); + uint32 clientseed_uint32=clientseed.AsDword(); + digest.UpdateData((uint8*)&clientseed_uint32,sizeof(uint32)); + digest.UpdateData((uint8*)&serverseed,sizeof(uint32)); + digest.UpdateBigNumbers(GetInstance()->GetSessionKey(),NULL); + digest.Finalize(); + WorldPacket auth; + auth<<(uint32)(GetInstance()->GetConf()->clientbuild)<InitCrypt(GetInstance()->GetSessionKey()->AsByteArray(), 40); + +} + +void WorldSession::_HandleAuthResponseOpcode(WorldPacket& recvPacket) +{ + uint8 errcode; + recvPacket >> errcode; + if(errcode==0xC){ + logdetail("World Authentication successful, preparing for char list request..."); + WorldPacket pkt; + pkt.SetOpcode(CMSG_CHAR_ENUM); + SendWorldPacket(pkt); + } else { + logcritical("World Authentication failed, errcode=0x%X",(unsigned char)errcode); + GetInstance()->SetError(); + } +} + +void WorldSession::_HandleCharEnumOpcode(WorldPacket& recvPacket) +{ + uint8 num; + uint8 charId; + PlayerEnum plr[10]; // max characters per realm is 10 + uint8 dummy8; + + recvPacket >> num; + if(num==0) + { + logerror("No chars found!"); + GetInstance()->SetError(); + return; + } + + logdetail("Chars in list: %u",num); + _LoadCache(); // we are about to login, so we need cache data + for(unsigned int i=0;i> plr[i]._guid; + recvPacket >> plr[i]._name; + recvPacket >> plr[i]._race; + recvPacket >> plr[i]._class; + recvPacket >> plr[i]._gender; + recvPacket >> plr[i]._bytes1; + recvPacket >> plr[i]._bytes2; + recvPacket >> plr[i]._bytes3; + recvPacket >> plr[i]._bytes4; + recvPacket >> plr[i]._bytesx; + recvPacket >> plr[i]._level; + recvPacket >> plr[i]._zoneId; + recvPacket >> plr[i]._mapId; + recvPacket >> plr[i]._x; + recvPacket >> plr[i]._y; + recvPacket >> plr[i]._z; + recvPacket >> plr[i]._guildId; + recvPacket >> dummy8; + recvPacket >> plr[i]._flags; + recvPacket >> dummy8 >> dummy8 >> dummy8; + recvPacket >> plr[i]._petInfoId; + recvPacket >> plr[i]._petLevel; + recvPacket >> plr[i]._petFamilyId; + for(unsigned int inv=0;inv<20;inv++) + { + recvPacket >> plr[i]._items[inv].displayId >> plr[i]._items[inv].inventorytype; + } + plrNameCache.AddInfo(plr[i]._guid, plr[i]._name); + } + bool char_found=false; + + for(unsigned int i=0;i coords: map=%u zone=%u x=%f y=%f z=%f", + plr[i]._mapId,plr[i]._zoneId,plr[i]._x,plr[i]._y,plr[i]._z); + + for(unsigned int inv=0;inv<20;inv++) + { + if(plr[i]._items[inv].displayId) + logdebug("-> Has Item: Model=%u InventoryType=%u",plr[i]._items[inv].displayId,plr[i]._items[inv].inventorytype); + } + if(plr[i]._name==GetInstance()->GetConf()->charname) + { + charId = i; + char_found=true; + _myGUID=plr[i]._guid; + GetInstance()->GetScripts()->variables.Set("@myguid",DefScriptTools::toString(plr[i]._guid)); + GetInstance()->GetScripts()->variables.Set("@myrace",DefScriptTools::toString((uint64)plr[i]._race)); + } + + } + if(!char_found) + { + logerror("Character \"%s\" was not found on char list!", plr[charId]._name.c_str()); + GetInstance()->SetError(); + return; + } + else + { + log("Entering World with Character \"%s\"...", plr[charId]._name.c_str()); + + // create the character and add it to the objmgr. + // note: this is the only object that has to stay in memory unless its explicitly deleted by the server! + // that means even if the server sends create object with that guid, do NOT recreate it!! + MyCharacter *my = new MyCharacter(); + my->Create(_myGUID); + objmgr.Add(my); + my->SetName(plr[charId]._name); + + // TODO: initialize the world here, and load required maps. + // must remove appropriate code from _HandleLoginVerifyWorldOpcode() then!! + + WorldPacket pkt(CMSG_PLAYER_LOGIN,8); + pkt << _myGUID; + SendWorldPacket(pkt); + } +} + + +void WorldSession::_HandleSetProficiencyOpcode(WorldPacket& recvPacket) +{ + if(recvPacket.size()) + { + DEBUG( + logdebug("SetProficiency: Hexdump:"); + logdebug(toHexDump((uint8*)recvPacket.contents(),recvPacket.size(),true).c_str()); + ); + } +} + +void WorldSession::_HandleAccountDataMD5Opcode(WorldPacket& recvPacket) +{ + // packet structure not yet known +} + +void WorldSession::_HandleMessageChatOpcode(WorldPacket& recvPacket) +{ + uint8 type=0; + uint32 lang=0; + uint64 source_guid=0; + uint64 target_guid=0; + uint64 npc_guid=0; // for CHAT_MSG_MONSTER_SAY + uint32 msglen=0; + uint32 unk=0; + uint32 npc_name_len; + std::string npc_name; + std::string msg,channel=""; + bool isCmd=false; + + recvPacket >> type >> lang; + + if(lang == CHAT_MSG_MONSTER_SAY) + { + recvPacket >> npc_guid; + recvPacket >> unk; + recvPacket >> npc_name_len; + recvPacket >> npc_name; + } + + if(lang == LANG_ADDON && GetInstance()->GetConf()->skipaddonchat) + return; + + recvPacket >> source_guid >> unk; // added in 2.1.0 + if (type == CHAT_MSG_CHANNEL) + { + recvPacket >> channel; // extract channel name + } + recvPacket >> target_guid >> msglen >> msg; + + std::string langname = GetDBMgr().GetLangName(lang); + const char* ln = langname.c_str(); + std::string name; + + if(type == CHAT_MSG_MONSTER_SAY) + { + name = npc_name; + source_guid = npc_guid; + } + + if(source_guid && IS_PLAYER_GUID(source_guid)) + { + name = GetOrRequestPlayerName(source_guid); + if(name.empty()) + { + _DelayWorldPacket(recvPacket, uint32(GetLagMS() * 1.2f)); // guess time how long it will take until we got player name from the server + return; // handle later + } + } + GetInstance()->GetScripts()->variables.Set("@thismsg_name",name); + GetInstance()->GetScripts()->variables.Set("@thismsg",DefScriptTools::toString(target_guid)); + + + DEBUG(logdebug("Chat packet recieved, type=%u lang=%u src="I64FMT" dst="I64FMT" chn='%s' len=%u", + type,lang,source_guid,target_guid,channel.c_str(),msglen)); + + if (type == CHAT_MSG_SYSTEM) + { + logcustom(0,WHITE,"SYSMSG: \"%s\"",msg.c_str()); + } + else if (type==CHAT_MSG_WHISPER ) + { + logcustom(0,WHITE,"WHISP: %s [%s]: %s",name.c_str(),ln,msg.c_str()); + } + else if (type==CHAT_MSG_CHANNEL ) + { + logcustom(0,WHITE,"CHANNEL: [%s]: %s [%s]: %s",channel.c_str(),name.c_str(),ln,msg.c_str()); + } + else if (type==CHAT_MSG_SAY ) + { + logcustom(0,WHITE,"CHAT: %s [%s]: %s",name.c_str(),ln,msg.c_str()); + } + else if (type==CHAT_MSG_YELL ) + { + logcustom(0,WHITE,"CHAT: %s yells [%s]: %s ",name.c_str(),ln,msg.c_str()); + } + else if (type==CHAT_MSG_WHISPER_INFORM ) + { + logcustom(0,WHITE,"TO %s [%s]: %s",name.c_str(),ln,msg.c_str()); + } + else if (type==CHAT_MSG_GUILD ) + { + logcustom(0,WHITE,"GUILD: %s [%s]: %s",name.c_str(),ln,msg.c_str()); + } + else if (type==CHAT_MSG_PARTY ) + { + logcustom(0,WHITE,"PARTY: %s [%s]: %s",name.c_str(),ln,msg.c_str()); + } + else if (type==CHAT_MSG_EMOTE ) + { + logcustom(0,WHITE,"EMOTE [%s]: %s %s",ln,name.c_str(),msg.c_str()); + } + else if (type==CHAT_MSG_MONSTER_SAY) + { + logcustom(0,WHITE,"NPC: %s [%s]: %s",name.c_str(),ln,msg.c_str()); + } + else + { + logcustom(0,WHITE,"UNK CHAT TYPE (%u): %s [%s]: %s",type,name.c_str(),ln,msg.c_str()); + } + + if(target_guid!=GetGuid() && msg.length()>1 && msg.at(0)=='-' && GetInstance()->GetConf()->allowgamecmd) + isCmd=true; + + // some fun code :P + if(type==CHAT_MSG_SAY && target_guid!=_myGUID && !isCmd) + { + // TODO: insert a good ChatAI here. + if (GetInstance()->GetConf()->enablechatai) + { + if(msg=="lol") + SendChatMessage(CHAT_MSG_SAY,lang,"say \"lol\" if you have nothing else to say... lol xD",""); + else if(msg.length()>4 && msg.find("you?")!=std::string::npos) + SendChatMessage(CHAT_MSG_SAY,lang,GetInstance()->GetScripts()->variables.Get("@version").append(" -- i am a bot, made by False.Genesis, my master."),""); + else if(msg=="hi") + SendChatMessage(CHAT_MSG_SAY,lang,"Hi, wadup?",""); + else if(msg.length()<12 && msg.find("wtf")!=std::string::npos) + SendChatMessage(CHAT_MSG_SAY,lang,"Yeah, WTF is a good way to say you dont understand anything... :P",""); + else if(msg.length()<15 && (msg.find("omg")!=std::string::npos || msg.find("omfg")!=std::string::npos) ) + SendChatMessage(CHAT_MSG_SAY,lang,"OMG a bot logged in, you don't believe it :O",""); + else if(msg.find("from")!=std::string::npos || msg.find("download")!=std::string::npos) + SendChatMessage(CHAT_MSG_SAY,lang,"www.mangosclient.org",""); + else if(msg.find("Genesis")!=std::string::npos || msg.find("genesis")!=std::string::npos) + SendChatMessage(CHAT_MSG_YELL,lang,"False.Genesis, they are calling you!! Come here, master xD",""); + } + } + + if(!isCmd && GetInstance()->GetScripts()->GetScript("_onchatmessage")) + { + CmdSet Set; + Set.arg[0] = DefScriptTools::toString(type); + Set.arg[1] = DefScriptTools::toString(lang); + Set.arg[2] = DefScriptTools::toString(target_guid); + Set.arg[3] = channel; + Set.defaultarg = GetInstance()->GetScripts()->SecureString(msg); + GetInstance()->GetScripts()->RunScript("_onchatmessage",&Set); + } + + if(isCmd) + { + GetInstance()->GetScripts()->variables.Set("@thiscmd_name",name); + GetInstance()->GetScripts()->variables.Set("@thiscmd",DefScriptTools::toString(target_guid)); + std::string lin=msg.substr(1,msg.length()-1); + try + { + GetInstance()->GetScripts()->My_Run(lin,name); + } + catch (...) + { + SendChatMessage(CHAT_MSG_SAY,0,"Exception while trying to execute: [ "+lin+" ]",""); + } + + } + + // the following block searches for items in chat and queries them if they are unknown + if(!isCmd && target_guid!=_myGUID && msg.length()>strlen(CHAT_ITEM_BEGIN_STRING)) + { + for(uint32 pos=0;pos> lines; + for(uint32 i = 0; i < lines; i++) + { + recvPacket >> line; + logcustom(0,YELLOW,"MOTD: %s",line.c_str()); + } +} + +void WorldSession::_HandleNotificationOpcode(WorldPacket& recvPacket) +{ + std::string text; + recvPacket >> text; + logcustom(0,YELLOW,"NOTIFY: %s",text.c_str()); +} + +void WorldSession::_HandleNameQueryResponseOpcode(WorldPacket& recvPacket) +{ + uint64 pguid; + std::string pname; + recvPacket >> pguid >> pname; + if(pname.length()>12 || pname.length()<2) + return; // playernames maxlen=12, minlen=2 + // rest of the packet is not interesting for now + if(plrNameCache.AddInfo(pguid,pname)) + { + logdetail("CACHE: Assigned new player name: '%s' = " I64FMTD ,pname.c_str(),pguid); + //if(GetInstance()->GetConf()->debug > 1) + // SendChatMessage(CHAT_MSG_SAY,0,"Player "+pname+" added to cache.",""); + } + WorldObject *wo = (WorldObject*)objmgr.GetObj(pguid); + if(wo) + wo->SetName(pname); +} + +void WorldSession::_HandlePongOpcode(WorldPacket& recvPacket) +{ + uint32 pong; + recvPacket >> pong; + _lag_ms = clock() - pong; + if(GetInstance()->GetConf()->notifyping) + log("Recieved Ping reply: %u ms latency.", _lag_ms); +} +void WorldSession::_HandleTradeStatusOpcode(WorldPacket& recvPacket) +{ + recvPacket.hexlike(); + uint8 unk; + recvPacket >> unk; + if(unk==1) + { + SendChatMessage(CHAT_MSG_SAY,0,"It has no sense trying to trade with me, that feature is not yet implemented!",""); + WorldPacket pkt; + pkt.SetOpcode(CMSG_CANCEL_TRADE); + SendWorldPacket(pkt); + } +} + +void WorldSession::_HandleGroupInviteOpcode(WorldPacket& recvPacket) +{ + recvPacket.hexlike(); + WorldPacket pkt; + pkt.SetOpcode(CMSG_GROUP_DECLINE); + SendWorldPacket(pkt); +} + +void WorldSession::_HandleMovementOpcode(WorldPacket& recvPacket) +{ + uint32 flags, time, unk32; + float x, y, z, o; + uint64 guid; + uint8 unk8; + guid = recvPacket.GetPackedGuid(); + recvPacket >> flags >> unk8 >> time >> x >> y >> z >> o >> unk32; + DEBUG(logdebug("MOVE: "I64FMT" -> time=%u flags=%u x=%.4f y=%.4f z=%.4f o=%.4f",guid,time,flags,x,y,z,o)); + Object *obj = objmgr.GetObj(guid); + if(obj && obj->IsWorldObject()) + { + ((WorldObject*)obj)->SetPosition(x,y,z,o); + } +} + +void WorldSession::_HandleTelePortAckOpcode(WorldPacket& recvPacket) +{ + uint32 unk32,time; + uint64 guid; + uint8 unk8; + float x, y, z, o; + + guid = recvPacket.GetPackedGuid(); + recvPacket >> unk32 >> unk32 >> unk8 >> time >> x >> y >> z >> o >> unk32; + + logdetail("Got teleported, data: x: %f, y: %f, z: %f, o: %f, guid: "I64FMT, x, y, z, o, guid); + + // TODO: put this into a capsule class later, that autodetects movement flags etc. + WorldPacket response(MSG_MOVE_FALL_LAND,4+1+4+4+4+4+4+4); + response << uint32(0) << (uint8)0; // no flags; unk + response <<(uint32)getMSTime(); // time correct? + response << x << y << z << o << uint32(100); // simulate 100 msec fall time + SendWorldPacket(response); + + _world->UpdatePos(x,y); + + if(PseuGUI *gui = GetInstance()->GetGUI()) + { + gui->SetWorldPosition(WorldPosition(x,y,z,o)); + } + + if(GetInstance()->GetScripts()->ScriptExists("_onteleport")) + { + CmdSet Set; + Set.defaultarg = "false"; // teleported to other map = false + Set.arg[0] = DefScriptTools::toString(guid); + Set.arg[1] = DefScriptTools::toString(x); + Set.arg[2] = DefScriptTools::toString(y); + Set.arg[3] = DefScriptTools::toString(z); + Set.arg[4] = DefScriptTools::toString(o); + GetInstance()->GetScripts()->RunScriptIfExists("_onteleport"); + } +} + +void WorldSession::_HandleNewWorldOpcode(WorldPacket& recvPacket) +{ + DEBUG(logdebug("DEBUG: _HandleNewWorldOpcode() objs:%u mychar: ptr=0x%X, guid="I64FMT,objmgr.GetObjectCount(),GetMyChar(),GetMyChar()->GetGUID())); + uint32 mapid; + float x,y,z,o; + // we assume we are NOT on a transport! + // else we had to do the following before: + // recvPacket >> tmapid >> tx >> ty >> tz >> to; + recvPacket >> mapid >> x >> y >> z >> o; + if(GetMyChar()) + GetMyChar()->ClearSpells(); // will be resent by server + + // when getting teleported, the client sends CMSG_CANCEL_TRADE 2 times.. dont ask me why. + WorldPacket wp(CMSG_CANCEL_TRADE,8); + SendWorldPacket(wp); + SendWorldPacket(wp); + + wp.SetOpcode(MSG_MOVE_WORLDPORT_ACK); + SendWorldPacket(wp); + + wp.SetOpcode(CMSG_SET_ACTIVE_MOVER); + wp << GetGuid(); + SendWorldPacket(wp); + + // TODO: put this into a capsule class later, that autodetects movement flags etc. + WorldPacket response(MSG_MOVE_FALL_LAND,4+1+4+4+4+4+4+4); + response << uint32(0) << (uint8)0; // no flags; unk + response <<(uint32)getMSTime(); // time correct? + response << x << y << z << o << uint32(100); // simulate 100 msec fall time + SendWorldPacket(response); + + + + // TODO: clear action buttons + + // clear world data and load required maps + _world->Clear(); + _world->UpdatePos(x,y,mapid); + _world->Update(); + + // TODO: need to switch to SCENESTATE_LOGINSCREEN here, and after everything is loaded, back to SCENESTATE_WORLD + if(PseuGUI *gui = GetInstance()->GetGUI()) + { + //gui->SetSceneState(SCENESTATE_WORLD); + // commented out, should be world scene anyway at this point... + gui->SetWorldPosition(WorldPosition(x,y,z,o)); + } + + if(GetInstance()->GetScripts()->ScriptExists("_onteleport")) + { + CmdSet Set; + Set.defaultarg = "true"; // teleported to other map = false + Set.arg[0] = DefScriptTools::toString(mapid); + Set.arg[1] = DefScriptTools::toString(x); + Set.arg[2] = DefScriptTools::toString(y); + Set.arg[3] = DefScriptTools::toString(z); + Set.arg[4] = DefScriptTools::toString(o); + GetInstance()->GetScripts()->RunScriptIfExists("_onteleport"); + } +} + +void WorldSession::_HandleChannelNotifyOpcode(WorldPacket& recvPacket) +{ + _channels->HandleNotifyOpcode(recvPacket); +} + +void WorldSession::_HandleCastResultOpcode(WorldPacket& recvPacket) +{ + uint32 spellid,otherr = 0; + uint8 result, castCount; + recvPacket >> spellid >> result >> castCount; + if (recvPacket.rpos()+sizeof(uint32) <= recvPacket.size()) + recvPacket >> otherr; + logdetail("Cast of spell %u failed. result=%u, cast count=%u, additional info=%u",spellid,result,castCount,otherr); +} + +void WorldSession::_HandleCastSuccessOpcode(WorldPacket& recvPacket) +{ + uint32 spellId; + uint64 casterGuid; + + casterGuid = recvPacket.GetPackedGuid(); + recvPacket >> spellId; + + if (GetMyChar()->GetGUID() == casterGuid) + logdetail("Cast of spell %u successful.",spellId); + else + { + Object *caster = objmgr.GetObj(casterGuid); + if(caster) + logdetail("%s casted spell %u", caster->GetName(), spellId); + else + logerror("Caster of spell %u (GUID "I64FMT") is unknown object!",spellId,casterGuid); + } +} + +void WorldSession::_HandleInitialSpellsOpcode(WorldPacket& recvPacket) +{ + uint8 unk; + uint16 spellid,spellslot,count; + recvPacket >> unk >> count; + logdebug("Got initial spells list, %u spells.",count); + for(uint16 i = 0; i < count; i++) + { + recvPacket >> spellid >> spellslot; + logdebug("Initial Spell: id=%u slot=%u",spellid,spellslot); + GetMyChar()->AddSpell(spellid, spellslot); + } +} + +void WorldSession::_HandleLearnedSpellOpcode(WorldPacket& recvPacket) +{ + uint32 spellid; + recvPacket >> spellid; + GetMyChar()->AddSpell(spellid, 0); // other spells must be moved by +1 in slot? + + logdebug("Learned spell: id=%u",spellid); +} + +void WorldSession::_HandleRemovedSpellOpcode(WorldPacket& recvPacket) +{ + uint32 spellid; + recvPacket >> spellid; + GetMyChar()->RemoveSpell(spellid); + logdebug("Unlearned spell: id=%u",spellid); +} + +void WorldSession::_HandleChannelListOpcode(WorldPacket& recvPacket) +{ + _channels->HandleListRequest(recvPacket); +} + +void WorldSession::_HandleEmoteOpcode(WorldPacket& recvPacket) +{ + std::string name; + uint32 anim; // animation id? + uint64 guid; // guid of the unit performing the emote + recvPacket >> anim >> guid; + + if(guid) + { + Object *o = objmgr.GetObj(guid); + if(o) + { + name = o->GetName(); + } + if(name.empty()) + { + if(IS_PLAYER_GUID(guid)) + { + name = GetOrRequestPlayerName(guid); + if(name.empty()) + { + _DelayWorldPacket(recvPacket, uint32(GetLagMS() * 1.2f)); + return; + } + } + } + } + + logdebug(I64FMT " / %s performing emote; anim=%u",guid,name.c_str(),anim); + + // TODO: show emote in GUI :P +} + +void WorldSession::_HandleTextEmoteOpcode(WorldPacket& recvPacket) +{ + std::string name; // name of emote target + std::string name_from; // name of the unit performing the emote + uint32 emotetext; // emote id + int32 emotev; // variation (like different texts on /flirt and so on) + uint32 namelen; // length of name of emote target (without '\0' ) + uint64 guid; // guid of the unit performing the emote + uint8 c; // temp + + recvPacket >> guid >> emotetext >> *((uint32*)&emotev) >> namelen; + + // get the target name, which is NOT null-terminated + for(uint32 i = 0; i < namelen; i++) + { + recvPacket >> c; + if(c) + name += c; + } + + logdebug(I64FMT " Emote: name=%s text=%u variation=%i len=%u",guid,name.c_str(),emotetext,emotev,namelen); + SCPDatabaseMgr& dbmgr = GetInstance()->dbmgr; + if(dbmgr.HasDB("emote")) + { + SCPDatabase& db = dbmgr.GetDB("emote"); + std::string target,target2; + bool targeted=false; // if the emote is directed to anyone around or a specific target + bool targeted_me=false; // if the emote was targeted to us if it was targeted + bool from_me=false; // if we did the emote + bool female=false; // if emote causer is female + + if(GetMyChar()->GetGUID() == guid) // we caused the emote + from_me=true; + + if(name.length()) // is it directed to someone? + { + targeted=true; // if yes, we have a target + if(GetMyChar()->GetName() == name) // if the name is ours, its directed to us + targeted_me=true; + } + + Unit *u = (Unit*)objmgr.GetObj(guid); + if(u) + { + if(u->GetGender() != 0) // female + female=true; + name_from = u->GetName(); + } + + // if we targeted ourself, the general emote is used! + if(targeted && from_me && targeted_me) + targeted_me=false; + + // now build the string that is used to lookup the text in the database + if(from_me) + target += "me"; + else + target += "one"; + + if(targeted) + { + target += "to"; + if(targeted_me) + target += "me"; + else + target += "one"; + } + else + target += "general"; + + // not all emotes have a female version, so check if there is one in the database + if(female && db.GetField(emotetext).HasEntry(target + "female")) + target += "female"; + + logdebug("Looking up 'emote' SCP field %u entry '%s'",emotetext,target.c_str()); + + std::string etext; + etext = db.GetField(emotetext).GetString(target); + + char out[300]; // should be enough + + if(from_me) + sprintf(out,etext.c_str(),name.c_str()); + else + sprintf(out,etext.c_str(),name_from.c_str(),name.c_str()); + + logcustom(0,WHITE,"EMOTE: %s",out); + + } + else + { + logerror("Can't display emote text %u, SCP database \"emote\" not loaded.",emotetext); + } + +} + +void WorldSession::_HandleLoginVerifyWorldOpcode(WorldPacket& recvPacket) +{ + float x,y,z,o; + uint32 m; + recvPacket >> m >> x >> y >> z >> o; + logdebug("LoginVerifyWorld: map=%u x=%f y=%f z=%f o=%f",m,x,y,z,o); + _OnEnterWorld(); + // update the world as soon as the server confirmed that we are where we are. + _world->UpdatePos(x,y,m); + _world->Update(); + + // temp. solution to test terrain rendering + if(PseuGUI *gui = GetInstance()->GetGUI()) + { + gui->SetSceneState(SCENESTATE_WORLD); + gui->SetWorldPosition(WorldPosition(x,y,z,o)); + } +} + +ByteBuffer& operator>>(ByteBuffer& bb, WhoListEntry& e) +{ + bb >> e.name >> e.gname >> e.level >> e.classId >> e.raceId >> e.zoneId; + return bb; +} + +void WorldSession::_HandleWhoOpcode(WorldPacket& recvPacket) +{ + uint32 count, unk; + recvPacket >> count >> unk; + + log("Got WHO-List, %u players. (unk=%u)",count,unk); + + if(count >= 1) + { + log(" Name |Level| Class | Race | Zone; Guild"); + log("--------------+-----+------------+--------------+----------------"); + if(count > 1) + { + _whoList.clear(); // need to clear current list only if requesting more then one player name + } + } + + for(uint32 i = 0; i < count; i++) + { + WhoListEntry wle; + recvPacket >> wle; + + _whoList.push_back(wle); + + // original WhoListEntry is saved, now do some formatting + while(wle.name.length() < 13) + wle.name.append(" "); + + SCPDatabaseMgr& db = GetInstance()->dbmgr; + char classname[20], racename[20]; + std::string zonename; + memset(classname,0,sizeof(classname)); + memset(racename,0,sizeof(racename)); + zonename = db.GetZoneName(wle.zoneId); + strcpy(classname, db.GetClassName_(wle.classId).c_str()); + strcpy(racename, db.GetRaceName(wle.raceId).c_str()); + + for(uint8 i = strlen(classname); strlen(classname) < 10; i++) + classname[i] = ' '; + for(uint8 i = strlen(racename); strlen(racename) < 12; i++) + racename[i] = ' '; + char tmp[12]; + sprintf(tmp,"%u",wle.level); + std::string lvl_str = tmp; + while(lvl_str.length() < 3) + lvl_str = " " + lvl_str; + + log("%s | %s | %s | %s | %s; %s", wle.name.c_str(), lvl_str.c_str(), classname, racename, zonename.c_str(), wle.gname.c_str()); + } +} + +void WorldSession::_HandleCreatureQueryResponseOpcode(WorldPacket& recvPacket) +{ + uint32 entry; + recvPacket >> entry; + if( (!entry) || (entry & 0x80000000) ) // last bit marks that entry is invalid / does not exist on server side + { + uint32 real_entry = entry & ~0x80000000; + logerror("Creature %u does not exist!", real_entry); + objmgr.AddNonexistentCreature(real_entry); + return; + } + + CreatureTemplate *ct = new CreatureTemplate(); + std::string s; + uint32 unk; + float unkf; + ct->entry = entry; + recvPacket >> ct->name; + recvPacket >> s; + recvPacket >> s; + recvPacket >> s; + recvPacket >> ct->subname; + recvPacket >> ct->directions; + recvPacket >> ct->flag1; + recvPacket >> ct->type; + recvPacket >> ct->family; + recvPacket >> ct->rank; + recvPacket >> unk; + recvPacket >> ct->SpellDataId; + recvPacket >> ct->displayid_A; + recvPacket >> ct->displayid_H; + recvPacket >> ct->displayid_AF; + recvPacket >> ct->displayid_HF; + recvPacket >> unkf; + recvPacket >> unkf; + recvPacket >> ct->RacialLeader; + + std::stringstream ss; + ss << "Got info for creature " << entry << ":" << ct->name; + if(!ct->subname.empty()) + ss << " <" << ct->subname << ">"; + ss << " type " << ct->type; + ss << " flags " << ct->flag1; + ss << " models " << ct->displayid_A << "/" << ct->displayid_H; + logdetail("%s",ss.str().c_str()); + + objmgr.Add(ct); + objmgr.AssignNameToObj(entry, TYPEID_UNIT, ct->name); +} + + + +// TODO: delete world on LogoutComplete once implemented + + + + diff --git a/src/Client/World/WorldSession.h b/src/Client/World/WorldSession.h index bd7f902..fea4680 100644 --- a/src/Client/World/WorldSession.h +++ b/src/Client/World/WorldSession.h @@ -1,162 +1,162 @@ -#ifndef _WORLDSESSION_H -#define _WORLDSESSION_H - -#include -#include - -#include "common.h" -#include "PseuWoW.h" -#include "Network/SocketHandler.h" -#include "Player.h" -#include "Auth/AuthCrypt.h" -#include "SharedDefines.h" -#include "ObjMgr.h" -#include "CacheHandler.h" -#include "Opcodes.h" - -class WorldSocket; -class WorldPacket; -class Channel; -class RealmSession; -struct OpcodeHandler; -class World; - -struct WhoListEntry -{ - std::string name; - std::string gname; - uint32 level; - uint32 classId; - uint32 raceId; - uint32 zoneId; -}; - -struct DelayedWorldPacket -{ - DelayedWorldPacket() { pkt = NULL; when = clock(); } - DelayedWorldPacket(WorldPacket *p, uint32 ms) { pkt = p; when = ms + clock(); } - WorldPacket *pkt; - clock_t when; -}; - -typedef std::vector WhoList; -typedef std::deque DelayedPacketQueue; - -class WorldSession -{ - friend class Channel; - -public: - WorldSession(PseuInstance *i); - ~WorldSession(); - void Init(void); - - inline PseuInstance *GetInstance(void) { return _instance; } - inline SCPDatabaseMgr& GetDBMgr(void) { return GetInstance()->dbmgr; } - - void AddToPktQueue(WorldPacket *pkt); - void Update(void); - void Start(void); - inline bool MustDie(void) { return _mustdie; } - void SetMustDie(void); - void SendWorldPacket(WorldPacket&); - inline bool InWorld(void) { return _logged; } - inline uint32 GetLagMS(void) { return _lag_ms; } - - void SetTarget(uint64 guid); - inline uint64 GetTarget(void) { return GetMyChar() ? GetMyChar()->GetTarget() : 0; } - inline uint64 GetGuid(void) { return _myGUID; } - inline Channel *GetChannels(void) { return _channels; } - inline MyCharacter *GetMyChar(void) { ASSERT(_myGUID > 0); return (MyCharacter*)objmgr.GetObj(_myGUID); } - inline World *GetWorld(void) { return _world; } - - std::string GetOrRequestPlayerName(uint64); - - - // CMSGConstructor - void SendChatMessage(uint32 type, uint32 lang, std::string msg, std::string to=""); - void SendQueryPlayerName(uint64 guid); - void SendPing(uint32); - void SendEmote(uint32); - void SendQueryItem(uint32 id, uint64 guid = 0); - void SendSetSelection(uint64); - void SendCastSpell(uint32 spellid, bool nocheck=false); - void SendWhoListRequest(uint32 minlvl=0, uint32 maxlvl=100, uint32 racemask=-1, uint32 classmask=-1, std::string name="", std::string guildname="", std::vector *zonelist=NULL, std::vector *strlist=NULL); - void SendQueryCreature(uint32 entry, uint64 guid = 0); - - void HandleWorldPacket(WorldPacket*); - - inline void DisableOpcode(uint16 opcode) { _disabledOpcodes[opcode] = true; } - inline void EnableOpcode(uint16 opcode) { _disabledOpcodes[opcode] = false; } - inline bool IsOpcodeDisabled(uint16 opcode) { return _disabledOpcodes[opcode]; } - - PlayerNameCache plrNameCache; - ObjMgr objmgr; - - -private: - - OpcodeHandler *_GetOpcodeHandlerTable(void) const; - - // Helpers - void _OnEnterWorld(void); // = login - void _OnLeaveWorld(void); // = logout - void _DoTimedActions(void); - void _DelayWorldPacket(WorldPacket&, uint32); - void _HandleDelayedPackets(void); - - // Opcode Handlers - void _HandleAuthChallengeOpcode(WorldPacket& recvPacket); - void _HandleAuthResponseOpcode(WorldPacket& recvPacket); - void _HandleCharEnumOpcode(WorldPacket& recvPacket); - void _HandleSetProficiencyOpcode(WorldPacket& recvPacket); - void _HandleAccountDataMD5Opcode(WorldPacket& recvPacket); - void _HandleMessageChatOpcode(WorldPacket& recvPacket); - void _HandleNameQueryResponseOpcode(WorldPacket& recvPacket); - void _HandleMovementOpcode(WorldPacket& recvPacket); - void _HandlePongOpcode(WorldPacket& recvPacket); - void _HandleTradeStatusOpcode(WorldPacket& recvPacket); - void _HandleGroupInviteOpcode(WorldPacket& recvPacket); - void _HandleTelePortAckOpcode(WorldPacket& recvPacket); - void _HandleChannelNotifyOpcode(WorldPacket& recvPacket); - void _HandleCastResultOpcode(WorldPacket& recvPacket); - void _HandleCastSuccessOpcode(WorldPacket& recvPacket); - void _HandleCompressedUpdateObjectOpcode(WorldPacket& recvPacket); - void _HandleUpdateObjectOpcode(WorldPacket& recvPacket); - void _HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket); - void _HandleDestroyObjectOpcode(WorldPacket& recvPacket); - void _HandleInitialSpellsOpcode(WorldPacket& recvPacket); - void _HandleLearnedSpellOpcode(WorldPacket& recvPacket); - void _HandleRemovedSpellOpcode(WorldPacket& recvPacket); - void _HandleChannelListOpcode(WorldPacket& recvPacket); - void _HandleEmoteOpcode(WorldPacket& recvPacket); - void _HandleTextEmoteOpcode(WorldPacket& recvPacket); - void _HandleNewWorldOpcode(WorldPacket& recvPacket); - void _HandleLoginVerifyWorldOpcode(WorldPacket& recvPacket); - void _HandleMotdOpcode(WorldPacket& recvPacket); - void _HandleNotificationOpcode(WorldPacket& recvPacket); - void _HandleWhoOpcode(WorldPacket& recvPacket); - void _HandleCreatureQueryResponseOpcode(WorldPacket& recvPacket); - - // helper functions to keep SMSG_(COMPRESSED_)UPDATE_OBJECT easy to handle - void _MovementUpdate(uint8 objtypeid, uint64 guid, WorldPacket& recvPacket); // Helper for _HandleUpdateObjectOpcode - void _ValuesUpdate(uint64 uguid, WorldPacket& recvPacket); // ... - void _QueryObjectInfo(uint64 guid); - - void _LoadCache(void); - - PseuInstance *_instance; - WorldSocket *_socket; - ZThread::LockedQueue pktQueue; - DelayedPacketQueue delayedPktQueue; - bool _logged,_mustdie; // world status - SocketHandler _sh; // handles the WorldSocket - Channel *_channels; - uint64 _myGUID; - World *_world; - WhoList _whoList; - uint32 _lag_ms; - std::bitset _disabledOpcodes; -}; - -#endif +#ifndef _WORLDSESSION_H +#define _WORLDSESSION_H + +#include +#include + +#include "common.h" +#include "PseuWoW.h" +#include "Network/SocketHandler.h" +#include "Player.h" +#include "Auth/AuthCrypt.h" +#include "SharedDefines.h" +#include "ObjMgr.h" +#include "CacheHandler.h" +#include "Opcodes.h" + +class WorldSocket; +class WorldPacket; +class Channel; +class RealmSession; +struct OpcodeHandler; +class World; + +struct WhoListEntry +{ + std::string name; + std::string gname; + uint32 level; + uint32 classId; + uint32 raceId; + uint32 zoneId; +}; + +struct DelayedWorldPacket +{ + DelayedWorldPacket() { pkt = NULL; when = clock(); } + DelayedWorldPacket(WorldPacket *p, uint32 ms) { pkt = p; when = ms + clock(); } + WorldPacket *pkt; + clock_t when; +}; + +typedef std::vector WhoList; +typedef std::deque DelayedPacketQueue; + +class WorldSession +{ + friend class Channel; + +public: + WorldSession(PseuInstance *i); + ~WorldSession(); + void Init(void); + + inline PseuInstance *GetInstance(void) { return _instance; } + inline SCPDatabaseMgr& GetDBMgr(void) { return GetInstance()->dbmgr; } + + void AddToPktQueue(WorldPacket *pkt); + void Update(void); + void Start(void); + inline bool MustDie(void) { return _mustdie; } + void SetMustDie(void); + void SendWorldPacket(WorldPacket&); + inline bool InWorld(void) { return _logged; } + inline uint32 GetLagMS(void) { return _lag_ms; } + + void SetTarget(uint64 guid); + inline uint64 GetTarget(void) { return GetMyChar() ? GetMyChar()->GetTarget() : 0; } + inline uint64 GetGuid(void) { return _myGUID; } + inline Channel *GetChannels(void) { return _channels; } + inline MyCharacter *GetMyChar(void) { ASSERT(_myGUID > 0); return (MyCharacter*)objmgr.GetObj(_myGUID); } + inline World *GetWorld(void) { return _world; } + + std::string GetOrRequestPlayerName(uint64); + + + // CMSGConstructor + void SendChatMessage(uint32 type, uint32 lang, std::string msg, std::string to=""); + void SendQueryPlayerName(uint64 guid); + void SendPing(uint32); + void SendEmote(uint32); + void SendQueryItem(uint32 id, uint64 guid = 0); + void SendSetSelection(uint64); + void SendCastSpell(uint32 spellid, bool nocheck=false); + void SendWhoListRequest(uint32 minlvl=0, uint32 maxlvl=100, uint32 racemask=-1, uint32 classmask=-1, std::string name="", std::string guildname="", std::vector *zonelist=NULL, std::vector *strlist=NULL); + void SendQueryCreature(uint32 entry, uint64 guid = 0); + + void HandleWorldPacket(WorldPacket*); + + inline void DisableOpcode(uint16 opcode) { _disabledOpcodes[opcode] = true; } + inline void EnableOpcode(uint16 opcode) { _disabledOpcodes[opcode] = false; } + inline bool IsOpcodeDisabled(uint16 opcode) { return _disabledOpcodes[opcode]; } + + PlayerNameCache plrNameCache; + ObjMgr objmgr; + + +private: + + OpcodeHandler *_GetOpcodeHandlerTable(void) const; + + // Helpers + void _OnEnterWorld(void); // = login + void _OnLeaveWorld(void); // = logout + void _DoTimedActions(void); + void _DelayWorldPacket(WorldPacket&, uint32); + void _HandleDelayedPackets(void); + + // Opcode Handlers + void _HandleAuthChallengeOpcode(WorldPacket& recvPacket); + void _HandleAuthResponseOpcode(WorldPacket& recvPacket); + void _HandleCharEnumOpcode(WorldPacket& recvPacket); + void _HandleSetProficiencyOpcode(WorldPacket& recvPacket); + void _HandleAccountDataMD5Opcode(WorldPacket& recvPacket); + void _HandleMessageChatOpcode(WorldPacket& recvPacket); + void _HandleNameQueryResponseOpcode(WorldPacket& recvPacket); + void _HandleMovementOpcode(WorldPacket& recvPacket); + void _HandlePongOpcode(WorldPacket& recvPacket); + void _HandleTradeStatusOpcode(WorldPacket& recvPacket); + void _HandleGroupInviteOpcode(WorldPacket& recvPacket); + void _HandleTelePortAckOpcode(WorldPacket& recvPacket); + void _HandleChannelNotifyOpcode(WorldPacket& recvPacket); + void _HandleCastResultOpcode(WorldPacket& recvPacket); + void _HandleCastSuccessOpcode(WorldPacket& recvPacket); + void _HandleCompressedUpdateObjectOpcode(WorldPacket& recvPacket); + void _HandleUpdateObjectOpcode(WorldPacket& recvPacket); + void _HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket); + void _HandleDestroyObjectOpcode(WorldPacket& recvPacket); + void _HandleInitialSpellsOpcode(WorldPacket& recvPacket); + void _HandleLearnedSpellOpcode(WorldPacket& recvPacket); + void _HandleRemovedSpellOpcode(WorldPacket& recvPacket); + void _HandleChannelListOpcode(WorldPacket& recvPacket); + void _HandleEmoteOpcode(WorldPacket& recvPacket); + void _HandleTextEmoteOpcode(WorldPacket& recvPacket); + void _HandleNewWorldOpcode(WorldPacket& recvPacket); + void _HandleLoginVerifyWorldOpcode(WorldPacket& recvPacket); + void _HandleMotdOpcode(WorldPacket& recvPacket); + void _HandleNotificationOpcode(WorldPacket& recvPacket); + void _HandleWhoOpcode(WorldPacket& recvPacket); + void _HandleCreatureQueryResponseOpcode(WorldPacket& recvPacket); + + // helper functions to keep SMSG_(COMPRESSED_)UPDATE_OBJECT easy to handle + void _MovementUpdate(uint8 objtypeid, uint64 guid, WorldPacket& recvPacket); // Helper for _HandleUpdateObjectOpcode + void _ValuesUpdate(uint64 uguid, WorldPacket& recvPacket); // ... + void _QueryObjectInfo(uint64 guid); + + void _LoadCache(void); + + PseuInstance *_instance; + WorldSocket *_socket; + ZThread::LockedQueue pktQueue; + DelayedPacketQueue delayedPktQueue; + bool _logged,_mustdie; // world status + SocketHandler _sh; // handles the WorldSocket + Channel *_channels; + uint64 _myGUID; + World *_world; + WhoList _whoList; + uint32 _lag_ms; + std::bitset _disabledOpcodes; +}; + +#endif diff --git a/src/Client/World/WorldSocket.cpp b/src/Client/World/WorldSocket.cpp index 05b2691..fbb8349 100644 --- a/src/Client/World/WorldSocket.cpp +++ b/src/Client/World/WorldSocket.cpp @@ -1,130 +1,130 @@ - -#include "WorldPacket.h" -#include "WorldSession.h" -#include "WorldSocket.h" -#include "Opcodes.h" - -WorldSocket::WorldSocket(SocketHandler &h, WorldSession *s) : TcpSocket(h) -{ - _session = s; - _gothdr = false; - _ok=false; -} - -bool WorldSocket::IsOk(void) -{ - return _ok; -} - -void WorldSocket::OnConnect() -{ - log("Connected to world server."); - _ok = true; -} - -void WorldSocket::OnConnectFailed() -{ - logerror("Connecting to World Server failed!"); - _ok = false; -} - -void WorldSocket::OnDelete() -{ - log("Connection to world server has been closed."); - _ok = false; - _session->SetMustDie(); // recreate the session if needed -} - -void WorldSocket::OnException() -{ - if(_ok) - { - logerror("WorldSocket::OnException()"); - _ok = false; - } -} - -void WorldSocket::OnRead() -{ - TcpSocket::OnRead(); - if(!ibuf.GetLength()) - { - this->CloseAndDelete(); - return; - } - while(ibuf.GetLength() > 0) // when all packets from the current ibuf are transformed into WorldPackets the remaining len will be zero - { - - if(_gothdr) // already got header, this packet has to be the data part - { - ASSERT(_remaining > 0); // case pktsize==0 is handled below - if(ibuf.GetLength() < _remaining) - { - DEBUG(logdebug("Delaying WorldPacket generation, bufsize is %u but should be >= %u",ibuf.GetLength(),_remaining)); - break; - } - _gothdr=false; - WorldPacket *wp = new WorldPacket(_remaining); - wp->resize(_remaining); - ibuf.Read((char*)wp->contents(),_remaining); - wp->SetOpcode(_opcode); - GetSession()->AddToPktQueue(wp); - } - else // no pending header stored, so this packet must be a header - { - if(ibuf.GetLength() < sizeof(ServerPktHeader)) - { - DEBUG(logdebug("Delaying header reading, bufsize is %u but should be >= %u",ibuf.GetLength(),sizeof(ServerPktHeader))); - break; - } - ServerPktHeader hdr; - ibuf.Read((char*)&hdr,sizeof(ServerPktHeader)); - _crypt.DecryptRecv((uint8*)&hdr,sizeof(ServerPktHeader)); - _remaining = ntohs(hdr.size)-2; - _opcode = hdr.cmd; - if(_opcode > MAX_OPCODE_ID) // no opcode has yet a number over 1000 - { - logcritical("CRYPT ERROR: opcode=%u, remain=%u",_opcode,_remaining); // this should never be the case! - GetSession()->GetInstance()->SetError(); // no way to recover the crypt, must exit - // if the crypt gets messy its hardly possible to recover it, especially if we dont know - // the lentgh of the following data part - // TODO: invent some way how to recover the crypt (reconnect?) - return; - } - - // the header is fine, now check if there are more data - if(_remaining == 0) // this is a packet with no data (like CMSG_NULL_ACTION) - { - WorldPacket *wp = new WorldPacket; - wp->SetOpcode(_opcode); - GetSession()->AddToPktQueue(wp); - } - else // there is a data part to fetch - { - _gothdr=true; // only got the header, next packet will contain the data - } - } - } -} - -void WorldSocket::SendWorldPacket(WorldPacket &pkt) -{ - if(!_ok) - return; - ClientPktHeader hdr; - memset(&hdr,0,sizeof(ClientPktHeader)); - hdr.size = ntohs(pkt.size()+4); - hdr.cmd = pkt.GetOpcode(); - _crypt.EncryptSend((uint8*)&hdr, 6); - ByteBuffer final(pkt.size()+6); - final.append((uint8*)&hdr,sizeof(ClientPktHeader)); - if(pkt.size()) - final.append(pkt.contents(),pkt.size()); - SendBuf((char*)final.contents(),final.size()); -} - -void WorldSocket::InitCrypt(uint8 *key,uint32 len) -{ - _crypt.SetKey(key,len); - _crypt.Init(); -} + +#include "WorldPacket.h" +#include "WorldSession.h" +#include "WorldSocket.h" +#include "Opcodes.h" + +WorldSocket::WorldSocket(SocketHandler &h, WorldSession *s) : TcpSocket(h) +{ + _session = s; + _gothdr = false; + _ok=false; +} + +bool WorldSocket::IsOk(void) +{ + return _ok; +} + +void WorldSocket::OnConnect() +{ + log("Connected to world server."); + _ok = true; +} + +void WorldSocket::OnConnectFailed() +{ + logerror("Connecting to World Server failed!"); + _ok = false; +} + +void WorldSocket::OnDelete() +{ + log("Connection to world server has been closed."); + _ok = false; + _session->SetMustDie(); // recreate the session if needed +} + +void WorldSocket::OnException() +{ + if(_ok) + { + logerror("WorldSocket::OnException()"); + _ok = false; + } +} + +void WorldSocket::OnRead() +{ + TcpSocket::OnRead(); + if(!ibuf.GetLength()) + { + this->CloseAndDelete(); + return; + } + while(ibuf.GetLength() > 0) // when all packets from the current ibuf are transformed into WorldPackets the remaining len will be zero + { + + if(_gothdr) // already got header, this packet has to be the data part + { + ASSERT(_remaining > 0); // case pktsize==0 is handled below + if(ibuf.GetLength() < _remaining) + { + DEBUG(logdebug("Delaying WorldPacket generation, bufsize is %u but should be >= %u",ibuf.GetLength(),_remaining)); + break; + } + _gothdr=false; + WorldPacket *wp = new WorldPacket(_remaining); + wp->resize(_remaining); + ibuf.Read((char*)wp->contents(),_remaining); + wp->SetOpcode(_opcode); + GetSession()->AddToPktQueue(wp); + } + else // no pending header stored, so this packet must be a header + { + if(ibuf.GetLength() < sizeof(ServerPktHeader)) + { + DEBUG(logdebug("Delaying header reading, bufsize is %u but should be >= %u",ibuf.GetLength(),sizeof(ServerPktHeader))); + break; + } + ServerPktHeader hdr; + ibuf.Read((char*)&hdr,sizeof(ServerPktHeader)); + _crypt.DecryptRecv((uint8*)&hdr,sizeof(ServerPktHeader)); + _remaining = ntohs(hdr.size)-2; + _opcode = hdr.cmd; + if(_opcode > MAX_OPCODE_ID) // no opcode has yet a number over 1000 + { + logcritical("CRYPT ERROR: opcode=%u, remain=%u",_opcode,_remaining); // this should never be the case! + GetSession()->GetInstance()->SetError(); // no way to recover the crypt, must exit + // if the crypt gets messy its hardly possible to recover it, especially if we dont know + // the lentgh of the following data part + // TODO: invent some way how to recover the crypt (reconnect?) + return; + } + + // the header is fine, now check if there are more data + if(_remaining == 0) // this is a packet with no data (like CMSG_NULL_ACTION) + { + WorldPacket *wp = new WorldPacket; + wp->SetOpcode(_opcode); + GetSession()->AddToPktQueue(wp); + } + else // there is a data part to fetch + { + _gothdr=true; // only got the header, next packet will contain the data + } + } + } +} + +void WorldSocket::SendWorldPacket(WorldPacket &pkt) +{ + if(!_ok) + return; + ClientPktHeader hdr; + memset(&hdr,0,sizeof(ClientPktHeader)); + hdr.size = ntohs(pkt.size()+4); + hdr.cmd = pkt.GetOpcode(); + _crypt.EncryptSend((uint8*)&hdr, 6); + ByteBuffer final(pkt.size()+6); + final.append((uint8*)&hdr,sizeof(ClientPktHeader)); + if(pkt.size()) + final.append(pkt.contents(),pkt.size()); + SendBuf((char*)final.contents(),final.size()); +} + +void WorldSocket::InitCrypt(uint8 *key,uint32 len) +{ + _crypt.SetKey(key,len); + _crypt.Init(); +} diff --git a/src/Client/doc/Ludmilla_1.8.0_LogonCodes.h.txt b/src/Client/doc/Ludmilla_1.8.0_LogonCodes.h.txt index 80dd28c..78111c0 100644 --- a/src/Client/doc/Ludmilla_1.8.0_LogonCodes.h.txt +++ b/src/Client/doc/Ludmilla_1.8.0_LogonCodes.h.txt @@ -1,61 +1,61 @@ -//****************************************************************************** -// Here are all codes used in Logon Server. -//============================================================================== -#ifndef _LOGONCODES_H -#define _LOGONCODES_H -//============================================================================== -//#include "OurDefs.h" -//============================================================================== -// wow's codes: -enum EClientCommand -// dumped from wow.exe 1.8.0 -// 0x007F86A8: table of -// -// switch: 005999A7 cmp byte ptr [ecx],dl -{ - CMD_AUTH_LOGON_CHALLENGE = 0x00, // client - CMD_AUTH_LOGON_PROOF = 0x01, // client - CMD_AUTH_RECONNECT_CHALLENGE = 0x02, // client - CMD_AUTH_RECONNECT_PROOF = 0x03, // client - CMD_REALM_LIST = 0x10, // client - CMD_XFER_INITIATE = 0x30, // client? from server - CMD_XFER_DATA = 0x31, // client? from server - CMD_XFER_ACCEPT = 0x32, // not official name, from client - CMD_XFER_RESUME = 0x33, // not official name, from client - CMD_XFER_CANCEL = 0x34, // not official name, from client - - // unknown: - CMD_GRUNT_AUTH_CHALLENGE = 0x00, // server - CMD_GRUNT_AUTH_VERIFY = 0x02, // server - CMD_GRUNT_CONN_PING = 0x10, // server - CMD_GRUNT_CONN_PONG = 0x11, // server - CMD_GRUNT_HELLO = 0x20, // server - CMD_GRUNT_PROVESESSION = 0x21, // server - CMD_GRUNT_KICK = 0x24, // server -}; -//------------------------------------------------------------------------------ -enum ELoginErrorCode - // dumped from wow.exe 1.8.0 - // 00591E9D mov eax,dword ptr [ebp+8] - // eax - code, name in stack after exiting from current funk -{ - // LOGIN_STATE_FAILED: - - LOGIN_FAILED = 1, // 2, B, C, D // "Unable to connect" - LOGIN_BANNED = 3, // "This World of Warcraft account has been closed and is no longer in service -- Please check the registered email address of this account for further information."; -- This is the error message players get when trying to log in with a banned account. - LOGIN_UNKNOWN_ACCOUNT = 4, // 5 // "The information you have entered is not valid. Please check the spelling of the account name and password. If you need help in retrieving a lost or stolen password and account, see www.worldofwarcraft.com for more information."; - LOGIN_ALREADYONLINE = 6, // "This account is already logged into World of Warcraft. Please check the spelling and try again."; - LOGIN_NOTIME = 7, // "You have used up your prepaid time for this account. Please purchase more to continue playing"; - LOGIN_DBBUSY = 8, // "Could not log in to World of Warcraft at this time. Please try again later."; - LOGIN_BADVERSION = 9, // "Unable to validate game version. This may be caused by file corruption or the interference of another program. Please visit www.blizzard.com/support/wow/ for more information and possible solutions to this issue."; - LOGIN_PARENTALCONTROL = 0xF, // "17"="LOGIN_PARENTALCONTROL" // "Access to this account has been blocked by parental controls. Your settings may be changed in your account preferences at http://www.worldofwarcraft.com."; - - // LOGIN_STATE_AUTHENTICATED: - LOGIN_OK = 0, // E - - // LOGIN_STATE_DOWNLOADFILE, LOGIN_OK - LOGIN_DOWNLOADFILE = 0xA, // not official name -}; -//============================================================================== -#endif // _LOGONCODES_H -//****************************************************************************** +//****************************************************************************** +// Here are all codes used in Logon Server. +//============================================================================== +#ifndef _LOGONCODES_H +#define _LOGONCODES_H +//============================================================================== +//#include "OurDefs.h" +//============================================================================== +// wow's codes: +enum EClientCommand +// dumped from wow.exe 1.8.0 +// 0x007F86A8: table of +// +// switch: 005999A7 cmp byte ptr [ecx],dl +{ + CMD_AUTH_LOGON_CHALLENGE = 0x00, // client + CMD_AUTH_LOGON_PROOF = 0x01, // client + CMD_AUTH_RECONNECT_CHALLENGE = 0x02, // client + CMD_AUTH_RECONNECT_PROOF = 0x03, // client + CMD_REALM_LIST = 0x10, // client + CMD_XFER_INITIATE = 0x30, // client? from server + CMD_XFER_DATA = 0x31, // client? from server + CMD_XFER_ACCEPT = 0x32, // not official name, from client + CMD_XFER_RESUME = 0x33, // not official name, from client + CMD_XFER_CANCEL = 0x34, // not official name, from client + + // unknown: + CMD_GRUNT_AUTH_CHALLENGE = 0x00, // server + CMD_GRUNT_AUTH_VERIFY = 0x02, // server + CMD_GRUNT_CONN_PING = 0x10, // server + CMD_GRUNT_CONN_PONG = 0x11, // server + CMD_GRUNT_HELLO = 0x20, // server + CMD_GRUNT_PROVESESSION = 0x21, // server + CMD_GRUNT_KICK = 0x24, // server +}; +//------------------------------------------------------------------------------ +enum ELoginErrorCode + // dumped from wow.exe 1.8.0 + // 00591E9D mov eax,dword ptr [ebp+8] + // eax - code, name in stack after exiting from current funk +{ + // LOGIN_STATE_FAILED: + + LOGIN_FAILED = 1, // 2, B, C, D // "Unable to connect" + LOGIN_BANNED = 3, // "This World of Warcraft account has been closed and is no longer in service -- Please check the registered email address of this account for further information."; -- This is the error message players get when trying to log in with a banned account. + LOGIN_UNKNOWN_ACCOUNT = 4, // 5 // "The information you have entered is not valid. Please check the spelling of the account name and password. If you need help in retrieving a lost or stolen password and account, see www.worldofwarcraft.com for more information."; + LOGIN_ALREADYONLINE = 6, // "This account is already logged into World of Warcraft. Please check the spelling and try again."; + LOGIN_NOTIME = 7, // "You have used up your prepaid time for this account. Please purchase more to continue playing"; + LOGIN_DBBUSY = 8, // "Could not log in to World of Warcraft at this time. Please try again later."; + LOGIN_BADVERSION = 9, // "Unable to validate game version. This may be caused by file corruption or the interference of another program. Please visit www.blizzard.com/support/wow/ for more information and possible solutions to this issue."; + LOGIN_PARENTALCONTROL = 0xF, // "17"="LOGIN_PARENTALCONTROL" // "Access to this account has been blocked by parental controls. Your settings may be changed in your account preferences at http://www.worldofwarcraft.com."; + + // LOGIN_STATE_AUTHENTICATED: + LOGIN_OK = 0, // E + + // LOGIN_STATE_DOWNLOADFILE, LOGIN_OK + LOGIN_DOWNLOADFILE = 0xA, // not official name +}; +//============================================================================== +#endif // _LOGONCODES_H +//****************************************************************************** diff --git a/src/Client/doc/Ludmilla_1.8.0_LogonPackets.h.txt b/src/Client/doc/Ludmilla_1.8.0_LogonPackets.h.txt index 15033e1..dd93511 100644 --- a/src/Client/doc/Ludmilla_1.8.0_LogonPackets.h.txt +++ b/src/Client/doc/Ludmilla_1.8.0_LogonPackets.h.txt @@ -1,193 +1,193 @@ -//****************************************************************************** -// Here are all packets to and from Logon Server. -//============================================================================== -#ifndef _LOGONPACKETS_H -#define _LOGONPACKETS_H -//============================================================================== -#include "../Shared/OurDefs.h" -#include -//============================================================================== -#pragma pack(push, 1) -//============================================================================== -// Challenge: -struct SClientLogonChallenge -{ - uint8 cmd; // OP code = CMD_AUTH_LOGON_CHALLENGE - uint8 error0x02; // 0x02 - uint16 size; // size of the rest of packet, without this part - uint8 gamename[4]; // "WoW" - uint8 version[2]; // 0x01 08 00 -> (1.8.0) - uint16 build; // 0x7F12 -> 4735 - uint8 platform[3]; // 68x\0 -> "x86" - uint8 os[3]; // niW\0 -> "Win" - uint8 localization[4];// BGne -> 'enGB' - uint32 timezone_bias; // 0x78 00 00 00 - uint8 ip[4]; // client ip: 0x7F 00 00 01 - uint8 acclen; // length of account name (without zero-char) - uint8 *acc; // upcased account name (without zero-char) -}; -struct SClientLogonChallenge_Header // just for usability -{ - uint8 cmd; // OP code = CMD_AUTH_LOGON_CHALLENGE - uint8 error; // 0x02 - uint16 size; // size of the rest of packet, without this part -}; -struct SClientReconnectChallenge // == SClientChallenge -{ - uint8 cmd; // OP code = 02 = CMD_AUTH_RECONNECT_CHALLENGE - uint8 error; // 0x02 - uint16 size; // size of the rest of packet, without this part - uint8 gamename[4]; // "WoW" - uint8 version[2]; // 0x01 08 00 -> (1.8.0) - uint16 build; // 0x7F12 -> 4735 - uint8 platform[4]; // 68x\0 -> "x86" - uint8 os[4]; // niW\0 -> "Win" - uint8 country[4]; // BGne -> 'enGB' - uint32 timezone_bias; // 0x78 00 00 00 - uint8 ip[4]; // client ip: 0x7F 00 00 01 - uint8 acclen; // length of account name (without zero-char) - uint8 *acc; // upcased account name (without zero-char) -}; -struct SServerLogonChallenge_Err -{ - uint8 cmd; // 0x00 -> OPcode = CMD_AUTH_LOGON_CHALLENGE ? CMD_GRUNT_AUTH_CHALLENGE - uint8 error; // one of SServerChallenge_ErrorCodes codes -}; -struct SServerLogonChallenge_Ok - // Variables: - // X := SHA1( salt || SHA1(upper(acc:pass)) ) - // b[20] := random server's secret - // K := 3 - // salt[32] := random - // N := 89 4B 64 5E - 89 E1 53 5B - BD AD 5B 8B - 29 06 50 53 - // 08 01 B1 8E - BF BF 5E 8F - AB 3C 82 87 - 2A 3E 9B B7 - // g[1] := 7 - // - // Calculations: - // Verifier := g^(~x) mod ~N - // B := ~( K*V + g^(~b) mod ~N ) -{ - uint8 cmd; // 0x00 -> OPcode = CMD_AUTH_LOGON_CHALLENGE ? CMD_GRUNT_AUTH_CHALLENGE - uint8 error; // 0 -> ok = LOGIN_OK - uint8 unk1; // 0x00 - - uint8 B[32]; // calculated by server - - uint8 g_len; // 0x01 - uint8 g[1]; // 0x07 (const) - - uint8 N_len; // 0x20 - uint8 N[32]; // const - - uint8 salt[32]; // random - uint8 unk2[16]; //1: BA 79 D4 8D - BF FC BF AD - 8C B4 EC B3 - 75 C5 96 05 - //2: 0F EB C2 82 - 28 C2 BC E4 - A6 31 30 C7 - 9F 6D 72 76 -}; -//------------------------------------------------------------------------------ -// Proof: -struct SClientLogonProof -{ - uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_LOGON_PROOF - uint8 A[32]; // calculated by client - uint8 M1[20]; // - uint8 crc_hash[20]; // - uint8 number_of_keys; // 0x00 -}; -struct SClientReconnectProof // == SClientProof -{ - uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_RECONNECT_PROOF - uint8 A[32]; // calculated by client - uint8 M1[20]; // - uint8 crc_hash[20]; // - uint8 number_of_keys; // 0x00 -}; -struct SServerLogonProof_Err - // Variables: - // U := SHA1(A || B) - // - // Calculations: - // S := ~( ( (V^(~U))*(~A) ) ^ (~b) mod ~N ) - // hS0 := SHA1 ( S[0] || S[2] || ... || S[20] ) - // hS1 := SHA1 ( S[1] || S[3] || ... || S[19] ) - // SS := hS0[0] || hS1[0] || hS0[1] || ... || hS1[10] - // M1 := SHA1( (SHA1(N) xor SHA1(G)) || SHA1(upper(acc)) || salt || A || B || SS ) -{ - uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_LOGON_PROOF - uint8 error; // 0x04 -> password is incorrect = LOGIN_UNKNOWN_ACCOUNT -}; -struct SServerLogonProof_Ok - // M2 := SHA1(A || M1 || SS) -{ - uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_LOGON_PROOF - uint8 error; // 0x00 -> ok - uint8 M2[20]; // calculated by server - uint32 unk; // 0x00 00 00 00 -}; -//------------------------------------------------------------------------------ -// Realm: -struct SClientRealmList -{ - uint8 cmd; // OP code = CMD_REALM_LIST - uint32 unknown; // 0x00 00 00 00 -}; -struct SServerRealmList // for info only - variable size -{ - uint8 cmd; // OP code = CMD_REALM_LIST - uint16 size; // size of the rest of packet, without this part - uint32 unknown; // 0x00 00 00 00 - uint8 count; // quantity of realms - struct SRealmInfo - { - uint32 icon; // icon near realm - uint8 color; // color of record - char *name; // Text zero terminated name of Realm - char *addr_port; // Text zero terminated address of Realm ("ip:port") - float population; // 1.6 -> population value. lower == lower population and vice versa - uint8 chars_here; // number of characters on this server - uint8 timezone; // timezone - uint8 unknown; // - } * realms; - uint8 unknown1; // 0x2A unknown - uint8 unknown2; // 0x00 unknown -}; -struct SServerRealmList_Header -{ - uint8 cmd; // OP code = CMD_REALM_LIST - uint16 size; // size of the rest of packet, without this part -}; -//------------------------------------------------------------------------------ -// Xref: -struct SServerXferInitiate -{ - uint8 cmd; // 0x30 -> OPcode = CMD_XFER_INITIATE - uint8 typelen; // 0x05 -> sizeof(Patch) - uint8 typestr[5]; // 'Patch' - uint32 size; // 0x34 C4 0D 00 = 902,196 byte (180->181 enGB) - uint32 unk; // 0x0 always - uint8 md5[MD5_DIGEST_LENGTH]; // md5 checksum of file -}; -struct SServerXferData -{ - uint8 cmd; // 0x31 -> OPcode = CMD_XFER_DATA - uint16 blocksize; // 0xDC 05 -> 1500 (max block) - uint8 buf[1500]; // block -}; -struct SClientXferAccept -{ - uint8 cmd; // 0x32 -> OPcode = CMD_XFER_ACCEPT -}; -struct SClientXferResume -{ - uint8 cmd; // 0x33 -> OPcode = CMD_XFER_RESUME - uint32 start; // will continue at - uint32 unknown; // -}; -struct SClientXferCancel -{ - uint8 cmd; // 0x34 -> OPcode = CMD_XFER_CANCEL -}; -//============================================================================== -#pragma pack(pop) -//============================================================================== -#endif // _LOGONPACKETS_H -//****************************************************************************** +//****************************************************************************** +// Here are all packets to and from Logon Server. +//============================================================================== +#ifndef _LOGONPACKETS_H +#define _LOGONPACKETS_H +//============================================================================== +#include "../Shared/OurDefs.h" +#include +//============================================================================== +#pragma pack(push, 1) +//============================================================================== +// Challenge: +struct SClientLogonChallenge +{ + uint8 cmd; // OP code = CMD_AUTH_LOGON_CHALLENGE + uint8 error0x02; // 0x02 + uint16 size; // size of the rest of packet, without this part + uint8 gamename[4]; // "WoW" + uint8 version[2]; // 0x01 08 00 -> (1.8.0) + uint16 build; // 0x7F12 -> 4735 + uint8 platform[3]; // 68x\0 -> "x86" + uint8 os[3]; // niW\0 -> "Win" + uint8 localization[4];// BGne -> 'enGB' + uint32 timezone_bias; // 0x78 00 00 00 + uint8 ip[4]; // client ip: 0x7F 00 00 01 + uint8 acclen; // length of account name (without zero-char) + uint8 *acc; // upcased account name (without zero-char) +}; +struct SClientLogonChallenge_Header // just for usability +{ + uint8 cmd; // OP code = CMD_AUTH_LOGON_CHALLENGE + uint8 error; // 0x02 + uint16 size; // size of the rest of packet, without this part +}; +struct SClientReconnectChallenge // == SClientChallenge +{ + uint8 cmd; // OP code = 02 = CMD_AUTH_RECONNECT_CHALLENGE + uint8 error; // 0x02 + uint16 size; // size of the rest of packet, without this part + uint8 gamename[4]; // "WoW" + uint8 version[2]; // 0x01 08 00 -> (1.8.0) + uint16 build; // 0x7F12 -> 4735 + uint8 platform[4]; // 68x\0 -> "x86" + uint8 os[4]; // niW\0 -> "Win" + uint8 country[4]; // BGne -> 'enGB' + uint32 timezone_bias; // 0x78 00 00 00 + uint8 ip[4]; // client ip: 0x7F 00 00 01 + uint8 acclen; // length of account name (without zero-char) + uint8 *acc; // upcased account name (without zero-char) +}; +struct SServerLogonChallenge_Err +{ + uint8 cmd; // 0x00 -> OPcode = CMD_AUTH_LOGON_CHALLENGE ? CMD_GRUNT_AUTH_CHALLENGE + uint8 error; // one of SServerChallenge_ErrorCodes codes +}; +struct SServerLogonChallenge_Ok + // Variables: + // X := SHA1( salt || SHA1(upper(acc:pass)) ) + // b[20] := random server's secret + // K := 3 + // salt[32] := random + // N := 89 4B 64 5E - 89 E1 53 5B - BD AD 5B 8B - 29 06 50 53 + // 08 01 B1 8E - BF BF 5E 8F - AB 3C 82 87 - 2A 3E 9B B7 + // g[1] := 7 + // + // Calculations: + // Verifier := g^(~x) mod ~N + // B := ~( K*V + g^(~b) mod ~N ) +{ + uint8 cmd; // 0x00 -> OPcode = CMD_AUTH_LOGON_CHALLENGE ? CMD_GRUNT_AUTH_CHALLENGE + uint8 error; // 0 -> ok = LOGIN_OK + uint8 unk1; // 0x00 + + uint8 B[32]; // calculated by server + + uint8 g_len; // 0x01 + uint8 g[1]; // 0x07 (const) + + uint8 N_len; // 0x20 + uint8 N[32]; // const + + uint8 salt[32]; // random + uint8 unk2[16]; //1: BA 79 D4 8D - BF FC BF AD - 8C B4 EC B3 - 75 C5 96 05 + //2: 0F EB C2 82 - 28 C2 BC E4 - A6 31 30 C7 - 9F 6D 72 76 +}; +//------------------------------------------------------------------------------ +// Proof: +struct SClientLogonProof +{ + uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_LOGON_PROOF + uint8 A[32]; // calculated by client + uint8 M1[20]; // + uint8 crc_hash[20]; // + uint8 number_of_keys; // 0x00 +}; +struct SClientReconnectProof // == SClientProof +{ + uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_RECONNECT_PROOF + uint8 A[32]; // calculated by client + uint8 M1[20]; // + uint8 crc_hash[20]; // + uint8 number_of_keys; // 0x00 +}; +struct SServerLogonProof_Err + // Variables: + // U := SHA1(A || B) + // + // Calculations: + // S := ~( ( (V^(~U))*(~A) ) ^ (~b) mod ~N ) + // hS0 := SHA1 ( S[0] || S[2] || ... || S[20] ) + // hS1 := SHA1 ( S[1] || S[3] || ... || S[19] ) + // SS := hS0[0] || hS1[0] || hS0[1] || ... || hS1[10] + // M1 := SHA1( (SHA1(N) xor SHA1(G)) || SHA1(upper(acc)) || salt || A || B || SS ) +{ + uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_LOGON_PROOF + uint8 error; // 0x04 -> password is incorrect = LOGIN_UNKNOWN_ACCOUNT +}; +struct SServerLogonProof_Ok + // M2 := SHA1(A || M1 || SS) +{ + uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_LOGON_PROOF + uint8 error; // 0x00 -> ok + uint8 M2[20]; // calculated by server + uint32 unk; // 0x00 00 00 00 +}; +//------------------------------------------------------------------------------ +// Realm: +struct SClientRealmList +{ + uint8 cmd; // OP code = CMD_REALM_LIST + uint32 unknown; // 0x00 00 00 00 +}; +struct SServerRealmList // for info only - variable size +{ + uint8 cmd; // OP code = CMD_REALM_LIST + uint16 size; // size of the rest of packet, without this part + uint32 unknown; // 0x00 00 00 00 + uint8 count; // quantity of realms + struct SRealmInfo + { + uint32 icon; // icon near realm + uint8 color; // color of record + char *name; // Text zero terminated name of Realm + char *addr_port; // Text zero terminated address of Realm ("ip:port") + float population; // 1.6 -> population value. lower == lower population and vice versa + uint8 chars_here; // number of characters on this server + uint8 timezone; // timezone + uint8 unknown; // + } * realms; + uint8 unknown1; // 0x2A unknown + uint8 unknown2; // 0x00 unknown +}; +struct SServerRealmList_Header +{ + uint8 cmd; // OP code = CMD_REALM_LIST + uint16 size; // size of the rest of packet, without this part +}; +//------------------------------------------------------------------------------ +// Xref: +struct SServerXferInitiate +{ + uint8 cmd; // 0x30 -> OPcode = CMD_XFER_INITIATE + uint8 typelen; // 0x05 -> sizeof(Patch) + uint8 typestr[5]; // 'Patch' + uint32 size; // 0x34 C4 0D 00 = 902,196 byte (180->181 enGB) + uint32 unk; // 0x0 always + uint8 md5[MD5_DIGEST_LENGTH]; // md5 checksum of file +}; +struct SServerXferData +{ + uint8 cmd; // 0x31 -> OPcode = CMD_XFER_DATA + uint16 blocksize; // 0xDC 05 -> 1500 (max block) + uint8 buf[1500]; // block +}; +struct SClientXferAccept +{ + uint8 cmd; // 0x32 -> OPcode = CMD_XFER_ACCEPT +}; +struct SClientXferResume +{ + uint8 cmd; // 0x33 -> OPcode = CMD_XFER_RESUME + uint32 start; // will continue at + uint32 unknown; // +}; +struct SClientXferCancel +{ + uint8 cmd; // 0x34 -> OPcode = CMD_XFER_CANCEL +}; +//============================================================================== +#pragma pack(pop) +//============================================================================== +#endif // _LOGONPACKETS_H +//****************************************************************************** diff --git a/src/Client/doc/RS Connection.html b/src/Client/doc/RS Connection.html index 8e8beff..2bbac29 100644 --- a/src/Client/doc/RS Connection.html +++ b/src/Client/doc/RS Connection.html @@ -1,257 +1,257 @@ - - -Notes by Biasha:
-Structure (fields, size) and sequence of the packets is valid for 1.8.0
-Algorithm is not checked for 1.8.0 yet
-Original URL: http://www.shockerz.net/wowresource/forum/index.php?showtopic=42
-SRP algorithm: RFC2945
-Information about SRP6: http://srp.stanford.edu/doc.html
-
-
-
- - [quote=Zam,Feb 11 2005, 09:26 PM] -
[Version 1.03] -
-
Ok, this only covers the first handshacking packets. :-) I haven't had time to disect any other packets. -
-
[size=18]If you are having problems; please verify your math with my math; there is a reason I supply the output to every function. This will allow you to see if there is typo's or any problem on either side. -
-
Please note that some libraries may have bugs with Big Numbers; hense the reason I used openssl, as it has been used by crypto products for years. :) -
-
[/size]
-
Changes: -
V1.00 - Initial Release -
V1.01 - Removal of the Second phase and adding where I forgot to up that B (Public) is reveresed before it is stored for use later. -
V1.02 - Added Temp variables results to S calc -
- Fixed the missing UPPERCASE in M1 calculation (Username) -
- Fixed colors. :o -
- Added some more notes. -
V1.03 - Update Warning, and added a couple more intermediate numbers in the M1 Calcs. -
-
-
I have been informed that only the first 4 packets are needed and then the client should ask for the realm list -
-
This is for version 1.1.1. I do not know if anything changed srp wise in 1.2.1; but I will be confirming and diferences between 111 and 121 once I have some spare time. According to several people; srp has NOT changed between 1.1.1 and 1.2.1 -
-
Kudo's to those who have shared there knowledge. Those who have selfishly held onto most or all of their hard work so as not to advance the community; well just disappear -- you are selfish losers and the community would be better off without you... -
------------------------------------------------------------- -
-
Packets as shared by sYkez on this topic (http://www.blizzhackers.com/viewtopic.php?t=21457) -
-
Kudo's to Amso for publically sharing his attempts at decoding srp; he actually was the one to inspire me to do this. -
Notes: -
Reverse means reverse the String. DO NOT USE strrev -- -
Treat this string as an array of numbers. 0 is a valid number; strrev will stop reversing when it incounters an NULL(0) character. My reverse routine is passed the length that it needs to reverse. In fact all of these variables are strored in a simple structure {char *data; int len;} and I pass this structure around. -
uppercase means upper case all letters in string. -
All values are in hex. -
& means concatanate the string valuse. "HI" & "THERE" = "HITHERE" -
Common Q & A: -
Yes, Username and Password are Uppercased. -
Yes, there are reversed string used in certain snippits of code. Don't ask my why; I don't know why Bliz deviated from the standard -- but it works. I assume the reason why is endian-ness of the machines. There server might be a main-frame... -
I am using an UNMODIFIED openssl (latest version) library. -
And I am using the wrapper functions in the t_math.c file that comes from the srp demo page. They just make the names of the functions much more readable. :-) -
-
Each Calculation assumes the byte order is in the initial stored state. So N=894B... -
When I reverse it in a routine N is only reversed for that Routine. When you get to the next routine, N is again equal to 894B... Some routines work with a reversed version of the calculation and some don't. Exception to this rule is B, it is reveresed before it is stored for use in later calculations. -
Lets Go at it: -
-
The Client Connects and sends the Client_Challenge packet. (Pretty self explanitory) -
-
struct { -
uint8 opcode; // 0x00 -
uint8 error; // 0x02 -
uint16 size; // 0x0023 (size of the rest of packet) -
char gameid[4]; //gameid[4]=0; // 'WoW' -
uint8 version1; // 0x00 -
uint8 version2; // 0x12 build version(0.12.0) -
uint8 version3; // 0x00 -
uint16 build; // 3988 -
char platform[4]; // platform[4]=0; // 'x86' -
char os[4]; // os[4]=0; // 'Win' -
char language[4]; // language[4]=0; // 'enUS' -
uint32 timezone_bias; // -419 -
uint32 ip; // client ip -
uint8 acclen; // length of account name -
char *AccountName; -
} Client_Challenge; -
-
The Server Generates the Following Packet: -
-
struct { -
uint8 opcode; // 0x00 -
uint8 error; //no error -
uint8 ukn1; -
char B[32]; -
uint8 g_length; //1 -
char g; -
-
uint8 n_len; // 32; //N_len -
char N[32]; -
char salt[32]; -
char unk3[16]; -
} Server_Challenge; -
-
Ok, N is is hard coded in hex as: -
894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7 -
G Length = 1 -
G = 7 -
K = 3 -
salt = randomly generated 32 characters. -
Server also internally generates a random generated "b" 20 characters -
-
We are going to assume some values to make it easier to duplicate: -
Username = "TEST" -
Password = "TEST" -
salt = 33f140d46cb66e631fdbbbc9f029ad8898e05ee533876118185e56dde843674f -
b = 8692E3A6BA48B5B1004CEF76825127B7EB7D1AEF -
-
Ok, Now for the calculations: -
-
To Generate x: -
Temp = "Username" (Supplied in the client challenge) & ":" & "Password" (Supplied to whatever user registration script). -
TempHash = SHA1(uppercase(Temp)) -
x = sha1(Salt & TempHash) -
-
Your x should equal: 1b70dd2ad03c1ed140223f8f8741c00ec3a4ce73 -
-
To Generate v (Verifier): -
N = Reverse(N) // 32 Characters -
x = Reverse(x) // 20 Characters -
v = g ^ x mod (N) -
// Exact call I Use: BN_mod_exp_mont(v, g, x, N, ctx, NULL); -
Your v Should equal: 996ec7b349d5827043ecd0e6efba3daea5590f944d0184fee1b83ff4f59ecfa8 -
-
-
To Generate B (public B, not private B): -
/* B = kv + g^b mod n */ -
b = Reverse(b) -
N = Reverse(N) -
-
Temp1 = K * v -
Temp2 = g ^ b mod (N) -
Temp3 = Temp1 + Temp2 -
B = Temp3 mod (N) -
B = Reverse(B) // Store this one PERMANATLY Reversed!!! -
-
// code I use is: -
//------------------------------ -
BigIntegerMul(B, k, v, NULL); -
BigIntegerModExp(k, g, b, N, NULL, NULL); -
BigIntegerAdd(k, k, B); -
BigIntegerMod(B, k, N, NULL); -
//------------------------------ -
Your B should equal: 645d1f78973073701e12bc98aa38ea99b4bc435c32e8447c73ab077ae4d75964 -
-
-
Stuff B, g, N, and Salt in the packet and send it. -
-
The client will respond with the following: -
struct { -
uint8 opcode; // 0x01 -
uint8 A[32]; -
uint8 M1[20]; -
uint8 crc_hash[20]; -
uint8 number_of_keys; -
} Client_Proof; -
-
Were going to assume A came over as follows: -
232fb1b88529643d95b8dce78f2750c75b2df37acba873eb31073839eda0738d -
And M1 came over as: -
eeb4adca80f4de02f9a9fe8d000d682e3ddfad6f -
-
A is generated by the client by its secret (a). You will never know what the secret (a) is, so you don't need to worry about how to calc A. (See SRP demo page if you really need to generate an A because you are working on a client program. -
-
M1 however is quite important, this will be used to detect if the user is authenticly loging on. -
-
crc_hash, appears to be unimportant in 1.1.1 (Anybody have any info?) -
number_of_keys = 0 -
-
Server will respond with: -
struct { -
uint8 opcode; // 0x01 -
uint8 error; // 0;//error -
uint8 M2[20]; //M2 -
uint8 ukn1; // 0; -
uint8 ukn2; // 0; -
uint8 ukn3; // 0; -
uint8 ukn4; // 0; -
} Server_Proof; -
-
To Generate M1 & M2, we need to generate some other values: -
Generate U: -
U = SHA1(A & B) -
Your U should equal: 2f4969ac9f387fd672236f9491a516777cdde1c1 -
-
-
Generate S: // S=(Av^u) ^ b (mod N) -
U = Reverse(U) -
N = Reverse(N) -
A = Reverse(A) -
b = Reverse(b) // Private b -
-
Temp1 = v ^ U mod (n) // Result: 84DC9E9F96AE7A2D9B05CD264A75EB5671EA02FD067B243848543E2713C8D91 -
-
Temp2 = Temp1 * A // Result: 496985FE28C394E7B8FB881105E4CD02F7DF4F378736332BC2F4733ABDEF0903F5BE9084C42B32E3615DF28B069A9D275A8A31DE7FBFD0DA76870B2B285F9D3 -
-
S = Temp2 ^ b mod (n) -
-
Code I use: -
//------------------------------ -
prod = BigIntegerFromInt(0); -
BigIntegerModExp(prod, v, U, N, NULL, NULL); -
S = BigIntegerFromInt(0); -
BigIntegerMul(prod, prod, A, NULL); -
BigIntegerModExp(S, prod, b, N, NULL, NULL); -
BigIntegerToBytes(S, Buffer, 20); -
//------------------------------ -
-
Your S should equal: 7666dc8a226dd0e3de093dddf6bc2b7929df2936a8cf15a972de4042766380ba -
-
-
Next we Take S and Split it into Two Hashes. Even / Odd -
-
S = reverse(S) // Yup we revsere the prior result. -
Then We take only Odd digits -
So S1 Should equal: -
ba63..[other hex digits]..8a66 -
And S2 Should Equal: -
8076..[other hex digits]..dc76 -
-
Then We Hash Each One: -
S1_Hash = SHA(S1) // Should Equal: 02f448b61a6e79d8b714387c0d2f22cc83f2877f -
S2_Hash = SHA(S2) // Should Equal: 61eb916a82b72864ea54dbfd3dc0ce4679c07814 -
-
And then we Re-combine them into S_Hash interleaving them togetner. -
SS_Hash = S1_Hash[0] & S2_Hash[0] & S1_Hash[1] & S2_Hash[1].... -
// SS_Hash should equal: 0261f4eb4891b66a1a826eb77928d864b7ea145438db7cfd0d3d2fc022cecc468379f2c087787f14 -
-
-
-
Ok, now lets calculate M1: You need to Calc M1 to verify it matches the M1 supplied by the client. This VERIFIES the username, password is correct. -
-
N_Hash = SHA1(N) // Nothing is Reversed in this routine -
G_Hash = SHA1(G) -
-
User_Hash = SHA1(uppercase(Username)) -
// User Hash = 984816fd329622876e14907634264e6f332e9fb3 -
// XOr them -
for(i=0;i<20;i++) NG_Hash = N_Hash[i] ^ G_Hash[i]; -
// NG_Hash = 1C76CF5659F68836A628404C431C1855E84D555B -
-
Temp = NG_Hash & User_Hash & Salt & A & B & SS_Hash -
// As you might Guess Temp is a really long string. :) -
-
M1 = SHA1(Temp) // Should = eeb4adca80f4de02f9a9fe8d000d682e3ddfad6f -
-
To Calculate M2: -
-
Temp = A & M1 & SS_Hash -
M2 = SHA1(Temp) // Should equal: 3a92ed0b783597be95654d6c66442046f9d389ae -
-
Now you stuff the server packets M2 with the above M2, and unknowns are all Zero. -
-
The client should request the realmlist packets at this time. You are logged IN!!! :-D -
P.S. I would also like to see the Header Encryption Documented. I've seen some people have decoded it but they are being quite selfish with the knowledge, which sets everyone back. I mean how many development hours does it set everyone back attempting to re-inventing srp6? It has taken me a huge number of hours to get to this point... :o -
[/quote] - + + +Notes by Biasha:
+Structure (fields, size) and sequence of the packets is valid for 1.8.0
+Algorithm is not checked for 1.8.0 yet
+Original URL: http://www.shockerz.net/wowresource/forum/index.php?showtopic=42
+SRP algorithm: RFC2945
+Information about SRP6: http://srp.stanford.edu/doc.html
+
+
+
+ + [quote=Zam,Feb 11 2005, 09:26 PM] +
[Version 1.03] +
+
Ok, this only covers the first handshacking packets. :-) I haven't had time to disect any other packets. +
+
[size=18]If you are having problems; please verify your math with my math; there is a reason I supply the output to every function. This will allow you to see if there is typo's or any problem on either side. +
+
Please note that some libraries may have bugs with Big Numbers; hense the reason I used openssl, as it has been used by crypto products for years. :) +
+
[/size]
+
Changes: +
V1.00 - Initial Release +
V1.01 - Removal of the Second phase and adding where I forgot to up that B (Public) is reveresed before it is stored for use later. +
V1.02 - Added Temp variables results to S calc +
- Fixed the missing UPPERCASE in M1 calculation (Username) +
- Fixed colors. :o +
- Added some more notes. +
V1.03 - Update Warning, and added a couple more intermediate numbers in the M1 Calcs. +
+
+
I have been informed that only the first 4 packets are needed and then the client should ask for the realm list +
+
This is for version 1.1.1. I do not know if anything changed srp wise in 1.2.1; but I will be confirming and diferences between 111 and 121 once I have some spare time. According to several people; srp has NOT changed between 1.1.1 and 1.2.1 +
+
Kudo's to those who have shared there knowledge. Those who have selfishly held onto most or all of their hard work so as not to advance the community; well just disappear -- you are selfish losers and the community would be better off without you... +
------------------------------------------------------------- +
+
Packets as shared by sYkez on this topic (http://www.blizzhackers.com/viewtopic.php?t=21457) +
+
Kudo's to Amso for publically sharing his attempts at decoding srp; he actually was the one to inspire me to do this. +
Notes: +
Reverse means reverse the String. DO NOT USE strrev -- +
Treat this string as an array of numbers. 0 is a valid number; strrev will stop reversing when it incounters an NULL(0) character. My reverse routine is passed the length that it needs to reverse. In fact all of these variables are strored in a simple structure {char *data; int len;} and I pass this structure around. +
uppercase means upper case all letters in string. +
All values are in hex. +
& means concatanate the string valuse. "HI" & "THERE" = "HITHERE" +
Common Q & A: +
Yes, Username and Password are Uppercased. +
Yes, there are reversed string used in certain snippits of code. Don't ask my why; I don't know why Bliz deviated from the standard -- but it works. I assume the reason why is endian-ness of the machines. There server might be a main-frame... +
I am using an UNMODIFIED openssl (latest version) library. +
And I am using the wrapper functions in the t_math.c file that comes from the srp demo page. They just make the names of the functions much more readable. :-) +
+
Each Calculation assumes the byte order is in the initial stored state. So N=894B... +
When I reverse it in a routine N is only reversed for that Routine. When you get to the next routine, N is again equal to 894B... Some routines work with a reversed version of the calculation and some don't. Exception to this rule is B, it is reveresed before it is stored for use in later calculations. +
Lets Go at it: +
+
The Client Connects and sends the Client_Challenge packet. (Pretty self explanitory) +
+
struct { +
uint8 opcode; // 0x00 +
uint8 error; // 0x02 +
uint16 size; // 0x0023 (size of the rest of packet) +
char gameid[4]; //gameid[4]=0; // 'WoW' +
uint8 version1; // 0x00 +
uint8 version2; // 0x12 build version(0.12.0) +
uint8 version3; // 0x00 +
uint16 build; // 3988 +
char platform[4]; // platform[4]=0; // 'x86' +
char os[4]; // os[4]=0; // 'Win' +
char language[4]; // language[4]=0; // 'enUS' +
uint32 timezone_bias; // -419 +
uint32 ip; // client ip +
uint8 acclen; // length of account name +
char *AccountName; +
} Client_Challenge; +
+
The Server Generates the Following Packet: +
+
struct { +
uint8 opcode; // 0x00 +
uint8 error; //no error +
uint8 ukn1; +
char B[32]; +
uint8 g_length; //1 +
char g; +
+
uint8 n_len; // 32; //N_len +
char N[32]; +
char salt[32]; +
char unk3[16]; +
} Server_Challenge; +
+
Ok, N is is hard coded in hex as: +
894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7 +
G Length = 1 +
G = 7 +
K = 3 +
salt = randomly generated 32 characters. +
Server also internally generates a random generated "b" 20 characters +
+
We are going to assume some values to make it easier to duplicate: +
Username = "TEST" +
Password = "TEST" +
salt = 33f140d46cb66e631fdbbbc9f029ad8898e05ee533876118185e56dde843674f +
b = 8692E3A6BA48B5B1004CEF76825127B7EB7D1AEF +
+
Ok, Now for the calculations: +
+
To Generate x: +
Temp = "Username" (Supplied in the client challenge) & ":" & "Password" (Supplied to whatever user registration script). +
TempHash = SHA1(uppercase(Temp)) +
x = sha1(Salt & TempHash) +
+
Your x should equal: 1b70dd2ad03c1ed140223f8f8741c00ec3a4ce73 +
+
To Generate v (Verifier): +
N = Reverse(N) // 32 Characters +
x = Reverse(x) // 20 Characters +
v = g ^ x mod (N) +
// Exact call I Use: BN_mod_exp_mont(v, g, x, N, ctx, NULL); +
Your v Should equal: 996ec7b349d5827043ecd0e6efba3daea5590f944d0184fee1b83ff4f59ecfa8 +
+
+
To Generate B (public B, not private B): +
/* B = kv + g^b mod n */ +
b = Reverse(b) +
N = Reverse(N) +
+
Temp1 = K * v +
Temp2 = g ^ b mod (N) +
Temp3 = Temp1 + Temp2 +
B = Temp3 mod (N) +
B = Reverse(B) // Store this one PERMANATLY Reversed!!! +
+
// code I use is: +
//------------------------------ +
BigIntegerMul(B, k, v, NULL); +
BigIntegerModExp(k, g, b, N, NULL, NULL); +
BigIntegerAdd(k, k, B); +
BigIntegerMod(B, k, N, NULL); +
//------------------------------ +
Your B should equal: 645d1f78973073701e12bc98aa38ea99b4bc435c32e8447c73ab077ae4d75964 +
+
+
Stuff B, g, N, and Salt in the packet and send it. +
+
The client will respond with the following: +
struct { +
uint8 opcode; // 0x01 +
uint8 A[32]; +
uint8 M1[20]; +
uint8 crc_hash[20]; +
uint8 number_of_keys; +
} Client_Proof; +
+
Were going to assume A came over as follows: +
232fb1b88529643d95b8dce78f2750c75b2df37acba873eb31073839eda0738d +
And M1 came over as: +
eeb4adca80f4de02f9a9fe8d000d682e3ddfad6f +
+
A is generated by the client by its secret (a). You will never know what the secret (a) is, so you don't need to worry about how to calc A. (See SRP demo page if you really need to generate an A because you are working on a client program. +
+
M1 however is quite important, this will be used to detect if the user is authenticly loging on. +
+
crc_hash, appears to be unimportant in 1.1.1 (Anybody have any info?) +
number_of_keys = 0 +
+
Server will respond with: +
struct { +
uint8 opcode; // 0x01 +
uint8 error; // 0;//error +
uint8 M2[20]; //M2 +
uint8 ukn1; // 0; +
uint8 ukn2; // 0; +
uint8 ukn3; // 0; +
uint8 ukn4; // 0; +
} Server_Proof; +
+
To Generate M1 & M2, we need to generate some other values: +
Generate U: +
U = SHA1(A & B) +
Your U should equal: 2f4969ac9f387fd672236f9491a516777cdde1c1 +
+
+
Generate S: // S=(Av^u) ^ b (mod N) +
U = Reverse(U) +
N = Reverse(N) +
A = Reverse(A) +
b = Reverse(b) // Private b +
+
Temp1 = v ^ U mod (n) // Result: 84DC9E9F96AE7A2D9B05CD264A75EB5671EA02FD067B243848543E2713C8D91 +
+
Temp2 = Temp1 * A // Result: 496985FE28C394E7B8FB881105E4CD02F7DF4F378736332BC2F4733ABDEF0903F5BE9084C42B32E3615DF28B069A9D275A8A31DE7FBFD0DA76870B2B285F9D3 +
+
S = Temp2 ^ b mod (n) +
+
Code I use: +
//------------------------------ +
prod = BigIntegerFromInt(0); +
BigIntegerModExp(prod, v, U, N, NULL, NULL); +
S = BigIntegerFromInt(0); +
BigIntegerMul(prod, prod, A, NULL); +
BigIntegerModExp(S, prod, b, N, NULL, NULL); +
BigIntegerToBytes(S, Buffer, 20); +
//------------------------------ +
+
Your S should equal: 7666dc8a226dd0e3de093dddf6bc2b7929df2936a8cf15a972de4042766380ba +
+
+
Next we Take S and Split it into Two Hashes. Even / Odd +
+
S = reverse(S) // Yup we revsere the prior result. +
Then We take only Odd digits +
So S1 Should equal: +
ba63..[other hex digits]..8a66 +
And S2 Should Equal: +
8076..[other hex digits]..dc76 +
+
Then We Hash Each One: +
S1_Hash = SHA(S1) // Should Equal: 02f448b61a6e79d8b714387c0d2f22cc83f2877f +
S2_Hash = SHA(S2) // Should Equal: 61eb916a82b72864ea54dbfd3dc0ce4679c07814 +
+
And then we Re-combine them into S_Hash interleaving them togetner. +
SS_Hash = S1_Hash[0] & S2_Hash[0] & S1_Hash[1] & S2_Hash[1].... +
// SS_Hash should equal: 0261f4eb4891b66a1a826eb77928d864b7ea145438db7cfd0d3d2fc022cecc468379f2c087787f14 +
+
+
+
Ok, now lets calculate M1: You need to Calc M1 to verify it matches the M1 supplied by the client. This VERIFIES the username, password is correct. +
+
N_Hash = SHA1(N) // Nothing is Reversed in this routine +
G_Hash = SHA1(G) +
+
User_Hash = SHA1(uppercase(Username)) +
// User Hash = 984816fd329622876e14907634264e6f332e9fb3 +
// XOr them +
for(i=0;i<20;i++) NG_Hash = N_Hash[i] ^ G_Hash[i]; +
// NG_Hash = 1C76CF5659F68836A628404C431C1855E84D555B +
+
Temp = NG_Hash & User_Hash & Salt & A & B & SS_Hash +
// As you might Guess Temp is a really long string. :) +
+
M1 = SHA1(Temp) // Should = eeb4adca80f4de02f9a9fe8d000d682e3ddfad6f +
+
To Calculate M2: +
+
Temp = A & M1 & SS_Hash +
M2 = SHA1(Temp) // Should equal: 3a92ed0b783597be95654d6c66442046f9d389ae +
+
Now you stuff the server packets M2 with the above M2, and unknowns are all Zero. +
+
The client should request the realmlist packets at this time. You are logged IN!!! :-D +
P.S. I would also like to see the Header Encryption Documented. I've seen some people have decoded it but they are being quite selfish with the knowledge, which sets everyone back. I mean how many development hours does it set everyone back attempting to re-inventing srp6? It has taken me a huge number of hours to get to this point... :o +
[/quote] + diff --git a/src/Client/main.cpp b/src/Client/main.cpp index 01720a4..50b0ead 100644 --- a/src/Client/main.cpp +++ b/src/Client/main.cpp @@ -1,115 +1,115 @@ -#include - -#include "common.h" -#include "main.h" -#include "PseuWoW.h" - - -std::list instanceList; // TODO: move this to a "Master" class later - - -void _HookSignals(void) -{ - signal(SIGINT, _OnSignal); - signal(SIGQUIT, _OnSignal); - signal(SIGTERM, _OnSignal); - signal(SIGABRT, _OnSignal); - #ifdef _WIN32 - signal(SIGBREAK, _OnSignal); - #endif -} - -void _UnhookSignals(void) -{ - signal(SIGINT, 0); - signal(SIGQUIT, 0); - signal(SIGTERM, 0); - signal(SIGABRT, 0); - #ifdef _WIN32 - signal(SIGBREAK, 0); - #endif -} - -void _OnSignal(int s) -{ - switch (s) - { - case SIGINT: - case SIGQUIT: - case SIGTERM: - quitproc(); - break; - case SIGABRT: - #ifndef _DEBUG - case SIGSEGV: - #endif - #ifdef _WIN32 - case SIGBREAK: - #endif - abortproc(); - break; - } - signal(s, _OnSignal); -} - -void quitproc(void) -{ - printf("Waiting for all instances to finish... [%u]\n",instanceList.size()); - for(std::list::iterator i=instanceList.begin();i!=instanceList.end();i++) - { - (*i)->GetInstance()->Stop(); - } -} - -void abortproc(void) -{ - printf("Terminating all instances... [%u]\n",instanceList.size()); - for(std::list::iterator i=instanceList.begin();i!=instanceList.end();i++) - { - (*i)->GetInstance()->SetFastQuit(true); - (*i)->GetInstance()->Stop(); - } -} - -void _new_handler(void) -{ - logcritical("ERROR: Out of memory!"); - throw; -} - -int main(int argc, char* argv[]) { - try - { - set_new_handler(_new_handler); - log_prepare("logfile.txt","a"); - logcustom(0,LGREEN,"+----------------------------------+"); - logcustom(0,LGREEN,"| (C) 2006-2008 Snowstorm Software |"); - logcustom(0,LGREEN,"| http://www.mangosclient.org |"); - logcustom(0,LGREEN,"+----------------------------------+"); - logcustom(0,GREEN,"Platform: %s",PLATFORM_NAME); - logcustom(0,GREEN,"Compiler: %s ("COMPILER_VERSION_OUT")",COMPILER_NAME,COMPILER_VERSION); - logcustom(0,GREEN,"Compiled: %s %s",__DATE__,__TIME__); - - _HookSignals(); - - // 1 instance is enough for now - PseuInstanceRunnable *r=new PseuInstanceRunnable(); - ZThread::Thread t(r); - instanceList.push_back(r); - t.setPriority((ZThread::Priority)2); - //... - t.wait(); - //... - log_close(); - _UnhookSignals(); - raise(SIGABRT); // this way to terminate is not nice but the only way to quit the CLI thread - raise(SIGQUIT); - return 0; - } - catch (...) - { - printf("ERROR: Unhandled exception in main thread!\n"); - raise(SIGABRT); - return 1; - } -} +#include + +#include "common.h" +#include "main.h" +#include "PseuWoW.h" + + +std::list instanceList; // TODO: move this to a "Master" class later + + +void _HookSignals(void) +{ + signal(SIGINT, _OnSignal); + signal(SIGQUIT, _OnSignal); + signal(SIGTERM, _OnSignal); + signal(SIGABRT, _OnSignal); + #ifdef _WIN32 + signal(SIGBREAK, _OnSignal); + #endif +} + +void _UnhookSignals(void) +{ + signal(SIGINT, 0); + signal(SIGQUIT, 0); + signal(SIGTERM, 0); + signal(SIGABRT, 0); + #ifdef _WIN32 + signal(SIGBREAK, 0); + #endif +} + +void _OnSignal(int s) +{ + switch (s) + { + case SIGINT: + case SIGQUIT: + case SIGTERM: + quitproc(); + break; + case SIGABRT: + #ifndef _DEBUG + case SIGSEGV: + #endif + #ifdef _WIN32 + case SIGBREAK: + #endif + abortproc(); + break; + } + signal(s, _OnSignal); +} + +void quitproc(void) +{ + printf("Waiting for all instances to finish... [%u]\n",instanceList.size()); + for(std::list::iterator i=instanceList.begin();i!=instanceList.end();i++) + { + (*i)->GetInstance()->Stop(); + } +} + +void abortproc(void) +{ + printf("Terminating all instances... [%u]\n",instanceList.size()); + for(std::list::iterator i=instanceList.begin();i!=instanceList.end();i++) + { + (*i)->GetInstance()->SetFastQuit(true); + (*i)->GetInstance()->Stop(); + } +} + +void _new_handler(void) +{ + logcritical("ERROR: Out of memory!"); + throw; +} + +int main(int argc, char* argv[]) { + try + { + set_new_handler(_new_handler); + log_prepare("logfile.txt","a"); + logcustom(0,LGREEN,"+----------------------------------+"); + logcustom(0,LGREEN,"| (C) 2006-2008 Snowstorm Software |"); + logcustom(0,LGREEN,"| http://www.mangosclient.org |"); + logcustom(0,LGREEN,"+----------------------------------+"); + logcustom(0,GREEN,"Platform: %s",PLATFORM_NAME); + logcustom(0,GREEN,"Compiler: %s ("COMPILER_VERSION_OUT")",COMPILER_NAME,COMPILER_VERSION); + logcustom(0,GREEN,"Compiled: %s %s",__DATE__,__TIME__); + + _HookSignals(); + + // 1 instance is enough for now + PseuInstanceRunnable *r=new PseuInstanceRunnable(); + ZThread::Thread t(r); + instanceList.push_back(r); + t.setPriority((ZThread::Priority)2); + //... + t.wait(); + //... + log_close(); + _UnhookSignals(); + raise(SIGABRT); // this way to terminate is not nice but the only way to quit the CLI thread + raise(SIGQUIT); + return 0; + } + catch (...) + { + printf("ERROR: Unhandled exception in main thread!\n"); + raise(SIGABRT); + return 1; + } +} diff --git a/src/Client/main.h b/src/Client/main.h index 0af8e4c..e93c0c5 100644 --- a/src/Client/main.h +++ b/src/Client/main.h @@ -1,12 +1,12 @@ -#ifndef _MAIN_H -#define _MAIN_H - -void _HookSignals(void); -void _UnhookSignals(void); -void _OnSignal(int); -void quitproc(void); -void abortproc(void); -void _new_handler(void); -int main(int,char**); - -#endif +#ifndef _MAIN_H +#define _MAIN_H + +void _HookSignals(void); +void _UnhookSignals(void); +void _OnSignal(int); +void quitproc(void); +void abortproc(void); +void _new_handler(void); +int main(int,char**); + +#endif diff --git a/src/Client/resource.h b/src/Client/resource.h index b9417c6..93d6742 100644 --- a/src/Client/resource.h +++ b/src/Client/resource.h @@ -1,16 +1,16 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by PseuWoW.rc -// -#define IDI_ICON1 101 - -// 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 +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by PseuWoW.rc +// +#define IDI_ICON1 101 + +// 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/src/PseuWoW.vcproj b/src/PseuWoW.vcproj index c280cbf..f1fa1e1 100644 --- a/src/PseuWoW.vcproj +++ b/src/PseuWoW.vcproj @@ -1,874 +1,874 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/PseuWoW_VC80.vcproj b/src/PseuWoW_VC80.vcproj index a44ebd4..2f1d6a3 100644 --- a/src/PseuWoW_VC80.vcproj +++ b/src/PseuWoW_VC80.vcproj @@ -1,1162 +1,1162 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/dep/include/DXSDK/include/D3D10.h b/src/dep/include/DXSDK/include/D3D10.h index 845489a..a6d5fbd 100644 --- a/src/dep/include/DXSDK/include/D3D10.h +++ b/src/dep/include/DXSDK/include/D3D10.h @@ -1,6566 +1,6566 @@ - - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 7.00.0485 */ -/* Compiler settings for d3d10.idl: - Oicf, W1, Zp8, env=Win32 (32b run) - protocol : dce , ms_ext, c_ext, robust - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() -*/ -//@@MIDL_FILE_HEADING( ) - -#pragma warning( disable: 4049 ) /* more than 64k source lines */ - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 475 -#endif - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCSAL_H_VERSION__ -#define __REQUIRED_RPCSAL_H_VERSION__ 100 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ - -#ifndef COM_NO_WINDOWS_H -#include "windows.h" -#include "ole2.h" -#endif /*COM_NO_WINDOWS_H*/ - -#ifndef __d3d10_h__ -#define __d3d10_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -/* Forward Declarations */ - -#ifndef __ID3D10DeviceChild_FWD_DEFINED__ -#define __ID3D10DeviceChild_FWD_DEFINED__ -typedef interface ID3D10DeviceChild ID3D10DeviceChild; -#endif /* __ID3D10DeviceChild_FWD_DEFINED__ */ - - -#ifndef __ID3D10DepthStencilState_FWD_DEFINED__ -#define __ID3D10DepthStencilState_FWD_DEFINED__ -typedef interface ID3D10DepthStencilState ID3D10DepthStencilState; -#endif /* __ID3D10DepthStencilState_FWD_DEFINED__ */ - - -#ifndef __ID3D10BlendState_FWD_DEFINED__ -#define __ID3D10BlendState_FWD_DEFINED__ -typedef interface ID3D10BlendState ID3D10BlendState; -#endif /* __ID3D10BlendState_FWD_DEFINED__ */ - - -#ifndef __ID3D10RasterizerState_FWD_DEFINED__ -#define __ID3D10RasterizerState_FWD_DEFINED__ -typedef interface ID3D10RasterizerState ID3D10RasterizerState; -#endif /* __ID3D10RasterizerState_FWD_DEFINED__ */ - - -#ifndef __ID3D10Resource_FWD_DEFINED__ -#define __ID3D10Resource_FWD_DEFINED__ -typedef interface ID3D10Resource ID3D10Resource; -#endif /* __ID3D10Resource_FWD_DEFINED__ */ - - -#ifndef __ID3D10Buffer_FWD_DEFINED__ -#define __ID3D10Buffer_FWD_DEFINED__ -typedef interface ID3D10Buffer ID3D10Buffer; -#endif /* __ID3D10Buffer_FWD_DEFINED__ */ - - -#ifndef __ID3D10Texture1D_FWD_DEFINED__ -#define __ID3D10Texture1D_FWD_DEFINED__ -typedef interface ID3D10Texture1D ID3D10Texture1D; -#endif /* __ID3D10Texture1D_FWD_DEFINED__ */ - - -#ifndef __ID3D10Texture2D_FWD_DEFINED__ -#define __ID3D10Texture2D_FWD_DEFINED__ -typedef interface ID3D10Texture2D ID3D10Texture2D; -#endif /* __ID3D10Texture2D_FWD_DEFINED__ */ - - -#ifndef __ID3D10Texture3D_FWD_DEFINED__ -#define __ID3D10Texture3D_FWD_DEFINED__ -typedef interface ID3D10Texture3D ID3D10Texture3D; -#endif /* __ID3D10Texture3D_FWD_DEFINED__ */ - - -#ifndef __ID3D10TextureCube_FWD_DEFINED__ -#define __ID3D10TextureCube_FWD_DEFINED__ -typedef interface ID3D10TextureCube ID3D10TextureCube; -#endif /* __ID3D10TextureCube_FWD_DEFINED__ */ - - -#ifndef __ID3D10View_FWD_DEFINED__ -#define __ID3D10View_FWD_DEFINED__ -typedef interface ID3D10View ID3D10View; -#endif /* __ID3D10View_FWD_DEFINED__ */ - - -#ifndef __ID3D10ShaderResourceView_FWD_DEFINED__ -#define __ID3D10ShaderResourceView_FWD_DEFINED__ -typedef interface ID3D10ShaderResourceView ID3D10ShaderResourceView; -#endif /* __ID3D10ShaderResourceView_FWD_DEFINED__ */ - - -#ifndef __ID3D10RenderTargetView_FWD_DEFINED__ -#define __ID3D10RenderTargetView_FWD_DEFINED__ -typedef interface ID3D10RenderTargetView ID3D10RenderTargetView; -#endif /* __ID3D10RenderTargetView_FWD_DEFINED__ */ - - -#ifndef __ID3D10DepthStencilView_FWD_DEFINED__ -#define __ID3D10DepthStencilView_FWD_DEFINED__ -typedef interface ID3D10DepthStencilView ID3D10DepthStencilView; -#endif /* __ID3D10DepthStencilView_FWD_DEFINED__ */ - - -#ifndef __ID3D10VertexShader_FWD_DEFINED__ -#define __ID3D10VertexShader_FWD_DEFINED__ -typedef interface ID3D10VertexShader ID3D10VertexShader; -#endif /* __ID3D10VertexShader_FWD_DEFINED__ */ - - -#ifndef __ID3D10GeometryShader_FWD_DEFINED__ -#define __ID3D10GeometryShader_FWD_DEFINED__ -typedef interface ID3D10GeometryShader ID3D10GeometryShader; -#endif /* __ID3D10GeometryShader_FWD_DEFINED__ */ - - -#ifndef __ID3D10PixelShader_FWD_DEFINED__ -#define __ID3D10PixelShader_FWD_DEFINED__ -typedef interface ID3D10PixelShader ID3D10PixelShader; -#endif /* __ID3D10PixelShader_FWD_DEFINED__ */ - - -#ifndef __ID3D10InputLayout_FWD_DEFINED__ -#define __ID3D10InputLayout_FWD_DEFINED__ -typedef interface ID3D10InputLayout ID3D10InputLayout; -#endif /* __ID3D10InputLayout_FWD_DEFINED__ */ - - -#ifndef __ID3D10SamplerState_FWD_DEFINED__ -#define __ID3D10SamplerState_FWD_DEFINED__ -typedef interface ID3D10SamplerState ID3D10SamplerState; -#endif /* __ID3D10SamplerState_FWD_DEFINED__ */ - - -#ifndef __ID3D10Asynchronous_FWD_DEFINED__ -#define __ID3D10Asynchronous_FWD_DEFINED__ -typedef interface ID3D10Asynchronous ID3D10Asynchronous; -#endif /* __ID3D10Asynchronous_FWD_DEFINED__ */ - - -#ifndef __ID3D10Query_FWD_DEFINED__ -#define __ID3D10Query_FWD_DEFINED__ -typedef interface ID3D10Query ID3D10Query; -#endif /* __ID3D10Query_FWD_DEFINED__ */ - - -#ifndef __ID3D10Predicate_FWD_DEFINED__ -#define __ID3D10Predicate_FWD_DEFINED__ -typedef interface ID3D10Predicate ID3D10Predicate; -#endif /* __ID3D10Predicate_FWD_DEFINED__ */ - - -#ifndef __ID3D10Counter_FWD_DEFINED__ -#define __ID3D10Counter_FWD_DEFINED__ -typedef interface ID3D10Counter ID3D10Counter; -#endif /* __ID3D10Counter_FWD_DEFINED__ */ - - -#ifndef __ID3D10Device_FWD_DEFINED__ -#define __ID3D10Device_FWD_DEFINED__ -typedef interface ID3D10Device ID3D10Device; -#endif /* __ID3D10Device_FWD_DEFINED__ */ - - -#ifndef __ID3D10StateMirror_FWD_DEFINED__ -#define __ID3D10StateMirror_FWD_DEFINED__ -typedef interface ID3D10StateMirror ID3D10StateMirror; -#endif /* __ID3D10StateMirror_FWD_DEFINED__ */ - - -#ifndef __ID3D10Multithread_FWD_DEFINED__ -#define __ID3D10Multithread_FWD_DEFINED__ -typedef interface ID3D10Multithread ID3D10Multithread; -#endif /* __ID3D10Multithread_FWD_DEFINED__ */ - - -/* header files for imported files */ -#include "oaidl.h" -#include "ocidl.h" -#include "dxgi.h" - -#ifdef __cplusplus -extern "C"{ -#endif - - -/* interface __MIDL_itf_d3d10_0000_0000 */ -/* [local] */ - -#ifndef _D3D10_CONSTANTS -#define _D3D10_CONSTANTS -#define D3D10_16BIT_INDEX_STRIP_CUT_VALUE ( 0xffff ) - -#define D3D10_32BIT_INDEX_STRIP_CUT_VALUE ( 0xffffffff ) - -#define D3D10_8BIT_INDEX_STRIP_CUT_VALUE ( 0xff ) - -#define D3D10_ARRAY_AXIS_ADDRESS_RANGE_BIT_COUNT ( 9 ) - -#define D3D10_CLIP_OR_CULL_DISTANCE_COUNT ( 8 ) - -#define D3D10_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT ( 2 ) - -#define D3D10_COMMONSHADER_CONSTANT_BUFFER_COMPONENTS ( 4 ) - -#define D3D10_COMMONSHADER_CONSTANT_BUFFER_COMPONENT_BIT_COUNT ( 32 ) - -#define D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COMPONENTS ( 4 ) - -#define D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COUNT ( 15 ) - -#define D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READS_PER_INST ( 1 ) - -#define D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READ_PORTS ( 1 ) - -#define D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT ( 15 ) - -#define D3D10_COMMONSHADER_FLOWCONTROL_NESTING_LIMIT ( 64 ) - -#define D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COMPONENTS ( 4 ) - -#define D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COUNT ( 1 ) - -#define D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READS_PER_INST ( 1 ) - -#define D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READ_PORTS ( 1 ) - -#define D3D10_COMMONSHADER_IMMEDIATE_VALUE_COMPONENT_BIT_COUNT ( 32 ) - -#define D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_COMPONENTS ( 1 ) - -#define D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT ( 128 ) - -#define D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_READS_PER_INST ( 1 ) - -#define D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_READ_PORTS ( 1 ) - -#define D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT ( 128 ) - -#define D3D10_COMMONSHADER_SAMPLER_REGISTER_COMPONENTS ( 1 ) - -#define D3D10_COMMONSHADER_SAMPLER_REGISTER_COUNT ( 16 ) - -#define D3D10_COMMONSHADER_SAMPLER_REGISTER_READS_PER_INST ( 1 ) - -#define D3D10_COMMONSHADER_SAMPLER_REGISTER_READ_PORTS ( 1 ) - -#define D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT ( 16 ) - -#define D3D10_COMMONSHADER_SUBROUTINE_NESTING_LIMIT ( 32 ) - -#define D3D10_COMMONSHADER_TEMP_REGISTER_COMPONENTS ( 4 ) - -#define D3D10_COMMONSHADER_TEMP_REGISTER_COMPONENT_BIT_COUNT ( 32 ) - -#define D3D10_COMMONSHADER_TEMP_REGISTER_COUNT ( 4096 ) - -#define D3D10_COMMONSHADER_TEMP_REGISTER_READS_PER_INST ( 3 ) - -#define D3D10_COMMONSHADER_TEMP_REGISTER_READ_PORTS ( 3 ) - -#define D3D10_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MAX ( 10 ) - -#define D3D10_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MIN ( -10 ) - -#define D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE ( -8 ) - -#define D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE ( 7 ) - -#define D3D10_DEFAULT_BLEND_FACTOR_ALPHA ( 1.0f ) -#define D3D10_DEFAULT_BLEND_FACTOR_BLUE ( 1.0f ) -#define D3D10_DEFAULT_BLEND_FACTOR_GREEN ( 1.0f ) -#define D3D10_DEFAULT_BLEND_FACTOR_RED ( 1.0f ) -#define D3D10_DEFAULT_BORDER_COLOR_COMPONENT ( 0.0f ) -#define D3D10_DEFAULT_DEPTH_BIAS ( 0 ) - -#define D3D10_DEFAULT_DEPTH_BIAS_CLAMP ( 0.0f ) -#define D3D10_DEFAULT_MAX_ANISOTROPY ( 16.0f ) -#define D3D10_DEFAULT_MIP_LOD_BIAS ( 0.0f ) -#define D3D10_DEFAULT_RENDER_TARGET_ARRAY_INDEX ( 0 ) - -#define D3D10_DEFAULT_SAMPLE_MASK ( 0xffffffff ) - -#define D3D10_DEFAULT_SCISSOR_ENDX ( 0 ) - -#define D3D10_DEFAULT_SCISSOR_ENDY ( 0 ) - -#define D3D10_DEFAULT_SCISSOR_STARTX ( 0 ) - -#define D3D10_DEFAULT_SCISSOR_STARTY ( 0 ) - -#define D3D10_DEFAULT_SLOPE_SCALED_DEPTH_BIAS ( 0.0f ) -#define D3D10_DEFAULT_STENCIL_READ_MASK ( 0xff ) - -#define D3D10_DEFAULT_STENCIL_REFERENCE ( 0 ) - -#define D3D10_DEFAULT_STENCIL_WRITE_MASK ( 0xff ) - -#define D3D10_DEFAULT_VIEWPORT_AND_SCISSORRECT_INDEX ( 0 ) - -#define D3D10_DEFAULT_VIEWPORT_HEIGHT ( 0.0f ) -#define D3D10_DEFAULT_VIEWPORT_MAX_DEPTH ( 0.0f ) -#define D3D10_DEFAULT_VIEWPORT_MIN_DEPTH ( 0.0f ) -#define D3D10_DEFAULT_VIEWPORT_TOPLEFTX ( 0.0f ) -#define D3D10_DEFAULT_VIEWPORT_TOPLEFTY ( 0.0f ) -#define D3D10_DEFAULT_VIEWPORT_WIDTH ( 0.0f ) -#define D3D10_FLOAT16_FUSED_TOLERANCE_IN_ULP ( 0.6 ) -#define D3D10_FLOAT32_DEPTH_BUFFER_EXPONENT_BIAS ( 23 ) - -#define D3D10_FLOAT32_MAX ( 3.402823466e+38f ) -#define D3D10_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP ( 0.6f ) -#define D3D10_FLOAT_TO_SRGB_EXPONENT_DENOMINATOR ( 2.4f ) -#define D3D10_FLOAT_TO_SRGB_EXPONENT_NUMERATOR ( 1.0f ) -#define D3D10_FLOAT_TO_SRGB_OFFSET ( 0.055f ) -#define D3D10_FLOAT_TO_SRGB_SCALE_1 ( 12.92f ) -#define D3D10_FLOAT_TO_SRGB_SCALE_2 ( 1.055f ) -#define D3D10_FLOAT_TO_SRGB_THRESHOLD ( 0.0031308f ) -#define D3D10_FTOI_INSTRUCTION_MAX_INPUT ( 2147483647.999f ) -#define D3D10_FTOI_INSTRUCTION_MIN_INPUT ( -2147483648.999f ) -#define D3D10_FTOU_INSTRUCTION_MAX_INPUT ( 4294967296.999f ) -#define D3D10_FTOU_INSTRUCTION_MIN_INPUT ( 0.0f ) -#define D3D10_GS_INPUT_PRIM_CONST_REGISTER_COMPONENTS ( 1 ) - -#define D3D10_GS_INPUT_PRIM_CONST_REGISTER_COMPONENT_BIT_COUNT ( 32 ) - -#define D3D10_GS_INPUT_PRIM_CONST_REGISTER_COUNT ( 1 ) - -#define D3D10_GS_INPUT_PRIM_CONST_REGISTER_READS_PER_INST ( 2 ) - -#define D3D10_GS_INPUT_PRIM_CONST_REGISTER_READ_PORTS ( 1 ) - -#define D3D10_GS_INPUT_REGISTER_COMPONENTS ( 4 ) - -#define D3D10_GS_INPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) - -#define D3D10_GS_INPUT_REGISTER_COUNT ( 16 ) - -#define D3D10_GS_INPUT_REGISTER_READS_PER_INST ( 2 ) - -#define D3D10_GS_INPUT_REGISTER_READ_PORTS ( 1 ) - -#define D3D10_GS_INPUT_REGISTER_VERTICES ( 6 ) - -#define D3D10_GS_OUTPUT_ELEMENTS ( 32 ) - -#define D3D10_GS_OUTPUT_REGISTER_COMPONENTS ( 4 ) - -#define D3D10_GS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) - -#define D3D10_GS_OUTPUT_REGISTER_COUNT ( 32 ) - -#define D3D10_IA_DEFAULT_INDEX_BUFFER_OFFSET_IN_BYTES ( 0 ) - -#define D3D10_IA_DEFAULT_PRIMITIVE_TOPOLOGY ( 0 ) - -#define D3D10_IA_DEFAULT_VERTEX_BUFFER_OFFSET_IN_BYTES ( 0 ) - -#define D3D10_IA_INDEX_INPUT_RESOURCE_SLOT_COUNT ( 1 ) - -#define D3D10_IA_INSTANCE_ID_BIT_COUNT ( 32 ) - -#define D3D10_IA_INTEGER_ARITHMETIC_BIT_COUNT ( 32 ) - -#define D3D10_IA_PRIMITIVE_ID_BIT_COUNT ( 32 ) - -#define D3D10_IA_VERTEX_ID_BIT_COUNT ( 32 ) - -#define D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT ( 16 ) - -#define D3D10_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS ( 64 ) - -#define D3D10_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT ( 16 ) - -#define D3D10_INTEGER_DIVIDE_BY_ZERO_QUOTIENT ( 0xffffffff ) - -#define D3D10_INTEGER_DIVIDE_BY_ZERO_REMAINDER ( 0xffffffff ) - -#define D3D10_LINEAR_GAMMA ( 1.0f ) -#define D3D10_MAX_BORDER_COLOR_COMPONENT ( 1.0f ) -#define D3D10_MAX_DEPTH ( 1.0f ) -#define D3D10_MAX_MAXANISOTROPY ( 16 ) - -#define D3D10_MAX_MULTISAMPLE_SAMPLE_COUNT ( 32 ) - -#define D3D10_MAX_POSITION_VALUE ( 3.402823466e+34f ) -#define D3D10_MAX_TEXTURE_DIMENSION_2_TO_EXP ( 17 ) - -#define D3D10_MIN_BORDER_COLOR_COMPONENT ( 0.0f ) -#define D3D10_MIN_DEPTH ( 0.0f ) -#define D3D10_MIN_MAXANISOTROPY ( 0 ) - -#define D3D10_MIP_LOD_BIAS_MAX ( 15.99f ) -#define D3D10_MIP_LOD_BIAS_MIN ( -16.0f ) -#define D3D10_MIP_LOD_FRACTIONAL_BIT_COUNT ( 6 ) - -#define D3D10_MIP_LOD_RANGE_BIT_COUNT ( 8 ) - -#define D3D10_MULTISAMPLE_ANTIALIAS_LINE_WIDTH ( 1.4f ) -#define D3D10_NONSAMPLE_FETCH_OUT_OF_RANGE_ACCESS_RESULT ( 0 ) - -#define D3D10_PIXEL_ADDRESS_RANGE_BIT_COUNT ( 13 ) - -#define D3D10_PRE_SCISSOR_PIXEL_ADDRESS_RANGE_BIT_COUNT ( 15 ) - -#define D3D10_PS_FRONTFACING_DEFAULT_VALUE ( 0xffffffff ) - -#define D3D10_PS_FRONTFACING_FALSE_VALUE ( 0 ) - -#define D3D10_PS_FRONTFACING_TRUE_VALUE ( 0xffffffff ) - -#define D3D10_PS_INPUT_REGISTER_COMPONENTS ( 4 ) - -#define D3D10_PS_INPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) - -#define D3D10_PS_INPUT_REGISTER_COUNT ( 32 ) - -#define D3D10_PS_INPUT_REGISTER_READS_PER_INST ( 2 ) - -#define D3D10_PS_INPUT_REGISTER_READ_PORTS ( 1 ) - -#define D3D10_PS_LEGACY_PIXEL_CENTER_FRACTIONAL_COMPONENT ( 0.0f ) -#define D3D10_PS_OUTPUT_DEPTH_REGISTER_COMPONENTS ( 1 ) - -#define D3D10_PS_OUTPUT_DEPTH_REGISTER_COMPONENT_BIT_COUNT ( 32 ) - -#define D3D10_PS_OUTPUT_DEPTH_REGISTER_COUNT ( 1 ) - -#define D3D10_PS_OUTPUT_REGISTER_COMPONENTS ( 4 ) - -#define D3D10_PS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) - -#define D3D10_PS_OUTPUT_REGISTER_COUNT ( 8 ) - -#define D3D10_PS_PIXEL_CENTER_FRACTIONAL_COMPONENT ( 0.5f ) -#define D3D10_REQ_BLEND_OBJECT_COUNT_PER_CONTEXT ( 4096 ) - -#define D3D10_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP ( 27 ) - -#define D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT ( 4096 ) - -#define D3D10_REQ_DEPTH_STENCIL_OBJECT_COUNT_PER_CONTEXT ( 4096 ) - -#define D3D10_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP ( 32 ) - -#define D3D10_REQ_DRAW_VERTEX_COUNT_2_TO_EXP ( 32 ) - -#define D3D10_REQ_FILTERING_HW_ADDRESSABLE_RESOURCE_DIMENSION ( 8192 ) - -#define D3D10_REQ_GS_INVOCATION_32BIT_OUTPUT_COMPONENT_LIMIT ( 1024 ) - -#define D3D10_REQ_IMMEDIATE_CONSTANT_BUFFER_ELEMENT_COUNT ( 4096 ) - -#define D3D10_REQ_MAXANISOTROPY ( 16 ) - -#define D3D10_REQ_MIP_LEVELS ( 13 ) - -#define D3D10_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES ( 2048 ) - -#define D3D10_REQ_RASTERIZER_OBJECT_COUNT_PER_CONTEXT ( 4096 ) - -#define D3D10_REQ_RENDER_TO_BUFFER_WINDOW_WIDTH ( 8192 ) - -#define D3D10_REQ_RESOURCE_SIZE_IN_MEGABYTES ( 128 ) - -#define D3D10_REQ_RESOURCE_VIEW_COUNT_PER_CONTEXT_2_TO_EXP ( 20 ) - -#define D3D10_REQ_SAMPLER_OBJECT_COUNT_PER_CONTEXT ( 4096 ) - -#define D3D10_REQ_SHADER_INVOCATION_INSTRUCTION_COUNT ( 65536 ) - -#define D3D10_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION ( 512 ) - -#define D3D10_REQ_TEXTURE1D_U_DIMENSION ( 8192 ) - -#define D3D10_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION ( 512 ) - -#define D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION ( 8192 ) - -#define D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION ( 2048 ) - -#define D3D10_REQ_TEXTURECUBE_DIMENSION ( 8192 ) - -#define D3D10_RESINFO_INSTRUCTION_MISSING_COMPONENT_RETVAL ( 0 ) - -#define D3D10_SHADER_MAJOR_VERSION ( 4 ) - -#define D3D10_SHADER_MINOR_VERSION ( 0 ) - -#define D3D10_SHIFT_INSTRUCTION_PAD_VALUE ( 0 ) - -#define D3D10_SHIFT_INSTRUCTION_SHIFT_VALUE_BIT_COUNT ( 5 ) - -#define D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT ( 8 ) - -#define D3D10_SO_BUFFER_MAX_STRIDE_IN_BYTES ( 2048 ) - -#define D3D10_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES ( 256 ) - -#define D3D10_SO_BUFFER_SLOT_COUNT ( 4 ) - -#define D3D10_SO_DDI_REGISTER_INDEX_DENOTING_GAP ( 0xffffffff ) - -#define D3D10_SO_MULTIPLE_BUFFER_ELEMENTS_PER_BUFFER ( 1 ) - -#define D3D10_SO_SINGLE_BUFFER_COMPONENT_LIMIT ( 64 ) - -#define D3D10_SRGB_GAMMA ( 2.2f ) -#define D3D10_SRGB_TO_FLOAT_DENOMINATOR_1 ( 12.92f ) -#define D3D10_SRGB_TO_FLOAT_DENOMINATOR_2 ( 1.055f ) -#define D3D10_SRGB_TO_FLOAT_EXPONENT ( 2.4f ) -#define D3D10_SRGB_TO_FLOAT_OFFSET ( 0.055f ) -#define D3D10_SRGB_TO_FLOAT_THRESHOLD ( 0.04045f ) -#define D3D10_SRGB_TO_FLOAT_TOLERANCE_IN_ULP ( 0.5f ) -#define D3D10_STANDARD_COMPONENT_BIT_COUNT ( 32 ) - -#define D3D10_STANDARD_COMPONENT_BIT_COUNT_DOUBLED ( 64 ) - -#define D3D10_STANDARD_MAXIMUM_ELEMENT_ALIGNMENT_BYTE_MULTIPLE ( 4 ) - -#define D3D10_STANDARD_PIXEL_COMPONENT_COUNT ( 128 ) - -#define D3D10_STANDARD_PIXEL_ELEMENT_COUNT ( 32 ) - -#define D3D10_STANDARD_VECTOR_SIZE ( 4 ) - -#define D3D10_STANDARD_VERTEX_ELEMENT_COUNT ( 16 ) - -#define D3D10_STANDARD_VERTEX_TOTAL_COMPONENT_COUNT ( 64 ) - -#define D3D10_SUBPIXEL_FRACTIONAL_BIT_COUNT ( 8 ) - -#define D3D10_SUBTEXEL_FRACTIONAL_BIT_COUNT ( 6 ) - -#define D3D10_TEXEL_ADDRESS_RANGE_BIT_COUNT ( 18 ) - -#define D3D10_UNBOUND_MEMORY_ACCESS_RESULT ( 0 ) - -#define D3D10_VIEWPORT_AND_SCISSORRECT_MAX_INDEX ( 15 ) - -#define D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE ( 16 ) - -#define D3D10_VIEWPORT_BOUNDS_MAX ( 16383 ) - -#define D3D10_VIEWPORT_BOUNDS_MIN ( -16384 ) - -#define D3D10_VS_INPUT_REGISTER_COMPONENTS ( 4 ) - -#define D3D10_VS_INPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) - -#define D3D10_VS_INPUT_REGISTER_COUNT ( 16 ) - -#define D3D10_VS_INPUT_REGISTER_READS_PER_INST ( 2 ) - -#define D3D10_VS_INPUT_REGISTER_READ_PORTS ( 1 ) - -#define D3D10_VS_OUTPUT_REGISTER_COMPONENTS ( 4 ) - -#define D3D10_VS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) - -#define D3D10_VS_OUTPUT_REGISTER_COUNT ( 16 ) - -#define D3D10_WHQL_CONTEXT_COUNT_FOR_RESOURCE_LIMIT ( 10 ) - -#define D3D10_WHQL_DRAWINDEXED_INDEX_COUNT_2_TO_EXP ( 25 ) - -#define D3D10_WHQL_DRAW_VERTEX_COUNT_2_TO_EXP ( 25 ) - -#define D3D_MAJOR_VERSION ( 10 ) - -#define D3D_MINOR_VERSION ( 0 ) - -#define D3D_SPEC_DATE_DAY ( 8 ) - -#define D3D_SPEC_DATE_MONTH ( 8 ) - -#define D3D_SPEC_DATE_YEAR ( 2005 ) - -#define D3D_SPEC_VERSION ( 1.03000002 ) -#define WGF_MAJOR_VERSION ( 2 ) - -#define WGF_MINOR_VERSION ( 0 ) - -#endif -#define _FACD3D10 ( 0x879 ) - -#define _FACD3D10DEBUG ( ( _FACD3D10 + 1 ) ) - -#define MAKE_D3D10HRESULT( code ) MAKE_HRESULT( 1, _FACD3D10, code ) -#define D3D10_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS MAKE_D3D10HRESULT(1) -#define D3D10_ERROR_FILE_NOT_FOUND MAKE_D3D10HRESULT(2) -typedef -enum D3D10_INPUT_CLASSIFICATION - { D3D10_INPUT_PER_VERTEX_DATA = 0, - D3D10_INPUT_PER_INSTANCE_DATA = 1 - } D3D10_INPUT_CLASSIFICATION; - -typedef struct D3D10_INPUT_ELEMENT_DESC - { - LPCWSTR SemanticName; - UINT SemanticIndex; - DXGI_FORMAT Format; - UINT InputSlot; - UINT AlignedByteOffset; - D3D10_INPUT_CLASSIFICATION InputSlotClass; - UINT InstanceDataStepRate; - } D3D10_INPUT_ELEMENT_DESC; - -typedef -enum D3D10_FILL_MODE - { D3D10_FILL_WIREFRAME = 2, - D3D10_FILL_SOLID = 3 - } D3D10_FILL_MODE; - -typedef -enum D3D10_PRIMITIVE_TOPOLOGY - { D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED = 0, - D3D10_PRIMITIVE_TOPOLOGY_POINTLIST = 1, - D3D10_PRIMITIVE_TOPOLOGY_LINELIST = 2, - D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP = 3, - D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST = 4, - D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP = 5, - D3D10_PRIMITIVE_TOPOLOGY_LINELIST_ADJ = 10, - D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ = 11, - D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ = 12, - D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ = 13 - } D3D10_PRIMITIVE_TOPOLOGY; - -typedef -enum D3D10_PRIMITIVE - { D3D10_PRIMITIVE_UNDEFINED = 0, - D3D10_PRIMITIVE_POINT = 1, - D3D10_PRIMITIVE_LINE = 2, - D3D10_PRIMITIVE_TRIANGLE = 3, - D3D10_PRIMITIVE_LINE_ADJ = 6, - D3D10_PRIMITIVE_TRIANGLE_ADJ = 7 - } D3D10_PRIMITIVE; - -typedef -enum D3D10_CULL_MODE - { D3D10_CULL_NONE = 1, - D3D10_CULL_FRONT = 2, - D3D10_CULL_BACK = 3 - } D3D10_CULL_MODE; - -typedef -enum D3D10_FRONT_WINDING - { D3D10_FRONT_CW = 1, - D3D10_FRONT_CCW = 2 - } D3D10_FRONT_WINDING; - -typedef struct D3D10_VERTEX_CACHE_DESC - { - UINT Pattern; - UINT OptMethod; - UINT CacheSize; - UINT MagicNumber; - } D3D10_VERTEX_CACHE_DESC; - -typedef struct D3D10_SO_DECLARATION_ENTRY - { - LPCWSTR SemanticName; - UINT SemanticIndex; - BYTE StartComponent; - BYTE ComponentCount; - BYTE OutputSlot; - } D3D10_SO_DECLARATION_ENTRY; - -typedef struct D3D10_VIEWPORT - { - FLOAT TopLeftX; - FLOAT TopLeftY; - FLOAT Width; - FLOAT Height; - FLOAT MinDepth; - FLOAT MaxDepth; - } D3D10_VIEWPORT; - -typedef -enum D3D10_RESOURCE - { D3D10_RESOURCE_BUFFER = 1, - D3D10_RESOURCE_TEXTURE1D = 2, - D3D10_RESOURCE_TEXTURE2D = 3, - D3D10_RESOURCE_TEXTURE3D = 4, - D3D10_RESOURCE_TEXTURECUBE = 5 - } D3D10_RESOURCE; - -typedef -enum D3D10_USAGE - { D3D10_USAGE_DEFAULT = 0, - D3D10_USAGE_IMMUTABLE = 1, - D3D10_USAGE_DYNAMIC = 2, - D3D10_USAGE_STAGING = 3 - } D3D10_USAGE; - -typedef -enum D3D10_BIND_FLAG - { D3D10_BIND_VERTEX_BUFFER = 0x1L, - D3D10_BIND_INDEX_BUFFER = 0x2L, - D3D10_BIND_CONSTANT_BUFFER = 0x4L, - D3D10_BIND_SHADER_RESOURCE = 0x8L, - D3D10_BIND_STREAM_OUTPUT = 0x10L, - D3D10_BIND_RENDER_TARGET = 0x20L, - D3D10_BIND_DEPTH_STENCIL = 0x40L - } D3D10_BIND_FLAG; - -typedef -enum D3D10_CPU_ACCESS_FLAG - { D3D10_CPU_ACCESS_WRITE = 0x10000L, - D3D10_CPU_ACCESS_READ = 0x20000L - } D3D10_CPU_ACCESS_FLAG; - -typedef -enum D3D10_RESOURCE_MISC_FLAG - { D3D10_RESOURCE_MISC_GENERATE_MIPS = 0x1L, - D3D10_RESOURCE_MISC_COPY_DESTINATION = 0x2L - } D3D10_RESOURCE_MISC_FLAG; - -typedef -enum D3D10_MAP - { D3D10_MAP_READ = 1, - D3D10_MAP_WRITE = 2, - D3D10_MAP_READ_WRITE = 3, - D3D10_MAP_WRITE_DISCARD = 4, - D3D10_MAP_WRITE_NO_OVERWRITE = 5 - } D3D10_MAP; - -typedef -enum D3D10_MAP_FLAG - { D3D10_MAP_FLAG_DO_NOT_WAIT = 0x100000L - } D3D10_MAP_FLAG; - -typedef -enum D3D10_RAISE_FLAG - { D3D10_RAISE_FLAG_DRIVER_INTERNAL_ERROR = 0x1L - } D3D10_RAISE_FLAG; - -#define D3D10_BUFFEROFFSET_APPEND ( 0xffffffffL ) - -typedef -enum D3D10_CLEAR_FLAG - { D3D10_CLEAR_DEPTH = 0x1L, - D3D10_CLEAR_STENCIL = 0x2L - } D3D10_CLEAR_FLAG; - -typedef RECT D3D10_RECT; - -typedef struct D3D10_BOX - { - UINT left; - UINT top; - UINT front; - UINT right; - UINT bottom; - UINT back; - } D3D10_BOX; - - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0000_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0000_v0_0_s_ifspec; - -#ifndef __ID3D10DeviceChild_INTERFACE_DEFINED__ -#define __ID3D10DeviceChild_INTERFACE_DEFINED__ - -/* interface ID3D10DeviceChild */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10DeviceChild; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C00-342C-4106-A19F-4F2704F689F0") - ID3D10DeviceChild : public IUnknown - { - public: - virtual void STDMETHODCALLTYPE GetDevice( - /* [retval][out] */ ID3D10Device **ppDevice) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetPrivateData( - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetPrivateData( - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10DeviceChildVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10DeviceChild * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10DeviceChild * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10DeviceChild * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10DeviceChild * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10DeviceChild * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10DeviceChild * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10DeviceChild * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - END_INTERFACE - } ID3D10DeviceChildVtbl; - - interface ID3D10DeviceChild - { - CONST_VTBL struct ID3D10DeviceChildVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10DeviceChild_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10DeviceChild_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10DeviceChild_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10DeviceChild_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10DeviceChild_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10DeviceChild_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10DeviceChild_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10DeviceChild_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0001 */ -/* [local] */ - -typedef -enum D3D10_COMPARISON_FUNC - { D3D10_COMPARISON_NEVER = 1, - D3D10_COMPARISON_LESS = 2, - D3D10_COMPARISON_EQUAL = 3, - D3D10_COMPARISON_LESS_EQUAL = 4, - D3D10_COMPARISON_GREATER = 5, - D3D10_COMPARISON_NOT_EQUAL = 6, - D3D10_COMPARISON_GREATER_EQUAL = 7, - D3D10_COMPARISON_ALWAYS = 8 - } D3D10_COMPARISON_FUNC; - -typedef -enum D3D10_DEPTH_WRITE_MASK - { D3D10_DEPTH_WRITE_MASK_ZERO = 0, - D3D10_DEPTH_WRITE_MASK_ALL = 1 - } D3D10_DEPTH_WRITE_MASK; - -typedef -enum D3D10_STENCIL_OP - { D3D10_STENCIL_OP_KEEP = 1, - D3D10_STENCIL_OP_ZERO = 2, - D3D10_STENCIL_OP_REPLACE = 3, - D3D10_STENCIL_OP_INCR_SAT = 4, - D3D10_STENCIL_OP_DECR_SAT = 5, - D3D10_STENCIL_OP_INVERT = 6, - D3D10_STENCIL_OP_INCR = 7, - D3D10_STENCIL_OP_DECR = 8 - } D3D10_STENCIL_OP; - -typedef struct D3D10_DEPTH_STENCILOP_DESC - { - D3D10_STENCIL_OP StencilFailOp; - D3D10_STENCIL_OP StencilDepthFailOp; - D3D10_STENCIL_OP StencilPassOp; - D3D10_COMPARISON_FUNC StencilFunc; - } D3D10_DEPTH_STENCILOP_DESC; - -typedef struct D3D10_DEPTH_STENCIL_DESC - { - BOOL DepthEnable; - D3D10_DEPTH_WRITE_MASK DepthWriteMask; - D3D10_COMPARISON_FUNC DepthFunc; - BOOL StencilEnable; - UINT8 StencilReadMask; - UINT8 StencilWriteMask; - D3D10_DEPTH_STENCILOP_DESC FrontFace; - D3D10_DEPTH_STENCILOP_DESC BackFace; - } D3D10_DEPTH_STENCIL_DESC; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0001_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0001_v0_0_s_ifspec; - -#ifndef __ID3D10DepthStencilState_INTERFACE_DEFINED__ -#define __ID3D10DepthStencilState_INTERFACE_DEFINED__ - -/* interface ID3D10DepthStencilState */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10DepthStencilState; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("2B4B1CC8-A4AD-41f8-8322-CA86FC3EC675") - ID3D10DepthStencilState : public ID3D10DeviceChild - { - public: - virtual void STDMETHODCALLTYPE GetDesc( - /* [retval][out] */ D3D10_DEPTH_STENCIL_DESC *pDesc) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10DepthStencilStateVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10DepthStencilState * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10DepthStencilState * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10DepthStencilState * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10DepthStencilState * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10DepthStencilState * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10DepthStencilState * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10DepthStencilState * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *GetDesc )( - ID3D10DepthStencilState * This, - /* [retval][out] */ D3D10_DEPTH_STENCIL_DESC *pDesc); - - END_INTERFACE - } ID3D10DepthStencilStateVtbl; - - interface ID3D10DepthStencilState - { - CONST_VTBL struct ID3D10DepthStencilStateVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10DepthStencilState_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10DepthStencilState_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10DepthStencilState_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10DepthStencilState_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10DepthStencilState_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10DepthStencilState_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10DepthStencilState_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10DepthStencilState_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10DepthStencilState_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0002 */ -/* [local] */ - -typedef -enum D3D10_BLEND - { D3D10_BLEND_ZERO = 1, - D3D10_BLEND_ONE = 2, - D3D10_BLEND_SRC_COLOR = 3, - D3D10_BLEND_INV_SRC_COLOR = 4, - D3D10_BLEND_SRC_ALPHA = 5, - D3D10_BLEND_INV_SRC_ALPHA = 6, - D3D10_BLEND_DEST_ALPHA = 7, - D3D10_BLEND_INV_DEST_ALPHA = 8, - D3D10_BLEND_DEST_COLOR = 9, - D3D10_BLEND_INV_DEST_COLOR = 10, - D3D10_BLEND_SRC_ALPHA_SAT = 11, - D3D10_BLEND_BLEND_FACTOR = 14, - D3D10_BLEND_INV_BLEND_FACTOR = 15, - D3D10_BLEND_SRC1_COLOR = 16, - D3D10_BLEND_INV_SRC1_COLOR = 17, - D3D10_BLEND_SRC1_ALPHA = 18, - D3D10_BLEND_INV_SRC1_ALPHA = 19 - } D3D10_BLEND; - -typedef -enum D3D10_BLEND_OP - { D3D10_BLEND_OP_ADD = 1, - D3D10_BLEND_OP_SUBTRACT = 2, - D3D10_BLEND_OP_REV_SUBTRACT = 3, - D3D10_BLEND_OP_MIN = 4, - D3D10_BLEND_OP_MAX = 5 - } D3D10_BLEND_OP; - -typedef -enum D3D10_COLOR_WRITE_ENABLE - { D3D10_COLOR_WRITE_ENABLE_RED = 1, - D3D10_COLOR_WRITE_ENABLE_GREEN = 2, - D3D10_COLOR_WRITE_ENABLE_BLUE = 4, - D3D10_COLOR_WRITE_ENABLE_ALPHA = 8, - D3D10_COLOR_WRITE_ENABLE_ALL = ( ( ( D3D10_COLOR_WRITE_ENABLE_RED | D3D10_COLOR_WRITE_ENABLE_GREEN ) | D3D10_COLOR_WRITE_ENABLE_BLUE ) | D3D10_COLOR_WRITE_ENABLE_ALPHA ) - } D3D10_COLOR_WRITE_ENABLE; - -typedef struct D3D10_BLEND_DESC - { - BOOL AlphaToCoverageEnable; - BOOL BlendEnable[ 8 ]; - D3D10_BLEND SrcBlend; - D3D10_BLEND DestBlend; - D3D10_BLEND_OP BlendOp; - D3D10_BLEND SrcBlendAlpha; - D3D10_BLEND DestBlendAlpha; - D3D10_BLEND_OP BlendOpAlpha; - UINT8 RenderTargetWriteMask[ 8 ]; - } D3D10_BLEND_DESC; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0002_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0002_v0_0_s_ifspec; - -#ifndef __ID3D10BlendState_INTERFACE_DEFINED__ -#define __ID3D10BlendState_INTERFACE_DEFINED__ - -/* interface ID3D10BlendState */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10BlendState; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("EDAD8D19-8A35-4d6d-8566-2EA276CDE161") - ID3D10BlendState : public ID3D10DeviceChild - { - public: - virtual void STDMETHODCALLTYPE GetDesc( - /* [retval][out] */ D3D10_BLEND_DESC *pDesc) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10BlendStateVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10BlendState * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10BlendState * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10BlendState * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10BlendState * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10BlendState * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10BlendState * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10BlendState * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *GetDesc )( - ID3D10BlendState * This, - /* [retval][out] */ D3D10_BLEND_DESC *pDesc); - - END_INTERFACE - } ID3D10BlendStateVtbl; - - interface ID3D10BlendState - { - CONST_VTBL struct ID3D10BlendStateVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10BlendState_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10BlendState_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10BlendState_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10BlendState_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10BlendState_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10BlendState_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10BlendState_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10BlendState_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10BlendState_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0003 */ -/* [local] */ - -typedef struct D3D10_RASTERIZER_DESC - { - D3D10_FILL_MODE FillMode; - D3D10_CULL_MODE CullMode; - BOOL FrontCounterClockwise; - INT DepthBias; - FLOAT DepthBiasClamp; - FLOAT SlopeScaledDepthBias; - BOOL DepthClipEnable; - BOOL ScissorEnable; - BOOL MultisampleEnable; - BOOL AntialiasedLineEnable; - } D3D10_RASTERIZER_DESC; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0003_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0003_v0_0_s_ifspec; - -#ifndef __ID3D10RasterizerState_INTERFACE_DEFINED__ -#define __ID3D10RasterizerState_INTERFACE_DEFINED__ - -/* interface ID3D10RasterizerState */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10RasterizerState; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("A2A07292-89AF-4345-BE2E-C53D9FBB6E9F") - ID3D10RasterizerState : public ID3D10DeviceChild - { - public: - virtual void STDMETHODCALLTYPE GetDesc( - /* [retval][out] */ D3D10_RASTERIZER_DESC *pDesc) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10RasterizerStateVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10RasterizerState * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10RasterizerState * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10RasterizerState * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10RasterizerState * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10RasterizerState * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10RasterizerState * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10RasterizerState * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *GetDesc )( - ID3D10RasterizerState * This, - /* [retval][out] */ D3D10_RASTERIZER_DESC *pDesc); - - END_INTERFACE - } ID3D10RasterizerStateVtbl; - - interface ID3D10RasterizerState - { - CONST_VTBL struct ID3D10RasterizerStateVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10RasterizerState_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10RasterizerState_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10RasterizerState_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10RasterizerState_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10RasterizerState_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10RasterizerState_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10RasterizerState_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10RasterizerState_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10RasterizerState_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0004 */ -/* [local] */ - -#if !defined( D3D10_NO_HELPERS ) && defined( __cplusplus ) -inline UINT D3D10CalcSubresource( UINT MipSlice, UINT ArraySlice, UINT MipLevels ) -{ return MipSlice + ArraySlice * MipLevels; } -#endif -typedef struct D3D10_SUBRESOURCE_UP - { - const void *pSysMem; - SIZE_T SysMemPitch; - SIZE_T SysMemSlicePitch; - } D3D10_SUBRESOURCE_UP; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0004_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0004_v0_0_s_ifspec; - -#ifndef __ID3D10Resource_INTERFACE_DEFINED__ -#define __ID3D10Resource_INTERFACE_DEFINED__ - -/* interface ID3D10Resource */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10Resource; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C01-342C-4106-A19F-4F2704F689F0") - ID3D10Resource : public ID3D10DeviceChild - { - public: - virtual void STDMETHODCALLTYPE CopySubresourceRegion( - /* [in] */ UINT DstSubresource, - /* [in] */ SIZE_T DstX, - /* [in] */ SIZE_T DstY, - /* [in] */ SIZE_T DstZ, - /* [in] */ ID3D10Resource *pSrcResource, - /* [in] */ UINT SrcSubresource, - /* [in] */ const D3D10_BOX *pSrcBox) = 0; - - virtual void STDMETHODCALLTYPE CopyResource( - /* [in] */ ID3D10Resource *pSrcResource) = 0; - - virtual void STDMETHODCALLTYPE UpdateSubresource( - /* [in] */ UINT DstSubresource, - /* [in] */ const D3D10_BOX *pDstBox, - /* [in] */ const void *pSrcData, - /* [in] */ SIZE_T SrcRowPitch, - /* [in] */ SIZE_T SrcDepthPitch) = 0; - - virtual void STDMETHODCALLTYPE GetType( - /* [out] */ D3D10_RESOURCE *rType) = 0; - - virtual void STDMETHODCALLTYPE SetEvictionPriority( - /* [in] */ UINT EvictionPriority) = 0; - - virtual UINT STDMETHODCALLTYPE GetEvictionPriority( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10ResourceVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10Resource * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10Resource * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10Resource * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10Resource * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10Resource * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10Resource * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10Resource * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *CopySubresourceRegion )( - ID3D10Resource * This, - /* [in] */ UINT DstSubresource, - /* [in] */ SIZE_T DstX, - /* [in] */ SIZE_T DstY, - /* [in] */ SIZE_T DstZ, - /* [in] */ ID3D10Resource *pSrcResource, - /* [in] */ UINT SrcSubresource, - /* [in] */ const D3D10_BOX *pSrcBox); - - void ( STDMETHODCALLTYPE *CopyResource )( - ID3D10Resource * This, - /* [in] */ ID3D10Resource *pSrcResource); - - void ( STDMETHODCALLTYPE *UpdateSubresource )( - ID3D10Resource * This, - /* [in] */ UINT DstSubresource, - /* [in] */ const D3D10_BOX *pDstBox, - /* [in] */ const void *pSrcData, - /* [in] */ SIZE_T SrcRowPitch, - /* [in] */ SIZE_T SrcDepthPitch); - - void ( STDMETHODCALLTYPE *GetType )( - ID3D10Resource * This, - /* [out] */ D3D10_RESOURCE *rType); - - void ( STDMETHODCALLTYPE *SetEvictionPriority )( - ID3D10Resource * This, - /* [in] */ UINT EvictionPriority); - - UINT ( STDMETHODCALLTYPE *GetEvictionPriority )( - ID3D10Resource * This); - - END_INTERFACE - } ID3D10ResourceVtbl; - - interface ID3D10Resource - { - CONST_VTBL struct ID3D10ResourceVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10Resource_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10Resource_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10Resource_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10Resource_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10Resource_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10Resource_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10Resource_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10Resource_CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) \ - ( (This)->lpVtbl -> CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) ) - -#define ID3D10Resource_CopyResource(This,pSrcResource) \ - ( (This)->lpVtbl -> CopyResource(This,pSrcResource) ) - -#define ID3D10Resource_UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ - ( (This)->lpVtbl -> UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) - -#define ID3D10Resource_GetType(This,rType) \ - ( (This)->lpVtbl -> GetType(This,rType) ) - -#define ID3D10Resource_SetEvictionPriority(This,EvictionPriority) \ - ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) - -#define ID3D10Resource_GetEvictionPriority(This) \ - ( (This)->lpVtbl -> GetEvictionPriority(This) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10Resource_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0005 */ -/* [local] */ - -typedef struct D3D10_BUFFER_DESC - { - SIZE_T ByteWidth; - D3D10_USAGE Usage; - UINT BindFlags; - UINT CPUAccessFlags; - UINT MiscFlags; - } D3D10_BUFFER_DESC; - -#if !defined( D3D10_NO_HELPERS ) && defined( __cplusplus ) -struct CD3D10_BUFFER_DESC : public D3D10_BUFFER_DESC -{ - CD3D10_BUFFER_DESC() - {} - explicit CD3D10_BUFFER_DESC( const D3D10_BUFFER_DESC& o ) : - D3D10_BUFFER_DESC( o ) - {} - explicit CD3D10_BUFFER_DESC( - SIZE_T byteWidth, - UINT bindFlags, - D3D10_USAGE usage = D3D10_USAGE_DEFAULT, - UINT cpuaccessFlags = 0, - UINT miscFlags = 0 ) - { - ByteWidth = byteWidth; - Usage = usage; - BindFlags = bindFlags; - CPUAccessFlags = cpuaccessFlags ; - MiscFlags = miscFlags; - } - ~CD3D10_BUFFER_DESC() {} - operator const D3D10_BUFFER_DESC&() const { return *this; } -}; -#endif - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0005_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0005_v0_0_s_ifspec; - -#ifndef __ID3D10Buffer_INTERFACE_DEFINED__ -#define __ID3D10Buffer_INTERFACE_DEFINED__ - -/* interface ID3D10Buffer */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10Buffer; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C02-342C-4106-A19F-4F2704F689F0") - ID3D10Buffer : public ID3D10Resource - { - public: - virtual HRESULT STDMETHODCALLTYPE Map( - /* [in] */ D3D10_MAP MapType, - /* [in] */ UINT Flags, - /* [out] */ void **ppData) = 0; - - virtual void STDMETHODCALLTYPE Unmap( void) = 0; - - virtual void STDMETHODCALLTYPE GetDesc( - /* [retval][out] */ D3D10_BUFFER_DESC *pDesc) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10BufferVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10Buffer * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10Buffer * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10Buffer * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10Buffer * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10Buffer * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10Buffer * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10Buffer * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *CopySubresourceRegion )( - ID3D10Buffer * This, - /* [in] */ UINT DstSubresource, - /* [in] */ SIZE_T DstX, - /* [in] */ SIZE_T DstY, - /* [in] */ SIZE_T DstZ, - /* [in] */ ID3D10Resource *pSrcResource, - /* [in] */ UINT SrcSubresource, - /* [in] */ const D3D10_BOX *pSrcBox); - - void ( STDMETHODCALLTYPE *CopyResource )( - ID3D10Buffer * This, - /* [in] */ ID3D10Resource *pSrcResource); - - void ( STDMETHODCALLTYPE *UpdateSubresource )( - ID3D10Buffer * This, - /* [in] */ UINT DstSubresource, - /* [in] */ const D3D10_BOX *pDstBox, - /* [in] */ const void *pSrcData, - /* [in] */ SIZE_T SrcRowPitch, - /* [in] */ SIZE_T SrcDepthPitch); - - void ( STDMETHODCALLTYPE *GetType )( - ID3D10Buffer * This, - /* [out] */ D3D10_RESOURCE *rType); - - void ( STDMETHODCALLTYPE *SetEvictionPriority )( - ID3D10Buffer * This, - /* [in] */ UINT EvictionPriority); - - UINT ( STDMETHODCALLTYPE *GetEvictionPriority )( - ID3D10Buffer * This); - - HRESULT ( STDMETHODCALLTYPE *Map )( - ID3D10Buffer * This, - /* [in] */ D3D10_MAP MapType, - /* [in] */ UINT Flags, - /* [out] */ void **ppData); - - void ( STDMETHODCALLTYPE *Unmap )( - ID3D10Buffer * This); - - void ( STDMETHODCALLTYPE *GetDesc )( - ID3D10Buffer * This, - /* [retval][out] */ D3D10_BUFFER_DESC *pDesc); - - END_INTERFACE - } ID3D10BufferVtbl; - - interface ID3D10Buffer - { - CONST_VTBL struct ID3D10BufferVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10Buffer_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10Buffer_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10Buffer_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10Buffer_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10Buffer_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10Buffer_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10Buffer_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10Buffer_CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) \ - ( (This)->lpVtbl -> CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) ) - -#define ID3D10Buffer_CopyResource(This,pSrcResource) \ - ( (This)->lpVtbl -> CopyResource(This,pSrcResource) ) - -#define ID3D10Buffer_UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ - ( (This)->lpVtbl -> UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) - -#define ID3D10Buffer_GetType(This,rType) \ - ( (This)->lpVtbl -> GetType(This,rType) ) - -#define ID3D10Buffer_SetEvictionPriority(This,EvictionPriority) \ - ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) - -#define ID3D10Buffer_GetEvictionPriority(This) \ - ( (This)->lpVtbl -> GetEvictionPriority(This) ) - - -#define ID3D10Buffer_Map(This,MapType,Flags,ppData) \ - ( (This)->lpVtbl -> Map(This,MapType,Flags,ppData) ) - -#define ID3D10Buffer_Unmap(This) \ - ( (This)->lpVtbl -> Unmap(This) ) - -#define ID3D10Buffer_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10Buffer_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0006 */ -/* [local] */ - -typedef struct D3D10_TEXTURE1D_DESC - { - SIZE_T Width; - UINT MipLevels; - UINT ArraySize; - DXGI_FORMAT Format; - DXGI_SAMPLE_DESC SampleDesc; - D3D10_USAGE Usage; - UINT BindFlags; - UINT CPUAccessFlags; - UINT MiscFlags; - } D3D10_TEXTURE1D_DESC; - -#if !defined( D3D10_NO_HELPERS ) && defined( __cplusplus ) -struct CD3D10_TEXTURE1D_DESC : public D3D10_TEXTURE1D_DESC -{ - CD3D10_TEXTURE1D_DESC() - {} - explicit CD3D10_TEXTURE1D_DESC( const D3D10_TEXTURE1D_DESC& o ) : - D3D10_TEXTURE1D_DESC( o ) - {} - explicit CD3D10_TEXTURE1D_DESC( - DXGI_FORMAT format, - SIZE_T width, - UINT arraySize = 1, - UINT mipLevels = 0, - UINT bindFlags = D3D10_BIND_SHADER_RESOURCE, - D3D10_USAGE usage = D3D10_USAGE_DEFAULT, - UINT cpuaccessFlags= 0, - UINT sampleCount = 1, - UINT sampleQuality = 0, - UINT miscFlags = 0 ) - { - Width = width; - MipLevels = mipLevels; - ArraySize = arraySize; - Format = format; - SampleDesc.Count = sampleCount; - SampleDesc.Quality = sampleQuality; - Usage = usage; - BindFlags = bindFlags; - CPUAccessFlags = cpuaccessFlags; - MiscFlags = miscFlags; - } - ~CD3D10_TEXTURE1D_DESC() {} - operator const D3D10_TEXTURE1D_DESC&() const { return *this; } -}; -#endif - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0006_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0006_v0_0_s_ifspec; - -#ifndef __ID3D10Texture1D_INTERFACE_DEFINED__ -#define __ID3D10Texture1D_INTERFACE_DEFINED__ - -/* interface ID3D10Texture1D */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10Texture1D; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C03-342C-4106-A19F-4F2704F689F0") - ID3D10Texture1D : public ID3D10Resource - { - public: - virtual HRESULT STDMETHODCALLTYPE Map( - /* [in] */ UINT Subresource, - /* [in] */ D3D10_MAP MapType, - /* [in] */ UINT Flags, - /* [out] */ void **ppData) = 0; - - virtual void STDMETHODCALLTYPE Unmap( - /* [in] */ UINT Subresource) = 0; - - virtual void STDMETHODCALLTYPE GetDesc( - /* [retval][out] */ D3D10_TEXTURE1D_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetMultisampleResolveFormat( - /* [in] */ DXGI_FORMAT Format) = 0; - - virtual DXGI_FORMAT STDMETHODCALLTYPE GetMultisampleResolveFormat( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10Texture1DVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10Texture1D * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10Texture1D * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10Texture1D * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10Texture1D * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10Texture1D * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10Texture1D * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10Texture1D * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *CopySubresourceRegion )( - ID3D10Texture1D * This, - /* [in] */ UINT DstSubresource, - /* [in] */ SIZE_T DstX, - /* [in] */ SIZE_T DstY, - /* [in] */ SIZE_T DstZ, - /* [in] */ ID3D10Resource *pSrcResource, - /* [in] */ UINT SrcSubresource, - /* [in] */ const D3D10_BOX *pSrcBox); - - void ( STDMETHODCALLTYPE *CopyResource )( - ID3D10Texture1D * This, - /* [in] */ ID3D10Resource *pSrcResource); - - void ( STDMETHODCALLTYPE *UpdateSubresource )( - ID3D10Texture1D * This, - /* [in] */ UINT DstSubresource, - /* [in] */ const D3D10_BOX *pDstBox, - /* [in] */ const void *pSrcData, - /* [in] */ SIZE_T SrcRowPitch, - /* [in] */ SIZE_T SrcDepthPitch); - - void ( STDMETHODCALLTYPE *GetType )( - ID3D10Texture1D * This, - /* [out] */ D3D10_RESOURCE *rType); - - void ( STDMETHODCALLTYPE *SetEvictionPriority )( - ID3D10Texture1D * This, - /* [in] */ UINT EvictionPriority); - - UINT ( STDMETHODCALLTYPE *GetEvictionPriority )( - ID3D10Texture1D * This); - - HRESULT ( STDMETHODCALLTYPE *Map )( - ID3D10Texture1D * This, - /* [in] */ UINT Subresource, - /* [in] */ D3D10_MAP MapType, - /* [in] */ UINT Flags, - /* [out] */ void **ppData); - - void ( STDMETHODCALLTYPE *Unmap )( - ID3D10Texture1D * This, - /* [in] */ UINT Subresource); - - void ( STDMETHODCALLTYPE *GetDesc )( - ID3D10Texture1D * This, - /* [retval][out] */ D3D10_TEXTURE1D_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *SetMultisampleResolveFormat )( - ID3D10Texture1D * This, - /* [in] */ DXGI_FORMAT Format); - - DXGI_FORMAT ( STDMETHODCALLTYPE *GetMultisampleResolveFormat )( - ID3D10Texture1D * This); - - END_INTERFACE - } ID3D10Texture1DVtbl; - - interface ID3D10Texture1D - { - CONST_VTBL struct ID3D10Texture1DVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10Texture1D_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10Texture1D_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10Texture1D_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10Texture1D_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10Texture1D_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10Texture1D_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10Texture1D_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10Texture1D_CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) \ - ( (This)->lpVtbl -> CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) ) - -#define ID3D10Texture1D_CopyResource(This,pSrcResource) \ - ( (This)->lpVtbl -> CopyResource(This,pSrcResource) ) - -#define ID3D10Texture1D_UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ - ( (This)->lpVtbl -> UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) - -#define ID3D10Texture1D_GetType(This,rType) \ - ( (This)->lpVtbl -> GetType(This,rType) ) - -#define ID3D10Texture1D_SetEvictionPriority(This,EvictionPriority) \ - ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) - -#define ID3D10Texture1D_GetEvictionPriority(This) \ - ( (This)->lpVtbl -> GetEvictionPriority(This) ) - - -#define ID3D10Texture1D_Map(This,Subresource,MapType,Flags,ppData) \ - ( (This)->lpVtbl -> Map(This,Subresource,MapType,Flags,ppData) ) - -#define ID3D10Texture1D_Unmap(This,Subresource) \ - ( (This)->lpVtbl -> Unmap(This,Subresource) ) - -#define ID3D10Texture1D_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define ID3D10Texture1D_SetMultisampleResolveFormat(This,Format) \ - ( (This)->lpVtbl -> SetMultisampleResolveFormat(This,Format) ) - -#define ID3D10Texture1D_GetMultisampleResolveFormat(This) \ - ( (This)->lpVtbl -> GetMultisampleResolveFormat(This) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10Texture1D_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0007 */ -/* [local] */ - -typedef struct D3D10_TEXTURE2D_DESC - { - SIZE_T Width; - SIZE_T Height; - UINT MipLevels; - UINT ArraySize; - DXGI_FORMAT Format; - DXGI_SAMPLE_DESC SampleDesc; - D3D10_USAGE Usage; - UINT BindFlags; - UINT CPUAccessFlags; - UINT MiscFlags; - } D3D10_TEXTURE2D_DESC; - -#if !defined( D3D10_NO_HELPERS ) && defined( __cplusplus ) -struct CD3D10_TEXTURE2D_DESC : public D3D10_TEXTURE2D_DESC -{ - CD3D10_TEXTURE2D_DESC() - {} - explicit CD3D10_TEXTURE2D_DESC( const D3D10_TEXTURE2D_DESC& o ) : - D3D10_TEXTURE2D_DESC( o ) - {} - explicit CD3D10_TEXTURE2D_DESC( - DXGI_FORMAT format, - SIZE_T width, - SIZE_T height, - UINT arraySize = 1, - UINT mipLevels = 0, - UINT bindFlags = D3D10_BIND_SHADER_RESOURCE, - D3D10_USAGE usage = D3D10_USAGE_DEFAULT, - UINT cpuaccessFlags = 0, - UINT sampleCount = 1, - UINT sampleQuality = 0, - UINT miscFlags = 0 ) - { - Width = width; - Height = height; - MipLevels = mipLevels; - ArraySize = arraySize; - Format = format; - SampleDesc.Count = sampleCount; - SampleDesc.Quality = sampleQuality; - Usage = usage; - BindFlags = bindFlags; - CPUAccessFlags = cpuaccessFlags; - MiscFlags = miscFlags; - } - ~CD3D10_TEXTURE2D_DESC() {} - operator const D3D10_TEXTURE2D_DESC&() const { return *this; } -}; -#endif -typedef struct D3D10_MAPPED_TEXTURE2D - { - void *pData; - SIZE_T RowPitch; - } D3D10_MAPPED_TEXTURE2D; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0007_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0007_v0_0_s_ifspec; - -#ifndef __ID3D10Texture2D_INTERFACE_DEFINED__ -#define __ID3D10Texture2D_INTERFACE_DEFINED__ - -/* interface ID3D10Texture2D */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10Texture2D; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C04-342C-4106-A19F-4F2704F689F0") - ID3D10Texture2D : public ID3D10Resource - { - public: - virtual HRESULT STDMETHODCALLTYPE Map( - /* [in] */ UINT Subresource, - /* [in] */ D3D10_MAP MapType, - /* [in] */ UINT Flags, - /* [out] */ D3D10_MAPPED_TEXTURE2D *pMappedTex2D) = 0; - - virtual void STDMETHODCALLTYPE Unmap( - /* [in] */ UINT Subresource) = 0; - - virtual void STDMETHODCALLTYPE GetDesc( - /* [retval][out] */ D3D10_TEXTURE2D_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetMultisampleResolveFormat( - /* [in] */ DXGI_FORMAT Format) = 0; - - virtual DXGI_FORMAT STDMETHODCALLTYPE GetMultisampleResolveFormat( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10Texture2DVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10Texture2D * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10Texture2D * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10Texture2D * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10Texture2D * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10Texture2D * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10Texture2D * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10Texture2D * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *CopySubresourceRegion )( - ID3D10Texture2D * This, - /* [in] */ UINT DstSubresource, - /* [in] */ SIZE_T DstX, - /* [in] */ SIZE_T DstY, - /* [in] */ SIZE_T DstZ, - /* [in] */ ID3D10Resource *pSrcResource, - /* [in] */ UINT SrcSubresource, - /* [in] */ const D3D10_BOX *pSrcBox); - - void ( STDMETHODCALLTYPE *CopyResource )( - ID3D10Texture2D * This, - /* [in] */ ID3D10Resource *pSrcResource); - - void ( STDMETHODCALLTYPE *UpdateSubresource )( - ID3D10Texture2D * This, - /* [in] */ UINT DstSubresource, - /* [in] */ const D3D10_BOX *pDstBox, - /* [in] */ const void *pSrcData, - /* [in] */ SIZE_T SrcRowPitch, - /* [in] */ SIZE_T SrcDepthPitch); - - void ( STDMETHODCALLTYPE *GetType )( - ID3D10Texture2D * This, - /* [out] */ D3D10_RESOURCE *rType); - - void ( STDMETHODCALLTYPE *SetEvictionPriority )( - ID3D10Texture2D * This, - /* [in] */ UINT EvictionPriority); - - UINT ( STDMETHODCALLTYPE *GetEvictionPriority )( - ID3D10Texture2D * This); - - HRESULT ( STDMETHODCALLTYPE *Map )( - ID3D10Texture2D * This, - /* [in] */ UINT Subresource, - /* [in] */ D3D10_MAP MapType, - /* [in] */ UINT Flags, - /* [out] */ D3D10_MAPPED_TEXTURE2D *pMappedTex2D); - - void ( STDMETHODCALLTYPE *Unmap )( - ID3D10Texture2D * This, - /* [in] */ UINT Subresource); - - void ( STDMETHODCALLTYPE *GetDesc )( - ID3D10Texture2D * This, - /* [retval][out] */ D3D10_TEXTURE2D_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *SetMultisampleResolveFormat )( - ID3D10Texture2D * This, - /* [in] */ DXGI_FORMAT Format); - - DXGI_FORMAT ( STDMETHODCALLTYPE *GetMultisampleResolveFormat )( - ID3D10Texture2D * This); - - END_INTERFACE - } ID3D10Texture2DVtbl; - - interface ID3D10Texture2D - { - CONST_VTBL struct ID3D10Texture2DVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10Texture2D_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10Texture2D_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10Texture2D_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10Texture2D_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10Texture2D_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10Texture2D_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10Texture2D_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10Texture2D_CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) \ - ( (This)->lpVtbl -> CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) ) - -#define ID3D10Texture2D_CopyResource(This,pSrcResource) \ - ( (This)->lpVtbl -> CopyResource(This,pSrcResource) ) - -#define ID3D10Texture2D_UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ - ( (This)->lpVtbl -> UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) - -#define ID3D10Texture2D_GetType(This,rType) \ - ( (This)->lpVtbl -> GetType(This,rType) ) - -#define ID3D10Texture2D_SetEvictionPriority(This,EvictionPriority) \ - ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) - -#define ID3D10Texture2D_GetEvictionPriority(This) \ - ( (This)->lpVtbl -> GetEvictionPriority(This) ) - - -#define ID3D10Texture2D_Map(This,Subresource,MapType,Flags,pMappedTex2D) \ - ( (This)->lpVtbl -> Map(This,Subresource,MapType,Flags,pMappedTex2D) ) - -#define ID3D10Texture2D_Unmap(This,Subresource) \ - ( (This)->lpVtbl -> Unmap(This,Subresource) ) - -#define ID3D10Texture2D_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define ID3D10Texture2D_SetMultisampleResolveFormat(This,Format) \ - ( (This)->lpVtbl -> SetMultisampleResolveFormat(This,Format) ) - -#define ID3D10Texture2D_GetMultisampleResolveFormat(This) \ - ( (This)->lpVtbl -> GetMultisampleResolveFormat(This) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10Texture2D_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0008 */ -/* [local] */ - -typedef struct D3D10_TEXTURE3D_DESC - { - SIZE_T Width; - SIZE_T Height; - SIZE_T Depth; - UINT MipLevels; - DXGI_FORMAT Format; - DXGI_SAMPLE_DESC SampleDesc; - D3D10_USAGE Usage; - UINT BindFlags; - UINT CPUAccessFlags; - UINT MiscFlags; - } D3D10_TEXTURE3D_DESC; - -#if !defined( D3D10_NO_HELPERS ) && defined( __cplusplus ) -struct CD3D10_TEXTURE3D_DESC : public D3D10_TEXTURE3D_DESC -{ - CD3D10_TEXTURE3D_DESC() - {} - explicit CD3D10_TEXTURE3D_DESC( const D3D10_TEXTURE3D_DESC& o ) : - D3D10_TEXTURE3D_DESC( o ) - {} - explicit CD3D10_TEXTURE3D_DESC( - DXGI_FORMAT format, - SIZE_T width, - SIZE_T height, - SIZE_T depth, - UINT mipLevels = 0, - UINT bindFlags = D3D10_BIND_SHADER_RESOURCE, - D3D10_USAGE usage = D3D10_USAGE_DEFAULT, - UINT cpuaccessFlags = 0, - UINT sampleCount = 1, - UINT sampleQuality = 0, - UINT miscFlags = 0 ) - { - Width = width; - Height = height; - Depth = depth; - MipLevels = mipLevels; - Format = format; - SampleDesc.Count = sampleCount; - SampleDesc.Quality = sampleQuality; - Usage = usage; - BindFlags = bindFlags; - CPUAccessFlags = cpuaccessFlags; - MiscFlags = miscFlags; - } - ~CD3D10_TEXTURE3D_DESC() {} - operator const D3D10_TEXTURE3D_DESC&() const { return *this; } -}; -#endif -typedef struct D3D10_MAPPED_TEXTURE3D - { - void *pData; - SIZE_T RowPitch; - SIZE_T DepthPitch; - } D3D10_MAPPED_TEXTURE3D; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0008_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0008_v0_0_s_ifspec; - -#ifndef __ID3D10Texture3D_INTERFACE_DEFINED__ -#define __ID3D10Texture3D_INTERFACE_DEFINED__ - -/* interface ID3D10Texture3D */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10Texture3D; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C05-342C-4106-A19F-4F2704F689F0") - ID3D10Texture3D : public ID3D10Resource - { - public: - virtual HRESULT STDMETHODCALLTYPE Map( - /* [in] */ UINT Subresource, - /* [in] */ D3D10_MAP MapType, - /* [in] */ UINT Flags, - /* [out] */ D3D10_MAPPED_TEXTURE3D *pMappedTex3D) = 0; - - virtual void STDMETHODCALLTYPE Unmap( - /* [in] */ UINT Subresource) = 0; - - virtual void STDMETHODCALLTYPE GetDesc( - /* [retval][out] */ D3D10_TEXTURE3D_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetMultisampleResolveFormat( - /* [in] */ DXGI_FORMAT Format) = 0; - - virtual DXGI_FORMAT STDMETHODCALLTYPE GetMultisampleResolveFormat( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10Texture3DVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10Texture3D * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10Texture3D * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10Texture3D * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10Texture3D * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10Texture3D * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10Texture3D * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10Texture3D * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *CopySubresourceRegion )( - ID3D10Texture3D * This, - /* [in] */ UINT DstSubresource, - /* [in] */ SIZE_T DstX, - /* [in] */ SIZE_T DstY, - /* [in] */ SIZE_T DstZ, - /* [in] */ ID3D10Resource *pSrcResource, - /* [in] */ UINT SrcSubresource, - /* [in] */ const D3D10_BOX *pSrcBox); - - void ( STDMETHODCALLTYPE *CopyResource )( - ID3D10Texture3D * This, - /* [in] */ ID3D10Resource *pSrcResource); - - void ( STDMETHODCALLTYPE *UpdateSubresource )( - ID3D10Texture3D * This, - /* [in] */ UINT DstSubresource, - /* [in] */ const D3D10_BOX *pDstBox, - /* [in] */ const void *pSrcData, - /* [in] */ SIZE_T SrcRowPitch, - /* [in] */ SIZE_T SrcDepthPitch); - - void ( STDMETHODCALLTYPE *GetType )( - ID3D10Texture3D * This, - /* [out] */ D3D10_RESOURCE *rType); - - void ( STDMETHODCALLTYPE *SetEvictionPriority )( - ID3D10Texture3D * This, - /* [in] */ UINT EvictionPriority); - - UINT ( STDMETHODCALLTYPE *GetEvictionPriority )( - ID3D10Texture3D * This); - - HRESULT ( STDMETHODCALLTYPE *Map )( - ID3D10Texture3D * This, - /* [in] */ UINT Subresource, - /* [in] */ D3D10_MAP MapType, - /* [in] */ UINT Flags, - /* [out] */ D3D10_MAPPED_TEXTURE3D *pMappedTex3D); - - void ( STDMETHODCALLTYPE *Unmap )( - ID3D10Texture3D * This, - /* [in] */ UINT Subresource); - - void ( STDMETHODCALLTYPE *GetDesc )( - ID3D10Texture3D * This, - /* [retval][out] */ D3D10_TEXTURE3D_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *SetMultisampleResolveFormat )( - ID3D10Texture3D * This, - /* [in] */ DXGI_FORMAT Format); - - DXGI_FORMAT ( STDMETHODCALLTYPE *GetMultisampleResolveFormat )( - ID3D10Texture3D * This); - - END_INTERFACE - } ID3D10Texture3DVtbl; - - interface ID3D10Texture3D - { - CONST_VTBL struct ID3D10Texture3DVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10Texture3D_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10Texture3D_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10Texture3D_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10Texture3D_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10Texture3D_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10Texture3D_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10Texture3D_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10Texture3D_CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) \ - ( (This)->lpVtbl -> CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) ) - -#define ID3D10Texture3D_CopyResource(This,pSrcResource) \ - ( (This)->lpVtbl -> CopyResource(This,pSrcResource) ) - -#define ID3D10Texture3D_UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ - ( (This)->lpVtbl -> UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) - -#define ID3D10Texture3D_GetType(This,rType) \ - ( (This)->lpVtbl -> GetType(This,rType) ) - -#define ID3D10Texture3D_SetEvictionPriority(This,EvictionPriority) \ - ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) - -#define ID3D10Texture3D_GetEvictionPriority(This) \ - ( (This)->lpVtbl -> GetEvictionPriority(This) ) - - -#define ID3D10Texture3D_Map(This,Subresource,MapType,Flags,pMappedTex3D) \ - ( (This)->lpVtbl -> Map(This,Subresource,MapType,Flags,pMappedTex3D) ) - -#define ID3D10Texture3D_Unmap(This,Subresource) \ - ( (This)->lpVtbl -> Unmap(This,Subresource) ) - -#define ID3D10Texture3D_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define ID3D10Texture3D_SetMultisampleResolveFormat(This,Format) \ - ( (This)->lpVtbl -> SetMultisampleResolveFormat(This,Format) ) - -#define ID3D10Texture3D_GetMultisampleResolveFormat(This) \ - ( (This)->lpVtbl -> GetMultisampleResolveFormat(This) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10Texture3D_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0009 */ -/* [local] */ - -typedef struct D3D10_TEXTURECUBE_DESC - { - SIZE_T EdgeWidth; - UINT MipLevels; - DXGI_FORMAT Format; - DXGI_SAMPLE_DESC SampleDesc; - D3D10_USAGE Usage; - UINT BindFlags; - UINT CPUAccessFlags; - UINT MiscFlags; - } D3D10_TEXTURECUBE_DESC; - -#if !defined( D3D10_NO_HELPERS ) && defined( __cplusplus ) -struct CD3D10_TEXTURECUBE_DESC : public D3D10_TEXTURECUBE_DESC -{ - CD3D10_TEXTURECUBE_DESC() - {} - explicit CD3D10_TEXTURECUBE_DESC( const D3D10_TEXTURECUBE_DESC& o ) : - D3D10_TEXTURECUBE_DESC( o ) - {} - explicit CD3D10_TEXTURECUBE_DESC( - DXGI_FORMAT format, - SIZE_T edgeWidth, - UINT mipLevels = 0, - UINT bindFlags = D3D10_BIND_SHADER_RESOURCE, - D3D10_USAGE usage = D3D10_USAGE_DEFAULT, - UINT cpuaccessFlags = 0, - UINT sampleCount = 1, - UINT sampleQuality = 0, - UINT miscFlags = 0 ) - { - EdgeWidth = edgeWidth; - MipLevels = mipLevels; - Format = format; - SampleDesc.Count = sampleCount; - SampleDesc.Quality = sampleQuality; - Usage = usage; - BindFlags = bindFlags; - CPUAccessFlags = cpuaccessFlags; - MiscFlags = miscFlags; - } - ~CD3D10_TEXTURECUBE_DESC() {} - operator const D3D10_TEXTURECUBE_DESC&() const { return *this; } -}; -#endif - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0009_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0009_v0_0_s_ifspec; - -#ifndef __ID3D10TextureCube_INTERFACE_DEFINED__ -#define __ID3D10TextureCube_INTERFACE_DEFINED__ - -/* interface ID3D10TextureCube */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10TextureCube; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C06-342C-4106-A19F-4F2704F689F0") - ID3D10TextureCube : public ID3D10Resource - { - public: - virtual HRESULT STDMETHODCALLTYPE Map( - /* [in] */ UINT Subresource, - /* [in] */ D3D10_MAP MapType, - /* [in] */ UINT Flags, - /* [out] */ D3D10_MAPPED_TEXTURE2D *pMappedFace) = 0; - - virtual void STDMETHODCALLTYPE Unmap( - /* [in] */ UINT Subresource) = 0; - - virtual void STDMETHODCALLTYPE GetDesc( - /* [retval][out] */ D3D10_TEXTURECUBE_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetMultisampleResolveFormat( - /* [in] */ DXGI_FORMAT Format) = 0; - - virtual DXGI_FORMAT STDMETHODCALLTYPE GetMultisampleResolveFormat( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10TextureCubeVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10TextureCube * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10TextureCube * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10TextureCube * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10TextureCube * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10TextureCube * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10TextureCube * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10TextureCube * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *CopySubresourceRegion )( - ID3D10TextureCube * This, - /* [in] */ UINT DstSubresource, - /* [in] */ SIZE_T DstX, - /* [in] */ SIZE_T DstY, - /* [in] */ SIZE_T DstZ, - /* [in] */ ID3D10Resource *pSrcResource, - /* [in] */ UINT SrcSubresource, - /* [in] */ const D3D10_BOX *pSrcBox); - - void ( STDMETHODCALLTYPE *CopyResource )( - ID3D10TextureCube * This, - /* [in] */ ID3D10Resource *pSrcResource); - - void ( STDMETHODCALLTYPE *UpdateSubresource )( - ID3D10TextureCube * This, - /* [in] */ UINT DstSubresource, - /* [in] */ const D3D10_BOX *pDstBox, - /* [in] */ const void *pSrcData, - /* [in] */ SIZE_T SrcRowPitch, - /* [in] */ SIZE_T SrcDepthPitch); - - void ( STDMETHODCALLTYPE *GetType )( - ID3D10TextureCube * This, - /* [out] */ D3D10_RESOURCE *rType); - - void ( STDMETHODCALLTYPE *SetEvictionPriority )( - ID3D10TextureCube * This, - /* [in] */ UINT EvictionPriority); - - UINT ( STDMETHODCALLTYPE *GetEvictionPriority )( - ID3D10TextureCube * This); - - HRESULT ( STDMETHODCALLTYPE *Map )( - ID3D10TextureCube * This, - /* [in] */ UINT Subresource, - /* [in] */ D3D10_MAP MapType, - /* [in] */ UINT Flags, - /* [out] */ D3D10_MAPPED_TEXTURE2D *pMappedFace); - - void ( STDMETHODCALLTYPE *Unmap )( - ID3D10TextureCube * This, - /* [in] */ UINT Subresource); - - void ( STDMETHODCALLTYPE *GetDesc )( - ID3D10TextureCube * This, - /* [retval][out] */ D3D10_TEXTURECUBE_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *SetMultisampleResolveFormat )( - ID3D10TextureCube * This, - /* [in] */ DXGI_FORMAT Format); - - DXGI_FORMAT ( STDMETHODCALLTYPE *GetMultisampleResolveFormat )( - ID3D10TextureCube * This); - - END_INTERFACE - } ID3D10TextureCubeVtbl; - - interface ID3D10TextureCube - { - CONST_VTBL struct ID3D10TextureCubeVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10TextureCube_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10TextureCube_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10TextureCube_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10TextureCube_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10TextureCube_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10TextureCube_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10TextureCube_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10TextureCube_CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) \ - ( (This)->lpVtbl -> CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) ) - -#define ID3D10TextureCube_CopyResource(This,pSrcResource) \ - ( (This)->lpVtbl -> CopyResource(This,pSrcResource) ) - -#define ID3D10TextureCube_UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ - ( (This)->lpVtbl -> UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) - -#define ID3D10TextureCube_GetType(This,rType) \ - ( (This)->lpVtbl -> GetType(This,rType) ) - -#define ID3D10TextureCube_SetEvictionPriority(This,EvictionPriority) \ - ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) - -#define ID3D10TextureCube_GetEvictionPriority(This) \ - ( (This)->lpVtbl -> GetEvictionPriority(This) ) - - -#define ID3D10TextureCube_Map(This,Subresource,MapType,Flags,pMappedFace) \ - ( (This)->lpVtbl -> Map(This,Subresource,MapType,Flags,pMappedFace) ) - -#define ID3D10TextureCube_Unmap(This,Subresource) \ - ( (This)->lpVtbl -> Unmap(This,Subresource) ) - -#define ID3D10TextureCube_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define ID3D10TextureCube_SetMultisampleResolveFormat(This,Format) \ - ( (This)->lpVtbl -> SetMultisampleResolveFormat(This,Format) ) - -#define ID3D10TextureCube_GetMultisampleResolveFormat(This) \ - ( (This)->lpVtbl -> GetMultisampleResolveFormat(This) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10TextureCube_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0010 */ -/* [local] */ - -typedef -enum D3D10_TEXTURECUBE_FACE - { D3D10_TEXTURECUBE_FACE_POSITIVE_X = 0, - D3D10_TEXTURECUBE_FACE_NEGATIVE_X = 1, - D3D10_TEXTURECUBE_FACE_POSITIVE_Y = 2, - D3D10_TEXTURECUBE_FACE_NEGATIVE_Y = 3, - D3D10_TEXTURECUBE_FACE_POSITIVE_Z = 4, - D3D10_TEXTURECUBE_FACE_NEGATIVE_Z = 5 - } D3D10_TEXTURECUBE_FACE; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0010_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0010_v0_0_s_ifspec; - -#ifndef __ID3D10View_INTERFACE_DEFINED__ -#define __ID3D10View_INTERFACE_DEFINED__ - -/* interface ID3D10View */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10View; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("C902B03F-60A7-49BA-9936-2A3AB37A7E33") - ID3D10View : public ID3D10DeviceChild - { - public: - virtual void STDMETHODCALLTYPE GetResource( - /* [retval][out] */ ID3D10Resource **ppResource) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10ViewVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10View * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10View * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10View * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10View * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10View * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10View * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10View * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *GetResource )( - ID3D10View * This, - /* [retval][out] */ ID3D10Resource **ppResource); - - END_INTERFACE - } ID3D10ViewVtbl; - - interface ID3D10View - { - CONST_VTBL struct ID3D10ViewVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10View_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10View_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10View_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10View_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10View_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10View_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10View_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10View_GetResource(This,ppResource) \ - ( (This)->lpVtbl -> GetResource(This,ppResource) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10View_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0011 */ -/* [local] */ - -typedef struct D3D10_BUFFER_SRV - { - SIZE_T ElementOffset; - SIZE_T ElementWidth; - } D3D10_BUFFER_SRV; - -typedef struct D3D10_TEX1D_SRV - { - UINT MostDetailedMip; - UINT MipLevels; - UINT FirstArraySlice; - UINT ArraySize; - } D3D10_TEX1D_SRV; - -typedef struct D3D10_TEX2D_SRV - { - UINT MostDetailedMip; - UINT MipLevels; - UINT FirstArraySlice; - UINT ArraySize; - } D3D10_TEX2D_SRV; - -typedef struct D3D10_TEX3D_SRV - { - UINT MostDetailedMip; - UINT MipLevels; - } D3D10_TEX3D_SRV; - -typedef struct D3D10_TEXCUBE_SRV - { - UINT MostDetailedMip; - UINT MipLevels; - } D3D10_TEXCUBE_SRV; - -typedef struct D3D10_SHADER_RESOURCE_VIEW_DESC - { - DXGI_FORMAT Format; - D3D10_RESOURCE ResourceType; - union - { - D3D10_BUFFER_SRV Buffer; - D3D10_TEX1D_SRV Texture1D; - D3D10_TEX2D_SRV Texture2D; - D3D10_TEX3D_SRV Texture3D; - D3D10_TEXCUBE_SRV TextureCube; - } ; - } D3D10_SHADER_RESOURCE_VIEW_DESC; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0011_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0011_v0_0_s_ifspec; - -#ifndef __ID3D10ShaderResourceView_INTERFACE_DEFINED__ -#define __ID3D10ShaderResourceView_INTERFACE_DEFINED__ - -/* interface ID3D10ShaderResourceView */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10ShaderResourceView; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C07-342C-4106-A19F-4F2704F689F0") - ID3D10ShaderResourceView : public ID3D10View - { - public: - virtual void STDMETHODCALLTYPE GetDesc( - /* [retval][out] */ D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10ShaderResourceViewVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10ShaderResourceView * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10ShaderResourceView * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10ShaderResourceView * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10ShaderResourceView * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10ShaderResourceView * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10ShaderResourceView * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10ShaderResourceView * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *GetResource )( - ID3D10ShaderResourceView * This, - /* [retval][out] */ ID3D10Resource **ppResource); - - void ( STDMETHODCALLTYPE *GetDesc )( - ID3D10ShaderResourceView * This, - /* [retval][out] */ D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc); - - END_INTERFACE - } ID3D10ShaderResourceViewVtbl; - - interface ID3D10ShaderResourceView - { - CONST_VTBL struct ID3D10ShaderResourceViewVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10ShaderResourceView_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10ShaderResourceView_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10ShaderResourceView_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10ShaderResourceView_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10ShaderResourceView_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10ShaderResourceView_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10ShaderResourceView_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10ShaderResourceView_GetResource(This,ppResource) \ - ( (This)->lpVtbl -> GetResource(This,ppResource) ) - - -#define ID3D10ShaderResourceView_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10ShaderResourceView_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0012 */ -/* [local] */ - -typedef struct D3D10_BUFFER_RTV - { - SIZE_T ElementOffset; - SIZE_T ElementWidth; - } D3D10_BUFFER_RTV; - -typedef struct D3D10_TEX1D_RTV - { - UINT MipSlice; - UINT FirstArraySlice; - UINT ArraySize; - } D3D10_TEX1D_RTV; - -typedef struct D3D10_TEX2D_RTV - { - UINT MipSlice; - UINT FirstArraySlice; - UINT ArraySize; - } D3D10_TEX2D_RTV; - -typedef struct D3D10_TEX3D_RTV - { - UINT MipSlice; - UINT FirstWSlice; - UINT WSize; - } D3D10_TEX3D_RTV; - -typedef struct D3D10_TEXCUBE_RTV - { - UINT MipSlice; - UINT FirstArraySlice; - UINT ArraySize; - } D3D10_TEXCUBE_RTV; - -typedef struct D3D10_RENDER_TARGET_VIEW_DESC - { - DXGI_FORMAT Format; - D3D10_RESOURCE ResourceType; - union - { - D3D10_BUFFER_RTV Buffer; - D3D10_TEX1D_RTV Texture1D; - D3D10_TEX2D_RTV Texture2D; - D3D10_TEX3D_RTV Texture3D; - D3D10_TEXCUBE_RTV TextureCube; - } ; - } D3D10_RENDER_TARGET_VIEW_DESC; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0012_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0012_v0_0_s_ifspec; - -#ifndef __ID3D10RenderTargetView_INTERFACE_DEFINED__ -#define __ID3D10RenderTargetView_INTERFACE_DEFINED__ - -/* interface ID3D10RenderTargetView */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10RenderTargetView; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C08-342C-4106-A19F-4F2704F689F0") - ID3D10RenderTargetView : public ID3D10View - { - public: - virtual void STDMETHODCALLTYPE GetDesc( - /* [retval][out] */ D3D10_RENDER_TARGET_VIEW_DESC *pDesc) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10RenderTargetViewVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10RenderTargetView * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10RenderTargetView * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10RenderTargetView * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10RenderTargetView * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10RenderTargetView * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10RenderTargetView * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10RenderTargetView * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *GetResource )( - ID3D10RenderTargetView * This, - /* [retval][out] */ ID3D10Resource **ppResource); - - void ( STDMETHODCALLTYPE *GetDesc )( - ID3D10RenderTargetView * This, - /* [retval][out] */ D3D10_RENDER_TARGET_VIEW_DESC *pDesc); - - END_INTERFACE - } ID3D10RenderTargetViewVtbl; - - interface ID3D10RenderTargetView - { - CONST_VTBL struct ID3D10RenderTargetViewVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10RenderTargetView_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10RenderTargetView_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10RenderTargetView_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10RenderTargetView_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10RenderTargetView_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10RenderTargetView_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10RenderTargetView_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10RenderTargetView_GetResource(This,ppResource) \ - ( (This)->lpVtbl -> GetResource(This,ppResource) ) - - -#define ID3D10RenderTargetView_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10RenderTargetView_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0013 */ -/* [local] */ - -typedef struct D3D10_TEX1D_DSV - { - UINT MipSlice; - UINT FirstArraySlice; - UINT ArraySize; - } D3D10_TEX1D_DSV; - -typedef struct D3D10_TEX2D_DSV - { - UINT MipSlice; - UINT FirstArraySlice; - UINT ArraySize; - } D3D10_TEX2D_DSV; - -typedef struct D3D10_TEXCUBE_DSV - { - UINT MipSlice; - UINT FirstArraySlice; - UINT ArraySize; - } D3D10_TEXCUBE_DSV; - -typedef struct D3D10_DEPTH_STENCIL_VIEW_DESC - { - DXGI_FORMAT Format; - D3D10_RESOURCE ResourceType; - union - { - D3D10_TEX1D_DSV Texture1D; - D3D10_TEX2D_DSV Texture2D; - D3D10_TEXCUBE_DSV TextureCube; - } ; - } D3D10_DEPTH_STENCIL_VIEW_DESC; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0013_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0013_v0_0_s_ifspec; - -#ifndef __ID3D10DepthStencilView_INTERFACE_DEFINED__ -#define __ID3D10DepthStencilView_INTERFACE_DEFINED__ - -/* interface ID3D10DepthStencilView */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10DepthStencilView; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C09-342C-4106-A19F-4F2704F689F0") - ID3D10DepthStencilView : public ID3D10View - { - public: - virtual void STDMETHODCALLTYPE GetDesc( - /* [retval][out] */ D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10DepthStencilViewVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10DepthStencilView * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10DepthStencilView * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10DepthStencilView * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10DepthStencilView * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10DepthStencilView * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10DepthStencilView * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10DepthStencilView * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *GetResource )( - ID3D10DepthStencilView * This, - /* [retval][out] */ ID3D10Resource **ppResource); - - void ( STDMETHODCALLTYPE *GetDesc )( - ID3D10DepthStencilView * This, - /* [retval][out] */ D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc); - - END_INTERFACE - } ID3D10DepthStencilViewVtbl; - - interface ID3D10DepthStencilView - { - CONST_VTBL struct ID3D10DepthStencilViewVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10DepthStencilView_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10DepthStencilView_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10DepthStencilView_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10DepthStencilView_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10DepthStencilView_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10DepthStencilView_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10DepthStencilView_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10DepthStencilView_GetResource(This,ppResource) \ - ( (This)->lpVtbl -> GetResource(This,ppResource) ) - - -#define ID3D10DepthStencilView_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10DepthStencilView_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0014 */ -/* [local] */ - -typedef struct D3D10_VERTEX_SHADER_DESC - { - const BYTE *pFunction; - UINT SizeInBytes; - } D3D10_VERTEX_SHADER_DESC; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0014_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0014_v0_0_s_ifspec; - -#ifndef __ID3D10VertexShader_INTERFACE_DEFINED__ -#define __ID3D10VertexShader_INTERFACE_DEFINED__ - -/* interface ID3D10VertexShader */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10VertexShader; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C0A-342C-4106-A19F-4F2704F689F0") - ID3D10VertexShader : public ID3D10DeviceChild - { - public: - }; - -#else /* C style interface */ - - typedef struct ID3D10VertexShaderVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10VertexShader * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10VertexShader * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10VertexShader * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10VertexShader * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10VertexShader * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10VertexShader * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10VertexShader * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - END_INTERFACE - } ID3D10VertexShaderVtbl; - - interface ID3D10VertexShader - { - CONST_VTBL struct ID3D10VertexShaderVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10VertexShader_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10VertexShader_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10VertexShader_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10VertexShader_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10VertexShader_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10VertexShader_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10VertexShader_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10VertexShader_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0015 */ -/* [local] */ - -typedef struct D3D10_GEOMETRY_SHADER_DESC - { - const BYTE *pFunction; - UINT SizeInBytes; - const D3D10_SO_DECLARATION_ENTRY *pDeclaration; - SIZE_T NumElements; - UINT StreamStride; - } D3D10_GEOMETRY_SHADER_DESC; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0015_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0015_v0_0_s_ifspec; - -#ifndef __ID3D10GeometryShader_INTERFACE_DEFINED__ -#define __ID3D10GeometryShader_INTERFACE_DEFINED__ - -/* interface ID3D10GeometryShader */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10GeometryShader; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("6316BE88-54CD-4040-AB44-20461BC81F68") - ID3D10GeometryShader : public ID3D10DeviceChild - { - public: - }; - -#else /* C style interface */ - - typedef struct ID3D10GeometryShaderVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10GeometryShader * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10GeometryShader * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10GeometryShader * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10GeometryShader * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10GeometryShader * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10GeometryShader * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10GeometryShader * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - END_INTERFACE - } ID3D10GeometryShaderVtbl; - - interface ID3D10GeometryShader - { - CONST_VTBL struct ID3D10GeometryShaderVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10GeometryShader_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10GeometryShader_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10GeometryShader_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10GeometryShader_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10GeometryShader_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10GeometryShader_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10GeometryShader_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10GeometryShader_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0016 */ -/* [local] */ - -typedef struct D3D10_PIXEL_SHADER_DESC - { - const BYTE *pFunction; - UINT SizeInBytes; - } D3D10_PIXEL_SHADER_DESC; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0016_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0016_v0_0_s_ifspec; - -#ifndef __ID3D10PixelShader_INTERFACE_DEFINED__ -#define __ID3D10PixelShader_INTERFACE_DEFINED__ - -/* interface ID3D10PixelShader */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10PixelShader; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("4968B601-9D00-4cde-8346-8E7F675819B6") - ID3D10PixelShader : public ID3D10DeviceChild - { - public: - }; - -#else /* C style interface */ - - typedef struct ID3D10PixelShaderVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10PixelShader * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10PixelShader * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10PixelShader * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10PixelShader * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10PixelShader * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10PixelShader * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10PixelShader * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - END_INTERFACE - } ID3D10PixelShaderVtbl; - - interface ID3D10PixelShader - { - CONST_VTBL struct ID3D10PixelShaderVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10PixelShader_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10PixelShader_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10PixelShader_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10PixelShader_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10PixelShader_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10PixelShader_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10PixelShader_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10PixelShader_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0017 */ -/* [local] */ - -typedef struct D3D10_INPUT_LAYOUT_DESC - { - D3D10_INPUT_ELEMENT_DESC *pDeclaration; - SIZE_T NumElements; - const void *pShaderBytecodeWithInputSignature; - } D3D10_INPUT_LAYOUT_DESC; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0017_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0017_v0_0_s_ifspec; - -#ifndef __ID3D10InputLayout_INTERFACE_DEFINED__ -#define __ID3D10InputLayout_INTERFACE_DEFINED__ - -/* interface ID3D10InputLayout */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10InputLayout; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C0B-342C-4106-A19F-4F2704F689F0") - ID3D10InputLayout : public ID3D10DeviceChild - { - public: - }; - -#else /* C style interface */ - - typedef struct ID3D10InputLayoutVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10InputLayout * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10InputLayout * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10InputLayout * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10InputLayout * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10InputLayout * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10InputLayout * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10InputLayout * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - END_INTERFACE - } ID3D10InputLayoutVtbl; - - interface ID3D10InputLayout - { - CONST_VTBL struct ID3D10InputLayoutVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10InputLayout_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10InputLayout_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10InputLayout_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10InputLayout_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10InputLayout_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10InputLayout_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10InputLayout_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10InputLayout_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0018 */ -/* [local] */ - -typedef -enum D3D10_FILTER - { D3D10_FILTER_MIN_MAG_MIP_POINT = 0, - D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR = 0x1, - D3D10_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x4, - D3D10_FILTER_MIN_POINT_MAG_MIP_LINEAR = 0x5, - D3D10_FILTER_MIN_LINEAR_MAG_MIP_POINT = 0x10, - D3D10_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11, - D3D10_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x14, - D3D10_FILTER_MIN_MAG_MIP_LINEAR = 0x15, - D3D10_FILTER_ANISOTROPIC = 0x55, - D3D10_FILTER_COMPARISON_MIN_MAG_MIP_POINT = 0x80, - D3D10_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR = 0x81, - D3D10_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x84, - D3D10_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR = 0x85, - D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT = 0x90, - D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x91, - D3D10_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT = 0x94, - D3D10_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = 0x95, - D3D10_FILTER_COMPARISON_ANISOTROPIC = 0xd5, - D3D10_FILTER_TEXT_1BIT = 0x80000000 - } D3D10_FILTER; - -typedef -enum D3D10_FILTER_TYPE - { D3D10_FILTER_TYPE_POINT = 0, - D3D10_FILTER_TYPE_LINEAR = 1 - } D3D10_FILTER_TYPE; - -#define D3D10_FILTER_TYPE_MASK ( 0x3 ) - -#define D3D10_MIN_FILTER_SHIFT ( 4 ) - -#define D3D10_MAG_FILTER_SHIFT ( 2 ) - -#define D3D10_MIP_FILTER_SHIFT ( 0 ) - -#define D3D10_COMPARISON_FILTERING_BIT ( 0x80 ) - -#define D3D10_ANISOTROPIC_FILTERING_BIT ( 0x40 ) - -#define D3D10_TEXT_1BIT_BIT ( 0x80000000 ) - -#define D3D10_ENCODE_BASIC_FILTER( min, mag, mip, bComparison ) \ - ( D3D10_FILTER ) ( \ - ( ( bComparison ) ? D3D10_COMPARISON_FILTERING_BIT : 0 ) | \ - ( ( min & D3D10_FILTER_TYPE_MASK ) << D3D10_MIN_FILTER_SHIFT ) | \ - ( ( mag & D3D10_FILTER_TYPE_MASK ) << D3D10_MAG_FILTER_SHIFT ) | \ - ( ( mip & D3D10_FILTER_TYPE_MASK ) << D3D10_MIP_FILTER_SHIFT ) ) -#define D3D10_ENCODE_ANISOTROPIC_FILTER( bComparison ) \ - ( D3D10_FILTER ) ( \ - D3D10_ANISOTROPIC_FILTERING_BIT | \ - D3D10_ENCODE_BASIC_FILTER( D3D10_FILTER_TYPE_LINEAR, \ - D3D10_FILTER_TYPE_LINEAR, \ - D3D10_FILTER_TYPE_LINEAR, \ - bComparison ) ) -#define D3D10_DECODE_MIN_FILTER( d3d10Filter ) \ - (D3D10_FILTER_TYPE) \ - ( ( d3d10Filter >> D3D10_MIN_FILTER_SHIFT ) & D3D10_FILTER_TYPE_MASK ) -#define D3D10_DECODE_MAG_FILTER( d3d10Filter ) \ - (D3D10_FILTER_TYPE) \ - ( ( d3d10Filter >> D3D10_MAG_FILTER_SHIFT ) & D3D10_FILTER_TYPE_MASK ) -#define D3D10_DECODE_MIP_FILTER( d3d10Filter ) \ - (D3D10_FILTER_TYPE) \ - ( ( d3d10Filter >> D3D10_MIP_FILTER_SHIFT ) & D3D10_FILTER_TYPE_MASK ) -#define D3D10_DECODE_IS_COMPARISON_FILTER( d3d10Filter ) \ - ( d3d10Filter & D3D10_COMPARISON_FILTERING_BIT ) -#define D3D10_DECODE_IS_ANISOTROPIC_FILTER( d3d10Filter ) \ - ( ( d3d10Filter & D3D10_ANISOTROPIC_FILTERING_BIT ) && \ - ( D3D10_FILTER_TYPE_LINEAR == D3D10_DECODE_MIN_FILTER( d3d10Filter ) ) && \ - ( D3D10_FILTER_TYPE_LINEAR == D3D10_DECODE_MAG_FILTER( d3d10Filter ) ) && \ - ( D3D10_FILTER_TYPE_LINEAR == D3D10_DECODE_MIP_FILTER( d3d10Filter ) ) ) -#define D3D10_DECODE_IS_TEXT_1BIT_FILTER( d3d10Filter ) \ - ( d3d10Filter == D3D10_TEXT_1BIT_BIT ) -typedef -enum D3D10_TEXTURE_ADDRESS_MODE - { D3D10_TEXTURE_ADDRESS_WRAP = 1, - D3D10_TEXTURE_ADDRESS_MIRROR = 2, - D3D10_TEXTURE_ADDRESS_CLAMP = 3, - D3D10_TEXTURE_ADDRESS_BORDER = 4, - D3D10_TEXTURE_ADDRESS_MIRROR_ONCE = 5 - } D3D10_TEXTURE_ADDRESS_MODE; - -typedef struct D3D10_SAMPLER_DESC - { - D3D10_FILTER Filter; - D3D10_TEXTURE_ADDRESS_MODE AddressU; - D3D10_TEXTURE_ADDRESS_MODE AddressV; - D3D10_TEXTURE_ADDRESS_MODE AddressW; - FLOAT MipLODBias; - UINT MaxAnisotropy; - D3D10_COMPARISON_FUNC ComparisonFunc; - FLOAT BorderColor[ 4 ]; - FLOAT MinLOD; - FLOAT MaxLOD; - } D3D10_SAMPLER_DESC; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0018_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0018_v0_0_s_ifspec; - -#ifndef __ID3D10SamplerState_INTERFACE_DEFINED__ -#define __ID3D10SamplerState_INTERFACE_DEFINED__ - -/* interface ID3D10SamplerState */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10SamplerState; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C0C-342C-4106-A19F-4F2704F689F0") - ID3D10SamplerState : public ID3D10DeviceChild - { - public: - virtual void STDMETHODCALLTYPE GetDesc( - /* [retval][out] */ D3D10_SAMPLER_DESC *pDesc) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10SamplerStateVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10SamplerState * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10SamplerState * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10SamplerState * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10SamplerState * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10SamplerState * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10SamplerState * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10SamplerState * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *GetDesc )( - ID3D10SamplerState * This, - /* [retval][out] */ D3D10_SAMPLER_DESC *pDesc); - - END_INTERFACE - } ID3D10SamplerStateVtbl; - - interface ID3D10SamplerState - { - CONST_VTBL struct ID3D10SamplerStateVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10SamplerState_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10SamplerState_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10SamplerState_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10SamplerState_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10SamplerState_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10SamplerState_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10SamplerState_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10SamplerState_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10SamplerState_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0019 */ -/* [local] */ - -typedef -enum D3D10_FORMAT_SUPPORT - { D3D10_FORMAT_SUPPORT_BUFFER = 0x1, - D3D10_FORMAT_SUPPORT_IA_VERTEX_BUFFER = 0x2, - D3D10_FORMAT_SUPPORT_IA_INDEX_BUFFER = 0x4, - D3D10_FORMAT_SUPPORT_SO_BUFFER = 0x8, - D3D10_FORMAT_SUPPORT_TEXTURE1D = 0x10, - D3D10_FORMAT_SUPPORT_TEXTURE2D = 0x20, - D3D10_FORMAT_SUPPORT_TEXTURE3D = 0x40, - D3D10_FORMAT_SUPPORT_TEXTURECUBE = 0x80, - D3D10_FORMAT_SUPPORT_SHADER_LOAD = 0x100, - D3D10_FORMAT_SUPPORT_SHADER_SAMPLE = 0x200, - D3D10_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON = 0x400, - D3D10_FORMAT_SUPPORT_SHADER_SAMPLE_MONO_TEXT = 0x800, - D3D10_FORMAT_SUPPORT_MIP = 0x1000, - D3D10_FORMAT_SUPPORT_MIP_AUTOGEN = 0x2000, - D3D10_FORMAT_SUPPORT_RENDER_TARGET = 0x4000, - D3D10_FORMAT_SUPPORT_BLENDABLE = 0x8000, - D3D10_FORMAT_SUPPORT_DEPTH_STENCIL = 0x10000, - D3D10_FORMAT_SUPPORT_CPU_LOCKABLE = 0x20000, - D3D10_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE = 0x40000, - D3D10_FORMAT_SUPPORT_DISPLAY = 0x80000, - D3D10_FORMAT_SUPPORT_CAST_WITHIN_BIT_LAYOUT = 0x100000 - } D3D10_FORMAT_SUPPORT; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0019_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0019_v0_0_s_ifspec; - -#ifndef __ID3D10Asynchronous_INTERFACE_DEFINED__ -#define __ID3D10Asynchronous_INTERFACE_DEFINED__ - -/* interface ID3D10Asynchronous */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10Asynchronous; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C0D-342C-4106-A19F-4F2704F689F0") - ID3D10Asynchronous : public ID3D10DeviceChild - { - public: - virtual void STDMETHODCALLTYPE Begin( void) = 0; - - virtual void STDMETHODCALLTYPE End( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetData( - /* [size_is][out] */ void *pData, - /* [in] */ SIZE_T DataSize, - /* [in] */ UINT Flags) = 0; - - virtual SIZE_T STDMETHODCALLTYPE GetDataSize( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10AsynchronousVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10Asynchronous * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10Asynchronous * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10Asynchronous * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10Asynchronous * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10Asynchronous * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10Asynchronous * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10Asynchronous * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *Begin )( - ID3D10Asynchronous * This); - - void ( STDMETHODCALLTYPE *End )( - ID3D10Asynchronous * This); - - HRESULT ( STDMETHODCALLTYPE *GetData )( - ID3D10Asynchronous * This, - /* [size_is][out] */ void *pData, - /* [in] */ SIZE_T DataSize, - /* [in] */ UINT Flags); - - SIZE_T ( STDMETHODCALLTYPE *GetDataSize )( - ID3D10Asynchronous * This); - - END_INTERFACE - } ID3D10AsynchronousVtbl; - - interface ID3D10Asynchronous - { - CONST_VTBL struct ID3D10AsynchronousVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10Asynchronous_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10Asynchronous_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10Asynchronous_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10Asynchronous_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10Asynchronous_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10Asynchronous_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10Asynchronous_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10Asynchronous_Begin(This) \ - ( (This)->lpVtbl -> Begin(This) ) - -#define ID3D10Asynchronous_End(This) \ - ( (This)->lpVtbl -> End(This) ) - -#define ID3D10Asynchronous_GetData(This,pData,DataSize,Flags) \ - ( (This)->lpVtbl -> GetData(This,pData,DataSize,Flags) ) - -#define ID3D10Asynchronous_GetDataSize(This) \ - ( (This)->lpVtbl -> GetDataSize(This) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10Asynchronous_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0020 */ -/* [local] */ - -#define D3D10_GETDATA_DONOTFLUSH ( 1 ) - -typedef -enum D3D10_QUERY - { D3D10_QUERY_EVENT = 0, - D3D10_QUERY_OCCLUSION = ( D3D10_QUERY_EVENT + 1 ) , - D3D10_QUERY_TIMESTAMP = ( D3D10_QUERY_OCCLUSION + 1 ) , - D3D10_QUERY_TIMESTAMP_DISJOINT = ( D3D10_QUERY_TIMESTAMP + 1 ) , - D3D10_QUERY_PIPELINE_STATISTICS = ( D3D10_QUERY_TIMESTAMP_DISJOINT + 1 ) , - D3D10_QUERY_OCCLUSION_PREDICATE = ( D3D10_QUERY_PIPELINE_STATISTICS + 1 ) , - D3D10_QUERY_SO_STATISTICS = ( D3D10_QUERY_OCCLUSION_PREDICATE + 1 ) , - D3D10_QUERY_SO_OVERFLOW_PREDICATE = ( D3D10_QUERY_SO_STATISTICS + 1 ) - } D3D10_QUERY; - -#define D3D10_QUERY_MISCFLAG_PREDICATEHINT ( 0x1 ) - -typedef struct D3D10_QUERY_DESC - { - D3D10_QUERY Query; - UINT MiscFlags; - } D3D10_QUERY_DESC; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0020_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0020_v0_0_s_ifspec; - -#ifndef __ID3D10Query_INTERFACE_DEFINED__ -#define __ID3D10Query_INTERFACE_DEFINED__ - -/* interface ID3D10Query */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10Query; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C0E-342C-4106-A19F-4F2704F689F0") - ID3D10Query : public ID3D10Asynchronous - { - public: - }; - -#else /* C style interface */ - - typedef struct ID3D10QueryVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10Query * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10Query * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10Query * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10Query * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10Query * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10Query * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10Query * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *Begin )( - ID3D10Query * This); - - void ( STDMETHODCALLTYPE *End )( - ID3D10Query * This); - - HRESULT ( STDMETHODCALLTYPE *GetData )( - ID3D10Query * This, - /* [size_is][out] */ void *pData, - /* [in] */ SIZE_T DataSize, - /* [in] */ UINT Flags); - - SIZE_T ( STDMETHODCALLTYPE *GetDataSize )( - ID3D10Query * This); - - END_INTERFACE - } ID3D10QueryVtbl; - - interface ID3D10Query - { - CONST_VTBL struct ID3D10QueryVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10Query_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10Query_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10Query_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10Query_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10Query_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10Query_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10Query_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10Query_Begin(This) \ - ( (This)->lpVtbl -> Begin(This) ) - -#define ID3D10Query_End(This) \ - ( (This)->lpVtbl -> End(This) ) - -#define ID3D10Query_GetData(This,pData,DataSize,Flags) \ - ( (This)->lpVtbl -> GetData(This,pData,DataSize,Flags) ) - -#define ID3D10Query_GetDataSize(This) \ - ( (This)->lpVtbl -> GetDataSize(This) ) - - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10Query_INTERFACE_DEFINED__ */ - - -#ifndef __ID3D10Predicate_INTERFACE_DEFINED__ -#define __ID3D10Predicate_INTERFACE_DEFINED__ - -/* interface ID3D10Predicate */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10Predicate; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C10-342C-4106-A19F-4F2704F689F0") - ID3D10Predicate : public ID3D10Query - { - public: - }; - -#else /* C style interface */ - - typedef struct ID3D10PredicateVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10Predicate * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10Predicate * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10Predicate * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10Predicate * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10Predicate * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10Predicate * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10Predicate * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *Begin )( - ID3D10Predicate * This); - - void ( STDMETHODCALLTYPE *End )( - ID3D10Predicate * This); - - HRESULT ( STDMETHODCALLTYPE *GetData )( - ID3D10Predicate * This, - /* [size_is][out] */ void *pData, - /* [in] */ SIZE_T DataSize, - /* [in] */ UINT Flags); - - SIZE_T ( STDMETHODCALLTYPE *GetDataSize )( - ID3D10Predicate * This); - - END_INTERFACE - } ID3D10PredicateVtbl; - - interface ID3D10Predicate - { - CONST_VTBL struct ID3D10PredicateVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10Predicate_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10Predicate_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10Predicate_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10Predicate_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10Predicate_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10Predicate_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10Predicate_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10Predicate_Begin(This) \ - ( (This)->lpVtbl -> Begin(This) ) - -#define ID3D10Predicate_End(This) \ - ( (This)->lpVtbl -> End(This) ) - -#define ID3D10Predicate_GetData(This,pData,DataSize,Flags) \ - ( (This)->lpVtbl -> GetData(This,pData,DataSize,Flags) ) - -#define ID3D10Predicate_GetDataSize(This) \ - ( (This)->lpVtbl -> GetDataSize(This) ) - - - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10Predicate_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0022 */ -/* [local] */ - -typedef struct D3D10_QUERY_DATA_TIMESTAMP_DISJOINT - { - UINT64 Frequency; - BOOL Disjoint; - } D3D10_QUERY_DATA_TIMESTAMP_DISJOINT; - -typedef struct D3D10_QUERY_DATA_PIPELINE_STATISTICS - { - UINT64 IAVertices; - UINT64 IAPrimitives; - UINT64 VSInvocations; - UINT64 GSInvocations; - UINT64 GSPrimitives; - UINT64 CInvocations; - UINT64 CPrimitives; - UINT64 PSInvocations; - } D3D10_QUERY_DATA_PIPELINE_STATISTICS; - -typedef struct D3D10_QUERY_DATA_SO_STATISTICS - { - UINT64 NumPrimitivesWritten; - UINT64 PrimitivesStorageNeeded; - } D3D10_QUERY_DATA_SO_STATISTICS; - -typedef -enum D3D10_COUNTER - { D3D10_COUNTER_GPU_IDLE = 0, - D3D10_COUNTER_VERTEX_PROCESSING = ( D3D10_COUNTER_GPU_IDLE + 1 ) , - D3D10_COUNTER_GEOMETRY_PROCESSING = ( D3D10_COUNTER_VERTEX_PROCESSING + 1 ) , - D3D10_COUNTER_PIXEL_PROCESSING = ( D3D10_COUNTER_GEOMETRY_PROCESSING + 1 ) , - D3D10_COUNTER_OTHER_GPU_PROCESSING = ( D3D10_COUNTER_PIXEL_PROCESSING + 1 ) , - D3D10_COUNTER_HOST_ADAPTER_BANDWIDTH_UTILIZATION = ( D3D10_COUNTER_OTHER_GPU_PROCESSING + 1 ) , - D3D10_COUNTER_LOCAL_VIDMEM_BANDWIDTH_UTILIZATION = ( D3D10_COUNTER_HOST_ADAPTER_BANDWIDTH_UTILIZATION + 1 ) , - D3D10_COUNTER_VERTEX_THROUGHPUT_UTILIZATION = ( D3D10_COUNTER_LOCAL_VIDMEM_BANDWIDTH_UTILIZATION + 1 ) , - D3D10_COUNTER_TRIANGLE_SETUP_THROUGHPUT_UTILIZATION = ( D3D10_COUNTER_VERTEX_THROUGHPUT_UTILIZATION + 1 ) , - D3D10_COUNTER_FILLRATE_THROUGHPUT_UTILIZATION = ( D3D10_COUNTER_TRIANGLE_SETUP_THROUGHPUT_UTILIZATION + 1 ) , - D3D10_COUNTER_VS_MEMORY_LIMITED = ( D3D10_COUNTER_FILLRATE_THROUGHPUT_UTILIZATION + 1 ) , - D3D10_COUNTER_VS_COMPUTATION_LIMITED = ( D3D10_COUNTER_VS_MEMORY_LIMITED + 1 ) , - D3D10_COUNTER_GS_MEMORY_LIMITED = ( D3D10_COUNTER_VS_COMPUTATION_LIMITED + 1 ) , - D3D10_COUNTER_GS_COMPUTATION_LIMITED = ( D3D10_COUNTER_GS_MEMORY_LIMITED + 1 ) , - D3D10_COUNTER_PS_MEMORY_LIMITED = ( D3D10_COUNTER_GS_COMPUTATION_LIMITED + 1 ) , - D3D10_COUNTER_PS_COMPUTATION_LIMITED = ( D3D10_COUNTER_PS_MEMORY_LIMITED + 1 ) , - D3D10_COUNTER_POST_TRANSFORM_CACHE_HIT_RATE = ( D3D10_COUNTER_PS_COMPUTATION_LIMITED + 1 ) , - D3D10_COUNTER_TEXTURE_CACHE_HIT_RATE = ( D3D10_COUNTER_POST_TRANSFORM_CACHE_HIT_RATE + 1 ) , - D3D10_COUNTER_DEVICE_DEPENDENT_0 = 0x40000000 - } D3D10_COUNTER; - -typedef -enum D3D10_COUNTER_TYPE - { D3D10_COUNTER_TYPE_FLOAT32 = 0, - D3D10_COUNTER_TYPE_UINT16 = ( D3D10_COUNTER_TYPE_FLOAT32 + 1 ) , - D3D10_COUNTER_TYPE_UINT32 = ( D3D10_COUNTER_TYPE_UINT16 + 1 ) , - D3D10_COUNTER_TYPE_UINT64 = ( D3D10_COUNTER_TYPE_UINT32 + 1 ) - } D3D10_COUNTER_TYPE; - -typedef struct D3D10_COUNTER_DESC - { - D3D10_COUNTER Counter; - UINT MiscFlags; - } D3D10_COUNTER_DESC; - -typedef struct D3D10_COUNTER_INFO - { - D3D10_COUNTER LastDeviceDependentCounter; - UINT NumSimultaneousCounters; - UINT8 NumDetectableParallelUnits; - } D3D10_COUNTER_INFO; - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0022_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0022_v0_0_s_ifspec; - -#ifndef __ID3D10Counter_INTERFACE_DEFINED__ -#define __ID3D10Counter_INTERFACE_DEFINED__ - -/* interface ID3D10Counter */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10Counter; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C11-342C-4106-A19F-4F2704F689F0") - ID3D10Counter : public ID3D10Asynchronous - { - public: - }; - -#else /* C style interface */ - - typedef struct ID3D10CounterVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10Counter * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10Counter * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10Counter * This); - - void ( STDMETHODCALLTYPE *GetDevice )( - ID3D10Counter * This, - /* [retval][out] */ ID3D10Device **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10Counter * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10Counter * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10Counter * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *Begin )( - ID3D10Counter * This); - - void ( STDMETHODCALLTYPE *End )( - ID3D10Counter * This); - - HRESULT ( STDMETHODCALLTYPE *GetData )( - ID3D10Counter * This, - /* [size_is][out] */ void *pData, - /* [in] */ SIZE_T DataSize, - /* [in] */ UINT Flags); - - SIZE_T ( STDMETHODCALLTYPE *GetDataSize )( - ID3D10Counter * This); - - END_INTERFACE - } ID3D10CounterVtbl; - - interface ID3D10Counter - { - CONST_VTBL struct ID3D10CounterVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10Counter_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10Counter_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10Counter_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10Counter_GetDevice(This,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) - -#define ID3D10Counter_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10Counter_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10Counter_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - - -#define ID3D10Counter_Begin(This) \ - ( (This)->lpVtbl -> Begin(This) ) - -#define ID3D10Counter_End(This) \ - ( (This)->lpVtbl -> End(This) ) - -#define ID3D10Counter_GetData(This,pData,DataSize,Flags) \ - ( (This)->lpVtbl -> GetData(This,pData,DataSize,Flags) ) - -#define ID3D10Counter_GetDataSize(This) \ - ( (This)->lpVtbl -> GetDataSize(This) ) - - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10Counter_INTERFACE_DEFINED__ */ - - -#ifndef __ID3D10Device_INTERFACE_DEFINED__ -#define __ID3D10Device_INTERFACE_DEFINED__ - -/* interface ID3D10Device */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10Device; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4C0F-342C-4106-A19F-4F2704F689F0") - ID3D10Device : public IUnknown - { - public: - virtual void STDMETHODCALLTYPE VSSetConstantBuffers( - /* [in] */ UINT StartConstantSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][in] */ ID3D10Buffer *const *ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE PSSetShaderResources( - /* [in] */ UINT Offset, - /* [in] */ UINT NumViews, - /* [size_is][in] */ ID3D10ShaderResourceView *const *ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE PSSetShader( - /* [in] */ ID3D10PixelShader *pPixelShader) = 0; - - virtual void STDMETHODCALLTYPE PSSetSamplers( - /* [in] */ UINT Offset, - /* [in] */ UINT NumSamplers, - /* [size_is][in] */ ID3D10SamplerState *const *ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE VSSetShader( - /* [in] */ ID3D10VertexShader *pVertexShader) = 0; - - virtual void STDMETHODCALLTYPE DrawIndexed( - /* [in] */ UINT IndexCount, - /* [in] */ UINT StartIndexLocation, - /* [in] */ INT BaseVertexLocation) = 0; - - virtual void STDMETHODCALLTYPE Draw( - /* [in] */ UINT VertexCount, - /* [in] */ UINT StartVertexLocation) = 0; - - virtual void STDMETHODCALLTYPE PSSetConstantBuffers( - /* [in] */ UINT StartConstantSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][in] */ ID3D10Buffer *const *ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE IASetInputLayout( - /* [in] */ ID3D10InputLayout *pInputLayout) = 0; - - virtual void STDMETHODCALLTYPE IASetVertexBuffers( - /* [in] */ UINT StartSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][in] */ ID3D10Buffer *const *ppVertexBuffers, - /* [size_is][in] */ const UINT *pStrides, - /* [size_is][in] */ const UINT *pOffsets) = 0; - - virtual void STDMETHODCALLTYPE IASetIndexBuffer( - /* [in] */ ID3D10Buffer *pIndexBuffer, - /* [in] */ DXGI_FORMAT Format, - /* [in] */ UINT Offset) = 0; - - virtual void STDMETHODCALLTYPE DrawIndexedInstanced( - /* [in] */ UINT IndexCountPerInstance, - /* [in] */ UINT InstanceCount, - /* [in] */ UINT StartIndexLocation, - /* [in] */ INT BaseVertexLocation, - /* [in] */ UINT StartInstanceLocation) = 0; - - virtual void STDMETHODCALLTYPE DrawInstanced( - /* [in] */ UINT VertexCountPerInstance, - /* [in] */ UINT InstanceCount, - /* [in] */ UINT StartVertexLocation, - /* [in] */ UINT StartInstanceLocation) = 0; - - virtual void STDMETHODCALLTYPE GSSetConstantBuffers( - /* [in] */ UINT StartConstantSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][in] */ ID3D10Buffer *const *ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE GSSetShader( - /* [in] */ ID3D10GeometryShader *pShader) = 0; - - virtual void STDMETHODCALLTYPE IASetPrimitiveTopology( - /* [in] */ D3D10_PRIMITIVE_TOPOLOGY Topology) = 0; - - virtual void STDMETHODCALLTYPE VSSetShaderResources( - /* [in] */ UINT Offset, - /* [in] */ UINT NumViews, - /* [size_is][in] */ ID3D10ShaderResourceView *const *ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE VSSetSamplers( - /* [in] */ UINT Offset, - /* [in] */ UINT NumSamplers, - /* [size_is][in] */ ID3D10SamplerState *const *ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE SetPredication( - /* [in] */ ID3D10Predicate *pPredicate, - /* [in] */ BOOL PredicateValue) = 0; - - virtual void STDMETHODCALLTYPE GSSetShaderResources( - /* [in] */ UINT Offset, - /* [in] */ UINT NumViews, - /* [size_is][in] */ ID3D10ShaderResourceView *const *ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE GSSetSamplers( - /* [in] */ UINT Offset, - /* [in] */ UINT NumSamplers, - /* [size_is][in] */ ID3D10SamplerState *const *ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE OMSetRenderTargets( - /* [in] */ UINT NumViews, - /* [size_is][in] */ ID3D10RenderTargetView *const *ppRenderTargetViews, - /* [in] */ ID3D10DepthStencilView *pDepthStencilView) = 0; - - virtual void STDMETHODCALLTYPE OMSetBlendState( - /* [in] */ ID3D10BlendState *pBlendState, - /* [in] */ const FLOAT BlendFactor[ 4 ], - /* [in] */ UINT SampleMask) = 0; - - virtual void STDMETHODCALLTYPE OMSetDepthStencilState( - /* [in] */ ID3D10DepthStencilState *pDepthStencilState, - /* [in] */ UINT StencilRef) = 0; - - virtual void STDMETHODCALLTYPE SOSetTargets( - /* [in] */ UINT NumBuffers, - /* [size_is][in] */ ID3D10Buffer *const *ppSOTargets, - /* [size_is][in] */ const UINT *pOffsets) = 0; - - virtual void STDMETHODCALLTYPE DrawAuto( void) = 0; - - virtual void STDMETHODCALLTYPE RSSetState( - /* [in] */ ID3D10RasterizerState *pRasterizerState) = 0; - - virtual void STDMETHODCALLTYPE RSSetViewports( - /* [in] */ UINT NumViewports, - /* [size_is][in] */ const D3D10_VIEWPORT *pViewports) = 0; - - virtual void STDMETHODCALLTYPE RSSetScissorRects( - /* [in] */ UINT NumRects, - /* [size_is][in] */ const D3D10_RECT *pRects) = 0; - - virtual void STDMETHODCALLTYPE ClearRenderTargetView( - /* [in] */ ID3D10RenderTargetView *pRenderTargetView, - /* [in] */ const FLOAT ColorRGBA[ 4 ]) = 0; - - virtual void STDMETHODCALLTYPE ClearDepthStencilView( - /* [in] */ ID3D10DepthStencilView *pDepthStencilView, - /* [in] */ UINT Flags, - /* [in] */ FLOAT Depth, - /* [in] */ UINT8 Stencil) = 0; - - virtual HRESULT STDMETHODCALLTYPE GenerateMips( - /* [in] */ ID3D10ShaderResourceView *pShaderResourceView) = 0; - - virtual void STDMETHODCALLTYPE VSGetConstantBuffers( - /* [in] */ UINT StartConstantSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][out] */ ID3D10Buffer **ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE PSGetShaderResources( - /* [in] */ UINT Offset, - /* [in] */ UINT NumViews, - /* [size_is][out] */ ID3D10ShaderResourceView **ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE PSGetShader( - /* [out][in] */ ID3D10PixelShader **ppPixelShader) = 0; - - virtual void STDMETHODCALLTYPE PSGetSamplers( - /* [in] */ UINT Offset, - /* [in] */ UINT NumSamplers, - /* [size_is][out] */ ID3D10SamplerState **ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE VSGetShader( - /* [out][in] */ ID3D10VertexShader **ppVertexShader) = 0; - - virtual void STDMETHODCALLTYPE PSGetConstantBuffers( - /* [in] */ UINT StartConstantSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][out] */ ID3D10Buffer **ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE IAGetInputLayout( - /* [out][in] */ ID3D10InputLayout **ppInputLayout) = 0; - - virtual void STDMETHODCALLTYPE IAGetVertexBuffers( - /* [in] */ UINT StartSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][out] */ ID3D10Buffer **ppVertexBuffers, - /* [size_is][out] */ UINT *pStrides, - /* [size_is][out] */ UINT *pOffsets) = 0; - - virtual void STDMETHODCALLTYPE IAGetIndexBuffer( - /* [out] */ ID3D10Buffer **pIndexBuffer, - /* [out] */ DXGI_FORMAT *Format, - /* [out] */ UINT *Offset) = 0; - - virtual void STDMETHODCALLTYPE GSGetConstantBuffers( - /* [in] */ UINT StartConstantSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][out] */ ID3D10Buffer **ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE GSGetShader( - /* [out] */ ID3D10GeometryShader **ppGeometryShader) = 0; - - virtual void STDMETHODCALLTYPE IAGetPrimitiveTopology( - /* [out] */ D3D10_PRIMITIVE_TOPOLOGY *pTopology) = 0; - - virtual void STDMETHODCALLTYPE VSGetShaderResources( - /* [in] */ UINT Offset, - /* [in] */ UINT NumViews, - /* [size_is][out] */ ID3D10ShaderResourceView **ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE VSGetSamplers( - /* [in] */ UINT Offset, - /* [in] */ UINT NumSamplers, - /* [size_is][out] */ ID3D10SamplerState **ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE GetPredication( - /* [out] */ ID3D10Predicate **ppPredicate, - /* [out] */ BOOL *pPredicateValue) = 0; - - virtual void STDMETHODCALLTYPE GSGetShaderResources( - /* [in] */ UINT Offset, - /* [in] */ UINT NumViews, - /* [size_is][out] */ ID3D10ShaderResourceView **ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE GSGetSamplers( - /* [in] */ UINT Offset, - /* [in] */ UINT NumSamplers, - /* [size_is][out] */ ID3D10SamplerState **ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE OMGetRenderTargets( - /* [in] */ UINT NumViews, - /* [size_is][out] */ ID3D10RenderTargetView **ppRenderTargetViews, - /* [out] */ ID3D10DepthStencilView **ppDepthStencilView) = 0; - - virtual void STDMETHODCALLTYPE OMGetBlendState( - /* [out] */ ID3D10BlendState **ppBlendState, - /* [out] */ FLOAT BlendFactor[ 4 ], - /* [out] */ UINT *pSampleMask) = 0; - - virtual void STDMETHODCALLTYPE OMGetDepthStencilState( - /* [out] */ ID3D10DepthStencilState **ppDepthStencilState, - /* [out] */ UINT *pStencilRef) = 0; - - virtual void STDMETHODCALLTYPE SOGetTargets( - /* [in] */ UINT NumBuffers, - /* [size_is][out] */ ID3D10Buffer **ppSOTargets, - /* [size_is][out] */ UINT *pOffsets) = 0; - - virtual void STDMETHODCALLTYPE RSGetState( - /* [out] */ ID3D10RasterizerState **ppRasterizerState) = 0; - - virtual void STDMETHODCALLTYPE RSGetViewports( - /* [out][in] */ UINT *NumViewports, - /* [size_is][out] */ D3D10_VIEWPORT *pViewports) = 0; - - virtual void STDMETHODCALLTYPE RSGetScissorRects( - /* [out][in] */ UINT *NumRects, - /* [size_is][out] */ D3D10_RECT *pRects) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetDeviceRemovedReason( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetExceptionMode( - UINT RaiseFlags) = 0; - - virtual UINT STDMETHODCALLTYPE GetExceptionMode( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetPrivateData( - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetPrivateData( - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData) = 0; - - virtual void STDMETHODCALLTYPE Enter( void) = 0; - - virtual void STDMETHODCALLTYPE Leave( void) = 0; - - virtual void STDMETHODCALLTYPE Flush( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateBuffer( - /* [in] */ const D3D10_BUFFER_DESC *pDesc, - /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, - /* [out] */ ID3D10Buffer **ppBuffer) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateTexture1D( - /* [in] */ const D3D10_TEXTURE1D_DESC *pDesc, - /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, - /* [out] */ ID3D10Texture1D **ppTexture1D) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateTexture2D( - /* [in] */ const D3D10_TEXTURE2D_DESC *pDesc, - /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, - /* [out] */ ID3D10Texture2D **ppTexture2D) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateTexture3D( - /* [in] */ const D3D10_TEXTURE3D_DESC *pDesc, - /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, - /* [out] */ ID3D10Texture3D **ppTexture3D) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateTextureCube( - /* [in] */ const D3D10_TEXTURECUBE_DESC *pDesc, - /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, - /* [out] */ ID3D10TextureCube **ppTextureCube) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateShaderResourceView( - /* [in] */ ID3D10Resource *pResource, - /* [in] */ const D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc, - /* [out] */ ID3D10ShaderResourceView **ppSRView) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateRenderTargetView( - /* [in] */ ID3D10Resource *pResource, - /* [in] */ const D3D10_RENDER_TARGET_VIEW_DESC *pDesc, - /* [out] */ ID3D10RenderTargetView **ppRTView) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateDepthStencilView( - /* [in] */ ID3D10Resource *pResource, - /* [in] */ const D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc, - /* [out] */ ID3D10DepthStencilView **ppDepthStencilView) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateInputLayout( - /* [size_is][in] */ const D3D10_INPUT_ELEMENT_DESC *pInputElementDescs, - /* [in] */ UINT NumElements, - /* [in] */ const void *pShaderBytecodeWithInputSignature, - /* [out] */ ID3D10InputLayout **ppInputLayout) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateVertexShader( - /* [in] */ const void *pShaderBytecode, - /* [out] */ ID3D10VertexShader **ppVertexShader) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateGeometryShader( - /* [in] */ const void *pShaderBytecode, - /* [out] */ ID3D10GeometryShader **ppGeometryShader) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateGeometryShaderWithStreamOutput( - /* [in] */ const void *pShaderBytecode, - /* [size_is][in] */ const D3D10_SO_DECLARATION_ENTRY *pSODeclaration, - /* [in] */ UINT NumEntries, - /* [in] */ UINT OutputStreamStride, - /* [out] */ ID3D10GeometryShader **ppGeometryShader) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreatePixelShader( - /* [in] */ const void *pShaderBytecode, - /* [out] */ ID3D10PixelShader **ppPixelShader) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateBlendState( - /* [in] */ const D3D10_BLEND_DESC *pBlendStateDesc, - /* [out] */ ID3D10BlendState **ppBlendState) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateDepthStencilState( - /* [in] */ const D3D10_DEPTH_STENCIL_DESC *pDepthStencilDesc, - /* [out] */ ID3D10DepthStencilState **ppDepthStencilState) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateRasterizerState( - /* [in] */ const D3D10_RASTERIZER_DESC *pRasterizerDesc, - /* [out] */ ID3D10RasterizerState **ppRasterizerState) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateSamplerState( - /* [in] */ const D3D10_SAMPLER_DESC *pSamplerDesc, - /* [out] */ ID3D10SamplerState **ppSamplerState) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateQuery( - /* [in] */ const D3D10_QUERY_DESC *pQueryDesc, - /* [out] */ ID3D10Query **ppQuery) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreatePredicate( - /* [in] */ const D3D10_QUERY_DESC *pPredicateDesc, - /* [out] */ ID3D10Predicate **ppPredicate) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateCounter( - /* [in] */ const D3D10_COUNTER_DESC *pCounterDesc, - /* [out] */ ID3D10Counter **ppCounter) = 0; - - virtual HRESULT STDMETHODCALLTYPE CheckFormatSupport( - /* [in] */ DXGI_FORMAT Format, - /* [retval][out] */ UINT *pFormatSupport) = 0; - - virtual HRESULT STDMETHODCALLTYPE CheckMultisampleQualityLevels( - /* [in] */ UINT SampleCount, - /* [retval][out] */ UINT *pNumQualityLevels) = 0; - - virtual void STDMETHODCALLTYPE CheckVertexCache( - /* [out] */ D3D10_VERTEX_CACHE_DESC *pVertexCacheDesc) = 0; - - virtual void STDMETHODCALLTYPE CheckCounterInfo( - /* [retval][out] */ D3D10_COUNTER_INFO *pCounterInfo) = 0; - - virtual HRESULT STDMETHODCALLTYPE CheckCounter( - /* */ - __in const D3D10_COUNTER_DESC *pDesc, - /* */ - __out D3D10_COUNTER_TYPE *pType, - /* */ - __out UINT *pActiveCounters, - /* */ - __out_ecount_opt(*pNameLength) LPWSTR wszName, - /* */ - __inout_opt SIZE_T *pNameLength, - /* */ - __out_ecount_opt(*pUnitsLength) LPWSTR wszUnits, - /* */ - __inout_opt SIZE_T *pUnitsLength, - /* */ - __out_ecount_opt(*pDescriptionLength) LPWSTR wszDescription, - /* */ - __inout_opt SIZE_T *pDescriptionLength) = 0; - - virtual UINT STDMETHODCALLTYPE GetCreationFlags( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10DeviceVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10Device * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10Device * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10Device * This); - - void ( STDMETHODCALLTYPE *VSSetConstantBuffers )( - ID3D10Device * This, - /* [in] */ UINT StartConstantSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][in] */ ID3D10Buffer *const *ppConstantBuffers); - - void ( STDMETHODCALLTYPE *PSSetShaderResources )( - ID3D10Device * This, - /* [in] */ UINT Offset, - /* [in] */ UINT NumViews, - /* [size_is][in] */ ID3D10ShaderResourceView *const *ppShaderResourceViews); - - void ( STDMETHODCALLTYPE *PSSetShader )( - ID3D10Device * This, - /* [in] */ ID3D10PixelShader *pPixelShader); - - void ( STDMETHODCALLTYPE *PSSetSamplers )( - ID3D10Device * This, - /* [in] */ UINT Offset, - /* [in] */ UINT NumSamplers, - /* [size_is][in] */ ID3D10SamplerState *const *ppSamplers); - - void ( STDMETHODCALLTYPE *VSSetShader )( - ID3D10Device * This, - /* [in] */ ID3D10VertexShader *pVertexShader); - - void ( STDMETHODCALLTYPE *DrawIndexed )( - ID3D10Device * This, - /* [in] */ UINT IndexCount, - /* [in] */ UINT StartIndexLocation, - /* [in] */ INT BaseVertexLocation); - - void ( STDMETHODCALLTYPE *Draw )( - ID3D10Device * This, - /* [in] */ UINT VertexCount, - /* [in] */ UINT StartVertexLocation); - - void ( STDMETHODCALLTYPE *PSSetConstantBuffers )( - ID3D10Device * This, - /* [in] */ UINT StartConstantSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][in] */ ID3D10Buffer *const *ppConstantBuffers); - - void ( STDMETHODCALLTYPE *IASetInputLayout )( - ID3D10Device * This, - /* [in] */ ID3D10InputLayout *pInputLayout); - - void ( STDMETHODCALLTYPE *IASetVertexBuffers )( - ID3D10Device * This, - /* [in] */ UINT StartSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][in] */ ID3D10Buffer *const *ppVertexBuffers, - /* [size_is][in] */ const UINT *pStrides, - /* [size_is][in] */ const UINT *pOffsets); - - void ( STDMETHODCALLTYPE *IASetIndexBuffer )( - ID3D10Device * This, - /* [in] */ ID3D10Buffer *pIndexBuffer, - /* [in] */ DXGI_FORMAT Format, - /* [in] */ UINT Offset); - - void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( - ID3D10Device * This, - /* [in] */ UINT IndexCountPerInstance, - /* [in] */ UINT InstanceCount, - /* [in] */ UINT StartIndexLocation, - /* [in] */ INT BaseVertexLocation, - /* [in] */ UINT StartInstanceLocation); - - void ( STDMETHODCALLTYPE *DrawInstanced )( - ID3D10Device * This, - /* [in] */ UINT VertexCountPerInstance, - /* [in] */ UINT InstanceCount, - /* [in] */ UINT StartVertexLocation, - /* [in] */ UINT StartInstanceLocation); - - void ( STDMETHODCALLTYPE *GSSetConstantBuffers )( - ID3D10Device * This, - /* [in] */ UINT StartConstantSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][in] */ ID3D10Buffer *const *ppConstantBuffers); - - void ( STDMETHODCALLTYPE *GSSetShader )( - ID3D10Device * This, - /* [in] */ ID3D10GeometryShader *pShader); - - void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( - ID3D10Device * This, - /* [in] */ D3D10_PRIMITIVE_TOPOLOGY Topology); - - void ( STDMETHODCALLTYPE *VSSetShaderResources )( - ID3D10Device * This, - /* [in] */ UINT Offset, - /* [in] */ UINT NumViews, - /* [size_is][in] */ ID3D10ShaderResourceView *const *ppShaderResourceViews); - - void ( STDMETHODCALLTYPE *VSSetSamplers )( - ID3D10Device * This, - /* [in] */ UINT Offset, - /* [in] */ UINT NumSamplers, - /* [size_is][in] */ ID3D10SamplerState *const *ppSamplers); - - void ( STDMETHODCALLTYPE *SetPredication )( - ID3D10Device * This, - /* [in] */ ID3D10Predicate *pPredicate, - /* [in] */ BOOL PredicateValue); - - void ( STDMETHODCALLTYPE *GSSetShaderResources )( - ID3D10Device * This, - /* [in] */ UINT Offset, - /* [in] */ UINT NumViews, - /* [size_is][in] */ ID3D10ShaderResourceView *const *ppShaderResourceViews); - - void ( STDMETHODCALLTYPE *GSSetSamplers )( - ID3D10Device * This, - /* [in] */ UINT Offset, - /* [in] */ UINT NumSamplers, - /* [size_is][in] */ ID3D10SamplerState *const *ppSamplers); - - void ( STDMETHODCALLTYPE *OMSetRenderTargets )( - ID3D10Device * This, - /* [in] */ UINT NumViews, - /* [size_is][in] */ ID3D10RenderTargetView *const *ppRenderTargetViews, - /* [in] */ ID3D10DepthStencilView *pDepthStencilView); - - void ( STDMETHODCALLTYPE *OMSetBlendState )( - ID3D10Device * This, - /* [in] */ ID3D10BlendState *pBlendState, - /* [in] */ const FLOAT BlendFactor[ 4 ], - /* [in] */ UINT SampleMask); - - void ( STDMETHODCALLTYPE *OMSetDepthStencilState )( - ID3D10Device * This, - /* [in] */ ID3D10DepthStencilState *pDepthStencilState, - /* [in] */ UINT StencilRef); - - void ( STDMETHODCALLTYPE *SOSetTargets )( - ID3D10Device * This, - /* [in] */ UINT NumBuffers, - /* [size_is][in] */ ID3D10Buffer *const *ppSOTargets, - /* [size_is][in] */ const UINT *pOffsets); - - void ( STDMETHODCALLTYPE *DrawAuto )( - ID3D10Device * This); - - void ( STDMETHODCALLTYPE *RSSetState )( - ID3D10Device * This, - /* [in] */ ID3D10RasterizerState *pRasterizerState); - - void ( STDMETHODCALLTYPE *RSSetViewports )( - ID3D10Device * This, - /* [in] */ UINT NumViewports, - /* [size_is][in] */ const D3D10_VIEWPORT *pViewports); - - void ( STDMETHODCALLTYPE *RSSetScissorRects )( - ID3D10Device * This, - /* [in] */ UINT NumRects, - /* [size_is][in] */ const D3D10_RECT *pRects); - - void ( STDMETHODCALLTYPE *ClearRenderTargetView )( - ID3D10Device * This, - /* [in] */ ID3D10RenderTargetView *pRenderTargetView, - /* [in] */ const FLOAT ColorRGBA[ 4 ]); - - void ( STDMETHODCALLTYPE *ClearDepthStencilView )( - ID3D10Device * This, - /* [in] */ ID3D10DepthStencilView *pDepthStencilView, - /* [in] */ UINT Flags, - /* [in] */ FLOAT Depth, - /* [in] */ UINT8 Stencil); - - HRESULT ( STDMETHODCALLTYPE *GenerateMips )( - ID3D10Device * This, - /* [in] */ ID3D10ShaderResourceView *pShaderResourceView); - - void ( STDMETHODCALLTYPE *VSGetConstantBuffers )( - ID3D10Device * This, - /* [in] */ UINT StartConstantSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][out] */ ID3D10Buffer **ppConstantBuffers); - - void ( STDMETHODCALLTYPE *PSGetShaderResources )( - ID3D10Device * This, - /* [in] */ UINT Offset, - /* [in] */ UINT NumViews, - /* [size_is][out] */ ID3D10ShaderResourceView **ppShaderResourceViews); - - void ( STDMETHODCALLTYPE *PSGetShader )( - ID3D10Device * This, - /* [out][in] */ ID3D10PixelShader **ppPixelShader); - - void ( STDMETHODCALLTYPE *PSGetSamplers )( - ID3D10Device * This, - /* [in] */ UINT Offset, - /* [in] */ UINT NumSamplers, - /* [size_is][out] */ ID3D10SamplerState **ppSamplers); - - void ( STDMETHODCALLTYPE *VSGetShader )( - ID3D10Device * This, - /* [out][in] */ ID3D10VertexShader **ppVertexShader); - - void ( STDMETHODCALLTYPE *PSGetConstantBuffers )( - ID3D10Device * This, - /* [in] */ UINT StartConstantSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][out] */ ID3D10Buffer **ppConstantBuffers); - - void ( STDMETHODCALLTYPE *IAGetInputLayout )( - ID3D10Device * This, - /* [out][in] */ ID3D10InputLayout **ppInputLayout); - - void ( STDMETHODCALLTYPE *IAGetVertexBuffers )( - ID3D10Device * This, - /* [in] */ UINT StartSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][out] */ ID3D10Buffer **ppVertexBuffers, - /* [size_is][out] */ UINT *pStrides, - /* [size_is][out] */ UINT *pOffsets); - - void ( STDMETHODCALLTYPE *IAGetIndexBuffer )( - ID3D10Device * This, - /* [out] */ ID3D10Buffer **pIndexBuffer, - /* [out] */ DXGI_FORMAT *Format, - /* [out] */ UINT *Offset); - - void ( STDMETHODCALLTYPE *GSGetConstantBuffers )( - ID3D10Device * This, - /* [in] */ UINT StartConstantSlot, - /* [in] */ UINT NumBuffers, - /* [size_is][out] */ ID3D10Buffer **ppConstantBuffers); - - void ( STDMETHODCALLTYPE *GSGetShader )( - ID3D10Device * This, - /* [out] */ ID3D10GeometryShader **ppGeometryShader); - - void ( STDMETHODCALLTYPE *IAGetPrimitiveTopology )( - ID3D10Device * This, - /* [out] */ D3D10_PRIMITIVE_TOPOLOGY *pTopology); - - void ( STDMETHODCALLTYPE *VSGetShaderResources )( - ID3D10Device * This, - /* [in] */ UINT Offset, - /* [in] */ UINT NumViews, - /* [size_is][out] */ ID3D10ShaderResourceView **ppShaderResourceViews); - - void ( STDMETHODCALLTYPE *VSGetSamplers )( - ID3D10Device * This, - /* [in] */ UINT Offset, - /* [in] */ UINT NumSamplers, - /* [size_is][out] */ ID3D10SamplerState **ppSamplers); - - void ( STDMETHODCALLTYPE *GetPredication )( - ID3D10Device * This, - /* [out] */ ID3D10Predicate **ppPredicate, - /* [out] */ BOOL *pPredicateValue); - - void ( STDMETHODCALLTYPE *GSGetShaderResources )( - ID3D10Device * This, - /* [in] */ UINT Offset, - /* [in] */ UINT NumViews, - /* [size_is][out] */ ID3D10ShaderResourceView **ppShaderResourceViews); - - void ( STDMETHODCALLTYPE *GSGetSamplers )( - ID3D10Device * This, - /* [in] */ UINT Offset, - /* [in] */ UINT NumSamplers, - /* [size_is][out] */ ID3D10SamplerState **ppSamplers); - - void ( STDMETHODCALLTYPE *OMGetRenderTargets )( - ID3D10Device * This, - /* [in] */ UINT NumViews, - /* [size_is][out] */ ID3D10RenderTargetView **ppRenderTargetViews, - /* [out] */ ID3D10DepthStencilView **ppDepthStencilView); - - void ( STDMETHODCALLTYPE *OMGetBlendState )( - ID3D10Device * This, - /* [out] */ ID3D10BlendState **ppBlendState, - /* [out] */ FLOAT BlendFactor[ 4 ], - /* [out] */ UINT *pSampleMask); - - void ( STDMETHODCALLTYPE *OMGetDepthStencilState )( - ID3D10Device * This, - /* [out] */ ID3D10DepthStencilState **ppDepthStencilState, - /* [out] */ UINT *pStencilRef); - - void ( STDMETHODCALLTYPE *SOGetTargets )( - ID3D10Device * This, - /* [in] */ UINT NumBuffers, - /* [size_is][out] */ ID3D10Buffer **ppSOTargets, - /* [size_is][out] */ UINT *pOffsets); - - void ( STDMETHODCALLTYPE *RSGetState )( - ID3D10Device * This, - /* [out] */ ID3D10RasterizerState **ppRasterizerState); - - void ( STDMETHODCALLTYPE *RSGetViewports )( - ID3D10Device * This, - /* [out][in] */ UINT *NumViewports, - /* [size_is][out] */ D3D10_VIEWPORT *pViewports); - - void ( STDMETHODCALLTYPE *RSGetScissorRects )( - ID3D10Device * This, - /* [out][in] */ UINT *NumRects, - /* [size_is][out] */ D3D10_RECT *pRects); - - HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( - ID3D10Device * This); - - HRESULT ( STDMETHODCALLTYPE *SetExceptionMode )( - ID3D10Device * This, - UINT RaiseFlags); - - UINT ( STDMETHODCALLTYPE *GetExceptionMode )( - ID3D10Device * This); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D10Device * This, - /* [in] */ REFGUID guid, - /* [out][in] */ SIZE_T *pDataSize, - /* [size_is][out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D10Device * This, - /* [in] */ REFGUID guid, - /* [in] */ SIZE_T DataSize, - /* [size_is][in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D10Device * This, - /* [in] */ REFGUID guid, - /* [in] */ const IUnknown *pData); - - void ( STDMETHODCALLTYPE *Enter )( - ID3D10Device * This); - - void ( STDMETHODCALLTYPE *Leave )( - ID3D10Device * This); - - void ( STDMETHODCALLTYPE *Flush )( - ID3D10Device * This); - - HRESULT ( STDMETHODCALLTYPE *CreateBuffer )( - ID3D10Device * This, - /* [in] */ const D3D10_BUFFER_DESC *pDesc, - /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, - /* [out] */ ID3D10Buffer **ppBuffer); - - HRESULT ( STDMETHODCALLTYPE *CreateTexture1D )( - ID3D10Device * This, - /* [in] */ const D3D10_TEXTURE1D_DESC *pDesc, - /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, - /* [out] */ ID3D10Texture1D **ppTexture1D); - - HRESULT ( STDMETHODCALLTYPE *CreateTexture2D )( - ID3D10Device * This, - /* [in] */ const D3D10_TEXTURE2D_DESC *pDesc, - /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, - /* [out] */ ID3D10Texture2D **ppTexture2D); - - HRESULT ( STDMETHODCALLTYPE *CreateTexture3D )( - ID3D10Device * This, - /* [in] */ const D3D10_TEXTURE3D_DESC *pDesc, - /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, - /* [out] */ ID3D10Texture3D **ppTexture3D); - - HRESULT ( STDMETHODCALLTYPE *CreateTextureCube )( - ID3D10Device * This, - /* [in] */ const D3D10_TEXTURECUBE_DESC *pDesc, - /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, - /* [out] */ ID3D10TextureCube **ppTextureCube); - - HRESULT ( STDMETHODCALLTYPE *CreateShaderResourceView )( - ID3D10Device * This, - /* [in] */ ID3D10Resource *pResource, - /* [in] */ const D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc, - /* [out] */ ID3D10ShaderResourceView **ppSRView); - - HRESULT ( STDMETHODCALLTYPE *CreateRenderTargetView )( - ID3D10Device * This, - /* [in] */ ID3D10Resource *pResource, - /* [in] */ const D3D10_RENDER_TARGET_VIEW_DESC *pDesc, - /* [out] */ ID3D10RenderTargetView **ppRTView); - - HRESULT ( STDMETHODCALLTYPE *CreateDepthStencilView )( - ID3D10Device * This, - /* [in] */ ID3D10Resource *pResource, - /* [in] */ const D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc, - /* [out] */ ID3D10DepthStencilView **ppDepthStencilView); - - HRESULT ( STDMETHODCALLTYPE *CreateInputLayout )( - ID3D10Device * This, - /* [size_is][in] */ const D3D10_INPUT_ELEMENT_DESC *pInputElementDescs, - /* [in] */ UINT NumElements, - /* [in] */ const void *pShaderBytecodeWithInputSignature, - /* [out] */ ID3D10InputLayout **ppInputLayout); - - HRESULT ( STDMETHODCALLTYPE *CreateVertexShader )( - ID3D10Device * This, - /* [in] */ const void *pShaderBytecode, - /* [out] */ ID3D10VertexShader **ppVertexShader); - - HRESULT ( STDMETHODCALLTYPE *CreateGeometryShader )( - ID3D10Device * This, - /* [in] */ const void *pShaderBytecode, - /* [out] */ ID3D10GeometryShader **ppGeometryShader); - - HRESULT ( STDMETHODCALLTYPE *CreateGeometryShaderWithStreamOutput )( - ID3D10Device * This, - /* [in] */ const void *pShaderBytecode, - /* [size_is][in] */ const D3D10_SO_DECLARATION_ENTRY *pSODeclaration, - /* [in] */ UINT NumEntries, - /* [in] */ UINT OutputStreamStride, - /* [out] */ ID3D10GeometryShader **ppGeometryShader); - - HRESULT ( STDMETHODCALLTYPE *CreatePixelShader )( - ID3D10Device * This, - /* [in] */ const void *pShaderBytecode, - /* [out] */ ID3D10PixelShader **ppPixelShader); - - HRESULT ( STDMETHODCALLTYPE *CreateBlendState )( - ID3D10Device * This, - /* [in] */ const D3D10_BLEND_DESC *pBlendStateDesc, - /* [out] */ ID3D10BlendState **ppBlendState); - - HRESULT ( STDMETHODCALLTYPE *CreateDepthStencilState )( - ID3D10Device * This, - /* [in] */ const D3D10_DEPTH_STENCIL_DESC *pDepthStencilDesc, - /* [out] */ ID3D10DepthStencilState **ppDepthStencilState); - - HRESULT ( STDMETHODCALLTYPE *CreateRasterizerState )( - ID3D10Device * This, - /* [in] */ const D3D10_RASTERIZER_DESC *pRasterizerDesc, - /* [out] */ ID3D10RasterizerState **ppRasterizerState); - - HRESULT ( STDMETHODCALLTYPE *CreateSamplerState )( - ID3D10Device * This, - /* [in] */ const D3D10_SAMPLER_DESC *pSamplerDesc, - /* [out] */ ID3D10SamplerState **ppSamplerState); - - HRESULT ( STDMETHODCALLTYPE *CreateQuery )( - ID3D10Device * This, - /* [in] */ const D3D10_QUERY_DESC *pQueryDesc, - /* [out] */ ID3D10Query **ppQuery); - - HRESULT ( STDMETHODCALLTYPE *CreatePredicate )( - ID3D10Device * This, - /* [in] */ const D3D10_QUERY_DESC *pPredicateDesc, - /* [out] */ ID3D10Predicate **ppPredicate); - - HRESULT ( STDMETHODCALLTYPE *CreateCounter )( - ID3D10Device * This, - /* [in] */ const D3D10_COUNTER_DESC *pCounterDesc, - /* [out] */ ID3D10Counter **ppCounter); - - HRESULT ( STDMETHODCALLTYPE *CheckFormatSupport )( - ID3D10Device * This, - /* [in] */ DXGI_FORMAT Format, - /* [retval][out] */ UINT *pFormatSupport); - - HRESULT ( STDMETHODCALLTYPE *CheckMultisampleQualityLevels )( - ID3D10Device * This, - /* [in] */ UINT SampleCount, - /* [retval][out] */ UINT *pNumQualityLevels); - - void ( STDMETHODCALLTYPE *CheckVertexCache )( - ID3D10Device * This, - /* [out] */ D3D10_VERTEX_CACHE_DESC *pVertexCacheDesc); - - void ( STDMETHODCALLTYPE *CheckCounterInfo )( - ID3D10Device * This, - /* [retval][out] */ D3D10_COUNTER_INFO *pCounterInfo); - - HRESULT ( STDMETHODCALLTYPE *CheckCounter )( - ID3D10Device * This, - /* */ - __in const D3D10_COUNTER_DESC *pDesc, - /* */ - __out D3D10_COUNTER_TYPE *pType, - /* */ - __out UINT *pActiveCounters, - /* */ - __out_ecount_opt(*pNameLength) LPWSTR wszName, - /* */ - __inout_opt SIZE_T *pNameLength, - /* */ - __out_ecount_opt(*pUnitsLength) LPWSTR wszUnits, - /* */ - __inout_opt SIZE_T *pUnitsLength, - /* */ - __out_ecount_opt(*pDescriptionLength) LPWSTR wszDescription, - /* */ - __inout_opt SIZE_T *pDescriptionLength); - - UINT ( STDMETHODCALLTYPE *GetCreationFlags )( - ID3D10Device * This); - - END_INTERFACE - } ID3D10DeviceVtbl; - - interface ID3D10Device - { - CONST_VTBL struct ID3D10DeviceVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10Device_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10Device_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10Device_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10Device_VSSetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) \ - ( (This)->lpVtbl -> VSSetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) ) - -#define ID3D10Device_PSSetShaderResources(This,Offset,NumViews,ppShaderResourceViews) \ - ( (This)->lpVtbl -> PSSetShaderResources(This,Offset,NumViews,ppShaderResourceViews) ) - -#define ID3D10Device_PSSetShader(This,pPixelShader) \ - ( (This)->lpVtbl -> PSSetShader(This,pPixelShader) ) - -#define ID3D10Device_PSSetSamplers(This,Offset,NumSamplers,ppSamplers) \ - ( (This)->lpVtbl -> PSSetSamplers(This,Offset,NumSamplers,ppSamplers) ) - -#define ID3D10Device_VSSetShader(This,pVertexShader) \ - ( (This)->lpVtbl -> VSSetShader(This,pVertexShader) ) - -#define ID3D10Device_DrawIndexed(This,IndexCount,StartIndexLocation,BaseVertexLocation) \ - ( (This)->lpVtbl -> DrawIndexed(This,IndexCount,StartIndexLocation,BaseVertexLocation) ) - -#define ID3D10Device_Draw(This,VertexCount,StartVertexLocation) \ - ( (This)->lpVtbl -> Draw(This,VertexCount,StartVertexLocation) ) - -#define ID3D10Device_PSSetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) \ - ( (This)->lpVtbl -> PSSetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) ) - -#define ID3D10Device_IASetInputLayout(This,pInputLayout) \ - ( (This)->lpVtbl -> IASetInputLayout(This,pInputLayout) ) - -#define ID3D10Device_IASetVertexBuffers(This,StartSlot,NumBuffers,ppVertexBuffers,pStrides,pOffsets) \ - ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumBuffers,ppVertexBuffers,pStrides,pOffsets) ) - -#define ID3D10Device_IASetIndexBuffer(This,pIndexBuffer,Format,Offset) \ - ( (This)->lpVtbl -> IASetIndexBuffer(This,pIndexBuffer,Format,Offset) ) - -#define ID3D10Device_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ - ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) - -#define ID3D10Device_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ - ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) - -#define ID3D10Device_GSSetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) \ - ( (This)->lpVtbl -> GSSetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) ) - -#define ID3D10Device_GSSetShader(This,pShader) \ - ( (This)->lpVtbl -> GSSetShader(This,pShader) ) - -#define ID3D10Device_IASetPrimitiveTopology(This,Topology) \ - ( (This)->lpVtbl -> IASetPrimitiveTopology(This,Topology) ) - -#define ID3D10Device_VSSetShaderResources(This,Offset,NumViews,ppShaderResourceViews) \ - ( (This)->lpVtbl -> VSSetShaderResources(This,Offset,NumViews,ppShaderResourceViews) ) - -#define ID3D10Device_VSSetSamplers(This,Offset,NumSamplers,ppSamplers) \ - ( (This)->lpVtbl -> VSSetSamplers(This,Offset,NumSamplers,ppSamplers) ) - -#define ID3D10Device_SetPredication(This,pPredicate,PredicateValue) \ - ( (This)->lpVtbl -> SetPredication(This,pPredicate,PredicateValue) ) - -#define ID3D10Device_GSSetShaderResources(This,Offset,NumViews,ppShaderResourceViews) \ - ( (This)->lpVtbl -> GSSetShaderResources(This,Offset,NumViews,ppShaderResourceViews) ) - -#define ID3D10Device_GSSetSamplers(This,Offset,NumSamplers,ppSamplers) \ - ( (This)->lpVtbl -> GSSetSamplers(This,Offset,NumSamplers,ppSamplers) ) - -#define ID3D10Device_OMSetRenderTargets(This,NumViews,ppRenderTargetViews,pDepthStencilView) \ - ( (This)->lpVtbl -> OMSetRenderTargets(This,NumViews,ppRenderTargetViews,pDepthStencilView) ) - -#define ID3D10Device_OMSetBlendState(This,pBlendState,BlendFactor,SampleMask) \ - ( (This)->lpVtbl -> OMSetBlendState(This,pBlendState,BlendFactor,SampleMask) ) - -#define ID3D10Device_OMSetDepthStencilState(This,pDepthStencilState,StencilRef) \ - ( (This)->lpVtbl -> OMSetDepthStencilState(This,pDepthStencilState,StencilRef) ) - -#define ID3D10Device_SOSetTargets(This,NumBuffers,ppSOTargets,pOffsets) \ - ( (This)->lpVtbl -> SOSetTargets(This,NumBuffers,ppSOTargets,pOffsets) ) - -#define ID3D10Device_DrawAuto(This) \ - ( (This)->lpVtbl -> DrawAuto(This) ) - -#define ID3D10Device_RSSetState(This,pRasterizerState) \ - ( (This)->lpVtbl -> RSSetState(This,pRasterizerState) ) - -#define ID3D10Device_RSSetViewports(This,NumViewports,pViewports) \ - ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) - -#define ID3D10Device_RSSetScissorRects(This,NumRects,pRects) \ - ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) - -#define ID3D10Device_ClearRenderTargetView(This,pRenderTargetView,ColorRGBA) \ - ( (This)->lpVtbl -> ClearRenderTargetView(This,pRenderTargetView,ColorRGBA) ) - -#define ID3D10Device_ClearDepthStencilView(This,pDepthStencilView,Flags,Depth,Stencil) \ - ( (This)->lpVtbl -> ClearDepthStencilView(This,pDepthStencilView,Flags,Depth,Stencil) ) - -#define ID3D10Device_GenerateMips(This,pShaderResourceView) \ - ( (This)->lpVtbl -> GenerateMips(This,pShaderResourceView) ) - -#define ID3D10Device_VSGetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) \ - ( (This)->lpVtbl -> VSGetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) ) - -#define ID3D10Device_PSGetShaderResources(This,Offset,NumViews,ppShaderResourceViews) \ - ( (This)->lpVtbl -> PSGetShaderResources(This,Offset,NumViews,ppShaderResourceViews) ) - -#define ID3D10Device_PSGetShader(This,ppPixelShader) \ - ( (This)->lpVtbl -> PSGetShader(This,ppPixelShader) ) - -#define ID3D10Device_PSGetSamplers(This,Offset,NumSamplers,ppSamplers) \ - ( (This)->lpVtbl -> PSGetSamplers(This,Offset,NumSamplers,ppSamplers) ) - -#define ID3D10Device_VSGetShader(This,ppVertexShader) \ - ( (This)->lpVtbl -> VSGetShader(This,ppVertexShader) ) - -#define ID3D10Device_PSGetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) \ - ( (This)->lpVtbl -> PSGetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) ) - -#define ID3D10Device_IAGetInputLayout(This,ppInputLayout) \ - ( (This)->lpVtbl -> IAGetInputLayout(This,ppInputLayout) ) - -#define ID3D10Device_IAGetVertexBuffers(This,StartSlot,NumBuffers,ppVertexBuffers,pStrides,pOffsets) \ - ( (This)->lpVtbl -> IAGetVertexBuffers(This,StartSlot,NumBuffers,ppVertexBuffers,pStrides,pOffsets) ) - -#define ID3D10Device_IAGetIndexBuffer(This,pIndexBuffer,Format,Offset) \ - ( (This)->lpVtbl -> IAGetIndexBuffer(This,pIndexBuffer,Format,Offset) ) - -#define ID3D10Device_GSGetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) \ - ( (This)->lpVtbl -> GSGetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) ) - -#define ID3D10Device_GSGetShader(This,ppGeometryShader) \ - ( (This)->lpVtbl -> GSGetShader(This,ppGeometryShader) ) - -#define ID3D10Device_IAGetPrimitiveTopology(This,pTopology) \ - ( (This)->lpVtbl -> IAGetPrimitiveTopology(This,pTopology) ) - -#define ID3D10Device_VSGetShaderResources(This,Offset,NumViews,ppShaderResourceViews) \ - ( (This)->lpVtbl -> VSGetShaderResources(This,Offset,NumViews,ppShaderResourceViews) ) - -#define ID3D10Device_VSGetSamplers(This,Offset,NumSamplers,ppSamplers) \ - ( (This)->lpVtbl -> VSGetSamplers(This,Offset,NumSamplers,ppSamplers) ) - -#define ID3D10Device_GetPredication(This,ppPredicate,pPredicateValue) \ - ( (This)->lpVtbl -> GetPredication(This,ppPredicate,pPredicateValue) ) - -#define ID3D10Device_GSGetShaderResources(This,Offset,NumViews,ppShaderResourceViews) \ - ( (This)->lpVtbl -> GSGetShaderResources(This,Offset,NumViews,ppShaderResourceViews) ) - -#define ID3D10Device_GSGetSamplers(This,Offset,NumSamplers,ppSamplers) \ - ( (This)->lpVtbl -> GSGetSamplers(This,Offset,NumSamplers,ppSamplers) ) - -#define ID3D10Device_OMGetRenderTargets(This,NumViews,ppRenderTargetViews,ppDepthStencilView) \ - ( (This)->lpVtbl -> OMGetRenderTargets(This,NumViews,ppRenderTargetViews,ppDepthStencilView) ) - -#define ID3D10Device_OMGetBlendState(This,ppBlendState,BlendFactor,pSampleMask) \ - ( (This)->lpVtbl -> OMGetBlendState(This,ppBlendState,BlendFactor,pSampleMask) ) - -#define ID3D10Device_OMGetDepthStencilState(This,ppDepthStencilState,pStencilRef) \ - ( (This)->lpVtbl -> OMGetDepthStencilState(This,ppDepthStencilState,pStencilRef) ) - -#define ID3D10Device_SOGetTargets(This,NumBuffers,ppSOTargets,pOffsets) \ - ( (This)->lpVtbl -> SOGetTargets(This,NumBuffers,ppSOTargets,pOffsets) ) - -#define ID3D10Device_RSGetState(This,ppRasterizerState) \ - ( (This)->lpVtbl -> RSGetState(This,ppRasterizerState) ) - -#define ID3D10Device_RSGetViewports(This,NumViewports,pViewports) \ - ( (This)->lpVtbl -> RSGetViewports(This,NumViewports,pViewports) ) - -#define ID3D10Device_RSGetScissorRects(This,NumRects,pRects) \ - ( (This)->lpVtbl -> RSGetScissorRects(This,NumRects,pRects) ) - -#define ID3D10Device_GetDeviceRemovedReason(This) \ - ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) - -#define ID3D10Device_SetExceptionMode(This,RaiseFlags) \ - ( (This)->lpVtbl -> SetExceptionMode(This,RaiseFlags) ) - -#define ID3D10Device_GetExceptionMode(This) \ - ( (This)->lpVtbl -> GetExceptionMode(This) ) - -#define ID3D10Device_GetPrivateData(This,guid,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) - -#define ID3D10Device_SetPrivateData(This,guid,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) - -#define ID3D10Device_SetPrivateDataInterface(This,guid,pData) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) - -#define ID3D10Device_Enter(This) \ - ( (This)->lpVtbl -> Enter(This) ) - -#define ID3D10Device_Leave(This) \ - ( (This)->lpVtbl -> Leave(This) ) - -#define ID3D10Device_Flush(This) \ - ( (This)->lpVtbl -> Flush(This) ) - -#define ID3D10Device_CreateBuffer(This,pDesc,pInitialData,ppBuffer) \ - ( (This)->lpVtbl -> CreateBuffer(This,pDesc,pInitialData,ppBuffer) ) - -#define ID3D10Device_CreateTexture1D(This,pDesc,pInitialData,ppTexture1D) \ - ( (This)->lpVtbl -> CreateTexture1D(This,pDesc,pInitialData,ppTexture1D) ) - -#define ID3D10Device_CreateTexture2D(This,pDesc,pInitialData,ppTexture2D) \ - ( (This)->lpVtbl -> CreateTexture2D(This,pDesc,pInitialData,ppTexture2D) ) - -#define ID3D10Device_CreateTexture3D(This,pDesc,pInitialData,ppTexture3D) \ - ( (This)->lpVtbl -> CreateTexture3D(This,pDesc,pInitialData,ppTexture3D) ) - -#define ID3D10Device_CreateTextureCube(This,pDesc,pInitialData,ppTextureCube) \ - ( (This)->lpVtbl -> CreateTextureCube(This,pDesc,pInitialData,ppTextureCube) ) - -#define ID3D10Device_CreateShaderResourceView(This,pResource,pDesc,ppSRView) \ - ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,ppSRView) ) - -#define ID3D10Device_CreateRenderTargetView(This,pResource,pDesc,ppRTView) \ - ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,ppRTView) ) - -#define ID3D10Device_CreateDepthStencilView(This,pResource,pDesc,ppDepthStencilView) \ - ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,ppDepthStencilView) ) - -#define ID3D10Device_CreateInputLayout(This,pInputElementDescs,NumElements,pShaderBytecodeWithInputSignature,ppInputLayout) \ - ( (This)->lpVtbl -> CreateInputLayout(This,pInputElementDescs,NumElements,pShaderBytecodeWithInputSignature,ppInputLayout) ) - -#define ID3D10Device_CreateVertexShader(This,pShaderBytecode,ppVertexShader) \ - ( (This)->lpVtbl -> CreateVertexShader(This,pShaderBytecode,ppVertexShader) ) - -#define ID3D10Device_CreateGeometryShader(This,pShaderBytecode,ppGeometryShader) \ - ( (This)->lpVtbl -> CreateGeometryShader(This,pShaderBytecode,ppGeometryShader) ) - -#define ID3D10Device_CreateGeometryShaderWithStreamOutput(This,pShaderBytecode,pSODeclaration,NumEntries,OutputStreamStride,ppGeometryShader) \ - ( (This)->lpVtbl -> CreateGeometryShaderWithStreamOutput(This,pShaderBytecode,pSODeclaration,NumEntries,OutputStreamStride,ppGeometryShader) ) - -#define ID3D10Device_CreatePixelShader(This,pShaderBytecode,ppPixelShader) \ - ( (This)->lpVtbl -> CreatePixelShader(This,pShaderBytecode,ppPixelShader) ) - -#define ID3D10Device_CreateBlendState(This,pBlendStateDesc,ppBlendState) \ - ( (This)->lpVtbl -> CreateBlendState(This,pBlendStateDesc,ppBlendState) ) - -#define ID3D10Device_CreateDepthStencilState(This,pDepthStencilDesc,ppDepthStencilState) \ - ( (This)->lpVtbl -> CreateDepthStencilState(This,pDepthStencilDesc,ppDepthStencilState) ) - -#define ID3D10Device_CreateRasterizerState(This,pRasterizerDesc,ppRasterizerState) \ - ( (This)->lpVtbl -> CreateRasterizerState(This,pRasterizerDesc,ppRasterizerState) ) - -#define ID3D10Device_CreateSamplerState(This,pSamplerDesc,ppSamplerState) \ - ( (This)->lpVtbl -> CreateSamplerState(This,pSamplerDesc,ppSamplerState) ) - -#define ID3D10Device_CreateQuery(This,pQueryDesc,ppQuery) \ - ( (This)->lpVtbl -> CreateQuery(This,pQueryDesc,ppQuery) ) - -#define ID3D10Device_CreatePredicate(This,pPredicateDesc,ppPredicate) \ - ( (This)->lpVtbl -> CreatePredicate(This,pPredicateDesc,ppPredicate) ) - -#define ID3D10Device_CreateCounter(This,pCounterDesc,ppCounter) \ - ( (This)->lpVtbl -> CreateCounter(This,pCounterDesc,ppCounter) ) - -#define ID3D10Device_CheckFormatSupport(This,Format,pFormatSupport) \ - ( (This)->lpVtbl -> CheckFormatSupport(This,Format,pFormatSupport) ) - -#define ID3D10Device_CheckMultisampleQualityLevels(This,SampleCount,pNumQualityLevels) \ - ( (This)->lpVtbl -> CheckMultisampleQualityLevels(This,SampleCount,pNumQualityLevels) ) - -#define ID3D10Device_CheckVertexCache(This,pVertexCacheDesc) \ - ( (This)->lpVtbl -> CheckVertexCache(This,pVertexCacheDesc) ) - -#define ID3D10Device_CheckCounterInfo(This,pCounterInfo) \ - ( (This)->lpVtbl -> CheckCounterInfo(This,pCounterInfo) ) - -#define ID3D10Device_CheckCounter(This,pDesc,pType,pActiveCounters,wszName,pNameLength,wszUnits,pUnitsLength,wszDescription,pDescriptionLength) \ - ( (This)->lpVtbl -> CheckCounter(This,pDesc,pType,pActiveCounters,wszName,pNameLength,wszUnits,pUnitsLength,wszDescription,pDescriptionLength) ) - -#define ID3D10Device_GetCreationFlags(This) \ - ( (This)->lpVtbl -> GetCreationFlags(This) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10Device_INTERFACE_DEFINED__ */ - - -#ifndef __ID3D10StateMirror_INTERFACE_DEFINED__ -#define __ID3D10StateMirror_INTERFACE_DEFINED__ - -/* interface ID3D10StateMirror */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10StateMirror; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4D0F-342C-4106-A19F-4F2704F689F0") - ID3D10StateMirror : public IUnknown - { - public: - virtual void STDMETHODCALLTYPE GetBufferDesc( - /* [in] */ ID3D10Buffer *pBuffer, - /* [retval][out] */ D3D10_BUFFER_DESC *pDesc) = 0; - - virtual void STDMETHODCALLTYPE GetTexture1DDesc( - /* [in] */ ID3D10Texture1D *pTexture1D, - /* [retval][out] */ D3D10_TEXTURE1D_DESC *pDesc) = 0; - - virtual void STDMETHODCALLTYPE GetTexture2DDesc( - /* [in] */ ID3D10Texture2D *pTexture2D, - /* [retval][out] */ D3D10_TEXTURE2D_DESC *pDesc) = 0; - - virtual void STDMETHODCALLTYPE GetTexture3DDesc( - /* [in] */ ID3D10Texture3D *pTexture3D, - /* [retval][out] */ D3D10_TEXTURE3D_DESC *pDesc) = 0; - - virtual void STDMETHODCALLTYPE GetTextureCubeDesc( - /* [in] */ ID3D10TextureCube *pTextureCube, - /* [retval][out] */ D3D10_TEXTURECUBE_DESC *pDesc) = 0; - - virtual void STDMETHODCALLTYPE GetShaderResourceViewDesc( - /* [in] */ ID3D10ShaderResourceView *pShaderResourceView, - /* [retval][out] */ D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc) = 0; - - virtual void STDMETHODCALLTYPE GetRenderTargetViewDesc( - /* [in] */ ID3D10RenderTargetView *pRenderTargetView, - /* [retval][out] */ D3D10_RENDER_TARGET_VIEW_DESC *pDesc) = 0; - - virtual void STDMETHODCALLTYPE GetDepthStencilViewDesc( - /* [in] */ ID3D10DepthStencilView *pDepthStencilView, - /* [retval][out] */ D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetVertexShaderDesc( - /* [in] */ ID3D10VertexShader *pShader, - /* [out][in] */ D3D10_VERTEX_SHADER_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetGeometryShaderDesc( - /* [in] */ ID3D10GeometryShader *pShader, - /* [out][in] */ D3D10_GEOMETRY_SHADER_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetPixelShaderDesc( - /* [in] */ ID3D10PixelShader *pShader, - /* [out][in] */ D3D10_PIXEL_SHADER_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetInputLayoutDesc( - /* [in] */ ID3D10InputLayout *pInputLayout, - /* [out][in] */ D3D10_INPUT_LAYOUT_DESC *pDesc) = 0; - - virtual SIZE_T STDMETHODCALLTYPE GetInputLayoutDeclarationElements( - /* [in] */ ID3D10InputLayout *pInputLayout) = 0; - - virtual void STDMETHODCALLTYPE GetSamplerDesc( - /* [in] */ ID3D10SamplerState *pSampler, - /* [retval][out] */ D3D10_SAMPLER_DESC *pDesc) = 0; - - virtual void STDMETHODCALLTYPE GetBlendStateDesc( - /* [in] */ ID3D10BlendState *pBlendState, - /* [retval][out] */ D3D10_BLEND_DESC *pDesc) = 0; - - virtual void STDMETHODCALLTYPE GetDepthStencilStateDesc( - /* [in] */ ID3D10DepthStencilState *pDepthStencilState, - /* [retval][out] */ D3D10_DEPTH_STENCIL_DESC *pDesc) = 0; - - virtual void STDMETHODCALLTYPE GetRasterizerStateDesc( - /* [in] */ ID3D10RasterizerState *pRasterizerState, - /* [retval][out] */ D3D10_RASTERIZER_DESC *pDesc) = 0; - - virtual void STDMETHODCALLTYPE GetQueryDesc( - /* [in] */ ID3D10Query *pQuery, - /* [retval][out] */ D3D10_QUERY_DESC *pDesc) = 0; - - virtual void STDMETHODCALLTYPE GetCounterDesc( - /* [in] */ ID3D10Counter *pCounter, - /* [retval][out] */ D3D10_COUNTER_DESC *pDesc) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10StateMirrorVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10StateMirror * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10StateMirror * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10StateMirror * This); - - void ( STDMETHODCALLTYPE *GetBufferDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10Buffer *pBuffer, - /* [retval][out] */ D3D10_BUFFER_DESC *pDesc); - - void ( STDMETHODCALLTYPE *GetTexture1DDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10Texture1D *pTexture1D, - /* [retval][out] */ D3D10_TEXTURE1D_DESC *pDesc); - - void ( STDMETHODCALLTYPE *GetTexture2DDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10Texture2D *pTexture2D, - /* [retval][out] */ D3D10_TEXTURE2D_DESC *pDesc); - - void ( STDMETHODCALLTYPE *GetTexture3DDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10Texture3D *pTexture3D, - /* [retval][out] */ D3D10_TEXTURE3D_DESC *pDesc); - - void ( STDMETHODCALLTYPE *GetTextureCubeDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10TextureCube *pTextureCube, - /* [retval][out] */ D3D10_TEXTURECUBE_DESC *pDesc); - - void ( STDMETHODCALLTYPE *GetShaderResourceViewDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10ShaderResourceView *pShaderResourceView, - /* [retval][out] */ D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc); - - void ( STDMETHODCALLTYPE *GetRenderTargetViewDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10RenderTargetView *pRenderTargetView, - /* [retval][out] */ D3D10_RENDER_TARGET_VIEW_DESC *pDesc); - - void ( STDMETHODCALLTYPE *GetDepthStencilViewDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10DepthStencilView *pDepthStencilView, - /* [retval][out] */ D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *GetVertexShaderDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10VertexShader *pShader, - /* [out][in] */ D3D10_VERTEX_SHADER_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *GetGeometryShaderDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10GeometryShader *pShader, - /* [out][in] */ D3D10_GEOMETRY_SHADER_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *GetPixelShaderDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10PixelShader *pShader, - /* [out][in] */ D3D10_PIXEL_SHADER_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *GetInputLayoutDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10InputLayout *pInputLayout, - /* [out][in] */ D3D10_INPUT_LAYOUT_DESC *pDesc); - - SIZE_T ( STDMETHODCALLTYPE *GetInputLayoutDeclarationElements )( - ID3D10StateMirror * This, - /* [in] */ ID3D10InputLayout *pInputLayout); - - void ( STDMETHODCALLTYPE *GetSamplerDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10SamplerState *pSampler, - /* [retval][out] */ D3D10_SAMPLER_DESC *pDesc); - - void ( STDMETHODCALLTYPE *GetBlendStateDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10BlendState *pBlendState, - /* [retval][out] */ D3D10_BLEND_DESC *pDesc); - - void ( STDMETHODCALLTYPE *GetDepthStencilStateDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10DepthStencilState *pDepthStencilState, - /* [retval][out] */ D3D10_DEPTH_STENCIL_DESC *pDesc); - - void ( STDMETHODCALLTYPE *GetRasterizerStateDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10RasterizerState *pRasterizerState, - /* [retval][out] */ D3D10_RASTERIZER_DESC *pDesc); - - void ( STDMETHODCALLTYPE *GetQueryDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10Query *pQuery, - /* [retval][out] */ D3D10_QUERY_DESC *pDesc); - - void ( STDMETHODCALLTYPE *GetCounterDesc )( - ID3D10StateMirror * This, - /* [in] */ ID3D10Counter *pCounter, - /* [retval][out] */ D3D10_COUNTER_DESC *pDesc); - - END_INTERFACE - } ID3D10StateMirrorVtbl; - - interface ID3D10StateMirror - { - CONST_VTBL struct ID3D10StateMirrorVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10StateMirror_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10StateMirror_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10StateMirror_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10StateMirror_GetBufferDesc(This,pBuffer,pDesc) \ - ( (This)->lpVtbl -> GetBufferDesc(This,pBuffer,pDesc) ) - -#define ID3D10StateMirror_GetTexture1DDesc(This,pTexture1D,pDesc) \ - ( (This)->lpVtbl -> GetTexture1DDesc(This,pTexture1D,pDesc) ) - -#define ID3D10StateMirror_GetTexture2DDesc(This,pTexture2D,pDesc) \ - ( (This)->lpVtbl -> GetTexture2DDesc(This,pTexture2D,pDesc) ) - -#define ID3D10StateMirror_GetTexture3DDesc(This,pTexture3D,pDesc) \ - ( (This)->lpVtbl -> GetTexture3DDesc(This,pTexture3D,pDesc) ) - -#define ID3D10StateMirror_GetTextureCubeDesc(This,pTextureCube,pDesc) \ - ( (This)->lpVtbl -> GetTextureCubeDesc(This,pTextureCube,pDesc) ) - -#define ID3D10StateMirror_GetShaderResourceViewDesc(This,pShaderResourceView,pDesc) \ - ( (This)->lpVtbl -> GetShaderResourceViewDesc(This,pShaderResourceView,pDesc) ) - -#define ID3D10StateMirror_GetRenderTargetViewDesc(This,pRenderTargetView,pDesc) \ - ( (This)->lpVtbl -> GetRenderTargetViewDesc(This,pRenderTargetView,pDesc) ) - -#define ID3D10StateMirror_GetDepthStencilViewDesc(This,pDepthStencilView,pDesc) \ - ( (This)->lpVtbl -> GetDepthStencilViewDesc(This,pDepthStencilView,pDesc) ) - -#define ID3D10StateMirror_GetVertexShaderDesc(This,pShader,pDesc) \ - ( (This)->lpVtbl -> GetVertexShaderDesc(This,pShader,pDesc) ) - -#define ID3D10StateMirror_GetGeometryShaderDesc(This,pShader,pDesc) \ - ( (This)->lpVtbl -> GetGeometryShaderDesc(This,pShader,pDesc) ) - -#define ID3D10StateMirror_GetPixelShaderDesc(This,pShader,pDesc) \ - ( (This)->lpVtbl -> GetPixelShaderDesc(This,pShader,pDesc) ) - -#define ID3D10StateMirror_GetInputLayoutDesc(This,pInputLayout,pDesc) \ - ( (This)->lpVtbl -> GetInputLayoutDesc(This,pInputLayout,pDesc) ) - -#define ID3D10StateMirror_GetInputLayoutDeclarationElements(This,pInputLayout) \ - ( (This)->lpVtbl -> GetInputLayoutDeclarationElements(This,pInputLayout) ) - -#define ID3D10StateMirror_GetSamplerDesc(This,pSampler,pDesc) \ - ( (This)->lpVtbl -> GetSamplerDesc(This,pSampler,pDesc) ) - -#define ID3D10StateMirror_GetBlendStateDesc(This,pBlendState,pDesc) \ - ( (This)->lpVtbl -> GetBlendStateDesc(This,pBlendState,pDesc) ) - -#define ID3D10StateMirror_GetDepthStencilStateDesc(This,pDepthStencilState,pDesc) \ - ( (This)->lpVtbl -> GetDepthStencilStateDesc(This,pDepthStencilState,pDesc) ) - -#define ID3D10StateMirror_GetRasterizerStateDesc(This,pRasterizerState,pDesc) \ - ( (This)->lpVtbl -> GetRasterizerStateDesc(This,pRasterizerState,pDesc) ) - -#define ID3D10StateMirror_GetQueryDesc(This,pQuery,pDesc) \ - ( (This)->lpVtbl -> GetQueryDesc(This,pQuery,pDesc) ) - -#define ID3D10StateMirror_GetCounterDesc(This,pCounter,pDesc) \ - ( (This)->lpVtbl -> GetCounterDesc(This,pCounter,pDesc) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10StateMirror_INTERFACE_DEFINED__ */ - - -#ifndef __ID3D10Multithread_INTERFACE_DEFINED__ -#define __ID3D10Multithread_INTERFACE_DEFINED__ - -/* interface ID3D10Multithread */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10Multithread; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4E00-342C-4106-A19F-4F2704F689F0") - ID3D10Multithread : public IUnknown - { - public: - virtual BOOL STDMETHODCALLTYPE SetMultithreadProtected( - /* [in] */ BOOL bMTProtect) = 0; - - virtual BOOL STDMETHODCALLTYPE GetMultithreadProtected( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10MultithreadVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10Multithread * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10Multithread * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10Multithread * This); - - BOOL ( STDMETHODCALLTYPE *SetMultithreadProtected )( - ID3D10Multithread * This, - /* [in] */ BOOL bMTProtect); - - BOOL ( STDMETHODCALLTYPE *GetMultithreadProtected )( - ID3D10Multithread * This); - - END_INTERFACE - } ID3D10MultithreadVtbl; - - interface ID3D10Multithread - { - CONST_VTBL struct ID3D10MultithreadVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10Multithread_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10Multithread_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10Multithread_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10Multithread_SetMultithreadProtected(This,bMTProtect) \ - ( (This)->lpVtbl -> SetMultithreadProtected(This,bMTProtect) ) - -#define ID3D10Multithread_GetMultithreadProtected(This) \ - ( (This)->lpVtbl -> GetMultithreadProtected(This) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10Multithread_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10_0000_0026 */ -/* [local] */ - -typedef -enum D3D10_CREATE_DEVICE_FLAG - { D3D10_CREATE_DEVICE_SINGLETHREADED = 0x1, - D3D10_CREATE_DEVICE_MIRROR_STATE = 0x2, - D3D10_CREATE_DEVICE_DEBUG = 0x4 - } D3D10_CREATE_DEVICE_FLAG; - - -#define D3D10_SDK_VERSION ( 20 ) - -#if !defined( D3D10_IGNORE_SDK_LAYERS ) -#include "d3d10sdklayers.h" -#endif -#include "d3d10misc.h" -#include "d3d10shader.h" -#include "d3d10effect.h" - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0026_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0026_v0_0_s_ifspec; - -/* Additional Prototypes for ALL interfaces */ - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 7.00.0485 */ +/* Compiler settings for d3d10.idl: + Oicf, W1, Zp8, env=Win32 (32b run) + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +//@@MIDL_FILE_HEADING( ) + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCSAL_H_VERSION__ +#define __REQUIRED_RPCSAL_H_VERSION__ 100 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif // __RPCNDR_H_VERSION__ + +#ifndef COM_NO_WINDOWS_H +#include "windows.h" +#include "ole2.h" +#endif /*COM_NO_WINDOWS_H*/ + +#ifndef __d3d10_h__ +#define __d3d10_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +#ifndef __ID3D10DeviceChild_FWD_DEFINED__ +#define __ID3D10DeviceChild_FWD_DEFINED__ +typedef interface ID3D10DeviceChild ID3D10DeviceChild; +#endif /* __ID3D10DeviceChild_FWD_DEFINED__ */ + + +#ifndef __ID3D10DepthStencilState_FWD_DEFINED__ +#define __ID3D10DepthStencilState_FWD_DEFINED__ +typedef interface ID3D10DepthStencilState ID3D10DepthStencilState; +#endif /* __ID3D10DepthStencilState_FWD_DEFINED__ */ + + +#ifndef __ID3D10BlendState_FWD_DEFINED__ +#define __ID3D10BlendState_FWD_DEFINED__ +typedef interface ID3D10BlendState ID3D10BlendState; +#endif /* __ID3D10BlendState_FWD_DEFINED__ */ + + +#ifndef __ID3D10RasterizerState_FWD_DEFINED__ +#define __ID3D10RasterizerState_FWD_DEFINED__ +typedef interface ID3D10RasterizerState ID3D10RasterizerState; +#endif /* __ID3D10RasterizerState_FWD_DEFINED__ */ + + +#ifndef __ID3D10Resource_FWD_DEFINED__ +#define __ID3D10Resource_FWD_DEFINED__ +typedef interface ID3D10Resource ID3D10Resource; +#endif /* __ID3D10Resource_FWD_DEFINED__ */ + + +#ifndef __ID3D10Buffer_FWD_DEFINED__ +#define __ID3D10Buffer_FWD_DEFINED__ +typedef interface ID3D10Buffer ID3D10Buffer; +#endif /* __ID3D10Buffer_FWD_DEFINED__ */ + + +#ifndef __ID3D10Texture1D_FWD_DEFINED__ +#define __ID3D10Texture1D_FWD_DEFINED__ +typedef interface ID3D10Texture1D ID3D10Texture1D; +#endif /* __ID3D10Texture1D_FWD_DEFINED__ */ + + +#ifndef __ID3D10Texture2D_FWD_DEFINED__ +#define __ID3D10Texture2D_FWD_DEFINED__ +typedef interface ID3D10Texture2D ID3D10Texture2D; +#endif /* __ID3D10Texture2D_FWD_DEFINED__ */ + + +#ifndef __ID3D10Texture3D_FWD_DEFINED__ +#define __ID3D10Texture3D_FWD_DEFINED__ +typedef interface ID3D10Texture3D ID3D10Texture3D; +#endif /* __ID3D10Texture3D_FWD_DEFINED__ */ + + +#ifndef __ID3D10TextureCube_FWD_DEFINED__ +#define __ID3D10TextureCube_FWD_DEFINED__ +typedef interface ID3D10TextureCube ID3D10TextureCube; +#endif /* __ID3D10TextureCube_FWD_DEFINED__ */ + + +#ifndef __ID3D10View_FWD_DEFINED__ +#define __ID3D10View_FWD_DEFINED__ +typedef interface ID3D10View ID3D10View; +#endif /* __ID3D10View_FWD_DEFINED__ */ + + +#ifndef __ID3D10ShaderResourceView_FWD_DEFINED__ +#define __ID3D10ShaderResourceView_FWD_DEFINED__ +typedef interface ID3D10ShaderResourceView ID3D10ShaderResourceView; +#endif /* __ID3D10ShaderResourceView_FWD_DEFINED__ */ + + +#ifndef __ID3D10RenderTargetView_FWD_DEFINED__ +#define __ID3D10RenderTargetView_FWD_DEFINED__ +typedef interface ID3D10RenderTargetView ID3D10RenderTargetView; +#endif /* __ID3D10RenderTargetView_FWD_DEFINED__ */ + + +#ifndef __ID3D10DepthStencilView_FWD_DEFINED__ +#define __ID3D10DepthStencilView_FWD_DEFINED__ +typedef interface ID3D10DepthStencilView ID3D10DepthStencilView; +#endif /* __ID3D10DepthStencilView_FWD_DEFINED__ */ + + +#ifndef __ID3D10VertexShader_FWD_DEFINED__ +#define __ID3D10VertexShader_FWD_DEFINED__ +typedef interface ID3D10VertexShader ID3D10VertexShader; +#endif /* __ID3D10VertexShader_FWD_DEFINED__ */ + + +#ifndef __ID3D10GeometryShader_FWD_DEFINED__ +#define __ID3D10GeometryShader_FWD_DEFINED__ +typedef interface ID3D10GeometryShader ID3D10GeometryShader; +#endif /* __ID3D10GeometryShader_FWD_DEFINED__ */ + + +#ifndef __ID3D10PixelShader_FWD_DEFINED__ +#define __ID3D10PixelShader_FWD_DEFINED__ +typedef interface ID3D10PixelShader ID3D10PixelShader; +#endif /* __ID3D10PixelShader_FWD_DEFINED__ */ + + +#ifndef __ID3D10InputLayout_FWD_DEFINED__ +#define __ID3D10InputLayout_FWD_DEFINED__ +typedef interface ID3D10InputLayout ID3D10InputLayout; +#endif /* __ID3D10InputLayout_FWD_DEFINED__ */ + + +#ifndef __ID3D10SamplerState_FWD_DEFINED__ +#define __ID3D10SamplerState_FWD_DEFINED__ +typedef interface ID3D10SamplerState ID3D10SamplerState; +#endif /* __ID3D10SamplerState_FWD_DEFINED__ */ + + +#ifndef __ID3D10Asynchronous_FWD_DEFINED__ +#define __ID3D10Asynchronous_FWD_DEFINED__ +typedef interface ID3D10Asynchronous ID3D10Asynchronous; +#endif /* __ID3D10Asynchronous_FWD_DEFINED__ */ + + +#ifndef __ID3D10Query_FWD_DEFINED__ +#define __ID3D10Query_FWD_DEFINED__ +typedef interface ID3D10Query ID3D10Query; +#endif /* __ID3D10Query_FWD_DEFINED__ */ + + +#ifndef __ID3D10Predicate_FWD_DEFINED__ +#define __ID3D10Predicate_FWD_DEFINED__ +typedef interface ID3D10Predicate ID3D10Predicate; +#endif /* __ID3D10Predicate_FWD_DEFINED__ */ + + +#ifndef __ID3D10Counter_FWD_DEFINED__ +#define __ID3D10Counter_FWD_DEFINED__ +typedef interface ID3D10Counter ID3D10Counter; +#endif /* __ID3D10Counter_FWD_DEFINED__ */ + + +#ifndef __ID3D10Device_FWD_DEFINED__ +#define __ID3D10Device_FWD_DEFINED__ +typedef interface ID3D10Device ID3D10Device; +#endif /* __ID3D10Device_FWD_DEFINED__ */ + + +#ifndef __ID3D10StateMirror_FWD_DEFINED__ +#define __ID3D10StateMirror_FWD_DEFINED__ +typedef interface ID3D10StateMirror ID3D10StateMirror; +#endif /* __ID3D10StateMirror_FWD_DEFINED__ */ + + +#ifndef __ID3D10Multithread_FWD_DEFINED__ +#define __ID3D10Multithread_FWD_DEFINED__ +typedef interface ID3D10Multithread ID3D10Multithread; +#endif /* __ID3D10Multithread_FWD_DEFINED__ */ + + +/* header files for imported files */ +#include "oaidl.h" +#include "ocidl.h" +#include "dxgi.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +/* interface __MIDL_itf_d3d10_0000_0000 */ +/* [local] */ + +#ifndef _D3D10_CONSTANTS +#define _D3D10_CONSTANTS +#define D3D10_16BIT_INDEX_STRIP_CUT_VALUE ( 0xffff ) + +#define D3D10_32BIT_INDEX_STRIP_CUT_VALUE ( 0xffffffff ) + +#define D3D10_8BIT_INDEX_STRIP_CUT_VALUE ( 0xff ) + +#define D3D10_ARRAY_AXIS_ADDRESS_RANGE_BIT_COUNT ( 9 ) + +#define D3D10_CLIP_OR_CULL_DISTANCE_COUNT ( 8 ) + +#define D3D10_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT ( 2 ) + +#define D3D10_COMMONSHADER_CONSTANT_BUFFER_COMPONENTS ( 4 ) + +#define D3D10_COMMONSHADER_CONSTANT_BUFFER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COMPONENTS ( 4 ) + +#define D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COUNT ( 15 ) + +#define D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READS_PER_INST ( 1 ) + +#define D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READ_PORTS ( 1 ) + +#define D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT ( 15 ) + +#define D3D10_COMMONSHADER_FLOWCONTROL_NESTING_LIMIT ( 64 ) + +#define D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COMPONENTS ( 4 ) + +#define D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COUNT ( 1 ) + +#define D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READS_PER_INST ( 1 ) + +#define D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READ_PORTS ( 1 ) + +#define D3D10_COMMONSHADER_IMMEDIATE_VALUE_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_COMPONENTS ( 1 ) + +#define D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT ( 128 ) + +#define D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_READS_PER_INST ( 1 ) + +#define D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_READ_PORTS ( 1 ) + +#define D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT ( 128 ) + +#define D3D10_COMMONSHADER_SAMPLER_REGISTER_COMPONENTS ( 1 ) + +#define D3D10_COMMONSHADER_SAMPLER_REGISTER_COUNT ( 16 ) + +#define D3D10_COMMONSHADER_SAMPLER_REGISTER_READS_PER_INST ( 1 ) + +#define D3D10_COMMONSHADER_SAMPLER_REGISTER_READ_PORTS ( 1 ) + +#define D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT ( 16 ) + +#define D3D10_COMMONSHADER_SUBROUTINE_NESTING_LIMIT ( 32 ) + +#define D3D10_COMMONSHADER_TEMP_REGISTER_COMPONENTS ( 4 ) + +#define D3D10_COMMONSHADER_TEMP_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D10_COMMONSHADER_TEMP_REGISTER_COUNT ( 4096 ) + +#define D3D10_COMMONSHADER_TEMP_REGISTER_READS_PER_INST ( 3 ) + +#define D3D10_COMMONSHADER_TEMP_REGISTER_READ_PORTS ( 3 ) + +#define D3D10_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MAX ( 10 ) + +#define D3D10_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MIN ( -10 ) + +#define D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE ( -8 ) + +#define D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE ( 7 ) + +#define D3D10_DEFAULT_BLEND_FACTOR_ALPHA ( 1.0f ) +#define D3D10_DEFAULT_BLEND_FACTOR_BLUE ( 1.0f ) +#define D3D10_DEFAULT_BLEND_FACTOR_GREEN ( 1.0f ) +#define D3D10_DEFAULT_BLEND_FACTOR_RED ( 1.0f ) +#define D3D10_DEFAULT_BORDER_COLOR_COMPONENT ( 0.0f ) +#define D3D10_DEFAULT_DEPTH_BIAS ( 0 ) + +#define D3D10_DEFAULT_DEPTH_BIAS_CLAMP ( 0.0f ) +#define D3D10_DEFAULT_MAX_ANISOTROPY ( 16.0f ) +#define D3D10_DEFAULT_MIP_LOD_BIAS ( 0.0f ) +#define D3D10_DEFAULT_RENDER_TARGET_ARRAY_INDEX ( 0 ) + +#define D3D10_DEFAULT_SAMPLE_MASK ( 0xffffffff ) + +#define D3D10_DEFAULT_SCISSOR_ENDX ( 0 ) + +#define D3D10_DEFAULT_SCISSOR_ENDY ( 0 ) + +#define D3D10_DEFAULT_SCISSOR_STARTX ( 0 ) + +#define D3D10_DEFAULT_SCISSOR_STARTY ( 0 ) + +#define D3D10_DEFAULT_SLOPE_SCALED_DEPTH_BIAS ( 0.0f ) +#define D3D10_DEFAULT_STENCIL_READ_MASK ( 0xff ) + +#define D3D10_DEFAULT_STENCIL_REFERENCE ( 0 ) + +#define D3D10_DEFAULT_STENCIL_WRITE_MASK ( 0xff ) + +#define D3D10_DEFAULT_VIEWPORT_AND_SCISSORRECT_INDEX ( 0 ) + +#define D3D10_DEFAULT_VIEWPORT_HEIGHT ( 0.0f ) +#define D3D10_DEFAULT_VIEWPORT_MAX_DEPTH ( 0.0f ) +#define D3D10_DEFAULT_VIEWPORT_MIN_DEPTH ( 0.0f ) +#define D3D10_DEFAULT_VIEWPORT_TOPLEFTX ( 0.0f ) +#define D3D10_DEFAULT_VIEWPORT_TOPLEFTY ( 0.0f ) +#define D3D10_DEFAULT_VIEWPORT_WIDTH ( 0.0f ) +#define D3D10_FLOAT16_FUSED_TOLERANCE_IN_ULP ( 0.6 ) +#define D3D10_FLOAT32_DEPTH_BUFFER_EXPONENT_BIAS ( 23 ) + +#define D3D10_FLOAT32_MAX ( 3.402823466e+38f ) +#define D3D10_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP ( 0.6f ) +#define D3D10_FLOAT_TO_SRGB_EXPONENT_DENOMINATOR ( 2.4f ) +#define D3D10_FLOAT_TO_SRGB_EXPONENT_NUMERATOR ( 1.0f ) +#define D3D10_FLOAT_TO_SRGB_OFFSET ( 0.055f ) +#define D3D10_FLOAT_TO_SRGB_SCALE_1 ( 12.92f ) +#define D3D10_FLOAT_TO_SRGB_SCALE_2 ( 1.055f ) +#define D3D10_FLOAT_TO_SRGB_THRESHOLD ( 0.0031308f ) +#define D3D10_FTOI_INSTRUCTION_MAX_INPUT ( 2147483647.999f ) +#define D3D10_FTOI_INSTRUCTION_MIN_INPUT ( -2147483648.999f ) +#define D3D10_FTOU_INSTRUCTION_MAX_INPUT ( 4294967296.999f ) +#define D3D10_FTOU_INSTRUCTION_MIN_INPUT ( 0.0f ) +#define D3D10_GS_INPUT_PRIM_CONST_REGISTER_COMPONENTS ( 1 ) + +#define D3D10_GS_INPUT_PRIM_CONST_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D10_GS_INPUT_PRIM_CONST_REGISTER_COUNT ( 1 ) + +#define D3D10_GS_INPUT_PRIM_CONST_REGISTER_READS_PER_INST ( 2 ) + +#define D3D10_GS_INPUT_PRIM_CONST_REGISTER_READ_PORTS ( 1 ) + +#define D3D10_GS_INPUT_REGISTER_COMPONENTS ( 4 ) + +#define D3D10_GS_INPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D10_GS_INPUT_REGISTER_COUNT ( 16 ) + +#define D3D10_GS_INPUT_REGISTER_READS_PER_INST ( 2 ) + +#define D3D10_GS_INPUT_REGISTER_READ_PORTS ( 1 ) + +#define D3D10_GS_INPUT_REGISTER_VERTICES ( 6 ) + +#define D3D10_GS_OUTPUT_ELEMENTS ( 32 ) + +#define D3D10_GS_OUTPUT_REGISTER_COMPONENTS ( 4 ) + +#define D3D10_GS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D10_GS_OUTPUT_REGISTER_COUNT ( 32 ) + +#define D3D10_IA_DEFAULT_INDEX_BUFFER_OFFSET_IN_BYTES ( 0 ) + +#define D3D10_IA_DEFAULT_PRIMITIVE_TOPOLOGY ( 0 ) + +#define D3D10_IA_DEFAULT_VERTEX_BUFFER_OFFSET_IN_BYTES ( 0 ) + +#define D3D10_IA_INDEX_INPUT_RESOURCE_SLOT_COUNT ( 1 ) + +#define D3D10_IA_INSTANCE_ID_BIT_COUNT ( 32 ) + +#define D3D10_IA_INTEGER_ARITHMETIC_BIT_COUNT ( 32 ) + +#define D3D10_IA_PRIMITIVE_ID_BIT_COUNT ( 32 ) + +#define D3D10_IA_VERTEX_ID_BIT_COUNT ( 32 ) + +#define D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT ( 16 ) + +#define D3D10_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS ( 64 ) + +#define D3D10_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT ( 16 ) + +#define D3D10_INTEGER_DIVIDE_BY_ZERO_QUOTIENT ( 0xffffffff ) + +#define D3D10_INTEGER_DIVIDE_BY_ZERO_REMAINDER ( 0xffffffff ) + +#define D3D10_LINEAR_GAMMA ( 1.0f ) +#define D3D10_MAX_BORDER_COLOR_COMPONENT ( 1.0f ) +#define D3D10_MAX_DEPTH ( 1.0f ) +#define D3D10_MAX_MAXANISOTROPY ( 16 ) + +#define D3D10_MAX_MULTISAMPLE_SAMPLE_COUNT ( 32 ) + +#define D3D10_MAX_POSITION_VALUE ( 3.402823466e+34f ) +#define D3D10_MAX_TEXTURE_DIMENSION_2_TO_EXP ( 17 ) + +#define D3D10_MIN_BORDER_COLOR_COMPONENT ( 0.0f ) +#define D3D10_MIN_DEPTH ( 0.0f ) +#define D3D10_MIN_MAXANISOTROPY ( 0 ) + +#define D3D10_MIP_LOD_BIAS_MAX ( 15.99f ) +#define D3D10_MIP_LOD_BIAS_MIN ( -16.0f ) +#define D3D10_MIP_LOD_FRACTIONAL_BIT_COUNT ( 6 ) + +#define D3D10_MIP_LOD_RANGE_BIT_COUNT ( 8 ) + +#define D3D10_MULTISAMPLE_ANTIALIAS_LINE_WIDTH ( 1.4f ) +#define D3D10_NONSAMPLE_FETCH_OUT_OF_RANGE_ACCESS_RESULT ( 0 ) + +#define D3D10_PIXEL_ADDRESS_RANGE_BIT_COUNT ( 13 ) + +#define D3D10_PRE_SCISSOR_PIXEL_ADDRESS_RANGE_BIT_COUNT ( 15 ) + +#define D3D10_PS_FRONTFACING_DEFAULT_VALUE ( 0xffffffff ) + +#define D3D10_PS_FRONTFACING_FALSE_VALUE ( 0 ) + +#define D3D10_PS_FRONTFACING_TRUE_VALUE ( 0xffffffff ) + +#define D3D10_PS_INPUT_REGISTER_COMPONENTS ( 4 ) + +#define D3D10_PS_INPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D10_PS_INPUT_REGISTER_COUNT ( 32 ) + +#define D3D10_PS_INPUT_REGISTER_READS_PER_INST ( 2 ) + +#define D3D10_PS_INPUT_REGISTER_READ_PORTS ( 1 ) + +#define D3D10_PS_LEGACY_PIXEL_CENTER_FRACTIONAL_COMPONENT ( 0.0f ) +#define D3D10_PS_OUTPUT_DEPTH_REGISTER_COMPONENTS ( 1 ) + +#define D3D10_PS_OUTPUT_DEPTH_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D10_PS_OUTPUT_DEPTH_REGISTER_COUNT ( 1 ) + +#define D3D10_PS_OUTPUT_REGISTER_COMPONENTS ( 4 ) + +#define D3D10_PS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D10_PS_OUTPUT_REGISTER_COUNT ( 8 ) + +#define D3D10_PS_PIXEL_CENTER_FRACTIONAL_COMPONENT ( 0.5f ) +#define D3D10_REQ_BLEND_OBJECT_COUNT_PER_CONTEXT ( 4096 ) + +#define D3D10_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP ( 27 ) + +#define D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT ( 4096 ) + +#define D3D10_REQ_DEPTH_STENCIL_OBJECT_COUNT_PER_CONTEXT ( 4096 ) + +#define D3D10_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP ( 32 ) + +#define D3D10_REQ_DRAW_VERTEX_COUNT_2_TO_EXP ( 32 ) + +#define D3D10_REQ_FILTERING_HW_ADDRESSABLE_RESOURCE_DIMENSION ( 8192 ) + +#define D3D10_REQ_GS_INVOCATION_32BIT_OUTPUT_COMPONENT_LIMIT ( 1024 ) + +#define D3D10_REQ_IMMEDIATE_CONSTANT_BUFFER_ELEMENT_COUNT ( 4096 ) + +#define D3D10_REQ_MAXANISOTROPY ( 16 ) + +#define D3D10_REQ_MIP_LEVELS ( 13 ) + +#define D3D10_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES ( 2048 ) + +#define D3D10_REQ_RASTERIZER_OBJECT_COUNT_PER_CONTEXT ( 4096 ) + +#define D3D10_REQ_RENDER_TO_BUFFER_WINDOW_WIDTH ( 8192 ) + +#define D3D10_REQ_RESOURCE_SIZE_IN_MEGABYTES ( 128 ) + +#define D3D10_REQ_RESOURCE_VIEW_COUNT_PER_CONTEXT_2_TO_EXP ( 20 ) + +#define D3D10_REQ_SAMPLER_OBJECT_COUNT_PER_CONTEXT ( 4096 ) + +#define D3D10_REQ_SHADER_INVOCATION_INSTRUCTION_COUNT ( 65536 ) + +#define D3D10_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION ( 512 ) + +#define D3D10_REQ_TEXTURE1D_U_DIMENSION ( 8192 ) + +#define D3D10_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION ( 512 ) + +#define D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION ( 8192 ) + +#define D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION ( 2048 ) + +#define D3D10_REQ_TEXTURECUBE_DIMENSION ( 8192 ) + +#define D3D10_RESINFO_INSTRUCTION_MISSING_COMPONENT_RETVAL ( 0 ) + +#define D3D10_SHADER_MAJOR_VERSION ( 4 ) + +#define D3D10_SHADER_MINOR_VERSION ( 0 ) + +#define D3D10_SHIFT_INSTRUCTION_PAD_VALUE ( 0 ) + +#define D3D10_SHIFT_INSTRUCTION_SHIFT_VALUE_BIT_COUNT ( 5 ) + +#define D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT ( 8 ) + +#define D3D10_SO_BUFFER_MAX_STRIDE_IN_BYTES ( 2048 ) + +#define D3D10_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES ( 256 ) + +#define D3D10_SO_BUFFER_SLOT_COUNT ( 4 ) + +#define D3D10_SO_DDI_REGISTER_INDEX_DENOTING_GAP ( 0xffffffff ) + +#define D3D10_SO_MULTIPLE_BUFFER_ELEMENTS_PER_BUFFER ( 1 ) + +#define D3D10_SO_SINGLE_BUFFER_COMPONENT_LIMIT ( 64 ) + +#define D3D10_SRGB_GAMMA ( 2.2f ) +#define D3D10_SRGB_TO_FLOAT_DENOMINATOR_1 ( 12.92f ) +#define D3D10_SRGB_TO_FLOAT_DENOMINATOR_2 ( 1.055f ) +#define D3D10_SRGB_TO_FLOAT_EXPONENT ( 2.4f ) +#define D3D10_SRGB_TO_FLOAT_OFFSET ( 0.055f ) +#define D3D10_SRGB_TO_FLOAT_THRESHOLD ( 0.04045f ) +#define D3D10_SRGB_TO_FLOAT_TOLERANCE_IN_ULP ( 0.5f ) +#define D3D10_STANDARD_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D10_STANDARD_COMPONENT_BIT_COUNT_DOUBLED ( 64 ) + +#define D3D10_STANDARD_MAXIMUM_ELEMENT_ALIGNMENT_BYTE_MULTIPLE ( 4 ) + +#define D3D10_STANDARD_PIXEL_COMPONENT_COUNT ( 128 ) + +#define D3D10_STANDARD_PIXEL_ELEMENT_COUNT ( 32 ) + +#define D3D10_STANDARD_VECTOR_SIZE ( 4 ) + +#define D3D10_STANDARD_VERTEX_ELEMENT_COUNT ( 16 ) + +#define D3D10_STANDARD_VERTEX_TOTAL_COMPONENT_COUNT ( 64 ) + +#define D3D10_SUBPIXEL_FRACTIONAL_BIT_COUNT ( 8 ) + +#define D3D10_SUBTEXEL_FRACTIONAL_BIT_COUNT ( 6 ) + +#define D3D10_TEXEL_ADDRESS_RANGE_BIT_COUNT ( 18 ) + +#define D3D10_UNBOUND_MEMORY_ACCESS_RESULT ( 0 ) + +#define D3D10_VIEWPORT_AND_SCISSORRECT_MAX_INDEX ( 15 ) + +#define D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE ( 16 ) + +#define D3D10_VIEWPORT_BOUNDS_MAX ( 16383 ) + +#define D3D10_VIEWPORT_BOUNDS_MIN ( -16384 ) + +#define D3D10_VS_INPUT_REGISTER_COMPONENTS ( 4 ) + +#define D3D10_VS_INPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D10_VS_INPUT_REGISTER_COUNT ( 16 ) + +#define D3D10_VS_INPUT_REGISTER_READS_PER_INST ( 2 ) + +#define D3D10_VS_INPUT_REGISTER_READ_PORTS ( 1 ) + +#define D3D10_VS_OUTPUT_REGISTER_COMPONENTS ( 4 ) + +#define D3D10_VS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D10_VS_OUTPUT_REGISTER_COUNT ( 16 ) + +#define D3D10_WHQL_CONTEXT_COUNT_FOR_RESOURCE_LIMIT ( 10 ) + +#define D3D10_WHQL_DRAWINDEXED_INDEX_COUNT_2_TO_EXP ( 25 ) + +#define D3D10_WHQL_DRAW_VERTEX_COUNT_2_TO_EXP ( 25 ) + +#define D3D_MAJOR_VERSION ( 10 ) + +#define D3D_MINOR_VERSION ( 0 ) + +#define D3D_SPEC_DATE_DAY ( 8 ) + +#define D3D_SPEC_DATE_MONTH ( 8 ) + +#define D3D_SPEC_DATE_YEAR ( 2005 ) + +#define D3D_SPEC_VERSION ( 1.03000002 ) +#define WGF_MAJOR_VERSION ( 2 ) + +#define WGF_MINOR_VERSION ( 0 ) + +#endif +#define _FACD3D10 ( 0x879 ) + +#define _FACD3D10DEBUG ( ( _FACD3D10 + 1 ) ) + +#define MAKE_D3D10HRESULT( code ) MAKE_HRESULT( 1, _FACD3D10, code ) +#define D3D10_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS MAKE_D3D10HRESULT(1) +#define D3D10_ERROR_FILE_NOT_FOUND MAKE_D3D10HRESULT(2) +typedef +enum D3D10_INPUT_CLASSIFICATION + { D3D10_INPUT_PER_VERTEX_DATA = 0, + D3D10_INPUT_PER_INSTANCE_DATA = 1 + } D3D10_INPUT_CLASSIFICATION; + +typedef struct D3D10_INPUT_ELEMENT_DESC + { + LPCWSTR SemanticName; + UINT SemanticIndex; + DXGI_FORMAT Format; + UINT InputSlot; + UINT AlignedByteOffset; + D3D10_INPUT_CLASSIFICATION InputSlotClass; + UINT InstanceDataStepRate; + } D3D10_INPUT_ELEMENT_DESC; + +typedef +enum D3D10_FILL_MODE + { D3D10_FILL_WIREFRAME = 2, + D3D10_FILL_SOLID = 3 + } D3D10_FILL_MODE; + +typedef +enum D3D10_PRIMITIVE_TOPOLOGY + { D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED = 0, + D3D10_PRIMITIVE_TOPOLOGY_POINTLIST = 1, + D3D10_PRIMITIVE_TOPOLOGY_LINELIST = 2, + D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP = 3, + D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST = 4, + D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP = 5, + D3D10_PRIMITIVE_TOPOLOGY_LINELIST_ADJ = 10, + D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ = 11, + D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ = 12, + D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ = 13 + } D3D10_PRIMITIVE_TOPOLOGY; + +typedef +enum D3D10_PRIMITIVE + { D3D10_PRIMITIVE_UNDEFINED = 0, + D3D10_PRIMITIVE_POINT = 1, + D3D10_PRIMITIVE_LINE = 2, + D3D10_PRIMITIVE_TRIANGLE = 3, + D3D10_PRIMITIVE_LINE_ADJ = 6, + D3D10_PRIMITIVE_TRIANGLE_ADJ = 7 + } D3D10_PRIMITIVE; + +typedef +enum D3D10_CULL_MODE + { D3D10_CULL_NONE = 1, + D3D10_CULL_FRONT = 2, + D3D10_CULL_BACK = 3 + } D3D10_CULL_MODE; + +typedef +enum D3D10_FRONT_WINDING + { D3D10_FRONT_CW = 1, + D3D10_FRONT_CCW = 2 + } D3D10_FRONT_WINDING; + +typedef struct D3D10_VERTEX_CACHE_DESC + { + UINT Pattern; + UINT OptMethod; + UINT CacheSize; + UINT MagicNumber; + } D3D10_VERTEX_CACHE_DESC; + +typedef struct D3D10_SO_DECLARATION_ENTRY + { + LPCWSTR SemanticName; + UINT SemanticIndex; + BYTE StartComponent; + BYTE ComponentCount; + BYTE OutputSlot; + } D3D10_SO_DECLARATION_ENTRY; + +typedef struct D3D10_VIEWPORT + { + FLOAT TopLeftX; + FLOAT TopLeftY; + FLOAT Width; + FLOAT Height; + FLOAT MinDepth; + FLOAT MaxDepth; + } D3D10_VIEWPORT; + +typedef +enum D3D10_RESOURCE + { D3D10_RESOURCE_BUFFER = 1, + D3D10_RESOURCE_TEXTURE1D = 2, + D3D10_RESOURCE_TEXTURE2D = 3, + D3D10_RESOURCE_TEXTURE3D = 4, + D3D10_RESOURCE_TEXTURECUBE = 5 + } D3D10_RESOURCE; + +typedef +enum D3D10_USAGE + { D3D10_USAGE_DEFAULT = 0, + D3D10_USAGE_IMMUTABLE = 1, + D3D10_USAGE_DYNAMIC = 2, + D3D10_USAGE_STAGING = 3 + } D3D10_USAGE; + +typedef +enum D3D10_BIND_FLAG + { D3D10_BIND_VERTEX_BUFFER = 0x1L, + D3D10_BIND_INDEX_BUFFER = 0x2L, + D3D10_BIND_CONSTANT_BUFFER = 0x4L, + D3D10_BIND_SHADER_RESOURCE = 0x8L, + D3D10_BIND_STREAM_OUTPUT = 0x10L, + D3D10_BIND_RENDER_TARGET = 0x20L, + D3D10_BIND_DEPTH_STENCIL = 0x40L + } D3D10_BIND_FLAG; + +typedef +enum D3D10_CPU_ACCESS_FLAG + { D3D10_CPU_ACCESS_WRITE = 0x10000L, + D3D10_CPU_ACCESS_READ = 0x20000L + } D3D10_CPU_ACCESS_FLAG; + +typedef +enum D3D10_RESOURCE_MISC_FLAG + { D3D10_RESOURCE_MISC_GENERATE_MIPS = 0x1L, + D3D10_RESOURCE_MISC_COPY_DESTINATION = 0x2L + } D3D10_RESOURCE_MISC_FLAG; + +typedef +enum D3D10_MAP + { D3D10_MAP_READ = 1, + D3D10_MAP_WRITE = 2, + D3D10_MAP_READ_WRITE = 3, + D3D10_MAP_WRITE_DISCARD = 4, + D3D10_MAP_WRITE_NO_OVERWRITE = 5 + } D3D10_MAP; + +typedef +enum D3D10_MAP_FLAG + { D3D10_MAP_FLAG_DO_NOT_WAIT = 0x100000L + } D3D10_MAP_FLAG; + +typedef +enum D3D10_RAISE_FLAG + { D3D10_RAISE_FLAG_DRIVER_INTERNAL_ERROR = 0x1L + } D3D10_RAISE_FLAG; + +#define D3D10_BUFFEROFFSET_APPEND ( 0xffffffffL ) + +typedef +enum D3D10_CLEAR_FLAG + { D3D10_CLEAR_DEPTH = 0x1L, + D3D10_CLEAR_STENCIL = 0x2L + } D3D10_CLEAR_FLAG; + +typedef RECT D3D10_RECT; + +typedef struct D3D10_BOX + { + UINT left; + UINT top; + UINT front; + UINT right; + UINT bottom; + UINT back; + } D3D10_BOX; + + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0000_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0000_v0_0_s_ifspec; + +#ifndef __ID3D10DeviceChild_INTERFACE_DEFINED__ +#define __ID3D10DeviceChild_INTERFACE_DEFINED__ + +/* interface ID3D10DeviceChild */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10DeviceChild; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C00-342C-4106-A19F-4F2704F689F0") + ID3D10DeviceChild : public IUnknown + { + public: + virtual void STDMETHODCALLTYPE GetDevice( + /* [retval][out] */ ID3D10Device **ppDevice) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetPrivateData( + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetPrivateData( + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10DeviceChildVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10DeviceChild * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10DeviceChild * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10DeviceChild * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10DeviceChild * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10DeviceChild * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10DeviceChild * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10DeviceChild * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + END_INTERFACE + } ID3D10DeviceChildVtbl; + + interface ID3D10DeviceChild + { + CONST_VTBL struct ID3D10DeviceChildVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10DeviceChild_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10DeviceChild_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10DeviceChild_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10DeviceChild_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10DeviceChild_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10DeviceChild_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10DeviceChild_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10DeviceChild_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0001 */ +/* [local] */ + +typedef +enum D3D10_COMPARISON_FUNC + { D3D10_COMPARISON_NEVER = 1, + D3D10_COMPARISON_LESS = 2, + D3D10_COMPARISON_EQUAL = 3, + D3D10_COMPARISON_LESS_EQUAL = 4, + D3D10_COMPARISON_GREATER = 5, + D3D10_COMPARISON_NOT_EQUAL = 6, + D3D10_COMPARISON_GREATER_EQUAL = 7, + D3D10_COMPARISON_ALWAYS = 8 + } D3D10_COMPARISON_FUNC; + +typedef +enum D3D10_DEPTH_WRITE_MASK + { D3D10_DEPTH_WRITE_MASK_ZERO = 0, + D3D10_DEPTH_WRITE_MASK_ALL = 1 + } D3D10_DEPTH_WRITE_MASK; + +typedef +enum D3D10_STENCIL_OP + { D3D10_STENCIL_OP_KEEP = 1, + D3D10_STENCIL_OP_ZERO = 2, + D3D10_STENCIL_OP_REPLACE = 3, + D3D10_STENCIL_OP_INCR_SAT = 4, + D3D10_STENCIL_OP_DECR_SAT = 5, + D3D10_STENCIL_OP_INVERT = 6, + D3D10_STENCIL_OP_INCR = 7, + D3D10_STENCIL_OP_DECR = 8 + } D3D10_STENCIL_OP; + +typedef struct D3D10_DEPTH_STENCILOP_DESC + { + D3D10_STENCIL_OP StencilFailOp; + D3D10_STENCIL_OP StencilDepthFailOp; + D3D10_STENCIL_OP StencilPassOp; + D3D10_COMPARISON_FUNC StencilFunc; + } D3D10_DEPTH_STENCILOP_DESC; + +typedef struct D3D10_DEPTH_STENCIL_DESC + { + BOOL DepthEnable; + D3D10_DEPTH_WRITE_MASK DepthWriteMask; + D3D10_COMPARISON_FUNC DepthFunc; + BOOL StencilEnable; + UINT8 StencilReadMask; + UINT8 StencilWriteMask; + D3D10_DEPTH_STENCILOP_DESC FrontFace; + D3D10_DEPTH_STENCILOP_DESC BackFace; + } D3D10_DEPTH_STENCIL_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0001_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0001_v0_0_s_ifspec; + +#ifndef __ID3D10DepthStencilState_INTERFACE_DEFINED__ +#define __ID3D10DepthStencilState_INTERFACE_DEFINED__ + +/* interface ID3D10DepthStencilState */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10DepthStencilState; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("2B4B1CC8-A4AD-41f8-8322-CA86FC3EC675") + ID3D10DepthStencilState : public ID3D10DeviceChild + { + public: + virtual void STDMETHODCALLTYPE GetDesc( + /* [retval][out] */ D3D10_DEPTH_STENCIL_DESC *pDesc) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10DepthStencilStateVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10DepthStencilState * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10DepthStencilState * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10DepthStencilState * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10DepthStencilState * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10DepthStencilState * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10DepthStencilState * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10DepthStencilState * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *GetDesc )( + ID3D10DepthStencilState * This, + /* [retval][out] */ D3D10_DEPTH_STENCIL_DESC *pDesc); + + END_INTERFACE + } ID3D10DepthStencilStateVtbl; + + interface ID3D10DepthStencilState + { + CONST_VTBL struct ID3D10DepthStencilStateVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10DepthStencilState_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10DepthStencilState_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10DepthStencilState_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10DepthStencilState_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10DepthStencilState_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10DepthStencilState_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10DepthStencilState_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10DepthStencilState_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10DepthStencilState_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0002 */ +/* [local] */ + +typedef +enum D3D10_BLEND + { D3D10_BLEND_ZERO = 1, + D3D10_BLEND_ONE = 2, + D3D10_BLEND_SRC_COLOR = 3, + D3D10_BLEND_INV_SRC_COLOR = 4, + D3D10_BLEND_SRC_ALPHA = 5, + D3D10_BLEND_INV_SRC_ALPHA = 6, + D3D10_BLEND_DEST_ALPHA = 7, + D3D10_BLEND_INV_DEST_ALPHA = 8, + D3D10_BLEND_DEST_COLOR = 9, + D3D10_BLEND_INV_DEST_COLOR = 10, + D3D10_BLEND_SRC_ALPHA_SAT = 11, + D3D10_BLEND_BLEND_FACTOR = 14, + D3D10_BLEND_INV_BLEND_FACTOR = 15, + D3D10_BLEND_SRC1_COLOR = 16, + D3D10_BLEND_INV_SRC1_COLOR = 17, + D3D10_BLEND_SRC1_ALPHA = 18, + D3D10_BLEND_INV_SRC1_ALPHA = 19 + } D3D10_BLEND; + +typedef +enum D3D10_BLEND_OP + { D3D10_BLEND_OP_ADD = 1, + D3D10_BLEND_OP_SUBTRACT = 2, + D3D10_BLEND_OP_REV_SUBTRACT = 3, + D3D10_BLEND_OP_MIN = 4, + D3D10_BLEND_OP_MAX = 5 + } D3D10_BLEND_OP; + +typedef +enum D3D10_COLOR_WRITE_ENABLE + { D3D10_COLOR_WRITE_ENABLE_RED = 1, + D3D10_COLOR_WRITE_ENABLE_GREEN = 2, + D3D10_COLOR_WRITE_ENABLE_BLUE = 4, + D3D10_COLOR_WRITE_ENABLE_ALPHA = 8, + D3D10_COLOR_WRITE_ENABLE_ALL = ( ( ( D3D10_COLOR_WRITE_ENABLE_RED | D3D10_COLOR_WRITE_ENABLE_GREEN ) | D3D10_COLOR_WRITE_ENABLE_BLUE ) | D3D10_COLOR_WRITE_ENABLE_ALPHA ) + } D3D10_COLOR_WRITE_ENABLE; + +typedef struct D3D10_BLEND_DESC + { + BOOL AlphaToCoverageEnable; + BOOL BlendEnable[ 8 ]; + D3D10_BLEND SrcBlend; + D3D10_BLEND DestBlend; + D3D10_BLEND_OP BlendOp; + D3D10_BLEND SrcBlendAlpha; + D3D10_BLEND DestBlendAlpha; + D3D10_BLEND_OP BlendOpAlpha; + UINT8 RenderTargetWriteMask[ 8 ]; + } D3D10_BLEND_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0002_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0002_v0_0_s_ifspec; + +#ifndef __ID3D10BlendState_INTERFACE_DEFINED__ +#define __ID3D10BlendState_INTERFACE_DEFINED__ + +/* interface ID3D10BlendState */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10BlendState; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("EDAD8D19-8A35-4d6d-8566-2EA276CDE161") + ID3D10BlendState : public ID3D10DeviceChild + { + public: + virtual void STDMETHODCALLTYPE GetDesc( + /* [retval][out] */ D3D10_BLEND_DESC *pDesc) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10BlendStateVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10BlendState * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10BlendState * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10BlendState * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10BlendState * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10BlendState * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10BlendState * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10BlendState * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *GetDesc )( + ID3D10BlendState * This, + /* [retval][out] */ D3D10_BLEND_DESC *pDesc); + + END_INTERFACE + } ID3D10BlendStateVtbl; + + interface ID3D10BlendState + { + CONST_VTBL struct ID3D10BlendStateVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10BlendState_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10BlendState_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10BlendState_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10BlendState_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10BlendState_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10BlendState_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10BlendState_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10BlendState_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10BlendState_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0003 */ +/* [local] */ + +typedef struct D3D10_RASTERIZER_DESC + { + D3D10_FILL_MODE FillMode; + D3D10_CULL_MODE CullMode; + BOOL FrontCounterClockwise; + INT DepthBias; + FLOAT DepthBiasClamp; + FLOAT SlopeScaledDepthBias; + BOOL DepthClipEnable; + BOOL ScissorEnable; + BOOL MultisampleEnable; + BOOL AntialiasedLineEnable; + } D3D10_RASTERIZER_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0003_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0003_v0_0_s_ifspec; + +#ifndef __ID3D10RasterizerState_INTERFACE_DEFINED__ +#define __ID3D10RasterizerState_INTERFACE_DEFINED__ + +/* interface ID3D10RasterizerState */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10RasterizerState; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("A2A07292-89AF-4345-BE2E-C53D9FBB6E9F") + ID3D10RasterizerState : public ID3D10DeviceChild + { + public: + virtual void STDMETHODCALLTYPE GetDesc( + /* [retval][out] */ D3D10_RASTERIZER_DESC *pDesc) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10RasterizerStateVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10RasterizerState * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10RasterizerState * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10RasterizerState * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10RasterizerState * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10RasterizerState * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10RasterizerState * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10RasterizerState * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *GetDesc )( + ID3D10RasterizerState * This, + /* [retval][out] */ D3D10_RASTERIZER_DESC *pDesc); + + END_INTERFACE + } ID3D10RasterizerStateVtbl; + + interface ID3D10RasterizerState + { + CONST_VTBL struct ID3D10RasterizerStateVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10RasterizerState_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10RasterizerState_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10RasterizerState_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10RasterizerState_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10RasterizerState_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10RasterizerState_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10RasterizerState_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10RasterizerState_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10RasterizerState_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0004 */ +/* [local] */ + +#if !defined( D3D10_NO_HELPERS ) && defined( __cplusplus ) +inline UINT D3D10CalcSubresource( UINT MipSlice, UINT ArraySlice, UINT MipLevels ) +{ return MipSlice + ArraySlice * MipLevels; } +#endif +typedef struct D3D10_SUBRESOURCE_UP + { + const void *pSysMem; + SIZE_T SysMemPitch; + SIZE_T SysMemSlicePitch; + } D3D10_SUBRESOURCE_UP; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0004_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0004_v0_0_s_ifspec; + +#ifndef __ID3D10Resource_INTERFACE_DEFINED__ +#define __ID3D10Resource_INTERFACE_DEFINED__ + +/* interface ID3D10Resource */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10Resource; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C01-342C-4106-A19F-4F2704F689F0") + ID3D10Resource : public ID3D10DeviceChild + { + public: + virtual void STDMETHODCALLTYPE CopySubresourceRegion( + /* [in] */ UINT DstSubresource, + /* [in] */ SIZE_T DstX, + /* [in] */ SIZE_T DstY, + /* [in] */ SIZE_T DstZ, + /* [in] */ ID3D10Resource *pSrcResource, + /* [in] */ UINT SrcSubresource, + /* [in] */ const D3D10_BOX *pSrcBox) = 0; + + virtual void STDMETHODCALLTYPE CopyResource( + /* [in] */ ID3D10Resource *pSrcResource) = 0; + + virtual void STDMETHODCALLTYPE UpdateSubresource( + /* [in] */ UINT DstSubresource, + /* [in] */ const D3D10_BOX *pDstBox, + /* [in] */ const void *pSrcData, + /* [in] */ SIZE_T SrcRowPitch, + /* [in] */ SIZE_T SrcDepthPitch) = 0; + + virtual void STDMETHODCALLTYPE GetType( + /* [out] */ D3D10_RESOURCE *rType) = 0; + + virtual void STDMETHODCALLTYPE SetEvictionPriority( + /* [in] */ UINT EvictionPriority) = 0; + + virtual UINT STDMETHODCALLTYPE GetEvictionPriority( void) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10ResourceVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10Resource * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10Resource * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10Resource * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10Resource * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10Resource * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10Resource * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10Resource * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *CopySubresourceRegion )( + ID3D10Resource * This, + /* [in] */ UINT DstSubresource, + /* [in] */ SIZE_T DstX, + /* [in] */ SIZE_T DstY, + /* [in] */ SIZE_T DstZ, + /* [in] */ ID3D10Resource *pSrcResource, + /* [in] */ UINT SrcSubresource, + /* [in] */ const D3D10_BOX *pSrcBox); + + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D10Resource * This, + /* [in] */ ID3D10Resource *pSrcResource); + + void ( STDMETHODCALLTYPE *UpdateSubresource )( + ID3D10Resource * This, + /* [in] */ UINT DstSubresource, + /* [in] */ const D3D10_BOX *pDstBox, + /* [in] */ const void *pSrcData, + /* [in] */ SIZE_T SrcRowPitch, + /* [in] */ SIZE_T SrcDepthPitch); + + void ( STDMETHODCALLTYPE *GetType )( + ID3D10Resource * This, + /* [out] */ D3D10_RESOURCE *rType); + + void ( STDMETHODCALLTYPE *SetEvictionPriority )( + ID3D10Resource * This, + /* [in] */ UINT EvictionPriority); + + UINT ( STDMETHODCALLTYPE *GetEvictionPriority )( + ID3D10Resource * This); + + END_INTERFACE + } ID3D10ResourceVtbl; + + interface ID3D10Resource + { + CONST_VTBL struct ID3D10ResourceVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10Resource_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10Resource_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10Resource_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10Resource_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10Resource_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10Resource_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10Resource_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10Resource_CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) \ + ( (This)->lpVtbl -> CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) ) + +#define ID3D10Resource_CopyResource(This,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pSrcResource) ) + +#define ID3D10Resource_UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ + ( (This)->lpVtbl -> UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) + +#define ID3D10Resource_GetType(This,rType) \ + ( (This)->lpVtbl -> GetType(This,rType) ) + +#define ID3D10Resource_SetEvictionPriority(This,EvictionPriority) \ + ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) + +#define ID3D10Resource_GetEvictionPriority(This) \ + ( (This)->lpVtbl -> GetEvictionPriority(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10Resource_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0005 */ +/* [local] */ + +typedef struct D3D10_BUFFER_DESC + { + SIZE_T ByteWidth; + D3D10_USAGE Usage; + UINT BindFlags; + UINT CPUAccessFlags; + UINT MiscFlags; + } D3D10_BUFFER_DESC; + +#if !defined( D3D10_NO_HELPERS ) && defined( __cplusplus ) +struct CD3D10_BUFFER_DESC : public D3D10_BUFFER_DESC +{ + CD3D10_BUFFER_DESC() + {} + explicit CD3D10_BUFFER_DESC( const D3D10_BUFFER_DESC& o ) : + D3D10_BUFFER_DESC( o ) + {} + explicit CD3D10_BUFFER_DESC( + SIZE_T byteWidth, + UINT bindFlags, + D3D10_USAGE usage = D3D10_USAGE_DEFAULT, + UINT cpuaccessFlags = 0, + UINT miscFlags = 0 ) + { + ByteWidth = byteWidth; + Usage = usage; + BindFlags = bindFlags; + CPUAccessFlags = cpuaccessFlags ; + MiscFlags = miscFlags; + } + ~CD3D10_BUFFER_DESC() {} + operator const D3D10_BUFFER_DESC&() const { return *this; } +}; +#endif + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0005_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0005_v0_0_s_ifspec; + +#ifndef __ID3D10Buffer_INTERFACE_DEFINED__ +#define __ID3D10Buffer_INTERFACE_DEFINED__ + +/* interface ID3D10Buffer */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10Buffer; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C02-342C-4106-A19F-4F2704F689F0") + ID3D10Buffer : public ID3D10Resource + { + public: + virtual HRESULT STDMETHODCALLTYPE Map( + /* [in] */ D3D10_MAP MapType, + /* [in] */ UINT Flags, + /* [out] */ void **ppData) = 0; + + virtual void STDMETHODCALLTYPE Unmap( void) = 0; + + virtual void STDMETHODCALLTYPE GetDesc( + /* [retval][out] */ D3D10_BUFFER_DESC *pDesc) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10BufferVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10Buffer * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10Buffer * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10Buffer * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10Buffer * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10Buffer * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10Buffer * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10Buffer * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *CopySubresourceRegion )( + ID3D10Buffer * This, + /* [in] */ UINT DstSubresource, + /* [in] */ SIZE_T DstX, + /* [in] */ SIZE_T DstY, + /* [in] */ SIZE_T DstZ, + /* [in] */ ID3D10Resource *pSrcResource, + /* [in] */ UINT SrcSubresource, + /* [in] */ const D3D10_BOX *pSrcBox); + + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D10Buffer * This, + /* [in] */ ID3D10Resource *pSrcResource); + + void ( STDMETHODCALLTYPE *UpdateSubresource )( + ID3D10Buffer * This, + /* [in] */ UINT DstSubresource, + /* [in] */ const D3D10_BOX *pDstBox, + /* [in] */ const void *pSrcData, + /* [in] */ SIZE_T SrcRowPitch, + /* [in] */ SIZE_T SrcDepthPitch); + + void ( STDMETHODCALLTYPE *GetType )( + ID3D10Buffer * This, + /* [out] */ D3D10_RESOURCE *rType); + + void ( STDMETHODCALLTYPE *SetEvictionPriority )( + ID3D10Buffer * This, + /* [in] */ UINT EvictionPriority); + + UINT ( STDMETHODCALLTYPE *GetEvictionPriority )( + ID3D10Buffer * This); + + HRESULT ( STDMETHODCALLTYPE *Map )( + ID3D10Buffer * This, + /* [in] */ D3D10_MAP MapType, + /* [in] */ UINT Flags, + /* [out] */ void **ppData); + + void ( STDMETHODCALLTYPE *Unmap )( + ID3D10Buffer * This); + + void ( STDMETHODCALLTYPE *GetDesc )( + ID3D10Buffer * This, + /* [retval][out] */ D3D10_BUFFER_DESC *pDesc); + + END_INTERFACE + } ID3D10BufferVtbl; + + interface ID3D10Buffer + { + CONST_VTBL struct ID3D10BufferVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10Buffer_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10Buffer_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10Buffer_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10Buffer_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10Buffer_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10Buffer_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10Buffer_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10Buffer_CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) \ + ( (This)->lpVtbl -> CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) ) + +#define ID3D10Buffer_CopyResource(This,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pSrcResource) ) + +#define ID3D10Buffer_UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ + ( (This)->lpVtbl -> UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) + +#define ID3D10Buffer_GetType(This,rType) \ + ( (This)->lpVtbl -> GetType(This,rType) ) + +#define ID3D10Buffer_SetEvictionPriority(This,EvictionPriority) \ + ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) + +#define ID3D10Buffer_GetEvictionPriority(This) \ + ( (This)->lpVtbl -> GetEvictionPriority(This) ) + + +#define ID3D10Buffer_Map(This,MapType,Flags,ppData) \ + ( (This)->lpVtbl -> Map(This,MapType,Flags,ppData) ) + +#define ID3D10Buffer_Unmap(This) \ + ( (This)->lpVtbl -> Unmap(This) ) + +#define ID3D10Buffer_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10Buffer_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0006 */ +/* [local] */ + +typedef struct D3D10_TEXTURE1D_DESC + { + SIZE_T Width; + UINT MipLevels; + UINT ArraySize; + DXGI_FORMAT Format; + DXGI_SAMPLE_DESC SampleDesc; + D3D10_USAGE Usage; + UINT BindFlags; + UINT CPUAccessFlags; + UINT MiscFlags; + } D3D10_TEXTURE1D_DESC; + +#if !defined( D3D10_NO_HELPERS ) && defined( __cplusplus ) +struct CD3D10_TEXTURE1D_DESC : public D3D10_TEXTURE1D_DESC +{ + CD3D10_TEXTURE1D_DESC() + {} + explicit CD3D10_TEXTURE1D_DESC( const D3D10_TEXTURE1D_DESC& o ) : + D3D10_TEXTURE1D_DESC( o ) + {} + explicit CD3D10_TEXTURE1D_DESC( + DXGI_FORMAT format, + SIZE_T width, + UINT arraySize = 1, + UINT mipLevels = 0, + UINT bindFlags = D3D10_BIND_SHADER_RESOURCE, + D3D10_USAGE usage = D3D10_USAGE_DEFAULT, + UINT cpuaccessFlags= 0, + UINT sampleCount = 1, + UINT sampleQuality = 0, + UINT miscFlags = 0 ) + { + Width = width; + MipLevels = mipLevels; + ArraySize = arraySize; + Format = format; + SampleDesc.Count = sampleCount; + SampleDesc.Quality = sampleQuality; + Usage = usage; + BindFlags = bindFlags; + CPUAccessFlags = cpuaccessFlags; + MiscFlags = miscFlags; + } + ~CD3D10_TEXTURE1D_DESC() {} + operator const D3D10_TEXTURE1D_DESC&() const { return *this; } +}; +#endif + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0006_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0006_v0_0_s_ifspec; + +#ifndef __ID3D10Texture1D_INTERFACE_DEFINED__ +#define __ID3D10Texture1D_INTERFACE_DEFINED__ + +/* interface ID3D10Texture1D */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10Texture1D; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C03-342C-4106-A19F-4F2704F689F0") + ID3D10Texture1D : public ID3D10Resource + { + public: + virtual HRESULT STDMETHODCALLTYPE Map( + /* [in] */ UINT Subresource, + /* [in] */ D3D10_MAP MapType, + /* [in] */ UINT Flags, + /* [out] */ void **ppData) = 0; + + virtual void STDMETHODCALLTYPE Unmap( + /* [in] */ UINT Subresource) = 0; + + virtual void STDMETHODCALLTYPE GetDesc( + /* [retval][out] */ D3D10_TEXTURE1D_DESC *pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetMultisampleResolveFormat( + /* [in] */ DXGI_FORMAT Format) = 0; + + virtual DXGI_FORMAT STDMETHODCALLTYPE GetMultisampleResolveFormat( void) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10Texture1DVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10Texture1D * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10Texture1D * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10Texture1D * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10Texture1D * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10Texture1D * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10Texture1D * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10Texture1D * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *CopySubresourceRegion )( + ID3D10Texture1D * This, + /* [in] */ UINT DstSubresource, + /* [in] */ SIZE_T DstX, + /* [in] */ SIZE_T DstY, + /* [in] */ SIZE_T DstZ, + /* [in] */ ID3D10Resource *pSrcResource, + /* [in] */ UINT SrcSubresource, + /* [in] */ const D3D10_BOX *pSrcBox); + + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D10Texture1D * This, + /* [in] */ ID3D10Resource *pSrcResource); + + void ( STDMETHODCALLTYPE *UpdateSubresource )( + ID3D10Texture1D * This, + /* [in] */ UINT DstSubresource, + /* [in] */ const D3D10_BOX *pDstBox, + /* [in] */ const void *pSrcData, + /* [in] */ SIZE_T SrcRowPitch, + /* [in] */ SIZE_T SrcDepthPitch); + + void ( STDMETHODCALLTYPE *GetType )( + ID3D10Texture1D * This, + /* [out] */ D3D10_RESOURCE *rType); + + void ( STDMETHODCALLTYPE *SetEvictionPriority )( + ID3D10Texture1D * This, + /* [in] */ UINT EvictionPriority); + + UINT ( STDMETHODCALLTYPE *GetEvictionPriority )( + ID3D10Texture1D * This); + + HRESULT ( STDMETHODCALLTYPE *Map )( + ID3D10Texture1D * This, + /* [in] */ UINT Subresource, + /* [in] */ D3D10_MAP MapType, + /* [in] */ UINT Flags, + /* [out] */ void **ppData); + + void ( STDMETHODCALLTYPE *Unmap )( + ID3D10Texture1D * This, + /* [in] */ UINT Subresource); + + void ( STDMETHODCALLTYPE *GetDesc )( + ID3D10Texture1D * This, + /* [retval][out] */ D3D10_TEXTURE1D_DESC *pDesc); + + HRESULT ( STDMETHODCALLTYPE *SetMultisampleResolveFormat )( + ID3D10Texture1D * This, + /* [in] */ DXGI_FORMAT Format); + + DXGI_FORMAT ( STDMETHODCALLTYPE *GetMultisampleResolveFormat )( + ID3D10Texture1D * This); + + END_INTERFACE + } ID3D10Texture1DVtbl; + + interface ID3D10Texture1D + { + CONST_VTBL struct ID3D10Texture1DVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10Texture1D_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10Texture1D_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10Texture1D_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10Texture1D_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10Texture1D_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10Texture1D_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10Texture1D_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10Texture1D_CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) \ + ( (This)->lpVtbl -> CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) ) + +#define ID3D10Texture1D_CopyResource(This,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pSrcResource) ) + +#define ID3D10Texture1D_UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ + ( (This)->lpVtbl -> UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) + +#define ID3D10Texture1D_GetType(This,rType) \ + ( (This)->lpVtbl -> GetType(This,rType) ) + +#define ID3D10Texture1D_SetEvictionPriority(This,EvictionPriority) \ + ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) + +#define ID3D10Texture1D_GetEvictionPriority(This) \ + ( (This)->lpVtbl -> GetEvictionPriority(This) ) + + +#define ID3D10Texture1D_Map(This,Subresource,MapType,Flags,ppData) \ + ( (This)->lpVtbl -> Map(This,Subresource,MapType,Flags,ppData) ) + +#define ID3D10Texture1D_Unmap(This,Subresource) \ + ( (This)->lpVtbl -> Unmap(This,Subresource) ) + +#define ID3D10Texture1D_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#define ID3D10Texture1D_SetMultisampleResolveFormat(This,Format) \ + ( (This)->lpVtbl -> SetMultisampleResolveFormat(This,Format) ) + +#define ID3D10Texture1D_GetMultisampleResolveFormat(This) \ + ( (This)->lpVtbl -> GetMultisampleResolveFormat(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10Texture1D_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0007 */ +/* [local] */ + +typedef struct D3D10_TEXTURE2D_DESC + { + SIZE_T Width; + SIZE_T Height; + UINT MipLevels; + UINT ArraySize; + DXGI_FORMAT Format; + DXGI_SAMPLE_DESC SampleDesc; + D3D10_USAGE Usage; + UINT BindFlags; + UINT CPUAccessFlags; + UINT MiscFlags; + } D3D10_TEXTURE2D_DESC; + +#if !defined( D3D10_NO_HELPERS ) && defined( __cplusplus ) +struct CD3D10_TEXTURE2D_DESC : public D3D10_TEXTURE2D_DESC +{ + CD3D10_TEXTURE2D_DESC() + {} + explicit CD3D10_TEXTURE2D_DESC( const D3D10_TEXTURE2D_DESC& o ) : + D3D10_TEXTURE2D_DESC( o ) + {} + explicit CD3D10_TEXTURE2D_DESC( + DXGI_FORMAT format, + SIZE_T width, + SIZE_T height, + UINT arraySize = 1, + UINT mipLevels = 0, + UINT bindFlags = D3D10_BIND_SHADER_RESOURCE, + D3D10_USAGE usage = D3D10_USAGE_DEFAULT, + UINT cpuaccessFlags = 0, + UINT sampleCount = 1, + UINT sampleQuality = 0, + UINT miscFlags = 0 ) + { + Width = width; + Height = height; + MipLevels = mipLevels; + ArraySize = arraySize; + Format = format; + SampleDesc.Count = sampleCount; + SampleDesc.Quality = sampleQuality; + Usage = usage; + BindFlags = bindFlags; + CPUAccessFlags = cpuaccessFlags; + MiscFlags = miscFlags; + } + ~CD3D10_TEXTURE2D_DESC() {} + operator const D3D10_TEXTURE2D_DESC&() const { return *this; } +}; +#endif +typedef struct D3D10_MAPPED_TEXTURE2D + { + void *pData; + SIZE_T RowPitch; + } D3D10_MAPPED_TEXTURE2D; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0007_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0007_v0_0_s_ifspec; + +#ifndef __ID3D10Texture2D_INTERFACE_DEFINED__ +#define __ID3D10Texture2D_INTERFACE_DEFINED__ + +/* interface ID3D10Texture2D */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10Texture2D; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C04-342C-4106-A19F-4F2704F689F0") + ID3D10Texture2D : public ID3D10Resource + { + public: + virtual HRESULT STDMETHODCALLTYPE Map( + /* [in] */ UINT Subresource, + /* [in] */ D3D10_MAP MapType, + /* [in] */ UINT Flags, + /* [out] */ D3D10_MAPPED_TEXTURE2D *pMappedTex2D) = 0; + + virtual void STDMETHODCALLTYPE Unmap( + /* [in] */ UINT Subresource) = 0; + + virtual void STDMETHODCALLTYPE GetDesc( + /* [retval][out] */ D3D10_TEXTURE2D_DESC *pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetMultisampleResolveFormat( + /* [in] */ DXGI_FORMAT Format) = 0; + + virtual DXGI_FORMAT STDMETHODCALLTYPE GetMultisampleResolveFormat( void) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10Texture2DVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10Texture2D * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10Texture2D * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10Texture2D * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10Texture2D * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10Texture2D * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10Texture2D * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10Texture2D * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *CopySubresourceRegion )( + ID3D10Texture2D * This, + /* [in] */ UINT DstSubresource, + /* [in] */ SIZE_T DstX, + /* [in] */ SIZE_T DstY, + /* [in] */ SIZE_T DstZ, + /* [in] */ ID3D10Resource *pSrcResource, + /* [in] */ UINT SrcSubresource, + /* [in] */ const D3D10_BOX *pSrcBox); + + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D10Texture2D * This, + /* [in] */ ID3D10Resource *pSrcResource); + + void ( STDMETHODCALLTYPE *UpdateSubresource )( + ID3D10Texture2D * This, + /* [in] */ UINT DstSubresource, + /* [in] */ const D3D10_BOX *pDstBox, + /* [in] */ const void *pSrcData, + /* [in] */ SIZE_T SrcRowPitch, + /* [in] */ SIZE_T SrcDepthPitch); + + void ( STDMETHODCALLTYPE *GetType )( + ID3D10Texture2D * This, + /* [out] */ D3D10_RESOURCE *rType); + + void ( STDMETHODCALLTYPE *SetEvictionPriority )( + ID3D10Texture2D * This, + /* [in] */ UINT EvictionPriority); + + UINT ( STDMETHODCALLTYPE *GetEvictionPriority )( + ID3D10Texture2D * This); + + HRESULT ( STDMETHODCALLTYPE *Map )( + ID3D10Texture2D * This, + /* [in] */ UINT Subresource, + /* [in] */ D3D10_MAP MapType, + /* [in] */ UINT Flags, + /* [out] */ D3D10_MAPPED_TEXTURE2D *pMappedTex2D); + + void ( STDMETHODCALLTYPE *Unmap )( + ID3D10Texture2D * This, + /* [in] */ UINT Subresource); + + void ( STDMETHODCALLTYPE *GetDesc )( + ID3D10Texture2D * This, + /* [retval][out] */ D3D10_TEXTURE2D_DESC *pDesc); + + HRESULT ( STDMETHODCALLTYPE *SetMultisampleResolveFormat )( + ID3D10Texture2D * This, + /* [in] */ DXGI_FORMAT Format); + + DXGI_FORMAT ( STDMETHODCALLTYPE *GetMultisampleResolveFormat )( + ID3D10Texture2D * This); + + END_INTERFACE + } ID3D10Texture2DVtbl; + + interface ID3D10Texture2D + { + CONST_VTBL struct ID3D10Texture2DVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10Texture2D_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10Texture2D_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10Texture2D_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10Texture2D_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10Texture2D_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10Texture2D_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10Texture2D_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10Texture2D_CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) \ + ( (This)->lpVtbl -> CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) ) + +#define ID3D10Texture2D_CopyResource(This,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pSrcResource) ) + +#define ID3D10Texture2D_UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ + ( (This)->lpVtbl -> UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) + +#define ID3D10Texture2D_GetType(This,rType) \ + ( (This)->lpVtbl -> GetType(This,rType) ) + +#define ID3D10Texture2D_SetEvictionPriority(This,EvictionPriority) \ + ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) + +#define ID3D10Texture2D_GetEvictionPriority(This) \ + ( (This)->lpVtbl -> GetEvictionPriority(This) ) + + +#define ID3D10Texture2D_Map(This,Subresource,MapType,Flags,pMappedTex2D) \ + ( (This)->lpVtbl -> Map(This,Subresource,MapType,Flags,pMappedTex2D) ) + +#define ID3D10Texture2D_Unmap(This,Subresource) \ + ( (This)->lpVtbl -> Unmap(This,Subresource) ) + +#define ID3D10Texture2D_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#define ID3D10Texture2D_SetMultisampleResolveFormat(This,Format) \ + ( (This)->lpVtbl -> SetMultisampleResolveFormat(This,Format) ) + +#define ID3D10Texture2D_GetMultisampleResolveFormat(This) \ + ( (This)->lpVtbl -> GetMultisampleResolveFormat(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10Texture2D_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0008 */ +/* [local] */ + +typedef struct D3D10_TEXTURE3D_DESC + { + SIZE_T Width; + SIZE_T Height; + SIZE_T Depth; + UINT MipLevels; + DXGI_FORMAT Format; + DXGI_SAMPLE_DESC SampleDesc; + D3D10_USAGE Usage; + UINT BindFlags; + UINT CPUAccessFlags; + UINT MiscFlags; + } D3D10_TEXTURE3D_DESC; + +#if !defined( D3D10_NO_HELPERS ) && defined( __cplusplus ) +struct CD3D10_TEXTURE3D_DESC : public D3D10_TEXTURE3D_DESC +{ + CD3D10_TEXTURE3D_DESC() + {} + explicit CD3D10_TEXTURE3D_DESC( const D3D10_TEXTURE3D_DESC& o ) : + D3D10_TEXTURE3D_DESC( o ) + {} + explicit CD3D10_TEXTURE3D_DESC( + DXGI_FORMAT format, + SIZE_T width, + SIZE_T height, + SIZE_T depth, + UINT mipLevels = 0, + UINT bindFlags = D3D10_BIND_SHADER_RESOURCE, + D3D10_USAGE usage = D3D10_USAGE_DEFAULT, + UINT cpuaccessFlags = 0, + UINT sampleCount = 1, + UINT sampleQuality = 0, + UINT miscFlags = 0 ) + { + Width = width; + Height = height; + Depth = depth; + MipLevels = mipLevels; + Format = format; + SampleDesc.Count = sampleCount; + SampleDesc.Quality = sampleQuality; + Usage = usage; + BindFlags = bindFlags; + CPUAccessFlags = cpuaccessFlags; + MiscFlags = miscFlags; + } + ~CD3D10_TEXTURE3D_DESC() {} + operator const D3D10_TEXTURE3D_DESC&() const { return *this; } +}; +#endif +typedef struct D3D10_MAPPED_TEXTURE3D + { + void *pData; + SIZE_T RowPitch; + SIZE_T DepthPitch; + } D3D10_MAPPED_TEXTURE3D; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0008_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0008_v0_0_s_ifspec; + +#ifndef __ID3D10Texture3D_INTERFACE_DEFINED__ +#define __ID3D10Texture3D_INTERFACE_DEFINED__ + +/* interface ID3D10Texture3D */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10Texture3D; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C05-342C-4106-A19F-4F2704F689F0") + ID3D10Texture3D : public ID3D10Resource + { + public: + virtual HRESULT STDMETHODCALLTYPE Map( + /* [in] */ UINT Subresource, + /* [in] */ D3D10_MAP MapType, + /* [in] */ UINT Flags, + /* [out] */ D3D10_MAPPED_TEXTURE3D *pMappedTex3D) = 0; + + virtual void STDMETHODCALLTYPE Unmap( + /* [in] */ UINT Subresource) = 0; + + virtual void STDMETHODCALLTYPE GetDesc( + /* [retval][out] */ D3D10_TEXTURE3D_DESC *pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetMultisampleResolveFormat( + /* [in] */ DXGI_FORMAT Format) = 0; + + virtual DXGI_FORMAT STDMETHODCALLTYPE GetMultisampleResolveFormat( void) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10Texture3DVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10Texture3D * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10Texture3D * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10Texture3D * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10Texture3D * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10Texture3D * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10Texture3D * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10Texture3D * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *CopySubresourceRegion )( + ID3D10Texture3D * This, + /* [in] */ UINT DstSubresource, + /* [in] */ SIZE_T DstX, + /* [in] */ SIZE_T DstY, + /* [in] */ SIZE_T DstZ, + /* [in] */ ID3D10Resource *pSrcResource, + /* [in] */ UINT SrcSubresource, + /* [in] */ const D3D10_BOX *pSrcBox); + + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D10Texture3D * This, + /* [in] */ ID3D10Resource *pSrcResource); + + void ( STDMETHODCALLTYPE *UpdateSubresource )( + ID3D10Texture3D * This, + /* [in] */ UINT DstSubresource, + /* [in] */ const D3D10_BOX *pDstBox, + /* [in] */ const void *pSrcData, + /* [in] */ SIZE_T SrcRowPitch, + /* [in] */ SIZE_T SrcDepthPitch); + + void ( STDMETHODCALLTYPE *GetType )( + ID3D10Texture3D * This, + /* [out] */ D3D10_RESOURCE *rType); + + void ( STDMETHODCALLTYPE *SetEvictionPriority )( + ID3D10Texture3D * This, + /* [in] */ UINT EvictionPriority); + + UINT ( STDMETHODCALLTYPE *GetEvictionPriority )( + ID3D10Texture3D * This); + + HRESULT ( STDMETHODCALLTYPE *Map )( + ID3D10Texture3D * This, + /* [in] */ UINT Subresource, + /* [in] */ D3D10_MAP MapType, + /* [in] */ UINT Flags, + /* [out] */ D3D10_MAPPED_TEXTURE3D *pMappedTex3D); + + void ( STDMETHODCALLTYPE *Unmap )( + ID3D10Texture3D * This, + /* [in] */ UINT Subresource); + + void ( STDMETHODCALLTYPE *GetDesc )( + ID3D10Texture3D * This, + /* [retval][out] */ D3D10_TEXTURE3D_DESC *pDesc); + + HRESULT ( STDMETHODCALLTYPE *SetMultisampleResolveFormat )( + ID3D10Texture3D * This, + /* [in] */ DXGI_FORMAT Format); + + DXGI_FORMAT ( STDMETHODCALLTYPE *GetMultisampleResolveFormat )( + ID3D10Texture3D * This); + + END_INTERFACE + } ID3D10Texture3DVtbl; + + interface ID3D10Texture3D + { + CONST_VTBL struct ID3D10Texture3DVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10Texture3D_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10Texture3D_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10Texture3D_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10Texture3D_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10Texture3D_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10Texture3D_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10Texture3D_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10Texture3D_CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) \ + ( (This)->lpVtbl -> CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) ) + +#define ID3D10Texture3D_CopyResource(This,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pSrcResource) ) + +#define ID3D10Texture3D_UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ + ( (This)->lpVtbl -> UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) + +#define ID3D10Texture3D_GetType(This,rType) \ + ( (This)->lpVtbl -> GetType(This,rType) ) + +#define ID3D10Texture3D_SetEvictionPriority(This,EvictionPriority) \ + ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) + +#define ID3D10Texture3D_GetEvictionPriority(This) \ + ( (This)->lpVtbl -> GetEvictionPriority(This) ) + + +#define ID3D10Texture3D_Map(This,Subresource,MapType,Flags,pMappedTex3D) \ + ( (This)->lpVtbl -> Map(This,Subresource,MapType,Flags,pMappedTex3D) ) + +#define ID3D10Texture3D_Unmap(This,Subresource) \ + ( (This)->lpVtbl -> Unmap(This,Subresource) ) + +#define ID3D10Texture3D_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#define ID3D10Texture3D_SetMultisampleResolveFormat(This,Format) \ + ( (This)->lpVtbl -> SetMultisampleResolveFormat(This,Format) ) + +#define ID3D10Texture3D_GetMultisampleResolveFormat(This) \ + ( (This)->lpVtbl -> GetMultisampleResolveFormat(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10Texture3D_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0009 */ +/* [local] */ + +typedef struct D3D10_TEXTURECUBE_DESC + { + SIZE_T EdgeWidth; + UINT MipLevels; + DXGI_FORMAT Format; + DXGI_SAMPLE_DESC SampleDesc; + D3D10_USAGE Usage; + UINT BindFlags; + UINT CPUAccessFlags; + UINT MiscFlags; + } D3D10_TEXTURECUBE_DESC; + +#if !defined( D3D10_NO_HELPERS ) && defined( __cplusplus ) +struct CD3D10_TEXTURECUBE_DESC : public D3D10_TEXTURECUBE_DESC +{ + CD3D10_TEXTURECUBE_DESC() + {} + explicit CD3D10_TEXTURECUBE_DESC( const D3D10_TEXTURECUBE_DESC& o ) : + D3D10_TEXTURECUBE_DESC( o ) + {} + explicit CD3D10_TEXTURECUBE_DESC( + DXGI_FORMAT format, + SIZE_T edgeWidth, + UINT mipLevels = 0, + UINT bindFlags = D3D10_BIND_SHADER_RESOURCE, + D3D10_USAGE usage = D3D10_USAGE_DEFAULT, + UINT cpuaccessFlags = 0, + UINT sampleCount = 1, + UINT sampleQuality = 0, + UINT miscFlags = 0 ) + { + EdgeWidth = edgeWidth; + MipLevels = mipLevels; + Format = format; + SampleDesc.Count = sampleCount; + SampleDesc.Quality = sampleQuality; + Usage = usage; + BindFlags = bindFlags; + CPUAccessFlags = cpuaccessFlags; + MiscFlags = miscFlags; + } + ~CD3D10_TEXTURECUBE_DESC() {} + operator const D3D10_TEXTURECUBE_DESC&() const { return *this; } +}; +#endif + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0009_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0009_v0_0_s_ifspec; + +#ifndef __ID3D10TextureCube_INTERFACE_DEFINED__ +#define __ID3D10TextureCube_INTERFACE_DEFINED__ + +/* interface ID3D10TextureCube */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10TextureCube; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C06-342C-4106-A19F-4F2704F689F0") + ID3D10TextureCube : public ID3D10Resource + { + public: + virtual HRESULT STDMETHODCALLTYPE Map( + /* [in] */ UINT Subresource, + /* [in] */ D3D10_MAP MapType, + /* [in] */ UINT Flags, + /* [out] */ D3D10_MAPPED_TEXTURE2D *pMappedFace) = 0; + + virtual void STDMETHODCALLTYPE Unmap( + /* [in] */ UINT Subresource) = 0; + + virtual void STDMETHODCALLTYPE GetDesc( + /* [retval][out] */ D3D10_TEXTURECUBE_DESC *pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetMultisampleResolveFormat( + /* [in] */ DXGI_FORMAT Format) = 0; + + virtual DXGI_FORMAT STDMETHODCALLTYPE GetMultisampleResolveFormat( void) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10TextureCubeVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10TextureCube * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10TextureCube * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10TextureCube * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10TextureCube * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10TextureCube * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10TextureCube * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10TextureCube * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *CopySubresourceRegion )( + ID3D10TextureCube * This, + /* [in] */ UINT DstSubresource, + /* [in] */ SIZE_T DstX, + /* [in] */ SIZE_T DstY, + /* [in] */ SIZE_T DstZ, + /* [in] */ ID3D10Resource *pSrcResource, + /* [in] */ UINT SrcSubresource, + /* [in] */ const D3D10_BOX *pSrcBox); + + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D10TextureCube * This, + /* [in] */ ID3D10Resource *pSrcResource); + + void ( STDMETHODCALLTYPE *UpdateSubresource )( + ID3D10TextureCube * This, + /* [in] */ UINT DstSubresource, + /* [in] */ const D3D10_BOX *pDstBox, + /* [in] */ const void *pSrcData, + /* [in] */ SIZE_T SrcRowPitch, + /* [in] */ SIZE_T SrcDepthPitch); + + void ( STDMETHODCALLTYPE *GetType )( + ID3D10TextureCube * This, + /* [out] */ D3D10_RESOURCE *rType); + + void ( STDMETHODCALLTYPE *SetEvictionPriority )( + ID3D10TextureCube * This, + /* [in] */ UINT EvictionPriority); + + UINT ( STDMETHODCALLTYPE *GetEvictionPriority )( + ID3D10TextureCube * This); + + HRESULT ( STDMETHODCALLTYPE *Map )( + ID3D10TextureCube * This, + /* [in] */ UINT Subresource, + /* [in] */ D3D10_MAP MapType, + /* [in] */ UINT Flags, + /* [out] */ D3D10_MAPPED_TEXTURE2D *pMappedFace); + + void ( STDMETHODCALLTYPE *Unmap )( + ID3D10TextureCube * This, + /* [in] */ UINT Subresource); + + void ( STDMETHODCALLTYPE *GetDesc )( + ID3D10TextureCube * This, + /* [retval][out] */ D3D10_TEXTURECUBE_DESC *pDesc); + + HRESULT ( STDMETHODCALLTYPE *SetMultisampleResolveFormat )( + ID3D10TextureCube * This, + /* [in] */ DXGI_FORMAT Format); + + DXGI_FORMAT ( STDMETHODCALLTYPE *GetMultisampleResolveFormat )( + ID3D10TextureCube * This); + + END_INTERFACE + } ID3D10TextureCubeVtbl; + + interface ID3D10TextureCube + { + CONST_VTBL struct ID3D10TextureCubeVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10TextureCube_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10TextureCube_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10TextureCube_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10TextureCube_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10TextureCube_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10TextureCube_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10TextureCube_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10TextureCube_CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) \ + ( (This)->lpVtbl -> CopySubresourceRegion(This,DstSubresource,DstX,DstY,DstZ,pSrcResource,SrcSubresource,pSrcBox) ) + +#define ID3D10TextureCube_CopyResource(This,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pSrcResource) ) + +#define ID3D10TextureCube_UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ + ( (This)->lpVtbl -> UpdateSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) + +#define ID3D10TextureCube_GetType(This,rType) \ + ( (This)->lpVtbl -> GetType(This,rType) ) + +#define ID3D10TextureCube_SetEvictionPriority(This,EvictionPriority) \ + ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) + +#define ID3D10TextureCube_GetEvictionPriority(This) \ + ( (This)->lpVtbl -> GetEvictionPriority(This) ) + + +#define ID3D10TextureCube_Map(This,Subresource,MapType,Flags,pMappedFace) \ + ( (This)->lpVtbl -> Map(This,Subresource,MapType,Flags,pMappedFace) ) + +#define ID3D10TextureCube_Unmap(This,Subresource) \ + ( (This)->lpVtbl -> Unmap(This,Subresource) ) + +#define ID3D10TextureCube_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#define ID3D10TextureCube_SetMultisampleResolveFormat(This,Format) \ + ( (This)->lpVtbl -> SetMultisampleResolveFormat(This,Format) ) + +#define ID3D10TextureCube_GetMultisampleResolveFormat(This) \ + ( (This)->lpVtbl -> GetMultisampleResolveFormat(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10TextureCube_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0010 */ +/* [local] */ + +typedef +enum D3D10_TEXTURECUBE_FACE + { D3D10_TEXTURECUBE_FACE_POSITIVE_X = 0, + D3D10_TEXTURECUBE_FACE_NEGATIVE_X = 1, + D3D10_TEXTURECUBE_FACE_POSITIVE_Y = 2, + D3D10_TEXTURECUBE_FACE_NEGATIVE_Y = 3, + D3D10_TEXTURECUBE_FACE_POSITIVE_Z = 4, + D3D10_TEXTURECUBE_FACE_NEGATIVE_Z = 5 + } D3D10_TEXTURECUBE_FACE; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0010_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0010_v0_0_s_ifspec; + +#ifndef __ID3D10View_INTERFACE_DEFINED__ +#define __ID3D10View_INTERFACE_DEFINED__ + +/* interface ID3D10View */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10View; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("C902B03F-60A7-49BA-9936-2A3AB37A7E33") + ID3D10View : public ID3D10DeviceChild + { + public: + virtual void STDMETHODCALLTYPE GetResource( + /* [retval][out] */ ID3D10Resource **ppResource) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10ViewVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10View * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10View * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10View * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10View * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10View * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10View * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10View * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *GetResource )( + ID3D10View * This, + /* [retval][out] */ ID3D10Resource **ppResource); + + END_INTERFACE + } ID3D10ViewVtbl; + + interface ID3D10View + { + CONST_VTBL struct ID3D10ViewVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10View_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10View_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10View_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10View_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10View_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10View_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10View_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10View_GetResource(This,ppResource) \ + ( (This)->lpVtbl -> GetResource(This,ppResource) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10View_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0011 */ +/* [local] */ + +typedef struct D3D10_BUFFER_SRV + { + SIZE_T ElementOffset; + SIZE_T ElementWidth; + } D3D10_BUFFER_SRV; + +typedef struct D3D10_TEX1D_SRV + { + UINT MostDetailedMip; + UINT MipLevels; + UINT FirstArraySlice; + UINT ArraySize; + } D3D10_TEX1D_SRV; + +typedef struct D3D10_TEX2D_SRV + { + UINT MostDetailedMip; + UINT MipLevels; + UINT FirstArraySlice; + UINT ArraySize; + } D3D10_TEX2D_SRV; + +typedef struct D3D10_TEX3D_SRV + { + UINT MostDetailedMip; + UINT MipLevels; + } D3D10_TEX3D_SRV; + +typedef struct D3D10_TEXCUBE_SRV + { + UINT MostDetailedMip; + UINT MipLevels; + } D3D10_TEXCUBE_SRV; + +typedef struct D3D10_SHADER_RESOURCE_VIEW_DESC + { + DXGI_FORMAT Format; + D3D10_RESOURCE ResourceType; + union + { + D3D10_BUFFER_SRV Buffer; + D3D10_TEX1D_SRV Texture1D; + D3D10_TEX2D_SRV Texture2D; + D3D10_TEX3D_SRV Texture3D; + D3D10_TEXCUBE_SRV TextureCube; + } ; + } D3D10_SHADER_RESOURCE_VIEW_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0011_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0011_v0_0_s_ifspec; + +#ifndef __ID3D10ShaderResourceView_INTERFACE_DEFINED__ +#define __ID3D10ShaderResourceView_INTERFACE_DEFINED__ + +/* interface ID3D10ShaderResourceView */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10ShaderResourceView; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C07-342C-4106-A19F-4F2704F689F0") + ID3D10ShaderResourceView : public ID3D10View + { + public: + virtual void STDMETHODCALLTYPE GetDesc( + /* [retval][out] */ D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10ShaderResourceViewVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10ShaderResourceView * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10ShaderResourceView * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10ShaderResourceView * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10ShaderResourceView * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10ShaderResourceView * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10ShaderResourceView * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10ShaderResourceView * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *GetResource )( + ID3D10ShaderResourceView * This, + /* [retval][out] */ ID3D10Resource **ppResource); + + void ( STDMETHODCALLTYPE *GetDesc )( + ID3D10ShaderResourceView * This, + /* [retval][out] */ D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc); + + END_INTERFACE + } ID3D10ShaderResourceViewVtbl; + + interface ID3D10ShaderResourceView + { + CONST_VTBL struct ID3D10ShaderResourceViewVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10ShaderResourceView_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10ShaderResourceView_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10ShaderResourceView_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10ShaderResourceView_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10ShaderResourceView_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10ShaderResourceView_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10ShaderResourceView_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10ShaderResourceView_GetResource(This,ppResource) \ + ( (This)->lpVtbl -> GetResource(This,ppResource) ) + + +#define ID3D10ShaderResourceView_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10ShaderResourceView_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0012 */ +/* [local] */ + +typedef struct D3D10_BUFFER_RTV + { + SIZE_T ElementOffset; + SIZE_T ElementWidth; + } D3D10_BUFFER_RTV; + +typedef struct D3D10_TEX1D_RTV + { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; + } D3D10_TEX1D_RTV; + +typedef struct D3D10_TEX2D_RTV + { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; + } D3D10_TEX2D_RTV; + +typedef struct D3D10_TEX3D_RTV + { + UINT MipSlice; + UINT FirstWSlice; + UINT WSize; + } D3D10_TEX3D_RTV; + +typedef struct D3D10_TEXCUBE_RTV + { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; + } D3D10_TEXCUBE_RTV; + +typedef struct D3D10_RENDER_TARGET_VIEW_DESC + { + DXGI_FORMAT Format; + D3D10_RESOURCE ResourceType; + union + { + D3D10_BUFFER_RTV Buffer; + D3D10_TEX1D_RTV Texture1D; + D3D10_TEX2D_RTV Texture2D; + D3D10_TEX3D_RTV Texture3D; + D3D10_TEXCUBE_RTV TextureCube; + } ; + } D3D10_RENDER_TARGET_VIEW_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0012_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0012_v0_0_s_ifspec; + +#ifndef __ID3D10RenderTargetView_INTERFACE_DEFINED__ +#define __ID3D10RenderTargetView_INTERFACE_DEFINED__ + +/* interface ID3D10RenderTargetView */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10RenderTargetView; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C08-342C-4106-A19F-4F2704F689F0") + ID3D10RenderTargetView : public ID3D10View + { + public: + virtual void STDMETHODCALLTYPE GetDesc( + /* [retval][out] */ D3D10_RENDER_TARGET_VIEW_DESC *pDesc) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10RenderTargetViewVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10RenderTargetView * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10RenderTargetView * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10RenderTargetView * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10RenderTargetView * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10RenderTargetView * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10RenderTargetView * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10RenderTargetView * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *GetResource )( + ID3D10RenderTargetView * This, + /* [retval][out] */ ID3D10Resource **ppResource); + + void ( STDMETHODCALLTYPE *GetDesc )( + ID3D10RenderTargetView * This, + /* [retval][out] */ D3D10_RENDER_TARGET_VIEW_DESC *pDesc); + + END_INTERFACE + } ID3D10RenderTargetViewVtbl; + + interface ID3D10RenderTargetView + { + CONST_VTBL struct ID3D10RenderTargetViewVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10RenderTargetView_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10RenderTargetView_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10RenderTargetView_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10RenderTargetView_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10RenderTargetView_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10RenderTargetView_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10RenderTargetView_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10RenderTargetView_GetResource(This,ppResource) \ + ( (This)->lpVtbl -> GetResource(This,ppResource) ) + + +#define ID3D10RenderTargetView_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10RenderTargetView_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0013 */ +/* [local] */ + +typedef struct D3D10_TEX1D_DSV + { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; + } D3D10_TEX1D_DSV; + +typedef struct D3D10_TEX2D_DSV + { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; + } D3D10_TEX2D_DSV; + +typedef struct D3D10_TEXCUBE_DSV + { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; + } D3D10_TEXCUBE_DSV; + +typedef struct D3D10_DEPTH_STENCIL_VIEW_DESC + { + DXGI_FORMAT Format; + D3D10_RESOURCE ResourceType; + union + { + D3D10_TEX1D_DSV Texture1D; + D3D10_TEX2D_DSV Texture2D; + D3D10_TEXCUBE_DSV TextureCube; + } ; + } D3D10_DEPTH_STENCIL_VIEW_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0013_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0013_v0_0_s_ifspec; + +#ifndef __ID3D10DepthStencilView_INTERFACE_DEFINED__ +#define __ID3D10DepthStencilView_INTERFACE_DEFINED__ + +/* interface ID3D10DepthStencilView */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10DepthStencilView; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C09-342C-4106-A19F-4F2704F689F0") + ID3D10DepthStencilView : public ID3D10View + { + public: + virtual void STDMETHODCALLTYPE GetDesc( + /* [retval][out] */ D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10DepthStencilViewVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10DepthStencilView * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10DepthStencilView * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10DepthStencilView * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10DepthStencilView * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10DepthStencilView * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10DepthStencilView * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10DepthStencilView * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *GetResource )( + ID3D10DepthStencilView * This, + /* [retval][out] */ ID3D10Resource **ppResource); + + void ( STDMETHODCALLTYPE *GetDesc )( + ID3D10DepthStencilView * This, + /* [retval][out] */ D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc); + + END_INTERFACE + } ID3D10DepthStencilViewVtbl; + + interface ID3D10DepthStencilView + { + CONST_VTBL struct ID3D10DepthStencilViewVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10DepthStencilView_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10DepthStencilView_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10DepthStencilView_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10DepthStencilView_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10DepthStencilView_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10DepthStencilView_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10DepthStencilView_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10DepthStencilView_GetResource(This,ppResource) \ + ( (This)->lpVtbl -> GetResource(This,ppResource) ) + + +#define ID3D10DepthStencilView_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10DepthStencilView_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0014 */ +/* [local] */ + +typedef struct D3D10_VERTEX_SHADER_DESC + { + const BYTE *pFunction; + UINT SizeInBytes; + } D3D10_VERTEX_SHADER_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0014_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0014_v0_0_s_ifspec; + +#ifndef __ID3D10VertexShader_INTERFACE_DEFINED__ +#define __ID3D10VertexShader_INTERFACE_DEFINED__ + +/* interface ID3D10VertexShader */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10VertexShader; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C0A-342C-4106-A19F-4F2704F689F0") + ID3D10VertexShader : public ID3D10DeviceChild + { + public: + }; + +#else /* C style interface */ + + typedef struct ID3D10VertexShaderVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10VertexShader * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10VertexShader * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10VertexShader * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10VertexShader * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10VertexShader * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10VertexShader * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10VertexShader * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + END_INTERFACE + } ID3D10VertexShaderVtbl; + + interface ID3D10VertexShader + { + CONST_VTBL struct ID3D10VertexShaderVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10VertexShader_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10VertexShader_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10VertexShader_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10VertexShader_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10VertexShader_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10VertexShader_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10VertexShader_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10VertexShader_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0015 */ +/* [local] */ + +typedef struct D3D10_GEOMETRY_SHADER_DESC + { + const BYTE *pFunction; + UINT SizeInBytes; + const D3D10_SO_DECLARATION_ENTRY *pDeclaration; + SIZE_T NumElements; + UINT StreamStride; + } D3D10_GEOMETRY_SHADER_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0015_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0015_v0_0_s_ifspec; + +#ifndef __ID3D10GeometryShader_INTERFACE_DEFINED__ +#define __ID3D10GeometryShader_INTERFACE_DEFINED__ + +/* interface ID3D10GeometryShader */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10GeometryShader; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("6316BE88-54CD-4040-AB44-20461BC81F68") + ID3D10GeometryShader : public ID3D10DeviceChild + { + public: + }; + +#else /* C style interface */ + + typedef struct ID3D10GeometryShaderVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10GeometryShader * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10GeometryShader * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10GeometryShader * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10GeometryShader * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10GeometryShader * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10GeometryShader * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10GeometryShader * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + END_INTERFACE + } ID3D10GeometryShaderVtbl; + + interface ID3D10GeometryShader + { + CONST_VTBL struct ID3D10GeometryShaderVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10GeometryShader_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10GeometryShader_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10GeometryShader_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10GeometryShader_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10GeometryShader_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10GeometryShader_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10GeometryShader_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10GeometryShader_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0016 */ +/* [local] */ + +typedef struct D3D10_PIXEL_SHADER_DESC + { + const BYTE *pFunction; + UINT SizeInBytes; + } D3D10_PIXEL_SHADER_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0016_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0016_v0_0_s_ifspec; + +#ifndef __ID3D10PixelShader_INTERFACE_DEFINED__ +#define __ID3D10PixelShader_INTERFACE_DEFINED__ + +/* interface ID3D10PixelShader */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10PixelShader; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("4968B601-9D00-4cde-8346-8E7F675819B6") + ID3D10PixelShader : public ID3D10DeviceChild + { + public: + }; + +#else /* C style interface */ + + typedef struct ID3D10PixelShaderVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10PixelShader * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10PixelShader * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10PixelShader * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10PixelShader * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10PixelShader * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10PixelShader * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10PixelShader * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + END_INTERFACE + } ID3D10PixelShaderVtbl; + + interface ID3D10PixelShader + { + CONST_VTBL struct ID3D10PixelShaderVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10PixelShader_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10PixelShader_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10PixelShader_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10PixelShader_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10PixelShader_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10PixelShader_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10PixelShader_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10PixelShader_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0017 */ +/* [local] */ + +typedef struct D3D10_INPUT_LAYOUT_DESC + { + D3D10_INPUT_ELEMENT_DESC *pDeclaration; + SIZE_T NumElements; + const void *pShaderBytecodeWithInputSignature; + } D3D10_INPUT_LAYOUT_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0017_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0017_v0_0_s_ifspec; + +#ifndef __ID3D10InputLayout_INTERFACE_DEFINED__ +#define __ID3D10InputLayout_INTERFACE_DEFINED__ + +/* interface ID3D10InputLayout */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10InputLayout; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C0B-342C-4106-A19F-4F2704F689F0") + ID3D10InputLayout : public ID3D10DeviceChild + { + public: + }; + +#else /* C style interface */ + + typedef struct ID3D10InputLayoutVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10InputLayout * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10InputLayout * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10InputLayout * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10InputLayout * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10InputLayout * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10InputLayout * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10InputLayout * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + END_INTERFACE + } ID3D10InputLayoutVtbl; + + interface ID3D10InputLayout + { + CONST_VTBL struct ID3D10InputLayoutVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10InputLayout_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10InputLayout_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10InputLayout_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10InputLayout_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10InputLayout_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10InputLayout_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10InputLayout_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10InputLayout_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0018 */ +/* [local] */ + +typedef +enum D3D10_FILTER + { D3D10_FILTER_MIN_MAG_MIP_POINT = 0, + D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR = 0x1, + D3D10_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x4, + D3D10_FILTER_MIN_POINT_MAG_MIP_LINEAR = 0x5, + D3D10_FILTER_MIN_LINEAR_MAG_MIP_POINT = 0x10, + D3D10_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11, + D3D10_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x14, + D3D10_FILTER_MIN_MAG_MIP_LINEAR = 0x15, + D3D10_FILTER_ANISOTROPIC = 0x55, + D3D10_FILTER_COMPARISON_MIN_MAG_MIP_POINT = 0x80, + D3D10_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR = 0x81, + D3D10_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x84, + D3D10_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR = 0x85, + D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT = 0x90, + D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x91, + D3D10_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT = 0x94, + D3D10_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = 0x95, + D3D10_FILTER_COMPARISON_ANISOTROPIC = 0xd5, + D3D10_FILTER_TEXT_1BIT = 0x80000000 + } D3D10_FILTER; + +typedef +enum D3D10_FILTER_TYPE + { D3D10_FILTER_TYPE_POINT = 0, + D3D10_FILTER_TYPE_LINEAR = 1 + } D3D10_FILTER_TYPE; + +#define D3D10_FILTER_TYPE_MASK ( 0x3 ) + +#define D3D10_MIN_FILTER_SHIFT ( 4 ) + +#define D3D10_MAG_FILTER_SHIFT ( 2 ) + +#define D3D10_MIP_FILTER_SHIFT ( 0 ) + +#define D3D10_COMPARISON_FILTERING_BIT ( 0x80 ) + +#define D3D10_ANISOTROPIC_FILTERING_BIT ( 0x40 ) + +#define D3D10_TEXT_1BIT_BIT ( 0x80000000 ) + +#define D3D10_ENCODE_BASIC_FILTER( min, mag, mip, bComparison ) \ + ( D3D10_FILTER ) ( \ + ( ( bComparison ) ? D3D10_COMPARISON_FILTERING_BIT : 0 ) | \ + ( ( min & D3D10_FILTER_TYPE_MASK ) << D3D10_MIN_FILTER_SHIFT ) | \ + ( ( mag & D3D10_FILTER_TYPE_MASK ) << D3D10_MAG_FILTER_SHIFT ) | \ + ( ( mip & D3D10_FILTER_TYPE_MASK ) << D3D10_MIP_FILTER_SHIFT ) ) +#define D3D10_ENCODE_ANISOTROPIC_FILTER( bComparison ) \ + ( D3D10_FILTER ) ( \ + D3D10_ANISOTROPIC_FILTERING_BIT | \ + D3D10_ENCODE_BASIC_FILTER( D3D10_FILTER_TYPE_LINEAR, \ + D3D10_FILTER_TYPE_LINEAR, \ + D3D10_FILTER_TYPE_LINEAR, \ + bComparison ) ) +#define D3D10_DECODE_MIN_FILTER( d3d10Filter ) \ + (D3D10_FILTER_TYPE) \ + ( ( d3d10Filter >> D3D10_MIN_FILTER_SHIFT ) & D3D10_FILTER_TYPE_MASK ) +#define D3D10_DECODE_MAG_FILTER( d3d10Filter ) \ + (D3D10_FILTER_TYPE) \ + ( ( d3d10Filter >> D3D10_MAG_FILTER_SHIFT ) & D3D10_FILTER_TYPE_MASK ) +#define D3D10_DECODE_MIP_FILTER( d3d10Filter ) \ + (D3D10_FILTER_TYPE) \ + ( ( d3d10Filter >> D3D10_MIP_FILTER_SHIFT ) & D3D10_FILTER_TYPE_MASK ) +#define D3D10_DECODE_IS_COMPARISON_FILTER( d3d10Filter ) \ + ( d3d10Filter & D3D10_COMPARISON_FILTERING_BIT ) +#define D3D10_DECODE_IS_ANISOTROPIC_FILTER( d3d10Filter ) \ + ( ( d3d10Filter & D3D10_ANISOTROPIC_FILTERING_BIT ) && \ + ( D3D10_FILTER_TYPE_LINEAR == D3D10_DECODE_MIN_FILTER( d3d10Filter ) ) && \ + ( D3D10_FILTER_TYPE_LINEAR == D3D10_DECODE_MAG_FILTER( d3d10Filter ) ) && \ + ( D3D10_FILTER_TYPE_LINEAR == D3D10_DECODE_MIP_FILTER( d3d10Filter ) ) ) +#define D3D10_DECODE_IS_TEXT_1BIT_FILTER( d3d10Filter ) \ + ( d3d10Filter == D3D10_TEXT_1BIT_BIT ) +typedef +enum D3D10_TEXTURE_ADDRESS_MODE + { D3D10_TEXTURE_ADDRESS_WRAP = 1, + D3D10_TEXTURE_ADDRESS_MIRROR = 2, + D3D10_TEXTURE_ADDRESS_CLAMP = 3, + D3D10_TEXTURE_ADDRESS_BORDER = 4, + D3D10_TEXTURE_ADDRESS_MIRROR_ONCE = 5 + } D3D10_TEXTURE_ADDRESS_MODE; + +typedef struct D3D10_SAMPLER_DESC + { + D3D10_FILTER Filter; + D3D10_TEXTURE_ADDRESS_MODE AddressU; + D3D10_TEXTURE_ADDRESS_MODE AddressV; + D3D10_TEXTURE_ADDRESS_MODE AddressW; + FLOAT MipLODBias; + UINT MaxAnisotropy; + D3D10_COMPARISON_FUNC ComparisonFunc; + FLOAT BorderColor[ 4 ]; + FLOAT MinLOD; + FLOAT MaxLOD; + } D3D10_SAMPLER_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0018_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0018_v0_0_s_ifspec; + +#ifndef __ID3D10SamplerState_INTERFACE_DEFINED__ +#define __ID3D10SamplerState_INTERFACE_DEFINED__ + +/* interface ID3D10SamplerState */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10SamplerState; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C0C-342C-4106-A19F-4F2704F689F0") + ID3D10SamplerState : public ID3D10DeviceChild + { + public: + virtual void STDMETHODCALLTYPE GetDesc( + /* [retval][out] */ D3D10_SAMPLER_DESC *pDesc) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10SamplerStateVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10SamplerState * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10SamplerState * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10SamplerState * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10SamplerState * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10SamplerState * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10SamplerState * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10SamplerState * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *GetDesc )( + ID3D10SamplerState * This, + /* [retval][out] */ D3D10_SAMPLER_DESC *pDesc); + + END_INTERFACE + } ID3D10SamplerStateVtbl; + + interface ID3D10SamplerState + { + CONST_VTBL struct ID3D10SamplerStateVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10SamplerState_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10SamplerState_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10SamplerState_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10SamplerState_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10SamplerState_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10SamplerState_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10SamplerState_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10SamplerState_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10SamplerState_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0019 */ +/* [local] */ + +typedef +enum D3D10_FORMAT_SUPPORT + { D3D10_FORMAT_SUPPORT_BUFFER = 0x1, + D3D10_FORMAT_SUPPORT_IA_VERTEX_BUFFER = 0x2, + D3D10_FORMAT_SUPPORT_IA_INDEX_BUFFER = 0x4, + D3D10_FORMAT_SUPPORT_SO_BUFFER = 0x8, + D3D10_FORMAT_SUPPORT_TEXTURE1D = 0x10, + D3D10_FORMAT_SUPPORT_TEXTURE2D = 0x20, + D3D10_FORMAT_SUPPORT_TEXTURE3D = 0x40, + D3D10_FORMAT_SUPPORT_TEXTURECUBE = 0x80, + D3D10_FORMAT_SUPPORT_SHADER_LOAD = 0x100, + D3D10_FORMAT_SUPPORT_SHADER_SAMPLE = 0x200, + D3D10_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON = 0x400, + D3D10_FORMAT_SUPPORT_SHADER_SAMPLE_MONO_TEXT = 0x800, + D3D10_FORMAT_SUPPORT_MIP = 0x1000, + D3D10_FORMAT_SUPPORT_MIP_AUTOGEN = 0x2000, + D3D10_FORMAT_SUPPORT_RENDER_TARGET = 0x4000, + D3D10_FORMAT_SUPPORT_BLENDABLE = 0x8000, + D3D10_FORMAT_SUPPORT_DEPTH_STENCIL = 0x10000, + D3D10_FORMAT_SUPPORT_CPU_LOCKABLE = 0x20000, + D3D10_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE = 0x40000, + D3D10_FORMAT_SUPPORT_DISPLAY = 0x80000, + D3D10_FORMAT_SUPPORT_CAST_WITHIN_BIT_LAYOUT = 0x100000 + } D3D10_FORMAT_SUPPORT; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0019_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0019_v0_0_s_ifspec; + +#ifndef __ID3D10Asynchronous_INTERFACE_DEFINED__ +#define __ID3D10Asynchronous_INTERFACE_DEFINED__ + +/* interface ID3D10Asynchronous */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10Asynchronous; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C0D-342C-4106-A19F-4F2704F689F0") + ID3D10Asynchronous : public ID3D10DeviceChild + { + public: + virtual void STDMETHODCALLTYPE Begin( void) = 0; + + virtual void STDMETHODCALLTYPE End( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetData( + /* [size_is][out] */ void *pData, + /* [in] */ SIZE_T DataSize, + /* [in] */ UINT Flags) = 0; + + virtual SIZE_T STDMETHODCALLTYPE GetDataSize( void) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10AsynchronousVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10Asynchronous * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10Asynchronous * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10Asynchronous * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10Asynchronous * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10Asynchronous * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10Asynchronous * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10Asynchronous * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *Begin )( + ID3D10Asynchronous * This); + + void ( STDMETHODCALLTYPE *End )( + ID3D10Asynchronous * This); + + HRESULT ( STDMETHODCALLTYPE *GetData )( + ID3D10Asynchronous * This, + /* [size_is][out] */ void *pData, + /* [in] */ SIZE_T DataSize, + /* [in] */ UINT Flags); + + SIZE_T ( STDMETHODCALLTYPE *GetDataSize )( + ID3D10Asynchronous * This); + + END_INTERFACE + } ID3D10AsynchronousVtbl; + + interface ID3D10Asynchronous + { + CONST_VTBL struct ID3D10AsynchronousVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10Asynchronous_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10Asynchronous_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10Asynchronous_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10Asynchronous_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10Asynchronous_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10Asynchronous_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10Asynchronous_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10Asynchronous_Begin(This) \ + ( (This)->lpVtbl -> Begin(This) ) + +#define ID3D10Asynchronous_End(This) \ + ( (This)->lpVtbl -> End(This) ) + +#define ID3D10Asynchronous_GetData(This,pData,DataSize,Flags) \ + ( (This)->lpVtbl -> GetData(This,pData,DataSize,Flags) ) + +#define ID3D10Asynchronous_GetDataSize(This) \ + ( (This)->lpVtbl -> GetDataSize(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10Asynchronous_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0020 */ +/* [local] */ + +#define D3D10_GETDATA_DONOTFLUSH ( 1 ) + +typedef +enum D3D10_QUERY + { D3D10_QUERY_EVENT = 0, + D3D10_QUERY_OCCLUSION = ( D3D10_QUERY_EVENT + 1 ) , + D3D10_QUERY_TIMESTAMP = ( D3D10_QUERY_OCCLUSION + 1 ) , + D3D10_QUERY_TIMESTAMP_DISJOINT = ( D3D10_QUERY_TIMESTAMP + 1 ) , + D3D10_QUERY_PIPELINE_STATISTICS = ( D3D10_QUERY_TIMESTAMP_DISJOINT + 1 ) , + D3D10_QUERY_OCCLUSION_PREDICATE = ( D3D10_QUERY_PIPELINE_STATISTICS + 1 ) , + D3D10_QUERY_SO_STATISTICS = ( D3D10_QUERY_OCCLUSION_PREDICATE + 1 ) , + D3D10_QUERY_SO_OVERFLOW_PREDICATE = ( D3D10_QUERY_SO_STATISTICS + 1 ) + } D3D10_QUERY; + +#define D3D10_QUERY_MISCFLAG_PREDICATEHINT ( 0x1 ) + +typedef struct D3D10_QUERY_DESC + { + D3D10_QUERY Query; + UINT MiscFlags; + } D3D10_QUERY_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0020_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0020_v0_0_s_ifspec; + +#ifndef __ID3D10Query_INTERFACE_DEFINED__ +#define __ID3D10Query_INTERFACE_DEFINED__ + +/* interface ID3D10Query */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10Query; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C0E-342C-4106-A19F-4F2704F689F0") + ID3D10Query : public ID3D10Asynchronous + { + public: + }; + +#else /* C style interface */ + + typedef struct ID3D10QueryVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10Query * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10Query * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10Query * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10Query * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10Query * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10Query * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10Query * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *Begin )( + ID3D10Query * This); + + void ( STDMETHODCALLTYPE *End )( + ID3D10Query * This); + + HRESULT ( STDMETHODCALLTYPE *GetData )( + ID3D10Query * This, + /* [size_is][out] */ void *pData, + /* [in] */ SIZE_T DataSize, + /* [in] */ UINT Flags); + + SIZE_T ( STDMETHODCALLTYPE *GetDataSize )( + ID3D10Query * This); + + END_INTERFACE + } ID3D10QueryVtbl; + + interface ID3D10Query + { + CONST_VTBL struct ID3D10QueryVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10Query_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10Query_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10Query_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10Query_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10Query_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10Query_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10Query_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10Query_Begin(This) \ + ( (This)->lpVtbl -> Begin(This) ) + +#define ID3D10Query_End(This) \ + ( (This)->lpVtbl -> End(This) ) + +#define ID3D10Query_GetData(This,pData,DataSize,Flags) \ + ( (This)->lpVtbl -> GetData(This,pData,DataSize,Flags) ) + +#define ID3D10Query_GetDataSize(This) \ + ( (This)->lpVtbl -> GetDataSize(This) ) + + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10Query_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D10Predicate_INTERFACE_DEFINED__ +#define __ID3D10Predicate_INTERFACE_DEFINED__ + +/* interface ID3D10Predicate */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10Predicate; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C10-342C-4106-A19F-4F2704F689F0") + ID3D10Predicate : public ID3D10Query + { + public: + }; + +#else /* C style interface */ + + typedef struct ID3D10PredicateVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10Predicate * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10Predicate * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10Predicate * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10Predicate * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10Predicate * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10Predicate * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10Predicate * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *Begin )( + ID3D10Predicate * This); + + void ( STDMETHODCALLTYPE *End )( + ID3D10Predicate * This); + + HRESULT ( STDMETHODCALLTYPE *GetData )( + ID3D10Predicate * This, + /* [size_is][out] */ void *pData, + /* [in] */ SIZE_T DataSize, + /* [in] */ UINT Flags); + + SIZE_T ( STDMETHODCALLTYPE *GetDataSize )( + ID3D10Predicate * This); + + END_INTERFACE + } ID3D10PredicateVtbl; + + interface ID3D10Predicate + { + CONST_VTBL struct ID3D10PredicateVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10Predicate_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10Predicate_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10Predicate_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10Predicate_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10Predicate_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10Predicate_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10Predicate_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10Predicate_Begin(This) \ + ( (This)->lpVtbl -> Begin(This) ) + +#define ID3D10Predicate_End(This) \ + ( (This)->lpVtbl -> End(This) ) + +#define ID3D10Predicate_GetData(This,pData,DataSize,Flags) \ + ( (This)->lpVtbl -> GetData(This,pData,DataSize,Flags) ) + +#define ID3D10Predicate_GetDataSize(This) \ + ( (This)->lpVtbl -> GetDataSize(This) ) + + + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10Predicate_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0022 */ +/* [local] */ + +typedef struct D3D10_QUERY_DATA_TIMESTAMP_DISJOINT + { + UINT64 Frequency; + BOOL Disjoint; + } D3D10_QUERY_DATA_TIMESTAMP_DISJOINT; + +typedef struct D3D10_QUERY_DATA_PIPELINE_STATISTICS + { + UINT64 IAVertices; + UINT64 IAPrimitives; + UINT64 VSInvocations; + UINT64 GSInvocations; + UINT64 GSPrimitives; + UINT64 CInvocations; + UINT64 CPrimitives; + UINT64 PSInvocations; + } D3D10_QUERY_DATA_PIPELINE_STATISTICS; + +typedef struct D3D10_QUERY_DATA_SO_STATISTICS + { + UINT64 NumPrimitivesWritten; + UINT64 PrimitivesStorageNeeded; + } D3D10_QUERY_DATA_SO_STATISTICS; + +typedef +enum D3D10_COUNTER + { D3D10_COUNTER_GPU_IDLE = 0, + D3D10_COUNTER_VERTEX_PROCESSING = ( D3D10_COUNTER_GPU_IDLE + 1 ) , + D3D10_COUNTER_GEOMETRY_PROCESSING = ( D3D10_COUNTER_VERTEX_PROCESSING + 1 ) , + D3D10_COUNTER_PIXEL_PROCESSING = ( D3D10_COUNTER_GEOMETRY_PROCESSING + 1 ) , + D3D10_COUNTER_OTHER_GPU_PROCESSING = ( D3D10_COUNTER_PIXEL_PROCESSING + 1 ) , + D3D10_COUNTER_HOST_ADAPTER_BANDWIDTH_UTILIZATION = ( D3D10_COUNTER_OTHER_GPU_PROCESSING + 1 ) , + D3D10_COUNTER_LOCAL_VIDMEM_BANDWIDTH_UTILIZATION = ( D3D10_COUNTER_HOST_ADAPTER_BANDWIDTH_UTILIZATION + 1 ) , + D3D10_COUNTER_VERTEX_THROUGHPUT_UTILIZATION = ( D3D10_COUNTER_LOCAL_VIDMEM_BANDWIDTH_UTILIZATION + 1 ) , + D3D10_COUNTER_TRIANGLE_SETUP_THROUGHPUT_UTILIZATION = ( D3D10_COUNTER_VERTEX_THROUGHPUT_UTILIZATION + 1 ) , + D3D10_COUNTER_FILLRATE_THROUGHPUT_UTILIZATION = ( D3D10_COUNTER_TRIANGLE_SETUP_THROUGHPUT_UTILIZATION + 1 ) , + D3D10_COUNTER_VS_MEMORY_LIMITED = ( D3D10_COUNTER_FILLRATE_THROUGHPUT_UTILIZATION + 1 ) , + D3D10_COUNTER_VS_COMPUTATION_LIMITED = ( D3D10_COUNTER_VS_MEMORY_LIMITED + 1 ) , + D3D10_COUNTER_GS_MEMORY_LIMITED = ( D3D10_COUNTER_VS_COMPUTATION_LIMITED + 1 ) , + D3D10_COUNTER_GS_COMPUTATION_LIMITED = ( D3D10_COUNTER_GS_MEMORY_LIMITED + 1 ) , + D3D10_COUNTER_PS_MEMORY_LIMITED = ( D3D10_COUNTER_GS_COMPUTATION_LIMITED + 1 ) , + D3D10_COUNTER_PS_COMPUTATION_LIMITED = ( D3D10_COUNTER_PS_MEMORY_LIMITED + 1 ) , + D3D10_COUNTER_POST_TRANSFORM_CACHE_HIT_RATE = ( D3D10_COUNTER_PS_COMPUTATION_LIMITED + 1 ) , + D3D10_COUNTER_TEXTURE_CACHE_HIT_RATE = ( D3D10_COUNTER_POST_TRANSFORM_CACHE_HIT_RATE + 1 ) , + D3D10_COUNTER_DEVICE_DEPENDENT_0 = 0x40000000 + } D3D10_COUNTER; + +typedef +enum D3D10_COUNTER_TYPE + { D3D10_COUNTER_TYPE_FLOAT32 = 0, + D3D10_COUNTER_TYPE_UINT16 = ( D3D10_COUNTER_TYPE_FLOAT32 + 1 ) , + D3D10_COUNTER_TYPE_UINT32 = ( D3D10_COUNTER_TYPE_UINT16 + 1 ) , + D3D10_COUNTER_TYPE_UINT64 = ( D3D10_COUNTER_TYPE_UINT32 + 1 ) + } D3D10_COUNTER_TYPE; + +typedef struct D3D10_COUNTER_DESC + { + D3D10_COUNTER Counter; + UINT MiscFlags; + } D3D10_COUNTER_DESC; + +typedef struct D3D10_COUNTER_INFO + { + D3D10_COUNTER LastDeviceDependentCounter; + UINT NumSimultaneousCounters; + UINT8 NumDetectableParallelUnits; + } D3D10_COUNTER_INFO; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0022_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0022_v0_0_s_ifspec; + +#ifndef __ID3D10Counter_INTERFACE_DEFINED__ +#define __ID3D10Counter_INTERFACE_DEFINED__ + +/* interface ID3D10Counter */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10Counter; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C11-342C-4106-A19F-4F2704F689F0") + ID3D10Counter : public ID3D10Asynchronous + { + public: + }; + +#else /* C style interface */ + + typedef struct ID3D10CounterVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10Counter * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10Counter * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10Counter * This); + + void ( STDMETHODCALLTYPE *GetDevice )( + ID3D10Counter * This, + /* [retval][out] */ ID3D10Device **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10Counter * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10Counter * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10Counter * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *Begin )( + ID3D10Counter * This); + + void ( STDMETHODCALLTYPE *End )( + ID3D10Counter * This); + + HRESULT ( STDMETHODCALLTYPE *GetData )( + ID3D10Counter * This, + /* [size_is][out] */ void *pData, + /* [in] */ SIZE_T DataSize, + /* [in] */ UINT Flags); + + SIZE_T ( STDMETHODCALLTYPE *GetDataSize )( + ID3D10Counter * This); + + END_INTERFACE + } ID3D10CounterVtbl; + + interface ID3D10Counter + { + CONST_VTBL struct ID3D10CounterVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10Counter_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10Counter_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10Counter_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10Counter_GetDevice(This,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,ppDevice) ) + +#define ID3D10Counter_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10Counter_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10Counter_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + + +#define ID3D10Counter_Begin(This) \ + ( (This)->lpVtbl -> Begin(This) ) + +#define ID3D10Counter_End(This) \ + ( (This)->lpVtbl -> End(This) ) + +#define ID3D10Counter_GetData(This,pData,DataSize,Flags) \ + ( (This)->lpVtbl -> GetData(This,pData,DataSize,Flags) ) + +#define ID3D10Counter_GetDataSize(This) \ + ( (This)->lpVtbl -> GetDataSize(This) ) + + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10Counter_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D10Device_INTERFACE_DEFINED__ +#define __ID3D10Device_INTERFACE_DEFINED__ + +/* interface ID3D10Device */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10Device; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4C0F-342C-4106-A19F-4F2704F689F0") + ID3D10Device : public IUnknown + { + public: + virtual void STDMETHODCALLTYPE VSSetConstantBuffers( + /* [in] */ UINT StartConstantSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][in] */ ID3D10Buffer *const *ppConstantBuffers) = 0; + + virtual void STDMETHODCALLTYPE PSSetShaderResources( + /* [in] */ UINT Offset, + /* [in] */ UINT NumViews, + /* [size_is][in] */ ID3D10ShaderResourceView *const *ppShaderResourceViews) = 0; + + virtual void STDMETHODCALLTYPE PSSetShader( + /* [in] */ ID3D10PixelShader *pPixelShader) = 0; + + virtual void STDMETHODCALLTYPE PSSetSamplers( + /* [in] */ UINT Offset, + /* [in] */ UINT NumSamplers, + /* [size_is][in] */ ID3D10SamplerState *const *ppSamplers) = 0; + + virtual void STDMETHODCALLTYPE VSSetShader( + /* [in] */ ID3D10VertexShader *pVertexShader) = 0; + + virtual void STDMETHODCALLTYPE DrawIndexed( + /* [in] */ UINT IndexCount, + /* [in] */ UINT StartIndexLocation, + /* [in] */ INT BaseVertexLocation) = 0; + + virtual void STDMETHODCALLTYPE Draw( + /* [in] */ UINT VertexCount, + /* [in] */ UINT StartVertexLocation) = 0; + + virtual void STDMETHODCALLTYPE PSSetConstantBuffers( + /* [in] */ UINT StartConstantSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][in] */ ID3D10Buffer *const *ppConstantBuffers) = 0; + + virtual void STDMETHODCALLTYPE IASetInputLayout( + /* [in] */ ID3D10InputLayout *pInputLayout) = 0; + + virtual void STDMETHODCALLTYPE IASetVertexBuffers( + /* [in] */ UINT StartSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][in] */ ID3D10Buffer *const *ppVertexBuffers, + /* [size_is][in] */ const UINT *pStrides, + /* [size_is][in] */ const UINT *pOffsets) = 0; + + virtual void STDMETHODCALLTYPE IASetIndexBuffer( + /* [in] */ ID3D10Buffer *pIndexBuffer, + /* [in] */ DXGI_FORMAT Format, + /* [in] */ UINT Offset) = 0; + + virtual void STDMETHODCALLTYPE DrawIndexedInstanced( + /* [in] */ UINT IndexCountPerInstance, + /* [in] */ UINT InstanceCount, + /* [in] */ UINT StartIndexLocation, + /* [in] */ INT BaseVertexLocation, + /* [in] */ UINT StartInstanceLocation) = 0; + + virtual void STDMETHODCALLTYPE DrawInstanced( + /* [in] */ UINT VertexCountPerInstance, + /* [in] */ UINT InstanceCount, + /* [in] */ UINT StartVertexLocation, + /* [in] */ UINT StartInstanceLocation) = 0; + + virtual void STDMETHODCALLTYPE GSSetConstantBuffers( + /* [in] */ UINT StartConstantSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][in] */ ID3D10Buffer *const *ppConstantBuffers) = 0; + + virtual void STDMETHODCALLTYPE GSSetShader( + /* [in] */ ID3D10GeometryShader *pShader) = 0; + + virtual void STDMETHODCALLTYPE IASetPrimitiveTopology( + /* [in] */ D3D10_PRIMITIVE_TOPOLOGY Topology) = 0; + + virtual void STDMETHODCALLTYPE VSSetShaderResources( + /* [in] */ UINT Offset, + /* [in] */ UINT NumViews, + /* [size_is][in] */ ID3D10ShaderResourceView *const *ppShaderResourceViews) = 0; + + virtual void STDMETHODCALLTYPE VSSetSamplers( + /* [in] */ UINT Offset, + /* [in] */ UINT NumSamplers, + /* [size_is][in] */ ID3D10SamplerState *const *ppSamplers) = 0; + + virtual void STDMETHODCALLTYPE SetPredication( + /* [in] */ ID3D10Predicate *pPredicate, + /* [in] */ BOOL PredicateValue) = 0; + + virtual void STDMETHODCALLTYPE GSSetShaderResources( + /* [in] */ UINT Offset, + /* [in] */ UINT NumViews, + /* [size_is][in] */ ID3D10ShaderResourceView *const *ppShaderResourceViews) = 0; + + virtual void STDMETHODCALLTYPE GSSetSamplers( + /* [in] */ UINT Offset, + /* [in] */ UINT NumSamplers, + /* [size_is][in] */ ID3D10SamplerState *const *ppSamplers) = 0; + + virtual void STDMETHODCALLTYPE OMSetRenderTargets( + /* [in] */ UINT NumViews, + /* [size_is][in] */ ID3D10RenderTargetView *const *ppRenderTargetViews, + /* [in] */ ID3D10DepthStencilView *pDepthStencilView) = 0; + + virtual void STDMETHODCALLTYPE OMSetBlendState( + /* [in] */ ID3D10BlendState *pBlendState, + /* [in] */ const FLOAT BlendFactor[ 4 ], + /* [in] */ UINT SampleMask) = 0; + + virtual void STDMETHODCALLTYPE OMSetDepthStencilState( + /* [in] */ ID3D10DepthStencilState *pDepthStencilState, + /* [in] */ UINT StencilRef) = 0; + + virtual void STDMETHODCALLTYPE SOSetTargets( + /* [in] */ UINT NumBuffers, + /* [size_is][in] */ ID3D10Buffer *const *ppSOTargets, + /* [size_is][in] */ const UINT *pOffsets) = 0; + + virtual void STDMETHODCALLTYPE DrawAuto( void) = 0; + + virtual void STDMETHODCALLTYPE RSSetState( + /* [in] */ ID3D10RasterizerState *pRasterizerState) = 0; + + virtual void STDMETHODCALLTYPE RSSetViewports( + /* [in] */ UINT NumViewports, + /* [size_is][in] */ const D3D10_VIEWPORT *pViewports) = 0; + + virtual void STDMETHODCALLTYPE RSSetScissorRects( + /* [in] */ UINT NumRects, + /* [size_is][in] */ const D3D10_RECT *pRects) = 0; + + virtual void STDMETHODCALLTYPE ClearRenderTargetView( + /* [in] */ ID3D10RenderTargetView *pRenderTargetView, + /* [in] */ const FLOAT ColorRGBA[ 4 ]) = 0; + + virtual void STDMETHODCALLTYPE ClearDepthStencilView( + /* [in] */ ID3D10DepthStencilView *pDepthStencilView, + /* [in] */ UINT Flags, + /* [in] */ FLOAT Depth, + /* [in] */ UINT8 Stencil) = 0; + + virtual HRESULT STDMETHODCALLTYPE GenerateMips( + /* [in] */ ID3D10ShaderResourceView *pShaderResourceView) = 0; + + virtual void STDMETHODCALLTYPE VSGetConstantBuffers( + /* [in] */ UINT StartConstantSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][out] */ ID3D10Buffer **ppConstantBuffers) = 0; + + virtual void STDMETHODCALLTYPE PSGetShaderResources( + /* [in] */ UINT Offset, + /* [in] */ UINT NumViews, + /* [size_is][out] */ ID3D10ShaderResourceView **ppShaderResourceViews) = 0; + + virtual void STDMETHODCALLTYPE PSGetShader( + /* [out][in] */ ID3D10PixelShader **ppPixelShader) = 0; + + virtual void STDMETHODCALLTYPE PSGetSamplers( + /* [in] */ UINT Offset, + /* [in] */ UINT NumSamplers, + /* [size_is][out] */ ID3D10SamplerState **ppSamplers) = 0; + + virtual void STDMETHODCALLTYPE VSGetShader( + /* [out][in] */ ID3D10VertexShader **ppVertexShader) = 0; + + virtual void STDMETHODCALLTYPE PSGetConstantBuffers( + /* [in] */ UINT StartConstantSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][out] */ ID3D10Buffer **ppConstantBuffers) = 0; + + virtual void STDMETHODCALLTYPE IAGetInputLayout( + /* [out][in] */ ID3D10InputLayout **ppInputLayout) = 0; + + virtual void STDMETHODCALLTYPE IAGetVertexBuffers( + /* [in] */ UINT StartSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][out] */ ID3D10Buffer **ppVertexBuffers, + /* [size_is][out] */ UINT *pStrides, + /* [size_is][out] */ UINT *pOffsets) = 0; + + virtual void STDMETHODCALLTYPE IAGetIndexBuffer( + /* [out] */ ID3D10Buffer **pIndexBuffer, + /* [out] */ DXGI_FORMAT *Format, + /* [out] */ UINT *Offset) = 0; + + virtual void STDMETHODCALLTYPE GSGetConstantBuffers( + /* [in] */ UINT StartConstantSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][out] */ ID3D10Buffer **ppConstantBuffers) = 0; + + virtual void STDMETHODCALLTYPE GSGetShader( + /* [out] */ ID3D10GeometryShader **ppGeometryShader) = 0; + + virtual void STDMETHODCALLTYPE IAGetPrimitiveTopology( + /* [out] */ D3D10_PRIMITIVE_TOPOLOGY *pTopology) = 0; + + virtual void STDMETHODCALLTYPE VSGetShaderResources( + /* [in] */ UINT Offset, + /* [in] */ UINT NumViews, + /* [size_is][out] */ ID3D10ShaderResourceView **ppShaderResourceViews) = 0; + + virtual void STDMETHODCALLTYPE VSGetSamplers( + /* [in] */ UINT Offset, + /* [in] */ UINT NumSamplers, + /* [size_is][out] */ ID3D10SamplerState **ppSamplers) = 0; + + virtual void STDMETHODCALLTYPE GetPredication( + /* [out] */ ID3D10Predicate **ppPredicate, + /* [out] */ BOOL *pPredicateValue) = 0; + + virtual void STDMETHODCALLTYPE GSGetShaderResources( + /* [in] */ UINT Offset, + /* [in] */ UINT NumViews, + /* [size_is][out] */ ID3D10ShaderResourceView **ppShaderResourceViews) = 0; + + virtual void STDMETHODCALLTYPE GSGetSamplers( + /* [in] */ UINT Offset, + /* [in] */ UINT NumSamplers, + /* [size_is][out] */ ID3D10SamplerState **ppSamplers) = 0; + + virtual void STDMETHODCALLTYPE OMGetRenderTargets( + /* [in] */ UINT NumViews, + /* [size_is][out] */ ID3D10RenderTargetView **ppRenderTargetViews, + /* [out] */ ID3D10DepthStencilView **ppDepthStencilView) = 0; + + virtual void STDMETHODCALLTYPE OMGetBlendState( + /* [out] */ ID3D10BlendState **ppBlendState, + /* [out] */ FLOAT BlendFactor[ 4 ], + /* [out] */ UINT *pSampleMask) = 0; + + virtual void STDMETHODCALLTYPE OMGetDepthStencilState( + /* [out] */ ID3D10DepthStencilState **ppDepthStencilState, + /* [out] */ UINT *pStencilRef) = 0; + + virtual void STDMETHODCALLTYPE SOGetTargets( + /* [in] */ UINT NumBuffers, + /* [size_is][out] */ ID3D10Buffer **ppSOTargets, + /* [size_is][out] */ UINT *pOffsets) = 0; + + virtual void STDMETHODCALLTYPE RSGetState( + /* [out] */ ID3D10RasterizerState **ppRasterizerState) = 0; + + virtual void STDMETHODCALLTYPE RSGetViewports( + /* [out][in] */ UINT *NumViewports, + /* [size_is][out] */ D3D10_VIEWPORT *pViewports) = 0; + + virtual void STDMETHODCALLTYPE RSGetScissorRects( + /* [out][in] */ UINT *NumRects, + /* [size_is][out] */ D3D10_RECT *pRects) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetDeviceRemovedReason( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetExceptionMode( + UINT RaiseFlags) = 0; + + virtual UINT STDMETHODCALLTYPE GetExceptionMode( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetPrivateData( + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetPrivateData( + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData) = 0; + + virtual void STDMETHODCALLTYPE Enter( void) = 0; + + virtual void STDMETHODCALLTYPE Leave( void) = 0; + + virtual void STDMETHODCALLTYPE Flush( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateBuffer( + /* [in] */ const D3D10_BUFFER_DESC *pDesc, + /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, + /* [out] */ ID3D10Buffer **ppBuffer) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateTexture1D( + /* [in] */ const D3D10_TEXTURE1D_DESC *pDesc, + /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, + /* [out] */ ID3D10Texture1D **ppTexture1D) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateTexture2D( + /* [in] */ const D3D10_TEXTURE2D_DESC *pDesc, + /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, + /* [out] */ ID3D10Texture2D **ppTexture2D) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateTexture3D( + /* [in] */ const D3D10_TEXTURE3D_DESC *pDesc, + /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, + /* [out] */ ID3D10Texture3D **ppTexture3D) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateTextureCube( + /* [in] */ const D3D10_TEXTURECUBE_DESC *pDesc, + /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, + /* [out] */ ID3D10TextureCube **ppTextureCube) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateShaderResourceView( + /* [in] */ ID3D10Resource *pResource, + /* [in] */ const D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc, + /* [out] */ ID3D10ShaderResourceView **ppSRView) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateRenderTargetView( + /* [in] */ ID3D10Resource *pResource, + /* [in] */ const D3D10_RENDER_TARGET_VIEW_DESC *pDesc, + /* [out] */ ID3D10RenderTargetView **ppRTView) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateDepthStencilView( + /* [in] */ ID3D10Resource *pResource, + /* [in] */ const D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc, + /* [out] */ ID3D10DepthStencilView **ppDepthStencilView) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateInputLayout( + /* [size_is][in] */ const D3D10_INPUT_ELEMENT_DESC *pInputElementDescs, + /* [in] */ UINT NumElements, + /* [in] */ const void *pShaderBytecodeWithInputSignature, + /* [out] */ ID3D10InputLayout **ppInputLayout) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateVertexShader( + /* [in] */ const void *pShaderBytecode, + /* [out] */ ID3D10VertexShader **ppVertexShader) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateGeometryShader( + /* [in] */ const void *pShaderBytecode, + /* [out] */ ID3D10GeometryShader **ppGeometryShader) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateGeometryShaderWithStreamOutput( + /* [in] */ const void *pShaderBytecode, + /* [size_is][in] */ const D3D10_SO_DECLARATION_ENTRY *pSODeclaration, + /* [in] */ UINT NumEntries, + /* [in] */ UINT OutputStreamStride, + /* [out] */ ID3D10GeometryShader **ppGeometryShader) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreatePixelShader( + /* [in] */ const void *pShaderBytecode, + /* [out] */ ID3D10PixelShader **ppPixelShader) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateBlendState( + /* [in] */ const D3D10_BLEND_DESC *pBlendStateDesc, + /* [out] */ ID3D10BlendState **ppBlendState) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateDepthStencilState( + /* [in] */ const D3D10_DEPTH_STENCIL_DESC *pDepthStencilDesc, + /* [out] */ ID3D10DepthStencilState **ppDepthStencilState) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateRasterizerState( + /* [in] */ const D3D10_RASTERIZER_DESC *pRasterizerDesc, + /* [out] */ ID3D10RasterizerState **ppRasterizerState) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateSamplerState( + /* [in] */ const D3D10_SAMPLER_DESC *pSamplerDesc, + /* [out] */ ID3D10SamplerState **ppSamplerState) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateQuery( + /* [in] */ const D3D10_QUERY_DESC *pQueryDesc, + /* [out] */ ID3D10Query **ppQuery) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreatePredicate( + /* [in] */ const D3D10_QUERY_DESC *pPredicateDesc, + /* [out] */ ID3D10Predicate **ppPredicate) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateCounter( + /* [in] */ const D3D10_COUNTER_DESC *pCounterDesc, + /* [out] */ ID3D10Counter **ppCounter) = 0; + + virtual HRESULT STDMETHODCALLTYPE CheckFormatSupport( + /* [in] */ DXGI_FORMAT Format, + /* [retval][out] */ UINT *pFormatSupport) = 0; + + virtual HRESULT STDMETHODCALLTYPE CheckMultisampleQualityLevels( + /* [in] */ UINT SampleCount, + /* [retval][out] */ UINT *pNumQualityLevels) = 0; + + virtual void STDMETHODCALLTYPE CheckVertexCache( + /* [out] */ D3D10_VERTEX_CACHE_DESC *pVertexCacheDesc) = 0; + + virtual void STDMETHODCALLTYPE CheckCounterInfo( + /* [retval][out] */ D3D10_COUNTER_INFO *pCounterInfo) = 0; + + virtual HRESULT STDMETHODCALLTYPE CheckCounter( + /* */ + __in const D3D10_COUNTER_DESC *pDesc, + /* */ + __out D3D10_COUNTER_TYPE *pType, + /* */ + __out UINT *pActiveCounters, + /* */ + __out_ecount_opt(*pNameLength) LPWSTR wszName, + /* */ + __inout_opt SIZE_T *pNameLength, + /* */ + __out_ecount_opt(*pUnitsLength) LPWSTR wszUnits, + /* */ + __inout_opt SIZE_T *pUnitsLength, + /* */ + __out_ecount_opt(*pDescriptionLength) LPWSTR wszDescription, + /* */ + __inout_opt SIZE_T *pDescriptionLength) = 0; + + virtual UINT STDMETHODCALLTYPE GetCreationFlags( void) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10DeviceVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10Device * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10Device * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10Device * This); + + void ( STDMETHODCALLTYPE *VSSetConstantBuffers )( + ID3D10Device * This, + /* [in] */ UINT StartConstantSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][in] */ ID3D10Buffer *const *ppConstantBuffers); + + void ( STDMETHODCALLTYPE *PSSetShaderResources )( + ID3D10Device * This, + /* [in] */ UINT Offset, + /* [in] */ UINT NumViews, + /* [size_is][in] */ ID3D10ShaderResourceView *const *ppShaderResourceViews); + + void ( STDMETHODCALLTYPE *PSSetShader )( + ID3D10Device * This, + /* [in] */ ID3D10PixelShader *pPixelShader); + + void ( STDMETHODCALLTYPE *PSSetSamplers )( + ID3D10Device * This, + /* [in] */ UINT Offset, + /* [in] */ UINT NumSamplers, + /* [size_is][in] */ ID3D10SamplerState *const *ppSamplers); + + void ( STDMETHODCALLTYPE *VSSetShader )( + ID3D10Device * This, + /* [in] */ ID3D10VertexShader *pVertexShader); + + void ( STDMETHODCALLTYPE *DrawIndexed )( + ID3D10Device * This, + /* [in] */ UINT IndexCount, + /* [in] */ UINT StartIndexLocation, + /* [in] */ INT BaseVertexLocation); + + void ( STDMETHODCALLTYPE *Draw )( + ID3D10Device * This, + /* [in] */ UINT VertexCount, + /* [in] */ UINT StartVertexLocation); + + void ( STDMETHODCALLTYPE *PSSetConstantBuffers )( + ID3D10Device * This, + /* [in] */ UINT StartConstantSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][in] */ ID3D10Buffer *const *ppConstantBuffers); + + void ( STDMETHODCALLTYPE *IASetInputLayout )( + ID3D10Device * This, + /* [in] */ ID3D10InputLayout *pInputLayout); + + void ( STDMETHODCALLTYPE *IASetVertexBuffers )( + ID3D10Device * This, + /* [in] */ UINT StartSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][in] */ ID3D10Buffer *const *ppVertexBuffers, + /* [size_is][in] */ const UINT *pStrides, + /* [size_is][in] */ const UINT *pOffsets); + + void ( STDMETHODCALLTYPE *IASetIndexBuffer )( + ID3D10Device * This, + /* [in] */ ID3D10Buffer *pIndexBuffer, + /* [in] */ DXGI_FORMAT Format, + /* [in] */ UINT Offset); + + void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( + ID3D10Device * This, + /* [in] */ UINT IndexCountPerInstance, + /* [in] */ UINT InstanceCount, + /* [in] */ UINT StartIndexLocation, + /* [in] */ INT BaseVertexLocation, + /* [in] */ UINT StartInstanceLocation); + + void ( STDMETHODCALLTYPE *DrawInstanced )( + ID3D10Device * This, + /* [in] */ UINT VertexCountPerInstance, + /* [in] */ UINT InstanceCount, + /* [in] */ UINT StartVertexLocation, + /* [in] */ UINT StartInstanceLocation); + + void ( STDMETHODCALLTYPE *GSSetConstantBuffers )( + ID3D10Device * This, + /* [in] */ UINT StartConstantSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][in] */ ID3D10Buffer *const *ppConstantBuffers); + + void ( STDMETHODCALLTYPE *GSSetShader )( + ID3D10Device * This, + /* [in] */ ID3D10GeometryShader *pShader); + + void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( + ID3D10Device * This, + /* [in] */ D3D10_PRIMITIVE_TOPOLOGY Topology); + + void ( STDMETHODCALLTYPE *VSSetShaderResources )( + ID3D10Device * This, + /* [in] */ UINT Offset, + /* [in] */ UINT NumViews, + /* [size_is][in] */ ID3D10ShaderResourceView *const *ppShaderResourceViews); + + void ( STDMETHODCALLTYPE *VSSetSamplers )( + ID3D10Device * This, + /* [in] */ UINT Offset, + /* [in] */ UINT NumSamplers, + /* [size_is][in] */ ID3D10SamplerState *const *ppSamplers); + + void ( STDMETHODCALLTYPE *SetPredication )( + ID3D10Device * This, + /* [in] */ ID3D10Predicate *pPredicate, + /* [in] */ BOOL PredicateValue); + + void ( STDMETHODCALLTYPE *GSSetShaderResources )( + ID3D10Device * This, + /* [in] */ UINT Offset, + /* [in] */ UINT NumViews, + /* [size_is][in] */ ID3D10ShaderResourceView *const *ppShaderResourceViews); + + void ( STDMETHODCALLTYPE *GSSetSamplers )( + ID3D10Device * This, + /* [in] */ UINT Offset, + /* [in] */ UINT NumSamplers, + /* [size_is][in] */ ID3D10SamplerState *const *ppSamplers); + + void ( STDMETHODCALLTYPE *OMSetRenderTargets )( + ID3D10Device * This, + /* [in] */ UINT NumViews, + /* [size_is][in] */ ID3D10RenderTargetView *const *ppRenderTargetViews, + /* [in] */ ID3D10DepthStencilView *pDepthStencilView); + + void ( STDMETHODCALLTYPE *OMSetBlendState )( + ID3D10Device * This, + /* [in] */ ID3D10BlendState *pBlendState, + /* [in] */ const FLOAT BlendFactor[ 4 ], + /* [in] */ UINT SampleMask); + + void ( STDMETHODCALLTYPE *OMSetDepthStencilState )( + ID3D10Device * This, + /* [in] */ ID3D10DepthStencilState *pDepthStencilState, + /* [in] */ UINT StencilRef); + + void ( STDMETHODCALLTYPE *SOSetTargets )( + ID3D10Device * This, + /* [in] */ UINT NumBuffers, + /* [size_is][in] */ ID3D10Buffer *const *ppSOTargets, + /* [size_is][in] */ const UINT *pOffsets); + + void ( STDMETHODCALLTYPE *DrawAuto )( + ID3D10Device * This); + + void ( STDMETHODCALLTYPE *RSSetState )( + ID3D10Device * This, + /* [in] */ ID3D10RasterizerState *pRasterizerState); + + void ( STDMETHODCALLTYPE *RSSetViewports )( + ID3D10Device * This, + /* [in] */ UINT NumViewports, + /* [size_is][in] */ const D3D10_VIEWPORT *pViewports); + + void ( STDMETHODCALLTYPE *RSSetScissorRects )( + ID3D10Device * This, + /* [in] */ UINT NumRects, + /* [size_is][in] */ const D3D10_RECT *pRects); + + void ( STDMETHODCALLTYPE *ClearRenderTargetView )( + ID3D10Device * This, + /* [in] */ ID3D10RenderTargetView *pRenderTargetView, + /* [in] */ const FLOAT ColorRGBA[ 4 ]); + + void ( STDMETHODCALLTYPE *ClearDepthStencilView )( + ID3D10Device * This, + /* [in] */ ID3D10DepthStencilView *pDepthStencilView, + /* [in] */ UINT Flags, + /* [in] */ FLOAT Depth, + /* [in] */ UINT8 Stencil); + + HRESULT ( STDMETHODCALLTYPE *GenerateMips )( + ID3D10Device * This, + /* [in] */ ID3D10ShaderResourceView *pShaderResourceView); + + void ( STDMETHODCALLTYPE *VSGetConstantBuffers )( + ID3D10Device * This, + /* [in] */ UINT StartConstantSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][out] */ ID3D10Buffer **ppConstantBuffers); + + void ( STDMETHODCALLTYPE *PSGetShaderResources )( + ID3D10Device * This, + /* [in] */ UINT Offset, + /* [in] */ UINT NumViews, + /* [size_is][out] */ ID3D10ShaderResourceView **ppShaderResourceViews); + + void ( STDMETHODCALLTYPE *PSGetShader )( + ID3D10Device * This, + /* [out][in] */ ID3D10PixelShader **ppPixelShader); + + void ( STDMETHODCALLTYPE *PSGetSamplers )( + ID3D10Device * This, + /* [in] */ UINT Offset, + /* [in] */ UINT NumSamplers, + /* [size_is][out] */ ID3D10SamplerState **ppSamplers); + + void ( STDMETHODCALLTYPE *VSGetShader )( + ID3D10Device * This, + /* [out][in] */ ID3D10VertexShader **ppVertexShader); + + void ( STDMETHODCALLTYPE *PSGetConstantBuffers )( + ID3D10Device * This, + /* [in] */ UINT StartConstantSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][out] */ ID3D10Buffer **ppConstantBuffers); + + void ( STDMETHODCALLTYPE *IAGetInputLayout )( + ID3D10Device * This, + /* [out][in] */ ID3D10InputLayout **ppInputLayout); + + void ( STDMETHODCALLTYPE *IAGetVertexBuffers )( + ID3D10Device * This, + /* [in] */ UINT StartSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][out] */ ID3D10Buffer **ppVertexBuffers, + /* [size_is][out] */ UINT *pStrides, + /* [size_is][out] */ UINT *pOffsets); + + void ( STDMETHODCALLTYPE *IAGetIndexBuffer )( + ID3D10Device * This, + /* [out] */ ID3D10Buffer **pIndexBuffer, + /* [out] */ DXGI_FORMAT *Format, + /* [out] */ UINT *Offset); + + void ( STDMETHODCALLTYPE *GSGetConstantBuffers )( + ID3D10Device * This, + /* [in] */ UINT StartConstantSlot, + /* [in] */ UINT NumBuffers, + /* [size_is][out] */ ID3D10Buffer **ppConstantBuffers); + + void ( STDMETHODCALLTYPE *GSGetShader )( + ID3D10Device * This, + /* [out] */ ID3D10GeometryShader **ppGeometryShader); + + void ( STDMETHODCALLTYPE *IAGetPrimitiveTopology )( + ID3D10Device * This, + /* [out] */ D3D10_PRIMITIVE_TOPOLOGY *pTopology); + + void ( STDMETHODCALLTYPE *VSGetShaderResources )( + ID3D10Device * This, + /* [in] */ UINT Offset, + /* [in] */ UINT NumViews, + /* [size_is][out] */ ID3D10ShaderResourceView **ppShaderResourceViews); + + void ( STDMETHODCALLTYPE *VSGetSamplers )( + ID3D10Device * This, + /* [in] */ UINT Offset, + /* [in] */ UINT NumSamplers, + /* [size_is][out] */ ID3D10SamplerState **ppSamplers); + + void ( STDMETHODCALLTYPE *GetPredication )( + ID3D10Device * This, + /* [out] */ ID3D10Predicate **ppPredicate, + /* [out] */ BOOL *pPredicateValue); + + void ( STDMETHODCALLTYPE *GSGetShaderResources )( + ID3D10Device * This, + /* [in] */ UINT Offset, + /* [in] */ UINT NumViews, + /* [size_is][out] */ ID3D10ShaderResourceView **ppShaderResourceViews); + + void ( STDMETHODCALLTYPE *GSGetSamplers )( + ID3D10Device * This, + /* [in] */ UINT Offset, + /* [in] */ UINT NumSamplers, + /* [size_is][out] */ ID3D10SamplerState **ppSamplers); + + void ( STDMETHODCALLTYPE *OMGetRenderTargets )( + ID3D10Device * This, + /* [in] */ UINT NumViews, + /* [size_is][out] */ ID3D10RenderTargetView **ppRenderTargetViews, + /* [out] */ ID3D10DepthStencilView **ppDepthStencilView); + + void ( STDMETHODCALLTYPE *OMGetBlendState )( + ID3D10Device * This, + /* [out] */ ID3D10BlendState **ppBlendState, + /* [out] */ FLOAT BlendFactor[ 4 ], + /* [out] */ UINT *pSampleMask); + + void ( STDMETHODCALLTYPE *OMGetDepthStencilState )( + ID3D10Device * This, + /* [out] */ ID3D10DepthStencilState **ppDepthStencilState, + /* [out] */ UINT *pStencilRef); + + void ( STDMETHODCALLTYPE *SOGetTargets )( + ID3D10Device * This, + /* [in] */ UINT NumBuffers, + /* [size_is][out] */ ID3D10Buffer **ppSOTargets, + /* [size_is][out] */ UINT *pOffsets); + + void ( STDMETHODCALLTYPE *RSGetState )( + ID3D10Device * This, + /* [out] */ ID3D10RasterizerState **ppRasterizerState); + + void ( STDMETHODCALLTYPE *RSGetViewports )( + ID3D10Device * This, + /* [out][in] */ UINT *NumViewports, + /* [size_is][out] */ D3D10_VIEWPORT *pViewports); + + void ( STDMETHODCALLTYPE *RSGetScissorRects )( + ID3D10Device * This, + /* [out][in] */ UINT *NumRects, + /* [size_is][out] */ D3D10_RECT *pRects); + + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D10Device * This); + + HRESULT ( STDMETHODCALLTYPE *SetExceptionMode )( + ID3D10Device * This, + UINT RaiseFlags); + + UINT ( STDMETHODCALLTYPE *GetExceptionMode )( + ID3D10Device * This); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D10Device * This, + /* [in] */ REFGUID guid, + /* [out][in] */ SIZE_T *pDataSize, + /* [size_is][out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D10Device * This, + /* [in] */ REFGUID guid, + /* [in] */ SIZE_T DataSize, + /* [size_is][in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D10Device * This, + /* [in] */ REFGUID guid, + /* [in] */ const IUnknown *pData); + + void ( STDMETHODCALLTYPE *Enter )( + ID3D10Device * This); + + void ( STDMETHODCALLTYPE *Leave )( + ID3D10Device * This); + + void ( STDMETHODCALLTYPE *Flush )( + ID3D10Device * This); + + HRESULT ( STDMETHODCALLTYPE *CreateBuffer )( + ID3D10Device * This, + /* [in] */ const D3D10_BUFFER_DESC *pDesc, + /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, + /* [out] */ ID3D10Buffer **ppBuffer); + + HRESULT ( STDMETHODCALLTYPE *CreateTexture1D )( + ID3D10Device * This, + /* [in] */ const D3D10_TEXTURE1D_DESC *pDesc, + /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, + /* [out] */ ID3D10Texture1D **ppTexture1D); + + HRESULT ( STDMETHODCALLTYPE *CreateTexture2D )( + ID3D10Device * This, + /* [in] */ const D3D10_TEXTURE2D_DESC *pDesc, + /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, + /* [out] */ ID3D10Texture2D **ppTexture2D); + + HRESULT ( STDMETHODCALLTYPE *CreateTexture3D )( + ID3D10Device * This, + /* [in] */ const D3D10_TEXTURE3D_DESC *pDesc, + /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, + /* [out] */ ID3D10Texture3D **ppTexture3D); + + HRESULT ( STDMETHODCALLTYPE *CreateTextureCube )( + ID3D10Device * This, + /* [in] */ const D3D10_TEXTURECUBE_DESC *pDesc, + /* [in] */ const D3D10_SUBRESOURCE_UP *pInitialData, + /* [out] */ ID3D10TextureCube **ppTextureCube); + + HRESULT ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D10Device * This, + /* [in] */ ID3D10Resource *pResource, + /* [in] */ const D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc, + /* [out] */ ID3D10ShaderResourceView **ppSRView); + + HRESULT ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D10Device * This, + /* [in] */ ID3D10Resource *pResource, + /* [in] */ const D3D10_RENDER_TARGET_VIEW_DESC *pDesc, + /* [out] */ ID3D10RenderTargetView **ppRTView); + + HRESULT ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D10Device * This, + /* [in] */ ID3D10Resource *pResource, + /* [in] */ const D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc, + /* [out] */ ID3D10DepthStencilView **ppDepthStencilView); + + HRESULT ( STDMETHODCALLTYPE *CreateInputLayout )( + ID3D10Device * This, + /* [size_is][in] */ const D3D10_INPUT_ELEMENT_DESC *pInputElementDescs, + /* [in] */ UINT NumElements, + /* [in] */ const void *pShaderBytecodeWithInputSignature, + /* [out] */ ID3D10InputLayout **ppInputLayout); + + HRESULT ( STDMETHODCALLTYPE *CreateVertexShader )( + ID3D10Device * This, + /* [in] */ const void *pShaderBytecode, + /* [out] */ ID3D10VertexShader **ppVertexShader); + + HRESULT ( STDMETHODCALLTYPE *CreateGeometryShader )( + ID3D10Device * This, + /* [in] */ const void *pShaderBytecode, + /* [out] */ ID3D10GeometryShader **ppGeometryShader); + + HRESULT ( STDMETHODCALLTYPE *CreateGeometryShaderWithStreamOutput )( + ID3D10Device * This, + /* [in] */ const void *pShaderBytecode, + /* [size_is][in] */ const D3D10_SO_DECLARATION_ENTRY *pSODeclaration, + /* [in] */ UINT NumEntries, + /* [in] */ UINT OutputStreamStride, + /* [out] */ ID3D10GeometryShader **ppGeometryShader); + + HRESULT ( STDMETHODCALLTYPE *CreatePixelShader )( + ID3D10Device * This, + /* [in] */ const void *pShaderBytecode, + /* [out] */ ID3D10PixelShader **ppPixelShader); + + HRESULT ( STDMETHODCALLTYPE *CreateBlendState )( + ID3D10Device * This, + /* [in] */ const D3D10_BLEND_DESC *pBlendStateDesc, + /* [out] */ ID3D10BlendState **ppBlendState); + + HRESULT ( STDMETHODCALLTYPE *CreateDepthStencilState )( + ID3D10Device * This, + /* [in] */ const D3D10_DEPTH_STENCIL_DESC *pDepthStencilDesc, + /* [out] */ ID3D10DepthStencilState **ppDepthStencilState); + + HRESULT ( STDMETHODCALLTYPE *CreateRasterizerState )( + ID3D10Device * This, + /* [in] */ const D3D10_RASTERIZER_DESC *pRasterizerDesc, + /* [out] */ ID3D10RasterizerState **ppRasterizerState); + + HRESULT ( STDMETHODCALLTYPE *CreateSamplerState )( + ID3D10Device * This, + /* [in] */ const D3D10_SAMPLER_DESC *pSamplerDesc, + /* [out] */ ID3D10SamplerState **ppSamplerState); + + HRESULT ( STDMETHODCALLTYPE *CreateQuery )( + ID3D10Device * This, + /* [in] */ const D3D10_QUERY_DESC *pQueryDesc, + /* [out] */ ID3D10Query **ppQuery); + + HRESULT ( STDMETHODCALLTYPE *CreatePredicate )( + ID3D10Device * This, + /* [in] */ const D3D10_QUERY_DESC *pPredicateDesc, + /* [out] */ ID3D10Predicate **ppPredicate); + + HRESULT ( STDMETHODCALLTYPE *CreateCounter )( + ID3D10Device * This, + /* [in] */ const D3D10_COUNTER_DESC *pCounterDesc, + /* [out] */ ID3D10Counter **ppCounter); + + HRESULT ( STDMETHODCALLTYPE *CheckFormatSupport )( + ID3D10Device * This, + /* [in] */ DXGI_FORMAT Format, + /* [retval][out] */ UINT *pFormatSupport); + + HRESULT ( STDMETHODCALLTYPE *CheckMultisampleQualityLevels )( + ID3D10Device * This, + /* [in] */ UINT SampleCount, + /* [retval][out] */ UINT *pNumQualityLevels); + + void ( STDMETHODCALLTYPE *CheckVertexCache )( + ID3D10Device * This, + /* [out] */ D3D10_VERTEX_CACHE_DESC *pVertexCacheDesc); + + void ( STDMETHODCALLTYPE *CheckCounterInfo )( + ID3D10Device * This, + /* [retval][out] */ D3D10_COUNTER_INFO *pCounterInfo); + + HRESULT ( STDMETHODCALLTYPE *CheckCounter )( + ID3D10Device * This, + /* */ + __in const D3D10_COUNTER_DESC *pDesc, + /* */ + __out D3D10_COUNTER_TYPE *pType, + /* */ + __out UINT *pActiveCounters, + /* */ + __out_ecount_opt(*pNameLength) LPWSTR wszName, + /* */ + __inout_opt SIZE_T *pNameLength, + /* */ + __out_ecount_opt(*pUnitsLength) LPWSTR wszUnits, + /* */ + __inout_opt SIZE_T *pUnitsLength, + /* */ + __out_ecount_opt(*pDescriptionLength) LPWSTR wszDescription, + /* */ + __inout_opt SIZE_T *pDescriptionLength); + + UINT ( STDMETHODCALLTYPE *GetCreationFlags )( + ID3D10Device * This); + + END_INTERFACE + } ID3D10DeviceVtbl; + + interface ID3D10Device + { + CONST_VTBL struct ID3D10DeviceVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10Device_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10Device_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10Device_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10Device_VSSetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) \ + ( (This)->lpVtbl -> VSSetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) ) + +#define ID3D10Device_PSSetShaderResources(This,Offset,NumViews,ppShaderResourceViews) \ + ( (This)->lpVtbl -> PSSetShaderResources(This,Offset,NumViews,ppShaderResourceViews) ) + +#define ID3D10Device_PSSetShader(This,pPixelShader) \ + ( (This)->lpVtbl -> PSSetShader(This,pPixelShader) ) + +#define ID3D10Device_PSSetSamplers(This,Offset,NumSamplers,ppSamplers) \ + ( (This)->lpVtbl -> PSSetSamplers(This,Offset,NumSamplers,ppSamplers) ) + +#define ID3D10Device_VSSetShader(This,pVertexShader) \ + ( (This)->lpVtbl -> VSSetShader(This,pVertexShader) ) + +#define ID3D10Device_DrawIndexed(This,IndexCount,StartIndexLocation,BaseVertexLocation) \ + ( (This)->lpVtbl -> DrawIndexed(This,IndexCount,StartIndexLocation,BaseVertexLocation) ) + +#define ID3D10Device_Draw(This,VertexCount,StartVertexLocation) \ + ( (This)->lpVtbl -> Draw(This,VertexCount,StartVertexLocation) ) + +#define ID3D10Device_PSSetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) \ + ( (This)->lpVtbl -> PSSetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) ) + +#define ID3D10Device_IASetInputLayout(This,pInputLayout) \ + ( (This)->lpVtbl -> IASetInputLayout(This,pInputLayout) ) + +#define ID3D10Device_IASetVertexBuffers(This,StartSlot,NumBuffers,ppVertexBuffers,pStrides,pOffsets) \ + ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumBuffers,ppVertexBuffers,pStrides,pOffsets) ) + +#define ID3D10Device_IASetIndexBuffer(This,pIndexBuffer,Format,Offset) \ + ( (This)->lpVtbl -> IASetIndexBuffer(This,pIndexBuffer,Format,Offset) ) + +#define ID3D10Device_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) + +#define ID3D10Device_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) + +#define ID3D10Device_GSSetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) \ + ( (This)->lpVtbl -> GSSetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) ) + +#define ID3D10Device_GSSetShader(This,pShader) \ + ( (This)->lpVtbl -> GSSetShader(This,pShader) ) + +#define ID3D10Device_IASetPrimitiveTopology(This,Topology) \ + ( (This)->lpVtbl -> IASetPrimitiveTopology(This,Topology) ) + +#define ID3D10Device_VSSetShaderResources(This,Offset,NumViews,ppShaderResourceViews) \ + ( (This)->lpVtbl -> VSSetShaderResources(This,Offset,NumViews,ppShaderResourceViews) ) + +#define ID3D10Device_VSSetSamplers(This,Offset,NumSamplers,ppSamplers) \ + ( (This)->lpVtbl -> VSSetSamplers(This,Offset,NumSamplers,ppSamplers) ) + +#define ID3D10Device_SetPredication(This,pPredicate,PredicateValue) \ + ( (This)->lpVtbl -> SetPredication(This,pPredicate,PredicateValue) ) + +#define ID3D10Device_GSSetShaderResources(This,Offset,NumViews,ppShaderResourceViews) \ + ( (This)->lpVtbl -> GSSetShaderResources(This,Offset,NumViews,ppShaderResourceViews) ) + +#define ID3D10Device_GSSetSamplers(This,Offset,NumSamplers,ppSamplers) \ + ( (This)->lpVtbl -> GSSetSamplers(This,Offset,NumSamplers,ppSamplers) ) + +#define ID3D10Device_OMSetRenderTargets(This,NumViews,ppRenderTargetViews,pDepthStencilView) \ + ( (This)->lpVtbl -> OMSetRenderTargets(This,NumViews,ppRenderTargetViews,pDepthStencilView) ) + +#define ID3D10Device_OMSetBlendState(This,pBlendState,BlendFactor,SampleMask) \ + ( (This)->lpVtbl -> OMSetBlendState(This,pBlendState,BlendFactor,SampleMask) ) + +#define ID3D10Device_OMSetDepthStencilState(This,pDepthStencilState,StencilRef) \ + ( (This)->lpVtbl -> OMSetDepthStencilState(This,pDepthStencilState,StencilRef) ) + +#define ID3D10Device_SOSetTargets(This,NumBuffers,ppSOTargets,pOffsets) \ + ( (This)->lpVtbl -> SOSetTargets(This,NumBuffers,ppSOTargets,pOffsets) ) + +#define ID3D10Device_DrawAuto(This) \ + ( (This)->lpVtbl -> DrawAuto(This) ) + +#define ID3D10Device_RSSetState(This,pRasterizerState) \ + ( (This)->lpVtbl -> RSSetState(This,pRasterizerState) ) + +#define ID3D10Device_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) + +#define ID3D10Device_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) + +#define ID3D10Device_ClearRenderTargetView(This,pRenderTargetView,ColorRGBA) \ + ( (This)->lpVtbl -> ClearRenderTargetView(This,pRenderTargetView,ColorRGBA) ) + +#define ID3D10Device_ClearDepthStencilView(This,pDepthStencilView,Flags,Depth,Stencil) \ + ( (This)->lpVtbl -> ClearDepthStencilView(This,pDepthStencilView,Flags,Depth,Stencil) ) + +#define ID3D10Device_GenerateMips(This,pShaderResourceView) \ + ( (This)->lpVtbl -> GenerateMips(This,pShaderResourceView) ) + +#define ID3D10Device_VSGetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) \ + ( (This)->lpVtbl -> VSGetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) ) + +#define ID3D10Device_PSGetShaderResources(This,Offset,NumViews,ppShaderResourceViews) \ + ( (This)->lpVtbl -> PSGetShaderResources(This,Offset,NumViews,ppShaderResourceViews) ) + +#define ID3D10Device_PSGetShader(This,ppPixelShader) \ + ( (This)->lpVtbl -> PSGetShader(This,ppPixelShader) ) + +#define ID3D10Device_PSGetSamplers(This,Offset,NumSamplers,ppSamplers) \ + ( (This)->lpVtbl -> PSGetSamplers(This,Offset,NumSamplers,ppSamplers) ) + +#define ID3D10Device_VSGetShader(This,ppVertexShader) \ + ( (This)->lpVtbl -> VSGetShader(This,ppVertexShader) ) + +#define ID3D10Device_PSGetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) \ + ( (This)->lpVtbl -> PSGetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) ) + +#define ID3D10Device_IAGetInputLayout(This,ppInputLayout) \ + ( (This)->lpVtbl -> IAGetInputLayout(This,ppInputLayout) ) + +#define ID3D10Device_IAGetVertexBuffers(This,StartSlot,NumBuffers,ppVertexBuffers,pStrides,pOffsets) \ + ( (This)->lpVtbl -> IAGetVertexBuffers(This,StartSlot,NumBuffers,ppVertexBuffers,pStrides,pOffsets) ) + +#define ID3D10Device_IAGetIndexBuffer(This,pIndexBuffer,Format,Offset) \ + ( (This)->lpVtbl -> IAGetIndexBuffer(This,pIndexBuffer,Format,Offset) ) + +#define ID3D10Device_GSGetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) \ + ( (This)->lpVtbl -> GSGetConstantBuffers(This,StartConstantSlot,NumBuffers,ppConstantBuffers) ) + +#define ID3D10Device_GSGetShader(This,ppGeometryShader) \ + ( (This)->lpVtbl -> GSGetShader(This,ppGeometryShader) ) + +#define ID3D10Device_IAGetPrimitiveTopology(This,pTopology) \ + ( (This)->lpVtbl -> IAGetPrimitiveTopology(This,pTopology) ) + +#define ID3D10Device_VSGetShaderResources(This,Offset,NumViews,ppShaderResourceViews) \ + ( (This)->lpVtbl -> VSGetShaderResources(This,Offset,NumViews,ppShaderResourceViews) ) + +#define ID3D10Device_VSGetSamplers(This,Offset,NumSamplers,ppSamplers) \ + ( (This)->lpVtbl -> VSGetSamplers(This,Offset,NumSamplers,ppSamplers) ) + +#define ID3D10Device_GetPredication(This,ppPredicate,pPredicateValue) \ + ( (This)->lpVtbl -> GetPredication(This,ppPredicate,pPredicateValue) ) + +#define ID3D10Device_GSGetShaderResources(This,Offset,NumViews,ppShaderResourceViews) \ + ( (This)->lpVtbl -> GSGetShaderResources(This,Offset,NumViews,ppShaderResourceViews) ) + +#define ID3D10Device_GSGetSamplers(This,Offset,NumSamplers,ppSamplers) \ + ( (This)->lpVtbl -> GSGetSamplers(This,Offset,NumSamplers,ppSamplers) ) + +#define ID3D10Device_OMGetRenderTargets(This,NumViews,ppRenderTargetViews,ppDepthStencilView) \ + ( (This)->lpVtbl -> OMGetRenderTargets(This,NumViews,ppRenderTargetViews,ppDepthStencilView) ) + +#define ID3D10Device_OMGetBlendState(This,ppBlendState,BlendFactor,pSampleMask) \ + ( (This)->lpVtbl -> OMGetBlendState(This,ppBlendState,BlendFactor,pSampleMask) ) + +#define ID3D10Device_OMGetDepthStencilState(This,ppDepthStencilState,pStencilRef) \ + ( (This)->lpVtbl -> OMGetDepthStencilState(This,ppDepthStencilState,pStencilRef) ) + +#define ID3D10Device_SOGetTargets(This,NumBuffers,ppSOTargets,pOffsets) \ + ( (This)->lpVtbl -> SOGetTargets(This,NumBuffers,ppSOTargets,pOffsets) ) + +#define ID3D10Device_RSGetState(This,ppRasterizerState) \ + ( (This)->lpVtbl -> RSGetState(This,ppRasterizerState) ) + +#define ID3D10Device_RSGetViewports(This,NumViewports,pViewports) \ + ( (This)->lpVtbl -> RSGetViewports(This,NumViewports,pViewports) ) + +#define ID3D10Device_RSGetScissorRects(This,NumRects,pRects) \ + ( (This)->lpVtbl -> RSGetScissorRects(This,NumRects,pRects) ) + +#define ID3D10Device_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D10Device_SetExceptionMode(This,RaiseFlags) \ + ( (This)->lpVtbl -> SetExceptionMode(This,RaiseFlags) ) + +#define ID3D10Device_GetExceptionMode(This) \ + ( (This)->lpVtbl -> GetExceptionMode(This) ) + +#define ID3D10Device_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D10Device_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D10Device_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D10Device_Enter(This) \ + ( (This)->lpVtbl -> Enter(This) ) + +#define ID3D10Device_Leave(This) \ + ( (This)->lpVtbl -> Leave(This) ) + +#define ID3D10Device_Flush(This) \ + ( (This)->lpVtbl -> Flush(This) ) + +#define ID3D10Device_CreateBuffer(This,pDesc,pInitialData,ppBuffer) \ + ( (This)->lpVtbl -> CreateBuffer(This,pDesc,pInitialData,ppBuffer) ) + +#define ID3D10Device_CreateTexture1D(This,pDesc,pInitialData,ppTexture1D) \ + ( (This)->lpVtbl -> CreateTexture1D(This,pDesc,pInitialData,ppTexture1D) ) + +#define ID3D10Device_CreateTexture2D(This,pDesc,pInitialData,ppTexture2D) \ + ( (This)->lpVtbl -> CreateTexture2D(This,pDesc,pInitialData,ppTexture2D) ) + +#define ID3D10Device_CreateTexture3D(This,pDesc,pInitialData,ppTexture3D) \ + ( (This)->lpVtbl -> CreateTexture3D(This,pDesc,pInitialData,ppTexture3D) ) + +#define ID3D10Device_CreateTextureCube(This,pDesc,pInitialData,ppTextureCube) \ + ( (This)->lpVtbl -> CreateTextureCube(This,pDesc,pInitialData,ppTextureCube) ) + +#define ID3D10Device_CreateShaderResourceView(This,pResource,pDesc,ppSRView) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,ppSRView) ) + +#define ID3D10Device_CreateRenderTargetView(This,pResource,pDesc,ppRTView) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,ppRTView) ) + +#define ID3D10Device_CreateDepthStencilView(This,pResource,pDesc,ppDepthStencilView) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,ppDepthStencilView) ) + +#define ID3D10Device_CreateInputLayout(This,pInputElementDescs,NumElements,pShaderBytecodeWithInputSignature,ppInputLayout) \ + ( (This)->lpVtbl -> CreateInputLayout(This,pInputElementDescs,NumElements,pShaderBytecodeWithInputSignature,ppInputLayout) ) + +#define ID3D10Device_CreateVertexShader(This,pShaderBytecode,ppVertexShader) \ + ( (This)->lpVtbl -> CreateVertexShader(This,pShaderBytecode,ppVertexShader) ) + +#define ID3D10Device_CreateGeometryShader(This,pShaderBytecode,ppGeometryShader) \ + ( (This)->lpVtbl -> CreateGeometryShader(This,pShaderBytecode,ppGeometryShader) ) + +#define ID3D10Device_CreateGeometryShaderWithStreamOutput(This,pShaderBytecode,pSODeclaration,NumEntries,OutputStreamStride,ppGeometryShader) \ + ( (This)->lpVtbl -> CreateGeometryShaderWithStreamOutput(This,pShaderBytecode,pSODeclaration,NumEntries,OutputStreamStride,ppGeometryShader) ) + +#define ID3D10Device_CreatePixelShader(This,pShaderBytecode,ppPixelShader) \ + ( (This)->lpVtbl -> CreatePixelShader(This,pShaderBytecode,ppPixelShader) ) + +#define ID3D10Device_CreateBlendState(This,pBlendStateDesc,ppBlendState) \ + ( (This)->lpVtbl -> CreateBlendState(This,pBlendStateDesc,ppBlendState) ) + +#define ID3D10Device_CreateDepthStencilState(This,pDepthStencilDesc,ppDepthStencilState) \ + ( (This)->lpVtbl -> CreateDepthStencilState(This,pDepthStencilDesc,ppDepthStencilState) ) + +#define ID3D10Device_CreateRasterizerState(This,pRasterizerDesc,ppRasterizerState) \ + ( (This)->lpVtbl -> CreateRasterizerState(This,pRasterizerDesc,ppRasterizerState) ) + +#define ID3D10Device_CreateSamplerState(This,pSamplerDesc,ppSamplerState) \ + ( (This)->lpVtbl -> CreateSamplerState(This,pSamplerDesc,ppSamplerState) ) + +#define ID3D10Device_CreateQuery(This,pQueryDesc,ppQuery) \ + ( (This)->lpVtbl -> CreateQuery(This,pQueryDesc,ppQuery) ) + +#define ID3D10Device_CreatePredicate(This,pPredicateDesc,ppPredicate) \ + ( (This)->lpVtbl -> CreatePredicate(This,pPredicateDesc,ppPredicate) ) + +#define ID3D10Device_CreateCounter(This,pCounterDesc,ppCounter) \ + ( (This)->lpVtbl -> CreateCounter(This,pCounterDesc,ppCounter) ) + +#define ID3D10Device_CheckFormatSupport(This,Format,pFormatSupport) \ + ( (This)->lpVtbl -> CheckFormatSupport(This,Format,pFormatSupport) ) + +#define ID3D10Device_CheckMultisampleQualityLevels(This,SampleCount,pNumQualityLevels) \ + ( (This)->lpVtbl -> CheckMultisampleQualityLevels(This,SampleCount,pNumQualityLevels) ) + +#define ID3D10Device_CheckVertexCache(This,pVertexCacheDesc) \ + ( (This)->lpVtbl -> CheckVertexCache(This,pVertexCacheDesc) ) + +#define ID3D10Device_CheckCounterInfo(This,pCounterInfo) \ + ( (This)->lpVtbl -> CheckCounterInfo(This,pCounterInfo) ) + +#define ID3D10Device_CheckCounter(This,pDesc,pType,pActiveCounters,wszName,pNameLength,wszUnits,pUnitsLength,wszDescription,pDescriptionLength) \ + ( (This)->lpVtbl -> CheckCounter(This,pDesc,pType,pActiveCounters,wszName,pNameLength,wszUnits,pUnitsLength,wszDescription,pDescriptionLength) ) + +#define ID3D10Device_GetCreationFlags(This) \ + ( (This)->lpVtbl -> GetCreationFlags(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10Device_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D10StateMirror_INTERFACE_DEFINED__ +#define __ID3D10StateMirror_INTERFACE_DEFINED__ + +/* interface ID3D10StateMirror */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10StateMirror; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4D0F-342C-4106-A19F-4F2704F689F0") + ID3D10StateMirror : public IUnknown + { + public: + virtual void STDMETHODCALLTYPE GetBufferDesc( + /* [in] */ ID3D10Buffer *pBuffer, + /* [retval][out] */ D3D10_BUFFER_DESC *pDesc) = 0; + + virtual void STDMETHODCALLTYPE GetTexture1DDesc( + /* [in] */ ID3D10Texture1D *pTexture1D, + /* [retval][out] */ D3D10_TEXTURE1D_DESC *pDesc) = 0; + + virtual void STDMETHODCALLTYPE GetTexture2DDesc( + /* [in] */ ID3D10Texture2D *pTexture2D, + /* [retval][out] */ D3D10_TEXTURE2D_DESC *pDesc) = 0; + + virtual void STDMETHODCALLTYPE GetTexture3DDesc( + /* [in] */ ID3D10Texture3D *pTexture3D, + /* [retval][out] */ D3D10_TEXTURE3D_DESC *pDesc) = 0; + + virtual void STDMETHODCALLTYPE GetTextureCubeDesc( + /* [in] */ ID3D10TextureCube *pTextureCube, + /* [retval][out] */ D3D10_TEXTURECUBE_DESC *pDesc) = 0; + + virtual void STDMETHODCALLTYPE GetShaderResourceViewDesc( + /* [in] */ ID3D10ShaderResourceView *pShaderResourceView, + /* [retval][out] */ D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc) = 0; + + virtual void STDMETHODCALLTYPE GetRenderTargetViewDesc( + /* [in] */ ID3D10RenderTargetView *pRenderTargetView, + /* [retval][out] */ D3D10_RENDER_TARGET_VIEW_DESC *pDesc) = 0; + + virtual void STDMETHODCALLTYPE GetDepthStencilViewDesc( + /* [in] */ ID3D10DepthStencilView *pDepthStencilView, + /* [retval][out] */ D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetVertexShaderDesc( + /* [in] */ ID3D10VertexShader *pShader, + /* [out][in] */ D3D10_VERTEX_SHADER_DESC *pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetGeometryShaderDesc( + /* [in] */ ID3D10GeometryShader *pShader, + /* [out][in] */ D3D10_GEOMETRY_SHADER_DESC *pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetPixelShaderDesc( + /* [in] */ ID3D10PixelShader *pShader, + /* [out][in] */ D3D10_PIXEL_SHADER_DESC *pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetInputLayoutDesc( + /* [in] */ ID3D10InputLayout *pInputLayout, + /* [out][in] */ D3D10_INPUT_LAYOUT_DESC *pDesc) = 0; + + virtual SIZE_T STDMETHODCALLTYPE GetInputLayoutDeclarationElements( + /* [in] */ ID3D10InputLayout *pInputLayout) = 0; + + virtual void STDMETHODCALLTYPE GetSamplerDesc( + /* [in] */ ID3D10SamplerState *pSampler, + /* [retval][out] */ D3D10_SAMPLER_DESC *pDesc) = 0; + + virtual void STDMETHODCALLTYPE GetBlendStateDesc( + /* [in] */ ID3D10BlendState *pBlendState, + /* [retval][out] */ D3D10_BLEND_DESC *pDesc) = 0; + + virtual void STDMETHODCALLTYPE GetDepthStencilStateDesc( + /* [in] */ ID3D10DepthStencilState *pDepthStencilState, + /* [retval][out] */ D3D10_DEPTH_STENCIL_DESC *pDesc) = 0; + + virtual void STDMETHODCALLTYPE GetRasterizerStateDesc( + /* [in] */ ID3D10RasterizerState *pRasterizerState, + /* [retval][out] */ D3D10_RASTERIZER_DESC *pDesc) = 0; + + virtual void STDMETHODCALLTYPE GetQueryDesc( + /* [in] */ ID3D10Query *pQuery, + /* [retval][out] */ D3D10_QUERY_DESC *pDesc) = 0; + + virtual void STDMETHODCALLTYPE GetCounterDesc( + /* [in] */ ID3D10Counter *pCounter, + /* [retval][out] */ D3D10_COUNTER_DESC *pDesc) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10StateMirrorVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10StateMirror * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10StateMirror * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10StateMirror * This); + + void ( STDMETHODCALLTYPE *GetBufferDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10Buffer *pBuffer, + /* [retval][out] */ D3D10_BUFFER_DESC *pDesc); + + void ( STDMETHODCALLTYPE *GetTexture1DDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10Texture1D *pTexture1D, + /* [retval][out] */ D3D10_TEXTURE1D_DESC *pDesc); + + void ( STDMETHODCALLTYPE *GetTexture2DDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10Texture2D *pTexture2D, + /* [retval][out] */ D3D10_TEXTURE2D_DESC *pDesc); + + void ( STDMETHODCALLTYPE *GetTexture3DDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10Texture3D *pTexture3D, + /* [retval][out] */ D3D10_TEXTURE3D_DESC *pDesc); + + void ( STDMETHODCALLTYPE *GetTextureCubeDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10TextureCube *pTextureCube, + /* [retval][out] */ D3D10_TEXTURECUBE_DESC *pDesc); + + void ( STDMETHODCALLTYPE *GetShaderResourceViewDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10ShaderResourceView *pShaderResourceView, + /* [retval][out] */ D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc); + + void ( STDMETHODCALLTYPE *GetRenderTargetViewDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10RenderTargetView *pRenderTargetView, + /* [retval][out] */ D3D10_RENDER_TARGET_VIEW_DESC *pDesc); + + void ( STDMETHODCALLTYPE *GetDepthStencilViewDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10DepthStencilView *pDepthStencilView, + /* [retval][out] */ D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc); + + HRESULT ( STDMETHODCALLTYPE *GetVertexShaderDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10VertexShader *pShader, + /* [out][in] */ D3D10_VERTEX_SHADER_DESC *pDesc); + + HRESULT ( STDMETHODCALLTYPE *GetGeometryShaderDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10GeometryShader *pShader, + /* [out][in] */ D3D10_GEOMETRY_SHADER_DESC *pDesc); + + HRESULT ( STDMETHODCALLTYPE *GetPixelShaderDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10PixelShader *pShader, + /* [out][in] */ D3D10_PIXEL_SHADER_DESC *pDesc); + + HRESULT ( STDMETHODCALLTYPE *GetInputLayoutDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10InputLayout *pInputLayout, + /* [out][in] */ D3D10_INPUT_LAYOUT_DESC *pDesc); + + SIZE_T ( STDMETHODCALLTYPE *GetInputLayoutDeclarationElements )( + ID3D10StateMirror * This, + /* [in] */ ID3D10InputLayout *pInputLayout); + + void ( STDMETHODCALLTYPE *GetSamplerDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10SamplerState *pSampler, + /* [retval][out] */ D3D10_SAMPLER_DESC *pDesc); + + void ( STDMETHODCALLTYPE *GetBlendStateDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10BlendState *pBlendState, + /* [retval][out] */ D3D10_BLEND_DESC *pDesc); + + void ( STDMETHODCALLTYPE *GetDepthStencilStateDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10DepthStencilState *pDepthStencilState, + /* [retval][out] */ D3D10_DEPTH_STENCIL_DESC *pDesc); + + void ( STDMETHODCALLTYPE *GetRasterizerStateDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10RasterizerState *pRasterizerState, + /* [retval][out] */ D3D10_RASTERIZER_DESC *pDesc); + + void ( STDMETHODCALLTYPE *GetQueryDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10Query *pQuery, + /* [retval][out] */ D3D10_QUERY_DESC *pDesc); + + void ( STDMETHODCALLTYPE *GetCounterDesc )( + ID3D10StateMirror * This, + /* [in] */ ID3D10Counter *pCounter, + /* [retval][out] */ D3D10_COUNTER_DESC *pDesc); + + END_INTERFACE + } ID3D10StateMirrorVtbl; + + interface ID3D10StateMirror + { + CONST_VTBL struct ID3D10StateMirrorVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10StateMirror_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10StateMirror_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10StateMirror_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10StateMirror_GetBufferDesc(This,pBuffer,pDesc) \ + ( (This)->lpVtbl -> GetBufferDesc(This,pBuffer,pDesc) ) + +#define ID3D10StateMirror_GetTexture1DDesc(This,pTexture1D,pDesc) \ + ( (This)->lpVtbl -> GetTexture1DDesc(This,pTexture1D,pDesc) ) + +#define ID3D10StateMirror_GetTexture2DDesc(This,pTexture2D,pDesc) \ + ( (This)->lpVtbl -> GetTexture2DDesc(This,pTexture2D,pDesc) ) + +#define ID3D10StateMirror_GetTexture3DDesc(This,pTexture3D,pDesc) \ + ( (This)->lpVtbl -> GetTexture3DDesc(This,pTexture3D,pDesc) ) + +#define ID3D10StateMirror_GetTextureCubeDesc(This,pTextureCube,pDesc) \ + ( (This)->lpVtbl -> GetTextureCubeDesc(This,pTextureCube,pDesc) ) + +#define ID3D10StateMirror_GetShaderResourceViewDesc(This,pShaderResourceView,pDesc) \ + ( (This)->lpVtbl -> GetShaderResourceViewDesc(This,pShaderResourceView,pDesc) ) + +#define ID3D10StateMirror_GetRenderTargetViewDesc(This,pRenderTargetView,pDesc) \ + ( (This)->lpVtbl -> GetRenderTargetViewDesc(This,pRenderTargetView,pDesc) ) + +#define ID3D10StateMirror_GetDepthStencilViewDesc(This,pDepthStencilView,pDesc) \ + ( (This)->lpVtbl -> GetDepthStencilViewDesc(This,pDepthStencilView,pDesc) ) + +#define ID3D10StateMirror_GetVertexShaderDesc(This,pShader,pDesc) \ + ( (This)->lpVtbl -> GetVertexShaderDesc(This,pShader,pDesc) ) + +#define ID3D10StateMirror_GetGeometryShaderDesc(This,pShader,pDesc) \ + ( (This)->lpVtbl -> GetGeometryShaderDesc(This,pShader,pDesc) ) + +#define ID3D10StateMirror_GetPixelShaderDesc(This,pShader,pDesc) \ + ( (This)->lpVtbl -> GetPixelShaderDesc(This,pShader,pDesc) ) + +#define ID3D10StateMirror_GetInputLayoutDesc(This,pInputLayout,pDesc) \ + ( (This)->lpVtbl -> GetInputLayoutDesc(This,pInputLayout,pDesc) ) + +#define ID3D10StateMirror_GetInputLayoutDeclarationElements(This,pInputLayout) \ + ( (This)->lpVtbl -> GetInputLayoutDeclarationElements(This,pInputLayout) ) + +#define ID3D10StateMirror_GetSamplerDesc(This,pSampler,pDesc) \ + ( (This)->lpVtbl -> GetSamplerDesc(This,pSampler,pDesc) ) + +#define ID3D10StateMirror_GetBlendStateDesc(This,pBlendState,pDesc) \ + ( (This)->lpVtbl -> GetBlendStateDesc(This,pBlendState,pDesc) ) + +#define ID3D10StateMirror_GetDepthStencilStateDesc(This,pDepthStencilState,pDesc) \ + ( (This)->lpVtbl -> GetDepthStencilStateDesc(This,pDepthStencilState,pDesc) ) + +#define ID3D10StateMirror_GetRasterizerStateDesc(This,pRasterizerState,pDesc) \ + ( (This)->lpVtbl -> GetRasterizerStateDesc(This,pRasterizerState,pDesc) ) + +#define ID3D10StateMirror_GetQueryDesc(This,pQuery,pDesc) \ + ( (This)->lpVtbl -> GetQueryDesc(This,pQuery,pDesc) ) + +#define ID3D10StateMirror_GetCounterDesc(This,pCounter,pDesc) \ + ( (This)->lpVtbl -> GetCounterDesc(This,pCounter,pDesc) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10StateMirror_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D10Multithread_INTERFACE_DEFINED__ +#define __ID3D10Multithread_INTERFACE_DEFINED__ + +/* interface ID3D10Multithread */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10Multithread; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4E00-342C-4106-A19F-4F2704F689F0") + ID3D10Multithread : public IUnknown + { + public: + virtual BOOL STDMETHODCALLTYPE SetMultithreadProtected( + /* [in] */ BOOL bMTProtect) = 0; + + virtual BOOL STDMETHODCALLTYPE GetMultithreadProtected( void) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10MultithreadVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10Multithread * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10Multithread * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10Multithread * This); + + BOOL ( STDMETHODCALLTYPE *SetMultithreadProtected )( + ID3D10Multithread * This, + /* [in] */ BOOL bMTProtect); + + BOOL ( STDMETHODCALLTYPE *GetMultithreadProtected )( + ID3D10Multithread * This); + + END_INTERFACE + } ID3D10MultithreadVtbl; + + interface ID3D10Multithread + { + CONST_VTBL struct ID3D10MultithreadVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10Multithread_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10Multithread_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10Multithread_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10Multithread_SetMultithreadProtected(This,bMTProtect) \ + ( (This)->lpVtbl -> SetMultithreadProtected(This,bMTProtect) ) + +#define ID3D10Multithread_GetMultithreadProtected(This) \ + ( (This)->lpVtbl -> GetMultithreadProtected(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10Multithread_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10_0000_0026 */ +/* [local] */ + +typedef +enum D3D10_CREATE_DEVICE_FLAG + { D3D10_CREATE_DEVICE_SINGLETHREADED = 0x1, + D3D10_CREATE_DEVICE_MIRROR_STATE = 0x2, + D3D10_CREATE_DEVICE_DEBUG = 0x4 + } D3D10_CREATE_DEVICE_FLAG; + + +#define D3D10_SDK_VERSION ( 20 ) + +#if !defined( D3D10_IGNORE_SDK_LAYERS ) +#include "d3d10sdklayers.h" +#endif +#include "d3d10misc.h" +#include "d3d10shader.h" +#include "d3d10effect.h" + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0026_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10_0000_0026_v0_0_s_ifspec; + +/* Additional Prototypes for ALL interfaces */ + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/dep/include/DXSDK/include/D3D10effect.h b/src/dep/include/DXSDK/include/D3D10effect.h index d7cb088..c716c6e 100644 --- a/src/dep/include/DXSDK/include/D3D10effect.h +++ b/src/dep/include/DXSDK/include/D3D10effect.h @@ -1,1318 +1,1318 @@ - -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// File: D3D10Effect.h -// Content: D3D10 Stateblock/Effect Types & APIs -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef __D3D10EFFECT_H__ -#define __D3D10EFFECT_H__ - -#include "d3d10.h" - -////////////////////////////////////////////////////////////////////////////// -// File contents: -// -// 1) Stateblock enums, structs, interfaces, flat APIs -// 2) Effect enums, structs, interfaces, flat APIs -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3D10_DEVICE_STATE_TYPES: -// -// Used in ID3D10StateBlockMask function calls -// -//---------------------------------------------------------------------------- - -typedef enum _D3D10_DEVICE_STATE_TYPES -{ - D3D10_DST_VS = 1, // Single-value state - D3D10_DST_VS_SAMPLERS, // Count: D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT - D3D10_DST_VS_SHADER_RESOURCES, // Count: D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - D3D10_DST_VS_CONSTANT_BUFFERS, // Count: D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT - - D3D10_DST_GS, // Single-value state - D3D10_DST_GS_SAMPLERS, // Count: D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT - D3D10_DST_GS_SHADER_RESOURCES, // Count: D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - D3D10_DST_GS_CONSTANT_BUFFERS, // Count: D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT - - D3D10_DST_PS, // Single-value state - D3D10_DST_PS_SAMPLERS, // Count: D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT - D3D10_DST_PS_SHADER_RESOURCES, // Count: D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - D3D10_DST_PS_CONSTANT_BUFFERS, // Count: D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT - - D3D10_DST_IA_VERTEX_BUFFERS, // Count: D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - D3D10_DST_IA_INDEX_BUFFER, // Single-value state - D3D10_DST_IA_INPUT_LAYOUT, // Single-value state - D3D10_DST_IA_PRIMITIVE_TOPOLOGY, // Single-value state - - D3D10_DST_OM_RENDER_TARGETS, // Single-value state (atomical gets/sets) - D3D10_DST_OM_DEPTH_STENCIL_STATE, // Single-value state - D3D10_DST_OM_BLEND_STATE, // Single-value state - - D3D10_DST_RS_VIEWPORTS, // Single-value state (atomical gets/sets) - D3D10_DST_RS_SCISSOR_RECTS, // Single-value state (atomical gets/sets) - D3D10_DST_RS_RASTERIZER_STATE, // Single-value state - - D3D10_DST_SO_BUFFERS, // Single-value state (atomical gets/sets) - - D3D10_DST_PREDICATION, // Single-value state -} D3D10_DEVICE_STATE_TYPES; - -//---------------------------------------------------------------------------- -// D3D10_DEVICE_STATE_TYPES: -// -// Used in ID3D10StateBlockMask function calls -// -//---------------------------------------------------------------------------- - -#ifndef D3D10_BYTES_FROM_BITS -#define D3D10_BYTES_FROM_BITS(x) (((x) + 7) / 8) -#endif // D3D10_BYTES_FROM_BITS - -typedef struct _D3D10_STATE_BLOCK_MASK -{ - BYTE VS; - BYTE VSSamplers[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT)]; - BYTE VSShaderResources[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)]; - BYTE VSConstantBuffers[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT)]; - - BYTE GS; - BYTE GSSamplers[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT)]; - BYTE GSShaderResources[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)]; - BYTE GSConstantBuffers[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT)]; - - BYTE PS; - BYTE PSSamplers[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT)]; - BYTE PSShaderResources[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)]; - BYTE PSConstantBuffers[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT)]; - - BYTE IAVertexBuffers[D3D10_BYTES_FROM_BITS(D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT)]; - BYTE IAIndexBuffer; - BYTE IAInputLayout; - BYTE IAPrimitiveTopology; - - BYTE OMRenderTargets; - BYTE OMDepthStencilState; - BYTE OMBlendState; - - BYTE RSViewports; - BYTE RSScissorRects; - BYTE RSRasterizerState; - - BYTE SOBuffers; - - BYTE Predication; -} D3D10_STATE_BLOCK_MASK; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10StateBlock ////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3D10StateBlock ID3D10StateBlock; -typedef interface ID3D10StateBlock *LPD3D10STATEBLOCK; - -// {0803425A-57F5-4dd6-9465-A87570834A08} -DEFINE_GUID(IID_ID3D10StateBlock, -0x803425a, 0x57f5, 0x4dd6, 0x94, 0x65, 0xa8, 0x75, 0x70, 0x83, 0x4a, 0x8); - -#undef INTERFACE -#define INTERFACE ID3D10StateBlock - -DECLARE_INTERFACE_(ID3D10StateBlock, IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - STDMETHOD(Capture)(THIS) PURE; - STDMETHOD(Apply)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ ID3D10Device **ppDevice) PURE; -}; - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -//---------------------------------------------------------------------------- -// D3D10_STATE_BLOCK_MASK and manipulation functions -// ------------------------------------------------- -// -// These functions exist to facilitate working with the D3D10_STATE_BLOCK_MASK -// structure. -// -// D3D10_STATE_BLOCK_MASK *pResult or *pMask -// The state block mask to operate on -// -// D3D10_STATE_BLOCK_MASK *pA, *pB -// The source state block masks for the binary union/intersect/difference -// operations. -// -// D3D10_DEVICE_STATE_TYPES StateType -// The specific state type to enable/disable/query -// -// UINT RangeStart, RangeLength, Entry -// The specific bit or range of bits for a given state type to operate on. -// Consult the comments for D3D10_DEVICE_STATE_TYPES and -// D3D10_STATE_BLOCK_MASK for information on the valid bit ranges for -// each state. -// -//---------------------------------------------------------------------------- - -HRESULT D3D10StateBlockMaskUnion(D3D10_STATE_BLOCK_MASK *pA, D3D10_STATE_BLOCK_MASK *pB, D3D10_STATE_BLOCK_MASK *pResult); -HRESULT D3D10StateBlockMaskIntersect(D3D10_STATE_BLOCK_MASK *pA, D3D10_STATE_BLOCK_MASK *pB, D3D10_STATE_BLOCK_MASK *pResult); -HRESULT D3D10StateBlockMaskDifference(D3D10_STATE_BLOCK_MASK *pA, D3D10_STATE_BLOCK_MASK *pB, D3D10_STATE_BLOCK_MASK *pResult); -HRESULT D3D10StateBlockMaskEnableCapture(D3D10_STATE_BLOCK_MASK *pMask, D3D10_DEVICE_STATE_TYPES StateType, UINT RangeStart, UINT RangeLength); -HRESULT D3D10StateBlockMaskDisableCapture(D3D10_STATE_BLOCK_MASK *pMask, D3D10_DEVICE_STATE_TYPES StateType, UINT RangeStart, UINT RangeLength); -HRESULT D3D10StateBlockMaskEnableAll(D3D10_STATE_BLOCK_MASK *pMask); -HRESULT D3D10StateBlockMaskDisableAll(D3D10_STATE_BLOCK_MASK *pMask); -BOOL D3D10StateBlockMaskGetSetting(D3D10_STATE_BLOCK_MASK *pMask, D3D10_DEVICE_STATE_TYPES StateType, UINT Entry); - -//---------------------------------------------------------------------------- -// D3D10CreateStateBlock -// --------------------- -// -// Creates a state block object based on the mask settings specified -// in a D3D10_STATE_BLOCK_MASK structure. -// -// ID3D10Device *pDevice -// The device interface to associate with this state block -// -// D3D10_STATE_BLOCK_MASK *pStateBlockMask -// A bit mask whose settings are used to generate a state block -// object. -// -// ID3D10StateBlock **ppStateBlock -// The resulting state block object. This object will save/restore -// only those pieces of state that were set in the state block -// bit mask -//---------------------------------------------------------------------------- - -HRESULT D3D10CreateStateBlock(ID3D10Device *pDevice, D3D10_STATE_BLOCK_MASK *pStateBlockMask, ID3D10StateBlock **ppStateBlock); - -#ifdef __cplusplus -} -#endif //__cplusplus - -//---------------------------------------------------------------------------- -// D3D10_COMPILE & D3D10_EFFECT flags: -// ------------------------------------- -// -// These flags are passed in when creating an effect, and affect -// either compilation behavior or runtime effect behavior -// -// D3D10_COMPILE_CHILD_EFFECT -// Compile this .fx file to a child effect. Child effects have no initializers -// for any shared values as these are initialied in the master effect (pool). -// -// D3D10_COMPILE_DISABLE_PERFORMANCE_MODE -// By default, performance mode is enabled. Performance mode disallows -// mutable state objects by preventing non-literal expressions from appearing in -// state object definitions. Specifying this flag will disable the mode and allow -// for mutable state objects. -// -// D3D10_EFFECT_SINGLE_THREADED -// Do not attempt to synchronize with other threads loading effects into the -// same pool. -// -//---------------------------------------------------------------------------- - -#define D3D10_COMPILE_CHILD_EFFECT (1 << 0) -#define D3D10_COMPILE_DISABLE_PERFORMANCE_MODE (1 << 1) -#define D3D10_EFFECT_SINGLE_THREADED (1 << 3) - - -//---------------------------------------------------------------------------- -// D3D10_EFFECT_VARIABLE flags: -// ---------------------------- -// -// These flags describe an effect variable (global or annotation), -// and are returned in D3D10_EFFECT_VARIABLE_DESC::Flags. -// -// D3D10_EFFECT_VARIABLE_POOLED -// Indicates that the this variable or constant buffer resides -// in an effect pool. If this flag is not set, then the variable resides -// in a standalone effect (if ID3D10Effect::GetPool returns NULL) -// or a child effect (if ID3D10Effect::GetPool returns non-NULL) -// -// D3D10_EFFECT_VARIABLE_ANNOTATION -// Indicates that this is an annotation on a technique, pass, or global -// variable. Otherwise, this is a global variable. Annotations cannot -// be shared. -//---------------------------------------------------------------------------- - -#define D3D10_EFFECT_VARIABLE_POOLED (1 << 0) -#define D3D10_EFFECT_VARIABLE_ANNOTATION (1 << 1) - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectType ////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3D10_EFFECT_TYPE_DESC: -// -// Retrieved by ID3D10EffectType::GetDesc() -//---------------------------------------------------------------------------- - -typedef struct _D3D10_EFFECT_TYPE_DESC -{ - LPCSTR TypeName; // Name of the type - // (e.g. "float4" or "MyStruct") - - D3D10_SHADER_VARIABLE_CLASS Class; // (e.g. scalar, vector, object, etc.) - D3D10_SHADER_VARIABLE_TYPE Type; // (e.g. float, texture, vertexshader, etc.) - - UINT Elements; // Number of elements in this type - // (0 if not an array) - UINT Members; // Number of members - // (0 if not a structure) - UINT Rows; // Number of rows in this type - // (0 if not a numeric primitive) - UINT Columns; // Number of columns in this type - // (0 if not a numeric primitive) - - UINT PackedSize; // Number of bytes required to represent - // this data type, when tightly packed - UINT UnpackedSize; // Number of bytes occupied by this data - // type, when laid out in a constant buffer - UINT Stride; // Number of bytes to seek between elements, - // when laid out in a constant buffer -} D3D10_EFFECT_TYPE_DESC; - -typedef interface ID3D10EffectType ID3D10EffectType; -typedef interface ID3D10EffectType *LPD3D10EFFECTTYPE; - -// {4E9E1DDC-CD9D-4772-A837-00180B9B88FD} -DEFINE_GUID(IID_ID3D10EffectType, -0x4e9e1ddc, 0xcd9d, 0x4772, 0xa8, 0x37, 0x0, 0x18, 0xb, 0x9b, 0x88, 0xfd); - -#undef INTERFACE -#define INTERFACE ID3D10EffectType - -DECLARE_INTERFACE(ID3D10EffectType) -{ - STDMETHOD_(BOOL, IsValid)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_TYPE_DESC *pDesc) PURE; - STDMETHOD_(ID3D10EffectType*, GetMemberTypeByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectType*, GetMemberTypeByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(ID3D10EffectType*, GetMemberTypeBySemantic)(THIS_ LPCSTR Semantic) PURE; - STDMETHOD_(LPCSTR, GetMemberName)(THIS_ UINT Index) PURE; - STDMETHOD_(LPCSTR, GetMemberSemantic)(THIS_ UINT Index) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectVariable ////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3D10_EFFECT_VARIABLE_DESC: -// -// Retrieved by ID3D10EffectVariable::GetDesc() -//---------------------------------------------------------------------------- - -typedef struct _D3D10_EFFECT_VARIABLE_DESC -{ - LPCSTR Name; // Name of this variable, annotation, - // or structure member - LPCSTR Semantic; // Semantic string of this variable - // or structure member (NULL for - // annotations or if not present) - - UINT Flags; // D3D10_EFFECT_VARIABLE_* flags - UINT Annotations; // Number of annotations on this variable - // (always 0 for annotations) - - UINT BufferOffset; // Offset into containing cbuffer or tbuffer - // (always 0 for annotations or variables - // not in constant buffers) -} D3D10_EFFECT_VARIABLE_DESC; - -typedef interface ID3D10EffectVariable ID3D10EffectVariable; -typedef interface ID3D10EffectVariable *LPD3D10EFFECTVARIABLE; - -// {AE897105-00E6-45bf-BB8E-281DD6DB8E1B} -DEFINE_GUID(IID_ID3D10EffectVariable, -0xae897105, 0xe6, 0x45bf, 0xbb, 0x8e, 0x28, 0x1d, 0xd6, 0xdb, 0x8e, 0x1b); - -#undef INTERFACE -#define INTERFACE ID3D10EffectVariable - -// Forward defines -typedef interface ID3D10EffectScalarVariable ID3D10EffectScalarVariable; -typedef interface ID3D10EffectVectorVariable ID3D10EffectVectorVariable; -typedef interface ID3D10EffectMatrixVariable ID3D10EffectMatrixVariable; -typedef interface ID3D10EffectStringVariable ID3D10EffectStringVariable; -typedef interface ID3D10EffectShaderResourceVariable ID3D10EffectShaderResourceVariable; -typedef interface ID3D10EffectConstantBuffer ID3D10EffectConstantBuffer; -typedef interface ID3D10EffectShaderVariable ID3D10EffectShaderVariable; -typedef interface ID3D10EffectBlendVariable ID3D10EffectBlendVariable; -typedef interface ID3D10EffectDepthStencilVariable ID3D10EffectDepthStencilVariable; -typedef interface ID3D10EffectRasterizerVariable ID3D10EffectRasterizerVariable; -typedef interface ID3D10EffectSamplerVariable ID3D10EffectSamplerVariable; - -DECLARE_INTERFACE(ID3D10EffectVariable) -{ - STDMETHOD_(BOOL, IsValid)(THIS) PURE; - STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; - - STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; - - STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; - STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; - STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; - STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; - STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; - STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; - STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; - STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; - STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; - - STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectScalarVariable //////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3D10EffectScalarVariable ID3D10EffectScalarVariable; -typedef interface ID3D10EffectScalarVariable *LPD3D10EFFECTSCALARVARIABLE; - -// {00E48F7B-D2C8-49e8-A86C-022DEE53431F} -DEFINE_GUID(IID_ID3D10EffectScalarVariable, -0xe48f7b, 0xd2c8, 0x49e8, 0xa8, 0x6c, 0x2, 0x2d, 0xee, 0x53, 0x43, 0x1f); - -#undef INTERFACE -#define INTERFACE ID3D10EffectScalarVariable - -DECLARE_INTERFACE_(ID3D10EffectScalarVariable, ID3D10EffectVariable) -{ - STDMETHOD_(BOOL, IsValid)(THIS) PURE; - STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; - - STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; - - STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; - STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; - STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; - STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; - STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; - STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; - STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; - STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; - STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; - - STDMETHOD(SetRawValue)(THIS_ void *pData, UINT ByteOffset, UINT ByteCount) PURE; - STDMETHOD(GetRawValue)(THIS_ void *pData, UINT ByteOffset, UINT ByteCount) PURE; - - STDMETHOD(SetFloat)(THIS_ float Value) PURE; - STDMETHOD(GetFloat)(THIS_ float *pValue) PURE; - - STDMETHOD(SetFloatArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetFloatArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; - - STDMETHOD(SetInt)(THIS_ int Value) PURE; - STDMETHOD(GetInt)(THIS_ int *pValue) PURE; - - STDMETHOD(SetIntArray)(THIS_ int *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetIntArray)(THIS_ int *pData, UINT Offset, UINT Count) PURE; - - STDMETHOD(SetBool)(THIS_ BOOL Value) PURE; - STDMETHOD(GetBool)(THIS_ BOOL *pValue) PURE; - - STDMETHOD(SetBoolArray)(THIS_ BOOL *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetBoolArray)(THIS_ BOOL *pData, UINT Offset, UINT Count) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectVectorVariable //////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3D10EffectVectorVariable ID3D10EffectVectorVariable; -typedef interface ID3D10EffectVectorVariable *LPD3D10EFFECTVECTORVARIABLE; - -// {62B98C44-1F82-4c67-BCD0-72CF8F217E81} -DEFINE_GUID(IID_ID3D10EffectVectorVariable, -0x62b98c44, 0x1f82, 0x4c67, 0xbc, 0xd0, 0x72, 0xcf, 0x8f, 0x21, 0x7e, 0x81); - -#undef INTERFACE -#define INTERFACE ID3D10EffectVectorVariable - -DECLARE_INTERFACE_(ID3D10EffectVectorVariable, ID3D10EffectVariable) -{ - STDMETHOD_(BOOL, IsValid)(THIS) PURE; - STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; - - STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; - - STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; - STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; - STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; - STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; - STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; - STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; - STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; - STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; - STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; - - STDMETHOD(SetRawValue)(THIS_ void *pData, UINT ByteOffset, UINT ByteCount) PURE; - STDMETHOD(GetRawValue)(THIS_ void *pData, UINT ByteOffset, UINT ByteCount) PURE; - - STDMETHOD(SetBoolVector) (THIS_ BOOL *pData) PURE; - STDMETHOD(SetIntVector) (THIS_ int *pData) PURE; - STDMETHOD(SetFloatVector)(THIS_ float *pData) PURE; - - STDMETHOD(GetBoolVector) (THIS_ BOOL *pData) PURE; - STDMETHOD(GetIntVector) (THIS_ int *pData) PURE; - STDMETHOD(GetFloatVector)(THIS_ float *pData) PURE; - - STDMETHOD(SetBoolVectorArray) (THIS_ BOOL *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(SetIntVectorArray) (THIS_ int *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(SetFloatVectorArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; - - STDMETHOD(GetBoolVectorArray) (THIS_ BOOL *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetIntVectorArray) (THIS_ int *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetFloatVectorArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectMatrixVariable //////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3D10EffectMatrixVariable ID3D10EffectMatrixVariable; -typedef interface ID3D10EffectMatrixVariable *LPD3D10EFFECTMATRIXVARIABLE; - -// {50666C24-B82F-4eed-A172-5B6E7E8522E0} -DEFINE_GUID(IID_ID3D10EffectMatrixVariable, -0x50666c24, 0xb82f, 0x4eed, 0xa1, 0x72, 0x5b, 0x6e, 0x7e, 0x85, 0x22, 0xe0); - -#undef INTERFACE -#define INTERFACE ID3D10EffectMatrixVariable - -DECLARE_INTERFACE_(ID3D10EffectMatrixVariable, ID3D10EffectVariable) -{ - STDMETHOD_(BOOL, IsValid)(THIS) PURE; - STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; - - STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; - - STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; - STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; - STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; - STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; - STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; - STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; - STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; - STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; - STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; - - STDMETHOD(SetRawValue)(THIS_ void *pData, UINT ByteOffset, UINT ByteCount) PURE; - STDMETHOD(GetRawValue)(THIS_ void *pData, UINT ByteOffset, UINT ByteCount) PURE; - - STDMETHOD(SetMatrix)(THIS_ float *pData) PURE; - STDMETHOD(GetMatrix)(THIS_ float *pData) PURE; - - STDMETHOD(SetMatrixArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetMatrixArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; - - STDMETHOD(SetMatrixTranspose)(THIS_ float *pData) PURE; - STDMETHOD(GetMatrixTranspose)(THIS_ float *pData) PURE; - - STDMETHOD(SetMatrixTransposeArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetMatrixTransposeArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectStringVariable //////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3D10EffectStringVariable ID3D10EffectStringVariable; -typedef interface ID3D10EffectStringVariable *LPD3D10EFFECTSTRINGVARIABLE; - -// {71417501-8DF9-4e0a-A78A-255F9756BAFF} -DEFINE_GUID(IID_ID3D10EffectStringVariable, -0x71417501, 0x8df9, 0x4e0a, 0xa7, 0x8a, 0x25, 0x5f, 0x97, 0x56, 0xba, 0xff); - -#undef INTERFACE -#define INTERFACE ID3D10EffectStringVariable - -DECLARE_INTERFACE_(ID3D10EffectStringVariable, ID3D10EffectVariable) -{ - STDMETHOD_(BOOL, IsValid)(THIS) PURE; - STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; - - STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; - - STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; - STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; - STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; - STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; - STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; - STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; - STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; - STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; - STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; - - STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - - STDMETHOD(GetString)(THIS_ LPCSTR *ppString) PURE; - STDMETHOD(GetStringArray)(THIS_ LPCSTR *ppStrings, UINT Offset, UINT Count) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectShaderResourceVariable //////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3D10EffectShaderResourceVariable ID3D10EffectShaderResourceVariable; -typedef interface ID3D10EffectShaderResourceVariable *LPD3D10EFFECTSHADERRESOURCEVARIABLE; - -// {C0A7157B-D872-4b1d-8073-EFC2ACD4B1FC} -DEFINE_GUID(IID_ID3D10EffectShaderResourceVariable, -0xc0a7157b, 0xd872, 0x4b1d, 0x80, 0x73, 0xef, 0xc2, 0xac, 0xd4, 0xb1, 0xfc); - - -#undef INTERFACE -#define INTERFACE ID3D10EffectShaderResourceVariable - -DECLARE_INTERFACE_(ID3D10EffectShaderResourceVariable, ID3D10EffectVariable) -{ - STDMETHOD_(BOOL, IsValid)(THIS) PURE; - STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; - - STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; - - STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; - STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; - STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; - STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; - STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; - STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; - STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; - STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; - STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; - - STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - - STDMETHOD(SetResource)(THIS_ ID3D10ShaderResourceView *pResource) PURE; - STDMETHOD(GetResource)(THIS_ ID3D10ShaderResourceView **ppResource) PURE; - - STDMETHOD(SetResourceArray)(THIS_ ID3D10ShaderResourceView **ppResources, UINT Offset, UINT Count) PURE; - STDMETHOD(GetResourceArray)(THIS_ ID3D10ShaderResourceView **ppResources, UINT Offset, UINT Count) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectConstantBuffer //////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3D10EffectConstantBuffer ID3D10EffectConstantBuffer; -typedef interface ID3D10EffectConstantBuffer *LPD3D10EFFECTCONSTANTBUFFER; - -// {56648F4D-CC8B-4444-A5AD-B5A3D76E91B3} -DEFINE_GUID(IID_ID3D10EffectConstantBuffer, -0x56648f4d, 0xcc8b, 0x4444, 0xa5, 0xad, 0xb5, 0xa3, 0xd7, 0x6e, 0x91, 0xb3); - -#undef INTERFACE -#define INTERFACE ID3D10EffectConstantBuffer - -DECLARE_INTERFACE_(ID3D10EffectConstantBuffer, ID3D10EffectVariable) -{ - STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; - - STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; - - STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; - STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; - STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; - STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; - STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; - STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; - STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; - STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; - STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; - - STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - - STDMETHOD(SetConstantBuffer)(THIS_ ID3D10Buffer *pConstantBuffer) PURE; - STDMETHOD(GetConstantBuffer)(THIS_ ID3D10Buffer **ppConstantBuffer) PURE; - - STDMETHOD(SetTextureBuffer)(THIS_ ID3D10ShaderResourceView *pTextureBuffer) PURE; - STDMETHOD(GetTextureBuffer)(THIS_ ID3D10ShaderResourceView **ppTextureBuffer) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectShaderVariable //////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3D10_EFFECT_SHADER_DESC: -// -// Retrieved by ID3D10EffectShaderVariable::GetShaderDesc() -//---------------------------------------------------------------------------- - -typedef struct _D3D10_EFFECT_SHADER_DESC -{ - CONST BYTE *pInputSignature; // Passed into CreateInputLayout, - // valid on VS and GS only - - BOOL IsInline; // Is this an anonymous shader variable - // resulting from an inline shader assignment? - - - // -- The following fields are not valid after Optimize() -- - CONST BYTE *pBytecode; // Shader bytecode - UINT BytecodeLength; - - LPCSTR SODecl; // Stream out declaration string (for GS with SO) - - UINT NumInputSignatureEntries; // Number of entries in the input signature - UINT NumOutputSignatureEntries; // Number of entries in the output signature -} D3D10_EFFECT_SHADER_DESC; - - -typedef interface ID3D10EffectShaderVariable ID3D10EffectShaderVariable; -typedef interface ID3D10EffectShaderVariable *LPD3D10EFFECTSHADERVARIABLE; - -// {80849279-C799-4797-8C33-0407A07D9E06} -DEFINE_GUID(IID_ID3D10EffectShaderVariable, -0x80849279, 0xc799, 0x4797, 0x8c, 0x33, 0x4, 0x7, 0xa0, 0x7d, 0x9e, 0x6); - -#undef INTERFACE -#define INTERFACE ID3D10EffectShaderVariable - -DECLARE_INTERFACE_(ID3D10EffectShaderVariable, ID3D10EffectVariable) -{ - STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; - - STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; - - STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; - STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; - STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; - STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; - STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; - STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; - STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; - STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; - STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; - - STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - - STDMETHOD(GetShaderDesc)(THIS_ UINT ShaderIndex, D3D10_EFFECT_SHADER_DESC *pDesc) PURE; - - STDMETHOD(GetVertexShader)(THIS_ UINT ShaderIndex, ID3D10VertexShader **ppVS) PURE; - STDMETHOD(GetGeometryShader)(THIS_ UINT ShaderIndex, ID3D10GeometryShader **ppGS) PURE; - STDMETHOD(GetPixelShader)(THIS_ UINT ShaderIndex, ID3D10PixelShader **ppPS) PURE; - - STDMETHOD(GetInputSignatureElementDesc)(THIS_ UINT ShaderIndex, UINT Element, D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE; - STDMETHOD(GetOutputSignatureElementDesc)(THIS_ UINT ShaderIndex, UINT Element, D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectBlendVariable ///////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3D10EffectBlendVariable ID3D10EffectBlendVariable; -typedef interface ID3D10EffectBlendVariable *LPD3D10EFFECTBLENDVARIABLE; - -// {1FCD2294-DF6D-4eae-86B3-0E9160CFB07B} -DEFINE_GUID(IID_ID3D10EffectBlendVariable, -0x1fcd2294, 0xdf6d, 0x4eae, 0x86, 0xb3, 0xe, 0x91, 0x60, 0xcf, 0xb0, 0x7b); - -#undef INTERFACE -#define INTERFACE ID3D10EffectBlendVariable - -DECLARE_INTERFACE_(ID3D10EffectBlendVariable, ID3D10EffectVariable) -{ - STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; - - STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; - - STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; - STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; - STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; - STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; - STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; - STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; - STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; - STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; - STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; - - STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - - STDMETHOD(GetBlendState)(THIS_ UINT Index, ID3D10BlendState **ppBlendState) PURE; - STDMETHOD(GetBackingStore)(THIS_ UINT Index, D3D10_BLEND_DESC *pBlendDesc) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectDepthStencilVariable ////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3D10EffectDepthStencilVariable ID3D10EffectDepthStencilVariable; -typedef interface ID3D10EffectDepthStencilVariable *LPD3D10EFFECTDEPTHSTENCILVARIABLE; - -// {AF482368-330A-46a5-9A5C-01C71AF24C8D} -DEFINE_GUID(IID_ID3D10EffectDepthStencilVariable, -0xaf482368, 0x330a, 0x46a5, 0x9a, 0x5c, 0x1, 0xc7, 0x1a, 0xf2, 0x4c, 0x8d); - -#undef INTERFACE -#define INTERFACE ID3D10EffectDepthStencilVariable - -DECLARE_INTERFACE_(ID3D10EffectDepthStencilVariable, ID3D10EffectVariable) -{ - STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; - - STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; - - STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; - STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; - STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; - STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; - STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; - STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; - STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; - STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; - STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; - - STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - - STDMETHOD(GetDepthStencilState)(THIS_ UINT Index, ID3D10DepthStencilState **ppDepthStencilState) PURE; - STDMETHOD(GetBackingStore)(THIS_ UINT Index, D3D10_DEPTH_STENCIL_DESC *pDepthStencilDesc) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectRasterizerVariable //////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3D10EffectRasterizerVariable ID3D10EffectRasterizerVariable; -typedef interface ID3D10EffectRasterizerVariable *LPD3D10EFFECTRASTERIZERVARIABLE; - -// {21AF9F0E-4D94-4ea9-9785-2CB76B8C0B34} -DEFINE_GUID(IID_ID3D10EffectRasterizerVariable, -0x21af9f0e, 0x4d94, 0x4ea9, 0x97, 0x85, 0x2c, 0xb7, 0x6b, 0x8c, 0xb, 0x34); - -#undef INTERFACE -#define INTERFACE ID3D10EffectRasterizerVariable - -DECLARE_INTERFACE_(ID3D10EffectRasterizerVariable, ID3D10EffectVariable) -{ - STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; - - STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; - - STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; - STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; - STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; - STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; - STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; - STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; - STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; - STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; - STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; - - STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - - STDMETHOD(GetRasterizerState)(THIS_ UINT Index, ID3D10RasterizerState **ppRasterizerState) PURE; - STDMETHOD(GetBackingStore)(THIS_ UINT Index, D3D10_RASTERIZER_DESC *pRasterizerDesc) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectSamplerVariable /////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3D10EffectSamplerVariable ID3D10EffectSamplerVariable; -typedef interface ID3D10EffectSamplerVariable *LPD3D10EFFECTSAMPLERVARIABLE; - -// {6530D5C7-07E9-4271-A418-E7CE4BD1E480} -DEFINE_GUID(IID_ID3D10EffectSamplerVariable, -0x6530d5c7, 0x7e9, 0x4271, 0xa4, 0x18, 0xe7, 0xce, 0x4b, 0xd1, 0xe4, 0x80); - -#undef INTERFACE -#define INTERFACE ID3D10EffectSamplerVariable - -DECLARE_INTERFACE_(ID3D10EffectSamplerVariable, ID3D10EffectVariable) -{ - STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; - - STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; - - STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; - STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; - STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; - STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; - STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; - STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; - STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; - STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; - STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; - STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; - - STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; - - STDMETHOD(GetSampler)(THIS_ UINT Index, ID3D10SamplerState **ppSampler) PURE; - STDMETHOD(GetBackingStore)(THIS_ UINT Index, D3D10_SAMPLER_DESC *pSamplerDesc) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectPass ////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3D10_PASS_DESC: -// -// Retrieved by ID3D10EffectPass::GetDesc() -//---------------------------------------------------------------------------- - -typedef struct _D3D10_PASS_DESC -{ - LPCSTR Name; // Name of this pass (NULL if not anonymous) - UINT Annotations; // Number of annotations on this pass - - BYTE *pIAInputSignature; // Signature from VS or GS (if there is no VS) - // or NULL if neither exists - - UINT StencilRef; // Specified in SetDepthStencilState() - UINT SampleMask; // Specified in SetBlendState() - FLOAT BlendFactor[4]; // Specified in SetBlendState() -} D3D10_PASS_DESC; - -//---------------------------------------------------------------------------- -// D3D10_PASS_SHADER_DESC: -// -// Retrieved by ID3D10EffectPass::Get**ShaderDesc() -//---------------------------------------------------------------------------- - -typedef struct _D3D10_PASS_SHADER_DESC -{ - ID3D10EffectShaderVariable *pShaderVariable; // The variable that this shader came from. - // If this is an inline shader assignment, - // the returned interface will be an - // anonymous shader variable, which is - // not retrievable any other way. It's - // name in the variable description will - // be "$Anonymous". - // If there is no assignment of this type in - // the pass block, pShaderVariable != NULL, - // but pShaderVariable->IsValid() == FALSE. - - UINT ShaderIndex; // The element of pShaderVariable (if an array) - // or 0 if not applicable -} D3D10_PASS_SHADER_DESC; - -typedef interface ID3D10EffectPass ID3D10EffectPass; -typedef interface ID3D10EffectPass *LPD3D10EFFECTPASS; - -// {5CFBEB89-1A06-46e0-B282-E3F9BFA36A54} -DEFINE_GUID(IID_ID3D10EffectPass, -0x5cfbeb89, 0x1a06, 0x46e0, 0xb2, 0x82, 0xe3, 0xf9, 0xbf, 0xa3, 0x6a, 0x54); - -#undef INTERFACE -#define INTERFACE ID3D10EffectPass - -DECLARE_INTERFACE(ID3D10EffectPass) -{ - STDMETHOD_(BOOL, IsValid)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_PASS_DESC *pDesc) PURE; - - STDMETHOD(GetVertexShaderDesc)(THIS_ D3D10_PASS_SHADER_DESC *pDesc) PURE; - STDMETHOD(GetGeometryShaderDesc)(THIS_ D3D10_PASS_SHADER_DESC *pDesc) PURE; - STDMETHOD(GetPixelShaderDesc)(THIS_ D3D10_PASS_SHADER_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD(Apply)(THIS_ UINT Flags) PURE; - - STDMETHOD(ComputeStateBlockMask)(THIS_ D3D10_STATE_BLOCK_MASK *pStateBlockMask) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectTechnique ///////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3D10_TECHNIQUE_DESC: -// -// Retrieved by ID3D10EffectTechnique::GetDesc() -//---------------------------------------------------------------------------- - -typedef struct _D3D10_TECHNIQUE_DESC -{ - LPCSTR Name; // Name of this technique (NULL if not anonymous) - UINT Passes; // Number of passes contained within - UINT Annotations; // Number of annotations on this technique -} D3D10_TECHNIQUE_DESC; - -typedef interface ID3D10EffectTechnique ID3D10EffectTechnique; -typedef interface ID3D10EffectTechnique *LPD3D10EFFECTTECHNIQUE; - -// {DB122CE8-D1C9-4292-B237-24ED3DE8B175} -DEFINE_GUID(IID_ID3D10EffectTechnique, -0xdb122ce8, 0xd1c9, 0x4292, 0xb2, 0x37, 0x24, 0xed, 0x3d, 0xe8, 0xb1, 0x75); - -#undef INTERFACE -#define INTERFACE ID3D10EffectTechnique - -DECLARE_INTERFACE(ID3D10EffectTechnique) -{ - STDMETHOD_(BOOL, IsValid)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3D10_TECHNIQUE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D10EffectPass*, GetPassByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectPass*, GetPassByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD(ComputeStateBlockMask)(THIS_ D3D10_STATE_BLOCK_MASK *pStateBlockMask) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10Effect ////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3D10_EFFECT_DESC: -// -// Retrieved by ID3D10Effect::GetDesc() -//---------------------------------------------------------------------------- - -typedef struct _D3D10_EFFECT_DESC -{ - //TODO: do we need these? - //LPCSTR Creator; - //UINT Version; - - BOOL IsChildEffect; // TRUE if this is a child effect, - // FALSE if this is standalone or an effect pool. - - UINT ConstantBuffers; // Number of constant buffers in this effect, - // excluding the effect pool. - UINT SharedConstantBuffers; // Number of constant buffers shared in this - // effect's pool. - - UINT GlobalVariables; // Number of global variables in this effect, - // excluding the effect pool. - UINT SharedGlobalVariables; // Number of global variables shared in this - // effect's pool. - - UINT Techniques; // Number of techniques in this effect, - // excluding the effect pool. -} D3D10_EFFECT_DESC; - -typedef interface ID3D10Effect ID3D10Effect; -typedef interface ID3D10Effect *LPD3D10EFFECT; - -// {51B0CA8B-EC0B-4519-870D-8EE1CB5017C7} -DEFINE_GUID(IID_ID3D10Effect, -0x51b0ca8b, 0xec0b, 0x4519, 0x87, 0xd, 0x8e, 0xe1, 0xcb, 0x50, 0x17, 0xc7); - -#undef INTERFACE -#define INTERFACE ID3D10Effect - -DECLARE_INTERFACE_(ID3D10Effect, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - STDMETHOD_(BOOL, IsValid)(THIS) PURE; - STDMETHOD_(BOOL, IsPool)(THIS) PURE; - - // Managing D3D Device - STDMETHOD(GetDevice)(THIS_ ID3D10Device** ppDevice) PURE; - - // New Reflection APIs - STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10EffectConstantBuffer*, GetConstantBufferByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectConstantBuffer*, GetConstantBufferByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D10EffectVariable*, GetVariableByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetVariableByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(ID3D10EffectVariable*, GetVariableBySemantic)(THIS_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3D10EffectTechnique*, GetTechniqueByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10EffectTechnique*, GetTechniqueByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD(Optimize)(THIS) PURE; - STDMETHOD_(BOOL, IsOptimized)(THIS) PURE; - -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3D10EffectPool ////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3D10EffectPool ID3D10EffectPool; -typedef interface ID3D10EffectPool *LPD3D10EFFECTPOOL; - -// {9537AB04-3250-412e-8213-FCD2F8677933} -DEFINE_GUID(IID_ID3D10EffectPool, -0x9537ab04, 0x3250, 0x412e, 0x82, 0x13, 0xfc, 0xd2, 0xf8, 0x67, 0x79, 0x33); - -#undef INTERFACE -#define INTERFACE ID3D10EffectPool - -DECLARE_INTERFACE_(ID3D10EffectPool, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - STDMETHOD_(ID3D10Effect*, AsEffect)(THIS) PURE; - - // No public methods -}; - -////////////////////////////////////////////////////////////////////////////// -// APIs ////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -//---------------------------------------------------------------------------- -// D3D10CreateEffectFromXXXX: -// -------------------------- -// Creates an effect from a binary effect or file -// -// Parameters: -// -// [in] -// -// TODO: Unicode support -// TODO: Support for binary (and not just ASCII) -// -// pFileName -// Name of the ASCII (uncompiled) or binary (compiled) Effect file to load -// -// hModule -// Handle to the module containing the resource to compile from -// pResourceName -// Name of the resource within hModule to compile from -// -// pData -// Blob of effect data, either ASCII (uncompiled) or binary (compiled) -// DataLength -// Length of the data blob -// -// pDefines -// Optional NULL-terminated array of preprocessor macro definitions. -// pInclude -// Optional interface pointer to use for handling #include directives. -// If this parameter is NULL, #includes will be honored when compiling -// from file, and will error when compiling from resource or memory. -// HLSLFlags -// Compilation flags pertaining to shaders and data types, honored by -// the HLSL compiler -// FXFlags -// Compilation flags pertaining to Effect compilation, honored -// by the Effect compiler -// pDevice -// Pointer to the D3D10 device on which to create Effect resources -// pEffectPool -// Pointer to an Effect pool to share variables with or NULL -// -// [out] -// -// ppEffect -// Address of the newly created Effect interface -// ppEffectPool -// Address of the newly created Effect pool interface -// ppErrors -// If non-NULL, address of a buffer with error messages that occurred -// during parsing or compilation -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI D3D10CompileEffectFromMemory(void *pData, SIZE_T DataLength, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, - ID3D10Blob **ppCompiledEffect, ID3D10Blob **ppErrors); - -HRESULT WINAPI D3D10CreateEffectFromMemory(void *pData, SIZE_T DataLength, UINT FXFlags, ID3D10Device *pDevice, - ID3D10EffectPool *pEffectPool, ID3D10Effect **ppEffect); - -HRESULT WINAPI D3D10CreateEffectPoolFromMemory(void *pData, SIZE_T DataLength, UINT FXFlags, ID3D10Device *pDevice, - ID3D10EffectPool **ppEffectPool); - - -//---------------------------------------------------------------------------- -// D3D10DisassembleEffect: -// ----------------------- -// Takes an effect interface, and returns a buffer containing text assembly. -// -// Parameters: -// pEffect -// Pointer to the runtime effect interface. -// EnableColorCode -// Emit HTML tags for color coding the output? -// ppDisassembly -// Returns a buffer containing the disassembled effect. -//---------------------------------------------------------------------------- - -HRESULT WINAPI D3D10DisassembleEffect(ID3D10Effect *pEffect, BOOL EnableColorCode, ID3D10Blob **ppDisassembly); - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3D10EFFECT_H__ - - + +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// File: D3D10Effect.h +// Content: D3D10 Stateblock/Effect Types & APIs +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef __D3D10EFFECT_H__ +#define __D3D10EFFECT_H__ + +#include "d3d10.h" + +////////////////////////////////////////////////////////////////////////////// +// File contents: +// +// 1) Stateblock enums, structs, interfaces, flat APIs +// 2) Effect enums, structs, interfaces, flat APIs +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3D10_DEVICE_STATE_TYPES: +// +// Used in ID3D10StateBlockMask function calls +// +//---------------------------------------------------------------------------- + +typedef enum _D3D10_DEVICE_STATE_TYPES +{ + D3D10_DST_VS = 1, // Single-value state + D3D10_DST_VS_SAMPLERS, // Count: D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT + D3D10_DST_VS_SHADER_RESOURCES, // Count: D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT + D3D10_DST_VS_CONSTANT_BUFFERS, // Count: D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT + + D3D10_DST_GS, // Single-value state + D3D10_DST_GS_SAMPLERS, // Count: D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT + D3D10_DST_GS_SHADER_RESOURCES, // Count: D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT + D3D10_DST_GS_CONSTANT_BUFFERS, // Count: D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT + + D3D10_DST_PS, // Single-value state + D3D10_DST_PS_SAMPLERS, // Count: D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT + D3D10_DST_PS_SHADER_RESOURCES, // Count: D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT + D3D10_DST_PS_CONSTANT_BUFFERS, // Count: D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT + + D3D10_DST_IA_VERTEX_BUFFERS, // Count: D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT + D3D10_DST_IA_INDEX_BUFFER, // Single-value state + D3D10_DST_IA_INPUT_LAYOUT, // Single-value state + D3D10_DST_IA_PRIMITIVE_TOPOLOGY, // Single-value state + + D3D10_DST_OM_RENDER_TARGETS, // Single-value state (atomical gets/sets) + D3D10_DST_OM_DEPTH_STENCIL_STATE, // Single-value state + D3D10_DST_OM_BLEND_STATE, // Single-value state + + D3D10_DST_RS_VIEWPORTS, // Single-value state (atomical gets/sets) + D3D10_DST_RS_SCISSOR_RECTS, // Single-value state (atomical gets/sets) + D3D10_DST_RS_RASTERIZER_STATE, // Single-value state + + D3D10_DST_SO_BUFFERS, // Single-value state (atomical gets/sets) + + D3D10_DST_PREDICATION, // Single-value state +} D3D10_DEVICE_STATE_TYPES; + +//---------------------------------------------------------------------------- +// D3D10_DEVICE_STATE_TYPES: +// +// Used in ID3D10StateBlockMask function calls +// +//---------------------------------------------------------------------------- + +#ifndef D3D10_BYTES_FROM_BITS +#define D3D10_BYTES_FROM_BITS(x) (((x) + 7) / 8) +#endif // D3D10_BYTES_FROM_BITS + +typedef struct _D3D10_STATE_BLOCK_MASK +{ + BYTE VS; + BYTE VSSamplers[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT)]; + BYTE VSShaderResources[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)]; + BYTE VSConstantBuffers[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT)]; + + BYTE GS; + BYTE GSSamplers[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT)]; + BYTE GSShaderResources[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)]; + BYTE GSConstantBuffers[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT)]; + + BYTE PS; + BYTE PSSamplers[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT)]; + BYTE PSShaderResources[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)]; + BYTE PSConstantBuffers[D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT)]; + + BYTE IAVertexBuffers[D3D10_BYTES_FROM_BITS(D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT)]; + BYTE IAIndexBuffer; + BYTE IAInputLayout; + BYTE IAPrimitiveTopology; + + BYTE OMRenderTargets; + BYTE OMDepthStencilState; + BYTE OMBlendState; + + BYTE RSViewports; + BYTE RSScissorRects; + BYTE RSRasterizerState; + + BYTE SOBuffers; + + BYTE Predication; +} D3D10_STATE_BLOCK_MASK; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10StateBlock ////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3D10StateBlock ID3D10StateBlock; +typedef interface ID3D10StateBlock *LPD3D10STATEBLOCK; + +// {0803425A-57F5-4dd6-9465-A87570834A08} +DEFINE_GUID(IID_ID3D10StateBlock, +0x803425a, 0x57f5, 0x4dd6, 0x94, 0x65, 0xa8, 0x75, 0x70, 0x83, 0x4a, 0x8); + +#undef INTERFACE +#define INTERFACE ID3D10StateBlock + +DECLARE_INTERFACE_(ID3D10StateBlock, IUnknown) +{ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + STDMETHOD(Capture)(THIS) PURE; + STDMETHOD(Apply)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ ID3D10Device **ppDevice) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +//---------------------------------------------------------------------------- +// D3D10_STATE_BLOCK_MASK and manipulation functions +// ------------------------------------------------- +// +// These functions exist to facilitate working with the D3D10_STATE_BLOCK_MASK +// structure. +// +// D3D10_STATE_BLOCK_MASK *pResult or *pMask +// The state block mask to operate on +// +// D3D10_STATE_BLOCK_MASK *pA, *pB +// The source state block masks for the binary union/intersect/difference +// operations. +// +// D3D10_DEVICE_STATE_TYPES StateType +// The specific state type to enable/disable/query +// +// UINT RangeStart, RangeLength, Entry +// The specific bit or range of bits for a given state type to operate on. +// Consult the comments for D3D10_DEVICE_STATE_TYPES and +// D3D10_STATE_BLOCK_MASK for information on the valid bit ranges for +// each state. +// +//---------------------------------------------------------------------------- + +HRESULT D3D10StateBlockMaskUnion(D3D10_STATE_BLOCK_MASK *pA, D3D10_STATE_BLOCK_MASK *pB, D3D10_STATE_BLOCK_MASK *pResult); +HRESULT D3D10StateBlockMaskIntersect(D3D10_STATE_BLOCK_MASK *pA, D3D10_STATE_BLOCK_MASK *pB, D3D10_STATE_BLOCK_MASK *pResult); +HRESULT D3D10StateBlockMaskDifference(D3D10_STATE_BLOCK_MASK *pA, D3D10_STATE_BLOCK_MASK *pB, D3D10_STATE_BLOCK_MASK *pResult); +HRESULT D3D10StateBlockMaskEnableCapture(D3D10_STATE_BLOCK_MASK *pMask, D3D10_DEVICE_STATE_TYPES StateType, UINT RangeStart, UINT RangeLength); +HRESULT D3D10StateBlockMaskDisableCapture(D3D10_STATE_BLOCK_MASK *pMask, D3D10_DEVICE_STATE_TYPES StateType, UINT RangeStart, UINT RangeLength); +HRESULT D3D10StateBlockMaskEnableAll(D3D10_STATE_BLOCK_MASK *pMask); +HRESULT D3D10StateBlockMaskDisableAll(D3D10_STATE_BLOCK_MASK *pMask); +BOOL D3D10StateBlockMaskGetSetting(D3D10_STATE_BLOCK_MASK *pMask, D3D10_DEVICE_STATE_TYPES StateType, UINT Entry); + +//---------------------------------------------------------------------------- +// D3D10CreateStateBlock +// --------------------- +// +// Creates a state block object based on the mask settings specified +// in a D3D10_STATE_BLOCK_MASK structure. +// +// ID3D10Device *pDevice +// The device interface to associate with this state block +// +// D3D10_STATE_BLOCK_MASK *pStateBlockMask +// A bit mask whose settings are used to generate a state block +// object. +// +// ID3D10StateBlock **ppStateBlock +// The resulting state block object. This object will save/restore +// only those pieces of state that were set in the state block +// bit mask +//---------------------------------------------------------------------------- + +HRESULT D3D10CreateStateBlock(ID3D10Device *pDevice, D3D10_STATE_BLOCK_MASK *pStateBlockMask, ID3D10StateBlock **ppStateBlock); + +#ifdef __cplusplus +} +#endif //__cplusplus + +//---------------------------------------------------------------------------- +// D3D10_COMPILE & D3D10_EFFECT flags: +// ------------------------------------- +// +// These flags are passed in when creating an effect, and affect +// either compilation behavior or runtime effect behavior +// +// D3D10_COMPILE_CHILD_EFFECT +// Compile this .fx file to a child effect. Child effects have no initializers +// for any shared values as these are initialied in the master effect (pool). +// +// D3D10_COMPILE_DISABLE_PERFORMANCE_MODE +// By default, performance mode is enabled. Performance mode disallows +// mutable state objects by preventing non-literal expressions from appearing in +// state object definitions. Specifying this flag will disable the mode and allow +// for mutable state objects. +// +// D3D10_EFFECT_SINGLE_THREADED +// Do not attempt to synchronize with other threads loading effects into the +// same pool. +// +//---------------------------------------------------------------------------- + +#define D3D10_COMPILE_CHILD_EFFECT (1 << 0) +#define D3D10_COMPILE_DISABLE_PERFORMANCE_MODE (1 << 1) +#define D3D10_EFFECT_SINGLE_THREADED (1 << 3) + + +//---------------------------------------------------------------------------- +// D3D10_EFFECT_VARIABLE flags: +// ---------------------------- +// +// These flags describe an effect variable (global or annotation), +// and are returned in D3D10_EFFECT_VARIABLE_DESC::Flags. +// +// D3D10_EFFECT_VARIABLE_POOLED +// Indicates that the this variable or constant buffer resides +// in an effect pool. If this flag is not set, then the variable resides +// in a standalone effect (if ID3D10Effect::GetPool returns NULL) +// or a child effect (if ID3D10Effect::GetPool returns non-NULL) +// +// D3D10_EFFECT_VARIABLE_ANNOTATION +// Indicates that this is an annotation on a technique, pass, or global +// variable. Otherwise, this is a global variable. Annotations cannot +// be shared. +//---------------------------------------------------------------------------- + +#define D3D10_EFFECT_VARIABLE_POOLED (1 << 0) +#define D3D10_EFFECT_VARIABLE_ANNOTATION (1 << 1) + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectType ////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3D10_EFFECT_TYPE_DESC: +// +// Retrieved by ID3D10EffectType::GetDesc() +//---------------------------------------------------------------------------- + +typedef struct _D3D10_EFFECT_TYPE_DESC +{ + LPCSTR TypeName; // Name of the type + // (e.g. "float4" or "MyStruct") + + D3D10_SHADER_VARIABLE_CLASS Class; // (e.g. scalar, vector, object, etc.) + D3D10_SHADER_VARIABLE_TYPE Type; // (e.g. float, texture, vertexshader, etc.) + + UINT Elements; // Number of elements in this type + // (0 if not an array) + UINT Members; // Number of members + // (0 if not a structure) + UINT Rows; // Number of rows in this type + // (0 if not a numeric primitive) + UINT Columns; // Number of columns in this type + // (0 if not a numeric primitive) + + UINT PackedSize; // Number of bytes required to represent + // this data type, when tightly packed + UINT UnpackedSize; // Number of bytes occupied by this data + // type, when laid out in a constant buffer + UINT Stride; // Number of bytes to seek between elements, + // when laid out in a constant buffer +} D3D10_EFFECT_TYPE_DESC; + +typedef interface ID3D10EffectType ID3D10EffectType; +typedef interface ID3D10EffectType *LPD3D10EFFECTTYPE; + +// {4E9E1DDC-CD9D-4772-A837-00180B9B88FD} +DEFINE_GUID(IID_ID3D10EffectType, +0x4e9e1ddc, 0xcd9d, 0x4772, 0xa8, 0x37, 0x0, 0x18, 0xb, 0x9b, 0x88, 0xfd); + +#undef INTERFACE +#define INTERFACE ID3D10EffectType + +DECLARE_INTERFACE(ID3D10EffectType) +{ + STDMETHOD_(BOOL, IsValid)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_TYPE_DESC *pDesc) PURE; + STDMETHOD_(ID3D10EffectType*, GetMemberTypeByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectType*, GetMemberTypeByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(ID3D10EffectType*, GetMemberTypeBySemantic)(THIS_ LPCSTR Semantic) PURE; + STDMETHOD_(LPCSTR, GetMemberName)(THIS_ UINT Index) PURE; + STDMETHOD_(LPCSTR, GetMemberSemantic)(THIS_ UINT Index) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectVariable ////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3D10_EFFECT_VARIABLE_DESC: +// +// Retrieved by ID3D10EffectVariable::GetDesc() +//---------------------------------------------------------------------------- + +typedef struct _D3D10_EFFECT_VARIABLE_DESC +{ + LPCSTR Name; // Name of this variable, annotation, + // or structure member + LPCSTR Semantic; // Semantic string of this variable + // or structure member (NULL for + // annotations or if not present) + + UINT Flags; // D3D10_EFFECT_VARIABLE_* flags + UINT Annotations; // Number of annotations on this variable + // (always 0 for annotations) + + UINT BufferOffset; // Offset into containing cbuffer or tbuffer + // (always 0 for annotations or variables + // not in constant buffers) +} D3D10_EFFECT_VARIABLE_DESC; + +typedef interface ID3D10EffectVariable ID3D10EffectVariable; +typedef interface ID3D10EffectVariable *LPD3D10EFFECTVARIABLE; + +// {AE897105-00E6-45bf-BB8E-281DD6DB8E1B} +DEFINE_GUID(IID_ID3D10EffectVariable, +0xae897105, 0xe6, 0x45bf, 0xbb, 0x8e, 0x28, 0x1d, 0xd6, 0xdb, 0x8e, 0x1b); + +#undef INTERFACE +#define INTERFACE ID3D10EffectVariable + +// Forward defines +typedef interface ID3D10EffectScalarVariable ID3D10EffectScalarVariable; +typedef interface ID3D10EffectVectorVariable ID3D10EffectVectorVariable; +typedef interface ID3D10EffectMatrixVariable ID3D10EffectMatrixVariable; +typedef interface ID3D10EffectStringVariable ID3D10EffectStringVariable; +typedef interface ID3D10EffectShaderResourceVariable ID3D10EffectShaderResourceVariable; +typedef interface ID3D10EffectConstantBuffer ID3D10EffectConstantBuffer; +typedef interface ID3D10EffectShaderVariable ID3D10EffectShaderVariable; +typedef interface ID3D10EffectBlendVariable ID3D10EffectBlendVariable; +typedef interface ID3D10EffectDepthStencilVariable ID3D10EffectDepthStencilVariable; +typedef interface ID3D10EffectRasterizerVariable ID3D10EffectRasterizerVariable; +typedef interface ID3D10EffectSamplerVariable ID3D10EffectSamplerVariable; + +DECLARE_INTERFACE(ID3D10EffectVariable) +{ + STDMETHOD_(BOOL, IsValid)(THIS) PURE; + STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; + + STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; + + STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; + STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; + STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; + STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; + STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; + STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; + STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; + STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; + STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; + + STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectScalarVariable //////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3D10EffectScalarVariable ID3D10EffectScalarVariable; +typedef interface ID3D10EffectScalarVariable *LPD3D10EFFECTSCALARVARIABLE; + +// {00E48F7B-D2C8-49e8-A86C-022DEE53431F} +DEFINE_GUID(IID_ID3D10EffectScalarVariable, +0xe48f7b, 0xd2c8, 0x49e8, 0xa8, 0x6c, 0x2, 0x2d, 0xee, 0x53, 0x43, 0x1f); + +#undef INTERFACE +#define INTERFACE ID3D10EffectScalarVariable + +DECLARE_INTERFACE_(ID3D10EffectScalarVariable, ID3D10EffectVariable) +{ + STDMETHOD_(BOOL, IsValid)(THIS) PURE; + STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; + + STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; + + STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; + STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; + STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; + STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; + STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; + STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; + STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; + STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; + STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; + + STDMETHOD(SetRawValue)(THIS_ void *pData, UINT ByteOffset, UINT ByteCount) PURE; + STDMETHOD(GetRawValue)(THIS_ void *pData, UINT ByteOffset, UINT ByteCount) PURE; + + STDMETHOD(SetFloat)(THIS_ float Value) PURE; + STDMETHOD(GetFloat)(THIS_ float *pValue) PURE; + + STDMETHOD(SetFloatArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetFloatArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; + + STDMETHOD(SetInt)(THIS_ int Value) PURE; + STDMETHOD(GetInt)(THIS_ int *pValue) PURE; + + STDMETHOD(SetIntArray)(THIS_ int *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetIntArray)(THIS_ int *pData, UINT Offset, UINT Count) PURE; + + STDMETHOD(SetBool)(THIS_ BOOL Value) PURE; + STDMETHOD(GetBool)(THIS_ BOOL *pValue) PURE; + + STDMETHOD(SetBoolArray)(THIS_ BOOL *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetBoolArray)(THIS_ BOOL *pData, UINT Offset, UINT Count) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectVectorVariable //////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3D10EffectVectorVariable ID3D10EffectVectorVariable; +typedef interface ID3D10EffectVectorVariable *LPD3D10EFFECTVECTORVARIABLE; + +// {62B98C44-1F82-4c67-BCD0-72CF8F217E81} +DEFINE_GUID(IID_ID3D10EffectVectorVariable, +0x62b98c44, 0x1f82, 0x4c67, 0xbc, 0xd0, 0x72, 0xcf, 0x8f, 0x21, 0x7e, 0x81); + +#undef INTERFACE +#define INTERFACE ID3D10EffectVectorVariable + +DECLARE_INTERFACE_(ID3D10EffectVectorVariable, ID3D10EffectVariable) +{ + STDMETHOD_(BOOL, IsValid)(THIS) PURE; + STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; + + STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; + + STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; + STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; + STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; + STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; + STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; + STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; + STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; + STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; + STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; + + STDMETHOD(SetRawValue)(THIS_ void *pData, UINT ByteOffset, UINT ByteCount) PURE; + STDMETHOD(GetRawValue)(THIS_ void *pData, UINT ByteOffset, UINT ByteCount) PURE; + + STDMETHOD(SetBoolVector) (THIS_ BOOL *pData) PURE; + STDMETHOD(SetIntVector) (THIS_ int *pData) PURE; + STDMETHOD(SetFloatVector)(THIS_ float *pData) PURE; + + STDMETHOD(GetBoolVector) (THIS_ BOOL *pData) PURE; + STDMETHOD(GetIntVector) (THIS_ int *pData) PURE; + STDMETHOD(GetFloatVector)(THIS_ float *pData) PURE; + + STDMETHOD(SetBoolVectorArray) (THIS_ BOOL *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(SetIntVectorArray) (THIS_ int *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(SetFloatVectorArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; + + STDMETHOD(GetBoolVectorArray) (THIS_ BOOL *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetIntVectorArray) (THIS_ int *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetFloatVectorArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectMatrixVariable //////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3D10EffectMatrixVariable ID3D10EffectMatrixVariable; +typedef interface ID3D10EffectMatrixVariable *LPD3D10EFFECTMATRIXVARIABLE; + +// {50666C24-B82F-4eed-A172-5B6E7E8522E0} +DEFINE_GUID(IID_ID3D10EffectMatrixVariable, +0x50666c24, 0xb82f, 0x4eed, 0xa1, 0x72, 0x5b, 0x6e, 0x7e, 0x85, 0x22, 0xe0); + +#undef INTERFACE +#define INTERFACE ID3D10EffectMatrixVariable + +DECLARE_INTERFACE_(ID3D10EffectMatrixVariable, ID3D10EffectVariable) +{ + STDMETHOD_(BOOL, IsValid)(THIS) PURE; + STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; + + STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; + + STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; + STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; + STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; + STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; + STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; + STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; + STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; + STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; + STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; + + STDMETHOD(SetRawValue)(THIS_ void *pData, UINT ByteOffset, UINT ByteCount) PURE; + STDMETHOD(GetRawValue)(THIS_ void *pData, UINT ByteOffset, UINT ByteCount) PURE; + + STDMETHOD(SetMatrix)(THIS_ float *pData) PURE; + STDMETHOD(GetMatrix)(THIS_ float *pData) PURE; + + STDMETHOD(SetMatrixArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetMatrixArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; + + STDMETHOD(SetMatrixTranspose)(THIS_ float *pData) PURE; + STDMETHOD(GetMatrixTranspose)(THIS_ float *pData) PURE; + + STDMETHOD(SetMatrixTransposeArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetMatrixTransposeArray)(THIS_ float *pData, UINT Offset, UINT Count) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectStringVariable //////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3D10EffectStringVariable ID3D10EffectStringVariable; +typedef interface ID3D10EffectStringVariable *LPD3D10EFFECTSTRINGVARIABLE; + +// {71417501-8DF9-4e0a-A78A-255F9756BAFF} +DEFINE_GUID(IID_ID3D10EffectStringVariable, +0x71417501, 0x8df9, 0x4e0a, 0xa7, 0x8a, 0x25, 0x5f, 0x97, 0x56, 0xba, 0xff); + +#undef INTERFACE +#define INTERFACE ID3D10EffectStringVariable + +DECLARE_INTERFACE_(ID3D10EffectStringVariable, ID3D10EffectVariable) +{ + STDMETHOD_(BOOL, IsValid)(THIS) PURE; + STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; + + STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; + + STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; + STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; + STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; + STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; + STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; + STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; + STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; + STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; + STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; + + STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + + STDMETHOD(GetString)(THIS_ LPCSTR *ppString) PURE; + STDMETHOD(GetStringArray)(THIS_ LPCSTR *ppStrings, UINT Offset, UINT Count) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectShaderResourceVariable //////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3D10EffectShaderResourceVariable ID3D10EffectShaderResourceVariable; +typedef interface ID3D10EffectShaderResourceVariable *LPD3D10EFFECTSHADERRESOURCEVARIABLE; + +// {C0A7157B-D872-4b1d-8073-EFC2ACD4B1FC} +DEFINE_GUID(IID_ID3D10EffectShaderResourceVariable, +0xc0a7157b, 0xd872, 0x4b1d, 0x80, 0x73, 0xef, 0xc2, 0xac, 0xd4, 0xb1, 0xfc); + + +#undef INTERFACE +#define INTERFACE ID3D10EffectShaderResourceVariable + +DECLARE_INTERFACE_(ID3D10EffectShaderResourceVariable, ID3D10EffectVariable) +{ + STDMETHOD_(BOOL, IsValid)(THIS) PURE; + STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; + + STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; + + STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; + STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; + STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; + STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; + STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; + STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; + STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; + STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; + STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; + + STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + + STDMETHOD(SetResource)(THIS_ ID3D10ShaderResourceView *pResource) PURE; + STDMETHOD(GetResource)(THIS_ ID3D10ShaderResourceView **ppResource) PURE; + + STDMETHOD(SetResourceArray)(THIS_ ID3D10ShaderResourceView **ppResources, UINT Offset, UINT Count) PURE; + STDMETHOD(GetResourceArray)(THIS_ ID3D10ShaderResourceView **ppResources, UINT Offset, UINT Count) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectConstantBuffer //////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3D10EffectConstantBuffer ID3D10EffectConstantBuffer; +typedef interface ID3D10EffectConstantBuffer *LPD3D10EFFECTCONSTANTBUFFER; + +// {56648F4D-CC8B-4444-A5AD-B5A3D76E91B3} +DEFINE_GUID(IID_ID3D10EffectConstantBuffer, +0x56648f4d, 0xcc8b, 0x4444, 0xa5, 0xad, 0xb5, 0xa3, 0xd7, 0x6e, 0x91, 0xb3); + +#undef INTERFACE +#define INTERFACE ID3D10EffectConstantBuffer + +DECLARE_INTERFACE_(ID3D10EffectConstantBuffer, ID3D10EffectVariable) +{ + STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; + + STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; + + STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; + STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; + STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; + STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; + STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; + STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; + STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; + STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; + STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; + + STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + + STDMETHOD(SetConstantBuffer)(THIS_ ID3D10Buffer *pConstantBuffer) PURE; + STDMETHOD(GetConstantBuffer)(THIS_ ID3D10Buffer **ppConstantBuffer) PURE; + + STDMETHOD(SetTextureBuffer)(THIS_ ID3D10ShaderResourceView *pTextureBuffer) PURE; + STDMETHOD(GetTextureBuffer)(THIS_ ID3D10ShaderResourceView **ppTextureBuffer) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectShaderVariable //////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3D10_EFFECT_SHADER_DESC: +// +// Retrieved by ID3D10EffectShaderVariable::GetShaderDesc() +//---------------------------------------------------------------------------- + +typedef struct _D3D10_EFFECT_SHADER_DESC +{ + CONST BYTE *pInputSignature; // Passed into CreateInputLayout, + // valid on VS and GS only + + BOOL IsInline; // Is this an anonymous shader variable + // resulting from an inline shader assignment? + + + // -- The following fields are not valid after Optimize() -- + CONST BYTE *pBytecode; // Shader bytecode + UINT BytecodeLength; + + LPCSTR SODecl; // Stream out declaration string (for GS with SO) + + UINT NumInputSignatureEntries; // Number of entries in the input signature + UINT NumOutputSignatureEntries; // Number of entries in the output signature +} D3D10_EFFECT_SHADER_DESC; + + +typedef interface ID3D10EffectShaderVariable ID3D10EffectShaderVariable; +typedef interface ID3D10EffectShaderVariable *LPD3D10EFFECTSHADERVARIABLE; + +// {80849279-C799-4797-8C33-0407A07D9E06} +DEFINE_GUID(IID_ID3D10EffectShaderVariable, +0x80849279, 0xc799, 0x4797, 0x8c, 0x33, 0x4, 0x7, 0xa0, 0x7d, 0x9e, 0x6); + +#undef INTERFACE +#define INTERFACE ID3D10EffectShaderVariable + +DECLARE_INTERFACE_(ID3D10EffectShaderVariable, ID3D10EffectVariable) +{ + STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; + + STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; + + STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; + STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; + STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; + STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; + STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; + STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; + STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; + STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; + STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; + + STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + + STDMETHOD(GetShaderDesc)(THIS_ UINT ShaderIndex, D3D10_EFFECT_SHADER_DESC *pDesc) PURE; + + STDMETHOD(GetVertexShader)(THIS_ UINT ShaderIndex, ID3D10VertexShader **ppVS) PURE; + STDMETHOD(GetGeometryShader)(THIS_ UINT ShaderIndex, ID3D10GeometryShader **ppGS) PURE; + STDMETHOD(GetPixelShader)(THIS_ UINT ShaderIndex, ID3D10PixelShader **ppPS) PURE; + + STDMETHOD(GetInputSignatureElementDesc)(THIS_ UINT ShaderIndex, UINT Element, D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE; + STDMETHOD(GetOutputSignatureElementDesc)(THIS_ UINT ShaderIndex, UINT Element, D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectBlendVariable ///////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3D10EffectBlendVariable ID3D10EffectBlendVariable; +typedef interface ID3D10EffectBlendVariable *LPD3D10EFFECTBLENDVARIABLE; + +// {1FCD2294-DF6D-4eae-86B3-0E9160CFB07B} +DEFINE_GUID(IID_ID3D10EffectBlendVariable, +0x1fcd2294, 0xdf6d, 0x4eae, 0x86, 0xb3, 0xe, 0x91, 0x60, 0xcf, 0xb0, 0x7b); + +#undef INTERFACE +#define INTERFACE ID3D10EffectBlendVariable + +DECLARE_INTERFACE_(ID3D10EffectBlendVariable, ID3D10EffectVariable) +{ + STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; + + STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; + + STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; + STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; + STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; + STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; + STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; + STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; + STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; + STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; + STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; + + STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + + STDMETHOD(GetBlendState)(THIS_ UINT Index, ID3D10BlendState **ppBlendState) PURE; + STDMETHOD(GetBackingStore)(THIS_ UINT Index, D3D10_BLEND_DESC *pBlendDesc) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectDepthStencilVariable ////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3D10EffectDepthStencilVariable ID3D10EffectDepthStencilVariable; +typedef interface ID3D10EffectDepthStencilVariable *LPD3D10EFFECTDEPTHSTENCILVARIABLE; + +// {AF482368-330A-46a5-9A5C-01C71AF24C8D} +DEFINE_GUID(IID_ID3D10EffectDepthStencilVariable, +0xaf482368, 0x330a, 0x46a5, 0x9a, 0x5c, 0x1, 0xc7, 0x1a, 0xf2, 0x4c, 0x8d); + +#undef INTERFACE +#define INTERFACE ID3D10EffectDepthStencilVariable + +DECLARE_INTERFACE_(ID3D10EffectDepthStencilVariable, ID3D10EffectVariable) +{ + STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; + + STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; + + STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; + STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; + STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; + STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; + STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; + STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; + STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; + STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; + STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; + + STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + + STDMETHOD(GetDepthStencilState)(THIS_ UINT Index, ID3D10DepthStencilState **ppDepthStencilState) PURE; + STDMETHOD(GetBackingStore)(THIS_ UINT Index, D3D10_DEPTH_STENCIL_DESC *pDepthStencilDesc) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectRasterizerVariable //////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3D10EffectRasterizerVariable ID3D10EffectRasterizerVariable; +typedef interface ID3D10EffectRasterizerVariable *LPD3D10EFFECTRASTERIZERVARIABLE; + +// {21AF9F0E-4D94-4ea9-9785-2CB76B8C0B34} +DEFINE_GUID(IID_ID3D10EffectRasterizerVariable, +0x21af9f0e, 0x4d94, 0x4ea9, 0x97, 0x85, 0x2c, 0xb7, 0x6b, 0x8c, 0xb, 0x34); + +#undef INTERFACE +#define INTERFACE ID3D10EffectRasterizerVariable + +DECLARE_INTERFACE_(ID3D10EffectRasterizerVariable, ID3D10EffectVariable) +{ + STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; + + STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; + + STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; + STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; + STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; + STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; + STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; + STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; + STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; + STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; + STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; + + STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + + STDMETHOD(GetRasterizerState)(THIS_ UINT Index, ID3D10RasterizerState **ppRasterizerState) PURE; + STDMETHOD(GetBackingStore)(THIS_ UINT Index, D3D10_RASTERIZER_DESC *pRasterizerDesc) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectSamplerVariable /////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3D10EffectSamplerVariable ID3D10EffectSamplerVariable; +typedef interface ID3D10EffectSamplerVariable *LPD3D10EFFECTSAMPLERVARIABLE; + +// {6530D5C7-07E9-4271-A418-E7CE4BD1E480} +DEFINE_GUID(IID_ID3D10EffectSamplerVariable, +0x6530d5c7, 0x7e9, 0x4271, 0xa4, 0x18, 0xe7, 0xce, 0x4b, 0xd1, 0xe4, 0x80); + +#undef INTERFACE +#define INTERFACE ID3D10EffectSamplerVariable + +DECLARE_INTERFACE_(ID3D10EffectSamplerVariable, ID3D10EffectVariable) +{ + STDMETHOD_(ID3D10EffectType*, GetType)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetMemberByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetMemberBySemantic)(THIS_ LPCSTR Semantic) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetElement)(THIS_ UINT Index) PURE; + + STDMETHOD_(ID3D10EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; + + STDMETHOD_(ID3D10EffectScalarVariable*, AsScalar)(THIS) PURE; + STDMETHOD_(ID3D10EffectVectorVariable*, AsVector)(THIS) PURE; + STDMETHOD_(ID3D10EffectMatrixVariable*, AsMatrix)(THIS) PURE; + STDMETHOD_(ID3D10EffectStringVariable*, AsString)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; + STDMETHOD_(ID3D10EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; + STDMETHOD_(ID3D10EffectShaderVariable*, AsShader)(THIS) PURE; + STDMETHOD_(ID3D10EffectBlendVariable*, AsBlend)(THIS) PURE; + STDMETHOD_(ID3D10EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; + STDMETHOD_(ID3D10EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; + STDMETHOD_(ID3D10EffectSamplerVariable*, AsSampler)(THIS) PURE; + + STDMETHOD(SetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + STDMETHOD(GetRawValue)(THIS_ void *pData, UINT Offset, UINT Count) PURE; + + STDMETHOD(GetSampler)(THIS_ UINT Index, ID3D10SamplerState **ppSampler) PURE; + STDMETHOD(GetBackingStore)(THIS_ UINT Index, D3D10_SAMPLER_DESC *pSamplerDesc) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectPass ////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3D10_PASS_DESC: +// +// Retrieved by ID3D10EffectPass::GetDesc() +//---------------------------------------------------------------------------- + +typedef struct _D3D10_PASS_DESC +{ + LPCSTR Name; // Name of this pass (NULL if not anonymous) + UINT Annotations; // Number of annotations on this pass + + BYTE *pIAInputSignature; // Signature from VS or GS (if there is no VS) + // or NULL if neither exists + + UINT StencilRef; // Specified in SetDepthStencilState() + UINT SampleMask; // Specified in SetBlendState() + FLOAT BlendFactor[4]; // Specified in SetBlendState() +} D3D10_PASS_DESC; + +//---------------------------------------------------------------------------- +// D3D10_PASS_SHADER_DESC: +// +// Retrieved by ID3D10EffectPass::Get**ShaderDesc() +//---------------------------------------------------------------------------- + +typedef struct _D3D10_PASS_SHADER_DESC +{ + ID3D10EffectShaderVariable *pShaderVariable; // The variable that this shader came from. + // If this is an inline shader assignment, + // the returned interface will be an + // anonymous shader variable, which is + // not retrievable any other way. It's + // name in the variable description will + // be "$Anonymous". + // If there is no assignment of this type in + // the pass block, pShaderVariable != NULL, + // but pShaderVariable->IsValid() == FALSE. + + UINT ShaderIndex; // The element of pShaderVariable (if an array) + // or 0 if not applicable +} D3D10_PASS_SHADER_DESC; + +typedef interface ID3D10EffectPass ID3D10EffectPass; +typedef interface ID3D10EffectPass *LPD3D10EFFECTPASS; + +// {5CFBEB89-1A06-46e0-B282-E3F9BFA36A54} +DEFINE_GUID(IID_ID3D10EffectPass, +0x5cfbeb89, 0x1a06, 0x46e0, 0xb2, 0x82, 0xe3, 0xf9, 0xbf, 0xa3, 0x6a, 0x54); + +#undef INTERFACE +#define INTERFACE ID3D10EffectPass + +DECLARE_INTERFACE(ID3D10EffectPass) +{ + STDMETHOD_(BOOL, IsValid)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_PASS_DESC *pDesc) PURE; + + STDMETHOD(GetVertexShaderDesc)(THIS_ D3D10_PASS_SHADER_DESC *pDesc) PURE; + STDMETHOD(GetGeometryShaderDesc)(THIS_ D3D10_PASS_SHADER_DESC *pDesc) PURE; + STDMETHOD(GetPixelShaderDesc)(THIS_ D3D10_PASS_SHADER_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD(Apply)(THIS_ UINT Flags) PURE; + + STDMETHOD(ComputeStateBlockMask)(THIS_ D3D10_STATE_BLOCK_MASK *pStateBlockMask) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectTechnique ///////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3D10_TECHNIQUE_DESC: +// +// Retrieved by ID3D10EffectTechnique::GetDesc() +//---------------------------------------------------------------------------- + +typedef struct _D3D10_TECHNIQUE_DESC +{ + LPCSTR Name; // Name of this technique (NULL if not anonymous) + UINT Passes; // Number of passes contained within + UINT Annotations; // Number of annotations on this technique +} D3D10_TECHNIQUE_DESC; + +typedef interface ID3D10EffectTechnique ID3D10EffectTechnique; +typedef interface ID3D10EffectTechnique *LPD3D10EFFECTTECHNIQUE; + +// {DB122CE8-D1C9-4292-B237-24ED3DE8B175} +DEFINE_GUID(IID_ID3D10EffectTechnique, +0xdb122ce8, 0xd1c9, 0x4292, 0xb2, 0x37, 0x24, 0xed, 0x3d, 0xe8, 0xb1, 0x75); + +#undef INTERFACE +#define INTERFACE ID3D10EffectTechnique + +DECLARE_INTERFACE(ID3D10EffectTechnique) +{ + STDMETHOD_(BOOL, IsValid)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D10_TECHNIQUE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD_(ID3D10EffectPass*, GetPassByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectPass*, GetPassByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD(ComputeStateBlockMask)(THIS_ D3D10_STATE_BLOCK_MASK *pStateBlockMask) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10Effect ////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3D10_EFFECT_DESC: +// +// Retrieved by ID3D10Effect::GetDesc() +//---------------------------------------------------------------------------- + +typedef struct _D3D10_EFFECT_DESC +{ + //TODO: do we need these? + //LPCSTR Creator; + //UINT Version; + + BOOL IsChildEffect; // TRUE if this is a child effect, + // FALSE if this is standalone or an effect pool. + + UINT ConstantBuffers; // Number of constant buffers in this effect, + // excluding the effect pool. + UINT SharedConstantBuffers; // Number of constant buffers shared in this + // effect's pool. + + UINT GlobalVariables; // Number of global variables in this effect, + // excluding the effect pool. + UINT SharedGlobalVariables; // Number of global variables shared in this + // effect's pool. + + UINT Techniques; // Number of techniques in this effect, + // excluding the effect pool. +} D3D10_EFFECT_DESC; + +typedef interface ID3D10Effect ID3D10Effect; +typedef interface ID3D10Effect *LPD3D10EFFECT; + +// {51B0CA8B-EC0B-4519-870D-8EE1CB5017C7} +DEFINE_GUID(IID_ID3D10Effect, +0x51b0ca8b, 0xec0b, 0x4519, 0x87, 0xd, 0x8e, 0xe1, 0xcb, 0x50, 0x17, 0xc7); + +#undef INTERFACE +#define INTERFACE ID3D10Effect + +DECLARE_INTERFACE_(ID3D10Effect, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + STDMETHOD_(BOOL, IsValid)(THIS) PURE; + STDMETHOD_(BOOL, IsPool)(THIS) PURE; + + // Managing D3D Device + STDMETHOD(GetDevice)(THIS_ ID3D10Device** ppDevice) PURE; + + // New Reflection APIs + STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10EffectConstantBuffer*, GetConstantBufferByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectConstantBuffer*, GetConstantBufferByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD_(ID3D10EffectVariable*, GetVariableByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetVariableByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(ID3D10EffectVariable*, GetVariableBySemantic)(THIS_ LPCSTR Semantic) PURE; + + STDMETHOD_(ID3D10EffectTechnique*, GetTechniqueByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10EffectTechnique*, GetTechniqueByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD(Optimize)(THIS) PURE; + STDMETHOD_(BOOL, IsOptimized)(THIS) PURE; + +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3D10EffectPool ////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3D10EffectPool ID3D10EffectPool; +typedef interface ID3D10EffectPool *LPD3D10EFFECTPOOL; + +// {9537AB04-3250-412e-8213-FCD2F8677933} +DEFINE_GUID(IID_ID3D10EffectPool, +0x9537ab04, 0x3250, 0x412e, 0x82, 0x13, 0xfc, 0xd2, 0xf8, 0x67, 0x79, 0x33); + +#undef INTERFACE +#define INTERFACE ID3D10EffectPool + +DECLARE_INTERFACE_(ID3D10EffectPool, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + STDMETHOD_(ID3D10Effect*, AsEffect)(THIS) PURE; + + // No public methods +}; + +////////////////////////////////////////////////////////////////////////////// +// APIs ////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +//---------------------------------------------------------------------------- +// D3D10CreateEffectFromXXXX: +// -------------------------- +// Creates an effect from a binary effect or file +// +// Parameters: +// +// [in] +// +// TODO: Unicode support +// TODO: Support for binary (and not just ASCII) +// +// pFileName +// Name of the ASCII (uncompiled) or binary (compiled) Effect file to load +// +// hModule +// Handle to the module containing the resource to compile from +// pResourceName +// Name of the resource within hModule to compile from +// +// pData +// Blob of effect data, either ASCII (uncompiled) or binary (compiled) +// DataLength +// Length of the data blob +// +// pDefines +// Optional NULL-terminated array of preprocessor macro definitions. +// pInclude +// Optional interface pointer to use for handling #include directives. +// If this parameter is NULL, #includes will be honored when compiling +// from file, and will error when compiling from resource or memory. +// HLSLFlags +// Compilation flags pertaining to shaders and data types, honored by +// the HLSL compiler +// FXFlags +// Compilation flags pertaining to Effect compilation, honored +// by the Effect compiler +// pDevice +// Pointer to the D3D10 device on which to create Effect resources +// pEffectPool +// Pointer to an Effect pool to share variables with or NULL +// +// [out] +// +// ppEffect +// Address of the newly created Effect interface +// ppEffectPool +// Address of the newly created Effect pool interface +// ppErrors +// If non-NULL, address of a buffer with error messages that occurred +// during parsing or compilation +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI D3D10CompileEffectFromMemory(void *pData, SIZE_T DataLength, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, + ID3D10Blob **ppCompiledEffect, ID3D10Blob **ppErrors); + +HRESULT WINAPI D3D10CreateEffectFromMemory(void *pData, SIZE_T DataLength, UINT FXFlags, ID3D10Device *pDevice, + ID3D10EffectPool *pEffectPool, ID3D10Effect **ppEffect); + +HRESULT WINAPI D3D10CreateEffectPoolFromMemory(void *pData, SIZE_T DataLength, UINT FXFlags, ID3D10Device *pDevice, + ID3D10EffectPool **ppEffectPool); + + +//---------------------------------------------------------------------------- +// D3D10DisassembleEffect: +// ----------------------- +// Takes an effect interface, and returns a buffer containing text assembly. +// +// Parameters: +// pEffect +// Pointer to the runtime effect interface. +// EnableColorCode +// Emit HTML tags for color coding the output? +// ppDisassembly +// Returns a buffer containing the disassembled effect. +//---------------------------------------------------------------------------- + +HRESULT WINAPI D3D10DisassembleEffect(ID3D10Effect *pEffect, BOOL EnableColorCode, ID3D10Blob **ppDisassembly); + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3D10EFFECT_H__ + + diff --git a/src/dep/include/DXSDK/include/D3D10shader.h b/src/dep/include/DXSDK/include/D3D10shader.h index a3c8e53..37ebd44 100644 --- a/src/dep/include/DXSDK/include/D3D10shader.h +++ b/src/dep/include/DXSDK/include/D3D10shader.h @@ -1,640 +1,640 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// File: D3D10Shader.h -// Content: D3D10 Shader Types and APIs -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef __D3D10SHADER_H__ -#define __D3D10SHADER_H__ - -#include "d3d10.h" - -//--------------------------------------------------------------------------- -// D3D10_TX_VERSION: -// -------------- -// Version token used to create a procedural texture filler in effects -// Used by D3D10Fill[]TX functions -//--------------------------------------------------------------------------- -#define D3D10_TX_VERSION(_Major,_Minor) (('T' << 24) | ('X' << 16) | ((_Major) << 8) | (_Minor)) - - -//---------------------------------------------------------------------------- -// D3D10SHADER flags: -// ----------------- -// D3D10_SHADER_DEBUG -// Insert debug file/line/type/symbol information. -// -// D3D10_SHADER_SKIP_VALIDATION -// Do not validate the generated code against known capabilities and -// constraints. This option is only recommended when compiling shaders -// you KNOW will work. (ie. have compiled before without this option.) -// Shaders are always validated by D3D before they are set to the device. -// -// D3D10_SHADER_SKIP_OPTIMIZATION -// Instructs the compiler to skip optimization steps during code generation. -// Unless you are trying to isolate a problem in your code using this option -// is not recommended. -// -// D3D10_SHADER_PACK_MATRIX_ROW_MAJOR -// Unless explicitly specified, matrices will be packed in row-major order -// on input and output from the shader. -// -// D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR -// Unless explicitly specified, matrices will be packed in column-major -// order on input and output from the shader. This is generally more -// efficient, since it allows vector-matrix multiplication to be performed -// using a series of dot-products. -// -// D3D10_SHADER_PARTIAL_PRECISION -// Force all computations in resulting shader to occur at partial precision. -// This may result in faster evaluation of shaders on some hardware. -// -// D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT -// Force compiler to compile against the next highest available software -// target for vertex shaders. This flag also turns optimizations off, -// and debugging on. -// -// D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT -// Force compiler to compile against the next highest available software -// target for pixel shaders. This flag also turns optimizations off, -// and debugging on. -// -// D3D10_SHADER_NO_PRESHADER -// Disables Preshaders. Using this flag will cause the compiler to not -// pull out static expression for evaluation on the host cpu -// -// D3D10_SHADER_AVOID_FLOW_CONTROL -// Hint compiler to avoid flow-control constructs where possible. -// -// D3D10_SHADER_PREFER_FLOW_CONTROL -// Hint compiler to prefer flow-control constructs where possible. -// -// D3D10_SHADER_ENABLE_STRICTNESS -// By default, the HLSL/Effect compilers are not strict on deprecated syntax. -// Specifying this flag enables the strict mode. Deprecated syntax may be -// removed in a future release, and enabling syntax is a good way to make sure -// your shaders comply to the latest spec. -// -// D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY -// This enables older shaders to compile to 4_0 targets. -// -//---------------------------------------------------------------------------- - -#define D3D10_SHADER_DEBUG (1 << 0) -#define D3D10_SHADER_SKIP_VALIDATION (1 << 1) -#define D3D10_SHADER_SKIP_OPTIMIZATION (1 << 2) -#define D3D10_SHADER_PACK_MATRIX_ROW_MAJOR (1 << 3) -#define D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR (1 << 4) -#define D3D10_SHADER_PARTIAL_PRECISION (1 << 5) -#define D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT (1 << 6) -#define D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT (1 << 7) -#define D3D10_SHADER_NO_PRESHADER (1 << 8) -#define D3D10_SHADER_AVOID_FLOW_CONTROL (1 << 9) -#define D3D10_SHADER_PREFER_FLOW_CONTROL (1 << 10) -#define D3D10_SHADER_ENABLE_STRICTNESS (1 << 11) -#define D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY (1 << 12) - - - -//---------------------------------------------------------------------------- -// D3D10_SHADER_MACRO: -// ---------- -// Preprocessor macro definition. The application pass in a NULL-terminated -// array of this structure to various D3D10 APIs. This enables the application -// to #define tokens at runtime, before the file is parsed. -//---------------------------------------------------------------------------- - -typedef struct _D3D10_SHADER_MACRO -{ - LPCSTR Name; - LPCSTR Definition; - -} D3D10_SHADER_MACRO, *LPD3D10_SHADER_MACRO; - - -//---------------------------------------------------------------------------- -// D3D10_SHADER_VARIABLE_CLASS: -//---------------------------------------------------------------------------- - -typedef enum _D3D10_SHADER_VARIABLE_CLASS -{ - D3D10_SVC_SCALAR, - D3D10_SVC_VECTOR, - D3D10_SVC_MATRIX_ROWS, - D3D10_SVC_MATRIX_COLUMNS, - D3D10_SVC_OBJECT, - D3D10_SVC_STRUCT, - - // force 32-bit size enum - D3D10_SVC_FORCE_DWORD = 0x7fffffff - -} D3D10_SHADER_VARIABLE_CLASS, *LPD3D10_SHADER_VARIABLE_CLASS; - -//---------------------------------------------------------------------------- -// D3D10_SHADER_VARIABLE_TYPE: -//---------------------------------------------------------------------------- - -typedef enum _D3D10_SHADER_VARIABLE_TYPE -{ - D3D10_SVT_VOID = 0, - D3D10_SVT_BOOL = 1, - D3D10_SVT_INT = 2, - D3D10_SVT_FLOAT = 3, - D3D10_SVT_STRING = 4, - D3D10_SVT_TEXTURE = 5, - D3D10_SVT_TEXTURE1D = 6, - D3D10_SVT_TEXTURE2D = 7, - D3D10_SVT_TEXTURE3D = 8, - D3D10_SVT_TEXTURECUBE = 9, - D3D10_SVT_SAMPLER = 10, - D3D10_SVT_PIXELSHADER = 15, - D3D10_SVT_VERTEXSHADER = 16, - D3D10_SVT_UINT = 19, - D3D10_SVT_UINT8 = 20, - D3D10_SVT_GEOMETRYSHADER = 21, - D3D10_SVT_RASTERIZER = 22, - D3D10_SVT_DEPTHSTENCIL = 23, - D3D10_SVT_BLEND = 24, - D3D10_SVT_BUFFER = 25, - D3D10_SVT_CBUFFER = 26, - D3D10_SVT_TBUFFER = 27, - D3D10_SVT_TEXTURE1DARRAY = 28, - D3D10_SVT_TEXTURE2DARRAY = 29, - - // force 32-bit size enum - D3D10_SVT_FORCE_DWORD = 0x7fffffff - -} D3D10_SHADER_VARIABLE_TYPE, *LPD3D10_SHADER_VARIABLE_TYPE; - -//---------------------------------------------------------------------------- -// D3D10_SHADER_INPUT_TYPE -//---------------------------------------------------------------------------- - -typedef enum _D3D10_SHADER_INPUT_TYPE -{ - D3D10_SIT_CBUFFER, - D3D10_SIT_TBUFFER, - D3D10_SIT_TEXTURE, - D3D10_SIT_SAMPLER, -} D3D10_SHADER_INPUT_TYPE, *LPD3D10_SHADER_INPUT_TYPE; - -typedef enum _D3D10_CBUFFER_TYPE -{ - D3D10_CT_CBUFFER, - D3D10_CT_TBUFFER, -} D3D10_CBUFFER_TYPE, *LPD3D10_CBUFFER_TYPE; - -typedef enum D3D10_NAME -{ - D3D10_NAME_UNDEFINED = 0, - D3D10_NAME_POSITION = 1, - D3D10_NAME_CLIP_DISTANCE = 2, - D3D10_NAME_CULL_DISTANCE = 3, - D3D10_NAME_RENDER_TARGET_ARRAY_INDEX = 4, - D3D10_NAME_VIEWPORT_ARRAY_INDEX = 5, - D3D10_NAME_VERTEX_ID = 6, - D3D10_NAME_PRIMITIVE_ID = 7, - D3D10_NAME_INSTANCE_ID = 8, - D3D10_NAME_IS_FRONT_FACE = 9 -} D3D10_NAME; - -typedef enum D3D10_RESOURCE_DIMENSION -{ - D3D10_RESOURCE_DIMENSION_UNKNOWN = 0, - D3D10_RESOURCE_DIMENSION_BUFFER = 1, - D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2, - D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3, - D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4, - D3D10_RESOURCE_DIMENSION_TEXTURECUBE = 5, - D3D10_RESOURCE_DIMENSION_TEXTURE1DARRAY = 6, - D3D10_RESOURCE_DIMENSION_TEXTURE2DARRAY = 7, -} D3D10_RESOURCE_DIMENSION; - -typedef enum D3D10_RESOURCE_RETURN_TYPE -{ - D3D10_RETURN_TYPE_UNORM = 1, - D3D10_RETURN_TYPE_SNORM = 2, - D3D10_RETURN_TYPE_SINT = 3, - D3D10_RETURN_TYPE_UINT = 4, - D3D10_RETURN_TYPE_FLOAT = 5, - D3D10_RETURN_TYPE_MIXED = 6, -} D3D10_RESOURCE_RETURN_TYPE; - -typedef enum D3D10_REGISTER_COMPONENT_TYPE -{ - D3D10_REGISTER_COMPONENT_UNKNOWN = 0, - D3D10_REGISTER_COMPONENT_UINT32 = 1, - D3D10_REGISTER_COMPONENT_SINT32 = 2, - D3D10_REGISTER_COMPONENT_FLOAT32 = 3 -} D3D10_REGISTER_COMPONENT_TYPE; - - -//---------------------------------------------------------------------------- -// D3D10_INCLUDE_TYPE: -//---------------------------------------------------------------------------- - -typedef enum _D3D10_INCLUDE_TYPE -{ - D3D10_INCLUDE_LOCAL, - D3D10_INCLUDE_SYSTEM, - - // force 32-bit size enum - D3D10_INCLUDE_FORCE_DWORD = 0x7fffffff - -} D3D10_INCLUDE_TYPE, *LPD3D10_INCLUDE_TYPE; - - -//---------------------------------------------------------------------------- -// ID3D10Include: -// ------------- -// This interface is intended to be implemented by the application, and can -// be used by various D3D10 APIs. This enables application-specific handling -// of #include directives in source files. -// -// Open() -// Opens an include file. If successful, it should fill in ppData and -// pBytes. The data pointer returned must remain valid until Close is -// subsequently called. -// Close() -// Closes an include file. If Open was successful, Close is guaranteed -// to be called before the API using this interface returns. -//---------------------------------------------------------------------------- - -typedef interface ID3D10Include ID3D10Include; -typedef interface ID3D10Include *LPD3D10INCLUDE; - -#undef INTERFACE -#define INTERFACE ID3D10Include - -DECLARE_INTERFACE(ID3D10Include) -{ - STDMETHOD(Open)(THIS_ D3D10_INCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes) PURE; - STDMETHOD(Close)(THIS_ LPCVOID pData) PURE; -}; - - -//---------------------------------------------------------------------------- -// ID3D10ShaderReflection: -//---------------------------------------------------------------------------- - -// -// Structure definitions -// - -typedef struct _D3D10_SHADER_DESC -{ - UINT Version; // Shader version - LPCSTR Creator; // Creator string - UINT Flags; // Shader compilation/parse flags - - UINT ConstantBuffers; // Number of constant buffers - UINT BoundResources; // Number of bound resources - UINT InputParameters; // Number of parameters in the input signature - UINT OutputParameters; // Number of parameters in the output signature -} D3D10_SHADER_DESC; - -typedef struct _D3D10_SHADER_BUFFER_DESC -{ - LPCSTR Name; // Name of the constant buffer - D3D10_CBUFFER_TYPE Type; // Indicates that this is a CBuffer or TBuffer - UINT Variables; // Number of member variables - UINT Size; // Size of CB (in bytes) -} D3D10_SHADER_BUFFER_DESC; - -typedef struct _D3D10_SHADER_VARIABLE_DESC -{ - LPCSTR Name; // Name of the variable - UINT StartOffset; // Offset in constant buffer's backing store - UINT Size; // Size of variable (in bytes) - LPVOID DefaultValue; // Raw pointer to default value -} D3D10_SHADER_VARIABLE_DESC; - -typedef struct _D3D10_SHADER_TYPE_DESC -{ - D3D10_SHADER_VARIABLE_CLASS Class; // Variable class (e.g. object, matrix, etc.) - D3D10_SHADER_VARIABLE_TYPE Type; // Variable type (e.g. float, sampler, etc.) - UINT Rows; // Number of rows (for matrices, 1 for other numeric, 0 if not applicable) - UINT Columns; // Number of columns (for vectors & matrices, 1 for other numeric, 0 if not applicable) - UINT Elements; // Number of elements (0 if not an array) - UINT Members; // Number of members (0 if not a structure) -} D3D10_SHADER_TYPE_DESC; - -typedef struct _D3D10_SHADER_INPUT_BIND_DESC -{ - LPCSTR Name; // Name of the resource - D3D10_SHADER_INPUT_TYPE Type; // Type of resource (e.g. texture, cbuffer, etc.) - UINT BindPoint; // Starting bind point - UINT BindCount; // Number of contiguous bind points (for arrays) - - D3D10_RESOURCE_RETURN_TYPE ReturnType; // Return type (if texture) - D3D10_RESOURCE_DIMENSION Dimension; // Dimension (if texture) -} D3D10_SHADER_INPUT_BIND_DESC; - -typedef struct _D3D10_SIGNATURE_PARAMETER_DESC -{ - LPCSTR SemanticName; // Name of the semantic - UINT SemanticIndex; // Index of the semantic - UINT Register; // Number of member variables - D3D10_NAME SystemValueType;// A predefined system value, or D3D10_NAME_UNDEFINED if not applicable - D3D10_REGISTER_COMPONENT_TYPE ComponentType;// Scalar type (e.g. uint, float, etc.) - BYTE Mask; // Mask to indicate which components of the register - // are used (combination of D3D10_COMPONENT_MASK values) - BYTE ReadWriteMask; // Mask to indicate whether a given component is - // never written (if this is an output signature) or - // always read (if this is an input signature). - // (combination of D3D10_COMPONENT_MASK values) - -} D3D10_SIGNATURE_PARAMETER_DESC; - -// -// Interface definitions -// - -typedef interface ID3D10ShaderReflectionType ID3D10ShaderReflectionType; -typedef interface ID3D10ShaderReflectionType *LPD3D10SHADERREFLECTIONTYPE; - -// {C530AD7D-9B16-4395-A979-BA2ECFF83ADD} -DEFINE_GUID(IID_ID3D10ShaderReflectionType, -0xc530ad7d, 0x9b16, 0x4395, 0xa9, 0x79, 0xba, 0x2e, 0xcf, 0xf8, 0x3a, 0xdd); - -#undef INTERFACE -#define INTERFACE ID3D10ShaderReflectionType - -DECLARE_INTERFACE(ID3D10ShaderReflectionType) -{ - STDMETHOD(GetDesc)(THIS_ D3D10_SHADER_TYPE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10ShaderReflectionType*, GetMemberTypeByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10ShaderReflectionType*, GetMemberTypeByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD_(LPCSTR, GetMemberTypeName)(THIS_ UINT Index) PURE; -}; - -typedef interface ID3D10ShaderReflectionVariable ID3D10ShaderReflectionVariable; -typedef interface ID3D10ShaderReflectionVariable *LPD3D10SHADERREFLECTIONVARIABLE; - -// {1BF63C95-2650-405d-99C1-3636BD1DA0A1} -DEFINE_GUID(IID_ID3D10ShaderReflectionVariable, -0x1bf63c95, 0x2650, 0x405d, 0x99, 0xc1, 0x36, 0x36, 0xbd, 0x1d, 0xa0, 0xa1); - -#undef INTERFACE -#define INTERFACE ID3D10ShaderReflectionVariable - -DECLARE_INTERFACE(ID3D10ShaderReflectionVariable) -{ - STDMETHOD(GetDesc)(THIS_ D3D10_SHADER_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10ShaderReflectionType*, GetType)(THIS) PURE; -}; - -typedef interface ID3D10ShaderReflectionConstantBuffer ID3D10ShaderReflectionConstantBuffer; -typedef interface ID3D10ShaderReflectionConstantBuffer *LPD3D10SHADERREFLECTIONCONSTANTBUFFER; - -// {66C66A94-DDDD-4b62-A66A-F0DA33C2B4D0} -DEFINE_GUID(IID_ID3D10ShaderReflectionConstantBuffer, -0x66c66a94, 0xdddd, 0x4b62, 0xa6, 0x6a, 0xf0, 0xda, 0x33, 0xc2, 0xb4, 0xd0); - -#undef INTERFACE -#define INTERFACE ID3D10ShaderReflectionConstantBuffer - -DECLARE_INTERFACE(ID3D10ShaderReflectionConstantBuffer) -{ - STDMETHOD(GetDesc)(THIS_ D3D10_SHADER_BUFFER_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10ShaderReflectionVariable*, GetVariableByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10ShaderReflectionVariable*, GetVariableByName)(THIS_ LPCSTR Name) PURE; -}; - -typedef interface ID3D10ShaderReflection ID3D10ShaderReflection; -typedef interface ID3D10ShaderReflection *LPD3D10SHADERREFLECTION; - -// {D40E20B6-F8F7-42ad-AB20-4BAF8F15DFAA} -DEFINE_GUID(IID_ID3D10ShaderReflection, -0xd40e20b6, 0xf8f7, 0x42ad, 0xab, 0x20, 0x4b, 0xaf, 0x8f, 0x15, 0xdf, 0xaa); - -#undef INTERFACE -#define INTERFACE ID3D10ShaderReflection - -DECLARE_INTERFACE_(ID3D10ShaderReflection, IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - STDMETHOD(GetDesc)(THIS_ D3D10_SHADER_DESC *pDesc) PURE; - - STDMETHOD_(ID3D10ShaderReflectionConstantBuffer*, GetConstantBufferByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(ID3D10ShaderReflectionConstantBuffer*, GetConstantBufferByName)(THIS_ LPCSTR Name) PURE; - - STDMETHOD(GetResourceBindingDesc)(THIS_ UINT ResourceIndex, D3D10_SHADER_INPUT_BIND_DESC *pDesc) PURE; - - STDMETHOD(GetInputParameterDesc)(THIS_ UINT ParameterIndex, D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE; - STDMETHOD(GetOutputParameterDesc)(THIS_ UINT ParameterIndex, D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE; - -}; - -////////////////////////////////////////////////////////////////////////////// -// APIs ////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -//---------------------------------------------------------------------------- -// D3D10CompileShader: -// ------------------ -// Compiles a shader. -// -// Parameters: -// pSrcFile -// Source file name. -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module. -// pSrcData -// Pointer to source code. -// SrcDataLen -// Size of source code, in bytes. -// pDefines -// Optional NULL-terminated array of preprocessor macro definitions. -// pInclude -// Optional interface pointer to use for handling #include directives. -// If this parameter is NULL, #includes will be honored when compiling -// from file, and will error when compiling from resource or memory. -// pFunctionName -// Name of the entrypoint function where execution should begin. -// pProfile -// Instruction set to be used when generating code. The D3D10 entry -// point currently supports only "vs_4_0", "ps_4_0", and "gs_4_0". -// Flags -// See D3D10_SHADER_xxx flags. -// ppShader -// Returns a buffer containing the created shader. This buffer contains -// the compiled shader code, as well as any embedded debug and symbol -// table info. (See D3D10GetShaderConstantTable) -// ppErrorMsgs -// Returns a buffer containing a listing of errors and warnings that were -// encountered during the compile. If you are running in a debugger, -// these are the same messages you will see in your debug output. -//---------------------------------------------------------------------------- - -HRESULT WINAPI D3D10CompileShader(LPCSTR pSrcData, SIZE_T SrcDataLen, LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, - LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs); - -//---------------------------------------------------------------------------- -// D3D10DisassembleShader: -// ---------------------- -// Takes a binary shader, and returns a buffer containing text assembly. -// -// Parameters: -// pShader -// Pointer to the shader byte code. -// ShaderSizeInBytes -// Size of the shader byte code in bytes. -// EnableColorCode -// Emit HTML tags for color coding the output? -// pComments -// Pointer to a comment string to include at the top of the shader. -// ppDisassembly -// Returns a buffer containing the disassembled shader. -//---------------------------------------------------------------------------- - -HRESULT WINAPI D3D10DisassembleShader(CONST UINT *pShader, BOOL EnableColorCode, LPCSTR pComments, ID3D10Blob** ppDisassembly); - -//---------------------------------------------------------------------------- -// D3D10GetShaderSize: -// ------------------ -// Returns the size of the shader blob container, in bytes. -// -// Parameters: -// pFunction -// Pointer to the function UINT stream -//---------------------------------------------------------------------------- - -UINT WINAPI D3D10GetShaderSize(CONST UINT *pFunction); - -//---------------------------------------------------------------------------- -// D3D10GetShaderVersion: -// ----------------------- -// Returns the shader version of a given shader. Returns zero if the shader -// function is NULL. -// -// Parameters: -// pFunction -// Pointer to the function UINT stream -//---------------------------------------------------------------------------- - -UINT WINAPI D3D10GetShaderVersion(CONST UINT *pFunction); - - -//---------------------------------------------------------------------------- -// D3D10GetPixelShaderProfile/D3D10GetVertexShaderProfile/D3D10GetGeometryShaderProfile: -// ----------------------------------------------------- -// Returns the name of the HLSL profile best suited to a given device. -// -// Parameters: -// pDevice -// Pointer to the device in question -//---------------------------------------------------------------------------- - -LPCSTR WINAPI D3D10GetPixelShaderProfile(ID3D10Device *pDevice); - -LPCSTR WINAPI D3D10GetVertexShaderProfile(ID3D10Device *pDevice); - -LPCSTR WINAPI D3D10GetGeometryShaderProfile(ID3D10Device *pDevice); - -//---------------------------------------------------------------------------- -// D3D10ReflectShader: -// ------------------ -// Creates a shader reflection object that can be used to retrieve information -// about a compiled shader -// -// Parameters: -// pShaderBytecode -// Pointer to a compiled shader (same pointer that is passed into -// ID3D10Device::CreateShader) -// BytecodeLength -// Length of the shader bytecode buffer -// ppReflector -// [out] Returns a ID3D10ShaderReflection object that can be used to -// retrieve shader resource and constant buffer information -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI D3D10ReflectShader(void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10ShaderReflection **ppReflector); - -//---------------------------------------------------------------------------- -// D3D10PreprocessShader -// --------------------- -// Creates a shader reflection object that can be used to retrieve information -// about a compiled shader -// -// Parameters: -// pSrcData -// Pointer to source code -// SrcDataLen -// Size of source code, in bytes -// pFileName -// Source file name (used for error output) -// pDefines -// Optional NULL-terminated array of preprocessor macro definitions. -// pInclude -// Optional interface pointer to use for handling #include directives. -// If this parameter is NULL, #includes will be honored when assembling -// from file, and will error when assembling from resource or memory. -// ppShaderText -// Returns a buffer containing a single large string that represents -// the resulting formatted token stream -// ppErrorMsgs -// Returns a buffer containing a listing of errors and warnings that were -// encountered during assembly. If you are running in a debugger, -// these are the same messages you will see in your debug output. -//---------------------------------------------------------------------------- - -HRESULT WINAPI D3D10PreprocessShader(LPCSTR pSrcData, SIZE_T SrcDataSize, LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, - LPD3D10INCLUDE pInclude, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs); - -////////////////////////////////////////////////////////////////////////// -// -// Shader blob manipulation routines -// --------------------------------- -// -// void *pShaderBytecode - a buffer containing the result of an HLSL -// compilation. Typically this opaque buffer contains several -// discrete sections including the shader executable code, the input -// signature, and the output signature. This can typically be retrieved -// by calling ID3D10Blob::GetBufferPointer() on the returned blob -// from HLSL's compile APIs. -// -// UINT BytecodeLength - the length of pShaderBytecode. This can -// typically be retrieved by calling ID3D10Blob::GetBufferSize() -// on the returned blob from HLSL's compile APIs. -// -// ID3D10Blob **ppSignatureBlob(s) - a newly created buffer that -// contains only the signature portions of the original bytecode. -// This is a copy; the original bytecode is not modified. You may -// specify NULL for this parameter to have the bytecode validated -// for the presence of the corresponding signatures without actually -// copying them and creating a new blob. -// -// Returns E_INVALIDARG if any required parameters are NULL -// Returns E_FAIL is the bytecode is corrupt or missing signatures -// Returns S_OK on success -// -////////////////////////////////////////////////////////////////////////// - -HRESULT D3D10GetInputSignatureBlob(void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob **ppSignatureBlob); -HRESULT D3D10GetOutputSignatureBlob(void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob **ppSignatureBlob); -HRESULT D3D10GetInputAndOutputSignatureBlob(void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob **ppSignatureBlob); - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3D10SHADER_H__ - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// File: D3D10Shader.h +// Content: D3D10 Shader Types and APIs +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef __D3D10SHADER_H__ +#define __D3D10SHADER_H__ + +#include "d3d10.h" + +//--------------------------------------------------------------------------- +// D3D10_TX_VERSION: +// -------------- +// Version token used to create a procedural texture filler in effects +// Used by D3D10Fill[]TX functions +//--------------------------------------------------------------------------- +#define D3D10_TX_VERSION(_Major,_Minor) (('T' << 24) | ('X' << 16) | ((_Major) << 8) | (_Minor)) + + +//---------------------------------------------------------------------------- +// D3D10SHADER flags: +// ----------------- +// D3D10_SHADER_DEBUG +// Insert debug file/line/type/symbol information. +// +// D3D10_SHADER_SKIP_VALIDATION +// Do not validate the generated code against known capabilities and +// constraints. This option is only recommended when compiling shaders +// you KNOW will work. (ie. have compiled before without this option.) +// Shaders are always validated by D3D before they are set to the device. +// +// D3D10_SHADER_SKIP_OPTIMIZATION +// Instructs the compiler to skip optimization steps during code generation. +// Unless you are trying to isolate a problem in your code using this option +// is not recommended. +// +// D3D10_SHADER_PACK_MATRIX_ROW_MAJOR +// Unless explicitly specified, matrices will be packed in row-major order +// on input and output from the shader. +// +// D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR +// Unless explicitly specified, matrices will be packed in column-major +// order on input and output from the shader. This is generally more +// efficient, since it allows vector-matrix multiplication to be performed +// using a series of dot-products. +// +// D3D10_SHADER_PARTIAL_PRECISION +// Force all computations in resulting shader to occur at partial precision. +// This may result in faster evaluation of shaders on some hardware. +// +// D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT +// Force compiler to compile against the next highest available software +// target for vertex shaders. This flag also turns optimizations off, +// and debugging on. +// +// D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT +// Force compiler to compile against the next highest available software +// target for pixel shaders. This flag also turns optimizations off, +// and debugging on. +// +// D3D10_SHADER_NO_PRESHADER +// Disables Preshaders. Using this flag will cause the compiler to not +// pull out static expression for evaluation on the host cpu +// +// D3D10_SHADER_AVOID_FLOW_CONTROL +// Hint compiler to avoid flow-control constructs where possible. +// +// D3D10_SHADER_PREFER_FLOW_CONTROL +// Hint compiler to prefer flow-control constructs where possible. +// +// D3D10_SHADER_ENABLE_STRICTNESS +// By default, the HLSL/Effect compilers are not strict on deprecated syntax. +// Specifying this flag enables the strict mode. Deprecated syntax may be +// removed in a future release, and enabling syntax is a good way to make sure +// your shaders comply to the latest spec. +// +// D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY +// This enables older shaders to compile to 4_0 targets. +// +//---------------------------------------------------------------------------- + +#define D3D10_SHADER_DEBUG (1 << 0) +#define D3D10_SHADER_SKIP_VALIDATION (1 << 1) +#define D3D10_SHADER_SKIP_OPTIMIZATION (1 << 2) +#define D3D10_SHADER_PACK_MATRIX_ROW_MAJOR (1 << 3) +#define D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR (1 << 4) +#define D3D10_SHADER_PARTIAL_PRECISION (1 << 5) +#define D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT (1 << 6) +#define D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT (1 << 7) +#define D3D10_SHADER_NO_PRESHADER (1 << 8) +#define D3D10_SHADER_AVOID_FLOW_CONTROL (1 << 9) +#define D3D10_SHADER_PREFER_FLOW_CONTROL (1 << 10) +#define D3D10_SHADER_ENABLE_STRICTNESS (1 << 11) +#define D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY (1 << 12) + + + +//---------------------------------------------------------------------------- +// D3D10_SHADER_MACRO: +// ---------- +// Preprocessor macro definition. The application pass in a NULL-terminated +// array of this structure to various D3D10 APIs. This enables the application +// to #define tokens at runtime, before the file is parsed. +//---------------------------------------------------------------------------- + +typedef struct _D3D10_SHADER_MACRO +{ + LPCSTR Name; + LPCSTR Definition; + +} D3D10_SHADER_MACRO, *LPD3D10_SHADER_MACRO; + + +//---------------------------------------------------------------------------- +// D3D10_SHADER_VARIABLE_CLASS: +//---------------------------------------------------------------------------- + +typedef enum _D3D10_SHADER_VARIABLE_CLASS +{ + D3D10_SVC_SCALAR, + D3D10_SVC_VECTOR, + D3D10_SVC_MATRIX_ROWS, + D3D10_SVC_MATRIX_COLUMNS, + D3D10_SVC_OBJECT, + D3D10_SVC_STRUCT, + + // force 32-bit size enum + D3D10_SVC_FORCE_DWORD = 0x7fffffff + +} D3D10_SHADER_VARIABLE_CLASS, *LPD3D10_SHADER_VARIABLE_CLASS; + +//---------------------------------------------------------------------------- +// D3D10_SHADER_VARIABLE_TYPE: +//---------------------------------------------------------------------------- + +typedef enum _D3D10_SHADER_VARIABLE_TYPE +{ + D3D10_SVT_VOID = 0, + D3D10_SVT_BOOL = 1, + D3D10_SVT_INT = 2, + D3D10_SVT_FLOAT = 3, + D3D10_SVT_STRING = 4, + D3D10_SVT_TEXTURE = 5, + D3D10_SVT_TEXTURE1D = 6, + D3D10_SVT_TEXTURE2D = 7, + D3D10_SVT_TEXTURE3D = 8, + D3D10_SVT_TEXTURECUBE = 9, + D3D10_SVT_SAMPLER = 10, + D3D10_SVT_PIXELSHADER = 15, + D3D10_SVT_VERTEXSHADER = 16, + D3D10_SVT_UINT = 19, + D3D10_SVT_UINT8 = 20, + D3D10_SVT_GEOMETRYSHADER = 21, + D3D10_SVT_RASTERIZER = 22, + D3D10_SVT_DEPTHSTENCIL = 23, + D3D10_SVT_BLEND = 24, + D3D10_SVT_BUFFER = 25, + D3D10_SVT_CBUFFER = 26, + D3D10_SVT_TBUFFER = 27, + D3D10_SVT_TEXTURE1DARRAY = 28, + D3D10_SVT_TEXTURE2DARRAY = 29, + + // force 32-bit size enum + D3D10_SVT_FORCE_DWORD = 0x7fffffff + +} D3D10_SHADER_VARIABLE_TYPE, *LPD3D10_SHADER_VARIABLE_TYPE; + +//---------------------------------------------------------------------------- +// D3D10_SHADER_INPUT_TYPE +//---------------------------------------------------------------------------- + +typedef enum _D3D10_SHADER_INPUT_TYPE +{ + D3D10_SIT_CBUFFER, + D3D10_SIT_TBUFFER, + D3D10_SIT_TEXTURE, + D3D10_SIT_SAMPLER, +} D3D10_SHADER_INPUT_TYPE, *LPD3D10_SHADER_INPUT_TYPE; + +typedef enum _D3D10_CBUFFER_TYPE +{ + D3D10_CT_CBUFFER, + D3D10_CT_TBUFFER, +} D3D10_CBUFFER_TYPE, *LPD3D10_CBUFFER_TYPE; + +typedef enum D3D10_NAME +{ + D3D10_NAME_UNDEFINED = 0, + D3D10_NAME_POSITION = 1, + D3D10_NAME_CLIP_DISTANCE = 2, + D3D10_NAME_CULL_DISTANCE = 3, + D3D10_NAME_RENDER_TARGET_ARRAY_INDEX = 4, + D3D10_NAME_VIEWPORT_ARRAY_INDEX = 5, + D3D10_NAME_VERTEX_ID = 6, + D3D10_NAME_PRIMITIVE_ID = 7, + D3D10_NAME_INSTANCE_ID = 8, + D3D10_NAME_IS_FRONT_FACE = 9 +} D3D10_NAME; + +typedef enum D3D10_RESOURCE_DIMENSION +{ + D3D10_RESOURCE_DIMENSION_UNKNOWN = 0, + D3D10_RESOURCE_DIMENSION_BUFFER = 1, + D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2, + D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3, + D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4, + D3D10_RESOURCE_DIMENSION_TEXTURECUBE = 5, + D3D10_RESOURCE_DIMENSION_TEXTURE1DARRAY = 6, + D3D10_RESOURCE_DIMENSION_TEXTURE2DARRAY = 7, +} D3D10_RESOURCE_DIMENSION; + +typedef enum D3D10_RESOURCE_RETURN_TYPE +{ + D3D10_RETURN_TYPE_UNORM = 1, + D3D10_RETURN_TYPE_SNORM = 2, + D3D10_RETURN_TYPE_SINT = 3, + D3D10_RETURN_TYPE_UINT = 4, + D3D10_RETURN_TYPE_FLOAT = 5, + D3D10_RETURN_TYPE_MIXED = 6, +} D3D10_RESOURCE_RETURN_TYPE; + +typedef enum D3D10_REGISTER_COMPONENT_TYPE +{ + D3D10_REGISTER_COMPONENT_UNKNOWN = 0, + D3D10_REGISTER_COMPONENT_UINT32 = 1, + D3D10_REGISTER_COMPONENT_SINT32 = 2, + D3D10_REGISTER_COMPONENT_FLOAT32 = 3 +} D3D10_REGISTER_COMPONENT_TYPE; + + +//---------------------------------------------------------------------------- +// D3D10_INCLUDE_TYPE: +//---------------------------------------------------------------------------- + +typedef enum _D3D10_INCLUDE_TYPE +{ + D3D10_INCLUDE_LOCAL, + D3D10_INCLUDE_SYSTEM, + + // force 32-bit size enum + D3D10_INCLUDE_FORCE_DWORD = 0x7fffffff + +} D3D10_INCLUDE_TYPE, *LPD3D10_INCLUDE_TYPE; + + +//---------------------------------------------------------------------------- +// ID3D10Include: +// ------------- +// This interface is intended to be implemented by the application, and can +// be used by various D3D10 APIs. This enables application-specific handling +// of #include directives in source files. +// +// Open() +// Opens an include file. If successful, it should fill in ppData and +// pBytes. The data pointer returned must remain valid until Close is +// subsequently called. +// Close() +// Closes an include file. If Open was successful, Close is guaranteed +// to be called before the API using this interface returns. +//---------------------------------------------------------------------------- + +typedef interface ID3D10Include ID3D10Include; +typedef interface ID3D10Include *LPD3D10INCLUDE; + +#undef INTERFACE +#define INTERFACE ID3D10Include + +DECLARE_INTERFACE(ID3D10Include) +{ + STDMETHOD(Open)(THIS_ D3D10_INCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes) PURE; + STDMETHOD(Close)(THIS_ LPCVOID pData) PURE; +}; + + +//---------------------------------------------------------------------------- +// ID3D10ShaderReflection: +//---------------------------------------------------------------------------- + +// +// Structure definitions +// + +typedef struct _D3D10_SHADER_DESC +{ + UINT Version; // Shader version + LPCSTR Creator; // Creator string + UINT Flags; // Shader compilation/parse flags + + UINT ConstantBuffers; // Number of constant buffers + UINT BoundResources; // Number of bound resources + UINT InputParameters; // Number of parameters in the input signature + UINT OutputParameters; // Number of parameters in the output signature +} D3D10_SHADER_DESC; + +typedef struct _D3D10_SHADER_BUFFER_DESC +{ + LPCSTR Name; // Name of the constant buffer + D3D10_CBUFFER_TYPE Type; // Indicates that this is a CBuffer or TBuffer + UINT Variables; // Number of member variables + UINT Size; // Size of CB (in bytes) +} D3D10_SHADER_BUFFER_DESC; + +typedef struct _D3D10_SHADER_VARIABLE_DESC +{ + LPCSTR Name; // Name of the variable + UINT StartOffset; // Offset in constant buffer's backing store + UINT Size; // Size of variable (in bytes) + LPVOID DefaultValue; // Raw pointer to default value +} D3D10_SHADER_VARIABLE_DESC; + +typedef struct _D3D10_SHADER_TYPE_DESC +{ + D3D10_SHADER_VARIABLE_CLASS Class; // Variable class (e.g. object, matrix, etc.) + D3D10_SHADER_VARIABLE_TYPE Type; // Variable type (e.g. float, sampler, etc.) + UINT Rows; // Number of rows (for matrices, 1 for other numeric, 0 if not applicable) + UINT Columns; // Number of columns (for vectors & matrices, 1 for other numeric, 0 if not applicable) + UINT Elements; // Number of elements (0 if not an array) + UINT Members; // Number of members (0 if not a structure) +} D3D10_SHADER_TYPE_DESC; + +typedef struct _D3D10_SHADER_INPUT_BIND_DESC +{ + LPCSTR Name; // Name of the resource + D3D10_SHADER_INPUT_TYPE Type; // Type of resource (e.g. texture, cbuffer, etc.) + UINT BindPoint; // Starting bind point + UINT BindCount; // Number of contiguous bind points (for arrays) + + D3D10_RESOURCE_RETURN_TYPE ReturnType; // Return type (if texture) + D3D10_RESOURCE_DIMENSION Dimension; // Dimension (if texture) +} D3D10_SHADER_INPUT_BIND_DESC; + +typedef struct _D3D10_SIGNATURE_PARAMETER_DESC +{ + LPCSTR SemanticName; // Name of the semantic + UINT SemanticIndex; // Index of the semantic + UINT Register; // Number of member variables + D3D10_NAME SystemValueType;// A predefined system value, or D3D10_NAME_UNDEFINED if not applicable + D3D10_REGISTER_COMPONENT_TYPE ComponentType;// Scalar type (e.g. uint, float, etc.) + BYTE Mask; // Mask to indicate which components of the register + // are used (combination of D3D10_COMPONENT_MASK values) + BYTE ReadWriteMask; // Mask to indicate whether a given component is + // never written (if this is an output signature) or + // always read (if this is an input signature). + // (combination of D3D10_COMPONENT_MASK values) + +} D3D10_SIGNATURE_PARAMETER_DESC; + +// +// Interface definitions +// + +typedef interface ID3D10ShaderReflectionType ID3D10ShaderReflectionType; +typedef interface ID3D10ShaderReflectionType *LPD3D10SHADERREFLECTIONTYPE; + +// {C530AD7D-9B16-4395-A979-BA2ECFF83ADD} +DEFINE_GUID(IID_ID3D10ShaderReflectionType, +0xc530ad7d, 0x9b16, 0x4395, 0xa9, 0x79, 0xba, 0x2e, 0xcf, 0xf8, 0x3a, 0xdd); + +#undef INTERFACE +#define INTERFACE ID3D10ShaderReflectionType + +DECLARE_INTERFACE(ID3D10ShaderReflectionType) +{ + STDMETHOD(GetDesc)(THIS_ D3D10_SHADER_TYPE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10ShaderReflectionType*, GetMemberTypeByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10ShaderReflectionType*, GetMemberTypeByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD_(LPCSTR, GetMemberTypeName)(THIS_ UINT Index) PURE; +}; + +typedef interface ID3D10ShaderReflectionVariable ID3D10ShaderReflectionVariable; +typedef interface ID3D10ShaderReflectionVariable *LPD3D10SHADERREFLECTIONVARIABLE; + +// {1BF63C95-2650-405d-99C1-3636BD1DA0A1} +DEFINE_GUID(IID_ID3D10ShaderReflectionVariable, +0x1bf63c95, 0x2650, 0x405d, 0x99, 0xc1, 0x36, 0x36, 0xbd, 0x1d, 0xa0, 0xa1); + +#undef INTERFACE +#define INTERFACE ID3D10ShaderReflectionVariable + +DECLARE_INTERFACE(ID3D10ShaderReflectionVariable) +{ + STDMETHOD(GetDesc)(THIS_ D3D10_SHADER_VARIABLE_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10ShaderReflectionType*, GetType)(THIS) PURE; +}; + +typedef interface ID3D10ShaderReflectionConstantBuffer ID3D10ShaderReflectionConstantBuffer; +typedef interface ID3D10ShaderReflectionConstantBuffer *LPD3D10SHADERREFLECTIONCONSTANTBUFFER; + +// {66C66A94-DDDD-4b62-A66A-F0DA33C2B4D0} +DEFINE_GUID(IID_ID3D10ShaderReflectionConstantBuffer, +0x66c66a94, 0xdddd, 0x4b62, 0xa6, 0x6a, 0xf0, 0xda, 0x33, 0xc2, 0xb4, 0xd0); + +#undef INTERFACE +#define INTERFACE ID3D10ShaderReflectionConstantBuffer + +DECLARE_INTERFACE(ID3D10ShaderReflectionConstantBuffer) +{ + STDMETHOD(GetDesc)(THIS_ D3D10_SHADER_BUFFER_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10ShaderReflectionVariable*, GetVariableByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10ShaderReflectionVariable*, GetVariableByName)(THIS_ LPCSTR Name) PURE; +}; + +typedef interface ID3D10ShaderReflection ID3D10ShaderReflection; +typedef interface ID3D10ShaderReflection *LPD3D10SHADERREFLECTION; + +// {D40E20B6-F8F7-42ad-AB20-4BAF8F15DFAA} +DEFINE_GUID(IID_ID3D10ShaderReflection, +0xd40e20b6, 0xf8f7, 0x42ad, 0xab, 0x20, 0x4b, 0xaf, 0x8f, 0x15, 0xdf, 0xaa); + +#undef INTERFACE +#define INTERFACE ID3D10ShaderReflection + +DECLARE_INTERFACE_(ID3D10ShaderReflection, IUnknown) +{ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + STDMETHOD(GetDesc)(THIS_ D3D10_SHADER_DESC *pDesc) PURE; + + STDMETHOD_(ID3D10ShaderReflectionConstantBuffer*, GetConstantBufferByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(ID3D10ShaderReflectionConstantBuffer*, GetConstantBufferByName)(THIS_ LPCSTR Name) PURE; + + STDMETHOD(GetResourceBindingDesc)(THIS_ UINT ResourceIndex, D3D10_SHADER_INPUT_BIND_DESC *pDesc) PURE; + + STDMETHOD(GetInputParameterDesc)(THIS_ UINT ParameterIndex, D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE; + STDMETHOD(GetOutputParameterDesc)(THIS_ UINT ParameterIndex, D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE; + +}; + +////////////////////////////////////////////////////////////////////////////// +// APIs ////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +//---------------------------------------------------------------------------- +// D3D10CompileShader: +// ------------------ +// Compiles a shader. +// +// Parameters: +// pSrcFile +// Source file name. +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module. +// pSrcData +// Pointer to source code. +// SrcDataLen +// Size of source code, in bytes. +// pDefines +// Optional NULL-terminated array of preprocessor macro definitions. +// pInclude +// Optional interface pointer to use for handling #include directives. +// If this parameter is NULL, #includes will be honored when compiling +// from file, and will error when compiling from resource or memory. +// pFunctionName +// Name of the entrypoint function where execution should begin. +// pProfile +// Instruction set to be used when generating code. The D3D10 entry +// point currently supports only "vs_4_0", "ps_4_0", and "gs_4_0". +// Flags +// See D3D10_SHADER_xxx flags. +// ppShader +// Returns a buffer containing the created shader. This buffer contains +// the compiled shader code, as well as any embedded debug and symbol +// table info. (See D3D10GetShaderConstantTable) +// ppErrorMsgs +// Returns a buffer containing a listing of errors and warnings that were +// encountered during the compile. If you are running in a debugger, +// these are the same messages you will see in your debug output. +//---------------------------------------------------------------------------- + +HRESULT WINAPI D3D10CompileShader(LPCSTR pSrcData, SIZE_T SrcDataLen, LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, + LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs); + +//---------------------------------------------------------------------------- +// D3D10DisassembleShader: +// ---------------------- +// Takes a binary shader, and returns a buffer containing text assembly. +// +// Parameters: +// pShader +// Pointer to the shader byte code. +// ShaderSizeInBytes +// Size of the shader byte code in bytes. +// EnableColorCode +// Emit HTML tags for color coding the output? +// pComments +// Pointer to a comment string to include at the top of the shader. +// ppDisassembly +// Returns a buffer containing the disassembled shader. +//---------------------------------------------------------------------------- + +HRESULT WINAPI D3D10DisassembleShader(CONST UINT *pShader, BOOL EnableColorCode, LPCSTR pComments, ID3D10Blob** ppDisassembly); + +//---------------------------------------------------------------------------- +// D3D10GetShaderSize: +// ------------------ +// Returns the size of the shader blob container, in bytes. +// +// Parameters: +// pFunction +// Pointer to the function UINT stream +//---------------------------------------------------------------------------- + +UINT WINAPI D3D10GetShaderSize(CONST UINT *pFunction); + +//---------------------------------------------------------------------------- +// D3D10GetShaderVersion: +// ----------------------- +// Returns the shader version of a given shader. Returns zero if the shader +// function is NULL. +// +// Parameters: +// pFunction +// Pointer to the function UINT stream +//---------------------------------------------------------------------------- + +UINT WINAPI D3D10GetShaderVersion(CONST UINT *pFunction); + + +//---------------------------------------------------------------------------- +// D3D10GetPixelShaderProfile/D3D10GetVertexShaderProfile/D3D10GetGeometryShaderProfile: +// ----------------------------------------------------- +// Returns the name of the HLSL profile best suited to a given device. +// +// Parameters: +// pDevice +// Pointer to the device in question +//---------------------------------------------------------------------------- + +LPCSTR WINAPI D3D10GetPixelShaderProfile(ID3D10Device *pDevice); + +LPCSTR WINAPI D3D10GetVertexShaderProfile(ID3D10Device *pDevice); + +LPCSTR WINAPI D3D10GetGeometryShaderProfile(ID3D10Device *pDevice); + +//---------------------------------------------------------------------------- +// D3D10ReflectShader: +// ------------------ +// Creates a shader reflection object that can be used to retrieve information +// about a compiled shader +// +// Parameters: +// pShaderBytecode +// Pointer to a compiled shader (same pointer that is passed into +// ID3D10Device::CreateShader) +// BytecodeLength +// Length of the shader bytecode buffer +// ppReflector +// [out] Returns a ID3D10ShaderReflection object that can be used to +// retrieve shader resource and constant buffer information +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI D3D10ReflectShader(void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10ShaderReflection **ppReflector); + +//---------------------------------------------------------------------------- +// D3D10PreprocessShader +// --------------------- +// Creates a shader reflection object that can be used to retrieve information +// about a compiled shader +// +// Parameters: +// pSrcData +// Pointer to source code +// SrcDataLen +// Size of source code, in bytes +// pFileName +// Source file name (used for error output) +// pDefines +// Optional NULL-terminated array of preprocessor macro definitions. +// pInclude +// Optional interface pointer to use for handling #include directives. +// If this parameter is NULL, #includes will be honored when assembling +// from file, and will error when assembling from resource or memory. +// ppShaderText +// Returns a buffer containing a single large string that represents +// the resulting formatted token stream +// ppErrorMsgs +// Returns a buffer containing a listing of errors and warnings that were +// encountered during assembly. If you are running in a debugger, +// these are the same messages you will see in your debug output. +//---------------------------------------------------------------------------- + +HRESULT WINAPI D3D10PreprocessShader(LPCSTR pSrcData, SIZE_T SrcDataSize, LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, + LPD3D10INCLUDE pInclude, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs); + +////////////////////////////////////////////////////////////////////////// +// +// Shader blob manipulation routines +// --------------------------------- +// +// void *pShaderBytecode - a buffer containing the result of an HLSL +// compilation. Typically this opaque buffer contains several +// discrete sections including the shader executable code, the input +// signature, and the output signature. This can typically be retrieved +// by calling ID3D10Blob::GetBufferPointer() on the returned blob +// from HLSL's compile APIs. +// +// UINT BytecodeLength - the length of pShaderBytecode. This can +// typically be retrieved by calling ID3D10Blob::GetBufferSize() +// on the returned blob from HLSL's compile APIs. +// +// ID3D10Blob **ppSignatureBlob(s) - a newly created buffer that +// contains only the signature portions of the original bytecode. +// This is a copy; the original bytecode is not modified. You may +// specify NULL for this parameter to have the bytecode validated +// for the presence of the corresponding signatures without actually +// copying them and creating a new blob. +// +// Returns E_INVALIDARG if any required parameters are NULL +// Returns E_FAIL is the bytecode is corrupt or missing signatures +// Returns S_OK on success +// +////////////////////////////////////////////////////////////////////////// + +HRESULT D3D10GetInputSignatureBlob(void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob **ppSignatureBlob); +HRESULT D3D10GetOutputSignatureBlob(void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob **ppSignatureBlob); +HRESULT D3D10GetInputAndOutputSignatureBlob(void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob **ppSignatureBlob); + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3D10SHADER_H__ + diff --git a/src/dep/include/DXSDK/include/D3DX10.h b/src/dep/include/DXSDK/include/D3DX10.h index fa26b3f..5cdcd51 100644 --- a/src/dep/include/DXSDK/include/D3DX10.h +++ b/src/dep/include/DXSDK/include/D3DX10.h @@ -1,72 +1,72 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx10.h -// Content: D3DX10 utility library -// -////////////////////////////////////////////////////////////////////////////// - -#ifdef __D3DX10_INTERNAL__ -#error Incorrect D3DX10 header used -#endif - -#ifndef __D3DX10_H__ -#define __D3DX10_H__ - - -// Defines -#include -#include - -#define D3DX10_DEFAULT ((UINT) -1) -#define D3DX10_FROM_FILE ((UINT) -3) -#define DXGI_FORMAT_FROM_FILE ((DXGI_FORMAT) -3) - -#ifndef D3DX10INLINE -#ifdef _MSC_VER - #if (_MSC_VER >= 1200) - #define D3DX10INLINE __forceinline - #else - #define D3DX10INLINE __inline - #endif -#else - #ifdef __cplusplus - #define D3DX10INLINE inline - #else - #define D3DX10INLINE - #endif -#endif -#endif - - - -// Includes -#include "d3d10.h" -#include "d3dx10.h" -#include "d3dx10math.h" -#include "d3dx10core.h" -#include "d3dx10tex.h" -#include "d3dx10mesh.h" -#include "d3dx10async.h" - - -// Errors -#define _FACDD 0x876 -#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) - -enum _D3DX10_ERR { - D3DX10_ERR_CANNOT_MODIFY_INDEX_BUFFER = MAKE_DDHRESULT(2900), - D3DX10_ERR_INVALID_MESH = MAKE_DDHRESULT(2901), - D3DX10_ERR_CANNOT_ATTR_SORT = MAKE_DDHRESULT(2902), - D3DX10_ERR_SKINNING_NOT_SUPPORTED = MAKE_DDHRESULT(2903), - D3DX10_ERR_TOO_MANY_INFLUENCES = MAKE_DDHRESULT(2904), - D3DX10_ERR_INVALID_DATA = MAKE_DDHRESULT(2905), - D3DX10_ERR_LOADED_MESH_HAS_NO_DATA = MAKE_DDHRESULT(2906), - D3DX10_ERR_DUPLICATE_NAMED_FRAGMENT = MAKE_DDHRESULT(2907), - D3DX10_ERR_CANNOT_REMOVE_LAST_ITEM = MAKE_DDHRESULT(2908), -}; - - -#endif //__D3DX10_H__ - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx10.h +// Content: D3DX10 utility library +// +////////////////////////////////////////////////////////////////////////////// + +#ifdef __D3DX10_INTERNAL__ +#error Incorrect D3DX10 header used +#endif + +#ifndef __D3DX10_H__ +#define __D3DX10_H__ + + +// Defines +#include +#include + +#define D3DX10_DEFAULT ((UINT) -1) +#define D3DX10_FROM_FILE ((UINT) -3) +#define DXGI_FORMAT_FROM_FILE ((DXGI_FORMAT) -3) + +#ifndef D3DX10INLINE +#ifdef _MSC_VER + #if (_MSC_VER >= 1200) + #define D3DX10INLINE __forceinline + #else + #define D3DX10INLINE __inline + #endif +#else + #ifdef __cplusplus + #define D3DX10INLINE inline + #else + #define D3DX10INLINE + #endif +#endif +#endif + + + +// Includes +#include "d3d10.h" +#include "d3dx10.h" +#include "d3dx10math.h" +#include "d3dx10core.h" +#include "d3dx10tex.h" +#include "d3dx10mesh.h" +#include "d3dx10async.h" + + +// Errors +#define _FACDD 0x876 +#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) + +enum _D3DX10_ERR { + D3DX10_ERR_CANNOT_MODIFY_INDEX_BUFFER = MAKE_DDHRESULT(2900), + D3DX10_ERR_INVALID_MESH = MAKE_DDHRESULT(2901), + D3DX10_ERR_CANNOT_ATTR_SORT = MAKE_DDHRESULT(2902), + D3DX10_ERR_SKINNING_NOT_SUPPORTED = MAKE_DDHRESULT(2903), + D3DX10_ERR_TOO_MANY_INFLUENCES = MAKE_DDHRESULT(2904), + D3DX10_ERR_INVALID_DATA = MAKE_DDHRESULT(2905), + D3DX10_ERR_LOADED_MESH_HAS_NO_DATA = MAKE_DDHRESULT(2906), + D3DX10_ERR_DUPLICATE_NAMED_FRAGMENT = MAKE_DDHRESULT(2907), + D3DX10_ERR_CANNOT_REMOVE_LAST_ITEM = MAKE_DDHRESULT(2908), +}; + + +#endif //__D3DX10_H__ + diff --git a/src/dep/include/DXSDK/include/D3DX10core.h b/src/dep/include/DXSDK/include/D3DX10core.h index a288a30..63dcc7a 100644 --- a/src/dep/include/DXSDK/include/D3DX10core.h +++ b/src/dep/include/DXSDK/include/D3DX10core.h @@ -1,418 +1,418 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx10core.h -// Content: D3DX10 core types and functions -// -/////////////////////////////////////////////////////////////////////////// - -#include "d3dx10.h" - -#ifndef __D3DX10CORE_H__ -#define __D3DX10CORE_H__ - -// Current name of the DLL shipped in the same SDK as this header. -#define D3DX10_DLL_W L"d3dx10.dll" -#define D3DX10_DLL_A "d3dx10.dll" - -#ifdef UNICODE - #define D3DX10_DLL D3DX10_DLL_W -#else - #define D3DX10_DLL D3DX10_DLL_A -#endif - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -/////////////////////////////////////////////////////////////////////////// -// D3DX10_SDK_VERSION: -// ----------------- -// This identifier is passed to D3DX10CheckVersion in order to ensure that an -// application was built against the correct header files and lib files. -// This number is incremented whenever a header (or other) change would -// require applications to be rebuilt. If the version doesn't match, -// D3DX10CreateVersion will return FALSE. (The number itself has no meaning.) -/////////////////////////////////////////////////////////////////////////// - -#define D3DX10_VERSION 0x1002 -#define D3DX10_SDK_VERSION 1000 - -HRESULT WINAPI D3DX10CheckVersion(UINT D3DSdkVersion, UINT D3DX10SdkVersion); -UINT WINAPI D3DX10GetDriverLevel(ID3D10Device *pDevice); - -#ifdef __cplusplus -} -#endif //__cplusplus - - -////////////////////////////////////////////////////////////////////////////// -// D3DX10_SPRITE flags: -// ----------------- -// D3DX10_SPRITE_SAVE_STATE -// Specifies device state should be saved and restored in Begin/End. -// D3DX10SPRITE_SORT_TEXTURE -// Sprites are sorted by texture prior to drawing. This is recommended when -// drawing non-overlapping sprites of uniform depth. For example, drawing -// screen-aligned text with ID3DX10Font. -// D3DX10SPRITE_SORT_DEPTH_FRONT_TO_BACK -// Sprites are sorted by depth front-to-back prior to drawing. This is -// recommended when drawing opaque sprites of varying depths. -// D3DX10SPRITE_SORT_DEPTH_BACK_TO_FRONT -// Sprites are sorted by depth back-to-front prior to drawing. This is -// recommended when drawing transparent sprites of varying depths. -// D3DX10SPRITE_ADDREF_TEXTURES -// AddRef/Release all textures passed in to DrawSpritesBuffered -////////////////////////////////////////////////////////////////////////////// - -enum -{ - D3DX10_SPRITE_SORT_TEXTURE = 0x01, - D3DX10_SPRITE_SORT_DEPTH_BACK_TO_FRONT = 0x02, - D3DX10_SPRITE_SORT_DEPTH_FRONT_TO_BACK = 0x04, - D3DX10_SPRITE_SAVE_STATE = 0x08, - D3DX10_SPRITE_ADDREF_TEXTURES = 0x10, -}; - -typedef struct _D3DX10_SPRITE -{ - D3DXMATRIX matWorld; - - D3DXVECTOR2 TexCoord; - D3DXVECTOR2 TexSize; - - D3DXCOLOR ColorModulate; - - ID3D10ShaderResourceView *pTexture; - UINT TextureIndex; -} D3DX10_SPRITE; - - -////////////////////////////////////////////////////////////////////////////// -// ID3DX10Sprite: -// ------------ -// This object intends to provide an easy way to drawing sprites using D3D. -// -// Begin - -// Prepares device for drawing sprites. -// -// Draw - -// Draws a sprite -// -// Flush - -// Forces all batched sprites to submitted to the device. -// -// End - -// Restores device state to how it was when Begin was called. -// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX10Sprite ID3DX10Sprite; -typedef interface ID3DX10Sprite *LPD3DX10SPRITE; - - -// {BA0B762D-8D28-43ec-B9DC-2F84443B0614} -DEFINE_GUID(IID_ID3DX10Sprite, -0xba0b762d, 0x8d28, 0x43ec, 0xb9, 0xdc, 0x2f, 0x84, 0x44, 0x3b, 0x6, 0x14); - - -#undef INTERFACE -#define INTERFACE ID3DX10Sprite - -DECLARE_INTERFACE_(ID3DX10Sprite, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DX10Sprite - STDMETHOD(Begin)(THIS_ UINT flags) PURE; - - STDMETHOD(DrawSpritesBuffered)(THIS_ D3DX10_SPRITE *pSprites, UINT cSprites) PURE; - STDMETHOD(Flush)(THIS) PURE; - - STDMETHOD(DrawSpritesImmediate)(THIS_ D3DX10_SPRITE *pSprites, UINT cSprites, UINT cbSprite, UINT flags) PURE; - STDMETHOD(End)(THIS) PURE; - - STDMETHOD(GetViewTransform)(THIS_ D3DXMATRIX *pViewTransform) PURE; - STDMETHOD(SetViewTransform)(THIS_ D3DXMATRIX *pViewTransform) PURE; - STDMETHOD(GetProjectionTransform)(THIS_ D3DXMATRIX *pProjectionTransform) PURE; - STDMETHOD(SetProjectionTransform)(THIS_ D3DXMATRIX *pProjectionTransform) PURE; - - STDMETHOD(GetDevice)(THIS_ ID3D10Device** ppDevice) PURE; -}; - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DX10CreateSprite( - ID3D10Device* pDevice, - UINT cDeviceBufferSize, - LPD3DX10SPRITE* ppSprite); - -#ifdef __cplusplus -} -#endif //__cplusplus - - -////////////////////////////////////////////////////////////////////////////// -// ID3DX10ThreadPump: -////////////////////////////////////////////////////////////////////////////// - -#undef INTERFACE -#define INTERFACE ID3DX10DataLoader - -DECLARE_INTERFACE(ID3DX10DataLoader) -{ - STDMETHOD(Load)(THIS) PURE; - STDMETHOD(Decompress)(THIS_ void **ppData, SIZE_T *pcBytes) PURE; - STDMETHOD(Destroy)(THIS) PURE; -}; - -#undef INTERFACE -#define INTERFACE ID3DX10DataProcessor - -DECLARE_INTERFACE(ID3DX10DataProcessor) -{ - STDMETHOD(Process)(THIS_ void *pData, SIZE_T cBytes) PURE; - STDMETHOD(CreateDeviceObject)(THIS_ void **ppDataObject) PURE; - STDMETHOD(Destroy)(THIS) PURE; -}; - -// {C93FECFA-6967-478a-ABBC-402D90621FCB} -DEFINE_GUID(IID_ID3DX10ThreadPump, -0xc93fecfa, 0x6967, 0x478a, 0xab, 0xbc, 0x40, 0x2d, 0x90, 0x62, 0x1f, 0xcb); - -#undef INTERFACE -#define INTERFACE ID3DX10ThreadPump - -DECLARE_INTERFACE_(ID3DX10ThreadPump, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DX10ThreadPump - STDMETHOD(AddWorkItem)(THIS_ ID3DX10DataLoader *pDataLoader, ID3DX10DataProcessor *pDataProcessor, HRESULT *pHResult, void **ppDeviceObject) PURE; - STDMETHOD_(UINT, GetWorkItemCount)(THIS) PURE; - - STDMETHOD(WaitForAllItems)(THIS) PURE; - STDMETHOD(ProcessDeviceWorkItems)(THIS_ UINT iWorkItemCount); - - STDMETHOD(PurgeAllItems)(THIS) PURE; - STDMETHOD(GetQueueStatus)(THIS_ UINT *pIoQueue, UINT *pProcessQueue, UINT *pDeviceQueue) PURE; - -}; - -HRESULT WINAPI D3DX10CreateThreadPump(UINT cIoThreads, UINT cProcThreads, ID3DX10ThreadPump **ppThreadPump); - - -////////////////////////////////////////////////////////////////////////////// -// ID3DX10Font: -// ---------- -// Font objects contain the textures and resources needed to render a specific -// font on a specific device. -// -// GetGlyphData - -// Returns glyph cache data, for a given glyph. -// -// PreloadCharacters/PreloadGlyphs/PreloadText - -// Preloads glyphs into the glyph cache textures. -// -// DrawText - -// Draws formatted text on a D3D device. Some parameters are -// surprisingly similar to those of GDI's DrawText function. See GDI -// documentation for a detailed description of these parameters. -// If pSprite is NULL, an internal sprite object will be used. -// -////////////////////////////////////////////////////////////////////////////// - -typedef struct _D3DX10_FONT_DESCA -{ - INT Height; - UINT Width; - UINT Weight; - UINT MipLevels; - BOOL Italic; - BYTE CharSet; - BYTE OutputPrecision; - BYTE Quality; - BYTE PitchAndFamily; - CHAR FaceName[LF_FACESIZE]; - -} D3DX10_FONT_DESCA, *LPD3DX10_FONT_DESCA; - -typedef struct _D3DX10_FONT_DESCW -{ - INT Height; - UINT Width; - UINT Weight; - UINT MipLevels; - BOOL Italic; - BYTE CharSet; - BYTE OutputPrecision; - BYTE Quality; - BYTE PitchAndFamily; - WCHAR FaceName[LF_FACESIZE]; - -} D3DX10_FONT_DESCW, *LPD3DX10_FONT_DESCW; - -#ifdef UNICODE -typedef D3DX10_FONT_DESCW D3DX10_FONT_DESC; -typedef LPD3DX10_FONT_DESCW LPD3DX10_FONT_DESC; -#else -typedef D3DX10_FONT_DESCA D3DX10_FONT_DESC; -typedef LPD3DX10_FONT_DESCA LPD3DX10_FONT_DESC; -#endif - - -typedef interface ID3DX10Font ID3DX10Font; -typedef interface ID3DX10Font *LPD3DX10FONT; - - -// {D79DBB70-5F21-4d36-BBC2-FF525C213CDC} -DEFINE_GUID(IID_ID3DX10Font, -0xd79dbb70, 0x5f21, 0x4d36, 0xbb, 0xc2, 0xff, 0x52, 0x5c, 0x21, 0x3c, 0xdc); - - -#undef INTERFACE -#define INTERFACE ID3DX10Font - -DECLARE_INTERFACE_(ID3DX10Font, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DX10Font - STDMETHOD(GetDevice)(THIS_ ID3D10Device** ppDevice) PURE; - STDMETHOD(GetDescA)(THIS_ D3DX10_FONT_DESCA *pDesc) PURE; - STDMETHOD(GetDescW)(THIS_ D3DX10_FONT_DESCW *pDesc) PURE; - STDMETHOD_(BOOL, GetTextMetricsA)(THIS_ TEXTMETRICA *pTextMetrics) PURE; - STDMETHOD_(BOOL, GetTextMetricsW)(THIS_ TEXTMETRICW *pTextMetrics) PURE; - - STDMETHOD_(HDC, GetDC)(THIS) PURE; - STDMETHOD(GetGlyphData)(THIS_ UINT Glyph, ID3D10ShaderResourceView** ppTexture, RECT *pBlackBox, POINT *pCellInc) PURE; - - STDMETHOD(PreloadCharacters)(THIS_ UINT First, UINT Last) PURE; - STDMETHOD(PreloadGlyphs)(THIS_ UINT First, UINT Last) PURE; - STDMETHOD(PreloadTextA)(THIS_ LPCSTR pString, INT Count) PURE; - STDMETHOD(PreloadTextW)(THIS_ LPCWSTR pString, INT Count) PURE; - - STDMETHOD_(INT, DrawTextA)(THIS_ LPD3DX10SPRITE pSprite, LPCSTR pString, INT Count, LPRECT pRect, UINT Format, D3DXCOLOR Color) PURE; - STDMETHOD_(INT, DrawTextW)(THIS_ LPD3DX10SPRITE pSprite, LPCWSTR pString, INT Count, LPRECT pRect, UINT Format, D3DXCOLOR Color) PURE; - -#ifdef __cplusplus -#ifdef UNICODE - HRESULT GetDesc(D3DX10_FONT_DESCW *pDesc) { return GetDescW(pDesc); } - HRESULT PreloadText(LPCWSTR pString, INT Count) { return PreloadTextW(pString, Count); } -#else - HRESULT GetDesc(D3DX10_FONT_DESCA *pDesc) { return GetDescA(pDesc); } - HRESULT PreloadText(LPCSTR pString, INT Count) { return PreloadTextA(pString, Count); } -#endif -#endif //__cplusplus -}; - -#ifndef GetTextMetrics -#ifdef UNICODE -#define GetTextMetrics GetTextMetricsW -#else -#define GetTextMetrics GetTextMetricsA -#endif -#endif - -#ifndef DrawText -#ifdef UNICODE -#define DrawText DrawTextW -#else -#define DrawText DrawTextA -#endif -#endif - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -HRESULT WINAPI - D3DX10CreateFontA( - ID3D10Device* pDevice, - INT Height, - UINT Width, - UINT Weight, - UINT MipLevels, - BOOL Italic, - UINT CharSet, - UINT OutputPrecision, - UINT Quality, - UINT PitchAndFamily, - LPCSTR pFaceName, - LPD3DX10FONT* ppFont); - -HRESULT WINAPI - D3DX10CreateFontW( - ID3D10Device* pDevice, - INT Height, - UINT Width, - UINT Weight, - UINT MipLevels, - BOOL Italic, - UINT CharSet, - UINT OutputPrecision, - UINT Quality, - UINT PitchAndFamily, - LPCWSTR pFaceName, - LPD3DX10FONT* ppFont); - -#ifdef UNICODE -#define D3DX10CreateFont D3DX10CreateFontW -#else -#define D3DX10CreateFont D3DX10CreateFontA -#endif - - -HRESULT WINAPI - D3DX10CreateFontIndirectA( - ID3D10Device* pDevice, - CONST D3DX10_FONT_DESCA* pDesc, - LPD3DX10FONT* ppFont); - -HRESULT WINAPI - D3DX10CreateFontIndirectW( - ID3D10Device* pDevice, - CONST D3DX10_FONT_DESCW* pDesc, - LPD3DX10FONT* ppFont); - -#ifdef UNICODE -#define D3DX10CreateFontIndirect D3DX10CreateFontIndirectW -#else -#define D3DX10CreateFontIndirect D3DX10CreateFontIndirectA -#endif - -HRESULT WINAPI D3DX10UnsetAllDeviceObjects(ID3D10Device *pDevice); - -#ifdef __cplusplus -} -#endif //__cplusplus - -/////////////////////////////////////////////////////////////////////////// -// -// TODO: move these to a central error header file -// -#define _FACD3D 0x876 -#define MAKE_D3DHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code ) -#define MAKE_D3DSTATUS( code ) MAKE_HRESULT( 0, _FACD3D, code ) - -#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156) -#define D3DERR_WASSTILLDRAWING MAKE_D3DHRESULT(540) - -#endif //__D3DX10CORE_H__ - +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx10core.h +// Content: D3DX10 core types and functions +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx10.h" + +#ifndef __D3DX10CORE_H__ +#define __D3DX10CORE_H__ + +// Current name of the DLL shipped in the same SDK as this header. +#define D3DX10_DLL_W L"d3dx10.dll" +#define D3DX10_DLL_A "d3dx10.dll" + +#ifdef UNICODE + #define D3DX10_DLL D3DX10_DLL_W +#else + #define D3DX10_DLL D3DX10_DLL_A +#endif + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +/////////////////////////////////////////////////////////////////////////// +// D3DX10_SDK_VERSION: +// ----------------- +// This identifier is passed to D3DX10CheckVersion in order to ensure that an +// application was built against the correct header files and lib files. +// This number is incremented whenever a header (or other) change would +// require applications to be rebuilt. If the version doesn't match, +// D3DX10CreateVersion will return FALSE. (The number itself has no meaning.) +/////////////////////////////////////////////////////////////////////////// + +#define D3DX10_VERSION 0x1002 +#define D3DX10_SDK_VERSION 1000 + +HRESULT WINAPI D3DX10CheckVersion(UINT D3DSdkVersion, UINT D3DX10SdkVersion); +UINT WINAPI D3DX10GetDriverLevel(ID3D10Device *pDevice); + +#ifdef __cplusplus +} +#endif //__cplusplus + + +////////////////////////////////////////////////////////////////////////////// +// D3DX10_SPRITE flags: +// ----------------- +// D3DX10_SPRITE_SAVE_STATE +// Specifies device state should be saved and restored in Begin/End. +// D3DX10SPRITE_SORT_TEXTURE +// Sprites are sorted by texture prior to drawing. This is recommended when +// drawing non-overlapping sprites of uniform depth. For example, drawing +// screen-aligned text with ID3DX10Font. +// D3DX10SPRITE_SORT_DEPTH_FRONT_TO_BACK +// Sprites are sorted by depth front-to-back prior to drawing. This is +// recommended when drawing opaque sprites of varying depths. +// D3DX10SPRITE_SORT_DEPTH_BACK_TO_FRONT +// Sprites are sorted by depth back-to-front prior to drawing. This is +// recommended when drawing transparent sprites of varying depths. +// D3DX10SPRITE_ADDREF_TEXTURES +// AddRef/Release all textures passed in to DrawSpritesBuffered +////////////////////////////////////////////////////////////////////////////// + +enum +{ + D3DX10_SPRITE_SORT_TEXTURE = 0x01, + D3DX10_SPRITE_SORT_DEPTH_BACK_TO_FRONT = 0x02, + D3DX10_SPRITE_SORT_DEPTH_FRONT_TO_BACK = 0x04, + D3DX10_SPRITE_SAVE_STATE = 0x08, + D3DX10_SPRITE_ADDREF_TEXTURES = 0x10, +}; + +typedef struct _D3DX10_SPRITE +{ + D3DXMATRIX matWorld; + + D3DXVECTOR2 TexCoord; + D3DXVECTOR2 TexSize; + + D3DXCOLOR ColorModulate; + + ID3D10ShaderResourceView *pTexture; + UINT TextureIndex; +} D3DX10_SPRITE; + + +////////////////////////////////////////////////////////////////////////////// +// ID3DX10Sprite: +// ------------ +// This object intends to provide an easy way to drawing sprites using D3D. +// +// Begin - +// Prepares device for drawing sprites. +// +// Draw - +// Draws a sprite +// +// Flush - +// Forces all batched sprites to submitted to the device. +// +// End - +// Restores device state to how it was when Begin was called. +// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DX10Sprite ID3DX10Sprite; +typedef interface ID3DX10Sprite *LPD3DX10SPRITE; + + +// {BA0B762D-8D28-43ec-B9DC-2F84443B0614} +DEFINE_GUID(IID_ID3DX10Sprite, +0xba0b762d, 0x8d28, 0x43ec, 0xb9, 0xdc, 0x2f, 0x84, 0x44, 0x3b, 0x6, 0x14); + + +#undef INTERFACE +#define INTERFACE ID3DX10Sprite + +DECLARE_INTERFACE_(ID3DX10Sprite, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DX10Sprite + STDMETHOD(Begin)(THIS_ UINT flags) PURE; + + STDMETHOD(DrawSpritesBuffered)(THIS_ D3DX10_SPRITE *pSprites, UINT cSprites) PURE; + STDMETHOD(Flush)(THIS) PURE; + + STDMETHOD(DrawSpritesImmediate)(THIS_ D3DX10_SPRITE *pSprites, UINT cSprites, UINT cbSprite, UINT flags) PURE; + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(GetViewTransform)(THIS_ D3DXMATRIX *pViewTransform) PURE; + STDMETHOD(SetViewTransform)(THIS_ D3DXMATRIX *pViewTransform) PURE; + STDMETHOD(GetProjectionTransform)(THIS_ D3DXMATRIX *pProjectionTransform) PURE; + STDMETHOD(SetProjectionTransform)(THIS_ D3DXMATRIX *pProjectionTransform) PURE; + + STDMETHOD(GetDevice)(THIS_ ID3D10Device** ppDevice) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DX10CreateSprite( + ID3D10Device* pDevice, + UINT cDeviceBufferSize, + LPD3DX10SPRITE* ppSprite); + +#ifdef __cplusplus +} +#endif //__cplusplus + + +////////////////////////////////////////////////////////////////////////////// +// ID3DX10ThreadPump: +////////////////////////////////////////////////////////////////////////////// + +#undef INTERFACE +#define INTERFACE ID3DX10DataLoader + +DECLARE_INTERFACE(ID3DX10DataLoader) +{ + STDMETHOD(Load)(THIS) PURE; + STDMETHOD(Decompress)(THIS_ void **ppData, SIZE_T *pcBytes) PURE; + STDMETHOD(Destroy)(THIS) PURE; +}; + +#undef INTERFACE +#define INTERFACE ID3DX10DataProcessor + +DECLARE_INTERFACE(ID3DX10DataProcessor) +{ + STDMETHOD(Process)(THIS_ void *pData, SIZE_T cBytes) PURE; + STDMETHOD(CreateDeviceObject)(THIS_ void **ppDataObject) PURE; + STDMETHOD(Destroy)(THIS) PURE; +}; + +// {C93FECFA-6967-478a-ABBC-402D90621FCB} +DEFINE_GUID(IID_ID3DX10ThreadPump, +0xc93fecfa, 0x6967, 0x478a, 0xab, 0xbc, 0x40, 0x2d, 0x90, 0x62, 0x1f, 0xcb); + +#undef INTERFACE +#define INTERFACE ID3DX10ThreadPump + +DECLARE_INTERFACE_(ID3DX10ThreadPump, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DX10ThreadPump + STDMETHOD(AddWorkItem)(THIS_ ID3DX10DataLoader *pDataLoader, ID3DX10DataProcessor *pDataProcessor, HRESULT *pHResult, void **ppDeviceObject) PURE; + STDMETHOD_(UINT, GetWorkItemCount)(THIS) PURE; + + STDMETHOD(WaitForAllItems)(THIS) PURE; + STDMETHOD(ProcessDeviceWorkItems)(THIS_ UINT iWorkItemCount); + + STDMETHOD(PurgeAllItems)(THIS) PURE; + STDMETHOD(GetQueueStatus)(THIS_ UINT *pIoQueue, UINT *pProcessQueue, UINT *pDeviceQueue) PURE; + +}; + +HRESULT WINAPI D3DX10CreateThreadPump(UINT cIoThreads, UINT cProcThreads, ID3DX10ThreadPump **ppThreadPump); + + +////////////////////////////////////////////////////////////////////////////// +// ID3DX10Font: +// ---------- +// Font objects contain the textures and resources needed to render a specific +// font on a specific device. +// +// GetGlyphData - +// Returns glyph cache data, for a given glyph. +// +// PreloadCharacters/PreloadGlyphs/PreloadText - +// Preloads glyphs into the glyph cache textures. +// +// DrawText - +// Draws formatted text on a D3D device. Some parameters are +// surprisingly similar to those of GDI's DrawText function. See GDI +// documentation for a detailed description of these parameters. +// If pSprite is NULL, an internal sprite object will be used. +// +////////////////////////////////////////////////////////////////////////////// + +typedef struct _D3DX10_FONT_DESCA +{ + INT Height; + UINT Width; + UINT Weight; + UINT MipLevels; + BOOL Italic; + BYTE CharSet; + BYTE OutputPrecision; + BYTE Quality; + BYTE PitchAndFamily; + CHAR FaceName[LF_FACESIZE]; + +} D3DX10_FONT_DESCA, *LPD3DX10_FONT_DESCA; + +typedef struct _D3DX10_FONT_DESCW +{ + INT Height; + UINT Width; + UINT Weight; + UINT MipLevels; + BOOL Italic; + BYTE CharSet; + BYTE OutputPrecision; + BYTE Quality; + BYTE PitchAndFamily; + WCHAR FaceName[LF_FACESIZE]; + +} D3DX10_FONT_DESCW, *LPD3DX10_FONT_DESCW; + +#ifdef UNICODE +typedef D3DX10_FONT_DESCW D3DX10_FONT_DESC; +typedef LPD3DX10_FONT_DESCW LPD3DX10_FONT_DESC; +#else +typedef D3DX10_FONT_DESCA D3DX10_FONT_DESC; +typedef LPD3DX10_FONT_DESCA LPD3DX10_FONT_DESC; +#endif + + +typedef interface ID3DX10Font ID3DX10Font; +typedef interface ID3DX10Font *LPD3DX10FONT; + + +// {D79DBB70-5F21-4d36-BBC2-FF525C213CDC} +DEFINE_GUID(IID_ID3DX10Font, +0xd79dbb70, 0x5f21, 0x4d36, 0xbb, 0xc2, 0xff, 0x52, 0x5c, 0x21, 0x3c, 0xdc); + + +#undef INTERFACE +#define INTERFACE ID3DX10Font + +DECLARE_INTERFACE_(ID3DX10Font, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DX10Font + STDMETHOD(GetDevice)(THIS_ ID3D10Device** ppDevice) PURE; + STDMETHOD(GetDescA)(THIS_ D3DX10_FONT_DESCA *pDesc) PURE; + STDMETHOD(GetDescW)(THIS_ D3DX10_FONT_DESCW *pDesc) PURE; + STDMETHOD_(BOOL, GetTextMetricsA)(THIS_ TEXTMETRICA *pTextMetrics) PURE; + STDMETHOD_(BOOL, GetTextMetricsW)(THIS_ TEXTMETRICW *pTextMetrics) PURE; + + STDMETHOD_(HDC, GetDC)(THIS) PURE; + STDMETHOD(GetGlyphData)(THIS_ UINT Glyph, ID3D10ShaderResourceView** ppTexture, RECT *pBlackBox, POINT *pCellInc) PURE; + + STDMETHOD(PreloadCharacters)(THIS_ UINT First, UINT Last) PURE; + STDMETHOD(PreloadGlyphs)(THIS_ UINT First, UINT Last) PURE; + STDMETHOD(PreloadTextA)(THIS_ LPCSTR pString, INT Count) PURE; + STDMETHOD(PreloadTextW)(THIS_ LPCWSTR pString, INT Count) PURE; + + STDMETHOD_(INT, DrawTextA)(THIS_ LPD3DX10SPRITE pSprite, LPCSTR pString, INT Count, LPRECT pRect, UINT Format, D3DXCOLOR Color) PURE; + STDMETHOD_(INT, DrawTextW)(THIS_ LPD3DX10SPRITE pSprite, LPCWSTR pString, INT Count, LPRECT pRect, UINT Format, D3DXCOLOR Color) PURE; + +#ifdef __cplusplus +#ifdef UNICODE + HRESULT GetDesc(D3DX10_FONT_DESCW *pDesc) { return GetDescW(pDesc); } + HRESULT PreloadText(LPCWSTR pString, INT Count) { return PreloadTextW(pString, Count); } +#else + HRESULT GetDesc(D3DX10_FONT_DESCA *pDesc) { return GetDescA(pDesc); } + HRESULT PreloadText(LPCSTR pString, INT Count) { return PreloadTextA(pString, Count); } +#endif +#endif //__cplusplus +}; + +#ifndef GetTextMetrics +#ifdef UNICODE +#define GetTextMetrics GetTextMetricsW +#else +#define GetTextMetrics GetTextMetricsA +#endif +#endif + +#ifndef DrawText +#ifdef UNICODE +#define DrawText DrawTextW +#else +#define DrawText DrawTextA +#endif +#endif + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +HRESULT WINAPI + D3DX10CreateFontA( + ID3D10Device* pDevice, + INT Height, + UINT Width, + UINT Weight, + UINT MipLevels, + BOOL Italic, + UINT CharSet, + UINT OutputPrecision, + UINT Quality, + UINT PitchAndFamily, + LPCSTR pFaceName, + LPD3DX10FONT* ppFont); + +HRESULT WINAPI + D3DX10CreateFontW( + ID3D10Device* pDevice, + INT Height, + UINT Width, + UINT Weight, + UINT MipLevels, + BOOL Italic, + UINT CharSet, + UINT OutputPrecision, + UINT Quality, + UINT PitchAndFamily, + LPCWSTR pFaceName, + LPD3DX10FONT* ppFont); + +#ifdef UNICODE +#define D3DX10CreateFont D3DX10CreateFontW +#else +#define D3DX10CreateFont D3DX10CreateFontA +#endif + + +HRESULT WINAPI + D3DX10CreateFontIndirectA( + ID3D10Device* pDevice, + CONST D3DX10_FONT_DESCA* pDesc, + LPD3DX10FONT* ppFont); + +HRESULT WINAPI + D3DX10CreateFontIndirectW( + ID3D10Device* pDevice, + CONST D3DX10_FONT_DESCW* pDesc, + LPD3DX10FONT* ppFont); + +#ifdef UNICODE +#define D3DX10CreateFontIndirect D3DX10CreateFontIndirectW +#else +#define D3DX10CreateFontIndirect D3DX10CreateFontIndirectA +#endif + +HRESULT WINAPI D3DX10UnsetAllDeviceObjects(ID3D10Device *pDevice); + +#ifdef __cplusplus +} +#endif //__cplusplus + +/////////////////////////////////////////////////////////////////////////// +// +// TODO: move these to a central error header file +// +#define _FACD3D 0x876 +#define MAKE_D3DHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code ) +#define MAKE_D3DSTATUS( code ) MAKE_HRESULT( 0, _FACD3D, code ) + +#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156) +#define D3DERR_WASSTILLDRAWING MAKE_D3DHRESULT(540) + +#endif //__D3DX10CORE_H__ + diff --git a/src/dep/include/DXSDK/include/D3DX10math.h b/src/dep/include/DXSDK/include/D3DX10math.h index e307044..1ff8fa3 100644 --- a/src/dep/include/DXSDK/include/D3DX10math.h +++ b/src/dep/include/DXSDK/include/D3DX10math.h @@ -1,1788 +1,1788 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: D3DX10math.h -// Content: D3DX10 math types and functions -// -////////////////////////////////////////////////////////////////////////////// - -#include "D3DX10.h" - -// D3DX10 and D3DX9 math look the same. You can include either one into your project. -// We are intentionally using the header define from D3DX9 math to prevent double-inclusion. -#ifndef __D3DX9MATH_H__ -#define __D3DX9MATH_H__ - -#include -#if _MSC_VER >= 1200 -#pragma warning(push) -#endif -#pragma warning(disable:4201) // anonymous unions warning - -//=========================================================================== -// -// Type definitions from D3D9 -// -//=========================================================================== - -#ifndef D3DVECTOR_DEFINED -typedef struct _D3DVECTOR { - float x; - float y; - float z; -} D3DVECTOR; -#define D3DVECTOR_DEFINED -#endif - -#ifndef D3DMATRIX_DEFINED -typedef struct _D3DMATRIX { - union { - struct { - float _11, _12, _13, _14; - float _21, _22, _23, _24; - float _31, _32, _33, _34; - float _41, _42, _43, _44; - - }; - float m[4][4]; - }; -} D3DMATRIX; -#define D3DMATRIX_DEFINED -#endif - -//=========================================================================== -// -// General purpose utilities -// -//=========================================================================== -#define D3DX_PI ((FLOAT) 3.141592654f) -#define D3DX_1BYPI ((FLOAT) 0.318309886f) - -#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) -#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) - - - -//=========================================================================== -// -// 16 bit floating point numbers -// -//=========================================================================== - -#define D3DX_16F_DIG 3 // # of decimal digits of precision -#define D3DX_16F_EPSILON 4.8875809e-4f // smallest such that 1.0 + epsilon != 1.0 -#define D3DX_16F_MANT_DIG 11 // # of bits in mantissa -#define D3DX_16F_MAX 6.550400e+004 // max value -#define D3DX_16F_MAX_10_EXP 4 // max decimal exponent -#define D3DX_16F_MAX_EXP 15 // max binary exponent -#define D3DX_16F_MIN 6.1035156e-5f // min positive value -#define D3DX_16F_MIN_10_EXP (-4) // min decimal exponent -#define D3DX_16F_MIN_EXP (-12) // min binary exponent -#define D3DX_16F_RADIX 2 // exponent radix -#define D3DX_16F_ROUNDS 1 // addition rounding: near - - -typedef struct D3DXFLOAT16 -{ -#ifdef __cplusplus -public: - D3DXFLOAT16() {}; - D3DXFLOAT16( FLOAT ); - D3DXFLOAT16( CONST D3DXFLOAT16& ); - - // casting - operator FLOAT (); - - // binary operators - BOOL operator == ( CONST D3DXFLOAT16& ) const; - BOOL operator != ( CONST D3DXFLOAT16& ) const; - -protected: -#endif //__cplusplus - WORD value; -} D3DXFLOAT16, *LPD3DXFLOAT16; - - - -//=========================================================================== -// -// Vectors -// -//=========================================================================== - - -//-------------------------- -// 2D Vector -//-------------------------- -typedef struct D3DXVECTOR2 -{ -#ifdef __cplusplus -public: - D3DXVECTOR2() {}; - D3DXVECTOR2( CONST FLOAT * ); - D3DXVECTOR2( CONST D3DXFLOAT16 * ); - D3DXVECTOR2( FLOAT x, FLOAT y ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR2& operator += ( CONST D3DXVECTOR2& ); - D3DXVECTOR2& operator -= ( CONST D3DXVECTOR2& ); - D3DXVECTOR2& operator *= ( FLOAT ); - D3DXVECTOR2& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR2 operator + () const; - D3DXVECTOR2 operator - () const; - - // binary operators - D3DXVECTOR2 operator + ( CONST D3DXVECTOR2& ) const; - D3DXVECTOR2 operator - ( CONST D3DXVECTOR2& ) const; - D3DXVECTOR2 operator * ( FLOAT ) const; - D3DXVECTOR2 operator / ( FLOAT ) const; - - friend D3DXVECTOR2 operator * ( FLOAT, CONST D3DXVECTOR2& ); - - BOOL operator == ( CONST D3DXVECTOR2& ) const; - BOOL operator != ( CONST D3DXVECTOR2& ) const; - - -public: -#endif //__cplusplus - FLOAT x, y; -} D3DXVECTOR2, *LPD3DXVECTOR2; - - - -//-------------------------- -// 2D Vector (16 bit) -//-------------------------- - -typedef struct D3DXVECTOR2_16F -{ -#ifdef __cplusplus -public: - D3DXVECTOR2_16F() {}; - D3DXVECTOR2_16F( CONST FLOAT * ); - D3DXVECTOR2_16F( CONST D3DXFLOAT16 * ); - D3DXVECTOR2_16F( CONST D3DXFLOAT16 &x, CONST D3DXFLOAT16 &y ); - - // casting - operator D3DXFLOAT16* (); - operator CONST D3DXFLOAT16* () const; - - // binary operators - BOOL operator == ( CONST D3DXVECTOR2_16F& ) const; - BOOL operator != ( CONST D3DXVECTOR2_16F& ) const; - -public: -#endif //__cplusplus - D3DXFLOAT16 x, y; - -} D3DXVECTOR2_16F, *LPD3DXVECTOR2_16F; - - - -//-------------------------- -// 3D Vector -//-------------------------- -#ifdef __cplusplus -typedef struct D3DXVECTOR3 : public D3DVECTOR -{ -public: - D3DXVECTOR3() {}; - D3DXVECTOR3( CONST FLOAT * ); - D3DXVECTOR3( CONST D3DVECTOR& ); - D3DXVECTOR3( CONST D3DXFLOAT16 * ); - D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); - D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& ); - D3DXVECTOR3& operator *= ( FLOAT ); - D3DXVECTOR3& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR3 operator + () const; - D3DXVECTOR3 operator - () const; - - // binary operators - D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const; - D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const; - D3DXVECTOR3 operator * ( FLOAT ) const; - D3DXVECTOR3 operator / ( FLOAT ) const; - - friend D3DXVECTOR3 operator * ( FLOAT, CONST struct D3DXVECTOR3& ); - - BOOL operator == ( CONST D3DXVECTOR3& ) const; - BOOL operator != ( CONST D3DXVECTOR3& ) const; - -} D3DXVECTOR3, *LPD3DXVECTOR3; - -#else //!__cplusplus -typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; -#endif //!__cplusplus - - - -//-------------------------- -// 3D Vector (16 bit) -//-------------------------- -typedef struct D3DXVECTOR3_16F -{ -#ifdef __cplusplus -public: - D3DXVECTOR3_16F() {}; - D3DXVECTOR3_16F( CONST FLOAT * ); - D3DXVECTOR3_16F( CONST D3DVECTOR& ); - D3DXVECTOR3_16F( CONST D3DXFLOAT16 * ); - D3DXVECTOR3_16F( CONST D3DXFLOAT16 &x, CONST D3DXFLOAT16 &y, CONST D3DXFLOAT16 &z ); - - // casting - operator D3DXFLOAT16* (); - operator CONST D3DXFLOAT16* () const; - - // binary operators - BOOL operator == ( CONST D3DXVECTOR3_16F& ) const; - BOOL operator != ( CONST D3DXVECTOR3_16F& ) const; - -public: -#endif //__cplusplus - D3DXFLOAT16 x, y, z; - -} D3DXVECTOR3_16F, *LPD3DXVECTOR3_16F; - - - -//-------------------------- -// 4D Vector -//-------------------------- -typedef struct D3DXVECTOR4 -{ -#ifdef __cplusplus -public: - D3DXVECTOR4() {}; - D3DXVECTOR4( CONST FLOAT* ); - D3DXVECTOR4( CONST D3DXFLOAT16* ); - D3DXVECTOR4( CONST D3DVECTOR& xyz, FLOAT w ); - D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& ); - D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& ); - D3DXVECTOR4& operator *= ( FLOAT ); - D3DXVECTOR4& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR4 operator + () const; - D3DXVECTOR4 operator - () const; - - // binary operators - D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const; - D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const; - D3DXVECTOR4 operator * ( FLOAT ) const; - D3DXVECTOR4 operator / ( FLOAT ) const; - - friend D3DXVECTOR4 operator * ( FLOAT, CONST D3DXVECTOR4& ); - - BOOL operator == ( CONST D3DXVECTOR4& ) const; - BOOL operator != ( CONST D3DXVECTOR4& ) const; - -public: -#endif //__cplusplus - FLOAT x, y, z, w; -} D3DXVECTOR4, *LPD3DXVECTOR4; - - -//-------------------------- -// 4D Vector (16 bit) -//-------------------------- -typedef struct D3DXVECTOR4_16F -{ -#ifdef __cplusplus -public: - D3DXVECTOR4_16F() {}; - D3DXVECTOR4_16F( CONST FLOAT * ); - D3DXVECTOR4_16F( CONST D3DXFLOAT16* ); - D3DXVECTOR4_16F( CONST D3DXVECTOR3_16F& xyz, CONST D3DXFLOAT16& w ); - D3DXVECTOR4_16F( CONST D3DXFLOAT16& x, CONST D3DXFLOAT16& y, CONST D3DXFLOAT16& z, CONST D3DXFLOAT16& w ); - - // casting - operator D3DXFLOAT16* (); - operator CONST D3DXFLOAT16* () const; - - // binary operators - BOOL operator == ( CONST D3DXVECTOR4_16F& ) const; - BOOL operator != ( CONST D3DXVECTOR4_16F& ) const; - -public: -#endif //__cplusplus - D3DXFLOAT16 x, y, z, w; - -} D3DXVECTOR4_16F, *LPD3DXVECTOR4_16F; - - - -//=========================================================================== -// -// Matrices -// -//=========================================================================== -#ifdef __cplusplus -typedef struct D3DXMATRIX : public D3DMATRIX -{ -public: - D3DXMATRIX() {}; - D3DXMATRIX( CONST FLOAT * ); - D3DXMATRIX( CONST D3DMATRIX& ); - D3DXMATRIX( CONST D3DXFLOAT16 * ); - D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, - FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, - FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, - FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); - - - // access grants - FLOAT& operator () ( UINT Row, UINT Col ); - FLOAT operator () ( UINT Row, UINT Col ) const; - - // casting operators - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXMATRIX& operator *= ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator += ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator -= ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator *= ( FLOAT ); - D3DXMATRIX& operator /= ( FLOAT ); - - // unary operators - D3DXMATRIX operator + () const; - D3DXMATRIX operator - () const; - - // binary operators - D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator * ( FLOAT ) const; - D3DXMATRIX operator / ( FLOAT ) const; - - friend D3DXMATRIX operator * ( FLOAT, CONST D3DXMATRIX& ); - - BOOL operator == ( CONST D3DXMATRIX& ) const; - BOOL operator != ( CONST D3DXMATRIX& ) const; - -} D3DXMATRIX, *LPD3DXMATRIX; - -#else //!__cplusplus -typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; -#endif //!__cplusplus - - -//--------------------------------------------------------------------------- -// Aligned Matrices -// -// This class helps keep matrices 16-byte aligned as preferred by P4 cpus. -// It aligns matrices on the stack and on the heap or in global scope. -// It does this using __declspec(align(16)) which works on VC7 and on VC 6 -// with the processor pack. Unfortunately there is no way to detect the -// latter so this is turned on only on VC7. On other compilers this is the -// the same as D3DXMATRIX. -// -// Using this class on a compiler that does not actually do the alignment -// can be dangerous since it will not expose bugs that ignore alignment. -// E.g if an object of this class in inside a struct or class, and some code -// memcopys data in it assuming tight packing. This could break on a compiler -// that eventually start aligning the matrix. -//--------------------------------------------------------------------------- -#ifdef __cplusplus -typedef struct _D3DXMATRIXA16 : public D3DXMATRIX -{ - _D3DXMATRIXA16() {}; - _D3DXMATRIXA16( CONST FLOAT * ); - _D3DXMATRIXA16( CONST D3DMATRIX& ); - _D3DXMATRIXA16( CONST D3DXFLOAT16 * ); - _D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, - FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, - FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, - FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); - - // new operators - void* operator new ( size_t ); - void* operator new[] ( size_t ); - - // delete operators - void operator delete ( void* ); // These are NOT virtual; Do not - void operator delete[] ( void* ); // cast to D3DXMATRIX and delete. - - // assignment operators - _D3DXMATRIXA16& operator = ( CONST D3DXMATRIX& ); - -} _D3DXMATRIXA16; - -#else //!__cplusplus -typedef D3DXMATRIX _D3DXMATRIXA16; -#endif //!__cplusplus - - - -#if _MSC_VER >= 1300 // VC7 -#define D3DX_ALIGN16 __declspec(align(16)) -#else -#define D3DX_ALIGN16 // Earlier compiler may not understand this, do nothing. -#endif - -typedef D3DX_ALIGN16 _D3DXMATRIXA16 D3DXMATRIXA16, *LPD3DXMATRIXA16; - - - -//=========================================================================== -// -// Quaternions -// -//=========================================================================== -typedef struct D3DXQUATERNION -{ -#ifdef __cplusplus -public: - D3DXQUATERNION() {}; - D3DXQUATERNION( CONST FLOAT * ); - D3DXQUATERNION( CONST D3DXFLOAT16 * ); - D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXQUATERNION& operator += ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator -= ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator *= ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator *= ( FLOAT ); - D3DXQUATERNION& operator /= ( FLOAT ); - - // unary operators - D3DXQUATERNION operator + () const; - D3DXQUATERNION operator - () const; - - // binary operators - D3DXQUATERNION operator + ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator - ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator * ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator * ( FLOAT ) const; - D3DXQUATERNION operator / ( FLOAT ) const; - - friend D3DXQUATERNION operator * (FLOAT, CONST D3DXQUATERNION& ); - - BOOL operator == ( CONST D3DXQUATERNION& ) const; - BOOL operator != ( CONST D3DXQUATERNION& ) const; - -#endif //__cplusplus - FLOAT x, y, z, w; -} D3DXQUATERNION, *LPD3DXQUATERNION; - - -//=========================================================================== -// -// Planes -// -//=========================================================================== -typedef struct D3DXPLANE -{ -#ifdef __cplusplus -public: - D3DXPLANE() {}; - D3DXPLANE( CONST FLOAT* ); - D3DXPLANE( CONST D3DXFLOAT16* ); - D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXPLANE& operator *= ( FLOAT ); - D3DXPLANE& operator /= ( FLOAT ); - - // unary operators - D3DXPLANE operator + () const; - D3DXPLANE operator - () const; - - // binary operators - D3DXPLANE operator * ( FLOAT ) const; - D3DXPLANE operator / ( FLOAT ) const; - - friend D3DXPLANE operator * ( FLOAT, CONST D3DXPLANE& ); - - BOOL operator == ( CONST D3DXPLANE& ) const; - BOOL operator != ( CONST D3DXPLANE& ) const; - -#endif //__cplusplus - FLOAT a, b, c, d; -} D3DXPLANE, *LPD3DXPLANE; - - -//=========================================================================== -// -// Colors -// -//=========================================================================== - -typedef struct D3DXCOLOR -{ -#ifdef __cplusplus -public: - D3DXCOLOR() {}; - D3DXCOLOR( UINT argb ); - D3DXCOLOR( CONST FLOAT * ); - D3DXCOLOR( CONST D3DXFLOAT16 * ); - D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); - - // casting - operator UINT () const; - - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); - D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); - D3DXCOLOR& operator *= ( FLOAT ); - D3DXCOLOR& operator /= ( FLOAT ); - - // unary operators - D3DXCOLOR operator + () const; - D3DXCOLOR operator - () const; - - // binary operators - D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; - D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; - D3DXCOLOR operator * ( FLOAT ) const; - D3DXCOLOR operator / ( FLOAT ) const; - - friend D3DXCOLOR operator * ( FLOAT, CONST D3DXCOLOR& ); - - BOOL operator == ( CONST D3DXCOLOR& ) const; - BOOL operator != ( CONST D3DXCOLOR& ) const; - -#endif //__cplusplus - FLOAT r, g, b, a; -} D3DXCOLOR, *LPD3DXCOLOR; - - - -//=========================================================================== -// -// D3DX math functions: -// -// NOTE: -// * All these functions can take the same object as in and out parameters. -// -// * Out parameters are typically also returned as return values, so that -// the output of one function may be used as a parameter to another. -// -//=========================================================================== - -//-------------------------- -// Float16 -//-------------------------- - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Converts an array 32-bit floats to 16-bit floats -D3DXFLOAT16* WINAPI D3DXFloat32To16Array - ( D3DXFLOAT16 *pOut, CONST FLOAT *pIn, UINT n ); - -// Converts an array 16-bit floats to 32-bit floats -FLOAT* WINAPI D3DXFloat16To32Array - ( FLOAT *pOut, CONST D3DXFLOAT16 *pIn, UINT n ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// 2D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec2Length - ( CONST D3DXVECTOR2 *pV ); - -FLOAT D3DXVec2LengthSq - ( CONST D3DXVECTOR2 *pV ); - -FLOAT D3DXVec2Dot - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Z component of ((x1,y1,0) cross (x2,y2,0)) -FLOAT D3DXVec2CCW - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Add - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Subtract - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2) -D3DXVECTOR2* D3DXVec2Minimize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2) -D3DXVECTOR2* D3DXVec2Maximize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Scale - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR2* D3DXVec2Lerp - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -D3DXVECTOR2* WINAPI D3DXVec2Normalize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR2* WINAPI D3DXVec2Hermite - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, - CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR2* WINAPI D3DXVec2CatmullRom - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, - CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR2* WINAPI D3DXVec2BaryCentric - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, - CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); - -// Transform (x, y, 0, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec2Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, 0, 1) by matrix, project result back into w=1. -D3DXVECTOR2* WINAPI D3DXVec2TransformCoord - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, 0, 0) by matrix. -D3DXVECTOR2* WINAPI D3DXVec2TransformNormal - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -// Transform Array (x, y, 0, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec2TransformArray - ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n); - -// Transform Array (x, y, 0, 1) by matrix, project result back into w=1. -D3DXVECTOR2* WINAPI D3DXVec2TransformCoordArray - ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); - -// Transform Array (x, y, 0, 0) by matrix. -D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray - ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); - - - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// 3D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec3Length - ( CONST D3DXVECTOR3 *pV ); - -FLOAT D3DXVec3LengthSq - ( CONST D3DXVECTOR3 *pV ); - -FLOAT D3DXVec3Dot - ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Cross - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Add - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Subtract - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... -D3DXVECTOR3* D3DXVec3Minimize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... -D3DXVECTOR3* D3DXVec3Maximize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Scale - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR3* D3DXVec3Lerp - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -D3DXVECTOR3* WINAPI D3DXVec3Normalize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR3* WINAPI D3DXVec3Hermite - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, - CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR3* WINAPI D3DXVec3CatmullRom - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, - CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR3* WINAPI D3DXVec3BaryCentric - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); - -// Transform (x, y, z, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec3Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, z, 1) by matrix, project result back into w=1. -D3DXVECTOR3* WINAPI D3DXVec3TransformCoord - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the -// transpose of the inverse of the matrix you would use to transform a coord. -D3DXVECTOR3* WINAPI D3DXVec3TransformNormal - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - - -// Transform Array (x, y, z, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec3TransformArray - ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); - -// Transform Array (x, y, z, 1) by matrix, project result back into w=1. -D3DXVECTOR3* WINAPI D3DXVec3TransformCoordArray - ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); - -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the -// transpose of the inverse of the matrix you would use to transform a coord. -D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray - ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); - -// Project vector from object space into screen space -D3DXVECTOR3* WINAPI D3DXVec3Project - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3D10_VIEWPORT *pViewport, - CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); - -// Project vector from screen space into object space -D3DXVECTOR3* WINAPI D3DXVec3Unproject - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3D10_VIEWPORT *pViewport, - CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); - -// Project vector Array from object space into screen space -D3DXVECTOR3* WINAPI D3DXVec3ProjectArray - ( D3DXVECTOR3 *pOut, UINT OutStride,CONST D3DXVECTOR3 *pV, UINT VStride,CONST D3D10_VIEWPORT *pViewport, - CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n); - -// Project vector Array from screen space into object space -D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray - ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3D10_VIEWPORT *pViewport, - CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n); - - -#ifdef __cplusplus -} -#endif - - - -//-------------------------- -// 4D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec4Length - ( CONST D3DXVECTOR4 *pV ); - -FLOAT D3DXVec4LengthSq - ( CONST D3DXVECTOR4 *pV ); - -FLOAT D3DXVec4Dot - ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ); - -D3DXVECTOR4* D3DXVec4Add - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -D3DXVECTOR4* D3DXVec4Subtract - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... -D3DXVECTOR4* D3DXVec4Minimize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... -D3DXVECTOR4* D3DXVec4Maximize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -D3DXVECTOR4* D3DXVec4Scale - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR4* D3DXVec4Lerp - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Cross-product in 4 dimensions. -D3DXVECTOR4* WINAPI D3DXVec4Cross - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - CONST D3DXVECTOR4 *pV3); - -D3DXVECTOR4* WINAPI D3DXVec4Normalize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR4* WINAPI D3DXVec4Hermite - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, - CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR4* WINAPI D3DXVec4CatmullRom - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, - CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR4* WINAPI D3DXVec4BaryCentric - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); - -// Transform vector by matrix. -D3DXVECTOR4* WINAPI D3DXVec4Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); - -// Transform vector array by matrix. -D3DXVECTOR4* WINAPI D3DXVec4TransformArray - ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR4 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// 4D Matrix -//-------------------------- - -// inline - -D3DXMATRIX* D3DXMatrixIdentity - ( D3DXMATRIX *pOut ); - -BOOL D3DXMatrixIsIdentity - ( CONST D3DXMATRIX *pM ); - - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -FLOAT WINAPI D3DXMatrixDeterminant - ( CONST D3DXMATRIX *pM ); - -HRESULT WINAPI D3DXMatrixDecompose - ( D3DXVECTOR3 *pOutScale, D3DXQUATERNION *pOutRotation, - D3DXVECTOR3 *pOutTranslation, CONST D3DXMATRIX *pM ); - -D3DXMATRIX* WINAPI D3DXMatrixTranspose - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); - -// Matrix multiplication. The result represents the transformation M2 -// followed by the transformation M1. (Out = M1 * M2) -D3DXMATRIX* WINAPI D3DXMatrixMultiply - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); - -// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) -D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); - -// Calculate inverse of matrix. Inversion my fail, in which case NULL will -// be returned. The determinant of pM is also returned it pfDeterminant -// is non-NULL. -D3DXMATRIX* WINAPI D3DXMatrixInverse - ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); - -// Build a matrix which scales by (sx, sy, sz) -D3DXMATRIX* WINAPI D3DXMatrixScaling - ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); - -// Build a matrix which translates by (x, y, z) -D3DXMATRIX* WINAPI D3DXMatrixTranslation - ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); - -// Build a matrix which rotates around the X axis -D3DXMATRIX* WINAPI D3DXMatrixRotationX - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around the Y axis -D3DXMATRIX* WINAPI D3DXMatrixRotationY - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around the Z axis -D3DXMATRIX* WINAPI D3DXMatrixRotationZ - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around an arbitrary axis -D3DXMATRIX* WINAPI D3DXMatrixRotationAxis - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); - -// Build a matrix from a quaternion -D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion - ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); - -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. -D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll - ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); - -// Build transformation matrix. NULL arguments are treated as identity. -// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixTransformation - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, - CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, - CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, - CONST D3DXVECTOR3 *pTranslation); - -// Build 2D transformation matrix in XY plane. NULL arguments are treated as identity. -// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixTransformation2D - ( D3DXMATRIX *pOut, CONST D3DXVECTOR2* pScalingCenter, - FLOAT ScalingRotation, CONST D3DXVECTOR2* pScaling, - CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, - CONST D3DXVECTOR2* pTranslation); - -// Build affine transformation matrix. NULL arguments are treated as identity. -// Mout = Ms * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation - ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, - CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); - -// Build 2D affine transformation matrix in XY plane. NULL arguments are treated as identity. -// Mout = Ms * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation2D - ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR2* pRotationCenter, - FLOAT Rotation, CONST D3DXVECTOR2* pTranslation); - -// Build a lookat matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixLookAtRH - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, - CONST D3DXVECTOR3 *pUp ); - -// Build a lookat matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixLookAtLH - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, - CONST D3DXVECTOR3 *pUp ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH - ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH - ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build an ortho projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoRH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build an ortho projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoLH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build an ortho projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build an ortho projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build a matrix which flattens geometry into a plane, as if casting -// a shadow from a light. -D3DXMATRIX* WINAPI D3DXMatrixShadow - ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, - CONST D3DXPLANE *pPlane ); - -// Build a matrix which reflects the coordinate system about a plane -D3DXMATRIX* WINAPI D3DXMatrixReflect - ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Quaternion -//-------------------------- - -// inline - -FLOAT D3DXQuaternionLength - ( CONST D3DXQUATERNION *pQ ); - -// Length squared, or "norm" -FLOAT D3DXQuaternionLengthSq - ( CONST D3DXQUATERNION *pQ ); - -FLOAT D3DXQuaternionDot - ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); - -// (0, 0, 0, 1) -D3DXQUATERNION* D3DXQuaternionIdentity - ( D3DXQUATERNION *pOut ); - -BOOL D3DXQuaternionIsIdentity - ( CONST D3DXQUATERNION *pQ ); - -// (-x, -y, -z, w) -D3DXQUATERNION* D3DXQuaternionConjugate - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. -void WINAPI D3DXQuaternionToAxisAngle - ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); - -// Build a quaternion from a rotation matrix. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix - ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); - -// Rotation about arbitrary axis. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis - ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); - -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll - ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); - -// Quaternion multiplication. The result represents the rotation Q2 -// followed by the rotation Q1. (Out = Q2 * Q1) -D3DXQUATERNION* WINAPI D3DXQuaternionMultiply - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2 ); - -D3DXQUATERNION* WINAPI D3DXQuaternionNormalize - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Conjugate and re-norm -D3DXQUATERNION* WINAPI D3DXQuaternionInverse - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Expects unit quaternions. -// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) -D3DXQUATERNION* WINAPI D3DXQuaternionLn - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Expects pure quaternions. (w == 0) w is ignored in calculation. -// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) -D3DXQUATERNION* WINAPI D3DXQuaternionExp - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). -// Expects unit quaternions. -D3DXQUATERNION* WINAPI D3DXQuaternionSlerp - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, FLOAT t ); - -// Spherical quadrangle interpolation. -// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) -D3DXQUATERNION* WINAPI D3DXQuaternionSquad - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, - CONST D3DXQUATERNION *pC, FLOAT t ); - -// Setup control points for spherical quadrangle interpolation -// from Q1 to Q2. The control points are chosen in such a way -// to ensure the continuity of tangents with adjacent segments. -void WINAPI D3DXQuaternionSquadSetup - ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, - CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); - -// Barycentric interpolation. -// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) -D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, - FLOAT f, FLOAT g ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Plane -//-------------------------- - -// inline - -// ax + by + cz + dw -FLOAT D3DXPlaneDot - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); - -// ax + by + cz + d -FLOAT D3DXPlaneDotCoord - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); - -// ax + by + cz -FLOAT D3DXPlaneDotNormal - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); - -D3DXPLANE* D3DXPlaneScale - (D3DXPLANE *pOut, CONST D3DXPLANE *pP, FLOAT s); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Normalize plane (so that |a,b,c| == 1) -D3DXPLANE* WINAPI D3DXPlaneNormalize - ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); - -// Find the intersection between a plane and a line. If the line is -// parallel to the plane, NULL is returned. -D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine - ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, - CONST D3DXVECTOR3 *pV2); - -// Construct a plane from a point and a normal -D3DXPLANE* WINAPI D3DXPlaneFromPointNormal - ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); - -// Construct a plane from 3 points -D3DXPLANE* WINAPI D3DXPlaneFromPoints - ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - CONST D3DXVECTOR3 *pV3); - -// 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* WINAPI D3DXPlaneTransform - ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); - -// Transform an array of planes by a matrix. The vectors (a,b,c) must be normal. -// M should be the inverse transpose of the transformation desired. -D3DXPLANE* WINAPI D3DXPlaneTransformArray - ( D3DXPLANE *pOut, UINT OutStride, CONST D3DXPLANE *pP, UINT PStride, CONST D3DXMATRIX *pM, UINT n ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Color -//-------------------------- - -// inline - -// (1-r, 1-g, 1-b, a) -D3DXCOLOR* D3DXColorNegative - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); - -D3DXCOLOR* D3DXColorAdd - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -D3DXCOLOR* D3DXColorSubtract - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -D3DXCOLOR* D3DXColorScale - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); - -// (r1*r2, g1*g2, b1*b2, a1*a2) -D3DXCOLOR* D3DXColorModulate - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) -D3DXCOLOR* D3DXColorLerp - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Interpolate r,g,b between desaturated color and color. -// DesaturatedColor + s(Color - DesaturatedColor) -D3DXCOLOR* WINAPI D3DXColorAdjustSaturation - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); - -// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) -D3DXCOLOR* WINAPI D3DXColorAdjustContrast - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); - -#ifdef __cplusplus -} -#endif - - - - -//-------------------------- -// Misc -//-------------------------- - -#ifdef __cplusplus -extern "C" { -#endif - -// Calculate Fresnel term given the cosine of theta (likely obtained by -// taking the dot of two normals), and the refraction index of the material. -FLOAT WINAPI D3DXFresnelTerm - (FLOAT CosTheta, FLOAT RefractionIndex); - -#ifdef __cplusplus -} -#endif - - - -//=========================================================================== -// -// Matrix Stack -// -//=========================================================================== - -typedef interface ID3DXMatrixStack ID3DXMatrixStack; -typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; - -// {C7885BA7-F990-4fe7-922D-8515E477DD85} -DEFINE_GUID(IID_ID3DXMatrixStack, -0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85); - - -#undef INTERFACE -#define INTERFACE ID3DXMatrixStack - -DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) -{ - // - // IUnknown methods - // - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - // - // ID3DXMatrixStack methods - // - - // Pops the top of the stack, returns the current top - // *after* popping the top. - STDMETHOD(Pop)(THIS) PURE; - - // Pushes the stack by one, duplicating the current matrix. - STDMETHOD(Push)(THIS) PURE; - - // Loads identity in the current matrix. - STDMETHOD(LoadIdentity)(THIS) PURE; - - // Loads the given matrix into the current matrix - STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Right-Multiplies the given matrix to the current matrix. - // (transformation is about the current world origin) - STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Left-Multiplies the given matrix to the current matrix - // (transformation is about the local origin of the object) - STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Right multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the current world origin) - STDMETHOD(RotateAxis) - (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - - // 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) - STDMETHOD(RotateAxisLocal) - (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - - // Right multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // current world origin) - - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. - STDMETHOD(RotateYawPitchRoll) - (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - - // Left multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // local origin of the object) - - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. - STDMETHOD(RotateYawPitchRollLocal) - (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - - // Right multiply the current matrix with the computed scale - // matrix. (transformation is about the current world origin) - STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - // Left multiply the current matrix with the computed scale - // matrix. (transformation is about the local origin of the object) - STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - // Right multiply the current matrix with the computed translation - // matrix. (transformation is about the current world origin) - STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; - - // Left multiply the current matrix with the computed translation - // matrix. (transformation is about the local origin of the object) - STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - // Obtain the current matrix at the top of the stack - STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; -}; - -#ifdef __cplusplus -extern "C" { -#endif - -HRESULT WINAPI - D3DXCreateMatrixStack( - UINT Flags, - LPD3DXMATRIXSTACK* ppStack); - -#ifdef __cplusplus -} -#endif - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -//============================================================================ -// -// Basic Spherical Harmonic math routines -// -//============================================================================ - -#define D3DXSH_MINORDER 2 -#define D3DXSH_MAXORDER 6 - -//============================================================================ -// -// D3DXSHEvalDirection: -// -------------------- -// Evaluates the Spherical Harmonic basis functions -// -// Parameters: -// pOut -// Output SH coefficients - basis function Ylm is stored at l*l + m+l -// This is the pointer that is returned. -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pDir -// Direction to evaluate in - assumed to be normalized -// -//============================================================================ - -FLOAT* WINAPI D3DXSHEvalDirection - ( FLOAT *pOut, UINT Order, CONST D3DXVECTOR3 *pDir ); - -//============================================================================ -// -// D3DXSHRotate: -// -------------------- -// Rotates SH vector by a rotation matrix -// -// Parameters: -// pOut -// Output SH coefficients - basis function Ylm is stored at l*l + m+l -// This is the pointer that is returned (should not alias with pIn.) -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pMatrix -// Matrix used for rotation - rotation sub matrix should be orthogonal -// and have a unit determinant. -// pIn -// Input SH coeffs (rotated), incorect results if this is also output. -// -//============================================================================ - -FLOAT* WINAPI D3DXSHRotate - ( FLOAT *pOut, UINT Order, CONST D3DXMATRIX *pMatrix, CONST FLOAT *pIn ); - -//============================================================================ -// -// D3DXSHRotateZ: -// -------------------- -// Rotates the SH vector in the Z axis by an angle -// -// Parameters: -// pOut -// Output SH coefficients - basis function Ylm is stored at l*l + m+l -// This is the pointer that is returned (should not alias with pIn.) -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// Angle -// Angle in radians to rotate around the Z axis. -// pIn -// Input SH coeffs (rotated), incorect results if this is also output. -// -//============================================================================ - - -FLOAT* WINAPI D3DXSHRotateZ - ( FLOAT *pOut, UINT Order, FLOAT Angle, CONST FLOAT *pIn ); - -//============================================================================ -// -// D3DXSHAdd: -// -------------------- -// Adds two SH vectors, pOut[i] = pA[i] + pB[i]; -// -// Parameters: -// pOut -// Output SH coefficients - basis function Ylm is stored at l*l + m+l -// This is the pointer that is returned. -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pA -// Input SH coeffs. -// pB -// Input SH coeffs (second vector.) -// -//============================================================================ - -FLOAT* WINAPI D3DXSHAdd - ( FLOAT *pOut, UINT Order, CONST FLOAT *pA, CONST FLOAT *pB ); - -//============================================================================ -// -// D3DXSHScale: -// -------------------- -// Adds two SH vectors, pOut[i] = pA[i]*Scale; -// -// Parameters: -// pOut -// Output SH coefficients - basis function Ylm is stored at l*l + m+l -// This is the pointer that is returned. -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pIn -// Input SH coeffs. -// Scale -// Scale factor. -// -//============================================================================ - -FLOAT* WINAPI D3DXSHScale - ( FLOAT *pOut, UINT Order, CONST FLOAT *pIn, CONST FLOAT Scale ); - -//============================================================================ -// -// D3DXSHDot: -// -------------------- -// Computes the dot product of two SH vectors -// -// Parameters: -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pA -// Input SH coeffs. -// pB -// Second set of input SH coeffs. -// -//============================================================================ - -FLOAT WINAPI D3DXSHDot - ( UINT Order, CONST FLOAT *pA, CONST FLOAT *pB ); - -//============================================================================ -// -// Basic Spherical Harmonic lighting routines -// -//============================================================================ - -//============================================================================ -// -// D3DXSHEvalDirectionalLight: -// -------------------- -// Evaluates a directional light and returns spectral SH data. The output -// vector is computed so that if the intensity of R/G/B is unit the resulting -// exit radiance of a point directly under the light on a diffuse object with -// an albedo of 1 would be 1.0. This will compute 3 spectral samples, pROut -// has to be specified, while pGout and pBout are optional. -// -// Parameters: -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pDir -// Direction light is coming from (assumed to be normalized.) -// RIntensity -// Red intensity of light. -// GIntensity -// Green intensity of light. -// BIntensity -// Blue intensity of light. -// pROut -// Output SH vector for Red. -// pGOut -// Output SH vector for Green (optional.) -// pBOut -// Output SH vector for Blue (optional.) -// -//============================================================================ - -HRESULT WINAPI D3DXSHEvalDirectionalLight - ( UINT Order, CONST D3DXVECTOR3 *pDir, - FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, - FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); - -//============================================================================ -// -// D3DXSHEvalSphericalLight: -// -------------------- -// Evaluates a spherical light and returns spectral SH data. There is no -// normalization of the intensity of the light like there is for directional -// lights, care has to be taken when specifiying the intensities. This will -// compute 3 spectral samples, pROut has to be specified, while pGout and -// pBout are optional. -// -// Parameters: -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pPos -// Position of light - reciever is assumed to be at the origin. -// Radius -// Radius of the spherical light source. -// RIntensity -// Red intensity of light. -// GIntensity -// Green intensity of light. -// BIntensity -// Blue intensity of light. -// pROut -// Output SH vector for Red. -// pGOut -// Output SH vector for Green (optional.) -// pBOut -// Output SH vector for Blue (optional.) -// -//============================================================================ - -HRESULT WINAPI D3DXSHEvalSphericalLight - ( UINT Order, CONST D3DXVECTOR3 *pPos, FLOAT Radius, - FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, - FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); - -//============================================================================ -// -// D3DXSHEvalConeLight: -// -------------------- -// Evaluates a light that is a cone of constant intensity and returns spectral -// SH data. The output vector is computed so that if the intensity of R/G/B is -// unit the resulting exit radiance of a point directly under the light oriented -// in the cone direction on a diffuse object with an albedo of 1 would be 1.0. -// This will compute 3 spectral samples, pROut has to be specified, while pGout -// and pBout are optional. -// -// Parameters: -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pDir -// Direction light is coming from (assumed to be normalized.) -// Radius -// Radius of cone in radians. -// RIntensity -// Red intensity of light. -// GIntensity -// Green intensity of light. -// BIntensity -// Blue intensity of light. -// pROut -// Output SH vector for Red. -// pGOut -// Output SH vector for Green (optional.) -// pBOut -// Output SH vector for Blue (optional.) -// -//============================================================================ - -HRESULT WINAPI D3DXSHEvalConeLight - ( UINT Order, CONST D3DXVECTOR3 *pDir, FLOAT Radius, - FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, - FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); - -//============================================================================ -// -// D3DXSHEvalHemisphereLight: -// -------------------- -// Evaluates a light that is a linear interpolant between two colors over the -// sphere. The interpolant is linear along the axis of the two points, not -// over the surface of the sphere (ie: if the axis was (0,0,1) it is linear in -// Z, not in the azimuthal angle.) The resulting spherical lighting function -// is normalized so that a point on a perfectly diffuse surface with no -// shadowing and a normal pointed in the direction pDir would result in exit -// radiance with a value of 1 if the top color was white and the bottom color -// was black. This is a very simple model where Top represents the intensity -// of the "sky" and Bottom represents the intensity of the "ground". -// -// Parameters: -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pDir -// Axis of the hemisphere. -// Top -// Color of the upper hemisphere. -// Bottom -// Color of the lower hemisphere. -// pROut -// Output SH vector for Red. -// pGOut -// Output SH vector for Green -// pBOut -// Output SH vector for Blue -// -//============================================================================ - -HRESULT WINAPI D3DXSHEvalHemisphereLight - ( UINT Order, CONST D3DXVECTOR3 *pDir, D3DXCOLOR Top, D3DXCOLOR Bottom, - FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); - -// Math intersection functions - -BOOL WINAPI D3DXIntersectTri -( - CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position - CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position - CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position - CONST D3DXVECTOR3 *pRayPos, // Ray origin - CONST D3DXVECTOR3 *pRayDir, // Ray direction - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist); // Ray-Intersection Parameter Distance - -BOOL WINAPI - D3DXSphereBoundProbe( - CONST D3DXVECTOR3 *pCenter, - FLOAT Radius, - CONST D3DXVECTOR3 *pRayPosition, - CONST D3DXVECTOR3 *pRayDirection); - -BOOL WINAPI - D3DXBoxBoundProbe( - CONST D3DXVECTOR3 *pMin, - CONST D3DXVECTOR3 *pMax, - CONST D3DXVECTOR3 *pRayPosition, - CONST D3DXVECTOR3 *pRayDirection); - -HRESULT WINAPI - D3DXComputeBoundingSphere( - CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position - DWORD NumVertices, - DWORD dwStride, // count in bytes to subsequent position vectors - D3DXVECTOR3 *pCenter, - FLOAT *pRadius); - -HRESULT WINAPI - D3DXComputeBoundingBox( - CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position - DWORD NumVertices, - DWORD dwStride, // count in bytes to subsequent position vectors - D3DXVECTOR3 *pMin, - D3DXVECTOR3 *pMax); - - -#ifdef __cplusplus -} -#endif - - -#include "D3DX10math.inl" - -#if _MSC_VER >= 1200 -#pragma warning(pop) -#else -#pragma warning(default:4201) -#endif - -#endif // __D3DX9MATH_H__ - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: D3DX10math.h +// Content: D3DX10 math types and functions +// +////////////////////////////////////////////////////////////////////////////// + +#include "D3DX10.h" + +// D3DX10 and D3DX9 math look the same. You can include either one into your project. +// We are intentionally using the header define from D3DX9 math to prevent double-inclusion. +#ifndef __D3DX9MATH_H__ +#define __D3DX9MATH_H__ + +#include +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif +#pragma warning(disable:4201) // anonymous unions warning + +//=========================================================================== +// +// Type definitions from D3D9 +// +//=========================================================================== + +#ifndef D3DVECTOR_DEFINED +typedef struct _D3DVECTOR { + float x; + float y; + float z; +} D3DVECTOR; +#define D3DVECTOR_DEFINED +#endif + +#ifndef D3DMATRIX_DEFINED +typedef struct _D3DMATRIX { + union { + struct { + float _11, _12, _13, _14; + float _21, _22, _23, _24; + float _31, _32, _33, _34; + float _41, _42, _43, _44; + + }; + float m[4][4]; + }; +} D3DMATRIX; +#define D3DMATRIX_DEFINED +#endif + +//=========================================================================== +// +// General purpose utilities +// +//=========================================================================== +#define D3DX_PI ((FLOAT) 3.141592654f) +#define D3DX_1BYPI ((FLOAT) 0.318309886f) + +#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) +#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) + + + +//=========================================================================== +// +// 16 bit floating point numbers +// +//=========================================================================== + +#define D3DX_16F_DIG 3 // # of decimal digits of precision +#define D3DX_16F_EPSILON 4.8875809e-4f // smallest such that 1.0 + epsilon != 1.0 +#define D3DX_16F_MANT_DIG 11 // # of bits in mantissa +#define D3DX_16F_MAX 6.550400e+004 // max value +#define D3DX_16F_MAX_10_EXP 4 // max decimal exponent +#define D3DX_16F_MAX_EXP 15 // max binary exponent +#define D3DX_16F_MIN 6.1035156e-5f // min positive value +#define D3DX_16F_MIN_10_EXP (-4) // min decimal exponent +#define D3DX_16F_MIN_EXP (-12) // min binary exponent +#define D3DX_16F_RADIX 2 // exponent radix +#define D3DX_16F_ROUNDS 1 // addition rounding: near + + +typedef struct D3DXFLOAT16 +{ +#ifdef __cplusplus +public: + D3DXFLOAT16() {}; + D3DXFLOAT16( FLOAT ); + D3DXFLOAT16( CONST D3DXFLOAT16& ); + + // casting + operator FLOAT (); + + // binary operators + BOOL operator == ( CONST D3DXFLOAT16& ) const; + BOOL operator != ( CONST D3DXFLOAT16& ) const; + +protected: +#endif //__cplusplus + WORD value; +} D3DXFLOAT16, *LPD3DXFLOAT16; + + + +//=========================================================================== +// +// Vectors +// +//=========================================================================== + + +//-------------------------- +// 2D Vector +//-------------------------- +typedef struct D3DXVECTOR2 +{ +#ifdef __cplusplus +public: + D3DXVECTOR2() {}; + D3DXVECTOR2( CONST FLOAT * ); + D3DXVECTOR2( CONST D3DXFLOAT16 * ); + D3DXVECTOR2( FLOAT x, FLOAT y ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR2& operator += ( CONST D3DXVECTOR2& ); + D3DXVECTOR2& operator -= ( CONST D3DXVECTOR2& ); + D3DXVECTOR2& operator *= ( FLOAT ); + D3DXVECTOR2& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR2 operator + () const; + D3DXVECTOR2 operator - () const; + + // binary operators + D3DXVECTOR2 operator + ( CONST D3DXVECTOR2& ) const; + D3DXVECTOR2 operator - ( CONST D3DXVECTOR2& ) const; + D3DXVECTOR2 operator * ( FLOAT ) const; + D3DXVECTOR2 operator / ( FLOAT ) const; + + friend D3DXVECTOR2 operator * ( FLOAT, CONST D3DXVECTOR2& ); + + BOOL operator == ( CONST D3DXVECTOR2& ) const; + BOOL operator != ( CONST D3DXVECTOR2& ) const; + + +public: +#endif //__cplusplus + FLOAT x, y; +} D3DXVECTOR2, *LPD3DXVECTOR2; + + + +//-------------------------- +// 2D Vector (16 bit) +//-------------------------- + +typedef struct D3DXVECTOR2_16F +{ +#ifdef __cplusplus +public: + D3DXVECTOR2_16F() {}; + D3DXVECTOR2_16F( CONST FLOAT * ); + D3DXVECTOR2_16F( CONST D3DXFLOAT16 * ); + D3DXVECTOR2_16F( CONST D3DXFLOAT16 &x, CONST D3DXFLOAT16 &y ); + + // casting + operator D3DXFLOAT16* (); + operator CONST D3DXFLOAT16* () const; + + // binary operators + BOOL operator == ( CONST D3DXVECTOR2_16F& ) const; + BOOL operator != ( CONST D3DXVECTOR2_16F& ) const; + +public: +#endif //__cplusplus + D3DXFLOAT16 x, y; + +} D3DXVECTOR2_16F, *LPD3DXVECTOR2_16F; + + + +//-------------------------- +// 3D Vector +//-------------------------- +#ifdef __cplusplus +typedef struct D3DXVECTOR3 : public D3DVECTOR +{ +public: + D3DXVECTOR3() {}; + D3DXVECTOR3( CONST FLOAT * ); + D3DXVECTOR3( CONST D3DVECTOR& ); + D3DXVECTOR3( CONST D3DXFLOAT16 * ); + D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); + D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& ); + D3DXVECTOR3& operator *= ( FLOAT ); + D3DXVECTOR3& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR3 operator + () const; + D3DXVECTOR3 operator - () const; + + // binary operators + D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const; + D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const; + D3DXVECTOR3 operator * ( FLOAT ) const; + D3DXVECTOR3 operator / ( FLOAT ) const; + + friend D3DXVECTOR3 operator * ( FLOAT, CONST struct D3DXVECTOR3& ); + + BOOL operator == ( CONST D3DXVECTOR3& ) const; + BOOL operator != ( CONST D3DXVECTOR3& ) const; + +} D3DXVECTOR3, *LPD3DXVECTOR3; + +#else //!__cplusplus +typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; +#endif //!__cplusplus + + + +//-------------------------- +// 3D Vector (16 bit) +//-------------------------- +typedef struct D3DXVECTOR3_16F +{ +#ifdef __cplusplus +public: + D3DXVECTOR3_16F() {}; + D3DXVECTOR3_16F( CONST FLOAT * ); + D3DXVECTOR3_16F( CONST D3DVECTOR& ); + D3DXVECTOR3_16F( CONST D3DXFLOAT16 * ); + D3DXVECTOR3_16F( CONST D3DXFLOAT16 &x, CONST D3DXFLOAT16 &y, CONST D3DXFLOAT16 &z ); + + // casting + operator D3DXFLOAT16* (); + operator CONST D3DXFLOAT16* () const; + + // binary operators + BOOL operator == ( CONST D3DXVECTOR3_16F& ) const; + BOOL operator != ( CONST D3DXVECTOR3_16F& ) const; + +public: +#endif //__cplusplus + D3DXFLOAT16 x, y, z; + +} D3DXVECTOR3_16F, *LPD3DXVECTOR3_16F; + + + +//-------------------------- +// 4D Vector +//-------------------------- +typedef struct D3DXVECTOR4 +{ +#ifdef __cplusplus +public: + D3DXVECTOR4() {}; + D3DXVECTOR4( CONST FLOAT* ); + D3DXVECTOR4( CONST D3DXFLOAT16* ); + D3DXVECTOR4( CONST D3DVECTOR& xyz, FLOAT w ); + D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& ); + D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& ); + D3DXVECTOR4& operator *= ( FLOAT ); + D3DXVECTOR4& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR4 operator + () const; + D3DXVECTOR4 operator - () const; + + // binary operators + D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const; + D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const; + D3DXVECTOR4 operator * ( FLOAT ) const; + D3DXVECTOR4 operator / ( FLOAT ) const; + + friend D3DXVECTOR4 operator * ( FLOAT, CONST D3DXVECTOR4& ); + + BOOL operator == ( CONST D3DXVECTOR4& ) const; + BOOL operator != ( CONST D3DXVECTOR4& ) const; + +public: +#endif //__cplusplus + FLOAT x, y, z, w; +} D3DXVECTOR4, *LPD3DXVECTOR4; + + +//-------------------------- +// 4D Vector (16 bit) +//-------------------------- +typedef struct D3DXVECTOR4_16F +{ +#ifdef __cplusplus +public: + D3DXVECTOR4_16F() {}; + D3DXVECTOR4_16F( CONST FLOAT * ); + D3DXVECTOR4_16F( CONST D3DXFLOAT16* ); + D3DXVECTOR4_16F( CONST D3DXVECTOR3_16F& xyz, CONST D3DXFLOAT16& w ); + D3DXVECTOR4_16F( CONST D3DXFLOAT16& x, CONST D3DXFLOAT16& y, CONST D3DXFLOAT16& z, CONST D3DXFLOAT16& w ); + + // casting + operator D3DXFLOAT16* (); + operator CONST D3DXFLOAT16* () const; + + // binary operators + BOOL operator == ( CONST D3DXVECTOR4_16F& ) const; + BOOL operator != ( CONST D3DXVECTOR4_16F& ) const; + +public: +#endif //__cplusplus + D3DXFLOAT16 x, y, z, w; + +} D3DXVECTOR4_16F, *LPD3DXVECTOR4_16F; + + + +//=========================================================================== +// +// Matrices +// +//=========================================================================== +#ifdef __cplusplus +typedef struct D3DXMATRIX : public D3DMATRIX +{ +public: + D3DXMATRIX() {}; + D3DXMATRIX( CONST FLOAT * ); + D3DXMATRIX( CONST D3DMATRIX& ); + D3DXMATRIX( CONST D3DXFLOAT16 * ); + D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, + FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, + FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, + FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); + + + // access grants + FLOAT& operator () ( UINT Row, UINT Col ); + FLOAT operator () ( UINT Row, UINT Col ) const; + + // casting operators + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXMATRIX& operator *= ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator += ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator -= ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator *= ( FLOAT ); + D3DXMATRIX& operator /= ( FLOAT ); + + // unary operators + D3DXMATRIX operator + () const; + D3DXMATRIX operator - () const; + + // binary operators + D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator * ( FLOAT ) const; + D3DXMATRIX operator / ( FLOAT ) const; + + friend D3DXMATRIX operator * ( FLOAT, CONST D3DXMATRIX& ); + + BOOL operator == ( CONST D3DXMATRIX& ) const; + BOOL operator != ( CONST D3DXMATRIX& ) const; + +} D3DXMATRIX, *LPD3DXMATRIX; + +#else //!__cplusplus +typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; +#endif //!__cplusplus + + +//--------------------------------------------------------------------------- +// Aligned Matrices +// +// This class helps keep matrices 16-byte aligned as preferred by P4 cpus. +// It aligns matrices on the stack and on the heap or in global scope. +// It does this using __declspec(align(16)) which works on VC7 and on VC 6 +// with the processor pack. Unfortunately there is no way to detect the +// latter so this is turned on only on VC7. On other compilers this is the +// the same as D3DXMATRIX. +// +// Using this class on a compiler that does not actually do the alignment +// can be dangerous since it will not expose bugs that ignore alignment. +// E.g if an object of this class in inside a struct or class, and some code +// memcopys data in it assuming tight packing. This could break on a compiler +// that eventually start aligning the matrix. +//--------------------------------------------------------------------------- +#ifdef __cplusplus +typedef struct _D3DXMATRIXA16 : public D3DXMATRIX +{ + _D3DXMATRIXA16() {}; + _D3DXMATRIXA16( CONST FLOAT * ); + _D3DXMATRIXA16( CONST D3DMATRIX& ); + _D3DXMATRIXA16( CONST D3DXFLOAT16 * ); + _D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, + FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, + FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, + FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); + + // new operators + void* operator new ( size_t ); + void* operator new[] ( size_t ); + + // delete operators + void operator delete ( void* ); // These are NOT virtual; Do not + void operator delete[] ( void* ); // cast to D3DXMATRIX and delete. + + // assignment operators + _D3DXMATRIXA16& operator = ( CONST D3DXMATRIX& ); + +} _D3DXMATRIXA16; + +#else //!__cplusplus +typedef D3DXMATRIX _D3DXMATRIXA16; +#endif //!__cplusplus + + + +#if _MSC_VER >= 1300 // VC7 +#define D3DX_ALIGN16 __declspec(align(16)) +#else +#define D3DX_ALIGN16 // Earlier compiler may not understand this, do nothing. +#endif + +typedef D3DX_ALIGN16 _D3DXMATRIXA16 D3DXMATRIXA16, *LPD3DXMATRIXA16; + + + +//=========================================================================== +// +// Quaternions +// +//=========================================================================== +typedef struct D3DXQUATERNION +{ +#ifdef __cplusplus +public: + D3DXQUATERNION() {}; + D3DXQUATERNION( CONST FLOAT * ); + D3DXQUATERNION( CONST D3DXFLOAT16 * ); + D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXQUATERNION& operator += ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator -= ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator *= ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator *= ( FLOAT ); + D3DXQUATERNION& operator /= ( FLOAT ); + + // unary operators + D3DXQUATERNION operator + () const; + D3DXQUATERNION operator - () const; + + // binary operators + D3DXQUATERNION operator + ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator - ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator * ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator * ( FLOAT ) const; + D3DXQUATERNION operator / ( FLOAT ) const; + + friend D3DXQUATERNION operator * (FLOAT, CONST D3DXQUATERNION& ); + + BOOL operator == ( CONST D3DXQUATERNION& ) const; + BOOL operator != ( CONST D3DXQUATERNION& ) const; + +#endif //__cplusplus + FLOAT x, y, z, w; +} D3DXQUATERNION, *LPD3DXQUATERNION; + + +//=========================================================================== +// +// Planes +// +//=========================================================================== +typedef struct D3DXPLANE +{ +#ifdef __cplusplus +public: + D3DXPLANE() {}; + D3DXPLANE( CONST FLOAT* ); + D3DXPLANE( CONST D3DXFLOAT16* ); + D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXPLANE& operator *= ( FLOAT ); + D3DXPLANE& operator /= ( FLOAT ); + + // unary operators + D3DXPLANE operator + () const; + D3DXPLANE operator - () const; + + // binary operators + D3DXPLANE operator * ( FLOAT ) const; + D3DXPLANE operator / ( FLOAT ) const; + + friend D3DXPLANE operator * ( FLOAT, CONST D3DXPLANE& ); + + BOOL operator == ( CONST D3DXPLANE& ) const; + BOOL operator != ( CONST D3DXPLANE& ) const; + +#endif //__cplusplus + FLOAT a, b, c, d; +} D3DXPLANE, *LPD3DXPLANE; + + +//=========================================================================== +// +// Colors +// +//=========================================================================== + +typedef struct D3DXCOLOR +{ +#ifdef __cplusplus +public: + D3DXCOLOR() {}; + D3DXCOLOR( UINT argb ); + D3DXCOLOR( CONST FLOAT * ); + D3DXCOLOR( CONST D3DXFLOAT16 * ); + D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); + + // casting + operator UINT () const; + + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); + D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); + D3DXCOLOR& operator *= ( FLOAT ); + D3DXCOLOR& operator /= ( FLOAT ); + + // unary operators + D3DXCOLOR operator + () const; + D3DXCOLOR operator - () const; + + // binary operators + D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; + D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; + D3DXCOLOR operator * ( FLOAT ) const; + D3DXCOLOR operator / ( FLOAT ) const; + + friend D3DXCOLOR operator * ( FLOAT, CONST D3DXCOLOR& ); + + BOOL operator == ( CONST D3DXCOLOR& ) const; + BOOL operator != ( CONST D3DXCOLOR& ) const; + +#endif //__cplusplus + FLOAT r, g, b, a; +} D3DXCOLOR, *LPD3DXCOLOR; + + + +//=========================================================================== +// +// D3DX math functions: +// +// NOTE: +// * All these functions can take the same object as in and out parameters. +// +// * Out parameters are typically also returned as return values, so that +// the output of one function may be used as a parameter to another. +// +//=========================================================================== + +//-------------------------- +// Float16 +//-------------------------- + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Converts an array 32-bit floats to 16-bit floats +D3DXFLOAT16* WINAPI D3DXFloat32To16Array + ( D3DXFLOAT16 *pOut, CONST FLOAT *pIn, UINT n ); + +// Converts an array 16-bit floats to 32-bit floats +FLOAT* WINAPI D3DXFloat16To32Array + ( FLOAT *pOut, CONST D3DXFLOAT16 *pIn, UINT n ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 2D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec2Length + ( CONST D3DXVECTOR2 *pV ); + +FLOAT D3DXVec2LengthSq + ( CONST D3DXVECTOR2 *pV ); + +FLOAT D3DXVec2Dot + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Z component of ((x1,y1,0) cross (x2,y2,0)) +FLOAT D3DXVec2CCW + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Add + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Subtract + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2) +D3DXVECTOR2* D3DXVec2Minimize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2) +D3DXVECTOR2* D3DXVec2Maximize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Scale + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR2* D3DXVec2Lerp + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +D3DXVECTOR2* WINAPI D3DXVec2Normalize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR2* WINAPI D3DXVec2Hermite + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, + CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR2* WINAPI D3DXVec2CatmullRom + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, + CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR2* WINAPI D3DXVec2BaryCentric + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); + +// Transform (x, y, 0, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec2Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, 0, 1) by matrix, project result back into w=1. +D3DXVECTOR2* WINAPI D3DXVec2TransformCoord + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, 0, 0) by matrix. +D3DXVECTOR2* WINAPI D3DXVec2TransformNormal + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +// Transform Array (x, y, 0, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec2TransformArray + ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n); + +// Transform Array (x, y, 0, 1) by matrix, project result back into w=1. +D3DXVECTOR2* WINAPI D3DXVec2TransformCoordArray + ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); + +// Transform Array (x, y, 0, 0) by matrix. +D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray + ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); + + + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 3D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec3Length + ( CONST D3DXVECTOR3 *pV ); + +FLOAT D3DXVec3LengthSq + ( CONST D3DXVECTOR3 *pV ); + +FLOAT D3DXVec3Dot + ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Cross + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Add + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Subtract + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +D3DXVECTOR3* D3DXVec3Minimize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +D3DXVECTOR3* D3DXVec3Maximize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Scale + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR3* D3DXVec3Lerp + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +D3DXVECTOR3* WINAPI D3DXVec3Normalize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR3* WINAPI D3DXVec3Hermite + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, + CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR3* WINAPI D3DXVec3CatmullRom + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, + CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR3* WINAPI D3DXVec3BaryCentric + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); + +// Transform (x, y, z, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec3Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, z, 1) by matrix, project result back into w=1. +D3DXVECTOR3* WINAPI D3DXVec3TransformCoord + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, z, 0) by matrix. If you transforming a normal by a +// non-affine matrix, the matrix you pass to this function should be the +// transpose of the inverse of the matrix you would use to transform a coord. +D3DXVECTOR3* WINAPI D3DXVec3TransformNormal + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + + +// Transform Array (x, y, z, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec3TransformArray + ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); + +// Transform Array (x, y, z, 1) by matrix, project result back into w=1. +D3DXVECTOR3* WINAPI D3DXVec3TransformCoordArray + ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); + +// Transform (x, y, z, 0) by matrix. If you transforming a normal by a +// non-affine matrix, the matrix you pass to this function should be the +// transpose of the inverse of the matrix you would use to transform a coord. +D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray + ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); + +// Project vector from object space into screen space +D3DXVECTOR3* WINAPI D3DXVec3Project + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3D10_VIEWPORT *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); + +// Project vector from screen space into object space +D3DXVECTOR3* WINAPI D3DXVec3Unproject + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3D10_VIEWPORT *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); + +// Project vector Array from object space into screen space +D3DXVECTOR3* WINAPI D3DXVec3ProjectArray + ( D3DXVECTOR3 *pOut, UINT OutStride,CONST D3DXVECTOR3 *pV, UINT VStride,CONST D3D10_VIEWPORT *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n); + +// Project vector Array from screen space into object space +D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray + ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3D10_VIEWPORT *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n); + + +#ifdef __cplusplus +} +#endif + + + +//-------------------------- +// 4D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec4Length + ( CONST D3DXVECTOR4 *pV ); + +FLOAT D3DXVec4LengthSq + ( CONST D3DXVECTOR4 *pV ); + +FLOAT D3DXVec4Dot + ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ); + +D3DXVECTOR4* D3DXVec4Add + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +D3DXVECTOR4* D3DXVec4Subtract + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +D3DXVECTOR4* D3DXVec4Minimize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +D3DXVECTOR4* D3DXVec4Maximize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +D3DXVECTOR4* D3DXVec4Scale + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR4* D3DXVec4Lerp + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Cross-product in 4 dimensions. +D3DXVECTOR4* WINAPI D3DXVec4Cross + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + CONST D3DXVECTOR4 *pV3); + +D3DXVECTOR4* WINAPI D3DXVec4Normalize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR4* WINAPI D3DXVec4Hermite + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, + CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR4* WINAPI D3DXVec4CatmullRom + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, + CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR4* WINAPI D3DXVec4BaryCentric + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); + +// Transform vector by matrix. +D3DXVECTOR4* WINAPI D3DXVec4Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); + +// Transform vector array by matrix. +D3DXVECTOR4* WINAPI D3DXVec4TransformArray + ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR4 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 4D Matrix +//-------------------------- + +// inline + +D3DXMATRIX* D3DXMatrixIdentity + ( D3DXMATRIX *pOut ); + +BOOL D3DXMatrixIsIdentity + ( CONST D3DXMATRIX *pM ); + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +FLOAT WINAPI D3DXMatrixDeterminant + ( CONST D3DXMATRIX *pM ); + +HRESULT WINAPI D3DXMatrixDecompose + ( D3DXVECTOR3 *pOutScale, D3DXQUATERNION *pOutRotation, + D3DXVECTOR3 *pOutTranslation, CONST D3DXMATRIX *pM ); + +D3DXMATRIX* WINAPI D3DXMatrixTranspose + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); + +// Matrix multiplication. The result represents the transformation M2 +// followed by the transformation M1. (Out = M1 * M2) +D3DXMATRIX* WINAPI D3DXMatrixMultiply + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); + +// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) +D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); + +// Calculate inverse of matrix. Inversion my fail, in which case NULL will +// be returned. The determinant of pM is also returned it pfDeterminant +// is non-NULL. +D3DXMATRIX* WINAPI D3DXMatrixInverse + ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); + +// Build a matrix which scales by (sx, sy, sz) +D3DXMATRIX* WINAPI D3DXMatrixScaling + ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); + +// Build a matrix which translates by (x, y, z) +D3DXMATRIX* WINAPI D3DXMatrixTranslation + ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); + +// Build a matrix which rotates around the X axis +D3DXMATRIX* WINAPI D3DXMatrixRotationX + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around the Y axis +D3DXMATRIX* WINAPI D3DXMatrixRotationY + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around the Z axis +D3DXMATRIX* WINAPI D3DXMatrixRotationZ + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around an arbitrary axis +D3DXMATRIX* WINAPI D3DXMatrixRotationAxis + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); + +// Build a matrix from a quaternion +D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion + ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); + +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. +D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll + ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); + +// Build transformation matrix. NULL arguments are treated as identity. +// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixTransformation + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, + CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, + CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, + CONST D3DXVECTOR3 *pTranslation); + +// Build 2D transformation matrix in XY plane. NULL arguments are treated as identity. +// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixTransformation2D + ( D3DXMATRIX *pOut, CONST D3DXVECTOR2* pScalingCenter, + FLOAT ScalingRotation, CONST D3DXVECTOR2* pScaling, + CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, + CONST D3DXVECTOR2* pTranslation); + +// Build affine transformation matrix. NULL arguments are treated as identity. +// Mout = Ms * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation + ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, + CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); + +// Build 2D affine transformation matrix in XY plane. NULL arguments are treated as identity. +// Mout = Ms * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation2D + ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR2* pRotationCenter, + FLOAT Rotation, CONST D3DXVECTOR2* pTranslation); + +// Build a lookat matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixLookAtRH + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, + CONST D3DXVECTOR3 *pUp ); + +// Build a lookat matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixLookAtLH + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, + CONST D3DXVECTOR3 *pUp ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH + ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH + ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoRH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build an ortho projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoLH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build an ortho projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build a matrix which flattens geometry into a plane, as if casting +// a shadow from a light. +D3DXMATRIX* WINAPI D3DXMatrixShadow + ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, + CONST D3DXPLANE *pPlane ); + +// Build a matrix which reflects the coordinate system about a plane +D3DXMATRIX* WINAPI D3DXMatrixReflect + ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Quaternion +//-------------------------- + +// inline + +FLOAT D3DXQuaternionLength + ( CONST D3DXQUATERNION *pQ ); + +// Length squared, or "norm" +FLOAT D3DXQuaternionLengthSq + ( CONST D3DXQUATERNION *pQ ); + +FLOAT D3DXQuaternionDot + ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); + +// (0, 0, 0, 1) +D3DXQUATERNION* D3DXQuaternionIdentity + ( D3DXQUATERNION *pOut ); + +BOOL D3DXQuaternionIsIdentity + ( CONST D3DXQUATERNION *pQ ); + +// (-x, -y, -z, w) +D3DXQUATERNION* D3DXQuaternionConjugate + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. +void WINAPI D3DXQuaternionToAxisAngle + ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); + +// Build a quaternion from a rotation matrix. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix + ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); + +// Rotation about arbitrary axis. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis + ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); + +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll + ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); + +// Quaternion multiplication. The result represents the rotation Q2 +// followed by the rotation Q1. (Out = Q2 * Q1) +D3DXQUATERNION* WINAPI D3DXQuaternionMultiply + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2 ); + +D3DXQUATERNION* WINAPI D3DXQuaternionNormalize + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Conjugate and re-norm +D3DXQUATERNION* WINAPI D3DXQuaternionInverse + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Expects unit quaternions. +// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) +D3DXQUATERNION* WINAPI D3DXQuaternionLn + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Expects pure quaternions. (w == 0) w is ignored in calculation. +// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) +D3DXQUATERNION* WINAPI D3DXQuaternionExp + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). +// Expects unit quaternions. +D3DXQUATERNION* WINAPI D3DXQuaternionSlerp + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, FLOAT t ); + +// Spherical quadrangle interpolation. +// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) +D3DXQUATERNION* WINAPI D3DXQuaternionSquad + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, + CONST D3DXQUATERNION *pC, FLOAT t ); + +// Setup control points for spherical quadrangle interpolation +// from Q1 to Q2. The control points are chosen in such a way +// to ensure the continuity of tangents with adjacent segments. +void WINAPI D3DXQuaternionSquadSetup + ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, + CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); + +// Barycentric interpolation. +// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) +D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, + FLOAT f, FLOAT g ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Plane +//-------------------------- + +// inline + +// ax + by + cz + dw +FLOAT D3DXPlaneDot + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); + +// ax + by + cz + d +FLOAT D3DXPlaneDotCoord + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); + +// ax + by + cz +FLOAT D3DXPlaneDotNormal + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); + +D3DXPLANE* D3DXPlaneScale + (D3DXPLANE *pOut, CONST D3DXPLANE *pP, FLOAT s); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Normalize plane (so that |a,b,c| == 1) +D3DXPLANE* WINAPI D3DXPlaneNormalize + ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); + +// Find the intersection between a plane and a line. If the line is +// parallel to the plane, NULL is returned. +D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine + ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, + CONST D3DXVECTOR3 *pV2); + +// Construct a plane from a point and a normal +D3DXPLANE* WINAPI D3DXPlaneFromPointNormal + ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); + +// Construct a plane from 3 points +D3DXPLANE* WINAPI D3DXPlaneFromPoints + ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + CONST D3DXVECTOR3 *pV3); + +// 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* WINAPI D3DXPlaneTransform + ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); + +// Transform an array of planes by a matrix. The vectors (a,b,c) must be normal. +// M should be the inverse transpose of the transformation desired. +D3DXPLANE* WINAPI D3DXPlaneTransformArray + ( D3DXPLANE *pOut, UINT OutStride, CONST D3DXPLANE *pP, UINT PStride, CONST D3DXMATRIX *pM, UINT n ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Color +//-------------------------- + +// inline + +// (1-r, 1-g, 1-b, a) +D3DXCOLOR* D3DXColorNegative + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); + +D3DXCOLOR* D3DXColorAdd + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +D3DXCOLOR* D3DXColorSubtract + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +D3DXCOLOR* D3DXColorScale + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); + +// (r1*r2, g1*g2, b1*b2, a1*a2) +D3DXCOLOR* D3DXColorModulate + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) +D3DXCOLOR* D3DXColorLerp + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Interpolate r,g,b between desaturated color and color. +// DesaturatedColor + s(Color - DesaturatedColor) +D3DXCOLOR* WINAPI D3DXColorAdjustSaturation + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); + +// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) +D3DXCOLOR* WINAPI D3DXColorAdjustContrast + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); + +#ifdef __cplusplus +} +#endif + + + + +//-------------------------- +// Misc +//-------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +// Calculate Fresnel term given the cosine of theta (likely obtained by +// taking the dot of two normals), and the refraction index of the material. +FLOAT WINAPI D3DXFresnelTerm + (FLOAT CosTheta, FLOAT RefractionIndex); + +#ifdef __cplusplus +} +#endif + + + +//=========================================================================== +// +// Matrix Stack +// +//=========================================================================== + +typedef interface ID3DXMatrixStack ID3DXMatrixStack; +typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; + +// {C7885BA7-F990-4fe7-922D-8515E477DD85} +DEFINE_GUID(IID_ID3DXMatrixStack, +0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85); + + +#undef INTERFACE +#define INTERFACE ID3DXMatrixStack + +DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) +{ + // + // IUnknown methods + // + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // + // ID3DXMatrixStack methods + // + + // Pops the top of the stack, returns the current top + // *after* popping the top. + STDMETHOD(Pop)(THIS) PURE; + + // Pushes the stack by one, duplicating the current matrix. + STDMETHOD(Push)(THIS) PURE; + + // Loads identity in the current matrix. + STDMETHOD(LoadIdentity)(THIS) PURE; + + // Loads the given matrix into the current matrix + STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Right-Multiplies the given matrix to the current matrix. + // (transformation is about the current world origin) + STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Left-Multiplies the given matrix to the current matrix + // (transformation is about the local origin of the object) + STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Right multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the current world origin) + STDMETHOD(RotateAxis) + (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; + + // 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) + STDMETHOD(RotateAxisLocal) + (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; + + // Right multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // current world origin) + + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. + STDMETHOD(RotateYawPitchRoll) + (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; + + // Left multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // local origin of the object) + + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. + STDMETHOD(RotateYawPitchRollLocal) + (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; + + // Right multiply the current matrix with the computed scale + // matrix. (transformation is about the current world origin) + STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Left multiply the current matrix with the computed scale + // matrix. (transformation is about the local origin of the object) + STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Right multiply the current matrix with the computed translation + // matrix. (transformation is about the current world origin) + STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; + + // Left multiply the current matrix with the computed translation + // matrix. (transformation is about the local origin of the object) + STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Obtain the current matrix at the top of the stack + STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +HRESULT WINAPI + D3DXCreateMatrixStack( + UINT Flags, + LPD3DXMATRIXSTACK* ppStack); + +#ifdef __cplusplus +} +#endif + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +//============================================================================ +// +// Basic Spherical Harmonic math routines +// +//============================================================================ + +#define D3DXSH_MINORDER 2 +#define D3DXSH_MAXORDER 6 + +//============================================================================ +// +// D3DXSHEvalDirection: +// -------------------- +// Evaluates the Spherical Harmonic basis functions +// +// Parameters: +// pOut +// Output SH coefficients - basis function Ylm is stored at l*l + m+l +// This is the pointer that is returned. +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pDir +// Direction to evaluate in - assumed to be normalized +// +//============================================================================ + +FLOAT* WINAPI D3DXSHEvalDirection + ( FLOAT *pOut, UINT Order, CONST D3DXVECTOR3 *pDir ); + +//============================================================================ +// +// D3DXSHRotate: +// -------------------- +// Rotates SH vector by a rotation matrix +// +// Parameters: +// pOut +// Output SH coefficients - basis function Ylm is stored at l*l + m+l +// This is the pointer that is returned (should not alias with pIn.) +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pMatrix +// Matrix used for rotation - rotation sub matrix should be orthogonal +// and have a unit determinant. +// pIn +// Input SH coeffs (rotated), incorect results if this is also output. +// +//============================================================================ + +FLOAT* WINAPI D3DXSHRotate + ( FLOAT *pOut, UINT Order, CONST D3DXMATRIX *pMatrix, CONST FLOAT *pIn ); + +//============================================================================ +// +// D3DXSHRotateZ: +// -------------------- +// Rotates the SH vector in the Z axis by an angle +// +// Parameters: +// pOut +// Output SH coefficients - basis function Ylm is stored at l*l + m+l +// This is the pointer that is returned (should not alias with pIn.) +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// Angle +// Angle in radians to rotate around the Z axis. +// pIn +// Input SH coeffs (rotated), incorect results if this is also output. +// +//============================================================================ + + +FLOAT* WINAPI D3DXSHRotateZ + ( FLOAT *pOut, UINT Order, FLOAT Angle, CONST FLOAT *pIn ); + +//============================================================================ +// +// D3DXSHAdd: +// -------------------- +// Adds two SH vectors, pOut[i] = pA[i] + pB[i]; +// +// Parameters: +// pOut +// Output SH coefficients - basis function Ylm is stored at l*l + m+l +// This is the pointer that is returned. +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pA +// Input SH coeffs. +// pB +// Input SH coeffs (second vector.) +// +//============================================================================ + +FLOAT* WINAPI D3DXSHAdd + ( FLOAT *pOut, UINT Order, CONST FLOAT *pA, CONST FLOAT *pB ); + +//============================================================================ +// +// D3DXSHScale: +// -------------------- +// Adds two SH vectors, pOut[i] = pA[i]*Scale; +// +// Parameters: +// pOut +// Output SH coefficients - basis function Ylm is stored at l*l + m+l +// This is the pointer that is returned. +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pIn +// Input SH coeffs. +// Scale +// Scale factor. +// +//============================================================================ + +FLOAT* WINAPI D3DXSHScale + ( FLOAT *pOut, UINT Order, CONST FLOAT *pIn, CONST FLOAT Scale ); + +//============================================================================ +// +// D3DXSHDot: +// -------------------- +// Computes the dot product of two SH vectors +// +// Parameters: +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pA +// Input SH coeffs. +// pB +// Second set of input SH coeffs. +// +//============================================================================ + +FLOAT WINAPI D3DXSHDot + ( UINT Order, CONST FLOAT *pA, CONST FLOAT *pB ); + +//============================================================================ +// +// Basic Spherical Harmonic lighting routines +// +//============================================================================ + +//============================================================================ +// +// D3DXSHEvalDirectionalLight: +// -------------------- +// Evaluates a directional light and returns spectral SH data. The output +// vector is computed so that if the intensity of R/G/B is unit the resulting +// exit radiance of a point directly under the light on a diffuse object with +// an albedo of 1 would be 1.0. This will compute 3 spectral samples, pROut +// has to be specified, while pGout and pBout are optional. +// +// Parameters: +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pDir +// Direction light is coming from (assumed to be normalized.) +// RIntensity +// Red intensity of light. +// GIntensity +// Green intensity of light. +// BIntensity +// Blue intensity of light. +// pROut +// Output SH vector for Red. +// pGOut +// Output SH vector for Green (optional.) +// pBOut +// Output SH vector for Blue (optional.) +// +//============================================================================ + +HRESULT WINAPI D3DXSHEvalDirectionalLight + ( UINT Order, CONST D3DXVECTOR3 *pDir, + FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, + FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); + +//============================================================================ +// +// D3DXSHEvalSphericalLight: +// -------------------- +// Evaluates a spherical light and returns spectral SH data. There is no +// normalization of the intensity of the light like there is for directional +// lights, care has to be taken when specifiying the intensities. This will +// compute 3 spectral samples, pROut has to be specified, while pGout and +// pBout are optional. +// +// Parameters: +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pPos +// Position of light - reciever is assumed to be at the origin. +// Radius +// Radius of the spherical light source. +// RIntensity +// Red intensity of light. +// GIntensity +// Green intensity of light. +// BIntensity +// Blue intensity of light. +// pROut +// Output SH vector for Red. +// pGOut +// Output SH vector for Green (optional.) +// pBOut +// Output SH vector for Blue (optional.) +// +//============================================================================ + +HRESULT WINAPI D3DXSHEvalSphericalLight + ( UINT Order, CONST D3DXVECTOR3 *pPos, FLOAT Radius, + FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, + FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); + +//============================================================================ +// +// D3DXSHEvalConeLight: +// -------------------- +// Evaluates a light that is a cone of constant intensity and returns spectral +// SH data. The output vector is computed so that if the intensity of R/G/B is +// unit the resulting exit radiance of a point directly under the light oriented +// in the cone direction on a diffuse object with an albedo of 1 would be 1.0. +// This will compute 3 spectral samples, pROut has to be specified, while pGout +// and pBout are optional. +// +// Parameters: +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pDir +// Direction light is coming from (assumed to be normalized.) +// Radius +// Radius of cone in radians. +// RIntensity +// Red intensity of light. +// GIntensity +// Green intensity of light. +// BIntensity +// Blue intensity of light. +// pROut +// Output SH vector for Red. +// pGOut +// Output SH vector for Green (optional.) +// pBOut +// Output SH vector for Blue (optional.) +// +//============================================================================ + +HRESULT WINAPI D3DXSHEvalConeLight + ( UINT Order, CONST D3DXVECTOR3 *pDir, FLOAT Radius, + FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, + FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); + +//============================================================================ +// +// D3DXSHEvalHemisphereLight: +// -------------------- +// Evaluates a light that is a linear interpolant between two colors over the +// sphere. The interpolant is linear along the axis of the two points, not +// over the surface of the sphere (ie: if the axis was (0,0,1) it is linear in +// Z, not in the azimuthal angle.) The resulting spherical lighting function +// is normalized so that a point on a perfectly diffuse surface with no +// shadowing and a normal pointed in the direction pDir would result in exit +// radiance with a value of 1 if the top color was white and the bottom color +// was black. This is a very simple model where Top represents the intensity +// of the "sky" and Bottom represents the intensity of the "ground". +// +// Parameters: +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pDir +// Axis of the hemisphere. +// Top +// Color of the upper hemisphere. +// Bottom +// Color of the lower hemisphere. +// pROut +// Output SH vector for Red. +// pGOut +// Output SH vector for Green +// pBOut +// Output SH vector for Blue +// +//============================================================================ + +HRESULT WINAPI D3DXSHEvalHemisphereLight + ( UINT Order, CONST D3DXVECTOR3 *pDir, D3DXCOLOR Top, D3DXCOLOR Bottom, + FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); + +// Math intersection functions + +BOOL WINAPI D3DXIntersectTri +( + CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position + CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position + CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position + CONST D3DXVECTOR3 *pRayPos, // Ray origin + CONST D3DXVECTOR3 *pRayDir, // Ray direction + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist); // Ray-Intersection Parameter Distance + +BOOL WINAPI + D3DXSphereBoundProbe( + CONST D3DXVECTOR3 *pCenter, + FLOAT Radius, + CONST D3DXVECTOR3 *pRayPosition, + CONST D3DXVECTOR3 *pRayDirection); + +BOOL WINAPI + D3DXBoxBoundProbe( + CONST D3DXVECTOR3 *pMin, + CONST D3DXVECTOR3 *pMax, + CONST D3DXVECTOR3 *pRayPosition, + CONST D3DXVECTOR3 *pRayDirection); + +HRESULT WINAPI + D3DXComputeBoundingSphere( + CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position + DWORD NumVertices, + DWORD dwStride, // count in bytes to subsequent position vectors + D3DXVECTOR3 *pCenter, + FLOAT *pRadius); + +HRESULT WINAPI + D3DXComputeBoundingBox( + CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position + DWORD NumVertices, + DWORD dwStride, // count in bytes to subsequent position vectors + D3DXVECTOR3 *pMin, + D3DXVECTOR3 *pMax); + + +#ifdef __cplusplus +} +#endif + + +#include "D3DX10math.inl" + +#if _MSC_VER >= 1200 +#pragma warning(pop) +#else +#pragma warning(default:4201) +#endif + +#endif // __D3DX9MATH_H__ + diff --git a/src/dep/include/DXSDK/include/D3DX10math.inl b/src/dep/include/DXSDK/include/D3DX10math.inl index ac31b8a..36566ea 100644 --- a/src/dep/include/DXSDK/include/D3DX10math.inl +++ b/src/dep/include/DXSDK/include/D3DX10math.inl @@ -1,2208 +1,2208 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx10math.inl -// Content: D3DX10 math inline functions -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DXMATH_INL__ -#define __D3DXMATH_INL__ - - -//=========================================================================== -// -// Inline Class Methods -// -//=========================================================================== - -#ifdef __cplusplus - -//-------------------------- -// Float16 -//-------------------------- - -D3DX10INLINE -D3DXFLOAT16::D3DXFLOAT16( FLOAT f ) -{ - D3DXFloat32To16Array(this, &f, 1); -} - -D3DX10INLINE -D3DXFLOAT16::D3DXFLOAT16( CONST D3DXFLOAT16& f ) -{ - value = f.value; -} - -// casting -D3DX10INLINE -D3DXFLOAT16::operator FLOAT () -{ - FLOAT f; - D3DXFloat16To32Array(&f, this, 1); - return f; -} - -// binary operators -D3DX10INLINE BOOL -D3DXFLOAT16::operator == ( CONST D3DXFLOAT16& f ) const -{ - return value == f.value; -} - -D3DX10INLINE BOOL -D3DXFLOAT16::operator != ( CONST D3DXFLOAT16& f ) const -{ - return value != f.value; -} - - -//-------------------------- -// 2D Vector -//-------------------------- - -D3DX10INLINE -D3DXVECTOR2::D3DXVECTOR2( CONST FLOAT *pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; -} - -D3DX10INLINE -D3DXVECTOR2::D3DXVECTOR2( CONST D3DXFLOAT16 *pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - D3DXFloat16To32Array(&x, pf, 2); -} - -D3DX10INLINE -D3DXVECTOR2::D3DXVECTOR2( FLOAT fx, FLOAT fy ) -{ - x = fx; - y = fy; -} - - -// casting -D3DX10INLINE -D3DXVECTOR2::operator FLOAT* () -{ - return (FLOAT *) &x; -} - -D3DX10INLINE -D3DXVECTOR2::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &x; -} - - -// assignment operators -D3DX10INLINE D3DXVECTOR2& -D3DXVECTOR2::operator += ( CONST D3DXVECTOR2& v ) -{ - x += v.x; - y += v.y; - return *this; -} - -D3DX10INLINE D3DXVECTOR2& -D3DXVECTOR2::operator -= ( CONST D3DXVECTOR2& v ) -{ - x -= v.x; - y -= v.y; - return *this; -} - -D3DX10INLINE D3DXVECTOR2& -D3DXVECTOR2::operator *= ( FLOAT f ) -{ - x *= f; - y *= f; - return *this; -} - -D3DX10INLINE D3DXVECTOR2& -D3DXVECTOR2::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - x *= fInv; - y *= fInv; - return *this; -} - - -// unary operators -D3DX10INLINE D3DXVECTOR2 -D3DXVECTOR2::operator + () const -{ - return *this; -} - -D3DX10INLINE D3DXVECTOR2 -D3DXVECTOR2::operator - () const -{ - return D3DXVECTOR2(-x, -y); -} - - -// binary operators -D3DX10INLINE D3DXVECTOR2 -D3DXVECTOR2::operator + ( CONST D3DXVECTOR2& v ) const -{ - return D3DXVECTOR2(x + v.x, y + v.y); -} - -D3DX10INLINE D3DXVECTOR2 -D3DXVECTOR2::operator - ( CONST D3DXVECTOR2& v ) const -{ - return D3DXVECTOR2(x - v.x, y - v.y); -} - -D3DX10INLINE D3DXVECTOR2 -D3DXVECTOR2::operator * ( FLOAT f ) const -{ - return D3DXVECTOR2(x * f, y * f); -} - -D3DX10INLINE D3DXVECTOR2 -D3DXVECTOR2::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXVECTOR2(x * fInv, y * fInv); -} - -D3DX10INLINE D3DXVECTOR2 -operator * ( FLOAT f, CONST D3DXVECTOR2& v ) -{ - return D3DXVECTOR2(f * v.x, f * v.y); -} - -D3DX10INLINE BOOL -D3DXVECTOR2::operator == ( CONST D3DXVECTOR2& v ) const -{ - return x == v.x && y == v.y; -} - -D3DX10INLINE BOOL -D3DXVECTOR2::operator != ( CONST D3DXVECTOR2& v ) const -{ - return x != v.x || y != v.y; -} - - - -//-------------------------- -// 2D Vector (16 bit) -//-------------------------- - -D3DX10INLINE -D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST FLOAT *pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - D3DXFloat32To16Array(&x, pf, 2); -} - -D3DX10INLINE -D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST D3DXFLOAT16 *pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - *((UINT *) &x) = *((UINT *) &pf[0]); -} - -D3DX10INLINE -D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy ) -{ - x = fx; - y = fy; -} - - -// casting -D3DX10INLINE -D3DXVECTOR2_16F::operator D3DXFLOAT16* () -{ - return (D3DXFLOAT16*) &x; -} - -D3DX10INLINE -D3DXVECTOR2_16F::operator CONST D3DXFLOAT16* () const -{ - return (CONST D3DXFLOAT16*) &x; -} - - -// binary operators -D3DX10INLINE BOOL -D3DXVECTOR2_16F::operator == ( CONST D3DXVECTOR2_16F &v ) const -{ - return *((UINT *) &x) == *((UINT *) &v.x); -} - -D3DX10INLINE BOOL -D3DXVECTOR2_16F::operator != ( CONST D3DXVECTOR2_16F &v ) const -{ - return *((UINT *) &x) != *((UINT *) &v.x); -} - - -//-------------------------- -// 3D Vector -//-------------------------- -D3DX10INLINE -D3DXVECTOR3::D3DXVECTOR3( CONST FLOAT *pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; - z = pf[2]; -} - -D3DX10INLINE -D3DXVECTOR3::D3DXVECTOR3( CONST D3DVECTOR& v ) -{ - x = v.x; - y = v.y; - z = v.z; -} - -D3DX10INLINE -D3DXVECTOR3::D3DXVECTOR3( CONST D3DXFLOAT16 *pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - D3DXFloat16To32Array(&x, pf, 3); -} - -D3DX10INLINE -D3DXVECTOR3::D3DXVECTOR3( FLOAT fx, FLOAT fy, FLOAT fz ) -{ - x = fx; - y = fy; - z = fz; -} - - -// casting -D3DX10INLINE -D3DXVECTOR3::operator FLOAT* () -{ - return (FLOAT *) &x; -} - -D3DX10INLINE -D3DXVECTOR3::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &x; -} - - -// assignment operators -D3DX10INLINE D3DXVECTOR3& -D3DXVECTOR3::operator += ( CONST D3DXVECTOR3& v ) -{ - x += v.x; - y += v.y; - z += v.z; - return *this; -} - -D3DX10INLINE D3DXVECTOR3& -D3DXVECTOR3::operator -= ( CONST D3DXVECTOR3& v ) -{ - x -= v.x; - y -= v.y; - z -= v.z; - return *this; -} - -D3DX10INLINE D3DXVECTOR3& -D3DXVECTOR3::operator *= ( FLOAT f ) -{ - x *= f; - y *= f; - z *= f; - return *this; -} - -D3DX10INLINE D3DXVECTOR3& -D3DXVECTOR3::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - x *= fInv; - y *= fInv; - z *= fInv; - return *this; -} - - -// unary operators -D3DX10INLINE D3DXVECTOR3 -D3DXVECTOR3::operator + () const -{ - return *this; -} - -D3DX10INLINE D3DXVECTOR3 -D3DXVECTOR3::operator - () const -{ - return D3DXVECTOR3(-x, -y, -z); -} - - -// binary operators -D3DX10INLINE D3DXVECTOR3 -D3DXVECTOR3::operator + ( CONST D3DXVECTOR3& v ) const -{ - return D3DXVECTOR3(x + v.x, y + v.y, z + v.z); -} - -D3DX10INLINE D3DXVECTOR3 -D3DXVECTOR3::operator - ( CONST D3DXVECTOR3& v ) const -{ - return D3DXVECTOR3(x - v.x, y - v.y, z - v.z); -} - -D3DX10INLINE D3DXVECTOR3 -D3DXVECTOR3::operator * ( FLOAT f ) const -{ - return D3DXVECTOR3(x * f, y * f, z * f); -} - -D3DX10INLINE D3DXVECTOR3 -D3DXVECTOR3::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXVECTOR3(x * fInv, y * fInv, z * fInv); -} - - -D3DX10INLINE D3DXVECTOR3 -operator * ( FLOAT f, CONST struct D3DXVECTOR3& v ) -{ - return D3DXVECTOR3(f * v.x, f * v.y, f * v.z); -} - - -D3DX10INLINE BOOL -D3DXVECTOR3::operator == ( CONST D3DXVECTOR3& v ) const -{ - return x == v.x && y == v.y && z == v.z; -} - -D3DX10INLINE BOOL -D3DXVECTOR3::operator != ( CONST D3DXVECTOR3& v ) const -{ - return x != v.x || y != v.y || z != v.z; -} - - - -//-------------------------- -// 3D Vector (16 bit) -//-------------------------- - -D3DX10INLINE -D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST FLOAT *pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - D3DXFloat32To16Array(&x, pf, 3); -} - -D3DX10INLINE -D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DVECTOR& v ) -{ - D3DXFloat32To16Array(&x, &v.x, 1); - D3DXFloat32To16Array(&y, &v.y, 1); - D3DXFloat32To16Array(&z, &v.z, 1); -} - -D3DX10INLINE -D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DXFLOAT16 *pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - *((UINT *) &x) = *((UINT *) &pf[0]); - *((WORD *) &z) = *((WORD *) &pf[2]); -} - -D3DX10INLINE -D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy, CONST D3DXFLOAT16 &fz ) -{ - x = fx; - y = fy; - z = fz; -} - - -// casting -D3DX10INLINE -D3DXVECTOR3_16F::operator D3DXFLOAT16* () -{ - return (D3DXFLOAT16*) &x; -} - -D3DX10INLINE -D3DXVECTOR3_16F::operator CONST D3DXFLOAT16* () const -{ - return (CONST D3DXFLOAT16*) &x; -} - - -// binary operators -D3DX10INLINE BOOL -D3DXVECTOR3_16F::operator == ( CONST D3DXVECTOR3_16F &v ) const -{ - return *((UINT *) &x) == *((UINT *) &v.x) && - *((WORD *) &z) == *((WORD *) &v.z); -} - -D3DX10INLINE BOOL -D3DXVECTOR3_16F::operator != ( CONST D3DXVECTOR3_16F &v ) const -{ - return *((UINT *) &x) != *((UINT *) &v.x) || - *((WORD *) &z) != *((WORD *) &v.z); -} - - -//-------------------------- -// 4D Vector -//-------------------------- -D3DX10INLINE -D3DXVECTOR4::D3DXVECTOR4( CONST FLOAT *pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; - z = pf[2]; - w = pf[3]; -} - -D3DX10INLINE -D3DXVECTOR4::D3DXVECTOR4( CONST D3DXFLOAT16 *pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - D3DXFloat16To32Array(&x, pf, 4); -} - -D3DX10INLINE -D3DXVECTOR4::D3DXVECTOR4( CONST D3DVECTOR& v, FLOAT f ) -{ - x = v.x; - y = v.y; - z = v.z; - w = f; -} - -D3DX10INLINE -D3DXVECTOR4::D3DXVECTOR4( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) -{ - x = fx; - y = fy; - z = fz; - w = fw; -} - - -// casting -D3DX10INLINE -D3DXVECTOR4::operator FLOAT* () -{ - return (FLOAT *) &x; -} - -D3DX10INLINE -D3DXVECTOR4::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &x; -} - - -// assignment operators -D3DX10INLINE D3DXVECTOR4& -D3DXVECTOR4::operator += ( CONST D3DXVECTOR4& v ) -{ - x += v.x; - y += v.y; - z += v.z; - w += v.w; - return *this; -} - -D3DX10INLINE D3DXVECTOR4& -D3DXVECTOR4::operator -= ( CONST D3DXVECTOR4& v ) -{ - x -= v.x; - y -= v.y; - z -= v.z; - w -= v.w; - return *this; -} - -D3DX10INLINE D3DXVECTOR4& -D3DXVECTOR4::operator *= ( FLOAT f ) -{ - x *= f; - y *= f; - z *= f; - w *= f; - return *this; -} - -D3DX10INLINE D3DXVECTOR4& -D3DXVECTOR4::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - x *= fInv; - y *= fInv; - z *= fInv; - w *= fInv; - return *this; -} - - -// unary operators -D3DX10INLINE D3DXVECTOR4 -D3DXVECTOR4::operator + () const -{ - return *this; -} - -D3DX10INLINE D3DXVECTOR4 -D3DXVECTOR4::operator - () const -{ - return D3DXVECTOR4(-x, -y, -z, -w); -} - - -// binary operators -D3DX10INLINE D3DXVECTOR4 -D3DXVECTOR4::operator + ( CONST D3DXVECTOR4& v ) const -{ - return D3DXVECTOR4(x + v.x, y + v.y, z + v.z, w + v.w); -} - -D3DX10INLINE D3DXVECTOR4 -D3DXVECTOR4::operator - ( CONST D3DXVECTOR4& v ) const -{ - return D3DXVECTOR4(x - v.x, y - v.y, z - v.z, w - v.w); -} - -D3DX10INLINE D3DXVECTOR4 -D3DXVECTOR4::operator * ( FLOAT f ) const -{ - return D3DXVECTOR4(x * f, y * f, z * f, w * f); -} - -D3DX10INLINE D3DXVECTOR4 -D3DXVECTOR4::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXVECTOR4(x * fInv, y * fInv, z * fInv, w * fInv); -} - -D3DX10INLINE D3DXVECTOR4 -operator * ( FLOAT f, CONST D3DXVECTOR4& v ) -{ - return D3DXVECTOR4(f * v.x, f * v.y, f * v.z, f * v.w); -} - - -D3DX10INLINE BOOL -D3DXVECTOR4::operator == ( CONST D3DXVECTOR4& v ) const -{ - return x == v.x && y == v.y && z == v.z && w == v.w; -} - -D3DX10INLINE BOOL -D3DXVECTOR4::operator != ( CONST D3DXVECTOR4& v ) const -{ - return x != v.x || y != v.y || z != v.z || w != v.w; -} - - - -//-------------------------- -// 4D Vector (16 bit) -//-------------------------- - -D3DX10INLINE -D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST FLOAT *pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - D3DXFloat32To16Array(&x, pf, 4); -} - -D3DX10INLINE -D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXFLOAT16 *pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - *((UINT *) &x) = *((UINT *) &pf[0]); - *((UINT *) &z) = *((UINT *) &pf[2]); -} - -D3DX10INLINE -D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXVECTOR3_16F& v, CONST D3DXFLOAT16& f ) -{ - x = v.x; - y = v.y; - z = v.z; - w = f; -} - -D3DX10INLINE -D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy, CONST D3DXFLOAT16 &fz, CONST D3DXFLOAT16 &fw ) -{ - x = fx; - y = fy; - z = fz; - w = fw; -} - - -// casting -D3DX10INLINE -D3DXVECTOR4_16F::operator D3DXFLOAT16* () -{ - return (D3DXFLOAT16*) &x; -} - -D3DX10INLINE -D3DXVECTOR4_16F::operator CONST D3DXFLOAT16* () const -{ - return (CONST D3DXFLOAT16*) &x; -} - - -// binary operators -D3DX10INLINE BOOL -D3DXVECTOR4_16F::operator == ( CONST D3DXVECTOR4_16F &v ) const -{ - return *((UINT *) &x) == *((UINT *) &v.x) && - *((UINT *) &z) == *((UINT *) &v.z); -} - -D3DX10INLINE BOOL -D3DXVECTOR4_16F::operator != ( CONST D3DXVECTOR4_16F &v ) const -{ - return *((UINT *) &x) != *((UINT *) &v.x) || - *((UINT *) &z) != *((UINT *) &v.z); -} - - -//-------------------------- -// Matrix -//-------------------------- -D3DX10INLINE -D3DXMATRIX::D3DXMATRIX( CONST FLOAT* pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - memcpy(&_11, pf, sizeof(D3DXMATRIX)); -} - -D3DX10INLINE -D3DXMATRIX::D3DXMATRIX( CONST D3DMATRIX& mat ) -{ - memcpy(&_11, &mat, sizeof(D3DXMATRIX)); -} - -D3DX10INLINE -D3DXMATRIX::D3DXMATRIX( CONST D3DXFLOAT16* pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - D3DXFloat16To32Array(&_11, pf, 16); -} - -D3DX10INLINE -D3DXMATRIX::D3DXMATRIX( FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14, - FLOAT f21, FLOAT f22, FLOAT f23, FLOAT f24, - FLOAT f31, FLOAT f32, FLOAT f33, FLOAT f34, - FLOAT f41, FLOAT f42, FLOAT f43, FLOAT f44 ) -{ - _11 = f11; _12 = f12; _13 = f13; _14 = f14; - _21 = f21; _22 = f22; _23 = f23; _24 = f24; - _31 = f31; _32 = f32; _33 = f33; _34 = f34; - _41 = f41; _42 = f42; _43 = f43; _44 = f44; -} - - - -// access grants -D3DX10INLINE FLOAT& -D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) -{ - return m[iRow][iCol]; -} - -D3DX10INLINE FLOAT -D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) const -{ - return m[iRow][iCol]; -} - - -// casting operators -D3DX10INLINE -D3DXMATRIX::operator FLOAT* () -{ - return (FLOAT *) &_11; -} - -D3DX10INLINE -D3DXMATRIX::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &_11; -} - - -// assignment operators -D3DX10INLINE D3DXMATRIX& -D3DXMATRIX::operator *= ( CONST D3DXMATRIX& mat ) -{ - D3DXMatrixMultiply(this, this, &mat); - return *this; -} - -D3DX10INLINE D3DXMATRIX& -D3DXMATRIX::operator += ( CONST D3DXMATRIX& mat ) -{ - _11 += mat._11; _12 += mat._12; _13 += mat._13; _14 += mat._14; - _21 += mat._21; _22 += mat._22; _23 += mat._23; _24 += mat._24; - _31 += mat._31; _32 += mat._32; _33 += mat._33; _34 += mat._34; - _41 += mat._41; _42 += mat._42; _43 += mat._43; _44 += mat._44; - return *this; -} - -D3DX10INLINE D3DXMATRIX& -D3DXMATRIX::operator -= ( CONST D3DXMATRIX& mat ) -{ - _11 -= mat._11; _12 -= mat._12; _13 -= mat._13; _14 -= mat._14; - _21 -= mat._21; _22 -= mat._22; _23 -= mat._23; _24 -= mat._24; - _31 -= mat._31; _32 -= mat._32; _33 -= mat._33; _34 -= mat._34; - _41 -= mat._41; _42 -= mat._42; _43 -= mat._43; _44 -= mat._44; - return *this; -} - -D3DX10INLINE D3DXMATRIX& -D3DXMATRIX::operator *= ( FLOAT f ) -{ - _11 *= f; _12 *= f; _13 *= f; _14 *= f; - _21 *= f; _22 *= f; _23 *= f; _24 *= f; - _31 *= f; _32 *= f; _33 *= f; _34 *= f; - _41 *= f; _42 *= f; _43 *= f; _44 *= f; - return *this; -} - -D3DX10INLINE D3DXMATRIX& -D3DXMATRIX::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - _11 *= fInv; _12 *= fInv; _13 *= fInv; _14 *= fInv; - _21 *= fInv; _22 *= fInv; _23 *= fInv; _24 *= fInv; - _31 *= fInv; _32 *= fInv; _33 *= fInv; _34 *= fInv; - _41 *= fInv; _42 *= fInv; _43 *= fInv; _44 *= fInv; - return *this; -} - - -// unary operators -D3DX10INLINE D3DXMATRIX -D3DXMATRIX::operator + () const -{ - return *this; -} - -D3DX10INLINE D3DXMATRIX -D3DXMATRIX::operator - () const -{ - return D3DXMATRIX(-_11, -_12, -_13, -_14, - -_21, -_22, -_23, -_24, - -_31, -_32, -_33, -_34, - -_41, -_42, -_43, -_44); -} - - -// binary operators -D3DX10INLINE D3DXMATRIX -D3DXMATRIX::operator * ( CONST D3DXMATRIX& mat ) const -{ - D3DXMATRIX matT; - D3DXMatrixMultiply(&matT, this, &mat); - return matT; -} - -D3DX10INLINE D3DXMATRIX -D3DXMATRIX::operator + ( CONST D3DXMATRIX& mat ) const -{ - return D3DXMATRIX(_11 + mat._11, _12 + mat._12, _13 + mat._13, _14 + mat._14, - _21 + mat._21, _22 + mat._22, _23 + mat._23, _24 + mat._24, - _31 + mat._31, _32 + mat._32, _33 + mat._33, _34 + mat._34, - _41 + mat._41, _42 + mat._42, _43 + mat._43, _44 + mat._44); -} - -D3DX10INLINE D3DXMATRIX -D3DXMATRIX::operator - ( CONST D3DXMATRIX& mat ) const -{ - return D3DXMATRIX(_11 - mat._11, _12 - mat._12, _13 - mat._13, _14 - mat._14, - _21 - mat._21, _22 - mat._22, _23 - mat._23, _24 - mat._24, - _31 - mat._31, _32 - mat._32, _33 - mat._33, _34 - mat._34, - _41 - mat._41, _42 - mat._42, _43 - mat._43, _44 - mat._44); -} - -D3DX10INLINE D3DXMATRIX -D3DXMATRIX::operator * ( FLOAT f ) const -{ - return D3DXMATRIX(_11 * f, _12 * f, _13 * f, _14 * f, - _21 * f, _22 * f, _23 * f, _24 * f, - _31 * f, _32 * f, _33 * f, _34 * f, - _41 * f, _42 * f, _43 * f, _44 * f); -} - -D3DX10INLINE D3DXMATRIX -D3DXMATRIX::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXMATRIX(_11 * fInv, _12 * fInv, _13 * fInv, _14 * fInv, - _21 * fInv, _22 * fInv, _23 * fInv, _24 * fInv, - _31 * fInv, _32 * fInv, _33 * fInv, _34 * fInv, - _41 * fInv, _42 * fInv, _43 * fInv, _44 * fInv); -} - - -D3DX10INLINE D3DXMATRIX -operator * ( FLOAT f, CONST D3DXMATRIX& mat ) -{ - return D3DXMATRIX(f * mat._11, f * mat._12, f * mat._13, f * mat._14, - f * mat._21, f * mat._22, f * mat._23, f * mat._24, - f * mat._31, f * mat._32, f * mat._33, f * mat._34, - f * mat._41, f * mat._42, f * mat._43, f * mat._44); -} - - -D3DX10INLINE BOOL -D3DXMATRIX::operator == ( CONST D3DXMATRIX& mat ) const -{ - return 0 == memcmp(this, &mat, sizeof(D3DXMATRIX)); -} - -D3DX10INLINE BOOL -D3DXMATRIX::operator != ( CONST D3DXMATRIX& mat ) const -{ - return 0 != memcmp(this, &mat, sizeof(D3DXMATRIX)); -} - - - -//-------------------------- -// Aligned Matrices -//-------------------------- - -D3DX10INLINE -_D3DXMATRIXA16::_D3DXMATRIXA16( CONST FLOAT* f ) : - D3DXMATRIX( f ) -{ -} - -D3DX10INLINE -_D3DXMATRIXA16::_D3DXMATRIXA16( CONST D3DMATRIX& m ) : - D3DXMATRIX( m ) -{ -} - -D3DX10INLINE -_D3DXMATRIXA16::_D3DXMATRIXA16( CONST D3DXFLOAT16* f ) : - D3DXMATRIX( f ) -{ -} - -D3DX10INLINE -_D3DXMATRIXA16::_D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, - FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, - FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, - FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ) : - D3DXMATRIX(_11, _12, _13, _14, - _21, _22, _23, _24, - _31, _32, _33, _34, - _41, _42, _43, _44) -{ -} - -D3DX10INLINE void* -_D3DXMATRIXA16::operator new( size_t s ) -{ - LPBYTE p = ::new BYTE[s + 16]; - if (p) - { - BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); - p += offset; - p[-1] = offset; - } - return p; -} - -D3DX10INLINE void* -_D3DXMATRIXA16::operator new[]( size_t s ) -{ - LPBYTE p = ::new BYTE[s + 16]; - if (p) - { - BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); - p += offset; - p[-1] = offset; - } - return p; -} - -D3DX10INLINE void -_D3DXMATRIXA16::operator delete(void* p) -{ - if(p) - { - BYTE* pb = static_cast(p); - pb -= pb[-1]; - ::delete [] pb; - } -} - -D3DX10INLINE void -_D3DXMATRIXA16::operator delete[](void* p) -{ - if(p) - { - BYTE* pb = static_cast(p); - pb -= pb[-1]; - ::delete [] pb; - } -} - -D3DX10INLINE _D3DXMATRIXA16& -_D3DXMATRIXA16::operator=(CONST D3DXMATRIX& rhs) -{ - memcpy(&_11, &rhs, sizeof(D3DXMATRIX)); - return *this; -} - - -//-------------------------- -// Quaternion -//-------------------------- - -D3DX10INLINE -D3DXQUATERNION::D3DXQUATERNION( CONST FLOAT* pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; - z = pf[2]; - w = pf[3]; -} - -D3DX10INLINE -D3DXQUATERNION::D3DXQUATERNION( CONST D3DXFLOAT16* pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - D3DXFloat16To32Array(&x, pf, 4); -} - -D3DX10INLINE -D3DXQUATERNION::D3DXQUATERNION( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) -{ - x = fx; - y = fy; - z = fz; - w = fw; -} - - -// casting -D3DX10INLINE -D3DXQUATERNION::operator FLOAT* () -{ - return (FLOAT *) &x; -} - -D3DX10INLINE -D3DXQUATERNION::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &x; -} - - -// assignment operators -D3DX10INLINE D3DXQUATERNION& -D3DXQUATERNION::operator += ( CONST D3DXQUATERNION& q ) -{ - x += q.x; - y += q.y; - z += q.z; - w += q.w; - return *this; -} - -D3DX10INLINE D3DXQUATERNION& -D3DXQUATERNION::operator -= ( CONST D3DXQUATERNION& q ) -{ - x -= q.x; - y -= q.y; - z -= q.z; - w -= q.w; - return *this; -} - -D3DX10INLINE D3DXQUATERNION& -D3DXQUATERNION::operator *= ( CONST D3DXQUATERNION& q ) -{ - D3DXQuaternionMultiply(this, this, &q); - return *this; -} - -D3DX10INLINE D3DXQUATERNION& -D3DXQUATERNION::operator *= ( FLOAT f ) -{ - x *= f; - y *= f; - z *= f; - w *= f; - return *this; -} - -D3DX10INLINE D3DXQUATERNION& -D3DXQUATERNION::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - x *= fInv; - y *= fInv; - z *= fInv; - w *= fInv; - return *this; -} - - -// unary operators -D3DX10INLINE D3DXQUATERNION -D3DXQUATERNION::operator + () const -{ - return *this; -} - -D3DX10INLINE D3DXQUATERNION -D3DXQUATERNION::operator - () const -{ - return D3DXQUATERNION(-x, -y, -z, -w); -} - - -// binary operators -D3DX10INLINE D3DXQUATERNION -D3DXQUATERNION::operator + ( CONST D3DXQUATERNION& q ) const -{ - return D3DXQUATERNION(x + q.x, y + q.y, z + q.z, w + q.w); -} - -D3DX10INLINE D3DXQUATERNION -D3DXQUATERNION::operator - ( CONST D3DXQUATERNION& q ) const -{ - return D3DXQUATERNION(x - q.x, y - q.y, z - q.z, w - q.w); -} - -D3DX10INLINE D3DXQUATERNION -D3DXQUATERNION::operator * ( CONST D3DXQUATERNION& q ) const -{ - D3DXQUATERNION qT; - D3DXQuaternionMultiply(&qT, this, &q); - return qT; -} - -D3DX10INLINE D3DXQUATERNION -D3DXQUATERNION::operator * ( FLOAT f ) const -{ - return D3DXQUATERNION(x * f, y * f, z * f, w * f); -} - -D3DX10INLINE D3DXQUATERNION -D3DXQUATERNION::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXQUATERNION(x * fInv, y * fInv, z * fInv, w * fInv); -} - - -D3DX10INLINE D3DXQUATERNION -operator * (FLOAT f, CONST D3DXQUATERNION& q ) -{ - return D3DXQUATERNION(f * q.x, f * q.y, f * q.z, f * q.w); -} - - -D3DX10INLINE BOOL -D3DXQUATERNION::operator == ( CONST D3DXQUATERNION& q ) const -{ - return x == q.x && y == q.y && z == q.z && w == q.w; -} - -D3DX10INLINE BOOL -D3DXQUATERNION::operator != ( CONST D3DXQUATERNION& q ) const -{ - return x != q.x || y != q.y || z != q.z || w != q.w; -} - - - -//-------------------------- -// Plane -//-------------------------- - -D3DX10INLINE -D3DXPLANE::D3DXPLANE( CONST FLOAT* pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - a = pf[0]; - b = pf[1]; - c = pf[2]; - d = pf[3]; -} - -D3DX10INLINE -D3DXPLANE::D3DXPLANE( CONST D3DXFLOAT16* pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - D3DXFloat16To32Array(&a, pf, 4); -} - -D3DX10INLINE -D3DXPLANE::D3DXPLANE( FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd ) -{ - a = fa; - b = fb; - c = fc; - d = fd; -} - - -// casting -D3DX10INLINE -D3DXPLANE::operator FLOAT* () -{ - return (FLOAT *) &a; -} - -D3DX10INLINE -D3DXPLANE::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &a; -} - - -// assignment operators -D3DX10INLINE D3DXPLANE& -D3DXPLANE::operator *= ( FLOAT f ) -{ - a *= f; - b *= f; - c *= f; - d *= f; - return *this; -} - -D3DX10INLINE D3DXPLANE& -D3DXPLANE::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - a *= fInv; - b *= fInv; - c *= fInv; - d *= fInv; - return *this; -} - - -// unary operators -D3DX10INLINE D3DXPLANE -D3DXPLANE::operator + () const -{ - return *this; -} - -D3DX10INLINE D3DXPLANE -D3DXPLANE::operator - () const -{ - return D3DXPLANE(-a, -b, -c, -d); -} - - -// binary operators -D3DX10INLINE D3DXPLANE -D3DXPLANE::operator * ( FLOAT f ) const -{ - return D3DXPLANE(a * f, b * f, c * f, d * f); -} - -D3DX10INLINE D3DXPLANE -D3DXPLANE::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXPLANE(a * fInv, b * fInv, c * fInv, d * fInv); -} - -D3DX10INLINE D3DXPLANE -operator * (FLOAT f, CONST D3DXPLANE& p ) -{ - return D3DXPLANE(f * p.a, f * p.b, f * p.c, f * p.d); -} - -D3DX10INLINE BOOL -D3DXPLANE::operator == ( CONST D3DXPLANE& p ) const -{ - return a == p.a && b == p.b && c == p.c && d == p.d; -} - -D3DX10INLINE BOOL -D3DXPLANE::operator != ( CONST D3DXPLANE& p ) const -{ - return a != p.a || b != p.b || c != p.c || d != p.d; -} - - - - -//-------------------------- -// Color -//-------------------------- - -D3DX10INLINE -D3DXCOLOR::D3DXCOLOR( UINT dw ) -{ - CONST FLOAT f = 1.0f / 255.0f; - r = f * (FLOAT) (unsigned char) (dw >> 16); - g = f * (FLOAT) (unsigned char) (dw >> 8); - b = f * (FLOAT) (unsigned char) (dw >> 0); - a = f * (FLOAT) (unsigned char) (dw >> 24); -} - -D3DX10INLINE -D3DXCOLOR::D3DXCOLOR( CONST FLOAT* pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - r = pf[0]; - g = pf[1]; - b = pf[2]; - a = pf[3]; -} - -D3DX10INLINE -D3DXCOLOR::D3DXCOLOR( CONST D3DXFLOAT16* pf ) -{ -#ifdef D3DX10_DEBUG - if(!pf) - return; -#endif - - D3DXFloat16To32Array(&r, pf, 4); -} - -D3DX10INLINE -D3DXCOLOR::D3DXCOLOR( FLOAT fr, FLOAT fg, FLOAT fb, FLOAT fa ) -{ - r = fr; - g = fg; - b = fb; - a = fa; -} - - -// casting -D3DX10INLINE -D3DXCOLOR::operator UINT () const -{ - UINT dwR = r >= 1.0f ? 0xff : r <= 0.0f ? 0x00 : (UINT) (r * 255.0f + 0.5f); - UINT dwG = g >= 1.0f ? 0xff : g <= 0.0f ? 0x00 : (UINT) (g * 255.0f + 0.5f); - UINT dwB = b >= 1.0f ? 0xff : b <= 0.0f ? 0x00 : (UINT) (b * 255.0f + 0.5f); - UINT dwA = a >= 1.0f ? 0xff : a <= 0.0f ? 0x00 : (UINT) (a * 255.0f + 0.5f); - - return (dwA << 24) | (dwR << 16) | (dwG << 8) | (dwB << 0); -} - - -D3DX10INLINE -D3DXCOLOR::operator FLOAT * () -{ - return (FLOAT *) &r; -} - -D3DX10INLINE -D3DXCOLOR::operator CONST FLOAT * () const -{ - return (CONST FLOAT *) &r; -} - -// assignment operators -D3DX10INLINE D3DXCOLOR& -D3DXCOLOR::operator += ( CONST D3DXCOLOR& c ) -{ - r += c.r; - g += c.g; - b += c.b; - a += c.a; - return *this; -} - -D3DX10INLINE D3DXCOLOR& -D3DXCOLOR::operator -= ( CONST D3DXCOLOR& c ) -{ - r -= c.r; - g -= c.g; - b -= c.b; - a -= c.a; - return *this; -} - -D3DX10INLINE D3DXCOLOR& -D3DXCOLOR::operator *= ( FLOAT f ) -{ - r *= f; - g *= f; - b *= f; - a *= f; - return *this; -} - -D3DX10INLINE D3DXCOLOR& -D3DXCOLOR::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - r *= fInv; - g *= fInv; - b *= fInv; - a *= fInv; - return *this; -} - - -// unary operators -D3DX10INLINE D3DXCOLOR -D3DXCOLOR::operator + () const -{ - return *this; -} - -D3DX10INLINE D3DXCOLOR -D3DXCOLOR::operator - () const -{ - return D3DXCOLOR(-r, -g, -b, -a); -} - - -// binary operators -D3DX10INLINE D3DXCOLOR -D3DXCOLOR::operator + ( CONST D3DXCOLOR& c ) const -{ - return D3DXCOLOR(r + c.r, g + c.g, b + c.b, a + c.a); -} - -D3DX10INLINE D3DXCOLOR -D3DXCOLOR::operator - ( CONST D3DXCOLOR& c ) const -{ - return D3DXCOLOR(r - c.r, g - c.g, b - c.b, a - c.a); -} - -D3DX10INLINE D3DXCOLOR -D3DXCOLOR::operator * ( FLOAT f ) const -{ - return D3DXCOLOR(r * f, g * f, b * f, a * f); -} - -D3DX10INLINE D3DXCOLOR -D3DXCOLOR::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXCOLOR(r * fInv, g * fInv, b * fInv, a * fInv); -} - - -D3DX10INLINE D3DXCOLOR -operator * (FLOAT f, CONST D3DXCOLOR& c ) -{ - return D3DXCOLOR(f * c.r, f * c.g, f * c.b, f * c.a); -} - - -D3DX10INLINE BOOL -D3DXCOLOR::operator == ( CONST D3DXCOLOR& c ) const -{ - return r == c.r && g == c.g && b == c.b && a == c.a; -} - -D3DX10INLINE BOOL -D3DXCOLOR::operator != ( CONST D3DXCOLOR& c ) const -{ - return r != c.r || g != c.g || b != c.b || a != c.a; -} - - -#endif //__cplusplus - - - -//=========================================================================== -// -// Inline functions -// -//=========================================================================== - - -//-------------------------- -// 2D Vector -//-------------------------- - -D3DX10INLINE FLOAT D3DXVec2Length - ( CONST D3DXVECTOR2 *pV ) -{ -#ifdef D3DX10_DEBUG - if(!pV) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pV->x * pV->x + pV->y * pV->y); -#else - return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y); -#endif -} - -D3DX10INLINE FLOAT D3DXVec2LengthSq - ( CONST D3DXVECTOR2 *pV ) -{ -#ifdef D3DX10_DEBUG - if(!pV) - return 0.0f; -#endif - - return pV->x * pV->x + pV->y * pV->y; -} - -D3DX10INLINE FLOAT D3DXVec2Dot - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX10_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->x + pV1->y * pV2->y; -} - -D3DX10INLINE FLOAT D3DXVec2CCW - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX10_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->y - pV1->y * pV2->x; -} - -D3DX10INLINE D3DXVECTOR2* D3DXVec2Add - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + pV2->x; - pOut->y = pV1->y + pV2->y; - return pOut; -} - -D3DX10INLINE D3DXVECTOR2* D3DXVec2Subtract - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x - pV2->x; - pOut->y = pV1->y - pV2->y; - return pOut; -} - -D3DX10INLINE D3DXVECTOR2* D3DXVec2Minimize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; - return pOut; -} - -D3DX10INLINE D3DXVECTOR2* D3DXVec2Maximize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; - return pOut; -} - -D3DX10INLINE D3DXVECTOR2* D3DXVec2Scale - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV) - return NULL; -#endif - - pOut->x = pV->x * s; - pOut->y = pV->y * s; - return pOut; -} - -D3DX10INLINE D3DXVECTOR2* D3DXVec2Lerp - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, - FLOAT s ) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + s * (pV2->x - pV1->x); - pOut->y = pV1->y + s * (pV2->y - pV1->y); - return pOut; -} - - -//-------------------------- -// 3D Vector -//-------------------------- - -D3DX10INLINE FLOAT D3DXVec3Length - ( CONST D3DXVECTOR3 *pV ) -{ -#ifdef D3DX10_DEBUG - if(!pV) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); -#else - return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); -#endif -} - -D3DX10INLINE FLOAT D3DXVec3LengthSq - ( CONST D3DXVECTOR3 *pV ) -{ -#ifdef D3DX10_DEBUG - if(!pV) - return 0.0f; -#endif - - return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z; -} - -D3DX10INLINE FLOAT D3DXVec3Dot - ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX10_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z; -} - -D3DX10INLINE D3DXVECTOR3* D3DXVec3Cross - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ - D3DXVECTOR3 v; - -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - 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; -} - -D3DX10INLINE D3DXVECTOR3* D3DXVec3Add - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + pV2->x; - pOut->y = pV1->y + pV2->y; - pOut->z = pV1->z + pV2->z; - return pOut; -} - -D3DX10INLINE D3DXVECTOR3* D3DXVec3Subtract - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x - pV2->x; - pOut->y = pV1->y - pV2->y; - pOut->z = pV1->z - pV2->z; - return pOut; -} - -D3DX10INLINE D3DXVECTOR3* D3DXVec3Minimize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; - return pOut; -} - -D3DX10INLINE D3DXVECTOR3* D3DXVec3Maximize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; - return pOut; -} - -D3DX10INLINE D3DXVECTOR3* D3DXVec3Scale - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV) - return NULL; -#endif - - pOut->x = pV->x * s; - pOut->y = pV->y * s; - pOut->z = pV->z * s; - return pOut; -} - -D3DX10INLINE D3DXVECTOR3* D3DXVec3Lerp - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - FLOAT s ) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + s * (pV2->x - pV1->x); - pOut->y = pV1->y + s * (pV2->y - pV1->y); - pOut->z = pV1->z + s * (pV2->z - pV1->z); - return pOut; -} - - -//-------------------------- -// 4D Vector -//-------------------------- - -D3DX10INLINE FLOAT D3DXVec4Length - ( CONST D3DXVECTOR4 *pV ) -{ -#ifdef D3DX10_DEBUG - if(!pV) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); -#else - return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); -#endif -} - -D3DX10INLINE FLOAT D3DXVec4LengthSq - ( CONST D3DXVECTOR4 *pV ) -{ -#ifdef D3DX10_DEBUG - if(!pV) - return 0.0f; -#endif - - return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w; -} - -D3DX10INLINE FLOAT D3DXVec4Dot - ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ) -{ -#ifdef D3DX10_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z + pV1->w * pV2->w; -} - -D3DX10INLINE D3DXVECTOR4* D3DXVec4Add - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + pV2->x; - pOut->y = pV1->y + pV2->y; - pOut->z = pV1->z + pV2->z; - pOut->w = pV1->w + pV2->w; - return pOut; -} - -D3DX10INLINE D3DXVECTOR4* D3DXVec4Subtract - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x - pV2->x; - pOut->y = pV1->y - pV2->y; - pOut->z = pV1->z - pV2->z; - pOut->w = pV1->w - pV2->w; - return pOut; -} - -D3DX10INLINE D3DXVECTOR4* D3DXVec4Minimize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; - pOut->w = pV1->w < pV2->w ? pV1->w : pV2->w; - return pOut; -} - -D3DX10INLINE D3DXVECTOR4* D3DXVec4Maximize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; - pOut->w = pV1->w > pV2->w ? pV1->w : pV2->w; - return pOut; -} - -D3DX10INLINE D3DXVECTOR4* D3DXVec4Scale - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV) - return NULL; -#endif - - pOut->x = pV->x * s; - pOut->y = pV->y * s; - pOut->z = pV->z * s; - pOut->w = pV->w * s; - return pOut; -} - -D3DX10INLINE D3DXVECTOR4* D3DXVec4Lerp - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - FLOAT s ) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + s * (pV2->x - pV1->x); - pOut->y = pV1->y + s * (pV2->y - pV1->y); - pOut->z = pV1->z + s * (pV2->z - pV1->z); - pOut->w = pV1->w + s * (pV2->w - pV1->w); - return pOut; -} - - -//-------------------------- -// 4D Matrix -//-------------------------- - -D3DX10INLINE D3DXMATRIX* D3DXMatrixIdentity - ( D3DXMATRIX *pOut ) -{ -#ifdef D3DX10_DEBUG - if(!pOut) - return NULL; -#endif - - pOut->m[0][1] = pOut->m[0][2] = pOut->m[0][3] = - pOut->m[1][0] = pOut->m[1][2] = pOut->m[1][3] = - pOut->m[2][0] = pOut->m[2][1] = pOut->m[2][3] = - pOut->m[3][0] = pOut->m[3][1] = pOut->m[3][2] = 0.0f; - - pOut->m[0][0] = pOut->m[1][1] = pOut->m[2][2] = pOut->m[3][3] = 1.0f; - return pOut; -} - - -D3DX10INLINE BOOL D3DXMatrixIsIdentity - ( CONST D3DXMATRIX *pM ) -{ -#ifdef D3DX10_DEBUG - if(!pM) - return FALSE; -#endif - - return pM->m[0][0] == 1.0f && pM->m[0][1] == 0.0f && pM->m[0][2] == 0.0f && pM->m[0][3] == 0.0f && - pM->m[1][0] == 0.0f && pM->m[1][1] == 1.0f && pM->m[1][2] == 0.0f && pM->m[1][3] == 0.0f && - pM->m[2][0] == 0.0f && pM->m[2][1] == 0.0f && pM->m[2][2] == 1.0f && pM->m[2][3] == 0.0f && - pM->m[3][0] == 0.0f && pM->m[3][1] == 0.0f && pM->m[3][2] == 0.0f && pM->m[3][3] == 1.0f; -} - - -//-------------------------- -// Quaternion -//-------------------------- - -D3DX10INLINE FLOAT D3DXQuaternionLength - ( CONST D3DXQUATERNION *pQ ) -{ -#ifdef D3DX10_DEBUG - if(!pQ) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); -#else - return (FLOAT) sqrt(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); -#endif -} - -D3DX10INLINE FLOAT D3DXQuaternionLengthSq - ( CONST D3DXQUATERNION *pQ ) -{ -#ifdef D3DX10_DEBUG - if(!pQ) - return 0.0f; -#endif - - return pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w; -} - -D3DX10INLINE FLOAT D3DXQuaternionDot - ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ) -{ -#ifdef D3DX10_DEBUG - if(!pQ1 || !pQ2) - return 0.0f; -#endif - - return pQ1->x * pQ2->x + pQ1->y * pQ2->y + pQ1->z * pQ2->z + pQ1->w * pQ2->w; -} - - -D3DX10INLINE D3DXQUATERNION* D3DXQuaternionIdentity - ( D3DXQUATERNION *pOut ) -{ -#ifdef D3DX10_DEBUG - if(!pOut) - return NULL; -#endif - - pOut->x = pOut->y = pOut->z = 0.0f; - pOut->w = 1.0f; - return pOut; -} - -D3DX10INLINE BOOL D3DXQuaternionIsIdentity - ( CONST D3DXQUATERNION *pQ ) -{ -#ifdef D3DX10_DEBUG - if(!pQ) - return FALSE; -#endif - - return pQ->x == 0.0f && pQ->y == 0.0f && pQ->z == 0.0f && pQ->w == 1.0f; -} - - -D3DX10INLINE D3DXQUATERNION* D3DXQuaternionConjugate - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pQ) - return NULL; -#endif - - pOut->x = -pQ->x; - pOut->y = -pQ->y; - pOut->z = -pQ->z; - pOut->w = pQ->w; - return pOut; -} - - -//-------------------------- -// Plane -//-------------------------- - -D3DX10INLINE FLOAT D3DXPlaneDot - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV) -{ -#ifdef D3DX10_DEBUG - if(!pP || !pV) - return 0.0f; -#endif - - return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d * pV->w; -} - -D3DX10INLINE FLOAT D3DXPlaneDotCoord - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV) -{ -#ifdef D3DX10_DEBUG - if(!pP || !pV) - return 0.0f; -#endif - - return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d; -} - -D3DX10INLINE FLOAT D3DXPlaneDotNormal - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV) -{ -#ifdef D3DX10_DEBUG - if(!pP || !pV) - return 0.0f; -#endif - - return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z; -} - -D3DX10INLINE D3DXPLANE* D3DXPlaneScale - (D3DXPLANE *pOut, CONST D3DXPLANE *pP, FLOAT s) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pP) - return NULL; -#endif - - pOut->a = pP->a * s; - pOut->b = pP->b * s; - pOut->c = pP->c * s; - pOut->d = pP->d * s; - return pOut; -} - - -//-------------------------- -// Color -//-------------------------- - -D3DX10INLINE D3DXCOLOR* D3DXColorNegative - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pC) - return NULL; -#endif - - pOut->r = 1.0f - pC->r; - pOut->g = 1.0f - pC->g; - pOut->b = 1.0f - pC->b; - pOut->a = pC->a; - return pOut; -} - -D3DX10INLINE D3DXCOLOR* D3DXColorAdd - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r + pC2->r; - pOut->g = pC1->g + pC2->g; - pOut->b = pC1->b + pC2->b; - pOut->a = pC1->a + pC2->a; - return pOut; -} - -D3DX10INLINE D3DXCOLOR* D3DXColorSubtract - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r - pC2->r; - pOut->g = pC1->g - pC2->g; - pOut->b = pC1->b - pC2->b; - pOut->a = pC1->a - pC2->a; - return pOut; -} - -D3DX10INLINE D3DXCOLOR* D3DXColorScale - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pC) - return NULL; -#endif - - pOut->r = pC->r * s; - pOut->g = pC->g * s; - pOut->b = pC->b * s; - pOut->a = pC->a * s; - return pOut; -} - -D3DX10INLINE D3DXCOLOR* D3DXColorModulate - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r * pC2->r; - pOut->g = pC1->g * pC2->g; - pOut->b = pC1->b * pC2->b; - pOut->a = pC1->a * pC2->a; - return pOut; -} - -D3DX10INLINE D3DXCOLOR* D3DXColorLerp - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s) -{ -#ifdef D3DX10_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r + s * (pC2->r - pC1->r); - pOut->g = pC1->g + s * (pC2->g - pC1->g); - pOut->b = pC1->b + s * (pC2->b - pC1->b); - pOut->a = pC1->a + s * (pC2->a - pC1->a); - return pOut; -} - - -#endif // __D3DXMATH_INL__ - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx10math.inl +// Content: D3DX10 math inline functions +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DXMATH_INL__ +#define __D3DXMATH_INL__ + + +//=========================================================================== +// +// Inline Class Methods +// +//=========================================================================== + +#ifdef __cplusplus + +//-------------------------- +// Float16 +//-------------------------- + +D3DX10INLINE +D3DXFLOAT16::D3DXFLOAT16( FLOAT f ) +{ + D3DXFloat32To16Array(this, &f, 1); +} + +D3DX10INLINE +D3DXFLOAT16::D3DXFLOAT16( CONST D3DXFLOAT16& f ) +{ + value = f.value; +} + +// casting +D3DX10INLINE +D3DXFLOAT16::operator FLOAT () +{ + FLOAT f; + D3DXFloat16To32Array(&f, this, 1); + return f; +} + +// binary operators +D3DX10INLINE BOOL +D3DXFLOAT16::operator == ( CONST D3DXFLOAT16& f ) const +{ + return value == f.value; +} + +D3DX10INLINE BOOL +D3DXFLOAT16::operator != ( CONST D3DXFLOAT16& f ) const +{ + return value != f.value; +} + + +//-------------------------- +// 2D Vector +//-------------------------- + +D3DX10INLINE +D3DXVECTOR2::D3DXVECTOR2( CONST FLOAT *pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; +} + +D3DX10INLINE +D3DXVECTOR2::D3DXVECTOR2( CONST D3DXFLOAT16 *pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + D3DXFloat16To32Array(&x, pf, 2); +} + +D3DX10INLINE +D3DXVECTOR2::D3DXVECTOR2( FLOAT fx, FLOAT fy ) +{ + x = fx; + y = fy; +} + + +// casting +D3DX10INLINE +D3DXVECTOR2::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DX10INLINE +D3DXVECTOR2::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + + +// assignment operators +D3DX10INLINE D3DXVECTOR2& +D3DXVECTOR2::operator += ( CONST D3DXVECTOR2& v ) +{ + x += v.x; + y += v.y; + return *this; +} + +D3DX10INLINE D3DXVECTOR2& +D3DXVECTOR2::operator -= ( CONST D3DXVECTOR2& v ) +{ + x -= v.x; + y -= v.y; + return *this; +} + +D3DX10INLINE D3DXVECTOR2& +D3DXVECTOR2::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + return *this; +} + +D3DX10INLINE D3DXVECTOR2& +D3DXVECTOR2::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + return *this; +} + + +// unary operators +D3DX10INLINE D3DXVECTOR2 +D3DXVECTOR2::operator + () const +{ + return *this; +} + +D3DX10INLINE D3DXVECTOR2 +D3DXVECTOR2::operator - () const +{ + return D3DXVECTOR2(-x, -y); +} + + +// binary operators +D3DX10INLINE D3DXVECTOR2 +D3DXVECTOR2::operator + ( CONST D3DXVECTOR2& v ) const +{ + return D3DXVECTOR2(x + v.x, y + v.y); +} + +D3DX10INLINE D3DXVECTOR2 +D3DXVECTOR2::operator - ( CONST D3DXVECTOR2& v ) const +{ + return D3DXVECTOR2(x - v.x, y - v.y); +} + +D3DX10INLINE D3DXVECTOR2 +D3DXVECTOR2::operator * ( FLOAT f ) const +{ + return D3DXVECTOR2(x * f, y * f); +} + +D3DX10INLINE D3DXVECTOR2 +D3DXVECTOR2::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXVECTOR2(x * fInv, y * fInv); +} + +D3DX10INLINE D3DXVECTOR2 +operator * ( FLOAT f, CONST D3DXVECTOR2& v ) +{ + return D3DXVECTOR2(f * v.x, f * v.y); +} + +D3DX10INLINE BOOL +D3DXVECTOR2::operator == ( CONST D3DXVECTOR2& v ) const +{ + return x == v.x && y == v.y; +} + +D3DX10INLINE BOOL +D3DXVECTOR2::operator != ( CONST D3DXVECTOR2& v ) const +{ + return x != v.x || y != v.y; +} + + + +//-------------------------- +// 2D Vector (16 bit) +//-------------------------- + +D3DX10INLINE +D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST FLOAT *pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + D3DXFloat32To16Array(&x, pf, 2); +} + +D3DX10INLINE +D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST D3DXFLOAT16 *pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + *((UINT *) &x) = *((UINT *) &pf[0]); +} + +D3DX10INLINE +D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy ) +{ + x = fx; + y = fy; +} + + +// casting +D3DX10INLINE +D3DXVECTOR2_16F::operator D3DXFLOAT16* () +{ + return (D3DXFLOAT16*) &x; +} + +D3DX10INLINE +D3DXVECTOR2_16F::operator CONST D3DXFLOAT16* () const +{ + return (CONST D3DXFLOAT16*) &x; +} + + +// binary operators +D3DX10INLINE BOOL +D3DXVECTOR2_16F::operator == ( CONST D3DXVECTOR2_16F &v ) const +{ + return *((UINT *) &x) == *((UINT *) &v.x); +} + +D3DX10INLINE BOOL +D3DXVECTOR2_16F::operator != ( CONST D3DXVECTOR2_16F &v ) const +{ + return *((UINT *) &x) != *((UINT *) &v.x); +} + + +//-------------------------- +// 3D Vector +//-------------------------- +D3DX10INLINE +D3DXVECTOR3::D3DXVECTOR3( CONST FLOAT *pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; +} + +D3DX10INLINE +D3DXVECTOR3::D3DXVECTOR3( CONST D3DVECTOR& v ) +{ + x = v.x; + y = v.y; + z = v.z; +} + +D3DX10INLINE +D3DXVECTOR3::D3DXVECTOR3( CONST D3DXFLOAT16 *pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + D3DXFloat16To32Array(&x, pf, 3); +} + +D3DX10INLINE +D3DXVECTOR3::D3DXVECTOR3( FLOAT fx, FLOAT fy, FLOAT fz ) +{ + x = fx; + y = fy; + z = fz; +} + + +// casting +D3DX10INLINE +D3DXVECTOR3::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DX10INLINE +D3DXVECTOR3::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + + +// assignment operators +D3DX10INLINE D3DXVECTOR3& +D3DXVECTOR3::operator += ( CONST D3DXVECTOR3& v ) +{ + x += v.x; + y += v.y; + z += v.z; + return *this; +} + +D3DX10INLINE D3DXVECTOR3& +D3DXVECTOR3::operator -= ( CONST D3DXVECTOR3& v ) +{ + x -= v.x; + y -= v.y; + z -= v.z; + return *this; +} + +D3DX10INLINE D3DXVECTOR3& +D3DXVECTOR3::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + z *= f; + return *this; +} + +D3DX10INLINE D3DXVECTOR3& +D3DXVECTOR3::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + return *this; +} + + +// unary operators +D3DX10INLINE D3DXVECTOR3 +D3DXVECTOR3::operator + () const +{ + return *this; +} + +D3DX10INLINE D3DXVECTOR3 +D3DXVECTOR3::operator - () const +{ + return D3DXVECTOR3(-x, -y, -z); +} + + +// binary operators +D3DX10INLINE D3DXVECTOR3 +D3DXVECTOR3::operator + ( CONST D3DXVECTOR3& v ) const +{ + return D3DXVECTOR3(x + v.x, y + v.y, z + v.z); +} + +D3DX10INLINE D3DXVECTOR3 +D3DXVECTOR3::operator - ( CONST D3DXVECTOR3& v ) const +{ + return D3DXVECTOR3(x - v.x, y - v.y, z - v.z); +} + +D3DX10INLINE D3DXVECTOR3 +D3DXVECTOR3::operator * ( FLOAT f ) const +{ + return D3DXVECTOR3(x * f, y * f, z * f); +} + +D3DX10INLINE D3DXVECTOR3 +D3DXVECTOR3::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXVECTOR3(x * fInv, y * fInv, z * fInv); +} + + +D3DX10INLINE D3DXVECTOR3 +operator * ( FLOAT f, CONST struct D3DXVECTOR3& v ) +{ + return D3DXVECTOR3(f * v.x, f * v.y, f * v.z); +} + + +D3DX10INLINE BOOL +D3DXVECTOR3::operator == ( CONST D3DXVECTOR3& v ) const +{ + return x == v.x && y == v.y && z == v.z; +} + +D3DX10INLINE BOOL +D3DXVECTOR3::operator != ( CONST D3DXVECTOR3& v ) const +{ + return x != v.x || y != v.y || z != v.z; +} + + + +//-------------------------- +// 3D Vector (16 bit) +//-------------------------- + +D3DX10INLINE +D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST FLOAT *pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + D3DXFloat32To16Array(&x, pf, 3); +} + +D3DX10INLINE +D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DVECTOR& v ) +{ + D3DXFloat32To16Array(&x, &v.x, 1); + D3DXFloat32To16Array(&y, &v.y, 1); + D3DXFloat32To16Array(&z, &v.z, 1); +} + +D3DX10INLINE +D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DXFLOAT16 *pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + *((UINT *) &x) = *((UINT *) &pf[0]); + *((WORD *) &z) = *((WORD *) &pf[2]); +} + +D3DX10INLINE +D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy, CONST D3DXFLOAT16 &fz ) +{ + x = fx; + y = fy; + z = fz; +} + + +// casting +D3DX10INLINE +D3DXVECTOR3_16F::operator D3DXFLOAT16* () +{ + return (D3DXFLOAT16*) &x; +} + +D3DX10INLINE +D3DXVECTOR3_16F::operator CONST D3DXFLOAT16* () const +{ + return (CONST D3DXFLOAT16*) &x; +} + + +// binary operators +D3DX10INLINE BOOL +D3DXVECTOR3_16F::operator == ( CONST D3DXVECTOR3_16F &v ) const +{ + return *((UINT *) &x) == *((UINT *) &v.x) && + *((WORD *) &z) == *((WORD *) &v.z); +} + +D3DX10INLINE BOOL +D3DXVECTOR3_16F::operator != ( CONST D3DXVECTOR3_16F &v ) const +{ + return *((UINT *) &x) != *((UINT *) &v.x) || + *((WORD *) &z) != *((WORD *) &v.z); +} + + +//-------------------------- +// 4D Vector +//-------------------------- +D3DX10INLINE +D3DXVECTOR4::D3DXVECTOR4( CONST FLOAT *pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; + w = pf[3]; +} + +D3DX10INLINE +D3DXVECTOR4::D3DXVECTOR4( CONST D3DXFLOAT16 *pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + D3DXFloat16To32Array(&x, pf, 4); +} + +D3DX10INLINE +D3DXVECTOR4::D3DXVECTOR4( CONST D3DVECTOR& v, FLOAT f ) +{ + x = v.x; + y = v.y; + z = v.z; + w = f; +} + +D3DX10INLINE +D3DXVECTOR4::D3DXVECTOR4( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) +{ + x = fx; + y = fy; + z = fz; + w = fw; +} + + +// casting +D3DX10INLINE +D3DXVECTOR4::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DX10INLINE +D3DXVECTOR4::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + + +// assignment operators +D3DX10INLINE D3DXVECTOR4& +D3DXVECTOR4::operator += ( CONST D3DXVECTOR4& v ) +{ + x += v.x; + y += v.y; + z += v.z; + w += v.w; + return *this; +} + +D3DX10INLINE D3DXVECTOR4& +D3DXVECTOR4::operator -= ( CONST D3DXVECTOR4& v ) +{ + x -= v.x; + y -= v.y; + z -= v.z; + w -= v.w; + return *this; +} + +D3DX10INLINE D3DXVECTOR4& +D3DXVECTOR4::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + z *= f; + w *= f; + return *this; +} + +D3DX10INLINE D3DXVECTOR4& +D3DXVECTOR4::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + w *= fInv; + return *this; +} + + +// unary operators +D3DX10INLINE D3DXVECTOR4 +D3DXVECTOR4::operator + () const +{ + return *this; +} + +D3DX10INLINE D3DXVECTOR4 +D3DXVECTOR4::operator - () const +{ + return D3DXVECTOR4(-x, -y, -z, -w); +} + + +// binary operators +D3DX10INLINE D3DXVECTOR4 +D3DXVECTOR4::operator + ( CONST D3DXVECTOR4& v ) const +{ + return D3DXVECTOR4(x + v.x, y + v.y, z + v.z, w + v.w); +} + +D3DX10INLINE D3DXVECTOR4 +D3DXVECTOR4::operator - ( CONST D3DXVECTOR4& v ) const +{ + return D3DXVECTOR4(x - v.x, y - v.y, z - v.z, w - v.w); +} + +D3DX10INLINE D3DXVECTOR4 +D3DXVECTOR4::operator * ( FLOAT f ) const +{ + return D3DXVECTOR4(x * f, y * f, z * f, w * f); +} + +D3DX10INLINE D3DXVECTOR4 +D3DXVECTOR4::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXVECTOR4(x * fInv, y * fInv, z * fInv, w * fInv); +} + +D3DX10INLINE D3DXVECTOR4 +operator * ( FLOAT f, CONST D3DXVECTOR4& v ) +{ + return D3DXVECTOR4(f * v.x, f * v.y, f * v.z, f * v.w); +} + + +D3DX10INLINE BOOL +D3DXVECTOR4::operator == ( CONST D3DXVECTOR4& v ) const +{ + return x == v.x && y == v.y && z == v.z && w == v.w; +} + +D3DX10INLINE BOOL +D3DXVECTOR4::operator != ( CONST D3DXVECTOR4& v ) const +{ + return x != v.x || y != v.y || z != v.z || w != v.w; +} + + + +//-------------------------- +// 4D Vector (16 bit) +//-------------------------- + +D3DX10INLINE +D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST FLOAT *pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + D3DXFloat32To16Array(&x, pf, 4); +} + +D3DX10INLINE +D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXFLOAT16 *pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + *((UINT *) &x) = *((UINT *) &pf[0]); + *((UINT *) &z) = *((UINT *) &pf[2]); +} + +D3DX10INLINE +D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXVECTOR3_16F& v, CONST D3DXFLOAT16& f ) +{ + x = v.x; + y = v.y; + z = v.z; + w = f; +} + +D3DX10INLINE +D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy, CONST D3DXFLOAT16 &fz, CONST D3DXFLOAT16 &fw ) +{ + x = fx; + y = fy; + z = fz; + w = fw; +} + + +// casting +D3DX10INLINE +D3DXVECTOR4_16F::operator D3DXFLOAT16* () +{ + return (D3DXFLOAT16*) &x; +} + +D3DX10INLINE +D3DXVECTOR4_16F::operator CONST D3DXFLOAT16* () const +{ + return (CONST D3DXFLOAT16*) &x; +} + + +// binary operators +D3DX10INLINE BOOL +D3DXVECTOR4_16F::operator == ( CONST D3DXVECTOR4_16F &v ) const +{ + return *((UINT *) &x) == *((UINT *) &v.x) && + *((UINT *) &z) == *((UINT *) &v.z); +} + +D3DX10INLINE BOOL +D3DXVECTOR4_16F::operator != ( CONST D3DXVECTOR4_16F &v ) const +{ + return *((UINT *) &x) != *((UINT *) &v.x) || + *((UINT *) &z) != *((UINT *) &v.z); +} + + +//-------------------------- +// Matrix +//-------------------------- +D3DX10INLINE +D3DXMATRIX::D3DXMATRIX( CONST FLOAT* pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + memcpy(&_11, pf, sizeof(D3DXMATRIX)); +} + +D3DX10INLINE +D3DXMATRIX::D3DXMATRIX( CONST D3DMATRIX& mat ) +{ + memcpy(&_11, &mat, sizeof(D3DXMATRIX)); +} + +D3DX10INLINE +D3DXMATRIX::D3DXMATRIX( CONST D3DXFLOAT16* pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + D3DXFloat16To32Array(&_11, pf, 16); +} + +D3DX10INLINE +D3DXMATRIX::D3DXMATRIX( FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14, + FLOAT f21, FLOAT f22, FLOAT f23, FLOAT f24, + FLOAT f31, FLOAT f32, FLOAT f33, FLOAT f34, + FLOAT f41, FLOAT f42, FLOAT f43, FLOAT f44 ) +{ + _11 = f11; _12 = f12; _13 = f13; _14 = f14; + _21 = f21; _22 = f22; _23 = f23; _24 = f24; + _31 = f31; _32 = f32; _33 = f33; _34 = f34; + _41 = f41; _42 = f42; _43 = f43; _44 = f44; +} + + + +// access grants +D3DX10INLINE FLOAT& +D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) +{ + return m[iRow][iCol]; +} + +D3DX10INLINE FLOAT +D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) const +{ + return m[iRow][iCol]; +} + + +// casting operators +D3DX10INLINE +D3DXMATRIX::operator FLOAT* () +{ + return (FLOAT *) &_11; +} + +D3DX10INLINE +D3DXMATRIX::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &_11; +} + + +// assignment operators +D3DX10INLINE D3DXMATRIX& +D3DXMATRIX::operator *= ( CONST D3DXMATRIX& mat ) +{ + D3DXMatrixMultiply(this, this, &mat); + return *this; +} + +D3DX10INLINE D3DXMATRIX& +D3DXMATRIX::operator += ( CONST D3DXMATRIX& mat ) +{ + _11 += mat._11; _12 += mat._12; _13 += mat._13; _14 += mat._14; + _21 += mat._21; _22 += mat._22; _23 += mat._23; _24 += mat._24; + _31 += mat._31; _32 += mat._32; _33 += mat._33; _34 += mat._34; + _41 += mat._41; _42 += mat._42; _43 += mat._43; _44 += mat._44; + return *this; +} + +D3DX10INLINE D3DXMATRIX& +D3DXMATRIX::operator -= ( CONST D3DXMATRIX& mat ) +{ + _11 -= mat._11; _12 -= mat._12; _13 -= mat._13; _14 -= mat._14; + _21 -= mat._21; _22 -= mat._22; _23 -= mat._23; _24 -= mat._24; + _31 -= mat._31; _32 -= mat._32; _33 -= mat._33; _34 -= mat._34; + _41 -= mat._41; _42 -= mat._42; _43 -= mat._43; _44 -= mat._44; + return *this; +} + +D3DX10INLINE D3DXMATRIX& +D3DXMATRIX::operator *= ( FLOAT f ) +{ + _11 *= f; _12 *= f; _13 *= f; _14 *= f; + _21 *= f; _22 *= f; _23 *= f; _24 *= f; + _31 *= f; _32 *= f; _33 *= f; _34 *= f; + _41 *= f; _42 *= f; _43 *= f; _44 *= f; + return *this; +} + +D3DX10INLINE D3DXMATRIX& +D3DXMATRIX::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + _11 *= fInv; _12 *= fInv; _13 *= fInv; _14 *= fInv; + _21 *= fInv; _22 *= fInv; _23 *= fInv; _24 *= fInv; + _31 *= fInv; _32 *= fInv; _33 *= fInv; _34 *= fInv; + _41 *= fInv; _42 *= fInv; _43 *= fInv; _44 *= fInv; + return *this; +} + + +// unary operators +D3DX10INLINE D3DXMATRIX +D3DXMATRIX::operator + () const +{ + return *this; +} + +D3DX10INLINE D3DXMATRIX +D3DXMATRIX::operator - () const +{ + return D3DXMATRIX(-_11, -_12, -_13, -_14, + -_21, -_22, -_23, -_24, + -_31, -_32, -_33, -_34, + -_41, -_42, -_43, -_44); +} + + +// binary operators +D3DX10INLINE D3DXMATRIX +D3DXMATRIX::operator * ( CONST D3DXMATRIX& mat ) const +{ + D3DXMATRIX matT; + D3DXMatrixMultiply(&matT, this, &mat); + return matT; +} + +D3DX10INLINE D3DXMATRIX +D3DXMATRIX::operator + ( CONST D3DXMATRIX& mat ) const +{ + return D3DXMATRIX(_11 + mat._11, _12 + mat._12, _13 + mat._13, _14 + mat._14, + _21 + mat._21, _22 + mat._22, _23 + mat._23, _24 + mat._24, + _31 + mat._31, _32 + mat._32, _33 + mat._33, _34 + mat._34, + _41 + mat._41, _42 + mat._42, _43 + mat._43, _44 + mat._44); +} + +D3DX10INLINE D3DXMATRIX +D3DXMATRIX::operator - ( CONST D3DXMATRIX& mat ) const +{ + return D3DXMATRIX(_11 - mat._11, _12 - mat._12, _13 - mat._13, _14 - mat._14, + _21 - mat._21, _22 - mat._22, _23 - mat._23, _24 - mat._24, + _31 - mat._31, _32 - mat._32, _33 - mat._33, _34 - mat._34, + _41 - mat._41, _42 - mat._42, _43 - mat._43, _44 - mat._44); +} + +D3DX10INLINE D3DXMATRIX +D3DXMATRIX::operator * ( FLOAT f ) const +{ + return D3DXMATRIX(_11 * f, _12 * f, _13 * f, _14 * f, + _21 * f, _22 * f, _23 * f, _24 * f, + _31 * f, _32 * f, _33 * f, _34 * f, + _41 * f, _42 * f, _43 * f, _44 * f); +} + +D3DX10INLINE D3DXMATRIX +D3DXMATRIX::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXMATRIX(_11 * fInv, _12 * fInv, _13 * fInv, _14 * fInv, + _21 * fInv, _22 * fInv, _23 * fInv, _24 * fInv, + _31 * fInv, _32 * fInv, _33 * fInv, _34 * fInv, + _41 * fInv, _42 * fInv, _43 * fInv, _44 * fInv); +} + + +D3DX10INLINE D3DXMATRIX +operator * ( FLOAT f, CONST D3DXMATRIX& mat ) +{ + return D3DXMATRIX(f * mat._11, f * mat._12, f * mat._13, f * mat._14, + f * mat._21, f * mat._22, f * mat._23, f * mat._24, + f * mat._31, f * mat._32, f * mat._33, f * mat._34, + f * mat._41, f * mat._42, f * mat._43, f * mat._44); +} + + +D3DX10INLINE BOOL +D3DXMATRIX::operator == ( CONST D3DXMATRIX& mat ) const +{ + return 0 == memcmp(this, &mat, sizeof(D3DXMATRIX)); +} + +D3DX10INLINE BOOL +D3DXMATRIX::operator != ( CONST D3DXMATRIX& mat ) const +{ + return 0 != memcmp(this, &mat, sizeof(D3DXMATRIX)); +} + + + +//-------------------------- +// Aligned Matrices +//-------------------------- + +D3DX10INLINE +_D3DXMATRIXA16::_D3DXMATRIXA16( CONST FLOAT* f ) : + D3DXMATRIX( f ) +{ +} + +D3DX10INLINE +_D3DXMATRIXA16::_D3DXMATRIXA16( CONST D3DMATRIX& m ) : + D3DXMATRIX( m ) +{ +} + +D3DX10INLINE +_D3DXMATRIXA16::_D3DXMATRIXA16( CONST D3DXFLOAT16* f ) : + D3DXMATRIX( f ) +{ +} + +D3DX10INLINE +_D3DXMATRIXA16::_D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, + FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, + FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, + FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ) : + D3DXMATRIX(_11, _12, _13, _14, + _21, _22, _23, _24, + _31, _32, _33, _34, + _41, _42, _43, _44) +{ +} + +D3DX10INLINE void* +_D3DXMATRIXA16::operator new( size_t s ) +{ + LPBYTE p = ::new BYTE[s + 16]; + if (p) + { + BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); + p += offset; + p[-1] = offset; + } + return p; +} + +D3DX10INLINE void* +_D3DXMATRIXA16::operator new[]( size_t s ) +{ + LPBYTE p = ::new BYTE[s + 16]; + if (p) + { + BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); + p += offset; + p[-1] = offset; + } + return p; +} + +D3DX10INLINE void +_D3DXMATRIXA16::operator delete(void* p) +{ + if(p) + { + BYTE* pb = static_cast(p); + pb -= pb[-1]; + ::delete [] pb; + } +} + +D3DX10INLINE void +_D3DXMATRIXA16::operator delete[](void* p) +{ + if(p) + { + BYTE* pb = static_cast(p); + pb -= pb[-1]; + ::delete [] pb; + } +} + +D3DX10INLINE _D3DXMATRIXA16& +_D3DXMATRIXA16::operator=(CONST D3DXMATRIX& rhs) +{ + memcpy(&_11, &rhs, sizeof(D3DXMATRIX)); + return *this; +} + + +//-------------------------- +// Quaternion +//-------------------------- + +D3DX10INLINE +D3DXQUATERNION::D3DXQUATERNION( CONST FLOAT* pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; + w = pf[3]; +} + +D3DX10INLINE +D3DXQUATERNION::D3DXQUATERNION( CONST D3DXFLOAT16* pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + D3DXFloat16To32Array(&x, pf, 4); +} + +D3DX10INLINE +D3DXQUATERNION::D3DXQUATERNION( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) +{ + x = fx; + y = fy; + z = fz; + w = fw; +} + + +// casting +D3DX10INLINE +D3DXQUATERNION::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DX10INLINE +D3DXQUATERNION::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + + +// assignment operators +D3DX10INLINE D3DXQUATERNION& +D3DXQUATERNION::operator += ( CONST D3DXQUATERNION& q ) +{ + x += q.x; + y += q.y; + z += q.z; + w += q.w; + return *this; +} + +D3DX10INLINE D3DXQUATERNION& +D3DXQUATERNION::operator -= ( CONST D3DXQUATERNION& q ) +{ + x -= q.x; + y -= q.y; + z -= q.z; + w -= q.w; + return *this; +} + +D3DX10INLINE D3DXQUATERNION& +D3DXQUATERNION::operator *= ( CONST D3DXQUATERNION& q ) +{ + D3DXQuaternionMultiply(this, this, &q); + return *this; +} + +D3DX10INLINE D3DXQUATERNION& +D3DXQUATERNION::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + z *= f; + w *= f; + return *this; +} + +D3DX10INLINE D3DXQUATERNION& +D3DXQUATERNION::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + w *= fInv; + return *this; +} + + +// unary operators +D3DX10INLINE D3DXQUATERNION +D3DXQUATERNION::operator + () const +{ + return *this; +} + +D3DX10INLINE D3DXQUATERNION +D3DXQUATERNION::operator - () const +{ + return D3DXQUATERNION(-x, -y, -z, -w); +} + + +// binary operators +D3DX10INLINE D3DXQUATERNION +D3DXQUATERNION::operator + ( CONST D3DXQUATERNION& q ) const +{ + return D3DXQUATERNION(x + q.x, y + q.y, z + q.z, w + q.w); +} + +D3DX10INLINE D3DXQUATERNION +D3DXQUATERNION::operator - ( CONST D3DXQUATERNION& q ) const +{ + return D3DXQUATERNION(x - q.x, y - q.y, z - q.z, w - q.w); +} + +D3DX10INLINE D3DXQUATERNION +D3DXQUATERNION::operator * ( CONST D3DXQUATERNION& q ) const +{ + D3DXQUATERNION qT; + D3DXQuaternionMultiply(&qT, this, &q); + return qT; +} + +D3DX10INLINE D3DXQUATERNION +D3DXQUATERNION::operator * ( FLOAT f ) const +{ + return D3DXQUATERNION(x * f, y * f, z * f, w * f); +} + +D3DX10INLINE D3DXQUATERNION +D3DXQUATERNION::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXQUATERNION(x * fInv, y * fInv, z * fInv, w * fInv); +} + + +D3DX10INLINE D3DXQUATERNION +operator * (FLOAT f, CONST D3DXQUATERNION& q ) +{ + return D3DXQUATERNION(f * q.x, f * q.y, f * q.z, f * q.w); +} + + +D3DX10INLINE BOOL +D3DXQUATERNION::operator == ( CONST D3DXQUATERNION& q ) const +{ + return x == q.x && y == q.y && z == q.z && w == q.w; +} + +D3DX10INLINE BOOL +D3DXQUATERNION::operator != ( CONST D3DXQUATERNION& q ) const +{ + return x != q.x || y != q.y || z != q.z || w != q.w; +} + + + +//-------------------------- +// Plane +//-------------------------- + +D3DX10INLINE +D3DXPLANE::D3DXPLANE( CONST FLOAT* pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + a = pf[0]; + b = pf[1]; + c = pf[2]; + d = pf[3]; +} + +D3DX10INLINE +D3DXPLANE::D3DXPLANE( CONST D3DXFLOAT16* pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + D3DXFloat16To32Array(&a, pf, 4); +} + +D3DX10INLINE +D3DXPLANE::D3DXPLANE( FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd ) +{ + a = fa; + b = fb; + c = fc; + d = fd; +} + + +// casting +D3DX10INLINE +D3DXPLANE::operator FLOAT* () +{ + return (FLOAT *) &a; +} + +D3DX10INLINE +D3DXPLANE::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &a; +} + + +// assignment operators +D3DX10INLINE D3DXPLANE& +D3DXPLANE::operator *= ( FLOAT f ) +{ + a *= f; + b *= f; + c *= f; + d *= f; + return *this; +} + +D3DX10INLINE D3DXPLANE& +D3DXPLANE::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + a *= fInv; + b *= fInv; + c *= fInv; + d *= fInv; + return *this; +} + + +// unary operators +D3DX10INLINE D3DXPLANE +D3DXPLANE::operator + () const +{ + return *this; +} + +D3DX10INLINE D3DXPLANE +D3DXPLANE::operator - () const +{ + return D3DXPLANE(-a, -b, -c, -d); +} + + +// binary operators +D3DX10INLINE D3DXPLANE +D3DXPLANE::operator * ( FLOAT f ) const +{ + return D3DXPLANE(a * f, b * f, c * f, d * f); +} + +D3DX10INLINE D3DXPLANE +D3DXPLANE::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXPLANE(a * fInv, b * fInv, c * fInv, d * fInv); +} + +D3DX10INLINE D3DXPLANE +operator * (FLOAT f, CONST D3DXPLANE& p ) +{ + return D3DXPLANE(f * p.a, f * p.b, f * p.c, f * p.d); +} + +D3DX10INLINE BOOL +D3DXPLANE::operator == ( CONST D3DXPLANE& p ) const +{ + return a == p.a && b == p.b && c == p.c && d == p.d; +} + +D3DX10INLINE BOOL +D3DXPLANE::operator != ( CONST D3DXPLANE& p ) const +{ + return a != p.a || b != p.b || c != p.c || d != p.d; +} + + + + +//-------------------------- +// Color +//-------------------------- + +D3DX10INLINE +D3DXCOLOR::D3DXCOLOR( UINT dw ) +{ + CONST FLOAT f = 1.0f / 255.0f; + r = f * (FLOAT) (unsigned char) (dw >> 16); + g = f * (FLOAT) (unsigned char) (dw >> 8); + b = f * (FLOAT) (unsigned char) (dw >> 0); + a = f * (FLOAT) (unsigned char) (dw >> 24); +} + +D3DX10INLINE +D3DXCOLOR::D3DXCOLOR( CONST FLOAT* pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + r = pf[0]; + g = pf[1]; + b = pf[2]; + a = pf[3]; +} + +D3DX10INLINE +D3DXCOLOR::D3DXCOLOR( CONST D3DXFLOAT16* pf ) +{ +#ifdef D3DX10_DEBUG + if(!pf) + return; +#endif + + D3DXFloat16To32Array(&r, pf, 4); +} + +D3DX10INLINE +D3DXCOLOR::D3DXCOLOR( FLOAT fr, FLOAT fg, FLOAT fb, FLOAT fa ) +{ + r = fr; + g = fg; + b = fb; + a = fa; +} + + +// casting +D3DX10INLINE +D3DXCOLOR::operator UINT () const +{ + UINT dwR = r >= 1.0f ? 0xff : r <= 0.0f ? 0x00 : (UINT) (r * 255.0f + 0.5f); + UINT dwG = g >= 1.0f ? 0xff : g <= 0.0f ? 0x00 : (UINT) (g * 255.0f + 0.5f); + UINT dwB = b >= 1.0f ? 0xff : b <= 0.0f ? 0x00 : (UINT) (b * 255.0f + 0.5f); + UINT dwA = a >= 1.0f ? 0xff : a <= 0.0f ? 0x00 : (UINT) (a * 255.0f + 0.5f); + + return (dwA << 24) | (dwR << 16) | (dwG << 8) | (dwB << 0); +} + + +D3DX10INLINE +D3DXCOLOR::operator FLOAT * () +{ + return (FLOAT *) &r; +} + +D3DX10INLINE +D3DXCOLOR::operator CONST FLOAT * () const +{ + return (CONST FLOAT *) &r; +} + +// assignment operators +D3DX10INLINE D3DXCOLOR& +D3DXCOLOR::operator += ( CONST D3DXCOLOR& c ) +{ + r += c.r; + g += c.g; + b += c.b; + a += c.a; + return *this; +} + +D3DX10INLINE D3DXCOLOR& +D3DXCOLOR::operator -= ( CONST D3DXCOLOR& c ) +{ + r -= c.r; + g -= c.g; + b -= c.b; + a -= c.a; + return *this; +} + +D3DX10INLINE D3DXCOLOR& +D3DXCOLOR::operator *= ( FLOAT f ) +{ + r *= f; + g *= f; + b *= f; + a *= f; + return *this; +} + +D3DX10INLINE D3DXCOLOR& +D3DXCOLOR::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + r *= fInv; + g *= fInv; + b *= fInv; + a *= fInv; + return *this; +} + + +// unary operators +D3DX10INLINE D3DXCOLOR +D3DXCOLOR::operator + () const +{ + return *this; +} + +D3DX10INLINE D3DXCOLOR +D3DXCOLOR::operator - () const +{ + return D3DXCOLOR(-r, -g, -b, -a); +} + + +// binary operators +D3DX10INLINE D3DXCOLOR +D3DXCOLOR::operator + ( CONST D3DXCOLOR& c ) const +{ + return D3DXCOLOR(r + c.r, g + c.g, b + c.b, a + c.a); +} + +D3DX10INLINE D3DXCOLOR +D3DXCOLOR::operator - ( CONST D3DXCOLOR& c ) const +{ + return D3DXCOLOR(r - c.r, g - c.g, b - c.b, a - c.a); +} + +D3DX10INLINE D3DXCOLOR +D3DXCOLOR::operator * ( FLOAT f ) const +{ + return D3DXCOLOR(r * f, g * f, b * f, a * f); +} + +D3DX10INLINE D3DXCOLOR +D3DXCOLOR::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXCOLOR(r * fInv, g * fInv, b * fInv, a * fInv); +} + + +D3DX10INLINE D3DXCOLOR +operator * (FLOAT f, CONST D3DXCOLOR& c ) +{ + return D3DXCOLOR(f * c.r, f * c.g, f * c.b, f * c.a); +} + + +D3DX10INLINE BOOL +D3DXCOLOR::operator == ( CONST D3DXCOLOR& c ) const +{ + return r == c.r && g == c.g && b == c.b && a == c.a; +} + +D3DX10INLINE BOOL +D3DXCOLOR::operator != ( CONST D3DXCOLOR& c ) const +{ + return r != c.r || g != c.g || b != c.b || a != c.a; +} + + +#endif //__cplusplus + + + +//=========================================================================== +// +// Inline functions +// +//=========================================================================== + + +//-------------------------- +// 2D Vector +//-------------------------- + +D3DX10INLINE FLOAT D3DXVec2Length + ( CONST D3DXVECTOR2 *pV ) +{ +#ifdef D3DX10_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y); +#else + return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y); +#endif +} + +D3DX10INLINE FLOAT D3DXVec2LengthSq + ( CONST D3DXVECTOR2 *pV ) +{ +#ifdef D3DX10_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y; +} + +D3DX10INLINE FLOAT D3DXVec2Dot + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX10_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y; +} + +D3DX10INLINE FLOAT D3DXVec2CCW + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX10_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->y - pV1->y * pV2->x; +} + +D3DX10INLINE D3DXVECTOR2* D3DXVec2Add + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + return pOut; +} + +D3DX10INLINE D3DXVECTOR2* D3DXVec2Subtract + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + return pOut; +} + +D3DX10INLINE D3DXVECTOR2* D3DXVec2Minimize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + return pOut; +} + +D3DX10INLINE D3DXVECTOR2* D3DXVec2Maximize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + return pOut; +} + +D3DX10INLINE D3DXVECTOR2* D3DXVec2Scale + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + return pOut; +} + +D3DX10INLINE D3DXVECTOR2* D3DXVec2Lerp + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + FLOAT s ) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + return pOut; +} + + +//-------------------------- +// 3D Vector +//-------------------------- + +D3DX10INLINE FLOAT D3DXVec3Length + ( CONST D3DXVECTOR3 *pV ) +{ +#ifdef D3DX10_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); +#else + return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); +#endif +} + +D3DX10INLINE FLOAT D3DXVec3LengthSq + ( CONST D3DXVECTOR3 *pV ) +{ +#ifdef D3DX10_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z; +} + +D3DX10INLINE FLOAT D3DXVec3Dot + ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX10_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z; +} + +D3DX10INLINE D3DXVECTOR3* D3DXVec3Cross + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ + D3DXVECTOR3 v; + +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + 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; +} + +D3DX10INLINE D3DXVECTOR3* D3DXVec3Add + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + pOut->z = pV1->z + pV2->z; + return pOut; +} + +D3DX10INLINE D3DXVECTOR3* D3DXVec3Subtract + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + pOut->z = pV1->z - pV2->z; + return pOut; +} + +D3DX10INLINE D3DXVECTOR3* D3DXVec3Minimize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; + return pOut; +} + +D3DX10INLINE D3DXVECTOR3* D3DXVec3Maximize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; + return pOut; +} + +D3DX10INLINE D3DXVECTOR3* D3DXVec3Scale + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + pOut->z = pV->z * s; + return pOut; +} + +D3DX10INLINE D3DXVECTOR3* D3DXVec3Lerp + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + FLOAT s ) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + pOut->z = pV1->z + s * (pV2->z - pV1->z); + return pOut; +} + + +//-------------------------- +// 4D Vector +//-------------------------- + +D3DX10INLINE FLOAT D3DXVec4Length + ( CONST D3DXVECTOR4 *pV ) +{ +#ifdef D3DX10_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); +#else + return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); +#endif +} + +D3DX10INLINE FLOAT D3DXVec4LengthSq + ( CONST D3DXVECTOR4 *pV ) +{ +#ifdef D3DX10_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w; +} + +D3DX10INLINE FLOAT D3DXVec4Dot + ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ) +{ +#ifdef D3DX10_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z + pV1->w * pV2->w; +} + +D3DX10INLINE D3DXVECTOR4* D3DXVec4Add + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + pOut->z = pV1->z + pV2->z; + pOut->w = pV1->w + pV2->w; + return pOut; +} + +D3DX10INLINE D3DXVECTOR4* D3DXVec4Subtract + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + pOut->z = pV1->z - pV2->z; + pOut->w = pV1->w - pV2->w; + return pOut; +} + +D3DX10INLINE D3DXVECTOR4* D3DXVec4Minimize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; + pOut->w = pV1->w < pV2->w ? pV1->w : pV2->w; + return pOut; +} + +D3DX10INLINE D3DXVECTOR4* D3DXVec4Maximize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; + pOut->w = pV1->w > pV2->w ? pV1->w : pV2->w; + return pOut; +} + +D3DX10INLINE D3DXVECTOR4* D3DXVec4Scale + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + pOut->z = pV->z * s; + pOut->w = pV->w * s; + return pOut; +} + +D3DX10INLINE D3DXVECTOR4* D3DXVec4Lerp + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + FLOAT s ) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + pOut->z = pV1->z + s * (pV2->z - pV1->z); + pOut->w = pV1->w + s * (pV2->w - pV1->w); + return pOut; +} + + +//-------------------------- +// 4D Matrix +//-------------------------- + +D3DX10INLINE D3DXMATRIX* D3DXMatrixIdentity + ( D3DXMATRIX *pOut ) +{ +#ifdef D3DX10_DEBUG + if(!pOut) + return NULL; +#endif + + pOut->m[0][1] = pOut->m[0][2] = pOut->m[0][3] = + pOut->m[1][0] = pOut->m[1][2] = pOut->m[1][3] = + pOut->m[2][0] = pOut->m[2][1] = pOut->m[2][3] = + pOut->m[3][0] = pOut->m[3][1] = pOut->m[3][2] = 0.0f; + + pOut->m[0][0] = pOut->m[1][1] = pOut->m[2][2] = pOut->m[3][3] = 1.0f; + return pOut; +} + + +D3DX10INLINE BOOL D3DXMatrixIsIdentity + ( CONST D3DXMATRIX *pM ) +{ +#ifdef D3DX10_DEBUG + if(!pM) + return FALSE; +#endif + + return pM->m[0][0] == 1.0f && pM->m[0][1] == 0.0f && pM->m[0][2] == 0.0f && pM->m[0][3] == 0.0f && + pM->m[1][0] == 0.0f && pM->m[1][1] == 1.0f && pM->m[1][2] == 0.0f && pM->m[1][3] == 0.0f && + pM->m[2][0] == 0.0f && pM->m[2][1] == 0.0f && pM->m[2][2] == 1.0f && pM->m[2][3] == 0.0f && + pM->m[3][0] == 0.0f && pM->m[3][1] == 0.0f && pM->m[3][2] == 0.0f && pM->m[3][3] == 1.0f; +} + + +//-------------------------- +// Quaternion +//-------------------------- + +D3DX10INLINE FLOAT D3DXQuaternionLength + ( CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX10_DEBUG + if(!pQ) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); +#else + return (FLOAT) sqrt(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); +#endif +} + +D3DX10INLINE FLOAT D3DXQuaternionLengthSq + ( CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX10_DEBUG + if(!pQ) + return 0.0f; +#endif + + return pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w; +} + +D3DX10INLINE FLOAT D3DXQuaternionDot + ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ) +{ +#ifdef D3DX10_DEBUG + if(!pQ1 || !pQ2) + return 0.0f; +#endif + + return pQ1->x * pQ2->x + pQ1->y * pQ2->y + pQ1->z * pQ2->z + pQ1->w * pQ2->w; +} + + +D3DX10INLINE D3DXQUATERNION* D3DXQuaternionIdentity + ( D3DXQUATERNION *pOut ) +{ +#ifdef D3DX10_DEBUG + if(!pOut) + return NULL; +#endif + + pOut->x = pOut->y = pOut->z = 0.0f; + pOut->w = 1.0f; + return pOut; +} + +D3DX10INLINE BOOL D3DXQuaternionIsIdentity + ( CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX10_DEBUG + if(!pQ) + return FALSE; +#endif + + return pQ->x == 0.0f && pQ->y == 0.0f && pQ->z == 0.0f && pQ->w == 1.0f; +} + + +D3DX10INLINE D3DXQUATERNION* D3DXQuaternionConjugate + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pQ) + return NULL; +#endif + + pOut->x = -pQ->x; + pOut->y = -pQ->y; + pOut->z = -pQ->z; + pOut->w = pQ->w; + return pOut; +} + + +//-------------------------- +// Plane +//-------------------------- + +D3DX10INLINE FLOAT D3DXPlaneDot + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV) +{ +#ifdef D3DX10_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d * pV->w; +} + +D3DX10INLINE FLOAT D3DXPlaneDotCoord + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV) +{ +#ifdef D3DX10_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d; +} + +D3DX10INLINE FLOAT D3DXPlaneDotNormal + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV) +{ +#ifdef D3DX10_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z; +} + +D3DX10INLINE D3DXPLANE* D3DXPlaneScale + (D3DXPLANE *pOut, CONST D3DXPLANE *pP, FLOAT s) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pP) + return NULL; +#endif + + pOut->a = pP->a * s; + pOut->b = pP->b * s; + pOut->c = pP->c * s; + pOut->d = pP->d * s; + return pOut; +} + + +//-------------------------- +// Color +//-------------------------- + +D3DX10INLINE D3DXCOLOR* D3DXColorNegative + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pC) + return NULL; +#endif + + pOut->r = 1.0f - pC->r; + pOut->g = 1.0f - pC->g; + pOut->b = 1.0f - pC->b; + pOut->a = pC->a; + return pOut; +} + +D3DX10INLINE D3DXCOLOR* D3DXColorAdd + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r + pC2->r; + pOut->g = pC1->g + pC2->g; + pOut->b = pC1->b + pC2->b; + pOut->a = pC1->a + pC2->a; + return pOut; +} + +D3DX10INLINE D3DXCOLOR* D3DXColorSubtract + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r - pC2->r; + pOut->g = pC1->g - pC2->g; + pOut->b = pC1->b - pC2->b; + pOut->a = pC1->a - pC2->a; + return pOut; +} + +D3DX10INLINE D3DXCOLOR* D3DXColorScale + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pC) + return NULL; +#endif + + pOut->r = pC->r * s; + pOut->g = pC->g * s; + pOut->b = pC->b * s; + pOut->a = pC->a * s; + return pOut; +} + +D3DX10INLINE D3DXCOLOR* D3DXColorModulate + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r * pC2->r; + pOut->g = pC1->g * pC2->g; + pOut->b = pC1->b * pC2->b; + pOut->a = pC1->a * pC2->a; + return pOut; +} + +D3DX10INLINE D3DXCOLOR* D3DXColorLerp + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s) +{ +#ifdef D3DX10_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r + s * (pC2->r - pC1->r); + pOut->g = pC1->g + s * (pC2->g - pC1->g); + pOut->b = pC1->b + s * (pC2->b - pC1->b); + pOut->a = pC1->a + s * (pC2->a - pC1->a); + return pOut; +} + + +#endif // __D3DXMATH_INL__ + diff --git a/src/dep/include/DXSDK/include/D3DX10mesh.h b/src/dep/include/DXSDK/include/D3DX10mesh.h index 3078204..9171022 100644 --- a/src/dep/include/DXSDK/include/D3DX10mesh.h +++ b/src/dep/include/DXSDK/include/D3DX10mesh.h @@ -1,286 +1,286 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx10mesh.h -// Content: D3DX10 mesh types and functions -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx10.h" - -#ifndef __D3DX10MESH_H__ -#define __D3DX10MESH_H__ - -// {7ED943DD-52E8-40b5-A8D8-76685C406330} -DEFINE_GUID(IID_ID3DX10BaseMesh, -0x7ed943dd, 0x52e8, 0x40b5, 0xa8, 0xd8, 0x76, 0x68, 0x5c, 0x40, 0x63, 0x30); - -// {04B0D117-1041-46b1-AA8A-3952848BA22E} -DEFINE_GUID(IID_ID3DX10MeshBuffer, -0x4b0d117, 0x1041, 0x46b1, 0xaa, 0x8a, 0x39, 0x52, 0x84, 0x8b, 0xa2, 0x2e); - -// {4020E5C2-1403-4929-883F-E2E849FAC195} -DEFINE_GUID(IID_ID3DX10Mesh, -0x4020e5c2, 0x1403, 0x4929, 0x88, 0x3f, 0xe2, 0xe8, 0x49, 0xfa, 0xc1, 0x95); - -// {8875769A-D579-4088-AAEB-534D1AD84E96} -DEFINE_GUID(IID_ID3DX10PMesh, -0x8875769a, 0xd579, 0x4088, 0xaa, 0xeb, 0x53, 0x4d, 0x1a, 0xd8, 0x4e, 0x96); - -// {667EA4C7-F1CD-4386-B523-7C0290B83CC5} -DEFINE_GUID(IID_ID3DX10SPMesh, -0x667ea4c7, 0xf1cd, 0x4386, 0xb5, 0x23, 0x7c, 0x2, 0x90, 0xb8, 0x3c, 0xc5); - -// {3CE6CC22-DBF2-44f4-894D-F9C34A337139} -DEFINE_GUID(IID_ID3DX10PatchMesh, -0x3ce6cc22, 0xdbf2, 0x44f4, 0x89, 0x4d, 0xf9, 0xc3, 0x4a, 0x33, 0x71, 0x39); - - -// Mesh options - lower 3 bytes only, upper byte used by _D3DX10MESHOPT option flags -enum _D3DX10MESH { - D3DX10_MESH_32_BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. - D3DX10_MESH_GS_ADJACENCY = 0x004, // If set, mesh contains GS adjacency info. Not valid on input. - -}; - -typedef struct _D3DX10_ATTRIBUTE_RANGE -{ - UINT AttribId; - UINT FaceStart; - UINT FaceCount; - UINT VertexStart; - UINT VertexCount; -} D3DX10_ATTRIBUTE_RANGE; - -typedef D3DX10_ATTRIBUTE_RANGE* LPD3DX10_ATTRIBUTE_RANGE; - -typedef enum _D3DX10_MESH_DISCARD_FLAGS -{ - D3DX10_MESH_DISCARD_ATTRIBUTE_BUFFER = 0x01, - D3DX10_MESH_DISCARD_ATTRIBUTE_TABLE = 0x02, - D3DX10_MESH_DISCARD_POINTREPS = 0x04, - D3DX10_MESH_DISCARD_ADJACENCY = 0x08, - D3DX10_MESH_DISCARD_DEVICE_BUFFERS = 0x10, - -} D3DX10_MESH_DISCARD_FLAGS; - -typedef struct _D3DX10_WELD_EPSILONS -{ - FLOAT Position; // NOTE: This does NOT replace the epsilon in GenerateAdjacency - // in general, it should be the same value or greater than the one passed to GeneratedAdjacency - FLOAT BlendWeights; - FLOAT Normal; - FLOAT PSize; - FLOAT Specular; - FLOAT Diffuse; - FLOAT Texcoord[8]; - FLOAT Tangent; - FLOAT Binormal; - FLOAT TessFactor; -} D3DX10_WELD_EPSILONS; - -typedef D3DX10_WELD_EPSILONS* LPD3DX10_WELD_EPSILONS; - -typedef struct _D3DX10_INTERSECT_INFO -{ - UINT FaceIndex; // index of face intersected - FLOAT U; // Barycentric Hit Coordinates - FLOAT V; // Barycentric Hit Coordinates - FLOAT Dist; // Ray-Intersection Parameter Distance -} D3DX10_INTERSECT_INFO, *LPD3DX10_INTERSECT_INFO; - -// ID3DX10MeshBuffer is used by D3DX10Mesh vertex and index buffers -#undef INTERFACE -#define INTERFACE ID3DX10MeshBuffer - -DECLARE_INTERFACE_(ID3DX10MeshBuffer, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DX10MeshBuffer - STDMETHOD(Map)(THIS_ void **ppData, SIZE_T *pSize) PURE; - STDMETHOD(Unmap)(THIS) PURE; - STDMETHOD_(SIZE_T, GetSize)(THIS) PURE; -}; - -// D3DX10 Mesh interfaces -#undef INTERFACE -#define INTERFACE ID3DX10Mesh - -DECLARE_INTERFACE_(ID3DX10Mesh, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DX10Mesh - STDMETHOD_(UINT, GetFaceCount)(THIS) PURE; - STDMETHOD_(UINT, GetVertexCount)(THIS) PURE; - STDMETHOD_(UINT, GetVertexBufferCount)(THIS) PURE; - STDMETHOD_(UINT, GetFlags)(THIS) PURE; - STDMETHOD(GetVertexDescription)(THIS_ CONST D3D10_INPUT_ELEMENT_DESC **ppDesc, UINT *pDeclCount) PURE; - - STDMETHOD(SetVertexData)(THIS_ UINT iBuffer, CONST void *pData) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ UINT iBuffer, ID3DX10MeshBuffer **ppVertexBuffer) PURE; - - STDMETHOD(SetIndexData)(THIS_ CONST void *pData, UINT cIndices) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ ID3DX10MeshBuffer **ppIndexBuffer) PURE; - - STDMETHOD(SetAttributeData)(THIS_ CONST UINT *pData) PURE; - STDMETHOD(GetAttributeBuffer)(THIS_ ID3DX10MeshBuffer **ppAttributeBuffer) PURE; - - STDMETHOD(SetAttributeTable)(THIS_ CONST D3DX10_ATTRIBUTE_RANGE *pAttribTable, UINT cAttribTableSize) PURE; - STDMETHOD(GetAttributeTable)(THIS_ D3DX10_ATTRIBUTE_RANGE *pAttribTable, UINT *pAttribTableSize) PURE; - - STDMETHOD(GenerateAdjacencyAndPointReps)(THIS_ FLOAT Epsilon) PURE; - STDMETHOD(GenerateGSAdjacency)(THIS) PURE; - - STDMETHOD(SetAdjacencyData)(THIS_ CONST UINT *pAdjacency) PURE; - STDMETHOD(GetAdjacencyBuffer)(THIS_ ID3DX10MeshBuffer **ppAdjacency) PURE; - - STDMETHOD(SetPointRepData)(THIS_ CONST UINT *pPointReps) PURE; - STDMETHOD(GetPointRepBuffer)(THIS_ ID3DX10MeshBuffer **ppPointReps) PURE; - - STDMETHOD(Discard)(THIS_ D3DX10_MESH_DISCARD_FLAGS dwDiscard) PURE; - STDMETHOD(CloneMesh)(THIS_ UINT Flags, LPCWSTR pPosSemantic, CONST D3D10_INPUT_ELEMENT_DESC *pDesc, UINT DeclCount, ID3DX10Mesh** ppCloneMesh) PURE; - - STDMETHOD(Optimize)(THIS_ UINT Flags, UINT * pFaceRemap, LPD3D10BLOB *ppVertexRemap) PURE; - STDMETHOD(GenerateAttributeBufferFromTable)(THIS) PURE; - - STDMETHOD(Intersect)(THIS_ D3DXVECTOR3 *pRayPos, D3DXVECTOR3 *pRayDir, - UINT *pHitCount, UINT *pFaceIndex, float *pU, float *pV, float *pDist, ID3D10Blob **ppAllHits); - STDMETHOD(IntersectSubset)(THIS_ UINT AttribId, D3DXVECTOR3 *pRayPos, D3DXVECTOR3 *pRayDir, - UINT *pHitCount, UINT *pFaceIndex, float *pU, float *pV, float *pDist, ID3D10Blob **ppAllHits); - - // ID3DX10Mesh - Device functions - STDMETHOD(CommitToDevice)(THIS) PURE; - STDMETHOD(DrawSubset)(THIS_ UINT AttribId) PURE; - STDMETHOD(DrawSubsetInstanced)(THIS_ UINT AttribId, UINT InstanceCount, UINT StartInstanceLocation) PURE; - - STDMETHOD(GetDeviceVertexBuffer)(THIS_ UINT iBuffer, ID3D10Buffer **ppVertexBuffer) PURE; - STDMETHOD(GetDeviceIndexBuffer)(THIS_ ID3D10Buffer **ppIndexBuffer) PURE; -}; - - -// Flat API -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DX10CreateMesh( - ID3D10Device *pDevice, - CONST D3D10_INPUT_ELEMENT_DESC *pDeclaration, - UINT DeclCount, - LPCWSTR pPositionSemantic, - UINT VertexCount, - UINT FaceCount, - UINT Options, - ID3DX10Mesh **ppMesh); - -#ifdef __cplusplus -} -#endif //__cplusplus - - -// ID3DX10Mesh::Optimize options - upper byte only, lower 3 bytes used from _D3DX10MESH option flags -enum _D3DX10MESHOPT { - D3DX10_MESHOPT_COMPACT = 0x01000000, - D3DX10_MESHOPT_ATTR_SORT = 0x02000000, - D3DX10_MESHOPT_VERTEX_CACHE = 0x04000000, - D3DX10_MESHOPT_STRIP_REORDER = 0x08000000, - D3DX10_MESHOPT_IGNORE_VERTS = 0x10000000, // optimize faces only, don't touch vertices - D3DX10_MESHOPT_DO_NOT_SPLIT = 0x20000000, // do not split vertices shared between attribute groups when attribute sorting - D3DX10_MESHOPT_DEVICE_INDEPENDENT = 0x00400000, // Only affects VCache. uses a static known good cache size for all cards - - // D3DX10_MESHOPT_SHAREVB has been removed, please use D3DX10MESH_VB_SHARE instead - -}; - - -////////////////////////////////////////////////////////////////////////// -// ID3DXSkinInfo -////////////////////////////////////////////////////////////////////////// - -// {420BD604-1C76-4a34-A466-E45D0658A32C} -DEFINE_GUID(IID_ID3DX10SkinInfo, -0x420bd604, 0x1c76, 0x4a34, 0xa4, 0x66, 0xe4, 0x5d, 0x6, 0x58, 0xa3, 0x2c); - -// scaling modes for ID3DX10SkinInfo::Compact() & ID3DX10SkinInfo::UpdateMesh() -#define D3DX10_SKININFO_NO_SCALING 0 -#define D3DX10_SKININFO_SCALE_TO_1 1 -#define D3DX10_SKININFO_SCALE_TO_TOTAL 2 - -typedef struct _D3DX10_SKINNING_CHANNEL -{ - UINT SrcOffset; - UINT DestOffset; - BOOL IsNormal; -} D3DX10_SKINNING_CHANNEL; - -#undef INTERFACE -#define INTERFACE ID3DX10SkinInfo - -typedef struct ID3DX10SkinInfo *LPD3DX10SKININFO; - -DECLARE_INTERFACE_(ID3DX10SkinInfo, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - STDMETHOD_(UINT , GetNumVertices)(THIS) PURE; - STDMETHOD_(UINT , GetNumBones)(THIS) PURE; - STDMETHOD_(UINT , GetMaxBoneInfluences)(THIS) PURE; - - STDMETHOD(AddVertices)(THIS_ UINT Count) PURE; - STDMETHOD(RemapVertices)(THIS_ UINT NewVertexCount, UINT *pVertexRemap) PURE; - - STDMETHOD(AddBones)(THIS_ UINT Count) PURE; - STDMETHOD(RemoveBone)(THIS_ UINT Index) PURE; - STDMETHOD(RemapBones)(THIS_ UINT NewBoneCount, UINT *pBoneRemap) PURE; - - STDMETHOD(AddBoneInfluences)(THIS_ UINT BoneIndex, UINT InfluenceCount, UINT *pIndices, float *pWeights) PURE; - STDMETHOD(ClearBoneInfluences)(THIS_ UINT BoneIndex) PURE; - STDMETHOD_(UINT , GetBoneInfluenceCount)(THIS_ UINT BoneIndex) PURE; - STDMETHOD(GetBoneInfluences)(THIS_ UINT BoneIndex, UINT Offset, UINT Count, UINT *pDestIndices, float *pDestWeights) PURE; - STDMETHOD(FindBoneInfluenceIndex)(THIS_ UINT BoneIndex, UINT VertexIndex, UINT *pInfluenceIndex) PURE; - STDMETHOD(SetBoneInfluence)(THIS_ UINT BoneIndex, UINT InfluenceIndex, float Weight) PURE; - STDMETHOD(GetBoneInfluence)(THIS_ UINT BoneIndex, UINT InfluenceIndex, float *pWeight) PURE; - - STDMETHOD(Compact)(THIS_ UINT MaxPerVertexInfluences, UINT ScaleMode, float MinWeight) PURE; - STDMETHOD(DoSoftwareSkinning)(UINT StartVertex, UINT VertexCount, void *pSrcVertices, UINT SrcStride, void *pDestVertices, UINT DestStride, D3DXMATRIX *pBoneMatrices, D3DXMATRIX *pInverseTransposeBoneMatrices, D3DX10_SKINNING_CHANNEL *pChannelDescs, UINT NumChannels) PURE; -}; - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DX10CreateSkinInfo(LPD3DX10SKININFO* ppSkinInfo); - -#ifdef __cplusplus -} -#endif //__cplusplus - -typedef struct _D3DX10_ATTRIBUTE_WEIGHTS -{ - FLOAT Position; - FLOAT Boundary; - FLOAT Normal; - FLOAT Diffuse; - FLOAT Specular; - FLOAT Texcoord[8]; - FLOAT Tangent; - FLOAT Binormal; -} D3DX10_ATTRIBUTE_WEIGHTS, *LPD3DX10_ATTRIBUTE_WEIGHTS; - -#endif //__D3DX10MESH_H__ - - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx10mesh.h +// Content: D3DX10 mesh types and functions +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx10.h" + +#ifndef __D3DX10MESH_H__ +#define __D3DX10MESH_H__ + +// {7ED943DD-52E8-40b5-A8D8-76685C406330} +DEFINE_GUID(IID_ID3DX10BaseMesh, +0x7ed943dd, 0x52e8, 0x40b5, 0xa8, 0xd8, 0x76, 0x68, 0x5c, 0x40, 0x63, 0x30); + +// {04B0D117-1041-46b1-AA8A-3952848BA22E} +DEFINE_GUID(IID_ID3DX10MeshBuffer, +0x4b0d117, 0x1041, 0x46b1, 0xaa, 0x8a, 0x39, 0x52, 0x84, 0x8b, 0xa2, 0x2e); + +// {4020E5C2-1403-4929-883F-E2E849FAC195} +DEFINE_GUID(IID_ID3DX10Mesh, +0x4020e5c2, 0x1403, 0x4929, 0x88, 0x3f, 0xe2, 0xe8, 0x49, 0xfa, 0xc1, 0x95); + +// {8875769A-D579-4088-AAEB-534D1AD84E96} +DEFINE_GUID(IID_ID3DX10PMesh, +0x8875769a, 0xd579, 0x4088, 0xaa, 0xeb, 0x53, 0x4d, 0x1a, 0xd8, 0x4e, 0x96); + +// {667EA4C7-F1CD-4386-B523-7C0290B83CC5} +DEFINE_GUID(IID_ID3DX10SPMesh, +0x667ea4c7, 0xf1cd, 0x4386, 0xb5, 0x23, 0x7c, 0x2, 0x90, 0xb8, 0x3c, 0xc5); + +// {3CE6CC22-DBF2-44f4-894D-F9C34A337139} +DEFINE_GUID(IID_ID3DX10PatchMesh, +0x3ce6cc22, 0xdbf2, 0x44f4, 0x89, 0x4d, 0xf9, 0xc3, 0x4a, 0x33, 0x71, 0x39); + + +// Mesh options - lower 3 bytes only, upper byte used by _D3DX10MESHOPT option flags +enum _D3DX10MESH { + D3DX10_MESH_32_BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. + D3DX10_MESH_GS_ADJACENCY = 0x004, // If set, mesh contains GS adjacency info. Not valid on input. + +}; + +typedef struct _D3DX10_ATTRIBUTE_RANGE +{ + UINT AttribId; + UINT FaceStart; + UINT FaceCount; + UINT VertexStart; + UINT VertexCount; +} D3DX10_ATTRIBUTE_RANGE; + +typedef D3DX10_ATTRIBUTE_RANGE* LPD3DX10_ATTRIBUTE_RANGE; + +typedef enum _D3DX10_MESH_DISCARD_FLAGS +{ + D3DX10_MESH_DISCARD_ATTRIBUTE_BUFFER = 0x01, + D3DX10_MESH_DISCARD_ATTRIBUTE_TABLE = 0x02, + D3DX10_MESH_DISCARD_POINTREPS = 0x04, + D3DX10_MESH_DISCARD_ADJACENCY = 0x08, + D3DX10_MESH_DISCARD_DEVICE_BUFFERS = 0x10, + +} D3DX10_MESH_DISCARD_FLAGS; + +typedef struct _D3DX10_WELD_EPSILONS +{ + FLOAT Position; // NOTE: This does NOT replace the epsilon in GenerateAdjacency + // in general, it should be the same value or greater than the one passed to GeneratedAdjacency + FLOAT BlendWeights; + FLOAT Normal; + FLOAT PSize; + FLOAT Specular; + FLOAT Diffuse; + FLOAT Texcoord[8]; + FLOAT Tangent; + FLOAT Binormal; + FLOAT TessFactor; +} D3DX10_WELD_EPSILONS; + +typedef D3DX10_WELD_EPSILONS* LPD3DX10_WELD_EPSILONS; + +typedef struct _D3DX10_INTERSECT_INFO +{ + UINT FaceIndex; // index of face intersected + FLOAT U; // Barycentric Hit Coordinates + FLOAT V; // Barycentric Hit Coordinates + FLOAT Dist; // Ray-Intersection Parameter Distance +} D3DX10_INTERSECT_INFO, *LPD3DX10_INTERSECT_INFO; + +// ID3DX10MeshBuffer is used by D3DX10Mesh vertex and index buffers +#undef INTERFACE +#define INTERFACE ID3DX10MeshBuffer + +DECLARE_INTERFACE_(ID3DX10MeshBuffer, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DX10MeshBuffer + STDMETHOD(Map)(THIS_ void **ppData, SIZE_T *pSize) PURE; + STDMETHOD(Unmap)(THIS) PURE; + STDMETHOD_(SIZE_T, GetSize)(THIS) PURE; +}; + +// D3DX10 Mesh interfaces +#undef INTERFACE +#define INTERFACE ID3DX10Mesh + +DECLARE_INTERFACE_(ID3DX10Mesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DX10Mesh + STDMETHOD_(UINT, GetFaceCount)(THIS) PURE; + STDMETHOD_(UINT, GetVertexCount)(THIS) PURE; + STDMETHOD_(UINT, GetVertexBufferCount)(THIS) PURE; + STDMETHOD_(UINT, GetFlags)(THIS) PURE; + STDMETHOD(GetVertexDescription)(THIS_ CONST D3D10_INPUT_ELEMENT_DESC **ppDesc, UINT *pDeclCount) PURE; + + STDMETHOD(SetVertexData)(THIS_ UINT iBuffer, CONST void *pData) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ UINT iBuffer, ID3DX10MeshBuffer **ppVertexBuffer) PURE; + + STDMETHOD(SetIndexData)(THIS_ CONST void *pData, UINT cIndices) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ ID3DX10MeshBuffer **ppIndexBuffer) PURE; + + STDMETHOD(SetAttributeData)(THIS_ CONST UINT *pData) PURE; + STDMETHOD(GetAttributeBuffer)(THIS_ ID3DX10MeshBuffer **ppAttributeBuffer) PURE; + + STDMETHOD(SetAttributeTable)(THIS_ CONST D3DX10_ATTRIBUTE_RANGE *pAttribTable, UINT cAttribTableSize) PURE; + STDMETHOD(GetAttributeTable)(THIS_ D3DX10_ATTRIBUTE_RANGE *pAttribTable, UINT *pAttribTableSize) PURE; + + STDMETHOD(GenerateAdjacencyAndPointReps)(THIS_ FLOAT Epsilon) PURE; + STDMETHOD(GenerateGSAdjacency)(THIS) PURE; + + STDMETHOD(SetAdjacencyData)(THIS_ CONST UINT *pAdjacency) PURE; + STDMETHOD(GetAdjacencyBuffer)(THIS_ ID3DX10MeshBuffer **ppAdjacency) PURE; + + STDMETHOD(SetPointRepData)(THIS_ CONST UINT *pPointReps) PURE; + STDMETHOD(GetPointRepBuffer)(THIS_ ID3DX10MeshBuffer **ppPointReps) PURE; + + STDMETHOD(Discard)(THIS_ D3DX10_MESH_DISCARD_FLAGS dwDiscard) PURE; + STDMETHOD(CloneMesh)(THIS_ UINT Flags, LPCWSTR pPosSemantic, CONST D3D10_INPUT_ELEMENT_DESC *pDesc, UINT DeclCount, ID3DX10Mesh** ppCloneMesh) PURE; + + STDMETHOD(Optimize)(THIS_ UINT Flags, UINT * pFaceRemap, LPD3D10BLOB *ppVertexRemap) PURE; + STDMETHOD(GenerateAttributeBufferFromTable)(THIS) PURE; + + STDMETHOD(Intersect)(THIS_ D3DXVECTOR3 *pRayPos, D3DXVECTOR3 *pRayDir, + UINT *pHitCount, UINT *pFaceIndex, float *pU, float *pV, float *pDist, ID3D10Blob **ppAllHits); + STDMETHOD(IntersectSubset)(THIS_ UINT AttribId, D3DXVECTOR3 *pRayPos, D3DXVECTOR3 *pRayDir, + UINT *pHitCount, UINT *pFaceIndex, float *pU, float *pV, float *pDist, ID3D10Blob **ppAllHits); + + // ID3DX10Mesh - Device functions + STDMETHOD(CommitToDevice)(THIS) PURE; + STDMETHOD(DrawSubset)(THIS_ UINT AttribId) PURE; + STDMETHOD(DrawSubsetInstanced)(THIS_ UINT AttribId, UINT InstanceCount, UINT StartInstanceLocation) PURE; + + STDMETHOD(GetDeviceVertexBuffer)(THIS_ UINT iBuffer, ID3D10Buffer **ppVertexBuffer) PURE; + STDMETHOD(GetDeviceIndexBuffer)(THIS_ ID3D10Buffer **ppIndexBuffer) PURE; +}; + + +// Flat API +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DX10CreateMesh( + ID3D10Device *pDevice, + CONST D3D10_INPUT_ELEMENT_DESC *pDeclaration, + UINT DeclCount, + LPCWSTR pPositionSemantic, + UINT VertexCount, + UINT FaceCount, + UINT Options, + ID3DX10Mesh **ppMesh); + +#ifdef __cplusplus +} +#endif //__cplusplus + + +// ID3DX10Mesh::Optimize options - upper byte only, lower 3 bytes used from _D3DX10MESH option flags +enum _D3DX10MESHOPT { + D3DX10_MESHOPT_COMPACT = 0x01000000, + D3DX10_MESHOPT_ATTR_SORT = 0x02000000, + D3DX10_MESHOPT_VERTEX_CACHE = 0x04000000, + D3DX10_MESHOPT_STRIP_REORDER = 0x08000000, + D3DX10_MESHOPT_IGNORE_VERTS = 0x10000000, // optimize faces only, don't touch vertices + D3DX10_MESHOPT_DO_NOT_SPLIT = 0x20000000, // do not split vertices shared between attribute groups when attribute sorting + D3DX10_MESHOPT_DEVICE_INDEPENDENT = 0x00400000, // Only affects VCache. uses a static known good cache size for all cards + + // D3DX10_MESHOPT_SHAREVB has been removed, please use D3DX10MESH_VB_SHARE instead + +}; + + +////////////////////////////////////////////////////////////////////////// +// ID3DXSkinInfo +////////////////////////////////////////////////////////////////////////// + +// {420BD604-1C76-4a34-A466-E45D0658A32C} +DEFINE_GUID(IID_ID3DX10SkinInfo, +0x420bd604, 0x1c76, 0x4a34, 0xa4, 0x66, 0xe4, 0x5d, 0x6, 0x58, 0xa3, 0x2c); + +// scaling modes for ID3DX10SkinInfo::Compact() & ID3DX10SkinInfo::UpdateMesh() +#define D3DX10_SKININFO_NO_SCALING 0 +#define D3DX10_SKININFO_SCALE_TO_1 1 +#define D3DX10_SKININFO_SCALE_TO_TOTAL 2 + +typedef struct _D3DX10_SKINNING_CHANNEL +{ + UINT SrcOffset; + UINT DestOffset; + BOOL IsNormal; +} D3DX10_SKINNING_CHANNEL; + +#undef INTERFACE +#define INTERFACE ID3DX10SkinInfo + +typedef struct ID3DX10SkinInfo *LPD3DX10SKININFO; + +DECLARE_INTERFACE_(ID3DX10SkinInfo, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + STDMETHOD_(UINT , GetNumVertices)(THIS) PURE; + STDMETHOD_(UINT , GetNumBones)(THIS) PURE; + STDMETHOD_(UINT , GetMaxBoneInfluences)(THIS) PURE; + + STDMETHOD(AddVertices)(THIS_ UINT Count) PURE; + STDMETHOD(RemapVertices)(THIS_ UINT NewVertexCount, UINT *pVertexRemap) PURE; + + STDMETHOD(AddBones)(THIS_ UINT Count) PURE; + STDMETHOD(RemoveBone)(THIS_ UINT Index) PURE; + STDMETHOD(RemapBones)(THIS_ UINT NewBoneCount, UINT *pBoneRemap) PURE; + + STDMETHOD(AddBoneInfluences)(THIS_ UINT BoneIndex, UINT InfluenceCount, UINT *pIndices, float *pWeights) PURE; + STDMETHOD(ClearBoneInfluences)(THIS_ UINT BoneIndex) PURE; + STDMETHOD_(UINT , GetBoneInfluenceCount)(THIS_ UINT BoneIndex) PURE; + STDMETHOD(GetBoneInfluences)(THIS_ UINT BoneIndex, UINT Offset, UINT Count, UINT *pDestIndices, float *pDestWeights) PURE; + STDMETHOD(FindBoneInfluenceIndex)(THIS_ UINT BoneIndex, UINT VertexIndex, UINT *pInfluenceIndex) PURE; + STDMETHOD(SetBoneInfluence)(THIS_ UINT BoneIndex, UINT InfluenceIndex, float Weight) PURE; + STDMETHOD(GetBoneInfluence)(THIS_ UINT BoneIndex, UINT InfluenceIndex, float *pWeight) PURE; + + STDMETHOD(Compact)(THIS_ UINT MaxPerVertexInfluences, UINT ScaleMode, float MinWeight) PURE; + STDMETHOD(DoSoftwareSkinning)(UINT StartVertex, UINT VertexCount, void *pSrcVertices, UINT SrcStride, void *pDestVertices, UINT DestStride, D3DXMATRIX *pBoneMatrices, D3DXMATRIX *pInverseTransposeBoneMatrices, D3DX10_SKINNING_CHANNEL *pChannelDescs, UINT NumChannels) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DX10CreateSkinInfo(LPD3DX10SKININFO* ppSkinInfo); + +#ifdef __cplusplus +} +#endif //__cplusplus + +typedef struct _D3DX10_ATTRIBUTE_WEIGHTS +{ + FLOAT Position; + FLOAT Boundary; + FLOAT Normal; + FLOAT Diffuse; + FLOAT Specular; + FLOAT Texcoord[8]; + FLOAT Tangent; + FLOAT Binormal; +} D3DX10_ATTRIBUTE_WEIGHTS, *LPD3DX10_ATTRIBUTE_WEIGHTS; + +#endif //__D3DX10MESH_H__ + + diff --git a/src/dep/include/DXSDK/include/D3DX10tex.h b/src/dep/include/DXSDK/include/D3DX10tex.h index ebca8ea..43bf939 100644 --- a/src/dep/include/DXSDK/include/D3DX10tex.h +++ b/src/dep/include/DXSDK/include/D3DX10tex.h @@ -1,637 +1,637 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx10tex.h -// Content: D3DX10 texturing APIs -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx10.h" - -#ifndef __D3DX10TEX_H__ -#define __D3DX10TEX_H__ - - -//---------------------------------------------------------------------------- -// D3DX10_FILTER flags: -// ------------------ -// -// A valid filter must contain one of these values: -// -// D3DX10_FILTER_NONE -// No scaling or filtering will take place. Pixels outside the bounds -// of the source image are assumed to be transparent black. -// D3DX10_FILTER_POINT -// Each destination pixel is computed by sampling the nearest pixel -// from the source image. -// D3DX10_FILTER_LINEAR -// Each destination pixel is computed by linearly interpolating between -// the nearest pixels in the source image. This filter works best -// when the scale on each axis is less than 2. -// D3DX10_FILTER_TRIANGLE -// Every pixel in the source image contributes equally to the -// destination image. This is the slowest of all the filters. -// D3DX10_FILTER_BOX -// Each pixel is computed by averaging a 2x2(x2) box pixels from -// the source image. Only works when the dimensions of the -// destination are half those of the source. (as with mip maps) -// -// And can be OR'd with any of these optional flags: -// -// D3DX10_FILTER_MIRROR_U -// Indicates that pixels off the edge of the texture on the U-axis -// should be mirrored, not wraped. -// D3DX10_FILTER_MIRROR_V -// Indicates that pixels off the edge of the texture on the V-axis -// should be mirrored, not wraped. -// D3DX10_FILTER_MIRROR_W -// Indicates that pixels off the edge of the texture on the W-axis -// should be mirrored, not wraped. -// D3DX10_FILTER_MIRROR -// Same as specifying D3DX10_FILTER_MIRROR_U | D3DX10_FILTER_MIRROR_V | -// D3DX10_FILTER_MIRROR_V -// D3DX10_FILTER_DITHER -// Dithers the resulting image using a 4x4 order dither pattern. -// D3DX10_FILTER_SRGB_IN -// Denotes that the input data is in sRGB (gamma 2.2) colorspace. -// D3DX10_FILTER_SRGB_OUT -// Denotes that the output data is in sRGB (gamma 2.2) colorspace. -// D3DX10_FILTER_SRGB -// Same as specifying D3DX10_FILTER_SRGB_IN | D3DX10_FILTER_SRGB_OUT -// -//---------------------------------------------------------------------------- - -typedef enum D3DX10_FILTER_FLAG -{ - D3DX10_FILTER_NONE = (1 << 0), - D3DX10_FILTER_POINT = (2 << 0), - D3DX10_FILTER_LINEAR = (3 << 0), - D3DX10_FILTER_TRIANGLE = (4 << 0), - D3DX10_FILTER_BOX = (5 << 0), - - D3DX10_FILTER_MIRROR_U = (1 << 16), - D3DX10_FILTER_MIRROR_V = (2 << 16), - D3DX10_FILTER_MIRROR_W = (4 << 16), - D3DX10_FILTER_MIRROR = (7 << 16), - - D3DX10_FILTER_DITHER = (1 << 19), - D3DX10_FILTER_DITHER_DIFFUSION= (2 << 19), - - D3DX10_FILTER_SRGB_IN = (1 << 21), - D3DX10_FILTER_SRGB_OUT = (2 << 21), - D3DX10_FILTER_SRGB = (3 << 21), -} D3DX10_FILTER_FLAG; - -//---------------------------------------------------------------------------- -// D3DX10_NORMALMAP flags: -// --------------------- -// These flags are used to control how D3DX10ComputeNormalMap generates normal -// maps. Any number of these flags may be OR'd together in any combination. -// -// D3DX10_NORMALMAP_MIRROR_U -// Indicates that pixels off the edge of the texture on the U-axis -// should be mirrored, not wraped. -// D3DX10_NORMALMAP_MIRROR_V -// Indicates that pixels off the edge of the texture on the V-axis -// should be mirrored, not wraped. -// D3DX10_NORMALMAP_MIRROR -// Same as specifying D3DX10_NORMALMAP_MIRROR_U | D3DX10_NORMALMAP_MIRROR_V -// D3DX10_NORMALMAP_INVERTSIGN -// Inverts the direction of each normal -// D3DX10_NORMALMAP_COMPUTE_OCCLUSION -// Compute the per pixel Occlusion term and encodes it into the alpha. -// An Alpha of 1 means that the pixel is not obscured in anyway, and -// an alpha of 0 would mean that the pixel is completly obscured. -// -//---------------------------------------------------------------------------- - -typedef enum D3DX10_NORMALMAP_FLAG -{ - D3DX10_NORMALMAP_MIRROR_U = (1 << 16), - D3DX10_NORMALMAP_MIRROR_V = (2 << 16), - D3DX10_NORMALMAP_MIRROR = (3 << 16), - D3DX10_NORMALMAP_INVERTSIGN = (8 << 16), - D3DX10_NORMALMAP_COMPUTE_OCCLUSION = (16 << 16), -} D3DX10_NORMALMAP_FLAG; - -//---------------------------------------------------------------------------- -// D3DX10_CHANNEL flags: -// ------------------- -// These flags are used by functions which operate on or more channels -// in a texture. -// -// D3DX10_CHANNEL_RED -// Indicates the red channel should be used -// D3DX10_CHANNEL_BLUE -// Indicates the blue channel should be used -// D3DX10_CHANNEL_GREEN -// Indicates the green channel should be used -// D3DX10_CHANNEL_ALPHA -// Indicates the alpha channel should be used -// D3DX10_CHANNEL_LUMINANCE -// Indicates the luminaces of the red green and blue channels should be -// used. -// -//---------------------------------------------------------------------------- - -typedef enum D3DX10_CHANNEL_FLAG -{ - D3DX10_CHANNEL_RED = (1 << 0), - D3DX10_CHANNEL_BLUE = (1 << 1), - D3DX10_CHANNEL_GREEN = (1 << 2), - D3DX10_CHANNEL_ALPHA = (1 << 3), - D3DX10_CHANNEL_LUMINANCE = (1 << 4), -} D3DX10_CHANNEL_FLAG; - - - -//---------------------------------------------------------------------------- -// D3DX10_IMAGE_FILE_FORMAT: -// --------------------- -// This enum is used to describe supported image file formats. -// -//---------------------------------------------------------------------------- - -typedef enum _D3DX10_IMAGE_FILE_FORMAT -{ - D3DX10_IFF_BMP = 0, - D3DX10_IFF_JPG = 1, - D3DX10_IFF_PNG = 3, - D3DX10_IFF_DDS = 4, - D3DX10_IFF_TIFF = 10, - D3DX10_IFF_GIF = 11, - D3DX10_IFF_FORCE_DWORD = 0x7fffffff - -} D3DX10_IMAGE_FILE_FORMAT; - - -//---------------------------------------------------------------------------- -// D3DX10_IMAGE_INFO: -// --------------- -// This structure is used to return a rough description of what the -// the original contents of an image file looked like. -// -// Width -// Width of original image in pixels -// Height -// Height of original image in pixels -// Depth -// Depth of original image in pixels -// ArraySize -// Array size in textures -// MipLevels -// Number of mip levels in original image -// Format -// D3D format which most closely describes the data in original image -// ResourceType -// D3DRESOURCETYPE representing the type of texture stored in the file. -// D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE. -// ImageFileFormat -// D3DX10_IMAGE_FILE_FORMAT representing the format of the image file. -// -//---------------------------------------------------------------------------- - -typedef struct _D3DX10_IMAGE_INFO -{ - UINT Width; - UINT Height; - UINT Depth; - UINT ArraySize; - UINT MipLevels; - DXGI_FORMAT Format; - D3D10_RESOURCE ResourceType; - D3DX10_IMAGE_FILE_FORMAT ImageFileFormat; - -} D3DX10_IMAGE_INFO; - - - - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - - -////////////////////////////////////////////////////////////////////////////// -// Image File APIs /////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DX10_IMAGE_LOAD_INFO: -// --------------- -// This structure can be optionally passed in to texture loader APIs to -// control how textures get loaded. Pass in D3DX10_DEFAULT for any of these -// to have D3DX automatically pick defaults based on the source file. -// -// Width -// Rescale texture to Width texels wide -// Height -// Rescale texture to Height texels high -// Depth -// Rescale texture to Depth texels deep -// FirstMipLevel -// First mip level to load -// MipLevels -// Number of mip levels to load after the first level -// Usage -// D3D10_USAGE flag for the new texture -// BindFlags -// D3D10 Bind flags for the new texture -// CpuAccessFlags -// D3D10 CPU Access flags for the new texture -// MiscFlags -// Reserved. Must be 0 -// Format -// Resample texture to the specified format -// Filter -// Filter the texture using the specified filter (only when resampling) -// MipFilter -// Filter the texture mip levels using the specified filter (only if -// generating mips) -// pSrcInfo -// (optional) pointer to a D3DX10_IMAGE_INFO structure that will get -// populated with source image information -// -//---------------------------------------------------------------------------- - -#define D3DX10_IMAGE_LOAD_VALID_FLAGS (0) - -typedef struct _D3DX10_IMAGE_LOAD_INFO -{ - UINT Width; - UINT Height; - UINT Depth; - UINT FirstMipLevel; - UINT MipLevels; - D3D10_USAGE Usage; - UINT32 BindFlags; - UINT32 CpuAccessFlags; - UINT32 MiscFlags; - DXGI_FORMAT Format; - UINT Filter; - UINT MipFilter; - D3DX10_IMAGE_INFO* pSrcInfo; - -#ifdef __cplusplus - _D3DX10_IMAGE_LOAD_INFO() - { - Width = D3DX10_DEFAULT; - Height = D3DX10_DEFAULT; - Depth = D3DX10_DEFAULT; - FirstMipLevel = D3DX10_DEFAULT; - MipLevels = D3DX10_DEFAULT; - Usage = (D3D10_USAGE) D3DX10_DEFAULT; - BindFlags = D3DX10_DEFAULT; - CpuAccessFlags = D3DX10_DEFAULT; - MiscFlags = D3DX10_DEFAULT; - Format = DXGI_FORMAT_FROM_FILE; - Filter = D3DX10_DEFAULT; - MipFilter = D3DX10_DEFAULT; - pSrcInfo = NULL; - } -#endif - -} D3DX10_IMAGE_LOAD_INFO; - -//---------------------------------------------------------------------------- -// D3DX10 Asynchronous texture I/O (advanced mode) -//---------------------------------------------------------------------------- - -HRESULT WINAPI D3DX10CreateAsyncFileLoaderW(LPCWSTR pFileName, ID3DX10DataLoader **ppDataLoader); -HRESULT WINAPI D3DX10CreateAsyncFileLoaderA(LPCSTR pFileName, ID3DX10DataLoader **ppDataLoader); -HRESULT WINAPI D3DX10CreateAsyncMemoryLoader(LPCVOID pData, SIZE_T cbData, ID3DX10DataLoader **ppDataLoader); -HRESULT WINAPI D3DX10CreateAsyncResourceLoaderW(HMODULE hSrcModule, LPCWSTR pSrcResource, ID3DX10DataLoader **ppDataLoader); -HRESULT WINAPI D3DX10CreateAsyncResourceLoaderA(HMODULE hSrcModule, LPCSTR pSrcResource, ID3DX10DataLoader **ppDataLoader); - -#ifdef UNICODE -#define D3DX10CreateAsyncFileLoader D3DX10CreateAsyncFileLoaderW -#define D3DX10CreateAsyncResourceLoader D3DX10CreateAsyncResourceLoaderW -#else -#define D3DX10CreateAsyncFileLoader D3DX10CreateAsyncFileLoaderA -#define D3DX10CreateAsyncResourceLoader D3DX10CreateAsyncResourceLoaderA -#endif - -HRESULT WINAPI D3DX10CreateAsyncTextureProcessor(ID3D10Device *pDevice, D3DX10_IMAGE_LOAD_INFO *pLoadInfo, ID3DX10DataProcessor **ppDataProcessor); -HRESULT WINAPI D3DX10CreateAsyncTextureInfoProcessor(D3DX10_IMAGE_INFO *pImageInfo, ID3DX10DataProcessor **ppDataProcessor); -HRESULT WINAPI D3DX10CreateAsyncShaderResourceViewProcessor(ID3D10Device *pDevice, D3DX10_IMAGE_LOAD_INFO *pLoadInfo, ID3DX10DataProcessor **ppDataProcessor); - -//---------------------------------------------------------------------------- -// GetImageInfoFromFile/Resource/Memory: -// ------------------------------ -// Fills in a D3DX10_IMAGE_INFO struct with information about an image file. -// -// Parameters: -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name. -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pPump -// Optional pointer to a thread pump object to use. -// pSrcInfo -// Pointer to a D3DX10_IMAGE_INFO structure to be filled in with the -// description of the data in the source image file. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DX10GetImageInfoFromFileA( - LPCSTR pSrcFile, - ID3DX10ThreadPump* pPump, - D3DX10_IMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DX10GetImageInfoFromFileW( - LPCWSTR pSrcFile, - ID3DX10ThreadPump* pPump, - D3DX10_IMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DX10GetImageInfoFromFile D3DX10GetImageInfoFromFileW -#else -#define D3DX10GetImageInfoFromFile D3DX10GetImageInfoFromFileA -#endif - - -HRESULT WINAPI - D3DX10GetImageInfoFromResourceA( - HMODULE hSrcModule, - LPCSTR pSrcResource, - ID3DX10ThreadPump* pPump, - D3DX10_IMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DX10GetImageInfoFromResourceW( - HMODULE hSrcModule, - LPCWSTR pSrcResource, - ID3DX10ThreadPump* pPump, - D3DX10_IMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DX10GetImageInfoFromResource D3DX10GetImageInfoFromResourceW -#else -#define D3DX10GetImageInfoFromResource D3DX10GetImageInfoFromResourceA -#endif - - -HRESULT WINAPI - D3DX10GetImageInfoFromMemory( - LPCVOID pSrcData, - SIZE_T SrcDataSize, - ID3DX10ThreadPump* pPump, - D3DX10_IMAGE_INFO* pSrcInfo); - -////////////////////////////////////////////////////////////////////////////// -// Create/Save Texture APIs ////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - - -//---------------------------------------------------------------------------- -// D3DX10CreateTextureFromFile/Resource/Memory: -// D3DX10CreateShaderResourceViewFromFile/Resource/Memory: -// ----------------------------------- -// Create a texture object from a file or resource. -// -// Parameters: -// -// pDevice -// The D3D device with which the texture is going to be used. -// pSrcFile -// File name. -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pvSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pLoadInfo -// Optional pointer to a D3DX10_IMAGE_LOAD_INFO structure that -// contains additional loader parameters. -// pPump -// Optional pointer to a thread pump object to use. -// ppTexture -// [out] Created texture object. -// ppShaderResourceView -// [out] Shader resource view object created. -// -//---------------------------------------------------------------------------- - - -// FromFile - -HRESULT WINAPI - D3DX10CreateShaderResourceViewFromFileA( - ID3D10Device* pDevice, - LPCSTR pSrcFile, - D3DX10_IMAGE_LOAD_INFO *pLoadInfo, - ID3DX10ThreadPump* pPump, - ID3D10ShaderResourceView** ppShaderResourceView); - -HRESULT WINAPI - D3DX10CreateShaderResourceViewFromFileW( - ID3D10Device* pDevice, - LPCWSTR pSrcFile, - D3DX10_IMAGE_LOAD_INFO *pLoadInfo, - ID3DX10ThreadPump* pPump, - ID3D10ShaderResourceView** ppShaderResourceView); - -#ifdef UNICODE -#define D3DX10CreateShaderResourceViewFromFile D3DX10CreateShaderResourceViewFromFileW -#else -#define D3DX10CreateShaderResourceViewFromFile D3DX10CreateShaderResourceViewFromFileA -#endif - -HRESULT WINAPI - D3DX10CreateTextureFromFileA( - ID3D10Device* pDevice, - LPCSTR pSrcFile, - D3DX10_IMAGE_LOAD_INFO *pLoadInfo, - ID3DX10ThreadPump* pPump, - ID3D10Resource** ppShaderResourceView); - -HRESULT WINAPI - D3DX10CreateTextureFromFileW( - ID3D10Device* pDevice, - LPCWSTR pSrcFile, - D3DX10_IMAGE_LOAD_INFO *pLoadInfo, - ID3DX10ThreadPump* pPump, - ID3D10Resource** ppShaderResourceView); - -#ifdef UNICODE -#define D3DX10CreateTextureFromFile D3DX10CreateTextureFromFileW -#else -#define D3DX10CreateTextureFromFile D3DX10CreateTextureFromFileA -#endif - -// FromResource (resources in dll/exes) - -HRESULT WINAPI - D3DX10CreateShaderResourceViewFromResourceA( - ID3D10Device* pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - D3DX10_IMAGE_LOAD_INFO *pLoadInfo, - ID3DX10ThreadPump* pPump, - ID3D10ShaderResourceView** ppShaderResourceView); - -HRESULT WINAPI - D3DX10CreateShaderResourceViewFromResourceW( - ID3D10Device* pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - D3DX10_IMAGE_LOAD_INFO *pLoadInfo, - ID3DX10ThreadPump* pPump, - ID3D10ShaderResourceView** ppShaderResourceView); - -#ifdef UNICODE -#define D3DX10CreateShaderResourceViewFromResource D3DX10CreateShaderResourceViewFromResourceW -#else -#define D3DX10CreateShaderResourceViewFromResource D3DX10CreateShaderResourceViewFromResourceA -#endif - -HRESULT WINAPI - D3DX10CreateTextureFromResourceA( - ID3D10Device* pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - D3DX10_IMAGE_LOAD_INFO *pLoadInfo, - ID3DX10ThreadPump* pPump, - ID3D10Resource** ppTexture); - -HRESULT WINAPI - D3DX10CreateTextureFromResourceW( - ID3D10Device* pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - D3DX10_IMAGE_LOAD_INFO *pLoadInfo, - ID3DX10ThreadPump* pPump, - ID3D10Resource** ppTexture); - -#ifdef UNICODE -#define D3DX10CreateTextureFromResource D3DX10CreateTextureFromResourceW -#else -#define D3DX10CreateTextureFromResource D3DX10CreateTextureFromResourceA -#endif - - -// FromFileInMemory - -HRESULT WINAPI - D3DX10CreateShaderResourceViewFromMemory( - ID3D10Device* pDevice, - LPCVOID pSrcData, - SIZE_T SrcDataSize, - D3DX10_IMAGE_LOAD_INFO *pLoadInfo, - ID3DX10ThreadPump* pPump, - ID3D10ShaderResourceView** ppShaderResourceView); - -HRESULT WINAPI - D3DX10CreateTextureFromMemory( - ID3D10Device* pDevice, - LPCVOID pSrcData, - SIZE_T SrcDataSize, - D3DX10_IMAGE_LOAD_INFO *pLoadInfo, - ID3DX10ThreadPump* pPump, - ID3D10Resource** ppTexture); - - -//---------------------------------------------------------------------------- -// D3DX10SaveTextureToFile: -// ---------------------- -// Save a texture to a file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DX10_IMAGE_FILE_FORMAT specifying file format to use when saving. -// pSrcTexture -// Source texture, containing the image to be saved -// -//---------------------------------------------------------------------------- - - -HRESULT WINAPI - D3DX10SaveTextureToFileA( - ID3D10Resource *pSrcTexture, - D3DX10_IMAGE_FILE_FORMAT DestFormat, - LPCSTR pDestFile); - -HRESULT WINAPI - D3DX10SaveTextureToFileW( - ID3D10Resource *pSrcTexture, - D3DX10_IMAGE_FILE_FORMAT DestFormat, - LPCWSTR pDestFile); - -#ifdef UNICODE -#define D3DX10SaveTextureToFile D3DX10SaveTextureToFileW -#else -#define D3DX10SaveTextureToFile D3DX10SaveTextureToFileA -#endif - -//---------------------------------------------------------------------------- -// D3DX10SaveTextureToMemory: -// ---------------------- -// Save a texture to a file. -// -// Parameters: -// ppDestBuf -// address of a d3dxbuffer pointer to return the image data -// DestFormat -// D3DX10_IMAGE_FILE_FORMAT specifying file format to use when saving. -// pSrcTexture -// Source texture, containing the image to be saved -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DX10SaveTextureToMemory( - ID3D10Resource *pSrcTexture, - D3DX10_IMAGE_FILE_FORMAT DestFormat, - LPD3D10BLOB* ppDestBuf); - - -//---------------------------------------------------------------------------- -// D3DX10ComputeNormalMap: -// --------------------- -// Converts a height map into a normal map. The (x,y,z) components of each -// normal are mapped to the (r,g,b) channels of the output texture. -// -// Parameters -// pSrcTexture -// Pointer to the source heightmap texture -// Flags -// D3DX10_NORMALMAP flags -// Channel -// D3DX10_CHANNEL specifying source of height information -// Amplitude -// The constant value which the height information is multiplied by. -// pDestTexture -// Pointer to the destination texture -//--------------------------------------------------------------------------- - -HRESULT WINAPI - D3DX10ComputeNormalMap( - ID3D10Texture2D *pSrcTexture, - UINT Flags, - UINT Channel, - FLOAT Amplitude, - ID3D10Texture2D *pDestTexture); - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX10TEX_H__ - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx10tex.h +// Content: D3DX10 texturing APIs +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx10.h" + +#ifndef __D3DX10TEX_H__ +#define __D3DX10TEX_H__ + + +//---------------------------------------------------------------------------- +// D3DX10_FILTER flags: +// ------------------ +// +// A valid filter must contain one of these values: +// +// D3DX10_FILTER_NONE +// No scaling or filtering will take place. Pixels outside the bounds +// of the source image are assumed to be transparent black. +// D3DX10_FILTER_POINT +// Each destination pixel is computed by sampling the nearest pixel +// from the source image. +// D3DX10_FILTER_LINEAR +// Each destination pixel is computed by linearly interpolating between +// the nearest pixels in the source image. This filter works best +// when the scale on each axis is less than 2. +// D3DX10_FILTER_TRIANGLE +// Every pixel in the source image contributes equally to the +// destination image. This is the slowest of all the filters. +// D3DX10_FILTER_BOX +// Each pixel is computed by averaging a 2x2(x2) box pixels from +// the source image. Only works when the dimensions of the +// destination are half those of the source. (as with mip maps) +// +// And can be OR'd with any of these optional flags: +// +// D3DX10_FILTER_MIRROR_U +// Indicates that pixels off the edge of the texture on the U-axis +// should be mirrored, not wraped. +// D3DX10_FILTER_MIRROR_V +// Indicates that pixels off the edge of the texture on the V-axis +// should be mirrored, not wraped. +// D3DX10_FILTER_MIRROR_W +// Indicates that pixels off the edge of the texture on the W-axis +// should be mirrored, not wraped. +// D3DX10_FILTER_MIRROR +// Same as specifying D3DX10_FILTER_MIRROR_U | D3DX10_FILTER_MIRROR_V | +// D3DX10_FILTER_MIRROR_V +// D3DX10_FILTER_DITHER +// Dithers the resulting image using a 4x4 order dither pattern. +// D3DX10_FILTER_SRGB_IN +// Denotes that the input data is in sRGB (gamma 2.2) colorspace. +// D3DX10_FILTER_SRGB_OUT +// Denotes that the output data is in sRGB (gamma 2.2) colorspace. +// D3DX10_FILTER_SRGB +// Same as specifying D3DX10_FILTER_SRGB_IN | D3DX10_FILTER_SRGB_OUT +// +//---------------------------------------------------------------------------- + +typedef enum D3DX10_FILTER_FLAG +{ + D3DX10_FILTER_NONE = (1 << 0), + D3DX10_FILTER_POINT = (2 << 0), + D3DX10_FILTER_LINEAR = (3 << 0), + D3DX10_FILTER_TRIANGLE = (4 << 0), + D3DX10_FILTER_BOX = (5 << 0), + + D3DX10_FILTER_MIRROR_U = (1 << 16), + D3DX10_FILTER_MIRROR_V = (2 << 16), + D3DX10_FILTER_MIRROR_W = (4 << 16), + D3DX10_FILTER_MIRROR = (7 << 16), + + D3DX10_FILTER_DITHER = (1 << 19), + D3DX10_FILTER_DITHER_DIFFUSION= (2 << 19), + + D3DX10_FILTER_SRGB_IN = (1 << 21), + D3DX10_FILTER_SRGB_OUT = (2 << 21), + D3DX10_FILTER_SRGB = (3 << 21), +} D3DX10_FILTER_FLAG; + +//---------------------------------------------------------------------------- +// D3DX10_NORMALMAP flags: +// --------------------- +// These flags are used to control how D3DX10ComputeNormalMap generates normal +// maps. Any number of these flags may be OR'd together in any combination. +// +// D3DX10_NORMALMAP_MIRROR_U +// Indicates that pixels off the edge of the texture on the U-axis +// should be mirrored, not wraped. +// D3DX10_NORMALMAP_MIRROR_V +// Indicates that pixels off the edge of the texture on the V-axis +// should be mirrored, not wraped. +// D3DX10_NORMALMAP_MIRROR +// Same as specifying D3DX10_NORMALMAP_MIRROR_U | D3DX10_NORMALMAP_MIRROR_V +// D3DX10_NORMALMAP_INVERTSIGN +// Inverts the direction of each normal +// D3DX10_NORMALMAP_COMPUTE_OCCLUSION +// Compute the per pixel Occlusion term and encodes it into the alpha. +// An Alpha of 1 means that the pixel is not obscured in anyway, and +// an alpha of 0 would mean that the pixel is completly obscured. +// +//---------------------------------------------------------------------------- + +typedef enum D3DX10_NORMALMAP_FLAG +{ + D3DX10_NORMALMAP_MIRROR_U = (1 << 16), + D3DX10_NORMALMAP_MIRROR_V = (2 << 16), + D3DX10_NORMALMAP_MIRROR = (3 << 16), + D3DX10_NORMALMAP_INVERTSIGN = (8 << 16), + D3DX10_NORMALMAP_COMPUTE_OCCLUSION = (16 << 16), +} D3DX10_NORMALMAP_FLAG; + +//---------------------------------------------------------------------------- +// D3DX10_CHANNEL flags: +// ------------------- +// These flags are used by functions which operate on or more channels +// in a texture. +// +// D3DX10_CHANNEL_RED +// Indicates the red channel should be used +// D3DX10_CHANNEL_BLUE +// Indicates the blue channel should be used +// D3DX10_CHANNEL_GREEN +// Indicates the green channel should be used +// D3DX10_CHANNEL_ALPHA +// Indicates the alpha channel should be used +// D3DX10_CHANNEL_LUMINANCE +// Indicates the luminaces of the red green and blue channels should be +// used. +// +//---------------------------------------------------------------------------- + +typedef enum D3DX10_CHANNEL_FLAG +{ + D3DX10_CHANNEL_RED = (1 << 0), + D3DX10_CHANNEL_BLUE = (1 << 1), + D3DX10_CHANNEL_GREEN = (1 << 2), + D3DX10_CHANNEL_ALPHA = (1 << 3), + D3DX10_CHANNEL_LUMINANCE = (1 << 4), +} D3DX10_CHANNEL_FLAG; + + + +//---------------------------------------------------------------------------- +// D3DX10_IMAGE_FILE_FORMAT: +// --------------------- +// This enum is used to describe supported image file formats. +// +//---------------------------------------------------------------------------- + +typedef enum _D3DX10_IMAGE_FILE_FORMAT +{ + D3DX10_IFF_BMP = 0, + D3DX10_IFF_JPG = 1, + D3DX10_IFF_PNG = 3, + D3DX10_IFF_DDS = 4, + D3DX10_IFF_TIFF = 10, + D3DX10_IFF_GIF = 11, + D3DX10_IFF_FORCE_DWORD = 0x7fffffff + +} D3DX10_IMAGE_FILE_FORMAT; + + +//---------------------------------------------------------------------------- +// D3DX10_IMAGE_INFO: +// --------------- +// This structure is used to return a rough description of what the +// the original contents of an image file looked like. +// +// Width +// Width of original image in pixels +// Height +// Height of original image in pixels +// Depth +// Depth of original image in pixels +// ArraySize +// Array size in textures +// MipLevels +// Number of mip levels in original image +// Format +// D3D format which most closely describes the data in original image +// ResourceType +// D3DRESOURCETYPE representing the type of texture stored in the file. +// D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE. +// ImageFileFormat +// D3DX10_IMAGE_FILE_FORMAT representing the format of the image file. +// +//---------------------------------------------------------------------------- + +typedef struct _D3DX10_IMAGE_INFO +{ + UINT Width; + UINT Height; + UINT Depth; + UINT ArraySize; + UINT MipLevels; + DXGI_FORMAT Format; + D3D10_RESOURCE ResourceType; + D3DX10_IMAGE_FILE_FORMAT ImageFileFormat; + +} D3DX10_IMAGE_INFO; + + + + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + + +////////////////////////////////////////////////////////////////////////////// +// Image File APIs /////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DX10_IMAGE_LOAD_INFO: +// --------------- +// This structure can be optionally passed in to texture loader APIs to +// control how textures get loaded. Pass in D3DX10_DEFAULT for any of these +// to have D3DX automatically pick defaults based on the source file. +// +// Width +// Rescale texture to Width texels wide +// Height +// Rescale texture to Height texels high +// Depth +// Rescale texture to Depth texels deep +// FirstMipLevel +// First mip level to load +// MipLevels +// Number of mip levels to load after the first level +// Usage +// D3D10_USAGE flag for the new texture +// BindFlags +// D3D10 Bind flags for the new texture +// CpuAccessFlags +// D3D10 CPU Access flags for the new texture +// MiscFlags +// Reserved. Must be 0 +// Format +// Resample texture to the specified format +// Filter +// Filter the texture using the specified filter (only when resampling) +// MipFilter +// Filter the texture mip levels using the specified filter (only if +// generating mips) +// pSrcInfo +// (optional) pointer to a D3DX10_IMAGE_INFO structure that will get +// populated with source image information +// +//---------------------------------------------------------------------------- + +#define D3DX10_IMAGE_LOAD_VALID_FLAGS (0) + +typedef struct _D3DX10_IMAGE_LOAD_INFO +{ + UINT Width; + UINT Height; + UINT Depth; + UINT FirstMipLevel; + UINT MipLevels; + D3D10_USAGE Usage; + UINT32 BindFlags; + UINT32 CpuAccessFlags; + UINT32 MiscFlags; + DXGI_FORMAT Format; + UINT Filter; + UINT MipFilter; + D3DX10_IMAGE_INFO* pSrcInfo; + +#ifdef __cplusplus + _D3DX10_IMAGE_LOAD_INFO() + { + Width = D3DX10_DEFAULT; + Height = D3DX10_DEFAULT; + Depth = D3DX10_DEFAULT; + FirstMipLevel = D3DX10_DEFAULT; + MipLevels = D3DX10_DEFAULT; + Usage = (D3D10_USAGE) D3DX10_DEFAULT; + BindFlags = D3DX10_DEFAULT; + CpuAccessFlags = D3DX10_DEFAULT; + MiscFlags = D3DX10_DEFAULT; + Format = DXGI_FORMAT_FROM_FILE; + Filter = D3DX10_DEFAULT; + MipFilter = D3DX10_DEFAULT; + pSrcInfo = NULL; + } +#endif + +} D3DX10_IMAGE_LOAD_INFO; + +//---------------------------------------------------------------------------- +// D3DX10 Asynchronous texture I/O (advanced mode) +//---------------------------------------------------------------------------- + +HRESULT WINAPI D3DX10CreateAsyncFileLoaderW(LPCWSTR pFileName, ID3DX10DataLoader **ppDataLoader); +HRESULT WINAPI D3DX10CreateAsyncFileLoaderA(LPCSTR pFileName, ID3DX10DataLoader **ppDataLoader); +HRESULT WINAPI D3DX10CreateAsyncMemoryLoader(LPCVOID pData, SIZE_T cbData, ID3DX10DataLoader **ppDataLoader); +HRESULT WINAPI D3DX10CreateAsyncResourceLoaderW(HMODULE hSrcModule, LPCWSTR pSrcResource, ID3DX10DataLoader **ppDataLoader); +HRESULT WINAPI D3DX10CreateAsyncResourceLoaderA(HMODULE hSrcModule, LPCSTR pSrcResource, ID3DX10DataLoader **ppDataLoader); + +#ifdef UNICODE +#define D3DX10CreateAsyncFileLoader D3DX10CreateAsyncFileLoaderW +#define D3DX10CreateAsyncResourceLoader D3DX10CreateAsyncResourceLoaderW +#else +#define D3DX10CreateAsyncFileLoader D3DX10CreateAsyncFileLoaderA +#define D3DX10CreateAsyncResourceLoader D3DX10CreateAsyncResourceLoaderA +#endif + +HRESULT WINAPI D3DX10CreateAsyncTextureProcessor(ID3D10Device *pDevice, D3DX10_IMAGE_LOAD_INFO *pLoadInfo, ID3DX10DataProcessor **ppDataProcessor); +HRESULT WINAPI D3DX10CreateAsyncTextureInfoProcessor(D3DX10_IMAGE_INFO *pImageInfo, ID3DX10DataProcessor **ppDataProcessor); +HRESULT WINAPI D3DX10CreateAsyncShaderResourceViewProcessor(ID3D10Device *pDevice, D3DX10_IMAGE_LOAD_INFO *pLoadInfo, ID3DX10DataProcessor **ppDataProcessor); + +//---------------------------------------------------------------------------- +// GetImageInfoFromFile/Resource/Memory: +// ------------------------------ +// Fills in a D3DX10_IMAGE_INFO struct with information about an image file. +// +// Parameters: +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name. +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pPump +// Optional pointer to a thread pump object to use. +// pSrcInfo +// Pointer to a D3DX10_IMAGE_INFO structure to be filled in with the +// description of the data in the source image file. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DX10GetImageInfoFromFileA( + LPCSTR pSrcFile, + ID3DX10ThreadPump* pPump, + D3DX10_IMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DX10GetImageInfoFromFileW( + LPCWSTR pSrcFile, + ID3DX10ThreadPump* pPump, + D3DX10_IMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DX10GetImageInfoFromFile D3DX10GetImageInfoFromFileW +#else +#define D3DX10GetImageInfoFromFile D3DX10GetImageInfoFromFileA +#endif + + +HRESULT WINAPI + D3DX10GetImageInfoFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + ID3DX10ThreadPump* pPump, + D3DX10_IMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DX10GetImageInfoFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + ID3DX10ThreadPump* pPump, + D3DX10_IMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DX10GetImageInfoFromResource D3DX10GetImageInfoFromResourceW +#else +#define D3DX10GetImageInfoFromResource D3DX10GetImageInfoFromResourceA +#endif + + +HRESULT WINAPI + D3DX10GetImageInfoFromMemory( + LPCVOID pSrcData, + SIZE_T SrcDataSize, + ID3DX10ThreadPump* pPump, + D3DX10_IMAGE_INFO* pSrcInfo); + +////////////////////////////////////////////////////////////////////////////// +// Create/Save Texture APIs ////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + + +//---------------------------------------------------------------------------- +// D3DX10CreateTextureFromFile/Resource/Memory: +// D3DX10CreateShaderResourceViewFromFile/Resource/Memory: +// ----------------------------------- +// Create a texture object from a file or resource. +// +// Parameters: +// +// pDevice +// The D3D device with which the texture is going to be used. +// pSrcFile +// File name. +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pvSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pLoadInfo +// Optional pointer to a D3DX10_IMAGE_LOAD_INFO structure that +// contains additional loader parameters. +// pPump +// Optional pointer to a thread pump object to use. +// ppTexture +// [out] Created texture object. +// ppShaderResourceView +// [out] Shader resource view object created. +// +//---------------------------------------------------------------------------- + + +// FromFile + +HRESULT WINAPI + D3DX10CreateShaderResourceViewFromFileA( + ID3D10Device* pDevice, + LPCSTR pSrcFile, + D3DX10_IMAGE_LOAD_INFO *pLoadInfo, + ID3DX10ThreadPump* pPump, + ID3D10ShaderResourceView** ppShaderResourceView); + +HRESULT WINAPI + D3DX10CreateShaderResourceViewFromFileW( + ID3D10Device* pDevice, + LPCWSTR pSrcFile, + D3DX10_IMAGE_LOAD_INFO *pLoadInfo, + ID3DX10ThreadPump* pPump, + ID3D10ShaderResourceView** ppShaderResourceView); + +#ifdef UNICODE +#define D3DX10CreateShaderResourceViewFromFile D3DX10CreateShaderResourceViewFromFileW +#else +#define D3DX10CreateShaderResourceViewFromFile D3DX10CreateShaderResourceViewFromFileA +#endif + +HRESULT WINAPI + D3DX10CreateTextureFromFileA( + ID3D10Device* pDevice, + LPCSTR pSrcFile, + D3DX10_IMAGE_LOAD_INFO *pLoadInfo, + ID3DX10ThreadPump* pPump, + ID3D10Resource** ppShaderResourceView); + +HRESULT WINAPI + D3DX10CreateTextureFromFileW( + ID3D10Device* pDevice, + LPCWSTR pSrcFile, + D3DX10_IMAGE_LOAD_INFO *pLoadInfo, + ID3DX10ThreadPump* pPump, + ID3D10Resource** ppShaderResourceView); + +#ifdef UNICODE +#define D3DX10CreateTextureFromFile D3DX10CreateTextureFromFileW +#else +#define D3DX10CreateTextureFromFile D3DX10CreateTextureFromFileA +#endif + +// FromResource (resources in dll/exes) + +HRESULT WINAPI + D3DX10CreateShaderResourceViewFromResourceA( + ID3D10Device* pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + D3DX10_IMAGE_LOAD_INFO *pLoadInfo, + ID3DX10ThreadPump* pPump, + ID3D10ShaderResourceView** ppShaderResourceView); + +HRESULT WINAPI + D3DX10CreateShaderResourceViewFromResourceW( + ID3D10Device* pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + D3DX10_IMAGE_LOAD_INFO *pLoadInfo, + ID3DX10ThreadPump* pPump, + ID3D10ShaderResourceView** ppShaderResourceView); + +#ifdef UNICODE +#define D3DX10CreateShaderResourceViewFromResource D3DX10CreateShaderResourceViewFromResourceW +#else +#define D3DX10CreateShaderResourceViewFromResource D3DX10CreateShaderResourceViewFromResourceA +#endif + +HRESULT WINAPI + D3DX10CreateTextureFromResourceA( + ID3D10Device* pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + D3DX10_IMAGE_LOAD_INFO *pLoadInfo, + ID3DX10ThreadPump* pPump, + ID3D10Resource** ppTexture); + +HRESULT WINAPI + D3DX10CreateTextureFromResourceW( + ID3D10Device* pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + D3DX10_IMAGE_LOAD_INFO *pLoadInfo, + ID3DX10ThreadPump* pPump, + ID3D10Resource** ppTexture); + +#ifdef UNICODE +#define D3DX10CreateTextureFromResource D3DX10CreateTextureFromResourceW +#else +#define D3DX10CreateTextureFromResource D3DX10CreateTextureFromResourceA +#endif + + +// FromFileInMemory + +HRESULT WINAPI + D3DX10CreateShaderResourceViewFromMemory( + ID3D10Device* pDevice, + LPCVOID pSrcData, + SIZE_T SrcDataSize, + D3DX10_IMAGE_LOAD_INFO *pLoadInfo, + ID3DX10ThreadPump* pPump, + ID3D10ShaderResourceView** ppShaderResourceView); + +HRESULT WINAPI + D3DX10CreateTextureFromMemory( + ID3D10Device* pDevice, + LPCVOID pSrcData, + SIZE_T SrcDataSize, + D3DX10_IMAGE_LOAD_INFO *pLoadInfo, + ID3DX10ThreadPump* pPump, + ID3D10Resource** ppTexture); + + +//---------------------------------------------------------------------------- +// D3DX10SaveTextureToFile: +// ---------------------- +// Save a texture to a file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DX10_IMAGE_FILE_FORMAT specifying file format to use when saving. +// pSrcTexture +// Source texture, containing the image to be saved +// +//---------------------------------------------------------------------------- + + +HRESULT WINAPI + D3DX10SaveTextureToFileA( + ID3D10Resource *pSrcTexture, + D3DX10_IMAGE_FILE_FORMAT DestFormat, + LPCSTR pDestFile); + +HRESULT WINAPI + D3DX10SaveTextureToFileW( + ID3D10Resource *pSrcTexture, + D3DX10_IMAGE_FILE_FORMAT DestFormat, + LPCWSTR pDestFile); + +#ifdef UNICODE +#define D3DX10SaveTextureToFile D3DX10SaveTextureToFileW +#else +#define D3DX10SaveTextureToFile D3DX10SaveTextureToFileA +#endif + +//---------------------------------------------------------------------------- +// D3DX10SaveTextureToMemory: +// ---------------------- +// Save a texture to a file. +// +// Parameters: +// ppDestBuf +// address of a d3dxbuffer pointer to return the image data +// DestFormat +// D3DX10_IMAGE_FILE_FORMAT specifying file format to use when saving. +// pSrcTexture +// Source texture, containing the image to be saved +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DX10SaveTextureToMemory( + ID3D10Resource *pSrcTexture, + D3DX10_IMAGE_FILE_FORMAT DestFormat, + LPD3D10BLOB* ppDestBuf); + + +//---------------------------------------------------------------------------- +// D3DX10ComputeNormalMap: +// --------------------- +// Converts a height map into a normal map. The (x,y,z) components of each +// normal are mapped to the (r,g,b) channels of the output texture. +// +// Parameters +// pSrcTexture +// Pointer to the source heightmap texture +// Flags +// D3DX10_NORMALMAP flags +// Channel +// D3DX10_CHANNEL specifying source of height information +// Amplitude +// The constant value which the height information is multiplied by. +// pDestTexture +// Pointer to the destination texture +//--------------------------------------------------------------------------- + +HRESULT WINAPI + D3DX10ComputeNormalMap( + ID3D10Texture2D *pSrcTexture, + UINT Flags, + UINT Channel, + FLOAT Amplitude, + ID3D10Texture2D *pDestTexture); + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX10TEX_H__ + diff --git a/src/dep/include/DXSDK/include/DXGI.h b/src/dep/include/DXSDK/include/DXGI.h index ec161c8..2c203e5 100644 --- a/src/dep/include/DXSDK/include/DXGI.h +++ b/src/dep/include/DXSDK/include/DXGI.h @@ -1,1667 +1,1667 @@ - - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 7.00.0485 */ -/* Compiler settings for dxgi.idl: - Oicf, W1, Zp8, env=Win32 (32b run) - protocol : dce , ms_ext, c_ext, robust - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() -*/ -//@@MIDL_FILE_HEADING( ) - -#pragma warning( disable: 4049 ) /* more than 64k source lines */ - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 475 -#endif - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCSAL_H_VERSION__ -#define __REQUIRED_RPCSAL_H_VERSION__ 100 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ - -#ifndef COM_NO_WINDOWS_H -#include "windows.h" -#include "ole2.h" -#endif /*COM_NO_WINDOWS_H*/ - -#ifndef __dxgi_h__ -#define __dxgi_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -/* Forward Declarations */ - -#ifndef __IDXGIObject_FWD_DEFINED__ -#define __IDXGIObject_FWD_DEFINED__ -typedef interface IDXGIObject IDXGIObject; -#endif /* __IDXGIObject_FWD_DEFINED__ */ - - -#ifndef __IDXGIDeviceSubObject_FWD_DEFINED__ -#define __IDXGIDeviceSubObject_FWD_DEFINED__ -typedef interface IDXGIDeviceSubObject IDXGIDeviceSubObject; -#endif /* __IDXGIDeviceSubObject_FWD_DEFINED__ */ - - -#ifndef __IDXGIResource_FWD_DEFINED__ -#define __IDXGIResource_FWD_DEFINED__ -typedef interface IDXGIResource IDXGIResource; -#endif /* __IDXGIResource_FWD_DEFINED__ */ - - -#ifndef __IDXGISurface_FWD_DEFINED__ -#define __IDXGISurface_FWD_DEFINED__ -typedef interface IDXGISurface IDXGISurface; -#endif /* __IDXGISurface_FWD_DEFINED__ */ - - -#ifndef __IDXGIAdapter_FWD_DEFINED__ -#define __IDXGIAdapter_FWD_DEFINED__ -typedef interface IDXGIAdapter IDXGIAdapter; -#endif /* __IDXGIAdapter_FWD_DEFINED__ */ - - -#ifndef __IDXGIOutput_FWD_DEFINED__ -#define __IDXGIOutput_FWD_DEFINED__ -typedef interface IDXGIOutput IDXGIOutput; -#endif /* __IDXGIOutput_FWD_DEFINED__ */ - - -#ifndef __IDXGISwapChain_FWD_DEFINED__ -#define __IDXGISwapChain_FWD_DEFINED__ -typedef interface IDXGISwapChain IDXGISwapChain; -#endif /* __IDXGISwapChain_FWD_DEFINED__ */ - - -#ifndef __IDXGIFactory_FWD_DEFINED__ -#define __IDXGIFactory_FWD_DEFINED__ -typedef interface IDXGIFactory IDXGIFactory; -#endif /* __IDXGIFactory_FWD_DEFINED__ */ - - -#ifndef __IDXGIDevice_FWD_DEFINED__ -#define __IDXGIDevice_FWD_DEFINED__ -typedef interface IDXGIDevice IDXGIDevice; -#endif /* __IDXGIDevice_FWD_DEFINED__ */ - - -/* header files for imported files */ -#include "dxgitype.h" - -#ifdef __cplusplus -extern "C"{ -#endif - - -#ifndef __IDXGIObject_INTERFACE_DEFINED__ -#define __IDXGIObject_INTERFACE_DEFINED__ - -/* interface IDXGIObject */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIObject; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("aec22fb8-76f3-4639-9be0-28eb43a67a2e") - IDXGIObject : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE SetPrivateData( - /* [in] */ REFGUID Name, - /* [in] */ SIZE_T DataSize, - /* [in] */ const void *pData) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( - /* [in] */ REFGUID Name, - /* [in] */ const IUnknown *pUnknown) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetPrivateData( - /* [in] */ REFGUID Name, - /* [out][in] */ SIZE_T *pDataSize, - /* [out] */ void *pData) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetParent( - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppParent) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXGIObjectVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIObject * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIObject * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIObject * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIObject * This, - /* [in] */ REFGUID Name, - /* [in] */ SIZE_T DataSize, - /* [in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIObject * This, - /* [in] */ REFGUID Name, - /* [in] */ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIObject * This, - /* [in] */ REFGUID Name, - /* [out][in] */ SIZE_T *pDataSize, - /* [out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIObject * This, - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppParent); - - END_INTERFACE - } IDXGIObjectVtbl; - - interface IDXGIObject - { - CONST_VTBL struct IDXGIObjectVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIObject_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIObject_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIObject_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIObject_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIObject_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIObject_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIObject_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIObject_INTERFACE_DEFINED__ */ - - -#ifndef __IDXGIDeviceSubObject_INTERFACE_DEFINED__ -#define __IDXGIDeviceSubObject_INTERFACE_DEFINED__ - -/* interface IDXGIDeviceSubObject */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIDeviceSubObject; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("3d3e0379-f9de-4d58-bb6c-18d62992f1a6") - IDXGIDeviceSubObject : public IDXGIObject - { - public: - virtual HRESULT STDMETHODCALLTYPE GetDevice( - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppDevice) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXGIDeviceSubObjectVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIDeviceSubObject * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIDeviceSubObject * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIDeviceSubObject * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIDeviceSubObject * This, - /* [in] */ REFGUID Name, - /* [in] */ SIZE_T DataSize, - /* [in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIDeviceSubObject * This, - /* [in] */ REFGUID Name, - /* [in] */ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIDeviceSubObject * This, - /* [in] */ REFGUID Name, - /* [out][in] */ SIZE_T *pDataSize, - /* [out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIDeviceSubObject * This, - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetDevice )( - IDXGIDeviceSubObject * This, - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppDevice); - - END_INTERFACE - } IDXGIDeviceSubObjectVtbl; - - interface IDXGIDeviceSubObject - { - CONST_VTBL struct IDXGIDeviceSubObjectVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIDeviceSubObject_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIDeviceSubObject_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIDeviceSubObject_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIDeviceSubObject_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIDeviceSubObject_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIDeviceSubObject_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIDeviceSubObject_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIDeviceSubObject_GetDevice(This,riid,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIDeviceSubObject_INTERFACE_DEFINED__ */ - - -#ifndef __IDXGIResource_INTERFACE_DEFINED__ -#define __IDXGIResource_INTERFACE_DEFINED__ - -/* interface IDXGIResource */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIResource; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("035f3ab4-482e-4e50-b41f-8a7f8bd8960b") - IDXGIResource : public IDXGIDeviceSubObject - { - public: - virtual HRESULT STDMETHODCALLTYPE GetSharedHandle( - /* [out] */ HANDLE *pSharedHandle) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetUsage( - /* [out] */ DXGI_USAGE *pUsage) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetEvictionPriority( - /* [in] */ UINT EvictionPriority) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetEvictionPriority( - /* [retval][out] */ UINT *pEvictionPriority) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXGIResourceVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIResource * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIResource * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIResource * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIResource * This, - /* [in] */ REFGUID Name, - /* [in] */ SIZE_T DataSize, - /* [in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIResource * This, - /* [in] */ REFGUID Name, - /* [in] */ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIResource * This, - /* [in] */ REFGUID Name, - /* [out][in] */ SIZE_T *pDataSize, - /* [out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIResource * This, - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetDevice )( - IDXGIResource * This, - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetSharedHandle )( - IDXGIResource * This, - /* [out] */ HANDLE *pSharedHandle); - - HRESULT ( STDMETHODCALLTYPE *GetUsage )( - IDXGIResource * This, - /* [out] */ DXGI_USAGE *pUsage); - - HRESULT ( STDMETHODCALLTYPE *SetEvictionPriority )( - IDXGIResource * This, - /* [in] */ UINT EvictionPriority); - - HRESULT ( STDMETHODCALLTYPE *GetEvictionPriority )( - IDXGIResource * This, - /* [retval][out] */ UINT *pEvictionPriority); - - END_INTERFACE - } IDXGIResourceVtbl; - - interface IDXGIResource - { - CONST_VTBL struct IDXGIResourceVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIResource_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIResource_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIResource_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIResource_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIResource_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIResource_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIResource_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIResource_GetDevice(This,riid,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) - - -#define IDXGIResource_GetSharedHandle(This,pSharedHandle) \ - ( (This)->lpVtbl -> GetSharedHandle(This,pSharedHandle) ) - -#define IDXGIResource_GetUsage(This,pUsage) \ - ( (This)->lpVtbl -> GetUsage(This,pUsage) ) - -#define IDXGIResource_SetEvictionPriority(This,EvictionPriority) \ - ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) - -#define IDXGIResource_GetEvictionPriority(This,pEvictionPriority) \ - ( (This)->lpVtbl -> GetEvictionPriority(This,pEvictionPriority) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIResource_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0003 */ -/* [local] */ - -#define DXGI_MAP_READ ( 1UL ) - -#define DXGI_MAP_WRITE ( 2UL ) - -#define DXGI_MAP_DISCARD ( 4UL ) - - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0003_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0003_v0_0_s_ifspec; - -#ifndef __IDXGISurface_INTERFACE_DEFINED__ -#define __IDXGISurface_INTERFACE_DEFINED__ - -/* interface IDXGISurface */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGISurface; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("cafcb56c-6ac3-4889-bf47-9e23bbd260ec") - IDXGISurface : public IDXGIDeviceSubObject - { - public: - virtual HRESULT STDMETHODCALLTYPE GetDesc( - /* [out] */ DXGI_SURFACE_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE Map( - /* [out] */ DXGI_MAPPED_RECT *pLockedRect, - /* [in] */ UINT Flags) = 0; - - virtual HRESULT STDMETHODCALLTYPE Unmap( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXGISurfaceVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGISurface * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGISurface * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGISurface * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGISurface * This, - /* [in] */ REFGUID Name, - /* [in] */ SIZE_T DataSize, - /* [in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGISurface * This, - /* [in] */ REFGUID Name, - /* [in] */ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGISurface * This, - /* [in] */ REFGUID Name, - /* [out][in] */ SIZE_T *pDataSize, - /* [out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGISurface * This, - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetDevice )( - IDXGISurface * This, - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetDesc )( - IDXGISurface * This, - /* [out] */ DXGI_SURFACE_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *Map )( - IDXGISurface * This, - /* [out] */ DXGI_MAPPED_RECT *pLockedRect, - /* [in] */ UINT Flags); - - HRESULT ( STDMETHODCALLTYPE *Unmap )( - IDXGISurface * This); - - END_INTERFACE - } IDXGISurfaceVtbl; - - interface IDXGISurface - { - CONST_VTBL struct IDXGISurfaceVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGISurface_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGISurface_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGISurface_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGISurface_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGISurface_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGISurface_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGISurface_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGISurface_GetDevice(This,riid,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) - - -#define IDXGISurface_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define IDXGISurface_Map(This,pLockedRect,Flags) \ - ( (This)->lpVtbl -> Map(This,pLockedRect,Flags) ) - -#define IDXGISurface_Unmap(This) \ - ( (This)->lpVtbl -> Unmap(This) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGISurface_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0004 */ -/* [local] */ - - - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0004_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0004_v0_0_s_ifspec; - -#ifndef __IDXGIAdapter_INTERFACE_DEFINED__ -#define __IDXGIAdapter_INTERFACE_DEFINED__ - -/* interface IDXGIAdapter */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIAdapter; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("2411e7e1-12ac-4ccf-bd14-9798e8534dc0") - IDXGIAdapter : public IDXGIObject - { - public: - virtual HRESULT STDMETHODCALLTYPE EnumOutputs( - /* [in] */ UINT Output, - /* [out][in] */ IDXGIOutput **ppOutput) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetDesc( - /* [out] */ DXGI_ADAPTER_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE RegisterDriver( - /* [in] */ HMODULE Module) = 0; - - virtual HRESULT STDMETHODCALLTYPE CheckInterfaceSupport( - /* [in] */ REFGUID InterfaceName, - /* [out] */ LARGE_INTEGER *pUMDVersion) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXGIAdapterVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIAdapter * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIAdapter * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIAdapter * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIAdapter * This, - /* [in] */ REFGUID Name, - /* [in] */ SIZE_T DataSize, - /* [in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIAdapter * This, - /* [in] */ REFGUID Name, - /* [in] */ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIAdapter * This, - /* [in] */ REFGUID Name, - /* [out][in] */ SIZE_T *pDataSize, - /* [out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIAdapter * This, - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *EnumOutputs )( - IDXGIAdapter * This, - /* [in] */ UINT Output, - /* [out][in] */ IDXGIOutput **ppOutput); - - HRESULT ( STDMETHODCALLTYPE *GetDesc )( - IDXGIAdapter * This, - /* [out] */ DXGI_ADAPTER_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *RegisterDriver )( - IDXGIAdapter * This, - /* [in] */ HMODULE Module); - - HRESULT ( STDMETHODCALLTYPE *CheckInterfaceSupport )( - IDXGIAdapter * This, - /* [in] */ REFGUID InterfaceName, - /* [out] */ LARGE_INTEGER *pUMDVersion); - - END_INTERFACE - } IDXGIAdapterVtbl; - - interface IDXGIAdapter - { - CONST_VTBL struct IDXGIAdapterVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIAdapter_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIAdapter_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIAdapter_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIAdapter_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIAdapter_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIAdapter_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIAdapter_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIAdapter_EnumOutputs(This,Output,ppOutput) \ - ( (This)->lpVtbl -> EnumOutputs(This,Output,ppOutput) ) - -#define IDXGIAdapter_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define IDXGIAdapter_RegisterDriver(This,Module) \ - ( (This)->lpVtbl -> RegisterDriver(This,Module) ) - -#define IDXGIAdapter_CheckInterfaceSupport(This,InterfaceName,pUMDVersion) \ - ( (This)->lpVtbl -> CheckInterfaceSupport(This,InterfaceName,pUMDVersion) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIAdapter_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0005 */ -/* [local] */ - -#define DXGI_ENUM_MODES_INTERLACED ( 1UL ) - -#define DXGI_ENUM_MODES_NONPREROTATED ( 2UL ) - -#define DXGI_ENUM_MODES_SCALING ( 4UL ) - - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0005_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0005_v0_0_s_ifspec; - -#ifndef __IDXGIOutput_INTERFACE_DEFINED__ -#define __IDXGIOutput_INTERFACE_DEFINED__ - -/* interface IDXGIOutput */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIOutput; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("ae02eedb-c735-4690-8d52-5a8dc20213aa") - IDXGIOutput : public IDXGIObject - { - public: - virtual HRESULT STDMETHODCALLTYPE GetDesc( - /* [out] */ DXGI_OUTPUT_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetGammaControlCapabilities( - /* [out] */ DXGI_GAMMA_CONTROL_CAPABILIITES *pGammaCaps) = 0; - - virtual HRESULT STDMETHODCALLTYPE EnumDisplayModes( - /* [in] */ UINT Mode, - /* [in] */ DXGI_FORMAT EnumFormat, - /* [out] */ DXGI_MODE_DESC *pDesc, - /* [in] */ UINT Flags) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetDisplayMode( - /* [out] */ DXGI_MODE_DESC *pMode) = 0; - - virtual HRESULT STDMETHODCALLTYPE FindClosestMatchingMode( - /* [in] */ const DXGI_MODE_DESC *pModeToMatch, - /* [out] */ DXGI_MODE_DESC *pClosestMatch) = 0; - - virtual HRESULT STDMETHODCALLTYPE WaitForVBlank( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE TakeOwnership( - /* [in] */ IUnknown *pDevice, - BOOL Exclusive) = 0; - - virtual void STDMETHODCALLTYPE ReleaseOwnership( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetDisplaySurface( - /* [in] */ IDXGISurface *pScanoutSurface, - /* [in] */ DXGI_MODE_DESC *pMode) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetDisplaySurfaceData( - /* [in] */ IDXGISurface *pDestination) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetFrameStatistics( - /* [out] */ DXGI_FRAME_STATISTICS *pStats) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetGammaControl( - /* [in] */ const DXGI_GAMMA_CONTROL *pArray) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXGIOutputVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIOutput * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIOutput * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIOutput * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIOutput * This, - /* [in] */ REFGUID Name, - /* [in] */ SIZE_T DataSize, - /* [in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIOutput * This, - /* [in] */ REFGUID Name, - /* [in] */ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIOutput * This, - /* [in] */ REFGUID Name, - /* [out][in] */ SIZE_T *pDataSize, - /* [out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIOutput * This, - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetDesc )( - IDXGIOutput * This, - /* [out] */ DXGI_OUTPUT_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *GetGammaControlCapabilities )( - IDXGIOutput * This, - /* [out] */ DXGI_GAMMA_CONTROL_CAPABILIITES *pGammaCaps); - - HRESULT ( STDMETHODCALLTYPE *EnumDisplayModes )( - IDXGIOutput * This, - /* [in] */ UINT Mode, - /* [in] */ DXGI_FORMAT EnumFormat, - /* [out] */ DXGI_MODE_DESC *pDesc, - /* [in] */ UINT Flags); - - HRESULT ( STDMETHODCALLTYPE *GetDisplayMode )( - IDXGIOutput * This, - /* [out] */ DXGI_MODE_DESC *pMode); - - HRESULT ( STDMETHODCALLTYPE *FindClosestMatchingMode )( - IDXGIOutput * This, - /* [in] */ const DXGI_MODE_DESC *pModeToMatch, - /* [out] */ DXGI_MODE_DESC *pClosestMatch); - - HRESULT ( STDMETHODCALLTYPE *WaitForVBlank )( - IDXGIOutput * This); - - HRESULT ( STDMETHODCALLTYPE *TakeOwnership )( - IDXGIOutput * This, - /* [in] */ IUnknown *pDevice, - BOOL Exclusive); - - void ( STDMETHODCALLTYPE *ReleaseOwnership )( - IDXGIOutput * This); - - HRESULT ( STDMETHODCALLTYPE *SetDisplaySurface )( - IDXGIOutput * This, - /* [in] */ IDXGISurface *pScanoutSurface, - /* [in] */ DXGI_MODE_DESC *pMode); - - HRESULT ( STDMETHODCALLTYPE *GetDisplaySurfaceData )( - IDXGIOutput * This, - /* [in] */ IDXGISurface *pDestination); - - HRESULT ( STDMETHODCALLTYPE *GetFrameStatistics )( - IDXGIOutput * This, - /* [out] */ DXGI_FRAME_STATISTICS *pStats); - - HRESULT ( STDMETHODCALLTYPE *SetGammaControl )( - IDXGIOutput * This, - /* [in] */ const DXGI_GAMMA_CONTROL *pArray); - - END_INTERFACE - } IDXGIOutputVtbl; - - interface IDXGIOutput - { - CONST_VTBL struct IDXGIOutputVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIOutput_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIOutput_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIOutput_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIOutput_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIOutput_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIOutput_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIOutput_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIOutput_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define IDXGIOutput_GetGammaControlCapabilities(This,pGammaCaps) \ - ( (This)->lpVtbl -> GetGammaControlCapabilities(This,pGammaCaps) ) - -#define IDXGIOutput_EnumDisplayModes(This,Mode,EnumFormat,pDesc,Flags) \ - ( (This)->lpVtbl -> EnumDisplayModes(This,Mode,EnumFormat,pDesc,Flags) ) - -#define IDXGIOutput_GetDisplayMode(This,pMode) \ - ( (This)->lpVtbl -> GetDisplayMode(This,pMode) ) - -#define IDXGIOutput_FindClosestMatchingMode(This,pModeToMatch,pClosestMatch) \ - ( (This)->lpVtbl -> FindClosestMatchingMode(This,pModeToMatch,pClosestMatch) ) - -#define IDXGIOutput_WaitForVBlank(This) \ - ( (This)->lpVtbl -> WaitForVBlank(This) ) - -#define IDXGIOutput_TakeOwnership(This,pDevice,Exclusive) \ - ( (This)->lpVtbl -> TakeOwnership(This,pDevice,Exclusive) ) - -#define IDXGIOutput_ReleaseOwnership(This) \ - ( (This)->lpVtbl -> ReleaseOwnership(This) ) - -#define IDXGIOutput_SetDisplaySurface(This,pScanoutSurface,pMode) \ - ( (This)->lpVtbl -> SetDisplaySurface(This,pScanoutSurface,pMode) ) - -#define IDXGIOutput_GetDisplaySurfaceData(This,pDestination) \ - ( (This)->lpVtbl -> GetDisplaySurfaceData(This,pDestination) ) - -#define IDXGIOutput_GetFrameStatistics(This,pStats) \ - ( (This)->lpVtbl -> GetFrameStatistics(This,pStats) ) - -#define IDXGIOutput_SetGammaControl(This,pArray) \ - ( (This)->lpVtbl -> SetGammaControl(This,pArray) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIOutput_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0006 */ -/* [local] */ - -#define DXGI_MAX_BACKBUFFERS ( 16 ) -#define DXGI_PRESENT_TEST 0x00000001UL - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0006_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0006_v0_0_s_ifspec; - -#ifndef __IDXGISwapChain_INTERFACE_DEFINED__ -#define __IDXGISwapChain_INTERFACE_DEFINED__ - -/* interface IDXGISwapChain */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGISwapChain; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("310d36a0-d2e7-4c0a-aa04-6a9d23b8886a") - IDXGISwapChain : public IDXGIDeviceSubObject - { - public: - virtual HRESULT STDMETHODCALLTYPE Present( - /* [in] */ RECT *pSrc, - /* [in] */ RECT *pDest, - /* [in] */ RECT *pSourceDirtyRects, - /* [in] */ UINT NumSourceRects, - /* [in] */ UINT SyncInterval, - /* [in] */ UINT Flags) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetBackBuffer( - /* [in] */ UINT Buffer, - /* [in] */ REFIID riid, - /* [out][in] */ void **ppSurface) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetFullscreenState( - /* [in] */ BOOL Fullscreen, - /* [in] */ IDXGIOutput *pTarget) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetFullscreenState( - /* [out] */ BOOL *pFullscreen, - /* [out] */ IDXGIOutput **ppTarget) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetDesc( - /* [out] */ DXGI_SWAP_CHAIN_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE ResizeBackBuffers( - /* [in] */ UINT Width, - /* [in] */ UINT Height, - /* [in] */ DXGI_FORMAT NewFormat) = 0; - - virtual HRESULT STDMETHODCALLTYPE ResizeTarget( - /* [in] */ const DXGI_MODE_DESC *pNewTargetParameters) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetContainingOutput( - IDXGIOutput **ppOutput) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetFrameStatistics( - /* [out] */ DXGI_FRAME_STATISTICS *pStats) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetLastPresentCount( - /* [out] */ UINT *pLastPresentCount) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXGISwapChainVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGISwapChain * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGISwapChain * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGISwapChain * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGISwapChain * This, - /* [in] */ REFGUID Name, - /* [in] */ SIZE_T DataSize, - /* [in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGISwapChain * This, - /* [in] */ REFGUID Name, - /* [in] */ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGISwapChain * This, - /* [in] */ REFGUID Name, - /* [out][in] */ SIZE_T *pDataSize, - /* [out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGISwapChain * This, - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetDevice )( - IDXGISwapChain * This, - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *Present )( - IDXGISwapChain * This, - /* [in] */ RECT *pSrc, - /* [in] */ RECT *pDest, - /* [in] */ RECT *pSourceDirtyRects, - /* [in] */ UINT NumSourceRects, - /* [in] */ UINT SyncInterval, - /* [in] */ UINT Flags); - - HRESULT ( STDMETHODCALLTYPE *GetBackBuffer )( - IDXGISwapChain * This, - /* [in] */ UINT Buffer, - /* [in] */ REFIID riid, - /* [out][in] */ void **ppSurface); - - HRESULT ( STDMETHODCALLTYPE *SetFullscreenState )( - IDXGISwapChain * This, - /* [in] */ BOOL Fullscreen, - /* [in] */ IDXGIOutput *pTarget); - - HRESULT ( STDMETHODCALLTYPE *GetFullscreenState )( - IDXGISwapChain * This, - /* [out] */ BOOL *pFullscreen, - /* [out] */ IDXGIOutput **ppTarget); - - HRESULT ( STDMETHODCALLTYPE *GetDesc )( - IDXGISwapChain * This, - /* [out] */ DXGI_SWAP_CHAIN_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *ResizeBackBuffers )( - IDXGISwapChain * This, - /* [in] */ UINT Width, - /* [in] */ UINT Height, - /* [in] */ DXGI_FORMAT NewFormat); - - HRESULT ( STDMETHODCALLTYPE *ResizeTarget )( - IDXGISwapChain * This, - /* [in] */ const DXGI_MODE_DESC *pNewTargetParameters); - - HRESULT ( STDMETHODCALLTYPE *GetContainingOutput )( - IDXGISwapChain * This, - IDXGIOutput **ppOutput); - - HRESULT ( STDMETHODCALLTYPE *GetFrameStatistics )( - IDXGISwapChain * This, - /* [out] */ DXGI_FRAME_STATISTICS *pStats); - - HRESULT ( STDMETHODCALLTYPE *GetLastPresentCount )( - IDXGISwapChain * This, - /* [out] */ UINT *pLastPresentCount); - - END_INTERFACE - } IDXGISwapChainVtbl; - - interface IDXGISwapChain - { - CONST_VTBL struct IDXGISwapChainVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGISwapChain_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGISwapChain_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGISwapChain_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGISwapChain_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGISwapChain_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGISwapChain_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGISwapChain_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGISwapChain_GetDevice(This,riid,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) - - -#define IDXGISwapChain_Present(This,pSrc,pDest,pSourceDirtyRects,NumSourceRects,SyncInterval,Flags) \ - ( (This)->lpVtbl -> Present(This,pSrc,pDest,pSourceDirtyRects,NumSourceRects,SyncInterval,Flags) ) - -#define IDXGISwapChain_GetBackBuffer(This,Buffer,riid,ppSurface) \ - ( (This)->lpVtbl -> GetBackBuffer(This,Buffer,riid,ppSurface) ) - -#define IDXGISwapChain_SetFullscreenState(This,Fullscreen,pTarget) \ - ( (This)->lpVtbl -> SetFullscreenState(This,Fullscreen,pTarget) ) - -#define IDXGISwapChain_GetFullscreenState(This,pFullscreen,ppTarget) \ - ( (This)->lpVtbl -> GetFullscreenState(This,pFullscreen,ppTarget) ) - -#define IDXGISwapChain_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define IDXGISwapChain_ResizeBackBuffers(This,Width,Height,NewFormat) \ - ( (This)->lpVtbl -> ResizeBackBuffers(This,Width,Height,NewFormat) ) - -#define IDXGISwapChain_ResizeTarget(This,pNewTargetParameters) \ - ( (This)->lpVtbl -> ResizeTarget(This,pNewTargetParameters) ) - -#define IDXGISwapChain_GetContainingOutput(This,ppOutput) \ - ( (This)->lpVtbl -> GetContainingOutput(This,ppOutput) ) - -#define IDXGISwapChain_GetFrameStatistics(This,pStats) \ - ( (This)->lpVtbl -> GetFrameStatistics(This,pStats) ) - -#define IDXGISwapChain_GetLastPresentCount(This,pLastPresentCount) \ - ( (This)->lpVtbl -> GetLastPresentCount(This,pLastPresentCount) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGISwapChain_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0007 */ -/* [local] */ - -#define DXGI_MWA_NO_WINDOW_CHANGES ( 1 << 0 ) -#define DXGI_MWA_NO_ALT_ENTER ( 1 << 1 ) -#define DXGI_MWA_VALID ( 0x3 ) - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0007_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0007_v0_0_s_ifspec; - -#ifndef __IDXGIFactory_INTERFACE_DEFINED__ -#define __IDXGIFactory_INTERFACE_DEFINED__ - -/* interface IDXGIFactory */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIFactory; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("7b7166ec-21c7-44ae-b21a-c9ae321ae369") - IDXGIFactory : public IDXGIObject - { - public: - virtual HRESULT STDMETHODCALLTYPE EnumAdapters( - /* [in] */ UINT Adapter, - /* [out] */ IDXGIAdapter **ppAdapter) = 0; - - virtual HRESULT STDMETHODCALLTYPE MakeWindowAssociation( - HWND WindowHandle, - UINT Flags) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetWindowAssociation( - HWND *pWindowHandle) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateSwapChain( - IUnknown *pDevice, - DXGI_SWAP_CHAIN_DESC *pDesc, - IDXGISwapChain **ppSwapChain) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXGIFactoryVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIFactory * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIFactory * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIFactory * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIFactory * This, - /* [in] */ REFGUID Name, - /* [in] */ SIZE_T DataSize, - /* [in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIFactory * This, - /* [in] */ REFGUID Name, - /* [in] */ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIFactory * This, - /* [in] */ REFGUID Name, - /* [out][in] */ SIZE_T *pDataSize, - /* [out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIFactory * This, - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *EnumAdapters )( - IDXGIFactory * This, - /* [in] */ UINT Adapter, - /* [out] */ IDXGIAdapter **ppAdapter); - - HRESULT ( STDMETHODCALLTYPE *MakeWindowAssociation )( - IDXGIFactory * This, - HWND WindowHandle, - UINT Flags); - - HRESULT ( STDMETHODCALLTYPE *GetWindowAssociation )( - IDXGIFactory * This, - HWND *pWindowHandle); - - HRESULT ( STDMETHODCALLTYPE *CreateSwapChain )( - IDXGIFactory * This, - IUnknown *pDevice, - DXGI_SWAP_CHAIN_DESC *pDesc, - IDXGISwapChain **ppSwapChain); - - END_INTERFACE - } IDXGIFactoryVtbl; - - interface IDXGIFactory - { - CONST_VTBL struct IDXGIFactoryVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIFactory_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIFactory_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIFactory_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIFactory_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIFactory_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIFactory_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIFactory_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIFactory_EnumAdapters(This,Adapter,ppAdapter) \ - ( (This)->lpVtbl -> EnumAdapters(This,Adapter,ppAdapter) ) - -#define IDXGIFactory_MakeWindowAssociation(This,WindowHandle,Flags) \ - ( (This)->lpVtbl -> MakeWindowAssociation(This,WindowHandle,Flags) ) - -#define IDXGIFactory_GetWindowAssociation(This,pWindowHandle) \ - ( (This)->lpVtbl -> GetWindowAssociation(This,pWindowHandle) ) - -#define IDXGIFactory_CreateSwapChain(This,pDevice,pDesc,ppSwapChain) \ - ( (This)->lpVtbl -> CreateSwapChain(This,pDevice,pDesc,ppSwapChain) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIFactory_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0008 */ -/* [local] */ - -HRESULT WINAPI CreateDXGIFactory(REFIID riid, void **ppFactory); - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0008_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0008_v0_0_s_ifspec; - -#ifndef __IDXGIDevice_INTERFACE_DEFINED__ -#define __IDXGIDevice_INTERFACE_DEFINED__ - -/* interface IDXGIDevice */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIDevice; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("54ec77fa-1377-44e6-8c32-88fd5f44c84c") - IDXGIDevice : public IDXGIObject - { - public: - virtual HRESULT STDMETHODCALLTYPE GetAdapter( - /* [out] */ IDXGIAdapter **pAdapter) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateSurface( - /* [in] */ const DXGI_SURFACE_DESC *pDesc, - /* [in] */ UINT NumSurfaces, - /* [in] */ DXGI_USAGE Usage, - /* [in] */ const DXGI_SHARED_RESOURCE *pSharedResource, - /* [out] */ IDXGISurface **ppSurface) = 0; - - virtual HRESULT STDMETHODCALLTYPE QueryResourceResidency( - /* [size_is][in] */ IUnknown *const *ppResources, - /* [size_is][out] */ DXGI_RESIDENCY *pResidencyStatus, - /* [in] */ SIZE_T NumResources) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetGPUThreadPriority( - /* [in] */ INT Priority) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetGPUThreadPriority( - /* [retval][out] */ INT *pPriority) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXGIDeviceVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIDevice * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIDevice * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIDevice * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIDevice * This, - /* [in] */ REFGUID Name, - /* [in] */ SIZE_T DataSize, - /* [in] */ const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIDevice * This, - /* [in] */ REFGUID Name, - /* [in] */ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIDevice * This, - /* [in] */ REFGUID Name, - /* [out][in] */ SIZE_T *pDataSize, - /* [out] */ void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIDevice * This, - /* [in] */ REFIID riid, - /* [retval][out] */ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetAdapter )( - IDXGIDevice * This, - /* [out] */ IDXGIAdapter **pAdapter); - - HRESULT ( STDMETHODCALLTYPE *CreateSurface )( - IDXGIDevice * This, - /* [in] */ const DXGI_SURFACE_DESC *pDesc, - /* [in] */ UINT NumSurfaces, - /* [in] */ DXGI_USAGE Usage, - /* [in] */ const DXGI_SHARED_RESOURCE *pSharedResource, - /* [out] */ IDXGISurface **ppSurface); - - HRESULT ( STDMETHODCALLTYPE *QueryResourceResidency )( - IDXGIDevice * This, - /* [size_is][in] */ IUnknown *const *ppResources, - /* [size_is][out] */ DXGI_RESIDENCY *pResidencyStatus, - /* [in] */ SIZE_T NumResources); - - HRESULT ( STDMETHODCALLTYPE *SetGPUThreadPriority )( - IDXGIDevice * This, - /* [in] */ INT Priority); - - HRESULT ( STDMETHODCALLTYPE *GetGPUThreadPriority )( - IDXGIDevice * This, - /* [retval][out] */ INT *pPriority); - - END_INTERFACE - } IDXGIDeviceVtbl; - - interface IDXGIDevice - { - CONST_VTBL struct IDXGIDeviceVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIDevice_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIDevice_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIDevice_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIDevice_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIDevice_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIDevice_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIDevice_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIDevice_GetAdapter(This,pAdapter) \ - ( (This)->lpVtbl -> GetAdapter(This,pAdapter) ) - -#define IDXGIDevice_CreateSurface(This,pDesc,NumSurfaces,Usage,pSharedResource,ppSurface) \ - ( (This)->lpVtbl -> CreateSurface(This,pDesc,NumSurfaces,Usage,pSharedResource,ppSurface) ) - -#define IDXGIDevice_QueryResourceResidency(This,ppResources,pResidencyStatus,NumResources) \ - ( (This)->lpVtbl -> QueryResourceResidency(This,ppResources,pResidencyStatus,NumResources) ) - -#define IDXGIDevice_SetGPUThreadPriority(This,Priority) \ - ( (This)->lpVtbl -> SetGPUThreadPriority(This,Priority) ) - -#define IDXGIDevice_GetGPUThreadPriority(This,pPriority) \ - ( (This)->lpVtbl -> GetGPUThreadPriority(This,pPriority) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIDevice_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0009 */ -/* [local] */ - -HRESULT WINAPI CreateDataTransportDevice( IDXGIAdapter *pAdapter, IDXGIDevice **pOut); -#ifdef __cplusplus -#endif /*__cplusplus*/ - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0009_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0009_v0_0_s_ifspec; - -/* Additional Prototypes for ALL interfaces */ - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 7.00.0485 */ +/* Compiler settings for dxgi.idl: + Oicf, W1, Zp8, env=Win32 (32b run) + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +//@@MIDL_FILE_HEADING( ) + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCSAL_H_VERSION__ +#define __REQUIRED_RPCSAL_H_VERSION__ 100 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif // __RPCNDR_H_VERSION__ + +#ifndef COM_NO_WINDOWS_H +#include "windows.h" +#include "ole2.h" +#endif /*COM_NO_WINDOWS_H*/ + +#ifndef __dxgi_h__ +#define __dxgi_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +#ifndef __IDXGIObject_FWD_DEFINED__ +#define __IDXGIObject_FWD_DEFINED__ +typedef interface IDXGIObject IDXGIObject; +#endif /* __IDXGIObject_FWD_DEFINED__ */ + + +#ifndef __IDXGIDeviceSubObject_FWD_DEFINED__ +#define __IDXGIDeviceSubObject_FWD_DEFINED__ +typedef interface IDXGIDeviceSubObject IDXGIDeviceSubObject; +#endif /* __IDXGIDeviceSubObject_FWD_DEFINED__ */ + + +#ifndef __IDXGIResource_FWD_DEFINED__ +#define __IDXGIResource_FWD_DEFINED__ +typedef interface IDXGIResource IDXGIResource; +#endif /* __IDXGIResource_FWD_DEFINED__ */ + + +#ifndef __IDXGISurface_FWD_DEFINED__ +#define __IDXGISurface_FWD_DEFINED__ +typedef interface IDXGISurface IDXGISurface; +#endif /* __IDXGISurface_FWD_DEFINED__ */ + + +#ifndef __IDXGIAdapter_FWD_DEFINED__ +#define __IDXGIAdapter_FWD_DEFINED__ +typedef interface IDXGIAdapter IDXGIAdapter; +#endif /* __IDXGIAdapter_FWD_DEFINED__ */ + + +#ifndef __IDXGIOutput_FWD_DEFINED__ +#define __IDXGIOutput_FWD_DEFINED__ +typedef interface IDXGIOutput IDXGIOutput; +#endif /* __IDXGIOutput_FWD_DEFINED__ */ + + +#ifndef __IDXGISwapChain_FWD_DEFINED__ +#define __IDXGISwapChain_FWD_DEFINED__ +typedef interface IDXGISwapChain IDXGISwapChain; +#endif /* __IDXGISwapChain_FWD_DEFINED__ */ + + +#ifndef __IDXGIFactory_FWD_DEFINED__ +#define __IDXGIFactory_FWD_DEFINED__ +typedef interface IDXGIFactory IDXGIFactory; +#endif /* __IDXGIFactory_FWD_DEFINED__ */ + + +#ifndef __IDXGIDevice_FWD_DEFINED__ +#define __IDXGIDevice_FWD_DEFINED__ +typedef interface IDXGIDevice IDXGIDevice; +#endif /* __IDXGIDevice_FWD_DEFINED__ */ + + +/* header files for imported files */ +#include "dxgitype.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __IDXGIObject_INTERFACE_DEFINED__ +#define __IDXGIObject_INTERFACE_DEFINED__ + +/* interface IDXGIObject */ +/* [unique][local][uuid][object] */ + + +EXTERN_C const IID IID_IDXGIObject; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("aec22fb8-76f3-4639-9be0-28eb43a67a2e") + IDXGIObject : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE SetPrivateData( + /* [in] */ REFGUID Name, + /* [in] */ SIZE_T DataSize, + /* [in] */ const void *pData) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( + /* [in] */ REFGUID Name, + /* [in] */ const IUnknown *pUnknown) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetPrivateData( + /* [in] */ REFGUID Name, + /* [out][in] */ SIZE_T *pDataSize, + /* [out] */ void *pData) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetParent( + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppParent) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXGIObjectVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXGIObject * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXGIObject * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXGIObject * This); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + IDXGIObject * This, + /* [in] */ REFGUID Name, + /* [in] */ SIZE_T DataSize, + /* [in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + IDXGIObject * This, + /* [in] */ REFGUID Name, + /* [in] */ const IUnknown *pUnknown); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + IDXGIObject * This, + /* [in] */ REFGUID Name, + /* [out][in] */ SIZE_T *pDataSize, + /* [out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *GetParent )( + IDXGIObject * This, + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppParent); + + END_INTERFACE + } IDXGIObjectVtbl; + + interface IDXGIObject + { + CONST_VTBL struct IDXGIObjectVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXGIObject_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IDXGIObject_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IDXGIObject_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IDXGIObject_SetPrivateData(This,Name,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) + +#define IDXGIObject_SetPrivateDataInterface(This,Name,pUnknown) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) + +#define IDXGIObject_GetPrivateData(This,Name,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) + +#define IDXGIObject_GetParent(This,riid,ppParent) \ + ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IDXGIObject_INTERFACE_DEFINED__ */ + + +#ifndef __IDXGIDeviceSubObject_INTERFACE_DEFINED__ +#define __IDXGIDeviceSubObject_INTERFACE_DEFINED__ + +/* interface IDXGIDeviceSubObject */ +/* [unique][local][uuid][object] */ + + +EXTERN_C const IID IID_IDXGIDeviceSubObject; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("3d3e0379-f9de-4d58-bb6c-18d62992f1a6") + IDXGIDeviceSubObject : public IDXGIObject + { + public: + virtual HRESULT STDMETHODCALLTYPE GetDevice( + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppDevice) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXGIDeviceSubObjectVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXGIDeviceSubObject * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXGIDeviceSubObject * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXGIDeviceSubObject * This); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + IDXGIDeviceSubObject * This, + /* [in] */ REFGUID Name, + /* [in] */ SIZE_T DataSize, + /* [in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + IDXGIDeviceSubObject * This, + /* [in] */ REFGUID Name, + /* [in] */ const IUnknown *pUnknown); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + IDXGIDeviceSubObject * This, + /* [in] */ REFGUID Name, + /* [out][in] */ SIZE_T *pDataSize, + /* [out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *GetParent )( + IDXGIDeviceSubObject * This, + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppParent); + + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + IDXGIDeviceSubObject * This, + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppDevice); + + END_INTERFACE + } IDXGIDeviceSubObjectVtbl; + + interface IDXGIDeviceSubObject + { + CONST_VTBL struct IDXGIDeviceSubObjectVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXGIDeviceSubObject_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IDXGIDeviceSubObject_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IDXGIDeviceSubObject_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IDXGIDeviceSubObject_SetPrivateData(This,Name,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) + +#define IDXGIDeviceSubObject_SetPrivateDataInterface(This,Name,pUnknown) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) + +#define IDXGIDeviceSubObject_GetPrivateData(This,Name,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) + +#define IDXGIDeviceSubObject_GetParent(This,riid,ppParent) \ + ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) + + +#define IDXGIDeviceSubObject_GetDevice(This,riid,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IDXGIDeviceSubObject_INTERFACE_DEFINED__ */ + + +#ifndef __IDXGIResource_INTERFACE_DEFINED__ +#define __IDXGIResource_INTERFACE_DEFINED__ + +/* interface IDXGIResource */ +/* [unique][local][uuid][object] */ + + +EXTERN_C const IID IID_IDXGIResource; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("035f3ab4-482e-4e50-b41f-8a7f8bd8960b") + IDXGIResource : public IDXGIDeviceSubObject + { + public: + virtual HRESULT STDMETHODCALLTYPE GetSharedHandle( + /* [out] */ HANDLE *pSharedHandle) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetUsage( + /* [out] */ DXGI_USAGE *pUsage) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetEvictionPriority( + /* [in] */ UINT EvictionPriority) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetEvictionPriority( + /* [retval][out] */ UINT *pEvictionPriority) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXGIResourceVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXGIResource * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXGIResource * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXGIResource * This); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + IDXGIResource * This, + /* [in] */ REFGUID Name, + /* [in] */ SIZE_T DataSize, + /* [in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + IDXGIResource * This, + /* [in] */ REFGUID Name, + /* [in] */ const IUnknown *pUnknown); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + IDXGIResource * This, + /* [in] */ REFGUID Name, + /* [out][in] */ SIZE_T *pDataSize, + /* [out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *GetParent )( + IDXGIResource * This, + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppParent); + + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + IDXGIResource * This, + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetSharedHandle )( + IDXGIResource * This, + /* [out] */ HANDLE *pSharedHandle); + + HRESULT ( STDMETHODCALLTYPE *GetUsage )( + IDXGIResource * This, + /* [out] */ DXGI_USAGE *pUsage); + + HRESULT ( STDMETHODCALLTYPE *SetEvictionPriority )( + IDXGIResource * This, + /* [in] */ UINT EvictionPriority); + + HRESULT ( STDMETHODCALLTYPE *GetEvictionPriority )( + IDXGIResource * This, + /* [retval][out] */ UINT *pEvictionPriority); + + END_INTERFACE + } IDXGIResourceVtbl; + + interface IDXGIResource + { + CONST_VTBL struct IDXGIResourceVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXGIResource_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IDXGIResource_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IDXGIResource_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IDXGIResource_SetPrivateData(This,Name,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) + +#define IDXGIResource_SetPrivateDataInterface(This,Name,pUnknown) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) + +#define IDXGIResource_GetPrivateData(This,Name,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) + +#define IDXGIResource_GetParent(This,riid,ppParent) \ + ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) + + +#define IDXGIResource_GetDevice(This,riid,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) + + +#define IDXGIResource_GetSharedHandle(This,pSharedHandle) \ + ( (This)->lpVtbl -> GetSharedHandle(This,pSharedHandle) ) + +#define IDXGIResource_GetUsage(This,pUsage) \ + ( (This)->lpVtbl -> GetUsage(This,pUsage) ) + +#define IDXGIResource_SetEvictionPriority(This,EvictionPriority) \ + ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) + +#define IDXGIResource_GetEvictionPriority(This,pEvictionPriority) \ + ( (This)->lpVtbl -> GetEvictionPriority(This,pEvictionPriority) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IDXGIResource_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxgi_0000_0003 */ +/* [local] */ + +#define DXGI_MAP_READ ( 1UL ) + +#define DXGI_MAP_WRITE ( 2UL ) + +#define DXGI_MAP_DISCARD ( 4UL ) + + + +extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0003_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0003_v0_0_s_ifspec; + +#ifndef __IDXGISurface_INTERFACE_DEFINED__ +#define __IDXGISurface_INTERFACE_DEFINED__ + +/* interface IDXGISurface */ +/* [unique][local][uuid][object] */ + + +EXTERN_C const IID IID_IDXGISurface; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("cafcb56c-6ac3-4889-bf47-9e23bbd260ec") + IDXGISurface : public IDXGIDeviceSubObject + { + public: + virtual HRESULT STDMETHODCALLTYPE GetDesc( + /* [out] */ DXGI_SURFACE_DESC *pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE Map( + /* [out] */ DXGI_MAPPED_RECT *pLockedRect, + /* [in] */ UINT Flags) = 0; + + virtual HRESULT STDMETHODCALLTYPE Unmap( void) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXGISurfaceVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXGISurface * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXGISurface * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXGISurface * This); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + IDXGISurface * This, + /* [in] */ REFGUID Name, + /* [in] */ SIZE_T DataSize, + /* [in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + IDXGISurface * This, + /* [in] */ REFGUID Name, + /* [in] */ const IUnknown *pUnknown); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + IDXGISurface * This, + /* [in] */ REFGUID Name, + /* [out][in] */ SIZE_T *pDataSize, + /* [out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *GetParent )( + IDXGISurface * This, + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppParent); + + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + IDXGISurface * This, + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *GetDesc )( + IDXGISurface * This, + /* [out] */ DXGI_SURFACE_DESC *pDesc); + + HRESULT ( STDMETHODCALLTYPE *Map )( + IDXGISurface * This, + /* [out] */ DXGI_MAPPED_RECT *pLockedRect, + /* [in] */ UINT Flags); + + HRESULT ( STDMETHODCALLTYPE *Unmap )( + IDXGISurface * This); + + END_INTERFACE + } IDXGISurfaceVtbl; + + interface IDXGISurface + { + CONST_VTBL struct IDXGISurfaceVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXGISurface_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IDXGISurface_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IDXGISurface_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IDXGISurface_SetPrivateData(This,Name,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) + +#define IDXGISurface_SetPrivateDataInterface(This,Name,pUnknown) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) + +#define IDXGISurface_GetPrivateData(This,Name,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) + +#define IDXGISurface_GetParent(This,riid,ppParent) \ + ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) + + +#define IDXGISurface_GetDevice(This,riid,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) + + +#define IDXGISurface_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#define IDXGISurface_Map(This,pLockedRect,Flags) \ + ( (This)->lpVtbl -> Map(This,pLockedRect,Flags) ) + +#define IDXGISurface_Unmap(This) \ + ( (This)->lpVtbl -> Unmap(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IDXGISurface_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxgi_0000_0004 */ +/* [local] */ + + + + +extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0004_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0004_v0_0_s_ifspec; + +#ifndef __IDXGIAdapter_INTERFACE_DEFINED__ +#define __IDXGIAdapter_INTERFACE_DEFINED__ + +/* interface IDXGIAdapter */ +/* [unique][local][uuid][object] */ + + +EXTERN_C const IID IID_IDXGIAdapter; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("2411e7e1-12ac-4ccf-bd14-9798e8534dc0") + IDXGIAdapter : public IDXGIObject + { + public: + virtual HRESULT STDMETHODCALLTYPE EnumOutputs( + /* [in] */ UINT Output, + /* [out][in] */ IDXGIOutput **ppOutput) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetDesc( + /* [out] */ DXGI_ADAPTER_DESC *pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE RegisterDriver( + /* [in] */ HMODULE Module) = 0; + + virtual HRESULT STDMETHODCALLTYPE CheckInterfaceSupport( + /* [in] */ REFGUID InterfaceName, + /* [out] */ LARGE_INTEGER *pUMDVersion) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXGIAdapterVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXGIAdapter * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXGIAdapter * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXGIAdapter * This); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + IDXGIAdapter * This, + /* [in] */ REFGUID Name, + /* [in] */ SIZE_T DataSize, + /* [in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + IDXGIAdapter * This, + /* [in] */ REFGUID Name, + /* [in] */ const IUnknown *pUnknown); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + IDXGIAdapter * This, + /* [in] */ REFGUID Name, + /* [out][in] */ SIZE_T *pDataSize, + /* [out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *GetParent )( + IDXGIAdapter * This, + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppParent); + + HRESULT ( STDMETHODCALLTYPE *EnumOutputs )( + IDXGIAdapter * This, + /* [in] */ UINT Output, + /* [out][in] */ IDXGIOutput **ppOutput); + + HRESULT ( STDMETHODCALLTYPE *GetDesc )( + IDXGIAdapter * This, + /* [out] */ DXGI_ADAPTER_DESC *pDesc); + + HRESULT ( STDMETHODCALLTYPE *RegisterDriver )( + IDXGIAdapter * This, + /* [in] */ HMODULE Module); + + HRESULT ( STDMETHODCALLTYPE *CheckInterfaceSupport )( + IDXGIAdapter * This, + /* [in] */ REFGUID InterfaceName, + /* [out] */ LARGE_INTEGER *pUMDVersion); + + END_INTERFACE + } IDXGIAdapterVtbl; + + interface IDXGIAdapter + { + CONST_VTBL struct IDXGIAdapterVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXGIAdapter_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IDXGIAdapter_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IDXGIAdapter_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IDXGIAdapter_SetPrivateData(This,Name,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) + +#define IDXGIAdapter_SetPrivateDataInterface(This,Name,pUnknown) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) + +#define IDXGIAdapter_GetPrivateData(This,Name,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) + +#define IDXGIAdapter_GetParent(This,riid,ppParent) \ + ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) + + +#define IDXGIAdapter_EnumOutputs(This,Output,ppOutput) \ + ( (This)->lpVtbl -> EnumOutputs(This,Output,ppOutput) ) + +#define IDXGIAdapter_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#define IDXGIAdapter_RegisterDriver(This,Module) \ + ( (This)->lpVtbl -> RegisterDriver(This,Module) ) + +#define IDXGIAdapter_CheckInterfaceSupport(This,InterfaceName,pUMDVersion) \ + ( (This)->lpVtbl -> CheckInterfaceSupport(This,InterfaceName,pUMDVersion) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IDXGIAdapter_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxgi_0000_0005 */ +/* [local] */ + +#define DXGI_ENUM_MODES_INTERLACED ( 1UL ) + +#define DXGI_ENUM_MODES_NONPREROTATED ( 2UL ) + +#define DXGI_ENUM_MODES_SCALING ( 4UL ) + + + +extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0005_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0005_v0_0_s_ifspec; + +#ifndef __IDXGIOutput_INTERFACE_DEFINED__ +#define __IDXGIOutput_INTERFACE_DEFINED__ + +/* interface IDXGIOutput */ +/* [unique][local][uuid][object] */ + + +EXTERN_C const IID IID_IDXGIOutput; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("ae02eedb-c735-4690-8d52-5a8dc20213aa") + IDXGIOutput : public IDXGIObject + { + public: + virtual HRESULT STDMETHODCALLTYPE GetDesc( + /* [out] */ DXGI_OUTPUT_DESC *pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetGammaControlCapabilities( + /* [out] */ DXGI_GAMMA_CONTROL_CAPABILIITES *pGammaCaps) = 0; + + virtual HRESULT STDMETHODCALLTYPE EnumDisplayModes( + /* [in] */ UINT Mode, + /* [in] */ DXGI_FORMAT EnumFormat, + /* [out] */ DXGI_MODE_DESC *pDesc, + /* [in] */ UINT Flags) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetDisplayMode( + /* [out] */ DXGI_MODE_DESC *pMode) = 0; + + virtual HRESULT STDMETHODCALLTYPE FindClosestMatchingMode( + /* [in] */ const DXGI_MODE_DESC *pModeToMatch, + /* [out] */ DXGI_MODE_DESC *pClosestMatch) = 0; + + virtual HRESULT STDMETHODCALLTYPE WaitForVBlank( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE TakeOwnership( + /* [in] */ IUnknown *pDevice, + BOOL Exclusive) = 0; + + virtual void STDMETHODCALLTYPE ReleaseOwnership( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetDisplaySurface( + /* [in] */ IDXGISurface *pScanoutSurface, + /* [in] */ DXGI_MODE_DESC *pMode) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetDisplaySurfaceData( + /* [in] */ IDXGISurface *pDestination) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetFrameStatistics( + /* [out] */ DXGI_FRAME_STATISTICS *pStats) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetGammaControl( + /* [in] */ const DXGI_GAMMA_CONTROL *pArray) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXGIOutputVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXGIOutput * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXGIOutput * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXGIOutput * This); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + IDXGIOutput * This, + /* [in] */ REFGUID Name, + /* [in] */ SIZE_T DataSize, + /* [in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + IDXGIOutput * This, + /* [in] */ REFGUID Name, + /* [in] */ const IUnknown *pUnknown); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + IDXGIOutput * This, + /* [in] */ REFGUID Name, + /* [out][in] */ SIZE_T *pDataSize, + /* [out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *GetParent )( + IDXGIOutput * This, + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppParent); + + HRESULT ( STDMETHODCALLTYPE *GetDesc )( + IDXGIOutput * This, + /* [out] */ DXGI_OUTPUT_DESC *pDesc); + + HRESULT ( STDMETHODCALLTYPE *GetGammaControlCapabilities )( + IDXGIOutput * This, + /* [out] */ DXGI_GAMMA_CONTROL_CAPABILIITES *pGammaCaps); + + HRESULT ( STDMETHODCALLTYPE *EnumDisplayModes )( + IDXGIOutput * This, + /* [in] */ UINT Mode, + /* [in] */ DXGI_FORMAT EnumFormat, + /* [out] */ DXGI_MODE_DESC *pDesc, + /* [in] */ UINT Flags); + + HRESULT ( STDMETHODCALLTYPE *GetDisplayMode )( + IDXGIOutput * This, + /* [out] */ DXGI_MODE_DESC *pMode); + + HRESULT ( STDMETHODCALLTYPE *FindClosestMatchingMode )( + IDXGIOutput * This, + /* [in] */ const DXGI_MODE_DESC *pModeToMatch, + /* [out] */ DXGI_MODE_DESC *pClosestMatch); + + HRESULT ( STDMETHODCALLTYPE *WaitForVBlank )( + IDXGIOutput * This); + + HRESULT ( STDMETHODCALLTYPE *TakeOwnership )( + IDXGIOutput * This, + /* [in] */ IUnknown *pDevice, + BOOL Exclusive); + + void ( STDMETHODCALLTYPE *ReleaseOwnership )( + IDXGIOutput * This); + + HRESULT ( STDMETHODCALLTYPE *SetDisplaySurface )( + IDXGIOutput * This, + /* [in] */ IDXGISurface *pScanoutSurface, + /* [in] */ DXGI_MODE_DESC *pMode); + + HRESULT ( STDMETHODCALLTYPE *GetDisplaySurfaceData )( + IDXGIOutput * This, + /* [in] */ IDXGISurface *pDestination); + + HRESULT ( STDMETHODCALLTYPE *GetFrameStatistics )( + IDXGIOutput * This, + /* [out] */ DXGI_FRAME_STATISTICS *pStats); + + HRESULT ( STDMETHODCALLTYPE *SetGammaControl )( + IDXGIOutput * This, + /* [in] */ const DXGI_GAMMA_CONTROL *pArray); + + END_INTERFACE + } IDXGIOutputVtbl; + + interface IDXGIOutput + { + CONST_VTBL struct IDXGIOutputVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXGIOutput_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IDXGIOutput_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IDXGIOutput_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IDXGIOutput_SetPrivateData(This,Name,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) + +#define IDXGIOutput_SetPrivateDataInterface(This,Name,pUnknown) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) + +#define IDXGIOutput_GetPrivateData(This,Name,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) + +#define IDXGIOutput_GetParent(This,riid,ppParent) \ + ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) + + +#define IDXGIOutput_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#define IDXGIOutput_GetGammaControlCapabilities(This,pGammaCaps) \ + ( (This)->lpVtbl -> GetGammaControlCapabilities(This,pGammaCaps) ) + +#define IDXGIOutput_EnumDisplayModes(This,Mode,EnumFormat,pDesc,Flags) \ + ( (This)->lpVtbl -> EnumDisplayModes(This,Mode,EnumFormat,pDesc,Flags) ) + +#define IDXGIOutput_GetDisplayMode(This,pMode) \ + ( (This)->lpVtbl -> GetDisplayMode(This,pMode) ) + +#define IDXGIOutput_FindClosestMatchingMode(This,pModeToMatch,pClosestMatch) \ + ( (This)->lpVtbl -> FindClosestMatchingMode(This,pModeToMatch,pClosestMatch) ) + +#define IDXGIOutput_WaitForVBlank(This) \ + ( (This)->lpVtbl -> WaitForVBlank(This) ) + +#define IDXGIOutput_TakeOwnership(This,pDevice,Exclusive) \ + ( (This)->lpVtbl -> TakeOwnership(This,pDevice,Exclusive) ) + +#define IDXGIOutput_ReleaseOwnership(This) \ + ( (This)->lpVtbl -> ReleaseOwnership(This) ) + +#define IDXGIOutput_SetDisplaySurface(This,pScanoutSurface,pMode) \ + ( (This)->lpVtbl -> SetDisplaySurface(This,pScanoutSurface,pMode) ) + +#define IDXGIOutput_GetDisplaySurfaceData(This,pDestination) \ + ( (This)->lpVtbl -> GetDisplaySurfaceData(This,pDestination) ) + +#define IDXGIOutput_GetFrameStatistics(This,pStats) \ + ( (This)->lpVtbl -> GetFrameStatistics(This,pStats) ) + +#define IDXGIOutput_SetGammaControl(This,pArray) \ + ( (This)->lpVtbl -> SetGammaControl(This,pArray) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IDXGIOutput_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxgi_0000_0006 */ +/* [local] */ + +#define DXGI_MAX_BACKBUFFERS ( 16 ) +#define DXGI_PRESENT_TEST 0x00000001UL + + +extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0006_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0006_v0_0_s_ifspec; + +#ifndef __IDXGISwapChain_INTERFACE_DEFINED__ +#define __IDXGISwapChain_INTERFACE_DEFINED__ + +/* interface IDXGISwapChain */ +/* [unique][local][uuid][object] */ + + +EXTERN_C const IID IID_IDXGISwapChain; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("310d36a0-d2e7-4c0a-aa04-6a9d23b8886a") + IDXGISwapChain : public IDXGIDeviceSubObject + { + public: + virtual HRESULT STDMETHODCALLTYPE Present( + /* [in] */ RECT *pSrc, + /* [in] */ RECT *pDest, + /* [in] */ RECT *pSourceDirtyRects, + /* [in] */ UINT NumSourceRects, + /* [in] */ UINT SyncInterval, + /* [in] */ UINT Flags) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetBackBuffer( + /* [in] */ UINT Buffer, + /* [in] */ REFIID riid, + /* [out][in] */ void **ppSurface) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetFullscreenState( + /* [in] */ BOOL Fullscreen, + /* [in] */ IDXGIOutput *pTarget) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetFullscreenState( + /* [out] */ BOOL *pFullscreen, + /* [out] */ IDXGIOutput **ppTarget) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetDesc( + /* [out] */ DXGI_SWAP_CHAIN_DESC *pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE ResizeBackBuffers( + /* [in] */ UINT Width, + /* [in] */ UINT Height, + /* [in] */ DXGI_FORMAT NewFormat) = 0; + + virtual HRESULT STDMETHODCALLTYPE ResizeTarget( + /* [in] */ const DXGI_MODE_DESC *pNewTargetParameters) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetContainingOutput( + IDXGIOutput **ppOutput) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetFrameStatistics( + /* [out] */ DXGI_FRAME_STATISTICS *pStats) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetLastPresentCount( + /* [out] */ UINT *pLastPresentCount) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXGISwapChainVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXGISwapChain * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXGISwapChain * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXGISwapChain * This); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + IDXGISwapChain * This, + /* [in] */ REFGUID Name, + /* [in] */ SIZE_T DataSize, + /* [in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + IDXGISwapChain * This, + /* [in] */ REFGUID Name, + /* [in] */ const IUnknown *pUnknown); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + IDXGISwapChain * This, + /* [in] */ REFGUID Name, + /* [out][in] */ SIZE_T *pDataSize, + /* [out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *GetParent )( + IDXGISwapChain * This, + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppParent); + + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + IDXGISwapChain * This, + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppDevice); + + HRESULT ( STDMETHODCALLTYPE *Present )( + IDXGISwapChain * This, + /* [in] */ RECT *pSrc, + /* [in] */ RECT *pDest, + /* [in] */ RECT *pSourceDirtyRects, + /* [in] */ UINT NumSourceRects, + /* [in] */ UINT SyncInterval, + /* [in] */ UINT Flags); + + HRESULT ( STDMETHODCALLTYPE *GetBackBuffer )( + IDXGISwapChain * This, + /* [in] */ UINT Buffer, + /* [in] */ REFIID riid, + /* [out][in] */ void **ppSurface); + + HRESULT ( STDMETHODCALLTYPE *SetFullscreenState )( + IDXGISwapChain * This, + /* [in] */ BOOL Fullscreen, + /* [in] */ IDXGIOutput *pTarget); + + HRESULT ( STDMETHODCALLTYPE *GetFullscreenState )( + IDXGISwapChain * This, + /* [out] */ BOOL *pFullscreen, + /* [out] */ IDXGIOutput **ppTarget); + + HRESULT ( STDMETHODCALLTYPE *GetDesc )( + IDXGISwapChain * This, + /* [out] */ DXGI_SWAP_CHAIN_DESC *pDesc); + + HRESULT ( STDMETHODCALLTYPE *ResizeBackBuffers )( + IDXGISwapChain * This, + /* [in] */ UINT Width, + /* [in] */ UINT Height, + /* [in] */ DXGI_FORMAT NewFormat); + + HRESULT ( STDMETHODCALLTYPE *ResizeTarget )( + IDXGISwapChain * This, + /* [in] */ const DXGI_MODE_DESC *pNewTargetParameters); + + HRESULT ( STDMETHODCALLTYPE *GetContainingOutput )( + IDXGISwapChain * This, + IDXGIOutput **ppOutput); + + HRESULT ( STDMETHODCALLTYPE *GetFrameStatistics )( + IDXGISwapChain * This, + /* [out] */ DXGI_FRAME_STATISTICS *pStats); + + HRESULT ( STDMETHODCALLTYPE *GetLastPresentCount )( + IDXGISwapChain * This, + /* [out] */ UINT *pLastPresentCount); + + END_INTERFACE + } IDXGISwapChainVtbl; + + interface IDXGISwapChain + { + CONST_VTBL struct IDXGISwapChainVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXGISwapChain_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IDXGISwapChain_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IDXGISwapChain_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IDXGISwapChain_SetPrivateData(This,Name,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) + +#define IDXGISwapChain_SetPrivateDataInterface(This,Name,pUnknown) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) + +#define IDXGISwapChain_GetPrivateData(This,Name,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) + +#define IDXGISwapChain_GetParent(This,riid,ppParent) \ + ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) + + +#define IDXGISwapChain_GetDevice(This,riid,ppDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) + + +#define IDXGISwapChain_Present(This,pSrc,pDest,pSourceDirtyRects,NumSourceRects,SyncInterval,Flags) \ + ( (This)->lpVtbl -> Present(This,pSrc,pDest,pSourceDirtyRects,NumSourceRects,SyncInterval,Flags) ) + +#define IDXGISwapChain_GetBackBuffer(This,Buffer,riid,ppSurface) \ + ( (This)->lpVtbl -> GetBackBuffer(This,Buffer,riid,ppSurface) ) + +#define IDXGISwapChain_SetFullscreenState(This,Fullscreen,pTarget) \ + ( (This)->lpVtbl -> SetFullscreenState(This,Fullscreen,pTarget) ) + +#define IDXGISwapChain_GetFullscreenState(This,pFullscreen,ppTarget) \ + ( (This)->lpVtbl -> GetFullscreenState(This,pFullscreen,ppTarget) ) + +#define IDXGISwapChain_GetDesc(This,pDesc) \ + ( (This)->lpVtbl -> GetDesc(This,pDesc) ) + +#define IDXGISwapChain_ResizeBackBuffers(This,Width,Height,NewFormat) \ + ( (This)->lpVtbl -> ResizeBackBuffers(This,Width,Height,NewFormat) ) + +#define IDXGISwapChain_ResizeTarget(This,pNewTargetParameters) \ + ( (This)->lpVtbl -> ResizeTarget(This,pNewTargetParameters) ) + +#define IDXGISwapChain_GetContainingOutput(This,ppOutput) \ + ( (This)->lpVtbl -> GetContainingOutput(This,ppOutput) ) + +#define IDXGISwapChain_GetFrameStatistics(This,pStats) \ + ( (This)->lpVtbl -> GetFrameStatistics(This,pStats) ) + +#define IDXGISwapChain_GetLastPresentCount(This,pLastPresentCount) \ + ( (This)->lpVtbl -> GetLastPresentCount(This,pLastPresentCount) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IDXGISwapChain_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxgi_0000_0007 */ +/* [local] */ + +#define DXGI_MWA_NO_WINDOW_CHANGES ( 1 << 0 ) +#define DXGI_MWA_NO_ALT_ENTER ( 1 << 1 ) +#define DXGI_MWA_VALID ( 0x3 ) + + +extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0007_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0007_v0_0_s_ifspec; + +#ifndef __IDXGIFactory_INTERFACE_DEFINED__ +#define __IDXGIFactory_INTERFACE_DEFINED__ + +/* interface IDXGIFactory */ +/* [unique][local][uuid][object] */ + + +EXTERN_C const IID IID_IDXGIFactory; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("7b7166ec-21c7-44ae-b21a-c9ae321ae369") + IDXGIFactory : public IDXGIObject + { + public: + virtual HRESULT STDMETHODCALLTYPE EnumAdapters( + /* [in] */ UINT Adapter, + /* [out] */ IDXGIAdapter **ppAdapter) = 0; + + virtual HRESULT STDMETHODCALLTYPE MakeWindowAssociation( + HWND WindowHandle, + UINT Flags) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetWindowAssociation( + HWND *pWindowHandle) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateSwapChain( + IUnknown *pDevice, + DXGI_SWAP_CHAIN_DESC *pDesc, + IDXGISwapChain **ppSwapChain) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXGIFactoryVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXGIFactory * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXGIFactory * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXGIFactory * This); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + IDXGIFactory * This, + /* [in] */ REFGUID Name, + /* [in] */ SIZE_T DataSize, + /* [in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + IDXGIFactory * This, + /* [in] */ REFGUID Name, + /* [in] */ const IUnknown *pUnknown); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + IDXGIFactory * This, + /* [in] */ REFGUID Name, + /* [out][in] */ SIZE_T *pDataSize, + /* [out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *GetParent )( + IDXGIFactory * This, + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppParent); + + HRESULT ( STDMETHODCALLTYPE *EnumAdapters )( + IDXGIFactory * This, + /* [in] */ UINT Adapter, + /* [out] */ IDXGIAdapter **ppAdapter); + + HRESULT ( STDMETHODCALLTYPE *MakeWindowAssociation )( + IDXGIFactory * This, + HWND WindowHandle, + UINT Flags); + + HRESULT ( STDMETHODCALLTYPE *GetWindowAssociation )( + IDXGIFactory * This, + HWND *pWindowHandle); + + HRESULT ( STDMETHODCALLTYPE *CreateSwapChain )( + IDXGIFactory * This, + IUnknown *pDevice, + DXGI_SWAP_CHAIN_DESC *pDesc, + IDXGISwapChain **ppSwapChain); + + END_INTERFACE + } IDXGIFactoryVtbl; + + interface IDXGIFactory + { + CONST_VTBL struct IDXGIFactoryVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXGIFactory_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IDXGIFactory_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IDXGIFactory_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IDXGIFactory_SetPrivateData(This,Name,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) + +#define IDXGIFactory_SetPrivateDataInterface(This,Name,pUnknown) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) + +#define IDXGIFactory_GetPrivateData(This,Name,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) + +#define IDXGIFactory_GetParent(This,riid,ppParent) \ + ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) + + +#define IDXGIFactory_EnumAdapters(This,Adapter,ppAdapter) \ + ( (This)->lpVtbl -> EnumAdapters(This,Adapter,ppAdapter) ) + +#define IDXGIFactory_MakeWindowAssociation(This,WindowHandle,Flags) \ + ( (This)->lpVtbl -> MakeWindowAssociation(This,WindowHandle,Flags) ) + +#define IDXGIFactory_GetWindowAssociation(This,pWindowHandle) \ + ( (This)->lpVtbl -> GetWindowAssociation(This,pWindowHandle) ) + +#define IDXGIFactory_CreateSwapChain(This,pDevice,pDesc,ppSwapChain) \ + ( (This)->lpVtbl -> CreateSwapChain(This,pDevice,pDesc,ppSwapChain) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IDXGIFactory_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxgi_0000_0008 */ +/* [local] */ + +HRESULT WINAPI CreateDXGIFactory(REFIID riid, void **ppFactory); + + +extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0008_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0008_v0_0_s_ifspec; + +#ifndef __IDXGIDevice_INTERFACE_DEFINED__ +#define __IDXGIDevice_INTERFACE_DEFINED__ + +/* interface IDXGIDevice */ +/* [unique][local][uuid][object] */ + + +EXTERN_C const IID IID_IDXGIDevice; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("54ec77fa-1377-44e6-8c32-88fd5f44c84c") + IDXGIDevice : public IDXGIObject + { + public: + virtual HRESULT STDMETHODCALLTYPE GetAdapter( + /* [out] */ IDXGIAdapter **pAdapter) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateSurface( + /* [in] */ const DXGI_SURFACE_DESC *pDesc, + /* [in] */ UINT NumSurfaces, + /* [in] */ DXGI_USAGE Usage, + /* [in] */ const DXGI_SHARED_RESOURCE *pSharedResource, + /* [out] */ IDXGISurface **ppSurface) = 0; + + virtual HRESULT STDMETHODCALLTYPE QueryResourceResidency( + /* [size_is][in] */ IUnknown *const *ppResources, + /* [size_is][out] */ DXGI_RESIDENCY *pResidencyStatus, + /* [in] */ SIZE_T NumResources) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetGPUThreadPriority( + /* [in] */ INT Priority) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetGPUThreadPriority( + /* [retval][out] */ INT *pPriority) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXGIDeviceVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXGIDevice * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXGIDevice * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXGIDevice * This); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + IDXGIDevice * This, + /* [in] */ REFGUID Name, + /* [in] */ SIZE_T DataSize, + /* [in] */ const void *pData); + + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + IDXGIDevice * This, + /* [in] */ REFGUID Name, + /* [in] */ const IUnknown *pUnknown); + + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + IDXGIDevice * This, + /* [in] */ REFGUID Name, + /* [out][in] */ SIZE_T *pDataSize, + /* [out] */ void *pData); + + HRESULT ( STDMETHODCALLTYPE *GetParent )( + IDXGIDevice * This, + /* [in] */ REFIID riid, + /* [retval][out] */ void **ppParent); + + HRESULT ( STDMETHODCALLTYPE *GetAdapter )( + IDXGIDevice * This, + /* [out] */ IDXGIAdapter **pAdapter); + + HRESULT ( STDMETHODCALLTYPE *CreateSurface )( + IDXGIDevice * This, + /* [in] */ const DXGI_SURFACE_DESC *pDesc, + /* [in] */ UINT NumSurfaces, + /* [in] */ DXGI_USAGE Usage, + /* [in] */ const DXGI_SHARED_RESOURCE *pSharedResource, + /* [out] */ IDXGISurface **ppSurface); + + HRESULT ( STDMETHODCALLTYPE *QueryResourceResidency )( + IDXGIDevice * This, + /* [size_is][in] */ IUnknown *const *ppResources, + /* [size_is][out] */ DXGI_RESIDENCY *pResidencyStatus, + /* [in] */ SIZE_T NumResources); + + HRESULT ( STDMETHODCALLTYPE *SetGPUThreadPriority )( + IDXGIDevice * This, + /* [in] */ INT Priority); + + HRESULT ( STDMETHODCALLTYPE *GetGPUThreadPriority )( + IDXGIDevice * This, + /* [retval][out] */ INT *pPriority); + + END_INTERFACE + } IDXGIDeviceVtbl; + + interface IDXGIDevice + { + CONST_VTBL struct IDXGIDeviceVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXGIDevice_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IDXGIDevice_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IDXGIDevice_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IDXGIDevice_SetPrivateData(This,Name,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) + +#define IDXGIDevice_SetPrivateDataInterface(This,Name,pUnknown) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) + +#define IDXGIDevice_GetPrivateData(This,Name,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) + +#define IDXGIDevice_GetParent(This,riid,ppParent) \ + ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) + + +#define IDXGIDevice_GetAdapter(This,pAdapter) \ + ( (This)->lpVtbl -> GetAdapter(This,pAdapter) ) + +#define IDXGIDevice_CreateSurface(This,pDesc,NumSurfaces,Usage,pSharedResource,ppSurface) \ + ( (This)->lpVtbl -> CreateSurface(This,pDesc,NumSurfaces,Usage,pSharedResource,ppSurface) ) + +#define IDXGIDevice_QueryResourceResidency(This,ppResources,pResidencyStatus,NumResources) \ + ( (This)->lpVtbl -> QueryResourceResidency(This,ppResources,pResidencyStatus,NumResources) ) + +#define IDXGIDevice_SetGPUThreadPriority(This,Priority) \ + ( (This)->lpVtbl -> SetGPUThreadPriority(This,Priority) ) + +#define IDXGIDevice_GetGPUThreadPriority(This,pPriority) \ + ( (This)->lpVtbl -> GetGPUThreadPriority(This,pPriority) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IDXGIDevice_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxgi_0000_0009 */ +/* [local] */ + +HRESULT WINAPI CreateDataTransportDevice( IDXGIAdapter *pAdapter, IDXGIDevice **pOut); +#ifdef __cplusplus +#endif /*__cplusplus*/ + + +extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0009_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0009_v0_0_s_ifspec; + +/* Additional Prototypes for ALL interfaces */ + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/dep/include/DXSDK/include/DXGIType.h b/src/dep/include/DXSDK/include/DXGIType.h index 36fa61f..fc65fee 100644 --- a/src/dep/include/DXSDK/include/DXGIType.h +++ b/src/dep/include/DXSDK/include/DXGIType.h @@ -1,359 +1,359 @@ - - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 7.00.0485 */ -/* Compiler settings for dxgitype.idl: - Oicf, W1, Zp8, env=Win32 (32b run) - protocol : dce , ms_ext, c_ext, robust - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() -*/ -//@@MIDL_FILE_HEADING( ) - -#pragma warning( disable: 4049 ) /* more than 64k source lines */ - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 475 -#endif - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCSAL_H_VERSION__ -#define __REQUIRED_RPCSAL_H_VERSION__ 100 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ - - -#ifndef __dxgitype_h__ -#define __dxgitype_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -/* Forward Declarations */ - -/* header files for imported files */ -#include "oaidl.h" -#include "ocidl.h" - -#ifdef __cplusplus -extern "C"{ -#endif - - -/* interface __MIDL_itf_dxgitype_0000_0000 */ -/* [local] */ - -#define _FACDXGI 0x87a -#define MAKE_DXGI_HRESULT( code ) MAKE_HRESULT( 1, _FACDXGI, code ) -#define MAKE_DXGI_STATUS( code ) MAKE_HRESULT( 0, _FACDXGI, code ) -#define DXGI_STATUS_OCCLUDED MAKE_DXGI_STATUS(1 ) -#define DXGI_STATUS_CLIPPED MAKE_DXGI_STATUS(2 ) -#define DXGI_STATUS_NO_REDIRECTION MAKE_DXGI_STATUS(4 ) -#define DXGI_ERROR_INVALID_CALL MAKE_DXGI_HRESULT( 1 ) -#define DXGI_ERROR_NOT_FOUND MAKE_DXGI_HRESULT( 2 ) -#define DXGI_ERROR_MORE_DATA MAKE_DXGI_HRESULT( 3 ) -#define DXGI_ERROR_UNSUPPORTED MAKE_DXGI_HRESULT( 4 ) -#define DXGI_ERROR_DEVICE_REMOVED MAKE_DXGI_HRESULT( 5 ) -#define DXGI_ERROR_DEVICE_HUNG MAKE_DXGI_HRESULT( 6 ) -#define DXGI_ERROR_DEVICE_RESET MAKE_DXGI_HRESULT( 7 ) -#define DXGI_ERROR_WAS_STILL_DRAWING MAKE_DXGI_HRESULT( 10 ) -#define DXGI_ERROR_DRIVER_INTERNAL_ERROR MAKE_DXGI_HRESULT( 32 ) -#define DXGI_ERROR_NONEXCLUSIVE MAKE_DXGI_HRESULT( 33 ) -#define DXGI_CPU_ACCESS_NONE ( 0 ) -#define DXGI_CPU_ACCESS_DYNAMIC ( 1 ) -#define DXGI_CPU_ACCESS_READ_WRITE ( 2 ) -#define DXGI_CPU_ACCESS_SCRATCH ( 3 ) -#define DXGI_CPU_ACCESS_FIELD 15 -#define DXGI_USAGE_SHADER_INPUT ( 1L << (0 + 4) ) -#define DXGI_USAGE_RENDER_TARGET_OUTPUT ( 1L << (1 + 4) ) -#define DXGI_USAGE_BACK_BUFFER ( 1L << (2 + 4) ) -#define DXGI_USAGE_SHARED ( 1L << (3 + 4) ) -#define DXGI_USAGE_PRIMARY ( 1L << (4 + 4) ) -typedef UINT DXGI_USAGE; - -typedef -enum DXGI_FORMAT - { DXGI_FORMAT_UNKNOWN = 0, - DXGI_FORMAT_R32G32B32A32_TYPELESS = 1, - DXGI_FORMAT_R32G32B32A32_FLOAT = 2, - DXGI_FORMAT_R32G32B32A32_UINT = 3, - DXGI_FORMAT_R32G32B32A32_SINT = 4, - DXGI_FORMAT_R32G32B32_TYPELESS = 5, - DXGI_FORMAT_R32G32B32_FLOAT = 6, - DXGI_FORMAT_R32G32B32_UINT = 7, - DXGI_FORMAT_R32G32B32_SINT = 8, - DXGI_FORMAT_R16G16B16A16_TYPELESS = 9, - DXGI_FORMAT_R16G16B16A16_FLOAT = 10, - DXGI_FORMAT_R16G16B16A16_UNORM = 11, - DXGI_FORMAT_R16G16B16A16_UINT = 12, - DXGI_FORMAT_R16G16B16A16_SNORM = 13, - DXGI_FORMAT_R16G16B16A16_SINT = 14, - DXGI_FORMAT_R32G32_TYPELESS = 15, - DXGI_FORMAT_R32G32_FLOAT = 16, - DXGI_FORMAT_R32G32_UINT = 17, - DXGI_FORMAT_R32G32_SINT = 18, - DXGI_FORMAT_R32G8X24_TYPELESS = 19, - DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20, - DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21, - DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22, - DXGI_FORMAT_R10G10B10A2_TYPELESS = 23, - DXGI_FORMAT_R10G10B10A2_UNORM = 24, - DXGI_FORMAT_R10G10B10A2_UINT = 25, - DXGI_FORMAT_R11G11B10_FLOAT = 26, - DXGI_FORMAT_R8G8B8A8_TYPELESS = 27, - DXGI_FORMAT_R8G8B8A8_UNORM = 28, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29, - DXGI_FORMAT_R8G8B8A8_UINT = 30, - DXGI_FORMAT_R8G8B8A8_SNORM = 31, - DXGI_FORMAT_R8G8B8A8_SINT = 32, - DXGI_FORMAT_R16G16_TYPELESS = 33, - DXGI_FORMAT_R16G16_FLOAT = 34, - DXGI_FORMAT_R16G16_UNORM = 35, - DXGI_FORMAT_R16G16_UINT = 36, - DXGI_FORMAT_R16G16_SNORM = 37, - DXGI_FORMAT_R16G16_SINT = 38, - DXGI_FORMAT_R32_TYPELESS = 39, - DXGI_FORMAT_D32_FLOAT = 40, - DXGI_FORMAT_R32_FLOAT = 41, - DXGI_FORMAT_R32_UINT = 42, - DXGI_FORMAT_R32_SINT = 43, - DXGI_FORMAT_R24G8_TYPELESS = 44, - DXGI_FORMAT_D24_UNORM_S8_UINT = 45, - DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46, - DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47, - DXGI_FORMAT_R8G8_TYPELESS = 48, - DXGI_FORMAT_R8G8_UNORM = 49, - DXGI_FORMAT_R8G8_UINT = 50, - DXGI_FORMAT_R8G8_SNORM = 51, - DXGI_FORMAT_R8G8_SINT = 52, - DXGI_FORMAT_R16_TYPELESS = 53, - DXGI_FORMAT_R16_FLOAT = 54, - DXGI_FORMAT_D16_UNORM = 55, - DXGI_FORMAT_R16_UNORM = 56, - DXGI_FORMAT_R16_UINT = 57, - DXGI_FORMAT_R16_SNORM = 58, - DXGI_FORMAT_R16_SINT = 59, - DXGI_FORMAT_R8_TYPELESS = 60, - DXGI_FORMAT_R8_UNORM = 61, - DXGI_FORMAT_R8_UINT = 62, - DXGI_FORMAT_R8_SNORM = 63, - DXGI_FORMAT_R8_SINT = 64, - DXGI_FORMAT_A8_UNORM = 65, - DXGI_FORMAT_R1_UNORM = 66, - DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67, - DXGI_FORMAT_R8G8_B8G8_UNORM = 68, - DXGI_FORMAT_G8R8_G8B8_UNORM = 69, - DXGI_FORMAT_BC1_TYPELESS = 70, - DXGI_FORMAT_BC1_UNORM = 71, - DXGI_FORMAT_BC1_UNORM_SRGB = 72, - DXGI_FORMAT_BC2_TYPELESS = 73, - DXGI_FORMAT_BC2_UNORM = 74, - DXGI_FORMAT_BC2_UNORM_SRGB = 75, - DXGI_FORMAT_BC3_TYPELESS = 76, - DXGI_FORMAT_BC3_UNORM = 77, - DXGI_FORMAT_BC3_UNORM_SRGB = 78, - DXGI_FORMAT_BC4_TYPELESS = 79, - DXGI_FORMAT_BC4_UNORM = 80, - DXGI_FORMAT_BC4_SNORM = 81, - DXGI_FORMAT_BC5_TYPELESS = 82, - DXGI_FORMAT_BC5_UNORM = 83, - DXGI_FORMAT_BC5_SNORM = 84, - DXGI_FORMAT_B5G6R5_UNORM = 85, - DXGI_FORMAT_B5G5R5A1_UNORM = 86, - DXGI_FORMAT_B8G8R8A8_UNORM = 87, - DXGI_FORMAT_B8G8R8X8_UNORM = 88, - DXGI_FORMAT_FORCE_UINT = 0xffffffffUL - } DXGI_FORMAT; - -typedef struct DXGI_RGB - { - float Red; - float Green; - float Blue; - } DXGI_RGB; - -typedef struct DXGI_GAMMA_CONTROL - { - DXGI_RGB Scale; - DXGI_RGB Offset; - DXGI_RGB GammaCurve[ 1025 ]; - } DXGI_GAMMA_CONTROL; - -typedef struct DXGI_GAMMA_CONTROL_CAPABILIITES - { - BOOL ScaleAndOffsetSupported; - float MaxConvertedValue; - float MinConvertedValue; - UINT NumGammaControlPoints; - float ControlPointPositions[ 1025 ]; - } DXGI_GAMMA_CONTROL_CAPABILIITES; - -typedef struct DXGI_FRAME_STATISTICS - { - UINT PresentCount; - UINT PresentRefreshCount; - UINT SyncRefreshCount; - LARGE_INTEGER SyncQPCTime; - LARGE_INTEGER SyncGPUTime; - } DXGI_FRAME_STATISTICS; - -typedef struct DXGI_RATIONAL - { - UINT Numerator; - UINT Denominator; - } DXGI_RATIONAL; - -typedef -enum DXGI_MODE_SCANLINE_ORDER - { DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED = 0, - DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE = 1, - DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST = 2, - DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST = 3 - } DXGI_MODE_SCANLINE_ORDER; - -typedef -enum DXGI_MODE_SCALING - { DXGI_MODE_SCALING_UNSPECIFIED = 0, - DXGI_MODE_SCALING_CENTERED = 1, - DXGI_MODE_SCALING_STRETCHED = 2 - } DXGI_MODE_SCALING; - -typedef -enum DXGI_MODE_ROTATION - { DXGI_MODE_ROTATION_UNSPECIFIED = 0, - DXGI_MODE_ROTATION_IDENTITY = 1, - DXGI_MODE_ROTATION_ROTATE90 = 2, - DXGI_MODE_ROTATION_ROTATE180 = 3, - DXGI_MODE_ROTATION_ROTATE270 = 4 - } DXGI_MODE_ROTATION; - -typedef struct DXGI_MODE_DESC - { - UINT Width; - UINT Height; - DXGI_RATIONAL RefreshRate; - DXGI_FORMAT Format; - DXGI_MODE_SCANLINE_ORDER ScanlineOrdering; - DXGI_MODE_SCALING Scaling; - } DXGI_MODE_DESC; - -typedef struct DXGI_MAPPED_RECT - { - INT Pitch; - BYTE *pBits; - } DXGI_MAPPED_RECT; - -typedef struct DXGI_ADAPTER_DESC - { - WCHAR Description[ 128 ]; - UINT VendorId; - UINT DeviceId; - UINT SubSysId; - UINT Revision; - SIZE_T DedicatedVideoMemory; - SIZE_T SharedVideoMemory; - } DXGI_ADAPTER_DESC; - -#if !defined(HMONITOR_DECLARED) && !defined(HMONITOR) && (WINVER < 0x0500) -#define HMONITOR_DECLARED -#if 0 -typedef HANDLE HMONITOR; - -#endif -DECLARE_HANDLE(HMONITOR); -#endif -typedef struct DXGI_OUTPUT_DESC - { - WCHAR DeviceName[ 32 ]; - RECT DesktopCoordinates; - BOOL AttachedToDesktop; - DXGI_MODE_ROTATION Rotation; - HMONITOR Monitor; - } DXGI_OUTPUT_DESC; - -typedef struct DXGI_SAMPLE_DESC - { - UINT Count; - UINT Quality; - } DXGI_SAMPLE_DESC; - -typedef struct DXGI_SHARED_RESOURCE - { - HANDLE Handle; - DXGI_USAGE OpenUsage; - } DXGI_SHARED_RESOURCE; - -#define DXGI_RESOURCE_PRIORITY_MINIMUM ( 0x28000000 ) - -#define DXGI_RESOURCE_PRIORITY_LOW ( 0x50000000 ) - -#define DXGI_RESOURCE_PRIORITY_NORMAL ( 0x78000000 ) - -#define DXGI_RESOURCE_PRIORITY_HIGH ( 0xa0000000 ) - -#define DXGI_RESOURCE_PRIORITY_MAXIMUM ( 0xc8000000 ) - -typedef -enum DXGI_RESIDENCY - { DXGI_RESIDENCY_FULLY_RESIDENT = 1, - DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY = 2, - DXGI_RESIDENCY_EVICTED_TO_DISK = 3 - } DXGI_RESIDENCY; - -typedef struct DXGI_SURFACE_DESC - { - UINT Width; - UINT Height; - DXGI_FORMAT Format; - DXGI_SAMPLE_DESC SampleDesc; - } DXGI_SURFACE_DESC; - -typedef -enum DXGI_SWAP_EFFECT - { DXGI_SWAP_EFFECT_DISCARD = 0, - DXGI_SWAP_EFFECT_COPY = 1 - } DXGI_SWAP_EFFECT; - -typedef struct DXGI_SWAP_CHAIN_DESC - { - DXGI_MODE_DESC BackBufferDesc; - DXGI_SAMPLE_DESC SampleDesc; - DXGI_SHARED_RESOURCE Sharing; - DXGI_USAGE BackBufferUsage; - UINT BackBufferCount; - UINT MaxFrameLatency; - HWND OutputWindow; - BOOL Windowed; - DXGI_SWAP_EFFECT SwapEffect; - DXGI_MODE_ROTATION BackBufferRotation; - } DXGI_SWAP_CHAIN_DESC; - - - -extern RPC_IF_HANDLE __MIDL_itf_dxgitype_0000_0000_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgitype_0000_0000_v0_0_s_ifspec; - -/* Additional Prototypes for ALL interfaces */ - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 7.00.0485 */ +/* Compiler settings for dxgitype.idl: + Oicf, W1, Zp8, env=Win32 (32b run) + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +//@@MIDL_FILE_HEADING( ) + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCSAL_H_VERSION__ +#define __REQUIRED_RPCSAL_H_VERSION__ 100 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif // __RPCNDR_H_VERSION__ + + +#ifndef __dxgitype_h__ +#define __dxgitype_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +/* header files for imported files */ +#include "oaidl.h" +#include "ocidl.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +/* interface __MIDL_itf_dxgitype_0000_0000 */ +/* [local] */ + +#define _FACDXGI 0x87a +#define MAKE_DXGI_HRESULT( code ) MAKE_HRESULT( 1, _FACDXGI, code ) +#define MAKE_DXGI_STATUS( code ) MAKE_HRESULT( 0, _FACDXGI, code ) +#define DXGI_STATUS_OCCLUDED MAKE_DXGI_STATUS(1 ) +#define DXGI_STATUS_CLIPPED MAKE_DXGI_STATUS(2 ) +#define DXGI_STATUS_NO_REDIRECTION MAKE_DXGI_STATUS(4 ) +#define DXGI_ERROR_INVALID_CALL MAKE_DXGI_HRESULT( 1 ) +#define DXGI_ERROR_NOT_FOUND MAKE_DXGI_HRESULT( 2 ) +#define DXGI_ERROR_MORE_DATA MAKE_DXGI_HRESULT( 3 ) +#define DXGI_ERROR_UNSUPPORTED MAKE_DXGI_HRESULT( 4 ) +#define DXGI_ERROR_DEVICE_REMOVED MAKE_DXGI_HRESULT( 5 ) +#define DXGI_ERROR_DEVICE_HUNG MAKE_DXGI_HRESULT( 6 ) +#define DXGI_ERROR_DEVICE_RESET MAKE_DXGI_HRESULT( 7 ) +#define DXGI_ERROR_WAS_STILL_DRAWING MAKE_DXGI_HRESULT( 10 ) +#define DXGI_ERROR_DRIVER_INTERNAL_ERROR MAKE_DXGI_HRESULT( 32 ) +#define DXGI_ERROR_NONEXCLUSIVE MAKE_DXGI_HRESULT( 33 ) +#define DXGI_CPU_ACCESS_NONE ( 0 ) +#define DXGI_CPU_ACCESS_DYNAMIC ( 1 ) +#define DXGI_CPU_ACCESS_READ_WRITE ( 2 ) +#define DXGI_CPU_ACCESS_SCRATCH ( 3 ) +#define DXGI_CPU_ACCESS_FIELD 15 +#define DXGI_USAGE_SHADER_INPUT ( 1L << (0 + 4) ) +#define DXGI_USAGE_RENDER_TARGET_OUTPUT ( 1L << (1 + 4) ) +#define DXGI_USAGE_BACK_BUFFER ( 1L << (2 + 4) ) +#define DXGI_USAGE_SHARED ( 1L << (3 + 4) ) +#define DXGI_USAGE_PRIMARY ( 1L << (4 + 4) ) +typedef UINT DXGI_USAGE; + +typedef +enum DXGI_FORMAT + { DXGI_FORMAT_UNKNOWN = 0, + DXGI_FORMAT_R32G32B32A32_TYPELESS = 1, + DXGI_FORMAT_R32G32B32A32_FLOAT = 2, + DXGI_FORMAT_R32G32B32A32_UINT = 3, + DXGI_FORMAT_R32G32B32A32_SINT = 4, + DXGI_FORMAT_R32G32B32_TYPELESS = 5, + DXGI_FORMAT_R32G32B32_FLOAT = 6, + DXGI_FORMAT_R32G32B32_UINT = 7, + DXGI_FORMAT_R32G32B32_SINT = 8, + DXGI_FORMAT_R16G16B16A16_TYPELESS = 9, + DXGI_FORMAT_R16G16B16A16_FLOAT = 10, + DXGI_FORMAT_R16G16B16A16_UNORM = 11, + DXGI_FORMAT_R16G16B16A16_UINT = 12, + DXGI_FORMAT_R16G16B16A16_SNORM = 13, + DXGI_FORMAT_R16G16B16A16_SINT = 14, + DXGI_FORMAT_R32G32_TYPELESS = 15, + DXGI_FORMAT_R32G32_FLOAT = 16, + DXGI_FORMAT_R32G32_UINT = 17, + DXGI_FORMAT_R32G32_SINT = 18, + DXGI_FORMAT_R32G8X24_TYPELESS = 19, + DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20, + DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21, + DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22, + DXGI_FORMAT_R10G10B10A2_TYPELESS = 23, + DXGI_FORMAT_R10G10B10A2_UNORM = 24, + DXGI_FORMAT_R10G10B10A2_UINT = 25, + DXGI_FORMAT_R11G11B10_FLOAT = 26, + DXGI_FORMAT_R8G8B8A8_TYPELESS = 27, + DXGI_FORMAT_R8G8B8A8_UNORM = 28, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29, + DXGI_FORMAT_R8G8B8A8_UINT = 30, + DXGI_FORMAT_R8G8B8A8_SNORM = 31, + DXGI_FORMAT_R8G8B8A8_SINT = 32, + DXGI_FORMAT_R16G16_TYPELESS = 33, + DXGI_FORMAT_R16G16_FLOAT = 34, + DXGI_FORMAT_R16G16_UNORM = 35, + DXGI_FORMAT_R16G16_UINT = 36, + DXGI_FORMAT_R16G16_SNORM = 37, + DXGI_FORMAT_R16G16_SINT = 38, + DXGI_FORMAT_R32_TYPELESS = 39, + DXGI_FORMAT_D32_FLOAT = 40, + DXGI_FORMAT_R32_FLOAT = 41, + DXGI_FORMAT_R32_UINT = 42, + DXGI_FORMAT_R32_SINT = 43, + DXGI_FORMAT_R24G8_TYPELESS = 44, + DXGI_FORMAT_D24_UNORM_S8_UINT = 45, + DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46, + DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47, + DXGI_FORMAT_R8G8_TYPELESS = 48, + DXGI_FORMAT_R8G8_UNORM = 49, + DXGI_FORMAT_R8G8_UINT = 50, + DXGI_FORMAT_R8G8_SNORM = 51, + DXGI_FORMAT_R8G8_SINT = 52, + DXGI_FORMAT_R16_TYPELESS = 53, + DXGI_FORMAT_R16_FLOAT = 54, + DXGI_FORMAT_D16_UNORM = 55, + DXGI_FORMAT_R16_UNORM = 56, + DXGI_FORMAT_R16_UINT = 57, + DXGI_FORMAT_R16_SNORM = 58, + DXGI_FORMAT_R16_SINT = 59, + DXGI_FORMAT_R8_TYPELESS = 60, + DXGI_FORMAT_R8_UNORM = 61, + DXGI_FORMAT_R8_UINT = 62, + DXGI_FORMAT_R8_SNORM = 63, + DXGI_FORMAT_R8_SINT = 64, + DXGI_FORMAT_A8_UNORM = 65, + DXGI_FORMAT_R1_UNORM = 66, + DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67, + DXGI_FORMAT_R8G8_B8G8_UNORM = 68, + DXGI_FORMAT_G8R8_G8B8_UNORM = 69, + DXGI_FORMAT_BC1_TYPELESS = 70, + DXGI_FORMAT_BC1_UNORM = 71, + DXGI_FORMAT_BC1_UNORM_SRGB = 72, + DXGI_FORMAT_BC2_TYPELESS = 73, + DXGI_FORMAT_BC2_UNORM = 74, + DXGI_FORMAT_BC2_UNORM_SRGB = 75, + DXGI_FORMAT_BC3_TYPELESS = 76, + DXGI_FORMAT_BC3_UNORM = 77, + DXGI_FORMAT_BC3_UNORM_SRGB = 78, + DXGI_FORMAT_BC4_TYPELESS = 79, + DXGI_FORMAT_BC4_UNORM = 80, + DXGI_FORMAT_BC4_SNORM = 81, + DXGI_FORMAT_BC5_TYPELESS = 82, + DXGI_FORMAT_BC5_UNORM = 83, + DXGI_FORMAT_BC5_SNORM = 84, + DXGI_FORMAT_B5G6R5_UNORM = 85, + DXGI_FORMAT_B5G5R5A1_UNORM = 86, + DXGI_FORMAT_B8G8R8A8_UNORM = 87, + DXGI_FORMAT_B8G8R8X8_UNORM = 88, + DXGI_FORMAT_FORCE_UINT = 0xffffffffUL + } DXGI_FORMAT; + +typedef struct DXGI_RGB + { + float Red; + float Green; + float Blue; + } DXGI_RGB; + +typedef struct DXGI_GAMMA_CONTROL + { + DXGI_RGB Scale; + DXGI_RGB Offset; + DXGI_RGB GammaCurve[ 1025 ]; + } DXGI_GAMMA_CONTROL; + +typedef struct DXGI_GAMMA_CONTROL_CAPABILIITES + { + BOOL ScaleAndOffsetSupported; + float MaxConvertedValue; + float MinConvertedValue; + UINT NumGammaControlPoints; + float ControlPointPositions[ 1025 ]; + } DXGI_GAMMA_CONTROL_CAPABILIITES; + +typedef struct DXGI_FRAME_STATISTICS + { + UINT PresentCount; + UINT PresentRefreshCount; + UINT SyncRefreshCount; + LARGE_INTEGER SyncQPCTime; + LARGE_INTEGER SyncGPUTime; + } DXGI_FRAME_STATISTICS; + +typedef struct DXGI_RATIONAL + { + UINT Numerator; + UINT Denominator; + } DXGI_RATIONAL; + +typedef +enum DXGI_MODE_SCANLINE_ORDER + { DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED = 0, + DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE = 1, + DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST = 2, + DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST = 3 + } DXGI_MODE_SCANLINE_ORDER; + +typedef +enum DXGI_MODE_SCALING + { DXGI_MODE_SCALING_UNSPECIFIED = 0, + DXGI_MODE_SCALING_CENTERED = 1, + DXGI_MODE_SCALING_STRETCHED = 2 + } DXGI_MODE_SCALING; + +typedef +enum DXGI_MODE_ROTATION + { DXGI_MODE_ROTATION_UNSPECIFIED = 0, + DXGI_MODE_ROTATION_IDENTITY = 1, + DXGI_MODE_ROTATION_ROTATE90 = 2, + DXGI_MODE_ROTATION_ROTATE180 = 3, + DXGI_MODE_ROTATION_ROTATE270 = 4 + } DXGI_MODE_ROTATION; + +typedef struct DXGI_MODE_DESC + { + UINT Width; + UINT Height; + DXGI_RATIONAL RefreshRate; + DXGI_FORMAT Format; + DXGI_MODE_SCANLINE_ORDER ScanlineOrdering; + DXGI_MODE_SCALING Scaling; + } DXGI_MODE_DESC; + +typedef struct DXGI_MAPPED_RECT + { + INT Pitch; + BYTE *pBits; + } DXGI_MAPPED_RECT; + +typedef struct DXGI_ADAPTER_DESC + { + WCHAR Description[ 128 ]; + UINT VendorId; + UINT DeviceId; + UINT SubSysId; + UINT Revision; + SIZE_T DedicatedVideoMemory; + SIZE_T SharedVideoMemory; + } DXGI_ADAPTER_DESC; + +#if !defined(HMONITOR_DECLARED) && !defined(HMONITOR) && (WINVER < 0x0500) +#define HMONITOR_DECLARED +#if 0 +typedef HANDLE HMONITOR; + +#endif +DECLARE_HANDLE(HMONITOR); +#endif +typedef struct DXGI_OUTPUT_DESC + { + WCHAR DeviceName[ 32 ]; + RECT DesktopCoordinates; + BOOL AttachedToDesktop; + DXGI_MODE_ROTATION Rotation; + HMONITOR Monitor; + } DXGI_OUTPUT_DESC; + +typedef struct DXGI_SAMPLE_DESC + { + UINT Count; + UINT Quality; + } DXGI_SAMPLE_DESC; + +typedef struct DXGI_SHARED_RESOURCE + { + HANDLE Handle; + DXGI_USAGE OpenUsage; + } DXGI_SHARED_RESOURCE; + +#define DXGI_RESOURCE_PRIORITY_MINIMUM ( 0x28000000 ) + +#define DXGI_RESOURCE_PRIORITY_LOW ( 0x50000000 ) + +#define DXGI_RESOURCE_PRIORITY_NORMAL ( 0x78000000 ) + +#define DXGI_RESOURCE_PRIORITY_HIGH ( 0xa0000000 ) + +#define DXGI_RESOURCE_PRIORITY_MAXIMUM ( 0xc8000000 ) + +typedef +enum DXGI_RESIDENCY + { DXGI_RESIDENCY_FULLY_RESIDENT = 1, + DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY = 2, + DXGI_RESIDENCY_EVICTED_TO_DISK = 3 + } DXGI_RESIDENCY; + +typedef struct DXGI_SURFACE_DESC + { + UINT Width; + UINT Height; + DXGI_FORMAT Format; + DXGI_SAMPLE_DESC SampleDesc; + } DXGI_SURFACE_DESC; + +typedef +enum DXGI_SWAP_EFFECT + { DXGI_SWAP_EFFECT_DISCARD = 0, + DXGI_SWAP_EFFECT_COPY = 1 + } DXGI_SWAP_EFFECT; + +typedef struct DXGI_SWAP_CHAIN_DESC + { + DXGI_MODE_DESC BackBufferDesc; + DXGI_SAMPLE_DESC SampleDesc; + DXGI_SHARED_RESOURCE Sharing; + DXGI_USAGE BackBufferUsage; + UINT BackBufferCount; + UINT MaxFrameLatency; + HWND OutputWindow; + BOOL Windowed; + DXGI_SWAP_EFFECT SwapEffect; + DXGI_MODE_ROTATION BackBufferRotation; + } DXGI_SWAP_CHAIN_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_dxgitype_0000_0000_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxgitype_0000_0000_v0_0_s_ifspec; + +/* Additional Prototypes for ALL interfaces */ + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/dep/include/DXSDK/include/DxErr.h b/src/dep/include/DXSDK/include/DxErr.h index ef1c7e0..c44f607 100644 --- a/src/dep/include/DXSDK/include/DxErr.h +++ b/src/dep/include/DXSDK/include/DxErr.h @@ -1,99 +1,99 @@ -/*==========================================================================; - * - * - * File: dxerr.h - * Content: DirectX Error Library Include File - * - ****************************************************************************/ - -#ifndef _DXERR_H_ -#define _DXERR_H_ - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -// -// DXGetErrorString -// -// Desc: Converts a DirectX HRESULT to a string -// -// Args: HRESULT hr Can be any error code from -// XACT D3D10 D3DX10 D3D9 D3DX9 D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW -// -// Return: Converted string -// -const char* WINAPI DXGetErrorStringA(HRESULT hr); -const WCHAR* WINAPI DXGetErrorStringW(HRESULT hr); - -#ifdef UNICODE -#define DXGetErrorString DXGetErrorStringW -#else -#define DXGetErrorString DXGetErrorStringA -#endif - - -// -// DXGetErrorDescription -// -// Desc: Returns a string description of a DirectX HRESULT -// -// Args: HRESULT hr Can be any error code from -// XACT D3D10 D3DX10 D3D9 D3DX9 D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW -// -// Return: String description -// -const char* WINAPI DXGetErrorDescriptionA(HRESULT hr); -const WCHAR* WINAPI DXGetErrorDescriptionW(HRESULT hr); - -#ifdef UNICODE - #define DXGetErrorDescription DXGetErrorDescriptionW -#else - #define DXGetErrorDescription DXGetErrorDescriptionA -#endif - - -// -// DXTrace -// -// Desc: Outputs a formatted error message to the debug stream -// -// Args: CHAR* strFile The current file, typically passed in using the -// __FILE__ macro. -// DWORD dwLine The current line number, typically passed in using the -// __LINE__ macro. -// HRESULT hr An HRESULT that will be traced to the debug stream. -// CHAR* strMsg A string that will be traced to the debug stream (may be NULL) -// BOOL bPopMsgBox If TRUE, then a message box will popup also containing the passed info. -// -// Return: The hr that was passed in. -// -HRESULT WINAPI DXTraceA( const char* strFile, DWORD dwLine, HRESULT hr, const char* strMsg, BOOL bPopMsgBox ); -HRESULT WINAPI DXTraceW( const char* strFile, DWORD dwLine, HRESULT hr, const WCHAR* strMsg, BOOL bPopMsgBox ); - -#ifdef UNICODE -#define DXTrace DXTraceW -#else -#define DXTrace DXTraceA -#endif - - -// -// Helper macros -// -#if defined(DEBUG) | defined(_DEBUG) -#define DXTRACE_MSG(str) DXTrace( __FILE__, (DWORD)__LINE__, 0, str, FALSE ) -#define DXTRACE_ERR(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, FALSE ) -#define DXTRACE_ERR_MSGBOX(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, TRUE ) -#else -#define DXTRACE_MSG(str) (0L) -#define DXTRACE_ERR(str,hr) (hr) -#define DXTRACE_ERR_MSGBOX(str,hr) (hr) -#endif - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif // _DXERR_H_ +/*==========================================================================; + * + * + * File: dxerr.h + * Content: DirectX Error Library Include File + * + ****************************************************************************/ + +#ifndef _DXERR_H_ +#define _DXERR_H_ + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +// +// DXGetErrorString +// +// Desc: Converts a DirectX HRESULT to a string +// +// Args: HRESULT hr Can be any error code from +// XACT D3D10 D3DX10 D3D9 D3DX9 D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW +// +// Return: Converted string +// +const char* WINAPI DXGetErrorStringA(HRESULT hr); +const WCHAR* WINAPI DXGetErrorStringW(HRESULT hr); + +#ifdef UNICODE +#define DXGetErrorString DXGetErrorStringW +#else +#define DXGetErrorString DXGetErrorStringA +#endif + + +// +// DXGetErrorDescription +// +// Desc: Returns a string description of a DirectX HRESULT +// +// Args: HRESULT hr Can be any error code from +// XACT D3D10 D3DX10 D3D9 D3DX9 D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW +// +// Return: String description +// +const char* WINAPI DXGetErrorDescriptionA(HRESULT hr); +const WCHAR* WINAPI DXGetErrorDescriptionW(HRESULT hr); + +#ifdef UNICODE + #define DXGetErrorDescription DXGetErrorDescriptionW +#else + #define DXGetErrorDescription DXGetErrorDescriptionA +#endif + + +// +// DXTrace +// +// Desc: Outputs a formatted error message to the debug stream +// +// Args: CHAR* strFile The current file, typically passed in using the +// __FILE__ macro. +// DWORD dwLine The current line number, typically passed in using the +// __LINE__ macro. +// HRESULT hr An HRESULT that will be traced to the debug stream. +// CHAR* strMsg A string that will be traced to the debug stream (may be NULL) +// BOOL bPopMsgBox If TRUE, then a message box will popup also containing the passed info. +// +// Return: The hr that was passed in. +// +HRESULT WINAPI DXTraceA( const char* strFile, DWORD dwLine, HRESULT hr, const char* strMsg, BOOL bPopMsgBox ); +HRESULT WINAPI DXTraceW( const char* strFile, DWORD dwLine, HRESULT hr, const WCHAR* strMsg, BOOL bPopMsgBox ); + +#ifdef UNICODE +#define DXTrace DXTraceW +#else +#define DXTrace DXTraceA +#endif + + +// +// Helper macros +// +#if defined(DEBUG) | defined(_DEBUG) +#define DXTRACE_MSG(str) DXTrace( __FILE__, (DWORD)__LINE__, 0, str, FALSE ) +#define DXTRACE_ERR(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, FALSE ) +#define DXTRACE_ERR_MSGBOX(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, TRUE ) +#else +#define DXTRACE_MSG(str) (0L) +#define DXTRACE_ERR(str,hr) (hr) +#define DXTRACE_ERR_MSGBOX(str,hr) (hr) +#endif + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif // _DXERR_H_ diff --git a/src/dep/include/DXSDK/include/PIXPlugin.h b/src/dep/include/DXSDK/include/PIXPlugin.h index 243c5b4..9c249af 100644 --- a/src/dep/include/DXSDK/include/PIXPlugin.h +++ b/src/dep/include/DXSDK/include/PIXPlugin.h @@ -1,120 +1,120 @@ -//================================================================================================== -// PIXPlugin.h -// -// Microsoft PIX Plugin Header -// -// Copyright (c) Microsoft Corporation, All rights reserved -//================================================================================================== - -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif - - -//================================================================================================== -// PIX_PLUGIN_SYSTEM_VERSION - Indicates version of the plugin interface the plugin is built with. -//================================================================================================== -#define PIX_PLUGIN_SYSTEM_VERSION 0x101 - - -//================================================================================================== -// PIXCOUNTERID - A unique identifier for each PIX plugin counter. -//================================================================================================== -typedef int PIXCOUNTERID; - - -//================================================================================================== -// PIXCOUNTERDATATYPE - Indicates what type of data the counter produces. -//================================================================================================== -enum PIXCOUNTERDATATYPE -{ - PCDT_RESERVED, - PCDT_FLOAT, - PCDT_INT, - PCDT_INT64, - PCDT_STRING, -}; - - -//================================================================================================== -// PIXPLUGININFO - This structure is filled out by PIXGetPluginInfo and passed back to PIX. -//================================================================================================== -struct PIXPLUGININFO -{ - // Filled in by caller: - HINSTANCE hinst; - - // Filled in by PIXGetPluginInfo: - WCHAR* pstrPluginName; // Name of plugin - int iPluginVersion; // Version of this particular plugin - int iPluginSystemVersion; // Version of PIX's plugin system this plugin was designed for -}; - - -//================================================================================================== -// PIXCOUNTERINFO - This structure is filled out by PIXGetCounterInfo and passed back to PIX -// to allow PIX to determine information about the counters in the plugin. -//================================================================================================== -struct PIXCOUNTERINFO -{ - PIXCOUNTERID counterID; // Used to uniquely ID this counter - WCHAR* pstrName; // String name of the counter - PIXCOUNTERDATATYPE pcdtDataType; // Data type returned by this counter -}; - - -//================================================================================================== -// PIXGetPluginInfo - This returns basic information about this plugin to PIX. -//================================================================================================== -BOOL WINAPI PIXGetPluginInfo( PIXPLUGININFO* pPIXPluginInfo ); - - -//================================================================================================== -// PIXGetCounterInfo - This returns an array of PIXCOUNTERINFO structs to PIX. -// These PIXCOUNTERINFOs allow PIX to enumerate the counters contained -// in this plugin. -//================================================================================================== -BOOL WINAPI PIXGetCounterInfo( DWORD* pdwReturnCounters, PIXCOUNTERINFO** ppCounterInfoList ); - - -//================================================================================================== -// PIXGetCounterDesc - This is called by PIX to request a description of the indicated counter. -//================================================================================================== -BOOL WINAPI PIXGetCounterDesc( PIXCOUNTERID id, WCHAR** ppstrCounterDesc ); - - -//================================================================================================== -// PIXBeginExperiment - This called by PIX once per counter when instrumentation starts. -//================================================================================================== -BOOL WINAPI PIXBeginExperiment( PIXCOUNTERID id, const WCHAR* pstrApplication ); - - -//================================================================================================== -// PIXEndFrame - This is called by PIX once per counter at the end of each frame to gather the -// counter value for that frame. Note that the pointer to the return data must -// continue to point to valid counter data until the next call to PIXEndFrame (or -// PIXEndExperiment) for the same counter. So do not set *ppReturnData to the same -// pointer for multiple counters, or point to a local variable that will go out of -// scope. See the sample PIX plugin for an example of how to structure a plugin -// properly. -//================================================================================================== -BOOL WINAPI PIXEndFrame( PIXCOUNTERID id, UINT iFrame, DWORD* pdwReturnBytes, BYTE** ppReturnData ); - - -//================================================================================================== -// PIXEndExperiment - This is called by PIX once per counter when instrumentation ends. -//================================================================================================== -BOOL WINAPI PIXEndExperiment( PIXCOUNTERID id ); - - -#ifdef __cplusplus -}; -#endif - -//================================================================================================== -// eof: PIXPlugin.h -//================================================================================================== - +//================================================================================================== +// PIXPlugin.h +// +// Microsoft PIX Plugin Header +// +// Copyright (c) Microsoft Corporation, All rights reserved +//================================================================================================== + +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + + +//================================================================================================== +// PIX_PLUGIN_SYSTEM_VERSION - Indicates version of the plugin interface the plugin is built with. +//================================================================================================== +#define PIX_PLUGIN_SYSTEM_VERSION 0x101 + + +//================================================================================================== +// PIXCOUNTERID - A unique identifier for each PIX plugin counter. +//================================================================================================== +typedef int PIXCOUNTERID; + + +//================================================================================================== +// PIXCOUNTERDATATYPE - Indicates what type of data the counter produces. +//================================================================================================== +enum PIXCOUNTERDATATYPE +{ + PCDT_RESERVED, + PCDT_FLOAT, + PCDT_INT, + PCDT_INT64, + PCDT_STRING, +}; + + +//================================================================================================== +// PIXPLUGININFO - This structure is filled out by PIXGetPluginInfo and passed back to PIX. +//================================================================================================== +struct PIXPLUGININFO +{ + // Filled in by caller: + HINSTANCE hinst; + + // Filled in by PIXGetPluginInfo: + WCHAR* pstrPluginName; // Name of plugin + int iPluginVersion; // Version of this particular plugin + int iPluginSystemVersion; // Version of PIX's plugin system this plugin was designed for +}; + + +//================================================================================================== +// PIXCOUNTERINFO - This structure is filled out by PIXGetCounterInfo and passed back to PIX +// to allow PIX to determine information about the counters in the plugin. +//================================================================================================== +struct PIXCOUNTERINFO +{ + PIXCOUNTERID counterID; // Used to uniquely ID this counter + WCHAR* pstrName; // String name of the counter + PIXCOUNTERDATATYPE pcdtDataType; // Data type returned by this counter +}; + + +//================================================================================================== +// PIXGetPluginInfo - This returns basic information about this plugin to PIX. +//================================================================================================== +BOOL WINAPI PIXGetPluginInfo( PIXPLUGININFO* pPIXPluginInfo ); + + +//================================================================================================== +// PIXGetCounterInfo - This returns an array of PIXCOUNTERINFO structs to PIX. +// These PIXCOUNTERINFOs allow PIX to enumerate the counters contained +// in this plugin. +//================================================================================================== +BOOL WINAPI PIXGetCounterInfo( DWORD* pdwReturnCounters, PIXCOUNTERINFO** ppCounterInfoList ); + + +//================================================================================================== +// PIXGetCounterDesc - This is called by PIX to request a description of the indicated counter. +//================================================================================================== +BOOL WINAPI PIXGetCounterDesc( PIXCOUNTERID id, WCHAR** ppstrCounterDesc ); + + +//================================================================================================== +// PIXBeginExperiment - This called by PIX once per counter when instrumentation starts. +//================================================================================================== +BOOL WINAPI PIXBeginExperiment( PIXCOUNTERID id, const WCHAR* pstrApplication ); + + +//================================================================================================== +// PIXEndFrame - This is called by PIX once per counter at the end of each frame to gather the +// counter value for that frame. Note that the pointer to the return data must +// continue to point to valid counter data until the next call to PIXEndFrame (or +// PIXEndExperiment) for the same counter. So do not set *ppReturnData to the same +// pointer for multiple counters, or point to a local variable that will go out of +// scope. See the sample PIX plugin for an example of how to structure a plugin +// properly. +//================================================================================================== +BOOL WINAPI PIXEndFrame( PIXCOUNTERID id, UINT iFrame, DWORD* pdwReturnBytes, BYTE** ppReturnData ); + + +//================================================================================================== +// PIXEndExperiment - This is called by PIX once per counter when instrumentation ends. +//================================================================================================== +BOOL WINAPI PIXEndExperiment( PIXCOUNTERID id ); + + +#ifdef __cplusplus +}; +#endif + +//================================================================================================== +// eof: PIXPlugin.h +//================================================================================================== + diff --git a/src/dep/include/DXSDK/include/X3DAudio.h b/src/dep/include/DXSDK/include/X3DAudio.h index 9f95766..fa6f456 100644 --- a/src/dep/include/DXSDK/include/X3DAudio.h +++ b/src/dep/include/DXSDK/include/X3DAudio.h @@ -1,279 +1,279 @@ -/*-========================================================================-_ - | - X3DAUDIO - | - | Copyright (c) Microsoft Corporation. All rights reserved. | - |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| - |VERSION: 0.1 MODEL: Unmanaged User-mode | - |CONTRACT: N / A EXCEPT: No Exceptions | - |PARENT: N / A MINREQ: Win2000, Xenon | - |PROJECT: X3DAudio DIALECT: MS Visual C++ 7.0 | - |>------------------------------------------------------------------------<| - | DUTY: Cross-platform stand-alone 3D audio math library | - ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ - NOTES: - 1. Definition of terms: - LFE: Low Frequency Effect -- always omnidirectional. - LPF: Low Pass Filter, divided into two classifications: - Direct -- Applied to the direct signal path, - used for obstruction/occlusion effect. - Reverb -- Applied to the reverb signal path, - used for occlusion effect only. - - 2. Volume level is expressed as a linear amplitude scaler: - 1.0f represents no attenuation applied to the original signal, - 0.5f denotes an attenuation of 6dB, and 0.0f results in silence. - Amplification (volume > 1.0f) is also allowed, and is not clamped. - - 3. X3DAudio uses a left-handed Cartesian coordinate system with values - on the x-axis increasing from left to right, on the y-axis from - bottom to top, and on the z-axis from near to far. - Azimuths are measured clockwise from a given reference direction. - - Distance measurement is with respect to user-defined world units. - Applications may provide coordinates using any system of measure - as all non-normalized calculations are scale invariant, with such - operations natively occurring in the user-defined world unit space. - Metric constants are supplied only as a convenience. - Distance is calculated using the Euclidean norm formula. - - 4. Only real values are permissible with functions using 32-bit - float parameters -- NAN and infinite values are not accepted. - All computation occurs in 32-bit precision mode. */ - - -#ifndef __X3DAUDIO_H__ -#define __X3DAUDIO_H__ -//---------------------------------------------------// - #if defined(_XBOX) - #include - #endif - #include - - // speaker geometry configuration flags, specifies assignment of channels to speaker positions, defined as per WAVEFORMATEXTENSIBLE.dwChannelMask - #if !defined(SPEAKER_FRONT_LEFT) - #define SPEAKER_FRONT_LEFT 0x00000001 - #define SPEAKER_FRONT_RIGHT 0x00000002 - #define SPEAKER_FRONT_CENTER 0x00000004 - #define SPEAKER_LOW_FREQUENCY 0x00000008 - #define SPEAKER_BACK_LEFT 0x00000010 - #define SPEAKER_BACK_RIGHT 0x00000020 - #define SPEAKER_FRONT_LEFT_OF_CENTER 0x00000040 - #define SPEAKER_FRONT_RIGHT_OF_CENTER 0x00000080 - #define SPEAKER_BACK_CENTER 0x00000100 - #define SPEAKER_SIDE_LEFT 0x00000200 - #define SPEAKER_SIDE_RIGHT 0x00000400 - #define SPEAKER_TOP_CENTER 0x00000800 - #define SPEAKER_TOP_FRONT_LEFT 0x00001000 - #define SPEAKER_TOP_FRONT_CENTER 0x00002000 - #define SPEAKER_TOP_FRONT_RIGHT 0x00004000 - #define SPEAKER_TOP_BACK_LEFT 0x00008000 - #define SPEAKER_TOP_BACK_CENTER 0x00010000 - #define SPEAKER_TOP_BACK_RIGHT 0x00020000 - #endif - - // standard speaker geometry configurations, used with X3DAudioInitialize - #if !defined(SPEAKER_STEREO) && !defined(SPEAKER_5POINT1) - #define SPEAKER_STEREO (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT) - #define SPEAKER_5POINT1 (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT) - #endif - - // xenon speaker geometry configuration, used with X3DAudioInitialize - #if defined(_XBOX) - #define SPEAKER_XBOX SPEAKER_5POINT1 - #endif - - - #define X3DAUDIO_HANDLE_BYTESIZE 16 // size of instance handle in bytes - - // float math constants - #define X3DAUDIO_PI 3.141592654f - #define X3DAUDIO_2PI 6.283185307f - - // speed of sound in meters per second for dry air at approximately 20C, used with X3DAudioInitialize - #define X3DAUDIO_SPEED_OF_SOUND 343.5f - - // calculation control flags, used with X3DAudioCalculate - #define X3DAUDIO_CALCULATE_MATRIX 0x00000001 // enable matrix coefficient table calculation - #define X3DAUDIO_CALCULATE_DELAY 0x00000002 // enable delay time array calculation (stereo final mix only) - #define X3DAUDIO_CALCULATE_LPF_DIRECT 0x00000004 // enable LPF direct-path coefficient calculation - #define X3DAUDIO_CALCULATE_LPF_REVERB 0x00000008 // enable LPF reverb-path coefficient calculation - #define X3DAUDIO_CALCULATE_REVERB 0x00000010 // enable reverb send level calculation - #define X3DAUDIO_CALCULATE_DOPPLER 0x00000020 // enable doppler shift factor calculation - #define X3DAUDIO_CALCULATE_EMITTER_ANGLE 0x00000040 // enable emitter-to-listener interior angle calculation - - -//-------------------------------------------------------------// - // function storage-class attribute and calltype - #if defined(_XBOX) - #define X3DAUDIO_API_(type) EXTERN_C type STDAPICALLTYPE - #else - #if defined(X3DEXPORT) - #define X3DAUDIO_API_(type) EXTERN_C __declspec(dllexport) type STDAPICALLTYPE - #else - #define X3DAUDIO_API_(type) EXTERN_C __declspec(dllimport) type STDAPICALLTYPE - #endif - #endif - #define X3DAUDIO_IMP_(type) type STDMETHODCALLTYPE - - -//-----------------------------------------------------// - // primitive types - typedef INT_PTR NWORD; // natural machine word, bytesize platform specific - typedef UINT_PTR UNWORD; // unsigned natural machine word, bytesize platform specific - typedef float FLOAT32; // 32-bit IEEE float - typedef D3DVECTOR X3DAUDIO_VECTOR; // float 3D vector - - // instance handle to precalculated constants - typedef BYTE X3DAUDIO_HANDLE[X3DAUDIO_HANDLE_BYTESIZE]; - - - // Distance curve point: - // Defines a DSP setting at a given normalized distance. - typedef struct X3DAUDIO_DISTANCE_CURVE_POINT - { - FLOAT32 Distance; // normalized distance, must be within [0.0f, 1.0f] - FLOAT32 DSPSetting; // DSP control setting - } X3DAUDIO_DISTANCE_CURVE_POINT, *LPX3DAUDIO_DISTANCE_CURVE_POINT; - - // Distance curve: - // A piecewise curve made up of linear segments used to - // define DSP behaviour with respect to normalized distance. - // - // Note that curve point distances are normalized within [0.0f, 1.0f]. - // X3DAUDIO_EMITTER.CurveDistanceScaler must be used to scale the - // normalized distances to user-defined world units. - // For distances beyond CurveDistanceScaler * 1.0f, - // pPoints[PointCount-1].DSPSetting is used as the DSP setting. - // - // All distance curve spans must be such that: - // pPoints[k-1].DSPSetting + ((pPoints[k].DSPSetting-pPoints[k-1].DSPSetting) / (pPoints[k].Distance-pPoints[k-1].Distance)) * (pPoints[k].Distance-pPoints[k-1].Distance) != NAN or infinite values - // For all points in the distance curve where 1 <= k < PointCount. - typedef struct X3DAUDIO_DISTANCE_CURVE - { - X3DAUDIO_DISTANCE_CURVE_POINT* pPoints; // distance curve point array, must have at least PointCount elements with no duplicates and be sorted in ascending order with respect to Distance - UINT32 PointCount; // number of distance curve points, must be >= 2 as all distance curves must have at least two endpoints, defining DSP settings at 0.0f and 1.0f normalized distance - } X3DAUDIO_DISTANCE_CURVE, *LPX3DAUDIO_DISTANCE_CURVE; - - // Cone: - // Specifies directionality for a single-channel emitter by - // scaling DSP behaviour with respect to the emitter's front orientation. - // This is modeled using two sound cones: an inner cone and an outer cone. - // On/within the inner cone, DSP settings are scaled by the inner values. - // On/beyond the outer cone, DSP settings are scaled by the outer values. - // If on both the cones, DSP settings are scaled by the inner values only. - // Between the two cones, the scaler is linearly interpolated between the - // inner and outer values. Set both cone angles to 0 or X3DAUDIO_2PI for - // omnidirectionality using only the outer or inner values respectively. - typedef struct X3DAUDIO_CONE - { - FLOAT32 InnerAngle; // inner cone angle in radians, must be within [0.0f, X3DAUDIO_2PI] - FLOAT32 OuterAngle; // outer cone angle in radians, must be within [InnerAngle, X3DAUDIO_2PI] - - FLOAT32 InnerVolume; // volume level scaler on/within inner cone, used only for matrix calculations, must be within [0.0f, 2.0f] when used - FLOAT32 OuterVolume; // volume level scaler on/beyond outer cone, used only for matrix calculations, must be within [0.0f, 2.0f] when used - FLOAT32 InnerLPF; // LPF (both direct and reverb paths) coefficient scaler on/within inner cone, used only for LPF (both direct and reverb paths) calculations, must be within [0.0f, 1.0f] when used - FLOAT32 OuterLPF; // LPF (both direct and reverb paths) coefficient scaler on/beyond outer cone, used only for LPF (both direct and reverb paths) calculations, must be within [0.0f, 1.0f] when used - FLOAT32 InnerReverb; // reverb send level scaler on/within inner cone, used only for reverb calculations, must be within [0.0f, 2.0f] when used - FLOAT32 OuterReverb; // reverb send level scaler on/beyond outer cone, used only for reverb calculations, must be within [0.0f, 2.0f] when used - } X3DAUDIO_CONE, *LPX3DAUDIO_CONE; - - - // Listener: - // Defines a point of 3D audio reception. - typedef struct X3DAUDIO_LISTENER - { - X3DAUDIO_VECTOR OrientFront; // orientation of front direction, used only for matrix and delay calculations, must be orthonormal with OrientTop when used - X3DAUDIO_VECTOR OrientTop; // orientation of top direction, used only for matrix and delay calculations, must be orthonormal with OrientFront when used - - X3DAUDIO_VECTOR Position; // position in user-defined world units, does not affect Velocity - X3DAUDIO_VECTOR Velocity; // velocity vector in user-defined world units/second, used only for doppler calculations, does not affect Position - } X3DAUDIO_LISTENER, *LPX3DAUDIO_LISTENER; - - // Emitter: - // Defines a 3D audio source, divided into two classifications: - // - // Single-point -- For use with single-channel sounds. - // Positioned at the emitter base, i.e. the channel radius - // and azimuth are ignored if the number of channels == 1. - // - // May be omnidirectional or directional using a cone. - // The cone originates from the emitter base position, - // and is directed by the emitter's front orientation. - // - // Multi-point -- For use with multi-channel sounds. - // Each non-LFE channel is positioned using an - // azimuth along the channel radius with respect to the - // front orientation vector in the plane orthogonal to the - // top orientation vector. An azimuth of X3DAUDIO_2PI - // specifies a channel is a LFE. Such channels are - // positioned at the emitter base and are calculated - // with respect to pLFECurve only, never pVolumeCurve. - // - // Multi-point emitters are always omnidirectional, - // i.e. the cone is ignored if the number of channels > 1. - // - // Note that many properties are shared among all channel points, - // locking certain behaviour with respect to the emitter base position. - // For example, doppler shift is always calculated with respect to the - // emitter base position and so is constant for all its channel points. - // Distance curve calculations are also with respect to the emitter base - // position, with the curves being calculated independently of each other. - // For instance, volume and LFE calculations do not affect one another. - typedef struct X3DAUDIO_EMITTER - { - X3DAUDIO_CONE* pCone; // sound cone, used only with single-channel emitters for matrix, LPF (both direct and reverb paths), and reverb calculations, NULL specifies omnidirectionality - X3DAUDIO_VECTOR OrientFront; // orientation of front direction, used only for emitter angle calculations or with multi-channel emitters for matrix calculations or single-channel emitters with cones for matrix, LPF (both direct and reverb paths), and reverb calculations, must be normalized when used - X3DAUDIO_VECTOR OrientTop; // orientation of top direction, used only with multi-channel emitters for matrix calculations, must be orthonormal with OrientFront when used - - X3DAUDIO_VECTOR Position; // position in user-defined world units, does not affect Velocity - X3DAUDIO_VECTOR Velocity; // velocity vector in user-defined world units/second, used only for doppler calculations, does not affect Position - - UINT32 ChannelCount; // number of sound channels, must be > 0 - FLOAT32 ChannelRadius; // channel radius, used only with multi-channel emitters for matrix calculations, must be >= 0.0f when used - FLOAT32* pChannelAzimuths; // channel azimuth array, used only with multi-channel emitters for matrix calculations, contains positions of each channel expressed in radians along the channel radius with respect to the front orientation vector in the plane orthogonal to the top orientation vector, or X3DAUDIO_2PI to specify a LFE channel, must have at least ChannelCount elements, all within [0.0f, X3DAUDIO_2PI] when used - - X3DAUDIO_DISTANCE_CURVE* pVolumeCurve; // volume level distance curve, used only for matrix calculations, NULL specifies the default curve: [0.0f,1.0f], [1.0f,0.0f] - X3DAUDIO_DISTANCE_CURVE* pLFECurve; // LFE level distance curve, used only for matrix calculations, NULL specifies the default curve: [0.0f,1.0f], [1.0f,0.0f] - X3DAUDIO_DISTANCE_CURVE* pLPFDirectCurve; // LPF direct-path coefficient distance curve, used only for LPF direct-path calculations, NULL specifies the default curve: [0.0f,0.0f], [1.0f,0.25f] - X3DAUDIO_DISTANCE_CURVE* pLPFReverbCurve; // LPF reverb-path coefficient distance curve, used only for LPF reverb-path calculations, NULL specifies the default curve: [0.0f,0.25f], [1.0f,0.25f] - X3DAUDIO_DISTANCE_CURVE* pReverbCurve; // reverb send level distance curve, used only for reverb calculations, NULL specifies the default curve: [0.0f,1.0f], [1.0f,0.0f] - - FLOAT32 CurveDistanceScaler; // curve distance scaler, used to scale normalized distance curves to user-defined world units and/or exaggerate their effect, does not affect any other calculations, must be within [FLT_MIN, FLT_MAX] when used - FLOAT32 DopplerScaler; // doppler shift scaler, used to exaggerate doppler shift effect, does not affect any other calculations, must be within [0.0f, FLT_MAX] when used - } X3DAUDIO_EMITTER, *LPX3DAUDIO_EMITTER; - - - // DSP settings: - // Receives results from a call to X3DAudioCalculate() to be sent - // to the low-level audio rendering API for 3D signal processing. - // - // The user is responsible for allocating the matrix coefficient table, - // delay time array, and initializing the channel counts when used. - typedef struct X3DAUDIO_DSP_SETTINGS - { - FLOAT32* pMatrixCoefficients; // [in] matrix coefficient table, receives an array representing the volume level of each source channel present in each destination channel with the source channels being the column index and the destination channels being the row index of the table, must have at least SrcChannelCount*DstChannelCount elements - FLOAT32* pDelayTimes; // [in] delay time array, receives delays for each destination channel in milliseconds, must have at least DstChannelCount elements (stereo final mix only) - UINT32 SrcChannelCount; // [in] number of source channels, must equal number of channels on respective emitter - UINT32 DstChannelCount; // [in] number of destination channels, must equal number of channels on the final mix - - FLOAT32 LPFDirectCoefficient; // [out] LPF direct-path coefficient - FLOAT32 LPFReverbCoefficient; // [out] LPF reverb-path coefficient - FLOAT32 ReverbLevel; // [out] reverb send level - FLOAT32 DopplerFactor; // [out] doppler shift factor, scales resampler ratio for doppler shift effect, where the effective frequency = DopplerFactor * original frequency - FLOAT32 EmitterToListenerAngle; // [out] emitter-to-listener interior angle, expressed in radians with respect to the emitter's front orientation - - FLOAT32 EmitterToListenerDistance; // [out] distance in user-defined world units from the emitter base to listener position, always calculated - FLOAT32 EmitterVelocityComponent; // [out] component of emitter velocity vector projected onto emitter->listener vector in user-defined world units/second, calculated only for doppler - FLOAT32 ListenerVelocityComponent; // [out] component of listener velocity vector projected onto emitter->listener vector in user-defined world units/second, calculated only for doppler - } X3DAUDIO_DSP_SETTINGS, *LPX3DAUDIO_DSP_SETTINGS; - - -//-------------------------------------------------------// - // sets all global 3D audio constants - X3DAUDIO_API_(void) X3DAudioInitialize (UINT32 SpeakerChannelMask, FLOAT32 SpeedOfSound, X3DAUDIO_HANDLE Instance); - - // calculates DSP settings with respect to 3D parameters - X3DAUDIO_API_(void) X3DAudioCalculate (const X3DAUDIO_HANDLE Instance, const X3DAUDIO_LISTENER* pListener, const X3DAUDIO_EMITTER* pEmitter, UINT32 Flags, X3DAUDIO_DSP_SETTINGS* pDSPSettings); - - -#endif // __X3DAUDIO_H__ -//---------------------------------<-EOF->----------------------------------// +/*-========================================================================-_ + | - X3DAUDIO - | + | Copyright (c) Microsoft Corporation. All rights reserved. | + |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| + |VERSION: 0.1 MODEL: Unmanaged User-mode | + |CONTRACT: N / A EXCEPT: No Exceptions | + |PARENT: N / A MINREQ: Win2000, Xenon | + |PROJECT: X3DAudio DIALECT: MS Visual C++ 7.0 | + |>------------------------------------------------------------------------<| + | DUTY: Cross-platform stand-alone 3D audio math library | + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ + NOTES: + 1. Definition of terms: + LFE: Low Frequency Effect -- always omnidirectional. + LPF: Low Pass Filter, divided into two classifications: + Direct -- Applied to the direct signal path, + used for obstruction/occlusion effect. + Reverb -- Applied to the reverb signal path, + used for occlusion effect only. + + 2. Volume level is expressed as a linear amplitude scaler: + 1.0f represents no attenuation applied to the original signal, + 0.5f denotes an attenuation of 6dB, and 0.0f results in silence. + Amplification (volume > 1.0f) is also allowed, and is not clamped. + + 3. X3DAudio uses a left-handed Cartesian coordinate system with values + on the x-axis increasing from left to right, on the y-axis from + bottom to top, and on the z-axis from near to far. + Azimuths are measured clockwise from a given reference direction. + + Distance measurement is with respect to user-defined world units. + Applications may provide coordinates using any system of measure + as all non-normalized calculations are scale invariant, with such + operations natively occurring in the user-defined world unit space. + Metric constants are supplied only as a convenience. + Distance is calculated using the Euclidean norm formula. + + 4. Only real values are permissible with functions using 32-bit + float parameters -- NAN and infinite values are not accepted. + All computation occurs in 32-bit precision mode. */ + + +#ifndef __X3DAUDIO_H__ +#define __X3DAUDIO_H__ +//---------------------------------------------------// + #if defined(_XBOX) + #include + #endif + #include + + // speaker geometry configuration flags, specifies assignment of channels to speaker positions, defined as per WAVEFORMATEXTENSIBLE.dwChannelMask + #if !defined(SPEAKER_FRONT_LEFT) + #define SPEAKER_FRONT_LEFT 0x00000001 + #define SPEAKER_FRONT_RIGHT 0x00000002 + #define SPEAKER_FRONT_CENTER 0x00000004 + #define SPEAKER_LOW_FREQUENCY 0x00000008 + #define SPEAKER_BACK_LEFT 0x00000010 + #define SPEAKER_BACK_RIGHT 0x00000020 + #define SPEAKER_FRONT_LEFT_OF_CENTER 0x00000040 + #define SPEAKER_FRONT_RIGHT_OF_CENTER 0x00000080 + #define SPEAKER_BACK_CENTER 0x00000100 + #define SPEAKER_SIDE_LEFT 0x00000200 + #define SPEAKER_SIDE_RIGHT 0x00000400 + #define SPEAKER_TOP_CENTER 0x00000800 + #define SPEAKER_TOP_FRONT_LEFT 0x00001000 + #define SPEAKER_TOP_FRONT_CENTER 0x00002000 + #define SPEAKER_TOP_FRONT_RIGHT 0x00004000 + #define SPEAKER_TOP_BACK_LEFT 0x00008000 + #define SPEAKER_TOP_BACK_CENTER 0x00010000 + #define SPEAKER_TOP_BACK_RIGHT 0x00020000 + #endif + + // standard speaker geometry configurations, used with X3DAudioInitialize + #if !defined(SPEAKER_STEREO) && !defined(SPEAKER_5POINT1) + #define SPEAKER_STEREO (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT) + #define SPEAKER_5POINT1 (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT) + #endif + + // xenon speaker geometry configuration, used with X3DAudioInitialize + #if defined(_XBOX) + #define SPEAKER_XBOX SPEAKER_5POINT1 + #endif + + + #define X3DAUDIO_HANDLE_BYTESIZE 16 // size of instance handle in bytes + + // float math constants + #define X3DAUDIO_PI 3.141592654f + #define X3DAUDIO_2PI 6.283185307f + + // speed of sound in meters per second for dry air at approximately 20C, used with X3DAudioInitialize + #define X3DAUDIO_SPEED_OF_SOUND 343.5f + + // calculation control flags, used with X3DAudioCalculate + #define X3DAUDIO_CALCULATE_MATRIX 0x00000001 // enable matrix coefficient table calculation + #define X3DAUDIO_CALCULATE_DELAY 0x00000002 // enable delay time array calculation (stereo final mix only) + #define X3DAUDIO_CALCULATE_LPF_DIRECT 0x00000004 // enable LPF direct-path coefficient calculation + #define X3DAUDIO_CALCULATE_LPF_REVERB 0x00000008 // enable LPF reverb-path coefficient calculation + #define X3DAUDIO_CALCULATE_REVERB 0x00000010 // enable reverb send level calculation + #define X3DAUDIO_CALCULATE_DOPPLER 0x00000020 // enable doppler shift factor calculation + #define X3DAUDIO_CALCULATE_EMITTER_ANGLE 0x00000040 // enable emitter-to-listener interior angle calculation + + +//-------------------------------------------------------------// + // function storage-class attribute and calltype + #if defined(_XBOX) + #define X3DAUDIO_API_(type) EXTERN_C type STDAPICALLTYPE + #else + #if defined(X3DEXPORT) + #define X3DAUDIO_API_(type) EXTERN_C __declspec(dllexport) type STDAPICALLTYPE + #else + #define X3DAUDIO_API_(type) EXTERN_C __declspec(dllimport) type STDAPICALLTYPE + #endif + #endif + #define X3DAUDIO_IMP_(type) type STDMETHODCALLTYPE + + +//-----------------------------------------------------// + // primitive types + typedef INT_PTR NWORD; // natural machine word, bytesize platform specific + typedef UINT_PTR UNWORD; // unsigned natural machine word, bytesize platform specific + typedef float FLOAT32; // 32-bit IEEE float + typedef D3DVECTOR X3DAUDIO_VECTOR; // float 3D vector + + // instance handle to precalculated constants + typedef BYTE X3DAUDIO_HANDLE[X3DAUDIO_HANDLE_BYTESIZE]; + + + // Distance curve point: + // Defines a DSP setting at a given normalized distance. + typedef struct X3DAUDIO_DISTANCE_CURVE_POINT + { + FLOAT32 Distance; // normalized distance, must be within [0.0f, 1.0f] + FLOAT32 DSPSetting; // DSP control setting + } X3DAUDIO_DISTANCE_CURVE_POINT, *LPX3DAUDIO_DISTANCE_CURVE_POINT; + + // Distance curve: + // A piecewise curve made up of linear segments used to + // define DSP behaviour with respect to normalized distance. + // + // Note that curve point distances are normalized within [0.0f, 1.0f]. + // X3DAUDIO_EMITTER.CurveDistanceScaler must be used to scale the + // normalized distances to user-defined world units. + // For distances beyond CurveDistanceScaler * 1.0f, + // pPoints[PointCount-1].DSPSetting is used as the DSP setting. + // + // All distance curve spans must be such that: + // pPoints[k-1].DSPSetting + ((pPoints[k].DSPSetting-pPoints[k-1].DSPSetting) / (pPoints[k].Distance-pPoints[k-1].Distance)) * (pPoints[k].Distance-pPoints[k-1].Distance) != NAN or infinite values + // For all points in the distance curve where 1 <= k < PointCount. + typedef struct X3DAUDIO_DISTANCE_CURVE + { + X3DAUDIO_DISTANCE_CURVE_POINT* pPoints; // distance curve point array, must have at least PointCount elements with no duplicates and be sorted in ascending order with respect to Distance + UINT32 PointCount; // number of distance curve points, must be >= 2 as all distance curves must have at least two endpoints, defining DSP settings at 0.0f and 1.0f normalized distance + } X3DAUDIO_DISTANCE_CURVE, *LPX3DAUDIO_DISTANCE_CURVE; + + // Cone: + // Specifies directionality for a single-channel emitter by + // scaling DSP behaviour with respect to the emitter's front orientation. + // This is modeled using two sound cones: an inner cone and an outer cone. + // On/within the inner cone, DSP settings are scaled by the inner values. + // On/beyond the outer cone, DSP settings are scaled by the outer values. + // If on both the cones, DSP settings are scaled by the inner values only. + // Between the two cones, the scaler is linearly interpolated between the + // inner and outer values. Set both cone angles to 0 or X3DAUDIO_2PI for + // omnidirectionality using only the outer or inner values respectively. + typedef struct X3DAUDIO_CONE + { + FLOAT32 InnerAngle; // inner cone angle in radians, must be within [0.0f, X3DAUDIO_2PI] + FLOAT32 OuterAngle; // outer cone angle in radians, must be within [InnerAngle, X3DAUDIO_2PI] + + FLOAT32 InnerVolume; // volume level scaler on/within inner cone, used only for matrix calculations, must be within [0.0f, 2.0f] when used + FLOAT32 OuterVolume; // volume level scaler on/beyond outer cone, used only for matrix calculations, must be within [0.0f, 2.0f] when used + FLOAT32 InnerLPF; // LPF (both direct and reverb paths) coefficient scaler on/within inner cone, used only for LPF (both direct and reverb paths) calculations, must be within [0.0f, 1.0f] when used + FLOAT32 OuterLPF; // LPF (both direct and reverb paths) coefficient scaler on/beyond outer cone, used only for LPF (both direct and reverb paths) calculations, must be within [0.0f, 1.0f] when used + FLOAT32 InnerReverb; // reverb send level scaler on/within inner cone, used only for reverb calculations, must be within [0.0f, 2.0f] when used + FLOAT32 OuterReverb; // reverb send level scaler on/beyond outer cone, used only for reverb calculations, must be within [0.0f, 2.0f] when used + } X3DAUDIO_CONE, *LPX3DAUDIO_CONE; + + + // Listener: + // Defines a point of 3D audio reception. + typedef struct X3DAUDIO_LISTENER + { + X3DAUDIO_VECTOR OrientFront; // orientation of front direction, used only for matrix and delay calculations, must be orthonormal with OrientTop when used + X3DAUDIO_VECTOR OrientTop; // orientation of top direction, used only for matrix and delay calculations, must be orthonormal with OrientFront when used + + X3DAUDIO_VECTOR Position; // position in user-defined world units, does not affect Velocity + X3DAUDIO_VECTOR Velocity; // velocity vector in user-defined world units/second, used only for doppler calculations, does not affect Position + } X3DAUDIO_LISTENER, *LPX3DAUDIO_LISTENER; + + // Emitter: + // Defines a 3D audio source, divided into two classifications: + // + // Single-point -- For use with single-channel sounds. + // Positioned at the emitter base, i.e. the channel radius + // and azimuth are ignored if the number of channels == 1. + // + // May be omnidirectional or directional using a cone. + // The cone originates from the emitter base position, + // and is directed by the emitter's front orientation. + // + // Multi-point -- For use with multi-channel sounds. + // Each non-LFE channel is positioned using an + // azimuth along the channel radius with respect to the + // front orientation vector in the plane orthogonal to the + // top orientation vector. An azimuth of X3DAUDIO_2PI + // specifies a channel is a LFE. Such channels are + // positioned at the emitter base and are calculated + // with respect to pLFECurve only, never pVolumeCurve. + // + // Multi-point emitters are always omnidirectional, + // i.e. the cone is ignored if the number of channels > 1. + // + // Note that many properties are shared among all channel points, + // locking certain behaviour with respect to the emitter base position. + // For example, doppler shift is always calculated with respect to the + // emitter base position and so is constant for all its channel points. + // Distance curve calculations are also with respect to the emitter base + // position, with the curves being calculated independently of each other. + // For instance, volume and LFE calculations do not affect one another. + typedef struct X3DAUDIO_EMITTER + { + X3DAUDIO_CONE* pCone; // sound cone, used only with single-channel emitters for matrix, LPF (both direct and reverb paths), and reverb calculations, NULL specifies omnidirectionality + X3DAUDIO_VECTOR OrientFront; // orientation of front direction, used only for emitter angle calculations or with multi-channel emitters for matrix calculations or single-channel emitters with cones for matrix, LPF (both direct and reverb paths), and reverb calculations, must be normalized when used + X3DAUDIO_VECTOR OrientTop; // orientation of top direction, used only with multi-channel emitters for matrix calculations, must be orthonormal with OrientFront when used + + X3DAUDIO_VECTOR Position; // position in user-defined world units, does not affect Velocity + X3DAUDIO_VECTOR Velocity; // velocity vector in user-defined world units/second, used only for doppler calculations, does not affect Position + + UINT32 ChannelCount; // number of sound channels, must be > 0 + FLOAT32 ChannelRadius; // channel radius, used only with multi-channel emitters for matrix calculations, must be >= 0.0f when used + FLOAT32* pChannelAzimuths; // channel azimuth array, used only with multi-channel emitters for matrix calculations, contains positions of each channel expressed in radians along the channel radius with respect to the front orientation vector in the plane orthogonal to the top orientation vector, or X3DAUDIO_2PI to specify a LFE channel, must have at least ChannelCount elements, all within [0.0f, X3DAUDIO_2PI] when used + + X3DAUDIO_DISTANCE_CURVE* pVolumeCurve; // volume level distance curve, used only for matrix calculations, NULL specifies the default curve: [0.0f,1.0f], [1.0f,0.0f] + X3DAUDIO_DISTANCE_CURVE* pLFECurve; // LFE level distance curve, used only for matrix calculations, NULL specifies the default curve: [0.0f,1.0f], [1.0f,0.0f] + X3DAUDIO_DISTANCE_CURVE* pLPFDirectCurve; // LPF direct-path coefficient distance curve, used only for LPF direct-path calculations, NULL specifies the default curve: [0.0f,0.0f], [1.0f,0.25f] + X3DAUDIO_DISTANCE_CURVE* pLPFReverbCurve; // LPF reverb-path coefficient distance curve, used only for LPF reverb-path calculations, NULL specifies the default curve: [0.0f,0.25f], [1.0f,0.25f] + X3DAUDIO_DISTANCE_CURVE* pReverbCurve; // reverb send level distance curve, used only for reverb calculations, NULL specifies the default curve: [0.0f,1.0f], [1.0f,0.0f] + + FLOAT32 CurveDistanceScaler; // curve distance scaler, used to scale normalized distance curves to user-defined world units and/or exaggerate their effect, does not affect any other calculations, must be within [FLT_MIN, FLT_MAX] when used + FLOAT32 DopplerScaler; // doppler shift scaler, used to exaggerate doppler shift effect, does not affect any other calculations, must be within [0.0f, FLT_MAX] when used + } X3DAUDIO_EMITTER, *LPX3DAUDIO_EMITTER; + + + // DSP settings: + // Receives results from a call to X3DAudioCalculate() to be sent + // to the low-level audio rendering API for 3D signal processing. + // + // The user is responsible for allocating the matrix coefficient table, + // delay time array, and initializing the channel counts when used. + typedef struct X3DAUDIO_DSP_SETTINGS + { + FLOAT32* pMatrixCoefficients; // [in] matrix coefficient table, receives an array representing the volume level of each source channel present in each destination channel with the source channels being the column index and the destination channels being the row index of the table, must have at least SrcChannelCount*DstChannelCount elements + FLOAT32* pDelayTimes; // [in] delay time array, receives delays for each destination channel in milliseconds, must have at least DstChannelCount elements (stereo final mix only) + UINT32 SrcChannelCount; // [in] number of source channels, must equal number of channels on respective emitter + UINT32 DstChannelCount; // [in] number of destination channels, must equal number of channels on the final mix + + FLOAT32 LPFDirectCoefficient; // [out] LPF direct-path coefficient + FLOAT32 LPFReverbCoefficient; // [out] LPF reverb-path coefficient + FLOAT32 ReverbLevel; // [out] reverb send level + FLOAT32 DopplerFactor; // [out] doppler shift factor, scales resampler ratio for doppler shift effect, where the effective frequency = DopplerFactor * original frequency + FLOAT32 EmitterToListenerAngle; // [out] emitter-to-listener interior angle, expressed in radians with respect to the emitter's front orientation + + FLOAT32 EmitterToListenerDistance; // [out] distance in user-defined world units from the emitter base to listener position, always calculated + FLOAT32 EmitterVelocityComponent; // [out] component of emitter velocity vector projected onto emitter->listener vector in user-defined world units/second, calculated only for doppler + FLOAT32 ListenerVelocityComponent; // [out] component of listener velocity vector projected onto emitter->listener vector in user-defined world units/second, calculated only for doppler + } X3DAUDIO_DSP_SETTINGS, *LPX3DAUDIO_DSP_SETTINGS; + + +//-------------------------------------------------------// + // sets all global 3D audio constants + X3DAUDIO_API_(void) X3DAudioInitialize (UINT32 SpeakerChannelMask, FLOAT32 SpeedOfSound, X3DAUDIO_HANDLE Instance); + + // calculates DSP settings with respect to 3D parameters + X3DAUDIO_API_(void) X3DAudioCalculate (const X3DAUDIO_HANDLE Instance, const X3DAUDIO_LISTENER* pListener, const X3DAUDIO_EMITTER* pEmitter, UINT32 Flags, X3DAUDIO_DSP_SETTINGS* pDSPSettings); + + +#endif // __X3DAUDIO_H__ +//---------------------------------<-EOF->----------------------------------// diff --git a/src/dep/include/DXSDK/include/XInput.h b/src/dep/include/DXSDK/include/XInput.h index 2eeca4e..7cb52e1 100644 --- a/src/dep/include/DXSDK/include/XInput.h +++ b/src/dep/include/DXSDK/include/XInput.h @@ -1,156 +1,156 @@ -/*************************************************************************** -* * -* XInput.h -- This module defines XBOX controller APIs * -* and constansts for the Windows platform. * -* * -* Copyright (c) Microsoft Corp. All rights reserved. * -* * -***************************************************************************/ -#ifndef _XINPUT_H_ -#define _XINPUT_H_ - -#include - -// Current name of the DLL shipped in the same SDK as this header. -// The name reflects the current version -#define XINPUT_DLL_A "xinput1_1.dll" -#define XINPUT_DLL_W L"xinput1_1.dll" -#ifdef UNICODE - #define XINPUT_DLL XINPUT_DLL_W -#else - #define XINPUT_DLL XINPUT_DLL_A -#endif - -// -// Device types available in XINPUT_CAPABILITIES -// -#define XINPUT_DEVTYPE_GAMEPAD 0x01 - -// -// Device subtypes available in XINPUT_CAPABILITIES -// -#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01 -#define XINPUT_DEVSUBTYPE_WHEEL 0x02 -#define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03 -#define XINPUT_DEVSUBTYPE_FLIGHT_SICK 0x04 -#define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05 - -// -// Flags for XINPUT_CAPABILITIES -// -#define XINPUT_CAPS_VOICE_SUPPORTED 0x0004 - -// -// Constants for gamepad buttons -// -#define XINPUT_GAMEPAD_DPAD_UP 0x0001 -#define XINPUT_GAMEPAD_DPAD_DOWN 0x0002 -#define XINPUT_GAMEPAD_DPAD_LEFT 0x0004 -#define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008 -#define XINPUT_GAMEPAD_START 0x0010 -#define XINPUT_GAMEPAD_BACK 0x0020 -#define XINPUT_GAMEPAD_LEFT_THUMB 0x0040 -#define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080 -#define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100 -#define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200 -#define XINPUT_GAMEPAD_A 0x1000 -#define XINPUT_GAMEPAD_B 0x2000 -#define XINPUT_GAMEPAD_X 0x4000 -#define XINPUT_GAMEPAD_Y 0x8000 - -// -// Gamepad thresholds -// -#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849 -#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689 -#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30 - -// -// Flags to pass to XInputGetCapabilities -// -#define XINPUT_FLAG_GAMEPAD 0x00000001 - - -// -// Structures used by XInput APIs -// -typedef struct _XINPUT_GAMEPAD -{ - WORD wButtons; - BYTE bLeftTrigger; - BYTE bRightTrigger; - SHORT sThumbLX; - SHORT sThumbLY; - SHORT sThumbRX; - SHORT sThumbRY; -} XINPUT_GAMEPAD, *PXINPUT_GAMEPAD; - -typedef struct _XINPUT_STATE -{ - DWORD dwPacketNumber; - XINPUT_GAMEPAD Gamepad; -} XINPUT_STATE, *PXINPUT_STATE; - -typedef struct _XINPUT_VIBRATION -{ - WORD wLeftMotorSpeed; - WORD wRightMotorSpeed; -} XINPUT_VIBRATION, *PXINPUT_VIBRATION; - -typedef struct _XINPUT_CAPABILITIES -{ - BYTE Type; - BYTE SubType; - WORD Flags; - XINPUT_GAMEPAD Gamepad; - XINPUT_VIBRATION Vibration; -} XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES; - - -// -// XInput APIs -// -#ifdef __cplusplus -extern "C" { -#endif - -DWORD WINAPI XInputGetState -( - DWORD dwUserIndex, // [in] Index of the gamer associated with the device - XINPUT_STATE* pState // [out] Receives the current state -); - -DWORD WINAPI XInputSetState -( - DWORD dwUserIndex, // [in] Index of the gamer associated with the device - XINPUT_VIBRATION* pVibration // [in, out] The vibration information to send to the controller -); - -DWORD WINAPI XInputGetCapabilities -( - DWORD dwUserIndex, // [in] Index of the gamer associated with the device - DWORD dwFlags, // [in] Input flags that identify the device type - XINPUT_CAPABILITIES* pCapabilities // [out] Receives the capabilities -); - -void WINAPI XInputEnable -( - BOOL enable // [in] Indicates weather xinput is enabled or disabled. -); - - - - -DWORD WINAPI XInputGetDSoundAudioDeviceGuids -( - DWORD dwUserIndex, // [in] Index of the gamer associated with the device - GUID* pDSoundRenderGuid, // [out] DSound device ID for render - GUID* pDSoundCaptureGuid // [out] DSound device ID for capture -); - -#ifdef __cplusplus -} -#endif - -#endif //_XINPUT_H_ - +/*************************************************************************** +* * +* XInput.h -- This module defines XBOX controller APIs * +* and constansts for the Windows platform. * +* * +* Copyright (c) Microsoft Corp. All rights reserved. * +* * +***************************************************************************/ +#ifndef _XINPUT_H_ +#define _XINPUT_H_ + +#include + +// Current name of the DLL shipped in the same SDK as this header. +// The name reflects the current version +#define XINPUT_DLL_A "xinput1_1.dll" +#define XINPUT_DLL_W L"xinput1_1.dll" +#ifdef UNICODE + #define XINPUT_DLL XINPUT_DLL_W +#else + #define XINPUT_DLL XINPUT_DLL_A +#endif + +// +// Device types available in XINPUT_CAPABILITIES +// +#define XINPUT_DEVTYPE_GAMEPAD 0x01 + +// +// Device subtypes available in XINPUT_CAPABILITIES +// +#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01 +#define XINPUT_DEVSUBTYPE_WHEEL 0x02 +#define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03 +#define XINPUT_DEVSUBTYPE_FLIGHT_SICK 0x04 +#define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05 + +// +// Flags for XINPUT_CAPABILITIES +// +#define XINPUT_CAPS_VOICE_SUPPORTED 0x0004 + +// +// Constants for gamepad buttons +// +#define XINPUT_GAMEPAD_DPAD_UP 0x0001 +#define XINPUT_GAMEPAD_DPAD_DOWN 0x0002 +#define XINPUT_GAMEPAD_DPAD_LEFT 0x0004 +#define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008 +#define XINPUT_GAMEPAD_START 0x0010 +#define XINPUT_GAMEPAD_BACK 0x0020 +#define XINPUT_GAMEPAD_LEFT_THUMB 0x0040 +#define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080 +#define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100 +#define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200 +#define XINPUT_GAMEPAD_A 0x1000 +#define XINPUT_GAMEPAD_B 0x2000 +#define XINPUT_GAMEPAD_X 0x4000 +#define XINPUT_GAMEPAD_Y 0x8000 + +// +// Gamepad thresholds +// +#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849 +#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689 +#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30 + +// +// Flags to pass to XInputGetCapabilities +// +#define XINPUT_FLAG_GAMEPAD 0x00000001 + + +// +// Structures used by XInput APIs +// +typedef struct _XINPUT_GAMEPAD +{ + WORD wButtons; + BYTE bLeftTrigger; + BYTE bRightTrigger; + SHORT sThumbLX; + SHORT sThumbLY; + SHORT sThumbRX; + SHORT sThumbRY; +} XINPUT_GAMEPAD, *PXINPUT_GAMEPAD; + +typedef struct _XINPUT_STATE +{ + DWORD dwPacketNumber; + XINPUT_GAMEPAD Gamepad; +} XINPUT_STATE, *PXINPUT_STATE; + +typedef struct _XINPUT_VIBRATION +{ + WORD wLeftMotorSpeed; + WORD wRightMotorSpeed; +} XINPUT_VIBRATION, *PXINPUT_VIBRATION; + +typedef struct _XINPUT_CAPABILITIES +{ + BYTE Type; + BYTE SubType; + WORD Flags; + XINPUT_GAMEPAD Gamepad; + XINPUT_VIBRATION Vibration; +} XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES; + + +// +// XInput APIs +// +#ifdef __cplusplus +extern "C" { +#endif + +DWORD WINAPI XInputGetState +( + DWORD dwUserIndex, // [in] Index of the gamer associated with the device + XINPUT_STATE* pState // [out] Receives the current state +); + +DWORD WINAPI XInputSetState +( + DWORD dwUserIndex, // [in] Index of the gamer associated with the device + XINPUT_VIBRATION* pVibration // [in, out] The vibration information to send to the controller +); + +DWORD WINAPI XInputGetCapabilities +( + DWORD dwUserIndex, // [in] Index of the gamer associated with the device + DWORD dwFlags, // [in] Input flags that identify the device type + XINPUT_CAPABILITIES* pCapabilities // [out] Receives the capabilities +); + +void WINAPI XInputEnable +( + BOOL enable // [in] Indicates weather xinput is enabled or disabled. +); + + + + +DWORD WINAPI XInputGetDSoundAudioDeviceGuids +( + DWORD dwUserIndex, // [in] Index of the gamer associated with the device + GUID* pDSoundRenderGuid, // [out] DSound device ID for render + GUID* pDSoundCaptureGuid // [out] DSound device ID for capture +); + +#ifdef __cplusplus +} +#endif + +#endif //_XINPUT_H_ + diff --git a/src/dep/include/DXSDK/include/comdecl.h b/src/dep/include/DXSDK/include/comdecl.h index 7d8eff5..6b6bf25 100644 --- a/src/dep/include/DXSDK/include/comdecl.h +++ b/src/dep/include/DXSDK/include/comdecl.h @@ -1,51 +1,51 @@ -// comdecl.h: Macros to facilitate COM interface and GUID declarations. -// Copyright (c) Microsoft Corporation. All rights reserved. - -#ifndef _COMDECL_H_ -#define _COMDECL_H_ - -#include // For standard COM interface macros - -// The DEFINE_CLSID() and DEFINE_IID() macros defined below allow COM GUIDs to -// be declared and defined in such a way that clients can obtain the GUIDs using -// either the __uuidof() extension or the old-style CLSID_Foo / IID_IFoo names. -// If using the latter approach, the client can also choose whether to get the -// GUID definitions by defining the INITGUID preprocessor constant or by linking -// to a GUID library. This works in either C or C++. - -#ifdef __cplusplus - - #define DECLSPEC_UUID_WRAPPER(x) __declspec(uuid(#x)) - #ifdef INITGUID - - #define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - class DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) className; \ - EXTERN_C const GUID DECLSPEC_SELECTANY CLSID_##className = __uuidof(className) - - #define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - interface DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) interfaceName; \ - EXTERN_C const GUID DECLSPEC_SELECTANY IID_##interfaceName = __uuidof(interfaceName) - - #else // INITGUID - - #define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - class DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) className; \ - EXTERN_C const GUID CLSID_##className - - #define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - interface DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) interfaceName; \ - EXTERN_C const GUID IID_##interfaceName - - #endif // INITGUID - -#else // __cplusplus - - #define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - DEFINE_GUID(CLSID_##className, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) - - #define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - DEFINE_GUID(IID_##interfaceName, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) - -#endif // __cplusplus - -#endif // #ifndef _COMDECL_H_ +// comdecl.h: Macros to facilitate COM interface and GUID declarations. +// Copyright (c) Microsoft Corporation. All rights reserved. + +#ifndef _COMDECL_H_ +#define _COMDECL_H_ + +#include // For standard COM interface macros + +// The DEFINE_CLSID() and DEFINE_IID() macros defined below allow COM GUIDs to +// be declared and defined in such a way that clients can obtain the GUIDs using +// either the __uuidof() extension or the old-style CLSID_Foo / IID_IFoo names. +// If using the latter approach, the client can also choose whether to get the +// GUID definitions by defining the INITGUID preprocessor constant or by linking +// to a GUID library. This works in either C or C++. + +#ifdef __cplusplus + + #define DECLSPEC_UUID_WRAPPER(x) __declspec(uuid(#x)) + #ifdef INITGUID + + #define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + class DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) className; \ + EXTERN_C const GUID DECLSPEC_SELECTANY CLSID_##className = __uuidof(className) + + #define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + interface DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) interfaceName; \ + EXTERN_C const GUID DECLSPEC_SELECTANY IID_##interfaceName = __uuidof(interfaceName) + + #else // INITGUID + + #define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + class DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) className; \ + EXTERN_C const GUID CLSID_##className + + #define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + interface DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) interfaceName; \ + EXTERN_C const GUID IID_##interfaceName + + #endif // INITGUID + +#else // __cplusplus + + #define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + DEFINE_GUID(CLSID_##className, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) + + #define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + DEFINE_GUID(IID_##interfaceName, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) + +#endif // __cplusplus + +#endif // #ifndef _COMDECL_H_ diff --git a/src/dep/include/DXSDK/include/d3d.h b/src/dep/include/DXSDK/include/d3d.h index 1cb8a96..eea7dff 100644 --- a/src/dep/include/DXSDK/include/d3d.h +++ b/src/dep/include/DXSDK/include/d3d.h @@ -1,1688 +1,1688 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: d3d.h - * Content: Direct3D include file - * - ****************************************************************************/ - -#ifndef _D3D_H_ -#define _D3D_H_ - -#ifndef DIRECT3D_VERSION -#define DIRECT3D_VERSION 0x0700 -#endif - -// include this file content only if compiling for <=DX7 interfaces -#if(DIRECT3D_VERSION < 0x0800) - - -#include - -#define COM_NO_WINDOWS_H -#include - -#define D3DAPI WINAPI - -/* - * Interface IID's - */ -#if defined( _WIN32 ) && !defined( _NO_COM) -DEFINE_GUID( IID_IDirect3D, 0x3BBA0080,0x2421,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56 ); -#if(DIRECT3D_VERSION >= 0x0500) -DEFINE_GUID( IID_IDirect3D2, 0x6aae1ec1,0x662a,0x11d0,0x88,0x9d,0x00,0xaa,0x00,0xbb,0xb7,0x6a); -#endif /* DIRECT3D_VERSION >= 0x0500 */ -#if(DIRECT3D_VERSION >= 0x0600) -DEFINE_GUID( IID_IDirect3D3, 0xbb223240,0xe72b,0x11d0,0xa9,0xb4,0x00,0xaa,0x00,0xc0,0x99,0x3e); -#endif /* DIRECT3D_VERSION >= 0x0600 */ -#if(DIRECT3D_VERSION >= 0x0700) -DEFINE_GUID( IID_IDirect3D7, 0xf5049e77,0x4861,0x11d2,0xa4,0x7,0x0,0xa0,0xc9,0x6,0x29,0xa8); -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -#if(DIRECT3D_VERSION >= 0x0500) -DEFINE_GUID( IID_IDirect3DRampDevice, 0xF2086B20,0x259F,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56 ); -DEFINE_GUID( IID_IDirect3DRGBDevice, 0xA4665C60,0x2673,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56 ); -DEFINE_GUID( IID_IDirect3DHALDevice, 0x84E63dE0,0x46AA,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E ); -DEFINE_GUID( IID_IDirect3DMMXDevice, 0x881949a1,0xd6f3,0x11d0,0x89,0xab,0x00,0xa0,0xc9,0x05,0x41,0x29 ); -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if(DIRECT3D_VERSION >= 0x0600) -DEFINE_GUID( IID_IDirect3DRefDevice, 0x50936643, 0x13e9, 0x11d1, 0x89, 0xaa, 0x0, 0xa0, 0xc9, 0x5, 0x41, 0x29); -DEFINE_GUID( IID_IDirect3DNullDevice, 0x8767df22, 0xbacc, 0x11d1, 0x89, 0x69, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); -#endif /* DIRECT3D_VERSION >= 0x0600 */ -#if(DIRECT3D_VERSION >= 0x0700) -DEFINE_GUID( IID_IDirect3DTnLHalDevice, 0xf5049e78, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -/* - * Internal Guid to distinguish requested MMX from MMX being used as an RGB rasterizer - */ - -DEFINE_GUID( IID_IDirect3DDevice, 0x64108800,0x957d,0X11d0,0x89,0xab,0x00,0xa0,0xc9,0x05,0x41,0x29 ); -#if(DIRECT3D_VERSION >= 0x0500) -DEFINE_GUID( IID_IDirect3DDevice2, 0x93281501, 0x8cf8, 0x11d0, 0x89, 0xab, 0x0, 0xa0, 0xc9, 0x5, 0x41, 0x29); -#endif /* DIRECT3D_VERSION >= 0x0500 */ -#if(DIRECT3D_VERSION >= 0x0600) -DEFINE_GUID( IID_IDirect3DDevice3, 0xb0ab3b60, 0x33d7, 0x11d1, 0xa9, 0x81, 0x0, 0xc0, 0x4f, 0xd7, 0xb1, 0x74); -#endif /* DIRECT3D_VERSION >= 0x0600 */ -#if(DIRECT3D_VERSION >= 0x0700) -DEFINE_GUID( IID_IDirect3DDevice7, 0xf5049e79, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -DEFINE_GUID( IID_IDirect3DTexture, 0x2CDCD9E0,0x25A0,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56 ); -#if(DIRECT3D_VERSION >= 0x0500) -DEFINE_GUID( IID_IDirect3DTexture2, 0x93281502, 0x8cf8, 0x11d0, 0x89, 0xab, 0x0, 0xa0, 0xc9, 0x5, 0x41, 0x29); -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -DEFINE_GUID( IID_IDirect3DLight, 0x4417C142,0x33AD,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E ); - -DEFINE_GUID( IID_IDirect3DMaterial, 0x4417C144,0x33AD,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E ); -#if(DIRECT3D_VERSION >= 0x0500) -DEFINE_GUID( IID_IDirect3DMaterial2, 0x93281503, 0x8cf8, 0x11d0, 0x89, 0xab, 0x0, 0xa0, 0xc9, 0x5, 0x41, 0x29); -#endif /* DIRECT3D_VERSION >= 0x0500 */ -#if(DIRECT3D_VERSION >= 0x0600) -DEFINE_GUID( IID_IDirect3DMaterial3, 0xca9c46f4, 0xd3c5, 0x11d1, 0xb7, 0x5a, 0x0, 0x60, 0x8, 0x52, 0xb3, 0x12); -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -DEFINE_GUID( IID_IDirect3DExecuteBuffer,0x4417C145,0x33AD,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E ); -DEFINE_GUID( IID_IDirect3DViewport, 0x4417C146,0x33AD,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E ); -#if(DIRECT3D_VERSION >= 0x0500) -DEFINE_GUID( IID_IDirect3DViewport2, 0x93281500, 0x8cf8, 0x11d0, 0x89, 0xab, 0x0, 0xa0, 0xc9, 0x5, 0x41, 0x29); -#endif /* DIRECT3D_VERSION >= 0x0500 */ -#if(DIRECT3D_VERSION >= 0x0600) -DEFINE_GUID( IID_IDirect3DViewport3, 0xb0ab3b61, 0x33d7, 0x11d1, 0xa9, 0x81, 0x0, 0xc0, 0x4f, 0xd7, 0xb1, 0x74); -#endif /* DIRECT3D_VERSION >= 0x0600 */ -#if(DIRECT3D_VERSION >= 0x0600) -DEFINE_GUID( IID_IDirect3DVertexBuffer, 0x7a503555, 0x4a83, 0x11d1, 0xa5, 0xdb, 0x0, 0xa0, 0xc9, 0x3, 0x67, 0xf8); -#endif /* DIRECT3D_VERSION >= 0x0600 */ -#if(DIRECT3D_VERSION >= 0x0700) -DEFINE_GUID( IID_IDirect3DVertexBuffer7, 0xf5049e7d, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); -#endif /* DIRECT3D_VERSION >= 0x0700 */ -#endif - -#ifdef __cplusplus -struct IDirect3D; -struct IDirect3DDevice; -struct IDirect3DLight; -struct IDirect3DMaterial; -struct IDirect3DExecuteBuffer; -struct IDirect3DTexture; -struct IDirect3DViewport; -typedef struct IDirect3D *LPDIRECT3D; -typedef struct IDirect3DDevice *LPDIRECT3DDEVICE; -typedef struct IDirect3DExecuteBuffer *LPDIRECT3DEXECUTEBUFFER; -typedef struct IDirect3DLight *LPDIRECT3DLIGHT; -typedef struct IDirect3DMaterial *LPDIRECT3DMATERIAL; -typedef struct IDirect3DTexture *LPDIRECT3DTEXTURE; -typedef struct IDirect3DViewport *LPDIRECT3DVIEWPORT; - -#if(DIRECT3D_VERSION >= 0x0500) -struct IDirect3D2; -struct IDirect3DDevice2; -struct IDirect3DMaterial2; -struct IDirect3DTexture2; -struct IDirect3DViewport2; -typedef struct IDirect3D2 *LPDIRECT3D2; -typedef struct IDirect3DDevice2 *LPDIRECT3DDEVICE2; -typedef struct IDirect3DMaterial2 *LPDIRECT3DMATERIAL2; -typedef struct IDirect3DTexture2 *LPDIRECT3DTEXTURE2; -typedef struct IDirect3DViewport2 *LPDIRECT3DVIEWPORT2; -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if(DIRECT3D_VERSION >= 0x0600) -struct IDirect3D3; -struct IDirect3DDevice3; -struct IDirect3DMaterial3; -struct IDirect3DViewport3; -struct IDirect3DVertexBuffer; -typedef struct IDirect3D3 *LPDIRECT3D3; -typedef struct IDirect3DDevice3 *LPDIRECT3DDEVICE3; -typedef struct IDirect3DMaterial3 *LPDIRECT3DMATERIAL3; -typedef struct IDirect3DViewport3 *LPDIRECT3DVIEWPORT3; -typedef struct IDirect3DVertexBuffer *LPDIRECT3DVERTEXBUFFER; -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -#if(DIRECT3D_VERSION >= 0x0700) -struct IDirect3D7; -struct IDirect3DDevice7; -struct IDirect3DVertexBuffer7; -typedef struct IDirect3D7 *LPDIRECT3D7; -typedef struct IDirect3DDevice7 *LPDIRECT3DDEVICE7; -typedef struct IDirect3DVertexBuffer7 *LPDIRECT3DVERTEXBUFFER7; -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -#else - -typedef struct IDirect3D *LPDIRECT3D; -typedef struct IDirect3DDevice *LPDIRECT3DDEVICE; -typedef struct IDirect3DExecuteBuffer *LPDIRECT3DEXECUTEBUFFER; -typedef struct IDirect3DLight *LPDIRECT3DLIGHT; -typedef struct IDirect3DMaterial *LPDIRECT3DMATERIAL; -typedef struct IDirect3DTexture *LPDIRECT3DTEXTURE; -typedef struct IDirect3DViewport *LPDIRECT3DVIEWPORT; - -#if(DIRECT3D_VERSION >= 0x0500) -typedef struct IDirect3D2 *LPDIRECT3D2; -typedef struct IDirect3DDevice2 *LPDIRECT3DDEVICE2; -typedef struct IDirect3DMaterial2 *LPDIRECT3DMATERIAL2; -typedef struct IDirect3DTexture2 *LPDIRECT3DTEXTURE2; -typedef struct IDirect3DViewport2 *LPDIRECT3DVIEWPORT2; -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if(DIRECT3D_VERSION >= 0x0600) -typedef struct IDirect3D3 *LPDIRECT3D3; -typedef struct IDirect3DDevice3 *LPDIRECT3DDEVICE3; -typedef struct IDirect3DMaterial3 *LPDIRECT3DMATERIAL3; -typedef struct IDirect3DViewport3 *LPDIRECT3DVIEWPORT3; -typedef struct IDirect3DVertexBuffer *LPDIRECT3DVERTEXBUFFER; -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -#if(DIRECT3D_VERSION >= 0x0700) -typedef struct IDirect3D7 *LPDIRECT3D7; -typedef struct IDirect3DDevice7 *LPDIRECT3DDEVICE7; -typedef struct IDirect3DVertexBuffer7 *LPDIRECT3DVERTEXBUFFER7; -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -#endif - -#include "d3dtypes.h" -#include "d3dcaps.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Direct3D interfaces - */ -#undef INTERFACE -#define INTERFACE IDirect3D - -DECLARE_INTERFACE_(IDirect3D, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3D methods ***/ - STDMETHOD(Initialize)(THIS_ REFCLSID) PURE; - STDMETHOD(EnumDevices)(THIS_ LPD3DENUMDEVICESCALLBACK,LPVOID) PURE; - STDMETHOD(CreateLight)(THIS_ LPDIRECT3DLIGHT*,IUnknown*) PURE; - STDMETHOD(CreateMaterial)(THIS_ LPDIRECT3DMATERIAL*,IUnknown*) PURE; - STDMETHOD(CreateViewport)(THIS_ LPDIRECT3DVIEWPORT*,IUnknown*) PURE; - STDMETHOD(FindDevice)(THIS_ LPD3DFINDDEVICESEARCH,LPD3DFINDDEVICERESULT) PURE; -}; - -typedef struct IDirect3D *LPDIRECT3D; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3D_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3D_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3D_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3D_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#define IDirect3D_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevices(p,a,b) -#define IDirect3D_CreateLight(p,a,b) (p)->lpVtbl->CreateLight(p,a,b) -#define IDirect3D_CreateMaterial(p,a,b) (p)->lpVtbl->CreateMaterial(p,a,b) -#define IDirect3D_CreateViewport(p,a,b) (p)->lpVtbl->CreateViewport(p,a,b) -#define IDirect3D_FindDevice(p,a,b) (p)->lpVtbl->FindDevice(p,a,b) -#else -#define IDirect3D_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3D_AddRef(p) (p)->AddRef() -#define IDirect3D_Release(p) (p)->Release() -#define IDirect3D_Initialize(p,a) (p)->Initialize(a) -#define IDirect3D_EnumDevices(p,a,b) (p)->EnumDevices(a,b) -#define IDirect3D_CreateLight(p,a,b) (p)->CreateLight(a,b) -#define IDirect3D_CreateMaterial(p,a,b) (p)->CreateMaterial(a,b) -#define IDirect3D_CreateViewport(p,a,b) (p)->CreateViewport(a,b) -#define IDirect3D_FindDevice(p,a,b) (p)->FindDevice(a,b) -#endif - -#if(DIRECT3D_VERSION >= 0x0500) -#undef INTERFACE -#define INTERFACE IDirect3D2 - -DECLARE_INTERFACE_(IDirect3D2, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3D2 methods ***/ - STDMETHOD(EnumDevices)(THIS_ LPD3DENUMDEVICESCALLBACK,LPVOID) PURE; - STDMETHOD(CreateLight)(THIS_ LPDIRECT3DLIGHT*,IUnknown*) PURE; - STDMETHOD(CreateMaterial)(THIS_ LPDIRECT3DMATERIAL2*,IUnknown*) PURE; - STDMETHOD(CreateViewport)(THIS_ LPDIRECT3DVIEWPORT2*,IUnknown*) PURE; - STDMETHOD(FindDevice)(THIS_ LPD3DFINDDEVICESEARCH,LPD3DFINDDEVICERESULT) PURE; - STDMETHOD(CreateDevice)(THIS_ REFCLSID,LPDIRECTDRAWSURFACE,LPDIRECT3DDEVICE2*) PURE; -}; - -typedef struct IDirect3D2 *LPDIRECT3D2; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3D2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3D2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3D2_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3D2_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevices(p,a,b) -#define IDirect3D2_CreateLight(p,a,b) (p)->lpVtbl->CreateLight(p,a,b) -#define IDirect3D2_CreateMaterial(p,a,b) (p)->lpVtbl->CreateMaterial(p,a,b) -#define IDirect3D2_CreateViewport(p,a,b) (p)->lpVtbl->CreateViewport(p,a,b) -#define IDirect3D2_FindDevice(p,a,b) (p)->lpVtbl->FindDevice(p,a,b) -#define IDirect3D2_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#else -#define IDirect3D2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3D2_AddRef(p) (p)->AddRef() -#define IDirect3D2_Release(p) (p)->Release() -#define IDirect3D2_EnumDevices(p,a,b) (p)->EnumDevices(a,b) -#define IDirect3D2_CreateLight(p,a,b) (p)->CreateLight(a,b) -#define IDirect3D2_CreateMaterial(p,a,b) (p)->CreateMaterial(a,b) -#define IDirect3D2_CreateViewport(p,a,b) (p)->CreateViewport(a,b) -#define IDirect3D2_FindDevice(p,a,b) (p)->FindDevice(a,b) -#define IDirect3D2_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#endif -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if(DIRECT3D_VERSION >= 0x0600) -#undef INTERFACE -#define INTERFACE IDirect3D3 - -DECLARE_INTERFACE_(IDirect3D3, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3D3 methods ***/ - STDMETHOD(EnumDevices)(THIS_ LPD3DENUMDEVICESCALLBACK,LPVOID) PURE; - STDMETHOD(CreateLight)(THIS_ LPDIRECT3DLIGHT*,LPUNKNOWN) PURE; - STDMETHOD(CreateMaterial)(THIS_ LPDIRECT3DMATERIAL3*,LPUNKNOWN) PURE; - STDMETHOD(CreateViewport)(THIS_ LPDIRECT3DVIEWPORT3*,LPUNKNOWN) PURE; - STDMETHOD(FindDevice)(THIS_ LPD3DFINDDEVICESEARCH,LPD3DFINDDEVICERESULT) PURE; - STDMETHOD(CreateDevice)(THIS_ REFCLSID,LPDIRECTDRAWSURFACE4,LPDIRECT3DDEVICE3*,LPUNKNOWN) PURE; - STDMETHOD(CreateVertexBuffer)(THIS_ LPD3DVERTEXBUFFERDESC,LPDIRECT3DVERTEXBUFFER*,DWORD,LPUNKNOWN) PURE; - STDMETHOD(EnumZBufferFormats)(THIS_ REFCLSID,LPD3DENUMPIXELFORMATSCALLBACK,LPVOID) PURE; - STDMETHOD(EvictManagedTextures)(THIS) PURE; -}; - -typedef struct IDirect3D3 *LPDIRECT3D3; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3D3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3D3_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3D3_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3D3_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevices(p,a,b) -#define IDirect3D3_CreateLight(p,a,b) (p)->lpVtbl->CreateLight(p,a,b) -#define IDirect3D3_CreateMaterial(p,a,b) (p)->lpVtbl->CreateMaterial(p,a,b) -#define IDirect3D3_CreateViewport(p,a,b) (p)->lpVtbl->CreateViewport(p,a,b) -#define IDirect3D3_FindDevice(p,a,b) (p)->lpVtbl->FindDevice(p,a,b) -#define IDirect3D3_CreateDevice(p,a,b,c,d) (p)->lpVtbl->CreateDevice(p,a,b,c,d) -#define IDirect3D3_CreateVertexBuffer(p,a,b,c,d) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d) -#define IDirect3D3_EnumZBufferFormats(p,a,b,c) (p)->lpVtbl->EnumZBufferFormats(p,a,b,c) -#define IDirect3D3_EvictManagedTextures(p) (p)->lpVtbl->EvictManagedTextures(p) -#else -#define IDirect3D3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3D3_AddRef(p) (p)->AddRef() -#define IDirect3D3_Release(p) (p)->Release() -#define IDirect3D3_EnumDevices(p,a,b) (p)->EnumDevices(a,b) -#define IDirect3D3_CreateLight(p,a,b) (p)->CreateLight(a,b) -#define IDirect3D3_CreateMaterial(p,a,b) (p)->CreateMaterial(a,b) -#define IDirect3D3_CreateViewport(p,a,b) (p)->CreateViewport(a,b) -#define IDirect3D3_FindDevice(p,a,b) (p)->FindDevice(a,b) -#define IDirect3D3_CreateDevice(p,a,b,c,d) (p)->CreateDevice(a,b,c,d) -#define IDirect3D3_CreateVertexBuffer(p,a,b,c,d) (p)->CreateVertexBuffer(a,b,c,d) -#define IDirect3D3_EnumZBufferFormats(p,a,b,c) (p)->EnumZBufferFormats(a,b,c) -#define IDirect3D3_EvictManagedTextures(p) (p)->EvictManagedTextures() -#endif -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -#if(DIRECT3D_VERSION >= 0x0700) -#undef INTERFACE -#define INTERFACE IDirect3D7 - -DECLARE_INTERFACE_(IDirect3D7, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3D7 methods ***/ - STDMETHOD(EnumDevices)(THIS_ LPD3DENUMDEVICESCALLBACK7,LPVOID) PURE; - STDMETHOD(CreateDevice)(THIS_ REFCLSID,LPDIRECTDRAWSURFACE7,LPDIRECT3DDEVICE7*) PURE; - STDMETHOD(CreateVertexBuffer)(THIS_ LPD3DVERTEXBUFFERDESC,LPDIRECT3DVERTEXBUFFER7*,DWORD) PURE; - STDMETHOD(EnumZBufferFormats)(THIS_ REFCLSID,LPD3DENUMPIXELFORMATSCALLBACK,LPVOID) PURE; - STDMETHOD(EvictManagedTextures)(THIS) PURE; -}; - -typedef struct IDirect3D7 *LPDIRECT3D7; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3D7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3D7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3D7_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3D7_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevices(p,a,b) -#define IDirect3D7_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirect3D7_CreateVertexBuffer(p,a,b,c) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c) -#define IDirect3D7_EnumZBufferFormats(p,a,b,c) (p)->lpVtbl->EnumZBufferFormats(p,a,b,c) -#define IDirect3D7_EvictManagedTextures(p) (p)->lpVtbl->EvictManagedTextures(p) -#else -#define IDirect3D7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3D7_AddRef(p) (p)->AddRef() -#define IDirect3D7_Release(p) (p)->Release() -#define IDirect3D7_EnumDevices(p,a,b) (p)->EnumDevices(a,b) -#define IDirect3D7_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirect3D7_CreateVertexBuffer(p,a,b,c) (p)->CreateVertexBuffer(a,b,c) -#define IDirect3D7_EnumZBufferFormats(p,a,b,c) (p)->EnumZBufferFormats(a,b,c) -#define IDirect3D7_EvictManagedTextures(p) (p)->EvictManagedTextures() -#endif -#endif /* DIRECT3D_VERSION >= 0x0700 */ -/* - * Direct3D Device interfaces - */ -#undef INTERFACE -#define INTERFACE IDirect3DDevice - -DECLARE_INTERFACE_(IDirect3DDevice, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DDevice methods ***/ - STDMETHOD(Initialize)(THIS_ LPDIRECT3D,LPGUID,LPD3DDEVICEDESC) PURE; - STDMETHOD(GetCaps)(THIS_ LPD3DDEVICEDESC,LPD3DDEVICEDESC) PURE; - STDMETHOD(SwapTextureHandles)(THIS_ LPDIRECT3DTEXTURE,LPDIRECT3DTEXTURE) PURE; - STDMETHOD(CreateExecuteBuffer)(THIS_ LPD3DEXECUTEBUFFERDESC,LPDIRECT3DEXECUTEBUFFER*,IUnknown*) PURE; - STDMETHOD(GetStats)(THIS_ LPD3DSTATS) PURE; - STDMETHOD(Execute)(THIS_ LPDIRECT3DEXECUTEBUFFER,LPDIRECT3DVIEWPORT,DWORD) PURE; - STDMETHOD(AddViewport)(THIS_ LPDIRECT3DVIEWPORT) PURE; - STDMETHOD(DeleteViewport)(THIS_ LPDIRECT3DVIEWPORT) PURE; - STDMETHOD(NextViewport)(THIS_ LPDIRECT3DVIEWPORT,LPDIRECT3DVIEWPORT*,DWORD) PURE; - STDMETHOD(Pick)(THIS_ LPDIRECT3DEXECUTEBUFFER,LPDIRECT3DVIEWPORT,DWORD,LPD3DRECT) PURE; - STDMETHOD(GetPickRecords)(THIS_ LPDWORD,LPD3DPICKRECORD) PURE; - STDMETHOD(EnumTextureFormats)(THIS_ LPD3DENUMTEXTUREFORMATSCALLBACK,LPVOID) PURE; - STDMETHOD(CreateMatrix)(THIS_ LPD3DMATRIXHANDLE) PURE; - STDMETHOD(SetMatrix)(THIS_ D3DMATRIXHANDLE,const LPD3DMATRIX) PURE; - STDMETHOD(GetMatrix)(THIS_ D3DMATRIXHANDLE,LPD3DMATRIX) PURE; - STDMETHOD(DeleteMatrix)(THIS_ D3DMATRIXHANDLE) PURE; - STDMETHOD(BeginScene)(THIS) PURE; - STDMETHOD(EndScene)(THIS) PURE; - STDMETHOD(GetDirect3D)(THIS_ LPDIRECT3D*) PURE; -}; - -typedef struct IDirect3DDevice *LPDIRECT3DDEVICE; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DDevice_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DDevice_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DDevice_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirect3DDevice_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) -#define IDirect3DDevice_SwapTextureHandles(p,a,b) (p)->lpVtbl->SwapTextureHandles(p,a,b) -#define IDirect3DDevice_CreateExecuteBuffer(p,a,b,c) (p)->lpVtbl->CreateExecuteBuffer(p,a,b,c) -#define IDirect3DDevice_GetStats(p,a) (p)->lpVtbl->GetStats(p,a) -#define IDirect3DDevice_Execute(p,a,b,c) (p)->lpVtbl->Execute(p,a,b,c) -#define IDirect3DDevice_AddViewport(p,a) (p)->lpVtbl->AddViewport(p,a) -#define IDirect3DDevice_DeleteViewport(p,a) (p)->lpVtbl->DeleteViewport(p,a) -#define IDirect3DDevice_NextViewport(p,a,b,c) (p)->lpVtbl->NextViewport(p,a,b,c) -#define IDirect3DDevice_Pick(p,a,b,c,d) (p)->lpVtbl->Pick(p,a,b,c,d) -#define IDirect3DDevice_GetPickRecords(p,a,b) (p)->lpVtbl->GetPickRecords(p,a,b) -#define IDirect3DDevice_EnumTextureFormats(p,a,b) (p)->lpVtbl->EnumTextureFormats(p,a,b) -#define IDirect3DDevice_CreateMatrix(p,a) (p)->lpVtbl->CreateMatrix(p,a) -#define IDirect3DDevice_SetMatrix(p,a,b) (p)->lpVtbl->SetMatrix(p,a,b) -#define IDirect3DDevice_GetMatrix(p,a,b) (p)->lpVtbl->GetMatrix(p,a,b) -#define IDirect3DDevice_DeleteMatrix(p,a) (p)->lpVtbl->DeleteMatrix(p,a) -#define IDirect3DDevice_BeginScene(p) (p)->lpVtbl->BeginScene(p) -#define IDirect3DDevice_EndScene(p) (p)->lpVtbl->EndScene(p) -#define IDirect3DDevice_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) -#else -#define IDirect3DDevice_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DDevice_AddRef(p) (p)->AddRef() -#define IDirect3DDevice_Release(p) (p)->Release() -#define IDirect3DDevice_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirect3DDevice_GetCaps(p,a,b) (p)->GetCaps(a,b) -#define IDirect3DDevice_SwapTextureHandles(p,a,b) (p)->SwapTextureHandles(a,b) -#define IDirect3DDevice_CreateExecuteBuffer(p,a,b,c) (p)->CreateExecuteBuffer(a,b,c) -#define IDirect3DDevice_GetStats(p,a) (p)->GetStats(a) -#define IDirect3DDevice_Execute(p,a,b,c) (p)->Execute(a,b,c) -#define IDirect3DDevice_AddViewport(p,a) (p)->AddViewport(a) -#define IDirect3DDevice_DeleteViewport(p,a) (p)->DeleteViewport(a) -#define IDirect3DDevice_NextViewport(p,a,b,c) (p)->NextViewport(a,b,c) -#define IDirect3DDevice_Pick(p,a,b,c,d) (p)->Pick(a,b,c,d) -#define IDirect3DDevice_GetPickRecords(p,a,b) (p)->GetPickRecords(a,b) -#define IDirect3DDevice_EnumTextureFormats(p,a,b) (p)->EnumTextureFormats(a,b) -#define IDirect3DDevice_CreateMatrix(p,a) (p)->CreateMatrix(a) -#define IDirect3DDevice_SetMatrix(p,a,b) (p)->SetMatrix(a,b) -#define IDirect3DDevice_GetMatrix(p,a,b) (p)->GetMatrix(a,b) -#define IDirect3DDevice_DeleteMatrix(p,a) (p)->DeleteMatrix(a) -#define IDirect3DDevice_BeginScene(p) (p)->BeginScene() -#define IDirect3DDevice_EndScene(p) (p)->EndScene() -#define IDirect3DDevice_GetDirect3D(p,a) (p)->GetDirect3D(a) -#endif - -#if(DIRECT3D_VERSION >= 0x0500) -#undef INTERFACE -#define INTERFACE IDirect3DDevice2 - -DECLARE_INTERFACE_(IDirect3DDevice2, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DDevice2 methods ***/ - STDMETHOD(GetCaps)(THIS_ LPD3DDEVICEDESC,LPD3DDEVICEDESC) PURE; - STDMETHOD(SwapTextureHandles)(THIS_ LPDIRECT3DTEXTURE2,LPDIRECT3DTEXTURE2) PURE; - STDMETHOD(GetStats)(THIS_ LPD3DSTATS) PURE; - STDMETHOD(AddViewport)(THIS_ LPDIRECT3DVIEWPORT2) PURE; - STDMETHOD(DeleteViewport)(THIS_ LPDIRECT3DVIEWPORT2) PURE; - STDMETHOD(NextViewport)(THIS_ LPDIRECT3DVIEWPORT2,LPDIRECT3DVIEWPORT2*,DWORD) PURE; - STDMETHOD(EnumTextureFormats)(THIS_ LPD3DENUMTEXTUREFORMATSCALLBACK,LPVOID) PURE; - STDMETHOD(BeginScene)(THIS) PURE; - STDMETHOD(EndScene)(THIS) PURE; - STDMETHOD(GetDirect3D)(THIS_ LPDIRECT3D2*) PURE; - STDMETHOD(SetCurrentViewport)(THIS_ LPDIRECT3DVIEWPORT2) PURE; - STDMETHOD(GetCurrentViewport)(THIS_ LPDIRECT3DVIEWPORT2 *) PURE; - STDMETHOD(SetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE,DWORD) PURE; - STDMETHOD(GetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE *) PURE; - STDMETHOD(Begin)(THIS_ D3DPRIMITIVETYPE,D3DVERTEXTYPE,DWORD) PURE; - STDMETHOD(BeginIndexed)(THIS_ D3DPRIMITIVETYPE,D3DVERTEXTYPE,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(Vertex)(THIS_ LPVOID) PURE; - STDMETHOD(Index)(THIS_ WORD) PURE; - STDMETHOD(End)(THIS_ DWORD) PURE; - STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE,LPDWORD) PURE; - STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE,DWORD) PURE; - STDMETHOD(GetLightState)(THIS_ D3DLIGHTSTATETYPE,LPDWORD) PURE; - STDMETHOD(SetLightState)(THIS_ D3DLIGHTSTATETYPE,DWORD) PURE; - STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; - STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; - STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; - STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE,D3DVERTEXTYPE,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,D3DVERTEXTYPE,LPVOID,DWORD,LPWORD,DWORD,DWORD) PURE; - STDMETHOD(SetClipStatus)(THIS_ LPD3DCLIPSTATUS) PURE; - STDMETHOD(GetClipStatus)(THIS_ LPD3DCLIPSTATUS) PURE; -}; - -typedef struct IDirect3DDevice2 *LPDIRECT3DDEVICE2; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DDevice2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DDevice2_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DDevice2_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) -#define IDirect3DDevice2_SwapTextureHandles(p,a,b) (p)->lpVtbl->SwapTextureHandles(p,a,b) -#define IDirect3DDevice2_GetStats(p,a) (p)->lpVtbl->GetStats(p,a) -#define IDirect3DDevice2_AddViewport(p,a) (p)->lpVtbl->AddViewport(p,a) -#define IDirect3DDevice2_DeleteViewport(p,a) (p)->lpVtbl->DeleteViewport(p,a) -#define IDirect3DDevice2_NextViewport(p,a,b,c) (p)->lpVtbl->NextViewport(p,a,b,c) -#define IDirect3DDevice2_EnumTextureFormats(p,a,b) (p)->lpVtbl->EnumTextureFormats(p,a,b) -#define IDirect3DDevice2_BeginScene(p) (p)->lpVtbl->BeginScene(p) -#define IDirect3DDevice2_EndScene(p) (p)->lpVtbl->EndScene(p) -#define IDirect3DDevice2_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) -#define IDirect3DDevice2_SetCurrentViewport(p,a) (p)->lpVtbl->SetCurrentViewport(p,a) -#define IDirect3DDevice2_GetCurrentViewport(p,a) (p)->lpVtbl->GetCurrentViewport(p,a) -#define IDirect3DDevice2_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) -#define IDirect3DDevice2_GetRenderTarget(p,a) (p)->lpVtbl->GetRenderTarget(p,a) -#define IDirect3DDevice2_Begin(p,a,b,c) (p)->lpVtbl->Begin(p,a,b,c) -#define IDirect3DDevice2_BeginIndexed(p,a,b,c,d,e) (p)->lpVtbl->BeginIndexed(p,a,b,c,d,e) -#define IDirect3DDevice2_Vertex(p,a) (p)->lpVtbl->Vertex(p,a) -#define IDirect3DDevice2_Index(p,a) (p)->lpVtbl->Index(p,a) -#define IDirect3DDevice2_End(p,a) (p)->lpVtbl->End(p,a) -#define IDirect3DDevice2_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) -#define IDirect3DDevice2_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) -#define IDirect3DDevice2_GetLightState(p,a,b) (p)->lpVtbl->GetLightState(p,a,b) -#define IDirect3DDevice2_SetLightState(p,a,b) (p)->lpVtbl->SetLightState(p,a,b) -#define IDirect3DDevice2_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) -#define IDirect3DDevice2_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) -#define IDirect3DDevice2_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) -#define IDirect3DDevice2_DrawPrimitive(p,a,b,c,d,e) (p)->lpVtbl->DrawPrimitive(p,a,b,c,d,e) -#define IDirect3DDevice2_DrawIndexedPrimitive(p,a,b,c,d,e,f,g) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e,f,g) -#define IDirect3DDevice2_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) -#define IDirect3DDevice2_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) -#else -#define IDirect3DDevice2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DDevice2_AddRef(p) (p)->AddRef() -#define IDirect3DDevice2_Release(p) (p)->Release() -#define IDirect3DDevice2_GetCaps(p,a,b) (p)->GetCaps(a,b) -#define IDirect3DDevice2_SwapTextureHandles(p,a,b) (p)->SwapTextureHandles(a,b) -#define IDirect3DDevice2_GetStats(p,a) (p)->GetStats(a) -#define IDirect3DDevice2_AddViewport(p,a) (p)->AddViewport(a) -#define IDirect3DDevice2_DeleteViewport(p,a) (p)->DeleteViewport(a) -#define IDirect3DDevice2_NextViewport(p,a,b,c) (p)->NextViewport(a,b,c) -#define IDirect3DDevice2_EnumTextureFormats(p,a,b) (p)->EnumTextureFormats(a,b) -#define IDirect3DDevice2_BeginScene(p) (p)->BeginScene() -#define IDirect3DDevice2_EndScene(p) (p)->EndScene() -#define IDirect3DDevice2_GetDirect3D(p,a) (p)->GetDirect3D(a) -#define IDirect3DDevice2_SetCurrentViewport(p,a) (p)->SetCurrentViewport(a) -#define IDirect3DDevice2_GetCurrentViewport(p,a) (p)->GetCurrentViewport(a) -#define IDirect3DDevice2_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) -#define IDirect3DDevice2_GetRenderTarget(p,a) (p)->GetRenderTarget(a) -#define IDirect3DDevice2_Begin(p,a,b,c) (p)->Begin(a,b,c) -#define IDirect3DDevice2_BeginIndexed(p,a,b,c,d,e) (p)->BeginIndexed(a,b,c,d,e) -#define IDirect3DDevice2_Vertex(p,a) (p)->Vertex(a) -#define IDirect3DDevice2_Index(p,a) (p)->Index(a) -#define IDirect3DDevice2_End(p,a) (p)->End(a) -#define IDirect3DDevice2_GetRenderState(p,a,b) (p)->GetRenderState(a,b) -#define IDirect3DDevice2_SetRenderState(p,a,b) (p)->SetRenderState(a,b) -#define IDirect3DDevice2_GetLightState(p,a,b) (p)->GetLightState(a,b) -#define IDirect3DDevice2_SetLightState(p,a,b) (p)->SetLightState(a,b) -#define IDirect3DDevice2_SetTransform(p,a,b) (p)->SetTransform(a,b) -#define IDirect3DDevice2_GetTransform(p,a,b) (p)->GetTransform(a,b) -#define IDirect3DDevice2_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) -#define IDirect3DDevice2_DrawPrimitive(p,a,b,c,d,e) (p)->DrawPrimitive(a,b,c,d,e) -#define IDirect3DDevice2_DrawIndexedPrimitive(p,a,b,c,d,e,f,g) (p)->DrawIndexedPrimitive(a,b,c,d,e,f,g) -#define IDirect3DDevice2_SetClipStatus(p,a) (p)->SetClipStatus(a) -#define IDirect3DDevice2_GetClipStatus(p,a) (p)->GetClipStatus(a) -#endif -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if(DIRECT3D_VERSION >= 0x0600) -#undef INTERFACE -#define INTERFACE IDirect3DDevice3 - -DECLARE_INTERFACE_(IDirect3DDevice3, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DDevice3 methods ***/ - STDMETHOD(GetCaps)(THIS_ LPD3DDEVICEDESC,LPD3DDEVICEDESC) PURE; - STDMETHOD(GetStats)(THIS_ LPD3DSTATS) PURE; - STDMETHOD(AddViewport)(THIS_ LPDIRECT3DVIEWPORT3) PURE; - STDMETHOD(DeleteViewport)(THIS_ LPDIRECT3DVIEWPORT3) PURE; - STDMETHOD(NextViewport)(THIS_ LPDIRECT3DVIEWPORT3,LPDIRECT3DVIEWPORT3*,DWORD) PURE; - STDMETHOD(EnumTextureFormats)(THIS_ LPD3DENUMPIXELFORMATSCALLBACK,LPVOID) PURE; - STDMETHOD(BeginScene)(THIS) PURE; - STDMETHOD(EndScene)(THIS) PURE; - STDMETHOD(GetDirect3D)(THIS_ LPDIRECT3D3*) PURE; - STDMETHOD(SetCurrentViewport)(THIS_ LPDIRECT3DVIEWPORT3) PURE; - STDMETHOD(GetCurrentViewport)(THIS_ LPDIRECT3DVIEWPORT3 *) PURE; - STDMETHOD(SetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE4,DWORD) PURE; - STDMETHOD(GetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE4 *) PURE; - STDMETHOD(Begin)(THIS_ D3DPRIMITIVETYPE,DWORD,DWORD) PURE; - STDMETHOD(BeginIndexed)(THIS_ D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(Vertex)(THIS_ LPVOID) PURE; - STDMETHOD(Index)(THIS_ WORD) PURE; - STDMETHOD(End)(THIS_ DWORD) PURE; - STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE,LPDWORD) PURE; - STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE,DWORD) PURE; - STDMETHOD(GetLightState)(THIS_ D3DLIGHTSTATETYPE,LPDWORD) PURE; - STDMETHOD(SetLightState)(THIS_ D3DLIGHTSTATETYPE,DWORD) PURE; - STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; - STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; - STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; - STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,LPWORD,DWORD,DWORD) PURE; - STDMETHOD(SetClipStatus)(THIS_ LPD3DCLIPSTATUS) PURE; - STDMETHOD(GetClipStatus)(THIS_ LPD3DCLIPSTATUS) PURE; - STDMETHOD(DrawPrimitiveStrided)(THIS_ D3DPRIMITIVETYPE,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,DWORD) PURE; - STDMETHOD(DrawIndexedPrimitiveStrided)(THIS_ D3DPRIMITIVETYPE,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,LPWORD,DWORD,DWORD) PURE; - STDMETHOD(DrawPrimitiveVB)(THIS_ D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER,DWORD,DWORD,DWORD) PURE; - STDMETHOD(DrawIndexedPrimitiveVB)(THIS_ D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER,LPWORD,DWORD,DWORD) PURE; - STDMETHOD(ComputeSphereVisibility)(THIS_ LPD3DVECTOR,LPD3DVALUE,DWORD,DWORD,LPDWORD) PURE; - STDMETHOD(GetTexture)(THIS_ DWORD,LPDIRECT3DTEXTURE2 *) PURE; - STDMETHOD(SetTexture)(THIS_ DWORD,LPDIRECT3DTEXTURE2) PURE; - STDMETHOD(GetTextureStageState)(THIS_ DWORD,D3DTEXTURESTAGESTATETYPE,LPDWORD) PURE; - STDMETHOD(SetTextureStageState)(THIS_ DWORD,D3DTEXTURESTAGESTATETYPE,DWORD) PURE; - STDMETHOD(ValidateDevice)(THIS_ LPDWORD) PURE; -}; - -typedef struct IDirect3DDevice3 *LPDIRECT3DDEVICE3; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DDevice3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DDevice3_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DDevice3_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DDevice3_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) -#define IDirect3DDevice3_GetStats(p,a) (p)->lpVtbl->GetStats(p,a) -#define IDirect3DDevice3_AddViewport(p,a) (p)->lpVtbl->AddViewport(p,a) -#define IDirect3DDevice3_DeleteViewport(p,a) (p)->lpVtbl->DeleteViewport(p,a) -#define IDirect3DDevice3_NextViewport(p,a,b,c) (p)->lpVtbl->NextViewport(p,a,b,c) -#define IDirect3DDevice3_EnumTextureFormats(p,a,b) (p)->lpVtbl->EnumTextureFormats(p,a,b) -#define IDirect3DDevice3_BeginScene(p) (p)->lpVtbl->BeginScene(p) -#define IDirect3DDevice3_EndScene(p) (p)->lpVtbl->EndScene(p) -#define IDirect3DDevice3_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) -#define IDirect3DDevice3_SetCurrentViewport(p,a) (p)->lpVtbl->SetCurrentViewport(p,a) -#define IDirect3DDevice3_GetCurrentViewport(p,a) (p)->lpVtbl->GetCurrentViewport(p,a) -#define IDirect3DDevice3_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) -#define IDirect3DDevice3_GetRenderTarget(p,a) (p)->lpVtbl->GetRenderTarget(p,a) -#define IDirect3DDevice3_Begin(p,a,b,c) (p)->lpVtbl->Begin(p,a,b,c) -#define IDirect3DDevice3_BeginIndexed(p,a,b,c,d,e) (p)->lpVtbl->BeginIndexed(p,a,b,c,d,e) -#define IDirect3DDevice3_Vertex(p,a) (p)->lpVtbl->Vertex(p,a) -#define IDirect3DDevice3_Index(p,a) (p)->lpVtbl->Index(p,a) -#define IDirect3DDevice3_End(p,a) (p)->lpVtbl->End(p,a) -#define IDirect3DDevice3_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) -#define IDirect3DDevice3_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) -#define IDirect3DDevice3_GetLightState(p,a,b) (p)->lpVtbl->GetLightState(p,a,b) -#define IDirect3DDevice3_SetLightState(p,a,b) (p)->lpVtbl->SetLightState(p,a,b) -#define IDirect3DDevice3_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) -#define IDirect3DDevice3_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) -#define IDirect3DDevice3_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) -#define IDirect3DDevice3_DrawPrimitive(p,a,b,c,d,e) (p)->lpVtbl->DrawPrimitive(p,a,b,c,d,e) -#define IDirect3DDevice3_DrawIndexedPrimitive(p,a,b,c,d,e,f,g) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e,f,g) -#define IDirect3DDevice3_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) -#define IDirect3DDevice3_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) -#define IDirect3DDevice3_DrawPrimitiveStrided(p,a,b,c,d,e) (p)->lpVtbl->DrawPrimitiveStrided(p,a,b,c,d,e) -#define IDirect3DDevice3_DrawIndexedPrimitiveStrided(p,a,b,c,d,e,f,g) (p)->lpVtbl->DrawIndexedPrimitiveStrided(p,a,b,c,d,e,f,g) -#define IDirect3DDevice3_DrawPrimitiveVB(p,a,b,c,d,e) (p)->lpVtbl->DrawPrimitiveVB(p,a,b,c,d,e) -#define IDirect3DDevice3_DrawIndexedPrimitiveVB(p,a,b,c,d,e) (p)->lpVtbl->DrawIndexedPrimitiveVB(p,a,b,c,d,e) -#define IDirect3DDevice3_ComputeSphereVisibility(p,a,b,c,d,e) (p)->lpVtbl->ComputeSphereVisibility(p,a,b,c,d,e) -#define IDirect3DDevice3_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) -#define IDirect3DDevice3_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) -#define IDirect3DDevice3_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) -#define IDirect3DDevice3_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) -#define IDirect3DDevice3_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a) -#else -#define IDirect3DDevice3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DDevice3_AddRef(p) (p)->AddRef() -#define IDirect3DDevice3_Release(p) (p)->Release() -#define IDirect3DDevice3_GetCaps(p,a,b) (p)->GetCaps(a,b) -#define IDirect3DDevice3_GetStats(p,a) (p)->GetStats(a) -#define IDirect3DDevice3_AddViewport(p,a) (p)->AddViewport(a) -#define IDirect3DDevice3_DeleteViewport(p,a) (p)->DeleteViewport(a) -#define IDirect3DDevice3_NextViewport(p,a,b,c) (p)->NextViewport(a,b,c) -#define IDirect3DDevice3_EnumTextureFormats(p,a,b) (p)->EnumTextureFormats(a,b) -#define IDirect3DDevice3_BeginScene(p) (p)->BeginScene() -#define IDirect3DDevice3_EndScene(p) (p)->EndScene() -#define IDirect3DDevice3_GetDirect3D(p,a) (p)->GetDirect3D(a) -#define IDirect3DDevice3_SetCurrentViewport(p,a) (p)->SetCurrentViewport(a) -#define IDirect3DDevice3_GetCurrentViewport(p,a) (p)->GetCurrentViewport(a) -#define IDirect3DDevice3_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) -#define IDirect3DDevice3_GetRenderTarget(p,a) (p)->GetRenderTarget(a) -#define IDirect3DDevice3_Begin(p,a,b,c) (p)->Begin(a,b,c) -#define IDirect3DDevice3_BeginIndexed(p,a,b,c,d,e) (p)->BeginIndexed(a,b,c,d,e) -#define IDirect3DDevice3_Vertex(p,a) (p)->Vertex(a) -#define IDirect3DDevice3_Index(p,a) (p)->Index(a) -#define IDirect3DDevice3_End(p,a) (p)->End(a) -#define IDirect3DDevice3_GetRenderState(p,a,b) (p)->GetRenderState(a,b) -#define IDirect3DDevice3_SetRenderState(p,a,b) (p)->SetRenderState(a,b) -#define IDirect3DDevice3_GetLightState(p,a,b) (p)->GetLightState(a,b) -#define IDirect3DDevice3_SetLightState(p,a,b) (p)->SetLightState(a,b) -#define IDirect3DDevice3_SetTransform(p,a,b) (p)->SetTransform(a,b) -#define IDirect3DDevice3_GetTransform(p,a,b) (p)->GetTransform(a,b) -#define IDirect3DDevice3_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) -#define IDirect3DDevice3_DrawPrimitive(p,a,b,c,d,e) (p)->DrawPrimitive(a,b,c,d,e) -#define IDirect3DDevice3_DrawIndexedPrimitive(p,a,b,c,d,e,f,g) (p)->DrawIndexedPrimitive(a,b,c,d,e,f,g) -#define IDirect3DDevice3_SetClipStatus(p,a) (p)->SetClipStatus(a) -#define IDirect3DDevice3_GetClipStatus(p,a) (p)->GetClipStatus(a) -#define IDirect3DDevice3_DrawPrimitiveStrided(p,a,b,c,d,e) (p)->DrawPrimitiveStrided(a,b,c,d,e) -#define IDirect3DDevice3_DrawIndexedPrimitiveStrided(p,a,b,c,d,e,f,g) (p)->DrawIndexedPrimitiveStrided(a,b,c,d,e,f,g) -#define IDirect3DDevice3_DrawPrimitiveVB(p,a,b,c,d,e) (p)->DrawPrimitiveVB(a,b,c,d,e) -#define IDirect3DDevice3_DrawIndexedPrimitiveVB(p,a,b,c,d,e) (p)->DrawIndexedPrimitiveVB(a,b,c,d,e) -#define IDirect3DDevice3_ComputeSphereVisibility(p,a,b,c,d,e) (p)->ComputeSphereVisibility(a,b,c,d,e) -#define IDirect3DDevice3_GetTexture(p,a,b) (p)->GetTexture(a,b) -#define IDirect3DDevice3_SetTexture(p,a,b) (p)->SetTexture(a,b) -#define IDirect3DDevice3_GetTextureStageState(p,a,b,c) (p)->GetTextureStageState(a,b,c) -#define IDirect3DDevice3_SetTextureStageState(p,a,b,c) (p)->SetTextureStageState(a,b,c) -#define IDirect3DDevice3_ValidateDevice(p,a) (p)->ValidateDevice(a) -#endif -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -#if(DIRECT3D_VERSION >= 0x0700) -#undef INTERFACE -#define INTERFACE IDirect3DDevice7 - -DECLARE_INTERFACE_(IDirect3DDevice7, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DDevice7 methods ***/ - STDMETHOD(GetCaps)(THIS_ LPD3DDEVICEDESC7) PURE; - STDMETHOD(EnumTextureFormats)(THIS_ LPD3DENUMPIXELFORMATSCALLBACK,LPVOID) PURE; - STDMETHOD(BeginScene)(THIS) PURE; - STDMETHOD(EndScene)(THIS) PURE; - STDMETHOD(GetDirect3D)(THIS_ LPDIRECT3D7*) PURE; - STDMETHOD(SetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE7,DWORD) PURE; - STDMETHOD(GetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE7 *) PURE; - STDMETHOD(Clear)(THIS_ DWORD,LPD3DRECT,DWORD,D3DCOLOR,D3DVALUE,DWORD) PURE; - STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; - STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; - STDMETHOD(SetViewport)(THIS_ LPD3DVIEWPORT7) PURE; - STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; - STDMETHOD(GetViewport)(THIS_ LPD3DVIEWPORT7) PURE; - STDMETHOD(SetMaterial)(THIS_ LPD3DMATERIAL7) PURE; - STDMETHOD(GetMaterial)(THIS_ LPD3DMATERIAL7) PURE; - STDMETHOD(SetLight)(THIS_ DWORD,LPD3DLIGHT7) PURE; - STDMETHOD(GetLight)(THIS_ DWORD,LPD3DLIGHT7) PURE; - STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE,DWORD) PURE; - STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE,LPDWORD) PURE; - STDMETHOD(BeginStateBlock)(THIS) PURE; - STDMETHOD(EndStateBlock)(THIS_ LPDWORD) PURE; - STDMETHOD(PreLoad)(THIS_ LPDIRECTDRAWSURFACE7) PURE; - STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,LPWORD,DWORD,DWORD) PURE; - STDMETHOD(SetClipStatus)(THIS_ LPD3DCLIPSTATUS) PURE; - STDMETHOD(GetClipStatus)(THIS_ LPD3DCLIPSTATUS) PURE; - STDMETHOD(DrawPrimitiveStrided)(THIS_ D3DPRIMITIVETYPE,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,DWORD) PURE; - STDMETHOD(DrawIndexedPrimitiveStrided)(THIS_ D3DPRIMITIVETYPE,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,LPWORD,DWORD,DWORD) PURE; - STDMETHOD(DrawPrimitiveVB)(THIS_ D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER7,DWORD,DWORD,DWORD) PURE; - STDMETHOD(DrawIndexedPrimitiveVB)(THIS_ D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER7,DWORD,DWORD,LPWORD,DWORD,DWORD) PURE; - STDMETHOD(ComputeSphereVisibility)(THIS_ LPD3DVECTOR,LPD3DVALUE,DWORD,DWORD,LPDWORD) PURE; - STDMETHOD(GetTexture)(THIS_ DWORD,LPDIRECTDRAWSURFACE7 *) PURE; - STDMETHOD(SetTexture)(THIS_ DWORD,LPDIRECTDRAWSURFACE7) PURE; - STDMETHOD(GetTextureStageState)(THIS_ DWORD,D3DTEXTURESTAGESTATETYPE,LPDWORD) PURE; - STDMETHOD(SetTextureStageState)(THIS_ DWORD,D3DTEXTURESTAGESTATETYPE,DWORD) PURE; - STDMETHOD(ValidateDevice)(THIS_ LPDWORD) PURE; - STDMETHOD(ApplyStateBlock)(THIS_ DWORD) PURE; - STDMETHOD(CaptureStateBlock)(THIS_ DWORD) PURE; - STDMETHOD(DeleteStateBlock)(THIS_ DWORD) PURE; - STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE,LPDWORD) PURE; - STDMETHOD(Load)(THIS_ LPDIRECTDRAWSURFACE7,LPPOINT,LPDIRECTDRAWSURFACE7,LPRECT,DWORD) PURE; - STDMETHOD(LightEnable)(THIS_ DWORD,BOOL) PURE; - STDMETHOD(GetLightEnable)(THIS_ DWORD,BOOL*) PURE; - STDMETHOD(SetClipPlane)(THIS_ DWORD,D3DVALUE*) PURE; - STDMETHOD(GetClipPlane)(THIS_ DWORD,D3DVALUE*) PURE; - STDMETHOD(GetInfo)(THIS_ DWORD,LPVOID,DWORD) PURE; -}; - -typedef struct IDirect3DDevice7 *LPDIRECT3DDEVICE7; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DDevice7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DDevice7_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DDevice7_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) -#define IDirect3DDevice7_EnumTextureFormats(p,a,b) (p)->lpVtbl->EnumTextureFormats(p,a,b) -#define IDirect3DDevice7_BeginScene(p) (p)->lpVtbl->BeginScene(p) -#define IDirect3DDevice7_EndScene(p) (p)->lpVtbl->EndScene(p) -#define IDirect3DDevice7_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) -#define IDirect3DDevice7_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) -#define IDirect3DDevice7_GetRenderTarget(p,a) (p)->lpVtbl->GetRenderTarget(p,a) -#define IDirect3DDevice7_Clear(p,a,b,c,d,e,f) (p)->lpVtbl->Clear(p,a,b,c,d,e,f) -#define IDirect3DDevice7_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) -#define IDirect3DDevice7_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) -#define IDirect3DDevice7_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) -#define IDirect3DDevice7_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) -#define IDirect3DDevice7_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) -#define IDirect3DDevice7_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) -#define IDirect3DDevice7_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) -#define IDirect3DDevice7_SetLight(p,a,b) (p)->lpVtbl->SetLight(p,a,b) -#define IDirect3DDevice7_GetLight(p,a,b) (p)->lpVtbl->GetLight(p,a,b) -#define IDirect3DDevice7_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) -#define IDirect3DDevice7_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) -#define IDirect3DDevice7_BeginStateBlock(p) (p)->lpVtbl->BeginStateBlock(p) -#define IDirect3DDevice7_EndStateBlock(p,a) (p)->lpVtbl->EndStateBlock(p,a) -#define IDirect3DDevice7_PreLoad(p,a) (p)->lpVtbl->PreLoad(p,a) -#define IDirect3DDevice7_DrawPrimitive(p,a,b,c,d,e) (p)->lpVtbl->DrawPrimitive(p,a,b,c,d,e) -#define IDirect3DDevice7_DrawIndexedPrimitive(p,a,b,c,d,e,f,g) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e,f,g) -#define IDirect3DDevice7_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) -#define IDirect3DDevice7_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) -#define IDirect3DDevice7_DrawPrimitiveStrided(p,a,b,c,d,e) (p)->lpVtbl->DrawPrimitiveStrided(p,a,b,c,d,e) -#define IDirect3DDevice7_DrawIndexedPrimitiveStrided(p,a,b,c,d,e,f,g) (p)->lpVtbl->DrawIndexedPrimitiveStrided(p,a,b,c,d,e,f,g) -#define IDirect3DDevice7_DrawPrimitiveVB(p,a,b,c,d,e) (p)->lpVtbl->DrawPrimitiveVB(p,a,b,c,d,e) -#define IDirect3DDevice7_DrawIndexedPrimitiveVB(p,a,b,c,d,e,f,g) (p)->lpVtbl->DrawIndexedPrimitiveVB(p,a,b,c,d,e,f,g) -#define IDirect3DDevice7_ComputeSphereVisibility(p,a,b,c,d,e) (p)->lpVtbl->ComputeSphereVisibility(p,a,b,c,d,e) -#define IDirect3DDevice7_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) -#define IDirect3DDevice7_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) -#define IDirect3DDevice7_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) -#define IDirect3DDevice7_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) -#define IDirect3DDevice7_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a) -#define IDirect3DDevice7_ApplyStateBlock(p,a) (p)->lpVtbl->ApplyStateBlock(p,a) -#define IDirect3DDevice7_CaptureStateBlock(p,a) (p)->lpVtbl->CaptureStateBlock(p,a) -#define IDirect3DDevice7_DeleteStateBlock(p,a) (p)->lpVtbl->DeleteStateBlock(p,a) -#define IDirect3DDevice7_CreateStateBlock(p,a,b) (p)->lpVtbl->CreateStateBlock(p,a,b) -#define IDirect3DDevice7_Load(p,a,b,c,d,e) (p)->lpVtbl->Load(p,a,b,c,d,e) -#define IDirect3DDevice7_LightEnable(p,a,b) (p)->lpVtbl->LightEnable(p,a,b) -#define IDirect3DDevice7_GetLightEnable(p,a,b) (p)->lpVtbl->GetLightEnable(p,a,b) -#define IDirect3DDevice7_SetClipPlane(p,a,b) (p)->lpVtbl->SetClipPlane(p,a,b) -#define IDirect3DDevice7_GetClipPlane(p,a,b) (p)->lpVtbl->GetClipPlane(p,a,b) -#define IDirect3DDevice7_GetInfo(p,a,b,c) (p)->lpVtbl->GetInfo(p,a,b,c) -#else -#define IDirect3DDevice7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DDevice7_AddRef(p) (p)->AddRef() -#define IDirect3DDevice7_Release(p) (p)->Release() -#define IDirect3DDevice7_GetCaps(p,a) (p)->GetCaps(a) -#define IDirect3DDevice7_EnumTextureFormats(p,a,b) (p)->EnumTextureFormats(a,b) -#define IDirect3DDevice7_BeginScene(p) (p)->BeginScene() -#define IDirect3DDevice7_EndScene(p) (p)->EndScene() -#define IDirect3DDevice7_GetDirect3D(p,a) (p)->GetDirect3D(a) -#define IDirect3DDevice7_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) -#define IDirect3DDevice7_GetRenderTarget(p,a) (p)->GetRenderTarget(a) -#define IDirect3DDevice7_Clear(p,a,b,c,d,e,f) (p)->Clear(a,b,c,d,e,f) -#define IDirect3DDevice7_SetTransform(p,a,b) (p)->SetTransform(a,b) -#define IDirect3DDevice7_GetTransform(p,a,b) (p)->GetTransform(a,b) -#define IDirect3DDevice7_SetViewport(p,a) (p)->SetViewport(a) -#define IDirect3DDevice7_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) -#define IDirect3DDevice7_GetViewport(p,a) (p)->GetViewport(a) -#define IDirect3DDevice7_SetMaterial(p,a) (p)->SetMaterial(a) -#define IDirect3DDevice7_GetMaterial(p,a) (p)->GetMaterial(a) -#define IDirect3DDevice7_SetLight(p,a,b) (p)->SetLight(a,b) -#define IDirect3DDevice7_GetLight(p,a,b) (p)->GetLight(a,b) -#define IDirect3DDevice7_SetRenderState(p,a,b) (p)->SetRenderState(a,b) -#define IDirect3DDevice7_GetRenderState(p,a,b) (p)->GetRenderState(a,b) -#define IDirect3DDevice7_BeginStateBlock(p) (p)->BeginStateBlock() -#define IDirect3DDevice7_EndStateBlock(p,a) (p)->EndStateBlock(a) -#define IDirect3DDevice7_PreLoad(p,a) (p)->PreLoad(a) -#define IDirect3DDevice7_DrawPrimitive(p,a,b,c,d,e) (p)->DrawPrimitive(a,b,c,d,e) -#define IDirect3DDevice7_DrawIndexedPrimitive(p,a,b,c,d,e,f,g) (p)->DrawIndexedPrimitive(a,b,c,d,e,f,g) -#define IDirect3DDevice7_SetClipStatus(p,a) (p)->SetClipStatus(a) -#define IDirect3DDevice7_GetClipStatus(p,a) (p)->GetClipStatus(a) -#define IDirect3DDevice7_DrawPrimitiveStrided(p,a,b,c,d,e) (p)->DrawPrimitiveStrided(a,b,c,d,e) -#define IDirect3DDevice7_DrawIndexedPrimitiveStrided(p,a,b,c,d,e,f,g) (p)->DrawIndexedPrimitiveStrided(a,b,c,d,e,f,g) -#define IDirect3DDevice7_DrawPrimitiveVB(p,a,b,c,d,e) (p)->DrawPrimitiveVB(a,b,c,d,e) -#define IDirect3DDevice7_DrawIndexedPrimitiveVB(p,a,b,c,d,e,f,g) (p)->DrawIndexedPrimitiveVB(a,b,c,d,e,f,g) -#define IDirect3DDevice7_ComputeSphereVisibility(p,a,b,c,d,e) (p)->ComputeSphereVisibility(a,b,c,d,e) -#define IDirect3DDevice7_GetTexture(p,a,b) (p)->GetTexture(a,b) -#define IDirect3DDevice7_SetTexture(p,a,b) (p)->SetTexture(a,b) -#define IDirect3DDevice7_GetTextureStageState(p,a,b,c) (p)->GetTextureStageState(a,b,c) -#define IDirect3DDevice7_SetTextureStageState(p,a,b,c) (p)->SetTextureStageState(a,b,c) -#define IDirect3DDevice7_ValidateDevice(p,a) (p)->ValidateDevice(a) -#define IDirect3DDevice7_ApplyStateBlock(p,a) (p)->ApplyStateBlock(a) -#define IDirect3DDevice7_CaptureStateBlock(p,a) (p)->CaptureStateBlock(a) -#define IDirect3DDevice7_DeleteStateBlock(p,a) (p)->DeleteStateBlock(a) -#define IDirect3DDevice7_CreateStateBlock(p,a,b) (p)->CreateStateBlock(a,b) -#define IDirect3DDevice7_Load(p,a,b,c,d,e) (p)->Load(a,b,c,d,e) -#define IDirect3DDevice7_LightEnable(p,a,b) (p)->LightEnable(a,b) -#define IDirect3DDevice7_GetLightEnable(p,a,b) (p)->GetLightEnable(a,b) -#define IDirect3DDevice7_SetClipPlane(p,a,b) (p)->SetClipPlane(a,b) -#define IDirect3DDevice7_GetClipPlane(p,a,b) (p)->GetClipPlane(a,b) -#define IDirect3DDevice7_GetInfo(p,a,b,c) (p)->GetInfo(a,b,c) -#endif -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -/* - * Execute Buffer interface - */ -#undef INTERFACE -#define INTERFACE IDirect3DExecuteBuffer - -DECLARE_INTERFACE_(IDirect3DExecuteBuffer, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DExecuteBuffer methods ***/ - STDMETHOD(Initialize)(THIS_ LPDIRECT3DDEVICE,LPD3DEXECUTEBUFFERDESC) PURE; - STDMETHOD(Lock)(THIS_ LPD3DEXECUTEBUFFERDESC) PURE; - STDMETHOD(Unlock)(THIS) PURE; - STDMETHOD(SetExecuteData)(THIS_ LPD3DEXECUTEDATA) PURE; - STDMETHOD(GetExecuteData)(THIS_ LPD3DEXECUTEDATA) PURE; - STDMETHOD(Validate)(THIS_ LPDWORD,LPD3DVALIDATECALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(Optimize)(THIS_ DWORD) PURE; -}; - -typedef struct IDirect3DExecuteBuffer *LPDIRECT3DEXECUTEBUFFER; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DExecuteBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DExecuteBuffer_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DExecuteBuffer_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DExecuteBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirect3DExecuteBuffer_Lock(p,a) (p)->lpVtbl->Lock(p,a) -#define IDirect3DExecuteBuffer_Unlock(p) (p)->lpVtbl->Unlock(p) -#define IDirect3DExecuteBuffer_SetExecuteData(p,a) (p)->lpVtbl->SetExecuteData(p,a) -#define IDirect3DExecuteBuffer_GetExecuteData(p,a) (p)->lpVtbl->GetExecuteData(p,a) -#define IDirect3DExecuteBuffer_Validate(p,a,b,c,d) (p)->lpVtbl->Validate(p,a,b,c,d) -#define IDirect3DExecuteBuffer_Optimize(p,a) (p)->lpVtbl->Optimize(p,a) -#else -#define IDirect3DExecuteBuffer_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DExecuteBuffer_AddRef(p) (p)->AddRef() -#define IDirect3DExecuteBuffer_Release(p) (p)->Release() -#define IDirect3DExecuteBuffer_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirect3DExecuteBuffer_Lock(p,a) (p)->Lock(a) -#define IDirect3DExecuteBuffer_Unlock(p) (p)->Unlock() -#define IDirect3DExecuteBuffer_SetExecuteData(p,a) (p)->SetExecuteData(a) -#define IDirect3DExecuteBuffer_GetExecuteData(p,a) (p)->GetExecuteData(a) -#define IDirect3DExecuteBuffer_Validate(p,a,b,c,d) (p)->Validate(a,b,c,d) -#define IDirect3DExecuteBuffer_Optimize(p,a) (p)->Optimize(a) -#endif - -/* - * Light interfaces - */ -#undef INTERFACE -#define INTERFACE IDirect3DLight - -DECLARE_INTERFACE_(IDirect3DLight, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DLight methods ***/ - STDMETHOD(Initialize)(THIS_ LPDIRECT3D) PURE; - STDMETHOD(SetLight)(THIS_ LPD3DLIGHT) PURE; - STDMETHOD(GetLight)(THIS_ LPD3DLIGHT) PURE; -}; - -typedef struct IDirect3DLight *LPDIRECT3DLIGHT; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DLight_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DLight_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DLight_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DLight_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#define IDirect3DLight_SetLight(p,a) (p)->lpVtbl->SetLight(p,a) -#define IDirect3DLight_GetLight(p,a) (p)->lpVtbl->GetLight(p,a) -#else -#define IDirect3DLight_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DLight_AddRef(p) (p)->AddRef() -#define IDirect3DLight_Release(p) (p)->Release() -#define IDirect3DLight_Initialize(p,a) (p)->Initialize(a) -#define IDirect3DLight_SetLight(p,a) (p)->SetLight(a) -#define IDirect3DLight_GetLight(p,a) (p)->GetLight(a) -#endif - -/* - * Material interfaces - */ -#undef INTERFACE -#define INTERFACE IDirect3DMaterial - -DECLARE_INTERFACE_(IDirect3DMaterial, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DMaterial methods ***/ - STDMETHOD(Initialize)(THIS_ LPDIRECT3D) PURE; - STDMETHOD(SetMaterial)(THIS_ LPD3DMATERIAL) PURE; - STDMETHOD(GetMaterial)(THIS_ LPD3DMATERIAL) PURE; - STDMETHOD(GetHandle)(THIS_ LPDIRECT3DDEVICE,LPD3DMATERIALHANDLE) PURE; - STDMETHOD(Reserve)(THIS) PURE; - STDMETHOD(Unreserve)(THIS) PURE; -}; - -typedef struct IDirect3DMaterial *LPDIRECT3DMATERIAL; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DMaterial_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DMaterial_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DMaterial_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DMaterial_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#define IDirect3DMaterial_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) -#define IDirect3DMaterial_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) -#define IDirect3DMaterial_GetHandle(p,a,b) (p)->lpVtbl->GetHandle(p,a,b) -#define IDirect3DMaterial_Reserve(p) (p)->lpVtbl->Reserve(p) -#define IDirect3DMaterial_Unreserve(p) (p)->lpVtbl->Unreserve(p) -#else -#define IDirect3DMaterial_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DMaterial_AddRef(p) (p)->AddRef() -#define IDirect3DMaterial_Release(p) (p)->Release() -#define IDirect3DMaterial_Initialize(p,a) (p)->Initialize(a) -#define IDirect3DMaterial_SetMaterial(p,a) (p)->SetMaterial(a) -#define IDirect3DMaterial_GetMaterial(p,a) (p)->GetMaterial(a) -#define IDirect3DMaterial_GetHandle(p,a,b) (p)->GetHandle(a,b) -#define IDirect3DMaterial_Reserve(p) (p)->Reserve() -#define IDirect3DMaterial_Unreserve(p) (p)->Unreserve() -#endif - -#if(DIRECT3D_VERSION >= 0x0500) -#undef INTERFACE -#define INTERFACE IDirect3DMaterial2 - -DECLARE_INTERFACE_(IDirect3DMaterial2, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DMaterial2 methods ***/ - STDMETHOD(SetMaterial)(THIS_ LPD3DMATERIAL) PURE; - STDMETHOD(GetMaterial)(THIS_ LPD3DMATERIAL) PURE; - STDMETHOD(GetHandle)(THIS_ LPDIRECT3DDEVICE2,LPD3DMATERIALHANDLE) PURE; -}; - -typedef struct IDirect3DMaterial2 *LPDIRECT3DMATERIAL2; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DMaterial2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DMaterial2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DMaterial2_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DMaterial2_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) -#define IDirect3DMaterial2_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) -#define IDirect3DMaterial2_GetHandle(p,a,b) (p)->lpVtbl->GetHandle(p,a,b) -#else -#define IDirect3DMaterial2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DMaterial2_AddRef(p) (p)->AddRef() -#define IDirect3DMaterial2_Release(p) (p)->Release() -#define IDirect3DMaterial2_SetMaterial(p,a) (p)->SetMaterial(a) -#define IDirect3DMaterial2_GetMaterial(p,a) (p)->GetMaterial(a) -#define IDirect3DMaterial2_GetHandle(p,a,b) (p)->GetHandle(a,b) -#endif -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if(DIRECT3D_VERSION >= 0x0600) -#undef INTERFACE -#define INTERFACE IDirect3DMaterial3 - -DECLARE_INTERFACE_(IDirect3DMaterial3, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DMaterial3 methods ***/ - STDMETHOD(SetMaterial)(THIS_ LPD3DMATERIAL) PURE; - STDMETHOD(GetMaterial)(THIS_ LPD3DMATERIAL) PURE; - STDMETHOD(GetHandle)(THIS_ LPDIRECT3DDEVICE3,LPD3DMATERIALHANDLE) PURE; -}; - -typedef struct IDirect3DMaterial3 *LPDIRECT3DMATERIAL3; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DMaterial3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DMaterial3_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DMaterial3_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DMaterial3_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) -#define IDirect3DMaterial3_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) -#define IDirect3DMaterial3_GetHandle(p,a,b) (p)->lpVtbl->GetHandle(p,a,b) -#else -#define IDirect3DMaterial3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DMaterial3_AddRef(p) (p)->AddRef() -#define IDirect3DMaterial3_Release(p) (p)->Release() -#define IDirect3DMaterial3_SetMaterial(p,a) (p)->SetMaterial(a) -#define IDirect3DMaterial3_GetMaterial(p,a) (p)->GetMaterial(a) -#define IDirect3DMaterial3_GetHandle(p,a,b) (p)->GetHandle(a,b) -#endif -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -/* - * Texture interfaces - */ -#undef INTERFACE -#define INTERFACE IDirect3DTexture - -DECLARE_INTERFACE_(IDirect3DTexture, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DTexture methods ***/ - STDMETHOD(Initialize)(THIS_ LPDIRECT3DDEVICE,LPDIRECTDRAWSURFACE) PURE; - STDMETHOD(GetHandle)(THIS_ LPDIRECT3DDEVICE,LPD3DTEXTUREHANDLE) PURE; - STDMETHOD(PaletteChanged)(THIS_ DWORD,DWORD) PURE; - STDMETHOD(Load)(THIS_ LPDIRECT3DTEXTURE) PURE; - STDMETHOD(Unload)(THIS) PURE; -}; - -typedef struct IDirect3DTexture *LPDIRECT3DTEXTURE; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DTexture_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DTexture_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DTexture_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DTexture_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirect3DTexture_GetHandle(p,a,b) (p)->lpVtbl->GetHandle(p,a,b) -#define IDirect3DTexture_PaletteChanged(p,a,b) (p)->lpVtbl->PaletteChanged(p,a,b) -#define IDirect3DTexture_Load(p,a) (p)->lpVtbl->Load(p,a) -#define IDirect3DTexture_Unload(p) (p)->lpVtbl->Unload(p) -#else -#define IDirect3DTexture_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DTexture_AddRef(p) (p)->AddRef() -#define IDirect3DTexture_Release(p) (p)->Release() -#define IDirect3DTexture_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirect3DTexture_GetHandle(p,a,b) (p)->GetHandle(a,b) -#define IDirect3DTexture_PaletteChanged(p,a,b) (p)->PaletteChanged(a,b) -#define IDirect3DTexture_Load(p,a) (p)->Load(a) -#define IDirect3DTexture_Unload(p) (p)->Unload() -#endif - -#if(DIRECT3D_VERSION >= 0x0500) -#undef INTERFACE -#define INTERFACE IDirect3DTexture2 - -DECLARE_INTERFACE_(IDirect3DTexture2, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DTexture2 methods ***/ - STDMETHOD(GetHandle)(THIS_ LPDIRECT3DDEVICE2,LPD3DTEXTUREHANDLE) PURE; - STDMETHOD(PaletteChanged)(THIS_ DWORD,DWORD) PURE; - STDMETHOD(Load)(THIS_ LPDIRECT3DTEXTURE2) PURE; -}; - -typedef struct IDirect3DTexture2 *LPDIRECT3DTEXTURE2; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DTexture2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DTexture2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DTexture2_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DTexture2_GetHandle(p,a,b) (p)->lpVtbl->GetHandle(p,a,b) -#define IDirect3DTexture2_PaletteChanged(p,a,b) (p)->lpVtbl->PaletteChanged(p,a,b) -#define IDirect3DTexture2_Load(p,a) (p)->lpVtbl->Load(p,a) -#else -#define IDirect3DTexture2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DTexture2_AddRef(p) (p)->AddRef() -#define IDirect3DTexture2_Release(p) (p)->Release() -#define IDirect3DTexture2_GetHandle(p,a,b) (p)->GetHandle(a,b) -#define IDirect3DTexture2_PaletteChanged(p,a,b) (p)->PaletteChanged(a,b) -#define IDirect3DTexture2_Load(p,a) (p)->Load(a) -#endif -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -/* - * Viewport interfaces - */ -#undef INTERFACE -#define INTERFACE IDirect3DViewport - -DECLARE_INTERFACE_(IDirect3DViewport, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DViewport methods ***/ - STDMETHOD(Initialize)(THIS_ LPDIRECT3D) PURE; - STDMETHOD(GetViewport)(THIS_ LPD3DVIEWPORT) PURE; - STDMETHOD(SetViewport)(THIS_ LPD3DVIEWPORT) PURE; - STDMETHOD(TransformVertices)(THIS_ DWORD,LPD3DTRANSFORMDATA,DWORD,LPDWORD) PURE; - STDMETHOD(LightElements)(THIS_ DWORD,LPD3DLIGHTDATA) PURE; - STDMETHOD(SetBackground)(THIS_ D3DMATERIALHANDLE) PURE; - STDMETHOD(GetBackground)(THIS_ LPD3DMATERIALHANDLE,LPBOOL) PURE; - STDMETHOD(SetBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE; - STDMETHOD(GetBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE*,LPBOOL) PURE; - STDMETHOD(Clear)(THIS_ DWORD,LPD3DRECT,DWORD) PURE; - STDMETHOD(AddLight)(THIS_ LPDIRECT3DLIGHT) PURE; - STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DLIGHT) PURE; - STDMETHOD(NextLight)(THIS_ LPDIRECT3DLIGHT,LPDIRECT3DLIGHT*,DWORD) PURE; -}; - -typedef struct IDirect3DViewport *LPDIRECT3DVIEWPORT; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DViewport_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DViewport_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DViewport_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DViewport_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#define IDirect3DViewport_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) -#define IDirect3DViewport_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) -#define IDirect3DViewport_TransformVertices(p,a,b,c,d) (p)->lpVtbl->TransformVertices(p,a,b,c,d) -#define IDirect3DViewport_LightElements(p,a,b) (p)->lpVtbl->LightElements(p,a,b) -#define IDirect3DViewport_SetBackground(p,a) (p)->lpVtbl->SetBackground(p,a) -#define IDirect3DViewport_GetBackground(p,a,b) (p)->lpVtbl->GetBackground(p,a,b) -#define IDirect3DViewport_SetBackgroundDepth(p,a) (p)->lpVtbl->SetBackgroundDepth(p,a) -#define IDirect3DViewport_GetBackgroundDepth(p,a,b) (p)->lpVtbl->GetBackgroundDepth(p,a,b) -#define IDirect3DViewport_Clear(p,a,b,c) (p)->lpVtbl->Clear(p,a,b,c) -#define IDirect3DViewport_AddLight(p,a) (p)->lpVtbl->AddLight(p,a) -#define IDirect3DViewport_DeleteLight(p,a) (p)->lpVtbl->DeleteLight(p,a) -#define IDirect3DViewport_NextLight(p,a,b,c) (p)->lpVtbl->NextLight(p,a,b,c) -#else -#define IDirect3DViewport_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DViewport_AddRef(p) (p)->AddRef() -#define IDirect3DViewport_Release(p) (p)->Release() -#define IDirect3DViewport_Initialize(p,a) (p)->Initialize(a) -#define IDirect3DViewport_GetViewport(p,a) (p)->GetViewport(a) -#define IDirect3DViewport_SetViewport(p,a) (p)->SetViewport(a) -#define IDirect3DViewport_TransformVertices(p,a,b,c,d) (p)->TransformVertices(a,b,c,d) -#define IDirect3DViewport_LightElements(p,a,b) (p)->LightElements(a,b) -#define IDirect3DViewport_SetBackground(p,a) (p)->SetBackground(a) -#define IDirect3DViewport_GetBackground(p,a,b) (p)->GetBackground(a,b) -#define IDirect3DViewport_SetBackgroundDepth(p,a) (p)->SetBackgroundDepth(a) -#define IDirect3DViewport_GetBackgroundDepth(p,a,b) (p)->GetBackgroundDepth(a,b) -#define IDirect3DViewport_Clear(p,a,b,c) (p)->Clear(a,b,c) -#define IDirect3DViewport_AddLight(p,a) (p)->AddLight(a) -#define IDirect3DViewport_DeleteLight(p,a) (p)->DeleteLight(a) -#define IDirect3DViewport_NextLight(p,a,b,c) (p)->NextLight(a,b,c) -#endif - -#if(DIRECT3D_VERSION >= 0x0500) -#undef INTERFACE -#define INTERFACE IDirect3DViewport2 - -DECLARE_INTERFACE_(IDirect3DViewport2, IDirect3DViewport) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DViewport methods ***/ - STDMETHOD(Initialize)(THIS_ LPDIRECT3D) PURE; - STDMETHOD(GetViewport)(THIS_ LPD3DVIEWPORT) PURE; - STDMETHOD(SetViewport)(THIS_ LPD3DVIEWPORT) PURE; - STDMETHOD(TransformVertices)(THIS_ DWORD,LPD3DTRANSFORMDATA,DWORD,LPDWORD) PURE; - STDMETHOD(LightElements)(THIS_ DWORD,LPD3DLIGHTDATA) PURE; - STDMETHOD(SetBackground)(THIS_ D3DMATERIALHANDLE) PURE; - STDMETHOD(GetBackground)(THIS_ LPD3DMATERIALHANDLE,LPBOOL) PURE; - STDMETHOD(SetBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE; - STDMETHOD(GetBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE*,LPBOOL) PURE; - STDMETHOD(Clear)(THIS_ DWORD,LPD3DRECT,DWORD) PURE; - STDMETHOD(AddLight)(THIS_ LPDIRECT3DLIGHT) PURE; - STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DLIGHT) PURE; - STDMETHOD(NextLight)(THIS_ LPDIRECT3DLIGHT,LPDIRECT3DLIGHT*,DWORD) PURE; - STDMETHOD(GetViewport2)(THIS_ LPD3DVIEWPORT2) PURE; - STDMETHOD(SetViewport2)(THIS_ LPD3DVIEWPORT2) PURE; -}; - -typedef struct IDirect3DViewport2 *LPDIRECT3DVIEWPORT2; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DViewport2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DViewport2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DViewport2_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DViewport2_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#define IDirect3DViewport2_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) -#define IDirect3DViewport2_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) -#define IDirect3DViewport2_TransformVertices(p,a,b,c,d) (p)->lpVtbl->TransformVertices(p,a,b,c,d) -#define IDirect3DViewport2_LightElements(p,a,b) (p)->lpVtbl->LightElements(p,a,b) -#define IDirect3DViewport2_SetBackground(p,a) (p)->lpVtbl->SetBackground(p,a) -#define IDirect3DViewport2_GetBackground(p,a,b) (p)->lpVtbl->GetBackground(p,a,b) -#define IDirect3DViewport2_SetBackgroundDepth(p,a) (p)->lpVtbl->SetBackgroundDepth(p,a) -#define IDirect3DViewport2_GetBackgroundDepth(p,a,b) (p)->lpVtbl->GetBackgroundDepth(p,a,b) -#define IDirect3DViewport2_Clear(p,a,b,c) (p)->lpVtbl->Clear(p,a,b,c) -#define IDirect3DViewport2_AddLight(p,a) (p)->lpVtbl->AddLight(p,a) -#define IDirect3DViewport2_DeleteLight(p,a) (p)->lpVtbl->DeleteLight(p,a) -#define IDirect3DViewport2_NextLight(p,a,b,c) (p)->lpVtbl->NextLight(p,a,b,c) -#define IDirect3DViewport2_GetViewport2(p,a) (p)->lpVtbl->GetViewport2(p,a) -#define IDirect3DViewport2_SetViewport2(p,a) (p)->lpVtbl->SetViewport2(p,a) -#else -#define IDirect3DViewport2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DViewport2_AddRef(p) (p)->AddRef() -#define IDirect3DViewport2_Release(p) (p)->Release() -#define IDirect3DViewport2_Initialize(p,a) (p)->Initialize(a) -#define IDirect3DViewport2_GetViewport(p,a) (p)->GetViewport(a) -#define IDirect3DViewport2_SetViewport(p,a) (p)->SetViewport(a) -#define IDirect3DViewport2_TransformVertices(p,a,b,c,d) (p)->TransformVertices(a,b,c,d) -#define IDirect3DViewport2_LightElements(p,a,b) (p)->LightElements(a,b) -#define IDirect3DViewport2_SetBackground(p,a) (p)->SetBackground(a) -#define IDirect3DViewport2_GetBackground(p,a,b) (p)->GetBackground(a,b) -#define IDirect3DViewport2_SetBackgroundDepth(p,a) (p)->SetBackgroundDepth(a) -#define IDirect3DViewport2_GetBackgroundDepth(p,a,b) (p)->GetBackgroundDepth(a,b) -#define IDirect3DViewport2_Clear(p,a,b,c) (p)->Clear(a,b,c) -#define IDirect3DViewport2_AddLight(p,a) (p)->AddLight(a) -#define IDirect3DViewport2_DeleteLight(p,a) (p)->DeleteLight(a) -#define IDirect3DViewport2_NextLight(p,a,b,c) (p)->NextLight(a,b,c) -#define IDirect3DViewport2_GetViewport2(p,a) (p)->GetViewport2(a) -#define IDirect3DViewport2_SetViewport2(p,a) (p)->SetViewport2(a) -#endif -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if(DIRECT3D_VERSION >= 0x0600) - -#undef INTERFACE -#define INTERFACE IDirect3DViewport3 - -DECLARE_INTERFACE_(IDirect3DViewport3, IDirect3DViewport2) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DViewport2 methods ***/ - STDMETHOD(Initialize)(THIS_ LPDIRECT3D) PURE; - STDMETHOD(GetViewport)(THIS_ LPD3DVIEWPORT) PURE; - STDMETHOD(SetViewport)(THIS_ LPD3DVIEWPORT) PURE; - STDMETHOD(TransformVertices)(THIS_ DWORD,LPD3DTRANSFORMDATA,DWORD,LPDWORD) PURE; - STDMETHOD(LightElements)(THIS_ DWORD,LPD3DLIGHTDATA) PURE; - STDMETHOD(SetBackground)(THIS_ D3DMATERIALHANDLE) PURE; - STDMETHOD(GetBackground)(THIS_ LPD3DMATERIALHANDLE,LPBOOL) PURE; - STDMETHOD(SetBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE; - STDMETHOD(GetBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE*,LPBOOL) PURE; - STDMETHOD(Clear)(THIS_ DWORD,LPD3DRECT,DWORD) PURE; - STDMETHOD(AddLight)(THIS_ LPDIRECT3DLIGHT) PURE; - STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DLIGHT) PURE; - STDMETHOD(NextLight)(THIS_ LPDIRECT3DLIGHT,LPDIRECT3DLIGHT*,DWORD) PURE; - STDMETHOD(GetViewport2)(THIS_ LPD3DVIEWPORT2) PURE; - STDMETHOD(SetViewport2)(THIS_ LPD3DVIEWPORT2) PURE; - STDMETHOD(SetBackgroundDepth2)(THIS_ LPDIRECTDRAWSURFACE4) PURE; - STDMETHOD(GetBackgroundDepth2)(THIS_ LPDIRECTDRAWSURFACE4*,LPBOOL) PURE; - STDMETHOD(Clear2)(THIS_ DWORD,LPD3DRECT,DWORD,D3DCOLOR,D3DVALUE,DWORD) PURE; -}; - -typedef struct IDirect3DViewport3 *LPDIRECT3DVIEWPORT3; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DViewport3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DViewport3_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DViewport3_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DViewport3_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#define IDirect3DViewport3_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) -#define IDirect3DViewport3_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) -#define IDirect3DViewport3_TransformVertices(p,a,b,c,d) (p)->lpVtbl->TransformVertices(p,a,b,c,d) -#define IDirect3DViewport3_LightElements(p,a,b) (p)->lpVtbl->LightElements(p,a,b) -#define IDirect3DViewport3_SetBackground(p,a) (p)->lpVtbl->SetBackground(p,a) -#define IDirect3DViewport3_GetBackground(p,a,b) (p)->lpVtbl->GetBackground(p,a,b) -#define IDirect3DViewport3_SetBackgroundDepth(p,a) (p)->lpVtbl->SetBackgroundDepth(p,a) -#define IDirect3DViewport3_GetBackgroundDepth(p,a,b) (p)->lpVtbl->GetBackgroundDepth(p,a,b) -#define IDirect3DViewport3_Clear(p,a,b,c) (p)->lpVtbl->Clear(p,a,b,c) -#define IDirect3DViewport3_AddLight(p,a) (p)->lpVtbl->AddLight(p,a) -#define IDirect3DViewport3_DeleteLight(p,a) (p)->lpVtbl->DeleteLight(p,a) -#define IDirect3DViewport3_NextLight(p,a,b,c) (p)->lpVtbl->NextLight(p,a,b,c) -#define IDirect3DViewport3_GetViewport2(p,a) (p)->lpVtbl->GetViewport2(p,a) -#define IDirect3DViewport3_SetViewport2(p,a) (p)->lpVtbl->SetViewport2(p,a) -#define IDirect3DViewport3_SetBackgroundDepth2(p,a) (p)->lpVtbl->SetBackgroundDepth2(p,a) -#define IDirect3DViewport3_GetBackgroundDepth2(p,a,b) (p)->lpVtbl->GetBackgroundDepth2(p,a,b) -#define IDirect3DViewport3_Clear2(p,a,b,c,d,e,f) (p)->lpVtbl->Clear2(p,a,b,c,d,e,f) -#else -#define IDirect3DViewport3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DViewport3_AddRef(p) (p)->AddRef() -#define IDirect3DViewport3_Release(p) (p)->Release() -#define IDirect3DViewport3_Initialize(p,a) (p)->Initialize(a) -#define IDirect3DViewport3_GetViewport(p,a) (p)->GetViewport(a) -#define IDirect3DViewport3_SetViewport(p,a) (p)->SetViewport(a) -#define IDirect3DViewport3_TransformVertices(p,a,b,c,d) (p)->TransformVertices(a,b,c,d) -#define IDirect3DViewport3_LightElements(p,a,b) (p)->LightElements(a,b) -#define IDirect3DViewport3_SetBackground(p,a) (p)->SetBackground(a) -#define IDirect3DViewport3_GetBackground(p,a,b) (p)->GetBackground(a,b) -#define IDirect3DViewport3_SetBackgroundDepth(p,a) (p)->SetBackgroundDepth(a) -#define IDirect3DViewport3_GetBackgroundDepth(p,a,b) (p)->GetBackgroundDepth(a,b) -#define IDirect3DViewport3_Clear(p,a,b,c) (p)->Clear(a,b,c) -#define IDirect3DViewport3_AddLight(p,a) (p)->AddLight(a) -#define IDirect3DViewport3_DeleteLight(p,a) (p)->DeleteLight(a) -#define IDirect3DViewport3_NextLight(p,a,b,c) (p)->NextLight(a,b,c) -#define IDirect3DViewport3_GetViewport2(p,a) (p)->GetViewport2(a) -#define IDirect3DViewport3_SetViewport2(p,a) (p)->SetViewport2(a) -#define IDirect3DViewport3_SetBackgroundDepth2(p,a) (p)->SetBackgroundDepth2(a) -#define IDirect3DViewport3_GetBackgroundDepth2(p,a,b) (p)->GetBackgroundDepth2(a,b) -#define IDirect3DViewport3_Clear2(p,a,b,c,d,e,f) (p)->Clear2(a,b,c,d,e,f) -#endif -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -#if(DIRECT3D_VERSION >= 0x0600) -#undef INTERFACE -#define INTERFACE IDirect3DVertexBuffer - -DECLARE_INTERFACE_(IDirect3DVertexBuffer, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DVertexBuffer methods ***/ - STDMETHOD(Lock)(THIS_ DWORD,LPVOID*,LPDWORD) PURE; - STDMETHOD(Unlock)(THIS) PURE; - STDMETHOD(ProcessVertices)(THIS_ DWORD,DWORD,DWORD,LPDIRECT3DVERTEXBUFFER,DWORD,LPDIRECT3DDEVICE3,DWORD) PURE; - STDMETHOD(GetVertexBufferDesc)(THIS_ LPD3DVERTEXBUFFERDESC) PURE; - STDMETHOD(Optimize)(THIS_ LPDIRECT3DDEVICE3,DWORD) PURE; -}; - -typedef struct IDirect3DVertexBuffer *LPDIRECT3DVERTEXBUFFER; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVertexBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVertexBuffer_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVertexBuffer_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVertexBuffer_Lock(p,a,b,c) (p)->lpVtbl->Lock(p,a,b,c) -#define IDirect3DVertexBuffer_Unlock(p) (p)->lpVtbl->Unlock(p) -#define IDirect3DVertexBuffer_ProcessVertices(p,a,b,c,d,e,f,g) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e,f,g) -#define IDirect3DVertexBuffer_GetVertexBufferDesc(p,a) (p)->lpVtbl->GetVertexBufferDesc(p,a) -#define IDirect3DVertexBuffer_Optimize(p,a,b) (p)->lpVtbl->Optimize(p,a,b) -#else -#define IDirect3DVertexBuffer_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVertexBuffer_AddRef(p) (p)->AddRef() -#define IDirect3DVertexBuffer_Release(p) (p)->Release() -#define IDirect3DVertexBuffer_Lock(p,a,b,c) (p)->Lock(a,b,c) -#define IDirect3DVertexBuffer_Unlock(p) (p)->Unlock() -#define IDirect3DVertexBuffer_ProcessVertices(p,a,b,c,d,e,f,g) (p)->ProcessVertices(a,b,c,d,e,f,g) -#define IDirect3DVertexBuffer_GetVertexBufferDesc(p,a) (p)->GetVertexBufferDesc(a) -#define IDirect3DVertexBuffer_Optimize(p,a,b) (p)->Optimize(a,b) -#endif -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -#if(DIRECT3D_VERSION >= 0x0700) -#undef INTERFACE -#define INTERFACE IDirect3DVertexBuffer7 - -DECLARE_INTERFACE_(IDirect3DVertexBuffer7, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DVertexBuffer7 methods ***/ - STDMETHOD(Lock)(THIS_ DWORD,LPVOID*,LPDWORD) PURE; - STDMETHOD(Unlock)(THIS) PURE; - STDMETHOD(ProcessVertices)(THIS_ DWORD,DWORD,DWORD,LPDIRECT3DVERTEXBUFFER7,DWORD,LPDIRECT3DDEVICE7,DWORD) PURE; - STDMETHOD(GetVertexBufferDesc)(THIS_ LPD3DVERTEXBUFFERDESC) PURE; - STDMETHOD(Optimize)(THIS_ LPDIRECT3DDEVICE7,DWORD) PURE; - STDMETHOD(ProcessVerticesStrided)(THIS_ DWORD,DWORD,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,LPDIRECT3DDEVICE7,DWORD) PURE; -}; - -typedef struct IDirect3DVertexBuffer7 *LPDIRECT3DVERTEXBUFFER7; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVertexBuffer7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVertexBuffer7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVertexBuffer7_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVertexBuffer7_Lock(p,a,b,c) (p)->lpVtbl->Lock(p,a,b,c) -#define IDirect3DVertexBuffer7_Unlock(p) (p)->lpVtbl->Unlock(p) -#define IDirect3DVertexBuffer7_ProcessVertices(p,a,b,c,d,e,f,g) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e,f,g) -#define IDirect3DVertexBuffer7_GetVertexBufferDesc(p,a) (p)->lpVtbl->GetVertexBufferDesc(p,a) -#define IDirect3DVertexBuffer7_Optimize(p,a,b) (p)->lpVtbl->Optimize(p,a,b) -#define IDirect3DVertexBuffer7_ProcessVerticesStrided(p,a,b,c,d,e,f,g) (p)->lpVtbl->ProcessVerticesStrided(p,a,b,c,d,e,f,g) -#else -#define IDirect3DVertexBuffer7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVertexBuffer7_AddRef(p) (p)->AddRef() -#define IDirect3DVertexBuffer7_Release(p) (p)->Release() -#define IDirect3DVertexBuffer7_Lock(p,a,b,c) (p)->Lock(a,b,c) -#define IDirect3DVertexBuffer7_Unlock(p) (p)->Unlock() -#define IDirect3DVertexBuffer7_ProcessVertices(p,a,b,c,d,e,f,g) (p)->ProcessVertices(a,b,c,d,e,f,g) -#define IDirect3DVertexBuffer7_GetVertexBufferDesc(p,a) (p)->GetVertexBufferDesc(a) -#define IDirect3DVertexBuffer7_Optimize(p,a,b) (p)->Optimize(a,b) -#define IDirect3DVertexBuffer7_ProcessVerticesStrided(p,a,b,c,d,e,f,g) (p)->ProcessVerticesStrided(a,b,c,d,e,f,g) -#endif -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -#if(DIRECT3D_VERSION >= 0x0500) -/**************************************************************************** - * - * Flags for IDirect3DDevice::NextViewport - * - ****************************************************************************/ - -/* - * Return the next viewport - */ -#define D3DNEXT_NEXT 0x00000001l - -/* - * Return the first viewport - */ -#define D3DNEXT_HEAD 0x00000002l - -/* - * Return the last viewport - */ -#define D3DNEXT_TAIL 0x00000004l - - -/**************************************************************************** - * - * Flags for DrawPrimitive/DrawIndexedPrimitive - * Also valid for Begin/BeginIndexed - * Also valid for VertexBuffer::CreateVertexBuffer - ****************************************************************************/ - -/* - * Wait until the device is ready to draw the primitive - * This will cause DP to not return DDERR_WASSTILLDRAWING - */ -#define D3DDP_WAIT 0x00000001l -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if (DIRECT3D_VERSION == 0x0500) -/* - * Hint that it is acceptable to render the primitive out of order. - */ -#define D3DDP_OUTOFORDER 0x00000002l -#endif - - -#if(DIRECT3D_VERSION >= 0x0500) -/* - * Hint that the primitives have been clipped by the application. - */ -#define D3DDP_DONOTCLIP 0x00000004l - -/* - * Hint that the extents need not be updated. - */ -#define D3DDP_DONOTUPDATEEXTENTS 0x00000008l -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if(DIRECT3D_VERSION >= 0x0600) - -/* - * Hint that the lighting should not be applied on vertices. - */ - -#define D3DDP_DONOTLIGHT 0x00000010l - -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -/* - * Direct3D Errors - * DirectDraw error codes are used when errors not specified here. - */ -#define D3D_OK DD_OK -#define D3DERR_BADMAJORVERSION MAKE_DDHRESULT(700) -#define D3DERR_BADMINORVERSION MAKE_DDHRESULT(701) - -#if(DIRECT3D_VERSION >= 0x0500) -/* - * An invalid device was requested by the application. - */ -#define D3DERR_INVALID_DEVICE MAKE_DDHRESULT(705) -#define D3DERR_INITFAILED MAKE_DDHRESULT(706) - -/* - * SetRenderTarget attempted on a device that was - * QI'd off the render target. - */ -#define D3DERR_DEVICEAGGREGATED MAKE_DDHRESULT(707) -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#define D3DERR_EXECUTE_CREATE_FAILED MAKE_DDHRESULT(710) -#define D3DERR_EXECUTE_DESTROY_FAILED MAKE_DDHRESULT(711) -#define D3DERR_EXECUTE_LOCK_FAILED MAKE_DDHRESULT(712) -#define D3DERR_EXECUTE_UNLOCK_FAILED MAKE_DDHRESULT(713) -#define D3DERR_EXECUTE_LOCKED MAKE_DDHRESULT(714) -#define D3DERR_EXECUTE_NOT_LOCKED MAKE_DDHRESULT(715) - -#define D3DERR_EXECUTE_FAILED MAKE_DDHRESULT(716) -#define D3DERR_EXECUTE_CLIPPED_FAILED MAKE_DDHRESULT(717) - -#define D3DERR_TEXTURE_NO_SUPPORT MAKE_DDHRESULT(720) -#define D3DERR_TEXTURE_CREATE_FAILED MAKE_DDHRESULT(721) -#define D3DERR_TEXTURE_DESTROY_FAILED MAKE_DDHRESULT(722) -#define D3DERR_TEXTURE_LOCK_FAILED MAKE_DDHRESULT(723) -#define D3DERR_TEXTURE_UNLOCK_FAILED MAKE_DDHRESULT(724) -#define D3DERR_TEXTURE_LOAD_FAILED MAKE_DDHRESULT(725) -#define D3DERR_TEXTURE_SWAP_FAILED MAKE_DDHRESULT(726) -#define D3DERR_TEXTURE_LOCKED MAKE_DDHRESULT(727) -#define D3DERR_TEXTURE_NOT_LOCKED MAKE_DDHRESULT(728) -#define D3DERR_TEXTURE_GETSURF_FAILED MAKE_DDHRESULT(729) - -#define D3DERR_MATRIX_CREATE_FAILED MAKE_DDHRESULT(730) -#define D3DERR_MATRIX_DESTROY_FAILED MAKE_DDHRESULT(731) -#define D3DERR_MATRIX_SETDATA_FAILED MAKE_DDHRESULT(732) -#define D3DERR_MATRIX_GETDATA_FAILED MAKE_DDHRESULT(733) -#define D3DERR_SETVIEWPORTDATA_FAILED MAKE_DDHRESULT(734) - -#if(DIRECT3D_VERSION >= 0x0500) -#define D3DERR_INVALIDCURRENTVIEWPORT MAKE_DDHRESULT(735) -#define D3DERR_INVALIDPRIMITIVETYPE MAKE_DDHRESULT(736) -#define D3DERR_INVALIDVERTEXTYPE MAKE_DDHRESULT(737) -#define D3DERR_TEXTURE_BADSIZE MAKE_DDHRESULT(738) -#define D3DERR_INVALIDRAMPTEXTURE MAKE_DDHRESULT(739) -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#define D3DERR_MATERIAL_CREATE_FAILED MAKE_DDHRESULT(740) -#define D3DERR_MATERIAL_DESTROY_FAILED MAKE_DDHRESULT(741) -#define D3DERR_MATERIAL_SETDATA_FAILED MAKE_DDHRESULT(742) -#define D3DERR_MATERIAL_GETDATA_FAILED MAKE_DDHRESULT(743) - -#if(DIRECT3D_VERSION >= 0x0500) -#define D3DERR_INVALIDPALETTE MAKE_DDHRESULT(744) - -#define D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY MAKE_DDHRESULT(745) -#define D3DERR_ZBUFF_NEEDS_VIDEOMEMORY MAKE_DDHRESULT(746) -#define D3DERR_SURFACENOTINVIDMEM MAKE_DDHRESULT(747) -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#define D3DERR_LIGHT_SET_FAILED MAKE_DDHRESULT(750) -#if(DIRECT3D_VERSION >= 0x0500) -#define D3DERR_LIGHTHASVIEWPORT MAKE_DDHRESULT(751) -#define D3DERR_LIGHTNOTINTHISVIEWPORT MAKE_DDHRESULT(752) -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#define D3DERR_SCENE_IN_SCENE MAKE_DDHRESULT(760) -#define D3DERR_SCENE_NOT_IN_SCENE MAKE_DDHRESULT(761) -#define D3DERR_SCENE_BEGIN_FAILED MAKE_DDHRESULT(762) -#define D3DERR_SCENE_END_FAILED MAKE_DDHRESULT(763) - -#if(DIRECT3D_VERSION >= 0x0500) -#define D3DERR_INBEGIN MAKE_DDHRESULT(770) -#define D3DERR_NOTINBEGIN MAKE_DDHRESULT(771) -#define D3DERR_NOVIEWPORTS MAKE_DDHRESULT(772) -#define D3DERR_VIEWPORTDATANOTSET MAKE_DDHRESULT(773) -#define D3DERR_VIEWPORTHASNODEVICE MAKE_DDHRESULT(774) -#define D3DERR_NOCURRENTVIEWPORT MAKE_DDHRESULT(775) -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if(DIRECT3D_VERSION >= 0x0600) -#define D3DERR_INVALIDVERTEXFORMAT MAKE_DDHRESULT(2048) - -/* - * Attempted to CreateTexture on a surface that had a color key - */ -#define D3DERR_COLORKEYATTACHED MAKE_DDHRESULT(2050) - -#define D3DERR_VERTEXBUFFEROPTIMIZED MAKE_DDHRESULT(2060) -#define D3DERR_VBUF_CREATE_FAILED MAKE_DDHRESULT(2061) -#define D3DERR_VERTEXBUFFERLOCKED MAKE_DDHRESULT(2062) -#define D3DERR_VERTEXBUFFERUNLOCKFAILED MAKE_DDHRESULT(2063) - -#define D3DERR_ZBUFFER_NOTPRESENT MAKE_DDHRESULT(2070) -#define D3DERR_STENCILBUFFER_NOTPRESENT MAKE_DDHRESULT(2071) - -#define D3DERR_WRONGTEXTUREFORMAT MAKE_DDHRESULT(2072) -#define D3DERR_UNSUPPORTEDCOLOROPERATION MAKE_DDHRESULT(2073) -#define D3DERR_UNSUPPORTEDCOLORARG MAKE_DDHRESULT(2074) -#define D3DERR_UNSUPPORTEDALPHAOPERATION MAKE_DDHRESULT(2075) -#define D3DERR_UNSUPPORTEDALPHAARG MAKE_DDHRESULT(2076) -#define D3DERR_TOOMANYOPERATIONS MAKE_DDHRESULT(2077) -#define D3DERR_CONFLICTINGTEXTUREFILTER MAKE_DDHRESULT(2078) -#define D3DERR_UNSUPPORTEDFACTORVALUE MAKE_DDHRESULT(2079) -#define D3DERR_CONFLICTINGRENDERSTATE MAKE_DDHRESULT(2081) -#define D3DERR_UNSUPPORTEDTEXTUREFILTER MAKE_DDHRESULT(2082) -#define D3DERR_TOOMANYPRIMITIVES MAKE_DDHRESULT(2083) -#define D3DERR_INVALIDMATRIX MAKE_DDHRESULT(2084) -#define D3DERR_TOOMANYVERTICES MAKE_DDHRESULT(2085) -#define D3DERR_CONFLICTINGTEXTUREPALETTE MAKE_DDHRESULT(2086) - -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -#if(DIRECT3D_VERSION >= 0x0700) -#define D3DERR_INVALIDSTATEBLOCK MAKE_DDHRESULT(2100) -#define D3DERR_INBEGINSTATEBLOCK MAKE_DDHRESULT(2101) -#define D3DERR_NOTINBEGINSTATEBLOCK MAKE_DDHRESULT(2102) -#endif /* DIRECT3D_VERSION >= 0x0700 */ - - -#ifdef __cplusplus -}; -#endif - -#endif /* (DIRECT3D_VERSION < 0x0800) */ -#endif /* _D3D_H_ */ - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3d.h + * Content: Direct3D include file + * + ****************************************************************************/ + +#ifndef _D3D_H_ +#define _D3D_H_ + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0700 +#endif + +// include this file content only if compiling for <=DX7 interfaces +#if(DIRECT3D_VERSION < 0x0800) + + +#include + +#define COM_NO_WINDOWS_H +#include + +#define D3DAPI WINAPI + +/* + * Interface IID's + */ +#if defined( _WIN32 ) && !defined( _NO_COM) +DEFINE_GUID( IID_IDirect3D, 0x3BBA0080,0x2421,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56 ); +#if(DIRECT3D_VERSION >= 0x0500) +DEFINE_GUID( IID_IDirect3D2, 0x6aae1ec1,0x662a,0x11d0,0x88,0x9d,0x00,0xaa,0x00,0xbb,0xb7,0x6a); +#endif /* DIRECT3D_VERSION >= 0x0500 */ +#if(DIRECT3D_VERSION >= 0x0600) +DEFINE_GUID( IID_IDirect3D3, 0xbb223240,0xe72b,0x11d0,0xa9,0xb4,0x00,0xaa,0x00,0xc0,0x99,0x3e); +#endif /* DIRECT3D_VERSION >= 0x0600 */ +#if(DIRECT3D_VERSION >= 0x0700) +DEFINE_GUID( IID_IDirect3D7, 0xf5049e77,0x4861,0x11d2,0xa4,0x7,0x0,0xa0,0xc9,0x6,0x29,0xa8); +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +#if(DIRECT3D_VERSION >= 0x0500) +DEFINE_GUID( IID_IDirect3DRampDevice, 0xF2086B20,0x259F,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56 ); +DEFINE_GUID( IID_IDirect3DRGBDevice, 0xA4665C60,0x2673,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56 ); +DEFINE_GUID( IID_IDirect3DHALDevice, 0x84E63dE0,0x46AA,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E ); +DEFINE_GUID( IID_IDirect3DMMXDevice, 0x881949a1,0xd6f3,0x11d0,0x89,0xab,0x00,0xa0,0xc9,0x05,0x41,0x29 ); +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if(DIRECT3D_VERSION >= 0x0600) +DEFINE_GUID( IID_IDirect3DRefDevice, 0x50936643, 0x13e9, 0x11d1, 0x89, 0xaa, 0x0, 0xa0, 0xc9, 0x5, 0x41, 0x29); +DEFINE_GUID( IID_IDirect3DNullDevice, 0x8767df22, 0xbacc, 0x11d1, 0x89, 0x69, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); +#endif /* DIRECT3D_VERSION >= 0x0600 */ +#if(DIRECT3D_VERSION >= 0x0700) +DEFINE_GUID( IID_IDirect3DTnLHalDevice, 0xf5049e78, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +/* + * Internal Guid to distinguish requested MMX from MMX being used as an RGB rasterizer + */ + +DEFINE_GUID( IID_IDirect3DDevice, 0x64108800,0x957d,0X11d0,0x89,0xab,0x00,0xa0,0xc9,0x05,0x41,0x29 ); +#if(DIRECT3D_VERSION >= 0x0500) +DEFINE_GUID( IID_IDirect3DDevice2, 0x93281501, 0x8cf8, 0x11d0, 0x89, 0xab, 0x0, 0xa0, 0xc9, 0x5, 0x41, 0x29); +#endif /* DIRECT3D_VERSION >= 0x0500 */ +#if(DIRECT3D_VERSION >= 0x0600) +DEFINE_GUID( IID_IDirect3DDevice3, 0xb0ab3b60, 0x33d7, 0x11d1, 0xa9, 0x81, 0x0, 0xc0, 0x4f, 0xd7, 0xb1, 0x74); +#endif /* DIRECT3D_VERSION >= 0x0600 */ +#if(DIRECT3D_VERSION >= 0x0700) +DEFINE_GUID( IID_IDirect3DDevice7, 0xf5049e79, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +DEFINE_GUID( IID_IDirect3DTexture, 0x2CDCD9E0,0x25A0,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56 ); +#if(DIRECT3D_VERSION >= 0x0500) +DEFINE_GUID( IID_IDirect3DTexture2, 0x93281502, 0x8cf8, 0x11d0, 0x89, 0xab, 0x0, 0xa0, 0xc9, 0x5, 0x41, 0x29); +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +DEFINE_GUID( IID_IDirect3DLight, 0x4417C142,0x33AD,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E ); + +DEFINE_GUID( IID_IDirect3DMaterial, 0x4417C144,0x33AD,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E ); +#if(DIRECT3D_VERSION >= 0x0500) +DEFINE_GUID( IID_IDirect3DMaterial2, 0x93281503, 0x8cf8, 0x11d0, 0x89, 0xab, 0x0, 0xa0, 0xc9, 0x5, 0x41, 0x29); +#endif /* DIRECT3D_VERSION >= 0x0500 */ +#if(DIRECT3D_VERSION >= 0x0600) +DEFINE_GUID( IID_IDirect3DMaterial3, 0xca9c46f4, 0xd3c5, 0x11d1, 0xb7, 0x5a, 0x0, 0x60, 0x8, 0x52, 0xb3, 0x12); +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +DEFINE_GUID( IID_IDirect3DExecuteBuffer,0x4417C145,0x33AD,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E ); +DEFINE_GUID( IID_IDirect3DViewport, 0x4417C146,0x33AD,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E ); +#if(DIRECT3D_VERSION >= 0x0500) +DEFINE_GUID( IID_IDirect3DViewport2, 0x93281500, 0x8cf8, 0x11d0, 0x89, 0xab, 0x0, 0xa0, 0xc9, 0x5, 0x41, 0x29); +#endif /* DIRECT3D_VERSION >= 0x0500 */ +#if(DIRECT3D_VERSION >= 0x0600) +DEFINE_GUID( IID_IDirect3DViewport3, 0xb0ab3b61, 0x33d7, 0x11d1, 0xa9, 0x81, 0x0, 0xc0, 0x4f, 0xd7, 0xb1, 0x74); +#endif /* DIRECT3D_VERSION >= 0x0600 */ +#if(DIRECT3D_VERSION >= 0x0600) +DEFINE_GUID( IID_IDirect3DVertexBuffer, 0x7a503555, 0x4a83, 0x11d1, 0xa5, 0xdb, 0x0, 0xa0, 0xc9, 0x3, 0x67, 0xf8); +#endif /* DIRECT3D_VERSION >= 0x0600 */ +#if(DIRECT3D_VERSION >= 0x0700) +DEFINE_GUID( IID_IDirect3DVertexBuffer7, 0xf5049e7d, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); +#endif /* DIRECT3D_VERSION >= 0x0700 */ +#endif + +#ifdef __cplusplus +struct IDirect3D; +struct IDirect3DDevice; +struct IDirect3DLight; +struct IDirect3DMaterial; +struct IDirect3DExecuteBuffer; +struct IDirect3DTexture; +struct IDirect3DViewport; +typedef struct IDirect3D *LPDIRECT3D; +typedef struct IDirect3DDevice *LPDIRECT3DDEVICE; +typedef struct IDirect3DExecuteBuffer *LPDIRECT3DEXECUTEBUFFER; +typedef struct IDirect3DLight *LPDIRECT3DLIGHT; +typedef struct IDirect3DMaterial *LPDIRECT3DMATERIAL; +typedef struct IDirect3DTexture *LPDIRECT3DTEXTURE; +typedef struct IDirect3DViewport *LPDIRECT3DVIEWPORT; + +#if(DIRECT3D_VERSION >= 0x0500) +struct IDirect3D2; +struct IDirect3DDevice2; +struct IDirect3DMaterial2; +struct IDirect3DTexture2; +struct IDirect3DViewport2; +typedef struct IDirect3D2 *LPDIRECT3D2; +typedef struct IDirect3DDevice2 *LPDIRECT3DDEVICE2; +typedef struct IDirect3DMaterial2 *LPDIRECT3DMATERIAL2; +typedef struct IDirect3DTexture2 *LPDIRECT3DTEXTURE2; +typedef struct IDirect3DViewport2 *LPDIRECT3DVIEWPORT2; +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if(DIRECT3D_VERSION >= 0x0600) +struct IDirect3D3; +struct IDirect3DDevice3; +struct IDirect3DMaterial3; +struct IDirect3DViewport3; +struct IDirect3DVertexBuffer; +typedef struct IDirect3D3 *LPDIRECT3D3; +typedef struct IDirect3DDevice3 *LPDIRECT3DDEVICE3; +typedef struct IDirect3DMaterial3 *LPDIRECT3DMATERIAL3; +typedef struct IDirect3DViewport3 *LPDIRECT3DVIEWPORT3; +typedef struct IDirect3DVertexBuffer *LPDIRECT3DVERTEXBUFFER; +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +#if(DIRECT3D_VERSION >= 0x0700) +struct IDirect3D7; +struct IDirect3DDevice7; +struct IDirect3DVertexBuffer7; +typedef struct IDirect3D7 *LPDIRECT3D7; +typedef struct IDirect3DDevice7 *LPDIRECT3DDEVICE7; +typedef struct IDirect3DVertexBuffer7 *LPDIRECT3DVERTEXBUFFER7; +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +#else + +typedef struct IDirect3D *LPDIRECT3D; +typedef struct IDirect3DDevice *LPDIRECT3DDEVICE; +typedef struct IDirect3DExecuteBuffer *LPDIRECT3DEXECUTEBUFFER; +typedef struct IDirect3DLight *LPDIRECT3DLIGHT; +typedef struct IDirect3DMaterial *LPDIRECT3DMATERIAL; +typedef struct IDirect3DTexture *LPDIRECT3DTEXTURE; +typedef struct IDirect3DViewport *LPDIRECT3DVIEWPORT; + +#if(DIRECT3D_VERSION >= 0x0500) +typedef struct IDirect3D2 *LPDIRECT3D2; +typedef struct IDirect3DDevice2 *LPDIRECT3DDEVICE2; +typedef struct IDirect3DMaterial2 *LPDIRECT3DMATERIAL2; +typedef struct IDirect3DTexture2 *LPDIRECT3DTEXTURE2; +typedef struct IDirect3DViewport2 *LPDIRECT3DVIEWPORT2; +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if(DIRECT3D_VERSION >= 0x0600) +typedef struct IDirect3D3 *LPDIRECT3D3; +typedef struct IDirect3DDevice3 *LPDIRECT3DDEVICE3; +typedef struct IDirect3DMaterial3 *LPDIRECT3DMATERIAL3; +typedef struct IDirect3DViewport3 *LPDIRECT3DVIEWPORT3; +typedef struct IDirect3DVertexBuffer *LPDIRECT3DVERTEXBUFFER; +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +#if(DIRECT3D_VERSION >= 0x0700) +typedef struct IDirect3D7 *LPDIRECT3D7; +typedef struct IDirect3DDevice7 *LPDIRECT3DDEVICE7; +typedef struct IDirect3DVertexBuffer7 *LPDIRECT3DVERTEXBUFFER7; +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +#endif + +#include "d3dtypes.h" +#include "d3dcaps.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Direct3D interfaces + */ +#undef INTERFACE +#define INTERFACE IDirect3D + +DECLARE_INTERFACE_(IDirect3D, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3D methods ***/ + STDMETHOD(Initialize)(THIS_ REFCLSID) PURE; + STDMETHOD(EnumDevices)(THIS_ LPD3DENUMDEVICESCALLBACK,LPVOID) PURE; + STDMETHOD(CreateLight)(THIS_ LPDIRECT3DLIGHT*,IUnknown*) PURE; + STDMETHOD(CreateMaterial)(THIS_ LPDIRECT3DMATERIAL*,IUnknown*) PURE; + STDMETHOD(CreateViewport)(THIS_ LPDIRECT3DVIEWPORT*,IUnknown*) PURE; + STDMETHOD(FindDevice)(THIS_ LPD3DFINDDEVICESEARCH,LPD3DFINDDEVICERESULT) PURE; +}; + +typedef struct IDirect3D *LPDIRECT3D; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3D_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3D_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3D_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3D_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#define IDirect3D_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevices(p,a,b) +#define IDirect3D_CreateLight(p,a,b) (p)->lpVtbl->CreateLight(p,a,b) +#define IDirect3D_CreateMaterial(p,a,b) (p)->lpVtbl->CreateMaterial(p,a,b) +#define IDirect3D_CreateViewport(p,a,b) (p)->lpVtbl->CreateViewport(p,a,b) +#define IDirect3D_FindDevice(p,a,b) (p)->lpVtbl->FindDevice(p,a,b) +#else +#define IDirect3D_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3D_AddRef(p) (p)->AddRef() +#define IDirect3D_Release(p) (p)->Release() +#define IDirect3D_Initialize(p,a) (p)->Initialize(a) +#define IDirect3D_EnumDevices(p,a,b) (p)->EnumDevices(a,b) +#define IDirect3D_CreateLight(p,a,b) (p)->CreateLight(a,b) +#define IDirect3D_CreateMaterial(p,a,b) (p)->CreateMaterial(a,b) +#define IDirect3D_CreateViewport(p,a,b) (p)->CreateViewport(a,b) +#define IDirect3D_FindDevice(p,a,b) (p)->FindDevice(a,b) +#endif + +#if(DIRECT3D_VERSION >= 0x0500) +#undef INTERFACE +#define INTERFACE IDirect3D2 + +DECLARE_INTERFACE_(IDirect3D2, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3D2 methods ***/ + STDMETHOD(EnumDevices)(THIS_ LPD3DENUMDEVICESCALLBACK,LPVOID) PURE; + STDMETHOD(CreateLight)(THIS_ LPDIRECT3DLIGHT*,IUnknown*) PURE; + STDMETHOD(CreateMaterial)(THIS_ LPDIRECT3DMATERIAL2*,IUnknown*) PURE; + STDMETHOD(CreateViewport)(THIS_ LPDIRECT3DVIEWPORT2*,IUnknown*) PURE; + STDMETHOD(FindDevice)(THIS_ LPD3DFINDDEVICESEARCH,LPD3DFINDDEVICERESULT) PURE; + STDMETHOD(CreateDevice)(THIS_ REFCLSID,LPDIRECTDRAWSURFACE,LPDIRECT3DDEVICE2*) PURE; +}; + +typedef struct IDirect3D2 *LPDIRECT3D2; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3D2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3D2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3D2_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3D2_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevices(p,a,b) +#define IDirect3D2_CreateLight(p,a,b) (p)->lpVtbl->CreateLight(p,a,b) +#define IDirect3D2_CreateMaterial(p,a,b) (p)->lpVtbl->CreateMaterial(p,a,b) +#define IDirect3D2_CreateViewport(p,a,b) (p)->lpVtbl->CreateViewport(p,a,b) +#define IDirect3D2_FindDevice(p,a,b) (p)->lpVtbl->FindDevice(p,a,b) +#define IDirect3D2_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) +#else +#define IDirect3D2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3D2_AddRef(p) (p)->AddRef() +#define IDirect3D2_Release(p) (p)->Release() +#define IDirect3D2_EnumDevices(p,a,b) (p)->EnumDevices(a,b) +#define IDirect3D2_CreateLight(p,a,b) (p)->CreateLight(a,b) +#define IDirect3D2_CreateMaterial(p,a,b) (p)->CreateMaterial(a,b) +#define IDirect3D2_CreateViewport(p,a,b) (p)->CreateViewport(a,b) +#define IDirect3D2_FindDevice(p,a,b) (p)->FindDevice(a,b) +#define IDirect3D2_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) +#endif +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if(DIRECT3D_VERSION >= 0x0600) +#undef INTERFACE +#define INTERFACE IDirect3D3 + +DECLARE_INTERFACE_(IDirect3D3, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3D3 methods ***/ + STDMETHOD(EnumDevices)(THIS_ LPD3DENUMDEVICESCALLBACK,LPVOID) PURE; + STDMETHOD(CreateLight)(THIS_ LPDIRECT3DLIGHT*,LPUNKNOWN) PURE; + STDMETHOD(CreateMaterial)(THIS_ LPDIRECT3DMATERIAL3*,LPUNKNOWN) PURE; + STDMETHOD(CreateViewport)(THIS_ LPDIRECT3DVIEWPORT3*,LPUNKNOWN) PURE; + STDMETHOD(FindDevice)(THIS_ LPD3DFINDDEVICESEARCH,LPD3DFINDDEVICERESULT) PURE; + STDMETHOD(CreateDevice)(THIS_ REFCLSID,LPDIRECTDRAWSURFACE4,LPDIRECT3DDEVICE3*,LPUNKNOWN) PURE; + STDMETHOD(CreateVertexBuffer)(THIS_ LPD3DVERTEXBUFFERDESC,LPDIRECT3DVERTEXBUFFER*,DWORD,LPUNKNOWN) PURE; + STDMETHOD(EnumZBufferFormats)(THIS_ REFCLSID,LPD3DENUMPIXELFORMATSCALLBACK,LPVOID) PURE; + STDMETHOD(EvictManagedTextures)(THIS) PURE; +}; + +typedef struct IDirect3D3 *LPDIRECT3D3; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3D3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3D3_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3D3_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3D3_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevices(p,a,b) +#define IDirect3D3_CreateLight(p,a,b) (p)->lpVtbl->CreateLight(p,a,b) +#define IDirect3D3_CreateMaterial(p,a,b) (p)->lpVtbl->CreateMaterial(p,a,b) +#define IDirect3D3_CreateViewport(p,a,b) (p)->lpVtbl->CreateViewport(p,a,b) +#define IDirect3D3_FindDevice(p,a,b) (p)->lpVtbl->FindDevice(p,a,b) +#define IDirect3D3_CreateDevice(p,a,b,c,d) (p)->lpVtbl->CreateDevice(p,a,b,c,d) +#define IDirect3D3_CreateVertexBuffer(p,a,b,c,d) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d) +#define IDirect3D3_EnumZBufferFormats(p,a,b,c) (p)->lpVtbl->EnumZBufferFormats(p,a,b,c) +#define IDirect3D3_EvictManagedTextures(p) (p)->lpVtbl->EvictManagedTextures(p) +#else +#define IDirect3D3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3D3_AddRef(p) (p)->AddRef() +#define IDirect3D3_Release(p) (p)->Release() +#define IDirect3D3_EnumDevices(p,a,b) (p)->EnumDevices(a,b) +#define IDirect3D3_CreateLight(p,a,b) (p)->CreateLight(a,b) +#define IDirect3D3_CreateMaterial(p,a,b) (p)->CreateMaterial(a,b) +#define IDirect3D3_CreateViewport(p,a,b) (p)->CreateViewport(a,b) +#define IDirect3D3_FindDevice(p,a,b) (p)->FindDevice(a,b) +#define IDirect3D3_CreateDevice(p,a,b,c,d) (p)->CreateDevice(a,b,c,d) +#define IDirect3D3_CreateVertexBuffer(p,a,b,c,d) (p)->CreateVertexBuffer(a,b,c,d) +#define IDirect3D3_EnumZBufferFormats(p,a,b,c) (p)->EnumZBufferFormats(a,b,c) +#define IDirect3D3_EvictManagedTextures(p) (p)->EvictManagedTextures() +#endif +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +#if(DIRECT3D_VERSION >= 0x0700) +#undef INTERFACE +#define INTERFACE IDirect3D7 + +DECLARE_INTERFACE_(IDirect3D7, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3D7 methods ***/ + STDMETHOD(EnumDevices)(THIS_ LPD3DENUMDEVICESCALLBACK7,LPVOID) PURE; + STDMETHOD(CreateDevice)(THIS_ REFCLSID,LPDIRECTDRAWSURFACE7,LPDIRECT3DDEVICE7*) PURE; + STDMETHOD(CreateVertexBuffer)(THIS_ LPD3DVERTEXBUFFERDESC,LPDIRECT3DVERTEXBUFFER7*,DWORD) PURE; + STDMETHOD(EnumZBufferFormats)(THIS_ REFCLSID,LPD3DENUMPIXELFORMATSCALLBACK,LPVOID) PURE; + STDMETHOD(EvictManagedTextures)(THIS) PURE; +}; + +typedef struct IDirect3D7 *LPDIRECT3D7; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3D7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3D7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3D7_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3D7_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevices(p,a,b) +#define IDirect3D7_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) +#define IDirect3D7_CreateVertexBuffer(p,a,b,c) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c) +#define IDirect3D7_EnumZBufferFormats(p,a,b,c) (p)->lpVtbl->EnumZBufferFormats(p,a,b,c) +#define IDirect3D7_EvictManagedTextures(p) (p)->lpVtbl->EvictManagedTextures(p) +#else +#define IDirect3D7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3D7_AddRef(p) (p)->AddRef() +#define IDirect3D7_Release(p) (p)->Release() +#define IDirect3D7_EnumDevices(p,a,b) (p)->EnumDevices(a,b) +#define IDirect3D7_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) +#define IDirect3D7_CreateVertexBuffer(p,a,b,c) (p)->CreateVertexBuffer(a,b,c) +#define IDirect3D7_EnumZBufferFormats(p,a,b,c) (p)->EnumZBufferFormats(a,b,c) +#define IDirect3D7_EvictManagedTextures(p) (p)->EvictManagedTextures() +#endif +#endif /* DIRECT3D_VERSION >= 0x0700 */ +/* + * Direct3D Device interfaces + */ +#undef INTERFACE +#define INTERFACE IDirect3DDevice + +DECLARE_INTERFACE_(IDirect3DDevice, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DDevice methods ***/ + STDMETHOD(Initialize)(THIS_ LPDIRECT3D,LPGUID,LPD3DDEVICEDESC) PURE; + STDMETHOD(GetCaps)(THIS_ LPD3DDEVICEDESC,LPD3DDEVICEDESC) PURE; + STDMETHOD(SwapTextureHandles)(THIS_ LPDIRECT3DTEXTURE,LPDIRECT3DTEXTURE) PURE; + STDMETHOD(CreateExecuteBuffer)(THIS_ LPD3DEXECUTEBUFFERDESC,LPDIRECT3DEXECUTEBUFFER*,IUnknown*) PURE; + STDMETHOD(GetStats)(THIS_ LPD3DSTATS) PURE; + STDMETHOD(Execute)(THIS_ LPDIRECT3DEXECUTEBUFFER,LPDIRECT3DVIEWPORT,DWORD) PURE; + STDMETHOD(AddViewport)(THIS_ LPDIRECT3DVIEWPORT) PURE; + STDMETHOD(DeleteViewport)(THIS_ LPDIRECT3DVIEWPORT) PURE; + STDMETHOD(NextViewport)(THIS_ LPDIRECT3DVIEWPORT,LPDIRECT3DVIEWPORT*,DWORD) PURE; + STDMETHOD(Pick)(THIS_ LPDIRECT3DEXECUTEBUFFER,LPDIRECT3DVIEWPORT,DWORD,LPD3DRECT) PURE; + STDMETHOD(GetPickRecords)(THIS_ LPDWORD,LPD3DPICKRECORD) PURE; + STDMETHOD(EnumTextureFormats)(THIS_ LPD3DENUMTEXTUREFORMATSCALLBACK,LPVOID) PURE; + STDMETHOD(CreateMatrix)(THIS_ LPD3DMATRIXHANDLE) PURE; + STDMETHOD(SetMatrix)(THIS_ D3DMATRIXHANDLE,const LPD3DMATRIX) PURE; + STDMETHOD(GetMatrix)(THIS_ D3DMATRIXHANDLE,LPD3DMATRIX) PURE; + STDMETHOD(DeleteMatrix)(THIS_ D3DMATRIXHANDLE) PURE; + STDMETHOD(BeginScene)(THIS) PURE; + STDMETHOD(EndScene)(THIS) PURE; + STDMETHOD(GetDirect3D)(THIS_ LPDIRECT3D*) PURE; +}; + +typedef struct IDirect3DDevice *LPDIRECT3DDEVICE; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DDevice_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DDevice_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DDevice_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirect3DDevice_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) +#define IDirect3DDevice_SwapTextureHandles(p,a,b) (p)->lpVtbl->SwapTextureHandles(p,a,b) +#define IDirect3DDevice_CreateExecuteBuffer(p,a,b,c) (p)->lpVtbl->CreateExecuteBuffer(p,a,b,c) +#define IDirect3DDevice_GetStats(p,a) (p)->lpVtbl->GetStats(p,a) +#define IDirect3DDevice_Execute(p,a,b,c) (p)->lpVtbl->Execute(p,a,b,c) +#define IDirect3DDevice_AddViewport(p,a) (p)->lpVtbl->AddViewport(p,a) +#define IDirect3DDevice_DeleteViewport(p,a) (p)->lpVtbl->DeleteViewport(p,a) +#define IDirect3DDevice_NextViewport(p,a,b,c) (p)->lpVtbl->NextViewport(p,a,b,c) +#define IDirect3DDevice_Pick(p,a,b,c,d) (p)->lpVtbl->Pick(p,a,b,c,d) +#define IDirect3DDevice_GetPickRecords(p,a,b) (p)->lpVtbl->GetPickRecords(p,a,b) +#define IDirect3DDevice_EnumTextureFormats(p,a,b) (p)->lpVtbl->EnumTextureFormats(p,a,b) +#define IDirect3DDevice_CreateMatrix(p,a) (p)->lpVtbl->CreateMatrix(p,a) +#define IDirect3DDevice_SetMatrix(p,a,b) (p)->lpVtbl->SetMatrix(p,a,b) +#define IDirect3DDevice_GetMatrix(p,a,b) (p)->lpVtbl->GetMatrix(p,a,b) +#define IDirect3DDevice_DeleteMatrix(p,a) (p)->lpVtbl->DeleteMatrix(p,a) +#define IDirect3DDevice_BeginScene(p) (p)->lpVtbl->BeginScene(p) +#define IDirect3DDevice_EndScene(p) (p)->lpVtbl->EndScene(p) +#define IDirect3DDevice_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) +#else +#define IDirect3DDevice_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DDevice_AddRef(p) (p)->AddRef() +#define IDirect3DDevice_Release(p) (p)->Release() +#define IDirect3DDevice_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirect3DDevice_GetCaps(p,a,b) (p)->GetCaps(a,b) +#define IDirect3DDevice_SwapTextureHandles(p,a,b) (p)->SwapTextureHandles(a,b) +#define IDirect3DDevice_CreateExecuteBuffer(p,a,b,c) (p)->CreateExecuteBuffer(a,b,c) +#define IDirect3DDevice_GetStats(p,a) (p)->GetStats(a) +#define IDirect3DDevice_Execute(p,a,b,c) (p)->Execute(a,b,c) +#define IDirect3DDevice_AddViewport(p,a) (p)->AddViewport(a) +#define IDirect3DDevice_DeleteViewport(p,a) (p)->DeleteViewport(a) +#define IDirect3DDevice_NextViewport(p,a,b,c) (p)->NextViewport(a,b,c) +#define IDirect3DDevice_Pick(p,a,b,c,d) (p)->Pick(a,b,c,d) +#define IDirect3DDevice_GetPickRecords(p,a,b) (p)->GetPickRecords(a,b) +#define IDirect3DDevice_EnumTextureFormats(p,a,b) (p)->EnumTextureFormats(a,b) +#define IDirect3DDevice_CreateMatrix(p,a) (p)->CreateMatrix(a) +#define IDirect3DDevice_SetMatrix(p,a,b) (p)->SetMatrix(a,b) +#define IDirect3DDevice_GetMatrix(p,a,b) (p)->GetMatrix(a,b) +#define IDirect3DDevice_DeleteMatrix(p,a) (p)->DeleteMatrix(a) +#define IDirect3DDevice_BeginScene(p) (p)->BeginScene() +#define IDirect3DDevice_EndScene(p) (p)->EndScene() +#define IDirect3DDevice_GetDirect3D(p,a) (p)->GetDirect3D(a) +#endif + +#if(DIRECT3D_VERSION >= 0x0500) +#undef INTERFACE +#define INTERFACE IDirect3DDevice2 + +DECLARE_INTERFACE_(IDirect3DDevice2, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DDevice2 methods ***/ + STDMETHOD(GetCaps)(THIS_ LPD3DDEVICEDESC,LPD3DDEVICEDESC) PURE; + STDMETHOD(SwapTextureHandles)(THIS_ LPDIRECT3DTEXTURE2,LPDIRECT3DTEXTURE2) PURE; + STDMETHOD(GetStats)(THIS_ LPD3DSTATS) PURE; + STDMETHOD(AddViewport)(THIS_ LPDIRECT3DVIEWPORT2) PURE; + STDMETHOD(DeleteViewport)(THIS_ LPDIRECT3DVIEWPORT2) PURE; + STDMETHOD(NextViewport)(THIS_ LPDIRECT3DVIEWPORT2,LPDIRECT3DVIEWPORT2*,DWORD) PURE; + STDMETHOD(EnumTextureFormats)(THIS_ LPD3DENUMTEXTUREFORMATSCALLBACK,LPVOID) PURE; + STDMETHOD(BeginScene)(THIS) PURE; + STDMETHOD(EndScene)(THIS) PURE; + STDMETHOD(GetDirect3D)(THIS_ LPDIRECT3D2*) PURE; + STDMETHOD(SetCurrentViewport)(THIS_ LPDIRECT3DVIEWPORT2) PURE; + STDMETHOD(GetCurrentViewport)(THIS_ LPDIRECT3DVIEWPORT2 *) PURE; + STDMETHOD(SetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE,DWORD) PURE; + STDMETHOD(GetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE *) PURE; + STDMETHOD(Begin)(THIS_ D3DPRIMITIVETYPE,D3DVERTEXTYPE,DWORD) PURE; + STDMETHOD(BeginIndexed)(THIS_ D3DPRIMITIVETYPE,D3DVERTEXTYPE,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(Vertex)(THIS_ LPVOID) PURE; + STDMETHOD(Index)(THIS_ WORD) PURE; + STDMETHOD(End)(THIS_ DWORD) PURE; + STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE,LPDWORD) PURE; + STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE,DWORD) PURE; + STDMETHOD(GetLightState)(THIS_ D3DLIGHTSTATETYPE,LPDWORD) PURE; + STDMETHOD(SetLightState)(THIS_ D3DLIGHTSTATETYPE,DWORD) PURE; + STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; + STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; + STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; + STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE,D3DVERTEXTYPE,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,D3DVERTEXTYPE,LPVOID,DWORD,LPWORD,DWORD,DWORD) PURE; + STDMETHOD(SetClipStatus)(THIS_ LPD3DCLIPSTATUS) PURE; + STDMETHOD(GetClipStatus)(THIS_ LPD3DCLIPSTATUS) PURE; +}; + +typedef struct IDirect3DDevice2 *LPDIRECT3DDEVICE2; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DDevice2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DDevice2_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DDevice2_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) +#define IDirect3DDevice2_SwapTextureHandles(p,a,b) (p)->lpVtbl->SwapTextureHandles(p,a,b) +#define IDirect3DDevice2_GetStats(p,a) (p)->lpVtbl->GetStats(p,a) +#define IDirect3DDevice2_AddViewport(p,a) (p)->lpVtbl->AddViewport(p,a) +#define IDirect3DDevice2_DeleteViewport(p,a) (p)->lpVtbl->DeleteViewport(p,a) +#define IDirect3DDevice2_NextViewport(p,a,b,c) (p)->lpVtbl->NextViewport(p,a,b,c) +#define IDirect3DDevice2_EnumTextureFormats(p,a,b) (p)->lpVtbl->EnumTextureFormats(p,a,b) +#define IDirect3DDevice2_BeginScene(p) (p)->lpVtbl->BeginScene(p) +#define IDirect3DDevice2_EndScene(p) (p)->lpVtbl->EndScene(p) +#define IDirect3DDevice2_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) +#define IDirect3DDevice2_SetCurrentViewport(p,a) (p)->lpVtbl->SetCurrentViewport(p,a) +#define IDirect3DDevice2_GetCurrentViewport(p,a) (p)->lpVtbl->GetCurrentViewport(p,a) +#define IDirect3DDevice2_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) +#define IDirect3DDevice2_GetRenderTarget(p,a) (p)->lpVtbl->GetRenderTarget(p,a) +#define IDirect3DDevice2_Begin(p,a,b,c) (p)->lpVtbl->Begin(p,a,b,c) +#define IDirect3DDevice2_BeginIndexed(p,a,b,c,d,e) (p)->lpVtbl->BeginIndexed(p,a,b,c,d,e) +#define IDirect3DDevice2_Vertex(p,a) (p)->lpVtbl->Vertex(p,a) +#define IDirect3DDevice2_Index(p,a) (p)->lpVtbl->Index(p,a) +#define IDirect3DDevice2_End(p,a) (p)->lpVtbl->End(p,a) +#define IDirect3DDevice2_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) +#define IDirect3DDevice2_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) +#define IDirect3DDevice2_GetLightState(p,a,b) (p)->lpVtbl->GetLightState(p,a,b) +#define IDirect3DDevice2_SetLightState(p,a,b) (p)->lpVtbl->SetLightState(p,a,b) +#define IDirect3DDevice2_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) +#define IDirect3DDevice2_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) +#define IDirect3DDevice2_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) +#define IDirect3DDevice2_DrawPrimitive(p,a,b,c,d,e) (p)->lpVtbl->DrawPrimitive(p,a,b,c,d,e) +#define IDirect3DDevice2_DrawIndexedPrimitive(p,a,b,c,d,e,f,g) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e,f,g) +#define IDirect3DDevice2_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) +#define IDirect3DDevice2_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) +#else +#define IDirect3DDevice2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DDevice2_AddRef(p) (p)->AddRef() +#define IDirect3DDevice2_Release(p) (p)->Release() +#define IDirect3DDevice2_GetCaps(p,a,b) (p)->GetCaps(a,b) +#define IDirect3DDevice2_SwapTextureHandles(p,a,b) (p)->SwapTextureHandles(a,b) +#define IDirect3DDevice2_GetStats(p,a) (p)->GetStats(a) +#define IDirect3DDevice2_AddViewport(p,a) (p)->AddViewport(a) +#define IDirect3DDevice2_DeleteViewport(p,a) (p)->DeleteViewport(a) +#define IDirect3DDevice2_NextViewport(p,a,b,c) (p)->NextViewport(a,b,c) +#define IDirect3DDevice2_EnumTextureFormats(p,a,b) (p)->EnumTextureFormats(a,b) +#define IDirect3DDevice2_BeginScene(p) (p)->BeginScene() +#define IDirect3DDevice2_EndScene(p) (p)->EndScene() +#define IDirect3DDevice2_GetDirect3D(p,a) (p)->GetDirect3D(a) +#define IDirect3DDevice2_SetCurrentViewport(p,a) (p)->SetCurrentViewport(a) +#define IDirect3DDevice2_GetCurrentViewport(p,a) (p)->GetCurrentViewport(a) +#define IDirect3DDevice2_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) +#define IDirect3DDevice2_GetRenderTarget(p,a) (p)->GetRenderTarget(a) +#define IDirect3DDevice2_Begin(p,a,b,c) (p)->Begin(a,b,c) +#define IDirect3DDevice2_BeginIndexed(p,a,b,c,d,e) (p)->BeginIndexed(a,b,c,d,e) +#define IDirect3DDevice2_Vertex(p,a) (p)->Vertex(a) +#define IDirect3DDevice2_Index(p,a) (p)->Index(a) +#define IDirect3DDevice2_End(p,a) (p)->End(a) +#define IDirect3DDevice2_GetRenderState(p,a,b) (p)->GetRenderState(a,b) +#define IDirect3DDevice2_SetRenderState(p,a,b) (p)->SetRenderState(a,b) +#define IDirect3DDevice2_GetLightState(p,a,b) (p)->GetLightState(a,b) +#define IDirect3DDevice2_SetLightState(p,a,b) (p)->SetLightState(a,b) +#define IDirect3DDevice2_SetTransform(p,a,b) (p)->SetTransform(a,b) +#define IDirect3DDevice2_GetTransform(p,a,b) (p)->GetTransform(a,b) +#define IDirect3DDevice2_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) +#define IDirect3DDevice2_DrawPrimitive(p,a,b,c,d,e) (p)->DrawPrimitive(a,b,c,d,e) +#define IDirect3DDevice2_DrawIndexedPrimitive(p,a,b,c,d,e,f,g) (p)->DrawIndexedPrimitive(a,b,c,d,e,f,g) +#define IDirect3DDevice2_SetClipStatus(p,a) (p)->SetClipStatus(a) +#define IDirect3DDevice2_GetClipStatus(p,a) (p)->GetClipStatus(a) +#endif +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if(DIRECT3D_VERSION >= 0x0600) +#undef INTERFACE +#define INTERFACE IDirect3DDevice3 + +DECLARE_INTERFACE_(IDirect3DDevice3, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DDevice3 methods ***/ + STDMETHOD(GetCaps)(THIS_ LPD3DDEVICEDESC,LPD3DDEVICEDESC) PURE; + STDMETHOD(GetStats)(THIS_ LPD3DSTATS) PURE; + STDMETHOD(AddViewport)(THIS_ LPDIRECT3DVIEWPORT3) PURE; + STDMETHOD(DeleteViewport)(THIS_ LPDIRECT3DVIEWPORT3) PURE; + STDMETHOD(NextViewport)(THIS_ LPDIRECT3DVIEWPORT3,LPDIRECT3DVIEWPORT3*,DWORD) PURE; + STDMETHOD(EnumTextureFormats)(THIS_ LPD3DENUMPIXELFORMATSCALLBACK,LPVOID) PURE; + STDMETHOD(BeginScene)(THIS) PURE; + STDMETHOD(EndScene)(THIS) PURE; + STDMETHOD(GetDirect3D)(THIS_ LPDIRECT3D3*) PURE; + STDMETHOD(SetCurrentViewport)(THIS_ LPDIRECT3DVIEWPORT3) PURE; + STDMETHOD(GetCurrentViewport)(THIS_ LPDIRECT3DVIEWPORT3 *) PURE; + STDMETHOD(SetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE4,DWORD) PURE; + STDMETHOD(GetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE4 *) PURE; + STDMETHOD(Begin)(THIS_ D3DPRIMITIVETYPE,DWORD,DWORD) PURE; + STDMETHOD(BeginIndexed)(THIS_ D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(Vertex)(THIS_ LPVOID) PURE; + STDMETHOD(Index)(THIS_ WORD) PURE; + STDMETHOD(End)(THIS_ DWORD) PURE; + STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE,LPDWORD) PURE; + STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE,DWORD) PURE; + STDMETHOD(GetLightState)(THIS_ D3DLIGHTSTATETYPE,LPDWORD) PURE; + STDMETHOD(SetLightState)(THIS_ D3DLIGHTSTATETYPE,DWORD) PURE; + STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; + STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; + STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; + STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,LPWORD,DWORD,DWORD) PURE; + STDMETHOD(SetClipStatus)(THIS_ LPD3DCLIPSTATUS) PURE; + STDMETHOD(GetClipStatus)(THIS_ LPD3DCLIPSTATUS) PURE; + STDMETHOD(DrawPrimitiveStrided)(THIS_ D3DPRIMITIVETYPE,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,DWORD) PURE; + STDMETHOD(DrawIndexedPrimitiveStrided)(THIS_ D3DPRIMITIVETYPE,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,LPWORD,DWORD,DWORD) PURE; + STDMETHOD(DrawPrimitiveVB)(THIS_ D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER,DWORD,DWORD,DWORD) PURE; + STDMETHOD(DrawIndexedPrimitiveVB)(THIS_ D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER,LPWORD,DWORD,DWORD) PURE; + STDMETHOD(ComputeSphereVisibility)(THIS_ LPD3DVECTOR,LPD3DVALUE,DWORD,DWORD,LPDWORD) PURE; + STDMETHOD(GetTexture)(THIS_ DWORD,LPDIRECT3DTEXTURE2 *) PURE; + STDMETHOD(SetTexture)(THIS_ DWORD,LPDIRECT3DTEXTURE2) PURE; + STDMETHOD(GetTextureStageState)(THIS_ DWORD,D3DTEXTURESTAGESTATETYPE,LPDWORD) PURE; + STDMETHOD(SetTextureStageState)(THIS_ DWORD,D3DTEXTURESTAGESTATETYPE,DWORD) PURE; + STDMETHOD(ValidateDevice)(THIS_ LPDWORD) PURE; +}; + +typedef struct IDirect3DDevice3 *LPDIRECT3DDEVICE3; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DDevice3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DDevice3_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DDevice3_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DDevice3_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) +#define IDirect3DDevice3_GetStats(p,a) (p)->lpVtbl->GetStats(p,a) +#define IDirect3DDevice3_AddViewport(p,a) (p)->lpVtbl->AddViewport(p,a) +#define IDirect3DDevice3_DeleteViewport(p,a) (p)->lpVtbl->DeleteViewport(p,a) +#define IDirect3DDevice3_NextViewport(p,a,b,c) (p)->lpVtbl->NextViewport(p,a,b,c) +#define IDirect3DDevice3_EnumTextureFormats(p,a,b) (p)->lpVtbl->EnumTextureFormats(p,a,b) +#define IDirect3DDevice3_BeginScene(p) (p)->lpVtbl->BeginScene(p) +#define IDirect3DDevice3_EndScene(p) (p)->lpVtbl->EndScene(p) +#define IDirect3DDevice3_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) +#define IDirect3DDevice3_SetCurrentViewport(p,a) (p)->lpVtbl->SetCurrentViewport(p,a) +#define IDirect3DDevice3_GetCurrentViewport(p,a) (p)->lpVtbl->GetCurrentViewport(p,a) +#define IDirect3DDevice3_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) +#define IDirect3DDevice3_GetRenderTarget(p,a) (p)->lpVtbl->GetRenderTarget(p,a) +#define IDirect3DDevice3_Begin(p,a,b,c) (p)->lpVtbl->Begin(p,a,b,c) +#define IDirect3DDevice3_BeginIndexed(p,a,b,c,d,e) (p)->lpVtbl->BeginIndexed(p,a,b,c,d,e) +#define IDirect3DDevice3_Vertex(p,a) (p)->lpVtbl->Vertex(p,a) +#define IDirect3DDevice3_Index(p,a) (p)->lpVtbl->Index(p,a) +#define IDirect3DDevice3_End(p,a) (p)->lpVtbl->End(p,a) +#define IDirect3DDevice3_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) +#define IDirect3DDevice3_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) +#define IDirect3DDevice3_GetLightState(p,a,b) (p)->lpVtbl->GetLightState(p,a,b) +#define IDirect3DDevice3_SetLightState(p,a,b) (p)->lpVtbl->SetLightState(p,a,b) +#define IDirect3DDevice3_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) +#define IDirect3DDevice3_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) +#define IDirect3DDevice3_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) +#define IDirect3DDevice3_DrawPrimitive(p,a,b,c,d,e) (p)->lpVtbl->DrawPrimitive(p,a,b,c,d,e) +#define IDirect3DDevice3_DrawIndexedPrimitive(p,a,b,c,d,e,f,g) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e,f,g) +#define IDirect3DDevice3_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) +#define IDirect3DDevice3_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) +#define IDirect3DDevice3_DrawPrimitiveStrided(p,a,b,c,d,e) (p)->lpVtbl->DrawPrimitiveStrided(p,a,b,c,d,e) +#define IDirect3DDevice3_DrawIndexedPrimitiveStrided(p,a,b,c,d,e,f,g) (p)->lpVtbl->DrawIndexedPrimitiveStrided(p,a,b,c,d,e,f,g) +#define IDirect3DDevice3_DrawPrimitiveVB(p,a,b,c,d,e) (p)->lpVtbl->DrawPrimitiveVB(p,a,b,c,d,e) +#define IDirect3DDevice3_DrawIndexedPrimitiveVB(p,a,b,c,d,e) (p)->lpVtbl->DrawIndexedPrimitiveVB(p,a,b,c,d,e) +#define IDirect3DDevice3_ComputeSphereVisibility(p,a,b,c,d,e) (p)->lpVtbl->ComputeSphereVisibility(p,a,b,c,d,e) +#define IDirect3DDevice3_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) +#define IDirect3DDevice3_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) +#define IDirect3DDevice3_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) +#define IDirect3DDevice3_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) +#define IDirect3DDevice3_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a) +#else +#define IDirect3DDevice3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DDevice3_AddRef(p) (p)->AddRef() +#define IDirect3DDevice3_Release(p) (p)->Release() +#define IDirect3DDevice3_GetCaps(p,a,b) (p)->GetCaps(a,b) +#define IDirect3DDevice3_GetStats(p,a) (p)->GetStats(a) +#define IDirect3DDevice3_AddViewport(p,a) (p)->AddViewport(a) +#define IDirect3DDevice3_DeleteViewport(p,a) (p)->DeleteViewport(a) +#define IDirect3DDevice3_NextViewport(p,a,b,c) (p)->NextViewport(a,b,c) +#define IDirect3DDevice3_EnumTextureFormats(p,a,b) (p)->EnumTextureFormats(a,b) +#define IDirect3DDevice3_BeginScene(p) (p)->BeginScene() +#define IDirect3DDevice3_EndScene(p) (p)->EndScene() +#define IDirect3DDevice3_GetDirect3D(p,a) (p)->GetDirect3D(a) +#define IDirect3DDevice3_SetCurrentViewport(p,a) (p)->SetCurrentViewport(a) +#define IDirect3DDevice3_GetCurrentViewport(p,a) (p)->GetCurrentViewport(a) +#define IDirect3DDevice3_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) +#define IDirect3DDevice3_GetRenderTarget(p,a) (p)->GetRenderTarget(a) +#define IDirect3DDevice3_Begin(p,a,b,c) (p)->Begin(a,b,c) +#define IDirect3DDevice3_BeginIndexed(p,a,b,c,d,e) (p)->BeginIndexed(a,b,c,d,e) +#define IDirect3DDevice3_Vertex(p,a) (p)->Vertex(a) +#define IDirect3DDevice3_Index(p,a) (p)->Index(a) +#define IDirect3DDevice3_End(p,a) (p)->End(a) +#define IDirect3DDevice3_GetRenderState(p,a,b) (p)->GetRenderState(a,b) +#define IDirect3DDevice3_SetRenderState(p,a,b) (p)->SetRenderState(a,b) +#define IDirect3DDevice3_GetLightState(p,a,b) (p)->GetLightState(a,b) +#define IDirect3DDevice3_SetLightState(p,a,b) (p)->SetLightState(a,b) +#define IDirect3DDevice3_SetTransform(p,a,b) (p)->SetTransform(a,b) +#define IDirect3DDevice3_GetTransform(p,a,b) (p)->GetTransform(a,b) +#define IDirect3DDevice3_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) +#define IDirect3DDevice3_DrawPrimitive(p,a,b,c,d,e) (p)->DrawPrimitive(a,b,c,d,e) +#define IDirect3DDevice3_DrawIndexedPrimitive(p,a,b,c,d,e,f,g) (p)->DrawIndexedPrimitive(a,b,c,d,e,f,g) +#define IDirect3DDevice3_SetClipStatus(p,a) (p)->SetClipStatus(a) +#define IDirect3DDevice3_GetClipStatus(p,a) (p)->GetClipStatus(a) +#define IDirect3DDevice3_DrawPrimitiveStrided(p,a,b,c,d,e) (p)->DrawPrimitiveStrided(a,b,c,d,e) +#define IDirect3DDevice3_DrawIndexedPrimitiveStrided(p,a,b,c,d,e,f,g) (p)->DrawIndexedPrimitiveStrided(a,b,c,d,e,f,g) +#define IDirect3DDevice3_DrawPrimitiveVB(p,a,b,c,d,e) (p)->DrawPrimitiveVB(a,b,c,d,e) +#define IDirect3DDevice3_DrawIndexedPrimitiveVB(p,a,b,c,d,e) (p)->DrawIndexedPrimitiveVB(a,b,c,d,e) +#define IDirect3DDevice3_ComputeSphereVisibility(p,a,b,c,d,e) (p)->ComputeSphereVisibility(a,b,c,d,e) +#define IDirect3DDevice3_GetTexture(p,a,b) (p)->GetTexture(a,b) +#define IDirect3DDevice3_SetTexture(p,a,b) (p)->SetTexture(a,b) +#define IDirect3DDevice3_GetTextureStageState(p,a,b,c) (p)->GetTextureStageState(a,b,c) +#define IDirect3DDevice3_SetTextureStageState(p,a,b,c) (p)->SetTextureStageState(a,b,c) +#define IDirect3DDevice3_ValidateDevice(p,a) (p)->ValidateDevice(a) +#endif +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +#if(DIRECT3D_VERSION >= 0x0700) +#undef INTERFACE +#define INTERFACE IDirect3DDevice7 + +DECLARE_INTERFACE_(IDirect3DDevice7, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DDevice7 methods ***/ + STDMETHOD(GetCaps)(THIS_ LPD3DDEVICEDESC7) PURE; + STDMETHOD(EnumTextureFormats)(THIS_ LPD3DENUMPIXELFORMATSCALLBACK,LPVOID) PURE; + STDMETHOD(BeginScene)(THIS) PURE; + STDMETHOD(EndScene)(THIS) PURE; + STDMETHOD(GetDirect3D)(THIS_ LPDIRECT3D7*) PURE; + STDMETHOD(SetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE7,DWORD) PURE; + STDMETHOD(GetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE7 *) PURE; + STDMETHOD(Clear)(THIS_ DWORD,LPD3DRECT,DWORD,D3DCOLOR,D3DVALUE,DWORD) PURE; + STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; + STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; + STDMETHOD(SetViewport)(THIS_ LPD3DVIEWPORT7) PURE; + STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX) PURE; + STDMETHOD(GetViewport)(THIS_ LPD3DVIEWPORT7) PURE; + STDMETHOD(SetMaterial)(THIS_ LPD3DMATERIAL7) PURE; + STDMETHOD(GetMaterial)(THIS_ LPD3DMATERIAL7) PURE; + STDMETHOD(SetLight)(THIS_ DWORD,LPD3DLIGHT7) PURE; + STDMETHOD(GetLight)(THIS_ DWORD,LPD3DLIGHT7) PURE; + STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE,DWORD) PURE; + STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE,LPDWORD) PURE; + STDMETHOD(BeginStateBlock)(THIS) PURE; + STDMETHOD(EndStateBlock)(THIS_ LPDWORD) PURE; + STDMETHOD(PreLoad)(THIS_ LPDIRECTDRAWSURFACE7) PURE; + STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,LPWORD,DWORD,DWORD) PURE; + STDMETHOD(SetClipStatus)(THIS_ LPD3DCLIPSTATUS) PURE; + STDMETHOD(GetClipStatus)(THIS_ LPD3DCLIPSTATUS) PURE; + STDMETHOD(DrawPrimitiveStrided)(THIS_ D3DPRIMITIVETYPE,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,DWORD) PURE; + STDMETHOD(DrawIndexedPrimitiveStrided)(THIS_ D3DPRIMITIVETYPE,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,LPWORD,DWORD,DWORD) PURE; + STDMETHOD(DrawPrimitiveVB)(THIS_ D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER7,DWORD,DWORD,DWORD) PURE; + STDMETHOD(DrawIndexedPrimitiveVB)(THIS_ D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER7,DWORD,DWORD,LPWORD,DWORD,DWORD) PURE; + STDMETHOD(ComputeSphereVisibility)(THIS_ LPD3DVECTOR,LPD3DVALUE,DWORD,DWORD,LPDWORD) PURE; + STDMETHOD(GetTexture)(THIS_ DWORD,LPDIRECTDRAWSURFACE7 *) PURE; + STDMETHOD(SetTexture)(THIS_ DWORD,LPDIRECTDRAWSURFACE7) PURE; + STDMETHOD(GetTextureStageState)(THIS_ DWORD,D3DTEXTURESTAGESTATETYPE,LPDWORD) PURE; + STDMETHOD(SetTextureStageState)(THIS_ DWORD,D3DTEXTURESTAGESTATETYPE,DWORD) PURE; + STDMETHOD(ValidateDevice)(THIS_ LPDWORD) PURE; + STDMETHOD(ApplyStateBlock)(THIS_ DWORD) PURE; + STDMETHOD(CaptureStateBlock)(THIS_ DWORD) PURE; + STDMETHOD(DeleteStateBlock)(THIS_ DWORD) PURE; + STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE,LPDWORD) PURE; + STDMETHOD(Load)(THIS_ LPDIRECTDRAWSURFACE7,LPPOINT,LPDIRECTDRAWSURFACE7,LPRECT,DWORD) PURE; + STDMETHOD(LightEnable)(THIS_ DWORD,BOOL) PURE; + STDMETHOD(GetLightEnable)(THIS_ DWORD,BOOL*) PURE; + STDMETHOD(SetClipPlane)(THIS_ DWORD,D3DVALUE*) PURE; + STDMETHOD(GetClipPlane)(THIS_ DWORD,D3DVALUE*) PURE; + STDMETHOD(GetInfo)(THIS_ DWORD,LPVOID,DWORD) PURE; +}; + +typedef struct IDirect3DDevice7 *LPDIRECT3DDEVICE7; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DDevice7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DDevice7_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DDevice7_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirect3DDevice7_EnumTextureFormats(p,a,b) (p)->lpVtbl->EnumTextureFormats(p,a,b) +#define IDirect3DDevice7_BeginScene(p) (p)->lpVtbl->BeginScene(p) +#define IDirect3DDevice7_EndScene(p) (p)->lpVtbl->EndScene(p) +#define IDirect3DDevice7_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) +#define IDirect3DDevice7_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) +#define IDirect3DDevice7_GetRenderTarget(p,a) (p)->lpVtbl->GetRenderTarget(p,a) +#define IDirect3DDevice7_Clear(p,a,b,c,d,e,f) (p)->lpVtbl->Clear(p,a,b,c,d,e,f) +#define IDirect3DDevice7_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) +#define IDirect3DDevice7_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) +#define IDirect3DDevice7_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) +#define IDirect3DDevice7_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) +#define IDirect3DDevice7_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) +#define IDirect3DDevice7_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) +#define IDirect3DDevice7_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) +#define IDirect3DDevice7_SetLight(p,a,b) (p)->lpVtbl->SetLight(p,a,b) +#define IDirect3DDevice7_GetLight(p,a,b) (p)->lpVtbl->GetLight(p,a,b) +#define IDirect3DDevice7_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) +#define IDirect3DDevice7_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) +#define IDirect3DDevice7_BeginStateBlock(p) (p)->lpVtbl->BeginStateBlock(p) +#define IDirect3DDevice7_EndStateBlock(p,a) (p)->lpVtbl->EndStateBlock(p,a) +#define IDirect3DDevice7_PreLoad(p,a) (p)->lpVtbl->PreLoad(p,a) +#define IDirect3DDevice7_DrawPrimitive(p,a,b,c,d,e) (p)->lpVtbl->DrawPrimitive(p,a,b,c,d,e) +#define IDirect3DDevice7_DrawIndexedPrimitive(p,a,b,c,d,e,f,g) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e,f,g) +#define IDirect3DDevice7_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) +#define IDirect3DDevice7_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) +#define IDirect3DDevice7_DrawPrimitiveStrided(p,a,b,c,d,e) (p)->lpVtbl->DrawPrimitiveStrided(p,a,b,c,d,e) +#define IDirect3DDevice7_DrawIndexedPrimitiveStrided(p,a,b,c,d,e,f,g) (p)->lpVtbl->DrawIndexedPrimitiveStrided(p,a,b,c,d,e,f,g) +#define IDirect3DDevice7_DrawPrimitiveVB(p,a,b,c,d,e) (p)->lpVtbl->DrawPrimitiveVB(p,a,b,c,d,e) +#define IDirect3DDevice7_DrawIndexedPrimitiveVB(p,a,b,c,d,e,f,g) (p)->lpVtbl->DrawIndexedPrimitiveVB(p,a,b,c,d,e,f,g) +#define IDirect3DDevice7_ComputeSphereVisibility(p,a,b,c,d,e) (p)->lpVtbl->ComputeSphereVisibility(p,a,b,c,d,e) +#define IDirect3DDevice7_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) +#define IDirect3DDevice7_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) +#define IDirect3DDevice7_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) +#define IDirect3DDevice7_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) +#define IDirect3DDevice7_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a) +#define IDirect3DDevice7_ApplyStateBlock(p,a) (p)->lpVtbl->ApplyStateBlock(p,a) +#define IDirect3DDevice7_CaptureStateBlock(p,a) (p)->lpVtbl->CaptureStateBlock(p,a) +#define IDirect3DDevice7_DeleteStateBlock(p,a) (p)->lpVtbl->DeleteStateBlock(p,a) +#define IDirect3DDevice7_CreateStateBlock(p,a,b) (p)->lpVtbl->CreateStateBlock(p,a,b) +#define IDirect3DDevice7_Load(p,a,b,c,d,e) (p)->lpVtbl->Load(p,a,b,c,d,e) +#define IDirect3DDevice7_LightEnable(p,a,b) (p)->lpVtbl->LightEnable(p,a,b) +#define IDirect3DDevice7_GetLightEnable(p,a,b) (p)->lpVtbl->GetLightEnable(p,a,b) +#define IDirect3DDevice7_SetClipPlane(p,a,b) (p)->lpVtbl->SetClipPlane(p,a,b) +#define IDirect3DDevice7_GetClipPlane(p,a,b) (p)->lpVtbl->GetClipPlane(p,a,b) +#define IDirect3DDevice7_GetInfo(p,a,b,c) (p)->lpVtbl->GetInfo(p,a,b,c) +#else +#define IDirect3DDevice7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DDevice7_AddRef(p) (p)->AddRef() +#define IDirect3DDevice7_Release(p) (p)->Release() +#define IDirect3DDevice7_GetCaps(p,a) (p)->GetCaps(a) +#define IDirect3DDevice7_EnumTextureFormats(p,a,b) (p)->EnumTextureFormats(a,b) +#define IDirect3DDevice7_BeginScene(p) (p)->BeginScene() +#define IDirect3DDevice7_EndScene(p) (p)->EndScene() +#define IDirect3DDevice7_GetDirect3D(p,a) (p)->GetDirect3D(a) +#define IDirect3DDevice7_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) +#define IDirect3DDevice7_GetRenderTarget(p,a) (p)->GetRenderTarget(a) +#define IDirect3DDevice7_Clear(p,a,b,c,d,e,f) (p)->Clear(a,b,c,d,e,f) +#define IDirect3DDevice7_SetTransform(p,a,b) (p)->SetTransform(a,b) +#define IDirect3DDevice7_GetTransform(p,a,b) (p)->GetTransform(a,b) +#define IDirect3DDevice7_SetViewport(p,a) (p)->SetViewport(a) +#define IDirect3DDevice7_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) +#define IDirect3DDevice7_GetViewport(p,a) (p)->GetViewport(a) +#define IDirect3DDevice7_SetMaterial(p,a) (p)->SetMaterial(a) +#define IDirect3DDevice7_GetMaterial(p,a) (p)->GetMaterial(a) +#define IDirect3DDevice7_SetLight(p,a,b) (p)->SetLight(a,b) +#define IDirect3DDevice7_GetLight(p,a,b) (p)->GetLight(a,b) +#define IDirect3DDevice7_SetRenderState(p,a,b) (p)->SetRenderState(a,b) +#define IDirect3DDevice7_GetRenderState(p,a,b) (p)->GetRenderState(a,b) +#define IDirect3DDevice7_BeginStateBlock(p) (p)->BeginStateBlock() +#define IDirect3DDevice7_EndStateBlock(p,a) (p)->EndStateBlock(a) +#define IDirect3DDevice7_PreLoad(p,a) (p)->PreLoad(a) +#define IDirect3DDevice7_DrawPrimitive(p,a,b,c,d,e) (p)->DrawPrimitive(a,b,c,d,e) +#define IDirect3DDevice7_DrawIndexedPrimitive(p,a,b,c,d,e,f,g) (p)->DrawIndexedPrimitive(a,b,c,d,e,f,g) +#define IDirect3DDevice7_SetClipStatus(p,a) (p)->SetClipStatus(a) +#define IDirect3DDevice7_GetClipStatus(p,a) (p)->GetClipStatus(a) +#define IDirect3DDevice7_DrawPrimitiveStrided(p,a,b,c,d,e) (p)->DrawPrimitiveStrided(a,b,c,d,e) +#define IDirect3DDevice7_DrawIndexedPrimitiveStrided(p,a,b,c,d,e,f,g) (p)->DrawIndexedPrimitiveStrided(a,b,c,d,e,f,g) +#define IDirect3DDevice7_DrawPrimitiveVB(p,a,b,c,d,e) (p)->DrawPrimitiveVB(a,b,c,d,e) +#define IDirect3DDevice7_DrawIndexedPrimitiveVB(p,a,b,c,d,e,f,g) (p)->DrawIndexedPrimitiveVB(a,b,c,d,e,f,g) +#define IDirect3DDevice7_ComputeSphereVisibility(p,a,b,c,d,e) (p)->ComputeSphereVisibility(a,b,c,d,e) +#define IDirect3DDevice7_GetTexture(p,a,b) (p)->GetTexture(a,b) +#define IDirect3DDevice7_SetTexture(p,a,b) (p)->SetTexture(a,b) +#define IDirect3DDevice7_GetTextureStageState(p,a,b,c) (p)->GetTextureStageState(a,b,c) +#define IDirect3DDevice7_SetTextureStageState(p,a,b,c) (p)->SetTextureStageState(a,b,c) +#define IDirect3DDevice7_ValidateDevice(p,a) (p)->ValidateDevice(a) +#define IDirect3DDevice7_ApplyStateBlock(p,a) (p)->ApplyStateBlock(a) +#define IDirect3DDevice7_CaptureStateBlock(p,a) (p)->CaptureStateBlock(a) +#define IDirect3DDevice7_DeleteStateBlock(p,a) (p)->DeleteStateBlock(a) +#define IDirect3DDevice7_CreateStateBlock(p,a,b) (p)->CreateStateBlock(a,b) +#define IDirect3DDevice7_Load(p,a,b,c,d,e) (p)->Load(a,b,c,d,e) +#define IDirect3DDevice7_LightEnable(p,a,b) (p)->LightEnable(a,b) +#define IDirect3DDevice7_GetLightEnable(p,a,b) (p)->GetLightEnable(a,b) +#define IDirect3DDevice7_SetClipPlane(p,a,b) (p)->SetClipPlane(a,b) +#define IDirect3DDevice7_GetClipPlane(p,a,b) (p)->GetClipPlane(a,b) +#define IDirect3DDevice7_GetInfo(p,a,b,c) (p)->GetInfo(a,b,c) +#endif +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +/* + * Execute Buffer interface + */ +#undef INTERFACE +#define INTERFACE IDirect3DExecuteBuffer + +DECLARE_INTERFACE_(IDirect3DExecuteBuffer, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DExecuteBuffer methods ***/ + STDMETHOD(Initialize)(THIS_ LPDIRECT3DDEVICE,LPD3DEXECUTEBUFFERDESC) PURE; + STDMETHOD(Lock)(THIS_ LPD3DEXECUTEBUFFERDESC) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(SetExecuteData)(THIS_ LPD3DEXECUTEDATA) PURE; + STDMETHOD(GetExecuteData)(THIS_ LPD3DEXECUTEDATA) PURE; + STDMETHOD(Validate)(THIS_ LPDWORD,LPD3DVALIDATECALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Optimize)(THIS_ DWORD) PURE; +}; + +typedef struct IDirect3DExecuteBuffer *LPDIRECT3DEXECUTEBUFFER; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DExecuteBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DExecuteBuffer_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DExecuteBuffer_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DExecuteBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirect3DExecuteBuffer_Lock(p,a) (p)->lpVtbl->Lock(p,a) +#define IDirect3DExecuteBuffer_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DExecuteBuffer_SetExecuteData(p,a) (p)->lpVtbl->SetExecuteData(p,a) +#define IDirect3DExecuteBuffer_GetExecuteData(p,a) (p)->lpVtbl->GetExecuteData(p,a) +#define IDirect3DExecuteBuffer_Validate(p,a,b,c,d) (p)->lpVtbl->Validate(p,a,b,c,d) +#define IDirect3DExecuteBuffer_Optimize(p,a) (p)->lpVtbl->Optimize(p,a) +#else +#define IDirect3DExecuteBuffer_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DExecuteBuffer_AddRef(p) (p)->AddRef() +#define IDirect3DExecuteBuffer_Release(p) (p)->Release() +#define IDirect3DExecuteBuffer_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirect3DExecuteBuffer_Lock(p,a) (p)->Lock(a) +#define IDirect3DExecuteBuffer_Unlock(p) (p)->Unlock() +#define IDirect3DExecuteBuffer_SetExecuteData(p,a) (p)->SetExecuteData(a) +#define IDirect3DExecuteBuffer_GetExecuteData(p,a) (p)->GetExecuteData(a) +#define IDirect3DExecuteBuffer_Validate(p,a,b,c,d) (p)->Validate(a,b,c,d) +#define IDirect3DExecuteBuffer_Optimize(p,a) (p)->Optimize(a) +#endif + +/* + * Light interfaces + */ +#undef INTERFACE +#define INTERFACE IDirect3DLight + +DECLARE_INTERFACE_(IDirect3DLight, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DLight methods ***/ + STDMETHOD(Initialize)(THIS_ LPDIRECT3D) PURE; + STDMETHOD(SetLight)(THIS_ LPD3DLIGHT) PURE; + STDMETHOD(GetLight)(THIS_ LPD3DLIGHT) PURE; +}; + +typedef struct IDirect3DLight *LPDIRECT3DLIGHT; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DLight_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DLight_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DLight_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DLight_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#define IDirect3DLight_SetLight(p,a) (p)->lpVtbl->SetLight(p,a) +#define IDirect3DLight_GetLight(p,a) (p)->lpVtbl->GetLight(p,a) +#else +#define IDirect3DLight_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DLight_AddRef(p) (p)->AddRef() +#define IDirect3DLight_Release(p) (p)->Release() +#define IDirect3DLight_Initialize(p,a) (p)->Initialize(a) +#define IDirect3DLight_SetLight(p,a) (p)->SetLight(a) +#define IDirect3DLight_GetLight(p,a) (p)->GetLight(a) +#endif + +/* + * Material interfaces + */ +#undef INTERFACE +#define INTERFACE IDirect3DMaterial + +DECLARE_INTERFACE_(IDirect3DMaterial, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DMaterial methods ***/ + STDMETHOD(Initialize)(THIS_ LPDIRECT3D) PURE; + STDMETHOD(SetMaterial)(THIS_ LPD3DMATERIAL) PURE; + STDMETHOD(GetMaterial)(THIS_ LPD3DMATERIAL) PURE; + STDMETHOD(GetHandle)(THIS_ LPDIRECT3DDEVICE,LPD3DMATERIALHANDLE) PURE; + STDMETHOD(Reserve)(THIS) PURE; + STDMETHOD(Unreserve)(THIS) PURE; +}; + +typedef struct IDirect3DMaterial *LPDIRECT3DMATERIAL; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DMaterial_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DMaterial_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DMaterial_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DMaterial_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#define IDirect3DMaterial_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) +#define IDirect3DMaterial_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) +#define IDirect3DMaterial_GetHandle(p,a,b) (p)->lpVtbl->GetHandle(p,a,b) +#define IDirect3DMaterial_Reserve(p) (p)->lpVtbl->Reserve(p) +#define IDirect3DMaterial_Unreserve(p) (p)->lpVtbl->Unreserve(p) +#else +#define IDirect3DMaterial_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DMaterial_AddRef(p) (p)->AddRef() +#define IDirect3DMaterial_Release(p) (p)->Release() +#define IDirect3DMaterial_Initialize(p,a) (p)->Initialize(a) +#define IDirect3DMaterial_SetMaterial(p,a) (p)->SetMaterial(a) +#define IDirect3DMaterial_GetMaterial(p,a) (p)->GetMaterial(a) +#define IDirect3DMaterial_GetHandle(p,a,b) (p)->GetHandle(a,b) +#define IDirect3DMaterial_Reserve(p) (p)->Reserve() +#define IDirect3DMaterial_Unreserve(p) (p)->Unreserve() +#endif + +#if(DIRECT3D_VERSION >= 0x0500) +#undef INTERFACE +#define INTERFACE IDirect3DMaterial2 + +DECLARE_INTERFACE_(IDirect3DMaterial2, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DMaterial2 methods ***/ + STDMETHOD(SetMaterial)(THIS_ LPD3DMATERIAL) PURE; + STDMETHOD(GetMaterial)(THIS_ LPD3DMATERIAL) PURE; + STDMETHOD(GetHandle)(THIS_ LPDIRECT3DDEVICE2,LPD3DMATERIALHANDLE) PURE; +}; + +typedef struct IDirect3DMaterial2 *LPDIRECT3DMATERIAL2; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DMaterial2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DMaterial2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DMaterial2_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DMaterial2_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) +#define IDirect3DMaterial2_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) +#define IDirect3DMaterial2_GetHandle(p,a,b) (p)->lpVtbl->GetHandle(p,a,b) +#else +#define IDirect3DMaterial2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DMaterial2_AddRef(p) (p)->AddRef() +#define IDirect3DMaterial2_Release(p) (p)->Release() +#define IDirect3DMaterial2_SetMaterial(p,a) (p)->SetMaterial(a) +#define IDirect3DMaterial2_GetMaterial(p,a) (p)->GetMaterial(a) +#define IDirect3DMaterial2_GetHandle(p,a,b) (p)->GetHandle(a,b) +#endif +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if(DIRECT3D_VERSION >= 0x0600) +#undef INTERFACE +#define INTERFACE IDirect3DMaterial3 + +DECLARE_INTERFACE_(IDirect3DMaterial3, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DMaterial3 methods ***/ + STDMETHOD(SetMaterial)(THIS_ LPD3DMATERIAL) PURE; + STDMETHOD(GetMaterial)(THIS_ LPD3DMATERIAL) PURE; + STDMETHOD(GetHandle)(THIS_ LPDIRECT3DDEVICE3,LPD3DMATERIALHANDLE) PURE; +}; + +typedef struct IDirect3DMaterial3 *LPDIRECT3DMATERIAL3; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DMaterial3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DMaterial3_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DMaterial3_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DMaterial3_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) +#define IDirect3DMaterial3_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) +#define IDirect3DMaterial3_GetHandle(p,a,b) (p)->lpVtbl->GetHandle(p,a,b) +#else +#define IDirect3DMaterial3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DMaterial3_AddRef(p) (p)->AddRef() +#define IDirect3DMaterial3_Release(p) (p)->Release() +#define IDirect3DMaterial3_SetMaterial(p,a) (p)->SetMaterial(a) +#define IDirect3DMaterial3_GetMaterial(p,a) (p)->GetMaterial(a) +#define IDirect3DMaterial3_GetHandle(p,a,b) (p)->GetHandle(a,b) +#endif +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +/* + * Texture interfaces + */ +#undef INTERFACE +#define INTERFACE IDirect3DTexture + +DECLARE_INTERFACE_(IDirect3DTexture, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DTexture methods ***/ + STDMETHOD(Initialize)(THIS_ LPDIRECT3DDEVICE,LPDIRECTDRAWSURFACE) PURE; + STDMETHOD(GetHandle)(THIS_ LPDIRECT3DDEVICE,LPD3DTEXTUREHANDLE) PURE; + STDMETHOD(PaletteChanged)(THIS_ DWORD,DWORD) PURE; + STDMETHOD(Load)(THIS_ LPDIRECT3DTEXTURE) PURE; + STDMETHOD(Unload)(THIS) PURE; +}; + +typedef struct IDirect3DTexture *LPDIRECT3DTEXTURE; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DTexture_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DTexture_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DTexture_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DTexture_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirect3DTexture_GetHandle(p,a,b) (p)->lpVtbl->GetHandle(p,a,b) +#define IDirect3DTexture_PaletteChanged(p,a,b) (p)->lpVtbl->PaletteChanged(p,a,b) +#define IDirect3DTexture_Load(p,a) (p)->lpVtbl->Load(p,a) +#define IDirect3DTexture_Unload(p) (p)->lpVtbl->Unload(p) +#else +#define IDirect3DTexture_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DTexture_AddRef(p) (p)->AddRef() +#define IDirect3DTexture_Release(p) (p)->Release() +#define IDirect3DTexture_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirect3DTexture_GetHandle(p,a,b) (p)->GetHandle(a,b) +#define IDirect3DTexture_PaletteChanged(p,a,b) (p)->PaletteChanged(a,b) +#define IDirect3DTexture_Load(p,a) (p)->Load(a) +#define IDirect3DTexture_Unload(p) (p)->Unload() +#endif + +#if(DIRECT3D_VERSION >= 0x0500) +#undef INTERFACE +#define INTERFACE IDirect3DTexture2 + +DECLARE_INTERFACE_(IDirect3DTexture2, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DTexture2 methods ***/ + STDMETHOD(GetHandle)(THIS_ LPDIRECT3DDEVICE2,LPD3DTEXTUREHANDLE) PURE; + STDMETHOD(PaletteChanged)(THIS_ DWORD,DWORD) PURE; + STDMETHOD(Load)(THIS_ LPDIRECT3DTEXTURE2) PURE; +}; + +typedef struct IDirect3DTexture2 *LPDIRECT3DTEXTURE2; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DTexture2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DTexture2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DTexture2_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DTexture2_GetHandle(p,a,b) (p)->lpVtbl->GetHandle(p,a,b) +#define IDirect3DTexture2_PaletteChanged(p,a,b) (p)->lpVtbl->PaletteChanged(p,a,b) +#define IDirect3DTexture2_Load(p,a) (p)->lpVtbl->Load(p,a) +#else +#define IDirect3DTexture2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DTexture2_AddRef(p) (p)->AddRef() +#define IDirect3DTexture2_Release(p) (p)->Release() +#define IDirect3DTexture2_GetHandle(p,a,b) (p)->GetHandle(a,b) +#define IDirect3DTexture2_PaletteChanged(p,a,b) (p)->PaletteChanged(a,b) +#define IDirect3DTexture2_Load(p,a) (p)->Load(a) +#endif +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +/* + * Viewport interfaces + */ +#undef INTERFACE +#define INTERFACE IDirect3DViewport + +DECLARE_INTERFACE_(IDirect3DViewport, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DViewport methods ***/ + STDMETHOD(Initialize)(THIS_ LPDIRECT3D) PURE; + STDMETHOD(GetViewport)(THIS_ LPD3DVIEWPORT) PURE; + STDMETHOD(SetViewport)(THIS_ LPD3DVIEWPORT) PURE; + STDMETHOD(TransformVertices)(THIS_ DWORD,LPD3DTRANSFORMDATA,DWORD,LPDWORD) PURE; + STDMETHOD(LightElements)(THIS_ DWORD,LPD3DLIGHTDATA) PURE; + STDMETHOD(SetBackground)(THIS_ D3DMATERIALHANDLE) PURE; + STDMETHOD(GetBackground)(THIS_ LPD3DMATERIALHANDLE,LPBOOL) PURE; + STDMETHOD(SetBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE; + STDMETHOD(GetBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE*,LPBOOL) PURE; + STDMETHOD(Clear)(THIS_ DWORD,LPD3DRECT,DWORD) PURE; + STDMETHOD(AddLight)(THIS_ LPDIRECT3DLIGHT) PURE; + STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DLIGHT) PURE; + STDMETHOD(NextLight)(THIS_ LPDIRECT3DLIGHT,LPDIRECT3DLIGHT*,DWORD) PURE; +}; + +typedef struct IDirect3DViewport *LPDIRECT3DVIEWPORT; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DViewport_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DViewport_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DViewport_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DViewport_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#define IDirect3DViewport_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) +#define IDirect3DViewport_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) +#define IDirect3DViewport_TransformVertices(p,a,b,c,d) (p)->lpVtbl->TransformVertices(p,a,b,c,d) +#define IDirect3DViewport_LightElements(p,a,b) (p)->lpVtbl->LightElements(p,a,b) +#define IDirect3DViewport_SetBackground(p,a) (p)->lpVtbl->SetBackground(p,a) +#define IDirect3DViewport_GetBackground(p,a,b) (p)->lpVtbl->GetBackground(p,a,b) +#define IDirect3DViewport_SetBackgroundDepth(p,a) (p)->lpVtbl->SetBackgroundDepth(p,a) +#define IDirect3DViewport_GetBackgroundDepth(p,a,b) (p)->lpVtbl->GetBackgroundDepth(p,a,b) +#define IDirect3DViewport_Clear(p,a,b,c) (p)->lpVtbl->Clear(p,a,b,c) +#define IDirect3DViewport_AddLight(p,a) (p)->lpVtbl->AddLight(p,a) +#define IDirect3DViewport_DeleteLight(p,a) (p)->lpVtbl->DeleteLight(p,a) +#define IDirect3DViewport_NextLight(p,a,b,c) (p)->lpVtbl->NextLight(p,a,b,c) +#else +#define IDirect3DViewport_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DViewport_AddRef(p) (p)->AddRef() +#define IDirect3DViewport_Release(p) (p)->Release() +#define IDirect3DViewport_Initialize(p,a) (p)->Initialize(a) +#define IDirect3DViewport_GetViewport(p,a) (p)->GetViewport(a) +#define IDirect3DViewport_SetViewport(p,a) (p)->SetViewport(a) +#define IDirect3DViewport_TransformVertices(p,a,b,c,d) (p)->TransformVertices(a,b,c,d) +#define IDirect3DViewport_LightElements(p,a,b) (p)->LightElements(a,b) +#define IDirect3DViewport_SetBackground(p,a) (p)->SetBackground(a) +#define IDirect3DViewport_GetBackground(p,a,b) (p)->GetBackground(a,b) +#define IDirect3DViewport_SetBackgroundDepth(p,a) (p)->SetBackgroundDepth(a) +#define IDirect3DViewport_GetBackgroundDepth(p,a,b) (p)->GetBackgroundDepth(a,b) +#define IDirect3DViewport_Clear(p,a,b,c) (p)->Clear(a,b,c) +#define IDirect3DViewport_AddLight(p,a) (p)->AddLight(a) +#define IDirect3DViewport_DeleteLight(p,a) (p)->DeleteLight(a) +#define IDirect3DViewport_NextLight(p,a,b,c) (p)->NextLight(a,b,c) +#endif + +#if(DIRECT3D_VERSION >= 0x0500) +#undef INTERFACE +#define INTERFACE IDirect3DViewport2 + +DECLARE_INTERFACE_(IDirect3DViewport2, IDirect3DViewport) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DViewport methods ***/ + STDMETHOD(Initialize)(THIS_ LPDIRECT3D) PURE; + STDMETHOD(GetViewport)(THIS_ LPD3DVIEWPORT) PURE; + STDMETHOD(SetViewport)(THIS_ LPD3DVIEWPORT) PURE; + STDMETHOD(TransformVertices)(THIS_ DWORD,LPD3DTRANSFORMDATA,DWORD,LPDWORD) PURE; + STDMETHOD(LightElements)(THIS_ DWORD,LPD3DLIGHTDATA) PURE; + STDMETHOD(SetBackground)(THIS_ D3DMATERIALHANDLE) PURE; + STDMETHOD(GetBackground)(THIS_ LPD3DMATERIALHANDLE,LPBOOL) PURE; + STDMETHOD(SetBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE; + STDMETHOD(GetBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE*,LPBOOL) PURE; + STDMETHOD(Clear)(THIS_ DWORD,LPD3DRECT,DWORD) PURE; + STDMETHOD(AddLight)(THIS_ LPDIRECT3DLIGHT) PURE; + STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DLIGHT) PURE; + STDMETHOD(NextLight)(THIS_ LPDIRECT3DLIGHT,LPDIRECT3DLIGHT*,DWORD) PURE; + STDMETHOD(GetViewport2)(THIS_ LPD3DVIEWPORT2) PURE; + STDMETHOD(SetViewport2)(THIS_ LPD3DVIEWPORT2) PURE; +}; + +typedef struct IDirect3DViewport2 *LPDIRECT3DVIEWPORT2; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DViewport2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DViewport2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DViewport2_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DViewport2_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#define IDirect3DViewport2_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) +#define IDirect3DViewport2_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) +#define IDirect3DViewport2_TransformVertices(p,a,b,c,d) (p)->lpVtbl->TransformVertices(p,a,b,c,d) +#define IDirect3DViewport2_LightElements(p,a,b) (p)->lpVtbl->LightElements(p,a,b) +#define IDirect3DViewport2_SetBackground(p,a) (p)->lpVtbl->SetBackground(p,a) +#define IDirect3DViewport2_GetBackground(p,a,b) (p)->lpVtbl->GetBackground(p,a,b) +#define IDirect3DViewport2_SetBackgroundDepth(p,a) (p)->lpVtbl->SetBackgroundDepth(p,a) +#define IDirect3DViewport2_GetBackgroundDepth(p,a,b) (p)->lpVtbl->GetBackgroundDepth(p,a,b) +#define IDirect3DViewport2_Clear(p,a,b,c) (p)->lpVtbl->Clear(p,a,b,c) +#define IDirect3DViewport2_AddLight(p,a) (p)->lpVtbl->AddLight(p,a) +#define IDirect3DViewport2_DeleteLight(p,a) (p)->lpVtbl->DeleteLight(p,a) +#define IDirect3DViewport2_NextLight(p,a,b,c) (p)->lpVtbl->NextLight(p,a,b,c) +#define IDirect3DViewport2_GetViewport2(p,a) (p)->lpVtbl->GetViewport2(p,a) +#define IDirect3DViewport2_SetViewport2(p,a) (p)->lpVtbl->SetViewport2(p,a) +#else +#define IDirect3DViewport2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DViewport2_AddRef(p) (p)->AddRef() +#define IDirect3DViewport2_Release(p) (p)->Release() +#define IDirect3DViewport2_Initialize(p,a) (p)->Initialize(a) +#define IDirect3DViewport2_GetViewport(p,a) (p)->GetViewport(a) +#define IDirect3DViewport2_SetViewport(p,a) (p)->SetViewport(a) +#define IDirect3DViewport2_TransformVertices(p,a,b,c,d) (p)->TransformVertices(a,b,c,d) +#define IDirect3DViewport2_LightElements(p,a,b) (p)->LightElements(a,b) +#define IDirect3DViewport2_SetBackground(p,a) (p)->SetBackground(a) +#define IDirect3DViewport2_GetBackground(p,a,b) (p)->GetBackground(a,b) +#define IDirect3DViewport2_SetBackgroundDepth(p,a) (p)->SetBackgroundDepth(a) +#define IDirect3DViewport2_GetBackgroundDepth(p,a,b) (p)->GetBackgroundDepth(a,b) +#define IDirect3DViewport2_Clear(p,a,b,c) (p)->Clear(a,b,c) +#define IDirect3DViewport2_AddLight(p,a) (p)->AddLight(a) +#define IDirect3DViewport2_DeleteLight(p,a) (p)->DeleteLight(a) +#define IDirect3DViewport2_NextLight(p,a,b,c) (p)->NextLight(a,b,c) +#define IDirect3DViewport2_GetViewport2(p,a) (p)->GetViewport2(a) +#define IDirect3DViewport2_SetViewport2(p,a) (p)->SetViewport2(a) +#endif +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if(DIRECT3D_VERSION >= 0x0600) + +#undef INTERFACE +#define INTERFACE IDirect3DViewport3 + +DECLARE_INTERFACE_(IDirect3DViewport3, IDirect3DViewport2) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DViewport2 methods ***/ + STDMETHOD(Initialize)(THIS_ LPDIRECT3D) PURE; + STDMETHOD(GetViewport)(THIS_ LPD3DVIEWPORT) PURE; + STDMETHOD(SetViewport)(THIS_ LPD3DVIEWPORT) PURE; + STDMETHOD(TransformVertices)(THIS_ DWORD,LPD3DTRANSFORMDATA,DWORD,LPDWORD) PURE; + STDMETHOD(LightElements)(THIS_ DWORD,LPD3DLIGHTDATA) PURE; + STDMETHOD(SetBackground)(THIS_ D3DMATERIALHANDLE) PURE; + STDMETHOD(GetBackground)(THIS_ LPD3DMATERIALHANDLE,LPBOOL) PURE; + STDMETHOD(SetBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE; + STDMETHOD(GetBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE*,LPBOOL) PURE; + STDMETHOD(Clear)(THIS_ DWORD,LPD3DRECT,DWORD) PURE; + STDMETHOD(AddLight)(THIS_ LPDIRECT3DLIGHT) PURE; + STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DLIGHT) PURE; + STDMETHOD(NextLight)(THIS_ LPDIRECT3DLIGHT,LPDIRECT3DLIGHT*,DWORD) PURE; + STDMETHOD(GetViewport2)(THIS_ LPD3DVIEWPORT2) PURE; + STDMETHOD(SetViewport2)(THIS_ LPD3DVIEWPORT2) PURE; + STDMETHOD(SetBackgroundDepth2)(THIS_ LPDIRECTDRAWSURFACE4) PURE; + STDMETHOD(GetBackgroundDepth2)(THIS_ LPDIRECTDRAWSURFACE4*,LPBOOL) PURE; + STDMETHOD(Clear2)(THIS_ DWORD,LPD3DRECT,DWORD,D3DCOLOR,D3DVALUE,DWORD) PURE; +}; + +typedef struct IDirect3DViewport3 *LPDIRECT3DVIEWPORT3; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DViewport3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DViewport3_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DViewport3_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DViewport3_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#define IDirect3DViewport3_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) +#define IDirect3DViewport3_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) +#define IDirect3DViewport3_TransformVertices(p,a,b,c,d) (p)->lpVtbl->TransformVertices(p,a,b,c,d) +#define IDirect3DViewport3_LightElements(p,a,b) (p)->lpVtbl->LightElements(p,a,b) +#define IDirect3DViewport3_SetBackground(p,a) (p)->lpVtbl->SetBackground(p,a) +#define IDirect3DViewport3_GetBackground(p,a,b) (p)->lpVtbl->GetBackground(p,a,b) +#define IDirect3DViewport3_SetBackgroundDepth(p,a) (p)->lpVtbl->SetBackgroundDepth(p,a) +#define IDirect3DViewport3_GetBackgroundDepth(p,a,b) (p)->lpVtbl->GetBackgroundDepth(p,a,b) +#define IDirect3DViewport3_Clear(p,a,b,c) (p)->lpVtbl->Clear(p,a,b,c) +#define IDirect3DViewport3_AddLight(p,a) (p)->lpVtbl->AddLight(p,a) +#define IDirect3DViewport3_DeleteLight(p,a) (p)->lpVtbl->DeleteLight(p,a) +#define IDirect3DViewport3_NextLight(p,a,b,c) (p)->lpVtbl->NextLight(p,a,b,c) +#define IDirect3DViewport3_GetViewport2(p,a) (p)->lpVtbl->GetViewport2(p,a) +#define IDirect3DViewport3_SetViewport2(p,a) (p)->lpVtbl->SetViewport2(p,a) +#define IDirect3DViewport3_SetBackgroundDepth2(p,a) (p)->lpVtbl->SetBackgroundDepth2(p,a) +#define IDirect3DViewport3_GetBackgroundDepth2(p,a,b) (p)->lpVtbl->GetBackgroundDepth2(p,a,b) +#define IDirect3DViewport3_Clear2(p,a,b,c,d,e,f) (p)->lpVtbl->Clear2(p,a,b,c,d,e,f) +#else +#define IDirect3DViewport3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DViewport3_AddRef(p) (p)->AddRef() +#define IDirect3DViewport3_Release(p) (p)->Release() +#define IDirect3DViewport3_Initialize(p,a) (p)->Initialize(a) +#define IDirect3DViewport3_GetViewport(p,a) (p)->GetViewport(a) +#define IDirect3DViewport3_SetViewport(p,a) (p)->SetViewport(a) +#define IDirect3DViewport3_TransformVertices(p,a,b,c,d) (p)->TransformVertices(a,b,c,d) +#define IDirect3DViewport3_LightElements(p,a,b) (p)->LightElements(a,b) +#define IDirect3DViewport3_SetBackground(p,a) (p)->SetBackground(a) +#define IDirect3DViewport3_GetBackground(p,a,b) (p)->GetBackground(a,b) +#define IDirect3DViewport3_SetBackgroundDepth(p,a) (p)->SetBackgroundDepth(a) +#define IDirect3DViewport3_GetBackgroundDepth(p,a,b) (p)->GetBackgroundDepth(a,b) +#define IDirect3DViewport3_Clear(p,a,b,c) (p)->Clear(a,b,c) +#define IDirect3DViewport3_AddLight(p,a) (p)->AddLight(a) +#define IDirect3DViewport3_DeleteLight(p,a) (p)->DeleteLight(a) +#define IDirect3DViewport3_NextLight(p,a,b,c) (p)->NextLight(a,b,c) +#define IDirect3DViewport3_GetViewport2(p,a) (p)->GetViewport2(a) +#define IDirect3DViewport3_SetViewport2(p,a) (p)->SetViewport2(a) +#define IDirect3DViewport3_SetBackgroundDepth2(p,a) (p)->SetBackgroundDepth2(a) +#define IDirect3DViewport3_GetBackgroundDepth2(p,a,b) (p)->GetBackgroundDepth2(a,b) +#define IDirect3DViewport3_Clear2(p,a,b,c,d,e,f) (p)->Clear2(a,b,c,d,e,f) +#endif +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +#if(DIRECT3D_VERSION >= 0x0600) +#undef INTERFACE +#define INTERFACE IDirect3DVertexBuffer + +DECLARE_INTERFACE_(IDirect3DVertexBuffer, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DVertexBuffer methods ***/ + STDMETHOD(Lock)(THIS_ DWORD,LPVOID*,LPDWORD) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(ProcessVertices)(THIS_ DWORD,DWORD,DWORD,LPDIRECT3DVERTEXBUFFER,DWORD,LPDIRECT3DDEVICE3,DWORD) PURE; + STDMETHOD(GetVertexBufferDesc)(THIS_ LPD3DVERTEXBUFFERDESC) PURE; + STDMETHOD(Optimize)(THIS_ LPDIRECT3DDEVICE3,DWORD) PURE; +}; + +typedef struct IDirect3DVertexBuffer *LPDIRECT3DVERTEXBUFFER; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVertexBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVertexBuffer_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVertexBuffer_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVertexBuffer_Lock(p,a,b,c) (p)->lpVtbl->Lock(p,a,b,c) +#define IDirect3DVertexBuffer_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DVertexBuffer_ProcessVertices(p,a,b,c,d,e,f,g) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e,f,g) +#define IDirect3DVertexBuffer_GetVertexBufferDesc(p,a) (p)->lpVtbl->GetVertexBufferDesc(p,a) +#define IDirect3DVertexBuffer_Optimize(p,a,b) (p)->lpVtbl->Optimize(p,a,b) +#else +#define IDirect3DVertexBuffer_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVertexBuffer_AddRef(p) (p)->AddRef() +#define IDirect3DVertexBuffer_Release(p) (p)->Release() +#define IDirect3DVertexBuffer_Lock(p,a,b,c) (p)->Lock(a,b,c) +#define IDirect3DVertexBuffer_Unlock(p) (p)->Unlock() +#define IDirect3DVertexBuffer_ProcessVertices(p,a,b,c,d,e,f,g) (p)->ProcessVertices(a,b,c,d,e,f,g) +#define IDirect3DVertexBuffer_GetVertexBufferDesc(p,a) (p)->GetVertexBufferDesc(a) +#define IDirect3DVertexBuffer_Optimize(p,a,b) (p)->Optimize(a,b) +#endif +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +#if(DIRECT3D_VERSION >= 0x0700) +#undef INTERFACE +#define INTERFACE IDirect3DVertexBuffer7 + +DECLARE_INTERFACE_(IDirect3DVertexBuffer7, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DVertexBuffer7 methods ***/ + STDMETHOD(Lock)(THIS_ DWORD,LPVOID*,LPDWORD) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(ProcessVertices)(THIS_ DWORD,DWORD,DWORD,LPDIRECT3DVERTEXBUFFER7,DWORD,LPDIRECT3DDEVICE7,DWORD) PURE; + STDMETHOD(GetVertexBufferDesc)(THIS_ LPD3DVERTEXBUFFERDESC) PURE; + STDMETHOD(Optimize)(THIS_ LPDIRECT3DDEVICE7,DWORD) PURE; + STDMETHOD(ProcessVerticesStrided)(THIS_ DWORD,DWORD,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,LPDIRECT3DDEVICE7,DWORD) PURE; +}; + +typedef struct IDirect3DVertexBuffer7 *LPDIRECT3DVERTEXBUFFER7; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVertexBuffer7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVertexBuffer7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVertexBuffer7_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVertexBuffer7_Lock(p,a,b,c) (p)->lpVtbl->Lock(p,a,b,c) +#define IDirect3DVertexBuffer7_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DVertexBuffer7_ProcessVertices(p,a,b,c,d,e,f,g) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e,f,g) +#define IDirect3DVertexBuffer7_GetVertexBufferDesc(p,a) (p)->lpVtbl->GetVertexBufferDesc(p,a) +#define IDirect3DVertexBuffer7_Optimize(p,a,b) (p)->lpVtbl->Optimize(p,a,b) +#define IDirect3DVertexBuffer7_ProcessVerticesStrided(p,a,b,c,d,e,f,g) (p)->lpVtbl->ProcessVerticesStrided(p,a,b,c,d,e,f,g) +#else +#define IDirect3DVertexBuffer7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVertexBuffer7_AddRef(p) (p)->AddRef() +#define IDirect3DVertexBuffer7_Release(p) (p)->Release() +#define IDirect3DVertexBuffer7_Lock(p,a,b,c) (p)->Lock(a,b,c) +#define IDirect3DVertexBuffer7_Unlock(p) (p)->Unlock() +#define IDirect3DVertexBuffer7_ProcessVertices(p,a,b,c,d,e,f,g) (p)->ProcessVertices(a,b,c,d,e,f,g) +#define IDirect3DVertexBuffer7_GetVertexBufferDesc(p,a) (p)->GetVertexBufferDesc(a) +#define IDirect3DVertexBuffer7_Optimize(p,a,b) (p)->Optimize(a,b) +#define IDirect3DVertexBuffer7_ProcessVerticesStrided(p,a,b,c,d,e,f,g) (p)->ProcessVerticesStrided(a,b,c,d,e,f,g) +#endif +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +#if(DIRECT3D_VERSION >= 0x0500) +/**************************************************************************** + * + * Flags for IDirect3DDevice::NextViewport + * + ****************************************************************************/ + +/* + * Return the next viewport + */ +#define D3DNEXT_NEXT 0x00000001l + +/* + * Return the first viewport + */ +#define D3DNEXT_HEAD 0x00000002l + +/* + * Return the last viewport + */ +#define D3DNEXT_TAIL 0x00000004l + + +/**************************************************************************** + * + * Flags for DrawPrimitive/DrawIndexedPrimitive + * Also valid for Begin/BeginIndexed + * Also valid for VertexBuffer::CreateVertexBuffer + ****************************************************************************/ + +/* + * Wait until the device is ready to draw the primitive + * This will cause DP to not return DDERR_WASSTILLDRAWING + */ +#define D3DDP_WAIT 0x00000001l +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if (DIRECT3D_VERSION == 0x0500) +/* + * Hint that it is acceptable to render the primitive out of order. + */ +#define D3DDP_OUTOFORDER 0x00000002l +#endif + + +#if(DIRECT3D_VERSION >= 0x0500) +/* + * Hint that the primitives have been clipped by the application. + */ +#define D3DDP_DONOTCLIP 0x00000004l + +/* + * Hint that the extents need not be updated. + */ +#define D3DDP_DONOTUPDATEEXTENTS 0x00000008l +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if(DIRECT3D_VERSION >= 0x0600) + +/* + * Hint that the lighting should not be applied on vertices. + */ + +#define D3DDP_DONOTLIGHT 0x00000010l + +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +/* + * Direct3D Errors + * DirectDraw error codes are used when errors not specified here. + */ +#define D3D_OK DD_OK +#define D3DERR_BADMAJORVERSION MAKE_DDHRESULT(700) +#define D3DERR_BADMINORVERSION MAKE_DDHRESULT(701) + +#if(DIRECT3D_VERSION >= 0x0500) +/* + * An invalid device was requested by the application. + */ +#define D3DERR_INVALID_DEVICE MAKE_DDHRESULT(705) +#define D3DERR_INITFAILED MAKE_DDHRESULT(706) + +/* + * SetRenderTarget attempted on a device that was + * QI'd off the render target. + */ +#define D3DERR_DEVICEAGGREGATED MAKE_DDHRESULT(707) +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#define D3DERR_EXECUTE_CREATE_FAILED MAKE_DDHRESULT(710) +#define D3DERR_EXECUTE_DESTROY_FAILED MAKE_DDHRESULT(711) +#define D3DERR_EXECUTE_LOCK_FAILED MAKE_DDHRESULT(712) +#define D3DERR_EXECUTE_UNLOCK_FAILED MAKE_DDHRESULT(713) +#define D3DERR_EXECUTE_LOCKED MAKE_DDHRESULT(714) +#define D3DERR_EXECUTE_NOT_LOCKED MAKE_DDHRESULT(715) + +#define D3DERR_EXECUTE_FAILED MAKE_DDHRESULT(716) +#define D3DERR_EXECUTE_CLIPPED_FAILED MAKE_DDHRESULT(717) + +#define D3DERR_TEXTURE_NO_SUPPORT MAKE_DDHRESULT(720) +#define D3DERR_TEXTURE_CREATE_FAILED MAKE_DDHRESULT(721) +#define D3DERR_TEXTURE_DESTROY_FAILED MAKE_DDHRESULT(722) +#define D3DERR_TEXTURE_LOCK_FAILED MAKE_DDHRESULT(723) +#define D3DERR_TEXTURE_UNLOCK_FAILED MAKE_DDHRESULT(724) +#define D3DERR_TEXTURE_LOAD_FAILED MAKE_DDHRESULT(725) +#define D3DERR_TEXTURE_SWAP_FAILED MAKE_DDHRESULT(726) +#define D3DERR_TEXTURE_LOCKED MAKE_DDHRESULT(727) +#define D3DERR_TEXTURE_NOT_LOCKED MAKE_DDHRESULT(728) +#define D3DERR_TEXTURE_GETSURF_FAILED MAKE_DDHRESULT(729) + +#define D3DERR_MATRIX_CREATE_FAILED MAKE_DDHRESULT(730) +#define D3DERR_MATRIX_DESTROY_FAILED MAKE_DDHRESULT(731) +#define D3DERR_MATRIX_SETDATA_FAILED MAKE_DDHRESULT(732) +#define D3DERR_MATRIX_GETDATA_FAILED MAKE_DDHRESULT(733) +#define D3DERR_SETVIEWPORTDATA_FAILED MAKE_DDHRESULT(734) + +#if(DIRECT3D_VERSION >= 0x0500) +#define D3DERR_INVALIDCURRENTVIEWPORT MAKE_DDHRESULT(735) +#define D3DERR_INVALIDPRIMITIVETYPE MAKE_DDHRESULT(736) +#define D3DERR_INVALIDVERTEXTYPE MAKE_DDHRESULT(737) +#define D3DERR_TEXTURE_BADSIZE MAKE_DDHRESULT(738) +#define D3DERR_INVALIDRAMPTEXTURE MAKE_DDHRESULT(739) +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#define D3DERR_MATERIAL_CREATE_FAILED MAKE_DDHRESULT(740) +#define D3DERR_MATERIAL_DESTROY_FAILED MAKE_DDHRESULT(741) +#define D3DERR_MATERIAL_SETDATA_FAILED MAKE_DDHRESULT(742) +#define D3DERR_MATERIAL_GETDATA_FAILED MAKE_DDHRESULT(743) + +#if(DIRECT3D_VERSION >= 0x0500) +#define D3DERR_INVALIDPALETTE MAKE_DDHRESULT(744) + +#define D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY MAKE_DDHRESULT(745) +#define D3DERR_ZBUFF_NEEDS_VIDEOMEMORY MAKE_DDHRESULT(746) +#define D3DERR_SURFACENOTINVIDMEM MAKE_DDHRESULT(747) +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#define D3DERR_LIGHT_SET_FAILED MAKE_DDHRESULT(750) +#if(DIRECT3D_VERSION >= 0x0500) +#define D3DERR_LIGHTHASVIEWPORT MAKE_DDHRESULT(751) +#define D3DERR_LIGHTNOTINTHISVIEWPORT MAKE_DDHRESULT(752) +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#define D3DERR_SCENE_IN_SCENE MAKE_DDHRESULT(760) +#define D3DERR_SCENE_NOT_IN_SCENE MAKE_DDHRESULT(761) +#define D3DERR_SCENE_BEGIN_FAILED MAKE_DDHRESULT(762) +#define D3DERR_SCENE_END_FAILED MAKE_DDHRESULT(763) + +#if(DIRECT3D_VERSION >= 0x0500) +#define D3DERR_INBEGIN MAKE_DDHRESULT(770) +#define D3DERR_NOTINBEGIN MAKE_DDHRESULT(771) +#define D3DERR_NOVIEWPORTS MAKE_DDHRESULT(772) +#define D3DERR_VIEWPORTDATANOTSET MAKE_DDHRESULT(773) +#define D3DERR_VIEWPORTHASNODEVICE MAKE_DDHRESULT(774) +#define D3DERR_NOCURRENTVIEWPORT MAKE_DDHRESULT(775) +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if(DIRECT3D_VERSION >= 0x0600) +#define D3DERR_INVALIDVERTEXFORMAT MAKE_DDHRESULT(2048) + +/* + * Attempted to CreateTexture on a surface that had a color key + */ +#define D3DERR_COLORKEYATTACHED MAKE_DDHRESULT(2050) + +#define D3DERR_VERTEXBUFFEROPTIMIZED MAKE_DDHRESULT(2060) +#define D3DERR_VBUF_CREATE_FAILED MAKE_DDHRESULT(2061) +#define D3DERR_VERTEXBUFFERLOCKED MAKE_DDHRESULT(2062) +#define D3DERR_VERTEXBUFFERUNLOCKFAILED MAKE_DDHRESULT(2063) + +#define D3DERR_ZBUFFER_NOTPRESENT MAKE_DDHRESULT(2070) +#define D3DERR_STENCILBUFFER_NOTPRESENT MAKE_DDHRESULT(2071) + +#define D3DERR_WRONGTEXTUREFORMAT MAKE_DDHRESULT(2072) +#define D3DERR_UNSUPPORTEDCOLOROPERATION MAKE_DDHRESULT(2073) +#define D3DERR_UNSUPPORTEDCOLORARG MAKE_DDHRESULT(2074) +#define D3DERR_UNSUPPORTEDALPHAOPERATION MAKE_DDHRESULT(2075) +#define D3DERR_UNSUPPORTEDALPHAARG MAKE_DDHRESULT(2076) +#define D3DERR_TOOMANYOPERATIONS MAKE_DDHRESULT(2077) +#define D3DERR_CONFLICTINGTEXTUREFILTER MAKE_DDHRESULT(2078) +#define D3DERR_UNSUPPORTEDFACTORVALUE MAKE_DDHRESULT(2079) +#define D3DERR_CONFLICTINGRENDERSTATE MAKE_DDHRESULT(2081) +#define D3DERR_UNSUPPORTEDTEXTUREFILTER MAKE_DDHRESULT(2082) +#define D3DERR_TOOMANYPRIMITIVES MAKE_DDHRESULT(2083) +#define D3DERR_INVALIDMATRIX MAKE_DDHRESULT(2084) +#define D3DERR_TOOMANYVERTICES MAKE_DDHRESULT(2085) +#define D3DERR_CONFLICTINGTEXTUREPALETTE MAKE_DDHRESULT(2086) + +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +#if(DIRECT3D_VERSION >= 0x0700) +#define D3DERR_INVALIDSTATEBLOCK MAKE_DDHRESULT(2100) +#define D3DERR_INBEGINSTATEBLOCK MAKE_DDHRESULT(2101) +#define D3DERR_NOTINBEGINSTATEBLOCK MAKE_DDHRESULT(2102) +#endif /* DIRECT3D_VERSION >= 0x0700 */ + + +#ifdef __cplusplus +}; +#endif + +#endif /* (DIRECT3D_VERSION < 0x0800) */ +#endif /* _D3D_H_ */ + diff --git a/src/dep/include/DXSDK/include/d3d10misc.h b/src/dep/include/DXSDK/include/d3d10misc.h index edfce5e..13c86f8 100644 --- a/src/dep/include/DXSDK/include/d3d10misc.h +++ b/src/dep/include/DXSDK/include/d3d10misc.h @@ -1,174 +1,174 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// File: D3D10Misc.h -// Content: D3D10 Device Creation APIs -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef __D3D10MISC_H__ -#define __D3D10MISC_H__ - -#include "d3d10.h" - -/////////////////////////////////////////////////////////////////////////// -// ID3D10Blob: -// ------------ -// The buffer object is used by D3D10 to return arbitrary size data. -// -// GetBufferPointer - -// Returns a pointer to the beginning of the buffer. -// -// GetBufferSize - -// Returns the size of the buffer, in bytes. -/////////////////////////////////////////////////////////////////////////// - -typedef interface ID3D10Blob ID3D10Blob; -typedef interface ID3D10Blob *LPD3D10BLOB; - -// {8BA5FB08-5195-40e2-AC58-0D989C3A0102} -DEFINE_GUID(IID_ID3D10Blob, -0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2); - -#undef INTERFACE -#define INTERFACE ID3D10Blob - -DECLARE_INTERFACE_(ID3D10Blob, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3D10Blob - STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; - STDMETHOD_(SIZE_T, GetBufferSize)(THIS) PURE; -}; - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -/////////////////////////////////////////////////////////////////////////// -// D3D10_DRIVER_TYPE -// ---------------- -// -// This identifier is used to determine the implementation of Direct3D10 -// to be used. -// -// Pass one of these values to D3D10CreateDevice -// -/////////////////////////////////////////////////////////////////////////// -typedef enum D3D10_DRIVER_TYPE -{ - D3D10_DRIVER_TYPE_HARDWARE = 0, - D3D10_DRIVER_TYPE_REFERENCE = 1, - D3D10_DRIVER_TYPE_NULL = 2, - D3D10_DRIVER_TYPE_SOFTWARE = 3, -} D3D10_DRIVER_TYPE; - -DEFINE_GUID(GUID_DeviceType, -0xd722fb4d, 0x7a68, 0x437a, 0xb2, 0x0c, 0x58, 0x04, 0xee, 0x24, 0x94, 0xa6); - -/////////////////////////////////////////////////////////////////////////// -// D3D10CreateDevice -// ------------------ -// -// pAdapter -// If NULL, D3D10CreateDevice will choose the primary adapter and -// create a new instance from a temporarily created IDXGIFactory. -// If non-NULL, D3D10CreateDevice will register the appropriate -// device, if necessary (via IDXGIAdapter::RegisterDrver), before -// creating the device. -// DriverType -// Specifies the driver type to be created: hardware, reference or -// null. -// Software -// HMODULE of a DLL implementing a software rasterizer. Must be NULL for -// non-Software driver types. -// Flags -// Any of those documented for D3D10CreateDevice. -// SDKVersion -// SDK version. Use the D3D10_SDK_VERSION macro. -// ppDevice -// Pointer to returned interface. -// -// Return Values -// Any of those documented for -// CreateDXGIFactory -// IDXGIFactory::EnumAdapters -// IDXGIAdapter::RegisterDriver -// D3D10CreateDevice -// -/////////////////////////////////////////////////////////////////////////// -HRESULT WINAPI D3D10CreateDevice( - IDXGIAdapter *pAdapter, - D3D10_DRIVER_TYPE DriverType, - HMODULE Software, - UINT Flags, - UINT SDKVersion, - ID3D10Device **ppDevice); - -/////////////////////////////////////////////////////////////////////////// -// D3D10CreateDeviceAndSwapChain -// ------------------------------ -// -// ppAdapter -// If NULL, D3D10CreateDevice will choose the primary adapter and -// create a new instance from a temporarily created IDXGIFactory. -// If non-NULL, D3D10CreateDevice will register the appropriate -// device, if necessary (via IDXGIAdapter::RegisterDrver), before -// creating the device. -// DriverType -// Specifies the driver type to be created: hardware, reference or -// null. -// Software -// HMODULE of a DLL implementing a software rasterizer. Must be NULL for -// non-Software driver types. -// Flags -// Any of those documented for D3D10CreateDevice. -// SDKVersion -// SDK version. Use the D3D10_SDK_VERSION macro. -// pSwapChainDesc -// Swap chain description, may be NULL. -// ppSwapChain -// Pointer to returned interface. May be NULL. -// ppDevice -// Pointer to returned interface. -// -// Return Values -// Any of those documented for -// CreateDXGIFactory -// IDXGIFactory::EnumAdapters -// IDXGIAdapter::RegisterDriver -// D3D10CreateDevice -// IDXGIFactory::CreateSwapChain -// -/////////////////////////////////////////////////////////////////////////// -HRESULT WINAPI D3D10CreateDeviceAndSwapChain( - IDXGIAdapter *pAdapter, - D3D10_DRIVER_TYPE DriverType, - HMODULE Software, - UINT Flags, - UINT SDKVersion, - DXGI_SWAP_CHAIN_DESC *pSwapChainDesc, - IDXGISwapChain **ppSwapChain, - ID3D10Device **ppDevice); - - -/////////////////////////////////////////////////////////////////////////// -// D3D10CreateBlob: -// ----------------- -// Creates a Buffer of n Bytes -////////////////////////////////////////////////////////////////////////// - -HRESULT WINAPI D3D10CreateBlob(SIZE_T NumBytes, LPD3D10BLOB *ppBuffer); - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3D10EFFECT_H__ - - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// File: D3D10Misc.h +// Content: D3D10 Device Creation APIs +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef __D3D10MISC_H__ +#define __D3D10MISC_H__ + +#include "d3d10.h" + +/////////////////////////////////////////////////////////////////////////// +// ID3D10Blob: +// ------------ +// The buffer object is used by D3D10 to return arbitrary size data. +// +// GetBufferPointer - +// Returns a pointer to the beginning of the buffer. +// +// GetBufferSize - +// Returns the size of the buffer, in bytes. +/////////////////////////////////////////////////////////////////////////// + +typedef interface ID3D10Blob ID3D10Blob; +typedef interface ID3D10Blob *LPD3D10BLOB; + +// {8BA5FB08-5195-40e2-AC58-0D989C3A0102} +DEFINE_GUID(IID_ID3D10Blob, +0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2); + +#undef INTERFACE +#define INTERFACE ID3D10Blob + +DECLARE_INTERFACE_(ID3D10Blob, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3D10Blob + STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; + STDMETHOD_(SIZE_T, GetBufferSize)(THIS) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +/////////////////////////////////////////////////////////////////////////// +// D3D10_DRIVER_TYPE +// ---------------- +// +// This identifier is used to determine the implementation of Direct3D10 +// to be used. +// +// Pass one of these values to D3D10CreateDevice +// +/////////////////////////////////////////////////////////////////////////// +typedef enum D3D10_DRIVER_TYPE +{ + D3D10_DRIVER_TYPE_HARDWARE = 0, + D3D10_DRIVER_TYPE_REFERENCE = 1, + D3D10_DRIVER_TYPE_NULL = 2, + D3D10_DRIVER_TYPE_SOFTWARE = 3, +} D3D10_DRIVER_TYPE; + +DEFINE_GUID(GUID_DeviceType, +0xd722fb4d, 0x7a68, 0x437a, 0xb2, 0x0c, 0x58, 0x04, 0xee, 0x24, 0x94, 0xa6); + +/////////////////////////////////////////////////////////////////////////// +// D3D10CreateDevice +// ------------------ +// +// pAdapter +// If NULL, D3D10CreateDevice will choose the primary adapter and +// create a new instance from a temporarily created IDXGIFactory. +// If non-NULL, D3D10CreateDevice will register the appropriate +// device, if necessary (via IDXGIAdapter::RegisterDrver), before +// creating the device. +// DriverType +// Specifies the driver type to be created: hardware, reference or +// null. +// Software +// HMODULE of a DLL implementing a software rasterizer. Must be NULL for +// non-Software driver types. +// Flags +// Any of those documented for D3D10CreateDevice. +// SDKVersion +// SDK version. Use the D3D10_SDK_VERSION macro. +// ppDevice +// Pointer to returned interface. +// +// Return Values +// Any of those documented for +// CreateDXGIFactory +// IDXGIFactory::EnumAdapters +// IDXGIAdapter::RegisterDriver +// D3D10CreateDevice +// +/////////////////////////////////////////////////////////////////////////// +HRESULT WINAPI D3D10CreateDevice( + IDXGIAdapter *pAdapter, + D3D10_DRIVER_TYPE DriverType, + HMODULE Software, + UINT Flags, + UINT SDKVersion, + ID3D10Device **ppDevice); + +/////////////////////////////////////////////////////////////////////////// +// D3D10CreateDeviceAndSwapChain +// ------------------------------ +// +// ppAdapter +// If NULL, D3D10CreateDevice will choose the primary adapter and +// create a new instance from a temporarily created IDXGIFactory. +// If non-NULL, D3D10CreateDevice will register the appropriate +// device, if necessary (via IDXGIAdapter::RegisterDrver), before +// creating the device. +// DriverType +// Specifies the driver type to be created: hardware, reference or +// null. +// Software +// HMODULE of a DLL implementing a software rasterizer. Must be NULL for +// non-Software driver types. +// Flags +// Any of those documented for D3D10CreateDevice. +// SDKVersion +// SDK version. Use the D3D10_SDK_VERSION macro. +// pSwapChainDesc +// Swap chain description, may be NULL. +// ppSwapChain +// Pointer to returned interface. May be NULL. +// ppDevice +// Pointer to returned interface. +// +// Return Values +// Any of those documented for +// CreateDXGIFactory +// IDXGIFactory::EnumAdapters +// IDXGIAdapter::RegisterDriver +// D3D10CreateDevice +// IDXGIFactory::CreateSwapChain +// +/////////////////////////////////////////////////////////////////////////// +HRESULT WINAPI D3D10CreateDeviceAndSwapChain( + IDXGIAdapter *pAdapter, + D3D10_DRIVER_TYPE DriverType, + HMODULE Software, + UINT Flags, + UINT SDKVersion, + DXGI_SWAP_CHAIN_DESC *pSwapChainDesc, + IDXGISwapChain **ppSwapChain, + ID3D10Device **ppDevice); + + +/////////////////////////////////////////////////////////////////////////// +// D3D10CreateBlob: +// ----------------- +// Creates a Buffer of n Bytes +////////////////////////////////////////////////////////////////////////// + +HRESULT WINAPI D3D10CreateBlob(SIZE_T NumBytes, LPD3D10BLOB *ppBuffer); + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3D10EFFECT_H__ + + diff --git a/src/dep/include/DXSDK/include/d3d10sdklayers.h b/src/dep/include/DXSDK/include/d3d10sdklayers.h index ff728fd..6ae103f 100644 --- a/src/dep/include/DXSDK/include/d3d10sdklayers.h +++ b/src/dep/include/DXSDK/include/d3d10sdklayers.h @@ -1,998 +1,998 @@ - - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 7.00.0485 */ -/* Compiler settings for d3d10sdklayers.idl: - Oicf, W1, Zp8, env=Win32 (32b run) - protocol : dce , ms_ext, c_ext, robust - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() -*/ -//@@MIDL_FILE_HEADING( ) - -#pragma warning( disable: 4049 ) /* more than 64k source lines */ - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 475 -#endif - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCSAL_H_VERSION__ -#define __REQUIRED_RPCSAL_H_VERSION__ 100 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ - -#ifndef COM_NO_WINDOWS_H -#include "windows.h" -#include "ole2.h" -#endif /*COM_NO_WINDOWS_H*/ - -#ifndef __d3d10sdklayers_h__ -#define __d3d10sdklayers_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -/* Forward Declarations */ - -#ifndef __ID3D10Debug_FWD_DEFINED__ -#define __ID3D10Debug_FWD_DEFINED__ -typedef interface ID3D10Debug ID3D10Debug; -#endif /* __ID3D10Debug_FWD_DEFINED__ */ - - -#ifndef __ID3D10InfoQueue_FWD_DEFINED__ -#define __ID3D10InfoQueue_FWD_DEFINED__ -typedef interface ID3D10InfoQueue ID3D10InfoQueue; -#endif /* __ID3D10InfoQueue_FWD_DEFINED__ */ - - -/* header files for imported files */ -#include "oaidl.h" -#include "ocidl.h" - -#ifdef __cplusplus -extern "C"{ -#endif - - -/* interface __MIDL_itf_d3d10sdklayers_0000_0000 */ -/* [local] */ - -#define D3D10_SDK_LAYERS_VERSION ( 2 ) - -#define D3D10_DEBUG_FEATURE_FLUSH_PER_RENDER_OP ( 0x1 ) - - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10sdklayers_0000_0000_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10sdklayers_0000_0000_v0_0_s_ifspec; - -#ifndef __ID3D10Debug_INTERFACE_DEFINED__ -#define __ID3D10Debug_INTERFACE_DEFINED__ - -/* interface ID3D10Debug */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10Debug; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9B7E4E01-342C-4106-A19F-4F2704F689F0") - ID3D10Debug : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE SetFeatureMask( - UINT Mask) = 0; - - virtual UINT STDMETHODCALLTYPE GetFeatureMask( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE Validate( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10DebugVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10Debug * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10Debug * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10Debug * This); - - HRESULT ( STDMETHODCALLTYPE *SetFeatureMask )( - ID3D10Debug * This, - UINT Mask); - - UINT ( STDMETHODCALLTYPE *GetFeatureMask )( - ID3D10Debug * This); - - HRESULT ( STDMETHODCALLTYPE *Validate )( - ID3D10Debug * This); - - END_INTERFACE - } ID3D10DebugVtbl; - - interface ID3D10Debug - { - CONST_VTBL struct ID3D10DebugVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10Debug_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10Debug_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10Debug_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10Debug_SetFeatureMask(This,Mask) \ - ( (This)->lpVtbl -> SetFeatureMask(This,Mask) ) - -#define ID3D10Debug_GetFeatureMask(This) \ - ( (This)->lpVtbl -> GetFeatureMask(This) ) - -#define ID3D10Debug_Validate(This) \ - ( (This)->lpVtbl -> Validate(This) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10Debug_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d10sdklayers_0000_0001 */ -/* [local] */ - -typedef -enum D3D10_MESSAGE_CATEGORY - { D3D10_MESSAGE_CATEGORY_APPLICATION_DEFINED = 0, - D3D10_MESSAGE_CATEGORY_MISCELLANEOUS = ( D3D10_MESSAGE_CATEGORY_APPLICATION_DEFINED + 1 ) , - D3D10_MESSAGE_CATEGORY_INITIALIZATION = ( D3D10_MESSAGE_CATEGORY_MISCELLANEOUS + 1 ) , - D3D10_MESSAGE_CATEGORY_CLEANUP = ( D3D10_MESSAGE_CATEGORY_INITIALIZATION + 1 ) , - D3D10_MESSAGE_CATEGORY_COMPILATION = ( D3D10_MESSAGE_CATEGORY_CLEANUP + 1 ) , - D3D10_MESSAGE_CATEGORY_STATE_CREATION = ( D3D10_MESSAGE_CATEGORY_COMPILATION + 1 ) , - D3D10_MESSAGE_CATEGORY_STATE_SETTING = ( D3D10_MESSAGE_CATEGORY_STATE_CREATION + 1 ) , - D3D10_MESSAGE_CATEGORY_STATE_GETTING = ( D3D10_MESSAGE_CATEGORY_STATE_SETTING + 1 ) , - D3D10_MESSAGE_CATEGORY_RESOURCE_MANIPULATION = ( D3D10_MESSAGE_CATEGORY_STATE_GETTING + 1 ) , - D3D10_MESSAGE_CATEGORY_EXECUTION = ( D3D10_MESSAGE_CATEGORY_RESOURCE_MANIPULATION + 1 ) - } D3D10_MESSAGE_CATEGORY; - -typedef -enum D3D10_MESSAGE_SEVERITY - { D3D10_MESSAGE_SEVERITY_CORRUPTION = 0, - D3D10_MESSAGE_SEVERITY_ERROR = ( D3D10_MESSAGE_SEVERITY_CORRUPTION + 1 ) , - D3D10_MESSAGE_SEVERITY_WARNING = ( D3D10_MESSAGE_SEVERITY_ERROR + 1 ) , - D3D10_MESSAGE_SEVERITY_INFO = ( D3D10_MESSAGE_SEVERITY_WARNING + 1 ) - } D3D10_MESSAGE_SEVERITY; - -typedef -enum D3D10_MESSAGE_ID - { D3D10_MESSAGE_ID_UNKNOWN = 0, - D3D10_MESSAGE_ID_STRING_FROM_APPLICATION = ( D3D10_MESSAGE_ID_UNKNOWN + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_THIS = ( D3D10_MESSAGE_ID_STRING_FROM_APPLICATION + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER0 = ( D3D10_MESSAGE_ID_CORRUPTED_THIS + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER1 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER0 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER2 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER1 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER3 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER2 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER4 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER3 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER5 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER4 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER6 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER5 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER7 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER6 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER8 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER7 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER9 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER8 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER10 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER9 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER11 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER10 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER12 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER11 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER13 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER12 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER14 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER13 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_PARAMETER15 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER14 + 1 ) , - D3D10_MESSAGE_ID_CORRUPTED_MULTITHREADING = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER15 + 1 ) , - D3D10_MESSAGE_ID_MESSAGE_REPORTING_OUTOFMEMORY = ( D3D10_MESSAGE_ID_CORRUPTED_MULTITHREADING + 1 ) , - D3D10_MESSAGE_ID_IASETINPUTLAYOUT_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_MESSAGE_REPORTING_OUTOFMEMORY + 1 ) , - D3D10_MESSAGE_ID_IASETVERTEXBUFFERS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_IASETINPUTLAYOUT_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_IASETINDEXBUFFER_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_IASETVERTEXBUFFERS_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_VSSETSHADER_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_IASETINDEXBUFFER_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_VSSETSHADERRESOURCES_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_VSSETSHADER_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_VSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_VSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_VSSETSAMPLERS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_VSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_GSSETSHADER_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_VSSETSAMPLERS_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_GSSETSHADERRESOURCES_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_GSSETSHADER_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_GSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_GSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_GSSETSAMPLERS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_GSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_SOSETTARGETS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_GSSETSAMPLERS_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_PSSETSHADER_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_SOSETTARGETS_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_PSSETSHADERRESOURCES_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_PSSETSHADER_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_PSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_PSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_PSSETSAMPLERS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_PSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_RSSETSTATE_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_PSSETSAMPLERS_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_OMSETBLENDSTATE_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_RSSETSTATE_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_OMSETDEPTHSTENCILSTATE_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_OMSETBLENDSTATE_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_OMSETRENDERTARGETS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_OMSETDEPTHSTENCILSTATE_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_SETPREDICATION_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_OMSETRENDERTARGETS_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_GETPRIVATEDATA_MOREDATA = ( D3D10_MESSAGE_ID_SETPREDICATION_UNBINDDELETINGOBJECT + 1 ) , - D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDFREEDATA = ( D3D10_MESSAGE_ID_GETPRIVATEDATA_MOREDATA + 1 ) , - D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDIUNKNOWN = ( D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDFREEDATA + 1 ) , - D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDFLAGS = ( D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDIUNKNOWN + 1 ) , - D3D10_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS = ( D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDFLAGS + 1 ) , - D3D10_MESSAGE_ID_SETPRIVATEDATA_OUTOFMEMORY = ( D3D10_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_SETPRIVATEDATA_OUTOFMEMORY + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDSAMPLES = ( D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDUSAGE = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDSAMPLES + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDUSAGE + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDBINDFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDCPUACCESSFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDMISCFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDCPUACCESSFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDINITIALDATA = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDBINDFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDINITIALDATA + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDMIPLEVELS = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDDIMENSIONS + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDMIPLEVELS + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDMISCFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDARG_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATEBUFFER_NULLDESC = ( D3D10_MESSAGE_ID_CREATEBUFFER_OUTOFMEMORY_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_CREATEBUFFER_NULLDESC + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_UNSUPPORTEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDSAMPLES = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_UNSUPPORTEDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDUSAGE = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDSAMPLES + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDUSAGE + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDBINDFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDCPUACCESSFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDMISCFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDCPUACCESSFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDINITIALDATA = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDBINDFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDINITIALDATA + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDMIPLEVELS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDDIMENSIONS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDMIPLEVELS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDMISCFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDARG_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_NULLDESC = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_OUTOFMEMORY_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE1D_RESOURCETOOLARGE = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_NULLDESC + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_RESOURCETOOLARGE + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_UNSUPPORTEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDSAMPLES = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_UNSUPPORTEDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDUSAGE = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDSAMPLES + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDUSAGE + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDBINDFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDCPUACCESSFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDMISCFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDCPUACCESSFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDINITIALDATA = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDBINDFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDINITIALDATA + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDMIPLEVELS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDDIMENSIONS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDMIPLEVELS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDMISCFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDARG_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_NULLDESC = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_OUTOFMEMORY_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE2D_RESOURCETOOLARGE = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_NULLDESC + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_RESOURCETOOLARGE + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_UNSUPPORTEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDSAMPLES = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_UNSUPPORTEDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDUSAGE = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDSAMPLES + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDUSAGE + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDBINDFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDCPUACCESSFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDMISCFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDCPUACCESSFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDINITIALDATA = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDBINDFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDINITIALDATA + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDMIPLEVELS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDDIMENSIONS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDMIPLEVELS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDMISCFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDARG_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_NULLDESC = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_OUTOFMEMORY_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURE3D_RESOURCETOOLARGE = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_NULLDESC + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_RESOURCETOOLARGE + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNSUPPORTEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDSAMPLES = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNSUPPORTEDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDUSAGE = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDSAMPLES + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDUSAGE + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDBINDFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDCPUACCESSFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDMISCFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDCPUACCESSFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDINITIALDATA = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDBINDFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDINITIALDATA + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDMIPLEVELS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDDIMENSIONS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDMIPLEVELS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDMISCFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDARG_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_NULLDESC = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_OUTOFMEMORY_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATETEXTURECUBE_RESOURCETOOLARGE = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_NULLDESC + 1 ) , - D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_RESOURCETOOLARGE + 1 ) , - D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDESC = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_UNRECOGNIZEDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDESC + 1 ) , - D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDRESOURCE = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDIMENSIONS + 1 ) , - D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_TOOMANYOBJECTS = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDRESOURCE + 1 ) , - D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_TOOMANYOBJECTS + 1 ) , - D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDARG_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_OUTOFMEMORY_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_UNSUPPORTEDFORMAT = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_UNRECOGNIZEDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDESC = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_UNSUPPORTEDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDESC + 1 ) , - D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDRESOURCE = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDIMENSIONS + 1 ) , - D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_TOOMANYOBJECTS = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDRESOURCE + 1 ) , - D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_TOOMANYOBJECTS + 1 ) , - D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDARG_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_OUTOFMEMORY_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDESC = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_UNRECOGNIZEDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDESC + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDRESOURCE = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDIMENSIONS + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_TOOMANYOBJECTS = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDRESOURCE + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_TOOMANYOBJECTS + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDARG_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_OUTOFMEMORY = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_OUTOFMEMORY_RETURN + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_TOOMANYELEMENTS = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_OUTOFMEMORY + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_TOOMANYELEMENTS + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INCOMPATIBLEFORMAT = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOT = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INCOMPATIBLEFORMAT + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDINPUTSLOTCLASS = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOT + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_STEPRATESLOTCLASSMISMATCH = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDINPUTSLOTCLASS + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOTCLASSCHANGE = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_STEPRATESLOTCLASSMISMATCH + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSTEPRATECHANGE = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOTCLASSCHANGE + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDALIGNMENT = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSTEPRATECHANGE + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_DUPLICATESEMANTIC = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDALIGNMENT + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_UNPARSEABLEINPUTSIGNATURE = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_DUPLICATESEMANTIC + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_NULLSEMANTIC = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_UNPARSEABLEINPUTSIGNATURE + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_MISSINGELEMENT = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_NULLSEMANTIC + 1 ) , - D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_NULLDESC = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_MISSINGELEMENT + 1 ) , - D3D10_MESSAGE_ID_CREATEVERTEXSHADER_OUTOFMEMORY = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_NULLDESC + 1 ) , - D3D10_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERBYTECODE = ( D3D10_MESSAGE_ID_CREATEVERTEXSHADER_OUTOFMEMORY + 1 ) , - D3D10_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERTYPE = ( D3D10_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERBYTECODE + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_OUTOFMEMORY = ( D3D10_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERTYPE + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERBYTECODE = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_OUTOFMEMORY + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERTYPE = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERBYTECODE + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTOFMEMORY = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERTYPE + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERBYTECODE = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTOFMEMORY + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERTYPE = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERBYTECODE + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMENTRIES = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERTYPE + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSTREAMSTRIDEUNUSED = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMENTRIES + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDDECL = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSTREAMSTRIDEUNUSED + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_EXPECTEDDECL = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDDECL + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSLOT0EXPECTED = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_EXPECTEDDECL + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSLOT = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSLOT0EXPECTED + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_ONLYONEELEMENTPERSLOT = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSLOT + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCOMPONENTCOUNT = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_ONLYONEELEMENTPERSLOT + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTARTCOMPONENTANDCOMPONENTCOUNT = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCOMPONENTCOUNT + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDGAPDEFINITION = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTARTCOMPONENTANDCOMPONENTCOUNT + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_REPEATEDOUTPUT = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDGAPDEFINITION + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSTREAMSTRIDE = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_REPEATEDOUTPUT + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGSEMANTIC = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSTREAMSTRIDE + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MASKMISMATCH = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGSEMANTIC + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_CANTHAVEONLYGAPS = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MASKMISMATCH + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DECLTOOCOMPLEX = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_CANTHAVEONLYGAPS + 1 ) , - D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGOUTPUTSIGNATURE = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DECLTOOCOMPLEX + 1 ) , - D3D10_MESSAGE_ID_CREATEPIXELSHADER_OUTOFMEMORY = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGOUTPUTSIGNATURE + 1 ) , - D3D10_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERBYTECODE = ( D3D10_MESSAGE_ID_CREATEPIXELSHADER_OUTOFMEMORY + 1 ) , - D3D10_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERTYPE = ( D3D10_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERBYTECODE + 1 ) , - D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFILLMODE = ( D3D10_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERTYPE + 1 ) , - D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDCULLMODE = ( D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFILLMODE + 1 ) , - D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDDEPTHBIASCLAMP = ( D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDCULLMODE + 1 ) , - D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDSLOPESCALEDDEPTHBIAS = ( D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDDEPTHBIASCLAMP + 1 ) , - D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_TOOMANYOBJECTS = ( D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDSLOPESCALEDDEPTHBIAS + 1 ) , - D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_NULLDESC = ( D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_TOOMANYOBJECTS + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHWRITEMASK = ( D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_NULLDESC + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHFUNC = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHWRITEMASK + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFAILOP = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHFUNC + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILZFAILOP = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFAILOP + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILPASSOP = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILZFAILOP + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFUNC = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILPASSOP + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFAILOP = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFUNC + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILZFAILOP = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFAILOP + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILPASSOP = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILZFAILOP + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFUNC = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILPASSOP + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_TOOMANYOBJECTS = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFUNC + 1 ) , - D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_NULLDESC = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_TOOMANYOBJECTS + 1 ) , - D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLEND = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_NULLDESC + 1 ) , - D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLEND = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLEND + 1 ) , - D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOP = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLEND + 1 ) , - D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLENDALPHA = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOP + 1 ) , - D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLENDALPHA = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLENDALPHA + 1 ) , - D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOPALPHA = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLENDALPHA + 1 ) , - D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDRENDERTARGETWRITEMASK = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOPALPHA + 1 ) , - D3D10_MESSAGE_ID_CREATEBLENDSTATE_TOOMANYOBJECTS = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDRENDERTARGETWRITEMASK + 1 ) , - D3D10_MESSAGE_ID_CREATEBLENDSTATE_NULLDESC = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_TOOMANYOBJECTS + 1 ) , - D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDFILTER = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_NULLDESC + 1 ) , - D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSU = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDFILTER + 1 ) , - D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSV = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSU + 1 ) , - D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSW = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSV + 1 ) , - D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMIPLODBIAS = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSW + 1 ) , - D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXANISOTROPY = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMIPLODBIAS + 1 ) , - D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDCOMPARISONFUNC = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXANISOTROPY + 1 ) , - D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMINLOD = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDCOMPARISONFUNC + 1 ) , - D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXLOD = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMINLOD + 1 ) , - D3D10_MESSAGE_ID_CREATESAMPLERSTATE_TOOMANYOBJECTS = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXLOD + 1 ) , - D3D10_MESSAGE_ID_CREATESAMPLERSTATE_NULLDESC = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_TOOMANYOBJECTS + 1 ) , - D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDQUERY = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_NULLDESC + 1 ) , - D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDQUERY + 1 ) , - D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_UNEXPECTEDMISCFLAG = ( D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDMISCFLAGS + 1 ) , - D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_NULLDESC = ( D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_UNEXPECTEDMISCFLAG + 1 ) , - D3D10_MESSAGE_ID_IASETVERTEXBUFFERS_INVALIDBUFFER = ( D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_NULLDESC + 1 ) , - D3D10_MESSAGE_ID_IASETINDEXBUFFERS_INVALIDBUFFER = ( D3D10_MESSAGE_ID_IASETVERTEXBUFFERS_INVALIDBUFFER + 1 ) , - D3D10_MESSAGE_ID_VSSETCONSTANTBUFFERS_INVALIDBUFFER = ( D3D10_MESSAGE_ID_IASETINDEXBUFFERS_INVALIDBUFFER + 1 ) , - D3D10_MESSAGE_ID_GSSETCONSTANTBUFFERS_INVALIDBUFFER = ( D3D10_MESSAGE_ID_VSSETCONSTANTBUFFERS_INVALIDBUFFER + 1 ) , - D3D10_MESSAGE_ID_SOSETTARGETS_INVALIDBUFFER = ( D3D10_MESSAGE_ID_GSSETCONSTANTBUFFERS_INVALIDBUFFER + 1 ) , - D3D10_MESSAGE_ID_PSSETCONSTANTBUFFERS_INVALIDBUFFER = ( D3D10_MESSAGE_ID_SOSETTARGETS_INVALIDBUFFER + 1 ) , - D3D10_MESSAGE_ID_CLEARRENDERTARGETVIEW_DENORMFLUSH = ( D3D10_MESSAGE_ID_PSSETCONSTANTBUFFERS_INVALIDBUFFER + 1 ) , - D3D10_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DENORMFLUSH = ( D3D10_MESSAGE_ID_CLEARRENDERTARGETVIEW_DENORMFLUSH + 1 ) , - D3D10_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_SATURATE = ( D3D10_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DENORMFLUSH + 1 ) , - D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSUBRESOURCE = ( D3D10_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_SATURATE + 1 ) , - D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESUBRESOURCE = ( D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSUBRESOURCE + 1 ) , - D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCEBOX = ( D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESUBRESOURCE + 1 ) , - D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCE = ( D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCEBOX + 1 ) , - D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSTATE = ( D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCE + 1 ) , - D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESTATE = ( D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSTATE + 1 ) , - D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCE = ( D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESTATE + 1 ) , - D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDDESTINATIONSTATE = ( D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCE + 1 ) , - D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCESTATE = ( D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDDESTINATIONSTATE + 1 ) , - D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSUBRESOURCE = ( D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCESTATE + 1 ) , - D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONBOX = ( D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSUBRESOURCE + 1 ) , - D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSTATE = ( D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONBOX + 1 ) , - D3D10_MESSAGE_ID_BUFFER_MAP_INVALIDMAPTYPE = ( D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSTATE + 1 ) , - D3D10_MESSAGE_ID_BUFFER_MAP_INVALIDFLAGS = ( D3D10_MESSAGE_ID_BUFFER_MAP_INVALIDMAPTYPE + 1 ) , - D3D10_MESSAGE_ID_BUFFER_MAP_ALREADYMAPPED = ( D3D10_MESSAGE_ID_BUFFER_MAP_INVALIDFLAGS + 1 ) , - D3D10_MESSAGE_ID_BUFFER_MAP_DEVICEREMOVED_RETURN = ( D3D10_MESSAGE_ID_BUFFER_MAP_ALREADYMAPPED + 1 ) , - D3D10_MESSAGE_ID_BUFFER_UNMAP_NOTMAPPED = ( D3D10_MESSAGE_ID_BUFFER_MAP_DEVICEREMOVED_RETURN + 1 ) , - D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDMAPTYPE = ( D3D10_MESSAGE_ID_BUFFER_UNMAP_NOTMAPPED + 1 ) , - D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDMAPTYPE + 1 ) , - D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDFLAGS = ( D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDSUBRESOURCE + 1 ) , - D3D10_MESSAGE_ID_TEXTURE1D_MAP_ALREADYMAPPED = ( D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDFLAGS + 1 ) , - D3D10_MESSAGE_ID_TEXTURE1D_MAP_DEVICEREMOVED_RETURN = ( D3D10_MESSAGE_ID_TEXTURE1D_MAP_ALREADYMAPPED + 1 ) , - D3D10_MESSAGE_ID_TEXTURE1D_UNMAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURE1D_MAP_DEVICEREMOVED_RETURN + 1 ) , - D3D10_MESSAGE_ID_TEXTURE1D_UNMAP_NOTMAPPED = ( D3D10_MESSAGE_ID_TEXTURE1D_UNMAP_INVALIDSUBRESOURCE + 1 ) , - D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDMAPTYPE = ( D3D10_MESSAGE_ID_TEXTURE1D_UNMAP_NOTMAPPED + 1 ) , - D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDMAPTYPE + 1 ) , - D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDFLAGS = ( D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDSUBRESOURCE + 1 ) , - D3D10_MESSAGE_ID_TEXTURE2D_MAP_ALREADYMAPPED = ( D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDFLAGS + 1 ) , - D3D10_MESSAGE_ID_TEXTURE2D_MAP_DEVICEREMOVED_RETURN = ( D3D10_MESSAGE_ID_TEXTURE2D_MAP_ALREADYMAPPED + 1 ) , - D3D10_MESSAGE_ID_TEXTURE2D_UNMAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURE2D_MAP_DEVICEREMOVED_RETURN + 1 ) , - D3D10_MESSAGE_ID_TEXTURE2D_UNMAP_NOTMAPPED = ( D3D10_MESSAGE_ID_TEXTURE2D_UNMAP_INVALIDSUBRESOURCE + 1 ) , - D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDMAPTYPE = ( D3D10_MESSAGE_ID_TEXTURE2D_UNMAP_NOTMAPPED + 1 ) , - D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDMAPTYPE + 1 ) , - D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDFLAGS = ( D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDSUBRESOURCE + 1 ) , - D3D10_MESSAGE_ID_TEXTURE3D_MAP_ALREADYMAPPED = ( D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDFLAGS + 1 ) , - D3D10_MESSAGE_ID_TEXTURE3D_MAP_DEVICEREMOVED_RETURN = ( D3D10_MESSAGE_ID_TEXTURE3D_MAP_ALREADYMAPPED + 1 ) , - D3D10_MESSAGE_ID_TEXTURE3D_UNMAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURE3D_MAP_DEVICEREMOVED_RETURN + 1 ) , - D3D10_MESSAGE_ID_TEXTURE3D_UNMAP_NOTMAPPED = ( D3D10_MESSAGE_ID_TEXTURE3D_UNMAP_INVALIDSUBRESOURCE + 1 ) , - D3D10_MESSAGE_ID_TEXTURECUBE_MAP_INVALIDMAPTYPE = ( D3D10_MESSAGE_ID_TEXTURE3D_UNMAP_NOTMAPPED + 1 ) , - D3D10_MESSAGE_ID_TEXTURECUBE_MAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURECUBE_MAP_INVALIDMAPTYPE + 1 ) , - D3D10_MESSAGE_ID_TEXTURECUBE_MAP_INVALIDFLAGS = ( D3D10_MESSAGE_ID_TEXTURECUBE_MAP_INVALIDSUBRESOURCE + 1 ) , - D3D10_MESSAGE_ID_TEXTURECUBE_MAP_ALREADYMAPPED = ( D3D10_MESSAGE_ID_TEXTURECUBE_MAP_INVALIDFLAGS + 1 ) , - D3D10_MESSAGE_ID_TEXTURECUBE_MAP_DEVICEREMOVED_RETURN = ( D3D10_MESSAGE_ID_TEXTURECUBE_MAP_ALREADYMAPPED + 1 ) , - D3D10_MESSAGE_ID_TEXTURECUBE_UNMAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURECUBE_MAP_DEVICEREMOVED_RETURN + 1 ) , - D3D10_MESSAGE_ID_TEXTURECUBE_UNMAP_NOTMAPPED = ( D3D10_MESSAGE_ID_TEXTURECUBE_UNMAP_INVALIDSUBRESOURCE + 1 ) , - D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_HAZARD = ( D3D10_MESSAGE_ID_TEXTURECUBE_UNMAP_NOTMAPPED + 1 ) , - D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_HAZARD + 1 ) , - D3D10_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_HAZARD + 1 ) , - D3D10_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_HAZARD + 1 ) , - D3D10_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_HAZARD + 1 ) , - D3D10_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_HAZARD + 1 ) , - D3D10_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_HAZARD + 1 ) , - D3D10_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_HAZARD + 1 ) , - D3D10_MESSAGE_ID_DEVICE_OMSETRENDERTARGETS_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_HAZARD + 1 ) , - D3D10_MESSAGE_ID_DEVICE_SOSETTARGETS_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_OMSETRENDERTARGETS_HAZARD + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEXPOS_OVERFLOW = ( D3D10_MESSAGE_ID_DEVICE_SOSETTARGETS_HAZARD + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAWINDEXED_INDEXPOS_OVERFLOW = ( D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEXPOS_OVERFLOW + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAWINSTANCED_VERTEXPOS_OVERFLOW = ( D3D10_MESSAGE_ID_DEVICE_DRAWINDEXED_INDEXPOS_OVERFLOW + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAWINSTANCED_INSTANCEPOS_OVERFLOW = ( D3D10_MESSAGE_ID_DEVICE_DRAWINSTANCED_VERTEXPOS_OVERFLOW + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INSTANCEPOS_OVERFLOW = ( D3D10_MESSAGE_ID_DEVICE_DRAWINSTANCED_INSTANCEPOS_OVERFLOW + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INDEXPOS_OVERFLOW = ( D3D10_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INSTANCEPOS_OVERFLOW + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_SHADER_MISSING = ( D3D10_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INDEXPOS_OVERFLOW + 1 ) , - D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND = ( D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_SHADER_MISSING + 1 ) , - D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERINDEX = ( D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND + 1 ) , - D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_COMPONENTTYPE = ( D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERINDEX + 1 ) , - D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERMASK = ( D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_COMPONENTTYPE + 1 ) , - D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SYSTEMVALUE = ( D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERMASK + 1 ) , - D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_NEVERWRITTEN_ALWAYSREADS = ( D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SYSTEMVALUE + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_NOT_SET = ( D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_NEVERWRITTEN_ALWAYSREADS + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_INPUTLAYOUT_NOT_SET = ( D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_NOT_SET + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_NOT_SET = ( D3D10_MESSAGE_ID_DEVICE_DRAW_INPUTLAYOUT_NOT_SET + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_TOO_SMALL = ( D3D10_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_NOT_SET + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_SAMPLER_NOT_SET = ( D3D10_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_TOO_SMALL + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_SHADERRESOURCEVIEW_NOT_SET = ( D3D10_MESSAGE_ID_DEVICE_DRAW_SAMPLER_NOT_SET + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_DIMENSION_MISMATCH = ( D3D10_MESSAGE_ID_DEVICE_DRAW_SHADERRESOURCEVIEW_NOT_SET + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_STRIDE_TOO_SMALL = ( D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_DIMENSION_MISMATCH + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_TOO_SMALL = ( D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_STRIDE_TOO_SMALL + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_NOT_SET = ( D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_TOO_SMALL + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_FORMAT_INVALID = ( D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_NOT_SET + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL = ( D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_FORMAT_INVALID + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_GS_INPUT_PRIMITIVE_MISMATCH = ( D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_RETURN_TYPE_MISMATCH = ( D3D10_MESSAGE_ID_DEVICE_DRAW_GS_INPUT_PRIMITIVE_MISMATCH + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_POSITION_NOT_PRESENT = ( D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_RETURN_TYPE_MISMATCH + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_NOT_PRESENT = ( D3D10_MESSAGE_ID_DEVICE_DRAW_POSITION_NOT_PRESENT + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_BOUND_RESOURCE_MAPPED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_NOT_PRESENT + 1 ) , - D3D10_MESSAGE_ID_SETEXCEPTIONMODE_UNRECOGNIZEDFLAGS = ( D3D10_MESSAGE_ID_DEVICE_DRAW_BOUND_RESOURCE_MAPPED + 1 ) , - D3D10_MESSAGE_ID_SETEXCEPTIONMODE_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_SETEXCEPTIONMODE_UNRECOGNIZEDFLAGS + 1 ) , - D3D10_MESSAGE_ID_SETEXCEPTIONMODE_DEVICEREMOVED_RETURN = ( D3D10_MESSAGE_ID_SETEXCEPTIONMODE_INVALIDARG_RETURN + 1 ) , - D3D10_MESSAGE_ID_REF_SIMULATING_INFINITELY_FAST_HARDWARE = ( D3D10_MESSAGE_ID_SETEXCEPTIONMODE_DEVICEREMOVED_RETURN + 1 ) , - D3D10_MESSAGE_ID_REF_THREADING_MODE = ( D3D10_MESSAGE_ID_REF_SIMULATING_INFINITELY_FAST_HARDWARE + 1 ) , - D3D10_MESSAGE_ID_REF_UMDRIVER_EXCEPTION = ( D3D10_MESSAGE_ID_REF_THREADING_MODE + 1 ) , - D3D10_MESSAGE_ID_REF_KMDRIVER_EXCEPTION = ( D3D10_MESSAGE_ID_REF_UMDRIVER_EXCEPTION + 1 ) , - D3D10_MESSAGE_ID_REF_HARDWARE_EXCEPTION = ( D3D10_MESSAGE_ID_REF_KMDRIVER_EXCEPTION + 1 ) , - D3D10_MESSAGE_ID_REF_ACCESSING_INDEXABLE_TEMP_OUT_OF_RANGE = ( D3D10_MESSAGE_ID_REF_HARDWARE_EXCEPTION + 1 ) , - D3D10_MESSAGE_ID_REF_PROBLEM_PARSING_SHADER = ( D3D10_MESSAGE_ID_REF_ACCESSING_INDEXABLE_TEMP_OUT_OF_RANGE + 1 ) , - D3D10_MESSAGE_ID_REF_OUT_OF_MEMORY = ( D3D10_MESSAGE_ID_REF_PROBLEM_PARSING_SHADER + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_INVALID_PRIMITIVETOPOLOGY = ( D3D10_MESSAGE_ID_REF_OUT_OF_MEMORY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_OFFSET_UNALIGNED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_INVALID_PRIMITIVETOPOLOGY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_STRIDE_UNALIGNED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_OFFSET_UNALIGNED + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_OFFSET_UNALIGNED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_STRIDE_UNALIGNED + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_OFFSET_UNALIGNED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_OFFSET_UNALIGNED + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_LD_UNSUPPORTED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_OFFSET_UNALIGNED + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_UNSUPPORTED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_LD_UNSUPPORTED + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_C_UNSUPPORTED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_UNSUPPORTED + 1 ) , - D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_MULTISAMPLE_UNSUPPORTED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_C_UNSUPPORTED + 1 ) , - D3D10_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNRECOGNIZED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_MULTISAMPLE_UNSUPPORTED + 1 ) , - D3D10_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNDEFINED = ( D3D10_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNRECOGNIZED + 1 ) , - D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_OFFSET_TOO_LARGE = ( D3D10_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNDEFINED + 1 ) , - D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_FORMAT_INVALID = ( D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_OFFSET_TOO_LARGE + 1 ) , - D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_TOO_LARGE = ( D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_FORMAT_INVALID + 1 ) , - D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_UNALIGNED = ( D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_TOO_LARGE + 1 ) , - D3D10_MESSAGE_ID_DEVICE_SOSETTARGETS_OFFSET_UNALIGNED = ( D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_UNALIGNED + 1 ) , - D3D10_MESSAGE_ID_DEVICE_GENERATEMIPS_RESOURCE_INVALID = ( D3D10_MESSAGE_ID_DEVICE_SOSETTARGETS_OFFSET_UNALIGNED + 1 ) , - D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_GENERATEMIPS_RESOURCE_INVALID + 1 ) , - D3D10_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_VIEWS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_BUFFERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_VIEWS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_VSSETSAMPLERS_SAMPLERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_BUFFERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_VIEWS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_VSSETSAMPLERS_SAMPLERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_VIEWS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_GSSETSAMPLERS_SAMPLERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_BUFFERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_VIEWS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_GSSETSAMPLERS_SAMPLERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_VIEWS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_PSSETSAMPLERS_SAMPLERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_BUFFERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_IAGETVERTEXBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_PSSETSAMPLERS_SAMPLERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_VSGETSHADERRESOURCES_VIEWS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_IAGETVERTEXBUFFERS_BUFFERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_VSGETCONSTANTBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_VSGETSHADERRESOURCES_VIEWS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_VSGETSAMPLERS_SAMPLERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_VSGETCONSTANTBUFFERS_BUFFERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_GSGETSHADERRESOURCES_VIEWS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_VSGETSAMPLERS_SAMPLERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_GSGETCONSTANTBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_GSGETSHADERRESOURCES_VIEWS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_GSGETSAMPLERS_SAMPLERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_GSGETCONSTANTBUFFERS_BUFFERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_SOGETTARGETS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_GSGETSAMPLERS_SAMPLERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_PSGETSHADERRESOURCES_VIEWS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_SOGETTARGETS_BUFFERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_PSGETCONSTANTBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_PSGETSHADERRESOURCES_VIEWS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_PSGETSAMPLERS_SAMPLERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_PSGETCONSTANTBUFFERS_BUFFERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_RSGETVIEWPORTS_VIEWPORTS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_PSGETSAMPLERS_SAMPLERS_EMPTY + 1 ) , - D3D10_MESSAGE_ID_DEVICE_RSGETSCISSORRECTS_RECTS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_RSGETVIEWPORTS_VIEWPORTS_EMPTY + 1 ) - } D3D10_MESSAGE_ID; - -typedef struct D3D10_MESSAGE - { - D3D10_MESSAGE_CATEGORY Category; - D3D10_MESSAGE_SEVERITY Severity; - D3D10_MESSAGE_ID ID; - const WCHAR *pDescription; - SIZE_T DescriptionByteLength; - } D3D10_MESSAGE; - -typedef struct D3D10_INFO_QUEUE_FILTER_DESC - { - UINT NumCategories; - D3D10_MESSAGE_CATEGORY *pCategoryList; - UINT NumSeverities; - D3D10_MESSAGE_SEVERITY *pSeverityList; - UINT NumIDs; - D3D10_MESSAGE_ID *pIDList; - } D3D10_INFO_QUEUE_FILTER_DESC; - -typedef struct D3D10_INFO_QUEUE_FILTER - { - D3D10_INFO_QUEUE_FILTER_DESC AllowList; - D3D10_INFO_QUEUE_FILTER_DESC DenyList; - } D3D10_INFO_QUEUE_FILTER; - -#define D3D10_INFO_QUEUE_DEFAULT_MESSAGE_COUNT_LIMIT 1024 - - -extern RPC_IF_HANDLE __MIDL_itf_d3d10sdklayers_0000_0001_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d10sdklayers_0000_0001_v0_0_s_ifspec; - -#ifndef __ID3D10InfoQueue_INTERFACE_DEFINED__ -#define __ID3D10InfoQueue_INTERFACE_DEFINED__ - -/* interface ID3D10InfoQueue */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D10InfoQueue; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("1b940b17-2642-4d1f-ab1f-b99bad0c395f") - ID3D10InfoQueue : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE SetMessageCountLimit( - /* */ - __in UINT64 MessageCountLimit) = 0; - - virtual void STDMETHODCALLTYPE ClearStoredMessages( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetMessage( - /* */ - __in UINT64 MessageIndex, - /* */ - __out_bcount_opt(*pMessageByteLength) D3D10_MESSAGE *pMessage, - /* */ - __inout SIZE_T *pMessageByteLength) = 0; - - virtual UINT64 STDMETHODCALLTYPE GetNumMessagesAllowedByStorageFilter( void) = 0; - - virtual UINT64 STDMETHODCALLTYPE GetNumMessagesDeniedByStorageFilter( void) = 0; - - virtual UINT64 STDMETHODCALLTYPE GetNumStoredMessages( void) = 0; - - virtual UINT64 STDMETHODCALLTYPE GetNumStoredMessagesAllowedByRetrievalFilter( void) = 0; - - virtual UINT64 STDMETHODCALLTYPE GetNumMessagesDiscardedByMessageCountLimit( void) = 0; - - virtual UINT64 STDMETHODCALLTYPE GetMessageCountLimit( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE AddStorageFilterEntries( - /* */ - __in D3D10_INFO_QUEUE_FILTER *pFilter) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetStorageFilter( - /* */ - __out_bcount_opt(*pFilterByteLength) D3D10_INFO_QUEUE_FILTER *pFilter, - /* */ - __inout SIZE_T *pFilterByteLength) = 0; - - virtual void STDMETHODCALLTYPE ClearStorageFilter( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE PushEmptyStorageFilter( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE PushCopyOfStorageFilter( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE PushStorageFilter( - /* */ - __in D3D10_INFO_QUEUE_FILTER *pFilter) = 0; - - virtual void STDMETHODCALLTYPE PopStorageFilter( void) = 0; - - virtual UINT STDMETHODCALLTYPE GetStorageFilterStackSize( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE AddRetrievalFilterEntries( - /* */ - __in D3D10_INFO_QUEUE_FILTER *pFilter) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetRetrievalFilter( - /* */ - __out_bcount_opt(*pFilterByteLength) D3D10_INFO_QUEUE_FILTER *pFilter, - /* */ - __inout SIZE_T *pFilterByteLength) = 0; - - virtual void STDMETHODCALLTYPE ClearRetrievalFilter( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE PushEmptyRetrievalFilter( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE PushCopyOfRetrievalFilter( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE PushRetrievalFilter( - /* */ - __in D3D10_INFO_QUEUE_FILTER *pFilter) = 0; - - virtual void STDMETHODCALLTYPE PopRetrievalFilter( void) = 0; - - virtual UINT STDMETHODCALLTYPE GetRetrievalFilterStackSize( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE AddMessage( - /* */ - __in D3D10_MESSAGE_CATEGORY Category, - /* */ - __in D3D10_MESSAGE_SEVERITY Severity, - /* */ - __in D3D10_MESSAGE_ID ID, - /* */ - __in LPCWSTR pDescription) = 0; - - virtual HRESULT STDMETHODCALLTYPE AddApplicationMessage( - /* */ - __in D3D10_MESSAGE_SEVERITY Severity, - /* */ - __in LPCWSTR pDescription) = 0; - - }; - -#else /* C style interface */ - - typedef struct ID3D10InfoQueueVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D10InfoQueue * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D10InfoQueue * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D10InfoQueue * This); - - HRESULT ( STDMETHODCALLTYPE *SetMessageCountLimit )( - ID3D10InfoQueue * This, - /* */ - __in UINT64 MessageCountLimit); - - void ( STDMETHODCALLTYPE *ClearStoredMessages )( - ID3D10InfoQueue * This); - - HRESULT ( STDMETHODCALLTYPE *GetMessage )( - ID3D10InfoQueue * This, - /* */ - __in UINT64 MessageIndex, - /* */ - __out_bcount_opt(*pMessageByteLength) D3D10_MESSAGE *pMessage, - /* */ - __inout SIZE_T *pMessageByteLength); - - UINT64 ( STDMETHODCALLTYPE *GetNumMessagesAllowedByStorageFilter )( - ID3D10InfoQueue * This); - - UINT64 ( STDMETHODCALLTYPE *GetNumMessagesDeniedByStorageFilter )( - ID3D10InfoQueue * This); - - UINT64 ( STDMETHODCALLTYPE *GetNumStoredMessages )( - ID3D10InfoQueue * This); - - UINT64 ( STDMETHODCALLTYPE *GetNumStoredMessagesAllowedByRetrievalFilter )( - ID3D10InfoQueue * This); - - UINT64 ( STDMETHODCALLTYPE *GetNumMessagesDiscardedByMessageCountLimit )( - ID3D10InfoQueue * This); - - UINT64 ( STDMETHODCALLTYPE *GetMessageCountLimit )( - ID3D10InfoQueue * This); - - HRESULT ( STDMETHODCALLTYPE *AddStorageFilterEntries )( - ID3D10InfoQueue * This, - /* */ - __in D3D10_INFO_QUEUE_FILTER *pFilter); - - HRESULT ( STDMETHODCALLTYPE *GetStorageFilter )( - ID3D10InfoQueue * This, - /* */ - __out_bcount_opt(*pFilterByteLength) D3D10_INFO_QUEUE_FILTER *pFilter, - /* */ - __inout SIZE_T *pFilterByteLength); - - void ( STDMETHODCALLTYPE *ClearStorageFilter )( - ID3D10InfoQueue * This); - - HRESULT ( STDMETHODCALLTYPE *PushEmptyStorageFilter )( - ID3D10InfoQueue * This); - - HRESULT ( STDMETHODCALLTYPE *PushCopyOfStorageFilter )( - ID3D10InfoQueue * This); - - HRESULT ( STDMETHODCALLTYPE *PushStorageFilter )( - ID3D10InfoQueue * This, - /* */ - __in D3D10_INFO_QUEUE_FILTER *pFilter); - - void ( STDMETHODCALLTYPE *PopStorageFilter )( - ID3D10InfoQueue * This); - - UINT ( STDMETHODCALLTYPE *GetStorageFilterStackSize )( - ID3D10InfoQueue * This); - - HRESULT ( STDMETHODCALLTYPE *AddRetrievalFilterEntries )( - ID3D10InfoQueue * This, - /* */ - __in D3D10_INFO_QUEUE_FILTER *pFilter); - - HRESULT ( STDMETHODCALLTYPE *GetRetrievalFilter )( - ID3D10InfoQueue * This, - /* */ - __out_bcount_opt(*pFilterByteLength) D3D10_INFO_QUEUE_FILTER *pFilter, - /* */ - __inout SIZE_T *pFilterByteLength); - - void ( STDMETHODCALLTYPE *ClearRetrievalFilter )( - ID3D10InfoQueue * This); - - HRESULT ( STDMETHODCALLTYPE *PushEmptyRetrievalFilter )( - ID3D10InfoQueue * This); - - HRESULT ( STDMETHODCALLTYPE *PushCopyOfRetrievalFilter )( - ID3D10InfoQueue * This); - - HRESULT ( STDMETHODCALLTYPE *PushRetrievalFilter )( - ID3D10InfoQueue * This, - /* */ - __in D3D10_INFO_QUEUE_FILTER *pFilter); - - void ( STDMETHODCALLTYPE *PopRetrievalFilter )( - ID3D10InfoQueue * This); - - UINT ( STDMETHODCALLTYPE *GetRetrievalFilterStackSize )( - ID3D10InfoQueue * This); - - HRESULT ( STDMETHODCALLTYPE *AddMessage )( - ID3D10InfoQueue * This, - /* */ - __in D3D10_MESSAGE_CATEGORY Category, - /* */ - __in D3D10_MESSAGE_SEVERITY Severity, - /* */ - __in D3D10_MESSAGE_ID ID, - /* */ - __in LPCWSTR pDescription); - - HRESULT ( STDMETHODCALLTYPE *AddApplicationMessage )( - ID3D10InfoQueue * This, - /* */ - __in D3D10_MESSAGE_SEVERITY Severity, - /* */ - __in LPCWSTR pDescription); - - END_INTERFACE - } ID3D10InfoQueueVtbl; - - interface ID3D10InfoQueue - { - CONST_VTBL struct ID3D10InfoQueueVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D10InfoQueue_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D10InfoQueue_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D10InfoQueue_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D10InfoQueue_SetMessageCountLimit(This,MessageCountLimit) \ - ( (This)->lpVtbl -> SetMessageCountLimit(This,MessageCountLimit) ) - -#define ID3D10InfoQueue_ClearStoredMessages(This) \ - ( (This)->lpVtbl -> ClearStoredMessages(This) ) - -#define ID3D10InfoQueue_GetMessage(This,MessageIndex,pMessage,pMessageByteLength) \ - ( (This)->lpVtbl -> GetMessage(This,MessageIndex,pMessage,pMessageByteLength) ) - -#define ID3D10InfoQueue_GetNumMessagesAllowedByStorageFilter(This) \ - ( (This)->lpVtbl -> GetNumMessagesAllowedByStorageFilter(This) ) - -#define ID3D10InfoQueue_GetNumMessagesDeniedByStorageFilter(This) \ - ( (This)->lpVtbl -> GetNumMessagesDeniedByStorageFilter(This) ) - -#define ID3D10InfoQueue_GetNumStoredMessages(This) \ - ( (This)->lpVtbl -> GetNumStoredMessages(This) ) - -#define ID3D10InfoQueue_GetNumStoredMessagesAllowedByRetrievalFilter(This) \ - ( (This)->lpVtbl -> GetNumStoredMessagesAllowedByRetrievalFilter(This) ) - -#define ID3D10InfoQueue_GetNumMessagesDiscardedByMessageCountLimit(This) \ - ( (This)->lpVtbl -> GetNumMessagesDiscardedByMessageCountLimit(This) ) - -#define ID3D10InfoQueue_GetMessageCountLimit(This) \ - ( (This)->lpVtbl -> GetMessageCountLimit(This) ) - -#define ID3D10InfoQueue_AddStorageFilterEntries(This,pFilter) \ - ( (This)->lpVtbl -> AddStorageFilterEntries(This,pFilter) ) - -#define ID3D10InfoQueue_GetStorageFilter(This,pFilter,pFilterByteLength) \ - ( (This)->lpVtbl -> GetStorageFilter(This,pFilter,pFilterByteLength) ) - -#define ID3D10InfoQueue_ClearStorageFilter(This) \ - ( (This)->lpVtbl -> ClearStorageFilter(This) ) - -#define ID3D10InfoQueue_PushEmptyStorageFilter(This) \ - ( (This)->lpVtbl -> PushEmptyStorageFilter(This) ) - -#define ID3D10InfoQueue_PushCopyOfStorageFilter(This) \ - ( (This)->lpVtbl -> PushCopyOfStorageFilter(This) ) - -#define ID3D10InfoQueue_PushStorageFilter(This,pFilter) \ - ( (This)->lpVtbl -> PushStorageFilter(This,pFilter) ) - -#define ID3D10InfoQueue_PopStorageFilter(This) \ - ( (This)->lpVtbl -> PopStorageFilter(This) ) - -#define ID3D10InfoQueue_GetStorageFilterStackSize(This) \ - ( (This)->lpVtbl -> GetStorageFilterStackSize(This) ) - -#define ID3D10InfoQueue_AddRetrievalFilterEntries(This,pFilter) \ - ( (This)->lpVtbl -> AddRetrievalFilterEntries(This,pFilter) ) - -#define ID3D10InfoQueue_GetRetrievalFilter(This,pFilter,pFilterByteLength) \ - ( (This)->lpVtbl -> GetRetrievalFilter(This,pFilter,pFilterByteLength) ) - -#define ID3D10InfoQueue_ClearRetrievalFilter(This) \ - ( (This)->lpVtbl -> ClearRetrievalFilter(This) ) - -#define ID3D10InfoQueue_PushEmptyRetrievalFilter(This) \ - ( (This)->lpVtbl -> PushEmptyRetrievalFilter(This) ) - -#define ID3D10InfoQueue_PushCopyOfRetrievalFilter(This) \ - ( (This)->lpVtbl -> PushCopyOfRetrievalFilter(This) ) - -#define ID3D10InfoQueue_PushRetrievalFilter(This,pFilter) \ - ( (This)->lpVtbl -> PushRetrievalFilter(This,pFilter) ) - -#define ID3D10InfoQueue_PopRetrievalFilter(This) \ - ( (This)->lpVtbl -> PopRetrievalFilter(This) ) - -#define ID3D10InfoQueue_GetRetrievalFilterStackSize(This) \ - ( (This)->lpVtbl -> GetRetrievalFilterStackSize(This) ) - -#define ID3D10InfoQueue_AddMessage(This,Category,Severity,ID,pDescription) \ - ( (This)->lpVtbl -> AddMessage(This,Category,Severity,ID,pDescription) ) - -#define ID3D10InfoQueue_AddApplicationMessage(This,Severity,pDescription) \ - ( (This)->lpVtbl -> AddApplicationMessage(This,Severity,pDescription) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D10InfoQueue_INTERFACE_DEFINED__ */ - - -/* Additional Prototypes for ALL interfaces */ - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 7.00.0485 */ +/* Compiler settings for d3d10sdklayers.idl: + Oicf, W1, Zp8, env=Win32 (32b run) + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +//@@MIDL_FILE_HEADING( ) + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCSAL_H_VERSION__ +#define __REQUIRED_RPCSAL_H_VERSION__ 100 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif // __RPCNDR_H_VERSION__ + +#ifndef COM_NO_WINDOWS_H +#include "windows.h" +#include "ole2.h" +#endif /*COM_NO_WINDOWS_H*/ + +#ifndef __d3d10sdklayers_h__ +#define __d3d10sdklayers_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +#ifndef __ID3D10Debug_FWD_DEFINED__ +#define __ID3D10Debug_FWD_DEFINED__ +typedef interface ID3D10Debug ID3D10Debug; +#endif /* __ID3D10Debug_FWD_DEFINED__ */ + + +#ifndef __ID3D10InfoQueue_FWD_DEFINED__ +#define __ID3D10InfoQueue_FWD_DEFINED__ +typedef interface ID3D10InfoQueue ID3D10InfoQueue; +#endif /* __ID3D10InfoQueue_FWD_DEFINED__ */ + + +/* header files for imported files */ +#include "oaidl.h" +#include "ocidl.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +/* interface __MIDL_itf_d3d10sdklayers_0000_0000 */ +/* [local] */ + +#define D3D10_SDK_LAYERS_VERSION ( 2 ) + +#define D3D10_DEBUG_FEATURE_FLUSH_PER_RENDER_OP ( 0x1 ) + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10sdklayers_0000_0000_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10sdklayers_0000_0000_v0_0_s_ifspec; + +#ifndef __ID3D10Debug_INTERFACE_DEFINED__ +#define __ID3D10Debug_INTERFACE_DEFINED__ + +/* interface ID3D10Debug */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10Debug; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9B7E4E01-342C-4106-A19F-4F2704F689F0") + ID3D10Debug : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE SetFeatureMask( + UINT Mask) = 0; + + virtual UINT STDMETHODCALLTYPE GetFeatureMask( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE Validate( void) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10DebugVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10Debug * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10Debug * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10Debug * This); + + HRESULT ( STDMETHODCALLTYPE *SetFeatureMask )( + ID3D10Debug * This, + UINT Mask); + + UINT ( STDMETHODCALLTYPE *GetFeatureMask )( + ID3D10Debug * This); + + HRESULT ( STDMETHODCALLTYPE *Validate )( + ID3D10Debug * This); + + END_INTERFACE + } ID3D10DebugVtbl; + + interface ID3D10Debug + { + CONST_VTBL struct ID3D10DebugVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10Debug_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10Debug_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10Debug_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10Debug_SetFeatureMask(This,Mask) \ + ( (This)->lpVtbl -> SetFeatureMask(This,Mask) ) + +#define ID3D10Debug_GetFeatureMask(This) \ + ( (This)->lpVtbl -> GetFeatureMask(This) ) + +#define ID3D10Debug_Validate(This) \ + ( (This)->lpVtbl -> Validate(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10Debug_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d10sdklayers_0000_0001 */ +/* [local] */ + +typedef +enum D3D10_MESSAGE_CATEGORY + { D3D10_MESSAGE_CATEGORY_APPLICATION_DEFINED = 0, + D3D10_MESSAGE_CATEGORY_MISCELLANEOUS = ( D3D10_MESSAGE_CATEGORY_APPLICATION_DEFINED + 1 ) , + D3D10_MESSAGE_CATEGORY_INITIALIZATION = ( D3D10_MESSAGE_CATEGORY_MISCELLANEOUS + 1 ) , + D3D10_MESSAGE_CATEGORY_CLEANUP = ( D3D10_MESSAGE_CATEGORY_INITIALIZATION + 1 ) , + D3D10_MESSAGE_CATEGORY_COMPILATION = ( D3D10_MESSAGE_CATEGORY_CLEANUP + 1 ) , + D3D10_MESSAGE_CATEGORY_STATE_CREATION = ( D3D10_MESSAGE_CATEGORY_COMPILATION + 1 ) , + D3D10_MESSAGE_CATEGORY_STATE_SETTING = ( D3D10_MESSAGE_CATEGORY_STATE_CREATION + 1 ) , + D3D10_MESSAGE_CATEGORY_STATE_GETTING = ( D3D10_MESSAGE_CATEGORY_STATE_SETTING + 1 ) , + D3D10_MESSAGE_CATEGORY_RESOURCE_MANIPULATION = ( D3D10_MESSAGE_CATEGORY_STATE_GETTING + 1 ) , + D3D10_MESSAGE_CATEGORY_EXECUTION = ( D3D10_MESSAGE_CATEGORY_RESOURCE_MANIPULATION + 1 ) + } D3D10_MESSAGE_CATEGORY; + +typedef +enum D3D10_MESSAGE_SEVERITY + { D3D10_MESSAGE_SEVERITY_CORRUPTION = 0, + D3D10_MESSAGE_SEVERITY_ERROR = ( D3D10_MESSAGE_SEVERITY_CORRUPTION + 1 ) , + D3D10_MESSAGE_SEVERITY_WARNING = ( D3D10_MESSAGE_SEVERITY_ERROR + 1 ) , + D3D10_MESSAGE_SEVERITY_INFO = ( D3D10_MESSAGE_SEVERITY_WARNING + 1 ) + } D3D10_MESSAGE_SEVERITY; + +typedef +enum D3D10_MESSAGE_ID + { D3D10_MESSAGE_ID_UNKNOWN = 0, + D3D10_MESSAGE_ID_STRING_FROM_APPLICATION = ( D3D10_MESSAGE_ID_UNKNOWN + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_THIS = ( D3D10_MESSAGE_ID_STRING_FROM_APPLICATION + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER0 = ( D3D10_MESSAGE_ID_CORRUPTED_THIS + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER1 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER0 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER2 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER1 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER3 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER2 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER4 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER3 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER5 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER4 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER6 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER5 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER7 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER6 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER8 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER7 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER9 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER8 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER10 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER9 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER11 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER10 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER12 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER11 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER13 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER12 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER14 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER13 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_PARAMETER15 = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER14 + 1 ) , + D3D10_MESSAGE_ID_CORRUPTED_MULTITHREADING = ( D3D10_MESSAGE_ID_CORRUPTED_PARAMETER15 + 1 ) , + D3D10_MESSAGE_ID_MESSAGE_REPORTING_OUTOFMEMORY = ( D3D10_MESSAGE_ID_CORRUPTED_MULTITHREADING + 1 ) , + D3D10_MESSAGE_ID_IASETINPUTLAYOUT_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_MESSAGE_REPORTING_OUTOFMEMORY + 1 ) , + D3D10_MESSAGE_ID_IASETVERTEXBUFFERS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_IASETINPUTLAYOUT_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_IASETINDEXBUFFER_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_IASETVERTEXBUFFERS_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_VSSETSHADER_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_IASETINDEXBUFFER_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_VSSETSHADERRESOURCES_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_VSSETSHADER_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_VSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_VSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_VSSETSAMPLERS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_VSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_GSSETSHADER_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_VSSETSAMPLERS_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_GSSETSHADERRESOURCES_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_GSSETSHADER_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_GSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_GSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_GSSETSAMPLERS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_GSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_SOSETTARGETS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_GSSETSAMPLERS_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_PSSETSHADER_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_SOSETTARGETS_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_PSSETSHADERRESOURCES_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_PSSETSHADER_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_PSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_PSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_PSSETSAMPLERS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_PSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_RSSETSTATE_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_PSSETSAMPLERS_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_OMSETBLENDSTATE_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_RSSETSTATE_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_OMSETDEPTHSTENCILSTATE_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_OMSETBLENDSTATE_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_OMSETRENDERTARGETS_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_OMSETDEPTHSTENCILSTATE_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_SETPREDICATION_UNBINDDELETINGOBJECT = ( D3D10_MESSAGE_ID_OMSETRENDERTARGETS_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_GETPRIVATEDATA_MOREDATA = ( D3D10_MESSAGE_ID_SETPREDICATION_UNBINDDELETINGOBJECT + 1 ) , + D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDFREEDATA = ( D3D10_MESSAGE_ID_GETPRIVATEDATA_MOREDATA + 1 ) , + D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDIUNKNOWN = ( D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDFREEDATA + 1 ) , + D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDFLAGS = ( D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDIUNKNOWN + 1 ) , + D3D10_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS = ( D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDFLAGS + 1 ) , + D3D10_MESSAGE_ID_SETPRIVATEDATA_OUTOFMEMORY = ( D3D10_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_SETPRIVATEDATA_OUTOFMEMORY + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDSAMPLES = ( D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDUSAGE = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDSAMPLES + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDUSAGE + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDBINDFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDCPUACCESSFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDMISCFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDCPUACCESSFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDINITIALDATA = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDBINDFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDINITIALDATA + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDMIPLEVELS = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDDIMENSIONS + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDMIPLEVELS + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDMISCFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDARG_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATEBUFFER_NULLDESC = ( D3D10_MESSAGE_ID_CREATEBUFFER_OUTOFMEMORY_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_CREATEBUFFER_NULLDESC + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_UNSUPPORTEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDSAMPLES = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_UNSUPPORTEDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDUSAGE = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDSAMPLES + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDUSAGE + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDBINDFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDCPUACCESSFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDMISCFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDCPUACCESSFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDINITIALDATA = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDBINDFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDINITIALDATA + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDMIPLEVELS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDDIMENSIONS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDMIPLEVELS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDMISCFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDARG_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_NULLDESC = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_OUTOFMEMORY_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE1D_RESOURCETOOLARGE = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_NULLDESC + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE1D_RESOURCETOOLARGE + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_UNSUPPORTEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDSAMPLES = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_UNSUPPORTEDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDUSAGE = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDSAMPLES + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDUSAGE + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDBINDFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDCPUACCESSFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDMISCFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDCPUACCESSFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDINITIALDATA = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDBINDFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDINITIALDATA + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDMIPLEVELS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDDIMENSIONS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDMIPLEVELS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDMISCFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDARG_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_NULLDESC = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_OUTOFMEMORY_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE2D_RESOURCETOOLARGE = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_NULLDESC + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE2D_RESOURCETOOLARGE + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_UNSUPPORTEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDSAMPLES = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_UNSUPPORTEDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDUSAGE = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDSAMPLES + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDUSAGE + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDBINDFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDCPUACCESSFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDMISCFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDCPUACCESSFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDINITIALDATA = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDBINDFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDINITIALDATA + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDMIPLEVELS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDDIMENSIONS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDMIPLEVELS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDMISCFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDARG_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_NULLDESC = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_OUTOFMEMORY_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURE3D_RESOURCETOOLARGE = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_NULLDESC + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURE3D_RESOURCETOOLARGE + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNSUPPORTEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDSAMPLES = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNSUPPORTEDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDUSAGE = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDSAMPLES + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDUSAGE + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDBINDFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDCPUACCESSFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_UNRECOGNIZEDMISCFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDCPUACCESSFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDBINDFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDCPUACCESSFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDINITIALDATA = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDBINDFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDINITIALDATA + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDMIPLEVELS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDDIMENSIONS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDMIPLEVELS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDMISCFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_INVALIDARG_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_NULLDESC = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_OUTOFMEMORY_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATETEXTURECUBE_RESOURCETOOLARGE = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_NULLDESC + 1 ) , + D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_CREATETEXTURECUBE_RESOURCETOOLARGE + 1 ) , + D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDESC = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_UNRECOGNIZEDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDESC + 1 ) , + D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDRESOURCE = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDIMENSIONS + 1 ) , + D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_TOOMANYOBJECTS = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDRESOURCE + 1 ) , + D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_TOOMANYOBJECTS + 1 ) , + D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDARG_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_OUTOFMEMORY_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_UNSUPPORTEDFORMAT = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_UNRECOGNIZEDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDESC = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_UNSUPPORTEDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDESC + 1 ) , + D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDRESOURCE = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDIMENSIONS + 1 ) , + D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_TOOMANYOBJECTS = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDRESOURCE + 1 ) , + D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_TOOMANYOBJECTS + 1 ) , + D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDARG_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_UNRECOGNIZEDFORMAT = ( D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_OUTOFMEMORY_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDESC = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_UNRECOGNIZEDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDESC + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDIMENSIONS = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDRESOURCE = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDIMENSIONS + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_TOOMANYOBJECTS = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDRESOURCE + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_TOOMANYOBJECTS + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_OUTOFMEMORY_RETURN = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDARG_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_OUTOFMEMORY = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_OUTOFMEMORY_RETURN + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_TOOMANYELEMENTS = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_OUTOFMEMORY + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDFORMAT = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_TOOMANYELEMENTS + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INCOMPATIBLEFORMAT = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOT = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INCOMPATIBLEFORMAT + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDINPUTSLOTCLASS = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOT + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_STEPRATESLOTCLASSMISMATCH = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDINPUTSLOTCLASS + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOTCLASSCHANGE = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_STEPRATESLOTCLASSMISMATCH + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSTEPRATECHANGE = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOTCLASSCHANGE + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDALIGNMENT = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSTEPRATECHANGE + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_DUPLICATESEMANTIC = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDALIGNMENT + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_UNPARSEABLEINPUTSIGNATURE = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_DUPLICATESEMANTIC + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_NULLSEMANTIC = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_UNPARSEABLEINPUTSIGNATURE + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_MISSINGELEMENT = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_NULLSEMANTIC + 1 ) , + D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_NULLDESC = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_MISSINGELEMENT + 1 ) , + D3D10_MESSAGE_ID_CREATEVERTEXSHADER_OUTOFMEMORY = ( D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_NULLDESC + 1 ) , + D3D10_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERBYTECODE = ( D3D10_MESSAGE_ID_CREATEVERTEXSHADER_OUTOFMEMORY + 1 ) , + D3D10_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERTYPE = ( D3D10_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERBYTECODE + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_OUTOFMEMORY = ( D3D10_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERTYPE + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERBYTECODE = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_OUTOFMEMORY + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERTYPE = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERBYTECODE + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTOFMEMORY = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERTYPE + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERBYTECODE = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTOFMEMORY + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERTYPE = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERBYTECODE + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMENTRIES = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERTYPE + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSTREAMSTRIDEUNUSED = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMENTRIES + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDDECL = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSTREAMSTRIDEUNUSED + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_EXPECTEDDECL = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDDECL + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSLOT0EXPECTED = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_EXPECTEDDECL + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSLOT = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSLOT0EXPECTED + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_ONLYONEELEMENTPERSLOT = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSLOT + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCOMPONENTCOUNT = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_ONLYONEELEMENTPERSLOT + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTARTCOMPONENTANDCOMPONENTCOUNT = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCOMPONENTCOUNT + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDGAPDEFINITION = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTARTCOMPONENTANDCOMPONENTCOUNT + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_REPEATEDOUTPUT = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDGAPDEFINITION + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSTREAMSTRIDE = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_REPEATEDOUTPUT + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGSEMANTIC = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSTREAMSTRIDE + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MASKMISMATCH = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGSEMANTIC + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_CANTHAVEONLYGAPS = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MASKMISMATCH + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DECLTOOCOMPLEX = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_CANTHAVEONLYGAPS + 1 ) , + D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGOUTPUTSIGNATURE = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DECLTOOCOMPLEX + 1 ) , + D3D10_MESSAGE_ID_CREATEPIXELSHADER_OUTOFMEMORY = ( D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGOUTPUTSIGNATURE + 1 ) , + D3D10_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERBYTECODE = ( D3D10_MESSAGE_ID_CREATEPIXELSHADER_OUTOFMEMORY + 1 ) , + D3D10_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERTYPE = ( D3D10_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERBYTECODE + 1 ) , + D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFILLMODE = ( D3D10_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERTYPE + 1 ) , + D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDCULLMODE = ( D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFILLMODE + 1 ) , + D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDDEPTHBIASCLAMP = ( D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDCULLMODE + 1 ) , + D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDSLOPESCALEDDEPTHBIAS = ( D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDDEPTHBIASCLAMP + 1 ) , + D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_TOOMANYOBJECTS = ( D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDSLOPESCALEDDEPTHBIAS + 1 ) , + D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_NULLDESC = ( D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_TOOMANYOBJECTS + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHWRITEMASK = ( D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_NULLDESC + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHFUNC = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHWRITEMASK + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFAILOP = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHFUNC + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILZFAILOP = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFAILOP + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILPASSOP = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILZFAILOP + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFUNC = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILPASSOP + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFAILOP = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFUNC + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILZFAILOP = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFAILOP + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILPASSOP = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILZFAILOP + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFUNC = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILPASSOP + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_TOOMANYOBJECTS = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFUNC + 1 ) , + D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_NULLDESC = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_TOOMANYOBJECTS + 1 ) , + D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLEND = ( D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_NULLDESC + 1 ) , + D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLEND = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLEND + 1 ) , + D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOP = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLEND + 1 ) , + D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLENDALPHA = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOP + 1 ) , + D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLENDALPHA = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLENDALPHA + 1 ) , + D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOPALPHA = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLENDALPHA + 1 ) , + D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDRENDERTARGETWRITEMASK = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOPALPHA + 1 ) , + D3D10_MESSAGE_ID_CREATEBLENDSTATE_TOOMANYOBJECTS = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDRENDERTARGETWRITEMASK + 1 ) , + D3D10_MESSAGE_ID_CREATEBLENDSTATE_NULLDESC = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_TOOMANYOBJECTS + 1 ) , + D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDFILTER = ( D3D10_MESSAGE_ID_CREATEBLENDSTATE_NULLDESC + 1 ) , + D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSU = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDFILTER + 1 ) , + D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSV = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSU + 1 ) , + D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSW = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSV + 1 ) , + D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMIPLODBIAS = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSW + 1 ) , + D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXANISOTROPY = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMIPLODBIAS + 1 ) , + D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDCOMPARISONFUNC = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXANISOTROPY + 1 ) , + D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMINLOD = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDCOMPARISONFUNC + 1 ) , + D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXLOD = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMINLOD + 1 ) , + D3D10_MESSAGE_ID_CREATESAMPLERSTATE_TOOMANYOBJECTS = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXLOD + 1 ) , + D3D10_MESSAGE_ID_CREATESAMPLERSTATE_NULLDESC = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_TOOMANYOBJECTS + 1 ) , + D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDQUERY = ( D3D10_MESSAGE_ID_CREATESAMPLERSTATE_NULLDESC + 1 ) , + D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDMISCFLAGS = ( D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDQUERY + 1 ) , + D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_UNEXPECTEDMISCFLAG = ( D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDMISCFLAGS + 1 ) , + D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_NULLDESC = ( D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_UNEXPECTEDMISCFLAG + 1 ) , + D3D10_MESSAGE_ID_IASETVERTEXBUFFERS_INVALIDBUFFER = ( D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_NULLDESC + 1 ) , + D3D10_MESSAGE_ID_IASETINDEXBUFFERS_INVALIDBUFFER = ( D3D10_MESSAGE_ID_IASETVERTEXBUFFERS_INVALIDBUFFER + 1 ) , + D3D10_MESSAGE_ID_VSSETCONSTANTBUFFERS_INVALIDBUFFER = ( D3D10_MESSAGE_ID_IASETINDEXBUFFERS_INVALIDBUFFER + 1 ) , + D3D10_MESSAGE_ID_GSSETCONSTANTBUFFERS_INVALIDBUFFER = ( D3D10_MESSAGE_ID_VSSETCONSTANTBUFFERS_INVALIDBUFFER + 1 ) , + D3D10_MESSAGE_ID_SOSETTARGETS_INVALIDBUFFER = ( D3D10_MESSAGE_ID_GSSETCONSTANTBUFFERS_INVALIDBUFFER + 1 ) , + D3D10_MESSAGE_ID_PSSETCONSTANTBUFFERS_INVALIDBUFFER = ( D3D10_MESSAGE_ID_SOSETTARGETS_INVALIDBUFFER + 1 ) , + D3D10_MESSAGE_ID_CLEARRENDERTARGETVIEW_DENORMFLUSH = ( D3D10_MESSAGE_ID_PSSETCONSTANTBUFFERS_INVALIDBUFFER + 1 ) , + D3D10_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DENORMFLUSH = ( D3D10_MESSAGE_ID_CLEARRENDERTARGETVIEW_DENORMFLUSH + 1 ) , + D3D10_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_SATURATE = ( D3D10_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DENORMFLUSH + 1 ) , + D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSUBRESOURCE = ( D3D10_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_SATURATE + 1 ) , + D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESUBRESOURCE = ( D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSUBRESOURCE + 1 ) , + D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCEBOX = ( D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESUBRESOURCE + 1 ) , + D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCE = ( D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCEBOX + 1 ) , + D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSTATE = ( D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCE + 1 ) , + D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESTATE = ( D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSTATE + 1 ) , + D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCE = ( D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESTATE + 1 ) , + D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDDESTINATIONSTATE = ( D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCE + 1 ) , + D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCESTATE = ( D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDDESTINATIONSTATE + 1 ) , + D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSUBRESOURCE = ( D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCESTATE + 1 ) , + D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONBOX = ( D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSUBRESOURCE + 1 ) , + D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSTATE = ( D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONBOX + 1 ) , + D3D10_MESSAGE_ID_BUFFER_MAP_INVALIDMAPTYPE = ( D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSTATE + 1 ) , + D3D10_MESSAGE_ID_BUFFER_MAP_INVALIDFLAGS = ( D3D10_MESSAGE_ID_BUFFER_MAP_INVALIDMAPTYPE + 1 ) , + D3D10_MESSAGE_ID_BUFFER_MAP_ALREADYMAPPED = ( D3D10_MESSAGE_ID_BUFFER_MAP_INVALIDFLAGS + 1 ) , + D3D10_MESSAGE_ID_BUFFER_MAP_DEVICEREMOVED_RETURN = ( D3D10_MESSAGE_ID_BUFFER_MAP_ALREADYMAPPED + 1 ) , + D3D10_MESSAGE_ID_BUFFER_UNMAP_NOTMAPPED = ( D3D10_MESSAGE_ID_BUFFER_MAP_DEVICEREMOVED_RETURN + 1 ) , + D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDMAPTYPE = ( D3D10_MESSAGE_ID_BUFFER_UNMAP_NOTMAPPED + 1 ) , + D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDMAPTYPE + 1 ) , + D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDFLAGS = ( D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDSUBRESOURCE + 1 ) , + D3D10_MESSAGE_ID_TEXTURE1D_MAP_ALREADYMAPPED = ( D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDFLAGS + 1 ) , + D3D10_MESSAGE_ID_TEXTURE1D_MAP_DEVICEREMOVED_RETURN = ( D3D10_MESSAGE_ID_TEXTURE1D_MAP_ALREADYMAPPED + 1 ) , + D3D10_MESSAGE_ID_TEXTURE1D_UNMAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURE1D_MAP_DEVICEREMOVED_RETURN + 1 ) , + D3D10_MESSAGE_ID_TEXTURE1D_UNMAP_NOTMAPPED = ( D3D10_MESSAGE_ID_TEXTURE1D_UNMAP_INVALIDSUBRESOURCE + 1 ) , + D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDMAPTYPE = ( D3D10_MESSAGE_ID_TEXTURE1D_UNMAP_NOTMAPPED + 1 ) , + D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDMAPTYPE + 1 ) , + D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDFLAGS = ( D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDSUBRESOURCE + 1 ) , + D3D10_MESSAGE_ID_TEXTURE2D_MAP_ALREADYMAPPED = ( D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDFLAGS + 1 ) , + D3D10_MESSAGE_ID_TEXTURE2D_MAP_DEVICEREMOVED_RETURN = ( D3D10_MESSAGE_ID_TEXTURE2D_MAP_ALREADYMAPPED + 1 ) , + D3D10_MESSAGE_ID_TEXTURE2D_UNMAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURE2D_MAP_DEVICEREMOVED_RETURN + 1 ) , + D3D10_MESSAGE_ID_TEXTURE2D_UNMAP_NOTMAPPED = ( D3D10_MESSAGE_ID_TEXTURE2D_UNMAP_INVALIDSUBRESOURCE + 1 ) , + D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDMAPTYPE = ( D3D10_MESSAGE_ID_TEXTURE2D_UNMAP_NOTMAPPED + 1 ) , + D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDMAPTYPE + 1 ) , + D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDFLAGS = ( D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDSUBRESOURCE + 1 ) , + D3D10_MESSAGE_ID_TEXTURE3D_MAP_ALREADYMAPPED = ( D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDFLAGS + 1 ) , + D3D10_MESSAGE_ID_TEXTURE3D_MAP_DEVICEREMOVED_RETURN = ( D3D10_MESSAGE_ID_TEXTURE3D_MAP_ALREADYMAPPED + 1 ) , + D3D10_MESSAGE_ID_TEXTURE3D_UNMAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURE3D_MAP_DEVICEREMOVED_RETURN + 1 ) , + D3D10_MESSAGE_ID_TEXTURE3D_UNMAP_NOTMAPPED = ( D3D10_MESSAGE_ID_TEXTURE3D_UNMAP_INVALIDSUBRESOURCE + 1 ) , + D3D10_MESSAGE_ID_TEXTURECUBE_MAP_INVALIDMAPTYPE = ( D3D10_MESSAGE_ID_TEXTURE3D_UNMAP_NOTMAPPED + 1 ) , + D3D10_MESSAGE_ID_TEXTURECUBE_MAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURECUBE_MAP_INVALIDMAPTYPE + 1 ) , + D3D10_MESSAGE_ID_TEXTURECUBE_MAP_INVALIDFLAGS = ( D3D10_MESSAGE_ID_TEXTURECUBE_MAP_INVALIDSUBRESOURCE + 1 ) , + D3D10_MESSAGE_ID_TEXTURECUBE_MAP_ALREADYMAPPED = ( D3D10_MESSAGE_ID_TEXTURECUBE_MAP_INVALIDFLAGS + 1 ) , + D3D10_MESSAGE_ID_TEXTURECUBE_MAP_DEVICEREMOVED_RETURN = ( D3D10_MESSAGE_ID_TEXTURECUBE_MAP_ALREADYMAPPED + 1 ) , + D3D10_MESSAGE_ID_TEXTURECUBE_UNMAP_INVALIDSUBRESOURCE = ( D3D10_MESSAGE_ID_TEXTURECUBE_MAP_DEVICEREMOVED_RETURN + 1 ) , + D3D10_MESSAGE_ID_TEXTURECUBE_UNMAP_NOTMAPPED = ( D3D10_MESSAGE_ID_TEXTURECUBE_UNMAP_INVALIDSUBRESOURCE + 1 ) , + D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_HAZARD = ( D3D10_MESSAGE_ID_TEXTURECUBE_UNMAP_NOTMAPPED + 1 ) , + D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_HAZARD + 1 ) , + D3D10_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_HAZARD + 1 ) , + D3D10_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_HAZARD + 1 ) , + D3D10_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_HAZARD + 1 ) , + D3D10_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_HAZARD + 1 ) , + D3D10_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_HAZARD + 1 ) , + D3D10_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_HAZARD + 1 ) , + D3D10_MESSAGE_ID_DEVICE_OMSETRENDERTARGETS_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_HAZARD + 1 ) , + D3D10_MESSAGE_ID_DEVICE_SOSETTARGETS_HAZARD = ( D3D10_MESSAGE_ID_DEVICE_OMSETRENDERTARGETS_HAZARD + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEXPOS_OVERFLOW = ( D3D10_MESSAGE_ID_DEVICE_SOSETTARGETS_HAZARD + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAWINDEXED_INDEXPOS_OVERFLOW = ( D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEXPOS_OVERFLOW + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAWINSTANCED_VERTEXPOS_OVERFLOW = ( D3D10_MESSAGE_ID_DEVICE_DRAWINDEXED_INDEXPOS_OVERFLOW + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAWINSTANCED_INSTANCEPOS_OVERFLOW = ( D3D10_MESSAGE_ID_DEVICE_DRAWINSTANCED_VERTEXPOS_OVERFLOW + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INSTANCEPOS_OVERFLOW = ( D3D10_MESSAGE_ID_DEVICE_DRAWINSTANCED_INSTANCEPOS_OVERFLOW + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INDEXPOS_OVERFLOW = ( D3D10_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INSTANCEPOS_OVERFLOW + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_SHADER_MISSING = ( D3D10_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INDEXPOS_OVERFLOW + 1 ) , + D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND = ( D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_SHADER_MISSING + 1 ) , + D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERINDEX = ( D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND + 1 ) , + D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_COMPONENTTYPE = ( D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERINDEX + 1 ) , + D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERMASK = ( D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_COMPONENTTYPE + 1 ) , + D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SYSTEMVALUE = ( D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERMASK + 1 ) , + D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_NEVERWRITTEN_ALWAYSREADS = ( D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SYSTEMVALUE + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_NOT_SET = ( D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_NEVERWRITTEN_ALWAYSREADS + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_INPUTLAYOUT_NOT_SET = ( D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_NOT_SET + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_NOT_SET = ( D3D10_MESSAGE_ID_DEVICE_DRAW_INPUTLAYOUT_NOT_SET + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_TOO_SMALL = ( D3D10_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_NOT_SET + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_SAMPLER_NOT_SET = ( D3D10_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_TOO_SMALL + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_SHADERRESOURCEVIEW_NOT_SET = ( D3D10_MESSAGE_ID_DEVICE_DRAW_SAMPLER_NOT_SET + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_DIMENSION_MISMATCH = ( D3D10_MESSAGE_ID_DEVICE_DRAW_SHADERRESOURCEVIEW_NOT_SET + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_STRIDE_TOO_SMALL = ( D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_DIMENSION_MISMATCH + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_TOO_SMALL = ( D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_STRIDE_TOO_SMALL + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_NOT_SET = ( D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_TOO_SMALL + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_FORMAT_INVALID = ( D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_NOT_SET + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL = ( D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_FORMAT_INVALID + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_GS_INPUT_PRIMITIVE_MISMATCH = ( D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_RETURN_TYPE_MISMATCH = ( D3D10_MESSAGE_ID_DEVICE_DRAW_GS_INPUT_PRIMITIVE_MISMATCH + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_POSITION_NOT_PRESENT = ( D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_RETURN_TYPE_MISMATCH + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_NOT_PRESENT = ( D3D10_MESSAGE_ID_DEVICE_DRAW_POSITION_NOT_PRESENT + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_BOUND_RESOURCE_MAPPED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_NOT_PRESENT + 1 ) , + D3D10_MESSAGE_ID_SETEXCEPTIONMODE_UNRECOGNIZEDFLAGS = ( D3D10_MESSAGE_ID_DEVICE_DRAW_BOUND_RESOURCE_MAPPED + 1 ) , + D3D10_MESSAGE_ID_SETEXCEPTIONMODE_INVALIDARG_RETURN = ( D3D10_MESSAGE_ID_SETEXCEPTIONMODE_UNRECOGNIZEDFLAGS + 1 ) , + D3D10_MESSAGE_ID_SETEXCEPTIONMODE_DEVICEREMOVED_RETURN = ( D3D10_MESSAGE_ID_SETEXCEPTIONMODE_INVALIDARG_RETURN + 1 ) , + D3D10_MESSAGE_ID_REF_SIMULATING_INFINITELY_FAST_HARDWARE = ( D3D10_MESSAGE_ID_SETEXCEPTIONMODE_DEVICEREMOVED_RETURN + 1 ) , + D3D10_MESSAGE_ID_REF_THREADING_MODE = ( D3D10_MESSAGE_ID_REF_SIMULATING_INFINITELY_FAST_HARDWARE + 1 ) , + D3D10_MESSAGE_ID_REF_UMDRIVER_EXCEPTION = ( D3D10_MESSAGE_ID_REF_THREADING_MODE + 1 ) , + D3D10_MESSAGE_ID_REF_KMDRIVER_EXCEPTION = ( D3D10_MESSAGE_ID_REF_UMDRIVER_EXCEPTION + 1 ) , + D3D10_MESSAGE_ID_REF_HARDWARE_EXCEPTION = ( D3D10_MESSAGE_ID_REF_KMDRIVER_EXCEPTION + 1 ) , + D3D10_MESSAGE_ID_REF_ACCESSING_INDEXABLE_TEMP_OUT_OF_RANGE = ( D3D10_MESSAGE_ID_REF_HARDWARE_EXCEPTION + 1 ) , + D3D10_MESSAGE_ID_REF_PROBLEM_PARSING_SHADER = ( D3D10_MESSAGE_ID_REF_ACCESSING_INDEXABLE_TEMP_OUT_OF_RANGE + 1 ) , + D3D10_MESSAGE_ID_REF_OUT_OF_MEMORY = ( D3D10_MESSAGE_ID_REF_PROBLEM_PARSING_SHADER + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_INVALID_PRIMITIVETOPOLOGY = ( D3D10_MESSAGE_ID_REF_OUT_OF_MEMORY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_OFFSET_UNALIGNED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_INVALID_PRIMITIVETOPOLOGY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_STRIDE_UNALIGNED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_OFFSET_UNALIGNED + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_OFFSET_UNALIGNED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_STRIDE_UNALIGNED + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_OFFSET_UNALIGNED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_OFFSET_UNALIGNED + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_LD_UNSUPPORTED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_OFFSET_UNALIGNED + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_UNSUPPORTED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_LD_UNSUPPORTED + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_C_UNSUPPORTED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_UNSUPPORTED + 1 ) , + D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_MULTISAMPLE_UNSUPPORTED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_C_UNSUPPORTED + 1 ) , + D3D10_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNRECOGNIZED = ( D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_MULTISAMPLE_UNSUPPORTED + 1 ) , + D3D10_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNDEFINED = ( D3D10_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNRECOGNIZED + 1 ) , + D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_OFFSET_TOO_LARGE = ( D3D10_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNDEFINED + 1 ) , + D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_FORMAT_INVALID = ( D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_OFFSET_TOO_LARGE + 1 ) , + D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_TOO_LARGE = ( D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_FORMAT_INVALID + 1 ) , + D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_UNALIGNED = ( D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_TOO_LARGE + 1 ) , + D3D10_MESSAGE_ID_DEVICE_SOSETTARGETS_OFFSET_UNALIGNED = ( D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_UNALIGNED + 1 ) , + D3D10_MESSAGE_ID_DEVICE_GENERATEMIPS_RESOURCE_INVALID = ( D3D10_MESSAGE_ID_DEVICE_SOSETTARGETS_OFFSET_UNALIGNED + 1 ) , + D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_GENERATEMIPS_RESOURCE_INVALID + 1 ) , + D3D10_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_VIEWS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_BUFFERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_VIEWS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_VSSETSAMPLERS_SAMPLERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_BUFFERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_VIEWS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_VSSETSAMPLERS_SAMPLERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_VIEWS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_GSSETSAMPLERS_SAMPLERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_BUFFERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_VIEWS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_GSSETSAMPLERS_SAMPLERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_VIEWS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_PSSETSAMPLERS_SAMPLERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_BUFFERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_IAGETVERTEXBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_PSSETSAMPLERS_SAMPLERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_VSGETSHADERRESOURCES_VIEWS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_IAGETVERTEXBUFFERS_BUFFERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_VSGETCONSTANTBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_VSGETSHADERRESOURCES_VIEWS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_VSGETSAMPLERS_SAMPLERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_VSGETCONSTANTBUFFERS_BUFFERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_GSGETSHADERRESOURCES_VIEWS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_VSGETSAMPLERS_SAMPLERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_GSGETCONSTANTBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_GSGETSHADERRESOURCES_VIEWS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_GSGETSAMPLERS_SAMPLERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_GSGETCONSTANTBUFFERS_BUFFERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_SOGETTARGETS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_GSGETSAMPLERS_SAMPLERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_PSGETSHADERRESOURCES_VIEWS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_SOGETTARGETS_BUFFERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_PSGETCONSTANTBUFFERS_BUFFERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_PSGETSHADERRESOURCES_VIEWS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_PSGETSAMPLERS_SAMPLERS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_PSGETCONSTANTBUFFERS_BUFFERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_RSGETVIEWPORTS_VIEWPORTS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_PSGETSAMPLERS_SAMPLERS_EMPTY + 1 ) , + D3D10_MESSAGE_ID_DEVICE_RSGETSCISSORRECTS_RECTS_EMPTY = ( D3D10_MESSAGE_ID_DEVICE_RSGETVIEWPORTS_VIEWPORTS_EMPTY + 1 ) + } D3D10_MESSAGE_ID; + +typedef struct D3D10_MESSAGE + { + D3D10_MESSAGE_CATEGORY Category; + D3D10_MESSAGE_SEVERITY Severity; + D3D10_MESSAGE_ID ID; + const WCHAR *pDescription; + SIZE_T DescriptionByteLength; + } D3D10_MESSAGE; + +typedef struct D3D10_INFO_QUEUE_FILTER_DESC + { + UINT NumCategories; + D3D10_MESSAGE_CATEGORY *pCategoryList; + UINT NumSeverities; + D3D10_MESSAGE_SEVERITY *pSeverityList; + UINT NumIDs; + D3D10_MESSAGE_ID *pIDList; + } D3D10_INFO_QUEUE_FILTER_DESC; + +typedef struct D3D10_INFO_QUEUE_FILTER + { + D3D10_INFO_QUEUE_FILTER_DESC AllowList; + D3D10_INFO_QUEUE_FILTER_DESC DenyList; + } D3D10_INFO_QUEUE_FILTER; + +#define D3D10_INFO_QUEUE_DEFAULT_MESSAGE_COUNT_LIMIT 1024 + + +extern RPC_IF_HANDLE __MIDL_itf_d3d10sdklayers_0000_0001_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d10sdklayers_0000_0001_v0_0_s_ifspec; + +#ifndef __ID3D10InfoQueue_INTERFACE_DEFINED__ +#define __ID3D10InfoQueue_INTERFACE_DEFINED__ + +/* interface ID3D10InfoQueue */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D10InfoQueue; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("1b940b17-2642-4d1f-ab1f-b99bad0c395f") + ID3D10InfoQueue : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE SetMessageCountLimit( + /* */ + __in UINT64 MessageCountLimit) = 0; + + virtual void STDMETHODCALLTYPE ClearStoredMessages( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetMessage( + /* */ + __in UINT64 MessageIndex, + /* */ + __out_bcount_opt(*pMessageByteLength) D3D10_MESSAGE *pMessage, + /* */ + __inout SIZE_T *pMessageByteLength) = 0; + + virtual UINT64 STDMETHODCALLTYPE GetNumMessagesAllowedByStorageFilter( void) = 0; + + virtual UINT64 STDMETHODCALLTYPE GetNumMessagesDeniedByStorageFilter( void) = 0; + + virtual UINT64 STDMETHODCALLTYPE GetNumStoredMessages( void) = 0; + + virtual UINT64 STDMETHODCALLTYPE GetNumStoredMessagesAllowedByRetrievalFilter( void) = 0; + + virtual UINT64 STDMETHODCALLTYPE GetNumMessagesDiscardedByMessageCountLimit( void) = 0; + + virtual UINT64 STDMETHODCALLTYPE GetMessageCountLimit( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE AddStorageFilterEntries( + /* */ + __in D3D10_INFO_QUEUE_FILTER *pFilter) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetStorageFilter( + /* */ + __out_bcount_opt(*pFilterByteLength) D3D10_INFO_QUEUE_FILTER *pFilter, + /* */ + __inout SIZE_T *pFilterByteLength) = 0; + + virtual void STDMETHODCALLTYPE ClearStorageFilter( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE PushEmptyStorageFilter( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE PushCopyOfStorageFilter( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE PushStorageFilter( + /* */ + __in D3D10_INFO_QUEUE_FILTER *pFilter) = 0; + + virtual void STDMETHODCALLTYPE PopStorageFilter( void) = 0; + + virtual UINT STDMETHODCALLTYPE GetStorageFilterStackSize( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE AddRetrievalFilterEntries( + /* */ + __in D3D10_INFO_QUEUE_FILTER *pFilter) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetRetrievalFilter( + /* */ + __out_bcount_opt(*pFilterByteLength) D3D10_INFO_QUEUE_FILTER *pFilter, + /* */ + __inout SIZE_T *pFilterByteLength) = 0; + + virtual void STDMETHODCALLTYPE ClearRetrievalFilter( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE PushEmptyRetrievalFilter( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE PushCopyOfRetrievalFilter( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE PushRetrievalFilter( + /* */ + __in D3D10_INFO_QUEUE_FILTER *pFilter) = 0; + + virtual void STDMETHODCALLTYPE PopRetrievalFilter( void) = 0; + + virtual UINT STDMETHODCALLTYPE GetRetrievalFilterStackSize( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE AddMessage( + /* */ + __in D3D10_MESSAGE_CATEGORY Category, + /* */ + __in D3D10_MESSAGE_SEVERITY Severity, + /* */ + __in D3D10_MESSAGE_ID ID, + /* */ + __in LPCWSTR pDescription) = 0; + + virtual HRESULT STDMETHODCALLTYPE AddApplicationMessage( + /* */ + __in D3D10_MESSAGE_SEVERITY Severity, + /* */ + __in LPCWSTR pDescription) = 0; + + }; + +#else /* C style interface */ + + typedef struct ID3D10InfoQueueVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D10InfoQueue * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D10InfoQueue * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D10InfoQueue * This); + + HRESULT ( STDMETHODCALLTYPE *SetMessageCountLimit )( + ID3D10InfoQueue * This, + /* */ + __in UINT64 MessageCountLimit); + + void ( STDMETHODCALLTYPE *ClearStoredMessages )( + ID3D10InfoQueue * This); + + HRESULT ( STDMETHODCALLTYPE *GetMessage )( + ID3D10InfoQueue * This, + /* */ + __in UINT64 MessageIndex, + /* */ + __out_bcount_opt(*pMessageByteLength) D3D10_MESSAGE *pMessage, + /* */ + __inout SIZE_T *pMessageByteLength); + + UINT64 ( STDMETHODCALLTYPE *GetNumMessagesAllowedByStorageFilter )( + ID3D10InfoQueue * This); + + UINT64 ( STDMETHODCALLTYPE *GetNumMessagesDeniedByStorageFilter )( + ID3D10InfoQueue * This); + + UINT64 ( STDMETHODCALLTYPE *GetNumStoredMessages )( + ID3D10InfoQueue * This); + + UINT64 ( STDMETHODCALLTYPE *GetNumStoredMessagesAllowedByRetrievalFilter )( + ID3D10InfoQueue * This); + + UINT64 ( STDMETHODCALLTYPE *GetNumMessagesDiscardedByMessageCountLimit )( + ID3D10InfoQueue * This); + + UINT64 ( STDMETHODCALLTYPE *GetMessageCountLimit )( + ID3D10InfoQueue * This); + + HRESULT ( STDMETHODCALLTYPE *AddStorageFilterEntries )( + ID3D10InfoQueue * This, + /* */ + __in D3D10_INFO_QUEUE_FILTER *pFilter); + + HRESULT ( STDMETHODCALLTYPE *GetStorageFilter )( + ID3D10InfoQueue * This, + /* */ + __out_bcount_opt(*pFilterByteLength) D3D10_INFO_QUEUE_FILTER *pFilter, + /* */ + __inout SIZE_T *pFilterByteLength); + + void ( STDMETHODCALLTYPE *ClearStorageFilter )( + ID3D10InfoQueue * This); + + HRESULT ( STDMETHODCALLTYPE *PushEmptyStorageFilter )( + ID3D10InfoQueue * This); + + HRESULT ( STDMETHODCALLTYPE *PushCopyOfStorageFilter )( + ID3D10InfoQueue * This); + + HRESULT ( STDMETHODCALLTYPE *PushStorageFilter )( + ID3D10InfoQueue * This, + /* */ + __in D3D10_INFO_QUEUE_FILTER *pFilter); + + void ( STDMETHODCALLTYPE *PopStorageFilter )( + ID3D10InfoQueue * This); + + UINT ( STDMETHODCALLTYPE *GetStorageFilterStackSize )( + ID3D10InfoQueue * This); + + HRESULT ( STDMETHODCALLTYPE *AddRetrievalFilterEntries )( + ID3D10InfoQueue * This, + /* */ + __in D3D10_INFO_QUEUE_FILTER *pFilter); + + HRESULT ( STDMETHODCALLTYPE *GetRetrievalFilter )( + ID3D10InfoQueue * This, + /* */ + __out_bcount_opt(*pFilterByteLength) D3D10_INFO_QUEUE_FILTER *pFilter, + /* */ + __inout SIZE_T *pFilterByteLength); + + void ( STDMETHODCALLTYPE *ClearRetrievalFilter )( + ID3D10InfoQueue * This); + + HRESULT ( STDMETHODCALLTYPE *PushEmptyRetrievalFilter )( + ID3D10InfoQueue * This); + + HRESULT ( STDMETHODCALLTYPE *PushCopyOfRetrievalFilter )( + ID3D10InfoQueue * This); + + HRESULT ( STDMETHODCALLTYPE *PushRetrievalFilter )( + ID3D10InfoQueue * This, + /* */ + __in D3D10_INFO_QUEUE_FILTER *pFilter); + + void ( STDMETHODCALLTYPE *PopRetrievalFilter )( + ID3D10InfoQueue * This); + + UINT ( STDMETHODCALLTYPE *GetRetrievalFilterStackSize )( + ID3D10InfoQueue * This); + + HRESULT ( STDMETHODCALLTYPE *AddMessage )( + ID3D10InfoQueue * This, + /* */ + __in D3D10_MESSAGE_CATEGORY Category, + /* */ + __in D3D10_MESSAGE_SEVERITY Severity, + /* */ + __in D3D10_MESSAGE_ID ID, + /* */ + __in LPCWSTR pDescription); + + HRESULT ( STDMETHODCALLTYPE *AddApplicationMessage )( + ID3D10InfoQueue * This, + /* */ + __in D3D10_MESSAGE_SEVERITY Severity, + /* */ + __in LPCWSTR pDescription); + + END_INTERFACE + } ID3D10InfoQueueVtbl; + + interface ID3D10InfoQueue + { + CONST_VTBL struct ID3D10InfoQueueVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D10InfoQueue_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D10InfoQueue_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D10InfoQueue_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D10InfoQueue_SetMessageCountLimit(This,MessageCountLimit) \ + ( (This)->lpVtbl -> SetMessageCountLimit(This,MessageCountLimit) ) + +#define ID3D10InfoQueue_ClearStoredMessages(This) \ + ( (This)->lpVtbl -> ClearStoredMessages(This) ) + +#define ID3D10InfoQueue_GetMessage(This,MessageIndex,pMessage,pMessageByteLength) \ + ( (This)->lpVtbl -> GetMessage(This,MessageIndex,pMessage,pMessageByteLength) ) + +#define ID3D10InfoQueue_GetNumMessagesAllowedByStorageFilter(This) \ + ( (This)->lpVtbl -> GetNumMessagesAllowedByStorageFilter(This) ) + +#define ID3D10InfoQueue_GetNumMessagesDeniedByStorageFilter(This) \ + ( (This)->lpVtbl -> GetNumMessagesDeniedByStorageFilter(This) ) + +#define ID3D10InfoQueue_GetNumStoredMessages(This) \ + ( (This)->lpVtbl -> GetNumStoredMessages(This) ) + +#define ID3D10InfoQueue_GetNumStoredMessagesAllowedByRetrievalFilter(This) \ + ( (This)->lpVtbl -> GetNumStoredMessagesAllowedByRetrievalFilter(This) ) + +#define ID3D10InfoQueue_GetNumMessagesDiscardedByMessageCountLimit(This) \ + ( (This)->lpVtbl -> GetNumMessagesDiscardedByMessageCountLimit(This) ) + +#define ID3D10InfoQueue_GetMessageCountLimit(This) \ + ( (This)->lpVtbl -> GetMessageCountLimit(This) ) + +#define ID3D10InfoQueue_AddStorageFilterEntries(This,pFilter) \ + ( (This)->lpVtbl -> AddStorageFilterEntries(This,pFilter) ) + +#define ID3D10InfoQueue_GetStorageFilter(This,pFilter,pFilterByteLength) \ + ( (This)->lpVtbl -> GetStorageFilter(This,pFilter,pFilterByteLength) ) + +#define ID3D10InfoQueue_ClearStorageFilter(This) \ + ( (This)->lpVtbl -> ClearStorageFilter(This) ) + +#define ID3D10InfoQueue_PushEmptyStorageFilter(This) \ + ( (This)->lpVtbl -> PushEmptyStorageFilter(This) ) + +#define ID3D10InfoQueue_PushCopyOfStorageFilter(This) \ + ( (This)->lpVtbl -> PushCopyOfStorageFilter(This) ) + +#define ID3D10InfoQueue_PushStorageFilter(This,pFilter) \ + ( (This)->lpVtbl -> PushStorageFilter(This,pFilter) ) + +#define ID3D10InfoQueue_PopStorageFilter(This) \ + ( (This)->lpVtbl -> PopStorageFilter(This) ) + +#define ID3D10InfoQueue_GetStorageFilterStackSize(This) \ + ( (This)->lpVtbl -> GetStorageFilterStackSize(This) ) + +#define ID3D10InfoQueue_AddRetrievalFilterEntries(This,pFilter) \ + ( (This)->lpVtbl -> AddRetrievalFilterEntries(This,pFilter) ) + +#define ID3D10InfoQueue_GetRetrievalFilter(This,pFilter,pFilterByteLength) \ + ( (This)->lpVtbl -> GetRetrievalFilter(This,pFilter,pFilterByteLength) ) + +#define ID3D10InfoQueue_ClearRetrievalFilter(This) \ + ( (This)->lpVtbl -> ClearRetrievalFilter(This) ) + +#define ID3D10InfoQueue_PushEmptyRetrievalFilter(This) \ + ( (This)->lpVtbl -> PushEmptyRetrievalFilter(This) ) + +#define ID3D10InfoQueue_PushCopyOfRetrievalFilter(This) \ + ( (This)->lpVtbl -> PushCopyOfRetrievalFilter(This) ) + +#define ID3D10InfoQueue_PushRetrievalFilter(This,pFilter) \ + ( (This)->lpVtbl -> PushRetrievalFilter(This,pFilter) ) + +#define ID3D10InfoQueue_PopRetrievalFilter(This) \ + ( (This)->lpVtbl -> PopRetrievalFilter(This) ) + +#define ID3D10InfoQueue_GetRetrievalFilterStackSize(This) \ + ( (This)->lpVtbl -> GetRetrievalFilterStackSize(This) ) + +#define ID3D10InfoQueue_AddMessage(This,Category,Severity,ID,pDescription) \ + ( (This)->lpVtbl -> AddMessage(This,Category,Severity,ID,pDescription) ) + +#define ID3D10InfoQueue_AddApplicationMessage(This,Severity,pDescription) \ + ( (This)->lpVtbl -> AddApplicationMessage(This,Severity,pDescription) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D10InfoQueue_INTERFACE_DEFINED__ */ + + +/* Additional Prototypes for ALL interfaces */ + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/dep/include/DXSDK/include/d3d8.h b/src/dep/include/DXSDK/include/d3d8.h index ae40ee9..347a86c 100644 --- a/src/dep/include/DXSDK/include/d3d8.h +++ b/src/dep/include/DXSDK/include/d3d8.h @@ -1,1279 +1,1279 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: d3d8.h - * Content: Direct3D include file - * - ****************************************************************************/ - -#ifndef _D3D8_H_ -#define _D3D8_H_ - -#ifndef DIRECT3D_VERSION -#define DIRECT3D_VERSION 0x0800 -#endif //DIRECT3D_VERSION - -// include this file content only if compiling for DX8 interfaces -#if(DIRECT3D_VERSION >= 0x0800) - - -/* This identifier is passed to Direct3DCreate8 in order to ensure that an - * application was built against the correct header files. This number is - * incremented whenever a header (or other) change would require applications - * to be rebuilt. If the version doesn't match, Direct3DCreate8 will fail. - * (The number itself has no meaning.)*/ - -#define D3D_SDK_VERSION 220 - - -#include - -#define COM_NO_WINDOWS_H -#include - -#include - -#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) - #define HMONITOR_DECLARED - DECLARE_HANDLE(HMONITOR); -#endif - -#define D3DAPI WINAPI - -/* - * Interface IID's - */ -#if defined( _WIN32 ) && !defined( _NO_COM) - -/* IID_IDirect3D8 */ -/* {1DD9E8DA-1C77-4d40-B0CF-98FEFDFF9512} */ -DEFINE_GUID(IID_IDirect3D8, 0x1dd9e8da, 0x1c77, 0x4d40, 0xb0, 0xcf, 0x98, 0xfe, 0xfd, 0xff, 0x95, 0x12); - -/* IID_IDirect3DDevice8 */ -/* {7385E5DF-8FE8-41D5-86B6-D7B48547B6CF} */ -DEFINE_GUID(IID_IDirect3DDevice8, 0x7385e5df, 0x8fe8, 0x41d5, 0x86, 0xb6, 0xd7, 0xb4, 0x85, 0x47, 0xb6, 0xcf); - -/* IID_IDirect3DResource8 */ -/* {1B36BB7B-09B7-410a-B445-7D1430D7B33F} */ -DEFINE_GUID(IID_IDirect3DResource8, 0x1b36bb7b, 0x9b7, 0x410a, 0xb4, 0x45, 0x7d, 0x14, 0x30, 0xd7, 0xb3, 0x3f); - -/* IID_IDirect3DBaseTexture8 */ -/* {B4211CFA-51B9-4a9f-AB78-DB99B2BB678E} */ -DEFINE_GUID(IID_IDirect3DBaseTexture8, 0xb4211cfa, 0x51b9, 0x4a9f, 0xab, 0x78, 0xdb, 0x99, 0xb2, 0xbb, 0x67, 0x8e); - -/* IID_IDirect3DTexture8 */ -/* {E4CDD575-2866-4f01-B12E-7EECE1EC9358} */ -DEFINE_GUID(IID_IDirect3DTexture8, 0xe4cdd575, 0x2866, 0x4f01, 0xb1, 0x2e, 0x7e, 0xec, 0xe1, 0xec, 0x93, 0x58); - -/* IID_IDirect3DCubeTexture8 */ -/* {3EE5B968-2ACA-4c34-8BB5-7E0C3D19B750} */ -DEFINE_GUID(IID_IDirect3DCubeTexture8, 0x3ee5b968, 0x2aca, 0x4c34, 0x8b, 0xb5, 0x7e, 0x0c, 0x3d, 0x19, 0xb7, 0x50); - -/* IID_IDirect3DVolumeTexture8 */ -/* {4B8AAAFA-140F-42ba-9131-597EAFAA2EAD} */ -DEFINE_GUID(IID_IDirect3DVolumeTexture8, 0x4b8aaafa, 0x140f, 0x42ba, 0x91, 0x31, 0x59, 0x7e, 0xaf, 0xaa, 0x2e, 0xad); - -/* IID_IDirect3DVertexBuffer8 */ -/* {8AEEEAC7-05F9-44d4-B591-000B0DF1CB95} */ -DEFINE_GUID(IID_IDirect3DVertexBuffer8, 0x8aeeeac7, 0x05f9, 0x44d4, 0xb5, 0x91, 0x00, 0x0b, 0x0d, 0xf1, 0xcb, 0x95); - -/* IID_IDirect3DIndexBuffer8 */ -/* {0E689C9A-053D-44a0-9D92-DB0E3D750F86} */ -DEFINE_GUID(IID_IDirect3DIndexBuffer8, 0x0e689c9a, 0x053d, 0x44a0, 0x9d, 0x92, 0xdb, 0x0e, 0x3d, 0x75, 0x0f, 0x86); - -/* IID_IDirect3DSurface8 */ -/* {B96EEBCA-B326-4ea5-882F-2FF5BAE021DD} */ -DEFINE_GUID(IID_IDirect3DSurface8, 0xb96eebca, 0xb326, 0x4ea5, 0x88, 0x2f, 0x2f, 0xf5, 0xba, 0xe0, 0x21, 0xdd); - -/* IID_IDirect3DVolume8 */ -/* {BD7349F5-14F1-42e4-9C79-972380DB40C0} */ -DEFINE_GUID(IID_IDirect3DVolume8, 0xbd7349f5, 0x14f1, 0x42e4, 0x9c, 0x79, 0x97, 0x23, 0x80, 0xdb, 0x40, 0xc0); - -/* IID_IDirect3DSwapChain8 */ -/* {928C088B-76B9-4C6B-A536-A590853876CD} */ -DEFINE_GUID(IID_IDirect3DSwapChain8, 0x928c088b, 0x76b9, 0x4c6b, 0xa5, 0x36, 0xa5, 0x90, 0x85, 0x38, 0x76, 0xcd); - -#endif - -#ifdef __cplusplus - -interface IDirect3D8; -interface IDirect3DDevice8; - -interface IDirect3DResource8; -interface IDirect3DBaseTexture8; -interface IDirect3DTexture8; -interface IDirect3DVolumeTexture8; -interface IDirect3DCubeTexture8; - -interface IDirect3DVertexBuffer8; -interface IDirect3DIndexBuffer8; - -interface IDirect3DSurface8; -interface IDirect3DVolume8; - -interface IDirect3DSwapChain8; - -#endif - - -typedef interface IDirect3D8 IDirect3D8; -typedef interface IDirect3DDevice8 IDirect3DDevice8; -typedef interface IDirect3DResource8 IDirect3DResource8; -typedef interface IDirect3DBaseTexture8 IDirect3DBaseTexture8; -typedef interface IDirect3DTexture8 IDirect3DTexture8; -typedef interface IDirect3DVolumeTexture8 IDirect3DVolumeTexture8; -typedef interface IDirect3DCubeTexture8 IDirect3DCubeTexture8; -typedef interface IDirect3DVertexBuffer8 IDirect3DVertexBuffer8; -typedef interface IDirect3DIndexBuffer8 IDirect3DIndexBuffer8; -typedef interface IDirect3DSurface8 IDirect3DSurface8; -typedef interface IDirect3DVolume8 IDirect3DVolume8; -typedef interface IDirect3DSwapChain8 IDirect3DSwapChain8; - -#include "d3d8types.h" -#include "d3d8caps.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * DLL Function for creating a Direct3D8 object. This object supports - * enumeration and allows the creation of Direct3DDevice8 objects. - * Pass the value of the constant D3D_SDK_VERSION to this function, so - * that the run-time can validate that your application was compiled - * against the right headers. - */ - -IDirect3D8 * WINAPI Direct3DCreate8(UINT SDKVersion); - - -/* - * Direct3D interfaces - */ - - - - - - -#undef INTERFACE -#define INTERFACE IDirect3D8 - -DECLARE_INTERFACE_(IDirect3D8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3D8 methods ***/ - STDMETHOD(RegisterSoftwareDevice)(THIS_ void* pInitializeFunction) PURE; - STDMETHOD_(UINT, GetAdapterCount)(THIS) PURE; - STDMETHOD(GetAdapterIdentifier)(THIS_ UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER8* pIdentifier) PURE; - STDMETHOD_(UINT, GetAdapterModeCount)(THIS_ UINT Adapter) PURE; - STDMETHOD(EnumAdapterModes)(THIS_ UINT Adapter,UINT Mode,D3DDISPLAYMODE* pMode) PURE; - STDMETHOD(GetAdapterDisplayMode)(THIS_ UINT Adapter,D3DDISPLAYMODE* pMode) PURE; - STDMETHOD(CheckDeviceType)(THIS_ UINT Adapter,D3DDEVTYPE CheckType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL Windowed) PURE; - STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) PURE; - STDMETHOD(CheckDeviceMultiSampleType)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType) PURE; - STDMETHOD(CheckDepthStencilMatch)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) PURE; - STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS8* pCaps) PURE; - STDMETHOD_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter) PURE; - STDMETHOD(CreateDevice)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice8** ppReturnedDeviceInterface) PURE; -}; - -typedef struct IDirect3D8 *LPDIRECT3D8, *PDIRECT3D8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3D8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3D8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3D8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3D8_RegisterSoftwareDevice(p,a) (p)->lpVtbl->RegisterSoftwareDevice(p,a) -#define IDirect3D8_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p) -#define IDirect3D8_GetAdapterIdentifier(p,a,b,c) (p)->lpVtbl->GetAdapterIdentifier(p,a,b,c) -#define IDirect3D8_GetAdapterModeCount(p,a) (p)->lpVtbl->GetAdapterModeCount(p,a) -#define IDirect3D8_EnumAdapterModes(p,a,b,c) (p)->lpVtbl->EnumAdapterModes(p,a,b,c) -#define IDirect3D8_GetAdapterDisplayMode(p,a,b) (p)->lpVtbl->GetAdapterDisplayMode(p,a,b) -#define IDirect3D8_CheckDeviceType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceType(p,a,b,c,d,e) -#define IDirect3D8_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f) -#define IDirect3D8_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceMultiSampleType(p,a,b,c,d,e) -#define IDirect3D8_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->lpVtbl->CheckDepthStencilMatch(p,a,b,c,d,e) -#define IDirect3D8_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c) -#define IDirect3D8_GetAdapterMonitor(p,a) (p)->lpVtbl->GetAdapterMonitor(p,a) -#define IDirect3D8_CreateDevice(p,a,b,c,d,e,f) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f) -#else -#define IDirect3D8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3D8_AddRef(p) (p)->AddRef() -#define IDirect3D8_Release(p) (p)->Release() -#define IDirect3D8_RegisterSoftwareDevice(p,a) (p)->RegisterSoftwareDevice(a) -#define IDirect3D8_GetAdapterCount(p) (p)->GetAdapterCount() -#define IDirect3D8_GetAdapterIdentifier(p,a,b,c) (p)->GetAdapterIdentifier(a,b,c) -#define IDirect3D8_GetAdapterModeCount(p,a) (p)->GetAdapterModeCount(a) -#define IDirect3D8_EnumAdapterModes(p,a,b,c) (p)->EnumAdapterModes(a,b,c) -#define IDirect3D8_GetAdapterDisplayMode(p,a,b) (p)->GetAdapterDisplayMode(a,b) -#define IDirect3D8_CheckDeviceType(p,a,b,c,d,e) (p)->CheckDeviceType(a,b,c,d,e) -#define IDirect3D8_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->CheckDeviceFormat(a,b,c,d,e,f) -#define IDirect3D8_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->CheckDeviceMultiSampleType(a,b,c,d,e) -#define IDirect3D8_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->CheckDepthStencilMatch(a,b,c,d,e) -#define IDirect3D8_GetDeviceCaps(p,a,b,c) (p)->GetDeviceCaps(a,b,c) -#define IDirect3D8_GetAdapterMonitor(p,a) (p)->GetAdapterMonitor(a) -#define IDirect3D8_CreateDevice(p,a,b,c,d,e,f) (p)->CreateDevice(a,b,c,d,e,f) -#endif - - - - - - - - - - - - - - - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DDevice8 - -DECLARE_INTERFACE_(IDirect3DDevice8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DDevice8 methods ***/ - STDMETHOD(TestCooperativeLevel)(THIS) PURE; - STDMETHOD_(UINT, GetAvailableTextureMem)(THIS) PURE; - STDMETHOD(ResourceManagerDiscardBytes)(THIS_ DWORD Bytes) PURE; - STDMETHOD(GetDirect3D)(THIS_ IDirect3D8** ppD3D8) PURE; - STDMETHOD(GetDeviceCaps)(THIS_ D3DCAPS8* pCaps) PURE; - STDMETHOD(GetDisplayMode)(THIS_ D3DDISPLAYMODE* pMode) PURE; - STDMETHOD(GetCreationParameters)(THIS_ D3DDEVICE_CREATION_PARAMETERS *pParameters) PURE; - STDMETHOD(SetCursorProperties)(THIS_ UINT XHotSpot,UINT YHotSpot,IDirect3DSurface8* pCursorBitmap) PURE; - STDMETHOD_(void, SetCursorPosition)(THIS_ UINT XScreenSpace,UINT YScreenSpace,DWORD Flags) PURE; - STDMETHOD_(BOOL, ShowCursor)(THIS_ BOOL bShow) PURE; - STDMETHOD(CreateAdditionalSwapChain)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain8** pSwapChain) PURE; - STDMETHOD(Reset)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; - STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; - STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) PURE; - STDMETHOD(GetRasterStatus)(THIS_ D3DRASTER_STATUS* pRasterStatus) PURE; - STDMETHOD_(void, SetGammaRamp)(THIS_ DWORD Flags,CONST D3DGAMMARAMP* pRamp) PURE; - STDMETHOD_(void, GetGammaRamp)(THIS_ D3DGAMMARAMP* pRamp) PURE; - STDMETHOD(CreateTexture)(THIS_ UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture8** ppTexture) PURE; - STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture8** ppVolumeTexture) PURE; - STDMETHOD(CreateCubeTexture)(THIS_ UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture8** ppCubeTexture) PURE; - STDMETHOD(CreateVertexBuffer)(THIS_ UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer8** ppVertexBuffer) PURE; - STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer8** ppIndexBuffer) PURE; - STDMETHOD(CreateRenderTarget)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,BOOL Lockable,IDirect3DSurface8** ppSurface) PURE; - STDMETHOD(CreateDepthStencilSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,IDirect3DSurface8** ppSurface) PURE; - STDMETHOD(CreateImageSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,IDirect3DSurface8** ppSurface) PURE; - STDMETHOD(CopyRects)(THIS_ IDirect3DSurface8* pSourceSurface,CONST RECT* pSourceRectsArray,UINT cRects,IDirect3DSurface8* pDestinationSurface,CONST POINT* pDestPointsArray) PURE; - STDMETHOD(UpdateTexture)(THIS_ IDirect3DBaseTexture8* pSourceTexture,IDirect3DBaseTexture8* pDestinationTexture) PURE; - STDMETHOD(GetFrontBuffer)(THIS_ IDirect3DSurface8* pDestSurface) PURE; - STDMETHOD(SetRenderTarget)(THIS_ IDirect3DSurface8* pRenderTarget,IDirect3DSurface8* pNewZStencil) PURE; - STDMETHOD(GetRenderTarget)(THIS_ IDirect3DSurface8** ppRenderTarget) PURE; - STDMETHOD(GetDepthStencilSurface)(THIS_ IDirect3DSurface8** ppZStencilSurface) PURE; - STDMETHOD(BeginScene)(THIS) PURE; - STDMETHOD(EndScene)(THIS) PURE; - STDMETHOD(Clear)(THIS_ DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil) PURE; - STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) PURE; - STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) PURE; - STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,CONST D3DMATRIX*) PURE; - STDMETHOD(SetViewport)(THIS_ CONST D3DVIEWPORT8* pViewport) PURE; - STDMETHOD(GetViewport)(THIS_ D3DVIEWPORT8* pViewport) PURE; - STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL8* pMaterial) PURE; - STDMETHOD(GetMaterial)(THIS_ D3DMATERIAL8* pMaterial) PURE; - STDMETHOD(SetLight)(THIS_ DWORD Index,CONST D3DLIGHT8*) PURE; - STDMETHOD(GetLight)(THIS_ DWORD Index,D3DLIGHT8*) PURE; - STDMETHOD(LightEnable)(THIS_ DWORD Index,BOOL Enable) PURE; - STDMETHOD(GetLightEnable)(THIS_ DWORD Index,BOOL* pEnable) PURE; - STDMETHOD(SetClipPlane)(THIS_ DWORD Index,CONST float* pPlane) PURE; - STDMETHOD(GetClipPlane)(THIS_ DWORD Index,float* pPlane) PURE; - STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD Value) PURE; - STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD* pValue) PURE; - STDMETHOD(BeginStateBlock)(THIS) PURE; - STDMETHOD(EndStateBlock)(THIS_ DWORD* pToken) PURE; - STDMETHOD(ApplyStateBlock)(THIS_ DWORD Token) PURE; - STDMETHOD(CaptureStateBlock)(THIS_ DWORD Token) PURE; - STDMETHOD(DeleteStateBlock)(THIS_ DWORD Token) PURE; - STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type,DWORD* pToken) PURE; - STDMETHOD(SetClipStatus)(THIS_ CONST D3DCLIPSTATUS8* pClipStatus) PURE; - STDMETHOD(GetClipStatus)(THIS_ D3DCLIPSTATUS8* pClipStatus) PURE; - STDMETHOD(GetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8** ppTexture) PURE; - STDMETHOD(SetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8* pTexture) PURE; - STDMETHOD(GetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) PURE; - STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE; - STDMETHOD(ValidateDevice)(THIS_ DWORD* pNumPasses) PURE; - STDMETHOD(GetInfo)(THIS_ DWORD DevInfoID,void* pDevInfoStruct,DWORD DevInfoStructSize) PURE; - STDMETHOD(SetPaletteEntries)(THIS_ UINT PaletteNumber,CONST PALETTEENTRY* pEntries) PURE; - STDMETHOD(GetPaletteEntries)(THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries) PURE; - STDMETHOD(SetCurrentTexturePalette)(THIS_ UINT PaletteNumber) PURE; - STDMETHOD(GetCurrentTexturePalette)(THIS_ UINT *PaletteNumber) PURE; - STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) PURE; - STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount) PURE; - STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; - STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; - STDMETHOD(ProcessVertices)(THIS_ UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags) PURE; - STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD* pDeclaration,CONST DWORD* pFunction,DWORD* pHandle,DWORD Usage) PURE; - STDMETHOD(SetVertexShader)(THIS_ DWORD Handle) PURE; - STDMETHOD(GetVertexShader)(THIS_ DWORD* pHandle) PURE; - STDMETHOD(DeleteVertexShader)(THIS_ DWORD Handle) PURE; - STDMETHOD(SetVertexShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE; - STDMETHOD(GetVertexShaderConstant)(THIS_ DWORD Register,void* pConstantData,DWORD ConstantCount) PURE; - STDMETHOD(GetVertexShaderDeclaration)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(GetVertexShaderFunction)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(SetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8* pStreamData,UINT Stride) PURE; - STDMETHOD(GetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8** ppStreamData,UINT* pStride) PURE; - STDMETHOD(SetIndices)(THIS_ IDirect3DIndexBuffer8* pIndexData,UINT BaseVertexIndex) PURE; - STDMETHOD(GetIndices)(THIS_ IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) PURE; - STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction,DWORD* pHandle) PURE; - STDMETHOD(SetPixelShader)(THIS_ DWORD Handle) PURE; - STDMETHOD(GetPixelShader)(THIS_ DWORD* pHandle) PURE; - STDMETHOD(DeletePixelShader)(THIS_ DWORD Handle) PURE; - STDMETHOD(SetPixelShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE; - STDMETHOD(GetPixelShaderConstant)(THIS_ DWORD Register,void* pConstantData,DWORD ConstantCount) PURE; - STDMETHOD(GetPixelShaderFunction)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(DrawRectPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) PURE; - STDMETHOD(DrawTriPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) PURE; - STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE; -}; - -typedef struct IDirect3DDevice8 *LPDIRECT3DDEVICE8, *PDIRECT3DDEVICE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DDevice8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DDevice8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DDevice8_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) -#define IDirect3DDevice8_GetAvailableTextureMem(p) (p)->lpVtbl->GetAvailableTextureMem(p) -#define IDirect3DDevice8_ResourceManagerDiscardBytes(p,a) (p)->lpVtbl->ResourceManagerDiscardBytes(p,a) -#define IDirect3DDevice8_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) -#define IDirect3DDevice8_GetDeviceCaps(p,a) (p)->lpVtbl->GetDeviceCaps(p,a) -#define IDirect3DDevice8_GetDisplayMode(p,a) (p)->lpVtbl->GetDisplayMode(p,a) -#define IDirect3DDevice8_GetCreationParameters(p,a) (p)->lpVtbl->GetCreationParameters(p,a) -#define IDirect3DDevice8_SetCursorProperties(p,a,b,c) (p)->lpVtbl->SetCursorProperties(p,a,b,c) -#define IDirect3DDevice8_SetCursorPosition(p,a,b,c) (p)->lpVtbl->SetCursorPosition(p,a,b,c) -#define IDirect3DDevice8_ShowCursor(p,a) (p)->lpVtbl->ShowCursor(p,a) -#define IDirect3DDevice8_CreateAdditionalSwapChain(p,a,b) (p)->lpVtbl->CreateAdditionalSwapChain(p,a,b) -#define IDirect3DDevice8_Reset(p,a) (p)->lpVtbl->Reset(p,a) -#define IDirect3DDevice8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) -#define IDirect3DDevice8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) -#define IDirect3DDevice8_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a) -#define IDirect3DDevice8_SetGammaRamp(p,a,b) (p)->lpVtbl->SetGammaRamp(p,a,b) -#define IDirect3DDevice8_GetGammaRamp(p,a) (p)->lpVtbl->GetGammaRamp(p,a) -#define IDirect3DDevice8_CreateTexture(p,a,b,c,d,e,f,g) (p)->lpVtbl->CreateTexture(p,a,b,c,d,e,f,g) -#define IDirect3DDevice8_CreateVolumeTexture(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateVolumeTexture(p,a,b,c,d,e,f,g,h) -#define IDirect3DDevice8_CreateCubeTexture(p,a,b,c,d,e,f) (p)->lpVtbl->CreateCubeTexture(p,a,b,c,d,e,f) -#define IDirect3DDevice8_CreateVertexBuffer(p,a,b,c,d,e) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d,e) -#define IDirect3DDevice8_CreateIndexBuffer(p,a,b,c,d,e) (p)->lpVtbl->CreateIndexBuffer(p,a,b,c,d,e) -#define IDirect3DDevice8_CreateRenderTarget(p,a,b,c,d,e,f) (p)->lpVtbl->CreateRenderTarget(p,a,b,c,d,e,f) -#define IDirect3DDevice8_CreateDepthStencilSurface(p,a,b,c,d,e) (p)->lpVtbl->CreateDepthStencilSurface(p,a,b,c,d,e) -#define IDirect3DDevice8_CreateImageSurface(p,a,b,c,d) (p)->lpVtbl->CreateImageSurface(p,a,b,c,d) -#define IDirect3DDevice8_CopyRects(p,a,b,c,d,e) (p)->lpVtbl->CopyRects(p,a,b,c,d,e) -#define IDirect3DDevice8_UpdateTexture(p,a,b) (p)->lpVtbl->UpdateTexture(p,a,b) -#define IDirect3DDevice8_GetFrontBuffer(p,a) (p)->lpVtbl->GetFrontBuffer(p,a) -#define IDirect3DDevice8_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) -#define IDirect3DDevice8_GetRenderTarget(p,a) (p)->lpVtbl->GetRenderTarget(p,a) -#define IDirect3DDevice8_GetDepthStencilSurface(p,a) (p)->lpVtbl->GetDepthStencilSurface(p,a) -#define IDirect3DDevice8_BeginScene(p) (p)->lpVtbl->BeginScene(p) -#define IDirect3DDevice8_EndScene(p) (p)->lpVtbl->EndScene(p) -#define IDirect3DDevice8_Clear(p,a,b,c,d,e,f) (p)->lpVtbl->Clear(p,a,b,c,d,e,f) -#define IDirect3DDevice8_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) -#define IDirect3DDevice8_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) -#define IDirect3DDevice8_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) -#define IDirect3DDevice8_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) -#define IDirect3DDevice8_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) -#define IDirect3DDevice8_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) -#define IDirect3DDevice8_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) -#define IDirect3DDevice8_SetLight(p,a,b) (p)->lpVtbl->SetLight(p,a,b) -#define IDirect3DDevice8_GetLight(p,a,b) (p)->lpVtbl->GetLight(p,a,b) -#define IDirect3DDevice8_LightEnable(p,a,b) (p)->lpVtbl->LightEnable(p,a,b) -#define IDirect3DDevice8_GetLightEnable(p,a,b) (p)->lpVtbl->GetLightEnable(p,a,b) -#define IDirect3DDevice8_SetClipPlane(p,a,b) (p)->lpVtbl->SetClipPlane(p,a,b) -#define IDirect3DDevice8_GetClipPlane(p,a,b) (p)->lpVtbl->GetClipPlane(p,a,b) -#define IDirect3DDevice8_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) -#define IDirect3DDevice8_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) -#define IDirect3DDevice8_BeginStateBlock(p) (p)->lpVtbl->BeginStateBlock(p) -#define IDirect3DDevice8_EndStateBlock(p,a) (p)->lpVtbl->EndStateBlock(p,a) -#define IDirect3DDevice8_ApplyStateBlock(p,a) (p)->lpVtbl->ApplyStateBlock(p,a) -#define IDirect3DDevice8_CaptureStateBlock(p,a) (p)->lpVtbl->CaptureStateBlock(p,a) -#define IDirect3DDevice8_DeleteStateBlock(p,a) (p)->lpVtbl->DeleteStateBlock(p,a) -#define IDirect3DDevice8_CreateStateBlock(p,a,b) (p)->lpVtbl->CreateStateBlock(p,a,b) -#define IDirect3DDevice8_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) -#define IDirect3DDevice8_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) -#define IDirect3DDevice8_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) -#define IDirect3DDevice8_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) -#define IDirect3DDevice8_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) -#define IDirect3DDevice8_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) -#define IDirect3DDevice8_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a) -#define IDirect3DDevice8_GetInfo(p,a,b,c) (p)->lpVtbl->GetInfo(p,a,b,c) -#define IDirect3DDevice8_SetPaletteEntries(p,a,b) (p)->lpVtbl->SetPaletteEntries(p,a,b) -#define IDirect3DDevice8_GetPaletteEntries(p,a,b) (p)->lpVtbl->GetPaletteEntries(p,a,b) -#define IDirect3DDevice8_SetCurrentTexturePalette(p,a) (p)->lpVtbl->SetCurrentTexturePalette(p,a) -#define IDirect3DDevice8_GetCurrentTexturePalette(p,a) (p)->lpVtbl->GetCurrentTexturePalette(p,a) -#define IDirect3DDevice8_DrawPrimitive(p,a,b,c) (p)->lpVtbl->DrawPrimitive(p,a,b,c) -#define IDirect3DDevice8_DrawIndexedPrimitive(p,a,b,c,d,e) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e) -#define IDirect3DDevice8_DrawPrimitiveUP(p,a,b,c,d) (p)->lpVtbl->DrawPrimitiveUP(p,a,b,c,d) -#define IDirect3DDevice8_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) -#define IDirect3DDevice8_ProcessVertices(p,a,b,c,d,e) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e) -#define IDirect3DDevice8_CreateVertexShader(p,a,b,c,d) (p)->lpVtbl->CreateVertexShader(p,a,b,c,d) -#define IDirect3DDevice8_SetVertexShader(p,a) (p)->lpVtbl->SetVertexShader(p,a) -#define IDirect3DDevice8_GetVertexShader(p,a) (p)->lpVtbl->GetVertexShader(p,a) -#define IDirect3DDevice8_DeleteVertexShader(p,a) (p)->lpVtbl->DeleteVertexShader(p,a) -#define IDirect3DDevice8_SetVertexShaderConstant(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstant(p,a,b,c) -#define IDirect3DDevice8_GetVertexShaderConstant(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstant(p,a,b,c) -#define IDirect3DDevice8_GetVertexShaderDeclaration(p,a,b,c) (p)->lpVtbl->GetVertexShaderDeclaration(p,a,b,c) -#define IDirect3DDevice8_GetVertexShaderFunction(p,a,b,c) (p)->lpVtbl->GetVertexShaderFunction(p,a,b,c) -#define IDirect3DDevice8_SetStreamSource(p,a,b,c) (p)->lpVtbl->SetStreamSource(p,a,b,c) -#define IDirect3DDevice8_GetStreamSource(p,a,b,c) (p)->lpVtbl->GetStreamSource(p,a,b,c) -#define IDirect3DDevice8_SetIndices(p,a,b) (p)->lpVtbl->SetIndices(p,a,b) -#define IDirect3DDevice8_GetIndices(p,a,b) (p)->lpVtbl->GetIndices(p,a,b) -#define IDirect3DDevice8_CreatePixelShader(p,a,b) (p)->lpVtbl->CreatePixelShader(p,a,b) -#define IDirect3DDevice8_SetPixelShader(p,a) (p)->lpVtbl->SetPixelShader(p,a) -#define IDirect3DDevice8_GetPixelShader(p,a) (p)->lpVtbl->GetPixelShader(p,a) -#define IDirect3DDevice8_DeletePixelShader(p,a) (p)->lpVtbl->DeletePixelShader(p,a) -#define IDirect3DDevice8_SetPixelShaderConstant(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstant(p,a,b,c) -#define IDirect3DDevice8_GetPixelShaderConstant(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstant(p,a,b,c) -#define IDirect3DDevice8_GetPixelShaderFunction(p,a,b,c) (p)->lpVtbl->GetPixelShaderFunction(p,a,b,c) -#define IDirect3DDevice8_DrawRectPatch(p,a,b,c) (p)->lpVtbl->DrawRectPatch(p,a,b,c) -#define IDirect3DDevice8_DrawTriPatch(p,a,b,c) (p)->lpVtbl->DrawTriPatch(p,a,b,c) -#define IDirect3DDevice8_DeletePatch(p,a) (p)->lpVtbl->DeletePatch(p,a) -#else -#define IDirect3DDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DDevice8_AddRef(p) (p)->AddRef() -#define IDirect3DDevice8_Release(p) (p)->Release() -#define IDirect3DDevice8_TestCooperativeLevel(p) (p)->TestCooperativeLevel() -#define IDirect3DDevice8_GetAvailableTextureMem(p) (p)->GetAvailableTextureMem() -#define IDirect3DDevice8_ResourceManagerDiscardBytes(p,a) (p)->ResourceManagerDiscardBytes(a) -#define IDirect3DDevice8_GetDirect3D(p,a) (p)->GetDirect3D(a) -#define IDirect3DDevice8_GetDeviceCaps(p,a) (p)->GetDeviceCaps(a) -#define IDirect3DDevice8_GetDisplayMode(p,a) (p)->GetDisplayMode(a) -#define IDirect3DDevice8_GetCreationParameters(p,a) (p)->GetCreationParameters(a) -#define IDirect3DDevice8_SetCursorProperties(p,a,b,c) (p)->SetCursorProperties(a,b,c) -#define IDirect3DDevice8_SetCursorPosition(p,a,b,c) (p)->SetCursorPosition(a,b,c) -#define IDirect3DDevice8_ShowCursor(p,a) (p)->ShowCursor(a) -#define IDirect3DDevice8_CreateAdditionalSwapChain(p,a,b) (p)->CreateAdditionalSwapChain(a,b) -#define IDirect3DDevice8_Reset(p,a) (p)->Reset(a) -#define IDirect3DDevice8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) -#define IDirect3DDevice8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) -#define IDirect3DDevice8_GetRasterStatus(p,a) (p)->GetRasterStatus(a) -#define IDirect3DDevice8_SetGammaRamp(p,a,b) (p)->SetGammaRamp(a,b) -#define IDirect3DDevice8_GetGammaRamp(p,a) (p)->GetGammaRamp(a) -#define IDirect3DDevice8_CreateTexture(p,a,b,c,d,e,f,g) (p)->CreateTexture(a,b,c,d,e,f,g) -#define IDirect3DDevice8_CreateVolumeTexture(p,a,b,c,d,e,f,g,h) (p)->CreateVolumeTexture(a,b,c,d,e,f,g,h) -#define IDirect3DDevice8_CreateCubeTexture(p,a,b,c,d,e,f) (p)->CreateCubeTexture(a,b,c,d,e,f) -#define IDirect3DDevice8_CreateVertexBuffer(p,a,b,c,d,e) (p)->CreateVertexBuffer(a,b,c,d,e) -#define IDirect3DDevice8_CreateIndexBuffer(p,a,b,c,d,e) (p)->CreateIndexBuffer(a,b,c,d,e) -#define IDirect3DDevice8_CreateRenderTarget(p,a,b,c,d,e,f) (p)->CreateRenderTarget(a,b,c,d,e,f) -#define IDirect3DDevice8_CreateDepthStencilSurface(p,a,b,c,d,e) (p)->CreateDepthStencilSurface(a,b,c,d,e) -#define IDirect3DDevice8_CreateImageSurface(p,a,b,c,d) (p)->CreateImageSurface(a,b,c,d) -#define IDirect3DDevice8_CopyRects(p,a,b,c,d,e) (p)->CopyRects(a,b,c,d,e) -#define IDirect3DDevice8_UpdateTexture(p,a,b) (p)->UpdateTexture(a,b) -#define IDirect3DDevice8_GetFrontBuffer(p,a) (p)->GetFrontBuffer(a) -#define IDirect3DDevice8_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) -#define IDirect3DDevice8_GetRenderTarget(p,a) (p)->GetRenderTarget(a) -#define IDirect3DDevice8_GetDepthStencilSurface(p,a) (p)->GetDepthStencilSurface(a) -#define IDirect3DDevice8_BeginScene(p) (p)->BeginScene() -#define IDirect3DDevice8_EndScene(p) (p)->EndScene() -#define IDirect3DDevice8_Clear(p,a,b,c,d,e,f) (p)->Clear(a,b,c,d,e,f) -#define IDirect3DDevice8_SetTransform(p,a,b) (p)->SetTransform(a,b) -#define IDirect3DDevice8_GetTransform(p,a,b) (p)->GetTransform(a,b) -#define IDirect3DDevice8_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) -#define IDirect3DDevice8_SetViewport(p,a) (p)->SetViewport(a) -#define IDirect3DDevice8_GetViewport(p,a) (p)->GetViewport(a) -#define IDirect3DDevice8_SetMaterial(p,a) (p)->SetMaterial(a) -#define IDirect3DDevice8_GetMaterial(p,a) (p)->GetMaterial(a) -#define IDirect3DDevice8_SetLight(p,a,b) (p)->SetLight(a,b) -#define IDirect3DDevice8_GetLight(p,a,b) (p)->GetLight(a,b) -#define IDirect3DDevice8_LightEnable(p,a,b) (p)->LightEnable(a,b) -#define IDirect3DDevice8_GetLightEnable(p,a,b) (p)->GetLightEnable(a,b) -#define IDirect3DDevice8_SetClipPlane(p,a,b) (p)->SetClipPlane(a,b) -#define IDirect3DDevice8_GetClipPlane(p,a,b) (p)->GetClipPlane(a,b) -#define IDirect3DDevice8_SetRenderState(p,a,b) (p)->SetRenderState(a,b) -#define IDirect3DDevice8_GetRenderState(p,a,b) (p)->GetRenderState(a,b) -#define IDirect3DDevice8_BeginStateBlock(p) (p)->BeginStateBlock() -#define IDirect3DDevice8_EndStateBlock(p,a) (p)->EndStateBlock(a) -#define IDirect3DDevice8_ApplyStateBlock(p,a) (p)->ApplyStateBlock(a) -#define IDirect3DDevice8_CaptureStateBlock(p,a) (p)->CaptureStateBlock(a) -#define IDirect3DDevice8_DeleteStateBlock(p,a) (p)->DeleteStateBlock(a) -#define IDirect3DDevice8_CreateStateBlock(p,a,b) (p)->CreateStateBlock(a,b) -#define IDirect3DDevice8_SetClipStatus(p,a) (p)->SetClipStatus(a) -#define IDirect3DDevice8_GetClipStatus(p,a) (p)->GetClipStatus(a) -#define IDirect3DDevice8_GetTexture(p,a,b) (p)->GetTexture(a,b) -#define IDirect3DDevice8_SetTexture(p,a,b) (p)->SetTexture(a,b) -#define IDirect3DDevice8_GetTextureStageState(p,a,b,c) (p)->GetTextureStageState(a,b,c) -#define IDirect3DDevice8_SetTextureStageState(p,a,b,c) (p)->SetTextureStageState(a,b,c) -#define IDirect3DDevice8_ValidateDevice(p,a) (p)->ValidateDevice(a) -#define IDirect3DDevice8_GetInfo(p,a,b,c) (p)->GetInfo(a,b,c) -#define IDirect3DDevice8_SetPaletteEntries(p,a,b) (p)->SetPaletteEntries(a,b) -#define IDirect3DDevice8_GetPaletteEntries(p,a,b) (p)->GetPaletteEntries(a,b) -#define IDirect3DDevice8_SetCurrentTexturePalette(p,a) (p)->SetCurrentTexturePalette(a) -#define IDirect3DDevice8_GetCurrentTexturePalette(p,a) (p)->GetCurrentTexturePalette(a) -#define IDirect3DDevice8_DrawPrimitive(p,a,b,c) (p)->DrawPrimitive(a,b,c) -#define IDirect3DDevice8_DrawIndexedPrimitive(p,a,b,c,d,e) (p)->DrawIndexedPrimitive(a,b,c,d,e) -#define IDirect3DDevice8_DrawPrimitiveUP(p,a,b,c,d) (p)->DrawPrimitiveUP(a,b,c,d) -#define IDirect3DDevice8_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->DrawIndexedPrimitiveUP(a,b,c,d,e,f,g,h) -#define IDirect3DDevice8_ProcessVertices(p,a,b,c,d,e) (p)->ProcessVertices(a,b,c,d,e) -#define IDirect3DDevice8_CreateVertexShader(p,a,b,c,d) (p)->CreateVertexShader(a,b,c,d) -#define IDirect3DDevice8_SetVertexShader(p,a) (p)->SetVertexShader(a) -#define IDirect3DDevice8_GetVertexShader(p,a) (p)->GetVertexShader(a) -#define IDirect3DDevice8_DeleteVertexShader(p,a) (p)->DeleteVertexShader(a) -#define IDirect3DDevice8_SetVertexShaderConstant(p,a,b,c) (p)->SetVertexShaderConstant(a,b,c) -#define IDirect3DDevice8_GetVertexShaderConstant(p,a,b,c) (p)->GetVertexShaderConstant(a,b,c) -#define IDirect3DDevice8_GetVertexShaderDeclaration(p,a,b,c) (p)->GetVertexShaderDeclaration(a,b,c) -#define IDirect3DDevice8_GetVertexShaderFunction(p,a,b,c) (p)->GetVertexShaderFunction(a,b,c) -#define IDirect3DDevice8_SetStreamSource(p,a,b,c) (p)->SetStreamSource(a,b,c) -#define IDirect3DDevice8_GetStreamSource(p,a,b,c) (p)->GetStreamSource(a,b,c) -#define IDirect3DDevice8_SetIndices(p,a,b) (p)->SetIndices(a,b) -#define IDirect3DDevice8_GetIndices(p,a,b) (p)->GetIndices(a,b) -#define IDirect3DDevice8_CreatePixelShader(p,a,b) (p)->CreatePixelShader(a,b) -#define IDirect3DDevice8_SetPixelShader(p,a) (p)->SetPixelShader(a) -#define IDirect3DDevice8_GetPixelShader(p,a) (p)->GetPixelShader(a) -#define IDirect3DDevice8_DeletePixelShader(p,a) (p)->DeletePixelShader(a) -#define IDirect3DDevice8_SetPixelShaderConstant(p,a,b,c) (p)->SetPixelShaderConstant(a,b,c) -#define IDirect3DDevice8_GetPixelShaderConstant(p,a,b,c) (p)->GetPixelShaderConstant(a,b,c) -#define IDirect3DDevice8_GetPixelShaderFunction(p,a,b,c) (p)->GetPixelShaderFunction(a,b,c) -#define IDirect3DDevice8_DrawRectPatch(p,a,b,c) (p)->DrawRectPatch(a,b,c) -#define IDirect3DDevice8_DrawTriPatch(p,a,b,c) (p)->DrawTriPatch(a,b,c) -#define IDirect3DDevice8_DeletePatch(p,a) (p)->DeletePatch(a) -#endif - - - -#undef INTERFACE -#define INTERFACE IDirect3DSwapChain8 - -DECLARE_INTERFACE_(IDirect3DSwapChain8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DSwapChain8 methods ***/ - STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; - STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) PURE; -}; - -typedef struct IDirect3DSwapChain8 *LPDIRECT3DSWAPCHAIN8, *PDIRECT3DSWAPCHAIN8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DSwapChain8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DSwapChain8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DSwapChain8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) -#define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) -#else -#define IDirect3DSwapChain8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DSwapChain8_AddRef(p) (p)->AddRef() -#define IDirect3DSwapChain8_Release(p) (p)->Release() -#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) -#define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) -#endif - - - -#undef INTERFACE -#define INTERFACE IDirect3DResource8 - -DECLARE_INTERFACE_(IDirect3DResource8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; -}; - -typedef struct IDirect3DResource8 *LPDIRECT3DRESOURCE8, *PDIRECT3DRESOURCE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DResource8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DResource8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DResource8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DResource8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DResource8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DResource8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DResource8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DResource8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DResource8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DResource8_GetType(p) (p)->lpVtbl->GetType(p) -#else -#define IDirect3DResource8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DResource8_AddRef(p) (p)->AddRef() -#define IDirect3DResource8_Release(p) (p)->Release() -#define IDirect3DResource8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DResource8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DResource8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DResource8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DResource8_GetPriority(p) (p)->GetPriority() -#define IDirect3DResource8_PreLoad(p) (p)->PreLoad() -#define IDirect3DResource8_GetType(p) (p)->GetType() -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DBaseTexture8 - -DECLARE_INTERFACE_(IDirect3DBaseTexture8, IDirect3DResource8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; -}; - -typedef struct IDirect3DBaseTexture8 *LPDIRECT3DBASETEXTURE8, *PDIRECT3DBASETEXTURE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DBaseTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DBaseTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DBaseTexture8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DBaseTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DBaseTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DBaseTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DBaseTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DBaseTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DBaseTexture8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DBaseTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DBaseTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DBaseTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#else -#define IDirect3DBaseTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DBaseTexture8_AddRef(p) (p)->AddRef() -#define IDirect3DBaseTexture8_Release(p) (p)->Release() -#define IDirect3DBaseTexture8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DBaseTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DBaseTexture8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DBaseTexture8_GetPriority(p) (p)->GetPriority() -#define IDirect3DBaseTexture8_PreLoad(p) (p)->PreLoad() -#define IDirect3DBaseTexture8_GetType(p) (p)->GetType() -#define IDirect3DBaseTexture8_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DBaseTexture8_GetLOD(p) (p)->GetLOD() -#define IDirect3DBaseTexture8_GetLevelCount(p) (p)->GetLevelCount() -#endif - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DTexture8 - -DECLARE_INTERFACE_(IDirect3DTexture8, IDirect3DBaseTexture8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DBaseTexture8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; - STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; - STDMETHOD(GetSurfaceLevel)(THIS_ UINT Level,IDirect3DSurface8** ppSurfaceLevel) PURE; - STDMETHOD(LockRect)(THIS_ UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; - STDMETHOD(UnlockRect)(THIS_ UINT Level) PURE; - STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pDirtyRect) PURE; -}; - -typedef struct IDirect3DTexture8 *LPDIRECT3DTEXTURE8, *PDIRECT3DTEXTURE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DTexture8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DTexture8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#define IDirect3DTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) -#define IDirect3DTexture8_GetSurfaceLevel(p,a,b) (p)->lpVtbl->GetSurfaceLevel(p,a,b) -#define IDirect3DTexture8_LockRect(p,a,b,c,d) (p)->lpVtbl->LockRect(p,a,b,c,d) -#define IDirect3DTexture8_UnlockRect(p,a) (p)->lpVtbl->UnlockRect(p,a) -#define IDirect3DTexture8_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a) -#else -#define IDirect3DTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DTexture8_AddRef(p) (p)->AddRef() -#define IDirect3DTexture8_Release(p) (p)->Release() -#define IDirect3DTexture8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DTexture8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DTexture8_GetPriority(p) (p)->GetPriority() -#define IDirect3DTexture8_PreLoad(p) (p)->PreLoad() -#define IDirect3DTexture8_GetType(p) (p)->GetType() -#define IDirect3DTexture8_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DTexture8_GetLOD(p) (p)->GetLOD() -#define IDirect3DTexture8_GetLevelCount(p) (p)->GetLevelCount() -#define IDirect3DTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) -#define IDirect3DTexture8_GetSurfaceLevel(p,a,b) (p)->GetSurfaceLevel(a,b) -#define IDirect3DTexture8_LockRect(p,a,b,c,d) (p)->LockRect(a,b,c,d) -#define IDirect3DTexture8_UnlockRect(p,a) (p)->UnlockRect(a) -#define IDirect3DTexture8_AddDirtyRect(p,a) (p)->AddDirtyRect(a) -#endif - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DVolumeTexture8 - -DECLARE_INTERFACE_(IDirect3DVolumeTexture8, IDirect3DBaseTexture8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DBaseTexture8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; - STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DVOLUME_DESC *pDesc) PURE; - STDMETHOD(GetVolumeLevel)(THIS_ UINT Level,IDirect3DVolume8** ppVolumeLevel) PURE; - STDMETHOD(LockBox)(THIS_ UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; - STDMETHOD(UnlockBox)(THIS_ UINT Level) PURE; - STDMETHOD(AddDirtyBox)(THIS_ CONST D3DBOX* pDirtyBox) PURE; -}; - -typedef struct IDirect3DVolumeTexture8 *LPDIRECT3DVOLUMETEXTURE8, *PDIRECT3DVOLUMETEXTURE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVolumeTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVolumeTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVolumeTexture8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVolumeTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DVolumeTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DVolumeTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DVolumeTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DVolumeTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DVolumeTexture8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DVolumeTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DVolumeTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DVolumeTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#define IDirect3DVolumeTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) -#define IDirect3DVolumeTexture8_GetVolumeLevel(p,a,b) (p)->lpVtbl->GetVolumeLevel(p,a,b) -#define IDirect3DVolumeTexture8_LockBox(p,a,b,c,d) (p)->lpVtbl->LockBox(p,a,b,c,d) -#define IDirect3DVolumeTexture8_UnlockBox(p,a) (p)->lpVtbl->UnlockBox(p,a) -#define IDirect3DVolumeTexture8_AddDirtyBox(p,a) (p)->lpVtbl->AddDirtyBox(p,a) -#else -#define IDirect3DVolumeTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVolumeTexture8_AddRef(p) (p)->AddRef() -#define IDirect3DVolumeTexture8_Release(p) (p)->Release() -#define IDirect3DVolumeTexture8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DVolumeTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DVolumeTexture8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DVolumeTexture8_GetPriority(p) (p)->GetPriority() -#define IDirect3DVolumeTexture8_PreLoad(p) (p)->PreLoad() -#define IDirect3DVolumeTexture8_GetType(p) (p)->GetType() -#define IDirect3DVolumeTexture8_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DVolumeTexture8_GetLOD(p) (p)->GetLOD() -#define IDirect3DVolumeTexture8_GetLevelCount(p) (p)->GetLevelCount() -#define IDirect3DVolumeTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) -#define IDirect3DVolumeTexture8_GetVolumeLevel(p,a,b) (p)->GetVolumeLevel(a,b) -#define IDirect3DVolumeTexture8_LockBox(p,a,b,c,d) (p)->LockBox(a,b,c,d) -#define IDirect3DVolumeTexture8_UnlockBox(p,a) (p)->UnlockBox(a) -#define IDirect3DVolumeTexture8_AddDirtyBox(p,a) (p)->AddDirtyBox(a) -#endif - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DCubeTexture8 - -DECLARE_INTERFACE_(IDirect3DCubeTexture8, IDirect3DBaseTexture8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DBaseTexture8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; - STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; - STDMETHOD(GetCubeMapSurface)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface8** ppCubeMapSurface) PURE; - STDMETHOD(LockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; - STDMETHOD(UnlockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level) PURE; - STDMETHOD(AddDirtyRect)(THIS_ D3DCUBEMAP_FACES FaceType,CONST RECT* pDirtyRect) PURE; -}; - -typedef struct IDirect3DCubeTexture8 *LPDIRECT3DCUBETEXTURE8, *PDIRECT3DCUBETEXTURE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DCubeTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DCubeTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DCubeTexture8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DCubeTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DCubeTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DCubeTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DCubeTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DCubeTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DCubeTexture8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DCubeTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DCubeTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DCubeTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#define IDirect3DCubeTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) -#define IDirect3DCubeTexture8_GetCubeMapSurface(p,a,b,c) (p)->lpVtbl->GetCubeMapSurface(p,a,b,c) -#define IDirect3DCubeTexture8_LockRect(p,a,b,c,d,e) (p)->lpVtbl->LockRect(p,a,b,c,d,e) -#define IDirect3DCubeTexture8_UnlockRect(p,a,b) (p)->lpVtbl->UnlockRect(p,a,b) -#define IDirect3DCubeTexture8_AddDirtyRect(p,a,b) (p)->lpVtbl->AddDirtyRect(p,a,b) -#else -#define IDirect3DCubeTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DCubeTexture8_AddRef(p) (p)->AddRef() -#define IDirect3DCubeTexture8_Release(p) (p)->Release() -#define IDirect3DCubeTexture8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DCubeTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DCubeTexture8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DCubeTexture8_GetPriority(p) (p)->GetPriority() -#define IDirect3DCubeTexture8_PreLoad(p) (p)->PreLoad() -#define IDirect3DCubeTexture8_GetType(p) (p)->GetType() -#define IDirect3DCubeTexture8_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DCubeTexture8_GetLOD(p) (p)->GetLOD() -#define IDirect3DCubeTexture8_GetLevelCount(p) (p)->GetLevelCount() -#define IDirect3DCubeTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) -#define IDirect3DCubeTexture8_GetCubeMapSurface(p,a,b,c) (p)->GetCubeMapSurface(a,b,c) -#define IDirect3DCubeTexture8_LockRect(p,a,b,c,d,e) (p)->LockRect(a,b,c,d,e) -#define IDirect3DCubeTexture8_UnlockRect(p,a,b) (p)->UnlockRect(a,b) -#define IDirect3DCubeTexture8_AddDirtyRect(p,a,b) (p)->AddDirtyRect(a,b) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DVertexBuffer8 - -DECLARE_INTERFACE_(IDirect3DVertexBuffer8, IDirect3DResource8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,BYTE** ppbData,DWORD Flags) PURE; - STDMETHOD(Unlock)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3DVERTEXBUFFER_DESC *pDesc) PURE; -}; - -typedef struct IDirect3DVertexBuffer8 *LPDIRECT3DVERTEXBUFFER8, *PDIRECT3DVERTEXBUFFER8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVertexBuffer8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVertexBuffer8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVertexBuffer8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DVertexBuffer8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DVertexBuffer8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DVertexBuffer8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DVertexBuffer8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DVertexBuffer8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirect3DVertexBuffer8_Unlock(p) (p)->lpVtbl->Unlock(p) -#define IDirect3DVertexBuffer8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#else -#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVertexBuffer8_AddRef(p) (p)->AddRef() -#define IDirect3DVertexBuffer8_Release(p) (p)->Release() -#define IDirect3DVertexBuffer8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DVertexBuffer8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DVertexBuffer8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DVertexBuffer8_GetPriority(p) (p)->GetPriority() -#define IDirect3DVertexBuffer8_PreLoad(p) (p)->PreLoad() -#define IDirect3DVertexBuffer8_GetType(p) (p)->GetType() -#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirect3DVertexBuffer8_Unlock(p) (p)->Unlock() -#define IDirect3DVertexBuffer8_GetDesc(p,a) (p)->GetDesc(a) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DIndexBuffer8 - -DECLARE_INTERFACE_(IDirect3DIndexBuffer8, IDirect3DResource8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,BYTE** ppbData,DWORD Flags) PURE; - STDMETHOD(Unlock)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3DINDEXBUFFER_DESC *pDesc) PURE; -}; - -typedef struct IDirect3DIndexBuffer8 *LPDIRECT3DINDEXBUFFER8, *PDIRECT3DINDEXBUFFER8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DIndexBuffer8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DIndexBuffer8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DIndexBuffer8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DIndexBuffer8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DIndexBuffer8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DIndexBuffer8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DIndexBuffer8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DIndexBuffer8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DIndexBuffer8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirect3DIndexBuffer8_Unlock(p) (p)->lpVtbl->Unlock(p) -#define IDirect3DIndexBuffer8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#else -#define IDirect3DIndexBuffer8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DIndexBuffer8_AddRef(p) (p)->AddRef() -#define IDirect3DIndexBuffer8_Release(p) (p)->Release() -#define IDirect3DIndexBuffer8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DIndexBuffer8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DIndexBuffer8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DIndexBuffer8_GetPriority(p) (p)->GetPriority() -#define IDirect3DIndexBuffer8_PreLoad(p) (p)->PreLoad() -#define IDirect3DIndexBuffer8_GetType(p) (p)->GetType() -#define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirect3DIndexBuffer8_Unlock(p) (p)->Unlock() -#define IDirect3DIndexBuffer8_GetDesc(p,a) (p)->GetDesc(a) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DSurface8 - -DECLARE_INTERFACE_(IDirect3DSurface8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DSurface8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; - STDMETHOD(GetDesc)(THIS_ D3DSURFACE_DESC *pDesc) PURE; - STDMETHOD(LockRect)(THIS_ D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; - STDMETHOD(UnlockRect)(THIS) PURE; -}; - -typedef struct IDirect3DSurface8 *LPDIRECT3DSURFACE8, *PDIRECT3DSURFACE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DSurface8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DSurface8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DSurface8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DSurface8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DSurface8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DSurface8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DSurface8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DSurface8_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) -#define IDirect3DSurface8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#define IDirect3DSurface8_LockRect(p,a,b,c) (p)->lpVtbl->LockRect(p,a,b,c) -#define IDirect3DSurface8_UnlockRect(p) (p)->lpVtbl->UnlockRect(p) -#else -#define IDirect3DSurface8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DSurface8_AddRef(p) (p)->AddRef() -#define IDirect3DSurface8_Release(p) (p)->Release() -#define IDirect3DSurface8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DSurface8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DSurface8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DSurface8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DSurface8_GetContainer(p,a,b) (p)->GetContainer(a,b) -#define IDirect3DSurface8_GetDesc(p,a) (p)->GetDesc(a) -#define IDirect3DSurface8_LockRect(p,a,b,c) (p)->LockRect(a,b,c) -#define IDirect3DSurface8_UnlockRect(p) (p)->UnlockRect() -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DVolume8 - -DECLARE_INTERFACE_(IDirect3DVolume8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DVolume8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; - STDMETHOD(GetDesc)(THIS_ D3DVOLUME_DESC *pDesc) PURE; - STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; - STDMETHOD(UnlockBox)(THIS) PURE; -}; - -typedef struct IDirect3DVolume8 *LPDIRECT3DVOLUME8, *PDIRECT3DVOLUME8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVolume8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVolume8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVolume8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVolume8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DVolume8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DVolume8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DVolume8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DVolume8_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) -#define IDirect3DVolume8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#define IDirect3DVolume8_LockBox(p,a,b,c) (p)->lpVtbl->LockBox(p,a,b,c) -#define IDirect3DVolume8_UnlockBox(p) (p)->lpVtbl->UnlockBox(p) -#else -#define IDirect3DVolume8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVolume8_AddRef(p) (p)->AddRef() -#define IDirect3DVolume8_Release(p) (p)->Release() -#define IDirect3DVolume8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DVolume8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DVolume8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DVolume8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DVolume8_GetContainer(p,a,b) (p)->GetContainer(a,b) -#define IDirect3DVolume8_GetDesc(p,a) (p)->GetDesc(a) -#define IDirect3DVolume8_LockBox(p,a,b,c) (p)->LockBox(a,b,c) -#define IDirect3DVolume8_UnlockBox(p) (p)->UnlockBox() -#endif - -/**************************************************************************** - * Flags for SetPrivateData method on all D3D8 interfaces - * - * The passed pointer is an IUnknown ptr. The SizeOfData argument to SetPrivateData - * must be set to sizeof(IUnknown*). Direct3D will call AddRef through this - * pointer and Release when the private data is destroyed. The data will be - * destroyed when another SetPrivateData with the same GUID is set, when - * FreePrivateData is called, or when the D3D8 object is freed. - ****************************************************************************/ -#define D3DSPD_IUNKNOWN 0x00000001L - -/**************************************************************************** - * - * Parameter for IDirect3D8 Enum and GetCaps8 functions to get the info for - * the current mode only. - * - ****************************************************************************/ - -#define D3DCURRENT_DISPLAY_MODE 0x00EFFFFFL - -/**************************************************************************** - * - * Flags for IDirect3D8::CreateDevice's BehaviorFlags - * - ****************************************************************************/ - -#define D3DCREATE_FPU_PRESERVE 0x00000002L -#define D3DCREATE_MULTITHREADED 0x00000004L - -#define D3DCREATE_PUREDEVICE 0x00000010L -#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020L -#define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040L -#define D3DCREATE_MIXED_VERTEXPROCESSING 0x00000080L - -#define D3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100L - - -/**************************************************************************** - * - * Parameter for IDirect3D8::CreateDevice's iAdapter - * - ****************************************************************************/ - -#define D3DADAPTER_DEFAULT 0 - -/**************************************************************************** - * - * Flags for IDirect3D8::EnumAdapters - * - ****************************************************************************/ - -#define D3DENUM_NO_WHQL_LEVEL 0x00000002L - -/**************************************************************************** - * - * Maximum number of back-buffers supported in DX8 - * - ****************************************************************************/ - -#define D3DPRESENT_BACK_BUFFERS_MAX 3L - -/**************************************************************************** - * - * Flags for IDirect3DDevice8::SetGammaRamp - * - ****************************************************************************/ - -#define D3DSGR_NO_CALIBRATION 0x00000000L -#define D3DSGR_CALIBRATE 0x00000001L - -/**************************************************************************** - * - * Flags for IDirect3DDevice8::SetCursorPosition - * - ****************************************************************************/ - -#define D3DCURSOR_IMMEDIATE_UPDATE 0x00000001L - -/**************************************************************************** - * - * Flags for DrawPrimitive/DrawIndexedPrimitive - * Also valid for Begin/BeginIndexed - * Also valid for VertexBuffer::CreateVertexBuffer - ****************************************************************************/ - - -/* - * DirectDraw error codes - */ -#define _FACD3D 0x876 -#define MAKE_D3DHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code ) - -/* - * Direct3D Errors - */ -#define D3D_OK S_OK - -#define D3DERR_WRONGTEXTUREFORMAT MAKE_D3DHRESULT(2072) -#define D3DERR_UNSUPPORTEDCOLOROPERATION MAKE_D3DHRESULT(2073) -#define D3DERR_UNSUPPORTEDCOLORARG MAKE_D3DHRESULT(2074) -#define D3DERR_UNSUPPORTEDALPHAOPERATION MAKE_D3DHRESULT(2075) -#define D3DERR_UNSUPPORTEDALPHAARG MAKE_D3DHRESULT(2076) -#define D3DERR_TOOMANYOPERATIONS MAKE_D3DHRESULT(2077) -#define D3DERR_CONFLICTINGTEXTUREFILTER MAKE_D3DHRESULT(2078) -#define D3DERR_UNSUPPORTEDFACTORVALUE MAKE_D3DHRESULT(2079) -#define D3DERR_CONFLICTINGRENDERSTATE MAKE_D3DHRESULT(2081) -#define D3DERR_UNSUPPORTEDTEXTUREFILTER MAKE_D3DHRESULT(2082) -#define D3DERR_CONFLICTINGTEXTUREPALETTE MAKE_D3DHRESULT(2086) -#define D3DERR_DRIVERINTERNALERROR MAKE_D3DHRESULT(2087) - -#define D3DERR_NOTFOUND MAKE_D3DHRESULT(2150) -#define D3DERR_MOREDATA MAKE_D3DHRESULT(2151) -#define D3DERR_DEVICELOST MAKE_D3DHRESULT(2152) -#define D3DERR_DEVICENOTRESET MAKE_D3DHRESULT(2153) -#define D3DERR_NOTAVAILABLE MAKE_D3DHRESULT(2154) -#define D3DERR_OUTOFVIDEOMEMORY MAKE_D3DHRESULT(380) -#define D3DERR_INVALIDDEVICE MAKE_D3DHRESULT(2155) -#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156) -#define D3DERR_DRIVERINVALIDCALL MAKE_D3DHRESULT(2157) - -#ifdef __cplusplus -}; -#endif - -#endif /* (DIRECT3D_VERSION >= 0x0800) */ -#endif /* _D3D_H_ */ - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3d8.h + * Content: Direct3D include file + * + ****************************************************************************/ + +#ifndef _D3D8_H_ +#define _D3D8_H_ + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0800 +#endif //DIRECT3D_VERSION + +// include this file content only if compiling for DX8 interfaces +#if(DIRECT3D_VERSION >= 0x0800) + + +/* This identifier is passed to Direct3DCreate8 in order to ensure that an + * application was built against the correct header files. This number is + * incremented whenever a header (or other) change would require applications + * to be rebuilt. If the version doesn't match, Direct3DCreate8 will fail. + * (The number itself has no meaning.)*/ + +#define D3D_SDK_VERSION 220 + + +#include + +#define COM_NO_WINDOWS_H +#include + +#include + +#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) + #define HMONITOR_DECLARED + DECLARE_HANDLE(HMONITOR); +#endif + +#define D3DAPI WINAPI + +/* + * Interface IID's + */ +#if defined( _WIN32 ) && !defined( _NO_COM) + +/* IID_IDirect3D8 */ +/* {1DD9E8DA-1C77-4d40-B0CF-98FEFDFF9512} */ +DEFINE_GUID(IID_IDirect3D8, 0x1dd9e8da, 0x1c77, 0x4d40, 0xb0, 0xcf, 0x98, 0xfe, 0xfd, 0xff, 0x95, 0x12); + +/* IID_IDirect3DDevice8 */ +/* {7385E5DF-8FE8-41D5-86B6-D7B48547B6CF} */ +DEFINE_GUID(IID_IDirect3DDevice8, 0x7385e5df, 0x8fe8, 0x41d5, 0x86, 0xb6, 0xd7, 0xb4, 0x85, 0x47, 0xb6, 0xcf); + +/* IID_IDirect3DResource8 */ +/* {1B36BB7B-09B7-410a-B445-7D1430D7B33F} */ +DEFINE_GUID(IID_IDirect3DResource8, 0x1b36bb7b, 0x9b7, 0x410a, 0xb4, 0x45, 0x7d, 0x14, 0x30, 0xd7, 0xb3, 0x3f); + +/* IID_IDirect3DBaseTexture8 */ +/* {B4211CFA-51B9-4a9f-AB78-DB99B2BB678E} */ +DEFINE_GUID(IID_IDirect3DBaseTexture8, 0xb4211cfa, 0x51b9, 0x4a9f, 0xab, 0x78, 0xdb, 0x99, 0xb2, 0xbb, 0x67, 0x8e); + +/* IID_IDirect3DTexture8 */ +/* {E4CDD575-2866-4f01-B12E-7EECE1EC9358} */ +DEFINE_GUID(IID_IDirect3DTexture8, 0xe4cdd575, 0x2866, 0x4f01, 0xb1, 0x2e, 0x7e, 0xec, 0xe1, 0xec, 0x93, 0x58); + +/* IID_IDirect3DCubeTexture8 */ +/* {3EE5B968-2ACA-4c34-8BB5-7E0C3D19B750} */ +DEFINE_GUID(IID_IDirect3DCubeTexture8, 0x3ee5b968, 0x2aca, 0x4c34, 0x8b, 0xb5, 0x7e, 0x0c, 0x3d, 0x19, 0xb7, 0x50); + +/* IID_IDirect3DVolumeTexture8 */ +/* {4B8AAAFA-140F-42ba-9131-597EAFAA2EAD} */ +DEFINE_GUID(IID_IDirect3DVolumeTexture8, 0x4b8aaafa, 0x140f, 0x42ba, 0x91, 0x31, 0x59, 0x7e, 0xaf, 0xaa, 0x2e, 0xad); + +/* IID_IDirect3DVertexBuffer8 */ +/* {8AEEEAC7-05F9-44d4-B591-000B0DF1CB95} */ +DEFINE_GUID(IID_IDirect3DVertexBuffer8, 0x8aeeeac7, 0x05f9, 0x44d4, 0xb5, 0x91, 0x00, 0x0b, 0x0d, 0xf1, 0xcb, 0x95); + +/* IID_IDirect3DIndexBuffer8 */ +/* {0E689C9A-053D-44a0-9D92-DB0E3D750F86} */ +DEFINE_GUID(IID_IDirect3DIndexBuffer8, 0x0e689c9a, 0x053d, 0x44a0, 0x9d, 0x92, 0xdb, 0x0e, 0x3d, 0x75, 0x0f, 0x86); + +/* IID_IDirect3DSurface8 */ +/* {B96EEBCA-B326-4ea5-882F-2FF5BAE021DD} */ +DEFINE_GUID(IID_IDirect3DSurface8, 0xb96eebca, 0xb326, 0x4ea5, 0x88, 0x2f, 0x2f, 0xf5, 0xba, 0xe0, 0x21, 0xdd); + +/* IID_IDirect3DVolume8 */ +/* {BD7349F5-14F1-42e4-9C79-972380DB40C0} */ +DEFINE_GUID(IID_IDirect3DVolume8, 0xbd7349f5, 0x14f1, 0x42e4, 0x9c, 0x79, 0x97, 0x23, 0x80, 0xdb, 0x40, 0xc0); + +/* IID_IDirect3DSwapChain8 */ +/* {928C088B-76B9-4C6B-A536-A590853876CD} */ +DEFINE_GUID(IID_IDirect3DSwapChain8, 0x928c088b, 0x76b9, 0x4c6b, 0xa5, 0x36, 0xa5, 0x90, 0x85, 0x38, 0x76, 0xcd); + +#endif + +#ifdef __cplusplus + +interface IDirect3D8; +interface IDirect3DDevice8; + +interface IDirect3DResource8; +interface IDirect3DBaseTexture8; +interface IDirect3DTexture8; +interface IDirect3DVolumeTexture8; +interface IDirect3DCubeTexture8; + +interface IDirect3DVertexBuffer8; +interface IDirect3DIndexBuffer8; + +interface IDirect3DSurface8; +interface IDirect3DVolume8; + +interface IDirect3DSwapChain8; + +#endif + + +typedef interface IDirect3D8 IDirect3D8; +typedef interface IDirect3DDevice8 IDirect3DDevice8; +typedef interface IDirect3DResource8 IDirect3DResource8; +typedef interface IDirect3DBaseTexture8 IDirect3DBaseTexture8; +typedef interface IDirect3DTexture8 IDirect3DTexture8; +typedef interface IDirect3DVolumeTexture8 IDirect3DVolumeTexture8; +typedef interface IDirect3DCubeTexture8 IDirect3DCubeTexture8; +typedef interface IDirect3DVertexBuffer8 IDirect3DVertexBuffer8; +typedef interface IDirect3DIndexBuffer8 IDirect3DIndexBuffer8; +typedef interface IDirect3DSurface8 IDirect3DSurface8; +typedef interface IDirect3DVolume8 IDirect3DVolume8; +typedef interface IDirect3DSwapChain8 IDirect3DSwapChain8; + +#include "d3d8types.h" +#include "d3d8caps.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * DLL Function for creating a Direct3D8 object. This object supports + * enumeration and allows the creation of Direct3DDevice8 objects. + * Pass the value of the constant D3D_SDK_VERSION to this function, so + * that the run-time can validate that your application was compiled + * against the right headers. + */ + +IDirect3D8 * WINAPI Direct3DCreate8(UINT SDKVersion); + + +/* + * Direct3D interfaces + */ + + + + + + +#undef INTERFACE +#define INTERFACE IDirect3D8 + +DECLARE_INTERFACE_(IDirect3D8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3D8 methods ***/ + STDMETHOD(RegisterSoftwareDevice)(THIS_ void* pInitializeFunction) PURE; + STDMETHOD_(UINT, GetAdapterCount)(THIS) PURE; + STDMETHOD(GetAdapterIdentifier)(THIS_ UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER8* pIdentifier) PURE; + STDMETHOD_(UINT, GetAdapterModeCount)(THIS_ UINT Adapter) PURE; + STDMETHOD(EnumAdapterModes)(THIS_ UINT Adapter,UINT Mode,D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(GetAdapterDisplayMode)(THIS_ UINT Adapter,D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(CheckDeviceType)(THIS_ UINT Adapter,D3DDEVTYPE CheckType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL Windowed) PURE; + STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) PURE; + STDMETHOD(CheckDeviceMultiSampleType)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType) PURE; + STDMETHOD(CheckDepthStencilMatch)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) PURE; + STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS8* pCaps) PURE; + STDMETHOD_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter) PURE; + STDMETHOD(CreateDevice)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice8** ppReturnedDeviceInterface) PURE; +}; + +typedef struct IDirect3D8 *LPDIRECT3D8, *PDIRECT3D8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3D8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3D8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3D8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3D8_RegisterSoftwareDevice(p,a) (p)->lpVtbl->RegisterSoftwareDevice(p,a) +#define IDirect3D8_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p) +#define IDirect3D8_GetAdapterIdentifier(p,a,b,c) (p)->lpVtbl->GetAdapterIdentifier(p,a,b,c) +#define IDirect3D8_GetAdapterModeCount(p,a) (p)->lpVtbl->GetAdapterModeCount(p,a) +#define IDirect3D8_EnumAdapterModes(p,a,b,c) (p)->lpVtbl->EnumAdapterModes(p,a,b,c) +#define IDirect3D8_GetAdapterDisplayMode(p,a,b) (p)->lpVtbl->GetAdapterDisplayMode(p,a,b) +#define IDirect3D8_CheckDeviceType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceType(p,a,b,c,d,e) +#define IDirect3D8_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f) +#define IDirect3D8_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceMultiSampleType(p,a,b,c,d,e) +#define IDirect3D8_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->lpVtbl->CheckDepthStencilMatch(p,a,b,c,d,e) +#define IDirect3D8_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c) +#define IDirect3D8_GetAdapterMonitor(p,a) (p)->lpVtbl->GetAdapterMonitor(p,a) +#define IDirect3D8_CreateDevice(p,a,b,c,d,e,f) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f) +#else +#define IDirect3D8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3D8_AddRef(p) (p)->AddRef() +#define IDirect3D8_Release(p) (p)->Release() +#define IDirect3D8_RegisterSoftwareDevice(p,a) (p)->RegisterSoftwareDevice(a) +#define IDirect3D8_GetAdapterCount(p) (p)->GetAdapterCount() +#define IDirect3D8_GetAdapterIdentifier(p,a,b,c) (p)->GetAdapterIdentifier(a,b,c) +#define IDirect3D8_GetAdapterModeCount(p,a) (p)->GetAdapterModeCount(a) +#define IDirect3D8_EnumAdapterModes(p,a,b,c) (p)->EnumAdapterModes(a,b,c) +#define IDirect3D8_GetAdapterDisplayMode(p,a,b) (p)->GetAdapterDisplayMode(a,b) +#define IDirect3D8_CheckDeviceType(p,a,b,c,d,e) (p)->CheckDeviceType(a,b,c,d,e) +#define IDirect3D8_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->CheckDeviceFormat(a,b,c,d,e,f) +#define IDirect3D8_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->CheckDeviceMultiSampleType(a,b,c,d,e) +#define IDirect3D8_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->CheckDepthStencilMatch(a,b,c,d,e) +#define IDirect3D8_GetDeviceCaps(p,a,b,c) (p)->GetDeviceCaps(a,b,c) +#define IDirect3D8_GetAdapterMonitor(p,a) (p)->GetAdapterMonitor(a) +#define IDirect3D8_CreateDevice(p,a,b,c,d,e,f) (p)->CreateDevice(a,b,c,d,e,f) +#endif + + + + + + + + + + + + + + + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DDevice8 + +DECLARE_INTERFACE_(IDirect3DDevice8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DDevice8 methods ***/ + STDMETHOD(TestCooperativeLevel)(THIS) PURE; + STDMETHOD_(UINT, GetAvailableTextureMem)(THIS) PURE; + STDMETHOD(ResourceManagerDiscardBytes)(THIS_ DWORD Bytes) PURE; + STDMETHOD(GetDirect3D)(THIS_ IDirect3D8** ppD3D8) PURE; + STDMETHOD(GetDeviceCaps)(THIS_ D3DCAPS8* pCaps) PURE; + STDMETHOD(GetDisplayMode)(THIS_ D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(GetCreationParameters)(THIS_ D3DDEVICE_CREATION_PARAMETERS *pParameters) PURE; + STDMETHOD(SetCursorProperties)(THIS_ UINT XHotSpot,UINT YHotSpot,IDirect3DSurface8* pCursorBitmap) PURE; + STDMETHOD_(void, SetCursorPosition)(THIS_ UINT XScreenSpace,UINT YScreenSpace,DWORD Flags) PURE; + STDMETHOD_(BOOL, ShowCursor)(THIS_ BOOL bShow) PURE; + STDMETHOD(CreateAdditionalSwapChain)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain8** pSwapChain) PURE; + STDMETHOD(Reset)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; + STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; + STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) PURE; + STDMETHOD(GetRasterStatus)(THIS_ D3DRASTER_STATUS* pRasterStatus) PURE; + STDMETHOD_(void, SetGammaRamp)(THIS_ DWORD Flags,CONST D3DGAMMARAMP* pRamp) PURE; + STDMETHOD_(void, GetGammaRamp)(THIS_ D3DGAMMARAMP* pRamp) PURE; + STDMETHOD(CreateTexture)(THIS_ UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture8** ppTexture) PURE; + STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture8** ppVolumeTexture) PURE; + STDMETHOD(CreateCubeTexture)(THIS_ UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture8** ppCubeTexture) PURE; + STDMETHOD(CreateVertexBuffer)(THIS_ UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer8** ppVertexBuffer) PURE; + STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer8** ppIndexBuffer) PURE; + STDMETHOD(CreateRenderTarget)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,BOOL Lockable,IDirect3DSurface8** ppSurface) PURE; + STDMETHOD(CreateDepthStencilSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,IDirect3DSurface8** ppSurface) PURE; + STDMETHOD(CreateImageSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,IDirect3DSurface8** ppSurface) PURE; + STDMETHOD(CopyRects)(THIS_ IDirect3DSurface8* pSourceSurface,CONST RECT* pSourceRectsArray,UINT cRects,IDirect3DSurface8* pDestinationSurface,CONST POINT* pDestPointsArray) PURE; + STDMETHOD(UpdateTexture)(THIS_ IDirect3DBaseTexture8* pSourceTexture,IDirect3DBaseTexture8* pDestinationTexture) PURE; + STDMETHOD(GetFrontBuffer)(THIS_ IDirect3DSurface8* pDestSurface) PURE; + STDMETHOD(SetRenderTarget)(THIS_ IDirect3DSurface8* pRenderTarget,IDirect3DSurface8* pNewZStencil) PURE; + STDMETHOD(GetRenderTarget)(THIS_ IDirect3DSurface8** ppRenderTarget) PURE; + STDMETHOD(GetDepthStencilSurface)(THIS_ IDirect3DSurface8** ppZStencilSurface) PURE; + STDMETHOD(BeginScene)(THIS) PURE; + STDMETHOD(EndScene)(THIS) PURE; + STDMETHOD(Clear)(THIS_ DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil) PURE; + STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) PURE; + STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) PURE; + STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,CONST D3DMATRIX*) PURE; + STDMETHOD(SetViewport)(THIS_ CONST D3DVIEWPORT8* pViewport) PURE; + STDMETHOD(GetViewport)(THIS_ D3DVIEWPORT8* pViewport) PURE; + STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL8* pMaterial) PURE; + STDMETHOD(GetMaterial)(THIS_ D3DMATERIAL8* pMaterial) PURE; + STDMETHOD(SetLight)(THIS_ DWORD Index,CONST D3DLIGHT8*) PURE; + STDMETHOD(GetLight)(THIS_ DWORD Index,D3DLIGHT8*) PURE; + STDMETHOD(LightEnable)(THIS_ DWORD Index,BOOL Enable) PURE; + STDMETHOD(GetLightEnable)(THIS_ DWORD Index,BOOL* pEnable) PURE; + STDMETHOD(SetClipPlane)(THIS_ DWORD Index,CONST float* pPlane) PURE; + STDMETHOD(GetClipPlane)(THIS_ DWORD Index,float* pPlane) PURE; + STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD Value) PURE; + STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD* pValue) PURE; + STDMETHOD(BeginStateBlock)(THIS) PURE; + STDMETHOD(EndStateBlock)(THIS_ DWORD* pToken) PURE; + STDMETHOD(ApplyStateBlock)(THIS_ DWORD Token) PURE; + STDMETHOD(CaptureStateBlock)(THIS_ DWORD Token) PURE; + STDMETHOD(DeleteStateBlock)(THIS_ DWORD Token) PURE; + STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type,DWORD* pToken) PURE; + STDMETHOD(SetClipStatus)(THIS_ CONST D3DCLIPSTATUS8* pClipStatus) PURE; + STDMETHOD(GetClipStatus)(THIS_ D3DCLIPSTATUS8* pClipStatus) PURE; + STDMETHOD(GetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8** ppTexture) PURE; + STDMETHOD(SetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8* pTexture) PURE; + STDMETHOD(GetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) PURE; + STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE; + STDMETHOD(ValidateDevice)(THIS_ DWORD* pNumPasses) PURE; + STDMETHOD(GetInfo)(THIS_ DWORD DevInfoID,void* pDevInfoStruct,DWORD DevInfoStructSize) PURE; + STDMETHOD(SetPaletteEntries)(THIS_ UINT PaletteNumber,CONST PALETTEENTRY* pEntries) PURE; + STDMETHOD(GetPaletteEntries)(THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries) PURE; + STDMETHOD(SetCurrentTexturePalette)(THIS_ UINT PaletteNumber) PURE; + STDMETHOD(GetCurrentTexturePalette)(THIS_ UINT *PaletteNumber) PURE; + STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) PURE; + STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount) PURE; + STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; + STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; + STDMETHOD(ProcessVertices)(THIS_ UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags) PURE; + STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD* pDeclaration,CONST DWORD* pFunction,DWORD* pHandle,DWORD Usage) PURE; + STDMETHOD(SetVertexShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(GetVertexShader)(THIS_ DWORD* pHandle) PURE; + STDMETHOD(DeleteVertexShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(SetVertexShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetVertexShaderConstant)(THIS_ DWORD Register,void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetVertexShaderDeclaration)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(GetVertexShaderFunction)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(SetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8* pStreamData,UINT Stride) PURE; + STDMETHOD(GetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8** ppStreamData,UINT* pStride) PURE; + STDMETHOD(SetIndices)(THIS_ IDirect3DIndexBuffer8* pIndexData,UINT BaseVertexIndex) PURE; + STDMETHOD(GetIndices)(THIS_ IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) PURE; + STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction,DWORD* pHandle) PURE; + STDMETHOD(SetPixelShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(GetPixelShader)(THIS_ DWORD* pHandle) PURE; + STDMETHOD(DeletePixelShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(SetPixelShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetPixelShaderConstant)(THIS_ DWORD Register,void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetPixelShaderFunction)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(DrawRectPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) PURE; + STDMETHOD(DrawTriPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) PURE; + STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE; +}; + +typedef struct IDirect3DDevice8 *LPDIRECT3DDEVICE8, *PDIRECT3DDEVICE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DDevice8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DDevice8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DDevice8_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) +#define IDirect3DDevice8_GetAvailableTextureMem(p) (p)->lpVtbl->GetAvailableTextureMem(p) +#define IDirect3DDevice8_ResourceManagerDiscardBytes(p,a) (p)->lpVtbl->ResourceManagerDiscardBytes(p,a) +#define IDirect3DDevice8_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) +#define IDirect3DDevice8_GetDeviceCaps(p,a) (p)->lpVtbl->GetDeviceCaps(p,a) +#define IDirect3DDevice8_GetDisplayMode(p,a) (p)->lpVtbl->GetDisplayMode(p,a) +#define IDirect3DDevice8_GetCreationParameters(p,a) (p)->lpVtbl->GetCreationParameters(p,a) +#define IDirect3DDevice8_SetCursorProperties(p,a,b,c) (p)->lpVtbl->SetCursorProperties(p,a,b,c) +#define IDirect3DDevice8_SetCursorPosition(p,a,b,c) (p)->lpVtbl->SetCursorPosition(p,a,b,c) +#define IDirect3DDevice8_ShowCursor(p,a) (p)->lpVtbl->ShowCursor(p,a) +#define IDirect3DDevice8_CreateAdditionalSwapChain(p,a,b) (p)->lpVtbl->CreateAdditionalSwapChain(p,a,b) +#define IDirect3DDevice8_Reset(p,a) (p)->lpVtbl->Reset(p,a) +#define IDirect3DDevice8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) +#define IDirect3DDevice8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) +#define IDirect3DDevice8_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a) +#define IDirect3DDevice8_SetGammaRamp(p,a,b) (p)->lpVtbl->SetGammaRamp(p,a,b) +#define IDirect3DDevice8_GetGammaRamp(p,a) (p)->lpVtbl->GetGammaRamp(p,a) +#define IDirect3DDevice8_CreateTexture(p,a,b,c,d,e,f,g) (p)->lpVtbl->CreateTexture(p,a,b,c,d,e,f,g) +#define IDirect3DDevice8_CreateVolumeTexture(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateVolumeTexture(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_CreateCubeTexture(p,a,b,c,d,e,f) (p)->lpVtbl->CreateCubeTexture(p,a,b,c,d,e,f) +#define IDirect3DDevice8_CreateVertexBuffer(p,a,b,c,d,e) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateIndexBuffer(p,a,b,c,d,e) (p)->lpVtbl->CreateIndexBuffer(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateRenderTarget(p,a,b,c,d,e,f) (p)->lpVtbl->CreateRenderTarget(p,a,b,c,d,e,f) +#define IDirect3DDevice8_CreateDepthStencilSurface(p,a,b,c,d,e) (p)->lpVtbl->CreateDepthStencilSurface(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateImageSurface(p,a,b,c,d) (p)->lpVtbl->CreateImageSurface(p,a,b,c,d) +#define IDirect3DDevice8_CopyRects(p,a,b,c,d,e) (p)->lpVtbl->CopyRects(p,a,b,c,d,e) +#define IDirect3DDevice8_UpdateTexture(p,a,b) (p)->lpVtbl->UpdateTexture(p,a,b) +#define IDirect3DDevice8_GetFrontBuffer(p,a) (p)->lpVtbl->GetFrontBuffer(p,a) +#define IDirect3DDevice8_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) +#define IDirect3DDevice8_GetRenderTarget(p,a) (p)->lpVtbl->GetRenderTarget(p,a) +#define IDirect3DDevice8_GetDepthStencilSurface(p,a) (p)->lpVtbl->GetDepthStencilSurface(p,a) +#define IDirect3DDevice8_BeginScene(p) (p)->lpVtbl->BeginScene(p) +#define IDirect3DDevice8_EndScene(p) (p)->lpVtbl->EndScene(p) +#define IDirect3DDevice8_Clear(p,a,b,c,d,e,f) (p)->lpVtbl->Clear(p,a,b,c,d,e,f) +#define IDirect3DDevice8_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) +#define IDirect3DDevice8_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) +#define IDirect3DDevice8_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) +#define IDirect3DDevice8_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) +#define IDirect3DDevice8_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) +#define IDirect3DDevice8_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) +#define IDirect3DDevice8_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) +#define IDirect3DDevice8_SetLight(p,a,b) (p)->lpVtbl->SetLight(p,a,b) +#define IDirect3DDevice8_GetLight(p,a,b) (p)->lpVtbl->GetLight(p,a,b) +#define IDirect3DDevice8_LightEnable(p,a,b) (p)->lpVtbl->LightEnable(p,a,b) +#define IDirect3DDevice8_GetLightEnable(p,a,b) (p)->lpVtbl->GetLightEnable(p,a,b) +#define IDirect3DDevice8_SetClipPlane(p,a,b) (p)->lpVtbl->SetClipPlane(p,a,b) +#define IDirect3DDevice8_GetClipPlane(p,a,b) (p)->lpVtbl->GetClipPlane(p,a,b) +#define IDirect3DDevice8_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) +#define IDirect3DDevice8_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) +#define IDirect3DDevice8_BeginStateBlock(p) (p)->lpVtbl->BeginStateBlock(p) +#define IDirect3DDevice8_EndStateBlock(p,a) (p)->lpVtbl->EndStateBlock(p,a) +#define IDirect3DDevice8_ApplyStateBlock(p,a) (p)->lpVtbl->ApplyStateBlock(p,a) +#define IDirect3DDevice8_CaptureStateBlock(p,a) (p)->lpVtbl->CaptureStateBlock(p,a) +#define IDirect3DDevice8_DeleteStateBlock(p,a) (p)->lpVtbl->DeleteStateBlock(p,a) +#define IDirect3DDevice8_CreateStateBlock(p,a,b) (p)->lpVtbl->CreateStateBlock(p,a,b) +#define IDirect3DDevice8_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) +#define IDirect3DDevice8_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) +#define IDirect3DDevice8_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) +#define IDirect3DDevice8_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) +#define IDirect3DDevice8_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) +#define IDirect3DDevice8_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) +#define IDirect3DDevice8_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a) +#define IDirect3DDevice8_GetInfo(p,a,b,c) (p)->lpVtbl->GetInfo(p,a,b,c) +#define IDirect3DDevice8_SetPaletteEntries(p,a,b) (p)->lpVtbl->SetPaletteEntries(p,a,b) +#define IDirect3DDevice8_GetPaletteEntries(p,a,b) (p)->lpVtbl->GetPaletteEntries(p,a,b) +#define IDirect3DDevice8_SetCurrentTexturePalette(p,a) (p)->lpVtbl->SetCurrentTexturePalette(p,a) +#define IDirect3DDevice8_GetCurrentTexturePalette(p,a) (p)->lpVtbl->GetCurrentTexturePalette(p,a) +#define IDirect3DDevice8_DrawPrimitive(p,a,b,c) (p)->lpVtbl->DrawPrimitive(p,a,b,c) +#define IDirect3DDevice8_DrawIndexedPrimitive(p,a,b,c,d,e) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e) +#define IDirect3DDevice8_DrawPrimitiveUP(p,a,b,c,d) (p)->lpVtbl->DrawPrimitiveUP(p,a,b,c,d) +#define IDirect3DDevice8_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_ProcessVertices(p,a,b,c,d,e) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateVertexShader(p,a,b,c,d) (p)->lpVtbl->CreateVertexShader(p,a,b,c,d) +#define IDirect3DDevice8_SetVertexShader(p,a) (p)->lpVtbl->SetVertexShader(p,a) +#define IDirect3DDevice8_GetVertexShader(p,a) (p)->lpVtbl->GetVertexShader(p,a) +#define IDirect3DDevice8_DeleteVertexShader(p,a) (p)->lpVtbl->DeleteVertexShader(p,a) +#define IDirect3DDevice8_SetVertexShaderConstant(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetVertexShaderConstant(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetVertexShaderDeclaration(p,a,b,c) (p)->lpVtbl->GetVertexShaderDeclaration(p,a,b,c) +#define IDirect3DDevice8_GetVertexShaderFunction(p,a,b,c) (p)->lpVtbl->GetVertexShaderFunction(p,a,b,c) +#define IDirect3DDevice8_SetStreamSource(p,a,b,c) (p)->lpVtbl->SetStreamSource(p,a,b,c) +#define IDirect3DDevice8_GetStreamSource(p,a,b,c) (p)->lpVtbl->GetStreamSource(p,a,b,c) +#define IDirect3DDevice8_SetIndices(p,a,b) (p)->lpVtbl->SetIndices(p,a,b) +#define IDirect3DDevice8_GetIndices(p,a,b) (p)->lpVtbl->GetIndices(p,a,b) +#define IDirect3DDevice8_CreatePixelShader(p,a,b) (p)->lpVtbl->CreatePixelShader(p,a,b) +#define IDirect3DDevice8_SetPixelShader(p,a) (p)->lpVtbl->SetPixelShader(p,a) +#define IDirect3DDevice8_GetPixelShader(p,a) (p)->lpVtbl->GetPixelShader(p,a) +#define IDirect3DDevice8_DeletePixelShader(p,a) (p)->lpVtbl->DeletePixelShader(p,a) +#define IDirect3DDevice8_SetPixelShaderConstant(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetPixelShaderConstant(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetPixelShaderFunction(p,a,b,c) (p)->lpVtbl->GetPixelShaderFunction(p,a,b,c) +#define IDirect3DDevice8_DrawRectPatch(p,a,b,c) (p)->lpVtbl->DrawRectPatch(p,a,b,c) +#define IDirect3DDevice8_DrawTriPatch(p,a,b,c) (p)->lpVtbl->DrawTriPatch(p,a,b,c) +#define IDirect3DDevice8_DeletePatch(p,a) (p)->lpVtbl->DeletePatch(p,a) +#else +#define IDirect3DDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DDevice8_AddRef(p) (p)->AddRef() +#define IDirect3DDevice8_Release(p) (p)->Release() +#define IDirect3DDevice8_TestCooperativeLevel(p) (p)->TestCooperativeLevel() +#define IDirect3DDevice8_GetAvailableTextureMem(p) (p)->GetAvailableTextureMem() +#define IDirect3DDevice8_ResourceManagerDiscardBytes(p,a) (p)->ResourceManagerDiscardBytes(a) +#define IDirect3DDevice8_GetDirect3D(p,a) (p)->GetDirect3D(a) +#define IDirect3DDevice8_GetDeviceCaps(p,a) (p)->GetDeviceCaps(a) +#define IDirect3DDevice8_GetDisplayMode(p,a) (p)->GetDisplayMode(a) +#define IDirect3DDevice8_GetCreationParameters(p,a) (p)->GetCreationParameters(a) +#define IDirect3DDevice8_SetCursorProperties(p,a,b,c) (p)->SetCursorProperties(a,b,c) +#define IDirect3DDevice8_SetCursorPosition(p,a,b,c) (p)->SetCursorPosition(a,b,c) +#define IDirect3DDevice8_ShowCursor(p,a) (p)->ShowCursor(a) +#define IDirect3DDevice8_CreateAdditionalSwapChain(p,a,b) (p)->CreateAdditionalSwapChain(a,b) +#define IDirect3DDevice8_Reset(p,a) (p)->Reset(a) +#define IDirect3DDevice8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) +#define IDirect3DDevice8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) +#define IDirect3DDevice8_GetRasterStatus(p,a) (p)->GetRasterStatus(a) +#define IDirect3DDevice8_SetGammaRamp(p,a,b) (p)->SetGammaRamp(a,b) +#define IDirect3DDevice8_GetGammaRamp(p,a) (p)->GetGammaRamp(a) +#define IDirect3DDevice8_CreateTexture(p,a,b,c,d,e,f,g) (p)->CreateTexture(a,b,c,d,e,f,g) +#define IDirect3DDevice8_CreateVolumeTexture(p,a,b,c,d,e,f,g,h) (p)->CreateVolumeTexture(a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_CreateCubeTexture(p,a,b,c,d,e,f) (p)->CreateCubeTexture(a,b,c,d,e,f) +#define IDirect3DDevice8_CreateVertexBuffer(p,a,b,c,d,e) (p)->CreateVertexBuffer(a,b,c,d,e) +#define IDirect3DDevice8_CreateIndexBuffer(p,a,b,c,d,e) (p)->CreateIndexBuffer(a,b,c,d,e) +#define IDirect3DDevice8_CreateRenderTarget(p,a,b,c,d,e,f) (p)->CreateRenderTarget(a,b,c,d,e,f) +#define IDirect3DDevice8_CreateDepthStencilSurface(p,a,b,c,d,e) (p)->CreateDepthStencilSurface(a,b,c,d,e) +#define IDirect3DDevice8_CreateImageSurface(p,a,b,c,d) (p)->CreateImageSurface(a,b,c,d) +#define IDirect3DDevice8_CopyRects(p,a,b,c,d,e) (p)->CopyRects(a,b,c,d,e) +#define IDirect3DDevice8_UpdateTexture(p,a,b) (p)->UpdateTexture(a,b) +#define IDirect3DDevice8_GetFrontBuffer(p,a) (p)->GetFrontBuffer(a) +#define IDirect3DDevice8_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) +#define IDirect3DDevice8_GetRenderTarget(p,a) (p)->GetRenderTarget(a) +#define IDirect3DDevice8_GetDepthStencilSurface(p,a) (p)->GetDepthStencilSurface(a) +#define IDirect3DDevice8_BeginScene(p) (p)->BeginScene() +#define IDirect3DDevice8_EndScene(p) (p)->EndScene() +#define IDirect3DDevice8_Clear(p,a,b,c,d,e,f) (p)->Clear(a,b,c,d,e,f) +#define IDirect3DDevice8_SetTransform(p,a,b) (p)->SetTransform(a,b) +#define IDirect3DDevice8_GetTransform(p,a,b) (p)->GetTransform(a,b) +#define IDirect3DDevice8_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) +#define IDirect3DDevice8_SetViewport(p,a) (p)->SetViewport(a) +#define IDirect3DDevice8_GetViewport(p,a) (p)->GetViewport(a) +#define IDirect3DDevice8_SetMaterial(p,a) (p)->SetMaterial(a) +#define IDirect3DDevice8_GetMaterial(p,a) (p)->GetMaterial(a) +#define IDirect3DDevice8_SetLight(p,a,b) (p)->SetLight(a,b) +#define IDirect3DDevice8_GetLight(p,a,b) (p)->GetLight(a,b) +#define IDirect3DDevice8_LightEnable(p,a,b) (p)->LightEnable(a,b) +#define IDirect3DDevice8_GetLightEnable(p,a,b) (p)->GetLightEnable(a,b) +#define IDirect3DDevice8_SetClipPlane(p,a,b) (p)->SetClipPlane(a,b) +#define IDirect3DDevice8_GetClipPlane(p,a,b) (p)->GetClipPlane(a,b) +#define IDirect3DDevice8_SetRenderState(p,a,b) (p)->SetRenderState(a,b) +#define IDirect3DDevice8_GetRenderState(p,a,b) (p)->GetRenderState(a,b) +#define IDirect3DDevice8_BeginStateBlock(p) (p)->BeginStateBlock() +#define IDirect3DDevice8_EndStateBlock(p,a) (p)->EndStateBlock(a) +#define IDirect3DDevice8_ApplyStateBlock(p,a) (p)->ApplyStateBlock(a) +#define IDirect3DDevice8_CaptureStateBlock(p,a) (p)->CaptureStateBlock(a) +#define IDirect3DDevice8_DeleteStateBlock(p,a) (p)->DeleteStateBlock(a) +#define IDirect3DDevice8_CreateStateBlock(p,a,b) (p)->CreateStateBlock(a,b) +#define IDirect3DDevice8_SetClipStatus(p,a) (p)->SetClipStatus(a) +#define IDirect3DDevice8_GetClipStatus(p,a) (p)->GetClipStatus(a) +#define IDirect3DDevice8_GetTexture(p,a,b) (p)->GetTexture(a,b) +#define IDirect3DDevice8_SetTexture(p,a,b) (p)->SetTexture(a,b) +#define IDirect3DDevice8_GetTextureStageState(p,a,b,c) (p)->GetTextureStageState(a,b,c) +#define IDirect3DDevice8_SetTextureStageState(p,a,b,c) (p)->SetTextureStageState(a,b,c) +#define IDirect3DDevice8_ValidateDevice(p,a) (p)->ValidateDevice(a) +#define IDirect3DDevice8_GetInfo(p,a,b,c) (p)->GetInfo(a,b,c) +#define IDirect3DDevice8_SetPaletteEntries(p,a,b) (p)->SetPaletteEntries(a,b) +#define IDirect3DDevice8_GetPaletteEntries(p,a,b) (p)->GetPaletteEntries(a,b) +#define IDirect3DDevice8_SetCurrentTexturePalette(p,a) (p)->SetCurrentTexturePalette(a) +#define IDirect3DDevice8_GetCurrentTexturePalette(p,a) (p)->GetCurrentTexturePalette(a) +#define IDirect3DDevice8_DrawPrimitive(p,a,b,c) (p)->DrawPrimitive(a,b,c) +#define IDirect3DDevice8_DrawIndexedPrimitive(p,a,b,c,d,e) (p)->DrawIndexedPrimitive(a,b,c,d,e) +#define IDirect3DDevice8_DrawPrimitiveUP(p,a,b,c,d) (p)->DrawPrimitiveUP(a,b,c,d) +#define IDirect3DDevice8_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->DrawIndexedPrimitiveUP(a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_ProcessVertices(p,a,b,c,d,e) (p)->ProcessVertices(a,b,c,d,e) +#define IDirect3DDevice8_CreateVertexShader(p,a,b,c,d) (p)->CreateVertexShader(a,b,c,d) +#define IDirect3DDevice8_SetVertexShader(p,a) (p)->SetVertexShader(a) +#define IDirect3DDevice8_GetVertexShader(p,a) (p)->GetVertexShader(a) +#define IDirect3DDevice8_DeleteVertexShader(p,a) (p)->DeleteVertexShader(a) +#define IDirect3DDevice8_SetVertexShaderConstant(p,a,b,c) (p)->SetVertexShaderConstant(a,b,c) +#define IDirect3DDevice8_GetVertexShaderConstant(p,a,b,c) (p)->GetVertexShaderConstant(a,b,c) +#define IDirect3DDevice8_GetVertexShaderDeclaration(p,a,b,c) (p)->GetVertexShaderDeclaration(a,b,c) +#define IDirect3DDevice8_GetVertexShaderFunction(p,a,b,c) (p)->GetVertexShaderFunction(a,b,c) +#define IDirect3DDevice8_SetStreamSource(p,a,b,c) (p)->SetStreamSource(a,b,c) +#define IDirect3DDevice8_GetStreamSource(p,a,b,c) (p)->GetStreamSource(a,b,c) +#define IDirect3DDevice8_SetIndices(p,a,b) (p)->SetIndices(a,b) +#define IDirect3DDevice8_GetIndices(p,a,b) (p)->GetIndices(a,b) +#define IDirect3DDevice8_CreatePixelShader(p,a,b) (p)->CreatePixelShader(a,b) +#define IDirect3DDevice8_SetPixelShader(p,a) (p)->SetPixelShader(a) +#define IDirect3DDevice8_GetPixelShader(p,a) (p)->GetPixelShader(a) +#define IDirect3DDevice8_DeletePixelShader(p,a) (p)->DeletePixelShader(a) +#define IDirect3DDevice8_SetPixelShaderConstant(p,a,b,c) (p)->SetPixelShaderConstant(a,b,c) +#define IDirect3DDevice8_GetPixelShaderConstant(p,a,b,c) (p)->GetPixelShaderConstant(a,b,c) +#define IDirect3DDevice8_GetPixelShaderFunction(p,a,b,c) (p)->GetPixelShaderFunction(a,b,c) +#define IDirect3DDevice8_DrawRectPatch(p,a,b,c) (p)->DrawRectPatch(a,b,c) +#define IDirect3DDevice8_DrawTriPatch(p,a,b,c) (p)->DrawTriPatch(a,b,c) +#define IDirect3DDevice8_DeletePatch(p,a) (p)->DeletePatch(a) +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DSwapChain8 + +DECLARE_INTERFACE_(IDirect3DSwapChain8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DSwapChain8 methods ***/ + STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; + STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) PURE; +}; + +typedef struct IDirect3DSwapChain8 *LPDIRECT3DSWAPCHAIN8, *PDIRECT3DSWAPCHAIN8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DSwapChain8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DSwapChain8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DSwapChain8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) +#define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) +#else +#define IDirect3DSwapChain8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DSwapChain8_AddRef(p) (p)->AddRef() +#define IDirect3DSwapChain8_Release(p) (p)->Release() +#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) +#define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DResource8 + +DECLARE_INTERFACE_(IDirect3DResource8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; +}; + +typedef struct IDirect3DResource8 *LPDIRECT3DRESOURCE8, *PDIRECT3DRESOURCE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DResource8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DResource8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DResource8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DResource8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DResource8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DResource8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DResource8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DResource8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DResource8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DResource8_GetType(p) (p)->lpVtbl->GetType(p) +#else +#define IDirect3DResource8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DResource8_AddRef(p) (p)->AddRef() +#define IDirect3DResource8_Release(p) (p)->Release() +#define IDirect3DResource8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DResource8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DResource8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DResource8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DResource8_GetPriority(p) (p)->GetPriority() +#define IDirect3DResource8_PreLoad(p) (p)->PreLoad() +#define IDirect3DResource8_GetType(p) (p)->GetType() +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DBaseTexture8 + +DECLARE_INTERFACE_(IDirect3DBaseTexture8, IDirect3DResource8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; +}; + +typedef struct IDirect3DBaseTexture8 *LPDIRECT3DBASETEXTURE8, *PDIRECT3DBASETEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DBaseTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DBaseTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DBaseTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DBaseTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DBaseTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DBaseTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DBaseTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DBaseTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DBaseTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DBaseTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DBaseTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DBaseTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#else +#define IDirect3DBaseTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DBaseTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DBaseTexture8_Release(p) (p)->Release() +#define IDirect3DBaseTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DBaseTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DBaseTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DBaseTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DBaseTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DBaseTexture8_GetType(p) (p)->GetType() +#define IDirect3DBaseTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DBaseTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DBaseTexture8_GetLevelCount(p) (p)->GetLevelCount() +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DTexture8 + +DECLARE_INTERFACE_(IDirect3DTexture8, IDirect3DBaseTexture8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(GetSurfaceLevel)(THIS_ UINT Level,IDirect3DSurface8** ppSurfaceLevel) PURE; + STDMETHOD(LockRect)(THIS_ UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS_ UINT Level) PURE; + STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pDirtyRect) PURE; +}; + +typedef struct IDirect3DTexture8 *LPDIRECT3DTEXTURE8, *PDIRECT3DTEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DTexture8_GetSurfaceLevel(p,a,b) (p)->lpVtbl->GetSurfaceLevel(p,a,b) +#define IDirect3DTexture8_LockRect(p,a,b,c,d) (p)->lpVtbl->LockRect(p,a,b,c,d) +#define IDirect3DTexture8_UnlockRect(p,a) (p)->lpVtbl->UnlockRect(p,a) +#define IDirect3DTexture8_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a) +#else +#define IDirect3DTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DTexture8_Release(p) (p)->Release() +#define IDirect3DTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DTexture8_GetType(p) (p)->GetType() +#define IDirect3DTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DTexture8_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DTexture8_GetSurfaceLevel(p,a,b) (p)->GetSurfaceLevel(a,b) +#define IDirect3DTexture8_LockRect(p,a,b,c,d) (p)->LockRect(a,b,c,d) +#define IDirect3DTexture8_UnlockRect(p,a) (p)->UnlockRect(a) +#define IDirect3DTexture8_AddDirtyRect(p,a) (p)->AddDirtyRect(a) +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVolumeTexture8 + +DECLARE_INTERFACE_(IDirect3DVolumeTexture8, IDirect3DBaseTexture8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DVOLUME_DESC *pDesc) PURE; + STDMETHOD(GetVolumeLevel)(THIS_ UINT Level,IDirect3DVolume8** ppVolumeLevel) PURE; + STDMETHOD(LockBox)(THIS_ UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; + STDMETHOD(UnlockBox)(THIS_ UINT Level) PURE; + STDMETHOD(AddDirtyBox)(THIS_ CONST D3DBOX* pDirtyBox) PURE; +}; + +typedef struct IDirect3DVolumeTexture8 *LPDIRECT3DVOLUMETEXTURE8, *PDIRECT3DVOLUMETEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVolumeTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVolumeTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVolumeTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVolumeTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVolumeTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVolumeTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DVolumeTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DVolumeTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DVolumeTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DVolumeTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DVolumeTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DVolumeTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DVolumeTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DVolumeTexture8_GetVolumeLevel(p,a,b) (p)->lpVtbl->GetVolumeLevel(p,a,b) +#define IDirect3DVolumeTexture8_LockBox(p,a,b,c,d) (p)->lpVtbl->LockBox(p,a,b,c,d) +#define IDirect3DVolumeTexture8_UnlockBox(p,a) (p)->lpVtbl->UnlockBox(p,a) +#define IDirect3DVolumeTexture8_AddDirtyBox(p,a) (p)->lpVtbl->AddDirtyBox(p,a) +#else +#define IDirect3DVolumeTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVolumeTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DVolumeTexture8_Release(p) (p)->Release() +#define IDirect3DVolumeTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVolumeTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVolumeTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DVolumeTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DVolumeTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DVolumeTexture8_GetType(p) (p)->GetType() +#define IDirect3DVolumeTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DVolumeTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DVolumeTexture8_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DVolumeTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DVolumeTexture8_GetVolumeLevel(p,a,b) (p)->GetVolumeLevel(a,b) +#define IDirect3DVolumeTexture8_LockBox(p,a,b,c,d) (p)->LockBox(a,b,c,d) +#define IDirect3DVolumeTexture8_UnlockBox(p,a) (p)->UnlockBox(a) +#define IDirect3DVolumeTexture8_AddDirtyBox(p,a) (p)->AddDirtyBox(a) +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DCubeTexture8 + +DECLARE_INTERFACE_(IDirect3DCubeTexture8, IDirect3DBaseTexture8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(GetCubeMapSurface)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface8** ppCubeMapSurface) PURE; + STDMETHOD(LockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level) PURE; + STDMETHOD(AddDirtyRect)(THIS_ D3DCUBEMAP_FACES FaceType,CONST RECT* pDirtyRect) PURE; +}; + +typedef struct IDirect3DCubeTexture8 *LPDIRECT3DCUBETEXTURE8, *PDIRECT3DCUBETEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DCubeTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DCubeTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DCubeTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DCubeTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DCubeTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DCubeTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DCubeTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DCubeTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DCubeTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DCubeTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DCubeTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DCubeTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DCubeTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DCubeTexture8_GetCubeMapSurface(p,a,b,c) (p)->lpVtbl->GetCubeMapSurface(p,a,b,c) +#define IDirect3DCubeTexture8_LockRect(p,a,b,c,d,e) (p)->lpVtbl->LockRect(p,a,b,c,d,e) +#define IDirect3DCubeTexture8_UnlockRect(p,a,b) (p)->lpVtbl->UnlockRect(p,a,b) +#define IDirect3DCubeTexture8_AddDirtyRect(p,a,b) (p)->lpVtbl->AddDirtyRect(p,a,b) +#else +#define IDirect3DCubeTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DCubeTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DCubeTexture8_Release(p) (p)->Release() +#define IDirect3DCubeTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DCubeTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DCubeTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DCubeTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DCubeTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DCubeTexture8_GetType(p) (p)->GetType() +#define IDirect3DCubeTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DCubeTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DCubeTexture8_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DCubeTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DCubeTexture8_GetCubeMapSurface(p,a,b,c) (p)->GetCubeMapSurface(a,b,c) +#define IDirect3DCubeTexture8_LockRect(p,a,b,c,d,e) (p)->LockRect(a,b,c,d,e) +#define IDirect3DCubeTexture8_UnlockRect(p,a,b) (p)->UnlockRect(a,b) +#define IDirect3DCubeTexture8_AddDirtyRect(p,a,b) (p)->AddDirtyRect(a,b) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVertexBuffer8 + +DECLARE_INTERFACE_(IDirect3DVertexBuffer8, IDirect3DResource8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,BYTE** ppbData,DWORD Flags) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3DVERTEXBUFFER_DESC *pDesc) PURE; +}; + +typedef struct IDirect3DVertexBuffer8 *LPDIRECT3DVERTEXBUFFER8, *PDIRECT3DVERTEXBUFFER8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVertexBuffer8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVertexBuffer8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVertexBuffer8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVertexBuffer8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVertexBuffer8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DVertexBuffer8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DVertexBuffer8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DVertexBuffer8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirect3DVertexBuffer8_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DVertexBuffer8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#else +#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVertexBuffer8_AddRef(p) (p)->AddRef() +#define IDirect3DVertexBuffer8_Release(p) (p)->Release() +#define IDirect3DVertexBuffer8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVertexBuffer8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVertexBuffer8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DVertexBuffer8_GetPriority(p) (p)->GetPriority() +#define IDirect3DVertexBuffer8_PreLoad(p) (p)->PreLoad() +#define IDirect3DVertexBuffer8_GetType(p) (p)->GetType() +#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirect3DVertexBuffer8_Unlock(p) (p)->Unlock() +#define IDirect3DVertexBuffer8_GetDesc(p,a) (p)->GetDesc(a) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DIndexBuffer8 + +DECLARE_INTERFACE_(IDirect3DIndexBuffer8, IDirect3DResource8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,BYTE** ppbData,DWORD Flags) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3DINDEXBUFFER_DESC *pDesc) PURE; +}; + +typedef struct IDirect3DIndexBuffer8 *LPDIRECT3DINDEXBUFFER8, *PDIRECT3DINDEXBUFFER8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DIndexBuffer8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DIndexBuffer8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DIndexBuffer8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DIndexBuffer8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DIndexBuffer8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DIndexBuffer8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DIndexBuffer8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DIndexBuffer8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DIndexBuffer8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirect3DIndexBuffer8_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DIndexBuffer8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#else +#define IDirect3DIndexBuffer8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DIndexBuffer8_AddRef(p) (p)->AddRef() +#define IDirect3DIndexBuffer8_Release(p) (p)->Release() +#define IDirect3DIndexBuffer8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DIndexBuffer8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DIndexBuffer8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DIndexBuffer8_GetPriority(p) (p)->GetPriority() +#define IDirect3DIndexBuffer8_PreLoad(p) (p)->PreLoad() +#define IDirect3DIndexBuffer8_GetType(p) (p)->GetType() +#define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirect3DIndexBuffer8_Unlock(p) (p)->Unlock() +#define IDirect3DIndexBuffer8_GetDesc(p,a) (p)->GetDesc(a) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DSurface8 + +DECLARE_INTERFACE_(IDirect3DSurface8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DSurface8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; + STDMETHOD(GetDesc)(THIS_ D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(LockRect)(THIS_ D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS) PURE; +}; + +typedef struct IDirect3DSurface8 *LPDIRECT3DSURFACE8, *PDIRECT3DSURFACE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DSurface8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DSurface8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DSurface8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DSurface8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DSurface8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DSurface8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DSurface8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DSurface8_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) +#define IDirect3DSurface8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#define IDirect3DSurface8_LockRect(p,a,b,c) (p)->lpVtbl->LockRect(p,a,b,c) +#define IDirect3DSurface8_UnlockRect(p) (p)->lpVtbl->UnlockRect(p) +#else +#define IDirect3DSurface8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DSurface8_AddRef(p) (p)->AddRef() +#define IDirect3DSurface8_Release(p) (p)->Release() +#define IDirect3DSurface8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DSurface8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DSurface8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DSurface8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DSurface8_GetContainer(p,a,b) (p)->GetContainer(a,b) +#define IDirect3DSurface8_GetDesc(p,a) (p)->GetDesc(a) +#define IDirect3DSurface8_LockRect(p,a,b,c) (p)->LockRect(a,b,c) +#define IDirect3DSurface8_UnlockRect(p) (p)->UnlockRect() +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVolume8 + +DECLARE_INTERFACE_(IDirect3DVolume8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DVolume8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; + STDMETHOD(GetDesc)(THIS_ D3DVOLUME_DESC *pDesc) PURE; + STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; + STDMETHOD(UnlockBox)(THIS) PURE; +}; + +typedef struct IDirect3DVolume8 *LPDIRECT3DVOLUME8, *PDIRECT3DVOLUME8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVolume8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVolume8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVolume8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVolume8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVolume8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVolume8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVolume8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVolume8_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) +#define IDirect3DVolume8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#define IDirect3DVolume8_LockBox(p,a,b,c) (p)->lpVtbl->LockBox(p,a,b,c) +#define IDirect3DVolume8_UnlockBox(p) (p)->lpVtbl->UnlockBox(p) +#else +#define IDirect3DVolume8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVolume8_AddRef(p) (p)->AddRef() +#define IDirect3DVolume8_Release(p) (p)->Release() +#define IDirect3DVolume8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVolume8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVolume8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVolume8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVolume8_GetContainer(p,a,b) (p)->GetContainer(a,b) +#define IDirect3DVolume8_GetDesc(p,a) (p)->GetDesc(a) +#define IDirect3DVolume8_LockBox(p,a,b,c) (p)->LockBox(a,b,c) +#define IDirect3DVolume8_UnlockBox(p) (p)->UnlockBox() +#endif + +/**************************************************************************** + * Flags for SetPrivateData method on all D3D8 interfaces + * + * The passed pointer is an IUnknown ptr. The SizeOfData argument to SetPrivateData + * must be set to sizeof(IUnknown*). Direct3D will call AddRef through this + * pointer and Release when the private data is destroyed. The data will be + * destroyed when another SetPrivateData with the same GUID is set, when + * FreePrivateData is called, or when the D3D8 object is freed. + ****************************************************************************/ +#define D3DSPD_IUNKNOWN 0x00000001L + +/**************************************************************************** + * + * Parameter for IDirect3D8 Enum and GetCaps8 functions to get the info for + * the current mode only. + * + ****************************************************************************/ + +#define D3DCURRENT_DISPLAY_MODE 0x00EFFFFFL + +/**************************************************************************** + * + * Flags for IDirect3D8::CreateDevice's BehaviorFlags + * + ****************************************************************************/ + +#define D3DCREATE_FPU_PRESERVE 0x00000002L +#define D3DCREATE_MULTITHREADED 0x00000004L + +#define D3DCREATE_PUREDEVICE 0x00000010L +#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020L +#define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040L +#define D3DCREATE_MIXED_VERTEXPROCESSING 0x00000080L + +#define D3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100L + + +/**************************************************************************** + * + * Parameter for IDirect3D8::CreateDevice's iAdapter + * + ****************************************************************************/ + +#define D3DADAPTER_DEFAULT 0 + +/**************************************************************************** + * + * Flags for IDirect3D8::EnumAdapters + * + ****************************************************************************/ + +#define D3DENUM_NO_WHQL_LEVEL 0x00000002L + +/**************************************************************************** + * + * Maximum number of back-buffers supported in DX8 + * + ****************************************************************************/ + +#define D3DPRESENT_BACK_BUFFERS_MAX 3L + +/**************************************************************************** + * + * Flags for IDirect3DDevice8::SetGammaRamp + * + ****************************************************************************/ + +#define D3DSGR_NO_CALIBRATION 0x00000000L +#define D3DSGR_CALIBRATE 0x00000001L + +/**************************************************************************** + * + * Flags for IDirect3DDevice8::SetCursorPosition + * + ****************************************************************************/ + +#define D3DCURSOR_IMMEDIATE_UPDATE 0x00000001L + +/**************************************************************************** + * + * Flags for DrawPrimitive/DrawIndexedPrimitive + * Also valid for Begin/BeginIndexed + * Also valid for VertexBuffer::CreateVertexBuffer + ****************************************************************************/ + + +/* + * DirectDraw error codes + */ +#define _FACD3D 0x876 +#define MAKE_D3DHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code ) + +/* + * Direct3D Errors + */ +#define D3D_OK S_OK + +#define D3DERR_WRONGTEXTUREFORMAT MAKE_D3DHRESULT(2072) +#define D3DERR_UNSUPPORTEDCOLOROPERATION MAKE_D3DHRESULT(2073) +#define D3DERR_UNSUPPORTEDCOLORARG MAKE_D3DHRESULT(2074) +#define D3DERR_UNSUPPORTEDALPHAOPERATION MAKE_D3DHRESULT(2075) +#define D3DERR_UNSUPPORTEDALPHAARG MAKE_D3DHRESULT(2076) +#define D3DERR_TOOMANYOPERATIONS MAKE_D3DHRESULT(2077) +#define D3DERR_CONFLICTINGTEXTUREFILTER MAKE_D3DHRESULT(2078) +#define D3DERR_UNSUPPORTEDFACTORVALUE MAKE_D3DHRESULT(2079) +#define D3DERR_CONFLICTINGRENDERSTATE MAKE_D3DHRESULT(2081) +#define D3DERR_UNSUPPORTEDTEXTUREFILTER MAKE_D3DHRESULT(2082) +#define D3DERR_CONFLICTINGTEXTUREPALETTE MAKE_D3DHRESULT(2086) +#define D3DERR_DRIVERINTERNALERROR MAKE_D3DHRESULT(2087) + +#define D3DERR_NOTFOUND MAKE_D3DHRESULT(2150) +#define D3DERR_MOREDATA MAKE_D3DHRESULT(2151) +#define D3DERR_DEVICELOST MAKE_D3DHRESULT(2152) +#define D3DERR_DEVICENOTRESET MAKE_D3DHRESULT(2153) +#define D3DERR_NOTAVAILABLE MAKE_D3DHRESULT(2154) +#define D3DERR_OUTOFVIDEOMEMORY MAKE_D3DHRESULT(380) +#define D3DERR_INVALIDDEVICE MAKE_D3DHRESULT(2155) +#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156) +#define D3DERR_DRIVERINVALIDCALL MAKE_D3DHRESULT(2157) + +#ifdef __cplusplus +}; +#endif + +#endif /* (DIRECT3D_VERSION >= 0x0800) */ +#endif /* _D3D_H_ */ + diff --git a/src/dep/include/DXSDK/include/d3d8caps.h b/src/dep/include/DXSDK/include/d3d8caps.h index 6a7dc11..6af8e6c 100644 --- a/src/dep/include/DXSDK/include/d3d8caps.h +++ b/src/dep/include/DXSDK/include/d3d8caps.h @@ -1,364 +1,364 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: d3d8caps.h - * Content: Direct3D capabilities include file - * - ***************************************************************************/ - -#ifndef _D3D8CAPS_H -#define _D3D8CAPS_H - -#ifndef DIRECT3D_VERSION -#define DIRECT3D_VERSION 0x0800 -#endif //DIRECT3D_VERSION - -// include this file content only if compiling for DX8 interfaces -#if(DIRECT3D_VERSION >= 0x0800) - -#if defined(_X86_) || defined(_IA64_) -#pragma pack(4) -#endif - -typedef struct _D3DCAPS8 -{ - /* Device Info */ - D3DDEVTYPE DeviceType; - UINT AdapterOrdinal; - - /* Caps from DX7 Draw */ - DWORD Caps; - DWORD Caps2; - DWORD Caps3; - DWORD PresentationIntervals; - - /* Cursor Caps */ - DWORD CursorCaps; - - /* 3D Device Caps */ - DWORD DevCaps; - - DWORD PrimitiveMiscCaps; - DWORD RasterCaps; - DWORD ZCmpCaps; - DWORD SrcBlendCaps; - DWORD DestBlendCaps; - DWORD AlphaCmpCaps; - DWORD ShadeCaps; - DWORD TextureCaps; - DWORD TextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture8's - DWORD CubeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DCubeTexture8's - DWORD VolumeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DVolumeTexture8's - DWORD TextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DTexture8's - DWORD VolumeTextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DVolumeTexture8's - - DWORD LineCaps; // D3DLINECAPS - - DWORD MaxTextureWidth, MaxTextureHeight; - DWORD MaxVolumeExtent; - - DWORD MaxTextureRepeat; - DWORD MaxTextureAspectRatio; - DWORD MaxAnisotropy; - float MaxVertexW; - - float GuardBandLeft; - float GuardBandTop; - float GuardBandRight; - float GuardBandBottom; - - float ExtentsAdjust; - DWORD StencilCaps; - - DWORD FVFCaps; - DWORD TextureOpCaps; - DWORD MaxTextureBlendStages; - DWORD MaxSimultaneousTextures; - - DWORD VertexProcessingCaps; - DWORD MaxActiveLights; - DWORD MaxUserClipPlanes; - DWORD MaxVertexBlendMatrices; - DWORD MaxVertexBlendMatrixIndex; - - float MaxPointSize; - - DWORD MaxPrimitiveCount; // max number of primitives per DrawPrimitive call - DWORD MaxVertexIndex; - DWORD MaxStreams; - DWORD MaxStreamStride; // max stride for SetStreamSource - - DWORD VertexShaderVersion; - DWORD MaxVertexShaderConst; // number of vertex shader constant registers - - DWORD PixelShaderVersion; - float MaxPixelShaderValue; // max value of pixel shader arithmetic component - -} D3DCAPS8; - -// -// BIT DEFINES FOR D3DCAPS8 DWORD MEMBERS -// - -// -// Caps -// -#define D3DCAPS_READ_SCANLINE 0x00020000L - -// -// Caps2 -// -#define D3DCAPS2_NO2DDURING3DSCENE 0x00000002L -#define D3DCAPS2_FULLSCREENGAMMA 0x00020000L -#define D3DCAPS2_CANRENDERWINDOWED 0x00080000L -#define D3DCAPS2_CANCALIBRATEGAMMA 0x00100000L -#define D3DCAPS2_RESERVED 0x02000000L -#define D3DCAPS2_CANMANAGERESOURCE 0x10000000L -#define D3DCAPS2_DYNAMICTEXTURES 0x20000000L - -// -// Caps3 -// -#define D3DCAPS3_RESERVED 0x8000001fL - -// Indicates that the device can respect the ALPHABLENDENABLE render state -// when fullscreen while using the FLIP or DISCARD swap effect. -// COPY and COPYVSYNC swap effects work whether or not this flag is set. -#define D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020L - -// -// PresentationIntervals -// -#define D3DPRESENT_INTERVAL_DEFAULT 0x00000000L -#define D3DPRESENT_INTERVAL_ONE 0x00000001L -#define D3DPRESENT_INTERVAL_TWO 0x00000002L -#define D3DPRESENT_INTERVAL_THREE 0x00000004L -#define D3DPRESENT_INTERVAL_FOUR 0x00000008L -#define D3DPRESENT_INTERVAL_IMMEDIATE 0x80000000L - -// -// CursorCaps -// -// Driver supports HW color cursor in at least hi-res modes(height >=400) -#define D3DCURSORCAPS_COLOR 0x00000001L -// Driver supports HW cursor also in low-res modes(height < 400) -#define D3DCURSORCAPS_LOWRES 0x00000002L - -// -// DevCaps -// -#define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010L /* Device can use execute buffers from system memory */ -#define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020L /* Device can use execute buffers from video 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_DRAWPRIMITIVES2 0x00002000L /* Device can support DrawPrimitives2 */ -#define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000L /* Device is texturing from separate memory pools */ -#define D3DDEVCAPS_DRAWPRIMITIVES2EX 0x00008000L /* Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver*/ -#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_RTPATCHES 0x00400000L /* Device supports Rect and Tri patches */ -#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_LINEPATTERNREP 0x00000004L -#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 */ - -// -// LineCaps -// -#define D3DLINECAPS_TEXTURE 0x00000001L -#define D3DLINECAPS_ZTEST 0x00000002L -#define D3DLINECAPS_BLEND 0x00000004L -#define D3DLINECAPS_ALPHACMP 0x00000008L -#define D3DLINECAPS_FOG 0x00000010L - -// -// RasterCaps -// -#define D3DPRASTERCAPS_DITHER 0x00000001L -#define D3DPRASTERCAPS_PAT 0x00000008L -#define D3DPRASTERCAPS_ZTEST 0x00000010L -#define D3DPRASTERCAPS_FOGVERTEX 0x00000080L -#define D3DPRASTERCAPS_FOGTABLE 0x00000100L -#define D3DPRASTERCAPS_ANTIALIASEDGES 0x00001000L -#define D3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000L -#define D3DPRASTERCAPS_ZBIAS 0x00004000L -#define D3DPRASTERCAPS_ZBUFFERLESSHSR 0x00008000L -#define D3DPRASTERCAPS_FOGRANGE 0x00010000L -#define D3DPRASTERCAPS_ANISOTROPY 0x00020000L -#define D3DPRASTERCAPS_WBUFFER 0x00040000L -#define D3DPRASTERCAPS_WFOG 0x00100000L -#define D3DPRASTERCAPS_ZFOG 0x00200000L -#define D3DPRASTERCAPS_COLORPERSPECTIVE 0x00400000L /* Device iterates colors perspective correct */ -#define D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE 0x00800000L - -// -// ZCmpCaps, AlphaCmpCaps -// -#define D3DPCMPCAPS_NEVER 0x00000001L -#define D3DPCMPCAPS_LESS 0x00000002L -#define D3DPCMPCAPS_EQUAL 0x00000004L -#define D3DPCMPCAPS_LESSEQUAL 0x00000008L -#define D3DPCMPCAPS_GREATER 0x00000010L -#define D3DPCMPCAPS_NOTEQUAL 0x00000020L -#define D3DPCMPCAPS_GREATEREQUAL 0x00000040L -#define D3DPCMPCAPS_ALWAYS 0x00000080L - -// -// SourceBlendCaps, DestBlendCaps -// -#define D3DPBLENDCAPS_ZERO 0x00000001L -#define D3DPBLENDCAPS_ONE 0x00000002L -#define D3DPBLENDCAPS_SRCCOLOR 0x00000004L -#define D3DPBLENDCAPS_INVSRCCOLOR 0x00000008L -#define D3DPBLENDCAPS_SRCALPHA 0x00000010L -#define D3DPBLENDCAPS_INVSRCALPHA 0x00000020L -#define D3DPBLENDCAPS_DESTALPHA 0x00000040L -#define D3DPBLENDCAPS_INVDESTALPHA 0x00000080L -#define D3DPBLENDCAPS_DESTCOLOR 0x00000100L -#define D3DPBLENDCAPS_INVDESTCOLOR 0x00000200L -#define D3DPBLENDCAPS_SRCALPHASAT 0x00000400L -#define D3DPBLENDCAPS_BOTHSRCALPHA 0x00000800L -#define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000L - -// -// ShadeCaps -// -#define D3DPSHADECAPS_COLORGOURAUDRGB 0x00000008L -#define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200L -#define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000L -#define D3DPSHADECAPS_FOGGOURAUD 0x00080000L - -// -// TextureCaps -// -#define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001L /* Perspective-correct texturing is supported */ -#define D3DPTEXTURECAPS_POW2 0x00000002L /* Power-of-2 texture dimensions are required - applies to non-Cube/Volume textures only. */ -#define D3DPTEXTURECAPS_ALPHA 0x00000004L /* Alpha in texture pixels is supported */ -#define D3DPTEXTURECAPS_SQUAREONLY 0x00000020L /* Only square textures are supported */ -#define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040L /* Texture indices are not scaled by the texture size prior to interpolation */ -#define D3DPTEXTURECAPS_ALPHAPALETTE 0x00000080L /* Device can draw alpha from texture palettes */ -// Device can use non-POW2 textures if: -// 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage -// 2) D3DRS_WRAP(N) is zero for this texture's coordinates -// 3) mip mapping is not enabled (use magnification filter only) -#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100L -#define D3DPTEXTURECAPS_PROJECTED 0x00000400L /* Device can do D3DTTFF_PROJECTED */ -#define D3DPTEXTURECAPS_CUBEMAP 0x00000800L /* Device can do cubemap textures */ -#define D3DPTEXTURECAPS_VOLUMEMAP 0x00002000L /* Device can do volume textures */ -#define D3DPTEXTURECAPS_MIPMAP 0x00004000L /* Device can do mipmapped textures */ -#define D3DPTEXTURECAPS_MIPVOLUMEMAP 0x00008000L /* Device can do mipmapped volume textures */ -#define D3DPTEXTURECAPS_MIPCUBEMAP 0x00010000L /* Device can do mipmapped cube maps */ -#define D3DPTEXTURECAPS_CUBEMAP_POW2 0x00020000L /* Device requires that cubemaps be power-of-2 dimension */ -#define D3DPTEXTURECAPS_VOLUMEMAP_POW2 0x00040000L /* Device requires that volume maps be power-of-2 dimension */ - -// -// TextureFilterCaps -// -#define D3DPTFILTERCAPS_MINFPOINT 0x00000100L /* Min Filter */ -#define D3DPTFILTERCAPS_MINFLINEAR 0x00000200L -#define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400L -#define D3DPTFILTERCAPS_MIPFPOINT 0x00010000L /* Mip Filter */ -#define D3DPTFILTERCAPS_MIPFLINEAR 0x00020000L -#define D3DPTFILTERCAPS_MAGFPOINT 0x01000000L /* Mag Filter */ -#define D3DPTFILTERCAPS_MAGFLINEAR 0x02000000L -#define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000L -#define D3DPTFILTERCAPS_MAGFAFLATCUBIC 0x08000000L -#define D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC 0x10000000L - -// -// TextureAddressCaps -// -#define D3DPTADDRESSCAPS_WRAP 0x00000001L -#define D3DPTADDRESSCAPS_MIRROR 0x00000002L -#define D3DPTADDRESSCAPS_CLAMP 0x00000004L -#define D3DPTADDRESSCAPS_BORDER 0x00000008L -#define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010L -#define D3DPTADDRESSCAPS_MIRRORONCE 0x00000020L - -// -// StencilCaps -// -#define D3DSTENCILCAPS_KEEP 0x00000001L -#define D3DSTENCILCAPS_ZERO 0x00000002L -#define D3DSTENCILCAPS_REPLACE 0x00000004L -#define D3DSTENCILCAPS_INCRSAT 0x00000008L -#define D3DSTENCILCAPS_DECRSAT 0x00000010L -#define D3DSTENCILCAPS_INVERT 0x00000020L -#define D3DSTENCILCAPS_INCR 0x00000040L -#define D3DSTENCILCAPS_DECR 0x00000080L - -// -// TextureOpCaps -// -#define D3DTEXOPCAPS_DISABLE 0x00000001L -#define D3DTEXOPCAPS_SELECTARG1 0x00000002L -#define D3DTEXOPCAPS_SELECTARG2 0x00000004L -#define D3DTEXOPCAPS_MODULATE 0x00000008L -#define D3DTEXOPCAPS_MODULATE2X 0x00000010L -#define D3DTEXOPCAPS_MODULATE4X 0x00000020L -#define D3DTEXOPCAPS_ADD 0x00000040L -#define D3DTEXOPCAPS_ADDSIGNED 0x00000080L -#define D3DTEXOPCAPS_ADDSIGNED2X 0x00000100L -#define D3DTEXOPCAPS_SUBTRACT 0x00000200L -#define D3DTEXOPCAPS_ADDSMOOTH 0x00000400L -#define D3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x00000800L -#define D3DTEXOPCAPS_BLENDTEXTUREALPHA 0x00001000L -#define D3DTEXOPCAPS_BLENDFACTORALPHA 0x00002000L -#define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x00004000L -#define D3DTEXOPCAPS_BLENDCURRENTALPHA 0x00008000L -#define D3DTEXOPCAPS_PREMODULATE 0x00010000L -#define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x00020000L -#define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x00040000L -#define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x00080000L -#define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x00100000L -#define D3DTEXOPCAPS_BUMPENVMAP 0x00200000L -#define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x00400000L -#define D3DTEXOPCAPS_DOTPRODUCT3 0x00800000L -#define D3DTEXOPCAPS_MULTIPLYADD 0x01000000L -#define D3DTEXOPCAPS_LERP 0x02000000L - -// -// FVFCaps -// -#define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000ffffL /* mask for texture coordinate count field */ -#define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000L /* Device prefers that vertex elements not be stripped */ -#define D3DFVFCAPS_PSIZE 0x00100000L /* Device can receive point size */ - -// -// VertexProcessingCaps -// -#define D3DVTXPCAPS_TEXGEN 0x00000001L /* device can do texgen */ -#define D3DVTXPCAPS_MATERIALSOURCE7 0x00000002L /* device can do DX7-level colormaterialsource ops */ -#define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008L /* device can do directional lights */ -#define D3DVTXPCAPS_POSITIONALLIGHTS 0x00000010L /* device can do positional lights (includes point and spot) */ -#define D3DVTXPCAPS_LOCALVIEWER 0x00000020L /* device can do local viewer */ -#define D3DVTXPCAPS_TWEENING 0x00000040L /* device can do vertex tweening */ -#define D3DVTXPCAPS_NO_VSDT_UBYTE4 0x00000080L /* device does not support D3DVSDT_UBYTE4 */ - -#pragma pack() - -#endif /* (DIRECT3D_VERSION >= 0x0800) */ -#endif /* _D3D8CAPS_H_ */ - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3d8caps.h + * Content: Direct3D capabilities include file + * + ***************************************************************************/ + +#ifndef _D3D8CAPS_H +#define _D3D8CAPS_H + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0800 +#endif //DIRECT3D_VERSION + +// include this file content only if compiling for DX8 interfaces +#if(DIRECT3D_VERSION >= 0x0800) + +#if defined(_X86_) || defined(_IA64_) +#pragma pack(4) +#endif + +typedef struct _D3DCAPS8 +{ + /* Device Info */ + D3DDEVTYPE DeviceType; + UINT AdapterOrdinal; + + /* Caps from DX7 Draw */ + DWORD Caps; + DWORD Caps2; + DWORD Caps3; + DWORD PresentationIntervals; + + /* Cursor Caps */ + DWORD CursorCaps; + + /* 3D Device Caps */ + DWORD DevCaps; + + DWORD PrimitiveMiscCaps; + DWORD RasterCaps; + DWORD ZCmpCaps; + DWORD SrcBlendCaps; + DWORD DestBlendCaps; + DWORD AlphaCmpCaps; + DWORD ShadeCaps; + DWORD TextureCaps; + DWORD TextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture8's + DWORD CubeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DCubeTexture8's + DWORD VolumeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DVolumeTexture8's + DWORD TextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DTexture8's + DWORD VolumeTextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DVolumeTexture8's + + DWORD LineCaps; // D3DLINECAPS + + DWORD MaxTextureWidth, MaxTextureHeight; + DWORD MaxVolumeExtent; + + DWORD MaxTextureRepeat; + DWORD MaxTextureAspectRatio; + DWORD MaxAnisotropy; + float MaxVertexW; + + float GuardBandLeft; + float GuardBandTop; + float GuardBandRight; + float GuardBandBottom; + + float ExtentsAdjust; + DWORD StencilCaps; + + DWORD FVFCaps; + DWORD TextureOpCaps; + DWORD MaxTextureBlendStages; + DWORD MaxSimultaneousTextures; + + DWORD VertexProcessingCaps; + DWORD MaxActiveLights; + DWORD MaxUserClipPlanes; + DWORD MaxVertexBlendMatrices; + DWORD MaxVertexBlendMatrixIndex; + + float MaxPointSize; + + DWORD MaxPrimitiveCount; // max number of primitives per DrawPrimitive call + DWORD MaxVertexIndex; + DWORD MaxStreams; + DWORD MaxStreamStride; // max stride for SetStreamSource + + DWORD VertexShaderVersion; + DWORD MaxVertexShaderConst; // number of vertex shader constant registers + + DWORD PixelShaderVersion; + float MaxPixelShaderValue; // max value of pixel shader arithmetic component + +} D3DCAPS8; + +// +// BIT DEFINES FOR D3DCAPS8 DWORD MEMBERS +// + +// +// Caps +// +#define D3DCAPS_READ_SCANLINE 0x00020000L + +// +// Caps2 +// +#define D3DCAPS2_NO2DDURING3DSCENE 0x00000002L +#define D3DCAPS2_FULLSCREENGAMMA 0x00020000L +#define D3DCAPS2_CANRENDERWINDOWED 0x00080000L +#define D3DCAPS2_CANCALIBRATEGAMMA 0x00100000L +#define D3DCAPS2_RESERVED 0x02000000L +#define D3DCAPS2_CANMANAGERESOURCE 0x10000000L +#define D3DCAPS2_DYNAMICTEXTURES 0x20000000L + +// +// Caps3 +// +#define D3DCAPS3_RESERVED 0x8000001fL + +// Indicates that the device can respect the ALPHABLENDENABLE render state +// when fullscreen while using the FLIP or DISCARD swap effect. +// COPY and COPYVSYNC swap effects work whether or not this flag is set. +#define D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020L + +// +// PresentationIntervals +// +#define D3DPRESENT_INTERVAL_DEFAULT 0x00000000L +#define D3DPRESENT_INTERVAL_ONE 0x00000001L +#define D3DPRESENT_INTERVAL_TWO 0x00000002L +#define D3DPRESENT_INTERVAL_THREE 0x00000004L +#define D3DPRESENT_INTERVAL_FOUR 0x00000008L +#define D3DPRESENT_INTERVAL_IMMEDIATE 0x80000000L + +// +// CursorCaps +// +// Driver supports HW color cursor in at least hi-res modes(height >=400) +#define D3DCURSORCAPS_COLOR 0x00000001L +// Driver supports HW cursor also in low-res modes(height < 400) +#define D3DCURSORCAPS_LOWRES 0x00000002L + +// +// DevCaps +// +#define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010L /* Device can use execute buffers from system memory */ +#define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020L /* Device can use execute buffers from video 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_DRAWPRIMITIVES2 0x00002000L /* Device can support DrawPrimitives2 */ +#define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000L /* Device is texturing from separate memory pools */ +#define D3DDEVCAPS_DRAWPRIMITIVES2EX 0x00008000L /* Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver*/ +#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_RTPATCHES 0x00400000L /* Device supports Rect and Tri patches */ +#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_LINEPATTERNREP 0x00000004L +#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 */ + +// +// LineCaps +// +#define D3DLINECAPS_TEXTURE 0x00000001L +#define D3DLINECAPS_ZTEST 0x00000002L +#define D3DLINECAPS_BLEND 0x00000004L +#define D3DLINECAPS_ALPHACMP 0x00000008L +#define D3DLINECAPS_FOG 0x00000010L + +// +// RasterCaps +// +#define D3DPRASTERCAPS_DITHER 0x00000001L +#define D3DPRASTERCAPS_PAT 0x00000008L +#define D3DPRASTERCAPS_ZTEST 0x00000010L +#define D3DPRASTERCAPS_FOGVERTEX 0x00000080L +#define D3DPRASTERCAPS_FOGTABLE 0x00000100L +#define D3DPRASTERCAPS_ANTIALIASEDGES 0x00001000L +#define D3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000L +#define D3DPRASTERCAPS_ZBIAS 0x00004000L +#define D3DPRASTERCAPS_ZBUFFERLESSHSR 0x00008000L +#define D3DPRASTERCAPS_FOGRANGE 0x00010000L +#define D3DPRASTERCAPS_ANISOTROPY 0x00020000L +#define D3DPRASTERCAPS_WBUFFER 0x00040000L +#define D3DPRASTERCAPS_WFOG 0x00100000L +#define D3DPRASTERCAPS_ZFOG 0x00200000L +#define D3DPRASTERCAPS_COLORPERSPECTIVE 0x00400000L /* Device iterates colors perspective correct */ +#define D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE 0x00800000L + +// +// ZCmpCaps, AlphaCmpCaps +// +#define D3DPCMPCAPS_NEVER 0x00000001L +#define D3DPCMPCAPS_LESS 0x00000002L +#define D3DPCMPCAPS_EQUAL 0x00000004L +#define D3DPCMPCAPS_LESSEQUAL 0x00000008L +#define D3DPCMPCAPS_GREATER 0x00000010L +#define D3DPCMPCAPS_NOTEQUAL 0x00000020L +#define D3DPCMPCAPS_GREATEREQUAL 0x00000040L +#define D3DPCMPCAPS_ALWAYS 0x00000080L + +// +// SourceBlendCaps, DestBlendCaps +// +#define D3DPBLENDCAPS_ZERO 0x00000001L +#define D3DPBLENDCAPS_ONE 0x00000002L +#define D3DPBLENDCAPS_SRCCOLOR 0x00000004L +#define D3DPBLENDCAPS_INVSRCCOLOR 0x00000008L +#define D3DPBLENDCAPS_SRCALPHA 0x00000010L +#define D3DPBLENDCAPS_INVSRCALPHA 0x00000020L +#define D3DPBLENDCAPS_DESTALPHA 0x00000040L +#define D3DPBLENDCAPS_INVDESTALPHA 0x00000080L +#define D3DPBLENDCAPS_DESTCOLOR 0x00000100L +#define D3DPBLENDCAPS_INVDESTCOLOR 0x00000200L +#define D3DPBLENDCAPS_SRCALPHASAT 0x00000400L +#define D3DPBLENDCAPS_BOTHSRCALPHA 0x00000800L +#define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000L + +// +// ShadeCaps +// +#define D3DPSHADECAPS_COLORGOURAUDRGB 0x00000008L +#define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200L +#define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000L +#define D3DPSHADECAPS_FOGGOURAUD 0x00080000L + +// +// TextureCaps +// +#define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001L /* Perspective-correct texturing is supported */ +#define D3DPTEXTURECAPS_POW2 0x00000002L /* Power-of-2 texture dimensions are required - applies to non-Cube/Volume textures only. */ +#define D3DPTEXTURECAPS_ALPHA 0x00000004L /* Alpha in texture pixels is supported */ +#define D3DPTEXTURECAPS_SQUAREONLY 0x00000020L /* Only square textures are supported */ +#define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040L /* Texture indices are not scaled by the texture size prior to interpolation */ +#define D3DPTEXTURECAPS_ALPHAPALETTE 0x00000080L /* Device can draw alpha from texture palettes */ +// Device can use non-POW2 textures if: +// 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage +// 2) D3DRS_WRAP(N) is zero for this texture's coordinates +// 3) mip mapping is not enabled (use magnification filter only) +#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100L +#define D3DPTEXTURECAPS_PROJECTED 0x00000400L /* Device can do D3DTTFF_PROJECTED */ +#define D3DPTEXTURECAPS_CUBEMAP 0x00000800L /* Device can do cubemap textures */ +#define D3DPTEXTURECAPS_VOLUMEMAP 0x00002000L /* Device can do volume textures */ +#define D3DPTEXTURECAPS_MIPMAP 0x00004000L /* Device can do mipmapped textures */ +#define D3DPTEXTURECAPS_MIPVOLUMEMAP 0x00008000L /* Device can do mipmapped volume textures */ +#define D3DPTEXTURECAPS_MIPCUBEMAP 0x00010000L /* Device can do mipmapped cube maps */ +#define D3DPTEXTURECAPS_CUBEMAP_POW2 0x00020000L /* Device requires that cubemaps be power-of-2 dimension */ +#define D3DPTEXTURECAPS_VOLUMEMAP_POW2 0x00040000L /* Device requires that volume maps be power-of-2 dimension */ + +// +// TextureFilterCaps +// +#define D3DPTFILTERCAPS_MINFPOINT 0x00000100L /* Min Filter */ +#define D3DPTFILTERCAPS_MINFLINEAR 0x00000200L +#define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400L +#define D3DPTFILTERCAPS_MIPFPOINT 0x00010000L /* Mip Filter */ +#define D3DPTFILTERCAPS_MIPFLINEAR 0x00020000L +#define D3DPTFILTERCAPS_MAGFPOINT 0x01000000L /* Mag Filter */ +#define D3DPTFILTERCAPS_MAGFLINEAR 0x02000000L +#define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000L +#define D3DPTFILTERCAPS_MAGFAFLATCUBIC 0x08000000L +#define D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC 0x10000000L + +// +// TextureAddressCaps +// +#define D3DPTADDRESSCAPS_WRAP 0x00000001L +#define D3DPTADDRESSCAPS_MIRROR 0x00000002L +#define D3DPTADDRESSCAPS_CLAMP 0x00000004L +#define D3DPTADDRESSCAPS_BORDER 0x00000008L +#define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010L +#define D3DPTADDRESSCAPS_MIRRORONCE 0x00000020L + +// +// StencilCaps +// +#define D3DSTENCILCAPS_KEEP 0x00000001L +#define D3DSTENCILCAPS_ZERO 0x00000002L +#define D3DSTENCILCAPS_REPLACE 0x00000004L +#define D3DSTENCILCAPS_INCRSAT 0x00000008L +#define D3DSTENCILCAPS_DECRSAT 0x00000010L +#define D3DSTENCILCAPS_INVERT 0x00000020L +#define D3DSTENCILCAPS_INCR 0x00000040L +#define D3DSTENCILCAPS_DECR 0x00000080L + +// +// TextureOpCaps +// +#define D3DTEXOPCAPS_DISABLE 0x00000001L +#define D3DTEXOPCAPS_SELECTARG1 0x00000002L +#define D3DTEXOPCAPS_SELECTARG2 0x00000004L +#define D3DTEXOPCAPS_MODULATE 0x00000008L +#define D3DTEXOPCAPS_MODULATE2X 0x00000010L +#define D3DTEXOPCAPS_MODULATE4X 0x00000020L +#define D3DTEXOPCAPS_ADD 0x00000040L +#define D3DTEXOPCAPS_ADDSIGNED 0x00000080L +#define D3DTEXOPCAPS_ADDSIGNED2X 0x00000100L +#define D3DTEXOPCAPS_SUBTRACT 0x00000200L +#define D3DTEXOPCAPS_ADDSMOOTH 0x00000400L +#define D3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x00000800L +#define D3DTEXOPCAPS_BLENDTEXTUREALPHA 0x00001000L +#define D3DTEXOPCAPS_BLENDFACTORALPHA 0x00002000L +#define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x00004000L +#define D3DTEXOPCAPS_BLENDCURRENTALPHA 0x00008000L +#define D3DTEXOPCAPS_PREMODULATE 0x00010000L +#define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x00020000L +#define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x00040000L +#define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x00080000L +#define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x00100000L +#define D3DTEXOPCAPS_BUMPENVMAP 0x00200000L +#define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x00400000L +#define D3DTEXOPCAPS_DOTPRODUCT3 0x00800000L +#define D3DTEXOPCAPS_MULTIPLYADD 0x01000000L +#define D3DTEXOPCAPS_LERP 0x02000000L + +// +// FVFCaps +// +#define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000ffffL /* mask for texture coordinate count field */ +#define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000L /* Device prefers that vertex elements not be stripped */ +#define D3DFVFCAPS_PSIZE 0x00100000L /* Device can receive point size */ + +// +// VertexProcessingCaps +// +#define D3DVTXPCAPS_TEXGEN 0x00000001L /* device can do texgen */ +#define D3DVTXPCAPS_MATERIALSOURCE7 0x00000002L /* device can do DX7-level colormaterialsource ops */ +#define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008L /* device can do directional lights */ +#define D3DVTXPCAPS_POSITIONALLIGHTS 0x00000010L /* device can do positional lights (includes point and spot) */ +#define D3DVTXPCAPS_LOCALVIEWER 0x00000020L /* device can do local viewer */ +#define D3DVTXPCAPS_TWEENING 0x00000040L /* device can do vertex tweening */ +#define D3DVTXPCAPS_NO_VSDT_UBYTE4 0x00000080L /* device does not support D3DVSDT_UBYTE4 */ + +#pragma pack() + +#endif /* (DIRECT3D_VERSION >= 0x0800) */ +#endif /* _D3D8CAPS_H_ */ + diff --git a/src/dep/include/DXSDK/include/d3d8types.h b/src/dep/include/DXSDK/include/d3d8types.h index 0303762..5d622af 100644 --- a/src/dep/include/DXSDK/include/d3d8types.h +++ b/src/dep/include/DXSDK/include/d3d8types.h @@ -1,1684 +1,1684 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: d3d8types.h - * Content: Direct3D capabilities include file - * - ***************************************************************************/ - -#ifndef _D3D8TYPES_H_ -#define _D3D8TYPES_H_ - -#ifndef DIRECT3D_VERSION -#define DIRECT3D_VERSION 0x0800 -#endif //DIRECT3D_VERSION - -// include this file content only if compiling for DX8 interfaces -#if(DIRECT3D_VERSION >= 0x0800) - -#include - -#if _MSC_VER >= 1200 -#pragma warning(push) -#endif -#pragma warning(disable:4201) // anonymous unions warning -#if defined(_X86_) || defined(_IA64_) -#pragma pack(4) -#endif - -// D3DCOLOR is equivalent to D3DFMT_A8R8G8B8 -#ifndef D3DCOLOR_DEFINED -typedef DWORD D3DCOLOR; -#define D3DCOLOR_DEFINED -#endif - -// maps unsigned 8 bits/channel to D3DCOLOR -#define D3DCOLOR_ARGB(a,r,g,b) \ - ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) -#define D3DCOLOR_RGBA(r,g,b,a) D3DCOLOR_ARGB(a,r,g,b) -#define D3DCOLOR_XRGB(r,g,b) D3DCOLOR_ARGB(0xff,r,g,b) - -// maps floating point channels (0.f to 1.f range) to D3DCOLOR -#define D3DCOLOR_COLORVALUE(r,g,b,a) \ - D3DCOLOR_RGBA((DWORD)((r)*255.f),(DWORD)((g)*255.f),(DWORD)((b)*255.f),(DWORD)((a)*255.f)) - - -#ifndef D3DVECTOR_DEFINED -typedef struct _D3DVECTOR { - float x; - float y; - float z; -} D3DVECTOR; -#define D3DVECTOR_DEFINED -#endif - -#ifndef D3DCOLORVALUE_DEFINED -typedef struct _D3DCOLORVALUE { - float r; - float g; - float b; - float a; -} D3DCOLORVALUE; -#define D3DCOLORVALUE_DEFINED -#endif - -#ifndef D3DRECT_DEFINED -typedef struct _D3DRECT { - LONG x1; - LONG y1; - LONG x2; - LONG y2; -} D3DRECT; -#define D3DRECT_DEFINED -#endif - -#ifndef D3DMATRIX_DEFINED -typedef struct _D3DMATRIX { - union { - struct { - float _11, _12, _13, _14; - float _21, _22, _23, _24; - float _31, _32, _33, _34; - float _41, _42, _43, _44; - - }; - float m[4][4]; - }; -} D3DMATRIX; -#define D3DMATRIX_DEFINED -#endif - -typedef struct _D3DVIEWPORT8 { - DWORD X; - DWORD Y; /* Viewport Top left */ - DWORD Width; - DWORD Height; /* Viewport Dimensions */ - float MinZ; /* Min/max of clip Volume */ - float MaxZ; -} D3DVIEWPORT8; - -/* - * Values for clip fields. - */ - -// Max number of user clipping planes, supported in D3D. -#define D3DMAXUSERCLIPPLANES 32 - -// These bits could be ORed together to use with D3DRS_CLIPPLANEENABLE -// -#define D3DCLIPPLANE0 (1 << 0) -#define D3DCLIPPLANE1 (1 << 1) -#define D3DCLIPPLANE2 (1 << 2) -#define D3DCLIPPLANE3 (1 << 3) -#define D3DCLIPPLANE4 (1 << 4) -#define D3DCLIPPLANE5 (1 << 5) - -// The following bits are used in the ClipUnion and ClipIntersection -// members of the D3DCLIPSTATUS8 -// - -#define D3DCS_LEFT 0x00000001L -#define D3DCS_RIGHT 0x00000002L -#define D3DCS_TOP 0x00000004L -#define D3DCS_BOTTOM 0x00000008L -#define D3DCS_FRONT 0x00000010L -#define D3DCS_BACK 0x00000020L -#define D3DCS_PLANE0 0x00000040L -#define D3DCS_PLANE1 0x00000080L -#define D3DCS_PLANE2 0x00000100L -#define D3DCS_PLANE3 0x00000200L -#define D3DCS_PLANE4 0x00000400L -#define D3DCS_PLANE5 0x00000800L - -#define D3DCS_ALL (D3DCS_LEFT | \ - D3DCS_RIGHT | \ - D3DCS_TOP | \ - D3DCS_BOTTOM | \ - D3DCS_FRONT | \ - D3DCS_BACK | \ - D3DCS_PLANE0 | \ - D3DCS_PLANE1 | \ - D3DCS_PLANE2 | \ - D3DCS_PLANE3 | \ - D3DCS_PLANE4 | \ - D3DCS_PLANE5) - -typedef struct _D3DCLIPSTATUS8 { - DWORD ClipUnion; - DWORD ClipIntersection; -} D3DCLIPSTATUS8; - -typedef struct _D3DMATERIAL8 { - 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 */ -} D3DMATERIAL8; - -typedef enum _D3DLIGHTTYPE { - D3DLIGHT_POINT = 1, - D3DLIGHT_SPOT = 2, - D3DLIGHT_DIRECTIONAL = 3, - D3DLIGHT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DLIGHTTYPE; - -typedef struct _D3DLIGHT8 { - 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 */ -} D3DLIGHT8; - -/* - * 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 */ - -/* - * The following defines the rendering states - */ - -typedef enum _D3DSHADEMODE { - D3DSHADE_FLAT = 1, - D3DSHADE_GOURAUD = 2, - D3DSHADE_PHONG = 3, - D3DSHADE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DSHADEMODE; - -typedef enum _D3DFILLMODE { - D3DFILL_POINT = 1, - D3DFILL_WIREFRAME = 2, - D3DFILL_SOLID = 3, - D3DFILL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DFILLMODE; - -typedef struct _D3DLINEPATTERN { - WORD wRepeatFactor; - WORD wLinePattern; -} D3DLINEPATTERN; - -typedef enum _D3DBLEND { - D3DBLEND_ZERO = 1, - D3DBLEND_ONE = 2, - D3DBLEND_SRCCOLOR = 3, - D3DBLEND_INVSRCCOLOR = 4, - D3DBLEND_SRCALPHA = 5, - D3DBLEND_INVSRCALPHA = 6, - D3DBLEND_DESTALPHA = 7, - D3DBLEND_INVDESTALPHA = 8, - D3DBLEND_DESTCOLOR = 9, - D3DBLEND_INVDESTCOLOR = 10, - D3DBLEND_SRCALPHASAT = 11, - D3DBLEND_BOTHSRCALPHA = 12, - D3DBLEND_BOTHINVSRCALPHA = 13, - D3DBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DBLEND; - -typedef enum _D3DBLENDOP { - D3DBLENDOP_ADD = 1, - D3DBLENDOP_SUBTRACT = 2, - D3DBLENDOP_REVSUBTRACT = 3, - D3DBLENDOP_MIN = 4, - D3DBLENDOP_MAX = 5, - D3DBLENDOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DBLENDOP; - -typedef enum _D3DTEXTUREADDRESS { - D3DTADDRESS_WRAP = 1, - D3DTADDRESS_MIRROR = 2, - D3DTADDRESS_CLAMP = 3, - D3DTADDRESS_BORDER = 4, - D3DTADDRESS_MIRRORONCE = 5, - D3DTADDRESS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DTEXTUREADDRESS; - -typedef enum _D3DCULL { - D3DCULL_NONE = 1, - D3DCULL_CW = 2, - D3DCULL_CCW = 3, - D3DCULL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DCULL; - -typedef enum _D3DCMPFUNC { - D3DCMP_NEVER = 1, - D3DCMP_LESS = 2, - D3DCMP_EQUAL = 3, - D3DCMP_LESSEQUAL = 4, - D3DCMP_GREATER = 5, - D3DCMP_NOTEQUAL = 6, - D3DCMP_GREATEREQUAL = 7, - D3DCMP_ALWAYS = 8, - D3DCMP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DCMPFUNC; - -typedef enum _D3DSTENCILOP { - D3DSTENCILOP_KEEP = 1, - D3DSTENCILOP_ZERO = 2, - D3DSTENCILOP_REPLACE = 3, - D3DSTENCILOP_INCRSAT = 4, - D3DSTENCILOP_DECRSAT = 5, - D3DSTENCILOP_INVERT = 6, - D3DSTENCILOP_INCR = 7, - D3DSTENCILOP_DECR = 8, - D3DSTENCILOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DSTENCILOP; - -typedef enum _D3DFOGMODE { - D3DFOG_NONE = 0, - D3DFOG_EXP = 1, - D3DFOG_EXP2 = 2, - D3DFOG_LINEAR = 3, - D3DFOG_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DFOGMODE; - -typedef enum _D3DZBUFFERTYPE { - D3DZB_FALSE = 0, - D3DZB_TRUE = 1, // Z buffering - D3DZB_USEW = 2, // W buffering - D3DZB_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DZBUFFERTYPE; - -// Primitives supported by draw-primitive API -typedef enum _D3DPRIMITIVETYPE { - D3DPT_POINTLIST = 1, - D3DPT_LINELIST = 2, - D3DPT_LINESTRIP = 3, - D3DPT_TRIANGLELIST = 4, - D3DPT_TRIANGLESTRIP = 5, - D3DPT_TRIANGLEFAN = 6, - D3DPT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DPRIMITIVETYPE; - -typedef enum _D3DTRANSFORMSTATETYPE { - D3DTS_VIEW = 2, - D3DTS_PROJECTION = 3, - D3DTS_TEXTURE0 = 16, - D3DTS_TEXTURE1 = 17, - D3DTS_TEXTURE2 = 18, - D3DTS_TEXTURE3 = 19, - D3DTS_TEXTURE4 = 20, - D3DTS_TEXTURE5 = 21, - D3DTS_TEXTURE6 = 22, - D3DTS_TEXTURE7 = 23, - D3DTS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DTRANSFORMSTATETYPE; - -#define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256) -#define D3DTS_WORLD D3DTS_WORLDMATRIX(0) -#define D3DTS_WORLD1 D3DTS_WORLDMATRIX(1) -#define D3DTS_WORLD2 D3DTS_WORLDMATRIX(2) -#define D3DTS_WORLD3 D3DTS_WORLDMATRIX(3) - -typedef enum _D3DRENDERSTATETYPE { - D3DRS_ZENABLE = 7, /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */ - D3DRS_FILLMODE = 8, /* D3DFILLMODE */ - D3DRS_SHADEMODE = 9, /* D3DSHADEMODE */ - D3DRS_LINEPATTERN = 10, /* D3DLINEPATTERN */ - D3DRS_ZWRITEENABLE = 14, /* TRUE to enable z writes */ - D3DRS_ALPHATESTENABLE = 15, /* TRUE to enable alpha tests */ - D3DRS_LASTPIXEL = 16, /* TRUE for last-pixel on lines */ - D3DRS_SRCBLEND = 19, /* D3DBLEND */ - D3DRS_DESTBLEND = 20, /* D3DBLEND */ - D3DRS_CULLMODE = 22, /* D3DCULL */ - D3DRS_ZFUNC = 23, /* D3DCMPFUNC */ - D3DRS_ALPHAREF = 24, /* D3DFIXED */ - D3DRS_ALPHAFUNC = 25, /* D3DCMPFUNC */ - D3DRS_DITHERENABLE = 26, /* TRUE to enable dithering */ - D3DRS_ALPHABLENDENABLE = 27, /* TRUE to enable alpha blending */ - D3DRS_FOGENABLE = 28, /* TRUE to enable fog blending */ - D3DRS_SPECULARENABLE = 29, /* TRUE to enable specular */ - D3DRS_ZVISIBLE = 30, /* TRUE to enable z checking */ - D3DRS_FOGCOLOR = 34, /* D3DCOLOR */ - D3DRS_FOGTABLEMODE = 35, /* D3DFOGMODE */ - D3DRS_FOGSTART = 36, /* Fog start (for both vertex and pixel fog) */ - D3DRS_FOGEND = 37, /* Fog end */ - D3DRS_FOGDENSITY = 38, /* Fog density */ - D3DRS_EDGEANTIALIAS = 40, /* TRUE to enable edge antialiasing */ - D3DRS_ZBIAS = 47, /* LONG Z bias */ - D3DRS_RANGEFOGENABLE = 48, /* Enables range-based fog */ - D3DRS_STENCILENABLE = 52, /* BOOL enable/disable stenciling */ - D3DRS_STENCILFAIL = 53, /* D3DSTENCILOP to do if stencil test fails */ - D3DRS_STENCILZFAIL = 54, /* D3DSTENCILOP to do if stencil test passes and Z test fails */ - D3DRS_STENCILPASS = 55, /* D3DSTENCILOP to do if both stencil and Z tests pass */ - D3DRS_STENCILFUNC = 56, /* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */ - D3DRS_STENCILREF = 57, /* Reference value used in stencil test */ - D3DRS_STENCILMASK = 58, /* Mask value used in stencil test */ - D3DRS_STENCILWRITEMASK = 59, /* Write mask applied to values written to stencil buffer */ - D3DRS_TEXTUREFACTOR = 60, /* D3DCOLOR used for multi-texture blend */ - D3DRS_WRAP0 = 128, /* wrap for 1st texture coord. set */ - D3DRS_WRAP1 = 129, /* wrap for 2nd texture coord. set */ - D3DRS_WRAP2 = 130, /* wrap for 3rd texture coord. set */ - D3DRS_WRAP3 = 131, /* wrap for 4th texture coord. set */ - D3DRS_WRAP4 = 132, /* wrap for 5th texture coord. set */ - D3DRS_WRAP5 = 133, /* wrap for 6th texture coord. set */ - D3DRS_WRAP6 = 134, /* wrap for 7th texture coord. set */ - D3DRS_WRAP7 = 135, /* wrap for 8th texture coord. set */ - D3DRS_CLIPPING = 136, - D3DRS_LIGHTING = 137, - D3DRS_AMBIENT = 139, - D3DRS_FOGVERTEXMODE = 140, - D3DRS_COLORVERTEX = 141, - D3DRS_LOCALVIEWER = 142, - D3DRS_NORMALIZENORMALS = 143, - D3DRS_DIFFUSEMATERIALSOURCE = 145, - D3DRS_SPECULARMATERIALSOURCE = 146, - D3DRS_AMBIENTMATERIALSOURCE = 147, - D3DRS_EMISSIVEMATERIALSOURCE = 148, - D3DRS_VERTEXBLEND = 151, - D3DRS_CLIPPLANEENABLE = 152, - D3DRS_SOFTWAREVERTEXPROCESSING = 153, - D3DRS_POINTSIZE = 154, /* float point size */ - D3DRS_POINTSIZE_MIN = 155, /* float point size min threshold */ - D3DRS_POINTSPRITEENABLE = 156, /* BOOL point texture coord control */ - D3DRS_POINTSCALEENABLE = 157, /* BOOL point size scale enable */ - D3DRS_POINTSCALE_A = 158, /* float point attenuation A value */ - D3DRS_POINTSCALE_B = 159, /* float point attenuation B value */ - D3DRS_POINTSCALE_C = 160, /* float point attenuation C value */ - D3DRS_MULTISAMPLEANTIALIAS = 161, // BOOL - set to do FSAA with multisample buffer - D3DRS_MULTISAMPLEMASK = 162, // DWORD - per-sample enable/disable - D3DRS_PATCHEDGESTYLE = 163, // Sets whether patch edges will use float style tessellation - D3DRS_PATCHSEGMENTS = 164, // Number of segments per edge when drawing patches - D3DRS_DEBUGMONITORTOKEN = 165, // DEBUG ONLY - token to debug monitor - D3DRS_POINTSIZE_MAX = 166, /* float point size max threshold */ - D3DRS_INDEXEDVERTEXBLENDENABLE = 167, - D3DRS_COLORWRITEENABLE = 168, // per-channel write enable - D3DRS_TWEENFACTOR = 170, // float tween factor - D3DRS_BLENDOP = 171, // D3DBLENDOP setting - D3DRS_POSITIONORDER = 172, // NPatch position interpolation order. D3DORDER_LINEAR or D3DORDER_CUBIC (default) - D3DRS_NORMALORDER = 173, // NPatch normal interpolation order. D3DORDER_LINEAR (default) or D3DORDER_QUADRATIC - - D3DRS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DRENDERSTATETYPE; - -// Values for material source -typedef enum _D3DMATERIALCOLORSOURCE -{ - D3DMCS_MATERIAL = 0, // Color from material is used - D3DMCS_COLOR1 = 1, // Diffuse vertex color is used - D3DMCS_COLOR2 = 2, // Specular vertex color is used - D3DMCS_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum -} D3DMATERIALCOLORSOURCE; - -// Bias to apply to the texture coordinate set to apply a wrap to. -#define D3DRENDERSTATE_WRAPBIAS 128UL - -/* Flags to construct the WRAP render states */ -#define D3DWRAP_U 0x00000001L -#define D3DWRAP_V 0x00000002L -#define D3DWRAP_W 0x00000004L - -/* Flags to construct the WRAP render states for 1D thru 4D texture coordinates */ -#define D3DWRAPCOORD_0 0x00000001L // same as D3DWRAP_U -#define D3DWRAPCOORD_1 0x00000002L // same as D3DWRAP_V -#define D3DWRAPCOORD_2 0x00000004L // same as D3DWRAP_W -#define D3DWRAPCOORD_3 0x00000008L - -/* 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) - -/* - * State enumerants for per-stage texture processing. - */ -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_ADDRESSU = 13, /* D3DTEXTUREADDRESS for U coordinate */ - D3DTSS_ADDRESSV = 14, /* D3DTEXTUREADDRESS for V coordinate */ - D3DTSS_BORDERCOLOR = 15, /* D3DCOLOR */ - D3DTSS_MAGFILTER = 16, /* D3DTEXTUREFILTER filter to use for magnification */ - D3DTSS_MINFILTER = 17, /* D3DTEXTUREFILTER filter to use for minification */ - D3DTSS_MIPFILTER = 18, /* D3DTEXTUREFILTER filter to use between mipmaps during minification */ - D3DTSS_MIPMAPLODBIAS = 19, /* float Mipmap LOD bias */ - D3DTSS_MAXMIPLEVEL = 20, /* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) */ - D3DTSS_MAXANISOTROPY = 21, /* DWORD maximum anisotropy */ - D3DTSS_BUMPENVLSCALE = 22, /* float scale for bump map luminance */ - D3DTSS_BUMPENVLOFFSET = 23, /* float offset for bump map luminance */ - D3DTSS_TEXTURETRANSFORMFLAGS = 24, /* D3DTEXTURETRANSFORMFLAGS controls texture transform */ - D3DTSS_ADDRESSW = 25, /* D3DTEXTUREADDRESS for W coordinate */ - D3DTSS_COLORARG0 = 26, /* D3DTA_* third arg for triadic ops */ - D3DTSS_ALPHAARG0 = 27, /* 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; - -// Values, used with D3DTSS_TEXCOORDINDEX, to specify that the vertex data(position -// and normal in the camera space) should be taken as texture coordinates -// Low 16 bits are used to specify texture coordinate index, to take the WRAP mode from -// -#define D3DTSS_TCI_PASSTHRU 0x00000000 -#define D3DTSS_TCI_CAMERASPACENORMAL 0x00010000 -#define D3DTSS_TCI_CAMERASPACEPOSITION 0x00020000 -#define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR 0x00030000 - -/* - * Enumerations for COLOROP and ALPHAOP texture blending operations set in - * texture processing stage controls in D3DTSS. - */ -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; - -/* - * Values for COLORARG0,1,2, ALPHAARG0,1,2, and RESULTARG texture blending - * operations set in texture processing stage controls in D3DRENDERSTATE. - */ -#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_COMPLEMENT 0x00000010 // take 1.0 - x (read modifier) -#define D3DTA_ALPHAREPLICATE 0x00000020 // replicate alpha to color components (read modifier) - -// -// Values for D3DTSS_***FILTER texture stage states -// -typedef enum _D3DTEXTUREFILTERTYPE -{ - D3DTEXF_NONE = 0, // filtering disabled (valid for mip filter only) - D3DTEXF_POINT = 1, // nearest - D3DTEXF_LINEAR = 2, // linear interpolation - D3DTEXF_ANISOTROPIC = 3, // anisotropic - D3DTEXF_FLATCUBIC = 4, // cubic - D3DTEXF_GAUSSIANCUBIC = 5, // different cubic kernel - D3DTEXF_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum -} D3DTEXTUREFILTERTYPE; - -/* Bits for Flags in ProcessVertices call */ - -#define D3DPV_DONOTCOPYDATA (1 << 0) - -//------------------------------------------------------------------- - -// Flexible vertex format bits -// -#define D3DFVF_RESERVED0 0x001 -#define D3DFVF_POSITION_MASK 0x00E -#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_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_RESERVED2 0xE000 // 4 reserved bits - -//--------------------------------------------------------------------- -// Vertex Shaders -// - -/* - -Vertex Shader Declaration - -The declaration portion of a vertex shader defines the static external -interface of the shader. The information in the declaration includes: - -- Assignments of vertex shader input registers to data streams. These -assignments bind a specific vertex register to a single component within a -vertex stream. A vertex stream element is identified by a byte offset -within the stream and a type. The type specifies the arithmetic data type -plus the dimensionality (1, 2, 3, or 4 values). Stream data which is -less than 4 values are always expanded out to 4 values with zero or more -0.F values and one 1.F value. - -- Assignment of vertex shader input registers to implicit data from the -primitive tessellator. This controls the loading of vertex data which is -not loaded from a stream, but rather is generated during primitive -tessellation prior to the vertex shader. - -- Loading data into the constant memory at the time a shader is set as the -current shader. Each token specifies values for one or more contiguous 4 -DWORD constant registers. This allows the shader to update an arbitrary -subset of the constant memory, overwriting the device state (which -contains the current values of the constant memory). Note that these -values can be subsequently overwritten (between DrawPrimitive calls) -during the time a shader is bound to a device via the -SetVertexShaderConstant method. - - -Declaration arrays are single-dimensional arrays of DWORDs composed of -multiple tokens each of which is one or more DWORDs. The single-DWORD -token value 0xFFFFFFFF is a special token used to indicate the end of the -declaration array. The single DWORD token value 0x00000000 is a NOP token -with is ignored during the declaration parsing. Note that 0x00000000 is a -valid value for DWORDs following the first DWORD for multiple word tokens. - -[31:29] TokenType - 0x0 - NOP (requires all DWORD bits to be zero) - 0x1 - stream selector - 0x2 - stream data definition (map to vertex input memory) - 0x3 - vertex input memory from tessellator - 0x4 - constant memory from shader - 0x5 - extension - 0x6 - reserved - 0x7 - end-of-array (requires all DWORD bits to be 1) - -NOP Token (single DWORD token) - [31:29] 0x0 - [28:00] 0x0 - -Stream Selector (single DWORD token) - [31:29] 0x1 - [28] indicates whether this is a tessellator stream - [27:04] 0x0 - [03:00] stream selector (0..15) - -Stream Data Definition (single DWORD token) - Vertex Input Register Load - [31:29] 0x2 - [28] 0x0 - [27:20] 0x0 - [19:16] type (dimensionality and data type) - [15:04] 0x0 - [03:00] vertex register address (0..15) - Data Skip (no register load) - [31:29] 0x2 - [28] 0x1 - [27:20] 0x0 - [19:16] count of DWORDS to skip over (0..15) - [15:00] 0x0 - Vertex Input Memory from Tessellator Data (single DWORD token) - [31:29] 0x3 - [28] indicates whether data is normals or u/v - [27:24] 0x0 - [23:20] vertex register address (0..15) - [19:16] type (dimensionality) - [15:04] 0x0 - [03:00] vertex register address (0..15) - -Constant Memory from Shader (multiple DWORD token) - [31:29] 0x4 - [28:25] count of 4*DWORD constants to load (0..15) - [24:07] 0x0 - [06:00] constant memory address (0..95) - -Extension Token (single or multiple DWORD token) - [31:29] 0x5 - [28:24] count of additional DWORDs in token (0..31) - [23:00] extension-specific information - -End-of-array token (single DWORD token) - [31:29] 0x7 - [28:00] 0x1fffffff - -The stream selector token must be immediately followed by a contiguous set of stream data definition tokens. This token sequence fully defines that stream, including the set of elements within the stream, the order in which the elements appear, the type of each element, and the vertex register into which to load an element. -Streams are allowed to include data which is not loaded into a vertex register, thus allowing data which is not used for this shader to exist in the vertex stream. This skipped data is defined only by a count of DWORDs to skip over, since the type information is irrelevant. -The token sequence: -Stream Select: stream=0 -Stream Data Definition (Load): type=FLOAT3; register=3 -Stream Data Definition (Load): type=FLOAT3; register=4 -Stream Data Definition (Skip): count=2 -Stream Data Definition (Load): type=FLOAT2; register=7 - -defines stream zero to consist of 4 elements, 3 of which are loaded into registers and the fourth skipped over. Register 3 is loaded with the first three DWORDs in each vertex interpreted as FLOAT data. Register 4 is loaded with the 4th, 5th, and 6th DWORDs interpreted as FLOAT data. The next two DWORDs (7th and 8th) are skipped over and not loaded into any vertex input register. Register 7 is loaded with the 9th and 10th DWORDS interpreted as FLOAT data. -Placing of tokens other than NOPs between the Stream Selector and Stream Data Definition tokens is disallowed. - -*/ - -typedef enum _D3DVSD_TOKENTYPE -{ - D3DVSD_TOKEN_NOP = 0, // NOP or extension - D3DVSD_TOKEN_STREAM, // stream selector - D3DVSD_TOKEN_STREAMDATA, // stream data definition (map to vertex input memory) - D3DVSD_TOKEN_TESSELLATOR, // vertex input memory from tessellator - D3DVSD_TOKEN_CONSTMEM, // constant memory from shader - D3DVSD_TOKEN_EXT, // extension - D3DVSD_TOKEN_END = 7, // end-of-array (requires all DWORD bits to be 1) - D3DVSD_FORCE_DWORD = 0x7fffffff,// force 32-bit size enum -} D3DVSD_TOKENTYPE; - -#define D3DVSD_TOKENTYPESHIFT 29 -#define D3DVSD_TOKENTYPEMASK (7 << D3DVSD_TOKENTYPESHIFT) - -#define D3DVSD_STREAMNUMBERSHIFT 0 -#define D3DVSD_STREAMNUMBERMASK (0xF << D3DVSD_STREAMNUMBERSHIFT) - -#define D3DVSD_DATALOADTYPESHIFT 28 -#define D3DVSD_DATALOADTYPEMASK (0x1 << D3DVSD_DATALOADTYPESHIFT) - -#define D3DVSD_DATATYPESHIFT 16 -#define D3DVSD_DATATYPEMASK (0xF << D3DVSD_DATATYPESHIFT) - -#define D3DVSD_SKIPCOUNTSHIFT 16 -#define D3DVSD_SKIPCOUNTMASK (0xF << D3DVSD_SKIPCOUNTSHIFT) - -#define D3DVSD_VERTEXREGSHIFT 0 -#define D3DVSD_VERTEXREGMASK (0x1F << D3DVSD_VERTEXREGSHIFT) - -#define D3DVSD_VERTEXREGINSHIFT 20 -#define D3DVSD_VERTEXREGINMASK (0xF << D3DVSD_VERTEXREGINSHIFT) - -#define D3DVSD_CONSTCOUNTSHIFT 25 -#define D3DVSD_CONSTCOUNTMASK (0xF << D3DVSD_CONSTCOUNTSHIFT) - -#define D3DVSD_CONSTADDRESSSHIFT 0 -#define D3DVSD_CONSTADDRESSMASK (0x7F << D3DVSD_CONSTADDRESSSHIFT) - -#define D3DVSD_CONSTRSSHIFT 16 -#define D3DVSD_CONSTRSMASK (0x1FFF << D3DVSD_CONSTRSSHIFT) - -#define D3DVSD_EXTCOUNTSHIFT 24 -#define D3DVSD_EXTCOUNTMASK (0x1F << D3DVSD_EXTCOUNTSHIFT) - -#define D3DVSD_EXTINFOSHIFT 0 -#define D3DVSD_EXTINFOMASK (0xFFFFFF << D3DVSD_EXTINFOSHIFT) - -#define D3DVSD_MAKETOKENTYPE(tokenType) ((tokenType << D3DVSD_TOKENTYPESHIFT) & D3DVSD_TOKENTYPEMASK) - -// macros for generation of CreateVertexShader Declaration token array - -// Set current stream -// _StreamNumber [0..(MaxStreams-1)] stream to get data from -// -#define D3DVSD_STREAM( _StreamNumber ) \ - (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) | (_StreamNumber)) - -// Set tessellator stream -// -#define D3DVSD_STREAMTESSSHIFT 28 -#define D3DVSD_STREAMTESSMASK (1 << D3DVSD_STREAMTESSSHIFT) -#define D3DVSD_STREAM_TESS( ) \ - (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) | (D3DVSD_STREAMTESSMASK)) - -// bind single vertex register to vertex element from vertex stream -// -// _VertexRegister [0..15] address of the vertex register -// _Type [D3DVSDT_*] dimensionality and arithmetic data type - -#define D3DVSD_REG( _VertexRegister, _Type ) \ - (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) | \ - ((_Type) << D3DVSD_DATATYPESHIFT) | (_VertexRegister)) - -// Skip _DWORDCount DWORDs in vertex -// -#define D3DVSD_SKIP( _DWORDCount ) \ - (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) | 0x10000000 | \ - ((_DWORDCount) << D3DVSD_SKIPCOUNTSHIFT)) - -// load data into vertex shader constant memory -// -// _ConstantAddress [0..95] - address of constant array to begin filling data -// _Count [0..15] - number of constant vectors to load (4 DWORDs each) -// followed by 4*_Count DWORDS of data -// -#define D3DVSD_CONST( _ConstantAddress, _Count ) \ - (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_CONSTMEM) | \ - ((_Count) << D3DVSD_CONSTCOUNTSHIFT) | (_ConstantAddress)) - -// enable tessellator generated normals -// -// _VertexRegisterIn [0..15] address of vertex register whose input stream -// will be used in normal computation -// _VertexRegisterOut [0..15] address of vertex register to output the normal to -// -#define D3DVSD_TESSNORMAL( _VertexRegisterIn, _VertexRegisterOut ) \ - (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) | \ - ((_VertexRegisterIn) << D3DVSD_VERTEXREGINSHIFT) | \ - ((0x02) << D3DVSD_DATATYPESHIFT) | (_VertexRegisterOut)) - -// enable tessellator generated surface parameters -// -// _VertexRegister [0..15] address of vertex register to output parameters -// -#define D3DVSD_TESSUV( _VertexRegister ) \ - (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) | 0x10000000 | \ - ((0x01) << D3DVSD_DATATYPESHIFT) | (_VertexRegister)) - -// Generates END token -// -#define D3DVSD_END() 0xFFFFFFFF - -// Generates NOP token -#define D3DVSD_NOP() 0x00000000 - -// bit declarations for _Type fields -#define D3DVSDT_FLOAT1 0x00 // 1D float expanded to (value, 0., 0., 1.) -#define D3DVSDT_FLOAT2 0x01 // 2D float expanded to (value, value, 0., 1.) -#define D3DVSDT_FLOAT3 0x02 // 3D float expanded to (value, value, value, 1.) -#define D3DVSDT_FLOAT4 0x03 // 4D float -#define D3DVSDT_D3DCOLOR 0x04 // 4D packed unsigned bytes mapped to 0. to 1. range - // Input is in D3DCOLOR format (ARGB) expanded to (R, G, B, A) -#define D3DVSDT_UBYTE4 0x05 // 4D unsigned byte -#define D3DVSDT_SHORT2 0x06 // 2D signed short expanded to (value, value, 0., 1.) -#define D3DVSDT_SHORT4 0x07 // 4D signed short - -// assignments of vertex input registers for fixed function vertex shader -// -#define D3DVSDE_POSITION 0 -#define D3DVSDE_BLENDWEIGHT 1 -#define D3DVSDE_BLENDINDICES 2 -#define D3DVSDE_NORMAL 3 -#define D3DVSDE_PSIZE 4 -#define D3DVSDE_DIFFUSE 5 -#define D3DVSDE_SPECULAR 6 -#define D3DVSDE_TEXCOORD0 7 -#define D3DVSDE_TEXCOORD1 8 -#define D3DVSDE_TEXCOORD2 9 -#define D3DVSDE_TEXCOORD3 10 -#define D3DVSDE_TEXCOORD4 11 -#define D3DVSDE_TEXCOORD5 12 -#define D3DVSDE_TEXCOORD6 13 -#define D3DVSDE_TEXCOORD7 14 -#define D3DVSDE_POSITION2 15 -#define D3DVSDE_NORMAL2 16 - -// Maximum supported number of texture coordinate sets -#define D3DDP_MAXTEXCOORD 8 - - -// -// Instruction Token Bit Definitions -// -#define D3DSI_OPCODE_MASK 0x0000FFFF - -typedef enum _D3DSHADER_INSTRUCTION_OPCODE_TYPE -{ - D3DSIO_NOP = 0, // PS/VS - D3DSIO_MOV , // PS/VS - D3DSIO_ADD , // PS/VS - D3DSIO_SUB , // PS - D3DSIO_MAD , // PS/VS - D3DSIO_MUL , // PS/VS - D3DSIO_RCP , // VS - D3DSIO_RSQ , // VS - D3DSIO_DP3 , // PS/VS - D3DSIO_DP4 , // PS/VS - D3DSIO_MIN , // VS - D3DSIO_MAX , // VS - D3DSIO_SLT , // VS - D3DSIO_SGE , // VS - D3DSIO_EXP , // VS - D3DSIO_LOG , // VS - D3DSIO_LIT , // VS - D3DSIO_DST , // VS - D3DSIO_LRP , // PS - D3DSIO_FRC , // VS - D3DSIO_M4x4 , // VS - D3DSIO_M4x3 , // VS - D3DSIO_M3x4 , // VS - D3DSIO_M3x3 , // VS - D3DSIO_M3x2 , // VS - - D3DSIO_TEXCOORD = 64, // PS - D3DSIO_TEXKILL , // PS - D3DSIO_TEX , // PS - D3DSIO_TEXBEM , // PS - D3DSIO_TEXBEML , // PS - D3DSIO_TEXREG2AR , // PS - D3DSIO_TEXREG2GB , // PS - D3DSIO_TEXM3x2PAD , // PS - D3DSIO_TEXM3x2TEX , // PS - D3DSIO_TEXM3x3PAD , // PS - D3DSIO_TEXM3x3TEX , // PS - D3DSIO_TEXM3x3DIFF , // PS - D3DSIO_TEXM3x3SPEC , // PS - D3DSIO_TEXM3x3VSPEC , // PS - D3DSIO_EXPP , // VS - D3DSIO_LOGP , // VS - D3DSIO_CND , // PS - D3DSIO_DEF , // PS - D3DSIO_TEXREG2RGB , // PS - D3DSIO_TEXDP3TEX , // PS - D3DSIO_TEXM3x2DEPTH , // PS - D3DSIO_TEXDP3 , // PS - D3DSIO_TEXM3x3 , // PS - D3DSIO_TEXDEPTH , // PS - D3DSIO_CMP , // PS - D3DSIO_BEM , // PS - - D3DSIO_PHASE = 0xFFFD, - D3DSIO_COMMENT = 0xFFFE, - D3DSIO_END = 0xFFFF, - - D3DSIO_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum -} D3DSHADER_INSTRUCTION_OPCODE_TYPE; - -// -// Co-Issue Instruction Modifier - if set then this instruction is to be -// issued in parallel with the previous instruction(s) for which this bit -// is not set. -// -#define D3DSI_COISSUE 0x40000000 - -// -// Parameter Token Bit Definitions -// -#define D3DSP_REGNUM_MASK 0x00001FFF - -// 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 - -// destination parameter modifiers -#define D3DSP_DSTMOD_SHIFT 20 -#define D3DSP_DSTMOD_MASK 0x00F00000 - -typedef enum _D3DSHADER_PARAM_DSTMOD_TYPE -{ - D3DSPDM_NONE = 0<>8)&0xFF) -#define D3DSHADER_VERSION_MINOR(_Version) (((_Version)>>0)&0xFF) - -// destination/source parameter register type -#define D3DSI_COMMENTSIZE_SHIFT 16 -#define D3DSI_COMMENTSIZE_MASK 0x7FFF0000 -#define D3DSHADER_COMMENT(_DWordSize) \ - ((((_DWordSize)<= 1200 -#pragma warning(pop) -#else -#pragma warning(default:4201) -#endif - -#endif /* (DIRECT3D_VERSION >= 0x0800) */ -#endif /* _D3D8TYPES(P)_H_ */ - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3d8types.h + * Content: Direct3D capabilities include file + * + ***************************************************************************/ + +#ifndef _D3D8TYPES_H_ +#define _D3D8TYPES_H_ + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0800 +#endif //DIRECT3D_VERSION + +// include this file content only if compiling for DX8 interfaces +#if(DIRECT3D_VERSION >= 0x0800) + +#include + +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif +#pragma warning(disable:4201) // anonymous unions warning +#if defined(_X86_) || defined(_IA64_) +#pragma pack(4) +#endif + +// D3DCOLOR is equivalent to D3DFMT_A8R8G8B8 +#ifndef D3DCOLOR_DEFINED +typedef DWORD D3DCOLOR; +#define D3DCOLOR_DEFINED +#endif + +// maps unsigned 8 bits/channel to D3DCOLOR +#define D3DCOLOR_ARGB(a,r,g,b) \ + ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) +#define D3DCOLOR_RGBA(r,g,b,a) D3DCOLOR_ARGB(a,r,g,b) +#define D3DCOLOR_XRGB(r,g,b) D3DCOLOR_ARGB(0xff,r,g,b) + +// maps floating point channels (0.f to 1.f range) to D3DCOLOR +#define D3DCOLOR_COLORVALUE(r,g,b,a) \ + D3DCOLOR_RGBA((DWORD)((r)*255.f),(DWORD)((g)*255.f),(DWORD)((b)*255.f),(DWORD)((a)*255.f)) + + +#ifndef D3DVECTOR_DEFINED +typedef struct _D3DVECTOR { + float x; + float y; + float z; +} D3DVECTOR; +#define D3DVECTOR_DEFINED +#endif + +#ifndef D3DCOLORVALUE_DEFINED +typedef struct _D3DCOLORVALUE { + float r; + float g; + float b; + float a; +} D3DCOLORVALUE; +#define D3DCOLORVALUE_DEFINED +#endif + +#ifndef D3DRECT_DEFINED +typedef struct _D3DRECT { + LONG x1; + LONG y1; + LONG x2; + LONG y2; +} D3DRECT; +#define D3DRECT_DEFINED +#endif + +#ifndef D3DMATRIX_DEFINED +typedef struct _D3DMATRIX { + union { + struct { + float _11, _12, _13, _14; + float _21, _22, _23, _24; + float _31, _32, _33, _34; + float _41, _42, _43, _44; + + }; + float m[4][4]; + }; +} D3DMATRIX; +#define D3DMATRIX_DEFINED +#endif + +typedef struct _D3DVIEWPORT8 { + DWORD X; + DWORD Y; /* Viewport Top left */ + DWORD Width; + DWORD Height; /* Viewport Dimensions */ + float MinZ; /* Min/max of clip Volume */ + float MaxZ; +} D3DVIEWPORT8; + +/* + * Values for clip fields. + */ + +// Max number of user clipping planes, supported in D3D. +#define D3DMAXUSERCLIPPLANES 32 + +// These bits could be ORed together to use with D3DRS_CLIPPLANEENABLE +// +#define D3DCLIPPLANE0 (1 << 0) +#define D3DCLIPPLANE1 (1 << 1) +#define D3DCLIPPLANE2 (1 << 2) +#define D3DCLIPPLANE3 (1 << 3) +#define D3DCLIPPLANE4 (1 << 4) +#define D3DCLIPPLANE5 (1 << 5) + +// The following bits are used in the ClipUnion and ClipIntersection +// members of the D3DCLIPSTATUS8 +// + +#define D3DCS_LEFT 0x00000001L +#define D3DCS_RIGHT 0x00000002L +#define D3DCS_TOP 0x00000004L +#define D3DCS_BOTTOM 0x00000008L +#define D3DCS_FRONT 0x00000010L +#define D3DCS_BACK 0x00000020L +#define D3DCS_PLANE0 0x00000040L +#define D3DCS_PLANE1 0x00000080L +#define D3DCS_PLANE2 0x00000100L +#define D3DCS_PLANE3 0x00000200L +#define D3DCS_PLANE4 0x00000400L +#define D3DCS_PLANE5 0x00000800L + +#define D3DCS_ALL (D3DCS_LEFT | \ + D3DCS_RIGHT | \ + D3DCS_TOP | \ + D3DCS_BOTTOM | \ + D3DCS_FRONT | \ + D3DCS_BACK | \ + D3DCS_PLANE0 | \ + D3DCS_PLANE1 | \ + D3DCS_PLANE2 | \ + D3DCS_PLANE3 | \ + D3DCS_PLANE4 | \ + D3DCS_PLANE5) + +typedef struct _D3DCLIPSTATUS8 { + DWORD ClipUnion; + DWORD ClipIntersection; +} D3DCLIPSTATUS8; + +typedef struct _D3DMATERIAL8 { + 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 */ +} D3DMATERIAL8; + +typedef enum _D3DLIGHTTYPE { + D3DLIGHT_POINT = 1, + D3DLIGHT_SPOT = 2, + D3DLIGHT_DIRECTIONAL = 3, + D3DLIGHT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DLIGHTTYPE; + +typedef struct _D3DLIGHT8 { + 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 */ +} D3DLIGHT8; + +/* + * 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 */ + +/* + * The following defines the rendering states + */ + +typedef enum _D3DSHADEMODE { + D3DSHADE_FLAT = 1, + D3DSHADE_GOURAUD = 2, + D3DSHADE_PHONG = 3, + D3DSHADE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DSHADEMODE; + +typedef enum _D3DFILLMODE { + D3DFILL_POINT = 1, + D3DFILL_WIREFRAME = 2, + D3DFILL_SOLID = 3, + D3DFILL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DFILLMODE; + +typedef struct _D3DLINEPATTERN { + WORD wRepeatFactor; + WORD wLinePattern; +} D3DLINEPATTERN; + +typedef enum _D3DBLEND { + D3DBLEND_ZERO = 1, + D3DBLEND_ONE = 2, + D3DBLEND_SRCCOLOR = 3, + D3DBLEND_INVSRCCOLOR = 4, + D3DBLEND_SRCALPHA = 5, + D3DBLEND_INVSRCALPHA = 6, + D3DBLEND_DESTALPHA = 7, + D3DBLEND_INVDESTALPHA = 8, + D3DBLEND_DESTCOLOR = 9, + D3DBLEND_INVDESTCOLOR = 10, + D3DBLEND_SRCALPHASAT = 11, + D3DBLEND_BOTHSRCALPHA = 12, + D3DBLEND_BOTHINVSRCALPHA = 13, + D3DBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DBLEND; + +typedef enum _D3DBLENDOP { + D3DBLENDOP_ADD = 1, + D3DBLENDOP_SUBTRACT = 2, + D3DBLENDOP_REVSUBTRACT = 3, + D3DBLENDOP_MIN = 4, + D3DBLENDOP_MAX = 5, + D3DBLENDOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DBLENDOP; + +typedef enum _D3DTEXTUREADDRESS { + D3DTADDRESS_WRAP = 1, + D3DTADDRESS_MIRROR = 2, + D3DTADDRESS_CLAMP = 3, + D3DTADDRESS_BORDER = 4, + D3DTADDRESS_MIRRORONCE = 5, + D3DTADDRESS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DTEXTUREADDRESS; + +typedef enum _D3DCULL { + D3DCULL_NONE = 1, + D3DCULL_CW = 2, + D3DCULL_CCW = 3, + D3DCULL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DCULL; + +typedef enum _D3DCMPFUNC { + D3DCMP_NEVER = 1, + D3DCMP_LESS = 2, + D3DCMP_EQUAL = 3, + D3DCMP_LESSEQUAL = 4, + D3DCMP_GREATER = 5, + D3DCMP_NOTEQUAL = 6, + D3DCMP_GREATEREQUAL = 7, + D3DCMP_ALWAYS = 8, + D3DCMP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DCMPFUNC; + +typedef enum _D3DSTENCILOP { + D3DSTENCILOP_KEEP = 1, + D3DSTENCILOP_ZERO = 2, + D3DSTENCILOP_REPLACE = 3, + D3DSTENCILOP_INCRSAT = 4, + D3DSTENCILOP_DECRSAT = 5, + D3DSTENCILOP_INVERT = 6, + D3DSTENCILOP_INCR = 7, + D3DSTENCILOP_DECR = 8, + D3DSTENCILOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DSTENCILOP; + +typedef enum _D3DFOGMODE { + D3DFOG_NONE = 0, + D3DFOG_EXP = 1, + D3DFOG_EXP2 = 2, + D3DFOG_LINEAR = 3, + D3DFOG_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DFOGMODE; + +typedef enum _D3DZBUFFERTYPE { + D3DZB_FALSE = 0, + D3DZB_TRUE = 1, // Z buffering + D3DZB_USEW = 2, // W buffering + D3DZB_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DZBUFFERTYPE; + +// Primitives supported by draw-primitive API +typedef enum _D3DPRIMITIVETYPE { + D3DPT_POINTLIST = 1, + D3DPT_LINELIST = 2, + D3DPT_LINESTRIP = 3, + D3DPT_TRIANGLELIST = 4, + D3DPT_TRIANGLESTRIP = 5, + D3DPT_TRIANGLEFAN = 6, + D3DPT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DPRIMITIVETYPE; + +typedef enum _D3DTRANSFORMSTATETYPE { + D3DTS_VIEW = 2, + D3DTS_PROJECTION = 3, + D3DTS_TEXTURE0 = 16, + D3DTS_TEXTURE1 = 17, + D3DTS_TEXTURE2 = 18, + D3DTS_TEXTURE3 = 19, + D3DTS_TEXTURE4 = 20, + D3DTS_TEXTURE5 = 21, + D3DTS_TEXTURE6 = 22, + D3DTS_TEXTURE7 = 23, + D3DTS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DTRANSFORMSTATETYPE; + +#define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256) +#define D3DTS_WORLD D3DTS_WORLDMATRIX(0) +#define D3DTS_WORLD1 D3DTS_WORLDMATRIX(1) +#define D3DTS_WORLD2 D3DTS_WORLDMATRIX(2) +#define D3DTS_WORLD3 D3DTS_WORLDMATRIX(3) + +typedef enum _D3DRENDERSTATETYPE { + D3DRS_ZENABLE = 7, /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */ + D3DRS_FILLMODE = 8, /* D3DFILLMODE */ + D3DRS_SHADEMODE = 9, /* D3DSHADEMODE */ + D3DRS_LINEPATTERN = 10, /* D3DLINEPATTERN */ + D3DRS_ZWRITEENABLE = 14, /* TRUE to enable z writes */ + D3DRS_ALPHATESTENABLE = 15, /* TRUE to enable alpha tests */ + D3DRS_LASTPIXEL = 16, /* TRUE for last-pixel on lines */ + D3DRS_SRCBLEND = 19, /* D3DBLEND */ + D3DRS_DESTBLEND = 20, /* D3DBLEND */ + D3DRS_CULLMODE = 22, /* D3DCULL */ + D3DRS_ZFUNC = 23, /* D3DCMPFUNC */ + D3DRS_ALPHAREF = 24, /* D3DFIXED */ + D3DRS_ALPHAFUNC = 25, /* D3DCMPFUNC */ + D3DRS_DITHERENABLE = 26, /* TRUE to enable dithering */ + D3DRS_ALPHABLENDENABLE = 27, /* TRUE to enable alpha blending */ + D3DRS_FOGENABLE = 28, /* TRUE to enable fog blending */ + D3DRS_SPECULARENABLE = 29, /* TRUE to enable specular */ + D3DRS_ZVISIBLE = 30, /* TRUE to enable z checking */ + D3DRS_FOGCOLOR = 34, /* D3DCOLOR */ + D3DRS_FOGTABLEMODE = 35, /* D3DFOGMODE */ + D3DRS_FOGSTART = 36, /* Fog start (for both vertex and pixel fog) */ + D3DRS_FOGEND = 37, /* Fog end */ + D3DRS_FOGDENSITY = 38, /* Fog density */ + D3DRS_EDGEANTIALIAS = 40, /* TRUE to enable edge antialiasing */ + D3DRS_ZBIAS = 47, /* LONG Z bias */ + D3DRS_RANGEFOGENABLE = 48, /* Enables range-based fog */ + D3DRS_STENCILENABLE = 52, /* BOOL enable/disable stenciling */ + D3DRS_STENCILFAIL = 53, /* D3DSTENCILOP to do if stencil test fails */ + D3DRS_STENCILZFAIL = 54, /* D3DSTENCILOP to do if stencil test passes and Z test fails */ + D3DRS_STENCILPASS = 55, /* D3DSTENCILOP to do if both stencil and Z tests pass */ + D3DRS_STENCILFUNC = 56, /* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */ + D3DRS_STENCILREF = 57, /* Reference value used in stencil test */ + D3DRS_STENCILMASK = 58, /* Mask value used in stencil test */ + D3DRS_STENCILWRITEMASK = 59, /* Write mask applied to values written to stencil buffer */ + D3DRS_TEXTUREFACTOR = 60, /* D3DCOLOR used for multi-texture blend */ + D3DRS_WRAP0 = 128, /* wrap for 1st texture coord. set */ + D3DRS_WRAP1 = 129, /* wrap for 2nd texture coord. set */ + D3DRS_WRAP2 = 130, /* wrap for 3rd texture coord. set */ + D3DRS_WRAP3 = 131, /* wrap for 4th texture coord. set */ + D3DRS_WRAP4 = 132, /* wrap for 5th texture coord. set */ + D3DRS_WRAP5 = 133, /* wrap for 6th texture coord. set */ + D3DRS_WRAP6 = 134, /* wrap for 7th texture coord. set */ + D3DRS_WRAP7 = 135, /* wrap for 8th texture coord. set */ + D3DRS_CLIPPING = 136, + D3DRS_LIGHTING = 137, + D3DRS_AMBIENT = 139, + D3DRS_FOGVERTEXMODE = 140, + D3DRS_COLORVERTEX = 141, + D3DRS_LOCALVIEWER = 142, + D3DRS_NORMALIZENORMALS = 143, + D3DRS_DIFFUSEMATERIALSOURCE = 145, + D3DRS_SPECULARMATERIALSOURCE = 146, + D3DRS_AMBIENTMATERIALSOURCE = 147, + D3DRS_EMISSIVEMATERIALSOURCE = 148, + D3DRS_VERTEXBLEND = 151, + D3DRS_CLIPPLANEENABLE = 152, + D3DRS_SOFTWAREVERTEXPROCESSING = 153, + D3DRS_POINTSIZE = 154, /* float point size */ + D3DRS_POINTSIZE_MIN = 155, /* float point size min threshold */ + D3DRS_POINTSPRITEENABLE = 156, /* BOOL point texture coord control */ + D3DRS_POINTSCALEENABLE = 157, /* BOOL point size scale enable */ + D3DRS_POINTSCALE_A = 158, /* float point attenuation A value */ + D3DRS_POINTSCALE_B = 159, /* float point attenuation B value */ + D3DRS_POINTSCALE_C = 160, /* float point attenuation C value */ + D3DRS_MULTISAMPLEANTIALIAS = 161, // BOOL - set to do FSAA with multisample buffer + D3DRS_MULTISAMPLEMASK = 162, // DWORD - per-sample enable/disable + D3DRS_PATCHEDGESTYLE = 163, // Sets whether patch edges will use float style tessellation + D3DRS_PATCHSEGMENTS = 164, // Number of segments per edge when drawing patches + D3DRS_DEBUGMONITORTOKEN = 165, // DEBUG ONLY - token to debug monitor + D3DRS_POINTSIZE_MAX = 166, /* float point size max threshold */ + D3DRS_INDEXEDVERTEXBLENDENABLE = 167, + D3DRS_COLORWRITEENABLE = 168, // per-channel write enable + D3DRS_TWEENFACTOR = 170, // float tween factor + D3DRS_BLENDOP = 171, // D3DBLENDOP setting + D3DRS_POSITIONORDER = 172, // NPatch position interpolation order. D3DORDER_LINEAR or D3DORDER_CUBIC (default) + D3DRS_NORMALORDER = 173, // NPatch normal interpolation order. D3DORDER_LINEAR (default) or D3DORDER_QUADRATIC + + D3DRS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DRENDERSTATETYPE; + +// Values for material source +typedef enum _D3DMATERIALCOLORSOURCE +{ + D3DMCS_MATERIAL = 0, // Color from material is used + D3DMCS_COLOR1 = 1, // Diffuse vertex color is used + D3DMCS_COLOR2 = 2, // Specular vertex color is used + D3DMCS_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum +} D3DMATERIALCOLORSOURCE; + +// Bias to apply to the texture coordinate set to apply a wrap to. +#define D3DRENDERSTATE_WRAPBIAS 128UL + +/* Flags to construct the WRAP render states */ +#define D3DWRAP_U 0x00000001L +#define D3DWRAP_V 0x00000002L +#define D3DWRAP_W 0x00000004L + +/* Flags to construct the WRAP render states for 1D thru 4D texture coordinates */ +#define D3DWRAPCOORD_0 0x00000001L // same as D3DWRAP_U +#define D3DWRAPCOORD_1 0x00000002L // same as D3DWRAP_V +#define D3DWRAPCOORD_2 0x00000004L // same as D3DWRAP_W +#define D3DWRAPCOORD_3 0x00000008L + +/* 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) + +/* + * State enumerants for per-stage texture processing. + */ +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_ADDRESSU = 13, /* D3DTEXTUREADDRESS for U coordinate */ + D3DTSS_ADDRESSV = 14, /* D3DTEXTUREADDRESS for V coordinate */ + D3DTSS_BORDERCOLOR = 15, /* D3DCOLOR */ + D3DTSS_MAGFILTER = 16, /* D3DTEXTUREFILTER filter to use for magnification */ + D3DTSS_MINFILTER = 17, /* D3DTEXTUREFILTER filter to use for minification */ + D3DTSS_MIPFILTER = 18, /* D3DTEXTUREFILTER filter to use between mipmaps during minification */ + D3DTSS_MIPMAPLODBIAS = 19, /* float Mipmap LOD bias */ + D3DTSS_MAXMIPLEVEL = 20, /* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) */ + D3DTSS_MAXANISOTROPY = 21, /* DWORD maximum anisotropy */ + D3DTSS_BUMPENVLSCALE = 22, /* float scale for bump map luminance */ + D3DTSS_BUMPENVLOFFSET = 23, /* float offset for bump map luminance */ + D3DTSS_TEXTURETRANSFORMFLAGS = 24, /* D3DTEXTURETRANSFORMFLAGS controls texture transform */ + D3DTSS_ADDRESSW = 25, /* D3DTEXTUREADDRESS for W coordinate */ + D3DTSS_COLORARG0 = 26, /* D3DTA_* third arg for triadic ops */ + D3DTSS_ALPHAARG0 = 27, /* 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; + +// Values, used with D3DTSS_TEXCOORDINDEX, to specify that the vertex data(position +// and normal in the camera space) should be taken as texture coordinates +// Low 16 bits are used to specify texture coordinate index, to take the WRAP mode from +// +#define D3DTSS_TCI_PASSTHRU 0x00000000 +#define D3DTSS_TCI_CAMERASPACENORMAL 0x00010000 +#define D3DTSS_TCI_CAMERASPACEPOSITION 0x00020000 +#define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR 0x00030000 + +/* + * Enumerations for COLOROP and ALPHAOP texture blending operations set in + * texture processing stage controls in D3DTSS. + */ +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; + +/* + * Values for COLORARG0,1,2, ALPHAARG0,1,2, and RESULTARG texture blending + * operations set in texture processing stage controls in D3DRENDERSTATE. + */ +#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_COMPLEMENT 0x00000010 // take 1.0 - x (read modifier) +#define D3DTA_ALPHAREPLICATE 0x00000020 // replicate alpha to color components (read modifier) + +// +// Values for D3DTSS_***FILTER texture stage states +// +typedef enum _D3DTEXTUREFILTERTYPE +{ + D3DTEXF_NONE = 0, // filtering disabled (valid for mip filter only) + D3DTEXF_POINT = 1, // nearest + D3DTEXF_LINEAR = 2, // linear interpolation + D3DTEXF_ANISOTROPIC = 3, // anisotropic + D3DTEXF_FLATCUBIC = 4, // cubic + D3DTEXF_GAUSSIANCUBIC = 5, // different cubic kernel + D3DTEXF_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum +} D3DTEXTUREFILTERTYPE; + +/* Bits for Flags in ProcessVertices call */ + +#define D3DPV_DONOTCOPYDATA (1 << 0) + +//------------------------------------------------------------------- + +// Flexible vertex format bits +// +#define D3DFVF_RESERVED0 0x001 +#define D3DFVF_POSITION_MASK 0x00E +#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_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_RESERVED2 0xE000 // 4 reserved bits + +//--------------------------------------------------------------------- +// Vertex Shaders +// + +/* + +Vertex Shader Declaration + +The declaration portion of a vertex shader defines the static external +interface of the shader. The information in the declaration includes: + +- Assignments of vertex shader input registers to data streams. These +assignments bind a specific vertex register to a single component within a +vertex stream. A vertex stream element is identified by a byte offset +within the stream and a type. The type specifies the arithmetic data type +plus the dimensionality (1, 2, 3, or 4 values). Stream data which is +less than 4 values are always expanded out to 4 values with zero or more +0.F values and one 1.F value. + +- Assignment of vertex shader input registers to implicit data from the +primitive tessellator. This controls the loading of vertex data which is +not loaded from a stream, but rather is generated during primitive +tessellation prior to the vertex shader. + +- Loading data into the constant memory at the time a shader is set as the +current shader. Each token specifies values for one or more contiguous 4 +DWORD constant registers. This allows the shader to update an arbitrary +subset of the constant memory, overwriting the device state (which +contains the current values of the constant memory). Note that these +values can be subsequently overwritten (between DrawPrimitive calls) +during the time a shader is bound to a device via the +SetVertexShaderConstant method. + + +Declaration arrays are single-dimensional arrays of DWORDs composed of +multiple tokens each of which is one or more DWORDs. The single-DWORD +token value 0xFFFFFFFF is a special token used to indicate the end of the +declaration array. The single DWORD token value 0x00000000 is a NOP token +with is ignored during the declaration parsing. Note that 0x00000000 is a +valid value for DWORDs following the first DWORD for multiple word tokens. + +[31:29] TokenType + 0x0 - NOP (requires all DWORD bits to be zero) + 0x1 - stream selector + 0x2 - stream data definition (map to vertex input memory) + 0x3 - vertex input memory from tessellator + 0x4 - constant memory from shader + 0x5 - extension + 0x6 - reserved + 0x7 - end-of-array (requires all DWORD bits to be 1) + +NOP Token (single DWORD token) + [31:29] 0x0 + [28:00] 0x0 + +Stream Selector (single DWORD token) + [31:29] 0x1 + [28] indicates whether this is a tessellator stream + [27:04] 0x0 + [03:00] stream selector (0..15) + +Stream Data Definition (single DWORD token) + Vertex Input Register Load + [31:29] 0x2 + [28] 0x0 + [27:20] 0x0 + [19:16] type (dimensionality and data type) + [15:04] 0x0 + [03:00] vertex register address (0..15) + Data Skip (no register load) + [31:29] 0x2 + [28] 0x1 + [27:20] 0x0 + [19:16] count of DWORDS to skip over (0..15) + [15:00] 0x0 + Vertex Input Memory from Tessellator Data (single DWORD token) + [31:29] 0x3 + [28] indicates whether data is normals or u/v + [27:24] 0x0 + [23:20] vertex register address (0..15) + [19:16] type (dimensionality) + [15:04] 0x0 + [03:00] vertex register address (0..15) + +Constant Memory from Shader (multiple DWORD token) + [31:29] 0x4 + [28:25] count of 4*DWORD constants to load (0..15) + [24:07] 0x0 + [06:00] constant memory address (0..95) + +Extension Token (single or multiple DWORD token) + [31:29] 0x5 + [28:24] count of additional DWORDs in token (0..31) + [23:00] extension-specific information + +End-of-array token (single DWORD token) + [31:29] 0x7 + [28:00] 0x1fffffff + +The stream selector token must be immediately followed by a contiguous set of stream data definition tokens. This token sequence fully defines that stream, including the set of elements within the stream, the order in which the elements appear, the type of each element, and the vertex register into which to load an element. +Streams are allowed to include data which is not loaded into a vertex register, thus allowing data which is not used for this shader to exist in the vertex stream. This skipped data is defined only by a count of DWORDs to skip over, since the type information is irrelevant. +The token sequence: +Stream Select: stream=0 +Stream Data Definition (Load): type=FLOAT3; register=3 +Stream Data Definition (Load): type=FLOAT3; register=4 +Stream Data Definition (Skip): count=2 +Stream Data Definition (Load): type=FLOAT2; register=7 + +defines stream zero to consist of 4 elements, 3 of which are loaded into registers and the fourth skipped over. Register 3 is loaded with the first three DWORDs in each vertex interpreted as FLOAT data. Register 4 is loaded with the 4th, 5th, and 6th DWORDs interpreted as FLOAT data. The next two DWORDs (7th and 8th) are skipped over and not loaded into any vertex input register. Register 7 is loaded with the 9th and 10th DWORDS interpreted as FLOAT data. +Placing of tokens other than NOPs between the Stream Selector and Stream Data Definition tokens is disallowed. + +*/ + +typedef enum _D3DVSD_TOKENTYPE +{ + D3DVSD_TOKEN_NOP = 0, // NOP or extension + D3DVSD_TOKEN_STREAM, // stream selector + D3DVSD_TOKEN_STREAMDATA, // stream data definition (map to vertex input memory) + D3DVSD_TOKEN_TESSELLATOR, // vertex input memory from tessellator + D3DVSD_TOKEN_CONSTMEM, // constant memory from shader + D3DVSD_TOKEN_EXT, // extension + D3DVSD_TOKEN_END = 7, // end-of-array (requires all DWORD bits to be 1) + D3DVSD_FORCE_DWORD = 0x7fffffff,// force 32-bit size enum +} D3DVSD_TOKENTYPE; + +#define D3DVSD_TOKENTYPESHIFT 29 +#define D3DVSD_TOKENTYPEMASK (7 << D3DVSD_TOKENTYPESHIFT) + +#define D3DVSD_STREAMNUMBERSHIFT 0 +#define D3DVSD_STREAMNUMBERMASK (0xF << D3DVSD_STREAMNUMBERSHIFT) + +#define D3DVSD_DATALOADTYPESHIFT 28 +#define D3DVSD_DATALOADTYPEMASK (0x1 << D3DVSD_DATALOADTYPESHIFT) + +#define D3DVSD_DATATYPESHIFT 16 +#define D3DVSD_DATATYPEMASK (0xF << D3DVSD_DATATYPESHIFT) + +#define D3DVSD_SKIPCOUNTSHIFT 16 +#define D3DVSD_SKIPCOUNTMASK (0xF << D3DVSD_SKIPCOUNTSHIFT) + +#define D3DVSD_VERTEXREGSHIFT 0 +#define D3DVSD_VERTEXREGMASK (0x1F << D3DVSD_VERTEXREGSHIFT) + +#define D3DVSD_VERTEXREGINSHIFT 20 +#define D3DVSD_VERTEXREGINMASK (0xF << D3DVSD_VERTEXREGINSHIFT) + +#define D3DVSD_CONSTCOUNTSHIFT 25 +#define D3DVSD_CONSTCOUNTMASK (0xF << D3DVSD_CONSTCOUNTSHIFT) + +#define D3DVSD_CONSTADDRESSSHIFT 0 +#define D3DVSD_CONSTADDRESSMASK (0x7F << D3DVSD_CONSTADDRESSSHIFT) + +#define D3DVSD_CONSTRSSHIFT 16 +#define D3DVSD_CONSTRSMASK (0x1FFF << D3DVSD_CONSTRSSHIFT) + +#define D3DVSD_EXTCOUNTSHIFT 24 +#define D3DVSD_EXTCOUNTMASK (0x1F << D3DVSD_EXTCOUNTSHIFT) + +#define D3DVSD_EXTINFOSHIFT 0 +#define D3DVSD_EXTINFOMASK (0xFFFFFF << D3DVSD_EXTINFOSHIFT) + +#define D3DVSD_MAKETOKENTYPE(tokenType) ((tokenType << D3DVSD_TOKENTYPESHIFT) & D3DVSD_TOKENTYPEMASK) + +// macros for generation of CreateVertexShader Declaration token array + +// Set current stream +// _StreamNumber [0..(MaxStreams-1)] stream to get data from +// +#define D3DVSD_STREAM( _StreamNumber ) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) | (_StreamNumber)) + +// Set tessellator stream +// +#define D3DVSD_STREAMTESSSHIFT 28 +#define D3DVSD_STREAMTESSMASK (1 << D3DVSD_STREAMTESSSHIFT) +#define D3DVSD_STREAM_TESS( ) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) | (D3DVSD_STREAMTESSMASK)) + +// bind single vertex register to vertex element from vertex stream +// +// _VertexRegister [0..15] address of the vertex register +// _Type [D3DVSDT_*] dimensionality and arithmetic data type + +#define D3DVSD_REG( _VertexRegister, _Type ) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) | \ + ((_Type) << D3DVSD_DATATYPESHIFT) | (_VertexRegister)) + +// Skip _DWORDCount DWORDs in vertex +// +#define D3DVSD_SKIP( _DWORDCount ) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) | 0x10000000 | \ + ((_DWORDCount) << D3DVSD_SKIPCOUNTSHIFT)) + +// load data into vertex shader constant memory +// +// _ConstantAddress [0..95] - address of constant array to begin filling data +// _Count [0..15] - number of constant vectors to load (4 DWORDs each) +// followed by 4*_Count DWORDS of data +// +#define D3DVSD_CONST( _ConstantAddress, _Count ) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_CONSTMEM) | \ + ((_Count) << D3DVSD_CONSTCOUNTSHIFT) | (_ConstantAddress)) + +// enable tessellator generated normals +// +// _VertexRegisterIn [0..15] address of vertex register whose input stream +// will be used in normal computation +// _VertexRegisterOut [0..15] address of vertex register to output the normal to +// +#define D3DVSD_TESSNORMAL( _VertexRegisterIn, _VertexRegisterOut ) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) | \ + ((_VertexRegisterIn) << D3DVSD_VERTEXREGINSHIFT) | \ + ((0x02) << D3DVSD_DATATYPESHIFT) | (_VertexRegisterOut)) + +// enable tessellator generated surface parameters +// +// _VertexRegister [0..15] address of vertex register to output parameters +// +#define D3DVSD_TESSUV( _VertexRegister ) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) | 0x10000000 | \ + ((0x01) << D3DVSD_DATATYPESHIFT) | (_VertexRegister)) + +// Generates END token +// +#define D3DVSD_END() 0xFFFFFFFF + +// Generates NOP token +#define D3DVSD_NOP() 0x00000000 + +// bit declarations for _Type fields +#define D3DVSDT_FLOAT1 0x00 // 1D float expanded to (value, 0., 0., 1.) +#define D3DVSDT_FLOAT2 0x01 // 2D float expanded to (value, value, 0., 1.) +#define D3DVSDT_FLOAT3 0x02 // 3D float expanded to (value, value, value, 1.) +#define D3DVSDT_FLOAT4 0x03 // 4D float +#define D3DVSDT_D3DCOLOR 0x04 // 4D packed unsigned bytes mapped to 0. to 1. range + // Input is in D3DCOLOR format (ARGB) expanded to (R, G, B, A) +#define D3DVSDT_UBYTE4 0x05 // 4D unsigned byte +#define D3DVSDT_SHORT2 0x06 // 2D signed short expanded to (value, value, 0., 1.) +#define D3DVSDT_SHORT4 0x07 // 4D signed short + +// assignments of vertex input registers for fixed function vertex shader +// +#define D3DVSDE_POSITION 0 +#define D3DVSDE_BLENDWEIGHT 1 +#define D3DVSDE_BLENDINDICES 2 +#define D3DVSDE_NORMAL 3 +#define D3DVSDE_PSIZE 4 +#define D3DVSDE_DIFFUSE 5 +#define D3DVSDE_SPECULAR 6 +#define D3DVSDE_TEXCOORD0 7 +#define D3DVSDE_TEXCOORD1 8 +#define D3DVSDE_TEXCOORD2 9 +#define D3DVSDE_TEXCOORD3 10 +#define D3DVSDE_TEXCOORD4 11 +#define D3DVSDE_TEXCOORD5 12 +#define D3DVSDE_TEXCOORD6 13 +#define D3DVSDE_TEXCOORD7 14 +#define D3DVSDE_POSITION2 15 +#define D3DVSDE_NORMAL2 16 + +// Maximum supported number of texture coordinate sets +#define D3DDP_MAXTEXCOORD 8 + + +// +// Instruction Token Bit Definitions +// +#define D3DSI_OPCODE_MASK 0x0000FFFF + +typedef enum _D3DSHADER_INSTRUCTION_OPCODE_TYPE +{ + D3DSIO_NOP = 0, // PS/VS + D3DSIO_MOV , // PS/VS + D3DSIO_ADD , // PS/VS + D3DSIO_SUB , // PS + D3DSIO_MAD , // PS/VS + D3DSIO_MUL , // PS/VS + D3DSIO_RCP , // VS + D3DSIO_RSQ , // VS + D3DSIO_DP3 , // PS/VS + D3DSIO_DP4 , // PS/VS + D3DSIO_MIN , // VS + D3DSIO_MAX , // VS + D3DSIO_SLT , // VS + D3DSIO_SGE , // VS + D3DSIO_EXP , // VS + D3DSIO_LOG , // VS + D3DSIO_LIT , // VS + D3DSIO_DST , // VS + D3DSIO_LRP , // PS + D3DSIO_FRC , // VS + D3DSIO_M4x4 , // VS + D3DSIO_M4x3 , // VS + D3DSIO_M3x4 , // VS + D3DSIO_M3x3 , // VS + D3DSIO_M3x2 , // VS + + D3DSIO_TEXCOORD = 64, // PS + D3DSIO_TEXKILL , // PS + D3DSIO_TEX , // PS + D3DSIO_TEXBEM , // PS + D3DSIO_TEXBEML , // PS + D3DSIO_TEXREG2AR , // PS + D3DSIO_TEXREG2GB , // PS + D3DSIO_TEXM3x2PAD , // PS + D3DSIO_TEXM3x2TEX , // PS + D3DSIO_TEXM3x3PAD , // PS + D3DSIO_TEXM3x3TEX , // PS + D3DSIO_TEXM3x3DIFF , // PS + D3DSIO_TEXM3x3SPEC , // PS + D3DSIO_TEXM3x3VSPEC , // PS + D3DSIO_EXPP , // VS + D3DSIO_LOGP , // VS + D3DSIO_CND , // PS + D3DSIO_DEF , // PS + D3DSIO_TEXREG2RGB , // PS + D3DSIO_TEXDP3TEX , // PS + D3DSIO_TEXM3x2DEPTH , // PS + D3DSIO_TEXDP3 , // PS + D3DSIO_TEXM3x3 , // PS + D3DSIO_TEXDEPTH , // PS + D3DSIO_CMP , // PS + D3DSIO_BEM , // PS + + D3DSIO_PHASE = 0xFFFD, + D3DSIO_COMMENT = 0xFFFE, + D3DSIO_END = 0xFFFF, + + D3DSIO_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum +} D3DSHADER_INSTRUCTION_OPCODE_TYPE; + +// +// Co-Issue Instruction Modifier - if set then this instruction is to be +// issued in parallel with the previous instruction(s) for which this bit +// is not set. +// +#define D3DSI_COISSUE 0x40000000 + +// +// Parameter Token Bit Definitions +// +#define D3DSP_REGNUM_MASK 0x00001FFF + +// 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 + +// destination parameter modifiers +#define D3DSP_DSTMOD_SHIFT 20 +#define D3DSP_DSTMOD_MASK 0x00F00000 + +typedef enum _D3DSHADER_PARAM_DSTMOD_TYPE +{ + D3DSPDM_NONE = 0<>8)&0xFF) +#define D3DSHADER_VERSION_MINOR(_Version) (((_Version)>>0)&0xFF) + +// destination/source parameter register type +#define D3DSI_COMMENTSIZE_SHIFT 16 +#define D3DSI_COMMENTSIZE_MASK 0x7FFF0000 +#define D3DSHADER_COMMENT(_DWordSize) \ + ((((_DWordSize)<= 1200 +#pragma warning(pop) +#else +#pragma warning(default:4201) +#endif + +#endif /* (DIRECT3D_VERSION >= 0x0800) */ +#endif /* _D3D8TYPES(P)_H_ */ + diff --git a/src/dep/include/DXSDK/include/d3d9.h b/src/dep/include/DXSDK/include/d3d9.h index d467992..85bd957 100644 --- a/src/dep/include/DXSDK/include/d3d9.h +++ b/src/dep/include/DXSDK/include/d3d9.h @@ -1,1870 +1,1870 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: d3d9.h - * Content: Direct3D include file - * - ****************************************************************************/ - -#ifndef _D3D9_H_ -#define _D3D9_H_ - -#ifndef DIRECT3D_VERSION -#define DIRECT3D_VERSION 0x0900 -#endif //DIRECT3D_VERSION - -// include this file content only if compiling for DX9 interfaces -#if(DIRECT3D_VERSION >= 0x0900) - - -/* This identifier is passed to Direct3DCreate9 in order to ensure that an - * application was built against the correct header files. This number is - * incremented whenever a header (or other) change would require applications - * to be rebuilt. If the version doesn't match, Direct3DCreate9 will fail. - * (The number itself has no meaning.)*/ - -#ifdef D3D_DEBUG_INFO -#define D3D_SDK_VERSION (32 | 0x80000000) -#define D3D9b_SDK_VERSION (31 | 0x80000000) - -#else -#define D3D_SDK_VERSION 32 -#define D3D9b_SDK_VERSION 31 -#endif - - -#include - -#define COM_NO_WINDOWS_H -#include - -#include - -#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) - #define HMONITOR_DECLARED - DECLARE_HANDLE(HMONITOR); -#endif - -#define D3DAPI WINAPI - -/* - * Interface IID's - */ -#if defined( _WIN32 ) && !defined( _NO_COM) - -/* IID_IDirect3D9 */ -/* {81BDCBCA-64D4-426d-AE8D-AD0147F4275C} */ -DEFINE_GUID(IID_IDirect3D9, 0x81bdcbca, 0x64d4, 0x426d, 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c); - -/* IID_IDirect3DDevice9 */ -// {D0223B96-BF7A-43fd-92BD-A43B0D82B9EB} */ -DEFINE_GUID(IID_IDirect3DDevice9, 0xd0223b96, 0xbf7a, 0x43fd, 0x92, 0xbd, 0xa4, 0x3b, 0xd, 0x82, 0xb9, 0xeb); - -/* IID_IDirect3DResource9 */ -// {05EEC05D-8F7D-4362-B999-D1BAF357C704} -DEFINE_GUID(IID_IDirect3DResource9, 0x5eec05d, 0x8f7d, 0x4362, 0xb9, 0x99, 0xd1, 0xba, 0xf3, 0x57, 0xc7, 0x4); - -/* IID_IDirect3DBaseTexture9 */ -/* {580CA87E-1D3C-4d54-991D-B7D3E3C298CE} */ -DEFINE_GUID(IID_IDirect3DBaseTexture9, 0x580ca87e, 0x1d3c, 0x4d54, 0x99, 0x1d, 0xb7, 0xd3, 0xe3, 0xc2, 0x98, 0xce); - -/* IID_IDirect3DTexture9 */ -/* {85C31227-3DE5-4f00-9B3A-F11AC38C18B5} */ -DEFINE_GUID(IID_IDirect3DTexture9, 0x85c31227, 0x3de5, 0x4f00, 0x9b, 0x3a, 0xf1, 0x1a, 0xc3, 0x8c, 0x18, 0xb5); - -/* IID_IDirect3DCubeTexture9 */ -/* {FFF32F81-D953-473a-9223-93D652ABA93F} */ -DEFINE_GUID(IID_IDirect3DCubeTexture9, 0xfff32f81, 0xd953, 0x473a, 0x92, 0x23, 0x93, 0xd6, 0x52, 0xab, 0xa9, 0x3f); - -/* IID_IDirect3DVolumeTexture9 */ -/* {2518526C-E789-4111-A7B9-47EF328D13E6} */ -DEFINE_GUID(IID_IDirect3DVolumeTexture9, 0x2518526c, 0xe789, 0x4111, 0xa7, 0xb9, 0x47, 0xef, 0x32, 0x8d, 0x13, 0xe6); - -/* IID_IDirect3DVertexBuffer9 */ -/* {B64BB1B5-FD70-4df6-BF91-19D0A12455E3} */ -DEFINE_GUID(IID_IDirect3DVertexBuffer9, 0xb64bb1b5, 0xfd70, 0x4df6, 0xbf, 0x91, 0x19, 0xd0, 0xa1, 0x24, 0x55, 0xe3); - -/* IID_IDirect3DIndexBuffer9 */ -/* {7C9DD65E-D3F7-4529-ACEE-785830ACDE35} */ -DEFINE_GUID(IID_IDirect3DIndexBuffer9, 0x7c9dd65e, 0xd3f7, 0x4529, 0xac, 0xee, 0x78, 0x58, 0x30, 0xac, 0xde, 0x35); - -/* IID_IDirect3DSurface9 */ -/* {0CFBAF3A-9FF6-429a-99B3-A2796AF8B89B} */ -DEFINE_GUID(IID_IDirect3DSurface9, 0xcfbaf3a, 0x9ff6, 0x429a, 0x99, 0xb3, 0xa2, 0x79, 0x6a, 0xf8, 0xb8, 0x9b); - -/* IID_IDirect3DVolume9 */ -/* {24F416E6-1F67-4aa7-B88E-D33F6F3128A1} */ -DEFINE_GUID(IID_IDirect3DVolume9, 0x24f416e6, 0x1f67, 0x4aa7, 0xb8, 0x8e, 0xd3, 0x3f, 0x6f, 0x31, 0x28, 0xa1); - -/* IID_IDirect3DSwapChain9 */ -/* {794950F2-ADFC-458a-905E-10A10B0B503B} */ -DEFINE_GUID(IID_IDirect3DSwapChain9, 0x794950f2, 0xadfc, 0x458a, 0x90, 0x5e, 0x10, 0xa1, 0xb, 0xb, 0x50, 0x3b); - -/* IID_IDirect3DVertexDeclaration9 */ -/* {DD13C59C-36FA-4098-A8FB-C7ED39DC8546} */ -DEFINE_GUID(IID_IDirect3DVertexDeclaration9, 0xdd13c59c, 0x36fa, 0x4098, 0xa8, 0xfb, 0xc7, 0xed, 0x39, 0xdc, 0x85, 0x46); - -/* IID_IDirect3DVertexShader9 */ -/* {EFC5557E-6265-4613-8A94-43857889EB36} */ -DEFINE_GUID(IID_IDirect3DVertexShader9, 0xefc5557e, 0x6265, 0x4613, 0x8a, 0x94, 0x43, 0x85, 0x78, 0x89, 0xeb, 0x36); - -/* IID_IDirect3DPixelShader9 */ -/* {6D3BDBDC-5B02-4415-B852-CE5E8BCCB289} */ -DEFINE_GUID(IID_IDirect3DPixelShader9, 0x6d3bdbdc, 0x5b02, 0x4415, 0xb8, 0x52, 0xce, 0x5e, 0x8b, 0xcc, 0xb2, 0x89); - -/* IID_IDirect3DStateBlock9 */ -/* {B07C4FE5-310D-4ba8-A23C-4F0F206F218B} */ -DEFINE_GUID(IID_IDirect3DStateBlock9, 0xb07c4fe5, 0x310d, 0x4ba8, 0xa2, 0x3c, 0x4f, 0xf, 0x20, 0x6f, 0x21, 0x8b); - -/* IID_IDirect3DQuery9 */ -/* {d9771460-a695-4f26-bbd3-27b840b541cc} */ -DEFINE_GUID(IID_IDirect3DQuery9, 0xd9771460, 0xa695, 0x4f26, 0xbb, 0xd3, 0x27, 0xb8, 0x40, 0xb5, 0x41, 0xcc); - - -/* IID_HelperName */ -/* {E4A36723-FDFE-4b22-B146-3C04C07F4CC8} */ -DEFINE_GUID(IID_HelperName, 0xe4a36723, 0xfdfe, 0x4b22, 0xb1, 0x46, 0x3c, 0x4, 0xc0, 0x7f, 0x4c, 0xc8); - - -#endif - -#ifdef __cplusplus - -#ifndef DECLSPEC_UUID -#if _MSC_VER >= 1100 -#define DECLSPEC_UUID(x) __declspec(uuid(x)) -#else -#define DECLSPEC_UUID(x) -#endif -#endif - -interface DECLSPEC_UUID("81BDCBCA-64D4-426d-AE8D-AD0147F4275C") IDirect3D9; -interface DECLSPEC_UUID("D0223B96-BF7A-43fd-92BD-A43B0D82B9EB") IDirect3DDevice9; - -interface DECLSPEC_UUID("B07C4FE5-310D-4ba8-A23C-4F0F206F218B") IDirect3DStateBlock9; -interface DECLSPEC_UUID("05EEC05D-8F7D-4362-B999-D1BAF357C704") IDirect3DResource9; -interface DECLSPEC_UUID("DD13C59C-36FA-4098-A8FB-C7ED39DC8546") IDirect3DVertexDeclaration9; -interface DECLSPEC_UUID("EFC5557E-6265-4613-8A94-43857889EB36") IDirect3DVertexShader9; -interface DECLSPEC_UUID("6D3BDBDC-5B02-4415-B852-CE5E8BCCB289") IDirect3DPixelShader9; -interface DECLSPEC_UUID("580CA87E-1D3C-4d54-991D-B7D3E3C298CE") IDirect3DBaseTexture9; -interface DECLSPEC_UUID("85C31227-3DE5-4f00-9B3A-F11AC38C18B5") IDirect3DTexture9; -interface DECLSPEC_UUID("2518526C-E789-4111-A7B9-47EF328D13E6") IDirect3DVolumeTexture9; -interface DECLSPEC_UUID("FFF32F81-D953-473a-9223-93D652ABA93F") IDirect3DCubeTexture9; - -interface DECLSPEC_UUID("B64BB1B5-FD70-4df6-BF91-19D0A12455E3") IDirect3DVertexBuffer9; -interface DECLSPEC_UUID("7C9DD65E-D3F7-4529-ACEE-785830ACDE35") IDirect3DIndexBuffer9; - -interface DECLSPEC_UUID("0CFBAF3A-9FF6-429a-99B3-A2796AF8B89B") IDirect3DSurface9; -interface DECLSPEC_UUID("24F416E6-1F67-4aa7-B88E-D33F6F3128A1") IDirect3DVolume9; - -interface DECLSPEC_UUID("794950F2-ADFC-458a-905E-10A10B0B503B") IDirect3DSwapChain9; -interface DECLSPEC_UUID("d9771460-a695-4f26-bbd3-27b840b541cc") IDirect3DQuery9; - - -#if defined(_COM_SMARTPTR_TYPEDEF) -_COM_SMARTPTR_TYPEDEF(IDirect3D9, __uuidof(IDirect3D9)); -_COM_SMARTPTR_TYPEDEF(IDirect3DDevice9, __uuidof(IDirect3DDevice9)); - -_COM_SMARTPTR_TYPEDEF(IDirect3DStateBlock9, __uuidof(IDirect3DStateBlock9)); -_COM_SMARTPTR_TYPEDEF(IDirect3DResource9, __uuidof(IDirect3DResource9)); -_COM_SMARTPTR_TYPEDEF(IDirect3DVertexDeclaration9, __uuidof(IDirect3DVertexDeclaration9)); -_COM_SMARTPTR_TYPEDEF(IDirect3DVertexShader9, __uuidof(IDirect3DVertexShader9)); -_COM_SMARTPTR_TYPEDEF(IDirect3DPixelShader9, __uuidof(IDirect3DPixelShader9)); -_COM_SMARTPTR_TYPEDEF(IDirect3DBaseTexture9, __uuidof(IDirect3DBaseTexture9)); -_COM_SMARTPTR_TYPEDEF(IDirect3DTexture9, __uuidof(IDirect3DTexture9)); -_COM_SMARTPTR_TYPEDEF(IDirect3DVolumeTexture9, __uuidof(IDirect3DVolumeTexture9)); -_COM_SMARTPTR_TYPEDEF(IDirect3DCubeTexture9, __uuidof(IDirect3DCubeTexture9)); - -_COM_SMARTPTR_TYPEDEF(IDirect3DVertexBuffer9, __uuidof(IDirect3DVertexBuffer9)); -_COM_SMARTPTR_TYPEDEF(IDirect3DIndexBuffer9, __uuidof(IDirect3DIndexBuffer9)); - -_COM_SMARTPTR_TYPEDEF(IDirect3DSurface9, __uuidof(IDirect3DSurface9)); -_COM_SMARTPTR_TYPEDEF(IDirect3DVolume9, __uuidof(IDirect3DVolume9)); - -_COM_SMARTPTR_TYPEDEF(IDirect3DSwapChain9, __uuidof(IDirect3DSwapChain9)); -_COM_SMARTPTR_TYPEDEF(IDirect3DQuery9, __uuidof(IDirect3DQuery9)); - -#endif -#endif - - -typedef interface IDirect3D9 IDirect3D9; -typedef interface IDirect3DDevice9 IDirect3DDevice9; -typedef interface IDirect3DStateBlock9 IDirect3DStateBlock9; -typedef interface IDirect3DVertexDeclaration9 IDirect3DVertexDeclaration9; -typedef interface IDirect3DVertexShader9 IDirect3DVertexShader9; -typedef interface IDirect3DPixelShader9 IDirect3DPixelShader9; -typedef interface IDirect3DResource9 IDirect3DResource9; -typedef interface IDirect3DBaseTexture9 IDirect3DBaseTexture9; -typedef interface IDirect3DTexture9 IDirect3DTexture9; -typedef interface IDirect3DVolumeTexture9 IDirect3DVolumeTexture9; -typedef interface IDirect3DCubeTexture9 IDirect3DCubeTexture9; -typedef interface IDirect3DVertexBuffer9 IDirect3DVertexBuffer9; -typedef interface IDirect3DIndexBuffer9 IDirect3DIndexBuffer9; -typedef interface IDirect3DSurface9 IDirect3DSurface9; -typedef interface IDirect3DVolume9 IDirect3DVolume9; -typedef interface IDirect3DSwapChain9 IDirect3DSwapChain9; -typedef interface IDirect3DQuery9 IDirect3DQuery9; - - -#include "d3d9types.h" -#include "d3d9caps.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * DLL Function for creating a Direct3D9 object. This object supports - * enumeration and allows the creation of Direct3DDevice9 objects. - * Pass the value of the constant D3D_SDK_VERSION to this function, so - * that the run-time can validate that your application was compiled - * against the right headers. - */ - -IDirect3D9 * WINAPI Direct3DCreate9(UINT SDKVersion); - -/* - * Stubs for graphics profiling. - */ - -int WINAPI D3DPERF_BeginEvent( D3DCOLOR col, LPCWSTR wszName ); -int WINAPI D3DPERF_EndEvent( void ); -void WINAPI D3DPERF_SetMarker( D3DCOLOR col, LPCWSTR wszName ); -void WINAPI D3DPERF_SetRegion( D3DCOLOR col, LPCWSTR wszName ); -BOOL WINAPI D3DPERF_QueryRepeatFrame( void ); - -void WINAPI D3DPERF_SetOptions( DWORD dwOptions ); -DWORD WINAPI D3DPERF_GetStatus( void ); - -/* - * Direct3D interfaces - */ - - - - - - -#undef INTERFACE -#define INTERFACE IDirect3D9 - -DECLARE_INTERFACE_(IDirect3D9, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3D9 methods ***/ - STDMETHOD(RegisterSoftwareDevice)(THIS_ void* pInitializeFunction) PURE; - STDMETHOD_(UINT, GetAdapterCount)(THIS) PURE; - STDMETHOD(GetAdapterIdentifier)(THIS_ UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier) PURE; - STDMETHOD_(UINT, GetAdapterModeCount)(THIS_ UINT Adapter,D3DFORMAT Format) PURE; - STDMETHOD(EnumAdapterModes)(THIS_ UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode) PURE; - STDMETHOD(GetAdapterDisplayMode)(THIS_ UINT Adapter,D3DDISPLAYMODE* pMode) PURE; - STDMETHOD(CheckDeviceType)(THIS_ UINT Adapter,D3DDEVTYPE DevType,D3DFORMAT AdapterFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed) PURE; - STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) PURE; - STDMETHOD(CheckDeviceMultiSampleType)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels) PURE; - STDMETHOD(CheckDepthStencilMatch)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) PURE; - STDMETHOD(CheckDeviceFormatConversion)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat) PURE; - STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps) PURE; - STDMETHOD_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter) PURE; - STDMETHOD(CreateDevice)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) PURE; - - #ifdef D3D_DEBUG_INFO - LPCWSTR Version; - #endif -}; - -typedef struct IDirect3D9 *LPDIRECT3D9, *PDIRECT3D9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3D9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3D9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3D9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3D9_RegisterSoftwareDevice(p,a) (p)->lpVtbl->RegisterSoftwareDevice(p,a) -#define IDirect3D9_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p) -#define IDirect3D9_GetAdapterIdentifier(p,a,b,c) (p)->lpVtbl->GetAdapterIdentifier(p,a,b,c) -#define IDirect3D9_GetAdapterModeCount(p,a,b) (p)->lpVtbl->GetAdapterModeCount(p,a,b) -#define IDirect3D9_EnumAdapterModes(p,a,b,c,d) (p)->lpVtbl->EnumAdapterModes(p,a,b,c,d) -#define IDirect3D9_GetAdapterDisplayMode(p,a,b) (p)->lpVtbl->GetAdapterDisplayMode(p,a,b) -#define IDirect3D9_CheckDeviceType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceType(p,a,b,c,d,e) -#define IDirect3D9_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f) -#define IDirect3D9_CheckDeviceMultiSampleType(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceMultiSampleType(p,a,b,c,d,e,f) -#define IDirect3D9_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->lpVtbl->CheckDepthStencilMatch(p,a,b,c,d,e) -#define IDirect3D9_CheckDeviceFormatConversion(p,a,b,c,d) (p)->lpVtbl->CheckDeviceFormatConversion(p,a,b,c,d) -#define IDirect3D9_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c) -#define IDirect3D9_GetAdapterMonitor(p,a) (p)->lpVtbl->GetAdapterMonitor(p,a) -#define IDirect3D9_CreateDevice(p,a,b,c,d,e,f) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f) -#else -#define IDirect3D9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3D9_AddRef(p) (p)->AddRef() -#define IDirect3D9_Release(p) (p)->Release() -#define IDirect3D9_RegisterSoftwareDevice(p,a) (p)->RegisterSoftwareDevice(a) -#define IDirect3D9_GetAdapterCount(p) (p)->GetAdapterCount() -#define IDirect3D9_GetAdapterIdentifier(p,a,b,c) (p)->GetAdapterIdentifier(a,b,c) -#define IDirect3D9_GetAdapterModeCount(p,a,b) (p)->GetAdapterModeCount(a,b) -#define IDirect3D9_EnumAdapterModes(p,a,b,c,d) (p)->EnumAdapterModes(a,b,c,d) -#define IDirect3D9_GetAdapterDisplayMode(p,a,b) (p)->GetAdapterDisplayMode(a,b) -#define IDirect3D9_CheckDeviceType(p,a,b,c,d,e) (p)->CheckDeviceType(a,b,c,d,e) -#define IDirect3D9_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->CheckDeviceFormat(a,b,c,d,e,f) -#define IDirect3D9_CheckDeviceMultiSampleType(p,a,b,c,d,e,f) (p)->CheckDeviceMultiSampleType(a,b,c,d,e,f) -#define IDirect3D9_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->CheckDepthStencilMatch(a,b,c,d,e) -#define IDirect3D9_CheckDeviceFormatConversion(p,a,b,c,d) (p)->CheckDeviceFormatConversion(a,b,c,d) -#define IDirect3D9_GetDeviceCaps(p,a,b,c) (p)->GetDeviceCaps(a,b,c) -#define IDirect3D9_GetAdapterMonitor(p,a) (p)->GetAdapterMonitor(a) -#define IDirect3D9_CreateDevice(p,a,b,c,d,e,f) (p)->CreateDevice(a,b,c,d,e,f) -#endif - - - - - - - -/* SwapChain */ - - - - - - - - - - - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DDevice9 - -DECLARE_INTERFACE_(IDirect3DDevice9, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DDevice9 methods ***/ - STDMETHOD(TestCooperativeLevel)(THIS) PURE; - STDMETHOD_(UINT, GetAvailableTextureMem)(THIS) PURE; - STDMETHOD(EvictManagedResources)(THIS) PURE; - STDMETHOD(GetDirect3D)(THIS_ IDirect3D9** ppD3D9) PURE; - STDMETHOD(GetDeviceCaps)(THIS_ D3DCAPS9* pCaps) PURE; - STDMETHOD(GetDisplayMode)(THIS_ UINT iSwapChain,D3DDISPLAYMODE* pMode) PURE; - STDMETHOD(GetCreationParameters)(THIS_ D3DDEVICE_CREATION_PARAMETERS *pParameters) PURE; - STDMETHOD(SetCursorProperties)(THIS_ UINT XHotSpot,UINT YHotSpot,IDirect3DSurface9* pCursorBitmap) PURE; - STDMETHOD_(void, SetCursorPosition)(THIS_ int X,int Y,DWORD Flags) PURE; - STDMETHOD_(BOOL, ShowCursor)(THIS_ BOOL bShow) PURE; - STDMETHOD(CreateAdditionalSwapChain)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain9** pSwapChain) PURE; - STDMETHOD(GetSwapChain)(THIS_ UINT iSwapChain,IDirect3DSwapChain9** pSwapChain) PURE; - STDMETHOD_(UINT, GetNumberOfSwapChains)(THIS) PURE; - STDMETHOD(Reset)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; - STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; - STDMETHOD(GetBackBuffer)(THIS_ UINT iSwapChain,UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer) PURE; - STDMETHOD(GetRasterStatus)(THIS_ UINT iSwapChain,D3DRASTER_STATUS* pRasterStatus) PURE; - STDMETHOD(SetDialogBoxMode)(THIS_ BOOL bEnableDialogs) PURE; - STDMETHOD_(void, SetGammaRamp)(THIS_ UINT iSwapChain,DWORD Flags,CONST D3DGAMMARAMP* pRamp) PURE; - STDMETHOD_(void, GetGammaRamp)(THIS_ UINT iSwapChain,D3DGAMMARAMP* pRamp) PURE; - STDMETHOD(CreateTexture)(THIS_ UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture9** ppTexture,HANDLE* pSharedHandle) PURE; - STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture9** ppVolumeTexture,HANDLE* pSharedHandle) PURE; - STDMETHOD(CreateCubeTexture)(THIS_ UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture9** ppCubeTexture,HANDLE* pSharedHandle) PURE; - STDMETHOD(CreateVertexBuffer)(THIS_ UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer9** ppVertexBuffer,HANDLE* pSharedHandle) PURE; - STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer9** ppIndexBuffer,HANDLE* pSharedHandle) PURE; - STDMETHOD(CreateRenderTarget)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Lockable,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle) PURE; - STDMETHOD(CreateDepthStencilSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Discard,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle) PURE; - STDMETHOD(UpdateSurface)(THIS_ IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestinationSurface,CONST POINT* pDestPoint) PURE; - STDMETHOD(UpdateTexture)(THIS_ IDirect3DBaseTexture9* pSourceTexture,IDirect3DBaseTexture9* pDestinationTexture) PURE; - STDMETHOD(GetRenderTargetData)(THIS_ IDirect3DSurface9* pRenderTarget,IDirect3DSurface9* pDestSurface) PURE; - STDMETHOD(GetFrontBufferData)(THIS_ UINT iSwapChain,IDirect3DSurface9* pDestSurface) PURE; - STDMETHOD(StretchRect)(THIS_ IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect,D3DTEXTUREFILTERTYPE Filter) PURE; - STDMETHOD(ColorFill)(THIS_ IDirect3DSurface9* pSurface,CONST RECT* pRect,D3DCOLOR color) PURE; - STDMETHOD(CreateOffscreenPlainSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle) PURE; - STDMETHOD(SetRenderTarget)(THIS_ DWORD RenderTargetIndex,IDirect3DSurface9* pRenderTarget) PURE; - STDMETHOD(GetRenderTarget)(THIS_ DWORD RenderTargetIndex,IDirect3DSurface9** ppRenderTarget) PURE; - STDMETHOD(SetDepthStencilSurface)(THIS_ IDirect3DSurface9* pNewZStencil) PURE; - STDMETHOD(GetDepthStencilSurface)(THIS_ IDirect3DSurface9** ppZStencilSurface) PURE; - STDMETHOD(BeginScene)(THIS) PURE; - STDMETHOD(EndScene)(THIS) PURE; - STDMETHOD(Clear)(THIS_ DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil) PURE; - STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) PURE; - STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) PURE; - STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,CONST D3DMATRIX*) PURE; - STDMETHOD(SetViewport)(THIS_ CONST D3DVIEWPORT9* pViewport) PURE; - STDMETHOD(GetViewport)(THIS_ D3DVIEWPORT9* pViewport) PURE; - STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL9* pMaterial) PURE; - STDMETHOD(GetMaterial)(THIS_ D3DMATERIAL9* pMaterial) PURE; - STDMETHOD(SetLight)(THIS_ DWORD Index,CONST D3DLIGHT9*) PURE; - STDMETHOD(GetLight)(THIS_ DWORD Index,D3DLIGHT9*) PURE; - STDMETHOD(LightEnable)(THIS_ DWORD Index,BOOL Enable) PURE; - STDMETHOD(GetLightEnable)(THIS_ DWORD Index,BOOL* pEnable) PURE; - STDMETHOD(SetClipPlane)(THIS_ DWORD Index,CONST float* pPlane) PURE; - STDMETHOD(GetClipPlane)(THIS_ DWORD Index,float* pPlane) PURE; - STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD Value) PURE; - STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD* pValue) PURE; - STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type,IDirect3DStateBlock9** ppSB) PURE; - STDMETHOD(BeginStateBlock)(THIS) PURE; - STDMETHOD(EndStateBlock)(THIS_ IDirect3DStateBlock9** ppSB) PURE; - STDMETHOD(SetClipStatus)(THIS_ CONST D3DCLIPSTATUS9* pClipStatus) PURE; - STDMETHOD(GetClipStatus)(THIS_ D3DCLIPSTATUS9* pClipStatus) PURE; - STDMETHOD(GetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture9** ppTexture) PURE; - STDMETHOD(SetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture9* pTexture) PURE; - STDMETHOD(GetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) PURE; - STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE; - STDMETHOD(GetSamplerState)(THIS_ DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD* pValue) PURE; - STDMETHOD(SetSamplerState)(THIS_ DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD Value) PURE; - STDMETHOD(ValidateDevice)(THIS_ DWORD* pNumPasses) PURE; - STDMETHOD(SetPaletteEntries)(THIS_ UINT PaletteNumber,CONST PALETTEENTRY* pEntries) PURE; - STDMETHOD(GetPaletteEntries)(THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries) PURE; - STDMETHOD(SetCurrentTexturePalette)(THIS_ UINT PaletteNumber) PURE; - STDMETHOD(GetCurrentTexturePalette)(THIS_ UINT *PaletteNumber) PURE; - STDMETHOD(SetScissorRect)(THIS_ CONST RECT* pRect) PURE; - STDMETHOD(GetScissorRect)(THIS_ RECT* pRect) PURE; - STDMETHOD(SetSoftwareVertexProcessing)(THIS_ BOOL bSoftware) PURE; - STDMETHOD_(BOOL, GetSoftwareVertexProcessing)(THIS) PURE; - STDMETHOD(SetNPatchMode)(THIS_ float nSegments) PURE; - STDMETHOD_(float, GetNPatchMode)(THIS) PURE; - STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) PURE; - STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount) PURE; - STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; - STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; - STDMETHOD(ProcessVertices)(THIS_ UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer9* pDestBuffer,IDirect3DVertexDeclaration9* pVertexDecl,DWORD Flags) PURE; - STDMETHOD(CreateVertexDeclaration)(THIS_ CONST D3DVERTEXELEMENT9* pVertexElements,IDirect3DVertexDeclaration9** ppDecl) PURE; - STDMETHOD(SetVertexDeclaration)(THIS_ IDirect3DVertexDeclaration9* pDecl) PURE; - STDMETHOD(GetVertexDeclaration)(THIS_ IDirect3DVertexDeclaration9** ppDecl) PURE; - STDMETHOD(SetFVF)(THIS_ DWORD FVF) PURE; - STDMETHOD(GetFVF)(THIS_ DWORD* pFVF) PURE; - STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD* pFunction,IDirect3DVertexShader9** ppShader) PURE; - STDMETHOD(SetVertexShader)(THIS_ IDirect3DVertexShader9* pShader) PURE; - STDMETHOD(GetVertexShader)(THIS_ IDirect3DVertexShader9** ppShader) PURE; - STDMETHOD(SetVertexShaderConstantF)(THIS_ UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount) PURE; - STDMETHOD(GetVertexShaderConstantF)(THIS_ UINT StartRegister,float* pConstantData,UINT Vector4fCount) PURE; - STDMETHOD(SetVertexShaderConstantI)(THIS_ UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount) PURE; - STDMETHOD(GetVertexShaderConstantI)(THIS_ UINT StartRegister,int* pConstantData,UINT Vector4iCount) PURE; - STDMETHOD(SetVertexShaderConstantB)(THIS_ UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount) PURE; - STDMETHOD(GetVertexShaderConstantB)(THIS_ UINT StartRegister,BOOL* pConstantData,UINT BoolCount) PURE; - STDMETHOD(SetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride) PURE; - STDMETHOD(GetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer9** ppStreamData,UINT* pOffsetInBytes,UINT* pStride) PURE; - STDMETHOD(SetStreamSourceFreq)(THIS_ UINT StreamNumber,UINT Setting) PURE; - STDMETHOD(GetStreamSourceFreq)(THIS_ UINT StreamNumber,UINT* pSetting) PURE; - STDMETHOD(SetIndices)(THIS_ IDirect3DIndexBuffer9* pIndexData) PURE; - STDMETHOD(GetIndices)(THIS_ IDirect3DIndexBuffer9** ppIndexData) PURE; - STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction,IDirect3DPixelShader9** ppShader) PURE; - STDMETHOD(SetPixelShader)(THIS_ IDirect3DPixelShader9* pShader) PURE; - STDMETHOD(GetPixelShader)(THIS_ IDirect3DPixelShader9** ppShader) PURE; - STDMETHOD(SetPixelShaderConstantF)(THIS_ UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount) PURE; - STDMETHOD(GetPixelShaderConstantF)(THIS_ UINT StartRegister,float* pConstantData,UINT Vector4fCount) PURE; - STDMETHOD(SetPixelShaderConstantI)(THIS_ UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount) PURE; - STDMETHOD(GetPixelShaderConstantI)(THIS_ UINT StartRegister,int* pConstantData,UINT Vector4iCount) PURE; - STDMETHOD(SetPixelShaderConstantB)(THIS_ UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount) PURE; - STDMETHOD(GetPixelShaderConstantB)(THIS_ UINT StartRegister,BOOL* pConstantData,UINT BoolCount) PURE; - STDMETHOD(DrawRectPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) PURE; - STDMETHOD(DrawTriPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) PURE; - STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE; - STDMETHOD(CreateQuery)(THIS_ D3DQUERYTYPE Type,IDirect3DQuery9** ppQuery) PURE; - - #ifdef D3D_DEBUG_INFO - D3DDEVICE_CREATION_PARAMETERS CreationParameters; - D3DPRESENT_PARAMETERS PresentParameters; - D3DDISPLAYMODE DisplayMode; - D3DCAPS9 Caps; - - UINT AvailableTextureMem; - UINT SwapChains; - UINT Textures; - UINT VertexBuffers; - UINT IndexBuffers; - UINT VertexShaders; - UINT PixelShaders; - - D3DVIEWPORT9 Viewport; - D3DMATRIX ProjectionMatrix; - D3DMATRIX ViewMatrix; - D3DMATRIX WorldMatrix; - D3DMATRIX TextureMatrices[8]; - - DWORD FVF; - UINT VertexSize; - DWORD VertexShaderVersion; - DWORD PixelShaderVersion; - BOOL SoftwareVertexProcessing; - - D3DMATERIAL9 Material; - D3DLIGHT9 Lights[16]; - BOOL LightsEnabled[16]; - - D3DGAMMARAMP GammaRamp; - RECT ScissorRect; - BOOL DialogBoxMode; - #endif -}; - -typedef struct IDirect3DDevice9 *LPDIRECT3DDEVICE9, *PDIRECT3DDEVICE9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DDevice9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DDevice9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DDevice9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DDevice9_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) -#define IDirect3DDevice9_GetAvailableTextureMem(p) (p)->lpVtbl->GetAvailableTextureMem(p) -#define IDirect3DDevice9_EvictManagedResources(p) (p)->lpVtbl->EvictManagedResources(p) -#define IDirect3DDevice9_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) -#define IDirect3DDevice9_GetDeviceCaps(p,a) (p)->lpVtbl->GetDeviceCaps(p,a) -#define IDirect3DDevice9_GetDisplayMode(p,a,b) (p)->lpVtbl->GetDisplayMode(p,a,b) -#define IDirect3DDevice9_GetCreationParameters(p,a) (p)->lpVtbl->GetCreationParameters(p,a) -#define IDirect3DDevice9_SetCursorProperties(p,a,b,c) (p)->lpVtbl->SetCursorProperties(p,a,b,c) -#define IDirect3DDevice9_SetCursorPosition(p,a,b,c) (p)->lpVtbl->SetCursorPosition(p,a,b,c) -#define IDirect3DDevice9_ShowCursor(p,a) (p)->lpVtbl->ShowCursor(p,a) -#define IDirect3DDevice9_CreateAdditionalSwapChain(p,a,b) (p)->lpVtbl->CreateAdditionalSwapChain(p,a,b) -#define IDirect3DDevice9_GetSwapChain(p,a,b) (p)->lpVtbl->GetSwapChain(p,a,b) -#define IDirect3DDevice9_GetNumberOfSwapChains(p) (p)->lpVtbl->GetNumberOfSwapChains(p) -#define IDirect3DDevice9_Reset(p,a) (p)->lpVtbl->Reset(p,a) -#define IDirect3DDevice9_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) -#define IDirect3DDevice9_GetBackBuffer(p,a,b,c,d) (p)->lpVtbl->GetBackBuffer(p,a,b,c,d) -#define IDirect3DDevice9_GetRasterStatus(p,a,b) (p)->lpVtbl->GetRasterStatus(p,a,b) -#define IDirect3DDevice9_SetDialogBoxMode(p,a) (p)->lpVtbl->SetDialogBoxMode(p,a) -#define IDirect3DDevice9_SetGammaRamp(p,a,b,c) (p)->lpVtbl->SetGammaRamp(p,a,b,c) -#define IDirect3DDevice9_GetGammaRamp(p,a,b) (p)->lpVtbl->GetGammaRamp(p,a,b) -#define IDirect3DDevice9_CreateTexture(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateTexture(p,a,b,c,d,e,f,g,h) -#define IDirect3DDevice9_CreateVolumeTexture(p,a,b,c,d,e,f,g,h,i) (p)->lpVtbl->CreateVolumeTexture(p,a,b,c,d,e,f,g,h,i) -#define IDirect3DDevice9_CreateCubeTexture(p,a,b,c,d,e,f,g) (p)->lpVtbl->CreateCubeTexture(p,a,b,c,d,e,f,g) -#define IDirect3DDevice9_CreateVertexBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d,e,f) -#define IDirect3DDevice9_CreateIndexBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->CreateIndexBuffer(p,a,b,c,d,e,f) -#define IDirect3DDevice9_CreateRenderTarget(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateRenderTarget(p,a,b,c,d,e,f,g,h) -#define IDirect3DDevice9_CreateDepthStencilSurface(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateDepthStencilSurface(p,a,b,c,d,e,f,g,h) -#define IDirect3DDevice9_UpdateSurface(p,a,b,c,d) (p)->lpVtbl->UpdateSurface(p,a,b,c,d) -#define IDirect3DDevice9_UpdateTexture(p,a,b) (p)->lpVtbl->UpdateTexture(p,a,b) -#define IDirect3DDevice9_GetRenderTargetData(p,a,b) (p)->lpVtbl->GetRenderTargetData(p,a,b) -#define IDirect3DDevice9_GetFrontBufferData(p,a,b) (p)->lpVtbl->GetFrontBufferData(p,a,b) -#define IDirect3DDevice9_StretchRect(p,a,b,c,d,e) (p)->lpVtbl->StretchRect(p,a,b,c,d,e) -#define IDirect3DDevice9_ColorFill(p,a,b,c) (p)->lpVtbl->ColorFill(p,a,b,c) -#define IDirect3DDevice9_CreateOffscreenPlainSurface(p,a,b,c,d,e,f) (p)->lpVtbl->CreateOffscreenPlainSurface(p,a,b,c,d,e,f) -#define IDirect3DDevice9_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) -#define IDirect3DDevice9_GetRenderTarget(p,a,b) (p)->lpVtbl->GetRenderTarget(p,a,b) -#define IDirect3DDevice9_SetDepthStencilSurface(p,a) (p)->lpVtbl->SetDepthStencilSurface(p,a) -#define IDirect3DDevice9_GetDepthStencilSurface(p,a) (p)->lpVtbl->GetDepthStencilSurface(p,a) -#define IDirect3DDevice9_BeginScene(p) (p)->lpVtbl->BeginScene(p) -#define IDirect3DDevice9_EndScene(p) (p)->lpVtbl->EndScene(p) -#define IDirect3DDevice9_Clear(p,a,b,c,d,e,f) (p)->lpVtbl->Clear(p,a,b,c,d,e,f) -#define IDirect3DDevice9_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) -#define IDirect3DDevice9_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) -#define IDirect3DDevice9_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) -#define IDirect3DDevice9_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) -#define IDirect3DDevice9_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) -#define IDirect3DDevice9_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) -#define IDirect3DDevice9_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) -#define IDirect3DDevice9_SetLight(p,a,b) (p)->lpVtbl->SetLight(p,a,b) -#define IDirect3DDevice9_GetLight(p,a,b) (p)->lpVtbl->GetLight(p,a,b) -#define IDirect3DDevice9_LightEnable(p,a,b) (p)->lpVtbl->LightEnable(p,a,b) -#define IDirect3DDevice9_GetLightEnable(p,a,b) (p)->lpVtbl->GetLightEnable(p,a,b) -#define IDirect3DDevice9_SetClipPlane(p,a,b) (p)->lpVtbl->SetClipPlane(p,a,b) -#define IDirect3DDevice9_GetClipPlane(p,a,b) (p)->lpVtbl->GetClipPlane(p,a,b) -#define IDirect3DDevice9_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) -#define IDirect3DDevice9_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) -#define IDirect3DDevice9_CreateStateBlock(p,a,b) (p)->lpVtbl->CreateStateBlock(p,a,b) -#define IDirect3DDevice9_BeginStateBlock(p) (p)->lpVtbl->BeginStateBlock(p) -#define IDirect3DDevice9_EndStateBlock(p,a) (p)->lpVtbl->EndStateBlock(p,a) -#define IDirect3DDevice9_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) -#define IDirect3DDevice9_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) -#define IDirect3DDevice9_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) -#define IDirect3DDevice9_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) -#define IDirect3DDevice9_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) -#define IDirect3DDevice9_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) -#define IDirect3DDevice9_GetSamplerState(p,a,b,c) (p)->lpVtbl->GetSamplerState(p,a,b,c) -#define IDirect3DDevice9_SetSamplerState(p,a,b,c) (p)->lpVtbl->SetSamplerState(p,a,b,c) -#define IDirect3DDevice9_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a) -#define IDirect3DDevice9_SetPaletteEntries(p,a,b) (p)->lpVtbl->SetPaletteEntries(p,a,b) -#define IDirect3DDevice9_GetPaletteEntries(p,a,b) (p)->lpVtbl->GetPaletteEntries(p,a,b) -#define IDirect3DDevice9_SetCurrentTexturePalette(p,a) (p)->lpVtbl->SetCurrentTexturePalette(p,a) -#define IDirect3DDevice9_GetCurrentTexturePalette(p,a) (p)->lpVtbl->GetCurrentTexturePalette(p,a) -#define IDirect3DDevice9_SetScissorRect(p,a) (p)->lpVtbl->SetScissorRect(p,a) -#define IDirect3DDevice9_GetScissorRect(p,a) (p)->lpVtbl->GetScissorRect(p,a) -#define IDirect3DDevice9_SetSoftwareVertexProcessing(p,a) (p)->lpVtbl->SetSoftwareVertexProcessing(p,a) -#define IDirect3DDevice9_GetSoftwareVertexProcessing(p) (p)->lpVtbl->GetSoftwareVertexProcessing(p) -#define IDirect3DDevice9_SetNPatchMode(p,a) (p)->lpVtbl->SetNPatchMode(p,a) -#define IDirect3DDevice9_GetNPatchMode(p) (p)->lpVtbl->GetNPatchMode(p) -#define IDirect3DDevice9_DrawPrimitive(p,a,b,c) (p)->lpVtbl->DrawPrimitive(p,a,b,c) -#define IDirect3DDevice9_DrawIndexedPrimitive(p,a,b,c,d,e,f) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e,f) -#define IDirect3DDevice9_DrawPrimitiveUP(p,a,b,c,d) (p)->lpVtbl->DrawPrimitiveUP(p,a,b,c,d) -#define IDirect3DDevice9_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) -#define IDirect3DDevice9_ProcessVertices(p,a,b,c,d,e,f) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e,f) -#define IDirect3DDevice9_CreateVertexDeclaration(p,a,b) (p)->lpVtbl->CreateVertexDeclaration(p,a,b) -#define IDirect3DDevice9_SetVertexDeclaration(p,a) (p)->lpVtbl->SetVertexDeclaration(p,a) -#define IDirect3DDevice9_GetVertexDeclaration(p,a) (p)->lpVtbl->GetVertexDeclaration(p,a) -#define IDirect3DDevice9_SetFVF(p,a) (p)->lpVtbl->SetFVF(p,a) -#define IDirect3DDevice9_GetFVF(p,a) (p)->lpVtbl->GetFVF(p,a) -#define IDirect3DDevice9_CreateVertexShader(p,a,b) (p)->lpVtbl->CreateVertexShader(p,a,b) -#define IDirect3DDevice9_SetVertexShader(p,a) (p)->lpVtbl->SetVertexShader(p,a) -#define IDirect3DDevice9_GetVertexShader(p,a) (p)->lpVtbl->GetVertexShader(p,a) -#define IDirect3DDevice9_SetVertexShaderConstantF(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantF(p,a,b,c) -#define IDirect3DDevice9_GetVertexShaderConstantF(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantF(p,a,b,c) -#define IDirect3DDevice9_SetVertexShaderConstantI(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantI(p,a,b,c) -#define IDirect3DDevice9_GetVertexShaderConstantI(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantI(p,a,b,c) -#define IDirect3DDevice9_SetVertexShaderConstantB(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantB(p,a,b,c) -#define IDirect3DDevice9_GetVertexShaderConstantB(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantB(p,a,b,c) -#define IDirect3DDevice9_SetStreamSource(p,a,b,c,d) (p)->lpVtbl->SetStreamSource(p,a,b,c,d) -#define IDirect3DDevice9_GetStreamSource(p,a,b,c,d) (p)->lpVtbl->GetStreamSource(p,a,b,c,d) -#define IDirect3DDevice9_SetStreamSourceFreq(p,a,b) (p)->lpVtbl->SetStreamSourceFreq(p,a,b) -#define IDirect3DDevice9_GetStreamSourceFreq(p,a,b) (p)->lpVtbl->GetStreamSourceFreq(p,a,b) -#define IDirect3DDevice9_SetIndices(p,a) (p)->lpVtbl->SetIndices(p,a) -#define IDirect3DDevice9_GetIndices(p,a) (p)->lpVtbl->GetIndices(p,a) -#define IDirect3DDevice9_CreatePixelShader(p,a,b) (p)->lpVtbl->CreatePixelShader(p,a,b) -#define IDirect3DDevice9_SetPixelShader(p,a) (p)->lpVtbl->SetPixelShader(p,a) -#define IDirect3DDevice9_GetPixelShader(p,a) (p)->lpVtbl->GetPixelShader(p,a) -#define IDirect3DDevice9_SetPixelShaderConstantF(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantF(p,a,b,c) -#define IDirect3DDevice9_GetPixelShaderConstantF(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantF(p,a,b,c) -#define IDirect3DDevice9_SetPixelShaderConstantI(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantI(p,a,b,c) -#define IDirect3DDevice9_GetPixelShaderConstantI(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantI(p,a,b,c) -#define IDirect3DDevice9_SetPixelShaderConstantB(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantB(p,a,b,c) -#define IDirect3DDevice9_GetPixelShaderConstantB(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantB(p,a,b,c) -#define IDirect3DDevice9_DrawRectPatch(p,a,b,c) (p)->lpVtbl->DrawRectPatch(p,a,b,c) -#define IDirect3DDevice9_DrawTriPatch(p,a,b,c) (p)->lpVtbl->DrawTriPatch(p,a,b,c) -#define IDirect3DDevice9_DeletePatch(p,a) (p)->lpVtbl->DeletePatch(p,a) -#define IDirect3DDevice9_CreateQuery(p,a,b) (p)->lpVtbl->CreateQuery(p,a,b) -#else -#define IDirect3DDevice9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DDevice9_AddRef(p) (p)->AddRef() -#define IDirect3DDevice9_Release(p) (p)->Release() -#define IDirect3DDevice9_TestCooperativeLevel(p) (p)->TestCooperativeLevel() -#define IDirect3DDevice9_GetAvailableTextureMem(p) (p)->GetAvailableTextureMem() -#define IDirect3DDevice9_EvictManagedResources(p) (p)->EvictManagedResources() -#define IDirect3DDevice9_GetDirect3D(p,a) (p)->GetDirect3D(a) -#define IDirect3DDevice9_GetDeviceCaps(p,a) (p)->GetDeviceCaps(a) -#define IDirect3DDevice9_GetDisplayMode(p,a,b) (p)->GetDisplayMode(a,b) -#define IDirect3DDevice9_GetCreationParameters(p,a) (p)->GetCreationParameters(a) -#define IDirect3DDevice9_SetCursorProperties(p,a,b,c) (p)->SetCursorProperties(a,b,c) -#define IDirect3DDevice9_SetCursorPosition(p,a,b,c) (p)->SetCursorPosition(a,b,c) -#define IDirect3DDevice9_ShowCursor(p,a) (p)->ShowCursor(a) -#define IDirect3DDevice9_CreateAdditionalSwapChain(p,a,b) (p)->CreateAdditionalSwapChain(a,b) -#define IDirect3DDevice9_GetSwapChain(p,a,b) (p)->GetSwapChain(a,b) -#define IDirect3DDevice9_GetNumberOfSwapChains(p) (p)->GetNumberOfSwapChains() -#define IDirect3DDevice9_Reset(p,a) (p)->Reset(a) -#define IDirect3DDevice9_Present(p,a,b,c,d) (p)->Present(a,b,c,d) -#define IDirect3DDevice9_GetBackBuffer(p,a,b,c,d) (p)->GetBackBuffer(a,b,c,d) -#define IDirect3DDevice9_GetRasterStatus(p,a,b) (p)->GetRasterStatus(a,b) -#define IDirect3DDevice9_SetDialogBoxMode(p,a) (p)->SetDialogBoxMode(a) -#define IDirect3DDevice9_SetGammaRamp(p,a,b,c) (p)->SetGammaRamp(a,b,c) -#define IDirect3DDevice9_GetGammaRamp(p,a,b) (p)->GetGammaRamp(a,b) -#define IDirect3DDevice9_CreateTexture(p,a,b,c,d,e,f,g,h) (p)->CreateTexture(a,b,c,d,e,f,g,h) -#define IDirect3DDevice9_CreateVolumeTexture(p,a,b,c,d,e,f,g,h,i) (p)->CreateVolumeTexture(a,b,c,d,e,f,g,h,i) -#define IDirect3DDevice9_CreateCubeTexture(p,a,b,c,d,e,f,g) (p)->CreateCubeTexture(a,b,c,d,e,f,g) -#define IDirect3DDevice9_CreateVertexBuffer(p,a,b,c,d,e,f) (p)->CreateVertexBuffer(a,b,c,d,e,f) -#define IDirect3DDevice9_CreateIndexBuffer(p,a,b,c,d,e,f) (p)->CreateIndexBuffer(a,b,c,d,e,f) -#define IDirect3DDevice9_CreateRenderTarget(p,a,b,c,d,e,f,g,h) (p)->CreateRenderTarget(a,b,c,d,e,f,g,h) -#define IDirect3DDevice9_CreateDepthStencilSurface(p,a,b,c,d,e,f,g,h) (p)->CreateDepthStencilSurface(a,b,c,d,e,f,g,h) -#define IDirect3DDevice9_UpdateSurface(p,a,b,c,d) (p)->UpdateSurface(a,b,c,d) -#define IDirect3DDevice9_UpdateTexture(p,a,b) (p)->UpdateTexture(a,b) -#define IDirect3DDevice9_GetRenderTargetData(p,a,b) (p)->GetRenderTargetData(a,b) -#define IDirect3DDevice9_GetFrontBufferData(p,a,b) (p)->GetFrontBufferData(a,b) -#define IDirect3DDevice9_StretchRect(p,a,b,c,d,e) (p)->StretchRect(a,b,c,d,e) -#define IDirect3DDevice9_ColorFill(p,a,b,c) (p)->ColorFill(a,b,c) -#define IDirect3DDevice9_CreateOffscreenPlainSurface(p,a,b,c,d,e,f) (p)->CreateOffscreenPlainSurface(a,b,c,d,e,f) -#define IDirect3DDevice9_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) -#define IDirect3DDevice9_GetRenderTarget(p,a,b) (p)->GetRenderTarget(a,b) -#define IDirect3DDevice9_SetDepthStencilSurface(p,a) (p)->SetDepthStencilSurface(a) -#define IDirect3DDevice9_GetDepthStencilSurface(p,a) (p)->GetDepthStencilSurface(a) -#define IDirect3DDevice9_BeginScene(p) (p)->BeginScene() -#define IDirect3DDevice9_EndScene(p) (p)->EndScene() -#define IDirect3DDevice9_Clear(p,a,b,c,d,e,f) (p)->Clear(a,b,c,d,e,f) -#define IDirect3DDevice9_SetTransform(p,a,b) (p)->SetTransform(a,b) -#define IDirect3DDevice9_GetTransform(p,a,b) (p)->GetTransform(a,b) -#define IDirect3DDevice9_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) -#define IDirect3DDevice9_SetViewport(p,a) (p)->SetViewport(a) -#define IDirect3DDevice9_GetViewport(p,a) (p)->GetViewport(a) -#define IDirect3DDevice9_SetMaterial(p,a) (p)->SetMaterial(a) -#define IDirect3DDevice9_GetMaterial(p,a) (p)->GetMaterial(a) -#define IDirect3DDevice9_SetLight(p,a,b) (p)->SetLight(a,b) -#define IDirect3DDevice9_GetLight(p,a,b) (p)->GetLight(a,b) -#define IDirect3DDevice9_LightEnable(p,a,b) (p)->LightEnable(a,b) -#define IDirect3DDevice9_GetLightEnable(p,a,b) (p)->GetLightEnable(a,b) -#define IDirect3DDevice9_SetClipPlane(p,a,b) (p)->SetClipPlane(a,b) -#define IDirect3DDevice9_GetClipPlane(p,a,b) (p)->GetClipPlane(a,b) -#define IDirect3DDevice9_SetRenderState(p,a,b) (p)->SetRenderState(a,b) -#define IDirect3DDevice9_GetRenderState(p,a,b) (p)->GetRenderState(a,b) -#define IDirect3DDevice9_CreateStateBlock(p,a,b) (p)->CreateStateBlock(a,b) -#define IDirect3DDevice9_BeginStateBlock(p) (p)->BeginStateBlock() -#define IDirect3DDevice9_EndStateBlock(p,a) (p)->EndStateBlock(a) -#define IDirect3DDevice9_SetClipStatus(p,a) (p)->SetClipStatus(a) -#define IDirect3DDevice9_GetClipStatus(p,a) (p)->GetClipStatus(a) -#define IDirect3DDevice9_GetTexture(p,a,b) (p)->GetTexture(a,b) -#define IDirect3DDevice9_SetTexture(p,a,b) (p)->SetTexture(a,b) -#define IDirect3DDevice9_GetTextureStageState(p,a,b,c) (p)->GetTextureStageState(a,b,c) -#define IDirect3DDevice9_SetTextureStageState(p,a,b,c) (p)->SetTextureStageState(a,b,c) -#define IDirect3DDevice9_GetSamplerState(p,a,b,c) (p)->GetSamplerState(a,b,c) -#define IDirect3DDevice9_SetSamplerState(p,a,b,c) (p)->SetSamplerState(a,b,c) -#define IDirect3DDevice9_ValidateDevice(p,a) (p)->ValidateDevice(a) -#define IDirect3DDevice9_SetPaletteEntries(p,a,b) (p)->SetPaletteEntries(a,b) -#define IDirect3DDevice9_GetPaletteEntries(p,a,b) (p)->GetPaletteEntries(a,b) -#define IDirect3DDevice9_SetCurrentTexturePalette(p,a) (p)->SetCurrentTexturePalette(a) -#define IDirect3DDevice9_GetCurrentTexturePalette(p,a) (p)->GetCurrentTexturePalette(a) -#define IDirect3DDevice9_SetScissorRect(p,a) (p)->SetScissorRect(a) -#define IDirect3DDevice9_GetScissorRect(p,a) (p)->GetScissorRect(a) -#define IDirect3DDevice9_SetSoftwareVertexProcessing(p,a) (p)->SetSoftwareVertexProcessing(a) -#define IDirect3DDevice9_GetSoftwareVertexProcessing(p) (p)->GetSoftwareVertexProcessing() -#define IDirect3DDevice9_SetNPatchMode(p,a) (p)->SetNPatchMode(a) -#define IDirect3DDevice9_GetNPatchMode(p) (p)->GetNPatchMode() -#define IDirect3DDevice9_DrawPrimitive(p,a,b,c) (p)->DrawPrimitive(a,b,c) -#define IDirect3DDevice9_DrawIndexedPrimitive(p,a,b,c,d,e,f) (p)->DrawIndexedPrimitive(a,b,c,d,e,f) -#define IDirect3DDevice9_DrawPrimitiveUP(p,a,b,c,d) (p)->DrawPrimitiveUP(a,b,c,d) -#define IDirect3DDevice9_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->DrawIndexedPrimitiveUP(a,b,c,d,e,f,g,h) -#define IDirect3DDevice9_ProcessVertices(p,a,b,c,d,e,f) (p)->ProcessVertices(a,b,c,d,e,f) -#define IDirect3DDevice9_CreateVertexDeclaration(p,a,b) (p)->CreateVertexDeclaration(a,b) -#define IDirect3DDevice9_SetVertexDeclaration(p,a) (p)->SetVertexDeclaration(a) -#define IDirect3DDevice9_GetVertexDeclaration(p,a) (p)->GetVertexDeclaration(a) -#define IDirect3DDevice9_SetFVF(p,a) (p)->SetFVF(a) -#define IDirect3DDevice9_GetFVF(p,a) (p)->GetFVF(a) -#define IDirect3DDevice9_CreateVertexShader(p,a,b) (p)->CreateVertexShader(a,b) -#define IDirect3DDevice9_SetVertexShader(p,a) (p)->SetVertexShader(a) -#define IDirect3DDevice9_GetVertexShader(p,a) (p)->GetVertexShader(a) -#define IDirect3DDevice9_SetVertexShaderConstantF(p,a,b,c) (p)->SetVertexShaderConstantF(a,b,c) -#define IDirect3DDevice9_GetVertexShaderConstantF(p,a,b,c) (p)->GetVertexShaderConstantF(a,b,c) -#define IDirect3DDevice9_SetVertexShaderConstantI(p,a,b,c) (p)->SetVertexShaderConstantI(a,b,c) -#define IDirect3DDevice9_GetVertexShaderConstantI(p,a,b,c) (p)->GetVertexShaderConstantI(a,b,c) -#define IDirect3DDevice9_SetVertexShaderConstantB(p,a,b,c) (p)->SetVertexShaderConstantB(a,b,c) -#define IDirect3DDevice9_GetVertexShaderConstantB(p,a,b,c) (p)->GetVertexShaderConstantB(a,b,c) -#define IDirect3DDevice9_SetStreamSource(p,a,b,c,d) (p)->SetStreamSource(a,b,c,d) -#define IDirect3DDevice9_GetStreamSource(p,a,b,c,d) (p)->GetStreamSource(a,b,c,d) -#define IDirect3DDevice9_SetStreamSourceFreq(p,a,b) (p)->SetStreamSourceFreq(a,b) -#define IDirect3DDevice9_GetStreamSourceFreq(p,a,b) (p)->GetStreamSourceFreq(a,b) -#define IDirect3DDevice9_SetIndices(p,a) (p)->SetIndices(a) -#define IDirect3DDevice9_GetIndices(p,a) (p)->GetIndices(a) -#define IDirect3DDevice9_CreatePixelShader(p,a,b) (p)->CreatePixelShader(a,b) -#define IDirect3DDevice9_SetPixelShader(p,a) (p)->SetPixelShader(a) -#define IDirect3DDevice9_GetPixelShader(p,a) (p)->GetPixelShader(a) -#define IDirect3DDevice9_SetPixelShaderConstantF(p,a,b,c) (p)->SetPixelShaderConstantF(a,b,c) -#define IDirect3DDevice9_GetPixelShaderConstantF(p,a,b,c) (p)->GetPixelShaderConstantF(a,b,c) -#define IDirect3DDevice9_SetPixelShaderConstantI(p,a,b,c) (p)->SetPixelShaderConstantI(a,b,c) -#define IDirect3DDevice9_GetPixelShaderConstantI(p,a,b,c) (p)->GetPixelShaderConstantI(a,b,c) -#define IDirect3DDevice9_SetPixelShaderConstantB(p,a,b,c) (p)->SetPixelShaderConstantB(a,b,c) -#define IDirect3DDevice9_GetPixelShaderConstantB(p,a,b,c) (p)->GetPixelShaderConstantB(a,b,c) -#define IDirect3DDevice9_DrawRectPatch(p,a,b,c) (p)->DrawRectPatch(a,b,c) -#define IDirect3DDevice9_DrawTriPatch(p,a,b,c) (p)->DrawTriPatch(a,b,c) -#define IDirect3DDevice9_DeletePatch(p,a) (p)->DeletePatch(a) -#define IDirect3DDevice9_CreateQuery(p,a,b) (p)->CreateQuery(a,b) -#endif - - -#undef INTERFACE -#define INTERFACE IDirect3DStateBlock9 - -DECLARE_INTERFACE_(IDirect3DStateBlock9, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DStateBlock9 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(Capture)(THIS) PURE; - STDMETHOD(Apply)(THIS) PURE; - - #ifdef D3D_DEBUG_INFO - LPCWSTR CreationCallStack; - #endif -}; - -typedef struct IDirect3DStateBlock9 *LPDIRECT3DSTATEBLOCK9, *PDIRECT3DSTATEBLOCK9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DStateBlock9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DStateBlock9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DStateBlock9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DStateBlock9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DStateBlock9_Capture(p) (p)->lpVtbl->Capture(p) -#define IDirect3DStateBlock9_Apply(p) (p)->lpVtbl->Apply(p) -#else -#define IDirect3DStateBlock9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DStateBlock9_AddRef(p) (p)->AddRef() -#define IDirect3DStateBlock9_Release(p) (p)->Release() -#define IDirect3DStateBlock9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DStateBlock9_Capture(p) (p)->Capture() -#define IDirect3DStateBlock9_Apply(p) (p)->Apply() -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DSwapChain9 - -DECLARE_INTERFACE_(IDirect3DSwapChain9, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DSwapChain9 methods ***/ - STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion,DWORD dwFlags) PURE; - STDMETHOD(GetFrontBufferData)(THIS_ IDirect3DSurface9* pDestSurface) PURE; - STDMETHOD(GetBackBuffer)(THIS_ UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer) PURE; - STDMETHOD(GetRasterStatus)(THIS_ D3DRASTER_STATUS* pRasterStatus) PURE; - STDMETHOD(GetDisplayMode)(THIS_ D3DDISPLAYMODE* pMode) PURE; - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(GetPresentParameters)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; - - #ifdef D3D_DEBUG_INFO - D3DPRESENT_PARAMETERS PresentParameters; - D3DDISPLAYMODE DisplayMode; - LPCWSTR CreationCallStack; - #endif -}; - -typedef struct IDirect3DSwapChain9 *LPDIRECT3DSWAPCHAIN9, *PDIRECT3DSWAPCHAIN9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DSwapChain9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DSwapChain9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DSwapChain9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DSwapChain9_Present(p,a,b,c,d,e) (p)->lpVtbl->Present(p,a,b,c,d,e) -#define IDirect3DSwapChain9_GetFrontBufferData(p,a) (p)->lpVtbl->GetFrontBufferData(p,a) -#define IDirect3DSwapChain9_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) -#define IDirect3DSwapChain9_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a) -#define IDirect3DSwapChain9_GetDisplayMode(p,a) (p)->lpVtbl->GetDisplayMode(p,a) -#define IDirect3DSwapChain9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DSwapChain9_GetPresentParameters(p,a) (p)->lpVtbl->GetPresentParameters(p,a) -#else -#define IDirect3DSwapChain9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DSwapChain9_AddRef(p) (p)->AddRef() -#define IDirect3DSwapChain9_Release(p) (p)->Release() -#define IDirect3DSwapChain9_Present(p,a,b,c,d,e) (p)->Present(a,b,c,d,e) -#define IDirect3DSwapChain9_GetFrontBufferData(p,a) (p)->GetFrontBufferData(a) -#define IDirect3DSwapChain9_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) -#define IDirect3DSwapChain9_GetRasterStatus(p,a) (p)->GetRasterStatus(a) -#define IDirect3DSwapChain9_GetDisplayMode(p,a) (p)->GetDisplayMode(a) -#define IDirect3DSwapChain9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DSwapChain9_GetPresentParameters(p,a) (p)->GetPresentParameters(a) -#endif - - - -#undef INTERFACE -#define INTERFACE IDirect3DResource9 - -DECLARE_INTERFACE_(IDirect3DResource9, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource9 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; -}; - -typedef struct IDirect3DResource9 *LPDIRECT3DRESOURCE9, *PDIRECT3DRESOURCE9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DResource9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DResource9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DResource9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DResource9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DResource9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DResource9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DResource9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DResource9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DResource9_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DResource9_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DResource9_GetType(p) (p)->lpVtbl->GetType(p) -#else -#define IDirect3DResource9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DResource9_AddRef(p) (p)->AddRef() -#define IDirect3DResource9_Release(p) (p)->Release() -#define IDirect3DResource9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DResource9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DResource9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DResource9_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DResource9_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DResource9_GetPriority(p) (p)->GetPriority() -#define IDirect3DResource9_PreLoad(p) (p)->PreLoad() -#define IDirect3DResource9_GetType(p) (p)->GetType() -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DVertexDeclaration9 - -DECLARE_INTERFACE_(IDirect3DVertexDeclaration9, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DVertexDeclaration9 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9* pElement,UINT* pNumElements) PURE; - - #ifdef D3D_DEBUG_INFO - LPCWSTR CreationCallStack; - #endif -}; - -typedef struct IDirect3DVertexDeclaration9 *LPDIRECT3DVERTEXDECLARATION9, *PDIRECT3DVERTEXDECLARATION9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVertexDeclaration9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVertexDeclaration9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVertexDeclaration9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVertexDeclaration9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DVertexDeclaration9_GetDeclaration(p,a,b) (p)->lpVtbl->GetDeclaration(p,a,b) -#else -#define IDirect3DVertexDeclaration9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVertexDeclaration9_AddRef(p) (p)->AddRef() -#define IDirect3DVertexDeclaration9_Release(p) (p)->Release() -#define IDirect3DVertexDeclaration9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DVertexDeclaration9_GetDeclaration(p,a,b) (p)->GetDeclaration(a,b) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DVertexShader9 - -DECLARE_INTERFACE_(IDirect3DVertexShader9, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DVertexShader9 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(GetFunction)(THIS_ void*,UINT* pSizeOfData) PURE; - - #ifdef D3D_DEBUG_INFO - DWORD Version; - LPCWSTR CreationCallStack; - #endif -}; - -typedef struct IDirect3DVertexShader9 *LPDIRECT3DVERTEXSHADER9, *PDIRECT3DVERTEXSHADER9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVertexShader9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVertexShader9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVertexShader9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVertexShader9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DVertexShader9_GetFunction(p,a,b) (p)->lpVtbl->GetFunction(p,a,b) -#else -#define IDirect3DVertexShader9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVertexShader9_AddRef(p) (p)->AddRef() -#define IDirect3DVertexShader9_Release(p) (p)->Release() -#define IDirect3DVertexShader9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DVertexShader9_GetFunction(p,a,b) (p)->GetFunction(a,b) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DPixelShader9 - -DECLARE_INTERFACE_(IDirect3DPixelShader9, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DPixelShader9 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(GetFunction)(THIS_ void*,UINT* pSizeOfData) PURE; - - #ifdef D3D_DEBUG_INFO - DWORD Version; - LPCWSTR CreationCallStack; - #endif -}; - -typedef struct IDirect3DPixelShader9 *LPDIRECT3DPIXELSHADER9, *PDIRECT3DPIXELSHADER9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DPixelShader9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DPixelShader9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DPixelShader9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DPixelShader9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DPixelShader9_GetFunction(p,a,b) (p)->lpVtbl->GetFunction(p,a,b) -#else -#define IDirect3DPixelShader9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DPixelShader9_AddRef(p) (p)->AddRef() -#define IDirect3DPixelShader9_Release(p) (p)->Release() -#define IDirect3DPixelShader9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DPixelShader9_GetFunction(p,a,b) (p)->GetFunction(a,b) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DBaseTexture9 - -DECLARE_INTERFACE_(IDirect3DBaseTexture9, IDirect3DResource9) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource9 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; - STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType) PURE; - STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS) PURE; - STDMETHOD_(void, GenerateMipSubLevels)(THIS) PURE; -}; - -typedef struct IDirect3DBaseTexture9 *LPDIRECT3DBASETEXTURE9, *PDIRECT3DBASETEXTURE9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DBaseTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DBaseTexture9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DBaseTexture9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DBaseTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DBaseTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DBaseTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DBaseTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DBaseTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DBaseTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DBaseTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DBaseTexture9_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DBaseTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DBaseTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DBaseTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#define IDirect3DBaseTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a) -#define IDirect3DBaseTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p) -#define IDirect3DBaseTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p) -#else -#define IDirect3DBaseTexture9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DBaseTexture9_AddRef(p) (p)->AddRef() -#define IDirect3DBaseTexture9_Release(p) (p)->Release() -#define IDirect3DBaseTexture9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DBaseTexture9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DBaseTexture9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DBaseTexture9_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DBaseTexture9_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DBaseTexture9_GetPriority(p) (p)->GetPriority() -#define IDirect3DBaseTexture9_PreLoad(p) (p)->PreLoad() -#define IDirect3DBaseTexture9_GetType(p) (p)->GetType() -#define IDirect3DBaseTexture9_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DBaseTexture9_GetLOD(p) (p)->GetLOD() -#define IDirect3DBaseTexture9_GetLevelCount(p) (p)->GetLevelCount() -#define IDirect3DBaseTexture9_SetAutoGenFilterType(p,a) (p)->SetAutoGenFilterType(a) -#define IDirect3DBaseTexture9_GetAutoGenFilterType(p) (p)->GetAutoGenFilterType() -#define IDirect3DBaseTexture9_GenerateMipSubLevels(p) (p)->GenerateMipSubLevels() -#endif - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DTexture9 - -DECLARE_INTERFACE_(IDirect3DTexture9, IDirect3DBaseTexture9) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DBaseTexture9 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; - STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType) PURE; - STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS) PURE; - STDMETHOD_(void, GenerateMipSubLevels)(THIS) PURE; - STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; - STDMETHOD(GetSurfaceLevel)(THIS_ UINT Level,IDirect3DSurface9** ppSurfaceLevel) PURE; - STDMETHOD(LockRect)(THIS_ UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; - STDMETHOD(UnlockRect)(THIS_ UINT Level) PURE; - STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pDirtyRect) PURE; - - #ifdef D3D_DEBUG_INFO - LPCWSTR Name; - UINT Width; - UINT Height; - UINT Levels; - DWORD Usage; - D3DFORMAT Format; - D3DPOOL Pool; - DWORD Priority; - DWORD LOD; - D3DTEXTUREFILTERTYPE FilterType; - UINT LockCount; - LPCWSTR CreationCallStack; - #endif -}; - -typedef struct IDirect3DTexture9 *LPDIRECT3DTEXTURE9, *PDIRECT3DTEXTURE9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DTexture9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DTexture9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DTexture9_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#define IDirect3DTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a) -#define IDirect3DTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p) -#define IDirect3DTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p) -#define IDirect3DTexture9_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) -#define IDirect3DTexture9_GetSurfaceLevel(p,a,b) (p)->lpVtbl->GetSurfaceLevel(p,a,b) -#define IDirect3DTexture9_LockRect(p,a,b,c,d) (p)->lpVtbl->LockRect(p,a,b,c,d) -#define IDirect3DTexture9_UnlockRect(p,a) (p)->lpVtbl->UnlockRect(p,a) -#define IDirect3DTexture9_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a) -#else -#define IDirect3DTexture9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DTexture9_AddRef(p) (p)->AddRef() -#define IDirect3DTexture9_Release(p) (p)->Release() -#define IDirect3DTexture9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DTexture9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DTexture9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DTexture9_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DTexture9_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DTexture9_GetPriority(p) (p)->GetPriority() -#define IDirect3DTexture9_PreLoad(p) (p)->PreLoad() -#define IDirect3DTexture9_GetType(p) (p)->GetType() -#define IDirect3DTexture9_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DTexture9_GetLOD(p) (p)->GetLOD() -#define IDirect3DTexture9_GetLevelCount(p) (p)->GetLevelCount() -#define IDirect3DTexture9_SetAutoGenFilterType(p,a) (p)->SetAutoGenFilterType(a) -#define IDirect3DTexture9_GetAutoGenFilterType(p) (p)->GetAutoGenFilterType() -#define IDirect3DTexture9_GenerateMipSubLevels(p) (p)->GenerateMipSubLevels() -#define IDirect3DTexture9_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) -#define IDirect3DTexture9_GetSurfaceLevel(p,a,b) (p)->GetSurfaceLevel(a,b) -#define IDirect3DTexture9_LockRect(p,a,b,c,d) (p)->LockRect(a,b,c,d) -#define IDirect3DTexture9_UnlockRect(p,a) (p)->UnlockRect(a) -#define IDirect3DTexture9_AddDirtyRect(p,a) (p)->AddDirtyRect(a) -#endif - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DVolumeTexture9 - -DECLARE_INTERFACE_(IDirect3DVolumeTexture9, IDirect3DBaseTexture9) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DBaseTexture9 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; - STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType) PURE; - STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS) PURE; - STDMETHOD_(void, GenerateMipSubLevels)(THIS) PURE; - STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DVOLUME_DESC *pDesc) PURE; - STDMETHOD(GetVolumeLevel)(THIS_ UINT Level,IDirect3DVolume9** ppVolumeLevel) PURE; - STDMETHOD(LockBox)(THIS_ UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; - STDMETHOD(UnlockBox)(THIS_ UINT Level) PURE; - STDMETHOD(AddDirtyBox)(THIS_ CONST D3DBOX* pDirtyBox) PURE; - - #ifdef D3D_DEBUG_INFO - LPCWSTR Name; - UINT Width; - UINT Height; - UINT Depth; - UINT Levels; - DWORD Usage; - D3DFORMAT Format; - D3DPOOL Pool; - DWORD Priority; - DWORD LOD; - D3DTEXTUREFILTERTYPE FilterType; - UINT LockCount; - LPCWSTR CreationCallStack; - #endif -}; - -typedef struct IDirect3DVolumeTexture9 *LPDIRECT3DVOLUMETEXTURE9, *PDIRECT3DVOLUMETEXTURE9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVolumeTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVolumeTexture9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVolumeTexture9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVolumeTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DVolumeTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DVolumeTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DVolumeTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DVolumeTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DVolumeTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DVolumeTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DVolumeTexture9_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DVolumeTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DVolumeTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DVolumeTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#define IDirect3DVolumeTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a) -#define IDirect3DVolumeTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p) -#define IDirect3DVolumeTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p) -#define IDirect3DVolumeTexture9_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) -#define IDirect3DVolumeTexture9_GetVolumeLevel(p,a,b) (p)->lpVtbl->GetVolumeLevel(p,a,b) -#define IDirect3DVolumeTexture9_LockBox(p,a,b,c,d) (p)->lpVtbl->LockBox(p,a,b,c,d) -#define IDirect3DVolumeTexture9_UnlockBox(p,a) (p)->lpVtbl->UnlockBox(p,a) -#define IDirect3DVolumeTexture9_AddDirtyBox(p,a) (p)->lpVtbl->AddDirtyBox(p,a) -#else -#define IDirect3DVolumeTexture9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVolumeTexture9_AddRef(p) (p)->AddRef() -#define IDirect3DVolumeTexture9_Release(p) (p)->Release() -#define IDirect3DVolumeTexture9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DVolumeTexture9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DVolumeTexture9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DVolumeTexture9_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DVolumeTexture9_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DVolumeTexture9_GetPriority(p) (p)->GetPriority() -#define IDirect3DVolumeTexture9_PreLoad(p) (p)->PreLoad() -#define IDirect3DVolumeTexture9_GetType(p) (p)->GetType() -#define IDirect3DVolumeTexture9_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DVolumeTexture9_GetLOD(p) (p)->GetLOD() -#define IDirect3DVolumeTexture9_GetLevelCount(p) (p)->GetLevelCount() -#define IDirect3DVolumeTexture9_SetAutoGenFilterType(p,a) (p)->SetAutoGenFilterType(a) -#define IDirect3DVolumeTexture9_GetAutoGenFilterType(p) (p)->GetAutoGenFilterType() -#define IDirect3DVolumeTexture9_GenerateMipSubLevels(p) (p)->GenerateMipSubLevels() -#define IDirect3DVolumeTexture9_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) -#define IDirect3DVolumeTexture9_GetVolumeLevel(p,a,b) (p)->GetVolumeLevel(a,b) -#define IDirect3DVolumeTexture9_LockBox(p,a,b,c,d) (p)->LockBox(a,b,c,d) -#define IDirect3DVolumeTexture9_UnlockBox(p,a) (p)->UnlockBox(a) -#define IDirect3DVolumeTexture9_AddDirtyBox(p,a) (p)->AddDirtyBox(a) -#endif - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DCubeTexture9 - -DECLARE_INTERFACE_(IDirect3DCubeTexture9, IDirect3DBaseTexture9) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DBaseTexture9 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; - STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType) PURE; - STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS) PURE; - STDMETHOD_(void, GenerateMipSubLevels)(THIS) PURE; - STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; - STDMETHOD(GetCubeMapSurface)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface9** ppCubeMapSurface) PURE; - STDMETHOD(LockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; - STDMETHOD(UnlockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level) PURE; - STDMETHOD(AddDirtyRect)(THIS_ D3DCUBEMAP_FACES FaceType,CONST RECT* pDirtyRect) PURE; - - #ifdef D3D_DEBUG_INFO - LPCWSTR Name; - UINT Width; - UINT Height; - UINT Levels; - DWORD Usage; - D3DFORMAT Format; - D3DPOOL Pool; - DWORD Priority; - DWORD LOD; - D3DTEXTUREFILTERTYPE FilterType; - UINT LockCount; - LPCWSTR CreationCallStack; - #endif -}; - -typedef struct IDirect3DCubeTexture9 *LPDIRECT3DCUBETEXTURE9, *PDIRECT3DCUBETEXTURE9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DCubeTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DCubeTexture9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DCubeTexture9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DCubeTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DCubeTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DCubeTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DCubeTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DCubeTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DCubeTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DCubeTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DCubeTexture9_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DCubeTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DCubeTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DCubeTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#define IDirect3DCubeTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a) -#define IDirect3DCubeTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p) -#define IDirect3DCubeTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p) -#define IDirect3DCubeTexture9_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) -#define IDirect3DCubeTexture9_GetCubeMapSurface(p,a,b,c) (p)->lpVtbl->GetCubeMapSurface(p,a,b,c) -#define IDirect3DCubeTexture9_LockRect(p,a,b,c,d,e) (p)->lpVtbl->LockRect(p,a,b,c,d,e) -#define IDirect3DCubeTexture9_UnlockRect(p,a,b) (p)->lpVtbl->UnlockRect(p,a,b) -#define IDirect3DCubeTexture9_AddDirtyRect(p,a,b) (p)->lpVtbl->AddDirtyRect(p,a,b) -#else -#define IDirect3DCubeTexture9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DCubeTexture9_AddRef(p) (p)->AddRef() -#define IDirect3DCubeTexture9_Release(p) (p)->Release() -#define IDirect3DCubeTexture9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DCubeTexture9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DCubeTexture9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DCubeTexture9_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DCubeTexture9_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DCubeTexture9_GetPriority(p) (p)->GetPriority() -#define IDirect3DCubeTexture9_PreLoad(p) (p)->PreLoad() -#define IDirect3DCubeTexture9_GetType(p) (p)->GetType() -#define IDirect3DCubeTexture9_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DCubeTexture9_GetLOD(p) (p)->GetLOD() -#define IDirect3DCubeTexture9_GetLevelCount(p) (p)->GetLevelCount() -#define IDirect3DCubeTexture9_SetAutoGenFilterType(p,a) (p)->SetAutoGenFilterType(a) -#define IDirect3DCubeTexture9_GetAutoGenFilterType(p) (p)->GetAutoGenFilterType() -#define IDirect3DCubeTexture9_GenerateMipSubLevels(p) (p)->GenerateMipSubLevels() -#define IDirect3DCubeTexture9_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) -#define IDirect3DCubeTexture9_GetCubeMapSurface(p,a,b,c) (p)->GetCubeMapSurface(a,b,c) -#define IDirect3DCubeTexture9_LockRect(p,a,b,c,d,e) (p)->LockRect(a,b,c,d,e) -#define IDirect3DCubeTexture9_UnlockRect(p,a,b) (p)->UnlockRect(a,b) -#define IDirect3DCubeTexture9_AddDirtyRect(p,a,b) (p)->AddDirtyRect(a,b) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DVertexBuffer9 - -DECLARE_INTERFACE_(IDirect3DVertexBuffer9, IDirect3DResource9) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource9 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags) PURE; - STDMETHOD(Unlock)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3DVERTEXBUFFER_DESC *pDesc) PURE; - - #ifdef D3D_DEBUG_INFO - LPCWSTR Name; - UINT Length; - DWORD Usage; - DWORD FVF; - D3DPOOL Pool; - DWORD Priority; - UINT LockCount; - LPCWSTR CreationCallStack; - #endif -}; - -typedef struct IDirect3DVertexBuffer9 *LPDIRECT3DVERTEXBUFFER9, *PDIRECT3DVERTEXBUFFER9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVertexBuffer9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVertexBuffer9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVertexBuffer9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVertexBuffer9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DVertexBuffer9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DVertexBuffer9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DVertexBuffer9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DVertexBuffer9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DVertexBuffer9_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DVertexBuffer9_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DVertexBuffer9_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DVertexBuffer9_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirect3DVertexBuffer9_Unlock(p) (p)->lpVtbl->Unlock(p) -#define IDirect3DVertexBuffer9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#else -#define IDirect3DVertexBuffer9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVertexBuffer9_AddRef(p) (p)->AddRef() -#define IDirect3DVertexBuffer9_Release(p) (p)->Release() -#define IDirect3DVertexBuffer9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DVertexBuffer9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DVertexBuffer9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DVertexBuffer9_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DVertexBuffer9_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DVertexBuffer9_GetPriority(p) (p)->GetPriority() -#define IDirect3DVertexBuffer9_PreLoad(p) (p)->PreLoad() -#define IDirect3DVertexBuffer9_GetType(p) (p)->GetType() -#define IDirect3DVertexBuffer9_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirect3DVertexBuffer9_Unlock(p) (p)->Unlock() -#define IDirect3DVertexBuffer9_GetDesc(p,a) (p)->GetDesc(a) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DIndexBuffer9 - -DECLARE_INTERFACE_(IDirect3DIndexBuffer9, IDirect3DResource9) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource9 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags) PURE; - STDMETHOD(Unlock)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3DINDEXBUFFER_DESC *pDesc) PURE; - - #ifdef D3D_DEBUG_INFO - LPCWSTR Name; - UINT Length; - DWORD Usage; - D3DFORMAT Format; - D3DPOOL Pool; - DWORD Priority; - UINT LockCount; - LPCWSTR CreationCallStack; - #endif -}; - -typedef struct IDirect3DIndexBuffer9 *LPDIRECT3DINDEXBUFFER9, *PDIRECT3DINDEXBUFFER9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DIndexBuffer9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DIndexBuffer9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DIndexBuffer9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DIndexBuffer9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DIndexBuffer9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DIndexBuffer9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DIndexBuffer9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DIndexBuffer9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DIndexBuffer9_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DIndexBuffer9_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DIndexBuffer9_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DIndexBuffer9_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirect3DIndexBuffer9_Unlock(p) (p)->lpVtbl->Unlock(p) -#define IDirect3DIndexBuffer9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#else -#define IDirect3DIndexBuffer9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DIndexBuffer9_AddRef(p) (p)->AddRef() -#define IDirect3DIndexBuffer9_Release(p) (p)->Release() -#define IDirect3DIndexBuffer9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DIndexBuffer9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DIndexBuffer9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DIndexBuffer9_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DIndexBuffer9_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DIndexBuffer9_GetPriority(p) (p)->GetPriority() -#define IDirect3DIndexBuffer9_PreLoad(p) (p)->PreLoad() -#define IDirect3DIndexBuffer9_GetType(p) (p)->GetType() -#define IDirect3DIndexBuffer9_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirect3DIndexBuffer9_Unlock(p) (p)->Unlock() -#define IDirect3DIndexBuffer9_GetDesc(p,a) (p)->GetDesc(a) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DSurface9 - -DECLARE_INTERFACE_(IDirect3DSurface9, IDirect3DResource9) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource9 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; - STDMETHOD(GetDesc)(THIS_ D3DSURFACE_DESC *pDesc) PURE; - STDMETHOD(LockRect)(THIS_ D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; - STDMETHOD(UnlockRect)(THIS) PURE; - STDMETHOD(GetDC)(THIS_ HDC *phdc) PURE; - STDMETHOD(ReleaseDC)(THIS_ HDC hdc) PURE; - - #ifdef D3D_DEBUG_INFO - LPCWSTR Name; - UINT Width; - UINT Height; - DWORD Usage; - D3DFORMAT Format; - D3DPOOL Pool; - D3DMULTISAMPLE_TYPE MultiSampleType; - DWORD MultiSampleQuality; - DWORD Priority; - UINT LockCount; - UINT DCCount; - LPCWSTR CreationCallStack; - #endif -}; - -typedef struct IDirect3DSurface9 *LPDIRECT3DSURFACE9, *PDIRECT3DSURFACE9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DSurface9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DSurface9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DSurface9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DSurface9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DSurface9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DSurface9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DSurface9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DSurface9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DSurface9_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DSurface9_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DSurface9_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DSurface9_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) -#define IDirect3DSurface9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#define IDirect3DSurface9_LockRect(p,a,b,c) (p)->lpVtbl->LockRect(p,a,b,c) -#define IDirect3DSurface9_UnlockRect(p) (p)->lpVtbl->UnlockRect(p) -#define IDirect3DSurface9_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) -#define IDirect3DSurface9_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) -#else -#define IDirect3DSurface9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DSurface9_AddRef(p) (p)->AddRef() -#define IDirect3DSurface9_Release(p) (p)->Release() -#define IDirect3DSurface9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DSurface9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DSurface9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DSurface9_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DSurface9_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DSurface9_GetPriority(p) (p)->GetPriority() -#define IDirect3DSurface9_PreLoad(p) (p)->PreLoad() -#define IDirect3DSurface9_GetType(p) (p)->GetType() -#define IDirect3DSurface9_GetContainer(p,a,b) (p)->GetContainer(a,b) -#define IDirect3DSurface9_GetDesc(p,a) (p)->GetDesc(a) -#define IDirect3DSurface9_LockRect(p,a,b,c) (p)->LockRect(a,b,c) -#define IDirect3DSurface9_UnlockRect(p) (p)->UnlockRect() -#define IDirect3DSurface9_GetDC(p,a) (p)->GetDC(a) -#define IDirect3DSurface9_ReleaseDC(p,a) (p)->ReleaseDC(a) -#endif - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DVolume9 - -DECLARE_INTERFACE_(IDirect3DVolume9, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DVolume9 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; - STDMETHOD(GetDesc)(THIS_ D3DVOLUME_DESC *pDesc) PURE; - STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; - STDMETHOD(UnlockBox)(THIS) PURE; - - #ifdef D3D_DEBUG_INFO - LPCWSTR Name; - UINT Width; - UINT Height; - UINT Depth; - DWORD Usage; - D3DFORMAT Format; - D3DPOOL Pool; - UINT LockCount; - LPCWSTR CreationCallStack; - #endif -}; - -typedef struct IDirect3DVolume9 *LPDIRECT3DVOLUME9, *PDIRECT3DVOLUME9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVolume9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVolume9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVolume9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVolume9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DVolume9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DVolume9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DVolume9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DVolume9_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) -#define IDirect3DVolume9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#define IDirect3DVolume9_LockBox(p,a,b,c) (p)->lpVtbl->LockBox(p,a,b,c) -#define IDirect3DVolume9_UnlockBox(p) (p)->lpVtbl->UnlockBox(p) -#else -#define IDirect3DVolume9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVolume9_AddRef(p) (p)->AddRef() -#define IDirect3DVolume9_Release(p) (p)->Release() -#define IDirect3DVolume9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DVolume9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DVolume9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DVolume9_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DVolume9_GetContainer(p,a,b) (p)->GetContainer(a,b) -#define IDirect3DVolume9_GetDesc(p,a) (p)->GetDesc(a) -#define IDirect3DVolume9_LockBox(p,a,b,c) (p)->LockBox(a,b,c) -#define IDirect3DVolume9_UnlockBox(p) (p)->UnlockBox() -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DQuery9 - -DECLARE_INTERFACE_(IDirect3DQuery9, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DQuery9 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; - STDMETHOD_(D3DQUERYTYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, GetDataSize)(THIS) PURE; - STDMETHOD(Issue)(THIS_ DWORD dwIssueFlags) PURE; - STDMETHOD(GetData)(THIS_ void* pData,DWORD dwSize,DWORD dwGetDataFlags) PURE; - - #ifdef D3D_DEBUG_INFO - D3DQUERYTYPE Type; - DWORD DataSize; - LPCWSTR CreationCallStack; - #endif -}; - -typedef struct IDirect3DQuery9 *LPDIRECT3DQUERY9, *PDIRECT3DQUERY9; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DQuery9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DQuery9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DQuery9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DQuery9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DQuery9_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DQuery9_GetDataSize(p) (p)->lpVtbl->GetDataSize(p) -#define IDirect3DQuery9_Issue(p,a) (p)->lpVtbl->Issue(p,a) -#define IDirect3DQuery9_GetData(p,a,b,c) (p)->lpVtbl->GetData(p,a,b,c) -#else -#define IDirect3DQuery9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DQuery9_AddRef(p) (p)->AddRef() -#define IDirect3DQuery9_Release(p) (p)->Release() -#define IDirect3DQuery9_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DQuery9_GetType(p) (p)->GetType() -#define IDirect3DQuery9_GetDataSize(p) (p)->GetDataSize() -#define IDirect3DQuery9_Issue(p,a) (p)->Issue(a) -#define IDirect3DQuery9_GetData(p,a,b,c) (p)->GetData(a,b,c) -#endif - - -/**************************************************************************** - * Flags for SetPrivateData method on all D3D9 interfaces - * - * The passed pointer is an IUnknown ptr. The SizeOfData argument to SetPrivateData - * must be set to sizeof(IUnknown*). Direct3D will call AddRef through this - * pointer and Release when the private data is destroyed. The data will be - * destroyed when another SetPrivateData with the same GUID is set, when - * FreePrivateData is called, or when the D3D9 object is freed. - ****************************************************************************/ -#define D3DSPD_IUNKNOWN 0x00000001L - -/**************************************************************************** - * - * Flags for IDirect3D9::CreateDevice's BehaviorFlags - * - ****************************************************************************/ - -#define D3DCREATE_FPU_PRESERVE 0x00000002L -#define D3DCREATE_MULTITHREADED 0x00000004L - -#define D3DCREATE_PUREDEVICE 0x00000010L -#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020L -#define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040L -#define D3DCREATE_MIXED_VERTEXPROCESSING 0x00000080L - -#define D3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100L -#define D3DCREATE_ADAPTERGROUP_DEVICE 0x00000200L -#define D3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX 0x00000400L - -// This flag causes the D3D runtime not to alter the focus -// window in any way. Use with caution- the burden of supporting -// focus management events (alt-tab, etc.) falls on the -// application, and appropriate responses (switching display -// mode, etc.) should be coded. -#define D3DCREATE_NOWINDOWCHANGES 0x00000800L - - -/**************************************************************************** - * - * Parameter for IDirect3D9::CreateDevice's Adapter argument - * - ****************************************************************************/ - -#define D3DADAPTER_DEFAULT 0 - -/**************************************************************************** - * - * Flags for IDirect3D9::EnumAdapters - * - ****************************************************************************/ - -#define D3DENUM_WHQL_LEVEL 0x00000002L - -/**************************************************************************** - * - * Maximum number of back-buffers supported in DX9 - * - ****************************************************************************/ - -#define D3DPRESENT_BACK_BUFFERS_MAX 3L - -/**************************************************************************** - * - * Flags for IDirect3DDevice9::SetGammaRamp - * - ****************************************************************************/ - -#define D3DSGR_NO_CALIBRATION 0x00000000L -#define D3DSGR_CALIBRATE 0x00000001L - -/**************************************************************************** - * - * Flags for IDirect3DDevice9::SetCursorPosition - * - ****************************************************************************/ - -#define D3DCURSOR_IMMEDIATE_UPDATE 0x00000001L - -/**************************************************************************** - * - * Flags for IDirect3DSwapChain9::Present - * - ****************************************************************************/ - -#define D3DPRESENT_DONOTWAIT 0x00000001L -#define D3DPRESENT_LINEAR_CONTENT 0x00000002L - -/**************************************************************************** - * - * Flags for DrawPrimitive/DrawIndexedPrimitive - * Also valid for Begin/BeginIndexed - * Also valid for VertexBuffer::CreateVertexBuffer - ****************************************************************************/ - - -/* - * DirectDraw error codes - */ -#define _FACD3D 0x876 -#define MAKE_D3DHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code ) -#define MAKE_D3DSTATUS( code ) MAKE_HRESULT( 0, _FACD3D, code ) - -/* - * Direct3D Errors - */ -#define D3D_OK S_OK - -#define D3DERR_WRONGTEXTUREFORMAT MAKE_D3DHRESULT(2072) -#define D3DERR_UNSUPPORTEDCOLOROPERATION MAKE_D3DHRESULT(2073) -#define D3DERR_UNSUPPORTEDCOLORARG MAKE_D3DHRESULT(2074) -#define D3DERR_UNSUPPORTEDALPHAOPERATION MAKE_D3DHRESULT(2075) -#define D3DERR_UNSUPPORTEDALPHAARG MAKE_D3DHRESULT(2076) -#define D3DERR_TOOMANYOPERATIONS MAKE_D3DHRESULT(2077) -#define D3DERR_CONFLICTINGTEXTUREFILTER MAKE_D3DHRESULT(2078) -#define D3DERR_UNSUPPORTEDFACTORVALUE MAKE_D3DHRESULT(2079) -#define D3DERR_CONFLICTINGRENDERSTATE MAKE_D3DHRESULT(2081) -#define D3DERR_UNSUPPORTEDTEXTUREFILTER MAKE_D3DHRESULT(2082) -#define D3DERR_CONFLICTINGTEXTUREPALETTE MAKE_D3DHRESULT(2086) -#define D3DERR_DRIVERINTERNALERROR MAKE_D3DHRESULT(2087) - -#define D3DERR_NOTFOUND MAKE_D3DHRESULT(2150) -#define D3DERR_MOREDATA MAKE_D3DHRESULT(2151) -#define D3DERR_DEVICELOST MAKE_D3DHRESULT(2152) -#define D3DERR_DEVICENOTRESET MAKE_D3DHRESULT(2153) -#define D3DERR_NOTAVAILABLE MAKE_D3DHRESULT(2154) -#define D3DERR_OUTOFVIDEOMEMORY MAKE_D3DHRESULT(380) -#define D3DERR_INVALIDDEVICE MAKE_D3DHRESULT(2155) -#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156) -#define D3DERR_DRIVERINVALIDCALL MAKE_D3DHRESULT(2157) -#define D3DERR_WASSTILLDRAWING MAKE_D3DHRESULT(540) -#define D3DOK_NOAUTOGEN MAKE_D3DSTATUS(2159) - - -#ifdef __cplusplus -}; -#endif - -#endif /* (DIRECT3D_VERSION >= 0x0900) */ -#endif /* _D3D_H_ */ - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3d9.h + * Content: Direct3D include file + * + ****************************************************************************/ + +#ifndef _D3D9_H_ +#define _D3D9_H_ + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0900 +#endif //DIRECT3D_VERSION + +// include this file content only if compiling for DX9 interfaces +#if(DIRECT3D_VERSION >= 0x0900) + + +/* This identifier is passed to Direct3DCreate9 in order to ensure that an + * application was built against the correct header files. This number is + * incremented whenever a header (or other) change would require applications + * to be rebuilt. If the version doesn't match, Direct3DCreate9 will fail. + * (The number itself has no meaning.)*/ + +#ifdef D3D_DEBUG_INFO +#define D3D_SDK_VERSION (32 | 0x80000000) +#define D3D9b_SDK_VERSION (31 | 0x80000000) + +#else +#define D3D_SDK_VERSION 32 +#define D3D9b_SDK_VERSION 31 +#endif + + +#include + +#define COM_NO_WINDOWS_H +#include + +#include + +#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) + #define HMONITOR_DECLARED + DECLARE_HANDLE(HMONITOR); +#endif + +#define D3DAPI WINAPI + +/* + * Interface IID's + */ +#if defined( _WIN32 ) && !defined( _NO_COM) + +/* IID_IDirect3D9 */ +/* {81BDCBCA-64D4-426d-AE8D-AD0147F4275C} */ +DEFINE_GUID(IID_IDirect3D9, 0x81bdcbca, 0x64d4, 0x426d, 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c); + +/* IID_IDirect3DDevice9 */ +// {D0223B96-BF7A-43fd-92BD-A43B0D82B9EB} */ +DEFINE_GUID(IID_IDirect3DDevice9, 0xd0223b96, 0xbf7a, 0x43fd, 0x92, 0xbd, 0xa4, 0x3b, 0xd, 0x82, 0xb9, 0xeb); + +/* IID_IDirect3DResource9 */ +// {05EEC05D-8F7D-4362-B999-D1BAF357C704} +DEFINE_GUID(IID_IDirect3DResource9, 0x5eec05d, 0x8f7d, 0x4362, 0xb9, 0x99, 0xd1, 0xba, 0xf3, 0x57, 0xc7, 0x4); + +/* IID_IDirect3DBaseTexture9 */ +/* {580CA87E-1D3C-4d54-991D-B7D3E3C298CE} */ +DEFINE_GUID(IID_IDirect3DBaseTexture9, 0x580ca87e, 0x1d3c, 0x4d54, 0x99, 0x1d, 0xb7, 0xd3, 0xe3, 0xc2, 0x98, 0xce); + +/* IID_IDirect3DTexture9 */ +/* {85C31227-3DE5-4f00-9B3A-F11AC38C18B5} */ +DEFINE_GUID(IID_IDirect3DTexture9, 0x85c31227, 0x3de5, 0x4f00, 0x9b, 0x3a, 0xf1, 0x1a, 0xc3, 0x8c, 0x18, 0xb5); + +/* IID_IDirect3DCubeTexture9 */ +/* {FFF32F81-D953-473a-9223-93D652ABA93F} */ +DEFINE_GUID(IID_IDirect3DCubeTexture9, 0xfff32f81, 0xd953, 0x473a, 0x92, 0x23, 0x93, 0xd6, 0x52, 0xab, 0xa9, 0x3f); + +/* IID_IDirect3DVolumeTexture9 */ +/* {2518526C-E789-4111-A7B9-47EF328D13E6} */ +DEFINE_GUID(IID_IDirect3DVolumeTexture9, 0x2518526c, 0xe789, 0x4111, 0xa7, 0xb9, 0x47, 0xef, 0x32, 0x8d, 0x13, 0xe6); + +/* IID_IDirect3DVertexBuffer9 */ +/* {B64BB1B5-FD70-4df6-BF91-19D0A12455E3} */ +DEFINE_GUID(IID_IDirect3DVertexBuffer9, 0xb64bb1b5, 0xfd70, 0x4df6, 0xbf, 0x91, 0x19, 0xd0, 0xa1, 0x24, 0x55, 0xe3); + +/* IID_IDirect3DIndexBuffer9 */ +/* {7C9DD65E-D3F7-4529-ACEE-785830ACDE35} */ +DEFINE_GUID(IID_IDirect3DIndexBuffer9, 0x7c9dd65e, 0xd3f7, 0x4529, 0xac, 0xee, 0x78, 0x58, 0x30, 0xac, 0xde, 0x35); + +/* IID_IDirect3DSurface9 */ +/* {0CFBAF3A-9FF6-429a-99B3-A2796AF8B89B} */ +DEFINE_GUID(IID_IDirect3DSurface9, 0xcfbaf3a, 0x9ff6, 0x429a, 0x99, 0xb3, 0xa2, 0x79, 0x6a, 0xf8, 0xb8, 0x9b); + +/* IID_IDirect3DVolume9 */ +/* {24F416E6-1F67-4aa7-B88E-D33F6F3128A1} */ +DEFINE_GUID(IID_IDirect3DVolume9, 0x24f416e6, 0x1f67, 0x4aa7, 0xb8, 0x8e, 0xd3, 0x3f, 0x6f, 0x31, 0x28, 0xa1); + +/* IID_IDirect3DSwapChain9 */ +/* {794950F2-ADFC-458a-905E-10A10B0B503B} */ +DEFINE_GUID(IID_IDirect3DSwapChain9, 0x794950f2, 0xadfc, 0x458a, 0x90, 0x5e, 0x10, 0xa1, 0xb, 0xb, 0x50, 0x3b); + +/* IID_IDirect3DVertexDeclaration9 */ +/* {DD13C59C-36FA-4098-A8FB-C7ED39DC8546} */ +DEFINE_GUID(IID_IDirect3DVertexDeclaration9, 0xdd13c59c, 0x36fa, 0x4098, 0xa8, 0xfb, 0xc7, 0xed, 0x39, 0xdc, 0x85, 0x46); + +/* IID_IDirect3DVertexShader9 */ +/* {EFC5557E-6265-4613-8A94-43857889EB36} */ +DEFINE_GUID(IID_IDirect3DVertexShader9, 0xefc5557e, 0x6265, 0x4613, 0x8a, 0x94, 0x43, 0x85, 0x78, 0x89, 0xeb, 0x36); + +/* IID_IDirect3DPixelShader9 */ +/* {6D3BDBDC-5B02-4415-B852-CE5E8BCCB289} */ +DEFINE_GUID(IID_IDirect3DPixelShader9, 0x6d3bdbdc, 0x5b02, 0x4415, 0xb8, 0x52, 0xce, 0x5e, 0x8b, 0xcc, 0xb2, 0x89); + +/* IID_IDirect3DStateBlock9 */ +/* {B07C4FE5-310D-4ba8-A23C-4F0F206F218B} */ +DEFINE_GUID(IID_IDirect3DStateBlock9, 0xb07c4fe5, 0x310d, 0x4ba8, 0xa2, 0x3c, 0x4f, 0xf, 0x20, 0x6f, 0x21, 0x8b); + +/* IID_IDirect3DQuery9 */ +/* {d9771460-a695-4f26-bbd3-27b840b541cc} */ +DEFINE_GUID(IID_IDirect3DQuery9, 0xd9771460, 0xa695, 0x4f26, 0xbb, 0xd3, 0x27, 0xb8, 0x40, 0xb5, 0x41, 0xcc); + + +/* IID_HelperName */ +/* {E4A36723-FDFE-4b22-B146-3C04C07F4CC8} */ +DEFINE_GUID(IID_HelperName, 0xe4a36723, 0xfdfe, 0x4b22, 0xb1, 0x46, 0x3c, 0x4, 0xc0, 0x7f, 0x4c, 0xc8); + + +#endif + +#ifdef __cplusplus + +#ifndef DECLSPEC_UUID +#if _MSC_VER >= 1100 +#define DECLSPEC_UUID(x) __declspec(uuid(x)) +#else +#define DECLSPEC_UUID(x) +#endif +#endif + +interface DECLSPEC_UUID("81BDCBCA-64D4-426d-AE8D-AD0147F4275C") IDirect3D9; +interface DECLSPEC_UUID("D0223B96-BF7A-43fd-92BD-A43B0D82B9EB") IDirect3DDevice9; + +interface DECLSPEC_UUID("B07C4FE5-310D-4ba8-A23C-4F0F206F218B") IDirect3DStateBlock9; +interface DECLSPEC_UUID("05EEC05D-8F7D-4362-B999-D1BAF357C704") IDirect3DResource9; +interface DECLSPEC_UUID("DD13C59C-36FA-4098-A8FB-C7ED39DC8546") IDirect3DVertexDeclaration9; +interface DECLSPEC_UUID("EFC5557E-6265-4613-8A94-43857889EB36") IDirect3DVertexShader9; +interface DECLSPEC_UUID("6D3BDBDC-5B02-4415-B852-CE5E8BCCB289") IDirect3DPixelShader9; +interface DECLSPEC_UUID("580CA87E-1D3C-4d54-991D-B7D3E3C298CE") IDirect3DBaseTexture9; +interface DECLSPEC_UUID("85C31227-3DE5-4f00-9B3A-F11AC38C18B5") IDirect3DTexture9; +interface DECLSPEC_UUID("2518526C-E789-4111-A7B9-47EF328D13E6") IDirect3DVolumeTexture9; +interface DECLSPEC_UUID("FFF32F81-D953-473a-9223-93D652ABA93F") IDirect3DCubeTexture9; + +interface DECLSPEC_UUID("B64BB1B5-FD70-4df6-BF91-19D0A12455E3") IDirect3DVertexBuffer9; +interface DECLSPEC_UUID("7C9DD65E-D3F7-4529-ACEE-785830ACDE35") IDirect3DIndexBuffer9; + +interface DECLSPEC_UUID("0CFBAF3A-9FF6-429a-99B3-A2796AF8B89B") IDirect3DSurface9; +interface DECLSPEC_UUID("24F416E6-1F67-4aa7-B88E-D33F6F3128A1") IDirect3DVolume9; + +interface DECLSPEC_UUID("794950F2-ADFC-458a-905E-10A10B0B503B") IDirect3DSwapChain9; +interface DECLSPEC_UUID("d9771460-a695-4f26-bbd3-27b840b541cc") IDirect3DQuery9; + + +#if defined(_COM_SMARTPTR_TYPEDEF) +_COM_SMARTPTR_TYPEDEF(IDirect3D9, __uuidof(IDirect3D9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DDevice9, __uuidof(IDirect3DDevice9)); + +_COM_SMARTPTR_TYPEDEF(IDirect3DStateBlock9, __uuidof(IDirect3DStateBlock9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DResource9, __uuidof(IDirect3DResource9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DVertexDeclaration9, __uuidof(IDirect3DVertexDeclaration9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DVertexShader9, __uuidof(IDirect3DVertexShader9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DPixelShader9, __uuidof(IDirect3DPixelShader9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DBaseTexture9, __uuidof(IDirect3DBaseTexture9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DTexture9, __uuidof(IDirect3DTexture9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DVolumeTexture9, __uuidof(IDirect3DVolumeTexture9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DCubeTexture9, __uuidof(IDirect3DCubeTexture9)); + +_COM_SMARTPTR_TYPEDEF(IDirect3DVertexBuffer9, __uuidof(IDirect3DVertexBuffer9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DIndexBuffer9, __uuidof(IDirect3DIndexBuffer9)); + +_COM_SMARTPTR_TYPEDEF(IDirect3DSurface9, __uuidof(IDirect3DSurface9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DVolume9, __uuidof(IDirect3DVolume9)); + +_COM_SMARTPTR_TYPEDEF(IDirect3DSwapChain9, __uuidof(IDirect3DSwapChain9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DQuery9, __uuidof(IDirect3DQuery9)); + +#endif +#endif + + +typedef interface IDirect3D9 IDirect3D9; +typedef interface IDirect3DDevice9 IDirect3DDevice9; +typedef interface IDirect3DStateBlock9 IDirect3DStateBlock9; +typedef interface IDirect3DVertexDeclaration9 IDirect3DVertexDeclaration9; +typedef interface IDirect3DVertexShader9 IDirect3DVertexShader9; +typedef interface IDirect3DPixelShader9 IDirect3DPixelShader9; +typedef interface IDirect3DResource9 IDirect3DResource9; +typedef interface IDirect3DBaseTexture9 IDirect3DBaseTexture9; +typedef interface IDirect3DTexture9 IDirect3DTexture9; +typedef interface IDirect3DVolumeTexture9 IDirect3DVolumeTexture9; +typedef interface IDirect3DCubeTexture9 IDirect3DCubeTexture9; +typedef interface IDirect3DVertexBuffer9 IDirect3DVertexBuffer9; +typedef interface IDirect3DIndexBuffer9 IDirect3DIndexBuffer9; +typedef interface IDirect3DSurface9 IDirect3DSurface9; +typedef interface IDirect3DVolume9 IDirect3DVolume9; +typedef interface IDirect3DSwapChain9 IDirect3DSwapChain9; +typedef interface IDirect3DQuery9 IDirect3DQuery9; + + +#include "d3d9types.h" +#include "d3d9caps.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * DLL Function for creating a Direct3D9 object. This object supports + * enumeration and allows the creation of Direct3DDevice9 objects. + * Pass the value of the constant D3D_SDK_VERSION to this function, so + * that the run-time can validate that your application was compiled + * against the right headers. + */ + +IDirect3D9 * WINAPI Direct3DCreate9(UINT SDKVersion); + +/* + * Stubs for graphics profiling. + */ + +int WINAPI D3DPERF_BeginEvent( D3DCOLOR col, LPCWSTR wszName ); +int WINAPI D3DPERF_EndEvent( void ); +void WINAPI D3DPERF_SetMarker( D3DCOLOR col, LPCWSTR wszName ); +void WINAPI D3DPERF_SetRegion( D3DCOLOR col, LPCWSTR wszName ); +BOOL WINAPI D3DPERF_QueryRepeatFrame( void ); + +void WINAPI D3DPERF_SetOptions( DWORD dwOptions ); +DWORD WINAPI D3DPERF_GetStatus( void ); + +/* + * Direct3D interfaces + */ + + + + + + +#undef INTERFACE +#define INTERFACE IDirect3D9 + +DECLARE_INTERFACE_(IDirect3D9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3D9 methods ***/ + STDMETHOD(RegisterSoftwareDevice)(THIS_ void* pInitializeFunction) PURE; + STDMETHOD_(UINT, GetAdapterCount)(THIS) PURE; + STDMETHOD(GetAdapterIdentifier)(THIS_ UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier) PURE; + STDMETHOD_(UINT, GetAdapterModeCount)(THIS_ UINT Adapter,D3DFORMAT Format) PURE; + STDMETHOD(EnumAdapterModes)(THIS_ UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(GetAdapterDisplayMode)(THIS_ UINT Adapter,D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(CheckDeviceType)(THIS_ UINT Adapter,D3DDEVTYPE DevType,D3DFORMAT AdapterFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed) PURE; + STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) PURE; + STDMETHOD(CheckDeviceMultiSampleType)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels) PURE; + STDMETHOD(CheckDepthStencilMatch)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) PURE; + STDMETHOD(CheckDeviceFormatConversion)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat) PURE; + STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps) PURE; + STDMETHOD_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter) PURE; + STDMETHOD(CreateDevice)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) PURE; + + #ifdef D3D_DEBUG_INFO + LPCWSTR Version; + #endif +}; + +typedef struct IDirect3D9 *LPDIRECT3D9, *PDIRECT3D9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3D9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3D9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3D9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3D9_RegisterSoftwareDevice(p,a) (p)->lpVtbl->RegisterSoftwareDevice(p,a) +#define IDirect3D9_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p) +#define IDirect3D9_GetAdapterIdentifier(p,a,b,c) (p)->lpVtbl->GetAdapterIdentifier(p,a,b,c) +#define IDirect3D9_GetAdapterModeCount(p,a,b) (p)->lpVtbl->GetAdapterModeCount(p,a,b) +#define IDirect3D9_EnumAdapterModes(p,a,b,c,d) (p)->lpVtbl->EnumAdapterModes(p,a,b,c,d) +#define IDirect3D9_GetAdapterDisplayMode(p,a,b) (p)->lpVtbl->GetAdapterDisplayMode(p,a,b) +#define IDirect3D9_CheckDeviceType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceType(p,a,b,c,d,e) +#define IDirect3D9_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f) +#define IDirect3D9_CheckDeviceMultiSampleType(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceMultiSampleType(p,a,b,c,d,e,f) +#define IDirect3D9_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->lpVtbl->CheckDepthStencilMatch(p,a,b,c,d,e) +#define IDirect3D9_CheckDeviceFormatConversion(p,a,b,c,d) (p)->lpVtbl->CheckDeviceFormatConversion(p,a,b,c,d) +#define IDirect3D9_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c) +#define IDirect3D9_GetAdapterMonitor(p,a) (p)->lpVtbl->GetAdapterMonitor(p,a) +#define IDirect3D9_CreateDevice(p,a,b,c,d,e,f) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f) +#else +#define IDirect3D9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3D9_AddRef(p) (p)->AddRef() +#define IDirect3D9_Release(p) (p)->Release() +#define IDirect3D9_RegisterSoftwareDevice(p,a) (p)->RegisterSoftwareDevice(a) +#define IDirect3D9_GetAdapterCount(p) (p)->GetAdapterCount() +#define IDirect3D9_GetAdapterIdentifier(p,a,b,c) (p)->GetAdapterIdentifier(a,b,c) +#define IDirect3D9_GetAdapterModeCount(p,a,b) (p)->GetAdapterModeCount(a,b) +#define IDirect3D9_EnumAdapterModes(p,a,b,c,d) (p)->EnumAdapterModes(a,b,c,d) +#define IDirect3D9_GetAdapterDisplayMode(p,a,b) (p)->GetAdapterDisplayMode(a,b) +#define IDirect3D9_CheckDeviceType(p,a,b,c,d,e) (p)->CheckDeviceType(a,b,c,d,e) +#define IDirect3D9_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->CheckDeviceFormat(a,b,c,d,e,f) +#define IDirect3D9_CheckDeviceMultiSampleType(p,a,b,c,d,e,f) (p)->CheckDeviceMultiSampleType(a,b,c,d,e,f) +#define IDirect3D9_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->CheckDepthStencilMatch(a,b,c,d,e) +#define IDirect3D9_CheckDeviceFormatConversion(p,a,b,c,d) (p)->CheckDeviceFormatConversion(a,b,c,d) +#define IDirect3D9_GetDeviceCaps(p,a,b,c) (p)->GetDeviceCaps(a,b,c) +#define IDirect3D9_GetAdapterMonitor(p,a) (p)->GetAdapterMonitor(a) +#define IDirect3D9_CreateDevice(p,a,b,c,d,e,f) (p)->CreateDevice(a,b,c,d,e,f) +#endif + + + + + + + +/* SwapChain */ + + + + + + + + + + + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DDevice9 + +DECLARE_INTERFACE_(IDirect3DDevice9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DDevice9 methods ***/ + STDMETHOD(TestCooperativeLevel)(THIS) PURE; + STDMETHOD_(UINT, GetAvailableTextureMem)(THIS) PURE; + STDMETHOD(EvictManagedResources)(THIS) PURE; + STDMETHOD(GetDirect3D)(THIS_ IDirect3D9** ppD3D9) PURE; + STDMETHOD(GetDeviceCaps)(THIS_ D3DCAPS9* pCaps) PURE; + STDMETHOD(GetDisplayMode)(THIS_ UINT iSwapChain,D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(GetCreationParameters)(THIS_ D3DDEVICE_CREATION_PARAMETERS *pParameters) PURE; + STDMETHOD(SetCursorProperties)(THIS_ UINT XHotSpot,UINT YHotSpot,IDirect3DSurface9* pCursorBitmap) PURE; + STDMETHOD_(void, SetCursorPosition)(THIS_ int X,int Y,DWORD Flags) PURE; + STDMETHOD_(BOOL, ShowCursor)(THIS_ BOOL bShow) PURE; + STDMETHOD(CreateAdditionalSwapChain)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain9** pSwapChain) PURE; + STDMETHOD(GetSwapChain)(THIS_ UINT iSwapChain,IDirect3DSwapChain9** pSwapChain) PURE; + STDMETHOD_(UINT, GetNumberOfSwapChains)(THIS) PURE; + STDMETHOD(Reset)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; + STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; + STDMETHOD(GetBackBuffer)(THIS_ UINT iSwapChain,UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer) PURE; + STDMETHOD(GetRasterStatus)(THIS_ UINT iSwapChain,D3DRASTER_STATUS* pRasterStatus) PURE; + STDMETHOD(SetDialogBoxMode)(THIS_ BOOL bEnableDialogs) PURE; + STDMETHOD_(void, SetGammaRamp)(THIS_ UINT iSwapChain,DWORD Flags,CONST D3DGAMMARAMP* pRamp) PURE; + STDMETHOD_(void, GetGammaRamp)(THIS_ UINT iSwapChain,D3DGAMMARAMP* pRamp) PURE; + STDMETHOD(CreateTexture)(THIS_ UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture9** ppTexture,HANDLE* pSharedHandle) PURE; + STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture9** ppVolumeTexture,HANDLE* pSharedHandle) PURE; + STDMETHOD(CreateCubeTexture)(THIS_ UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture9** ppCubeTexture,HANDLE* pSharedHandle) PURE; + STDMETHOD(CreateVertexBuffer)(THIS_ UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer9** ppVertexBuffer,HANDLE* pSharedHandle) PURE; + STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer9** ppIndexBuffer,HANDLE* pSharedHandle) PURE; + STDMETHOD(CreateRenderTarget)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Lockable,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle) PURE; + STDMETHOD(CreateDepthStencilSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Discard,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle) PURE; + STDMETHOD(UpdateSurface)(THIS_ IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestinationSurface,CONST POINT* pDestPoint) PURE; + STDMETHOD(UpdateTexture)(THIS_ IDirect3DBaseTexture9* pSourceTexture,IDirect3DBaseTexture9* pDestinationTexture) PURE; + STDMETHOD(GetRenderTargetData)(THIS_ IDirect3DSurface9* pRenderTarget,IDirect3DSurface9* pDestSurface) PURE; + STDMETHOD(GetFrontBufferData)(THIS_ UINT iSwapChain,IDirect3DSurface9* pDestSurface) PURE; + STDMETHOD(StretchRect)(THIS_ IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect,D3DTEXTUREFILTERTYPE Filter) PURE; + STDMETHOD(ColorFill)(THIS_ IDirect3DSurface9* pSurface,CONST RECT* pRect,D3DCOLOR color) PURE; + STDMETHOD(CreateOffscreenPlainSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle) PURE; + STDMETHOD(SetRenderTarget)(THIS_ DWORD RenderTargetIndex,IDirect3DSurface9* pRenderTarget) PURE; + STDMETHOD(GetRenderTarget)(THIS_ DWORD RenderTargetIndex,IDirect3DSurface9** ppRenderTarget) PURE; + STDMETHOD(SetDepthStencilSurface)(THIS_ IDirect3DSurface9* pNewZStencil) PURE; + STDMETHOD(GetDepthStencilSurface)(THIS_ IDirect3DSurface9** ppZStencilSurface) PURE; + STDMETHOD(BeginScene)(THIS) PURE; + STDMETHOD(EndScene)(THIS) PURE; + STDMETHOD(Clear)(THIS_ DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil) PURE; + STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) PURE; + STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) PURE; + STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,CONST D3DMATRIX*) PURE; + STDMETHOD(SetViewport)(THIS_ CONST D3DVIEWPORT9* pViewport) PURE; + STDMETHOD(GetViewport)(THIS_ D3DVIEWPORT9* pViewport) PURE; + STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL9* pMaterial) PURE; + STDMETHOD(GetMaterial)(THIS_ D3DMATERIAL9* pMaterial) PURE; + STDMETHOD(SetLight)(THIS_ DWORD Index,CONST D3DLIGHT9*) PURE; + STDMETHOD(GetLight)(THIS_ DWORD Index,D3DLIGHT9*) PURE; + STDMETHOD(LightEnable)(THIS_ DWORD Index,BOOL Enable) PURE; + STDMETHOD(GetLightEnable)(THIS_ DWORD Index,BOOL* pEnable) PURE; + STDMETHOD(SetClipPlane)(THIS_ DWORD Index,CONST float* pPlane) PURE; + STDMETHOD(GetClipPlane)(THIS_ DWORD Index,float* pPlane) PURE; + STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD Value) PURE; + STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD* pValue) PURE; + STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type,IDirect3DStateBlock9** ppSB) PURE; + STDMETHOD(BeginStateBlock)(THIS) PURE; + STDMETHOD(EndStateBlock)(THIS_ IDirect3DStateBlock9** ppSB) PURE; + STDMETHOD(SetClipStatus)(THIS_ CONST D3DCLIPSTATUS9* pClipStatus) PURE; + STDMETHOD(GetClipStatus)(THIS_ D3DCLIPSTATUS9* pClipStatus) PURE; + STDMETHOD(GetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture9** ppTexture) PURE; + STDMETHOD(SetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture9* pTexture) PURE; + STDMETHOD(GetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) PURE; + STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE; + STDMETHOD(GetSamplerState)(THIS_ DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD* pValue) PURE; + STDMETHOD(SetSamplerState)(THIS_ DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD Value) PURE; + STDMETHOD(ValidateDevice)(THIS_ DWORD* pNumPasses) PURE; + STDMETHOD(SetPaletteEntries)(THIS_ UINT PaletteNumber,CONST PALETTEENTRY* pEntries) PURE; + STDMETHOD(GetPaletteEntries)(THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries) PURE; + STDMETHOD(SetCurrentTexturePalette)(THIS_ UINT PaletteNumber) PURE; + STDMETHOD(GetCurrentTexturePalette)(THIS_ UINT *PaletteNumber) PURE; + STDMETHOD(SetScissorRect)(THIS_ CONST RECT* pRect) PURE; + STDMETHOD(GetScissorRect)(THIS_ RECT* pRect) PURE; + STDMETHOD(SetSoftwareVertexProcessing)(THIS_ BOOL bSoftware) PURE; + STDMETHOD_(BOOL, GetSoftwareVertexProcessing)(THIS) PURE; + STDMETHOD(SetNPatchMode)(THIS_ float nSegments) PURE; + STDMETHOD_(float, GetNPatchMode)(THIS) PURE; + STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) PURE; + STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount) PURE; + STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; + STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; + STDMETHOD(ProcessVertices)(THIS_ UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer9* pDestBuffer,IDirect3DVertexDeclaration9* pVertexDecl,DWORD Flags) PURE; + STDMETHOD(CreateVertexDeclaration)(THIS_ CONST D3DVERTEXELEMENT9* pVertexElements,IDirect3DVertexDeclaration9** ppDecl) PURE; + STDMETHOD(SetVertexDeclaration)(THIS_ IDirect3DVertexDeclaration9* pDecl) PURE; + STDMETHOD(GetVertexDeclaration)(THIS_ IDirect3DVertexDeclaration9** ppDecl) PURE; + STDMETHOD(SetFVF)(THIS_ DWORD FVF) PURE; + STDMETHOD(GetFVF)(THIS_ DWORD* pFVF) PURE; + STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD* pFunction,IDirect3DVertexShader9** ppShader) PURE; + STDMETHOD(SetVertexShader)(THIS_ IDirect3DVertexShader9* pShader) PURE; + STDMETHOD(GetVertexShader)(THIS_ IDirect3DVertexShader9** ppShader) PURE; + STDMETHOD(SetVertexShaderConstantF)(THIS_ UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount) PURE; + STDMETHOD(GetVertexShaderConstantF)(THIS_ UINT StartRegister,float* pConstantData,UINT Vector4fCount) PURE; + STDMETHOD(SetVertexShaderConstantI)(THIS_ UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount) PURE; + STDMETHOD(GetVertexShaderConstantI)(THIS_ UINT StartRegister,int* pConstantData,UINT Vector4iCount) PURE; + STDMETHOD(SetVertexShaderConstantB)(THIS_ UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount) PURE; + STDMETHOD(GetVertexShaderConstantB)(THIS_ UINT StartRegister,BOOL* pConstantData,UINT BoolCount) PURE; + STDMETHOD(SetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride) PURE; + STDMETHOD(GetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer9** ppStreamData,UINT* pOffsetInBytes,UINT* pStride) PURE; + STDMETHOD(SetStreamSourceFreq)(THIS_ UINT StreamNumber,UINT Setting) PURE; + STDMETHOD(GetStreamSourceFreq)(THIS_ UINT StreamNumber,UINT* pSetting) PURE; + STDMETHOD(SetIndices)(THIS_ IDirect3DIndexBuffer9* pIndexData) PURE; + STDMETHOD(GetIndices)(THIS_ IDirect3DIndexBuffer9** ppIndexData) PURE; + STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction,IDirect3DPixelShader9** ppShader) PURE; + STDMETHOD(SetPixelShader)(THIS_ IDirect3DPixelShader9* pShader) PURE; + STDMETHOD(GetPixelShader)(THIS_ IDirect3DPixelShader9** ppShader) PURE; + STDMETHOD(SetPixelShaderConstantF)(THIS_ UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount) PURE; + STDMETHOD(GetPixelShaderConstantF)(THIS_ UINT StartRegister,float* pConstantData,UINT Vector4fCount) PURE; + STDMETHOD(SetPixelShaderConstantI)(THIS_ UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount) PURE; + STDMETHOD(GetPixelShaderConstantI)(THIS_ UINT StartRegister,int* pConstantData,UINT Vector4iCount) PURE; + STDMETHOD(SetPixelShaderConstantB)(THIS_ UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount) PURE; + STDMETHOD(GetPixelShaderConstantB)(THIS_ UINT StartRegister,BOOL* pConstantData,UINT BoolCount) PURE; + STDMETHOD(DrawRectPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) PURE; + STDMETHOD(DrawTriPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) PURE; + STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE; + STDMETHOD(CreateQuery)(THIS_ D3DQUERYTYPE Type,IDirect3DQuery9** ppQuery) PURE; + + #ifdef D3D_DEBUG_INFO + D3DDEVICE_CREATION_PARAMETERS CreationParameters; + D3DPRESENT_PARAMETERS PresentParameters; + D3DDISPLAYMODE DisplayMode; + D3DCAPS9 Caps; + + UINT AvailableTextureMem; + UINT SwapChains; + UINT Textures; + UINT VertexBuffers; + UINT IndexBuffers; + UINT VertexShaders; + UINT PixelShaders; + + D3DVIEWPORT9 Viewport; + D3DMATRIX ProjectionMatrix; + D3DMATRIX ViewMatrix; + D3DMATRIX WorldMatrix; + D3DMATRIX TextureMatrices[8]; + + DWORD FVF; + UINT VertexSize; + DWORD VertexShaderVersion; + DWORD PixelShaderVersion; + BOOL SoftwareVertexProcessing; + + D3DMATERIAL9 Material; + D3DLIGHT9 Lights[16]; + BOOL LightsEnabled[16]; + + D3DGAMMARAMP GammaRamp; + RECT ScissorRect; + BOOL DialogBoxMode; + #endif +}; + +typedef struct IDirect3DDevice9 *LPDIRECT3DDEVICE9, *PDIRECT3DDEVICE9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DDevice9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DDevice9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DDevice9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DDevice9_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) +#define IDirect3DDevice9_GetAvailableTextureMem(p) (p)->lpVtbl->GetAvailableTextureMem(p) +#define IDirect3DDevice9_EvictManagedResources(p) (p)->lpVtbl->EvictManagedResources(p) +#define IDirect3DDevice9_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) +#define IDirect3DDevice9_GetDeviceCaps(p,a) (p)->lpVtbl->GetDeviceCaps(p,a) +#define IDirect3DDevice9_GetDisplayMode(p,a,b) (p)->lpVtbl->GetDisplayMode(p,a,b) +#define IDirect3DDevice9_GetCreationParameters(p,a) (p)->lpVtbl->GetCreationParameters(p,a) +#define IDirect3DDevice9_SetCursorProperties(p,a,b,c) (p)->lpVtbl->SetCursorProperties(p,a,b,c) +#define IDirect3DDevice9_SetCursorPosition(p,a,b,c) (p)->lpVtbl->SetCursorPosition(p,a,b,c) +#define IDirect3DDevice9_ShowCursor(p,a) (p)->lpVtbl->ShowCursor(p,a) +#define IDirect3DDevice9_CreateAdditionalSwapChain(p,a,b) (p)->lpVtbl->CreateAdditionalSwapChain(p,a,b) +#define IDirect3DDevice9_GetSwapChain(p,a,b) (p)->lpVtbl->GetSwapChain(p,a,b) +#define IDirect3DDevice9_GetNumberOfSwapChains(p) (p)->lpVtbl->GetNumberOfSwapChains(p) +#define IDirect3DDevice9_Reset(p,a) (p)->lpVtbl->Reset(p,a) +#define IDirect3DDevice9_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) +#define IDirect3DDevice9_GetBackBuffer(p,a,b,c,d) (p)->lpVtbl->GetBackBuffer(p,a,b,c,d) +#define IDirect3DDevice9_GetRasterStatus(p,a,b) (p)->lpVtbl->GetRasterStatus(p,a,b) +#define IDirect3DDevice9_SetDialogBoxMode(p,a) (p)->lpVtbl->SetDialogBoxMode(p,a) +#define IDirect3DDevice9_SetGammaRamp(p,a,b,c) (p)->lpVtbl->SetGammaRamp(p,a,b,c) +#define IDirect3DDevice9_GetGammaRamp(p,a,b) (p)->lpVtbl->GetGammaRamp(p,a,b) +#define IDirect3DDevice9_CreateTexture(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateTexture(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_CreateVolumeTexture(p,a,b,c,d,e,f,g,h,i) (p)->lpVtbl->CreateVolumeTexture(p,a,b,c,d,e,f,g,h,i) +#define IDirect3DDevice9_CreateCubeTexture(p,a,b,c,d,e,f,g) (p)->lpVtbl->CreateCubeTexture(p,a,b,c,d,e,f,g) +#define IDirect3DDevice9_CreateVertexBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d,e,f) +#define IDirect3DDevice9_CreateIndexBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->CreateIndexBuffer(p,a,b,c,d,e,f) +#define IDirect3DDevice9_CreateRenderTarget(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateRenderTarget(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_CreateDepthStencilSurface(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateDepthStencilSurface(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_UpdateSurface(p,a,b,c,d) (p)->lpVtbl->UpdateSurface(p,a,b,c,d) +#define IDirect3DDevice9_UpdateTexture(p,a,b) (p)->lpVtbl->UpdateTexture(p,a,b) +#define IDirect3DDevice9_GetRenderTargetData(p,a,b) (p)->lpVtbl->GetRenderTargetData(p,a,b) +#define IDirect3DDevice9_GetFrontBufferData(p,a,b) (p)->lpVtbl->GetFrontBufferData(p,a,b) +#define IDirect3DDevice9_StretchRect(p,a,b,c,d,e) (p)->lpVtbl->StretchRect(p,a,b,c,d,e) +#define IDirect3DDevice9_ColorFill(p,a,b,c) (p)->lpVtbl->ColorFill(p,a,b,c) +#define IDirect3DDevice9_CreateOffscreenPlainSurface(p,a,b,c,d,e,f) (p)->lpVtbl->CreateOffscreenPlainSurface(p,a,b,c,d,e,f) +#define IDirect3DDevice9_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) +#define IDirect3DDevice9_GetRenderTarget(p,a,b) (p)->lpVtbl->GetRenderTarget(p,a,b) +#define IDirect3DDevice9_SetDepthStencilSurface(p,a) (p)->lpVtbl->SetDepthStencilSurface(p,a) +#define IDirect3DDevice9_GetDepthStencilSurface(p,a) (p)->lpVtbl->GetDepthStencilSurface(p,a) +#define IDirect3DDevice9_BeginScene(p) (p)->lpVtbl->BeginScene(p) +#define IDirect3DDevice9_EndScene(p) (p)->lpVtbl->EndScene(p) +#define IDirect3DDevice9_Clear(p,a,b,c,d,e,f) (p)->lpVtbl->Clear(p,a,b,c,d,e,f) +#define IDirect3DDevice9_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) +#define IDirect3DDevice9_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) +#define IDirect3DDevice9_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) +#define IDirect3DDevice9_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) +#define IDirect3DDevice9_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) +#define IDirect3DDevice9_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) +#define IDirect3DDevice9_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) +#define IDirect3DDevice9_SetLight(p,a,b) (p)->lpVtbl->SetLight(p,a,b) +#define IDirect3DDevice9_GetLight(p,a,b) (p)->lpVtbl->GetLight(p,a,b) +#define IDirect3DDevice9_LightEnable(p,a,b) (p)->lpVtbl->LightEnable(p,a,b) +#define IDirect3DDevice9_GetLightEnable(p,a,b) (p)->lpVtbl->GetLightEnable(p,a,b) +#define IDirect3DDevice9_SetClipPlane(p,a,b) (p)->lpVtbl->SetClipPlane(p,a,b) +#define IDirect3DDevice9_GetClipPlane(p,a,b) (p)->lpVtbl->GetClipPlane(p,a,b) +#define IDirect3DDevice9_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) +#define IDirect3DDevice9_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) +#define IDirect3DDevice9_CreateStateBlock(p,a,b) (p)->lpVtbl->CreateStateBlock(p,a,b) +#define IDirect3DDevice9_BeginStateBlock(p) (p)->lpVtbl->BeginStateBlock(p) +#define IDirect3DDevice9_EndStateBlock(p,a) (p)->lpVtbl->EndStateBlock(p,a) +#define IDirect3DDevice9_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) +#define IDirect3DDevice9_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) +#define IDirect3DDevice9_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) +#define IDirect3DDevice9_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) +#define IDirect3DDevice9_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) +#define IDirect3DDevice9_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) +#define IDirect3DDevice9_GetSamplerState(p,a,b,c) (p)->lpVtbl->GetSamplerState(p,a,b,c) +#define IDirect3DDevice9_SetSamplerState(p,a,b,c) (p)->lpVtbl->SetSamplerState(p,a,b,c) +#define IDirect3DDevice9_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a) +#define IDirect3DDevice9_SetPaletteEntries(p,a,b) (p)->lpVtbl->SetPaletteEntries(p,a,b) +#define IDirect3DDevice9_GetPaletteEntries(p,a,b) (p)->lpVtbl->GetPaletteEntries(p,a,b) +#define IDirect3DDevice9_SetCurrentTexturePalette(p,a) (p)->lpVtbl->SetCurrentTexturePalette(p,a) +#define IDirect3DDevice9_GetCurrentTexturePalette(p,a) (p)->lpVtbl->GetCurrentTexturePalette(p,a) +#define IDirect3DDevice9_SetScissorRect(p,a) (p)->lpVtbl->SetScissorRect(p,a) +#define IDirect3DDevice9_GetScissorRect(p,a) (p)->lpVtbl->GetScissorRect(p,a) +#define IDirect3DDevice9_SetSoftwareVertexProcessing(p,a) (p)->lpVtbl->SetSoftwareVertexProcessing(p,a) +#define IDirect3DDevice9_GetSoftwareVertexProcessing(p) (p)->lpVtbl->GetSoftwareVertexProcessing(p) +#define IDirect3DDevice9_SetNPatchMode(p,a) (p)->lpVtbl->SetNPatchMode(p,a) +#define IDirect3DDevice9_GetNPatchMode(p) (p)->lpVtbl->GetNPatchMode(p) +#define IDirect3DDevice9_DrawPrimitive(p,a,b,c) (p)->lpVtbl->DrawPrimitive(p,a,b,c) +#define IDirect3DDevice9_DrawIndexedPrimitive(p,a,b,c,d,e,f) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e,f) +#define IDirect3DDevice9_DrawPrimitiveUP(p,a,b,c,d) (p)->lpVtbl->DrawPrimitiveUP(p,a,b,c,d) +#define IDirect3DDevice9_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_ProcessVertices(p,a,b,c,d,e,f) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e,f) +#define IDirect3DDevice9_CreateVertexDeclaration(p,a,b) (p)->lpVtbl->CreateVertexDeclaration(p,a,b) +#define IDirect3DDevice9_SetVertexDeclaration(p,a) (p)->lpVtbl->SetVertexDeclaration(p,a) +#define IDirect3DDevice9_GetVertexDeclaration(p,a) (p)->lpVtbl->GetVertexDeclaration(p,a) +#define IDirect3DDevice9_SetFVF(p,a) (p)->lpVtbl->SetFVF(p,a) +#define IDirect3DDevice9_GetFVF(p,a) (p)->lpVtbl->GetFVF(p,a) +#define IDirect3DDevice9_CreateVertexShader(p,a,b) (p)->lpVtbl->CreateVertexShader(p,a,b) +#define IDirect3DDevice9_SetVertexShader(p,a) (p)->lpVtbl->SetVertexShader(p,a) +#define IDirect3DDevice9_GetVertexShader(p,a) (p)->lpVtbl->GetVertexShader(p,a) +#define IDirect3DDevice9_SetVertexShaderConstantF(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantF(p,a,b,c) +#define IDirect3DDevice9_GetVertexShaderConstantF(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantF(p,a,b,c) +#define IDirect3DDevice9_SetVertexShaderConstantI(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantI(p,a,b,c) +#define IDirect3DDevice9_GetVertexShaderConstantI(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantI(p,a,b,c) +#define IDirect3DDevice9_SetVertexShaderConstantB(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantB(p,a,b,c) +#define IDirect3DDevice9_GetVertexShaderConstantB(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantB(p,a,b,c) +#define IDirect3DDevice9_SetStreamSource(p,a,b,c,d) (p)->lpVtbl->SetStreamSource(p,a,b,c,d) +#define IDirect3DDevice9_GetStreamSource(p,a,b,c,d) (p)->lpVtbl->GetStreamSource(p,a,b,c,d) +#define IDirect3DDevice9_SetStreamSourceFreq(p,a,b) (p)->lpVtbl->SetStreamSourceFreq(p,a,b) +#define IDirect3DDevice9_GetStreamSourceFreq(p,a,b) (p)->lpVtbl->GetStreamSourceFreq(p,a,b) +#define IDirect3DDevice9_SetIndices(p,a) (p)->lpVtbl->SetIndices(p,a) +#define IDirect3DDevice9_GetIndices(p,a) (p)->lpVtbl->GetIndices(p,a) +#define IDirect3DDevice9_CreatePixelShader(p,a,b) (p)->lpVtbl->CreatePixelShader(p,a,b) +#define IDirect3DDevice9_SetPixelShader(p,a) (p)->lpVtbl->SetPixelShader(p,a) +#define IDirect3DDevice9_GetPixelShader(p,a) (p)->lpVtbl->GetPixelShader(p,a) +#define IDirect3DDevice9_SetPixelShaderConstantF(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantF(p,a,b,c) +#define IDirect3DDevice9_GetPixelShaderConstantF(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantF(p,a,b,c) +#define IDirect3DDevice9_SetPixelShaderConstantI(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantI(p,a,b,c) +#define IDirect3DDevice9_GetPixelShaderConstantI(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantI(p,a,b,c) +#define IDirect3DDevice9_SetPixelShaderConstantB(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantB(p,a,b,c) +#define IDirect3DDevice9_GetPixelShaderConstantB(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantB(p,a,b,c) +#define IDirect3DDevice9_DrawRectPatch(p,a,b,c) (p)->lpVtbl->DrawRectPatch(p,a,b,c) +#define IDirect3DDevice9_DrawTriPatch(p,a,b,c) (p)->lpVtbl->DrawTriPatch(p,a,b,c) +#define IDirect3DDevice9_DeletePatch(p,a) (p)->lpVtbl->DeletePatch(p,a) +#define IDirect3DDevice9_CreateQuery(p,a,b) (p)->lpVtbl->CreateQuery(p,a,b) +#else +#define IDirect3DDevice9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DDevice9_AddRef(p) (p)->AddRef() +#define IDirect3DDevice9_Release(p) (p)->Release() +#define IDirect3DDevice9_TestCooperativeLevel(p) (p)->TestCooperativeLevel() +#define IDirect3DDevice9_GetAvailableTextureMem(p) (p)->GetAvailableTextureMem() +#define IDirect3DDevice9_EvictManagedResources(p) (p)->EvictManagedResources() +#define IDirect3DDevice9_GetDirect3D(p,a) (p)->GetDirect3D(a) +#define IDirect3DDevice9_GetDeviceCaps(p,a) (p)->GetDeviceCaps(a) +#define IDirect3DDevice9_GetDisplayMode(p,a,b) (p)->GetDisplayMode(a,b) +#define IDirect3DDevice9_GetCreationParameters(p,a) (p)->GetCreationParameters(a) +#define IDirect3DDevice9_SetCursorProperties(p,a,b,c) (p)->SetCursorProperties(a,b,c) +#define IDirect3DDevice9_SetCursorPosition(p,a,b,c) (p)->SetCursorPosition(a,b,c) +#define IDirect3DDevice9_ShowCursor(p,a) (p)->ShowCursor(a) +#define IDirect3DDevice9_CreateAdditionalSwapChain(p,a,b) (p)->CreateAdditionalSwapChain(a,b) +#define IDirect3DDevice9_GetSwapChain(p,a,b) (p)->GetSwapChain(a,b) +#define IDirect3DDevice9_GetNumberOfSwapChains(p) (p)->GetNumberOfSwapChains() +#define IDirect3DDevice9_Reset(p,a) (p)->Reset(a) +#define IDirect3DDevice9_Present(p,a,b,c,d) (p)->Present(a,b,c,d) +#define IDirect3DDevice9_GetBackBuffer(p,a,b,c,d) (p)->GetBackBuffer(a,b,c,d) +#define IDirect3DDevice9_GetRasterStatus(p,a,b) (p)->GetRasterStatus(a,b) +#define IDirect3DDevice9_SetDialogBoxMode(p,a) (p)->SetDialogBoxMode(a) +#define IDirect3DDevice9_SetGammaRamp(p,a,b,c) (p)->SetGammaRamp(a,b,c) +#define IDirect3DDevice9_GetGammaRamp(p,a,b) (p)->GetGammaRamp(a,b) +#define IDirect3DDevice9_CreateTexture(p,a,b,c,d,e,f,g,h) (p)->CreateTexture(a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_CreateVolumeTexture(p,a,b,c,d,e,f,g,h,i) (p)->CreateVolumeTexture(a,b,c,d,e,f,g,h,i) +#define IDirect3DDevice9_CreateCubeTexture(p,a,b,c,d,e,f,g) (p)->CreateCubeTexture(a,b,c,d,e,f,g) +#define IDirect3DDevice9_CreateVertexBuffer(p,a,b,c,d,e,f) (p)->CreateVertexBuffer(a,b,c,d,e,f) +#define IDirect3DDevice9_CreateIndexBuffer(p,a,b,c,d,e,f) (p)->CreateIndexBuffer(a,b,c,d,e,f) +#define IDirect3DDevice9_CreateRenderTarget(p,a,b,c,d,e,f,g,h) (p)->CreateRenderTarget(a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_CreateDepthStencilSurface(p,a,b,c,d,e,f,g,h) (p)->CreateDepthStencilSurface(a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_UpdateSurface(p,a,b,c,d) (p)->UpdateSurface(a,b,c,d) +#define IDirect3DDevice9_UpdateTexture(p,a,b) (p)->UpdateTexture(a,b) +#define IDirect3DDevice9_GetRenderTargetData(p,a,b) (p)->GetRenderTargetData(a,b) +#define IDirect3DDevice9_GetFrontBufferData(p,a,b) (p)->GetFrontBufferData(a,b) +#define IDirect3DDevice9_StretchRect(p,a,b,c,d,e) (p)->StretchRect(a,b,c,d,e) +#define IDirect3DDevice9_ColorFill(p,a,b,c) (p)->ColorFill(a,b,c) +#define IDirect3DDevice9_CreateOffscreenPlainSurface(p,a,b,c,d,e,f) (p)->CreateOffscreenPlainSurface(a,b,c,d,e,f) +#define IDirect3DDevice9_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) +#define IDirect3DDevice9_GetRenderTarget(p,a,b) (p)->GetRenderTarget(a,b) +#define IDirect3DDevice9_SetDepthStencilSurface(p,a) (p)->SetDepthStencilSurface(a) +#define IDirect3DDevice9_GetDepthStencilSurface(p,a) (p)->GetDepthStencilSurface(a) +#define IDirect3DDevice9_BeginScene(p) (p)->BeginScene() +#define IDirect3DDevice9_EndScene(p) (p)->EndScene() +#define IDirect3DDevice9_Clear(p,a,b,c,d,e,f) (p)->Clear(a,b,c,d,e,f) +#define IDirect3DDevice9_SetTransform(p,a,b) (p)->SetTransform(a,b) +#define IDirect3DDevice9_GetTransform(p,a,b) (p)->GetTransform(a,b) +#define IDirect3DDevice9_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) +#define IDirect3DDevice9_SetViewport(p,a) (p)->SetViewport(a) +#define IDirect3DDevice9_GetViewport(p,a) (p)->GetViewport(a) +#define IDirect3DDevice9_SetMaterial(p,a) (p)->SetMaterial(a) +#define IDirect3DDevice9_GetMaterial(p,a) (p)->GetMaterial(a) +#define IDirect3DDevice9_SetLight(p,a,b) (p)->SetLight(a,b) +#define IDirect3DDevice9_GetLight(p,a,b) (p)->GetLight(a,b) +#define IDirect3DDevice9_LightEnable(p,a,b) (p)->LightEnable(a,b) +#define IDirect3DDevice9_GetLightEnable(p,a,b) (p)->GetLightEnable(a,b) +#define IDirect3DDevice9_SetClipPlane(p,a,b) (p)->SetClipPlane(a,b) +#define IDirect3DDevice9_GetClipPlane(p,a,b) (p)->GetClipPlane(a,b) +#define IDirect3DDevice9_SetRenderState(p,a,b) (p)->SetRenderState(a,b) +#define IDirect3DDevice9_GetRenderState(p,a,b) (p)->GetRenderState(a,b) +#define IDirect3DDevice9_CreateStateBlock(p,a,b) (p)->CreateStateBlock(a,b) +#define IDirect3DDevice9_BeginStateBlock(p) (p)->BeginStateBlock() +#define IDirect3DDevice9_EndStateBlock(p,a) (p)->EndStateBlock(a) +#define IDirect3DDevice9_SetClipStatus(p,a) (p)->SetClipStatus(a) +#define IDirect3DDevice9_GetClipStatus(p,a) (p)->GetClipStatus(a) +#define IDirect3DDevice9_GetTexture(p,a,b) (p)->GetTexture(a,b) +#define IDirect3DDevice9_SetTexture(p,a,b) (p)->SetTexture(a,b) +#define IDirect3DDevice9_GetTextureStageState(p,a,b,c) (p)->GetTextureStageState(a,b,c) +#define IDirect3DDevice9_SetTextureStageState(p,a,b,c) (p)->SetTextureStageState(a,b,c) +#define IDirect3DDevice9_GetSamplerState(p,a,b,c) (p)->GetSamplerState(a,b,c) +#define IDirect3DDevice9_SetSamplerState(p,a,b,c) (p)->SetSamplerState(a,b,c) +#define IDirect3DDevice9_ValidateDevice(p,a) (p)->ValidateDevice(a) +#define IDirect3DDevice9_SetPaletteEntries(p,a,b) (p)->SetPaletteEntries(a,b) +#define IDirect3DDevice9_GetPaletteEntries(p,a,b) (p)->GetPaletteEntries(a,b) +#define IDirect3DDevice9_SetCurrentTexturePalette(p,a) (p)->SetCurrentTexturePalette(a) +#define IDirect3DDevice9_GetCurrentTexturePalette(p,a) (p)->GetCurrentTexturePalette(a) +#define IDirect3DDevice9_SetScissorRect(p,a) (p)->SetScissorRect(a) +#define IDirect3DDevice9_GetScissorRect(p,a) (p)->GetScissorRect(a) +#define IDirect3DDevice9_SetSoftwareVertexProcessing(p,a) (p)->SetSoftwareVertexProcessing(a) +#define IDirect3DDevice9_GetSoftwareVertexProcessing(p) (p)->GetSoftwareVertexProcessing() +#define IDirect3DDevice9_SetNPatchMode(p,a) (p)->SetNPatchMode(a) +#define IDirect3DDevice9_GetNPatchMode(p) (p)->GetNPatchMode() +#define IDirect3DDevice9_DrawPrimitive(p,a,b,c) (p)->DrawPrimitive(a,b,c) +#define IDirect3DDevice9_DrawIndexedPrimitive(p,a,b,c,d,e,f) (p)->DrawIndexedPrimitive(a,b,c,d,e,f) +#define IDirect3DDevice9_DrawPrimitiveUP(p,a,b,c,d) (p)->DrawPrimitiveUP(a,b,c,d) +#define IDirect3DDevice9_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->DrawIndexedPrimitiveUP(a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_ProcessVertices(p,a,b,c,d,e,f) (p)->ProcessVertices(a,b,c,d,e,f) +#define IDirect3DDevice9_CreateVertexDeclaration(p,a,b) (p)->CreateVertexDeclaration(a,b) +#define IDirect3DDevice9_SetVertexDeclaration(p,a) (p)->SetVertexDeclaration(a) +#define IDirect3DDevice9_GetVertexDeclaration(p,a) (p)->GetVertexDeclaration(a) +#define IDirect3DDevice9_SetFVF(p,a) (p)->SetFVF(a) +#define IDirect3DDevice9_GetFVF(p,a) (p)->GetFVF(a) +#define IDirect3DDevice9_CreateVertexShader(p,a,b) (p)->CreateVertexShader(a,b) +#define IDirect3DDevice9_SetVertexShader(p,a) (p)->SetVertexShader(a) +#define IDirect3DDevice9_GetVertexShader(p,a) (p)->GetVertexShader(a) +#define IDirect3DDevice9_SetVertexShaderConstantF(p,a,b,c) (p)->SetVertexShaderConstantF(a,b,c) +#define IDirect3DDevice9_GetVertexShaderConstantF(p,a,b,c) (p)->GetVertexShaderConstantF(a,b,c) +#define IDirect3DDevice9_SetVertexShaderConstantI(p,a,b,c) (p)->SetVertexShaderConstantI(a,b,c) +#define IDirect3DDevice9_GetVertexShaderConstantI(p,a,b,c) (p)->GetVertexShaderConstantI(a,b,c) +#define IDirect3DDevice9_SetVertexShaderConstantB(p,a,b,c) (p)->SetVertexShaderConstantB(a,b,c) +#define IDirect3DDevice9_GetVertexShaderConstantB(p,a,b,c) (p)->GetVertexShaderConstantB(a,b,c) +#define IDirect3DDevice9_SetStreamSource(p,a,b,c,d) (p)->SetStreamSource(a,b,c,d) +#define IDirect3DDevice9_GetStreamSource(p,a,b,c,d) (p)->GetStreamSource(a,b,c,d) +#define IDirect3DDevice9_SetStreamSourceFreq(p,a,b) (p)->SetStreamSourceFreq(a,b) +#define IDirect3DDevice9_GetStreamSourceFreq(p,a,b) (p)->GetStreamSourceFreq(a,b) +#define IDirect3DDevice9_SetIndices(p,a) (p)->SetIndices(a) +#define IDirect3DDevice9_GetIndices(p,a) (p)->GetIndices(a) +#define IDirect3DDevice9_CreatePixelShader(p,a,b) (p)->CreatePixelShader(a,b) +#define IDirect3DDevice9_SetPixelShader(p,a) (p)->SetPixelShader(a) +#define IDirect3DDevice9_GetPixelShader(p,a) (p)->GetPixelShader(a) +#define IDirect3DDevice9_SetPixelShaderConstantF(p,a,b,c) (p)->SetPixelShaderConstantF(a,b,c) +#define IDirect3DDevice9_GetPixelShaderConstantF(p,a,b,c) (p)->GetPixelShaderConstantF(a,b,c) +#define IDirect3DDevice9_SetPixelShaderConstantI(p,a,b,c) (p)->SetPixelShaderConstantI(a,b,c) +#define IDirect3DDevice9_GetPixelShaderConstantI(p,a,b,c) (p)->GetPixelShaderConstantI(a,b,c) +#define IDirect3DDevice9_SetPixelShaderConstantB(p,a,b,c) (p)->SetPixelShaderConstantB(a,b,c) +#define IDirect3DDevice9_GetPixelShaderConstantB(p,a,b,c) (p)->GetPixelShaderConstantB(a,b,c) +#define IDirect3DDevice9_DrawRectPatch(p,a,b,c) (p)->DrawRectPatch(a,b,c) +#define IDirect3DDevice9_DrawTriPatch(p,a,b,c) (p)->DrawTriPatch(a,b,c) +#define IDirect3DDevice9_DeletePatch(p,a) (p)->DeletePatch(a) +#define IDirect3DDevice9_CreateQuery(p,a,b) (p)->CreateQuery(a,b) +#endif + + +#undef INTERFACE +#define INTERFACE IDirect3DStateBlock9 + +DECLARE_INTERFACE_(IDirect3DStateBlock9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DStateBlock9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(Capture)(THIS) PURE; + STDMETHOD(Apply)(THIS) PURE; + + #ifdef D3D_DEBUG_INFO + LPCWSTR CreationCallStack; + #endif +}; + +typedef struct IDirect3DStateBlock9 *LPDIRECT3DSTATEBLOCK9, *PDIRECT3DSTATEBLOCK9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DStateBlock9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DStateBlock9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DStateBlock9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DStateBlock9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DStateBlock9_Capture(p) (p)->lpVtbl->Capture(p) +#define IDirect3DStateBlock9_Apply(p) (p)->lpVtbl->Apply(p) +#else +#define IDirect3DStateBlock9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DStateBlock9_AddRef(p) (p)->AddRef() +#define IDirect3DStateBlock9_Release(p) (p)->Release() +#define IDirect3DStateBlock9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DStateBlock9_Capture(p) (p)->Capture() +#define IDirect3DStateBlock9_Apply(p) (p)->Apply() +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DSwapChain9 + +DECLARE_INTERFACE_(IDirect3DSwapChain9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DSwapChain9 methods ***/ + STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion,DWORD dwFlags) PURE; + STDMETHOD(GetFrontBufferData)(THIS_ IDirect3DSurface9* pDestSurface) PURE; + STDMETHOD(GetBackBuffer)(THIS_ UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer) PURE; + STDMETHOD(GetRasterStatus)(THIS_ D3DRASTER_STATUS* pRasterStatus) PURE; + STDMETHOD(GetDisplayMode)(THIS_ D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(GetPresentParameters)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; + + #ifdef D3D_DEBUG_INFO + D3DPRESENT_PARAMETERS PresentParameters; + D3DDISPLAYMODE DisplayMode; + LPCWSTR CreationCallStack; + #endif +}; + +typedef struct IDirect3DSwapChain9 *LPDIRECT3DSWAPCHAIN9, *PDIRECT3DSWAPCHAIN9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DSwapChain9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DSwapChain9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DSwapChain9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DSwapChain9_Present(p,a,b,c,d,e) (p)->lpVtbl->Present(p,a,b,c,d,e) +#define IDirect3DSwapChain9_GetFrontBufferData(p,a) (p)->lpVtbl->GetFrontBufferData(p,a) +#define IDirect3DSwapChain9_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) +#define IDirect3DSwapChain9_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a) +#define IDirect3DSwapChain9_GetDisplayMode(p,a) (p)->lpVtbl->GetDisplayMode(p,a) +#define IDirect3DSwapChain9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DSwapChain9_GetPresentParameters(p,a) (p)->lpVtbl->GetPresentParameters(p,a) +#else +#define IDirect3DSwapChain9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DSwapChain9_AddRef(p) (p)->AddRef() +#define IDirect3DSwapChain9_Release(p) (p)->Release() +#define IDirect3DSwapChain9_Present(p,a,b,c,d,e) (p)->Present(a,b,c,d,e) +#define IDirect3DSwapChain9_GetFrontBufferData(p,a) (p)->GetFrontBufferData(a) +#define IDirect3DSwapChain9_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) +#define IDirect3DSwapChain9_GetRasterStatus(p,a) (p)->GetRasterStatus(a) +#define IDirect3DSwapChain9_GetDisplayMode(p,a) (p)->GetDisplayMode(a) +#define IDirect3DSwapChain9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DSwapChain9_GetPresentParameters(p,a) (p)->GetPresentParameters(a) +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DResource9 + +DECLARE_INTERFACE_(IDirect3DResource9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; +}; + +typedef struct IDirect3DResource9 *LPDIRECT3DRESOURCE9, *PDIRECT3DRESOURCE9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DResource9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DResource9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DResource9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DResource9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DResource9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DResource9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DResource9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DResource9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DResource9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DResource9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DResource9_GetType(p) (p)->lpVtbl->GetType(p) +#else +#define IDirect3DResource9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DResource9_AddRef(p) (p)->AddRef() +#define IDirect3DResource9_Release(p) (p)->Release() +#define IDirect3DResource9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DResource9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DResource9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DResource9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DResource9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DResource9_GetPriority(p) (p)->GetPriority() +#define IDirect3DResource9_PreLoad(p) (p)->PreLoad() +#define IDirect3DResource9_GetType(p) (p)->GetType() +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVertexDeclaration9 + +DECLARE_INTERFACE_(IDirect3DVertexDeclaration9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DVertexDeclaration9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9* pElement,UINT* pNumElements) PURE; + + #ifdef D3D_DEBUG_INFO + LPCWSTR CreationCallStack; + #endif +}; + +typedef struct IDirect3DVertexDeclaration9 *LPDIRECT3DVERTEXDECLARATION9, *PDIRECT3DVERTEXDECLARATION9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVertexDeclaration9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVertexDeclaration9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVertexDeclaration9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVertexDeclaration9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVertexDeclaration9_GetDeclaration(p,a,b) (p)->lpVtbl->GetDeclaration(p,a,b) +#else +#define IDirect3DVertexDeclaration9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVertexDeclaration9_AddRef(p) (p)->AddRef() +#define IDirect3DVertexDeclaration9_Release(p) (p)->Release() +#define IDirect3DVertexDeclaration9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVertexDeclaration9_GetDeclaration(p,a,b) (p)->GetDeclaration(a,b) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVertexShader9 + +DECLARE_INTERFACE_(IDirect3DVertexShader9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DVertexShader9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(GetFunction)(THIS_ void*,UINT* pSizeOfData) PURE; + + #ifdef D3D_DEBUG_INFO + DWORD Version; + LPCWSTR CreationCallStack; + #endif +}; + +typedef struct IDirect3DVertexShader9 *LPDIRECT3DVERTEXSHADER9, *PDIRECT3DVERTEXSHADER9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVertexShader9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVertexShader9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVertexShader9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVertexShader9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVertexShader9_GetFunction(p,a,b) (p)->lpVtbl->GetFunction(p,a,b) +#else +#define IDirect3DVertexShader9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVertexShader9_AddRef(p) (p)->AddRef() +#define IDirect3DVertexShader9_Release(p) (p)->Release() +#define IDirect3DVertexShader9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVertexShader9_GetFunction(p,a,b) (p)->GetFunction(a,b) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DPixelShader9 + +DECLARE_INTERFACE_(IDirect3DPixelShader9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DPixelShader9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(GetFunction)(THIS_ void*,UINT* pSizeOfData) PURE; + + #ifdef D3D_DEBUG_INFO + DWORD Version; + LPCWSTR CreationCallStack; + #endif +}; + +typedef struct IDirect3DPixelShader9 *LPDIRECT3DPIXELSHADER9, *PDIRECT3DPIXELSHADER9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DPixelShader9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DPixelShader9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DPixelShader9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DPixelShader9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DPixelShader9_GetFunction(p,a,b) (p)->lpVtbl->GetFunction(p,a,b) +#else +#define IDirect3DPixelShader9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DPixelShader9_AddRef(p) (p)->AddRef() +#define IDirect3DPixelShader9_Release(p) (p)->Release() +#define IDirect3DPixelShader9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DPixelShader9_GetFunction(p,a,b) (p)->GetFunction(a,b) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DBaseTexture9 + +DECLARE_INTERFACE_(IDirect3DBaseTexture9, IDirect3DResource9) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType) PURE; + STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS) PURE; + STDMETHOD_(void, GenerateMipSubLevels)(THIS) PURE; +}; + +typedef struct IDirect3DBaseTexture9 *LPDIRECT3DBASETEXTURE9, *PDIRECT3DBASETEXTURE9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DBaseTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DBaseTexture9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DBaseTexture9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DBaseTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DBaseTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DBaseTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DBaseTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DBaseTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DBaseTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DBaseTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DBaseTexture9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DBaseTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DBaseTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DBaseTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DBaseTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a) +#define IDirect3DBaseTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p) +#define IDirect3DBaseTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p) +#else +#define IDirect3DBaseTexture9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DBaseTexture9_AddRef(p) (p)->AddRef() +#define IDirect3DBaseTexture9_Release(p) (p)->Release() +#define IDirect3DBaseTexture9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DBaseTexture9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DBaseTexture9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DBaseTexture9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DBaseTexture9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DBaseTexture9_GetPriority(p) (p)->GetPriority() +#define IDirect3DBaseTexture9_PreLoad(p) (p)->PreLoad() +#define IDirect3DBaseTexture9_GetType(p) (p)->GetType() +#define IDirect3DBaseTexture9_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DBaseTexture9_GetLOD(p) (p)->GetLOD() +#define IDirect3DBaseTexture9_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DBaseTexture9_SetAutoGenFilterType(p,a) (p)->SetAutoGenFilterType(a) +#define IDirect3DBaseTexture9_GetAutoGenFilterType(p) (p)->GetAutoGenFilterType() +#define IDirect3DBaseTexture9_GenerateMipSubLevels(p) (p)->GenerateMipSubLevels() +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DTexture9 + +DECLARE_INTERFACE_(IDirect3DTexture9, IDirect3DBaseTexture9) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType) PURE; + STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS) PURE; + STDMETHOD_(void, GenerateMipSubLevels)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(GetSurfaceLevel)(THIS_ UINT Level,IDirect3DSurface9** ppSurfaceLevel) PURE; + STDMETHOD(LockRect)(THIS_ UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS_ UINT Level) PURE; + STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pDirtyRect) PURE; + + #ifdef D3D_DEBUG_INFO + LPCWSTR Name; + UINT Width; + UINT Height; + UINT Levels; + DWORD Usage; + D3DFORMAT Format; + D3DPOOL Pool; + DWORD Priority; + DWORD LOD; + D3DTEXTUREFILTERTYPE FilterType; + UINT LockCount; + LPCWSTR CreationCallStack; + #endif +}; + +typedef struct IDirect3DTexture9 *LPDIRECT3DTEXTURE9, *PDIRECT3DTEXTURE9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DTexture9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DTexture9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DTexture9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a) +#define IDirect3DTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p) +#define IDirect3DTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p) +#define IDirect3DTexture9_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DTexture9_GetSurfaceLevel(p,a,b) (p)->lpVtbl->GetSurfaceLevel(p,a,b) +#define IDirect3DTexture9_LockRect(p,a,b,c,d) (p)->lpVtbl->LockRect(p,a,b,c,d) +#define IDirect3DTexture9_UnlockRect(p,a) (p)->lpVtbl->UnlockRect(p,a) +#define IDirect3DTexture9_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a) +#else +#define IDirect3DTexture9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DTexture9_AddRef(p) (p)->AddRef() +#define IDirect3DTexture9_Release(p) (p)->Release() +#define IDirect3DTexture9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DTexture9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DTexture9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DTexture9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DTexture9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DTexture9_GetPriority(p) (p)->GetPriority() +#define IDirect3DTexture9_PreLoad(p) (p)->PreLoad() +#define IDirect3DTexture9_GetType(p) (p)->GetType() +#define IDirect3DTexture9_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DTexture9_GetLOD(p) (p)->GetLOD() +#define IDirect3DTexture9_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DTexture9_SetAutoGenFilterType(p,a) (p)->SetAutoGenFilterType(a) +#define IDirect3DTexture9_GetAutoGenFilterType(p) (p)->GetAutoGenFilterType() +#define IDirect3DTexture9_GenerateMipSubLevels(p) (p)->GenerateMipSubLevels() +#define IDirect3DTexture9_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DTexture9_GetSurfaceLevel(p,a,b) (p)->GetSurfaceLevel(a,b) +#define IDirect3DTexture9_LockRect(p,a,b,c,d) (p)->LockRect(a,b,c,d) +#define IDirect3DTexture9_UnlockRect(p,a) (p)->UnlockRect(a) +#define IDirect3DTexture9_AddDirtyRect(p,a) (p)->AddDirtyRect(a) +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVolumeTexture9 + +DECLARE_INTERFACE_(IDirect3DVolumeTexture9, IDirect3DBaseTexture9) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType) PURE; + STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS) PURE; + STDMETHOD_(void, GenerateMipSubLevels)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DVOLUME_DESC *pDesc) PURE; + STDMETHOD(GetVolumeLevel)(THIS_ UINT Level,IDirect3DVolume9** ppVolumeLevel) PURE; + STDMETHOD(LockBox)(THIS_ UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; + STDMETHOD(UnlockBox)(THIS_ UINT Level) PURE; + STDMETHOD(AddDirtyBox)(THIS_ CONST D3DBOX* pDirtyBox) PURE; + + #ifdef D3D_DEBUG_INFO + LPCWSTR Name; + UINT Width; + UINT Height; + UINT Depth; + UINT Levels; + DWORD Usage; + D3DFORMAT Format; + D3DPOOL Pool; + DWORD Priority; + DWORD LOD; + D3DTEXTUREFILTERTYPE FilterType; + UINT LockCount; + LPCWSTR CreationCallStack; + #endif +}; + +typedef struct IDirect3DVolumeTexture9 *LPDIRECT3DVOLUMETEXTURE9, *PDIRECT3DVOLUMETEXTURE9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVolumeTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVolumeTexture9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVolumeTexture9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVolumeTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVolumeTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVolumeTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVolumeTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVolumeTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DVolumeTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DVolumeTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DVolumeTexture9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DVolumeTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DVolumeTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DVolumeTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DVolumeTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a) +#define IDirect3DVolumeTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p) +#define IDirect3DVolumeTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p) +#define IDirect3DVolumeTexture9_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DVolumeTexture9_GetVolumeLevel(p,a,b) (p)->lpVtbl->GetVolumeLevel(p,a,b) +#define IDirect3DVolumeTexture9_LockBox(p,a,b,c,d) (p)->lpVtbl->LockBox(p,a,b,c,d) +#define IDirect3DVolumeTexture9_UnlockBox(p,a) (p)->lpVtbl->UnlockBox(p,a) +#define IDirect3DVolumeTexture9_AddDirtyBox(p,a) (p)->lpVtbl->AddDirtyBox(p,a) +#else +#define IDirect3DVolumeTexture9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVolumeTexture9_AddRef(p) (p)->AddRef() +#define IDirect3DVolumeTexture9_Release(p) (p)->Release() +#define IDirect3DVolumeTexture9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVolumeTexture9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVolumeTexture9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVolumeTexture9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVolumeTexture9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DVolumeTexture9_GetPriority(p) (p)->GetPriority() +#define IDirect3DVolumeTexture9_PreLoad(p) (p)->PreLoad() +#define IDirect3DVolumeTexture9_GetType(p) (p)->GetType() +#define IDirect3DVolumeTexture9_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DVolumeTexture9_GetLOD(p) (p)->GetLOD() +#define IDirect3DVolumeTexture9_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DVolumeTexture9_SetAutoGenFilterType(p,a) (p)->SetAutoGenFilterType(a) +#define IDirect3DVolumeTexture9_GetAutoGenFilterType(p) (p)->GetAutoGenFilterType() +#define IDirect3DVolumeTexture9_GenerateMipSubLevels(p) (p)->GenerateMipSubLevels() +#define IDirect3DVolumeTexture9_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DVolumeTexture9_GetVolumeLevel(p,a,b) (p)->GetVolumeLevel(a,b) +#define IDirect3DVolumeTexture9_LockBox(p,a,b,c,d) (p)->LockBox(a,b,c,d) +#define IDirect3DVolumeTexture9_UnlockBox(p,a) (p)->UnlockBox(a) +#define IDirect3DVolumeTexture9_AddDirtyBox(p,a) (p)->AddDirtyBox(a) +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DCubeTexture9 + +DECLARE_INTERFACE_(IDirect3DCubeTexture9, IDirect3DBaseTexture9) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType) PURE; + STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS) PURE; + STDMETHOD_(void, GenerateMipSubLevels)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(GetCubeMapSurface)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface9** ppCubeMapSurface) PURE; + STDMETHOD(LockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level) PURE; + STDMETHOD(AddDirtyRect)(THIS_ D3DCUBEMAP_FACES FaceType,CONST RECT* pDirtyRect) PURE; + + #ifdef D3D_DEBUG_INFO + LPCWSTR Name; + UINT Width; + UINT Height; + UINT Levels; + DWORD Usage; + D3DFORMAT Format; + D3DPOOL Pool; + DWORD Priority; + DWORD LOD; + D3DTEXTUREFILTERTYPE FilterType; + UINT LockCount; + LPCWSTR CreationCallStack; + #endif +}; + +typedef struct IDirect3DCubeTexture9 *LPDIRECT3DCUBETEXTURE9, *PDIRECT3DCUBETEXTURE9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DCubeTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DCubeTexture9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DCubeTexture9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DCubeTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DCubeTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DCubeTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DCubeTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DCubeTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DCubeTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DCubeTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DCubeTexture9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DCubeTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DCubeTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DCubeTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DCubeTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a) +#define IDirect3DCubeTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p) +#define IDirect3DCubeTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p) +#define IDirect3DCubeTexture9_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DCubeTexture9_GetCubeMapSurface(p,a,b,c) (p)->lpVtbl->GetCubeMapSurface(p,a,b,c) +#define IDirect3DCubeTexture9_LockRect(p,a,b,c,d,e) (p)->lpVtbl->LockRect(p,a,b,c,d,e) +#define IDirect3DCubeTexture9_UnlockRect(p,a,b) (p)->lpVtbl->UnlockRect(p,a,b) +#define IDirect3DCubeTexture9_AddDirtyRect(p,a,b) (p)->lpVtbl->AddDirtyRect(p,a,b) +#else +#define IDirect3DCubeTexture9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DCubeTexture9_AddRef(p) (p)->AddRef() +#define IDirect3DCubeTexture9_Release(p) (p)->Release() +#define IDirect3DCubeTexture9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DCubeTexture9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DCubeTexture9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DCubeTexture9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DCubeTexture9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DCubeTexture9_GetPriority(p) (p)->GetPriority() +#define IDirect3DCubeTexture9_PreLoad(p) (p)->PreLoad() +#define IDirect3DCubeTexture9_GetType(p) (p)->GetType() +#define IDirect3DCubeTexture9_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DCubeTexture9_GetLOD(p) (p)->GetLOD() +#define IDirect3DCubeTexture9_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DCubeTexture9_SetAutoGenFilterType(p,a) (p)->SetAutoGenFilterType(a) +#define IDirect3DCubeTexture9_GetAutoGenFilterType(p) (p)->GetAutoGenFilterType() +#define IDirect3DCubeTexture9_GenerateMipSubLevels(p) (p)->GenerateMipSubLevels() +#define IDirect3DCubeTexture9_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DCubeTexture9_GetCubeMapSurface(p,a,b,c) (p)->GetCubeMapSurface(a,b,c) +#define IDirect3DCubeTexture9_LockRect(p,a,b,c,d,e) (p)->LockRect(a,b,c,d,e) +#define IDirect3DCubeTexture9_UnlockRect(p,a,b) (p)->UnlockRect(a,b) +#define IDirect3DCubeTexture9_AddDirtyRect(p,a,b) (p)->AddDirtyRect(a,b) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVertexBuffer9 + +DECLARE_INTERFACE_(IDirect3DVertexBuffer9, IDirect3DResource9) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3DVERTEXBUFFER_DESC *pDesc) PURE; + + #ifdef D3D_DEBUG_INFO + LPCWSTR Name; + UINT Length; + DWORD Usage; + DWORD FVF; + D3DPOOL Pool; + DWORD Priority; + UINT LockCount; + LPCWSTR CreationCallStack; + #endif +}; + +typedef struct IDirect3DVertexBuffer9 *LPDIRECT3DVERTEXBUFFER9, *PDIRECT3DVERTEXBUFFER9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVertexBuffer9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVertexBuffer9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVertexBuffer9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVertexBuffer9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVertexBuffer9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVertexBuffer9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVertexBuffer9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVertexBuffer9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DVertexBuffer9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DVertexBuffer9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DVertexBuffer9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DVertexBuffer9_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirect3DVertexBuffer9_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DVertexBuffer9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#else +#define IDirect3DVertexBuffer9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVertexBuffer9_AddRef(p) (p)->AddRef() +#define IDirect3DVertexBuffer9_Release(p) (p)->Release() +#define IDirect3DVertexBuffer9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVertexBuffer9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVertexBuffer9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVertexBuffer9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVertexBuffer9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DVertexBuffer9_GetPriority(p) (p)->GetPriority() +#define IDirect3DVertexBuffer9_PreLoad(p) (p)->PreLoad() +#define IDirect3DVertexBuffer9_GetType(p) (p)->GetType() +#define IDirect3DVertexBuffer9_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirect3DVertexBuffer9_Unlock(p) (p)->Unlock() +#define IDirect3DVertexBuffer9_GetDesc(p,a) (p)->GetDesc(a) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DIndexBuffer9 + +DECLARE_INTERFACE_(IDirect3DIndexBuffer9, IDirect3DResource9) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3DINDEXBUFFER_DESC *pDesc) PURE; + + #ifdef D3D_DEBUG_INFO + LPCWSTR Name; + UINT Length; + DWORD Usage; + D3DFORMAT Format; + D3DPOOL Pool; + DWORD Priority; + UINT LockCount; + LPCWSTR CreationCallStack; + #endif +}; + +typedef struct IDirect3DIndexBuffer9 *LPDIRECT3DINDEXBUFFER9, *PDIRECT3DINDEXBUFFER9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DIndexBuffer9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DIndexBuffer9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DIndexBuffer9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DIndexBuffer9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DIndexBuffer9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DIndexBuffer9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DIndexBuffer9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DIndexBuffer9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DIndexBuffer9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DIndexBuffer9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DIndexBuffer9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DIndexBuffer9_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirect3DIndexBuffer9_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DIndexBuffer9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#else +#define IDirect3DIndexBuffer9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DIndexBuffer9_AddRef(p) (p)->AddRef() +#define IDirect3DIndexBuffer9_Release(p) (p)->Release() +#define IDirect3DIndexBuffer9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DIndexBuffer9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DIndexBuffer9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DIndexBuffer9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DIndexBuffer9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DIndexBuffer9_GetPriority(p) (p)->GetPriority() +#define IDirect3DIndexBuffer9_PreLoad(p) (p)->PreLoad() +#define IDirect3DIndexBuffer9_GetType(p) (p)->GetType() +#define IDirect3DIndexBuffer9_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirect3DIndexBuffer9_Unlock(p) (p)->Unlock() +#define IDirect3DIndexBuffer9_GetDesc(p,a) (p)->GetDesc(a) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DSurface9 + +DECLARE_INTERFACE_(IDirect3DSurface9, IDirect3DResource9) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; + STDMETHOD(GetDesc)(THIS_ D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(LockRect)(THIS_ D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS) PURE; + STDMETHOD(GetDC)(THIS_ HDC *phdc) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC hdc) PURE; + + #ifdef D3D_DEBUG_INFO + LPCWSTR Name; + UINT Width; + UINT Height; + DWORD Usage; + D3DFORMAT Format; + D3DPOOL Pool; + D3DMULTISAMPLE_TYPE MultiSampleType; + DWORD MultiSampleQuality; + DWORD Priority; + UINT LockCount; + UINT DCCount; + LPCWSTR CreationCallStack; + #endif +}; + +typedef struct IDirect3DSurface9 *LPDIRECT3DSURFACE9, *PDIRECT3DSURFACE9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DSurface9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DSurface9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DSurface9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DSurface9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DSurface9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DSurface9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DSurface9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DSurface9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DSurface9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DSurface9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DSurface9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DSurface9_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) +#define IDirect3DSurface9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#define IDirect3DSurface9_LockRect(p,a,b,c) (p)->lpVtbl->LockRect(p,a,b,c) +#define IDirect3DSurface9_UnlockRect(p) (p)->lpVtbl->UnlockRect(p) +#define IDirect3DSurface9_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirect3DSurface9_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#else +#define IDirect3DSurface9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DSurface9_AddRef(p) (p)->AddRef() +#define IDirect3DSurface9_Release(p) (p)->Release() +#define IDirect3DSurface9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DSurface9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DSurface9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DSurface9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DSurface9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DSurface9_GetPriority(p) (p)->GetPriority() +#define IDirect3DSurface9_PreLoad(p) (p)->PreLoad() +#define IDirect3DSurface9_GetType(p) (p)->GetType() +#define IDirect3DSurface9_GetContainer(p,a,b) (p)->GetContainer(a,b) +#define IDirect3DSurface9_GetDesc(p,a) (p)->GetDesc(a) +#define IDirect3DSurface9_LockRect(p,a,b,c) (p)->LockRect(a,b,c) +#define IDirect3DSurface9_UnlockRect(p) (p)->UnlockRect() +#define IDirect3DSurface9_GetDC(p,a) (p)->GetDC(a) +#define IDirect3DSurface9_ReleaseDC(p,a) (p)->ReleaseDC(a) +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVolume9 + +DECLARE_INTERFACE_(IDirect3DVolume9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DVolume9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; + STDMETHOD(GetDesc)(THIS_ D3DVOLUME_DESC *pDesc) PURE; + STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; + STDMETHOD(UnlockBox)(THIS) PURE; + + #ifdef D3D_DEBUG_INFO + LPCWSTR Name; + UINT Width; + UINT Height; + UINT Depth; + DWORD Usage; + D3DFORMAT Format; + D3DPOOL Pool; + UINT LockCount; + LPCWSTR CreationCallStack; + #endif +}; + +typedef struct IDirect3DVolume9 *LPDIRECT3DVOLUME9, *PDIRECT3DVOLUME9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVolume9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVolume9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVolume9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVolume9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVolume9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVolume9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVolume9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVolume9_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) +#define IDirect3DVolume9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#define IDirect3DVolume9_LockBox(p,a,b,c) (p)->lpVtbl->LockBox(p,a,b,c) +#define IDirect3DVolume9_UnlockBox(p) (p)->lpVtbl->UnlockBox(p) +#else +#define IDirect3DVolume9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVolume9_AddRef(p) (p)->AddRef() +#define IDirect3DVolume9_Release(p) (p)->Release() +#define IDirect3DVolume9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVolume9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVolume9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVolume9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVolume9_GetContainer(p,a,b) (p)->GetContainer(a,b) +#define IDirect3DVolume9_GetDesc(p,a) (p)->GetDesc(a) +#define IDirect3DVolume9_LockBox(p,a,b,c) (p)->LockBox(a,b,c) +#define IDirect3DVolume9_UnlockBox(p) (p)->UnlockBox() +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DQuery9 + +DECLARE_INTERFACE_(IDirect3DQuery9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DQuery9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD_(D3DQUERYTYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, GetDataSize)(THIS) PURE; + STDMETHOD(Issue)(THIS_ DWORD dwIssueFlags) PURE; + STDMETHOD(GetData)(THIS_ void* pData,DWORD dwSize,DWORD dwGetDataFlags) PURE; + + #ifdef D3D_DEBUG_INFO + D3DQUERYTYPE Type; + DWORD DataSize; + LPCWSTR CreationCallStack; + #endif +}; + +typedef struct IDirect3DQuery9 *LPDIRECT3DQUERY9, *PDIRECT3DQUERY9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DQuery9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DQuery9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DQuery9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DQuery9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DQuery9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DQuery9_GetDataSize(p) (p)->lpVtbl->GetDataSize(p) +#define IDirect3DQuery9_Issue(p,a) (p)->lpVtbl->Issue(p,a) +#define IDirect3DQuery9_GetData(p,a,b,c) (p)->lpVtbl->GetData(p,a,b,c) +#else +#define IDirect3DQuery9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DQuery9_AddRef(p) (p)->AddRef() +#define IDirect3DQuery9_Release(p) (p)->Release() +#define IDirect3DQuery9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DQuery9_GetType(p) (p)->GetType() +#define IDirect3DQuery9_GetDataSize(p) (p)->GetDataSize() +#define IDirect3DQuery9_Issue(p,a) (p)->Issue(a) +#define IDirect3DQuery9_GetData(p,a,b,c) (p)->GetData(a,b,c) +#endif + + +/**************************************************************************** + * Flags for SetPrivateData method on all D3D9 interfaces + * + * The passed pointer is an IUnknown ptr. The SizeOfData argument to SetPrivateData + * must be set to sizeof(IUnknown*). Direct3D will call AddRef through this + * pointer and Release when the private data is destroyed. The data will be + * destroyed when another SetPrivateData with the same GUID is set, when + * FreePrivateData is called, or when the D3D9 object is freed. + ****************************************************************************/ +#define D3DSPD_IUNKNOWN 0x00000001L + +/**************************************************************************** + * + * Flags for IDirect3D9::CreateDevice's BehaviorFlags + * + ****************************************************************************/ + +#define D3DCREATE_FPU_PRESERVE 0x00000002L +#define D3DCREATE_MULTITHREADED 0x00000004L + +#define D3DCREATE_PUREDEVICE 0x00000010L +#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020L +#define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040L +#define D3DCREATE_MIXED_VERTEXPROCESSING 0x00000080L + +#define D3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100L +#define D3DCREATE_ADAPTERGROUP_DEVICE 0x00000200L +#define D3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX 0x00000400L + +// This flag causes the D3D runtime not to alter the focus +// window in any way. Use with caution- the burden of supporting +// focus management events (alt-tab, etc.) falls on the +// application, and appropriate responses (switching display +// mode, etc.) should be coded. +#define D3DCREATE_NOWINDOWCHANGES 0x00000800L + + +/**************************************************************************** + * + * Parameter for IDirect3D9::CreateDevice's Adapter argument + * + ****************************************************************************/ + +#define D3DADAPTER_DEFAULT 0 + +/**************************************************************************** + * + * Flags for IDirect3D9::EnumAdapters + * + ****************************************************************************/ + +#define D3DENUM_WHQL_LEVEL 0x00000002L + +/**************************************************************************** + * + * Maximum number of back-buffers supported in DX9 + * + ****************************************************************************/ + +#define D3DPRESENT_BACK_BUFFERS_MAX 3L + +/**************************************************************************** + * + * Flags for IDirect3DDevice9::SetGammaRamp + * + ****************************************************************************/ + +#define D3DSGR_NO_CALIBRATION 0x00000000L +#define D3DSGR_CALIBRATE 0x00000001L + +/**************************************************************************** + * + * Flags for IDirect3DDevice9::SetCursorPosition + * + ****************************************************************************/ + +#define D3DCURSOR_IMMEDIATE_UPDATE 0x00000001L + +/**************************************************************************** + * + * Flags for IDirect3DSwapChain9::Present + * + ****************************************************************************/ + +#define D3DPRESENT_DONOTWAIT 0x00000001L +#define D3DPRESENT_LINEAR_CONTENT 0x00000002L + +/**************************************************************************** + * + * Flags for DrawPrimitive/DrawIndexedPrimitive + * Also valid for Begin/BeginIndexed + * Also valid for VertexBuffer::CreateVertexBuffer + ****************************************************************************/ + + +/* + * DirectDraw error codes + */ +#define _FACD3D 0x876 +#define MAKE_D3DHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code ) +#define MAKE_D3DSTATUS( code ) MAKE_HRESULT( 0, _FACD3D, code ) + +/* + * Direct3D Errors + */ +#define D3D_OK S_OK + +#define D3DERR_WRONGTEXTUREFORMAT MAKE_D3DHRESULT(2072) +#define D3DERR_UNSUPPORTEDCOLOROPERATION MAKE_D3DHRESULT(2073) +#define D3DERR_UNSUPPORTEDCOLORARG MAKE_D3DHRESULT(2074) +#define D3DERR_UNSUPPORTEDALPHAOPERATION MAKE_D3DHRESULT(2075) +#define D3DERR_UNSUPPORTEDALPHAARG MAKE_D3DHRESULT(2076) +#define D3DERR_TOOMANYOPERATIONS MAKE_D3DHRESULT(2077) +#define D3DERR_CONFLICTINGTEXTUREFILTER MAKE_D3DHRESULT(2078) +#define D3DERR_UNSUPPORTEDFACTORVALUE MAKE_D3DHRESULT(2079) +#define D3DERR_CONFLICTINGRENDERSTATE MAKE_D3DHRESULT(2081) +#define D3DERR_UNSUPPORTEDTEXTUREFILTER MAKE_D3DHRESULT(2082) +#define D3DERR_CONFLICTINGTEXTUREPALETTE MAKE_D3DHRESULT(2086) +#define D3DERR_DRIVERINTERNALERROR MAKE_D3DHRESULT(2087) + +#define D3DERR_NOTFOUND MAKE_D3DHRESULT(2150) +#define D3DERR_MOREDATA MAKE_D3DHRESULT(2151) +#define D3DERR_DEVICELOST MAKE_D3DHRESULT(2152) +#define D3DERR_DEVICENOTRESET MAKE_D3DHRESULT(2153) +#define D3DERR_NOTAVAILABLE MAKE_D3DHRESULT(2154) +#define D3DERR_OUTOFVIDEOMEMORY MAKE_D3DHRESULT(380) +#define D3DERR_INVALIDDEVICE MAKE_D3DHRESULT(2155) +#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156) +#define D3DERR_DRIVERINVALIDCALL MAKE_D3DHRESULT(2157) +#define D3DERR_WASSTILLDRAWING MAKE_D3DHRESULT(540) +#define D3DOK_NOAUTOGEN MAKE_D3DSTATUS(2159) + + +#ifdef __cplusplus +}; +#endif + +#endif /* (DIRECT3D_VERSION >= 0x0900) */ +#endif /* _D3D_H_ */ + diff --git a/src/dep/include/DXSDK/include/d3d9caps.h b/src/dep/include/DXSDK/include/d3d9caps.h index 913f960..6489f0e 100644 --- a/src/dep/include/DXSDK/include/d3d9caps.h +++ b/src/dep/include/DXSDK/include/d3d9caps.h @@ -1,476 +1,476 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: d3d9caps.h - * Content: Direct3D capabilities include file - * - ***************************************************************************/ - -#ifndef _d3d9CAPS_H -#define _d3d9CAPS_H - -#ifndef DIRECT3D_VERSION -#define DIRECT3D_VERSION 0x0900 -#endif //DIRECT3D_VERSION - -// include this file content only if compiling for DX9 interfaces -#if(DIRECT3D_VERSION >= 0x0900) - -#if defined(_X86_) || defined(_IA64) -#pragma pack(4) -#endif - -typedef struct _D3DVSHADERCAPS2_0 -{ - DWORD Caps; - INT DynamicFlowControlDepth; - INT NumTemps; - INT StaticFlowControlDepth; -} D3DVSHADERCAPS2_0; - -#define D3DVS20CAPS_PREDICATION (1<<0) - -#define D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH 24 -#define D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH 0 -#define D3DVS20_MAX_NUMTEMPS 32 -#define D3DVS20_MIN_NUMTEMPS 12 -#define D3DVS20_MAX_STATICFLOWCONTROLDEPTH 4 -#define D3DVS20_MIN_STATICFLOWCONTROLDEPTH 1 - -typedef struct _D3DPSHADERCAPS2_0 -{ - DWORD Caps; - INT DynamicFlowControlDepth; - INT NumTemps; - INT StaticFlowControlDepth; - INT NumInstructionSlots; -} D3DPSHADERCAPS2_0; - -#define D3DPS20CAPS_ARBITRARYSWIZZLE (1<<0) -#define D3DPS20CAPS_GRADIENTINSTRUCTIONS (1<<1) -#define D3DPS20CAPS_PREDICATION (1<<2) -#define D3DPS20CAPS_NODEPENDENTREADLIMIT (1<<3) -#define D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT (1<<4) - -#define D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH 24 -#define D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH 0 -#define D3DPS20_MAX_NUMTEMPS 32 -#define D3DPS20_MIN_NUMTEMPS 12 -#define D3DPS20_MAX_STATICFLOWCONTROLDEPTH 4 -#define D3DPS20_MIN_STATICFLOWCONTROLDEPTH 0 -#define D3DPS20_MAX_NUMINSTRUCTIONSLOTS 512 -#define D3DPS20_MIN_NUMINSTRUCTIONSLOTS 96 - -#define D3DMIN30SHADERINSTRUCTIONS 512 -#define D3DMAX30SHADERINSTRUCTIONS 32768 - -typedef struct _D3DCAPS9 -{ - /* Device Info */ - D3DDEVTYPE DeviceType; - UINT AdapterOrdinal; - - /* Caps from DX7 Draw */ - DWORD Caps; - DWORD Caps2; - DWORD Caps3; - DWORD PresentationIntervals; - - /* Cursor Caps */ - DWORD CursorCaps; - - /* 3D Device Caps */ - DWORD DevCaps; - - DWORD PrimitiveMiscCaps; - DWORD RasterCaps; - DWORD ZCmpCaps; - DWORD SrcBlendCaps; - DWORD DestBlendCaps; - DWORD AlphaCmpCaps; - DWORD ShadeCaps; - DWORD TextureCaps; - DWORD TextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture9's - DWORD CubeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DCubeTexture9's - DWORD VolumeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DVolumeTexture9's - DWORD TextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DTexture9's - DWORD VolumeTextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DVolumeTexture9's - - DWORD LineCaps; // D3DLINECAPS - - DWORD MaxTextureWidth, MaxTextureHeight; - DWORD MaxVolumeExtent; - - DWORD MaxTextureRepeat; - DWORD MaxTextureAspectRatio; - DWORD MaxAnisotropy; - float MaxVertexW; - - float GuardBandLeft; - float GuardBandTop; - float GuardBandRight; - float GuardBandBottom; - - float ExtentsAdjust; - DWORD StencilCaps; - - DWORD FVFCaps; - DWORD TextureOpCaps; - DWORD MaxTextureBlendStages; - DWORD MaxSimultaneousTextures; - - DWORD VertexProcessingCaps; - DWORD MaxActiveLights; - DWORD MaxUserClipPlanes; - DWORD MaxVertexBlendMatrices; - DWORD MaxVertexBlendMatrixIndex; - - float MaxPointSize; - - DWORD MaxPrimitiveCount; // max number of primitives per DrawPrimitive call - DWORD MaxVertexIndex; - DWORD MaxStreams; - DWORD MaxStreamStride; // max stride for SetStreamSource - - DWORD VertexShaderVersion; - DWORD MaxVertexShaderConst; // number of vertex shader constant registers - - DWORD PixelShaderVersion; - float PixelShader1xMaxValue; // max value storable in registers of ps.1.x shaders - - // Here are the DX9 specific ones - DWORD DevCaps2; - - float MaxNpatchTessellationLevel; - DWORD Reserved5; - - UINT MasterAdapterOrdinal; // ordinal of master adaptor for adapter group - UINT AdapterOrdinalInGroup; // ordinal inside the adapter group - UINT NumberOfAdaptersInGroup; // number of adapters in this adapter group (only if master) - DWORD DeclTypes; // Data types, supported in vertex declarations - DWORD NumSimultaneousRTs; // Will be at least 1 - DWORD StretchRectFilterCaps; // Filter caps supported by StretchRect - D3DVSHADERCAPS2_0 VS20Caps; - D3DPSHADERCAPS2_0 PS20Caps; - DWORD VertexTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture9's for texture, used in vertex shaders - DWORD MaxVShaderInstructionsExecuted; // maximum number of vertex shader instructions that can be executed - DWORD MaxPShaderInstructionsExecuted; // maximum number of pixel shader instructions that can be executed - DWORD MaxVertexShader30InstructionSlots; - DWORD MaxPixelShader30InstructionSlots; -} D3DCAPS9; - -// -// BIT DEFINES FOR D3DCAPS9 DWORD MEMBERS -// - -// -// Caps -// -#define D3DCAPS_READ_SCANLINE 0x00020000L - -// -// Caps2 -// -#define D3DCAPS2_FULLSCREENGAMMA 0x00020000L -#define D3DCAPS2_CANCALIBRATEGAMMA 0x00100000L -#define D3DCAPS2_RESERVED 0x02000000L -#define D3DCAPS2_CANMANAGERESOURCE 0x10000000L -#define D3DCAPS2_DYNAMICTEXTURES 0x20000000L -#define D3DCAPS2_CANAUTOGENMIPMAP 0x40000000L - -// -// Caps3 -// -#define D3DCAPS3_RESERVED 0x8000001fL - -// Indicates that the device can respect the ALPHABLENDENABLE render state -// when fullscreen while using the FLIP or DISCARD swap effect. -// COPY and COPYVSYNC swap effects work whether or not this flag is set. -#define D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020L - -// Indicates that the device can perform a gamma correction from -// a windowed back buffer containing linear content to the sRGB desktop. -#define D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION 0x00000080L - -#define D3DCAPS3_COPY_TO_VIDMEM 0x00000100L /* Device can acclerate copies from sysmem to local vidmem */ -#define D3DCAPS3_COPY_TO_SYSTEMMEM 0x00000200L /* Device can acclerate copies from local vidmem to sysmem */ - - -// -// PresentationIntervals -// -#define D3DPRESENT_INTERVAL_DEFAULT 0x00000000L -#define D3DPRESENT_INTERVAL_ONE 0x00000001L -#define D3DPRESENT_INTERVAL_TWO 0x00000002L -#define D3DPRESENT_INTERVAL_THREE 0x00000004L -#define D3DPRESENT_INTERVAL_FOUR 0x00000008L -#define D3DPRESENT_INTERVAL_IMMEDIATE 0x80000000L - -// -// CursorCaps -// -// Driver supports HW color cursor in at least hi-res modes(height >=400) -#define D3DCURSORCAPS_COLOR 0x00000001L -// Driver supports HW cursor also in low-res modes(height < 400) -#define D3DCURSORCAPS_LOWRES 0x00000002L - -// -// DevCaps -// -#define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010L /* Device can use execute buffers from system memory */ -#define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020L /* Device can use execute buffers from video 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_DRAWPRIMITIVES2 0x00002000L /* Device can support DrawPrimitives2 */ -#define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000L /* Device is texturing from separate memory pools */ -#define D3DDEVCAPS_DRAWPRIMITIVES2EX 0x00008000L /* Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver*/ -#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_RTPATCHES 0x00400000L /* Device supports Rect and Tri patches */ -#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_INDEPENDENTWRITEMASKS 0x00004000L /* Device supports independent write masks for MET or MRT */ -#define D3DPMISCCAPS_PERSTAGECONSTANT 0x00008000L /* Device supports per-stage constants */ -#define D3DPMISCCAPS_FOGANDSPECULARALPHA 0x00010000L /* Device supports separate fog and specular alpha (many devices - use the specular alpha channel to store fog factor) */ -#define D3DPMISCCAPS_SEPARATEALPHABLEND 0x00020000L /* Device supports separate blend settings for the alpha channel */ -#define D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS 0x00040000L /* Device supports different bit depths for MRT */ -#define D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING 0x00080000L /* Device supports post-pixel shader operations for MRT */ -#define D3DPMISCCAPS_FOGVERTEXCLAMPED 0x00100000L /* Device clamps fog blend factor per vertex */ - -// -// LineCaps -// -#define D3DLINECAPS_TEXTURE 0x00000001L -#define D3DLINECAPS_ZTEST 0x00000002L -#define D3DLINECAPS_BLEND 0x00000004L -#define D3DLINECAPS_ALPHACMP 0x00000008L -#define D3DLINECAPS_FOG 0x00000010L -#define D3DLINECAPS_ANTIALIAS 0x00000020L - -// -// RasterCaps -// -#define D3DPRASTERCAPS_DITHER 0x00000001L -#define D3DPRASTERCAPS_ZTEST 0x00000010L -#define D3DPRASTERCAPS_FOGVERTEX 0x00000080L -#define D3DPRASTERCAPS_FOGTABLE 0x00000100L -#define D3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000L -#define D3DPRASTERCAPS_ZBUFFERLESSHSR 0x00008000L -#define D3DPRASTERCAPS_FOGRANGE 0x00010000L -#define D3DPRASTERCAPS_ANISOTROPY 0x00020000L -#define D3DPRASTERCAPS_WBUFFER 0x00040000L -#define D3DPRASTERCAPS_WFOG 0x00100000L -#define D3DPRASTERCAPS_ZFOG 0x00200000L -#define D3DPRASTERCAPS_COLORPERSPECTIVE 0x00400000L /* Device iterates colors perspective correct */ -#define D3DPRASTERCAPS_SCISSORTEST 0x01000000L -#define D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS 0x02000000L -#define D3DPRASTERCAPS_DEPTHBIAS 0x04000000L -#define D3DPRASTERCAPS_MULTISAMPLE_TOGGLE 0x08000000L - -// -// ZCmpCaps, AlphaCmpCaps -// -#define D3DPCMPCAPS_NEVER 0x00000001L -#define D3DPCMPCAPS_LESS 0x00000002L -#define D3DPCMPCAPS_EQUAL 0x00000004L -#define D3DPCMPCAPS_LESSEQUAL 0x00000008L -#define D3DPCMPCAPS_GREATER 0x00000010L -#define D3DPCMPCAPS_NOTEQUAL 0x00000020L -#define D3DPCMPCAPS_GREATEREQUAL 0x00000040L -#define D3DPCMPCAPS_ALWAYS 0x00000080L - -// -// SourceBlendCaps, DestBlendCaps -// -#define D3DPBLENDCAPS_ZERO 0x00000001L -#define D3DPBLENDCAPS_ONE 0x00000002L -#define D3DPBLENDCAPS_SRCCOLOR 0x00000004L -#define D3DPBLENDCAPS_INVSRCCOLOR 0x00000008L -#define D3DPBLENDCAPS_SRCALPHA 0x00000010L -#define D3DPBLENDCAPS_INVSRCALPHA 0x00000020L -#define D3DPBLENDCAPS_DESTALPHA 0x00000040L -#define D3DPBLENDCAPS_INVDESTALPHA 0x00000080L -#define D3DPBLENDCAPS_DESTCOLOR 0x00000100L -#define D3DPBLENDCAPS_INVDESTCOLOR 0x00000200L -#define D3DPBLENDCAPS_SRCALPHASAT 0x00000400L -#define D3DPBLENDCAPS_BOTHSRCALPHA 0x00000800L -#define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000L -#define D3DPBLENDCAPS_BLENDFACTOR 0x00002000L /* Supports both D3DBLEND_BLENDFACTOR and D3DBLEND_INVBLENDFACTOR */ - -// -// ShadeCaps -// -#define D3DPSHADECAPS_COLORGOURAUDRGB 0x00000008L -#define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200L -#define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000L -#define D3DPSHADECAPS_FOGGOURAUD 0x00080000L - -// -// TextureCaps -// -#define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001L /* Perspective-correct texturing is supported */ -#define D3DPTEXTURECAPS_POW2 0x00000002L /* Power-of-2 texture dimensions are required - applies to non-Cube/Volume textures only. */ -#define D3DPTEXTURECAPS_ALPHA 0x00000004L /* Alpha in texture pixels is supported */ -#define D3DPTEXTURECAPS_SQUAREONLY 0x00000020L /* Only square textures are supported */ -#define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040L /* Texture indices are not scaled by the texture size prior to interpolation */ -#define D3DPTEXTURECAPS_ALPHAPALETTE 0x00000080L /* Device can draw alpha from texture palettes */ -// Device can use non-POW2 textures if: -// 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage -// 2) D3DRS_WRAP(N) is zero for this texture's coordinates -// 3) mip mapping is not enabled (use magnification filter only) -#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100L -#define D3DPTEXTURECAPS_PROJECTED 0x00000400L /* Device can do D3DTTFF_PROJECTED */ -#define D3DPTEXTURECAPS_CUBEMAP 0x00000800L /* Device can do cubemap textures */ -#define D3DPTEXTURECAPS_VOLUMEMAP 0x00002000L /* Device can do volume textures */ -#define D3DPTEXTURECAPS_MIPMAP 0x00004000L /* Device can do mipmapped textures */ -#define D3DPTEXTURECAPS_MIPVOLUMEMAP 0x00008000L /* Device can do mipmapped volume textures */ -#define D3DPTEXTURECAPS_MIPCUBEMAP 0x00010000L /* Device can do mipmapped cube maps */ -#define D3DPTEXTURECAPS_CUBEMAP_POW2 0x00020000L /* Device requires that cubemaps be power-of-2 dimension */ -#define D3DPTEXTURECAPS_VOLUMEMAP_POW2 0x00040000L /* Device requires that volume maps be power-of-2 dimension */ -#define D3DPTEXTURECAPS_NOPROJECTEDBUMPENV 0x00200000L /* Device does not support projected bump env lookup operation - in programmable and fixed function pixel shaders */ - -// -// TextureFilterCaps, StretchRectFilterCaps -// -#define D3DPTFILTERCAPS_MINFPOINT 0x00000100L /* Min Filter */ -#define D3DPTFILTERCAPS_MINFLINEAR 0x00000200L -#define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400L -#define D3DPTFILTERCAPS_MINFPYRAMIDALQUAD 0x00000800L -#define D3DPTFILTERCAPS_MINFGAUSSIANQUAD 0x00001000L -#define D3DPTFILTERCAPS_MIPFPOINT 0x00010000L /* Mip Filter */ -#define D3DPTFILTERCAPS_MIPFLINEAR 0x00020000L -#define D3DPTFILTERCAPS_MAGFPOINT 0x01000000L /* Mag Filter */ -#define D3DPTFILTERCAPS_MAGFLINEAR 0x02000000L -#define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000L -#define D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD 0x08000000L -#define D3DPTFILTERCAPS_MAGFGAUSSIANQUAD 0x10000000L - -// -// TextureAddressCaps -// -#define D3DPTADDRESSCAPS_WRAP 0x00000001L -#define D3DPTADDRESSCAPS_MIRROR 0x00000002L -#define D3DPTADDRESSCAPS_CLAMP 0x00000004L -#define D3DPTADDRESSCAPS_BORDER 0x00000008L -#define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010L -#define D3DPTADDRESSCAPS_MIRRORONCE 0x00000020L - -// -// StencilCaps -// -#define D3DSTENCILCAPS_KEEP 0x00000001L -#define D3DSTENCILCAPS_ZERO 0x00000002L -#define D3DSTENCILCAPS_REPLACE 0x00000004L -#define D3DSTENCILCAPS_INCRSAT 0x00000008L -#define D3DSTENCILCAPS_DECRSAT 0x00000010L -#define D3DSTENCILCAPS_INVERT 0x00000020L -#define D3DSTENCILCAPS_INCR 0x00000040L -#define D3DSTENCILCAPS_DECR 0x00000080L -#define D3DSTENCILCAPS_TWOSIDED 0x00000100L - -// -// TextureOpCaps -// -#define D3DTEXOPCAPS_DISABLE 0x00000001L -#define D3DTEXOPCAPS_SELECTARG1 0x00000002L -#define D3DTEXOPCAPS_SELECTARG2 0x00000004L -#define D3DTEXOPCAPS_MODULATE 0x00000008L -#define D3DTEXOPCAPS_MODULATE2X 0x00000010L -#define D3DTEXOPCAPS_MODULATE4X 0x00000020L -#define D3DTEXOPCAPS_ADD 0x00000040L -#define D3DTEXOPCAPS_ADDSIGNED 0x00000080L -#define D3DTEXOPCAPS_ADDSIGNED2X 0x00000100L -#define D3DTEXOPCAPS_SUBTRACT 0x00000200L -#define D3DTEXOPCAPS_ADDSMOOTH 0x00000400L -#define D3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x00000800L -#define D3DTEXOPCAPS_BLENDTEXTUREALPHA 0x00001000L -#define D3DTEXOPCAPS_BLENDFACTORALPHA 0x00002000L -#define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x00004000L -#define D3DTEXOPCAPS_BLENDCURRENTALPHA 0x00008000L -#define D3DTEXOPCAPS_PREMODULATE 0x00010000L -#define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x00020000L -#define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x00040000L -#define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x00080000L -#define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x00100000L -#define D3DTEXOPCAPS_BUMPENVMAP 0x00200000L -#define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x00400000L -#define D3DTEXOPCAPS_DOTPRODUCT3 0x00800000L -#define D3DTEXOPCAPS_MULTIPLYADD 0x01000000L -#define D3DTEXOPCAPS_LERP 0x02000000L - -// -// FVFCaps -// -#define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000ffffL /* mask for texture coordinate count field */ -#define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000L /* Device prefers that vertex elements not be stripped */ -#define D3DFVFCAPS_PSIZE 0x00100000L /* Device can receive point size */ - -// -// VertexProcessingCaps -// -#define D3DVTXPCAPS_TEXGEN 0x00000001L /* device can do texgen */ -#define D3DVTXPCAPS_MATERIALSOURCE7 0x00000002L /* device can do DX7-level colormaterialsource ops */ -#define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008L /* device can do directional lights */ -#define D3DVTXPCAPS_POSITIONALLIGHTS 0x00000010L /* device can do positional lights (includes point and spot) */ -#define D3DVTXPCAPS_LOCALVIEWER 0x00000020L /* device can do local viewer */ -#define D3DVTXPCAPS_TWEENING 0x00000040L /* device can do vertex tweening */ -#define D3DVTXPCAPS_TEXGEN_SPHEREMAP 0x00000100L /* device supports D3DTSS_TCI_SPHEREMAP */ -#define D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER 0x00000200L /* device does not support TexGen in non-local - viewer mode */ - -// -// DevCaps2 -// -#define D3DDEVCAPS2_STREAMOFFSET 0x00000001L /* Device supports offsets in streams. Must be set by DX9 drivers */ -#define D3DDEVCAPS2_DMAPNPATCH 0x00000002L /* Device supports displacement maps for N-Patches*/ -#define D3DDEVCAPS2_ADAPTIVETESSRTPATCH 0x00000004L /* Device supports adaptive tesselation of RT-patches*/ -#define D3DDEVCAPS2_ADAPTIVETESSNPATCH 0x00000008L /* Device supports adaptive tesselation of N-patches*/ -#define D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES 0x00000010L /* Device supports StretchRect calls with a texture as the source*/ -#define D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH 0x00000020L /* Device supports presampled displacement maps for N-Patches */ -#define D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET 0x00000040L /* Vertex elements in a vertex declaration can share the same stream offset */ - -// -// DeclTypes -// -#define D3DDTCAPS_UBYTE4 0x00000001L -#define D3DDTCAPS_UBYTE4N 0x00000002L -#define D3DDTCAPS_SHORT2N 0x00000004L -#define D3DDTCAPS_SHORT4N 0x00000008L -#define D3DDTCAPS_USHORT2N 0x00000010L -#define D3DDTCAPS_USHORT4N 0x00000020L -#define D3DDTCAPS_UDEC3 0x00000040L -#define D3DDTCAPS_DEC3N 0x00000080L -#define D3DDTCAPS_FLOAT16_2 0x00000100L -#define D3DDTCAPS_FLOAT16_4 0x00000200L - - -#pragma pack() - -#endif /* (DIRECT3D_VERSION >= 0x0900) */ -#endif /* _d3d9CAPS_H_ */ - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3d9caps.h + * Content: Direct3D capabilities include file + * + ***************************************************************************/ + +#ifndef _d3d9CAPS_H +#define _d3d9CAPS_H + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0900 +#endif //DIRECT3D_VERSION + +// include this file content only if compiling for DX9 interfaces +#if(DIRECT3D_VERSION >= 0x0900) + +#if defined(_X86_) || defined(_IA64) +#pragma pack(4) +#endif + +typedef struct _D3DVSHADERCAPS2_0 +{ + DWORD Caps; + INT DynamicFlowControlDepth; + INT NumTemps; + INT StaticFlowControlDepth; +} D3DVSHADERCAPS2_0; + +#define D3DVS20CAPS_PREDICATION (1<<0) + +#define D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH 24 +#define D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH 0 +#define D3DVS20_MAX_NUMTEMPS 32 +#define D3DVS20_MIN_NUMTEMPS 12 +#define D3DVS20_MAX_STATICFLOWCONTROLDEPTH 4 +#define D3DVS20_MIN_STATICFLOWCONTROLDEPTH 1 + +typedef struct _D3DPSHADERCAPS2_0 +{ + DWORD Caps; + INT DynamicFlowControlDepth; + INT NumTemps; + INT StaticFlowControlDepth; + INT NumInstructionSlots; +} D3DPSHADERCAPS2_0; + +#define D3DPS20CAPS_ARBITRARYSWIZZLE (1<<0) +#define D3DPS20CAPS_GRADIENTINSTRUCTIONS (1<<1) +#define D3DPS20CAPS_PREDICATION (1<<2) +#define D3DPS20CAPS_NODEPENDENTREADLIMIT (1<<3) +#define D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT (1<<4) + +#define D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH 24 +#define D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH 0 +#define D3DPS20_MAX_NUMTEMPS 32 +#define D3DPS20_MIN_NUMTEMPS 12 +#define D3DPS20_MAX_STATICFLOWCONTROLDEPTH 4 +#define D3DPS20_MIN_STATICFLOWCONTROLDEPTH 0 +#define D3DPS20_MAX_NUMINSTRUCTIONSLOTS 512 +#define D3DPS20_MIN_NUMINSTRUCTIONSLOTS 96 + +#define D3DMIN30SHADERINSTRUCTIONS 512 +#define D3DMAX30SHADERINSTRUCTIONS 32768 + +typedef struct _D3DCAPS9 +{ + /* Device Info */ + D3DDEVTYPE DeviceType; + UINT AdapterOrdinal; + + /* Caps from DX7 Draw */ + DWORD Caps; + DWORD Caps2; + DWORD Caps3; + DWORD PresentationIntervals; + + /* Cursor Caps */ + DWORD CursorCaps; + + /* 3D Device Caps */ + DWORD DevCaps; + + DWORD PrimitiveMiscCaps; + DWORD RasterCaps; + DWORD ZCmpCaps; + DWORD SrcBlendCaps; + DWORD DestBlendCaps; + DWORD AlphaCmpCaps; + DWORD ShadeCaps; + DWORD TextureCaps; + DWORD TextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture9's + DWORD CubeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DCubeTexture9's + DWORD VolumeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DVolumeTexture9's + DWORD TextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DTexture9's + DWORD VolumeTextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DVolumeTexture9's + + DWORD LineCaps; // D3DLINECAPS + + DWORD MaxTextureWidth, MaxTextureHeight; + DWORD MaxVolumeExtent; + + DWORD MaxTextureRepeat; + DWORD MaxTextureAspectRatio; + DWORD MaxAnisotropy; + float MaxVertexW; + + float GuardBandLeft; + float GuardBandTop; + float GuardBandRight; + float GuardBandBottom; + + float ExtentsAdjust; + DWORD StencilCaps; + + DWORD FVFCaps; + DWORD TextureOpCaps; + DWORD MaxTextureBlendStages; + DWORD MaxSimultaneousTextures; + + DWORD VertexProcessingCaps; + DWORD MaxActiveLights; + DWORD MaxUserClipPlanes; + DWORD MaxVertexBlendMatrices; + DWORD MaxVertexBlendMatrixIndex; + + float MaxPointSize; + + DWORD MaxPrimitiveCount; // max number of primitives per DrawPrimitive call + DWORD MaxVertexIndex; + DWORD MaxStreams; + DWORD MaxStreamStride; // max stride for SetStreamSource + + DWORD VertexShaderVersion; + DWORD MaxVertexShaderConst; // number of vertex shader constant registers + + DWORD PixelShaderVersion; + float PixelShader1xMaxValue; // max value storable in registers of ps.1.x shaders + + // Here are the DX9 specific ones + DWORD DevCaps2; + + float MaxNpatchTessellationLevel; + DWORD Reserved5; + + UINT MasterAdapterOrdinal; // ordinal of master adaptor for adapter group + UINT AdapterOrdinalInGroup; // ordinal inside the adapter group + UINT NumberOfAdaptersInGroup; // number of adapters in this adapter group (only if master) + DWORD DeclTypes; // Data types, supported in vertex declarations + DWORD NumSimultaneousRTs; // Will be at least 1 + DWORD StretchRectFilterCaps; // Filter caps supported by StretchRect + D3DVSHADERCAPS2_0 VS20Caps; + D3DPSHADERCAPS2_0 PS20Caps; + DWORD VertexTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture9's for texture, used in vertex shaders + DWORD MaxVShaderInstructionsExecuted; // maximum number of vertex shader instructions that can be executed + DWORD MaxPShaderInstructionsExecuted; // maximum number of pixel shader instructions that can be executed + DWORD MaxVertexShader30InstructionSlots; + DWORD MaxPixelShader30InstructionSlots; +} D3DCAPS9; + +// +// BIT DEFINES FOR D3DCAPS9 DWORD MEMBERS +// + +// +// Caps +// +#define D3DCAPS_READ_SCANLINE 0x00020000L + +// +// Caps2 +// +#define D3DCAPS2_FULLSCREENGAMMA 0x00020000L +#define D3DCAPS2_CANCALIBRATEGAMMA 0x00100000L +#define D3DCAPS2_RESERVED 0x02000000L +#define D3DCAPS2_CANMANAGERESOURCE 0x10000000L +#define D3DCAPS2_DYNAMICTEXTURES 0x20000000L +#define D3DCAPS2_CANAUTOGENMIPMAP 0x40000000L + +// +// Caps3 +// +#define D3DCAPS3_RESERVED 0x8000001fL + +// Indicates that the device can respect the ALPHABLENDENABLE render state +// when fullscreen while using the FLIP or DISCARD swap effect. +// COPY and COPYVSYNC swap effects work whether or not this flag is set. +#define D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020L + +// Indicates that the device can perform a gamma correction from +// a windowed back buffer containing linear content to the sRGB desktop. +#define D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION 0x00000080L + +#define D3DCAPS3_COPY_TO_VIDMEM 0x00000100L /* Device can acclerate copies from sysmem to local vidmem */ +#define D3DCAPS3_COPY_TO_SYSTEMMEM 0x00000200L /* Device can acclerate copies from local vidmem to sysmem */ + + +// +// PresentationIntervals +// +#define D3DPRESENT_INTERVAL_DEFAULT 0x00000000L +#define D3DPRESENT_INTERVAL_ONE 0x00000001L +#define D3DPRESENT_INTERVAL_TWO 0x00000002L +#define D3DPRESENT_INTERVAL_THREE 0x00000004L +#define D3DPRESENT_INTERVAL_FOUR 0x00000008L +#define D3DPRESENT_INTERVAL_IMMEDIATE 0x80000000L + +// +// CursorCaps +// +// Driver supports HW color cursor in at least hi-res modes(height >=400) +#define D3DCURSORCAPS_COLOR 0x00000001L +// Driver supports HW cursor also in low-res modes(height < 400) +#define D3DCURSORCAPS_LOWRES 0x00000002L + +// +// DevCaps +// +#define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010L /* Device can use execute buffers from system memory */ +#define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020L /* Device can use execute buffers from video 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_DRAWPRIMITIVES2 0x00002000L /* Device can support DrawPrimitives2 */ +#define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000L /* Device is texturing from separate memory pools */ +#define D3DDEVCAPS_DRAWPRIMITIVES2EX 0x00008000L /* Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver*/ +#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_RTPATCHES 0x00400000L /* Device supports Rect and Tri patches */ +#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_INDEPENDENTWRITEMASKS 0x00004000L /* Device supports independent write masks for MET or MRT */ +#define D3DPMISCCAPS_PERSTAGECONSTANT 0x00008000L /* Device supports per-stage constants */ +#define D3DPMISCCAPS_FOGANDSPECULARALPHA 0x00010000L /* Device supports separate fog and specular alpha (many devices + use the specular alpha channel to store fog factor) */ +#define D3DPMISCCAPS_SEPARATEALPHABLEND 0x00020000L /* Device supports separate blend settings for the alpha channel */ +#define D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS 0x00040000L /* Device supports different bit depths for MRT */ +#define D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING 0x00080000L /* Device supports post-pixel shader operations for MRT */ +#define D3DPMISCCAPS_FOGVERTEXCLAMPED 0x00100000L /* Device clamps fog blend factor per vertex */ + +// +// LineCaps +// +#define D3DLINECAPS_TEXTURE 0x00000001L +#define D3DLINECAPS_ZTEST 0x00000002L +#define D3DLINECAPS_BLEND 0x00000004L +#define D3DLINECAPS_ALPHACMP 0x00000008L +#define D3DLINECAPS_FOG 0x00000010L +#define D3DLINECAPS_ANTIALIAS 0x00000020L + +// +// RasterCaps +// +#define D3DPRASTERCAPS_DITHER 0x00000001L +#define D3DPRASTERCAPS_ZTEST 0x00000010L +#define D3DPRASTERCAPS_FOGVERTEX 0x00000080L +#define D3DPRASTERCAPS_FOGTABLE 0x00000100L +#define D3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000L +#define D3DPRASTERCAPS_ZBUFFERLESSHSR 0x00008000L +#define D3DPRASTERCAPS_FOGRANGE 0x00010000L +#define D3DPRASTERCAPS_ANISOTROPY 0x00020000L +#define D3DPRASTERCAPS_WBUFFER 0x00040000L +#define D3DPRASTERCAPS_WFOG 0x00100000L +#define D3DPRASTERCAPS_ZFOG 0x00200000L +#define D3DPRASTERCAPS_COLORPERSPECTIVE 0x00400000L /* Device iterates colors perspective correct */ +#define D3DPRASTERCAPS_SCISSORTEST 0x01000000L +#define D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS 0x02000000L +#define D3DPRASTERCAPS_DEPTHBIAS 0x04000000L +#define D3DPRASTERCAPS_MULTISAMPLE_TOGGLE 0x08000000L + +// +// ZCmpCaps, AlphaCmpCaps +// +#define D3DPCMPCAPS_NEVER 0x00000001L +#define D3DPCMPCAPS_LESS 0x00000002L +#define D3DPCMPCAPS_EQUAL 0x00000004L +#define D3DPCMPCAPS_LESSEQUAL 0x00000008L +#define D3DPCMPCAPS_GREATER 0x00000010L +#define D3DPCMPCAPS_NOTEQUAL 0x00000020L +#define D3DPCMPCAPS_GREATEREQUAL 0x00000040L +#define D3DPCMPCAPS_ALWAYS 0x00000080L + +// +// SourceBlendCaps, DestBlendCaps +// +#define D3DPBLENDCAPS_ZERO 0x00000001L +#define D3DPBLENDCAPS_ONE 0x00000002L +#define D3DPBLENDCAPS_SRCCOLOR 0x00000004L +#define D3DPBLENDCAPS_INVSRCCOLOR 0x00000008L +#define D3DPBLENDCAPS_SRCALPHA 0x00000010L +#define D3DPBLENDCAPS_INVSRCALPHA 0x00000020L +#define D3DPBLENDCAPS_DESTALPHA 0x00000040L +#define D3DPBLENDCAPS_INVDESTALPHA 0x00000080L +#define D3DPBLENDCAPS_DESTCOLOR 0x00000100L +#define D3DPBLENDCAPS_INVDESTCOLOR 0x00000200L +#define D3DPBLENDCAPS_SRCALPHASAT 0x00000400L +#define D3DPBLENDCAPS_BOTHSRCALPHA 0x00000800L +#define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000L +#define D3DPBLENDCAPS_BLENDFACTOR 0x00002000L /* Supports both D3DBLEND_BLENDFACTOR and D3DBLEND_INVBLENDFACTOR */ + +// +// ShadeCaps +// +#define D3DPSHADECAPS_COLORGOURAUDRGB 0x00000008L +#define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200L +#define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000L +#define D3DPSHADECAPS_FOGGOURAUD 0x00080000L + +// +// TextureCaps +// +#define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001L /* Perspective-correct texturing is supported */ +#define D3DPTEXTURECAPS_POW2 0x00000002L /* Power-of-2 texture dimensions are required - applies to non-Cube/Volume textures only. */ +#define D3DPTEXTURECAPS_ALPHA 0x00000004L /* Alpha in texture pixels is supported */ +#define D3DPTEXTURECAPS_SQUAREONLY 0x00000020L /* Only square textures are supported */ +#define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040L /* Texture indices are not scaled by the texture size prior to interpolation */ +#define D3DPTEXTURECAPS_ALPHAPALETTE 0x00000080L /* Device can draw alpha from texture palettes */ +// Device can use non-POW2 textures if: +// 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage +// 2) D3DRS_WRAP(N) is zero for this texture's coordinates +// 3) mip mapping is not enabled (use magnification filter only) +#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100L +#define D3DPTEXTURECAPS_PROJECTED 0x00000400L /* Device can do D3DTTFF_PROJECTED */ +#define D3DPTEXTURECAPS_CUBEMAP 0x00000800L /* Device can do cubemap textures */ +#define D3DPTEXTURECAPS_VOLUMEMAP 0x00002000L /* Device can do volume textures */ +#define D3DPTEXTURECAPS_MIPMAP 0x00004000L /* Device can do mipmapped textures */ +#define D3DPTEXTURECAPS_MIPVOLUMEMAP 0x00008000L /* Device can do mipmapped volume textures */ +#define D3DPTEXTURECAPS_MIPCUBEMAP 0x00010000L /* Device can do mipmapped cube maps */ +#define D3DPTEXTURECAPS_CUBEMAP_POW2 0x00020000L /* Device requires that cubemaps be power-of-2 dimension */ +#define D3DPTEXTURECAPS_VOLUMEMAP_POW2 0x00040000L /* Device requires that volume maps be power-of-2 dimension */ +#define D3DPTEXTURECAPS_NOPROJECTEDBUMPENV 0x00200000L /* Device does not support projected bump env lookup operation + in programmable and fixed function pixel shaders */ + +// +// TextureFilterCaps, StretchRectFilterCaps +// +#define D3DPTFILTERCAPS_MINFPOINT 0x00000100L /* Min Filter */ +#define D3DPTFILTERCAPS_MINFLINEAR 0x00000200L +#define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400L +#define D3DPTFILTERCAPS_MINFPYRAMIDALQUAD 0x00000800L +#define D3DPTFILTERCAPS_MINFGAUSSIANQUAD 0x00001000L +#define D3DPTFILTERCAPS_MIPFPOINT 0x00010000L /* Mip Filter */ +#define D3DPTFILTERCAPS_MIPFLINEAR 0x00020000L +#define D3DPTFILTERCAPS_MAGFPOINT 0x01000000L /* Mag Filter */ +#define D3DPTFILTERCAPS_MAGFLINEAR 0x02000000L +#define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000L +#define D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD 0x08000000L +#define D3DPTFILTERCAPS_MAGFGAUSSIANQUAD 0x10000000L + +// +// TextureAddressCaps +// +#define D3DPTADDRESSCAPS_WRAP 0x00000001L +#define D3DPTADDRESSCAPS_MIRROR 0x00000002L +#define D3DPTADDRESSCAPS_CLAMP 0x00000004L +#define D3DPTADDRESSCAPS_BORDER 0x00000008L +#define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010L +#define D3DPTADDRESSCAPS_MIRRORONCE 0x00000020L + +// +// StencilCaps +// +#define D3DSTENCILCAPS_KEEP 0x00000001L +#define D3DSTENCILCAPS_ZERO 0x00000002L +#define D3DSTENCILCAPS_REPLACE 0x00000004L +#define D3DSTENCILCAPS_INCRSAT 0x00000008L +#define D3DSTENCILCAPS_DECRSAT 0x00000010L +#define D3DSTENCILCAPS_INVERT 0x00000020L +#define D3DSTENCILCAPS_INCR 0x00000040L +#define D3DSTENCILCAPS_DECR 0x00000080L +#define D3DSTENCILCAPS_TWOSIDED 0x00000100L + +// +// TextureOpCaps +// +#define D3DTEXOPCAPS_DISABLE 0x00000001L +#define D3DTEXOPCAPS_SELECTARG1 0x00000002L +#define D3DTEXOPCAPS_SELECTARG2 0x00000004L +#define D3DTEXOPCAPS_MODULATE 0x00000008L +#define D3DTEXOPCAPS_MODULATE2X 0x00000010L +#define D3DTEXOPCAPS_MODULATE4X 0x00000020L +#define D3DTEXOPCAPS_ADD 0x00000040L +#define D3DTEXOPCAPS_ADDSIGNED 0x00000080L +#define D3DTEXOPCAPS_ADDSIGNED2X 0x00000100L +#define D3DTEXOPCAPS_SUBTRACT 0x00000200L +#define D3DTEXOPCAPS_ADDSMOOTH 0x00000400L +#define D3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x00000800L +#define D3DTEXOPCAPS_BLENDTEXTUREALPHA 0x00001000L +#define D3DTEXOPCAPS_BLENDFACTORALPHA 0x00002000L +#define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x00004000L +#define D3DTEXOPCAPS_BLENDCURRENTALPHA 0x00008000L +#define D3DTEXOPCAPS_PREMODULATE 0x00010000L +#define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x00020000L +#define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x00040000L +#define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x00080000L +#define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x00100000L +#define D3DTEXOPCAPS_BUMPENVMAP 0x00200000L +#define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x00400000L +#define D3DTEXOPCAPS_DOTPRODUCT3 0x00800000L +#define D3DTEXOPCAPS_MULTIPLYADD 0x01000000L +#define D3DTEXOPCAPS_LERP 0x02000000L + +// +// FVFCaps +// +#define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000ffffL /* mask for texture coordinate count field */ +#define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000L /* Device prefers that vertex elements not be stripped */ +#define D3DFVFCAPS_PSIZE 0x00100000L /* Device can receive point size */ + +// +// VertexProcessingCaps +// +#define D3DVTXPCAPS_TEXGEN 0x00000001L /* device can do texgen */ +#define D3DVTXPCAPS_MATERIALSOURCE7 0x00000002L /* device can do DX7-level colormaterialsource ops */ +#define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008L /* device can do directional lights */ +#define D3DVTXPCAPS_POSITIONALLIGHTS 0x00000010L /* device can do positional lights (includes point and spot) */ +#define D3DVTXPCAPS_LOCALVIEWER 0x00000020L /* device can do local viewer */ +#define D3DVTXPCAPS_TWEENING 0x00000040L /* device can do vertex tweening */ +#define D3DVTXPCAPS_TEXGEN_SPHEREMAP 0x00000100L /* device supports D3DTSS_TCI_SPHEREMAP */ +#define D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER 0x00000200L /* device does not support TexGen in non-local + viewer mode */ + +// +// DevCaps2 +// +#define D3DDEVCAPS2_STREAMOFFSET 0x00000001L /* Device supports offsets in streams. Must be set by DX9 drivers */ +#define D3DDEVCAPS2_DMAPNPATCH 0x00000002L /* Device supports displacement maps for N-Patches*/ +#define D3DDEVCAPS2_ADAPTIVETESSRTPATCH 0x00000004L /* Device supports adaptive tesselation of RT-patches*/ +#define D3DDEVCAPS2_ADAPTIVETESSNPATCH 0x00000008L /* Device supports adaptive tesselation of N-patches*/ +#define D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES 0x00000010L /* Device supports StretchRect calls with a texture as the source*/ +#define D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH 0x00000020L /* Device supports presampled displacement maps for N-Patches */ +#define D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET 0x00000040L /* Vertex elements in a vertex declaration can share the same stream offset */ + +// +// DeclTypes +// +#define D3DDTCAPS_UBYTE4 0x00000001L +#define D3DDTCAPS_UBYTE4N 0x00000002L +#define D3DDTCAPS_SHORT2N 0x00000004L +#define D3DDTCAPS_SHORT4N 0x00000008L +#define D3DDTCAPS_USHORT2N 0x00000010L +#define D3DDTCAPS_USHORT4N 0x00000020L +#define D3DDTCAPS_UDEC3 0x00000040L +#define D3DDTCAPS_DEC3N 0x00000080L +#define D3DDTCAPS_FLOAT16_2 0x00000100L +#define D3DDTCAPS_FLOAT16_4 0x00000200L + + +#pragma pack() + +#endif /* (DIRECT3D_VERSION >= 0x0900) */ +#endif /* _d3d9CAPS_H_ */ + diff --git a/src/dep/include/DXSDK/include/d3d9types.h b/src/dep/include/DXSDK/include/d3d9types.h index 9f6cee8..4c2108f 100644 --- a/src/dep/include/DXSDK/include/d3d9types.h +++ b/src/dep/include/DXSDK/include/d3d9types.h @@ -1,1855 +1,1855 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: d3d9types.h - * Content: Direct3D capabilities include file - * - ***************************************************************************/ - -#ifndef _d3d9TYPES_H_ -#define _d3d9TYPES_H_ - -#ifndef DIRECT3D_VERSION -#define DIRECT3D_VERSION 0x0900 -#endif //DIRECT3D_VERSION - -// include this file content only if compiling for DX9 interfaces -#if(DIRECT3D_VERSION >= 0x0900) - -#include - -#if _MSC_VER >= 1200 -#pragma warning(push) -#endif -#pragma warning(disable:4201) // anonymous unions warning -#if defined(_X86_) || defined(_IA64) -#pragma pack(4) -#endif - -// D3DCOLOR is equivalent to D3DFMT_A8R8G8B8 -#ifndef D3DCOLOR_DEFINED -typedef DWORD D3DCOLOR; -#define D3DCOLOR_DEFINED -#endif - -// maps unsigned 8 bits/channel to D3DCOLOR -#define D3DCOLOR_ARGB(a,r,g,b) \ - ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) -#define D3DCOLOR_RGBA(r,g,b,a) D3DCOLOR_ARGB(a,r,g,b) -#define D3DCOLOR_XRGB(r,g,b) D3DCOLOR_ARGB(0xff,r,g,b) - -#define D3DCOLOR_XYUV(y,u,v) D3DCOLOR_ARGB(0xff,y,u,v) -#define D3DCOLOR_AYUV(a,y,u,v) D3DCOLOR_ARGB(a,y,u,v) - -// maps floating point channels (0.f to 1.f range) to D3DCOLOR -#define D3DCOLOR_COLORVALUE(r,g,b,a) \ - D3DCOLOR_RGBA((DWORD)((r)*255.f),(DWORD)((g)*255.f),(DWORD)((b)*255.f),(DWORD)((a)*255.f)) - - -#ifndef D3DVECTOR_DEFINED -typedef struct _D3DVECTOR { - float x; - float y; - float z; -} D3DVECTOR; -#define D3DVECTOR_DEFINED -#endif - -#ifndef D3DCOLORVALUE_DEFINED -typedef struct _D3DCOLORVALUE { - float r; - float g; - float b; - float a; -} D3DCOLORVALUE; -#define D3DCOLORVALUE_DEFINED -#endif - -#ifndef D3DRECT_DEFINED -typedef struct _D3DRECT { - LONG x1; - LONG y1; - LONG x2; - LONG y2; -} D3DRECT; -#define D3DRECT_DEFINED -#endif - -#ifndef D3DMATRIX_DEFINED -typedef struct _D3DMATRIX { - union { - struct { - float _11, _12, _13, _14; - float _21, _22, _23, _24; - float _31, _32, _33, _34; - float _41, _42, _43, _44; - - }; - float m[4][4]; - }; -} D3DMATRIX; -#define D3DMATRIX_DEFINED -#endif - -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; - -/* - * Values for clip fields. - */ - -// Max number of user clipping planes, supported in D3D. -#define D3DMAXUSERCLIPPLANES 32 - -// These bits could be ORed together to use with D3DRS_CLIPPLANEENABLE -// -#define D3DCLIPPLANE0 (1 << 0) -#define D3DCLIPPLANE1 (1 << 1) -#define D3DCLIPPLANE2 (1 << 2) -#define D3DCLIPPLANE3 (1 << 3) -#define D3DCLIPPLANE4 (1 << 4) -#define D3DCLIPPLANE5 (1 << 5) - -// The following bits are used in the ClipUnion and ClipIntersection -// members of the D3DCLIPSTATUS9 -// - -#define D3DCS_LEFT 0x00000001L -#define D3DCS_RIGHT 0x00000002L -#define D3DCS_TOP 0x00000004L -#define D3DCS_BOTTOM 0x00000008L -#define D3DCS_FRONT 0x00000010L -#define D3DCS_BACK 0x00000020L -#define D3DCS_PLANE0 0x00000040L -#define D3DCS_PLANE1 0x00000080L -#define D3DCS_PLANE2 0x00000100L -#define D3DCS_PLANE3 0x00000200L -#define D3DCS_PLANE4 0x00000400L -#define D3DCS_PLANE5 0x00000800L - -#define D3DCS_ALL (D3DCS_LEFT | \ - D3DCS_RIGHT | \ - D3DCS_TOP | \ - D3DCS_BOTTOM | \ - D3DCS_FRONT | \ - D3DCS_BACK | \ - D3DCS_PLANE0 | \ - D3DCS_PLANE1 | \ - D3DCS_PLANE2 | \ - D3DCS_PLANE3 | \ - D3DCS_PLANE4 | \ - D3DCS_PLANE5) - -typedef struct _D3DCLIPSTATUS9 { - DWORD ClipUnion; - DWORD ClipIntersection; -} D3DCLIPSTATUS9; - -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 enum _D3DLIGHTTYPE { - D3DLIGHT_POINT = 1, - D3DLIGHT_SPOT = 2, - D3DLIGHT_DIRECTIONAL = 3, - D3DLIGHT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DLIGHTTYPE; - -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; - -/* - * 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 */ - -/* - * The following defines the rendering states - */ - -typedef enum _D3DSHADEMODE { - D3DSHADE_FLAT = 1, - D3DSHADE_GOURAUD = 2, - D3DSHADE_PHONG = 3, - D3DSHADE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DSHADEMODE; - -typedef enum _D3DFILLMODE { - D3DFILL_POINT = 1, - D3DFILL_WIREFRAME = 2, - D3DFILL_SOLID = 3, - D3DFILL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DFILLMODE; - -typedef enum _D3DBLEND { - D3DBLEND_ZERO = 1, - D3DBLEND_ONE = 2, - D3DBLEND_SRCCOLOR = 3, - D3DBLEND_INVSRCCOLOR = 4, - D3DBLEND_SRCALPHA = 5, - D3DBLEND_INVSRCALPHA = 6, - D3DBLEND_DESTALPHA = 7, - D3DBLEND_INVDESTALPHA = 8, - D3DBLEND_DESTCOLOR = 9, - D3DBLEND_INVDESTCOLOR = 10, - D3DBLEND_SRCALPHASAT = 11, - D3DBLEND_BOTHSRCALPHA = 12, - D3DBLEND_BOTHINVSRCALPHA = 13, - D3DBLEND_BLENDFACTOR = 14, /* Only supported if D3DPBLENDCAPS_BLENDFACTOR is on */ - D3DBLEND_INVBLENDFACTOR = 15, /* Only supported if D3DPBLENDCAPS_BLENDFACTOR is on */ - D3DBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DBLEND; - -typedef enum _D3DBLENDOP { - D3DBLENDOP_ADD = 1, - D3DBLENDOP_SUBTRACT = 2, - D3DBLENDOP_REVSUBTRACT = 3, - D3DBLENDOP_MIN = 4, - D3DBLENDOP_MAX = 5, - D3DBLENDOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DBLENDOP; - -typedef enum _D3DTEXTUREADDRESS { - D3DTADDRESS_WRAP = 1, - D3DTADDRESS_MIRROR = 2, - D3DTADDRESS_CLAMP = 3, - D3DTADDRESS_BORDER = 4, - D3DTADDRESS_MIRRORONCE = 5, - D3DTADDRESS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DTEXTUREADDRESS; - -typedef enum _D3DCULL { - D3DCULL_NONE = 1, - D3DCULL_CW = 2, - D3DCULL_CCW = 3, - D3DCULL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DCULL; - -typedef enum _D3DCMPFUNC { - D3DCMP_NEVER = 1, - D3DCMP_LESS = 2, - D3DCMP_EQUAL = 3, - D3DCMP_LESSEQUAL = 4, - D3DCMP_GREATER = 5, - D3DCMP_NOTEQUAL = 6, - D3DCMP_GREATEREQUAL = 7, - D3DCMP_ALWAYS = 8, - D3DCMP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DCMPFUNC; - -typedef enum _D3DSTENCILOP { - D3DSTENCILOP_KEEP = 1, - D3DSTENCILOP_ZERO = 2, - D3DSTENCILOP_REPLACE = 3, - D3DSTENCILOP_INCRSAT = 4, - D3DSTENCILOP_DECRSAT = 5, - D3DSTENCILOP_INVERT = 6, - D3DSTENCILOP_INCR = 7, - D3DSTENCILOP_DECR = 8, - D3DSTENCILOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DSTENCILOP; - -typedef enum _D3DFOGMODE { - D3DFOG_NONE = 0, - D3DFOG_EXP = 1, - D3DFOG_EXP2 = 2, - D3DFOG_LINEAR = 3, - D3DFOG_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DFOGMODE; - -typedef enum _D3DZBUFFERTYPE { - D3DZB_FALSE = 0, - D3DZB_TRUE = 1, // Z buffering - D3DZB_USEW = 2, // W buffering - D3DZB_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DZBUFFERTYPE; - -// Primitives supported by draw-primitive API -typedef enum _D3DPRIMITIVETYPE { - D3DPT_POINTLIST = 1, - D3DPT_LINELIST = 2, - D3DPT_LINESTRIP = 3, - D3DPT_TRIANGLELIST = 4, - D3DPT_TRIANGLESTRIP = 5, - D3DPT_TRIANGLEFAN = 6, - D3DPT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DPRIMITIVETYPE; - -typedef enum _D3DTRANSFORMSTATETYPE { - D3DTS_VIEW = 2, - D3DTS_PROJECTION = 3, - D3DTS_TEXTURE0 = 16, - D3DTS_TEXTURE1 = 17, - D3DTS_TEXTURE2 = 18, - D3DTS_TEXTURE3 = 19, - D3DTS_TEXTURE4 = 20, - D3DTS_TEXTURE5 = 21, - D3DTS_TEXTURE6 = 22, - D3DTS_TEXTURE7 = 23, - D3DTS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DTRANSFORMSTATETYPE; - -#define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256) -#define D3DTS_WORLD D3DTS_WORLDMATRIX(0) -#define D3DTS_WORLD1 D3DTS_WORLDMATRIX(1) -#define D3DTS_WORLD2 D3DTS_WORLDMATRIX(2) -#define D3DTS_WORLD3 D3DTS_WORLDMATRIX(3) - -typedef enum _D3DRENDERSTATETYPE { - D3DRS_ZENABLE = 7, /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */ - D3DRS_FILLMODE = 8, /* D3DFILLMODE */ - D3DRS_SHADEMODE = 9, /* D3DSHADEMODE */ - D3DRS_ZWRITEENABLE = 14, /* TRUE to enable z writes */ - D3DRS_ALPHATESTENABLE = 15, /* TRUE to enable alpha tests */ - D3DRS_LASTPIXEL = 16, /* TRUE for last-pixel on lines */ - D3DRS_SRCBLEND = 19, /* D3DBLEND */ - D3DRS_DESTBLEND = 20, /* D3DBLEND */ - D3DRS_CULLMODE = 22, /* D3DCULL */ - D3DRS_ZFUNC = 23, /* D3DCMPFUNC */ - D3DRS_ALPHAREF = 24, /* D3DFIXED */ - D3DRS_ALPHAFUNC = 25, /* D3DCMPFUNC */ - D3DRS_DITHERENABLE = 26, /* TRUE to enable dithering */ - D3DRS_ALPHABLENDENABLE = 27, /* TRUE to enable alpha blending */ - D3DRS_FOGENABLE = 28, /* TRUE to enable fog blending */ - D3DRS_SPECULARENABLE = 29, /* TRUE to enable specular */ - D3DRS_FOGCOLOR = 34, /* D3DCOLOR */ - D3DRS_FOGTABLEMODE = 35, /* D3DFOGMODE */ - D3DRS_FOGSTART = 36, /* Fog start (for both vertex and pixel fog) */ - D3DRS_FOGEND = 37, /* Fog end */ - D3DRS_FOGDENSITY = 38, /* Fog density */ - D3DRS_RANGEFOGENABLE = 48, /* Enables range-based fog */ - D3DRS_STENCILENABLE = 52, /* BOOL enable/disable stenciling */ - D3DRS_STENCILFAIL = 53, /* D3DSTENCILOP to do if stencil test fails */ - D3DRS_STENCILZFAIL = 54, /* D3DSTENCILOP to do if stencil test passes and Z test fails */ - D3DRS_STENCILPASS = 55, /* D3DSTENCILOP to do if both stencil and Z tests pass */ - D3DRS_STENCILFUNC = 56, /* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */ - D3DRS_STENCILREF = 57, /* Reference value used in stencil test */ - D3DRS_STENCILMASK = 58, /* Mask value used in stencil test */ - D3DRS_STENCILWRITEMASK = 59, /* Write mask applied to values written to stencil buffer */ - D3DRS_TEXTUREFACTOR = 60, /* D3DCOLOR used for multi-texture blend */ - D3DRS_WRAP0 = 128, /* wrap for 1st texture coord. set */ - D3DRS_WRAP1 = 129, /* wrap for 2nd texture coord. set */ - D3DRS_WRAP2 = 130, /* wrap for 3rd texture coord. set */ - D3DRS_WRAP3 = 131, /* wrap for 4th texture coord. set */ - D3DRS_WRAP4 = 132, /* wrap for 5th texture coord. set */ - D3DRS_WRAP5 = 133, /* wrap for 6th texture coord. set */ - D3DRS_WRAP6 = 134, /* wrap for 7th texture coord. set */ - D3DRS_WRAP7 = 135, /* wrap for 8th texture coord. set */ - D3DRS_CLIPPING = 136, - D3DRS_LIGHTING = 137, - D3DRS_AMBIENT = 139, - D3DRS_FOGVERTEXMODE = 140, - D3DRS_COLORVERTEX = 141, - D3DRS_LOCALVIEWER = 142, - D3DRS_NORMALIZENORMALS = 143, - D3DRS_DIFFUSEMATERIALSOURCE = 145, - D3DRS_SPECULARMATERIALSOURCE = 146, - D3DRS_AMBIENTMATERIALSOURCE = 147, - D3DRS_EMISSIVEMATERIALSOURCE = 148, - D3DRS_VERTEXBLEND = 151, - D3DRS_CLIPPLANEENABLE = 152, - D3DRS_POINTSIZE = 154, /* float point size */ - D3DRS_POINTSIZE_MIN = 155, /* float point size min threshold */ - D3DRS_POINTSPRITEENABLE = 156, /* BOOL point texture coord control */ - D3DRS_POINTSCALEENABLE = 157, /* BOOL point size scale enable */ - D3DRS_POINTSCALE_A = 158, /* float point attenuation A value */ - D3DRS_POINTSCALE_B = 159, /* float point attenuation B value */ - D3DRS_POINTSCALE_C = 160, /* float point attenuation C value */ - D3DRS_MULTISAMPLEANTIALIAS = 161, // BOOL - set to do FSAA with multisample buffer - D3DRS_MULTISAMPLEMASK = 162, // DWORD - per-sample enable/disable - D3DRS_PATCHEDGESTYLE = 163, // Sets whether patch edges will use float style tessellation - D3DRS_DEBUGMONITORTOKEN = 165, // DEBUG ONLY - token to debug monitor - D3DRS_POINTSIZE_MAX = 166, /* float point size max threshold */ - D3DRS_INDEXEDVERTEXBLENDENABLE = 167, - D3DRS_COLORWRITEENABLE = 168, // per-channel write enable - D3DRS_TWEENFACTOR = 170, // float tween factor - D3DRS_BLENDOP = 171, // D3DBLENDOP setting - D3DRS_POSITIONDEGREE = 172, // NPatch position interpolation degree. D3DDEGREE_LINEAR or D3DDEGREE_CUBIC (default) - D3DRS_NORMALDEGREE = 173, // NPatch normal interpolation degree. D3DDEGREE_LINEAR (default) or D3DDEGREE_QUADRATIC - D3DRS_SCISSORTESTENABLE = 174, - D3DRS_SLOPESCALEDEPTHBIAS = 175, - D3DRS_ANTIALIASEDLINEENABLE = 176, - D3DRS_MINTESSELLATIONLEVEL = 178, - D3DRS_MAXTESSELLATIONLEVEL = 179, - D3DRS_ADAPTIVETESS_X = 180, - D3DRS_ADAPTIVETESS_Y = 181, - D3DRS_ADAPTIVETESS_Z = 182, - D3DRS_ADAPTIVETESS_W = 183, - D3DRS_ENABLEADAPTIVETESSELLATION = 184, - D3DRS_TWOSIDEDSTENCILMODE = 185, /* BOOL enable/disable 2 sided stenciling */ - D3DRS_CCW_STENCILFAIL = 186, /* D3DSTENCILOP to do if ccw stencil test fails */ - D3DRS_CCW_STENCILZFAIL = 187, /* D3DSTENCILOP to do if ccw stencil test passes and Z test fails */ - D3DRS_CCW_STENCILPASS = 188, /* D3DSTENCILOP to do if both ccw stencil and Z tests pass */ - D3DRS_CCW_STENCILFUNC = 189, /* D3DCMPFUNC fn. ccw Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */ - D3DRS_COLORWRITEENABLE1 = 190, /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */ - D3DRS_COLORWRITEENABLE2 = 191, /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */ - D3DRS_COLORWRITEENABLE3 = 192, /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */ - D3DRS_BLENDFACTOR = 193, /* D3DCOLOR used for a constant blend factor during alpha blending for devices that support D3DPBLENDCAPS_BLENDFACTOR */ - D3DRS_SRGBWRITEENABLE = 194, /* Enable rendertarget writes to be DE-linearized to SRGB (for formats that expose D3DUSAGE_QUERY_SRGBWRITE) */ - D3DRS_DEPTHBIAS = 195, - D3DRS_WRAP8 = 198, /* Additional wrap states for vs_3_0+ attributes with D3DDECLUSAGE_TEXCOORD */ - D3DRS_WRAP9 = 199, - D3DRS_WRAP10 = 200, - D3DRS_WRAP11 = 201, - D3DRS_WRAP12 = 202, - D3DRS_WRAP13 = 203, - D3DRS_WRAP14 = 204, - D3DRS_WRAP15 = 205, - D3DRS_SEPARATEALPHABLENDENABLE = 206, /* TRUE to enable a separate blending function for the alpha channel */ - D3DRS_SRCBLENDALPHA = 207, /* SRC blend factor for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */ - D3DRS_DESTBLENDALPHA = 208, /* DST blend factor for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */ - D3DRS_BLENDOPALPHA = 209, /* Blending operation for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */ - - - D3DRS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DRENDERSTATETYPE; - -// Maximum number of simultaneous render targets D3D supports -#define D3D_MAX_SIMULTANEOUS_RENDERTARGETS 4 - -// Values for material source -typedef enum _D3DMATERIALCOLORSOURCE -{ - D3DMCS_MATERIAL = 0, // Color from material is used - D3DMCS_COLOR1 = 1, // Diffuse vertex color is used - D3DMCS_COLOR2 = 2, // Specular vertex color is used - D3DMCS_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum -} D3DMATERIALCOLORSOURCE; - -// Bias to apply to the texture coordinate set to apply a wrap to. -#define D3DRENDERSTATE_WRAPBIAS 128UL - -/* Flags to construct the WRAP render states */ -#define D3DWRAP_U 0x00000001L -#define D3DWRAP_V 0x00000002L -#define D3DWRAP_W 0x00000004L - -/* Flags to construct the WRAP render states for 1D thru 4D texture coordinates */ -#define D3DWRAPCOORD_0 0x00000001L // same as D3DWRAP_U -#define D3DWRAPCOORD_1 0x00000002L // same as D3DWRAP_V -#define D3DWRAPCOORD_2 0x00000004L // same as D3DWRAP_W -#define D3DWRAPCOORD_3 0x00000008L - -/* 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) - -/* - * State enumerants for per-stage processing of fixed function pixel processing - * Two of these affect fixed function vertex processing as well: TEXTURETRANSFORMFLAGS and TEXCOORDINDEX. - */ -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_BUMPENVLSCALE = 22, /* float scale for bump map luminance */ - 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_ALPHAARG0 = 27, /* D3DTA_* third arg for triadic ops */ - D3DTSS_RESULTARG = 28, /* D3DTA_* arg for result (CURRENT or TEMP) */ - D3DTSS_CONSTANT = 32, /* Per-stage constant D3DTA_CONSTANT */ - - - D3DTSS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DTEXTURESTAGESTATETYPE; - -/* - * State enumerants for per-sampler texture processing. - */ -typedef enum _D3DSAMPLERSTATETYPE -{ - D3DSAMP_ADDRESSU = 1, /* D3DTEXTUREADDRESS for U coordinate */ - D3DSAMP_ADDRESSV = 2, /* D3DTEXTUREADDRESS for V coordinate */ - D3DSAMP_ADDRESSW = 3, /* D3DTEXTUREADDRESS for W coordinate */ - D3DSAMP_BORDERCOLOR = 4, /* D3DCOLOR */ - D3DSAMP_MAGFILTER = 5, /* D3DTEXTUREFILTER filter to use for magnification */ - D3DSAMP_MINFILTER = 6, /* D3DTEXTUREFILTER filter to use for minification */ - D3DSAMP_MIPFILTER = 7, /* D3DTEXTUREFILTER filter to use between mipmaps during minification */ - D3DSAMP_MIPMAPLODBIAS = 8, /* float Mipmap LOD bias */ - D3DSAMP_MAXMIPLEVEL = 9, /* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) */ - D3DSAMP_MAXANISOTROPY = 10, /* DWORD maximum anisotropy */ - D3DSAMP_SRGBTEXTURE = 11, /* Default = 0 (which means Gamma 1.0, - no correction required.) else correct for - Gamma = 2.2 */ - D3DSAMP_ELEMENTINDEX = 12, /* When multi-element texture is assigned to sampler, this - indicates which element index to use. Default = 0. */ - D3DSAMP_DMAPOFFSET = 13, /* Offset in vertices in the pre-sampled displacement map. - Only valid for D3DDMAPSAMPLER sampler */ - D3DSAMP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DSAMPLERSTATETYPE; - -/* Special sampler which is used in the tesselator */ -#define D3DDMAPSAMPLER 256 - -// Samplers used in vertex shaders -#define D3DVERTEXTEXTURESAMPLER0 (D3DDMAPSAMPLER+1) -#define D3DVERTEXTEXTURESAMPLER1 (D3DDMAPSAMPLER+2) -#define D3DVERTEXTEXTURESAMPLER2 (D3DDMAPSAMPLER+3) -#define D3DVERTEXTEXTURESAMPLER3 (D3DDMAPSAMPLER+4) - -// Values, used with D3DTSS_TEXCOORDINDEX, to specify that the vertex data(position -// and normal in the camera space) should be taken as texture coordinates -// Low 16 bits are used to specify texture coordinate index, to take the WRAP mode from -// -#define D3DTSS_TCI_PASSTHRU 0x00000000 -#define D3DTSS_TCI_CAMERASPACENORMAL 0x00010000 -#define D3DTSS_TCI_CAMERASPACEPOSITION 0x00020000 -#define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR 0x00030000 -#define D3DTSS_TCI_SPHEREMAP 0x00040000 - -/* - * Enumerations for COLOROP and ALPHAOP texture blending operations set in - * texture processing stage controls in D3DTSS. - */ -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; - -/* - * Values for COLORARG0,1,2, ALPHAARG0,1,2, and RESULTARG texture blending - * operations set in texture processing stage controls in D3DRENDERSTATE. - */ -#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) - -// -// Values for D3DSAMP_***FILTER texture stage states -// -typedef enum _D3DTEXTUREFILTERTYPE -{ - D3DTEXF_NONE = 0, // filtering disabled (valid for mip filter only) - D3DTEXF_POINT = 1, // nearest - D3DTEXF_LINEAR = 2, // linear interpolation - D3DTEXF_ANISOTROPIC = 3, // anisotropic - D3DTEXF_PYRAMIDALQUAD = 6, // 4-sample tent - D3DTEXF_GAUSSIANQUAD = 7, // 4-sample gaussian - D3DTEXF_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum -} D3DTEXTUREFILTERTYPE; - -/* Bits for Flags in ProcessVertices call */ - -#define D3DPV_DONOTCOPYDATA (1 << 0) - -//------------------------------------------------------------------- - -// 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 - -//--------------------------------------------------------------------- -// Vertex Shaders -// - -// Vertex shader declaration - -// Vertex element semantics -// -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; - -#define MAXD3DDECLUSAGE D3DDECLUSAGE_SAMPLE -#define MAXD3DDECLUSAGEINDEX 15 -#define MAXD3DDECLLENGTH 64 // does not include "end" marker vertex element - -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; - -#define MAXD3DDECLMETHOD D3DDECLMETHOD_LOOKUPPRESAMPLED - -// Declarations for _Type fields -// -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; - -#define MAXD3DDECLTYPE D3DDECLTYPE_UNUSED - -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; - -// This is used to initialize the last vertex element in a vertex declaration -// array -// -#define D3DDECL_END() {0xFF,0,D3DDECLTYPE_UNUSED,0,0,0} - -// Maximum supported number of texture coordinate sets -#define D3DDP_MAXTEXCOORD 8 - -//--------------------------------------------------------------------- -// Values for IDirect3DDevice9::SetStreamSourceFreq's Setting parameter -//--------------------------------------------------------------------- -#define D3DSTREAMSOURCE_INDEXEDDATA (1<<30) -#define D3DSTREAMSOURCE_INSTANCEDATA (2<<30) - - - -//--------------------------------------------------------------------- -// -// The internal format of Pixel Shader (PS) & Vertex Shader (VS) -// Instruction Tokens is defined in the Direct3D Device Driver Kit -// -//--------------------------------------------------------------------- - -// -// Instruction Token Bit Definitions -// -#define D3DSI_OPCODE_MASK 0x0000FFFF - -#define D3DSI_INSTLENGTH_MASK 0x0F000000 -#define D3DSI_INSTLENGTH_SHIFT 24 - -typedef enum _D3DSHADER_INSTRUCTION_OPCODE_TYPE -{ - D3DSIO_NOP = 0, - D3DSIO_MOV , - D3DSIO_ADD , - D3DSIO_SUB , - D3DSIO_MAD , - D3DSIO_MUL , - D3DSIO_RCP , - D3DSIO_RSQ , - D3DSIO_DP3 , - D3DSIO_DP4 , - D3DSIO_MIN , - D3DSIO_MAX , - D3DSIO_SLT , - D3DSIO_SGE , - D3DSIO_EXP , - D3DSIO_LOG , - D3DSIO_LIT , - D3DSIO_DST , - D3DSIO_LRP , - D3DSIO_FRC , - D3DSIO_M4x4 , - D3DSIO_M4x3 , - D3DSIO_M3x4 , - D3DSIO_M3x3 , - D3DSIO_M3x2 , - D3DSIO_CALL , - D3DSIO_CALLNZ , - D3DSIO_LOOP , - D3DSIO_RET , - D3DSIO_ENDLOOP , - D3DSIO_LABEL , - D3DSIO_DCL , - D3DSIO_POW , - D3DSIO_CRS , - D3DSIO_SGN , - D3DSIO_ABS , - D3DSIO_NRM , - D3DSIO_SINCOS , - D3DSIO_REP , - D3DSIO_ENDREP , - D3DSIO_IF , - D3DSIO_IFC , - D3DSIO_ELSE , - D3DSIO_ENDIF , - D3DSIO_BREAK , - D3DSIO_BREAKC , - D3DSIO_MOVA , - D3DSIO_DEFB , - D3DSIO_DEFI , - - D3DSIO_TEXCOORD = 64, - D3DSIO_TEXKILL , - D3DSIO_TEX , - D3DSIO_TEXBEM , - D3DSIO_TEXBEML , - D3DSIO_TEXREG2AR , - D3DSIO_TEXREG2GB , - D3DSIO_TEXM3x2PAD , - D3DSIO_TEXM3x2TEX , - D3DSIO_TEXM3x3PAD , - D3DSIO_TEXM3x3TEX , - D3DSIO_RESERVED0 , - D3DSIO_TEXM3x3SPEC , - D3DSIO_TEXM3x3VSPEC , - D3DSIO_EXPP , - D3DSIO_LOGP , - D3DSIO_CND , - D3DSIO_DEF , - D3DSIO_TEXREG2RGB , - D3DSIO_TEXDP3TEX , - D3DSIO_TEXM3x2DEPTH , - D3DSIO_TEXDP3 , - D3DSIO_TEXM3x3 , - D3DSIO_TEXDEPTH , - D3DSIO_CMP , - D3DSIO_BEM , - D3DSIO_DP2ADD , - D3DSIO_DSX , - D3DSIO_DSY , - D3DSIO_TEXLDD , - D3DSIO_SETP , - D3DSIO_TEXLDL , - D3DSIO_BREAKP , - - D3DSIO_PHASE = 0xFFFD, - D3DSIO_COMMENT = 0xFFFE, - D3DSIO_END = 0xFFFF, - - D3DSIO_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum -} D3DSHADER_INSTRUCTION_OPCODE_TYPE; - -//--------------------------------------------------------------------- -// Use these constants with D3DSIO_SINCOS macro as SRC2, SRC3 -// -#define D3DSINCOSCONST1 -1.5500992e-006f, -2.1701389e-005f, 0.0026041667f, 0.00026041668f -#define D3DSINCOSCONST2 -0.020833334f, -0.12500000f, 1.0f, 0.50000000f - -//--------------------------------------------------------------------- -// Co-Issue Instruction Modifier - if set then this instruction is to be -// issued in parallel with the previous instruction(s) for which this bit -// is not set. -// -#define D3DSI_COISSUE 0x40000000 - -//--------------------------------------------------------------------- -// Opcode specific controls - -#define D3DSP_OPCODESPECIFICCONTROL_MASK 0x00ff0000 -#define D3DSP_OPCODESPECIFICCONTROL_SHIFT 16 - -// ps_2_0 texld controls -#define D3DSI_TEXLD_PROJECT (0x01 << D3DSP_OPCODESPECIFICCONTROL_SHIFT) -#define D3DSI_TEXLD_BIAS (0x02 << D3DSP_OPCODESPECIFICCONTROL_SHIFT) - -// Comparison for dynamic conditional instruction opcodes (i.e. if, breakc) -typedef enum _D3DSHADER_COMPARISON -{ - // < = > - D3DSPC_RESERVED0= 0, // 0 0 0 - D3DSPC_GT = 1, // 0 0 1 - D3DSPC_EQ = 2, // 0 1 0 - D3DSPC_GE = 3, // 0 1 1 - D3DSPC_LT = 4, // 1 0 0 - D3DSPC_NE = 5, // 1 0 1 - D3DSPC_LE = 6, // 1 1 0 - D3DSPC_RESERVED1= 7 // 1 1 1 -} D3DSHADER_COMPARISON; - -// Comparison is part of instruction opcode token: -#define D3DSHADER_COMPARISON_SHIFT D3DSP_OPCODESPECIFICCONTROL_SHIFT -#define D3DSHADER_COMPARISON_MASK (0x7<>8)&0xFF) -#define D3DSHADER_VERSION_MINOR(_Version) (((_Version)>>0)&0xFF) - -// destination/source parameter register type -#define D3DSI_COMMENTSIZE_SHIFT 16 -#define D3DSI_COMMENTSIZE_MASK 0x7FFF0000 -#define D3DSHADER_COMMENT(_DWordSize) \ - ((((_DWordSize)<= 1200 -#pragma warning(pop) -#else -#pragma warning(default:4201) -#endif - -#endif /* (DIRECT3D_VERSION >= 0x0900) */ -#endif /* _d3d9TYPES(P)_H_ */ - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3d9types.h + * Content: Direct3D capabilities include file + * + ***************************************************************************/ + +#ifndef _d3d9TYPES_H_ +#define _d3d9TYPES_H_ + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0900 +#endif //DIRECT3D_VERSION + +// include this file content only if compiling for DX9 interfaces +#if(DIRECT3D_VERSION >= 0x0900) + +#include + +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif +#pragma warning(disable:4201) // anonymous unions warning +#if defined(_X86_) || defined(_IA64) +#pragma pack(4) +#endif + +// D3DCOLOR is equivalent to D3DFMT_A8R8G8B8 +#ifndef D3DCOLOR_DEFINED +typedef DWORD D3DCOLOR; +#define D3DCOLOR_DEFINED +#endif + +// maps unsigned 8 bits/channel to D3DCOLOR +#define D3DCOLOR_ARGB(a,r,g,b) \ + ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) +#define D3DCOLOR_RGBA(r,g,b,a) D3DCOLOR_ARGB(a,r,g,b) +#define D3DCOLOR_XRGB(r,g,b) D3DCOLOR_ARGB(0xff,r,g,b) + +#define D3DCOLOR_XYUV(y,u,v) D3DCOLOR_ARGB(0xff,y,u,v) +#define D3DCOLOR_AYUV(a,y,u,v) D3DCOLOR_ARGB(a,y,u,v) + +// maps floating point channels (0.f to 1.f range) to D3DCOLOR +#define D3DCOLOR_COLORVALUE(r,g,b,a) \ + D3DCOLOR_RGBA((DWORD)((r)*255.f),(DWORD)((g)*255.f),(DWORD)((b)*255.f),(DWORD)((a)*255.f)) + + +#ifndef D3DVECTOR_DEFINED +typedef struct _D3DVECTOR { + float x; + float y; + float z; +} D3DVECTOR; +#define D3DVECTOR_DEFINED +#endif + +#ifndef D3DCOLORVALUE_DEFINED +typedef struct _D3DCOLORVALUE { + float r; + float g; + float b; + float a; +} D3DCOLORVALUE; +#define D3DCOLORVALUE_DEFINED +#endif + +#ifndef D3DRECT_DEFINED +typedef struct _D3DRECT { + LONG x1; + LONG y1; + LONG x2; + LONG y2; +} D3DRECT; +#define D3DRECT_DEFINED +#endif + +#ifndef D3DMATRIX_DEFINED +typedef struct _D3DMATRIX { + union { + struct { + float _11, _12, _13, _14; + float _21, _22, _23, _24; + float _31, _32, _33, _34; + float _41, _42, _43, _44; + + }; + float m[4][4]; + }; +} D3DMATRIX; +#define D3DMATRIX_DEFINED +#endif + +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; + +/* + * Values for clip fields. + */ + +// Max number of user clipping planes, supported in D3D. +#define D3DMAXUSERCLIPPLANES 32 + +// These bits could be ORed together to use with D3DRS_CLIPPLANEENABLE +// +#define D3DCLIPPLANE0 (1 << 0) +#define D3DCLIPPLANE1 (1 << 1) +#define D3DCLIPPLANE2 (1 << 2) +#define D3DCLIPPLANE3 (1 << 3) +#define D3DCLIPPLANE4 (1 << 4) +#define D3DCLIPPLANE5 (1 << 5) + +// The following bits are used in the ClipUnion and ClipIntersection +// members of the D3DCLIPSTATUS9 +// + +#define D3DCS_LEFT 0x00000001L +#define D3DCS_RIGHT 0x00000002L +#define D3DCS_TOP 0x00000004L +#define D3DCS_BOTTOM 0x00000008L +#define D3DCS_FRONT 0x00000010L +#define D3DCS_BACK 0x00000020L +#define D3DCS_PLANE0 0x00000040L +#define D3DCS_PLANE1 0x00000080L +#define D3DCS_PLANE2 0x00000100L +#define D3DCS_PLANE3 0x00000200L +#define D3DCS_PLANE4 0x00000400L +#define D3DCS_PLANE5 0x00000800L + +#define D3DCS_ALL (D3DCS_LEFT | \ + D3DCS_RIGHT | \ + D3DCS_TOP | \ + D3DCS_BOTTOM | \ + D3DCS_FRONT | \ + D3DCS_BACK | \ + D3DCS_PLANE0 | \ + D3DCS_PLANE1 | \ + D3DCS_PLANE2 | \ + D3DCS_PLANE3 | \ + D3DCS_PLANE4 | \ + D3DCS_PLANE5) + +typedef struct _D3DCLIPSTATUS9 { + DWORD ClipUnion; + DWORD ClipIntersection; +} D3DCLIPSTATUS9; + +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 enum _D3DLIGHTTYPE { + D3DLIGHT_POINT = 1, + D3DLIGHT_SPOT = 2, + D3DLIGHT_DIRECTIONAL = 3, + D3DLIGHT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DLIGHTTYPE; + +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; + +/* + * 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 */ + +/* + * The following defines the rendering states + */ + +typedef enum _D3DSHADEMODE { + D3DSHADE_FLAT = 1, + D3DSHADE_GOURAUD = 2, + D3DSHADE_PHONG = 3, + D3DSHADE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DSHADEMODE; + +typedef enum _D3DFILLMODE { + D3DFILL_POINT = 1, + D3DFILL_WIREFRAME = 2, + D3DFILL_SOLID = 3, + D3DFILL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DFILLMODE; + +typedef enum _D3DBLEND { + D3DBLEND_ZERO = 1, + D3DBLEND_ONE = 2, + D3DBLEND_SRCCOLOR = 3, + D3DBLEND_INVSRCCOLOR = 4, + D3DBLEND_SRCALPHA = 5, + D3DBLEND_INVSRCALPHA = 6, + D3DBLEND_DESTALPHA = 7, + D3DBLEND_INVDESTALPHA = 8, + D3DBLEND_DESTCOLOR = 9, + D3DBLEND_INVDESTCOLOR = 10, + D3DBLEND_SRCALPHASAT = 11, + D3DBLEND_BOTHSRCALPHA = 12, + D3DBLEND_BOTHINVSRCALPHA = 13, + D3DBLEND_BLENDFACTOR = 14, /* Only supported if D3DPBLENDCAPS_BLENDFACTOR is on */ + D3DBLEND_INVBLENDFACTOR = 15, /* Only supported if D3DPBLENDCAPS_BLENDFACTOR is on */ + D3DBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DBLEND; + +typedef enum _D3DBLENDOP { + D3DBLENDOP_ADD = 1, + D3DBLENDOP_SUBTRACT = 2, + D3DBLENDOP_REVSUBTRACT = 3, + D3DBLENDOP_MIN = 4, + D3DBLENDOP_MAX = 5, + D3DBLENDOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DBLENDOP; + +typedef enum _D3DTEXTUREADDRESS { + D3DTADDRESS_WRAP = 1, + D3DTADDRESS_MIRROR = 2, + D3DTADDRESS_CLAMP = 3, + D3DTADDRESS_BORDER = 4, + D3DTADDRESS_MIRRORONCE = 5, + D3DTADDRESS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DTEXTUREADDRESS; + +typedef enum _D3DCULL { + D3DCULL_NONE = 1, + D3DCULL_CW = 2, + D3DCULL_CCW = 3, + D3DCULL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DCULL; + +typedef enum _D3DCMPFUNC { + D3DCMP_NEVER = 1, + D3DCMP_LESS = 2, + D3DCMP_EQUAL = 3, + D3DCMP_LESSEQUAL = 4, + D3DCMP_GREATER = 5, + D3DCMP_NOTEQUAL = 6, + D3DCMP_GREATEREQUAL = 7, + D3DCMP_ALWAYS = 8, + D3DCMP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DCMPFUNC; + +typedef enum _D3DSTENCILOP { + D3DSTENCILOP_KEEP = 1, + D3DSTENCILOP_ZERO = 2, + D3DSTENCILOP_REPLACE = 3, + D3DSTENCILOP_INCRSAT = 4, + D3DSTENCILOP_DECRSAT = 5, + D3DSTENCILOP_INVERT = 6, + D3DSTENCILOP_INCR = 7, + D3DSTENCILOP_DECR = 8, + D3DSTENCILOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DSTENCILOP; + +typedef enum _D3DFOGMODE { + D3DFOG_NONE = 0, + D3DFOG_EXP = 1, + D3DFOG_EXP2 = 2, + D3DFOG_LINEAR = 3, + D3DFOG_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DFOGMODE; + +typedef enum _D3DZBUFFERTYPE { + D3DZB_FALSE = 0, + D3DZB_TRUE = 1, // Z buffering + D3DZB_USEW = 2, // W buffering + D3DZB_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DZBUFFERTYPE; + +// Primitives supported by draw-primitive API +typedef enum _D3DPRIMITIVETYPE { + D3DPT_POINTLIST = 1, + D3DPT_LINELIST = 2, + D3DPT_LINESTRIP = 3, + D3DPT_TRIANGLELIST = 4, + D3DPT_TRIANGLESTRIP = 5, + D3DPT_TRIANGLEFAN = 6, + D3DPT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DPRIMITIVETYPE; + +typedef enum _D3DTRANSFORMSTATETYPE { + D3DTS_VIEW = 2, + D3DTS_PROJECTION = 3, + D3DTS_TEXTURE0 = 16, + D3DTS_TEXTURE1 = 17, + D3DTS_TEXTURE2 = 18, + D3DTS_TEXTURE3 = 19, + D3DTS_TEXTURE4 = 20, + D3DTS_TEXTURE5 = 21, + D3DTS_TEXTURE6 = 22, + D3DTS_TEXTURE7 = 23, + D3DTS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DTRANSFORMSTATETYPE; + +#define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256) +#define D3DTS_WORLD D3DTS_WORLDMATRIX(0) +#define D3DTS_WORLD1 D3DTS_WORLDMATRIX(1) +#define D3DTS_WORLD2 D3DTS_WORLDMATRIX(2) +#define D3DTS_WORLD3 D3DTS_WORLDMATRIX(3) + +typedef enum _D3DRENDERSTATETYPE { + D3DRS_ZENABLE = 7, /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */ + D3DRS_FILLMODE = 8, /* D3DFILLMODE */ + D3DRS_SHADEMODE = 9, /* D3DSHADEMODE */ + D3DRS_ZWRITEENABLE = 14, /* TRUE to enable z writes */ + D3DRS_ALPHATESTENABLE = 15, /* TRUE to enable alpha tests */ + D3DRS_LASTPIXEL = 16, /* TRUE for last-pixel on lines */ + D3DRS_SRCBLEND = 19, /* D3DBLEND */ + D3DRS_DESTBLEND = 20, /* D3DBLEND */ + D3DRS_CULLMODE = 22, /* D3DCULL */ + D3DRS_ZFUNC = 23, /* D3DCMPFUNC */ + D3DRS_ALPHAREF = 24, /* D3DFIXED */ + D3DRS_ALPHAFUNC = 25, /* D3DCMPFUNC */ + D3DRS_DITHERENABLE = 26, /* TRUE to enable dithering */ + D3DRS_ALPHABLENDENABLE = 27, /* TRUE to enable alpha blending */ + D3DRS_FOGENABLE = 28, /* TRUE to enable fog blending */ + D3DRS_SPECULARENABLE = 29, /* TRUE to enable specular */ + D3DRS_FOGCOLOR = 34, /* D3DCOLOR */ + D3DRS_FOGTABLEMODE = 35, /* D3DFOGMODE */ + D3DRS_FOGSTART = 36, /* Fog start (for both vertex and pixel fog) */ + D3DRS_FOGEND = 37, /* Fog end */ + D3DRS_FOGDENSITY = 38, /* Fog density */ + D3DRS_RANGEFOGENABLE = 48, /* Enables range-based fog */ + D3DRS_STENCILENABLE = 52, /* BOOL enable/disable stenciling */ + D3DRS_STENCILFAIL = 53, /* D3DSTENCILOP to do if stencil test fails */ + D3DRS_STENCILZFAIL = 54, /* D3DSTENCILOP to do if stencil test passes and Z test fails */ + D3DRS_STENCILPASS = 55, /* D3DSTENCILOP to do if both stencil and Z tests pass */ + D3DRS_STENCILFUNC = 56, /* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */ + D3DRS_STENCILREF = 57, /* Reference value used in stencil test */ + D3DRS_STENCILMASK = 58, /* Mask value used in stencil test */ + D3DRS_STENCILWRITEMASK = 59, /* Write mask applied to values written to stencil buffer */ + D3DRS_TEXTUREFACTOR = 60, /* D3DCOLOR used for multi-texture blend */ + D3DRS_WRAP0 = 128, /* wrap for 1st texture coord. set */ + D3DRS_WRAP1 = 129, /* wrap for 2nd texture coord. set */ + D3DRS_WRAP2 = 130, /* wrap for 3rd texture coord. set */ + D3DRS_WRAP3 = 131, /* wrap for 4th texture coord. set */ + D3DRS_WRAP4 = 132, /* wrap for 5th texture coord. set */ + D3DRS_WRAP5 = 133, /* wrap for 6th texture coord. set */ + D3DRS_WRAP6 = 134, /* wrap for 7th texture coord. set */ + D3DRS_WRAP7 = 135, /* wrap for 8th texture coord. set */ + D3DRS_CLIPPING = 136, + D3DRS_LIGHTING = 137, + D3DRS_AMBIENT = 139, + D3DRS_FOGVERTEXMODE = 140, + D3DRS_COLORVERTEX = 141, + D3DRS_LOCALVIEWER = 142, + D3DRS_NORMALIZENORMALS = 143, + D3DRS_DIFFUSEMATERIALSOURCE = 145, + D3DRS_SPECULARMATERIALSOURCE = 146, + D3DRS_AMBIENTMATERIALSOURCE = 147, + D3DRS_EMISSIVEMATERIALSOURCE = 148, + D3DRS_VERTEXBLEND = 151, + D3DRS_CLIPPLANEENABLE = 152, + D3DRS_POINTSIZE = 154, /* float point size */ + D3DRS_POINTSIZE_MIN = 155, /* float point size min threshold */ + D3DRS_POINTSPRITEENABLE = 156, /* BOOL point texture coord control */ + D3DRS_POINTSCALEENABLE = 157, /* BOOL point size scale enable */ + D3DRS_POINTSCALE_A = 158, /* float point attenuation A value */ + D3DRS_POINTSCALE_B = 159, /* float point attenuation B value */ + D3DRS_POINTSCALE_C = 160, /* float point attenuation C value */ + D3DRS_MULTISAMPLEANTIALIAS = 161, // BOOL - set to do FSAA with multisample buffer + D3DRS_MULTISAMPLEMASK = 162, // DWORD - per-sample enable/disable + D3DRS_PATCHEDGESTYLE = 163, // Sets whether patch edges will use float style tessellation + D3DRS_DEBUGMONITORTOKEN = 165, // DEBUG ONLY - token to debug monitor + D3DRS_POINTSIZE_MAX = 166, /* float point size max threshold */ + D3DRS_INDEXEDVERTEXBLENDENABLE = 167, + D3DRS_COLORWRITEENABLE = 168, // per-channel write enable + D3DRS_TWEENFACTOR = 170, // float tween factor + D3DRS_BLENDOP = 171, // D3DBLENDOP setting + D3DRS_POSITIONDEGREE = 172, // NPatch position interpolation degree. D3DDEGREE_LINEAR or D3DDEGREE_CUBIC (default) + D3DRS_NORMALDEGREE = 173, // NPatch normal interpolation degree. D3DDEGREE_LINEAR (default) or D3DDEGREE_QUADRATIC + D3DRS_SCISSORTESTENABLE = 174, + D3DRS_SLOPESCALEDEPTHBIAS = 175, + D3DRS_ANTIALIASEDLINEENABLE = 176, + D3DRS_MINTESSELLATIONLEVEL = 178, + D3DRS_MAXTESSELLATIONLEVEL = 179, + D3DRS_ADAPTIVETESS_X = 180, + D3DRS_ADAPTIVETESS_Y = 181, + D3DRS_ADAPTIVETESS_Z = 182, + D3DRS_ADAPTIVETESS_W = 183, + D3DRS_ENABLEADAPTIVETESSELLATION = 184, + D3DRS_TWOSIDEDSTENCILMODE = 185, /* BOOL enable/disable 2 sided stenciling */ + D3DRS_CCW_STENCILFAIL = 186, /* D3DSTENCILOP to do if ccw stencil test fails */ + D3DRS_CCW_STENCILZFAIL = 187, /* D3DSTENCILOP to do if ccw stencil test passes and Z test fails */ + D3DRS_CCW_STENCILPASS = 188, /* D3DSTENCILOP to do if both ccw stencil and Z tests pass */ + D3DRS_CCW_STENCILFUNC = 189, /* D3DCMPFUNC fn. ccw Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */ + D3DRS_COLORWRITEENABLE1 = 190, /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */ + D3DRS_COLORWRITEENABLE2 = 191, /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */ + D3DRS_COLORWRITEENABLE3 = 192, /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */ + D3DRS_BLENDFACTOR = 193, /* D3DCOLOR used for a constant blend factor during alpha blending for devices that support D3DPBLENDCAPS_BLENDFACTOR */ + D3DRS_SRGBWRITEENABLE = 194, /* Enable rendertarget writes to be DE-linearized to SRGB (for formats that expose D3DUSAGE_QUERY_SRGBWRITE) */ + D3DRS_DEPTHBIAS = 195, + D3DRS_WRAP8 = 198, /* Additional wrap states for vs_3_0+ attributes with D3DDECLUSAGE_TEXCOORD */ + D3DRS_WRAP9 = 199, + D3DRS_WRAP10 = 200, + D3DRS_WRAP11 = 201, + D3DRS_WRAP12 = 202, + D3DRS_WRAP13 = 203, + D3DRS_WRAP14 = 204, + D3DRS_WRAP15 = 205, + D3DRS_SEPARATEALPHABLENDENABLE = 206, /* TRUE to enable a separate blending function for the alpha channel */ + D3DRS_SRCBLENDALPHA = 207, /* SRC blend factor for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */ + D3DRS_DESTBLENDALPHA = 208, /* DST blend factor for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */ + D3DRS_BLENDOPALPHA = 209, /* Blending operation for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */ + + + D3DRS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DRENDERSTATETYPE; + +// Maximum number of simultaneous render targets D3D supports +#define D3D_MAX_SIMULTANEOUS_RENDERTARGETS 4 + +// Values for material source +typedef enum _D3DMATERIALCOLORSOURCE +{ + D3DMCS_MATERIAL = 0, // Color from material is used + D3DMCS_COLOR1 = 1, // Diffuse vertex color is used + D3DMCS_COLOR2 = 2, // Specular vertex color is used + D3DMCS_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum +} D3DMATERIALCOLORSOURCE; + +// Bias to apply to the texture coordinate set to apply a wrap to. +#define D3DRENDERSTATE_WRAPBIAS 128UL + +/* Flags to construct the WRAP render states */ +#define D3DWRAP_U 0x00000001L +#define D3DWRAP_V 0x00000002L +#define D3DWRAP_W 0x00000004L + +/* Flags to construct the WRAP render states for 1D thru 4D texture coordinates */ +#define D3DWRAPCOORD_0 0x00000001L // same as D3DWRAP_U +#define D3DWRAPCOORD_1 0x00000002L // same as D3DWRAP_V +#define D3DWRAPCOORD_2 0x00000004L // same as D3DWRAP_W +#define D3DWRAPCOORD_3 0x00000008L + +/* 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) + +/* + * State enumerants for per-stage processing of fixed function pixel processing + * Two of these affect fixed function vertex processing as well: TEXTURETRANSFORMFLAGS and TEXCOORDINDEX. + */ +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_BUMPENVLSCALE = 22, /* float scale for bump map luminance */ + 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_ALPHAARG0 = 27, /* D3DTA_* third arg for triadic ops */ + D3DTSS_RESULTARG = 28, /* D3DTA_* arg for result (CURRENT or TEMP) */ + D3DTSS_CONSTANT = 32, /* Per-stage constant D3DTA_CONSTANT */ + + + D3DTSS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DTEXTURESTAGESTATETYPE; + +/* + * State enumerants for per-sampler texture processing. + */ +typedef enum _D3DSAMPLERSTATETYPE +{ + D3DSAMP_ADDRESSU = 1, /* D3DTEXTUREADDRESS for U coordinate */ + D3DSAMP_ADDRESSV = 2, /* D3DTEXTUREADDRESS for V coordinate */ + D3DSAMP_ADDRESSW = 3, /* D3DTEXTUREADDRESS for W coordinate */ + D3DSAMP_BORDERCOLOR = 4, /* D3DCOLOR */ + D3DSAMP_MAGFILTER = 5, /* D3DTEXTUREFILTER filter to use for magnification */ + D3DSAMP_MINFILTER = 6, /* D3DTEXTUREFILTER filter to use for minification */ + D3DSAMP_MIPFILTER = 7, /* D3DTEXTUREFILTER filter to use between mipmaps during minification */ + D3DSAMP_MIPMAPLODBIAS = 8, /* float Mipmap LOD bias */ + D3DSAMP_MAXMIPLEVEL = 9, /* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) */ + D3DSAMP_MAXANISOTROPY = 10, /* DWORD maximum anisotropy */ + D3DSAMP_SRGBTEXTURE = 11, /* Default = 0 (which means Gamma 1.0, + no correction required.) else correct for + Gamma = 2.2 */ + D3DSAMP_ELEMENTINDEX = 12, /* When multi-element texture is assigned to sampler, this + indicates which element index to use. Default = 0. */ + D3DSAMP_DMAPOFFSET = 13, /* Offset in vertices in the pre-sampled displacement map. + Only valid for D3DDMAPSAMPLER sampler */ + D3DSAMP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DSAMPLERSTATETYPE; + +/* Special sampler which is used in the tesselator */ +#define D3DDMAPSAMPLER 256 + +// Samplers used in vertex shaders +#define D3DVERTEXTEXTURESAMPLER0 (D3DDMAPSAMPLER+1) +#define D3DVERTEXTEXTURESAMPLER1 (D3DDMAPSAMPLER+2) +#define D3DVERTEXTEXTURESAMPLER2 (D3DDMAPSAMPLER+3) +#define D3DVERTEXTEXTURESAMPLER3 (D3DDMAPSAMPLER+4) + +// Values, used with D3DTSS_TEXCOORDINDEX, to specify that the vertex data(position +// and normal in the camera space) should be taken as texture coordinates +// Low 16 bits are used to specify texture coordinate index, to take the WRAP mode from +// +#define D3DTSS_TCI_PASSTHRU 0x00000000 +#define D3DTSS_TCI_CAMERASPACENORMAL 0x00010000 +#define D3DTSS_TCI_CAMERASPACEPOSITION 0x00020000 +#define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR 0x00030000 +#define D3DTSS_TCI_SPHEREMAP 0x00040000 + +/* + * Enumerations for COLOROP and ALPHAOP texture blending operations set in + * texture processing stage controls in D3DTSS. + */ +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; + +/* + * Values for COLORARG0,1,2, ALPHAARG0,1,2, and RESULTARG texture blending + * operations set in texture processing stage controls in D3DRENDERSTATE. + */ +#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) + +// +// Values for D3DSAMP_***FILTER texture stage states +// +typedef enum _D3DTEXTUREFILTERTYPE +{ + D3DTEXF_NONE = 0, // filtering disabled (valid for mip filter only) + D3DTEXF_POINT = 1, // nearest + D3DTEXF_LINEAR = 2, // linear interpolation + D3DTEXF_ANISOTROPIC = 3, // anisotropic + D3DTEXF_PYRAMIDALQUAD = 6, // 4-sample tent + D3DTEXF_GAUSSIANQUAD = 7, // 4-sample gaussian + D3DTEXF_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum +} D3DTEXTUREFILTERTYPE; + +/* Bits for Flags in ProcessVertices call */ + +#define D3DPV_DONOTCOPYDATA (1 << 0) + +//------------------------------------------------------------------- + +// 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 + +//--------------------------------------------------------------------- +// Vertex Shaders +// + +// Vertex shader declaration + +// Vertex element semantics +// +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; + +#define MAXD3DDECLUSAGE D3DDECLUSAGE_SAMPLE +#define MAXD3DDECLUSAGEINDEX 15 +#define MAXD3DDECLLENGTH 64 // does not include "end" marker vertex element + +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; + +#define MAXD3DDECLMETHOD D3DDECLMETHOD_LOOKUPPRESAMPLED + +// Declarations for _Type fields +// +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; + +#define MAXD3DDECLTYPE D3DDECLTYPE_UNUSED + +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; + +// This is used to initialize the last vertex element in a vertex declaration +// array +// +#define D3DDECL_END() {0xFF,0,D3DDECLTYPE_UNUSED,0,0,0} + +// Maximum supported number of texture coordinate sets +#define D3DDP_MAXTEXCOORD 8 + +//--------------------------------------------------------------------- +// Values for IDirect3DDevice9::SetStreamSourceFreq's Setting parameter +//--------------------------------------------------------------------- +#define D3DSTREAMSOURCE_INDEXEDDATA (1<<30) +#define D3DSTREAMSOURCE_INSTANCEDATA (2<<30) + + + +//--------------------------------------------------------------------- +// +// The internal format of Pixel Shader (PS) & Vertex Shader (VS) +// Instruction Tokens is defined in the Direct3D Device Driver Kit +// +//--------------------------------------------------------------------- + +// +// Instruction Token Bit Definitions +// +#define D3DSI_OPCODE_MASK 0x0000FFFF + +#define D3DSI_INSTLENGTH_MASK 0x0F000000 +#define D3DSI_INSTLENGTH_SHIFT 24 + +typedef enum _D3DSHADER_INSTRUCTION_OPCODE_TYPE +{ + D3DSIO_NOP = 0, + D3DSIO_MOV , + D3DSIO_ADD , + D3DSIO_SUB , + D3DSIO_MAD , + D3DSIO_MUL , + D3DSIO_RCP , + D3DSIO_RSQ , + D3DSIO_DP3 , + D3DSIO_DP4 , + D3DSIO_MIN , + D3DSIO_MAX , + D3DSIO_SLT , + D3DSIO_SGE , + D3DSIO_EXP , + D3DSIO_LOG , + D3DSIO_LIT , + D3DSIO_DST , + D3DSIO_LRP , + D3DSIO_FRC , + D3DSIO_M4x4 , + D3DSIO_M4x3 , + D3DSIO_M3x4 , + D3DSIO_M3x3 , + D3DSIO_M3x2 , + D3DSIO_CALL , + D3DSIO_CALLNZ , + D3DSIO_LOOP , + D3DSIO_RET , + D3DSIO_ENDLOOP , + D3DSIO_LABEL , + D3DSIO_DCL , + D3DSIO_POW , + D3DSIO_CRS , + D3DSIO_SGN , + D3DSIO_ABS , + D3DSIO_NRM , + D3DSIO_SINCOS , + D3DSIO_REP , + D3DSIO_ENDREP , + D3DSIO_IF , + D3DSIO_IFC , + D3DSIO_ELSE , + D3DSIO_ENDIF , + D3DSIO_BREAK , + D3DSIO_BREAKC , + D3DSIO_MOVA , + D3DSIO_DEFB , + D3DSIO_DEFI , + + D3DSIO_TEXCOORD = 64, + D3DSIO_TEXKILL , + D3DSIO_TEX , + D3DSIO_TEXBEM , + D3DSIO_TEXBEML , + D3DSIO_TEXREG2AR , + D3DSIO_TEXREG2GB , + D3DSIO_TEXM3x2PAD , + D3DSIO_TEXM3x2TEX , + D3DSIO_TEXM3x3PAD , + D3DSIO_TEXM3x3TEX , + D3DSIO_RESERVED0 , + D3DSIO_TEXM3x3SPEC , + D3DSIO_TEXM3x3VSPEC , + D3DSIO_EXPP , + D3DSIO_LOGP , + D3DSIO_CND , + D3DSIO_DEF , + D3DSIO_TEXREG2RGB , + D3DSIO_TEXDP3TEX , + D3DSIO_TEXM3x2DEPTH , + D3DSIO_TEXDP3 , + D3DSIO_TEXM3x3 , + D3DSIO_TEXDEPTH , + D3DSIO_CMP , + D3DSIO_BEM , + D3DSIO_DP2ADD , + D3DSIO_DSX , + D3DSIO_DSY , + D3DSIO_TEXLDD , + D3DSIO_SETP , + D3DSIO_TEXLDL , + D3DSIO_BREAKP , + + D3DSIO_PHASE = 0xFFFD, + D3DSIO_COMMENT = 0xFFFE, + D3DSIO_END = 0xFFFF, + + D3DSIO_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum +} D3DSHADER_INSTRUCTION_OPCODE_TYPE; + +//--------------------------------------------------------------------- +// Use these constants with D3DSIO_SINCOS macro as SRC2, SRC3 +// +#define D3DSINCOSCONST1 -1.5500992e-006f, -2.1701389e-005f, 0.0026041667f, 0.00026041668f +#define D3DSINCOSCONST2 -0.020833334f, -0.12500000f, 1.0f, 0.50000000f + +//--------------------------------------------------------------------- +// Co-Issue Instruction Modifier - if set then this instruction is to be +// issued in parallel with the previous instruction(s) for which this bit +// is not set. +// +#define D3DSI_COISSUE 0x40000000 + +//--------------------------------------------------------------------- +// Opcode specific controls + +#define D3DSP_OPCODESPECIFICCONTROL_MASK 0x00ff0000 +#define D3DSP_OPCODESPECIFICCONTROL_SHIFT 16 + +// ps_2_0 texld controls +#define D3DSI_TEXLD_PROJECT (0x01 << D3DSP_OPCODESPECIFICCONTROL_SHIFT) +#define D3DSI_TEXLD_BIAS (0x02 << D3DSP_OPCODESPECIFICCONTROL_SHIFT) + +// Comparison for dynamic conditional instruction opcodes (i.e. if, breakc) +typedef enum _D3DSHADER_COMPARISON +{ + // < = > + D3DSPC_RESERVED0= 0, // 0 0 0 + D3DSPC_GT = 1, // 0 0 1 + D3DSPC_EQ = 2, // 0 1 0 + D3DSPC_GE = 3, // 0 1 1 + D3DSPC_LT = 4, // 1 0 0 + D3DSPC_NE = 5, // 1 0 1 + D3DSPC_LE = 6, // 1 1 0 + D3DSPC_RESERVED1= 7 // 1 1 1 +} D3DSHADER_COMPARISON; + +// Comparison is part of instruction opcode token: +#define D3DSHADER_COMPARISON_SHIFT D3DSP_OPCODESPECIFICCONTROL_SHIFT +#define D3DSHADER_COMPARISON_MASK (0x7<>8)&0xFF) +#define D3DSHADER_VERSION_MINOR(_Version) (((_Version)>>0)&0xFF) + +// destination/source parameter register type +#define D3DSI_COMMENTSIZE_SHIFT 16 +#define D3DSI_COMMENTSIZE_MASK 0x7FFF0000 +#define D3DSHADER_COMMENT(_DWordSize) \ + ((((_DWordSize)<= 1200 +#pragma warning(pop) +#else +#pragma warning(default:4201) +#endif + +#endif /* (DIRECT3D_VERSION >= 0x0900) */ +#endif /* _d3d9TYPES(P)_H_ */ + diff --git a/src/dep/include/DXSDK/include/d3dcaps.h b/src/dep/include/DXSDK/include/d3dcaps.h index 701bf9c..6066c7a 100644 --- a/src/dep/include/DXSDK/include/d3dcaps.h +++ b/src/dep/include/DXSDK/include/d3dcaps.h @@ -1,601 +1,601 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: d3dcaps.h - * Content: Direct3D capabilities include file - * - ***************************************************************************/ - -#ifndef _D3DCAPS_H -#define _D3DCAPS_H - -/* - * Pull in DirectDraw include file automatically: - */ -#include "ddraw.h" - -#ifndef DIRECT3D_VERSION -#define DIRECT3D_VERSION 0x0700 -#endif - -#if defined(_X86_) || defined(_IA64_) -#pragma pack(4) -#endif - -/* Description of capabilities of transform */ - -typedef struct _D3DTRANSFORMCAPS { - DWORD dwSize; - DWORD dwCaps; -} D3DTRANSFORMCAPS, *LPD3DTRANSFORMCAPS; - -#define D3DTRANSFORMCAPS_CLIP 0x00000001L /* Will clip whilst transforming */ - -/* Description of capabilities of lighting */ - -typedef struct _D3DLIGHTINGCAPS { - DWORD dwSize; - DWORD dwCaps; /* Lighting caps */ - DWORD dwLightingModel; /* Lighting model - RGB or mono */ - DWORD dwNumLights; /* Number of lights that can be handled */ -} D3DLIGHTINGCAPS, *LPD3DLIGHTINGCAPS; - -#define D3DLIGHTINGMODEL_RGB 0x00000001L -#define D3DLIGHTINGMODEL_MONO 0x00000002L - -#define D3DLIGHTCAPS_POINT 0x00000001L /* Point lights supported */ -#define D3DLIGHTCAPS_SPOT 0x00000002L /* Spot lights supported */ -#define D3DLIGHTCAPS_DIRECTIONAL 0x00000004L /* Directional lights supported */ -#if(DIRECT3D_VERSION < 0x700) -#define D3DLIGHTCAPS_PARALLELPOINT 0x00000008L /* Parallel point lights supported */ -#endif -#if(DIRECT3D_VERSION < 0x500) -#define D3DLIGHTCAPS_GLSPOT 0x00000010L /* GL syle spot lights supported */ -#endif - -/* Description of capabilities for each primitive type */ - -typedef struct _D3DPrimCaps { - DWORD dwSize; - DWORD dwMiscCaps; /* Capability flags */ - DWORD dwRasterCaps; - DWORD dwZCmpCaps; - DWORD dwSrcBlendCaps; - DWORD dwDestBlendCaps; - DWORD dwAlphaCmpCaps; - DWORD dwShadeCaps; - DWORD dwTextureCaps; - DWORD dwTextureFilterCaps; - DWORD dwTextureBlendCaps; - DWORD dwTextureAddressCaps; - DWORD dwStippleWidth; /* maximum width and height of */ - DWORD dwStippleHeight; /* of supported stipple (up to 32x32) */ -} D3DPRIMCAPS, *LPD3DPRIMCAPS; - -/* D3DPRIMCAPS dwMiscCaps */ - -#define D3DPMISCCAPS_MASKPLANES 0x00000001L -#define D3DPMISCCAPS_MASKZ 0x00000002L -#define D3DPMISCCAPS_LINEPATTERNREP 0x00000004L -#define D3DPMISCCAPS_CONFORMANT 0x00000008L -#define D3DPMISCCAPS_CULLNONE 0x00000010L -#define D3DPMISCCAPS_CULLCW 0x00000020L -#define D3DPMISCCAPS_CULLCCW 0x00000040L - -/* D3DPRIMCAPS dwRasterCaps */ - -#define D3DPRASTERCAPS_DITHER 0x00000001L -#define D3DPRASTERCAPS_ROP2 0x00000002L -#define D3DPRASTERCAPS_XOR 0x00000004L -#define D3DPRASTERCAPS_PAT 0x00000008L -#define D3DPRASTERCAPS_ZTEST 0x00000010L -#define D3DPRASTERCAPS_SUBPIXEL 0x00000020L -#define D3DPRASTERCAPS_SUBPIXELX 0x00000040L -#define D3DPRASTERCAPS_FOGVERTEX 0x00000080L -#define D3DPRASTERCAPS_FOGTABLE 0x00000100L -#define D3DPRASTERCAPS_STIPPLE 0x00000200L -#if(DIRECT3D_VERSION >= 0x0500) -#define D3DPRASTERCAPS_ANTIALIASSORTDEPENDENT 0x00000400L -#define D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT 0x00000800L -#define D3DPRASTERCAPS_ANTIALIASEDGES 0x00001000L -#define D3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000L -#define D3DPRASTERCAPS_ZBIAS 0x00004000L -#define D3DPRASTERCAPS_ZBUFFERLESSHSR 0x00008000L -#define D3DPRASTERCAPS_FOGRANGE 0x00010000L -#define D3DPRASTERCAPS_ANISOTROPY 0x00020000L -#endif /* DIRECT3D_VERSION >= 0x0500 */ -#if(DIRECT3D_VERSION >= 0x0600) -#define D3DPRASTERCAPS_WBUFFER 0x00040000L -#define D3DPRASTERCAPS_TRANSLUCENTSORTINDEPENDENT 0x00080000L -#define D3DPRASTERCAPS_WFOG 0x00100000L -#define D3DPRASTERCAPS_ZFOG 0x00200000L -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -/* D3DPRIMCAPS dwZCmpCaps, dwAlphaCmpCaps */ - -#define D3DPCMPCAPS_NEVER 0x00000001L -#define D3DPCMPCAPS_LESS 0x00000002L -#define D3DPCMPCAPS_EQUAL 0x00000004L -#define D3DPCMPCAPS_LESSEQUAL 0x00000008L -#define D3DPCMPCAPS_GREATER 0x00000010L -#define D3DPCMPCAPS_NOTEQUAL 0x00000020L -#define D3DPCMPCAPS_GREATEREQUAL 0x00000040L -#define D3DPCMPCAPS_ALWAYS 0x00000080L - -/* D3DPRIMCAPS dwSourceBlendCaps, dwDestBlendCaps */ - -#define D3DPBLENDCAPS_ZERO 0x00000001L -#define D3DPBLENDCAPS_ONE 0x00000002L -#define D3DPBLENDCAPS_SRCCOLOR 0x00000004L -#define D3DPBLENDCAPS_INVSRCCOLOR 0x00000008L -#define D3DPBLENDCAPS_SRCALPHA 0x00000010L -#define D3DPBLENDCAPS_INVSRCALPHA 0x00000020L -#define D3DPBLENDCAPS_DESTALPHA 0x00000040L -#define D3DPBLENDCAPS_INVDESTALPHA 0x00000080L -#define D3DPBLENDCAPS_DESTCOLOR 0x00000100L -#define D3DPBLENDCAPS_INVDESTCOLOR 0x00000200L -#define D3DPBLENDCAPS_SRCALPHASAT 0x00000400L -#define D3DPBLENDCAPS_BOTHSRCALPHA 0x00000800L -#define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000L - -/* D3DPRIMCAPS dwShadeCaps */ - -#define D3DPSHADECAPS_COLORFLATMONO 0x00000001L -#define D3DPSHADECAPS_COLORFLATRGB 0x00000002L -#define D3DPSHADECAPS_COLORGOURAUDMONO 0x00000004L -#define D3DPSHADECAPS_COLORGOURAUDRGB 0x00000008L -#define D3DPSHADECAPS_COLORPHONGMONO 0x00000010L -#define D3DPSHADECAPS_COLORPHONGRGB 0x00000020L - -#define D3DPSHADECAPS_SPECULARFLATMONO 0x00000040L -#define D3DPSHADECAPS_SPECULARFLATRGB 0x00000080L -#define D3DPSHADECAPS_SPECULARGOURAUDMONO 0x00000100L -#define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200L -#define D3DPSHADECAPS_SPECULARPHONGMONO 0x00000400L -#define D3DPSHADECAPS_SPECULARPHONGRGB 0x00000800L - -#define D3DPSHADECAPS_ALPHAFLATBLEND 0x00001000L -#define D3DPSHADECAPS_ALPHAFLATSTIPPLED 0x00002000L -#define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000L -#define D3DPSHADECAPS_ALPHAGOURAUDSTIPPLED 0x00008000L -#define D3DPSHADECAPS_ALPHAPHONGBLEND 0x00010000L -#define D3DPSHADECAPS_ALPHAPHONGSTIPPLED 0x00020000L - -#define D3DPSHADECAPS_FOGFLAT 0x00040000L -#define D3DPSHADECAPS_FOGGOURAUD 0x00080000L -#define D3DPSHADECAPS_FOGPHONG 0x00100000L - -/* D3DPRIMCAPS dwTextureCaps */ - -/* - * Perspective-correct texturing is supported - */ -#define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001L - -/* - * Power-of-2 texture dimensions are required - */ -#define D3DPTEXTURECAPS_POW2 0x00000002L - -/* - * Alpha in texture pixels is supported - */ -#define D3DPTEXTURECAPS_ALPHA 0x00000004L - -/* - * Color-keyed textures are supported - */ -#define D3DPTEXTURECAPS_TRANSPARENCY 0x00000008L - -/* - * obsolete, see D3DPTADDRESSCAPS_BORDER - */ -#define D3DPTEXTURECAPS_BORDER 0x00000010L - -/* - * Only square textures are supported - */ -#define D3DPTEXTURECAPS_SQUAREONLY 0x00000020L - -#if(DIRECT3D_VERSION >= 0x0600) -/* - * Texture indices are not scaled by the texture size prior - * to interpolation. - */ -#define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040L - -/* - * Device can draw alpha from texture palettes - */ -#define D3DPTEXTURECAPS_ALPHAPALETTE 0x00000080L - -/* - * Device can use non-POW2 textures if: - * 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage - * 2) D3DRS_WRAP(N) is zero for this texture's coordinates - * 3) mip mapping is not enabled (use magnification filter only) - */ -#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100L - -#endif /* DIRECT3D_VERSION >= 0x0600 */ -#if(DIRECT3D_VERSION >= 0x0700) - -// 0x00000200L unused - -/* - * Device can divide transformed texture coordinates by the - * COUNTth texture coordinate (can do D3DTTFF_PROJECTED) - */ -#define D3DPTEXTURECAPS_PROJECTED 0x00000400L - -/* - * Device can do cubemap textures - */ -#define D3DPTEXTURECAPS_CUBEMAP 0x00000800L - -#define D3DPTEXTURECAPS_COLORKEYBLEND 0x00001000L -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -/* D3DPRIMCAPS dwTextureFilterCaps */ - -#define D3DPTFILTERCAPS_NEAREST 0x00000001L -#define D3DPTFILTERCAPS_LINEAR 0x00000002L -#define D3DPTFILTERCAPS_MIPNEAREST 0x00000004L -#define D3DPTFILTERCAPS_MIPLINEAR 0x00000008L -#define D3DPTFILTERCAPS_LINEARMIPNEAREST 0x00000010L -#define D3DPTFILTERCAPS_LINEARMIPLINEAR 0x00000020L - -#if(DIRECT3D_VERSION >= 0x0600) -/* Device3 Min Filter */ -#define D3DPTFILTERCAPS_MINFPOINT 0x00000100L -#define D3DPTFILTERCAPS_MINFLINEAR 0x00000200L -#define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400L - -/* Device3 Mip Filter */ -#define D3DPTFILTERCAPS_MIPFPOINT 0x00010000L -#define D3DPTFILTERCAPS_MIPFLINEAR 0x00020000L - -/* Device3 Mag Filter */ -#define D3DPTFILTERCAPS_MAGFPOINT 0x01000000L -#define D3DPTFILTERCAPS_MAGFLINEAR 0x02000000L -#define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000L -#define D3DPTFILTERCAPS_MAGFAFLATCUBIC 0x08000000L -#define D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC 0x10000000L -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -/* D3DPRIMCAPS dwTextureBlendCaps */ - -#define D3DPTBLENDCAPS_DECAL 0x00000001L -#define D3DPTBLENDCAPS_MODULATE 0x00000002L -#define D3DPTBLENDCAPS_DECALALPHA 0x00000004L -#define D3DPTBLENDCAPS_MODULATEALPHA 0x00000008L -#define D3DPTBLENDCAPS_DECALMASK 0x00000010L -#define D3DPTBLENDCAPS_MODULATEMASK 0x00000020L -#define D3DPTBLENDCAPS_COPY 0x00000040L -#if(DIRECT3D_VERSION >= 0x0500) -#define D3DPTBLENDCAPS_ADD 0x00000080L -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -/* D3DPRIMCAPS dwTextureAddressCaps */ -#define D3DPTADDRESSCAPS_WRAP 0x00000001L -#define D3DPTADDRESSCAPS_MIRROR 0x00000002L -#define D3DPTADDRESSCAPS_CLAMP 0x00000004L -#if(DIRECT3D_VERSION >= 0x0500) -#define D3DPTADDRESSCAPS_BORDER 0x00000008L -#define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010L -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if(DIRECT3D_VERSION >= 0x0600) - -/* D3DDEVICEDESC dwStencilCaps */ - -#define D3DSTENCILCAPS_KEEP 0x00000001L -#define D3DSTENCILCAPS_ZERO 0x00000002L -#define D3DSTENCILCAPS_REPLACE 0x00000004L -#define D3DSTENCILCAPS_INCRSAT 0x00000008L -#define D3DSTENCILCAPS_DECRSAT 0x00000010L -#define D3DSTENCILCAPS_INVERT 0x00000020L -#define D3DSTENCILCAPS_INCR 0x00000040L -#define D3DSTENCILCAPS_DECR 0x00000080L - -/* D3DDEVICEDESC dwTextureOpCaps */ - -#define D3DTEXOPCAPS_DISABLE 0x00000001L -#define D3DTEXOPCAPS_SELECTARG1 0x00000002L -#define D3DTEXOPCAPS_SELECTARG2 0x00000004L -#define D3DTEXOPCAPS_MODULATE 0x00000008L -#define D3DTEXOPCAPS_MODULATE2X 0x00000010L -#define D3DTEXOPCAPS_MODULATE4X 0x00000020L -#define D3DTEXOPCAPS_ADD 0x00000040L -#define D3DTEXOPCAPS_ADDSIGNED 0x00000080L -#define D3DTEXOPCAPS_ADDSIGNED2X 0x00000100L -#define D3DTEXOPCAPS_SUBTRACT 0x00000200L -#define D3DTEXOPCAPS_ADDSMOOTH 0x00000400L -#define D3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x00000800L -#define D3DTEXOPCAPS_BLENDTEXTUREALPHA 0x00001000L -#define D3DTEXOPCAPS_BLENDFACTORALPHA 0x00002000L -#define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x00004000L -#define D3DTEXOPCAPS_BLENDCURRENTALPHA 0x00008000L -#define D3DTEXOPCAPS_PREMODULATE 0x00010000L -#define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x00020000L -#define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x00040000L -#define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x00080000L -#define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x00100000L -#define D3DTEXOPCAPS_BUMPENVMAP 0x00200000L -#define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x00400000L -#define D3DTEXOPCAPS_DOTPRODUCT3 0x00800000L - -/* D3DDEVICEDESC dwFVFCaps flags */ - -#define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000ffffL /* mask for texture coordinate count field */ -#define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000L /* Device prefers that vertex elements not be stripped */ - -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -/* - * Description for a device. - * This is used to describe a device that is to be created or to query - * the current device. - */ -typedef struct _D3DDeviceDesc { - DWORD dwSize; /* Size of D3DDEVICEDESC structure */ - DWORD dwFlags; /* Indicates which fields have valid data */ - D3DCOLORMODEL dcmColorModel; /* Color model of device */ - DWORD dwDevCaps; /* Capabilities of device */ - D3DTRANSFORMCAPS dtcTransformCaps; /* Capabilities of transform */ - BOOL bClipping; /* Device can do 3D clipping */ - D3DLIGHTINGCAPS dlcLightingCaps; /* Capabilities of lighting */ - D3DPRIMCAPS dpcLineCaps; - D3DPRIMCAPS dpcTriCaps; - DWORD dwDeviceRenderBitDepth; /* One of DDBB_8, 16, etc.. */ - DWORD dwDeviceZBufferBitDepth;/* One of DDBD_16, 32, etc.. */ - DWORD dwMaxBufferSize; /* Maximum execute buffer size */ - DWORD dwMaxVertexCount; /* Maximum vertex count */ -#if(DIRECT3D_VERSION >= 0x0500) - // *** New fields for DX5 *** // - - // Width and height caps are 0 for legacy HALs. - DWORD dwMinTextureWidth, dwMinTextureHeight; - DWORD dwMaxTextureWidth, dwMaxTextureHeight; - DWORD dwMinStippleWidth, dwMaxStippleWidth; - DWORD dwMinStippleHeight, dwMaxStippleHeight; -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if(DIRECT3D_VERSION >= 0x0600) - // New fields for DX6 - DWORD dwMaxTextureRepeat; - DWORD dwMaxTextureAspectRatio; - DWORD dwMaxAnisotropy; - - // Guard band that the rasterizer can accommodate - // Screen-space vertices inside this space but outside the viewport - // will get clipped properly. - D3DVALUE dvGuardBandLeft; - D3DVALUE dvGuardBandTop; - D3DVALUE dvGuardBandRight; - D3DVALUE dvGuardBandBottom; - - D3DVALUE dvExtentsAdjust; - DWORD dwStencilCaps; - - DWORD dwFVFCaps; - DWORD dwTextureOpCaps; - WORD wMaxTextureBlendStages; - WORD wMaxSimultaneousTextures; -#endif /* DIRECT3D_VERSION >= 0x0600 */ -} D3DDEVICEDESC, *LPD3DDEVICEDESC; - -#if(DIRECT3D_VERSION >= 0x0700) -typedef struct _D3DDeviceDesc7 { - DWORD dwDevCaps; /* Capabilities of device */ - D3DPRIMCAPS dpcLineCaps; - D3DPRIMCAPS dpcTriCaps; - DWORD dwDeviceRenderBitDepth; /* One of DDBB_8, 16, etc.. */ - DWORD dwDeviceZBufferBitDepth;/* One of DDBD_16, 32, etc.. */ - - DWORD dwMinTextureWidth, dwMinTextureHeight; - DWORD dwMaxTextureWidth, dwMaxTextureHeight; - - DWORD dwMaxTextureRepeat; - DWORD dwMaxTextureAspectRatio; - DWORD dwMaxAnisotropy; - - D3DVALUE dvGuardBandLeft; - D3DVALUE dvGuardBandTop; - D3DVALUE dvGuardBandRight; - D3DVALUE dvGuardBandBottom; - - D3DVALUE dvExtentsAdjust; - DWORD dwStencilCaps; - - DWORD dwFVFCaps; - DWORD dwTextureOpCaps; - WORD wMaxTextureBlendStages; - WORD wMaxSimultaneousTextures; - - DWORD dwMaxActiveLights; - D3DVALUE dvMaxVertexW; - GUID deviceGUID; - - WORD wMaxUserClipPlanes; - WORD wMaxVertexBlendMatrices; - - DWORD dwVertexProcessingCaps; - - DWORD dwReserved1; - DWORD dwReserved2; - DWORD dwReserved3; - DWORD dwReserved4; -} D3DDEVICEDESC7, *LPD3DDEVICEDESC7; -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -#define D3DDEVICEDESCSIZE (sizeof(D3DDEVICEDESC)) -#define D3DDEVICEDESC7SIZE (sizeof(D3DDEVICEDESC7)) - -typedef HRESULT (CALLBACK * LPD3DENUMDEVICESCALLBACK)(GUID FAR *lpGuid, LPSTR lpDeviceDescription, LPSTR lpDeviceName, LPD3DDEVICEDESC, LPD3DDEVICEDESC, LPVOID); - -#if(DIRECT3D_VERSION >= 0x0700) -typedef HRESULT (CALLBACK * LPD3DENUMDEVICESCALLBACK7)(LPSTR lpDeviceDescription, LPSTR lpDeviceName, LPD3DDEVICEDESC7, LPVOID); -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -/* D3DDEVICEDESC dwFlags indicating valid fields */ - -#define D3DDD_COLORMODEL 0x00000001L /* dcmColorModel is valid */ -#define D3DDD_DEVCAPS 0x00000002L /* dwDevCaps is valid */ -#define D3DDD_TRANSFORMCAPS 0x00000004L /* dtcTransformCaps is valid */ -#define D3DDD_LIGHTINGCAPS 0x00000008L /* dlcLightingCaps is valid */ -#define D3DDD_BCLIPPING 0x00000010L /* bClipping is valid */ -#define D3DDD_LINECAPS 0x00000020L /* dpcLineCaps is valid */ -#define D3DDD_TRICAPS 0x00000040L /* dpcTriCaps is valid */ -#define D3DDD_DEVICERENDERBITDEPTH 0x00000080L /* dwDeviceRenderBitDepth is valid */ -#define D3DDD_DEVICEZBUFFERBITDEPTH 0x00000100L /* dwDeviceZBufferBitDepth is valid */ -#define D3DDD_MAXBUFFERSIZE 0x00000200L /* dwMaxBufferSize is valid */ -#define D3DDD_MAXVERTEXCOUNT 0x00000400L /* dwMaxVertexCount is valid */ - -/* D3DDEVICEDESC dwDevCaps flags */ - -#define D3DDEVCAPS_FLOATTLVERTEX 0x00000001L /* Device accepts floating point */ - /* for post-transform vertex data */ -#define D3DDEVCAPS_SORTINCREASINGZ 0x00000002L /* Device needs data sorted for increasing Z */ -#define D3DDEVCAPS_SORTDECREASINGZ 0X00000004L /* Device needs data sorted for decreasing Z */ -#define D3DDEVCAPS_SORTEXACT 0x00000008L /* Device needs data sorted exactly */ - -#define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010L /* Device can use execute buffers from system memory */ -#define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020L /* Device can use execute buffers from video 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 */ -#if(DIRECT3D_VERSION >= 0x0500) -#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 */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ -#if(DIRECT3D_VERSION >= 0x0600) -#define D3DDEVCAPS_DRAWPRIMITIVES2 0x00002000L /* Device can support DrawPrimitives2 */ -#define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000L /* Device is texturing from separate memory pools */ -#define D3DDEVCAPS_DRAWPRIMITIVES2EX 0x00008000L /* Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver*/ -#endif /* DIRECT3D_VERSION >= 0x0600 */ -#if(DIRECT3D_VERSION >= 0x0700) -#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 */ - -/* - * These are the flags in the D3DDEVICEDESC7.dwVertexProcessingCaps field - */ - -/* device can do texgen */ -#define D3DVTXPCAPS_TEXGEN 0x00000001L -/* device can do IDirect3DDevice7 colormaterialsource ops */ -#define D3DVTXPCAPS_MATERIALSOURCE7 0x00000002L -/* device can do vertex fog */ -#define D3DVTXPCAPS_VERTEXFOG 0x00000004L -/* device can do directional lights */ -#define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008L -/* device can do positional lights (includes point and spot) */ -#define D3DVTXPCAPS_POSITIONALLIGHTS 0x00000010L -/* device can do local viewer */ -#define D3DVTXPCAPS_LOCALVIEWER 0x00000020L - -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -#define D3DFDS_COLORMODEL 0x00000001L /* Match color model */ -#define D3DFDS_GUID 0x00000002L /* Match guid */ -#define D3DFDS_HARDWARE 0x00000004L /* Match hardware/software */ -#define D3DFDS_TRIANGLES 0x00000008L /* Match in triCaps */ -#define D3DFDS_LINES 0x00000010L /* Match in lineCaps */ -#define D3DFDS_MISCCAPS 0x00000020L /* Match primCaps.dwMiscCaps */ -#define D3DFDS_RASTERCAPS 0x00000040L /* Match primCaps.dwRasterCaps */ -#define D3DFDS_ZCMPCAPS 0x00000080L /* Match primCaps.dwZCmpCaps */ -#define D3DFDS_ALPHACMPCAPS 0x00000100L /* Match primCaps.dwAlphaCmpCaps */ -#define D3DFDS_SRCBLENDCAPS 0x00000200L /* Match primCaps.dwSourceBlendCaps */ -#define D3DFDS_DSTBLENDCAPS 0x00000400L /* Match primCaps.dwDestBlendCaps */ -#define D3DFDS_SHADECAPS 0x00000800L /* Match primCaps.dwShadeCaps */ -#define D3DFDS_TEXTURECAPS 0x00001000L /* Match primCaps.dwTextureCaps */ -#define D3DFDS_TEXTUREFILTERCAPS 0x00002000L /* Match primCaps.dwTextureFilterCaps */ -#define D3DFDS_TEXTUREBLENDCAPS 0x00004000L /* Match primCaps.dwTextureBlendCaps */ -#define D3DFDS_TEXTUREADDRESSCAPS 0x00008000L /* Match primCaps.dwTextureBlendCaps */ - -/* - * FindDevice arguments - */ -typedef struct _D3DFINDDEVICESEARCH { - DWORD dwSize; - DWORD dwFlags; - BOOL bHardware; - D3DCOLORMODEL dcmColorModel; - GUID guid; - DWORD dwCaps; - D3DPRIMCAPS dpcPrimCaps; -} D3DFINDDEVICESEARCH, *LPD3DFINDDEVICESEARCH; - -typedef struct _D3DFINDDEVICERESULT { - DWORD dwSize; - GUID guid; /* guid which matched */ - D3DDEVICEDESC ddHwDesc; /* hardware D3DDEVICEDESC */ - D3DDEVICEDESC ddSwDesc; /* software D3DDEVICEDESC */ -} D3DFINDDEVICERESULT, *LPD3DFINDDEVICERESULT; - -/* - * Description of execute buffer. - */ -typedef struct _D3DExecuteBufferDesc { - DWORD dwSize; /* size of this structure */ - DWORD dwFlags; /* flags indicating which fields are valid */ - DWORD dwCaps; /* capabilities of execute buffer */ - DWORD dwBufferSize; /* size of execute buffer data */ - LPVOID lpData; /* pointer to actual data */ -} D3DEXECUTEBUFFERDESC, *LPD3DEXECUTEBUFFERDESC; - -/* D3DEXECUTEBUFFER dwFlags indicating valid fields */ - -#define D3DDEB_BUFSIZE 0x00000001l /* buffer size valid */ -#define D3DDEB_CAPS 0x00000002l /* caps valid */ -#define D3DDEB_LPDATA 0x00000004l /* lpData valid */ - -/* D3DEXECUTEBUFFER dwCaps */ - -#define D3DDEBCAPS_SYSTEMMEMORY 0x00000001l /* buffer in system memory */ -#define D3DDEBCAPS_VIDEOMEMORY 0x00000002l /* buffer in device memory */ -#define D3DDEBCAPS_MEM (D3DDEBCAPS_SYSTEMMEMORY|D3DDEBCAPS_VIDEOMEMORY) - -#if(DIRECT3D_VERSION < 0x0800) - -#if(DIRECT3D_VERSION >= 0x0700) -typedef struct _D3DDEVINFO_TEXTUREMANAGER { - BOOL bThrashing; /* indicates if thrashing */ - DWORD dwApproxBytesDownloaded; /* Approximate number of bytes downloaded by texture manager */ - DWORD dwNumEvicts; /* number of textures evicted */ - DWORD dwNumVidCreates; /* number of textures created in video memory */ - DWORD dwNumTexturesUsed; /* number of textures used */ - DWORD dwNumUsedTexInVid; /* number of used textures present in video memory */ - DWORD dwWorkingSet; /* number of textures in video memory */ - DWORD dwWorkingSetBytes; /* number of bytes in video memory */ - DWORD dwTotalManaged; /* total number of managed textures */ - DWORD dwTotalBytes; /* total number of bytes of managed textures */ - DWORD dwLastPri; /* priority of last texture evicted */ -} D3DDEVINFO_TEXTUREMANAGER, *LPD3DDEVINFO_TEXTUREMANAGER; - -typedef struct _D3DDEVINFO_TEXTURING { - DWORD dwNumLoads; /* counts Load() API calls */ - DWORD dwApproxBytesLoaded; /* Approximate number bytes loaded via Load() */ - DWORD dwNumPreLoads; /* counts PreLoad() API calls */ - DWORD dwNumSet; /* counts SetTexture() API calls */ - DWORD dwNumCreates; /* counts texture creates */ - DWORD dwNumDestroys; /* counts texture destroys */ - DWORD dwNumSetPriorities; /* counts SetPriority() API calls */ - DWORD dwNumSetLODs; /* counts SetLOD() API calls */ - DWORD dwNumLocks; /* counts number of texture locks */ - DWORD dwNumGetDCs; /* counts number of GetDCs to textures */ -} D3DDEVINFO_TEXTURING, *LPD3DDEVINFO_TEXTURING; -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -#endif //(DIRECT3D_VERSION < 0x0800) - -#pragma pack() - - -#endif /* _D3DCAPS_H_ */ - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3dcaps.h + * Content: Direct3D capabilities include file + * + ***************************************************************************/ + +#ifndef _D3DCAPS_H +#define _D3DCAPS_H + +/* + * Pull in DirectDraw include file automatically: + */ +#include "ddraw.h" + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0700 +#endif + +#if defined(_X86_) || defined(_IA64_) +#pragma pack(4) +#endif + +/* Description of capabilities of transform */ + +typedef struct _D3DTRANSFORMCAPS { + DWORD dwSize; + DWORD dwCaps; +} D3DTRANSFORMCAPS, *LPD3DTRANSFORMCAPS; + +#define D3DTRANSFORMCAPS_CLIP 0x00000001L /* Will clip whilst transforming */ + +/* Description of capabilities of lighting */ + +typedef struct _D3DLIGHTINGCAPS { + DWORD dwSize; + DWORD dwCaps; /* Lighting caps */ + DWORD dwLightingModel; /* Lighting model - RGB or mono */ + DWORD dwNumLights; /* Number of lights that can be handled */ +} D3DLIGHTINGCAPS, *LPD3DLIGHTINGCAPS; + +#define D3DLIGHTINGMODEL_RGB 0x00000001L +#define D3DLIGHTINGMODEL_MONO 0x00000002L + +#define D3DLIGHTCAPS_POINT 0x00000001L /* Point lights supported */ +#define D3DLIGHTCAPS_SPOT 0x00000002L /* Spot lights supported */ +#define D3DLIGHTCAPS_DIRECTIONAL 0x00000004L /* Directional lights supported */ +#if(DIRECT3D_VERSION < 0x700) +#define D3DLIGHTCAPS_PARALLELPOINT 0x00000008L /* Parallel point lights supported */ +#endif +#if(DIRECT3D_VERSION < 0x500) +#define D3DLIGHTCAPS_GLSPOT 0x00000010L /* GL syle spot lights supported */ +#endif + +/* Description of capabilities for each primitive type */ + +typedef struct _D3DPrimCaps { + DWORD dwSize; + DWORD dwMiscCaps; /* Capability flags */ + DWORD dwRasterCaps; + DWORD dwZCmpCaps; + DWORD dwSrcBlendCaps; + DWORD dwDestBlendCaps; + DWORD dwAlphaCmpCaps; + DWORD dwShadeCaps; + DWORD dwTextureCaps; + DWORD dwTextureFilterCaps; + DWORD dwTextureBlendCaps; + DWORD dwTextureAddressCaps; + DWORD dwStippleWidth; /* maximum width and height of */ + DWORD dwStippleHeight; /* of supported stipple (up to 32x32) */ +} D3DPRIMCAPS, *LPD3DPRIMCAPS; + +/* D3DPRIMCAPS dwMiscCaps */ + +#define D3DPMISCCAPS_MASKPLANES 0x00000001L +#define D3DPMISCCAPS_MASKZ 0x00000002L +#define D3DPMISCCAPS_LINEPATTERNREP 0x00000004L +#define D3DPMISCCAPS_CONFORMANT 0x00000008L +#define D3DPMISCCAPS_CULLNONE 0x00000010L +#define D3DPMISCCAPS_CULLCW 0x00000020L +#define D3DPMISCCAPS_CULLCCW 0x00000040L + +/* D3DPRIMCAPS dwRasterCaps */ + +#define D3DPRASTERCAPS_DITHER 0x00000001L +#define D3DPRASTERCAPS_ROP2 0x00000002L +#define D3DPRASTERCAPS_XOR 0x00000004L +#define D3DPRASTERCAPS_PAT 0x00000008L +#define D3DPRASTERCAPS_ZTEST 0x00000010L +#define D3DPRASTERCAPS_SUBPIXEL 0x00000020L +#define D3DPRASTERCAPS_SUBPIXELX 0x00000040L +#define D3DPRASTERCAPS_FOGVERTEX 0x00000080L +#define D3DPRASTERCAPS_FOGTABLE 0x00000100L +#define D3DPRASTERCAPS_STIPPLE 0x00000200L +#if(DIRECT3D_VERSION >= 0x0500) +#define D3DPRASTERCAPS_ANTIALIASSORTDEPENDENT 0x00000400L +#define D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT 0x00000800L +#define D3DPRASTERCAPS_ANTIALIASEDGES 0x00001000L +#define D3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000L +#define D3DPRASTERCAPS_ZBIAS 0x00004000L +#define D3DPRASTERCAPS_ZBUFFERLESSHSR 0x00008000L +#define D3DPRASTERCAPS_FOGRANGE 0x00010000L +#define D3DPRASTERCAPS_ANISOTROPY 0x00020000L +#endif /* DIRECT3D_VERSION >= 0x0500 */ +#if(DIRECT3D_VERSION >= 0x0600) +#define D3DPRASTERCAPS_WBUFFER 0x00040000L +#define D3DPRASTERCAPS_TRANSLUCENTSORTINDEPENDENT 0x00080000L +#define D3DPRASTERCAPS_WFOG 0x00100000L +#define D3DPRASTERCAPS_ZFOG 0x00200000L +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +/* D3DPRIMCAPS dwZCmpCaps, dwAlphaCmpCaps */ + +#define D3DPCMPCAPS_NEVER 0x00000001L +#define D3DPCMPCAPS_LESS 0x00000002L +#define D3DPCMPCAPS_EQUAL 0x00000004L +#define D3DPCMPCAPS_LESSEQUAL 0x00000008L +#define D3DPCMPCAPS_GREATER 0x00000010L +#define D3DPCMPCAPS_NOTEQUAL 0x00000020L +#define D3DPCMPCAPS_GREATEREQUAL 0x00000040L +#define D3DPCMPCAPS_ALWAYS 0x00000080L + +/* D3DPRIMCAPS dwSourceBlendCaps, dwDestBlendCaps */ + +#define D3DPBLENDCAPS_ZERO 0x00000001L +#define D3DPBLENDCAPS_ONE 0x00000002L +#define D3DPBLENDCAPS_SRCCOLOR 0x00000004L +#define D3DPBLENDCAPS_INVSRCCOLOR 0x00000008L +#define D3DPBLENDCAPS_SRCALPHA 0x00000010L +#define D3DPBLENDCAPS_INVSRCALPHA 0x00000020L +#define D3DPBLENDCAPS_DESTALPHA 0x00000040L +#define D3DPBLENDCAPS_INVDESTALPHA 0x00000080L +#define D3DPBLENDCAPS_DESTCOLOR 0x00000100L +#define D3DPBLENDCAPS_INVDESTCOLOR 0x00000200L +#define D3DPBLENDCAPS_SRCALPHASAT 0x00000400L +#define D3DPBLENDCAPS_BOTHSRCALPHA 0x00000800L +#define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000L + +/* D3DPRIMCAPS dwShadeCaps */ + +#define D3DPSHADECAPS_COLORFLATMONO 0x00000001L +#define D3DPSHADECAPS_COLORFLATRGB 0x00000002L +#define D3DPSHADECAPS_COLORGOURAUDMONO 0x00000004L +#define D3DPSHADECAPS_COLORGOURAUDRGB 0x00000008L +#define D3DPSHADECAPS_COLORPHONGMONO 0x00000010L +#define D3DPSHADECAPS_COLORPHONGRGB 0x00000020L + +#define D3DPSHADECAPS_SPECULARFLATMONO 0x00000040L +#define D3DPSHADECAPS_SPECULARFLATRGB 0x00000080L +#define D3DPSHADECAPS_SPECULARGOURAUDMONO 0x00000100L +#define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200L +#define D3DPSHADECAPS_SPECULARPHONGMONO 0x00000400L +#define D3DPSHADECAPS_SPECULARPHONGRGB 0x00000800L + +#define D3DPSHADECAPS_ALPHAFLATBLEND 0x00001000L +#define D3DPSHADECAPS_ALPHAFLATSTIPPLED 0x00002000L +#define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000L +#define D3DPSHADECAPS_ALPHAGOURAUDSTIPPLED 0x00008000L +#define D3DPSHADECAPS_ALPHAPHONGBLEND 0x00010000L +#define D3DPSHADECAPS_ALPHAPHONGSTIPPLED 0x00020000L + +#define D3DPSHADECAPS_FOGFLAT 0x00040000L +#define D3DPSHADECAPS_FOGGOURAUD 0x00080000L +#define D3DPSHADECAPS_FOGPHONG 0x00100000L + +/* D3DPRIMCAPS dwTextureCaps */ + +/* + * Perspective-correct texturing is supported + */ +#define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001L + +/* + * Power-of-2 texture dimensions are required + */ +#define D3DPTEXTURECAPS_POW2 0x00000002L + +/* + * Alpha in texture pixels is supported + */ +#define D3DPTEXTURECAPS_ALPHA 0x00000004L + +/* + * Color-keyed textures are supported + */ +#define D3DPTEXTURECAPS_TRANSPARENCY 0x00000008L + +/* + * obsolete, see D3DPTADDRESSCAPS_BORDER + */ +#define D3DPTEXTURECAPS_BORDER 0x00000010L + +/* + * Only square textures are supported + */ +#define D3DPTEXTURECAPS_SQUAREONLY 0x00000020L + +#if(DIRECT3D_VERSION >= 0x0600) +/* + * Texture indices are not scaled by the texture size prior + * to interpolation. + */ +#define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040L + +/* + * Device can draw alpha from texture palettes + */ +#define D3DPTEXTURECAPS_ALPHAPALETTE 0x00000080L + +/* + * Device can use non-POW2 textures if: + * 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage + * 2) D3DRS_WRAP(N) is zero for this texture's coordinates + * 3) mip mapping is not enabled (use magnification filter only) + */ +#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100L + +#endif /* DIRECT3D_VERSION >= 0x0600 */ +#if(DIRECT3D_VERSION >= 0x0700) + +// 0x00000200L unused + +/* + * Device can divide transformed texture coordinates by the + * COUNTth texture coordinate (can do D3DTTFF_PROJECTED) + */ +#define D3DPTEXTURECAPS_PROJECTED 0x00000400L + +/* + * Device can do cubemap textures + */ +#define D3DPTEXTURECAPS_CUBEMAP 0x00000800L + +#define D3DPTEXTURECAPS_COLORKEYBLEND 0x00001000L +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +/* D3DPRIMCAPS dwTextureFilterCaps */ + +#define D3DPTFILTERCAPS_NEAREST 0x00000001L +#define D3DPTFILTERCAPS_LINEAR 0x00000002L +#define D3DPTFILTERCAPS_MIPNEAREST 0x00000004L +#define D3DPTFILTERCAPS_MIPLINEAR 0x00000008L +#define D3DPTFILTERCAPS_LINEARMIPNEAREST 0x00000010L +#define D3DPTFILTERCAPS_LINEARMIPLINEAR 0x00000020L + +#if(DIRECT3D_VERSION >= 0x0600) +/* Device3 Min Filter */ +#define D3DPTFILTERCAPS_MINFPOINT 0x00000100L +#define D3DPTFILTERCAPS_MINFLINEAR 0x00000200L +#define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400L + +/* Device3 Mip Filter */ +#define D3DPTFILTERCAPS_MIPFPOINT 0x00010000L +#define D3DPTFILTERCAPS_MIPFLINEAR 0x00020000L + +/* Device3 Mag Filter */ +#define D3DPTFILTERCAPS_MAGFPOINT 0x01000000L +#define D3DPTFILTERCAPS_MAGFLINEAR 0x02000000L +#define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000L +#define D3DPTFILTERCAPS_MAGFAFLATCUBIC 0x08000000L +#define D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC 0x10000000L +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +/* D3DPRIMCAPS dwTextureBlendCaps */ + +#define D3DPTBLENDCAPS_DECAL 0x00000001L +#define D3DPTBLENDCAPS_MODULATE 0x00000002L +#define D3DPTBLENDCAPS_DECALALPHA 0x00000004L +#define D3DPTBLENDCAPS_MODULATEALPHA 0x00000008L +#define D3DPTBLENDCAPS_DECALMASK 0x00000010L +#define D3DPTBLENDCAPS_MODULATEMASK 0x00000020L +#define D3DPTBLENDCAPS_COPY 0x00000040L +#if(DIRECT3D_VERSION >= 0x0500) +#define D3DPTBLENDCAPS_ADD 0x00000080L +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +/* D3DPRIMCAPS dwTextureAddressCaps */ +#define D3DPTADDRESSCAPS_WRAP 0x00000001L +#define D3DPTADDRESSCAPS_MIRROR 0x00000002L +#define D3DPTADDRESSCAPS_CLAMP 0x00000004L +#if(DIRECT3D_VERSION >= 0x0500) +#define D3DPTADDRESSCAPS_BORDER 0x00000008L +#define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010L +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if(DIRECT3D_VERSION >= 0x0600) + +/* D3DDEVICEDESC dwStencilCaps */ + +#define D3DSTENCILCAPS_KEEP 0x00000001L +#define D3DSTENCILCAPS_ZERO 0x00000002L +#define D3DSTENCILCAPS_REPLACE 0x00000004L +#define D3DSTENCILCAPS_INCRSAT 0x00000008L +#define D3DSTENCILCAPS_DECRSAT 0x00000010L +#define D3DSTENCILCAPS_INVERT 0x00000020L +#define D3DSTENCILCAPS_INCR 0x00000040L +#define D3DSTENCILCAPS_DECR 0x00000080L + +/* D3DDEVICEDESC dwTextureOpCaps */ + +#define D3DTEXOPCAPS_DISABLE 0x00000001L +#define D3DTEXOPCAPS_SELECTARG1 0x00000002L +#define D3DTEXOPCAPS_SELECTARG2 0x00000004L +#define D3DTEXOPCAPS_MODULATE 0x00000008L +#define D3DTEXOPCAPS_MODULATE2X 0x00000010L +#define D3DTEXOPCAPS_MODULATE4X 0x00000020L +#define D3DTEXOPCAPS_ADD 0x00000040L +#define D3DTEXOPCAPS_ADDSIGNED 0x00000080L +#define D3DTEXOPCAPS_ADDSIGNED2X 0x00000100L +#define D3DTEXOPCAPS_SUBTRACT 0x00000200L +#define D3DTEXOPCAPS_ADDSMOOTH 0x00000400L +#define D3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x00000800L +#define D3DTEXOPCAPS_BLENDTEXTUREALPHA 0x00001000L +#define D3DTEXOPCAPS_BLENDFACTORALPHA 0x00002000L +#define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x00004000L +#define D3DTEXOPCAPS_BLENDCURRENTALPHA 0x00008000L +#define D3DTEXOPCAPS_PREMODULATE 0x00010000L +#define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x00020000L +#define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x00040000L +#define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x00080000L +#define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x00100000L +#define D3DTEXOPCAPS_BUMPENVMAP 0x00200000L +#define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x00400000L +#define D3DTEXOPCAPS_DOTPRODUCT3 0x00800000L + +/* D3DDEVICEDESC dwFVFCaps flags */ + +#define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000ffffL /* mask for texture coordinate count field */ +#define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000L /* Device prefers that vertex elements not be stripped */ + +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +/* + * Description for a device. + * This is used to describe a device that is to be created or to query + * the current device. + */ +typedef struct _D3DDeviceDesc { + DWORD dwSize; /* Size of D3DDEVICEDESC structure */ + DWORD dwFlags; /* Indicates which fields have valid data */ + D3DCOLORMODEL dcmColorModel; /* Color model of device */ + DWORD dwDevCaps; /* Capabilities of device */ + D3DTRANSFORMCAPS dtcTransformCaps; /* Capabilities of transform */ + BOOL bClipping; /* Device can do 3D clipping */ + D3DLIGHTINGCAPS dlcLightingCaps; /* Capabilities of lighting */ + D3DPRIMCAPS dpcLineCaps; + D3DPRIMCAPS dpcTriCaps; + DWORD dwDeviceRenderBitDepth; /* One of DDBB_8, 16, etc.. */ + DWORD dwDeviceZBufferBitDepth;/* One of DDBD_16, 32, etc.. */ + DWORD dwMaxBufferSize; /* Maximum execute buffer size */ + DWORD dwMaxVertexCount; /* Maximum vertex count */ +#if(DIRECT3D_VERSION >= 0x0500) + // *** New fields for DX5 *** // + + // Width and height caps are 0 for legacy HALs. + DWORD dwMinTextureWidth, dwMinTextureHeight; + DWORD dwMaxTextureWidth, dwMaxTextureHeight; + DWORD dwMinStippleWidth, dwMaxStippleWidth; + DWORD dwMinStippleHeight, dwMaxStippleHeight; +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if(DIRECT3D_VERSION >= 0x0600) + // New fields for DX6 + DWORD dwMaxTextureRepeat; + DWORD dwMaxTextureAspectRatio; + DWORD dwMaxAnisotropy; + + // Guard band that the rasterizer can accommodate + // Screen-space vertices inside this space but outside the viewport + // will get clipped properly. + D3DVALUE dvGuardBandLeft; + D3DVALUE dvGuardBandTop; + D3DVALUE dvGuardBandRight; + D3DVALUE dvGuardBandBottom; + + D3DVALUE dvExtentsAdjust; + DWORD dwStencilCaps; + + DWORD dwFVFCaps; + DWORD dwTextureOpCaps; + WORD wMaxTextureBlendStages; + WORD wMaxSimultaneousTextures; +#endif /* DIRECT3D_VERSION >= 0x0600 */ +} D3DDEVICEDESC, *LPD3DDEVICEDESC; + +#if(DIRECT3D_VERSION >= 0x0700) +typedef struct _D3DDeviceDesc7 { + DWORD dwDevCaps; /* Capabilities of device */ + D3DPRIMCAPS dpcLineCaps; + D3DPRIMCAPS dpcTriCaps; + DWORD dwDeviceRenderBitDepth; /* One of DDBB_8, 16, etc.. */ + DWORD dwDeviceZBufferBitDepth;/* One of DDBD_16, 32, etc.. */ + + DWORD dwMinTextureWidth, dwMinTextureHeight; + DWORD dwMaxTextureWidth, dwMaxTextureHeight; + + DWORD dwMaxTextureRepeat; + DWORD dwMaxTextureAspectRatio; + DWORD dwMaxAnisotropy; + + D3DVALUE dvGuardBandLeft; + D3DVALUE dvGuardBandTop; + D3DVALUE dvGuardBandRight; + D3DVALUE dvGuardBandBottom; + + D3DVALUE dvExtentsAdjust; + DWORD dwStencilCaps; + + DWORD dwFVFCaps; + DWORD dwTextureOpCaps; + WORD wMaxTextureBlendStages; + WORD wMaxSimultaneousTextures; + + DWORD dwMaxActiveLights; + D3DVALUE dvMaxVertexW; + GUID deviceGUID; + + WORD wMaxUserClipPlanes; + WORD wMaxVertexBlendMatrices; + + DWORD dwVertexProcessingCaps; + + DWORD dwReserved1; + DWORD dwReserved2; + DWORD dwReserved3; + DWORD dwReserved4; +} D3DDEVICEDESC7, *LPD3DDEVICEDESC7; +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +#define D3DDEVICEDESCSIZE (sizeof(D3DDEVICEDESC)) +#define D3DDEVICEDESC7SIZE (sizeof(D3DDEVICEDESC7)) + +typedef HRESULT (CALLBACK * LPD3DENUMDEVICESCALLBACK)(GUID FAR *lpGuid, LPSTR lpDeviceDescription, LPSTR lpDeviceName, LPD3DDEVICEDESC, LPD3DDEVICEDESC, LPVOID); + +#if(DIRECT3D_VERSION >= 0x0700) +typedef HRESULT (CALLBACK * LPD3DENUMDEVICESCALLBACK7)(LPSTR lpDeviceDescription, LPSTR lpDeviceName, LPD3DDEVICEDESC7, LPVOID); +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +/* D3DDEVICEDESC dwFlags indicating valid fields */ + +#define D3DDD_COLORMODEL 0x00000001L /* dcmColorModel is valid */ +#define D3DDD_DEVCAPS 0x00000002L /* dwDevCaps is valid */ +#define D3DDD_TRANSFORMCAPS 0x00000004L /* dtcTransformCaps is valid */ +#define D3DDD_LIGHTINGCAPS 0x00000008L /* dlcLightingCaps is valid */ +#define D3DDD_BCLIPPING 0x00000010L /* bClipping is valid */ +#define D3DDD_LINECAPS 0x00000020L /* dpcLineCaps is valid */ +#define D3DDD_TRICAPS 0x00000040L /* dpcTriCaps is valid */ +#define D3DDD_DEVICERENDERBITDEPTH 0x00000080L /* dwDeviceRenderBitDepth is valid */ +#define D3DDD_DEVICEZBUFFERBITDEPTH 0x00000100L /* dwDeviceZBufferBitDepth is valid */ +#define D3DDD_MAXBUFFERSIZE 0x00000200L /* dwMaxBufferSize is valid */ +#define D3DDD_MAXVERTEXCOUNT 0x00000400L /* dwMaxVertexCount is valid */ + +/* D3DDEVICEDESC dwDevCaps flags */ + +#define D3DDEVCAPS_FLOATTLVERTEX 0x00000001L /* Device accepts floating point */ + /* for post-transform vertex data */ +#define D3DDEVCAPS_SORTINCREASINGZ 0x00000002L /* Device needs data sorted for increasing Z */ +#define D3DDEVCAPS_SORTDECREASINGZ 0X00000004L /* Device needs data sorted for decreasing Z */ +#define D3DDEVCAPS_SORTEXACT 0x00000008L /* Device needs data sorted exactly */ + +#define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010L /* Device can use execute buffers from system memory */ +#define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020L /* Device can use execute buffers from video 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 */ +#if(DIRECT3D_VERSION >= 0x0500) +#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 */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ +#if(DIRECT3D_VERSION >= 0x0600) +#define D3DDEVCAPS_DRAWPRIMITIVES2 0x00002000L /* Device can support DrawPrimitives2 */ +#define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000L /* Device is texturing from separate memory pools */ +#define D3DDEVCAPS_DRAWPRIMITIVES2EX 0x00008000L /* Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver*/ +#endif /* DIRECT3D_VERSION >= 0x0600 */ +#if(DIRECT3D_VERSION >= 0x0700) +#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 */ + +/* + * These are the flags in the D3DDEVICEDESC7.dwVertexProcessingCaps field + */ + +/* device can do texgen */ +#define D3DVTXPCAPS_TEXGEN 0x00000001L +/* device can do IDirect3DDevice7 colormaterialsource ops */ +#define D3DVTXPCAPS_MATERIALSOURCE7 0x00000002L +/* device can do vertex fog */ +#define D3DVTXPCAPS_VERTEXFOG 0x00000004L +/* device can do directional lights */ +#define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008L +/* device can do positional lights (includes point and spot) */ +#define D3DVTXPCAPS_POSITIONALLIGHTS 0x00000010L +/* device can do local viewer */ +#define D3DVTXPCAPS_LOCALVIEWER 0x00000020L + +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +#define D3DFDS_COLORMODEL 0x00000001L /* Match color model */ +#define D3DFDS_GUID 0x00000002L /* Match guid */ +#define D3DFDS_HARDWARE 0x00000004L /* Match hardware/software */ +#define D3DFDS_TRIANGLES 0x00000008L /* Match in triCaps */ +#define D3DFDS_LINES 0x00000010L /* Match in lineCaps */ +#define D3DFDS_MISCCAPS 0x00000020L /* Match primCaps.dwMiscCaps */ +#define D3DFDS_RASTERCAPS 0x00000040L /* Match primCaps.dwRasterCaps */ +#define D3DFDS_ZCMPCAPS 0x00000080L /* Match primCaps.dwZCmpCaps */ +#define D3DFDS_ALPHACMPCAPS 0x00000100L /* Match primCaps.dwAlphaCmpCaps */ +#define D3DFDS_SRCBLENDCAPS 0x00000200L /* Match primCaps.dwSourceBlendCaps */ +#define D3DFDS_DSTBLENDCAPS 0x00000400L /* Match primCaps.dwDestBlendCaps */ +#define D3DFDS_SHADECAPS 0x00000800L /* Match primCaps.dwShadeCaps */ +#define D3DFDS_TEXTURECAPS 0x00001000L /* Match primCaps.dwTextureCaps */ +#define D3DFDS_TEXTUREFILTERCAPS 0x00002000L /* Match primCaps.dwTextureFilterCaps */ +#define D3DFDS_TEXTUREBLENDCAPS 0x00004000L /* Match primCaps.dwTextureBlendCaps */ +#define D3DFDS_TEXTUREADDRESSCAPS 0x00008000L /* Match primCaps.dwTextureBlendCaps */ + +/* + * FindDevice arguments + */ +typedef struct _D3DFINDDEVICESEARCH { + DWORD dwSize; + DWORD dwFlags; + BOOL bHardware; + D3DCOLORMODEL dcmColorModel; + GUID guid; + DWORD dwCaps; + D3DPRIMCAPS dpcPrimCaps; +} D3DFINDDEVICESEARCH, *LPD3DFINDDEVICESEARCH; + +typedef struct _D3DFINDDEVICERESULT { + DWORD dwSize; + GUID guid; /* guid which matched */ + D3DDEVICEDESC ddHwDesc; /* hardware D3DDEVICEDESC */ + D3DDEVICEDESC ddSwDesc; /* software D3DDEVICEDESC */ +} D3DFINDDEVICERESULT, *LPD3DFINDDEVICERESULT; + +/* + * Description of execute buffer. + */ +typedef struct _D3DExecuteBufferDesc { + DWORD dwSize; /* size of this structure */ + DWORD dwFlags; /* flags indicating which fields are valid */ + DWORD dwCaps; /* capabilities of execute buffer */ + DWORD dwBufferSize; /* size of execute buffer data */ + LPVOID lpData; /* pointer to actual data */ +} D3DEXECUTEBUFFERDESC, *LPD3DEXECUTEBUFFERDESC; + +/* D3DEXECUTEBUFFER dwFlags indicating valid fields */ + +#define D3DDEB_BUFSIZE 0x00000001l /* buffer size valid */ +#define D3DDEB_CAPS 0x00000002l /* caps valid */ +#define D3DDEB_LPDATA 0x00000004l /* lpData valid */ + +/* D3DEXECUTEBUFFER dwCaps */ + +#define D3DDEBCAPS_SYSTEMMEMORY 0x00000001l /* buffer in system memory */ +#define D3DDEBCAPS_VIDEOMEMORY 0x00000002l /* buffer in device memory */ +#define D3DDEBCAPS_MEM (D3DDEBCAPS_SYSTEMMEMORY|D3DDEBCAPS_VIDEOMEMORY) + +#if(DIRECT3D_VERSION < 0x0800) + +#if(DIRECT3D_VERSION >= 0x0700) +typedef struct _D3DDEVINFO_TEXTUREMANAGER { + BOOL bThrashing; /* indicates if thrashing */ + DWORD dwApproxBytesDownloaded; /* Approximate number of bytes downloaded by texture manager */ + DWORD dwNumEvicts; /* number of textures evicted */ + DWORD dwNumVidCreates; /* number of textures created in video memory */ + DWORD dwNumTexturesUsed; /* number of textures used */ + DWORD dwNumUsedTexInVid; /* number of used textures present in video memory */ + DWORD dwWorkingSet; /* number of textures in video memory */ + DWORD dwWorkingSetBytes; /* number of bytes in video memory */ + DWORD dwTotalManaged; /* total number of managed textures */ + DWORD dwTotalBytes; /* total number of bytes of managed textures */ + DWORD dwLastPri; /* priority of last texture evicted */ +} D3DDEVINFO_TEXTUREMANAGER, *LPD3DDEVINFO_TEXTUREMANAGER; + +typedef struct _D3DDEVINFO_TEXTURING { + DWORD dwNumLoads; /* counts Load() API calls */ + DWORD dwApproxBytesLoaded; /* Approximate number bytes loaded via Load() */ + DWORD dwNumPreLoads; /* counts PreLoad() API calls */ + DWORD dwNumSet; /* counts SetTexture() API calls */ + DWORD dwNumCreates; /* counts texture creates */ + DWORD dwNumDestroys; /* counts texture destroys */ + DWORD dwNumSetPriorities; /* counts SetPriority() API calls */ + DWORD dwNumSetLODs; /* counts SetLOD() API calls */ + DWORD dwNumLocks; /* counts number of texture locks */ + DWORD dwNumGetDCs; /* counts number of GetDCs to textures */ +} D3DDEVINFO_TEXTURING, *LPD3DDEVINFO_TEXTURING; +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +#endif //(DIRECT3D_VERSION < 0x0800) + +#pragma pack() + + +#endif /* _D3DCAPS_H_ */ + diff --git a/src/dep/include/DXSDK/include/d3drm.h b/src/dep/include/DXSDK/include/d3drm.h index 95594b8..143c0e0 100644 --- a/src/dep/include/DXSDK/include/d3drm.h +++ b/src/dep/include/DXSDK/include/d3drm.h @@ -1,342 +1,342 @@ -/*==========================================================================; - * - * Copyright (c) Microsoft Corporation. All rights reserved. - * - * File: d3drm.h - * Content: Direct3DRM include file - * - ***************************************************************************/ - -#ifndef __D3DRM_H__ -#define __D3DRM_H__ - -#include "ddraw.h" - -#ifdef __cplusplus -struct IDirect3DRM; -#endif - -typedef struct IDirect3DRM *LPDIRECT3DRM; - -#include "d3drmobj.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -DEFINE_GUID(IID_IDirect3DRM, 0x2bc49361, 0x8327, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRM2, 0x4516ecc8, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(IID_IDirect3DRM3, 0x4516ec83, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); -WIN_TYPES(IDirect3DRM, DIRECT3DRM); -WIN_TYPES(IDirect3DRM2, DIRECT3DRM2); -WIN_TYPES(IDirect3DRM3, DIRECT3DRM3); - -/* - * Direct3DRM Object Class (for CoCreateInstance()) - */ -DEFINE_GUID(CLSID_CDirect3DRM, 0x4516ec41, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); - - -/* Create a Direct3DRM API */ -STDAPI Direct3DRMCreate(LPDIRECT3DRM FAR *lplpDirect3DRM); - -#undef INTERFACE -#define INTERFACE IDirect3DRM - -DECLARE_INTERFACE_(IDirect3DRM, IUnknown) -{ - IUNKNOWN_METHODS(PURE); - - STDMETHOD(CreateObject) - (THIS_ REFCLSID rclsid, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID FAR* ppv) PURE; - STDMETHOD(CreateFrame) (THIS_ LPDIRECT3DRMFRAME, LPDIRECT3DRMFRAME *) PURE; - STDMETHOD(CreateMesh) (THIS_ LPDIRECT3DRMMESH *) PURE; - STDMETHOD(CreateMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER *) PURE; - STDMETHOD(CreateFace) (THIS_ LPDIRECT3DRMFACE *) PURE; - STDMETHOD(CreateAnimation) (THIS_ LPDIRECT3DRMANIMATION *) PURE; - STDMETHOD(CreateAnimationSet)(THIS_ LPDIRECT3DRMANIMATIONSET *) PURE; - STDMETHOD(CreateTexture) (THIS_ LPD3DRMIMAGE, LPDIRECT3DRMTEXTURE *) PURE; - STDMETHOD(CreateLight) (THIS_ D3DRMLIGHTTYPE, D3DCOLOR, LPDIRECT3DRMLIGHT *) PURE; - STDMETHOD(CreateLightRGB) - (THIS_ D3DRMLIGHTTYPE, D3DVALUE, D3DVALUE, D3DVALUE, LPDIRECT3DRMLIGHT *) PURE; - STDMETHOD(CreateMaterial) (THIS_ D3DVALUE, LPDIRECT3DRMMATERIAL *) PURE; - STDMETHOD(CreateDevice) (THIS_ DWORD, DWORD, LPDIRECT3DRMDEVICE *) PURE; - - /* Create a Windows Device using DirectDraw surfaces */ - STDMETHOD(CreateDeviceFromSurface) - ( THIS_ LPGUID lpGUID, LPDIRECTDRAW lpDD, - LPDIRECTDRAWSURFACE lpDDSBack, LPDIRECT3DRMDEVICE * - ) PURE; - - /* Create a Windows Device using D3D objects */ - STDMETHOD(CreateDeviceFromD3D) - ( THIS_ LPDIRECT3D lpD3D, LPDIRECT3DDEVICE lpD3DDev, - LPDIRECT3DRMDEVICE * - ) PURE; - - STDMETHOD(CreateDeviceFromClipper) - ( THIS_ LPDIRECTDRAWCLIPPER lpDDClipper, LPGUID lpGUID, - int width, int height, LPDIRECT3DRMDEVICE *) PURE; - - STDMETHOD(CreateTextureFromSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDS, LPDIRECT3DRMTEXTURE *) PURE; - - STDMETHOD(CreateShadow) - ( THIS_ LPDIRECT3DRMVISUAL, LPDIRECT3DRMLIGHT, - D3DVALUE px, D3DVALUE py, D3DVALUE pz, - D3DVALUE nx, D3DVALUE ny, D3DVALUE nz, - LPDIRECT3DRMVISUAL * - ) PURE; - STDMETHOD(CreateViewport) - ( THIS_ LPDIRECT3DRMDEVICE, LPDIRECT3DRMFRAME, DWORD, DWORD, - DWORD, DWORD, LPDIRECT3DRMVIEWPORT * - ) PURE; - STDMETHOD(CreateWrap) - ( THIS_ D3DRMWRAPTYPE, LPDIRECT3DRMFRAME, - D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, - D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, - D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, - D3DVALUE ou, D3DVALUE ov, - D3DVALUE su, D3DVALUE sv, - LPDIRECT3DRMWRAP * - ) PURE; - STDMETHOD(CreateUserVisual) (THIS_ D3DRMUSERVISUALCALLBACK, LPVOID lPArg, LPDIRECT3DRMUSERVISUAL *) PURE; - STDMETHOD(LoadTexture) (THIS_ const char *, LPDIRECT3DRMTEXTURE *) PURE; - STDMETHOD(LoadTextureFromResource) (THIS_ HRSRC rs, LPDIRECT3DRMTEXTURE *) PURE; - - STDMETHOD(SetSearchPath) (THIS_ LPCSTR) PURE; - STDMETHOD(AddSearchPath) (THIS_ LPCSTR) PURE; - STDMETHOD(GetSearchPath) (THIS_ DWORD *size_return, LPSTR path_return) PURE; - STDMETHOD(SetDefaultTextureColors)(THIS_ DWORD) PURE; - STDMETHOD(SetDefaultTextureShades)(THIS_ DWORD) PURE; - - STDMETHOD(GetDevices) (THIS_ LPDIRECT3DRMDEVICEARRAY *) PURE; - STDMETHOD(GetNamedObject) (THIS_ const char *, LPDIRECT3DRMOBJECT *) PURE; - - STDMETHOD(EnumerateObjects) (THIS_ D3DRMOBJECTCALLBACK, LPVOID) PURE; - - STDMETHOD(Load) - ( THIS_ LPVOID, LPVOID, LPIID *, DWORD, D3DRMLOADOPTIONS, - D3DRMLOADCALLBACK, LPVOID, D3DRMLOADTEXTURECALLBACK, LPVOID, - LPDIRECT3DRMFRAME - ) PURE; - STDMETHOD(Tick) (THIS_ D3DVALUE) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRM2 - -DECLARE_INTERFACE_(IDirect3DRM2, IUnknown) -{ - IUNKNOWN_METHODS(PURE); - - STDMETHOD(CreateObject) - (THIS_ REFCLSID rclsid, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID FAR* ppv) PURE; - STDMETHOD(CreateFrame) (THIS_ LPDIRECT3DRMFRAME, LPDIRECT3DRMFRAME2 *) PURE; - STDMETHOD(CreateMesh) (THIS_ LPDIRECT3DRMMESH *) PURE; - STDMETHOD(CreateMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER2 *) PURE; - STDMETHOD(CreateFace) (THIS_ LPDIRECT3DRMFACE *) PURE; - STDMETHOD(CreateAnimation) (THIS_ LPDIRECT3DRMANIMATION *) PURE; - STDMETHOD(CreateAnimationSet)(THIS_ LPDIRECT3DRMANIMATIONSET *) PURE; - STDMETHOD(CreateTexture) (THIS_ LPD3DRMIMAGE, LPDIRECT3DRMTEXTURE2 *) PURE; - STDMETHOD(CreateLight) (THIS_ D3DRMLIGHTTYPE, D3DCOLOR, LPDIRECT3DRMLIGHT *) PURE; - STDMETHOD(CreateLightRGB) - (THIS_ D3DRMLIGHTTYPE, D3DVALUE, D3DVALUE, D3DVALUE, LPDIRECT3DRMLIGHT *) PURE; - STDMETHOD(CreateMaterial) (THIS_ D3DVALUE, LPDIRECT3DRMMATERIAL *) PURE; - STDMETHOD(CreateDevice) (THIS_ DWORD, DWORD, LPDIRECT3DRMDEVICE2 *) PURE; - - /* Create a Windows Device using DirectDraw surfaces */ - STDMETHOD(CreateDeviceFromSurface) - ( THIS_ LPGUID lpGUID, LPDIRECTDRAW lpDD, - LPDIRECTDRAWSURFACE lpDDSBack, LPDIRECT3DRMDEVICE2 * - ) PURE; - - /* Create a Windows Device using D3D objects */ - STDMETHOD(CreateDeviceFromD3D) - ( THIS_ LPDIRECT3D2 lpD3D, LPDIRECT3DDEVICE2 lpD3DDev, - LPDIRECT3DRMDEVICE2 * - ) PURE; - - STDMETHOD(CreateDeviceFromClipper) - ( THIS_ LPDIRECTDRAWCLIPPER lpDDClipper, LPGUID lpGUID, - int width, int height, LPDIRECT3DRMDEVICE2 *) PURE; - - STDMETHOD(CreateTextureFromSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDS, LPDIRECT3DRMTEXTURE2 *) PURE; - - STDMETHOD(CreateShadow) - ( THIS_ LPDIRECT3DRMVISUAL, LPDIRECT3DRMLIGHT, - D3DVALUE px, D3DVALUE py, D3DVALUE pz, - D3DVALUE nx, D3DVALUE ny, D3DVALUE nz, - LPDIRECT3DRMVISUAL * - ) PURE; - STDMETHOD(CreateViewport) - ( THIS_ LPDIRECT3DRMDEVICE, LPDIRECT3DRMFRAME, DWORD, DWORD, - DWORD, DWORD, LPDIRECT3DRMVIEWPORT * - ) PURE; - STDMETHOD(CreateWrap) - ( THIS_ D3DRMWRAPTYPE, LPDIRECT3DRMFRAME, - D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, - D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, - D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, - D3DVALUE ou, D3DVALUE ov, - D3DVALUE su, D3DVALUE sv, - LPDIRECT3DRMWRAP * - ) PURE; - STDMETHOD(CreateUserVisual) (THIS_ D3DRMUSERVISUALCALLBACK, LPVOID lPArg, LPDIRECT3DRMUSERVISUAL *) PURE; - STDMETHOD(LoadTexture) (THIS_ const char *, LPDIRECT3DRMTEXTURE2 *) PURE; - STDMETHOD(LoadTextureFromResource) (THIS_ HMODULE hModule, LPCTSTR strName, LPCTSTR strType, LPDIRECT3DRMTEXTURE2 *) PURE; - - STDMETHOD(SetSearchPath) (THIS_ LPCSTR) PURE; - STDMETHOD(AddSearchPath) (THIS_ LPCSTR) PURE; - STDMETHOD(GetSearchPath) (THIS_ DWORD *size_return, LPSTR path_return) PURE; - STDMETHOD(SetDefaultTextureColors)(THIS_ DWORD) PURE; - STDMETHOD(SetDefaultTextureShades)(THIS_ DWORD) PURE; - - STDMETHOD(GetDevices) (THIS_ LPDIRECT3DRMDEVICEARRAY *) PURE; - STDMETHOD(GetNamedObject) (THIS_ const char *, LPDIRECT3DRMOBJECT *) PURE; - - STDMETHOD(EnumerateObjects) (THIS_ D3DRMOBJECTCALLBACK, LPVOID) PURE; - - STDMETHOD(Load) - ( THIS_ LPVOID, LPVOID, LPIID *, DWORD, D3DRMLOADOPTIONS, - D3DRMLOADCALLBACK, LPVOID, D3DRMLOADTEXTURECALLBACK, LPVOID, - LPDIRECT3DRMFRAME - ) PURE; - STDMETHOD(Tick) (THIS_ D3DVALUE) PURE; - - STDMETHOD(CreateProgressiveMesh)(THIS_ LPDIRECT3DRMPROGRESSIVEMESH *) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRM3 - -DECLARE_INTERFACE_(IDirect3DRM3, IUnknown) -{ - IUNKNOWN_METHODS(PURE); - - STDMETHOD(CreateObject) - (THIS_ REFCLSID rclsid, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID FAR* ppv) PURE; - STDMETHOD(CreateFrame) (THIS_ LPDIRECT3DRMFRAME3, LPDIRECT3DRMFRAME3 *) PURE; - STDMETHOD(CreateMesh) (THIS_ LPDIRECT3DRMMESH *) PURE; - STDMETHOD(CreateMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER3 *) PURE; - STDMETHOD(CreateFace) (THIS_ LPDIRECT3DRMFACE2 *) PURE; - STDMETHOD(CreateAnimation) (THIS_ LPDIRECT3DRMANIMATION2 *) PURE; - STDMETHOD(CreateAnimationSet)(THIS_ LPDIRECT3DRMANIMATIONSET2 *) PURE; - STDMETHOD(CreateTexture) (THIS_ LPD3DRMIMAGE, LPDIRECT3DRMTEXTURE3 *) PURE; - STDMETHOD(CreateLight) (THIS_ D3DRMLIGHTTYPE, D3DCOLOR, LPDIRECT3DRMLIGHT *) PURE; - STDMETHOD(CreateLightRGB) - (THIS_ D3DRMLIGHTTYPE, D3DVALUE, D3DVALUE, D3DVALUE, LPDIRECT3DRMLIGHT *) PURE; - STDMETHOD(CreateMaterial) (THIS_ D3DVALUE, LPDIRECT3DRMMATERIAL2 *) PURE; - STDMETHOD(CreateDevice) (THIS_ DWORD, DWORD, LPDIRECT3DRMDEVICE3 *) PURE; - - /* Create a Windows Device using DirectDraw surfaces */ - STDMETHOD(CreateDeviceFromSurface) - ( THIS_ LPGUID lpGUID, LPDIRECTDRAW lpDD, - LPDIRECTDRAWSURFACE lpDDSBack, DWORD dwFlags, LPDIRECT3DRMDEVICE3 * - ) PURE; - - /* Create a Windows Device using D3D objects */ - STDMETHOD(CreateDeviceFromD3D) - ( THIS_ LPDIRECT3D2 lpD3D, LPDIRECT3DDEVICE2 lpD3DDev, - LPDIRECT3DRMDEVICE3 * - ) PURE; - - STDMETHOD(CreateDeviceFromClipper) - ( THIS_ LPDIRECTDRAWCLIPPER lpDDClipper, LPGUID lpGUID, - int width, int height, LPDIRECT3DRMDEVICE3 *) PURE; - - STDMETHOD(CreateTextureFromSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDS, LPDIRECT3DRMTEXTURE3 *) PURE; - - STDMETHOD(CreateShadow) - ( THIS_ LPUNKNOWN, LPDIRECT3DRMLIGHT, - D3DVALUE px, D3DVALUE py, D3DVALUE pz, - D3DVALUE nx, D3DVALUE ny, D3DVALUE nz, - LPDIRECT3DRMSHADOW2 * - ) PURE; - STDMETHOD(CreateViewport) - ( THIS_ LPDIRECT3DRMDEVICE3, LPDIRECT3DRMFRAME3, DWORD, DWORD, - DWORD, DWORD, LPDIRECT3DRMVIEWPORT2 * - ) PURE; - STDMETHOD(CreateWrap) - ( THIS_ D3DRMWRAPTYPE, LPDIRECT3DRMFRAME3, - D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, - D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, - D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, - D3DVALUE ou, D3DVALUE ov, - D3DVALUE su, D3DVALUE sv, - LPDIRECT3DRMWRAP * - ) PURE; - STDMETHOD(CreateUserVisual) (THIS_ D3DRMUSERVISUALCALLBACK, LPVOID lPArg, LPDIRECT3DRMUSERVISUAL *) PURE; - STDMETHOD(LoadTexture) (THIS_ const char *, LPDIRECT3DRMTEXTURE3 *) PURE; - STDMETHOD(LoadTextureFromResource) (THIS_ HMODULE hModule, LPCTSTR strName, LPCTSTR strType, LPDIRECT3DRMTEXTURE3 *) PURE; - - STDMETHOD(SetSearchPath) (THIS_ LPCSTR) PURE; - STDMETHOD(AddSearchPath) (THIS_ LPCSTR) PURE; - STDMETHOD(GetSearchPath) (THIS_ DWORD *size_return, LPSTR path_return) PURE; - STDMETHOD(SetDefaultTextureColors)(THIS_ DWORD) PURE; - STDMETHOD(SetDefaultTextureShades)(THIS_ DWORD) PURE; - - STDMETHOD(GetDevices) (THIS_ LPDIRECT3DRMDEVICEARRAY *) PURE; - STDMETHOD(GetNamedObject) (THIS_ const char *, LPDIRECT3DRMOBJECT *) PURE; - - STDMETHOD(EnumerateObjects) (THIS_ D3DRMOBJECTCALLBACK, LPVOID) PURE; - - STDMETHOD(Load) - ( THIS_ LPVOID, LPVOID, LPIID *, DWORD, D3DRMLOADOPTIONS, - D3DRMLOADCALLBACK, LPVOID, D3DRMLOADTEXTURE3CALLBACK, LPVOID, - LPDIRECT3DRMFRAME3 - ) PURE; - STDMETHOD(Tick) (THIS_ D3DVALUE) PURE; - - STDMETHOD(CreateProgressiveMesh)(THIS_ LPDIRECT3DRMPROGRESSIVEMESH *) PURE; - - /* Used with IDirect3DRMObject2 */ - STDMETHOD(RegisterClient) (THIS_ REFGUID rguid, LPDWORD lpdwID) PURE; - STDMETHOD(UnregisterClient) (THIS_ REFGUID rguid) PURE; - - STDMETHOD(CreateClippedVisual) (THIS_ LPDIRECT3DRMVISUAL, LPDIRECT3DRMCLIPPEDVISUAL *) PURE; - STDMETHOD(SetOptions) (THIS_ DWORD); - STDMETHOD(GetOptions) (THIS_ LPDWORD); -}; - -#define D3DRM_OK DD_OK -#define D3DRMERR_BADOBJECT MAKE_DDHRESULT(781) -#define D3DRMERR_BADTYPE MAKE_DDHRESULT(782) -#define D3DRMERR_BADALLOC MAKE_DDHRESULT(783) -#define D3DRMERR_FACEUSED MAKE_DDHRESULT(784) -#define D3DRMERR_NOTFOUND MAKE_DDHRESULT(785) -#define D3DRMERR_NOTDONEYET MAKE_DDHRESULT(786) -#define D3DRMERR_FILENOTFOUND MAKE_DDHRESULT(787) -#define D3DRMERR_BADFILE MAKE_DDHRESULT(788) -#define D3DRMERR_BADDEVICE MAKE_DDHRESULT(789) -#define D3DRMERR_BADVALUE MAKE_DDHRESULT(790) -#define D3DRMERR_BADMAJORVERSION MAKE_DDHRESULT(791) -#define D3DRMERR_BADMINORVERSION MAKE_DDHRESULT(792) -#define D3DRMERR_UNABLETOEXECUTE MAKE_DDHRESULT(793) -#define D3DRMERR_LIBRARYNOTFOUND MAKE_DDHRESULT(794) -#define D3DRMERR_INVALIDLIBRARY MAKE_DDHRESULT(795) -#define D3DRMERR_PENDING MAKE_DDHRESULT(796) -#define D3DRMERR_NOTENOUGHDATA MAKE_DDHRESULT(797) -#define D3DRMERR_REQUESTTOOLARGE MAKE_DDHRESULT(798) -#define D3DRMERR_REQUESTTOOSMALL MAKE_DDHRESULT(799) -#define D3DRMERR_CONNECTIONLOST MAKE_DDHRESULT(800) -#define D3DRMERR_LOADABORTED MAKE_DDHRESULT(801) -#define D3DRMERR_NOINTERNET MAKE_DDHRESULT(802) -#define D3DRMERR_BADCACHEFILE MAKE_DDHRESULT(803) -#define D3DRMERR_BOXNOTSET MAKE_DDHRESULT(804) -#define D3DRMERR_BADPMDATA MAKE_DDHRESULT(805) -#define D3DRMERR_CLIENTNOTREGISTERED MAKE_DDHRESULT(806) -#define D3DRMERR_NOTCREATEDFROMDDS MAKE_DDHRESULT(807) -#define D3DRMERR_NOSUCHKEY MAKE_DDHRESULT(808) -#define D3DRMERR_INCOMPATABLEKEY MAKE_DDHRESULT(809) -#define D3DRMERR_ELEMENTINUSE MAKE_DDHRESULT(810) -#define D3DRMERR_TEXTUREFORMATNOTFOUND MAKE_DDHRESULT(811) -#define D3DRMERR_NOTAGGREGATED MAKE_DDHRESULT(812) - -#ifdef __cplusplus -}; -#endif - -#endif /* _D3DRMAPI_H_ */ - - +/*==========================================================================; + * + * Copyright (c) Microsoft Corporation. All rights reserved. + * + * File: d3drm.h + * Content: Direct3DRM include file + * + ***************************************************************************/ + +#ifndef __D3DRM_H__ +#define __D3DRM_H__ + +#include "ddraw.h" + +#ifdef __cplusplus +struct IDirect3DRM; +#endif + +typedef struct IDirect3DRM *LPDIRECT3DRM; + +#include "d3drmobj.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +DEFINE_GUID(IID_IDirect3DRM, 0x2bc49361, 0x8327, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRM2, 0x4516ecc8, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(IID_IDirect3DRM3, 0x4516ec83, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); +WIN_TYPES(IDirect3DRM, DIRECT3DRM); +WIN_TYPES(IDirect3DRM2, DIRECT3DRM2); +WIN_TYPES(IDirect3DRM3, DIRECT3DRM3); + +/* + * Direct3DRM Object Class (for CoCreateInstance()) + */ +DEFINE_GUID(CLSID_CDirect3DRM, 0x4516ec41, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); + + +/* Create a Direct3DRM API */ +STDAPI Direct3DRMCreate(LPDIRECT3DRM FAR *lplpDirect3DRM); + +#undef INTERFACE +#define INTERFACE IDirect3DRM + +DECLARE_INTERFACE_(IDirect3DRM, IUnknown) +{ + IUNKNOWN_METHODS(PURE); + + STDMETHOD(CreateObject) + (THIS_ REFCLSID rclsid, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID FAR* ppv) PURE; + STDMETHOD(CreateFrame) (THIS_ LPDIRECT3DRMFRAME, LPDIRECT3DRMFRAME *) PURE; + STDMETHOD(CreateMesh) (THIS_ LPDIRECT3DRMMESH *) PURE; + STDMETHOD(CreateMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER *) PURE; + STDMETHOD(CreateFace) (THIS_ LPDIRECT3DRMFACE *) PURE; + STDMETHOD(CreateAnimation) (THIS_ LPDIRECT3DRMANIMATION *) PURE; + STDMETHOD(CreateAnimationSet)(THIS_ LPDIRECT3DRMANIMATIONSET *) PURE; + STDMETHOD(CreateTexture) (THIS_ LPD3DRMIMAGE, LPDIRECT3DRMTEXTURE *) PURE; + STDMETHOD(CreateLight) (THIS_ D3DRMLIGHTTYPE, D3DCOLOR, LPDIRECT3DRMLIGHT *) PURE; + STDMETHOD(CreateLightRGB) + (THIS_ D3DRMLIGHTTYPE, D3DVALUE, D3DVALUE, D3DVALUE, LPDIRECT3DRMLIGHT *) PURE; + STDMETHOD(CreateMaterial) (THIS_ D3DVALUE, LPDIRECT3DRMMATERIAL *) PURE; + STDMETHOD(CreateDevice) (THIS_ DWORD, DWORD, LPDIRECT3DRMDEVICE *) PURE; + + /* Create a Windows Device using DirectDraw surfaces */ + STDMETHOD(CreateDeviceFromSurface) + ( THIS_ LPGUID lpGUID, LPDIRECTDRAW lpDD, + LPDIRECTDRAWSURFACE lpDDSBack, LPDIRECT3DRMDEVICE * + ) PURE; + + /* Create a Windows Device using D3D objects */ + STDMETHOD(CreateDeviceFromD3D) + ( THIS_ LPDIRECT3D lpD3D, LPDIRECT3DDEVICE lpD3DDev, + LPDIRECT3DRMDEVICE * + ) PURE; + + STDMETHOD(CreateDeviceFromClipper) + ( THIS_ LPDIRECTDRAWCLIPPER lpDDClipper, LPGUID lpGUID, + int width, int height, LPDIRECT3DRMDEVICE *) PURE; + + STDMETHOD(CreateTextureFromSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDS, LPDIRECT3DRMTEXTURE *) PURE; + + STDMETHOD(CreateShadow) + ( THIS_ LPDIRECT3DRMVISUAL, LPDIRECT3DRMLIGHT, + D3DVALUE px, D3DVALUE py, D3DVALUE pz, + D3DVALUE nx, D3DVALUE ny, D3DVALUE nz, + LPDIRECT3DRMVISUAL * + ) PURE; + STDMETHOD(CreateViewport) + ( THIS_ LPDIRECT3DRMDEVICE, LPDIRECT3DRMFRAME, DWORD, DWORD, + DWORD, DWORD, LPDIRECT3DRMVIEWPORT * + ) PURE; + STDMETHOD(CreateWrap) + ( THIS_ D3DRMWRAPTYPE, LPDIRECT3DRMFRAME, + D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, + D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, + D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, + D3DVALUE ou, D3DVALUE ov, + D3DVALUE su, D3DVALUE sv, + LPDIRECT3DRMWRAP * + ) PURE; + STDMETHOD(CreateUserVisual) (THIS_ D3DRMUSERVISUALCALLBACK, LPVOID lPArg, LPDIRECT3DRMUSERVISUAL *) PURE; + STDMETHOD(LoadTexture) (THIS_ const char *, LPDIRECT3DRMTEXTURE *) PURE; + STDMETHOD(LoadTextureFromResource) (THIS_ HRSRC rs, LPDIRECT3DRMTEXTURE *) PURE; + + STDMETHOD(SetSearchPath) (THIS_ LPCSTR) PURE; + STDMETHOD(AddSearchPath) (THIS_ LPCSTR) PURE; + STDMETHOD(GetSearchPath) (THIS_ DWORD *size_return, LPSTR path_return) PURE; + STDMETHOD(SetDefaultTextureColors)(THIS_ DWORD) PURE; + STDMETHOD(SetDefaultTextureShades)(THIS_ DWORD) PURE; + + STDMETHOD(GetDevices) (THIS_ LPDIRECT3DRMDEVICEARRAY *) PURE; + STDMETHOD(GetNamedObject) (THIS_ const char *, LPDIRECT3DRMOBJECT *) PURE; + + STDMETHOD(EnumerateObjects) (THIS_ D3DRMOBJECTCALLBACK, LPVOID) PURE; + + STDMETHOD(Load) + ( THIS_ LPVOID, LPVOID, LPIID *, DWORD, D3DRMLOADOPTIONS, + D3DRMLOADCALLBACK, LPVOID, D3DRMLOADTEXTURECALLBACK, LPVOID, + LPDIRECT3DRMFRAME + ) PURE; + STDMETHOD(Tick) (THIS_ D3DVALUE) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRM2 + +DECLARE_INTERFACE_(IDirect3DRM2, IUnknown) +{ + IUNKNOWN_METHODS(PURE); + + STDMETHOD(CreateObject) + (THIS_ REFCLSID rclsid, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID FAR* ppv) PURE; + STDMETHOD(CreateFrame) (THIS_ LPDIRECT3DRMFRAME, LPDIRECT3DRMFRAME2 *) PURE; + STDMETHOD(CreateMesh) (THIS_ LPDIRECT3DRMMESH *) PURE; + STDMETHOD(CreateMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER2 *) PURE; + STDMETHOD(CreateFace) (THIS_ LPDIRECT3DRMFACE *) PURE; + STDMETHOD(CreateAnimation) (THIS_ LPDIRECT3DRMANIMATION *) PURE; + STDMETHOD(CreateAnimationSet)(THIS_ LPDIRECT3DRMANIMATIONSET *) PURE; + STDMETHOD(CreateTexture) (THIS_ LPD3DRMIMAGE, LPDIRECT3DRMTEXTURE2 *) PURE; + STDMETHOD(CreateLight) (THIS_ D3DRMLIGHTTYPE, D3DCOLOR, LPDIRECT3DRMLIGHT *) PURE; + STDMETHOD(CreateLightRGB) + (THIS_ D3DRMLIGHTTYPE, D3DVALUE, D3DVALUE, D3DVALUE, LPDIRECT3DRMLIGHT *) PURE; + STDMETHOD(CreateMaterial) (THIS_ D3DVALUE, LPDIRECT3DRMMATERIAL *) PURE; + STDMETHOD(CreateDevice) (THIS_ DWORD, DWORD, LPDIRECT3DRMDEVICE2 *) PURE; + + /* Create a Windows Device using DirectDraw surfaces */ + STDMETHOD(CreateDeviceFromSurface) + ( THIS_ LPGUID lpGUID, LPDIRECTDRAW lpDD, + LPDIRECTDRAWSURFACE lpDDSBack, LPDIRECT3DRMDEVICE2 * + ) PURE; + + /* Create a Windows Device using D3D objects */ + STDMETHOD(CreateDeviceFromD3D) + ( THIS_ LPDIRECT3D2 lpD3D, LPDIRECT3DDEVICE2 lpD3DDev, + LPDIRECT3DRMDEVICE2 * + ) PURE; + + STDMETHOD(CreateDeviceFromClipper) + ( THIS_ LPDIRECTDRAWCLIPPER lpDDClipper, LPGUID lpGUID, + int width, int height, LPDIRECT3DRMDEVICE2 *) PURE; + + STDMETHOD(CreateTextureFromSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDS, LPDIRECT3DRMTEXTURE2 *) PURE; + + STDMETHOD(CreateShadow) + ( THIS_ LPDIRECT3DRMVISUAL, LPDIRECT3DRMLIGHT, + D3DVALUE px, D3DVALUE py, D3DVALUE pz, + D3DVALUE nx, D3DVALUE ny, D3DVALUE nz, + LPDIRECT3DRMVISUAL * + ) PURE; + STDMETHOD(CreateViewport) + ( THIS_ LPDIRECT3DRMDEVICE, LPDIRECT3DRMFRAME, DWORD, DWORD, + DWORD, DWORD, LPDIRECT3DRMVIEWPORT * + ) PURE; + STDMETHOD(CreateWrap) + ( THIS_ D3DRMWRAPTYPE, LPDIRECT3DRMFRAME, + D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, + D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, + D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, + D3DVALUE ou, D3DVALUE ov, + D3DVALUE su, D3DVALUE sv, + LPDIRECT3DRMWRAP * + ) PURE; + STDMETHOD(CreateUserVisual) (THIS_ D3DRMUSERVISUALCALLBACK, LPVOID lPArg, LPDIRECT3DRMUSERVISUAL *) PURE; + STDMETHOD(LoadTexture) (THIS_ const char *, LPDIRECT3DRMTEXTURE2 *) PURE; + STDMETHOD(LoadTextureFromResource) (THIS_ HMODULE hModule, LPCTSTR strName, LPCTSTR strType, LPDIRECT3DRMTEXTURE2 *) PURE; + + STDMETHOD(SetSearchPath) (THIS_ LPCSTR) PURE; + STDMETHOD(AddSearchPath) (THIS_ LPCSTR) PURE; + STDMETHOD(GetSearchPath) (THIS_ DWORD *size_return, LPSTR path_return) PURE; + STDMETHOD(SetDefaultTextureColors)(THIS_ DWORD) PURE; + STDMETHOD(SetDefaultTextureShades)(THIS_ DWORD) PURE; + + STDMETHOD(GetDevices) (THIS_ LPDIRECT3DRMDEVICEARRAY *) PURE; + STDMETHOD(GetNamedObject) (THIS_ const char *, LPDIRECT3DRMOBJECT *) PURE; + + STDMETHOD(EnumerateObjects) (THIS_ D3DRMOBJECTCALLBACK, LPVOID) PURE; + + STDMETHOD(Load) + ( THIS_ LPVOID, LPVOID, LPIID *, DWORD, D3DRMLOADOPTIONS, + D3DRMLOADCALLBACK, LPVOID, D3DRMLOADTEXTURECALLBACK, LPVOID, + LPDIRECT3DRMFRAME + ) PURE; + STDMETHOD(Tick) (THIS_ D3DVALUE) PURE; + + STDMETHOD(CreateProgressiveMesh)(THIS_ LPDIRECT3DRMPROGRESSIVEMESH *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRM3 + +DECLARE_INTERFACE_(IDirect3DRM3, IUnknown) +{ + IUNKNOWN_METHODS(PURE); + + STDMETHOD(CreateObject) + (THIS_ REFCLSID rclsid, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID FAR* ppv) PURE; + STDMETHOD(CreateFrame) (THIS_ LPDIRECT3DRMFRAME3, LPDIRECT3DRMFRAME3 *) PURE; + STDMETHOD(CreateMesh) (THIS_ LPDIRECT3DRMMESH *) PURE; + STDMETHOD(CreateMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER3 *) PURE; + STDMETHOD(CreateFace) (THIS_ LPDIRECT3DRMFACE2 *) PURE; + STDMETHOD(CreateAnimation) (THIS_ LPDIRECT3DRMANIMATION2 *) PURE; + STDMETHOD(CreateAnimationSet)(THIS_ LPDIRECT3DRMANIMATIONSET2 *) PURE; + STDMETHOD(CreateTexture) (THIS_ LPD3DRMIMAGE, LPDIRECT3DRMTEXTURE3 *) PURE; + STDMETHOD(CreateLight) (THIS_ D3DRMLIGHTTYPE, D3DCOLOR, LPDIRECT3DRMLIGHT *) PURE; + STDMETHOD(CreateLightRGB) + (THIS_ D3DRMLIGHTTYPE, D3DVALUE, D3DVALUE, D3DVALUE, LPDIRECT3DRMLIGHT *) PURE; + STDMETHOD(CreateMaterial) (THIS_ D3DVALUE, LPDIRECT3DRMMATERIAL2 *) PURE; + STDMETHOD(CreateDevice) (THIS_ DWORD, DWORD, LPDIRECT3DRMDEVICE3 *) PURE; + + /* Create a Windows Device using DirectDraw surfaces */ + STDMETHOD(CreateDeviceFromSurface) + ( THIS_ LPGUID lpGUID, LPDIRECTDRAW lpDD, + LPDIRECTDRAWSURFACE lpDDSBack, DWORD dwFlags, LPDIRECT3DRMDEVICE3 * + ) PURE; + + /* Create a Windows Device using D3D objects */ + STDMETHOD(CreateDeviceFromD3D) + ( THIS_ LPDIRECT3D2 lpD3D, LPDIRECT3DDEVICE2 lpD3DDev, + LPDIRECT3DRMDEVICE3 * + ) PURE; + + STDMETHOD(CreateDeviceFromClipper) + ( THIS_ LPDIRECTDRAWCLIPPER lpDDClipper, LPGUID lpGUID, + int width, int height, LPDIRECT3DRMDEVICE3 *) PURE; + + STDMETHOD(CreateTextureFromSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDS, LPDIRECT3DRMTEXTURE3 *) PURE; + + STDMETHOD(CreateShadow) + ( THIS_ LPUNKNOWN, LPDIRECT3DRMLIGHT, + D3DVALUE px, D3DVALUE py, D3DVALUE pz, + D3DVALUE nx, D3DVALUE ny, D3DVALUE nz, + LPDIRECT3DRMSHADOW2 * + ) PURE; + STDMETHOD(CreateViewport) + ( THIS_ LPDIRECT3DRMDEVICE3, LPDIRECT3DRMFRAME3, DWORD, DWORD, + DWORD, DWORD, LPDIRECT3DRMVIEWPORT2 * + ) PURE; + STDMETHOD(CreateWrap) + ( THIS_ D3DRMWRAPTYPE, LPDIRECT3DRMFRAME3, + D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, + D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, + D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, + D3DVALUE ou, D3DVALUE ov, + D3DVALUE su, D3DVALUE sv, + LPDIRECT3DRMWRAP * + ) PURE; + STDMETHOD(CreateUserVisual) (THIS_ D3DRMUSERVISUALCALLBACK, LPVOID lPArg, LPDIRECT3DRMUSERVISUAL *) PURE; + STDMETHOD(LoadTexture) (THIS_ const char *, LPDIRECT3DRMTEXTURE3 *) PURE; + STDMETHOD(LoadTextureFromResource) (THIS_ HMODULE hModule, LPCTSTR strName, LPCTSTR strType, LPDIRECT3DRMTEXTURE3 *) PURE; + + STDMETHOD(SetSearchPath) (THIS_ LPCSTR) PURE; + STDMETHOD(AddSearchPath) (THIS_ LPCSTR) PURE; + STDMETHOD(GetSearchPath) (THIS_ DWORD *size_return, LPSTR path_return) PURE; + STDMETHOD(SetDefaultTextureColors)(THIS_ DWORD) PURE; + STDMETHOD(SetDefaultTextureShades)(THIS_ DWORD) PURE; + + STDMETHOD(GetDevices) (THIS_ LPDIRECT3DRMDEVICEARRAY *) PURE; + STDMETHOD(GetNamedObject) (THIS_ const char *, LPDIRECT3DRMOBJECT *) PURE; + + STDMETHOD(EnumerateObjects) (THIS_ D3DRMOBJECTCALLBACK, LPVOID) PURE; + + STDMETHOD(Load) + ( THIS_ LPVOID, LPVOID, LPIID *, DWORD, D3DRMLOADOPTIONS, + D3DRMLOADCALLBACK, LPVOID, D3DRMLOADTEXTURE3CALLBACK, LPVOID, + LPDIRECT3DRMFRAME3 + ) PURE; + STDMETHOD(Tick) (THIS_ D3DVALUE) PURE; + + STDMETHOD(CreateProgressiveMesh)(THIS_ LPDIRECT3DRMPROGRESSIVEMESH *) PURE; + + /* Used with IDirect3DRMObject2 */ + STDMETHOD(RegisterClient) (THIS_ REFGUID rguid, LPDWORD lpdwID) PURE; + STDMETHOD(UnregisterClient) (THIS_ REFGUID rguid) PURE; + + STDMETHOD(CreateClippedVisual) (THIS_ LPDIRECT3DRMVISUAL, LPDIRECT3DRMCLIPPEDVISUAL *) PURE; + STDMETHOD(SetOptions) (THIS_ DWORD); + STDMETHOD(GetOptions) (THIS_ LPDWORD); +}; + +#define D3DRM_OK DD_OK +#define D3DRMERR_BADOBJECT MAKE_DDHRESULT(781) +#define D3DRMERR_BADTYPE MAKE_DDHRESULT(782) +#define D3DRMERR_BADALLOC MAKE_DDHRESULT(783) +#define D3DRMERR_FACEUSED MAKE_DDHRESULT(784) +#define D3DRMERR_NOTFOUND MAKE_DDHRESULT(785) +#define D3DRMERR_NOTDONEYET MAKE_DDHRESULT(786) +#define D3DRMERR_FILENOTFOUND MAKE_DDHRESULT(787) +#define D3DRMERR_BADFILE MAKE_DDHRESULT(788) +#define D3DRMERR_BADDEVICE MAKE_DDHRESULT(789) +#define D3DRMERR_BADVALUE MAKE_DDHRESULT(790) +#define D3DRMERR_BADMAJORVERSION MAKE_DDHRESULT(791) +#define D3DRMERR_BADMINORVERSION MAKE_DDHRESULT(792) +#define D3DRMERR_UNABLETOEXECUTE MAKE_DDHRESULT(793) +#define D3DRMERR_LIBRARYNOTFOUND MAKE_DDHRESULT(794) +#define D3DRMERR_INVALIDLIBRARY MAKE_DDHRESULT(795) +#define D3DRMERR_PENDING MAKE_DDHRESULT(796) +#define D3DRMERR_NOTENOUGHDATA MAKE_DDHRESULT(797) +#define D3DRMERR_REQUESTTOOLARGE MAKE_DDHRESULT(798) +#define D3DRMERR_REQUESTTOOSMALL MAKE_DDHRESULT(799) +#define D3DRMERR_CONNECTIONLOST MAKE_DDHRESULT(800) +#define D3DRMERR_LOADABORTED MAKE_DDHRESULT(801) +#define D3DRMERR_NOINTERNET MAKE_DDHRESULT(802) +#define D3DRMERR_BADCACHEFILE MAKE_DDHRESULT(803) +#define D3DRMERR_BOXNOTSET MAKE_DDHRESULT(804) +#define D3DRMERR_BADPMDATA MAKE_DDHRESULT(805) +#define D3DRMERR_CLIENTNOTREGISTERED MAKE_DDHRESULT(806) +#define D3DRMERR_NOTCREATEDFROMDDS MAKE_DDHRESULT(807) +#define D3DRMERR_NOSUCHKEY MAKE_DDHRESULT(808) +#define D3DRMERR_INCOMPATABLEKEY MAKE_DDHRESULT(809) +#define D3DRMERR_ELEMENTINUSE MAKE_DDHRESULT(810) +#define D3DRMERR_TEXTUREFORMATNOTFOUND MAKE_DDHRESULT(811) +#define D3DRMERR_NOTAGGREGATED MAKE_DDHRESULT(812) + +#ifdef __cplusplus +}; +#endif + +#endif /* _D3DRMAPI_H_ */ + + diff --git a/src/dep/include/DXSDK/include/d3drmdef.h b/src/dep/include/DXSDK/include/d3drmdef.h index c6477ca..9da4b18 100644 --- a/src/dep/include/DXSDK/include/d3drmdef.h +++ b/src/dep/include/DXSDK/include/d3drmdef.h @@ -1,695 +1,695 @@ -/*==========================================================================; - * - * Copyright (c) Microsoft Corporation. All rights reserved. - * - * File: d3drm.h - * Content: Direct3DRM include file - * - ***************************************************************************/ - -#ifndef __D3DRMDEFS_H__ -#define __D3DRMDEFS_H__ - -#include -#include "d3dtypes.h" - -#ifdef WIN32 -#define D3DRMAPI __stdcall -#else -#define D3DRMAPI -#endif - -#if defined(__cplusplus) -extern "C" { -#endif - -#ifndef TRUE -#define FALSE 0 -#define TRUE 1 -#endif - -typedef struct _D3DRMVECTOR4D -{ D3DVALUE x, y, z, w; -} D3DRMVECTOR4D, *LPD3DRMVECTOR4D; - -typedef D3DVALUE D3DRMMATRIX4D[4][4]; - -typedef struct _D3DRMQUATERNION -{ D3DVALUE s; - D3DVECTOR v; -} D3DRMQUATERNION, *LPD3DRMQUATERNION; - -typedef struct _D3DRMRAY -{ D3DVECTOR dvDir; - D3DVECTOR dvPos; -} D3DRMRAY, *LPD3DRMRAY; - -typedef struct _D3DRMBOX -{ D3DVECTOR min, max; -} D3DRMBOX, *LPD3DRMBOX; - -typedef void (*D3DRMWRAPCALLBACK) - (LPD3DVECTOR, int* u, int* v, LPD3DVECTOR a, LPD3DVECTOR b, LPVOID); - -typedef enum _D3DRMLIGHTTYPE -{ D3DRMLIGHT_AMBIENT, - D3DRMLIGHT_POINT, - D3DRMLIGHT_SPOT, - D3DRMLIGHT_DIRECTIONAL, - D3DRMLIGHT_PARALLELPOINT -} D3DRMLIGHTTYPE, *LPD3DRMLIGHTTYPE; - -typedef enum _D3DRMSHADEMODE { - D3DRMSHADE_FLAT = 0, - D3DRMSHADE_GOURAUD = 1, - D3DRMSHADE_PHONG = 2, - - D3DRMSHADE_MASK = 7, - D3DRMSHADE_MAX = 8 -} D3DRMSHADEMODE, *LPD3DRMSHADEMODE; - -typedef enum _D3DRMLIGHTMODE { - D3DRMLIGHT_OFF = 0 * D3DRMSHADE_MAX, - D3DRMLIGHT_ON = 1 * D3DRMSHADE_MAX, - - D3DRMLIGHT_MASK = 7 * D3DRMSHADE_MAX, - D3DRMLIGHT_MAX = 8 * D3DRMSHADE_MAX -} D3DRMLIGHTMODE, *LPD3DRMLIGHTMODE; - -typedef enum _D3DRMFILLMODE { - D3DRMFILL_POINTS = 0 * D3DRMLIGHT_MAX, - D3DRMFILL_WIREFRAME = 1 * D3DRMLIGHT_MAX, - D3DRMFILL_SOLID = 2 * D3DRMLIGHT_MAX, - - D3DRMFILL_MASK = 7 * D3DRMLIGHT_MAX, - D3DRMFILL_MAX = 8 * D3DRMLIGHT_MAX -} D3DRMFILLMODE, *LPD3DRMFILLMODE; - -typedef DWORD D3DRMRENDERQUALITY, *LPD3DRMRENDERQUALITY; - -#define D3DRMRENDER_WIREFRAME (D3DRMSHADE_FLAT+D3DRMLIGHT_OFF+D3DRMFILL_WIREFRAME) -#define D3DRMRENDER_UNLITFLAT (D3DRMSHADE_FLAT+D3DRMLIGHT_OFF+D3DRMFILL_SOLID) -#define D3DRMRENDER_FLAT (D3DRMSHADE_FLAT+D3DRMLIGHT_ON+D3DRMFILL_SOLID) -#define D3DRMRENDER_GOURAUD (D3DRMSHADE_GOURAUD+D3DRMLIGHT_ON+D3DRMFILL_SOLID) -#define D3DRMRENDER_PHONG (D3DRMSHADE_PHONG+D3DRMLIGHT_ON+D3DRMFILL_SOLID) - -#define D3DRMRENDERMODE_BLENDEDTRANSPARENCY 1 -#define D3DRMRENDERMODE_SORTEDTRANSPARENCY 2 -#define D3DRMRENDERMODE_LIGHTINMODELSPACE 8 -#define D3DRMRENDERMODE_VIEWDEPENDENTSPECULAR 16 -#define D3DRMRENDERMODE_DISABLESORTEDALPHAZWRITE 32 - -typedef enum _D3DRMTEXTUREQUALITY -{ D3DRMTEXTURE_NEAREST, /* choose nearest texel */ - D3DRMTEXTURE_LINEAR, /* interpolate 4 texels */ - D3DRMTEXTURE_MIPNEAREST, /* nearest texel in nearest mipmap */ - D3DRMTEXTURE_MIPLINEAR, /* interpolate 2 texels from 2 mipmaps */ - D3DRMTEXTURE_LINEARMIPNEAREST, /* interpolate 4 texels in nearest mipmap */ - D3DRMTEXTURE_LINEARMIPLINEAR /* interpolate 8 texels from 2 mipmaps */ -} D3DRMTEXTUREQUALITY, *LPD3DRMTEXTUREQUALITY; - -/* - * Texture flags - */ -#define D3DRMTEXTURE_FORCERESIDENT 0x00000001 /* texture should be kept in video memory */ -#define D3DRMTEXTURE_STATIC 0x00000002 /* texture will not change */ -#define D3DRMTEXTURE_DOWNSAMPLEPOINT 0x00000004 /* point filtering should be used when downsampling */ -#define D3DRMTEXTURE_DOWNSAMPLEBILINEAR 0x00000008 /* bilinear filtering should be used when downsampling */ -#define D3DRMTEXTURE_DOWNSAMPLEREDUCEDEPTH 0x00000010 /* reduce bit depth when downsampling */ -#define D3DRMTEXTURE_DOWNSAMPLENONE 0x00000020 /* texture should never be downsampled */ -#define D3DRMTEXTURE_CHANGEDPIXELS 0x00000040 /* pixels have changed */ -#define D3DRMTEXTURE_CHANGEDPALETTE 0x00000080 /* palette has changed */ -#define D3DRMTEXTURE_INVALIDATEONLY 0x00000100 /* dirty regions are invalid */ - -/* - * Shadow flags - */ -#define D3DRMSHADOW_TRUEALPHA 0x00000001 /* shadow should render without artifacts when true alpha is on */ - -typedef enum _D3DRMCOMBINETYPE -{ D3DRMCOMBINE_REPLACE, - D3DRMCOMBINE_BEFORE, - D3DRMCOMBINE_AFTER -} D3DRMCOMBINETYPE, *LPD3DRMCOMBINETYPE; - -typedef D3DCOLORMODEL D3DRMCOLORMODEL, *LPD3DRMCOLORMODEL; - -typedef enum _D3DRMPALETTEFLAGS -{ D3DRMPALETTE_FREE, /* renderer may use this entry freely */ - D3DRMPALETTE_READONLY, /* fixed but may be used by renderer */ - D3DRMPALETTE_RESERVED /* may not be used by renderer */ -} D3DRMPALETTEFLAGS, *LPD3DRMPALETTEFLAGS; - -typedef struct _D3DRMPALETTEENTRY -{ unsigned char red; /* 0 .. 255 */ - unsigned char green; /* 0 .. 255 */ - unsigned char blue; /* 0 .. 255 */ - unsigned char flags; /* one of D3DRMPALETTEFLAGS */ -} D3DRMPALETTEENTRY, *LPD3DRMPALETTEENTRY; - -typedef struct _D3DRMIMAGE -{ int width, height; /* width and height in pixels */ - int aspectx, aspecty; /* aspect ratio for non-square pixels */ - int depth; /* bits per pixel */ - int rgb; /* if false, pixels are indices into a - palette otherwise, pixels encode - RGB values. */ - int bytes_per_line; /* number of bytes of memory for a - scanline. This must be a multiple - of 4. */ - void* buffer1; /* memory to render into (first buffer). */ - void* buffer2; /* second rendering buffer for double - buffering, set to NULL for single - buffering. */ - unsigned long red_mask; - unsigned long green_mask; - unsigned long blue_mask; - unsigned long alpha_mask; /* if rgb is true, these are masks for - the red, green and blue parts of a - pixel. Otherwise, these are masks - for the significant bits of the - red, green and blue elements in the - palette. For instance, most SVGA - displays use 64 intensities of red, - green and blue, so the masks should - all be set to 0xfc. */ - int palette_size; /* number of entries in palette */ - D3DRMPALETTEENTRY* palette; /* description of the palette (only if - rgb is false). Must be (1< +#include "d3dtypes.h" + +#ifdef WIN32 +#define D3DRMAPI __stdcall +#else +#define D3DRMAPI +#endif + +#if defined(__cplusplus) +extern "C" { +#endif + +#ifndef TRUE +#define FALSE 0 +#define TRUE 1 +#endif + +typedef struct _D3DRMVECTOR4D +{ D3DVALUE x, y, z, w; +} D3DRMVECTOR4D, *LPD3DRMVECTOR4D; + +typedef D3DVALUE D3DRMMATRIX4D[4][4]; + +typedef struct _D3DRMQUATERNION +{ D3DVALUE s; + D3DVECTOR v; +} D3DRMQUATERNION, *LPD3DRMQUATERNION; + +typedef struct _D3DRMRAY +{ D3DVECTOR dvDir; + D3DVECTOR dvPos; +} D3DRMRAY, *LPD3DRMRAY; + +typedef struct _D3DRMBOX +{ D3DVECTOR min, max; +} D3DRMBOX, *LPD3DRMBOX; + +typedef void (*D3DRMWRAPCALLBACK) + (LPD3DVECTOR, int* u, int* v, LPD3DVECTOR a, LPD3DVECTOR b, LPVOID); + +typedef enum _D3DRMLIGHTTYPE +{ D3DRMLIGHT_AMBIENT, + D3DRMLIGHT_POINT, + D3DRMLIGHT_SPOT, + D3DRMLIGHT_DIRECTIONAL, + D3DRMLIGHT_PARALLELPOINT +} D3DRMLIGHTTYPE, *LPD3DRMLIGHTTYPE; + +typedef enum _D3DRMSHADEMODE { + D3DRMSHADE_FLAT = 0, + D3DRMSHADE_GOURAUD = 1, + D3DRMSHADE_PHONG = 2, + + D3DRMSHADE_MASK = 7, + D3DRMSHADE_MAX = 8 +} D3DRMSHADEMODE, *LPD3DRMSHADEMODE; + +typedef enum _D3DRMLIGHTMODE { + D3DRMLIGHT_OFF = 0 * D3DRMSHADE_MAX, + D3DRMLIGHT_ON = 1 * D3DRMSHADE_MAX, + + D3DRMLIGHT_MASK = 7 * D3DRMSHADE_MAX, + D3DRMLIGHT_MAX = 8 * D3DRMSHADE_MAX +} D3DRMLIGHTMODE, *LPD3DRMLIGHTMODE; + +typedef enum _D3DRMFILLMODE { + D3DRMFILL_POINTS = 0 * D3DRMLIGHT_MAX, + D3DRMFILL_WIREFRAME = 1 * D3DRMLIGHT_MAX, + D3DRMFILL_SOLID = 2 * D3DRMLIGHT_MAX, + + D3DRMFILL_MASK = 7 * D3DRMLIGHT_MAX, + D3DRMFILL_MAX = 8 * D3DRMLIGHT_MAX +} D3DRMFILLMODE, *LPD3DRMFILLMODE; + +typedef DWORD D3DRMRENDERQUALITY, *LPD3DRMRENDERQUALITY; + +#define D3DRMRENDER_WIREFRAME (D3DRMSHADE_FLAT+D3DRMLIGHT_OFF+D3DRMFILL_WIREFRAME) +#define D3DRMRENDER_UNLITFLAT (D3DRMSHADE_FLAT+D3DRMLIGHT_OFF+D3DRMFILL_SOLID) +#define D3DRMRENDER_FLAT (D3DRMSHADE_FLAT+D3DRMLIGHT_ON+D3DRMFILL_SOLID) +#define D3DRMRENDER_GOURAUD (D3DRMSHADE_GOURAUD+D3DRMLIGHT_ON+D3DRMFILL_SOLID) +#define D3DRMRENDER_PHONG (D3DRMSHADE_PHONG+D3DRMLIGHT_ON+D3DRMFILL_SOLID) + +#define D3DRMRENDERMODE_BLENDEDTRANSPARENCY 1 +#define D3DRMRENDERMODE_SORTEDTRANSPARENCY 2 +#define D3DRMRENDERMODE_LIGHTINMODELSPACE 8 +#define D3DRMRENDERMODE_VIEWDEPENDENTSPECULAR 16 +#define D3DRMRENDERMODE_DISABLESORTEDALPHAZWRITE 32 + +typedef enum _D3DRMTEXTUREQUALITY +{ D3DRMTEXTURE_NEAREST, /* choose nearest texel */ + D3DRMTEXTURE_LINEAR, /* interpolate 4 texels */ + D3DRMTEXTURE_MIPNEAREST, /* nearest texel in nearest mipmap */ + D3DRMTEXTURE_MIPLINEAR, /* interpolate 2 texels from 2 mipmaps */ + D3DRMTEXTURE_LINEARMIPNEAREST, /* interpolate 4 texels in nearest mipmap */ + D3DRMTEXTURE_LINEARMIPLINEAR /* interpolate 8 texels from 2 mipmaps */ +} D3DRMTEXTUREQUALITY, *LPD3DRMTEXTUREQUALITY; + +/* + * Texture flags + */ +#define D3DRMTEXTURE_FORCERESIDENT 0x00000001 /* texture should be kept in video memory */ +#define D3DRMTEXTURE_STATIC 0x00000002 /* texture will not change */ +#define D3DRMTEXTURE_DOWNSAMPLEPOINT 0x00000004 /* point filtering should be used when downsampling */ +#define D3DRMTEXTURE_DOWNSAMPLEBILINEAR 0x00000008 /* bilinear filtering should be used when downsampling */ +#define D3DRMTEXTURE_DOWNSAMPLEREDUCEDEPTH 0x00000010 /* reduce bit depth when downsampling */ +#define D3DRMTEXTURE_DOWNSAMPLENONE 0x00000020 /* texture should never be downsampled */ +#define D3DRMTEXTURE_CHANGEDPIXELS 0x00000040 /* pixels have changed */ +#define D3DRMTEXTURE_CHANGEDPALETTE 0x00000080 /* palette has changed */ +#define D3DRMTEXTURE_INVALIDATEONLY 0x00000100 /* dirty regions are invalid */ + +/* + * Shadow flags + */ +#define D3DRMSHADOW_TRUEALPHA 0x00000001 /* shadow should render without artifacts when true alpha is on */ + +typedef enum _D3DRMCOMBINETYPE +{ D3DRMCOMBINE_REPLACE, + D3DRMCOMBINE_BEFORE, + D3DRMCOMBINE_AFTER +} D3DRMCOMBINETYPE, *LPD3DRMCOMBINETYPE; + +typedef D3DCOLORMODEL D3DRMCOLORMODEL, *LPD3DRMCOLORMODEL; + +typedef enum _D3DRMPALETTEFLAGS +{ D3DRMPALETTE_FREE, /* renderer may use this entry freely */ + D3DRMPALETTE_READONLY, /* fixed but may be used by renderer */ + D3DRMPALETTE_RESERVED /* may not be used by renderer */ +} D3DRMPALETTEFLAGS, *LPD3DRMPALETTEFLAGS; + +typedef struct _D3DRMPALETTEENTRY +{ unsigned char red; /* 0 .. 255 */ + unsigned char green; /* 0 .. 255 */ + unsigned char blue; /* 0 .. 255 */ + unsigned char flags; /* one of D3DRMPALETTEFLAGS */ +} D3DRMPALETTEENTRY, *LPD3DRMPALETTEENTRY; + +typedef struct _D3DRMIMAGE +{ int width, height; /* width and height in pixels */ + int aspectx, aspecty; /* aspect ratio for non-square pixels */ + int depth; /* bits per pixel */ + int rgb; /* if false, pixels are indices into a + palette otherwise, pixels encode + RGB values. */ + int bytes_per_line; /* number of bytes of memory for a + scanline. This must be a multiple + of 4. */ + void* buffer1; /* memory to render into (first buffer). */ + void* buffer2; /* second rendering buffer for double + buffering, set to NULL for single + buffering. */ + unsigned long red_mask; + unsigned long green_mask; + unsigned long blue_mask; + unsigned long alpha_mask; /* if rgb is true, these are masks for + the red, green and blue parts of a + pixel. Otherwise, these are masks + for the significant bits of the + red, green and blue elements in the + palette. For instance, most SVGA + displays use 64 intensities of red, + green and blue, so the masks should + all be set to 0xfc. */ + int palette_size; /* number of entries in palette */ + D3DRMPALETTEENTRY* palette; /* description of the palette (only if + rgb is false). Must be (1< /* Use Windows header files */ -#define VIRTUAL -#include "d3drmdef.h" - -#include "d3d.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * The methods for IUnknown - */ -#define IUNKNOWN_METHODS(kind) \ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) kind; \ - STDMETHOD_(ULONG, AddRef) (THIS) kind; \ - STDMETHOD_(ULONG, Release) (THIS) kind - -/* - * The methods for IDirect3DRMObject - */ -#define IDIRECT3DRMOBJECT_METHODS(kind) \ - STDMETHOD(Clone) (THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) kind; \ - STDMETHOD(AddDestroyCallback) (THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) kind; \ - STDMETHOD(DeleteDestroyCallback) (THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) kind; \ - STDMETHOD(SetAppData) (THIS_ DWORD data) kind; \ - STDMETHOD_(DWORD, GetAppData) (THIS) kind; \ - STDMETHOD(SetName) (THIS_ LPCSTR) kind; \ - STDMETHOD(GetName) (THIS_ LPDWORD lpdwSize, LPSTR lpName) kind; \ - STDMETHOD(GetClassName) (THIS_ LPDWORD lpdwSize, LPSTR lpName) kind - - -#define WIN_TYPES(itype, ptype) \ - typedef interface itype FAR *LP##ptype, FAR **LPLP##ptype - -WIN_TYPES(IDirect3DRMObject, DIRECT3DRMOBJECT); -WIN_TYPES(IDirect3DRMObject2, DIRECT3DRMOBJECT2); -WIN_TYPES(IDirect3DRMDevice, DIRECT3DRMDEVICE); -WIN_TYPES(IDirect3DRMDevice2, DIRECT3DRMDEVICE2); -WIN_TYPES(IDirect3DRMDevice3, DIRECT3DRMDEVICE3); -WIN_TYPES(IDirect3DRMViewport, DIRECT3DRMVIEWPORT); -WIN_TYPES(IDirect3DRMViewport2, DIRECT3DRMVIEWPORT2); -WIN_TYPES(IDirect3DRMFrame, DIRECT3DRMFRAME); -WIN_TYPES(IDirect3DRMFrame2, DIRECT3DRMFRAME2); -WIN_TYPES(IDirect3DRMFrame3, DIRECT3DRMFRAME3); -WIN_TYPES(IDirect3DRMVisual, DIRECT3DRMVISUAL); -WIN_TYPES(IDirect3DRMMesh, DIRECT3DRMMESH); -WIN_TYPES(IDirect3DRMMeshBuilder, DIRECT3DRMMESHBUILDER); -WIN_TYPES(IDirect3DRMMeshBuilder2, DIRECT3DRMMESHBUILDER2); -WIN_TYPES(IDirect3DRMMeshBuilder3, DIRECT3DRMMESHBUILDER3); -WIN_TYPES(IDirect3DRMFace, DIRECT3DRMFACE); -WIN_TYPES(IDirect3DRMFace2, DIRECT3DRMFACE2); -WIN_TYPES(IDirect3DRMLight, DIRECT3DRMLIGHT); -WIN_TYPES(IDirect3DRMTexture, DIRECT3DRMTEXTURE); -WIN_TYPES(IDirect3DRMTexture2, DIRECT3DRMTEXTURE2); -WIN_TYPES(IDirect3DRMTexture3, DIRECT3DRMTEXTURE3); -WIN_TYPES(IDirect3DRMWrap, DIRECT3DRMWRAP); -WIN_TYPES(IDirect3DRMMaterial, DIRECT3DRMMATERIAL); -WIN_TYPES(IDirect3DRMMaterial2, DIRECT3DRMMATERIAL2); -WIN_TYPES(IDirect3DRMInterpolator, DIRECT3DRMINTERPOLATOR); -WIN_TYPES(IDirect3DRMAnimation, DIRECT3DRMANIMATION); -WIN_TYPES(IDirect3DRMAnimation2, DIRECT3DRMANIMATION2); -WIN_TYPES(IDirect3DRMAnimationSet, DIRECT3DRMANIMATIONSET); -WIN_TYPES(IDirect3DRMAnimationSet2, DIRECT3DRMANIMATIONSET2); -WIN_TYPES(IDirect3DRMUserVisual, DIRECT3DRMUSERVISUAL); -WIN_TYPES(IDirect3DRMShadow, DIRECT3DRMSHADOW); -WIN_TYPES(IDirect3DRMShadow2, DIRECT3DRMSHADOW2); -WIN_TYPES(IDirect3DRMArray, DIRECT3DRMARRAY); -WIN_TYPES(IDirect3DRMObjectArray, DIRECT3DRMOBJECTARRAY); -WIN_TYPES(IDirect3DRMDeviceArray, DIRECT3DRMDEVICEARRAY); -WIN_TYPES(IDirect3DRMFaceArray, DIRECT3DRMFACEARRAY); -WIN_TYPES(IDirect3DRMViewportArray, DIRECT3DRMVIEWPORTARRAY); -WIN_TYPES(IDirect3DRMFrameArray, DIRECT3DRMFRAMEARRAY); -WIN_TYPES(IDirect3DRMAnimationArray, DIRECT3DRMANIMATIONARRAY); -WIN_TYPES(IDirect3DRMVisualArray, DIRECT3DRMVISUALARRAY); -WIN_TYPES(IDirect3DRMPickedArray, DIRECT3DRMPICKEDARRAY); -WIN_TYPES(IDirect3DRMPicked2Array, DIRECT3DRMPICKED2ARRAY); -WIN_TYPES(IDirect3DRMLightArray, DIRECT3DRMLIGHTARRAY); -WIN_TYPES(IDirect3DRMProgressiveMesh, DIRECT3DRMPROGRESSIVEMESH); -WIN_TYPES(IDirect3DRMClippedVisual, DIRECT3DRMCLIPPEDVISUAL); - -/* - * Direct3DRM Object classes - */ -DEFINE_GUID(CLSID_CDirect3DRMDevice, 0x4fa3568e, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(CLSID_CDirect3DRMViewport, 0x4fa3568f, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(CLSID_CDirect3DRMFrame, 0x4fa35690, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(CLSID_CDirect3DRMMesh, 0x4fa35691, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(CLSID_CDirect3DRMMeshBuilder, 0x4fa35692, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(CLSID_CDirect3DRMFace, 0x4fa35693, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(CLSID_CDirect3DRMLight, 0x4fa35694, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(CLSID_CDirect3DRMTexture, 0x4fa35695, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(CLSID_CDirect3DRMWrap, 0x4fa35696, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(CLSID_CDirect3DRMMaterial, 0x4fa35697, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(CLSID_CDirect3DRMAnimation, 0x4fa35698, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(CLSID_CDirect3DRMAnimationSet, 0x4fa35699, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(CLSID_CDirect3DRMUserVisual, 0x4fa3569a, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(CLSID_CDirect3DRMShadow, 0x4fa3569b, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(CLSID_CDirect3DRMViewportInterpolator, -0xde9eaa1, 0x3b84, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(CLSID_CDirect3DRMFrameInterpolator, -0xde9eaa2, 0x3b84, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(CLSID_CDirect3DRMMeshInterpolator, -0xde9eaa3, 0x3b84, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(CLSID_CDirect3DRMLightInterpolator, -0xde9eaa6, 0x3b84, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(CLSID_CDirect3DRMMaterialInterpolator, -0xde9eaa7, 0x3b84, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(CLSID_CDirect3DRMTextureInterpolator, -0xde9eaa8, 0x3b84, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(CLSID_CDirect3DRMProgressiveMesh, 0x4516ec40, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(CLSID_CDirect3DRMClippedVisual, 0x5434e72d, 0x6d66, 0x11d1, 0xbb, 0xb, 0x0, 0x0, 0xf8, 0x75, 0x86, 0x5a); - - -/* - * Direct3DRM Object interfaces - */ -DEFINE_GUID(IID_IDirect3DRMObject, 0xeb16cb00, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMObject2, 0x4516ec7c, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(IID_IDirect3DRMDevice, 0xe9e19280, 0x6e05, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMDevice2, 0x4516ec78, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(IID_IDirect3DRMDevice3, 0x549f498b, 0xbfeb, 0x11d1, 0x8e, 0xd8, 0x0, 0xa0, 0xc9, 0x67, 0xa4, 0x82); -DEFINE_GUID(IID_IDirect3DRMViewport, 0xeb16cb02, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMViewport2, 0x4a1b1be6, 0xbfed, 0x11d1, 0x8e, 0xd8, 0x0, 0xa0, 0xc9, 0x67, 0xa4, 0x82); -DEFINE_GUID(IID_IDirect3DRMFrame, 0xeb16cb03, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMFrame2, 0xc3dfbd60, 0x3988, 0x11d0, 0x9e, 0xc2, 0x0, 0x0, 0xc0, 0x29, 0x1a, 0xc3); -DEFINE_GUID(IID_IDirect3DRMFrame3, 0xff6b7f70, 0xa40e, 0x11d1, 0x91, 0xf9, 0x0, 0x0, 0xf8, 0x75, 0x8e, 0x66); -DEFINE_GUID(IID_IDirect3DRMVisual, 0xeb16cb04, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMMesh, 0xa3a80d01, 0x6e12, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMMeshBuilder, 0xa3a80d02, 0x6e12, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMMeshBuilder2, 0x4516ec77, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(IID_IDirect3DRMMeshBuilder3, 0x4516ec82, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(IID_IDirect3DRMFace, 0xeb16cb07, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMFace2, 0x4516ec81, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(IID_IDirect3DRMLight, 0xeb16cb08, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMTexture, 0xeb16cb09, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMTexture2, 0x120f30c0, 0x1629, 0x11d0, 0x94, 0x1c, 0x0, 0x80, 0xc8, 0xc, 0xfa, 0x7b); -DEFINE_GUID(IID_IDirect3DRMTexture3, 0xff6b7f73, 0xa40e, 0x11d1, 0x91, 0xf9, 0x0, 0x0, 0xf8, 0x75, 0x8e, 0x66); -DEFINE_GUID(IID_IDirect3DRMWrap, 0xeb16cb0a, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMMaterial, 0xeb16cb0b, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMMaterial2, 0xff6b7f75, 0xa40e, 0x11d1, 0x91, 0xf9, 0x0, 0x0, 0xf8, 0x75, 0x8e, 0x66); -DEFINE_GUID(IID_IDirect3DRMAnimation, 0xeb16cb0d, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMAnimation2, 0xff6b7f77, 0xa40e, 0x11d1, 0x91, 0xf9, 0x0, 0x0, 0xf8, 0x75, 0x8e, 0x66); -DEFINE_GUID(IID_IDirect3DRMAnimationSet, 0xeb16cb0e, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMAnimationSet2, 0xff6b7f79, 0xa40e, 0x11d1, 0x91, 0xf9, 0x0, 0x0, 0xf8, 0x75, 0x8e, 0x66); -DEFINE_GUID(IID_IDirect3DRMObjectArray, 0x242f6bc2, 0x3849, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(IID_IDirect3DRMDeviceArray, 0xeb16cb10, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMViewportArray, 0xeb16cb11, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMFrameArray, 0xeb16cb12, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMVisualArray, 0xeb16cb13, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMLightArray, 0xeb16cb14, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMPickedArray, 0xeb16cb16, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMFaceArray, 0xeb16cb17, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMAnimationArray, -0xd5f1cae0, 0x4bd7, 0x11d1, 0xb9, 0x74, 0x0, 0x60, 0x8, 0x3e, 0x45, 0xf3); -DEFINE_GUID(IID_IDirect3DRMUserVisual, 0x59163de0, 0x6d43, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMShadow, 0xaf359780, 0x6ba3, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); -DEFINE_GUID(IID_IDirect3DRMShadow2, 0x86b44e25, 0x9c82, 0x11d1, 0xbb, 0xb, 0x0, 0xa0, 0xc9, 0x81, 0xa0, 0xa6); -DEFINE_GUID(IID_IDirect3DRMInterpolator, 0x242f6bc1, 0x3849, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(IID_IDirect3DRMProgressiveMesh, 0x4516ec79, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(IID_IDirect3DRMPicked2Array, 0x4516ec7b, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(IID_IDirect3DRMClippedVisual, 0x5434e733, 0x6d66, 0x11d1, 0xbb, 0xb, 0x0, 0x0, 0xf8, 0x75, 0x86, 0x5a); - -typedef void (__cdecl *D3DRMOBJECTCALLBACK)(LPDIRECT3DRMOBJECT obj, LPVOID arg); -typedef void (__cdecl *D3DRMFRAMEMOVECALLBACK)(LPDIRECT3DRMFRAME obj, LPVOID arg, D3DVALUE delta); -typedef void (__cdecl *D3DRMFRAME3MOVECALLBACK)(LPDIRECT3DRMFRAME3 obj, LPVOID arg, D3DVALUE delta); -typedef void (__cdecl *D3DRMUPDATECALLBACK)(LPDIRECT3DRMDEVICE obj, LPVOID arg, int, LPD3DRECT); -typedef void (__cdecl *D3DRMDEVICE3UPDATECALLBACK)(LPDIRECT3DRMDEVICE3 obj, LPVOID arg, int, LPD3DRECT); -typedef int (__cdecl *D3DRMUSERVISUALCALLBACK) - ( LPDIRECT3DRMUSERVISUAL obj, LPVOID arg, D3DRMUSERVISUALREASON reason, - LPDIRECT3DRMDEVICE dev, LPDIRECT3DRMVIEWPORT view - ); -typedef HRESULT (__cdecl *D3DRMLOADTEXTURECALLBACK) - (char *tex_name, void *arg, LPDIRECT3DRMTEXTURE *); -typedef HRESULT (__cdecl *D3DRMLOADTEXTURE3CALLBACK) - (char *tex_name, void *arg, LPDIRECT3DRMTEXTURE3 *); -typedef void (__cdecl *D3DRMLOADCALLBACK) - (LPDIRECT3DRMOBJECT object, REFIID objectguid, LPVOID arg); - -typedef HRESULT (__cdecl *D3DRMDOWNSAMPLECALLBACK) - (LPDIRECT3DRMTEXTURE3 lpDirect3DRMTexture, LPVOID pArg, - LPDIRECTDRAWSURFACE pDDSSrc, LPDIRECTDRAWSURFACE pDDSDst); -typedef HRESULT (__cdecl *D3DRMVALIDATIONCALLBACK) - (LPDIRECT3DRMTEXTURE3 lpDirect3DRMTexture, LPVOID pArg, - DWORD dwFlags, DWORD dwcRects, LPRECT pRects); - - -typedef struct _D3DRMPICKDESC -{ - ULONG ulFaceIdx; - LONG lGroupIdx; - D3DVECTOR vPosition; - -} D3DRMPICKDESC, *LPD3DRMPICKDESC; - -typedef struct _D3DRMPICKDESC2 -{ - ULONG ulFaceIdx; - LONG lGroupIdx; - D3DVECTOR dvPosition; - D3DVALUE tu; - D3DVALUE tv; - D3DVECTOR dvNormal; - D3DCOLOR dcColor; - -} D3DRMPICKDESC2, *LPD3DRMPICKDESC2; - -#undef INTERFACE -#define INTERFACE IDirect3DRMObject - -/* - * Base class - */ -DECLARE_INTERFACE_(IDirect3DRMObject, IUnknown) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMObject2 - -DECLARE_INTERFACE_(IDirect3DRMObject2, IUnknown) -{ - IUNKNOWN_METHODS(PURE); - - /* - * IDirect3DRMObject2 methods - */ - STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK lpFunc, LPVOID pvArg) PURE; - STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE; \ - STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK lpFunc, LPVOID pvArg) PURE; \ - STDMETHOD(GetClientData)(THIS_ DWORD dwID, LPVOID* lplpvData) PURE; - STDMETHOD(GetDirect3DRM)(THIS_ LPDIRECT3DRM* lplpDirect3DRM) PURE; - STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE; - STDMETHOD(SetClientData)(THIS_ DWORD dwID, LPVOID lpvData, DWORD dwFlags) PURE; - STDMETHOD(SetName)(THIS_ LPCSTR lpName) PURE; - STDMETHOD(GetAge)(THIS_ DWORD dwFlags, LPDWORD pdwAge) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMVisual - -DECLARE_INTERFACE_(IDirect3DRMVisual, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMDevice - -DECLARE_INTERFACE_(IDirect3DRMDevice, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMDevice methods - */ - STDMETHOD(Init)(THIS_ ULONG width, ULONG height) PURE; - STDMETHOD(InitFromD3D)(THIS_ LPDIRECT3D lpD3D, LPDIRECT3DDEVICE lpD3DDev) PURE; - STDMETHOD(InitFromClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper, LPGUID lpGUID, int width, int height) PURE; - - STDMETHOD(Update)(THIS) PURE; - STDMETHOD(AddUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE; - STDMETHOD(DeleteUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE; - STDMETHOD(SetBufferCount)(THIS_ DWORD) PURE; - STDMETHOD_(DWORD, GetBufferCount)(THIS) PURE; - - STDMETHOD(SetDither)(THIS_ BOOL) PURE; - STDMETHOD(SetShades)(THIS_ DWORD) PURE; - STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE; - STDMETHOD(SetTextureQuality)(THIS_ D3DRMTEXTUREQUALITY) PURE; - - STDMETHOD(GetViewports)(THIS_ LPDIRECT3DRMVIEWPORTARRAY *return_views) PURE; - - STDMETHOD_(BOOL, GetDither)(THIS) PURE; - STDMETHOD_(DWORD, GetShades)(THIS) PURE; - STDMETHOD_(DWORD, GetHeight)(THIS) PURE; - STDMETHOD_(DWORD, GetWidth)(THIS) PURE; - STDMETHOD_(DWORD, GetTrianglesDrawn)(THIS) PURE; - STDMETHOD_(DWORD, GetWireframeOptions)(THIS) PURE; - STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE; - STDMETHOD_(D3DCOLORMODEL, GetColorModel)(THIS) PURE; - STDMETHOD_(D3DRMTEXTUREQUALITY, GetTextureQuality)(THIS) PURE; - STDMETHOD(GetDirect3DDevice)(THIS_ LPDIRECT3DDEVICE *) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMDevice2 - -DECLARE_INTERFACE_(IDirect3DRMDevice2, IDirect3DRMDevice) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMDevice methods - */ - STDMETHOD(Init)(THIS_ ULONG width, ULONG height) PURE; - STDMETHOD(InitFromD3D)(THIS_ LPDIRECT3D lpD3D, LPDIRECT3DDEVICE lpD3DDev) PURE; - STDMETHOD(InitFromClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper, LPGUID lpGUID, int width, int height) PURE; - - STDMETHOD(Update)(THIS) PURE; - STDMETHOD(AddUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE; - STDMETHOD(DeleteUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE; - STDMETHOD(SetBufferCount)(THIS_ DWORD) PURE; - STDMETHOD_(DWORD, GetBufferCount)(THIS) PURE; - - STDMETHOD(SetDither)(THIS_ BOOL) PURE; - STDMETHOD(SetShades)(THIS_ DWORD) PURE; - STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE; - STDMETHOD(SetTextureQuality)(THIS_ D3DRMTEXTUREQUALITY) PURE; - - STDMETHOD(GetViewports)(THIS_ LPDIRECT3DRMVIEWPORTARRAY *return_views) PURE; - - STDMETHOD_(BOOL, GetDither)(THIS) PURE; - STDMETHOD_(DWORD, GetShades)(THIS) PURE; - STDMETHOD_(DWORD, GetHeight)(THIS) PURE; - STDMETHOD_(DWORD, GetWidth)(THIS) PURE; - STDMETHOD_(DWORD, GetTrianglesDrawn)(THIS) PURE; - STDMETHOD_(DWORD, GetWireframeOptions)(THIS) PURE; - STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE; - STDMETHOD_(D3DCOLORMODEL, GetColorModel)(THIS) PURE; - STDMETHOD_(D3DRMTEXTUREQUALITY, GetTextureQuality)(THIS) PURE; - STDMETHOD(GetDirect3DDevice)(THIS_ LPDIRECT3DDEVICE *) PURE; - - /* - * IDirect3DRMDevice2 methods - */ - STDMETHOD(InitFromD3D2)(THIS_ LPDIRECT3D2 lpD3D, LPDIRECT3DDEVICE2 lpD3DDev) PURE; - STDMETHOD(InitFromSurface)(THIS_ LPGUID lpGUID, LPDIRECTDRAW lpDD, LPDIRECTDRAWSURFACE lpDDSBack) PURE; - STDMETHOD(SetRenderMode)(THIS_ DWORD dwFlags) PURE; - STDMETHOD_(DWORD, GetRenderMode)(THIS) PURE; - STDMETHOD(GetDirect3DDevice2)(THIS_ LPDIRECT3DDEVICE2 *) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMDevice3 - -DECLARE_INTERFACE_(IDirect3DRMDevice3, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMDevice methods - */ - STDMETHOD(Init)(THIS_ ULONG width, ULONG height) PURE; - STDMETHOD(InitFromD3D)(THIS_ LPDIRECT3D lpD3D, LPDIRECT3DDEVICE lpD3DDev) PURE; - STDMETHOD(InitFromClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper, LPGUID lpGUID, int width, int height) PURE; - - STDMETHOD(Update)(THIS) PURE; - STDMETHOD(AddUpdateCallback)(THIS_ D3DRMDEVICE3UPDATECALLBACK, LPVOID arg) PURE; - STDMETHOD(DeleteUpdateCallback)(THIS_ D3DRMDEVICE3UPDATECALLBACK, LPVOID arg) PURE; - STDMETHOD(SetBufferCount)(THIS_ DWORD) PURE; - STDMETHOD_(DWORD, GetBufferCount)(THIS) PURE; - - STDMETHOD(SetDither)(THIS_ BOOL) PURE; - STDMETHOD(SetShades)(THIS_ DWORD) PURE; - STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE; - STDMETHOD(SetTextureQuality)(THIS_ D3DRMTEXTUREQUALITY) PURE; - - STDMETHOD(GetViewports)(THIS_ LPDIRECT3DRMVIEWPORTARRAY *return_views) PURE; - - STDMETHOD_(BOOL, GetDither)(THIS) PURE; - STDMETHOD_(DWORD, GetShades)(THIS) PURE; - STDMETHOD_(DWORD, GetHeight)(THIS) PURE; - STDMETHOD_(DWORD, GetWidth)(THIS) PURE; - STDMETHOD_(DWORD, GetTrianglesDrawn)(THIS) PURE; - STDMETHOD_(DWORD, GetWireframeOptions)(THIS) PURE; - STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE; - STDMETHOD_(D3DCOLORMODEL, GetColorModel)(THIS) PURE; - STDMETHOD_(D3DRMTEXTUREQUALITY, GetTextureQuality)(THIS) PURE; - STDMETHOD(GetDirect3DDevice)(THIS_ LPDIRECT3DDEVICE *) PURE; - - /* - * IDirect3DRMDevice2 methods - */ - STDMETHOD(InitFromD3D2)(THIS_ LPDIRECT3D2 lpD3D, LPDIRECT3DDEVICE2 lpD3DDev) PURE; - STDMETHOD(InitFromSurface)(THIS_ LPGUID lpGUID, LPDIRECTDRAW lpDD, LPDIRECTDRAWSURFACE lpDDSBack, DWORD dwFlags) PURE; - STDMETHOD(SetRenderMode)(THIS_ DWORD dwFlags) PURE; - STDMETHOD_(DWORD, GetRenderMode)(THIS) PURE; - STDMETHOD(GetDirect3DDevice2)(THIS_ LPDIRECT3DDEVICE2 *) PURE; - - /* - * IDirect3DRMDevice3 methods - */ - STDMETHOD(FindPreferredTextureFormat)(THIS_ DWORD dwBitDepths, DWORD dwFlags, LPDDPIXELFORMAT lpDDPF) PURE; - STDMETHOD(RenderStateChange)(THIS_ D3DRENDERSTATETYPE drsType, DWORD dwVal, DWORD dwFlags) PURE; - STDMETHOD(LightStateChange)(THIS_ D3DLIGHTSTATETYPE drsType, DWORD dwVal, DWORD dwFlags) PURE; - STDMETHOD(GetStateChangeOptions)(THIS_ DWORD dwStateClass, DWORD dwStateNum, LPDWORD pdwFlags) PURE; - STDMETHOD(SetStateChangeOptions)(THIS_ DWORD dwStateClass, DWORD dwStateNum, DWORD dwFlags) PURE; -}; - - -#undef INTERFACE -#define INTERFACE IDirect3DRMViewport - -DECLARE_INTERFACE_(IDirect3DRMViewport, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMViewport methods - */ - STDMETHOD(Init) - ( THIS_ LPDIRECT3DRMDEVICE dev, LPDIRECT3DRMFRAME camera, - DWORD xpos, DWORD ypos, DWORD width, DWORD height - ) PURE; - STDMETHOD(Clear)(THIS) PURE; - STDMETHOD(Render)(THIS_ LPDIRECT3DRMFRAME) PURE; - - STDMETHOD(SetFront)(THIS_ D3DVALUE) PURE; - STDMETHOD(SetBack)(THIS_ D3DVALUE) PURE; - STDMETHOD(SetField)(THIS_ D3DVALUE) PURE; - STDMETHOD(SetUniformScaling)(THIS_ BOOL) PURE; - STDMETHOD(SetCamera)(THIS_ LPDIRECT3DRMFRAME) PURE; - STDMETHOD(SetProjection)(THIS_ D3DRMPROJECTIONTYPE) PURE; - STDMETHOD(Transform)(THIS_ D3DRMVECTOR4D *d, D3DVECTOR *s) PURE; - STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DRMVECTOR4D *s) PURE; - STDMETHOD(Configure)(THIS_ LONG x, LONG y, DWORD width, DWORD height) PURE; - STDMETHOD(ForceUpdate)(THIS_ DWORD x1, DWORD y1, DWORD x2, DWORD y2) PURE; - STDMETHOD(SetPlane)(THIS_ D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top) PURE; - - STDMETHOD(GetCamera)(THIS_ LPDIRECT3DRMFRAME *) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DRMDEVICE *) PURE; - STDMETHOD(GetPlane)(THIS_ D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top) PURE; - STDMETHOD(Pick)(THIS_ LONG x, LONG y, LPDIRECT3DRMPICKEDARRAY *return_visuals) PURE; - - STDMETHOD_(BOOL, GetUniformScaling)(THIS) PURE; - STDMETHOD_(LONG, GetX)(THIS) PURE; - STDMETHOD_(LONG, GetY)(THIS) PURE; - STDMETHOD_(DWORD, GetWidth)(THIS) PURE; - STDMETHOD_(DWORD, GetHeight)(THIS) PURE; - STDMETHOD_(D3DVALUE, GetField)(THIS) PURE; - STDMETHOD_(D3DVALUE, GetBack)(THIS) PURE; - STDMETHOD_(D3DVALUE, GetFront)(THIS) PURE; - STDMETHOD_(D3DRMPROJECTIONTYPE, GetProjection)(THIS) PURE; - STDMETHOD(GetDirect3DViewport)(THIS_ LPDIRECT3DVIEWPORT *) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMViewport2 -DECLARE_INTERFACE_(IDirect3DRMViewport2, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMViewport2 methods - */ - STDMETHOD(Init) - ( THIS_ LPDIRECT3DRMDEVICE3 dev, LPDIRECT3DRMFRAME3 camera, - DWORD xpos, DWORD ypos, DWORD width, DWORD height - ) PURE; - STDMETHOD(Clear)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(Render)(THIS_ LPDIRECT3DRMFRAME3) PURE; - - STDMETHOD(SetFront)(THIS_ D3DVALUE) PURE; - STDMETHOD(SetBack)(THIS_ D3DVALUE) PURE; - STDMETHOD(SetField)(THIS_ D3DVALUE) PURE; - STDMETHOD(SetUniformScaling)(THIS_ BOOL) PURE; - STDMETHOD(SetCamera)(THIS_ LPDIRECT3DRMFRAME3) PURE; - STDMETHOD(SetProjection)(THIS_ D3DRMPROJECTIONTYPE) PURE; - STDMETHOD(Transform)(THIS_ D3DRMVECTOR4D *d, D3DVECTOR *s) PURE; - STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DRMVECTOR4D *s) PURE; - STDMETHOD(Configure)(THIS_ LONG x, LONG y, DWORD width, DWORD height) PURE; - STDMETHOD(ForceUpdate)(THIS_ DWORD x1, DWORD y1, DWORD x2, DWORD y2) PURE; - STDMETHOD(SetPlane)(THIS_ D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top) PURE; - - STDMETHOD(GetCamera)(THIS_ LPDIRECT3DRMFRAME3 *) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DRMDEVICE3 *) PURE; - STDMETHOD(GetPlane)(THIS_ D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top) PURE; - STDMETHOD(Pick)(THIS_ LONG x, LONG y, LPDIRECT3DRMPICKEDARRAY *return_visuals) PURE; - - STDMETHOD_(BOOL, GetUniformScaling)(THIS) PURE; - STDMETHOD_(LONG, GetX)(THIS) PURE; - STDMETHOD_(LONG, GetY)(THIS) PURE; - STDMETHOD_(DWORD, GetWidth)(THIS) PURE; - STDMETHOD_(DWORD, GetHeight)(THIS) PURE; - STDMETHOD_(D3DVALUE, GetField)(THIS) PURE; - STDMETHOD_(D3DVALUE, GetBack)(THIS) PURE; - STDMETHOD_(D3DVALUE, GetFront)(THIS) PURE; - STDMETHOD_(D3DRMPROJECTIONTYPE, GetProjection)(THIS) PURE; - STDMETHOD(GetDirect3DViewport)(THIS_ LPDIRECT3DVIEWPORT *) PURE; - STDMETHOD(TransformVectors)(THIS_ DWORD dwNumVectors, - LPD3DRMVECTOR4D lpDstVectors, - LPD3DVECTOR lpSrcVectors) PURE; - STDMETHOD(InverseTransformVectors)(THIS_ DWORD dwNumVectors, - LPD3DVECTOR lpDstVectors, - LPD3DRMVECTOR4D lpSrcVectors) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMFrame - -DECLARE_INTERFACE_(IDirect3DRMFrame, IDirect3DRMVisual) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMFrame methods - */ - STDMETHOD(AddChild)(THIS_ LPDIRECT3DRMFRAME child) PURE; - STDMETHOD(AddLight)(THIS_ LPDIRECT3DRMLIGHT) PURE; - STDMETHOD(AddMoveCallback)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg) PURE; - STDMETHOD(AddTransform)(THIS_ D3DRMCOMBINETYPE, D3DRMMATRIX4D) PURE; - STDMETHOD(AddTranslation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(AddScale)(THIS_ D3DRMCOMBINETYPE, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE; - STDMETHOD(AddRotation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE; - STDMETHOD(AddVisual)(THIS_ LPDIRECT3DRMVISUAL) PURE; - STDMETHOD(GetChildren)(THIS_ LPDIRECT3DRMFRAMEARRAY *children) PURE; - STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE; - STDMETHOD(GetLights)(THIS_ LPDIRECT3DRMLIGHTARRAY *lights) PURE; - STDMETHOD_(D3DRMMATERIALMODE, GetMaterialMode)(THIS) PURE; - STDMETHOD(GetParent)(THIS_ LPDIRECT3DRMFRAME *) PURE; - STDMETHOD(GetPosition)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR return_position) PURE; - STDMETHOD(GetRotation)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR axis, LPD3DVALUE return_theta) PURE; - STDMETHOD(GetScene)(THIS_ LPDIRECT3DRMFRAME *) PURE; - STDMETHOD_(D3DRMSORTMODE, GetSortMode)(THIS) PURE; - STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE *) PURE; - STDMETHOD(GetTransform)(THIS_ D3DRMMATRIX4D return_matrix) PURE; - STDMETHOD(GetVelocity)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR return_velocity, BOOL with_rotation) PURE; - STDMETHOD(GetOrientation)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR dir, LPD3DVECTOR up) PURE; - STDMETHOD(GetVisuals)(THIS_ LPDIRECT3DRMVISUALARRAY *visuals) PURE; - STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE; - STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE; - STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID lpArg)PURE; - STDMETHOD(LookAt)(THIS_ LPDIRECT3DRMFRAME target, LPDIRECT3DRMFRAME reference, D3DRMFRAMECONSTRAINT) PURE; - STDMETHOD(Move)(THIS_ D3DVALUE delta) PURE; - STDMETHOD(DeleteChild)(THIS_ LPDIRECT3DRMFRAME) PURE; - STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DRMLIGHT) PURE; - STDMETHOD(DeleteMoveCallback)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg) PURE; - STDMETHOD(DeleteVisual)(THIS_ LPDIRECT3DRMVISUAL) PURE; - STDMETHOD_(D3DCOLOR, GetSceneBackground)(THIS) PURE; - STDMETHOD(GetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE *) PURE; - STDMETHOD_(D3DCOLOR, GetSceneFogColor)(THIS) PURE; - STDMETHOD_(BOOL, GetSceneFogEnable)(THIS) PURE; - STDMETHOD_(D3DRMFOGMODE, GetSceneFogMode)(THIS) PURE; - STDMETHOD(GetSceneFogParams)(THIS_ D3DVALUE *return_start, D3DVALUE *return_end, D3DVALUE *return_density) PURE; - STDMETHOD(SetSceneBackground)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetSceneBackgroundRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; - STDMETHOD(SetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE; - STDMETHOD(SetSceneBackgroundImage)(THIS_ LPDIRECT3DRMTEXTURE) PURE; - STDMETHOD(SetSceneFogEnable)(THIS_ BOOL) PURE; - STDMETHOD(SetSceneFogColor)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetSceneFogMode)(THIS_ D3DRMFOGMODE) PURE; - STDMETHOD(SetSceneFogParams)(THIS_ D3DVALUE start, D3DVALUE end, D3DVALUE density) PURE; - STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; - STDMETHOD_(D3DRMZBUFFERMODE, GetZbufferMode)(THIS) PURE; - STDMETHOD(SetMaterialMode)(THIS_ D3DRMMATERIALMODE) PURE; - STDMETHOD(SetOrientation) - ( THIS_ LPDIRECT3DRMFRAME reference, - D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, - D3DVALUE ux, D3DVALUE uy, D3DVALUE uz - ) PURE; - STDMETHOD(SetPosition)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(SetRotation)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE; - STDMETHOD(SetSortMode)(THIS_ D3DRMSORTMODE) PURE; - STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE; - STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; - STDMETHOD(SetVelocity)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, BOOL with_rotation) PURE; - STDMETHOD(SetZbufferMode)(THIS_ D3DRMZBUFFERMODE) PURE; - STDMETHOD(Transform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMFrame2 - -DECLARE_INTERFACE_(IDirect3DRMFrame2, IDirect3DRMFrame) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMFrame methods - */ - STDMETHOD(AddChild)(THIS_ LPDIRECT3DRMFRAME child) PURE; - STDMETHOD(AddLight)(THIS_ LPDIRECT3DRMLIGHT) PURE; - STDMETHOD(AddMoveCallback)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg) PURE; - STDMETHOD(AddTransform)(THIS_ D3DRMCOMBINETYPE, D3DRMMATRIX4D) PURE; - STDMETHOD(AddTranslation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(AddScale)(THIS_ D3DRMCOMBINETYPE, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE; - STDMETHOD(AddRotation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE; - STDMETHOD(AddVisual)(THIS_ LPDIRECT3DRMVISUAL) PURE; - STDMETHOD(GetChildren)(THIS_ LPDIRECT3DRMFRAMEARRAY *children) PURE; - STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE; - STDMETHOD(GetLights)(THIS_ LPDIRECT3DRMLIGHTARRAY *lights) PURE; - STDMETHOD_(D3DRMMATERIALMODE, GetMaterialMode)(THIS) PURE; - STDMETHOD(GetParent)(THIS_ LPDIRECT3DRMFRAME *) PURE; - STDMETHOD(GetPosition)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR return_position) PURE; - STDMETHOD(GetRotation)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR axis, LPD3DVALUE return_theta) PURE; - STDMETHOD(GetScene)(THIS_ LPDIRECT3DRMFRAME *) PURE; - STDMETHOD_(D3DRMSORTMODE, GetSortMode)(THIS) PURE; - STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE *) PURE; - STDMETHOD(GetTransform)(THIS_ D3DRMMATRIX4D return_matrix) PURE; - STDMETHOD(GetVelocity)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR return_velocity, BOOL with_rotation) PURE; - STDMETHOD(GetOrientation)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR dir, LPD3DVECTOR up) PURE; - STDMETHOD(GetVisuals)(THIS_ LPDIRECT3DRMVISUALARRAY *visuals) PURE; - STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE; - STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE; - STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID lpArg)PURE; - STDMETHOD(LookAt)(THIS_ LPDIRECT3DRMFRAME target, LPDIRECT3DRMFRAME reference, D3DRMFRAMECONSTRAINT) PURE; - STDMETHOD(Move)(THIS_ D3DVALUE delta) PURE; - STDMETHOD(DeleteChild)(THIS_ LPDIRECT3DRMFRAME) PURE; - STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DRMLIGHT) PURE; - STDMETHOD(DeleteMoveCallback)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg) PURE; - STDMETHOD(DeleteVisual)(THIS_ LPDIRECT3DRMVISUAL) PURE; - STDMETHOD_(D3DCOLOR, GetSceneBackground)(THIS) PURE; - STDMETHOD(GetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE *) PURE; - STDMETHOD_(D3DCOLOR, GetSceneFogColor)(THIS) PURE; - STDMETHOD_(BOOL, GetSceneFogEnable)(THIS) PURE; - STDMETHOD_(D3DRMFOGMODE, GetSceneFogMode)(THIS) PURE; - STDMETHOD(GetSceneFogParams)(THIS_ D3DVALUE *return_start, D3DVALUE *return_end, D3DVALUE *return_density) PURE; - STDMETHOD(SetSceneBackground)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetSceneBackgroundRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; - STDMETHOD(SetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE; - STDMETHOD(SetSceneBackgroundImage)(THIS_ LPDIRECT3DRMTEXTURE) PURE; - STDMETHOD(SetSceneFogEnable)(THIS_ BOOL) PURE; - STDMETHOD(SetSceneFogColor)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetSceneFogMode)(THIS_ D3DRMFOGMODE) PURE; - STDMETHOD(SetSceneFogParams)(THIS_ D3DVALUE start, D3DVALUE end, D3DVALUE density) PURE; - STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; - STDMETHOD_(D3DRMZBUFFERMODE, GetZbufferMode)(THIS) PURE; - STDMETHOD(SetMaterialMode)(THIS_ D3DRMMATERIALMODE) PURE; - STDMETHOD(SetOrientation) - ( THIS_ LPDIRECT3DRMFRAME reference, - D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, - D3DVALUE ux, D3DVALUE uy, D3DVALUE uz - ) PURE; - STDMETHOD(SetPosition)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(SetRotation)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE; - STDMETHOD(SetSortMode)(THIS_ D3DRMSORTMODE) PURE; - STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE; - STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; - STDMETHOD(SetVelocity)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, BOOL with_rotation) PURE; - STDMETHOD(SetZbufferMode)(THIS_ D3DRMZBUFFERMODE) PURE; - STDMETHOD(Transform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE; - - /* - * IDirect3DRMFrame2 methods - */ - STDMETHOD(AddMoveCallback2)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg, DWORD dwFlags) PURE; - STDMETHOD(GetBox)(THIS_ LPD3DRMBOX) PURE; - STDMETHOD_(BOOL, GetBoxEnable)(THIS) PURE; - STDMETHOD(GetAxes)(THIS_ LPD3DVECTOR dir, LPD3DVECTOR up); - STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL *) PURE; - STDMETHOD_(BOOL, GetInheritAxes)(THIS); - STDMETHOD(GetHierarchyBox)(THIS_ LPD3DRMBOX) PURE; - - STDMETHOD(SetBox)(THIS_ LPD3DRMBOX) PURE; - STDMETHOD(SetBoxEnable)(THIS_ BOOL) PURE; - STDMETHOD(SetAxes)(THIS_ D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, - D3DVALUE ux, D3DVALUE uy, D3DVALUE uz); - STDMETHOD(SetInheritAxes)(THIS_ BOOL inherit_from_parent); - STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL) PURE; - STDMETHOD(SetQuaternion)(THIS_ LPDIRECT3DRMFRAME reference, D3DRMQUATERNION *q) PURE; - - STDMETHOD(RayPick)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DRMRAY ray, DWORD dwFlags, LPDIRECT3DRMPICKED2ARRAY *return_visuals) PURE; - STDMETHOD(Save)(THIS_ LPCSTR filename, D3DRMXOFFORMAT d3dFormat, - D3DRMSAVEOPTIONS d3dSaveFlags); -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMFrame3 - -DECLARE_INTERFACE_(IDirect3DRMFrame3, IDirect3DRMVisual) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMFrame3 methods - */ - STDMETHOD(AddChild)(THIS_ LPDIRECT3DRMFRAME3 child) PURE; - STDMETHOD(AddLight)(THIS_ LPDIRECT3DRMLIGHT) PURE; - STDMETHOD(AddMoveCallback)(THIS_ D3DRMFRAME3MOVECALLBACK, VOID *arg, DWORD dwFlags) PURE; - STDMETHOD(AddTransform)(THIS_ D3DRMCOMBINETYPE, D3DRMMATRIX4D) PURE; - STDMETHOD(AddTranslation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(AddScale)(THIS_ D3DRMCOMBINETYPE, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE; - STDMETHOD(AddRotation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE; - STDMETHOD(AddVisual)(THIS_ LPUNKNOWN) PURE; - STDMETHOD(GetChildren)(THIS_ LPDIRECT3DRMFRAMEARRAY *children) PURE; - STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE; - STDMETHOD(GetLights)(THIS_ LPDIRECT3DRMLIGHTARRAY *lights) PURE; - STDMETHOD_(D3DRMMATERIALMODE, GetMaterialMode)(THIS) PURE; - STDMETHOD(GetParent)(THIS_ LPDIRECT3DRMFRAME3 *) PURE; - STDMETHOD(GetPosition)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DVECTOR return_position) PURE; - STDMETHOD(GetRotation)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DVECTOR axis, LPD3DVALUE return_theta) PURE; - STDMETHOD(GetScene)(THIS_ LPDIRECT3DRMFRAME3 *) PURE; - STDMETHOD_(D3DRMSORTMODE, GetSortMode)(THIS) PURE; - STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE3 *) PURE; - STDMETHOD(GetTransform)(THIS_ LPDIRECT3DRMFRAME3 reference, - D3DRMMATRIX4D rmMatrix) PURE; - STDMETHOD(GetVelocity)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DVECTOR return_velocity, BOOL with_rotation) PURE; - STDMETHOD(GetOrientation)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DVECTOR dir, LPD3DVECTOR up) PURE; - STDMETHOD(GetVisuals)(THIS_ LPDWORD lpdwCount, LPUNKNOWN *) PURE; - STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE; - STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURE3CALLBACK, LPVOID lpArg)PURE; - STDMETHOD(LookAt)(THIS_ LPDIRECT3DRMFRAME3 target, LPDIRECT3DRMFRAME3 reference, D3DRMFRAMECONSTRAINT) PURE; - STDMETHOD(Move)(THIS_ D3DVALUE delta) PURE; - STDMETHOD(DeleteChild)(THIS_ LPDIRECT3DRMFRAME3) PURE; - STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DRMLIGHT) PURE; - STDMETHOD(DeleteMoveCallback)(THIS_ D3DRMFRAME3MOVECALLBACK, VOID *arg) PURE; - STDMETHOD(DeleteVisual)(THIS_ LPUNKNOWN) PURE; - STDMETHOD_(D3DCOLOR, GetSceneBackground)(THIS) PURE; - STDMETHOD(GetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE *) PURE; - STDMETHOD_(D3DCOLOR, GetSceneFogColor)(THIS) PURE; - STDMETHOD_(BOOL, GetSceneFogEnable)(THIS) PURE; - STDMETHOD_(D3DRMFOGMODE, GetSceneFogMode)(THIS) PURE; - STDMETHOD(GetSceneFogParams)(THIS_ D3DVALUE *return_start, D3DVALUE *return_end, D3DVALUE *return_density) PURE; - STDMETHOD(SetSceneBackground)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetSceneBackgroundRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; - STDMETHOD(SetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE; - STDMETHOD(SetSceneBackgroundImage)(THIS_ LPDIRECT3DRMTEXTURE3) PURE; - STDMETHOD(SetSceneFogEnable)(THIS_ BOOL) PURE; - STDMETHOD(SetSceneFogColor)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetSceneFogMode)(THIS_ D3DRMFOGMODE) PURE; - STDMETHOD(SetSceneFogParams)(THIS_ D3DVALUE start, D3DVALUE end, D3DVALUE density) PURE; - STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; - STDMETHOD_(D3DRMZBUFFERMODE, GetZbufferMode)(THIS) PURE; - STDMETHOD(SetMaterialMode)(THIS_ D3DRMMATERIALMODE) PURE; - STDMETHOD(SetOrientation) - ( THIS_ LPDIRECT3DRMFRAME3 reference, - D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, - D3DVALUE ux, D3DVALUE uy, D3DVALUE uz - ) PURE; - STDMETHOD(SetPosition)(THIS_ LPDIRECT3DRMFRAME3 reference, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(SetRotation)(THIS_ LPDIRECT3DRMFRAME3 reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE; - STDMETHOD(SetSortMode)(THIS_ D3DRMSORTMODE) PURE; - STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE3) PURE; - STDMETHOD(SetVelocity)(THIS_ LPDIRECT3DRMFRAME3 reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, BOOL with_rotation) PURE; - STDMETHOD(SetZbufferMode)(THIS_ D3DRMZBUFFERMODE) PURE; - STDMETHOD(Transform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE; - STDMETHOD(GetBox)(THIS_ LPD3DRMBOX) PURE; - STDMETHOD_(BOOL, GetBoxEnable)(THIS) PURE; - STDMETHOD(GetAxes)(THIS_ LPD3DVECTOR dir, LPD3DVECTOR up); - STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2 *) PURE; - STDMETHOD_(BOOL, GetInheritAxes)(THIS); - STDMETHOD(GetHierarchyBox)(THIS_ LPD3DRMBOX) PURE; - - STDMETHOD(SetBox)(THIS_ LPD3DRMBOX) PURE; - STDMETHOD(SetBoxEnable)(THIS_ BOOL) PURE; - STDMETHOD(SetAxes)(THIS_ D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, - D3DVALUE ux, D3DVALUE uy, D3DVALUE uz); - STDMETHOD(SetInheritAxes)(THIS_ BOOL inherit_from_parent); - STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2) PURE; - STDMETHOD(SetQuaternion)(THIS_ LPDIRECT3DRMFRAME3 reference, D3DRMQUATERNION *q) PURE; - - STDMETHOD(RayPick)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DRMRAY ray, DWORD dwFlags, LPDIRECT3DRMPICKED2ARRAY *return_visuals) PURE; - STDMETHOD(Save)(THIS_ LPCSTR filename, D3DRMXOFFORMAT d3dFormat, - D3DRMSAVEOPTIONS d3dSaveFlags); - STDMETHOD(TransformVectors)(THIS_ LPDIRECT3DRMFRAME3 reference, - DWORD dwNumVectors, - LPD3DVECTOR lpDstVectors, - LPD3DVECTOR lpSrcVectors) PURE; - STDMETHOD(InverseTransformVectors)(THIS_ LPDIRECT3DRMFRAME3 reference, - DWORD dwNumVectors, - LPD3DVECTOR lpDstVectors, - LPD3DVECTOR lpSrcVectors) PURE; - STDMETHOD(SetTraversalOptions)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(GetTraversalOptions)(THIS_ LPDWORD lpdwFlags) PURE; - STDMETHOD(SetSceneFogMethod)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(GetSceneFogMethod)(THIS_ LPDWORD lpdwFlags) PURE; - STDMETHOD(SetMaterialOverride)(THIS_ LPD3DRMMATERIALOVERRIDE) PURE; - STDMETHOD(GetMaterialOverride)(THIS_ LPD3DRMMATERIALOVERRIDE) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMMesh - -DECLARE_INTERFACE_(IDirect3DRMMesh, IDirect3DRMVisual) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMMesh methods - */ - STDMETHOD(Scale)(THIS_ D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE; - STDMETHOD(Translate)(THIS_ D3DVALUE tx, D3DVALUE ty, D3DVALUE tz) PURE; - STDMETHOD(GetBox)(THIS_ D3DRMBOX *) PURE; - STDMETHOD(AddGroup)(THIS_ unsigned vCount, unsigned fCount, unsigned vPerFace, unsigned *fData, D3DRMGROUPINDEX *returnId) PURE; - STDMETHOD(SetVertices)(THIS_ D3DRMGROUPINDEX id, unsigned index, unsigned count, D3DRMVERTEX *values) PURE; - STDMETHOD(SetGroupColor)(THIS_ D3DRMGROUPINDEX id, D3DCOLOR value) PURE; - STDMETHOD(SetGroupColorRGB)(THIS_ D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; - STDMETHOD(SetGroupMapping)(THIS_ D3DRMGROUPINDEX id, D3DRMMAPPING value) PURE; - STDMETHOD(SetGroupQuality)(THIS_ D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value) PURE; - STDMETHOD(SetGroupMaterial)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL value) PURE; - STDMETHOD(SetGroupTexture)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE value) PURE; - - STDMETHOD_(unsigned, GetGroupCount)(THIS) PURE; - STDMETHOD(GetGroup)(THIS_ D3DRMGROUPINDEX id, unsigned *vCount, unsigned *fCount, unsigned *vPerFace, DWORD *fDataSize, unsigned *fData) PURE; - STDMETHOD(GetVertices)(THIS_ D3DRMGROUPINDEX id, DWORD index, DWORD count, D3DRMVERTEX *returnPtr) PURE; - STDMETHOD_(D3DCOLOR, GetGroupColor)(THIS_ D3DRMGROUPINDEX id) PURE; - STDMETHOD_(D3DRMMAPPING, GetGroupMapping)(THIS_ D3DRMGROUPINDEX id) PURE; - STDMETHOD_(D3DRMRENDERQUALITY, GetGroupQuality)(THIS_ D3DRMGROUPINDEX id) PURE; - STDMETHOD(GetGroupMaterial)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL *returnPtr) PURE; - STDMETHOD(GetGroupTexture)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE *returnPtr) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMProgressiveMesh - -DECLARE_INTERFACE_(IDirect3DRMProgressiveMesh, IDirect3DRMVisual) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMProgressiveMesh methods - */ - STDMETHOD(Load) (THIS_ LPVOID lpObjLocation, LPVOID lpObjId, - D3DRMLOADOPTIONS dloLoadflags, D3DRMLOADTEXTURECALLBACK lpCallback, - LPVOID lpArg) PURE; - STDMETHOD(GetLoadStatus) (THIS_ LPD3DRMPMESHLOADSTATUS lpStatus) PURE; - STDMETHOD(SetMinRenderDetail) (THIS_ D3DVALUE d3dVal) PURE; - STDMETHOD(Abort) (THIS_ DWORD dwFlags) PURE; - - STDMETHOD(GetFaceDetail) (THIS_ LPDWORD lpdwCount) PURE; - STDMETHOD(GetVertexDetail) (THIS_ LPDWORD lpdwCount) PURE; - STDMETHOD(SetFaceDetail) (THIS_ DWORD dwCount) PURE; - STDMETHOD(SetVertexDetail) (THIS_ DWORD dwCount) PURE; - STDMETHOD(GetFaceDetailRange) (THIS_ LPDWORD lpdwMin, LPDWORD lpdwMax) PURE; - STDMETHOD(GetVertexDetailRange) (THIS_ LPDWORD lpdwMin, LPDWORD lpdwMax) PURE; - STDMETHOD(GetDetail) (THIS_ D3DVALUE *lpdvVal) PURE; - STDMETHOD(SetDetail) (THIS_ D3DVALUE d3dVal) PURE; - - STDMETHOD(RegisterEvents) (THIS_ HANDLE hEvent, DWORD dwFlags, DWORD dwReserved) PURE; - STDMETHOD(CreateMesh) (THIS_ LPDIRECT3DRMMESH *lplpD3DRMMesh) PURE; - STDMETHOD(Duplicate) (THIS_ LPDIRECT3DRMPROGRESSIVEMESH *lplpD3DRMPMesh) PURE; - STDMETHOD(GetBox) (THIS_ LPD3DRMBOX lpBBox) PURE; - STDMETHOD(SetQuality) (THIS_ D3DRMRENDERQUALITY) PURE; - STDMETHOD(GetQuality) (THIS_ LPD3DRMRENDERQUALITY lpdwquality) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMShadow - -DECLARE_INTERFACE_(IDirect3DRMShadow, IDirect3DRMVisual) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMShadow methods - */ - STDMETHOD(Init) - ( THIS_ LPDIRECT3DRMVISUAL visual, LPDIRECT3DRMLIGHT light, - D3DVALUE px, D3DVALUE py, D3DVALUE pz, - D3DVALUE nx, D3DVALUE ny, D3DVALUE nz - ) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMShadow2 - -DECLARE_INTERFACE_(IDirect3DRMShadow2, IDirect3DRMVisual) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMShadow methods - */ - STDMETHOD(Init) - ( THIS_ LPUNKNOWN pUNK, LPDIRECT3DRMLIGHT light, - D3DVALUE px, D3DVALUE py, D3DVALUE pz, - D3DVALUE nx, D3DVALUE ny, D3DVALUE nz - ) PURE; - - /* - * IDirect3DRMShadow2 methods - */ - STDMETHOD(GetVisual)(THIS_ LPDIRECT3DRMVISUAL *) PURE; - STDMETHOD(SetVisual)(THIS_ LPUNKNOWN pUNK, DWORD) PURE; - STDMETHOD(GetLight)(THIS_ LPDIRECT3DRMLIGHT *) PURE; - STDMETHOD(SetLight)(THIS_ LPDIRECT3DRMLIGHT, DWORD) PURE; - STDMETHOD(GetPlane)(THIS_ LPD3DVALUE px, LPD3DVALUE py, LPD3DVALUE pz, - LPD3DVALUE nx, LPD3DVALUE ny, LPD3DVALUE nz) PURE; - STDMETHOD(SetPlane)(THIS_ D3DVALUE px, D3DVALUE py, D3DVALUE pz, - D3DVALUE nx, D3DVALUE ny, D3DVALUE nz, DWORD) PURE; - STDMETHOD(GetOptions)(THIS_ LPDWORD) PURE; - STDMETHOD(SetOptions)(THIS_ DWORD) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMFace - -DECLARE_INTERFACE_(IDirect3DRMFace, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMFace methods - */ - STDMETHOD(AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(AddVertexAndNormalIndexed)(THIS_ DWORD vertex, DWORD normal) PURE; - STDMETHOD(SetColorRGB)(THIS_ D3DVALUE, D3DVALUE, D3DVALUE) PURE; - STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE; - STDMETHOD(SetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE u, D3DVALUE v) PURE; - STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL) PURE; - STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; - - STDMETHOD(GetVertex)(THIS_ DWORD index, D3DVECTOR *vertex, D3DVECTOR *normal) PURE; - STDMETHOD(GetVertices)(THIS_ DWORD *vertex_count, D3DVECTOR *coords, D3DVECTOR *normals); - STDMETHOD(GetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE *u, D3DVALUE *v) PURE; - STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE; - STDMETHOD(GetNormal)(THIS_ D3DVECTOR *) PURE; - STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE *) PURE; - STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL *) PURE; - - STDMETHOD_(int, GetVertexCount)(THIS) PURE; - STDMETHOD_(int, GetVertexIndex)(THIS_ DWORD which) PURE; - STDMETHOD_(int, GetTextureCoordinateIndex)(THIS_ DWORD which) PURE; - STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMFace2 - -DECLARE_INTERFACE_(IDirect3DRMFace2, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMFace methods - */ - STDMETHOD(AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(AddVertexAndNormalIndexed)(THIS_ DWORD vertex, DWORD normal) PURE; - STDMETHOD(SetColorRGB)(THIS_ D3DVALUE, D3DVALUE, D3DVALUE) PURE; - STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE3) PURE; - STDMETHOD(SetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE u, D3DVALUE v) PURE; - STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2) PURE; - STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; - - STDMETHOD(GetVertex)(THIS_ DWORD index, D3DVECTOR *vertex, D3DVECTOR *normal) PURE; - STDMETHOD(GetVertices)(THIS_ DWORD *vertex_count, D3DVECTOR *coords, D3DVECTOR *normals); - STDMETHOD(GetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE *u, D3DVALUE *v) PURE; - STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE; - STDMETHOD(GetNormal)(THIS_ D3DVECTOR *) PURE; - STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE3 *) PURE; - STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2 *) PURE; - - STDMETHOD_(int, GetVertexCount)(THIS) PURE; - STDMETHOD_(int, GetVertexIndex)(THIS_ DWORD which) PURE; - STDMETHOD_(int, GetTextureCoordinateIndex)(THIS_ DWORD which) PURE; - STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMMeshBuilder - -DECLARE_INTERFACE_(IDirect3DRMMeshBuilder, IDirect3DRMVisual) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMMeshBuilder methods - */ - STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID lpArg) PURE; - STDMETHOD(Save)(THIS_ const char *filename, D3DRMXOFFORMAT, D3DRMSAVEOPTIONS save) PURE; - STDMETHOD(Scale)(THIS_ D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE; - STDMETHOD(Translate)(THIS_ D3DVALUE tx, D3DVALUE ty, D3DVALUE tz) PURE; - STDMETHOD(SetColorSource)(THIS_ D3DRMCOLORSOURCE) PURE; - STDMETHOD(GetBox)(THIS_ D3DRMBOX *) PURE; - STDMETHOD(GenerateNormals)(THIS) PURE; - STDMETHOD_(D3DRMCOLORSOURCE, GetColorSource)(THIS) PURE; - - STDMETHOD(AddMesh)(THIS_ LPDIRECT3DRMMESH) PURE; - STDMETHOD(AddMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER) PURE; - STDMETHOD(AddFrame)(THIS_ LPDIRECT3DRMFRAME) PURE; - STDMETHOD(AddFace)(THIS_ LPDIRECT3DRMFACE) PURE; - STDMETHOD(AddFaces) - ( THIS_ DWORD vcount, D3DVECTOR *vertices, DWORD ncount, D3DVECTOR *normals, - DWORD *data, LPDIRECT3DRMFACEARRAY* - ) PURE; - STDMETHOD(ReserveSpace)(THIS_ DWORD vertex_Count, DWORD normal_count, DWORD face_count) PURE; - STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; - STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE; - STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL) PURE; - STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; - STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE; - STDMETHOD(SetPerspective)(THIS_ BOOL) PURE; - STDMETHOD(SetVertex)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(SetNormal)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(SetTextureCoordinates)(THIS_ DWORD index, D3DVALUE u, D3DVALUE v) PURE; - STDMETHOD(SetVertexColor)(THIS_ DWORD index, D3DCOLOR) PURE; - STDMETHOD(SetVertexColorRGB)(THIS_ DWORD index, D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; - - STDMETHOD(GetFaces)(THIS_ LPDIRECT3DRMFACEARRAY*) PURE; - STDMETHOD(GetVertices) - ( THIS_ DWORD *vcount, D3DVECTOR *vertices, DWORD *ncount, D3DVECTOR *normals, DWORD *face_data_size, DWORD *face_data - ) PURE; - STDMETHOD(GetTextureCoordinates)(THIS_ DWORD index, D3DVALUE *u, D3DVALUE *v) PURE; - - STDMETHOD_(int, AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD_(int, AddNormal)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(CreateFace)(THIS_ LPDIRECT3DRMFACE*) PURE; - STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE; - STDMETHOD_(BOOL, GetPerspective)(THIS) PURE; - STDMETHOD_(int, GetFaceCount)(THIS) PURE; - STDMETHOD_(int, GetVertexCount)(THIS) PURE; - STDMETHOD_(D3DCOLOR, GetVertexColor)(THIS_ DWORD index) PURE; - - STDMETHOD(CreateMesh)(THIS_ LPDIRECT3DRMMESH*) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMMeshBuilder2 - -DECLARE_INTERFACE_(IDirect3DRMMeshBuilder2, IDirect3DRMMeshBuilder) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMMeshBuilder methods - */ - STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID lpArg) PURE; - STDMETHOD(Save)(THIS_ const char *filename, D3DRMXOFFORMAT, D3DRMSAVEOPTIONS save) PURE; - STDMETHOD(Scale)(THIS_ D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE; - STDMETHOD(Translate)(THIS_ D3DVALUE tx, D3DVALUE ty, D3DVALUE tz) PURE; - STDMETHOD(SetColorSource)(THIS_ D3DRMCOLORSOURCE) PURE; - STDMETHOD(GetBox)(THIS_ D3DRMBOX *) PURE; - STDMETHOD(GenerateNormals)(THIS) PURE; - STDMETHOD_(D3DRMCOLORSOURCE, GetColorSource)(THIS) PURE; - - STDMETHOD(AddMesh)(THIS_ LPDIRECT3DRMMESH) PURE; - STDMETHOD(AddMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER) PURE; - STDMETHOD(AddFrame)(THIS_ LPDIRECT3DRMFRAME) PURE; - STDMETHOD(AddFace)(THIS_ LPDIRECT3DRMFACE) PURE; - STDMETHOD(AddFaces) - ( THIS_ DWORD vcount, D3DVECTOR *vertices, DWORD ncount, D3DVECTOR *normals, - DWORD *data, LPDIRECT3DRMFACEARRAY* - ) PURE; - STDMETHOD(ReserveSpace)(THIS_ DWORD vertex_Count, DWORD normal_count, DWORD face_count) PURE; - STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; - STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE; - STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL) PURE; - STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; - STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE; - STDMETHOD(SetPerspective)(THIS_ BOOL) PURE; - STDMETHOD(SetVertex)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(SetNormal)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(SetTextureCoordinates)(THIS_ DWORD index, D3DVALUE u, D3DVALUE v) PURE; - STDMETHOD(SetVertexColor)(THIS_ DWORD index, D3DCOLOR) PURE; - STDMETHOD(SetVertexColorRGB)(THIS_ DWORD index, D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; - - STDMETHOD(GetFaces)(THIS_ LPDIRECT3DRMFACEARRAY*) PURE; - STDMETHOD(GetVertices) - ( THIS_ DWORD *vcount, D3DVECTOR *vertices, DWORD *ncount, D3DVECTOR *normals, DWORD *face_data_size, DWORD *face_data - ) PURE; - STDMETHOD(GetTextureCoordinates)(THIS_ DWORD index, D3DVALUE *u, D3DVALUE *v) PURE; - - STDMETHOD_(int, AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD_(int, AddNormal)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(CreateFace)(THIS_ LPDIRECT3DRMFACE*) PURE; - STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE; - STDMETHOD_(BOOL, GetPerspective)(THIS) PURE; - STDMETHOD_(int, GetFaceCount)(THIS) PURE; - STDMETHOD_(int, GetVertexCount)(THIS) PURE; - STDMETHOD_(D3DCOLOR, GetVertexColor)(THIS_ DWORD index) PURE; - - STDMETHOD(CreateMesh)(THIS_ LPDIRECT3DRMMESH*) PURE; - - /* - * IDirect3DRMMeshBuilder2 methods - */ - STDMETHOD(GenerateNormals2)(THIS_ D3DVALUE crease, DWORD dwFlags) PURE; - STDMETHOD(GetFace)(THIS_ DWORD index, LPDIRECT3DRMFACE*) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMMeshBuilder3 - -DECLARE_INTERFACE_(IDirect3DRMMeshBuilder3, IDirect3DRMVisual) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMMeshBuilder3 methods - */ - STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURE3CALLBACK, LPVOID lpArg) PURE; - STDMETHOD(Save)(THIS_ const char *filename, D3DRMXOFFORMAT, D3DRMSAVEOPTIONS save) PURE; - STDMETHOD(Scale)(THIS_ D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE; - STDMETHOD(Translate)(THIS_ D3DVALUE tx, D3DVALUE ty, D3DVALUE tz) PURE; - STDMETHOD(SetColorSource)(THIS_ D3DRMCOLORSOURCE) PURE; - STDMETHOD(GetBox)(THIS_ D3DRMBOX *) PURE; - STDMETHOD(GenerateNormals)(THIS_ D3DVALUE crease, DWORD dwFlags) PURE; - STDMETHOD_(D3DRMCOLORSOURCE, GetColorSource)(THIS) PURE; - - STDMETHOD(AddMesh)(THIS_ LPDIRECT3DRMMESH) PURE; - STDMETHOD(AddMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER3, DWORD dwFlags) PURE; - STDMETHOD(AddFrame)(THIS_ LPDIRECT3DRMFRAME3) PURE; - STDMETHOD(AddFace)(THIS_ LPDIRECT3DRMFACE2) PURE; - STDMETHOD(AddFaces) - ( THIS_ DWORD vcount, D3DVECTOR *vertices, DWORD ncount, D3DVECTOR *normals, - DWORD *data, LPDIRECT3DRMFACEARRAY* - ) PURE; - STDMETHOD(ReserveSpace)(THIS_ DWORD vertex_Count, DWORD normal_count, DWORD face_count) PURE; - STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; - STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE3) PURE; - STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2) PURE; - STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; - STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE; - STDMETHOD(SetPerspective)(THIS_ BOOL) PURE; - STDMETHOD(SetVertex)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(SetNormal)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(SetTextureCoordinates)(THIS_ DWORD index, D3DVALUE u, D3DVALUE v) PURE; - STDMETHOD(SetVertexColor)(THIS_ DWORD index, D3DCOLOR) PURE; - STDMETHOD(SetVertexColorRGB)(THIS_ DWORD index, D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; - STDMETHOD(GetFaces)(THIS_ LPDIRECT3DRMFACEARRAY*) PURE; - STDMETHOD(GetGeometry) - ( THIS_ DWORD *vcount, D3DVECTOR *vertices, DWORD *ncount, D3DVECTOR *normals, DWORD *face_data_size, DWORD *face_data - ) PURE; - STDMETHOD(GetTextureCoordinates)(THIS_ DWORD index, D3DVALUE *u, D3DVALUE *v) PURE; - STDMETHOD_(int, AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD_(int, AddNormal)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(CreateFace)(THIS_ LPDIRECT3DRMFACE2 *) PURE; - STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE; - STDMETHOD_(BOOL, GetPerspective)(THIS) PURE; - STDMETHOD_(int, GetFaceCount)(THIS) PURE; - STDMETHOD_(int, GetVertexCount)(THIS) PURE; - STDMETHOD_(D3DCOLOR, GetVertexColor)(THIS_ DWORD index) PURE; - STDMETHOD(CreateMesh)(THIS_ LPDIRECT3DRMMESH*) PURE; - STDMETHOD(GetFace)(THIS_ DWORD index, LPDIRECT3DRMFACE2 *) PURE; - STDMETHOD(GetVertex)(THIS_ DWORD dwIndex, LPD3DVECTOR lpVector) PURE; - STDMETHOD(GetNormal)(THIS_ DWORD dwIndex, LPD3DVECTOR lpVector) PURE; - STDMETHOD(DeleteVertices)(THIS_ DWORD dwIndexFirst, DWORD dwCount) PURE; - STDMETHOD(DeleteNormals)(THIS_ DWORD dwIndexFirst, DWORD dwCount) PURE; - STDMETHOD(DeleteFace)(THIS_ LPDIRECT3DRMFACE2) PURE; - STDMETHOD(Empty)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(Optimize)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(AddFacesIndexed)(THIS_ DWORD dwFlags, DWORD *lpdwvIndices, DWORD *dwIndexFirst, DWORD *dwCount) PURE; - STDMETHOD(CreateSubMesh)(THIS_ LPUNKNOWN *) PURE; - STDMETHOD(GetParentMesh)(THIS_ DWORD, LPUNKNOWN *) PURE; - STDMETHOD(GetSubMeshes)(THIS_ LPDWORD lpdwCount, LPUNKNOWN *) PURE; - STDMETHOD(DeleteSubMesh)(THIS_ LPUNKNOWN) PURE; - STDMETHOD(Enable)(THIS_ DWORD) PURE; - STDMETHOD(GetEnable)(THIS_ DWORD *) PURE; - STDMETHOD(AddTriangles)(THIS_ DWORD dwFlags, DWORD dwFormat, - DWORD dwVertexCount, LPVOID lpvData) PURE; - STDMETHOD(SetVertices)(THIS_ DWORD dwIndexFirst, DWORD dwCount, LPD3DVECTOR) PURE; - STDMETHOD(GetVertices)(THIS_ DWORD dwIndexFirst, LPDWORD lpdwCount, LPD3DVECTOR) PURE; - STDMETHOD(SetNormals)(THIS_ DWORD dwIndexFirst, DWORD dwCount, LPD3DVECTOR) PURE; - STDMETHOD(GetNormals)(THIS_ DWORD dwIndexFirst, LPDWORD lpdwCount, LPD3DVECTOR) PURE; - STDMETHOD_(int, GetNormalCount)(THIS) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMLight - -DECLARE_INTERFACE_(IDirect3DRMLight, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMLight methods - */ - STDMETHOD(SetType)(THIS_ D3DRMLIGHTTYPE) PURE; - STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; - STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; - STDMETHOD(SetRange)(THIS_ D3DVALUE) PURE; - STDMETHOD(SetUmbra)(THIS_ D3DVALUE) PURE; - STDMETHOD(SetPenumbra)(THIS_ D3DVALUE) PURE; - STDMETHOD(SetConstantAttenuation)(THIS_ D3DVALUE) PURE; - STDMETHOD(SetLinearAttenuation)(THIS_ D3DVALUE) PURE; - STDMETHOD(SetQuadraticAttenuation)(THIS_ D3DVALUE) PURE; - - STDMETHOD_(D3DVALUE, GetRange)(THIS) PURE; - STDMETHOD_(D3DVALUE, GetUmbra)(THIS) PURE; - STDMETHOD_(D3DVALUE, GetPenumbra)(THIS) PURE; - STDMETHOD_(D3DVALUE, GetConstantAttenuation)(THIS) PURE; - STDMETHOD_(D3DVALUE, GetLinearAttenuation)(THIS) PURE; - STDMETHOD_(D3DVALUE, GetQuadraticAttenuation)(THIS) PURE; - STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE; - STDMETHOD_(D3DRMLIGHTTYPE, GetType)(THIS) PURE; - - STDMETHOD(SetEnableFrame)(THIS_ LPDIRECT3DRMFRAME) PURE; - STDMETHOD(GetEnableFrame)(THIS_ LPDIRECT3DRMFRAME*) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMTexture - -DECLARE_INTERFACE_(IDirect3DRMTexture, IDirect3DRMVisual) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMTexture methods - */ - STDMETHOD(InitFromFile)(THIS_ const char *filename) PURE; - STDMETHOD(InitFromSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDS) PURE; - STDMETHOD(InitFromResource)(THIS_ HRSRC) PURE; - STDMETHOD(Changed)(THIS_ BOOL pixels, BOOL palette) PURE; - - STDMETHOD(SetColors)(THIS_ DWORD) PURE; - STDMETHOD(SetShades)(THIS_ DWORD) PURE; - STDMETHOD(SetDecalSize)(THIS_ D3DVALUE width, D3DVALUE height) PURE; - STDMETHOD(SetDecalOrigin)(THIS_ LONG x, LONG y) PURE; - STDMETHOD(SetDecalScale)(THIS_ DWORD) PURE; - STDMETHOD(SetDecalTransparency)(THIS_ BOOL) PURE; - STDMETHOD(SetDecalTransparentColor)(THIS_ D3DCOLOR) PURE; - - STDMETHOD(GetDecalSize)(THIS_ D3DVALUE *width_return, D3DVALUE *height_return) PURE; - STDMETHOD(GetDecalOrigin)(THIS_ LONG *x_return, LONG *y_return) PURE; - - STDMETHOD_(D3DRMIMAGE *, GetImage)(THIS) PURE; - STDMETHOD_(DWORD, GetShades)(THIS) PURE; - STDMETHOD_(DWORD, GetColors)(THIS) PURE; - STDMETHOD_(DWORD, GetDecalScale)(THIS) PURE; - STDMETHOD_(BOOL, GetDecalTransparency)(THIS) PURE; - STDMETHOD_(D3DCOLOR, GetDecalTransparentColor)(THIS) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMTexture2 - -DECLARE_INTERFACE_(IDirect3DRMTexture2, IDirect3DRMTexture) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMTexture methods - */ - STDMETHOD(InitFromFile)(THIS_ const char *filename) PURE; - STDMETHOD(InitFromSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDS) PURE; - STDMETHOD(InitFromResource)(THIS_ HRSRC) PURE; - STDMETHOD(Changed)(THIS_ BOOL pixels, BOOL palette) PURE; - - STDMETHOD(SetColors)(THIS_ DWORD) PURE; - STDMETHOD(SetShades)(THIS_ DWORD) PURE; - STDMETHOD(SetDecalSize)(THIS_ D3DVALUE width, D3DVALUE height) PURE; - STDMETHOD(SetDecalOrigin)(THIS_ LONG x, LONG y) PURE; - STDMETHOD(SetDecalScale)(THIS_ DWORD) PURE; - STDMETHOD(SetDecalTransparency)(THIS_ BOOL) PURE; - STDMETHOD(SetDecalTransparentColor)(THIS_ D3DCOLOR) PURE; - - STDMETHOD(GetDecalSize)(THIS_ D3DVALUE *width_return, D3DVALUE *height_return) PURE; - STDMETHOD(GetDecalOrigin)(THIS_ LONG *x_return, LONG *y_return) PURE; - - STDMETHOD_(D3DRMIMAGE *, GetImage)(THIS) PURE; - STDMETHOD_(DWORD, GetShades)(THIS) PURE; - STDMETHOD_(DWORD, GetColors)(THIS) PURE; - STDMETHOD_(DWORD, GetDecalScale)(THIS) PURE; - STDMETHOD_(BOOL, GetDecalTransparency)(THIS) PURE; - STDMETHOD_(D3DCOLOR, GetDecalTransparentColor)(THIS) PURE; - - /* - * IDirect3DRMTexture2 methods - */ - STDMETHOD(InitFromImage)(THIS_ LPD3DRMIMAGE) PURE; - STDMETHOD(InitFromResource2)(THIS_ HMODULE hModule, LPCTSTR strName, LPCTSTR strType) PURE; - STDMETHOD(GenerateMIPMap)(THIS_ DWORD) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMTexture3 - -DECLARE_INTERFACE_(IDirect3DRMTexture3, IDirect3DRMVisual) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMTexture3 methods - */ - STDMETHOD(InitFromFile)(THIS_ const char *filename) PURE; - STDMETHOD(InitFromSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDS) PURE; - STDMETHOD(InitFromResource)(THIS_ HRSRC) PURE; - STDMETHOD(Changed)(THIS_ DWORD dwFlags, DWORD dwcRects, LPRECT pRects) PURE; - STDMETHOD(SetColors)(THIS_ DWORD) PURE; - STDMETHOD(SetShades)(THIS_ DWORD) PURE; - STDMETHOD(SetDecalSize)(THIS_ D3DVALUE width, D3DVALUE height) PURE; - STDMETHOD(SetDecalOrigin)(THIS_ LONG x, LONG y) PURE; - STDMETHOD(SetDecalScale)(THIS_ DWORD) PURE; - STDMETHOD(SetDecalTransparency)(THIS_ BOOL) PURE; - STDMETHOD(SetDecalTransparentColor)(THIS_ D3DCOLOR) PURE; - - STDMETHOD(GetDecalSize)(THIS_ D3DVALUE *width_return, D3DVALUE *height_return) PURE; - STDMETHOD(GetDecalOrigin)(THIS_ LONG *x_return, LONG *y_return) PURE; - - STDMETHOD_(D3DRMIMAGE *, GetImage)(THIS) PURE; - STDMETHOD_(DWORD, GetShades)(THIS) PURE; - STDMETHOD_(DWORD, GetColors)(THIS) PURE; - STDMETHOD_(DWORD, GetDecalScale)(THIS) PURE; - STDMETHOD_(BOOL, GetDecalTransparency)(THIS) PURE; - STDMETHOD_(D3DCOLOR, GetDecalTransparentColor)(THIS) PURE; - STDMETHOD(InitFromImage)(THIS_ LPD3DRMIMAGE) PURE; - STDMETHOD(InitFromResource2)(THIS_ HMODULE hModule, LPCTSTR strName, LPCTSTR strType) PURE; - STDMETHOD(GenerateMIPMap)(THIS_ DWORD) PURE; - STDMETHOD(GetSurface)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE* lplpDDS) PURE; - STDMETHOD(SetCacheOptions)(THIS_ LONG lImportance, DWORD dwFlags) PURE; - STDMETHOD(GetCacheOptions)(THIS_ LPLONG lplImportance, LPDWORD lpdwFlags) PURE; - STDMETHOD(SetDownsampleCallback)(THIS_ D3DRMDOWNSAMPLECALLBACK pCallback, LPVOID pArg) PURE; - STDMETHOD(SetValidationCallback)(THIS_ D3DRMVALIDATIONCALLBACK pCallback, LPVOID pArg) PURE; -}; - - -#undef INTERFACE -#define INTERFACE IDirect3DRMWrap - -DECLARE_INTERFACE_(IDirect3DRMWrap, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMWrap methods - */ - STDMETHOD(Init) - ( THIS_ D3DRMWRAPTYPE, LPDIRECT3DRMFRAME ref, - D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, - D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, - D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, - D3DVALUE ou, D3DVALUE ov, - D3DVALUE su, D3DVALUE sv - ) PURE; - STDMETHOD(Apply)(THIS_ LPDIRECT3DRMOBJECT) PURE; - STDMETHOD(ApplyRelative)(THIS_ LPDIRECT3DRMFRAME frame, LPDIRECT3DRMOBJECT) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMMaterial - -DECLARE_INTERFACE_(IDirect3DRMMaterial, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMMaterial methods - */ - STDMETHOD(SetPower)(THIS_ D3DVALUE power) PURE; - STDMETHOD(SetSpecular)(THIS_ D3DVALUE r, D3DVALUE g, D3DVALUE b) PURE; - STDMETHOD(SetEmissive)(THIS_ D3DVALUE r, D3DVALUE g, D3DVALUE b) PURE; - - STDMETHOD_(D3DVALUE, GetPower)(THIS) PURE; - STDMETHOD(GetSpecular)(THIS_ D3DVALUE* r, D3DVALUE* g, D3DVALUE* b) PURE; - STDMETHOD(GetEmissive)(THIS_ D3DVALUE* r, D3DVALUE* g, D3DVALUE* b) PURE; -}; - - -#undef INTERFACE -#define INTERFACE IDirect3DRMMaterial2 - -DECLARE_INTERFACE_(IDirect3DRMMaterial2, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMMaterial2 methods - */ - STDMETHOD(SetPower)(THIS_ D3DVALUE power) PURE; - STDMETHOD(SetSpecular)(THIS_ D3DVALUE r, D3DVALUE g, D3DVALUE b) PURE; - STDMETHOD(SetEmissive)(THIS_ D3DVALUE r, D3DVALUE g, D3DVALUE b) PURE; - STDMETHOD_(D3DVALUE, GetPower)(THIS) PURE; - STDMETHOD(GetSpecular)(THIS_ D3DVALUE* r, D3DVALUE* g, D3DVALUE* b) PURE; - STDMETHOD(GetEmissive)(THIS_ D3DVALUE* r, D3DVALUE* g, D3DVALUE* b) PURE; - STDMETHOD(GetAmbient)(THIS_ D3DVALUE* r, D3DVALUE* g, D3DVALUE* b) PURE; - STDMETHOD(SetAmbient)(THIS_ D3DVALUE r, D3DVALUE g, D3DVALUE b) PURE; -}; - - -#undef INTERFACE -#define INTERFACE IDirect3DRMAnimation - -DECLARE_INTERFACE_(IDirect3DRMAnimation, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMAnimation methods - */ - STDMETHOD(SetOptions)(THIS_ D3DRMANIMATIONOPTIONS flags) PURE; - STDMETHOD(AddRotateKey)(THIS_ D3DVALUE time, D3DRMQUATERNION *q) PURE; - STDMETHOD(AddPositionKey)(THIS_ D3DVALUE time, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(AddScaleKey)(THIS_ D3DVALUE time, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(DeleteKey)(THIS_ D3DVALUE time) PURE; - STDMETHOD(SetFrame)(THIS_ LPDIRECT3DRMFRAME frame) PURE; - STDMETHOD(SetTime)(THIS_ D3DVALUE time) PURE; - - STDMETHOD_(D3DRMANIMATIONOPTIONS, GetOptions)(THIS) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMAnimation2 - -DECLARE_INTERFACE_(IDirect3DRMAnimation2, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMAnimation2 methods - */ - STDMETHOD(SetOptions)(THIS_ D3DRMANIMATIONOPTIONS flags) PURE; - STDMETHOD(AddRotateKey)(THIS_ D3DVALUE time, D3DRMQUATERNION *q) PURE; - STDMETHOD(AddPositionKey)(THIS_ D3DVALUE time, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(AddScaleKey)(THIS_ D3DVALUE time, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; - STDMETHOD(DeleteKey)(THIS_ D3DVALUE time) PURE; - STDMETHOD(SetFrame)(THIS_ LPDIRECT3DRMFRAME3 frame) PURE; - STDMETHOD(SetTime)(THIS_ D3DVALUE time) PURE; - - STDMETHOD_(D3DRMANIMATIONOPTIONS, GetOptions)(THIS) PURE; - STDMETHOD(GetFrame)(THIS_ LPDIRECT3DRMFRAME3 *lpD3DFrame) PURE; - STDMETHOD(DeleteKeyByID)(THIS_ DWORD dwID) PURE; - STDMETHOD(AddKey)(THIS_ LPD3DRMANIMATIONKEY lpKey) PURE; - STDMETHOD(ModifyKey)(THIS_ LPD3DRMANIMATIONKEY lpKey) PURE; - STDMETHOD(GetKeys)(THIS_ D3DVALUE dvTimeMin, - D3DVALUE dvTimeMax, LPDWORD lpdwNumKeys, - LPD3DRMANIMATIONKEY lpKey); -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMAnimationSet - -DECLARE_INTERFACE_(IDirect3DRMAnimationSet, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMAnimationSet methods - */ - STDMETHOD(AddAnimation)(THIS_ LPDIRECT3DRMANIMATION aid) PURE; - STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID lpArg, LPDIRECT3DRMFRAME parent)PURE; - STDMETHOD(DeleteAnimation)(THIS_ LPDIRECT3DRMANIMATION aid) PURE; - STDMETHOD(SetTime)(THIS_ D3DVALUE time) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMAnimationSet2 - -DECLARE_INTERFACE_(IDirect3DRMAnimationSet2, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMAnimationSet2 methods - */ - STDMETHOD(AddAnimation)(THIS_ LPDIRECT3DRMANIMATION2 aid) PURE; - STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURE3CALLBACK, LPVOID lpArg, LPDIRECT3DRMFRAME3 parent)PURE; - STDMETHOD(DeleteAnimation)(THIS_ LPDIRECT3DRMANIMATION2 aid) PURE; - STDMETHOD(SetTime)(THIS_ D3DVALUE time) PURE; - STDMETHOD(GetAnimations)(THIS_ LPDIRECT3DRMANIMATIONARRAY *) PURE; -}; - - -#undef INTERFACE -#define INTERFACE IDirect3DRMUserVisual - -DECLARE_INTERFACE_(IDirect3DRMUserVisual, IDirect3DRMVisual) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMUserVisual methods - */ - STDMETHOD(Init)(THIS_ D3DRMUSERVISUALCALLBACK fn, void *arg) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMArray - -DECLARE_INTERFACE_(IDirect3DRMArray, IUnknown) -{ - IUNKNOWN_METHODS(PURE); - - STDMETHOD_(DWORD, GetSize)(THIS) PURE; - /* No GetElement method as it would get overloaded - * in derived classes, and overloading is - * a no-no in COM - */ -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMObjectArray - -DECLARE_INTERFACE_(IDirect3DRMObjectArray, IDirect3DRMArray) -{ - IUNKNOWN_METHODS(PURE); - - STDMETHOD_(DWORD, GetSize)(THIS) PURE; - STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMOBJECT *) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMDeviceArray - -DECLARE_INTERFACE_(IDirect3DRMDeviceArray, IDirect3DRMArray) -{ - IUNKNOWN_METHODS(PURE); - - STDMETHOD_(DWORD, GetSize)(THIS) PURE; - STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMDEVICE *) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMFrameArray - -DECLARE_INTERFACE_(IDirect3DRMFrameArray, IDirect3DRMArray) -{ - IUNKNOWN_METHODS(PURE); - - STDMETHOD_(DWORD, GetSize)(THIS) PURE; - STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMFRAME *) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMViewportArray - -DECLARE_INTERFACE_(IDirect3DRMViewportArray, IDirect3DRMArray) -{ - IUNKNOWN_METHODS(PURE); - - STDMETHOD_(DWORD, GetSize)(THIS) PURE; - STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMVIEWPORT *) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMVisualArray - -DECLARE_INTERFACE_(IDirect3DRMVisualArray, IDirect3DRMArray) -{ - IUNKNOWN_METHODS(PURE); - - STDMETHOD_(DWORD, GetSize)(THIS) PURE; - STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMVISUAL *) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMAnimationArray - -DECLARE_INTERFACE_(IDirect3DRMAnimationArray, IDirect3DRMArray) -{ - IUNKNOWN_METHODS(PURE); - - STDMETHOD_(DWORD, GetSize)(THIS) PURE; - STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMANIMATION2 *) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMPickedArray - -DECLARE_INTERFACE_(IDirect3DRMPickedArray, IDirect3DRMArray) -{ - IUNKNOWN_METHODS(PURE); - - STDMETHOD_(DWORD, GetSize)(THIS) PURE; - STDMETHOD(GetPick)(THIS_ DWORD index, LPDIRECT3DRMVISUAL *, LPDIRECT3DRMFRAMEARRAY *, LPD3DRMPICKDESC) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMLightArray - -DECLARE_INTERFACE_(IDirect3DRMLightArray, IDirect3DRMArray) -{ - IUNKNOWN_METHODS(PURE); - - STDMETHOD_(DWORD, GetSize)(THIS) PURE; - STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMLIGHT *) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMFaceArray - -DECLARE_INTERFACE_(IDirect3DRMFaceArray, IDirect3DRMArray) -{ - IUNKNOWN_METHODS(PURE); - - STDMETHOD_(DWORD, GetSize)(THIS) PURE; - STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMFACE *) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMPicked2Array - -DECLARE_INTERFACE_(IDirect3DRMPicked2Array, IDirect3DRMArray) -{ - IUNKNOWN_METHODS(PURE); - - STDMETHOD_(DWORD, GetSize)(THIS) PURE; - STDMETHOD(GetPick)(THIS_ DWORD index, LPDIRECT3DRMVISUAL *, LPDIRECT3DRMFRAMEARRAY *, LPD3DRMPICKDESC2) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMInterpolator - -DECLARE_INTERFACE_(IDirect3DRMInterpolator, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMInterpolator methods - */ - STDMETHOD(AttachObject)(THIS_ LPDIRECT3DRMOBJECT) PURE; - STDMETHOD(GetAttachedObjects)(THIS_ LPDIRECT3DRMOBJECTARRAY *) PURE; - STDMETHOD(DetachObject)(THIS_ LPDIRECT3DRMOBJECT) PURE; - STDMETHOD(SetIndex)(THIS_ D3DVALUE) PURE; - STDMETHOD_(D3DVALUE, GetIndex)(THIS) PURE; - STDMETHOD(Interpolate)(THIS_ D3DVALUE, LPDIRECT3DRMOBJECT, D3DRMINTERPOLATIONOPTIONS) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirect3DRMClippedVisual - -DECLARE_INTERFACE_(IDirect3DRMClippedVisual, IDirect3DRMVisual) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMClippedVisual methods - */ - STDMETHOD(Init) (THIS_ LPDIRECT3DRMVISUAL) PURE; - STDMETHOD(AddPlane) (THIS_ LPDIRECT3DRMFRAME3, LPD3DVECTOR, LPD3DVECTOR, DWORD, LPDWORD) PURE; - STDMETHOD(DeletePlane)(THIS_ DWORD, DWORD) PURE; - STDMETHOD(GetPlaneIDs)(THIS_ LPDWORD, LPDWORD, DWORD) PURE; - STDMETHOD(GetPlane) (THIS_ DWORD, LPDIRECT3DRMFRAME3, LPD3DVECTOR, LPD3DVECTOR, DWORD) PURE; - STDMETHOD(SetPlane) (THIS_ DWORD, LPDIRECT3DRMFRAME3, LPD3DVECTOR, LPD3DVECTOR, DWORD) PURE; -}; - -#ifdef __cplusplus -}; -#endif -#endif /* _D3DRMOBJ_H_ */ - +/*==========================================================================; + * + * Copyright (c) Microsoft Corporation. All rights reserved. + * + * File: d3drm.h + * Content: Direct3DRM include file + * + ***************************************************************************/ + +#ifndef _D3DRMOBJ_H_ +#define _D3DRMOBJ_H_ + +#include /* Use Windows header files */ +#define VIRTUAL +#include "d3drmdef.h" + +#include "d3d.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The methods for IUnknown + */ +#define IUNKNOWN_METHODS(kind) \ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) kind; \ + STDMETHOD_(ULONG, AddRef) (THIS) kind; \ + STDMETHOD_(ULONG, Release) (THIS) kind + +/* + * The methods for IDirect3DRMObject + */ +#define IDIRECT3DRMOBJECT_METHODS(kind) \ + STDMETHOD(Clone) (THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) kind; \ + STDMETHOD(AddDestroyCallback) (THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) kind; \ + STDMETHOD(DeleteDestroyCallback) (THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) kind; \ + STDMETHOD(SetAppData) (THIS_ DWORD data) kind; \ + STDMETHOD_(DWORD, GetAppData) (THIS) kind; \ + STDMETHOD(SetName) (THIS_ LPCSTR) kind; \ + STDMETHOD(GetName) (THIS_ LPDWORD lpdwSize, LPSTR lpName) kind; \ + STDMETHOD(GetClassName) (THIS_ LPDWORD lpdwSize, LPSTR lpName) kind + + +#define WIN_TYPES(itype, ptype) \ + typedef interface itype FAR *LP##ptype, FAR **LPLP##ptype + +WIN_TYPES(IDirect3DRMObject, DIRECT3DRMOBJECT); +WIN_TYPES(IDirect3DRMObject2, DIRECT3DRMOBJECT2); +WIN_TYPES(IDirect3DRMDevice, DIRECT3DRMDEVICE); +WIN_TYPES(IDirect3DRMDevice2, DIRECT3DRMDEVICE2); +WIN_TYPES(IDirect3DRMDevice3, DIRECT3DRMDEVICE3); +WIN_TYPES(IDirect3DRMViewport, DIRECT3DRMVIEWPORT); +WIN_TYPES(IDirect3DRMViewport2, DIRECT3DRMVIEWPORT2); +WIN_TYPES(IDirect3DRMFrame, DIRECT3DRMFRAME); +WIN_TYPES(IDirect3DRMFrame2, DIRECT3DRMFRAME2); +WIN_TYPES(IDirect3DRMFrame3, DIRECT3DRMFRAME3); +WIN_TYPES(IDirect3DRMVisual, DIRECT3DRMVISUAL); +WIN_TYPES(IDirect3DRMMesh, DIRECT3DRMMESH); +WIN_TYPES(IDirect3DRMMeshBuilder, DIRECT3DRMMESHBUILDER); +WIN_TYPES(IDirect3DRMMeshBuilder2, DIRECT3DRMMESHBUILDER2); +WIN_TYPES(IDirect3DRMMeshBuilder3, DIRECT3DRMMESHBUILDER3); +WIN_TYPES(IDirect3DRMFace, DIRECT3DRMFACE); +WIN_TYPES(IDirect3DRMFace2, DIRECT3DRMFACE2); +WIN_TYPES(IDirect3DRMLight, DIRECT3DRMLIGHT); +WIN_TYPES(IDirect3DRMTexture, DIRECT3DRMTEXTURE); +WIN_TYPES(IDirect3DRMTexture2, DIRECT3DRMTEXTURE2); +WIN_TYPES(IDirect3DRMTexture3, DIRECT3DRMTEXTURE3); +WIN_TYPES(IDirect3DRMWrap, DIRECT3DRMWRAP); +WIN_TYPES(IDirect3DRMMaterial, DIRECT3DRMMATERIAL); +WIN_TYPES(IDirect3DRMMaterial2, DIRECT3DRMMATERIAL2); +WIN_TYPES(IDirect3DRMInterpolator, DIRECT3DRMINTERPOLATOR); +WIN_TYPES(IDirect3DRMAnimation, DIRECT3DRMANIMATION); +WIN_TYPES(IDirect3DRMAnimation2, DIRECT3DRMANIMATION2); +WIN_TYPES(IDirect3DRMAnimationSet, DIRECT3DRMANIMATIONSET); +WIN_TYPES(IDirect3DRMAnimationSet2, DIRECT3DRMANIMATIONSET2); +WIN_TYPES(IDirect3DRMUserVisual, DIRECT3DRMUSERVISUAL); +WIN_TYPES(IDirect3DRMShadow, DIRECT3DRMSHADOW); +WIN_TYPES(IDirect3DRMShadow2, DIRECT3DRMSHADOW2); +WIN_TYPES(IDirect3DRMArray, DIRECT3DRMARRAY); +WIN_TYPES(IDirect3DRMObjectArray, DIRECT3DRMOBJECTARRAY); +WIN_TYPES(IDirect3DRMDeviceArray, DIRECT3DRMDEVICEARRAY); +WIN_TYPES(IDirect3DRMFaceArray, DIRECT3DRMFACEARRAY); +WIN_TYPES(IDirect3DRMViewportArray, DIRECT3DRMVIEWPORTARRAY); +WIN_TYPES(IDirect3DRMFrameArray, DIRECT3DRMFRAMEARRAY); +WIN_TYPES(IDirect3DRMAnimationArray, DIRECT3DRMANIMATIONARRAY); +WIN_TYPES(IDirect3DRMVisualArray, DIRECT3DRMVISUALARRAY); +WIN_TYPES(IDirect3DRMPickedArray, DIRECT3DRMPICKEDARRAY); +WIN_TYPES(IDirect3DRMPicked2Array, DIRECT3DRMPICKED2ARRAY); +WIN_TYPES(IDirect3DRMLightArray, DIRECT3DRMLIGHTARRAY); +WIN_TYPES(IDirect3DRMProgressiveMesh, DIRECT3DRMPROGRESSIVEMESH); +WIN_TYPES(IDirect3DRMClippedVisual, DIRECT3DRMCLIPPEDVISUAL); + +/* + * Direct3DRM Object classes + */ +DEFINE_GUID(CLSID_CDirect3DRMDevice, 0x4fa3568e, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(CLSID_CDirect3DRMViewport, 0x4fa3568f, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(CLSID_CDirect3DRMFrame, 0x4fa35690, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(CLSID_CDirect3DRMMesh, 0x4fa35691, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(CLSID_CDirect3DRMMeshBuilder, 0x4fa35692, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(CLSID_CDirect3DRMFace, 0x4fa35693, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(CLSID_CDirect3DRMLight, 0x4fa35694, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(CLSID_CDirect3DRMTexture, 0x4fa35695, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(CLSID_CDirect3DRMWrap, 0x4fa35696, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(CLSID_CDirect3DRMMaterial, 0x4fa35697, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(CLSID_CDirect3DRMAnimation, 0x4fa35698, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(CLSID_CDirect3DRMAnimationSet, 0x4fa35699, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(CLSID_CDirect3DRMUserVisual, 0x4fa3569a, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(CLSID_CDirect3DRMShadow, 0x4fa3569b, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(CLSID_CDirect3DRMViewportInterpolator, +0xde9eaa1, 0x3b84, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(CLSID_CDirect3DRMFrameInterpolator, +0xde9eaa2, 0x3b84, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(CLSID_CDirect3DRMMeshInterpolator, +0xde9eaa3, 0x3b84, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(CLSID_CDirect3DRMLightInterpolator, +0xde9eaa6, 0x3b84, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(CLSID_CDirect3DRMMaterialInterpolator, +0xde9eaa7, 0x3b84, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(CLSID_CDirect3DRMTextureInterpolator, +0xde9eaa8, 0x3b84, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(CLSID_CDirect3DRMProgressiveMesh, 0x4516ec40, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(CLSID_CDirect3DRMClippedVisual, 0x5434e72d, 0x6d66, 0x11d1, 0xbb, 0xb, 0x0, 0x0, 0xf8, 0x75, 0x86, 0x5a); + + +/* + * Direct3DRM Object interfaces + */ +DEFINE_GUID(IID_IDirect3DRMObject, 0xeb16cb00, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMObject2, 0x4516ec7c, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(IID_IDirect3DRMDevice, 0xe9e19280, 0x6e05, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMDevice2, 0x4516ec78, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(IID_IDirect3DRMDevice3, 0x549f498b, 0xbfeb, 0x11d1, 0x8e, 0xd8, 0x0, 0xa0, 0xc9, 0x67, 0xa4, 0x82); +DEFINE_GUID(IID_IDirect3DRMViewport, 0xeb16cb02, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMViewport2, 0x4a1b1be6, 0xbfed, 0x11d1, 0x8e, 0xd8, 0x0, 0xa0, 0xc9, 0x67, 0xa4, 0x82); +DEFINE_GUID(IID_IDirect3DRMFrame, 0xeb16cb03, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMFrame2, 0xc3dfbd60, 0x3988, 0x11d0, 0x9e, 0xc2, 0x0, 0x0, 0xc0, 0x29, 0x1a, 0xc3); +DEFINE_GUID(IID_IDirect3DRMFrame3, 0xff6b7f70, 0xa40e, 0x11d1, 0x91, 0xf9, 0x0, 0x0, 0xf8, 0x75, 0x8e, 0x66); +DEFINE_GUID(IID_IDirect3DRMVisual, 0xeb16cb04, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMMesh, 0xa3a80d01, 0x6e12, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMMeshBuilder, 0xa3a80d02, 0x6e12, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMMeshBuilder2, 0x4516ec77, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(IID_IDirect3DRMMeshBuilder3, 0x4516ec82, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(IID_IDirect3DRMFace, 0xeb16cb07, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMFace2, 0x4516ec81, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(IID_IDirect3DRMLight, 0xeb16cb08, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMTexture, 0xeb16cb09, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMTexture2, 0x120f30c0, 0x1629, 0x11d0, 0x94, 0x1c, 0x0, 0x80, 0xc8, 0xc, 0xfa, 0x7b); +DEFINE_GUID(IID_IDirect3DRMTexture3, 0xff6b7f73, 0xa40e, 0x11d1, 0x91, 0xf9, 0x0, 0x0, 0xf8, 0x75, 0x8e, 0x66); +DEFINE_GUID(IID_IDirect3DRMWrap, 0xeb16cb0a, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMMaterial, 0xeb16cb0b, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMMaterial2, 0xff6b7f75, 0xa40e, 0x11d1, 0x91, 0xf9, 0x0, 0x0, 0xf8, 0x75, 0x8e, 0x66); +DEFINE_GUID(IID_IDirect3DRMAnimation, 0xeb16cb0d, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMAnimation2, 0xff6b7f77, 0xa40e, 0x11d1, 0x91, 0xf9, 0x0, 0x0, 0xf8, 0x75, 0x8e, 0x66); +DEFINE_GUID(IID_IDirect3DRMAnimationSet, 0xeb16cb0e, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMAnimationSet2, 0xff6b7f79, 0xa40e, 0x11d1, 0x91, 0xf9, 0x0, 0x0, 0xf8, 0x75, 0x8e, 0x66); +DEFINE_GUID(IID_IDirect3DRMObjectArray, 0x242f6bc2, 0x3849, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(IID_IDirect3DRMDeviceArray, 0xeb16cb10, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMViewportArray, 0xeb16cb11, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMFrameArray, 0xeb16cb12, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMVisualArray, 0xeb16cb13, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMLightArray, 0xeb16cb14, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMPickedArray, 0xeb16cb16, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMFaceArray, 0xeb16cb17, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMAnimationArray, +0xd5f1cae0, 0x4bd7, 0x11d1, 0xb9, 0x74, 0x0, 0x60, 0x8, 0x3e, 0x45, 0xf3); +DEFINE_GUID(IID_IDirect3DRMUserVisual, 0x59163de0, 0x6d43, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMShadow, 0xaf359780, 0x6ba3, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMShadow2, 0x86b44e25, 0x9c82, 0x11d1, 0xbb, 0xb, 0x0, 0xa0, 0xc9, 0x81, 0xa0, 0xa6); +DEFINE_GUID(IID_IDirect3DRMInterpolator, 0x242f6bc1, 0x3849, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(IID_IDirect3DRMProgressiveMesh, 0x4516ec79, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(IID_IDirect3DRMPicked2Array, 0x4516ec7b, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x0, 0x0, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(IID_IDirect3DRMClippedVisual, 0x5434e733, 0x6d66, 0x11d1, 0xbb, 0xb, 0x0, 0x0, 0xf8, 0x75, 0x86, 0x5a); + +typedef void (__cdecl *D3DRMOBJECTCALLBACK)(LPDIRECT3DRMOBJECT obj, LPVOID arg); +typedef void (__cdecl *D3DRMFRAMEMOVECALLBACK)(LPDIRECT3DRMFRAME obj, LPVOID arg, D3DVALUE delta); +typedef void (__cdecl *D3DRMFRAME3MOVECALLBACK)(LPDIRECT3DRMFRAME3 obj, LPVOID arg, D3DVALUE delta); +typedef void (__cdecl *D3DRMUPDATECALLBACK)(LPDIRECT3DRMDEVICE obj, LPVOID arg, int, LPD3DRECT); +typedef void (__cdecl *D3DRMDEVICE3UPDATECALLBACK)(LPDIRECT3DRMDEVICE3 obj, LPVOID arg, int, LPD3DRECT); +typedef int (__cdecl *D3DRMUSERVISUALCALLBACK) + ( LPDIRECT3DRMUSERVISUAL obj, LPVOID arg, D3DRMUSERVISUALREASON reason, + LPDIRECT3DRMDEVICE dev, LPDIRECT3DRMVIEWPORT view + ); +typedef HRESULT (__cdecl *D3DRMLOADTEXTURECALLBACK) + (char *tex_name, void *arg, LPDIRECT3DRMTEXTURE *); +typedef HRESULT (__cdecl *D3DRMLOADTEXTURE3CALLBACK) + (char *tex_name, void *arg, LPDIRECT3DRMTEXTURE3 *); +typedef void (__cdecl *D3DRMLOADCALLBACK) + (LPDIRECT3DRMOBJECT object, REFIID objectguid, LPVOID arg); + +typedef HRESULT (__cdecl *D3DRMDOWNSAMPLECALLBACK) + (LPDIRECT3DRMTEXTURE3 lpDirect3DRMTexture, LPVOID pArg, + LPDIRECTDRAWSURFACE pDDSSrc, LPDIRECTDRAWSURFACE pDDSDst); +typedef HRESULT (__cdecl *D3DRMVALIDATIONCALLBACK) + (LPDIRECT3DRMTEXTURE3 lpDirect3DRMTexture, LPVOID pArg, + DWORD dwFlags, DWORD dwcRects, LPRECT pRects); + + +typedef struct _D3DRMPICKDESC +{ + ULONG ulFaceIdx; + LONG lGroupIdx; + D3DVECTOR vPosition; + +} D3DRMPICKDESC, *LPD3DRMPICKDESC; + +typedef struct _D3DRMPICKDESC2 +{ + ULONG ulFaceIdx; + LONG lGroupIdx; + D3DVECTOR dvPosition; + D3DVALUE tu; + D3DVALUE tv; + D3DVECTOR dvNormal; + D3DCOLOR dcColor; + +} D3DRMPICKDESC2, *LPD3DRMPICKDESC2; + +#undef INTERFACE +#define INTERFACE IDirect3DRMObject + +/* + * Base class + */ +DECLARE_INTERFACE_(IDirect3DRMObject, IUnknown) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMObject2 + +DECLARE_INTERFACE_(IDirect3DRMObject2, IUnknown) +{ + IUNKNOWN_METHODS(PURE); + + /* + * IDirect3DRMObject2 methods + */ + STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK lpFunc, LPVOID pvArg) PURE; + STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE; \ + STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK lpFunc, LPVOID pvArg) PURE; \ + STDMETHOD(GetClientData)(THIS_ DWORD dwID, LPVOID* lplpvData) PURE; + STDMETHOD(GetDirect3DRM)(THIS_ LPDIRECT3DRM* lplpDirect3DRM) PURE; + STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE; + STDMETHOD(SetClientData)(THIS_ DWORD dwID, LPVOID lpvData, DWORD dwFlags) PURE; + STDMETHOD(SetName)(THIS_ LPCSTR lpName) PURE; + STDMETHOD(GetAge)(THIS_ DWORD dwFlags, LPDWORD pdwAge) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMVisual + +DECLARE_INTERFACE_(IDirect3DRMVisual, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMDevice + +DECLARE_INTERFACE_(IDirect3DRMDevice, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMDevice methods + */ + STDMETHOD(Init)(THIS_ ULONG width, ULONG height) PURE; + STDMETHOD(InitFromD3D)(THIS_ LPDIRECT3D lpD3D, LPDIRECT3DDEVICE lpD3DDev) PURE; + STDMETHOD(InitFromClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper, LPGUID lpGUID, int width, int height) PURE; + + STDMETHOD(Update)(THIS) PURE; + STDMETHOD(AddUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE; + STDMETHOD(DeleteUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE; + STDMETHOD(SetBufferCount)(THIS_ DWORD) PURE; + STDMETHOD_(DWORD, GetBufferCount)(THIS) PURE; + + STDMETHOD(SetDither)(THIS_ BOOL) PURE; + STDMETHOD(SetShades)(THIS_ DWORD) PURE; + STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE; + STDMETHOD(SetTextureQuality)(THIS_ D3DRMTEXTUREQUALITY) PURE; + + STDMETHOD(GetViewports)(THIS_ LPDIRECT3DRMVIEWPORTARRAY *return_views) PURE; + + STDMETHOD_(BOOL, GetDither)(THIS) PURE; + STDMETHOD_(DWORD, GetShades)(THIS) PURE; + STDMETHOD_(DWORD, GetHeight)(THIS) PURE; + STDMETHOD_(DWORD, GetWidth)(THIS) PURE; + STDMETHOD_(DWORD, GetTrianglesDrawn)(THIS) PURE; + STDMETHOD_(DWORD, GetWireframeOptions)(THIS) PURE; + STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE; + STDMETHOD_(D3DCOLORMODEL, GetColorModel)(THIS) PURE; + STDMETHOD_(D3DRMTEXTUREQUALITY, GetTextureQuality)(THIS) PURE; + STDMETHOD(GetDirect3DDevice)(THIS_ LPDIRECT3DDEVICE *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMDevice2 + +DECLARE_INTERFACE_(IDirect3DRMDevice2, IDirect3DRMDevice) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMDevice methods + */ + STDMETHOD(Init)(THIS_ ULONG width, ULONG height) PURE; + STDMETHOD(InitFromD3D)(THIS_ LPDIRECT3D lpD3D, LPDIRECT3DDEVICE lpD3DDev) PURE; + STDMETHOD(InitFromClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper, LPGUID lpGUID, int width, int height) PURE; + + STDMETHOD(Update)(THIS) PURE; + STDMETHOD(AddUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE; + STDMETHOD(DeleteUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE; + STDMETHOD(SetBufferCount)(THIS_ DWORD) PURE; + STDMETHOD_(DWORD, GetBufferCount)(THIS) PURE; + + STDMETHOD(SetDither)(THIS_ BOOL) PURE; + STDMETHOD(SetShades)(THIS_ DWORD) PURE; + STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE; + STDMETHOD(SetTextureQuality)(THIS_ D3DRMTEXTUREQUALITY) PURE; + + STDMETHOD(GetViewports)(THIS_ LPDIRECT3DRMVIEWPORTARRAY *return_views) PURE; + + STDMETHOD_(BOOL, GetDither)(THIS) PURE; + STDMETHOD_(DWORD, GetShades)(THIS) PURE; + STDMETHOD_(DWORD, GetHeight)(THIS) PURE; + STDMETHOD_(DWORD, GetWidth)(THIS) PURE; + STDMETHOD_(DWORD, GetTrianglesDrawn)(THIS) PURE; + STDMETHOD_(DWORD, GetWireframeOptions)(THIS) PURE; + STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE; + STDMETHOD_(D3DCOLORMODEL, GetColorModel)(THIS) PURE; + STDMETHOD_(D3DRMTEXTUREQUALITY, GetTextureQuality)(THIS) PURE; + STDMETHOD(GetDirect3DDevice)(THIS_ LPDIRECT3DDEVICE *) PURE; + + /* + * IDirect3DRMDevice2 methods + */ + STDMETHOD(InitFromD3D2)(THIS_ LPDIRECT3D2 lpD3D, LPDIRECT3DDEVICE2 lpD3DDev) PURE; + STDMETHOD(InitFromSurface)(THIS_ LPGUID lpGUID, LPDIRECTDRAW lpDD, LPDIRECTDRAWSURFACE lpDDSBack) PURE; + STDMETHOD(SetRenderMode)(THIS_ DWORD dwFlags) PURE; + STDMETHOD_(DWORD, GetRenderMode)(THIS) PURE; + STDMETHOD(GetDirect3DDevice2)(THIS_ LPDIRECT3DDEVICE2 *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMDevice3 + +DECLARE_INTERFACE_(IDirect3DRMDevice3, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMDevice methods + */ + STDMETHOD(Init)(THIS_ ULONG width, ULONG height) PURE; + STDMETHOD(InitFromD3D)(THIS_ LPDIRECT3D lpD3D, LPDIRECT3DDEVICE lpD3DDev) PURE; + STDMETHOD(InitFromClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper, LPGUID lpGUID, int width, int height) PURE; + + STDMETHOD(Update)(THIS) PURE; + STDMETHOD(AddUpdateCallback)(THIS_ D3DRMDEVICE3UPDATECALLBACK, LPVOID arg) PURE; + STDMETHOD(DeleteUpdateCallback)(THIS_ D3DRMDEVICE3UPDATECALLBACK, LPVOID arg) PURE; + STDMETHOD(SetBufferCount)(THIS_ DWORD) PURE; + STDMETHOD_(DWORD, GetBufferCount)(THIS) PURE; + + STDMETHOD(SetDither)(THIS_ BOOL) PURE; + STDMETHOD(SetShades)(THIS_ DWORD) PURE; + STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE; + STDMETHOD(SetTextureQuality)(THIS_ D3DRMTEXTUREQUALITY) PURE; + + STDMETHOD(GetViewports)(THIS_ LPDIRECT3DRMVIEWPORTARRAY *return_views) PURE; + + STDMETHOD_(BOOL, GetDither)(THIS) PURE; + STDMETHOD_(DWORD, GetShades)(THIS) PURE; + STDMETHOD_(DWORD, GetHeight)(THIS) PURE; + STDMETHOD_(DWORD, GetWidth)(THIS) PURE; + STDMETHOD_(DWORD, GetTrianglesDrawn)(THIS) PURE; + STDMETHOD_(DWORD, GetWireframeOptions)(THIS) PURE; + STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE; + STDMETHOD_(D3DCOLORMODEL, GetColorModel)(THIS) PURE; + STDMETHOD_(D3DRMTEXTUREQUALITY, GetTextureQuality)(THIS) PURE; + STDMETHOD(GetDirect3DDevice)(THIS_ LPDIRECT3DDEVICE *) PURE; + + /* + * IDirect3DRMDevice2 methods + */ + STDMETHOD(InitFromD3D2)(THIS_ LPDIRECT3D2 lpD3D, LPDIRECT3DDEVICE2 lpD3DDev) PURE; + STDMETHOD(InitFromSurface)(THIS_ LPGUID lpGUID, LPDIRECTDRAW lpDD, LPDIRECTDRAWSURFACE lpDDSBack, DWORD dwFlags) PURE; + STDMETHOD(SetRenderMode)(THIS_ DWORD dwFlags) PURE; + STDMETHOD_(DWORD, GetRenderMode)(THIS) PURE; + STDMETHOD(GetDirect3DDevice2)(THIS_ LPDIRECT3DDEVICE2 *) PURE; + + /* + * IDirect3DRMDevice3 methods + */ + STDMETHOD(FindPreferredTextureFormat)(THIS_ DWORD dwBitDepths, DWORD dwFlags, LPDDPIXELFORMAT lpDDPF) PURE; + STDMETHOD(RenderStateChange)(THIS_ D3DRENDERSTATETYPE drsType, DWORD dwVal, DWORD dwFlags) PURE; + STDMETHOD(LightStateChange)(THIS_ D3DLIGHTSTATETYPE drsType, DWORD dwVal, DWORD dwFlags) PURE; + STDMETHOD(GetStateChangeOptions)(THIS_ DWORD dwStateClass, DWORD dwStateNum, LPDWORD pdwFlags) PURE; + STDMETHOD(SetStateChangeOptions)(THIS_ DWORD dwStateClass, DWORD dwStateNum, DWORD dwFlags) PURE; +}; + + +#undef INTERFACE +#define INTERFACE IDirect3DRMViewport + +DECLARE_INTERFACE_(IDirect3DRMViewport, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMViewport methods + */ + STDMETHOD(Init) + ( THIS_ LPDIRECT3DRMDEVICE dev, LPDIRECT3DRMFRAME camera, + DWORD xpos, DWORD ypos, DWORD width, DWORD height + ) PURE; + STDMETHOD(Clear)(THIS) PURE; + STDMETHOD(Render)(THIS_ LPDIRECT3DRMFRAME) PURE; + + STDMETHOD(SetFront)(THIS_ D3DVALUE) PURE; + STDMETHOD(SetBack)(THIS_ D3DVALUE) PURE; + STDMETHOD(SetField)(THIS_ D3DVALUE) PURE; + STDMETHOD(SetUniformScaling)(THIS_ BOOL) PURE; + STDMETHOD(SetCamera)(THIS_ LPDIRECT3DRMFRAME) PURE; + STDMETHOD(SetProjection)(THIS_ D3DRMPROJECTIONTYPE) PURE; + STDMETHOD(Transform)(THIS_ D3DRMVECTOR4D *d, D3DVECTOR *s) PURE; + STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DRMVECTOR4D *s) PURE; + STDMETHOD(Configure)(THIS_ LONG x, LONG y, DWORD width, DWORD height) PURE; + STDMETHOD(ForceUpdate)(THIS_ DWORD x1, DWORD y1, DWORD x2, DWORD y2) PURE; + STDMETHOD(SetPlane)(THIS_ D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top) PURE; + + STDMETHOD(GetCamera)(THIS_ LPDIRECT3DRMFRAME *) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DRMDEVICE *) PURE; + STDMETHOD(GetPlane)(THIS_ D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top) PURE; + STDMETHOD(Pick)(THIS_ LONG x, LONG y, LPDIRECT3DRMPICKEDARRAY *return_visuals) PURE; + + STDMETHOD_(BOOL, GetUniformScaling)(THIS) PURE; + STDMETHOD_(LONG, GetX)(THIS) PURE; + STDMETHOD_(LONG, GetY)(THIS) PURE; + STDMETHOD_(DWORD, GetWidth)(THIS) PURE; + STDMETHOD_(DWORD, GetHeight)(THIS) PURE; + STDMETHOD_(D3DVALUE, GetField)(THIS) PURE; + STDMETHOD_(D3DVALUE, GetBack)(THIS) PURE; + STDMETHOD_(D3DVALUE, GetFront)(THIS) PURE; + STDMETHOD_(D3DRMPROJECTIONTYPE, GetProjection)(THIS) PURE; + STDMETHOD(GetDirect3DViewport)(THIS_ LPDIRECT3DVIEWPORT *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMViewport2 +DECLARE_INTERFACE_(IDirect3DRMViewport2, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMViewport2 methods + */ + STDMETHOD(Init) + ( THIS_ LPDIRECT3DRMDEVICE3 dev, LPDIRECT3DRMFRAME3 camera, + DWORD xpos, DWORD ypos, DWORD width, DWORD height + ) PURE; + STDMETHOD(Clear)(THIS_ DWORD dwFlags) PURE; + STDMETHOD(Render)(THIS_ LPDIRECT3DRMFRAME3) PURE; + + STDMETHOD(SetFront)(THIS_ D3DVALUE) PURE; + STDMETHOD(SetBack)(THIS_ D3DVALUE) PURE; + STDMETHOD(SetField)(THIS_ D3DVALUE) PURE; + STDMETHOD(SetUniformScaling)(THIS_ BOOL) PURE; + STDMETHOD(SetCamera)(THIS_ LPDIRECT3DRMFRAME3) PURE; + STDMETHOD(SetProjection)(THIS_ D3DRMPROJECTIONTYPE) PURE; + STDMETHOD(Transform)(THIS_ D3DRMVECTOR4D *d, D3DVECTOR *s) PURE; + STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DRMVECTOR4D *s) PURE; + STDMETHOD(Configure)(THIS_ LONG x, LONG y, DWORD width, DWORD height) PURE; + STDMETHOD(ForceUpdate)(THIS_ DWORD x1, DWORD y1, DWORD x2, DWORD y2) PURE; + STDMETHOD(SetPlane)(THIS_ D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top) PURE; + + STDMETHOD(GetCamera)(THIS_ LPDIRECT3DRMFRAME3 *) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DRMDEVICE3 *) PURE; + STDMETHOD(GetPlane)(THIS_ D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top) PURE; + STDMETHOD(Pick)(THIS_ LONG x, LONG y, LPDIRECT3DRMPICKEDARRAY *return_visuals) PURE; + + STDMETHOD_(BOOL, GetUniformScaling)(THIS) PURE; + STDMETHOD_(LONG, GetX)(THIS) PURE; + STDMETHOD_(LONG, GetY)(THIS) PURE; + STDMETHOD_(DWORD, GetWidth)(THIS) PURE; + STDMETHOD_(DWORD, GetHeight)(THIS) PURE; + STDMETHOD_(D3DVALUE, GetField)(THIS) PURE; + STDMETHOD_(D3DVALUE, GetBack)(THIS) PURE; + STDMETHOD_(D3DVALUE, GetFront)(THIS) PURE; + STDMETHOD_(D3DRMPROJECTIONTYPE, GetProjection)(THIS) PURE; + STDMETHOD(GetDirect3DViewport)(THIS_ LPDIRECT3DVIEWPORT *) PURE; + STDMETHOD(TransformVectors)(THIS_ DWORD dwNumVectors, + LPD3DRMVECTOR4D lpDstVectors, + LPD3DVECTOR lpSrcVectors) PURE; + STDMETHOD(InverseTransformVectors)(THIS_ DWORD dwNumVectors, + LPD3DVECTOR lpDstVectors, + LPD3DRMVECTOR4D lpSrcVectors) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMFrame + +DECLARE_INTERFACE_(IDirect3DRMFrame, IDirect3DRMVisual) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMFrame methods + */ + STDMETHOD(AddChild)(THIS_ LPDIRECT3DRMFRAME child) PURE; + STDMETHOD(AddLight)(THIS_ LPDIRECT3DRMLIGHT) PURE; + STDMETHOD(AddMoveCallback)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg) PURE; + STDMETHOD(AddTransform)(THIS_ D3DRMCOMBINETYPE, D3DRMMATRIX4D) PURE; + STDMETHOD(AddTranslation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(AddScale)(THIS_ D3DRMCOMBINETYPE, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE; + STDMETHOD(AddRotation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE; + STDMETHOD(AddVisual)(THIS_ LPDIRECT3DRMVISUAL) PURE; + STDMETHOD(GetChildren)(THIS_ LPDIRECT3DRMFRAMEARRAY *children) PURE; + STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE; + STDMETHOD(GetLights)(THIS_ LPDIRECT3DRMLIGHTARRAY *lights) PURE; + STDMETHOD_(D3DRMMATERIALMODE, GetMaterialMode)(THIS) PURE; + STDMETHOD(GetParent)(THIS_ LPDIRECT3DRMFRAME *) PURE; + STDMETHOD(GetPosition)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR return_position) PURE; + STDMETHOD(GetRotation)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR axis, LPD3DVALUE return_theta) PURE; + STDMETHOD(GetScene)(THIS_ LPDIRECT3DRMFRAME *) PURE; + STDMETHOD_(D3DRMSORTMODE, GetSortMode)(THIS) PURE; + STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE *) PURE; + STDMETHOD(GetTransform)(THIS_ D3DRMMATRIX4D return_matrix) PURE; + STDMETHOD(GetVelocity)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR return_velocity, BOOL with_rotation) PURE; + STDMETHOD(GetOrientation)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR dir, LPD3DVECTOR up) PURE; + STDMETHOD(GetVisuals)(THIS_ LPDIRECT3DRMVISUALARRAY *visuals) PURE; + STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE; + STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE; + STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID lpArg)PURE; + STDMETHOD(LookAt)(THIS_ LPDIRECT3DRMFRAME target, LPDIRECT3DRMFRAME reference, D3DRMFRAMECONSTRAINT) PURE; + STDMETHOD(Move)(THIS_ D3DVALUE delta) PURE; + STDMETHOD(DeleteChild)(THIS_ LPDIRECT3DRMFRAME) PURE; + STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DRMLIGHT) PURE; + STDMETHOD(DeleteMoveCallback)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg) PURE; + STDMETHOD(DeleteVisual)(THIS_ LPDIRECT3DRMVISUAL) PURE; + STDMETHOD_(D3DCOLOR, GetSceneBackground)(THIS) PURE; + STDMETHOD(GetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE *) PURE; + STDMETHOD_(D3DCOLOR, GetSceneFogColor)(THIS) PURE; + STDMETHOD_(BOOL, GetSceneFogEnable)(THIS) PURE; + STDMETHOD_(D3DRMFOGMODE, GetSceneFogMode)(THIS) PURE; + STDMETHOD(GetSceneFogParams)(THIS_ D3DVALUE *return_start, D3DVALUE *return_end, D3DVALUE *return_density) PURE; + STDMETHOD(SetSceneBackground)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetSceneBackgroundRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; + STDMETHOD(SetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE; + STDMETHOD(SetSceneBackgroundImage)(THIS_ LPDIRECT3DRMTEXTURE) PURE; + STDMETHOD(SetSceneFogEnable)(THIS_ BOOL) PURE; + STDMETHOD(SetSceneFogColor)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetSceneFogMode)(THIS_ D3DRMFOGMODE) PURE; + STDMETHOD(SetSceneFogParams)(THIS_ D3DVALUE start, D3DVALUE end, D3DVALUE density) PURE; + STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; + STDMETHOD_(D3DRMZBUFFERMODE, GetZbufferMode)(THIS) PURE; + STDMETHOD(SetMaterialMode)(THIS_ D3DRMMATERIALMODE) PURE; + STDMETHOD(SetOrientation) + ( THIS_ LPDIRECT3DRMFRAME reference, + D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, + D3DVALUE ux, D3DVALUE uy, D3DVALUE uz + ) PURE; + STDMETHOD(SetPosition)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(SetRotation)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE; + STDMETHOD(SetSortMode)(THIS_ D3DRMSORTMODE) PURE; + STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE; + STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; + STDMETHOD(SetVelocity)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, BOOL with_rotation) PURE; + STDMETHOD(SetZbufferMode)(THIS_ D3DRMZBUFFERMODE) PURE; + STDMETHOD(Transform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMFrame2 + +DECLARE_INTERFACE_(IDirect3DRMFrame2, IDirect3DRMFrame) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMFrame methods + */ + STDMETHOD(AddChild)(THIS_ LPDIRECT3DRMFRAME child) PURE; + STDMETHOD(AddLight)(THIS_ LPDIRECT3DRMLIGHT) PURE; + STDMETHOD(AddMoveCallback)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg) PURE; + STDMETHOD(AddTransform)(THIS_ D3DRMCOMBINETYPE, D3DRMMATRIX4D) PURE; + STDMETHOD(AddTranslation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(AddScale)(THIS_ D3DRMCOMBINETYPE, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE; + STDMETHOD(AddRotation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE; + STDMETHOD(AddVisual)(THIS_ LPDIRECT3DRMVISUAL) PURE; + STDMETHOD(GetChildren)(THIS_ LPDIRECT3DRMFRAMEARRAY *children) PURE; + STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE; + STDMETHOD(GetLights)(THIS_ LPDIRECT3DRMLIGHTARRAY *lights) PURE; + STDMETHOD_(D3DRMMATERIALMODE, GetMaterialMode)(THIS) PURE; + STDMETHOD(GetParent)(THIS_ LPDIRECT3DRMFRAME *) PURE; + STDMETHOD(GetPosition)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR return_position) PURE; + STDMETHOD(GetRotation)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR axis, LPD3DVALUE return_theta) PURE; + STDMETHOD(GetScene)(THIS_ LPDIRECT3DRMFRAME *) PURE; + STDMETHOD_(D3DRMSORTMODE, GetSortMode)(THIS) PURE; + STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE *) PURE; + STDMETHOD(GetTransform)(THIS_ D3DRMMATRIX4D return_matrix) PURE; + STDMETHOD(GetVelocity)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR return_velocity, BOOL with_rotation) PURE; + STDMETHOD(GetOrientation)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR dir, LPD3DVECTOR up) PURE; + STDMETHOD(GetVisuals)(THIS_ LPDIRECT3DRMVISUALARRAY *visuals) PURE; + STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE; + STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE; + STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID lpArg)PURE; + STDMETHOD(LookAt)(THIS_ LPDIRECT3DRMFRAME target, LPDIRECT3DRMFRAME reference, D3DRMFRAMECONSTRAINT) PURE; + STDMETHOD(Move)(THIS_ D3DVALUE delta) PURE; + STDMETHOD(DeleteChild)(THIS_ LPDIRECT3DRMFRAME) PURE; + STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DRMLIGHT) PURE; + STDMETHOD(DeleteMoveCallback)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg) PURE; + STDMETHOD(DeleteVisual)(THIS_ LPDIRECT3DRMVISUAL) PURE; + STDMETHOD_(D3DCOLOR, GetSceneBackground)(THIS) PURE; + STDMETHOD(GetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE *) PURE; + STDMETHOD_(D3DCOLOR, GetSceneFogColor)(THIS) PURE; + STDMETHOD_(BOOL, GetSceneFogEnable)(THIS) PURE; + STDMETHOD_(D3DRMFOGMODE, GetSceneFogMode)(THIS) PURE; + STDMETHOD(GetSceneFogParams)(THIS_ D3DVALUE *return_start, D3DVALUE *return_end, D3DVALUE *return_density) PURE; + STDMETHOD(SetSceneBackground)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetSceneBackgroundRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; + STDMETHOD(SetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE; + STDMETHOD(SetSceneBackgroundImage)(THIS_ LPDIRECT3DRMTEXTURE) PURE; + STDMETHOD(SetSceneFogEnable)(THIS_ BOOL) PURE; + STDMETHOD(SetSceneFogColor)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetSceneFogMode)(THIS_ D3DRMFOGMODE) PURE; + STDMETHOD(SetSceneFogParams)(THIS_ D3DVALUE start, D3DVALUE end, D3DVALUE density) PURE; + STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; + STDMETHOD_(D3DRMZBUFFERMODE, GetZbufferMode)(THIS) PURE; + STDMETHOD(SetMaterialMode)(THIS_ D3DRMMATERIALMODE) PURE; + STDMETHOD(SetOrientation) + ( THIS_ LPDIRECT3DRMFRAME reference, + D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, + D3DVALUE ux, D3DVALUE uy, D3DVALUE uz + ) PURE; + STDMETHOD(SetPosition)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(SetRotation)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE; + STDMETHOD(SetSortMode)(THIS_ D3DRMSORTMODE) PURE; + STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE; + STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; + STDMETHOD(SetVelocity)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, BOOL with_rotation) PURE; + STDMETHOD(SetZbufferMode)(THIS_ D3DRMZBUFFERMODE) PURE; + STDMETHOD(Transform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE; + + /* + * IDirect3DRMFrame2 methods + */ + STDMETHOD(AddMoveCallback2)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg, DWORD dwFlags) PURE; + STDMETHOD(GetBox)(THIS_ LPD3DRMBOX) PURE; + STDMETHOD_(BOOL, GetBoxEnable)(THIS) PURE; + STDMETHOD(GetAxes)(THIS_ LPD3DVECTOR dir, LPD3DVECTOR up); + STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL *) PURE; + STDMETHOD_(BOOL, GetInheritAxes)(THIS); + STDMETHOD(GetHierarchyBox)(THIS_ LPD3DRMBOX) PURE; + + STDMETHOD(SetBox)(THIS_ LPD3DRMBOX) PURE; + STDMETHOD(SetBoxEnable)(THIS_ BOOL) PURE; + STDMETHOD(SetAxes)(THIS_ D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, + D3DVALUE ux, D3DVALUE uy, D3DVALUE uz); + STDMETHOD(SetInheritAxes)(THIS_ BOOL inherit_from_parent); + STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL) PURE; + STDMETHOD(SetQuaternion)(THIS_ LPDIRECT3DRMFRAME reference, D3DRMQUATERNION *q) PURE; + + STDMETHOD(RayPick)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DRMRAY ray, DWORD dwFlags, LPDIRECT3DRMPICKED2ARRAY *return_visuals) PURE; + STDMETHOD(Save)(THIS_ LPCSTR filename, D3DRMXOFFORMAT d3dFormat, + D3DRMSAVEOPTIONS d3dSaveFlags); +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMFrame3 + +DECLARE_INTERFACE_(IDirect3DRMFrame3, IDirect3DRMVisual) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMFrame3 methods + */ + STDMETHOD(AddChild)(THIS_ LPDIRECT3DRMFRAME3 child) PURE; + STDMETHOD(AddLight)(THIS_ LPDIRECT3DRMLIGHT) PURE; + STDMETHOD(AddMoveCallback)(THIS_ D3DRMFRAME3MOVECALLBACK, VOID *arg, DWORD dwFlags) PURE; + STDMETHOD(AddTransform)(THIS_ D3DRMCOMBINETYPE, D3DRMMATRIX4D) PURE; + STDMETHOD(AddTranslation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(AddScale)(THIS_ D3DRMCOMBINETYPE, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE; + STDMETHOD(AddRotation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE; + STDMETHOD(AddVisual)(THIS_ LPUNKNOWN) PURE; + STDMETHOD(GetChildren)(THIS_ LPDIRECT3DRMFRAMEARRAY *children) PURE; + STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE; + STDMETHOD(GetLights)(THIS_ LPDIRECT3DRMLIGHTARRAY *lights) PURE; + STDMETHOD_(D3DRMMATERIALMODE, GetMaterialMode)(THIS) PURE; + STDMETHOD(GetParent)(THIS_ LPDIRECT3DRMFRAME3 *) PURE; + STDMETHOD(GetPosition)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DVECTOR return_position) PURE; + STDMETHOD(GetRotation)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DVECTOR axis, LPD3DVALUE return_theta) PURE; + STDMETHOD(GetScene)(THIS_ LPDIRECT3DRMFRAME3 *) PURE; + STDMETHOD_(D3DRMSORTMODE, GetSortMode)(THIS) PURE; + STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE3 *) PURE; + STDMETHOD(GetTransform)(THIS_ LPDIRECT3DRMFRAME3 reference, + D3DRMMATRIX4D rmMatrix) PURE; + STDMETHOD(GetVelocity)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DVECTOR return_velocity, BOOL with_rotation) PURE; + STDMETHOD(GetOrientation)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DVECTOR dir, LPD3DVECTOR up) PURE; + STDMETHOD(GetVisuals)(THIS_ LPDWORD lpdwCount, LPUNKNOWN *) PURE; + STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE; + STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURE3CALLBACK, LPVOID lpArg)PURE; + STDMETHOD(LookAt)(THIS_ LPDIRECT3DRMFRAME3 target, LPDIRECT3DRMFRAME3 reference, D3DRMFRAMECONSTRAINT) PURE; + STDMETHOD(Move)(THIS_ D3DVALUE delta) PURE; + STDMETHOD(DeleteChild)(THIS_ LPDIRECT3DRMFRAME3) PURE; + STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DRMLIGHT) PURE; + STDMETHOD(DeleteMoveCallback)(THIS_ D3DRMFRAME3MOVECALLBACK, VOID *arg) PURE; + STDMETHOD(DeleteVisual)(THIS_ LPUNKNOWN) PURE; + STDMETHOD_(D3DCOLOR, GetSceneBackground)(THIS) PURE; + STDMETHOD(GetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE *) PURE; + STDMETHOD_(D3DCOLOR, GetSceneFogColor)(THIS) PURE; + STDMETHOD_(BOOL, GetSceneFogEnable)(THIS) PURE; + STDMETHOD_(D3DRMFOGMODE, GetSceneFogMode)(THIS) PURE; + STDMETHOD(GetSceneFogParams)(THIS_ D3DVALUE *return_start, D3DVALUE *return_end, D3DVALUE *return_density) PURE; + STDMETHOD(SetSceneBackground)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetSceneBackgroundRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; + STDMETHOD(SetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE; + STDMETHOD(SetSceneBackgroundImage)(THIS_ LPDIRECT3DRMTEXTURE3) PURE; + STDMETHOD(SetSceneFogEnable)(THIS_ BOOL) PURE; + STDMETHOD(SetSceneFogColor)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetSceneFogMode)(THIS_ D3DRMFOGMODE) PURE; + STDMETHOD(SetSceneFogParams)(THIS_ D3DVALUE start, D3DVALUE end, D3DVALUE density) PURE; + STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; + STDMETHOD_(D3DRMZBUFFERMODE, GetZbufferMode)(THIS) PURE; + STDMETHOD(SetMaterialMode)(THIS_ D3DRMMATERIALMODE) PURE; + STDMETHOD(SetOrientation) + ( THIS_ LPDIRECT3DRMFRAME3 reference, + D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, + D3DVALUE ux, D3DVALUE uy, D3DVALUE uz + ) PURE; + STDMETHOD(SetPosition)(THIS_ LPDIRECT3DRMFRAME3 reference, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(SetRotation)(THIS_ LPDIRECT3DRMFRAME3 reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE; + STDMETHOD(SetSortMode)(THIS_ D3DRMSORTMODE) PURE; + STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE3) PURE; + STDMETHOD(SetVelocity)(THIS_ LPDIRECT3DRMFRAME3 reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, BOOL with_rotation) PURE; + STDMETHOD(SetZbufferMode)(THIS_ D3DRMZBUFFERMODE) PURE; + STDMETHOD(Transform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE; + STDMETHOD(GetBox)(THIS_ LPD3DRMBOX) PURE; + STDMETHOD_(BOOL, GetBoxEnable)(THIS) PURE; + STDMETHOD(GetAxes)(THIS_ LPD3DVECTOR dir, LPD3DVECTOR up); + STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2 *) PURE; + STDMETHOD_(BOOL, GetInheritAxes)(THIS); + STDMETHOD(GetHierarchyBox)(THIS_ LPD3DRMBOX) PURE; + + STDMETHOD(SetBox)(THIS_ LPD3DRMBOX) PURE; + STDMETHOD(SetBoxEnable)(THIS_ BOOL) PURE; + STDMETHOD(SetAxes)(THIS_ D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, + D3DVALUE ux, D3DVALUE uy, D3DVALUE uz); + STDMETHOD(SetInheritAxes)(THIS_ BOOL inherit_from_parent); + STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2) PURE; + STDMETHOD(SetQuaternion)(THIS_ LPDIRECT3DRMFRAME3 reference, D3DRMQUATERNION *q) PURE; + + STDMETHOD(RayPick)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DRMRAY ray, DWORD dwFlags, LPDIRECT3DRMPICKED2ARRAY *return_visuals) PURE; + STDMETHOD(Save)(THIS_ LPCSTR filename, D3DRMXOFFORMAT d3dFormat, + D3DRMSAVEOPTIONS d3dSaveFlags); + STDMETHOD(TransformVectors)(THIS_ LPDIRECT3DRMFRAME3 reference, + DWORD dwNumVectors, + LPD3DVECTOR lpDstVectors, + LPD3DVECTOR lpSrcVectors) PURE; + STDMETHOD(InverseTransformVectors)(THIS_ LPDIRECT3DRMFRAME3 reference, + DWORD dwNumVectors, + LPD3DVECTOR lpDstVectors, + LPD3DVECTOR lpSrcVectors) PURE; + STDMETHOD(SetTraversalOptions)(THIS_ DWORD dwFlags) PURE; + STDMETHOD(GetTraversalOptions)(THIS_ LPDWORD lpdwFlags) PURE; + STDMETHOD(SetSceneFogMethod)(THIS_ DWORD dwFlags) PURE; + STDMETHOD(GetSceneFogMethod)(THIS_ LPDWORD lpdwFlags) PURE; + STDMETHOD(SetMaterialOverride)(THIS_ LPD3DRMMATERIALOVERRIDE) PURE; + STDMETHOD(GetMaterialOverride)(THIS_ LPD3DRMMATERIALOVERRIDE) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMMesh + +DECLARE_INTERFACE_(IDirect3DRMMesh, IDirect3DRMVisual) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMMesh methods + */ + STDMETHOD(Scale)(THIS_ D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE; + STDMETHOD(Translate)(THIS_ D3DVALUE tx, D3DVALUE ty, D3DVALUE tz) PURE; + STDMETHOD(GetBox)(THIS_ D3DRMBOX *) PURE; + STDMETHOD(AddGroup)(THIS_ unsigned vCount, unsigned fCount, unsigned vPerFace, unsigned *fData, D3DRMGROUPINDEX *returnId) PURE; + STDMETHOD(SetVertices)(THIS_ D3DRMGROUPINDEX id, unsigned index, unsigned count, D3DRMVERTEX *values) PURE; + STDMETHOD(SetGroupColor)(THIS_ D3DRMGROUPINDEX id, D3DCOLOR value) PURE; + STDMETHOD(SetGroupColorRGB)(THIS_ D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; + STDMETHOD(SetGroupMapping)(THIS_ D3DRMGROUPINDEX id, D3DRMMAPPING value) PURE; + STDMETHOD(SetGroupQuality)(THIS_ D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value) PURE; + STDMETHOD(SetGroupMaterial)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL value) PURE; + STDMETHOD(SetGroupTexture)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE value) PURE; + + STDMETHOD_(unsigned, GetGroupCount)(THIS) PURE; + STDMETHOD(GetGroup)(THIS_ D3DRMGROUPINDEX id, unsigned *vCount, unsigned *fCount, unsigned *vPerFace, DWORD *fDataSize, unsigned *fData) PURE; + STDMETHOD(GetVertices)(THIS_ D3DRMGROUPINDEX id, DWORD index, DWORD count, D3DRMVERTEX *returnPtr) PURE; + STDMETHOD_(D3DCOLOR, GetGroupColor)(THIS_ D3DRMGROUPINDEX id) PURE; + STDMETHOD_(D3DRMMAPPING, GetGroupMapping)(THIS_ D3DRMGROUPINDEX id) PURE; + STDMETHOD_(D3DRMRENDERQUALITY, GetGroupQuality)(THIS_ D3DRMGROUPINDEX id) PURE; + STDMETHOD(GetGroupMaterial)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL *returnPtr) PURE; + STDMETHOD(GetGroupTexture)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE *returnPtr) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMProgressiveMesh + +DECLARE_INTERFACE_(IDirect3DRMProgressiveMesh, IDirect3DRMVisual) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMProgressiveMesh methods + */ + STDMETHOD(Load) (THIS_ LPVOID lpObjLocation, LPVOID lpObjId, + D3DRMLOADOPTIONS dloLoadflags, D3DRMLOADTEXTURECALLBACK lpCallback, + LPVOID lpArg) PURE; + STDMETHOD(GetLoadStatus) (THIS_ LPD3DRMPMESHLOADSTATUS lpStatus) PURE; + STDMETHOD(SetMinRenderDetail) (THIS_ D3DVALUE d3dVal) PURE; + STDMETHOD(Abort) (THIS_ DWORD dwFlags) PURE; + + STDMETHOD(GetFaceDetail) (THIS_ LPDWORD lpdwCount) PURE; + STDMETHOD(GetVertexDetail) (THIS_ LPDWORD lpdwCount) PURE; + STDMETHOD(SetFaceDetail) (THIS_ DWORD dwCount) PURE; + STDMETHOD(SetVertexDetail) (THIS_ DWORD dwCount) PURE; + STDMETHOD(GetFaceDetailRange) (THIS_ LPDWORD lpdwMin, LPDWORD lpdwMax) PURE; + STDMETHOD(GetVertexDetailRange) (THIS_ LPDWORD lpdwMin, LPDWORD lpdwMax) PURE; + STDMETHOD(GetDetail) (THIS_ D3DVALUE *lpdvVal) PURE; + STDMETHOD(SetDetail) (THIS_ D3DVALUE d3dVal) PURE; + + STDMETHOD(RegisterEvents) (THIS_ HANDLE hEvent, DWORD dwFlags, DWORD dwReserved) PURE; + STDMETHOD(CreateMesh) (THIS_ LPDIRECT3DRMMESH *lplpD3DRMMesh) PURE; + STDMETHOD(Duplicate) (THIS_ LPDIRECT3DRMPROGRESSIVEMESH *lplpD3DRMPMesh) PURE; + STDMETHOD(GetBox) (THIS_ LPD3DRMBOX lpBBox) PURE; + STDMETHOD(SetQuality) (THIS_ D3DRMRENDERQUALITY) PURE; + STDMETHOD(GetQuality) (THIS_ LPD3DRMRENDERQUALITY lpdwquality) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMShadow + +DECLARE_INTERFACE_(IDirect3DRMShadow, IDirect3DRMVisual) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMShadow methods + */ + STDMETHOD(Init) + ( THIS_ LPDIRECT3DRMVISUAL visual, LPDIRECT3DRMLIGHT light, + D3DVALUE px, D3DVALUE py, D3DVALUE pz, + D3DVALUE nx, D3DVALUE ny, D3DVALUE nz + ) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMShadow2 + +DECLARE_INTERFACE_(IDirect3DRMShadow2, IDirect3DRMVisual) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMShadow methods + */ + STDMETHOD(Init) + ( THIS_ LPUNKNOWN pUNK, LPDIRECT3DRMLIGHT light, + D3DVALUE px, D3DVALUE py, D3DVALUE pz, + D3DVALUE nx, D3DVALUE ny, D3DVALUE nz + ) PURE; + + /* + * IDirect3DRMShadow2 methods + */ + STDMETHOD(GetVisual)(THIS_ LPDIRECT3DRMVISUAL *) PURE; + STDMETHOD(SetVisual)(THIS_ LPUNKNOWN pUNK, DWORD) PURE; + STDMETHOD(GetLight)(THIS_ LPDIRECT3DRMLIGHT *) PURE; + STDMETHOD(SetLight)(THIS_ LPDIRECT3DRMLIGHT, DWORD) PURE; + STDMETHOD(GetPlane)(THIS_ LPD3DVALUE px, LPD3DVALUE py, LPD3DVALUE pz, + LPD3DVALUE nx, LPD3DVALUE ny, LPD3DVALUE nz) PURE; + STDMETHOD(SetPlane)(THIS_ D3DVALUE px, D3DVALUE py, D3DVALUE pz, + D3DVALUE nx, D3DVALUE ny, D3DVALUE nz, DWORD) PURE; + STDMETHOD(GetOptions)(THIS_ LPDWORD) PURE; + STDMETHOD(SetOptions)(THIS_ DWORD) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMFace + +DECLARE_INTERFACE_(IDirect3DRMFace, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMFace methods + */ + STDMETHOD(AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(AddVertexAndNormalIndexed)(THIS_ DWORD vertex, DWORD normal) PURE; + STDMETHOD(SetColorRGB)(THIS_ D3DVALUE, D3DVALUE, D3DVALUE) PURE; + STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE; + STDMETHOD(SetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE u, D3DVALUE v) PURE; + STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL) PURE; + STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; + + STDMETHOD(GetVertex)(THIS_ DWORD index, D3DVECTOR *vertex, D3DVECTOR *normal) PURE; + STDMETHOD(GetVertices)(THIS_ DWORD *vertex_count, D3DVECTOR *coords, D3DVECTOR *normals); + STDMETHOD(GetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE *u, D3DVALUE *v) PURE; + STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE; + STDMETHOD(GetNormal)(THIS_ D3DVECTOR *) PURE; + STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE *) PURE; + STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL *) PURE; + + STDMETHOD_(int, GetVertexCount)(THIS) PURE; + STDMETHOD_(int, GetVertexIndex)(THIS_ DWORD which) PURE; + STDMETHOD_(int, GetTextureCoordinateIndex)(THIS_ DWORD which) PURE; + STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMFace2 + +DECLARE_INTERFACE_(IDirect3DRMFace2, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMFace methods + */ + STDMETHOD(AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(AddVertexAndNormalIndexed)(THIS_ DWORD vertex, DWORD normal) PURE; + STDMETHOD(SetColorRGB)(THIS_ D3DVALUE, D3DVALUE, D3DVALUE) PURE; + STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE3) PURE; + STDMETHOD(SetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE u, D3DVALUE v) PURE; + STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2) PURE; + STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; + + STDMETHOD(GetVertex)(THIS_ DWORD index, D3DVECTOR *vertex, D3DVECTOR *normal) PURE; + STDMETHOD(GetVertices)(THIS_ DWORD *vertex_count, D3DVECTOR *coords, D3DVECTOR *normals); + STDMETHOD(GetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE *u, D3DVALUE *v) PURE; + STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE; + STDMETHOD(GetNormal)(THIS_ D3DVECTOR *) PURE; + STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE3 *) PURE; + STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2 *) PURE; + + STDMETHOD_(int, GetVertexCount)(THIS) PURE; + STDMETHOD_(int, GetVertexIndex)(THIS_ DWORD which) PURE; + STDMETHOD_(int, GetTextureCoordinateIndex)(THIS_ DWORD which) PURE; + STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMMeshBuilder + +DECLARE_INTERFACE_(IDirect3DRMMeshBuilder, IDirect3DRMVisual) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMMeshBuilder methods + */ + STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID lpArg) PURE; + STDMETHOD(Save)(THIS_ const char *filename, D3DRMXOFFORMAT, D3DRMSAVEOPTIONS save) PURE; + STDMETHOD(Scale)(THIS_ D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE; + STDMETHOD(Translate)(THIS_ D3DVALUE tx, D3DVALUE ty, D3DVALUE tz) PURE; + STDMETHOD(SetColorSource)(THIS_ D3DRMCOLORSOURCE) PURE; + STDMETHOD(GetBox)(THIS_ D3DRMBOX *) PURE; + STDMETHOD(GenerateNormals)(THIS) PURE; + STDMETHOD_(D3DRMCOLORSOURCE, GetColorSource)(THIS) PURE; + + STDMETHOD(AddMesh)(THIS_ LPDIRECT3DRMMESH) PURE; + STDMETHOD(AddMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER) PURE; + STDMETHOD(AddFrame)(THIS_ LPDIRECT3DRMFRAME) PURE; + STDMETHOD(AddFace)(THIS_ LPDIRECT3DRMFACE) PURE; + STDMETHOD(AddFaces) + ( THIS_ DWORD vcount, D3DVECTOR *vertices, DWORD ncount, D3DVECTOR *normals, + DWORD *data, LPDIRECT3DRMFACEARRAY* + ) PURE; + STDMETHOD(ReserveSpace)(THIS_ DWORD vertex_Count, DWORD normal_count, DWORD face_count) PURE; + STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; + STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE; + STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL) PURE; + STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; + STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE; + STDMETHOD(SetPerspective)(THIS_ BOOL) PURE; + STDMETHOD(SetVertex)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(SetNormal)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(SetTextureCoordinates)(THIS_ DWORD index, D3DVALUE u, D3DVALUE v) PURE; + STDMETHOD(SetVertexColor)(THIS_ DWORD index, D3DCOLOR) PURE; + STDMETHOD(SetVertexColorRGB)(THIS_ DWORD index, D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; + + STDMETHOD(GetFaces)(THIS_ LPDIRECT3DRMFACEARRAY*) PURE; + STDMETHOD(GetVertices) + ( THIS_ DWORD *vcount, D3DVECTOR *vertices, DWORD *ncount, D3DVECTOR *normals, DWORD *face_data_size, DWORD *face_data + ) PURE; + STDMETHOD(GetTextureCoordinates)(THIS_ DWORD index, D3DVALUE *u, D3DVALUE *v) PURE; + + STDMETHOD_(int, AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD_(int, AddNormal)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(CreateFace)(THIS_ LPDIRECT3DRMFACE*) PURE; + STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE; + STDMETHOD_(BOOL, GetPerspective)(THIS) PURE; + STDMETHOD_(int, GetFaceCount)(THIS) PURE; + STDMETHOD_(int, GetVertexCount)(THIS) PURE; + STDMETHOD_(D3DCOLOR, GetVertexColor)(THIS_ DWORD index) PURE; + + STDMETHOD(CreateMesh)(THIS_ LPDIRECT3DRMMESH*) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMMeshBuilder2 + +DECLARE_INTERFACE_(IDirect3DRMMeshBuilder2, IDirect3DRMMeshBuilder) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMMeshBuilder methods + */ + STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID lpArg) PURE; + STDMETHOD(Save)(THIS_ const char *filename, D3DRMXOFFORMAT, D3DRMSAVEOPTIONS save) PURE; + STDMETHOD(Scale)(THIS_ D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE; + STDMETHOD(Translate)(THIS_ D3DVALUE tx, D3DVALUE ty, D3DVALUE tz) PURE; + STDMETHOD(SetColorSource)(THIS_ D3DRMCOLORSOURCE) PURE; + STDMETHOD(GetBox)(THIS_ D3DRMBOX *) PURE; + STDMETHOD(GenerateNormals)(THIS) PURE; + STDMETHOD_(D3DRMCOLORSOURCE, GetColorSource)(THIS) PURE; + + STDMETHOD(AddMesh)(THIS_ LPDIRECT3DRMMESH) PURE; + STDMETHOD(AddMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER) PURE; + STDMETHOD(AddFrame)(THIS_ LPDIRECT3DRMFRAME) PURE; + STDMETHOD(AddFace)(THIS_ LPDIRECT3DRMFACE) PURE; + STDMETHOD(AddFaces) + ( THIS_ DWORD vcount, D3DVECTOR *vertices, DWORD ncount, D3DVECTOR *normals, + DWORD *data, LPDIRECT3DRMFACEARRAY* + ) PURE; + STDMETHOD(ReserveSpace)(THIS_ DWORD vertex_Count, DWORD normal_count, DWORD face_count) PURE; + STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; + STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE; + STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL) PURE; + STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; + STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE; + STDMETHOD(SetPerspective)(THIS_ BOOL) PURE; + STDMETHOD(SetVertex)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(SetNormal)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(SetTextureCoordinates)(THIS_ DWORD index, D3DVALUE u, D3DVALUE v) PURE; + STDMETHOD(SetVertexColor)(THIS_ DWORD index, D3DCOLOR) PURE; + STDMETHOD(SetVertexColorRGB)(THIS_ DWORD index, D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; + + STDMETHOD(GetFaces)(THIS_ LPDIRECT3DRMFACEARRAY*) PURE; + STDMETHOD(GetVertices) + ( THIS_ DWORD *vcount, D3DVECTOR *vertices, DWORD *ncount, D3DVECTOR *normals, DWORD *face_data_size, DWORD *face_data + ) PURE; + STDMETHOD(GetTextureCoordinates)(THIS_ DWORD index, D3DVALUE *u, D3DVALUE *v) PURE; + + STDMETHOD_(int, AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD_(int, AddNormal)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(CreateFace)(THIS_ LPDIRECT3DRMFACE*) PURE; + STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE; + STDMETHOD_(BOOL, GetPerspective)(THIS) PURE; + STDMETHOD_(int, GetFaceCount)(THIS) PURE; + STDMETHOD_(int, GetVertexCount)(THIS) PURE; + STDMETHOD_(D3DCOLOR, GetVertexColor)(THIS_ DWORD index) PURE; + + STDMETHOD(CreateMesh)(THIS_ LPDIRECT3DRMMESH*) PURE; + + /* + * IDirect3DRMMeshBuilder2 methods + */ + STDMETHOD(GenerateNormals2)(THIS_ D3DVALUE crease, DWORD dwFlags) PURE; + STDMETHOD(GetFace)(THIS_ DWORD index, LPDIRECT3DRMFACE*) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMMeshBuilder3 + +DECLARE_INTERFACE_(IDirect3DRMMeshBuilder3, IDirect3DRMVisual) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMMeshBuilder3 methods + */ + STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURE3CALLBACK, LPVOID lpArg) PURE; + STDMETHOD(Save)(THIS_ const char *filename, D3DRMXOFFORMAT, D3DRMSAVEOPTIONS save) PURE; + STDMETHOD(Scale)(THIS_ D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE; + STDMETHOD(Translate)(THIS_ D3DVALUE tx, D3DVALUE ty, D3DVALUE tz) PURE; + STDMETHOD(SetColorSource)(THIS_ D3DRMCOLORSOURCE) PURE; + STDMETHOD(GetBox)(THIS_ D3DRMBOX *) PURE; + STDMETHOD(GenerateNormals)(THIS_ D3DVALUE crease, DWORD dwFlags) PURE; + STDMETHOD_(D3DRMCOLORSOURCE, GetColorSource)(THIS) PURE; + + STDMETHOD(AddMesh)(THIS_ LPDIRECT3DRMMESH) PURE; + STDMETHOD(AddMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER3, DWORD dwFlags) PURE; + STDMETHOD(AddFrame)(THIS_ LPDIRECT3DRMFRAME3) PURE; + STDMETHOD(AddFace)(THIS_ LPDIRECT3DRMFACE2) PURE; + STDMETHOD(AddFaces) + ( THIS_ DWORD vcount, D3DVECTOR *vertices, DWORD ncount, D3DVECTOR *normals, + DWORD *data, LPDIRECT3DRMFACEARRAY* + ) PURE; + STDMETHOD(ReserveSpace)(THIS_ DWORD vertex_Count, DWORD normal_count, DWORD face_count) PURE; + STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; + STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE3) PURE; + STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2) PURE; + STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; + STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE; + STDMETHOD(SetPerspective)(THIS_ BOOL) PURE; + STDMETHOD(SetVertex)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(SetNormal)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(SetTextureCoordinates)(THIS_ DWORD index, D3DVALUE u, D3DVALUE v) PURE; + STDMETHOD(SetVertexColor)(THIS_ DWORD index, D3DCOLOR) PURE; + STDMETHOD(SetVertexColorRGB)(THIS_ DWORD index, D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; + STDMETHOD(GetFaces)(THIS_ LPDIRECT3DRMFACEARRAY*) PURE; + STDMETHOD(GetGeometry) + ( THIS_ DWORD *vcount, D3DVECTOR *vertices, DWORD *ncount, D3DVECTOR *normals, DWORD *face_data_size, DWORD *face_data + ) PURE; + STDMETHOD(GetTextureCoordinates)(THIS_ DWORD index, D3DVALUE *u, D3DVALUE *v) PURE; + STDMETHOD_(int, AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD_(int, AddNormal)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(CreateFace)(THIS_ LPDIRECT3DRMFACE2 *) PURE; + STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE; + STDMETHOD_(BOOL, GetPerspective)(THIS) PURE; + STDMETHOD_(int, GetFaceCount)(THIS) PURE; + STDMETHOD_(int, GetVertexCount)(THIS) PURE; + STDMETHOD_(D3DCOLOR, GetVertexColor)(THIS_ DWORD index) PURE; + STDMETHOD(CreateMesh)(THIS_ LPDIRECT3DRMMESH*) PURE; + STDMETHOD(GetFace)(THIS_ DWORD index, LPDIRECT3DRMFACE2 *) PURE; + STDMETHOD(GetVertex)(THIS_ DWORD dwIndex, LPD3DVECTOR lpVector) PURE; + STDMETHOD(GetNormal)(THIS_ DWORD dwIndex, LPD3DVECTOR lpVector) PURE; + STDMETHOD(DeleteVertices)(THIS_ DWORD dwIndexFirst, DWORD dwCount) PURE; + STDMETHOD(DeleteNormals)(THIS_ DWORD dwIndexFirst, DWORD dwCount) PURE; + STDMETHOD(DeleteFace)(THIS_ LPDIRECT3DRMFACE2) PURE; + STDMETHOD(Empty)(THIS_ DWORD dwFlags) PURE; + STDMETHOD(Optimize)(THIS_ DWORD dwFlags) PURE; + STDMETHOD(AddFacesIndexed)(THIS_ DWORD dwFlags, DWORD *lpdwvIndices, DWORD *dwIndexFirst, DWORD *dwCount) PURE; + STDMETHOD(CreateSubMesh)(THIS_ LPUNKNOWN *) PURE; + STDMETHOD(GetParentMesh)(THIS_ DWORD, LPUNKNOWN *) PURE; + STDMETHOD(GetSubMeshes)(THIS_ LPDWORD lpdwCount, LPUNKNOWN *) PURE; + STDMETHOD(DeleteSubMesh)(THIS_ LPUNKNOWN) PURE; + STDMETHOD(Enable)(THIS_ DWORD) PURE; + STDMETHOD(GetEnable)(THIS_ DWORD *) PURE; + STDMETHOD(AddTriangles)(THIS_ DWORD dwFlags, DWORD dwFormat, + DWORD dwVertexCount, LPVOID lpvData) PURE; + STDMETHOD(SetVertices)(THIS_ DWORD dwIndexFirst, DWORD dwCount, LPD3DVECTOR) PURE; + STDMETHOD(GetVertices)(THIS_ DWORD dwIndexFirst, LPDWORD lpdwCount, LPD3DVECTOR) PURE; + STDMETHOD(SetNormals)(THIS_ DWORD dwIndexFirst, DWORD dwCount, LPD3DVECTOR) PURE; + STDMETHOD(GetNormals)(THIS_ DWORD dwIndexFirst, LPDWORD lpdwCount, LPD3DVECTOR) PURE; + STDMETHOD_(int, GetNormalCount)(THIS) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMLight + +DECLARE_INTERFACE_(IDirect3DRMLight, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMLight methods + */ + STDMETHOD(SetType)(THIS_ D3DRMLIGHTTYPE) PURE; + STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; + STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; + STDMETHOD(SetRange)(THIS_ D3DVALUE) PURE; + STDMETHOD(SetUmbra)(THIS_ D3DVALUE) PURE; + STDMETHOD(SetPenumbra)(THIS_ D3DVALUE) PURE; + STDMETHOD(SetConstantAttenuation)(THIS_ D3DVALUE) PURE; + STDMETHOD(SetLinearAttenuation)(THIS_ D3DVALUE) PURE; + STDMETHOD(SetQuadraticAttenuation)(THIS_ D3DVALUE) PURE; + + STDMETHOD_(D3DVALUE, GetRange)(THIS) PURE; + STDMETHOD_(D3DVALUE, GetUmbra)(THIS) PURE; + STDMETHOD_(D3DVALUE, GetPenumbra)(THIS) PURE; + STDMETHOD_(D3DVALUE, GetConstantAttenuation)(THIS) PURE; + STDMETHOD_(D3DVALUE, GetLinearAttenuation)(THIS) PURE; + STDMETHOD_(D3DVALUE, GetQuadraticAttenuation)(THIS) PURE; + STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE; + STDMETHOD_(D3DRMLIGHTTYPE, GetType)(THIS) PURE; + + STDMETHOD(SetEnableFrame)(THIS_ LPDIRECT3DRMFRAME) PURE; + STDMETHOD(GetEnableFrame)(THIS_ LPDIRECT3DRMFRAME*) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMTexture + +DECLARE_INTERFACE_(IDirect3DRMTexture, IDirect3DRMVisual) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMTexture methods + */ + STDMETHOD(InitFromFile)(THIS_ const char *filename) PURE; + STDMETHOD(InitFromSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDS) PURE; + STDMETHOD(InitFromResource)(THIS_ HRSRC) PURE; + STDMETHOD(Changed)(THIS_ BOOL pixels, BOOL palette) PURE; + + STDMETHOD(SetColors)(THIS_ DWORD) PURE; + STDMETHOD(SetShades)(THIS_ DWORD) PURE; + STDMETHOD(SetDecalSize)(THIS_ D3DVALUE width, D3DVALUE height) PURE; + STDMETHOD(SetDecalOrigin)(THIS_ LONG x, LONG y) PURE; + STDMETHOD(SetDecalScale)(THIS_ DWORD) PURE; + STDMETHOD(SetDecalTransparency)(THIS_ BOOL) PURE; + STDMETHOD(SetDecalTransparentColor)(THIS_ D3DCOLOR) PURE; + + STDMETHOD(GetDecalSize)(THIS_ D3DVALUE *width_return, D3DVALUE *height_return) PURE; + STDMETHOD(GetDecalOrigin)(THIS_ LONG *x_return, LONG *y_return) PURE; + + STDMETHOD_(D3DRMIMAGE *, GetImage)(THIS) PURE; + STDMETHOD_(DWORD, GetShades)(THIS) PURE; + STDMETHOD_(DWORD, GetColors)(THIS) PURE; + STDMETHOD_(DWORD, GetDecalScale)(THIS) PURE; + STDMETHOD_(BOOL, GetDecalTransparency)(THIS) PURE; + STDMETHOD_(D3DCOLOR, GetDecalTransparentColor)(THIS) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMTexture2 + +DECLARE_INTERFACE_(IDirect3DRMTexture2, IDirect3DRMTexture) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMTexture methods + */ + STDMETHOD(InitFromFile)(THIS_ const char *filename) PURE; + STDMETHOD(InitFromSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDS) PURE; + STDMETHOD(InitFromResource)(THIS_ HRSRC) PURE; + STDMETHOD(Changed)(THIS_ BOOL pixels, BOOL palette) PURE; + + STDMETHOD(SetColors)(THIS_ DWORD) PURE; + STDMETHOD(SetShades)(THIS_ DWORD) PURE; + STDMETHOD(SetDecalSize)(THIS_ D3DVALUE width, D3DVALUE height) PURE; + STDMETHOD(SetDecalOrigin)(THIS_ LONG x, LONG y) PURE; + STDMETHOD(SetDecalScale)(THIS_ DWORD) PURE; + STDMETHOD(SetDecalTransparency)(THIS_ BOOL) PURE; + STDMETHOD(SetDecalTransparentColor)(THIS_ D3DCOLOR) PURE; + + STDMETHOD(GetDecalSize)(THIS_ D3DVALUE *width_return, D3DVALUE *height_return) PURE; + STDMETHOD(GetDecalOrigin)(THIS_ LONG *x_return, LONG *y_return) PURE; + + STDMETHOD_(D3DRMIMAGE *, GetImage)(THIS) PURE; + STDMETHOD_(DWORD, GetShades)(THIS) PURE; + STDMETHOD_(DWORD, GetColors)(THIS) PURE; + STDMETHOD_(DWORD, GetDecalScale)(THIS) PURE; + STDMETHOD_(BOOL, GetDecalTransparency)(THIS) PURE; + STDMETHOD_(D3DCOLOR, GetDecalTransparentColor)(THIS) PURE; + + /* + * IDirect3DRMTexture2 methods + */ + STDMETHOD(InitFromImage)(THIS_ LPD3DRMIMAGE) PURE; + STDMETHOD(InitFromResource2)(THIS_ HMODULE hModule, LPCTSTR strName, LPCTSTR strType) PURE; + STDMETHOD(GenerateMIPMap)(THIS_ DWORD) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMTexture3 + +DECLARE_INTERFACE_(IDirect3DRMTexture3, IDirect3DRMVisual) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMTexture3 methods + */ + STDMETHOD(InitFromFile)(THIS_ const char *filename) PURE; + STDMETHOD(InitFromSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDS) PURE; + STDMETHOD(InitFromResource)(THIS_ HRSRC) PURE; + STDMETHOD(Changed)(THIS_ DWORD dwFlags, DWORD dwcRects, LPRECT pRects) PURE; + STDMETHOD(SetColors)(THIS_ DWORD) PURE; + STDMETHOD(SetShades)(THIS_ DWORD) PURE; + STDMETHOD(SetDecalSize)(THIS_ D3DVALUE width, D3DVALUE height) PURE; + STDMETHOD(SetDecalOrigin)(THIS_ LONG x, LONG y) PURE; + STDMETHOD(SetDecalScale)(THIS_ DWORD) PURE; + STDMETHOD(SetDecalTransparency)(THIS_ BOOL) PURE; + STDMETHOD(SetDecalTransparentColor)(THIS_ D3DCOLOR) PURE; + + STDMETHOD(GetDecalSize)(THIS_ D3DVALUE *width_return, D3DVALUE *height_return) PURE; + STDMETHOD(GetDecalOrigin)(THIS_ LONG *x_return, LONG *y_return) PURE; + + STDMETHOD_(D3DRMIMAGE *, GetImage)(THIS) PURE; + STDMETHOD_(DWORD, GetShades)(THIS) PURE; + STDMETHOD_(DWORD, GetColors)(THIS) PURE; + STDMETHOD_(DWORD, GetDecalScale)(THIS) PURE; + STDMETHOD_(BOOL, GetDecalTransparency)(THIS) PURE; + STDMETHOD_(D3DCOLOR, GetDecalTransparentColor)(THIS) PURE; + STDMETHOD(InitFromImage)(THIS_ LPD3DRMIMAGE) PURE; + STDMETHOD(InitFromResource2)(THIS_ HMODULE hModule, LPCTSTR strName, LPCTSTR strType) PURE; + STDMETHOD(GenerateMIPMap)(THIS_ DWORD) PURE; + STDMETHOD(GetSurface)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE* lplpDDS) PURE; + STDMETHOD(SetCacheOptions)(THIS_ LONG lImportance, DWORD dwFlags) PURE; + STDMETHOD(GetCacheOptions)(THIS_ LPLONG lplImportance, LPDWORD lpdwFlags) PURE; + STDMETHOD(SetDownsampleCallback)(THIS_ D3DRMDOWNSAMPLECALLBACK pCallback, LPVOID pArg) PURE; + STDMETHOD(SetValidationCallback)(THIS_ D3DRMVALIDATIONCALLBACK pCallback, LPVOID pArg) PURE; +}; + + +#undef INTERFACE +#define INTERFACE IDirect3DRMWrap + +DECLARE_INTERFACE_(IDirect3DRMWrap, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMWrap methods + */ + STDMETHOD(Init) + ( THIS_ D3DRMWRAPTYPE, LPDIRECT3DRMFRAME ref, + D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, + D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, + D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, + D3DVALUE ou, D3DVALUE ov, + D3DVALUE su, D3DVALUE sv + ) PURE; + STDMETHOD(Apply)(THIS_ LPDIRECT3DRMOBJECT) PURE; + STDMETHOD(ApplyRelative)(THIS_ LPDIRECT3DRMFRAME frame, LPDIRECT3DRMOBJECT) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMMaterial + +DECLARE_INTERFACE_(IDirect3DRMMaterial, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMMaterial methods + */ + STDMETHOD(SetPower)(THIS_ D3DVALUE power) PURE; + STDMETHOD(SetSpecular)(THIS_ D3DVALUE r, D3DVALUE g, D3DVALUE b) PURE; + STDMETHOD(SetEmissive)(THIS_ D3DVALUE r, D3DVALUE g, D3DVALUE b) PURE; + + STDMETHOD_(D3DVALUE, GetPower)(THIS) PURE; + STDMETHOD(GetSpecular)(THIS_ D3DVALUE* r, D3DVALUE* g, D3DVALUE* b) PURE; + STDMETHOD(GetEmissive)(THIS_ D3DVALUE* r, D3DVALUE* g, D3DVALUE* b) PURE; +}; + + +#undef INTERFACE +#define INTERFACE IDirect3DRMMaterial2 + +DECLARE_INTERFACE_(IDirect3DRMMaterial2, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMMaterial2 methods + */ + STDMETHOD(SetPower)(THIS_ D3DVALUE power) PURE; + STDMETHOD(SetSpecular)(THIS_ D3DVALUE r, D3DVALUE g, D3DVALUE b) PURE; + STDMETHOD(SetEmissive)(THIS_ D3DVALUE r, D3DVALUE g, D3DVALUE b) PURE; + STDMETHOD_(D3DVALUE, GetPower)(THIS) PURE; + STDMETHOD(GetSpecular)(THIS_ D3DVALUE* r, D3DVALUE* g, D3DVALUE* b) PURE; + STDMETHOD(GetEmissive)(THIS_ D3DVALUE* r, D3DVALUE* g, D3DVALUE* b) PURE; + STDMETHOD(GetAmbient)(THIS_ D3DVALUE* r, D3DVALUE* g, D3DVALUE* b) PURE; + STDMETHOD(SetAmbient)(THIS_ D3DVALUE r, D3DVALUE g, D3DVALUE b) PURE; +}; + + +#undef INTERFACE +#define INTERFACE IDirect3DRMAnimation + +DECLARE_INTERFACE_(IDirect3DRMAnimation, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMAnimation methods + */ + STDMETHOD(SetOptions)(THIS_ D3DRMANIMATIONOPTIONS flags) PURE; + STDMETHOD(AddRotateKey)(THIS_ D3DVALUE time, D3DRMQUATERNION *q) PURE; + STDMETHOD(AddPositionKey)(THIS_ D3DVALUE time, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(AddScaleKey)(THIS_ D3DVALUE time, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(DeleteKey)(THIS_ D3DVALUE time) PURE; + STDMETHOD(SetFrame)(THIS_ LPDIRECT3DRMFRAME frame) PURE; + STDMETHOD(SetTime)(THIS_ D3DVALUE time) PURE; + + STDMETHOD_(D3DRMANIMATIONOPTIONS, GetOptions)(THIS) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMAnimation2 + +DECLARE_INTERFACE_(IDirect3DRMAnimation2, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMAnimation2 methods + */ + STDMETHOD(SetOptions)(THIS_ D3DRMANIMATIONOPTIONS flags) PURE; + STDMETHOD(AddRotateKey)(THIS_ D3DVALUE time, D3DRMQUATERNION *q) PURE; + STDMETHOD(AddPositionKey)(THIS_ D3DVALUE time, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(AddScaleKey)(THIS_ D3DVALUE time, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE; + STDMETHOD(DeleteKey)(THIS_ D3DVALUE time) PURE; + STDMETHOD(SetFrame)(THIS_ LPDIRECT3DRMFRAME3 frame) PURE; + STDMETHOD(SetTime)(THIS_ D3DVALUE time) PURE; + + STDMETHOD_(D3DRMANIMATIONOPTIONS, GetOptions)(THIS) PURE; + STDMETHOD(GetFrame)(THIS_ LPDIRECT3DRMFRAME3 *lpD3DFrame) PURE; + STDMETHOD(DeleteKeyByID)(THIS_ DWORD dwID) PURE; + STDMETHOD(AddKey)(THIS_ LPD3DRMANIMATIONKEY lpKey) PURE; + STDMETHOD(ModifyKey)(THIS_ LPD3DRMANIMATIONKEY lpKey) PURE; + STDMETHOD(GetKeys)(THIS_ D3DVALUE dvTimeMin, + D3DVALUE dvTimeMax, LPDWORD lpdwNumKeys, + LPD3DRMANIMATIONKEY lpKey); +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMAnimationSet + +DECLARE_INTERFACE_(IDirect3DRMAnimationSet, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMAnimationSet methods + */ + STDMETHOD(AddAnimation)(THIS_ LPDIRECT3DRMANIMATION aid) PURE; + STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID lpArg, LPDIRECT3DRMFRAME parent)PURE; + STDMETHOD(DeleteAnimation)(THIS_ LPDIRECT3DRMANIMATION aid) PURE; + STDMETHOD(SetTime)(THIS_ D3DVALUE time) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMAnimationSet2 + +DECLARE_INTERFACE_(IDirect3DRMAnimationSet2, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMAnimationSet2 methods + */ + STDMETHOD(AddAnimation)(THIS_ LPDIRECT3DRMANIMATION2 aid) PURE; + STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURE3CALLBACK, LPVOID lpArg, LPDIRECT3DRMFRAME3 parent)PURE; + STDMETHOD(DeleteAnimation)(THIS_ LPDIRECT3DRMANIMATION2 aid) PURE; + STDMETHOD(SetTime)(THIS_ D3DVALUE time) PURE; + STDMETHOD(GetAnimations)(THIS_ LPDIRECT3DRMANIMATIONARRAY *) PURE; +}; + + +#undef INTERFACE +#define INTERFACE IDirect3DRMUserVisual + +DECLARE_INTERFACE_(IDirect3DRMUserVisual, IDirect3DRMVisual) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMUserVisual methods + */ + STDMETHOD(Init)(THIS_ D3DRMUSERVISUALCALLBACK fn, void *arg) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMArray + +DECLARE_INTERFACE_(IDirect3DRMArray, IUnknown) +{ + IUNKNOWN_METHODS(PURE); + + STDMETHOD_(DWORD, GetSize)(THIS) PURE; + /* No GetElement method as it would get overloaded + * in derived classes, and overloading is + * a no-no in COM + */ +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMObjectArray + +DECLARE_INTERFACE_(IDirect3DRMObjectArray, IDirect3DRMArray) +{ + IUNKNOWN_METHODS(PURE); + + STDMETHOD_(DWORD, GetSize)(THIS) PURE; + STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMOBJECT *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMDeviceArray + +DECLARE_INTERFACE_(IDirect3DRMDeviceArray, IDirect3DRMArray) +{ + IUNKNOWN_METHODS(PURE); + + STDMETHOD_(DWORD, GetSize)(THIS) PURE; + STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMDEVICE *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMFrameArray + +DECLARE_INTERFACE_(IDirect3DRMFrameArray, IDirect3DRMArray) +{ + IUNKNOWN_METHODS(PURE); + + STDMETHOD_(DWORD, GetSize)(THIS) PURE; + STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMFRAME *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMViewportArray + +DECLARE_INTERFACE_(IDirect3DRMViewportArray, IDirect3DRMArray) +{ + IUNKNOWN_METHODS(PURE); + + STDMETHOD_(DWORD, GetSize)(THIS) PURE; + STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMVIEWPORT *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMVisualArray + +DECLARE_INTERFACE_(IDirect3DRMVisualArray, IDirect3DRMArray) +{ + IUNKNOWN_METHODS(PURE); + + STDMETHOD_(DWORD, GetSize)(THIS) PURE; + STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMVISUAL *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMAnimationArray + +DECLARE_INTERFACE_(IDirect3DRMAnimationArray, IDirect3DRMArray) +{ + IUNKNOWN_METHODS(PURE); + + STDMETHOD_(DWORD, GetSize)(THIS) PURE; + STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMANIMATION2 *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMPickedArray + +DECLARE_INTERFACE_(IDirect3DRMPickedArray, IDirect3DRMArray) +{ + IUNKNOWN_METHODS(PURE); + + STDMETHOD_(DWORD, GetSize)(THIS) PURE; + STDMETHOD(GetPick)(THIS_ DWORD index, LPDIRECT3DRMVISUAL *, LPDIRECT3DRMFRAMEARRAY *, LPD3DRMPICKDESC) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMLightArray + +DECLARE_INTERFACE_(IDirect3DRMLightArray, IDirect3DRMArray) +{ + IUNKNOWN_METHODS(PURE); + + STDMETHOD_(DWORD, GetSize)(THIS) PURE; + STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMLIGHT *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMFaceArray + +DECLARE_INTERFACE_(IDirect3DRMFaceArray, IDirect3DRMArray) +{ + IUNKNOWN_METHODS(PURE); + + STDMETHOD_(DWORD, GetSize)(THIS) PURE; + STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMFACE *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMPicked2Array + +DECLARE_INTERFACE_(IDirect3DRMPicked2Array, IDirect3DRMArray) +{ + IUNKNOWN_METHODS(PURE); + + STDMETHOD_(DWORD, GetSize)(THIS) PURE; + STDMETHOD(GetPick)(THIS_ DWORD index, LPDIRECT3DRMVISUAL *, LPDIRECT3DRMFRAMEARRAY *, LPD3DRMPICKDESC2) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMInterpolator + +DECLARE_INTERFACE_(IDirect3DRMInterpolator, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMInterpolator methods + */ + STDMETHOD(AttachObject)(THIS_ LPDIRECT3DRMOBJECT) PURE; + STDMETHOD(GetAttachedObjects)(THIS_ LPDIRECT3DRMOBJECTARRAY *) PURE; + STDMETHOD(DetachObject)(THIS_ LPDIRECT3DRMOBJECT) PURE; + STDMETHOD(SetIndex)(THIS_ D3DVALUE) PURE; + STDMETHOD_(D3DVALUE, GetIndex)(THIS) PURE; + STDMETHOD(Interpolate)(THIS_ D3DVALUE, LPDIRECT3DRMOBJECT, D3DRMINTERPOLATIONOPTIONS) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirect3DRMClippedVisual + +DECLARE_INTERFACE_(IDirect3DRMClippedVisual, IDirect3DRMVisual) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMClippedVisual methods + */ + STDMETHOD(Init) (THIS_ LPDIRECT3DRMVISUAL) PURE; + STDMETHOD(AddPlane) (THIS_ LPDIRECT3DRMFRAME3, LPD3DVECTOR, LPD3DVECTOR, DWORD, LPDWORD) PURE; + STDMETHOD(DeletePlane)(THIS_ DWORD, DWORD) PURE; + STDMETHOD(GetPlaneIDs)(THIS_ LPDWORD, LPDWORD, DWORD) PURE; + STDMETHOD(GetPlane) (THIS_ DWORD, LPDIRECT3DRMFRAME3, LPD3DVECTOR, LPD3DVECTOR, DWORD) PURE; + STDMETHOD(SetPlane) (THIS_ DWORD, LPDIRECT3DRMFRAME3, LPD3DVECTOR, LPD3DVECTOR, DWORD) PURE; +}; + +#ifdef __cplusplus +}; +#endif +#endif /* _D3DRMOBJ_H_ */ + diff --git a/src/dep/include/DXSDK/include/d3drmwin.h b/src/dep/include/DXSDK/include/d3drmwin.h index a785319..d051ef4 100644 --- a/src/dep/include/DXSDK/include/d3drmwin.h +++ b/src/dep/include/DXSDK/include/d3drmwin.h @@ -1,50 +1,50 @@ -/*==========================================================================; - * - * Copyright (c) Microsoft Corporation. All rights reserved. - * - * File: d3drm.h - * Content: Direct3DRM include file - * - ***************************************************************************/ - -#ifndef __D3DRMWIN_H__ -#define __D3DRMWIN_H__ - -#ifndef WIN32 -#define WIN32 -#endif - -#include "d3drm.h" - -#include "ddraw.h" -#include "d3d.h" - -/* - * GUIDS used by Direct3DRM Windows interface - */ -DEFINE_GUID(IID_IDirect3DRMWinDevice, 0xc5016cc0, 0xd273, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); - -WIN_TYPES(IDirect3DRMWinDevice, DIRECT3DRMWINDEVICE); - -#undef INTERFACE -#define INTERFACE IDirect3DRMWinDevice - -DECLARE_INTERFACE_(IDirect3DRMWinDevice, IDirect3DRMObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECT3DRMOBJECT_METHODS(PURE); - - /* - * IDirect3DRMWinDevice methods - */ - - /* Repaint the window with the last frame which was rendered. */ - STDMETHOD(HandlePaint)(THIS_ HDC hdc) PURE; - - /* Respond to a WM_ACTIVATE message. */ - STDMETHOD(HandleActivate)(THIS_ WORD wparam) PURE; -}; - - -#endif - +/*==========================================================================; + * + * Copyright (c) Microsoft Corporation. All rights reserved. + * + * File: d3drm.h + * Content: Direct3DRM include file + * + ***************************************************************************/ + +#ifndef __D3DRMWIN_H__ +#define __D3DRMWIN_H__ + +#ifndef WIN32 +#define WIN32 +#endif + +#include "d3drm.h" + +#include "ddraw.h" +#include "d3d.h" + +/* + * GUIDS used by Direct3DRM Windows interface + */ +DEFINE_GUID(IID_IDirect3DRMWinDevice, 0xc5016cc0, 0xd273, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); + +WIN_TYPES(IDirect3DRMWinDevice, DIRECT3DRMWINDEVICE); + +#undef INTERFACE +#define INTERFACE IDirect3DRMWinDevice + +DECLARE_INTERFACE_(IDirect3DRMWinDevice, IDirect3DRMObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECT3DRMOBJECT_METHODS(PURE); + + /* + * IDirect3DRMWinDevice methods + */ + + /* Repaint the window with the last frame which was rendered. */ + STDMETHOD(HandlePaint)(THIS_ HDC hdc) PURE; + + /* Respond to a WM_ACTIVATE message. */ + STDMETHOD(HandleActivate)(THIS_ WORD wparam) PURE; +}; + + +#endif + diff --git a/src/dep/include/DXSDK/include/d3dtypes.h b/src/dep/include/DXSDK/include/d3dtypes.h index d1759dc..7949041 100644 --- a/src/dep/include/DXSDK/include/d3dtypes.h +++ b/src/dep/include/DXSDK/include/d3dtypes.h @@ -1,2119 +1,2119 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: d3dtypes.h - * Content: Direct3D types include file - * - ***************************************************************************/ - -#ifndef _D3DTYPES_H_ -#define _D3DTYPES_H_ - -#ifndef DIRECT3D_VERSION -#define DIRECT3D_VERSION 0x0700 -#endif - -#if (DIRECT3D_VERSION >= 0x0800) -#pragma message("should not include d3dtypes.h when compiling for DX8 or newer interfaces") -#endif - -#include - -#include -#include "ddraw.h" - -#pragma warning(disable:4201) // anonymous unions warning -#if defined(_X86_) || defined(_IA64_) -#pragma pack(4) -#endif - - -/* D3DVALUE is the fundamental Direct3D fractional data type */ - -#define D3DVALP(val, prec) ((float)(val)) -#define D3DVAL(val) ((float)(val)) - -#ifndef DX_SHARED_DEFINES - -/* - * This definition is shared with other DirectX components whose header files - * might already have defined it. Therefore, we don't define this type if - * someone else already has (as indicated by the definition of - * DX_SHARED_DEFINES). We don't set DX_SHARED_DEFINES here as there are - * other types in this header that are also shared. The last of these - * shared defines in this file will set DX_SHARED_DEFINES. - */ -typedef float D3DVALUE, *LPD3DVALUE; - -#endif /* DX_SHARED_DEFINES */ - -#define D3DDivide(a, b) (float)((double) (a) / (double) (b)) -#define D3DMultiply(a, b) ((a) * (b)) - -typedef LONG D3DFIXED; - -#ifndef RGB_MAKE -/* - * Format of CI colors is - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | alpha | color index | fraction | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ -#define CI_GETALPHA(ci) ((ci) >> 24) -#define CI_GETINDEX(ci) (((ci) >> 8) & 0xffff) -#define CI_GETFRACTION(ci) ((ci) & 0xff) -#define CI_ROUNDINDEX(ci) CI_GETINDEX((ci) + 0x80) -#define CI_MASKALPHA(ci) ((ci) & 0xffffff) -#define CI_MAKE(a, i, f) (((a) << 24) | ((i) << 8) | (f)) - -/* - * Format of RGBA colors is - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | alpha | red | green | blue | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ -#define RGBA_GETALPHA(rgb) ((rgb) >> 24) -#define RGBA_GETRED(rgb) (((rgb) >> 16) & 0xff) -#define RGBA_GETGREEN(rgb) (((rgb) >> 8) & 0xff) -#define RGBA_GETBLUE(rgb) ((rgb) & 0xff) -#define RGBA_MAKE(r, g, b, a) ((D3DCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))) - -/* D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs - * The float values must be in the range 0..1 - */ -#define D3DRGB(r, g, b) \ - (0xff000000L | ( ((long)((r) * 255)) << 16) | (((long)((g) * 255)) << 8) | (long)((b) * 255)) -#define D3DRGBA(r, g, b, a) \ - ( (((long)((a) * 255)) << 24) | (((long)((r) * 255)) << 16) \ - | (((long)((g) * 255)) << 8) | (long)((b) * 255) \ - ) - -/* - * Format of RGB colors is - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | ignored | red | green | blue | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ -#define RGB_GETRED(rgb) (((rgb) >> 16) & 0xff) -#define RGB_GETGREEN(rgb) (((rgb) >> 8) & 0xff) -#define RGB_GETBLUE(rgb) ((rgb) & 0xff) -#define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff)) -#define RGB_MAKE(r, g, b) ((D3DCOLOR) (((r) << 16) | ((g) << 8) | (b))) -#define RGBA_TORGB(rgba) ((D3DCOLOR) ((rgba) & 0xffffff)) -#define RGB_TORGBA(rgb) ((D3DCOLOR) ((rgb) | 0xff000000)) - -#endif - -/* - * Flags for Enumerate functions - */ - -/* - * Stop the enumeration - */ -#define D3DENUMRET_CANCEL DDENUMRET_CANCEL - -/* - * Continue the enumeration - */ -#define D3DENUMRET_OK DDENUMRET_OK - -typedef HRESULT (CALLBACK* LPD3DVALIDATECALLBACK)(LPVOID lpUserArg, DWORD dwOffset); -typedef HRESULT (CALLBACK* LPD3DENUMTEXTUREFORMATSCALLBACK)(LPDDSURFACEDESC lpDdsd, LPVOID lpContext); -typedef HRESULT (CALLBACK* LPD3DENUMPIXELFORMATSCALLBACK)(LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext); - -#ifndef DX_SHARED_DEFINES - -/* - * This definition is shared with other DirectX components whose header files - * might already have defined it. Therefore, we don't define this type if - * someone else already has (as indicated by the definition of - * DX_SHARED_DEFINES). We don't set DX_SHARED_DEFINES here as there are - * other types in this header that are also shared. The last of these - * shared defines in this file will set DX_SHARED_DEFINES. - */ -#ifndef D3DCOLOR_DEFINED -typedef DWORD D3DCOLOR; -#define D3DCOLOR_DEFINED -#endif -typedef DWORD *LPD3DCOLOR; - -#endif /* DX_SHARED_DEFINES */ - -typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE; -typedef DWORD D3DTEXTUREHANDLE, *LPD3DTEXTUREHANDLE; -typedef DWORD D3DMATRIXHANDLE, *LPD3DMATRIXHANDLE; - -#ifndef D3DCOLORVALUE_DEFINED -typedef struct _D3DCOLORVALUE { - union { - D3DVALUE r; - D3DVALUE dvR; - }; - union { - D3DVALUE g; - D3DVALUE dvG; - }; - union { - D3DVALUE b; - D3DVALUE dvB; - }; - union { - D3DVALUE a; - D3DVALUE dvA; - }; -} D3DCOLORVALUE; -#define D3DCOLORVALUE_DEFINED -#endif -typedef struct _D3DCOLORVALUE *LPD3DCOLORVALUE; - -#ifndef D3DRECT_DEFINED -typedef struct _D3DRECT { - union { - LONG x1; - LONG lX1; - }; - union { - LONG y1; - LONG lY1; - }; - union { - LONG x2; - LONG lX2; - }; - union { - LONG y2; - LONG lY2; - }; -} D3DRECT; -#define D3DRECT_DEFINED -#endif -typedef struct _D3DRECT *LPD3DRECT; - -#ifndef DX_SHARED_DEFINES - -/* - * This definition is shared with other DirectX components whose header files - * might already have defined it. Therefore, we don't define this type if - * someone else already has (as indicated by the definition of - * DX_SHARED_DEFINES). - */ - -#ifndef D3DVECTOR_DEFINED -typedef struct _D3DVECTOR { - union { - D3DVALUE x; - D3DVALUE dvX; - }; - union { - D3DVALUE y; - D3DVALUE dvY; - }; - union { - D3DVALUE z; - D3DVALUE dvZ; - }; -#if(DIRECT3D_VERSION >= 0x0500) -#if (defined __cplusplus) && (defined D3D_OVERLOADS) - -public: - - // ===================================== - // Constructors - // ===================================== - - _D3DVECTOR() { } - _D3DVECTOR(D3DVALUE f); - _D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z); - _D3DVECTOR(const D3DVALUE f[3]); - - // ===================================== - // Access grants - // ===================================== - - const D3DVALUE&operator[](int i) const; - D3DVALUE&operator[](int i); - - // ===================================== - // Assignment operators - // ===================================== - - _D3DVECTOR& operator += (const _D3DVECTOR& v); - _D3DVECTOR& operator -= (const _D3DVECTOR& v); - _D3DVECTOR& operator *= (const _D3DVECTOR& v); - _D3DVECTOR& operator /= (const _D3DVECTOR& v); - _D3DVECTOR& operator *= (D3DVALUE s); - _D3DVECTOR& operator /= (D3DVALUE s); - - // ===================================== - // Unary operators - // ===================================== - - friend _D3DVECTOR operator + (const _D3DVECTOR& v); - friend _D3DVECTOR operator - (const _D3DVECTOR& v); - - - // ===================================== - // Binary operators - // ===================================== - - // Addition and subtraction - friend _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2); - friend _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2); - // Scalar multiplication and division - friend _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s); - friend _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v); - friend _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s); - // Memberwise multiplication and division - friend _D3DVECTOR operator * (const _D3DVECTOR& v1, const _D3DVECTOR& v2); - friend _D3DVECTOR operator / (const _D3DVECTOR& v1, const _D3DVECTOR& v2); - - // Vector dominance - friend int operator < (const _D3DVECTOR& v1, const _D3DVECTOR& v2); - friend int operator <= (const _D3DVECTOR& v1, const _D3DVECTOR& v2); - - // Bitwise equality - friend int operator == (const _D3DVECTOR& v1, const _D3DVECTOR& v2); - - // Length-related functions - friend D3DVALUE SquareMagnitude (const _D3DVECTOR& v); - friend D3DVALUE Magnitude (const _D3DVECTOR& v); - - // Returns vector with same direction and unit length - friend _D3DVECTOR Normalize (const _D3DVECTOR& v); - - // Return min/max component of the input vector - friend D3DVALUE Min (const _D3DVECTOR& v); - friend D3DVALUE Max (const _D3DVECTOR& v); - - // Return memberwise min/max of input vectors - friend _D3DVECTOR Minimize (const _D3DVECTOR& v1, const _D3DVECTOR& v2); - friend _D3DVECTOR Maximize (const _D3DVECTOR& v1, const _D3DVECTOR& v2); - - // Dot and cross product - friend D3DVALUE DotProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2); - friend _D3DVECTOR CrossProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2); - -#endif -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DVECTOR; -#define D3DVECTOR_DEFINED -#endif -typedef struct _D3DVECTOR *LPD3DVECTOR; - -/* - * As this is the last of the shared defines to be defined we now set - * D3D_SHARED_DEFINES to flag that fact that this header has defined these - * types. - */ -#define DX_SHARED_DEFINES - -#endif /* DX_SHARED_DEFINES */ - -/* - * Vertex data types supported in an ExecuteBuffer. - */ - -/* - * Homogeneous vertices - */ - -typedef struct _D3DHVERTEX { - DWORD dwFlags; /* Homogeneous clipping flags */ - union { - D3DVALUE hx; - D3DVALUE dvHX; - }; - union { - D3DVALUE hy; - D3DVALUE dvHY; - }; - union { - D3DVALUE hz; - D3DVALUE dvHZ; - }; -} D3DHVERTEX, *LPD3DHVERTEX; - -/* - * Transformed/lit vertices - */ -typedef struct _D3DTLVERTEX { - union { - D3DVALUE sx; /* Screen coordinates */ - D3DVALUE dvSX; - }; - union { - D3DVALUE sy; - D3DVALUE dvSY; - }; - union { - D3DVALUE sz; - D3DVALUE dvSZ; - }; - union { - D3DVALUE rhw; /* Reciprocal of homogeneous w */ - D3DVALUE dvRHW; - }; - union { - D3DCOLOR color; /* Vertex color */ - D3DCOLOR dcColor; - }; - union { - D3DCOLOR specular; /* Specular component of vertex */ - D3DCOLOR dcSpecular; - }; - union { - D3DVALUE tu; /* Texture coordinates */ - D3DVALUE dvTU; - }; - union { - D3DVALUE tv; - D3DVALUE dvTV; - }; -#if(DIRECT3D_VERSION >= 0x0500) -#if (defined __cplusplus) && (defined D3D_OVERLOADS) - _D3DTLVERTEX() { } - _D3DTLVERTEX(const D3DVECTOR& v, float _rhw, - D3DCOLOR _color, D3DCOLOR _specular, - float _tu, float _tv) - { sx = v.x; sy = v.y; sz = v.z; rhw = _rhw; - color = _color; specular = _specular; - tu = _tu; tv = _tv; - } -#endif -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DTLVERTEX, *LPD3DTLVERTEX; - -/* - * Untransformed/lit vertices - */ -typedef struct _D3DLVERTEX { - union { - D3DVALUE x; /* Homogeneous coordinates */ - D3DVALUE dvX; - }; - union { - D3DVALUE y; - D3DVALUE dvY; - }; - union { - D3DVALUE z; - D3DVALUE dvZ; - }; - DWORD dwReserved; - union { - D3DCOLOR color; /* Vertex color */ - D3DCOLOR dcColor; - }; - union { - D3DCOLOR specular; /* Specular component of vertex */ - D3DCOLOR dcSpecular; - }; - union { - D3DVALUE tu; /* Texture coordinates */ - D3DVALUE dvTU; - }; - union { - D3DVALUE tv; - D3DVALUE dvTV; - }; -#if(DIRECT3D_VERSION >= 0x0500) -#if (defined __cplusplus) && (defined D3D_OVERLOADS) - _D3DLVERTEX() { } - _D3DLVERTEX(const D3DVECTOR& v, - D3DCOLOR _color, D3DCOLOR _specular, - float _tu, float _tv) - { x = v.x; y = v.y; z = v.z; dwReserved = 0; - color = _color; specular = _specular; - tu = _tu; tv = _tv; - } -#endif -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DLVERTEX, *LPD3DLVERTEX; - -/* - * Untransformed/unlit vertices - */ - -typedef struct _D3DVERTEX { - union { - D3DVALUE x; /* Homogeneous coordinates */ - D3DVALUE dvX; - }; - union { - D3DVALUE y; - D3DVALUE dvY; - }; - union { - D3DVALUE z; - D3DVALUE dvZ; - }; - union { - D3DVALUE nx; /* Normal */ - D3DVALUE dvNX; - }; - union { - D3DVALUE ny; - D3DVALUE dvNY; - }; - union { - D3DVALUE nz; - D3DVALUE dvNZ; - }; - union { - D3DVALUE tu; /* Texture coordinates */ - D3DVALUE dvTU; - }; - union { - D3DVALUE tv; - D3DVALUE dvTV; - }; -#if(DIRECT3D_VERSION >= 0x0500) -#if (defined __cplusplus) && (defined D3D_OVERLOADS) - _D3DVERTEX() { } - _D3DVERTEX(const D3DVECTOR& v, const D3DVECTOR& n, float _tu, float _tv) - { x = v.x; y = v.y; z = v.z; - nx = n.x; ny = n.y; nz = n.z; - tu = _tu; tv = _tv; - } -#endif -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DVERTEX, *LPD3DVERTEX; - - -/* - * Matrix, viewport, and tranformation structures and definitions. - */ - -#ifndef D3DMATRIX_DEFINED -typedef struct _D3DMATRIX { -#if(DIRECT3D_VERSION >= 0x0500) -#if (defined __cplusplus) && (defined D3D_OVERLOADS) - union { - struct { -#endif - -#endif /* DIRECT3D_VERSION >= 0x0500 */ - D3DVALUE _11, _12, _13, _14; - D3DVALUE _21, _22, _23, _24; - D3DVALUE _31, _32, _33, _34; - D3DVALUE _41, _42, _43, _44; - -#if(DIRECT3D_VERSION >= 0x0500) -#if (defined __cplusplus) && (defined D3D_OVERLOADS) - }; - D3DVALUE m[4][4]; - }; - _D3DMATRIX() { } - _D3DMATRIX( D3DVALUE _m00, D3DVALUE _m01, D3DVALUE _m02, D3DVALUE _m03, - D3DVALUE _m10, D3DVALUE _m11, D3DVALUE _m12, D3DVALUE _m13, - D3DVALUE _m20, D3DVALUE _m21, D3DVALUE _m22, D3DVALUE _m23, - D3DVALUE _m30, D3DVALUE _m31, D3DVALUE _m32, D3DVALUE _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; - } - - D3DVALUE& operator()(int iRow, int iColumn) { return m[iRow][iColumn]; } - const D3DVALUE& operator()(int iRow, int iColumn) const { return m[iRow][iColumn]; } -#if(DIRECT3D_VERSION >= 0x0600) - friend _D3DMATRIX operator* (const _D3DMATRIX&, const _D3DMATRIX&); -#endif /* DIRECT3D_VERSION >= 0x0600 */ -#endif -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DMATRIX; -#define D3DMATRIX_DEFINED -#endif -typedef struct _D3DMATRIX *LPD3DMATRIX; - -#if (defined __cplusplus) && (defined D3D_OVERLOADS) -#include "d3dvec.inl" -#endif - -typedef struct _D3DVIEWPORT { - DWORD dwSize; - DWORD dwX; - DWORD dwY; /* Top left */ - DWORD dwWidth; - DWORD dwHeight; /* Dimensions */ - D3DVALUE dvScaleX; /* Scale homogeneous to screen */ - D3DVALUE dvScaleY; /* Scale homogeneous to screen */ - D3DVALUE dvMaxX; /* Min/max homogeneous x coord */ - D3DVALUE dvMaxY; /* Min/max homogeneous y coord */ - D3DVALUE dvMinZ; - D3DVALUE dvMaxZ; /* Min/max homogeneous z coord */ -} D3DVIEWPORT, *LPD3DVIEWPORT; - -#if(DIRECT3D_VERSION >= 0x0500) -typedef struct _D3DVIEWPORT2 { - DWORD dwSize; - DWORD dwX; - DWORD dwY; /* Viewport Top left */ - DWORD dwWidth; - DWORD dwHeight; /* Viewport Dimensions */ - D3DVALUE dvClipX; /* Top left of clip volume */ - D3DVALUE dvClipY; - D3DVALUE dvClipWidth; /* Clip Volume Dimensions */ - D3DVALUE dvClipHeight; - D3DVALUE dvMinZ; /* Min/max of clip Volume */ - D3DVALUE dvMaxZ; -} D3DVIEWPORT2, *LPD3DVIEWPORT2; -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if(DIRECT3D_VERSION >= 0x0700) -typedef struct _D3DVIEWPORT7 { - DWORD dwX; - DWORD dwY; /* Viewport Top left */ - DWORD dwWidth; - DWORD dwHeight; /* Viewport Dimensions */ - D3DVALUE dvMinZ; /* Min/max of clip Volume */ - D3DVALUE dvMaxZ; -} D3DVIEWPORT7, *LPD3DVIEWPORT7; -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -/* - * Values for clip fields. - */ - -#if(DIRECT3D_VERSION >= 0x0700) - -// Max number of user clipping planes, supported in D3D. -#define D3DMAXUSERCLIPPLANES 32 - -// These bits could be ORed together to use with D3DRENDERSTATE_CLIPPLANEENABLE -// -#define D3DCLIPPLANE0 (1 << 0) -#define D3DCLIPPLANE1 (1 << 1) -#define D3DCLIPPLANE2 (1 << 2) -#define D3DCLIPPLANE3 (1 << 3) -#define D3DCLIPPLANE4 (1 << 4) -#define D3DCLIPPLANE5 (1 << 5) - -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -#define D3DCLIP_LEFT 0x00000001L -#define D3DCLIP_RIGHT 0x00000002L -#define D3DCLIP_TOP 0x00000004L -#define D3DCLIP_BOTTOM 0x00000008L -#define D3DCLIP_FRONT 0x00000010L -#define D3DCLIP_BACK 0x00000020L -#define D3DCLIP_GEN0 0x00000040L -#define D3DCLIP_GEN1 0x00000080L -#define D3DCLIP_GEN2 0x00000100L -#define D3DCLIP_GEN3 0x00000200L -#define D3DCLIP_GEN4 0x00000400L -#define D3DCLIP_GEN5 0x00000800L - -/* - * Values for d3d status. - */ -#define D3DSTATUS_CLIPUNIONLEFT D3DCLIP_LEFT -#define D3DSTATUS_CLIPUNIONRIGHT D3DCLIP_RIGHT -#define D3DSTATUS_CLIPUNIONTOP D3DCLIP_TOP -#define D3DSTATUS_CLIPUNIONBOTTOM D3DCLIP_BOTTOM -#define D3DSTATUS_CLIPUNIONFRONT D3DCLIP_FRONT -#define D3DSTATUS_CLIPUNIONBACK D3DCLIP_BACK -#define D3DSTATUS_CLIPUNIONGEN0 D3DCLIP_GEN0 -#define D3DSTATUS_CLIPUNIONGEN1 D3DCLIP_GEN1 -#define D3DSTATUS_CLIPUNIONGEN2 D3DCLIP_GEN2 -#define D3DSTATUS_CLIPUNIONGEN3 D3DCLIP_GEN3 -#define D3DSTATUS_CLIPUNIONGEN4 D3DCLIP_GEN4 -#define D3DSTATUS_CLIPUNIONGEN5 D3DCLIP_GEN5 - -#define D3DSTATUS_CLIPINTERSECTIONLEFT 0x00001000L -#define D3DSTATUS_CLIPINTERSECTIONRIGHT 0x00002000L -#define D3DSTATUS_CLIPINTERSECTIONTOP 0x00004000L -#define D3DSTATUS_CLIPINTERSECTIONBOTTOM 0x00008000L -#define D3DSTATUS_CLIPINTERSECTIONFRONT 0x00010000L -#define D3DSTATUS_CLIPINTERSECTIONBACK 0x00020000L -#define D3DSTATUS_CLIPINTERSECTIONGEN0 0x00040000L -#define D3DSTATUS_CLIPINTERSECTIONGEN1 0x00080000L -#define D3DSTATUS_CLIPINTERSECTIONGEN2 0x00100000L -#define D3DSTATUS_CLIPINTERSECTIONGEN3 0x00200000L -#define D3DSTATUS_CLIPINTERSECTIONGEN4 0x00400000L -#define D3DSTATUS_CLIPINTERSECTIONGEN5 0x00800000L -#define D3DSTATUS_ZNOTVISIBLE 0x01000000L -/* Do not use 0x80000000 for any status flags in future as it is reserved */ - -#define D3DSTATUS_CLIPUNIONALL ( \ - D3DSTATUS_CLIPUNIONLEFT | \ - D3DSTATUS_CLIPUNIONRIGHT | \ - D3DSTATUS_CLIPUNIONTOP | \ - D3DSTATUS_CLIPUNIONBOTTOM | \ - D3DSTATUS_CLIPUNIONFRONT | \ - D3DSTATUS_CLIPUNIONBACK | \ - D3DSTATUS_CLIPUNIONGEN0 | \ - D3DSTATUS_CLIPUNIONGEN1 | \ - D3DSTATUS_CLIPUNIONGEN2 | \ - D3DSTATUS_CLIPUNIONGEN3 | \ - D3DSTATUS_CLIPUNIONGEN4 | \ - D3DSTATUS_CLIPUNIONGEN5 \ - ) - -#define D3DSTATUS_CLIPINTERSECTIONALL ( \ - D3DSTATUS_CLIPINTERSECTIONLEFT | \ - D3DSTATUS_CLIPINTERSECTIONRIGHT | \ - D3DSTATUS_CLIPINTERSECTIONTOP | \ - D3DSTATUS_CLIPINTERSECTIONBOTTOM | \ - D3DSTATUS_CLIPINTERSECTIONFRONT | \ - D3DSTATUS_CLIPINTERSECTIONBACK | \ - D3DSTATUS_CLIPINTERSECTIONGEN0 | \ - D3DSTATUS_CLIPINTERSECTIONGEN1 | \ - D3DSTATUS_CLIPINTERSECTIONGEN2 | \ - D3DSTATUS_CLIPINTERSECTIONGEN3 | \ - D3DSTATUS_CLIPINTERSECTIONGEN4 | \ - D3DSTATUS_CLIPINTERSECTIONGEN5 \ - ) - -#define D3DSTATUS_DEFAULT ( \ - D3DSTATUS_CLIPINTERSECTIONALL | \ - D3DSTATUS_ZNOTVISIBLE) - - -/* - * Options for direct transform calls - */ -#define D3DTRANSFORM_CLIPPED 0x00000001l -#define D3DTRANSFORM_UNCLIPPED 0x00000002l - -typedef struct _D3DTRANSFORMDATA { - DWORD dwSize; - LPVOID lpIn; /* Input vertices */ - DWORD dwInSize; /* Stride of input vertices */ - LPVOID lpOut; /* Output vertices */ - DWORD dwOutSize; /* Stride of output vertices */ - LPD3DHVERTEX lpHOut; /* Output homogeneous vertices */ - DWORD dwClip; /* Clipping hint */ - DWORD dwClipIntersection; - DWORD dwClipUnion; /* Union of all clip flags */ - D3DRECT drExtent; /* Extent of transformed vertices */ -} D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA; - -/* - * Structure defining position and direction properties for lighting. - */ -typedef struct _D3DLIGHTINGELEMENT { - D3DVECTOR dvPosition; /* Lightable point in model space */ - D3DVECTOR dvNormal; /* Normalised unit vector */ -} D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT; - -/* - * Structure defining material properties for lighting. - */ -typedef struct _D3DMATERIAL { - DWORD dwSize; - union { - D3DCOLORVALUE diffuse; /* Diffuse color RGBA */ - D3DCOLORVALUE dcvDiffuse; - }; - union { - D3DCOLORVALUE ambient; /* Ambient color RGB */ - D3DCOLORVALUE dcvAmbient; - }; - union { - D3DCOLORVALUE specular; /* Specular 'shininess' */ - D3DCOLORVALUE dcvSpecular; - }; - union { - D3DCOLORVALUE emissive; /* Emissive color RGB */ - D3DCOLORVALUE dcvEmissive; - }; - union { - D3DVALUE power; /* Sharpness if specular highlight */ - D3DVALUE dvPower; - }; - D3DTEXTUREHANDLE hTexture; /* Handle to texture map */ - DWORD dwRampSize; -} D3DMATERIAL, *LPD3DMATERIAL; - -#if(DIRECT3D_VERSION >= 0x0700) - -typedef struct _D3DMATERIAL7 { - union { - D3DCOLORVALUE diffuse; /* Diffuse color RGBA */ - D3DCOLORVALUE dcvDiffuse; - }; - union { - D3DCOLORVALUE ambient; /* Ambient color RGB */ - D3DCOLORVALUE dcvAmbient; - }; - union { - D3DCOLORVALUE specular; /* Specular 'shininess' */ - D3DCOLORVALUE dcvSpecular; - }; - union { - D3DCOLORVALUE emissive; /* Emissive color RGB */ - D3DCOLORVALUE dcvEmissive; - }; - union { - D3DVALUE power; /* Sharpness if specular highlight */ - D3DVALUE dvPower; - }; -} D3DMATERIAL7, *LPD3DMATERIAL7; - -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -#if(DIRECT3D_VERSION < 0x0800) - -typedef enum _D3DLIGHTTYPE { - D3DLIGHT_POINT = 1, - D3DLIGHT_SPOT = 2, - D3DLIGHT_DIRECTIONAL = 3, -// Note: The following light type (D3DLIGHT_PARALLELPOINT) -// is no longer supported from D3D for DX7 onwards. - D3DLIGHT_PARALLELPOINT = 4, -#if(DIRECT3D_VERSION < 0x0500) // For backward compatible headers - D3DLIGHT_GLSPOT = 5, -#endif - D3DLIGHT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DLIGHTTYPE; - -#else -typedef enum _D3DLIGHTTYPE D3DLIGHTTYPE; -#define D3DLIGHT_PARALLELPOINT (D3DLIGHTTYPE)4 -#define D3DLIGHT_GLSPOT (D3DLIGHTTYPE)5 - -#endif //(DIRECT3D_VERSION < 0x0800) - -/* - * Structure defining a light source and its properties. - */ -typedef struct _D3DLIGHT { - DWORD dwSize; - D3DLIGHTTYPE dltType; /* Type of light source */ - D3DCOLORVALUE dcvColor; /* Color of light */ - D3DVECTOR dvPosition; /* Position in world space */ - D3DVECTOR dvDirection; /* Direction in world space */ - D3DVALUE dvRange; /* Cutoff range */ - D3DVALUE dvFalloff; /* Falloff */ - D3DVALUE dvAttenuation0; /* Constant attenuation */ - D3DVALUE dvAttenuation1; /* Linear attenuation */ - D3DVALUE dvAttenuation2; /* Quadratic attenuation */ - D3DVALUE dvTheta; /* Inner angle of spotlight cone */ - D3DVALUE dvPhi; /* Outer angle of spotlight cone */ -} D3DLIGHT, *LPD3DLIGHT; - -#if(DIRECT3D_VERSION >= 0x0700) - -typedef struct _D3DLIGHT7 { - D3DLIGHTTYPE dltType; /* Type of light source */ - D3DCOLORVALUE dcvDiffuse; /* Diffuse color of light */ - D3DCOLORVALUE dcvSpecular; /* Specular color of light */ - D3DCOLORVALUE dcvAmbient; /* Ambient color of light */ - D3DVECTOR dvPosition; /* Position in world space */ - D3DVECTOR dvDirection; /* Direction in world space */ - D3DVALUE dvRange; /* Cutoff range */ - D3DVALUE dvFalloff; /* Falloff */ - D3DVALUE dvAttenuation0; /* Constant attenuation */ - D3DVALUE dvAttenuation1; /* Linear attenuation */ - D3DVALUE dvAttenuation2; /* Quadratic attenuation */ - D3DVALUE dvTheta; /* Inner angle of spotlight cone */ - D3DVALUE dvPhi; /* Outer angle of spotlight cone */ -} D3DLIGHT7, *LPD3DLIGHT7; - -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -#if(DIRECT3D_VERSION >= 0x0500) -/* - * Structure defining a light source and its properties. - */ - -/* flags bits */ -#define D3DLIGHT_ACTIVE 0x00000001 -#define D3DLIGHT_NO_SPECULAR 0x00000002 -#define D3DLIGHT_ALL (D3DLIGHT_ACTIVE | D3DLIGHT_NO_SPECULAR) - -/* maximum valid light range */ -#define D3DLIGHT_RANGE_MAX ((float)sqrt(FLT_MAX)) - -typedef struct _D3DLIGHT2 { - DWORD dwSize; - D3DLIGHTTYPE dltType; /* Type of light source */ - D3DCOLORVALUE dcvColor; /* Color of light */ - D3DVECTOR dvPosition; /* Position in world space */ - D3DVECTOR dvDirection; /* Direction in world space */ - D3DVALUE dvRange; /* Cutoff range */ - D3DVALUE dvFalloff; /* Falloff */ - D3DVALUE dvAttenuation0; /* Constant attenuation */ - D3DVALUE dvAttenuation1; /* Linear attenuation */ - D3DVALUE dvAttenuation2; /* Quadratic attenuation */ - D3DVALUE dvTheta; /* Inner angle of spotlight cone */ - D3DVALUE dvPhi; /* Outer angle of spotlight cone */ - DWORD dwFlags; -} D3DLIGHT2, *LPD3DLIGHT2; - -#endif /* DIRECT3D_VERSION >= 0x0500 */ -typedef struct _D3DLIGHTDATA { - DWORD dwSize; - LPD3DLIGHTINGELEMENT lpIn; /* Input positions and normals */ - DWORD dwInSize; /* Stride of input elements */ - LPD3DTLVERTEX lpOut; /* Output colors */ - DWORD dwOutSize; /* Stride of output colors */ -} D3DLIGHTDATA, *LPD3DLIGHTDATA; - -#if(DIRECT3D_VERSION >= 0x0500) -/* - * Before DX5, these values were in an enum called - * D3DCOLORMODEL. This was not correct, since they are - * bit flags. A driver can surface either or both flags - * in the dcmColorModel member of D3DDEVICEDESC. - */ -#define D3DCOLOR_MONO 1 -#define D3DCOLOR_RGB 2 - -typedef DWORD D3DCOLORMODEL; -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -/* - * Options for clearing - */ -#define D3DCLEAR_TARGET 0x00000001l /* Clear target surface */ -#define D3DCLEAR_ZBUFFER 0x00000002l /* Clear target z buffer */ -#if(DIRECT3D_VERSION >= 0x0600) -#define D3DCLEAR_STENCIL 0x00000004l /* Clear stencil planes */ -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -/* - * Execute buffers are allocated via Direct3D. These buffers may then - * be filled by the application with instructions to execute along with - * vertex data. - */ - -/* - * Supported op codes for execute instructions. - */ -typedef enum _D3DOPCODE { - D3DOP_POINT = 1, - D3DOP_LINE = 2, - D3DOP_TRIANGLE = 3, - D3DOP_MATRIXLOAD = 4, - D3DOP_MATRIXMULTIPLY = 5, - D3DOP_STATETRANSFORM = 6, - D3DOP_STATELIGHT = 7, - D3DOP_STATERENDER = 8, - D3DOP_PROCESSVERTICES = 9, - D3DOP_TEXTURELOAD = 10, - D3DOP_EXIT = 11, - D3DOP_BRANCHFORWARD = 12, - D3DOP_SPAN = 13, - D3DOP_SETSTATUS = 14, -#if(DIRECT3D_VERSION >= 0x0500) - D3DOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DOPCODE; - -typedef struct _D3DINSTRUCTION { - BYTE bOpcode; /* Instruction opcode */ - BYTE bSize; /* Size of each instruction data unit */ - WORD wCount; /* Count of instruction data units to follow */ -} D3DINSTRUCTION, *LPD3DINSTRUCTION; - -/* - * Structure for texture loads - */ -typedef struct _D3DTEXTURELOAD { - D3DTEXTUREHANDLE hDestTexture; - D3DTEXTUREHANDLE hSrcTexture; -} D3DTEXTURELOAD, *LPD3DTEXTURELOAD; - -/* - * Structure for picking - */ -typedef struct _D3DPICKRECORD { - BYTE bOpcode; - BYTE bPad; - DWORD dwOffset; - D3DVALUE dvZ; -} D3DPICKRECORD, *LPD3DPICKRECORD; - -/* - * The following defines the rendering states which can be set in the - * execute buffer. - */ - -#if(DIRECT3D_VERSION < 0x0800) - -typedef enum _D3DSHADEMODE { - D3DSHADE_FLAT = 1, - D3DSHADE_GOURAUD = 2, - D3DSHADE_PHONG = 3, -#if(DIRECT3D_VERSION >= 0x0500) - D3DSHADE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DSHADEMODE; - -typedef enum _D3DFILLMODE { - D3DFILL_POINT = 1, - D3DFILL_WIREFRAME = 2, - D3DFILL_SOLID = 3, -#if(DIRECT3D_VERSION >= 0x0500) - D3DFILL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DFILLMODE; - -typedef struct _D3DLINEPATTERN { - WORD wRepeatFactor; - WORD wLinePattern; -} D3DLINEPATTERN; - -#endif //(DIRECT3D_VERSION < 0x0800) - -typedef enum _D3DTEXTUREFILTER { - D3DFILTER_NEAREST = 1, - D3DFILTER_LINEAR = 2, - D3DFILTER_MIPNEAREST = 3, - D3DFILTER_MIPLINEAR = 4, - D3DFILTER_LINEARMIPNEAREST = 5, - D3DFILTER_LINEARMIPLINEAR = 6, -#if(DIRECT3D_VERSION >= 0x0500) - D3DFILTER_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DTEXTUREFILTER; - -#if(DIRECT3D_VERSION < 0x0800) - -typedef enum _D3DBLEND { - D3DBLEND_ZERO = 1, - D3DBLEND_ONE = 2, - D3DBLEND_SRCCOLOR = 3, - D3DBLEND_INVSRCCOLOR = 4, - D3DBLEND_SRCALPHA = 5, - D3DBLEND_INVSRCALPHA = 6, - D3DBLEND_DESTALPHA = 7, - D3DBLEND_INVDESTALPHA = 8, - D3DBLEND_DESTCOLOR = 9, - D3DBLEND_INVDESTCOLOR = 10, - D3DBLEND_SRCALPHASAT = 11, - D3DBLEND_BOTHSRCALPHA = 12, - D3DBLEND_BOTHINVSRCALPHA = 13, -#if(DIRECT3D_VERSION >= 0x0500) - D3DBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DBLEND; - -#endif //(DIRECT3D_VERSION < 0x0800) - -typedef enum _D3DTEXTUREBLEND { - D3DTBLEND_DECAL = 1, - D3DTBLEND_MODULATE = 2, - D3DTBLEND_DECALALPHA = 3, - D3DTBLEND_MODULATEALPHA = 4, - D3DTBLEND_DECALMASK = 5, - D3DTBLEND_MODULATEMASK = 6, - D3DTBLEND_COPY = 7, -#if(DIRECT3D_VERSION >= 0x0500) - D3DTBLEND_ADD = 8, - D3DTBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DTEXTUREBLEND; - -#if(DIRECT3D_VERSION < 0x0800) - -typedef enum _D3DTEXTUREADDRESS { - D3DTADDRESS_WRAP = 1, - D3DTADDRESS_MIRROR = 2, - D3DTADDRESS_CLAMP = 3, -#if(DIRECT3D_VERSION >= 0x0500) - D3DTADDRESS_BORDER = 4, - D3DTADDRESS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DTEXTUREADDRESS; - -typedef enum _D3DCULL { - D3DCULL_NONE = 1, - D3DCULL_CW = 2, - D3DCULL_CCW = 3, -#if(DIRECT3D_VERSION >= 0x0500) - D3DCULL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DCULL; - -typedef enum _D3DCMPFUNC { - D3DCMP_NEVER = 1, - D3DCMP_LESS = 2, - D3DCMP_EQUAL = 3, - D3DCMP_LESSEQUAL = 4, - D3DCMP_GREATER = 5, - D3DCMP_NOTEQUAL = 6, - D3DCMP_GREATEREQUAL = 7, - D3DCMP_ALWAYS = 8, -#if(DIRECT3D_VERSION >= 0x0500) - D3DCMP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DCMPFUNC; - -#if(DIRECT3D_VERSION >= 0x0600) -typedef enum _D3DSTENCILOP { - D3DSTENCILOP_KEEP = 1, - D3DSTENCILOP_ZERO = 2, - D3DSTENCILOP_REPLACE = 3, - D3DSTENCILOP_INCRSAT = 4, - D3DSTENCILOP_DECRSAT = 5, - D3DSTENCILOP_INVERT = 6, - D3DSTENCILOP_INCR = 7, - D3DSTENCILOP_DECR = 8, - D3DSTENCILOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DSTENCILOP; -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -typedef enum _D3DFOGMODE { - D3DFOG_NONE = 0, - D3DFOG_EXP = 1, - D3DFOG_EXP2 = 2, -#if(DIRECT3D_VERSION >= 0x0500) - D3DFOG_LINEAR = 3, - D3DFOG_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DFOGMODE; - -#if(DIRECT3D_VERSION >= 0x0600) -typedef enum _D3DZBUFFERTYPE { - D3DZB_FALSE = 0, - D3DZB_TRUE = 1, // Z buffering - D3DZB_USEW = 2, // W buffering - D3DZB_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DZBUFFERTYPE; -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -#endif //(DIRECT3D_VERSION < 0x0800) - -#if(DIRECT3D_VERSION >= 0x0500) -typedef enum _D3DANTIALIASMODE { - D3DANTIALIAS_NONE = 0, - D3DANTIALIAS_SORTDEPENDENT = 1, - D3DANTIALIAS_SORTINDEPENDENT = 2, - D3DANTIALIAS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DANTIALIASMODE; - -// Vertex types supported by Direct3D -typedef enum _D3DVERTEXTYPE { - D3DVT_VERTEX = 1, - D3DVT_LVERTEX = 2, - D3DVT_TLVERTEX = 3, - D3DVT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DVERTEXTYPE; - -#if(DIRECT3D_VERSION < 0x0800) - -// Primitives supported by draw-primitive API -typedef enum _D3DPRIMITIVETYPE { - D3DPT_POINTLIST = 1, - D3DPT_LINELIST = 2, - D3DPT_LINESTRIP = 3, - D3DPT_TRIANGLELIST = 4, - D3DPT_TRIANGLESTRIP = 5, - D3DPT_TRIANGLEFAN = 6, - D3DPT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DPRIMITIVETYPE; - -#endif //(DIRECT3D_VERSION < 0x0800) - -#endif /* DIRECT3D_VERSION >= 0x0500 */ -/* - * Amount to add to a state to generate the override for that state. - */ -#define D3DSTATE_OVERRIDE_BIAS 256 - -/* - * A state which sets the override flag for the specified state type. - */ -#define D3DSTATE_OVERRIDE(type) (D3DRENDERSTATETYPE)(((DWORD) (type) + D3DSTATE_OVERRIDE_BIAS)) - -#if(DIRECT3D_VERSION < 0x0800) - -typedef enum _D3DTRANSFORMSTATETYPE { - D3DTRANSFORMSTATE_WORLD = 1, - D3DTRANSFORMSTATE_VIEW = 2, - D3DTRANSFORMSTATE_PROJECTION = 3, -#if(DIRECT3D_VERSION >= 0x0700) - D3DTRANSFORMSTATE_WORLD1 = 4, // 2nd matrix to blend - D3DTRANSFORMSTATE_WORLD2 = 5, // 3rd matrix to blend - D3DTRANSFORMSTATE_WORLD3 = 6, // 4th matrix to blend - D3DTRANSFORMSTATE_TEXTURE0 = 16, - D3DTRANSFORMSTATE_TEXTURE1 = 17, - D3DTRANSFORMSTATE_TEXTURE2 = 18, - D3DTRANSFORMSTATE_TEXTURE3 = 19, - D3DTRANSFORMSTATE_TEXTURE4 = 20, - D3DTRANSFORMSTATE_TEXTURE5 = 21, - D3DTRANSFORMSTATE_TEXTURE6 = 22, - D3DTRANSFORMSTATE_TEXTURE7 = 23, -#endif /* DIRECT3D_VERSION >= 0x0700 */ -#if(DIRECT3D_VERSION >= 0x0500) - D3DTRANSFORMSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DTRANSFORMSTATETYPE; - -#else - -// -// legacy transform state names -// -typedef enum _D3DTRANSFORMSTATETYPE D3DTRANSFORMSTATETYPE; -#define D3DTRANSFORMSTATE_WORLD (D3DTRANSFORMSTATETYPE)1 -#define D3DTRANSFORMSTATE_VIEW (D3DTRANSFORMSTATETYPE)2 -#define D3DTRANSFORMSTATE_PROJECTION (D3DTRANSFORMSTATETYPE)3 -#define D3DTRANSFORMSTATE_WORLD1 (D3DTRANSFORMSTATETYPE)4 -#define D3DTRANSFORMSTATE_WORLD2 (D3DTRANSFORMSTATETYPE)5 -#define D3DTRANSFORMSTATE_WORLD3 (D3DTRANSFORMSTATETYPE)6 -#define D3DTRANSFORMSTATE_TEXTURE0 (D3DTRANSFORMSTATETYPE)16 -#define D3DTRANSFORMSTATE_TEXTURE1 (D3DTRANSFORMSTATETYPE)17 -#define D3DTRANSFORMSTATE_TEXTURE2 (D3DTRANSFORMSTATETYPE)18 -#define D3DTRANSFORMSTATE_TEXTURE3 (D3DTRANSFORMSTATETYPE)19 -#define D3DTRANSFORMSTATE_TEXTURE4 (D3DTRANSFORMSTATETYPE)20 -#define D3DTRANSFORMSTATE_TEXTURE5 (D3DTRANSFORMSTATETYPE)21 -#define D3DTRANSFORMSTATE_TEXTURE6 (D3DTRANSFORMSTATETYPE)22 -#define D3DTRANSFORMSTATE_TEXTURE7 (D3DTRANSFORMSTATETYPE)23 - -#endif //(DIRECT3D_VERSION < 0x0800) - -typedef enum _D3DLIGHTSTATETYPE { - D3DLIGHTSTATE_MATERIAL = 1, - D3DLIGHTSTATE_AMBIENT = 2, - D3DLIGHTSTATE_COLORMODEL = 3, - D3DLIGHTSTATE_FOGMODE = 4, - D3DLIGHTSTATE_FOGSTART = 5, - D3DLIGHTSTATE_FOGEND = 6, - D3DLIGHTSTATE_FOGDENSITY = 7, -#if(DIRECT3D_VERSION >= 0x0600) - D3DLIGHTSTATE_COLORVERTEX = 8, -#endif /* DIRECT3D_VERSION >= 0x0600 */ -#if(DIRECT3D_VERSION >= 0x0500) - D3DLIGHTSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DLIGHTSTATETYPE; - -#if(DIRECT3D_VERSION < 0x0800) - -typedef enum _D3DRENDERSTATETYPE { - D3DRENDERSTATE_ANTIALIAS = 2, /* D3DANTIALIASMODE */ - D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4, /* TRUE for perspective correction */ - D3DRENDERSTATE_ZENABLE = 7, /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */ - D3DRENDERSTATE_FILLMODE = 8, /* D3DFILL_MODE */ - D3DRENDERSTATE_SHADEMODE = 9, /* D3DSHADEMODE */ - D3DRENDERSTATE_LINEPATTERN = 10, /* D3DLINEPATTERN */ - D3DRENDERSTATE_ZWRITEENABLE = 14, /* TRUE to enable z writes */ - D3DRENDERSTATE_ALPHATESTENABLE = 15, /* TRUE to enable alpha tests */ - D3DRENDERSTATE_LASTPIXEL = 16, /* TRUE for last-pixel on lines */ - D3DRENDERSTATE_SRCBLEND = 19, /* D3DBLEND */ - D3DRENDERSTATE_DESTBLEND = 20, /* D3DBLEND */ - D3DRENDERSTATE_CULLMODE = 22, /* D3DCULL */ - D3DRENDERSTATE_ZFUNC = 23, /* D3DCMPFUNC */ - D3DRENDERSTATE_ALPHAREF = 24, /* D3DFIXED */ - D3DRENDERSTATE_ALPHAFUNC = 25, /* D3DCMPFUNC */ - D3DRENDERSTATE_DITHERENABLE = 26, /* TRUE to enable dithering */ -#if(DIRECT3D_VERSION >= 0x0500) - D3DRENDERSTATE_ALPHABLENDENABLE = 27, /* TRUE to enable alpha blending */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ - D3DRENDERSTATE_FOGENABLE = 28, /* TRUE to enable fog blending */ - D3DRENDERSTATE_SPECULARENABLE = 29, /* TRUE to enable specular */ - D3DRENDERSTATE_ZVISIBLE = 30, /* TRUE to enable z checking */ - D3DRENDERSTATE_STIPPLEDALPHA = 33, /* TRUE to enable stippled alpha (RGB device only) */ - D3DRENDERSTATE_FOGCOLOR = 34, /* D3DCOLOR */ - D3DRENDERSTATE_FOGTABLEMODE = 35, /* D3DFOGMODE */ -#if(DIRECT3D_VERSION >= 0x0700) - D3DRENDERSTATE_FOGSTART = 36, /* Fog start (for both vertex and pixel fog) */ - D3DRENDERSTATE_FOGEND = 37, /* Fog end */ - D3DRENDERSTATE_FOGDENSITY = 38, /* Fog density */ -#endif /* DIRECT3D_VERSION >= 0x0700 */ -#if(DIRECT3D_VERSION >= 0x0500) - D3DRENDERSTATE_EDGEANTIALIAS = 40, /* TRUE to enable edge antialiasing */ - D3DRENDERSTATE_COLORKEYENABLE = 41, /* TRUE to enable source colorkeyed textures */ - D3DRENDERSTATE_ZBIAS = 47, /* LONG Z bias */ - D3DRENDERSTATE_RANGEFOGENABLE = 48, /* Enables range-based fog */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if(DIRECT3D_VERSION >= 0x0600) - D3DRENDERSTATE_STENCILENABLE = 52, /* BOOL enable/disable stenciling */ - D3DRENDERSTATE_STENCILFAIL = 53, /* D3DSTENCILOP to do if stencil test fails */ - D3DRENDERSTATE_STENCILZFAIL = 54, /* D3DSTENCILOP to do if stencil test passes and Z test fails */ - D3DRENDERSTATE_STENCILPASS = 55, /* D3DSTENCILOP to do if both stencil and Z tests pass */ - D3DRENDERSTATE_STENCILFUNC = 56, /* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */ - D3DRENDERSTATE_STENCILREF = 57, /* Reference value used in stencil test */ - D3DRENDERSTATE_STENCILMASK = 58, /* Mask value used in stencil test */ - D3DRENDERSTATE_STENCILWRITEMASK = 59, /* Write mask applied to values written to stencil buffer */ - D3DRENDERSTATE_TEXTUREFACTOR = 60, /* D3DCOLOR used for multi-texture blend */ -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -#if(DIRECT3D_VERSION >= 0x0600) - - /* - * 128 values [128, 255] are reserved for texture coordinate wrap flags. - * These are constructed with the D3DWRAP_U and D3DWRAP_V macros. Using - * a flags word preserves forward compatibility with texture coordinates - * that are >2D. - */ - D3DRENDERSTATE_WRAP0 = 128, /* wrap for 1st texture coord. set */ - D3DRENDERSTATE_WRAP1 = 129, /* wrap for 2nd texture coord. set */ - D3DRENDERSTATE_WRAP2 = 130, /* wrap for 3rd texture coord. set */ - D3DRENDERSTATE_WRAP3 = 131, /* wrap for 4th texture coord. set */ - D3DRENDERSTATE_WRAP4 = 132, /* wrap for 5th texture coord. set */ - D3DRENDERSTATE_WRAP5 = 133, /* wrap for 6th texture coord. set */ - D3DRENDERSTATE_WRAP6 = 134, /* wrap for 7th texture coord. set */ - D3DRENDERSTATE_WRAP7 = 135, /* wrap for 8th texture coord. set */ -#endif /* DIRECT3D_VERSION >= 0x0600 */ -#if(DIRECT3D_VERSION >= 0x0700) - D3DRENDERSTATE_CLIPPING = 136, - D3DRENDERSTATE_LIGHTING = 137, - D3DRENDERSTATE_EXTENTS = 138, - D3DRENDERSTATE_AMBIENT = 139, - D3DRENDERSTATE_FOGVERTEXMODE = 140, - D3DRENDERSTATE_COLORVERTEX = 141, - D3DRENDERSTATE_LOCALVIEWER = 142, - D3DRENDERSTATE_NORMALIZENORMALS = 143, - D3DRENDERSTATE_COLORKEYBLENDENABLE = 144, - D3DRENDERSTATE_DIFFUSEMATERIALSOURCE = 145, - D3DRENDERSTATE_SPECULARMATERIALSOURCE = 146, - D3DRENDERSTATE_AMBIENTMATERIALSOURCE = 147, - D3DRENDERSTATE_EMISSIVEMATERIALSOURCE = 148, - D3DRENDERSTATE_VERTEXBLEND = 151, - D3DRENDERSTATE_CLIPPLANEENABLE = 152, - -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -// -// retired renderstates - not supported for DX7 interfaces -// - D3DRENDERSTATE_TEXTUREHANDLE = 1, /* Texture handle for legacy interfaces (Texture,Texture2) */ - D3DRENDERSTATE_TEXTUREADDRESS = 3, /* D3DTEXTUREADDRESS */ - D3DRENDERSTATE_WRAPU = 5, /* TRUE for wrapping in u */ - D3DRENDERSTATE_WRAPV = 6, /* TRUE for wrapping in v */ - D3DRENDERSTATE_MONOENABLE = 11, /* TRUE to enable mono rasterization */ - D3DRENDERSTATE_ROP2 = 12, /* ROP2 */ - D3DRENDERSTATE_PLANEMASK = 13, /* DWORD physical plane mask */ - D3DRENDERSTATE_TEXTUREMAG = 17, /* D3DTEXTUREFILTER */ - D3DRENDERSTATE_TEXTUREMIN = 18, /* D3DTEXTUREFILTER */ - D3DRENDERSTATE_TEXTUREMAPBLEND = 21, /* D3DTEXTUREBLEND */ - D3DRENDERSTATE_SUBPIXEL = 31, /* TRUE to enable subpixel correction */ - D3DRENDERSTATE_SUBPIXELX = 32, /* TRUE to enable correction in X only */ - D3DRENDERSTATE_STIPPLEENABLE = 39, /* TRUE to enable stippling */ -#if(DIRECT3D_VERSION >= 0x0500) - D3DRENDERSTATE_BORDERCOLOR = 43, /* Border color for texturing w/border */ - D3DRENDERSTATE_TEXTUREADDRESSU = 44, /* Texture addressing mode for U coordinate */ - D3DRENDERSTATE_TEXTUREADDRESSV = 45, /* Texture addressing mode for V coordinate */ - D3DRENDERSTATE_MIPMAPLODBIAS = 46, /* D3DVALUE Mipmap LOD bias */ - D3DRENDERSTATE_ANISOTROPY = 49, /* Max. anisotropy. 1 = no anisotropy */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ - D3DRENDERSTATE_FLUSHBATCH = 50, /* Explicit flush for DP batching (DX5 Only) */ -#if(DIRECT3D_VERSION >= 0x0600) - D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT=51, /* BOOL enable sort-independent transparency */ -#endif /* DIRECT3D_VERSION >= 0x0600 */ - D3DRENDERSTATE_STIPPLEPATTERN00 = 64, /* Stipple pattern 01... */ - D3DRENDERSTATE_STIPPLEPATTERN01 = 65, - D3DRENDERSTATE_STIPPLEPATTERN02 = 66, - D3DRENDERSTATE_STIPPLEPATTERN03 = 67, - D3DRENDERSTATE_STIPPLEPATTERN04 = 68, - D3DRENDERSTATE_STIPPLEPATTERN05 = 69, - D3DRENDERSTATE_STIPPLEPATTERN06 = 70, - D3DRENDERSTATE_STIPPLEPATTERN07 = 71, - D3DRENDERSTATE_STIPPLEPATTERN08 = 72, - D3DRENDERSTATE_STIPPLEPATTERN09 = 73, - D3DRENDERSTATE_STIPPLEPATTERN10 = 74, - D3DRENDERSTATE_STIPPLEPATTERN11 = 75, - D3DRENDERSTATE_STIPPLEPATTERN12 = 76, - D3DRENDERSTATE_STIPPLEPATTERN13 = 77, - D3DRENDERSTATE_STIPPLEPATTERN14 = 78, - D3DRENDERSTATE_STIPPLEPATTERN15 = 79, - D3DRENDERSTATE_STIPPLEPATTERN16 = 80, - D3DRENDERSTATE_STIPPLEPATTERN17 = 81, - D3DRENDERSTATE_STIPPLEPATTERN18 = 82, - D3DRENDERSTATE_STIPPLEPATTERN19 = 83, - D3DRENDERSTATE_STIPPLEPATTERN20 = 84, - D3DRENDERSTATE_STIPPLEPATTERN21 = 85, - D3DRENDERSTATE_STIPPLEPATTERN22 = 86, - D3DRENDERSTATE_STIPPLEPATTERN23 = 87, - D3DRENDERSTATE_STIPPLEPATTERN24 = 88, - D3DRENDERSTATE_STIPPLEPATTERN25 = 89, - D3DRENDERSTATE_STIPPLEPATTERN26 = 90, - D3DRENDERSTATE_STIPPLEPATTERN27 = 91, - D3DRENDERSTATE_STIPPLEPATTERN28 = 92, - D3DRENDERSTATE_STIPPLEPATTERN29 = 93, - D3DRENDERSTATE_STIPPLEPATTERN30 = 94, - D3DRENDERSTATE_STIPPLEPATTERN31 = 95, - -// -// retired renderstate names - the values are still used under new naming conventions -// - D3DRENDERSTATE_FOGTABLESTART = 36, /* Fog table start */ - D3DRENDERSTATE_FOGTABLEEND = 37, /* Fog table end */ - D3DRENDERSTATE_FOGTABLEDENSITY = 38, /* Fog table density */ - -#if(DIRECT3D_VERSION >= 0x0500) - D3DRENDERSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -#endif /* DIRECT3D_VERSION >= 0x0500 */ -} D3DRENDERSTATETYPE; - -#else - -typedef enum _D3DRENDERSTATETYPE D3DRENDERSTATETYPE; - -// -// legacy renderstate names -// -#define D3DRENDERSTATE_TEXTUREPERSPECTIVE (D3DRENDERSTATETYPE)4 -#define D3DRENDERSTATE_ZENABLE (D3DRENDERSTATETYPE)7 -#define D3DRENDERSTATE_FILLMODE (D3DRENDERSTATETYPE)8 -#define D3DRENDERSTATE_SHADEMODE (D3DRENDERSTATETYPE)9 -#define D3DRENDERSTATE_LINEPATTERN (D3DRENDERSTATETYPE)10 -#define D3DRENDERSTATE_ZWRITEENABLE (D3DRENDERSTATETYPE)14 -#define D3DRENDERSTATE_ALPHATESTENABLE (D3DRENDERSTATETYPE)15 -#define D3DRENDERSTATE_LASTPIXEL (D3DRENDERSTATETYPE)16 -#define D3DRENDERSTATE_SRCBLEND (D3DRENDERSTATETYPE)19 -#define D3DRENDERSTATE_DESTBLEND (D3DRENDERSTATETYPE)20 -#define D3DRENDERSTATE_CULLMODE (D3DRENDERSTATETYPE)22 -#define D3DRENDERSTATE_ZFUNC (D3DRENDERSTATETYPE)23 -#define D3DRENDERSTATE_ALPHAREF (D3DRENDERSTATETYPE)24 -#define D3DRENDERSTATE_ALPHAFUNC (D3DRENDERSTATETYPE)25 -#define D3DRENDERSTATE_DITHERENABLE (D3DRENDERSTATETYPE)26 -#define D3DRENDERSTATE_ALPHABLENDENABLE (D3DRENDERSTATETYPE)27 -#define D3DRENDERSTATE_FOGENABLE (D3DRENDERSTATETYPE)28 -#define D3DRENDERSTATE_SPECULARENABLE (D3DRENDERSTATETYPE)29 -#define D3DRENDERSTATE_ZVISIBLE (D3DRENDERSTATETYPE)30 -#define D3DRENDERSTATE_STIPPLEDALPHA (D3DRENDERSTATETYPE)33 -#define D3DRENDERSTATE_FOGCOLOR (D3DRENDERSTATETYPE)34 -#define D3DRENDERSTATE_FOGTABLEMODE (D3DRENDERSTATETYPE)35 -#define D3DRENDERSTATE_FOGSTART (D3DRENDERSTATETYPE)36 -#define D3DRENDERSTATE_FOGEND (D3DRENDERSTATETYPE)37 -#define D3DRENDERSTATE_FOGDENSITY (D3DRENDERSTATETYPE)38 -#define D3DRENDERSTATE_EDGEANTIALIAS (D3DRENDERSTATETYPE)40 -#define D3DRENDERSTATE_ZBIAS (D3DRENDERSTATETYPE)47 -#define D3DRENDERSTATE_RANGEFOGENABLE (D3DRENDERSTATETYPE)48 -#define D3DRENDERSTATE_STENCILENABLE (D3DRENDERSTATETYPE)52 -#define D3DRENDERSTATE_STENCILFAIL (D3DRENDERSTATETYPE)53 -#define D3DRENDERSTATE_STENCILZFAIL (D3DRENDERSTATETYPE)54 -#define D3DRENDERSTATE_STENCILPASS (D3DRENDERSTATETYPE)55 -#define D3DRENDERSTATE_STENCILFUNC (D3DRENDERSTATETYPE)56 -#define D3DRENDERSTATE_STENCILREF (D3DRENDERSTATETYPE)57 -#define D3DRENDERSTATE_STENCILMASK (D3DRENDERSTATETYPE)58 -#define D3DRENDERSTATE_STENCILWRITEMASK (D3DRENDERSTATETYPE)59 -#define D3DRENDERSTATE_TEXTUREFACTOR (D3DRENDERSTATETYPE)60 -#define D3DRENDERSTATE_WRAP0 (D3DRENDERSTATETYPE)128 -#define D3DRENDERSTATE_WRAP1 (D3DRENDERSTATETYPE)129 -#define D3DRENDERSTATE_WRAP2 (D3DRENDERSTATETYPE)130 -#define D3DRENDERSTATE_WRAP3 (D3DRENDERSTATETYPE)131 -#define D3DRENDERSTATE_WRAP4 (D3DRENDERSTATETYPE)132 -#define D3DRENDERSTATE_WRAP5 (D3DRENDERSTATETYPE)133 -#define D3DRENDERSTATE_WRAP6 (D3DRENDERSTATETYPE)134 -#define D3DRENDERSTATE_WRAP7 (D3DRENDERSTATETYPE)135 - -#define D3DRENDERSTATE_CLIPPING (D3DRENDERSTATETYPE)136 -#define D3DRENDERSTATE_LIGHTING (D3DRENDERSTATETYPE)137 -#define D3DRENDERSTATE_EXTENTS (D3DRENDERSTATETYPE)138 -#define D3DRENDERSTATE_AMBIENT (D3DRENDERSTATETYPE)139 -#define D3DRENDERSTATE_FOGVERTEXMODE (D3DRENDERSTATETYPE)140 -#define D3DRENDERSTATE_COLORVERTEX (D3DRENDERSTATETYPE)141 -#define D3DRENDERSTATE_LOCALVIEWER (D3DRENDERSTATETYPE)142 -#define D3DRENDERSTATE_NORMALIZENORMALS (D3DRENDERSTATETYPE)143 -#define D3DRENDERSTATE_COLORKEYBLENDENABLE (D3DRENDERSTATETYPE)144 -#define D3DRENDERSTATE_DIFFUSEMATERIALSOURCE (D3DRENDERSTATETYPE)145 -#define D3DRENDERSTATE_SPECULARMATERIALSOURCE (D3DRENDERSTATETYPE)146 -#define D3DRENDERSTATE_AMBIENTMATERIALSOURCE (D3DRENDERSTATETYPE)147 -#define D3DRENDERSTATE_EMISSIVEMATERIALSOURCE (D3DRENDERSTATETYPE)148 -#define D3DRENDERSTATE_VERTEXBLEND (D3DRENDERSTATETYPE)151 -#define D3DRENDERSTATE_CLIPPLANEENABLE (D3DRENDERSTATETYPE)152 - -// -// retired renderstates - not supported for DX7 interfaces -// -#define D3DRENDERSTATE_TEXTUREHANDLE (D3DRENDERSTATETYPE)1 -#define D3DRENDERSTATE_ANTIALIAS (D3DRENDERSTATETYPE)2 -#define D3DRENDERSTATE_TEXTUREADDRESS (D3DRENDERSTATETYPE)3 -#define D3DRENDERSTATE_WRAPU (D3DRENDERSTATETYPE)5 -#define D3DRENDERSTATE_WRAPV (D3DRENDERSTATETYPE)6 -#define D3DRENDERSTATE_MONOENABLE (D3DRENDERSTATETYPE)11 -#define D3DRENDERSTATE_ROP2 (D3DRENDERSTATETYPE)12 -#define D3DRENDERSTATE_PLANEMASK (D3DRENDERSTATETYPE)13 -#define D3DRENDERSTATE_TEXTUREMAG (D3DRENDERSTATETYPE)17 -#define D3DRENDERSTATE_TEXTUREMIN (D3DRENDERSTATETYPE)18 -#define D3DRENDERSTATE_TEXTUREMAPBLEND (D3DRENDERSTATETYPE)21 -#define D3DRENDERSTATE_SUBPIXEL (D3DRENDERSTATETYPE)31 -#define D3DRENDERSTATE_SUBPIXELX (D3DRENDERSTATETYPE)32 -#define D3DRENDERSTATE_STIPPLEENABLE (D3DRENDERSTATETYPE)39 -#define D3DRENDERSTATE_OLDALPHABLENDENABLE (D3DRENDERSTATETYPE)42 -#define D3DRENDERSTATE_BORDERCOLOR (D3DRENDERSTATETYPE)43 -#define D3DRENDERSTATE_TEXTUREADDRESSU (D3DRENDERSTATETYPE)44 -#define D3DRENDERSTATE_TEXTUREADDRESSV (D3DRENDERSTATETYPE)45 -#define D3DRENDERSTATE_MIPMAPLODBIAS (D3DRENDERSTATETYPE)46 -#define D3DRENDERSTATE_ANISOTROPY (D3DRENDERSTATETYPE)49 -#define D3DRENDERSTATE_FLUSHBATCH (D3DRENDERSTATETYPE)50 -#define D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT (D3DRENDERSTATETYPE)51 -#define D3DRENDERSTATE_STIPPLEPATTERN00 (D3DRENDERSTATETYPE)64 -#define D3DRENDERSTATE_STIPPLEPATTERN01 (D3DRENDERSTATETYPE)65 -#define D3DRENDERSTATE_STIPPLEPATTERN02 (D3DRENDERSTATETYPE)66 -#define D3DRENDERSTATE_STIPPLEPATTERN03 (D3DRENDERSTATETYPE)67 -#define D3DRENDERSTATE_STIPPLEPATTERN04 (D3DRENDERSTATETYPE)68 -#define D3DRENDERSTATE_STIPPLEPATTERN05 (D3DRENDERSTATETYPE)69 -#define D3DRENDERSTATE_STIPPLEPATTERN06 (D3DRENDERSTATETYPE)70 -#define D3DRENDERSTATE_STIPPLEPATTERN07 (D3DRENDERSTATETYPE)71 -#define D3DRENDERSTATE_STIPPLEPATTERN08 (D3DRENDERSTATETYPE)72 -#define D3DRENDERSTATE_STIPPLEPATTERN09 (D3DRENDERSTATETYPE)73 -#define D3DRENDERSTATE_STIPPLEPATTERN10 (D3DRENDERSTATETYPE)74 -#define D3DRENDERSTATE_STIPPLEPATTERN11 (D3DRENDERSTATETYPE)75 -#define D3DRENDERSTATE_STIPPLEPATTERN12 (D3DRENDERSTATETYPE)76 -#define D3DRENDERSTATE_STIPPLEPATTERN13 (D3DRENDERSTATETYPE)77 -#define D3DRENDERSTATE_STIPPLEPATTERN14 (D3DRENDERSTATETYPE)78 -#define D3DRENDERSTATE_STIPPLEPATTERN15 (D3DRENDERSTATETYPE)79 -#define D3DRENDERSTATE_STIPPLEPATTERN16 (D3DRENDERSTATETYPE)80 -#define D3DRENDERSTATE_STIPPLEPATTERN17 (D3DRENDERSTATETYPE)81 -#define D3DRENDERSTATE_STIPPLEPATTERN18 (D3DRENDERSTATETYPE)82 -#define D3DRENDERSTATE_STIPPLEPATTERN19 (D3DRENDERSTATETYPE)83 -#define D3DRENDERSTATE_STIPPLEPATTERN20 (D3DRENDERSTATETYPE)84 -#define D3DRENDERSTATE_STIPPLEPATTERN21 (D3DRENDERSTATETYPE)85 -#define D3DRENDERSTATE_STIPPLEPATTERN22 (D3DRENDERSTATETYPE)86 -#define D3DRENDERSTATE_STIPPLEPATTERN23 (D3DRENDERSTATETYPE)87 -#define D3DRENDERSTATE_STIPPLEPATTERN24 (D3DRENDERSTATETYPE)88 -#define D3DRENDERSTATE_STIPPLEPATTERN25 (D3DRENDERSTATETYPE)89 -#define D3DRENDERSTATE_STIPPLEPATTERN26 (D3DRENDERSTATETYPE)90 -#define D3DRENDERSTATE_STIPPLEPATTERN27 (D3DRENDERSTATETYPE)91 -#define D3DRENDERSTATE_STIPPLEPATTERN28 (D3DRENDERSTATETYPE)92 -#define D3DRENDERSTATE_STIPPLEPATTERN29 (D3DRENDERSTATETYPE)93 -#define D3DRENDERSTATE_STIPPLEPATTERN30 (D3DRENDERSTATETYPE)94 -#define D3DRENDERSTATE_STIPPLEPATTERN31 (D3DRENDERSTATETYPE)95 - -// -// retired renderstates - not supported for DX8 interfaces -// -#define D3DRENDERSTATE_COLORKEYENABLE (D3DRENDERSTATETYPE)41 -#define D3DRENDERSTATE_COLORKEYBLENDENABLE (D3DRENDERSTATETYPE)144 - -// -// retired renderstate names - the values are still used under new naming conventions -// -#define D3DRENDERSTATE_BLENDENABLE (D3DRENDERSTATETYPE)27 -#define D3DRENDERSTATE_FOGTABLESTART (D3DRENDERSTATETYPE)36 -#define D3DRENDERSTATE_FOGTABLEEND (D3DRENDERSTATETYPE)37 -#define D3DRENDERSTATE_FOGTABLEDENSITY (D3DRENDERSTATETYPE)38 - -#endif //(DIRECT3D_VERSION < 0x0800) - - -#if(DIRECT3D_VERSION < 0x0800) - -// Values for material source -typedef enum _D3DMATERIALCOLORSOURCE -{ - D3DMCS_MATERIAL = 0, // Color from material is used - D3DMCS_COLOR1 = 1, // Diffuse vertex color is used - D3DMCS_COLOR2 = 2, // Specular vertex color is used - D3DMCS_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum -} D3DMATERIALCOLORSOURCE; - - -#if(DIRECT3D_VERSION >= 0x0500) -// For back-compatibility with legacy compilations -#define D3DRENDERSTATE_BLENDENABLE D3DRENDERSTATE_ALPHABLENDENABLE -#endif /* DIRECT3D_VERSION >= 0x0500 */ - -#if(DIRECT3D_VERSION >= 0x0600) - -// Bias to apply to the texture coordinate set to apply a wrap to. -#define D3DRENDERSTATE_WRAPBIAS 128UL - -/* Flags to construct the WRAP render states */ -#define D3DWRAP_U 0x00000001L -#define D3DWRAP_V 0x00000002L - -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -#if(DIRECT3D_VERSION >= 0x0700) - -/* Flags to construct the WRAP render states for 1D thru 4D texture coordinates */ -#define D3DWRAPCOORD_0 0x00000001L // same as D3DWRAP_U -#define D3DWRAPCOORD_1 0x00000002L // same as D3DWRAP_V -#define D3DWRAPCOORD_2 0x00000004L -#define D3DWRAPCOORD_3 0x00000008L - -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -#endif //(DIRECT3D_VERSION < 0x0800) - -#define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y)) - -typedef struct _D3DSTATE { - union { -#if(DIRECT3D_VERSION < 0x0800) - D3DTRANSFORMSTATETYPE dtstTransformStateType; -#endif //(DIRECT3D_VERSION < 0x0800) - D3DLIGHTSTATETYPE dlstLightStateType; - D3DRENDERSTATETYPE drstRenderStateType; - }; - union { - DWORD dwArg[1]; - D3DVALUE dvArg[1]; - }; -} D3DSTATE, *LPD3DSTATE; - - -/* - * Operation used to load matrices - * hDstMat = hSrcMat - */ -typedef struct _D3DMATRIXLOAD { - D3DMATRIXHANDLE hDestMatrix; /* Destination matrix */ - D3DMATRIXHANDLE hSrcMatrix; /* Source matrix */ -} D3DMATRIXLOAD, *LPD3DMATRIXLOAD; - -/* - * Operation used to multiply matrices - * hDstMat = hSrcMat1 * hSrcMat2 - */ -typedef struct _D3DMATRIXMULTIPLY { - D3DMATRIXHANDLE hDestMatrix; /* Destination matrix */ - D3DMATRIXHANDLE hSrcMatrix1; /* First source matrix */ - D3DMATRIXHANDLE hSrcMatrix2; /* Second source matrix */ -} D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY; - -/* - * Operation used to transform and light vertices. - */ -typedef struct _D3DPROCESSVERTICES { - DWORD dwFlags; /* Do we transform or light or just copy? */ - WORD wStart; /* Index to first vertex in source */ - WORD wDest; /* Index to first vertex in local buffer */ - DWORD dwCount; /* Number of vertices to be processed */ - DWORD dwReserved; /* Must be zero */ -} D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES; - -#define D3DPROCESSVERTICES_TRANSFORMLIGHT 0x00000000L -#define D3DPROCESSVERTICES_TRANSFORM 0x00000001L -#define D3DPROCESSVERTICES_COPY 0x00000002L -#define D3DPROCESSVERTICES_OPMASK 0x00000007L - -#define D3DPROCESSVERTICES_UPDATEEXTENTS 0x00000008L -#define D3DPROCESSVERTICES_NOCOLOR 0x00000010L - - -#if(DIRECT3D_VERSION >= 0x0600) - - -#if(DIRECT3D_VERSION < 0x0800) - -/* - * State enumerants for per-stage texture processing. - */ -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, /* D3DVALUE (bump mapping matrix) */ - D3DTSS_BUMPENVMAT01 = 8, /* D3DVALUE (bump mapping matrix) */ - D3DTSS_BUMPENVMAT10 = 9, /* D3DVALUE (bump mapping matrix) */ - D3DTSS_BUMPENVMAT11 = 10, /* D3DVALUE (bump mapping matrix) */ - D3DTSS_TEXCOORDINDEX = 11, /* identifies which set of texture coordinates index this texture */ - D3DTSS_ADDRESS = 12, /* D3DTEXTUREADDRESS for both coordinates */ - D3DTSS_ADDRESSU = 13, /* D3DTEXTUREADDRESS for U coordinate */ - D3DTSS_ADDRESSV = 14, /* D3DTEXTUREADDRESS for V coordinate */ - D3DTSS_BORDERCOLOR = 15, /* D3DCOLOR */ - D3DTSS_MAGFILTER = 16, /* D3DTEXTUREMAGFILTER filter to use for magnification */ - D3DTSS_MINFILTER = 17, /* D3DTEXTUREMINFILTER filter to use for minification */ - D3DTSS_MIPFILTER = 18, /* D3DTEXTUREMIPFILTER filter to use between mipmaps during minification */ - D3DTSS_MIPMAPLODBIAS = 19, /* D3DVALUE Mipmap LOD bias */ - D3DTSS_MAXMIPLEVEL = 20, /* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) */ - D3DTSS_MAXANISOTROPY = 21, /* DWORD maximum anisotropy */ - D3DTSS_BUMPENVLSCALE = 22, /* D3DVALUE scale for bump map luminance */ - D3DTSS_BUMPENVLOFFSET = 23, /* D3DVALUE offset for bump map luminance */ -#if(DIRECT3D_VERSION >= 0x0700) - D3DTSS_TEXTURETRANSFORMFLAGS = 24, /* D3DTEXTURETRANSFORMFLAGS controls texture transform */ -#endif /* DIRECT3D_VERSION >= 0x0700 */ - D3DTSS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DTEXTURESTAGESTATETYPE; - -#if(DIRECT3D_VERSION >= 0x0700) -// Values, used with D3DTSS_TEXCOORDINDEX, to specify that the vertex data(position -// and normal in the camera space) should be taken as texture coordinates -// Low 16 bits are used to specify texture coordinate index, to take the WRAP mode from -// -#define D3DTSS_TCI_PASSTHRU 0x00000000 -#define D3DTSS_TCI_CAMERASPACENORMAL 0x00010000 -#define D3DTSS_TCI_CAMERASPACEPOSITION 0x00020000 -#define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR 0x00030000 -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -/* - * Enumerations for COLOROP and ALPHAOP texture blending operations set in - * texture processing stage controls in D3DRENDERSTATE. - */ -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 D3DRENDERSTATE_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, - - D3DTOP_FORCE_DWORD = 0x7fffffff, -} D3DTEXTUREOP; - -/* - * Values for COLORARG1,2 and ALPHAARG1,2 texture blending operations - * set in texture processing stage controls in D3DRENDERSTATE. - */ -#define D3DTA_SELECTMASK 0x0000000f // mask for arg selector -#define D3DTA_DIFFUSE 0x00000000 // select diffuse color -#define D3DTA_CURRENT 0x00000001 // select result of previous stage -#define D3DTA_TEXTURE 0x00000002 // select texture color -#define D3DTA_TFACTOR 0x00000003 // select RENDERSTATE_TEXTUREFACTOR -#if(DIRECT3D_VERSION >= 0x0700) -#define D3DTA_SPECULAR 0x00000004 // select specular color -#endif /* DIRECT3D_VERSION >= 0x0700 */ -#define D3DTA_COMPLEMENT 0x00000010 // take 1.0 - x -#define D3DTA_ALPHAREPLICATE 0x00000020 // replicate alpha to color components - -#endif //(DIRECT3D_VERSION < 0x0800) - -/* - * IDirect3DTexture2 State Filter Types - */ -typedef enum _D3DTEXTUREMAGFILTER -{ - D3DTFG_POINT = 1, // nearest - D3DTFG_LINEAR = 2, // linear interpolation - D3DTFG_FLATCUBIC = 3, // cubic - D3DTFG_GAUSSIANCUBIC = 4, // different cubic kernel - D3DTFG_ANISOTROPIC = 5, // -#if(DIRECT3D_VERSION >= 0x0700) -#endif /* DIRECT3D_VERSION >= 0x0700 */ - D3DTFG_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum -} D3DTEXTUREMAGFILTER; - -typedef enum _D3DTEXTUREMINFILTER -{ - D3DTFN_POINT = 1, // nearest - D3DTFN_LINEAR = 2, // linear interpolation - D3DTFN_ANISOTROPIC = 3, // - D3DTFN_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum -} D3DTEXTUREMINFILTER; - -typedef enum _D3DTEXTUREMIPFILTER -{ - D3DTFP_NONE = 1, // mipmapping disabled (use MAG filter) - D3DTFP_POINT = 2, // nearest - D3DTFP_LINEAR = 3, // linear interpolation - D3DTFP_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum -} D3DTEXTUREMIPFILTER; - -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -/* - * Triangle flags - */ - -/* - * Tri strip and fan flags. - * START loads all three vertices - * EVEN and ODD load just v3 with even or odd culling - * START_FLAT contains a count from 0 to 29 that allows the - * whole strip or fan to be culled in one hit. - * e.g. for a quad len = 1 - */ -#define D3DTRIFLAG_START 0x00000000L -#define D3DTRIFLAG_STARTFLAT(len) (len) /* 0 < len < 30 */ -#define D3DTRIFLAG_ODD 0x0000001eL -#define D3DTRIFLAG_EVEN 0x0000001fL - -/* - * Triangle edge flags - * enable edges for wireframe or antialiasing - */ -#define D3DTRIFLAG_EDGEENABLE1 0x00000100L /* v0-v1 edge */ -#define D3DTRIFLAG_EDGEENABLE2 0x00000200L /* v1-v2 edge */ -#define D3DTRIFLAG_EDGEENABLE3 0x00000400L /* v2-v0 edge */ -#define D3DTRIFLAG_EDGEENABLETRIANGLE \ - (D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3) - -/* - * Primitive structures and related defines. Vertex offsets are to types - * D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX. - */ - -/* - * Triangle list primitive structure - */ -typedef struct _D3DTRIANGLE { - union { - WORD v1; /* Vertex indices */ - WORD wV1; - }; - union { - WORD v2; - WORD wV2; - }; - union { - WORD v3; - WORD wV3; - }; - WORD wFlags; /* Edge (and other) flags */ -} D3DTRIANGLE, *LPD3DTRIANGLE; - -/* - * Line list structure. - * The instruction count defines the number of line segments. - */ -typedef struct _D3DLINE { - union { - WORD v1; /* Vertex indices */ - WORD wV1; - }; - union { - WORD v2; - WORD wV2; - }; -} D3DLINE, *LPD3DLINE; - -/* - * Span structure - * Spans join a list of points with the same y value. - * If the y value changes, a new span is started. - */ -typedef struct _D3DSPAN { - WORD wCount; /* Number of spans */ - WORD wFirst; /* Index to first vertex */ -} D3DSPAN, *LPD3DSPAN; - -/* - * Point structure - */ -typedef struct _D3DPOINT { - WORD wCount; /* number of points */ - WORD wFirst; /* index to first vertex */ -} D3DPOINT, *LPD3DPOINT; - - -/* - * Forward branch structure. - * Mask is logically anded with the driver status mask - * if the result equals 'value', the branch is taken. - */ -typedef struct _D3DBRANCH { - DWORD dwMask; /* Bitmask against D3D status */ - DWORD dwValue; - BOOL bNegate; /* TRUE to negate comparison */ - DWORD dwOffset; /* How far to branch forward (0 for exit)*/ -} D3DBRANCH, *LPD3DBRANCH; - -/* - * Status used for set status instruction. - * The D3D status is initialised on device creation - * and is modified by all execute calls. - */ -typedef struct _D3DSTATUS { - DWORD dwFlags; /* Do we set extents or status */ - DWORD dwStatus; /* D3D status */ - D3DRECT drExtent; -} D3DSTATUS, *LPD3DSTATUS; - -#define D3DSETSTATUS_STATUS 0x00000001L -#define D3DSETSTATUS_EXTENTS 0x00000002L -#define D3DSETSTATUS_ALL (D3DSETSTATUS_STATUS | D3DSETSTATUS_EXTENTS) - -#if(DIRECT3D_VERSION >= 0x0500) -typedef struct _D3DCLIPSTATUS { - DWORD dwFlags; /* Do we set 2d extents, 3D extents or status */ - DWORD dwStatus; /* Clip status */ - float minx, maxx; /* X extents */ - float miny, maxy; /* Y extents */ - float minz, maxz; /* Z extents */ -} D3DCLIPSTATUS, *LPD3DCLIPSTATUS; - -#define D3DCLIPSTATUS_STATUS 0x00000001L -#define D3DCLIPSTATUS_EXTENTS2 0x00000002L -#define D3DCLIPSTATUS_EXTENTS3 0x00000004L - -#endif /* DIRECT3D_VERSION >= 0x0500 */ -/* - * Statistics structure - */ -typedef struct _D3DSTATS { - DWORD dwSize; - DWORD dwTrianglesDrawn; - DWORD dwLinesDrawn; - DWORD dwPointsDrawn; - DWORD dwSpansDrawn; - DWORD dwVerticesProcessed; -} D3DSTATS, *LPD3DSTATS; - -/* - * Execute options. - * When calling using D3DEXECUTE_UNCLIPPED all the primitives - * inside the buffer must be contained within the viewport. - */ -#define D3DEXECUTE_CLIPPED 0x00000001l -#define D3DEXECUTE_UNCLIPPED 0x00000002l - -typedef struct _D3DEXECUTEDATA { - DWORD dwSize; - DWORD dwVertexOffset; - DWORD dwVertexCount; - DWORD dwInstructionOffset; - DWORD dwInstructionLength; - DWORD dwHVertexOffset; - D3DSTATUS dsStatus; /* Status after execute */ -} D3DEXECUTEDATA, *LPD3DEXECUTEDATA; - -/* - * Palette flags. - * This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw. - */ -#define D3DPAL_FREE 0x00 /* Renderer may use this entry freely */ -#define D3DPAL_READONLY 0x40 /* Renderer may not set this entry */ -#define D3DPAL_RESERVED 0x80 /* Renderer may not use this entry */ - - -#if(DIRECT3D_VERSION >= 0x0600) - -typedef struct _D3DVERTEXBUFFERDESC { - DWORD dwSize; - DWORD dwCaps; - DWORD dwFVF; - DWORD dwNumVertices; -} D3DVERTEXBUFFERDESC, *LPD3DVERTEXBUFFERDESC; - -#define D3DVBCAPS_SYSTEMMEMORY 0x00000800l -#define D3DVBCAPS_WRITEONLY 0x00010000l -#define D3DVBCAPS_OPTIMIZED 0x80000000l -#define D3DVBCAPS_DONOTCLIP 0x00000001l - -/* Vertex Operations for ProcessVertices */ -#define D3DVOP_LIGHT (1 << 10) -#define D3DVOP_TRANSFORM (1 << 0) -#define D3DVOP_CLIP (1 << 2) -#define D3DVOP_EXTENTS (1 << 3) - - -#if(DIRECT3D_VERSION < 0x0800) - -/* The maximum number of vertices user can pass to any d3d - drawing function or to create vertex buffer with -*/ -#define D3DMAXNUMVERTICES ((1<<16) - 1) -/* The maximum number of primitives user can pass to any d3d - drawing function. -*/ -#define D3DMAXNUMPRIMITIVES ((1<<16) - 1) - -#if(DIRECT3D_VERSION >= 0x0700) - -/* Bits for dwFlags in ProcessVertices call */ -#define D3DPV_DONOTCOPYDATA (1 << 0) - -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -#endif //(DIRECT3D_VERSION < 0x0800) - -//------------------------------------------------------------------- - -#if(DIRECT3D_VERSION < 0x0800) - -// Flexible vertex format bits -// -#define D3DFVF_RESERVED0 0x001 -#define D3DFVF_POSITION_MASK 0x00E -#define D3DFVF_XYZ 0x002 -#define D3DFVF_XYZRHW 0x004 -#if(DIRECT3D_VERSION >= 0x0700) -#define D3DFVF_XYZB1 0x006 -#define D3DFVF_XYZB2 0x008 -#define D3DFVF_XYZB3 0x00a -#define D3DFVF_XYZB4 0x00c -#define D3DFVF_XYZB5 0x00e - -#endif /* DIRECT3D_VERSION >= 0x0700 */ -#define D3DFVF_NORMAL 0x010 -#define D3DFVF_RESERVED1 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_RESERVED2 0xf000 // 4 reserved bits - -#else -#define D3DFVF_RESERVED1 0x020 -#endif //(DIRECT3D_VERSION < 0x0800) - -#define D3DFVF_VERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 ) -#define D3DFVF_LVERTEX ( D3DFVF_XYZ | D3DFVF_RESERVED1 | D3DFVF_DIFFUSE | \ - D3DFVF_SPECULAR | D3DFVF_TEX1 ) -#define D3DFVF_TLVERTEX ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | \ - D3DFVF_TEX1 ) - - -typedef struct _D3DDP_PTRSTRIDE -{ - LPVOID lpvData; - DWORD dwStride; -} D3DDP_PTRSTRIDE; - -#define D3DDP_MAXTEXCOORD 8 - -typedef struct _D3DDRAWPRIMITIVESTRIDEDDATA -{ - D3DDP_PTRSTRIDE position; - D3DDP_PTRSTRIDE normal; - D3DDP_PTRSTRIDE diffuse; - D3DDP_PTRSTRIDE specular; - D3DDP_PTRSTRIDE textureCoords[D3DDP_MAXTEXCOORD]; -} D3DDRAWPRIMITIVESTRIDEDDATA, *LPD3DDRAWPRIMITIVESTRIDEDDATA; -//--------------------------------------------------------------------- -// ComputeSphereVisibility return values -// -#define D3DVIS_INSIDE_FRUSTUM 0 -#define D3DVIS_INTERSECT_FRUSTUM 1 -#define D3DVIS_OUTSIDE_FRUSTUM 2 -#define D3DVIS_INSIDE_LEFT 0 -#define D3DVIS_INTERSECT_LEFT (1 << 2) -#define D3DVIS_OUTSIDE_LEFT (2 << 2) -#define D3DVIS_INSIDE_RIGHT 0 -#define D3DVIS_INTERSECT_RIGHT (1 << 4) -#define D3DVIS_OUTSIDE_RIGHT (2 << 4) -#define D3DVIS_INSIDE_TOP 0 -#define D3DVIS_INTERSECT_TOP (1 << 6) -#define D3DVIS_OUTSIDE_TOP (2 << 6) -#define D3DVIS_INSIDE_BOTTOM 0 -#define D3DVIS_INTERSECT_BOTTOM (1 << 8) -#define D3DVIS_OUTSIDE_BOTTOM (2 << 8) -#define D3DVIS_INSIDE_NEAR 0 -#define D3DVIS_INTERSECT_NEAR (1 << 10) -#define D3DVIS_OUTSIDE_NEAR (2 << 10) -#define D3DVIS_INSIDE_FAR 0 -#define D3DVIS_INTERSECT_FAR (1 << 12) -#define D3DVIS_OUTSIDE_FAR (2 << 12) - -#define D3DVIS_MASK_FRUSTUM (3 << 0) -#define D3DVIS_MASK_LEFT (3 << 2) -#define D3DVIS_MASK_RIGHT (3 << 4) -#define D3DVIS_MASK_TOP (3 << 6) -#define D3DVIS_MASK_BOTTOM (3 << 8) -#define D3DVIS_MASK_NEAR (3 << 10) -#define D3DVIS_MASK_FAR (3 << 12) - -#endif /* DIRECT3D_VERSION >= 0x0600 */ - -#if(DIRECT3D_VERSION < 0x0800) - -#if(DIRECT3D_VERSION >= 0x0700) - -// To be used with GetInfo() -#define D3DDEVINFOID_TEXTUREMANAGER 1 -#define D3DDEVINFOID_D3DTEXTUREMANAGER 2 -#define D3DDEVINFOID_TEXTURING 3 - -typedef enum _D3DSTATEBLOCKTYPE -{ - D3DSBT_ALL = 1, // capture all state - D3DSBT_PIXELSTATE = 2, // capture pixel state - D3DSBT_VERTEXSTATE = 3, // capture vertex state - D3DSBT_FORCE_DWORD = 0xffffffff -} D3DSTATEBLOCKTYPE; - -// The D3DVERTEXBLENDFLAGS type is used with D3DRENDERSTATE_VERTEXBLEND state. -// -typedef enum _D3DVERTEXBLENDFLAGS -{ - D3DVBLEND_DISABLE = 0, // Disable vertex blending - D3DVBLEND_1WEIGHT = 1, // blend between 2 matrices - D3DVBLEND_2WEIGHTS = 2, // blend between 3 matrices - D3DVBLEND_3WEIGHTS = 3, // blend between 4 matrices -} D3DVERTEXBLENDFLAGS; - -typedef enum _D3DTEXTURETRANSFORMFLAGS { - D3DTTFF_DISABLE = 0, // texture coordinates are passed directly - D3DTTFF_COUNT1 = 1, // rasterizer should expect 1-D texture coords - D3DTTFF_COUNT2 = 2, // rasterizer should expect 2-D texture coords - D3DTTFF_COUNT3 = 3, // rasterizer should expect 3-D texture coords - D3DTTFF_COUNT4 = 4, // rasterizer should expect 4-D texture coords - D3DTTFF_PROJECTED = 256, // texcoords to be divided by COUNTth element - D3DTTFF_FORCE_DWORD = 0x7fffffff, -} D3DTEXTURETRANSFORMFLAGS; - -// Macros to set texture coordinate format bits in the FVF id - -#define D3DFVF_TEXTUREFORMAT2 0 // Two floating point values -#define D3DFVF_TEXTUREFORMAT1 3 // One floating point value -#define D3DFVF_TEXTUREFORMAT3 1 // Three floating point values -#define D3DFVF_TEXTUREFORMAT4 2 // Four floating point values - -#define D3DFVF_TEXCOORDSIZE3(CoordIndex) (D3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16)) -#define D3DFVF_TEXCOORDSIZE2(CoordIndex) (D3DFVF_TEXTUREFORMAT2) -#define D3DFVF_TEXCOORDSIZE4(CoordIndex) (D3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16)) -#define D3DFVF_TEXCOORDSIZE1(CoordIndex) (D3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16)) - - -#endif /* DIRECT3D_VERSION >= 0x0700 */ - -#else -// -// legacy vertex blend names -// -typedef enum _D3DVERTEXBLENDFLAGS D3DVERTEXBLENDFLAGS; -#define D3DVBLEND_DISABLE (D3DVERTEXBLENDFLAGS)0 -#define D3DVBLEND_1WEIGHT (D3DVERTEXBLENDFLAGS)1 -#define D3DVBLEND_2WEIGHTS (D3DVERTEXBLENDFLAGS)2 -#define D3DVBLEND_3WEIGHTS (D3DVERTEXBLENDFLAGS)3 - -#endif //(DIRECT3D_VERSION < 0x0800) - -#pragma pack() -#pragma warning(default:4201) - -#endif /* _D3DTYPES_H_ */ - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3dtypes.h + * Content: Direct3D types include file + * + ***************************************************************************/ + +#ifndef _D3DTYPES_H_ +#define _D3DTYPES_H_ + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0700 +#endif + +#if (DIRECT3D_VERSION >= 0x0800) +#pragma message("should not include d3dtypes.h when compiling for DX8 or newer interfaces") +#endif + +#include + +#include +#include "ddraw.h" + +#pragma warning(disable:4201) // anonymous unions warning +#if defined(_X86_) || defined(_IA64_) +#pragma pack(4) +#endif + + +/* D3DVALUE is the fundamental Direct3D fractional data type */ + +#define D3DVALP(val, prec) ((float)(val)) +#define D3DVAL(val) ((float)(val)) + +#ifndef DX_SHARED_DEFINES + +/* + * This definition is shared with other DirectX components whose header files + * might already have defined it. Therefore, we don't define this type if + * someone else already has (as indicated by the definition of + * DX_SHARED_DEFINES). We don't set DX_SHARED_DEFINES here as there are + * other types in this header that are also shared. The last of these + * shared defines in this file will set DX_SHARED_DEFINES. + */ +typedef float D3DVALUE, *LPD3DVALUE; + +#endif /* DX_SHARED_DEFINES */ + +#define D3DDivide(a, b) (float)((double) (a) / (double) (b)) +#define D3DMultiply(a, b) ((a) * (b)) + +typedef LONG D3DFIXED; + +#ifndef RGB_MAKE +/* + * Format of CI colors is + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | alpha | color index | fraction | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +#define CI_GETALPHA(ci) ((ci) >> 24) +#define CI_GETINDEX(ci) (((ci) >> 8) & 0xffff) +#define CI_GETFRACTION(ci) ((ci) & 0xff) +#define CI_ROUNDINDEX(ci) CI_GETINDEX((ci) + 0x80) +#define CI_MASKALPHA(ci) ((ci) & 0xffffff) +#define CI_MAKE(a, i, f) (((a) << 24) | ((i) << 8) | (f)) + +/* + * Format of RGBA colors is + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | alpha | red | green | blue | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +#define RGBA_GETALPHA(rgb) ((rgb) >> 24) +#define RGBA_GETRED(rgb) (((rgb) >> 16) & 0xff) +#define RGBA_GETGREEN(rgb) (((rgb) >> 8) & 0xff) +#define RGBA_GETBLUE(rgb) ((rgb) & 0xff) +#define RGBA_MAKE(r, g, b, a) ((D3DCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))) + +/* D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs + * The float values must be in the range 0..1 + */ +#define D3DRGB(r, g, b) \ + (0xff000000L | ( ((long)((r) * 255)) << 16) | (((long)((g) * 255)) << 8) | (long)((b) * 255)) +#define D3DRGBA(r, g, b, a) \ + ( (((long)((a) * 255)) << 24) | (((long)((r) * 255)) << 16) \ + | (((long)((g) * 255)) << 8) | (long)((b) * 255) \ + ) + +/* + * Format of RGB colors is + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ignored | red | green | blue | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +#define RGB_GETRED(rgb) (((rgb) >> 16) & 0xff) +#define RGB_GETGREEN(rgb) (((rgb) >> 8) & 0xff) +#define RGB_GETBLUE(rgb) ((rgb) & 0xff) +#define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff)) +#define RGB_MAKE(r, g, b) ((D3DCOLOR) (((r) << 16) | ((g) << 8) | (b))) +#define RGBA_TORGB(rgba) ((D3DCOLOR) ((rgba) & 0xffffff)) +#define RGB_TORGBA(rgb) ((D3DCOLOR) ((rgb) | 0xff000000)) + +#endif + +/* + * Flags for Enumerate functions + */ + +/* + * Stop the enumeration + */ +#define D3DENUMRET_CANCEL DDENUMRET_CANCEL + +/* + * Continue the enumeration + */ +#define D3DENUMRET_OK DDENUMRET_OK + +typedef HRESULT (CALLBACK* LPD3DVALIDATECALLBACK)(LPVOID lpUserArg, DWORD dwOffset); +typedef HRESULT (CALLBACK* LPD3DENUMTEXTUREFORMATSCALLBACK)(LPDDSURFACEDESC lpDdsd, LPVOID lpContext); +typedef HRESULT (CALLBACK* LPD3DENUMPIXELFORMATSCALLBACK)(LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext); + +#ifndef DX_SHARED_DEFINES + +/* + * This definition is shared with other DirectX components whose header files + * might already have defined it. Therefore, we don't define this type if + * someone else already has (as indicated by the definition of + * DX_SHARED_DEFINES). We don't set DX_SHARED_DEFINES here as there are + * other types in this header that are also shared. The last of these + * shared defines in this file will set DX_SHARED_DEFINES. + */ +#ifndef D3DCOLOR_DEFINED +typedef DWORD D3DCOLOR; +#define D3DCOLOR_DEFINED +#endif +typedef DWORD *LPD3DCOLOR; + +#endif /* DX_SHARED_DEFINES */ + +typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE; +typedef DWORD D3DTEXTUREHANDLE, *LPD3DTEXTUREHANDLE; +typedef DWORD D3DMATRIXHANDLE, *LPD3DMATRIXHANDLE; + +#ifndef D3DCOLORVALUE_DEFINED +typedef struct _D3DCOLORVALUE { + union { + D3DVALUE r; + D3DVALUE dvR; + }; + union { + D3DVALUE g; + D3DVALUE dvG; + }; + union { + D3DVALUE b; + D3DVALUE dvB; + }; + union { + D3DVALUE a; + D3DVALUE dvA; + }; +} D3DCOLORVALUE; +#define D3DCOLORVALUE_DEFINED +#endif +typedef struct _D3DCOLORVALUE *LPD3DCOLORVALUE; + +#ifndef D3DRECT_DEFINED +typedef struct _D3DRECT { + union { + LONG x1; + LONG lX1; + }; + union { + LONG y1; + LONG lY1; + }; + union { + LONG x2; + LONG lX2; + }; + union { + LONG y2; + LONG lY2; + }; +} D3DRECT; +#define D3DRECT_DEFINED +#endif +typedef struct _D3DRECT *LPD3DRECT; + +#ifndef DX_SHARED_DEFINES + +/* + * This definition is shared with other DirectX components whose header files + * might already have defined it. Therefore, we don't define this type if + * someone else already has (as indicated by the definition of + * DX_SHARED_DEFINES). + */ + +#ifndef D3DVECTOR_DEFINED +typedef struct _D3DVECTOR { + union { + D3DVALUE x; + D3DVALUE dvX; + }; + union { + D3DVALUE y; + D3DVALUE dvY; + }; + union { + D3DVALUE z; + D3DVALUE dvZ; + }; +#if(DIRECT3D_VERSION >= 0x0500) +#if (defined __cplusplus) && (defined D3D_OVERLOADS) + +public: + + // ===================================== + // Constructors + // ===================================== + + _D3DVECTOR() { } + _D3DVECTOR(D3DVALUE f); + _D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z); + _D3DVECTOR(const D3DVALUE f[3]); + + // ===================================== + // Access grants + // ===================================== + + const D3DVALUE&operator[](int i) const; + D3DVALUE&operator[](int i); + + // ===================================== + // Assignment operators + // ===================================== + + _D3DVECTOR& operator += (const _D3DVECTOR& v); + _D3DVECTOR& operator -= (const _D3DVECTOR& v); + _D3DVECTOR& operator *= (const _D3DVECTOR& v); + _D3DVECTOR& operator /= (const _D3DVECTOR& v); + _D3DVECTOR& operator *= (D3DVALUE s); + _D3DVECTOR& operator /= (D3DVALUE s); + + // ===================================== + // Unary operators + // ===================================== + + friend _D3DVECTOR operator + (const _D3DVECTOR& v); + friend _D3DVECTOR operator - (const _D3DVECTOR& v); + + + // ===================================== + // Binary operators + // ===================================== + + // Addition and subtraction + friend _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2); + friend _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2); + // Scalar multiplication and division + friend _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s); + friend _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v); + friend _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s); + // Memberwise multiplication and division + friend _D3DVECTOR operator * (const _D3DVECTOR& v1, const _D3DVECTOR& v2); + friend _D3DVECTOR operator / (const _D3DVECTOR& v1, const _D3DVECTOR& v2); + + // Vector dominance + friend int operator < (const _D3DVECTOR& v1, const _D3DVECTOR& v2); + friend int operator <= (const _D3DVECTOR& v1, const _D3DVECTOR& v2); + + // Bitwise equality + friend int operator == (const _D3DVECTOR& v1, const _D3DVECTOR& v2); + + // Length-related functions + friend D3DVALUE SquareMagnitude (const _D3DVECTOR& v); + friend D3DVALUE Magnitude (const _D3DVECTOR& v); + + // Returns vector with same direction and unit length + friend _D3DVECTOR Normalize (const _D3DVECTOR& v); + + // Return min/max component of the input vector + friend D3DVALUE Min (const _D3DVECTOR& v); + friend D3DVALUE Max (const _D3DVECTOR& v); + + // Return memberwise min/max of input vectors + friend _D3DVECTOR Minimize (const _D3DVECTOR& v1, const _D3DVECTOR& v2); + friend _D3DVECTOR Maximize (const _D3DVECTOR& v1, const _D3DVECTOR& v2); + + // Dot and cross product + friend D3DVALUE DotProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2); + friend _D3DVECTOR CrossProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2); + +#endif +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DVECTOR; +#define D3DVECTOR_DEFINED +#endif +typedef struct _D3DVECTOR *LPD3DVECTOR; + +/* + * As this is the last of the shared defines to be defined we now set + * D3D_SHARED_DEFINES to flag that fact that this header has defined these + * types. + */ +#define DX_SHARED_DEFINES + +#endif /* DX_SHARED_DEFINES */ + +/* + * Vertex data types supported in an ExecuteBuffer. + */ + +/* + * Homogeneous vertices + */ + +typedef struct _D3DHVERTEX { + DWORD dwFlags; /* Homogeneous clipping flags */ + union { + D3DVALUE hx; + D3DVALUE dvHX; + }; + union { + D3DVALUE hy; + D3DVALUE dvHY; + }; + union { + D3DVALUE hz; + D3DVALUE dvHZ; + }; +} D3DHVERTEX, *LPD3DHVERTEX; + +/* + * Transformed/lit vertices + */ +typedef struct _D3DTLVERTEX { + union { + D3DVALUE sx; /* Screen coordinates */ + D3DVALUE dvSX; + }; + union { + D3DVALUE sy; + D3DVALUE dvSY; + }; + union { + D3DVALUE sz; + D3DVALUE dvSZ; + }; + union { + D3DVALUE rhw; /* Reciprocal of homogeneous w */ + D3DVALUE dvRHW; + }; + union { + D3DCOLOR color; /* Vertex color */ + D3DCOLOR dcColor; + }; + union { + D3DCOLOR specular; /* Specular component of vertex */ + D3DCOLOR dcSpecular; + }; + union { + D3DVALUE tu; /* Texture coordinates */ + D3DVALUE dvTU; + }; + union { + D3DVALUE tv; + D3DVALUE dvTV; + }; +#if(DIRECT3D_VERSION >= 0x0500) +#if (defined __cplusplus) && (defined D3D_OVERLOADS) + _D3DTLVERTEX() { } + _D3DTLVERTEX(const D3DVECTOR& v, float _rhw, + D3DCOLOR _color, D3DCOLOR _specular, + float _tu, float _tv) + { sx = v.x; sy = v.y; sz = v.z; rhw = _rhw; + color = _color; specular = _specular; + tu = _tu; tv = _tv; + } +#endif +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DTLVERTEX, *LPD3DTLVERTEX; + +/* + * Untransformed/lit vertices + */ +typedef struct _D3DLVERTEX { + union { + D3DVALUE x; /* Homogeneous coordinates */ + D3DVALUE dvX; + }; + union { + D3DVALUE y; + D3DVALUE dvY; + }; + union { + D3DVALUE z; + D3DVALUE dvZ; + }; + DWORD dwReserved; + union { + D3DCOLOR color; /* Vertex color */ + D3DCOLOR dcColor; + }; + union { + D3DCOLOR specular; /* Specular component of vertex */ + D3DCOLOR dcSpecular; + }; + union { + D3DVALUE tu; /* Texture coordinates */ + D3DVALUE dvTU; + }; + union { + D3DVALUE tv; + D3DVALUE dvTV; + }; +#if(DIRECT3D_VERSION >= 0x0500) +#if (defined __cplusplus) && (defined D3D_OVERLOADS) + _D3DLVERTEX() { } + _D3DLVERTEX(const D3DVECTOR& v, + D3DCOLOR _color, D3DCOLOR _specular, + float _tu, float _tv) + { x = v.x; y = v.y; z = v.z; dwReserved = 0; + color = _color; specular = _specular; + tu = _tu; tv = _tv; + } +#endif +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DLVERTEX, *LPD3DLVERTEX; + +/* + * Untransformed/unlit vertices + */ + +typedef struct _D3DVERTEX { + union { + D3DVALUE x; /* Homogeneous coordinates */ + D3DVALUE dvX; + }; + union { + D3DVALUE y; + D3DVALUE dvY; + }; + union { + D3DVALUE z; + D3DVALUE dvZ; + }; + union { + D3DVALUE nx; /* Normal */ + D3DVALUE dvNX; + }; + union { + D3DVALUE ny; + D3DVALUE dvNY; + }; + union { + D3DVALUE nz; + D3DVALUE dvNZ; + }; + union { + D3DVALUE tu; /* Texture coordinates */ + D3DVALUE dvTU; + }; + union { + D3DVALUE tv; + D3DVALUE dvTV; + }; +#if(DIRECT3D_VERSION >= 0x0500) +#if (defined __cplusplus) && (defined D3D_OVERLOADS) + _D3DVERTEX() { } + _D3DVERTEX(const D3DVECTOR& v, const D3DVECTOR& n, float _tu, float _tv) + { x = v.x; y = v.y; z = v.z; + nx = n.x; ny = n.y; nz = n.z; + tu = _tu; tv = _tv; + } +#endif +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DVERTEX, *LPD3DVERTEX; + + +/* + * Matrix, viewport, and tranformation structures and definitions. + */ + +#ifndef D3DMATRIX_DEFINED +typedef struct _D3DMATRIX { +#if(DIRECT3D_VERSION >= 0x0500) +#if (defined __cplusplus) && (defined D3D_OVERLOADS) + union { + struct { +#endif + +#endif /* DIRECT3D_VERSION >= 0x0500 */ + D3DVALUE _11, _12, _13, _14; + D3DVALUE _21, _22, _23, _24; + D3DVALUE _31, _32, _33, _34; + D3DVALUE _41, _42, _43, _44; + +#if(DIRECT3D_VERSION >= 0x0500) +#if (defined __cplusplus) && (defined D3D_OVERLOADS) + }; + D3DVALUE m[4][4]; + }; + _D3DMATRIX() { } + _D3DMATRIX( D3DVALUE _m00, D3DVALUE _m01, D3DVALUE _m02, D3DVALUE _m03, + D3DVALUE _m10, D3DVALUE _m11, D3DVALUE _m12, D3DVALUE _m13, + D3DVALUE _m20, D3DVALUE _m21, D3DVALUE _m22, D3DVALUE _m23, + D3DVALUE _m30, D3DVALUE _m31, D3DVALUE _m32, D3DVALUE _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; + } + + D3DVALUE& operator()(int iRow, int iColumn) { return m[iRow][iColumn]; } + const D3DVALUE& operator()(int iRow, int iColumn) const { return m[iRow][iColumn]; } +#if(DIRECT3D_VERSION >= 0x0600) + friend _D3DMATRIX operator* (const _D3DMATRIX&, const _D3DMATRIX&); +#endif /* DIRECT3D_VERSION >= 0x0600 */ +#endif +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DMATRIX; +#define D3DMATRIX_DEFINED +#endif +typedef struct _D3DMATRIX *LPD3DMATRIX; + +#if (defined __cplusplus) && (defined D3D_OVERLOADS) +#include "d3dvec.inl" +#endif + +typedef struct _D3DVIEWPORT { + DWORD dwSize; + DWORD dwX; + DWORD dwY; /* Top left */ + DWORD dwWidth; + DWORD dwHeight; /* Dimensions */ + D3DVALUE dvScaleX; /* Scale homogeneous to screen */ + D3DVALUE dvScaleY; /* Scale homogeneous to screen */ + D3DVALUE dvMaxX; /* Min/max homogeneous x coord */ + D3DVALUE dvMaxY; /* Min/max homogeneous y coord */ + D3DVALUE dvMinZ; + D3DVALUE dvMaxZ; /* Min/max homogeneous z coord */ +} D3DVIEWPORT, *LPD3DVIEWPORT; + +#if(DIRECT3D_VERSION >= 0x0500) +typedef struct _D3DVIEWPORT2 { + DWORD dwSize; + DWORD dwX; + DWORD dwY; /* Viewport Top left */ + DWORD dwWidth; + DWORD dwHeight; /* Viewport Dimensions */ + D3DVALUE dvClipX; /* Top left of clip volume */ + D3DVALUE dvClipY; + D3DVALUE dvClipWidth; /* Clip Volume Dimensions */ + D3DVALUE dvClipHeight; + D3DVALUE dvMinZ; /* Min/max of clip Volume */ + D3DVALUE dvMaxZ; +} D3DVIEWPORT2, *LPD3DVIEWPORT2; +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if(DIRECT3D_VERSION >= 0x0700) +typedef struct _D3DVIEWPORT7 { + DWORD dwX; + DWORD dwY; /* Viewport Top left */ + DWORD dwWidth; + DWORD dwHeight; /* Viewport Dimensions */ + D3DVALUE dvMinZ; /* Min/max of clip Volume */ + D3DVALUE dvMaxZ; +} D3DVIEWPORT7, *LPD3DVIEWPORT7; +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +/* + * Values for clip fields. + */ + +#if(DIRECT3D_VERSION >= 0x0700) + +// Max number of user clipping planes, supported in D3D. +#define D3DMAXUSERCLIPPLANES 32 + +// These bits could be ORed together to use with D3DRENDERSTATE_CLIPPLANEENABLE +// +#define D3DCLIPPLANE0 (1 << 0) +#define D3DCLIPPLANE1 (1 << 1) +#define D3DCLIPPLANE2 (1 << 2) +#define D3DCLIPPLANE3 (1 << 3) +#define D3DCLIPPLANE4 (1 << 4) +#define D3DCLIPPLANE5 (1 << 5) + +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +#define D3DCLIP_LEFT 0x00000001L +#define D3DCLIP_RIGHT 0x00000002L +#define D3DCLIP_TOP 0x00000004L +#define D3DCLIP_BOTTOM 0x00000008L +#define D3DCLIP_FRONT 0x00000010L +#define D3DCLIP_BACK 0x00000020L +#define D3DCLIP_GEN0 0x00000040L +#define D3DCLIP_GEN1 0x00000080L +#define D3DCLIP_GEN2 0x00000100L +#define D3DCLIP_GEN3 0x00000200L +#define D3DCLIP_GEN4 0x00000400L +#define D3DCLIP_GEN5 0x00000800L + +/* + * Values for d3d status. + */ +#define D3DSTATUS_CLIPUNIONLEFT D3DCLIP_LEFT +#define D3DSTATUS_CLIPUNIONRIGHT D3DCLIP_RIGHT +#define D3DSTATUS_CLIPUNIONTOP D3DCLIP_TOP +#define D3DSTATUS_CLIPUNIONBOTTOM D3DCLIP_BOTTOM +#define D3DSTATUS_CLIPUNIONFRONT D3DCLIP_FRONT +#define D3DSTATUS_CLIPUNIONBACK D3DCLIP_BACK +#define D3DSTATUS_CLIPUNIONGEN0 D3DCLIP_GEN0 +#define D3DSTATUS_CLIPUNIONGEN1 D3DCLIP_GEN1 +#define D3DSTATUS_CLIPUNIONGEN2 D3DCLIP_GEN2 +#define D3DSTATUS_CLIPUNIONGEN3 D3DCLIP_GEN3 +#define D3DSTATUS_CLIPUNIONGEN4 D3DCLIP_GEN4 +#define D3DSTATUS_CLIPUNIONGEN5 D3DCLIP_GEN5 + +#define D3DSTATUS_CLIPINTERSECTIONLEFT 0x00001000L +#define D3DSTATUS_CLIPINTERSECTIONRIGHT 0x00002000L +#define D3DSTATUS_CLIPINTERSECTIONTOP 0x00004000L +#define D3DSTATUS_CLIPINTERSECTIONBOTTOM 0x00008000L +#define D3DSTATUS_CLIPINTERSECTIONFRONT 0x00010000L +#define D3DSTATUS_CLIPINTERSECTIONBACK 0x00020000L +#define D3DSTATUS_CLIPINTERSECTIONGEN0 0x00040000L +#define D3DSTATUS_CLIPINTERSECTIONGEN1 0x00080000L +#define D3DSTATUS_CLIPINTERSECTIONGEN2 0x00100000L +#define D3DSTATUS_CLIPINTERSECTIONGEN3 0x00200000L +#define D3DSTATUS_CLIPINTERSECTIONGEN4 0x00400000L +#define D3DSTATUS_CLIPINTERSECTIONGEN5 0x00800000L +#define D3DSTATUS_ZNOTVISIBLE 0x01000000L +/* Do not use 0x80000000 for any status flags in future as it is reserved */ + +#define D3DSTATUS_CLIPUNIONALL ( \ + D3DSTATUS_CLIPUNIONLEFT | \ + D3DSTATUS_CLIPUNIONRIGHT | \ + D3DSTATUS_CLIPUNIONTOP | \ + D3DSTATUS_CLIPUNIONBOTTOM | \ + D3DSTATUS_CLIPUNIONFRONT | \ + D3DSTATUS_CLIPUNIONBACK | \ + D3DSTATUS_CLIPUNIONGEN0 | \ + D3DSTATUS_CLIPUNIONGEN1 | \ + D3DSTATUS_CLIPUNIONGEN2 | \ + D3DSTATUS_CLIPUNIONGEN3 | \ + D3DSTATUS_CLIPUNIONGEN4 | \ + D3DSTATUS_CLIPUNIONGEN5 \ + ) + +#define D3DSTATUS_CLIPINTERSECTIONALL ( \ + D3DSTATUS_CLIPINTERSECTIONLEFT | \ + D3DSTATUS_CLIPINTERSECTIONRIGHT | \ + D3DSTATUS_CLIPINTERSECTIONTOP | \ + D3DSTATUS_CLIPINTERSECTIONBOTTOM | \ + D3DSTATUS_CLIPINTERSECTIONFRONT | \ + D3DSTATUS_CLIPINTERSECTIONBACK | \ + D3DSTATUS_CLIPINTERSECTIONGEN0 | \ + D3DSTATUS_CLIPINTERSECTIONGEN1 | \ + D3DSTATUS_CLIPINTERSECTIONGEN2 | \ + D3DSTATUS_CLIPINTERSECTIONGEN3 | \ + D3DSTATUS_CLIPINTERSECTIONGEN4 | \ + D3DSTATUS_CLIPINTERSECTIONGEN5 \ + ) + +#define D3DSTATUS_DEFAULT ( \ + D3DSTATUS_CLIPINTERSECTIONALL | \ + D3DSTATUS_ZNOTVISIBLE) + + +/* + * Options for direct transform calls + */ +#define D3DTRANSFORM_CLIPPED 0x00000001l +#define D3DTRANSFORM_UNCLIPPED 0x00000002l + +typedef struct _D3DTRANSFORMDATA { + DWORD dwSize; + LPVOID lpIn; /* Input vertices */ + DWORD dwInSize; /* Stride of input vertices */ + LPVOID lpOut; /* Output vertices */ + DWORD dwOutSize; /* Stride of output vertices */ + LPD3DHVERTEX lpHOut; /* Output homogeneous vertices */ + DWORD dwClip; /* Clipping hint */ + DWORD dwClipIntersection; + DWORD dwClipUnion; /* Union of all clip flags */ + D3DRECT drExtent; /* Extent of transformed vertices */ +} D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA; + +/* + * Structure defining position and direction properties for lighting. + */ +typedef struct _D3DLIGHTINGELEMENT { + D3DVECTOR dvPosition; /* Lightable point in model space */ + D3DVECTOR dvNormal; /* Normalised unit vector */ +} D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT; + +/* + * Structure defining material properties for lighting. + */ +typedef struct _D3DMATERIAL { + DWORD dwSize; + union { + D3DCOLORVALUE diffuse; /* Diffuse color RGBA */ + D3DCOLORVALUE dcvDiffuse; + }; + union { + D3DCOLORVALUE ambient; /* Ambient color RGB */ + D3DCOLORVALUE dcvAmbient; + }; + union { + D3DCOLORVALUE specular; /* Specular 'shininess' */ + D3DCOLORVALUE dcvSpecular; + }; + union { + D3DCOLORVALUE emissive; /* Emissive color RGB */ + D3DCOLORVALUE dcvEmissive; + }; + union { + D3DVALUE power; /* Sharpness if specular highlight */ + D3DVALUE dvPower; + }; + D3DTEXTUREHANDLE hTexture; /* Handle to texture map */ + DWORD dwRampSize; +} D3DMATERIAL, *LPD3DMATERIAL; + +#if(DIRECT3D_VERSION >= 0x0700) + +typedef struct _D3DMATERIAL7 { + union { + D3DCOLORVALUE diffuse; /* Diffuse color RGBA */ + D3DCOLORVALUE dcvDiffuse; + }; + union { + D3DCOLORVALUE ambient; /* Ambient color RGB */ + D3DCOLORVALUE dcvAmbient; + }; + union { + D3DCOLORVALUE specular; /* Specular 'shininess' */ + D3DCOLORVALUE dcvSpecular; + }; + union { + D3DCOLORVALUE emissive; /* Emissive color RGB */ + D3DCOLORVALUE dcvEmissive; + }; + union { + D3DVALUE power; /* Sharpness if specular highlight */ + D3DVALUE dvPower; + }; +} D3DMATERIAL7, *LPD3DMATERIAL7; + +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +#if(DIRECT3D_VERSION < 0x0800) + +typedef enum _D3DLIGHTTYPE { + D3DLIGHT_POINT = 1, + D3DLIGHT_SPOT = 2, + D3DLIGHT_DIRECTIONAL = 3, +// Note: The following light type (D3DLIGHT_PARALLELPOINT) +// is no longer supported from D3D for DX7 onwards. + D3DLIGHT_PARALLELPOINT = 4, +#if(DIRECT3D_VERSION < 0x0500) // For backward compatible headers + D3DLIGHT_GLSPOT = 5, +#endif + D3DLIGHT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DLIGHTTYPE; + +#else +typedef enum _D3DLIGHTTYPE D3DLIGHTTYPE; +#define D3DLIGHT_PARALLELPOINT (D3DLIGHTTYPE)4 +#define D3DLIGHT_GLSPOT (D3DLIGHTTYPE)5 + +#endif //(DIRECT3D_VERSION < 0x0800) + +/* + * Structure defining a light source and its properties. + */ +typedef struct _D3DLIGHT { + DWORD dwSize; + D3DLIGHTTYPE dltType; /* Type of light source */ + D3DCOLORVALUE dcvColor; /* Color of light */ + D3DVECTOR dvPosition; /* Position in world space */ + D3DVECTOR dvDirection; /* Direction in world space */ + D3DVALUE dvRange; /* Cutoff range */ + D3DVALUE dvFalloff; /* Falloff */ + D3DVALUE dvAttenuation0; /* Constant attenuation */ + D3DVALUE dvAttenuation1; /* Linear attenuation */ + D3DVALUE dvAttenuation2; /* Quadratic attenuation */ + D3DVALUE dvTheta; /* Inner angle of spotlight cone */ + D3DVALUE dvPhi; /* Outer angle of spotlight cone */ +} D3DLIGHT, *LPD3DLIGHT; + +#if(DIRECT3D_VERSION >= 0x0700) + +typedef struct _D3DLIGHT7 { + D3DLIGHTTYPE dltType; /* Type of light source */ + D3DCOLORVALUE dcvDiffuse; /* Diffuse color of light */ + D3DCOLORVALUE dcvSpecular; /* Specular color of light */ + D3DCOLORVALUE dcvAmbient; /* Ambient color of light */ + D3DVECTOR dvPosition; /* Position in world space */ + D3DVECTOR dvDirection; /* Direction in world space */ + D3DVALUE dvRange; /* Cutoff range */ + D3DVALUE dvFalloff; /* Falloff */ + D3DVALUE dvAttenuation0; /* Constant attenuation */ + D3DVALUE dvAttenuation1; /* Linear attenuation */ + D3DVALUE dvAttenuation2; /* Quadratic attenuation */ + D3DVALUE dvTheta; /* Inner angle of spotlight cone */ + D3DVALUE dvPhi; /* Outer angle of spotlight cone */ +} D3DLIGHT7, *LPD3DLIGHT7; + +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +#if(DIRECT3D_VERSION >= 0x0500) +/* + * Structure defining a light source and its properties. + */ + +/* flags bits */ +#define D3DLIGHT_ACTIVE 0x00000001 +#define D3DLIGHT_NO_SPECULAR 0x00000002 +#define D3DLIGHT_ALL (D3DLIGHT_ACTIVE | D3DLIGHT_NO_SPECULAR) + +/* maximum valid light range */ +#define D3DLIGHT_RANGE_MAX ((float)sqrt(FLT_MAX)) + +typedef struct _D3DLIGHT2 { + DWORD dwSize; + D3DLIGHTTYPE dltType; /* Type of light source */ + D3DCOLORVALUE dcvColor; /* Color of light */ + D3DVECTOR dvPosition; /* Position in world space */ + D3DVECTOR dvDirection; /* Direction in world space */ + D3DVALUE dvRange; /* Cutoff range */ + D3DVALUE dvFalloff; /* Falloff */ + D3DVALUE dvAttenuation0; /* Constant attenuation */ + D3DVALUE dvAttenuation1; /* Linear attenuation */ + D3DVALUE dvAttenuation2; /* Quadratic attenuation */ + D3DVALUE dvTheta; /* Inner angle of spotlight cone */ + D3DVALUE dvPhi; /* Outer angle of spotlight cone */ + DWORD dwFlags; +} D3DLIGHT2, *LPD3DLIGHT2; + +#endif /* DIRECT3D_VERSION >= 0x0500 */ +typedef struct _D3DLIGHTDATA { + DWORD dwSize; + LPD3DLIGHTINGELEMENT lpIn; /* Input positions and normals */ + DWORD dwInSize; /* Stride of input elements */ + LPD3DTLVERTEX lpOut; /* Output colors */ + DWORD dwOutSize; /* Stride of output colors */ +} D3DLIGHTDATA, *LPD3DLIGHTDATA; + +#if(DIRECT3D_VERSION >= 0x0500) +/* + * Before DX5, these values were in an enum called + * D3DCOLORMODEL. This was not correct, since they are + * bit flags. A driver can surface either or both flags + * in the dcmColorModel member of D3DDEVICEDESC. + */ +#define D3DCOLOR_MONO 1 +#define D3DCOLOR_RGB 2 + +typedef DWORD D3DCOLORMODEL; +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +/* + * Options for clearing + */ +#define D3DCLEAR_TARGET 0x00000001l /* Clear target surface */ +#define D3DCLEAR_ZBUFFER 0x00000002l /* Clear target z buffer */ +#if(DIRECT3D_VERSION >= 0x0600) +#define D3DCLEAR_STENCIL 0x00000004l /* Clear stencil planes */ +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +/* + * Execute buffers are allocated via Direct3D. These buffers may then + * be filled by the application with instructions to execute along with + * vertex data. + */ + +/* + * Supported op codes for execute instructions. + */ +typedef enum _D3DOPCODE { + D3DOP_POINT = 1, + D3DOP_LINE = 2, + D3DOP_TRIANGLE = 3, + D3DOP_MATRIXLOAD = 4, + D3DOP_MATRIXMULTIPLY = 5, + D3DOP_STATETRANSFORM = 6, + D3DOP_STATELIGHT = 7, + D3DOP_STATERENDER = 8, + D3DOP_PROCESSVERTICES = 9, + D3DOP_TEXTURELOAD = 10, + D3DOP_EXIT = 11, + D3DOP_BRANCHFORWARD = 12, + D3DOP_SPAN = 13, + D3DOP_SETSTATUS = 14, +#if(DIRECT3D_VERSION >= 0x0500) + D3DOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DOPCODE; + +typedef struct _D3DINSTRUCTION { + BYTE bOpcode; /* Instruction opcode */ + BYTE bSize; /* Size of each instruction data unit */ + WORD wCount; /* Count of instruction data units to follow */ +} D3DINSTRUCTION, *LPD3DINSTRUCTION; + +/* + * Structure for texture loads + */ +typedef struct _D3DTEXTURELOAD { + D3DTEXTUREHANDLE hDestTexture; + D3DTEXTUREHANDLE hSrcTexture; +} D3DTEXTURELOAD, *LPD3DTEXTURELOAD; + +/* + * Structure for picking + */ +typedef struct _D3DPICKRECORD { + BYTE bOpcode; + BYTE bPad; + DWORD dwOffset; + D3DVALUE dvZ; +} D3DPICKRECORD, *LPD3DPICKRECORD; + +/* + * The following defines the rendering states which can be set in the + * execute buffer. + */ + +#if(DIRECT3D_VERSION < 0x0800) + +typedef enum _D3DSHADEMODE { + D3DSHADE_FLAT = 1, + D3DSHADE_GOURAUD = 2, + D3DSHADE_PHONG = 3, +#if(DIRECT3D_VERSION >= 0x0500) + D3DSHADE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DSHADEMODE; + +typedef enum _D3DFILLMODE { + D3DFILL_POINT = 1, + D3DFILL_WIREFRAME = 2, + D3DFILL_SOLID = 3, +#if(DIRECT3D_VERSION >= 0x0500) + D3DFILL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DFILLMODE; + +typedef struct _D3DLINEPATTERN { + WORD wRepeatFactor; + WORD wLinePattern; +} D3DLINEPATTERN; + +#endif //(DIRECT3D_VERSION < 0x0800) + +typedef enum _D3DTEXTUREFILTER { + D3DFILTER_NEAREST = 1, + D3DFILTER_LINEAR = 2, + D3DFILTER_MIPNEAREST = 3, + D3DFILTER_MIPLINEAR = 4, + D3DFILTER_LINEARMIPNEAREST = 5, + D3DFILTER_LINEARMIPLINEAR = 6, +#if(DIRECT3D_VERSION >= 0x0500) + D3DFILTER_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DTEXTUREFILTER; + +#if(DIRECT3D_VERSION < 0x0800) + +typedef enum _D3DBLEND { + D3DBLEND_ZERO = 1, + D3DBLEND_ONE = 2, + D3DBLEND_SRCCOLOR = 3, + D3DBLEND_INVSRCCOLOR = 4, + D3DBLEND_SRCALPHA = 5, + D3DBLEND_INVSRCALPHA = 6, + D3DBLEND_DESTALPHA = 7, + D3DBLEND_INVDESTALPHA = 8, + D3DBLEND_DESTCOLOR = 9, + D3DBLEND_INVDESTCOLOR = 10, + D3DBLEND_SRCALPHASAT = 11, + D3DBLEND_BOTHSRCALPHA = 12, + D3DBLEND_BOTHINVSRCALPHA = 13, +#if(DIRECT3D_VERSION >= 0x0500) + D3DBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DBLEND; + +#endif //(DIRECT3D_VERSION < 0x0800) + +typedef enum _D3DTEXTUREBLEND { + D3DTBLEND_DECAL = 1, + D3DTBLEND_MODULATE = 2, + D3DTBLEND_DECALALPHA = 3, + D3DTBLEND_MODULATEALPHA = 4, + D3DTBLEND_DECALMASK = 5, + D3DTBLEND_MODULATEMASK = 6, + D3DTBLEND_COPY = 7, +#if(DIRECT3D_VERSION >= 0x0500) + D3DTBLEND_ADD = 8, + D3DTBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DTEXTUREBLEND; + +#if(DIRECT3D_VERSION < 0x0800) + +typedef enum _D3DTEXTUREADDRESS { + D3DTADDRESS_WRAP = 1, + D3DTADDRESS_MIRROR = 2, + D3DTADDRESS_CLAMP = 3, +#if(DIRECT3D_VERSION >= 0x0500) + D3DTADDRESS_BORDER = 4, + D3DTADDRESS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DTEXTUREADDRESS; + +typedef enum _D3DCULL { + D3DCULL_NONE = 1, + D3DCULL_CW = 2, + D3DCULL_CCW = 3, +#if(DIRECT3D_VERSION >= 0x0500) + D3DCULL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DCULL; + +typedef enum _D3DCMPFUNC { + D3DCMP_NEVER = 1, + D3DCMP_LESS = 2, + D3DCMP_EQUAL = 3, + D3DCMP_LESSEQUAL = 4, + D3DCMP_GREATER = 5, + D3DCMP_NOTEQUAL = 6, + D3DCMP_GREATEREQUAL = 7, + D3DCMP_ALWAYS = 8, +#if(DIRECT3D_VERSION >= 0x0500) + D3DCMP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DCMPFUNC; + +#if(DIRECT3D_VERSION >= 0x0600) +typedef enum _D3DSTENCILOP { + D3DSTENCILOP_KEEP = 1, + D3DSTENCILOP_ZERO = 2, + D3DSTENCILOP_REPLACE = 3, + D3DSTENCILOP_INCRSAT = 4, + D3DSTENCILOP_DECRSAT = 5, + D3DSTENCILOP_INVERT = 6, + D3DSTENCILOP_INCR = 7, + D3DSTENCILOP_DECR = 8, + D3DSTENCILOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DSTENCILOP; +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +typedef enum _D3DFOGMODE { + D3DFOG_NONE = 0, + D3DFOG_EXP = 1, + D3DFOG_EXP2 = 2, +#if(DIRECT3D_VERSION >= 0x0500) + D3DFOG_LINEAR = 3, + D3DFOG_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DFOGMODE; + +#if(DIRECT3D_VERSION >= 0x0600) +typedef enum _D3DZBUFFERTYPE { + D3DZB_FALSE = 0, + D3DZB_TRUE = 1, // Z buffering + D3DZB_USEW = 2, // W buffering + D3DZB_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DZBUFFERTYPE; +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +#endif //(DIRECT3D_VERSION < 0x0800) + +#if(DIRECT3D_VERSION >= 0x0500) +typedef enum _D3DANTIALIASMODE { + D3DANTIALIAS_NONE = 0, + D3DANTIALIAS_SORTDEPENDENT = 1, + D3DANTIALIAS_SORTINDEPENDENT = 2, + D3DANTIALIAS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DANTIALIASMODE; + +// Vertex types supported by Direct3D +typedef enum _D3DVERTEXTYPE { + D3DVT_VERTEX = 1, + D3DVT_LVERTEX = 2, + D3DVT_TLVERTEX = 3, + D3DVT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DVERTEXTYPE; + +#if(DIRECT3D_VERSION < 0x0800) + +// Primitives supported by draw-primitive API +typedef enum _D3DPRIMITIVETYPE { + D3DPT_POINTLIST = 1, + D3DPT_LINELIST = 2, + D3DPT_LINESTRIP = 3, + D3DPT_TRIANGLELIST = 4, + D3DPT_TRIANGLESTRIP = 5, + D3DPT_TRIANGLEFAN = 6, + D3DPT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DPRIMITIVETYPE; + +#endif //(DIRECT3D_VERSION < 0x0800) + +#endif /* DIRECT3D_VERSION >= 0x0500 */ +/* + * Amount to add to a state to generate the override for that state. + */ +#define D3DSTATE_OVERRIDE_BIAS 256 + +/* + * A state which sets the override flag for the specified state type. + */ +#define D3DSTATE_OVERRIDE(type) (D3DRENDERSTATETYPE)(((DWORD) (type) + D3DSTATE_OVERRIDE_BIAS)) + +#if(DIRECT3D_VERSION < 0x0800) + +typedef enum _D3DTRANSFORMSTATETYPE { + D3DTRANSFORMSTATE_WORLD = 1, + D3DTRANSFORMSTATE_VIEW = 2, + D3DTRANSFORMSTATE_PROJECTION = 3, +#if(DIRECT3D_VERSION >= 0x0700) + D3DTRANSFORMSTATE_WORLD1 = 4, // 2nd matrix to blend + D3DTRANSFORMSTATE_WORLD2 = 5, // 3rd matrix to blend + D3DTRANSFORMSTATE_WORLD3 = 6, // 4th matrix to blend + D3DTRANSFORMSTATE_TEXTURE0 = 16, + D3DTRANSFORMSTATE_TEXTURE1 = 17, + D3DTRANSFORMSTATE_TEXTURE2 = 18, + D3DTRANSFORMSTATE_TEXTURE3 = 19, + D3DTRANSFORMSTATE_TEXTURE4 = 20, + D3DTRANSFORMSTATE_TEXTURE5 = 21, + D3DTRANSFORMSTATE_TEXTURE6 = 22, + D3DTRANSFORMSTATE_TEXTURE7 = 23, +#endif /* DIRECT3D_VERSION >= 0x0700 */ +#if(DIRECT3D_VERSION >= 0x0500) + D3DTRANSFORMSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DTRANSFORMSTATETYPE; + +#else + +// +// legacy transform state names +// +typedef enum _D3DTRANSFORMSTATETYPE D3DTRANSFORMSTATETYPE; +#define D3DTRANSFORMSTATE_WORLD (D3DTRANSFORMSTATETYPE)1 +#define D3DTRANSFORMSTATE_VIEW (D3DTRANSFORMSTATETYPE)2 +#define D3DTRANSFORMSTATE_PROJECTION (D3DTRANSFORMSTATETYPE)3 +#define D3DTRANSFORMSTATE_WORLD1 (D3DTRANSFORMSTATETYPE)4 +#define D3DTRANSFORMSTATE_WORLD2 (D3DTRANSFORMSTATETYPE)5 +#define D3DTRANSFORMSTATE_WORLD3 (D3DTRANSFORMSTATETYPE)6 +#define D3DTRANSFORMSTATE_TEXTURE0 (D3DTRANSFORMSTATETYPE)16 +#define D3DTRANSFORMSTATE_TEXTURE1 (D3DTRANSFORMSTATETYPE)17 +#define D3DTRANSFORMSTATE_TEXTURE2 (D3DTRANSFORMSTATETYPE)18 +#define D3DTRANSFORMSTATE_TEXTURE3 (D3DTRANSFORMSTATETYPE)19 +#define D3DTRANSFORMSTATE_TEXTURE4 (D3DTRANSFORMSTATETYPE)20 +#define D3DTRANSFORMSTATE_TEXTURE5 (D3DTRANSFORMSTATETYPE)21 +#define D3DTRANSFORMSTATE_TEXTURE6 (D3DTRANSFORMSTATETYPE)22 +#define D3DTRANSFORMSTATE_TEXTURE7 (D3DTRANSFORMSTATETYPE)23 + +#endif //(DIRECT3D_VERSION < 0x0800) + +typedef enum _D3DLIGHTSTATETYPE { + D3DLIGHTSTATE_MATERIAL = 1, + D3DLIGHTSTATE_AMBIENT = 2, + D3DLIGHTSTATE_COLORMODEL = 3, + D3DLIGHTSTATE_FOGMODE = 4, + D3DLIGHTSTATE_FOGSTART = 5, + D3DLIGHTSTATE_FOGEND = 6, + D3DLIGHTSTATE_FOGDENSITY = 7, +#if(DIRECT3D_VERSION >= 0x0600) + D3DLIGHTSTATE_COLORVERTEX = 8, +#endif /* DIRECT3D_VERSION >= 0x0600 */ +#if(DIRECT3D_VERSION >= 0x0500) + D3DLIGHTSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DLIGHTSTATETYPE; + +#if(DIRECT3D_VERSION < 0x0800) + +typedef enum _D3DRENDERSTATETYPE { + D3DRENDERSTATE_ANTIALIAS = 2, /* D3DANTIALIASMODE */ + D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4, /* TRUE for perspective correction */ + D3DRENDERSTATE_ZENABLE = 7, /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */ + D3DRENDERSTATE_FILLMODE = 8, /* D3DFILL_MODE */ + D3DRENDERSTATE_SHADEMODE = 9, /* D3DSHADEMODE */ + D3DRENDERSTATE_LINEPATTERN = 10, /* D3DLINEPATTERN */ + D3DRENDERSTATE_ZWRITEENABLE = 14, /* TRUE to enable z writes */ + D3DRENDERSTATE_ALPHATESTENABLE = 15, /* TRUE to enable alpha tests */ + D3DRENDERSTATE_LASTPIXEL = 16, /* TRUE for last-pixel on lines */ + D3DRENDERSTATE_SRCBLEND = 19, /* D3DBLEND */ + D3DRENDERSTATE_DESTBLEND = 20, /* D3DBLEND */ + D3DRENDERSTATE_CULLMODE = 22, /* D3DCULL */ + D3DRENDERSTATE_ZFUNC = 23, /* D3DCMPFUNC */ + D3DRENDERSTATE_ALPHAREF = 24, /* D3DFIXED */ + D3DRENDERSTATE_ALPHAFUNC = 25, /* D3DCMPFUNC */ + D3DRENDERSTATE_DITHERENABLE = 26, /* TRUE to enable dithering */ +#if(DIRECT3D_VERSION >= 0x0500) + D3DRENDERSTATE_ALPHABLENDENABLE = 27, /* TRUE to enable alpha blending */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ + D3DRENDERSTATE_FOGENABLE = 28, /* TRUE to enable fog blending */ + D3DRENDERSTATE_SPECULARENABLE = 29, /* TRUE to enable specular */ + D3DRENDERSTATE_ZVISIBLE = 30, /* TRUE to enable z checking */ + D3DRENDERSTATE_STIPPLEDALPHA = 33, /* TRUE to enable stippled alpha (RGB device only) */ + D3DRENDERSTATE_FOGCOLOR = 34, /* D3DCOLOR */ + D3DRENDERSTATE_FOGTABLEMODE = 35, /* D3DFOGMODE */ +#if(DIRECT3D_VERSION >= 0x0700) + D3DRENDERSTATE_FOGSTART = 36, /* Fog start (for both vertex and pixel fog) */ + D3DRENDERSTATE_FOGEND = 37, /* Fog end */ + D3DRENDERSTATE_FOGDENSITY = 38, /* Fog density */ +#endif /* DIRECT3D_VERSION >= 0x0700 */ +#if(DIRECT3D_VERSION >= 0x0500) + D3DRENDERSTATE_EDGEANTIALIAS = 40, /* TRUE to enable edge antialiasing */ + D3DRENDERSTATE_COLORKEYENABLE = 41, /* TRUE to enable source colorkeyed textures */ + D3DRENDERSTATE_ZBIAS = 47, /* LONG Z bias */ + D3DRENDERSTATE_RANGEFOGENABLE = 48, /* Enables range-based fog */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if(DIRECT3D_VERSION >= 0x0600) + D3DRENDERSTATE_STENCILENABLE = 52, /* BOOL enable/disable stenciling */ + D3DRENDERSTATE_STENCILFAIL = 53, /* D3DSTENCILOP to do if stencil test fails */ + D3DRENDERSTATE_STENCILZFAIL = 54, /* D3DSTENCILOP to do if stencil test passes and Z test fails */ + D3DRENDERSTATE_STENCILPASS = 55, /* D3DSTENCILOP to do if both stencil and Z tests pass */ + D3DRENDERSTATE_STENCILFUNC = 56, /* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */ + D3DRENDERSTATE_STENCILREF = 57, /* Reference value used in stencil test */ + D3DRENDERSTATE_STENCILMASK = 58, /* Mask value used in stencil test */ + D3DRENDERSTATE_STENCILWRITEMASK = 59, /* Write mask applied to values written to stencil buffer */ + D3DRENDERSTATE_TEXTUREFACTOR = 60, /* D3DCOLOR used for multi-texture blend */ +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +#if(DIRECT3D_VERSION >= 0x0600) + + /* + * 128 values [128, 255] are reserved for texture coordinate wrap flags. + * These are constructed with the D3DWRAP_U and D3DWRAP_V macros. Using + * a flags word preserves forward compatibility with texture coordinates + * that are >2D. + */ + D3DRENDERSTATE_WRAP0 = 128, /* wrap for 1st texture coord. set */ + D3DRENDERSTATE_WRAP1 = 129, /* wrap for 2nd texture coord. set */ + D3DRENDERSTATE_WRAP2 = 130, /* wrap for 3rd texture coord. set */ + D3DRENDERSTATE_WRAP3 = 131, /* wrap for 4th texture coord. set */ + D3DRENDERSTATE_WRAP4 = 132, /* wrap for 5th texture coord. set */ + D3DRENDERSTATE_WRAP5 = 133, /* wrap for 6th texture coord. set */ + D3DRENDERSTATE_WRAP6 = 134, /* wrap for 7th texture coord. set */ + D3DRENDERSTATE_WRAP7 = 135, /* wrap for 8th texture coord. set */ +#endif /* DIRECT3D_VERSION >= 0x0600 */ +#if(DIRECT3D_VERSION >= 0x0700) + D3DRENDERSTATE_CLIPPING = 136, + D3DRENDERSTATE_LIGHTING = 137, + D3DRENDERSTATE_EXTENTS = 138, + D3DRENDERSTATE_AMBIENT = 139, + D3DRENDERSTATE_FOGVERTEXMODE = 140, + D3DRENDERSTATE_COLORVERTEX = 141, + D3DRENDERSTATE_LOCALVIEWER = 142, + D3DRENDERSTATE_NORMALIZENORMALS = 143, + D3DRENDERSTATE_COLORKEYBLENDENABLE = 144, + D3DRENDERSTATE_DIFFUSEMATERIALSOURCE = 145, + D3DRENDERSTATE_SPECULARMATERIALSOURCE = 146, + D3DRENDERSTATE_AMBIENTMATERIALSOURCE = 147, + D3DRENDERSTATE_EMISSIVEMATERIALSOURCE = 148, + D3DRENDERSTATE_VERTEXBLEND = 151, + D3DRENDERSTATE_CLIPPLANEENABLE = 152, + +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +// +// retired renderstates - not supported for DX7 interfaces +// + D3DRENDERSTATE_TEXTUREHANDLE = 1, /* Texture handle for legacy interfaces (Texture,Texture2) */ + D3DRENDERSTATE_TEXTUREADDRESS = 3, /* D3DTEXTUREADDRESS */ + D3DRENDERSTATE_WRAPU = 5, /* TRUE for wrapping in u */ + D3DRENDERSTATE_WRAPV = 6, /* TRUE for wrapping in v */ + D3DRENDERSTATE_MONOENABLE = 11, /* TRUE to enable mono rasterization */ + D3DRENDERSTATE_ROP2 = 12, /* ROP2 */ + D3DRENDERSTATE_PLANEMASK = 13, /* DWORD physical plane mask */ + D3DRENDERSTATE_TEXTUREMAG = 17, /* D3DTEXTUREFILTER */ + D3DRENDERSTATE_TEXTUREMIN = 18, /* D3DTEXTUREFILTER */ + D3DRENDERSTATE_TEXTUREMAPBLEND = 21, /* D3DTEXTUREBLEND */ + D3DRENDERSTATE_SUBPIXEL = 31, /* TRUE to enable subpixel correction */ + D3DRENDERSTATE_SUBPIXELX = 32, /* TRUE to enable correction in X only */ + D3DRENDERSTATE_STIPPLEENABLE = 39, /* TRUE to enable stippling */ +#if(DIRECT3D_VERSION >= 0x0500) + D3DRENDERSTATE_BORDERCOLOR = 43, /* Border color for texturing w/border */ + D3DRENDERSTATE_TEXTUREADDRESSU = 44, /* Texture addressing mode for U coordinate */ + D3DRENDERSTATE_TEXTUREADDRESSV = 45, /* Texture addressing mode for V coordinate */ + D3DRENDERSTATE_MIPMAPLODBIAS = 46, /* D3DVALUE Mipmap LOD bias */ + D3DRENDERSTATE_ANISOTROPY = 49, /* Max. anisotropy. 1 = no anisotropy */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ + D3DRENDERSTATE_FLUSHBATCH = 50, /* Explicit flush for DP batching (DX5 Only) */ +#if(DIRECT3D_VERSION >= 0x0600) + D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT=51, /* BOOL enable sort-independent transparency */ +#endif /* DIRECT3D_VERSION >= 0x0600 */ + D3DRENDERSTATE_STIPPLEPATTERN00 = 64, /* Stipple pattern 01... */ + D3DRENDERSTATE_STIPPLEPATTERN01 = 65, + D3DRENDERSTATE_STIPPLEPATTERN02 = 66, + D3DRENDERSTATE_STIPPLEPATTERN03 = 67, + D3DRENDERSTATE_STIPPLEPATTERN04 = 68, + D3DRENDERSTATE_STIPPLEPATTERN05 = 69, + D3DRENDERSTATE_STIPPLEPATTERN06 = 70, + D3DRENDERSTATE_STIPPLEPATTERN07 = 71, + D3DRENDERSTATE_STIPPLEPATTERN08 = 72, + D3DRENDERSTATE_STIPPLEPATTERN09 = 73, + D3DRENDERSTATE_STIPPLEPATTERN10 = 74, + D3DRENDERSTATE_STIPPLEPATTERN11 = 75, + D3DRENDERSTATE_STIPPLEPATTERN12 = 76, + D3DRENDERSTATE_STIPPLEPATTERN13 = 77, + D3DRENDERSTATE_STIPPLEPATTERN14 = 78, + D3DRENDERSTATE_STIPPLEPATTERN15 = 79, + D3DRENDERSTATE_STIPPLEPATTERN16 = 80, + D3DRENDERSTATE_STIPPLEPATTERN17 = 81, + D3DRENDERSTATE_STIPPLEPATTERN18 = 82, + D3DRENDERSTATE_STIPPLEPATTERN19 = 83, + D3DRENDERSTATE_STIPPLEPATTERN20 = 84, + D3DRENDERSTATE_STIPPLEPATTERN21 = 85, + D3DRENDERSTATE_STIPPLEPATTERN22 = 86, + D3DRENDERSTATE_STIPPLEPATTERN23 = 87, + D3DRENDERSTATE_STIPPLEPATTERN24 = 88, + D3DRENDERSTATE_STIPPLEPATTERN25 = 89, + D3DRENDERSTATE_STIPPLEPATTERN26 = 90, + D3DRENDERSTATE_STIPPLEPATTERN27 = 91, + D3DRENDERSTATE_STIPPLEPATTERN28 = 92, + D3DRENDERSTATE_STIPPLEPATTERN29 = 93, + D3DRENDERSTATE_STIPPLEPATTERN30 = 94, + D3DRENDERSTATE_STIPPLEPATTERN31 = 95, + +// +// retired renderstate names - the values are still used under new naming conventions +// + D3DRENDERSTATE_FOGTABLESTART = 36, /* Fog table start */ + D3DRENDERSTATE_FOGTABLEEND = 37, /* Fog table end */ + D3DRENDERSTATE_FOGTABLEDENSITY = 38, /* Fog table density */ + +#if(DIRECT3D_VERSION >= 0x0500) + D3DRENDERSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +#endif /* DIRECT3D_VERSION >= 0x0500 */ +} D3DRENDERSTATETYPE; + +#else + +typedef enum _D3DRENDERSTATETYPE D3DRENDERSTATETYPE; + +// +// legacy renderstate names +// +#define D3DRENDERSTATE_TEXTUREPERSPECTIVE (D3DRENDERSTATETYPE)4 +#define D3DRENDERSTATE_ZENABLE (D3DRENDERSTATETYPE)7 +#define D3DRENDERSTATE_FILLMODE (D3DRENDERSTATETYPE)8 +#define D3DRENDERSTATE_SHADEMODE (D3DRENDERSTATETYPE)9 +#define D3DRENDERSTATE_LINEPATTERN (D3DRENDERSTATETYPE)10 +#define D3DRENDERSTATE_ZWRITEENABLE (D3DRENDERSTATETYPE)14 +#define D3DRENDERSTATE_ALPHATESTENABLE (D3DRENDERSTATETYPE)15 +#define D3DRENDERSTATE_LASTPIXEL (D3DRENDERSTATETYPE)16 +#define D3DRENDERSTATE_SRCBLEND (D3DRENDERSTATETYPE)19 +#define D3DRENDERSTATE_DESTBLEND (D3DRENDERSTATETYPE)20 +#define D3DRENDERSTATE_CULLMODE (D3DRENDERSTATETYPE)22 +#define D3DRENDERSTATE_ZFUNC (D3DRENDERSTATETYPE)23 +#define D3DRENDERSTATE_ALPHAREF (D3DRENDERSTATETYPE)24 +#define D3DRENDERSTATE_ALPHAFUNC (D3DRENDERSTATETYPE)25 +#define D3DRENDERSTATE_DITHERENABLE (D3DRENDERSTATETYPE)26 +#define D3DRENDERSTATE_ALPHABLENDENABLE (D3DRENDERSTATETYPE)27 +#define D3DRENDERSTATE_FOGENABLE (D3DRENDERSTATETYPE)28 +#define D3DRENDERSTATE_SPECULARENABLE (D3DRENDERSTATETYPE)29 +#define D3DRENDERSTATE_ZVISIBLE (D3DRENDERSTATETYPE)30 +#define D3DRENDERSTATE_STIPPLEDALPHA (D3DRENDERSTATETYPE)33 +#define D3DRENDERSTATE_FOGCOLOR (D3DRENDERSTATETYPE)34 +#define D3DRENDERSTATE_FOGTABLEMODE (D3DRENDERSTATETYPE)35 +#define D3DRENDERSTATE_FOGSTART (D3DRENDERSTATETYPE)36 +#define D3DRENDERSTATE_FOGEND (D3DRENDERSTATETYPE)37 +#define D3DRENDERSTATE_FOGDENSITY (D3DRENDERSTATETYPE)38 +#define D3DRENDERSTATE_EDGEANTIALIAS (D3DRENDERSTATETYPE)40 +#define D3DRENDERSTATE_ZBIAS (D3DRENDERSTATETYPE)47 +#define D3DRENDERSTATE_RANGEFOGENABLE (D3DRENDERSTATETYPE)48 +#define D3DRENDERSTATE_STENCILENABLE (D3DRENDERSTATETYPE)52 +#define D3DRENDERSTATE_STENCILFAIL (D3DRENDERSTATETYPE)53 +#define D3DRENDERSTATE_STENCILZFAIL (D3DRENDERSTATETYPE)54 +#define D3DRENDERSTATE_STENCILPASS (D3DRENDERSTATETYPE)55 +#define D3DRENDERSTATE_STENCILFUNC (D3DRENDERSTATETYPE)56 +#define D3DRENDERSTATE_STENCILREF (D3DRENDERSTATETYPE)57 +#define D3DRENDERSTATE_STENCILMASK (D3DRENDERSTATETYPE)58 +#define D3DRENDERSTATE_STENCILWRITEMASK (D3DRENDERSTATETYPE)59 +#define D3DRENDERSTATE_TEXTUREFACTOR (D3DRENDERSTATETYPE)60 +#define D3DRENDERSTATE_WRAP0 (D3DRENDERSTATETYPE)128 +#define D3DRENDERSTATE_WRAP1 (D3DRENDERSTATETYPE)129 +#define D3DRENDERSTATE_WRAP2 (D3DRENDERSTATETYPE)130 +#define D3DRENDERSTATE_WRAP3 (D3DRENDERSTATETYPE)131 +#define D3DRENDERSTATE_WRAP4 (D3DRENDERSTATETYPE)132 +#define D3DRENDERSTATE_WRAP5 (D3DRENDERSTATETYPE)133 +#define D3DRENDERSTATE_WRAP6 (D3DRENDERSTATETYPE)134 +#define D3DRENDERSTATE_WRAP7 (D3DRENDERSTATETYPE)135 + +#define D3DRENDERSTATE_CLIPPING (D3DRENDERSTATETYPE)136 +#define D3DRENDERSTATE_LIGHTING (D3DRENDERSTATETYPE)137 +#define D3DRENDERSTATE_EXTENTS (D3DRENDERSTATETYPE)138 +#define D3DRENDERSTATE_AMBIENT (D3DRENDERSTATETYPE)139 +#define D3DRENDERSTATE_FOGVERTEXMODE (D3DRENDERSTATETYPE)140 +#define D3DRENDERSTATE_COLORVERTEX (D3DRENDERSTATETYPE)141 +#define D3DRENDERSTATE_LOCALVIEWER (D3DRENDERSTATETYPE)142 +#define D3DRENDERSTATE_NORMALIZENORMALS (D3DRENDERSTATETYPE)143 +#define D3DRENDERSTATE_COLORKEYBLENDENABLE (D3DRENDERSTATETYPE)144 +#define D3DRENDERSTATE_DIFFUSEMATERIALSOURCE (D3DRENDERSTATETYPE)145 +#define D3DRENDERSTATE_SPECULARMATERIALSOURCE (D3DRENDERSTATETYPE)146 +#define D3DRENDERSTATE_AMBIENTMATERIALSOURCE (D3DRENDERSTATETYPE)147 +#define D3DRENDERSTATE_EMISSIVEMATERIALSOURCE (D3DRENDERSTATETYPE)148 +#define D3DRENDERSTATE_VERTEXBLEND (D3DRENDERSTATETYPE)151 +#define D3DRENDERSTATE_CLIPPLANEENABLE (D3DRENDERSTATETYPE)152 + +// +// retired renderstates - not supported for DX7 interfaces +// +#define D3DRENDERSTATE_TEXTUREHANDLE (D3DRENDERSTATETYPE)1 +#define D3DRENDERSTATE_ANTIALIAS (D3DRENDERSTATETYPE)2 +#define D3DRENDERSTATE_TEXTUREADDRESS (D3DRENDERSTATETYPE)3 +#define D3DRENDERSTATE_WRAPU (D3DRENDERSTATETYPE)5 +#define D3DRENDERSTATE_WRAPV (D3DRENDERSTATETYPE)6 +#define D3DRENDERSTATE_MONOENABLE (D3DRENDERSTATETYPE)11 +#define D3DRENDERSTATE_ROP2 (D3DRENDERSTATETYPE)12 +#define D3DRENDERSTATE_PLANEMASK (D3DRENDERSTATETYPE)13 +#define D3DRENDERSTATE_TEXTUREMAG (D3DRENDERSTATETYPE)17 +#define D3DRENDERSTATE_TEXTUREMIN (D3DRENDERSTATETYPE)18 +#define D3DRENDERSTATE_TEXTUREMAPBLEND (D3DRENDERSTATETYPE)21 +#define D3DRENDERSTATE_SUBPIXEL (D3DRENDERSTATETYPE)31 +#define D3DRENDERSTATE_SUBPIXELX (D3DRENDERSTATETYPE)32 +#define D3DRENDERSTATE_STIPPLEENABLE (D3DRENDERSTATETYPE)39 +#define D3DRENDERSTATE_OLDALPHABLENDENABLE (D3DRENDERSTATETYPE)42 +#define D3DRENDERSTATE_BORDERCOLOR (D3DRENDERSTATETYPE)43 +#define D3DRENDERSTATE_TEXTUREADDRESSU (D3DRENDERSTATETYPE)44 +#define D3DRENDERSTATE_TEXTUREADDRESSV (D3DRENDERSTATETYPE)45 +#define D3DRENDERSTATE_MIPMAPLODBIAS (D3DRENDERSTATETYPE)46 +#define D3DRENDERSTATE_ANISOTROPY (D3DRENDERSTATETYPE)49 +#define D3DRENDERSTATE_FLUSHBATCH (D3DRENDERSTATETYPE)50 +#define D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT (D3DRENDERSTATETYPE)51 +#define D3DRENDERSTATE_STIPPLEPATTERN00 (D3DRENDERSTATETYPE)64 +#define D3DRENDERSTATE_STIPPLEPATTERN01 (D3DRENDERSTATETYPE)65 +#define D3DRENDERSTATE_STIPPLEPATTERN02 (D3DRENDERSTATETYPE)66 +#define D3DRENDERSTATE_STIPPLEPATTERN03 (D3DRENDERSTATETYPE)67 +#define D3DRENDERSTATE_STIPPLEPATTERN04 (D3DRENDERSTATETYPE)68 +#define D3DRENDERSTATE_STIPPLEPATTERN05 (D3DRENDERSTATETYPE)69 +#define D3DRENDERSTATE_STIPPLEPATTERN06 (D3DRENDERSTATETYPE)70 +#define D3DRENDERSTATE_STIPPLEPATTERN07 (D3DRENDERSTATETYPE)71 +#define D3DRENDERSTATE_STIPPLEPATTERN08 (D3DRENDERSTATETYPE)72 +#define D3DRENDERSTATE_STIPPLEPATTERN09 (D3DRENDERSTATETYPE)73 +#define D3DRENDERSTATE_STIPPLEPATTERN10 (D3DRENDERSTATETYPE)74 +#define D3DRENDERSTATE_STIPPLEPATTERN11 (D3DRENDERSTATETYPE)75 +#define D3DRENDERSTATE_STIPPLEPATTERN12 (D3DRENDERSTATETYPE)76 +#define D3DRENDERSTATE_STIPPLEPATTERN13 (D3DRENDERSTATETYPE)77 +#define D3DRENDERSTATE_STIPPLEPATTERN14 (D3DRENDERSTATETYPE)78 +#define D3DRENDERSTATE_STIPPLEPATTERN15 (D3DRENDERSTATETYPE)79 +#define D3DRENDERSTATE_STIPPLEPATTERN16 (D3DRENDERSTATETYPE)80 +#define D3DRENDERSTATE_STIPPLEPATTERN17 (D3DRENDERSTATETYPE)81 +#define D3DRENDERSTATE_STIPPLEPATTERN18 (D3DRENDERSTATETYPE)82 +#define D3DRENDERSTATE_STIPPLEPATTERN19 (D3DRENDERSTATETYPE)83 +#define D3DRENDERSTATE_STIPPLEPATTERN20 (D3DRENDERSTATETYPE)84 +#define D3DRENDERSTATE_STIPPLEPATTERN21 (D3DRENDERSTATETYPE)85 +#define D3DRENDERSTATE_STIPPLEPATTERN22 (D3DRENDERSTATETYPE)86 +#define D3DRENDERSTATE_STIPPLEPATTERN23 (D3DRENDERSTATETYPE)87 +#define D3DRENDERSTATE_STIPPLEPATTERN24 (D3DRENDERSTATETYPE)88 +#define D3DRENDERSTATE_STIPPLEPATTERN25 (D3DRENDERSTATETYPE)89 +#define D3DRENDERSTATE_STIPPLEPATTERN26 (D3DRENDERSTATETYPE)90 +#define D3DRENDERSTATE_STIPPLEPATTERN27 (D3DRENDERSTATETYPE)91 +#define D3DRENDERSTATE_STIPPLEPATTERN28 (D3DRENDERSTATETYPE)92 +#define D3DRENDERSTATE_STIPPLEPATTERN29 (D3DRENDERSTATETYPE)93 +#define D3DRENDERSTATE_STIPPLEPATTERN30 (D3DRENDERSTATETYPE)94 +#define D3DRENDERSTATE_STIPPLEPATTERN31 (D3DRENDERSTATETYPE)95 + +// +// retired renderstates - not supported for DX8 interfaces +// +#define D3DRENDERSTATE_COLORKEYENABLE (D3DRENDERSTATETYPE)41 +#define D3DRENDERSTATE_COLORKEYBLENDENABLE (D3DRENDERSTATETYPE)144 + +// +// retired renderstate names - the values are still used under new naming conventions +// +#define D3DRENDERSTATE_BLENDENABLE (D3DRENDERSTATETYPE)27 +#define D3DRENDERSTATE_FOGTABLESTART (D3DRENDERSTATETYPE)36 +#define D3DRENDERSTATE_FOGTABLEEND (D3DRENDERSTATETYPE)37 +#define D3DRENDERSTATE_FOGTABLEDENSITY (D3DRENDERSTATETYPE)38 + +#endif //(DIRECT3D_VERSION < 0x0800) + + +#if(DIRECT3D_VERSION < 0x0800) + +// Values for material source +typedef enum _D3DMATERIALCOLORSOURCE +{ + D3DMCS_MATERIAL = 0, // Color from material is used + D3DMCS_COLOR1 = 1, // Diffuse vertex color is used + D3DMCS_COLOR2 = 2, // Specular vertex color is used + D3DMCS_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum +} D3DMATERIALCOLORSOURCE; + + +#if(DIRECT3D_VERSION >= 0x0500) +// For back-compatibility with legacy compilations +#define D3DRENDERSTATE_BLENDENABLE D3DRENDERSTATE_ALPHABLENDENABLE +#endif /* DIRECT3D_VERSION >= 0x0500 */ + +#if(DIRECT3D_VERSION >= 0x0600) + +// Bias to apply to the texture coordinate set to apply a wrap to. +#define D3DRENDERSTATE_WRAPBIAS 128UL + +/* Flags to construct the WRAP render states */ +#define D3DWRAP_U 0x00000001L +#define D3DWRAP_V 0x00000002L + +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +#if(DIRECT3D_VERSION >= 0x0700) + +/* Flags to construct the WRAP render states for 1D thru 4D texture coordinates */ +#define D3DWRAPCOORD_0 0x00000001L // same as D3DWRAP_U +#define D3DWRAPCOORD_1 0x00000002L // same as D3DWRAP_V +#define D3DWRAPCOORD_2 0x00000004L +#define D3DWRAPCOORD_3 0x00000008L + +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +#endif //(DIRECT3D_VERSION < 0x0800) + +#define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y)) + +typedef struct _D3DSTATE { + union { +#if(DIRECT3D_VERSION < 0x0800) + D3DTRANSFORMSTATETYPE dtstTransformStateType; +#endif //(DIRECT3D_VERSION < 0x0800) + D3DLIGHTSTATETYPE dlstLightStateType; + D3DRENDERSTATETYPE drstRenderStateType; + }; + union { + DWORD dwArg[1]; + D3DVALUE dvArg[1]; + }; +} D3DSTATE, *LPD3DSTATE; + + +/* + * Operation used to load matrices + * hDstMat = hSrcMat + */ +typedef struct _D3DMATRIXLOAD { + D3DMATRIXHANDLE hDestMatrix; /* Destination matrix */ + D3DMATRIXHANDLE hSrcMatrix; /* Source matrix */ +} D3DMATRIXLOAD, *LPD3DMATRIXLOAD; + +/* + * Operation used to multiply matrices + * hDstMat = hSrcMat1 * hSrcMat2 + */ +typedef struct _D3DMATRIXMULTIPLY { + D3DMATRIXHANDLE hDestMatrix; /* Destination matrix */ + D3DMATRIXHANDLE hSrcMatrix1; /* First source matrix */ + D3DMATRIXHANDLE hSrcMatrix2; /* Second source matrix */ +} D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY; + +/* + * Operation used to transform and light vertices. + */ +typedef struct _D3DPROCESSVERTICES { + DWORD dwFlags; /* Do we transform or light or just copy? */ + WORD wStart; /* Index to first vertex in source */ + WORD wDest; /* Index to first vertex in local buffer */ + DWORD dwCount; /* Number of vertices to be processed */ + DWORD dwReserved; /* Must be zero */ +} D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES; + +#define D3DPROCESSVERTICES_TRANSFORMLIGHT 0x00000000L +#define D3DPROCESSVERTICES_TRANSFORM 0x00000001L +#define D3DPROCESSVERTICES_COPY 0x00000002L +#define D3DPROCESSVERTICES_OPMASK 0x00000007L + +#define D3DPROCESSVERTICES_UPDATEEXTENTS 0x00000008L +#define D3DPROCESSVERTICES_NOCOLOR 0x00000010L + + +#if(DIRECT3D_VERSION >= 0x0600) + + +#if(DIRECT3D_VERSION < 0x0800) + +/* + * State enumerants for per-stage texture processing. + */ +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, /* D3DVALUE (bump mapping matrix) */ + D3DTSS_BUMPENVMAT01 = 8, /* D3DVALUE (bump mapping matrix) */ + D3DTSS_BUMPENVMAT10 = 9, /* D3DVALUE (bump mapping matrix) */ + D3DTSS_BUMPENVMAT11 = 10, /* D3DVALUE (bump mapping matrix) */ + D3DTSS_TEXCOORDINDEX = 11, /* identifies which set of texture coordinates index this texture */ + D3DTSS_ADDRESS = 12, /* D3DTEXTUREADDRESS for both coordinates */ + D3DTSS_ADDRESSU = 13, /* D3DTEXTUREADDRESS for U coordinate */ + D3DTSS_ADDRESSV = 14, /* D3DTEXTUREADDRESS for V coordinate */ + D3DTSS_BORDERCOLOR = 15, /* D3DCOLOR */ + D3DTSS_MAGFILTER = 16, /* D3DTEXTUREMAGFILTER filter to use for magnification */ + D3DTSS_MINFILTER = 17, /* D3DTEXTUREMINFILTER filter to use for minification */ + D3DTSS_MIPFILTER = 18, /* D3DTEXTUREMIPFILTER filter to use between mipmaps during minification */ + D3DTSS_MIPMAPLODBIAS = 19, /* D3DVALUE Mipmap LOD bias */ + D3DTSS_MAXMIPLEVEL = 20, /* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) */ + D3DTSS_MAXANISOTROPY = 21, /* DWORD maximum anisotropy */ + D3DTSS_BUMPENVLSCALE = 22, /* D3DVALUE scale for bump map luminance */ + D3DTSS_BUMPENVLOFFSET = 23, /* D3DVALUE offset for bump map luminance */ +#if(DIRECT3D_VERSION >= 0x0700) + D3DTSS_TEXTURETRANSFORMFLAGS = 24, /* D3DTEXTURETRANSFORMFLAGS controls texture transform */ +#endif /* DIRECT3D_VERSION >= 0x0700 */ + D3DTSS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DTEXTURESTAGESTATETYPE; + +#if(DIRECT3D_VERSION >= 0x0700) +// Values, used with D3DTSS_TEXCOORDINDEX, to specify that the vertex data(position +// and normal in the camera space) should be taken as texture coordinates +// Low 16 bits are used to specify texture coordinate index, to take the WRAP mode from +// +#define D3DTSS_TCI_PASSTHRU 0x00000000 +#define D3DTSS_TCI_CAMERASPACENORMAL 0x00010000 +#define D3DTSS_TCI_CAMERASPACEPOSITION 0x00020000 +#define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR 0x00030000 +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +/* + * Enumerations for COLOROP and ALPHAOP texture blending operations set in + * texture processing stage controls in D3DRENDERSTATE. + */ +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 D3DRENDERSTATE_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, + + D3DTOP_FORCE_DWORD = 0x7fffffff, +} D3DTEXTUREOP; + +/* + * Values for COLORARG1,2 and ALPHAARG1,2 texture blending operations + * set in texture processing stage controls in D3DRENDERSTATE. + */ +#define D3DTA_SELECTMASK 0x0000000f // mask for arg selector +#define D3DTA_DIFFUSE 0x00000000 // select diffuse color +#define D3DTA_CURRENT 0x00000001 // select result of previous stage +#define D3DTA_TEXTURE 0x00000002 // select texture color +#define D3DTA_TFACTOR 0x00000003 // select RENDERSTATE_TEXTUREFACTOR +#if(DIRECT3D_VERSION >= 0x0700) +#define D3DTA_SPECULAR 0x00000004 // select specular color +#endif /* DIRECT3D_VERSION >= 0x0700 */ +#define D3DTA_COMPLEMENT 0x00000010 // take 1.0 - x +#define D3DTA_ALPHAREPLICATE 0x00000020 // replicate alpha to color components + +#endif //(DIRECT3D_VERSION < 0x0800) + +/* + * IDirect3DTexture2 State Filter Types + */ +typedef enum _D3DTEXTUREMAGFILTER +{ + D3DTFG_POINT = 1, // nearest + D3DTFG_LINEAR = 2, // linear interpolation + D3DTFG_FLATCUBIC = 3, // cubic + D3DTFG_GAUSSIANCUBIC = 4, // different cubic kernel + D3DTFG_ANISOTROPIC = 5, // +#if(DIRECT3D_VERSION >= 0x0700) +#endif /* DIRECT3D_VERSION >= 0x0700 */ + D3DTFG_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum +} D3DTEXTUREMAGFILTER; + +typedef enum _D3DTEXTUREMINFILTER +{ + D3DTFN_POINT = 1, // nearest + D3DTFN_LINEAR = 2, // linear interpolation + D3DTFN_ANISOTROPIC = 3, // + D3DTFN_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum +} D3DTEXTUREMINFILTER; + +typedef enum _D3DTEXTUREMIPFILTER +{ + D3DTFP_NONE = 1, // mipmapping disabled (use MAG filter) + D3DTFP_POINT = 2, // nearest + D3DTFP_LINEAR = 3, // linear interpolation + D3DTFP_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum +} D3DTEXTUREMIPFILTER; + +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +/* + * Triangle flags + */ + +/* + * Tri strip and fan flags. + * START loads all three vertices + * EVEN and ODD load just v3 with even or odd culling + * START_FLAT contains a count from 0 to 29 that allows the + * whole strip or fan to be culled in one hit. + * e.g. for a quad len = 1 + */ +#define D3DTRIFLAG_START 0x00000000L +#define D3DTRIFLAG_STARTFLAT(len) (len) /* 0 < len < 30 */ +#define D3DTRIFLAG_ODD 0x0000001eL +#define D3DTRIFLAG_EVEN 0x0000001fL + +/* + * Triangle edge flags + * enable edges for wireframe or antialiasing + */ +#define D3DTRIFLAG_EDGEENABLE1 0x00000100L /* v0-v1 edge */ +#define D3DTRIFLAG_EDGEENABLE2 0x00000200L /* v1-v2 edge */ +#define D3DTRIFLAG_EDGEENABLE3 0x00000400L /* v2-v0 edge */ +#define D3DTRIFLAG_EDGEENABLETRIANGLE \ + (D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3) + +/* + * Primitive structures and related defines. Vertex offsets are to types + * D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX. + */ + +/* + * Triangle list primitive structure + */ +typedef struct _D3DTRIANGLE { + union { + WORD v1; /* Vertex indices */ + WORD wV1; + }; + union { + WORD v2; + WORD wV2; + }; + union { + WORD v3; + WORD wV3; + }; + WORD wFlags; /* Edge (and other) flags */ +} D3DTRIANGLE, *LPD3DTRIANGLE; + +/* + * Line list structure. + * The instruction count defines the number of line segments. + */ +typedef struct _D3DLINE { + union { + WORD v1; /* Vertex indices */ + WORD wV1; + }; + union { + WORD v2; + WORD wV2; + }; +} D3DLINE, *LPD3DLINE; + +/* + * Span structure + * Spans join a list of points with the same y value. + * If the y value changes, a new span is started. + */ +typedef struct _D3DSPAN { + WORD wCount; /* Number of spans */ + WORD wFirst; /* Index to first vertex */ +} D3DSPAN, *LPD3DSPAN; + +/* + * Point structure + */ +typedef struct _D3DPOINT { + WORD wCount; /* number of points */ + WORD wFirst; /* index to first vertex */ +} D3DPOINT, *LPD3DPOINT; + + +/* + * Forward branch structure. + * Mask is logically anded with the driver status mask + * if the result equals 'value', the branch is taken. + */ +typedef struct _D3DBRANCH { + DWORD dwMask; /* Bitmask against D3D status */ + DWORD dwValue; + BOOL bNegate; /* TRUE to negate comparison */ + DWORD dwOffset; /* How far to branch forward (0 for exit)*/ +} D3DBRANCH, *LPD3DBRANCH; + +/* + * Status used for set status instruction. + * The D3D status is initialised on device creation + * and is modified by all execute calls. + */ +typedef struct _D3DSTATUS { + DWORD dwFlags; /* Do we set extents or status */ + DWORD dwStatus; /* D3D status */ + D3DRECT drExtent; +} D3DSTATUS, *LPD3DSTATUS; + +#define D3DSETSTATUS_STATUS 0x00000001L +#define D3DSETSTATUS_EXTENTS 0x00000002L +#define D3DSETSTATUS_ALL (D3DSETSTATUS_STATUS | D3DSETSTATUS_EXTENTS) + +#if(DIRECT3D_VERSION >= 0x0500) +typedef struct _D3DCLIPSTATUS { + DWORD dwFlags; /* Do we set 2d extents, 3D extents or status */ + DWORD dwStatus; /* Clip status */ + float minx, maxx; /* X extents */ + float miny, maxy; /* Y extents */ + float minz, maxz; /* Z extents */ +} D3DCLIPSTATUS, *LPD3DCLIPSTATUS; + +#define D3DCLIPSTATUS_STATUS 0x00000001L +#define D3DCLIPSTATUS_EXTENTS2 0x00000002L +#define D3DCLIPSTATUS_EXTENTS3 0x00000004L + +#endif /* DIRECT3D_VERSION >= 0x0500 */ +/* + * Statistics structure + */ +typedef struct _D3DSTATS { + DWORD dwSize; + DWORD dwTrianglesDrawn; + DWORD dwLinesDrawn; + DWORD dwPointsDrawn; + DWORD dwSpansDrawn; + DWORD dwVerticesProcessed; +} D3DSTATS, *LPD3DSTATS; + +/* + * Execute options. + * When calling using D3DEXECUTE_UNCLIPPED all the primitives + * inside the buffer must be contained within the viewport. + */ +#define D3DEXECUTE_CLIPPED 0x00000001l +#define D3DEXECUTE_UNCLIPPED 0x00000002l + +typedef struct _D3DEXECUTEDATA { + DWORD dwSize; + DWORD dwVertexOffset; + DWORD dwVertexCount; + DWORD dwInstructionOffset; + DWORD dwInstructionLength; + DWORD dwHVertexOffset; + D3DSTATUS dsStatus; /* Status after execute */ +} D3DEXECUTEDATA, *LPD3DEXECUTEDATA; + +/* + * Palette flags. + * This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw. + */ +#define D3DPAL_FREE 0x00 /* Renderer may use this entry freely */ +#define D3DPAL_READONLY 0x40 /* Renderer may not set this entry */ +#define D3DPAL_RESERVED 0x80 /* Renderer may not use this entry */ + + +#if(DIRECT3D_VERSION >= 0x0600) + +typedef struct _D3DVERTEXBUFFERDESC { + DWORD dwSize; + DWORD dwCaps; + DWORD dwFVF; + DWORD dwNumVertices; +} D3DVERTEXBUFFERDESC, *LPD3DVERTEXBUFFERDESC; + +#define D3DVBCAPS_SYSTEMMEMORY 0x00000800l +#define D3DVBCAPS_WRITEONLY 0x00010000l +#define D3DVBCAPS_OPTIMIZED 0x80000000l +#define D3DVBCAPS_DONOTCLIP 0x00000001l + +/* Vertex Operations for ProcessVertices */ +#define D3DVOP_LIGHT (1 << 10) +#define D3DVOP_TRANSFORM (1 << 0) +#define D3DVOP_CLIP (1 << 2) +#define D3DVOP_EXTENTS (1 << 3) + + +#if(DIRECT3D_VERSION < 0x0800) + +/* The maximum number of vertices user can pass to any d3d + drawing function or to create vertex buffer with +*/ +#define D3DMAXNUMVERTICES ((1<<16) - 1) +/* The maximum number of primitives user can pass to any d3d + drawing function. +*/ +#define D3DMAXNUMPRIMITIVES ((1<<16) - 1) + +#if(DIRECT3D_VERSION >= 0x0700) + +/* Bits for dwFlags in ProcessVertices call */ +#define D3DPV_DONOTCOPYDATA (1 << 0) + +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +#endif //(DIRECT3D_VERSION < 0x0800) + +//------------------------------------------------------------------- + +#if(DIRECT3D_VERSION < 0x0800) + +// Flexible vertex format bits +// +#define D3DFVF_RESERVED0 0x001 +#define D3DFVF_POSITION_MASK 0x00E +#define D3DFVF_XYZ 0x002 +#define D3DFVF_XYZRHW 0x004 +#if(DIRECT3D_VERSION >= 0x0700) +#define D3DFVF_XYZB1 0x006 +#define D3DFVF_XYZB2 0x008 +#define D3DFVF_XYZB3 0x00a +#define D3DFVF_XYZB4 0x00c +#define D3DFVF_XYZB5 0x00e + +#endif /* DIRECT3D_VERSION >= 0x0700 */ +#define D3DFVF_NORMAL 0x010 +#define D3DFVF_RESERVED1 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_RESERVED2 0xf000 // 4 reserved bits + +#else +#define D3DFVF_RESERVED1 0x020 +#endif //(DIRECT3D_VERSION < 0x0800) + +#define D3DFVF_VERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 ) +#define D3DFVF_LVERTEX ( D3DFVF_XYZ | D3DFVF_RESERVED1 | D3DFVF_DIFFUSE | \ + D3DFVF_SPECULAR | D3DFVF_TEX1 ) +#define D3DFVF_TLVERTEX ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | \ + D3DFVF_TEX1 ) + + +typedef struct _D3DDP_PTRSTRIDE +{ + LPVOID lpvData; + DWORD dwStride; +} D3DDP_PTRSTRIDE; + +#define D3DDP_MAXTEXCOORD 8 + +typedef struct _D3DDRAWPRIMITIVESTRIDEDDATA +{ + D3DDP_PTRSTRIDE position; + D3DDP_PTRSTRIDE normal; + D3DDP_PTRSTRIDE diffuse; + D3DDP_PTRSTRIDE specular; + D3DDP_PTRSTRIDE textureCoords[D3DDP_MAXTEXCOORD]; +} D3DDRAWPRIMITIVESTRIDEDDATA, *LPD3DDRAWPRIMITIVESTRIDEDDATA; +//--------------------------------------------------------------------- +// ComputeSphereVisibility return values +// +#define D3DVIS_INSIDE_FRUSTUM 0 +#define D3DVIS_INTERSECT_FRUSTUM 1 +#define D3DVIS_OUTSIDE_FRUSTUM 2 +#define D3DVIS_INSIDE_LEFT 0 +#define D3DVIS_INTERSECT_LEFT (1 << 2) +#define D3DVIS_OUTSIDE_LEFT (2 << 2) +#define D3DVIS_INSIDE_RIGHT 0 +#define D3DVIS_INTERSECT_RIGHT (1 << 4) +#define D3DVIS_OUTSIDE_RIGHT (2 << 4) +#define D3DVIS_INSIDE_TOP 0 +#define D3DVIS_INTERSECT_TOP (1 << 6) +#define D3DVIS_OUTSIDE_TOP (2 << 6) +#define D3DVIS_INSIDE_BOTTOM 0 +#define D3DVIS_INTERSECT_BOTTOM (1 << 8) +#define D3DVIS_OUTSIDE_BOTTOM (2 << 8) +#define D3DVIS_INSIDE_NEAR 0 +#define D3DVIS_INTERSECT_NEAR (1 << 10) +#define D3DVIS_OUTSIDE_NEAR (2 << 10) +#define D3DVIS_INSIDE_FAR 0 +#define D3DVIS_INTERSECT_FAR (1 << 12) +#define D3DVIS_OUTSIDE_FAR (2 << 12) + +#define D3DVIS_MASK_FRUSTUM (3 << 0) +#define D3DVIS_MASK_LEFT (3 << 2) +#define D3DVIS_MASK_RIGHT (3 << 4) +#define D3DVIS_MASK_TOP (3 << 6) +#define D3DVIS_MASK_BOTTOM (3 << 8) +#define D3DVIS_MASK_NEAR (3 << 10) +#define D3DVIS_MASK_FAR (3 << 12) + +#endif /* DIRECT3D_VERSION >= 0x0600 */ + +#if(DIRECT3D_VERSION < 0x0800) + +#if(DIRECT3D_VERSION >= 0x0700) + +// To be used with GetInfo() +#define D3DDEVINFOID_TEXTUREMANAGER 1 +#define D3DDEVINFOID_D3DTEXTUREMANAGER 2 +#define D3DDEVINFOID_TEXTURING 3 + +typedef enum _D3DSTATEBLOCKTYPE +{ + D3DSBT_ALL = 1, // capture all state + D3DSBT_PIXELSTATE = 2, // capture pixel state + D3DSBT_VERTEXSTATE = 3, // capture vertex state + D3DSBT_FORCE_DWORD = 0xffffffff +} D3DSTATEBLOCKTYPE; + +// The D3DVERTEXBLENDFLAGS type is used with D3DRENDERSTATE_VERTEXBLEND state. +// +typedef enum _D3DVERTEXBLENDFLAGS +{ + D3DVBLEND_DISABLE = 0, // Disable vertex blending + D3DVBLEND_1WEIGHT = 1, // blend between 2 matrices + D3DVBLEND_2WEIGHTS = 2, // blend between 3 matrices + D3DVBLEND_3WEIGHTS = 3, // blend between 4 matrices +} D3DVERTEXBLENDFLAGS; + +typedef enum _D3DTEXTURETRANSFORMFLAGS { + D3DTTFF_DISABLE = 0, // texture coordinates are passed directly + D3DTTFF_COUNT1 = 1, // rasterizer should expect 1-D texture coords + D3DTTFF_COUNT2 = 2, // rasterizer should expect 2-D texture coords + D3DTTFF_COUNT3 = 3, // rasterizer should expect 3-D texture coords + D3DTTFF_COUNT4 = 4, // rasterizer should expect 4-D texture coords + D3DTTFF_PROJECTED = 256, // texcoords to be divided by COUNTth element + D3DTTFF_FORCE_DWORD = 0x7fffffff, +} D3DTEXTURETRANSFORMFLAGS; + +// Macros to set texture coordinate format bits in the FVF id + +#define D3DFVF_TEXTUREFORMAT2 0 // Two floating point values +#define D3DFVF_TEXTUREFORMAT1 3 // One floating point value +#define D3DFVF_TEXTUREFORMAT3 1 // Three floating point values +#define D3DFVF_TEXTUREFORMAT4 2 // Four floating point values + +#define D3DFVF_TEXCOORDSIZE3(CoordIndex) (D3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16)) +#define D3DFVF_TEXCOORDSIZE2(CoordIndex) (D3DFVF_TEXTUREFORMAT2) +#define D3DFVF_TEXCOORDSIZE4(CoordIndex) (D3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16)) +#define D3DFVF_TEXCOORDSIZE1(CoordIndex) (D3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16)) + + +#endif /* DIRECT3D_VERSION >= 0x0700 */ + +#else +// +// legacy vertex blend names +// +typedef enum _D3DVERTEXBLENDFLAGS D3DVERTEXBLENDFLAGS; +#define D3DVBLEND_DISABLE (D3DVERTEXBLENDFLAGS)0 +#define D3DVBLEND_1WEIGHT (D3DVERTEXBLENDFLAGS)1 +#define D3DVBLEND_2WEIGHTS (D3DVERTEXBLENDFLAGS)2 +#define D3DVBLEND_3WEIGHTS (D3DVERTEXBLENDFLAGS)3 + +#endif //(DIRECT3D_VERSION < 0x0800) + +#pragma pack() +#pragma warning(default:4201) + +#endif /* _D3DTYPES_H_ */ + diff --git a/src/dep/include/DXSDK/include/d3dvec.inl b/src/dep/include/DXSDK/include/d3dvec.inl index b9d6db7..ff7fdfe 100644 --- a/src/dep/include/DXSDK/include/d3dvec.inl +++ b/src/dep/include/DXSDK/include/d3dvec.inl @@ -1,255 +1,255 @@ - -/****************************************************************** - * * - * D3DVec.inl * - * * - * Float-valued 3D vector class for Direct3D. * - * * - * Copyright (c) Microsoft Corp. All rights reserved. * - * * - ******************************************************************/ - -#include - -// ===================================== -// Constructors -// ===================================== - -inline -_D3DVECTOR::_D3DVECTOR(D3DVALUE f) -{ - x = y = z = f; -} - -inline -_D3DVECTOR::_D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z) -{ - x = _x; y = _y; z = _z; -} - -inline -_D3DVECTOR::_D3DVECTOR(const D3DVALUE f[3]) -{ - x = f[0]; y = f[1]; z = f[2]; -} - -// ===================================== -// Access grants -// ===================================== - -inline const D3DVALUE& -_D3DVECTOR::operator[](int i) const -{ - return (&x)[i]; -} - -inline D3DVALUE& -_D3DVECTOR::operator[](int i) -{ - return (&x)[i]; -} - - -// ===================================== -// Assignment operators -// ===================================== - -inline _D3DVECTOR& -_D3DVECTOR::operator += (const _D3DVECTOR& v) -{ - x += v.x; y += v.y; z += v.z; - return *this; -} - -inline _D3DVECTOR& -_D3DVECTOR::operator -= (const _D3DVECTOR& v) -{ - x -= v.x; y -= v.y; z -= v.z; - return *this; -} - -inline _D3DVECTOR& -_D3DVECTOR::operator *= (const _D3DVECTOR& v) -{ - x *= v.x; y *= v.y; z *= v.z; - return *this; -} - -inline _D3DVECTOR& -_D3DVECTOR::operator /= (const _D3DVECTOR& v) -{ - x /= v.x; y /= v.y; z /= v.z; - return *this; -} - -inline _D3DVECTOR& -_D3DVECTOR::operator *= (D3DVALUE s) -{ - x *= s; y *= s; z *= s; - return *this; -} - -inline _D3DVECTOR& -_D3DVECTOR::operator /= (D3DVALUE s) -{ - x /= s; y /= s; z /= s; - return *this; -} - -inline _D3DVECTOR -operator + (const _D3DVECTOR& v) -{ - return v; -} - -inline _D3DVECTOR -operator - (const _D3DVECTOR& v) -{ - return _D3DVECTOR(-v.x, -v.y, -v.z); -} - -inline _D3DVECTOR -operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2) -{ - return _D3DVECTOR(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z); -} - -inline _D3DVECTOR -operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2) -{ - return _D3DVECTOR(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z); -} - -inline _D3DVECTOR -operator * (const _D3DVECTOR& v1, const _D3DVECTOR& v2) -{ - return _D3DVECTOR(v1.x*v2.x, v1.y*v2.y, v1.z*v2.z); -} - -inline _D3DVECTOR -operator / (const _D3DVECTOR& v1, const _D3DVECTOR& v2) -{ - return _D3DVECTOR(v1.x/v2.x, v1.y/v2.y, v1.z/v2.z); -} - -inline int -operator < (const _D3DVECTOR& v1, const _D3DVECTOR& v2) -{ - return v1[0] < v2[0] && v1[1] < v2[1] && v1[2] < v2[2]; -} - -inline int -operator <= (const _D3DVECTOR& v1, const _D3DVECTOR& v2) -{ - return v1[0] <= v2[0] && v1[1] <= v2[1] && v1[2] <= v2[2]; -} - -inline _D3DVECTOR -operator * (const _D3DVECTOR& v, D3DVALUE s) -{ - return _D3DVECTOR(s*v.x, s*v.y, s*v.z); -} - -inline _D3DVECTOR -operator * (D3DVALUE s, const _D3DVECTOR& v) -{ - return _D3DVECTOR(s*v.x, s*v.y, s*v.z); -} - -inline _D3DVECTOR -operator / (const _D3DVECTOR& v, D3DVALUE s) -{ - return _D3DVECTOR(v.x/s, v.y/s, v.z/s); -} - -inline int -operator == (const _D3DVECTOR& v1, const _D3DVECTOR& v2) -{ - return v1.x==v2.x && v1.y==v2.y && v1.z == v2.z; -} - -inline D3DVALUE -Magnitude (const _D3DVECTOR& v) -{ - return (D3DVALUE) sqrt(SquareMagnitude(v)); -} - -inline D3DVALUE -SquareMagnitude (const _D3DVECTOR& v) -{ - return v.x*v.x + v.y*v.y + v.z*v.z; -} - -inline _D3DVECTOR -Normalize (const _D3DVECTOR& v) -{ - return v / Magnitude(v); -} - -inline D3DVALUE -Min (const _D3DVECTOR& v) -{ - D3DVALUE ret = v.x; - if (v.y < ret) ret = v.y; - if (v.z < ret) ret = v.z; - return ret; -} - -inline D3DVALUE -Max (const _D3DVECTOR& v) -{ - D3DVALUE ret = v.x; - if (ret < v.y) ret = v.y; - if (ret < v.z) ret = v.z; - return ret; -} - -inline _D3DVECTOR -Minimize (const _D3DVECTOR& v1, const _D3DVECTOR& v2) -{ - return _D3DVECTOR( v1[0] < v2[0] ? v1[0] : v2[0], - v1[1] < v2[1] ? v1[1] : v2[1], - v1[2] < v2[2] ? v1[2] : v2[2]); -} - -inline _D3DVECTOR -Maximize (const _D3DVECTOR& v1, const _D3DVECTOR& v2) -{ - return _D3DVECTOR( v1[0] > v2[0] ? v1[0] : v2[0], - v1[1] > v2[1] ? v1[1] : v2[1], - v1[2] > v2[2] ? v1[2] : v2[2]); -} - -inline D3DVALUE -DotProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2) -{ - return v1.x*v2.x + v1.y * v2.y + v1.z*v2.z; -} - -inline _D3DVECTOR -CrossProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2) -{ - _D3DVECTOR result; - - result[0] = v1[1] * v2[2] - v1[2] * v2[1]; - result[1] = v1[2] * v2[0] - v1[0] * v2[2]; - result[2] = v1[0] * v2[1] - v1[1] * v2[0]; - - return result; -} - -inline _D3DMATRIX -operator* (const _D3DMATRIX& a, const _D3DMATRIX& b) -{ - _D3DMATRIX ret; - for (int i=0; i<4; i++) { - for (int j=0; j<4; j++) { - ret(i, j) = 0.0f; - for (int k=0; k<4; k++) { - ret(i, j) += a(i, k) * b(k, j); - } - } - } - return ret; -} - + +/****************************************************************** + * * + * D3DVec.inl * + * * + * Float-valued 3D vector class for Direct3D. * + * * + * Copyright (c) Microsoft Corp. All rights reserved. * + * * + ******************************************************************/ + +#include + +// ===================================== +// Constructors +// ===================================== + +inline +_D3DVECTOR::_D3DVECTOR(D3DVALUE f) +{ + x = y = z = f; +} + +inline +_D3DVECTOR::_D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z) +{ + x = _x; y = _y; z = _z; +} + +inline +_D3DVECTOR::_D3DVECTOR(const D3DVALUE f[3]) +{ + x = f[0]; y = f[1]; z = f[2]; +} + +// ===================================== +// Access grants +// ===================================== + +inline const D3DVALUE& +_D3DVECTOR::operator[](int i) const +{ + return (&x)[i]; +} + +inline D3DVALUE& +_D3DVECTOR::operator[](int i) +{ + return (&x)[i]; +} + + +// ===================================== +// Assignment operators +// ===================================== + +inline _D3DVECTOR& +_D3DVECTOR::operator += (const _D3DVECTOR& v) +{ + x += v.x; y += v.y; z += v.z; + return *this; +} + +inline _D3DVECTOR& +_D3DVECTOR::operator -= (const _D3DVECTOR& v) +{ + x -= v.x; y -= v.y; z -= v.z; + return *this; +} + +inline _D3DVECTOR& +_D3DVECTOR::operator *= (const _D3DVECTOR& v) +{ + x *= v.x; y *= v.y; z *= v.z; + return *this; +} + +inline _D3DVECTOR& +_D3DVECTOR::operator /= (const _D3DVECTOR& v) +{ + x /= v.x; y /= v.y; z /= v.z; + return *this; +} + +inline _D3DVECTOR& +_D3DVECTOR::operator *= (D3DVALUE s) +{ + x *= s; y *= s; z *= s; + return *this; +} + +inline _D3DVECTOR& +_D3DVECTOR::operator /= (D3DVALUE s) +{ + x /= s; y /= s; z /= s; + return *this; +} + +inline _D3DVECTOR +operator + (const _D3DVECTOR& v) +{ + return v; +} + +inline _D3DVECTOR +operator - (const _D3DVECTOR& v) +{ + return _D3DVECTOR(-v.x, -v.y, -v.z); +} + +inline _D3DVECTOR +operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + return _D3DVECTOR(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z); +} + +inline _D3DVECTOR +operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + return _D3DVECTOR(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z); +} + +inline _D3DVECTOR +operator * (const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + return _D3DVECTOR(v1.x*v2.x, v1.y*v2.y, v1.z*v2.z); +} + +inline _D3DVECTOR +operator / (const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + return _D3DVECTOR(v1.x/v2.x, v1.y/v2.y, v1.z/v2.z); +} + +inline int +operator < (const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + return v1[0] < v2[0] && v1[1] < v2[1] && v1[2] < v2[2]; +} + +inline int +operator <= (const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + return v1[0] <= v2[0] && v1[1] <= v2[1] && v1[2] <= v2[2]; +} + +inline _D3DVECTOR +operator * (const _D3DVECTOR& v, D3DVALUE s) +{ + return _D3DVECTOR(s*v.x, s*v.y, s*v.z); +} + +inline _D3DVECTOR +operator * (D3DVALUE s, const _D3DVECTOR& v) +{ + return _D3DVECTOR(s*v.x, s*v.y, s*v.z); +} + +inline _D3DVECTOR +operator / (const _D3DVECTOR& v, D3DVALUE s) +{ + return _D3DVECTOR(v.x/s, v.y/s, v.z/s); +} + +inline int +operator == (const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + return v1.x==v2.x && v1.y==v2.y && v1.z == v2.z; +} + +inline D3DVALUE +Magnitude (const _D3DVECTOR& v) +{ + return (D3DVALUE) sqrt(SquareMagnitude(v)); +} + +inline D3DVALUE +SquareMagnitude (const _D3DVECTOR& v) +{ + return v.x*v.x + v.y*v.y + v.z*v.z; +} + +inline _D3DVECTOR +Normalize (const _D3DVECTOR& v) +{ + return v / Magnitude(v); +} + +inline D3DVALUE +Min (const _D3DVECTOR& v) +{ + D3DVALUE ret = v.x; + if (v.y < ret) ret = v.y; + if (v.z < ret) ret = v.z; + return ret; +} + +inline D3DVALUE +Max (const _D3DVECTOR& v) +{ + D3DVALUE ret = v.x; + if (ret < v.y) ret = v.y; + if (ret < v.z) ret = v.z; + return ret; +} + +inline _D3DVECTOR +Minimize (const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + return _D3DVECTOR( v1[0] < v2[0] ? v1[0] : v2[0], + v1[1] < v2[1] ? v1[1] : v2[1], + v1[2] < v2[2] ? v1[2] : v2[2]); +} + +inline _D3DVECTOR +Maximize (const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + return _D3DVECTOR( v1[0] > v2[0] ? v1[0] : v2[0], + v1[1] > v2[1] ? v1[1] : v2[1], + v1[2] > v2[2] ? v1[2] : v2[2]); +} + +inline D3DVALUE +DotProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + return v1.x*v2.x + v1.y * v2.y + v1.z*v2.z; +} + +inline _D3DVECTOR +CrossProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + _D3DVECTOR result; + + result[0] = v1[1] * v2[2] - v1[2] * v2[1]; + result[1] = v1[2] * v2[0] - v1[0] * v2[2]; + result[2] = v1[0] * v2[1] - v1[1] * v2[0]; + + return result; +} + +inline _D3DMATRIX +operator* (const _D3DMATRIX& a, const _D3DMATRIX& b) +{ + _D3DMATRIX ret; + for (int i=0; i<4; i++) { + for (int j=0; j<4; j++) { + ret(i, j) = 0.0f; + for (int k=0; k<4; k++) { + ret(i, j) += a(i, k) * b(k, j); + } + } + } + return ret; +} + diff --git a/src/dep/include/DXSDK/include/d3dx.h b/src/dep/include/DXSDK/include/d3dx.h index ac5cd2f..7a511e3 100644 --- a/src/dep/include/DXSDK/include/d3dx.h +++ b/src/dep/include/DXSDK/include/d3dx.h @@ -1,26 +1,26 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx.h -// Content: D3DX utility library -// -/////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DX_H__ -#define __D3DX_H__ - -#ifndef D3DXINLINE -#ifdef __cplusplus -#define D3DXINLINE inline -#else -#define D3DXINLINE _inline -#endif -#endif - -#include "d3dxcore.h" -#include "d3dxmath.h" -#include "d3dxshapes.h" -#include "d3dxsprite.h" - -#endif //__D3DX_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx.h +// Content: D3DX utility library +// +/////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DX_H__ +#define __D3DX_H__ + +#ifndef D3DXINLINE +#ifdef __cplusplus +#define D3DXINLINE inline +#else +#define D3DXINLINE _inline +#endif +#endif + +#include "d3dxcore.h" +#include "d3dxmath.h" +#include "d3dxshapes.h" +#include "d3dxsprite.h" + +#endif //__D3DX_H__ diff --git a/src/dep/include/DXSDK/include/d3dx10async.h b/src/dep/include/DXSDK/include/d3dx10async.h index fa754f0..227eaf1 100644 --- a/src/dep/include/DXSDK/include/d3dx10async.h +++ b/src/dep/include/DXSDK/include/d3dx10async.h @@ -1,280 +1,280 @@ - -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// File: D3DX10Effect.h -// Content: D3DX10 Effect / Shader loaders -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DX10EFFECT_H__ -#define __D3DX10EFFECT_H__ - -#include "d3dx10.h" - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -//---------------------------------------------------------------------------- -// D3DX10CompileShader: -// ------------------ -// Compiles a shader. -// -// Parameters: -// pSrcFile -// Source file name. -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module. -// pSrcData -// Pointer to source code. -// SrcDataLen -// Size of source code, in bytes. -// pDefines -// Optional NULL-terminated array of preprocessor macro definitions. -// pInclude -// Optional interface pointer to use for handling #include directives. -// If this parameter is NULL, #includes will be honored when compiling -// from file, and will error when compiling from resource or memory. -// pFunctionName -// Name of the entrypoint function where execution should begin. -// pProfile -// Instruction set to be used when generating code. Currently supported -// profiles are "vs_1_1", "vs_2_0", "vs_2_a", "vs_2_sw", "ps_1_1", -// "ps_1_2", "ps_1_3", "ps_1_4", "ps_2_0", "ps_2_a", "ps_2_sw", "tx_1_0" -// Flags -// See D3D10_SHADER_xxx flags. -// ppShader -// Returns a buffer containing the created shader. This buffer contains -// the compiled shader code, as well as any embedded debug and symbol -// table info. (See D3D10GetShaderConstantTable) -// ppErrorMsgs -// Returns a buffer containing a listing of errors and warnings that were -// encountered during the compile. If you are running in a debugger, -// these are the same messages you will see in your debug output. -//---------------------------------------------------------------------------- - -HRESULT WINAPI D3DX10CompileShaderFromFileA(LPCSTR pSrcFile,CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, - LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs); - -HRESULT WINAPI D3DX10CompileShaderFromFileW(LPCWSTR pSrcFile, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, - LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs); - -#ifdef UNICODE -#define D3DX10CompileShaderFromFile D3DX10CompileShaderFromFileW -#else -#define D3DX10CompileShaderFromFile D3DX10CompileShaderFromFileA -#endif - -HRESULT WINAPI D3DX10CompileShaderFromResourceA(HMODULE hSrcModule, LPCSTR pSrcResource, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO* pDefines, - LPD3D10INCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs); - -HRESULT WINAPI D3DX10CompileShaderFromResourceW(HMODULE hSrcModule, LPCWSTR pSrcResource, LPCWSTR pSrcFileName, CONST D3D10_SHADER_MACRO* pDefines, - LPD3D10INCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs); - -#ifdef UNICODE -#define D3DX10CompileShaderFromResource D3DX10CompileShaderFromResourceW -#else -#define D3DX10CompileShaderFromResource D3DX10CompileShaderFromResourceA -#endif - -HRESULT WINAPI D3DX10CompileShaderFromMemory(LPCSTR pSrcData, SIZE_T SrcDataLen, LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, - LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs); - -//---------------------------------------------------------------------------- -// D3D10CreateEffectFromXXXX: -// -------------------------- -// Creates an effect from a binary effect or file -// -// Parameters: -// -// [in] -// -// TODO: Unicode support -// TODO: Support for binary (and not just ASCII) -// -// pFileName -// Name of the ASCII (uncompiled) or binary (compiled) Effect file to load -// -// hModule -// Handle to the module containing the resource to compile from -// pResourceName -// Name of the resource within hModule to compile from -// -// pData -// Blob of effect data, either ASCII (uncompiled) or binary (compiled) -// DataLength -// Length of the data blob -// -// pDefines -// Optional NULL-terminated array of preprocessor macro definitions. -// pInclude -// Optional interface pointer to use for handling #include directives. -// If this parameter is NULL, #includes will be honored when compiling -// from file, and will error when compiling from resource or memory. -// HLSLFlags -// Compilation flags pertaining to shaders and data types, honored by -// the HLSL compiler -// FXFlags -// Compilation flags pertaining to Effect compilation, honored -// by the Effect compiler -// pDevice -// Pointer to the D3D10 device on which to create Effect resources -// pEffectPool -// Pointer to an Effect pool to share variables with or NULL -// -// [out] -// -// ppEffect -// Address of the newly created Effect interface -// ppEffectPool -// Address of the newly created Effect pool interface -// ppErrors -// If non-NULL, address of a buffer with error messages that occurred -// during parsing or compilation -// -//---------------------------------------------------------------------------- - - -HRESULT WINAPI D3DX10CompileEffectFromFileA(LPCSTR pFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3DX10ThreadPump* pPump, - ID3D10Blob **ppCompiledEffect, ID3D10Blob **ppErrors); - -HRESULT WINAPI D3DX10CompileEffectFromFileW(LPCWSTR pFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3DX10ThreadPump* pPump, - ID3D10Blob **ppCompiledEffect, ID3D10Blob **ppErrors); - -HRESULT WINAPI D3DX10CompileEffectFromMemory(LPCVOID pData, SIZE_T DataLength, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, - ID3DX10ThreadPump* pPump, ID3D10Blob **ppCompiledEffect, ID3D10Blob **ppErrors); - -HRESULT WINAPI D3DX10CompileEffectFromResourceA(HMODULE hModule, LPCSTR pResourceName, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, - ID3DX10ThreadPump* pPump, ID3D10Blob **ppCompiledEffect, ID3D10Blob **ppErrors); - -HRESULT WINAPI D3DX10CompileEffectFromResourceW(HMODULE hModule, LPCWSTR pResourceName, LPCWSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, - ID3DX10ThreadPump* pPump, ID3D10Blob **ppCompiledEffect, ID3D10Blob **ppErrors); - -#ifdef UNICODE -#define D3DX10CompileEffectFromFile D3DX10CompileEffectFromFileW -#define D3DX10CompileEffectFromResource D3DX10CompileEffectFromResourceW -#else -#define D3DX10CompileEffectFromFile D3DX10CompileEffectFromFileA -#define D3DX10CompileEffectFromResource D3DX10CompileEffectFromResourceA -#endif - -HRESULT WINAPI D3DX10CreateEffectFromFileA(LPCSTR pFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, - ID3D10EffectPool *pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect **ppEffect, ID3D10Blob **ppErrors); - -HRESULT WINAPI D3DX10CreateEffectFromFileW(LPCWSTR pFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, - ID3D10EffectPool *pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect **ppEffect, ID3D10Blob **ppErrors); - -HRESULT WINAPI D3DX10CreateEffectFromMemory(LPCVOID pData, SIZE_T DataLength, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, - ID3D10EffectPool *pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect **ppEffect, ID3D10Blob **ppErrors); - -HRESULT WINAPI D3DX10CreateEffectFromResourceA(HMODULE hModule, LPCSTR pResourceName, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, - ID3D10EffectPool *pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect **ppEffect, ID3D10Blob **ppErrors); - -HRESULT WINAPI D3DX10CreateEffectFromResourceW(HMODULE hModule, LPCWSTR pResourceName, LPCWSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, - ID3D10EffectPool *pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect **ppEffect, ID3D10Blob **ppErrors); - - -#ifdef UNICODE -#define D3DX10CreateEffectFromFile D3DX10CreateEffectFromFileW -#define D3DX10CreateEffectFromResource D3DX10CreateEffectFromResourceW -#else -#define D3DX10CreateEffectFromFile D3DX10CreateEffectFromFileA -#define D3DX10CreateEffectFromResource D3DX10CreateEffectFromResourceA -#endif - -HRESULT WINAPI D3DX10CreateEffectPoolFromFileA(LPCSTR pFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, ID3DX10ThreadPump* pPump, - ID3D10EffectPool **ppEffectPool, ID3D10Blob **ppErrors); - -HRESULT WINAPI D3DX10CreateEffectPoolFromFileW(LPCWSTR pFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, ID3DX10ThreadPump* pPump, - ID3D10EffectPool **ppEffectPool, ID3D10Blob **ppErrors); - -HRESULT WINAPI D3DX10CreateEffectPoolFromMemory(LPCVOID pData, SIZE_T DataLength, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, - ID3DX10ThreadPump* pPump, ID3D10EffectPool **ppEffectPool, ID3D10Blob **ppErrors); - -HRESULT WINAPI D3DX10CreateEffectPoolFromResourceA(HMODULE hModule, LPCSTR pResourceName, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, - ID3DX10ThreadPump* pPump, ID3D10EffectPool **ppEffectPool, ID3D10Blob **ppErrors); - -HRESULT WINAPI D3DX10CreateEffectPoolFromResourceW(HMODULE hModule, LPCWSTR pResourceName, LPCWSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, - ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, - ID3DX10ThreadPump* pPump, ID3D10EffectPool **ppEffectPool, ID3D10Blob **ppErrors); - -#ifdef UNICODE -#define D3DX10CreateEffectPoolFromFile D3DX10CreateEffectPoolFromFileW -#define D3DX10CreateEffectPoolFromResource D3DX10CreateEffectPoolFromResourceW -#else -#define D3DX10CreateEffectPoolFromFile D3DX10CreateEffectPoolFromFileA -#define D3DX10CreateEffectPoolFromResource D3DX10CreateEffectPoolFromResourceA -#endif - -HRESULT WINAPI D3DX10PreprocessShaderFromFileA(LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, - LPD3D10INCLUDE pInclude, ID3DX10ThreadPump *pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs); - -HRESULT WINAPI D3DX10PreprocessShaderFromFileW(LPCWSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, - LPD3D10INCLUDE pInclude, ID3DX10ThreadPump *pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs); - -HRESULT WINAPI D3DX10PreprocessShaderFromMemory(LPCSTR pSrcData, SIZE_T SrcDataSize, LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, - LPD3D10INCLUDE pInclude, ID3DX10ThreadPump *pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs); - -HRESULT WINAPI D3DX10PreprocessShaderFromResourceA(HMODULE hModule, LPCSTR pResourceName, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO* pDefines, - LPD3D10INCLUDE pInclude, ID3DX10ThreadPump *pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs); - -HRESULT WINAPI D3DX10PreprocessShaderFromResourceW(HMODULE hModule, LPCWSTR pResourceName, LPCWSTR pSrcFileName, CONST D3D10_SHADER_MACRO* pDefines, - LPD3D10INCLUDE pInclude, ID3DX10ThreadPump *pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs); - -#ifdef UNICODE -#define D3DX10PreprocessShaderFromFile D3DX10PreprocessShaderFromFileW -#define D3DX10PreprocessShaderFromResource D3DX10PreprocessShaderFromResourceW -#else -#define D3DX10PreprocessShaderFromFile D3DX10PreprocessShaderFromFileA -#define D3DX10PreprocessShaderFromResource D3DX10PreprocessShaderFromResourceA -#endif - -//---------------------------------------------------------------------------- -// Async processors -//---------------------------------------------------------------------------- - -HRESULT WINAPI D3DX10CreateAsyncShaderCompilerProcessor(LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, - LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, - ID3D10Blob **ppCompiledShader, ID3D10Blob **ppErrorBuffer, ID3DX10DataProcessor **ppProcessor); - -HRESULT WINAPI D3DX10CreateAsyncEffectCompilerProcessor(LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, - UINT Flags, UINT FXFlags, - ID3D10Blob **ppCompiledShader, ID3D10Blob **ppErrorBuffer, ID3DX10DataProcessor **ppProcessor); - -HRESULT WINAPI D3DX10CreateAsyncEffectCreateProcessor(LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, - UINT Flags, UINT FXFlags, ID3D10Device *pDevice, - ID3D10EffectPool *pPool, ID3D10Blob **ppErrorBuffer, ID3DX10DataProcessor **ppProcessor); - -HRESULT WINAPI D3DX10CreateAsyncEffectPoolCreateProcessor(LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, - UINT Flags, UINT FXFlags, ID3D10Device *pDevice, - ID3D10Blob **ppErrorBuffer, ID3DX10DataProcessor **ppProcessor); - -HRESULT WINAPI D3DX10CreateAsyncShaderPreprocessProcessor(LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, - ID3D10Blob** ppShaderText, ID3D10Blob **ppErrorBuffer, ID3DX10DataProcessor **ppProcessor); - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3D10EFFECT_H__ - - + +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// File: D3DX10Effect.h +// Content: D3DX10 Effect / Shader loaders +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DX10EFFECT_H__ +#define __D3DX10EFFECT_H__ + +#include "d3dx10.h" + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +//---------------------------------------------------------------------------- +// D3DX10CompileShader: +// ------------------ +// Compiles a shader. +// +// Parameters: +// pSrcFile +// Source file name. +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module. +// pSrcData +// Pointer to source code. +// SrcDataLen +// Size of source code, in bytes. +// pDefines +// Optional NULL-terminated array of preprocessor macro definitions. +// pInclude +// Optional interface pointer to use for handling #include directives. +// If this parameter is NULL, #includes will be honored when compiling +// from file, and will error when compiling from resource or memory. +// pFunctionName +// Name of the entrypoint function where execution should begin. +// pProfile +// Instruction set to be used when generating code. Currently supported +// profiles are "vs_1_1", "vs_2_0", "vs_2_a", "vs_2_sw", "ps_1_1", +// "ps_1_2", "ps_1_3", "ps_1_4", "ps_2_0", "ps_2_a", "ps_2_sw", "tx_1_0" +// Flags +// See D3D10_SHADER_xxx flags. +// ppShader +// Returns a buffer containing the created shader. This buffer contains +// the compiled shader code, as well as any embedded debug and symbol +// table info. (See D3D10GetShaderConstantTable) +// ppErrorMsgs +// Returns a buffer containing a listing of errors and warnings that were +// encountered during the compile. If you are running in a debugger, +// these are the same messages you will see in your debug output. +//---------------------------------------------------------------------------- + +HRESULT WINAPI D3DX10CompileShaderFromFileA(LPCSTR pSrcFile,CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, + LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs); + +HRESULT WINAPI D3DX10CompileShaderFromFileW(LPCWSTR pSrcFile, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, + LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs); + +#ifdef UNICODE +#define D3DX10CompileShaderFromFile D3DX10CompileShaderFromFileW +#else +#define D3DX10CompileShaderFromFile D3DX10CompileShaderFromFileA +#endif + +HRESULT WINAPI D3DX10CompileShaderFromResourceA(HMODULE hSrcModule, LPCSTR pSrcResource, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO* pDefines, + LPD3D10INCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs); + +HRESULT WINAPI D3DX10CompileShaderFromResourceW(HMODULE hSrcModule, LPCWSTR pSrcResource, LPCWSTR pSrcFileName, CONST D3D10_SHADER_MACRO* pDefines, + LPD3D10INCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs); + +#ifdef UNICODE +#define D3DX10CompileShaderFromResource D3DX10CompileShaderFromResourceW +#else +#define D3DX10CompileShaderFromResource D3DX10CompileShaderFromResourceA +#endif + +HRESULT WINAPI D3DX10CompileShaderFromMemory(LPCSTR pSrcData, SIZE_T SrcDataLen, LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, + LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs); + +//---------------------------------------------------------------------------- +// D3D10CreateEffectFromXXXX: +// -------------------------- +// Creates an effect from a binary effect or file +// +// Parameters: +// +// [in] +// +// TODO: Unicode support +// TODO: Support for binary (and not just ASCII) +// +// pFileName +// Name of the ASCII (uncompiled) or binary (compiled) Effect file to load +// +// hModule +// Handle to the module containing the resource to compile from +// pResourceName +// Name of the resource within hModule to compile from +// +// pData +// Blob of effect data, either ASCII (uncompiled) or binary (compiled) +// DataLength +// Length of the data blob +// +// pDefines +// Optional NULL-terminated array of preprocessor macro definitions. +// pInclude +// Optional interface pointer to use for handling #include directives. +// If this parameter is NULL, #includes will be honored when compiling +// from file, and will error when compiling from resource or memory. +// HLSLFlags +// Compilation flags pertaining to shaders and data types, honored by +// the HLSL compiler +// FXFlags +// Compilation flags pertaining to Effect compilation, honored +// by the Effect compiler +// pDevice +// Pointer to the D3D10 device on which to create Effect resources +// pEffectPool +// Pointer to an Effect pool to share variables with or NULL +// +// [out] +// +// ppEffect +// Address of the newly created Effect interface +// ppEffectPool +// Address of the newly created Effect pool interface +// ppErrors +// If non-NULL, address of a buffer with error messages that occurred +// during parsing or compilation +// +//---------------------------------------------------------------------------- + + +HRESULT WINAPI D3DX10CompileEffectFromFileA(LPCSTR pFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3DX10ThreadPump* pPump, + ID3D10Blob **ppCompiledEffect, ID3D10Blob **ppErrors); + +HRESULT WINAPI D3DX10CompileEffectFromFileW(LPCWSTR pFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3DX10ThreadPump* pPump, + ID3D10Blob **ppCompiledEffect, ID3D10Blob **ppErrors); + +HRESULT WINAPI D3DX10CompileEffectFromMemory(LPCVOID pData, SIZE_T DataLength, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, + ID3DX10ThreadPump* pPump, ID3D10Blob **ppCompiledEffect, ID3D10Blob **ppErrors); + +HRESULT WINAPI D3DX10CompileEffectFromResourceA(HMODULE hModule, LPCSTR pResourceName, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, + ID3DX10ThreadPump* pPump, ID3D10Blob **ppCompiledEffect, ID3D10Blob **ppErrors); + +HRESULT WINAPI D3DX10CompileEffectFromResourceW(HMODULE hModule, LPCWSTR pResourceName, LPCWSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, + ID3DX10ThreadPump* pPump, ID3D10Blob **ppCompiledEffect, ID3D10Blob **ppErrors); + +#ifdef UNICODE +#define D3DX10CompileEffectFromFile D3DX10CompileEffectFromFileW +#define D3DX10CompileEffectFromResource D3DX10CompileEffectFromResourceW +#else +#define D3DX10CompileEffectFromFile D3DX10CompileEffectFromFileA +#define D3DX10CompileEffectFromResource D3DX10CompileEffectFromResourceA +#endif + +HRESULT WINAPI D3DX10CreateEffectFromFileA(LPCSTR pFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, + ID3D10EffectPool *pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect **ppEffect, ID3D10Blob **ppErrors); + +HRESULT WINAPI D3DX10CreateEffectFromFileW(LPCWSTR pFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, + ID3D10EffectPool *pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect **ppEffect, ID3D10Blob **ppErrors); + +HRESULT WINAPI D3DX10CreateEffectFromMemory(LPCVOID pData, SIZE_T DataLength, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, + ID3D10EffectPool *pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect **ppEffect, ID3D10Blob **ppErrors); + +HRESULT WINAPI D3DX10CreateEffectFromResourceA(HMODULE hModule, LPCSTR pResourceName, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, + ID3D10EffectPool *pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect **ppEffect, ID3D10Blob **ppErrors); + +HRESULT WINAPI D3DX10CreateEffectFromResourceW(HMODULE hModule, LPCWSTR pResourceName, LPCWSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, + ID3D10EffectPool *pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect **ppEffect, ID3D10Blob **ppErrors); + + +#ifdef UNICODE +#define D3DX10CreateEffectFromFile D3DX10CreateEffectFromFileW +#define D3DX10CreateEffectFromResource D3DX10CreateEffectFromResourceW +#else +#define D3DX10CreateEffectFromFile D3DX10CreateEffectFromFileA +#define D3DX10CreateEffectFromResource D3DX10CreateEffectFromResourceA +#endif + +HRESULT WINAPI D3DX10CreateEffectPoolFromFileA(LPCSTR pFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, ID3DX10ThreadPump* pPump, + ID3D10EffectPool **ppEffectPool, ID3D10Blob **ppErrors); + +HRESULT WINAPI D3DX10CreateEffectPoolFromFileW(LPCWSTR pFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, ID3DX10ThreadPump* pPump, + ID3D10EffectPool **ppEffectPool, ID3D10Blob **ppErrors); + +HRESULT WINAPI D3DX10CreateEffectPoolFromMemory(LPCVOID pData, SIZE_T DataLength, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, + ID3DX10ThreadPump* pPump, ID3D10EffectPool **ppEffectPool, ID3D10Blob **ppErrors); + +HRESULT WINAPI D3DX10CreateEffectPoolFromResourceA(HMODULE hModule, LPCSTR pResourceName, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, + ID3DX10ThreadPump* pPump, ID3D10EffectPool **ppEffectPool, ID3D10Blob **ppErrors); + +HRESULT WINAPI D3DX10CreateEffectPoolFromResourceW(HMODULE hModule, LPCWSTR pResourceName, LPCWSTR pSrcFileName, CONST D3D10_SHADER_MACRO *pDefines, + ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags, ID3D10Device *pDevice, + ID3DX10ThreadPump* pPump, ID3D10EffectPool **ppEffectPool, ID3D10Blob **ppErrors); + +#ifdef UNICODE +#define D3DX10CreateEffectPoolFromFile D3DX10CreateEffectPoolFromFileW +#define D3DX10CreateEffectPoolFromResource D3DX10CreateEffectPoolFromResourceW +#else +#define D3DX10CreateEffectPoolFromFile D3DX10CreateEffectPoolFromFileA +#define D3DX10CreateEffectPoolFromResource D3DX10CreateEffectPoolFromResourceA +#endif + +HRESULT WINAPI D3DX10PreprocessShaderFromFileA(LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, + LPD3D10INCLUDE pInclude, ID3DX10ThreadPump *pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs); + +HRESULT WINAPI D3DX10PreprocessShaderFromFileW(LPCWSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, + LPD3D10INCLUDE pInclude, ID3DX10ThreadPump *pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs); + +HRESULT WINAPI D3DX10PreprocessShaderFromMemory(LPCSTR pSrcData, SIZE_T SrcDataSize, LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, + LPD3D10INCLUDE pInclude, ID3DX10ThreadPump *pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs); + +HRESULT WINAPI D3DX10PreprocessShaderFromResourceA(HMODULE hModule, LPCSTR pResourceName, LPCSTR pSrcFileName, CONST D3D10_SHADER_MACRO* pDefines, + LPD3D10INCLUDE pInclude, ID3DX10ThreadPump *pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs); + +HRESULT WINAPI D3DX10PreprocessShaderFromResourceW(HMODULE hModule, LPCWSTR pResourceName, LPCWSTR pSrcFileName, CONST D3D10_SHADER_MACRO* pDefines, + LPD3D10INCLUDE pInclude, ID3DX10ThreadPump *pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs); + +#ifdef UNICODE +#define D3DX10PreprocessShaderFromFile D3DX10PreprocessShaderFromFileW +#define D3DX10PreprocessShaderFromResource D3DX10PreprocessShaderFromResourceW +#else +#define D3DX10PreprocessShaderFromFile D3DX10PreprocessShaderFromFileA +#define D3DX10PreprocessShaderFromResource D3DX10PreprocessShaderFromResourceA +#endif + +//---------------------------------------------------------------------------- +// Async processors +//---------------------------------------------------------------------------- + +HRESULT WINAPI D3DX10CreateAsyncShaderCompilerProcessor(LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, + LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, + ID3D10Blob **ppCompiledShader, ID3D10Blob **ppErrorBuffer, ID3DX10DataProcessor **ppProcessor); + +HRESULT WINAPI D3DX10CreateAsyncEffectCompilerProcessor(LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, + UINT Flags, UINT FXFlags, + ID3D10Blob **ppCompiledShader, ID3D10Blob **ppErrorBuffer, ID3DX10DataProcessor **ppProcessor); + +HRESULT WINAPI D3DX10CreateAsyncEffectCreateProcessor(LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, + UINT Flags, UINT FXFlags, ID3D10Device *pDevice, + ID3D10EffectPool *pPool, ID3D10Blob **ppErrorBuffer, ID3DX10DataProcessor **ppProcessor); + +HRESULT WINAPI D3DX10CreateAsyncEffectPoolCreateProcessor(LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, + UINT Flags, UINT FXFlags, ID3D10Device *pDevice, + ID3D10Blob **ppErrorBuffer, ID3DX10DataProcessor **ppProcessor); + +HRESULT WINAPI D3DX10CreateAsyncShaderPreprocessProcessor(LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, + ID3D10Blob** ppShaderText, ID3D10Blob **ppErrorBuffer, ID3DX10DataProcessor **ppProcessor); + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3D10EFFECT_H__ + + diff --git a/src/dep/include/DXSDK/include/d3dx8.h b/src/dep/include/DXSDK/include/d3dx8.h index 89f602d..31927a2 100644 --- a/src/dep/include/DXSDK/include/d3dx8.h +++ b/src/dep/include/DXSDK/include/d3dx8.h @@ -1,45 +1,45 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8.h -// Content: D3DX utility library -// -/////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DX8_H__ -#define __D3DX8_H__ - -#include "d3d8.h" -#include - -#ifndef D3DXINLINE -#ifdef _MSC_VER - #if (_MSC_VER >= 1200) - #define D3DXINLINE __forceinline - #else - #define D3DXINLINE __inline - #endif -#else - #ifdef __cplusplus - #define D3DXINLINE inline - #else - #define D3DXINLINE - #endif -#endif -#endif - - -#define D3DX_DEFAULT ULONG_MAX -#define D3DX_DEFAULT_FLOAT FLT_MAX - -#include "d3dx8math.h" -#include "d3dx8core.h" -#include "d3dx8tex.h" -#include "d3dx8mesh.h" -#include "d3dx8shape.h" -#include "d3dx8effect.h" - - -#endif //__D3DX8_H__ - +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8.h +// Content: D3DX utility library +// +/////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DX8_H__ +#define __D3DX8_H__ + +#include "d3d8.h" +#include + +#ifndef D3DXINLINE +#ifdef _MSC_VER + #if (_MSC_VER >= 1200) + #define D3DXINLINE __forceinline + #else + #define D3DXINLINE __inline + #endif +#else + #ifdef __cplusplus + #define D3DXINLINE inline + #else + #define D3DXINLINE + #endif +#endif +#endif + + +#define D3DX_DEFAULT ULONG_MAX +#define D3DX_DEFAULT_FLOAT FLT_MAX + +#include "d3dx8math.h" +#include "d3dx8core.h" +#include "d3dx8tex.h" +#include "d3dx8mesh.h" +#include "d3dx8shape.h" +#include "d3dx8effect.h" + + +#endif //__D3DX8_H__ + diff --git a/src/dep/include/DXSDK/include/d3dx8core.h b/src/dep/include/DXSDK/include/d3dx8core.h index 7db338f..46552a9 100644 --- a/src/dep/include/DXSDK/include/d3dx8core.h +++ b/src/dep/include/DXSDK/include/d3dx8core.h @@ -1,563 +1,563 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8core.h -// Content: D3DX core types and functions -// -/////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8CORE_H__ -#define __D3DX8CORE_H__ - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXBuffer: -// ------------ -// The buffer object is used by D3DX to return arbitrary size data. -// -// GetBufferPointer - -// Returns a pointer to the beginning of the buffer. -// -// GetBufferSize - -// Returns the size of the buffer, in bytes. -/////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXBuffer ID3DXBuffer; -typedef interface ID3DXBuffer *LPD3DXBUFFER; - -// {932E6A7E-C68E-45dd-A7BF-53D19C86DB1F} -DEFINE_GUID(IID_ID3DXBuffer, -0x932e6a7e, 0xc68e, 0x45dd, 0xa7, 0xbf, 0x53, 0xd1, 0x9c, 0x86, 0xdb, 0x1f); - -#undef INTERFACE -#define INTERFACE ID3DXBuffer - -DECLARE_INTERFACE_(ID3DXBuffer, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBuffer - STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; - STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; -}; - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXFont: -// ---------- -// Font objects contain the textures and resources needed to render -// a specific font on a specific device. -// -// Begin - -// Prepartes device for drawing text. This is optional.. if DrawText -// is called outside of Begin/End, it will call Begin and End for you. -// -// DrawText - -// Draws formatted text on a D3D device. Some parameters are -// surprisingly similar to those of GDI's DrawText function. See GDI -// documentation for a detailed description of these parameters. -// -// End - -// Restores device state to how it was when Begin was called. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -// -/////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXFont ID3DXFont; -typedef interface ID3DXFont *LPD3DXFONT; - - -// {89FAD6A5-024D-49af-8FE7-F51123B85E25} -DEFINE_GUID( IID_ID3DXFont, -0x89fad6a5, 0x24d, 0x49af, 0x8f, 0xe7, 0xf5, 0x11, 0x23, 0xb8, 0x5e, 0x25); - - -#undef INTERFACE -#define INTERFACE ID3DXFont - -DECLARE_INTERFACE_(ID3DXFont, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXFont - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetLogFont)(THIS_ LOGFONT* pLogFont) PURE; - - STDMETHOD(Begin)(THIS) PURE; - STDMETHOD_(INT, DrawTextA)(THIS_ LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; - STDMETHOD_(INT, DrawTextW)(THIS_ LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; - STDMETHOD(End)(THIS) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - -#ifndef DrawText -#ifdef UNICODE -#define DrawText DrawTextW -#else -#define DrawText DrawTextA -#endif -#endif - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateFont( - LPDIRECT3DDEVICE8 pDevice, - HFONT hFont, - LPD3DXFONT* ppFont); - - -HRESULT WINAPI - D3DXCreateFontIndirect( - LPDIRECT3DDEVICE8 pDevice, - CONST LOGFONT* pLogFont, - LPD3DXFONT* ppFont); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXSprite: -// ------------ -// This object intends to provide an easy way to drawing sprites using D3D. -// -// Begin - -// Prepares device for drawing sprites -// -// Draw, DrawAffine, DrawTransform - -// Draws a sprite in screen-space. Before transformation, the sprite is -// the size of SrcRect, with its top-left corner at the origin (0,0). -// The color and alpha channels are modulated by Color. -// -// End - -// Restores device state to how it was when Begin was called. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXSprite ID3DXSprite; -typedef interface ID3DXSprite *LPD3DXSPRITE; - - -// {13D69D15-F9B0-4e0f-B39E-C91EB33F6CE7} -DEFINE_GUID( IID_ID3DXSprite, -0x13d69d15, 0xf9b0, 0x4e0f, 0xb3, 0x9e, 0xc9, 0x1e, 0xb3, 0x3f, 0x6c, 0xe7); - - -#undef INTERFACE -#define INTERFACE ID3DXSprite - -DECLARE_INTERFACE_(ID3DXSprite, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXSprite - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - - STDMETHOD(Begin)(THIS) PURE; - - STDMETHOD(Draw)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture, - CONST RECT* pSrcRect, CONST D3DXVECTOR2* pScaling, - CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, - CONST D3DXVECTOR2* pTranslation, D3DCOLOR Color) PURE; - - STDMETHOD(DrawTransform)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture, - CONST RECT* pSrcRect, CONST D3DXMATRIX* pTransform, - D3DCOLOR Color) PURE; - - STDMETHOD(End)(THIS) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -HRESULT WINAPI - D3DXCreateSprite( - LPDIRECT3DDEVICE8 pDevice, - LPD3DXSPRITE* ppSprite); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXRenderToSurface: -// --------------------- -// This object abstracts rendering to surfaces. These surfaces do not -// necessarily need to be render targets. If they are not, a compatible -// render target is used, and the result copied into surface at end scene. -// -// BeginScene, EndScene - -// Call BeginScene() and EndScene() at the beginning and ending of your -// scene. These calls will setup and restore render targets, viewports, -// etc.. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// - -typedef struct _D3DXRTS_DESC -{ - UINT Width; - UINT Height; - D3DFORMAT Format; - BOOL DepthStencil; - D3DFORMAT DepthStencilFormat; - -} D3DXRTS_DESC; - - -typedef interface ID3DXRenderToSurface ID3DXRenderToSurface; -typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE; - - -// {82DF5B90-E34E-496e-AC1C-62117A6A5913} -DEFINE_GUID( IID_ID3DXRenderToSurface, -0x82df5b90, 0xe34e, 0x496e, 0xac, 0x1c, 0x62, 0x11, 0x7a, 0x6a, 0x59, 0x13); - - -#undef INTERFACE -#define INTERFACE ID3DXRenderToSurface - -DECLARE_INTERFACE_(ID3DXRenderToSurface, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXRenderToSurface - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetDesc)(THIS_ D3DXRTS_DESC* pDesc) PURE; - - STDMETHOD(BeginScene)(THIS_ LPDIRECT3DSURFACE8 pSurface, CONST D3DVIEWPORT8* pViewport) PURE; - STDMETHOD(EndScene)(THIS) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateRenderToSurface( - LPDIRECT3DDEVICE8 pDevice, - UINT Width, - UINT Height, - D3DFORMAT Format, - BOOL DepthStencil, - D3DFORMAT DepthStencilFormat, - LPD3DXRENDERTOSURFACE* ppRenderToSurface); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXRenderToEnvMap: -// -------------------- -// This object abstracts rendering to environment maps. These surfaces -// do not necessarily need to be render targets. If they are not, a -// compatible render target is used, and the result copied into the -// environment map at end scene. -// -// BeginCube, BeginSphere, BeginHemisphere, BeginParabolic - -// This function initiates the rendering of the environment map. As -// parameters, you pass the textures in which will get filled in with -// the resulting environment map. -// -// Face - -// Call this function to initiate the drawing of each face. For each -// environment map, you will call this six times.. once for each face -// in D3DCUBEMAP_FACES. -// -// End - -// This will restore all render targets, and if needed compose all the -// rendered faces into the environment map surfaces. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// - -typedef struct _D3DXRTE_DESC -{ - UINT Size; - D3DFORMAT Format; - BOOL DepthStencil; - D3DFORMAT DepthStencilFormat; -} D3DXRTE_DESC; - - -typedef interface ID3DXRenderToEnvMap ID3DXRenderToEnvMap; -typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap; - -// {4E42C623-9451-44b7-8C86-ABCCDE5D52C8} -DEFINE_GUID( IID_ID3DXRenderToEnvMap, -0x4e42c623, 0x9451, 0x44b7, 0x8c, 0x86, 0xab, 0xcc, 0xde, 0x5d, 0x52, 0xc8); - - -#undef INTERFACE -#define INTERFACE ID3DXRenderToEnvMap - -DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXRenderToEnvMap - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE; - - STDMETHOD(BeginCube)(THIS_ - LPDIRECT3DCUBETEXTURE8 pCubeTex) PURE; - - STDMETHOD(BeginSphere)(THIS_ - LPDIRECT3DTEXTURE8 pTex) PURE; - - STDMETHOD(BeginHemisphere)(THIS_ - LPDIRECT3DTEXTURE8 pTexZPos, - LPDIRECT3DTEXTURE8 pTexZNeg) PURE; - - STDMETHOD(BeginParabolic)(THIS_ - LPDIRECT3DTEXTURE8 pTexZPos, - LPDIRECT3DTEXTURE8 pTexZNeg) PURE; - - STDMETHOD(Face)(THIS_ D3DCUBEMAP_FACES Face) PURE; - STDMETHOD(End)(THIS) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateRenderToEnvMap( - LPDIRECT3DDEVICE8 pDevice, - UINT Size, - D3DFORMAT Format, - BOOL DepthStencil, - D3DFORMAT DepthStencilFormat, - LPD3DXRenderToEnvMap* ppRenderToEnvMap); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - -/////////////////////////////////////////////////////////////////////////// -// Shader assemblers: -/////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------- -// D3DXASM flags: -// -------------- -// -// D3DXASM_DEBUG -// Generate debug info. -// -// D3DXASM_SKIPVALIDATION -// Do not validate the generated code against known capabilities and -// constraints. This option is only recommended when assembling shaders -// you KNOW will work. (ie. have assembled before without this option.) -//------------------------------------------------------------------------- - -#define D3DXASM_DEBUG (1 << 0) -#define D3DXASM_SKIPVALIDATION (1 << 1) - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -//------------------------------------------------------------------------- -// D3DXAssembleShader: -// ------------------- -// Assembles an ascii description of a vertex or pixel shader into -// binary form. -// -// Parameters: -// pSrcFile -// Source file name -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pSrcData -// Pointer to source code -// SrcDataLen -// Size of source code, in bytes -// Flags -// D3DXASM_xxx flags -// ppConstants -// Returns an ID3DXBuffer object containing constant declarations. -// ppCompiledShader -// Returns an ID3DXBuffer object containing the object code. -// ppCompilationErrors -// Returns an ID3DXBuffer object containing ascii error messages -//------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXAssembleShaderFromFileA( - LPCSTR pSrcFile, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXAssembleShaderFromFileW( - LPCWSTR pSrcFile, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileW -#else -#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileA -#endif - -HRESULT WINAPI - D3DXAssembleShaderFromResourceA( - HMODULE hSrcModule, - LPCSTR pSrcResource, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXAssembleShaderFromResourceW( - HMODULE hSrcModule, - LPCWSTR pSrcResource, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceW -#else -#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceA -#endif - -HRESULT WINAPI - D3DXAssembleShader( - LPCVOID pSrcData, - UINT SrcDataLen, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - - -#ifdef __cplusplus -} -#endif //__cplusplus - - - -/////////////////////////////////////////////////////////////////////////// -// Misc APIs: -/////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -//------------------------------------------------------------------------- -// D3DXGetErrorString: -// ------------------ -// Returns the error string for given an hresult. Interprets all D3DX and -// D3D hresults. -// -// Parameters: -// hr -// The error code to be deciphered. -// pBuffer -// Pointer to the buffer to be filled in. -// BufferLen -// Count of characters in buffer. Any error message longer than this -// length will be truncated to fit. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXGetErrorStringA( - HRESULT hr, - LPSTR pBuffer, - UINT BufferLen); - -HRESULT WINAPI - D3DXGetErrorStringW( - HRESULT hr, - LPWSTR pBuffer, - UINT BufferLen); - -#ifdef UNICODE -#define D3DXGetErrorString D3DXGetErrorStringW -#else -#define D3DXGetErrorString D3DXGetErrorStringA -#endif - - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8CORE_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8core.h +// Content: D3DX core types and functions +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8CORE_H__ +#define __D3DX8CORE_H__ + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXBuffer: +// ------------ +// The buffer object is used by D3DX to return arbitrary size data. +// +// GetBufferPointer - +// Returns a pointer to the beginning of the buffer. +// +// GetBufferSize - +// Returns the size of the buffer, in bytes. +/////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXBuffer ID3DXBuffer; +typedef interface ID3DXBuffer *LPD3DXBUFFER; + +// {932E6A7E-C68E-45dd-A7BF-53D19C86DB1F} +DEFINE_GUID(IID_ID3DXBuffer, +0x932e6a7e, 0xc68e, 0x45dd, 0xa7, 0xbf, 0x53, 0xd1, 0x9c, 0x86, 0xdb, 0x1f); + +#undef INTERFACE +#define INTERFACE ID3DXBuffer + +DECLARE_INTERFACE_(ID3DXBuffer, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBuffer + STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; + STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; +}; + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXFont: +// ---------- +// Font objects contain the textures and resources needed to render +// a specific font on a specific device. +// +// Begin - +// Prepartes device for drawing text. This is optional.. if DrawText +// is called outside of Begin/End, it will call Begin and End for you. +// +// DrawText - +// Draws formatted text on a D3D device. Some parameters are +// surprisingly similar to those of GDI's DrawText function. See GDI +// documentation for a detailed description of these parameters. +// +// End - +// Restores device state to how it was when Begin was called. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +// +/////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXFont ID3DXFont; +typedef interface ID3DXFont *LPD3DXFONT; + + +// {89FAD6A5-024D-49af-8FE7-F51123B85E25} +DEFINE_GUID( IID_ID3DXFont, +0x89fad6a5, 0x24d, 0x49af, 0x8f, 0xe7, 0xf5, 0x11, 0x23, 0xb8, 0x5e, 0x25); + + +#undef INTERFACE +#define INTERFACE ID3DXFont + +DECLARE_INTERFACE_(ID3DXFont, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXFont + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetLogFont)(THIS_ LOGFONT* pLogFont) PURE; + + STDMETHOD(Begin)(THIS) PURE; + STDMETHOD_(INT, DrawTextA)(THIS_ LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; + STDMETHOD_(INT, DrawTextW)(THIS_ LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + +#ifndef DrawText +#ifdef UNICODE +#define DrawText DrawTextW +#else +#define DrawText DrawTextA +#endif +#endif + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateFont( + LPDIRECT3DDEVICE8 pDevice, + HFONT hFont, + LPD3DXFONT* ppFont); + + +HRESULT WINAPI + D3DXCreateFontIndirect( + LPDIRECT3DDEVICE8 pDevice, + CONST LOGFONT* pLogFont, + LPD3DXFONT* ppFont); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXSprite: +// ------------ +// This object intends to provide an easy way to drawing sprites using D3D. +// +// Begin - +// Prepares device for drawing sprites +// +// Draw, DrawAffine, DrawTransform - +// Draws a sprite in screen-space. Before transformation, the sprite is +// the size of SrcRect, with its top-left corner at the origin (0,0). +// The color and alpha channels are modulated by Color. +// +// End - +// Restores device state to how it was when Begin was called. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXSprite ID3DXSprite; +typedef interface ID3DXSprite *LPD3DXSPRITE; + + +// {13D69D15-F9B0-4e0f-B39E-C91EB33F6CE7} +DEFINE_GUID( IID_ID3DXSprite, +0x13d69d15, 0xf9b0, 0x4e0f, 0xb3, 0x9e, 0xc9, 0x1e, 0xb3, 0x3f, 0x6c, 0xe7); + + +#undef INTERFACE +#define INTERFACE ID3DXSprite + +DECLARE_INTERFACE_(ID3DXSprite, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXSprite + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + + STDMETHOD(Begin)(THIS) PURE; + + STDMETHOD(Draw)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture, + CONST RECT* pSrcRect, CONST D3DXVECTOR2* pScaling, + CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, + CONST D3DXVECTOR2* pTranslation, D3DCOLOR Color) PURE; + + STDMETHOD(DrawTransform)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture, + CONST RECT* pSrcRect, CONST D3DXMATRIX* pTransform, + D3DCOLOR Color) PURE; + + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +HRESULT WINAPI + D3DXCreateSprite( + LPDIRECT3DDEVICE8 pDevice, + LPD3DXSPRITE* ppSprite); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXRenderToSurface: +// --------------------- +// This object abstracts rendering to surfaces. These surfaces do not +// necessarily need to be render targets. If they are not, a compatible +// render target is used, and the result copied into surface at end scene. +// +// BeginScene, EndScene - +// Call BeginScene() and EndScene() at the beginning and ending of your +// scene. These calls will setup and restore render targets, viewports, +// etc.. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + +typedef struct _D3DXRTS_DESC +{ + UINT Width; + UINT Height; + D3DFORMAT Format; + BOOL DepthStencil; + D3DFORMAT DepthStencilFormat; + +} D3DXRTS_DESC; + + +typedef interface ID3DXRenderToSurface ID3DXRenderToSurface; +typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE; + + +// {82DF5B90-E34E-496e-AC1C-62117A6A5913} +DEFINE_GUID( IID_ID3DXRenderToSurface, +0x82df5b90, 0xe34e, 0x496e, 0xac, 0x1c, 0x62, 0x11, 0x7a, 0x6a, 0x59, 0x13); + + +#undef INTERFACE +#define INTERFACE ID3DXRenderToSurface + +DECLARE_INTERFACE_(ID3DXRenderToSurface, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXRenderToSurface + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetDesc)(THIS_ D3DXRTS_DESC* pDesc) PURE; + + STDMETHOD(BeginScene)(THIS_ LPDIRECT3DSURFACE8 pSurface, CONST D3DVIEWPORT8* pViewport) PURE; + STDMETHOD(EndScene)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateRenderToSurface( + LPDIRECT3DDEVICE8 pDevice, + UINT Width, + UINT Height, + D3DFORMAT Format, + BOOL DepthStencil, + D3DFORMAT DepthStencilFormat, + LPD3DXRENDERTOSURFACE* ppRenderToSurface); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXRenderToEnvMap: +// -------------------- +// This object abstracts rendering to environment maps. These surfaces +// do not necessarily need to be render targets. If they are not, a +// compatible render target is used, and the result copied into the +// environment map at end scene. +// +// BeginCube, BeginSphere, BeginHemisphere, BeginParabolic - +// This function initiates the rendering of the environment map. As +// parameters, you pass the textures in which will get filled in with +// the resulting environment map. +// +// Face - +// Call this function to initiate the drawing of each face. For each +// environment map, you will call this six times.. once for each face +// in D3DCUBEMAP_FACES. +// +// End - +// This will restore all render targets, and if needed compose all the +// rendered faces into the environment map surfaces. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + +typedef struct _D3DXRTE_DESC +{ + UINT Size; + D3DFORMAT Format; + BOOL DepthStencil; + D3DFORMAT DepthStencilFormat; +} D3DXRTE_DESC; + + +typedef interface ID3DXRenderToEnvMap ID3DXRenderToEnvMap; +typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap; + +// {4E42C623-9451-44b7-8C86-ABCCDE5D52C8} +DEFINE_GUID( IID_ID3DXRenderToEnvMap, +0x4e42c623, 0x9451, 0x44b7, 0x8c, 0x86, 0xab, 0xcc, 0xde, 0x5d, 0x52, 0xc8); + + +#undef INTERFACE +#define INTERFACE ID3DXRenderToEnvMap + +DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXRenderToEnvMap + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE; + + STDMETHOD(BeginCube)(THIS_ + LPDIRECT3DCUBETEXTURE8 pCubeTex) PURE; + + STDMETHOD(BeginSphere)(THIS_ + LPDIRECT3DTEXTURE8 pTex) PURE; + + STDMETHOD(BeginHemisphere)(THIS_ + LPDIRECT3DTEXTURE8 pTexZPos, + LPDIRECT3DTEXTURE8 pTexZNeg) PURE; + + STDMETHOD(BeginParabolic)(THIS_ + LPDIRECT3DTEXTURE8 pTexZPos, + LPDIRECT3DTEXTURE8 pTexZNeg) PURE; + + STDMETHOD(Face)(THIS_ D3DCUBEMAP_FACES Face) PURE; + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateRenderToEnvMap( + LPDIRECT3DDEVICE8 pDevice, + UINT Size, + D3DFORMAT Format, + BOOL DepthStencil, + D3DFORMAT DepthStencilFormat, + LPD3DXRenderToEnvMap* ppRenderToEnvMap); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// Shader assemblers: +/////////////////////////////////////////////////////////////////////////// + +//------------------------------------------------------------------------- +// D3DXASM flags: +// -------------- +// +// D3DXASM_DEBUG +// Generate debug info. +// +// D3DXASM_SKIPVALIDATION +// Do not validate the generated code against known capabilities and +// constraints. This option is only recommended when assembling shaders +// you KNOW will work. (ie. have assembled before without this option.) +//------------------------------------------------------------------------- + +#define D3DXASM_DEBUG (1 << 0) +#define D3DXASM_SKIPVALIDATION (1 << 1) + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +//------------------------------------------------------------------------- +// D3DXAssembleShader: +// ------------------- +// Assembles an ascii description of a vertex or pixel shader into +// binary form. +// +// Parameters: +// pSrcFile +// Source file name +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pSrcData +// Pointer to source code +// SrcDataLen +// Size of source code, in bytes +// Flags +// D3DXASM_xxx flags +// ppConstants +// Returns an ID3DXBuffer object containing constant declarations. +// ppCompiledShader +// Returns an ID3DXBuffer object containing the object code. +// ppCompilationErrors +// Returns an ID3DXBuffer object containing ascii error messages +//------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXAssembleShaderFromFileA( + LPCSTR pSrcFile, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXAssembleShaderFromFileW( + LPCWSTR pSrcFile, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileW +#else +#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileA +#endif + +HRESULT WINAPI + D3DXAssembleShaderFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXAssembleShaderFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceW +#else +#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceA +#endif + +HRESULT WINAPI + D3DXAssembleShader( + LPCVOID pSrcData, + UINT SrcDataLen, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// Misc APIs: +/////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +//------------------------------------------------------------------------- +// D3DXGetErrorString: +// ------------------ +// Returns the error string for given an hresult. Interprets all D3DX and +// D3D hresults. +// +// Parameters: +// hr +// The error code to be deciphered. +// pBuffer +// Pointer to the buffer to be filled in. +// BufferLen +// Count of characters in buffer. Any error message longer than this +// length will be truncated to fit. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXGetErrorStringA( + HRESULT hr, + LPSTR pBuffer, + UINT BufferLen); + +HRESULT WINAPI + D3DXGetErrorStringW( + HRESULT hr, + LPWSTR pBuffer, + UINT BufferLen); + +#ifdef UNICODE +#define D3DXGetErrorString D3DXGetErrorStringW +#else +#define D3DXGetErrorString D3DXGetErrorStringA +#endif + + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8CORE_H__ diff --git a/src/dep/include/DXSDK/include/d3dx8effect.h b/src/dep/include/DXSDK/include/d3dx8effect.h index 96fc382..97c44df 100644 --- a/src/dep/include/DXSDK/include/d3dx8effect.h +++ b/src/dep/include/DXSDK/include/d3dx8effect.h @@ -1,226 +1,226 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8effect.h -// Content: D3DX effect types and functions -// -/////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8EFFECT_H__ -#define __D3DX8EFFECT_H__ - - -#define D3DXFX_DONOTSAVESTATE (1 << 0) - - -typedef enum _D3DXPARAMETERTYPE -{ - D3DXPT_DWORD = 0, - D3DXPT_FLOAT = 1, - D3DXPT_VECTOR = 2, - D3DXPT_MATRIX = 3, - D3DXPT_TEXTURE = 4, - D3DXPT_VERTEXSHADER = 5, - D3DXPT_PIXELSHADER = 6, - D3DXPT_CONSTANT = 7, - D3DXPT_STRING = 8, - D3DXPT_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */ - -} D3DXPARAMETERTYPE; - - -typedef struct _D3DXEFFECT_DESC -{ - UINT Parameters; - UINT Techniques; - -} D3DXEFFECT_DESC; - - -typedef struct _D3DXPARAMETER_DESC -{ - LPCSTR Name; - LPCSTR Index; - D3DXPARAMETERTYPE Type; - -} D3DXPARAMETER_DESC; - - -typedef struct _D3DXTECHNIQUE_DESC -{ - LPCSTR Name; - LPCSTR Index; - UINT Passes; - -} D3DXTECHNIQUE_DESC; - - -typedef struct _D3DXPASS_DESC -{ - LPCSTR Name; - LPCSTR Index; - -} D3DXPASS_DESC; - - - -////////////////////////////////////////////////////////////////////////////// -// ID3DXEffect /////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXEffect ID3DXEffect; -typedef interface ID3DXEffect *LPD3DXEFFECT; - -// {648B1CEB-8D4E-4d66-B6FA-E44969E82E89} -DEFINE_GUID( IID_ID3DXEffect, -0x648b1ceb, 0x8d4e, 0x4d66, 0xb6, 0xfa, 0xe4, 0x49, 0x69, 0xe8, 0x2e, 0x89); - - -#undef INTERFACE -#define INTERFACE ID3DXEffect - -DECLARE_INTERFACE_(ID3DXEffect, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXEffect - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; - STDMETHOD(GetParameterDesc)(THIS_ LPCSTR pParameter, D3DXPARAMETER_DESC* pDesc) PURE; - STDMETHOD(GetTechniqueDesc)(THIS_ LPCSTR pTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; - STDMETHOD(GetPassDesc)(THIS_ LPCSTR pTechnique, LPCSTR pPass, D3DXPASS_DESC* pDesc) PURE; - STDMETHOD(FindNextValidTechnique)(THIS_ LPCSTR pTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; - STDMETHOD(CloneEffect)(THIS_ LPDIRECT3DDEVICE8 pDevice, LPD3DXEFFECT* ppEffect) PURE; - STDMETHOD(GetCompiledEffect)(THIS_ LPD3DXBUFFER* ppCompiledEffect) PURE; - - STDMETHOD(SetTechnique)(THIS_ LPCSTR pTechnique) PURE; - STDMETHOD(GetTechnique)(THIS_ LPCSTR* ppTechnique) PURE; - - STDMETHOD(SetDword)(THIS_ LPCSTR pParameter, DWORD dw) PURE; - STDMETHOD(GetDword)(THIS_ LPCSTR pParameter, DWORD* pdw) PURE; - STDMETHOD(SetFloat)(THIS_ LPCSTR pParameter, FLOAT f) PURE; - STDMETHOD(GetFloat)(THIS_ LPCSTR pParameter, FLOAT* pf) PURE; - STDMETHOD(SetVector)(THIS_ LPCSTR pParameter, CONST D3DXVECTOR4* pVector) PURE; - STDMETHOD(GetVector)(THIS_ LPCSTR pParameter, D3DXVECTOR4* pVector) PURE; - STDMETHOD(SetMatrix)(THIS_ LPCSTR pParameter, CONST D3DXMATRIX* pMatrix) PURE; - STDMETHOD(GetMatrix)(THIS_ LPCSTR pParameter, D3DXMATRIX* pMatrix) PURE; - STDMETHOD(SetTexture)(THIS_ LPCSTR pParameter, LPDIRECT3DBASETEXTURE8 pTexture) PURE; - STDMETHOD(GetTexture)(THIS_ LPCSTR pParameter, LPDIRECT3DBASETEXTURE8 *ppTexture) PURE; - STDMETHOD(SetVertexShader)(THIS_ LPCSTR pParameter, DWORD Handle) PURE; - STDMETHOD(GetVertexShader)(THIS_ LPCSTR pParameter, DWORD* pHandle) PURE; - STDMETHOD(SetPixelShader)(THIS_ LPCSTR pParameter, DWORD Handle) PURE; - STDMETHOD(GetPixelShader)(THIS_ LPCSTR pParameter, DWORD* pHandle) PURE; - STDMETHOD(SetString)(THIS_ LPCSTR pParameter, LPCSTR pString) PURE; - STDMETHOD(GetString)(THIS_ LPCSTR pParameter, LPCSTR* ppString) PURE; - STDMETHOD_(BOOL, IsParameterUsed)(THIS_ LPCSTR pParameter) PURE; - - STDMETHOD(Validate)(THIS) PURE; - STDMETHOD(Begin)(THIS_ UINT *pPasses, DWORD Flags) PURE; - STDMETHOD(Pass)(THIS_ UINT Pass) PURE; - STDMETHOD(End)(THIS) PURE; - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - - -////////////////////////////////////////////////////////////////////////////// -// APIs ////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -//---------------------------------------------------------------------------- -// D3DXCreateEffect: -// ----------------- -// Creates an effect from an ascii or binaray effect description. -// -// Parameters: -// pDevice -// Pointer of the device on which to create the effect -// pSrcFile -// Name of the file containing the effect description -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pSrcData -// Pointer to effect description -// SrcDataSize -// Size of the effect description in bytes -// ppEffect -// Returns a buffer containing created effect. -// ppCompilationErrors -// Returns a buffer containing any error messages which occurred during -// compile. Or NULL if you do not care about the error messages. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCreateEffectFromFileA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXCreateEffectFromFileW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileW -#else -#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileA -#endif - - -HRESULT WINAPI - D3DXCreateEffectFromResourceA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXCreateEffectFromResourceW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceW -#else -#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceA -#endif - - -HRESULT WINAPI - D3DXCreateEffect( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8EFFECT_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8effect.h +// Content: D3DX effect types and functions +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8EFFECT_H__ +#define __D3DX8EFFECT_H__ + + +#define D3DXFX_DONOTSAVESTATE (1 << 0) + + +typedef enum _D3DXPARAMETERTYPE +{ + D3DXPT_DWORD = 0, + D3DXPT_FLOAT = 1, + D3DXPT_VECTOR = 2, + D3DXPT_MATRIX = 3, + D3DXPT_TEXTURE = 4, + D3DXPT_VERTEXSHADER = 5, + D3DXPT_PIXELSHADER = 6, + D3DXPT_CONSTANT = 7, + D3DXPT_STRING = 8, + D3DXPT_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */ + +} D3DXPARAMETERTYPE; + + +typedef struct _D3DXEFFECT_DESC +{ + UINT Parameters; + UINT Techniques; + +} D3DXEFFECT_DESC; + + +typedef struct _D3DXPARAMETER_DESC +{ + LPCSTR Name; + LPCSTR Index; + D3DXPARAMETERTYPE Type; + +} D3DXPARAMETER_DESC; + + +typedef struct _D3DXTECHNIQUE_DESC +{ + LPCSTR Name; + LPCSTR Index; + UINT Passes; + +} D3DXTECHNIQUE_DESC; + + +typedef struct _D3DXPASS_DESC +{ + LPCSTR Name; + LPCSTR Index; + +} D3DXPASS_DESC; + + + +////////////////////////////////////////////////////////////////////////////// +// ID3DXEffect /////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXEffect ID3DXEffect; +typedef interface ID3DXEffect *LPD3DXEFFECT; + +// {648B1CEB-8D4E-4d66-B6FA-E44969E82E89} +DEFINE_GUID( IID_ID3DXEffect, +0x648b1ceb, 0x8d4e, 0x4d66, 0xb6, 0xfa, 0xe4, 0x49, 0x69, 0xe8, 0x2e, 0x89); + + +#undef INTERFACE +#define INTERFACE ID3DXEffect + +DECLARE_INTERFACE_(ID3DXEffect, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXEffect + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; + STDMETHOD(GetParameterDesc)(THIS_ LPCSTR pParameter, D3DXPARAMETER_DESC* pDesc) PURE; + STDMETHOD(GetTechniqueDesc)(THIS_ LPCSTR pTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; + STDMETHOD(GetPassDesc)(THIS_ LPCSTR pTechnique, LPCSTR pPass, D3DXPASS_DESC* pDesc) PURE; + STDMETHOD(FindNextValidTechnique)(THIS_ LPCSTR pTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; + STDMETHOD(CloneEffect)(THIS_ LPDIRECT3DDEVICE8 pDevice, LPD3DXEFFECT* ppEffect) PURE; + STDMETHOD(GetCompiledEffect)(THIS_ LPD3DXBUFFER* ppCompiledEffect) PURE; + + STDMETHOD(SetTechnique)(THIS_ LPCSTR pTechnique) PURE; + STDMETHOD(GetTechnique)(THIS_ LPCSTR* ppTechnique) PURE; + + STDMETHOD(SetDword)(THIS_ LPCSTR pParameter, DWORD dw) PURE; + STDMETHOD(GetDword)(THIS_ LPCSTR pParameter, DWORD* pdw) PURE; + STDMETHOD(SetFloat)(THIS_ LPCSTR pParameter, FLOAT f) PURE; + STDMETHOD(GetFloat)(THIS_ LPCSTR pParameter, FLOAT* pf) PURE; + STDMETHOD(SetVector)(THIS_ LPCSTR pParameter, CONST D3DXVECTOR4* pVector) PURE; + STDMETHOD(GetVector)(THIS_ LPCSTR pParameter, D3DXVECTOR4* pVector) PURE; + STDMETHOD(SetMatrix)(THIS_ LPCSTR pParameter, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(GetMatrix)(THIS_ LPCSTR pParameter, D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetTexture)(THIS_ LPCSTR pParameter, LPDIRECT3DBASETEXTURE8 pTexture) PURE; + STDMETHOD(GetTexture)(THIS_ LPCSTR pParameter, LPDIRECT3DBASETEXTURE8 *ppTexture) PURE; + STDMETHOD(SetVertexShader)(THIS_ LPCSTR pParameter, DWORD Handle) PURE; + STDMETHOD(GetVertexShader)(THIS_ LPCSTR pParameter, DWORD* pHandle) PURE; + STDMETHOD(SetPixelShader)(THIS_ LPCSTR pParameter, DWORD Handle) PURE; + STDMETHOD(GetPixelShader)(THIS_ LPCSTR pParameter, DWORD* pHandle) PURE; + STDMETHOD(SetString)(THIS_ LPCSTR pParameter, LPCSTR pString) PURE; + STDMETHOD(GetString)(THIS_ LPCSTR pParameter, LPCSTR* ppString) PURE; + STDMETHOD_(BOOL, IsParameterUsed)(THIS_ LPCSTR pParameter) PURE; + + STDMETHOD(Validate)(THIS) PURE; + STDMETHOD(Begin)(THIS_ UINT *pPasses, DWORD Flags) PURE; + STDMETHOD(Pass)(THIS_ UINT Pass) PURE; + STDMETHOD(End)(THIS) PURE; + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + + +////////////////////////////////////////////////////////////////////////////// +// APIs ////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +//---------------------------------------------------------------------------- +// D3DXCreateEffect: +// ----------------- +// Creates an effect from an ascii or binaray effect description. +// +// Parameters: +// pDevice +// Pointer of the device on which to create the effect +// pSrcFile +// Name of the file containing the effect description +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pSrcData +// Pointer to effect description +// SrcDataSize +// Size of the effect description in bytes +// ppEffect +// Returns a buffer containing created effect. +// ppCompilationErrors +// Returns a buffer containing any error messages which occurred during +// compile. Or NULL if you do not care about the error messages. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCreateEffectFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXCreateEffectFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileW +#else +#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateEffectFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXCreateEffectFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceW +#else +#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateEffect( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8EFFECT_H__ diff --git a/src/dep/include/DXSDK/include/d3dx8math.h b/src/dep/include/DXSDK/include/d3dx8math.h index 4677954..9c8f203 100644 --- a/src/dep/include/DXSDK/include/d3dx8math.h +++ b/src/dep/include/DXSDK/include/d3dx8math.h @@ -1,1215 +1,1215 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8math.h -// Content: D3DX math types and functions -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8MATH_H__ -#define __D3DX8MATH_H__ - -#include -#pragma warning(disable:4201) // anonymous unions warning - - - -//=========================================================================== -// -// General purpose utilities -// -//=========================================================================== -#define D3DX_PI ((FLOAT) 3.141592654f) -#define D3DX_1BYPI ((FLOAT) 0.318309886f) - -#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) -#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) - - - -//=========================================================================== -// -// Vectors -// -//=========================================================================== - -//-------------------------- -// 2D Vector -//-------------------------- -typedef struct D3DXVECTOR2 -{ -#ifdef __cplusplus -public: - D3DXVECTOR2() {}; - D3DXVECTOR2( CONST FLOAT * ); - D3DXVECTOR2( FLOAT x, FLOAT y ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR2& operator += ( CONST D3DXVECTOR2& ); - D3DXVECTOR2& operator -= ( CONST D3DXVECTOR2& ); - D3DXVECTOR2& operator *= ( FLOAT ); - D3DXVECTOR2& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR2 operator + () const; - D3DXVECTOR2 operator - () const; - - // binary operators - D3DXVECTOR2 operator + ( CONST D3DXVECTOR2& ) const; - D3DXVECTOR2 operator - ( CONST D3DXVECTOR2& ) const; - D3DXVECTOR2 operator * ( FLOAT ) const; - D3DXVECTOR2 operator / ( FLOAT ) const; - - friend D3DXVECTOR2 operator * ( FLOAT, CONST D3DXVECTOR2& ); - - BOOL operator == ( CONST D3DXVECTOR2& ) const; - BOOL operator != ( CONST D3DXVECTOR2& ) const; - - -public: -#endif //__cplusplus - FLOAT x, y; -} D3DXVECTOR2, *LPD3DXVECTOR2; - - -//-------------------------- -// 3D Vector -//-------------------------- -#ifdef __cplusplus -typedef struct D3DXVECTOR3 : public D3DVECTOR -{ -public: - D3DXVECTOR3() {}; - D3DXVECTOR3( CONST FLOAT * ); - D3DXVECTOR3( CONST D3DVECTOR& ); - D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); - D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& ); - D3DXVECTOR3& operator *= ( FLOAT ); - D3DXVECTOR3& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR3 operator + () const; - D3DXVECTOR3 operator - () const; - - // binary operators - D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const; - D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const; - D3DXVECTOR3 operator * ( FLOAT ) const; - D3DXVECTOR3 operator / ( FLOAT ) const; - - friend D3DXVECTOR3 operator * ( FLOAT, CONST struct D3DXVECTOR3& ); - - BOOL operator == ( CONST D3DXVECTOR3& ) const; - BOOL operator != ( CONST D3DXVECTOR3& ) const; - -} D3DXVECTOR3, *LPD3DXVECTOR3; - -#else //!__cplusplus -typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; -#endif //!__cplusplus - - -//-------------------------- -// 4D Vector -//-------------------------- -typedef struct D3DXVECTOR4 -{ -#ifdef __cplusplus -public: - D3DXVECTOR4() {}; - D3DXVECTOR4( CONST FLOAT* ); - D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& ); - D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& ); - D3DXVECTOR4& operator *= ( FLOAT ); - D3DXVECTOR4& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR4 operator + () const; - D3DXVECTOR4 operator - () const; - - // binary operators - D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const; - D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const; - D3DXVECTOR4 operator * ( FLOAT ) const; - D3DXVECTOR4 operator / ( FLOAT ) const; - - friend D3DXVECTOR4 operator * ( FLOAT, CONST D3DXVECTOR4& ); - - BOOL operator == ( CONST D3DXVECTOR4& ) const; - BOOL operator != ( CONST D3DXVECTOR4& ) const; - -public: -#endif //__cplusplus - FLOAT x, y, z, w; -} D3DXVECTOR4, *LPD3DXVECTOR4; - - -//=========================================================================== -// -// Matrices -// -//=========================================================================== -#ifdef __cplusplus -typedef struct D3DXMATRIX : public D3DMATRIX -{ -public: - D3DXMATRIX() {}; - D3DXMATRIX( CONST FLOAT * ); - D3DXMATRIX( CONST D3DMATRIX& ); - D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, - FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, - FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, - FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); - - - // access grants - FLOAT& operator () ( UINT Row, UINT Col ); - FLOAT operator () ( UINT Row, UINT Col ) const; - - // casting operators - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXMATRIX& operator *= ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator += ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator -= ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator *= ( FLOAT ); - D3DXMATRIX& operator /= ( FLOAT ); - - // unary operators - D3DXMATRIX operator + () const; - D3DXMATRIX operator - () const; - - // binary operators - D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator * ( FLOAT ) const; - D3DXMATRIX operator / ( FLOAT ) const; - - friend D3DXMATRIX operator * ( FLOAT, CONST D3DXMATRIX& ); - - BOOL operator == ( CONST D3DXMATRIX& ) const; - BOOL operator != ( CONST D3DXMATRIX& ) const; - -} D3DXMATRIX, *LPD3DXMATRIX; - -#else //!__cplusplus -typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; -#endif //!__cplusplus - -//=========================================================================== -// -// Aligned Matrices -// -// This class helps keep matrices 16-byte aligned as preferred by P4 cpus. -// It aligns matrices on the stack and on the heap or in global scope. -// It does this using __declspec(align(16)) which works on VC7 and on VC 6 -// with the processor pack. Unfortunately there is no way to detect the -// latter so this is turned on only on VC7. On other compilers this is the -// the same as D3DXMATRIX. -// Using this class on a compiler that does not actually do the alignment -// can be dangerous since it will not expose bugs that ignore alignment. -// E.g if an object of this class in inside a struct or class, and some code -// memcopys data in it assuming tight packing. This could break on a compiler -// that eventually start aligning the matrix. -// -//=========================================================================== -#ifdef __cplusplus -typedef struct _D3DXMATRIXA16 : public D3DXMATRIX -{ - _D3DXMATRIXA16() {} - _D3DXMATRIXA16( CONST FLOAT * f): D3DXMATRIX(f) {} - _D3DXMATRIXA16( CONST D3DMATRIX& m): D3DXMATRIX(m) {} - _D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, - FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, - FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, - FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ) : - D3DXMATRIX(_11, _12, _13, _14, - _21, _22, _23, _24, - _31, _32, _33, _34, - _41, _42, _43, _44) {} - void* operator new(size_t s) - { - LPBYTE p = ::new BYTE[s + 16]; - if (p) - { - BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); - p += offset; - p[-1] = offset; - } - return p; - }; - - void* operator new[](size_t s) - { - LPBYTE p = ::new BYTE[s + 16]; - if (p) - { - BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); - p += offset; - p[-1] = offset; - } - return p; - }; - - // This is NOT a virtual operator. If you cast - // to D3DXMATRIX, do not delete using that - void operator delete(void* p) - { - if(p) - { - BYTE* pb = static_cast(p); - pb -= pb[-1]; - ::delete [] pb; - } - }; - - // This is NOT a virtual operator. If you cast - // to D3DXMATRIX, do not delete using that - void operator delete[](void* p) - { - if(p) - { - BYTE* pb = static_cast(p); - pb -= pb[-1]; - ::delete [] pb; - } - }; - - struct _D3DXMATRIXA16& operator=(CONST D3DXMATRIX& rhs) - { - memcpy(&_11, &rhs, sizeof(D3DXMATRIX)); - return *this; - }; -} _D3DXMATRIXA16; - -#else //!__cplusplus -typedef D3DXMATRIX _D3DXMATRIXA16; -#endif //!__cplusplus - -#if _MSC_VER >= 1300 // VC7 -#define _ALIGN_16 __declspec(align(16)) -#else -#define _ALIGN_16 // Earlier compiler may not understand this, do nothing. -#endif - -#define D3DXMATRIXA16 _ALIGN_16 _D3DXMATRIXA16 - -typedef D3DXMATRIXA16 *LPD3DXMATRIXA16; - -//=========================================================================== -// -// Quaternions -// -//=========================================================================== -typedef struct D3DXQUATERNION -{ -#ifdef __cplusplus -public: - D3DXQUATERNION() {} - D3DXQUATERNION( CONST FLOAT * ); - D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXQUATERNION& operator += ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator -= ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator *= ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator *= ( FLOAT ); - D3DXQUATERNION& operator /= ( FLOAT ); - - // unary operators - D3DXQUATERNION operator + () const; - D3DXQUATERNION operator - () const; - - // binary operators - D3DXQUATERNION operator + ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator - ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator * ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator * ( FLOAT ) const; - D3DXQUATERNION operator / ( FLOAT ) const; - - friend D3DXQUATERNION operator * (FLOAT, CONST D3DXQUATERNION& ); - - BOOL operator == ( CONST D3DXQUATERNION& ) const; - BOOL operator != ( CONST D3DXQUATERNION& ) const; - -#endif //__cplusplus - FLOAT x, y, z, w; -} D3DXQUATERNION, *LPD3DXQUATERNION; - - -//=========================================================================== -// -// Planes -// -//=========================================================================== -typedef struct D3DXPLANE -{ -#ifdef __cplusplus -public: - D3DXPLANE() {} - D3DXPLANE( CONST FLOAT* ); - D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // unary operators - D3DXPLANE operator + () const; - D3DXPLANE operator - () const; - - // binary operators - BOOL operator == ( CONST D3DXPLANE& ) const; - BOOL operator != ( CONST D3DXPLANE& ) const; - -#endif //__cplusplus - FLOAT a, b, c, d; -} D3DXPLANE, *LPD3DXPLANE; - - -//=========================================================================== -// -// Colors -// -//=========================================================================== - -typedef struct D3DXCOLOR -{ -#ifdef __cplusplus -public: - D3DXCOLOR() {} - D3DXCOLOR( DWORD argb ); - D3DXCOLOR( CONST FLOAT * ); - D3DXCOLOR( CONST D3DCOLORVALUE& ); - D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); - - // casting - operator DWORD () const; - - operator FLOAT* (); - operator CONST FLOAT* () const; - - operator D3DCOLORVALUE* (); - operator CONST D3DCOLORVALUE* () const; - - operator D3DCOLORVALUE& (); - operator CONST D3DCOLORVALUE& () const; - - // assignment operators - D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); - D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); - D3DXCOLOR& operator *= ( FLOAT ); - D3DXCOLOR& operator /= ( FLOAT ); - - // unary operators - D3DXCOLOR operator + () const; - D3DXCOLOR operator - () const; - - // binary operators - D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; - D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; - D3DXCOLOR operator * ( FLOAT ) const; - D3DXCOLOR operator / ( FLOAT ) const; - - friend D3DXCOLOR operator * (FLOAT, CONST D3DXCOLOR& ); - - BOOL operator == ( CONST D3DXCOLOR& ) const; - BOOL operator != ( CONST D3DXCOLOR& ) const; - -#endif //__cplusplus - FLOAT r, g, b, a; -} D3DXCOLOR, *LPD3DXCOLOR; - - - -//=========================================================================== -// -// D3DX math functions: -// -// NOTE: -// * All these functions can take the same object as in and out parameters. -// -// * Out parameters are typically also returned as return values, so that -// the output of one function may be used as a parameter to another. -// -//=========================================================================== - -//-------------------------- -// 2D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec2Length - ( CONST D3DXVECTOR2 *pV ); - -FLOAT D3DXVec2LengthSq - ( CONST D3DXVECTOR2 *pV ); - -FLOAT D3DXVec2Dot - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Z component of ((x1,y1,0) cross (x2,y2,0)) -FLOAT D3DXVec2CCW - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Add - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Subtract - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2) -D3DXVECTOR2* D3DXVec2Minimize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2) -D3DXVECTOR2* D3DXVec2Maximize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Scale - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR2* D3DXVec2Lerp - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -D3DXVECTOR2* WINAPI D3DXVec2Normalize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR2* WINAPI D3DXVec2Hermite - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, - CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR2* WINAPI D3DXVec2CatmullRom - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, - CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR2* WINAPI D3DXVec2BaryCentric - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, - CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); - -// Transform (x, y, 0, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec2Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, 0, 1) by matrix, project result back into w=1. -D3DXVECTOR2* WINAPI D3DXVec2TransformCoord - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, 0, 0) by matrix. -D3DXVECTOR2* WINAPI D3DXVec2TransformNormal - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// 3D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec3Length - ( CONST D3DXVECTOR3 *pV ); - -FLOAT D3DXVec3LengthSq - ( CONST D3DXVECTOR3 *pV ); - -FLOAT D3DXVec3Dot - ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Cross - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Add - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Subtract - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... -D3DXVECTOR3* D3DXVec3Minimize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... -D3DXVECTOR3* D3DXVec3Maximize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Scale - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR3* D3DXVec3Lerp - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -D3DXVECTOR3* WINAPI D3DXVec3Normalize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR3* WINAPI D3DXVec3Hermite - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, - CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR3* WINAPI D3DXVec3CatmullRom - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, - CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR3* WINAPI D3DXVec3BaryCentric - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); - -// Transform (x, y, z, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec3Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, z, 1) by matrix, project result back into w=1. -D3DXVECTOR3* WINAPI D3DXVec3TransformCoord - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the -// transpose of the inverse of the matrix you would use to transform a coord. -D3DXVECTOR3* WINAPI D3DXVec3TransformNormal - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -// Project vector from object space into screen space -D3DXVECTOR3* WINAPI D3DXVec3Project - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, - CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); - -// Project vector from screen space into object space -D3DXVECTOR3* WINAPI D3DXVec3Unproject - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, - CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); - -#ifdef __cplusplus -} -#endif - - - -//-------------------------- -// 4D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec4Length - ( CONST D3DXVECTOR4 *pV ); - -FLOAT D3DXVec4LengthSq - ( CONST D3DXVECTOR4 *pV ); - -FLOAT D3DXVec4Dot - ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ); - -D3DXVECTOR4* D3DXVec4Add - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -D3DXVECTOR4* D3DXVec4Subtract - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... -D3DXVECTOR4* D3DXVec4Minimize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... -D3DXVECTOR4* D3DXVec4Maximize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -D3DXVECTOR4* D3DXVec4Scale - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR4* D3DXVec4Lerp - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Cross-product in 4 dimensions. -D3DXVECTOR4* WINAPI D3DXVec4Cross - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - CONST D3DXVECTOR4 *pV3); - -D3DXVECTOR4* WINAPI D3DXVec4Normalize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR4* WINAPI D3DXVec4Hermite - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, - CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR4* WINAPI D3DXVec4CatmullRom - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, - CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR4* WINAPI D3DXVec4BaryCentric - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); - -// Transform vector by matrix. -D3DXVECTOR4* WINAPI D3DXVec4Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// 4D Matrix -//-------------------------- - -// inline - -D3DXMATRIX* D3DXMatrixIdentity - ( D3DXMATRIX *pOut ); - -BOOL D3DXMatrixIsIdentity - ( CONST D3DXMATRIX *pM ); - - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -FLOAT WINAPI D3DXMatrixfDeterminant - ( CONST D3DXMATRIX *pM ); - -D3DXMATRIX* WINAPI D3DXMatrixTranspose - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); - -// Matrix multiplication. The result represents the transformation M2 -// followed by the transformation M1. (Out = M1 * M2) -D3DXMATRIX* WINAPI D3DXMatrixMultiply - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); - -// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) -D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); - -// Calculate inverse of matrix. Inversion my fail, in which case NULL will -// be returned. The determinant of pM is also returned it pfDeterminant -// is non-NULL. -D3DXMATRIX* WINAPI D3DXMatrixInverse - ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); - -// Build a matrix which scales by (sx, sy, sz) -D3DXMATRIX* WINAPI D3DXMatrixScaling - ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); - -// Build a matrix which translates by (x, y, z) -D3DXMATRIX* WINAPI D3DXMatrixTranslation - ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); - -// Build a matrix which rotates around the X axis -D3DXMATRIX* WINAPI D3DXMatrixRotationX - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around the Y axis -D3DXMATRIX* WINAPI D3DXMatrixRotationY - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around the Z axis -D3DXMATRIX* WINAPI D3DXMatrixRotationZ - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around an arbitrary axis -D3DXMATRIX* WINAPI D3DXMatrixRotationAxis - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); - -// Build a matrix from a quaternion -D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion - ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); - -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. -D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll - ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); - - -// Build transformation matrix. NULL arguments are treated as identity. -// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixTransformation - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, - CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, - CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, - CONST D3DXVECTOR3 *pTranslation); - -// Build affine transformation matrix. NULL arguments are treated as identity. -// Mout = Ms * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation - ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, - CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); - -// Build a lookat matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixLookAtRH - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, - CONST D3DXVECTOR3 *pUp ); - -// Build a lookat matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixLookAtLH - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, - CONST D3DXVECTOR3 *pUp ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH - ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH - ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build an ortho projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoRH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build an ortho projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoLH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build an ortho projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build an ortho projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build a matrix which flattens geometry into a plane, as if casting -// a shadow from a light. -D3DXMATRIX* WINAPI D3DXMatrixShadow - ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, - CONST D3DXPLANE *pPlane ); - -// Build a matrix which reflects the coordinate system about a plane -D3DXMATRIX* WINAPI D3DXMatrixReflect - ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Quaternion -//-------------------------- - -// inline - -FLOAT D3DXQuaternionLength - ( CONST D3DXQUATERNION *pQ ); - -// Length squared, or "norm" -FLOAT D3DXQuaternionLengthSq - ( CONST D3DXQUATERNION *pQ ); - -FLOAT D3DXQuaternionDot - ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); - -// (0, 0, 0, 1) -D3DXQUATERNION* D3DXQuaternionIdentity - ( D3DXQUATERNION *pOut ); - -BOOL D3DXQuaternionIsIdentity - ( CONST D3DXQUATERNION *pQ ); - -// (-x, -y, -z, w) -D3DXQUATERNION* D3DXQuaternionConjugate - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. -void WINAPI D3DXQuaternionToAxisAngle - ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); - -// Build a quaternion from a rotation matrix. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix - ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); - -// Rotation about arbitrary axis. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis - ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); - -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll - ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); - -// Quaternion multiplication. The result represents the rotation Q2 -// followed by the rotation Q1. (Out = Q2 * Q1) -D3DXQUATERNION* WINAPI D3DXQuaternionMultiply - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2 ); - -D3DXQUATERNION* WINAPI D3DXQuaternionNormalize - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Conjugate and re-norm -D3DXQUATERNION* WINAPI D3DXQuaternionInverse - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Expects unit quaternions. -// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) -D3DXQUATERNION* WINAPI D3DXQuaternionLn - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Expects pure quaternions. (w == 0) w is ignored in calculation. -// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) -D3DXQUATERNION* WINAPI D3DXQuaternionExp - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). -// Expects unit quaternions. -D3DXQUATERNION* WINAPI D3DXQuaternionSlerp - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, FLOAT t ); - -// Spherical quadrangle interpolation. -// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) -D3DXQUATERNION* WINAPI D3DXQuaternionSquad - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, - CONST D3DXQUATERNION *pC, FLOAT t ); - -// Setup control points for spherical quadrangle interpolation -// from Q1 to Q2. The control points are chosen in such a way -// to ensure the continuity of tangents with adjacent segments. -void WINAPI D3DXQuaternionSquadSetup - ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, - CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); - -// Barycentric interpolation. -// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) -D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, - FLOAT f, FLOAT g ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Plane -//-------------------------- - -// inline - -// ax + by + cz + dw -FLOAT D3DXPlaneDot - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); - -// ax + by + cz + d -FLOAT D3DXPlaneDotCoord - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); - -// ax + by + cz -FLOAT D3DXPlaneDotNormal - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Normalize plane (so that |a,b,c| == 1) -D3DXPLANE* WINAPI D3DXPlaneNormalize - ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); - -// Find the intersection between a plane and a line. If the line is -// parallel to the plane, NULL is returned. -D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine - ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, - CONST D3DXVECTOR3 *pV2); - -// Construct a plane from a point and a normal -D3DXPLANE* WINAPI D3DXPlaneFromPointNormal - ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); - -// Construct a plane from 3 points -D3DXPLANE* WINAPI D3DXPlaneFromPoints - ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - CONST D3DXVECTOR3 *pV3); - -// 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* WINAPI D3DXPlaneTransform - ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Color -//-------------------------- - -// inline - -// (1-r, 1-g, 1-b, a) -D3DXCOLOR* D3DXColorNegative - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); - -D3DXCOLOR* D3DXColorAdd - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -D3DXCOLOR* D3DXColorSubtract - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -D3DXCOLOR* D3DXColorScale - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); - -// (r1*r2, g1*g2, b1*b2, a1*a2) -D3DXCOLOR* D3DXColorModulate - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) -D3DXCOLOR* D3DXColorLerp - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Interpolate r,g,b between desaturated color and color. -// DesaturatedColor + s(Color - DesaturatedColor) -D3DXCOLOR* WINAPI D3DXColorAdjustSaturation - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); - -// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) -D3DXCOLOR* WINAPI D3DXColorAdjustContrast - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); - -#ifdef __cplusplus -} -#endif - - - - -//-------------------------- -// Misc -//-------------------------- - -#ifdef __cplusplus -extern "C" { -#endif - -// Calculate Fresnel term given the cosine of theta (likely obtained by -// taking the dot of two normals), and the refraction index of the material. -FLOAT WINAPI D3DXFresnelTerm - (FLOAT CosTheta, FLOAT RefractionIndex); - -#ifdef __cplusplus -} -#endif - - - -//=========================================================================== -// -// Matrix Stack -// -//=========================================================================== - -typedef interface ID3DXMatrixStack ID3DXMatrixStack; -typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; - -// {E3357330-CC5E-11d2-A434-00A0C90629A8} -DEFINE_GUID( IID_ID3DXMatrixStack, -0xe3357330, 0xcc5e, 0x11d2, 0xa4, 0x34, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); - - -#undef INTERFACE -#define INTERFACE ID3DXMatrixStack - -DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) -{ - // - // IUnknown methods - // - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - // - // ID3DXMatrixStack methods - // - - // Pops the top of the stack, returns the current top - // *after* popping the top. - STDMETHOD(Pop)(THIS) PURE; - - // Pushes the stack by one, duplicating the current matrix. - STDMETHOD(Push)(THIS) PURE; - - // Loads identity in the current matrix. - STDMETHOD(LoadIdentity)(THIS) PURE; - - // Loads the given matrix into the current matrix - STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Right-Multiplies the given matrix to the current matrix. - // (transformation is about the current world origin) - STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Left-Multiplies the given matrix to the current matrix - // (transformation is about the local origin of the object) - STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Right multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the current world origin) - STDMETHOD(RotateAxis) - (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - - // 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) - STDMETHOD(RotateAxisLocal) - (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - - // Right multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // current world origin) - - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. - STDMETHOD(RotateYawPitchRoll) - (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - - // Left multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // local origin of the object) - - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. - STDMETHOD(RotateYawPitchRollLocal) - (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - - // Right multiply the current matrix with the computed scale - // matrix. (transformation is about the current world origin) - STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - // Left multiply the current matrix with the computed scale - // matrix. (transformation is about the local origin of the object) - STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - // Right multiply the current matrix with the computed translation - // matrix. (transformation is about the current world origin) - STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; - - // Left multiply the current matrix with the computed translation - // matrix. (transformation is about the local origin of the object) - STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - // Obtain the current matrix at the top of the stack - STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; -}; - -#ifdef __cplusplus -extern "C" { -#endif - -HRESULT WINAPI - D3DXCreateMatrixStack( - DWORD Flags, - LPD3DXMATRIXSTACK* ppStack); - -#ifdef __cplusplus -} -#endif - -#include "d3dx8math.inl" - -#pragma warning(default:4201) - -#endif // __D3DX8MATH_H__ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8math.h +// Content: D3DX math types and functions +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8MATH_H__ +#define __D3DX8MATH_H__ + +#include +#pragma warning(disable:4201) // anonymous unions warning + + + +//=========================================================================== +// +// General purpose utilities +// +//=========================================================================== +#define D3DX_PI ((FLOAT) 3.141592654f) +#define D3DX_1BYPI ((FLOAT) 0.318309886f) + +#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) +#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) + + + +//=========================================================================== +// +// Vectors +// +//=========================================================================== + +//-------------------------- +// 2D Vector +//-------------------------- +typedef struct D3DXVECTOR2 +{ +#ifdef __cplusplus +public: + D3DXVECTOR2() {}; + D3DXVECTOR2( CONST FLOAT * ); + D3DXVECTOR2( FLOAT x, FLOAT y ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR2& operator += ( CONST D3DXVECTOR2& ); + D3DXVECTOR2& operator -= ( CONST D3DXVECTOR2& ); + D3DXVECTOR2& operator *= ( FLOAT ); + D3DXVECTOR2& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR2 operator + () const; + D3DXVECTOR2 operator - () const; + + // binary operators + D3DXVECTOR2 operator + ( CONST D3DXVECTOR2& ) const; + D3DXVECTOR2 operator - ( CONST D3DXVECTOR2& ) const; + D3DXVECTOR2 operator * ( FLOAT ) const; + D3DXVECTOR2 operator / ( FLOAT ) const; + + friend D3DXVECTOR2 operator * ( FLOAT, CONST D3DXVECTOR2& ); + + BOOL operator == ( CONST D3DXVECTOR2& ) const; + BOOL operator != ( CONST D3DXVECTOR2& ) const; + + +public: +#endif //__cplusplus + FLOAT x, y; +} D3DXVECTOR2, *LPD3DXVECTOR2; + + +//-------------------------- +// 3D Vector +//-------------------------- +#ifdef __cplusplus +typedef struct D3DXVECTOR3 : public D3DVECTOR +{ +public: + D3DXVECTOR3() {}; + D3DXVECTOR3( CONST FLOAT * ); + D3DXVECTOR3( CONST D3DVECTOR& ); + D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); + D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& ); + D3DXVECTOR3& operator *= ( FLOAT ); + D3DXVECTOR3& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR3 operator + () const; + D3DXVECTOR3 operator - () const; + + // binary operators + D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const; + D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const; + D3DXVECTOR3 operator * ( FLOAT ) const; + D3DXVECTOR3 operator / ( FLOAT ) const; + + friend D3DXVECTOR3 operator * ( FLOAT, CONST struct D3DXVECTOR3& ); + + BOOL operator == ( CONST D3DXVECTOR3& ) const; + BOOL operator != ( CONST D3DXVECTOR3& ) const; + +} D3DXVECTOR3, *LPD3DXVECTOR3; + +#else //!__cplusplus +typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; +#endif //!__cplusplus + + +//-------------------------- +// 4D Vector +//-------------------------- +typedef struct D3DXVECTOR4 +{ +#ifdef __cplusplus +public: + D3DXVECTOR4() {}; + D3DXVECTOR4( CONST FLOAT* ); + D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& ); + D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& ); + D3DXVECTOR4& operator *= ( FLOAT ); + D3DXVECTOR4& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR4 operator + () const; + D3DXVECTOR4 operator - () const; + + // binary operators + D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const; + D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const; + D3DXVECTOR4 operator * ( FLOAT ) const; + D3DXVECTOR4 operator / ( FLOAT ) const; + + friend D3DXVECTOR4 operator * ( FLOAT, CONST D3DXVECTOR4& ); + + BOOL operator == ( CONST D3DXVECTOR4& ) const; + BOOL operator != ( CONST D3DXVECTOR4& ) const; + +public: +#endif //__cplusplus + FLOAT x, y, z, w; +} D3DXVECTOR4, *LPD3DXVECTOR4; + + +//=========================================================================== +// +// Matrices +// +//=========================================================================== +#ifdef __cplusplus +typedef struct D3DXMATRIX : public D3DMATRIX +{ +public: + D3DXMATRIX() {}; + D3DXMATRIX( CONST FLOAT * ); + D3DXMATRIX( CONST D3DMATRIX& ); + D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, + FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, + FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, + FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); + + + // access grants + FLOAT& operator () ( UINT Row, UINT Col ); + FLOAT operator () ( UINT Row, UINT Col ) const; + + // casting operators + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXMATRIX& operator *= ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator += ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator -= ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator *= ( FLOAT ); + D3DXMATRIX& operator /= ( FLOAT ); + + // unary operators + D3DXMATRIX operator + () const; + D3DXMATRIX operator - () const; + + // binary operators + D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator * ( FLOAT ) const; + D3DXMATRIX operator / ( FLOAT ) const; + + friend D3DXMATRIX operator * ( FLOAT, CONST D3DXMATRIX& ); + + BOOL operator == ( CONST D3DXMATRIX& ) const; + BOOL operator != ( CONST D3DXMATRIX& ) const; + +} D3DXMATRIX, *LPD3DXMATRIX; + +#else //!__cplusplus +typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; +#endif //!__cplusplus + +//=========================================================================== +// +// Aligned Matrices +// +// This class helps keep matrices 16-byte aligned as preferred by P4 cpus. +// It aligns matrices on the stack and on the heap or in global scope. +// It does this using __declspec(align(16)) which works on VC7 and on VC 6 +// with the processor pack. Unfortunately there is no way to detect the +// latter so this is turned on only on VC7. On other compilers this is the +// the same as D3DXMATRIX. +// Using this class on a compiler that does not actually do the alignment +// can be dangerous since it will not expose bugs that ignore alignment. +// E.g if an object of this class in inside a struct or class, and some code +// memcopys data in it assuming tight packing. This could break on a compiler +// that eventually start aligning the matrix. +// +//=========================================================================== +#ifdef __cplusplus +typedef struct _D3DXMATRIXA16 : public D3DXMATRIX +{ + _D3DXMATRIXA16() {} + _D3DXMATRIXA16( CONST FLOAT * f): D3DXMATRIX(f) {} + _D3DXMATRIXA16( CONST D3DMATRIX& m): D3DXMATRIX(m) {} + _D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, + FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, + FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, + FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ) : + D3DXMATRIX(_11, _12, _13, _14, + _21, _22, _23, _24, + _31, _32, _33, _34, + _41, _42, _43, _44) {} + void* operator new(size_t s) + { + LPBYTE p = ::new BYTE[s + 16]; + if (p) + { + BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); + p += offset; + p[-1] = offset; + } + return p; + }; + + void* operator new[](size_t s) + { + LPBYTE p = ::new BYTE[s + 16]; + if (p) + { + BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); + p += offset; + p[-1] = offset; + } + return p; + }; + + // This is NOT a virtual operator. If you cast + // to D3DXMATRIX, do not delete using that + void operator delete(void* p) + { + if(p) + { + BYTE* pb = static_cast(p); + pb -= pb[-1]; + ::delete [] pb; + } + }; + + // This is NOT a virtual operator. If you cast + // to D3DXMATRIX, do not delete using that + void operator delete[](void* p) + { + if(p) + { + BYTE* pb = static_cast(p); + pb -= pb[-1]; + ::delete [] pb; + } + }; + + struct _D3DXMATRIXA16& operator=(CONST D3DXMATRIX& rhs) + { + memcpy(&_11, &rhs, sizeof(D3DXMATRIX)); + return *this; + }; +} _D3DXMATRIXA16; + +#else //!__cplusplus +typedef D3DXMATRIX _D3DXMATRIXA16; +#endif //!__cplusplus + +#if _MSC_VER >= 1300 // VC7 +#define _ALIGN_16 __declspec(align(16)) +#else +#define _ALIGN_16 // Earlier compiler may not understand this, do nothing. +#endif + +#define D3DXMATRIXA16 _ALIGN_16 _D3DXMATRIXA16 + +typedef D3DXMATRIXA16 *LPD3DXMATRIXA16; + +//=========================================================================== +// +// Quaternions +// +//=========================================================================== +typedef struct D3DXQUATERNION +{ +#ifdef __cplusplus +public: + D3DXQUATERNION() {} + D3DXQUATERNION( CONST FLOAT * ); + D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXQUATERNION& operator += ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator -= ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator *= ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator *= ( FLOAT ); + D3DXQUATERNION& operator /= ( FLOAT ); + + // unary operators + D3DXQUATERNION operator + () const; + D3DXQUATERNION operator - () const; + + // binary operators + D3DXQUATERNION operator + ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator - ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator * ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator * ( FLOAT ) const; + D3DXQUATERNION operator / ( FLOAT ) const; + + friend D3DXQUATERNION operator * (FLOAT, CONST D3DXQUATERNION& ); + + BOOL operator == ( CONST D3DXQUATERNION& ) const; + BOOL operator != ( CONST D3DXQUATERNION& ) const; + +#endif //__cplusplus + FLOAT x, y, z, w; +} D3DXQUATERNION, *LPD3DXQUATERNION; + + +//=========================================================================== +// +// Planes +// +//=========================================================================== +typedef struct D3DXPLANE +{ +#ifdef __cplusplus +public: + D3DXPLANE() {} + D3DXPLANE( CONST FLOAT* ); + D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // unary operators + D3DXPLANE operator + () const; + D3DXPLANE operator - () const; + + // binary operators + BOOL operator == ( CONST D3DXPLANE& ) const; + BOOL operator != ( CONST D3DXPLANE& ) const; + +#endif //__cplusplus + FLOAT a, b, c, d; +} D3DXPLANE, *LPD3DXPLANE; + + +//=========================================================================== +// +// Colors +// +//=========================================================================== + +typedef struct D3DXCOLOR +{ +#ifdef __cplusplus +public: + D3DXCOLOR() {} + D3DXCOLOR( DWORD argb ); + D3DXCOLOR( CONST FLOAT * ); + D3DXCOLOR( CONST D3DCOLORVALUE& ); + D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); + + // casting + operator DWORD () const; + + operator FLOAT* (); + operator CONST FLOAT* () const; + + operator D3DCOLORVALUE* (); + operator CONST D3DCOLORVALUE* () const; + + operator D3DCOLORVALUE& (); + operator CONST D3DCOLORVALUE& () const; + + // assignment operators + D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); + D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); + D3DXCOLOR& operator *= ( FLOAT ); + D3DXCOLOR& operator /= ( FLOAT ); + + // unary operators + D3DXCOLOR operator + () const; + D3DXCOLOR operator - () const; + + // binary operators + D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; + D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; + D3DXCOLOR operator * ( FLOAT ) const; + D3DXCOLOR operator / ( FLOAT ) const; + + friend D3DXCOLOR operator * (FLOAT, CONST D3DXCOLOR& ); + + BOOL operator == ( CONST D3DXCOLOR& ) const; + BOOL operator != ( CONST D3DXCOLOR& ) const; + +#endif //__cplusplus + FLOAT r, g, b, a; +} D3DXCOLOR, *LPD3DXCOLOR; + + + +//=========================================================================== +// +// D3DX math functions: +// +// NOTE: +// * All these functions can take the same object as in and out parameters. +// +// * Out parameters are typically also returned as return values, so that +// the output of one function may be used as a parameter to another. +// +//=========================================================================== + +//-------------------------- +// 2D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec2Length + ( CONST D3DXVECTOR2 *pV ); + +FLOAT D3DXVec2LengthSq + ( CONST D3DXVECTOR2 *pV ); + +FLOAT D3DXVec2Dot + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Z component of ((x1,y1,0) cross (x2,y2,0)) +FLOAT D3DXVec2CCW + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Add + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Subtract + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2) +D3DXVECTOR2* D3DXVec2Minimize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2) +D3DXVECTOR2* D3DXVec2Maximize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Scale + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR2* D3DXVec2Lerp + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +D3DXVECTOR2* WINAPI D3DXVec2Normalize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR2* WINAPI D3DXVec2Hermite + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, + CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR2* WINAPI D3DXVec2CatmullRom + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, + CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR2* WINAPI D3DXVec2BaryCentric + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); + +// Transform (x, y, 0, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec2Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, 0, 1) by matrix, project result back into w=1. +D3DXVECTOR2* WINAPI D3DXVec2TransformCoord + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, 0, 0) by matrix. +D3DXVECTOR2* WINAPI D3DXVec2TransformNormal + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 3D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec3Length + ( CONST D3DXVECTOR3 *pV ); + +FLOAT D3DXVec3LengthSq + ( CONST D3DXVECTOR3 *pV ); + +FLOAT D3DXVec3Dot + ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Cross + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Add + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Subtract + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +D3DXVECTOR3* D3DXVec3Minimize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +D3DXVECTOR3* D3DXVec3Maximize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Scale + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR3* D3DXVec3Lerp + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +D3DXVECTOR3* WINAPI D3DXVec3Normalize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR3* WINAPI D3DXVec3Hermite + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, + CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR3* WINAPI D3DXVec3CatmullRom + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, + CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR3* WINAPI D3DXVec3BaryCentric + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); + +// Transform (x, y, z, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec3Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, z, 1) by matrix, project result back into w=1. +D3DXVECTOR3* WINAPI D3DXVec3TransformCoord + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, z, 0) by matrix. If you transforming a normal by a +// non-affine matrix, the matrix you pass to this function should be the +// transpose of the inverse of the matrix you would use to transform a coord. +D3DXVECTOR3* WINAPI D3DXVec3TransformNormal + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Project vector from object space into screen space +D3DXVECTOR3* WINAPI D3DXVec3Project + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); + +// Project vector from screen space into object space +D3DXVECTOR3* WINAPI D3DXVec3Unproject + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); + +#ifdef __cplusplus +} +#endif + + + +//-------------------------- +// 4D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec4Length + ( CONST D3DXVECTOR4 *pV ); + +FLOAT D3DXVec4LengthSq + ( CONST D3DXVECTOR4 *pV ); + +FLOAT D3DXVec4Dot + ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ); + +D3DXVECTOR4* D3DXVec4Add + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +D3DXVECTOR4* D3DXVec4Subtract + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +D3DXVECTOR4* D3DXVec4Minimize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +D3DXVECTOR4* D3DXVec4Maximize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +D3DXVECTOR4* D3DXVec4Scale + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR4* D3DXVec4Lerp + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Cross-product in 4 dimensions. +D3DXVECTOR4* WINAPI D3DXVec4Cross + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + CONST D3DXVECTOR4 *pV3); + +D3DXVECTOR4* WINAPI D3DXVec4Normalize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR4* WINAPI D3DXVec4Hermite + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, + CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR4* WINAPI D3DXVec4CatmullRom + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, + CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR4* WINAPI D3DXVec4BaryCentric + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); + +// Transform vector by matrix. +D3DXVECTOR4* WINAPI D3DXVec4Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 4D Matrix +//-------------------------- + +// inline + +D3DXMATRIX* D3DXMatrixIdentity + ( D3DXMATRIX *pOut ); + +BOOL D3DXMatrixIsIdentity + ( CONST D3DXMATRIX *pM ); + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +FLOAT WINAPI D3DXMatrixfDeterminant + ( CONST D3DXMATRIX *pM ); + +D3DXMATRIX* WINAPI D3DXMatrixTranspose + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); + +// Matrix multiplication. The result represents the transformation M2 +// followed by the transformation M1. (Out = M1 * M2) +D3DXMATRIX* WINAPI D3DXMatrixMultiply + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); + +// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) +D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); + +// Calculate inverse of matrix. Inversion my fail, in which case NULL will +// be returned. The determinant of pM is also returned it pfDeterminant +// is non-NULL. +D3DXMATRIX* WINAPI D3DXMatrixInverse + ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); + +// Build a matrix which scales by (sx, sy, sz) +D3DXMATRIX* WINAPI D3DXMatrixScaling + ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); + +// Build a matrix which translates by (x, y, z) +D3DXMATRIX* WINAPI D3DXMatrixTranslation + ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); + +// Build a matrix which rotates around the X axis +D3DXMATRIX* WINAPI D3DXMatrixRotationX + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around the Y axis +D3DXMATRIX* WINAPI D3DXMatrixRotationY + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around the Z axis +D3DXMATRIX* WINAPI D3DXMatrixRotationZ + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around an arbitrary axis +D3DXMATRIX* WINAPI D3DXMatrixRotationAxis + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); + +// Build a matrix from a quaternion +D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion + ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); + +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. +D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll + ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); + + +// Build transformation matrix. NULL arguments are treated as identity. +// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixTransformation + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, + CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, + CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, + CONST D3DXVECTOR3 *pTranslation); + +// Build affine transformation matrix. NULL arguments are treated as identity. +// Mout = Ms * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation + ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, + CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); + +// Build a lookat matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixLookAtRH + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, + CONST D3DXVECTOR3 *pUp ); + +// Build a lookat matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixLookAtLH + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, + CONST D3DXVECTOR3 *pUp ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH + ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH + ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoRH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build an ortho projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoLH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build an ortho projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build a matrix which flattens geometry into a plane, as if casting +// a shadow from a light. +D3DXMATRIX* WINAPI D3DXMatrixShadow + ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, + CONST D3DXPLANE *pPlane ); + +// Build a matrix which reflects the coordinate system about a plane +D3DXMATRIX* WINAPI D3DXMatrixReflect + ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Quaternion +//-------------------------- + +// inline + +FLOAT D3DXQuaternionLength + ( CONST D3DXQUATERNION *pQ ); + +// Length squared, or "norm" +FLOAT D3DXQuaternionLengthSq + ( CONST D3DXQUATERNION *pQ ); + +FLOAT D3DXQuaternionDot + ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); + +// (0, 0, 0, 1) +D3DXQUATERNION* D3DXQuaternionIdentity + ( D3DXQUATERNION *pOut ); + +BOOL D3DXQuaternionIsIdentity + ( CONST D3DXQUATERNION *pQ ); + +// (-x, -y, -z, w) +D3DXQUATERNION* D3DXQuaternionConjugate + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. +void WINAPI D3DXQuaternionToAxisAngle + ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); + +// Build a quaternion from a rotation matrix. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix + ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); + +// Rotation about arbitrary axis. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis + ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); + +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll + ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); + +// Quaternion multiplication. The result represents the rotation Q2 +// followed by the rotation Q1. (Out = Q2 * Q1) +D3DXQUATERNION* WINAPI D3DXQuaternionMultiply + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2 ); + +D3DXQUATERNION* WINAPI D3DXQuaternionNormalize + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Conjugate and re-norm +D3DXQUATERNION* WINAPI D3DXQuaternionInverse + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Expects unit quaternions. +// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) +D3DXQUATERNION* WINAPI D3DXQuaternionLn + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Expects pure quaternions. (w == 0) w is ignored in calculation. +// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) +D3DXQUATERNION* WINAPI D3DXQuaternionExp + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). +// Expects unit quaternions. +D3DXQUATERNION* WINAPI D3DXQuaternionSlerp + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, FLOAT t ); + +// Spherical quadrangle interpolation. +// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) +D3DXQUATERNION* WINAPI D3DXQuaternionSquad + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, + CONST D3DXQUATERNION *pC, FLOAT t ); + +// Setup control points for spherical quadrangle interpolation +// from Q1 to Q2. The control points are chosen in such a way +// to ensure the continuity of tangents with adjacent segments. +void WINAPI D3DXQuaternionSquadSetup + ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, + CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); + +// Barycentric interpolation. +// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) +D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, + FLOAT f, FLOAT g ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Plane +//-------------------------- + +// inline + +// ax + by + cz + dw +FLOAT D3DXPlaneDot + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); + +// ax + by + cz + d +FLOAT D3DXPlaneDotCoord + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); + +// ax + by + cz +FLOAT D3DXPlaneDotNormal + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Normalize plane (so that |a,b,c| == 1) +D3DXPLANE* WINAPI D3DXPlaneNormalize + ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); + +// Find the intersection between a plane and a line. If the line is +// parallel to the plane, NULL is returned. +D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine + ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, + CONST D3DXVECTOR3 *pV2); + +// Construct a plane from a point and a normal +D3DXPLANE* WINAPI D3DXPlaneFromPointNormal + ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); + +// Construct a plane from 3 points +D3DXPLANE* WINAPI D3DXPlaneFromPoints + ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + CONST D3DXVECTOR3 *pV3); + +// 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* WINAPI D3DXPlaneTransform + ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Color +//-------------------------- + +// inline + +// (1-r, 1-g, 1-b, a) +D3DXCOLOR* D3DXColorNegative + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); + +D3DXCOLOR* D3DXColorAdd + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +D3DXCOLOR* D3DXColorSubtract + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +D3DXCOLOR* D3DXColorScale + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); + +// (r1*r2, g1*g2, b1*b2, a1*a2) +D3DXCOLOR* D3DXColorModulate + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) +D3DXCOLOR* D3DXColorLerp + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Interpolate r,g,b between desaturated color and color. +// DesaturatedColor + s(Color - DesaturatedColor) +D3DXCOLOR* WINAPI D3DXColorAdjustSaturation + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); + +// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) +D3DXCOLOR* WINAPI D3DXColorAdjustContrast + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); + +#ifdef __cplusplus +} +#endif + + + + +//-------------------------- +// Misc +//-------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +// Calculate Fresnel term given the cosine of theta (likely obtained by +// taking the dot of two normals), and the refraction index of the material. +FLOAT WINAPI D3DXFresnelTerm + (FLOAT CosTheta, FLOAT RefractionIndex); + +#ifdef __cplusplus +} +#endif + + + +//=========================================================================== +// +// Matrix Stack +// +//=========================================================================== + +typedef interface ID3DXMatrixStack ID3DXMatrixStack; +typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; + +// {E3357330-CC5E-11d2-A434-00A0C90629A8} +DEFINE_GUID( IID_ID3DXMatrixStack, +0xe3357330, 0xcc5e, 0x11d2, 0xa4, 0x34, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); + + +#undef INTERFACE +#define INTERFACE ID3DXMatrixStack + +DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) +{ + // + // IUnknown methods + // + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // + // ID3DXMatrixStack methods + // + + // Pops the top of the stack, returns the current top + // *after* popping the top. + STDMETHOD(Pop)(THIS) PURE; + + // Pushes the stack by one, duplicating the current matrix. + STDMETHOD(Push)(THIS) PURE; + + // Loads identity in the current matrix. + STDMETHOD(LoadIdentity)(THIS) PURE; + + // Loads the given matrix into the current matrix + STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Right-Multiplies the given matrix to the current matrix. + // (transformation is about the current world origin) + STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Left-Multiplies the given matrix to the current matrix + // (transformation is about the local origin of the object) + STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Right multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the current world origin) + STDMETHOD(RotateAxis) + (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; + + // 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) + STDMETHOD(RotateAxisLocal) + (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; + + // Right multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // current world origin) + + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. + STDMETHOD(RotateYawPitchRoll) + (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; + + // Left multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // local origin of the object) + + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. + STDMETHOD(RotateYawPitchRollLocal) + (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; + + // Right multiply the current matrix with the computed scale + // matrix. (transformation is about the current world origin) + STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Left multiply the current matrix with the computed scale + // matrix. (transformation is about the local origin of the object) + STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Right multiply the current matrix with the computed translation + // matrix. (transformation is about the current world origin) + STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; + + // Left multiply the current matrix with the computed translation + // matrix. (transformation is about the local origin of the object) + STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Obtain the current matrix at the top of the stack + STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +HRESULT WINAPI + D3DXCreateMatrixStack( + DWORD Flags, + LPD3DXMATRIXSTACK* ppStack); + +#ifdef __cplusplus +} +#endif + +#include "d3dx8math.inl" + +#pragma warning(default:4201) + +#endif // __D3DX8MATH_H__ diff --git a/src/dep/include/DXSDK/include/d3dx8math.inl b/src/dep/include/DXSDK/include/d3dx8math.inl index c1f465c..a64e5c5 100644 --- a/src/dep/include/DXSDK/include/d3dx8math.inl +++ b/src/dep/include/DXSDK/include/d3dx8math.inl @@ -1,1757 +1,1757 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8math.inl -// Content: D3DX math inline functions -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DX8MATH_INL__ -#define __D3DX8MATH_INL__ - - -//=========================================================================== -// -// Inline Class Methods -// -//=========================================================================== - -#ifdef __cplusplus - -//-------------------------- -// 2D Vector -//-------------------------- - -D3DXINLINE -D3DXVECTOR2::D3DXVECTOR2( CONST FLOAT *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; -} - -D3DXINLINE -D3DXVECTOR2::D3DXVECTOR2( FLOAT fx, FLOAT fy ) -{ - x = fx; - y = fy; -} - -// casting -D3DXINLINE -D3DXVECTOR2::operator FLOAT* () -{ - return (FLOAT *) &x; -} - -D3DXINLINE -D3DXVECTOR2::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &x; -} - -// assignment operators -D3DXINLINE D3DXVECTOR2& -D3DXVECTOR2::operator += ( CONST D3DXVECTOR2& v ) -{ - x += v.x; - y += v.y; - return *this; -} - -D3DXINLINE D3DXVECTOR2& -D3DXVECTOR2::operator -= ( CONST D3DXVECTOR2& v ) -{ - x -= v.x; - y -= v.y; - return *this; -} - -D3DXINLINE D3DXVECTOR2& -D3DXVECTOR2::operator *= ( FLOAT f ) -{ - x *= f; - y *= f; - return *this; -} - -D3DXINLINE D3DXVECTOR2& -D3DXVECTOR2::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - x *= fInv; - y *= fInv; - return *this; -} - -// unary operators -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator - () const -{ - return D3DXVECTOR2(-x, -y); -} - -// binary operators -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator + ( CONST D3DXVECTOR2& v ) const -{ - return D3DXVECTOR2(x + v.x, y + v.y); -} - -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator - ( CONST D3DXVECTOR2& v ) const -{ - return D3DXVECTOR2(x - v.x, y - v.y); -} - -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator * ( FLOAT f ) const -{ - return D3DXVECTOR2(x * f, y * f); -} - -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXVECTOR2(x * fInv, y * fInv); -} - - -D3DXINLINE D3DXVECTOR2 -operator * ( FLOAT f, CONST D3DXVECTOR2& v ) -{ - return D3DXVECTOR2(f * v.x, f * v.y); -} - -D3DXINLINE BOOL -D3DXVECTOR2::operator == ( CONST D3DXVECTOR2& v ) const -{ - return x == v.x && y == v.y; -} - -D3DXINLINE BOOL -D3DXVECTOR2::operator != ( CONST D3DXVECTOR2& v ) const -{ - return x != v.x || y != v.y; -} - - - - -//-------------------------- -// 3D Vector -//-------------------------- -D3DXINLINE -D3DXVECTOR3::D3DXVECTOR3( CONST FLOAT *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; - z = pf[2]; -} - -D3DXINLINE -D3DXVECTOR3::D3DXVECTOR3( CONST D3DVECTOR& v ) -{ - x = v.x; - y = v.y; - z = v.z; -} - -D3DXINLINE -D3DXVECTOR3::D3DXVECTOR3( FLOAT fx, FLOAT fy, FLOAT fz ) -{ - x = fx; - y = fy; - z = fz; -} - - -// casting -D3DXINLINE -D3DXVECTOR3::operator FLOAT* () -{ - return (FLOAT *) &x; -} - -D3DXINLINE -D3DXVECTOR3::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &x; -} - - -// assignment operators -D3DXINLINE D3DXVECTOR3& -D3DXVECTOR3::operator += ( CONST D3DXVECTOR3& v ) -{ - x += v.x; - y += v.y; - z += v.z; - return *this; -} - -D3DXINLINE D3DXVECTOR3& -D3DXVECTOR3::operator -= ( CONST D3DXVECTOR3& v ) -{ - x -= v.x; - y -= v.y; - z -= v.z; - return *this; -} - -D3DXINLINE D3DXVECTOR3& -D3DXVECTOR3::operator *= ( FLOAT f ) -{ - x *= f; - y *= f; - z *= f; - return *this; -} - -D3DXINLINE D3DXVECTOR3& -D3DXVECTOR3::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - x *= fInv; - y *= fInv; - z *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator - () const -{ - return D3DXVECTOR3(-x, -y, -z); -} - - -// binary operators -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator + ( CONST D3DXVECTOR3& v ) const -{ - return D3DXVECTOR3(x + v.x, y + v.y, z + v.z); -} - -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator - ( CONST D3DXVECTOR3& v ) const -{ - return D3DXVECTOR3(x - v.x, y - v.y, z - v.z); -} - -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator * ( FLOAT f ) const -{ - return D3DXVECTOR3(x * f, y * f, z * f); -} - -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXVECTOR3(x * fInv, y * fInv, z * fInv); -} - - -D3DXINLINE D3DXVECTOR3 -operator * ( FLOAT f, CONST struct D3DXVECTOR3& v ) -{ - return D3DXVECTOR3(f * v.x, f * v.y, f * v.z); -} - - -D3DXINLINE BOOL -D3DXVECTOR3::operator == ( CONST D3DXVECTOR3& v ) const -{ - return x == v.x && y == v.y && z == v.z; -} - -D3DXINLINE BOOL -D3DXVECTOR3::operator != ( CONST D3DXVECTOR3& v ) const -{ - return x != v.x || y != v.y || z != v.z; -} - - - -//-------------------------- -// 4D Vector -//-------------------------- -D3DXINLINE -D3DXVECTOR4::D3DXVECTOR4( CONST FLOAT *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; - z = pf[2]; - w = pf[3]; -} - -D3DXINLINE -D3DXVECTOR4::D3DXVECTOR4( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) -{ - x = fx; - y = fy; - z = fz; - w = fw; -} - - -// casting -D3DXINLINE -D3DXVECTOR4::operator FLOAT* () -{ - return (FLOAT *) &x; -} - -D3DXINLINE -D3DXVECTOR4::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &x; -} - - -// assignment operators -D3DXINLINE D3DXVECTOR4& -D3DXVECTOR4::operator += ( CONST D3DXVECTOR4& v ) -{ - x += v.x; - y += v.y; - z += v.z; - w += v.w; - return *this; -} - -D3DXINLINE D3DXVECTOR4& -D3DXVECTOR4::operator -= ( CONST D3DXVECTOR4& v ) -{ - x -= v.x; - y -= v.y; - z -= v.z; - w -= v.w; - return *this; -} - -D3DXINLINE D3DXVECTOR4& -D3DXVECTOR4::operator *= ( FLOAT f ) -{ - x *= f; - y *= f; - z *= f; - w *= f; - return *this; -} - -D3DXINLINE D3DXVECTOR4& -D3DXVECTOR4::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - x *= fInv; - y *= fInv; - z *= fInv; - w *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator - () const -{ - return D3DXVECTOR4(-x, -y, -z, -w); -} - - -// binary operators -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator + ( CONST D3DXVECTOR4& v ) const -{ - return D3DXVECTOR4(x + v.x, y + v.y, z + v.z, w + v.w); -} - -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator - ( CONST D3DXVECTOR4& v ) const -{ - return D3DXVECTOR4(x - v.x, y - v.y, z - v.z, w - v.w); -} - -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator * ( FLOAT f ) const -{ - return D3DXVECTOR4(x * f, y * f, z * f, w * f); -} - -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXVECTOR4(x * fInv, y * fInv, z * fInv, w * fInv); -} - - -D3DXINLINE D3DXVECTOR4 -operator * ( FLOAT f, CONST D3DXVECTOR4& v ) -{ - return D3DXVECTOR4(f * v.x, f * v.y, f * v.z, f * v.w); -} - - -D3DXINLINE BOOL -D3DXVECTOR4::operator == ( CONST D3DXVECTOR4& v ) const -{ - return x == v.x && y == v.y && z == v.z && w == v.w; -} - -D3DXINLINE BOOL -D3DXVECTOR4::operator != ( CONST D3DXVECTOR4& v ) const -{ - return x != v.x || y != v.y || z != v.z || w != v.w; -} - - -//-------------------------- -// Matrix -//-------------------------- -D3DXINLINE -D3DXMATRIX::D3DXMATRIX( CONST FLOAT* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - memcpy(&_11, pf, sizeof(D3DXMATRIX)); -} - -D3DXINLINE -D3DXMATRIX::D3DXMATRIX( CONST D3DMATRIX& mat ) -{ - memcpy(&_11, &mat, sizeof(D3DXMATRIX)); -} - -D3DXINLINE -D3DXMATRIX::D3DXMATRIX( FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14, - FLOAT f21, FLOAT f22, FLOAT f23, FLOAT f24, - FLOAT f31, FLOAT f32, FLOAT f33, FLOAT f34, - FLOAT f41, FLOAT f42, FLOAT f43, FLOAT f44 ) -{ - _11 = f11; _12 = f12; _13 = f13; _14 = f14; - _21 = f21; _22 = f22; _23 = f23; _24 = f24; - _31 = f31; _32 = f32; _33 = f33; _34 = f34; - _41 = f41; _42 = f42; _43 = f43; _44 = f44; -} - - - -// access grants -D3DXINLINE FLOAT& -D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) -{ - return m[iRow][iCol]; -} - -D3DXINLINE FLOAT -D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) const -{ - return m[iRow][iCol]; -} - - -// casting operators -D3DXINLINE -D3DXMATRIX::operator FLOAT* () -{ - return (FLOAT *) &_11; -} - -D3DXINLINE -D3DXMATRIX::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &_11; -} - - -// assignment operators -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator *= ( CONST D3DXMATRIX& mat ) -{ - D3DXMatrixMultiply(this, this, &mat); - return *this; -} - -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator += ( CONST D3DXMATRIX& mat ) -{ - _11 += mat._11; _12 += mat._12; _13 += mat._13; _14 += mat._14; - _21 += mat._21; _22 += mat._22; _23 += mat._23; _24 += mat._24; - _31 += mat._31; _32 += mat._32; _33 += mat._33; _34 += mat._34; - _41 += mat._41; _42 += mat._42; _43 += mat._43; _44 += mat._44; - return *this; -} - -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator -= ( CONST D3DXMATRIX& mat ) -{ - _11 -= mat._11; _12 -= mat._12; _13 -= mat._13; _14 -= mat._14; - _21 -= mat._21; _22 -= mat._22; _23 -= mat._23; _24 -= mat._24; - _31 -= mat._31; _32 -= mat._32; _33 -= mat._33; _34 -= mat._34; - _41 -= mat._41; _42 -= mat._42; _43 -= mat._43; _44 -= mat._44; - return *this; -} - -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator *= ( FLOAT f ) -{ - _11 *= f; _12 *= f; _13 *= f; _14 *= f; - _21 *= f; _22 *= f; _23 *= f; _24 *= f; - _31 *= f; _32 *= f; _33 *= f; _34 *= f; - _41 *= f; _42 *= f; _43 *= f; _44 *= f; - return *this; -} - -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - _11 *= fInv; _12 *= fInv; _13 *= fInv; _14 *= fInv; - _21 *= fInv; _22 *= fInv; _23 *= fInv; _24 *= fInv; - _31 *= fInv; _32 *= fInv; _33 *= fInv; _34 *= fInv; - _41 *= fInv; _42 *= fInv; _43 *= fInv; _44 *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator - () const -{ - return D3DXMATRIX(-_11, -_12, -_13, -_14, - -_21, -_22, -_23, -_24, - -_31, -_32, -_33, -_34, - -_41, -_42, -_43, -_44); -} - - -// binary operators -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator * ( CONST D3DXMATRIX& mat ) const -{ - D3DXMATRIX matT; - D3DXMatrixMultiply(&matT, this, &mat); - return matT; -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator + ( CONST D3DXMATRIX& mat ) const -{ - return D3DXMATRIX(_11 + mat._11, _12 + mat._12, _13 + mat._13, _14 + mat._14, - _21 + mat._21, _22 + mat._22, _23 + mat._23, _24 + mat._24, - _31 + mat._31, _32 + mat._32, _33 + mat._33, _34 + mat._34, - _41 + mat._41, _42 + mat._42, _43 + mat._43, _44 + mat._44); -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator - ( CONST D3DXMATRIX& mat ) const -{ - return D3DXMATRIX(_11 - mat._11, _12 - mat._12, _13 - mat._13, _14 - mat._14, - _21 - mat._21, _22 - mat._22, _23 - mat._23, _24 - mat._24, - _31 - mat._31, _32 - mat._32, _33 - mat._33, _34 - mat._34, - _41 - mat._41, _42 - mat._42, _43 - mat._43, _44 - mat._44); -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator * ( FLOAT f ) const -{ - return D3DXMATRIX(_11 * f, _12 * f, _13 * f, _14 * f, - _21 * f, _22 * f, _23 * f, _24 * f, - _31 * f, _32 * f, _33 * f, _34 * f, - _41 * f, _42 * f, _43 * f, _44 * f); -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXMATRIX(_11 * fInv, _12 * fInv, _13 * fInv, _14 * fInv, - _21 * fInv, _22 * fInv, _23 * fInv, _24 * fInv, - _31 * fInv, _32 * fInv, _33 * fInv, _34 * fInv, - _41 * fInv, _42 * fInv, _43 * fInv, _44 * fInv); -} - - -D3DXINLINE D3DXMATRIX -operator * ( FLOAT f, CONST D3DXMATRIX& mat ) -{ - return D3DXMATRIX(f * mat._11, f * mat._12, f * mat._13, f * mat._14, - f * mat._21, f * mat._22, f * mat._23, f * mat._24, - f * mat._31, f * mat._32, f * mat._33, f * mat._34, - f * mat._41, f * mat._42, f * mat._43, f * mat._44); -} - - -D3DXINLINE BOOL -D3DXMATRIX::operator == ( CONST D3DXMATRIX& mat ) const -{ - return 0 == memcmp(this, &mat, sizeof(D3DXMATRIX)); -} - -D3DXINLINE BOOL -D3DXMATRIX::operator != ( CONST D3DXMATRIX& mat ) const -{ - return 0 != memcmp(this, &mat, sizeof(D3DXMATRIX)); -} - - - -//-------------------------- -// Quaternion -//-------------------------- - -D3DXINLINE -D3DXQUATERNION::D3DXQUATERNION( CONST FLOAT* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; - z = pf[2]; - w = pf[3]; -} - -D3DXINLINE -D3DXQUATERNION::D3DXQUATERNION( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) -{ - x = fx; - y = fy; - z = fz; - w = fw; -} - - -// casting -D3DXINLINE -D3DXQUATERNION::operator FLOAT* () -{ - return (FLOAT *) &x; -} - -D3DXINLINE -D3DXQUATERNION::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &x; -} - - -// assignment operators -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator += ( CONST D3DXQUATERNION& q ) -{ - x += q.x; - y += q.y; - z += q.z; - w += q.w; - return *this; -} - -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator -= ( CONST D3DXQUATERNION& q ) -{ - x -= q.x; - y -= q.y; - z -= q.z; - w -= q.w; - return *this; -} - -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator *= ( CONST D3DXQUATERNION& q ) -{ - D3DXQuaternionMultiply(this, this, &q); - return *this; -} - -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator *= ( FLOAT f ) -{ - x *= f; - y *= f; - z *= f; - w *= f; - return *this; -} - -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - x *= fInv; - y *= fInv; - z *= fInv; - w *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator - () const -{ - return D3DXQUATERNION(-x, -y, -z, -w); -} - - -// binary operators -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator + ( CONST D3DXQUATERNION& q ) const -{ - return D3DXQUATERNION(x + q.x, y + q.y, z + q.z, w + q.w); -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator - ( CONST D3DXQUATERNION& q ) const -{ - return D3DXQUATERNION(x - q.x, y - q.y, z - q.z, w - q.w); -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator * ( CONST D3DXQUATERNION& q ) const -{ - D3DXQUATERNION qT; - D3DXQuaternionMultiply(&qT, this, &q); - return qT; -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator * ( FLOAT f ) const -{ - return D3DXQUATERNION(x * f, y * f, z * f, w * f); -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXQUATERNION(x * fInv, y * fInv, z * fInv, w * fInv); -} - - -D3DXINLINE D3DXQUATERNION -operator * (FLOAT f, CONST D3DXQUATERNION& q ) -{ - return D3DXQUATERNION(f * q.x, f * q.y, f * q.z, f * q.w); -} - - -D3DXINLINE BOOL -D3DXQUATERNION::operator == ( CONST D3DXQUATERNION& q ) const -{ - return x == q.x && y == q.y && z == q.z && w == q.w; -} - -D3DXINLINE BOOL -D3DXQUATERNION::operator != ( CONST D3DXQUATERNION& q ) const -{ - return x != q.x || y != q.y || z != q.z || w != q.w; -} - - - -//-------------------------- -// Plane -//-------------------------- - -D3DXINLINE -D3DXPLANE::D3DXPLANE( CONST FLOAT* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - a = pf[0]; - b = pf[1]; - c = pf[2]; - d = pf[3]; -} - -D3DXINLINE -D3DXPLANE::D3DXPLANE( FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd ) -{ - a = fa; - b = fb; - c = fc; - d = fd; -} - - -// casting -D3DXINLINE -D3DXPLANE::operator FLOAT* () -{ - return (FLOAT *) &a; -} - -D3DXINLINE -D3DXPLANE::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &a; -} - - -// unary operators -D3DXINLINE D3DXPLANE -D3DXPLANE::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXPLANE -D3DXPLANE::operator - () const -{ - return D3DXPLANE(-a, -b, -c, -d); -} - - -// binary operators -D3DXINLINE BOOL -D3DXPLANE::operator == ( CONST D3DXPLANE& p ) const -{ - return a == p.a && b == p.b && c == p.c && d == p.d; -} - -D3DXINLINE BOOL -D3DXPLANE::operator != ( CONST D3DXPLANE& p ) const -{ - return a != p.a || b != p.b || c != p.c || d != p.d; -} - - - - -//-------------------------- -// Color -//-------------------------- - -D3DXINLINE -D3DXCOLOR::D3DXCOLOR( DWORD dw ) -{ - CONST FLOAT f = 1.0f / 255.0f; - r = f * (FLOAT) (unsigned char) (dw >> 16); - g = f * (FLOAT) (unsigned char) (dw >> 8); - b = f * (FLOAT) (unsigned char) (dw >> 0); - a = f * (FLOAT) (unsigned char) (dw >> 24); -} - -D3DXINLINE -D3DXCOLOR::D3DXCOLOR( CONST FLOAT* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - r = pf[0]; - g = pf[1]; - b = pf[2]; - a = pf[3]; -} - -D3DXINLINE -D3DXCOLOR::D3DXCOLOR( CONST D3DCOLORVALUE& c ) -{ - r = c.r; - g = c.g; - b = c.b; - a = c.a; -} - -D3DXINLINE -D3DXCOLOR::D3DXCOLOR( FLOAT fr, FLOAT fg, FLOAT fb, FLOAT fa ) -{ - r = fr; - g = fg; - b = fb; - a = fa; -} - - -// casting -D3DXINLINE -D3DXCOLOR::operator DWORD () const -{ - DWORD dwR = r >= 1.0f ? 0xff : r <= 0.0f ? 0x00 : (DWORD) (r * 255.0f + 0.5f); - DWORD dwG = g >= 1.0f ? 0xff : g <= 0.0f ? 0x00 : (DWORD) (g * 255.0f + 0.5f); - DWORD dwB = b >= 1.0f ? 0xff : b <= 0.0f ? 0x00 : (DWORD) (b * 255.0f + 0.5f); - DWORD dwA = a >= 1.0f ? 0xff : a <= 0.0f ? 0x00 : (DWORD) (a * 255.0f + 0.5f); - - return (dwA << 24) | (dwR << 16) | (dwG << 8) | dwB; -} - - -D3DXINLINE -D3DXCOLOR::operator FLOAT * () -{ - return (FLOAT *) &r; -} - -D3DXINLINE -D3DXCOLOR::operator CONST FLOAT * () const -{ - return (CONST FLOAT *) &r; -} - - -D3DXINLINE -D3DXCOLOR::operator D3DCOLORVALUE * () -{ - return (D3DCOLORVALUE *) &r; -} - -D3DXINLINE -D3DXCOLOR::operator CONST D3DCOLORVALUE * () const -{ - return (CONST D3DCOLORVALUE *) &r; -} - - -D3DXINLINE -D3DXCOLOR::operator D3DCOLORVALUE& () -{ - return *((D3DCOLORVALUE *) &r); -} - -D3DXINLINE -D3DXCOLOR::operator CONST D3DCOLORVALUE& () const -{ - return *((CONST D3DCOLORVALUE *) &r); -} - - -// assignment operators -D3DXINLINE D3DXCOLOR& -D3DXCOLOR::operator += ( CONST D3DXCOLOR& c ) -{ - r += c.r; - g += c.g; - b += c.b; - a += c.a; - return *this; -} - -D3DXINLINE D3DXCOLOR& -D3DXCOLOR::operator -= ( CONST D3DXCOLOR& c ) -{ - r -= c.r; - g -= c.g; - b -= c.b; - a -= c.a; - return *this; -} - -D3DXINLINE D3DXCOLOR& -D3DXCOLOR::operator *= ( FLOAT f ) -{ - r *= f; - g *= f; - b *= f; - a *= f; - return *this; -} - -D3DXINLINE D3DXCOLOR& -D3DXCOLOR::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - r *= fInv; - g *= fInv; - b *= fInv; - a *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator - () const -{ - return D3DXCOLOR(-r, -g, -b, -a); -} - - -// binary operators -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator + ( CONST D3DXCOLOR& c ) const -{ - return D3DXCOLOR(r + c.r, g + c.g, b + c.b, a + c.a); -} - -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator - ( CONST D3DXCOLOR& c ) const -{ - return D3DXCOLOR(r - c.r, g - c.g, b - c.b, a - c.a); -} - -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator * ( FLOAT f ) const -{ - return D3DXCOLOR(r * f, g * f, b * f, a * f); -} - -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXCOLOR(r * fInv, g * fInv, b * fInv, a * fInv); -} - - -D3DXINLINE D3DXCOLOR -operator * (FLOAT f, CONST D3DXCOLOR& c ) -{ - return D3DXCOLOR(f * c.r, f * c.g, f * c.b, f * c.a); -} - - -D3DXINLINE BOOL -D3DXCOLOR::operator == ( CONST D3DXCOLOR& c ) const -{ - return r == c.r && g == c.g && b == c.b && a == c.a; -} - -D3DXINLINE BOOL -D3DXCOLOR::operator != ( CONST D3DXCOLOR& c ) const -{ - return r != c.r || g != c.g || b != c.b || a != c.a; -} - - -#endif //__cplusplus - - - -//=========================================================================== -// -// Inline functions -// -//=========================================================================== - - -//-------------------------- -// 2D Vector -//-------------------------- - -D3DXINLINE FLOAT D3DXVec2Length - ( CONST D3DXVECTOR2 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pV->x * pV->x + pV->y * pV->y); -#else - return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y); -#endif -} - -D3DXINLINE FLOAT D3DXVec2LengthSq - ( CONST D3DXVECTOR2 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - - return pV->x * pV->x + pV->y * pV->y; -} - -D3DXINLINE FLOAT D3DXVec2Dot - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->x + pV1->y * pV2->y; -} - -D3DXINLINE FLOAT D3DXVec2CCW - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->y - pV1->y * pV2->x; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Add - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + pV2->x; - pOut->y = pV1->y + pV2->y; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Subtract - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x - pV2->x; - pOut->y = pV1->y - pV2->y; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Minimize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Maximize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Scale - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV) - return NULL; -#endif - - pOut->x = pV->x * s; - pOut->y = pV->y * s; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Lerp - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, - FLOAT s ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + s * (pV2->x - pV1->x); - pOut->y = pV1->y + s * (pV2->y - pV1->y); - return pOut; -} - - -//-------------------------- -// 3D Vector -//-------------------------- - -D3DXINLINE FLOAT D3DXVec3Length - ( CONST D3DXVECTOR3 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); -#else - return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); -#endif -} - -D3DXINLINE FLOAT D3DXVec3LengthSq - ( CONST D3DXVECTOR3 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - - return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z; -} - -D3DXINLINE FLOAT D3DXVec3Dot - ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Cross - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ - D3DXVECTOR3 v; - -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - 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 D3DXVECTOR3* D3DXVec3Add - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + pV2->x; - pOut->y = pV1->y + pV2->y; - pOut->z = pV1->z + pV2->z; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Subtract - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x - pV2->x; - pOut->y = pV1->y - pV2->y; - pOut->z = pV1->z - pV2->z; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Minimize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Maximize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Scale - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV) - return NULL; -#endif - - pOut->x = pV->x * s; - pOut->y = pV->y * s; - pOut->z = pV->z * s; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Lerp - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - FLOAT s ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + s * (pV2->x - pV1->x); - pOut->y = pV1->y + s * (pV2->y - pV1->y); - pOut->z = pV1->z + s * (pV2->z - pV1->z); - return pOut; -} - - -//-------------------------- -// 4D Vector -//-------------------------- - -D3DXINLINE FLOAT D3DXVec4Length - ( CONST D3DXVECTOR4 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); -#else - return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); -#endif -} - -D3DXINLINE FLOAT D3DXVec4LengthSq - ( CONST D3DXVECTOR4 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - - return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w; -} - -D3DXINLINE FLOAT D3DXVec4Dot - ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z + pV1->w * pV2->w; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Add - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + pV2->x; - pOut->y = pV1->y + pV2->y; - pOut->z = pV1->z + pV2->z; - pOut->w = pV1->w + pV2->w; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Subtract - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x - pV2->x; - pOut->y = pV1->y - pV2->y; - pOut->z = pV1->z - pV2->z; - pOut->w = pV1->w - pV2->w; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Minimize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; - pOut->w = pV1->w < pV2->w ? pV1->w : pV2->w; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Maximize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; - pOut->w = pV1->w > pV2->w ? pV1->w : pV2->w; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Scale - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV) - return NULL; -#endif - - pOut->x = pV->x * s; - pOut->y = pV->y * s; - pOut->z = pV->z * s; - pOut->w = pV->w * s; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Lerp - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - FLOAT s ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + s * (pV2->x - pV1->x); - pOut->y = pV1->y + s * (pV2->y - pV1->y); - pOut->z = pV1->z + s * (pV2->z - pV1->z); - pOut->w = pV1->w + s * (pV2->w - pV1->w); - return pOut; -} - - -//-------------------------- -// 4D Matrix -//-------------------------- - -D3DXINLINE D3DXMATRIX* D3DXMatrixIdentity - ( D3DXMATRIX *pOut ) -{ -#ifdef D3DX_DEBUG - if(!pOut) - return NULL; -#endif - - pOut->m[0][1] = pOut->m[0][2] = pOut->m[0][3] = - pOut->m[1][0] = pOut->m[1][2] = pOut->m[1][3] = - pOut->m[2][0] = pOut->m[2][1] = pOut->m[2][3] = - pOut->m[3][0] = pOut->m[3][1] = pOut->m[3][2] = 0.0f; - - pOut->m[0][0] = pOut->m[1][1] = pOut->m[2][2] = pOut->m[3][3] = 1.0f; - return pOut; -} - - -D3DXINLINE BOOL D3DXMatrixIsIdentity - ( CONST D3DXMATRIX *pM ) -{ -#ifdef D3DX_DEBUG - if(!pM) - return FALSE; -#endif - - return pM->m[0][0] == 1.0f && pM->m[0][1] == 0.0f && pM->m[0][2] == 0.0f && pM->m[0][3] == 0.0f && - pM->m[1][0] == 0.0f && pM->m[1][1] == 1.0f && pM->m[1][2] == 0.0f && pM->m[1][3] == 0.0f && - pM->m[2][0] == 0.0f && pM->m[2][1] == 0.0f && pM->m[2][2] == 1.0f && pM->m[2][3] == 0.0f && - pM->m[3][0] == 0.0f && pM->m[3][1] == 0.0f && pM->m[3][2] == 0.0f && pM->m[3][3] == 1.0f; -} - - -//-------------------------- -// Quaternion -//-------------------------- - -D3DXINLINE FLOAT D3DXQuaternionLength - ( CONST D3DXQUATERNION *pQ ) -{ -#ifdef D3DX_DEBUG - if(!pQ) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); -#else - return (FLOAT) sqrt(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); -#endif -} - -D3DXINLINE FLOAT D3DXQuaternionLengthSq - ( CONST D3DXQUATERNION *pQ ) -{ -#ifdef D3DX_DEBUG - if(!pQ) - return 0.0f; -#endif - - return pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w; -} - -D3DXINLINE FLOAT D3DXQuaternionDot - ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ) -{ -#ifdef D3DX_DEBUG - if(!pQ1 || !pQ2) - return 0.0f; -#endif - - return pQ1->x * pQ2->x + pQ1->y * pQ2->y + pQ1->z * pQ2->z + pQ1->w * pQ2->w; -} - - -D3DXINLINE D3DXQUATERNION* D3DXQuaternionIdentity - ( D3DXQUATERNION *pOut ) -{ -#ifdef D3DX_DEBUG - if(!pOut) - return NULL; -#endif - - pOut->x = pOut->y = pOut->z = 0.0f; - pOut->w = 1.0f; - return pOut; -} - -D3DXINLINE BOOL D3DXQuaternionIsIdentity - ( CONST D3DXQUATERNION *pQ ) -{ -#ifdef D3DX_DEBUG - if(!pQ) - return FALSE; -#endif - - return pQ->x == 0.0f && pQ->y == 0.0f && pQ->z == 0.0f && pQ->w == 1.0f; -} - - -D3DXINLINE D3DXQUATERNION* D3DXQuaternionConjugate - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pQ) - return NULL; -#endif - - pOut->x = -pQ->x; - pOut->y = -pQ->y; - pOut->z = -pQ->z; - pOut->w = pQ->w; - return pOut; -} - - -//-------------------------- -// Plane -//-------------------------- - -D3DXINLINE FLOAT D3DXPlaneDot - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV) -{ -#ifdef D3DX_DEBUG - if(!pP || !pV) - return 0.0f; -#endif - - return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d * pV->w; -} - -D3DXINLINE FLOAT D3DXPlaneDotCoord - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV) -{ -#ifdef D3DX_DEBUG - if(!pP || !pV) - return 0.0f; -#endif - - return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d; -} - -D3DXINLINE FLOAT D3DXPlaneDotNormal - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV) -{ -#ifdef D3DX_DEBUG - if(!pP || !pV) - return 0.0f; -#endif - - return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z; -} - - -//-------------------------- -// Color -//-------------------------- - -D3DXINLINE D3DXCOLOR* D3DXColorNegative - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC) - return NULL; -#endif - - pOut->r = 1.0f - pC->r; - pOut->g = 1.0f - pC->g; - pOut->b = 1.0f - pC->b; - pOut->a = pC->a; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorAdd - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r + pC2->r; - pOut->g = pC1->g + pC2->g; - pOut->b = pC1->b + pC2->b; - pOut->a = pC1->a + pC2->a; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorSubtract - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r - pC2->r; - pOut->g = pC1->g - pC2->g; - pOut->b = pC1->b - pC2->b; - pOut->a = pC1->a - pC2->a; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorScale - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC) - return NULL; -#endif - - pOut->r = pC->r * s; - pOut->g = pC->g * s; - pOut->b = pC->b * s; - pOut->a = pC->a * s; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorModulate - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r * pC2->r; - pOut->g = pC1->g * pC2->g; - pOut->b = pC1->b * pC2->b; - pOut->a = pC1->a * pC2->a; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorLerp - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r + s * (pC2->r - pC1->r); - pOut->g = pC1->g + s * (pC2->g - pC1->g); - pOut->b = pC1->b + s * (pC2->b - pC1->b); - pOut->a = pC1->a + s * (pC2->a - pC1->a); - return pOut; -} - - -#endif // __D3DX8MATH_INL__ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8math.inl +// Content: D3DX math inline functions +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DX8MATH_INL__ +#define __D3DX8MATH_INL__ + + +//=========================================================================== +// +// Inline Class Methods +// +//=========================================================================== + +#ifdef __cplusplus + +//-------------------------- +// 2D Vector +//-------------------------- + +D3DXINLINE +D3DXVECTOR2::D3DXVECTOR2( CONST FLOAT *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; +} + +D3DXINLINE +D3DXVECTOR2::D3DXVECTOR2( FLOAT fx, FLOAT fy ) +{ + x = fx; + y = fy; +} + +// casting +D3DXINLINE +D3DXVECTOR2::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DXINLINE +D3DXVECTOR2::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + +// assignment operators +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator += ( CONST D3DXVECTOR2& v ) +{ + x += v.x; + y += v.y; + return *this; +} + +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator -= ( CONST D3DXVECTOR2& v ) +{ + x -= v.x; + y -= v.y; + return *this; +} + +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + return *this; +} + +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + return *this; +} + +// unary operators +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator - () const +{ + return D3DXVECTOR2(-x, -y); +} + +// binary operators +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator + ( CONST D3DXVECTOR2& v ) const +{ + return D3DXVECTOR2(x + v.x, y + v.y); +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator - ( CONST D3DXVECTOR2& v ) const +{ + return D3DXVECTOR2(x - v.x, y - v.y); +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator * ( FLOAT f ) const +{ + return D3DXVECTOR2(x * f, y * f); +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXVECTOR2(x * fInv, y * fInv); +} + + +D3DXINLINE D3DXVECTOR2 +operator * ( FLOAT f, CONST D3DXVECTOR2& v ) +{ + return D3DXVECTOR2(f * v.x, f * v.y); +} + +D3DXINLINE BOOL +D3DXVECTOR2::operator == ( CONST D3DXVECTOR2& v ) const +{ + return x == v.x && y == v.y; +} + +D3DXINLINE BOOL +D3DXVECTOR2::operator != ( CONST D3DXVECTOR2& v ) const +{ + return x != v.x || y != v.y; +} + + + + +//-------------------------- +// 3D Vector +//-------------------------- +D3DXINLINE +D3DXVECTOR3::D3DXVECTOR3( CONST FLOAT *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; +} + +D3DXINLINE +D3DXVECTOR3::D3DXVECTOR3( CONST D3DVECTOR& v ) +{ + x = v.x; + y = v.y; + z = v.z; +} + +D3DXINLINE +D3DXVECTOR3::D3DXVECTOR3( FLOAT fx, FLOAT fy, FLOAT fz ) +{ + x = fx; + y = fy; + z = fz; +} + + +// casting +D3DXINLINE +D3DXVECTOR3::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DXINLINE +D3DXVECTOR3::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + + +// assignment operators +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator += ( CONST D3DXVECTOR3& v ) +{ + x += v.x; + y += v.y; + z += v.z; + return *this; +} + +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator -= ( CONST D3DXVECTOR3& v ) +{ + x -= v.x; + y -= v.y; + z -= v.z; + return *this; +} + +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + z *= f; + return *this; +} + +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator - () const +{ + return D3DXVECTOR3(-x, -y, -z); +} + + +// binary operators +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator + ( CONST D3DXVECTOR3& v ) const +{ + return D3DXVECTOR3(x + v.x, y + v.y, z + v.z); +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator - ( CONST D3DXVECTOR3& v ) const +{ + return D3DXVECTOR3(x - v.x, y - v.y, z - v.z); +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator * ( FLOAT f ) const +{ + return D3DXVECTOR3(x * f, y * f, z * f); +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXVECTOR3(x * fInv, y * fInv, z * fInv); +} + + +D3DXINLINE D3DXVECTOR3 +operator * ( FLOAT f, CONST struct D3DXVECTOR3& v ) +{ + return D3DXVECTOR3(f * v.x, f * v.y, f * v.z); +} + + +D3DXINLINE BOOL +D3DXVECTOR3::operator == ( CONST D3DXVECTOR3& v ) const +{ + return x == v.x && y == v.y && z == v.z; +} + +D3DXINLINE BOOL +D3DXVECTOR3::operator != ( CONST D3DXVECTOR3& v ) const +{ + return x != v.x || y != v.y || z != v.z; +} + + + +//-------------------------- +// 4D Vector +//-------------------------- +D3DXINLINE +D3DXVECTOR4::D3DXVECTOR4( CONST FLOAT *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; + w = pf[3]; +} + +D3DXINLINE +D3DXVECTOR4::D3DXVECTOR4( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) +{ + x = fx; + y = fy; + z = fz; + w = fw; +} + + +// casting +D3DXINLINE +D3DXVECTOR4::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DXINLINE +D3DXVECTOR4::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + + +// assignment operators +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator += ( CONST D3DXVECTOR4& v ) +{ + x += v.x; + y += v.y; + z += v.z; + w += v.w; + return *this; +} + +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator -= ( CONST D3DXVECTOR4& v ) +{ + x -= v.x; + y -= v.y; + z -= v.z; + w -= v.w; + return *this; +} + +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + z *= f; + w *= f; + return *this; +} + +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + w *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator - () const +{ + return D3DXVECTOR4(-x, -y, -z, -w); +} + + +// binary operators +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator + ( CONST D3DXVECTOR4& v ) const +{ + return D3DXVECTOR4(x + v.x, y + v.y, z + v.z, w + v.w); +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator - ( CONST D3DXVECTOR4& v ) const +{ + return D3DXVECTOR4(x - v.x, y - v.y, z - v.z, w - v.w); +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator * ( FLOAT f ) const +{ + return D3DXVECTOR4(x * f, y * f, z * f, w * f); +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXVECTOR4(x * fInv, y * fInv, z * fInv, w * fInv); +} + + +D3DXINLINE D3DXVECTOR4 +operator * ( FLOAT f, CONST D3DXVECTOR4& v ) +{ + return D3DXVECTOR4(f * v.x, f * v.y, f * v.z, f * v.w); +} + + +D3DXINLINE BOOL +D3DXVECTOR4::operator == ( CONST D3DXVECTOR4& v ) const +{ + return x == v.x && y == v.y && z == v.z && w == v.w; +} + +D3DXINLINE BOOL +D3DXVECTOR4::operator != ( CONST D3DXVECTOR4& v ) const +{ + return x != v.x || y != v.y || z != v.z || w != v.w; +} + + +//-------------------------- +// Matrix +//-------------------------- +D3DXINLINE +D3DXMATRIX::D3DXMATRIX( CONST FLOAT* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + memcpy(&_11, pf, sizeof(D3DXMATRIX)); +} + +D3DXINLINE +D3DXMATRIX::D3DXMATRIX( CONST D3DMATRIX& mat ) +{ + memcpy(&_11, &mat, sizeof(D3DXMATRIX)); +} + +D3DXINLINE +D3DXMATRIX::D3DXMATRIX( FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14, + FLOAT f21, FLOAT f22, FLOAT f23, FLOAT f24, + FLOAT f31, FLOAT f32, FLOAT f33, FLOAT f34, + FLOAT f41, FLOAT f42, FLOAT f43, FLOAT f44 ) +{ + _11 = f11; _12 = f12; _13 = f13; _14 = f14; + _21 = f21; _22 = f22; _23 = f23; _24 = f24; + _31 = f31; _32 = f32; _33 = f33; _34 = f34; + _41 = f41; _42 = f42; _43 = f43; _44 = f44; +} + + + +// access grants +D3DXINLINE FLOAT& +D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) +{ + return m[iRow][iCol]; +} + +D3DXINLINE FLOAT +D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) const +{ + return m[iRow][iCol]; +} + + +// casting operators +D3DXINLINE +D3DXMATRIX::operator FLOAT* () +{ + return (FLOAT *) &_11; +} + +D3DXINLINE +D3DXMATRIX::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &_11; +} + + +// assignment operators +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator *= ( CONST D3DXMATRIX& mat ) +{ + D3DXMatrixMultiply(this, this, &mat); + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator += ( CONST D3DXMATRIX& mat ) +{ + _11 += mat._11; _12 += mat._12; _13 += mat._13; _14 += mat._14; + _21 += mat._21; _22 += mat._22; _23 += mat._23; _24 += mat._24; + _31 += mat._31; _32 += mat._32; _33 += mat._33; _34 += mat._34; + _41 += mat._41; _42 += mat._42; _43 += mat._43; _44 += mat._44; + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator -= ( CONST D3DXMATRIX& mat ) +{ + _11 -= mat._11; _12 -= mat._12; _13 -= mat._13; _14 -= mat._14; + _21 -= mat._21; _22 -= mat._22; _23 -= mat._23; _24 -= mat._24; + _31 -= mat._31; _32 -= mat._32; _33 -= mat._33; _34 -= mat._34; + _41 -= mat._41; _42 -= mat._42; _43 -= mat._43; _44 -= mat._44; + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator *= ( FLOAT f ) +{ + _11 *= f; _12 *= f; _13 *= f; _14 *= f; + _21 *= f; _22 *= f; _23 *= f; _24 *= f; + _31 *= f; _32 *= f; _33 *= f; _34 *= f; + _41 *= f; _42 *= f; _43 *= f; _44 *= f; + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + _11 *= fInv; _12 *= fInv; _13 *= fInv; _14 *= fInv; + _21 *= fInv; _22 *= fInv; _23 *= fInv; _24 *= fInv; + _31 *= fInv; _32 *= fInv; _33 *= fInv; _34 *= fInv; + _41 *= fInv; _42 *= fInv; _43 *= fInv; _44 *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator - () const +{ + return D3DXMATRIX(-_11, -_12, -_13, -_14, + -_21, -_22, -_23, -_24, + -_31, -_32, -_33, -_34, + -_41, -_42, -_43, -_44); +} + + +// binary operators +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator * ( CONST D3DXMATRIX& mat ) const +{ + D3DXMATRIX matT; + D3DXMatrixMultiply(&matT, this, &mat); + return matT; +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator + ( CONST D3DXMATRIX& mat ) const +{ + return D3DXMATRIX(_11 + mat._11, _12 + mat._12, _13 + mat._13, _14 + mat._14, + _21 + mat._21, _22 + mat._22, _23 + mat._23, _24 + mat._24, + _31 + mat._31, _32 + mat._32, _33 + mat._33, _34 + mat._34, + _41 + mat._41, _42 + mat._42, _43 + mat._43, _44 + mat._44); +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator - ( CONST D3DXMATRIX& mat ) const +{ + return D3DXMATRIX(_11 - mat._11, _12 - mat._12, _13 - mat._13, _14 - mat._14, + _21 - mat._21, _22 - mat._22, _23 - mat._23, _24 - mat._24, + _31 - mat._31, _32 - mat._32, _33 - mat._33, _34 - mat._34, + _41 - mat._41, _42 - mat._42, _43 - mat._43, _44 - mat._44); +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator * ( FLOAT f ) const +{ + return D3DXMATRIX(_11 * f, _12 * f, _13 * f, _14 * f, + _21 * f, _22 * f, _23 * f, _24 * f, + _31 * f, _32 * f, _33 * f, _34 * f, + _41 * f, _42 * f, _43 * f, _44 * f); +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXMATRIX(_11 * fInv, _12 * fInv, _13 * fInv, _14 * fInv, + _21 * fInv, _22 * fInv, _23 * fInv, _24 * fInv, + _31 * fInv, _32 * fInv, _33 * fInv, _34 * fInv, + _41 * fInv, _42 * fInv, _43 * fInv, _44 * fInv); +} + + +D3DXINLINE D3DXMATRIX +operator * ( FLOAT f, CONST D3DXMATRIX& mat ) +{ + return D3DXMATRIX(f * mat._11, f * mat._12, f * mat._13, f * mat._14, + f * mat._21, f * mat._22, f * mat._23, f * mat._24, + f * mat._31, f * mat._32, f * mat._33, f * mat._34, + f * mat._41, f * mat._42, f * mat._43, f * mat._44); +} + + +D3DXINLINE BOOL +D3DXMATRIX::operator == ( CONST D3DXMATRIX& mat ) const +{ + return 0 == memcmp(this, &mat, sizeof(D3DXMATRIX)); +} + +D3DXINLINE BOOL +D3DXMATRIX::operator != ( CONST D3DXMATRIX& mat ) const +{ + return 0 != memcmp(this, &mat, sizeof(D3DXMATRIX)); +} + + + +//-------------------------- +// Quaternion +//-------------------------- + +D3DXINLINE +D3DXQUATERNION::D3DXQUATERNION( CONST FLOAT* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; + w = pf[3]; +} + +D3DXINLINE +D3DXQUATERNION::D3DXQUATERNION( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) +{ + x = fx; + y = fy; + z = fz; + w = fw; +} + + +// casting +D3DXINLINE +D3DXQUATERNION::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DXINLINE +D3DXQUATERNION::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + + +// assignment operators +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator += ( CONST D3DXQUATERNION& q ) +{ + x += q.x; + y += q.y; + z += q.z; + w += q.w; + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator -= ( CONST D3DXQUATERNION& q ) +{ + x -= q.x; + y -= q.y; + z -= q.z; + w -= q.w; + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator *= ( CONST D3DXQUATERNION& q ) +{ + D3DXQuaternionMultiply(this, this, &q); + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + z *= f; + w *= f; + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + w *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator - () const +{ + return D3DXQUATERNION(-x, -y, -z, -w); +} + + +// binary operators +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator + ( CONST D3DXQUATERNION& q ) const +{ + return D3DXQUATERNION(x + q.x, y + q.y, z + q.z, w + q.w); +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator - ( CONST D3DXQUATERNION& q ) const +{ + return D3DXQUATERNION(x - q.x, y - q.y, z - q.z, w - q.w); +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator * ( CONST D3DXQUATERNION& q ) const +{ + D3DXQUATERNION qT; + D3DXQuaternionMultiply(&qT, this, &q); + return qT; +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator * ( FLOAT f ) const +{ + return D3DXQUATERNION(x * f, y * f, z * f, w * f); +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXQUATERNION(x * fInv, y * fInv, z * fInv, w * fInv); +} + + +D3DXINLINE D3DXQUATERNION +operator * (FLOAT f, CONST D3DXQUATERNION& q ) +{ + return D3DXQUATERNION(f * q.x, f * q.y, f * q.z, f * q.w); +} + + +D3DXINLINE BOOL +D3DXQUATERNION::operator == ( CONST D3DXQUATERNION& q ) const +{ + return x == q.x && y == q.y && z == q.z && w == q.w; +} + +D3DXINLINE BOOL +D3DXQUATERNION::operator != ( CONST D3DXQUATERNION& q ) const +{ + return x != q.x || y != q.y || z != q.z || w != q.w; +} + + + +//-------------------------- +// Plane +//-------------------------- + +D3DXINLINE +D3DXPLANE::D3DXPLANE( CONST FLOAT* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + a = pf[0]; + b = pf[1]; + c = pf[2]; + d = pf[3]; +} + +D3DXINLINE +D3DXPLANE::D3DXPLANE( FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd ) +{ + a = fa; + b = fb; + c = fc; + d = fd; +} + + +// casting +D3DXINLINE +D3DXPLANE::operator FLOAT* () +{ + return (FLOAT *) &a; +} + +D3DXINLINE +D3DXPLANE::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &a; +} + + +// unary operators +D3DXINLINE D3DXPLANE +D3DXPLANE::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXPLANE +D3DXPLANE::operator - () const +{ + return D3DXPLANE(-a, -b, -c, -d); +} + + +// binary operators +D3DXINLINE BOOL +D3DXPLANE::operator == ( CONST D3DXPLANE& p ) const +{ + return a == p.a && b == p.b && c == p.c && d == p.d; +} + +D3DXINLINE BOOL +D3DXPLANE::operator != ( CONST D3DXPLANE& p ) const +{ + return a != p.a || b != p.b || c != p.c || d != p.d; +} + + + + +//-------------------------- +// Color +//-------------------------- + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( DWORD dw ) +{ + CONST FLOAT f = 1.0f / 255.0f; + r = f * (FLOAT) (unsigned char) (dw >> 16); + g = f * (FLOAT) (unsigned char) (dw >> 8); + b = f * (FLOAT) (unsigned char) (dw >> 0); + a = f * (FLOAT) (unsigned char) (dw >> 24); +} + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( CONST FLOAT* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + r = pf[0]; + g = pf[1]; + b = pf[2]; + a = pf[3]; +} + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( CONST D3DCOLORVALUE& c ) +{ + r = c.r; + g = c.g; + b = c.b; + a = c.a; +} + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( FLOAT fr, FLOAT fg, FLOAT fb, FLOAT fa ) +{ + r = fr; + g = fg; + b = fb; + a = fa; +} + + +// casting +D3DXINLINE +D3DXCOLOR::operator DWORD () const +{ + DWORD dwR = r >= 1.0f ? 0xff : r <= 0.0f ? 0x00 : (DWORD) (r * 255.0f + 0.5f); + DWORD dwG = g >= 1.0f ? 0xff : g <= 0.0f ? 0x00 : (DWORD) (g * 255.0f + 0.5f); + DWORD dwB = b >= 1.0f ? 0xff : b <= 0.0f ? 0x00 : (DWORD) (b * 255.0f + 0.5f); + DWORD dwA = a >= 1.0f ? 0xff : a <= 0.0f ? 0x00 : (DWORD) (a * 255.0f + 0.5f); + + return (dwA << 24) | (dwR << 16) | (dwG << 8) | dwB; +} + + +D3DXINLINE +D3DXCOLOR::operator FLOAT * () +{ + return (FLOAT *) &r; +} + +D3DXINLINE +D3DXCOLOR::operator CONST FLOAT * () const +{ + return (CONST FLOAT *) &r; +} + + +D3DXINLINE +D3DXCOLOR::operator D3DCOLORVALUE * () +{ + return (D3DCOLORVALUE *) &r; +} + +D3DXINLINE +D3DXCOLOR::operator CONST D3DCOLORVALUE * () const +{ + return (CONST D3DCOLORVALUE *) &r; +} + + +D3DXINLINE +D3DXCOLOR::operator D3DCOLORVALUE& () +{ + return *((D3DCOLORVALUE *) &r); +} + +D3DXINLINE +D3DXCOLOR::operator CONST D3DCOLORVALUE& () const +{ + return *((CONST D3DCOLORVALUE *) &r); +} + + +// assignment operators +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator += ( CONST D3DXCOLOR& c ) +{ + r += c.r; + g += c.g; + b += c.b; + a += c.a; + return *this; +} + +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator -= ( CONST D3DXCOLOR& c ) +{ + r -= c.r; + g -= c.g; + b -= c.b; + a -= c.a; + return *this; +} + +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator *= ( FLOAT f ) +{ + r *= f; + g *= f; + b *= f; + a *= f; + return *this; +} + +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + r *= fInv; + g *= fInv; + b *= fInv; + a *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator - () const +{ + return D3DXCOLOR(-r, -g, -b, -a); +} + + +// binary operators +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator + ( CONST D3DXCOLOR& c ) const +{ + return D3DXCOLOR(r + c.r, g + c.g, b + c.b, a + c.a); +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator - ( CONST D3DXCOLOR& c ) const +{ + return D3DXCOLOR(r - c.r, g - c.g, b - c.b, a - c.a); +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator * ( FLOAT f ) const +{ + return D3DXCOLOR(r * f, g * f, b * f, a * f); +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXCOLOR(r * fInv, g * fInv, b * fInv, a * fInv); +} + + +D3DXINLINE D3DXCOLOR +operator * (FLOAT f, CONST D3DXCOLOR& c ) +{ + return D3DXCOLOR(f * c.r, f * c.g, f * c.b, f * c.a); +} + + +D3DXINLINE BOOL +D3DXCOLOR::operator == ( CONST D3DXCOLOR& c ) const +{ + return r == c.r && g == c.g && b == c.b && a == c.a; +} + +D3DXINLINE BOOL +D3DXCOLOR::operator != ( CONST D3DXCOLOR& c ) const +{ + return r != c.r || g != c.g || b != c.b || a != c.a; +} + + +#endif //__cplusplus + + + +//=========================================================================== +// +// Inline functions +// +//=========================================================================== + + +//-------------------------- +// 2D Vector +//-------------------------- + +D3DXINLINE FLOAT D3DXVec2Length + ( CONST D3DXVECTOR2 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y); +#else + return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y); +#endif +} + +D3DXINLINE FLOAT D3DXVec2LengthSq + ( CONST D3DXVECTOR2 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y; +} + +D3DXINLINE FLOAT D3DXVec2Dot + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y; +} + +D3DXINLINE FLOAT D3DXVec2CCW + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->y - pV1->y * pV2->x; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Add + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Subtract + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Minimize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Maximize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Scale + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Lerp + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + FLOAT s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + return pOut; +} + + +//-------------------------- +// 3D Vector +//-------------------------- + +D3DXINLINE FLOAT D3DXVec3Length + ( CONST D3DXVECTOR3 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); +#else + return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); +#endif +} + +D3DXINLINE FLOAT D3DXVec3LengthSq + ( CONST D3DXVECTOR3 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z; +} + +D3DXINLINE FLOAT D3DXVec3Dot + ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Cross + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ + D3DXVECTOR3 v; + +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + 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 D3DXVECTOR3* D3DXVec3Add + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + pOut->z = pV1->z + pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Subtract + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + pOut->z = pV1->z - pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Minimize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Maximize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Scale + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + pOut->z = pV->z * s; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Lerp + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + FLOAT s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + pOut->z = pV1->z + s * (pV2->z - pV1->z); + return pOut; +} + + +//-------------------------- +// 4D Vector +//-------------------------- + +D3DXINLINE FLOAT D3DXVec4Length + ( CONST D3DXVECTOR4 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); +#else + return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); +#endif +} + +D3DXINLINE FLOAT D3DXVec4LengthSq + ( CONST D3DXVECTOR4 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w; +} + +D3DXINLINE FLOAT D3DXVec4Dot + ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z + pV1->w * pV2->w; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Add + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + pOut->z = pV1->z + pV2->z; + pOut->w = pV1->w + pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Subtract + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + pOut->z = pV1->z - pV2->z; + pOut->w = pV1->w - pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Minimize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; + pOut->w = pV1->w < pV2->w ? pV1->w : pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Maximize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; + pOut->w = pV1->w > pV2->w ? pV1->w : pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Scale + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + pOut->z = pV->z * s; + pOut->w = pV->w * s; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Lerp + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + FLOAT s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + pOut->z = pV1->z + s * (pV2->z - pV1->z); + pOut->w = pV1->w + s * (pV2->w - pV1->w); + return pOut; +} + + +//-------------------------- +// 4D Matrix +//-------------------------- + +D3DXINLINE D3DXMATRIX* D3DXMatrixIdentity + ( D3DXMATRIX *pOut ) +{ +#ifdef D3DX_DEBUG + if(!pOut) + return NULL; +#endif + + pOut->m[0][1] = pOut->m[0][2] = pOut->m[0][3] = + pOut->m[1][0] = pOut->m[1][2] = pOut->m[1][3] = + pOut->m[2][0] = pOut->m[2][1] = pOut->m[2][3] = + pOut->m[3][0] = pOut->m[3][1] = pOut->m[3][2] = 0.0f; + + pOut->m[0][0] = pOut->m[1][1] = pOut->m[2][2] = pOut->m[3][3] = 1.0f; + return pOut; +} + + +D3DXINLINE BOOL D3DXMatrixIsIdentity + ( CONST D3DXMATRIX *pM ) +{ +#ifdef D3DX_DEBUG + if(!pM) + return FALSE; +#endif + + return pM->m[0][0] == 1.0f && pM->m[0][1] == 0.0f && pM->m[0][2] == 0.0f && pM->m[0][3] == 0.0f && + pM->m[1][0] == 0.0f && pM->m[1][1] == 1.0f && pM->m[1][2] == 0.0f && pM->m[1][3] == 0.0f && + pM->m[2][0] == 0.0f && pM->m[2][1] == 0.0f && pM->m[2][2] == 1.0f && pM->m[2][3] == 0.0f && + pM->m[3][0] == 0.0f && pM->m[3][1] == 0.0f && pM->m[3][2] == 0.0f && pM->m[3][3] == 1.0f; +} + + +//-------------------------- +// Quaternion +//-------------------------- + +D3DXINLINE FLOAT D3DXQuaternionLength + ( CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pQ) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); +#else + return (FLOAT) sqrt(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); +#endif +} + +D3DXINLINE FLOAT D3DXQuaternionLengthSq + ( CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pQ) + return 0.0f; +#endif + + return pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w; +} + +D3DXINLINE FLOAT D3DXQuaternionDot + ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ) +{ +#ifdef D3DX_DEBUG + if(!pQ1 || !pQ2) + return 0.0f; +#endif + + return pQ1->x * pQ2->x + pQ1->y * pQ2->y + pQ1->z * pQ2->z + pQ1->w * pQ2->w; +} + + +D3DXINLINE D3DXQUATERNION* D3DXQuaternionIdentity + ( D3DXQUATERNION *pOut ) +{ +#ifdef D3DX_DEBUG + if(!pOut) + return NULL; +#endif + + pOut->x = pOut->y = pOut->z = 0.0f; + pOut->w = 1.0f; + return pOut; +} + +D3DXINLINE BOOL D3DXQuaternionIsIdentity + ( CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pQ) + return FALSE; +#endif + + return pQ->x == 0.0f && pQ->y == 0.0f && pQ->z == 0.0f && pQ->w == 1.0f; +} + + +D3DXINLINE D3DXQUATERNION* D3DXQuaternionConjugate + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pQ) + return NULL; +#endif + + pOut->x = -pQ->x; + pOut->y = -pQ->y; + pOut->z = -pQ->z; + pOut->w = pQ->w; + return pOut; +} + + +//-------------------------- +// Plane +//-------------------------- + +D3DXINLINE FLOAT D3DXPlaneDot + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV) +{ +#ifdef D3DX_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d * pV->w; +} + +D3DXINLINE FLOAT D3DXPlaneDotCoord + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV) +{ +#ifdef D3DX_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d; +} + +D3DXINLINE FLOAT D3DXPlaneDotNormal + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV) +{ +#ifdef D3DX_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z; +} + + +//-------------------------- +// Color +//-------------------------- + +D3DXINLINE D3DXCOLOR* D3DXColorNegative + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC) + return NULL; +#endif + + pOut->r = 1.0f - pC->r; + pOut->g = 1.0f - pC->g; + pOut->b = 1.0f - pC->b; + pOut->a = pC->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorAdd + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r + pC2->r; + pOut->g = pC1->g + pC2->g; + pOut->b = pC1->b + pC2->b; + pOut->a = pC1->a + pC2->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorSubtract + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r - pC2->r; + pOut->g = pC1->g - pC2->g; + pOut->b = pC1->b - pC2->b; + pOut->a = pC1->a - pC2->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorScale + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC) + return NULL; +#endif + + pOut->r = pC->r * s; + pOut->g = pC->g * s; + pOut->b = pC->b * s; + pOut->a = pC->a * s; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorModulate + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r * pC2->r; + pOut->g = pC1->g * pC2->g; + pOut->b = pC1->b * pC2->b; + pOut->a = pC1->a * pC2->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorLerp + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r + s * (pC2->r - pC1->r); + pOut->g = pC1->g + s * (pC2->g - pC1->g); + pOut->b = pC1->b + s * (pC2->b - pC1->b); + pOut->a = pC1->a + s * (pC2->a - pC1->a); + return pOut; +} + + +#endif // __D3DX8MATH_INL__ diff --git a/src/dep/include/DXSDK/include/d3dx8mesh.h b/src/dep/include/DXSDK/include/d3dx8mesh.h index d4cadd9..5408cd3 100644 --- a/src/dep/include/DXSDK/include/d3dx8mesh.h +++ b/src/dep/include/DXSDK/include/d3dx8mesh.h @@ -1,760 +1,760 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8mesh.h -// Content: D3DX mesh types and functions -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8MESH_H__ -#define __D3DX8MESH_H__ - -#include "dxfile.h" // defines LPDIRECTXFILEDATA - -// {2A835771-BF4D-43f4-8E14-82A809F17D8A} -DEFINE_GUID(IID_ID3DXBaseMesh, -0x2a835771, 0xbf4d, 0x43f4, 0x8e, 0x14, 0x82, 0xa8, 0x9, 0xf1, 0x7d, 0x8a); - -// {CCAE5C3B-4DD1-4d0f-997E-4684CA64557F} -DEFINE_GUID(IID_ID3DXMesh, -0xccae5c3b, 0x4dd1, 0x4d0f, 0x99, 0x7e, 0x46, 0x84, 0xca, 0x64, 0x55, 0x7f); - -// {19FBE386-C282-4659-97BD-CB869B084A6C} -DEFINE_GUID(IID_ID3DXPMesh, -0x19fbe386, 0xc282, 0x4659, 0x97, 0xbd, 0xcb, 0x86, 0x9b, 0x8, 0x4a, 0x6c); - -// {4E3CA05C-D4FF-4d11-8A02-16459E08F6F4} -DEFINE_GUID(IID_ID3DXSPMesh, -0x4e3ca05c, 0xd4ff, 0x4d11, 0x8a, 0x2, 0x16, 0x45, 0x9e, 0x8, 0xf6, 0xf4); - -// {8DB06ECC-EBFC-408a-9404-3074B4773515} -DEFINE_GUID(IID_ID3DXSkinMesh, -0x8db06ecc, 0xebfc, 0x408a, 0x94, 0x4, 0x30, 0x74, 0xb4, 0x77, 0x35, 0x15); - -// Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags -enum _D3DXMESH { - D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. - D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB. - D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. - D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. - D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. - D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER - D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. - D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB. - D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB. - D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB. - D3DXMESH_IB_SYSTEMMEM = 0x100, // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER - D3DXMESH_IB_MANAGED = 0x200, // Use D3DPOOL_MANAGED for IB. - D3DXMESH_IB_WRITEONLY = 0x400, // Use D3DUSAGE_WRITEONLY for IB. - D3DXMESH_IB_DYNAMIC = 0x800, // Use D3DUSAGE_DYNAMIC for IB. - D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, // Use D3DUSAGE_SOFTWAREPROCESSING for IB. - - D3DXMESH_VB_SHARE = 0x1000, // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer - - D3DXMESH_USEHWONLY = 0x2000, // Valid for ID3DXSkinMesh::ConvertToBlendedMesh - - // Helper options - D3DXMESH_SYSTEMMEM = 0x110, // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM - D3DXMESH_MANAGED = 0x220, // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED - D3DXMESH_WRITEONLY = 0x440, // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY - D3DXMESH_DYNAMIC = 0x880, // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC - D3DXMESH_SOFTWAREPROCESSING = 0x18000, // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING - -}; - -// option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh -enum _D3DXMESHSIMP -{ - D3DXMESHSIMP_VERTEX = 0x1, - D3DXMESHSIMP_FACE = 0x2, - -}; - -enum _MAX_FVF_DECL_SIZE -{ - MAX_FVF_DECL_SIZE = 20 -}; - -typedef struct ID3DXBaseMesh *LPD3DXBASEMESH; -typedef struct ID3DXMesh *LPD3DXMESH; -typedef struct ID3DXPMesh *LPD3DXPMESH; -typedef struct ID3DXSPMesh *LPD3DXSPMESH; -typedef struct ID3DXSkinMesh *LPD3DXSKINMESH; - -typedef struct _D3DXATTRIBUTERANGE -{ - DWORD AttribId; - DWORD FaceStart; - DWORD FaceCount; - DWORD VertexStart; - DWORD VertexCount; -} D3DXATTRIBUTERANGE; - -typedef D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE; - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus -struct D3DXMATERIAL -{ - D3DMATERIAL8 MatD3D; - LPSTR pTextureFilename; -}; -typedef struct D3DXMATERIAL *LPD3DXMATERIAL; -#ifdef __cplusplus -} -#endif //__cplusplus - -typedef struct _D3DXATTRIBUTEWEIGHTS -{ - FLOAT Position; - FLOAT Boundary; - FLOAT Normal; - FLOAT Diffuse; - FLOAT Specular; - FLOAT Tex[8]; -} D3DXATTRIBUTEWEIGHTS; - -typedef D3DXATTRIBUTEWEIGHTS* LPD3DXATTRIBUTEWEIGHTS; - -enum _D3DXWELDEPSILONSFLAGS -{ - D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping - - D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched - // vertices so that both components identical AND if all components "equal" - // remove one of the vertices - D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal - // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set - // useful to modify vertices to be equal, but not allow vertices to be removed -}; - -typedef struct _D3DXWELDEPSILONS -{ - FLOAT SkinWeights; - FLOAT Normal; - FLOAT Tex[8]; - DWORD Flags; -} D3DXWELDEPSILONS; - -typedef D3DXWELDEPSILONS* LPD3DXWELDEPSILONS; - - -#undef INTERFACE -#define INTERFACE ID3DXBaseMesh - -DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBaseMesh - STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(GetAttributeTable)( - THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; - - STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; - STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; - STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; -}; - - -#undef INTERFACE -#define INTERFACE ID3DXMesh - -DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBaseMesh - STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(GetAttributeTable)( - THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; - - STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; - STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; - STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; - - // ID3DXMesh - STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE; - STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; - STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppOptMesh) PURE; - STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap) PURE; - -}; - - -#undef INTERFACE -#define INTERFACE ID3DXPMesh - -DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBaseMesh - STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(GetAttributeTable)( - THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; - - STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; - STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; - STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; - - // ID3DXPMesh - STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(SetNumFaces)(THIS_ DWORD Faces) PURE; - STDMETHOD(SetNumVertices)(THIS_ DWORD Vertices) PURE; - STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetMinFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetMinVertices)(THIS) PURE; - STDMETHOD(Save)(THIS_ IStream *pStream, LPD3DXMATERIAL pMaterials, DWORD NumMaterials) PURE; - - STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppOptMesh) PURE; - - STDMETHOD(OptimizeBaseLOD)(THIS_ DWORD Flags, DWORD* pFaceRemap) PURE; - STDMETHOD(TrimByFaces)(THIS_ DWORD NewFacesMin, DWORD NewFacesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; - STDMETHOD(TrimByVertices)(THIS_ DWORD NewVerticesMin, DWORD NewVerticesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; - - STDMETHOD(GetAdjacency)(THIS_ DWORD* pAdjacency) PURE; -}; - - -#undef INTERFACE -#define INTERFACE ID3DXSPMesh - -DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXSPMesh - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ReduceFaces)(THIS_ DWORD Faces) PURE; - STDMETHOD(ReduceVertices)(THIS_ DWORD Vertices) PURE; - STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; - STDMETHOD(GetVertexAttributeWeights)(THIS_ LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights) PURE; - STDMETHOD(GetVertexWeights)(THIS_ FLOAT *pVertexWeights) PURE; -}; - -#define UNUSED16 (0xffff) -#define UNUSED32 (0xffffffff) - -// ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags -enum _D3DXMESHOPT { - D3DXMESHOPT_COMPACT = 0x01000000, - D3DXMESHOPT_ATTRSORT = 0x02000000, - D3DXMESHOPT_VERTEXCACHE = 0x04000000, - D3DXMESHOPT_STRIPREORDER = 0x08000000, - D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices - D3DXMESHOPT_SHAREVB = 0x1000, // same as D3DXMESH_VB_SHARE -}; - -// Subset of the mesh that has the same attribute and bone combination. -// This subset can be rendered in a single draw call -typedef struct _D3DXBONECOMBINATION -{ - DWORD AttribId; - DWORD FaceStart; - DWORD FaceCount; - DWORD VertexStart; - DWORD VertexCount; - DWORD* BoneId; -} D3DXBONECOMBINATION, *LPD3DXBONECOMBINATION; - - -#undef INTERFACE -#define INTERFACE ID3DXSkinMesh - -DECLARE_INTERFACE_(ID3DXSkinMesh, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXMesh - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(LockAttributeBuffer)(THIS_ DWORD flags, DWORD** ppData) PURE; - STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; - // ID3DXSkinMesh - STDMETHOD_(DWORD, GetNumBones)(THIS) PURE; - STDMETHOD(GetOriginalMesh)(THIS_ LPD3DXMESH* ppMesh) PURE; - STDMETHOD(SetBoneInfluence)(THIS_ DWORD bone, DWORD numInfluences, CONST DWORD* vertices, CONST FLOAT* weights) PURE; - STDMETHOD_(DWORD, GetNumBoneInfluences)(THIS_ DWORD bone) PURE; - STDMETHOD(GetBoneInfluence)(THIS_ DWORD bone, DWORD* vertices, FLOAT* weights) PURE; - STDMETHOD(GetMaxVertexInfluences)(THIS_ DWORD* maxVertexInfluences) PURE; - STDMETHOD(GetMaxFaceInfluences)(THIS_ DWORD* maxFaceInfluences) PURE; - - STDMETHOD(ConvertToBlendedMesh)(THIS_ DWORD Options, - CONST LPDWORD pAdjacencyIn, - LPDWORD pAdjacencyOut, - DWORD* pNumBoneCombinations, - LPD3DXBUFFER* ppBoneCombinationTable, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppMesh) PURE; - - STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ DWORD Options, - CONST LPDWORD pAdjacencyIn, - DWORD paletteSize, - LPDWORD pAdjacencyOut, - DWORD* pNumBoneCombinations, - LPD3DXBUFFER* ppBoneCombinationTable, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppMesh) PURE; - - STDMETHOD(GenerateSkinnedMesh)(THIS_ DWORD Options, - FLOAT minWeight, - CONST LPDWORD pAdjacencyIn, - LPDWORD pAdjacencyOut, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppMesh) PURE; - STDMETHOD(UpdateSkinnedMesh)(THIS_ CONST D3DXMATRIX* pBoneTransforms, CONST D3DXMATRIX* pBoneInvTransforms, LPD3DXMESH pMesh) PURE; -}; - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateMesh( - DWORD NumFaces, - DWORD NumVertices, - DWORD Options, - CONST DWORD *pDeclaration, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXMESH* ppMesh); - -HRESULT WINAPI - D3DXCreateMeshFVF( - DWORD NumFaces, - DWORD NumVertices, - DWORD Options, - DWORD FVF, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXMESH* ppMesh); - -HRESULT WINAPI - D3DXCreateSPMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, - CONST FLOAT *pVertexWeights, - LPD3DXSPMESH* ppSMesh); - -// clean a mesh up for simplification, try to make manifold -HRESULT WINAPI - D3DXCleanMesh( - LPD3DXMESH pMeshIn, - CONST DWORD* pAdjacencyIn, - LPD3DXMESH* ppMeshOut, - DWORD* pAdjacencyOut, - LPD3DXBUFFER* ppErrorsAndWarnings); - -HRESULT WINAPI - D3DXValidMesh( - LPD3DXMESH pMeshIn, - CONST DWORD* pAdjacency, - LPD3DXBUFFER* ppErrorsAndWarnings); - -HRESULT WINAPI - D3DXGeneratePMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, - CONST FLOAT *pVertexWeights, - DWORD MinValue, - DWORD Options, - LPD3DXPMESH* ppPMesh); - -HRESULT WINAPI - D3DXSimplifyMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, - CONST FLOAT *pVertexWeights, - DWORD MinValue, - DWORD Options, - LPD3DXMESH* ppMesh); - -HRESULT WINAPI - D3DXComputeBoundingSphere( - PVOID pPointsFVF, - DWORD NumVertices, - DWORD FVF, - D3DXVECTOR3 *pCenter, - FLOAT *pRadius); - -HRESULT WINAPI - D3DXComputeBoundingBox( - PVOID pPointsFVF, - DWORD NumVertices, - DWORD FVF, - D3DXVECTOR3 *pMin, - D3DXVECTOR3 *pMax); - -HRESULT WINAPI - D3DXComputeNormals( - LPD3DXBASEMESH pMesh, - CONST DWORD *pAdjacency); - -HRESULT WINAPI - D3DXCreateBuffer( - DWORD NumBytes, - LPD3DXBUFFER *ppBuffer); - - -HRESULT WINAPI - D3DXLoadMeshFromX( - LPSTR pFilename, - DWORD Options, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXLoadMeshFromXInMemory( - PBYTE Memory, - DWORD SizeOfMemory, - DWORD Options, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXLoadMeshFromXResource( - HMODULE Module, - LPCTSTR Name, - LPCTSTR Type, - DWORD Options, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXSaveMeshToX( - LPSTR pFilename, - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST LPD3DXMATERIAL pMaterials, - DWORD NumMaterials, - DWORD Format - ); - -HRESULT WINAPI - D3DXCreatePMeshFromStream( - IStream *pStream, - DWORD Options, - LPDIRECT3DDEVICE8 pD3DDevice, - LPD3DXBUFFER *ppMaterials, - DWORD* pNumMaterials, - LPD3DXPMESH *ppPMesh); - -HRESULT WINAPI - D3DXCreateSkinMesh( - DWORD NumFaces, - DWORD NumVertices, - DWORD NumBones, - DWORD Options, - CONST DWORD *pDeclaration, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXSKINMESH* ppSkinMesh); - -HRESULT WINAPI - D3DXCreateSkinMeshFVF( - DWORD NumFaces, - DWORD NumVertices, - DWORD NumBones, - DWORD Options, - DWORD FVF, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXSKINMESH* ppSkinMesh); - -HRESULT WINAPI - D3DXCreateSkinMeshFromMesh( - LPD3DXMESH pMesh, - DWORD numBones, - LPD3DXSKINMESH* ppSkinMesh); - -HRESULT WINAPI - D3DXLoadMeshFromXof( - LPDIRECTXFILEDATA pXofObjMesh, - DWORD Options, - LPDIRECT3DDEVICE8 pD3DDevice, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXLoadSkinMeshFromXof( - LPDIRECTXFILEDATA pxofobjMesh, - DWORD Options, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXBUFFER* ppAdjacency, - LPD3DXBUFFER* ppMaterials, - DWORD *pMatOut, - LPD3DXBUFFER* ppBoneNames, - LPD3DXBUFFER* ppBoneTransforms, - LPD3DXSKINMESH* ppMesh); - -HRESULT WINAPI - D3DXTessellateNPatches( - LPD3DXMESH pMeshIn, - CONST DWORD* pAdjacencyIn, - FLOAT NumSegs, - BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic - LPD3DXMESH *ppMeshOut, - LPD3DXBUFFER *ppAdjacencyOut); - -UINT WINAPI - D3DXGetFVFVertexSize(DWORD FVF); - -HRESULT WINAPI - D3DXDeclaratorFromFVF( - DWORD FVF, - DWORD Declaration[MAX_FVF_DECL_SIZE]); - -HRESULT WINAPI - D3DXFVFFromDeclarator( - CONST DWORD *pDeclarator, - DWORD *pFVF); - -HRESULT WINAPI - D3DXWeldVertices( - CONST LPD3DXMESH pMesh, - LPD3DXWELDEPSILONS pEpsilons, - CONST DWORD *pAdjacencyIn, - DWORD *pAdjacencyOut, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap); - -typedef struct _D3DXINTERSECTINFO -{ - DWORD FaceIndex; // index of face intersected - FLOAT U; // Barycentric Hit Coordinates - FLOAT V; // Barycentric Hit Coordinates - FLOAT Dist; // Ray-Intersection Parameter Distance -} D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO; - - -HRESULT WINAPI - D3DXIntersect( - LPD3DXBASEMESH pMesh, - CONST D3DXVECTOR3 *pRayPos, - CONST D3DXVECTOR3 *pRayDir, - BOOL *pHit, // True if any faces were intersected - DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) - DWORD *pCountOfHits); // Number of entries in AllHits array - -HRESULT WINAPI - D3DXIntersectSubset( - LPD3DXBASEMESH pMesh, - DWORD AttribId, - CONST D3DXVECTOR3 *pRayPos, - CONST D3DXVECTOR3 *pRayDir, - BOOL *pHit, // True if any faces were intersected - DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) - DWORD *pCountOfHits); // Number of entries in AllHits array - - -HRESULT WINAPI D3DXSplitMesh - ( - CONST LPD3DXMESH pMeshIn, - CONST DWORD *pAdjacencyIn, - CONST DWORD MaxSize, - CONST DWORD Options, - DWORD *pMeshesOut, - LPD3DXBUFFER *ppMeshArrayOut, - LPD3DXBUFFER *ppAdjacencyArrayOut, - LPD3DXBUFFER *ppFaceRemapArrayOut, - LPD3DXBUFFER *ppVertRemapArrayOut - ); - -BOOL D3DXIntersectTri -( - CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position - CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position - CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position - CONST D3DXVECTOR3 *pRayPos, // Ray origin - CONST D3DXVECTOR3 *pRayDir, // Ray direction - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist); // Ray-Intersection Parameter Distance - -BOOL WINAPI - D3DXSphereBoundProbe( - CONST D3DXVECTOR3 *pCenter, - FLOAT Radius, - CONST D3DXVECTOR3 *pRayPosition, - CONST D3DXVECTOR3 *pRayDirection); - -BOOL WINAPI - D3DXBoxBoundProbe( - CONST D3DXVECTOR3 *pMin, - CONST D3DXVECTOR3 *pMax, - CONST D3DXVECTOR3 *pRayPosition, - CONST D3DXVECTOR3 *pRayDirection); - -enum _D3DXERR { - D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900), - D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901), - D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902), - D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903), - D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904), - D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905), - D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906), -}; - - -#define D3DX_COMP_TANGENT_NONE 0xFFFFFFFF - -HRESULT WINAPI D3DXComputeTangent(LPD3DXMESH InMesh, - DWORD TexStage, - LPD3DXMESH OutMesh, - DWORD TexStageUVec, - DWORD TexStageVVec, - DWORD Wrap, - DWORD *Adjacency); - -HRESULT WINAPI -D3DXConvertMeshSubsetToSingleStrip -( - LPD3DXBASEMESH MeshIn, - DWORD AttribId, - DWORD IBOptions, - LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer, - DWORD *pNumIndices -); - -HRESULT WINAPI -D3DXConvertMeshSubsetToStrips -( - LPD3DXBASEMESH MeshIn, - DWORD AttribId, - DWORD IBOptions, - LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer, - DWORD *pNumIndices, - LPD3DXBUFFER *ppStripLengths, - DWORD *pNumStrips -); - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8MESH_H__ - - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8mesh.h +// Content: D3DX mesh types and functions +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8MESH_H__ +#define __D3DX8MESH_H__ + +#include "dxfile.h" // defines LPDIRECTXFILEDATA + +// {2A835771-BF4D-43f4-8E14-82A809F17D8A} +DEFINE_GUID(IID_ID3DXBaseMesh, +0x2a835771, 0xbf4d, 0x43f4, 0x8e, 0x14, 0x82, 0xa8, 0x9, 0xf1, 0x7d, 0x8a); + +// {CCAE5C3B-4DD1-4d0f-997E-4684CA64557F} +DEFINE_GUID(IID_ID3DXMesh, +0xccae5c3b, 0x4dd1, 0x4d0f, 0x99, 0x7e, 0x46, 0x84, 0xca, 0x64, 0x55, 0x7f); + +// {19FBE386-C282-4659-97BD-CB869B084A6C} +DEFINE_GUID(IID_ID3DXPMesh, +0x19fbe386, 0xc282, 0x4659, 0x97, 0xbd, 0xcb, 0x86, 0x9b, 0x8, 0x4a, 0x6c); + +// {4E3CA05C-D4FF-4d11-8A02-16459E08F6F4} +DEFINE_GUID(IID_ID3DXSPMesh, +0x4e3ca05c, 0xd4ff, 0x4d11, 0x8a, 0x2, 0x16, 0x45, 0x9e, 0x8, 0xf6, 0xf4); + +// {8DB06ECC-EBFC-408a-9404-3074B4773515} +DEFINE_GUID(IID_ID3DXSkinMesh, +0x8db06ecc, 0xebfc, 0x408a, 0x94, 0x4, 0x30, 0x74, 0xb4, 0x77, 0x35, 0x15); + +// Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags +enum _D3DXMESH { + D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. + D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB. + D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. + D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. + D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. + D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER + D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. + D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB. + D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB. + D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB. + D3DXMESH_IB_SYSTEMMEM = 0x100, // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER + D3DXMESH_IB_MANAGED = 0x200, // Use D3DPOOL_MANAGED for IB. + D3DXMESH_IB_WRITEONLY = 0x400, // Use D3DUSAGE_WRITEONLY for IB. + D3DXMESH_IB_DYNAMIC = 0x800, // Use D3DUSAGE_DYNAMIC for IB. + D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, // Use D3DUSAGE_SOFTWAREPROCESSING for IB. + + D3DXMESH_VB_SHARE = 0x1000, // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer + + D3DXMESH_USEHWONLY = 0x2000, // Valid for ID3DXSkinMesh::ConvertToBlendedMesh + + // Helper options + D3DXMESH_SYSTEMMEM = 0x110, // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM + D3DXMESH_MANAGED = 0x220, // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED + D3DXMESH_WRITEONLY = 0x440, // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY + D3DXMESH_DYNAMIC = 0x880, // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC + D3DXMESH_SOFTWAREPROCESSING = 0x18000, // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING + +}; + +// option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh +enum _D3DXMESHSIMP +{ + D3DXMESHSIMP_VERTEX = 0x1, + D3DXMESHSIMP_FACE = 0x2, + +}; + +enum _MAX_FVF_DECL_SIZE +{ + MAX_FVF_DECL_SIZE = 20 +}; + +typedef struct ID3DXBaseMesh *LPD3DXBASEMESH; +typedef struct ID3DXMesh *LPD3DXMESH; +typedef struct ID3DXPMesh *LPD3DXPMESH; +typedef struct ID3DXSPMesh *LPD3DXSPMESH; +typedef struct ID3DXSkinMesh *LPD3DXSKINMESH; + +typedef struct _D3DXATTRIBUTERANGE +{ + DWORD AttribId; + DWORD FaceStart; + DWORD FaceCount; + DWORD VertexStart; + DWORD VertexCount; +} D3DXATTRIBUTERANGE; + +typedef D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE; + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus +struct D3DXMATERIAL +{ + D3DMATERIAL8 MatD3D; + LPSTR pTextureFilename; +}; +typedef struct D3DXMATERIAL *LPD3DXMATERIAL; +#ifdef __cplusplus +} +#endif //__cplusplus + +typedef struct _D3DXATTRIBUTEWEIGHTS +{ + FLOAT Position; + FLOAT Boundary; + FLOAT Normal; + FLOAT Diffuse; + FLOAT Specular; + FLOAT Tex[8]; +} D3DXATTRIBUTEWEIGHTS; + +typedef D3DXATTRIBUTEWEIGHTS* LPD3DXATTRIBUTEWEIGHTS; + +enum _D3DXWELDEPSILONSFLAGS +{ + D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping + + D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched + // vertices so that both components identical AND if all components "equal" + // remove one of the vertices + D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal + // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set + // useful to modify vertices to be equal, but not allow vertices to be removed +}; + +typedef struct _D3DXWELDEPSILONS +{ + FLOAT SkinWeights; + FLOAT Normal; + FLOAT Tex[8]; + DWORD Flags; +} D3DXWELDEPSILONS; + +typedef D3DXWELDEPSILONS* LPD3DXWELDEPSILONS; + + +#undef INTERFACE +#define INTERFACE ID3DXBaseMesh + +DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; +}; + + +#undef INTERFACE +#define INTERFACE ID3DXMesh + +DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; + + // ID3DXMesh + STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE; + STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; + STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppOptMesh) PURE; + STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap) PURE; + +}; + + +#undef INTERFACE +#define INTERFACE ID3DXPMesh + +DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; + + // ID3DXPMesh + STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(SetNumFaces)(THIS_ DWORD Faces) PURE; + STDMETHOD(SetNumVertices)(THIS_ DWORD Vertices) PURE; + STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMinFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetMinVertices)(THIS) PURE; + STDMETHOD(Save)(THIS_ IStream *pStream, LPD3DXMATERIAL pMaterials, DWORD NumMaterials) PURE; + + STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppOptMesh) PURE; + + STDMETHOD(OptimizeBaseLOD)(THIS_ DWORD Flags, DWORD* pFaceRemap) PURE; + STDMETHOD(TrimByFaces)(THIS_ DWORD NewFacesMin, DWORD NewFacesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; + STDMETHOD(TrimByVertices)(THIS_ DWORD NewVerticesMin, DWORD NewVerticesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; + + STDMETHOD(GetAdjacency)(THIS_ DWORD* pAdjacency) PURE; +}; + + +#undef INTERFACE +#define INTERFACE ID3DXSPMesh + +DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXSPMesh + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ReduceFaces)(THIS_ DWORD Faces) PURE; + STDMETHOD(ReduceVertices)(THIS_ DWORD Vertices) PURE; + STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; + STDMETHOD(GetVertexAttributeWeights)(THIS_ LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights) PURE; + STDMETHOD(GetVertexWeights)(THIS_ FLOAT *pVertexWeights) PURE; +}; + +#define UNUSED16 (0xffff) +#define UNUSED32 (0xffffffff) + +// ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags +enum _D3DXMESHOPT { + D3DXMESHOPT_COMPACT = 0x01000000, + D3DXMESHOPT_ATTRSORT = 0x02000000, + D3DXMESHOPT_VERTEXCACHE = 0x04000000, + D3DXMESHOPT_STRIPREORDER = 0x08000000, + D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices + D3DXMESHOPT_SHAREVB = 0x1000, // same as D3DXMESH_VB_SHARE +}; + +// Subset of the mesh that has the same attribute and bone combination. +// This subset can be rendered in a single draw call +typedef struct _D3DXBONECOMBINATION +{ + DWORD AttribId; + DWORD FaceStart; + DWORD FaceCount; + DWORD VertexStart; + DWORD VertexCount; + DWORD* BoneId; +} D3DXBONECOMBINATION, *LPD3DXBONECOMBINATION; + + +#undef INTERFACE +#define INTERFACE ID3DXSkinMesh + +DECLARE_INTERFACE_(ID3DXSkinMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXMesh + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(LockAttributeBuffer)(THIS_ DWORD flags, DWORD** ppData) PURE; + STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; + // ID3DXSkinMesh + STDMETHOD_(DWORD, GetNumBones)(THIS) PURE; + STDMETHOD(GetOriginalMesh)(THIS_ LPD3DXMESH* ppMesh) PURE; + STDMETHOD(SetBoneInfluence)(THIS_ DWORD bone, DWORD numInfluences, CONST DWORD* vertices, CONST FLOAT* weights) PURE; + STDMETHOD_(DWORD, GetNumBoneInfluences)(THIS_ DWORD bone) PURE; + STDMETHOD(GetBoneInfluence)(THIS_ DWORD bone, DWORD* vertices, FLOAT* weights) PURE; + STDMETHOD(GetMaxVertexInfluences)(THIS_ DWORD* maxVertexInfluences) PURE; + STDMETHOD(GetMaxFaceInfluences)(THIS_ DWORD* maxFaceInfluences) PURE; + + STDMETHOD(ConvertToBlendedMesh)(THIS_ DWORD Options, + CONST LPDWORD pAdjacencyIn, + LPDWORD pAdjacencyOut, + DWORD* pNumBoneCombinations, + LPD3DXBUFFER* ppBoneCombinationTable, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppMesh) PURE; + + STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ DWORD Options, + CONST LPDWORD pAdjacencyIn, + DWORD paletteSize, + LPDWORD pAdjacencyOut, + DWORD* pNumBoneCombinations, + LPD3DXBUFFER* ppBoneCombinationTable, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppMesh) PURE; + + STDMETHOD(GenerateSkinnedMesh)(THIS_ DWORD Options, + FLOAT minWeight, + CONST LPDWORD pAdjacencyIn, + LPDWORD pAdjacencyOut, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppMesh) PURE; + STDMETHOD(UpdateSkinnedMesh)(THIS_ CONST D3DXMATRIX* pBoneTransforms, CONST D3DXMATRIX* pBoneInvTransforms, LPD3DXMESH pMesh) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateMesh( + DWORD NumFaces, + DWORD NumVertices, + DWORD Options, + CONST DWORD *pDeclaration, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXCreateMeshFVF( + DWORD NumFaces, + DWORD NumVertices, + DWORD Options, + DWORD FVF, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXCreateSPMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + LPD3DXSPMESH* ppSMesh); + +// clean a mesh up for simplification, try to make manifold +HRESULT WINAPI + D3DXCleanMesh( + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacencyIn, + LPD3DXMESH* ppMeshOut, + DWORD* pAdjacencyOut, + LPD3DXBUFFER* ppErrorsAndWarnings); + +HRESULT WINAPI + D3DXValidMesh( + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacency, + LPD3DXBUFFER* ppErrorsAndWarnings); + +HRESULT WINAPI + D3DXGeneratePMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + DWORD MinValue, + DWORD Options, + LPD3DXPMESH* ppPMesh); + +HRESULT WINAPI + D3DXSimplifyMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + DWORD MinValue, + DWORD Options, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXComputeBoundingSphere( + PVOID pPointsFVF, + DWORD NumVertices, + DWORD FVF, + D3DXVECTOR3 *pCenter, + FLOAT *pRadius); + +HRESULT WINAPI + D3DXComputeBoundingBox( + PVOID pPointsFVF, + DWORD NumVertices, + DWORD FVF, + D3DXVECTOR3 *pMin, + D3DXVECTOR3 *pMax); + +HRESULT WINAPI + D3DXComputeNormals( + LPD3DXBASEMESH pMesh, + CONST DWORD *pAdjacency); + +HRESULT WINAPI + D3DXCreateBuffer( + DWORD NumBytes, + LPD3DXBUFFER *ppBuffer); + + +HRESULT WINAPI + D3DXLoadMeshFromX( + LPSTR pFilename, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXLoadMeshFromXInMemory( + PBYTE Memory, + DWORD SizeOfMemory, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXLoadMeshFromXResource( + HMODULE Module, + LPCTSTR Name, + LPCTSTR Type, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXSaveMeshToX( + LPSTR pFilename, + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXMATERIAL pMaterials, + DWORD NumMaterials, + DWORD Format + ); + +HRESULT WINAPI + D3DXCreatePMeshFromStream( + IStream *pStream, + DWORD Options, + LPDIRECT3DDEVICE8 pD3DDevice, + LPD3DXBUFFER *ppMaterials, + DWORD* pNumMaterials, + LPD3DXPMESH *ppPMesh); + +HRESULT WINAPI + D3DXCreateSkinMesh( + DWORD NumFaces, + DWORD NumVertices, + DWORD NumBones, + DWORD Options, + CONST DWORD *pDeclaration, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXSKINMESH* ppSkinMesh); + +HRESULT WINAPI + D3DXCreateSkinMeshFVF( + DWORD NumFaces, + DWORD NumVertices, + DWORD NumBones, + DWORD Options, + DWORD FVF, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXSKINMESH* ppSkinMesh); + +HRESULT WINAPI + D3DXCreateSkinMeshFromMesh( + LPD3DXMESH pMesh, + DWORD numBones, + LPD3DXSKINMESH* ppSkinMesh); + +HRESULT WINAPI + D3DXLoadMeshFromXof( + LPDIRECTXFILEDATA pXofObjMesh, + DWORD Options, + LPDIRECT3DDEVICE8 pD3DDevice, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXLoadSkinMeshFromXof( + LPDIRECTXFILEDATA pxofobjMesh, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER* ppAdjacency, + LPD3DXBUFFER* ppMaterials, + DWORD *pMatOut, + LPD3DXBUFFER* ppBoneNames, + LPD3DXBUFFER* ppBoneTransforms, + LPD3DXSKINMESH* ppMesh); + +HRESULT WINAPI + D3DXTessellateNPatches( + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacencyIn, + FLOAT NumSegs, + BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic + LPD3DXMESH *ppMeshOut, + LPD3DXBUFFER *ppAdjacencyOut); + +UINT WINAPI + D3DXGetFVFVertexSize(DWORD FVF); + +HRESULT WINAPI + D3DXDeclaratorFromFVF( + DWORD FVF, + DWORD Declaration[MAX_FVF_DECL_SIZE]); + +HRESULT WINAPI + D3DXFVFFromDeclarator( + CONST DWORD *pDeclarator, + DWORD *pFVF); + +HRESULT WINAPI + D3DXWeldVertices( + CONST LPD3DXMESH pMesh, + LPD3DXWELDEPSILONS pEpsilons, + CONST DWORD *pAdjacencyIn, + DWORD *pAdjacencyOut, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap); + +typedef struct _D3DXINTERSECTINFO +{ + DWORD FaceIndex; // index of face intersected + FLOAT U; // Barycentric Hit Coordinates + FLOAT V; // Barycentric Hit Coordinates + FLOAT Dist; // Ray-Intersection Parameter Distance +} D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO; + + +HRESULT WINAPI + D3DXIntersect( + LPD3DXBASEMESH pMesh, + CONST D3DXVECTOR3 *pRayPos, + CONST D3DXVECTOR3 *pRayDir, + BOOL *pHit, // True if any faces were intersected + DWORD *pFaceIndex, // index of closest face intersected + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist, // Ray-Intersection Parameter Distance + LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) + DWORD *pCountOfHits); // Number of entries in AllHits array + +HRESULT WINAPI + D3DXIntersectSubset( + LPD3DXBASEMESH pMesh, + DWORD AttribId, + CONST D3DXVECTOR3 *pRayPos, + CONST D3DXVECTOR3 *pRayDir, + BOOL *pHit, // True if any faces were intersected + DWORD *pFaceIndex, // index of closest face intersected + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist, // Ray-Intersection Parameter Distance + LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) + DWORD *pCountOfHits); // Number of entries in AllHits array + + +HRESULT WINAPI D3DXSplitMesh + ( + CONST LPD3DXMESH pMeshIn, + CONST DWORD *pAdjacencyIn, + CONST DWORD MaxSize, + CONST DWORD Options, + DWORD *pMeshesOut, + LPD3DXBUFFER *ppMeshArrayOut, + LPD3DXBUFFER *ppAdjacencyArrayOut, + LPD3DXBUFFER *ppFaceRemapArrayOut, + LPD3DXBUFFER *ppVertRemapArrayOut + ); + +BOOL D3DXIntersectTri +( + CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position + CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position + CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position + CONST D3DXVECTOR3 *pRayPos, // Ray origin + CONST D3DXVECTOR3 *pRayDir, // Ray direction + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist); // Ray-Intersection Parameter Distance + +BOOL WINAPI + D3DXSphereBoundProbe( + CONST D3DXVECTOR3 *pCenter, + FLOAT Radius, + CONST D3DXVECTOR3 *pRayPosition, + CONST D3DXVECTOR3 *pRayDirection); + +BOOL WINAPI + D3DXBoxBoundProbe( + CONST D3DXVECTOR3 *pMin, + CONST D3DXVECTOR3 *pMax, + CONST D3DXVECTOR3 *pRayPosition, + CONST D3DXVECTOR3 *pRayDirection); + +enum _D3DXERR { + D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900), + D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901), + D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902), + D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903), + D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904), + D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905), + D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906), +}; + + +#define D3DX_COMP_TANGENT_NONE 0xFFFFFFFF + +HRESULT WINAPI D3DXComputeTangent(LPD3DXMESH InMesh, + DWORD TexStage, + LPD3DXMESH OutMesh, + DWORD TexStageUVec, + DWORD TexStageVVec, + DWORD Wrap, + DWORD *Adjacency); + +HRESULT WINAPI +D3DXConvertMeshSubsetToSingleStrip +( + LPD3DXBASEMESH MeshIn, + DWORD AttribId, + DWORD IBOptions, + LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer, + DWORD *pNumIndices +); + +HRESULT WINAPI +D3DXConvertMeshSubsetToStrips +( + LPD3DXBASEMESH MeshIn, + DWORD AttribId, + DWORD IBOptions, + LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer, + DWORD *pNumIndices, + LPD3DXBUFFER *ppStripLengths, + DWORD *pNumStrips +); + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8MESH_H__ + + diff --git a/src/dep/include/DXSDK/include/d3dx8shape.h b/src/dep/include/DXSDK/include/d3dx8shape.h index c4d3630..b7ab637 100644 --- a/src/dep/include/DXSDK/include/d3dx8shape.h +++ b/src/dep/include/DXSDK/include/d3dx8shape.h @@ -1,220 +1,220 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8shapes.h -// Content: D3DX simple shapes -// -/////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8SHAPES_H__ -#define __D3DX8SHAPES_H__ - -/////////////////////////////////////////////////////////////////////////// -// Functions: -/////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -//------------------------------------------------------------------------- -// D3DXCreatePolygon: -// ------------------ -// Creates a mesh containing an n-sided polygon. The polygon is centered -// at the origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Length Length of each side. -// Sides Number of sides the polygon has. (Must be >= 3) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreatePolygon( - LPDIRECT3DDEVICE8 pDevice, - FLOAT Length, - UINT Sides, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateBox: -// -------------- -// Creates a mesh containing an axis-aligned box. The box is centered at -// the origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Width Width of box (along X-axis) -// Height Height of box (along Y-axis) -// Depth Depth of box (along Z-axis) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateBox( - LPDIRECT3DDEVICE8 pDevice, - FLOAT Width, - FLOAT Height, - FLOAT Depth, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateCylinder: -// ------------------- -// Creates a mesh containing a cylinder. The generated cylinder is -// centered at the origin, and its axis is aligned with the Z-axis. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Radius1 Radius at -Z end (should be >= 0.0f) -// Radius2 Radius at +Z end (should be >= 0.0f) -// Length Length of cylinder (along Z-axis) -// Slices Number of slices about the main axis -// Stacks Number of stacks along the main axis -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateCylinder( - LPDIRECT3DDEVICE8 pDevice, - FLOAT Radius1, - FLOAT Radius2, - FLOAT Length, - UINT Slices, - UINT Stacks, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateSphere: -// ----------------- -// Creates a mesh containing a sphere. The sphere is centered at the -// origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Radius Radius of the sphere (should be >= 0.0f) -// Slices Number of slices about the main axis -// Stacks Number of stacks along the main axis -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateSphere( - LPDIRECT3DDEVICE8 pDevice, - FLOAT Radius, - UINT Slices, - UINT Stacks, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateTorus: -// ---------------- -// Creates a mesh containing a torus. The generated torus is centered at -// the origin, and its axis is aligned with the Z-axis. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// InnerRadius Inner radius of the torus (should be >= 0.0f) -// OuterRadius Outer radius of the torue (should be >= 0.0f) -// Sides Number of sides in a cross-section (must be >= 3) -// Rings Number of rings making up the torus (must be >= 3) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTorus( - LPDIRECT3DDEVICE8 pDevice, - FLOAT InnerRadius, - FLOAT OuterRadius, - UINT Sides, - UINT Rings, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateTeapot: -// ----------------- -// Creates a mesh containing a teapot. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTeapot( - LPDIRECT3DDEVICE8 pDevice, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateText: -// --------------- -// Creates a mesh containing the specified text using the font associated -// with the device context. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// hDC Device context, with desired font selected -// pText Text to generate -// Deviation Maximum chordal deviation from true font outlines -// Extrusion Amount to extrude text in -Z direction -// ppMesh The mesh object which will be created -// pGlyphMetrics Address of buffer to receive glyph metric data (or NULL) -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTextA( - LPDIRECT3DDEVICE8 pDevice, - HDC hDC, - LPCSTR pText, - FLOAT Deviation, - FLOAT Extrusion, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency, - LPGLYPHMETRICSFLOAT pGlyphMetrics); - -HRESULT WINAPI - D3DXCreateTextW( - LPDIRECT3DDEVICE8 pDevice, - HDC hDC, - LPCWSTR pText, - FLOAT Deviation, - FLOAT Extrusion, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency, - LPGLYPHMETRICSFLOAT pGlyphMetrics); - -#ifdef UNICODE -#define D3DXCreateText D3DXCreateTextW -#else -#define D3DXCreateText D3DXCreateTextA -#endif - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8SHAPES_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8shapes.h +// Content: D3DX simple shapes +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8SHAPES_H__ +#define __D3DX8SHAPES_H__ + +/////////////////////////////////////////////////////////////////////////// +// Functions: +/////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +//------------------------------------------------------------------------- +// D3DXCreatePolygon: +// ------------------ +// Creates a mesh containing an n-sided polygon. The polygon is centered +// at the origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Length Length of each side. +// Sides Number of sides the polygon has. (Must be >= 3) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreatePolygon( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Length, + UINT Sides, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateBox: +// -------------- +// Creates a mesh containing an axis-aligned box. The box is centered at +// the origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Width Width of box (along X-axis) +// Height Height of box (along Y-axis) +// Depth Depth of box (along Z-axis) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateBox( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Width, + FLOAT Height, + FLOAT Depth, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateCylinder: +// ------------------- +// Creates a mesh containing a cylinder. The generated cylinder is +// centered at the origin, and its axis is aligned with the Z-axis. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Radius1 Radius at -Z end (should be >= 0.0f) +// Radius2 Radius at +Z end (should be >= 0.0f) +// Length Length of cylinder (along Z-axis) +// Slices Number of slices about the main axis +// Stacks Number of stacks along the main axis +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateCylinder( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Radius1, + FLOAT Radius2, + FLOAT Length, + UINT Slices, + UINT Stacks, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateSphere: +// ----------------- +// Creates a mesh containing a sphere. The sphere is centered at the +// origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Radius Radius of the sphere (should be >= 0.0f) +// Slices Number of slices about the main axis +// Stacks Number of stacks along the main axis +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateSphere( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Radius, + UINT Slices, + UINT Stacks, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateTorus: +// ---------------- +// Creates a mesh containing a torus. The generated torus is centered at +// the origin, and its axis is aligned with the Z-axis. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// InnerRadius Inner radius of the torus (should be >= 0.0f) +// OuterRadius Outer radius of the torue (should be >= 0.0f) +// Sides Number of sides in a cross-section (must be >= 3) +// Rings Number of rings making up the torus (must be >= 3) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTorus( + LPDIRECT3DDEVICE8 pDevice, + FLOAT InnerRadius, + FLOAT OuterRadius, + UINT Sides, + UINT Rings, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateTeapot: +// ----------------- +// Creates a mesh containing a teapot. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTeapot( + LPDIRECT3DDEVICE8 pDevice, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateText: +// --------------- +// Creates a mesh containing the specified text using the font associated +// with the device context. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// hDC Device context, with desired font selected +// pText Text to generate +// Deviation Maximum chordal deviation from true font outlines +// Extrusion Amount to extrude text in -Z direction +// ppMesh The mesh object which will be created +// pGlyphMetrics Address of buffer to receive glyph metric data (or NULL) +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTextA( + LPDIRECT3DDEVICE8 pDevice, + HDC hDC, + LPCSTR pText, + FLOAT Deviation, + FLOAT Extrusion, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency, + LPGLYPHMETRICSFLOAT pGlyphMetrics); + +HRESULT WINAPI + D3DXCreateTextW( + LPDIRECT3DDEVICE8 pDevice, + HDC hDC, + LPCWSTR pText, + FLOAT Deviation, + FLOAT Extrusion, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency, + LPGLYPHMETRICSFLOAT pGlyphMetrics); + +#ifdef UNICODE +#define D3DXCreateText D3DXCreateTextW +#else +#define D3DXCreateText D3DXCreateTextA +#endif + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8SHAPES_H__ diff --git a/src/dep/include/DXSDK/include/d3dx8tex.h b/src/dep/include/DXSDK/include/d3dx8tex.h index 2bdfce8..dd9fe9d 100644 --- a/src/dep/include/DXSDK/include/d3dx8tex.h +++ b/src/dep/include/DXSDK/include/d3dx8tex.h @@ -1,1592 +1,1592 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8tex.h -// Content: D3DX texturing APIs -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8TEX_H__ -#define __D3DX8TEX_H__ - - -//---------------------------------------------------------------------------- -// D3DX_FILTER flags: -// ------------------ -// -// A valid filter must contain one of these values: -// -// D3DX_FILTER_NONE -// No scaling or filtering will take place. Pixels outside the bounds -// of the source image are assumed to be transparent black. -// D3DX_FILTER_POINT -// Each destination pixel is computed by sampling the nearest pixel -// from the source image. -// D3DX_FILTER_LINEAR -// Each destination pixel is computed by linearly interpolating between -// the nearest pixels in the source image. This filter works best -// when the scale on each axis is less than 2. -// D3DX_FILTER_TRIANGLE -// Every pixel in the source image contributes equally to the -// destination image. This is the slowest of all the filters. -// D3DX_FILTER_BOX -// Each pixel is computed by averaging a 2x2(x2) box pixels from -// the source image. Only works when the dimensions of the -// destination are half those of the source. (as with mip maps) -// -// And can be OR'd with any of these optional flags: -// -// D3DX_FILTER_MIRROR_U -// Indicates that pixels off the edge of the texture on the U-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR_V -// Indicates that pixels off the edge of the texture on the V-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR_W -// Indicates that pixels off the edge of the texture on the W-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR -// Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V | -// D3DX_FILTER_MIRROR_V -// D3DX_FILTER_DITHER -// Dithers the resulting image. -// -//---------------------------------------------------------------------------- - -#define D3DX_FILTER_NONE (1 << 0) -#define D3DX_FILTER_POINT (2 << 0) -#define D3DX_FILTER_LINEAR (3 << 0) -#define D3DX_FILTER_TRIANGLE (4 << 0) -#define D3DX_FILTER_BOX (5 << 0) - -#define D3DX_FILTER_MIRROR_U (1 << 16) -#define D3DX_FILTER_MIRROR_V (2 << 16) -#define D3DX_FILTER_MIRROR_W (4 << 16) -#define D3DX_FILTER_MIRROR (7 << 16) -#define D3DX_FILTER_DITHER (8 << 16) - - -//---------------------------------------------------------------------------- -// D3DX_NORMALMAP flags: -// --------------------- -// These flags are used to control how D3DXComputeNormalMap generates normal -// maps. Any number of these flags may be OR'd together in any combination. -// -// D3DX_NORMALMAP_MIRROR_U -// Indicates that pixels off the edge of the texture on the U-axis -// should be mirrored, not wraped. -// D3DX_NORMALMAP_MIRROR_V -// Indicates that pixels off the edge of the texture on the V-axis -// should be mirrored, not wraped. -// D3DX_NORMALMAP_MIRROR -// Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V -// D3DX_NORMALMAP_INVERTSIGN -// Inverts the direction of each normal -// D3DX_NORMALMAP_COMPUTE_OCCLUSION -// Compute the per pixel Occlusion term and encodes it into the alpha. -// An Alpha of 1 means that the pixel is not obscured in anyway, and -// an alpha of 0 would mean that the pixel is completly obscured. -// -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- - -#define D3DX_NORMALMAP_MIRROR_U (1 << 16) -#define D3DX_NORMALMAP_MIRROR_V (2 << 16) -#define D3DX_NORMALMAP_MIRROR (3 << 16) -#define D3DX_NORMALMAP_INVERTSIGN (8 << 16) -#define D3DX_NORMALMAP_COMPUTE_OCCLUSION (16 << 16) - - - - -//---------------------------------------------------------------------------- -// D3DX_CHANNEL flags: -// ------------------- -// These flags are used by functions which operate on or more channels -// in a texture. -// -// D3DX_CHANNEL_RED -// Indicates the red channel should be used -// D3DX_CHANNEL_BLUE -// Indicates the blue channel should be used -// D3DX_CHANNEL_GREEN -// Indicates the green channel should be used -// D3DX_CHANNEL_ALPHA -// Indicates the alpha channel should be used -// D3DX_CHANNEL_LUMINANCE -// Indicates the luminaces of the red green and blue channels should be -// used. -// -//---------------------------------------------------------------------------- - -#define D3DX_CHANNEL_RED (1 << 0) -#define D3DX_CHANNEL_BLUE (1 << 1) -#define D3DX_CHANNEL_GREEN (1 << 2) -#define D3DX_CHANNEL_ALPHA (1 << 3) -#define D3DX_CHANNEL_LUMINANCE (1 << 4) - - - - -//---------------------------------------------------------------------------- -// D3DXIMAGE_FILEFORMAT: -// --------------------- -// This enum is used to describe supported image file formats. -// -//---------------------------------------------------------------------------- - -typedef enum _D3DXIMAGE_FILEFORMAT -{ - D3DXIFF_BMP = 0, - D3DXIFF_JPG = 1, - D3DXIFF_TGA = 2, - D3DXIFF_PNG = 3, - D3DXIFF_DDS = 4, - D3DXIFF_PPM = 5, - D3DXIFF_DIB = 6, - D3DXIFF_FORCE_DWORD = 0x7fffffff - -} D3DXIMAGE_FILEFORMAT; - - -//---------------------------------------------------------------------------- -// LPD3DXFILL2D and LPD3DXFILL3D: -// ------------------------------ -// Function types used by the texture fill functions. -// -// Parameters: -// pOut -// Pointer to a vector which the function uses to return its result. -// X,Y,Z,W will be mapped to R,G,B,A respectivly. -// pTexCoord -// Pointer to a vector containing the coordinates of the texel currently -// being evaluated. Textures and VolumeTexture texcoord components -// range from 0 to 1. CubeTexture texcoord component range from -1 to 1. -// pTexelSize -// Pointer to a vector containing the dimensions of the current texel. -// pData -// Pointer to user data. -// -//---------------------------------------------------------------------------- - -typedef VOID (*LPD3DXFILL2D)(D3DXVECTOR4 *pOut, D3DXVECTOR2 *pTexCoord, D3DXVECTOR2 *pTexelSize, LPVOID pData); -typedef VOID (*LPD3DXFILL3D)(D3DXVECTOR4 *pOut, D3DXVECTOR3 *pTexCoord, D3DXVECTOR3 *pTexelSize, LPVOID pData); - - - -//---------------------------------------------------------------------------- -// D3DXIMAGE_INFO: -// --------------- -// This structure is used to return a rough description of what the -// the original contents of an image file looked like. -// -// Width -// Width of original image in pixels -// Height -// Height of original image in pixels -// Depth -// Depth of original image in pixels -// MipLevels -// Number of mip levels in original image -// Format -// D3D format which most closely describes the data in original image -// ResourceType -// D3DRESOURCETYPE representing the type of texture stored in the file. -// D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE. -// ImageFileFormat -// D3DXIMAGE_FILEFORMAT representing the format of the image file. -// -//---------------------------------------------------------------------------- - -typedef struct _D3DXIMAGE_INFO -{ - UINT Width; - UINT Height; - UINT Depth; - UINT MipLevels; - D3DFORMAT Format; - D3DRESOURCETYPE ResourceType; - D3DXIMAGE_FILEFORMAT ImageFileFormat; - -} D3DXIMAGE_INFO; - - - - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - - -////////////////////////////////////////////////////////////////////////////// -// Image File APIs /////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -; -//---------------------------------------------------------------------------- -// GetImageInfoFromFile/Resource: -// ------------------------------ -// Fills in a D3DXIMAGE_INFO struct with information about an image file. -// -// Parameters: -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXGetImageInfoFromFileA( - LPCSTR pSrcFile, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXGetImageInfoFromFileW( - LPCWSTR pSrcFile, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileW -#else -#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileA -#endif - - -HRESULT WINAPI - D3DXGetImageInfoFromResourceA( - HMODULE hSrcModule, - LPCSTR pSrcResource, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXGetImageInfoFromResourceW( - HMODULE hSrcModule, - LPCWSTR pSrcResource, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceW -#else -#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceA -#endif - - -HRESULT WINAPI - D3DXGetImageInfoFromFileInMemory( - LPCVOID pSrcData, - UINT SrcDataSize, - D3DXIMAGE_INFO* pSrcInfo); - - - - -////////////////////////////////////////////////////////////////////////////// -// Load/Save Surface APIs //////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromFile/Resource: -// --------------------------------- -// Load surface from a file or resource -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcRect -// Source rectangle, or NULL for entire image -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadSurfaceFromFileA( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCSTR pSrcFile, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadSurfaceFromFileW( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCWSTR pSrcFile, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileW -#else -#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileA -#endif - - - -HRESULT WINAPI - D3DXLoadSurfaceFromResourceA( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadSurfaceFromResourceW( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - - -#ifdef UNICODE -#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceW -#else -#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceA -#endif - - - -HRESULT WINAPI - D3DXLoadSurfaceFromFileInMemory( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCVOID pSrcData, - UINT SrcDataSize, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - - - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromSurface: -// --------------------------- -// Load surface from another surface (with color conversion) -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcSurface -// Source surface -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle, or NULL for entire surface -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadSurfaceFromSurface( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPDIRECT3DSURFACE8 pSrcSurface, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey); - - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromMemory: -// -------------------------- -// Load surface from memory. -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcMemory -// Pointer to the top-left corner of the source image in memory -// SrcFormat -// Pixel format of the source image. -// SrcPitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the width of one row of cells, in bytes. -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle. -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadSurfaceFromMemory( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCVOID pSrcMemory, - D3DFORMAT SrcFormat, - UINT SrcPitch, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey); - - -//---------------------------------------------------------------------------- -// D3DXSaveSurfaceToFile: -// ---------------------- -// Save a surface to a image file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcSurface -// Source surface, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle, or NULL for the entire image -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXSaveSurfaceToFileA( - LPCSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DSURFACE8 pSrcSurface, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect); - -HRESULT WINAPI - D3DXSaveSurfaceToFileW( - LPCWSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DSURFACE8 pSrcSurface, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect); - -#ifdef UNICODE -#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW -#else -#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA -#endif - - - - -////////////////////////////////////////////////////////////////////////////// -// Load/Save Volume APIs ///////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromFile/Resource: -// -------------------------------- -// Load volume from a file or resource -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcBox -// Source box, or NULL for entire image -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadVolumeFromFileA( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCSTR pSrcFile, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadVolumeFromFileW( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCWSTR pSrcFile, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileW -#else -#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileA -#endif - - -HRESULT WINAPI - D3DXLoadVolumeFromResourceA( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadVolumeFromResourceW( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceW -#else -#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceA -#endif - - - -HRESULT WINAPI - D3DXLoadVolumeFromFileInMemory( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCVOID pSrcData, - UINT SrcDataSize, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - - - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromVolume: -// ------------------------- -// Load volume from another volume (with color conversion) -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcVolume -// Source volume -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box, or NULL for entire volume -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadVolumeFromVolume( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPDIRECT3DVOLUME8 pSrcVolume, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey); - - - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromMemory: -// ------------------------- -// Load volume from memory. -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcMemory -// Pointer to the top-left corner of the source volume in memory -// SrcFormat -// Pixel format of the source volume. -// SrcRowPitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the size of one row of cells, in bytes. -// SrcSlicePitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the size of one slice of cells, in bytes. -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box. -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadVolumeFromMemory( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCVOID pSrcMemory, - D3DFORMAT SrcFormat, - UINT SrcRowPitch, - UINT SrcSlicePitch, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey); - - - -//---------------------------------------------------------------------------- -// D3DXSaveVolumeToFile: -// --------------------- -// Save a volume to a image file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcVolume -// Source volume, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box, or NULL for the entire volume -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXSaveVolumeToFileA( - LPCSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DVOLUME8 pSrcVolume, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox); - -HRESULT WINAPI - D3DXSaveVolumeToFileW( - LPCWSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DVOLUME8 pSrcVolume, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox); - -#ifdef UNICODE -#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileW -#else -#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileA -#endif - - - - -////////////////////////////////////////////////////////////////////////////// -// Create/Save Texture APIs ////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXCheckTextureRequirements: -// ----------------------------- -// Checks texture creation parameters. If parameters are invalid, this -// function returns corrected parameters. -// -// Parameters: -// -// pDevice -// The D3D device to be used -// pWidth, pHeight, pDepth, pSize -// Desired size in pixels, or NULL. Returns corrected size. -// pNumMipLevels -// Number of desired mipmap levels, or NULL. Returns corrected number. -// Usage -// Texture usage flags -// pFormat -// Desired pixel format, or NULL. Returns corrected format. -// Pool -// Memory pool to be used to create texture -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCheckTextureRequirements( - LPDIRECT3DDEVICE8 pDevice, - UINT* pWidth, - UINT* pHeight, - UINT* pNumMipLevels, - DWORD Usage, - D3DFORMAT* pFormat, - D3DPOOL Pool); - -HRESULT WINAPI - D3DXCheckCubeTextureRequirements( - LPDIRECT3DDEVICE8 pDevice, - UINT* pSize, - UINT* pNumMipLevels, - DWORD Usage, - D3DFORMAT* pFormat, - D3DPOOL Pool); - -HRESULT WINAPI - D3DXCheckVolumeTextureRequirements( - LPDIRECT3DDEVICE8 pDevice, - UINT* pWidth, - UINT* pHeight, - UINT* pDepth, - UINT* pNumMipLevels, - DWORD Usage, - D3DFORMAT* pFormat, - D3DPOOL Pool); - - -//---------------------------------------------------------------------------- -// D3DXCreateTexture: -// ------------------ -// Create an empty texture -// -// Parameters: -// -// pDevice -// The D3D device with which the texture is going to be used. -// Width, Height, Depth, Size -// size in pixels; these must be non-zero -// MipLevels -// number of mip levels desired; if zero or D3DX_DEFAULT, a complete -// mipmap chain will be created. -// Usage -// Texture usage flags -// Format -// Pixel format. -// Pool -// Memory pool to be used to create texture -// ppTexture, ppCubeTexture, ppVolumeTexture -// The texture object that will be created -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCreateTexture( - LPDIRECT3DDEVICE8 pDevice, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateCubeTexture( - LPDIRECT3DDEVICE8 pDevice, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTexture( - LPDIRECT3DDEVICE8 pDevice, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - - - -//---------------------------------------------------------------------------- -// D3DXCreateTextureFromFile/Resource: -// ----------------------------------- -// Create a texture object from a file or resource. -// -// Parameters: -// -// pDevice -// The D3D device with which the texture is going to be used. -// pSrcFile -// File name. -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pvSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// Width, Height, Depth, Size -// Size in pixels; if zero or D3DX_DEFAULT, the size will be taken -// from the file. -// MipLevels -// Number of mip levels; if zero or D3DX_DEFAULT, a complete mipmap -// chain will be created. -// Usage -// Texture usage flags -// Format -// Desired pixel format. If D3DFMT_UNKNOWN, the format will be -// taken from the file. -// Pool -// Memory pool to be used to create texture -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// MipFilter -// D3DX_FILTER flags controlling how each miplevel is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_BOX, -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// pPalette -// 256 color palette to be filled in, or NULL -// ppTexture, ppCubeTexture, ppVolumeTexture -// The texture object that will be created -// -//---------------------------------------------------------------------------- - - -// FromFile - -HRESULT WINAPI - D3DXCreateTextureFromFileA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromFileW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - LPDIRECT3DTEXTURE8* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileW -#else -#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileW -#else -#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileW -#else -#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileA -#endif - - -// FromResource - -HRESULT WINAPI - D3DXCreateTextureFromResourceA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromResourceW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPDIRECT3DTEXTURE8* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceW -#else -#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceW -#else -#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceW -#else -#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceA -#endif - - -// FromFileEx - -HRESULT WINAPI - D3DXCreateTextureFromFileExA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromFileExW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExW -#else -#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileExA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileExW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExW -#else -#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileExA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileExW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExW -#else -#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExA -#endif - - -// FromResourceEx - -HRESULT WINAPI - D3DXCreateTextureFromResourceExA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromResourceExW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExW -#else -#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceExA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceExW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExW -#else -#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceExA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceExW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExW -#else -#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExA -#endif - - -// FromFileInMemory - -HRESULT WINAPI - D3DXCreateTextureFromFileInMemory( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileInMemory( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileInMemory( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - - -// FromFileInMemoryEx - -HRESULT WINAPI - D3DXCreateTextureFromFileInMemoryEx( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileInMemoryEx( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileInMemoryEx( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - - - -//---------------------------------------------------------------------------- -// D3DXSaveTextureToFile: -// ---------------------- -// Save a texture to a file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcTexture -// Source texture, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// -//---------------------------------------------------------------------------- - - -HRESULT WINAPI - D3DXSaveTextureToFileA( - LPCSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DBASETEXTURE8 pSrcTexture, - CONST PALETTEENTRY* pSrcPalette); - -HRESULT WINAPI - D3DXSaveTextureToFileW( - LPCWSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DBASETEXTURE8 pSrcTexture, - CONST PALETTEENTRY* pSrcPalette); - -#ifdef UNICODE -#define D3DXSaveTextureToFile D3DXSaveTextureToFileW -#else -#define D3DXSaveTextureToFile D3DXSaveTextureToFileA -#endif - - - - -////////////////////////////////////////////////////////////////////////////// -// Misc Texture APIs ///////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXFilterTexture: -// ------------------ -// Filters mipmaps levels of a texture. -// -// Parameters: -// pBaseTexture -// The texture object to be filtered -// pPalette -// 256 color palette to be used, or NULL for non-palettized formats -// SrcLevel -// The level whose image is used to generate the subsequent levels. -// Filter -// D3DX_FILTER flags controlling how each miplevel is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_BOX, -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXFilterTexture( - LPDIRECT3DBASETEXTURE8 pBaseTexture, - CONST PALETTEENTRY* pPalette, - UINT SrcLevel, - DWORD Filter); - -#define D3DXFilterCubeTexture D3DXFilterTexture -#define D3DXFilterVolumeTexture D3DXFilterTexture - - - -//---------------------------------------------------------------------------- -// D3DXFillTexture: -// ---------------- -// Uses a user provided function to fill each texel of each mip level of a -// given texture. -// -// Paramters: -// pTexture, pCubeTexture, pVolumeTexture -// Pointer to the texture to be filled. -// pFunction -// Pointer to user provided evalutor function which will be used to -// compute the value of each texel. -// pData -// Pointer to an arbitrary block of user defined data. This pointer -// will be passed to the function provided in pFunction -//----------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXFillTexture( - LPDIRECT3DTEXTURE8 pTexture, - LPD3DXFILL2D pFunction, - LPVOID pData); - -HRESULT WINAPI - D3DXFillCubeTexture( - LPDIRECT3DCUBETEXTURE8 pCubeTexture, - LPD3DXFILL3D pFunction, - LPVOID pData); - -HRESULT WINAPI - D3DXFillVolumeTexture( - LPDIRECT3DVOLUMETEXTURE8 pVolumeTexture, - LPD3DXFILL3D pFunction, - LPVOID pData); - - - -//---------------------------------------------------------------------------- -// D3DXComputeNormalMap: -// --------------------- -// Converts a height map into a normal map. The (x,y,z) components of each -// normal are mapped to the (r,g,b) channels of the output texture. -// -// Parameters -// pTexture -// Pointer to the destination texture -// pSrcTexture -// Pointer to the source heightmap texture -// pSrcPalette -// Source palette of 256 colors, or NULL -// Flags -// D3DX_NORMALMAP flags -// Channel -// D3DX_CHANNEL specifying source of height information -// Amplitude -// The constant value which the height information is multiplied by. -//--------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXComputeNormalMap( - LPDIRECT3DTEXTURE8 pTexture, - LPDIRECT3DTEXTURE8 pSrcTexture, - CONST PALETTEENTRY* pSrcPalette, - DWORD Flags, - DWORD Channel, - FLOAT Amplitude); - - - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8TEX_H__ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8tex.h +// Content: D3DX texturing APIs +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8TEX_H__ +#define __D3DX8TEX_H__ + + +//---------------------------------------------------------------------------- +// D3DX_FILTER flags: +// ------------------ +// +// A valid filter must contain one of these values: +// +// D3DX_FILTER_NONE +// No scaling or filtering will take place. Pixels outside the bounds +// of the source image are assumed to be transparent black. +// D3DX_FILTER_POINT +// Each destination pixel is computed by sampling the nearest pixel +// from the source image. +// D3DX_FILTER_LINEAR +// Each destination pixel is computed by linearly interpolating between +// the nearest pixels in the source image. This filter works best +// when the scale on each axis is less than 2. +// D3DX_FILTER_TRIANGLE +// Every pixel in the source image contributes equally to the +// destination image. This is the slowest of all the filters. +// D3DX_FILTER_BOX +// Each pixel is computed by averaging a 2x2(x2) box pixels from +// the source image. Only works when the dimensions of the +// destination are half those of the source. (as with mip maps) +// +// And can be OR'd with any of these optional flags: +// +// D3DX_FILTER_MIRROR_U +// Indicates that pixels off the edge of the texture on the U-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR_V +// Indicates that pixels off the edge of the texture on the V-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR_W +// Indicates that pixels off the edge of the texture on the W-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR +// Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V | +// D3DX_FILTER_MIRROR_V +// D3DX_FILTER_DITHER +// Dithers the resulting image. +// +//---------------------------------------------------------------------------- + +#define D3DX_FILTER_NONE (1 << 0) +#define D3DX_FILTER_POINT (2 << 0) +#define D3DX_FILTER_LINEAR (3 << 0) +#define D3DX_FILTER_TRIANGLE (4 << 0) +#define D3DX_FILTER_BOX (5 << 0) + +#define D3DX_FILTER_MIRROR_U (1 << 16) +#define D3DX_FILTER_MIRROR_V (2 << 16) +#define D3DX_FILTER_MIRROR_W (4 << 16) +#define D3DX_FILTER_MIRROR (7 << 16) +#define D3DX_FILTER_DITHER (8 << 16) + + +//---------------------------------------------------------------------------- +// D3DX_NORMALMAP flags: +// --------------------- +// These flags are used to control how D3DXComputeNormalMap generates normal +// maps. Any number of these flags may be OR'd together in any combination. +// +// D3DX_NORMALMAP_MIRROR_U +// Indicates that pixels off the edge of the texture on the U-axis +// should be mirrored, not wraped. +// D3DX_NORMALMAP_MIRROR_V +// Indicates that pixels off the edge of the texture on the V-axis +// should be mirrored, not wraped. +// D3DX_NORMALMAP_MIRROR +// Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V +// D3DX_NORMALMAP_INVERTSIGN +// Inverts the direction of each normal +// D3DX_NORMALMAP_COMPUTE_OCCLUSION +// Compute the per pixel Occlusion term and encodes it into the alpha. +// An Alpha of 1 means that the pixel is not obscured in anyway, and +// an alpha of 0 would mean that the pixel is completly obscured. +// +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- + +#define D3DX_NORMALMAP_MIRROR_U (1 << 16) +#define D3DX_NORMALMAP_MIRROR_V (2 << 16) +#define D3DX_NORMALMAP_MIRROR (3 << 16) +#define D3DX_NORMALMAP_INVERTSIGN (8 << 16) +#define D3DX_NORMALMAP_COMPUTE_OCCLUSION (16 << 16) + + + + +//---------------------------------------------------------------------------- +// D3DX_CHANNEL flags: +// ------------------- +// These flags are used by functions which operate on or more channels +// in a texture. +// +// D3DX_CHANNEL_RED +// Indicates the red channel should be used +// D3DX_CHANNEL_BLUE +// Indicates the blue channel should be used +// D3DX_CHANNEL_GREEN +// Indicates the green channel should be used +// D3DX_CHANNEL_ALPHA +// Indicates the alpha channel should be used +// D3DX_CHANNEL_LUMINANCE +// Indicates the luminaces of the red green and blue channels should be +// used. +// +//---------------------------------------------------------------------------- + +#define D3DX_CHANNEL_RED (1 << 0) +#define D3DX_CHANNEL_BLUE (1 << 1) +#define D3DX_CHANNEL_GREEN (1 << 2) +#define D3DX_CHANNEL_ALPHA (1 << 3) +#define D3DX_CHANNEL_LUMINANCE (1 << 4) + + + + +//---------------------------------------------------------------------------- +// D3DXIMAGE_FILEFORMAT: +// --------------------- +// This enum is used to describe supported image file formats. +// +//---------------------------------------------------------------------------- + +typedef enum _D3DXIMAGE_FILEFORMAT +{ + D3DXIFF_BMP = 0, + D3DXIFF_JPG = 1, + D3DXIFF_TGA = 2, + D3DXIFF_PNG = 3, + D3DXIFF_DDS = 4, + D3DXIFF_PPM = 5, + D3DXIFF_DIB = 6, + D3DXIFF_FORCE_DWORD = 0x7fffffff + +} D3DXIMAGE_FILEFORMAT; + + +//---------------------------------------------------------------------------- +// LPD3DXFILL2D and LPD3DXFILL3D: +// ------------------------------ +// Function types used by the texture fill functions. +// +// Parameters: +// pOut +// Pointer to a vector which the function uses to return its result. +// X,Y,Z,W will be mapped to R,G,B,A respectivly. +// pTexCoord +// Pointer to a vector containing the coordinates of the texel currently +// being evaluated. Textures and VolumeTexture texcoord components +// range from 0 to 1. CubeTexture texcoord component range from -1 to 1. +// pTexelSize +// Pointer to a vector containing the dimensions of the current texel. +// pData +// Pointer to user data. +// +//---------------------------------------------------------------------------- + +typedef VOID (*LPD3DXFILL2D)(D3DXVECTOR4 *pOut, D3DXVECTOR2 *pTexCoord, D3DXVECTOR2 *pTexelSize, LPVOID pData); +typedef VOID (*LPD3DXFILL3D)(D3DXVECTOR4 *pOut, D3DXVECTOR3 *pTexCoord, D3DXVECTOR3 *pTexelSize, LPVOID pData); + + + +//---------------------------------------------------------------------------- +// D3DXIMAGE_INFO: +// --------------- +// This structure is used to return a rough description of what the +// the original contents of an image file looked like. +// +// Width +// Width of original image in pixels +// Height +// Height of original image in pixels +// Depth +// Depth of original image in pixels +// MipLevels +// Number of mip levels in original image +// Format +// D3D format which most closely describes the data in original image +// ResourceType +// D3DRESOURCETYPE representing the type of texture stored in the file. +// D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE. +// ImageFileFormat +// D3DXIMAGE_FILEFORMAT representing the format of the image file. +// +//---------------------------------------------------------------------------- + +typedef struct _D3DXIMAGE_INFO +{ + UINT Width; + UINT Height; + UINT Depth; + UINT MipLevels; + D3DFORMAT Format; + D3DRESOURCETYPE ResourceType; + D3DXIMAGE_FILEFORMAT ImageFileFormat; + +} D3DXIMAGE_INFO; + + + + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + + +////////////////////////////////////////////////////////////////////////////// +// Image File APIs /////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +; +//---------------------------------------------------------------------------- +// GetImageInfoFromFile/Resource: +// ------------------------------ +// Fills in a D3DXIMAGE_INFO struct with information about an image file. +// +// Parameters: +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXGetImageInfoFromFileA( + LPCSTR pSrcFile, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXGetImageInfoFromFileW( + LPCWSTR pSrcFile, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileW +#else +#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileA +#endif + + +HRESULT WINAPI + D3DXGetImageInfoFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXGetImageInfoFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceW +#else +#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceA +#endif + + +HRESULT WINAPI + D3DXGetImageInfoFromFileInMemory( + LPCVOID pSrcData, + UINT SrcDataSize, + D3DXIMAGE_INFO* pSrcInfo); + + + + +////////////////////////////////////////////////////////////////////////////// +// Load/Save Surface APIs //////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromFile/Resource: +// --------------------------------- +// Load surface from a file or resource +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcRect +// Source rectangle, or NULL for entire image +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromFileA( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCSTR pSrcFile, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadSurfaceFromFileW( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCWSTR pSrcFile, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileW +#else +#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileA +#endif + + + +HRESULT WINAPI + D3DXLoadSurfaceFromResourceA( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadSurfaceFromResourceW( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + +#ifdef UNICODE +#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceW +#else +#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceA +#endif + + + +HRESULT WINAPI + D3DXLoadSurfaceFromFileInMemory( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCVOID pSrcData, + UINT SrcDataSize, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromSurface: +// --------------------------- +// Load surface from another surface (with color conversion) +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcSurface +// Source surface +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle, or NULL for entire surface +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromSurface( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPDIRECT3DSURFACE8 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey); + + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromMemory: +// -------------------------- +// Load surface from memory. +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcMemory +// Pointer to the top-left corner of the source image in memory +// SrcFormat +// Pixel format of the source image. +// SrcPitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the width of one row of cells, in bytes. +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle. +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromMemory( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCVOID pSrcMemory, + D3DFORMAT SrcFormat, + UINT SrcPitch, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey); + + +//---------------------------------------------------------------------------- +// D3DXSaveSurfaceToFile: +// ---------------------- +// Save a surface to a image file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcSurface +// Source surface, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle, or NULL for the entire image +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXSaveSurfaceToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DSURFACE8 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect); + +HRESULT WINAPI + D3DXSaveSurfaceToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DSURFACE8 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect); + +#ifdef UNICODE +#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW +#else +#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA +#endif + + + + +////////////////////////////////////////////////////////////////////////////// +// Load/Save Volume APIs ///////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromFile/Resource: +// -------------------------------- +// Load volume from a file or resource +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcBox +// Source box, or NULL for entire image +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromFileA( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCSTR pSrcFile, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadVolumeFromFileW( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCWSTR pSrcFile, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileW +#else +#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileA +#endif + + +HRESULT WINAPI + D3DXLoadVolumeFromResourceA( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadVolumeFromResourceW( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceW +#else +#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceA +#endif + + + +HRESULT WINAPI + D3DXLoadVolumeFromFileInMemory( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCVOID pSrcData, + UINT SrcDataSize, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromVolume: +// ------------------------- +// Load volume from another volume (with color conversion) +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcVolume +// Source volume +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box, or NULL for entire volume +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromVolume( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPDIRECT3DVOLUME8 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey); + + + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromMemory: +// ------------------------- +// Load volume from memory. +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcMemory +// Pointer to the top-left corner of the source volume in memory +// SrcFormat +// Pixel format of the source volume. +// SrcRowPitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the size of one row of cells, in bytes. +// SrcSlicePitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the size of one slice of cells, in bytes. +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box. +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromMemory( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCVOID pSrcMemory, + D3DFORMAT SrcFormat, + UINT SrcRowPitch, + UINT SrcSlicePitch, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey); + + + +//---------------------------------------------------------------------------- +// D3DXSaveVolumeToFile: +// --------------------- +// Save a volume to a image file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcVolume +// Source volume, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box, or NULL for the entire volume +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXSaveVolumeToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DVOLUME8 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox); + +HRESULT WINAPI + D3DXSaveVolumeToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DVOLUME8 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox); + +#ifdef UNICODE +#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileW +#else +#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileA +#endif + + + + +////////////////////////////////////////////////////////////////////////////// +// Create/Save Texture APIs ////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXCheckTextureRequirements: +// ----------------------------- +// Checks texture creation parameters. If parameters are invalid, this +// function returns corrected parameters. +// +// Parameters: +// +// pDevice +// The D3D device to be used +// pWidth, pHeight, pDepth, pSize +// Desired size in pixels, or NULL. Returns corrected size. +// pNumMipLevels +// Number of desired mipmap levels, or NULL. Returns corrected number. +// Usage +// Texture usage flags +// pFormat +// Desired pixel format, or NULL. Returns corrected format. +// Pool +// Memory pool to be used to create texture +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCheckTextureRequirements( + LPDIRECT3DDEVICE8 pDevice, + UINT* pWidth, + UINT* pHeight, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + +HRESULT WINAPI + D3DXCheckCubeTextureRequirements( + LPDIRECT3DDEVICE8 pDevice, + UINT* pSize, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + +HRESULT WINAPI + D3DXCheckVolumeTextureRequirements( + LPDIRECT3DDEVICE8 pDevice, + UINT* pWidth, + UINT* pHeight, + UINT* pDepth, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + + +//---------------------------------------------------------------------------- +// D3DXCreateTexture: +// ------------------ +// Create an empty texture +// +// Parameters: +// +// pDevice +// The D3D device with which the texture is going to be used. +// Width, Height, Depth, Size +// size in pixels; these must be non-zero +// MipLevels +// number of mip levels desired; if zero or D3DX_DEFAULT, a complete +// mipmap chain will be created. +// Usage +// Texture usage flags +// Format +// Pixel format. +// Pool +// Memory pool to be used to create texture +// ppTexture, ppCubeTexture, ppVolumeTexture +// The texture object that will be created +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCreateTexture( + LPDIRECT3DDEVICE8 pDevice, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTexture( + LPDIRECT3DDEVICE8 pDevice, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTexture( + LPDIRECT3DDEVICE8 pDevice, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + + + +//---------------------------------------------------------------------------- +// D3DXCreateTextureFromFile/Resource: +// ----------------------------------- +// Create a texture object from a file or resource. +// +// Parameters: +// +// pDevice +// The D3D device with which the texture is going to be used. +// pSrcFile +// File name. +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pvSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// Width, Height, Depth, Size +// Size in pixels; if zero or D3DX_DEFAULT, the size will be taken +// from the file. +// MipLevels +// Number of mip levels; if zero or D3DX_DEFAULT, a complete mipmap +// chain will be created. +// Usage +// Texture usage flags +// Format +// Desired pixel format. If D3DFMT_UNKNOWN, the format will be +// taken from the file. +// Pool +// Memory pool to be used to create texture +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// MipFilter +// D3DX_FILTER flags controlling how each miplevel is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_BOX, +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// pPalette +// 256 color palette to be filled in, or NULL +// ppTexture, ppCubeTexture, ppVolumeTexture +// The texture object that will be created +// +//---------------------------------------------------------------------------- + + +// FromFile + +HRESULT WINAPI + D3DXCreateTextureFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileW +#else +#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileW +#else +#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileW +#else +#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileA +#endif + + +// FromResource + +HRESULT WINAPI + D3DXCreateTextureFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceW +#else +#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceW +#else +#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceW +#else +#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceA +#endif + + +// FromFileEx + +HRESULT WINAPI + D3DXCreateTextureFromFileExA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromFileExW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExW +#else +#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileExA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileExW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExW +#else +#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileExA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileExW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExW +#else +#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExA +#endif + + +// FromResourceEx + +HRESULT WINAPI + D3DXCreateTextureFromResourceExA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromResourceExW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExW +#else +#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceExA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceExW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExW +#else +#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceExA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceExW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExW +#else +#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExA +#endif + + +// FromFileInMemory + +HRESULT WINAPI + D3DXCreateTextureFromFileInMemory( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileInMemory( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileInMemory( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + + +// FromFileInMemoryEx + +HRESULT WINAPI + D3DXCreateTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + + + +//---------------------------------------------------------------------------- +// D3DXSaveTextureToFile: +// ---------------------- +// Save a texture to a file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcTexture +// Source texture, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// +//---------------------------------------------------------------------------- + + +HRESULT WINAPI + D3DXSaveTextureToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DBASETEXTURE8 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette); + +HRESULT WINAPI + D3DXSaveTextureToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DBASETEXTURE8 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette); + +#ifdef UNICODE +#define D3DXSaveTextureToFile D3DXSaveTextureToFileW +#else +#define D3DXSaveTextureToFile D3DXSaveTextureToFileA +#endif + + + + +////////////////////////////////////////////////////////////////////////////// +// Misc Texture APIs ///////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXFilterTexture: +// ------------------ +// Filters mipmaps levels of a texture. +// +// Parameters: +// pBaseTexture +// The texture object to be filtered +// pPalette +// 256 color palette to be used, or NULL for non-palettized formats +// SrcLevel +// The level whose image is used to generate the subsequent levels. +// Filter +// D3DX_FILTER flags controlling how each miplevel is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_BOX, +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXFilterTexture( + LPDIRECT3DBASETEXTURE8 pBaseTexture, + CONST PALETTEENTRY* pPalette, + UINT SrcLevel, + DWORD Filter); + +#define D3DXFilterCubeTexture D3DXFilterTexture +#define D3DXFilterVolumeTexture D3DXFilterTexture + + + +//---------------------------------------------------------------------------- +// D3DXFillTexture: +// ---------------- +// Uses a user provided function to fill each texel of each mip level of a +// given texture. +// +// Paramters: +// pTexture, pCubeTexture, pVolumeTexture +// Pointer to the texture to be filled. +// pFunction +// Pointer to user provided evalutor function which will be used to +// compute the value of each texel. +// pData +// Pointer to an arbitrary block of user defined data. This pointer +// will be passed to the function provided in pFunction +//----------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXFillTexture( + LPDIRECT3DTEXTURE8 pTexture, + LPD3DXFILL2D pFunction, + LPVOID pData); + +HRESULT WINAPI + D3DXFillCubeTexture( + LPDIRECT3DCUBETEXTURE8 pCubeTexture, + LPD3DXFILL3D pFunction, + LPVOID pData); + +HRESULT WINAPI + D3DXFillVolumeTexture( + LPDIRECT3DVOLUMETEXTURE8 pVolumeTexture, + LPD3DXFILL3D pFunction, + LPVOID pData); + + + +//---------------------------------------------------------------------------- +// D3DXComputeNormalMap: +// --------------------- +// Converts a height map into a normal map. The (x,y,z) components of each +// normal are mapped to the (r,g,b) channels of the output texture. +// +// Parameters +// pTexture +// Pointer to the destination texture +// pSrcTexture +// Pointer to the source heightmap texture +// pSrcPalette +// Source palette of 256 colors, or NULL +// Flags +// D3DX_NORMALMAP flags +// Channel +// D3DX_CHANNEL specifying source of height information +// Amplitude +// The constant value which the height information is multiplied by. +//--------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXComputeNormalMap( + LPDIRECT3DTEXTURE8 pTexture, + LPDIRECT3DTEXTURE8 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette, + DWORD Flags, + DWORD Channel, + FLOAT Amplitude); + + + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8TEX_H__ diff --git a/src/dep/include/DXSDK/include/d3dx9.h b/src/dep/include/DXSDK/include/d3dx9.h index d7730cc..822f0a8 100644 --- a/src/dep/include/DXSDK/include/d3dx9.h +++ b/src/dep/include/DXSDK/include/d3dx9.h @@ -1,76 +1,76 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx9.h -// Content: D3DX utility library -// -////////////////////////////////////////////////////////////////////////////// - -#ifdef __D3DX_INTERNAL__ -#error Incorrect D3DX header used -#endif - -#ifndef __D3DX9_H__ -#define __D3DX9_H__ - - -// Defines -#include - -#define D3DX_DEFAULT ((UINT) -1) -#define D3DX_DEFAULT_NONPOW2 ((UINT) -2) -#define D3DX_DEFAULT_FLOAT FLT_MAX -#define D3DX_FROM_FILE ((UINT) -3) -#define D3DFMT_FROM_FILE ((D3DFORMAT) -3) - -#ifndef D3DXINLINE -#ifdef _MSC_VER - #if (_MSC_VER >= 1200) - #define D3DXINLINE __forceinline - #else - #define D3DXINLINE __inline - #endif -#else - #ifdef __cplusplus - #define D3DXINLINE inline - #else - #define D3DXINLINE - #endif -#endif -#endif - - - -// Includes -#include "d3d9.h" -#include "d3dx9math.h" -#include "d3dx9core.h" -#include "d3dx9xof.h" -#include "d3dx9mesh.h" -#include "d3dx9shader.h" -#include "d3dx9effect.h" -#include "d3dx9tex.h" -#include "d3dx9shape.h" -#include "d3dx9anim.h" - - -// Errors -#define _FACDD 0x876 -#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) - -enum _D3DXERR { - D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900), - D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901), - D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902), - D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903), - D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904), - D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905), - D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906), - D3DXERR_DUPLICATENAMEDFRAGMENT = MAKE_DDHRESULT(2907), - D3DXERR_CANNOTREMOVELASTITEM = MAKE_DDHRESULT(2908), -}; - - -#endif //__D3DX9_H__ - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx9.h +// Content: D3DX utility library +// +////////////////////////////////////////////////////////////////////////////// + +#ifdef __D3DX_INTERNAL__ +#error Incorrect D3DX header used +#endif + +#ifndef __D3DX9_H__ +#define __D3DX9_H__ + + +// Defines +#include + +#define D3DX_DEFAULT ((UINT) -1) +#define D3DX_DEFAULT_NONPOW2 ((UINT) -2) +#define D3DX_DEFAULT_FLOAT FLT_MAX +#define D3DX_FROM_FILE ((UINT) -3) +#define D3DFMT_FROM_FILE ((D3DFORMAT) -3) + +#ifndef D3DXINLINE +#ifdef _MSC_VER + #if (_MSC_VER >= 1200) + #define D3DXINLINE __forceinline + #else + #define D3DXINLINE __inline + #endif +#else + #ifdef __cplusplus + #define D3DXINLINE inline + #else + #define D3DXINLINE + #endif +#endif +#endif + + + +// Includes +#include "d3d9.h" +#include "d3dx9math.h" +#include "d3dx9core.h" +#include "d3dx9xof.h" +#include "d3dx9mesh.h" +#include "d3dx9shader.h" +#include "d3dx9effect.h" +#include "d3dx9tex.h" +#include "d3dx9shape.h" +#include "d3dx9anim.h" + + +// Errors +#define _FACDD 0x876 +#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) + +enum _D3DXERR { + D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900), + D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901), + D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902), + D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903), + D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904), + D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905), + D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906), + D3DXERR_DUPLICATENAMEDFRAGMENT = MAKE_DDHRESULT(2907), + D3DXERR_CANNOTREMOVELASTITEM = MAKE_DDHRESULT(2908), +}; + + +#endif //__D3DX9_H__ + diff --git a/src/dep/include/DXSDK/include/d3dx9anim.h b/src/dep/include/DXSDK/include/d3dx9anim.h index 252ce93..fedb1db 100644 --- a/src/dep/include/DXSDK/include/d3dx9anim.h +++ b/src/dep/include/DXSDK/include/d3dx9anim.h @@ -1,1114 +1,1114 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx9anim.h -// Content: D3DX mesh types and functions -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DX9ANIM_H__ -#define __D3DX9ANIM_H__ - -// {698CFB3F-9289-4d95-9A57-33A94B5A65F9} -DEFINE_GUID(IID_ID3DXAnimationSet, -0x698cfb3f, 0x9289, 0x4d95, 0x9a, 0x57, 0x33, 0xa9, 0x4b, 0x5a, 0x65, 0xf9); - -// {FA4E8E3A-9786-407d-8B4C-5995893764AF} -DEFINE_GUID(IID_ID3DXKeyframedAnimationSet, -0xfa4e8e3a, 0x9786, 0x407d, 0x8b, 0x4c, 0x59, 0x95, 0x89, 0x37, 0x64, 0xaf); - -// {6CC2480D-3808-4739-9F88-DE49FACD8D4C} -DEFINE_GUID(IID_ID3DXCompressedAnimationSet, -0x6cc2480d, 0x3808, 0x4739, 0x9f, 0x88, 0xde, 0x49, 0xfa, 0xcd, 0x8d, 0x4c); - -// {AC8948EC-F86D-43e2-96DE-31FC35F96D9E} -DEFINE_GUID(IID_ID3DXAnimationController, -0xac8948ec, 0xf86d, 0x43e2, 0x96, 0xde, 0x31, 0xfc, 0x35, 0xf9, 0x6d, 0x9e); - - -//---------------------------------------------------------------------------- -// D3DXMESHDATATYPE: -// ----------------- -// This enum defines the type of mesh data present in a MeshData structure. -//---------------------------------------------------------------------------- -typedef enum _D3DXMESHDATATYPE { - D3DXMESHTYPE_MESH = 0x001, // Normal ID3DXMesh data - D3DXMESHTYPE_PMESH = 0x002, // Progressive Mesh - ID3DXPMesh - D3DXMESHTYPE_PATCHMESH = 0x003, // Patch Mesh - ID3DXPatchMesh - - D3DXMESHTYPE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DXMESHDATATYPE; - -//---------------------------------------------------------------------------- -// D3DXMESHDATA: -// ------------- -// This struct encapsulates a the mesh data that can be present in a mesh -// container. The supported mesh types are pMesh, pPMesh, pPatchMesh. -// The valid way to access this is determined by the Type enum. -//---------------------------------------------------------------------------- -typedef struct _D3DXMESHDATA -{ - D3DXMESHDATATYPE Type; - - // current mesh data interface - union - { - LPD3DXMESH pMesh; - LPD3DXPMESH pPMesh; - LPD3DXPATCHMESH pPatchMesh; - }; -} D3DXMESHDATA, *LPD3DXMESHDATA; - -//---------------------------------------------------------------------------- -// D3DXMESHCONTAINER: -// ------------------ -// This struct encapsulates a mesh object in a transformation frame -// hierarchy. The app can derive from this structure to add other app specific -// data to this. -//---------------------------------------------------------------------------- -typedef struct _D3DXMESHCONTAINER -{ - LPSTR Name; - - D3DXMESHDATA MeshData; - - LPD3DXMATERIAL pMaterials; - LPD3DXEFFECTINSTANCE pEffects; - DWORD NumMaterials; - DWORD *pAdjacency; - - LPD3DXSKININFO pSkinInfo; - - struct _D3DXMESHCONTAINER *pNextMeshContainer; -} D3DXMESHCONTAINER, *LPD3DXMESHCONTAINER; - -//---------------------------------------------------------------------------- -// D3DXFRAME: -// ---------- -// This struct is the encapsulates a transform frame in a transformation frame -// hierarchy. The app can derive from this structure to add other app specific -// data to this -//---------------------------------------------------------------------------- -typedef struct _D3DXFRAME -{ - LPSTR Name; - D3DXMATRIX TransformationMatrix; - - LPD3DXMESHCONTAINER pMeshContainer; - - struct _D3DXFRAME *pFrameSibling; - struct _D3DXFRAME *pFrameFirstChild; -} D3DXFRAME, *LPD3DXFRAME; - - -//---------------------------------------------------------------------------- -// ID3DXAllocateHierarchy: -// ----------------------- -// This interface is implemented by the application to allocate/free frame and -// mesh container objects. Methods on this are called during loading and -// destroying frame hierarchies -//---------------------------------------------------------------------------- -typedef interface ID3DXAllocateHierarchy ID3DXAllocateHierarchy; -typedef interface ID3DXAllocateHierarchy *LPD3DXALLOCATEHIERARCHY; - -#undef INTERFACE -#define INTERFACE ID3DXAllocateHierarchy - -DECLARE_INTERFACE(ID3DXAllocateHierarchy) -{ - // ID3DXAllocateHierarchy - - //------------------------------------------------------------------------ - // CreateFrame: - // ------------ - // Requests allocation of a frame object. - // - // Parameters: - // Name - // Name of the frame to be created - // ppNewFrame - // Returns the created frame object - // - //------------------------------------------------------------------------ - STDMETHOD(CreateFrame)(THIS_ LPCSTR Name, - LPD3DXFRAME *ppNewFrame) PURE; - - //------------------------------------------------------------------------ - // CreateMeshContainer: - // -------------------- - // Requests allocation of a mesh container object. - // - // Parameters: - // Name - // Name of the mesh - // pMesh - // Pointer to the mesh object if basic polygon data found - // pPMesh - // Pointer to the progressive mesh object if progressive mesh data found - // pPatchMesh - // Pointer to the patch mesh object if patch data found - // pMaterials - // Array of materials used in the mesh - // pEffectInstances - // Array of effect instances used in the mesh - // NumMaterials - // Num elements in the pMaterials array - // pAdjacency - // Adjacency array for the mesh - // pSkinInfo - // Pointer to the skininfo object if the mesh is skinned - // pBoneNames - // Array of names, one for each bone in the skinned mesh. - // The numberof bones can be found from the pSkinMesh object - // pBoneOffsetMatrices - // Array of matrices, one for each bone in the skinned mesh. - // - //------------------------------------------------------------------------ - STDMETHOD(CreateMeshContainer)(THIS_ - LPCSTR Name, - CONST D3DXMESHDATA *pMeshData, - CONST D3DXMATERIAL *pMaterials, - CONST D3DXEFFECTINSTANCE *pEffectInstances, - DWORD NumMaterials, - CONST DWORD *pAdjacency, - LPD3DXSKININFO pSkinInfo, - LPD3DXMESHCONTAINER *ppNewMeshContainer) PURE; - - //------------------------------------------------------------------------ - // DestroyFrame: - // ------------- - // Requests de-allocation of a frame object. - // - // Parameters: - // pFrameToFree - // Pointer to the frame to be de-allocated - // - //------------------------------------------------------------------------ - STDMETHOD(DestroyFrame)(THIS_ LPD3DXFRAME pFrameToFree) PURE; - - //------------------------------------------------------------------------ - // DestroyMeshContainer: - // --------------------- - // Requests de-allocation of a mesh container object. - // - // Parameters: - // pMeshContainerToFree - // Pointer to the mesh container object to be de-allocated - // - //------------------------------------------------------------------------ - STDMETHOD(DestroyMeshContainer)(THIS_ LPD3DXMESHCONTAINER pMeshContainerToFree) PURE; -}; - -//---------------------------------------------------------------------------- -// ID3DXLoadUserData: -// ------------------ -// This interface is implemented by the application to load user data in a .X file -// When user data is found, these callbacks will be used to allow the application -// to load the data. -//---------------------------------------------------------------------------- -typedef interface ID3DXLoadUserData ID3DXLoadUserData; -typedef interface ID3DXLoadUserData *LPD3DXLOADUSERDATA; - -#undef INTERFACE -#define INTERFACE ID3DXLoadUserData - -DECLARE_INTERFACE(ID3DXLoadUserData) -{ - STDMETHOD(LoadTopLevelData)(LPD3DXFILEDATA pXofChildData) PURE; - - STDMETHOD(LoadFrameChildData)(LPD3DXFRAME pFrame, - LPD3DXFILEDATA pXofChildData) PURE; - - STDMETHOD(LoadMeshChildData)(LPD3DXMESHCONTAINER pMeshContainer, - LPD3DXFILEDATA pXofChildData) PURE; -}; - -//---------------------------------------------------------------------------- -// ID3DXSaveUserData: -// ------------------ -// This interface is implemented by the application to save user data in a .X file -// The callbacks are called for all data saved. The user can then add any -// child data objects to the object provided to the callback. -//---------------------------------------------------------------------------- -typedef interface ID3DXSaveUserData ID3DXSaveUserData; -typedef interface ID3DXSaveUserData *LPD3DXSAVEUSERDATA; - -#undef INTERFACE -#define INTERFACE ID3DXSaveUserData - -DECLARE_INTERFACE(ID3DXSaveUserData) -{ - STDMETHOD(AddFrameChildData)(CONST D3DXFRAME *pFrame, - LPD3DXFILESAVEOBJECT pXofSave, - LPD3DXFILESAVEDATA pXofFrameData) PURE; - - STDMETHOD(AddMeshChildData)(CONST D3DXMESHCONTAINER *pMeshContainer, - LPD3DXFILESAVEOBJECT pXofSave, - LPD3DXFILESAVEDATA pXofMeshData) PURE; - - // NOTE: this is called once per Save. All top level objects should be added using the - // provided interface. One call adds objects before the frame hierarchy, the other after - STDMETHOD(AddTopLevelDataObjectsPre)(LPD3DXFILESAVEOBJECT pXofSave) PURE; - STDMETHOD(AddTopLevelDataObjectsPost)(LPD3DXFILESAVEOBJECT pXofSave) PURE; - - // callbacks for the user to register and then save templates to the XFile - STDMETHOD(RegisterTemplates)(LPD3DXFILE pXFileApi) PURE; - STDMETHOD(SaveTemplates)(LPD3DXFILESAVEOBJECT pXofSave) PURE; -}; - - -//---------------------------------------------------------------------------- -// D3DXCALLBACK_SEARCH_FLAGS: -// -------------------------- -// Flags that can be passed into ID3DXAnimationSet::GetCallback. -//---------------------------------------------------------------------------- -typedef enum _D3DXCALLBACK_SEARCH_FLAGS -{ - D3DXCALLBACK_SEARCH_EXCLUDING_INITIAL_POSITION = 0x01, // exclude callbacks at the initial position from the search - D3DXCALLBACK_SEARCH_BEHIND_INITIAL_POSITION = 0x02, // reverse the callback search direction - - D3DXCALLBACK_SEARCH_FORCE_DWORD = 0x7fffffff, -} D3DXCALLBACK_SEARCH_FLAGS; - -//---------------------------------------------------------------------------- -// ID3DXAnimationSet: -// ------------------ -// This interface implements an animation set. -//---------------------------------------------------------------------------- -typedef interface ID3DXAnimationSet ID3DXAnimationSet; -typedef interface ID3DXAnimationSet *LPD3DXANIMATIONSET; - -#undef INTERFACE -#define INTERFACE ID3DXAnimationSet - -DECLARE_INTERFACE_(ID3DXAnimationSet, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // Name - STDMETHOD_(LPCSTR, GetName)(THIS) PURE; - - // Period - STDMETHOD_(DOUBLE, GetPeriod)(THIS) PURE; - STDMETHOD_(DOUBLE, GetPeriodicPosition)(THIS_ DOUBLE Position) PURE; // Maps position into animation period - - // Animation names - STDMETHOD_(UINT, GetNumAnimations)(THIS) PURE; - STDMETHOD(GetAnimationNameByIndex)(THIS_ UINT Index, LPCSTR *ppName) PURE; - STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE; - - // SRT - STDMETHOD(GetSRT)(THIS_ - DOUBLE PeriodicPosition, // Position mapped to period (use GetPeriodicPosition) - UINT Animation, // Animation index - D3DXVECTOR3 *pScale, // Returns the scale - D3DXQUATERNION *pRotation, // Returns the rotation as a quaternion - D3DXVECTOR3 *pTranslation) PURE; // Returns the translation - - // Callbacks - STDMETHOD(GetCallback)(THIS_ - DOUBLE Position, // Position from which to find callbacks - DWORD Flags, // Callback search flags - DOUBLE *pCallbackPosition, // Returns the position of the callback - LPVOID *ppCallbackData) PURE; // Returns the callback data pointer -}; - - -//---------------------------------------------------------------------------- -// D3DXPLAYBACK_TYPE: -// ------------------ -// This enum defines the type of animation set loop modes. -//---------------------------------------------------------------------------- -typedef enum _D3DXPLAYBACK_TYPE -{ - D3DXPLAY_LOOP = 0, - D3DXPLAY_ONCE = 1, - D3DXPLAY_PINGPONG = 2, - - D3DXPLAY_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DXPLAYBACK_TYPE; - - -//---------------------------------------------------------------------------- -// D3DXKEY_VECTOR3: -// ---------------- -// This structure describes a vector key for use in keyframe animation. -// It specifies a vector Value at a given Time. This is used for scale and -// translation keys. -//---------------------------------------------------------------------------- -typedef struct _D3DXKEY_VECTOR3 -{ - FLOAT Time; - D3DXVECTOR3 Value; -} D3DXKEY_VECTOR3, *LPD3DXKEY_VECTOR3; - - -//---------------------------------------------------------------------------- -// D3DXKEY_QUATERNION: -// ------------------- -// This structure describes a quaternion key for use in keyframe animation. -// It specifies a quaternion Value at a given Time. This is used for rotation -// keys. -//---------------------------------------------------------------------------- -typedef struct _D3DXKEY_QUATERNION -{ - FLOAT Time; - D3DXQUATERNION Value; -} D3DXKEY_QUATERNION, *LPD3DXKEY_QUATERNION; - - -//---------------------------------------------------------------------------- -// D3DXKEY_CALLBACK: -// ----------------- -// This structure describes an callback key for use in keyframe animation. -// It specifies a pointer to user data at a given Time. -//---------------------------------------------------------------------------- -typedef struct _D3DXKEY_CALLBACK -{ - FLOAT Time; - LPVOID pCallbackData; -} D3DXKEY_CALLBACK, *LPD3DXKEY_CALLBACK; - - -//---------------------------------------------------------------------------- -// D3DXCOMPRESSION_FLAGS: -// ---------------------- -// Flags that can be passed into ID3DXKeyframedAnimationSet::Compress. -//---------------------------------------------------------------------------- -typedef enum _D3DXCOMPRESSION_FLAGS -{ - D3DXCOMPRESS_DEFAULT = 0x00, - - D3DXCOMPRESS_FORCE_DWORD = 0x7fffffff, -} D3DXCOMPRESSION_FLAGS; - - -//---------------------------------------------------------------------------- -// ID3DXKeyframedAnimationSet: -// --------------------------- -// This interface implements a compressable keyframed animation set. -//---------------------------------------------------------------------------- -typedef interface ID3DXKeyframedAnimationSet ID3DXKeyframedAnimationSet; -typedef interface ID3DXKeyframedAnimationSet *LPD3DXKEYFRAMEDANIMATIONSET; - -#undef INTERFACE -#define INTERFACE ID3DXKeyframedAnimationSet - -DECLARE_INTERFACE_(ID3DXKeyframedAnimationSet, ID3DXAnimationSet) -{ - // ID3DXAnimationSet - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // Name - STDMETHOD_(LPCSTR, GetName)(THIS) PURE; - - // Period - STDMETHOD_(DOUBLE, GetPeriod)(THIS) PURE; - STDMETHOD_(DOUBLE, GetPeriodicPosition)(THIS_ DOUBLE Position) PURE; // Maps position into animation period - - // Animation names - STDMETHOD_(UINT, GetNumAnimations)(THIS) PURE; - STDMETHOD(GetAnimationNameByIndex)(THIS_ UINT Index, LPCSTR *ppName) PURE; - STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE; - - // SRT - STDMETHOD(GetSRT)(THIS_ - DOUBLE PeriodicPosition, // Position mapped to period (use GetPeriodicPosition) - UINT Animation, // Animation index - D3DXVECTOR3 *pScale, // Returns the scale - D3DXQUATERNION *pRotation, // Returns the rotation as a quaternion - D3DXVECTOR3 *pTranslation) PURE; // Returns the translation - - // Callbacks - STDMETHOD(GetCallback)(THIS_ - DOUBLE Position, // Position from which to find callbacks - DWORD Flags, // Callback search flags - DOUBLE *pCallbackPosition, // Returns the position of the callback - LPVOID *ppCallbackData) PURE; // Returns the callback data pointer - - // Playback - STDMETHOD_(D3DXPLAYBACK_TYPE, GetPlaybackType)(THIS) PURE; - STDMETHOD_(DOUBLE, GetSourceTicksPerSecond)(THIS) PURE; - - // Scale keys - STDMETHOD_(UINT, GetNumScaleKeys)(THIS_ UINT Animation) PURE; - STDMETHOD(GetScaleKeys)(THIS_ UINT Animation, LPD3DXKEY_VECTOR3 pScaleKeys) PURE; - STDMETHOD(GetScaleKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pScaleKey) PURE; - STDMETHOD(SetScaleKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pScaleKey) PURE; - - // Rotation keys - STDMETHOD_(UINT, GetNumRotationKeys)(THIS_ UINT Animation) PURE; - STDMETHOD(GetRotationKeys)(THIS_ UINT Animation, LPD3DXKEY_QUATERNION pRotationKeys) PURE; - STDMETHOD(GetRotationKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_QUATERNION pRotationKey) PURE; - STDMETHOD(SetRotationKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_QUATERNION pRotationKey) PURE; - - // Translation keys - STDMETHOD_(UINT, GetNumTranslationKeys)(THIS_ UINT Animation) PURE; - STDMETHOD(GetTranslationKeys)(THIS_ UINT Animation, LPD3DXKEY_VECTOR3 pTranslationKeys) PURE; - STDMETHOD(GetTranslationKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pTranslationKey) PURE; - STDMETHOD(SetTranslationKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pTranslationKey) PURE; - - // Callback keys - STDMETHOD_(UINT, GetNumCallbackKeys)(THIS) PURE; - STDMETHOD(GetCallbackKeys)(THIS_ LPD3DXKEY_CALLBACK pCallbackKeys) PURE; - STDMETHOD(GetCallbackKey)(THIS_ UINT Key, LPD3DXKEY_CALLBACK pCallbackKey) PURE; - STDMETHOD(SetCallbackKey)(THIS_ UINT Key, LPD3DXKEY_CALLBACK pCallbackKey) PURE; - - // Key removal methods. These are slow, and should not be used once the animation starts playing - STDMETHOD(UnregisterScaleKey)(THIS_ UINT Animation, UINT Key) PURE; - STDMETHOD(UnregisterRotationKey)(THIS_ UINT Animation, UINT Key) PURE; - STDMETHOD(UnregisterTranslationKey)(THIS_ UINT Animation, UINT Key) PURE; - - // One-time animaton SRT keyframe registration - STDMETHOD(RegisterAnimationSRTKeys)(THIS_ - LPCSTR pName, // Animation name - UINT NumScaleKeys, // Number of scale keys - UINT NumRotationKeys, // Number of rotation keys - UINT NumTranslationKeys, // Number of translation keys - CONST D3DXKEY_VECTOR3 *pScaleKeys, // Array of scale keys - CONST D3DXKEY_QUATERNION *pRotationKeys, // Array of rotation keys - CONST D3DXKEY_VECTOR3 *pTranslationKeys, // Array of translation keys - DWORD *pAnimationIndex) PURE; // Returns the animation index - - // Compression - STDMETHOD(Compress)(THIS_ - DWORD Flags, // Compression flags (use D3DXCOMPRESS_STRONG for better results) - FLOAT Lossiness, // Compression loss ratio in the [0, 1] range - LPD3DXFRAME pHierarchy, // Frame hierarchy (optional) - LPD3DXBUFFER *ppCompressedData) PURE; // Returns the compressed animation set - - STDMETHOD(UnregisterAnimation)(THIS_ UINT Index) PURE; -}; - - -//---------------------------------------------------------------------------- -// ID3DXCompressedAnimationSet: -// ---------------------------- -// This interface implements a compressed keyframed animation set. -//---------------------------------------------------------------------------- -typedef interface ID3DXCompressedAnimationSet ID3DXCompressedAnimationSet; -typedef interface ID3DXCompressedAnimationSet *LPD3DXCOMPRESSEDANIMATIONSET; - -#undef INTERFACE -#define INTERFACE ID3DXCompressedAnimationSet - -DECLARE_INTERFACE_(ID3DXCompressedAnimationSet, ID3DXAnimationSet) -{ - // ID3DXAnimationSet - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // Name - STDMETHOD_(LPCSTR, GetName)(THIS) PURE; - - // Period - STDMETHOD_(DOUBLE, GetPeriod)(THIS) PURE; - STDMETHOD_(DOUBLE, GetPeriodicPosition)(THIS_ DOUBLE Position) PURE; // Maps position into animation period - - // Animation names - STDMETHOD_(UINT, GetNumAnimations)(THIS) PURE; - STDMETHOD(GetAnimationNameByIndex)(THIS_ UINT Index, LPCSTR *ppName) PURE; - STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE; - - // SRT - STDMETHOD(GetSRT)(THIS_ - DOUBLE PeriodicPosition, // Position mapped to period (use GetPeriodicPosition) - UINT Animation, // Animation index - D3DXVECTOR3 *pScale, // Returns the scale - D3DXQUATERNION *pRotation, // Returns the rotation as a quaternion - D3DXVECTOR3 *pTranslation) PURE; // Returns the translation - - // Callbacks - STDMETHOD(GetCallback)(THIS_ - DOUBLE Position, // Position from which to find callbacks - DWORD Flags, // Callback search flags - DOUBLE *pCallbackPosition, // Returns the position of the callback - LPVOID *ppCallbackData) PURE; // Returns the callback data pointer - - // Playback - STDMETHOD_(D3DXPLAYBACK_TYPE, GetPlaybackType)(THIS) PURE; - STDMETHOD_(DOUBLE, GetSourceTicksPerSecond)(THIS) PURE; - - // Scale keys - STDMETHOD(GetCompressedData)(THIS_ LPD3DXBUFFER *ppCompressedData) PURE; - - // Callback keys - STDMETHOD_(UINT, GetNumCallbackKeys)(THIS) PURE; - STDMETHOD(GetCallbackKeys)(THIS_ LPD3DXKEY_CALLBACK pCallbackKeys) PURE; -}; - - -//---------------------------------------------------------------------------- -// D3DXPRIORITY_TYPE: -// ------------------ -// This enum defines the type of priority group that a track can be assigned to. -//---------------------------------------------------------------------------- -typedef enum _D3DXPRIORITY_TYPE { - D3DXPRIORITY_LOW = 0, // This track should be blended with all low priority tracks before mixed with the high priority result - D3DXPRIORITY_HIGH = 1, // This track should be blended with all high priority tracks before mixed with the low priority result - - D3DXPRIORITY_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DXPRIORITY_TYPE; - -//---------------------------------------------------------------------------- -// D3DXTRACK_DESC: -// --------------- -// This structure describes the mixing information of an animation track. -// The mixing information consists of the current position, speed, and blending -// weight for the track. The Flags field also specifies whether the track is -// low or high priority. Tracks with the same priority are blended together -// and then the two resulting values are blended using the priority blend factor. -// A track also has an animation set (stored separately) associated with it. -//---------------------------------------------------------------------------- -typedef struct _D3DXTRACK_DESC -{ - D3DXPRIORITY_TYPE Priority; - FLOAT Weight; - FLOAT Speed; - DOUBLE Position; - BOOL Enable; -} D3DXTRACK_DESC, *LPD3DXTRACK_DESC; - -//---------------------------------------------------------------------------- -// D3DXEVENT_TYPE: -// --------------- -// This enum defines the type of events keyable via the animation controller. -//---------------------------------------------------------------------------- -typedef enum _D3DXEVENT_TYPE -{ - D3DXEVENT_TRACKSPEED = 0, - D3DXEVENT_TRACKWEIGHT = 1, - D3DXEVENT_TRACKPOSITION = 2, - D3DXEVENT_TRACKENABLE = 3, - D3DXEVENT_PRIORITYBLEND = 4, - - D3DXEVENT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DXEVENT_TYPE; - -//---------------------------------------------------------------------------- -// D3DXTRANSITION_TYPE: -// -------------------- -// This enum defines the type of transtion performed on a event that -// transitions from one value to another. -//---------------------------------------------------------------------------- -typedef enum _D3DXTRANSITION_TYPE { - D3DXTRANSITION_LINEAR = 0x000, // Linear transition from one value to the next - D3DXTRANSITION_EASEINEASEOUT = 0x001, // Ease-In Ease-Out spline transtion from one value to the next - - D3DXTRANSITION_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DXTRANSITION_TYPE; - -//---------------------------------------------------------------------------- -// D3DXEVENT_DESC: -// --------------- -// This structure describes a animation controller event. -// It gives the event's type, track (if the event is a track event), global -// start time, duration, transition method, and target value. -//---------------------------------------------------------------------------- -typedef struct _D3DXEVENT_DESC -{ - D3DXEVENT_TYPE Type; - UINT Track; - DOUBLE StartTime; - DOUBLE Duration; - D3DXTRANSITION_TYPE Transition; - union - { - FLOAT Weight; - FLOAT Speed; - DOUBLE Position; - BOOL Enable; - }; -} D3DXEVENT_DESC, *LPD3DXEVENT_DESC; - -//---------------------------------------------------------------------------- -// D3DXEVENTHANDLE: -// ---------------- -// Handle values used to efficiently reference animation controller events. -//---------------------------------------------------------------------------- -typedef DWORD D3DXEVENTHANDLE; -typedef D3DXEVENTHANDLE *LPD3DXEVENTHANDLE; - - -//---------------------------------------------------------------------------- -// ID3DXAnimationCallbackHandler: -// ------------------------------ -// This interface is intended to be implemented by the application, and can -// be used to handle callbacks in animation sets generated when -// ID3DXAnimationController::AdvanceTime() is called. -//---------------------------------------------------------------------------- -typedef interface ID3DXAnimationCallbackHandler ID3DXAnimationCallbackHandler; -typedef interface ID3DXAnimationCallbackHandler *LPD3DXANIMATIONCALLBACKHANDLER; - -#undef INTERFACE -#define INTERFACE ID3DXAnimationCallbackHandler - -DECLARE_INTERFACE(ID3DXAnimationCallbackHandler) -{ - //---------------------------------------------------------------------------- - // ID3DXAnimationCallbackHandler::HandleCallback: - // ---------------------------------------------- - // This method gets called when a callback occurs for an animation set in one - // of the tracks during the ID3DXAnimationController::AdvanceTime() call. - // - // Parameters: - // Track - // Index of the track on which the callback occured. - // pCallbackData - // Pointer to user owned callback data. - // - //---------------------------------------------------------------------------- - STDMETHOD(HandleCallback)(THIS_ UINT Track, LPVOID pCallbackData) PURE; -}; - - -//---------------------------------------------------------------------------- -// ID3DXAnimationController: -// ------------------------- -// This interface implements the main animation functionality. It connects -// animation sets with the transform frames that are being animated. Allows -// mixing multiple animations for blended animations or for transistions -// It adds also has methods to modify blending parameters over time to -// enable smooth transistions and other effects. -//---------------------------------------------------------------------------- -typedef interface ID3DXAnimationController ID3DXAnimationController; -typedef interface ID3DXAnimationController *LPD3DXANIMATIONCONTROLLER; - -#undef INTERFACE -#define INTERFACE ID3DXAnimationController - -DECLARE_INTERFACE_(ID3DXAnimationController, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // Max sizes - STDMETHOD_(UINT, GetMaxNumAnimationOutputs)(THIS) PURE; - STDMETHOD_(UINT, GetMaxNumAnimationSets)(THIS) PURE; - STDMETHOD_(UINT, GetMaxNumTracks)(THIS) PURE; - STDMETHOD_(UINT, GetMaxNumEvents)(THIS) PURE; - - // Animation output registration - STDMETHOD(RegisterAnimationOutput)(THIS_ - LPCSTR pName, - D3DXMATRIX *pMatrix, - D3DXVECTOR3 *pScale, - D3DXQUATERNION *pRotation, - D3DXVECTOR3 *pTranslation) PURE; - - // Animation set registration - STDMETHOD(RegisterAnimationSet)(THIS_ LPD3DXANIMATIONSET pAnimSet) PURE; - STDMETHOD(UnregisterAnimationSet)(THIS_ LPD3DXANIMATIONSET pAnimSet) PURE; - - STDMETHOD_(UINT, GetNumAnimationSets)(THIS) PURE; - STDMETHOD(GetAnimationSet)(THIS_ UINT Index, LPD3DXANIMATIONSET *ppAnimationSet) PURE; - STDMETHOD(GetAnimationSetByName)(THIS_ LPCSTR szName, LPD3DXANIMATIONSET *ppAnimationSet) PURE; - - // Global time - STDMETHOD(AdvanceTime)(THIS_ DOUBLE TimeDelta, LPD3DXANIMATIONCALLBACKHANDLER pCallbackHandler) PURE; - STDMETHOD(ResetTime)(THIS) PURE; - STDMETHOD_(DOUBLE, GetTime)(THIS) PURE; - - // Tracks - STDMETHOD(SetTrackAnimationSet)(THIS_ UINT Track, LPD3DXANIMATIONSET pAnimSet) PURE; - STDMETHOD(GetTrackAnimationSet)(THIS_ UINT Track, LPD3DXANIMATIONSET *ppAnimSet) PURE; - - STDMETHOD(SetTrackPriority)(THIS_ UINT Track, D3DXPRIORITY_TYPE Priority) PURE; - - STDMETHOD(SetTrackSpeed)(THIS_ UINT Track, FLOAT Speed) PURE; - STDMETHOD(SetTrackWeight)(THIS_ UINT Track, FLOAT Weight) PURE; - STDMETHOD(SetTrackPosition)(THIS_ UINT Track, DOUBLE Position) PURE; - STDMETHOD(SetTrackEnable)(THIS_ UINT Track, BOOL Enable) PURE; - - STDMETHOD(SetTrackDesc)(THIS_ UINT Track, LPD3DXTRACK_DESC pDesc) PURE; - STDMETHOD(GetTrackDesc)(THIS_ UINT Track, LPD3DXTRACK_DESC pDesc) PURE; - - // Priority blending - STDMETHOD(SetPriorityBlend)(THIS_ FLOAT BlendWeight) PURE; - STDMETHOD_(FLOAT, GetPriorityBlend)(THIS) PURE; - - // Event keying - STDMETHOD_(D3DXEVENTHANDLE, KeyTrackSpeed)(THIS_ UINT Track, FLOAT NewSpeed, DOUBLE StartTime, DOUBLE Duration, D3DXTRANSITION_TYPE Transition) PURE; - STDMETHOD_(D3DXEVENTHANDLE, KeyTrackWeight)(THIS_ UINT Track, FLOAT NewWeight, DOUBLE StartTime, DOUBLE Duration, D3DXTRANSITION_TYPE Transition) PURE; - STDMETHOD_(D3DXEVENTHANDLE, KeyTrackPosition)(THIS_ UINT Track, DOUBLE NewPosition, DOUBLE StartTime) PURE; - STDMETHOD_(D3DXEVENTHANDLE, KeyTrackEnable)(THIS_ UINT Track, BOOL NewEnable, DOUBLE StartTime) PURE; - - STDMETHOD_(D3DXEVENTHANDLE, KeyPriorityBlend)(THIS_ FLOAT NewBlendWeight, DOUBLE StartTime, DOUBLE Duration, D3DXTRANSITION_TYPE Transition) PURE; - - // Event unkeying - STDMETHOD(UnkeyEvent)(THIS_ D3DXEVENTHANDLE hEvent) PURE; - - STDMETHOD(UnkeyAllTrackEvents)(THIS_ UINT Track) PURE; - STDMETHOD(UnkeyAllPriorityBlends)(THIS) PURE; - - // Event enumeration - STDMETHOD_(D3DXEVENTHANDLE, GetCurrentTrackEvent)(THIS_ UINT Track, D3DXEVENT_TYPE EventType) PURE; - STDMETHOD_(D3DXEVENTHANDLE, GetCurrentPriorityBlend)(THIS) PURE; - - STDMETHOD_(D3DXEVENTHANDLE, GetUpcomingTrackEvent)(THIS_ UINT Track, D3DXEVENTHANDLE hEvent) PURE; - STDMETHOD_(D3DXEVENTHANDLE, GetUpcomingPriorityBlend)(THIS_ D3DXEVENTHANDLE hEvent) PURE; - - STDMETHOD(ValidateEvent)(THIS_ D3DXEVENTHANDLE hEvent) PURE; - - STDMETHOD(GetEventDesc)(THIS_ D3DXEVENTHANDLE hEvent, LPD3DXEVENT_DESC pDesc) PURE; - - // Cloning - STDMETHOD(CloneAnimationController)(THIS_ - UINT MaxNumAnimationOutputs, - UINT MaxNumAnimationSets, - UINT MaxNumTracks, - UINT MaxNumEvents, - LPD3DXANIMATIONCONTROLLER *ppAnimController) PURE; -}; - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -//---------------------------------------------------------------------------- -// D3DXLoadMeshHierarchyFromX: -// --------------------------- -// Loads the first frame hierarchy in a .X file. -// -// Parameters: -// Filename -// Name of the .X file -// MeshOptions -// Mesh creation options for meshes in the file (see d3dx9mesh.h) -// pD3DDevice -// D3D9 device on which meshes in the file are created in -// pAlloc -// Allocation interface used to allocate nodes of the frame hierarchy -// pUserDataLoader -// Application provided interface to allow loading of user data -// ppFrameHierarchy -// Returns root node pointer of the loaded frame hierarchy -// ppAnimController -// Returns pointer to an animation controller corresponding to animation -// in the .X file. This is created with default max tracks and events -// -//---------------------------------------------------------------------------- -HRESULT WINAPI -D3DXLoadMeshHierarchyFromXA - ( - LPCSTR Filename, - DWORD MeshOptions, - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXALLOCATEHIERARCHY pAlloc, - LPD3DXLOADUSERDATA pUserDataLoader, - LPD3DXFRAME *ppFrameHierarchy, - LPD3DXANIMATIONCONTROLLER *ppAnimController - ); - -HRESULT WINAPI -D3DXLoadMeshHierarchyFromXW - ( - LPCWSTR Filename, - DWORD MeshOptions, - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXALLOCATEHIERARCHY pAlloc, - LPD3DXLOADUSERDATA pUserDataLoader, - LPD3DXFRAME *ppFrameHierarchy, - LPD3DXANIMATIONCONTROLLER *ppAnimController - ); - -#ifdef UNICODE -#define D3DXLoadMeshHierarchyFromX D3DXLoadMeshHierarchyFromXW -#else -#define D3DXLoadMeshHierarchyFromX D3DXLoadMeshHierarchyFromXA -#endif - -HRESULT WINAPI -D3DXLoadMeshHierarchyFromXInMemory - ( - LPCVOID Memory, - DWORD SizeOfMemory, - DWORD MeshOptions, - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXALLOCATEHIERARCHY pAlloc, - LPD3DXLOADUSERDATA pUserDataLoader, - LPD3DXFRAME *ppFrameHierarchy, - LPD3DXANIMATIONCONTROLLER *ppAnimController - ); - -//---------------------------------------------------------------------------- -// D3DXSaveMeshHierarchyToFile: -// ---------------------------- -// Creates a .X file and saves the mesh hierarchy and corresponding animations -// in it -// -// Parameters: -// Filename -// Name of the .X file -// XFormat -// Format of the .X file (text or binary, compressed or not, etc) -// pFrameRoot -// Root node of the hierarchy to be saved -// pAnimController -// The animation controller whose animation sets are to be stored -// pUserDataSaver -// Application provided interface to allow adding of user data to -// data objects saved to .X file -// -//---------------------------------------------------------------------------- -HRESULT WINAPI -D3DXSaveMeshHierarchyToFileA - ( - LPCSTR Filename, - DWORD XFormat, - CONST D3DXFRAME *pFrameRoot, - LPD3DXANIMATIONCONTROLLER pAnimcontroller, - LPD3DXSAVEUSERDATA pUserDataSaver - ); - -HRESULT WINAPI -D3DXSaveMeshHierarchyToFileW - ( - LPCWSTR Filename, - DWORD XFormat, - CONST D3DXFRAME *pFrameRoot, - LPD3DXANIMATIONCONTROLLER pAnimController, - LPD3DXSAVEUSERDATA pUserDataSaver - ); - -#ifdef UNICODE -#define D3DXSaveMeshHierarchyToFile D3DXSaveMeshHierarchyToFileW -#else -#define D3DXSaveMeshHierarchyToFile D3DXSaveMeshHierarchyToFileA -#endif - -//---------------------------------------------------------------------------- -// D3DXFrameDestroy: -// ----------------- -// Destroys the subtree of frames under the root, including the root -// -// Parameters: -// pFrameRoot -// Pointer to the root node -// pAlloc -// Allocation interface used to de-allocate nodes of the frame hierarchy -// -//---------------------------------------------------------------------------- -HRESULT WINAPI -D3DXFrameDestroy - ( - LPD3DXFRAME pFrameRoot, - LPD3DXALLOCATEHIERARCHY pAlloc - ); - -//---------------------------------------------------------------------------- -// D3DXFrameAppendChild: -// --------------------- -// Add a child frame to a frame -// -// Parameters: -// pFrameParent -// Pointer to the parent node -// pFrameChild -// Pointer to the child node -// -//---------------------------------------------------------------------------- -HRESULT WINAPI -D3DXFrameAppendChild - ( - LPD3DXFRAME pFrameParent, - CONST D3DXFRAME *pFrameChild - ); - -//---------------------------------------------------------------------------- -// D3DXFrameFind: -// -------------- -// Finds a frame with the given name. Returns NULL if no frame found. -// -// Parameters: -// pFrameRoot -// Pointer to the root node -// Name -// Name of frame to find -// -//---------------------------------------------------------------------------- -LPD3DXFRAME WINAPI -D3DXFrameFind - ( - CONST D3DXFRAME *pFrameRoot, - LPCSTR Name - ); - -//---------------------------------------------------------------------------- -// D3DXFrameRegisterNamedMatrices: -// ------------------------------- -// Finds all frames that have non-null names and registers each of those frame -// matrices to the given animation controller -// -// Parameters: -// pFrameRoot -// Pointer to the root node -// pAnimController -// Pointer to the animation controller where the matrices are registered -// -//---------------------------------------------------------------------------- -HRESULT WINAPI -D3DXFrameRegisterNamedMatrices - ( - LPD3DXFRAME pFrameRoot, - LPD3DXANIMATIONCONTROLLER pAnimController - ); - -//---------------------------------------------------------------------------- -// D3DXFrameNumNamedMatrices: -// -------------------------- -// Counts number of frames in a subtree that have non-null names -// -// Parameters: -// pFrameRoot -// Pointer to the root node of the subtree -// Return Value: -// Count of frames -// -//---------------------------------------------------------------------------- -UINT WINAPI -D3DXFrameNumNamedMatrices - ( - CONST D3DXFRAME *pFrameRoot - ); - -//---------------------------------------------------------------------------- -// D3DXFrameCalculateBoundingSphere: -// --------------------------------- -// Computes the bounding sphere of all the meshes in the frame hierarchy. -// -// Parameters: -// pFrameRoot -// Pointer to the root node -// pObjectCenter -// Returns the center of the bounding sphere -// pObjectRadius -// Returns the radius of the bounding sphere -// -//---------------------------------------------------------------------------- -HRESULT WINAPI -D3DXFrameCalculateBoundingSphere - ( - CONST D3DXFRAME *pFrameRoot, - LPD3DXVECTOR3 pObjectCenter, - FLOAT *pObjectRadius - ); - - -//---------------------------------------------------------------------------- -// D3DXCreateKeyframedAnimationSet: -// -------------------------------- -// This function creates a compressable keyframed animations set interface. -// -// Parameters: -// pName -// Name of the animation set -// TicksPerSecond -// Number of keyframe ticks that elapse per second -// Playback -// Playback mode of keyframe looping -// NumAnimations -// Number of SRT animations -// NumCallbackKeys -// Number of callback keys -// pCallbackKeys -// Array of callback keys -// ppAnimationSet -// Returns the animation set interface -// -//----------------------------------------------------------------------------- -HRESULT WINAPI -D3DXCreateKeyframedAnimationSet - ( - LPCSTR pName, - DOUBLE TicksPerSecond, - D3DXPLAYBACK_TYPE Playback, - UINT NumAnimations, - UINT NumCallbackKeys, - CONST D3DXKEY_CALLBACK *pCallbackKeys, - LPD3DXKEYFRAMEDANIMATIONSET *ppAnimationSet - ); - - -//---------------------------------------------------------------------------- -// D3DXCreateCompressedAnimationSet: -// -------------------------------- -// This function creates a compressed animations set interface from -// compressed data. -// -// Parameters: -// pName -// Name of the animation set -// TicksPerSecond -// Number of keyframe ticks that elapse per second -// Playback -// Playback mode of keyframe looping -// pCompressedData -// Compressed animation SRT data -// NumCallbackKeys -// Number of callback keys -// pCallbackKeys -// Array of callback keys -// ppAnimationSet -// Returns the animation set interface -// -//----------------------------------------------------------------------------- -HRESULT WINAPI -D3DXCreateCompressedAnimationSet - ( - LPCSTR pName, - DOUBLE TicksPerSecond, - D3DXPLAYBACK_TYPE Playback, - LPD3DXBUFFER pCompressedData, - UINT NumCallbackKeys, - CONST D3DXKEY_CALLBACK *pCallbackKeys, - LPD3DXCOMPRESSEDANIMATIONSET *ppAnimationSet - ); - - -//---------------------------------------------------------------------------- -// D3DXCreateAnimationController: -// ------------------------------ -// This function creates an animation controller object. -// -// Parameters: -// MaxNumMatrices -// Maximum number of matrices that can be animated -// MaxNumAnimationSets -// Maximum number of animation sets that can be played -// MaxNumTracks -// Maximum number of animation sets that can be blended -// MaxNumEvents -// Maximum number of outstanding events that can be scheduled at any given time -// ppAnimController -// Returns the animation controller interface -// -//----------------------------------------------------------------------------- -HRESULT WINAPI -D3DXCreateAnimationController - ( - UINT MaxNumMatrices, - UINT MaxNumAnimationSets, - UINT MaxNumTracks, - UINT MaxNumEvents, - LPD3DXANIMATIONCONTROLLER *ppAnimController - ); - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX9ANIM_H__ - - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx9anim.h +// Content: D3DX mesh types and functions +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DX9ANIM_H__ +#define __D3DX9ANIM_H__ + +// {698CFB3F-9289-4d95-9A57-33A94B5A65F9} +DEFINE_GUID(IID_ID3DXAnimationSet, +0x698cfb3f, 0x9289, 0x4d95, 0x9a, 0x57, 0x33, 0xa9, 0x4b, 0x5a, 0x65, 0xf9); + +// {FA4E8E3A-9786-407d-8B4C-5995893764AF} +DEFINE_GUID(IID_ID3DXKeyframedAnimationSet, +0xfa4e8e3a, 0x9786, 0x407d, 0x8b, 0x4c, 0x59, 0x95, 0x89, 0x37, 0x64, 0xaf); + +// {6CC2480D-3808-4739-9F88-DE49FACD8D4C} +DEFINE_GUID(IID_ID3DXCompressedAnimationSet, +0x6cc2480d, 0x3808, 0x4739, 0x9f, 0x88, 0xde, 0x49, 0xfa, 0xcd, 0x8d, 0x4c); + +// {AC8948EC-F86D-43e2-96DE-31FC35F96D9E} +DEFINE_GUID(IID_ID3DXAnimationController, +0xac8948ec, 0xf86d, 0x43e2, 0x96, 0xde, 0x31, 0xfc, 0x35, 0xf9, 0x6d, 0x9e); + + +//---------------------------------------------------------------------------- +// D3DXMESHDATATYPE: +// ----------------- +// This enum defines the type of mesh data present in a MeshData structure. +//---------------------------------------------------------------------------- +typedef enum _D3DXMESHDATATYPE { + D3DXMESHTYPE_MESH = 0x001, // Normal ID3DXMesh data + D3DXMESHTYPE_PMESH = 0x002, // Progressive Mesh - ID3DXPMesh + D3DXMESHTYPE_PATCHMESH = 0x003, // Patch Mesh - ID3DXPatchMesh + + D3DXMESHTYPE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DXMESHDATATYPE; + +//---------------------------------------------------------------------------- +// D3DXMESHDATA: +// ------------- +// This struct encapsulates a the mesh data that can be present in a mesh +// container. The supported mesh types are pMesh, pPMesh, pPatchMesh. +// The valid way to access this is determined by the Type enum. +//---------------------------------------------------------------------------- +typedef struct _D3DXMESHDATA +{ + D3DXMESHDATATYPE Type; + + // current mesh data interface + union + { + LPD3DXMESH pMesh; + LPD3DXPMESH pPMesh; + LPD3DXPATCHMESH pPatchMesh; + }; +} D3DXMESHDATA, *LPD3DXMESHDATA; + +//---------------------------------------------------------------------------- +// D3DXMESHCONTAINER: +// ------------------ +// This struct encapsulates a mesh object in a transformation frame +// hierarchy. The app can derive from this structure to add other app specific +// data to this. +//---------------------------------------------------------------------------- +typedef struct _D3DXMESHCONTAINER +{ + LPSTR Name; + + D3DXMESHDATA MeshData; + + LPD3DXMATERIAL pMaterials; + LPD3DXEFFECTINSTANCE pEffects; + DWORD NumMaterials; + DWORD *pAdjacency; + + LPD3DXSKININFO pSkinInfo; + + struct _D3DXMESHCONTAINER *pNextMeshContainer; +} D3DXMESHCONTAINER, *LPD3DXMESHCONTAINER; + +//---------------------------------------------------------------------------- +// D3DXFRAME: +// ---------- +// This struct is the encapsulates a transform frame in a transformation frame +// hierarchy. The app can derive from this structure to add other app specific +// data to this +//---------------------------------------------------------------------------- +typedef struct _D3DXFRAME +{ + LPSTR Name; + D3DXMATRIX TransformationMatrix; + + LPD3DXMESHCONTAINER pMeshContainer; + + struct _D3DXFRAME *pFrameSibling; + struct _D3DXFRAME *pFrameFirstChild; +} D3DXFRAME, *LPD3DXFRAME; + + +//---------------------------------------------------------------------------- +// ID3DXAllocateHierarchy: +// ----------------------- +// This interface is implemented by the application to allocate/free frame and +// mesh container objects. Methods on this are called during loading and +// destroying frame hierarchies +//---------------------------------------------------------------------------- +typedef interface ID3DXAllocateHierarchy ID3DXAllocateHierarchy; +typedef interface ID3DXAllocateHierarchy *LPD3DXALLOCATEHIERARCHY; + +#undef INTERFACE +#define INTERFACE ID3DXAllocateHierarchy + +DECLARE_INTERFACE(ID3DXAllocateHierarchy) +{ + // ID3DXAllocateHierarchy + + //------------------------------------------------------------------------ + // CreateFrame: + // ------------ + // Requests allocation of a frame object. + // + // Parameters: + // Name + // Name of the frame to be created + // ppNewFrame + // Returns the created frame object + // + //------------------------------------------------------------------------ + STDMETHOD(CreateFrame)(THIS_ LPCSTR Name, + LPD3DXFRAME *ppNewFrame) PURE; + + //------------------------------------------------------------------------ + // CreateMeshContainer: + // -------------------- + // Requests allocation of a mesh container object. + // + // Parameters: + // Name + // Name of the mesh + // pMesh + // Pointer to the mesh object if basic polygon data found + // pPMesh + // Pointer to the progressive mesh object if progressive mesh data found + // pPatchMesh + // Pointer to the patch mesh object if patch data found + // pMaterials + // Array of materials used in the mesh + // pEffectInstances + // Array of effect instances used in the mesh + // NumMaterials + // Num elements in the pMaterials array + // pAdjacency + // Adjacency array for the mesh + // pSkinInfo + // Pointer to the skininfo object if the mesh is skinned + // pBoneNames + // Array of names, one for each bone in the skinned mesh. + // The numberof bones can be found from the pSkinMesh object + // pBoneOffsetMatrices + // Array of matrices, one for each bone in the skinned mesh. + // + //------------------------------------------------------------------------ + STDMETHOD(CreateMeshContainer)(THIS_ + LPCSTR Name, + CONST D3DXMESHDATA *pMeshData, + CONST D3DXMATERIAL *pMaterials, + CONST D3DXEFFECTINSTANCE *pEffectInstances, + DWORD NumMaterials, + CONST DWORD *pAdjacency, + LPD3DXSKININFO pSkinInfo, + LPD3DXMESHCONTAINER *ppNewMeshContainer) PURE; + + //------------------------------------------------------------------------ + // DestroyFrame: + // ------------- + // Requests de-allocation of a frame object. + // + // Parameters: + // pFrameToFree + // Pointer to the frame to be de-allocated + // + //------------------------------------------------------------------------ + STDMETHOD(DestroyFrame)(THIS_ LPD3DXFRAME pFrameToFree) PURE; + + //------------------------------------------------------------------------ + // DestroyMeshContainer: + // --------------------- + // Requests de-allocation of a mesh container object. + // + // Parameters: + // pMeshContainerToFree + // Pointer to the mesh container object to be de-allocated + // + //------------------------------------------------------------------------ + STDMETHOD(DestroyMeshContainer)(THIS_ LPD3DXMESHCONTAINER pMeshContainerToFree) PURE; +}; + +//---------------------------------------------------------------------------- +// ID3DXLoadUserData: +// ------------------ +// This interface is implemented by the application to load user data in a .X file +// When user data is found, these callbacks will be used to allow the application +// to load the data. +//---------------------------------------------------------------------------- +typedef interface ID3DXLoadUserData ID3DXLoadUserData; +typedef interface ID3DXLoadUserData *LPD3DXLOADUSERDATA; + +#undef INTERFACE +#define INTERFACE ID3DXLoadUserData + +DECLARE_INTERFACE(ID3DXLoadUserData) +{ + STDMETHOD(LoadTopLevelData)(LPD3DXFILEDATA pXofChildData) PURE; + + STDMETHOD(LoadFrameChildData)(LPD3DXFRAME pFrame, + LPD3DXFILEDATA pXofChildData) PURE; + + STDMETHOD(LoadMeshChildData)(LPD3DXMESHCONTAINER pMeshContainer, + LPD3DXFILEDATA pXofChildData) PURE; +}; + +//---------------------------------------------------------------------------- +// ID3DXSaveUserData: +// ------------------ +// This interface is implemented by the application to save user data in a .X file +// The callbacks are called for all data saved. The user can then add any +// child data objects to the object provided to the callback. +//---------------------------------------------------------------------------- +typedef interface ID3DXSaveUserData ID3DXSaveUserData; +typedef interface ID3DXSaveUserData *LPD3DXSAVEUSERDATA; + +#undef INTERFACE +#define INTERFACE ID3DXSaveUserData + +DECLARE_INTERFACE(ID3DXSaveUserData) +{ + STDMETHOD(AddFrameChildData)(CONST D3DXFRAME *pFrame, + LPD3DXFILESAVEOBJECT pXofSave, + LPD3DXFILESAVEDATA pXofFrameData) PURE; + + STDMETHOD(AddMeshChildData)(CONST D3DXMESHCONTAINER *pMeshContainer, + LPD3DXFILESAVEOBJECT pXofSave, + LPD3DXFILESAVEDATA pXofMeshData) PURE; + + // NOTE: this is called once per Save. All top level objects should be added using the + // provided interface. One call adds objects before the frame hierarchy, the other after + STDMETHOD(AddTopLevelDataObjectsPre)(LPD3DXFILESAVEOBJECT pXofSave) PURE; + STDMETHOD(AddTopLevelDataObjectsPost)(LPD3DXFILESAVEOBJECT pXofSave) PURE; + + // callbacks for the user to register and then save templates to the XFile + STDMETHOD(RegisterTemplates)(LPD3DXFILE pXFileApi) PURE; + STDMETHOD(SaveTemplates)(LPD3DXFILESAVEOBJECT pXofSave) PURE; +}; + + +//---------------------------------------------------------------------------- +// D3DXCALLBACK_SEARCH_FLAGS: +// -------------------------- +// Flags that can be passed into ID3DXAnimationSet::GetCallback. +//---------------------------------------------------------------------------- +typedef enum _D3DXCALLBACK_SEARCH_FLAGS +{ + D3DXCALLBACK_SEARCH_EXCLUDING_INITIAL_POSITION = 0x01, // exclude callbacks at the initial position from the search + D3DXCALLBACK_SEARCH_BEHIND_INITIAL_POSITION = 0x02, // reverse the callback search direction + + D3DXCALLBACK_SEARCH_FORCE_DWORD = 0x7fffffff, +} D3DXCALLBACK_SEARCH_FLAGS; + +//---------------------------------------------------------------------------- +// ID3DXAnimationSet: +// ------------------ +// This interface implements an animation set. +//---------------------------------------------------------------------------- +typedef interface ID3DXAnimationSet ID3DXAnimationSet; +typedef interface ID3DXAnimationSet *LPD3DXANIMATIONSET; + +#undef INTERFACE +#define INTERFACE ID3DXAnimationSet + +DECLARE_INTERFACE_(ID3DXAnimationSet, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // Name + STDMETHOD_(LPCSTR, GetName)(THIS) PURE; + + // Period + STDMETHOD_(DOUBLE, GetPeriod)(THIS) PURE; + STDMETHOD_(DOUBLE, GetPeriodicPosition)(THIS_ DOUBLE Position) PURE; // Maps position into animation period + + // Animation names + STDMETHOD_(UINT, GetNumAnimations)(THIS) PURE; + STDMETHOD(GetAnimationNameByIndex)(THIS_ UINT Index, LPCSTR *ppName) PURE; + STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE; + + // SRT + STDMETHOD(GetSRT)(THIS_ + DOUBLE PeriodicPosition, // Position mapped to period (use GetPeriodicPosition) + UINT Animation, // Animation index + D3DXVECTOR3 *pScale, // Returns the scale + D3DXQUATERNION *pRotation, // Returns the rotation as a quaternion + D3DXVECTOR3 *pTranslation) PURE; // Returns the translation + + // Callbacks + STDMETHOD(GetCallback)(THIS_ + DOUBLE Position, // Position from which to find callbacks + DWORD Flags, // Callback search flags + DOUBLE *pCallbackPosition, // Returns the position of the callback + LPVOID *ppCallbackData) PURE; // Returns the callback data pointer +}; + + +//---------------------------------------------------------------------------- +// D3DXPLAYBACK_TYPE: +// ------------------ +// This enum defines the type of animation set loop modes. +//---------------------------------------------------------------------------- +typedef enum _D3DXPLAYBACK_TYPE +{ + D3DXPLAY_LOOP = 0, + D3DXPLAY_ONCE = 1, + D3DXPLAY_PINGPONG = 2, + + D3DXPLAY_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DXPLAYBACK_TYPE; + + +//---------------------------------------------------------------------------- +// D3DXKEY_VECTOR3: +// ---------------- +// This structure describes a vector key for use in keyframe animation. +// It specifies a vector Value at a given Time. This is used for scale and +// translation keys. +//---------------------------------------------------------------------------- +typedef struct _D3DXKEY_VECTOR3 +{ + FLOAT Time; + D3DXVECTOR3 Value; +} D3DXKEY_VECTOR3, *LPD3DXKEY_VECTOR3; + + +//---------------------------------------------------------------------------- +// D3DXKEY_QUATERNION: +// ------------------- +// This structure describes a quaternion key for use in keyframe animation. +// It specifies a quaternion Value at a given Time. This is used for rotation +// keys. +//---------------------------------------------------------------------------- +typedef struct _D3DXKEY_QUATERNION +{ + FLOAT Time; + D3DXQUATERNION Value; +} D3DXKEY_QUATERNION, *LPD3DXKEY_QUATERNION; + + +//---------------------------------------------------------------------------- +// D3DXKEY_CALLBACK: +// ----------------- +// This structure describes an callback key for use in keyframe animation. +// It specifies a pointer to user data at a given Time. +//---------------------------------------------------------------------------- +typedef struct _D3DXKEY_CALLBACK +{ + FLOAT Time; + LPVOID pCallbackData; +} D3DXKEY_CALLBACK, *LPD3DXKEY_CALLBACK; + + +//---------------------------------------------------------------------------- +// D3DXCOMPRESSION_FLAGS: +// ---------------------- +// Flags that can be passed into ID3DXKeyframedAnimationSet::Compress. +//---------------------------------------------------------------------------- +typedef enum _D3DXCOMPRESSION_FLAGS +{ + D3DXCOMPRESS_DEFAULT = 0x00, + + D3DXCOMPRESS_FORCE_DWORD = 0x7fffffff, +} D3DXCOMPRESSION_FLAGS; + + +//---------------------------------------------------------------------------- +// ID3DXKeyframedAnimationSet: +// --------------------------- +// This interface implements a compressable keyframed animation set. +//---------------------------------------------------------------------------- +typedef interface ID3DXKeyframedAnimationSet ID3DXKeyframedAnimationSet; +typedef interface ID3DXKeyframedAnimationSet *LPD3DXKEYFRAMEDANIMATIONSET; + +#undef INTERFACE +#define INTERFACE ID3DXKeyframedAnimationSet + +DECLARE_INTERFACE_(ID3DXKeyframedAnimationSet, ID3DXAnimationSet) +{ + // ID3DXAnimationSet + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // Name + STDMETHOD_(LPCSTR, GetName)(THIS) PURE; + + // Period + STDMETHOD_(DOUBLE, GetPeriod)(THIS) PURE; + STDMETHOD_(DOUBLE, GetPeriodicPosition)(THIS_ DOUBLE Position) PURE; // Maps position into animation period + + // Animation names + STDMETHOD_(UINT, GetNumAnimations)(THIS) PURE; + STDMETHOD(GetAnimationNameByIndex)(THIS_ UINT Index, LPCSTR *ppName) PURE; + STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE; + + // SRT + STDMETHOD(GetSRT)(THIS_ + DOUBLE PeriodicPosition, // Position mapped to period (use GetPeriodicPosition) + UINT Animation, // Animation index + D3DXVECTOR3 *pScale, // Returns the scale + D3DXQUATERNION *pRotation, // Returns the rotation as a quaternion + D3DXVECTOR3 *pTranslation) PURE; // Returns the translation + + // Callbacks + STDMETHOD(GetCallback)(THIS_ + DOUBLE Position, // Position from which to find callbacks + DWORD Flags, // Callback search flags + DOUBLE *pCallbackPosition, // Returns the position of the callback + LPVOID *ppCallbackData) PURE; // Returns the callback data pointer + + // Playback + STDMETHOD_(D3DXPLAYBACK_TYPE, GetPlaybackType)(THIS) PURE; + STDMETHOD_(DOUBLE, GetSourceTicksPerSecond)(THIS) PURE; + + // Scale keys + STDMETHOD_(UINT, GetNumScaleKeys)(THIS_ UINT Animation) PURE; + STDMETHOD(GetScaleKeys)(THIS_ UINT Animation, LPD3DXKEY_VECTOR3 pScaleKeys) PURE; + STDMETHOD(GetScaleKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pScaleKey) PURE; + STDMETHOD(SetScaleKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pScaleKey) PURE; + + // Rotation keys + STDMETHOD_(UINT, GetNumRotationKeys)(THIS_ UINT Animation) PURE; + STDMETHOD(GetRotationKeys)(THIS_ UINT Animation, LPD3DXKEY_QUATERNION pRotationKeys) PURE; + STDMETHOD(GetRotationKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_QUATERNION pRotationKey) PURE; + STDMETHOD(SetRotationKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_QUATERNION pRotationKey) PURE; + + // Translation keys + STDMETHOD_(UINT, GetNumTranslationKeys)(THIS_ UINT Animation) PURE; + STDMETHOD(GetTranslationKeys)(THIS_ UINT Animation, LPD3DXKEY_VECTOR3 pTranslationKeys) PURE; + STDMETHOD(GetTranslationKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pTranslationKey) PURE; + STDMETHOD(SetTranslationKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pTranslationKey) PURE; + + // Callback keys + STDMETHOD_(UINT, GetNumCallbackKeys)(THIS) PURE; + STDMETHOD(GetCallbackKeys)(THIS_ LPD3DXKEY_CALLBACK pCallbackKeys) PURE; + STDMETHOD(GetCallbackKey)(THIS_ UINT Key, LPD3DXKEY_CALLBACK pCallbackKey) PURE; + STDMETHOD(SetCallbackKey)(THIS_ UINT Key, LPD3DXKEY_CALLBACK pCallbackKey) PURE; + + // Key removal methods. These are slow, and should not be used once the animation starts playing + STDMETHOD(UnregisterScaleKey)(THIS_ UINT Animation, UINT Key) PURE; + STDMETHOD(UnregisterRotationKey)(THIS_ UINT Animation, UINT Key) PURE; + STDMETHOD(UnregisterTranslationKey)(THIS_ UINT Animation, UINT Key) PURE; + + // One-time animaton SRT keyframe registration + STDMETHOD(RegisterAnimationSRTKeys)(THIS_ + LPCSTR pName, // Animation name + UINT NumScaleKeys, // Number of scale keys + UINT NumRotationKeys, // Number of rotation keys + UINT NumTranslationKeys, // Number of translation keys + CONST D3DXKEY_VECTOR3 *pScaleKeys, // Array of scale keys + CONST D3DXKEY_QUATERNION *pRotationKeys, // Array of rotation keys + CONST D3DXKEY_VECTOR3 *pTranslationKeys, // Array of translation keys + DWORD *pAnimationIndex) PURE; // Returns the animation index + + // Compression + STDMETHOD(Compress)(THIS_ + DWORD Flags, // Compression flags (use D3DXCOMPRESS_STRONG for better results) + FLOAT Lossiness, // Compression loss ratio in the [0, 1] range + LPD3DXFRAME pHierarchy, // Frame hierarchy (optional) + LPD3DXBUFFER *ppCompressedData) PURE; // Returns the compressed animation set + + STDMETHOD(UnregisterAnimation)(THIS_ UINT Index) PURE; +}; + + +//---------------------------------------------------------------------------- +// ID3DXCompressedAnimationSet: +// ---------------------------- +// This interface implements a compressed keyframed animation set. +//---------------------------------------------------------------------------- +typedef interface ID3DXCompressedAnimationSet ID3DXCompressedAnimationSet; +typedef interface ID3DXCompressedAnimationSet *LPD3DXCOMPRESSEDANIMATIONSET; + +#undef INTERFACE +#define INTERFACE ID3DXCompressedAnimationSet + +DECLARE_INTERFACE_(ID3DXCompressedAnimationSet, ID3DXAnimationSet) +{ + // ID3DXAnimationSet + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // Name + STDMETHOD_(LPCSTR, GetName)(THIS) PURE; + + // Period + STDMETHOD_(DOUBLE, GetPeriod)(THIS) PURE; + STDMETHOD_(DOUBLE, GetPeriodicPosition)(THIS_ DOUBLE Position) PURE; // Maps position into animation period + + // Animation names + STDMETHOD_(UINT, GetNumAnimations)(THIS) PURE; + STDMETHOD(GetAnimationNameByIndex)(THIS_ UINT Index, LPCSTR *ppName) PURE; + STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE; + + // SRT + STDMETHOD(GetSRT)(THIS_ + DOUBLE PeriodicPosition, // Position mapped to period (use GetPeriodicPosition) + UINT Animation, // Animation index + D3DXVECTOR3 *pScale, // Returns the scale + D3DXQUATERNION *pRotation, // Returns the rotation as a quaternion + D3DXVECTOR3 *pTranslation) PURE; // Returns the translation + + // Callbacks + STDMETHOD(GetCallback)(THIS_ + DOUBLE Position, // Position from which to find callbacks + DWORD Flags, // Callback search flags + DOUBLE *pCallbackPosition, // Returns the position of the callback + LPVOID *ppCallbackData) PURE; // Returns the callback data pointer + + // Playback + STDMETHOD_(D3DXPLAYBACK_TYPE, GetPlaybackType)(THIS) PURE; + STDMETHOD_(DOUBLE, GetSourceTicksPerSecond)(THIS) PURE; + + // Scale keys + STDMETHOD(GetCompressedData)(THIS_ LPD3DXBUFFER *ppCompressedData) PURE; + + // Callback keys + STDMETHOD_(UINT, GetNumCallbackKeys)(THIS) PURE; + STDMETHOD(GetCallbackKeys)(THIS_ LPD3DXKEY_CALLBACK pCallbackKeys) PURE; +}; + + +//---------------------------------------------------------------------------- +// D3DXPRIORITY_TYPE: +// ------------------ +// This enum defines the type of priority group that a track can be assigned to. +//---------------------------------------------------------------------------- +typedef enum _D3DXPRIORITY_TYPE { + D3DXPRIORITY_LOW = 0, // This track should be blended with all low priority tracks before mixed with the high priority result + D3DXPRIORITY_HIGH = 1, // This track should be blended with all high priority tracks before mixed with the low priority result + + D3DXPRIORITY_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DXPRIORITY_TYPE; + +//---------------------------------------------------------------------------- +// D3DXTRACK_DESC: +// --------------- +// This structure describes the mixing information of an animation track. +// The mixing information consists of the current position, speed, and blending +// weight for the track. The Flags field also specifies whether the track is +// low or high priority. Tracks with the same priority are blended together +// and then the two resulting values are blended using the priority blend factor. +// A track also has an animation set (stored separately) associated with it. +//---------------------------------------------------------------------------- +typedef struct _D3DXTRACK_DESC +{ + D3DXPRIORITY_TYPE Priority; + FLOAT Weight; + FLOAT Speed; + DOUBLE Position; + BOOL Enable; +} D3DXTRACK_DESC, *LPD3DXTRACK_DESC; + +//---------------------------------------------------------------------------- +// D3DXEVENT_TYPE: +// --------------- +// This enum defines the type of events keyable via the animation controller. +//---------------------------------------------------------------------------- +typedef enum _D3DXEVENT_TYPE +{ + D3DXEVENT_TRACKSPEED = 0, + D3DXEVENT_TRACKWEIGHT = 1, + D3DXEVENT_TRACKPOSITION = 2, + D3DXEVENT_TRACKENABLE = 3, + D3DXEVENT_PRIORITYBLEND = 4, + + D3DXEVENT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DXEVENT_TYPE; + +//---------------------------------------------------------------------------- +// D3DXTRANSITION_TYPE: +// -------------------- +// This enum defines the type of transtion performed on a event that +// transitions from one value to another. +//---------------------------------------------------------------------------- +typedef enum _D3DXTRANSITION_TYPE { + D3DXTRANSITION_LINEAR = 0x000, // Linear transition from one value to the next + D3DXTRANSITION_EASEINEASEOUT = 0x001, // Ease-In Ease-Out spline transtion from one value to the next + + D3DXTRANSITION_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DXTRANSITION_TYPE; + +//---------------------------------------------------------------------------- +// D3DXEVENT_DESC: +// --------------- +// This structure describes a animation controller event. +// It gives the event's type, track (if the event is a track event), global +// start time, duration, transition method, and target value. +//---------------------------------------------------------------------------- +typedef struct _D3DXEVENT_DESC +{ + D3DXEVENT_TYPE Type; + UINT Track; + DOUBLE StartTime; + DOUBLE Duration; + D3DXTRANSITION_TYPE Transition; + union + { + FLOAT Weight; + FLOAT Speed; + DOUBLE Position; + BOOL Enable; + }; +} D3DXEVENT_DESC, *LPD3DXEVENT_DESC; + +//---------------------------------------------------------------------------- +// D3DXEVENTHANDLE: +// ---------------- +// Handle values used to efficiently reference animation controller events. +//---------------------------------------------------------------------------- +typedef DWORD D3DXEVENTHANDLE; +typedef D3DXEVENTHANDLE *LPD3DXEVENTHANDLE; + + +//---------------------------------------------------------------------------- +// ID3DXAnimationCallbackHandler: +// ------------------------------ +// This interface is intended to be implemented by the application, and can +// be used to handle callbacks in animation sets generated when +// ID3DXAnimationController::AdvanceTime() is called. +//---------------------------------------------------------------------------- +typedef interface ID3DXAnimationCallbackHandler ID3DXAnimationCallbackHandler; +typedef interface ID3DXAnimationCallbackHandler *LPD3DXANIMATIONCALLBACKHANDLER; + +#undef INTERFACE +#define INTERFACE ID3DXAnimationCallbackHandler + +DECLARE_INTERFACE(ID3DXAnimationCallbackHandler) +{ + //---------------------------------------------------------------------------- + // ID3DXAnimationCallbackHandler::HandleCallback: + // ---------------------------------------------- + // This method gets called when a callback occurs for an animation set in one + // of the tracks during the ID3DXAnimationController::AdvanceTime() call. + // + // Parameters: + // Track + // Index of the track on which the callback occured. + // pCallbackData + // Pointer to user owned callback data. + // + //---------------------------------------------------------------------------- + STDMETHOD(HandleCallback)(THIS_ UINT Track, LPVOID pCallbackData) PURE; +}; + + +//---------------------------------------------------------------------------- +// ID3DXAnimationController: +// ------------------------- +// This interface implements the main animation functionality. It connects +// animation sets with the transform frames that are being animated. Allows +// mixing multiple animations for blended animations or for transistions +// It adds also has methods to modify blending parameters over time to +// enable smooth transistions and other effects. +//---------------------------------------------------------------------------- +typedef interface ID3DXAnimationController ID3DXAnimationController; +typedef interface ID3DXAnimationController *LPD3DXANIMATIONCONTROLLER; + +#undef INTERFACE +#define INTERFACE ID3DXAnimationController + +DECLARE_INTERFACE_(ID3DXAnimationController, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // Max sizes + STDMETHOD_(UINT, GetMaxNumAnimationOutputs)(THIS) PURE; + STDMETHOD_(UINT, GetMaxNumAnimationSets)(THIS) PURE; + STDMETHOD_(UINT, GetMaxNumTracks)(THIS) PURE; + STDMETHOD_(UINT, GetMaxNumEvents)(THIS) PURE; + + // Animation output registration + STDMETHOD(RegisterAnimationOutput)(THIS_ + LPCSTR pName, + D3DXMATRIX *pMatrix, + D3DXVECTOR3 *pScale, + D3DXQUATERNION *pRotation, + D3DXVECTOR3 *pTranslation) PURE; + + // Animation set registration + STDMETHOD(RegisterAnimationSet)(THIS_ LPD3DXANIMATIONSET pAnimSet) PURE; + STDMETHOD(UnregisterAnimationSet)(THIS_ LPD3DXANIMATIONSET pAnimSet) PURE; + + STDMETHOD_(UINT, GetNumAnimationSets)(THIS) PURE; + STDMETHOD(GetAnimationSet)(THIS_ UINT Index, LPD3DXANIMATIONSET *ppAnimationSet) PURE; + STDMETHOD(GetAnimationSetByName)(THIS_ LPCSTR szName, LPD3DXANIMATIONSET *ppAnimationSet) PURE; + + // Global time + STDMETHOD(AdvanceTime)(THIS_ DOUBLE TimeDelta, LPD3DXANIMATIONCALLBACKHANDLER pCallbackHandler) PURE; + STDMETHOD(ResetTime)(THIS) PURE; + STDMETHOD_(DOUBLE, GetTime)(THIS) PURE; + + // Tracks + STDMETHOD(SetTrackAnimationSet)(THIS_ UINT Track, LPD3DXANIMATIONSET pAnimSet) PURE; + STDMETHOD(GetTrackAnimationSet)(THIS_ UINT Track, LPD3DXANIMATIONSET *ppAnimSet) PURE; + + STDMETHOD(SetTrackPriority)(THIS_ UINT Track, D3DXPRIORITY_TYPE Priority) PURE; + + STDMETHOD(SetTrackSpeed)(THIS_ UINT Track, FLOAT Speed) PURE; + STDMETHOD(SetTrackWeight)(THIS_ UINT Track, FLOAT Weight) PURE; + STDMETHOD(SetTrackPosition)(THIS_ UINT Track, DOUBLE Position) PURE; + STDMETHOD(SetTrackEnable)(THIS_ UINT Track, BOOL Enable) PURE; + + STDMETHOD(SetTrackDesc)(THIS_ UINT Track, LPD3DXTRACK_DESC pDesc) PURE; + STDMETHOD(GetTrackDesc)(THIS_ UINT Track, LPD3DXTRACK_DESC pDesc) PURE; + + // Priority blending + STDMETHOD(SetPriorityBlend)(THIS_ FLOAT BlendWeight) PURE; + STDMETHOD_(FLOAT, GetPriorityBlend)(THIS) PURE; + + // Event keying + STDMETHOD_(D3DXEVENTHANDLE, KeyTrackSpeed)(THIS_ UINT Track, FLOAT NewSpeed, DOUBLE StartTime, DOUBLE Duration, D3DXTRANSITION_TYPE Transition) PURE; + STDMETHOD_(D3DXEVENTHANDLE, KeyTrackWeight)(THIS_ UINT Track, FLOAT NewWeight, DOUBLE StartTime, DOUBLE Duration, D3DXTRANSITION_TYPE Transition) PURE; + STDMETHOD_(D3DXEVENTHANDLE, KeyTrackPosition)(THIS_ UINT Track, DOUBLE NewPosition, DOUBLE StartTime) PURE; + STDMETHOD_(D3DXEVENTHANDLE, KeyTrackEnable)(THIS_ UINT Track, BOOL NewEnable, DOUBLE StartTime) PURE; + + STDMETHOD_(D3DXEVENTHANDLE, KeyPriorityBlend)(THIS_ FLOAT NewBlendWeight, DOUBLE StartTime, DOUBLE Duration, D3DXTRANSITION_TYPE Transition) PURE; + + // Event unkeying + STDMETHOD(UnkeyEvent)(THIS_ D3DXEVENTHANDLE hEvent) PURE; + + STDMETHOD(UnkeyAllTrackEvents)(THIS_ UINT Track) PURE; + STDMETHOD(UnkeyAllPriorityBlends)(THIS) PURE; + + // Event enumeration + STDMETHOD_(D3DXEVENTHANDLE, GetCurrentTrackEvent)(THIS_ UINT Track, D3DXEVENT_TYPE EventType) PURE; + STDMETHOD_(D3DXEVENTHANDLE, GetCurrentPriorityBlend)(THIS) PURE; + + STDMETHOD_(D3DXEVENTHANDLE, GetUpcomingTrackEvent)(THIS_ UINT Track, D3DXEVENTHANDLE hEvent) PURE; + STDMETHOD_(D3DXEVENTHANDLE, GetUpcomingPriorityBlend)(THIS_ D3DXEVENTHANDLE hEvent) PURE; + + STDMETHOD(ValidateEvent)(THIS_ D3DXEVENTHANDLE hEvent) PURE; + + STDMETHOD(GetEventDesc)(THIS_ D3DXEVENTHANDLE hEvent, LPD3DXEVENT_DESC pDesc) PURE; + + // Cloning + STDMETHOD(CloneAnimationController)(THIS_ + UINT MaxNumAnimationOutputs, + UINT MaxNumAnimationSets, + UINT MaxNumTracks, + UINT MaxNumEvents, + LPD3DXANIMATIONCONTROLLER *ppAnimController) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +//---------------------------------------------------------------------------- +// D3DXLoadMeshHierarchyFromX: +// --------------------------- +// Loads the first frame hierarchy in a .X file. +// +// Parameters: +// Filename +// Name of the .X file +// MeshOptions +// Mesh creation options for meshes in the file (see d3dx9mesh.h) +// pD3DDevice +// D3D9 device on which meshes in the file are created in +// pAlloc +// Allocation interface used to allocate nodes of the frame hierarchy +// pUserDataLoader +// Application provided interface to allow loading of user data +// ppFrameHierarchy +// Returns root node pointer of the loaded frame hierarchy +// ppAnimController +// Returns pointer to an animation controller corresponding to animation +// in the .X file. This is created with default max tracks and events +// +//---------------------------------------------------------------------------- +HRESULT WINAPI +D3DXLoadMeshHierarchyFromXA + ( + LPCSTR Filename, + DWORD MeshOptions, + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXALLOCATEHIERARCHY pAlloc, + LPD3DXLOADUSERDATA pUserDataLoader, + LPD3DXFRAME *ppFrameHierarchy, + LPD3DXANIMATIONCONTROLLER *ppAnimController + ); + +HRESULT WINAPI +D3DXLoadMeshHierarchyFromXW + ( + LPCWSTR Filename, + DWORD MeshOptions, + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXALLOCATEHIERARCHY pAlloc, + LPD3DXLOADUSERDATA pUserDataLoader, + LPD3DXFRAME *ppFrameHierarchy, + LPD3DXANIMATIONCONTROLLER *ppAnimController + ); + +#ifdef UNICODE +#define D3DXLoadMeshHierarchyFromX D3DXLoadMeshHierarchyFromXW +#else +#define D3DXLoadMeshHierarchyFromX D3DXLoadMeshHierarchyFromXA +#endif + +HRESULT WINAPI +D3DXLoadMeshHierarchyFromXInMemory + ( + LPCVOID Memory, + DWORD SizeOfMemory, + DWORD MeshOptions, + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXALLOCATEHIERARCHY pAlloc, + LPD3DXLOADUSERDATA pUserDataLoader, + LPD3DXFRAME *ppFrameHierarchy, + LPD3DXANIMATIONCONTROLLER *ppAnimController + ); + +//---------------------------------------------------------------------------- +// D3DXSaveMeshHierarchyToFile: +// ---------------------------- +// Creates a .X file and saves the mesh hierarchy and corresponding animations +// in it +// +// Parameters: +// Filename +// Name of the .X file +// XFormat +// Format of the .X file (text or binary, compressed or not, etc) +// pFrameRoot +// Root node of the hierarchy to be saved +// pAnimController +// The animation controller whose animation sets are to be stored +// pUserDataSaver +// Application provided interface to allow adding of user data to +// data objects saved to .X file +// +//---------------------------------------------------------------------------- +HRESULT WINAPI +D3DXSaveMeshHierarchyToFileA + ( + LPCSTR Filename, + DWORD XFormat, + CONST D3DXFRAME *pFrameRoot, + LPD3DXANIMATIONCONTROLLER pAnimcontroller, + LPD3DXSAVEUSERDATA pUserDataSaver + ); + +HRESULT WINAPI +D3DXSaveMeshHierarchyToFileW + ( + LPCWSTR Filename, + DWORD XFormat, + CONST D3DXFRAME *pFrameRoot, + LPD3DXANIMATIONCONTROLLER pAnimController, + LPD3DXSAVEUSERDATA pUserDataSaver + ); + +#ifdef UNICODE +#define D3DXSaveMeshHierarchyToFile D3DXSaveMeshHierarchyToFileW +#else +#define D3DXSaveMeshHierarchyToFile D3DXSaveMeshHierarchyToFileA +#endif + +//---------------------------------------------------------------------------- +// D3DXFrameDestroy: +// ----------------- +// Destroys the subtree of frames under the root, including the root +// +// Parameters: +// pFrameRoot +// Pointer to the root node +// pAlloc +// Allocation interface used to de-allocate nodes of the frame hierarchy +// +//---------------------------------------------------------------------------- +HRESULT WINAPI +D3DXFrameDestroy + ( + LPD3DXFRAME pFrameRoot, + LPD3DXALLOCATEHIERARCHY pAlloc + ); + +//---------------------------------------------------------------------------- +// D3DXFrameAppendChild: +// --------------------- +// Add a child frame to a frame +// +// Parameters: +// pFrameParent +// Pointer to the parent node +// pFrameChild +// Pointer to the child node +// +//---------------------------------------------------------------------------- +HRESULT WINAPI +D3DXFrameAppendChild + ( + LPD3DXFRAME pFrameParent, + CONST D3DXFRAME *pFrameChild + ); + +//---------------------------------------------------------------------------- +// D3DXFrameFind: +// -------------- +// Finds a frame with the given name. Returns NULL if no frame found. +// +// Parameters: +// pFrameRoot +// Pointer to the root node +// Name +// Name of frame to find +// +//---------------------------------------------------------------------------- +LPD3DXFRAME WINAPI +D3DXFrameFind + ( + CONST D3DXFRAME *pFrameRoot, + LPCSTR Name + ); + +//---------------------------------------------------------------------------- +// D3DXFrameRegisterNamedMatrices: +// ------------------------------- +// Finds all frames that have non-null names and registers each of those frame +// matrices to the given animation controller +// +// Parameters: +// pFrameRoot +// Pointer to the root node +// pAnimController +// Pointer to the animation controller where the matrices are registered +// +//---------------------------------------------------------------------------- +HRESULT WINAPI +D3DXFrameRegisterNamedMatrices + ( + LPD3DXFRAME pFrameRoot, + LPD3DXANIMATIONCONTROLLER pAnimController + ); + +//---------------------------------------------------------------------------- +// D3DXFrameNumNamedMatrices: +// -------------------------- +// Counts number of frames in a subtree that have non-null names +// +// Parameters: +// pFrameRoot +// Pointer to the root node of the subtree +// Return Value: +// Count of frames +// +//---------------------------------------------------------------------------- +UINT WINAPI +D3DXFrameNumNamedMatrices + ( + CONST D3DXFRAME *pFrameRoot + ); + +//---------------------------------------------------------------------------- +// D3DXFrameCalculateBoundingSphere: +// --------------------------------- +// Computes the bounding sphere of all the meshes in the frame hierarchy. +// +// Parameters: +// pFrameRoot +// Pointer to the root node +// pObjectCenter +// Returns the center of the bounding sphere +// pObjectRadius +// Returns the radius of the bounding sphere +// +//---------------------------------------------------------------------------- +HRESULT WINAPI +D3DXFrameCalculateBoundingSphere + ( + CONST D3DXFRAME *pFrameRoot, + LPD3DXVECTOR3 pObjectCenter, + FLOAT *pObjectRadius + ); + + +//---------------------------------------------------------------------------- +// D3DXCreateKeyframedAnimationSet: +// -------------------------------- +// This function creates a compressable keyframed animations set interface. +// +// Parameters: +// pName +// Name of the animation set +// TicksPerSecond +// Number of keyframe ticks that elapse per second +// Playback +// Playback mode of keyframe looping +// NumAnimations +// Number of SRT animations +// NumCallbackKeys +// Number of callback keys +// pCallbackKeys +// Array of callback keys +// ppAnimationSet +// Returns the animation set interface +// +//----------------------------------------------------------------------------- +HRESULT WINAPI +D3DXCreateKeyframedAnimationSet + ( + LPCSTR pName, + DOUBLE TicksPerSecond, + D3DXPLAYBACK_TYPE Playback, + UINT NumAnimations, + UINT NumCallbackKeys, + CONST D3DXKEY_CALLBACK *pCallbackKeys, + LPD3DXKEYFRAMEDANIMATIONSET *ppAnimationSet + ); + + +//---------------------------------------------------------------------------- +// D3DXCreateCompressedAnimationSet: +// -------------------------------- +// This function creates a compressed animations set interface from +// compressed data. +// +// Parameters: +// pName +// Name of the animation set +// TicksPerSecond +// Number of keyframe ticks that elapse per second +// Playback +// Playback mode of keyframe looping +// pCompressedData +// Compressed animation SRT data +// NumCallbackKeys +// Number of callback keys +// pCallbackKeys +// Array of callback keys +// ppAnimationSet +// Returns the animation set interface +// +//----------------------------------------------------------------------------- +HRESULT WINAPI +D3DXCreateCompressedAnimationSet + ( + LPCSTR pName, + DOUBLE TicksPerSecond, + D3DXPLAYBACK_TYPE Playback, + LPD3DXBUFFER pCompressedData, + UINT NumCallbackKeys, + CONST D3DXKEY_CALLBACK *pCallbackKeys, + LPD3DXCOMPRESSEDANIMATIONSET *ppAnimationSet + ); + + +//---------------------------------------------------------------------------- +// D3DXCreateAnimationController: +// ------------------------------ +// This function creates an animation controller object. +// +// Parameters: +// MaxNumMatrices +// Maximum number of matrices that can be animated +// MaxNumAnimationSets +// Maximum number of animation sets that can be played +// MaxNumTracks +// Maximum number of animation sets that can be blended +// MaxNumEvents +// Maximum number of outstanding events that can be scheduled at any given time +// ppAnimController +// Returns the animation controller interface +// +//----------------------------------------------------------------------------- +HRESULT WINAPI +D3DXCreateAnimationController + ( + UINT MaxNumMatrices, + UINT MaxNumAnimationSets, + UINT MaxNumTracks, + UINT MaxNumEvents, + LPD3DXANIMATIONCONTROLLER *ppAnimController + ); + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX9ANIM_H__ + + diff --git a/src/dep/include/DXSDK/include/d3dx9core.h b/src/dep/include/DXSDK/include/d3dx9core.h index 4aa0b98..3c3cee0 100644 --- a/src/dep/include/DXSDK/include/d3dx9core.h +++ b/src/dep/include/DXSDK/include/d3dx9core.h @@ -1,748 +1,748 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx9core.h -// Content: D3DX core types and functions -// -/////////////////////////////////////////////////////////////////////////// - -#include "d3dx9.h" - -#ifndef __D3DX9CORE_H__ -#define __D3DX9CORE_H__ - - -/////////////////////////////////////////////////////////////////////////// -// D3DX_SDK_VERSION: -// ----------------- -// This identifier is passed to D3DXCheckVersion in order to ensure that an -// application was built against the correct header files and lib files. -// This number is incremented whenever a header (or other) change would -// require applications to be rebuilt. If the version doesn't match, -// D3DXCheckVersion will return FALSE. (The number itself has no meaning.) -/////////////////////////////////////////////////////////////////////////// - -#define D3DX_VERSION 0x0902 -#define D3DX_SDK_VERSION 30 - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -BOOL WINAPI - D3DXCheckVersion(UINT D3DSdkVersion, UINT D3DXSdkVersion); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - -/////////////////////////////////////////////////////////////////////////// -// D3DXDebugMute -// Mutes D3DX and D3D debug spew (TRUE - mute, FALSE - not mute) -// -// returns previous mute value -// -/////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -BOOL WINAPI - D3DXDebugMute(BOOL Mute); - -#ifdef __cplusplus -} -#endif //__cplusplus - - -/////////////////////////////////////////////////////////////////////////// -// D3DXGetDriverLevel: -// Returns driver version information: -// -// 700 - DX7 level driver -// 800 - DX8 level driver -// 900 - DX9 level driver -/////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -UINT WINAPI - D3DXGetDriverLevel(LPDIRECT3DDEVICE9 pDevice); - -#ifdef __cplusplus -} -#endif //__cplusplus - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXBuffer: -// ------------ -// The buffer object is used by D3DX to return arbitrary size data. -// -// GetBufferPointer - -// Returns a pointer to the beginning of the buffer. -// -// GetBufferSize - -// Returns the size of the buffer, in bytes. -/////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXBuffer ID3DXBuffer; -typedef interface ID3DXBuffer *LPD3DXBUFFER; - -// {8BA5FB08-5195-40e2-AC58-0D989C3A0102} -DEFINE_GUID(IID_ID3DXBuffer, -0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2); - -#undef INTERFACE -#define INTERFACE ID3DXBuffer - -DECLARE_INTERFACE_(ID3DXBuffer, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBuffer - STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; - STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; -}; - - - -////////////////////////////////////////////////////////////////////////////// -// D3DXSPRITE flags: -// ----------------- -// D3DXSPRITE_DONOTSAVESTATE -// Specifies device state is not to be saved and restored in Begin/End. -// D3DXSPRITE_DONOTMODIFY_RENDERSTATE -// Specifies device render state is not to be changed in Begin. The device -// is assumed to be in a valid state to draw vertices containing POSITION0, -// TEXCOORD0, and COLOR0 data. -// D3DXSPRITE_OBJECTSPACE -// The WORLD, VIEW, and PROJECTION transforms are NOT modified. The -// transforms currently set to the device are used to transform the sprites -// when the batch is drawn (at Flush or End). If this is not specified, -// WORLD, VIEW, and PROJECTION transforms are modified so that sprites are -// drawn in screenspace coordinates. -// D3DXSPRITE_BILLBOARD -// Rotates each sprite about its center so that it is facing the viewer. -// D3DXSPRITE_ALPHABLEND -// Enables ALPHABLEND(SRCALPHA, INVSRCALPHA) and ALPHATEST(alpha > 0). -// ID3DXFont expects this to be set when drawing text. -// D3DXSPRITE_SORT_TEXTURE -// Sprites are sorted by texture prior to drawing. This is recommended when -// drawing non-overlapping sprites of uniform depth. For example, drawing -// screen-aligned text with ID3DXFont. -// D3DXSPRITE_SORT_DEPTH_FRONTTOBACK -// Sprites are sorted by depth front-to-back prior to drawing. This is -// recommended when drawing opaque sprites of varying depths. -// D3DXSPRITE_SORT_DEPTH_BACKTOFRONT -// Sprites are sorted by depth back-to-front prior to drawing. This is -// recommended when drawing transparent sprites of varying depths. -////////////////////////////////////////////////////////////////////////////// - -#define D3DXSPRITE_DONOTSAVESTATE (1 << 0) -#define D3DXSPRITE_DONOTMODIFY_RENDERSTATE (1 << 1) -#define D3DXSPRITE_OBJECTSPACE (1 << 2) -#define D3DXSPRITE_BILLBOARD (1 << 3) -#define D3DXSPRITE_ALPHABLEND (1 << 4) -#define D3DXSPRITE_SORT_TEXTURE (1 << 5) -#define D3DXSPRITE_SORT_DEPTH_FRONTTOBACK (1 << 6) -#define D3DXSPRITE_SORT_DEPTH_BACKTOFRONT (1 << 7) - - -////////////////////////////////////////////////////////////////////////////// -// ID3DXSprite: -// ------------ -// This object intends to provide an easy way to drawing sprites using D3D. -// -// Begin - -// Prepares device for drawing sprites. -// -// Draw - -// Draws a sprite. Before transformation, the sprite is the size of -// SrcRect, with its top-left corner specified by Position. The color -// and alpha channels are modulated by Color. -// -// Flush - -// Forces all batched sprites to submitted to the device. -// -// End - -// Restores device state to how it was when Begin was called. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXSprite ID3DXSprite; -typedef interface ID3DXSprite *LPD3DXSPRITE; - - -// {BA0B762D-7D28-43ec-B9DC-2F84443B0614} -DEFINE_GUID(IID_ID3DXSprite, -0xba0b762d, 0x7d28, 0x43ec, 0xb9, 0xdc, 0x2f, 0x84, 0x44, 0x3b, 0x6, 0x14); - - -#undef INTERFACE -#define INTERFACE ID3DXSprite - -DECLARE_INTERFACE_(ID3DXSprite, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXSprite - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - - STDMETHOD(GetTransform)(THIS_ D3DXMATRIX *pTransform) PURE; - STDMETHOD(SetTransform)(THIS_ CONST D3DXMATRIX *pTransform) PURE; - - STDMETHOD(SetWorldViewRH)(THIS_ CONST D3DXMATRIX *pWorld, CONST D3DXMATRIX *pView) PURE; - STDMETHOD(SetWorldViewLH)(THIS_ CONST D3DXMATRIX *pWorld, CONST D3DXMATRIX *pView) PURE; - - STDMETHOD(Begin)(THIS_ DWORD Flags) PURE; - STDMETHOD(Draw)(THIS_ LPDIRECT3DTEXTURE9 pTexture, CONST RECT *pSrcRect, CONST D3DXVECTOR3 *pCenter, CONST D3DXVECTOR3 *pPosition, D3DCOLOR Color) PURE; - STDMETHOD(Flush)(THIS) PURE; - STDMETHOD(End)(THIS) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateSprite( - LPDIRECT3DDEVICE9 pDevice, - LPD3DXSPRITE* ppSprite); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - -////////////////////////////////////////////////////////////////////////////// -// ID3DXFont: -// ---------- -// Font objects contain the textures and resources needed to render a specific -// font on a specific device. -// -// GetGlyphData - -// Returns glyph cache data, for a given glyph. -// -// PreloadCharacters/PreloadGlyphs/PreloadText - -// Preloads glyphs into the glyph cache textures. -// -// DrawText - -// Draws formatted text on a D3D device. Some parameters are -// surprisingly similar to those of GDI's DrawText function. See GDI -// documentation for a detailed description of these parameters. -// If pSprite is NULL, an internal sprite object will be used. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -////////////////////////////////////////////////////////////////////////////// - -typedef struct _D3DXFONT_DESCA -{ - INT Height; - UINT Width; - UINT Weight; - UINT MipLevels; - BOOL Italic; - BYTE CharSet; - BYTE OutputPrecision; - BYTE Quality; - BYTE PitchAndFamily; - CHAR FaceName[LF_FACESIZE]; - -} D3DXFONT_DESCA, *LPD3DXFONT_DESCA; - -typedef struct _D3DXFONT_DESCW -{ - INT Height; - UINT Width; - UINT Weight; - UINT MipLevels; - BOOL Italic; - BYTE CharSet; - BYTE OutputPrecision; - BYTE Quality; - BYTE PitchAndFamily; - WCHAR FaceName[LF_FACESIZE]; - -} D3DXFONT_DESCW, *LPD3DXFONT_DESCW; - -#ifdef UNICODE -typedef D3DXFONT_DESCW D3DXFONT_DESC; -typedef LPD3DXFONT_DESCW LPD3DXFONT_DESC; -#else -typedef D3DXFONT_DESCA D3DXFONT_DESC; -typedef LPD3DXFONT_DESCA LPD3DXFONT_DESC; -#endif - - -typedef interface ID3DXFont ID3DXFont; -typedef interface ID3DXFont *LPD3DXFONT; - - -// {D79DBB70-5F21-4d36-BBC2-FF525C213CDC} -DEFINE_GUID(IID_ID3DXFont, -0xd79dbb70, 0x5f21, 0x4d36, 0xbb, 0xc2, 0xff, 0x52, 0x5c, 0x21, 0x3c, 0xdc); - - -#undef INTERFACE -#define INTERFACE ID3DXFont - -DECLARE_INTERFACE_(ID3DXFont, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXFont - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9 *ppDevice) PURE; - STDMETHOD(GetDescA)(THIS_ D3DXFONT_DESCA *pDesc) PURE; - STDMETHOD(GetDescW)(THIS_ D3DXFONT_DESCW *pDesc) PURE; - STDMETHOD_(BOOL, GetTextMetricsA)(THIS_ TEXTMETRICA *pTextMetrics) PURE; - STDMETHOD_(BOOL, GetTextMetricsW)(THIS_ TEXTMETRICW *pTextMetrics) PURE; - - STDMETHOD_(HDC, GetDC)(THIS) PURE; - STDMETHOD(GetGlyphData)(THIS_ UINT Glyph, LPDIRECT3DTEXTURE9 *ppTexture, RECT *pBlackBox, POINT *pCellInc) PURE; - - STDMETHOD(PreloadCharacters)(THIS_ UINT First, UINT Last) PURE; - STDMETHOD(PreloadGlyphs)(THIS_ UINT First, UINT Last) PURE; - STDMETHOD(PreloadTextA)(THIS_ LPCSTR pString, INT Count) PURE; - STDMETHOD(PreloadTextW)(THIS_ LPCWSTR pString, INT Count) PURE; - - STDMETHOD_(INT, DrawTextA)(THIS_ LPD3DXSPRITE pSprite, LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; - STDMETHOD_(INT, DrawTextW)(THIS_ LPD3DXSPRITE pSprite, LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; - -#ifdef __cplusplus -#ifdef UNICODE - HRESULT GetDesc(D3DXFONT_DESCW *pDesc) { return GetDescW(pDesc); } - HRESULT PreloadText(LPCWSTR pString, INT Count) { return PreloadTextW(pString, Count); } -#else - HRESULT GetDesc(D3DXFONT_DESCA *pDesc) { return GetDescA(pDesc); } - HRESULT PreloadText(LPCSTR pString, INT Count) { return PreloadTextA(pString, Count); } -#endif -#endif //__cplusplus -}; - -#ifndef GetTextMetrics -#ifdef UNICODE -#define GetTextMetrics GetTextMetricsW -#else -#define GetTextMetrics GetTextMetricsA -#endif -#endif - -#ifndef DrawText -#ifdef UNICODE -#define DrawText DrawTextW -#else -#define DrawText DrawTextA -#endif -#endif - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -HRESULT WINAPI - D3DXCreateFontA( - LPDIRECT3DDEVICE9 pDevice, - INT Height, - UINT Width, - UINT Weight, - UINT MipLevels, - BOOL Italic, - DWORD CharSet, - DWORD OutputPrecision, - DWORD Quality, - DWORD PitchAndFamily, - LPCSTR pFaceName, - LPD3DXFONT* ppFont); - -HRESULT WINAPI - D3DXCreateFontW( - LPDIRECT3DDEVICE9 pDevice, - INT Height, - UINT Width, - UINT Weight, - UINT MipLevels, - BOOL Italic, - DWORD CharSet, - DWORD OutputPrecision, - DWORD Quality, - DWORD PitchAndFamily, - LPCWSTR pFaceName, - LPD3DXFONT* ppFont); - -#ifdef UNICODE -#define D3DXCreateFont D3DXCreateFontW -#else -#define D3DXCreateFont D3DXCreateFontA -#endif - - -HRESULT WINAPI - D3DXCreateFontIndirectA( - LPDIRECT3DDEVICE9 pDevice, - CONST D3DXFONT_DESCA* pDesc, - LPD3DXFONT* ppFont); - -HRESULT WINAPI - D3DXCreateFontIndirectW( - LPDIRECT3DDEVICE9 pDevice, - CONST D3DXFONT_DESCW* pDesc, - LPD3DXFONT* ppFont); - -#ifdef UNICODE -#define D3DXCreateFontIndirect D3DXCreateFontIndirectW -#else -#define D3DXCreateFontIndirect D3DXCreateFontIndirectA -#endif - - -#ifdef __cplusplus -} -#endif //__cplusplus - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXRenderToSurface: -// --------------------- -// This object abstracts rendering to surfaces. These surfaces do not -// necessarily need to be render targets. If they are not, a compatible -// render target is used, and the result copied into surface at end scene. -// -// BeginScene, EndScene - -// Call BeginScene() and EndScene() at the beginning and ending of your -// scene. These calls will setup and restore render targets, viewports, -// etc.. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// - -typedef struct _D3DXRTS_DESC -{ - UINT Width; - UINT Height; - D3DFORMAT Format; - BOOL DepthStencil; - D3DFORMAT DepthStencilFormat; - -} D3DXRTS_DESC, *LPD3DXRTS_DESC; - - -typedef interface ID3DXRenderToSurface ID3DXRenderToSurface; -typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE; - - -// {6985F346-2C3D-43b3-BE8B-DAAE8A03D894} -DEFINE_GUID(IID_ID3DXRenderToSurface, -0x6985f346, 0x2c3d, 0x43b3, 0xbe, 0x8b, 0xda, 0xae, 0x8a, 0x3, 0xd8, 0x94); - - -#undef INTERFACE -#define INTERFACE ID3DXRenderToSurface - -DECLARE_INTERFACE_(ID3DXRenderToSurface, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXRenderToSurface - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(GetDesc)(THIS_ D3DXRTS_DESC* pDesc) PURE; - - STDMETHOD(BeginScene)(THIS_ LPDIRECT3DSURFACE9 pSurface, CONST D3DVIEWPORT9* pViewport) PURE; - STDMETHOD(EndScene)(THIS_ DWORD MipFilter) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateRenderToSurface( - LPDIRECT3DDEVICE9 pDevice, - UINT Width, - UINT Height, - D3DFORMAT Format, - BOOL DepthStencil, - D3DFORMAT DepthStencilFormat, - LPD3DXRENDERTOSURFACE* ppRenderToSurface); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXRenderToEnvMap: -// -------------------- -// This object abstracts rendering to environment maps. These surfaces -// do not necessarily need to be render targets. If they are not, a -// compatible render target is used, and the result copied into the -// environment map at end scene. -// -// BeginCube, BeginSphere, BeginHemisphere, BeginParabolic - -// This function initiates the rendering of the environment map. As -// parameters, you pass the textures in which will get filled in with -// the resulting environment map. -// -// Face - -// Call this function to initiate the drawing of each face. For each -// environment map, you will call this six times.. once for each face -// in D3DCUBEMAP_FACES. -// -// End - -// This will restore all render targets, and if needed compose all the -// rendered faces into the environment map surfaces. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// - -typedef struct _D3DXRTE_DESC -{ - UINT Size; - UINT MipLevels; - D3DFORMAT Format; - BOOL DepthStencil; - D3DFORMAT DepthStencilFormat; - -} D3DXRTE_DESC, *LPD3DXRTE_DESC; - - -typedef interface ID3DXRenderToEnvMap ID3DXRenderToEnvMap; -typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap; - - -// {313F1B4B-C7B0-4fa2-9D9D-8D380B64385E} -DEFINE_GUID(IID_ID3DXRenderToEnvMap, -0x313f1b4b, 0xc7b0, 0x4fa2, 0x9d, 0x9d, 0x8d, 0x38, 0xb, 0x64, 0x38, 0x5e); - - -#undef INTERFACE -#define INTERFACE ID3DXRenderToEnvMap - -DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXRenderToEnvMap - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE; - - STDMETHOD(BeginCube)(THIS_ - LPDIRECT3DCUBETEXTURE9 pCubeTex) PURE; - - STDMETHOD(BeginSphere)(THIS_ - LPDIRECT3DTEXTURE9 pTex) PURE; - - STDMETHOD(BeginHemisphere)(THIS_ - LPDIRECT3DTEXTURE9 pTexZPos, - LPDIRECT3DTEXTURE9 pTexZNeg) PURE; - - STDMETHOD(BeginParabolic)(THIS_ - LPDIRECT3DTEXTURE9 pTexZPos, - LPDIRECT3DTEXTURE9 pTexZNeg) PURE; - - STDMETHOD(Face)(THIS_ D3DCUBEMAP_FACES Face, DWORD MipFilter) PURE; - STDMETHOD(End)(THIS_ DWORD MipFilter) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateRenderToEnvMap( - LPDIRECT3DDEVICE9 pDevice, - UINT Size, - UINT MipLevels, - D3DFORMAT Format, - BOOL DepthStencil, - D3DFORMAT DepthStencilFormat, - LPD3DXRenderToEnvMap* ppRenderToEnvMap); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXLine: -// ------------ -// This object intends to provide an easy way to draw lines using D3D. -// -// Begin - -// Prepares device for drawing lines -// -// Draw - -// Draws a line strip in screen-space. -// Input is in the form of a array defining points on the line strip. of D3DXVECTOR2 -// -// DrawTransform - -// Draws a line in screen-space with a specified input transformation matrix. -// -// End - -// Restores device state to how it was when Begin was called. -// -// SetPattern - -// Applies a stipple pattern to the line. Input is one 32-bit -// DWORD which describes the stipple pattern. 1 is opaque, 0 is -// transparent. -// -// SetPatternScale - -// Stretches the stipple pattern in the u direction. Input is one -// floating-point value. 0.0f is no scaling, whereas 1.0f doubles -// the length of the stipple pattern. -// -// SetWidth - -// Specifies the thickness of the line in the v direction. Input is -// one floating-point value. -// -// SetAntialias - -// Toggles line antialiasing. Input is a BOOL. -// TRUE = Antialiasing on. -// FALSE = Antialiasing off. -// -// SetGLLines - -// Toggles non-antialiased OpenGL line emulation. Input is a BOOL. -// TRUE = OpenGL line emulation on. -// FALSE = OpenGL line emulation off. -// -// OpenGL line: Regular line: -// *\ *\ -// | \ / \ -// | \ *\ \ -// *\ \ \ \ -// \ \ \ \ -// \ * \ * -// \ | \ / -// \| * -// * -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// - - -typedef interface ID3DXLine ID3DXLine; -typedef interface ID3DXLine *LPD3DXLINE; - - -// {D379BA7F-9042-4ac4-9F5E-58192A4C6BD8} -DEFINE_GUID(IID_ID3DXLine, -0xd379ba7f, 0x9042, 0x4ac4, 0x9f, 0x5e, 0x58, 0x19, 0x2a, 0x4c, 0x6b, 0xd8); - -#undef INTERFACE -#define INTERFACE ID3DXLine - -DECLARE_INTERFACE_(ID3DXLine, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXLine - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - - STDMETHOD(Begin)(THIS) PURE; - - STDMETHOD(Draw)(THIS_ CONST D3DXVECTOR2 *pVertexList, - DWORD dwVertexListCount, D3DCOLOR Color) PURE; - - STDMETHOD(DrawTransform)(THIS_ CONST D3DXVECTOR3 *pVertexList, - DWORD dwVertexListCount, CONST D3DXMATRIX* pTransform, - D3DCOLOR Color) PURE; - - STDMETHOD(SetPattern)(THIS_ DWORD dwPattern) PURE; - STDMETHOD_(DWORD, GetPattern)(THIS) PURE; - - STDMETHOD(SetPatternScale)(THIS_ FLOAT fPatternScale) PURE; - STDMETHOD_(FLOAT, GetPatternScale)(THIS) PURE; - - STDMETHOD(SetWidth)(THIS_ FLOAT fWidth) PURE; - STDMETHOD_(FLOAT, GetWidth)(THIS) PURE; - - STDMETHOD(SetAntialias)(THIS_ BOOL bAntialias) PURE; - STDMETHOD_(BOOL, GetAntialias)(THIS) PURE; - - STDMETHOD(SetGLLines)(THIS_ BOOL bGLLines) PURE; - STDMETHOD_(BOOL, GetGLLines)(THIS) PURE; - - STDMETHOD(End)(THIS) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -HRESULT WINAPI - D3DXCreateLine( - LPDIRECT3DDEVICE9 pDevice, - LPD3DXLINE* ppLine); - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX9CORE_H__ - +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx9core.h +// Content: D3DX core types and functions +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx9.h" + +#ifndef __D3DX9CORE_H__ +#define __D3DX9CORE_H__ + + +/////////////////////////////////////////////////////////////////////////// +// D3DX_SDK_VERSION: +// ----------------- +// This identifier is passed to D3DXCheckVersion in order to ensure that an +// application was built against the correct header files and lib files. +// This number is incremented whenever a header (or other) change would +// require applications to be rebuilt. If the version doesn't match, +// D3DXCheckVersion will return FALSE. (The number itself has no meaning.) +/////////////////////////////////////////////////////////////////////////// + +#define D3DX_VERSION 0x0902 +#define D3DX_SDK_VERSION 30 + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +BOOL WINAPI + D3DXCheckVersion(UINT D3DSdkVersion, UINT D3DXSdkVersion); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// D3DXDebugMute +// Mutes D3DX and D3D debug spew (TRUE - mute, FALSE - not mute) +// +// returns previous mute value +// +/////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +BOOL WINAPI + D3DXDebugMute(BOOL Mute); + +#ifdef __cplusplus +} +#endif //__cplusplus + + +/////////////////////////////////////////////////////////////////////////// +// D3DXGetDriverLevel: +// Returns driver version information: +// +// 700 - DX7 level driver +// 800 - DX8 level driver +// 900 - DX9 level driver +/////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +UINT WINAPI + D3DXGetDriverLevel(LPDIRECT3DDEVICE9 pDevice); + +#ifdef __cplusplus +} +#endif //__cplusplus + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXBuffer: +// ------------ +// The buffer object is used by D3DX to return arbitrary size data. +// +// GetBufferPointer - +// Returns a pointer to the beginning of the buffer. +// +// GetBufferSize - +// Returns the size of the buffer, in bytes. +/////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXBuffer ID3DXBuffer; +typedef interface ID3DXBuffer *LPD3DXBUFFER; + +// {8BA5FB08-5195-40e2-AC58-0D989C3A0102} +DEFINE_GUID(IID_ID3DXBuffer, +0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2); + +#undef INTERFACE +#define INTERFACE ID3DXBuffer + +DECLARE_INTERFACE_(ID3DXBuffer, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBuffer + STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; + STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; +}; + + + +////////////////////////////////////////////////////////////////////////////// +// D3DXSPRITE flags: +// ----------------- +// D3DXSPRITE_DONOTSAVESTATE +// Specifies device state is not to be saved and restored in Begin/End. +// D3DXSPRITE_DONOTMODIFY_RENDERSTATE +// Specifies device render state is not to be changed in Begin. The device +// is assumed to be in a valid state to draw vertices containing POSITION0, +// TEXCOORD0, and COLOR0 data. +// D3DXSPRITE_OBJECTSPACE +// The WORLD, VIEW, and PROJECTION transforms are NOT modified. The +// transforms currently set to the device are used to transform the sprites +// when the batch is drawn (at Flush or End). If this is not specified, +// WORLD, VIEW, and PROJECTION transforms are modified so that sprites are +// drawn in screenspace coordinates. +// D3DXSPRITE_BILLBOARD +// Rotates each sprite about its center so that it is facing the viewer. +// D3DXSPRITE_ALPHABLEND +// Enables ALPHABLEND(SRCALPHA, INVSRCALPHA) and ALPHATEST(alpha > 0). +// ID3DXFont expects this to be set when drawing text. +// D3DXSPRITE_SORT_TEXTURE +// Sprites are sorted by texture prior to drawing. This is recommended when +// drawing non-overlapping sprites of uniform depth. For example, drawing +// screen-aligned text with ID3DXFont. +// D3DXSPRITE_SORT_DEPTH_FRONTTOBACK +// Sprites are sorted by depth front-to-back prior to drawing. This is +// recommended when drawing opaque sprites of varying depths. +// D3DXSPRITE_SORT_DEPTH_BACKTOFRONT +// Sprites are sorted by depth back-to-front prior to drawing. This is +// recommended when drawing transparent sprites of varying depths. +////////////////////////////////////////////////////////////////////////////// + +#define D3DXSPRITE_DONOTSAVESTATE (1 << 0) +#define D3DXSPRITE_DONOTMODIFY_RENDERSTATE (1 << 1) +#define D3DXSPRITE_OBJECTSPACE (1 << 2) +#define D3DXSPRITE_BILLBOARD (1 << 3) +#define D3DXSPRITE_ALPHABLEND (1 << 4) +#define D3DXSPRITE_SORT_TEXTURE (1 << 5) +#define D3DXSPRITE_SORT_DEPTH_FRONTTOBACK (1 << 6) +#define D3DXSPRITE_SORT_DEPTH_BACKTOFRONT (1 << 7) + + +////////////////////////////////////////////////////////////////////////////// +// ID3DXSprite: +// ------------ +// This object intends to provide an easy way to drawing sprites using D3D. +// +// Begin - +// Prepares device for drawing sprites. +// +// Draw - +// Draws a sprite. Before transformation, the sprite is the size of +// SrcRect, with its top-left corner specified by Position. The color +// and alpha channels are modulated by Color. +// +// Flush - +// Forces all batched sprites to submitted to the device. +// +// End - +// Restores device state to how it was when Begin was called. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXSprite ID3DXSprite; +typedef interface ID3DXSprite *LPD3DXSPRITE; + + +// {BA0B762D-7D28-43ec-B9DC-2F84443B0614} +DEFINE_GUID(IID_ID3DXSprite, +0xba0b762d, 0x7d28, 0x43ec, 0xb9, 0xdc, 0x2f, 0x84, 0x44, 0x3b, 0x6, 0x14); + + +#undef INTERFACE +#define INTERFACE ID3DXSprite + +DECLARE_INTERFACE_(ID3DXSprite, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXSprite + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; + + STDMETHOD(GetTransform)(THIS_ D3DXMATRIX *pTransform) PURE; + STDMETHOD(SetTransform)(THIS_ CONST D3DXMATRIX *pTransform) PURE; + + STDMETHOD(SetWorldViewRH)(THIS_ CONST D3DXMATRIX *pWorld, CONST D3DXMATRIX *pView) PURE; + STDMETHOD(SetWorldViewLH)(THIS_ CONST D3DXMATRIX *pWorld, CONST D3DXMATRIX *pView) PURE; + + STDMETHOD(Begin)(THIS_ DWORD Flags) PURE; + STDMETHOD(Draw)(THIS_ LPDIRECT3DTEXTURE9 pTexture, CONST RECT *pSrcRect, CONST D3DXVECTOR3 *pCenter, CONST D3DXVECTOR3 *pPosition, D3DCOLOR Color) PURE; + STDMETHOD(Flush)(THIS) PURE; + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateSprite( + LPDIRECT3DDEVICE9 pDevice, + LPD3DXSPRITE* ppSprite); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +////////////////////////////////////////////////////////////////////////////// +// ID3DXFont: +// ---------- +// Font objects contain the textures and resources needed to render a specific +// font on a specific device. +// +// GetGlyphData - +// Returns glyph cache data, for a given glyph. +// +// PreloadCharacters/PreloadGlyphs/PreloadText - +// Preloads glyphs into the glyph cache textures. +// +// DrawText - +// Draws formatted text on a D3D device. Some parameters are +// surprisingly similar to those of GDI's DrawText function. See GDI +// documentation for a detailed description of these parameters. +// If pSprite is NULL, an internal sprite object will be used. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +////////////////////////////////////////////////////////////////////////////// + +typedef struct _D3DXFONT_DESCA +{ + INT Height; + UINT Width; + UINT Weight; + UINT MipLevels; + BOOL Italic; + BYTE CharSet; + BYTE OutputPrecision; + BYTE Quality; + BYTE PitchAndFamily; + CHAR FaceName[LF_FACESIZE]; + +} D3DXFONT_DESCA, *LPD3DXFONT_DESCA; + +typedef struct _D3DXFONT_DESCW +{ + INT Height; + UINT Width; + UINT Weight; + UINT MipLevels; + BOOL Italic; + BYTE CharSet; + BYTE OutputPrecision; + BYTE Quality; + BYTE PitchAndFamily; + WCHAR FaceName[LF_FACESIZE]; + +} D3DXFONT_DESCW, *LPD3DXFONT_DESCW; + +#ifdef UNICODE +typedef D3DXFONT_DESCW D3DXFONT_DESC; +typedef LPD3DXFONT_DESCW LPD3DXFONT_DESC; +#else +typedef D3DXFONT_DESCA D3DXFONT_DESC; +typedef LPD3DXFONT_DESCA LPD3DXFONT_DESC; +#endif + + +typedef interface ID3DXFont ID3DXFont; +typedef interface ID3DXFont *LPD3DXFONT; + + +// {D79DBB70-5F21-4d36-BBC2-FF525C213CDC} +DEFINE_GUID(IID_ID3DXFont, +0xd79dbb70, 0x5f21, 0x4d36, 0xbb, 0xc2, 0xff, 0x52, 0x5c, 0x21, 0x3c, 0xdc); + + +#undef INTERFACE +#define INTERFACE ID3DXFont + +DECLARE_INTERFACE_(ID3DXFont, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXFont + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9 *ppDevice) PURE; + STDMETHOD(GetDescA)(THIS_ D3DXFONT_DESCA *pDesc) PURE; + STDMETHOD(GetDescW)(THIS_ D3DXFONT_DESCW *pDesc) PURE; + STDMETHOD_(BOOL, GetTextMetricsA)(THIS_ TEXTMETRICA *pTextMetrics) PURE; + STDMETHOD_(BOOL, GetTextMetricsW)(THIS_ TEXTMETRICW *pTextMetrics) PURE; + + STDMETHOD_(HDC, GetDC)(THIS) PURE; + STDMETHOD(GetGlyphData)(THIS_ UINT Glyph, LPDIRECT3DTEXTURE9 *ppTexture, RECT *pBlackBox, POINT *pCellInc) PURE; + + STDMETHOD(PreloadCharacters)(THIS_ UINT First, UINT Last) PURE; + STDMETHOD(PreloadGlyphs)(THIS_ UINT First, UINT Last) PURE; + STDMETHOD(PreloadTextA)(THIS_ LPCSTR pString, INT Count) PURE; + STDMETHOD(PreloadTextW)(THIS_ LPCWSTR pString, INT Count) PURE; + + STDMETHOD_(INT, DrawTextA)(THIS_ LPD3DXSPRITE pSprite, LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; + STDMETHOD_(INT, DrawTextW)(THIS_ LPD3DXSPRITE pSprite, LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; + +#ifdef __cplusplus +#ifdef UNICODE + HRESULT GetDesc(D3DXFONT_DESCW *pDesc) { return GetDescW(pDesc); } + HRESULT PreloadText(LPCWSTR pString, INT Count) { return PreloadTextW(pString, Count); } +#else + HRESULT GetDesc(D3DXFONT_DESCA *pDesc) { return GetDescA(pDesc); } + HRESULT PreloadText(LPCSTR pString, INT Count) { return PreloadTextA(pString, Count); } +#endif +#endif //__cplusplus +}; + +#ifndef GetTextMetrics +#ifdef UNICODE +#define GetTextMetrics GetTextMetricsW +#else +#define GetTextMetrics GetTextMetricsA +#endif +#endif + +#ifndef DrawText +#ifdef UNICODE +#define DrawText DrawTextW +#else +#define DrawText DrawTextA +#endif +#endif + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +HRESULT WINAPI + D3DXCreateFontA( + LPDIRECT3DDEVICE9 pDevice, + INT Height, + UINT Width, + UINT Weight, + UINT MipLevels, + BOOL Italic, + DWORD CharSet, + DWORD OutputPrecision, + DWORD Quality, + DWORD PitchAndFamily, + LPCSTR pFaceName, + LPD3DXFONT* ppFont); + +HRESULT WINAPI + D3DXCreateFontW( + LPDIRECT3DDEVICE9 pDevice, + INT Height, + UINT Width, + UINT Weight, + UINT MipLevels, + BOOL Italic, + DWORD CharSet, + DWORD OutputPrecision, + DWORD Quality, + DWORD PitchAndFamily, + LPCWSTR pFaceName, + LPD3DXFONT* ppFont); + +#ifdef UNICODE +#define D3DXCreateFont D3DXCreateFontW +#else +#define D3DXCreateFont D3DXCreateFontA +#endif + + +HRESULT WINAPI + D3DXCreateFontIndirectA( + LPDIRECT3DDEVICE9 pDevice, + CONST D3DXFONT_DESCA* pDesc, + LPD3DXFONT* ppFont); + +HRESULT WINAPI + D3DXCreateFontIndirectW( + LPDIRECT3DDEVICE9 pDevice, + CONST D3DXFONT_DESCW* pDesc, + LPD3DXFONT* ppFont); + +#ifdef UNICODE +#define D3DXCreateFontIndirect D3DXCreateFontIndirectW +#else +#define D3DXCreateFontIndirect D3DXCreateFontIndirectA +#endif + + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXRenderToSurface: +// --------------------- +// This object abstracts rendering to surfaces. These surfaces do not +// necessarily need to be render targets. If they are not, a compatible +// render target is used, and the result copied into surface at end scene. +// +// BeginScene, EndScene - +// Call BeginScene() and EndScene() at the beginning and ending of your +// scene. These calls will setup and restore render targets, viewports, +// etc.. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + +typedef struct _D3DXRTS_DESC +{ + UINT Width; + UINT Height; + D3DFORMAT Format; + BOOL DepthStencil; + D3DFORMAT DepthStencilFormat; + +} D3DXRTS_DESC, *LPD3DXRTS_DESC; + + +typedef interface ID3DXRenderToSurface ID3DXRenderToSurface; +typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE; + + +// {6985F346-2C3D-43b3-BE8B-DAAE8A03D894} +DEFINE_GUID(IID_ID3DXRenderToSurface, +0x6985f346, 0x2c3d, 0x43b3, 0xbe, 0x8b, 0xda, 0xae, 0x8a, 0x3, 0xd8, 0x94); + + +#undef INTERFACE +#define INTERFACE ID3DXRenderToSurface + +DECLARE_INTERFACE_(ID3DXRenderToSurface, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXRenderToSurface + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; + STDMETHOD(GetDesc)(THIS_ D3DXRTS_DESC* pDesc) PURE; + + STDMETHOD(BeginScene)(THIS_ LPDIRECT3DSURFACE9 pSurface, CONST D3DVIEWPORT9* pViewport) PURE; + STDMETHOD(EndScene)(THIS_ DWORD MipFilter) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateRenderToSurface( + LPDIRECT3DDEVICE9 pDevice, + UINT Width, + UINT Height, + D3DFORMAT Format, + BOOL DepthStencil, + D3DFORMAT DepthStencilFormat, + LPD3DXRENDERTOSURFACE* ppRenderToSurface); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXRenderToEnvMap: +// -------------------- +// This object abstracts rendering to environment maps. These surfaces +// do not necessarily need to be render targets. If they are not, a +// compatible render target is used, and the result copied into the +// environment map at end scene. +// +// BeginCube, BeginSphere, BeginHemisphere, BeginParabolic - +// This function initiates the rendering of the environment map. As +// parameters, you pass the textures in which will get filled in with +// the resulting environment map. +// +// Face - +// Call this function to initiate the drawing of each face. For each +// environment map, you will call this six times.. once for each face +// in D3DCUBEMAP_FACES. +// +// End - +// This will restore all render targets, and if needed compose all the +// rendered faces into the environment map surfaces. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + +typedef struct _D3DXRTE_DESC +{ + UINT Size; + UINT MipLevels; + D3DFORMAT Format; + BOOL DepthStencil; + D3DFORMAT DepthStencilFormat; + +} D3DXRTE_DESC, *LPD3DXRTE_DESC; + + +typedef interface ID3DXRenderToEnvMap ID3DXRenderToEnvMap; +typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap; + + +// {313F1B4B-C7B0-4fa2-9D9D-8D380B64385E} +DEFINE_GUID(IID_ID3DXRenderToEnvMap, +0x313f1b4b, 0xc7b0, 0x4fa2, 0x9d, 0x9d, 0x8d, 0x38, 0xb, 0x64, 0x38, 0x5e); + + +#undef INTERFACE +#define INTERFACE ID3DXRenderToEnvMap + +DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXRenderToEnvMap + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; + STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE; + + STDMETHOD(BeginCube)(THIS_ + LPDIRECT3DCUBETEXTURE9 pCubeTex) PURE; + + STDMETHOD(BeginSphere)(THIS_ + LPDIRECT3DTEXTURE9 pTex) PURE; + + STDMETHOD(BeginHemisphere)(THIS_ + LPDIRECT3DTEXTURE9 pTexZPos, + LPDIRECT3DTEXTURE9 pTexZNeg) PURE; + + STDMETHOD(BeginParabolic)(THIS_ + LPDIRECT3DTEXTURE9 pTexZPos, + LPDIRECT3DTEXTURE9 pTexZNeg) PURE; + + STDMETHOD(Face)(THIS_ D3DCUBEMAP_FACES Face, DWORD MipFilter) PURE; + STDMETHOD(End)(THIS_ DWORD MipFilter) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateRenderToEnvMap( + LPDIRECT3DDEVICE9 pDevice, + UINT Size, + UINT MipLevels, + D3DFORMAT Format, + BOOL DepthStencil, + D3DFORMAT DepthStencilFormat, + LPD3DXRenderToEnvMap* ppRenderToEnvMap); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXLine: +// ------------ +// This object intends to provide an easy way to draw lines using D3D. +// +// Begin - +// Prepares device for drawing lines +// +// Draw - +// Draws a line strip in screen-space. +// Input is in the form of a array defining points on the line strip. of D3DXVECTOR2 +// +// DrawTransform - +// Draws a line in screen-space with a specified input transformation matrix. +// +// End - +// Restores device state to how it was when Begin was called. +// +// SetPattern - +// Applies a stipple pattern to the line. Input is one 32-bit +// DWORD which describes the stipple pattern. 1 is opaque, 0 is +// transparent. +// +// SetPatternScale - +// Stretches the stipple pattern in the u direction. Input is one +// floating-point value. 0.0f is no scaling, whereas 1.0f doubles +// the length of the stipple pattern. +// +// SetWidth - +// Specifies the thickness of the line in the v direction. Input is +// one floating-point value. +// +// SetAntialias - +// Toggles line antialiasing. Input is a BOOL. +// TRUE = Antialiasing on. +// FALSE = Antialiasing off. +// +// SetGLLines - +// Toggles non-antialiased OpenGL line emulation. Input is a BOOL. +// TRUE = OpenGL line emulation on. +// FALSE = OpenGL line emulation off. +// +// OpenGL line: Regular line: +// *\ *\ +// | \ / \ +// | \ *\ \ +// *\ \ \ \ +// \ \ \ \ +// \ * \ * +// \ | \ / +// \| * +// * +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + + +typedef interface ID3DXLine ID3DXLine; +typedef interface ID3DXLine *LPD3DXLINE; + + +// {D379BA7F-9042-4ac4-9F5E-58192A4C6BD8} +DEFINE_GUID(IID_ID3DXLine, +0xd379ba7f, 0x9042, 0x4ac4, 0x9f, 0x5e, 0x58, 0x19, 0x2a, 0x4c, 0x6b, 0xd8); + +#undef INTERFACE +#define INTERFACE ID3DXLine + +DECLARE_INTERFACE_(ID3DXLine, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXLine + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; + + STDMETHOD(Begin)(THIS) PURE; + + STDMETHOD(Draw)(THIS_ CONST D3DXVECTOR2 *pVertexList, + DWORD dwVertexListCount, D3DCOLOR Color) PURE; + + STDMETHOD(DrawTransform)(THIS_ CONST D3DXVECTOR3 *pVertexList, + DWORD dwVertexListCount, CONST D3DXMATRIX* pTransform, + D3DCOLOR Color) PURE; + + STDMETHOD(SetPattern)(THIS_ DWORD dwPattern) PURE; + STDMETHOD_(DWORD, GetPattern)(THIS) PURE; + + STDMETHOD(SetPatternScale)(THIS_ FLOAT fPatternScale) PURE; + STDMETHOD_(FLOAT, GetPatternScale)(THIS) PURE; + + STDMETHOD(SetWidth)(THIS_ FLOAT fWidth) PURE; + STDMETHOD_(FLOAT, GetWidth)(THIS) PURE; + + STDMETHOD(SetAntialias)(THIS_ BOOL bAntialias) PURE; + STDMETHOD_(BOOL, GetAntialias)(THIS) PURE; + + STDMETHOD(SetGLLines)(THIS_ BOOL bGLLines) PURE; + STDMETHOD_(BOOL, GetGLLines)(THIS) PURE; + + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +HRESULT WINAPI + D3DXCreateLine( + LPDIRECT3DDEVICE9 pDevice, + LPD3DXLINE* ppLine); + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX9CORE_H__ + diff --git a/src/dep/include/DXSDK/include/d3dx9effect.h b/src/dep/include/DXSDK/include/d3dx9effect.h index dd896ce..6af6d47 100644 --- a/src/dep/include/DXSDK/include/d3dx9effect.h +++ b/src/dep/include/DXSDK/include/d3dx9effect.h @@ -1,871 +1,871 @@ - -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// File: d3dx9effect.h -// Content: D3DX effect types and Shaders -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx9.h" - -#ifndef __D3DX9EFFECT_H__ -#define __D3DX9EFFECT_H__ - - -//---------------------------------------------------------------------------- -// D3DXFX_DONOTSAVESTATE -// This flag is used as a parameter to ID3DXEffect::Begin(). When this flag -// is specified, device state is not saved or restored in Begin/End. -// D3DXFX_DONOTSAVESHADERSTATE -// This flag is used as a parameter to ID3DXEffect::Begin(). When this flag -// is specified, shader device state is not saved or restored in Begin/End. -// This includes pixel/vertex shaders and shader constants -// D3DXFX_DONOTSAVESAMPLERSTATE -// This flag is used as a parameter to ID3DXEffect::Begin(). When this flag -// is specified, sampler device state is not saved or restored in Begin/End. -// D3DXFX_NOT_CLONEABLE -// This flag is used as a parameter to the D3DXCreateEffect family of APIs. -// When this flag is specified, the effect will be non-cloneable and will not -// contain any shader binary data. -// Furthermore, GetPassDesc will not return shader function pointers. -// Setting this flag reduces effect memory usage by about 50%. -//---------------------------------------------------------------------------- - -#define D3DXFX_DONOTSAVESTATE (1 << 0) -#define D3DXFX_DONOTSAVESHADERSTATE (1 << 1) -#define D3DXFX_DONOTSAVESAMPLERSTATE (1 << 2) -#define D3DXFX_NOT_CLONEABLE (1 << 11) - -//---------------------------------------------------------------------------- -// D3DX_PARAMETER_SHARED -// Indicates that the value of a parameter will be shared with all effects -// which share the same namespace. Changing the value in one effect will -// change it in all. -// -// D3DX_PARAMETER_LITERAL -// Indicates that the value of this parameter can be treated as literal. -// Literal parameters can be marked when the effect is compiled, and their -// cannot be changed after the effect is compiled. Shared parameters cannot -// be literal. -//---------------------------------------------------------------------------- - -#define D3DX_PARAMETER_SHARED (1 << 0) -#define D3DX_PARAMETER_LITERAL (1 << 1) -#define D3DX_PARAMETER_ANNOTATION (1 << 2) - -//---------------------------------------------------------------------------- -// D3DXEFFECT_DESC: -//---------------------------------------------------------------------------- - -typedef struct _D3DXEFFECT_DESC -{ - LPCSTR Creator; // Creator string - UINT Parameters; // Number of parameters - UINT Techniques; // Number of techniques - UINT Functions; // Number of function entrypoints - -} D3DXEFFECT_DESC; - - -//---------------------------------------------------------------------------- -// D3DXPARAMETER_DESC: -//---------------------------------------------------------------------------- - -typedef struct _D3DXPARAMETER_DESC -{ - LPCSTR Name; // Parameter name - LPCSTR Semantic; // Parameter semantic - D3DXPARAMETER_CLASS Class; // Class - D3DXPARAMETER_TYPE Type; // Component type - UINT Rows; // Number of rows - UINT Columns; // Number of columns - UINT Elements; // Number of array elements - UINT Annotations; // Number of annotations - UINT StructMembers; // Number of structure member sub-parameters - DWORD Flags; // D3DX_PARAMETER_* flags - UINT Bytes; // Parameter size, in bytes - -} D3DXPARAMETER_DESC; - - -//---------------------------------------------------------------------------- -// D3DXTECHNIQUE_DESC: -//---------------------------------------------------------------------------- - -typedef struct _D3DXTECHNIQUE_DESC -{ - LPCSTR Name; // Technique name - UINT Passes; // Number of passes - UINT Annotations; // Number of annotations - -} D3DXTECHNIQUE_DESC; - - -//---------------------------------------------------------------------------- -// D3DXPASS_DESC: -//---------------------------------------------------------------------------- - -typedef struct _D3DXPASS_DESC -{ - LPCSTR Name; // Pass name - UINT Annotations; // Number of annotations - - CONST DWORD *pVertexShaderFunction; // Vertex shader function - CONST DWORD *pPixelShaderFunction; // Pixel shader function - -} D3DXPASS_DESC; - - -//---------------------------------------------------------------------------- -// D3DXFUNCTION_DESC: -//---------------------------------------------------------------------------- - -typedef struct _D3DXFUNCTION_DESC -{ - LPCSTR Name; // Function name - UINT Annotations; // Number of annotations - -} D3DXFUNCTION_DESC; - - - -////////////////////////////////////////////////////////////////////////////// -// ID3DXEffectPool /////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXEffectPool ID3DXEffectPool; -typedef interface ID3DXEffectPool *LPD3DXEFFECTPOOL; - -// {9537AB04-3250-412e-8213-FCD2F8677933} -DEFINE_GUID(IID_ID3DXEffectPool, -0x9537ab04, 0x3250, 0x412e, 0x82, 0x13, 0xfc, 0xd2, 0xf8, 0x67, 0x79, 0x33); - - -#undef INTERFACE -#define INTERFACE ID3DXEffectPool - -DECLARE_INTERFACE_(ID3DXEffectPool, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // No public methods -}; - - -////////////////////////////////////////////////////////////////////////////// -// ID3DXBaseEffect /////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXBaseEffect ID3DXBaseEffect; -typedef interface ID3DXBaseEffect *LPD3DXBASEEFFECT; - -// {017C18AC-103F-4417-8C51-6BF6EF1E56BE} -DEFINE_GUID(IID_ID3DXBaseEffect, -0x17c18ac, 0x103f, 0x4417, 0x8c, 0x51, 0x6b, 0xf6, 0xef, 0x1e, 0x56, 0xbe); - - -#undef INTERFACE -#define INTERFACE ID3DXBaseEffect - -DECLARE_INTERFACE_(ID3DXBaseEffect, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // Descs - STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; - STDMETHOD(GetParameterDesc)(THIS_ D3DXHANDLE hParameter, D3DXPARAMETER_DESC* pDesc) PURE; - STDMETHOD(GetTechniqueDesc)(THIS_ D3DXHANDLE hTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; - STDMETHOD(GetPassDesc)(THIS_ D3DXHANDLE hPass, D3DXPASS_DESC* pDesc) PURE; - STDMETHOD(GetFunctionDesc)(THIS_ D3DXHANDLE hShader, D3DXFUNCTION_DESC* pDesc) PURE; - - // Handle operations - STDMETHOD_(D3DXHANDLE, GetParameter)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetParameterByName)(THIS_ D3DXHANDLE hParameter, LPCSTR pName) PURE; - STDMETHOD_(D3DXHANDLE, GetParameterBySemantic)(THIS_ D3DXHANDLE hParameter, LPCSTR pSemantic) PURE; - STDMETHOD_(D3DXHANDLE, GetParameterElement)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetTechnique)(THIS_ UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetTechniqueByName)(THIS_ LPCSTR pName) PURE; - STDMETHOD_(D3DXHANDLE, GetPass)(THIS_ D3DXHANDLE hTechnique, UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetPassByName)(THIS_ D3DXHANDLE hTechnique, LPCSTR pName) PURE; - STDMETHOD_(D3DXHANDLE, GetFunction)(THIS_ UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetFunctionByName)(THIS_ LPCSTR pName) PURE; - STDMETHOD_(D3DXHANDLE, GetAnnotation)(THIS_ D3DXHANDLE hObject, UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetAnnotationByName)(THIS_ D3DXHANDLE hObject, LPCSTR pName) PURE; - - // Get/Set Parameters - STDMETHOD(SetValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT Bytes) PURE; - STDMETHOD(GetValue)(THIS_ D3DXHANDLE hParameter, LPVOID pData, UINT Bytes) PURE; - STDMETHOD(SetBool)(THIS_ D3DXHANDLE hParameter, BOOL b) PURE; - STDMETHOD(GetBool)(THIS_ D3DXHANDLE hParameter, BOOL* pb) PURE; - STDMETHOD(SetBoolArray)(THIS_ D3DXHANDLE hParameter, CONST BOOL* pb, UINT Count) PURE; - STDMETHOD(GetBoolArray)(THIS_ D3DXHANDLE hParameter, BOOL* pb, UINT Count) PURE; - STDMETHOD(SetInt)(THIS_ D3DXHANDLE hParameter, INT n) PURE; - STDMETHOD(GetInt)(THIS_ D3DXHANDLE hParameter, INT* pn) PURE; - STDMETHOD(SetIntArray)(THIS_ D3DXHANDLE hParameter, CONST INT* pn, UINT Count) PURE; - STDMETHOD(GetIntArray)(THIS_ D3DXHANDLE hParameter, INT* pn, UINT Count) PURE; - STDMETHOD(SetFloat)(THIS_ D3DXHANDLE hParameter, FLOAT f) PURE; - STDMETHOD(GetFloat)(THIS_ D3DXHANDLE hParameter, FLOAT* pf) PURE; - STDMETHOD(SetFloatArray)(THIS_ D3DXHANDLE hParameter, CONST FLOAT* pf, UINT Count) PURE; - STDMETHOD(GetFloatArray)(THIS_ D3DXHANDLE hParameter, FLOAT* pf, UINT Count) PURE; - STDMETHOD(SetVector)(THIS_ D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector) PURE; - STDMETHOD(GetVector)(THIS_ D3DXHANDLE hParameter, D3DXVECTOR4* pVector) PURE; - STDMETHOD(SetVectorArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector, UINT Count) PURE; - STDMETHOD(GetVectorArray)(THIS_ D3DXHANDLE hParameter, D3DXVECTOR4* pVector, UINT Count) PURE; - STDMETHOD(SetMatrix)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix) PURE; - STDMETHOD(GetMatrix)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix) PURE; - STDMETHOD(SetMatrixArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(GetMatrixArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixPointerArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; - STDMETHOD(GetMatrixPointerArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixTranspose)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix) PURE; - STDMETHOD(GetMatrixTranspose)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix) PURE; - STDMETHOD(SetMatrixTransposeArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(GetMatrixTransposeArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; - STDMETHOD(GetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count) PURE; - STDMETHOD(SetString)(THIS_ D3DXHANDLE hParameter, LPCSTR pString) PURE; - STDMETHOD(GetString)(THIS_ D3DXHANDLE hParameter, LPCSTR* ppString) PURE; - STDMETHOD(SetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 pTexture) PURE; - STDMETHOD(GetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 *ppTexture) PURE; - STDMETHOD(GetPixelShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9 *ppPShader) PURE; - STDMETHOD(GetVertexShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DVERTEXSHADER9 *ppVShader) PURE; - - //Set Range of an Array to pass to device - //Useful for sending only a subrange of an array down to the device - STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; - -}; - - -//---------------------------------------------------------------------------- -// ID3DXEffectStateManager: -// ------------------------ -// This is a user implemented interface that can be used to manage device -// state changes made by an Effect. -//---------------------------------------------------------------------------- - -typedef interface ID3DXEffectStateManager ID3DXEffectStateManager; -typedef interface ID3DXEffectStateManager *LPD3DXEFFECTSTATEMANAGER; - -// {79AAB587-6DBC-4fa7-82DE-37FA1781C5CE} -DEFINE_GUID(IID_ID3DXEffectStateManager, -0x79aab587, 0x6dbc, 0x4fa7, 0x82, 0xde, 0x37, 0xfa, 0x17, 0x81, 0xc5, 0xce); - -#undef INTERFACE -#define INTERFACE ID3DXEffectStateManager - -DECLARE_INTERFACE_(ID3DXEffectStateManager, IUnknown) -{ - // The user must correctly implement QueryInterface, AddRef, and Release. - - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // The following methods are called by the Effect when it wants to make - // the corresponding device call. Note that: - // 1. Users manage the state and are therefore responsible for making the - // the corresponding device calls themselves inside their callbacks. - // 2. Effects pay attention to the return values of the callbacks, and so - // users must pay attention to what they return in their callbacks. - - STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX *pMatrix) PURE; - STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL9 *pMaterial) PURE; - STDMETHOD(SetLight)(THIS_ DWORD Index, CONST D3DLIGHT9 *pLight) PURE; - STDMETHOD(LightEnable)(THIS_ DWORD Index, BOOL Enable) PURE; - STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State, DWORD Value) PURE; - STDMETHOD(SetTexture)(THIS_ DWORD Stage, LPDIRECT3DBASETEXTURE9 pTexture) PURE; - STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) PURE; - STDMETHOD(SetSamplerState)(THIS_ DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) PURE; - STDMETHOD(SetNPatchMode)(THIS_ FLOAT NumSegments) PURE; - STDMETHOD(SetFVF)(THIS_ DWORD FVF) PURE; - STDMETHOD(SetVertexShader)(THIS_ LPDIRECT3DVERTEXSHADER9 pShader) PURE; - STDMETHOD(SetVertexShaderConstantF)(THIS_ UINT RegisterIndex, CONST FLOAT *pConstantData, UINT RegisterCount) PURE; - STDMETHOD(SetVertexShaderConstantI)(THIS_ UINT RegisterIndex, CONST INT *pConstantData, UINT RegisterCount) PURE; - STDMETHOD(SetVertexShaderConstantB)(THIS_ UINT RegisterIndex, CONST BOOL *pConstantData, UINT RegisterCount) PURE; - STDMETHOD(SetPixelShader)(THIS_ LPDIRECT3DPIXELSHADER9 pShader) PURE; - STDMETHOD(SetPixelShaderConstantF)(THIS_ UINT RegisterIndex, CONST FLOAT *pConstantData, UINT RegisterCount) PURE; - STDMETHOD(SetPixelShaderConstantI)(THIS_ UINT RegisterIndex, CONST INT *pConstantData, UINT RegisterCount) PURE; - STDMETHOD(SetPixelShaderConstantB)(THIS_ UINT RegisterIndex, CONST BOOL *pConstantData, UINT RegisterCount) PURE; -}; - - -////////////////////////////////////////////////////////////////////////////// -// ID3DXEffect /////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXEffect ID3DXEffect; -typedef interface ID3DXEffect *LPD3DXEFFECT; - -// {F6CEB4B3-4E4C-40dd-B883-8D8DE5EA0CD5} -DEFINE_GUID(IID_ID3DXEffect, -0xf6ceb4b3, 0x4e4c, 0x40dd, 0xb8, 0x83, 0x8d, 0x8d, 0xe5, 0xea, 0xc, 0xd5); - -#undef INTERFACE -#define INTERFACE ID3DXEffect - -DECLARE_INTERFACE_(ID3DXEffect, ID3DXBaseEffect) -{ - // ID3DXBaseEffect - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // Descs - STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; - STDMETHOD(GetParameterDesc)(THIS_ D3DXHANDLE hParameter, D3DXPARAMETER_DESC* pDesc) PURE; - STDMETHOD(GetTechniqueDesc)(THIS_ D3DXHANDLE hTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; - STDMETHOD(GetPassDesc)(THIS_ D3DXHANDLE hPass, D3DXPASS_DESC* pDesc) PURE; - STDMETHOD(GetFunctionDesc)(THIS_ D3DXHANDLE hShader, D3DXFUNCTION_DESC* pDesc) PURE; - - // Handle operations - STDMETHOD_(D3DXHANDLE, GetParameter)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetParameterByName)(THIS_ D3DXHANDLE hParameter, LPCSTR pName) PURE; - STDMETHOD_(D3DXHANDLE, GetParameterBySemantic)(THIS_ D3DXHANDLE hParameter, LPCSTR pSemantic) PURE; - STDMETHOD_(D3DXHANDLE, GetParameterElement)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetTechnique)(THIS_ UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetTechniqueByName)(THIS_ LPCSTR pName) PURE; - STDMETHOD_(D3DXHANDLE, GetPass)(THIS_ D3DXHANDLE hTechnique, UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetPassByName)(THIS_ D3DXHANDLE hTechnique, LPCSTR pName) PURE; - STDMETHOD_(D3DXHANDLE, GetFunction)(THIS_ UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetFunctionByName)(THIS_ LPCSTR pName) PURE; - STDMETHOD_(D3DXHANDLE, GetAnnotation)(THIS_ D3DXHANDLE hObject, UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetAnnotationByName)(THIS_ D3DXHANDLE hObject, LPCSTR pName) PURE; - - // Get/Set Parameters - STDMETHOD(SetValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT Bytes) PURE; - STDMETHOD(GetValue)(THIS_ D3DXHANDLE hParameter, LPVOID pData, UINT Bytes) PURE; - STDMETHOD(SetBool)(THIS_ D3DXHANDLE hParameter, BOOL b) PURE; - STDMETHOD(GetBool)(THIS_ D3DXHANDLE hParameter, BOOL* pb) PURE; - STDMETHOD(SetBoolArray)(THIS_ D3DXHANDLE hParameter, CONST BOOL* pb, UINT Count) PURE; - STDMETHOD(GetBoolArray)(THIS_ D3DXHANDLE hParameter, BOOL* pb, UINT Count) PURE; - STDMETHOD(SetInt)(THIS_ D3DXHANDLE hParameter, INT n) PURE; - STDMETHOD(GetInt)(THIS_ D3DXHANDLE hParameter, INT* pn) PURE; - STDMETHOD(SetIntArray)(THIS_ D3DXHANDLE hParameter, CONST INT* pn, UINT Count) PURE; - STDMETHOD(GetIntArray)(THIS_ D3DXHANDLE hParameter, INT* pn, UINT Count) PURE; - STDMETHOD(SetFloat)(THIS_ D3DXHANDLE hParameter, FLOAT f) PURE; - STDMETHOD(GetFloat)(THIS_ D3DXHANDLE hParameter, FLOAT* pf) PURE; - STDMETHOD(SetFloatArray)(THIS_ D3DXHANDLE hParameter, CONST FLOAT* pf, UINT Count) PURE; - STDMETHOD(GetFloatArray)(THIS_ D3DXHANDLE hParameter, FLOAT* pf, UINT Count) PURE; - STDMETHOD(SetVector)(THIS_ D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector) PURE; - STDMETHOD(GetVector)(THIS_ D3DXHANDLE hParameter, D3DXVECTOR4* pVector) PURE; - STDMETHOD(SetVectorArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector, UINT Count) PURE; - STDMETHOD(GetVectorArray)(THIS_ D3DXHANDLE hParameter, D3DXVECTOR4* pVector, UINT Count) PURE; - STDMETHOD(SetMatrix)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix) PURE; - STDMETHOD(GetMatrix)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix) PURE; - STDMETHOD(SetMatrixArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(GetMatrixArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixPointerArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; - STDMETHOD(GetMatrixPointerArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixTranspose)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix) PURE; - STDMETHOD(GetMatrixTranspose)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix) PURE; - STDMETHOD(SetMatrixTransposeArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(GetMatrixTransposeArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; - STDMETHOD(GetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count) PURE; - STDMETHOD(SetString)(THIS_ D3DXHANDLE hParameter, LPCSTR pString) PURE; - STDMETHOD(GetString)(THIS_ D3DXHANDLE hParameter, LPCSTR* ppString) PURE; - STDMETHOD(SetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 pTexture) PURE; - STDMETHOD(GetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 *ppTexture) PURE; - STDMETHOD(GetPixelShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9 *ppPShader) PURE; - STDMETHOD(GetVertexShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DVERTEXSHADER9 *ppVShader) PURE; - - //Set Range of an Array to pass to device - //Usefull for sending only a subrange of an array down to the device - STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; - // ID3DXBaseEffect - - - // Pool - STDMETHOD(GetPool)(THIS_ LPD3DXEFFECTPOOL* ppPool) PURE; - - // Selecting and setting a technique - STDMETHOD(SetTechnique)(THIS_ D3DXHANDLE hTechnique) PURE; - STDMETHOD_(D3DXHANDLE, GetCurrentTechnique)(THIS) PURE; - STDMETHOD(ValidateTechnique)(THIS_ D3DXHANDLE hTechnique) PURE; - STDMETHOD(FindNextValidTechnique)(THIS_ D3DXHANDLE hTechnique, D3DXHANDLE *pTechnique) PURE; - STDMETHOD_(BOOL, IsParameterUsed)(THIS_ D3DXHANDLE hParameter, D3DXHANDLE hTechnique) PURE; - - // Using current technique - // Begin starts active technique - // BeginPass begins a pass - // CommitChanges updates changes to any set calls in the pass. This should be called before - // any DrawPrimitive call to d3d - // EndPass ends a pass - // End ends active technique - STDMETHOD(Begin)(THIS_ UINT *pPasses, DWORD Flags) PURE; - STDMETHOD(BeginPass)(THIS_ UINT Pass) PURE; - STDMETHOD(CommitChanges)(THIS) PURE; - STDMETHOD(EndPass)(THIS) PURE; - STDMETHOD(End)(THIS) PURE; - - // Managing D3D Device - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; - - // Logging device calls - STDMETHOD(SetStateManager)(THIS_ LPD3DXEFFECTSTATEMANAGER pManager) PURE; - STDMETHOD(GetStateManager)(THIS_ LPD3DXEFFECTSTATEMANAGER *ppManager) PURE; - - // Parameter blocks - STDMETHOD(BeginParameterBlock)(THIS) PURE; - STDMETHOD_(D3DXHANDLE, EndParameterBlock)(THIS) PURE; - STDMETHOD(ApplyParameterBlock)(THIS_ D3DXHANDLE hParameterBlock) PURE; - STDMETHOD(DeleteParameterBlock)(THIS_ D3DXHANDLE hParameterBlock) PURE; - - // Cloning - STDMETHOD(CloneEffect)(THIS_ LPDIRECT3DDEVICE9 pDevice, LPD3DXEFFECT* ppEffect) PURE; - - // Fast path for setting variables directly in ID3DXEffect - STDMETHOD(SetRawValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT ByteOffset, UINT Bytes) PURE; -}; - - -////////////////////////////////////////////////////////////////////////////// -// ID3DXEffectCompiler /////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXEffectCompiler ID3DXEffectCompiler; -typedef interface ID3DXEffectCompiler *LPD3DXEFFECTCOMPILER; - -// {51B8A949-1A31-47e6-BEA0-4B30DB53F1E0} -DEFINE_GUID(IID_ID3DXEffectCompiler, -0x51b8a949, 0x1a31, 0x47e6, 0xbe, 0xa0, 0x4b, 0x30, 0xdb, 0x53, 0xf1, 0xe0); - - -#undef INTERFACE -#define INTERFACE ID3DXEffectCompiler - -DECLARE_INTERFACE_(ID3DXEffectCompiler, ID3DXBaseEffect) -{ - // ID3DXBaseEffect - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // Descs - STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; - STDMETHOD(GetParameterDesc)(THIS_ D3DXHANDLE hParameter, D3DXPARAMETER_DESC* pDesc) PURE; - STDMETHOD(GetTechniqueDesc)(THIS_ D3DXHANDLE hTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; - STDMETHOD(GetPassDesc)(THIS_ D3DXHANDLE hPass, D3DXPASS_DESC* pDesc) PURE; - STDMETHOD(GetFunctionDesc)(THIS_ D3DXHANDLE hShader, D3DXFUNCTION_DESC* pDesc) PURE; - - // Handle operations - STDMETHOD_(D3DXHANDLE, GetParameter)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetParameterByName)(THIS_ D3DXHANDLE hParameter, LPCSTR pName) PURE; - STDMETHOD_(D3DXHANDLE, GetParameterBySemantic)(THIS_ D3DXHANDLE hParameter, LPCSTR pSemantic) PURE; - STDMETHOD_(D3DXHANDLE, GetParameterElement)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetTechnique)(THIS_ UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetTechniqueByName)(THIS_ LPCSTR pName) PURE; - STDMETHOD_(D3DXHANDLE, GetPass)(THIS_ D3DXHANDLE hTechnique, UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetPassByName)(THIS_ D3DXHANDLE hTechnique, LPCSTR pName) PURE; - STDMETHOD_(D3DXHANDLE, GetFunction)(THIS_ UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetFunctionByName)(THIS_ LPCSTR pName) PURE; - STDMETHOD_(D3DXHANDLE, GetAnnotation)(THIS_ D3DXHANDLE hObject, UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetAnnotationByName)(THIS_ D3DXHANDLE hObject, LPCSTR pName) PURE; - - // Get/Set Parameters - STDMETHOD(SetValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT Bytes) PURE; - STDMETHOD(GetValue)(THIS_ D3DXHANDLE hParameter, LPVOID pData, UINT Bytes) PURE; - STDMETHOD(SetBool)(THIS_ D3DXHANDLE hParameter, BOOL b) PURE; - STDMETHOD(GetBool)(THIS_ D3DXHANDLE hParameter, BOOL* pb) PURE; - STDMETHOD(SetBoolArray)(THIS_ D3DXHANDLE hParameter, CONST BOOL* pb, UINT Count) PURE; - STDMETHOD(GetBoolArray)(THIS_ D3DXHANDLE hParameter, BOOL* pb, UINT Count) PURE; - STDMETHOD(SetInt)(THIS_ D3DXHANDLE hParameter, INT n) PURE; - STDMETHOD(GetInt)(THIS_ D3DXHANDLE hParameter, INT* pn) PURE; - STDMETHOD(SetIntArray)(THIS_ D3DXHANDLE hParameter, CONST INT* pn, UINT Count) PURE; - STDMETHOD(GetIntArray)(THIS_ D3DXHANDLE hParameter, INT* pn, UINT Count) PURE; - STDMETHOD(SetFloat)(THIS_ D3DXHANDLE hParameter, FLOAT f) PURE; - STDMETHOD(GetFloat)(THIS_ D3DXHANDLE hParameter, FLOAT* pf) PURE; - STDMETHOD(SetFloatArray)(THIS_ D3DXHANDLE hParameter, CONST FLOAT* pf, UINT Count) PURE; - STDMETHOD(GetFloatArray)(THIS_ D3DXHANDLE hParameter, FLOAT* pf, UINT Count) PURE; - STDMETHOD(SetVector)(THIS_ D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector) PURE; - STDMETHOD(GetVector)(THIS_ D3DXHANDLE hParameter, D3DXVECTOR4* pVector) PURE; - STDMETHOD(SetVectorArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector, UINT Count) PURE; - STDMETHOD(GetVectorArray)(THIS_ D3DXHANDLE hParameter, D3DXVECTOR4* pVector, UINT Count) PURE; - STDMETHOD(SetMatrix)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix) PURE; - STDMETHOD(GetMatrix)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix) PURE; - STDMETHOD(SetMatrixArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(GetMatrixArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixPointerArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; - STDMETHOD(GetMatrixPointerArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixTranspose)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix) PURE; - STDMETHOD(GetMatrixTranspose)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix) PURE; - STDMETHOD(SetMatrixTransposeArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(GetMatrixTransposeArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; - STDMETHOD(GetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count) PURE; - STDMETHOD(SetString)(THIS_ D3DXHANDLE hParameter, LPCSTR pString) PURE; - STDMETHOD(GetString)(THIS_ D3DXHANDLE hParameter, LPCSTR* ppString) PURE; - STDMETHOD(SetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 pTexture) PURE; - STDMETHOD(GetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 *ppTexture) PURE; - STDMETHOD(GetPixelShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9 *ppPShader) PURE; - STDMETHOD(GetVertexShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DVERTEXSHADER9 *ppVShader) PURE; - - //Set Range of an Array to pass to device - //Usefull for sending only a subrange of an array down to the device - STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; - // ID3DXBaseEffect - - // Parameter sharing, specialization, and information - STDMETHOD(SetLiteral)(THIS_ D3DXHANDLE hParameter, BOOL Literal) PURE; - STDMETHOD(GetLiteral)(THIS_ D3DXHANDLE hParameter, BOOL *pLiteral) PURE; - - // Compilation - STDMETHOD(CompileEffect)(THIS_ DWORD Flags, - LPD3DXBUFFER* ppEffect, LPD3DXBUFFER* ppErrorMsgs) PURE; - - STDMETHOD(CompileShader)(THIS_ D3DXHANDLE hFunction, LPCSTR pTarget, DWORD Flags, - LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable) PURE; -}; - - -////////////////////////////////////////////////////////////////////////////// -// APIs ////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -//---------------------------------------------------------------------------- -// D3DXCreateEffectPool: -// --------------------- -// Creates an effect pool. Pools are used for sharing parameters between -// multiple effects. For all effects within a pool, shared parameters of the -// same name all share the same value. -// -// Parameters: -// ppPool -// Returns the created pool. -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCreateEffectPool( - LPD3DXEFFECTPOOL* ppPool); - - -//---------------------------------------------------------------------------- -// D3DXCreateEffect: -// ----------------- -// Creates an effect from an ascii or binary effect description. -// -// Parameters: -// pDevice -// Pointer of the device on which to create the effect -// pSrcFile -// Name of the file containing the effect description -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pSrcData -// Pointer to effect description -// SrcDataSize -// Size of the effect description in bytes -// pDefines -// Optional NULL-terminated array of preprocessor macro definitions. -// Flags -// See D3DXSHADER_xxx flags. -// pSkipConstants -// A list of semi-colon delimited variable names. The effect will -// not set these variables to the device when they are referenced -// by a shader. NOTE: the variables specified here must be -// register bound in the file and must not be used in expressions -// in passes or samplers or the file will not load. -// pInclude -// Optional interface pointer to use for handling #include directives. -// If this parameter is NULL, #includes will be honored when compiling -// from file, and will error when compiling from resource or memory. -// pPool -// Pointer to ID3DXEffectPool object to use for shared parameters. -// If NULL, no parameters will be shared. -// ppEffect -// Returns a buffer containing created effect. -// ppCompilationErrors -// Returns a buffer containing any error messages which occurred during -// compile. Or NULL if you do not care about the error messages. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCreateEffectFromFileA( - LPDIRECT3DDEVICE9 pDevice, - LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXEFFECTPOOL pPool, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXCreateEffectFromFileW( - LPDIRECT3DDEVICE9 pDevice, - LPCWSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXEFFECTPOOL pPool, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileW -#else -#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileA -#endif - - -HRESULT WINAPI - D3DXCreateEffectFromResourceA( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXEFFECTPOOL pPool, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXCreateEffectFromResourceW( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXEFFECTPOOL pPool, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceW -#else -#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceA -#endif - - -HRESULT WINAPI - D3DXCreateEffect( - LPDIRECT3DDEVICE9 pDevice, - LPCVOID pSrcData, - UINT SrcDataLen, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXEFFECTPOOL pPool, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -// -// Ex functions that accept pSkipConstants in addition to other parameters -// - -HRESULT WINAPI - D3DXCreateEffectFromFileExA( - LPDIRECT3DDEVICE9 pDevice, - LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, - DWORD Flags, - LPD3DXEFFECTPOOL pPool, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXCreateEffectFromFileExW( - LPDIRECT3DDEVICE9 pDevice, - LPCWSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, - DWORD Flags, - LPD3DXEFFECTPOOL pPool, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXCreateEffectFromFileEx D3DXCreateEffectFromFileExW -#else -#define D3DXCreateEffectFromFileEx D3DXCreateEffectFromFileExA -#endif - - -HRESULT WINAPI - D3DXCreateEffectFromResourceExA( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, - DWORD Flags, - LPD3DXEFFECTPOOL pPool, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXCreateEffectFromResourceExW( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, - DWORD Flags, - LPD3DXEFFECTPOOL pPool, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXCreateEffectFromResourceEx D3DXCreateEffectFromResourceExW -#else -#define D3DXCreateEffectFromResourceEx D3DXCreateEffectFromResourceExA -#endif - - -HRESULT WINAPI - D3DXCreateEffectEx( - LPDIRECT3DDEVICE9 pDevice, - LPCVOID pSrcData, - UINT SrcDataLen, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, - DWORD Flags, - LPD3DXEFFECTPOOL pPool, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -//---------------------------------------------------------------------------- -// D3DXCreateEffectCompiler: -// ------------------------- -// Creates an effect from an ascii or binary effect description. -// -// Parameters: -// pSrcFile -// Name of the file containing the effect description -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pSrcData -// Pointer to effect description -// SrcDataSize -// Size of the effect description in bytes -// pDefines -// Optional NULL-terminated array of preprocessor macro definitions. -// pInclude -// Optional interface pointer to use for handling #include directives. -// If this parameter is NULL, #includes will be honored when compiling -// from file, and will error when compiling from resource or memory. -// pPool -// Pointer to ID3DXEffectPool object to use for shared parameters. -// If NULL, no parameters will be shared. -// ppCompiler -// Returns a buffer containing created effect compiler. -// ppParseErrors -// Returns a buffer containing any error messages which occurred during -// parse. Or NULL if you do not care about the error messages. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCreateEffectCompilerFromFileA( - LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXEFFECTCOMPILER* ppCompiler, - LPD3DXBUFFER* ppParseErrors); - -HRESULT WINAPI - D3DXCreateEffectCompilerFromFileW( - LPCWSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXEFFECTCOMPILER* ppCompiler, - LPD3DXBUFFER* ppParseErrors); - -#ifdef UNICODE -#define D3DXCreateEffectCompilerFromFile D3DXCreateEffectCompilerFromFileW -#else -#define D3DXCreateEffectCompilerFromFile D3DXCreateEffectCompilerFromFileA -#endif - - -HRESULT WINAPI - D3DXCreateEffectCompilerFromResourceA( - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXEFFECTCOMPILER* ppCompiler, - LPD3DXBUFFER* ppParseErrors); - -HRESULT WINAPI - D3DXCreateEffectCompilerFromResourceW( - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXEFFECTCOMPILER* ppCompiler, - LPD3DXBUFFER* ppParseErrors); - -#ifdef UNICODE -#define D3DXCreateEffectCompilerFromResource D3DXCreateEffectCompilerFromResourceW -#else -#define D3DXCreateEffectCompilerFromResource D3DXCreateEffectCompilerFromResourceA -#endif - - -HRESULT WINAPI - D3DXCreateEffectCompiler( - LPCSTR pSrcData, - UINT SrcDataLen, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXEFFECTCOMPILER* ppCompiler, - LPD3DXBUFFER* ppParseErrors); - -//---------------------------------------------------------------------------- -// D3DXDisassembleEffect: -// ----------------------- -// -// Parameters: -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXDisassembleEffect( - LPD3DXEFFECT pEffect, - BOOL EnableColorCode, - LPD3DXBUFFER *ppDisassembly); - - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX9EFFECT_H__ - - + +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// File: d3dx9effect.h +// Content: D3DX effect types and Shaders +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx9.h" + +#ifndef __D3DX9EFFECT_H__ +#define __D3DX9EFFECT_H__ + + +//---------------------------------------------------------------------------- +// D3DXFX_DONOTSAVESTATE +// This flag is used as a parameter to ID3DXEffect::Begin(). When this flag +// is specified, device state is not saved or restored in Begin/End. +// D3DXFX_DONOTSAVESHADERSTATE +// This flag is used as a parameter to ID3DXEffect::Begin(). When this flag +// is specified, shader device state is not saved or restored in Begin/End. +// This includes pixel/vertex shaders and shader constants +// D3DXFX_DONOTSAVESAMPLERSTATE +// This flag is used as a parameter to ID3DXEffect::Begin(). When this flag +// is specified, sampler device state is not saved or restored in Begin/End. +// D3DXFX_NOT_CLONEABLE +// This flag is used as a parameter to the D3DXCreateEffect family of APIs. +// When this flag is specified, the effect will be non-cloneable and will not +// contain any shader binary data. +// Furthermore, GetPassDesc will not return shader function pointers. +// Setting this flag reduces effect memory usage by about 50%. +//---------------------------------------------------------------------------- + +#define D3DXFX_DONOTSAVESTATE (1 << 0) +#define D3DXFX_DONOTSAVESHADERSTATE (1 << 1) +#define D3DXFX_DONOTSAVESAMPLERSTATE (1 << 2) +#define D3DXFX_NOT_CLONEABLE (1 << 11) + +//---------------------------------------------------------------------------- +// D3DX_PARAMETER_SHARED +// Indicates that the value of a parameter will be shared with all effects +// which share the same namespace. Changing the value in one effect will +// change it in all. +// +// D3DX_PARAMETER_LITERAL +// Indicates that the value of this parameter can be treated as literal. +// Literal parameters can be marked when the effect is compiled, and their +// cannot be changed after the effect is compiled. Shared parameters cannot +// be literal. +//---------------------------------------------------------------------------- + +#define D3DX_PARAMETER_SHARED (1 << 0) +#define D3DX_PARAMETER_LITERAL (1 << 1) +#define D3DX_PARAMETER_ANNOTATION (1 << 2) + +//---------------------------------------------------------------------------- +// D3DXEFFECT_DESC: +//---------------------------------------------------------------------------- + +typedef struct _D3DXEFFECT_DESC +{ + LPCSTR Creator; // Creator string + UINT Parameters; // Number of parameters + UINT Techniques; // Number of techniques + UINT Functions; // Number of function entrypoints + +} D3DXEFFECT_DESC; + + +//---------------------------------------------------------------------------- +// D3DXPARAMETER_DESC: +//---------------------------------------------------------------------------- + +typedef struct _D3DXPARAMETER_DESC +{ + LPCSTR Name; // Parameter name + LPCSTR Semantic; // Parameter semantic + D3DXPARAMETER_CLASS Class; // Class + D3DXPARAMETER_TYPE Type; // Component type + UINT Rows; // Number of rows + UINT Columns; // Number of columns + UINT Elements; // Number of array elements + UINT Annotations; // Number of annotations + UINT StructMembers; // Number of structure member sub-parameters + DWORD Flags; // D3DX_PARAMETER_* flags + UINT Bytes; // Parameter size, in bytes + +} D3DXPARAMETER_DESC; + + +//---------------------------------------------------------------------------- +// D3DXTECHNIQUE_DESC: +//---------------------------------------------------------------------------- + +typedef struct _D3DXTECHNIQUE_DESC +{ + LPCSTR Name; // Technique name + UINT Passes; // Number of passes + UINT Annotations; // Number of annotations + +} D3DXTECHNIQUE_DESC; + + +//---------------------------------------------------------------------------- +// D3DXPASS_DESC: +//---------------------------------------------------------------------------- + +typedef struct _D3DXPASS_DESC +{ + LPCSTR Name; // Pass name + UINT Annotations; // Number of annotations + + CONST DWORD *pVertexShaderFunction; // Vertex shader function + CONST DWORD *pPixelShaderFunction; // Pixel shader function + +} D3DXPASS_DESC; + + +//---------------------------------------------------------------------------- +// D3DXFUNCTION_DESC: +//---------------------------------------------------------------------------- + +typedef struct _D3DXFUNCTION_DESC +{ + LPCSTR Name; // Function name + UINT Annotations; // Number of annotations + +} D3DXFUNCTION_DESC; + + + +////////////////////////////////////////////////////////////////////////////// +// ID3DXEffectPool /////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXEffectPool ID3DXEffectPool; +typedef interface ID3DXEffectPool *LPD3DXEFFECTPOOL; + +// {9537AB04-3250-412e-8213-FCD2F8677933} +DEFINE_GUID(IID_ID3DXEffectPool, +0x9537ab04, 0x3250, 0x412e, 0x82, 0x13, 0xfc, 0xd2, 0xf8, 0x67, 0x79, 0x33); + + +#undef INTERFACE +#define INTERFACE ID3DXEffectPool + +DECLARE_INTERFACE_(ID3DXEffectPool, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // No public methods +}; + + +////////////////////////////////////////////////////////////////////////////// +// ID3DXBaseEffect /////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXBaseEffect ID3DXBaseEffect; +typedef interface ID3DXBaseEffect *LPD3DXBASEEFFECT; + +// {017C18AC-103F-4417-8C51-6BF6EF1E56BE} +DEFINE_GUID(IID_ID3DXBaseEffect, +0x17c18ac, 0x103f, 0x4417, 0x8c, 0x51, 0x6b, 0xf6, 0xef, 0x1e, 0x56, 0xbe); + + +#undef INTERFACE +#define INTERFACE ID3DXBaseEffect + +DECLARE_INTERFACE_(ID3DXBaseEffect, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // Descs + STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; + STDMETHOD(GetParameterDesc)(THIS_ D3DXHANDLE hParameter, D3DXPARAMETER_DESC* pDesc) PURE; + STDMETHOD(GetTechniqueDesc)(THIS_ D3DXHANDLE hTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; + STDMETHOD(GetPassDesc)(THIS_ D3DXHANDLE hPass, D3DXPASS_DESC* pDesc) PURE; + STDMETHOD(GetFunctionDesc)(THIS_ D3DXHANDLE hShader, D3DXFUNCTION_DESC* pDesc) PURE; + + // Handle operations + STDMETHOD_(D3DXHANDLE, GetParameter)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetParameterByName)(THIS_ D3DXHANDLE hParameter, LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetParameterBySemantic)(THIS_ D3DXHANDLE hParameter, LPCSTR pSemantic) PURE; + STDMETHOD_(D3DXHANDLE, GetParameterElement)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetTechnique)(THIS_ UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetTechniqueByName)(THIS_ LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetPass)(THIS_ D3DXHANDLE hTechnique, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetPassByName)(THIS_ D3DXHANDLE hTechnique, LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetFunction)(THIS_ UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetFunctionByName)(THIS_ LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetAnnotation)(THIS_ D3DXHANDLE hObject, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetAnnotationByName)(THIS_ D3DXHANDLE hObject, LPCSTR pName) PURE; + + // Get/Set Parameters + STDMETHOD(SetValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT Bytes) PURE; + STDMETHOD(GetValue)(THIS_ D3DXHANDLE hParameter, LPVOID pData, UINT Bytes) PURE; + STDMETHOD(SetBool)(THIS_ D3DXHANDLE hParameter, BOOL b) PURE; + STDMETHOD(GetBool)(THIS_ D3DXHANDLE hParameter, BOOL* pb) PURE; + STDMETHOD(SetBoolArray)(THIS_ D3DXHANDLE hParameter, CONST BOOL* pb, UINT Count) PURE; + STDMETHOD(GetBoolArray)(THIS_ D3DXHANDLE hParameter, BOOL* pb, UINT Count) PURE; + STDMETHOD(SetInt)(THIS_ D3DXHANDLE hParameter, INT n) PURE; + STDMETHOD(GetInt)(THIS_ D3DXHANDLE hParameter, INT* pn) PURE; + STDMETHOD(SetIntArray)(THIS_ D3DXHANDLE hParameter, CONST INT* pn, UINT Count) PURE; + STDMETHOD(GetIntArray)(THIS_ D3DXHANDLE hParameter, INT* pn, UINT Count) PURE; + STDMETHOD(SetFloat)(THIS_ D3DXHANDLE hParameter, FLOAT f) PURE; + STDMETHOD(GetFloat)(THIS_ D3DXHANDLE hParameter, FLOAT* pf) PURE; + STDMETHOD(SetFloatArray)(THIS_ D3DXHANDLE hParameter, CONST FLOAT* pf, UINT Count) PURE; + STDMETHOD(GetFloatArray)(THIS_ D3DXHANDLE hParameter, FLOAT* pf, UINT Count) PURE; + STDMETHOD(SetVector)(THIS_ D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector) PURE; + STDMETHOD(GetVector)(THIS_ D3DXHANDLE hParameter, D3DXVECTOR4* pVector) PURE; + STDMETHOD(SetVectorArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector, UINT Count) PURE; + STDMETHOD(GetVectorArray)(THIS_ D3DXHANDLE hParameter, D3DXVECTOR4* pVector, UINT Count) PURE; + STDMETHOD(SetMatrix)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(GetMatrix)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetMatrixArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(GetMatrixArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixPointerArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(GetMatrixPointerArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixTranspose)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(GetMatrixTranspose)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetMatrixTransposeArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(GetMatrixTransposeArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(GetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(SetString)(THIS_ D3DXHANDLE hParameter, LPCSTR pString) PURE; + STDMETHOD(GetString)(THIS_ D3DXHANDLE hParameter, LPCSTR* ppString) PURE; + STDMETHOD(SetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 pTexture) PURE; + STDMETHOD(GetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 *ppTexture) PURE; + STDMETHOD(GetPixelShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9 *ppPShader) PURE; + STDMETHOD(GetVertexShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DVERTEXSHADER9 *ppVShader) PURE; + + //Set Range of an Array to pass to device + //Useful for sending only a subrange of an array down to the device + STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; + +}; + + +//---------------------------------------------------------------------------- +// ID3DXEffectStateManager: +// ------------------------ +// This is a user implemented interface that can be used to manage device +// state changes made by an Effect. +//---------------------------------------------------------------------------- + +typedef interface ID3DXEffectStateManager ID3DXEffectStateManager; +typedef interface ID3DXEffectStateManager *LPD3DXEFFECTSTATEMANAGER; + +// {79AAB587-6DBC-4fa7-82DE-37FA1781C5CE} +DEFINE_GUID(IID_ID3DXEffectStateManager, +0x79aab587, 0x6dbc, 0x4fa7, 0x82, 0xde, 0x37, 0xfa, 0x17, 0x81, 0xc5, 0xce); + +#undef INTERFACE +#define INTERFACE ID3DXEffectStateManager + +DECLARE_INTERFACE_(ID3DXEffectStateManager, IUnknown) +{ + // The user must correctly implement QueryInterface, AddRef, and Release. + + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // The following methods are called by the Effect when it wants to make + // the corresponding device call. Note that: + // 1. Users manage the state and are therefore responsible for making the + // the corresponding device calls themselves inside their callbacks. + // 2. Effects pay attention to the return values of the callbacks, and so + // users must pay attention to what they return in their callbacks. + + STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX *pMatrix) PURE; + STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL9 *pMaterial) PURE; + STDMETHOD(SetLight)(THIS_ DWORD Index, CONST D3DLIGHT9 *pLight) PURE; + STDMETHOD(LightEnable)(THIS_ DWORD Index, BOOL Enable) PURE; + STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State, DWORD Value) PURE; + STDMETHOD(SetTexture)(THIS_ DWORD Stage, LPDIRECT3DBASETEXTURE9 pTexture) PURE; + STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) PURE; + STDMETHOD(SetSamplerState)(THIS_ DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) PURE; + STDMETHOD(SetNPatchMode)(THIS_ FLOAT NumSegments) PURE; + STDMETHOD(SetFVF)(THIS_ DWORD FVF) PURE; + STDMETHOD(SetVertexShader)(THIS_ LPDIRECT3DVERTEXSHADER9 pShader) PURE; + STDMETHOD(SetVertexShaderConstantF)(THIS_ UINT RegisterIndex, CONST FLOAT *pConstantData, UINT RegisterCount) PURE; + STDMETHOD(SetVertexShaderConstantI)(THIS_ UINT RegisterIndex, CONST INT *pConstantData, UINT RegisterCount) PURE; + STDMETHOD(SetVertexShaderConstantB)(THIS_ UINT RegisterIndex, CONST BOOL *pConstantData, UINT RegisterCount) PURE; + STDMETHOD(SetPixelShader)(THIS_ LPDIRECT3DPIXELSHADER9 pShader) PURE; + STDMETHOD(SetPixelShaderConstantF)(THIS_ UINT RegisterIndex, CONST FLOAT *pConstantData, UINT RegisterCount) PURE; + STDMETHOD(SetPixelShaderConstantI)(THIS_ UINT RegisterIndex, CONST INT *pConstantData, UINT RegisterCount) PURE; + STDMETHOD(SetPixelShaderConstantB)(THIS_ UINT RegisterIndex, CONST BOOL *pConstantData, UINT RegisterCount) PURE; +}; + + +////////////////////////////////////////////////////////////////////////////// +// ID3DXEffect /////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXEffect ID3DXEffect; +typedef interface ID3DXEffect *LPD3DXEFFECT; + +// {F6CEB4B3-4E4C-40dd-B883-8D8DE5EA0CD5} +DEFINE_GUID(IID_ID3DXEffect, +0xf6ceb4b3, 0x4e4c, 0x40dd, 0xb8, 0x83, 0x8d, 0x8d, 0xe5, 0xea, 0xc, 0xd5); + +#undef INTERFACE +#define INTERFACE ID3DXEffect + +DECLARE_INTERFACE_(ID3DXEffect, ID3DXBaseEffect) +{ + // ID3DXBaseEffect + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // Descs + STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; + STDMETHOD(GetParameterDesc)(THIS_ D3DXHANDLE hParameter, D3DXPARAMETER_DESC* pDesc) PURE; + STDMETHOD(GetTechniqueDesc)(THIS_ D3DXHANDLE hTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; + STDMETHOD(GetPassDesc)(THIS_ D3DXHANDLE hPass, D3DXPASS_DESC* pDesc) PURE; + STDMETHOD(GetFunctionDesc)(THIS_ D3DXHANDLE hShader, D3DXFUNCTION_DESC* pDesc) PURE; + + // Handle operations + STDMETHOD_(D3DXHANDLE, GetParameter)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetParameterByName)(THIS_ D3DXHANDLE hParameter, LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetParameterBySemantic)(THIS_ D3DXHANDLE hParameter, LPCSTR pSemantic) PURE; + STDMETHOD_(D3DXHANDLE, GetParameterElement)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetTechnique)(THIS_ UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetTechniqueByName)(THIS_ LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetPass)(THIS_ D3DXHANDLE hTechnique, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetPassByName)(THIS_ D3DXHANDLE hTechnique, LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetFunction)(THIS_ UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetFunctionByName)(THIS_ LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetAnnotation)(THIS_ D3DXHANDLE hObject, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetAnnotationByName)(THIS_ D3DXHANDLE hObject, LPCSTR pName) PURE; + + // Get/Set Parameters + STDMETHOD(SetValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT Bytes) PURE; + STDMETHOD(GetValue)(THIS_ D3DXHANDLE hParameter, LPVOID pData, UINT Bytes) PURE; + STDMETHOD(SetBool)(THIS_ D3DXHANDLE hParameter, BOOL b) PURE; + STDMETHOD(GetBool)(THIS_ D3DXHANDLE hParameter, BOOL* pb) PURE; + STDMETHOD(SetBoolArray)(THIS_ D3DXHANDLE hParameter, CONST BOOL* pb, UINT Count) PURE; + STDMETHOD(GetBoolArray)(THIS_ D3DXHANDLE hParameter, BOOL* pb, UINT Count) PURE; + STDMETHOD(SetInt)(THIS_ D3DXHANDLE hParameter, INT n) PURE; + STDMETHOD(GetInt)(THIS_ D3DXHANDLE hParameter, INT* pn) PURE; + STDMETHOD(SetIntArray)(THIS_ D3DXHANDLE hParameter, CONST INT* pn, UINT Count) PURE; + STDMETHOD(GetIntArray)(THIS_ D3DXHANDLE hParameter, INT* pn, UINT Count) PURE; + STDMETHOD(SetFloat)(THIS_ D3DXHANDLE hParameter, FLOAT f) PURE; + STDMETHOD(GetFloat)(THIS_ D3DXHANDLE hParameter, FLOAT* pf) PURE; + STDMETHOD(SetFloatArray)(THIS_ D3DXHANDLE hParameter, CONST FLOAT* pf, UINT Count) PURE; + STDMETHOD(GetFloatArray)(THIS_ D3DXHANDLE hParameter, FLOAT* pf, UINT Count) PURE; + STDMETHOD(SetVector)(THIS_ D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector) PURE; + STDMETHOD(GetVector)(THIS_ D3DXHANDLE hParameter, D3DXVECTOR4* pVector) PURE; + STDMETHOD(SetVectorArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector, UINT Count) PURE; + STDMETHOD(GetVectorArray)(THIS_ D3DXHANDLE hParameter, D3DXVECTOR4* pVector, UINT Count) PURE; + STDMETHOD(SetMatrix)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(GetMatrix)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetMatrixArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(GetMatrixArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixPointerArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(GetMatrixPointerArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixTranspose)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(GetMatrixTranspose)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetMatrixTransposeArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(GetMatrixTransposeArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(GetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(SetString)(THIS_ D3DXHANDLE hParameter, LPCSTR pString) PURE; + STDMETHOD(GetString)(THIS_ D3DXHANDLE hParameter, LPCSTR* ppString) PURE; + STDMETHOD(SetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 pTexture) PURE; + STDMETHOD(GetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 *ppTexture) PURE; + STDMETHOD(GetPixelShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9 *ppPShader) PURE; + STDMETHOD(GetVertexShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DVERTEXSHADER9 *ppVShader) PURE; + + //Set Range of an Array to pass to device + //Usefull for sending only a subrange of an array down to the device + STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; + // ID3DXBaseEffect + + + // Pool + STDMETHOD(GetPool)(THIS_ LPD3DXEFFECTPOOL* ppPool) PURE; + + // Selecting and setting a technique + STDMETHOD(SetTechnique)(THIS_ D3DXHANDLE hTechnique) PURE; + STDMETHOD_(D3DXHANDLE, GetCurrentTechnique)(THIS) PURE; + STDMETHOD(ValidateTechnique)(THIS_ D3DXHANDLE hTechnique) PURE; + STDMETHOD(FindNextValidTechnique)(THIS_ D3DXHANDLE hTechnique, D3DXHANDLE *pTechnique) PURE; + STDMETHOD_(BOOL, IsParameterUsed)(THIS_ D3DXHANDLE hParameter, D3DXHANDLE hTechnique) PURE; + + // Using current technique + // Begin starts active technique + // BeginPass begins a pass + // CommitChanges updates changes to any set calls in the pass. This should be called before + // any DrawPrimitive call to d3d + // EndPass ends a pass + // End ends active technique + STDMETHOD(Begin)(THIS_ UINT *pPasses, DWORD Flags) PURE; + STDMETHOD(BeginPass)(THIS_ UINT Pass) PURE; + STDMETHOD(CommitChanges)(THIS) PURE; + STDMETHOD(EndPass)(THIS) PURE; + STDMETHOD(End)(THIS) PURE; + + // Managing D3D Device + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; + + // Logging device calls + STDMETHOD(SetStateManager)(THIS_ LPD3DXEFFECTSTATEMANAGER pManager) PURE; + STDMETHOD(GetStateManager)(THIS_ LPD3DXEFFECTSTATEMANAGER *ppManager) PURE; + + // Parameter blocks + STDMETHOD(BeginParameterBlock)(THIS) PURE; + STDMETHOD_(D3DXHANDLE, EndParameterBlock)(THIS) PURE; + STDMETHOD(ApplyParameterBlock)(THIS_ D3DXHANDLE hParameterBlock) PURE; + STDMETHOD(DeleteParameterBlock)(THIS_ D3DXHANDLE hParameterBlock) PURE; + + // Cloning + STDMETHOD(CloneEffect)(THIS_ LPDIRECT3DDEVICE9 pDevice, LPD3DXEFFECT* ppEffect) PURE; + + // Fast path for setting variables directly in ID3DXEffect + STDMETHOD(SetRawValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT ByteOffset, UINT Bytes) PURE; +}; + + +////////////////////////////////////////////////////////////////////////////// +// ID3DXEffectCompiler /////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXEffectCompiler ID3DXEffectCompiler; +typedef interface ID3DXEffectCompiler *LPD3DXEFFECTCOMPILER; + +// {51B8A949-1A31-47e6-BEA0-4B30DB53F1E0} +DEFINE_GUID(IID_ID3DXEffectCompiler, +0x51b8a949, 0x1a31, 0x47e6, 0xbe, 0xa0, 0x4b, 0x30, 0xdb, 0x53, 0xf1, 0xe0); + + +#undef INTERFACE +#define INTERFACE ID3DXEffectCompiler + +DECLARE_INTERFACE_(ID3DXEffectCompiler, ID3DXBaseEffect) +{ + // ID3DXBaseEffect + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // Descs + STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; + STDMETHOD(GetParameterDesc)(THIS_ D3DXHANDLE hParameter, D3DXPARAMETER_DESC* pDesc) PURE; + STDMETHOD(GetTechniqueDesc)(THIS_ D3DXHANDLE hTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; + STDMETHOD(GetPassDesc)(THIS_ D3DXHANDLE hPass, D3DXPASS_DESC* pDesc) PURE; + STDMETHOD(GetFunctionDesc)(THIS_ D3DXHANDLE hShader, D3DXFUNCTION_DESC* pDesc) PURE; + + // Handle operations + STDMETHOD_(D3DXHANDLE, GetParameter)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetParameterByName)(THIS_ D3DXHANDLE hParameter, LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetParameterBySemantic)(THIS_ D3DXHANDLE hParameter, LPCSTR pSemantic) PURE; + STDMETHOD_(D3DXHANDLE, GetParameterElement)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetTechnique)(THIS_ UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetTechniqueByName)(THIS_ LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetPass)(THIS_ D3DXHANDLE hTechnique, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetPassByName)(THIS_ D3DXHANDLE hTechnique, LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetFunction)(THIS_ UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetFunctionByName)(THIS_ LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetAnnotation)(THIS_ D3DXHANDLE hObject, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetAnnotationByName)(THIS_ D3DXHANDLE hObject, LPCSTR pName) PURE; + + // Get/Set Parameters + STDMETHOD(SetValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT Bytes) PURE; + STDMETHOD(GetValue)(THIS_ D3DXHANDLE hParameter, LPVOID pData, UINT Bytes) PURE; + STDMETHOD(SetBool)(THIS_ D3DXHANDLE hParameter, BOOL b) PURE; + STDMETHOD(GetBool)(THIS_ D3DXHANDLE hParameter, BOOL* pb) PURE; + STDMETHOD(SetBoolArray)(THIS_ D3DXHANDLE hParameter, CONST BOOL* pb, UINT Count) PURE; + STDMETHOD(GetBoolArray)(THIS_ D3DXHANDLE hParameter, BOOL* pb, UINT Count) PURE; + STDMETHOD(SetInt)(THIS_ D3DXHANDLE hParameter, INT n) PURE; + STDMETHOD(GetInt)(THIS_ D3DXHANDLE hParameter, INT* pn) PURE; + STDMETHOD(SetIntArray)(THIS_ D3DXHANDLE hParameter, CONST INT* pn, UINT Count) PURE; + STDMETHOD(GetIntArray)(THIS_ D3DXHANDLE hParameter, INT* pn, UINT Count) PURE; + STDMETHOD(SetFloat)(THIS_ D3DXHANDLE hParameter, FLOAT f) PURE; + STDMETHOD(GetFloat)(THIS_ D3DXHANDLE hParameter, FLOAT* pf) PURE; + STDMETHOD(SetFloatArray)(THIS_ D3DXHANDLE hParameter, CONST FLOAT* pf, UINT Count) PURE; + STDMETHOD(GetFloatArray)(THIS_ D3DXHANDLE hParameter, FLOAT* pf, UINT Count) PURE; + STDMETHOD(SetVector)(THIS_ D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector) PURE; + STDMETHOD(GetVector)(THIS_ D3DXHANDLE hParameter, D3DXVECTOR4* pVector) PURE; + STDMETHOD(SetVectorArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector, UINT Count) PURE; + STDMETHOD(GetVectorArray)(THIS_ D3DXHANDLE hParameter, D3DXVECTOR4* pVector, UINT Count) PURE; + STDMETHOD(SetMatrix)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(GetMatrix)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetMatrixArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(GetMatrixArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixPointerArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(GetMatrixPointerArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixTranspose)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(GetMatrixTranspose)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetMatrixTransposeArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(GetMatrixTransposeArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(GetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(SetString)(THIS_ D3DXHANDLE hParameter, LPCSTR pString) PURE; + STDMETHOD(GetString)(THIS_ D3DXHANDLE hParameter, LPCSTR* ppString) PURE; + STDMETHOD(SetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 pTexture) PURE; + STDMETHOD(GetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 *ppTexture) PURE; + STDMETHOD(GetPixelShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9 *ppPShader) PURE; + STDMETHOD(GetVertexShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DVERTEXSHADER9 *ppVShader) PURE; + + //Set Range of an Array to pass to device + //Usefull for sending only a subrange of an array down to the device + STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; + // ID3DXBaseEffect + + // Parameter sharing, specialization, and information + STDMETHOD(SetLiteral)(THIS_ D3DXHANDLE hParameter, BOOL Literal) PURE; + STDMETHOD(GetLiteral)(THIS_ D3DXHANDLE hParameter, BOOL *pLiteral) PURE; + + // Compilation + STDMETHOD(CompileEffect)(THIS_ DWORD Flags, + LPD3DXBUFFER* ppEffect, LPD3DXBUFFER* ppErrorMsgs) PURE; + + STDMETHOD(CompileShader)(THIS_ D3DXHANDLE hFunction, LPCSTR pTarget, DWORD Flags, + LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable) PURE; +}; + + +////////////////////////////////////////////////////////////////////////////// +// APIs ////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +//---------------------------------------------------------------------------- +// D3DXCreateEffectPool: +// --------------------- +// Creates an effect pool. Pools are used for sharing parameters between +// multiple effects. For all effects within a pool, shared parameters of the +// same name all share the same value. +// +// Parameters: +// ppPool +// Returns the created pool. +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCreateEffectPool( + LPD3DXEFFECTPOOL* ppPool); + + +//---------------------------------------------------------------------------- +// D3DXCreateEffect: +// ----------------- +// Creates an effect from an ascii or binary effect description. +// +// Parameters: +// pDevice +// Pointer of the device on which to create the effect +// pSrcFile +// Name of the file containing the effect description +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pSrcData +// Pointer to effect description +// SrcDataSize +// Size of the effect description in bytes +// pDefines +// Optional NULL-terminated array of preprocessor macro definitions. +// Flags +// See D3DXSHADER_xxx flags. +// pSkipConstants +// A list of semi-colon delimited variable names. The effect will +// not set these variables to the device when they are referenced +// by a shader. NOTE: the variables specified here must be +// register bound in the file and must not be used in expressions +// in passes or samplers or the file will not load. +// pInclude +// Optional interface pointer to use for handling #include directives. +// If this parameter is NULL, #includes will be honored when compiling +// from file, and will error when compiling from resource or memory. +// pPool +// Pointer to ID3DXEffectPool object to use for shared parameters. +// If NULL, no parameters will be shared. +// ppEffect +// Returns a buffer containing created effect. +// ppCompilationErrors +// Returns a buffer containing any error messages which occurred during +// compile. Or NULL if you do not care about the error messages. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCreateEffectFromFileA( + LPDIRECT3DDEVICE9 pDevice, + LPCSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXEFFECTPOOL pPool, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXCreateEffectFromFileW( + LPDIRECT3DDEVICE9 pDevice, + LPCWSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXEFFECTPOOL pPool, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileW +#else +#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateEffectFromResourceA( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXEFFECTPOOL pPool, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXCreateEffectFromResourceW( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXEFFECTPOOL pPool, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceW +#else +#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateEffect( + LPDIRECT3DDEVICE9 pDevice, + LPCVOID pSrcData, + UINT SrcDataLen, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXEFFECTPOOL pPool, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +// +// Ex functions that accept pSkipConstants in addition to other parameters +// + +HRESULT WINAPI + D3DXCreateEffectFromFileExA( + LPDIRECT3DDEVICE9 pDevice, + LPCSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pSkipConstants, + DWORD Flags, + LPD3DXEFFECTPOOL pPool, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXCreateEffectFromFileExW( + LPDIRECT3DDEVICE9 pDevice, + LPCWSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pSkipConstants, + DWORD Flags, + LPD3DXEFFECTPOOL pPool, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXCreateEffectFromFileEx D3DXCreateEffectFromFileExW +#else +#define D3DXCreateEffectFromFileEx D3DXCreateEffectFromFileExA +#endif + + +HRESULT WINAPI + D3DXCreateEffectFromResourceExA( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pSkipConstants, + DWORD Flags, + LPD3DXEFFECTPOOL pPool, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXCreateEffectFromResourceExW( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pSkipConstants, + DWORD Flags, + LPD3DXEFFECTPOOL pPool, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXCreateEffectFromResourceEx D3DXCreateEffectFromResourceExW +#else +#define D3DXCreateEffectFromResourceEx D3DXCreateEffectFromResourceExA +#endif + + +HRESULT WINAPI + D3DXCreateEffectEx( + LPDIRECT3DDEVICE9 pDevice, + LPCVOID pSrcData, + UINT SrcDataLen, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pSkipConstants, + DWORD Flags, + LPD3DXEFFECTPOOL pPool, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +//---------------------------------------------------------------------------- +// D3DXCreateEffectCompiler: +// ------------------------- +// Creates an effect from an ascii or binary effect description. +// +// Parameters: +// pSrcFile +// Name of the file containing the effect description +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pSrcData +// Pointer to effect description +// SrcDataSize +// Size of the effect description in bytes +// pDefines +// Optional NULL-terminated array of preprocessor macro definitions. +// pInclude +// Optional interface pointer to use for handling #include directives. +// If this parameter is NULL, #includes will be honored when compiling +// from file, and will error when compiling from resource or memory. +// pPool +// Pointer to ID3DXEffectPool object to use for shared parameters. +// If NULL, no parameters will be shared. +// ppCompiler +// Returns a buffer containing created effect compiler. +// ppParseErrors +// Returns a buffer containing any error messages which occurred during +// parse. Or NULL if you do not care about the error messages. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCreateEffectCompilerFromFileA( + LPCSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXEFFECTCOMPILER* ppCompiler, + LPD3DXBUFFER* ppParseErrors); + +HRESULT WINAPI + D3DXCreateEffectCompilerFromFileW( + LPCWSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXEFFECTCOMPILER* ppCompiler, + LPD3DXBUFFER* ppParseErrors); + +#ifdef UNICODE +#define D3DXCreateEffectCompilerFromFile D3DXCreateEffectCompilerFromFileW +#else +#define D3DXCreateEffectCompilerFromFile D3DXCreateEffectCompilerFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateEffectCompilerFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXEFFECTCOMPILER* ppCompiler, + LPD3DXBUFFER* ppParseErrors); + +HRESULT WINAPI + D3DXCreateEffectCompilerFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXEFFECTCOMPILER* ppCompiler, + LPD3DXBUFFER* ppParseErrors); + +#ifdef UNICODE +#define D3DXCreateEffectCompilerFromResource D3DXCreateEffectCompilerFromResourceW +#else +#define D3DXCreateEffectCompilerFromResource D3DXCreateEffectCompilerFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateEffectCompiler( + LPCSTR pSrcData, + UINT SrcDataLen, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXEFFECTCOMPILER* ppCompiler, + LPD3DXBUFFER* ppParseErrors); + +//---------------------------------------------------------------------------- +// D3DXDisassembleEffect: +// ----------------------- +// +// Parameters: +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXDisassembleEffect( + LPD3DXEFFECT pEffect, + BOOL EnableColorCode, + LPD3DXBUFFER *ppDisassembly); + + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX9EFFECT_H__ + + diff --git a/src/dep/include/DXSDK/include/d3dx9math.h b/src/dep/include/DXSDK/include/d3dx9math.h index c524476..8f9bbc9 100644 --- a/src/dep/include/DXSDK/include/d3dx9math.h +++ b/src/dep/include/DXSDK/include/d3dx9math.h @@ -1,1765 +1,1765 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx9math.h -// Content: D3DX math types and functions -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx9.h" - -#ifndef __D3DX9MATH_H__ -#define __D3DX9MATH_H__ - -#include -#if _MSC_VER >= 1200 -#pragma warning(push) -#endif -#pragma warning(disable:4201) // anonymous unions warning - - - -//=========================================================================== -// -// General purpose utilities -// -//=========================================================================== -#define D3DX_PI ((FLOAT) 3.141592654f) -#define D3DX_1BYPI ((FLOAT) 0.318309886f) - -#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) -#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) - - - -//=========================================================================== -// -// 16 bit floating point numbers -// -//=========================================================================== - -#define D3DX_16F_DIG 3 // # of decimal digits of precision -#define D3DX_16F_EPSILON 4.8875809e-4f // smallest such that 1.0 + epsilon != 1.0 -#define D3DX_16F_MANT_DIG 11 // # of bits in mantissa -#define D3DX_16F_MAX 6.550400e+004 // max value -#define D3DX_16F_MAX_10_EXP 4 // max decimal exponent -#define D3DX_16F_MAX_EXP 15 // max binary exponent -#define D3DX_16F_MIN 6.1035156e-5f // min positive value -#define D3DX_16F_MIN_10_EXP (-4) // min decimal exponent -#define D3DX_16F_MIN_EXP (-14) // min binary exponent -#define D3DX_16F_RADIX 2 // exponent radix -#define D3DX_16F_ROUNDS 1 // addition rounding: near - - -typedef struct D3DXFLOAT16 -{ -#ifdef __cplusplus -public: - D3DXFLOAT16() {}; - D3DXFLOAT16( FLOAT ); - D3DXFLOAT16( CONST D3DXFLOAT16& ); - - // casting - operator FLOAT (); - - // binary operators - BOOL operator == ( CONST D3DXFLOAT16& ) const; - BOOL operator != ( CONST D3DXFLOAT16& ) const; - -protected: -#endif //__cplusplus - WORD value; -} D3DXFLOAT16, *LPD3DXFLOAT16; - - - -//=========================================================================== -// -// Vectors -// -//=========================================================================== - - -//-------------------------- -// 2D Vector -//-------------------------- -typedef struct D3DXVECTOR2 -{ -#ifdef __cplusplus -public: - D3DXVECTOR2() {}; - D3DXVECTOR2( CONST FLOAT * ); - D3DXVECTOR2( CONST D3DXFLOAT16 * ); - D3DXVECTOR2( FLOAT x, FLOAT y ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR2& operator += ( CONST D3DXVECTOR2& ); - D3DXVECTOR2& operator -= ( CONST D3DXVECTOR2& ); - D3DXVECTOR2& operator *= ( FLOAT ); - D3DXVECTOR2& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR2 operator + () const; - D3DXVECTOR2 operator - () const; - - // binary operators - D3DXVECTOR2 operator + ( CONST D3DXVECTOR2& ) const; - D3DXVECTOR2 operator - ( CONST D3DXVECTOR2& ) const; - D3DXVECTOR2 operator * ( FLOAT ) const; - D3DXVECTOR2 operator / ( FLOAT ) const; - - friend D3DXVECTOR2 operator * ( FLOAT, CONST D3DXVECTOR2& ); - - BOOL operator == ( CONST D3DXVECTOR2& ) const; - BOOL operator != ( CONST D3DXVECTOR2& ) const; - - -public: -#endif //__cplusplus - FLOAT x, y; -} D3DXVECTOR2, *LPD3DXVECTOR2; - - - -//-------------------------- -// 2D Vector (16 bit) -//-------------------------- - -typedef struct D3DXVECTOR2_16F -{ -#ifdef __cplusplus -public: - D3DXVECTOR2_16F() {}; - D3DXVECTOR2_16F( CONST FLOAT * ); - D3DXVECTOR2_16F( CONST D3DXFLOAT16 * ); - D3DXVECTOR2_16F( CONST D3DXFLOAT16 &x, CONST D3DXFLOAT16 &y ); - - // casting - operator D3DXFLOAT16* (); - operator CONST D3DXFLOAT16* () const; - - // binary operators - BOOL operator == ( CONST D3DXVECTOR2_16F& ) const; - BOOL operator != ( CONST D3DXVECTOR2_16F& ) const; - -public: -#endif //__cplusplus - D3DXFLOAT16 x, y; - -} D3DXVECTOR2_16F, *LPD3DXVECTOR2_16F; - - - -//-------------------------- -// 3D Vector -//-------------------------- -#ifdef __cplusplus -typedef struct D3DXVECTOR3 : public D3DVECTOR -{ -public: - D3DXVECTOR3() {}; - D3DXVECTOR3( CONST FLOAT * ); - D3DXVECTOR3( CONST D3DVECTOR& ); - D3DXVECTOR3( CONST D3DXFLOAT16 * ); - D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); - D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& ); - D3DXVECTOR3& operator *= ( FLOAT ); - D3DXVECTOR3& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR3 operator + () const; - D3DXVECTOR3 operator - () const; - - // binary operators - D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const; - D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const; - D3DXVECTOR3 operator * ( FLOAT ) const; - D3DXVECTOR3 operator / ( FLOAT ) const; - - friend D3DXVECTOR3 operator * ( FLOAT, CONST struct D3DXVECTOR3& ); - - BOOL operator == ( CONST D3DXVECTOR3& ) const; - BOOL operator != ( CONST D3DXVECTOR3& ) const; - -} D3DXVECTOR3, *LPD3DXVECTOR3; - -#else //!__cplusplus -typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; -#endif //!__cplusplus - - - -//-------------------------- -// 3D Vector (16 bit) -//-------------------------- -typedef struct D3DXVECTOR3_16F -{ -#ifdef __cplusplus -public: - D3DXVECTOR3_16F() {}; - D3DXVECTOR3_16F( CONST FLOAT * ); - D3DXVECTOR3_16F( CONST D3DVECTOR& ); - D3DXVECTOR3_16F( CONST D3DXFLOAT16 * ); - D3DXVECTOR3_16F( CONST D3DXFLOAT16 &x, CONST D3DXFLOAT16 &y, CONST D3DXFLOAT16 &z ); - - // casting - operator D3DXFLOAT16* (); - operator CONST D3DXFLOAT16* () const; - - // binary operators - BOOL operator == ( CONST D3DXVECTOR3_16F& ) const; - BOOL operator != ( CONST D3DXVECTOR3_16F& ) const; - -public: -#endif //__cplusplus - D3DXFLOAT16 x, y, z; - -} D3DXVECTOR3_16F, *LPD3DXVECTOR3_16F; - - - -//-------------------------- -// 4D Vector -//-------------------------- -typedef struct D3DXVECTOR4 -{ -#ifdef __cplusplus -public: - D3DXVECTOR4() {}; - D3DXVECTOR4( CONST FLOAT* ); - D3DXVECTOR4( CONST D3DXFLOAT16* ); - D3DXVECTOR4( CONST D3DVECTOR& xyz, FLOAT w ); - D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& ); - D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& ); - D3DXVECTOR4& operator *= ( FLOAT ); - D3DXVECTOR4& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR4 operator + () const; - D3DXVECTOR4 operator - () const; - - // binary operators - D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const; - D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const; - D3DXVECTOR4 operator * ( FLOAT ) const; - D3DXVECTOR4 operator / ( FLOAT ) const; - - friend D3DXVECTOR4 operator * ( FLOAT, CONST D3DXVECTOR4& ); - - BOOL operator == ( CONST D3DXVECTOR4& ) const; - BOOL operator != ( CONST D3DXVECTOR4& ) const; - -public: -#endif //__cplusplus - FLOAT x, y, z, w; -} D3DXVECTOR4, *LPD3DXVECTOR4; - - -//-------------------------- -// 4D Vector (16 bit) -//-------------------------- -typedef struct D3DXVECTOR4_16F -{ -#ifdef __cplusplus -public: - D3DXVECTOR4_16F() {}; - D3DXVECTOR4_16F( CONST FLOAT * ); - D3DXVECTOR4_16F( CONST D3DXFLOAT16* ); - D3DXVECTOR4_16F( CONST D3DXVECTOR3_16F& xyz, CONST D3DXFLOAT16& w ); - D3DXVECTOR4_16F( CONST D3DXFLOAT16& x, CONST D3DXFLOAT16& y, CONST D3DXFLOAT16& z, CONST D3DXFLOAT16& w ); - - // casting - operator D3DXFLOAT16* (); - operator CONST D3DXFLOAT16* () const; - - // binary operators - BOOL operator == ( CONST D3DXVECTOR4_16F& ) const; - BOOL operator != ( CONST D3DXVECTOR4_16F& ) const; - -public: -#endif //__cplusplus - D3DXFLOAT16 x, y, z, w; - -} D3DXVECTOR4_16F, *LPD3DXVECTOR4_16F; - - - -//=========================================================================== -// -// Matrices -// -//=========================================================================== -#ifdef __cplusplus -typedef struct D3DXMATRIX : public D3DMATRIX -{ -public: - D3DXMATRIX() {}; - D3DXMATRIX( CONST FLOAT * ); - D3DXMATRIX( CONST D3DMATRIX& ); - D3DXMATRIX( CONST D3DXFLOAT16 * ); - D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, - FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, - FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, - FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); - - - // access grants - FLOAT& operator () ( UINT Row, UINT Col ); - FLOAT operator () ( UINT Row, UINT Col ) const; - - // casting operators - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXMATRIX& operator *= ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator += ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator -= ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator *= ( FLOAT ); - D3DXMATRIX& operator /= ( FLOAT ); - - // unary operators - D3DXMATRIX operator + () const; - D3DXMATRIX operator - () const; - - // binary operators - D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator * ( FLOAT ) const; - D3DXMATRIX operator / ( FLOAT ) const; - - friend D3DXMATRIX operator * ( FLOAT, CONST D3DXMATRIX& ); - - BOOL operator == ( CONST D3DXMATRIX& ) const; - BOOL operator != ( CONST D3DXMATRIX& ) const; - -} D3DXMATRIX, *LPD3DXMATRIX; - -#else //!__cplusplus -typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; -#endif //!__cplusplus - - -//--------------------------------------------------------------------------- -// Aligned Matrices -// -// This class helps keep matrices 16-byte aligned as preferred by P4 cpus. -// It aligns matrices on the stack and on the heap or in global scope. -// It does this using __declspec(align(16)) which works on VC7 and on VC 6 -// with the processor pack. Unfortunately there is no way to detect the -// latter so this is turned on only on VC7. On other compilers this is the -// the same as D3DXMATRIX. -// -// Using this class on a compiler that does not actually do the alignment -// can be dangerous since it will not expose bugs that ignore alignment. -// E.g if an object of this class in inside a struct or class, and some code -// memcopys data in it assuming tight packing. This could break on a compiler -// that eventually start aligning the matrix. -//--------------------------------------------------------------------------- -#ifdef __cplusplus -typedef struct _D3DXMATRIXA16 : public D3DXMATRIX -{ - _D3DXMATRIXA16() {} - _D3DXMATRIXA16( CONST FLOAT * ); - _D3DXMATRIXA16( CONST D3DMATRIX& ); - _D3DXMATRIXA16( CONST D3DXFLOAT16 * ); - _D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, - FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, - FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, - FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); - - // new operators - void* operator new ( size_t ); - void* operator new[] ( size_t ); - - // delete operators - void operator delete ( void* ); // These are NOT virtual; Do not - void operator delete[] ( void* ); // cast to D3DXMATRIX and delete. - - // assignment operators - _D3DXMATRIXA16& operator = ( CONST D3DXMATRIX& ); - -} _D3DXMATRIXA16; - -#else //!__cplusplus -typedef D3DXMATRIX _D3DXMATRIXA16; -#endif //!__cplusplus - - - -#if _MSC_VER >= 1300 // VC7 -#define D3DX_ALIGN16 __declspec(align(16)) -#else -#define D3DX_ALIGN16 // Earlier compiler may not understand this, do nothing. -#endif - -typedef D3DX_ALIGN16 _D3DXMATRIXA16 D3DXMATRIXA16, *LPD3DXMATRIXA16; - - - -//=========================================================================== -// -// Quaternions -// -//=========================================================================== -typedef struct D3DXQUATERNION -{ -#ifdef __cplusplus -public: - D3DXQUATERNION() {} - D3DXQUATERNION( CONST FLOAT * ); - D3DXQUATERNION( CONST D3DXFLOAT16 * ); - D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXQUATERNION& operator += ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator -= ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator *= ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator *= ( FLOAT ); - D3DXQUATERNION& operator /= ( FLOAT ); - - // unary operators - D3DXQUATERNION operator + () const; - D3DXQUATERNION operator - () const; - - // binary operators - D3DXQUATERNION operator + ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator - ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator * ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator * ( FLOAT ) const; - D3DXQUATERNION operator / ( FLOAT ) const; - - friend D3DXQUATERNION operator * (FLOAT, CONST D3DXQUATERNION& ); - - BOOL operator == ( CONST D3DXQUATERNION& ) const; - BOOL operator != ( CONST D3DXQUATERNION& ) const; - -#endif //__cplusplus - FLOAT x, y, z, w; -} D3DXQUATERNION, *LPD3DXQUATERNION; - - -//=========================================================================== -// -// Planes -// -//=========================================================================== -typedef struct D3DXPLANE -{ -#ifdef __cplusplus -public: - D3DXPLANE() {} - D3DXPLANE( CONST FLOAT* ); - D3DXPLANE( CONST D3DXFLOAT16* ); - D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXPLANE& operator *= ( FLOAT ); - D3DXPLANE& operator /= ( FLOAT ); - - // unary operators - D3DXPLANE operator + () const; - D3DXPLANE operator - () const; - - // binary operators - D3DXPLANE operator * ( FLOAT ) const; - D3DXPLANE operator / ( FLOAT ) const; - - friend D3DXPLANE operator * ( FLOAT, CONST D3DXPLANE& ); - - BOOL operator == ( CONST D3DXPLANE& ) const; - BOOL operator != ( CONST D3DXPLANE& ) const; - -#endif //__cplusplus - FLOAT a, b, c, d; -} D3DXPLANE, *LPD3DXPLANE; - - -//=========================================================================== -// -// Colors -// -//=========================================================================== - -typedef struct D3DXCOLOR -{ -#ifdef __cplusplus -public: - D3DXCOLOR() {} - D3DXCOLOR( DWORD argb ); - D3DXCOLOR( CONST FLOAT * ); - D3DXCOLOR( CONST D3DXFLOAT16 * ); - D3DXCOLOR( CONST D3DCOLORVALUE& ); - D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); - - // casting - operator DWORD () const; - - operator FLOAT* (); - operator CONST FLOAT* () const; - - operator D3DCOLORVALUE* (); - operator CONST D3DCOLORVALUE* () const; - - operator D3DCOLORVALUE& (); - operator CONST D3DCOLORVALUE& () const; - - // assignment operators - D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); - D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); - D3DXCOLOR& operator *= ( FLOAT ); - D3DXCOLOR& operator /= ( FLOAT ); - - // unary operators - D3DXCOLOR operator + () const; - D3DXCOLOR operator - () const; - - // binary operators - D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; - D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; - D3DXCOLOR operator * ( FLOAT ) const; - D3DXCOLOR operator / ( FLOAT ) const; - - friend D3DXCOLOR operator * ( FLOAT, CONST D3DXCOLOR& ); - - BOOL operator == ( CONST D3DXCOLOR& ) const; - BOOL operator != ( CONST D3DXCOLOR& ) const; - -#endif //__cplusplus - FLOAT r, g, b, a; -} D3DXCOLOR, *LPD3DXCOLOR; - - - -//=========================================================================== -// -// D3DX math functions: -// -// NOTE: -// * All these functions can take the same object as in and out parameters. -// -// * Out parameters are typically also returned as return values, so that -// the output of one function may be used as a parameter to another. -// -//=========================================================================== - -//-------------------------- -// Float16 -//-------------------------- - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Converts an array 32-bit floats to 16-bit floats -D3DXFLOAT16* WINAPI D3DXFloat32To16Array - ( D3DXFLOAT16 *pOut, CONST FLOAT *pIn, UINT n ); - -// Converts an array 16-bit floats to 32-bit floats -FLOAT* WINAPI D3DXFloat16To32Array - ( FLOAT *pOut, CONST D3DXFLOAT16 *pIn, UINT n ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// 2D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec2Length - ( CONST D3DXVECTOR2 *pV ); - -FLOAT D3DXVec2LengthSq - ( CONST D3DXVECTOR2 *pV ); - -FLOAT D3DXVec2Dot - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Z component of ((x1,y1,0) cross (x2,y2,0)) -FLOAT D3DXVec2CCW - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Add - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Subtract - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2) -D3DXVECTOR2* D3DXVec2Minimize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2) -D3DXVECTOR2* D3DXVec2Maximize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Scale - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR2* D3DXVec2Lerp - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -D3DXVECTOR2* WINAPI D3DXVec2Normalize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR2* WINAPI D3DXVec2Hermite - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, - CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR2* WINAPI D3DXVec2CatmullRom - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, - CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR2* WINAPI D3DXVec2BaryCentric - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, - CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); - -// Transform (x, y, 0, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec2Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, 0, 1) by matrix, project result back into w=1. -D3DXVECTOR2* WINAPI D3DXVec2TransformCoord - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, 0, 0) by matrix. -D3DXVECTOR2* WINAPI D3DXVec2TransformNormal - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -// Transform Array (x, y, 0, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec2TransformArray - ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n); - -// Transform Array (x, y, 0, 1) by matrix, project result back into w=1. -D3DXVECTOR2* WINAPI D3DXVec2TransformCoordArray - ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); - -// Transform Array (x, y, 0, 0) by matrix. -D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray - ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); - - - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// 3D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec3Length - ( CONST D3DXVECTOR3 *pV ); - -FLOAT D3DXVec3LengthSq - ( CONST D3DXVECTOR3 *pV ); - -FLOAT D3DXVec3Dot - ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Cross - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Add - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Subtract - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... -D3DXVECTOR3* D3DXVec3Minimize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... -D3DXVECTOR3* D3DXVec3Maximize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Scale - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR3* D3DXVec3Lerp - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -D3DXVECTOR3* WINAPI D3DXVec3Normalize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR3* WINAPI D3DXVec3Hermite - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, - CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR3* WINAPI D3DXVec3CatmullRom - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, - CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR3* WINAPI D3DXVec3BaryCentric - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); - -// Transform (x, y, z, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec3Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, z, 1) by matrix, project result back into w=1. -D3DXVECTOR3* WINAPI D3DXVec3TransformCoord - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the -// transpose of the inverse of the matrix you would use to transform a coord. -D3DXVECTOR3* WINAPI D3DXVec3TransformNormal - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - - -// Transform Array (x, y, z, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec3TransformArray - ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); - -// Transform Array (x, y, z, 1) by matrix, project result back into w=1. -D3DXVECTOR3* WINAPI D3DXVec3TransformCoordArray - ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); - -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the -// transpose of the inverse of the matrix you would use to transform a coord. -D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray - ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); - -// Project vector from object space into screen space -D3DXVECTOR3* WINAPI D3DXVec3Project - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport, - CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); - -// Project vector from screen space into object space -D3DXVECTOR3* WINAPI D3DXVec3Unproject - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport, - CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); - -// Project vector Array from object space into screen space -D3DXVECTOR3* WINAPI D3DXVec3ProjectArray - ( D3DXVECTOR3 *pOut, UINT OutStride,CONST D3DXVECTOR3 *pV, UINT VStride,CONST D3DVIEWPORT9 *pViewport, - CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n); - -// Project vector Array from screen space into object space -D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray - ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DVIEWPORT9 *pViewport, - CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n); - - -#ifdef __cplusplus -} -#endif - - - -//-------------------------- -// 4D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec4Length - ( CONST D3DXVECTOR4 *pV ); - -FLOAT D3DXVec4LengthSq - ( CONST D3DXVECTOR4 *pV ); - -FLOAT D3DXVec4Dot - ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ); - -D3DXVECTOR4* D3DXVec4Add - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -D3DXVECTOR4* D3DXVec4Subtract - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... -D3DXVECTOR4* D3DXVec4Minimize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... -D3DXVECTOR4* D3DXVec4Maximize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -D3DXVECTOR4* D3DXVec4Scale - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR4* D3DXVec4Lerp - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Cross-product in 4 dimensions. -D3DXVECTOR4* WINAPI D3DXVec4Cross - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - CONST D3DXVECTOR4 *pV3); - -D3DXVECTOR4* WINAPI D3DXVec4Normalize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR4* WINAPI D3DXVec4Hermite - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, - CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR4* WINAPI D3DXVec4CatmullRom - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, - CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR4* WINAPI D3DXVec4BaryCentric - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); - -// Transform vector by matrix. -D3DXVECTOR4* WINAPI D3DXVec4Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); - -// Transform vector array by matrix. -D3DXVECTOR4* WINAPI D3DXVec4TransformArray - ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR4 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// 4D Matrix -//-------------------------- - -// inline - -D3DXMATRIX* D3DXMatrixIdentity - ( D3DXMATRIX *pOut ); - -BOOL D3DXMatrixIsIdentity - ( CONST D3DXMATRIX *pM ); - - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -FLOAT WINAPI D3DXMatrixDeterminant - ( CONST D3DXMATRIX *pM ); - -HRESULT WINAPI D3DXMatrixDecompose - ( D3DXVECTOR3 *pOutScale, D3DXQUATERNION *pOutRotation, - D3DXVECTOR3 *pOutTranslation, CONST D3DXMATRIX *pM ); - -D3DXMATRIX* WINAPI D3DXMatrixTranspose - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); - -// Matrix multiplication. The result represents the transformation M2 -// followed by the transformation M1. (Out = M1 * M2) -D3DXMATRIX* WINAPI D3DXMatrixMultiply - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); - -// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) -D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); - -// Calculate inverse of matrix. Inversion my fail, in which case NULL will -// be returned. The determinant of pM is also returned it pfDeterminant -// is non-NULL. -D3DXMATRIX* WINAPI D3DXMatrixInverse - ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); - -// Build a matrix which scales by (sx, sy, sz) -D3DXMATRIX* WINAPI D3DXMatrixScaling - ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); - -// Build a matrix which translates by (x, y, z) -D3DXMATRIX* WINAPI D3DXMatrixTranslation - ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); - -// Build a matrix which rotates around the X axis -D3DXMATRIX* WINAPI D3DXMatrixRotationX - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around the Y axis -D3DXMATRIX* WINAPI D3DXMatrixRotationY - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around the Z axis -D3DXMATRIX* WINAPI D3DXMatrixRotationZ - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around an arbitrary axis -D3DXMATRIX* WINAPI D3DXMatrixRotationAxis - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); - -// Build a matrix from a quaternion -D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion - ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); - -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. -D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll - ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); - -// Build transformation matrix. NULL arguments are treated as identity. -// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixTransformation - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, - CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, - CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, - CONST D3DXVECTOR3 *pTranslation); - -// Build 2D transformation matrix in XY plane. NULL arguments are treated as identity. -// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixTransformation2D - ( D3DXMATRIX *pOut, CONST D3DXVECTOR2* pScalingCenter, - FLOAT ScalingRotation, CONST D3DXVECTOR2* pScaling, - CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, - CONST D3DXVECTOR2* pTranslation); - -// Build affine transformation matrix. NULL arguments are treated as identity. -// Mout = Ms * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation - ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, - CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); - -// Build 2D affine transformation matrix in XY plane. NULL arguments are treated as identity. -// Mout = Ms * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation2D - ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR2* pRotationCenter, - FLOAT Rotation, CONST D3DXVECTOR2* pTranslation); - -// Build a lookat matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixLookAtRH - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, - CONST D3DXVECTOR3 *pUp ); - -// Build a lookat matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixLookAtLH - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, - CONST D3DXVECTOR3 *pUp ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH - ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH - ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build an ortho projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoRH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build an ortho projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoLH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build an ortho projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build an ortho projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build a matrix which flattens geometry into a plane, as if casting -// a shadow from a light. -D3DXMATRIX* WINAPI D3DXMatrixShadow - ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, - CONST D3DXPLANE *pPlane ); - -// Build a matrix which reflects the coordinate system about a plane -D3DXMATRIX* WINAPI D3DXMatrixReflect - ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Quaternion -//-------------------------- - -// inline - -FLOAT D3DXQuaternionLength - ( CONST D3DXQUATERNION *pQ ); - -// Length squared, or "norm" -FLOAT D3DXQuaternionLengthSq - ( CONST D3DXQUATERNION *pQ ); - -FLOAT D3DXQuaternionDot - ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); - -// (0, 0, 0, 1) -D3DXQUATERNION* D3DXQuaternionIdentity - ( D3DXQUATERNION *pOut ); - -BOOL D3DXQuaternionIsIdentity - ( CONST D3DXQUATERNION *pQ ); - -// (-x, -y, -z, w) -D3DXQUATERNION* D3DXQuaternionConjugate - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. -void WINAPI D3DXQuaternionToAxisAngle - ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); - -// Build a quaternion from a rotation matrix. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix - ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); - -// Rotation about arbitrary axis. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis - ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); - -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll - ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); - -// Quaternion multiplication. The result represents the rotation Q2 -// followed by the rotation Q1. (Out = Q2 * Q1) -D3DXQUATERNION* WINAPI D3DXQuaternionMultiply - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2 ); - -D3DXQUATERNION* WINAPI D3DXQuaternionNormalize - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Conjugate and re-norm -D3DXQUATERNION* WINAPI D3DXQuaternionInverse - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Expects unit quaternions. -// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) -D3DXQUATERNION* WINAPI D3DXQuaternionLn - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Expects pure quaternions. (w == 0) w is ignored in calculation. -// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) -D3DXQUATERNION* WINAPI D3DXQuaternionExp - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). -// Expects unit quaternions. -D3DXQUATERNION* WINAPI D3DXQuaternionSlerp - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, FLOAT t ); - -// Spherical quadrangle interpolation. -// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) -D3DXQUATERNION* WINAPI D3DXQuaternionSquad - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, - CONST D3DXQUATERNION *pC, FLOAT t ); - -// Setup control points for spherical quadrangle interpolation -// from Q1 to Q2. The control points are chosen in such a way -// to ensure the continuity of tangents with adjacent segments. -void WINAPI D3DXQuaternionSquadSetup - ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, - CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); - -// Barycentric interpolation. -// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) -D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, - FLOAT f, FLOAT g ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Plane -//-------------------------- - -// inline - -// ax + by + cz + dw -FLOAT D3DXPlaneDot - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); - -// ax + by + cz + d -FLOAT D3DXPlaneDotCoord - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); - -// ax + by + cz -FLOAT D3DXPlaneDotNormal - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); - -D3DXPLANE* D3DXPlaneScale - (D3DXPLANE *pOut, CONST D3DXPLANE *pP, FLOAT s); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Normalize plane (so that |a,b,c| == 1) -D3DXPLANE* WINAPI D3DXPlaneNormalize - ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); - -// Find the intersection between a plane and a line. If the line is -// parallel to the plane, NULL is returned. -D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine - ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, - CONST D3DXVECTOR3 *pV2); - -// Construct a plane from a point and a normal -D3DXPLANE* WINAPI D3DXPlaneFromPointNormal - ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); - -// Construct a plane from 3 points -D3DXPLANE* WINAPI D3DXPlaneFromPoints - ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - CONST D3DXVECTOR3 *pV3); - -// 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* WINAPI D3DXPlaneTransform - ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); - -// Transform an array of planes by a matrix. The vectors (a,b,c) must be normal. -// M should be the inverse transpose of the transformation desired. -D3DXPLANE* WINAPI D3DXPlaneTransformArray - ( D3DXPLANE *pOut, UINT OutStride, CONST D3DXPLANE *pP, UINT PStride, CONST D3DXMATRIX *pM, UINT n ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Color -//-------------------------- - -// inline - -// (1-r, 1-g, 1-b, a) -D3DXCOLOR* D3DXColorNegative - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); - -D3DXCOLOR* D3DXColorAdd - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -D3DXCOLOR* D3DXColorSubtract - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -D3DXCOLOR* D3DXColorScale - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); - -// (r1*r2, g1*g2, b1*b2, a1*a2) -D3DXCOLOR* D3DXColorModulate - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) -D3DXCOLOR* D3DXColorLerp - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Interpolate r,g,b between desaturated color and color. -// DesaturatedColor + s(Color - DesaturatedColor) -D3DXCOLOR* WINAPI D3DXColorAdjustSaturation - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); - -// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) -D3DXCOLOR* WINAPI D3DXColorAdjustContrast - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); - -#ifdef __cplusplus -} -#endif - - - - -//-------------------------- -// Misc -//-------------------------- - -#ifdef __cplusplus -extern "C" { -#endif - -// Calculate Fresnel term given the cosine of theta (likely obtained by -// taking the dot of two normals), and the refraction index of the material. -FLOAT WINAPI D3DXFresnelTerm - (FLOAT CosTheta, FLOAT RefractionIndex); - -#ifdef __cplusplus -} -#endif - - - -//=========================================================================== -// -// Matrix Stack -// -//=========================================================================== - -typedef interface ID3DXMatrixStack ID3DXMatrixStack; -typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; - -// {C7885BA7-F990-4fe7-922D-8515E477DD85} -DEFINE_GUID(IID_ID3DXMatrixStack, -0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85); - - -#undef INTERFACE -#define INTERFACE ID3DXMatrixStack - -DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) -{ - // - // IUnknown methods - // - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - // - // ID3DXMatrixStack methods - // - - // Pops the top of the stack, returns the current top - // *after* popping the top. - STDMETHOD(Pop)(THIS) PURE; - - // Pushes the stack by one, duplicating the current matrix. - STDMETHOD(Push)(THIS) PURE; - - // Loads identity in the current matrix. - STDMETHOD(LoadIdentity)(THIS) PURE; - - // Loads the given matrix into the current matrix - STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Right-Multiplies the given matrix to the current matrix. - // (transformation is about the current world origin) - STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Left-Multiplies the given matrix to the current matrix - // (transformation is about the local origin of the object) - STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Right multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the current world origin) - STDMETHOD(RotateAxis) - (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - - // 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) - STDMETHOD(RotateAxisLocal) - (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - - // Right multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // current world origin) - - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. - STDMETHOD(RotateYawPitchRoll) - (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - - // Left multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // local origin of the object) - - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. - STDMETHOD(RotateYawPitchRollLocal) - (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - - // Right multiply the current matrix with the computed scale - // matrix. (transformation is about the current world origin) - STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - // Left multiply the current matrix with the computed scale - // matrix. (transformation is about the local origin of the object) - STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - // Right multiply the current matrix with the computed translation - // matrix. (transformation is about the current world origin) - STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; - - // Left multiply the current matrix with the computed translation - // matrix. (transformation is about the local origin of the object) - STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - // Obtain the current matrix at the top of the stack - STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; -}; - -#ifdef __cplusplus -extern "C" { -#endif - -HRESULT WINAPI - D3DXCreateMatrixStack( - DWORD Flags, - LPD3DXMATRIXSTACK* ppStack); - -#ifdef __cplusplus -} -#endif - -//=========================================================================== -// -// Spherical Harmonic Runtime Routines -// -// NOTE: -// * Most of these functions can take the same object as in and out parameters. -// The exceptions are the rotation functions. -// -// * Out parameters are typically also returned as return values, so that -// the output of one function may be used as a parameter to another. -// -//============================================================================ - - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -//============================================================================ -// -// Basic Spherical Harmonic math routines -// -//============================================================================ - -#define D3DXSH_MINORDER 2 -#define D3DXSH_MAXORDER 6 - -//============================================================================ -// -// D3DXSHEvalDirection: -// -------------------- -// Evaluates the Spherical Harmonic basis functions -// -// Parameters: -// pOut -// Output SH coefficients - basis function Ylm is stored at l*l + m+l -// This is the pointer that is returned. -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pDir -// Direction to evaluate in - assumed to be normalized -// -//============================================================================ - -FLOAT* WINAPI D3DXSHEvalDirection - ( FLOAT *pOut, UINT Order, CONST D3DXVECTOR3 *pDir ); - -//============================================================================ -// -// D3DXSHRotate: -// -------------------- -// Rotates SH vector by a rotation matrix -// -// Parameters: -// pOut -// Output SH coefficients - basis function Ylm is stored at l*l + m+l -// This is the pointer that is returned (should not alias with pIn.) -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pMatrix -// Matrix used for rotation - rotation sub matrix should be orthogonal -// and have a unit determinant. -// pIn -// Input SH coeffs (rotated), incorect results if this is also output. -// -//============================================================================ - -FLOAT* WINAPI D3DXSHRotate - ( FLOAT *pOut, UINT Order, CONST D3DXMATRIX *pMatrix, CONST FLOAT *pIn ); - -//============================================================================ -// -// D3DXSHRotateZ: -// -------------------- -// Rotates the SH vector in the Z axis by an angle -// -// Parameters: -// pOut -// Output SH coefficients - basis function Ylm is stored at l*l + m+l -// This is the pointer that is returned (should not alias with pIn.) -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// Angle -// Angle in radians to rotate around the Z axis. -// pIn -// Input SH coeffs (rotated), incorect results if this is also output. -// -//============================================================================ - - -FLOAT* WINAPI D3DXSHRotateZ - ( FLOAT *pOut, UINT Order, FLOAT Angle, CONST FLOAT *pIn ); - -//============================================================================ -// -// D3DXSHAdd: -// -------------------- -// Adds two SH vectors, pOut[i] = pA[i] + pB[i]; -// -// Parameters: -// pOut -// Output SH coefficients - basis function Ylm is stored at l*l + m+l -// This is the pointer that is returned. -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pA -// Input SH coeffs. -// pB -// Input SH coeffs (second vector.) -// -//============================================================================ - -FLOAT* WINAPI D3DXSHAdd - ( FLOAT *pOut, UINT Order, CONST FLOAT *pA, CONST FLOAT *pB ); - -//============================================================================ -// -// D3DXSHScale: -// -------------------- -// Adds two SH vectors, pOut[i] = pA[i]*Scale; -// -// Parameters: -// pOut -// Output SH coefficients - basis function Ylm is stored at l*l + m+l -// This is the pointer that is returned. -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pIn -// Input SH coeffs. -// Scale -// Scale factor. -// -//============================================================================ - -FLOAT* WINAPI D3DXSHScale - ( FLOAT *pOut, UINT Order, CONST FLOAT *pIn, CONST FLOAT Scale ); - -//============================================================================ -// -// D3DXSHDot: -// -------------------- -// Computes the dot product of two SH vectors -// -// Parameters: -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pA -// Input SH coeffs. -// pB -// Second set of input SH coeffs. -// -//============================================================================ - -FLOAT WINAPI D3DXSHDot - ( UINT Order, CONST FLOAT *pA, CONST FLOAT *pB ); - -//============================================================================ -// -// Basic Spherical Harmonic lighting routines -// -//============================================================================ - -//============================================================================ -// -// D3DXSHEvalDirectionalLight: -// -------------------- -// Evaluates a directional light and returns spectral SH data. The output -// vector is computed so that if the intensity of R/G/B is unit the resulting -// exit radiance of a point directly under the light on a diffuse object with -// an albedo of 1 would be 1.0. This will compute 3 spectral samples, pROut -// has to be specified, while pGout and pBout are optional. -// -// Parameters: -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pDir -// Direction light is coming from (assumed to be normalized.) -// RIntensity -// Red intensity of light. -// GIntensity -// Green intensity of light. -// BIntensity -// Blue intensity of light. -// pROut -// Output SH vector for Red. -// pGOut -// Output SH vector for Green (optional.) -// pBOut -// Output SH vector for Blue (optional.) -// -//============================================================================ - -HRESULT WINAPI D3DXSHEvalDirectionalLight - ( UINT Order, CONST D3DXVECTOR3 *pDir, - FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, - FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); - -//============================================================================ -// -// D3DXSHEvalSphericalLight: -// -------------------- -// Evaluates a spherical light and returns spectral SH data. There is no -// normalization of the intensity of the light like there is for directional -// lights, care has to be taken when specifiying the intensities. This will -// compute 3 spectral samples, pROut has to be specified, while pGout and -// pBout are optional. -// -// Parameters: -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pPos -// Position of light - reciever is assumed to be at the origin. -// Radius -// Radius of the spherical light source. -// RIntensity -// Red intensity of light. -// GIntensity -// Green intensity of light. -// BIntensity -// Blue intensity of light. -// pROut -// Output SH vector for Red. -// pGOut -// Output SH vector for Green (optional.) -// pBOut -// Output SH vector for Blue (optional.) -// -//============================================================================ - -HRESULT WINAPI D3DXSHEvalSphericalLight - ( UINT Order, CONST D3DXVECTOR3 *pPos, FLOAT Radius, - FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, - FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); - -//============================================================================ -// -// D3DXSHEvalConeLight: -// -------------------- -// Evaluates a light that is a cone of constant intensity and returns spectral -// SH data. The output vector is computed so that if the intensity of R/G/B is -// unit the resulting exit radiance of a point directly under the light oriented -// in the cone direction on a diffuse object with an albedo of 1 would be 1.0. -// This will compute 3 spectral samples, pROut has to be specified, while pGout -// and pBout are optional. -// -// Parameters: -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pDir -// Direction light is coming from (assumed to be normalized.) -// Radius -// Radius of cone in radians. -// RIntensity -// Red intensity of light. -// GIntensity -// Green intensity of light. -// BIntensity -// Blue intensity of light. -// pROut -// Output SH vector for Red. -// pGOut -// Output SH vector for Green (optional.) -// pBOut -// Output SH vector for Blue (optional.) -// -//============================================================================ - -HRESULT WINAPI D3DXSHEvalConeLight - ( UINT Order, CONST D3DXVECTOR3 *pDir, FLOAT Radius, - FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, - FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); - -//============================================================================ -// -// D3DXSHEvalHemisphereLight: -// -------------------- -// Evaluates a light that is a linear interpolant between two colors over the -// sphere. The interpolant is linear along the axis of the two points, not -// over the surface of the sphere (ie: if the axis was (0,0,1) it is linear in -// Z, not in the azimuthal angle.) The resulting spherical lighting function -// is normalized so that a point on a perfectly diffuse surface with no -// shadowing and a normal pointed in the direction pDir would result in exit -// radiance with a value of 1 if the top color was white and the bottom color -// was black. This is a very simple model where Top represents the intensity -// of the "sky" and Bottom represents the intensity of the "ground". -// -// Parameters: -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pDir -// Axis of the hemisphere. -// Top -// Color of the upper hemisphere. -// Bottom -// Color of the lower hemisphere. -// pROut -// Output SH vector for Red. -// pGOut -// Output SH vector for Green -// pBOut -// Output SH vector for Blue -// -//============================================================================ - -HRESULT WINAPI D3DXSHEvalHemisphereLight - ( UINT Order, CONST D3DXVECTOR3 *pDir, D3DXCOLOR Top, D3DXCOLOR Bottom, - FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); - -//============================================================================ -// -// Basic Spherical Harmonic projection routines -// -//============================================================================ - -//============================================================================ -// -// D3DXSHProjectCubeMap: -// -------------------- -// Projects a function represented on a cube map into spherical harmonics. -// -// Parameters: -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pCubeMap -// CubeMap that is going to be projected into spherical harmonics -// pROut -// Output SH vector for Red. -// pGOut -// Output SH vector for Green -// pBOut -// Output SH vector for Blue -// -//============================================================================ - -HRESULT WINAPI D3DXSHProjectCubeMap - ( UINT uOrder, LPDIRECT3DCUBETEXTURE9 pCubeMap, - FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); - - -#ifdef __cplusplus -} -#endif - - -#include "d3dx9math.inl" - -#if _MSC_VER >= 1200 -#pragma warning(pop) -#else -#pragma warning(default:4201) -#endif - -#endif // __D3DX9MATH_H__ - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx9math.h +// Content: D3DX math types and functions +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx9.h" + +#ifndef __D3DX9MATH_H__ +#define __D3DX9MATH_H__ + +#include +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif +#pragma warning(disable:4201) // anonymous unions warning + + + +//=========================================================================== +// +// General purpose utilities +// +//=========================================================================== +#define D3DX_PI ((FLOAT) 3.141592654f) +#define D3DX_1BYPI ((FLOAT) 0.318309886f) + +#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) +#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) + + + +//=========================================================================== +// +// 16 bit floating point numbers +// +//=========================================================================== + +#define D3DX_16F_DIG 3 // # of decimal digits of precision +#define D3DX_16F_EPSILON 4.8875809e-4f // smallest such that 1.0 + epsilon != 1.0 +#define D3DX_16F_MANT_DIG 11 // # of bits in mantissa +#define D3DX_16F_MAX 6.550400e+004 // max value +#define D3DX_16F_MAX_10_EXP 4 // max decimal exponent +#define D3DX_16F_MAX_EXP 15 // max binary exponent +#define D3DX_16F_MIN 6.1035156e-5f // min positive value +#define D3DX_16F_MIN_10_EXP (-4) // min decimal exponent +#define D3DX_16F_MIN_EXP (-14) // min binary exponent +#define D3DX_16F_RADIX 2 // exponent radix +#define D3DX_16F_ROUNDS 1 // addition rounding: near + + +typedef struct D3DXFLOAT16 +{ +#ifdef __cplusplus +public: + D3DXFLOAT16() {}; + D3DXFLOAT16( FLOAT ); + D3DXFLOAT16( CONST D3DXFLOAT16& ); + + // casting + operator FLOAT (); + + // binary operators + BOOL operator == ( CONST D3DXFLOAT16& ) const; + BOOL operator != ( CONST D3DXFLOAT16& ) const; + +protected: +#endif //__cplusplus + WORD value; +} D3DXFLOAT16, *LPD3DXFLOAT16; + + + +//=========================================================================== +// +// Vectors +// +//=========================================================================== + + +//-------------------------- +// 2D Vector +//-------------------------- +typedef struct D3DXVECTOR2 +{ +#ifdef __cplusplus +public: + D3DXVECTOR2() {}; + D3DXVECTOR2( CONST FLOAT * ); + D3DXVECTOR2( CONST D3DXFLOAT16 * ); + D3DXVECTOR2( FLOAT x, FLOAT y ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR2& operator += ( CONST D3DXVECTOR2& ); + D3DXVECTOR2& operator -= ( CONST D3DXVECTOR2& ); + D3DXVECTOR2& operator *= ( FLOAT ); + D3DXVECTOR2& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR2 operator + () const; + D3DXVECTOR2 operator - () const; + + // binary operators + D3DXVECTOR2 operator + ( CONST D3DXVECTOR2& ) const; + D3DXVECTOR2 operator - ( CONST D3DXVECTOR2& ) const; + D3DXVECTOR2 operator * ( FLOAT ) const; + D3DXVECTOR2 operator / ( FLOAT ) const; + + friend D3DXVECTOR2 operator * ( FLOAT, CONST D3DXVECTOR2& ); + + BOOL operator == ( CONST D3DXVECTOR2& ) const; + BOOL operator != ( CONST D3DXVECTOR2& ) const; + + +public: +#endif //__cplusplus + FLOAT x, y; +} D3DXVECTOR2, *LPD3DXVECTOR2; + + + +//-------------------------- +// 2D Vector (16 bit) +//-------------------------- + +typedef struct D3DXVECTOR2_16F +{ +#ifdef __cplusplus +public: + D3DXVECTOR2_16F() {}; + D3DXVECTOR2_16F( CONST FLOAT * ); + D3DXVECTOR2_16F( CONST D3DXFLOAT16 * ); + D3DXVECTOR2_16F( CONST D3DXFLOAT16 &x, CONST D3DXFLOAT16 &y ); + + // casting + operator D3DXFLOAT16* (); + operator CONST D3DXFLOAT16* () const; + + // binary operators + BOOL operator == ( CONST D3DXVECTOR2_16F& ) const; + BOOL operator != ( CONST D3DXVECTOR2_16F& ) const; + +public: +#endif //__cplusplus + D3DXFLOAT16 x, y; + +} D3DXVECTOR2_16F, *LPD3DXVECTOR2_16F; + + + +//-------------------------- +// 3D Vector +//-------------------------- +#ifdef __cplusplus +typedef struct D3DXVECTOR3 : public D3DVECTOR +{ +public: + D3DXVECTOR3() {}; + D3DXVECTOR3( CONST FLOAT * ); + D3DXVECTOR3( CONST D3DVECTOR& ); + D3DXVECTOR3( CONST D3DXFLOAT16 * ); + D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); + D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& ); + D3DXVECTOR3& operator *= ( FLOAT ); + D3DXVECTOR3& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR3 operator + () const; + D3DXVECTOR3 operator - () const; + + // binary operators + D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const; + D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const; + D3DXVECTOR3 operator * ( FLOAT ) const; + D3DXVECTOR3 operator / ( FLOAT ) const; + + friend D3DXVECTOR3 operator * ( FLOAT, CONST struct D3DXVECTOR3& ); + + BOOL operator == ( CONST D3DXVECTOR3& ) const; + BOOL operator != ( CONST D3DXVECTOR3& ) const; + +} D3DXVECTOR3, *LPD3DXVECTOR3; + +#else //!__cplusplus +typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; +#endif //!__cplusplus + + + +//-------------------------- +// 3D Vector (16 bit) +//-------------------------- +typedef struct D3DXVECTOR3_16F +{ +#ifdef __cplusplus +public: + D3DXVECTOR3_16F() {}; + D3DXVECTOR3_16F( CONST FLOAT * ); + D3DXVECTOR3_16F( CONST D3DVECTOR& ); + D3DXVECTOR3_16F( CONST D3DXFLOAT16 * ); + D3DXVECTOR3_16F( CONST D3DXFLOAT16 &x, CONST D3DXFLOAT16 &y, CONST D3DXFLOAT16 &z ); + + // casting + operator D3DXFLOAT16* (); + operator CONST D3DXFLOAT16* () const; + + // binary operators + BOOL operator == ( CONST D3DXVECTOR3_16F& ) const; + BOOL operator != ( CONST D3DXVECTOR3_16F& ) const; + +public: +#endif //__cplusplus + D3DXFLOAT16 x, y, z; + +} D3DXVECTOR3_16F, *LPD3DXVECTOR3_16F; + + + +//-------------------------- +// 4D Vector +//-------------------------- +typedef struct D3DXVECTOR4 +{ +#ifdef __cplusplus +public: + D3DXVECTOR4() {}; + D3DXVECTOR4( CONST FLOAT* ); + D3DXVECTOR4( CONST D3DXFLOAT16* ); + D3DXVECTOR4( CONST D3DVECTOR& xyz, FLOAT w ); + D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& ); + D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& ); + D3DXVECTOR4& operator *= ( FLOAT ); + D3DXVECTOR4& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR4 operator + () const; + D3DXVECTOR4 operator - () const; + + // binary operators + D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const; + D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const; + D3DXVECTOR4 operator * ( FLOAT ) const; + D3DXVECTOR4 operator / ( FLOAT ) const; + + friend D3DXVECTOR4 operator * ( FLOAT, CONST D3DXVECTOR4& ); + + BOOL operator == ( CONST D3DXVECTOR4& ) const; + BOOL operator != ( CONST D3DXVECTOR4& ) const; + +public: +#endif //__cplusplus + FLOAT x, y, z, w; +} D3DXVECTOR4, *LPD3DXVECTOR4; + + +//-------------------------- +// 4D Vector (16 bit) +//-------------------------- +typedef struct D3DXVECTOR4_16F +{ +#ifdef __cplusplus +public: + D3DXVECTOR4_16F() {}; + D3DXVECTOR4_16F( CONST FLOAT * ); + D3DXVECTOR4_16F( CONST D3DXFLOAT16* ); + D3DXVECTOR4_16F( CONST D3DXVECTOR3_16F& xyz, CONST D3DXFLOAT16& w ); + D3DXVECTOR4_16F( CONST D3DXFLOAT16& x, CONST D3DXFLOAT16& y, CONST D3DXFLOAT16& z, CONST D3DXFLOAT16& w ); + + // casting + operator D3DXFLOAT16* (); + operator CONST D3DXFLOAT16* () const; + + // binary operators + BOOL operator == ( CONST D3DXVECTOR4_16F& ) const; + BOOL operator != ( CONST D3DXVECTOR4_16F& ) const; + +public: +#endif //__cplusplus + D3DXFLOAT16 x, y, z, w; + +} D3DXVECTOR4_16F, *LPD3DXVECTOR4_16F; + + + +//=========================================================================== +// +// Matrices +// +//=========================================================================== +#ifdef __cplusplus +typedef struct D3DXMATRIX : public D3DMATRIX +{ +public: + D3DXMATRIX() {}; + D3DXMATRIX( CONST FLOAT * ); + D3DXMATRIX( CONST D3DMATRIX& ); + D3DXMATRIX( CONST D3DXFLOAT16 * ); + D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, + FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, + FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, + FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); + + + // access grants + FLOAT& operator () ( UINT Row, UINT Col ); + FLOAT operator () ( UINT Row, UINT Col ) const; + + // casting operators + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXMATRIX& operator *= ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator += ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator -= ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator *= ( FLOAT ); + D3DXMATRIX& operator /= ( FLOAT ); + + // unary operators + D3DXMATRIX operator + () const; + D3DXMATRIX operator - () const; + + // binary operators + D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator * ( FLOAT ) const; + D3DXMATRIX operator / ( FLOAT ) const; + + friend D3DXMATRIX operator * ( FLOAT, CONST D3DXMATRIX& ); + + BOOL operator == ( CONST D3DXMATRIX& ) const; + BOOL operator != ( CONST D3DXMATRIX& ) const; + +} D3DXMATRIX, *LPD3DXMATRIX; + +#else //!__cplusplus +typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; +#endif //!__cplusplus + + +//--------------------------------------------------------------------------- +// Aligned Matrices +// +// This class helps keep matrices 16-byte aligned as preferred by P4 cpus. +// It aligns matrices on the stack and on the heap or in global scope. +// It does this using __declspec(align(16)) which works on VC7 and on VC 6 +// with the processor pack. Unfortunately there is no way to detect the +// latter so this is turned on only on VC7. On other compilers this is the +// the same as D3DXMATRIX. +// +// Using this class on a compiler that does not actually do the alignment +// can be dangerous since it will not expose bugs that ignore alignment. +// E.g if an object of this class in inside a struct or class, and some code +// memcopys data in it assuming tight packing. This could break on a compiler +// that eventually start aligning the matrix. +//--------------------------------------------------------------------------- +#ifdef __cplusplus +typedef struct _D3DXMATRIXA16 : public D3DXMATRIX +{ + _D3DXMATRIXA16() {} + _D3DXMATRIXA16( CONST FLOAT * ); + _D3DXMATRIXA16( CONST D3DMATRIX& ); + _D3DXMATRIXA16( CONST D3DXFLOAT16 * ); + _D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, + FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, + FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, + FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); + + // new operators + void* operator new ( size_t ); + void* operator new[] ( size_t ); + + // delete operators + void operator delete ( void* ); // These are NOT virtual; Do not + void operator delete[] ( void* ); // cast to D3DXMATRIX and delete. + + // assignment operators + _D3DXMATRIXA16& operator = ( CONST D3DXMATRIX& ); + +} _D3DXMATRIXA16; + +#else //!__cplusplus +typedef D3DXMATRIX _D3DXMATRIXA16; +#endif //!__cplusplus + + + +#if _MSC_VER >= 1300 // VC7 +#define D3DX_ALIGN16 __declspec(align(16)) +#else +#define D3DX_ALIGN16 // Earlier compiler may not understand this, do nothing. +#endif + +typedef D3DX_ALIGN16 _D3DXMATRIXA16 D3DXMATRIXA16, *LPD3DXMATRIXA16; + + + +//=========================================================================== +// +// Quaternions +// +//=========================================================================== +typedef struct D3DXQUATERNION +{ +#ifdef __cplusplus +public: + D3DXQUATERNION() {} + D3DXQUATERNION( CONST FLOAT * ); + D3DXQUATERNION( CONST D3DXFLOAT16 * ); + D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXQUATERNION& operator += ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator -= ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator *= ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator *= ( FLOAT ); + D3DXQUATERNION& operator /= ( FLOAT ); + + // unary operators + D3DXQUATERNION operator + () const; + D3DXQUATERNION operator - () const; + + // binary operators + D3DXQUATERNION operator + ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator - ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator * ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator * ( FLOAT ) const; + D3DXQUATERNION operator / ( FLOAT ) const; + + friend D3DXQUATERNION operator * (FLOAT, CONST D3DXQUATERNION& ); + + BOOL operator == ( CONST D3DXQUATERNION& ) const; + BOOL operator != ( CONST D3DXQUATERNION& ) const; + +#endif //__cplusplus + FLOAT x, y, z, w; +} D3DXQUATERNION, *LPD3DXQUATERNION; + + +//=========================================================================== +// +// Planes +// +//=========================================================================== +typedef struct D3DXPLANE +{ +#ifdef __cplusplus +public: + D3DXPLANE() {} + D3DXPLANE( CONST FLOAT* ); + D3DXPLANE( CONST D3DXFLOAT16* ); + D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXPLANE& operator *= ( FLOAT ); + D3DXPLANE& operator /= ( FLOAT ); + + // unary operators + D3DXPLANE operator + () const; + D3DXPLANE operator - () const; + + // binary operators + D3DXPLANE operator * ( FLOAT ) const; + D3DXPLANE operator / ( FLOAT ) const; + + friend D3DXPLANE operator * ( FLOAT, CONST D3DXPLANE& ); + + BOOL operator == ( CONST D3DXPLANE& ) const; + BOOL operator != ( CONST D3DXPLANE& ) const; + +#endif //__cplusplus + FLOAT a, b, c, d; +} D3DXPLANE, *LPD3DXPLANE; + + +//=========================================================================== +// +// Colors +// +//=========================================================================== + +typedef struct D3DXCOLOR +{ +#ifdef __cplusplus +public: + D3DXCOLOR() {} + D3DXCOLOR( DWORD argb ); + D3DXCOLOR( CONST FLOAT * ); + D3DXCOLOR( CONST D3DXFLOAT16 * ); + D3DXCOLOR( CONST D3DCOLORVALUE& ); + D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); + + // casting + operator DWORD () const; + + operator FLOAT* (); + operator CONST FLOAT* () const; + + operator D3DCOLORVALUE* (); + operator CONST D3DCOLORVALUE* () const; + + operator D3DCOLORVALUE& (); + operator CONST D3DCOLORVALUE& () const; + + // assignment operators + D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); + D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); + D3DXCOLOR& operator *= ( FLOAT ); + D3DXCOLOR& operator /= ( FLOAT ); + + // unary operators + D3DXCOLOR operator + () const; + D3DXCOLOR operator - () const; + + // binary operators + D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; + D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; + D3DXCOLOR operator * ( FLOAT ) const; + D3DXCOLOR operator / ( FLOAT ) const; + + friend D3DXCOLOR operator * ( FLOAT, CONST D3DXCOLOR& ); + + BOOL operator == ( CONST D3DXCOLOR& ) const; + BOOL operator != ( CONST D3DXCOLOR& ) const; + +#endif //__cplusplus + FLOAT r, g, b, a; +} D3DXCOLOR, *LPD3DXCOLOR; + + + +//=========================================================================== +// +// D3DX math functions: +// +// NOTE: +// * All these functions can take the same object as in and out parameters. +// +// * Out parameters are typically also returned as return values, so that +// the output of one function may be used as a parameter to another. +// +//=========================================================================== + +//-------------------------- +// Float16 +//-------------------------- + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Converts an array 32-bit floats to 16-bit floats +D3DXFLOAT16* WINAPI D3DXFloat32To16Array + ( D3DXFLOAT16 *pOut, CONST FLOAT *pIn, UINT n ); + +// Converts an array 16-bit floats to 32-bit floats +FLOAT* WINAPI D3DXFloat16To32Array + ( FLOAT *pOut, CONST D3DXFLOAT16 *pIn, UINT n ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 2D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec2Length + ( CONST D3DXVECTOR2 *pV ); + +FLOAT D3DXVec2LengthSq + ( CONST D3DXVECTOR2 *pV ); + +FLOAT D3DXVec2Dot + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Z component of ((x1,y1,0) cross (x2,y2,0)) +FLOAT D3DXVec2CCW + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Add + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Subtract + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2) +D3DXVECTOR2* D3DXVec2Minimize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2) +D3DXVECTOR2* D3DXVec2Maximize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Scale + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR2* D3DXVec2Lerp + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +D3DXVECTOR2* WINAPI D3DXVec2Normalize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR2* WINAPI D3DXVec2Hermite + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, + CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR2* WINAPI D3DXVec2CatmullRom + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, + CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR2* WINAPI D3DXVec2BaryCentric + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); + +// Transform (x, y, 0, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec2Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, 0, 1) by matrix, project result back into w=1. +D3DXVECTOR2* WINAPI D3DXVec2TransformCoord + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, 0, 0) by matrix. +D3DXVECTOR2* WINAPI D3DXVec2TransformNormal + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +// Transform Array (x, y, 0, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec2TransformArray + ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n); + +// Transform Array (x, y, 0, 1) by matrix, project result back into w=1. +D3DXVECTOR2* WINAPI D3DXVec2TransformCoordArray + ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); + +// Transform Array (x, y, 0, 0) by matrix. +D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray + ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); + + + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 3D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec3Length + ( CONST D3DXVECTOR3 *pV ); + +FLOAT D3DXVec3LengthSq + ( CONST D3DXVECTOR3 *pV ); + +FLOAT D3DXVec3Dot + ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Cross + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Add + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Subtract + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +D3DXVECTOR3* D3DXVec3Minimize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +D3DXVECTOR3* D3DXVec3Maximize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Scale + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR3* D3DXVec3Lerp + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +D3DXVECTOR3* WINAPI D3DXVec3Normalize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR3* WINAPI D3DXVec3Hermite + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, + CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR3* WINAPI D3DXVec3CatmullRom + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, + CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR3* WINAPI D3DXVec3BaryCentric + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); + +// Transform (x, y, z, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec3Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, z, 1) by matrix, project result back into w=1. +D3DXVECTOR3* WINAPI D3DXVec3TransformCoord + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, z, 0) by matrix. If you transforming a normal by a +// non-affine matrix, the matrix you pass to this function should be the +// transpose of the inverse of the matrix you would use to transform a coord. +D3DXVECTOR3* WINAPI D3DXVec3TransformNormal + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + + +// Transform Array (x, y, z, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec3TransformArray + ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); + +// Transform Array (x, y, z, 1) by matrix, project result back into w=1. +D3DXVECTOR3* WINAPI D3DXVec3TransformCoordArray + ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); + +// Transform (x, y, z, 0) by matrix. If you transforming a normal by a +// non-affine matrix, the matrix you pass to this function should be the +// transpose of the inverse of the matrix you would use to transform a coord. +D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray + ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); + +// Project vector from object space into screen space +D3DXVECTOR3* WINAPI D3DXVec3Project + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); + +// Project vector from screen space into object space +D3DXVECTOR3* WINAPI D3DXVec3Unproject + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); + +// Project vector Array from object space into screen space +D3DXVECTOR3* WINAPI D3DXVec3ProjectArray + ( D3DXVECTOR3 *pOut, UINT OutStride,CONST D3DXVECTOR3 *pV, UINT VStride,CONST D3DVIEWPORT9 *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n); + +// Project vector Array from screen space into object space +D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray + ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DVIEWPORT9 *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n); + + +#ifdef __cplusplus +} +#endif + + + +//-------------------------- +// 4D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec4Length + ( CONST D3DXVECTOR4 *pV ); + +FLOAT D3DXVec4LengthSq + ( CONST D3DXVECTOR4 *pV ); + +FLOAT D3DXVec4Dot + ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ); + +D3DXVECTOR4* D3DXVec4Add + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +D3DXVECTOR4* D3DXVec4Subtract + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +D3DXVECTOR4* D3DXVec4Minimize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +D3DXVECTOR4* D3DXVec4Maximize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +D3DXVECTOR4* D3DXVec4Scale + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR4* D3DXVec4Lerp + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Cross-product in 4 dimensions. +D3DXVECTOR4* WINAPI D3DXVec4Cross + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + CONST D3DXVECTOR4 *pV3); + +D3DXVECTOR4* WINAPI D3DXVec4Normalize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR4* WINAPI D3DXVec4Hermite + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, + CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR4* WINAPI D3DXVec4CatmullRom + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, + CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR4* WINAPI D3DXVec4BaryCentric + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); + +// Transform vector by matrix. +D3DXVECTOR4* WINAPI D3DXVec4Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); + +// Transform vector array by matrix. +D3DXVECTOR4* WINAPI D3DXVec4TransformArray + ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR4 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 4D Matrix +//-------------------------- + +// inline + +D3DXMATRIX* D3DXMatrixIdentity + ( D3DXMATRIX *pOut ); + +BOOL D3DXMatrixIsIdentity + ( CONST D3DXMATRIX *pM ); + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +FLOAT WINAPI D3DXMatrixDeterminant + ( CONST D3DXMATRIX *pM ); + +HRESULT WINAPI D3DXMatrixDecompose + ( D3DXVECTOR3 *pOutScale, D3DXQUATERNION *pOutRotation, + D3DXVECTOR3 *pOutTranslation, CONST D3DXMATRIX *pM ); + +D3DXMATRIX* WINAPI D3DXMatrixTranspose + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); + +// Matrix multiplication. The result represents the transformation M2 +// followed by the transformation M1. (Out = M1 * M2) +D3DXMATRIX* WINAPI D3DXMatrixMultiply + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); + +// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) +D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); + +// Calculate inverse of matrix. Inversion my fail, in which case NULL will +// be returned. The determinant of pM is also returned it pfDeterminant +// is non-NULL. +D3DXMATRIX* WINAPI D3DXMatrixInverse + ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); + +// Build a matrix which scales by (sx, sy, sz) +D3DXMATRIX* WINAPI D3DXMatrixScaling + ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); + +// Build a matrix which translates by (x, y, z) +D3DXMATRIX* WINAPI D3DXMatrixTranslation + ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); + +// Build a matrix which rotates around the X axis +D3DXMATRIX* WINAPI D3DXMatrixRotationX + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around the Y axis +D3DXMATRIX* WINAPI D3DXMatrixRotationY + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around the Z axis +D3DXMATRIX* WINAPI D3DXMatrixRotationZ + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around an arbitrary axis +D3DXMATRIX* WINAPI D3DXMatrixRotationAxis + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); + +// Build a matrix from a quaternion +D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion + ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); + +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. +D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll + ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); + +// Build transformation matrix. NULL arguments are treated as identity. +// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixTransformation + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, + CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, + CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, + CONST D3DXVECTOR3 *pTranslation); + +// Build 2D transformation matrix in XY plane. NULL arguments are treated as identity. +// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixTransformation2D + ( D3DXMATRIX *pOut, CONST D3DXVECTOR2* pScalingCenter, + FLOAT ScalingRotation, CONST D3DXVECTOR2* pScaling, + CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, + CONST D3DXVECTOR2* pTranslation); + +// Build affine transformation matrix. NULL arguments are treated as identity. +// Mout = Ms * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation + ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, + CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); + +// Build 2D affine transformation matrix in XY plane. NULL arguments are treated as identity. +// Mout = Ms * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation2D + ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR2* pRotationCenter, + FLOAT Rotation, CONST D3DXVECTOR2* pTranslation); + +// Build a lookat matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixLookAtRH + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, + CONST D3DXVECTOR3 *pUp ); + +// Build a lookat matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixLookAtLH + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, + CONST D3DXVECTOR3 *pUp ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH + ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH + ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoRH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build an ortho projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoLH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build an ortho projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build a matrix which flattens geometry into a plane, as if casting +// a shadow from a light. +D3DXMATRIX* WINAPI D3DXMatrixShadow + ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, + CONST D3DXPLANE *pPlane ); + +// Build a matrix which reflects the coordinate system about a plane +D3DXMATRIX* WINAPI D3DXMatrixReflect + ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Quaternion +//-------------------------- + +// inline + +FLOAT D3DXQuaternionLength + ( CONST D3DXQUATERNION *pQ ); + +// Length squared, or "norm" +FLOAT D3DXQuaternionLengthSq + ( CONST D3DXQUATERNION *pQ ); + +FLOAT D3DXQuaternionDot + ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); + +// (0, 0, 0, 1) +D3DXQUATERNION* D3DXQuaternionIdentity + ( D3DXQUATERNION *pOut ); + +BOOL D3DXQuaternionIsIdentity + ( CONST D3DXQUATERNION *pQ ); + +// (-x, -y, -z, w) +D3DXQUATERNION* D3DXQuaternionConjugate + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. +void WINAPI D3DXQuaternionToAxisAngle + ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); + +// Build a quaternion from a rotation matrix. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix + ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); + +// Rotation about arbitrary axis. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis + ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); + +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll + ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); + +// Quaternion multiplication. The result represents the rotation Q2 +// followed by the rotation Q1. (Out = Q2 * Q1) +D3DXQUATERNION* WINAPI D3DXQuaternionMultiply + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2 ); + +D3DXQUATERNION* WINAPI D3DXQuaternionNormalize + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Conjugate and re-norm +D3DXQUATERNION* WINAPI D3DXQuaternionInverse + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Expects unit quaternions. +// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) +D3DXQUATERNION* WINAPI D3DXQuaternionLn + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Expects pure quaternions. (w == 0) w is ignored in calculation. +// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) +D3DXQUATERNION* WINAPI D3DXQuaternionExp + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). +// Expects unit quaternions. +D3DXQUATERNION* WINAPI D3DXQuaternionSlerp + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, FLOAT t ); + +// Spherical quadrangle interpolation. +// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) +D3DXQUATERNION* WINAPI D3DXQuaternionSquad + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, + CONST D3DXQUATERNION *pC, FLOAT t ); + +// Setup control points for spherical quadrangle interpolation +// from Q1 to Q2. The control points are chosen in such a way +// to ensure the continuity of tangents with adjacent segments. +void WINAPI D3DXQuaternionSquadSetup + ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, + CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); + +// Barycentric interpolation. +// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) +D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, + FLOAT f, FLOAT g ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Plane +//-------------------------- + +// inline + +// ax + by + cz + dw +FLOAT D3DXPlaneDot + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); + +// ax + by + cz + d +FLOAT D3DXPlaneDotCoord + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); + +// ax + by + cz +FLOAT D3DXPlaneDotNormal + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); + +D3DXPLANE* D3DXPlaneScale + (D3DXPLANE *pOut, CONST D3DXPLANE *pP, FLOAT s); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Normalize plane (so that |a,b,c| == 1) +D3DXPLANE* WINAPI D3DXPlaneNormalize + ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); + +// Find the intersection between a plane and a line. If the line is +// parallel to the plane, NULL is returned. +D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine + ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, + CONST D3DXVECTOR3 *pV2); + +// Construct a plane from a point and a normal +D3DXPLANE* WINAPI D3DXPlaneFromPointNormal + ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); + +// Construct a plane from 3 points +D3DXPLANE* WINAPI D3DXPlaneFromPoints + ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + CONST D3DXVECTOR3 *pV3); + +// 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* WINAPI D3DXPlaneTransform + ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); + +// Transform an array of planes by a matrix. The vectors (a,b,c) must be normal. +// M should be the inverse transpose of the transformation desired. +D3DXPLANE* WINAPI D3DXPlaneTransformArray + ( D3DXPLANE *pOut, UINT OutStride, CONST D3DXPLANE *pP, UINT PStride, CONST D3DXMATRIX *pM, UINT n ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Color +//-------------------------- + +// inline + +// (1-r, 1-g, 1-b, a) +D3DXCOLOR* D3DXColorNegative + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); + +D3DXCOLOR* D3DXColorAdd + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +D3DXCOLOR* D3DXColorSubtract + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +D3DXCOLOR* D3DXColorScale + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); + +// (r1*r2, g1*g2, b1*b2, a1*a2) +D3DXCOLOR* D3DXColorModulate + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) +D3DXCOLOR* D3DXColorLerp + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Interpolate r,g,b between desaturated color and color. +// DesaturatedColor + s(Color - DesaturatedColor) +D3DXCOLOR* WINAPI D3DXColorAdjustSaturation + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); + +// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) +D3DXCOLOR* WINAPI D3DXColorAdjustContrast + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); + +#ifdef __cplusplus +} +#endif + + + + +//-------------------------- +// Misc +//-------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +// Calculate Fresnel term given the cosine of theta (likely obtained by +// taking the dot of two normals), and the refraction index of the material. +FLOAT WINAPI D3DXFresnelTerm + (FLOAT CosTheta, FLOAT RefractionIndex); + +#ifdef __cplusplus +} +#endif + + + +//=========================================================================== +// +// Matrix Stack +// +//=========================================================================== + +typedef interface ID3DXMatrixStack ID3DXMatrixStack; +typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; + +// {C7885BA7-F990-4fe7-922D-8515E477DD85} +DEFINE_GUID(IID_ID3DXMatrixStack, +0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85); + + +#undef INTERFACE +#define INTERFACE ID3DXMatrixStack + +DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) +{ + // + // IUnknown methods + // + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // + // ID3DXMatrixStack methods + // + + // Pops the top of the stack, returns the current top + // *after* popping the top. + STDMETHOD(Pop)(THIS) PURE; + + // Pushes the stack by one, duplicating the current matrix. + STDMETHOD(Push)(THIS) PURE; + + // Loads identity in the current matrix. + STDMETHOD(LoadIdentity)(THIS) PURE; + + // Loads the given matrix into the current matrix + STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Right-Multiplies the given matrix to the current matrix. + // (transformation is about the current world origin) + STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Left-Multiplies the given matrix to the current matrix + // (transformation is about the local origin of the object) + STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Right multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the current world origin) + STDMETHOD(RotateAxis) + (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; + + // 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) + STDMETHOD(RotateAxisLocal) + (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; + + // Right multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // current world origin) + + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. + STDMETHOD(RotateYawPitchRoll) + (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; + + // Left multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // local origin of the object) + + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. + STDMETHOD(RotateYawPitchRollLocal) + (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; + + // Right multiply the current matrix with the computed scale + // matrix. (transformation is about the current world origin) + STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Left multiply the current matrix with the computed scale + // matrix. (transformation is about the local origin of the object) + STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Right multiply the current matrix with the computed translation + // matrix. (transformation is about the current world origin) + STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; + + // Left multiply the current matrix with the computed translation + // matrix. (transformation is about the local origin of the object) + STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Obtain the current matrix at the top of the stack + STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +HRESULT WINAPI + D3DXCreateMatrixStack( + DWORD Flags, + LPD3DXMATRIXSTACK* ppStack); + +#ifdef __cplusplus +} +#endif + +//=========================================================================== +// +// Spherical Harmonic Runtime Routines +// +// NOTE: +// * Most of these functions can take the same object as in and out parameters. +// The exceptions are the rotation functions. +// +// * Out parameters are typically also returned as return values, so that +// the output of one function may be used as a parameter to another. +// +//============================================================================ + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +//============================================================================ +// +// Basic Spherical Harmonic math routines +// +//============================================================================ + +#define D3DXSH_MINORDER 2 +#define D3DXSH_MAXORDER 6 + +//============================================================================ +// +// D3DXSHEvalDirection: +// -------------------- +// Evaluates the Spherical Harmonic basis functions +// +// Parameters: +// pOut +// Output SH coefficients - basis function Ylm is stored at l*l + m+l +// This is the pointer that is returned. +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pDir +// Direction to evaluate in - assumed to be normalized +// +//============================================================================ + +FLOAT* WINAPI D3DXSHEvalDirection + ( FLOAT *pOut, UINT Order, CONST D3DXVECTOR3 *pDir ); + +//============================================================================ +// +// D3DXSHRotate: +// -------------------- +// Rotates SH vector by a rotation matrix +// +// Parameters: +// pOut +// Output SH coefficients - basis function Ylm is stored at l*l + m+l +// This is the pointer that is returned (should not alias with pIn.) +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pMatrix +// Matrix used for rotation - rotation sub matrix should be orthogonal +// and have a unit determinant. +// pIn +// Input SH coeffs (rotated), incorect results if this is also output. +// +//============================================================================ + +FLOAT* WINAPI D3DXSHRotate + ( FLOAT *pOut, UINT Order, CONST D3DXMATRIX *pMatrix, CONST FLOAT *pIn ); + +//============================================================================ +// +// D3DXSHRotateZ: +// -------------------- +// Rotates the SH vector in the Z axis by an angle +// +// Parameters: +// pOut +// Output SH coefficients - basis function Ylm is stored at l*l + m+l +// This is the pointer that is returned (should not alias with pIn.) +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// Angle +// Angle in radians to rotate around the Z axis. +// pIn +// Input SH coeffs (rotated), incorect results if this is also output. +// +//============================================================================ + + +FLOAT* WINAPI D3DXSHRotateZ + ( FLOAT *pOut, UINT Order, FLOAT Angle, CONST FLOAT *pIn ); + +//============================================================================ +// +// D3DXSHAdd: +// -------------------- +// Adds two SH vectors, pOut[i] = pA[i] + pB[i]; +// +// Parameters: +// pOut +// Output SH coefficients - basis function Ylm is stored at l*l + m+l +// This is the pointer that is returned. +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pA +// Input SH coeffs. +// pB +// Input SH coeffs (second vector.) +// +//============================================================================ + +FLOAT* WINAPI D3DXSHAdd + ( FLOAT *pOut, UINT Order, CONST FLOAT *pA, CONST FLOAT *pB ); + +//============================================================================ +// +// D3DXSHScale: +// -------------------- +// Adds two SH vectors, pOut[i] = pA[i]*Scale; +// +// Parameters: +// pOut +// Output SH coefficients - basis function Ylm is stored at l*l + m+l +// This is the pointer that is returned. +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pIn +// Input SH coeffs. +// Scale +// Scale factor. +// +//============================================================================ + +FLOAT* WINAPI D3DXSHScale + ( FLOAT *pOut, UINT Order, CONST FLOAT *pIn, CONST FLOAT Scale ); + +//============================================================================ +// +// D3DXSHDot: +// -------------------- +// Computes the dot product of two SH vectors +// +// Parameters: +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pA +// Input SH coeffs. +// pB +// Second set of input SH coeffs. +// +//============================================================================ + +FLOAT WINAPI D3DXSHDot + ( UINT Order, CONST FLOAT *pA, CONST FLOAT *pB ); + +//============================================================================ +// +// Basic Spherical Harmonic lighting routines +// +//============================================================================ + +//============================================================================ +// +// D3DXSHEvalDirectionalLight: +// -------------------- +// Evaluates a directional light and returns spectral SH data. The output +// vector is computed so that if the intensity of R/G/B is unit the resulting +// exit radiance of a point directly under the light on a diffuse object with +// an albedo of 1 would be 1.0. This will compute 3 spectral samples, pROut +// has to be specified, while pGout and pBout are optional. +// +// Parameters: +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pDir +// Direction light is coming from (assumed to be normalized.) +// RIntensity +// Red intensity of light. +// GIntensity +// Green intensity of light. +// BIntensity +// Blue intensity of light. +// pROut +// Output SH vector for Red. +// pGOut +// Output SH vector for Green (optional.) +// pBOut +// Output SH vector for Blue (optional.) +// +//============================================================================ + +HRESULT WINAPI D3DXSHEvalDirectionalLight + ( UINT Order, CONST D3DXVECTOR3 *pDir, + FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, + FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); + +//============================================================================ +// +// D3DXSHEvalSphericalLight: +// -------------------- +// Evaluates a spherical light and returns spectral SH data. There is no +// normalization of the intensity of the light like there is for directional +// lights, care has to be taken when specifiying the intensities. This will +// compute 3 spectral samples, pROut has to be specified, while pGout and +// pBout are optional. +// +// Parameters: +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pPos +// Position of light - reciever is assumed to be at the origin. +// Radius +// Radius of the spherical light source. +// RIntensity +// Red intensity of light. +// GIntensity +// Green intensity of light. +// BIntensity +// Blue intensity of light. +// pROut +// Output SH vector for Red. +// pGOut +// Output SH vector for Green (optional.) +// pBOut +// Output SH vector for Blue (optional.) +// +//============================================================================ + +HRESULT WINAPI D3DXSHEvalSphericalLight + ( UINT Order, CONST D3DXVECTOR3 *pPos, FLOAT Radius, + FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, + FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); + +//============================================================================ +// +// D3DXSHEvalConeLight: +// -------------------- +// Evaluates a light that is a cone of constant intensity and returns spectral +// SH data. The output vector is computed so that if the intensity of R/G/B is +// unit the resulting exit radiance of a point directly under the light oriented +// in the cone direction on a diffuse object with an albedo of 1 would be 1.0. +// This will compute 3 spectral samples, pROut has to be specified, while pGout +// and pBout are optional. +// +// Parameters: +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pDir +// Direction light is coming from (assumed to be normalized.) +// Radius +// Radius of cone in radians. +// RIntensity +// Red intensity of light. +// GIntensity +// Green intensity of light. +// BIntensity +// Blue intensity of light. +// pROut +// Output SH vector for Red. +// pGOut +// Output SH vector for Green (optional.) +// pBOut +// Output SH vector for Blue (optional.) +// +//============================================================================ + +HRESULT WINAPI D3DXSHEvalConeLight + ( UINT Order, CONST D3DXVECTOR3 *pDir, FLOAT Radius, + FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, + FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); + +//============================================================================ +// +// D3DXSHEvalHemisphereLight: +// -------------------- +// Evaluates a light that is a linear interpolant between two colors over the +// sphere. The interpolant is linear along the axis of the two points, not +// over the surface of the sphere (ie: if the axis was (0,0,1) it is linear in +// Z, not in the azimuthal angle.) The resulting spherical lighting function +// is normalized so that a point on a perfectly diffuse surface with no +// shadowing and a normal pointed in the direction pDir would result in exit +// radiance with a value of 1 if the top color was white and the bottom color +// was black. This is a very simple model where Top represents the intensity +// of the "sky" and Bottom represents the intensity of the "ground". +// +// Parameters: +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pDir +// Axis of the hemisphere. +// Top +// Color of the upper hemisphere. +// Bottom +// Color of the lower hemisphere. +// pROut +// Output SH vector for Red. +// pGOut +// Output SH vector for Green +// pBOut +// Output SH vector for Blue +// +//============================================================================ + +HRESULT WINAPI D3DXSHEvalHemisphereLight + ( UINT Order, CONST D3DXVECTOR3 *pDir, D3DXCOLOR Top, D3DXCOLOR Bottom, + FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); + +//============================================================================ +// +// Basic Spherical Harmonic projection routines +// +//============================================================================ + +//============================================================================ +// +// D3DXSHProjectCubeMap: +// -------------------- +// Projects a function represented on a cube map into spherical harmonics. +// +// Parameters: +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pCubeMap +// CubeMap that is going to be projected into spherical harmonics +// pROut +// Output SH vector for Red. +// pGOut +// Output SH vector for Green +// pBOut +// Output SH vector for Blue +// +//============================================================================ + +HRESULT WINAPI D3DXSHProjectCubeMap + ( UINT uOrder, LPDIRECT3DCUBETEXTURE9 pCubeMap, + FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); + + +#ifdef __cplusplus +} +#endif + + +#include "d3dx9math.inl" + +#if _MSC_VER >= 1200 +#pragma warning(pop) +#else +#pragma warning(default:4201) +#endif + +#endif // __D3DX9MATH_H__ + diff --git a/src/dep/include/DXSDK/include/d3dx9math.inl b/src/dep/include/DXSDK/include/d3dx9math.inl index de070e2..ecf52f9 100644 --- a/src/dep/include/DXSDK/include/d3dx9math.inl +++ b/src/dep/include/DXSDK/include/d3dx9math.inl @@ -1,2244 +1,2244 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx9math.inl -// Content: D3DX math inline functions -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DX9MATH_INL__ -#define __D3DX9MATH_INL__ - - -//=========================================================================== -// -// Inline Class Methods -// -//=========================================================================== - -#ifdef __cplusplus - -//-------------------------- -// Float16 -//-------------------------- - -D3DXINLINE -D3DXFLOAT16::D3DXFLOAT16( FLOAT f ) -{ - D3DXFloat32To16Array(this, &f, 1); -} - -D3DXINLINE -D3DXFLOAT16::D3DXFLOAT16( CONST D3DXFLOAT16& f ) -{ - value = f.value; -} - -// casting -D3DXINLINE -D3DXFLOAT16::operator FLOAT () -{ - FLOAT f; - D3DXFloat16To32Array(&f, this, 1); - return f; -} - -// binary operators -D3DXINLINE BOOL -D3DXFLOAT16::operator == ( CONST D3DXFLOAT16& f ) const -{ - return value == f.value; -} - -D3DXINLINE BOOL -D3DXFLOAT16::operator != ( CONST D3DXFLOAT16& f ) const -{ - return value != f.value; -} - - -//-------------------------- -// 2D Vector -//-------------------------- - -D3DXINLINE -D3DXVECTOR2::D3DXVECTOR2( CONST FLOAT *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; -} - -D3DXINLINE -D3DXVECTOR2::D3DXVECTOR2( CONST D3DXFLOAT16 *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - D3DXFloat16To32Array(&x, pf, 2); -} - -D3DXINLINE -D3DXVECTOR2::D3DXVECTOR2( FLOAT fx, FLOAT fy ) -{ - x = fx; - y = fy; -} - - -// casting -D3DXINLINE -D3DXVECTOR2::operator FLOAT* () -{ - return (FLOAT *) &x; -} - -D3DXINLINE -D3DXVECTOR2::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &x; -} - - -// assignment operators -D3DXINLINE D3DXVECTOR2& -D3DXVECTOR2::operator += ( CONST D3DXVECTOR2& v ) -{ - x += v.x; - y += v.y; - return *this; -} - -D3DXINLINE D3DXVECTOR2& -D3DXVECTOR2::operator -= ( CONST D3DXVECTOR2& v ) -{ - x -= v.x; - y -= v.y; - return *this; -} - -D3DXINLINE D3DXVECTOR2& -D3DXVECTOR2::operator *= ( FLOAT f ) -{ - x *= f; - y *= f; - return *this; -} - -D3DXINLINE D3DXVECTOR2& -D3DXVECTOR2::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - x *= fInv; - y *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator - () const -{ - return D3DXVECTOR2(-x, -y); -} - - -// binary operators -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator + ( CONST D3DXVECTOR2& v ) const -{ - return D3DXVECTOR2(x + v.x, y + v.y); -} - -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator - ( CONST D3DXVECTOR2& v ) const -{ - return D3DXVECTOR2(x - v.x, y - v.y); -} - -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator * ( FLOAT f ) const -{ - return D3DXVECTOR2(x * f, y * f); -} - -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXVECTOR2(x * fInv, y * fInv); -} - -D3DXINLINE D3DXVECTOR2 -operator * ( FLOAT f, CONST D3DXVECTOR2& v ) -{ - return D3DXVECTOR2(f * v.x, f * v.y); -} - -D3DXINLINE BOOL -D3DXVECTOR2::operator == ( CONST D3DXVECTOR2& v ) const -{ - return x == v.x && y == v.y; -} - -D3DXINLINE BOOL -D3DXVECTOR2::operator != ( CONST D3DXVECTOR2& v ) const -{ - return x != v.x || y != v.y; -} - - - -//-------------------------- -// 2D Vector (16 bit) -//-------------------------- - -D3DXINLINE -D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST FLOAT *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - D3DXFloat32To16Array(&x, pf, 2); -} - -D3DXINLINE -D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST D3DXFLOAT16 *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - *((DWORD *) &x) = *((DWORD *) &pf[0]); -} - -D3DXINLINE -D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy ) -{ - x = fx; - y = fy; -} - - -// casting -D3DXINLINE -D3DXVECTOR2_16F::operator D3DXFLOAT16* () -{ - return (D3DXFLOAT16*) &x; -} - -D3DXINLINE -D3DXVECTOR2_16F::operator CONST D3DXFLOAT16* () const -{ - return (CONST D3DXFLOAT16*) &x; -} - - -// binary operators -D3DXINLINE BOOL -D3DXVECTOR2_16F::operator == ( CONST D3DXVECTOR2_16F &v ) const -{ - return *((DWORD *) &x) == *((DWORD *) &v.x); -} - -D3DXINLINE BOOL -D3DXVECTOR2_16F::operator != ( CONST D3DXVECTOR2_16F &v ) const -{ - return *((DWORD *) &x) != *((DWORD *) &v.x); -} - - -//-------------------------- -// 3D Vector -//-------------------------- -D3DXINLINE -D3DXVECTOR3::D3DXVECTOR3( CONST FLOAT *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; - z = pf[2]; -} - -D3DXINLINE -D3DXVECTOR3::D3DXVECTOR3( CONST D3DVECTOR& v ) -{ - x = v.x; - y = v.y; - z = v.z; -} - -D3DXINLINE -D3DXVECTOR3::D3DXVECTOR3( CONST D3DXFLOAT16 *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - D3DXFloat16To32Array(&x, pf, 3); -} - -D3DXINLINE -D3DXVECTOR3::D3DXVECTOR3( FLOAT fx, FLOAT fy, FLOAT fz ) -{ - x = fx; - y = fy; - z = fz; -} - - -// casting -D3DXINLINE -D3DXVECTOR3::operator FLOAT* () -{ - return (FLOAT *) &x; -} - -D3DXINLINE -D3DXVECTOR3::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &x; -} - - -// assignment operators -D3DXINLINE D3DXVECTOR3& -D3DXVECTOR3::operator += ( CONST D3DXVECTOR3& v ) -{ - x += v.x; - y += v.y; - z += v.z; - return *this; -} - -D3DXINLINE D3DXVECTOR3& -D3DXVECTOR3::operator -= ( CONST D3DXVECTOR3& v ) -{ - x -= v.x; - y -= v.y; - z -= v.z; - return *this; -} - -D3DXINLINE D3DXVECTOR3& -D3DXVECTOR3::operator *= ( FLOAT f ) -{ - x *= f; - y *= f; - z *= f; - return *this; -} - -D3DXINLINE D3DXVECTOR3& -D3DXVECTOR3::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - x *= fInv; - y *= fInv; - z *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator - () const -{ - return D3DXVECTOR3(-x, -y, -z); -} - - -// binary operators -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator + ( CONST D3DXVECTOR3& v ) const -{ - return D3DXVECTOR3(x + v.x, y + v.y, z + v.z); -} - -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator - ( CONST D3DXVECTOR3& v ) const -{ - return D3DXVECTOR3(x - v.x, y - v.y, z - v.z); -} - -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator * ( FLOAT f ) const -{ - return D3DXVECTOR3(x * f, y * f, z * f); -} - -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXVECTOR3(x * fInv, y * fInv, z * fInv); -} - - -D3DXINLINE D3DXVECTOR3 -operator * ( FLOAT f, CONST struct D3DXVECTOR3& v ) -{ - return D3DXVECTOR3(f * v.x, f * v.y, f * v.z); -} - - -D3DXINLINE BOOL -D3DXVECTOR3::operator == ( CONST D3DXVECTOR3& v ) const -{ - return x == v.x && y == v.y && z == v.z; -} - -D3DXINLINE BOOL -D3DXVECTOR3::operator != ( CONST D3DXVECTOR3& v ) const -{ - return x != v.x || y != v.y || z != v.z; -} - - - -//-------------------------- -// 3D Vector (16 bit) -//-------------------------- - -D3DXINLINE -D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST FLOAT *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - D3DXFloat32To16Array(&x, pf, 3); -} - -D3DXINLINE -D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DVECTOR& v ) -{ - D3DXFloat32To16Array(&x, &v.x, 1); - D3DXFloat32To16Array(&y, &v.y, 1); - D3DXFloat32To16Array(&z, &v.z, 1); -} - -D3DXINLINE -D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DXFLOAT16 *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - *((DWORD *) &x) = *((DWORD *) &pf[0]); - *((WORD *) &z) = *((WORD *) &pf[2]); -} - -D3DXINLINE -D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy, CONST D3DXFLOAT16 &fz ) -{ - x = fx; - y = fy; - z = fz; -} - - -// casting -D3DXINLINE -D3DXVECTOR3_16F::operator D3DXFLOAT16* () -{ - return (D3DXFLOAT16*) &x; -} - -D3DXINLINE -D3DXVECTOR3_16F::operator CONST D3DXFLOAT16* () const -{ - return (CONST D3DXFLOAT16*) &x; -} - - -// binary operators -D3DXINLINE BOOL -D3DXVECTOR3_16F::operator == ( CONST D3DXVECTOR3_16F &v ) const -{ - return *((DWORD *) &x) == *((DWORD *) &v.x) && - *((WORD *) &z) == *((WORD *) &v.z); -} - -D3DXINLINE BOOL -D3DXVECTOR3_16F::operator != ( CONST D3DXVECTOR3_16F &v ) const -{ - return *((DWORD *) &x) != *((DWORD *) &v.x) || - *((WORD *) &z) != *((WORD *) &v.z); -} - - -//-------------------------- -// 4D Vector -//-------------------------- -D3DXINLINE -D3DXVECTOR4::D3DXVECTOR4( CONST FLOAT *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; - z = pf[2]; - w = pf[3]; -} - -D3DXINLINE -D3DXVECTOR4::D3DXVECTOR4( CONST D3DXFLOAT16 *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - D3DXFloat16To32Array(&x, pf, 4); -} - -D3DXINLINE -D3DXVECTOR4::D3DXVECTOR4( CONST D3DVECTOR& v, FLOAT f ) -{ - x = v.x; - y = v.y; - z = v.z; - w = f; -} - -D3DXINLINE -D3DXVECTOR4::D3DXVECTOR4( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) -{ - x = fx; - y = fy; - z = fz; - w = fw; -} - - -// casting -D3DXINLINE -D3DXVECTOR4::operator FLOAT* () -{ - return (FLOAT *) &x; -} - -D3DXINLINE -D3DXVECTOR4::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &x; -} - - -// assignment operators -D3DXINLINE D3DXVECTOR4& -D3DXVECTOR4::operator += ( CONST D3DXVECTOR4& v ) -{ - x += v.x; - y += v.y; - z += v.z; - w += v.w; - return *this; -} - -D3DXINLINE D3DXVECTOR4& -D3DXVECTOR4::operator -= ( CONST D3DXVECTOR4& v ) -{ - x -= v.x; - y -= v.y; - z -= v.z; - w -= v.w; - return *this; -} - -D3DXINLINE D3DXVECTOR4& -D3DXVECTOR4::operator *= ( FLOAT f ) -{ - x *= f; - y *= f; - z *= f; - w *= f; - return *this; -} - -D3DXINLINE D3DXVECTOR4& -D3DXVECTOR4::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - x *= fInv; - y *= fInv; - z *= fInv; - w *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator - () const -{ - return D3DXVECTOR4(-x, -y, -z, -w); -} - - -// binary operators -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator + ( CONST D3DXVECTOR4& v ) const -{ - return D3DXVECTOR4(x + v.x, y + v.y, z + v.z, w + v.w); -} - -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator - ( CONST D3DXVECTOR4& v ) const -{ - return D3DXVECTOR4(x - v.x, y - v.y, z - v.z, w - v.w); -} - -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator * ( FLOAT f ) const -{ - return D3DXVECTOR4(x * f, y * f, z * f, w * f); -} - -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXVECTOR4(x * fInv, y * fInv, z * fInv, w * fInv); -} - -D3DXINLINE D3DXVECTOR4 -operator * ( FLOAT f, CONST D3DXVECTOR4& v ) -{ - return D3DXVECTOR4(f * v.x, f * v.y, f * v.z, f * v.w); -} - - -D3DXINLINE BOOL -D3DXVECTOR4::operator == ( CONST D3DXVECTOR4& v ) const -{ - return x == v.x && y == v.y && z == v.z && w == v.w; -} - -D3DXINLINE BOOL -D3DXVECTOR4::operator != ( CONST D3DXVECTOR4& v ) const -{ - return x != v.x || y != v.y || z != v.z || w != v.w; -} - - - -//-------------------------- -// 4D Vector (16 bit) -//-------------------------- - -D3DXINLINE -D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST FLOAT *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - D3DXFloat32To16Array(&x, pf, 4); -} - -D3DXINLINE -D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXFLOAT16 *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - *((DWORD *) &x) = *((DWORD *) &pf[0]); - *((DWORD *) &z) = *((DWORD *) &pf[2]); -} - -D3DXINLINE -D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXVECTOR3_16F& v, CONST D3DXFLOAT16& f ) -{ - x = v.x; - y = v.y; - z = v.z; - w = f; -} - -D3DXINLINE -D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy, CONST D3DXFLOAT16 &fz, CONST D3DXFLOAT16 &fw ) -{ - x = fx; - y = fy; - z = fz; - w = fw; -} - - -// casting -D3DXINLINE -D3DXVECTOR4_16F::operator D3DXFLOAT16* () -{ - return (D3DXFLOAT16*) &x; -} - -D3DXINLINE -D3DXVECTOR4_16F::operator CONST D3DXFLOAT16* () const -{ - return (CONST D3DXFLOAT16*) &x; -} - - -// binary operators -D3DXINLINE BOOL -D3DXVECTOR4_16F::operator == ( CONST D3DXVECTOR4_16F &v ) const -{ - return *((DWORD *) &x) == *((DWORD *) &v.x) && - *((DWORD *) &z) == *((DWORD *) &v.z); -} - -D3DXINLINE BOOL -D3DXVECTOR4_16F::operator != ( CONST D3DXVECTOR4_16F &v ) const -{ - return *((DWORD *) &x) != *((DWORD *) &v.x) || - *((DWORD *) &z) != *((DWORD *) &v.z); -} - - -//-------------------------- -// Matrix -//-------------------------- -D3DXINLINE -D3DXMATRIX::D3DXMATRIX( CONST FLOAT* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - memcpy(&_11, pf, sizeof(D3DXMATRIX)); -} - -D3DXINLINE -D3DXMATRIX::D3DXMATRIX( CONST D3DMATRIX& mat ) -{ - memcpy(&_11, &mat, sizeof(D3DXMATRIX)); -} - -D3DXINLINE -D3DXMATRIX::D3DXMATRIX( CONST D3DXFLOAT16* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - D3DXFloat16To32Array(&_11, pf, 16); -} - -D3DXINLINE -D3DXMATRIX::D3DXMATRIX( FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14, - FLOAT f21, FLOAT f22, FLOAT f23, FLOAT f24, - FLOAT f31, FLOAT f32, FLOAT f33, FLOAT f34, - FLOAT f41, FLOAT f42, FLOAT f43, FLOAT f44 ) -{ - _11 = f11; _12 = f12; _13 = f13; _14 = f14; - _21 = f21; _22 = f22; _23 = f23; _24 = f24; - _31 = f31; _32 = f32; _33 = f33; _34 = f34; - _41 = f41; _42 = f42; _43 = f43; _44 = f44; -} - - - -// access grants -D3DXINLINE FLOAT& -D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) -{ - return m[iRow][iCol]; -} - -D3DXINLINE FLOAT -D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) const -{ - return m[iRow][iCol]; -} - - -// casting operators -D3DXINLINE -D3DXMATRIX::operator FLOAT* () -{ - return (FLOAT *) &_11; -} - -D3DXINLINE -D3DXMATRIX::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &_11; -} - - -// assignment operators -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator *= ( CONST D3DXMATRIX& mat ) -{ - D3DXMatrixMultiply(this, this, &mat); - return *this; -} - -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator += ( CONST D3DXMATRIX& mat ) -{ - _11 += mat._11; _12 += mat._12; _13 += mat._13; _14 += mat._14; - _21 += mat._21; _22 += mat._22; _23 += mat._23; _24 += mat._24; - _31 += mat._31; _32 += mat._32; _33 += mat._33; _34 += mat._34; - _41 += mat._41; _42 += mat._42; _43 += mat._43; _44 += mat._44; - return *this; -} - -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator -= ( CONST D3DXMATRIX& mat ) -{ - _11 -= mat._11; _12 -= mat._12; _13 -= mat._13; _14 -= mat._14; - _21 -= mat._21; _22 -= mat._22; _23 -= mat._23; _24 -= mat._24; - _31 -= mat._31; _32 -= mat._32; _33 -= mat._33; _34 -= mat._34; - _41 -= mat._41; _42 -= mat._42; _43 -= mat._43; _44 -= mat._44; - return *this; -} - -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator *= ( FLOAT f ) -{ - _11 *= f; _12 *= f; _13 *= f; _14 *= f; - _21 *= f; _22 *= f; _23 *= f; _24 *= f; - _31 *= f; _32 *= f; _33 *= f; _34 *= f; - _41 *= f; _42 *= f; _43 *= f; _44 *= f; - return *this; -} - -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - _11 *= fInv; _12 *= fInv; _13 *= fInv; _14 *= fInv; - _21 *= fInv; _22 *= fInv; _23 *= fInv; _24 *= fInv; - _31 *= fInv; _32 *= fInv; _33 *= fInv; _34 *= fInv; - _41 *= fInv; _42 *= fInv; _43 *= fInv; _44 *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator - () const -{ - return D3DXMATRIX(-_11, -_12, -_13, -_14, - -_21, -_22, -_23, -_24, - -_31, -_32, -_33, -_34, - -_41, -_42, -_43, -_44); -} - - -// binary operators -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator * ( CONST D3DXMATRIX& mat ) const -{ - D3DXMATRIX matT; - D3DXMatrixMultiply(&matT, this, &mat); - return matT; -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator + ( CONST D3DXMATRIX& mat ) const -{ - return D3DXMATRIX(_11 + mat._11, _12 + mat._12, _13 + mat._13, _14 + mat._14, - _21 + mat._21, _22 + mat._22, _23 + mat._23, _24 + mat._24, - _31 + mat._31, _32 + mat._32, _33 + mat._33, _34 + mat._34, - _41 + mat._41, _42 + mat._42, _43 + mat._43, _44 + mat._44); -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator - ( CONST D3DXMATRIX& mat ) const -{ - return D3DXMATRIX(_11 - mat._11, _12 - mat._12, _13 - mat._13, _14 - mat._14, - _21 - mat._21, _22 - mat._22, _23 - mat._23, _24 - mat._24, - _31 - mat._31, _32 - mat._32, _33 - mat._33, _34 - mat._34, - _41 - mat._41, _42 - mat._42, _43 - mat._43, _44 - mat._44); -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator * ( FLOAT f ) const -{ - return D3DXMATRIX(_11 * f, _12 * f, _13 * f, _14 * f, - _21 * f, _22 * f, _23 * f, _24 * f, - _31 * f, _32 * f, _33 * f, _34 * f, - _41 * f, _42 * f, _43 * f, _44 * f); -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXMATRIX(_11 * fInv, _12 * fInv, _13 * fInv, _14 * fInv, - _21 * fInv, _22 * fInv, _23 * fInv, _24 * fInv, - _31 * fInv, _32 * fInv, _33 * fInv, _34 * fInv, - _41 * fInv, _42 * fInv, _43 * fInv, _44 * fInv); -} - - -D3DXINLINE D3DXMATRIX -operator * ( FLOAT f, CONST D3DXMATRIX& mat ) -{ - return D3DXMATRIX(f * mat._11, f * mat._12, f * mat._13, f * mat._14, - f * mat._21, f * mat._22, f * mat._23, f * mat._24, - f * mat._31, f * mat._32, f * mat._33, f * mat._34, - f * mat._41, f * mat._42, f * mat._43, f * mat._44); -} - - -D3DXINLINE BOOL -D3DXMATRIX::operator == ( CONST D3DXMATRIX& mat ) const -{ - return 0 == memcmp(this, &mat, sizeof(D3DXMATRIX)); -} - -D3DXINLINE BOOL -D3DXMATRIX::operator != ( CONST D3DXMATRIX& mat ) const -{ - return 0 != memcmp(this, &mat, sizeof(D3DXMATRIX)); -} - - - -//-------------------------- -// Aligned Matrices -//-------------------------- - -D3DXINLINE -_D3DXMATRIXA16::_D3DXMATRIXA16( CONST FLOAT* f ) : - D3DXMATRIX( f ) -{ -} - -D3DXINLINE -_D3DXMATRIXA16::_D3DXMATRIXA16( CONST D3DMATRIX& m ) : - D3DXMATRIX( m ) -{ -} - -D3DXINLINE -_D3DXMATRIXA16::_D3DXMATRIXA16( CONST D3DXFLOAT16* f ) : - D3DXMATRIX( f ) -{ -} - -D3DXINLINE -_D3DXMATRIXA16::_D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, - FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, - FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, - FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ) : - D3DXMATRIX(_11, _12, _13, _14, - _21, _22, _23, _24, - _31, _32, _33, _34, - _41, _42, _43, _44) -{ -} - -D3DXINLINE void* -_D3DXMATRIXA16::operator new( size_t s ) -{ - LPBYTE p = ::new BYTE[s + 16]; - if (p) - { - BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); - p += offset; - p[-1] = offset; - } - return p; -} - -D3DXINLINE void* -_D3DXMATRIXA16::operator new[]( size_t s ) -{ - LPBYTE p = ::new BYTE[s + 16]; - if (p) - { - BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); - p += offset; - p[-1] = offset; - } - return p; -} - -D3DXINLINE void -_D3DXMATRIXA16::operator delete(void* p) -{ - if(p) - { - BYTE* pb = static_cast(p); - pb -= pb[-1]; - ::delete [] pb; - } -} - -D3DXINLINE void -_D3DXMATRIXA16::operator delete[](void* p) -{ - if(p) - { - BYTE* pb = static_cast(p); - pb -= pb[-1]; - ::delete [] pb; - } -} - -D3DXINLINE _D3DXMATRIXA16& -_D3DXMATRIXA16::operator=(CONST D3DXMATRIX& rhs) -{ - memcpy(&_11, &rhs, sizeof(D3DXMATRIX)); - return *this; -} - - -//-------------------------- -// Quaternion -//-------------------------- - -D3DXINLINE -D3DXQUATERNION::D3DXQUATERNION( CONST FLOAT* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; - z = pf[2]; - w = pf[3]; -} - -D3DXINLINE -D3DXQUATERNION::D3DXQUATERNION( CONST D3DXFLOAT16* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - D3DXFloat16To32Array(&x, pf, 4); -} - -D3DXINLINE -D3DXQUATERNION::D3DXQUATERNION( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) -{ - x = fx; - y = fy; - z = fz; - w = fw; -} - - -// casting -D3DXINLINE -D3DXQUATERNION::operator FLOAT* () -{ - return (FLOAT *) &x; -} - -D3DXINLINE -D3DXQUATERNION::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &x; -} - - -// assignment operators -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator += ( CONST D3DXQUATERNION& q ) -{ - x += q.x; - y += q.y; - z += q.z; - w += q.w; - return *this; -} - -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator -= ( CONST D3DXQUATERNION& q ) -{ - x -= q.x; - y -= q.y; - z -= q.z; - w -= q.w; - return *this; -} - -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator *= ( CONST D3DXQUATERNION& q ) -{ - D3DXQuaternionMultiply(this, this, &q); - return *this; -} - -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator *= ( FLOAT f ) -{ - x *= f; - y *= f; - z *= f; - w *= f; - return *this; -} - -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - x *= fInv; - y *= fInv; - z *= fInv; - w *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator - () const -{ - return D3DXQUATERNION(-x, -y, -z, -w); -} - - -// binary operators -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator + ( CONST D3DXQUATERNION& q ) const -{ - return D3DXQUATERNION(x + q.x, y + q.y, z + q.z, w + q.w); -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator - ( CONST D3DXQUATERNION& q ) const -{ - return D3DXQUATERNION(x - q.x, y - q.y, z - q.z, w - q.w); -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator * ( CONST D3DXQUATERNION& q ) const -{ - D3DXQUATERNION qT; - D3DXQuaternionMultiply(&qT, this, &q); - return qT; -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator * ( FLOAT f ) const -{ - return D3DXQUATERNION(x * f, y * f, z * f, w * f); -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXQUATERNION(x * fInv, y * fInv, z * fInv, w * fInv); -} - - -D3DXINLINE D3DXQUATERNION -operator * (FLOAT f, CONST D3DXQUATERNION& q ) -{ - return D3DXQUATERNION(f * q.x, f * q.y, f * q.z, f * q.w); -} - - -D3DXINLINE BOOL -D3DXQUATERNION::operator == ( CONST D3DXQUATERNION& q ) const -{ - return x == q.x && y == q.y && z == q.z && w == q.w; -} - -D3DXINLINE BOOL -D3DXQUATERNION::operator != ( CONST D3DXQUATERNION& q ) const -{ - return x != q.x || y != q.y || z != q.z || w != q.w; -} - - - -//-------------------------- -// Plane -//-------------------------- - -D3DXINLINE -D3DXPLANE::D3DXPLANE( CONST FLOAT* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - a = pf[0]; - b = pf[1]; - c = pf[2]; - d = pf[3]; -} - -D3DXINLINE -D3DXPLANE::D3DXPLANE( CONST D3DXFLOAT16* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - D3DXFloat16To32Array(&a, pf, 4); -} - -D3DXINLINE -D3DXPLANE::D3DXPLANE( FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd ) -{ - a = fa; - b = fb; - c = fc; - d = fd; -} - - -// casting -D3DXINLINE -D3DXPLANE::operator FLOAT* () -{ - return (FLOAT *) &a; -} - -D3DXINLINE -D3DXPLANE::operator CONST FLOAT* () const -{ - return (CONST FLOAT *) &a; -} - - -// assignment operators -D3DXINLINE D3DXPLANE& -D3DXPLANE::operator *= ( FLOAT f ) -{ - a *= f; - b *= f; - c *= f; - d *= f; - return *this; -} - -D3DXINLINE D3DXPLANE& -D3DXPLANE::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - a *= fInv; - b *= fInv; - c *= fInv; - d *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXPLANE -D3DXPLANE::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXPLANE -D3DXPLANE::operator - () const -{ - return D3DXPLANE(-a, -b, -c, -d); -} - - -// binary operators -D3DXINLINE D3DXPLANE -D3DXPLANE::operator * ( FLOAT f ) const -{ - return D3DXPLANE(a * f, b * f, c * f, d * f); -} - -D3DXINLINE D3DXPLANE -D3DXPLANE::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXPLANE(a * fInv, b * fInv, c * fInv, d * fInv); -} - -D3DXINLINE D3DXPLANE -operator * (FLOAT f, CONST D3DXPLANE& p ) -{ - return D3DXPLANE(f * p.a, f * p.b, f * p.c, f * p.d); -} - -D3DXINLINE BOOL -D3DXPLANE::operator == ( CONST D3DXPLANE& p ) const -{ - return a == p.a && b == p.b && c == p.c && d == p.d; -} - -D3DXINLINE BOOL -D3DXPLANE::operator != ( CONST D3DXPLANE& p ) const -{ - return a != p.a || b != p.b || c != p.c || d != p.d; -} - - - - -//-------------------------- -// Color -//-------------------------- - -D3DXINLINE -D3DXCOLOR::D3DXCOLOR( DWORD dw ) -{ - CONST FLOAT f = 1.0f / 255.0f; - r = f * (FLOAT) (unsigned char) (dw >> 16); - g = f * (FLOAT) (unsigned char) (dw >> 8); - b = f * (FLOAT) (unsigned char) (dw >> 0); - a = f * (FLOAT) (unsigned char) (dw >> 24); -} - -D3DXINLINE -D3DXCOLOR::D3DXCOLOR( CONST FLOAT* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - r = pf[0]; - g = pf[1]; - b = pf[2]; - a = pf[3]; -} - -D3DXINLINE -D3DXCOLOR::D3DXCOLOR( CONST D3DXFLOAT16* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - D3DXFloat16To32Array(&r, pf, 4); -} - -D3DXINLINE -D3DXCOLOR::D3DXCOLOR( CONST D3DCOLORVALUE& c ) -{ - r = c.r; - g = c.g; - b = c.b; - a = c.a; -} - -D3DXINLINE -D3DXCOLOR::D3DXCOLOR( FLOAT fr, FLOAT fg, FLOAT fb, FLOAT fa ) -{ - r = fr; - g = fg; - b = fb; - a = fa; -} - - -// casting -D3DXINLINE -D3DXCOLOR::operator DWORD () const -{ - DWORD dwR = r >= 1.0f ? 0xff : r <= 0.0f ? 0x00 : (DWORD) (r * 255.0f + 0.5f); - DWORD dwG = g >= 1.0f ? 0xff : g <= 0.0f ? 0x00 : (DWORD) (g * 255.0f + 0.5f); - DWORD dwB = b >= 1.0f ? 0xff : b <= 0.0f ? 0x00 : (DWORD) (b * 255.0f + 0.5f); - DWORD dwA = a >= 1.0f ? 0xff : a <= 0.0f ? 0x00 : (DWORD) (a * 255.0f + 0.5f); - - return (dwA << 24) | (dwR << 16) | (dwG << 8) | dwB; -} - - -D3DXINLINE -D3DXCOLOR::operator FLOAT * () -{ - return (FLOAT *) &r; -} - -D3DXINLINE -D3DXCOLOR::operator CONST FLOAT * () const -{ - return (CONST FLOAT *) &r; -} - - -D3DXINLINE -D3DXCOLOR::operator D3DCOLORVALUE * () -{ - return (D3DCOLORVALUE *) &r; -} - -D3DXINLINE -D3DXCOLOR::operator CONST D3DCOLORVALUE * () const -{ - return (CONST D3DCOLORVALUE *) &r; -} - - -D3DXINLINE -D3DXCOLOR::operator D3DCOLORVALUE& () -{ - return *((D3DCOLORVALUE *) &r); -} - -D3DXINLINE -D3DXCOLOR::operator CONST D3DCOLORVALUE& () const -{ - return *((CONST D3DCOLORVALUE *) &r); -} - - -// assignment operators -D3DXINLINE D3DXCOLOR& -D3DXCOLOR::operator += ( CONST D3DXCOLOR& c ) -{ - r += c.r; - g += c.g; - b += c.b; - a += c.a; - return *this; -} - -D3DXINLINE D3DXCOLOR& -D3DXCOLOR::operator -= ( CONST D3DXCOLOR& c ) -{ - r -= c.r; - g -= c.g; - b -= c.b; - a -= c.a; - return *this; -} - -D3DXINLINE D3DXCOLOR& -D3DXCOLOR::operator *= ( FLOAT f ) -{ - r *= f; - g *= f; - b *= f; - a *= f; - return *this; -} - -D3DXINLINE D3DXCOLOR& -D3DXCOLOR::operator /= ( FLOAT f ) -{ - FLOAT fInv = 1.0f / f; - r *= fInv; - g *= fInv; - b *= fInv; - a *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator - () const -{ - return D3DXCOLOR(-r, -g, -b, -a); -} - - -// binary operators -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator + ( CONST D3DXCOLOR& c ) const -{ - return D3DXCOLOR(r + c.r, g + c.g, b + c.b, a + c.a); -} - -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator - ( CONST D3DXCOLOR& c ) const -{ - return D3DXCOLOR(r - c.r, g - c.g, b - c.b, a - c.a); -} - -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator * ( FLOAT f ) const -{ - return D3DXCOLOR(r * f, g * f, b * f, a * f); -} - -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator / ( FLOAT f ) const -{ - FLOAT fInv = 1.0f / f; - return D3DXCOLOR(r * fInv, g * fInv, b * fInv, a * fInv); -} - - -D3DXINLINE D3DXCOLOR -operator * (FLOAT f, CONST D3DXCOLOR& c ) -{ - return D3DXCOLOR(f * c.r, f * c.g, f * c.b, f * c.a); -} - - -D3DXINLINE BOOL -D3DXCOLOR::operator == ( CONST D3DXCOLOR& c ) const -{ - return r == c.r && g == c.g && b == c.b && a == c.a; -} - -D3DXINLINE BOOL -D3DXCOLOR::operator != ( CONST D3DXCOLOR& c ) const -{ - return r != c.r || g != c.g || b != c.b || a != c.a; -} - - -#endif //__cplusplus - - - -//=========================================================================== -// -// Inline functions -// -//=========================================================================== - - -//-------------------------- -// 2D Vector -//-------------------------- - -D3DXINLINE FLOAT D3DXVec2Length - ( CONST D3DXVECTOR2 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pV->x * pV->x + pV->y * pV->y); -#else - return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y); -#endif -} - -D3DXINLINE FLOAT D3DXVec2LengthSq - ( CONST D3DXVECTOR2 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - - return pV->x * pV->x + pV->y * pV->y; -} - -D3DXINLINE FLOAT D3DXVec2Dot - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->x + pV1->y * pV2->y; -} - -D3DXINLINE FLOAT D3DXVec2CCW - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->y - pV1->y * pV2->x; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Add - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + pV2->x; - pOut->y = pV1->y + pV2->y; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Subtract - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x - pV2->x; - pOut->y = pV1->y - pV2->y; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Minimize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Maximize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Scale - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV) - return NULL; -#endif - - pOut->x = pV->x * s; - pOut->y = pV->y * s; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Lerp - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, - FLOAT s ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + s * (pV2->x - pV1->x); - pOut->y = pV1->y + s * (pV2->y - pV1->y); - return pOut; -} - - -//-------------------------- -// 3D Vector -//-------------------------- - -D3DXINLINE FLOAT D3DXVec3Length - ( CONST D3DXVECTOR3 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); -#else - return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); -#endif -} - -D3DXINLINE FLOAT D3DXVec3LengthSq - ( CONST D3DXVECTOR3 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - - return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z; -} - -D3DXINLINE FLOAT D3DXVec3Dot - ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Cross - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ - D3DXVECTOR3 v; - -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - 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 D3DXVECTOR3* D3DXVec3Add - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + pV2->x; - pOut->y = pV1->y + pV2->y; - pOut->z = pV1->z + pV2->z; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Subtract - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x - pV2->x; - pOut->y = pV1->y - pV2->y; - pOut->z = pV1->z - pV2->z; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Minimize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Maximize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Scale - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV) - return NULL; -#endif - - pOut->x = pV->x * s; - pOut->y = pV->y * s; - pOut->z = pV->z * s; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Lerp - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - FLOAT s ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + s * (pV2->x - pV1->x); - pOut->y = pV1->y + s * (pV2->y - pV1->y); - pOut->z = pV1->z + s * (pV2->z - pV1->z); - return pOut; -} - - -//-------------------------- -// 4D Vector -//-------------------------- - -D3DXINLINE FLOAT D3DXVec4Length - ( CONST D3DXVECTOR4 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); -#else - return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); -#endif -} - -D3DXINLINE FLOAT D3DXVec4LengthSq - ( CONST D3DXVECTOR4 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - - return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w; -} - -D3DXINLINE FLOAT D3DXVec4Dot - ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z + pV1->w * pV2->w; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Add - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + pV2->x; - pOut->y = pV1->y + pV2->y; - pOut->z = pV1->z + pV2->z; - pOut->w = pV1->w + pV2->w; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Subtract - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x - pV2->x; - pOut->y = pV1->y - pV2->y; - pOut->z = pV1->z - pV2->z; - pOut->w = pV1->w - pV2->w; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Minimize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; - pOut->w = pV1->w < pV2->w ? pV1->w : pV2->w; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Maximize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; - pOut->w = pV1->w > pV2->w ? pV1->w : pV2->w; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Scale - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV) - return NULL; -#endif - - pOut->x = pV->x * s; - pOut->y = pV->y * s; - pOut->z = pV->z * s; - pOut->w = pV->w * s; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Lerp - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - FLOAT s ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + s * (pV2->x - pV1->x); - pOut->y = pV1->y + s * (pV2->y - pV1->y); - pOut->z = pV1->z + s * (pV2->z - pV1->z); - pOut->w = pV1->w + s * (pV2->w - pV1->w); - return pOut; -} - - -//-------------------------- -// 4D Matrix -//-------------------------- - -D3DXINLINE D3DXMATRIX* D3DXMatrixIdentity - ( D3DXMATRIX *pOut ) -{ -#ifdef D3DX_DEBUG - if(!pOut) - return NULL; -#endif - - pOut->m[0][1] = pOut->m[0][2] = pOut->m[0][3] = - pOut->m[1][0] = pOut->m[1][2] = pOut->m[1][3] = - pOut->m[2][0] = pOut->m[2][1] = pOut->m[2][3] = - pOut->m[3][0] = pOut->m[3][1] = pOut->m[3][2] = 0.0f; - - pOut->m[0][0] = pOut->m[1][1] = pOut->m[2][2] = pOut->m[3][3] = 1.0f; - return pOut; -} - - -D3DXINLINE BOOL D3DXMatrixIsIdentity - ( CONST D3DXMATRIX *pM ) -{ -#ifdef D3DX_DEBUG - if(!pM) - return FALSE; -#endif - - return pM->m[0][0] == 1.0f && pM->m[0][1] == 0.0f && pM->m[0][2] == 0.0f && pM->m[0][3] == 0.0f && - pM->m[1][0] == 0.0f && pM->m[1][1] == 1.0f && pM->m[1][2] == 0.0f && pM->m[1][3] == 0.0f && - pM->m[2][0] == 0.0f && pM->m[2][1] == 0.0f && pM->m[2][2] == 1.0f && pM->m[2][3] == 0.0f && - pM->m[3][0] == 0.0f && pM->m[3][1] == 0.0f && pM->m[3][2] == 0.0f && pM->m[3][3] == 1.0f; -} - - -//-------------------------- -// Quaternion -//-------------------------- - -D3DXINLINE FLOAT D3DXQuaternionLength - ( CONST D3DXQUATERNION *pQ ) -{ -#ifdef D3DX_DEBUG - if(!pQ) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); -#else - return (FLOAT) sqrt(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); -#endif -} - -D3DXINLINE FLOAT D3DXQuaternionLengthSq - ( CONST D3DXQUATERNION *pQ ) -{ -#ifdef D3DX_DEBUG - if(!pQ) - return 0.0f; -#endif - - return pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w; -} - -D3DXINLINE FLOAT D3DXQuaternionDot - ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ) -{ -#ifdef D3DX_DEBUG - if(!pQ1 || !pQ2) - return 0.0f; -#endif - - return pQ1->x * pQ2->x + pQ1->y * pQ2->y + pQ1->z * pQ2->z + pQ1->w * pQ2->w; -} - - -D3DXINLINE D3DXQUATERNION* D3DXQuaternionIdentity - ( D3DXQUATERNION *pOut ) -{ -#ifdef D3DX_DEBUG - if(!pOut) - return NULL; -#endif - - pOut->x = pOut->y = pOut->z = 0.0f; - pOut->w = 1.0f; - return pOut; -} - -D3DXINLINE BOOL D3DXQuaternionIsIdentity - ( CONST D3DXQUATERNION *pQ ) -{ -#ifdef D3DX_DEBUG - if(!pQ) - return FALSE; -#endif - - return pQ->x == 0.0f && pQ->y == 0.0f && pQ->z == 0.0f && pQ->w == 1.0f; -} - - -D3DXINLINE D3DXQUATERNION* D3DXQuaternionConjugate - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pQ) - return NULL; -#endif - - pOut->x = -pQ->x; - pOut->y = -pQ->y; - pOut->z = -pQ->z; - pOut->w = pQ->w; - return pOut; -} - - -//-------------------------- -// Plane -//-------------------------- - -D3DXINLINE FLOAT D3DXPlaneDot - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV) -{ -#ifdef D3DX_DEBUG - if(!pP || !pV) - return 0.0f; -#endif - - return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d * pV->w; -} - -D3DXINLINE FLOAT D3DXPlaneDotCoord - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV) -{ -#ifdef D3DX_DEBUG - if(!pP || !pV) - return 0.0f; -#endif - - return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d; -} - -D3DXINLINE FLOAT D3DXPlaneDotNormal - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV) -{ -#ifdef D3DX_DEBUG - if(!pP || !pV) - return 0.0f; -#endif - - return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z; -} - -D3DXINLINE D3DXPLANE* D3DXPlaneScale - (D3DXPLANE *pOut, CONST D3DXPLANE *pP, FLOAT s) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pP) - return NULL; -#endif - - pOut->a = pP->a * s; - pOut->b = pP->b * s; - pOut->c = pP->c * s; - pOut->d = pP->d * s; - return pOut; -} - - -//-------------------------- -// Color -//-------------------------- - -D3DXINLINE D3DXCOLOR* D3DXColorNegative - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC) - return NULL; -#endif - - pOut->r = 1.0f - pC->r; - pOut->g = 1.0f - pC->g; - pOut->b = 1.0f - pC->b; - pOut->a = pC->a; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorAdd - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r + pC2->r; - pOut->g = pC1->g + pC2->g; - pOut->b = pC1->b + pC2->b; - pOut->a = pC1->a + pC2->a; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorSubtract - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r - pC2->r; - pOut->g = pC1->g - pC2->g; - pOut->b = pC1->b - pC2->b; - pOut->a = pC1->a - pC2->a; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorScale - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC) - return NULL; -#endif - - pOut->r = pC->r * s; - pOut->g = pC->g * s; - pOut->b = pC->b * s; - pOut->a = pC->a * s; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorModulate - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r * pC2->r; - pOut->g = pC1->g * pC2->g; - pOut->b = pC1->b * pC2->b; - pOut->a = pC1->a * pC2->a; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorLerp - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r + s * (pC2->r - pC1->r); - pOut->g = pC1->g + s * (pC2->g - pC1->g); - pOut->b = pC1->b + s * (pC2->b - pC1->b); - pOut->a = pC1->a + s * (pC2->a - pC1->a); - return pOut; -} - - -#endif // __D3DX9MATH_INL__ - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx9math.inl +// Content: D3DX math inline functions +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DX9MATH_INL__ +#define __D3DX9MATH_INL__ + + +//=========================================================================== +// +// Inline Class Methods +// +//=========================================================================== + +#ifdef __cplusplus + +//-------------------------- +// Float16 +//-------------------------- + +D3DXINLINE +D3DXFLOAT16::D3DXFLOAT16( FLOAT f ) +{ + D3DXFloat32To16Array(this, &f, 1); +} + +D3DXINLINE +D3DXFLOAT16::D3DXFLOAT16( CONST D3DXFLOAT16& f ) +{ + value = f.value; +} + +// casting +D3DXINLINE +D3DXFLOAT16::operator FLOAT () +{ + FLOAT f; + D3DXFloat16To32Array(&f, this, 1); + return f; +} + +// binary operators +D3DXINLINE BOOL +D3DXFLOAT16::operator == ( CONST D3DXFLOAT16& f ) const +{ + return value == f.value; +} + +D3DXINLINE BOOL +D3DXFLOAT16::operator != ( CONST D3DXFLOAT16& f ) const +{ + return value != f.value; +} + + +//-------------------------- +// 2D Vector +//-------------------------- + +D3DXINLINE +D3DXVECTOR2::D3DXVECTOR2( CONST FLOAT *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; +} + +D3DXINLINE +D3DXVECTOR2::D3DXVECTOR2( CONST D3DXFLOAT16 *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + D3DXFloat16To32Array(&x, pf, 2); +} + +D3DXINLINE +D3DXVECTOR2::D3DXVECTOR2( FLOAT fx, FLOAT fy ) +{ + x = fx; + y = fy; +} + + +// casting +D3DXINLINE +D3DXVECTOR2::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DXINLINE +D3DXVECTOR2::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + + +// assignment operators +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator += ( CONST D3DXVECTOR2& v ) +{ + x += v.x; + y += v.y; + return *this; +} + +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator -= ( CONST D3DXVECTOR2& v ) +{ + x -= v.x; + y -= v.y; + return *this; +} + +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + return *this; +} + +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator - () const +{ + return D3DXVECTOR2(-x, -y); +} + + +// binary operators +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator + ( CONST D3DXVECTOR2& v ) const +{ + return D3DXVECTOR2(x + v.x, y + v.y); +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator - ( CONST D3DXVECTOR2& v ) const +{ + return D3DXVECTOR2(x - v.x, y - v.y); +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator * ( FLOAT f ) const +{ + return D3DXVECTOR2(x * f, y * f); +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXVECTOR2(x * fInv, y * fInv); +} + +D3DXINLINE D3DXVECTOR2 +operator * ( FLOAT f, CONST D3DXVECTOR2& v ) +{ + return D3DXVECTOR2(f * v.x, f * v.y); +} + +D3DXINLINE BOOL +D3DXVECTOR2::operator == ( CONST D3DXVECTOR2& v ) const +{ + return x == v.x && y == v.y; +} + +D3DXINLINE BOOL +D3DXVECTOR2::operator != ( CONST D3DXVECTOR2& v ) const +{ + return x != v.x || y != v.y; +} + + + +//-------------------------- +// 2D Vector (16 bit) +//-------------------------- + +D3DXINLINE +D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST FLOAT *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + D3DXFloat32To16Array(&x, pf, 2); +} + +D3DXINLINE +D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST D3DXFLOAT16 *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + *((DWORD *) &x) = *((DWORD *) &pf[0]); +} + +D3DXINLINE +D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy ) +{ + x = fx; + y = fy; +} + + +// casting +D3DXINLINE +D3DXVECTOR2_16F::operator D3DXFLOAT16* () +{ + return (D3DXFLOAT16*) &x; +} + +D3DXINLINE +D3DXVECTOR2_16F::operator CONST D3DXFLOAT16* () const +{ + return (CONST D3DXFLOAT16*) &x; +} + + +// binary operators +D3DXINLINE BOOL +D3DXVECTOR2_16F::operator == ( CONST D3DXVECTOR2_16F &v ) const +{ + return *((DWORD *) &x) == *((DWORD *) &v.x); +} + +D3DXINLINE BOOL +D3DXVECTOR2_16F::operator != ( CONST D3DXVECTOR2_16F &v ) const +{ + return *((DWORD *) &x) != *((DWORD *) &v.x); +} + + +//-------------------------- +// 3D Vector +//-------------------------- +D3DXINLINE +D3DXVECTOR3::D3DXVECTOR3( CONST FLOAT *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; +} + +D3DXINLINE +D3DXVECTOR3::D3DXVECTOR3( CONST D3DVECTOR& v ) +{ + x = v.x; + y = v.y; + z = v.z; +} + +D3DXINLINE +D3DXVECTOR3::D3DXVECTOR3( CONST D3DXFLOAT16 *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + D3DXFloat16To32Array(&x, pf, 3); +} + +D3DXINLINE +D3DXVECTOR3::D3DXVECTOR3( FLOAT fx, FLOAT fy, FLOAT fz ) +{ + x = fx; + y = fy; + z = fz; +} + + +// casting +D3DXINLINE +D3DXVECTOR3::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DXINLINE +D3DXVECTOR3::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + + +// assignment operators +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator += ( CONST D3DXVECTOR3& v ) +{ + x += v.x; + y += v.y; + z += v.z; + return *this; +} + +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator -= ( CONST D3DXVECTOR3& v ) +{ + x -= v.x; + y -= v.y; + z -= v.z; + return *this; +} + +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + z *= f; + return *this; +} + +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator - () const +{ + return D3DXVECTOR3(-x, -y, -z); +} + + +// binary operators +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator + ( CONST D3DXVECTOR3& v ) const +{ + return D3DXVECTOR3(x + v.x, y + v.y, z + v.z); +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator - ( CONST D3DXVECTOR3& v ) const +{ + return D3DXVECTOR3(x - v.x, y - v.y, z - v.z); +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator * ( FLOAT f ) const +{ + return D3DXVECTOR3(x * f, y * f, z * f); +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXVECTOR3(x * fInv, y * fInv, z * fInv); +} + + +D3DXINLINE D3DXVECTOR3 +operator * ( FLOAT f, CONST struct D3DXVECTOR3& v ) +{ + return D3DXVECTOR3(f * v.x, f * v.y, f * v.z); +} + + +D3DXINLINE BOOL +D3DXVECTOR3::operator == ( CONST D3DXVECTOR3& v ) const +{ + return x == v.x && y == v.y && z == v.z; +} + +D3DXINLINE BOOL +D3DXVECTOR3::operator != ( CONST D3DXVECTOR3& v ) const +{ + return x != v.x || y != v.y || z != v.z; +} + + + +//-------------------------- +// 3D Vector (16 bit) +//-------------------------- + +D3DXINLINE +D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST FLOAT *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + D3DXFloat32To16Array(&x, pf, 3); +} + +D3DXINLINE +D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DVECTOR& v ) +{ + D3DXFloat32To16Array(&x, &v.x, 1); + D3DXFloat32To16Array(&y, &v.y, 1); + D3DXFloat32To16Array(&z, &v.z, 1); +} + +D3DXINLINE +D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DXFLOAT16 *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + *((DWORD *) &x) = *((DWORD *) &pf[0]); + *((WORD *) &z) = *((WORD *) &pf[2]); +} + +D3DXINLINE +D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy, CONST D3DXFLOAT16 &fz ) +{ + x = fx; + y = fy; + z = fz; +} + + +// casting +D3DXINLINE +D3DXVECTOR3_16F::operator D3DXFLOAT16* () +{ + return (D3DXFLOAT16*) &x; +} + +D3DXINLINE +D3DXVECTOR3_16F::operator CONST D3DXFLOAT16* () const +{ + return (CONST D3DXFLOAT16*) &x; +} + + +// binary operators +D3DXINLINE BOOL +D3DXVECTOR3_16F::operator == ( CONST D3DXVECTOR3_16F &v ) const +{ + return *((DWORD *) &x) == *((DWORD *) &v.x) && + *((WORD *) &z) == *((WORD *) &v.z); +} + +D3DXINLINE BOOL +D3DXVECTOR3_16F::operator != ( CONST D3DXVECTOR3_16F &v ) const +{ + return *((DWORD *) &x) != *((DWORD *) &v.x) || + *((WORD *) &z) != *((WORD *) &v.z); +} + + +//-------------------------- +// 4D Vector +//-------------------------- +D3DXINLINE +D3DXVECTOR4::D3DXVECTOR4( CONST FLOAT *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; + w = pf[3]; +} + +D3DXINLINE +D3DXVECTOR4::D3DXVECTOR4( CONST D3DXFLOAT16 *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + D3DXFloat16To32Array(&x, pf, 4); +} + +D3DXINLINE +D3DXVECTOR4::D3DXVECTOR4( CONST D3DVECTOR& v, FLOAT f ) +{ + x = v.x; + y = v.y; + z = v.z; + w = f; +} + +D3DXINLINE +D3DXVECTOR4::D3DXVECTOR4( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) +{ + x = fx; + y = fy; + z = fz; + w = fw; +} + + +// casting +D3DXINLINE +D3DXVECTOR4::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DXINLINE +D3DXVECTOR4::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + + +// assignment operators +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator += ( CONST D3DXVECTOR4& v ) +{ + x += v.x; + y += v.y; + z += v.z; + w += v.w; + return *this; +} + +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator -= ( CONST D3DXVECTOR4& v ) +{ + x -= v.x; + y -= v.y; + z -= v.z; + w -= v.w; + return *this; +} + +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + z *= f; + w *= f; + return *this; +} + +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + w *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator - () const +{ + return D3DXVECTOR4(-x, -y, -z, -w); +} + + +// binary operators +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator + ( CONST D3DXVECTOR4& v ) const +{ + return D3DXVECTOR4(x + v.x, y + v.y, z + v.z, w + v.w); +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator - ( CONST D3DXVECTOR4& v ) const +{ + return D3DXVECTOR4(x - v.x, y - v.y, z - v.z, w - v.w); +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator * ( FLOAT f ) const +{ + return D3DXVECTOR4(x * f, y * f, z * f, w * f); +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXVECTOR4(x * fInv, y * fInv, z * fInv, w * fInv); +} + +D3DXINLINE D3DXVECTOR4 +operator * ( FLOAT f, CONST D3DXVECTOR4& v ) +{ + return D3DXVECTOR4(f * v.x, f * v.y, f * v.z, f * v.w); +} + + +D3DXINLINE BOOL +D3DXVECTOR4::operator == ( CONST D3DXVECTOR4& v ) const +{ + return x == v.x && y == v.y && z == v.z && w == v.w; +} + +D3DXINLINE BOOL +D3DXVECTOR4::operator != ( CONST D3DXVECTOR4& v ) const +{ + return x != v.x || y != v.y || z != v.z || w != v.w; +} + + + +//-------------------------- +// 4D Vector (16 bit) +//-------------------------- + +D3DXINLINE +D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST FLOAT *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + D3DXFloat32To16Array(&x, pf, 4); +} + +D3DXINLINE +D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXFLOAT16 *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + *((DWORD *) &x) = *((DWORD *) &pf[0]); + *((DWORD *) &z) = *((DWORD *) &pf[2]); +} + +D3DXINLINE +D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXVECTOR3_16F& v, CONST D3DXFLOAT16& f ) +{ + x = v.x; + y = v.y; + z = v.z; + w = f; +} + +D3DXINLINE +D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy, CONST D3DXFLOAT16 &fz, CONST D3DXFLOAT16 &fw ) +{ + x = fx; + y = fy; + z = fz; + w = fw; +} + + +// casting +D3DXINLINE +D3DXVECTOR4_16F::operator D3DXFLOAT16* () +{ + return (D3DXFLOAT16*) &x; +} + +D3DXINLINE +D3DXVECTOR4_16F::operator CONST D3DXFLOAT16* () const +{ + return (CONST D3DXFLOAT16*) &x; +} + + +// binary operators +D3DXINLINE BOOL +D3DXVECTOR4_16F::operator == ( CONST D3DXVECTOR4_16F &v ) const +{ + return *((DWORD *) &x) == *((DWORD *) &v.x) && + *((DWORD *) &z) == *((DWORD *) &v.z); +} + +D3DXINLINE BOOL +D3DXVECTOR4_16F::operator != ( CONST D3DXVECTOR4_16F &v ) const +{ + return *((DWORD *) &x) != *((DWORD *) &v.x) || + *((DWORD *) &z) != *((DWORD *) &v.z); +} + + +//-------------------------- +// Matrix +//-------------------------- +D3DXINLINE +D3DXMATRIX::D3DXMATRIX( CONST FLOAT* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + memcpy(&_11, pf, sizeof(D3DXMATRIX)); +} + +D3DXINLINE +D3DXMATRIX::D3DXMATRIX( CONST D3DMATRIX& mat ) +{ + memcpy(&_11, &mat, sizeof(D3DXMATRIX)); +} + +D3DXINLINE +D3DXMATRIX::D3DXMATRIX( CONST D3DXFLOAT16* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + D3DXFloat16To32Array(&_11, pf, 16); +} + +D3DXINLINE +D3DXMATRIX::D3DXMATRIX( FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14, + FLOAT f21, FLOAT f22, FLOAT f23, FLOAT f24, + FLOAT f31, FLOAT f32, FLOAT f33, FLOAT f34, + FLOAT f41, FLOAT f42, FLOAT f43, FLOAT f44 ) +{ + _11 = f11; _12 = f12; _13 = f13; _14 = f14; + _21 = f21; _22 = f22; _23 = f23; _24 = f24; + _31 = f31; _32 = f32; _33 = f33; _34 = f34; + _41 = f41; _42 = f42; _43 = f43; _44 = f44; +} + + + +// access grants +D3DXINLINE FLOAT& +D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) +{ + return m[iRow][iCol]; +} + +D3DXINLINE FLOAT +D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) const +{ + return m[iRow][iCol]; +} + + +// casting operators +D3DXINLINE +D3DXMATRIX::operator FLOAT* () +{ + return (FLOAT *) &_11; +} + +D3DXINLINE +D3DXMATRIX::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &_11; +} + + +// assignment operators +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator *= ( CONST D3DXMATRIX& mat ) +{ + D3DXMatrixMultiply(this, this, &mat); + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator += ( CONST D3DXMATRIX& mat ) +{ + _11 += mat._11; _12 += mat._12; _13 += mat._13; _14 += mat._14; + _21 += mat._21; _22 += mat._22; _23 += mat._23; _24 += mat._24; + _31 += mat._31; _32 += mat._32; _33 += mat._33; _34 += mat._34; + _41 += mat._41; _42 += mat._42; _43 += mat._43; _44 += mat._44; + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator -= ( CONST D3DXMATRIX& mat ) +{ + _11 -= mat._11; _12 -= mat._12; _13 -= mat._13; _14 -= mat._14; + _21 -= mat._21; _22 -= mat._22; _23 -= mat._23; _24 -= mat._24; + _31 -= mat._31; _32 -= mat._32; _33 -= mat._33; _34 -= mat._34; + _41 -= mat._41; _42 -= mat._42; _43 -= mat._43; _44 -= mat._44; + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator *= ( FLOAT f ) +{ + _11 *= f; _12 *= f; _13 *= f; _14 *= f; + _21 *= f; _22 *= f; _23 *= f; _24 *= f; + _31 *= f; _32 *= f; _33 *= f; _34 *= f; + _41 *= f; _42 *= f; _43 *= f; _44 *= f; + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + _11 *= fInv; _12 *= fInv; _13 *= fInv; _14 *= fInv; + _21 *= fInv; _22 *= fInv; _23 *= fInv; _24 *= fInv; + _31 *= fInv; _32 *= fInv; _33 *= fInv; _34 *= fInv; + _41 *= fInv; _42 *= fInv; _43 *= fInv; _44 *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator - () const +{ + return D3DXMATRIX(-_11, -_12, -_13, -_14, + -_21, -_22, -_23, -_24, + -_31, -_32, -_33, -_34, + -_41, -_42, -_43, -_44); +} + + +// binary operators +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator * ( CONST D3DXMATRIX& mat ) const +{ + D3DXMATRIX matT; + D3DXMatrixMultiply(&matT, this, &mat); + return matT; +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator + ( CONST D3DXMATRIX& mat ) const +{ + return D3DXMATRIX(_11 + mat._11, _12 + mat._12, _13 + mat._13, _14 + mat._14, + _21 + mat._21, _22 + mat._22, _23 + mat._23, _24 + mat._24, + _31 + mat._31, _32 + mat._32, _33 + mat._33, _34 + mat._34, + _41 + mat._41, _42 + mat._42, _43 + mat._43, _44 + mat._44); +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator - ( CONST D3DXMATRIX& mat ) const +{ + return D3DXMATRIX(_11 - mat._11, _12 - mat._12, _13 - mat._13, _14 - mat._14, + _21 - mat._21, _22 - mat._22, _23 - mat._23, _24 - mat._24, + _31 - mat._31, _32 - mat._32, _33 - mat._33, _34 - mat._34, + _41 - mat._41, _42 - mat._42, _43 - mat._43, _44 - mat._44); +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator * ( FLOAT f ) const +{ + return D3DXMATRIX(_11 * f, _12 * f, _13 * f, _14 * f, + _21 * f, _22 * f, _23 * f, _24 * f, + _31 * f, _32 * f, _33 * f, _34 * f, + _41 * f, _42 * f, _43 * f, _44 * f); +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXMATRIX(_11 * fInv, _12 * fInv, _13 * fInv, _14 * fInv, + _21 * fInv, _22 * fInv, _23 * fInv, _24 * fInv, + _31 * fInv, _32 * fInv, _33 * fInv, _34 * fInv, + _41 * fInv, _42 * fInv, _43 * fInv, _44 * fInv); +} + + +D3DXINLINE D3DXMATRIX +operator * ( FLOAT f, CONST D3DXMATRIX& mat ) +{ + return D3DXMATRIX(f * mat._11, f * mat._12, f * mat._13, f * mat._14, + f * mat._21, f * mat._22, f * mat._23, f * mat._24, + f * mat._31, f * mat._32, f * mat._33, f * mat._34, + f * mat._41, f * mat._42, f * mat._43, f * mat._44); +} + + +D3DXINLINE BOOL +D3DXMATRIX::operator == ( CONST D3DXMATRIX& mat ) const +{ + return 0 == memcmp(this, &mat, sizeof(D3DXMATRIX)); +} + +D3DXINLINE BOOL +D3DXMATRIX::operator != ( CONST D3DXMATRIX& mat ) const +{ + return 0 != memcmp(this, &mat, sizeof(D3DXMATRIX)); +} + + + +//-------------------------- +// Aligned Matrices +//-------------------------- + +D3DXINLINE +_D3DXMATRIXA16::_D3DXMATRIXA16( CONST FLOAT* f ) : + D3DXMATRIX( f ) +{ +} + +D3DXINLINE +_D3DXMATRIXA16::_D3DXMATRIXA16( CONST D3DMATRIX& m ) : + D3DXMATRIX( m ) +{ +} + +D3DXINLINE +_D3DXMATRIXA16::_D3DXMATRIXA16( CONST D3DXFLOAT16* f ) : + D3DXMATRIX( f ) +{ +} + +D3DXINLINE +_D3DXMATRIXA16::_D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, + FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, + FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, + FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ) : + D3DXMATRIX(_11, _12, _13, _14, + _21, _22, _23, _24, + _31, _32, _33, _34, + _41, _42, _43, _44) +{ +} + +D3DXINLINE void* +_D3DXMATRIXA16::operator new( size_t s ) +{ + LPBYTE p = ::new BYTE[s + 16]; + if (p) + { + BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); + p += offset; + p[-1] = offset; + } + return p; +} + +D3DXINLINE void* +_D3DXMATRIXA16::operator new[]( size_t s ) +{ + LPBYTE p = ::new BYTE[s + 16]; + if (p) + { + BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); + p += offset; + p[-1] = offset; + } + return p; +} + +D3DXINLINE void +_D3DXMATRIXA16::operator delete(void* p) +{ + if(p) + { + BYTE* pb = static_cast(p); + pb -= pb[-1]; + ::delete [] pb; + } +} + +D3DXINLINE void +_D3DXMATRIXA16::operator delete[](void* p) +{ + if(p) + { + BYTE* pb = static_cast(p); + pb -= pb[-1]; + ::delete [] pb; + } +} + +D3DXINLINE _D3DXMATRIXA16& +_D3DXMATRIXA16::operator=(CONST D3DXMATRIX& rhs) +{ + memcpy(&_11, &rhs, sizeof(D3DXMATRIX)); + return *this; +} + + +//-------------------------- +// Quaternion +//-------------------------- + +D3DXINLINE +D3DXQUATERNION::D3DXQUATERNION( CONST FLOAT* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; + w = pf[3]; +} + +D3DXINLINE +D3DXQUATERNION::D3DXQUATERNION( CONST D3DXFLOAT16* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + D3DXFloat16To32Array(&x, pf, 4); +} + +D3DXINLINE +D3DXQUATERNION::D3DXQUATERNION( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) +{ + x = fx; + y = fy; + z = fz; + w = fw; +} + + +// casting +D3DXINLINE +D3DXQUATERNION::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DXINLINE +D3DXQUATERNION::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + + +// assignment operators +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator += ( CONST D3DXQUATERNION& q ) +{ + x += q.x; + y += q.y; + z += q.z; + w += q.w; + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator -= ( CONST D3DXQUATERNION& q ) +{ + x -= q.x; + y -= q.y; + z -= q.z; + w -= q.w; + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator *= ( CONST D3DXQUATERNION& q ) +{ + D3DXQuaternionMultiply(this, this, &q); + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + z *= f; + w *= f; + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + w *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator - () const +{ + return D3DXQUATERNION(-x, -y, -z, -w); +} + + +// binary operators +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator + ( CONST D3DXQUATERNION& q ) const +{ + return D3DXQUATERNION(x + q.x, y + q.y, z + q.z, w + q.w); +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator - ( CONST D3DXQUATERNION& q ) const +{ + return D3DXQUATERNION(x - q.x, y - q.y, z - q.z, w - q.w); +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator * ( CONST D3DXQUATERNION& q ) const +{ + D3DXQUATERNION qT; + D3DXQuaternionMultiply(&qT, this, &q); + return qT; +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator * ( FLOAT f ) const +{ + return D3DXQUATERNION(x * f, y * f, z * f, w * f); +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXQUATERNION(x * fInv, y * fInv, z * fInv, w * fInv); +} + + +D3DXINLINE D3DXQUATERNION +operator * (FLOAT f, CONST D3DXQUATERNION& q ) +{ + return D3DXQUATERNION(f * q.x, f * q.y, f * q.z, f * q.w); +} + + +D3DXINLINE BOOL +D3DXQUATERNION::operator == ( CONST D3DXQUATERNION& q ) const +{ + return x == q.x && y == q.y && z == q.z && w == q.w; +} + +D3DXINLINE BOOL +D3DXQUATERNION::operator != ( CONST D3DXQUATERNION& q ) const +{ + return x != q.x || y != q.y || z != q.z || w != q.w; +} + + + +//-------------------------- +// Plane +//-------------------------- + +D3DXINLINE +D3DXPLANE::D3DXPLANE( CONST FLOAT* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + a = pf[0]; + b = pf[1]; + c = pf[2]; + d = pf[3]; +} + +D3DXINLINE +D3DXPLANE::D3DXPLANE( CONST D3DXFLOAT16* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + D3DXFloat16To32Array(&a, pf, 4); +} + +D3DXINLINE +D3DXPLANE::D3DXPLANE( FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd ) +{ + a = fa; + b = fb; + c = fc; + d = fd; +} + + +// casting +D3DXINLINE +D3DXPLANE::operator FLOAT* () +{ + return (FLOAT *) &a; +} + +D3DXINLINE +D3DXPLANE::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &a; +} + + +// assignment operators +D3DXINLINE D3DXPLANE& +D3DXPLANE::operator *= ( FLOAT f ) +{ + a *= f; + b *= f; + c *= f; + d *= f; + return *this; +} + +D3DXINLINE D3DXPLANE& +D3DXPLANE::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + a *= fInv; + b *= fInv; + c *= fInv; + d *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXPLANE +D3DXPLANE::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXPLANE +D3DXPLANE::operator - () const +{ + return D3DXPLANE(-a, -b, -c, -d); +} + + +// binary operators +D3DXINLINE D3DXPLANE +D3DXPLANE::operator * ( FLOAT f ) const +{ + return D3DXPLANE(a * f, b * f, c * f, d * f); +} + +D3DXINLINE D3DXPLANE +D3DXPLANE::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXPLANE(a * fInv, b * fInv, c * fInv, d * fInv); +} + +D3DXINLINE D3DXPLANE +operator * (FLOAT f, CONST D3DXPLANE& p ) +{ + return D3DXPLANE(f * p.a, f * p.b, f * p.c, f * p.d); +} + +D3DXINLINE BOOL +D3DXPLANE::operator == ( CONST D3DXPLANE& p ) const +{ + return a == p.a && b == p.b && c == p.c && d == p.d; +} + +D3DXINLINE BOOL +D3DXPLANE::operator != ( CONST D3DXPLANE& p ) const +{ + return a != p.a || b != p.b || c != p.c || d != p.d; +} + + + + +//-------------------------- +// Color +//-------------------------- + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( DWORD dw ) +{ + CONST FLOAT f = 1.0f / 255.0f; + r = f * (FLOAT) (unsigned char) (dw >> 16); + g = f * (FLOAT) (unsigned char) (dw >> 8); + b = f * (FLOAT) (unsigned char) (dw >> 0); + a = f * (FLOAT) (unsigned char) (dw >> 24); +} + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( CONST FLOAT* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + r = pf[0]; + g = pf[1]; + b = pf[2]; + a = pf[3]; +} + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( CONST D3DXFLOAT16* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + D3DXFloat16To32Array(&r, pf, 4); +} + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( CONST D3DCOLORVALUE& c ) +{ + r = c.r; + g = c.g; + b = c.b; + a = c.a; +} + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( FLOAT fr, FLOAT fg, FLOAT fb, FLOAT fa ) +{ + r = fr; + g = fg; + b = fb; + a = fa; +} + + +// casting +D3DXINLINE +D3DXCOLOR::operator DWORD () const +{ + DWORD dwR = r >= 1.0f ? 0xff : r <= 0.0f ? 0x00 : (DWORD) (r * 255.0f + 0.5f); + DWORD dwG = g >= 1.0f ? 0xff : g <= 0.0f ? 0x00 : (DWORD) (g * 255.0f + 0.5f); + DWORD dwB = b >= 1.0f ? 0xff : b <= 0.0f ? 0x00 : (DWORD) (b * 255.0f + 0.5f); + DWORD dwA = a >= 1.0f ? 0xff : a <= 0.0f ? 0x00 : (DWORD) (a * 255.0f + 0.5f); + + return (dwA << 24) | (dwR << 16) | (dwG << 8) | dwB; +} + + +D3DXINLINE +D3DXCOLOR::operator FLOAT * () +{ + return (FLOAT *) &r; +} + +D3DXINLINE +D3DXCOLOR::operator CONST FLOAT * () const +{ + return (CONST FLOAT *) &r; +} + + +D3DXINLINE +D3DXCOLOR::operator D3DCOLORVALUE * () +{ + return (D3DCOLORVALUE *) &r; +} + +D3DXINLINE +D3DXCOLOR::operator CONST D3DCOLORVALUE * () const +{ + return (CONST D3DCOLORVALUE *) &r; +} + + +D3DXINLINE +D3DXCOLOR::operator D3DCOLORVALUE& () +{ + return *((D3DCOLORVALUE *) &r); +} + +D3DXINLINE +D3DXCOLOR::operator CONST D3DCOLORVALUE& () const +{ + return *((CONST D3DCOLORVALUE *) &r); +} + + +// assignment operators +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator += ( CONST D3DXCOLOR& c ) +{ + r += c.r; + g += c.g; + b += c.b; + a += c.a; + return *this; +} + +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator -= ( CONST D3DXCOLOR& c ) +{ + r -= c.r; + g -= c.g; + b -= c.b; + a -= c.a; + return *this; +} + +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator *= ( FLOAT f ) +{ + r *= f; + g *= f; + b *= f; + a *= f; + return *this; +} + +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + r *= fInv; + g *= fInv; + b *= fInv; + a *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator - () const +{ + return D3DXCOLOR(-r, -g, -b, -a); +} + + +// binary operators +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator + ( CONST D3DXCOLOR& c ) const +{ + return D3DXCOLOR(r + c.r, g + c.g, b + c.b, a + c.a); +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator - ( CONST D3DXCOLOR& c ) const +{ + return D3DXCOLOR(r - c.r, g - c.g, b - c.b, a - c.a); +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator * ( FLOAT f ) const +{ + return D3DXCOLOR(r * f, g * f, b * f, a * f); +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXCOLOR(r * fInv, g * fInv, b * fInv, a * fInv); +} + + +D3DXINLINE D3DXCOLOR +operator * (FLOAT f, CONST D3DXCOLOR& c ) +{ + return D3DXCOLOR(f * c.r, f * c.g, f * c.b, f * c.a); +} + + +D3DXINLINE BOOL +D3DXCOLOR::operator == ( CONST D3DXCOLOR& c ) const +{ + return r == c.r && g == c.g && b == c.b && a == c.a; +} + +D3DXINLINE BOOL +D3DXCOLOR::operator != ( CONST D3DXCOLOR& c ) const +{ + return r != c.r || g != c.g || b != c.b || a != c.a; +} + + +#endif //__cplusplus + + + +//=========================================================================== +// +// Inline functions +// +//=========================================================================== + + +//-------------------------- +// 2D Vector +//-------------------------- + +D3DXINLINE FLOAT D3DXVec2Length + ( CONST D3DXVECTOR2 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y); +#else + return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y); +#endif +} + +D3DXINLINE FLOAT D3DXVec2LengthSq + ( CONST D3DXVECTOR2 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y; +} + +D3DXINLINE FLOAT D3DXVec2Dot + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y; +} + +D3DXINLINE FLOAT D3DXVec2CCW + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->y - pV1->y * pV2->x; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Add + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Subtract + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Minimize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Maximize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Scale + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Lerp + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + FLOAT s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + return pOut; +} + + +//-------------------------- +// 3D Vector +//-------------------------- + +D3DXINLINE FLOAT D3DXVec3Length + ( CONST D3DXVECTOR3 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); +#else + return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); +#endif +} + +D3DXINLINE FLOAT D3DXVec3LengthSq + ( CONST D3DXVECTOR3 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z; +} + +D3DXINLINE FLOAT D3DXVec3Dot + ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Cross + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ + D3DXVECTOR3 v; + +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + 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 D3DXVECTOR3* D3DXVec3Add + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + pOut->z = pV1->z + pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Subtract + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + pOut->z = pV1->z - pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Minimize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Maximize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Scale + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + pOut->z = pV->z * s; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Lerp + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + FLOAT s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + pOut->z = pV1->z + s * (pV2->z - pV1->z); + return pOut; +} + + +//-------------------------- +// 4D Vector +//-------------------------- + +D3DXINLINE FLOAT D3DXVec4Length + ( CONST D3DXVECTOR4 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); +#else + return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); +#endif +} + +D3DXINLINE FLOAT D3DXVec4LengthSq + ( CONST D3DXVECTOR4 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w; +} + +D3DXINLINE FLOAT D3DXVec4Dot + ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z + pV1->w * pV2->w; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Add + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + pOut->z = pV1->z + pV2->z; + pOut->w = pV1->w + pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Subtract + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + pOut->z = pV1->z - pV2->z; + pOut->w = pV1->w - pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Minimize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; + pOut->w = pV1->w < pV2->w ? pV1->w : pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Maximize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; + pOut->w = pV1->w > pV2->w ? pV1->w : pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Scale + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + pOut->z = pV->z * s; + pOut->w = pV->w * s; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Lerp + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + FLOAT s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + pOut->z = pV1->z + s * (pV2->z - pV1->z); + pOut->w = pV1->w + s * (pV2->w - pV1->w); + return pOut; +} + + +//-------------------------- +// 4D Matrix +//-------------------------- + +D3DXINLINE D3DXMATRIX* D3DXMatrixIdentity + ( D3DXMATRIX *pOut ) +{ +#ifdef D3DX_DEBUG + if(!pOut) + return NULL; +#endif + + pOut->m[0][1] = pOut->m[0][2] = pOut->m[0][3] = + pOut->m[1][0] = pOut->m[1][2] = pOut->m[1][3] = + pOut->m[2][0] = pOut->m[2][1] = pOut->m[2][3] = + pOut->m[3][0] = pOut->m[3][1] = pOut->m[3][2] = 0.0f; + + pOut->m[0][0] = pOut->m[1][1] = pOut->m[2][2] = pOut->m[3][3] = 1.0f; + return pOut; +} + + +D3DXINLINE BOOL D3DXMatrixIsIdentity + ( CONST D3DXMATRIX *pM ) +{ +#ifdef D3DX_DEBUG + if(!pM) + return FALSE; +#endif + + return pM->m[0][0] == 1.0f && pM->m[0][1] == 0.0f && pM->m[0][2] == 0.0f && pM->m[0][3] == 0.0f && + pM->m[1][0] == 0.0f && pM->m[1][1] == 1.0f && pM->m[1][2] == 0.0f && pM->m[1][3] == 0.0f && + pM->m[2][0] == 0.0f && pM->m[2][1] == 0.0f && pM->m[2][2] == 1.0f && pM->m[2][3] == 0.0f && + pM->m[3][0] == 0.0f && pM->m[3][1] == 0.0f && pM->m[3][2] == 0.0f && pM->m[3][3] == 1.0f; +} + + +//-------------------------- +// Quaternion +//-------------------------- + +D3DXINLINE FLOAT D3DXQuaternionLength + ( CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pQ) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); +#else + return (FLOAT) sqrt(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); +#endif +} + +D3DXINLINE FLOAT D3DXQuaternionLengthSq + ( CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pQ) + return 0.0f; +#endif + + return pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w; +} + +D3DXINLINE FLOAT D3DXQuaternionDot + ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ) +{ +#ifdef D3DX_DEBUG + if(!pQ1 || !pQ2) + return 0.0f; +#endif + + return pQ1->x * pQ2->x + pQ1->y * pQ2->y + pQ1->z * pQ2->z + pQ1->w * pQ2->w; +} + + +D3DXINLINE D3DXQUATERNION* D3DXQuaternionIdentity + ( D3DXQUATERNION *pOut ) +{ +#ifdef D3DX_DEBUG + if(!pOut) + return NULL; +#endif + + pOut->x = pOut->y = pOut->z = 0.0f; + pOut->w = 1.0f; + return pOut; +} + +D3DXINLINE BOOL D3DXQuaternionIsIdentity + ( CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pQ) + return FALSE; +#endif + + return pQ->x == 0.0f && pQ->y == 0.0f && pQ->z == 0.0f && pQ->w == 1.0f; +} + + +D3DXINLINE D3DXQUATERNION* D3DXQuaternionConjugate + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pQ) + return NULL; +#endif + + pOut->x = -pQ->x; + pOut->y = -pQ->y; + pOut->z = -pQ->z; + pOut->w = pQ->w; + return pOut; +} + + +//-------------------------- +// Plane +//-------------------------- + +D3DXINLINE FLOAT D3DXPlaneDot + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV) +{ +#ifdef D3DX_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d * pV->w; +} + +D3DXINLINE FLOAT D3DXPlaneDotCoord + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV) +{ +#ifdef D3DX_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d; +} + +D3DXINLINE FLOAT D3DXPlaneDotNormal + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV) +{ +#ifdef D3DX_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z; +} + +D3DXINLINE D3DXPLANE* D3DXPlaneScale + (D3DXPLANE *pOut, CONST D3DXPLANE *pP, FLOAT s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pP) + return NULL; +#endif + + pOut->a = pP->a * s; + pOut->b = pP->b * s; + pOut->c = pP->c * s; + pOut->d = pP->d * s; + return pOut; +} + + +//-------------------------- +// Color +//-------------------------- + +D3DXINLINE D3DXCOLOR* D3DXColorNegative + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC) + return NULL; +#endif + + pOut->r = 1.0f - pC->r; + pOut->g = 1.0f - pC->g; + pOut->b = 1.0f - pC->b; + pOut->a = pC->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorAdd + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r + pC2->r; + pOut->g = pC1->g + pC2->g; + pOut->b = pC1->b + pC2->b; + pOut->a = pC1->a + pC2->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorSubtract + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r - pC2->r; + pOut->g = pC1->g - pC2->g; + pOut->b = pC1->b - pC2->b; + pOut->a = pC1->a - pC2->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorScale + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC) + return NULL; +#endif + + pOut->r = pC->r * s; + pOut->g = pC->g * s; + pOut->b = pC->b * s; + pOut->a = pC->a * s; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorModulate + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r * pC2->r; + pOut->g = pC1->g * pC2->g; + pOut->b = pC1->b * pC2->b; + pOut->a = pC1->a * pC2->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorLerp + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r + s * (pC2->r - pC1->r); + pOut->g = pC1->g + s * (pC2->g - pC1->g); + pOut->b = pC1->b + s * (pC2->b - pC1->b); + pOut->a = pC1->a + s * (pC2->a - pC1->a); + return pOut; +} + + +#endif // __D3DX9MATH_INL__ + diff --git a/src/dep/include/DXSDK/include/d3dx9mesh.h b/src/dep/include/DXSDK/include/d3dx9mesh.h index 5df9139..2f81eaf 100644 --- a/src/dep/include/DXSDK/include/d3dx9mesh.h +++ b/src/dep/include/DXSDK/include/d3dx9mesh.h @@ -1,2992 +1,2992 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx9mesh.h -// Content: D3DX mesh types and functions -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx9.h" - -#ifndef __D3DX9MESH_H__ -#define __D3DX9MESH_H__ - -// {7ED943DD-52E8-40b5-A8D8-76685C406330} -DEFINE_GUID(IID_ID3DXBaseMesh, -0x7ed943dd, 0x52e8, 0x40b5, 0xa8, 0xd8, 0x76, 0x68, 0x5c, 0x40, 0x63, 0x30); - -// {4020E5C2-1403-4929-883F-E2E849FAC195} -DEFINE_GUID(IID_ID3DXMesh, -0x4020e5c2, 0x1403, 0x4929, 0x88, 0x3f, 0xe2, 0xe8, 0x49, 0xfa, 0xc1, 0x95); - -// {8875769A-D579-4088-AAEB-534D1AD84E96} -DEFINE_GUID(IID_ID3DXPMesh, -0x8875769a, 0xd579, 0x4088, 0xaa, 0xeb, 0x53, 0x4d, 0x1a, 0xd8, 0x4e, 0x96); - -// {667EA4C7-F1CD-4386-B523-7C0290B83CC5} -DEFINE_GUID(IID_ID3DXSPMesh, -0x667ea4c7, 0xf1cd, 0x4386, 0xb5, 0x23, 0x7c, 0x2, 0x90, 0xb8, 0x3c, 0xc5); - -// {11EAA540-F9A6-4d49-AE6A-E19221F70CC4} -DEFINE_GUID(IID_ID3DXSkinInfo, -0x11eaa540, 0xf9a6, 0x4d49, 0xae, 0x6a, 0xe1, 0x92, 0x21, 0xf7, 0xc, 0xc4); - -// {3CE6CC22-DBF2-44f4-894D-F9C34A337139} -DEFINE_GUID(IID_ID3DXPatchMesh, -0x3ce6cc22, 0xdbf2, 0x44f4, 0x89, 0x4d, 0xf9, 0xc3, 0x4a, 0x33, 0x71, 0x39); - -//patch mesh can be quads or tris -typedef enum _D3DXPATCHMESHTYPE { - D3DXPATCHMESH_RECT = 0x001, - D3DXPATCHMESH_TRI = 0x002, - D3DXPATCHMESH_NPATCH = 0x003, - - D3DXPATCHMESH_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} D3DXPATCHMESHTYPE; - -// Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags -enum _D3DXMESH { - D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. - D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB. - D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. - D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. - D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. - D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER - D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. - D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB. - D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB. - D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB. - D3DXMESH_IB_SYSTEMMEM = 0x100, // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER - D3DXMESH_IB_MANAGED = 0x200, // Use D3DPOOL_MANAGED for IB. - D3DXMESH_IB_WRITEONLY = 0x400, // Use D3DUSAGE_WRITEONLY for IB. - D3DXMESH_IB_DYNAMIC = 0x800, // Use D3DUSAGE_DYNAMIC for IB. - D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, // Use D3DUSAGE_SOFTWAREPROCESSING for IB. - - D3DXMESH_VB_SHARE = 0x1000, // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer - - D3DXMESH_USEHWONLY = 0x2000, // Valid for ID3DXSkinInfo::ConvertToBlendedMesh - - // Helper options - D3DXMESH_SYSTEMMEM = 0x110, // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM - D3DXMESH_MANAGED = 0x220, // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED - D3DXMESH_WRITEONLY = 0x440, // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY - D3DXMESH_DYNAMIC = 0x880, // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC - D3DXMESH_SOFTWAREPROCESSING = 0x18000, // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING - -}; - -//patch mesh options -enum _D3DXPATCHMESH { - D3DXPATCHMESH_DEFAULT = 000, -}; -// option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh -enum _D3DXMESHSIMP -{ - D3DXMESHSIMP_VERTEX = 0x1, - D3DXMESHSIMP_FACE = 0x2, - -}; - -typedef enum _D3DXCLEANTYPE { - D3DXCLEAN_BACKFACING = 0x00000001, - D3DXCLEAN_BOWTIES = 0x00000002, - - // Helper options - D3DXCLEAN_SKINNING = D3DXCLEAN_BACKFACING, // Bowtie cleaning modifies geometry and breaks skinning - D3DXCLEAN_OPTIMIZATION = D3DXCLEAN_BACKFACING, - D3DXCLEAN_SIMPLIFICATION= D3DXCLEAN_BACKFACING | D3DXCLEAN_BOWTIES, -} D3DXCLEANTYPE; - -enum _MAX_FVF_DECL_SIZE -{ - MAX_FVF_DECL_SIZE = MAXD3DDECLLENGTH + 1 // +1 for END -}; - -typedef enum _D3DXTANGENT -{ - D3DXTANGENT_WRAP_U = 0x01, - D3DXTANGENT_WRAP_V = 0x02, - D3DXTANGENT_WRAP_UV = 0x03, - D3DXTANGENT_DONT_NORMALIZE_PARTIALS = 0x04, - D3DXTANGENT_DONT_ORTHOGONALIZE = 0x08, - D3DXTANGENT_ORTHOGONALIZE_FROM_V = 0x010, - D3DXTANGENT_ORTHOGONALIZE_FROM_U = 0x020, - D3DXTANGENT_WEIGHT_BY_AREA = 0x040, - D3DXTANGENT_WEIGHT_EQUAL = 0x080, - D3DXTANGENT_WIND_CW = 0x0100, - D3DXTANGENT_CALCULATE_NORMALS = 0x0200, - D3DXTANGENT_GENERATE_IN_PLACE = 0x0400, -} D3DXTANGENT; - -// D3DXIMT_WRAP_U means the texture wraps in the U direction -// D3DXIMT_WRAP_V means the texture wraps in the V direction -// D3DXIMT_WRAP_UV means the texture wraps in both directions -typedef enum _D3DXIMT -{ - D3DXIMT_WRAP_U = 0x01, - D3DXIMT_WRAP_V = 0x02, - D3DXIMT_WRAP_UV = 0x03, -} D3DXIMT; - - -typedef struct ID3DXBaseMesh *LPD3DXBASEMESH; -typedef struct ID3DXMesh *LPD3DXMESH; -typedef struct ID3DXPMesh *LPD3DXPMESH; -typedef struct ID3DXSPMesh *LPD3DXSPMESH; -typedef struct ID3DXSkinInfo *LPD3DXSKININFO; -typedef struct ID3DXPatchMesh *LPD3DXPATCHMESH; -typedef interface ID3DXTextureGutterHelper *LPD3DXTEXTUREGUTTERHELPER; -typedef interface ID3DXPRTBuffer *LPD3DXPRTBUFFER; - - -typedef struct _D3DXATTRIBUTERANGE -{ - DWORD AttribId; - DWORD FaceStart; - DWORD FaceCount; - DWORD VertexStart; - DWORD VertexCount; -} D3DXATTRIBUTERANGE; - -typedef D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE; - -typedef struct _D3DXMATERIAL -{ - D3DMATERIAL9 MatD3D; - LPSTR pTextureFilename; -} D3DXMATERIAL; -typedef D3DXMATERIAL *LPD3DXMATERIAL; - -typedef enum _D3DXEFFECTDEFAULTTYPE -{ - D3DXEDT_STRING = 0x1, // pValue points to a null terminated ASCII string - D3DXEDT_FLOATS = 0x2, // pValue points to an array of floats - number of floats is NumBytes / sizeof(float) - D3DXEDT_DWORD = 0x3, // pValue points to a DWORD - - D3DXEDT_FORCEDWORD = 0x7fffffff -} D3DXEFFECTDEFAULTTYPE; - -typedef struct _D3DXEFFECTDEFAULT -{ - LPSTR pParamName; - D3DXEFFECTDEFAULTTYPE Type; // type of the data pointed to by pValue - DWORD NumBytes; // size in bytes of the data pointed to by pValue - LPVOID pValue; // data for the default of the effect -} D3DXEFFECTDEFAULT, *LPD3DXEFFECTDEFAULT; - -typedef struct _D3DXEFFECTINSTANCE -{ - LPSTR pEffectFilename; - DWORD NumDefaults; - LPD3DXEFFECTDEFAULT pDefaults; -} D3DXEFFECTINSTANCE, *LPD3DXEFFECTINSTANCE; - -typedef struct _D3DXATTRIBUTEWEIGHTS -{ - FLOAT Position; - FLOAT Boundary; - FLOAT Normal; - FLOAT Diffuse; - FLOAT Specular; - FLOAT Texcoord[8]; - FLOAT Tangent; - FLOAT Binormal; -} D3DXATTRIBUTEWEIGHTS, *LPD3DXATTRIBUTEWEIGHTS; - -enum _D3DXWELDEPSILONSFLAGS -{ - D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping - - D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched - // vertices so that both components identical AND if all components "equal" - // remove one of the vertices - D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal - // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set - // useful to modify vertices to be equal, but not allow vertices to be removed - - D3DXWELDEPSILONS_DONOTSPLIT = 0x8, // instructs weld to specify the D3DXMESHOPT_DONOTSPLIT flag when doing an Optimize(ATTR_SORT) - // if this flag is not set, all vertices that are in separate attribute groups - // will remain split and not welded. Setting this flag can slow down software vertex processing - -}; - -typedef struct _D3DXWELDEPSILONS -{ - FLOAT Position; // NOTE: This does NOT replace the epsilon in GenerateAdjacency - // in general, it should be the same value or greater than the one passed to GeneratedAdjacency - FLOAT BlendWeights; - FLOAT Normal; - FLOAT PSize; - FLOAT Specular; - FLOAT Diffuse; - FLOAT Texcoord[8]; - FLOAT Tangent; - FLOAT Binormal; - FLOAT TessFactor; -} D3DXWELDEPSILONS; - -typedef D3DXWELDEPSILONS* LPD3DXWELDEPSILONS; - - -#undef INTERFACE -#define INTERFACE ID3DXBaseMesh - -DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBaseMesh - STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(GetAttributeTable)( - THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; - - STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; - STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; - STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; - - STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; -}; - - -#undef INTERFACE -#define INTERFACE ID3DXMesh - -DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBaseMesh - STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(GetAttributeTable)( - THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; - - STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; - STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; - STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; - - STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; - - // ID3DXMesh - STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE; - STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; - STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppOptMesh) PURE; - STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap) PURE; - STDMETHOD(SetAttributeTable)(THIS_ CONST D3DXATTRIBUTERANGE *pAttribTable, DWORD cAttribTableSize) PURE; -}; - - -#undef INTERFACE -#define INTERFACE ID3DXPMesh - -DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBaseMesh - STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(GetAttributeTable)( - THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; - - STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; - STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; - STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; - - STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; - - // ID3DXPMesh - STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMesh)(THIS_ DWORD Options, - CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(SetNumFaces)(THIS_ DWORD Faces) PURE; - STDMETHOD(SetNumVertices)(THIS_ DWORD Vertices) PURE; - STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetMinFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetMinVertices)(THIS) PURE; - STDMETHOD(Save)(THIS_ IStream *pStream, CONST D3DXMATERIAL* pMaterials, CONST D3DXEFFECTINSTANCE* pEffectInstances, DWORD NumMaterials) PURE; - - STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppOptMesh) PURE; - - STDMETHOD(OptimizeBaseLOD)(THIS_ DWORD Flags, DWORD* pFaceRemap) PURE; - STDMETHOD(TrimByFaces)(THIS_ DWORD NewFacesMin, DWORD NewFacesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; - STDMETHOD(TrimByVertices)(THIS_ DWORD NewVerticesMin, DWORD NewVerticesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; - - STDMETHOD(GetAdjacency)(THIS_ DWORD* pAdjacency) PURE; - - // Used to generate the immediate "ancestor" for each vertex when it is removed by a vsplit. Allows generation of geomorphs - // Vertex buffer must be equal to or greater than the maximum number of vertices in the pmesh - STDMETHOD(GenerateVertexHistory)(THIS_ DWORD* pVertexHistory) PURE; -}; - - -#undef INTERFACE -#define INTERFACE ID3DXSPMesh - -DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXSPMesh - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pVertexRemapOut, FLOAT *pErrorsByFace, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMesh)(THIS_ DWORD Options, - CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pVertexRemapOut, FLOAT *pErrorsbyFace, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ReduceFaces)(THIS_ DWORD Faces) PURE; - STDMETHOD(ReduceVertices)(THIS_ DWORD Vertices) PURE; - STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; - STDMETHOD(GetVertexAttributeWeights)(THIS_ LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights) PURE; - STDMETHOD(GetVertexWeights)(THIS_ FLOAT *pVertexWeights) PURE; -}; - -#define UNUSED16 (0xffff) -#define UNUSED32 (0xffffffff) - -// ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags -enum _D3DXMESHOPT { - D3DXMESHOPT_COMPACT = 0x01000000, - D3DXMESHOPT_ATTRSORT = 0x02000000, - D3DXMESHOPT_VERTEXCACHE = 0x04000000, - D3DXMESHOPT_STRIPREORDER = 0x08000000, - D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices - D3DXMESHOPT_DONOTSPLIT = 0x20000000, // do not split vertices shared between attribute groups when attribute sorting - D3DXMESHOPT_DEVICEINDEPENDENT = 0x00400000, // Only affects VCache. uses a static known good cache size for all cards - - // D3DXMESHOPT_SHAREVB has been removed, please use D3DXMESH_VB_SHARE instead - -}; - -// Subset of the mesh that has the same attribute and bone combination. -// This subset can be rendered in a single draw call -typedef struct _D3DXBONECOMBINATION -{ - DWORD AttribId; - DWORD FaceStart; - DWORD FaceCount; - DWORD VertexStart; - DWORD VertexCount; - DWORD* BoneId; -} D3DXBONECOMBINATION, *LPD3DXBONECOMBINATION; - -// The following types of patch combinations are supported: -// Patch type Basis Degree -// Rect Bezier 2,3,5 -// Rect B-Spline 2,3,5 -// Rect Catmull-Rom 3 -// Tri Bezier 2,3,5 -// N-Patch N/A 3 - -typedef struct _D3DXPATCHINFO -{ - D3DXPATCHMESHTYPE PatchType; - D3DDEGREETYPE Degree; - D3DBASISTYPE Basis; -} D3DXPATCHINFO, *LPD3DXPATCHINFO; - -#undef INTERFACE -#define INTERFACE ID3DXPatchMesh - -DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXPatchMesh - - // Return creation parameters - STDMETHOD_(DWORD, GetNumPatches)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetControlVerticesPerPatch)(THIS) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9 *ppDevice) PURE; - STDMETHOD(GetPatchInfo)(THIS_ LPD3DXPATCHINFO PatchInfo) PURE; - - // Control mesh access - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, LPVOID *ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD flags, LPVOID *ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(LockAttributeBuffer)(THIS_ DWORD flags, DWORD** ppData) PURE; - STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; - - // This function returns the size of the tessellated mesh given a tessellation level. - // This assumes uniform tessellation. For adaptive tessellation the Adaptive parameter must - // be set to TRUE and TessellationLevel should be the max tessellation. - // This will result in the max mesh size necessary for adaptive tessellation. - STDMETHOD(GetTessSize)(THIS_ FLOAT fTessLevel,DWORD Adaptive, DWORD *NumTriangles,DWORD *NumVertices) PURE; - - //GenerateAdjacency determines which patches are adjacent with provided tolerance - //this information is used internally to optimize tessellation - STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Tolerance) PURE; - - //CloneMesh Creates a new patchmesh with the specified decl, and converts the vertex buffer - //to the new decl. Entries in the new decl which are new are set to 0. If the current mesh - //has adjacency, the new mesh will also have adjacency - STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDecl, LPD3DXPATCHMESH *pMesh) PURE; - - // Optimizes the patchmesh for efficient tessellation. This function is designed - // to perform one time optimization for patch meshes that need to be tessellated - // repeatedly by calling the Tessellate() method. The optimization performed is - // independent of the actual tessellation level used. - // Currently Flags is unused. - // If vertices are changed, Optimize must be called again - STDMETHOD(Optimize)(THIS_ DWORD flags) PURE; - - //gets and sets displacement parameters - //displacement maps can only be 2D textures MIP-MAPPING is ignored for non adapative tessellation - STDMETHOD(SetDisplaceParam)(THIS_ LPDIRECT3DBASETEXTURE9 Texture, - D3DTEXTUREFILTERTYPE MinFilter, - D3DTEXTUREFILTERTYPE MagFilter, - D3DTEXTUREFILTERTYPE MipFilter, - D3DTEXTUREADDRESS Wrap, - DWORD dwLODBias) PURE; - - STDMETHOD(GetDisplaceParam)(THIS_ LPDIRECT3DBASETEXTURE9 *Texture, - D3DTEXTUREFILTERTYPE *MinFilter, - D3DTEXTUREFILTERTYPE *MagFilter, - D3DTEXTUREFILTERTYPE *MipFilter, - D3DTEXTUREADDRESS *Wrap, - DWORD *dwLODBias) PURE; - - // Performs the uniform tessellation based on the tessellation level. - // This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call. - STDMETHOD(Tessellate)(THIS_ FLOAT fTessLevel,LPD3DXMESH pMesh) PURE; - - // Performs adaptive tessellation based on the Z based adaptive tessellation criterion. - // pTrans specifies a 4D vector that is dotted with the vertices to get the per vertex - // adaptive tessellation amount. Each edge is tessellated to the average of the criterion - // at the 2 vertices it connects. - // MaxTessLevel specifies the upper limit for adaptive tesselation. - // This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call. - STDMETHOD(TessellateAdaptive)(THIS_ - CONST D3DXVECTOR4 *pTrans, - DWORD dwMaxTessLevel, - DWORD dwMinTessLevel, - LPD3DXMESH pMesh) PURE; - -}; - -#undef INTERFACE -#define INTERFACE ID3DXSkinInfo - -DECLARE_INTERFACE_(ID3DXSkinInfo, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // Specify the which vertices do each bones influence and by how much - STDMETHOD(SetBoneInfluence)(THIS_ DWORD bone, DWORD numInfluences, CONST DWORD* vertices, CONST FLOAT* weights) PURE; - STDMETHOD(SetBoneVertexInfluence)(THIS_ DWORD boneNum, DWORD influenceNum, float weight) PURE; - STDMETHOD_(DWORD, GetNumBoneInfluences)(THIS_ DWORD bone) PURE; - STDMETHOD(GetBoneInfluence)(THIS_ DWORD bone, DWORD* vertices, FLOAT* weights) PURE; - STDMETHOD(GetBoneVertexInfluence)(THIS_ DWORD boneNum, DWORD influenceNum, float *pWeight, DWORD *pVertexNum) PURE; - STDMETHOD(GetMaxVertexInfluences)(THIS_ DWORD* maxVertexInfluences) PURE; - STDMETHOD_(DWORD, GetNumBones)(THIS) PURE; - STDMETHOD(FindBoneVertexInfluenceIndex)(THIS_ DWORD boneNum, DWORD vertexNum, DWORD *pInfluenceIndex) PURE; - - // This gets the max face influences based on a triangle mesh with the specified index buffer - STDMETHOD(GetMaxFaceInfluences)(THIS_ LPDIRECT3DINDEXBUFFER9 pIB, DWORD NumFaces, DWORD* maxFaceInfluences) PURE; - - // Set min bone influence. Bone influences that are smaller than this are ignored - STDMETHOD(SetMinBoneInfluence)(THIS_ FLOAT MinInfl) PURE; - // Get min bone influence. - STDMETHOD_(FLOAT, GetMinBoneInfluence)(THIS) PURE; - - // Bone names are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object - STDMETHOD(SetBoneName)(THIS_ DWORD Bone, LPCSTR pName) PURE; // pName is copied to an internal string buffer - STDMETHOD_(LPCSTR, GetBoneName)(THIS_ DWORD Bone) PURE; // A pointer to an internal string buffer is returned. Do not free this. - - // Bone offset matrices are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object - STDMETHOD(SetBoneOffsetMatrix)(THIS_ DWORD Bone, CONST D3DXMATRIX *pBoneTransform) PURE; // pBoneTransform is copied to an internal buffer - STDMETHOD_(LPD3DXMATRIX, GetBoneOffsetMatrix)(THIS_ DWORD Bone) PURE; // A pointer to an internal matrix is returned. Do not free this. - - // Clone a skin info object - STDMETHOD(Clone)(THIS_ LPD3DXSKININFO* ppSkinInfo) PURE; - - // Update bone influence information to match vertices after they are reordered. This should be called - // if the target vertex buffer has been reordered externally. - STDMETHOD(Remap)(THIS_ DWORD NumVertices, DWORD* pVertexRemap) PURE; - - // These methods enable the modification of the vertex layout of the vertices that will be skinned - STDMETHOD(SetFVF)(THIS_ DWORD FVF) PURE; - STDMETHOD(SetDeclaration)(THIS_ CONST D3DVERTEXELEMENT9 *pDeclaration) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; - - // Apply SW skinning based on current pose matrices to the target vertices. - STDMETHOD(UpdateSkinnedMesh)(THIS_ - CONST D3DXMATRIX* pBoneTransforms, - CONST D3DXMATRIX* pBoneInvTransposeTransforms, - LPCVOID pVerticesSrc, - PVOID pVerticesDst) PURE; - - // Takes a mesh and returns a new mesh with per vertex blend weights and a bone combination - // table that describes which bones affect which subsets of the mesh - STDMETHOD(ConvertToBlendedMesh)(THIS_ - LPD3DXMESH pMesh, - DWORD Options, - CONST DWORD *pAdjacencyIn, - LPDWORD pAdjacencyOut, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, - DWORD* pMaxFaceInfl, - DWORD* pNumBoneCombinations, - LPD3DXBUFFER* ppBoneCombinationTable, - LPD3DXMESH* ppMesh) PURE; - - // Takes a mesh and returns a new mesh with per vertex blend weights and indices - // and a bone combination table that describes which bones palettes affect which subsets of the mesh - STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ - LPD3DXMESH pMesh, - DWORD Options, - DWORD paletteSize, - CONST DWORD *pAdjacencyIn, - LPDWORD pAdjacencyOut, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, - DWORD* pMaxVertexInfl, - DWORD* pNumBoneCombinations, - LPD3DXBUFFER* ppBoneCombinationTable, - LPD3DXMESH* ppMesh) PURE; -}; - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -HRESULT WINAPI - D3DXCreateMesh( - DWORD NumFaces, - DWORD NumVertices, - DWORD Options, - CONST D3DVERTEXELEMENT9 *pDeclaration, - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXMESH* ppMesh); - -HRESULT WINAPI - D3DXCreateMeshFVF( - DWORD NumFaces, - DWORD NumVertices, - DWORD Options, - DWORD FVF, - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXMESH* ppMesh); - -HRESULT WINAPI - D3DXCreateSPMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights, - CONST FLOAT *pVertexWeights, - LPD3DXSPMESH* ppSMesh); - -// clean a mesh up for simplification, try to make manifold -HRESULT WINAPI - D3DXCleanMesh( - D3DXCLEANTYPE CleanType, - LPD3DXMESH pMeshIn, - CONST DWORD* pAdjacencyIn, - LPD3DXMESH* ppMeshOut, - DWORD* pAdjacencyOut, - LPD3DXBUFFER* ppErrorsAndWarnings); - -HRESULT WINAPI - D3DXValidMesh( - LPD3DXMESH pMeshIn, - CONST DWORD* pAdjacency, - LPD3DXBUFFER* ppErrorsAndWarnings); - -HRESULT WINAPI - D3DXGeneratePMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights, - CONST FLOAT *pVertexWeights, - DWORD MinValue, - DWORD Options, - LPD3DXPMESH* ppPMesh); - -HRESULT WINAPI - D3DXSimplifyMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights, - CONST FLOAT *pVertexWeights, - DWORD MinValue, - DWORD Options, - LPD3DXMESH* ppMesh); - -HRESULT WINAPI - D3DXComputeBoundingSphere( - CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position - DWORD NumVertices, - DWORD dwStride, // count in bytes to subsequent position vectors - D3DXVECTOR3 *pCenter, - FLOAT *pRadius); - -HRESULT WINAPI - D3DXComputeBoundingBox( - CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position - DWORD NumVertices, - DWORD dwStride, // count in bytes to subsequent position vectors - D3DXVECTOR3 *pMin, - D3DXVECTOR3 *pMax); - -HRESULT WINAPI - D3DXComputeNormals( - LPD3DXBASEMESH pMesh, - CONST DWORD *pAdjacency); - -HRESULT WINAPI - D3DXCreateBuffer( - DWORD NumBytes, - LPD3DXBUFFER *ppBuffer); - - -HRESULT WINAPI - D3DXLoadMeshFromXA( - LPCSTR pFilename, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXLoadMeshFromXW( - LPCWSTR pFilename, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -#ifdef UNICODE -#define D3DXLoadMeshFromX D3DXLoadMeshFromXW -#else -#define D3DXLoadMeshFromX D3DXLoadMeshFromXA -#endif - -HRESULT WINAPI - D3DXLoadMeshFromXInMemory( - LPCVOID Memory, - DWORD SizeOfMemory, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXLoadMeshFromXResource( - HMODULE Module, - LPCSTR Name, - LPCSTR Type, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXSaveMeshToXA( - LPCSTR pFilename, - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST D3DXMATERIAL* pMaterials, - CONST D3DXEFFECTINSTANCE* pEffectInstances, - DWORD NumMaterials, - DWORD Format - ); - -HRESULT WINAPI - D3DXSaveMeshToXW( - LPCWSTR pFilename, - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST D3DXMATERIAL* pMaterials, - CONST D3DXEFFECTINSTANCE* pEffectInstances, - DWORD NumMaterials, - DWORD Format - ); - -#ifdef UNICODE -#define D3DXSaveMeshToX D3DXSaveMeshToXW -#else -#define D3DXSaveMeshToX D3DXSaveMeshToXA -#endif - - -HRESULT WINAPI - D3DXCreatePMeshFromStream( - IStream *pStream, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, - DWORD* pNumMaterials, - LPD3DXPMESH *ppPMesh); - -// Creates a skin info object based on the number of vertices, number of bones, and a declaration describing the vertex layout of the target vertices -// The bone names and initial bone transforms are not filled in the skin info object by this method. -HRESULT WINAPI - D3DXCreateSkinInfo( - DWORD NumVertices, - CONST D3DVERTEXELEMENT9 *pDeclaration, - DWORD NumBones, - LPD3DXSKININFO* ppSkinInfo); - -// Creates a skin info object based on the number of vertices, number of bones, and a FVF describing the vertex layout of the target vertices -// The bone names and initial bone transforms are not filled in the skin info object by this method. -HRESULT WINAPI - D3DXCreateSkinInfoFVF( - DWORD NumVertices, - DWORD FVF, - DWORD NumBones, - LPD3DXSKININFO* ppSkinInfo); - -#ifdef __cplusplus -} - -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXLoadMeshFromXof( - LPD3DXFILEDATA pxofMesh, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -// This similar to D3DXLoadMeshFromXof, except also returns skinning info if present in the file -// If skinning info is not present, ppSkinInfo will be NULL -HRESULT WINAPI - D3DXLoadSkinMeshFromXof( - LPD3DXFILEDATA pxofMesh, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXBUFFER* ppAdjacency, - LPD3DXBUFFER* ppMaterials, - LPD3DXBUFFER *ppEffectInstances, - DWORD *pMatOut, - LPD3DXSKININFO* ppSkinInfo, - LPD3DXMESH* ppMesh); - - -// The inverse of D3DXConvertTo{Indexed}BlendedMesh() functions. It figures out the skinning info from -// the mesh and the bone combination table and populates a skin info object with that data. The bone -// names and initial bone transforms are not filled in the skin info object by this method. This works -// with either a non-indexed or indexed blended mesh. It examines the FVF or declarator of the mesh to -// determine what type it is. -HRESULT WINAPI - D3DXCreateSkinInfoFromBlendedMesh( - LPD3DXBASEMESH pMesh, - DWORD NumBones, - CONST D3DXBONECOMBINATION *pBoneCombinationTable, - LPD3DXSKININFO* ppSkinInfo); - -HRESULT WINAPI - D3DXTessellateNPatches( - LPD3DXMESH pMeshIn, - CONST DWORD* pAdjacencyIn, - FLOAT NumSegs, - BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic - LPD3DXMESH *ppMeshOut, - LPD3DXBUFFER *ppAdjacencyOut); - - -//generates implied outputdecl from input decl -//the decl generated from this should be used to generate the output decl for -//the tessellator subroutines. - -HRESULT WINAPI - D3DXGenerateOutputDecl( - D3DVERTEXELEMENT9 *pOutput, - CONST D3DVERTEXELEMENT9 *pInput); - -//loads patches from an XFileData -//since an X file can have up to 6 different patch meshes in it, -//returns them in an array - pNumPatches will contain the number of -//meshes in the actual file. -HRESULT WINAPI - D3DXLoadPatchMeshFromXof( - LPD3DXFILEDATA pXofObjMesh, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, - PDWORD pNumMaterials, - LPD3DXPATCHMESH *ppMesh); - -//computes the size a single rect patch. -HRESULT WINAPI - D3DXRectPatchSize( - CONST FLOAT *pfNumSegs, //segments for each edge (4) - DWORD *pdwTriangles, //output number of triangles - DWORD *pdwVertices); //output number of vertices - -//computes the size of a single triangle patch -HRESULT WINAPI - D3DXTriPatchSize( - CONST FLOAT *pfNumSegs, //segments for each edge (3) - DWORD *pdwTriangles, //output number of triangles - DWORD *pdwVertices); //output number of vertices - - -//tessellates a patch into a created mesh -//similar to D3D RT patch -HRESULT WINAPI - D3DXTessellateRectPatch( - LPDIRECT3DVERTEXBUFFER9 pVB, - CONST FLOAT *pNumSegs, - CONST D3DVERTEXELEMENT9 *pdwInDecl, - CONST D3DRECTPATCH_INFO *pRectPatchInfo, - LPD3DXMESH pMesh); - - -HRESULT WINAPI - D3DXTessellateTriPatch( - LPDIRECT3DVERTEXBUFFER9 pVB, - CONST FLOAT *pNumSegs, - CONST D3DVERTEXELEMENT9 *pInDecl, - CONST D3DTRIPATCH_INFO *pTriPatchInfo, - LPD3DXMESH pMesh); - - - -//creates an NPatch PatchMesh from a D3DXMESH -HRESULT WINAPI - D3DXCreateNPatchMesh( - LPD3DXMESH pMeshSysMem, - LPD3DXPATCHMESH *pPatchMesh); - - -//creates a patch mesh -HRESULT WINAPI - D3DXCreatePatchMesh( - CONST D3DXPATCHINFO *pInfo, //patch type - DWORD dwNumPatches, //number of patches - DWORD dwNumVertices, //number of control vertices - DWORD dwOptions, //options - CONST D3DVERTEXELEMENT9 *pDecl, //format of control vertices - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXPATCHMESH *pPatchMesh); - - -//returns the number of degenerates in a patch mesh - -//text output put in string. -HRESULT WINAPI - D3DXValidPatchMesh(LPD3DXPATCHMESH pMesh, - DWORD *dwcDegenerateVertices, - DWORD *dwcDegeneratePatches, - LPD3DXBUFFER *ppErrorsAndWarnings); - -UINT WINAPI - D3DXGetFVFVertexSize(DWORD FVF); - -UINT WINAPI - D3DXGetDeclVertexSize(CONST D3DVERTEXELEMENT9 *pDecl,DWORD Stream); - -UINT WINAPI - D3DXGetDeclLength(CONST D3DVERTEXELEMENT9 *pDecl); - -HRESULT WINAPI - D3DXDeclaratorFromFVF( - DWORD FVF, - D3DVERTEXELEMENT9 pDeclarator[MAX_FVF_DECL_SIZE]); - -HRESULT WINAPI - D3DXFVFFromDeclarator( - CONST D3DVERTEXELEMENT9 *pDeclarator, - DWORD *pFVF); - -HRESULT WINAPI - D3DXWeldVertices( - LPD3DXMESH pMesh, - DWORD Flags, - CONST D3DXWELDEPSILONS *pEpsilons, - CONST DWORD *pAdjacencyIn, - DWORD *pAdjacencyOut, - DWORD *pFaceRemap, - LPD3DXBUFFER *ppVertexRemap); - -typedef struct _D3DXINTERSECTINFO -{ - DWORD FaceIndex; // index of face intersected - FLOAT U; // Barycentric Hit Coordinates - FLOAT V; // Barycentric Hit Coordinates - FLOAT Dist; // Ray-Intersection Parameter Distance -} D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO; - - -HRESULT WINAPI - D3DXIntersect( - LPD3DXBASEMESH pMesh, - CONST D3DXVECTOR3 *pRayPos, - CONST D3DXVECTOR3 *pRayDir, - BOOL *pHit, // True if any faces were intersected - DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) - DWORD *pCountOfHits); // Number of entries in AllHits array - -HRESULT WINAPI - D3DXIntersectSubset( - LPD3DXBASEMESH pMesh, - DWORD AttribId, - CONST D3DXVECTOR3 *pRayPos, - CONST D3DXVECTOR3 *pRayDir, - BOOL *pHit, // True if any faces were intersected - DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) - DWORD *pCountOfHits); // Number of entries in AllHits array - - -HRESULT WINAPI D3DXSplitMesh - ( - LPD3DXMESH pMeshIn, - CONST DWORD *pAdjacencyIn, - CONST DWORD MaxSize, - CONST DWORD Options, - DWORD *pMeshesOut, - LPD3DXBUFFER *ppMeshArrayOut, - LPD3DXBUFFER *ppAdjacencyArrayOut, - LPD3DXBUFFER *ppFaceRemapArrayOut, - LPD3DXBUFFER *ppVertRemapArrayOut - ); - -BOOL WINAPI D3DXIntersectTri -( - CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position - CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position - CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position - CONST D3DXVECTOR3 *pRayPos, // Ray origin - CONST D3DXVECTOR3 *pRayDir, // Ray direction - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist); // Ray-Intersection Parameter Distance - -BOOL WINAPI - D3DXSphereBoundProbe( - CONST D3DXVECTOR3 *pCenter, - FLOAT Radius, - CONST D3DXVECTOR3 *pRayPosition, - CONST D3DXVECTOR3 *pRayDirection); - -BOOL WINAPI - D3DXBoxBoundProbe( - CONST D3DXVECTOR3 *pMin, - CONST D3DXVECTOR3 *pMax, - CONST D3DXVECTOR3 *pRayPosition, - CONST D3DXVECTOR3 *pRayDirection); - - -HRESULT WINAPI D3DXComputeTangentFrame(ID3DXMesh *pMesh, - DWORD dwOptions); - -HRESULT WINAPI D3DXComputeTangentFrameEx(ID3DXMesh *pMesh, - DWORD dwTextureInSemantic, - DWORD dwTextureInIndex, - DWORD dwUPartialOutSemantic, - DWORD dwUPartialOutIndex, - DWORD dwVPartialOutSemantic, - DWORD dwVPartialOutIndex, - DWORD dwNormalOutSemantic, - DWORD dwNormalOutIndex, - DWORD dwOptions, - CONST DWORD *pdwAdjacency, - FLOAT fPartialEdgeThreshold, - FLOAT fSingularPointThreshold, - FLOAT fNormalEdgeThreshold, - ID3DXMesh **ppMeshOut, - ID3DXBuffer **ppVertexMapping); - - -//D3DXComputeTangent -// -//Computes the Tangent vectors for the TexStage texture coordinates -//and places the results in the TANGENT[TangentIndex] specified in the meshes' DECL -//puts the binorm in BINORM[BinormIndex] also specified in the decl. -// -//If neither the binorm or the tangnet are in the meshes declaration, -//the function will fail. -// -//If a tangent or Binorm field is in the Decl, but the user does not -//wish D3DXComputeTangent to replace them, then D3DX_DEFAULT specified -//in the TangentIndex or BinormIndex will cause it to ignore the specified -//semantic. -// -//Wrap should be specified if the texture coordinates wrap. - -HRESULT WINAPI D3DXComputeTangent(LPD3DXMESH Mesh, - DWORD TexStage, - DWORD TangentIndex, - DWORD BinormIndex, - DWORD Wrap, - CONST DWORD *pAdjacency); - -//============================================================================ -// -// UVAtlas apis -// -//============================================================================ -typedef HRESULT (WINAPI *LPD3DXUVATLASCB)(FLOAT fPercentDone, LPVOID lpUserContext); - -// This function creates atlases for meshes. There are two modes of operation, -// either based on the number of charts, or the maximum allowed stretch. If the -// maximum allowed stretch is 0, then each triangle will likely be in its own -// chart. - -// -// The parameters are as follows: -// pMesh - Input mesh to calculate an atlas for. This must have a position -// channel and at least a 2-d texture channel. -// uMaxChartNumber - The maximum number of charts required for the atlas. -// If this is 0, it will be parameterized based solely on -// stretch. -// fMaxStretch - The maximum amount of stretch, if 0, no stretching is allowed, -// if 1, then any amount of stretching is allowed. -// uWidth - The width of the texture the atlas will be used on. -// uHeight - The height of the texture the atlas will be used on. -// fGutter - The minimum distance, in texels between two charts on the atlas. -// this gets scaled by the width, so if fGutter is 2.5, and it is -// used on a 512x512 texture, then the minimum distance will be -// 2.5 / 512 in u-v space. -// dwTextureIndex - Specifies which texture coordinate to write to in the -// output mesh (which is cloned from the input mesh). Useful -// if your vertex has multiple texture coordinates. -// pdwAdjacency - a pointer to an array with 3 DWORDs per face, indicating -// which triangles are adjacent to each other. -// pdwFalseEdgeAdjacency - a pointer to an array with 3 DWORDS per face, indicating -// at each face, whether an edge is a false edge or not (using -// the same ordering as the adjacency data structure). If this -// is NULL, then it is assumed that there are no false edges. If -// not NULL, then a non-false edge is indicated by -1 and a false -// edge is indicated by any other value (it is not required, but -// it may be useful for the caller to use the original adjacency -// value). This allows you to parameterize a mesh of quads, and -// the edges down the middle of each quad will not be cut when -// parameterizing the mesh. -// pfIMTArray - a pointer to an array with 3 FLOATs per face, describing the -// integrated metric tensor for that face. This lets you control -// the way this triangle may be stretched in the atlas. The IMT -// passed in will be 3 floats (a,b,c) and specify a symmetric -// matrix (a b) that, given a vector (s,t), specifies the -// (b c) -// distance between a vector v1 and a vector v2 = v1 + (s,t) as -// sqrt((s, t) * M * (s, t)^T). -// In other words, this lets one specify the magnitude of the -// stretch in an arbitrary direction in u-v space. For example -// if a = b = c = 1, then this scales the vector (1,1) by 2, and -// the vector (1,-1) by 0. Note that this is multiplying the edge -// length by the square of the matrix, so if you want the face to -// stretch to twice its -// size with no shearing, the IMT value should be (2, 0, 2), which -// is just the identity matrix times 2. -// Note that this assumes you have an orientation for the triangle -// in some 2-D space. For D3DXUVAtlas, this space is created by -// letting S be the direction from the first to the second -// vertex, and T be the cross product between the normal and S. -// -// pStatusCallback - Since the atlas creation process can be very CPU intensive, -// this allows the programmer to specify a function to be called -// periodically, similarly to how it is done in the PRT simulation -// engine. -// fCallbackFrequency - This lets you specify how often the callback will be -// called. A decent default should be 0.0001f. -// pUserContext - a void pointer to be passed back to the callback function -// ppMeshOut - A pointer to a location to store a pointer for the newly created -// mesh. -// ppFacePartitioning - A pointer to a location to store a pointer for an array, -// one DWORD per face, giving the final partitioning -// created by the atlasing algorithm. -// ppVertexRemapArray - A pointer to a location to store a pointer for an array, -// one DWORD per vertex, giving the vertex it was copied -// from, if any vertices needed to be split. -// pfMaxStretchOut - A location to store the maximum stretch resulting from the -// atlasing algorithm. -// puNumChartsOut - A location to store the number of charts created, or if the -// maximum number of charts was too low, this gives the minimum -// number of charts needed to create an atlas. - -HRESULT WINAPI D3DXUVAtlasCreate(LPD3DXMESH pMesh, - UINT uMaxChartNumber, - FLOAT fMaxStretch, - UINT uWidth, - UINT uHeight, - FLOAT fGutter, - DWORD dwTextureIndex, - CONST DWORD *pdwAdjacency, - CONST DWORD *pdwFalseEdgeAdjacency, - CONST FLOAT *pfIMTArray, - LPD3DXUVATLASCB pStatusCallback, - FLOAT fCallbackFrequency, - LPVOID pUserContext, - LPD3DXMESH *ppMeshOut, - LPD3DXBUFFER *ppFacePartitioning, - LPD3DXBUFFER *ppVertexRemapArray, - FLOAT *pfMaxStretchOut, - UINT *puNumChartsOut); - -// This has the same exact arguments as Create, except that it does not perform the -// final packing step. This method allows one to get a partitioning out, and possibly -// modify it before sending it to be repacked. Note that if you change the -// partitioning, you'll also need to calculate new texture coordinates for any faces -// that have switched charts. -// -// The partition result adjacency output parameter is meant to be passed to the -// UVAtlasPack function, this adjacency cuts edges that are between adjacent -// charts, and also can include cuts inside of a chart in order to make it -// equivalent to a disc. For example: -// -// _______ -// | ___ | -// | |_| | -// |_____| -// -// In order to make this equivalent to a disc, we would need to add a cut, and it -// Would end up looking like: -// _______ -// | ___ | -// | |_|_| -// |_____| -// -// The resulting partition adjacency parameter cannot be NULL, because it is -// required for the packing step. - - - -HRESULT WINAPI D3DXUVAtlasPartition(LPD3DXMESH pMesh, - UINT uMaxChartNumber, - FLOAT fMaxStretch, - DWORD dwTextureIndex, - CONST DWORD *pdwAdjacency, - CONST DWORD *pdwFalseEdgeAdjacency, - CONST FLOAT *pfIMTArray, - LPD3DXUVATLASCB pStatusCallback, - FLOAT fCallbackFrequency, - LPVOID pUserContext, - LPD3DXMESH *ppMeshOut, - LPD3DXBUFFER *ppFacePartitioning, - LPD3DXBUFFER *ppVertexRemapArray, - LPD3DXBUFFER *ppPartitionResultAdjacency, - FLOAT *pfMaxStretchOut, - UINT *puNumChartsOut); - -// This takes the face partitioning result from Partition and packs it into an -// atlas of the given size. pdwPartitionResultAdjacency should be derived from -// the adjacency returned from the partition step. This value cannot be NULL -// because Pack needs to know where charts were cut in the partition step in -// order to find the edges of each chart. -HRESULT WINAPI D3DXUVAtlasPack(ID3DXMesh *pMesh, - UINT uWidth, - UINT uHeight, - FLOAT fGutter, - DWORD dwTextureIndex, - CONST DWORD *pdwPartitionResultAdjacency, - LPD3DXUVATLASCB pStatusCallback, - FLOAT fCallbackFrequency, - LPVOID pUserContext, - LPD3DXBUFFER pFacePartitioning); - - -//============================================================================ -// -// IMT Calculation apis -// -// These functions all compute the Integrated Metric Tensor for use in the -// UVAtlas API. They all calculate the IMT with respect to the canonical -// triangle, where the coordinate system is set up so that the u axis goes -// from vertex 0 to 1 and the v axis is N x u. So, for example, the second -// vertex's canonical uv coordinates are (d,0) where d is the distance between -// vertices 0 and 1. This way the IMT does not depend on the parameterization -// of the mesh, and if the signal over the surface doesn't change, then -// the IMT doesn't need to be recalculated. -//============================================================================ - -// This callback is used by D3DXComputeIMTFromSignal. -// -// uv - The texture coordinate for the vertex. -// uPrimitiveID - Face ID of the triangle on which to compute the signal. -// uSignalDimension - The number of floats to store in pfSignalOut. -// pUserData - The pUserData pointer passed in to ComputeIMTFromSignal. -// pfSignalOut - A pointer to where to store the signal data. -typedef HRESULT (WINAPI* LPD3DXIMTSIGNALCALLBACK) - (CONST D3DXVECTOR2 *uv, - UINT uPrimitiveID, - UINT uSignalDimension, - VOID *pUserData, - FLOAT *pfSignalOut); - -// This function is used to calculate the IMT from per vertex data. It sets -// up a linear system over the triangle, solves for the jacobian J, then -// constructs the IMT from that (J^TJ). -// This function allows you to calculate the IMT based off of any value in a -// mesh (color, normal, etc) by specifying the correct stride of the array. -// The IMT computed will cause areas of the mesh that have similar values to -// take up less space in the texture. -// -// pMesh - The mesh to calculate the IMT for. -// pVertexSignal - A float array of size uSignalStride * v, where v is the -// number of vertices in the mesh. -// uSignalDimension - How many floats per vertex to use in calculating the IMT. -// uSignalStride - The number of bytes per vertex in the array. This must be -// a multiple of sizeof(float) -// ppIMTData - Where to store the buffer holding the IMT data - -HRESULT WINAPI D3DXComputeIMTFromPerVertexSignal ( - LPD3DXMESH pMesh, - CONST FLOAT *pfVertexSignal, // uSignalDimension floats per vertex - UINT uSignalDimension, - UINT uSignalStride, // stride of signal in bytes - DWORD dwOptions, // reserved for future use - LPD3DXUVATLASCB pStatusCallback, - LPVOID pUserContext, - LPD3DXBUFFER *ppIMTData); - -// This function is used to calculate the IMT from data that varies over the -// surface of the mesh (generally at a higher frequency than vertex data). -// This function requires the mesh to already be parameterized (so it already -// has texture coordinates). It allows the user to define a signal arbitrarily -// over the surface of the mesh. -// -// pMesh - The mesh to calculate the IMT for. -// dwTextureIndex - This describes which set of texture coordinates in the -// mesh to use. -// uSignalDimension - How many components there are in the signal. -// fMaxUVDistance - The subdivision will continue until the distance between -// all vertices is at most fMaxUVDistance. -// dwOptions - reserved for future use -// pSignalCallback - The callback to use to get the signal. -// pUserData - A pointer that will be passed in to the callback. -// ppIMTData - Where to store the buffer holding the IMT data -HRESULT WINAPI D3DXComputeIMTFromSignal( - LPD3DXMESH pMesh, - DWORD dwTextureIndex, - UINT uSignalDimension, - FLOAT fMaxUVDistance, - DWORD dwOptions, // reserved for future use - LPD3DXIMTSIGNALCALLBACK pSignalCallback, - VOID *pUserData, - LPD3DXUVATLASCB pStatusCallback, - LPVOID pUserContext, - LPD3DXBUFFER *ppIMTData); - -// This function is used to calculate the IMT from texture data. Given a texture -// that maps over the surface of the mesh, the algorithm computes the IMT for -// each face. This will cause large areas that are very similar to take up less -// room when parameterized with UVAtlas. The texture is assumed to be -// interpolated over the mesh bilinearly. -// -// pMesh - The mesh to calculate the IMT for. -// pTexture - The texture to load data from. -// dwTextureIndex - This describes which set of texture coordinates in the -// mesh to use. -// dwOptions - Combination of one or more D3DXIMT flags. -// ppIMTData - Where to store the buffer holding the IMT data -HRESULT WINAPI D3DXComputeIMTFromTexture ( - LPD3DXMESH pMesh, - LPDIRECT3DTEXTURE9 pTexture, - DWORD dwTextureIndex, - DWORD dwOptions, - LPD3DXUVATLASCB pStatusCallback, - LPVOID pUserContext, - LPD3DXBUFFER *ppIMTData); - -// This function is very similar to ComputeIMTFromTexture, but it uses a -// float array to pass in the data, and it can calculate higher dimensional -// values than 4. -// -// pMesh - The mesh to calculate the IMT for. -// dwTextureIndex - This describes which set of texture coordinates in the -// mesh to use. -// pfFloatArray - a pointer to a float array of size -// uWidth*uHeight*uComponents -// uWidth - The width of the texture -// uHeight - The height of the texture -// uSignalDimension - The number of floats per texel in the signal -// uComponents - The number of floats in each texel -// dwOptions - Combination of one or more D3DXIMT flags -// ppIMTData - Where to store the buffer holding the IMT data -HRESULT WINAPI D3DXComputeIMTFromPerTexelSignal( - LPD3DXMESH pMesh, - DWORD dwTextureIndex, - FLOAT *pfTexelSignal, - UINT uWidth, - UINT uHeight, - UINT uSignalDimension, - UINT uComponents, - DWORD dwOptions, - LPD3DXUVATLASCB pStatusCallback, - LPVOID pUserContext, - LPD3DXBUFFER *ppIMTData); - -HRESULT WINAPI - D3DXConvertMeshSubsetToSingleStrip( - LPD3DXBASEMESH MeshIn, - DWORD AttribId, - DWORD IBOptions, - LPDIRECT3DINDEXBUFFER9 *ppIndexBuffer, - DWORD *pNumIndices); - -HRESULT WINAPI - D3DXConvertMeshSubsetToStrips( - LPD3DXBASEMESH MeshIn, - DWORD AttribId, - DWORD IBOptions, - LPDIRECT3DINDEXBUFFER9 *ppIndexBuffer, - DWORD *pNumIndices, - LPD3DXBUFFER *ppStripLengths, - DWORD *pNumStrips); - - -//============================================================================ -// -// D3DXOptimizeFaces: -// -------------------- -// Generate a face remapping for a triangle list that more effectively utilizes -// vertex caches. This optimization is identical to the one provided -// by ID3DXMesh::Optimize with the hardware independent option enabled. -// -// Parameters: -// pbIndices -// Triangle list indices to use for generating a vertex ordering -// NumFaces -// Number of faces in the triangle list -// NumVertices -// Number of vertices referenced by the triangle list -// b32BitIndices -// TRUE if indices are 32 bit, FALSE if indices are 16 bit -// pFaceRemap -// Destination buffer to store face ordering -// The number stored for a given element is where in the new ordering -// the face will have come from. See ID3DXMesh::Optimize for more info. -// -//============================================================================ -HRESULT WINAPI - D3DXOptimizeFaces( - LPCVOID pbIndices, - UINT cFaces, - UINT cVertices, - BOOL b32BitIndices, - DWORD* pFaceRemap); - -//============================================================================ -// -// D3DXOptimizeVertices: -// -------------------- -// Generate a vertex remapping to optimize for in order use of vertices for -// a given set of indices. This is commonly used after applying the face -// remap generated by D3DXOptimizeFaces -// -// Parameters: -// pbIndices -// Triangle list indices to use for generating a vertex ordering -// NumFaces -// Number of faces in the triangle list -// NumVertices -// Number of vertices referenced by the triangle list -// b32BitIndices -// TRUE if indices are 32 bit, FALSE if indices are 16 bit -// pVertexRemap -// Destination buffer to store vertex ordering -// The number stored for a given element is where in the new ordering -// the vertex will have come from. See ID3DXMesh::Optimize for more info. -// -//============================================================================ -HRESULT WINAPI - D3DXOptimizeVertices( - LPCVOID pbIndices, - UINT cFaces, - UINT cVertices, - BOOL b32BitIndices, - DWORD* pVertexRemap); - -#ifdef __cplusplus -} -#endif //__cplusplus - - -//=========================================================================== -// -// Data structures for Spherical Harmonic Precomputation -// -// -//============================================================================ - -typedef enum _D3DXSHCOMPRESSQUALITYTYPE { - D3DXSHCQUAL_FASTLOWQUALITY = 1, - D3DXSHCQUAL_SLOWHIGHQUALITY = 2, - D3DXSHCQUAL_FORCE_DWORD = 0x7fffffff -} D3DXSHCOMPRESSQUALITYTYPE; - -typedef enum _D3DXSHGPUSIMOPT { - D3DXSHGPUSIMOPT_SHADOWRES256 = 1, - D3DXSHGPUSIMOPT_SHADOWRES512 = 0, - D3DXSHGPUSIMOPT_SHADOWRES1024 = 2, - D3DXSHGPUSIMOPT_SHADOWRES2048 = 3, - - D3DXSHGPUSIMOPT_HIGHQUALITY = 4, - - D3DXSHGPUSIMOPT_FORCE_DWORD = 0x7fffffff -} D3DXSHGPUSIMOPT; - -// for all properties that are colors the luminance is computed -// if the simulator is run with a single channel using the following -// formula: R * 0.2125 + G * 0.7154 + B * 0.0721 - -typedef struct _D3DXSHMATERIAL { - D3DCOLORVALUE Diffuse; // Diffuse albedo of the surface. (Ignored if object is a Mirror) - BOOL bMirror; // Must be set to FALSE. bMirror == TRUE not currently supported - BOOL bSubSurf; // true if the object does subsurface scattering - can't do this and be a mirror - - // subsurface scattering parameters - FLOAT RelativeIndexOfRefraction; - D3DCOLORVALUE Absorption; - D3DCOLORVALUE ReducedScattering; - -} D3DXSHMATERIAL; - -// allocated in D3DXSHPRTCompSplitMeshSC -// vertices are duplicated into multiple super clusters but -// only have a valid status in one super cluster (fill in the rest) - -typedef struct _D3DXSHPRTSPLITMESHVERTDATA { - UINT uVertRemap; // vertex in original mesh this corresponds to - UINT uSubCluster; // cluster index relative to super cluster - UCHAR ucVertStatus; // 1 if vertex has valid data, 0 if it is "fill" -} D3DXSHPRTSPLITMESHVERTDATA; - -// used in D3DXSHPRTCompSplitMeshSC -// information for each super cluster that maps into face/vert arrays - -typedef struct _D3DXSHPRTSPLITMESHCLUSTERDATA { - UINT uVertStart; // initial index into remapped vertex array - UINT uVertLength; // number of vertices in this super cluster - - UINT uFaceStart; // initial index into face array - UINT uFaceLength; // number of faces in this super cluster - - UINT uClusterStart; // initial index into cluster array - UINT uClusterLength; // number of clusters in this super cluster -} D3DXSHPRTSPLITMESHCLUSTERDATA; - -// call back function for simulator -// return S_OK to keep running the simulator - anything else represents -// failure and the simulator will abort. - -typedef HRESULT (WINAPI *LPD3DXSHPRTSIMCB)(float fPercentDone, LPVOID lpUserContext); - -// interfaces for PRT buffers/simulator - -// GUIDs -// {F1827E47-00A8-49cd-908C-9D11955F8728} -DEFINE_GUID(IID_ID3DXPRTBuffer, -0xf1827e47, 0xa8, 0x49cd, 0x90, 0x8c, 0x9d, 0x11, 0x95, 0x5f, 0x87, 0x28); - -// {A758D465-FE8D-45ad-9CF0-D01E56266A07} -DEFINE_GUID(IID_ID3DXPRTCompBuffer, -0xa758d465, 0xfe8d, 0x45ad, 0x9c, 0xf0, 0xd0, 0x1e, 0x56, 0x26, 0x6a, 0x7); - -// {838F01EC-9729-4527-AADB-DF70ADE7FEA9} -DEFINE_GUID(IID_ID3DXTextureGutterHelper, -0x838f01ec, 0x9729, 0x4527, 0xaa, 0xdb, 0xdf, 0x70, 0xad, 0xe7, 0xfe, 0xa9); - -// {683A4278-CD5F-4d24-90AD-C4E1B6855D53} -DEFINE_GUID(IID_ID3DXPRTEngine, -0x683a4278, 0xcd5f, 0x4d24, 0x90, 0xad, 0xc4, 0xe1, 0xb6, 0x85, 0x5d, 0x53); - -// interface defenitions - -typedef interface ID3DXTextureGutterHelper ID3DXTextureGutterHelper; -typedef interface ID3DXPRTBuffer ID3DXPRTBuffer; - -#undef INTERFACE -#define INTERFACE ID3DXPRTBuffer - -// Buffer interface - contains "NumSamples" samples -// each sample in memory is stored as NumCoeffs scalars per channel (1 or 3) -// Same interface is used for both Vertex and Pixel PRT buffers - -DECLARE_INTERFACE_(ID3DXPRTBuffer, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXPRTBuffer - STDMETHOD_(UINT, GetNumSamples)(THIS) PURE; - STDMETHOD_(UINT, GetNumCoeffs)(THIS) PURE; - STDMETHOD_(UINT, GetNumChannels)(THIS) PURE; - - STDMETHOD_(BOOL, IsTexture)(THIS) PURE; - STDMETHOD_(UINT, GetWidth)(THIS) PURE; - STDMETHOD_(UINT, GetHeight)(THIS) PURE; - - // changes the number of samples allocated in the buffer - STDMETHOD(Resize)(THIS_ UINT NewSize) PURE; - - // ppData will point to the memory location where sample Start begins - // pointer is valid for at least NumSamples samples - STDMETHOD(LockBuffer)(THIS_ UINT Start, UINT NumSamples, FLOAT **ppData) PURE; - STDMETHOD(UnlockBuffer)(THIS) PURE; - - // every scalar in buffer is multiplied by Scale - STDMETHOD(ScaleBuffer)(THIS_ FLOAT Scale) PURE; - - // every scalar contains the sum of this and pBuffers values - // pBuffer must have the same storage class/dimensions - STDMETHOD(AddBuffer)(THIS_ LPD3DXPRTBUFFER pBuffer) PURE; - - // GutterHelper (described below) will fill in the gutter - // regions of a texture by interpolating "internal" values - STDMETHOD(AttachGH)(THIS_ LPD3DXTEXTUREGUTTERHELPER) PURE; - STDMETHOD(ReleaseGH)(THIS) PURE; - - // Evaluates attached gutter helper on the contents of this buffer - STDMETHOD(EvalGH)(THIS) PURE; - - // extracts a given channel into texture pTexture - // NumCoefficients starting from StartCoefficient are copied - STDMETHOD(ExtractTexture)(THIS_ UINT Channel, UINT StartCoefficient, - UINT NumCoefficients, LPDIRECT3DTEXTURE9 pTexture) PURE; - - // extracts NumCoefficients coefficients into mesh - only applicable on single channel - // buffers, otherwise just lockbuffer and copy data. With SHPRT data NumCoefficients - // should be Order^2 - STDMETHOD(ExtractToMesh)(THIS_ UINT NumCoefficients, D3DDECLUSAGE Usage, UINT UsageIndexStart, - LPD3DXMESH pScene) PURE; - -}; - -typedef interface ID3DXPRTCompBuffer ID3DXPRTCompBuffer; -typedef interface ID3DXPRTCompBuffer *LPD3DXPRTCOMPBUFFER; - -#undef INTERFACE -#define INTERFACE ID3DXPRTCompBuffer - -// compressed buffers stored a compressed version of a PRTBuffer - -DECLARE_INTERFACE_(ID3DXPRTCompBuffer, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DPRTCompBuffer - - // NumCoeffs and NumChannels are properties of input buffer - STDMETHOD_(UINT, GetNumSamples)(THIS) PURE; - STDMETHOD_(UINT, GetNumCoeffs)(THIS) PURE; - STDMETHOD_(UINT, GetNumChannels)(THIS) PURE; - - STDMETHOD_(BOOL, IsTexture)(THIS) PURE; - STDMETHOD_(UINT, GetWidth)(THIS) PURE; - STDMETHOD_(UINT, GetHeight)(THIS) PURE; - - // number of clusters, and PCA vectors per-cluster - STDMETHOD_(UINT, GetNumClusters)(THIS) PURE; - STDMETHOD_(UINT, GetNumPCA)(THIS) PURE; - - // normalizes PCA weights so that they are between [-1,1] - // basis vectors are modified to reflect this - STDMETHOD(NormalizeData)(THIS) PURE; - - // copies basis vectors for cluster "Cluster" into pClusterBasis - // (NumPCA+1)*NumCoeffs*NumChannels floats - STDMETHOD(ExtractBasis)(THIS_ UINT Cluster, FLOAT *pClusterBasis) PURE; - - // UINT per sample - which cluster it belongs to - STDMETHOD(ExtractClusterIDs)(THIS_ UINT *pClusterIDs) PURE; - - // copies NumExtract PCA projection coefficients starting at StartPCA - // into pPCACoefficients - NumSamples*NumExtract floats copied - STDMETHOD(ExtractPCA)(THIS_ UINT StartPCA, UINT NumExtract, FLOAT *pPCACoefficients) PURE; - - // copies NumPCA projection coefficients starting at StartPCA - // into pTexture - should be able to cope with signed formats - STDMETHOD(ExtractTexture)(THIS_ UINT StartPCA, UINT NumpPCA, - LPDIRECT3DTEXTURE9 pTexture) PURE; - - // copies NumPCA projection coefficients into mesh pScene - // Usage is D3DDECLUSAGE where coefficients are to be stored - // UsageIndexStart is starting index - STDMETHOD(ExtractToMesh)(THIS_ UINT NumPCA, D3DDECLUSAGE Usage, UINT UsageIndexStart, - LPD3DXMESH pScene) PURE; -}; - - -#undef INTERFACE -#define INTERFACE ID3DXTextureGutterHelper - -// ID3DXTextureGutterHelper will build and manage -// "gutter" regions in a texture - this will allow for -// bi-linear interpolation to not have artifacts when rendering -// It generates a map (in texture space) where each texel -// is in one of 3 states: -// 0 Invalid - not used at all -// 1 Inside triangle -// 2 Gutter texel -// 4 represents a gutter texel that will be computed during PRT -// For each Inside/Gutter texel it stores the face it -// belongs to and barycentric coordinates for the 1st two -// vertices of that face. Gutter vertices are assigned to -// the closest edge in texture space. -// -// When used with PRT this requires a unique parameterization -// of the model - every texel must correspond to a single point -// on the surface of the model and vice versa - -DECLARE_INTERFACE_(ID3DXTextureGutterHelper, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXTextureGutterHelper - - // dimensions of texture this is bound too - STDMETHOD_(UINT, GetWidth)(THIS) PURE; - STDMETHOD_(UINT, GetHeight)(THIS) PURE; - - - // Applying gutters recomputes all of the gutter texels of class "2" - // based on texels of class "1" or "4" - - // Applies gutters to a raw float buffer - each texel is NumCoeffs floats - // Width and Height must match GutterHelper - STDMETHOD(ApplyGuttersFloat)(THIS_ FLOAT *pDataIn, UINT NumCoeffs, UINT Width, UINT Height); - - // Applies gutters to pTexture - // Dimensions must match GutterHelper - STDMETHOD(ApplyGuttersTex)(THIS_ LPDIRECT3DTEXTURE9 pTexture); - - // Applies gutters to a D3DXPRTBuffer - // Dimensions must match GutterHelper - STDMETHOD(ApplyGuttersPRT)(THIS_ LPD3DXPRTBUFFER pBuffer); - - // Resamples a texture from a mesh onto this gutterhelpers - // parameterization. It is assumed that the UV coordinates - // for this gutter helper are in TEXTURE 0 (usage/usage index) - // and the texture coordinates should all be within [0,1] for - // both sets. - // - // pTextureIn - texture represented using parameterization in pMeshIn - // pMeshIn - Mesh with texture coordinates that represent pTextureIn - // pTextureOut texture coordinates are assumed to be in - // TEXTURE 0 - // Usage - field in DECL for pMeshIn that stores texture coordinates - // for pTextureIn - // UsageIndex - which index for Usage above for pTextureIn - // pTextureOut- Resampled texture - // - // Usage would generally be D3DDECLUSAGE_TEXCOORD and UsageIndex other than zero - STDMETHOD(ResampleTex)(THIS_ LPDIRECT3DTEXTURE9 pTextureIn, - LPD3DXMESH pMeshIn, - D3DDECLUSAGE Usage, UINT UsageIndex, - LPDIRECT3DTEXTURE9 pTextureOut); - - // the routines below provide access to the data structures - // used by the Apply functions - - // face map is a UINT per texel that represents the - // face of the mesh that texel belongs too - - // only valid if same texel is valid in pGutterData - // pFaceData must be allocated by the user - STDMETHOD(GetFaceMap)(THIS_ UINT *pFaceData) PURE; - - // BaryMap is a D3DXVECTOR2 per texel - // the 1st two barycentric coordinates for the corresponding - // face (3rd weight is always 1-sum of first two) - // only valid if same texel is valid in pGutterData - // pBaryData must be allocated by the user - STDMETHOD(GetBaryMap)(THIS_ D3DXVECTOR2 *pBaryData) PURE; - - // TexelMap is a D3DXVECTOR2 per texel that - // stores the location in pixel coordinates where the - // corresponding texel is mapped - // pTexelData must be allocated by the user - STDMETHOD(GetTexelMap)(THIS_ D3DXVECTOR2 *pTexelData) PURE; - - // GutterMap is a BYTE per texel - // 0/1/2 for Invalid/Internal/Gutter texels - // 4 represents a gutter texel that will be computed - // during PRT - // pGutterData must be allocated by the user - STDMETHOD(GetGutterMap)(THIS_ BYTE *pGutterData) PURE; - - // face map is a UINT per texel that represents the - // face of the mesh that texel belongs too - - // only valid if same texel is valid in pGutterData - STDMETHOD(SetFaceMap)(THIS_ UINT *pFaceData) PURE; - - // BaryMap is a D3DXVECTOR2 per texel - // the 1st two barycentric coordinates for the corresponding - // face (3rd weight is always 1-sum of first two) - // only valid if same texel is valid in pGutterData - STDMETHOD(SetBaryMap)(THIS_ D3DXVECTOR2 *pBaryData) PURE; - - // TexelMap is a D3DXVECTOR2 per texel that - // stores the location in pixel coordinates where the - // corresponding texel is mapped - STDMETHOD(SetTexelMap)(THIS_ D3DXVECTOR2 *pTexelData) PURE; - - // GutterMap is a BYTE per texel - // 0/1/2 for Invalid/Internal/Gutter texels - // 4 represents a gutter texel that will be computed - // during PRT - STDMETHOD(SetGutterMap)(THIS_ BYTE *pGutterData) PURE; -}; - - -typedef interface ID3DXPRTEngine ID3DXPRTEngine; -typedef interface ID3DXPRTEngine *LPD3DXPRTENGINE; - -#undef INTERFACE -#define INTERFACE ID3DXPRTEngine - -// ID3DXPRTEngine is used to compute a PRT simulation -// Use the following steps to compute PRT for SH -// (1) create an interface (which includes a scene) -// (2) call SetSamplingInfo -// (3) [optional] Set MeshMaterials/albedo's (required if doing bounces) -// (4) call ComputeDirectLightingSH -// (5) [optional] call ComputeBounce -// repeat step 5 for as many bounces as wanted. -// if you want to model subsurface scattering you -// need to call ComputeSS after direct lighting and -// each bounce. -// If you want to bake the albedo into the PRT signal, you -// must call MutliplyAlbedo, otherwise the user has to multiply -// the albedo themselves. Not multiplying the albedo allows you -// to model albedo variation at a finer scale then illumination, and -// can result in better compression results. -// Luminance values are computed from RGB values using the following -// formula: R * 0.2125 + G * 0.7154 + B * 0.0721 - -DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXPRTEngine - - // This sets a material per attribute in the scene mesh and it is - // the only way to specify subsurface scattering parameters. if - // bSetAlbedo is FALSE, NumChannels must match the current - // configuration of the PRTEngine. If you intend to change - // NumChannels (through some other SetAlbedo function) it must - // happen before SetMeshMaterials is called. - // - // NumChannels 1 implies "grayscale" materials, set this to 3 to enable - // color bleeding effects - // bSetAlbedo sets albedo from material if TRUE - which clobbers per texel/vertex - // albedo that might have been set before. FALSE won't clobber. - // fLengthScale is used for subsurface scattering - scene is mapped into a 1mm unit cube - // and scaled by this amount - STDMETHOD(SetMeshMaterials)(THIS_ CONST D3DXSHMATERIAL **ppMaterials, UINT NumMeshes, - UINT NumChannels, BOOL bSetAlbedo, FLOAT fLengthScale) PURE; - - // setting albedo per-vertex or per-texel over rides the albedos stored per mesh - // but it does not over ride any other settings - - // sets an albedo to be used per vertex - the albedo is represented as a float - // pDataIn input pointer (pointint to albedo of 1st sample) - // NumChannels 1 implies "grayscale" materials, set this to 3 to enable - // color bleeding effects - // Stride - stride in bytes to get to next samples albedo - STDMETHOD(SetPerVertexAlbedo)(THIS_ CONST VOID *pDataIn, UINT NumChannels, UINT Stride) PURE; - - // represents the albedo per-texel instead of per-vertex (even if per-vertex PRT is used) - // pAlbedoTexture - texture that stores the albedo (dimension arbitrary) - // NumChannels 1 implies "grayscale" materials, set this to 3 to enable - // color bleeding effects - // pGH - optional gutter helper, otherwise one is constructed in computation routines and - // destroyed (if not attached to buffers) - STDMETHOD(SetPerTexelAlbedo)(THIS_ LPDIRECT3DTEXTURE9 pAlbedoTexture, - UINT NumChannels, - LPD3DXTEXTUREGUTTERHELPER pGH) PURE; - - // gets the per-vertex albedo - STDMETHOD(GetVertexAlbedo)(THIS_ D3DXCOLOR *pVertColors, UINT NumVerts) PURE; - - // If pixel PRT is being computed normals default to ones that are interpolated - // from the vertex normals. This specifies a texture that stores an object - // space normal map instead (must use a texture format that can represent signed values) - // pNormalTexture - normal map, must be same dimensions as PRTBuffers, signed - STDMETHOD(SetPerTexelNormal)(THIS_ LPDIRECT3DTEXTURE9 pNormalTexture) PURE; - - // Copies per-vertex albedo from mesh - // pMesh - mesh that represents the scene. It must have the same - // properties as the mesh used to create the PRTEngine - // Usage - D3DDECLUSAGE to extract albedos from - // NumChannels 1 implies "grayscale" materials, set this to 3 to enable - // color bleeding effects - STDMETHOD(ExtractPerVertexAlbedo)(THIS_ LPD3DXMESH pMesh, - D3DDECLUSAGE Usage, - UINT NumChannels) PURE; - - // Resamples the input buffer into the output buffer - // can be used to move between per-vertex and per-texel buffers. This can also be used - // to convert single channel buffers to 3-channel buffers and vice-versa. - STDMETHOD(ResampleBuffer)(THIS_ LPD3DXPRTBUFFER pBufferIn, LPD3DXPRTBUFFER pBufferOut) PURE; - - // Returns the scene mesh - including modifications from adaptive spatial sampling - // The returned mesh only has positions, normals and texture coordinates (if defined) - // pD3DDevice - d3d device that will be used to allocate the mesh - // pFaceRemap - each face has a pointer back to the face on the original mesh that it comes from - // if the face hasn't been subdivided this will be an identity mapping - // pVertRemap - each vertex contains 3 vertices that this is a linear combination of - // pVertWeights - weights for each of above indices (sum to 1.0f) - // ppMesh - mesh that will be allocated and filled - STDMETHOD(GetAdaptedMesh)(THIS_ LPDIRECT3DDEVICE9 pD3DDevice,UINT *pFaceRemap, UINT *pVertRemap, FLOAT *pfVertWeights, LPD3DXMESH *ppMesh) PURE; - - // Number of vertices currently allocated (includes new vertices from adaptive sampling) - STDMETHOD_(UINT, GetNumVerts)(THIS) PURE; - // Number of faces currently allocated (includes new faces) - STDMETHOD_(UINT, GetNumFaces)(THIS) PURE; - - // Sets the Minimum/Maximum intersection distances, this can be used to control - // maximum distance that objects can shadow/reflect light, and help with "bad" - // art that might have near features that you don't want to shadow. This does not - // apply for GPU simulations. - // fMin - minimum intersection distance, must be positive and less than fMax - // fMax - maximum intersection distance, if 0.0f use the previous value, otherwise - // must be strictly greater than fMin - STDMETHOD(SetMinMaxIntersection)(THIS_ FLOAT fMin, FLOAT fMax) PURE; - - // This will subdivide faces on a mesh so that adaptively simulations can - // use a more conservative threshold (it won't miss features.) - // MinEdgeLength - minimum edge length that will be generated, if 0.0f a - // reasonable default will be used - // MaxSubdiv - maximum level of subdivision, if 0 is specified a default - // value will be used (5) - STDMETHOD(RobustMeshRefine)(THIS_ FLOAT MinEdgeLength, UINT MaxSubdiv) PURE; - - // This sets to sampling information used by the simulator. Adaptive sampling - // parameters are currently ignored. - // NumRays - number of rays to shoot per sample - // UseSphere - if TRUE uses spherical samples, otherwise samples over - // the hemisphere. Should only be used with GPU and Vol computations - // UseCosine - if TRUE uses a cosine weighting - not used for Vol computations - // or if only the visiblity function is desired - // Adaptive - if TRUE adaptive sampling (angular) is used - // AdaptiveThresh - threshold used to terminate adaptive angular sampling - // ignored if adaptive sampling is not set - STDMETHOD(SetSamplingInfo)(THIS_ UINT NumRays, - BOOL UseSphere, - BOOL UseCosine, - BOOL Adaptive, - FLOAT AdaptiveThresh) PURE; - - // Methods that compute the direct lighting contribution for objects - // always represente light using spherical harmonics (SH) - // the albedo is not multiplied by the signal - it just integrates - // incoming light. If NumChannels is not 1 the vector is replicated - // - // SHOrder - order of SH to use - // pDataOut - PRT buffer that is generated. Can be single channel - STDMETHOD(ComputeDirectLightingSH)(THIS_ UINT SHOrder, - LPD3DXPRTBUFFER pDataOut) PURE; - - // Adaptive variant of above function. This will refine the mesh - // generating new vertices/faces to approximate the PRT signal - // more faithfully. - // SHOrder - order of SH to use - // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error) - // if value is less then 1e-6f, 1e-6f is specified - // MinEdgeLength - minimum edge length that will be generated - // if value is too small a fairly conservative model dependent value - // is used - // MaxSubdiv - maximum subdivision level, if 0 is specified it - // will default to 4 - // pDataOut - PRT buffer that is generated. Can be single channel. - STDMETHOD(ComputeDirectLightingSHAdaptive)(THIS_ UINT SHOrder, - FLOAT AdaptiveThresh, - FLOAT MinEdgeLength, - UINT MaxSubdiv, - LPD3DXPRTBUFFER pDataOut) PURE; - - // Function that computes the direct lighting contribution for objects - // light is always represented using spherical harmonics (SH) - // This is done on the GPU and is much faster then using the CPU. - // The albedo is not multiplied by the signal - it just integrates - // incoming light. If NumChannels is not 1 the vector is replicated. - // ZBias/ZAngleBias are akin to parameters used with shadow zbuffers. - // A reasonable default for both values is 0.005, but the user should - // experiment (ZAngleBias can be zero, ZBias should not be.) - // Callbacks should not use the Direct3D9Device the simulator is using. - // SetSamplingInfo must be called with TRUE for UseSphere and - // FALSE for UseCosine before this method is called. - // - // pD3DDevice - device used to run GPU simulator - must support PS2.0 - // and FP render targets - // Flags - parameters for the GPU simulator, combination of one or more - // D3DXSHGPUSIMOPT flags. Only one SHADOWRES setting should be set and - // the defaults is 512 - // SHOrder - order of SH to use - // ZBias - bias in normal direction (for depth test) - // ZAngleBias - scaled by one minus cosine of angle with light (offset in depth) - // pDataOut - PRT buffer that is filled in. Can be single channel - STDMETHOD(ComputeDirectLightingSHGPU)(THIS_ LPDIRECT3DDEVICE9 pD3DDevice, - UINT Flags, - UINT SHOrder, - FLOAT ZBias, - FLOAT ZAngleBias, - LPD3DXPRTBUFFER pDataOut) PURE; - - - // Functions that computes subsurface scattering (using material properties) - // Albedo is not multiplied by result. This only works for per-vertex data - // use ResampleBuffer to move per-vertex data into a texture and back. - // - // pDataIn - input data (previous bounce) - // pDataOut - result of subsurface scattering simulation - // pDataTotal - [optional] results can be summed into this buffer - STDMETHOD(ComputeSS)(THIS_ LPD3DXPRTBUFFER pDataIn, - LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal) PURE; - - // Adaptive version of ComputeSS. - // - // pDataIn - input data (previous bounce) - // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error) - // if value is less then 1e-6f, 1e-6f is specified - // MinEdgeLength - minimum edge length that will be generated - // if value is too small a fairly conservative model dependent value - // is used - // MaxSubdiv - maximum subdivision level, if 0 is specified it - // will default to 4 - // pDataOut - result of subsurface scattering simulation - // pDataTotal - [optional] results can be summed into this buffer - STDMETHOD(ComputeSSAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn, - FLOAT AdaptiveThresh, - FLOAT MinEdgeLength, - UINT MaxSubdiv, - LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal) PURE; - - // computes a single bounce of inter-reflected light - // works for SH based PRT or generic lighting - // Albedo is not multiplied by result - // - // pDataIn - previous bounces data - // pDataOut - PRT buffer that is generated - // pDataTotal - [optional] can be used to keep a running sum - STDMETHOD(ComputeBounce)(THIS_ LPD3DXPRTBUFFER pDataIn, - LPD3DXPRTBUFFER pDataOut, - LPD3DXPRTBUFFER pDataTotal) PURE; - - // Adaptive version of above function. - // - // pDataIn - previous bounces data, can be single channel - // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error) - // if value is less then 1e-6f, 1e-6f is specified - // MinEdgeLength - minimum edge length that will be generated - // if value is too small a fairly conservative model dependent value - // is used - // MaxSubdiv - maximum subdivision level, if 0 is specified it - // will default to 4 - // pDataOut - PRT buffer that is generated - // pDataTotal - [optional] can be used to keep a running sum - STDMETHOD(ComputeBounceAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn, - FLOAT AdaptiveThresh, - FLOAT MinEdgeLength, - UINT MaxSubdiv, - LPD3DXPRTBUFFER pDataOut, - LPD3DXPRTBUFFER pDataTotal) PURE; - - // Computes projection of distant SH radiance into a local SH radiance - // function. This models how direct lighting is attenuated by the - // scene and is a form of "neighborhood transfer." The result is - // a linear operator (matrix) at every sample point, if you multiply - // this matrix by the distant SH lighting coefficients you get an - // approximation of the local incident radiance function from - // direct lighting. These resulting lighting coefficients can - // than be projected into another basis or used with any rendering - // technique that uses spherical harmonics as input. - // SetSamplingInfo must be called with TRUE for UseSphere and - // FALSE for UseCosine before this method is called. - // Generates SHOrderIn*SHOrderIn*SHOrderOut*SHOrderOut scalars - // per channel at each sample location. - // - // SHOrderIn - Order of the SH representation of distant lighting - // SHOrderOut - Order of the SH representation of local lighting - // NumVolSamples - Number of sample locations - // pSampleLocs - position of sample locations - // pDataOut - PRT Buffer that will store output results - STDMETHOD(ComputeVolumeSamplesDirectSH)(THIS_ UINT SHOrderIn, - UINT SHOrderOut, - UINT NumVolSamples, - CONST D3DXVECTOR3 *pSampleLocs, - LPD3DXPRTBUFFER pDataOut) PURE; - - // At each sample location computes a linear operator (matrix) that maps - // the representation of source radiance (NumCoeffs in pSurfDataIn) - // into a local incident radiance function approximated with spherical - // harmonics. For example if a light map data is specified in pSurfDataIn - // the result is an SH representation of the flow of light at each sample - // point. If PRT data for an outdoor scene is used, each sample point - // contains a matrix that models how distant lighting bounces of the objects - // in the scene and arrives at the given sample point. Combined with - // ComputeVolumeSamplesDirectSH this gives the complete representation for - // how light arrives at each sample point parameterized by distant lighting. - // SetSamplingInfo must be called with TRUE for UseSphere and - // FALSE for UseCosine before this method is called. - // Generates pSurfDataIn->NumCoeffs()*SHOrder*SHOrder scalars - // per channel at each sample location. - // - // pSurfDataIn - previous bounce data - // SHOrder - order of SH to generate projection with - // NumVolSamples - Number of sample locations - // pSampleLocs - position of sample locations - // pDataOut - PRT Buffer that will store output results - STDMETHOD(ComputeVolumeSamples)(THIS_ LPD3DXPRTBUFFER pSurfDataIn, - UINT SHOrder, - UINT NumVolSamples, - CONST D3DXVECTOR3 *pSampleLocs, - LPD3DXPRTBUFFER pDataOut) PURE; - - // Computes direct lighting (SH) for a point not on the mesh - // with a given normal - cannot use texture buffers. - // - // SHOrder - order of SH to use - // NumSamples - number of sample locations - // pSampleLocs - position for each sample - // pSampleNorms - normal for each sample - // pDataOut - PRT Buffer that will store output results - STDMETHOD(ComputeSurfSamplesDirectSH)(THIS_ UINT SHOrder, - UINT NumSamples, - CONST D3DXVECTOR3 *pSampleLocs, - CONST D3DXVECTOR3 *pSampleNorms, - LPD3DXPRTBUFFER pDataOut) PURE; - - - // given the solution for PRT or light maps, computes transfer vector at arbitrary - // position/normal pairs in space - // - // pSurfDataIn - input data - // NumSamples - number of sample locations - // pSampleLocs - position for each sample - // pSampleNorms - normal for each sample - // pDataOut - PRT Buffer that will store output results - // pDataTotal - optional buffer to sum results into - can be NULL - STDMETHOD(ComputeSurfSamplesBounce)(THIS_ LPD3DXPRTBUFFER pSurfDataIn, - UINT NumSamples, - CONST D3DXVECTOR3 *pSampleLocs, - CONST D3DXVECTOR3 *pSampleNorms, - LPD3DXPRTBUFFER pDataOut, - LPD3DXPRTBUFFER pDataTotal) PURE; - - // Frees temporary data structures that can be created for subsurface scattering - // this data is freed when the PRTComputeEngine is freed and is lazily created - STDMETHOD(FreeSSData)(THIS) PURE; - - // Frees temporary data structures that can be created for bounce simulations - // this data is freed when the PRTComputeEngine is freed and is lazily created - STDMETHOD(FreeBounceData)(THIS) PURE; - - // This computes the Local Deformable PRT (LDPRT) coefficients relative to the - // per sample normals that minimize error in a least squares sense with respect - // to the input PRT data set. These coefficients can be used with skinned/transformed - // normals to model global effects with dynamic objects. Shading normals can - // optionally be solved for - these normals (along with the LDPRT coefficients) can - // more accurately represent the PRT signal. The coefficients are for zonal - // harmonics oriented in the normal/shading normal direction. - // - // pDataIn - SH PRT dataset that is input - // SHOrder - Order of SH to compute conv coefficients for - // pNormOut - Optional array of vectors (passed in) that will be filled with - // "shading normals", LDPRT coefficients are optimized for - // these normals. This array must be the same size as the number of - // samples in pDataIn - // pDataOut - Output buffer (SHOrder zonal harmonic coefficients per channel per sample) - STDMETHOD(ComputeLDPRTCoeffs)(THIS_ LPD3DXPRTBUFFER pDataIn, - UINT SHOrder, - D3DXVECTOR3 *pNormOut, - LPD3DXPRTBUFFER pDataOut) PURE; - - // scales all the samples associated with a given sub mesh - // can be useful when using subsurface scattering - // fScale - value to scale each vector in submesh by - STDMETHOD(ScaleMeshChunk)(THIS_ UINT uMeshChunk, FLOAT fScale, LPD3DXPRTBUFFER pDataOut) PURE; - - // mutliplies each PRT vector by the albedo - can be used if you want to have the albedo - // burned into the dataset, often better not to do this. If this is not done the user - // must mutliply the albedo themselves when rendering - just multiply the albedo times - // the result of the PRT dot product. - // If pDataOut is a texture simulation result and there is an albedo texture it - // must be represented at the same resolution as the simulation buffer. You can use - // LoadSurfaceFromSurface and set a new albedo texture if this is an issue - but must - // be careful about how the gutters are handled. - // - // pDataOut - dataset that will get albedo pushed into it - STDMETHOD(MultiplyAlbedo)(THIS_ LPD3DXPRTBUFFER pDataOut) PURE; - - // Sets a pointer to an optional call back function that reports back to the - // user percentage done and gives them the option of quitting - // pCB - pointer to call back function, return S_OK for the simulation - // to continue - // Frequency - 1/Frequency is roughly the number of times the call back - // will be invoked - // lpUserContext - will be passed back to the users call back - STDMETHOD(SetCallBack)(THIS_ LPD3DXSHPRTSIMCB pCB, FLOAT Frequency, LPVOID lpUserContext) PURE; - - // Returns TRUE if the ray intersects the mesh, FALSE if it does not. This function - // takes into account settings from SetMinMaxIntersection. If the closest intersection - // is not needed this function is more efficient compared to the ClosestRayIntersection - // method. - // pRayPos - origin of ray - // pRayDir - normalized ray direction (normalization required for SetMinMax to be meaningful) - - STDMETHOD_(BOOL, ShadowRayIntersects)(THIS_ CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir) PURE; - - // Returns TRUE if the ray intersects the mesh, FALSE if it does not. If there is an - // intersection the closest face that was intersected and its first two barycentric coordinates - // are returned. This function takes into account settings from SetMinMaxIntersection. - // This is a slower function compared to ShadowRayIntersects and should only be used where - // needed. The third vertices barycentric coordinates will be 1 - pU - pV. - // pRayPos - origin of ray - // pRayDir - normalized ray direction (normalization required for SetMinMax to be meaningful) - // pFaceIndex - Closest face that intersects. This index is based on stacking the pBlockerMesh - // faces before the faces from pMesh - // pU - Barycentric coordinate for vertex 0 - // pV - Barycentric coordinate for vertex 1 - // pDist - Distance along ray where the intersection occured - - STDMETHOD_(BOOL, ClosestRayIntersects)(THIS_ CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir, - DWORD *pFaceIndex, FLOAT *pU, FLOAT *pV, FLOAT *pDist) PURE; -}; - - -// API functions for creating interfaces - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -//============================================================================ -// -// D3DXCreatePRTBuffer: -// -------------------- -// Generates a PRT Buffer that can be compressed or filled by a simulator -// This function should be used to create per-vertex or volume buffers. -// When buffers are created all values are initialized to zero. -// -// Parameters: -// NumSamples -// Number of sample locations represented -// NumCoeffs -// Number of coefficients per sample location (order^2 for SH) -// NumChannels -// Number of color channels to represent (1 or 3) -// ppBuffer -// Buffer that will be allocated -// -//============================================================================ - -HRESULT WINAPI - D3DXCreatePRTBuffer( - UINT NumSamples, - UINT NumCoeffs, - UINT NumChannels, - LPD3DXPRTBUFFER* ppBuffer); - -//============================================================================ -// -// D3DXCreatePRTBufferTex: -// -------------------- -// Generates a PRT Buffer that can be compressed or filled by a simulator -// This function should be used to create per-pixel buffers. -// When buffers are created all values are initialized to zero. -// -// Parameters: -// Width -// Width of texture -// Height -// Height of texture -// NumCoeffs -// Number of coefficients per sample location (order^2 for SH) -// NumChannels -// Number of color channels to represent (1 or 3) -// ppBuffer -// Buffer that will be allocated -// -//============================================================================ - -HRESULT WINAPI - D3DXCreatePRTBufferTex( - UINT Width, - UINT Height, - UINT NumCoeffs, - UINT NumChannels, - LPD3DXPRTBUFFER* ppBuffer); - -//============================================================================ -// -// D3DXLoadPRTBufferFromFile: -// -------------------- -// Loads a PRT buffer that has been saved to disk. -// -// Parameters: -// pFilename -// Name of the file to load -// ppBuffer -// Buffer that will be allocated -// -//============================================================================ - -HRESULT WINAPI - D3DXLoadPRTBufferFromFileA( - LPCSTR pFilename, - LPD3DXPRTBUFFER* ppBuffer); - -HRESULT WINAPI - D3DXLoadPRTBufferFromFileW( - LPCWSTR pFilename, - LPD3DXPRTBUFFER* ppBuffer); - -#ifdef UNICODE -#define D3DXLoadPRTBufferFromFile D3DXLoadPRTBufferFromFileW -#else -#define D3DXLoadPRTBufferFromFile D3DXLoadPRTBufferFromFileA -#endif - - -//============================================================================ -// -// D3DXSavePRTBufferToFile: -// -------------------- -// Saves a PRTBuffer to disk. -// -// Parameters: -// pFilename -// Name of the file to save -// pBuffer -// Buffer that will be saved -// -//============================================================================ - -HRESULT WINAPI - D3DXSavePRTBufferToFileA( - LPCSTR pFileName, - LPD3DXPRTBUFFER pBuffer); - -HRESULT WINAPI - D3DXSavePRTBufferToFileW( - LPCWSTR pFileName, - LPD3DXPRTBUFFER pBuffer); - -#ifdef UNICODE -#define D3DXSavePRTBufferToFile D3DXSavePRTBufferToFileW -#else -#define D3DXSavePRTBufferToFile D3DXSavePRTBufferToFileA -#endif - - -//============================================================================ -// -// D3DXLoadPRTCompBufferFromFile: -// -------------------- -// Loads a PRTComp buffer that has been saved to disk. -// -// Parameters: -// pFilename -// Name of the file to load -// ppBuffer -// Buffer that will be allocated -// -//============================================================================ - -HRESULT WINAPI - D3DXLoadPRTCompBufferFromFileA( - LPCSTR pFilename, - LPD3DXPRTCOMPBUFFER* ppBuffer); - -HRESULT WINAPI - D3DXLoadPRTCompBufferFromFileW( - LPCWSTR pFilename, - LPD3DXPRTCOMPBUFFER* ppBuffer); - -#ifdef UNICODE -#define D3DXLoadPRTCompBufferFromFile D3DXLoadPRTCompBufferFromFileW -#else -#define D3DXLoadPRTCompBufferFromFile D3DXLoadPRTCompBufferFromFileA -#endif - -//============================================================================ -// -// D3DXSavePRTCompBufferToFile: -// -------------------- -// Saves a PRTCompBuffer to disk. -// -// Parameters: -// pFilename -// Name of the file to save -// pBuffer -// Buffer that will be saved -// -//============================================================================ - -HRESULT WINAPI - D3DXSavePRTCompBufferToFileA( - LPCSTR pFileName, - LPD3DXPRTCOMPBUFFER pBuffer); - -HRESULT WINAPI - D3DXSavePRTCompBufferToFileW( - LPCWSTR pFileName, - LPD3DXPRTCOMPBUFFER pBuffer); - -#ifdef UNICODE -#define D3DXSavePRTCompBufferToFile D3DXSavePRTCompBufferToFileW -#else -#define D3DXSavePRTCompBufferToFile D3DXSavePRTCompBufferToFileA -#endif - -//============================================================================ -// -// D3DXCreatePRTCompBuffer: -// -------------------- -// Compresses a PRT buffer (vertex or texel) -// -// Parameters: -// D3DXSHCOMPRESSQUALITYTYPE -// Quality of compression - low is faster (computes PCA per voronoi cluster) -// high is slower but better quality (clusters based on distance to affine subspace) -// NumClusters -// Number of clusters to compute -// NumPCA -// Number of basis vectors to compute -// pCB -// Optional Callback function -// lpUserContext -// Optional user context -// pBufferIn -// Buffer that will be compressed -// ppBufferOut -// Compressed buffer that will be created -// -//============================================================================ - - -HRESULT WINAPI - D3DXCreatePRTCompBuffer( - D3DXSHCOMPRESSQUALITYTYPE Quality, - UINT NumClusters, - UINT NumPCA, - LPD3DXSHPRTSIMCB pCB, - LPVOID lpUserContext, - LPD3DXPRTBUFFER pBufferIn, - LPD3DXPRTCOMPBUFFER *ppBufferOut - ); - -//============================================================================ -// -// D3DXCreateTextureGutterHelper: -// -------------------- -// Generates a "GutterHelper" for a given set of meshes and texture -// resolution -// -// Parameters: -// Width -// Width of texture -// Height -// Height of texture -// pMesh -// Mesh that represents the scene -// GutterSize -// Number of texels to over rasterize in texture space -// this should be at least 1.0 -// ppBuffer -// GutterHelper that will be created -// -//============================================================================ - - -HRESULT WINAPI - D3DXCreateTextureGutterHelper( - UINT Width, - UINT Height, - LPD3DXMESH pMesh, - FLOAT GutterSize, - LPD3DXTEXTUREGUTTERHELPER* ppBuffer); - - -//============================================================================ -// -// D3DXCreatePRTEngine: -// -------------------- -// Computes a PRTEngine which can efficiently generate PRT simulations -// of a scene -// -// Parameters: -// pMesh -// Mesh that represents the scene - must have an AttributeTable -// where vertices are in a unique attribute. -// pAdjacency -// Optional adjacency information -// ExtractUVs -// Set this to true if textures are going to be used for albedos -// or to store PRT vectors -// pBlockerMesh -// Optional mesh that just blocks the scene -// ppEngine -// PRTEngine that will be created -// -//============================================================================ - - -HRESULT WINAPI - D3DXCreatePRTEngine( - LPD3DXMESH pMesh, - DWORD *pAdjacency, - BOOL ExtractUVs, - LPD3DXMESH pBlockerMesh, - LPD3DXPRTENGINE* ppEngine); - -//============================================================================ -// -// D3DXConcatenateMeshes: -// -------------------- -// Concatenates a group of meshes into one common mesh. This can optionaly transform -// each sub mesh or its texture coordinates. If no DECL is given it will -// generate a union of all of the DECL's of the sub meshes, promoting channels -// and types if neccesary. It will create an AttributeTable if possible, one can -// call OptimizeMesh with attribute sort and compacting enabled to ensure this. -// -// Parameters: -// ppMeshes -// Array of pointers to meshes that can store PRT vectors -// NumMeshes -// Number of meshes -// Options -// Passed through to D3DXCreateMesh -// pGeomXForms -// [optional] Each sub mesh is transformed by the corresponding -// matrix if this array is supplied -// pTextureXForms -// [optional] UV coordinates for each sub mesh are transformed -// by corresponding matrix if supplied -// pDecl -// [optional] Only information in this DECL is used when merging -// data -// pD3DDevice -// D3D device that is used to create the new mesh -// ppMeshOut -// Mesh that will be created -// -//============================================================================ - - -HRESULT WINAPI - D3DXConcatenateMeshes( - LPD3DXMESH *ppMeshes, - UINT NumMeshes, - DWORD Options, - CONST D3DXMATRIX *pGeomXForms, - CONST D3DXMATRIX *pTextureXForms, - CONST D3DVERTEXELEMENT9 *pDecl, - LPDIRECT3DDEVICE9 pD3DDevice, - LPD3DXMESH *ppMeshOut); - -//============================================================================ -// -// D3DXSHPRTCompSuperCluster: -// -------------------------- -// Used with compressed results of D3DXSHPRTSimulation. -// Generates "super clusters" - groups of clusters that can be drawn in -// the same draw call. A greedy algorithm that minimizes overdraw is used -// to group the clusters. -// -// Parameters: -// pClusterIDs -// NumVerts cluster ID's (extracted from a compressed buffer) -// pScene -// Mesh that represents composite scene passed to the simulator -// MaxNumClusters -// Maximum number of clusters allocated per super cluster -// NumClusters -// Number of clusters computed in the simulator -// pSuperClusterIDs -// Array of length NumClusters, contains index of super cluster -// that corresponding cluster was assigned to -// pNumSuperClusters -// Returns the number of super clusters allocated -// -//============================================================================ - -HRESULT WINAPI - D3DXSHPRTCompSuperCluster( - UINT *pClusterIDs, - LPD3DXMESH pScene, - UINT MaxNumClusters, - UINT NumClusters, - UINT *pSuperClusterIDs, - UINT *pNumSuperClusters); - -//============================================================================ -// -// D3DXSHPRTCompSplitMeshSC: -// ------------------------- -// Used with compressed results of the vertex version of the PRT simulator. -// After D3DXSHRTCompSuperCluster has been called this function can be used -// to split the mesh into a group of faces/vertices per super cluster. -// Each super cluster contains all of the faces that contain any vertex -// classified in one of its clusters. All of the vertices connected to this -// set of faces are also included with the returned array ppVertStatus -// indicating whether or not the vertex belongs to the supercluster. -// -// Parameters: -// pClusterIDs -// NumVerts cluster ID's (extracted from a compressed buffer) -// NumVertices -// Number of vertices in original mesh -// NumClusters -// Number of clusters (input parameter to compression) -// pSuperClusterIDs -// Array of size NumClusters that will contain super cluster ID's (from -// D3DXSHCompSuerCluster) -// NumSuperClusters -// Number of superclusters allocated in D3DXSHCompSuerCluster -// pInputIB -// Raw index buffer for mesh - format depends on bInputIBIs32Bit -// InputIBIs32Bit -// Indicates whether the input index buffer is 32-bit (otherwise 16-bit -// is assumed) -// NumFaces -// Number of faces in the original mesh (pInputIB is 3 times this length) -// ppIBData -// LPD3DXBUFFER holds raw index buffer that will contain the resulting split faces. -// Format determined by bIBIs32Bit. Allocated by function -// pIBDataLength -// Length of ppIBData, assigned in function -// OutputIBIs32Bit -// Indicates whether the output index buffer is to be 32-bit (otherwise -// 16-bit is assumed) -// ppFaceRemap -// LPD3DXBUFFER mapping of each face in ppIBData to original faces. Length is -// *pIBDataLength/3. Optional paramter, allocated in function -// ppVertData -// LPD3DXBUFFER contains new vertex data structure. Size of pVertDataLength -// pVertDataLength -// Number of new vertices in split mesh. Assigned in function -// pSCClusterList -// Array of length NumClusters which pSCData indexes into (Cluster* fields) -// for each SC, contains clusters sorted by super cluster -// pSCData -// Structure per super cluster - contains indices into ppIBData, -// pSCClusterList and ppVertData -// -//============================================================================ - -HRESULT WINAPI - D3DXSHPRTCompSplitMeshSC( - UINT *pClusterIDs, - UINT NumVertices, - UINT NumClusters, - UINT *pSuperClusterIDs, - UINT NumSuperClusters, - LPVOID pInputIB, - BOOL InputIBIs32Bit, - UINT NumFaces, - LPD3DXBUFFER *ppIBData, - UINT *pIBDataLength, - BOOL OutputIBIs32Bit, - LPD3DXBUFFER *ppFaceRemap, - LPD3DXBUFFER *ppVertData, - UINT *pVertDataLength, - UINT *pSCClusterList, - D3DXSHPRTSPLITMESHCLUSTERDATA *pSCData); - - -#ifdef __cplusplus -} -#endif //__cplusplus - -////////////////////////////////////////////////////////////////////////////// -// -// Definitions of .X file templates used by mesh load/save functions -// that are not RM standard -// -////////////////////////////////////////////////////////////////////////////// - -// {3CF169CE-FF7C-44ab-93C0-F78F62D172E2} -DEFINE_GUID(DXFILEOBJ_XSkinMeshHeader, -0x3cf169ce, 0xff7c, 0x44ab, 0x93, 0xc0, 0xf7, 0x8f, 0x62, 0xd1, 0x72, 0xe2); - -// {B8D65549-D7C9-4995-89CF-53A9A8B031E3} -DEFINE_GUID(DXFILEOBJ_VertexDuplicationIndices, -0xb8d65549, 0xd7c9, 0x4995, 0x89, 0xcf, 0x53, 0xa9, 0xa8, 0xb0, 0x31, 0xe3); - -// {A64C844A-E282-4756-8B80-250CDE04398C} -DEFINE_GUID(DXFILEOBJ_FaceAdjacency, -0xa64c844a, 0xe282, 0x4756, 0x8b, 0x80, 0x25, 0xc, 0xde, 0x4, 0x39, 0x8c); - -// {6F0D123B-BAD2-4167-A0D0-80224F25FABB} -DEFINE_GUID(DXFILEOBJ_SkinWeights, -0x6f0d123b, 0xbad2, 0x4167, 0xa0, 0xd0, 0x80, 0x22, 0x4f, 0x25, 0xfa, 0xbb); - -// {A3EB5D44-FC22-429d-9AFB-3221CB9719A6} -DEFINE_GUID(DXFILEOBJ_Patch, -0xa3eb5d44, 0xfc22, 0x429d, 0x9a, 0xfb, 0x32, 0x21, 0xcb, 0x97, 0x19, 0xa6); - -// {D02C95CC-EDBA-4305-9B5D-1820D7704BBF} -DEFINE_GUID(DXFILEOBJ_PatchMesh, -0xd02c95cc, 0xedba, 0x4305, 0x9b, 0x5d, 0x18, 0x20, 0xd7, 0x70, 0x4b, 0xbf); - -// {B9EC94E1-B9A6-4251-BA18-94893F02C0EA} -DEFINE_GUID(DXFILEOBJ_PatchMesh9, -0xb9ec94e1, 0xb9a6, 0x4251, 0xba, 0x18, 0x94, 0x89, 0x3f, 0x2, 0xc0, 0xea); - -// {B6C3E656-EC8B-4b92-9B62-681659522947} -DEFINE_GUID(DXFILEOBJ_PMInfo, -0xb6c3e656, 0xec8b, 0x4b92, 0x9b, 0x62, 0x68, 0x16, 0x59, 0x52, 0x29, 0x47); - -// {917E0427-C61E-4a14-9C64-AFE65F9E9844} -DEFINE_GUID(DXFILEOBJ_PMAttributeRange, -0x917e0427, 0xc61e, 0x4a14, 0x9c, 0x64, 0xaf, 0xe6, 0x5f, 0x9e, 0x98, 0x44); - -// {574CCC14-F0B3-4333-822D-93E8A8A08E4C} -DEFINE_GUID(DXFILEOBJ_PMVSplitRecord, -0x574ccc14, 0xf0b3, 0x4333, 0x82, 0x2d, 0x93, 0xe8, 0xa8, 0xa0, 0x8e, 0x4c); - -// {B6E70A0E-8EF9-4e83-94AD-ECC8B0C04897} -DEFINE_GUID(DXFILEOBJ_FVFData, -0xb6e70a0e, 0x8ef9, 0x4e83, 0x94, 0xad, 0xec, 0xc8, 0xb0, 0xc0, 0x48, 0x97); - -// {F752461C-1E23-48f6-B9F8-8350850F336F} -DEFINE_GUID(DXFILEOBJ_VertexElement, -0xf752461c, 0x1e23, 0x48f6, 0xb9, 0xf8, 0x83, 0x50, 0x85, 0xf, 0x33, 0x6f); - -// {BF22E553-292C-4781-9FEA-62BD554BDD93} -DEFINE_GUID(DXFILEOBJ_DeclData, -0xbf22e553, 0x292c, 0x4781, 0x9f, 0xea, 0x62, 0xbd, 0x55, 0x4b, 0xdd, 0x93); - -// {F1CFE2B3-0DE3-4e28-AFA1-155A750A282D} -DEFINE_GUID(DXFILEOBJ_EffectFloats, -0xf1cfe2b3, 0xde3, 0x4e28, 0xaf, 0xa1, 0x15, 0x5a, 0x75, 0xa, 0x28, 0x2d); - -// {D55B097E-BDB6-4c52-B03D-6051C89D0E42} -DEFINE_GUID(DXFILEOBJ_EffectString, -0xd55b097e, 0xbdb6, 0x4c52, 0xb0, 0x3d, 0x60, 0x51, 0xc8, 0x9d, 0xe, 0x42); - -// {622C0ED0-956E-4da9-908A-2AF94F3CE716} -DEFINE_GUID(DXFILEOBJ_EffectDWord, -0x622c0ed0, 0x956e, 0x4da9, 0x90, 0x8a, 0x2a, 0xf9, 0x4f, 0x3c, 0xe7, 0x16); - -// {3014B9A0-62F5-478c-9B86-E4AC9F4E418B} -DEFINE_GUID(DXFILEOBJ_EffectParamFloats, -0x3014b9a0, 0x62f5, 0x478c, 0x9b, 0x86, 0xe4, 0xac, 0x9f, 0x4e, 0x41, 0x8b); - -// {1DBC4C88-94C1-46ee-9076-2C28818C9481} -DEFINE_GUID(DXFILEOBJ_EffectParamString, -0x1dbc4c88, 0x94c1, 0x46ee, 0x90, 0x76, 0x2c, 0x28, 0x81, 0x8c, 0x94, 0x81); - -// {E13963BC-AE51-4c5d-B00F-CFA3A9D97CE5} -DEFINE_GUID(DXFILEOBJ_EffectParamDWord, -0xe13963bc, 0xae51, 0x4c5d, 0xb0, 0xf, 0xcf, 0xa3, 0xa9, 0xd9, 0x7c, 0xe5); - -// {E331F7E4-0559-4cc2-8E99-1CEC1657928F} -DEFINE_GUID(DXFILEOBJ_EffectInstance, -0xe331f7e4, 0x559, 0x4cc2, 0x8e, 0x99, 0x1c, 0xec, 0x16, 0x57, 0x92, 0x8f); - -// {9E415A43-7BA6-4a73-8743-B73D47E88476} -DEFINE_GUID(DXFILEOBJ_AnimTicksPerSecond, -0x9e415a43, 0x7ba6, 0x4a73, 0x87, 0x43, 0xb7, 0x3d, 0x47, 0xe8, 0x84, 0x76); - -// {7F9B00B3-F125-4890-876E-1CFFBF697C4D} -DEFINE_GUID(DXFILEOBJ_CompressedAnimationSet, -0x7f9b00b3, 0xf125, 0x4890, 0x87, 0x6e, 0x1c, 0x42, 0xbf, 0x69, 0x7c, 0x4d); - -#pragma pack(push, 1) -typedef struct _XFILECOMPRESSEDANIMATIONSET -{ - DWORD CompressedBlockSize; - FLOAT TicksPerSec; - DWORD PlaybackType; - DWORD BufferLength; -} XFILECOMPRESSEDANIMATIONSET; -#pragma pack(pop) - -#define XSKINEXP_TEMPLATES \ - "xof 0303txt 0032\ - template XSkinMeshHeader \ - { \ - <3CF169CE-FF7C-44ab-93C0-F78F62D172E2> \ - WORD nMaxSkinWeightsPerVertex; \ - WORD nMaxSkinWeightsPerFace; \ - WORD nBones; \ - } \ - template VertexDuplicationIndices \ - { \ - \ - DWORD nIndices; \ - DWORD nOriginalVertices; \ - array DWORD indices[nIndices]; \ - } \ - template FaceAdjacency \ - { \ - \ - DWORD nIndices; \ - array DWORD indices[nIndices]; \ - } \ - template SkinWeights \ - { \ - <6F0D123B-BAD2-4167-A0D0-80224F25FABB> \ - STRING transformNodeName; \ - DWORD nWeights; \ - array DWORD vertexIndices[nWeights]; \ - array float weights[nWeights]; \ - Matrix4x4 matrixOffset; \ - } \ - template Patch \ - { \ - \ - DWORD nControlIndices; \ - array DWORD controlIndices[nControlIndices]; \ - } \ - template PatchMesh \ - { \ - \ - DWORD nVertices; \ - array Vector vertices[nVertices]; \ - DWORD nPatches; \ - array Patch patches[nPatches]; \ - [ ... ] \ - } \ - template PatchMesh9 \ - { \ - \ - DWORD Type; \ - DWORD Degree; \ - DWORD Basis; \ - DWORD nVertices; \ - array Vector vertices[nVertices]; \ - DWORD nPatches; \ - array Patch patches[nPatches]; \ - [ ... ] \ - } " \ - "template EffectFloats \ - { \ - \ - DWORD nFloats; \ - array float Floats[nFloats]; \ - } \ - template EffectString \ - { \ - \ - STRING Value; \ - } \ - template EffectDWord \ - { \ - <622C0ED0-956E-4da9-908A-2AF94F3CE716> \ - DWORD Value; \ - } " \ - "template EffectParamFloats \ - { \ - <3014B9A0-62F5-478c-9B86-E4AC9F4E418B> \ - STRING ParamName; \ - DWORD nFloats; \ - array float Floats[nFloats]; \ - } " \ - "template EffectParamString \ - { \ - <1DBC4C88-94C1-46ee-9076-2C28818C9481> \ - STRING ParamName; \ - STRING Value; \ - } \ - template EffectParamDWord \ - { \ - \ - STRING ParamName; \ - DWORD Value; \ - } \ - template EffectInstance \ - { \ - \ - STRING EffectFilename; \ - [ ... ] \ - } " \ - "template AnimTicksPerSecond \ - { \ - <9E415A43-7BA6-4a73-8743-B73D47E88476> \ - DWORD AnimTicksPerSecond; \ - } \ - template CompressedAnimationSet \ - { \ - <7F9B00B3-F125-4890-876E-1C42BF697C4D> \ - DWORD CompressedBlockSize; \ - FLOAT TicksPerSec; \ - DWORD PlaybackType; \ - DWORD BufferLength; \ - array DWORD CompressedData[BufferLength]; \ - } " - -#define XEXTENSIONS_TEMPLATES \ - "xof 0303txt 0032\ - template FVFData \ - { \ - \ - DWORD dwFVF; \ - DWORD nDWords; \ - array DWORD data[nDWords]; \ - } \ - template VertexElement \ - { \ - \ - DWORD Type; \ - DWORD Method; \ - DWORD Usage; \ - DWORD UsageIndex; \ - } \ - template DeclData \ - { \ - \ - DWORD nElements; \ - array VertexElement Elements[nElements]; \ - DWORD nDWords; \ - array DWORD data[nDWords]; \ - } \ - template PMAttributeRange \ - { \ - <917E0427-C61E-4a14-9C64-AFE65F9E9844> \ - DWORD iFaceOffset; \ - DWORD nFacesMin; \ - DWORD nFacesMax; \ - DWORD iVertexOffset; \ - DWORD nVerticesMin; \ - DWORD nVerticesMax; \ - } \ - template PMVSplitRecord \ - { \ - <574CCC14-F0B3-4333-822D-93E8A8A08E4C> \ - DWORD iFaceCLW; \ - DWORD iVlrOffset; \ - DWORD iCode; \ - } \ - template PMInfo \ - { \ - \ - DWORD nAttributes; \ - array PMAttributeRange attributeRanges[nAttributes]; \ - DWORD nMaxValence; \ - DWORD nMinLogicalVertices; \ - DWORD nMaxLogicalVertices; \ - DWORD nVSplits; \ - array PMVSplitRecord splitRecords[nVSplits]; \ - DWORD nAttributeMispredicts; \ - array DWORD attributeMispredicts[nAttributeMispredicts]; \ - } " - -#endif //__D3DX9MESH_H__ - - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx9mesh.h +// Content: D3DX mesh types and functions +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx9.h" + +#ifndef __D3DX9MESH_H__ +#define __D3DX9MESH_H__ + +// {7ED943DD-52E8-40b5-A8D8-76685C406330} +DEFINE_GUID(IID_ID3DXBaseMesh, +0x7ed943dd, 0x52e8, 0x40b5, 0xa8, 0xd8, 0x76, 0x68, 0x5c, 0x40, 0x63, 0x30); + +// {4020E5C2-1403-4929-883F-E2E849FAC195} +DEFINE_GUID(IID_ID3DXMesh, +0x4020e5c2, 0x1403, 0x4929, 0x88, 0x3f, 0xe2, 0xe8, 0x49, 0xfa, 0xc1, 0x95); + +// {8875769A-D579-4088-AAEB-534D1AD84E96} +DEFINE_GUID(IID_ID3DXPMesh, +0x8875769a, 0xd579, 0x4088, 0xaa, 0xeb, 0x53, 0x4d, 0x1a, 0xd8, 0x4e, 0x96); + +// {667EA4C7-F1CD-4386-B523-7C0290B83CC5} +DEFINE_GUID(IID_ID3DXSPMesh, +0x667ea4c7, 0xf1cd, 0x4386, 0xb5, 0x23, 0x7c, 0x2, 0x90, 0xb8, 0x3c, 0xc5); + +// {11EAA540-F9A6-4d49-AE6A-E19221F70CC4} +DEFINE_GUID(IID_ID3DXSkinInfo, +0x11eaa540, 0xf9a6, 0x4d49, 0xae, 0x6a, 0xe1, 0x92, 0x21, 0xf7, 0xc, 0xc4); + +// {3CE6CC22-DBF2-44f4-894D-F9C34A337139} +DEFINE_GUID(IID_ID3DXPatchMesh, +0x3ce6cc22, 0xdbf2, 0x44f4, 0x89, 0x4d, 0xf9, 0xc3, 0x4a, 0x33, 0x71, 0x39); + +//patch mesh can be quads or tris +typedef enum _D3DXPATCHMESHTYPE { + D3DXPATCHMESH_RECT = 0x001, + D3DXPATCHMESH_TRI = 0x002, + D3DXPATCHMESH_NPATCH = 0x003, + + D3DXPATCHMESH_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DXPATCHMESHTYPE; + +// Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags +enum _D3DXMESH { + D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. + D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB. + D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. + D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. + D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. + D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER + D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. + D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB. + D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB. + D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB. + D3DXMESH_IB_SYSTEMMEM = 0x100, // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER + D3DXMESH_IB_MANAGED = 0x200, // Use D3DPOOL_MANAGED for IB. + D3DXMESH_IB_WRITEONLY = 0x400, // Use D3DUSAGE_WRITEONLY for IB. + D3DXMESH_IB_DYNAMIC = 0x800, // Use D3DUSAGE_DYNAMIC for IB. + D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, // Use D3DUSAGE_SOFTWAREPROCESSING for IB. + + D3DXMESH_VB_SHARE = 0x1000, // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer + + D3DXMESH_USEHWONLY = 0x2000, // Valid for ID3DXSkinInfo::ConvertToBlendedMesh + + // Helper options + D3DXMESH_SYSTEMMEM = 0x110, // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM + D3DXMESH_MANAGED = 0x220, // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED + D3DXMESH_WRITEONLY = 0x440, // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY + D3DXMESH_DYNAMIC = 0x880, // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC + D3DXMESH_SOFTWAREPROCESSING = 0x18000, // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING + +}; + +//patch mesh options +enum _D3DXPATCHMESH { + D3DXPATCHMESH_DEFAULT = 000, +}; +// option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh +enum _D3DXMESHSIMP +{ + D3DXMESHSIMP_VERTEX = 0x1, + D3DXMESHSIMP_FACE = 0x2, + +}; + +typedef enum _D3DXCLEANTYPE { + D3DXCLEAN_BACKFACING = 0x00000001, + D3DXCLEAN_BOWTIES = 0x00000002, + + // Helper options + D3DXCLEAN_SKINNING = D3DXCLEAN_BACKFACING, // Bowtie cleaning modifies geometry and breaks skinning + D3DXCLEAN_OPTIMIZATION = D3DXCLEAN_BACKFACING, + D3DXCLEAN_SIMPLIFICATION= D3DXCLEAN_BACKFACING | D3DXCLEAN_BOWTIES, +} D3DXCLEANTYPE; + +enum _MAX_FVF_DECL_SIZE +{ + MAX_FVF_DECL_SIZE = MAXD3DDECLLENGTH + 1 // +1 for END +}; + +typedef enum _D3DXTANGENT +{ + D3DXTANGENT_WRAP_U = 0x01, + D3DXTANGENT_WRAP_V = 0x02, + D3DXTANGENT_WRAP_UV = 0x03, + D3DXTANGENT_DONT_NORMALIZE_PARTIALS = 0x04, + D3DXTANGENT_DONT_ORTHOGONALIZE = 0x08, + D3DXTANGENT_ORTHOGONALIZE_FROM_V = 0x010, + D3DXTANGENT_ORTHOGONALIZE_FROM_U = 0x020, + D3DXTANGENT_WEIGHT_BY_AREA = 0x040, + D3DXTANGENT_WEIGHT_EQUAL = 0x080, + D3DXTANGENT_WIND_CW = 0x0100, + D3DXTANGENT_CALCULATE_NORMALS = 0x0200, + D3DXTANGENT_GENERATE_IN_PLACE = 0x0400, +} D3DXTANGENT; + +// D3DXIMT_WRAP_U means the texture wraps in the U direction +// D3DXIMT_WRAP_V means the texture wraps in the V direction +// D3DXIMT_WRAP_UV means the texture wraps in both directions +typedef enum _D3DXIMT +{ + D3DXIMT_WRAP_U = 0x01, + D3DXIMT_WRAP_V = 0x02, + D3DXIMT_WRAP_UV = 0x03, +} D3DXIMT; + + +typedef struct ID3DXBaseMesh *LPD3DXBASEMESH; +typedef struct ID3DXMesh *LPD3DXMESH; +typedef struct ID3DXPMesh *LPD3DXPMESH; +typedef struct ID3DXSPMesh *LPD3DXSPMESH; +typedef struct ID3DXSkinInfo *LPD3DXSKININFO; +typedef struct ID3DXPatchMesh *LPD3DXPATCHMESH; +typedef interface ID3DXTextureGutterHelper *LPD3DXTEXTUREGUTTERHELPER; +typedef interface ID3DXPRTBuffer *LPD3DXPRTBUFFER; + + +typedef struct _D3DXATTRIBUTERANGE +{ + DWORD AttribId; + DWORD FaceStart; + DWORD FaceCount; + DWORD VertexStart; + DWORD VertexCount; +} D3DXATTRIBUTERANGE; + +typedef D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE; + +typedef struct _D3DXMATERIAL +{ + D3DMATERIAL9 MatD3D; + LPSTR pTextureFilename; +} D3DXMATERIAL; +typedef D3DXMATERIAL *LPD3DXMATERIAL; + +typedef enum _D3DXEFFECTDEFAULTTYPE +{ + D3DXEDT_STRING = 0x1, // pValue points to a null terminated ASCII string + D3DXEDT_FLOATS = 0x2, // pValue points to an array of floats - number of floats is NumBytes / sizeof(float) + D3DXEDT_DWORD = 0x3, // pValue points to a DWORD + + D3DXEDT_FORCEDWORD = 0x7fffffff +} D3DXEFFECTDEFAULTTYPE; + +typedef struct _D3DXEFFECTDEFAULT +{ + LPSTR pParamName; + D3DXEFFECTDEFAULTTYPE Type; // type of the data pointed to by pValue + DWORD NumBytes; // size in bytes of the data pointed to by pValue + LPVOID pValue; // data for the default of the effect +} D3DXEFFECTDEFAULT, *LPD3DXEFFECTDEFAULT; + +typedef struct _D3DXEFFECTINSTANCE +{ + LPSTR pEffectFilename; + DWORD NumDefaults; + LPD3DXEFFECTDEFAULT pDefaults; +} D3DXEFFECTINSTANCE, *LPD3DXEFFECTINSTANCE; + +typedef struct _D3DXATTRIBUTEWEIGHTS +{ + FLOAT Position; + FLOAT Boundary; + FLOAT Normal; + FLOAT Diffuse; + FLOAT Specular; + FLOAT Texcoord[8]; + FLOAT Tangent; + FLOAT Binormal; +} D3DXATTRIBUTEWEIGHTS, *LPD3DXATTRIBUTEWEIGHTS; + +enum _D3DXWELDEPSILONSFLAGS +{ + D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping + + D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched + // vertices so that both components identical AND if all components "equal" + // remove one of the vertices + D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal + // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set + // useful to modify vertices to be equal, but not allow vertices to be removed + + D3DXWELDEPSILONS_DONOTSPLIT = 0x8, // instructs weld to specify the D3DXMESHOPT_DONOTSPLIT flag when doing an Optimize(ATTR_SORT) + // if this flag is not set, all vertices that are in separate attribute groups + // will remain split and not welded. Setting this flag can slow down software vertex processing + +}; + +typedef struct _D3DXWELDEPSILONS +{ + FLOAT Position; // NOTE: This does NOT replace the epsilon in GenerateAdjacency + // in general, it should be the same value or greater than the one passed to GeneratedAdjacency + FLOAT BlendWeights; + FLOAT Normal; + FLOAT PSize; + FLOAT Specular; + FLOAT Diffuse; + FLOAT Texcoord[8]; + FLOAT Tangent; + FLOAT Binormal; + FLOAT TessFactor; +} D3DXWELDEPSILONS; + +typedef D3DXWELDEPSILONS* LPD3DXWELDEPSILONS; + + +#undef INTERFACE +#define INTERFACE ID3DXBaseMesh + +DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; + + STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; +}; + + +#undef INTERFACE +#define INTERFACE ID3DXMesh + +DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; + + STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; + + // ID3DXMesh + STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE; + STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; + STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppOptMesh) PURE; + STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap) PURE; + STDMETHOD(SetAttributeTable)(THIS_ CONST D3DXATTRIBUTERANGE *pAttribTable, DWORD cAttribTableSize) PURE; +}; + + +#undef INTERFACE +#define INTERFACE ID3DXPMesh + +DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; + + STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; + + // ID3DXPMesh + STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMesh)(THIS_ DWORD Options, + CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(SetNumFaces)(THIS_ DWORD Faces) PURE; + STDMETHOD(SetNumVertices)(THIS_ DWORD Vertices) PURE; + STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMinFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetMinVertices)(THIS) PURE; + STDMETHOD(Save)(THIS_ IStream *pStream, CONST D3DXMATERIAL* pMaterials, CONST D3DXEFFECTINSTANCE* pEffectInstances, DWORD NumMaterials) PURE; + + STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppOptMesh) PURE; + + STDMETHOD(OptimizeBaseLOD)(THIS_ DWORD Flags, DWORD* pFaceRemap) PURE; + STDMETHOD(TrimByFaces)(THIS_ DWORD NewFacesMin, DWORD NewFacesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; + STDMETHOD(TrimByVertices)(THIS_ DWORD NewVerticesMin, DWORD NewVerticesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; + + STDMETHOD(GetAdjacency)(THIS_ DWORD* pAdjacency) PURE; + + // Used to generate the immediate "ancestor" for each vertex when it is removed by a vsplit. Allows generation of geomorphs + // Vertex buffer must be equal to or greater than the maximum number of vertices in the pmesh + STDMETHOD(GenerateVertexHistory)(THIS_ DWORD* pVertexHistory) PURE; +}; + + +#undef INTERFACE +#define INTERFACE ID3DXSPMesh + +DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXSPMesh + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pVertexRemapOut, FLOAT *pErrorsByFace, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMesh)(THIS_ DWORD Options, + CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pVertexRemapOut, FLOAT *pErrorsbyFace, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ReduceFaces)(THIS_ DWORD Faces) PURE; + STDMETHOD(ReduceVertices)(THIS_ DWORD Vertices) PURE; + STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; + STDMETHOD(GetVertexAttributeWeights)(THIS_ LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights) PURE; + STDMETHOD(GetVertexWeights)(THIS_ FLOAT *pVertexWeights) PURE; +}; + +#define UNUSED16 (0xffff) +#define UNUSED32 (0xffffffff) + +// ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags +enum _D3DXMESHOPT { + D3DXMESHOPT_COMPACT = 0x01000000, + D3DXMESHOPT_ATTRSORT = 0x02000000, + D3DXMESHOPT_VERTEXCACHE = 0x04000000, + D3DXMESHOPT_STRIPREORDER = 0x08000000, + D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices + D3DXMESHOPT_DONOTSPLIT = 0x20000000, // do not split vertices shared between attribute groups when attribute sorting + D3DXMESHOPT_DEVICEINDEPENDENT = 0x00400000, // Only affects VCache. uses a static known good cache size for all cards + + // D3DXMESHOPT_SHAREVB has been removed, please use D3DXMESH_VB_SHARE instead + +}; + +// Subset of the mesh that has the same attribute and bone combination. +// This subset can be rendered in a single draw call +typedef struct _D3DXBONECOMBINATION +{ + DWORD AttribId; + DWORD FaceStart; + DWORD FaceCount; + DWORD VertexStart; + DWORD VertexCount; + DWORD* BoneId; +} D3DXBONECOMBINATION, *LPD3DXBONECOMBINATION; + +// The following types of patch combinations are supported: +// Patch type Basis Degree +// Rect Bezier 2,3,5 +// Rect B-Spline 2,3,5 +// Rect Catmull-Rom 3 +// Tri Bezier 2,3,5 +// N-Patch N/A 3 + +typedef struct _D3DXPATCHINFO +{ + D3DXPATCHMESHTYPE PatchType; + D3DDEGREETYPE Degree; + D3DBASISTYPE Basis; +} D3DXPATCHINFO, *LPD3DXPATCHINFO; + +#undef INTERFACE +#define INTERFACE ID3DXPatchMesh + +DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXPatchMesh + + // Return creation parameters + STDMETHOD_(DWORD, GetNumPatches)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetControlVerticesPerPatch)(THIS) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9 *ppDevice) PURE; + STDMETHOD(GetPatchInfo)(THIS_ LPD3DXPATCHINFO PatchInfo) PURE; + + // Control mesh access + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, LPVOID *ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD flags, LPVOID *ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(LockAttributeBuffer)(THIS_ DWORD flags, DWORD** ppData) PURE; + STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; + + // This function returns the size of the tessellated mesh given a tessellation level. + // This assumes uniform tessellation. For adaptive tessellation the Adaptive parameter must + // be set to TRUE and TessellationLevel should be the max tessellation. + // This will result in the max mesh size necessary for adaptive tessellation. + STDMETHOD(GetTessSize)(THIS_ FLOAT fTessLevel,DWORD Adaptive, DWORD *NumTriangles,DWORD *NumVertices) PURE; + + //GenerateAdjacency determines which patches are adjacent with provided tolerance + //this information is used internally to optimize tessellation + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Tolerance) PURE; + + //CloneMesh Creates a new patchmesh with the specified decl, and converts the vertex buffer + //to the new decl. Entries in the new decl which are new are set to 0. If the current mesh + //has adjacency, the new mesh will also have adjacency + STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDecl, LPD3DXPATCHMESH *pMesh) PURE; + + // Optimizes the patchmesh for efficient tessellation. This function is designed + // to perform one time optimization for patch meshes that need to be tessellated + // repeatedly by calling the Tessellate() method. The optimization performed is + // independent of the actual tessellation level used. + // Currently Flags is unused. + // If vertices are changed, Optimize must be called again + STDMETHOD(Optimize)(THIS_ DWORD flags) PURE; + + //gets and sets displacement parameters + //displacement maps can only be 2D textures MIP-MAPPING is ignored for non adapative tessellation + STDMETHOD(SetDisplaceParam)(THIS_ LPDIRECT3DBASETEXTURE9 Texture, + D3DTEXTUREFILTERTYPE MinFilter, + D3DTEXTUREFILTERTYPE MagFilter, + D3DTEXTUREFILTERTYPE MipFilter, + D3DTEXTUREADDRESS Wrap, + DWORD dwLODBias) PURE; + + STDMETHOD(GetDisplaceParam)(THIS_ LPDIRECT3DBASETEXTURE9 *Texture, + D3DTEXTUREFILTERTYPE *MinFilter, + D3DTEXTUREFILTERTYPE *MagFilter, + D3DTEXTUREFILTERTYPE *MipFilter, + D3DTEXTUREADDRESS *Wrap, + DWORD *dwLODBias) PURE; + + // Performs the uniform tessellation based on the tessellation level. + // This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call. + STDMETHOD(Tessellate)(THIS_ FLOAT fTessLevel,LPD3DXMESH pMesh) PURE; + + // Performs adaptive tessellation based on the Z based adaptive tessellation criterion. + // pTrans specifies a 4D vector that is dotted with the vertices to get the per vertex + // adaptive tessellation amount. Each edge is tessellated to the average of the criterion + // at the 2 vertices it connects. + // MaxTessLevel specifies the upper limit for adaptive tesselation. + // This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call. + STDMETHOD(TessellateAdaptive)(THIS_ + CONST D3DXVECTOR4 *pTrans, + DWORD dwMaxTessLevel, + DWORD dwMinTessLevel, + LPD3DXMESH pMesh) PURE; + +}; + +#undef INTERFACE +#define INTERFACE ID3DXSkinInfo + +DECLARE_INTERFACE_(ID3DXSkinInfo, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // Specify the which vertices do each bones influence and by how much + STDMETHOD(SetBoneInfluence)(THIS_ DWORD bone, DWORD numInfluences, CONST DWORD* vertices, CONST FLOAT* weights) PURE; + STDMETHOD(SetBoneVertexInfluence)(THIS_ DWORD boneNum, DWORD influenceNum, float weight) PURE; + STDMETHOD_(DWORD, GetNumBoneInfluences)(THIS_ DWORD bone) PURE; + STDMETHOD(GetBoneInfluence)(THIS_ DWORD bone, DWORD* vertices, FLOAT* weights) PURE; + STDMETHOD(GetBoneVertexInfluence)(THIS_ DWORD boneNum, DWORD influenceNum, float *pWeight, DWORD *pVertexNum) PURE; + STDMETHOD(GetMaxVertexInfluences)(THIS_ DWORD* maxVertexInfluences) PURE; + STDMETHOD_(DWORD, GetNumBones)(THIS) PURE; + STDMETHOD(FindBoneVertexInfluenceIndex)(THIS_ DWORD boneNum, DWORD vertexNum, DWORD *pInfluenceIndex) PURE; + + // This gets the max face influences based on a triangle mesh with the specified index buffer + STDMETHOD(GetMaxFaceInfluences)(THIS_ LPDIRECT3DINDEXBUFFER9 pIB, DWORD NumFaces, DWORD* maxFaceInfluences) PURE; + + // Set min bone influence. Bone influences that are smaller than this are ignored + STDMETHOD(SetMinBoneInfluence)(THIS_ FLOAT MinInfl) PURE; + // Get min bone influence. + STDMETHOD_(FLOAT, GetMinBoneInfluence)(THIS) PURE; + + // Bone names are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object + STDMETHOD(SetBoneName)(THIS_ DWORD Bone, LPCSTR pName) PURE; // pName is copied to an internal string buffer + STDMETHOD_(LPCSTR, GetBoneName)(THIS_ DWORD Bone) PURE; // A pointer to an internal string buffer is returned. Do not free this. + + // Bone offset matrices are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object + STDMETHOD(SetBoneOffsetMatrix)(THIS_ DWORD Bone, CONST D3DXMATRIX *pBoneTransform) PURE; // pBoneTransform is copied to an internal buffer + STDMETHOD_(LPD3DXMATRIX, GetBoneOffsetMatrix)(THIS_ DWORD Bone) PURE; // A pointer to an internal matrix is returned. Do not free this. + + // Clone a skin info object + STDMETHOD(Clone)(THIS_ LPD3DXSKININFO* ppSkinInfo) PURE; + + // Update bone influence information to match vertices after they are reordered. This should be called + // if the target vertex buffer has been reordered externally. + STDMETHOD(Remap)(THIS_ DWORD NumVertices, DWORD* pVertexRemap) PURE; + + // These methods enable the modification of the vertex layout of the vertices that will be skinned + STDMETHOD(SetFVF)(THIS_ DWORD FVF) PURE; + STDMETHOD(SetDeclaration)(THIS_ CONST D3DVERTEXELEMENT9 *pDeclaration) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; + + // Apply SW skinning based on current pose matrices to the target vertices. + STDMETHOD(UpdateSkinnedMesh)(THIS_ + CONST D3DXMATRIX* pBoneTransforms, + CONST D3DXMATRIX* pBoneInvTransposeTransforms, + LPCVOID pVerticesSrc, + PVOID pVerticesDst) PURE; + + // Takes a mesh and returns a new mesh with per vertex blend weights and a bone combination + // table that describes which bones affect which subsets of the mesh + STDMETHOD(ConvertToBlendedMesh)(THIS_ + LPD3DXMESH pMesh, + DWORD Options, + CONST DWORD *pAdjacencyIn, + LPDWORD pAdjacencyOut, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, + DWORD* pMaxFaceInfl, + DWORD* pNumBoneCombinations, + LPD3DXBUFFER* ppBoneCombinationTable, + LPD3DXMESH* ppMesh) PURE; + + // Takes a mesh and returns a new mesh with per vertex blend weights and indices + // and a bone combination table that describes which bones palettes affect which subsets of the mesh + STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ + LPD3DXMESH pMesh, + DWORD Options, + DWORD paletteSize, + CONST DWORD *pAdjacencyIn, + LPDWORD pAdjacencyOut, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, + DWORD* pMaxVertexInfl, + DWORD* pNumBoneCombinations, + LPD3DXBUFFER* ppBoneCombinationTable, + LPD3DXMESH* ppMesh) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +HRESULT WINAPI + D3DXCreateMesh( + DWORD NumFaces, + DWORD NumVertices, + DWORD Options, + CONST D3DVERTEXELEMENT9 *pDeclaration, + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXCreateMeshFVF( + DWORD NumFaces, + DWORD NumVertices, + DWORD Options, + DWORD FVF, + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXCreateSPMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + LPD3DXSPMESH* ppSMesh); + +// clean a mesh up for simplification, try to make manifold +HRESULT WINAPI + D3DXCleanMesh( + D3DXCLEANTYPE CleanType, + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacencyIn, + LPD3DXMESH* ppMeshOut, + DWORD* pAdjacencyOut, + LPD3DXBUFFER* ppErrorsAndWarnings); + +HRESULT WINAPI + D3DXValidMesh( + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacency, + LPD3DXBUFFER* ppErrorsAndWarnings); + +HRESULT WINAPI + D3DXGeneratePMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + DWORD MinValue, + DWORD Options, + LPD3DXPMESH* ppPMesh); + +HRESULT WINAPI + D3DXSimplifyMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + DWORD MinValue, + DWORD Options, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXComputeBoundingSphere( + CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position + DWORD NumVertices, + DWORD dwStride, // count in bytes to subsequent position vectors + D3DXVECTOR3 *pCenter, + FLOAT *pRadius); + +HRESULT WINAPI + D3DXComputeBoundingBox( + CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position + DWORD NumVertices, + DWORD dwStride, // count in bytes to subsequent position vectors + D3DXVECTOR3 *pMin, + D3DXVECTOR3 *pMax); + +HRESULT WINAPI + D3DXComputeNormals( + LPD3DXBASEMESH pMesh, + CONST DWORD *pAdjacency); + +HRESULT WINAPI + D3DXCreateBuffer( + DWORD NumBytes, + LPD3DXBUFFER *ppBuffer); + + +HRESULT WINAPI + D3DXLoadMeshFromXA( + LPCSTR pFilename, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXLoadMeshFromXW( + LPCWSTR pFilename, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +#ifdef UNICODE +#define D3DXLoadMeshFromX D3DXLoadMeshFromXW +#else +#define D3DXLoadMeshFromX D3DXLoadMeshFromXA +#endif + +HRESULT WINAPI + D3DXLoadMeshFromXInMemory( + LPCVOID Memory, + DWORD SizeOfMemory, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXLoadMeshFromXResource( + HMODULE Module, + LPCSTR Name, + LPCSTR Type, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXSaveMeshToXA( + LPCSTR pFilename, + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST D3DXMATERIAL* pMaterials, + CONST D3DXEFFECTINSTANCE* pEffectInstances, + DWORD NumMaterials, + DWORD Format + ); + +HRESULT WINAPI + D3DXSaveMeshToXW( + LPCWSTR pFilename, + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST D3DXMATERIAL* pMaterials, + CONST D3DXEFFECTINSTANCE* pEffectInstances, + DWORD NumMaterials, + DWORD Format + ); + +#ifdef UNICODE +#define D3DXSaveMeshToX D3DXSaveMeshToXW +#else +#define D3DXSaveMeshToX D3DXSaveMeshToXA +#endif + + +HRESULT WINAPI + D3DXCreatePMeshFromStream( + IStream *pStream, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, + DWORD* pNumMaterials, + LPD3DXPMESH *ppPMesh); + +// Creates a skin info object based on the number of vertices, number of bones, and a declaration describing the vertex layout of the target vertices +// The bone names and initial bone transforms are not filled in the skin info object by this method. +HRESULT WINAPI + D3DXCreateSkinInfo( + DWORD NumVertices, + CONST D3DVERTEXELEMENT9 *pDeclaration, + DWORD NumBones, + LPD3DXSKININFO* ppSkinInfo); + +// Creates a skin info object based on the number of vertices, number of bones, and a FVF describing the vertex layout of the target vertices +// The bone names and initial bone transforms are not filled in the skin info object by this method. +HRESULT WINAPI + D3DXCreateSkinInfoFVF( + DWORD NumVertices, + DWORD FVF, + DWORD NumBones, + LPD3DXSKININFO* ppSkinInfo); + +#ifdef __cplusplus +} + +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXLoadMeshFromXof( + LPD3DXFILEDATA pxofMesh, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +// This similar to D3DXLoadMeshFromXof, except also returns skinning info if present in the file +// If skinning info is not present, ppSkinInfo will be NULL +HRESULT WINAPI + D3DXLoadSkinMeshFromXof( + LPD3DXFILEDATA pxofMesh, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXBUFFER* ppAdjacency, + LPD3DXBUFFER* ppMaterials, + LPD3DXBUFFER *ppEffectInstances, + DWORD *pMatOut, + LPD3DXSKININFO* ppSkinInfo, + LPD3DXMESH* ppMesh); + + +// The inverse of D3DXConvertTo{Indexed}BlendedMesh() functions. It figures out the skinning info from +// the mesh and the bone combination table and populates a skin info object with that data. The bone +// names and initial bone transforms are not filled in the skin info object by this method. This works +// with either a non-indexed or indexed blended mesh. It examines the FVF or declarator of the mesh to +// determine what type it is. +HRESULT WINAPI + D3DXCreateSkinInfoFromBlendedMesh( + LPD3DXBASEMESH pMesh, + DWORD NumBones, + CONST D3DXBONECOMBINATION *pBoneCombinationTable, + LPD3DXSKININFO* ppSkinInfo); + +HRESULT WINAPI + D3DXTessellateNPatches( + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacencyIn, + FLOAT NumSegs, + BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic + LPD3DXMESH *ppMeshOut, + LPD3DXBUFFER *ppAdjacencyOut); + + +//generates implied outputdecl from input decl +//the decl generated from this should be used to generate the output decl for +//the tessellator subroutines. + +HRESULT WINAPI + D3DXGenerateOutputDecl( + D3DVERTEXELEMENT9 *pOutput, + CONST D3DVERTEXELEMENT9 *pInput); + +//loads patches from an XFileData +//since an X file can have up to 6 different patch meshes in it, +//returns them in an array - pNumPatches will contain the number of +//meshes in the actual file. +HRESULT WINAPI + D3DXLoadPatchMeshFromXof( + LPD3DXFILEDATA pXofObjMesh, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, + PDWORD pNumMaterials, + LPD3DXPATCHMESH *ppMesh); + +//computes the size a single rect patch. +HRESULT WINAPI + D3DXRectPatchSize( + CONST FLOAT *pfNumSegs, //segments for each edge (4) + DWORD *pdwTriangles, //output number of triangles + DWORD *pdwVertices); //output number of vertices + +//computes the size of a single triangle patch +HRESULT WINAPI + D3DXTriPatchSize( + CONST FLOAT *pfNumSegs, //segments for each edge (3) + DWORD *pdwTriangles, //output number of triangles + DWORD *pdwVertices); //output number of vertices + + +//tessellates a patch into a created mesh +//similar to D3D RT patch +HRESULT WINAPI + D3DXTessellateRectPatch( + LPDIRECT3DVERTEXBUFFER9 pVB, + CONST FLOAT *pNumSegs, + CONST D3DVERTEXELEMENT9 *pdwInDecl, + CONST D3DRECTPATCH_INFO *pRectPatchInfo, + LPD3DXMESH pMesh); + + +HRESULT WINAPI + D3DXTessellateTriPatch( + LPDIRECT3DVERTEXBUFFER9 pVB, + CONST FLOAT *pNumSegs, + CONST D3DVERTEXELEMENT9 *pInDecl, + CONST D3DTRIPATCH_INFO *pTriPatchInfo, + LPD3DXMESH pMesh); + + + +//creates an NPatch PatchMesh from a D3DXMESH +HRESULT WINAPI + D3DXCreateNPatchMesh( + LPD3DXMESH pMeshSysMem, + LPD3DXPATCHMESH *pPatchMesh); + + +//creates a patch mesh +HRESULT WINAPI + D3DXCreatePatchMesh( + CONST D3DXPATCHINFO *pInfo, //patch type + DWORD dwNumPatches, //number of patches + DWORD dwNumVertices, //number of control vertices + DWORD dwOptions, //options + CONST D3DVERTEXELEMENT9 *pDecl, //format of control vertices + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXPATCHMESH *pPatchMesh); + + +//returns the number of degenerates in a patch mesh - +//text output put in string. +HRESULT WINAPI + D3DXValidPatchMesh(LPD3DXPATCHMESH pMesh, + DWORD *dwcDegenerateVertices, + DWORD *dwcDegeneratePatches, + LPD3DXBUFFER *ppErrorsAndWarnings); + +UINT WINAPI + D3DXGetFVFVertexSize(DWORD FVF); + +UINT WINAPI + D3DXGetDeclVertexSize(CONST D3DVERTEXELEMENT9 *pDecl,DWORD Stream); + +UINT WINAPI + D3DXGetDeclLength(CONST D3DVERTEXELEMENT9 *pDecl); + +HRESULT WINAPI + D3DXDeclaratorFromFVF( + DWORD FVF, + D3DVERTEXELEMENT9 pDeclarator[MAX_FVF_DECL_SIZE]); + +HRESULT WINAPI + D3DXFVFFromDeclarator( + CONST D3DVERTEXELEMENT9 *pDeclarator, + DWORD *pFVF); + +HRESULT WINAPI + D3DXWeldVertices( + LPD3DXMESH pMesh, + DWORD Flags, + CONST D3DXWELDEPSILONS *pEpsilons, + CONST DWORD *pAdjacencyIn, + DWORD *pAdjacencyOut, + DWORD *pFaceRemap, + LPD3DXBUFFER *ppVertexRemap); + +typedef struct _D3DXINTERSECTINFO +{ + DWORD FaceIndex; // index of face intersected + FLOAT U; // Barycentric Hit Coordinates + FLOAT V; // Barycentric Hit Coordinates + FLOAT Dist; // Ray-Intersection Parameter Distance +} D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO; + + +HRESULT WINAPI + D3DXIntersect( + LPD3DXBASEMESH pMesh, + CONST D3DXVECTOR3 *pRayPos, + CONST D3DXVECTOR3 *pRayDir, + BOOL *pHit, // True if any faces were intersected + DWORD *pFaceIndex, // index of closest face intersected + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist, // Ray-Intersection Parameter Distance + LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) + DWORD *pCountOfHits); // Number of entries in AllHits array + +HRESULT WINAPI + D3DXIntersectSubset( + LPD3DXBASEMESH pMesh, + DWORD AttribId, + CONST D3DXVECTOR3 *pRayPos, + CONST D3DXVECTOR3 *pRayDir, + BOOL *pHit, // True if any faces were intersected + DWORD *pFaceIndex, // index of closest face intersected + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist, // Ray-Intersection Parameter Distance + LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) + DWORD *pCountOfHits); // Number of entries in AllHits array + + +HRESULT WINAPI D3DXSplitMesh + ( + LPD3DXMESH pMeshIn, + CONST DWORD *pAdjacencyIn, + CONST DWORD MaxSize, + CONST DWORD Options, + DWORD *pMeshesOut, + LPD3DXBUFFER *ppMeshArrayOut, + LPD3DXBUFFER *ppAdjacencyArrayOut, + LPD3DXBUFFER *ppFaceRemapArrayOut, + LPD3DXBUFFER *ppVertRemapArrayOut + ); + +BOOL WINAPI D3DXIntersectTri +( + CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position + CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position + CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position + CONST D3DXVECTOR3 *pRayPos, // Ray origin + CONST D3DXVECTOR3 *pRayDir, // Ray direction + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist); // Ray-Intersection Parameter Distance + +BOOL WINAPI + D3DXSphereBoundProbe( + CONST D3DXVECTOR3 *pCenter, + FLOAT Radius, + CONST D3DXVECTOR3 *pRayPosition, + CONST D3DXVECTOR3 *pRayDirection); + +BOOL WINAPI + D3DXBoxBoundProbe( + CONST D3DXVECTOR3 *pMin, + CONST D3DXVECTOR3 *pMax, + CONST D3DXVECTOR3 *pRayPosition, + CONST D3DXVECTOR3 *pRayDirection); + + +HRESULT WINAPI D3DXComputeTangentFrame(ID3DXMesh *pMesh, + DWORD dwOptions); + +HRESULT WINAPI D3DXComputeTangentFrameEx(ID3DXMesh *pMesh, + DWORD dwTextureInSemantic, + DWORD dwTextureInIndex, + DWORD dwUPartialOutSemantic, + DWORD dwUPartialOutIndex, + DWORD dwVPartialOutSemantic, + DWORD dwVPartialOutIndex, + DWORD dwNormalOutSemantic, + DWORD dwNormalOutIndex, + DWORD dwOptions, + CONST DWORD *pdwAdjacency, + FLOAT fPartialEdgeThreshold, + FLOAT fSingularPointThreshold, + FLOAT fNormalEdgeThreshold, + ID3DXMesh **ppMeshOut, + ID3DXBuffer **ppVertexMapping); + + +//D3DXComputeTangent +// +//Computes the Tangent vectors for the TexStage texture coordinates +//and places the results in the TANGENT[TangentIndex] specified in the meshes' DECL +//puts the binorm in BINORM[BinormIndex] also specified in the decl. +// +//If neither the binorm or the tangnet are in the meshes declaration, +//the function will fail. +// +//If a tangent or Binorm field is in the Decl, but the user does not +//wish D3DXComputeTangent to replace them, then D3DX_DEFAULT specified +//in the TangentIndex or BinormIndex will cause it to ignore the specified +//semantic. +// +//Wrap should be specified if the texture coordinates wrap. + +HRESULT WINAPI D3DXComputeTangent(LPD3DXMESH Mesh, + DWORD TexStage, + DWORD TangentIndex, + DWORD BinormIndex, + DWORD Wrap, + CONST DWORD *pAdjacency); + +//============================================================================ +// +// UVAtlas apis +// +//============================================================================ +typedef HRESULT (WINAPI *LPD3DXUVATLASCB)(FLOAT fPercentDone, LPVOID lpUserContext); + +// This function creates atlases for meshes. There are two modes of operation, +// either based on the number of charts, or the maximum allowed stretch. If the +// maximum allowed stretch is 0, then each triangle will likely be in its own +// chart. + +// +// The parameters are as follows: +// pMesh - Input mesh to calculate an atlas for. This must have a position +// channel and at least a 2-d texture channel. +// uMaxChartNumber - The maximum number of charts required for the atlas. +// If this is 0, it will be parameterized based solely on +// stretch. +// fMaxStretch - The maximum amount of stretch, if 0, no stretching is allowed, +// if 1, then any amount of stretching is allowed. +// uWidth - The width of the texture the atlas will be used on. +// uHeight - The height of the texture the atlas will be used on. +// fGutter - The minimum distance, in texels between two charts on the atlas. +// this gets scaled by the width, so if fGutter is 2.5, and it is +// used on a 512x512 texture, then the minimum distance will be +// 2.5 / 512 in u-v space. +// dwTextureIndex - Specifies which texture coordinate to write to in the +// output mesh (which is cloned from the input mesh). Useful +// if your vertex has multiple texture coordinates. +// pdwAdjacency - a pointer to an array with 3 DWORDs per face, indicating +// which triangles are adjacent to each other. +// pdwFalseEdgeAdjacency - a pointer to an array with 3 DWORDS per face, indicating +// at each face, whether an edge is a false edge or not (using +// the same ordering as the adjacency data structure). If this +// is NULL, then it is assumed that there are no false edges. If +// not NULL, then a non-false edge is indicated by -1 and a false +// edge is indicated by any other value (it is not required, but +// it may be useful for the caller to use the original adjacency +// value). This allows you to parameterize a mesh of quads, and +// the edges down the middle of each quad will not be cut when +// parameterizing the mesh. +// pfIMTArray - a pointer to an array with 3 FLOATs per face, describing the +// integrated metric tensor for that face. This lets you control +// the way this triangle may be stretched in the atlas. The IMT +// passed in will be 3 floats (a,b,c) and specify a symmetric +// matrix (a b) that, given a vector (s,t), specifies the +// (b c) +// distance between a vector v1 and a vector v2 = v1 + (s,t) as +// sqrt((s, t) * M * (s, t)^T). +// In other words, this lets one specify the magnitude of the +// stretch in an arbitrary direction in u-v space. For example +// if a = b = c = 1, then this scales the vector (1,1) by 2, and +// the vector (1,-1) by 0. Note that this is multiplying the edge +// length by the square of the matrix, so if you want the face to +// stretch to twice its +// size with no shearing, the IMT value should be (2, 0, 2), which +// is just the identity matrix times 2. +// Note that this assumes you have an orientation for the triangle +// in some 2-D space. For D3DXUVAtlas, this space is created by +// letting S be the direction from the first to the second +// vertex, and T be the cross product between the normal and S. +// +// pStatusCallback - Since the atlas creation process can be very CPU intensive, +// this allows the programmer to specify a function to be called +// periodically, similarly to how it is done in the PRT simulation +// engine. +// fCallbackFrequency - This lets you specify how often the callback will be +// called. A decent default should be 0.0001f. +// pUserContext - a void pointer to be passed back to the callback function +// ppMeshOut - A pointer to a location to store a pointer for the newly created +// mesh. +// ppFacePartitioning - A pointer to a location to store a pointer for an array, +// one DWORD per face, giving the final partitioning +// created by the atlasing algorithm. +// ppVertexRemapArray - A pointer to a location to store a pointer for an array, +// one DWORD per vertex, giving the vertex it was copied +// from, if any vertices needed to be split. +// pfMaxStretchOut - A location to store the maximum stretch resulting from the +// atlasing algorithm. +// puNumChartsOut - A location to store the number of charts created, or if the +// maximum number of charts was too low, this gives the minimum +// number of charts needed to create an atlas. + +HRESULT WINAPI D3DXUVAtlasCreate(LPD3DXMESH pMesh, + UINT uMaxChartNumber, + FLOAT fMaxStretch, + UINT uWidth, + UINT uHeight, + FLOAT fGutter, + DWORD dwTextureIndex, + CONST DWORD *pdwAdjacency, + CONST DWORD *pdwFalseEdgeAdjacency, + CONST FLOAT *pfIMTArray, + LPD3DXUVATLASCB pStatusCallback, + FLOAT fCallbackFrequency, + LPVOID pUserContext, + LPD3DXMESH *ppMeshOut, + LPD3DXBUFFER *ppFacePartitioning, + LPD3DXBUFFER *ppVertexRemapArray, + FLOAT *pfMaxStretchOut, + UINT *puNumChartsOut); + +// This has the same exact arguments as Create, except that it does not perform the +// final packing step. This method allows one to get a partitioning out, and possibly +// modify it before sending it to be repacked. Note that if you change the +// partitioning, you'll also need to calculate new texture coordinates for any faces +// that have switched charts. +// +// The partition result adjacency output parameter is meant to be passed to the +// UVAtlasPack function, this adjacency cuts edges that are between adjacent +// charts, and also can include cuts inside of a chart in order to make it +// equivalent to a disc. For example: +// +// _______ +// | ___ | +// | |_| | +// |_____| +// +// In order to make this equivalent to a disc, we would need to add a cut, and it +// Would end up looking like: +// _______ +// | ___ | +// | |_|_| +// |_____| +// +// The resulting partition adjacency parameter cannot be NULL, because it is +// required for the packing step. + + + +HRESULT WINAPI D3DXUVAtlasPartition(LPD3DXMESH pMesh, + UINT uMaxChartNumber, + FLOAT fMaxStretch, + DWORD dwTextureIndex, + CONST DWORD *pdwAdjacency, + CONST DWORD *pdwFalseEdgeAdjacency, + CONST FLOAT *pfIMTArray, + LPD3DXUVATLASCB pStatusCallback, + FLOAT fCallbackFrequency, + LPVOID pUserContext, + LPD3DXMESH *ppMeshOut, + LPD3DXBUFFER *ppFacePartitioning, + LPD3DXBUFFER *ppVertexRemapArray, + LPD3DXBUFFER *ppPartitionResultAdjacency, + FLOAT *pfMaxStretchOut, + UINT *puNumChartsOut); + +// This takes the face partitioning result from Partition and packs it into an +// atlas of the given size. pdwPartitionResultAdjacency should be derived from +// the adjacency returned from the partition step. This value cannot be NULL +// because Pack needs to know where charts were cut in the partition step in +// order to find the edges of each chart. +HRESULT WINAPI D3DXUVAtlasPack(ID3DXMesh *pMesh, + UINT uWidth, + UINT uHeight, + FLOAT fGutter, + DWORD dwTextureIndex, + CONST DWORD *pdwPartitionResultAdjacency, + LPD3DXUVATLASCB pStatusCallback, + FLOAT fCallbackFrequency, + LPVOID pUserContext, + LPD3DXBUFFER pFacePartitioning); + + +//============================================================================ +// +// IMT Calculation apis +// +// These functions all compute the Integrated Metric Tensor for use in the +// UVAtlas API. They all calculate the IMT with respect to the canonical +// triangle, where the coordinate system is set up so that the u axis goes +// from vertex 0 to 1 and the v axis is N x u. So, for example, the second +// vertex's canonical uv coordinates are (d,0) where d is the distance between +// vertices 0 and 1. This way the IMT does not depend on the parameterization +// of the mesh, and if the signal over the surface doesn't change, then +// the IMT doesn't need to be recalculated. +//============================================================================ + +// This callback is used by D3DXComputeIMTFromSignal. +// +// uv - The texture coordinate for the vertex. +// uPrimitiveID - Face ID of the triangle on which to compute the signal. +// uSignalDimension - The number of floats to store in pfSignalOut. +// pUserData - The pUserData pointer passed in to ComputeIMTFromSignal. +// pfSignalOut - A pointer to where to store the signal data. +typedef HRESULT (WINAPI* LPD3DXIMTSIGNALCALLBACK) + (CONST D3DXVECTOR2 *uv, + UINT uPrimitiveID, + UINT uSignalDimension, + VOID *pUserData, + FLOAT *pfSignalOut); + +// This function is used to calculate the IMT from per vertex data. It sets +// up a linear system over the triangle, solves for the jacobian J, then +// constructs the IMT from that (J^TJ). +// This function allows you to calculate the IMT based off of any value in a +// mesh (color, normal, etc) by specifying the correct stride of the array. +// The IMT computed will cause areas of the mesh that have similar values to +// take up less space in the texture. +// +// pMesh - The mesh to calculate the IMT for. +// pVertexSignal - A float array of size uSignalStride * v, where v is the +// number of vertices in the mesh. +// uSignalDimension - How many floats per vertex to use in calculating the IMT. +// uSignalStride - The number of bytes per vertex in the array. This must be +// a multiple of sizeof(float) +// ppIMTData - Where to store the buffer holding the IMT data + +HRESULT WINAPI D3DXComputeIMTFromPerVertexSignal ( + LPD3DXMESH pMesh, + CONST FLOAT *pfVertexSignal, // uSignalDimension floats per vertex + UINT uSignalDimension, + UINT uSignalStride, // stride of signal in bytes + DWORD dwOptions, // reserved for future use + LPD3DXUVATLASCB pStatusCallback, + LPVOID pUserContext, + LPD3DXBUFFER *ppIMTData); + +// This function is used to calculate the IMT from data that varies over the +// surface of the mesh (generally at a higher frequency than vertex data). +// This function requires the mesh to already be parameterized (so it already +// has texture coordinates). It allows the user to define a signal arbitrarily +// over the surface of the mesh. +// +// pMesh - The mesh to calculate the IMT for. +// dwTextureIndex - This describes which set of texture coordinates in the +// mesh to use. +// uSignalDimension - How many components there are in the signal. +// fMaxUVDistance - The subdivision will continue until the distance between +// all vertices is at most fMaxUVDistance. +// dwOptions - reserved for future use +// pSignalCallback - The callback to use to get the signal. +// pUserData - A pointer that will be passed in to the callback. +// ppIMTData - Where to store the buffer holding the IMT data +HRESULT WINAPI D3DXComputeIMTFromSignal( + LPD3DXMESH pMesh, + DWORD dwTextureIndex, + UINT uSignalDimension, + FLOAT fMaxUVDistance, + DWORD dwOptions, // reserved for future use + LPD3DXIMTSIGNALCALLBACK pSignalCallback, + VOID *pUserData, + LPD3DXUVATLASCB pStatusCallback, + LPVOID pUserContext, + LPD3DXBUFFER *ppIMTData); + +// This function is used to calculate the IMT from texture data. Given a texture +// that maps over the surface of the mesh, the algorithm computes the IMT for +// each face. This will cause large areas that are very similar to take up less +// room when parameterized with UVAtlas. The texture is assumed to be +// interpolated over the mesh bilinearly. +// +// pMesh - The mesh to calculate the IMT for. +// pTexture - The texture to load data from. +// dwTextureIndex - This describes which set of texture coordinates in the +// mesh to use. +// dwOptions - Combination of one or more D3DXIMT flags. +// ppIMTData - Where to store the buffer holding the IMT data +HRESULT WINAPI D3DXComputeIMTFromTexture ( + LPD3DXMESH pMesh, + LPDIRECT3DTEXTURE9 pTexture, + DWORD dwTextureIndex, + DWORD dwOptions, + LPD3DXUVATLASCB pStatusCallback, + LPVOID pUserContext, + LPD3DXBUFFER *ppIMTData); + +// This function is very similar to ComputeIMTFromTexture, but it uses a +// float array to pass in the data, and it can calculate higher dimensional +// values than 4. +// +// pMesh - The mesh to calculate the IMT for. +// dwTextureIndex - This describes which set of texture coordinates in the +// mesh to use. +// pfFloatArray - a pointer to a float array of size +// uWidth*uHeight*uComponents +// uWidth - The width of the texture +// uHeight - The height of the texture +// uSignalDimension - The number of floats per texel in the signal +// uComponents - The number of floats in each texel +// dwOptions - Combination of one or more D3DXIMT flags +// ppIMTData - Where to store the buffer holding the IMT data +HRESULT WINAPI D3DXComputeIMTFromPerTexelSignal( + LPD3DXMESH pMesh, + DWORD dwTextureIndex, + FLOAT *pfTexelSignal, + UINT uWidth, + UINT uHeight, + UINT uSignalDimension, + UINT uComponents, + DWORD dwOptions, + LPD3DXUVATLASCB pStatusCallback, + LPVOID pUserContext, + LPD3DXBUFFER *ppIMTData); + +HRESULT WINAPI + D3DXConvertMeshSubsetToSingleStrip( + LPD3DXBASEMESH MeshIn, + DWORD AttribId, + DWORD IBOptions, + LPDIRECT3DINDEXBUFFER9 *ppIndexBuffer, + DWORD *pNumIndices); + +HRESULT WINAPI + D3DXConvertMeshSubsetToStrips( + LPD3DXBASEMESH MeshIn, + DWORD AttribId, + DWORD IBOptions, + LPDIRECT3DINDEXBUFFER9 *ppIndexBuffer, + DWORD *pNumIndices, + LPD3DXBUFFER *ppStripLengths, + DWORD *pNumStrips); + + +//============================================================================ +// +// D3DXOptimizeFaces: +// -------------------- +// Generate a face remapping for a triangle list that more effectively utilizes +// vertex caches. This optimization is identical to the one provided +// by ID3DXMesh::Optimize with the hardware independent option enabled. +// +// Parameters: +// pbIndices +// Triangle list indices to use for generating a vertex ordering +// NumFaces +// Number of faces in the triangle list +// NumVertices +// Number of vertices referenced by the triangle list +// b32BitIndices +// TRUE if indices are 32 bit, FALSE if indices are 16 bit +// pFaceRemap +// Destination buffer to store face ordering +// The number stored for a given element is where in the new ordering +// the face will have come from. See ID3DXMesh::Optimize for more info. +// +//============================================================================ +HRESULT WINAPI + D3DXOptimizeFaces( + LPCVOID pbIndices, + UINT cFaces, + UINT cVertices, + BOOL b32BitIndices, + DWORD* pFaceRemap); + +//============================================================================ +// +// D3DXOptimizeVertices: +// -------------------- +// Generate a vertex remapping to optimize for in order use of vertices for +// a given set of indices. This is commonly used after applying the face +// remap generated by D3DXOptimizeFaces +// +// Parameters: +// pbIndices +// Triangle list indices to use for generating a vertex ordering +// NumFaces +// Number of faces in the triangle list +// NumVertices +// Number of vertices referenced by the triangle list +// b32BitIndices +// TRUE if indices are 32 bit, FALSE if indices are 16 bit +// pVertexRemap +// Destination buffer to store vertex ordering +// The number stored for a given element is where in the new ordering +// the vertex will have come from. See ID3DXMesh::Optimize for more info. +// +//============================================================================ +HRESULT WINAPI + D3DXOptimizeVertices( + LPCVOID pbIndices, + UINT cFaces, + UINT cVertices, + BOOL b32BitIndices, + DWORD* pVertexRemap); + +#ifdef __cplusplus +} +#endif //__cplusplus + + +//=========================================================================== +// +// Data structures for Spherical Harmonic Precomputation +// +// +//============================================================================ + +typedef enum _D3DXSHCOMPRESSQUALITYTYPE { + D3DXSHCQUAL_FASTLOWQUALITY = 1, + D3DXSHCQUAL_SLOWHIGHQUALITY = 2, + D3DXSHCQUAL_FORCE_DWORD = 0x7fffffff +} D3DXSHCOMPRESSQUALITYTYPE; + +typedef enum _D3DXSHGPUSIMOPT { + D3DXSHGPUSIMOPT_SHADOWRES256 = 1, + D3DXSHGPUSIMOPT_SHADOWRES512 = 0, + D3DXSHGPUSIMOPT_SHADOWRES1024 = 2, + D3DXSHGPUSIMOPT_SHADOWRES2048 = 3, + + D3DXSHGPUSIMOPT_HIGHQUALITY = 4, + + D3DXSHGPUSIMOPT_FORCE_DWORD = 0x7fffffff +} D3DXSHGPUSIMOPT; + +// for all properties that are colors the luminance is computed +// if the simulator is run with a single channel using the following +// formula: R * 0.2125 + G * 0.7154 + B * 0.0721 + +typedef struct _D3DXSHMATERIAL { + D3DCOLORVALUE Diffuse; // Diffuse albedo of the surface. (Ignored if object is a Mirror) + BOOL bMirror; // Must be set to FALSE. bMirror == TRUE not currently supported + BOOL bSubSurf; // true if the object does subsurface scattering - can't do this and be a mirror + + // subsurface scattering parameters + FLOAT RelativeIndexOfRefraction; + D3DCOLORVALUE Absorption; + D3DCOLORVALUE ReducedScattering; + +} D3DXSHMATERIAL; + +// allocated in D3DXSHPRTCompSplitMeshSC +// vertices are duplicated into multiple super clusters but +// only have a valid status in one super cluster (fill in the rest) + +typedef struct _D3DXSHPRTSPLITMESHVERTDATA { + UINT uVertRemap; // vertex in original mesh this corresponds to + UINT uSubCluster; // cluster index relative to super cluster + UCHAR ucVertStatus; // 1 if vertex has valid data, 0 if it is "fill" +} D3DXSHPRTSPLITMESHVERTDATA; + +// used in D3DXSHPRTCompSplitMeshSC +// information for each super cluster that maps into face/vert arrays + +typedef struct _D3DXSHPRTSPLITMESHCLUSTERDATA { + UINT uVertStart; // initial index into remapped vertex array + UINT uVertLength; // number of vertices in this super cluster + + UINT uFaceStart; // initial index into face array + UINT uFaceLength; // number of faces in this super cluster + + UINT uClusterStart; // initial index into cluster array + UINT uClusterLength; // number of clusters in this super cluster +} D3DXSHPRTSPLITMESHCLUSTERDATA; + +// call back function for simulator +// return S_OK to keep running the simulator - anything else represents +// failure and the simulator will abort. + +typedef HRESULT (WINAPI *LPD3DXSHPRTSIMCB)(float fPercentDone, LPVOID lpUserContext); + +// interfaces for PRT buffers/simulator + +// GUIDs +// {F1827E47-00A8-49cd-908C-9D11955F8728} +DEFINE_GUID(IID_ID3DXPRTBuffer, +0xf1827e47, 0xa8, 0x49cd, 0x90, 0x8c, 0x9d, 0x11, 0x95, 0x5f, 0x87, 0x28); + +// {A758D465-FE8D-45ad-9CF0-D01E56266A07} +DEFINE_GUID(IID_ID3DXPRTCompBuffer, +0xa758d465, 0xfe8d, 0x45ad, 0x9c, 0xf0, 0xd0, 0x1e, 0x56, 0x26, 0x6a, 0x7); + +// {838F01EC-9729-4527-AADB-DF70ADE7FEA9} +DEFINE_GUID(IID_ID3DXTextureGutterHelper, +0x838f01ec, 0x9729, 0x4527, 0xaa, 0xdb, 0xdf, 0x70, 0xad, 0xe7, 0xfe, 0xa9); + +// {683A4278-CD5F-4d24-90AD-C4E1B6855D53} +DEFINE_GUID(IID_ID3DXPRTEngine, +0x683a4278, 0xcd5f, 0x4d24, 0x90, 0xad, 0xc4, 0xe1, 0xb6, 0x85, 0x5d, 0x53); + +// interface defenitions + +typedef interface ID3DXTextureGutterHelper ID3DXTextureGutterHelper; +typedef interface ID3DXPRTBuffer ID3DXPRTBuffer; + +#undef INTERFACE +#define INTERFACE ID3DXPRTBuffer + +// Buffer interface - contains "NumSamples" samples +// each sample in memory is stored as NumCoeffs scalars per channel (1 or 3) +// Same interface is used for both Vertex and Pixel PRT buffers + +DECLARE_INTERFACE_(ID3DXPRTBuffer, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXPRTBuffer + STDMETHOD_(UINT, GetNumSamples)(THIS) PURE; + STDMETHOD_(UINT, GetNumCoeffs)(THIS) PURE; + STDMETHOD_(UINT, GetNumChannels)(THIS) PURE; + + STDMETHOD_(BOOL, IsTexture)(THIS) PURE; + STDMETHOD_(UINT, GetWidth)(THIS) PURE; + STDMETHOD_(UINT, GetHeight)(THIS) PURE; + + // changes the number of samples allocated in the buffer + STDMETHOD(Resize)(THIS_ UINT NewSize) PURE; + + // ppData will point to the memory location where sample Start begins + // pointer is valid for at least NumSamples samples + STDMETHOD(LockBuffer)(THIS_ UINT Start, UINT NumSamples, FLOAT **ppData) PURE; + STDMETHOD(UnlockBuffer)(THIS) PURE; + + // every scalar in buffer is multiplied by Scale + STDMETHOD(ScaleBuffer)(THIS_ FLOAT Scale) PURE; + + // every scalar contains the sum of this and pBuffers values + // pBuffer must have the same storage class/dimensions + STDMETHOD(AddBuffer)(THIS_ LPD3DXPRTBUFFER pBuffer) PURE; + + // GutterHelper (described below) will fill in the gutter + // regions of a texture by interpolating "internal" values + STDMETHOD(AttachGH)(THIS_ LPD3DXTEXTUREGUTTERHELPER) PURE; + STDMETHOD(ReleaseGH)(THIS) PURE; + + // Evaluates attached gutter helper on the contents of this buffer + STDMETHOD(EvalGH)(THIS) PURE; + + // extracts a given channel into texture pTexture + // NumCoefficients starting from StartCoefficient are copied + STDMETHOD(ExtractTexture)(THIS_ UINT Channel, UINT StartCoefficient, + UINT NumCoefficients, LPDIRECT3DTEXTURE9 pTexture) PURE; + + // extracts NumCoefficients coefficients into mesh - only applicable on single channel + // buffers, otherwise just lockbuffer and copy data. With SHPRT data NumCoefficients + // should be Order^2 + STDMETHOD(ExtractToMesh)(THIS_ UINT NumCoefficients, D3DDECLUSAGE Usage, UINT UsageIndexStart, + LPD3DXMESH pScene) PURE; + +}; + +typedef interface ID3DXPRTCompBuffer ID3DXPRTCompBuffer; +typedef interface ID3DXPRTCompBuffer *LPD3DXPRTCOMPBUFFER; + +#undef INTERFACE +#define INTERFACE ID3DXPRTCompBuffer + +// compressed buffers stored a compressed version of a PRTBuffer + +DECLARE_INTERFACE_(ID3DXPRTCompBuffer, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DPRTCompBuffer + + // NumCoeffs and NumChannels are properties of input buffer + STDMETHOD_(UINT, GetNumSamples)(THIS) PURE; + STDMETHOD_(UINT, GetNumCoeffs)(THIS) PURE; + STDMETHOD_(UINT, GetNumChannels)(THIS) PURE; + + STDMETHOD_(BOOL, IsTexture)(THIS) PURE; + STDMETHOD_(UINT, GetWidth)(THIS) PURE; + STDMETHOD_(UINT, GetHeight)(THIS) PURE; + + // number of clusters, and PCA vectors per-cluster + STDMETHOD_(UINT, GetNumClusters)(THIS) PURE; + STDMETHOD_(UINT, GetNumPCA)(THIS) PURE; + + // normalizes PCA weights so that they are between [-1,1] + // basis vectors are modified to reflect this + STDMETHOD(NormalizeData)(THIS) PURE; + + // copies basis vectors for cluster "Cluster" into pClusterBasis + // (NumPCA+1)*NumCoeffs*NumChannels floats + STDMETHOD(ExtractBasis)(THIS_ UINT Cluster, FLOAT *pClusterBasis) PURE; + + // UINT per sample - which cluster it belongs to + STDMETHOD(ExtractClusterIDs)(THIS_ UINT *pClusterIDs) PURE; + + // copies NumExtract PCA projection coefficients starting at StartPCA + // into pPCACoefficients - NumSamples*NumExtract floats copied + STDMETHOD(ExtractPCA)(THIS_ UINT StartPCA, UINT NumExtract, FLOAT *pPCACoefficients) PURE; + + // copies NumPCA projection coefficients starting at StartPCA + // into pTexture - should be able to cope with signed formats + STDMETHOD(ExtractTexture)(THIS_ UINT StartPCA, UINT NumpPCA, + LPDIRECT3DTEXTURE9 pTexture) PURE; + + // copies NumPCA projection coefficients into mesh pScene + // Usage is D3DDECLUSAGE where coefficients are to be stored + // UsageIndexStart is starting index + STDMETHOD(ExtractToMesh)(THIS_ UINT NumPCA, D3DDECLUSAGE Usage, UINT UsageIndexStart, + LPD3DXMESH pScene) PURE; +}; + + +#undef INTERFACE +#define INTERFACE ID3DXTextureGutterHelper + +// ID3DXTextureGutterHelper will build and manage +// "gutter" regions in a texture - this will allow for +// bi-linear interpolation to not have artifacts when rendering +// It generates a map (in texture space) where each texel +// is in one of 3 states: +// 0 Invalid - not used at all +// 1 Inside triangle +// 2 Gutter texel +// 4 represents a gutter texel that will be computed during PRT +// For each Inside/Gutter texel it stores the face it +// belongs to and barycentric coordinates for the 1st two +// vertices of that face. Gutter vertices are assigned to +// the closest edge in texture space. +// +// When used with PRT this requires a unique parameterization +// of the model - every texel must correspond to a single point +// on the surface of the model and vice versa + +DECLARE_INTERFACE_(ID3DXTextureGutterHelper, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXTextureGutterHelper + + // dimensions of texture this is bound too + STDMETHOD_(UINT, GetWidth)(THIS) PURE; + STDMETHOD_(UINT, GetHeight)(THIS) PURE; + + + // Applying gutters recomputes all of the gutter texels of class "2" + // based on texels of class "1" or "4" + + // Applies gutters to a raw float buffer - each texel is NumCoeffs floats + // Width and Height must match GutterHelper + STDMETHOD(ApplyGuttersFloat)(THIS_ FLOAT *pDataIn, UINT NumCoeffs, UINT Width, UINT Height); + + // Applies gutters to pTexture + // Dimensions must match GutterHelper + STDMETHOD(ApplyGuttersTex)(THIS_ LPDIRECT3DTEXTURE9 pTexture); + + // Applies gutters to a D3DXPRTBuffer + // Dimensions must match GutterHelper + STDMETHOD(ApplyGuttersPRT)(THIS_ LPD3DXPRTBUFFER pBuffer); + + // Resamples a texture from a mesh onto this gutterhelpers + // parameterization. It is assumed that the UV coordinates + // for this gutter helper are in TEXTURE 0 (usage/usage index) + // and the texture coordinates should all be within [0,1] for + // both sets. + // + // pTextureIn - texture represented using parameterization in pMeshIn + // pMeshIn - Mesh with texture coordinates that represent pTextureIn + // pTextureOut texture coordinates are assumed to be in + // TEXTURE 0 + // Usage - field in DECL for pMeshIn that stores texture coordinates + // for pTextureIn + // UsageIndex - which index for Usage above for pTextureIn + // pTextureOut- Resampled texture + // + // Usage would generally be D3DDECLUSAGE_TEXCOORD and UsageIndex other than zero + STDMETHOD(ResampleTex)(THIS_ LPDIRECT3DTEXTURE9 pTextureIn, + LPD3DXMESH pMeshIn, + D3DDECLUSAGE Usage, UINT UsageIndex, + LPDIRECT3DTEXTURE9 pTextureOut); + + // the routines below provide access to the data structures + // used by the Apply functions + + // face map is a UINT per texel that represents the + // face of the mesh that texel belongs too - + // only valid if same texel is valid in pGutterData + // pFaceData must be allocated by the user + STDMETHOD(GetFaceMap)(THIS_ UINT *pFaceData) PURE; + + // BaryMap is a D3DXVECTOR2 per texel + // the 1st two barycentric coordinates for the corresponding + // face (3rd weight is always 1-sum of first two) + // only valid if same texel is valid in pGutterData + // pBaryData must be allocated by the user + STDMETHOD(GetBaryMap)(THIS_ D3DXVECTOR2 *pBaryData) PURE; + + // TexelMap is a D3DXVECTOR2 per texel that + // stores the location in pixel coordinates where the + // corresponding texel is mapped + // pTexelData must be allocated by the user + STDMETHOD(GetTexelMap)(THIS_ D3DXVECTOR2 *pTexelData) PURE; + + // GutterMap is a BYTE per texel + // 0/1/2 for Invalid/Internal/Gutter texels + // 4 represents a gutter texel that will be computed + // during PRT + // pGutterData must be allocated by the user + STDMETHOD(GetGutterMap)(THIS_ BYTE *pGutterData) PURE; + + // face map is a UINT per texel that represents the + // face of the mesh that texel belongs too - + // only valid if same texel is valid in pGutterData + STDMETHOD(SetFaceMap)(THIS_ UINT *pFaceData) PURE; + + // BaryMap is a D3DXVECTOR2 per texel + // the 1st two barycentric coordinates for the corresponding + // face (3rd weight is always 1-sum of first two) + // only valid if same texel is valid in pGutterData + STDMETHOD(SetBaryMap)(THIS_ D3DXVECTOR2 *pBaryData) PURE; + + // TexelMap is a D3DXVECTOR2 per texel that + // stores the location in pixel coordinates where the + // corresponding texel is mapped + STDMETHOD(SetTexelMap)(THIS_ D3DXVECTOR2 *pTexelData) PURE; + + // GutterMap is a BYTE per texel + // 0/1/2 for Invalid/Internal/Gutter texels + // 4 represents a gutter texel that will be computed + // during PRT + STDMETHOD(SetGutterMap)(THIS_ BYTE *pGutterData) PURE; +}; + + +typedef interface ID3DXPRTEngine ID3DXPRTEngine; +typedef interface ID3DXPRTEngine *LPD3DXPRTENGINE; + +#undef INTERFACE +#define INTERFACE ID3DXPRTEngine + +// ID3DXPRTEngine is used to compute a PRT simulation +// Use the following steps to compute PRT for SH +// (1) create an interface (which includes a scene) +// (2) call SetSamplingInfo +// (3) [optional] Set MeshMaterials/albedo's (required if doing bounces) +// (4) call ComputeDirectLightingSH +// (5) [optional] call ComputeBounce +// repeat step 5 for as many bounces as wanted. +// if you want to model subsurface scattering you +// need to call ComputeSS after direct lighting and +// each bounce. +// If you want to bake the albedo into the PRT signal, you +// must call MutliplyAlbedo, otherwise the user has to multiply +// the albedo themselves. Not multiplying the albedo allows you +// to model albedo variation at a finer scale then illumination, and +// can result in better compression results. +// Luminance values are computed from RGB values using the following +// formula: R * 0.2125 + G * 0.7154 + B * 0.0721 + +DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXPRTEngine + + // This sets a material per attribute in the scene mesh and it is + // the only way to specify subsurface scattering parameters. if + // bSetAlbedo is FALSE, NumChannels must match the current + // configuration of the PRTEngine. If you intend to change + // NumChannels (through some other SetAlbedo function) it must + // happen before SetMeshMaterials is called. + // + // NumChannels 1 implies "grayscale" materials, set this to 3 to enable + // color bleeding effects + // bSetAlbedo sets albedo from material if TRUE - which clobbers per texel/vertex + // albedo that might have been set before. FALSE won't clobber. + // fLengthScale is used for subsurface scattering - scene is mapped into a 1mm unit cube + // and scaled by this amount + STDMETHOD(SetMeshMaterials)(THIS_ CONST D3DXSHMATERIAL **ppMaterials, UINT NumMeshes, + UINT NumChannels, BOOL bSetAlbedo, FLOAT fLengthScale) PURE; + + // setting albedo per-vertex or per-texel over rides the albedos stored per mesh + // but it does not over ride any other settings + + // sets an albedo to be used per vertex - the albedo is represented as a float + // pDataIn input pointer (pointint to albedo of 1st sample) + // NumChannels 1 implies "grayscale" materials, set this to 3 to enable + // color bleeding effects + // Stride - stride in bytes to get to next samples albedo + STDMETHOD(SetPerVertexAlbedo)(THIS_ CONST VOID *pDataIn, UINT NumChannels, UINT Stride) PURE; + + // represents the albedo per-texel instead of per-vertex (even if per-vertex PRT is used) + // pAlbedoTexture - texture that stores the albedo (dimension arbitrary) + // NumChannels 1 implies "grayscale" materials, set this to 3 to enable + // color bleeding effects + // pGH - optional gutter helper, otherwise one is constructed in computation routines and + // destroyed (if not attached to buffers) + STDMETHOD(SetPerTexelAlbedo)(THIS_ LPDIRECT3DTEXTURE9 pAlbedoTexture, + UINT NumChannels, + LPD3DXTEXTUREGUTTERHELPER pGH) PURE; + + // gets the per-vertex albedo + STDMETHOD(GetVertexAlbedo)(THIS_ D3DXCOLOR *pVertColors, UINT NumVerts) PURE; + + // If pixel PRT is being computed normals default to ones that are interpolated + // from the vertex normals. This specifies a texture that stores an object + // space normal map instead (must use a texture format that can represent signed values) + // pNormalTexture - normal map, must be same dimensions as PRTBuffers, signed + STDMETHOD(SetPerTexelNormal)(THIS_ LPDIRECT3DTEXTURE9 pNormalTexture) PURE; + + // Copies per-vertex albedo from mesh + // pMesh - mesh that represents the scene. It must have the same + // properties as the mesh used to create the PRTEngine + // Usage - D3DDECLUSAGE to extract albedos from + // NumChannels 1 implies "grayscale" materials, set this to 3 to enable + // color bleeding effects + STDMETHOD(ExtractPerVertexAlbedo)(THIS_ LPD3DXMESH pMesh, + D3DDECLUSAGE Usage, + UINT NumChannels) PURE; + + // Resamples the input buffer into the output buffer + // can be used to move between per-vertex and per-texel buffers. This can also be used + // to convert single channel buffers to 3-channel buffers and vice-versa. + STDMETHOD(ResampleBuffer)(THIS_ LPD3DXPRTBUFFER pBufferIn, LPD3DXPRTBUFFER pBufferOut) PURE; + + // Returns the scene mesh - including modifications from adaptive spatial sampling + // The returned mesh only has positions, normals and texture coordinates (if defined) + // pD3DDevice - d3d device that will be used to allocate the mesh + // pFaceRemap - each face has a pointer back to the face on the original mesh that it comes from + // if the face hasn't been subdivided this will be an identity mapping + // pVertRemap - each vertex contains 3 vertices that this is a linear combination of + // pVertWeights - weights for each of above indices (sum to 1.0f) + // ppMesh - mesh that will be allocated and filled + STDMETHOD(GetAdaptedMesh)(THIS_ LPDIRECT3DDEVICE9 pD3DDevice,UINT *pFaceRemap, UINT *pVertRemap, FLOAT *pfVertWeights, LPD3DXMESH *ppMesh) PURE; + + // Number of vertices currently allocated (includes new vertices from adaptive sampling) + STDMETHOD_(UINT, GetNumVerts)(THIS) PURE; + // Number of faces currently allocated (includes new faces) + STDMETHOD_(UINT, GetNumFaces)(THIS) PURE; + + // Sets the Minimum/Maximum intersection distances, this can be used to control + // maximum distance that objects can shadow/reflect light, and help with "bad" + // art that might have near features that you don't want to shadow. This does not + // apply for GPU simulations. + // fMin - minimum intersection distance, must be positive and less than fMax + // fMax - maximum intersection distance, if 0.0f use the previous value, otherwise + // must be strictly greater than fMin + STDMETHOD(SetMinMaxIntersection)(THIS_ FLOAT fMin, FLOAT fMax) PURE; + + // This will subdivide faces on a mesh so that adaptively simulations can + // use a more conservative threshold (it won't miss features.) + // MinEdgeLength - minimum edge length that will be generated, if 0.0f a + // reasonable default will be used + // MaxSubdiv - maximum level of subdivision, if 0 is specified a default + // value will be used (5) + STDMETHOD(RobustMeshRefine)(THIS_ FLOAT MinEdgeLength, UINT MaxSubdiv) PURE; + + // This sets to sampling information used by the simulator. Adaptive sampling + // parameters are currently ignored. + // NumRays - number of rays to shoot per sample + // UseSphere - if TRUE uses spherical samples, otherwise samples over + // the hemisphere. Should only be used with GPU and Vol computations + // UseCosine - if TRUE uses a cosine weighting - not used for Vol computations + // or if only the visiblity function is desired + // Adaptive - if TRUE adaptive sampling (angular) is used + // AdaptiveThresh - threshold used to terminate adaptive angular sampling + // ignored if adaptive sampling is not set + STDMETHOD(SetSamplingInfo)(THIS_ UINT NumRays, + BOOL UseSphere, + BOOL UseCosine, + BOOL Adaptive, + FLOAT AdaptiveThresh) PURE; + + // Methods that compute the direct lighting contribution for objects + // always represente light using spherical harmonics (SH) + // the albedo is not multiplied by the signal - it just integrates + // incoming light. If NumChannels is not 1 the vector is replicated + // + // SHOrder - order of SH to use + // pDataOut - PRT buffer that is generated. Can be single channel + STDMETHOD(ComputeDirectLightingSH)(THIS_ UINT SHOrder, + LPD3DXPRTBUFFER pDataOut) PURE; + + // Adaptive variant of above function. This will refine the mesh + // generating new vertices/faces to approximate the PRT signal + // more faithfully. + // SHOrder - order of SH to use + // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error) + // if value is less then 1e-6f, 1e-6f is specified + // MinEdgeLength - minimum edge length that will be generated + // if value is too small a fairly conservative model dependent value + // is used + // MaxSubdiv - maximum subdivision level, if 0 is specified it + // will default to 4 + // pDataOut - PRT buffer that is generated. Can be single channel. + STDMETHOD(ComputeDirectLightingSHAdaptive)(THIS_ UINT SHOrder, + FLOAT AdaptiveThresh, + FLOAT MinEdgeLength, + UINT MaxSubdiv, + LPD3DXPRTBUFFER pDataOut) PURE; + + // Function that computes the direct lighting contribution for objects + // light is always represented using spherical harmonics (SH) + // This is done on the GPU and is much faster then using the CPU. + // The albedo is not multiplied by the signal - it just integrates + // incoming light. If NumChannels is not 1 the vector is replicated. + // ZBias/ZAngleBias are akin to parameters used with shadow zbuffers. + // A reasonable default for both values is 0.005, but the user should + // experiment (ZAngleBias can be zero, ZBias should not be.) + // Callbacks should not use the Direct3D9Device the simulator is using. + // SetSamplingInfo must be called with TRUE for UseSphere and + // FALSE for UseCosine before this method is called. + // + // pD3DDevice - device used to run GPU simulator - must support PS2.0 + // and FP render targets + // Flags - parameters for the GPU simulator, combination of one or more + // D3DXSHGPUSIMOPT flags. Only one SHADOWRES setting should be set and + // the defaults is 512 + // SHOrder - order of SH to use + // ZBias - bias in normal direction (for depth test) + // ZAngleBias - scaled by one minus cosine of angle with light (offset in depth) + // pDataOut - PRT buffer that is filled in. Can be single channel + STDMETHOD(ComputeDirectLightingSHGPU)(THIS_ LPDIRECT3DDEVICE9 pD3DDevice, + UINT Flags, + UINT SHOrder, + FLOAT ZBias, + FLOAT ZAngleBias, + LPD3DXPRTBUFFER pDataOut) PURE; + + + // Functions that computes subsurface scattering (using material properties) + // Albedo is not multiplied by result. This only works for per-vertex data + // use ResampleBuffer to move per-vertex data into a texture and back. + // + // pDataIn - input data (previous bounce) + // pDataOut - result of subsurface scattering simulation + // pDataTotal - [optional] results can be summed into this buffer + STDMETHOD(ComputeSS)(THIS_ LPD3DXPRTBUFFER pDataIn, + LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal) PURE; + + // Adaptive version of ComputeSS. + // + // pDataIn - input data (previous bounce) + // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error) + // if value is less then 1e-6f, 1e-6f is specified + // MinEdgeLength - minimum edge length that will be generated + // if value is too small a fairly conservative model dependent value + // is used + // MaxSubdiv - maximum subdivision level, if 0 is specified it + // will default to 4 + // pDataOut - result of subsurface scattering simulation + // pDataTotal - [optional] results can be summed into this buffer + STDMETHOD(ComputeSSAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn, + FLOAT AdaptiveThresh, + FLOAT MinEdgeLength, + UINT MaxSubdiv, + LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal) PURE; + + // computes a single bounce of inter-reflected light + // works for SH based PRT or generic lighting + // Albedo is not multiplied by result + // + // pDataIn - previous bounces data + // pDataOut - PRT buffer that is generated + // pDataTotal - [optional] can be used to keep a running sum + STDMETHOD(ComputeBounce)(THIS_ LPD3DXPRTBUFFER pDataIn, + LPD3DXPRTBUFFER pDataOut, + LPD3DXPRTBUFFER pDataTotal) PURE; + + // Adaptive version of above function. + // + // pDataIn - previous bounces data, can be single channel + // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error) + // if value is less then 1e-6f, 1e-6f is specified + // MinEdgeLength - minimum edge length that will be generated + // if value is too small a fairly conservative model dependent value + // is used + // MaxSubdiv - maximum subdivision level, if 0 is specified it + // will default to 4 + // pDataOut - PRT buffer that is generated + // pDataTotal - [optional] can be used to keep a running sum + STDMETHOD(ComputeBounceAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn, + FLOAT AdaptiveThresh, + FLOAT MinEdgeLength, + UINT MaxSubdiv, + LPD3DXPRTBUFFER pDataOut, + LPD3DXPRTBUFFER pDataTotal) PURE; + + // Computes projection of distant SH radiance into a local SH radiance + // function. This models how direct lighting is attenuated by the + // scene and is a form of "neighborhood transfer." The result is + // a linear operator (matrix) at every sample point, if you multiply + // this matrix by the distant SH lighting coefficients you get an + // approximation of the local incident radiance function from + // direct lighting. These resulting lighting coefficients can + // than be projected into another basis or used with any rendering + // technique that uses spherical harmonics as input. + // SetSamplingInfo must be called with TRUE for UseSphere and + // FALSE for UseCosine before this method is called. + // Generates SHOrderIn*SHOrderIn*SHOrderOut*SHOrderOut scalars + // per channel at each sample location. + // + // SHOrderIn - Order of the SH representation of distant lighting + // SHOrderOut - Order of the SH representation of local lighting + // NumVolSamples - Number of sample locations + // pSampleLocs - position of sample locations + // pDataOut - PRT Buffer that will store output results + STDMETHOD(ComputeVolumeSamplesDirectSH)(THIS_ UINT SHOrderIn, + UINT SHOrderOut, + UINT NumVolSamples, + CONST D3DXVECTOR3 *pSampleLocs, + LPD3DXPRTBUFFER pDataOut) PURE; + + // At each sample location computes a linear operator (matrix) that maps + // the representation of source radiance (NumCoeffs in pSurfDataIn) + // into a local incident radiance function approximated with spherical + // harmonics. For example if a light map data is specified in pSurfDataIn + // the result is an SH representation of the flow of light at each sample + // point. If PRT data for an outdoor scene is used, each sample point + // contains a matrix that models how distant lighting bounces of the objects + // in the scene and arrives at the given sample point. Combined with + // ComputeVolumeSamplesDirectSH this gives the complete representation for + // how light arrives at each sample point parameterized by distant lighting. + // SetSamplingInfo must be called with TRUE for UseSphere and + // FALSE for UseCosine before this method is called. + // Generates pSurfDataIn->NumCoeffs()*SHOrder*SHOrder scalars + // per channel at each sample location. + // + // pSurfDataIn - previous bounce data + // SHOrder - order of SH to generate projection with + // NumVolSamples - Number of sample locations + // pSampleLocs - position of sample locations + // pDataOut - PRT Buffer that will store output results + STDMETHOD(ComputeVolumeSamples)(THIS_ LPD3DXPRTBUFFER pSurfDataIn, + UINT SHOrder, + UINT NumVolSamples, + CONST D3DXVECTOR3 *pSampleLocs, + LPD3DXPRTBUFFER pDataOut) PURE; + + // Computes direct lighting (SH) for a point not on the mesh + // with a given normal - cannot use texture buffers. + // + // SHOrder - order of SH to use + // NumSamples - number of sample locations + // pSampleLocs - position for each sample + // pSampleNorms - normal for each sample + // pDataOut - PRT Buffer that will store output results + STDMETHOD(ComputeSurfSamplesDirectSH)(THIS_ UINT SHOrder, + UINT NumSamples, + CONST D3DXVECTOR3 *pSampleLocs, + CONST D3DXVECTOR3 *pSampleNorms, + LPD3DXPRTBUFFER pDataOut) PURE; + + + // given the solution for PRT or light maps, computes transfer vector at arbitrary + // position/normal pairs in space + // + // pSurfDataIn - input data + // NumSamples - number of sample locations + // pSampleLocs - position for each sample + // pSampleNorms - normal for each sample + // pDataOut - PRT Buffer that will store output results + // pDataTotal - optional buffer to sum results into - can be NULL + STDMETHOD(ComputeSurfSamplesBounce)(THIS_ LPD3DXPRTBUFFER pSurfDataIn, + UINT NumSamples, + CONST D3DXVECTOR3 *pSampleLocs, + CONST D3DXVECTOR3 *pSampleNorms, + LPD3DXPRTBUFFER pDataOut, + LPD3DXPRTBUFFER pDataTotal) PURE; + + // Frees temporary data structures that can be created for subsurface scattering + // this data is freed when the PRTComputeEngine is freed and is lazily created + STDMETHOD(FreeSSData)(THIS) PURE; + + // Frees temporary data structures that can be created for bounce simulations + // this data is freed when the PRTComputeEngine is freed and is lazily created + STDMETHOD(FreeBounceData)(THIS) PURE; + + // This computes the Local Deformable PRT (LDPRT) coefficients relative to the + // per sample normals that minimize error in a least squares sense with respect + // to the input PRT data set. These coefficients can be used with skinned/transformed + // normals to model global effects with dynamic objects. Shading normals can + // optionally be solved for - these normals (along with the LDPRT coefficients) can + // more accurately represent the PRT signal. The coefficients are for zonal + // harmonics oriented in the normal/shading normal direction. + // + // pDataIn - SH PRT dataset that is input + // SHOrder - Order of SH to compute conv coefficients for + // pNormOut - Optional array of vectors (passed in) that will be filled with + // "shading normals", LDPRT coefficients are optimized for + // these normals. This array must be the same size as the number of + // samples in pDataIn + // pDataOut - Output buffer (SHOrder zonal harmonic coefficients per channel per sample) + STDMETHOD(ComputeLDPRTCoeffs)(THIS_ LPD3DXPRTBUFFER pDataIn, + UINT SHOrder, + D3DXVECTOR3 *pNormOut, + LPD3DXPRTBUFFER pDataOut) PURE; + + // scales all the samples associated with a given sub mesh + // can be useful when using subsurface scattering + // fScale - value to scale each vector in submesh by + STDMETHOD(ScaleMeshChunk)(THIS_ UINT uMeshChunk, FLOAT fScale, LPD3DXPRTBUFFER pDataOut) PURE; + + // mutliplies each PRT vector by the albedo - can be used if you want to have the albedo + // burned into the dataset, often better not to do this. If this is not done the user + // must mutliply the albedo themselves when rendering - just multiply the albedo times + // the result of the PRT dot product. + // If pDataOut is a texture simulation result and there is an albedo texture it + // must be represented at the same resolution as the simulation buffer. You can use + // LoadSurfaceFromSurface and set a new albedo texture if this is an issue - but must + // be careful about how the gutters are handled. + // + // pDataOut - dataset that will get albedo pushed into it + STDMETHOD(MultiplyAlbedo)(THIS_ LPD3DXPRTBUFFER pDataOut) PURE; + + // Sets a pointer to an optional call back function that reports back to the + // user percentage done and gives them the option of quitting + // pCB - pointer to call back function, return S_OK for the simulation + // to continue + // Frequency - 1/Frequency is roughly the number of times the call back + // will be invoked + // lpUserContext - will be passed back to the users call back + STDMETHOD(SetCallBack)(THIS_ LPD3DXSHPRTSIMCB pCB, FLOAT Frequency, LPVOID lpUserContext) PURE; + + // Returns TRUE if the ray intersects the mesh, FALSE if it does not. This function + // takes into account settings from SetMinMaxIntersection. If the closest intersection + // is not needed this function is more efficient compared to the ClosestRayIntersection + // method. + // pRayPos - origin of ray + // pRayDir - normalized ray direction (normalization required for SetMinMax to be meaningful) + + STDMETHOD_(BOOL, ShadowRayIntersects)(THIS_ CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir) PURE; + + // Returns TRUE if the ray intersects the mesh, FALSE if it does not. If there is an + // intersection the closest face that was intersected and its first two barycentric coordinates + // are returned. This function takes into account settings from SetMinMaxIntersection. + // This is a slower function compared to ShadowRayIntersects and should only be used where + // needed. The third vertices barycentric coordinates will be 1 - pU - pV. + // pRayPos - origin of ray + // pRayDir - normalized ray direction (normalization required for SetMinMax to be meaningful) + // pFaceIndex - Closest face that intersects. This index is based on stacking the pBlockerMesh + // faces before the faces from pMesh + // pU - Barycentric coordinate for vertex 0 + // pV - Barycentric coordinate for vertex 1 + // pDist - Distance along ray where the intersection occured + + STDMETHOD_(BOOL, ClosestRayIntersects)(THIS_ CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir, + DWORD *pFaceIndex, FLOAT *pU, FLOAT *pV, FLOAT *pDist) PURE; +}; + + +// API functions for creating interfaces + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +//============================================================================ +// +// D3DXCreatePRTBuffer: +// -------------------- +// Generates a PRT Buffer that can be compressed or filled by a simulator +// This function should be used to create per-vertex or volume buffers. +// When buffers are created all values are initialized to zero. +// +// Parameters: +// NumSamples +// Number of sample locations represented +// NumCoeffs +// Number of coefficients per sample location (order^2 for SH) +// NumChannels +// Number of color channels to represent (1 or 3) +// ppBuffer +// Buffer that will be allocated +// +//============================================================================ + +HRESULT WINAPI + D3DXCreatePRTBuffer( + UINT NumSamples, + UINT NumCoeffs, + UINT NumChannels, + LPD3DXPRTBUFFER* ppBuffer); + +//============================================================================ +// +// D3DXCreatePRTBufferTex: +// -------------------- +// Generates a PRT Buffer that can be compressed or filled by a simulator +// This function should be used to create per-pixel buffers. +// When buffers are created all values are initialized to zero. +// +// Parameters: +// Width +// Width of texture +// Height +// Height of texture +// NumCoeffs +// Number of coefficients per sample location (order^2 for SH) +// NumChannels +// Number of color channels to represent (1 or 3) +// ppBuffer +// Buffer that will be allocated +// +//============================================================================ + +HRESULT WINAPI + D3DXCreatePRTBufferTex( + UINT Width, + UINT Height, + UINT NumCoeffs, + UINT NumChannels, + LPD3DXPRTBUFFER* ppBuffer); + +//============================================================================ +// +// D3DXLoadPRTBufferFromFile: +// -------------------- +// Loads a PRT buffer that has been saved to disk. +// +// Parameters: +// pFilename +// Name of the file to load +// ppBuffer +// Buffer that will be allocated +// +//============================================================================ + +HRESULT WINAPI + D3DXLoadPRTBufferFromFileA( + LPCSTR pFilename, + LPD3DXPRTBUFFER* ppBuffer); + +HRESULT WINAPI + D3DXLoadPRTBufferFromFileW( + LPCWSTR pFilename, + LPD3DXPRTBUFFER* ppBuffer); + +#ifdef UNICODE +#define D3DXLoadPRTBufferFromFile D3DXLoadPRTBufferFromFileW +#else +#define D3DXLoadPRTBufferFromFile D3DXLoadPRTBufferFromFileA +#endif + + +//============================================================================ +// +// D3DXSavePRTBufferToFile: +// -------------------- +// Saves a PRTBuffer to disk. +// +// Parameters: +// pFilename +// Name of the file to save +// pBuffer +// Buffer that will be saved +// +//============================================================================ + +HRESULT WINAPI + D3DXSavePRTBufferToFileA( + LPCSTR pFileName, + LPD3DXPRTBUFFER pBuffer); + +HRESULT WINAPI + D3DXSavePRTBufferToFileW( + LPCWSTR pFileName, + LPD3DXPRTBUFFER pBuffer); + +#ifdef UNICODE +#define D3DXSavePRTBufferToFile D3DXSavePRTBufferToFileW +#else +#define D3DXSavePRTBufferToFile D3DXSavePRTBufferToFileA +#endif + + +//============================================================================ +// +// D3DXLoadPRTCompBufferFromFile: +// -------------------- +// Loads a PRTComp buffer that has been saved to disk. +// +// Parameters: +// pFilename +// Name of the file to load +// ppBuffer +// Buffer that will be allocated +// +//============================================================================ + +HRESULT WINAPI + D3DXLoadPRTCompBufferFromFileA( + LPCSTR pFilename, + LPD3DXPRTCOMPBUFFER* ppBuffer); + +HRESULT WINAPI + D3DXLoadPRTCompBufferFromFileW( + LPCWSTR pFilename, + LPD3DXPRTCOMPBUFFER* ppBuffer); + +#ifdef UNICODE +#define D3DXLoadPRTCompBufferFromFile D3DXLoadPRTCompBufferFromFileW +#else +#define D3DXLoadPRTCompBufferFromFile D3DXLoadPRTCompBufferFromFileA +#endif + +//============================================================================ +// +// D3DXSavePRTCompBufferToFile: +// -------------------- +// Saves a PRTCompBuffer to disk. +// +// Parameters: +// pFilename +// Name of the file to save +// pBuffer +// Buffer that will be saved +// +//============================================================================ + +HRESULT WINAPI + D3DXSavePRTCompBufferToFileA( + LPCSTR pFileName, + LPD3DXPRTCOMPBUFFER pBuffer); + +HRESULT WINAPI + D3DXSavePRTCompBufferToFileW( + LPCWSTR pFileName, + LPD3DXPRTCOMPBUFFER pBuffer); + +#ifdef UNICODE +#define D3DXSavePRTCompBufferToFile D3DXSavePRTCompBufferToFileW +#else +#define D3DXSavePRTCompBufferToFile D3DXSavePRTCompBufferToFileA +#endif + +//============================================================================ +// +// D3DXCreatePRTCompBuffer: +// -------------------- +// Compresses a PRT buffer (vertex or texel) +// +// Parameters: +// D3DXSHCOMPRESSQUALITYTYPE +// Quality of compression - low is faster (computes PCA per voronoi cluster) +// high is slower but better quality (clusters based on distance to affine subspace) +// NumClusters +// Number of clusters to compute +// NumPCA +// Number of basis vectors to compute +// pCB +// Optional Callback function +// lpUserContext +// Optional user context +// pBufferIn +// Buffer that will be compressed +// ppBufferOut +// Compressed buffer that will be created +// +//============================================================================ + + +HRESULT WINAPI + D3DXCreatePRTCompBuffer( + D3DXSHCOMPRESSQUALITYTYPE Quality, + UINT NumClusters, + UINT NumPCA, + LPD3DXSHPRTSIMCB pCB, + LPVOID lpUserContext, + LPD3DXPRTBUFFER pBufferIn, + LPD3DXPRTCOMPBUFFER *ppBufferOut + ); + +//============================================================================ +// +// D3DXCreateTextureGutterHelper: +// -------------------- +// Generates a "GutterHelper" for a given set of meshes and texture +// resolution +// +// Parameters: +// Width +// Width of texture +// Height +// Height of texture +// pMesh +// Mesh that represents the scene +// GutterSize +// Number of texels to over rasterize in texture space +// this should be at least 1.0 +// ppBuffer +// GutterHelper that will be created +// +//============================================================================ + + +HRESULT WINAPI + D3DXCreateTextureGutterHelper( + UINT Width, + UINT Height, + LPD3DXMESH pMesh, + FLOAT GutterSize, + LPD3DXTEXTUREGUTTERHELPER* ppBuffer); + + +//============================================================================ +// +// D3DXCreatePRTEngine: +// -------------------- +// Computes a PRTEngine which can efficiently generate PRT simulations +// of a scene +// +// Parameters: +// pMesh +// Mesh that represents the scene - must have an AttributeTable +// where vertices are in a unique attribute. +// pAdjacency +// Optional adjacency information +// ExtractUVs +// Set this to true if textures are going to be used for albedos +// or to store PRT vectors +// pBlockerMesh +// Optional mesh that just blocks the scene +// ppEngine +// PRTEngine that will be created +// +//============================================================================ + + +HRESULT WINAPI + D3DXCreatePRTEngine( + LPD3DXMESH pMesh, + DWORD *pAdjacency, + BOOL ExtractUVs, + LPD3DXMESH pBlockerMesh, + LPD3DXPRTENGINE* ppEngine); + +//============================================================================ +// +// D3DXConcatenateMeshes: +// -------------------- +// Concatenates a group of meshes into one common mesh. This can optionaly transform +// each sub mesh or its texture coordinates. If no DECL is given it will +// generate a union of all of the DECL's of the sub meshes, promoting channels +// and types if neccesary. It will create an AttributeTable if possible, one can +// call OptimizeMesh with attribute sort and compacting enabled to ensure this. +// +// Parameters: +// ppMeshes +// Array of pointers to meshes that can store PRT vectors +// NumMeshes +// Number of meshes +// Options +// Passed through to D3DXCreateMesh +// pGeomXForms +// [optional] Each sub mesh is transformed by the corresponding +// matrix if this array is supplied +// pTextureXForms +// [optional] UV coordinates for each sub mesh are transformed +// by corresponding matrix if supplied +// pDecl +// [optional] Only information in this DECL is used when merging +// data +// pD3DDevice +// D3D device that is used to create the new mesh +// ppMeshOut +// Mesh that will be created +// +//============================================================================ + + +HRESULT WINAPI + D3DXConcatenateMeshes( + LPD3DXMESH *ppMeshes, + UINT NumMeshes, + DWORD Options, + CONST D3DXMATRIX *pGeomXForms, + CONST D3DXMATRIX *pTextureXForms, + CONST D3DVERTEXELEMENT9 *pDecl, + LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXMESH *ppMeshOut); + +//============================================================================ +// +// D3DXSHPRTCompSuperCluster: +// -------------------------- +// Used with compressed results of D3DXSHPRTSimulation. +// Generates "super clusters" - groups of clusters that can be drawn in +// the same draw call. A greedy algorithm that minimizes overdraw is used +// to group the clusters. +// +// Parameters: +// pClusterIDs +// NumVerts cluster ID's (extracted from a compressed buffer) +// pScene +// Mesh that represents composite scene passed to the simulator +// MaxNumClusters +// Maximum number of clusters allocated per super cluster +// NumClusters +// Number of clusters computed in the simulator +// pSuperClusterIDs +// Array of length NumClusters, contains index of super cluster +// that corresponding cluster was assigned to +// pNumSuperClusters +// Returns the number of super clusters allocated +// +//============================================================================ + +HRESULT WINAPI + D3DXSHPRTCompSuperCluster( + UINT *pClusterIDs, + LPD3DXMESH pScene, + UINT MaxNumClusters, + UINT NumClusters, + UINT *pSuperClusterIDs, + UINT *pNumSuperClusters); + +//============================================================================ +// +// D3DXSHPRTCompSplitMeshSC: +// ------------------------- +// Used with compressed results of the vertex version of the PRT simulator. +// After D3DXSHRTCompSuperCluster has been called this function can be used +// to split the mesh into a group of faces/vertices per super cluster. +// Each super cluster contains all of the faces that contain any vertex +// classified in one of its clusters. All of the vertices connected to this +// set of faces are also included with the returned array ppVertStatus +// indicating whether or not the vertex belongs to the supercluster. +// +// Parameters: +// pClusterIDs +// NumVerts cluster ID's (extracted from a compressed buffer) +// NumVertices +// Number of vertices in original mesh +// NumClusters +// Number of clusters (input parameter to compression) +// pSuperClusterIDs +// Array of size NumClusters that will contain super cluster ID's (from +// D3DXSHCompSuerCluster) +// NumSuperClusters +// Number of superclusters allocated in D3DXSHCompSuerCluster +// pInputIB +// Raw index buffer for mesh - format depends on bInputIBIs32Bit +// InputIBIs32Bit +// Indicates whether the input index buffer is 32-bit (otherwise 16-bit +// is assumed) +// NumFaces +// Number of faces in the original mesh (pInputIB is 3 times this length) +// ppIBData +// LPD3DXBUFFER holds raw index buffer that will contain the resulting split faces. +// Format determined by bIBIs32Bit. Allocated by function +// pIBDataLength +// Length of ppIBData, assigned in function +// OutputIBIs32Bit +// Indicates whether the output index buffer is to be 32-bit (otherwise +// 16-bit is assumed) +// ppFaceRemap +// LPD3DXBUFFER mapping of each face in ppIBData to original faces. Length is +// *pIBDataLength/3. Optional paramter, allocated in function +// ppVertData +// LPD3DXBUFFER contains new vertex data structure. Size of pVertDataLength +// pVertDataLength +// Number of new vertices in split mesh. Assigned in function +// pSCClusterList +// Array of length NumClusters which pSCData indexes into (Cluster* fields) +// for each SC, contains clusters sorted by super cluster +// pSCData +// Structure per super cluster - contains indices into ppIBData, +// pSCClusterList and ppVertData +// +//============================================================================ + +HRESULT WINAPI + D3DXSHPRTCompSplitMeshSC( + UINT *pClusterIDs, + UINT NumVertices, + UINT NumClusters, + UINT *pSuperClusterIDs, + UINT NumSuperClusters, + LPVOID pInputIB, + BOOL InputIBIs32Bit, + UINT NumFaces, + LPD3DXBUFFER *ppIBData, + UINT *pIBDataLength, + BOOL OutputIBIs32Bit, + LPD3DXBUFFER *ppFaceRemap, + LPD3DXBUFFER *ppVertData, + UINT *pVertDataLength, + UINT *pSCClusterList, + D3DXSHPRTSPLITMESHCLUSTERDATA *pSCData); + + +#ifdef __cplusplus +} +#endif //__cplusplus + +////////////////////////////////////////////////////////////////////////////// +// +// Definitions of .X file templates used by mesh load/save functions +// that are not RM standard +// +////////////////////////////////////////////////////////////////////////////// + +// {3CF169CE-FF7C-44ab-93C0-F78F62D172E2} +DEFINE_GUID(DXFILEOBJ_XSkinMeshHeader, +0x3cf169ce, 0xff7c, 0x44ab, 0x93, 0xc0, 0xf7, 0x8f, 0x62, 0xd1, 0x72, 0xe2); + +// {B8D65549-D7C9-4995-89CF-53A9A8B031E3} +DEFINE_GUID(DXFILEOBJ_VertexDuplicationIndices, +0xb8d65549, 0xd7c9, 0x4995, 0x89, 0xcf, 0x53, 0xa9, 0xa8, 0xb0, 0x31, 0xe3); + +// {A64C844A-E282-4756-8B80-250CDE04398C} +DEFINE_GUID(DXFILEOBJ_FaceAdjacency, +0xa64c844a, 0xe282, 0x4756, 0x8b, 0x80, 0x25, 0xc, 0xde, 0x4, 0x39, 0x8c); + +// {6F0D123B-BAD2-4167-A0D0-80224F25FABB} +DEFINE_GUID(DXFILEOBJ_SkinWeights, +0x6f0d123b, 0xbad2, 0x4167, 0xa0, 0xd0, 0x80, 0x22, 0x4f, 0x25, 0xfa, 0xbb); + +// {A3EB5D44-FC22-429d-9AFB-3221CB9719A6} +DEFINE_GUID(DXFILEOBJ_Patch, +0xa3eb5d44, 0xfc22, 0x429d, 0x9a, 0xfb, 0x32, 0x21, 0xcb, 0x97, 0x19, 0xa6); + +// {D02C95CC-EDBA-4305-9B5D-1820D7704BBF} +DEFINE_GUID(DXFILEOBJ_PatchMesh, +0xd02c95cc, 0xedba, 0x4305, 0x9b, 0x5d, 0x18, 0x20, 0xd7, 0x70, 0x4b, 0xbf); + +// {B9EC94E1-B9A6-4251-BA18-94893F02C0EA} +DEFINE_GUID(DXFILEOBJ_PatchMesh9, +0xb9ec94e1, 0xb9a6, 0x4251, 0xba, 0x18, 0x94, 0x89, 0x3f, 0x2, 0xc0, 0xea); + +// {B6C3E656-EC8B-4b92-9B62-681659522947} +DEFINE_GUID(DXFILEOBJ_PMInfo, +0xb6c3e656, 0xec8b, 0x4b92, 0x9b, 0x62, 0x68, 0x16, 0x59, 0x52, 0x29, 0x47); + +// {917E0427-C61E-4a14-9C64-AFE65F9E9844} +DEFINE_GUID(DXFILEOBJ_PMAttributeRange, +0x917e0427, 0xc61e, 0x4a14, 0x9c, 0x64, 0xaf, 0xe6, 0x5f, 0x9e, 0x98, 0x44); + +// {574CCC14-F0B3-4333-822D-93E8A8A08E4C} +DEFINE_GUID(DXFILEOBJ_PMVSplitRecord, +0x574ccc14, 0xf0b3, 0x4333, 0x82, 0x2d, 0x93, 0xe8, 0xa8, 0xa0, 0x8e, 0x4c); + +// {B6E70A0E-8EF9-4e83-94AD-ECC8B0C04897} +DEFINE_GUID(DXFILEOBJ_FVFData, +0xb6e70a0e, 0x8ef9, 0x4e83, 0x94, 0xad, 0xec, 0xc8, 0xb0, 0xc0, 0x48, 0x97); + +// {F752461C-1E23-48f6-B9F8-8350850F336F} +DEFINE_GUID(DXFILEOBJ_VertexElement, +0xf752461c, 0x1e23, 0x48f6, 0xb9, 0xf8, 0x83, 0x50, 0x85, 0xf, 0x33, 0x6f); + +// {BF22E553-292C-4781-9FEA-62BD554BDD93} +DEFINE_GUID(DXFILEOBJ_DeclData, +0xbf22e553, 0x292c, 0x4781, 0x9f, 0xea, 0x62, 0xbd, 0x55, 0x4b, 0xdd, 0x93); + +// {F1CFE2B3-0DE3-4e28-AFA1-155A750A282D} +DEFINE_GUID(DXFILEOBJ_EffectFloats, +0xf1cfe2b3, 0xde3, 0x4e28, 0xaf, 0xa1, 0x15, 0x5a, 0x75, 0xa, 0x28, 0x2d); + +// {D55B097E-BDB6-4c52-B03D-6051C89D0E42} +DEFINE_GUID(DXFILEOBJ_EffectString, +0xd55b097e, 0xbdb6, 0x4c52, 0xb0, 0x3d, 0x60, 0x51, 0xc8, 0x9d, 0xe, 0x42); + +// {622C0ED0-956E-4da9-908A-2AF94F3CE716} +DEFINE_GUID(DXFILEOBJ_EffectDWord, +0x622c0ed0, 0x956e, 0x4da9, 0x90, 0x8a, 0x2a, 0xf9, 0x4f, 0x3c, 0xe7, 0x16); + +// {3014B9A0-62F5-478c-9B86-E4AC9F4E418B} +DEFINE_GUID(DXFILEOBJ_EffectParamFloats, +0x3014b9a0, 0x62f5, 0x478c, 0x9b, 0x86, 0xe4, 0xac, 0x9f, 0x4e, 0x41, 0x8b); + +// {1DBC4C88-94C1-46ee-9076-2C28818C9481} +DEFINE_GUID(DXFILEOBJ_EffectParamString, +0x1dbc4c88, 0x94c1, 0x46ee, 0x90, 0x76, 0x2c, 0x28, 0x81, 0x8c, 0x94, 0x81); + +// {E13963BC-AE51-4c5d-B00F-CFA3A9D97CE5} +DEFINE_GUID(DXFILEOBJ_EffectParamDWord, +0xe13963bc, 0xae51, 0x4c5d, 0xb0, 0xf, 0xcf, 0xa3, 0xa9, 0xd9, 0x7c, 0xe5); + +// {E331F7E4-0559-4cc2-8E99-1CEC1657928F} +DEFINE_GUID(DXFILEOBJ_EffectInstance, +0xe331f7e4, 0x559, 0x4cc2, 0x8e, 0x99, 0x1c, 0xec, 0x16, 0x57, 0x92, 0x8f); + +// {9E415A43-7BA6-4a73-8743-B73D47E88476} +DEFINE_GUID(DXFILEOBJ_AnimTicksPerSecond, +0x9e415a43, 0x7ba6, 0x4a73, 0x87, 0x43, 0xb7, 0x3d, 0x47, 0xe8, 0x84, 0x76); + +// {7F9B00B3-F125-4890-876E-1CFFBF697C4D} +DEFINE_GUID(DXFILEOBJ_CompressedAnimationSet, +0x7f9b00b3, 0xf125, 0x4890, 0x87, 0x6e, 0x1c, 0x42, 0xbf, 0x69, 0x7c, 0x4d); + +#pragma pack(push, 1) +typedef struct _XFILECOMPRESSEDANIMATIONSET +{ + DWORD CompressedBlockSize; + FLOAT TicksPerSec; + DWORD PlaybackType; + DWORD BufferLength; +} XFILECOMPRESSEDANIMATIONSET; +#pragma pack(pop) + +#define XSKINEXP_TEMPLATES \ + "xof 0303txt 0032\ + template XSkinMeshHeader \ + { \ + <3CF169CE-FF7C-44ab-93C0-F78F62D172E2> \ + WORD nMaxSkinWeightsPerVertex; \ + WORD nMaxSkinWeightsPerFace; \ + WORD nBones; \ + } \ + template VertexDuplicationIndices \ + { \ + \ + DWORD nIndices; \ + DWORD nOriginalVertices; \ + array DWORD indices[nIndices]; \ + } \ + template FaceAdjacency \ + { \ + \ + DWORD nIndices; \ + array DWORD indices[nIndices]; \ + } \ + template SkinWeights \ + { \ + <6F0D123B-BAD2-4167-A0D0-80224F25FABB> \ + STRING transformNodeName; \ + DWORD nWeights; \ + array DWORD vertexIndices[nWeights]; \ + array float weights[nWeights]; \ + Matrix4x4 matrixOffset; \ + } \ + template Patch \ + { \ + \ + DWORD nControlIndices; \ + array DWORD controlIndices[nControlIndices]; \ + } \ + template PatchMesh \ + { \ + \ + DWORD nVertices; \ + array Vector vertices[nVertices]; \ + DWORD nPatches; \ + array Patch patches[nPatches]; \ + [ ... ] \ + } \ + template PatchMesh9 \ + { \ + \ + DWORD Type; \ + DWORD Degree; \ + DWORD Basis; \ + DWORD nVertices; \ + array Vector vertices[nVertices]; \ + DWORD nPatches; \ + array Patch patches[nPatches]; \ + [ ... ] \ + } " \ + "template EffectFloats \ + { \ + \ + DWORD nFloats; \ + array float Floats[nFloats]; \ + } \ + template EffectString \ + { \ + \ + STRING Value; \ + } \ + template EffectDWord \ + { \ + <622C0ED0-956E-4da9-908A-2AF94F3CE716> \ + DWORD Value; \ + } " \ + "template EffectParamFloats \ + { \ + <3014B9A0-62F5-478c-9B86-E4AC9F4E418B> \ + STRING ParamName; \ + DWORD nFloats; \ + array float Floats[nFloats]; \ + } " \ + "template EffectParamString \ + { \ + <1DBC4C88-94C1-46ee-9076-2C28818C9481> \ + STRING ParamName; \ + STRING Value; \ + } \ + template EffectParamDWord \ + { \ + \ + STRING ParamName; \ + DWORD Value; \ + } \ + template EffectInstance \ + { \ + \ + STRING EffectFilename; \ + [ ... ] \ + } " \ + "template AnimTicksPerSecond \ + { \ + <9E415A43-7BA6-4a73-8743-B73D47E88476> \ + DWORD AnimTicksPerSecond; \ + } \ + template CompressedAnimationSet \ + { \ + <7F9B00B3-F125-4890-876E-1C42BF697C4D> \ + DWORD CompressedBlockSize; \ + FLOAT TicksPerSec; \ + DWORD PlaybackType; \ + DWORD BufferLength; \ + array DWORD CompressedData[BufferLength]; \ + } " + +#define XEXTENSIONS_TEMPLATES \ + "xof 0303txt 0032\ + template FVFData \ + { \ + \ + DWORD dwFVF; \ + DWORD nDWords; \ + array DWORD data[nDWords]; \ + } \ + template VertexElement \ + { \ + \ + DWORD Type; \ + DWORD Method; \ + DWORD Usage; \ + DWORD UsageIndex; \ + } \ + template DeclData \ + { \ + \ + DWORD nElements; \ + array VertexElement Elements[nElements]; \ + DWORD nDWords; \ + array DWORD data[nDWords]; \ + } \ + template PMAttributeRange \ + { \ + <917E0427-C61E-4a14-9C64-AFE65F9E9844> \ + DWORD iFaceOffset; \ + DWORD nFacesMin; \ + DWORD nFacesMax; \ + DWORD iVertexOffset; \ + DWORD nVerticesMin; \ + DWORD nVerticesMax; \ + } \ + template PMVSplitRecord \ + { \ + <574CCC14-F0B3-4333-822D-93E8A8A08E4C> \ + DWORD iFaceCLW; \ + DWORD iVlrOffset; \ + DWORD iCode; \ + } \ + template PMInfo \ + { \ + \ + DWORD nAttributes; \ + array PMAttributeRange attributeRanges[nAttributes]; \ + DWORD nMaxValence; \ + DWORD nMinLogicalVertices; \ + DWORD nMaxLogicalVertices; \ + DWORD nVSplits; \ + array PMVSplitRecord splitRecords[nVSplits]; \ + DWORD nAttributeMispredicts; \ + array DWORD attributeMispredicts[nAttributeMispredicts]; \ + } " + +#endif //__D3DX9MESH_H__ + + diff --git a/src/dep/include/DXSDK/include/d3dx9shader.h b/src/dep/include/DXSDK/include/d3dx9shader.h index c57cd23..f84d75e 100644 --- a/src/dep/include/DXSDK/include/d3dx9shader.h +++ b/src/dep/include/DXSDK/include/d3dx9shader.h @@ -1,1161 +1,1161 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// File: d3dx9shader.h -// Content: D3DX Shader APIs -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx9.h" - -#ifndef __D3DX9SHADER_H__ -#define __D3DX9SHADER_H__ - - -//--------------------------------------------------------------------------- -// D3DXTX_VERSION: -// -------------- -// Version token used to create a procedural texture filler in effects -// Used by D3DXFill[]TX functions -//--------------------------------------------------------------------------- -#define D3DXTX_VERSION(_Major,_Minor) (('T' << 24) | ('X' << 16) | ((_Major) << 8) | (_Minor)) - - - -//---------------------------------------------------------------------------- -// D3DXSHADER flags: -// ----------------- -// D3DXSHADER_DEBUG -// Insert debug file/line/type/symbol information. -// -// D3DXSHADER_SKIPVALIDATION -// Do not validate the generated code against known capabilities and -// constraints. This option is only recommended when compiling shaders -// you KNOW will work. (ie. have compiled before without this option.) -// Shaders are always validated by D3D before they are set to the device. -// -// D3DXSHADER_SKIPOPTIMIZATION -// Instructs the compiler to skip optimization steps during code generation. -// Unless you are trying to isolate a problem in your code using this option -// is not recommended. -// -// D3DXSHADER_PACKMATRIX_ROWMAJOR -// Unless explicitly specified, matrices will be packed in row-major order -// on input and output from the shader. -// -// D3DXSHADER_PACKMATRIX_COLUMNMAJOR -// Unless explicitly specified, matrices will be packed in column-major -// order on input and output from the shader. This is generally more -// efficient, since it allows vector-matrix multiplication to be performed -// using a series of dot-products. -// -// D3DXSHADER_PARTIALPRECISION -// Force all computations in resulting shader to occur at partial precision. -// This may result in faster evaluation of shaders on some hardware. -// -// D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT -// Force compiler to compile against the next highest available software -// target for vertex shaders. This flag also turns optimizations off, -// and debugging on. -// -// D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT -// Force compiler to compile against the next highest available software -// target for pixel shaders. This flag also turns optimizations off, -// and debugging on. -// -// D3DXSHADER_NO_PRESHADER -// Disables Preshaders. Using this flag will cause the compiler to not -// pull out static expression for evaluation on the host cpu -// -// D3DXSHADER_AVOID_FLOW_CONTROL -// Hint compiler to avoid flow-control constructs where possible. -// -// D3DXSHADER_PREFER_FLOW_CONTROL -// Hint compiler to prefer flow-control constructs where possible. -// -//---------------------------------------------------------------------------- - -#define D3DXSHADER_DEBUG (1 << 0) -#define D3DXSHADER_SKIPVALIDATION (1 << 1) -#define D3DXSHADER_SKIPOPTIMIZATION (1 << 2) -#define D3DXSHADER_PACKMATRIX_ROWMAJOR (1 << 3) -#define D3DXSHADER_PACKMATRIX_COLUMNMAJOR (1 << 4) -#define D3DXSHADER_PARTIALPRECISION (1 << 5) -#define D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT (1 << 6) -#define D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT (1 << 7) -#define D3DXSHADER_NO_PRESHADER (1 << 8) -#define D3DXSHADER_AVOID_FLOW_CONTROL (1 << 9) -#define D3DXSHADER_PREFER_FLOW_CONTROL (1 << 10) - - - -//---------------------------------------------------------------------------- -// D3DXHANDLE: -// ----------- -// Handle values used to efficiently reference shader and effect parameters. -// Strings can be used as handles. However, handles are not always strings. -//---------------------------------------------------------------------------- - -typedef LPCSTR D3DXHANDLE; -typedef D3DXHANDLE *LPD3DXHANDLE; - - -//---------------------------------------------------------------------------- -// 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; - - -//---------------------------------------------------------------------------- -// D3DXSEMANTIC: -//---------------------------------------------------------------------------- - -typedef struct _D3DXSEMANTIC -{ - UINT Usage; - UINT UsageIndex; - -} D3DXSEMANTIC, *LPD3DXSEMANTIC; - - - -//---------------------------------------------------------------------------- -// D3DXFRAGMENT_DESC: -//---------------------------------------------------------------------------- - -typedef struct _D3DXFRAGMENT_DESC -{ - LPCSTR Name; - DWORD Target; - -} D3DXFRAGMENT_DESC, *LPD3DXFRAGMENT_DESC; - - -//---------------------------------------------------------------------------- -// D3DXREGISTER_SET: -//---------------------------------------------------------------------------- - -typedef enum _D3DXREGISTER_SET -{ - D3DXRS_BOOL, - D3DXRS_INT4, - D3DXRS_FLOAT4, - D3DXRS_SAMPLER, - - // force 32-bit size enum - D3DXRS_FORCE_DWORD = 0x7fffffff - -} D3DXREGISTER_SET, *LPD3DXREGISTER_SET; - - -//---------------------------------------------------------------------------- -// D3DXPARAMETER_CLASS: -//---------------------------------------------------------------------------- - -typedef enum _D3DXPARAMETER_CLASS -{ - D3DXPC_SCALAR, - D3DXPC_VECTOR, - D3DXPC_MATRIX_ROWS, - D3DXPC_MATRIX_COLUMNS, - D3DXPC_OBJECT, - D3DXPC_STRUCT, - - // force 32-bit size enum - D3DXPC_FORCE_DWORD = 0x7fffffff - -} D3DXPARAMETER_CLASS, *LPD3DXPARAMETER_CLASS; - - -//---------------------------------------------------------------------------- -// D3DXPARAMETER_TYPE: -//---------------------------------------------------------------------------- - -typedef enum _D3DXPARAMETER_TYPE -{ - D3DXPT_VOID, - D3DXPT_BOOL, - D3DXPT_INT, - D3DXPT_FLOAT, - D3DXPT_STRING, - D3DXPT_TEXTURE, - D3DXPT_TEXTURE1D, - D3DXPT_TEXTURE2D, - D3DXPT_TEXTURE3D, - D3DXPT_TEXTURECUBE, - D3DXPT_SAMPLER, - D3DXPT_SAMPLER1D, - D3DXPT_SAMPLER2D, - D3DXPT_SAMPLER3D, - D3DXPT_SAMPLERCUBE, - D3DXPT_PIXELSHADER, - D3DXPT_VERTEXSHADER, - D3DXPT_PIXELFRAGMENT, - D3DXPT_VERTEXFRAGMENT, - - // force 32-bit size enum - D3DXPT_FORCE_DWORD = 0x7fffffff - -} D3DXPARAMETER_TYPE, *LPD3DXPARAMETER_TYPE; - - -//---------------------------------------------------------------------------- -// D3DXCONSTANTTABLE_DESC: -//---------------------------------------------------------------------------- - -typedef struct _D3DXCONSTANTTABLE_DESC -{ - LPCSTR Creator; // Creator string - DWORD Version; // Shader version - UINT Constants; // Number of constants - -} D3DXCONSTANTTABLE_DESC, *LPD3DXCONSTANTTABLE_DESC; - - -//---------------------------------------------------------------------------- -// D3DXCONSTANT_DESC: -//---------------------------------------------------------------------------- - -typedef struct _D3DXCONSTANT_DESC -{ - LPCSTR Name; // Constant name - - D3DXREGISTER_SET RegisterSet; // Register set - UINT RegisterIndex; // Register index - UINT RegisterCount; // Number of registers occupied - - D3DXPARAMETER_CLASS Class; // Class - D3DXPARAMETER_TYPE Type; // Component type - - UINT Rows; // Number of rows - UINT Columns; // Number of columns - UINT Elements; // Number of array elements - UINT StructMembers; // Number of structure member sub-parameters - - UINT Bytes; // Data size, in bytes - LPCVOID DefaultValue; // Pointer to default value - -} D3DXCONSTANT_DESC, *LPD3DXCONSTANT_DESC; - - - -//---------------------------------------------------------------------------- -// ID3DXConstantTable: -//---------------------------------------------------------------------------- - -typedef interface ID3DXConstantTable ID3DXConstantTable; -typedef interface ID3DXConstantTable *LPD3DXCONSTANTTABLE; - -// {AB3C758F-093E-4356-B762-4DB18F1B3A01} -DEFINE_GUID(IID_ID3DXConstantTable, -0xab3c758f, 0x93e, 0x4356, 0xb7, 0x62, 0x4d, 0xb1, 0x8f, 0x1b, 0x3a, 0x1); - - -#undef INTERFACE -#define INTERFACE ID3DXConstantTable - -DECLARE_INTERFACE_(ID3DXConstantTable, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // Buffer - STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; - STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; - - // Descs - STDMETHOD(GetDesc)(THIS_ D3DXCONSTANTTABLE_DESC *pDesc) PURE; - STDMETHOD(GetConstantDesc)(THIS_ D3DXHANDLE hConstant, D3DXCONSTANT_DESC *pConstantDesc, UINT *pCount) PURE; - STDMETHOD_(UINT, GetSamplerIndex)(THIS_ D3DXHANDLE hConstant) PURE; - - // Handle operations - STDMETHOD_(D3DXHANDLE, GetConstant)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetConstantByName)(THIS_ D3DXHANDLE hConstant, LPCSTR pName) PURE; - STDMETHOD_(D3DXHANDLE, GetConstantElement)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE; - - // Set Constants - STDMETHOD(SetDefaults)(THIS_ LPDIRECT3DDEVICE9 pDevice) PURE; - STDMETHOD(SetValue)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, LPCVOID pData, UINT Bytes) PURE; - STDMETHOD(SetBool)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, BOOL b) PURE; - STDMETHOD(SetBoolArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST BOOL* pb, UINT Count) PURE; - STDMETHOD(SetInt)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, INT n) PURE; - STDMETHOD(SetIntArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST INT* pn, UINT Count) PURE; - STDMETHOD(SetFloat)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, FLOAT f) PURE; - STDMETHOD(SetFloatArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST FLOAT* pf, UINT Count) PURE; - STDMETHOD(SetVector)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector) PURE; - STDMETHOD(SetVectorArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector, UINT Count) PURE; - STDMETHOD(SetMatrix)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE; - STDMETHOD(SetMatrixArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixPointerArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixTranspose)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE; - STDMETHOD(SetMatrixTransposeArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixTransposePointerArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; -}; - - -//---------------------------------------------------------------------------- -// ID3DXTextureShader: -//---------------------------------------------------------------------------- - -typedef interface ID3DXTextureShader ID3DXTextureShader; -typedef interface ID3DXTextureShader *LPD3DXTEXTURESHADER; - -// {3E3D67F8-AA7A-405d-A857-BA01D4758426} -DEFINE_GUID(IID_ID3DXTextureShader, -0x3e3d67f8, 0xaa7a, 0x405d, 0xa8, 0x57, 0xba, 0x1, 0xd4, 0x75, 0x84, 0x26); - -#undef INTERFACE -#define INTERFACE ID3DXTextureShader - -DECLARE_INTERFACE_(ID3DXTextureShader, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // Gets - STDMETHOD(GetFunction)(THIS_ LPD3DXBUFFER *ppFunction) PURE; - STDMETHOD(GetConstantBuffer)(THIS_ LPD3DXBUFFER *ppConstantBuffer) PURE; - - // Descs - STDMETHOD(GetDesc)(THIS_ D3DXCONSTANTTABLE_DESC *pDesc) PURE; - STDMETHOD(GetConstantDesc)(THIS_ D3DXHANDLE hConstant, D3DXCONSTANT_DESC *pConstantDesc, UINT *pCount) PURE; - - // Handle operations - STDMETHOD_(D3DXHANDLE, GetConstant)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetConstantByName)(THIS_ D3DXHANDLE hConstant, LPCSTR pName) PURE; - STDMETHOD_(D3DXHANDLE, GetConstantElement)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE; - - // Set Constants - STDMETHOD(SetDefaults)(THIS) PURE; - STDMETHOD(SetValue)(THIS_ D3DXHANDLE hConstant, LPCVOID pData, UINT Bytes) PURE; - STDMETHOD(SetBool)(THIS_ D3DXHANDLE hConstant, BOOL b) PURE; - STDMETHOD(SetBoolArray)(THIS_ D3DXHANDLE hConstant, CONST BOOL* pb, UINT Count) PURE; - STDMETHOD(SetInt)(THIS_ D3DXHANDLE hConstant, INT n) PURE; - STDMETHOD(SetIntArray)(THIS_ D3DXHANDLE hConstant, CONST INT* pn, UINT Count) PURE; - STDMETHOD(SetFloat)(THIS_ D3DXHANDLE hConstant, FLOAT f) PURE; - STDMETHOD(SetFloatArray)(THIS_ D3DXHANDLE hConstant, CONST FLOAT* pf, UINT Count) PURE; - STDMETHOD(SetVector)(THIS_ D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector) PURE; - STDMETHOD(SetVectorArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector, UINT Count) PURE; - STDMETHOD(SetMatrix)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE; - STDMETHOD(SetMatrixArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixPointerArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixTranspose)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE; - STDMETHOD(SetMatrixTransposeArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; - STDMETHOD(SetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; -}; - - - -//---------------------------------------------------------------------------- -// ID3DXFragmentLinker -//---------------------------------------------------------------------------- - -typedef interface ID3DXFragmentLinker ID3DXFragmentLinker; -typedef interface ID3DXFragmentLinker *LPD3DXFRAGMENTLINKER; - -// {1A2C0CC2-E5B6-4ebc-9E8D-390E057811B6} -DEFINE_GUID(IID_ID3DXFragmentLinker, -0x1a2c0cc2, 0xe5b6, 0x4ebc, 0x9e, 0x8d, 0x39, 0xe, 0x5, 0x78, 0x11, 0xb6); - -#undef INTERFACE -#define INTERFACE ID3DXFragmentLinker - -DECLARE_INTERFACE_(ID3DXFragmentLinker, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXFragmentLinker - - // fragment access and information retrieval functions - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD_(UINT, GetNumberOfFragments)(THIS) PURE; - - STDMETHOD_(D3DXHANDLE, GetFragmentHandleByIndex)(THIS_ UINT Index) PURE; - STDMETHOD_(D3DXHANDLE, GetFragmentHandleByName)(THIS_ LPCSTR Name) PURE; - STDMETHOD(GetFragmentDesc)(THIS_ D3DXHANDLE Name, LPD3DXFRAGMENT_DESC FragDesc) PURE; - - // add the fragments in the buffer to the linker - STDMETHOD(AddFragments)(THIS_ CONST DWORD *Fragments) PURE; - - // Create a buffer containing the fragments. Suitable for saving to disk - STDMETHOD(GetAllFragments)(THIS_ LPD3DXBUFFER *ppBuffer) PURE; - STDMETHOD(GetFragment)(THIS_ D3DXHANDLE Name, LPD3DXBUFFER *ppBuffer) PURE; - - STDMETHOD(LinkShader)(THIS_ LPCSTR pProfile, DWORD Flags, CONST D3DXHANDLE *rgFragmentHandles, UINT cFragments, LPD3DXBUFFER *ppBuffer, LPD3DXBUFFER *ppErrorMsgs) PURE; - STDMETHOD(LinkVertexShader)(THIS_ LPCSTR pProfile, DWORD Flags, CONST D3DXHANDLE *rgFragmentHandles, UINT cFragments, LPDIRECT3DVERTEXSHADER9 *pVShader, LPD3DXBUFFER *ppErrorMsgs) PURE; - STDMETHOD(LinkPixelShader)(THIS_ LPCSTR pProfile, DWORD Flags, CONST D3DXHANDLE *rgFragmentHandles, UINT cFragments, LPDIRECT3DPIXELSHADER9 *pPShader, LPD3DXBUFFER *ppErrorMsgs) PURE; - - STDMETHOD(ClearCache)(THIS) PURE; -}; - - -//---------------------------------------------------------------------------- -// D3DXINCLUDE_TYPE: -//---------------------------------------------------------------------------- - -typedef enum _D3DXINCLUDE_TYPE -{ - D3DXINC_LOCAL, - D3DXINC_SYSTEM, - - // force 32-bit size enum - D3DXINC_FORCE_DWORD = 0x7fffffff - -} D3DXINCLUDE_TYPE, *LPD3DXINCLUDE_TYPE; - - -//---------------------------------------------------------------------------- -// ID3DXInclude: -// ------------- -// This interface is intended to be implemented by the application, and can -// be used by various D3DX APIs. This enables application-specific handling -// of #include directives in source files. -// -// Open() -// Opens an include file. If successful, it should fill in ppData and -// pBytes. The data pointer returned must remain valid until Close is -// subsequently called. -// Close() -// Closes an include file. If Open was successful, Close is guaranteed -// to be called before the API using this interface returns. -//---------------------------------------------------------------------------- - -typedef interface ID3DXInclude ID3DXInclude; -typedef interface ID3DXInclude *LPD3DXINCLUDE; - -#undef INTERFACE -#define INTERFACE ID3DXInclude - -DECLARE_INTERFACE(ID3DXInclude) -{ - STDMETHOD(Open)(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes) PURE; - STDMETHOD(Close)(THIS_ LPCVOID pData) PURE; -}; - - -////////////////////////////////////////////////////////////////////////////// -// APIs ////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -//---------------------------------------------------------------------------- -// D3DXAssembleShader: -// ------------------- -// Assembles a shader. -// -// Parameters: -// pSrcFile -// Source file name -// hSrcModule -// Module handle. if NULL, current module will be used -// pSrcResource -// Resource name in module -// pSrcData -// Pointer to source code -// SrcDataLen -// Size of source code, in bytes -// pDefines -// Optional NULL-terminated array of preprocessor macro definitions. -// pInclude -// Optional interface pointer to use for handling #include directives. -// If this parameter is NULL, #includes will be honored when assembling -// from file, and will error when assembling from resource or memory. -// Flags -// See D3DXSHADER_xxx flags -// ppShader -// Returns a buffer containing the created shader. This buffer contains -// the assembled shader code, as well as any embedded debug info. -// ppErrorMsgs -// Returns a buffer containing a listing of errors and warnings that were -// encountered during assembly. If you are running in a debugger, -// these are the same messages you will see in your debug output. -//---------------------------------------------------------------------------- - - -HRESULT WINAPI - D3DXAssembleShaderFromFileA( - LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs); - -HRESULT WINAPI - D3DXAssembleShaderFromFileW( - LPCWSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs); - -#ifdef UNICODE -#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileW -#else -#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileA -#endif - - -HRESULT WINAPI - D3DXAssembleShaderFromResourceA( - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs); - -HRESULT WINAPI - D3DXAssembleShaderFromResourceW( - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs); - -#ifdef UNICODE -#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceW -#else -#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceA -#endif - - -HRESULT WINAPI - D3DXAssembleShader( - LPCSTR pSrcData, - UINT SrcDataLen, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs); - - - -//---------------------------------------------------------------------------- -// D3DXCompileShader: -// ------------------ -// Compiles a shader. -// -// Parameters: -// pSrcFile -// Source file name. -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module. -// pSrcData -// Pointer to source code. -// SrcDataLen -// Size of source code, in bytes. -// pDefines -// Optional NULL-terminated array of preprocessor macro definitions. -// pInclude -// Optional interface pointer to use for handling #include directives. -// If this parameter is NULL, #includes will be honored when compiling -// from file, and will error when compiling from resource or memory. -// pFunctionName -// Name of the entrypoint function where execution should begin. -// pProfile -// Instruction set to be used when generating code. Currently supported -// profiles are "vs_1_1", "vs_2_0", "vs_2_a", "vs_2_sw", "ps_1_1", -// "ps_1_2", "ps_1_3", "ps_1_4", "ps_2_0", "ps_2_a", "ps_2_sw", "tx_1_0" -// Flags -// See D3DXSHADER_xxx flags. -// ppShader -// Returns a buffer containing the created shader. This buffer contains -// the compiled shader code, as well as any embedded debug and symbol -// table info. (See D3DXGetShaderConstantTable) -// ppErrorMsgs -// Returns a buffer containing a listing of errors and warnings that were -// encountered during the compile. If you are running in a debugger, -// these are the same messages you will see in your debug output. -// ppConstantTable -// Returns a ID3DXConstantTable object which can be used to set -// shader constants to the device. Alternatively, an application can -// parse the D3DXSHADER_CONSTANTTABLE block embedded as a comment within -// the shader. -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCompileShaderFromFileA( - LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPCSTR pFunctionName, - LPCSTR pProfile, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable); - -HRESULT WINAPI - D3DXCompileShaderFromFileW( - LPCWSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPCSTR pFunctionName, - LPCSTR pProfile, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable); - -#ifdef UNICODE -#define D3DXCompileShaderFromFile D3DXCompileShaderFromFileW -#else -#define D3DXCompileShaderFromFile D3DXCompileShaderFromFileA -#endif - - -HRESULT WINAPI - D3DXCompileShaderFromResourceA( - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPCSTR pFunctionName, - LPCSTR pProfile, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable); - -HRESULT WINAPI - D3DXCompileShaderFromResourceW( - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPCSTR pFunctionName, - LPCSTR pProfile, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable); - -#ifdef UNICODE -#define D3DXCompileShaderFromResource D3DXCompileShaderFromResourceW -#else -#define D3DXCompileShaderFromResource D3DXCompileShaderFromResourceA -#endif - - -HRESULT WINAPI - D3DXCompileShader( - LPCSTR pSrcData, - UINT SrcDataLen, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPCSTR pFunctionName, - LPCSTR pProfile, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable); - - -//---------------------------------------------------------------------------- -// D3DXDisassembleShader: -// ---------------------- -// Takes a binary shader, and returns a buffer containing text assembly. -// -// Parameters: -// pShader -// Pointer to the shader byte code. -// ShaderSizeInBytes -// Size of the shader byte code in bytes. -// EnableColorCode -// Emit HTML tags for color coding the output? -// pComments -// Pointer to a comment string to include at the top of the shader. -// ppDisassembly -// Returns a buffer containing the disassembled shader. -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXDisassembleShader( - CONST DWORD* pShader, - BOOL EnableColorCode, - LPCSTR pComments, - LPD3DXBUFFER* ppDisassembly); - - -//---------------------------------------------------------------------------- -// D3DXGetPixelShaderProfile/D3DXGetVertexShaderProfile: -// ----------------------------------------------------- -// Returns the name of the HLSL profile best suited to a given device. -// -// Parameters: -// pDevice -// Pointer to the device in question -//---------------------------------------------------------------------------- - -LPCSTR WINAPI - D3DXGetPixelShaderProfile( - LPDIRECT3DDEVICE9 pDevice); - -LPCSTR WINAPI - D3DXGetVertexShaderProfile( - LPDIRECT3DDEVICE9 pDevice); - - -//---------------------------------------------------------------------------- -// D3DXFindShaderComment: -// ---------------------- -// Searches through a shader for a particular comment, denoted by a FourCC in -// the first DWORD of the comment. If the comment is not found, and no other -// error has occurred, S_FALSE is returned. -// -// Parameters: -// pFunction -// Pointer to the function DWORD stream -// FourCC -// FourCC used to identify the desired comment block. -// ppData -// Returns a pointer to the comment data (not including comment token -// and FourCC). Can be NULL. -// pSizeInBytes -// Returns the size of the comment data in bytes. Can be NULL. -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXFindShaderComment( - CONST DWORD* pFunction, - DWORD FourCC, - LPCVOID* ppData, - UINT* pSizeInBytes); - - -//---------------------------------------------------------------------------- -// D3DXGetShaderSize: -// ------------------ -// Returns the size of the shader byte-code, in bytes. -// -// Parameters: -// pFunction -// Pointer to the function DWORD stream -//---------------------------------------------------------------------------- - -UINT WINAPI - D3DXGetShaderSize( - CONST DWORD* pFunction); - - -//---------------------------------------------------------------------------- -// D3DXGetShaderVersion: -// ----------------------- -// Returns the shader version of a given shader. Returns zero if the shader -// function is NULL. -// -// Parameters: -// pFunction -// Pointer to the function DWORD stream -//---------------------------------------------------------------------------- - -DWORD WINAPI - D3DXGetShaderVersion( - CONST DWORD* pFunction); - -//---------------------------------------------------------------------------- -// D3DXGetShaderSemantics: -// ----------------------- -// Gets semantics for all input elements referenced inside a given shader. -// -// Parameters: -// pFunction -// Pointer to the function DWORD stream -// pSemantics -// Pointer to an array of D3DXSEMANTIC structures. The function will -// fill this array with the semantics for each input element referenced -// inside the shader. This array is assumed to contain at least -// MAXD3DDECLLENGTH elements. -// pCount -// Returns the number of elements referenced by the shader -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXGetShaderInputSemantics( - CONST DWORD* pFunction, - D3DXSEMANTIC* pSemantics, - UINT* pCount); - -HRESULT WINAPI - D3DXGetShaderOutputSemantics( - CONST DWORD* pFunction, - D3DXSEMANTIC* pSemantics, - UINT* pCount); - - -//---------------------------------------------------------------------------- -// D3DXGetShaderSamplers: -// ---------------------- -// Gets semantics for all input elements referenced inside a given shader. -// -// pFunction -// Pointer to the function DWORD stream -// pSamplers -// Pointer to an array of LPCSTRs. The function will fill this array -// with pointers to the sampler names contained within pFunction, for -// each sampler referenced inside the shader. This array is assumed to -// contain at least 16 elements. -// pCount -// Returns the number of samplers referenced by the shader -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXGetShaderSamplers( - CONST DWORD* pFunction, - LPCSTR* pSamplers, - UINT* pCount); - - -//---------------------------------------------------------------------------- -// D3DXGetShaderConstantTable: -// --------------------------- -// Gets shader constant table embedded inside shader. A constant table is -// generated by D3DXAssembleShader and D3DXCompileShader, and is embedded in -// the body of the shader. -// -// Parameters: -// pFunction -// Pointer to the function DWORD stream -// ppConstantTable -// Returns a ID3DXConstantTable object which can be used to set -// shader constants to the device. Alternatively, an application can -// parse the D3DXSHADER_CONSTANTTABLE block embedded as a comment within -// the shader. -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXGetShaderConstantTable( - CONST DWORD* pFunction, - LPD3DXCONSTANTTABLE* ppConstantTable); - - - -//---------------------------------------------------------------------------- -// D3DXCreateTextureShader: -// ------------------------ -// Creates a texture shader object, given the compiled shader. -// -// Parameters -// pFunction -// Pointer to the function DWORD stream -// ppTextureShader -// Returns a ID3DXTextureShader object which can be used to procedurally -// fill the contents of a texture using the D3DXFillTextureTX functions. -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCreateTextureShader( - CONST DWORD* pFunction, - LPD3DXTEXTURESHADER* ppTextureShader); - - - -//---------------------------------------------------------------------------- -// D3DXGatherFragments: -// ------------------- -// Assembles shader fragments into a buffer to be passed to a fragment linker. -// will generate shader fragments for all fragments in the file -// -// Parameters: -// pSrcFile -// Source file name -// hSrcModule -// Module handle. if NULL, current module will be used -// pSrcResource -// Resource name in module -// pSrcData -// Pointer to source code -// SrcDataLen -// Size of source code, in bytes -// pDefines -// Optional NULL-terminated array of preprocessor macro definitions. -// pInclude -// Optional interface pointer to use for handling #include directives. -// If this parameter is NULL, #includes will be honored when assembling -// from file, and will error when assembling from resource or memory. -// Flags -// See D3DXSHADER_xxx flags -// ppShader -// Returns a buffer containing the created shader fragments. This buffer contains -// the assembled shader code, as well as any embedded debug info. -// ppErrorMsgs -// Returns a buffer containing a listing of errors and warnings that were -// encountered during assembly. If you are running in a debugger, -// these are the same messages you will see in your debug output. -//---------------------------------------------------------------------------- - - -HRESULT WINAPI -D3DXGatherFragmentsFromFileA( - LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs); - -HRESULT WINAPI -D3DXGatherFragmentsFromFileW( - LPCWSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs); - -#ifdef UNICODE -#define D3DXGatherFragmentsFromFile D3DXGatherFragmentsFromFileW -#else -#define D3DXGatherFragmentsFromFile D3DXGatherFragmentsFromFileA -#endif - - -HRESULT WINAPI - D3DXGatherFragmentsFromResourceA( - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs); - -HRESULT WINAPI - D3DXGatherFragmentsFromResourceW( - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs); - -#ifdef UNICODE -#define D3DXGatherFragmentsFromResource D3DXGatherFragmentsFromResourceW -#else -#define D3DXGatherFragmentsFromResource D3DXGatherFragmentsFromResourceA -#endif - - -HRESULT WINAPI - D3DXGatherFragments( - LPCSTR pSrcData, - UINT SrcDataLen, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs); - - - -//---------------------------------------------------------------------------- -// D3DXCreateFragmentLinker: -// ------------------------- -// Creates a fragment linker with a given cache size. The interface returned -// can be used to link together shader fragments. (both HLSL & ASM fragements) -// -// Parameters: -// pDevice -// Pointer to the device on which to create the shaders -// ShaderCacheSize -// Size of the shader cache -// ppFragmentLinker -// pointer to a memory location to put the created interface pointer -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCreateFragmentLinker( - LPDIRECT3DDEVICE9 pDevice, - UINT ShaderCacheSize, - LPD3DXFRAGMENTLINKER* ppFragmentLinker); - - -//---------------------------------------------------------------------------- -// D3DXPreprocessShader: -// --------------------- -// Runs the preprocessor on the specified shader or effect, but does -// not actually compile it. This is useful for evaluating the #includes -// and #defines in a shader and then emitting a reformatted token stream -// for debugging purposes or for generating a self-contained shader. -// -// Parameters: -// pSrcFile -// Source file name -// hSrcModule -// Module handle. if NULL, current module will be used -// pSrcResource -// Resource name in module -// pSrcData -// Pointer to source code -// SrcDataLen -// Size of source code, in bytes -// pDefines -// Optional NULL-terminated array of preprocessor macro definitions. -// pInclude -// Optional interface pointer to use for handling #include directives. -// If this parameter is NULL, #includes will be honored when assembling -// from file, and will error when assembling from resource or memory. -// ppShaderText -// Returns a buffer containing a single large string that represents -// the resulting formatted token stream -// ppErrorMsgs -// Returns a buffer containing a listing of errors and warnings that were -// encountered during assembly. If you are running in a debugger, -// these are the same messages you will see in your debug output. -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXPreprocessShaderFromFileA( - LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPD3DXBUFFER* ppShaderText, - LPD3DXBUFFER* ppErrorMsgs); - -HRESULT WINAPI - D3DXPreprocessShaderFromFileW( - LPCWSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPD3DXBUFFER* ppShaderText, - LPD3DXBUFFER* ppErrorMsgs); - -#ifdef UNICODE -#define D3DXPreprocessShaderFromFile D3DXPreprocessShaderFromFileW -#else -#define D3DXPreprocessShaderFromFile D3DXPreprocessShaderFromFileA -#endif - -HRESULT WINAPI - D3DXPreprocessShaderFromResourceA( - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPD3DXBUFFER* ppShaderText, - LPD3DXBUFFER* ppErrorMsgs); - -HRESULT WINAPI - D3DXPreprocessShaderFromResourceW( - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPD3DXBUFFER* ppShaderText, - LPD3DXBUFFER* ppErrorMsgs); - -#ifdef UNICODE -#define D3DXPreprocessShaderFromResource D3DXPreprocessShaderFromResourceW -#else -#define D3DXPreprocessShaderFromResource D3DXPreprocessShaderFromResourceA -#endif - -HRESULT WINAPI - D3DXPreprocessShader( - LPCSTR pSrcData, - UINT SrcDataSize, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPD3DXBUFFER* ppShaderText, - LPD3DXBUFFER* ppErrorMsgs); - - -#ifdef __cplusplus -} -#endif //__cplusplus - - -////////////////////////////////////////////////////////////////////////////// -// Shader comment block layouts ////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXSHADER_CONSTANTTABLE: -// ------------------------- -// Shader constant information; included as an CTAB comment block inside -// shaders. All offsets are BYTE offsets from start of CONSTANTTABLE struct. -// Entries in the table are sorted by Name in ascending order. -//---------------------------------------------------------------------------- - -typedef struct _D3DXSHADER_CONSTANTTABLE -{ - DWORD Size; // sizeof(D3DXSHADER_CONSTANTTABLE) - DWORD Creator; // LPCSTR offset - DWORD Version; // shader version - DWORD Constants; // number of constants - DWORD ConstantInfo; // D3DXSHADER_CONSTANTINFO[Constants] offset - DWORD Flags; // flags shader was compiled with - DWORD Target; // LPCSTR offset - -} D3DXSHADER_CONSTANTTABLE, *LPD3DXSHADER_CONSTANTTABLE; - - -typedef struct _D3DXSHADER_CONSTANTINFO -{ - DWORD Name; // LPCSTR offset - WORD RegisterSet; // D3DXREGISTER_SET - WORD RegisterIndex; // register number - WORD RegisterCount; // number of registers - WORD Reserved; // reserved - DWORD TypeInfo; // D3DXSHADER_TYPEINFO offset - DWORD DefaultValue; // offset of default value - -} D3DXSHADER_CONSTANTINFO, *LPD3DXSHADER_CONSTANTINFO; - - -typedef struct _D3DXSHADER_TYPEINFO -{ - WORD Class; // D3DXPARAMETER_CLASS - WORD Type; // D3DXPARAMETER_TYPE - WORD Rows; // number of rows (matrices) - WORD Columns; // number of columns (vectors and matrices) - WORD Elements; // array dimension - WORD StructMembers; // number of struct members - DWORD StructMemberInfo; // D3DXSHADER_STRUCTMEMBERINFO[Members] offset - -} D3DXSHADER_TYPEINFO, *LPD3DXSHADER_TYPEINFO; - - -typedef struct _D3DXSHADER_STRUCTMEMBERINFO -{ - DWORD Name; // LPCSTR offset - DWORD TypeInfo; // D3DXSHADER_TYPEINFO offset - -} D3DXSHADER_STRUCTMEMBERINFO, *LPD3DXSHADER_STRUCTMEMBERINFO; - - - -#endif //__D3DX9SHADER_H__ - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// File: d3dx9shader.h +// Content: D3DX Shader APIs +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx9.h" + +#ifndef __D3DX9SHADER_H__ +#define __D3DX9SHADER_H__ + + +//--------------------------------------------------------------------------- +// D3DXTX_VERSION: +// -------------- +// Version token used to create a procedural texture filler in effects +// Used by D3DXFill[]TX functions +//--------------------------------------------------------------------------- +#define D3DXTX_VERSION(_Major,_Minor) (('T' << 24) | ('X' << 16) | ((_Major) << 8) | (_Minor)) + + + +//---------------------------------------------------------------------------- +// D3DXSHADER flags: +// ----------------- +// D3DXSHADER_DEBUG +// Insert debug file/line/type/symbol information. +// +// D3DXSHADER_SKIPVALIDATION +// Do not validate the generated code against known capabilities and +// constraints. This option is only recommended when compiling shaders +// you KNOW will work. (ie. have compiled before without this option.) +// Shaders are always validated by D3D before they are set to the device. +// +// D3DXSHADER_SKIPOPTIMIZATION +// Instructs the compiler to skip optimization steps during code generation. +// Unless you are trying to isolate a problem in your code using this option +// is not recommended. +// +// D3DXSHADER_PACKMATRIX_ROWMAJOR +// Unless explicitly specified, matrices will be packed in row-major order +// on input and output from the shader. +// +// D3DXSHADER_PACKMATRIX_COLUMNMAJOR +// Unless explicitly specified, matrices will be packed in column-major +// order on input and output from the shader. This is generally more +// efficient, since it allows vector-matrix multiplication to be performed +// using a series of dot-products. +// +// D3DXSHADER_PARTIALPRECISION +// Force all computations in resulting shader to occur at partial precision. +// This may result in faster evaluation of shaders on some hardware. +// +// D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT +// Force compiler to compile against the next highest available software +// target for vertex shaders. This flag also turns optimizations off, +// and debugging on. +// +// D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT +// Force compiler to compile against the next highest available software +// target for pixel shaders. This flag also turns optimizations off, +// and debugging on. +// +// D3DXSHADER_NO_PRESHADER +// Disables Preshaders. Using this flag will cause the compiler to not +// pull out static expression for evaluation on the host cpu +// +// D3DXSHADER_AVOID_FLOW_CONTROL +// Hint compiler to avoid flow-control constructs where possible. +// +// D3DXSHADER_PREFER_FLOW_CONTROL +// Hint compiler to prefer flow-control constructs where possible. +// +//---------------------------------------------------------------------------- + +#define D3DXSHADER_DEBUG (1 << 0) +#define D3DXSHADER_SKIPVALIDATION (1 << 1) +#define D3DXSHADER_SKIPOPTIMIZATION (1 << 2) +#define D3DXSHADER_PACKMATRIX_ROWMAJOR (1 << 3) +#define D3DXSHADER_PACKMATRIX_COLUMNMAJOR (1 << 4) +#define D3DXSHADER_PARTIALPRECISION (1 << 5) +#define D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT (1 << 6) +#define D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT (1 << 7) +#define D3DXSHADER_NO_PRESHADER (1 << 8) +#define D3DXSHADER_AVOID_FLOW_CONTROL (1 << 9) +#define D3DXSHADER_PREFER_FLOW_CONTROL (1 << 10) + + + +//---------------------------------------------------------------------------- +// D3DXHANDLE: +// ----------- +// Handle values used to efficiently reference shader and effect parameters. +// Strings can be used as handles. However, handles are not always strings. +//---------------------------------------------------------------------------- + +typedef LPCSTR D3DXHANDLE; +typedef D3DXHANDLE *LPD3DXHANDLE; + + +//---------------------------------------------------------------------------- +// 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; + + +//---------------------------------------------------------------------------- +// D3DXSEMANTIC: +//---------------------------------------------------------------------------- + +typedef struct _D3DXSEMANTIC +{ + UINT Usage; + UINT UsageIndex; + +} D3DXSEMANTIC, *LPD3DXSEMANTIC; + + + +//---------------------------------------------------------------------------- +// D3DXFRAGMENT_DESC: +//---------------------------------------------------------------------------- + +typedef struct _D3DXFRAGMENT_DESC +{ + LPCSTR Name; + DWORD Target; + +} D3DXFRAGMENT_DESC, *LPD3DXFRAGMENT_DESC; + + +//---------------------------------------------------------------------------- +// D3DXREGISTER_SET: +//---------------------------------------------------------------------------- + +typedef enum _D3DXREGISTER_SET +{ + D3DXRS_BOOL, + D3DXRS_INT4, + D3DXRS_FLOAT4, + D3DXRS_SAMPLER, + + // force 32-bit size enum + D3DXRS_FORCE_DWORD = 0x7fffffff + +} D3DXREGISTER_SET, *LPD3DXREGISTER_SET; + + +//---------------------------------------------------------------------------- +// D3DXPARAMETER_CLASS: +//---------------------------------------------------------------------------- + +typedef enum _D3DXPARAMETER_CLASS +{ + D3DXPC_SCALAR, + D3DXPC_VECTOR, + D3DXPC_MATRIX_ROWS, + D3DXPC_MATRIX_COLUMNS, + D3DXPC_OBJECT, + D3DXPC_STRUCT, + + // force 32-bit size enum + D3DXPC_FORCE_DWORD = 0x7fffffff + +} D3DXPARAMETER_CLASS, *LPD3DXPARAMETER_CLASS; + + +//---------------------------------------------------------------------------- +// D3DXPARAMETER_TYPE: +//---------------------------------------------------------------------------- + +typedef enum _D3DXPARAMETER_TYPE +{ + D3DXPT_VOID, + D3DXPT_BOOL, + D3DXPT_INT, + D3DXPT_FLOAT, + D3DXPT_STRING, + D3DXPT_TEXTURE, + D3DXPT_TEXTURE1D, + D3DXPT_TEXTURE2D, + D3DXPT_TEXTURE3D, + D3DXPT_TEXTURECUBE, + D3DXPT_SAMPLER, + D3DXPT_SAMPLER1D, + D3DXPT_SAMPLER2D, + D3DXPT_SAMPLER3D, + D3DXPT_SAMPLERCUBE, + D3DXPT_PIXELSHADER, + D3DXPT_VERTEXSHADER, + D3DXPT_PIXELFRAGMENT, + D3DXPT_VERTEXFRAGMENT, + + // force 32-bit size enum + D3DXPT_FORCE_DWORD = 0x7fffffff + +} D3DXPARAMETER_TYPE, *LPD3DXPARAMETER_TYPE; + + +//---------------------------------------------------------------------------- +// D3DXCONSTANTTABLE_DESC: +//---------------------------------------------------------------------------- + +typedef struct _D3DXCONSTANTTABLE_DESC +{ + LPCSTR Creator; // Creator string + DWORD Version; // Shader version + UINT Constants; // Number of constants + +} D3DXCONSTANTTABLE_DESC, *LPD3DXCONSTANTTABLE_DESC; + + +//---------------------------------------------------------------------------- +// D3DXCONSTANT_DESC: +//---------------------------------------------------------------------------- + +typedef struct _D3DXCONSTANT_DESC +{ + LPCSTR Name; // Constant name + + D3DXREGISTER_SET RegisterSet; // Register set + UINT RegisterIndex; // Register index + UINT RegisterCount; // Number of registers occupied + + D3DXPARAMETER_CLASS Class; // Class + D3DXPARAMETER_TYPE Type; // Component type + + UINT Rows; // Number of rows + UINT Columns; // Number of columns + UINT Elements; // Number of array elements + UINT StructMembers; // Number of structure member sub-parameters + + UINT Bytes; // Data size, in bytes + LPCVOID DefaultValue; // Pointer to default value + +} D3DXCONSTANT_DESC, *LPD3DXCONSTANT_DESC; + + + +//---------------------------------------------------------------------------- +// ID3DXConstantTable: +//---------------------------------------------------------------------------- + +typedef interface ID3DXConstantTable ID3DXConstantTable; +typedef interface ID3DXConstantTable *LPD3DXCONSTANTTABLE; + +// {AB3C758F-093E-4356-B762-4DB18F1B3A01} +DEFINE_GUID(IID_ID3DXConstantTable, +0xab3c758f, 0x93e, 0x4356, 0xb7, 0x62, 0x4d, 0xb1, 0x8f, 0x1b, 0x3a, 0x1); + + +#undef INTERFACE +#define INTERFACE ID3DXConstantTable + +DECLARE_INTERFACE_(ID3DXConstantTable, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // Buffer + STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; + STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; + + // Descs + STDMETHOD(GetDesc)(THIS_ D3DXCONSTANTTABLE_DESC *pDesc) PURE; + STDMETHOD(GetConstantDesc)(THIS_ D3DXHANDLE hConstant, D3DXCONSTANT_DESC *pConstantDesc, UINT *pCount) PURE; + STDMETHOD_(UINT, GetSamplerIndex)(THIS_ D3DXHANDLE hConstant) PURE; + + // Handle operations + STDMETHOD_(D3DXHANDLE, GetConstant)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetConstantByName)(THIS_ D3DXHANDLE hConstant, LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetConstantElement)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE; + + // Set Constants + STDMETHOD(SetDefaults)(THIS_ LPDIRECT3DDEVICE9 pDevice) PURE; + STDMETHOD(SetValue)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, LPCVOID pData, UINT Bytes) PURE; + STDMETHOD(SetBool)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, BOOL b) PURE; + STDMETHOD(SetBoolArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST BOOL* pb, UINT Count) PURE; + STDMETHOD(SetInt)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, INT n) PURE; + STDMETHOD(SetIntArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST INT* pn, UINT Count) PURE; + STDMETHOD(SetFloat)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, FLOAT f) PURE; + STDMETHOD(SetFloatArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST FLOAT* pf, UINT Count) PURE; + STDMETHOD(SetVector)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector) PURE; + STDMETHOD(SetVectorArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector, UINT Count) PURE; + STDMETHOD(SetMatrix)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetMatrixArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixPointerArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixTranspose)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetMatrixTransposeArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixTransposePointerArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; +}; + + +//---------------------------------------------------------------------------- +// ID3DXTextureShader: +//---------------------------------------------------------------------------- + +typedef interface ID3DXTextureShader ID3DXTextureShader; +typedef interface ID3DXTextureShader *LPD3DXTEXTURESHADER; + +// {3E3D67F8-AA7A-405d-A857-BA01D4758426} +DEFINE_GUID(IID_ID3DXTextureShader, +0x3e3d67f8, 0xaa7a, 0x405d, 0xa8, 0x57, 0xba, 0x1, 0xd4, 0x75, 0x84, 0x26); + +#undef INTERFACE +#define INTERFACE ID3DXTextureShader + +DECLARE_INTERFACE_(ID3DXTextureShader, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // Gets + STDMETHOD(GetFunction)(THIS_ LPD3DXBUFFER *ppFunction) PURE; + STDMETHOD(GetConstantBuffer)(THIS_ LPD3DXBUFFER *ppConstantBuffer) PURE; + + // Descs + STDMETHOD(GetDesc)(THIS_ D3DXCONSTANTTABLE_DESC *pDesc) PURE; + STDMETHOD(GetConstantDesc)(THIS_ D3DXHANDLE hConstant, D3DXCONSTANT_DESC *pConstantDesc, UINT *pCount) PURE; + + // Handle operations + STDMETHOD_(D3DXHANDLE, GetConstant)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetConstantByName)(THIS_ D3DXHANDLE hConstant, LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetConstantElement)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE; + + // Set Constants + STDMETHOD(SetDefaults)(THIS) PURE; + STDMETHOD(SetValue)(THIS_ D3DXHANDLE hConstant, LPCVOID pData, UINT Bytes) PURE; + STDMETHOD(SetBool)(THIS_ D3DXHANDLE hConstant, BOOL b) PURE; + STDMETHOD(SetBoolArray)(THIS_ D3DXHANDLE hConstant, CONST BOOL* pb, UINT Count) PURE; + STDMETHOD(SetInt)(THIS_ D3DXHANDLE hConstant, INT n) PURE; + STDMETHOD(SetIntArray)(THIS_ D3DXHANDLE hConstant, CONST INT* pn, UINT Count) PURE; + STDMETHOD(SetFloat)(THIS_ D3DXHANDLE hConstant, FLOAT f) PURE; + STDMETHOD(SetFloatArray)(THIS_ D3DXHANDLE hConstant, CONST FLOAT* pf, UINT Count) PURE; + STDMETHOD(SetVector)(THIS_ D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector) PURE; + STDMETHOD(SetVectorArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector, UINT Count) PURE; + STDMETHOD(SetMatrix)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetMatrixArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixPointerArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixTranspose)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetMatrixTransposeArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; +}; + + + +//---------------------------------------------------------------------------- +// ID3DXFragmentLinker +//---------------------------------------------------------------------------- + +typedef interface ID3DXFragmentLinker ID3DXFragmentLinker; +typedef interface ID3DXFragmentLinker *LPD3DXFRAGMENTLINKER; + +// {1A2C0CC2-E5B6-4ebc-9E8D-390E057811B6} +DEFINE_GUID(IID_ID3DXFragmentLinker, +0x1a2c0cc2, 0xe5b6, 0x4ebc, 0x9e, 0x8d, 0x39, 0xe, 0x5, 0x78, 0x11, 0xb6); + +#undef INTERFACE +#define INTERFACE ID3DXFragmentLinker + +DECLARE_INTERFACE_(ID3DXFragmentLinker, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXFragmentLinker + + // fragment access and information retrieval functions + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; + STDMETHOD_(UINT, GetNumberOfFragments)(THIS) PURE; + + STDMETHOD_(D3DXHANDLE, GetFragmentHandleByIndex)(THIS_ UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetFragmentHandleByName)(THIS_ LPCSTR Name) PURE; + STDMETHOD(GetFragmentDesc)(THIS_ D3DXHANDLE Name, LPD3DXFRAGMENT_DESC FragDesc) PURE; + + // add the fragments in the buffer to the linker + STDMETHOD(AddFragments)(THIS_ CONST DWORD *Fragments) PURE; + + // Create a buffer containing the fragments. Suitable for saving to disk + STDMETHOD(GetAllFragments)(THIS_ LPD3DXBUFFER *ppBuffer) PURE; + STDMETHOD(GetFragment)(THIS_ D3DXHANDLE Name, LPD3DXBUFFER *ppBuffer) PURE; + + STDMETHOD(LinkShader)(THIS_ LPCSTR pProfile, DWORD Flags, CONST D3DXHANDLE *rgFragmentHandles, UINT cFragments, LPD3DXBUFFER *ppBuffer, LPD3DXBUFFER *ppErrorMsgs) PURE; + STDMETHOD(LinkVertexShader)(THIS_ LPCSTR pProfile, DWORD Flags, CONST D3DXHANDLE *rgFragmentHandles, UINT cFragments, LPDIRECT3DVERTEXSHADER9 *pVShader, LPD3DXBUFFER *ppErrorMsgs) PURE; + STDMETHOD(LinkPixelShader)(THIS_ LPCSTR pProfile, DWORD Flags, CONST D3DXHANDLE *rgFragmentHandles, UINT cFragments, LPDIRECT3DPIXELSHADER9 *pPShader, LPD3DXBUFFER *ppErrorMsgs) PURE; + + STDMETHOD(ClearCache)(THIS) PURE; +}; + + +//---------------------------------------------------------------------------- +// D3DXINCLUDE_TYPE: +//---------------------------------------------------------------------------- + +typedef enum _D3DXINCLUDE_TYPE +{ + D3DXINC_LOCAL, + D3DXINC_SYSTEM, + + // force 32-bit size enum + D3DXINC_FORCE_DWORD = 0x7fffffff + +} D3DXINCLUDE_TYPE, *LPD3DXINCLUDE_TYPE; + + +//---------------------------------------------------------------------------- +// ID3DXInclude: +// ------------- +// This interface is intended to be implemented by the application, and can +// be used by various D3DX APIs. This enables application-specific handling +// of #include directives in source files. +// +// Open() +// Opens an include file. If successful, it should fill in ppData and +// pBytes. The data pointer returned must remain valid until Close is +// subsequently called. +// Close() +// Closes an include file. If Open was successful, Close is guaranteed +// to be called before the API using this interface returns. +//---------------------------------------------------------------------------- + +typedef interface ID3DXInclude ID3DXInclude; +typedef interface ID3DXInclude *LPD3DXINCLUDE; + +#undef INTERFACE +#define INTERFACE ID3DXInclude + +DECLARE_INTERFACE(ID3DXInclude) +{ + STDMETHOD(Open)(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes) PURE; + STDMETHOD(Close)(THIS_ LPCVOID pData) PURE; +}; + + +////////////////////////////////////////////////////////////////////////////// +// APIs ////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +//---------------------------------------------------------------------------- +// D3DXAssembleShader: +// ------------------- +// Assembles a shader. +// +// Parameters: +// pSrcFile +// Source file name +// hSrcModule +// Module handle. if NULL, current module will be used +// pSrcResource +// Resource name in module +// pSrcData +// Pointer to source code +// SrcDataLen +// Size of source code, in bytes +// pDefines +// Optional NULL-terminated array of preprocessor macro definitions. +// pInclude +// Optional interface pointer to use for handling #include directives. +// If this parameter is NULL, #includes will be honored when assembling +// from file, and will error when assembling from resource or memory. +// Flags +// See D3DXSHADER_xxx flags +// ppShader +// Returns a buffer containing the created shader. This buffer contains +// the assembled shader code, as well as any embedded debug info. +// ppErrorMsgs +// Returns a buffer containing a listing of errors and warnings that were +// encountered during assembly. If you are running in a debugger, +// these are the same messages you will see in your debug output. +//---------------------------------------------------------------------------- + + +HRESULT WINAPI + D3DXAssembleShaderFromFileA( + LPCSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs); + +HRESULT WINAPI + D3DXAssembleShaderFromFileW( + LPCWSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs); + +#ifdef UNICODE +#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileW +#else +#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileA +#endif + + +HRESULT WINAPI + D3DXAssembleShaderFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs); + +HRESULT WINAPI + D3DXAssembleShaderFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs); + +#ifdef UNICODE +#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceW +#else +#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceA +#endif + + +HRESULT WINAPI + D3DXAssembleShader( + LPCSTR pSrcData, + UINT SrcDataLen, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs); + + + +//---------------------------------------------------------------------------- +// D3DXCompileShader: +// ------------------ +// Compiles a shader. +// +// Parameters: +// pSrcFile +// Source file name. +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module. +// pSrcData +// Pointer to source code. +// SrcDataLen +// Size of source code, in bytes. +// pDefines +// Optional NULL-terminated array of preprocessor macro definitions. +// pInclude +// Optional interface pointer to use for handling #include directives. +// If this parameter is NULL, #includes will be honored when compiling +// from file, and will error when compiling from resource or memory. +// pFunctionName +// Name of the entrypoint function where execution should begin. +// pProfile +// Instruction set to be used when generating code. Currently supported +// profiles are "vs_1_1", "vs_2_0", "vs_2_a", "vs_2_sw", "ps_1_1", +// "ps_1_2", "ps_1_3", "ps_1_4", "ps_2_0", "ps_2_a", "ps_2_sw", "tx_1_0" +// Flags +// See D3DXSHADER_xxx flags. +// ppShader +// Returns a buffer containing the created shader. This buffer contains +// the compiled shader code, as well as any embedded debug and symbol +// table info. (See D3DXGetShaderConstantTable) +// ppErrorMsgs +// Returns a buffer containing a listing of errors and warnings that were +// encountered during the compile. If you are running in a debugger, +// these are the same messages you will see in your debug output. +// ppConstantTable +// Returns a ID3DXConstantTable object which can be used to set +// shader constants to the device. Alternatively, an application can +// parse the D3DXSHADER_CONSTANTTABLE block embedded as a comment within +// the shader. +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCompileShaderFromFileA( + LPCSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pProfile, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs, + LPD3DXCONSTANTTABLE* ppConstantTable); + +HRESULT WINAPI + D3DXCompileShaderFromFileW( + LPCWSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pProfile, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs, + LPD3DXCONSTANTTABLE* ppConstantTable); + +#ifdef UNICODE +#define D3DXCompileShaderFromFile D3DXCompileShaderFromFileW +#else +#define D3DXCompileShaderFromFile D3DXCompileShaderFromFileA +#endif + + +HRESULT WINAPI + D3DXCompileShaderFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pProfile, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs, + LPD3DXCONSTANTTABLE* ppConstantTable); + +HRESULT WINAPI + D3DXCompileShaderFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pProfile, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs, + LPD3DXCONSTANTTABLE* ppConstantTable); + +#ifdef UNICODE +#define D3DXCompileShaderFromResource D3DXCompileShaderFromResourceW +#else +#define D3DXCompileShaderFromResource D3DXCompileShaderFromResourceA +#endif + + +HRESULT WINAPI + D3DXCompileShader( + LPCSTR pSrcData, + UINT SrcDataLen, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pProfile, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs, + LPD3DXCONSTANTTABLE* ppConstantTable); + + +//---------------------------------------------------------------------------- +// D3DXDisassembleShader: +// ---------------------- +// Takes a binary shader, and returns a buffer containing text assembly. +// +// Parameters: +// pShader +// Pointer to the shader byte code. +// ShaderSizeInBytes +// Size of the shader byte code in bytes. +// EnableColorCode +// Emit HTML tags for color coding the output? +// pComments +// Pointer to a comment string to include at the top of the shader. +// ppDisassembly +// Returns a buffer containing the disassembled shader. +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXDisassembleShader( + CONST DWORD* pShader, + BOOL EnableColorCode, + LPCSTR pComments, + LPD3DXBUFFER* ppDisassembly); + + +//---------------------------------------------------------------------------- +// D3DXGetPixelShaderProfile/D3DXGetVertexShaderProfile: +// ----------------------------------------------------- +// Returns the name of the HLSL profile best suited to a given device. +// +// Parameters: +// pDevice +// Pointer to the device in question +//---------------------------------------------------------------------------- + +LPCSTR WINAPI + D3DXGetPixelShaderProfile( + LPDIRECT3DDEVICE9 pDevice); + +LPCSTR WINAPI + D3DXGetVertexShaderProfile( + LPDIRECT3DDEVICE9 pDevice); + + +//---------------------------------------------------------------------------- +// D3DXFindShaderComment: +// ---------------------- +// Searches through a shader for a particular comment, denoted by a FourCC in +// the first DWORD of the comment. If the comment is not found, and no other +// error has occurred, S_FALSE is returned. +// +// Parameters: +// pFunction +// Pointer to the function DWORD stream +// FourCC +// FourCC used to identify the desired comment block. +// ppData +// Returns a pointer to the comment data (not including comment token +// and FourCC). Can be NULL. +// pSizeInBytes +// Returns the size of the comment data in bytes. Can be NULL. +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXFindShaderComment( + CONST DWORD* pFunction, + DWORD FourCC, + LPCVOID* ppData, + UINT* pSizeInBytes); + + +//---------------------------------------------------------------------------- +// D3DXGetShaderSize: +// ------------------ +// Returns the size of the shader byte-code, in bytes. +// +// Parameters: +// pFunction +// Pointer to the function DWORD stream +//---------------------------------------------------------------------------- + +UINT WINAPI + D3DXGetShaderSize( + CONST DWORD* pFunction); + + +//---------------------------------------------------------------------------- +// D3DXGetShaderVersion: +// ----------------------- +// Returns the shader version of a given shader. Returns zero if the shader +// function is NULL. +// +// Parameters: +// pFunction +// Pointer to the function DWORD stream +//---------------------------------------------------------------------------- + +DWORD WINAPI + D3DXGetShaderVersion( + CONST DWORD* pFunction); + +//---------------------------------------------------------------------------- +// D3DXGetShaderSemantics: +// ----------------------- +// Gets semantics for all input elements referenced inside a given shader. +// +// Parameters: +// pFunction +// Pointer to the function DWORD stream +// pSemantics +// Pointer to an array of D3DXSEMANTIC structures. The function will +// fill this array with the semantics for each input element referenced +// inside the shader. This array is assumed to contain at least +// MAXD3DDECLLENGTH elements. +// pCount +// Returns the number of elements referenced by the shader +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXGetShaderInputSemantics( + CONST DWORD* pFunction, + D3DXSEMANTIC* pSemantics, + UINT* pCount); + +HRESULT WINAPI + D3DXGetShaderOutputSemantics( + CONST DWORD* pFunction, + D3DXSEMANTIC* pSemantics, + UINT* pCount); + + +//---------------------------------------------------------------------------- +// D3DXGetShaderSamplers: +// ---------------------- +// Gets semantics for all input elements referenced inside a given shader. +// +// pFunction +// Pointer to the function DWORD stream +// pSamplers +// Pointer to an array of LPCSTRs. The function will fill this array +// with pointers to the sampler names contained within pFunction, for +// each sampler referenced inside the shader. This array is assumed to +// contain at least 16 elements. +// pCount +// Returns the number of samplers referenced by the shader +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXGetShaderSamplers( + CONST DWORD* pFunction, + LPCSTR* pSamplers, + UINT* pCount); + + +//---------------------------------------------------------------------------- +// D3DXGetShaderConstantTable: +// --------------------------- +// Gets shader constant table embedded inside shader. A constant table is +// generated by D3DXAssembleShader and D3DXCompileShader, and is embedded in +// the body of the shader. +// +// Parameters: +// pFunction +// Pointer to the function DWORD stream +// ppConstantTable +// Returns a ID3DXConstantTable object which can be used to set +// shader constants to the device. Alternatively, an application can +// parse the D3DXSHADER_CONSTANTTABLE block embedded as a comment within +// the shader. +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXGetShaderConstantTable( + CONST DWORD* pFunction, + LPD3DXCONSTANTTABLE* ppConstantTable); + + + +//---------------------------------------------------------------------------- +// D3DXCreateTextureShader: +// ------------------------ +// Creates a texture shader object, given the compiled shader. +// +// Parameters +// pFunction +// Pointer to the function DWORD stream +// ppTextureShader +// Returns a ID3DXTextureShader object which can be used to procedurally +// fill the contents of a texture using the D3DXFillTextureTX functions. +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCreateTextureShader( + CONST DWORD* pFunction, + LPD3DXTEXTURESHADER* ppTextureShader); + + + +//---------------------------------------------------------------------------- +// D3DXGatherFragments: +// ------------------- +// Assembles shader fragments into a buffer to be passed to a fragment linker. +// will generate shader fragments for all fragments in the file +// +// Parameters: +// pSrcFile +// Source file name +// hSrcModule +// Module handle. if NULL, current module will be used +// pSrcResource +// Resource name in module +// pSrcData +// Pointer to source code +// SrcDataLen +// Size of source code, in bytes +// pDefines +// Optional NULL-terminated array of preprocessor macro definitions. +// pInclude +// Optional interface pointer to use for handling #include directives. +// If this parameter is NULL, #includes will be honored when assembling +// from file, and will error when assembling from resource or memory. +// Flags +// See D3DXSHADER_xxx flags +// ppShader +// Returns a buffer containing the created shader fragments. This buffer contains +// the assembled shader code, as well as any embedded debug info. +// ppErrorMsgs +// Returns a buffer containing a listing of errors and warnings that were +// encountered during assembly. If you are running in a debugger, +// these are the same messages you will see in your debug output. +//---------------------------------------------------------------------------- + + +HRESULT WINAPI +D3DXGatherFragmentsFromFileA( + LPCSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs); + +HRESULT WINAPI +D3DXGatherFragmentsFromFileW( + LPCWSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs); + +#ifdef UNICODE +#define D3DXGatherFragmentsFromFile D3DXGatherFragmentsFromFileW +#else +#define D3DXGatherFragmentsFromFile D3DXGatherFragmentsFromFileA +#endif + + +HRESULT WINAPI + D3DXGatherFragmentsFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs); + +HRESULT WINAPI + D3DXGatherFragmentsFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs); + +#ifdef UNICODE +#define D3DXGatherFragmentsFromResource D3DXGatherFragmentsFromResourceW +#else +#define D3DXGatherFragmentsFromResource D3DXGatherFragmentsFromResourceA +#endif + + +HRESULT WINAPI + D3DXGatherFragments( + LPCSTR pSrcData, + UINT SrcDataLen, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs); + + + +//---------------------------------------------------------------------------- +// D3DXCreateFragmentLinker: +// ------------------------- +// Creates a fragment linker with a given cache size. The interface returned +// can be used to link together shader fragments. (both HLSL & ASM fragements) +// +// Parameters: +// pDevice +// Pointer to the device on which to create the shaders +// ShaderCacheSize +// Size of the shader cache +// ppFragmentLinker +// pointer to a memory location to put the created interface pointer +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCreateFragmentLinker( + LPDIRECT3DDEVICE9 pDevice, + UINT ShaderCacheSize, + LPD3DXFRAGMENTLINKER* ppFragmentLinker); + + +//---------------------------------------------------------------------------- +// D3DXPreprocessShader: +// --------------------- +// Runs the preprocessor on the specified shader or effect, but does +// not actually compile it. This is useful for evaluating the #includes +// and #defines in a shader and then emitting a reformatted token stream +// for debugging purposes or for generating a self-contained shader. +// +// Parameters: +// pSrcFile +// Source file name +// hSrcModule +// Module handle. if NULL, current module will be used +// pSrcResource +// Resource name in module +// pSrcData +// Pointer to source code +// SrcDataLen +// Size of source code, in bytes +// pDefines +// Optional NULL-terminated array of preprocessor macro definitions. +// pInclude +// Optional interface pointer to use for handling #include directives. +// If this parameter is NULL, #includes will be honored when assembling +// from file, and will error when assembling from resource or memory. +// ppShaderText +// Returns a buffer containing a single large string that represents +// the resulting formatted token stream +// ppErrorMsgs +// Returns a buffer containing a listing of errors and warnings that were +// encountered during assembly. If you are running in a debugger, +// these are the same messages you will see in your debug output. +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXPreprocessShaderFromFileA( + LPCSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPD3DXBUFFER* ppShaderText, + LPD3DXBUFFER* ppErrorMsgs); + +HRESULT WINAPI + D3DXPreprocessShaderFromFileW( + LPCWSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPD3DXBUFFER* ppShaderText, + LPD3DXBUFFER* ppErrorMsgs); + +#ifdef UNICODE +#define D3DXPreprocessShaderFromFile D3DXPreprocessShaderFromFileW +#else +#define D3DXPreprocessShaderFromFile D3DXPreprocessShaderFromFileA +#endif + +HRESULT WINAPI + D3DXPreprocessShaderFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPD3DXBUFFER* ppShaderText, + LPD3DXBUFFER* ppErrorMsgs); + +HRESULT WINAPI + D3DXPreprocessShaderFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPD3DXBUFFER* ppShaderText, + LPD3DXBUFFER* ppErrorMsgs); + +#ifdef UNICODE +#define D3DXPreprocessShaderFromResource D3DXPreprocessShaderFromResourceW +#else +#define D3DXPreprocessShaderFromResource D3DXPreprocessShaderFromResourceA +#endif + +HRESULT WINAPI + D3DXPreprocessShader( + LPCSTR pSrcData, + UINT SrcDataSize, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPD3DXBUFFER* ppShaderText, + LPD3DXBUFFER* ppErrorMsgs); + + +#ifdef __cplusplus +} +#endif //__cplusplus + + +////////////////////////////////////////////////////////////////////////////// +// Shader comment block layouts ////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXSHADER_CONSTANTTABLE: +// ------------------------- +// Shader constant information; included as an CTAB comment block inside +// shaders. All offsets are BYTE offsets from start of CONSTANTTABLE struct. +// Entries in the table are sorted by Name in ascending order. +//---------------------------------------------------------------------------- + +typedef struct _D3DXSHADER_CONSTANTTABLE +{ + DWORD Size; // sizeof(D3DXSHADER_CONSTANTTABLE) + DWORD Creator; // LPCSTR offset + DWORD Version; // shader version + DWORD Constants; // number of constants + DWORD ConstantInfo; // D3DXSHADER_CONSTANTINFO[Constants] offset + DWORD Flags; // flags shader was compiled with + DWORD Target; // LPCSTR offset + +} D3DXSHADER_CONSTANTTABLE, *LPD3DXSHADER_CONSTANTTABLE; + + +typedef struct _D3DXSHADER_CONSTANTINFO +{ + DWORD Name; // LPCSTR offset + WORD RegisterSet; // D3DXREGISTER_SET + WORD RegisterIndex; // register number + WORD RegisterCount; // number of registers + WORD Reserved; // reserved + DWORD TypeInfo; // D3DXSHADER_TYPEINFO offset + DWORD DefaultValue; // offset of default value + +} D3DXSHADER_CONSTANTINFO, *LPD3DXSHADER_CONSTANTINFO; + + +typedef struct _D3DXSHADER_TYPEINFO +{ + WORD Class; // D3DXPARAMETER_CLASS + WORD Type; // D3DXPARAMETER_TYPE + WORD Rows; // number of rows (matrices) + WORD Columns; // number of columns (vectors and matrices) + WORD Elements; // array dimension + WORD StructMembers; // number of struct members + DWORD StructMemberInfo; // D3DXSHADER_STRUCTMEMBERINFO[Members] offset + +} D3DXSHADER_TYPEINFO, *LPD3DXSHADER_TYPEINFO; + + +typedef struct _D3DXSHADER_STRUCTMEMBERINFO +{ + DWORD Name; // LPCSTR offset + DWORD TypeInfo; // D3DXSHADER_TYPEINFO offset + +} D3DXSHADER_STRUCTMEMBERINFO, *LPD3DXSHADER_STRUCTMEMBERINFO; + + + +#endif //__D3DX9SHADER_H__ + diff --git a/src/dep/include/DXSDK/include/d3dx9shape.h b/src/dep/include/DXSDK/include/d3dx9shape.h index 82908fe..4c23091 100644 --- a/src/dep/include/DXSDK/include/d3dx9shape.h +++ b/src/dep/include/DXSDK/include/d3dx9shape.h @@ -1,221 +1,221 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx9shapes.h -// Content: D3DX simple shapes -// -/////////////////////////////////////////////////////////////////////////// - -#include "d3dx9.h" - -#ifndef __D3DX9SHAPES_H__ -#define __D3DX9SHAPES_H__ - -/////////////////////////////////////////////////////////////////////////// -// Functions: -/////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -//------------------------------------------------------------------------- -// D3DXCreatePolygon: -// ------------------ -// Creates a mesh containing an n-sided polygon. The polygon is centered -// at the origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Length Length of each side. -// Sides Number of sides the polygon has. (Must be >= 3) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreatePolygon( - LPDIRECT3DDEVICE9 pDevice, - FLOAT Length, - UINT Sides, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateBox: -// -------------- -// Creates a mesh containing an axis-aligned box. The box is centered at -// the origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Width Width of box (along X-axis) -// Height Height of box (along Y-axis) -// Depth Depth of box (along Z-axis) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateBox( - LPDIRECT3DDEVICE9 pDevice, - FLOAT Width, - FLOAT Height, - FLOAT Depth, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateCylinder: -// ------------------- -// Creates a mesh containing a cylinder. The generated cylinder is -// centered at the origin, and its axis is aligned with the Z-axis. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Radius1 Radius at -Z end (should be >= 0.0f) -// Radius2 Radius at +Z end (should be >= 0.0f) -// Length Length of cylinder (along Z-axis) -// Slices Number of slices about the main axis -// Stacks Number of stacks along the main axis -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateCylinder( - LPDIRECT3DDEVICE9 pDevice, - FLOAT Radius1, - FLOAT Radius2, - FLOAT Length, - UINT Slices, - UINT Stacks, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateSphere: -// ----------------- -// Creates a mesh containing a sphere. The sphere is centered at the -// origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Radius Radius of the sphere (should be >= 0.0f) -// Slices Number of slices about the main axis -// Stacks Number of stacks along the main axis -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateSphere( - LPDIRECT3DDEVICE9 pDevice, - FLOAT Radius, - UINT Slices, - UINT Stacks, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateTorus: -// ---------------- -// Creates a mesh containing a torus. The generated torus is centered at -// the origin, and its axis is aligned with the Z-axis. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// InnerRadius Inner radius of the torus (should be >= 0.0f) -// OuterRadius Outer radius of the torue (should be >= 0.0f) -// Sides Number of sides in a cross-section (must be >= 3) -// Rings Number of rings making up the torus (must be >= 3) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTorus( - LPDIRECT3DDEVICE9 pDevice, - FLOAT InnerRadius, - FLOAT OuterRadius, - UINT Sides, - UINT Rings, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateTeapot: -// ----------------- -// Creates a mesh containing a teapot. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTeapot( - LPDIRECT3DDEVICE9 pDevice, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateText: -// --------------- -// Creates a mesh containing the specified text using the font associated -// with the device context. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// hDC Device context, with desired font selected -// pText Text to generate -// Deviation Maximum chordal deviation from true font outlines -// Extrusion Amount to extrude text in -Z direction -// ppMesh The mesh object which will be created -// pGlyphMetrics Address of buffer to receive glyph metric data (or NULL) -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTextA( - LPDIRECT3DDEVICE9 pDevice, - HDC hDC, - LPCSTR pText, - FLOAT Deviation, - FLOAT Extrusion, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency, - LPGLYPHMETRICSFLOAT pGlyphMetrics); - -HRESULT WINAPI - D3DXCreateTextW( - LPDIRECT3DDEVICE9 pDevice, - HDC hDC, - LPCWSTR pText, - FLOAT Deviation, - FLOAT Extrusion, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency, - LPGLYPHMETRICSFLOAT pGlyphMetrics); - -#ifdef UNICODE -#define D3DXCreateText D3DXCreateTextW -#else -#define D3DXCreateText D3DXCreateTextA -#endif - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX9SHAPES_H__ - +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx9shapes.h +// Content: D3DX simple shapes +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx9.h" + +#ifndef __D3DX9SHAPES_H__ +#define __D3DX9SHAPES_H__ + +/////////////////////////////////////////////////////////////////////////// +// Functions: +/////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +//------------------------------------------------------------------------- +// D3DXCreatePolygon: +// ------------------ +// Creates a mesh containing an n-sided polygon. The polygon is centered +// at the origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Length Length of each side. +// Sides Number of sides the polygon has. (Must be >= 3) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreatePolygon( + LPDIRECT3DDEVICE9 pDevice, + FLOAT Length, + UINT Sides, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateBox: +// -------------- +// Creates a mesh containing an axis-aligned box. The box is centered at +// the origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Width Width of box (along X-axis) +// Height Height of box (along Y-axis) +// Depth Depth of box (along Z-axis) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateBox( + LPDIRECT3DDEVICE9 pDevice, + FLOAT Width, + FLOAT Height, + FLOAT Depth, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateCylinder: +// ------------------- +// Creates a mesh containing a cylinder. The generated cylinder is +// centered at the origin, and its axis is aligned with the Z-axis. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Radius1 Radius at -Z end (should be >= 0.0f) +// Radius2 Radius at +Z end (should be >= 0.0f) +// Length Length of cylinder (along Z-axis) +// Slices Number of slices about the main axis +// Stacks Number of stacks along the main axis +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateCylinder( + LPDIRECT3DDEVICE9 pDevice, + FLOAT Radius1, + FLOAT Radius2, + FLOAT Length, + UINT Slices, + UINT Stacks, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateSphere: +// ----------------- +// Creates a mesh containing a sphere. The sphere is centered at the +// origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Radius Radius of the sphere (should be >= 0.0f) +// Slices Number of slices about the main axis +// Stacks Number of stacks along the main axis +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateSphere( + LPDIRECT3DDEVICE9 pDevice, + FLOAT Radius, + UINT Slices, + UINT Stacks, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateTorus: +// ---------------- +// Creates a mesh containing a torus. The generated torus is centered at +// the origin, and its axis is aligned with the Z-axis. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// InnerRadius Inner radius of the torus (should be >= 0.0f) +// OuterRadius Outer radius of the torue (should be >= 0.0f) +// Sides Number of sides in a cross-section (must be >= 3) +// Rings Number of rings making up the torus (must be >= 3) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTorus( + LPDIRECT3DDEVICE9 pDevice, + FLOAT InnerRadius, + FLOAT OuterRadius, + UINT Sides, + UINT Rings, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateTeapot: +// ----------------- +// Creates a mesh containing a teapot. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTeapot( + LPDIRECT3DDEVICE9 pDevice, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateText: +// --------------- +// Creates a mesh containing the specified text using the font associated +// with the device context. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// hDC Device context, with desired font selected +// pText Text to generate +// Deviation Maximum chordal deviation from true font outlines +// Extrusion Amount to extrude text in -Z direction +// ppMesh The mesh object which will be created +// pGlyphMetrics Address of buffer to receive glyph metric data (or NULL) +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTextA( + LPDIRECT3DDEVICE9 pDevice, + HDC hDC, + LPCSTR pText, + FLOAT Deviation, + FLOAT Extrusion, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency, + LPGLYPHMETRICSFLOAT pGlyphMetrics); + +HRESULT WINAPI + D3DXCreateTextW( + LPDIRECT3DDEVICE9 pDevice, + HDC hDC, + LPCWSTR pText, + FLOAT Deviation, + FLOAT Extrusion, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency, + LPGLYPHMETRICSFLOAT pGlyphMetrics); + +#ifdef UNICODE +#define D3DXCreateText D3DXCreateTextW +#else +#define D3DXCreateText D3DXCreateTextA +#endif + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX9SHAPES_H__ + diff --git a/src/dep/include/DXSDK/include/d3dx9tex.h b/src/dep/include/DXSDK/include/d3dx9tex.h index 84c632c..34cd8e2 100644 --- a/src/dep/include/DXSDK/include/d3dx9tex.h +++ b/src/dep/include/DXSDK/include/d3dx9tex.h @@ -1,1735 +1,1735 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx9tex.h -// Content: D3DX texturing APIs -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx9.h" - -#ifndef __D3DX9TEX_H__ -#define __D3DX9TEX_H__ - - -//---------------------------------------------------------------------------- -// D3DX_FILTER flags: -// ------------------ -// -// A valid filter must contain one of these values: -// -// D3DX_FILTER_NONE -// No scaling or filtering will take place. Pixels outside the bounds -// of the source image are assumed to be transparent black. -// D3DX_FILTER_POINT -// Each destination pixel is computed by sampling the nearest pixel -// from the source image. -// D3DX_FILTER_LINEAR -// Each destination pixel is computed by linearly interpolating between -// the nearest pixels in the source image. This filter works best -// when the scale on each axis is less than 2. -// D3DX_FILTER_TRIANGLE -// Every pixel in the source image contributes equally to the -// destination image. This is the slowest of all the filters. -// D3DX_FILTER_BOX -// Each pixel is computed by averaging a 2x2(x2) box pixels from -// the source image. Only works when the dimensions of the -// destination are half those of the source. (as with mip maps) -// -// And can be OR'd with any of these optional flags: -// -// D3DX_FILTER_MIRROR_U -// Indicates that pixels off the edge of the texture on the U-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR_V -// Indicates that pixels off the edge of the texture on the V-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR_W -// Indicates that pixels off the edge of the texture on the W-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR -// Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V | -// D3DX_FILTER_MIRROR_V -// D3DX_FILTER_DITHER -// Dithers the resulting image using a 4x4 order dither pattern. -// D3DX_FILTER_SRGB_IN -// Denotes that the input data is in sRGB (gamma 2.2) colorspace. -// D3DX_FILTER_SRGB_OUT -// Denotes that the output data is in sRGB (gamma 2.2) colorspace. -// D3DX_FILTER_SRGB -// Same as specifying D3DX_FILTER_SRGB_IN | D3DX_FILTER_SRGB_OUT -// -//---------------------------------------------------------------------------- - -#define D3DX_FILTER_NONE (1 << 0) -#define D3DX_FILTER_POINT (2 << 0) -#define D3DX_FILTER_LINEAR (3 << 0) -#define D3DX_FILTER_TRIANGLE (4 << 0) -#define D3DX_FILTER_BOX (5 << 0) - -#define D3DX_FILTER_MIRROR_U (1 << 16) -#define D3DX_FILTER_MIRROR_V (2 << 16) -#define D3DX_FILTER_MIRROR_W (4 << 16) -#define D3DX_FILTER_MIRROR (7 << 16) - -#define D3DX_FILTER_DITHER (1 << 19) -#define D3DX_FILTER_DITHER_DIFFUSION (2 << 19) - -#define D3DX_FILTER_SRGB_IN (1 << 21) -#define D3DX_FILTER_SRGB_OUT (2 << 21) -#define D3DX_FILTER_SRGB (3 << 21) - - -//----------------------------------------------------------------------------- -// D3DX_SKIP_DDS_MIP_LEVELS is used to skip mip levels when loading a DDS file: -//----------------------------------------------------------------------------- - -#define D3DX_SKIP_DDS_MIP_LEVELS_MASK 0x1F -#define D3DX_SKIP_DDS_MIP_LEVELS_SHIFT 26 -#define D3DX_SKIP_DDS_MIP_LEVELS(levels, filter) ((((levels) & D3DX_SKIP_DDS_MIP_LEVELS_MASK) << D3DX_SKIP_DDS_MIP_LEVELS_SHIFT) | (filter)) - - - - -//---------------------------------------------------------------------------- -// D3DX_NORMALMAP flags: -// --------------------- -// These flags are used to control how D3DXComputeNormalMap generates normal -// maps. Any number of these flags may be OR'd together in any combination. -// -// D3DX_NORMALMAP_MIRROR_U -// Indicates that pixels off the edge of the texture on the U-axis -// should be mirrored, not wraped. -// D3DX_NORMALMAP_MIRROR_V -// Indicates that pixels off the edge of the texture on the V-axis -// should be mirrored, not wraped. -// D3DX_NORMALMAP_MIRROR -// Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V -// D3DX_NORMALMAP_INVERTSIGN -// Inverts the direction of each normal -// D3DX_NORMALMAP_COMPUTE_OCCLUSION -// Compute the per pixel Occlusion term and encodes it into the alpha. -// An Alpha of 1 means that the pixel is not obscured in anyway, and -// an alpha of 0 would mean that the pixel is completly obscured. -// -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- - -#define D3DX_NORMALMAP_MIRROR_U (1 << 16) -#define D3DX_NORMALMAP_MIRROR_V (2 << 16) -#define D3DX_NORMALMAP_MIRROR (3 << 16) -#define D3DX_NORMALMAP_INVERTSIGN (8 << 16) -#define D3DX_NORMALMAP_COMPUTE_OCCLUSION (16 << 16) - - - - -//---------------------------------------------------------------------------- -// D3DX_CHANNEL flags: -// ------------------- -// These flags are used by functions which operate on or more channels -// in a texture. -// -// D3DX_CHANNEL_RED -// Indicates the red channel should be used -// D3DX_CHANNEL_BLUE -// Indicates the blue channel should be used -// D3DX_CHANNEL_GREEN -// Indicates the green channel should be used -// D3DX_CHANNEL_ALPHA -// Indicates the alpha channel should be used -// D3DX_CHANNEL_LUMINANCE -// Indicates the luminaces of the red green and blue channels should be -// used. -// -//---------------------------------------------------------------------------- - -#define D3DX_CHANNEL_RED (1 << 0) -#define D3DX_CHANNEL_BLUE (1 << 1) -#define D3DX_CHANNEL_GREEN (1 << 2) -#define D3DX_CHANNEL_ALPHA (1 << 3) -#define D3DX_CHANNEL_LUMINANCE (1 << 4) - - - - -//---------------------------------------------------------------------------- -// D3DXIMAGE_FILEFORMAT: -// --------------------- -// This enum is used to describe supported image file formats. -// -//---------------------------------------------------------------------------- - -typedef enum _D3DXIMAGE_FILEFORMAT -{ - D3DXIFF_BMP = 0, - D3DXIFF_JPG = 1, - D3DXIFF_TGA = 2, - D3DXIFF_PNG = 3, - D3DXIFF_DDS = 4, - D3DXIFF_PPM = 5, - D3DXIFF_DIB = 6, - D3DXIFF_HDR = 7, //high dynamic range formats - D3DXIFF_PFM = 8, // - D3DXIFF_FORCE_DWORD = 0x7fffffff - -} D3DXIMAGE_FILEFORMAT; - - -//---------------------------------------------------------------------------- -// LPD3DXFILL2D and LPD3DXFILL3D: -// ------------------------------ -// Function types used by the texture fill functions. -// -// Parameters: -// pOut -// Pointer to a vector which the function uses to return its result. -// X,Y,Z,W will be mapped to R,G,B,A respectivly. -// pTexCoord -// Pointer to a vector containing the coordinates of the texel currently -// being evaluated. Textures and VolumeTexture texcoord components -// range from 0 to 1. CubeTexture texcoord component range from -1 to 1. -// pTexelSize -// Pointer to a vector containing the dimensions of the current texel. -// pData -// Pointer to user data. -// -//---------------------------------------------------------------------------- - -typedef VOID (WINAPI *LPD3DXFILL2D)(D3DXVECTOR4 *pOut, - CONST D3DXVECTOR2 *pTexCoord, CONST D3DXVECTOR2 *pTexelSize, LPVOID pData); - -typedef VOID (WINAPI *LPD3DXFILL3D)(D3DXVECTOR4 *pOut, - CONST D3DXVECTOR3 *pTexCoord, CONST D3DXVECTOR3 *pTexelSize, LPVOID pData); - - - -//---------------------------------------------------------------------------- -// D3DXIMAGE_INFO: -// --------------- -// This structure is used to return a rough description of what the -// the original contents of an image file looked like. -// -// Width -// Width of original image in pixels -// Height -// Height of original image in pixels -// Depth -// Depth of original image in pixels -// MipLevels -// Number of mip levels in original image -// Format -// D3D format which most closely describes the data in original image -// ResourceType -// D3DRESOURCETYPE representing the type of texture stored in the file. -// D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE. -// ImageFileFormat -// D3DXIMAGE_FILEFORMAT representing the format of the image file. -// -//---------------------------------------------------------------------------- - -typedef struct _D3DXIMAGE_INFO -{ - UINT Width; - UINT Height; - UINT Depth; - UINT MipLevels; - D3DFORMAT Format; - D3DRESOURCETYPE ResourceType; - D3DXIMAGE_FILEFORMAT ImageFileFormat; - -} D3DXIMAGE_INFO; - - - - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - - -////////////////////////////////////////////////////////////////////////////// -// Image File APIs /////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -; -//---------------------------------------------------------------------------- -// GetImageInfoFromFile/Resource: -// ------------------------------ -// Fills in a D3DXIMAGE_INFO struct with information about an image file. -// -// Parameters: -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXGetImageInfoFromFileA( - LPCSTR pSrcFile, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXGetImageInfoFromFileW( - LPCWSTR pSrcFile, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileW -#else -#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileA -#endif - - -HRESULT WINAPI - D3DXGetImageInfoFromResourceA( - HMODULE hSrcModule, - LPCSTR pSrcResource, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXGetImageInfoFromResourceW( - HMODULE hSrcModule, - LPCWSTR pSrcResource, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceW -#else -#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceA -#endif - - -HRESULT WINAPI - D3DXGetImageInfoFromFileInMemory( - LPCVOID pSrcData, - UINT SrcDataSize, - D3DXIMAGE_INFO* pSrcInfo); - - - - -////////////////////////////////////////////////////////////////////////////// -// Load/Save Surface APIs //////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromFile/Resource: -// --------------------------------- -// Load surface from a file or resource -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcRect -// Source rectangle, or NULL for entire image -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadSurfaceFromFileA( - LPDIRECT3DSURFACE9 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCSTR pSrcFile, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadSurfaceFromFileW( - LPDIRECT3DSURFACE9 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCWSTR pSrcFile, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileW -#else -#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileA -#endif - - - -HRESULT WINAPI - D3DXLoadSurfaceFromResourceA( - LPDIRECT3DSURFACE9 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadSurfaceFromResourceW( - LPDIRECT3DSURFACE9 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - - -#ifdef UNICODE -#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceW -#else -#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceA -#endif - - - -HRESULT WINAPI - D3DXLoadSurfaceFromFileInMemory( - LPDIRECT3DSURFACE9 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCVOID pSrcData, - UINT SrcDataSize, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - - - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromSurface: -// --------------------------- -// Load surface from another surface (with color conversion) -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcSurface -// Source surface -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle, or NULL for entire surface -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadSurfaceFromSurface( - LPDIRECT3DSURFACE9 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPDIRECT3DSURFACE9 pSrcSurface, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey); - - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromMemory: -// -------------------------- -// Load surface from memory. -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcMemory -// Pointer to the top-left corner of the source image in memory -// SrcFormat -// Pixel format of the source image. -// SrcPitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the width of one row of cells, in bytes. -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle. -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadSurfaceFromMemory( - LPDIRECT3DSURFACE9 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCVOID pSrcMemory, - D3DFORMAT SrcFormat, - UINT SrcPitch, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey); - - -//---------------------------------------------------------------------------- -// D3DXSaveSurfaceToFile: -// ---------------------- -// Save a surface to a image file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcSurface -// Source surface, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle, or NULL for the entire image -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXSaveSurfaceToFileA( - LPCSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DSURFACE9 pSrcSurface, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect); - -HRESULT WINAPI - D3DXSaveSurfaceToFileW( - LPCWSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DSURFACE9 pSrcSurface, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect); - -#ifdef UNICODE -#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW -#else -#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA -#endif - -//---------------------------------------------------------------------------- -// D3DXSaveSurfaceToFileInMemory: -// ---------------------- -// Save a surface to a image file. -// -// Parameters: -// ppDestBuf -// address of pointer to d3dxbuffer for returning data bits -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcSurface -// Source surface, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle, or NULL for the entire image -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXSaveSurfaceToFileInMemory( - LPD3DXBUFFER* ppDestBuf, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DSURFACE9 pSrcSurface, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect); - - -////////////////////////////////////////////////////////////////////////////// -// Load/Save Volume APIs ///////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromFile/Resource: -// -------------------------------- -// Load volume from a file or resource -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcBox -// Source box, or NULL for entire image -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadVolumeFromFileA( - LPDIRECT3DVOLUME9 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCSTR pSrcFile, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadVolumeFromFileW( - LPDIRECT3DVOLUME9 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCWSTR pSrcFile, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileW -#else -#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileA -#endif - - -HRESULT WINAPI - D3DXLoadVolumeFromResourceA( - LPDIRECT3DVOLUME9 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadVolumeFromResourceW( - LPDIRECT3DVOLUME9 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceW -#else -#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceA -#endif - - - -HRESULT WINAPI - D3DXLoadVolumeFromFileInMemory( - LPDIRECT3DVOLUME9 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCVOID pSrcData, - UINT SrcDataSize, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - - - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromVolume: -// ------------------------- -// Load volume from another volume (with color conversion) -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcVolume -// Source volume -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box, or NULL for entire volume -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadVolumeFromVolume( - LPDIRECT3DVOLUME9 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPDIRECT3DVOLUME9 pSrcVolume, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey); - - - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromMemory: -// ------------------------- -// Load volume from memory. -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcMemory -// Pointer to the top-left corner of the source volume in memory -// SrcFormat -// Pixel format of the source volume. -// SrcRowPitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the size of one row of cells, in bytes. -// SrcSlicePitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the size of one slice of cells, in bytes. -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box. -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadVolumeFromMemory( - LPDIRECT3DVOLUME9 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCVOID pSrcMemory, - D3DFORMAT SrcFormat, - UINT SrcRowPitch, - UINT SrcSlicePitch, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey); - - - -//---------------------------------------------------------------------------- -// D3DXSaveVolumeToFile: -// --------------------- -// Save a volume to a image file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcVolume -// Source volume, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box, or NULL for the entire volume -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXSaveVolumeToFileA( - LPCSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DVOLUME9 pSrcVolume, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox); - -HRESULT WINAPI - D3DXSaveVolumeToFileW( - LPCWSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DVOLUME9 pSrcVolume, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox); - -#ifdef UNICODE -#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileW -#else -#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileA -#endif - - -//---------------------------------------------------------------------------- -// D3DXSaveVolumeToFileInMemory: -// --------------------- -// Save a volume to a image file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcVolume -// Source volume, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box, or NULL for the entire volume -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXSaveVolumeToFileInMemory( - LPD3DXBUFFER* ppDestBuf, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DVOLUME9 pSrcVolume, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox); - -////////////////////////////////////////////////////////////////////////////// -// Create/Save Texture APIs ////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXCheckTextureRequirements: -// ----------------------------- -// Checks texture creation parameters. If parameters are invalid, this -// function returns corrected parameters. -// -// Parameters: -// -// pDevice -// The D3D device to be used -// pWidth, pHeight, pDepth, pSize -// Desired size in pixels, or NULL. Returns corrected size. -// pNumMipLevels -// Number of desired mipmap levels, or NULL. Returns corrected number. -// Usage -// Texture usage flags -// pFormat -// Desired pixel format, or NULL. Returns corrected format. -// Pool -// Memory pool to be used to create texture -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCheckTextureRequirements( - LPDIRECT3DDEVICE9 pDevice, - UINT* pWidth, - UINT* pHeight, - UINT* pNumMipLevels, - DWORD Usage, - D3DFORMAT* pFormat, - D3DPOOL Pool); - -HRESULT WINAPI - D3DXCheckCubeTextureRequirements( - LPDIRECT3DDEVICE9 pDevice, - UINT* pSize, - UINT* pNumMipLevels, - DWORD Usage, - D3DFORMAT* pFormat, - D3DPOOL Pool); - -HRESULT WINAPI - D3DXCheckVolumeTextureRequirements( - LPDIRECT3DDEVICE9 pDevice, - UINT* pWidth, - UINT* pHeight, - UINT* pDepth, - UINT* pNumMipLevels, - DWORD Usage, - D3DFORMAT* pFormat, - D3DPOOL Pool); - - -//---------------------------------------------------------------------------- -// D3DXCreateTexture: -// ------------------ -// Create an empty texture -// -// Parameters: -// -// pDevice -// The D3D device with which the texture is going to be used. -// Width, Height, Depth, Size -// size in pixels. these must be non-zero -// MipLevels -// number of mip levels desired. if zero or D3DX_DEFAULT, a complete -// mipmap chain will be created. -// Usage -// Texture usage flags -// Format -// Pixel format. -// Pool -// Memory pool to be used to create texture -// ppTexture, ppCubeTexture, ppVolumeTexture -// The texture object that will be created -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCreateTexture( - LPDIRECT3DDEVICE9 pDevice, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - LPDIRECT3DTEXTURE9* ppTexture); - -HRESULT WINAPI - D3DXCreateCubeTexture( - LPDIRECT3DDEVICE9 pDevice, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - LPDIRECT3DCUBETEXTURE9* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTexture( - LPDIRECT3DDEVICE9 pDevice, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); - - - -//---------------------------------------------------------------------------- -// D3DXCreateTextureFromFile/Resource: -// ----------------------------------- -// Create a texture object from a file or resource. -// -// Parameters: -// -// pDevice -// The D3D device with which the texture is going to be used. -// pSrcFile -// File name. -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pvSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// Width, Height, Depth, Size -// Size in pixels. If zero or D3DX_DEFAULT, the size will be taken from -// the file and rounded up to a power of two. If D3DX_DEFAULT_NONPOW2, -// and the device supports NONPOW2 textures, the size will not be rounded. -// If D3DX_FROM_FILE, the size will be taken exactly as it is in the file, -// and the call will fail if this violates device capabilities. -// MipLevels -// Number of mip levels. If zero or D3DX_DEFAULT, a complete mipmap -// chain will be created. If D3DX_FROM_FILE, the size will be taken -// exactly as it is in the file, and the call will fail if this violates -// device capabilities. -// Usage -// Texture usage flags -// Format -// Desired pixel format. If D3DFMT_UNKNOWN, the format will be -// taken from the file. If D3DFMT_FROM_FILE, the format will be taken -// exactly as it is in the file, and the call will fail if the device does -// not support the given format. -// Pool -// Memory pool to be used to create texture -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// MipFilter -// D3DX_FILTER flags controlling how each miplevel is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_BOX. -// Use the D3DX_SKIP_DDS_MIP_LEVELS macro to specify both a filter and the -// number of mip levels to skip when loading DDS files. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// pPalette -// 256 color palette to be filled in, or NULL -// ppTexture, ppCubeTexture, ppVolumeTexture -// The texture object that will be created -// -//---------------------------------------------------------------------------- - -// FromFile - -HRESULT WINAPI - D3DXCreateTextureFromFileA( - LPDIRECT3DDEVICE9 pDevice, - LPCSTR pSrcFile, - LPDIRECT3DTEXTURE9* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromFileW( - LPDIRECT3DDEVICE9 pDevice, - LPCWSTR pSrcFile, - LPDIRECT3DTEXTURE9* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileW -#else -#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileA( - LPDIRECT3DDEVICE9 pDevice, - LPCSTR pSrcFile, - LPDIRECT3DCUBETEXTURE9* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileW( - LPDIRECT3DDEVICE9 pDevice, - LPCWSTR pSrcFile, - LPDIRECT3DCUBETEXTURE9* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileW -#else -#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileA( - LPDIRECT3DDEVICE9 pDevice, - LPCSTR pSrcFile, - LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileW( - LPDIRECT3DDEVICE9 pDevice, - LPCWSTR pSrcFile, - LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileW -#else -#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileA -#endif - - -// FromResource - -HRESULT WINAPI - D3DXCreateTextureFromResourceA( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPDIRECT3DTEXTURE9* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromResourceW( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPDIRECT3DTEXTURE9* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceW -#else -#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceA( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPDIRECT3DCUBETEXTURE9* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceW( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPDIRECT3DCUBETEXTURE9* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceW -#else -#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceA( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceW( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceW -#else -#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceA -#endif - - -// FromFileEx - -HRESULT WINAPI - D3DXCreateTextureFromFileExA( - LPDIRECT3DDEVICE9 pDevice, - LPCSTR pSrcFile, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE9* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromFileExW( - LPDIRECT3DDEVICE9 pDevice, - LPCWSTR pSrcFile, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE9* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExW -#else -#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileExA( - LPDIRECT3DDEVICE9 pDevice, - LPCSTR pSrcFile, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE9* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileExW( - LPDIRECT3DDEVICE9 pDevice, - LPCWSTR pSrcFile, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE9* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExW -#else -#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileExA( - LPDIRECT3DDEVICE9 pDevice, - LPCSTR pSrcFile, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileExW( - LPDIRECT3DDEVICE9 pDevice, - LPCWSTR pSrcFile, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExW -#else -#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExA -#endif - - -// FromResourceEx - -HRESULT WINAPI - D3DXCreateTextureFromResourceExA( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE9* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromResourceExW( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE9* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExW -#else -#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceExA( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE9* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceExW( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE9* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExW -#else -#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceExA( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceExW( - LPDIRECT3DDEVICE9 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExW -#else -#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExA -#endif - - -// FromFileInMemory - -HRESULT WINAPI - D3DXCreateTextureFromFileInMemory( - LPDIRECT3DDEVICE9 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPDIRECT3DTEXTURE9* ppTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileInMemory( - LPDIRECT3DDEVICE9 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPDIRECT3DCUBETEXTURE9* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileInMemory( - LPDIRECT3DDEVICE9 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); - - -// FromFileInMemoryEx - -HRESULT WINAPI - D3DXCreateTextureFromFileInMemoryEx( - LPDIRECT3DDEVICE9 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE9* ppTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileInMemoryEx( - LPDIRECT3DDEVICE9 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE9* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileInMemoryEx( - LPDIRECT3DDEVICE9 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); - - - -//---------------------------------------------------------------------------- -// D3DXSaveTextureToFile: -// ---------------------- -// Save a texture to a file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcTexture -// Source texture, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// -//---------------------------------------------------------------------------- - - -HRESULT WINAPI - D3DXSaveTextureToFileA( - LPCSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DBASETEXTURE9 pSrcTexture, - CONST PALETTEENTRY* pSrcPalette); - -HRESULT WINAPI - D3DXSaveTextureToFileW( - LPCWSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DBASETEXTURE9 pSrcTexture, - CONST PALETTEENTRY* pSrcPalette); - -#ifdef UNICODE -#define D3DXSaveTextureToFile D3DXSaveTextureToFileW -#else -#define D3DXSaveTextureToFile D3DXSaveTextureToFileA -#endif - - -//---------------------------------------------------------------------------- -// D3DXSaveTextureToFileInMemory: -// ---------------------- -// Save a texture to a file. -// -// Parameters: -// ppDestBuf -// address of a d3dxbuffer pointer to return the image data -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcTexture -// Source texture, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXSaveTextureToFileInMemory( - LPD3DXBUFFER* ppDestBuf, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DBASETEXTURE9 pSrcTexture, - CONST PALETTEENTRY* pSrcPalette); - - - - -////////////////////////////////////////////////////////////////////////////// -// Misc Texture APIs ///////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXFilterTexture: -// ------------------ -// Filters mipmaps levels of a texture. -// -// Parameters: -// pBaseTexture -// The texture object to be filtered -// pPalette -// 256 color palette to be used, or NULL for non-palettized formats -// SrcLevel -// The level whose image is used to generate the subsequent levels. -// Filter -// D3DX_FILTER flags controlling how each miplevel is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_BOX, -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXFilterTexture( - LPDIRECT3DBASETEXTURE9 pBaseTexture, - CONST PALETTEENTRY* pPalette, - UINT SrcLevel, - DWORD Filter); - -#define D3DXFilterCubeTexture D3DXFilterTexture -#define D3DXFilterVolumeTexture D3DXFilterTexture - - - -//---------------------------------------------------------------------------- -// D3DXFillTexture: -// ---------------- -// Uses a user provided function to fill each texel of each mip level of a -// given texture. -// -// Paramters: -// pTexture, pCubeTexture, pVolumeTexture -// Pointer to the texture to be filled. -// pFunction -// Pointer to user provided evalutor function which will be used to -// compute the value of each texel. -// pData -// Pointer to an arbitrary block of user defined data. This pointer -// will be passed to the function provided in pFunction -//----------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXFillTexture( - LPDIRECT3DTEXTURE9 pTexture, - LPD3DXFILL2D pFunction, - LPVOID pData); - -HRESULT WINAPI - D3DXFillCubeTexture( - LPDIRECT3DCUBETEXTURE9 pCubeTexture, - LPD3DXFILL3D pFunction, - LPVOID pData); - -HRESULT WINAPI - D3DXFillVolumeTexture( - LPDIRECT3DVOLUMETEXTURE9 pVolumeTexture, - LPD3DXFILL3D pFunction, - LPVOID pData); - -//--------------------------------------------------------------------------- -// D3DXFillTextureTX: -// ------------------ -// Uses a TX Shader target to function to fill each texel of each mip level -// of a given texture. The TX Shader target should be a compiled function -// taking 2 paramters and returning a float4 color. -// -// Paramters: -// pTexture, pCubeTexture, pVolumeTexture -// Pointer to the texture to be filled. -// pTextureShader -// Pointer to the texture shader to be used to fill in the texture -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXFillTextureTX( - LPDIRECT3DTEXTURE9 pTexture, - LPD3DXTEXTURESHADER pTextureShader); - - -HRESULT WINAPI - D3DXFillCubeTextureTX( - LPDIRECT3DCUBETEXTURE9 pCubeTexture, - LPD3DXTEXTURESHADER pTextureShader); - - -HRESULT WINAPI - D3DXFillVolumeTextureTX( - LPDIRECT3DVOLUMETEXTURE9 pVolumeTexture, - LPD3DXTEXTURESHADER pTextureShader); - - - -//---------------------------------------------------------------------------- -// D3DXComputeNormalMap: -// --------------------- -// Converts a height map into a normal map. The (x,y,z) components of each -// normal are mapped to the (r,g,b) channels of the output texture. -// -// Parameters -// pTexture -// Pointer to the destination texture -// pSrcTexture -// Pointer to the source heightmap texture -// pSrcPalette -// Source palette of 256 colors, or NULL -// Flags -// D3DX_NORMALMAP flags -// Channel -// D3DX_CHANNEL specifying source of height information -// Amplitude -// The constant value which the height information is multiplied by. -//--------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXComputeNormalMap( - LPDIRECT3DTEXTURE9 pTexture, - LPDIRECT3DTEXTURE9 pSrcTexture, - CONST PALETTEENTRY* pSrcPalette, - DWORD Flags, - DWORD Channel, - FLOAT Amplitude); - - - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX9TEX_H__ - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx9tex.h +// Content: D3DX texturing APIs +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx9.h" + +#ifndef __D3DX9TEX_H__ +#define __D3DX9TEX_H__ + + +//---------------------------------------------------------------------------- +// D3DX_FILTER flags: +// ------------------ +// +// A valid filter must contain one of these values: +// +// D3DX_FILTER_NONE +// No scaling or filtering will take place. Pixels outside the bounds +// of the source image are assumed to be transparent black. +// D3DX_FILTER_POINT +// Each destination pixel is computed by sampling the nearest pixel +// from the source image. +// D3DX_FILTER_LINEAR +// Each destination pixel is computed by linearly interpolating between +// the nearest pixels in the source image. This filter works best +// when the scale on each axis is less than 2. +// D3DX_FILTER_TRIANGLE +// Every pixel in the source image contributes equally to the +// destination image. This is the slowest of all the filters. +// D3DX_FILTER_BOX +// Each pixel is computed by averaging a 2x2(x2) box pixels from +// the source image. Only works when the dimensions of the +// destination are half those of the source. (as with mip maps) +// +// And can be OR'd with any of these optional flags: +// +// D3DX_FILTER_MIRROR_U +// Indicates that pixels off the edge of the texture on the U-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR_V +// Indicates that pixels off the edge of the texture on the V-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR_W +// Indicates that pixels off the edge of the texture on the W-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR +// Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V | +// D3DX_FILTER_MIRROR_V +// D3DX_FILTER_DITHER +// Dithers the resulting image using a 4x4 order dither pattern. +// D3DX_FILTER_SRGB_IN +// Denotes that the input data is in sRGB (gamma 2.2) colorspace. +// D3DX_FILTER_SRGB_OUT +// Denotes that the output data is in sRGB (gamma 2.2) colorspace. +// D3DX_FILTER_SRGB +// Same as specifying D3DX_FILTER_SRGB_IN | D3DX_FILTER_SRGB_OUT +// +//---------------------------------------------------------------------------- + +#define D3DX_FILTER_NONE (1 << 0) +#define D3DX_FILTER_POINT (2 << 0) +#define D3DX_FILTER_LINEAR (3 << 0) +#define D3DX_FILTER_TRIANGLE (4 << 0) +#define D3DX_FILTER_BOX (5 << 0) + +#define D3DX_FILTER_MIRROR_U (1 << 16) +#define D3DX_FILTER_MIRROR_V (2 << 16) +#define D3DX_FILTER_MIRROR_W (4 << 16) +#define D3DX_FILTER_MIRROR (7 << 16) + +#define D3DX_FILTER_DITHER (1 << 19) +#define D3DX_FILTER_DITHER_DIFFUSION (2 << 19) + +#define D3DX_FILTER_SRGB_IN (1 << 21) +#define D3DX_FILTER_SRGB_OUT (2 << 21) +#define D3DX_FILTER_SRGB (3 << 21) + + +//----------------------------------------------------------------------------- +// D3DX_SKIP_DDS_MIP_LEVELS is used to skip mip levels when loading a DDS file: +//----------------------------------------------------------------------------- + +#define D3DX_SKIP_DDS_MIP_LEVELS_MASK 0x1F +#define D3DX_SKIP_DDS_MIP_LEVELS_SHIFT 26 +#define D3DX_SKIP_DDS_MIP_LEVELS(levels, filter) ((((levels) & D3DX_SKIP_DDS_MIP_LEVELS_MASK) << D3DX_SKIP_DDS_MIP_LEVELS_SHIFT) | (filter)) + + + + +//---------------------------------------------------------------------------- +// D3DX_NORMALMAP flags: +// --------------------- +// These flags are used to control how D3DXComputeNormalMap generates normal +// maps. Any number of these flags may be OR'd together in any combination. +// +// D3DX_NORMALMAP_MIRROR_U +// Indicates that pixels off the edge of the texture on the U-axis +// should be mirrored, not wraped. +// D3DX_NORMALMAP_MIRROR_V +// Indicates that pixels off the edge of the texture on the V-axis +// should be mirrored, not wraped. +// D3DX_NORMALMAP_MIRROR +// Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V +// D3DX_NORMALMAP_INVERTSIGN +// Inverts the direction of each normal +// D3DX_NORMALMAP_COMPUTE_OCCLUSION +// Compute the per pixel Occlusion term and encodes it into the alpha. +// An Alpha of 1 means that the pixel is not obscured in anyway, and +// an alpha of 0 would mean that the pixel is completly obscured. +// +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- + +#define D3DX_NORMALMAP_MIRROR_U (1 << 16) +#define D3DX_NORMALMAP_MIRROR_V (2 << 16) +#define D3DX_NORMALMAP_MIRROR (3 << 16) +#define D3DX_NORMALMAP_INVERTSIGN (8 << 16) +#define D3DX_NORMALMAP_COMPUTE_OCCLUSION (16 << 16) + + + + +//---------------------------------------------------------------------------- +// D3DX_CHANNEL flags: +// ------------------- +// These flags are used by functions which operate on or more channels +// in a texture. +// +// D3DX_CHANNEL_RED +// Indicates the red channel should be used +// D3DX_CHANNEL_BLUE +// Indicates the blue channel should be used +// D3DX_CHANNEL_GREEN +// Indicates the green channel should be used +// D3DX_CHANNEL_ALPHA +// Indicates the alpha channel should be used +// D3DX_CHANNEL_LUMINANCE +// Indicates the luminaces of the red green and blue channels should be +// used. +// +//---------------------------------------------------------------------------- + +#define D3DX_CHANNEL_RED (1 << 0) +#define D3DX_CHANNEL_BLUE (1 << 1) +#define D3DX_CHANNEL_GREEN (1 << 2) +#define D3DX_CHANNEL_ALPHA (1 << 3) +#define D3DX_CHANNEL_LUMINANCE (1 << 4) + + + + +//---------------------------------------------------------------------------- +// D3DXIMAGE_FILEFORMAT: +// --------------------- +// This enum is used to describe supported image file formats. +// +//---------------------------------------------------------------------------- + +typedef enum _D3DXIMAGE_FILEFORMAT +{ + D3DXIFF_BMP = 0, + D3DXIFF_JPG = 1, + D3DXIFF_TGA = 2, + D3DXIFF_PNG = 3, + D3DXIFF_DDS = 4, + D3DXIFF_PPM = 5, + D3DXIFF_DIB = 6, + D3DXIFF_HDR = 7, //high dynamic range formats + D3DXIFF_PFM = 8, // + D3DXIFF_FORCE_DWORD = 0x7fffffff + +} D3DXIMAGE_FILEFORMAT; + + +//---------------------------------------------------------------------------- +// LPD3DXFILL2D and LPD3DXFILL3D: +// ------------------------------ +// Function types used by the texture fill functions. +// +// Parameters: +// pOut +// Pointer to a vector which the function uses to return its result. +// X,Y,Z,W will be mapped to R,G,B,A respectivly. +// pTexCoord +// Pointer to a vector containing the coordinates of the texel currently +// being evaluated. Textures and VolumeTexture texcoord components +// range from 0 to 1. CubeTexture texcoord component range from -1 to 1. +// pTexelSize +// Pointer to a vector containing the dimensions of the current texel. +// pData +// Pointer to user data. +// +//---------------------------------------------------------------------------- + +typedef VOID (WINAPI *LPD3DXFILL2D)(D3DXVECTOR4 *pOut, + CONST D3DXVECTOR2 *pTexCoord, CONST D3DXVECTOR2 *pTexelSize, LPVOID pData); + +typedef VOID (WINAPI *LPD3DXFILL3D)(D3DXVECTOR4 *pOut, + CONST D3DXVECTOR3 *pTexCoord, CONST D3DXVECTOR3 *pTexelSize, LPVOID pData); + + + +//---------------------------------------------------------------------------- +// D3DXIMAGE_INFO: +// --------------- +// This structure is used to return a rough description of what the +// the original contents of an image file looked like. +// +// Width +// Width of original image in pixels +// Height +// Height of original image in pixels +// Depth +// Depth of original image in pixels +// MipLevels +// Number of mip levels in original image +// Format +// D3D format which most closely describes the data in original image +// ResourceType +// D3DRESOURCETYPE representing the type of texture stored in the file. +// D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE. +// ImageFileFormat +// D3DXIMAGE_FILEFORMAT representing the format of the image file. +// +//---------------------------------------------------------------------------- + +typedef struct _D3DXIMAGE_INFO +{ + UINT Width; + UINT Height; + UINT Depth; + UINT MipLevels; + D3DFORMAT Format; + D3DRESOURCETYPE ResourceType; + D3DXIMAGE_FILEFORMAT ImageFileFormat; + +} D3DXIMAGE_INFO; + + + + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + + +////////////////////////////////////////////////////////////////////////////// +// Image File APIs /////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +; +//---------------------------------------------------------------------------- +// GetImageInfoFromFile/Resource: +// ------------------------------ +// Fills in a D3DXIMAGE_INFO struct with information about an image file. +// +// Parameters: +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXGetImageInfoFromFileA( + LPCSTR pSrcFile, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXGetImageInfoFromFileW( + LPCWSTR pSrcFile, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileW +#else +#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileA +#endif + + +HRESULT WINAPI + D3DXGetImageInfoFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXGetImageInfoFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceW +#else +#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceA +#endif + + +HRESULT WINAPI + D3DXGetImageInfoFromFileInMemory( + LPCVOID pSrcData, + UINT SrcDataSize, + D3DXIMAGE_INFO* pSrcInfo); + + + + +////////////////////////////////////////////////////////////////////////////// +// Load/Save Surface APIs //////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromFile/Resource: +// --------------------------------- +// Load surface from a file or resource +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcRect +// Source rectangle, or NULL for entire image +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromFileA( + LPDIRECT3DSURFACE9 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCSTR pSrcFile, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadSurfaceFromFileW( + LPDIRECT3DSURFACE9 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCWSTR pSrcFile, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileW +#else +#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileA +#endif + + + +HRESULT WINAPI + D3DXLoadSurfaceFromResourceA( + LPDIRECT3DSURFACE9 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadSurfaceFromResourceW( + LPDIRECT3DSURFACE9 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + +#ifdef UNICODE +#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceW +#else +#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceA +#endif + + + +HRESULT WINAPI + D3DXLoadSurfaceFromFileInMemory( + LPDIRECT3DSURFACE9 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCVOID pSrcData, + UINT SrcDataSize, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromSurface: +// --------------------------- +// Load surface from another surface (with color conversion) +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcSurface +// Source surface +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle, or NULL for entire surface +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromSurface( + LPDIRECT3DSURFACE9 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPDIRECT3DSURFACE9 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey); + + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromMemory: +// -------------------------- +// Load surface from memory. +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcMemory +// Pointer to the top-left corner of the source image in memory +// SrcFormat +// Pixel format of the source image. +// SrcPitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the width of one row of cells, in bytes. +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle. +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromMemory( + LPDIRECT3DSURFACE9 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCVOID pSrcMemory, + D3DFORMAT SrcFormat, + UINT SrcPitch, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey); + + +//---------------------------------------------------------------------------- +// D3DXSaveSurfaceToFile: +// ---------------------- +// Save a surface to a image file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcSurface +// Source surface, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle, or NULL for the entire image +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXSaveSurfaceToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DSURFACE9 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect); + +HRESULT WINAPI + D3DXSaveSurfaceToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DSURFACE9 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect); + +#ifdef UNICODE +#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW +#else +#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA +#endif + +//---------------------------------------------------------------------------- +// D3DXSaveSurfaceToFileInMemory: +// ---------------------- +// Save a surface to a image file. +// +// Parameters: +// ppDestBuf +// address of pointer to d3dxbuffer for returning data bits +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcSurface +// Source surface, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle, or NULL for the entire image +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXSaveSurfaceToFileInMemory( + LPD3DXBUFFER* ppDestBuf, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DSURFACE9 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect); + + +////////////////////////////////////////////////////////////////////////////// +// Load/Save Volume APIs ///////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromFile/Resource: +// -------------------------------- +// Load volume from a file or resource +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcBox +// Source box, or NULL for entire image +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromFileA( + LPDIRECT3DVOLUME9 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCSTR pSrcFile, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadVolumeFromFileW( + LPDIRECT3DVOLUME9 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCWSTR pSrcFile, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileW +#else +#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileA +#endif + + +HRESULT WINAPI + D3DXLoadVolumeFromResourceA( + LPDIRECT3DVOLUME9 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadVolumeFromResourceW( + LPDIRECT3DVOLUME9 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceW +#else +#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceA +#endif + + + +HRESULT WINAPI + D3DXLoadVolumeFromFileInMemory( + LPDIRECT3DVOLUME9 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCVOID pSrcData, + UINT SrcDataSize, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromVolume: +// ------------------------- +// Load volume from another volume (with color conversion) +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcVolume +// Source volume +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box, or NULL for entire volume +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromVolume( + LPDIRECT3DVOLUME9 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPDIRECT3DVOLUME9 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey); + + + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromMemory: +// ------------------------- +// Load volume from memory. +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcMemory +// Pointer to the top-left corner of the source volume in memory +// SrcFormat +// Pixel format of the source volume. +// SrcRowPitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the size of one row of cells, in bytes. +// SrcSlicePitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the size of one slice of cells, in bytes. +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box. +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromMemory( + LPDIRECT3DVOLUME9 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCVOID pSrcMemory, + D3DFORMAT SrcFormat, + UINT SrcRowPitch, + UINT SrcSlicePitch, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey); + + + +//---------------------------------------------------------------------------- +// D3DXSaveVolumeToFile: +// --------------------- +// Save a volume to a image file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcVolume +// Source volume, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box, or NULL for the entire volume +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXSaveVolumeToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DVOLUME9 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox); + +HRESULT WINAPI + D3DXSaveVolumeToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DVOLUME9 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox); + +#ifdef UNICODE +#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileW +#else +#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileA +#endif + + +//---------------------------------------------------------------------------- +// D3DXSaveVolumeToFileInMemory: +// --------------------- +// Save a volume to a image file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcVolume +// Source volume, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box, or NULL for the entire volume +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXSaveVolumeToFileInMemory( + LPD3DXBUFFER* ppDestBuf, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DVOLUME9 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox); + +////////////////////////////////////////////////////////////////////////////// +// Create/Save Texture APIs ////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXCheckTextureRequirements: +// ----------------------------- +// Checks texture creation parameters. If parameters are invalid, this +// function returns corrected parameters. +// +// Parameters: +// +// pDevice +// The D3D device to be used +// pWidth, pHeight, pDepth, pSize +// Desired size in pixels, or NULL. Returns corrected size. +// pNumMipLevels +// Number of desired mipmap levels, or NULL. Returns corrected number. +// Usage +// Texture usage flags +// pFormat +// Desired pixel format, or NULL. Returns corrected format. +// Pool +// Memory pool to be used to create texture +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCheckTextureRequirements( + LPDIRECT3DDEVICE9 pDevice, + UINT* pWidth, + UINT* pHeight, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + +HRESULT WINAPI + D3DXCheckCubeTextureRequirements( + LPDIRECT3DDEVICE9 pDevice, + UINT* pSize, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + +HRESULT WINAPI + D3DXCheckVolumeTextureRequirements( + LPDIRECT3DDEVICE9 pDevice, + UINT* pWidth, + UINT* pHeight, + UINT* pDepth, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + + +//---------------------------------------------------------------------------- +// D3DXCreateTexture: +// ------------------ +// Create an empty texture +// +// Parameters: +// +// pDevice +// The D3D device with which the texture is going to be used. +// Width, Height, Depth, Size +// size in pixels. these must be non-zero +// MipLevels +// number of mip levels desired. if zero or D3DX_DEFAULT, a complete +// mipmap chain will be created. +// Usage +// Texture usage flags +// Format +// Pixel format. +// Pool +// Memory pool to be used to create texture +// ppTexture, ppCubeTexture, ppVolumeTexture +// The texture object that will be created +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCreateTexture( + LPDIRECT3DDEVICE9 pDevice, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DTEXTURE9* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTexture( + LPDIRECT3DDEVICE9 pDevice, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DCUBETEXTURE9* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTexture( + LPDIRECT3DDEVICE9 pDevice, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); + + + +//---------------------------------------------------------------------------- +// D3DXCreateTextureFromFile/Resource: +// ----------------------------------- +// Create a texture object from a file or resource. +// +// Parameters: +// +// pDevice +// The D3D device with which the texture is going to be used. +// pSrcFile +// File name. +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pvSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// Width, Height, Depth, Size +// Size in pixels. If zero or D3DX_DEFAULT, the size will be taken from +// the file and rounded up to a power of two. If D3DX_DEFAULT_NONPOW2, +// and the device supports NONPOW2 textures, the size will not be rounded. +// If D3DX_FROM_FILE, the size will be taken exactly as it is in the file, +// and the call will fail if this violates device capabilities. +// MipLevels +// Number of mip levels. If zero or D3DX_DEFAULT, a complete mipmap +// chain will be created. If D3DX_FROM_FILE, the size will be taken +// exactly as it is in the file, and the call will fail if this violates +// device capabilities. +// Usage +// Texture usage flags +// Format +// Desired pixel format. If D3DFMT_UNKNOWN, the format will be +// taken from the file. If D3DFMT_FROM_FILE, the format will be taken +// exactly as it is in the file, and the call will fail if the device does +// not support the given format. +// Pool +// Memory pool to be used to create texture +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// MipFilter +// D3DX_FILTER flags controlling how each miplevel is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_BOX. +// Use the D3DX_SKIP_DDS_MIP_LEVELS macro to specify both a filter and the +// number of mip levels to skip when loading DDS files. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// pPalette +// 256 color palette to be filled in, or NULL +// ppTexture, ppCubeTexture, ppVolumeTexture +// The texture object that will be created +// +//---------------------------------------------------------------------------- + +// FromFile + +HRESULT WINAPI + D3DXCreateTextureFromFileA( + LPDIRECT3DDEVICE9 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DTEXTURE9* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromFileW( + LPDIRECT3DDEVICE9 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DTEXTURE9* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileW +#else +#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileA( + LPDIRECT3DDEVICE9 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DCUBETEXTURE9* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileW( + LPDIRECT3DDEVICE9 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DCUBETEXTURE9* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileW +#else +#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileA( + LPDIRECT3DDEVICE9 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileW( + LPDIRECT3DDEVICE9 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileW +#else +#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileA +#endif + + +// FromResource + +HRESULT WINAPI + D3DXCreateTextureFromResourceA( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DTEXTURE9* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromResourceW( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DTEXTURE9* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceW +#else +#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceA( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DCUBETEXTURE9* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceW( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DCUBETEXTURE9* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceW +#else +#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceA( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceW( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceW +#else +#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceA +#endif + + +// FromFileEx + +HRESULT WINAPI + D3DXCreateTextureFromFileExA( + LPDIRECT3DDEVICE9 pDevice, + LPCSTR pSrcFile, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE9* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromFileExW( + LPDIRECT3DDEVICE9 pDevice, + LPCWSTR pSrcFile, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE9* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExW +#else +#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileExA( + LPDIRECT3DDEVICE9 pDevice, + LPCSTR pSrcFile, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE9* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileExW( + LPDIRECT3DDEVICE9 pDevice, + LPCWSTR pSrcFile, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE9* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExW +#else +#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileExA( + LPDIRECT3DDEVICE9 pDevice, + LPCSTR pSrcFile, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileExW( + LPDIRECT3DDEVICE9 pDevice, + LPCWSTR pSrcFile, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExW +#else +#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExA +#endif + + +// FromResourceEx + +HRESULT WINAPI + D3DXCreateTextureFromResourceExA( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE9* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromResourceExW( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE9* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExW +#else +#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceExA( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE9* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceExW( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE9* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExW +#else +#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceExA( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceExW( + LPDIRECT3DDEVICE9 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExW +#else +#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExA +#endif + + +// FromFileInMemory + +HRESULT WINAPI + D3DXCreateTextureFromFileInMemory( + LPDIRECT3DDEVICE9 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DTEXTURE9* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileInMemory( + LPDIRECT3DDEVICE9 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DCUBETEXTURE9* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileInMemory( + LPDIRECT3DDEVICE9 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); + + +// FromFileInMemoryEx + +HRESULT WINAPI + D3DXCreateTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE9 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE9* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE9 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE9* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE9 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture); + + + +//---------------------------------------------------------------------------- +// D3DXSaveTextureToFile: +// ---------------------- +// Save a texture to a file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcTexture +// Source texture, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// +//---------------------------------------------------------------------------- + + +HRESULT WINAPI + D3DXSaveTextureToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DBASETEXTURE9 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette); + +HRESULT WINAPI + D3DXSaveTextureToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DBASETEXTURE9 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette); + +#ifdef UNICODE +#define D3DXSaveTextureToFile D3DXSaveTextureToFileW +#else +#define D3DXSaveTextureToFile D3DXSaveTextureToFileA +#endif + + +//---------------------------------------------------------------------------- +// D3DXSaveTextureToFileInMemory: +// ---------------------- +// Save a texture to a file. +// +// Parameters: +// ppDestBuf +// address of a d3dxbuffer pointer to return the image data +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcTexture +// Source texture, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXSaveTextureToFileInMemory( + LPD3DXBUFFER* ppDestBuf, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DBASETEXTURE9 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette); + + + + +////////////////////////////////////////////////////////////////////////////// +// Misc Texture APIs ///////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXFilterTexture: +// ------------------ +// Filters mipmaps levels of a texture. +// +// Parameters: +// pBaseTexture +// The texture object to be filtered +// pPalette +// 256 color palette to be used, or NULL for non-palettized formats +// SrcLevel +// The level whose image is used to generate the subsequent levels. +// Filter +// D3DX_FILTER flags controlling how each miplevel is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_BOX, +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXFilterTexture( + LPDIRECT3DBASETEXTURE9 pBaseTexture, + CONST PALETTEENTRY* pPalette, + UINT SrcLevel, + DWORD Filter); + +#define D3DXFilterCubeTexture D3DXFilterTexture +#define D3DXFilterVolumeTexture D3DXFilterTexture + + + +//---------------------------------------------------------------------------- +// D3DXFillTexture: +// ---------------- +// Uses a user provided function to fill each texel of each mip level of a +// given texture. +// +// Paramters: +// pTexture, pCubeTexture, pVolumeTexture +// Pointer to the texture to be filled. +// pFunction +// Pointer to user provided evalutor function which will be used to +// compute the value of each texel. +// pData +// Pointer to an arbitrary block of user defined data. This pointer +// will be passed to the function provided in pFunction +//----------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXFillTexture( + LPDIRECT3DTEXTURE9 pTexture, + LPD3DXFILL2D pFunction, + LPVOID pData); + +HRESULT WINAPI + D3DXFillCubeTexture( + LPDIRECT3DCUBETEXTURE9 pCubeTexture, + LPD3DXFILL3D pFunction, + LPVOID pData); + +HRESULT WINAPI + D3DXFillVolumeTexture( + LPDIRECT3DVOLUMETEXTURE9 pVolumeTexture, + LPD3DXFILL3D pFunction, + LPVOID pData); + +//--------------------------------------------------------------------------- +// D3DXFillTextureTX: +// ------------------ +// Uses a TX Shader target to function to fill each texel of each mip level +// of a given texture. The TX Shader target should be a compiled function +// taking 2 paramters and returning a float4 color. +// +// Paramters: +// pTexture, pCubeTexture, pVolumeTexture +// Pointer to the texture to be filled. +// pTextureShader +// Pointer to the texture shader to be used to fill in the texture +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXFillTextureTX( + LPDIRECT3DTEXTURE9 pTexture, + LPD3DXTEXTURESHADER pTextureShader); + + +HRESULT WINAPI + D3DXFillCubeTextureTX( + LPDIRECT3DCUBETEXTURE9 pCubeTexture, + LPD3DXTEXTURESHADER pTextureShader); + + +HRESULT WINAPI + D3DXFillVolumeTextureTX( + LPDIRECT3DVOLUMETEXTURE9 pVolumeTexture, + LPD3DXTEXTURESHADER pTextureShader); + + + +//---------------------------------------------------------------------------- +// D3DXComputeNormalMap: +// --------------------- +// Converts a height map into a normal map. The (x,y,z) components of each +// normal are mapped to the (r,g,b) channels of the output texture. +// +// Parameters +// pTexture +// Pointer to the destination texture +// pSrcTexture +// Pointer to the source heightmap texture +// pSrcPalette +// Source palette of 256 colors, or NULL +// Flags +// D3DX_NORMALMAP flags +// Channel +// D3DX_CHANNEL specifying source of height information +// Amplitude +// The constant value which the height information is multiplied by. +//--------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXComputeNormalMap( + LPDIRECT3DTEXTURE9 pTexture, + LPDIRECT3DTEXTURE9 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette, + DWORD Flags, + DWORD Channel, + FLOAT Amplitude); + + + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX9TEX_H__ + diff --git a/src/dep/include/DXSDK/include/d3dx9xof.h b/src/dep/include/DXSDK/include/d3dx9xof.h index 6edb926..c513f0f 100644 --- a/src/dep/include/DXSDK/include/d3dx9xof.h +++ b/src/dep/include/DXSDK/include/d3dx9xof.h @@ -1,299 +1,299 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx9xof.h -// Content: D3DX .X File types and functions -// -/////////////////////////////////////////////////////////////////////////// - -#include "d3dx9.h" - -#if !defined( __D3DX9XOF_H__ ) -#define __D3DX9XOF_H__ - -#if defined( __cplusplus ) -extern "C" { -#endif // defined( __cplusplus ) - -//---------------------------------------------------------------------------- -// D3DXF_FILEFORMAT -// This flag is used to specify what file type to use when saving to disk. -// _BINARY, and _TEXT are mutually exclusive, while -// _COMPRESSED is an optional setting that works with all file types. -//---------------------------------------------------------------------------- -typedef DWORD D3DXF_FILEFORMAT; - -#define D3DXF_FILEFORMAT_BINARY 0 -#define D3DXF_FILEFORMAT_TEXT 1 -#define D3DXF_FILEFORMAT_COMPRESSED 2 - -//---------------------------------------------------------------------------- -// D3DXF_FILESAVEOPTIONS -// This flag is used to specify where to save the file to. Each flag is -// mutually exclusive, indicates the data location of the file, and also -// chooses which additional data will specify the location. -// _TOFILE is paired with a filename (LPCSTR) -// _TOWFILE is paired with a filename (LPWSTR) -//---------------------------------------------------------------------------- -typedef DWORD D3DXF_FILESAVEOPTIONS; - -#define D3DXF_FILESAVE_TOFILE 0x00L -#define D3DXF_FILESAVE_TOWFILE 0x01L - -//---------------------------------------------------------------------------- -// D3DXF_FILELOADOPTIONS -// This flag is used to specify where to load the file from. Each flag is -// mutually exclusive, indicates the data location of the file, and also -// chooses which additional data will specify the location. -// _FROMFILE is paired with a filename (LPCSTR) -// _FROMWFILE is paired with a filename (LPWSTR) -// _FROMRESOURCE is paired with a (D3DXF_FILELOADRESOUCE*) description. -// _FROMMEMORY is paired with a (D3DXF_FILELOADMEMORY*) description. -//---------------------------------------------------------------------------- -typedef DWORD D3DXF_FILELOADOPTIONS; - -#define D3DXF_FILELOAD_FROMFILE 0x00L -#define D3DXF_FILELOAD_FROMWFILE 0x01L -#define D3DXF_FILELOAD_FROMRESOURCE 0x02L -#define D3DXF_FILELOAD_FROMMEMORY 0x03L - -//---------------------------------------------------------------------------- -// D3DXF_FILELOADRESOURCE: -//---------------------------------------------------------------------------- - -typedef struct _D3DXF_FILELOADRESOURCE -{ - HMODULE hModule; // Desc - LPCSTR lpName; // Desc - LPCSTR lpType; // Desc -} D3DXF_FILELOADRESOURCE; - -//---------------------------------------------------------------------------- -// D3DXF_FILELOADMEMORY: -//---------------------------------------------------------------------------- - -typedef struct _D3DXF_FILELOADMEMORY -{ - LPCVOID lpMemory; // Desc - SIZE_T dSize; // Desc -} D3DXF_FILELOADMEMORY; - -#if defined( _WIN32 ) && !defined( _NO_COM ) - -// {cef08cf9-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFile, -0xcef08cf9, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); - -// {cef08cfa-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFileSaveObject, -0xcef08cfa, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); - -// {cef08cfb-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFileSaveData, -0xcef08cfb, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); - -// {cef08cfc-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFileEnumObject, -0xcef08cfc, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); - -// {cef08cfd-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFileData, -0xcef08cfd, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); - -#endif // defined( _WIN32 ) && !defined( _NO_COM ) - -#if defined( __cplusplus ) -#if !defined( DECLSPEC_UUID ) -#if _MSC_VER >= 1100 -#define DECLSPEC_UUID( x ) __declspec( uuid( x ) ) -#else // !( _MSC_VER >= 1100 ) -#define DECLSPEC_UUID( x ) -#endif // !( _MSC_VER >= 1100 ) -#endif // !defined( DECLSPEC_UUID ) - -interface DECLSPEC_UUID( "cef08cf9-7b4f-4429-9624-2a690a933201" ) - ID3DXFile; -interface DECLSPEC_UUID( "cef08cfa-7b4f-4429-9624-2a690a933201" ) - ID3DXFileSaveObject; -interface DECLSPEC_UUID( "cef08cfb-7b4f-4429-9624-2a690a933201" ) - ID3DXFileSaveData; -interface DECLSPEC_UUID( "cef08cfc-7b4f-4429-9624-2a690a933201" ) - ID3DXFileEnumObject; -interface DECLSPEC_UUID( "cef08cfd-7b4f-4429-9624-2a690a933201" ) - ID3DXFileData; - -#if defined( _COM_SMARTPTR_TYPEDEF ) -_COM_SMARTPTR_TYPEDEF( ID3DXFile, - __uuidof( ID3DXFile ) ); -_COM_SMARTPTR_TYPEDEF( ID3DXFileSaveObject, - __uuidof( ID3DXFileSaveObject ) ); -_COM_SMARTPTR_TYPEDEF( ID3DXFileSaveData, - __uuidof( ID3DXFileSaveData ) ); -_COM_SMARTPTR_TYPEDEF( ID3DXFileEnumObject, - __uuidof( ID3DXFileEnumObject ) ); -_COM_SMARTPTR_TYPEDEF( ID3DXFileData, - __uuidof( ID3DXFileData ) ); -#endif // defined( _COM_SMARTPTR_TYPEDEF ) -#endif // defined( __cplusplus ) - -typedef interface ID3DXFile ID3DXFile; -typedef interface ID3DXFileSaveObject ID3DXFileSaveObject; -typedef interface ID3DXFileSaveData ID3DXFileSaveData; -typedef interface ID3DXFileEnumObject ID3DXFileEnumObject; -typedef interface ID3DXFileData ID3DXFileData; - -////////////////////////////////////////////////////////////////////////////// -// ID3DXFile ///////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#undef INTERFACE -#define INTERFACE ID3DXFile - -DECLARE_INTERFACE_( ID3DXFile, IUnknown ) -{ - STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; - STDMETHOD_( ULONG, AddRef )( THIS ) PURE; - STDMETHOD_( ULONG, Release )( THIS ) PURE; - - STDMETHOD( CreateEnumObject )( THIS_ LPCVOID, D3DXF_FILELOADOPTIONS, - ID3DXFileEnumObject** ) PURE; - STDMETHOD( CreateSaveObject )( THIS_ LPCVOID, D3DXF_FILESAVEOPTIONS, - D3DXF_FILEFORMAT, ID3DXFileSaveObject** ) PURE; - STDMETHOD( RegisterTemplates )( THIS_ LPCVOID, SIZE_T ) PURE; - STDMETHOD( RegisterEnumTemplates )( THIS_ ID3DXFileEnumObject* ) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DXFileSaveObject /////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#undef INTERFACE -#define INTERFACE ID3DXFileSaveObject - -DECLARE_INTERFACE_( ID3DXFileSaveObject, IUnknown ) -{ - STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; - STDMETHOD_( ULONG, AddRef )( THIS ) PURE; - STDMETHOD_( ULONG, Release )( THIS ) PURE; - - STDMETHOD( GetFile )( THIS_ ID3DXFile** ) PURE; - STDMETHOD( AddDataObject )( THIS_ REFGUID, LPCSTR, CONST GUID*, - SIZE_T, LPCVOID, ID3DXFileSaveData** ) PURE; - STDMETHOD( Save )( THIS ) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DXFileSaveData ///////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#undef INTERFACE -#define INTERFACE ID3DXFileSaveData - -DECLARE_INTERFACE_( ID3DXFileSaveData, IUnknown ) -{ - STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; - STDMETHOD_( ULONG, AddRef )( THIS ) PURE; - STDMETHOD_( ULONG, Release )( THIS ) PURE; - - STDMETHOD( GetSave )( THIS_ ID3DXFileSaveObject** ) PURE; - STDMETHOD( GetName )( THIS_ LPSTR, SIZE_T* ) PURE; - STDMETHOD( GetId )( THIS_ LPGUID ) PURE; - STDMETHOD( GetType )( THIS_ GUID* ) PURE; - STDMETHOD( AddDataObject )( THIS_ REFGUID, LPCSTR, CONST GUID*, - SIZE_T, LPCVOID, ID3DXFileSaveData** ) PURE; - STDMETHOD( AddDataReference )( THIS_ LPCSTR, CONST GUID* ) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DXFileEnumObject /////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#undef INTERFACE -#define INTERFACE ID3DXFileEnumObject - -DECLARE_INTERFACE_( ID3DXFileEnumObject, IUnknown ) -{ - STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; - STDMETHOD_( ULONG, AddRef )( THIS ) PURE; - STDMETHOD_( ULONG, Release )( THIS ) PURE; - - STDMETHOD( GetFile )( THIS_ ID3DXFile** ) PURE; - STDMETHOD( GetChildren )( THIS_ SIZE_T* ) PURE; - STDMETHOD( GetChild )( THIS_ SIZE_T, ID3DXFileData** ) PURE; - STDMETHOD( GetDataObjectById )( THIS_ REFGUID, ID3DXFileData** ) PURE; - STDMETHOD( GetDataObjectByName )( THIS_ LPCSTR, ID3DXFileData** ) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DXFileData ///////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#undef INTERFACE -#define INTERFACE ID3DXFileData - -DECLARE_INTERFACE_( ID3DXFileData, IUnknown ) -{ - STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; - STDMETHOD_( ULONG, AddRef )( THIS ) PURE; - STDMETHOD_( ULONG, Release )( THIS ) PURE; - - STDMETHOD( GetEnum )( THIS_ ID3DXFileEnumObject** ) PURE; - STDMETHOD( GetName )( THIS_ LPSTR, SIZE_T* ) PURE; - STDMETHOD( GetId )( THIS_ LPGUID ) PURE; - STDMETHOD( Lock )( THIS_ SIZE_T*, LPCVOID* ) PURE; - STDMETHOD( Unlock )( THIS ) PURE; - STDMETHOD( GetType )( THIS_ GUID* ) PURE; - STDMETHOD_( BOOL, IsReference )( THIS ) PURE; - STDMETHOD( GetChildren )( THIS_ SIZE_T* ) PURE; - STDMETHOD( GetChild )( THIS_ SIZE_T, ID3DXFileData** ) PURE; -}; - -STDAPI D3DXFileCreate( ID3DXFile** lplpDirectXFile ); - -/* - * DirectX File errors. - */ - -#define _FACD3DXF 0x876 - -#define D3DXFERR_BADOBJECT MAKE_HRESULT( 1, _FACD3DXF, 900 ) -#define D3DXFERR_BADVALUE MAKE_HRESULT( 1, _FACD3DXF, 901 ) -#define D3DXFERR_BADTYPE MAKE_HRESULT( 1, _FACD3DXF, 902 ) -#define D3DXFERR_NOTFOUND MAKE_HRESULT( 1, _FACD3DXF, 903 ) -#define D3DXFERR_NOTDONEYET MAKE_HRESULT( 1, _FACD3DXF, 904 ) -#define D3DXFERR_FILENOTFOUND MAKE_HRESULT( 1, _FACD3DXF, 905 ) -#define D3DXFERR_RESOURCENOTFOUND MAKE_HRESULT( 1, _FACD3DXF, 906 ) -#define D3DXFERR_BADRESOURCE MAKE_HRESULT( 1, _FACD3DXF, 907 ) -#define D3DXFERR_BADFILETYPE MAKE_HRESULT( 1, _FACD3DXF, 908 ) -#define D3DXFERR_BADFILEVERSION MAKE_HRESULT( 1, _FACD3DXF, 909 ) -#define D3DXFERR_BADFILEFLOATSIZE MAKE_HRESULT( 1, _FACD3DXF, 910 ) -#define D3DXFERR_BADFILE MAKE_HRESULT( 1, _FACD3DXF, 911 ) -#define D3DXFERR_PARSEERROR MAKE_HRESULT( 1, _FACD3DXF, 912 ) -#define D3DXFERR_BADARRAYSIZE MAKE_HRESULT( 1, _FACD3DXF, 913 ) -#define D3DXFERR_BADDATAREFERENCE MAKE_HRESULT( 1, _FACD3DXF, 914 ) -#define D3DXFERR_NOMOREOBJECTS MAKE_HRESULT( 1, _FACD3DXF, 915 ) -#define D3DXFERR_NOMOREDATA MAKE_HRESULT( 1, _FACD3DXF, 916 ) -#define D3DXFERR_BADCACHEFILE MAKE_HRESULT( 1, _FACD3DXF, 917 ) - -/* - * DirectX File object types. - */ - -#ifndef WIN_TYPES -#define WIN_TYPES(itype, ptype) typedef interface itype *LP##ptype, **LPLP##ptype -#endif - -WIN_TYPES(ID3DXFile, D3DXFILE); -WIN_TYPES(ID3DXFileEnumObject, D3DXFILEENUMOBJECT); -WIN_TYPES(ID3DXFileSaveObject, D3DXFILESAVEOBJECT); -WIN_TYPES(ID3DXFileData, D3DXFILEDATA); -WIN_TYPES(ID3DXFileSaveData, D3DXFILESAVEDATA); - -#if defined( __cplusplus ) -} // extern "C" -#endif // defined( __cplusplus ) - -#endif // !defined( __D3DX9XOF_H__ ) - - +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx9xof.h +// Content: D3DX .X File types and functions +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx9.h" + +#if !defined( __D3DX9XOF_H__ ) +#define __D3DX9XOF_H__ + +#if defined( __cplusplus ) +extern "C" { +#endif // defined( __cplusplus ) + +//---------------------------------------------------------------------------- +// D3DXF_FILEFORMAT +// This flag is used to specify what file type to use when saving to disk. +// _BINARY, and _TEXT are mutually exclusive, while +// _COMPRESSED is an optional setting that works with all file types. +//---------------------------------------------------------------------------- +typedef DWORD D3DXF_FILEFORMAT; + +#define D3DXF_FILEFORMAT_BINARY 0 +#define D3DXF_FILEFORMAT_TEXT 1 +#define D3DXF_FILEFORMAT_COMPRESSED 2 + +//---------------------------------------------------------------------------- +// D3DXF_FILESAVEOPTIONS +// This flag is used to specify where to save the file to. Each flag is +// mutually exclusive, indicates the data location of the file, and also +// chooses which additional data will specify the location. +// _TOFILE is paired with a filename (LPCSTR) +// _TOWFILE is paired with a filename (LPWSTR) +//---------------------------------------------------------------------------- +typedef DWORD D3DXF_FILESAVEOPTIONS; + +#define D3DXF_FILESAVE_TOFILE 0x00L +#define D3DXF_FILESAVE_TOWFILE 0x01L + +//---------------------------------------------------------------------------- +// D3DXF_FILELOADOPTIONS +// This flag is used to specify where to load the file from. Each flag is +// mutually exclusive, indicates the data location of the file, and also +// chooses which additional data will specify the location. +// _FROMFILE is paired with a filename (LPCSTR) +// _FROMWFILE is paired with a filename (LPWSTR) +// _FROMRESOURCE is paired with a (D3DXF_FILELOADRESOUCE*) description. +// _FROMMEMORY is paired with a (D3DXF_FILELOADMEMORY*) description. +//---------------------------------------------------------------------------- +typedef DWORD D3DXF_FILELOADOPTIONS; + +#define D3DXF_FILELOAD_FROMFILE 0x00L +#define D3DXF_FILELOAD_FROMWFILE 0x01L +#define D3DXF_FILELOAD_FROMRESOURCE 0x02L +#define D3DXF_FILELOAD_FROMMEMORY 0x03L + +//---------------------------------------------------------------------------- +// D3DXF_FILELOADRESOURCE: +//---------------------------------------------------------------------------- + +typedef struct _D3DXF_FILELOADRESOURCE +{ + HMODULE hModule; // Desc + LPCSTR lpName; // Desc + LPCSTR lpType; // Desc +} D3DXF_FILELOADRESOURCE; + +//---------------------------------------------------------------------------- +// D3DXF_FILELOADMEMORY: +//---------------------------------------------------------------------------- + +typedef struct _D3DXF_FILELOADMEMORY +{ + LPCVOID lpMemory; // Desc + SIZE_T dSize; // Desc +} D3DXF_FILELOADMEMORY; + +#if defined( _WIN32 ) && !defined( _NO_COM ) + +// {cef08cf9-7b4f-4429-9624-2a690a933201} +DEFINE_GUID( IID_ID3DXFile, +0xcef08cf9, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); + +// {cef08cfa-7b4f-4429-9624-2a690a933201} +DEFINE_GUID( IID_ID3DXFileSaveObject, +0xcef08cfa, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); + +// {cef08cfb-7b4f-4429-9624-2a690a933201} +DEFINE_GUID( IID_ID3DXFileSaveData, +0xcef08cfb, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); + +// {cef08cfc-7b4f-4429-9624-2a690a933201} +DEFINE_GUID( IID_ID3DXFileEnumObject, +0xcef08cfc, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); + +// {cef08cfd-7b4f-4429-9624-2a690a933201} +DEFINE_GUID( IID_ID3DXFileData, +0xcef08cfd, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); + +#endif // defined( _WIN32 ) && !defined( _NO_COM ) + +#if defined( __cplusplus ) +#if !defined( DECLSPEC_UUID ) +#if _MSC_VER >= 1100 +#define DECLSPEC_UUID( x ) __declspec( uuid( x ) ) +#else // !( _MSC_VER >= 1100 ) +#define DECLSPEC_UUID( x ) +#endif // !( _MSC_VER >= 1100 ) +#endif // !defined( DECLSPEC_UUID ) + +interface DECLSPEC_UUID( "cef08cf9-7b4f-4429-9624-2a690a933201" ) + ID3DXFile; +interface DECLSPEC_UUID( "cef08cfa-7b4f-4429-9624-2a690a933201" ) + ID3DXFileSaveObject; +interface DECLSPEC_UUID( "cef08cfb-7b4f-4429-9624-2a690a933201" ) + ID3DXFileSaveData; +interface DECLSPEC_UUID( "cef08cfc-7b4f-4429-9624-2a690a933201" ) + ID3DXFileEnumObject; +interface DECLSPEC_UUID( "cef08cfd-7b4f-4429-9624-2a690a933201" ) + ID3DXFileData; + +#if defined( _COM_SMARTPTR_TYPEDEF ) +_COM_SMARTPTR_TYPEDEF( ID3DXFile, + __uuidof( ID3DXFile ) ); +_COM_SMARTPTR_TYPEDEF( ID3DXFileSaveObject, + __uuidof( ID3DXFileSaveObject ) ); +_COM_SMARTPTR_TYPEDEF( ID3DXFileSaveData, + __uuidof( ID3DXFileSaveData ) ); +_COM_SMARTPTR_TYPEDEF( ID3DXFileEnumObject, + __uuidof( ID3DXFileEnumObject ) ); +_COM_SMARTPTR_TYPEDEF( ID3DXFileData, + __uuidof( ID3DXFileData ) ); +#endif // defined( _COM_SMARTPTR_TYPEDEF ) +#endif // defined( __cplusplus ) + +typedef interface ID3DXFile ID3DXFile; +typedef interface ID3DXFileSaveObject ID3DXFileSaveObject; +typedef interface ID3DXFileSaveData ID3DXFileSaveData; +typedef interface ID3DXFileEnumObject ID3DXFileEnumObject; +typedef interface ID3DXFileData ID3DXFileData; + +////////////////////////////////////////////////////////////////////////////// +// ID3DXFile ///////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +#undef INTERFACE +#define INTERFACE ID3DXFile + +DECLARE_INTERFACE_( ID3DXFile, IUnknown ) +{ + STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; + STDMETHOD_( ULONG, AddRef )( THIS ) PURE; + STDMETHOD_( ULONG, Release )( THIS ) PURE; + + STDMETHOD( CreateEnumObject )( THIS_ LPCVOID, D3DXF_FILELOADOPTIONS, + ID3DXFileEnumObject** ) PURE; + STDMETHOD( CreateSaveObject )( THIS_ LPCVOID, D3DXF_FILESAVEOPTIONS, + D3DXF_FILEFORMAT, ID3DXFileSaveObject** ) PURE; + STDMETHOD( RegisterTemplates )( THIS_ LPCVOID, SIZE_T ) PURE; + STDMETHOD( RegisterEnumTemplates )( THIS_ ID3DXFileEnumObject* ) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3DXFileSaveObject /////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +#undef INTERFACE +#define INTERFACE ID3DXFileSaveObject + +DECLARE_INTERFACE_( ID3DXFileSaveObject, IUnknown ) +{ + STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; + STDMETHOD_( ULONG, AddRef )( THIS ) PURE; + STDMETHOD_( ULONG, Release )( THIS ) PURE; + + STDMETHOD( GetFile )( THIS_ ID3DXFile** ) PURE; + STDMETHOD( AddDataObject )( THIS_ REFGUID, LPCSTR, CONST GUID*, + SIZE_T, LPCVOID, ID3DXFileSaveData** ) PURE; + STDMETHOD( Save )( THIS ) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3DXFileSaveData ///////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +#undef INTERFACE +#define INTERFACE ID3DXFileSaveData + +DECLARE_INTERFACE_( ID3DXFileSaveData, IUnknown ) +{ + STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; + STDMETHOD_( ULONG, AddRef )( THIS ) PURE; + STDMETHOD_( ULONG, Release )( THIS ) PURE; + + STDMETHOD( GetSave )( THIS_ ID3DXFileSaveObject** ) PURE; + STDMETHOD( GetName )( THIS_ LPSTR, SIZE_T* ) PURE; + STDMETHOD( GetId )( THIS_ LPGUID ) PURE; + STDMETHOD( GetType )( THIS_ GUID* ) PURE; + STDMETHOD( AddDataObject )( THIS_ REFGUID, LPCSTR, CONST GUID*, + SIZE_T, LPCVOID, ID3DXFileSaveData** ) PURE; + STDMETHOD( AddDataReference )( THIS_ LPCSTR, CONST GUID* ) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3DXFileEnumObject /////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +#undef INTERFACE +#define INTERFACE ID3DXFileEnumObject + +DECLARE_INTERFACE_( ID3DXFileEnumObject, IUnknown ) +{ + STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; + STDMETHOD_( ULONG, AddRef )( THIS ) PURE; + STDMETHOD_( ULONG, Release )( THIS ) PURE; + + STDMETHOD( GetFile )( THIS_ ID3DXFile** ) PURE; + STDMETHOD( GetChildren )( THIS_ SIZE_T* ) PURE; + STDMETHOD( GetChild )( THIS_ SIZE_T, ID3DXFileData** ) PURE; + STDMETHOD( GetDataObjectById )( THIS_ REFGUID, ID3DXFileData** ) PURE; + STDMETHOD( GetDataObjectByName )( THIS_ LPCSTR, ID3DXFileData** ) PURE; +}; + +////////////////////////////////////////////////////////////////////////////// +// ID3DXFileData ///////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +#undef INTERFACE +#define INTERFACE ID3DXFileData + +DECLARE_INTERFACE_( ID3DXFileData, IUnknown ) +{ + STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; + STDMETHOD_( ULONG, AddRef )( THIS ) PURE; + STDMETHOD_( ULONG, Release )( THIS ) PURE; + + STDMETHOD( GetEnum )( THIS_ ID3DXFileEnumObject** ) PURE; + STDMETHOD( GetName )( THIS_ LPSTR, SIZE_T* ) PURE; + STDMETHOD( GetId )( THIS_ LPGUID ) PURE; + STDMETHOD( Lock )( THIS_ SIZE_T*, LPCVOID* ) PURE; + STDMETHOD( Unlock )( THIS ) PURE; + STDMETHOD( GetType )( THIS_ GUID* ) PURE; + STDMETHOD_( BOOL, IsReference )( THIS ) PURE; + STDMETHOD( GetChildren )( THIS_ SIZE_T* ) PURE; + STDMETHOD( GetChild )( THIS_ SIZE_T, ID3DXFileData** ) PURE; +}; + +STDAPI D3DXFileCreate( ID3DXFile** lplpDirectXFile ); + +/* + * DirectX File errors. + */ + +#define _FACD3DXF 0x876 + +#define D3DXFERR_BADOBJECT MAKE_HRESULT( 1, _FACD3DXF, 900 ) +#define D3DXFERR_BADVALUE MAKE_HRESULT( 1, _FACD3DXF, 901 ) +#define D3DXFERR_BADTYPE MAKE_HRESULT( 1, _FACD3DXF, 902 ) +#define D3DXFERR_NOTFOUND MAKE_HRESULT( 1, _FACD3DXF, 903 ) +#define D3DXFERR_NOTDONEYET MAKE_HRESULT( 1, _FACD3DXF, 904 ) +#define D3DXFERR_FILENOTFOUND MAKE_HRESULT( 1, _FACD3DXF, 905 ) +#define D3DXFERR_RESOURCENOTFOUND MAKE_HRESULT( 1, _FACD3DXF, 906 ) +#define D3DXFERR_BADRESOURCE MAKE_HRESULT( 1, _FACD3DXF, 907 ) +#define D3DXFERR_BADFILETYPE MAKE_HRESULT( 1, _FACD3DXF, 908 ) +#define D3DXFERR_BADFILEVERSION MAKE_HRESULT( 1, _FACD3DXF, 909 ) +#define D3DXFERR_BADFILEFLOATSIZE MAKE_HRESULT( 1, _FACD3DXF, 910 ) +#define D3DXFERR_BADFILE MAKE_HRESULT( 1, _FACD3DXF, 911 ) +#define D3DXFERR_PARSEERROR MAKE_HRESULT( 1, _FACD3DXF, 912 ) +#define D3DXFERR_BADARRAYSIZE MAKE_HRESULT( 1, _FACD3DXF, 913 ) +#define D3DXFERR_BADDATAREFERENCE MAKE_HRESULT( 1, _FACD3DXF, 914 ) +#define D3DXFERR_NOMOREOBJECTS MAKE_HRESULT( 1, _FACD3DXF, 915 ) +#define D3DXFERR_NOMOREDATA MAKE_HRESULT( 1, _FACD3DXF, 916 ) +#define D3DXFERR_BADCACHEFILE MAKE_HRESULT( 1, _FACD3DXF, 917 ) + +/* + * DirectX File object types. + */ + +#ifndef WIN_TYPES +#define WIN_TYPES(itype, ptype) typedef interface itype *LP##ptype, **LPLP##ptype +#endif + +WIN_TYPES(ID3DXFile, D3DXFILE); +WIN_TYPES(ID3DXFileEnumObject, D3DXFILEENUMOBJECT); +WIN_TYPES(ID3DXFileSaveObject, D3DXFILESAVEOBJECT); +WIN_TYPES(ID3DXFileData, D3DXFILEDATA); +WIN_TYPES(ID3DXFileSaveData, D3DXFILESAVEDATA); + +#if defined( __cplusplus ) +} // extern "C" +#endif // defined( __cplusplus ) + +#endif // !defined( __D3DX9XOF_H__ ) + + diff --git a/src/dep/include/DXSDK/include/d3dxcore.h b/src/dep/include/DXSDK/include/d3dxcore.h index 84f992c..da1e989 100644 --- a/src/dep/include/DXSDK/include/d3dxcore.h +++ b/src/dep/include/DXSDK/include/d3dxcore.h @@ -1,1027 +1,1027 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dxcore.h -// Content: D3DX core types and functions -// -/////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DXCORE_H__ -#define __D3DXCORE_H__ - -#include -#include -#include "d3dxerr.h" - - -typedef struct ID3DXContext *LPD3DXCONTEXT; - -// {9B74ED7A-BBEF-11d2-9F8E-0000F8080835} -DEFINE_GUID(IID_ID3DXContext, - 0x9b74ed7a, 0xbbef, 0x11d2, 0x9f, 0x8e, 0x0, 0x0, 0xf8, 0x8, 0x8, 0x35); - - -/////////////////////////////////////////////////////////////////////////// -// Defines and Enumerators used below: -/////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------- -// D3DX_DEFAULT: -// --------- -// A predefined value that could be used for any parameter in D3DX APIs or -// member functions that is an enumerant or a handle. The D3DX -// documentation indicates wherever D3DX_DEFAULT may be used, -// and how it will be interpreted in each situation. -//------------------------------------------------------------------------- -#define D3DX_DEFAULT ULONG_MAX - -//------------------------------------------------------------------------- -// D3DX_DEFAULT_FLOAT: -// ------------------ -// Similar to D3DX_DEFAULT, but used for floating point parameters. -// The D3DX documentation indicates wherever D3DX_DEFAULT_FLOAT may be used, -// and how it will be interpreted in each situation. -//------------------------------------------------------------------------- -#define D3DX_DEFAULT_FLOAT FLT_MAX - -//------------------------------------------------------------------------- -// Hardware Acceleration Level: -// --------------------------- -// These constants represent pre-defined hardware acceleration levels, -// and may be used as a default anywhere a (DWORD) deviceIndex is required. -// Each pre-define indicates a different level of hardware acceleration. -// They are an alternative to using explicit deviceIndices retrieved by -// D3DXGetDeviceDescription(). -// -// The only case these pre-defines should be used as device indices is if -// a particular level of acceleration is required, and given more than -// one capable device on the computer, it does not matter which one -// is used. -// -// The method of selection is as follows: If one of the D3DX devices on -// the primary DDraw device supports a requested hardware acceleration -// level, it will be used. Otherwise, the first matching device discovered -// by D3DX will be used. -// -// Of course, it is possible for no match to exist for any of the -// pre-defines on a particular computer. Passing such a value into the -// D3DX apis will simply cause them to fail, reporting that no match -// is available. -// -// D3DX_HWLEVEL_NULL: Null implementation (draws nothing) -// D3DX_HWLEVEL_REFERENCE: Reference implementation (slowest) -// D3DX_HWLEVEL_2D: 2D acceleration only (RGB rasterizer used) -// D3DX_HWLEVEL_RASTER: Rasterization acceleration (likely most useful) -// D3DX_HWLEVEL_TL: Transform and lighting acceleration -// D3DX_DEFAULT: The highest level of acceleration available -// on the primary DDraw device. -//------------------------------------------------------------------------- -#define D3DX_HWLEVEL_NULL (D3DX_DEFAULT - 1) -#define D3DX_HWLEVEL_REFERENCE (D3DX_DEFAULT - 2) -#define D3DX_HWLEVEL_2D (D3DX_DEFAULT - 3) -#define D3DX_HWLEVEL_RASTER (D3DX_DEFAULT - 4) -#define D3DX_HWLEVEL_TL (D3DX_DEFAULT - 5) - -//------------------------------------------------------------------------- -// Surface Class: -// ------------- -// These are the various types of 2D-surfaces classified according to their -// usage. Note that a number of them overlap. e.g. STENCILBUFFERS and -// DEPTHBUFFERS overlap (since in DX7 implementation the stencil and depth -// bits are part of the same pixel format). -// -// Mapping to the DX7 DDPIXELFORMAT concepts: -// ----------------------------------------- -// D3DX_SC_DEPTHBUFFER: All ddpfs which have the DDPF_ZPIXELS or the -// DDPF_ZBUFFER flags set. -// D3DX_SC_STENCILBUFFER: All ddpfs which have the DDPF_STENCILBUFFER -// flag set. -// D3DX_SC_BUMPMAP: All ddpfs which have the DDPF_BUMPLUMINANCE -// or the DDPF_BUMPDUDV flags set. -// D3DX_SC_LUMINANCEMAP: All ddpfs which have the DDPF_BUMPLUMINANCE -// or the DDPF_LUMINANCE flags set. -// D3DX_SC_COLORTEXTURE: All the surfaces that have color information in -// them and can be used for texturing. -// D3DX_SC_COLORRENDERTGT: All the surfaces that contain color -// information and can be used as render targets. -//------------------------------------------------------------------------- -#define D3DX_SC_DEPTHBUFFER 0x01 -#define D3DX_SC_STENCILBUFFER 0x02 -#define D3DX_SC_COLORTEXTURE 0x04 -#define D3DX_SC_BUMPMAP 0x08 -#define D3DX_SC_LUMINANCEMAP 0x10 -#define D3DX_SC_COLORRENDERTGT 0x20 - -//------------------------------------------------------------------------- -// Surface Formats: -// --------------- -// These are the various types of surface formats that can be enumerated, -// there is no DDPIXELFORMAT structure in D3DX, the enums carry the meaning -// (like FOURCCs). -// -// All the surface classes are represented here. -// -//------------------------------------------------------------------------- -typedef enum _D3DX_SURFACEFORMAT -{ - D3DX_SF_UNKNOWN = 0, - D3DX_SF_R8G8B8 = 1, - D3DX_SF_A8R8G8B8 = 2, - D3DX_SF_X8R8G8B8 = 3, - D3DX_SF_R5G6B5 = 4, - D3DX_SF_R5G5B5 = 5, - D3DX_SF_PALETTE4 = 6, - D3DX_SF_PALETTE8 = 7, - D3DX_SF_A1R5G5B5 = 8, - D3DX_SF_X4R4G4B4 = 9, - D3DX_SF_A4R4G4B4 =10, - D3DX_SF_L8 =11, // 8 bit luminance-only - D3DX_SF_A8L8 =12, // 16 bit alpha-luminance - D3DX_SF_U8V8 =13, // 16 bit bump map format - D3DX_SF_U5V5L6 =14, // 16 bit bump map format with luminance - D3DX_SF_U8V8L8 =15, // 24 bit bump map format with luminance - D3DX_SF_UYVY =16, // UYVY format (PC98 compliance) - D3DX_SF_YUY2 =17, // YUY2 format (PC98 compliance) - D3DX_SF_DXT1 =18, // S3 texture compression technique 1 - D3DX_SF_DXT3 =19, // S3 texture compression technique 3 - D3DX_SF_DXT5 =20, // S3 texture compression technique 5 - D3DX_SF_R3G3B2 =21, // 8 bit RGB texture format - D3DX_SF_A8 =22, // 8 bit alpha-only - D3DX_SF_TEXTUREMAX =23, // Last texture format - - D3DX_SF_Z16S0 =256, - D3DX_SF_Z32S0 =257, - D3DX_SF_Z15S1 =258, - D3DX_SF_Z24S8 =259, - D3DX_SF_S1Z15 =260, - D3DX_SF_S8Z24 =261, - D3DX_SF_DEPTHMAX =262, // Last depth format - - D3DX_SF_FORCEMAX = (DWORD)(-1) -} D3DX_SURFACEFORMAT; - -//------------------------------------------------------------------------- -// Filtering types for Texture APIs -// -// ------------- -// These are the various filter types for generation of mip-maps -// -// D3DX_FILTERTYPE -// ----------------------------------------- -// D3DX_FT_POINT: Point sampling only - no filtering -// D3DX_FT_LINEAR: Bi-linear filtering -// -//------------------------------------------------------------------------- -typedef enum _D3DX_FILTERTYPE -{ - D3DX_FT_POINT = 0x01, - D3DX_FT_LINEAR = 0x02, - D3DX_FT_DEFAULT = D3DX_DEFAULT -} D3DX_FILTERTYPE; - -/////////////////////////////////////////////////////////////////////////// -// Structures used below: -/////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------- -// D3DX_VIDMODEDESC: Display mode description. -// ---------------- -// width: Screen Width -// height: Screen Height -// bpp: Bits per pixel -// refreshRate: Refresh rate -//------------------------------------------------------------------------- -typedef struct _D3DX_VIDMODEDESC -{ - DWORD width; - DWORD height; - DWORD bpp; - DWORD refreshRate; -} D3DX_VIDMODEDESC; - -//------------------------------------------------------------------------- -// D3DX_DEVICEDESC: Description of a device that can do 3D -// --------------- -// deviceIndex: Unique (DWORD) number for the device. -// hwLevel: Level of acceleration afforded. This is one of the -// predefined Device Indices, and exists in this -// structure for informational purposes only. More than -// one device on the system may have the same hwLevel. -// To refer to a particular device with the D3DX apis, -// use the value in the deviceIndex member instead. -// ddGuid: The ddraw GUID -// d3dDeviceGuid: Direct3D Device GUID -// ddDeviceID: DDraw's GetDeviceIdentifier GUID. This GUID is unique to -// a particular driver revision on a particular video card. -// driverDesc: String describing the driver -// monitor: Handle to the video monitor used by this device (multimon -// specific). Devices that use different monitors on a -// multimon system report different values in this field. -// Therefore, to test for a multimon system, an application -// should look for more than one different monitor handle in -// the list of D3DX devices. -// onPrimary: Indicates if this device is on the primary monitor -// (multimon specific). -//------------------------------------------------------------------------- -#define D3DX_DRIVERDESC_LENGTH 256 - -typedef struct _D3DX_DEVICEDESC -{ - DWORD deviceIndex; - DWORD hwLevel; - GUID ddGuid; - GUID d3dDeviceGuid; - GUID ddDeviceID; - char driverDesc[D3DX_DRIVERDESC_LENGTH]; - HMONITOR monitor; - BOOL onPrimary; -} D3DX_DEVICEDESC; - -/////////////////////////////////////////////////////////////////////////// -// APIs: -/////////////////////////////////////////////////////////////////////////// -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -//------------------------------------------------------------------------- -// D3DXInitialize: The very first call a D3DX app must make. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXInitialize(); - -//------------------------------------------------------------------------- -// D3DXUninitialize: The very last call a D3DX app must make. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXUninitialize(); - -//------------------------------------------------------------------------- -// D3DXGetDeviceCount: Returns the maximum number of D3DXdevices -// ------------------ available. -// -// D3DXGetDeviceDescription: Lists the 2D and 3D capabilities of the devices. -// ------------------------ Also, the various guids needed by ddraw and d3d. -// -// Params: -// [in] DWORD deviceIndex: Which device? Starts at 0. -// [in] D3DX_DEVICEDESC* pd3dxDevice: Pointer to the D3DX_DEVICEDESC -// structure to be filled in. -//------------------------------------------------------------------------- -DWORD WINAPI - D3DXGetDeviceCount(); - -HRESULT WINAPI - D3DXGetDeviceDescription(DWORD deviceIndex, - D3DX_DEVICEDESC* pd3dxDeviceDesc); - -//------------------------------------------------------------------------- -// D3DXGetMaxNumVideoModes: Returns the maximum number of video-modes . -// ----------------------- -// -// Params: -// [in] DWORD deviceIndex: The device being referred to. -// [in] DWORD flags: If D3DX_GVM_REFRESHRATE is set, then the refresh -// rates are not ignored. -// -// D3DXGetVideoMode: Describes a particular video mode for this device -// ---------------- -// -// Note: These queries will simply give you a list of modes that the -// display adapter tells DirectX that it supports. -// There is no guarantee that D3DXCreateContext(Ex) will succeed -// with all listed video modes. This is a fundamental limitation -// of the current DirectX architecture which D3DX cannot hide in -// any clean way. -// -// Params: -// [in] DWORD deviceIndex: The device being referred to. -// [in] DWORD flags: If D3DX_GVM_REFRESHRATE is set, then the refresh -// rates are returned -// [in] DWORD which: Which VideoMode ? Starts at 0. -// [out] D3DX_VIDMODEDESC* pModeList: Pointer to the D3DX_VIDMODEDESC -// structure that will be filled in. -//------------------------------------------------------------------------- -DWORD WINAPI - D3DXGetMaxNumVideoModes(DWORD deviceIndex, - DWORD flags); - -HRESULT WINAPI - D3DXGetVideoMode(DWORD deviceIndex, - DWORD flags, - DWORD modeIndex, - D3DX_VIDMODEDESC* pModeDesc); - -#define D3DX_GVM_REFRESHRATE 0x00000001 -//------------------------------------------------------------------------- -// D3DXGetMaxSurfaceFormats: Returns the maximum number of surface -// ------------------------ formats supported by the device at that -// video mode. -// -// D3DXGetSurfaceFormat: Describes one of the supported surface formats. -// --------------------- -// -// Params: -// [in] DWORD deviceIndex: The device being referred to. -// [in] D3DX_VIDMODEDESC* pDesc: The display mode at which the supported -// surface formats are requested. If it is -// NULL, the current display mode is -// assumed. -// [in] DWORD surfClassFlags: Required surface classes. Only surface -// formats which support all specified -// surface classes will be returned. -// (Multiple surface classes may be specified -// using bitwise OR.) -// [in] DWORD which: Which surface formats to retrieve. Starts at 0. -// [out] D3DX_SURFACEFORMAT* pFormat: The surface format -//------------------------------------------------------------------------- -DWORD WINAPI - D3DXGetMaxSurfaceFormats(DWORD deviceIndex, - D3DX_VIDMODEDESC* pDesc, - DWORD surfClassFlags); -HRESULT WINAPI - D3DXGetSurfaceFormat(DWORD deviceIndex, - D3DX_VIDMODEDESC* pDesc, - DWORD surfClassFlags, - DWORD surfaceIndex, - D3DX_SURFACEFORMAT* pFormat); - - -//------------------------------------------------------------------------- -// D3DXGetCurrentVideoMode: Retrieves the current video mode for this device. -// ------------------- -// -// Params: -// [in] DWORD deviceIndex: The device being referred to. -// [out] D3DX_VIDMODEDESC* pVidMode: The current video mode -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXGetCurrentVideoMode(DWORD deviceIndex, - D3DX_VIDMODEDESC* pVidMode); - -//------------------------------------------------------------------------- -// D3DXGetDeviceCaps: Lists all the capabilities of a device at a display -// mode. -// ---------------- -// -// Params: -// [in] DWORD deviceIndex: The device being referred to. -// [in] D3DX_VIDMODEDESC* pDesc: If this is NULL, we will return the -// caps at the current display mode of -// the device. -// [out] D3DDEVICEDESC7* pD3DDeviceDesc7: D3D Caps ( NULL to ignore -// parameter) -// [out] DDCAPS7* pDDHalCaps: DDraw HAL Caps (NULL to ignore parameter) -// [out] DDCAPS7* pDDHelCaps: DDraw HEL Caps (NULL to ignore paramter) -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXGetDeviceCaps(DWORD deviceIndex, - D3DX_VIDMODEDESC* pVidMode, - D3DDEVICEDESC7* pD3DCaps, - DDCAPS* pDDHALCaps, - DDCAPS* pDDHELCaps); - -//------------------------------------------------------------------------- -// D3DXCreateContext: Initializes the chosen device. It is the simplest init -// ----------------- function available. Parameters are treated the same -// as the matching subset of parameters in -// D3DXCreateContextEx, documented below. -// Remaining D3DXCreateContextEx parameters that are -// not present in D3DXCreateContext are treated as -// D3DX_DEFAULT. Note that multimon is not supported -// with D3DXCreateContext. -// -// D3DXCreateContextEx: A more advanced function to initialize the device. -// ------------------- Also accepts D3DX_DEFAULT for most of the parameters -// and then will do what D3DXCreateContext did. -// -// Note: Do not expect D3DXCreateContext(Ex) to be fail-safe (as with any -// API). Supported device capablilites should be used as a guide -// for choosing parameter values. Keep in mind that there will -// inevitably be some combinations of parameters that just do not work. -// -// Params: -// [in] DWORD deviceIndex: The device being referred to. -// [in] DWORD flags: The valid flags are D3DX_CONTEXT_FULLSCREEN, and -// D3DX_CONTEXT_OFFSCREEN. These flags cannot both -// be specified. If no flags are specified, the -// context defaults to windowed mode. -// -// [in] HWND hwnd: Device window. See note. -// [in] HWND hwndFocus: Window which receives keyboard messages from -// the device window. The device window should be -// a child of focus window. Useful for multimon -// applications. See note. -// NOTE: -// windowed: -// hwnd must be a valid window. hwndFocus must be NULL or -// D3DX_DEFAULT. -// -// fullscreen: -// Either hwnd or hwndFocus must be a valid window. (Both cannot -// be NULL or D3DX_DEFAULT). If hwnd is NULL or D3DX_DEFAULT, -// a default device window will be created as a child of hwndFocus. -// -// offscreen: -// Both hwnd and hwndFocus must be NULL or D3DX_DEFAULT -// -// [in] DWORD numColorBits: If D3DX_DEFAULT is passed for windowed mode, -// the current desktop's color depth is chosen. -// For full screen mode, D3DX_DEFAULT causes 16 -// bit color to be used. -// [in] DWORD numAlphaBits: If D3DX_DEFAULT is passed, 0 is chosen. -// [in] DWORD numDepthbits: If D3DX_DEFAULT is passed, -// the highest available number of depth bits -// is chosen. See note. -// [in] DWORD numStencilBits: If D3DX_DEFAULT is passed, the highest -// available number of stencil bits is chosen. -// See note. -// -// NOTE: If both numDepthBits and numStencilBits are D3DX_DEFAULT, -// D3DX first picks the highest available number of stencil -// bits. Then, for the chosen number of stencil bits, -// the highest available number of depth bits is chosen. -// If only one of numStencilBits or numDepthBits -// is D3DX_DEFAULT, the highest number of bits available -// for this parameter is chosen out of only the formats -// that support the number of bits requested for the -// fixed parameter. -// -// [in] DWORD numBackBuffers: Number of back buffers, or D3DX_DEFAULT. -// See note. -// -// NOTE: -// windowed: D3DX_DEFAULT means 1. You must specify one back buffer. -// -// fullscreen: D3DX_DEFAULT means 1. Any number of back buffers can be -// specified. -// -// offscreen: D3DX_DEFAULT means 0. You cannot specify additional back -// buffers. -// -// [in] DWORD width: Width, in pixels, or D3DX_DEFAULT. See note. -// [in] DWORD height: Height, in pixels, or D3DX_DEFAULT. See note. -// -// NOTE: -// windowed: If either width or height is D3DX_DEFAULT, both values -// default to the dimensions of the client area of hwnd. -// -// fullscreen: If either width or height is D3DX_DEFAULT, width -// defaults to 640, and height defaults to 480. -// -// offscreen: An error is returned if either width or height is -// D3DX_DEFAULT. -// -// [in] DWORD refreshRate: D3DX_DEFAULT means we let ddraw choose for -// us. Ignored for windowed and offscreen modes. -// [out] LPD3DXCONTEXT* ppCtx: This is the Context object that is used for -// rendering on that device. -// -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateContext(DWORD deviceIndex, - DWORD flags, - HWND hwnd, - DWORD width, - DWORD height, - LPD3DXCONTEXT* ppCtx); - -HRESULT WINAPI - D3DXCreateContextEx(DWORD deviceIndex, - DWORD flags, - HWND hwnd, - HWND hwndFocus, - DWORD numColorBits, - DWORD numAlphaBits, - DWORD numDepthbits, - DWORD numStencilBits, - DWORD numBackBuffers, - DWORD width, - DWORD height, - DWORD refreshRate, - LPD3DXCONTEXT* ppCtx); - -// The D3DXCreateContext(Ex) flags are: -#define D3DX_CONTEXT_FULLSCREEN 0x00000001 -#define D3DX_CONTEXT_OFFSCREEN 0x00000002 - -//------------------------------------------------------------------------- -// D3DXGetErrorString: Prints out the error string given an hresult. Prints -// ------------------ Win32 as well as DX6 error messages besides the D3DX -// messages. -// -// Params: -// [in] HRESULT hr: The error code to be deciphered. -// [in] DWORD strLength: Length of the string passed in. -// [out] LPSTR pStr: The string output. This string of appropriate -// size needs to be passed in. -//------------------------------------------------------------------------- -void WINAPI - D3DXGetErrorString(HRESULT hr, - DWORD strLength, - LPSTR pStr); - -//------------------------------------------------------------------------- -// D3DXMakeDDPixelFormat: Fills in a DDPIXELFORMAT structure based on the -// --------------------- D3DX surface format requested. -// -// Params: -// [in] D3DX_SURFACEFORMAT d3dxFormat: Surface format. -// [out] DDPIXELFORMAT* pddpf: Pixel format matching the given -// surface format. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXMakeDDPixelFormat(D3DX_SURFACEFORMAT d3dxFormat, - DDPIXELFORMAT* pddpf); - -//------------------------------------------------------------------------- -// D3DXMakeSurfaceFormat: Determines the surface format corresponding to -// --------------------- a given DDPIXELFORMAT. -// -// Params: -// [in] DDPIXELFORMAT* pddpf: Pixel format. -// Return Value: -// D3DX_SURFACEFORMAT: Surface format matching the given pixel format. -// D3DX_SF_UNKNOWN if the format is not supported -//------------------------------------------------------------------------- -D3DX_SURFACEFORMAT WINAPI - D3DXMakeSurfaceFormat(DDPIXELFORMAT* pddpf); - -#ifdef __cplusplus -} -#endif //__cplusplus - -/////////////////////////////////////////////////////////////////////////// -// Interfaces: -/////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------- -// ID3DXContext interface: -// -// This encapsulates all the stuff that the app might -// want to do at initialization time and any global control over d3d and -// ddraw. -//------------------------------------------------------------------------- - - -DECLARE_INTERFACE_(ID3DXContext, IUnknown) -{ - // - // IUnknown methods - // - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID* ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - // Get the DDraw and Direct3D objects to call DirectDraw or - // Direct3D Immediate Mode functions. - // If the objects don't exist (because they have not - // been created for some reason) NULL is returned. - // All the objects returned in the following Get* functions - // are addref'ed. It is the application's responsibility to - // release them when no longer needed. - STDMETHOD_(LPDIRECTDRAW7,GetDD)(THIS) PURE; - STDMETHOD_(LPDIRECT3D7,GetD3D)(THIS) PURE; - STDMETHOD_(LPDIRECT3DDEVICE7,GetD3DDevice)(THIS) PURE; - - // Get the various buffers that get created at the init time - // These are addref'ed as well. It is the application's responsibility - // to release them before the app quits or when it needs a resize. - STDMETHOD_(LPDIRECTDRAWSURFACE7,GetPrimary)(THIS) PURE; - STDMETHOD_(LPDIRECTDRAWSURFACE7,GetZBuffer)(THIS) PURE; - STDMETHOD_(LPDIRECTDRAWSURFACE7,GetBackBuffer)(THIS_ DWORD which) PURE; - - // Get the associated window handles - STDMETHOD_(HWND,GetWindow)(THIS) PURE; - STDMETHOD_(HWND,GetFocusWindow)(THIS) PURE; - - // - // Various Get methods, in case the user had specified default - // parameters - // - STDMETHOD(GetDeviceIndex)(THIS_ - LPDWORD pDeviceIndex, - LPDWORD pHwLevel) PURE; - - STDMETHOD_(DWORD, GetNumBackBuffers)(THIS) PURE; - - STDMETHOD(GetNumBits)(THIS_ - LPDWORD pColorBits, - LPDWORD pDepthBits, - LPDWORD pAlphaBits, - LPDWORD pStencilBits) PURE; - - STDMETHOD(GetBufferSize)(THIS_ - LPDWORD pWidth, - LPDWORD pHeight) PURE; - - // Get the flags that were used to create this context - STDMETHOD_(DWORD, GetCreationFlags)(THIS) PURE; - STDMETHOD_(DWORD, GetRefreshRate)(THIS) PURE; - - // Restoring surfaces in case stuff is lost - STDMETHOD(RestoreSurfaces)(THIS) PURE; - - // Resize all the buffers to the new width and height - STDMETHOD(Resize)(THIS_ DWORD width, DWORD height) PURE; - - // Update the frame using a flip or a blit, - // If the D3DX_UPDATE_NOVSYNC flag is set, blit is used if the - // driver cannot flip without waiting for vsync in full-screen mode. - STDMETHOD(UpdateFrame)(THIS_ DWORD flags) PURE; - - // Render a string at the specified coordinates, with the specified - // colour. This is only provided as a convenience for - // debugging/information during development. - // topLeftX and topLeftY represent the location of the top left corner - // of the string, on the render target. - // The coordinate and color parameters each have a range of 0.0-1.0 - STDMETHOD(DrawDebugText)(THIS_ - float topLeftX, - float topLeftY, - D3DCOLOR color, - LPSTR pString) PURE; - - // Clears to the current viewport - // The following are the valid flags: - // D3DCLEAR_TARGET (to clear the render target ) - // D3DCLEAR_ZBUFFER (to clear the depth-buffer ) - // D3DCLEAR_STENCIL (to clear the stencil-buffer ) - STDMETHOD(Clear)(THIS_ DWORD ClearFlags) PURE; - - STDMETHOD(SetClearColor)(THIS_ D3DCOLOR color ) PURE; - STDMETHOD(SetClearDepth)(THIS_ float z) PURE; - STDMETHOD(SetClearStencil)(THIS_ DWORD stencil) PURE; -}; - - -//------------------------------------------------------------------------- -// Flags for Update member function: -// - -// Flag to indicate that blit should be used instead of a flip -// for full-screen rendering. -#define D3DX_UPDATE_NOVSYNC (1<<0) - -/////////////////////////////////////////////////////////////////////////// -// Texturing APIs: -/////////////////////////////////////////////////////////////////////////// -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -//------------------------------------------------------------------------- -// D3DXCheckTextureRequirements: Return information about texture creation -// ---------------------------- (used by CreateTexture, CreateTextureFromFile -// and CreateCubeMapTexture) -// -// Parameters: -// -// pd3dDevice -// The D3D device with which the texture is going to be used. -// pFlags -// allows specification of D3DX_TEXTURE_NOMIPMAP -// D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation -// is not supported. -// pWidth -// width in pixels or NULL -// returns corrected width -// pHeight -// height in pixels or NULL -// returns corrected height -// pPixelFormat -// surface format -// returns best match to input format -// -// Notes: 1. Unless the flags is set to specifically prevent creating -// mipmaps, mipmaps are generated all the way till 1x1 surface. -// 2. width, height and pixelformat are altered based on available -// hardware. For example: -// a. Texture dimensions may be required to be powers of 2 -// b. We may require width == height for some devices -// c. If PixelFormat is unavailable, a best fit is made -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCheckTextureRequirements( LPDIRECT3DDEVICE7 pd3dDevice, - LPDWORD pFlags, - LPDWORD pWidth, - LPDWORD pHeight, - D3DX_SURFACEFORMAT* pPixelFormat); - -//------------------------------------------------------------------------- -// D3DXCreateTexture: Create an empty texture object -// ----------------- -// -// Parameters: -// -// pd3dDevice -// The D3D device with which the texture is going to be used. -// pFlags -// allows specification of D3DX_TEXTURE_NOMIPMAP -// D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation -// is not supported. Additionally, D3DX_TEXTURE_STAGE can be specified -// to indicate which texture stage the texture is for e.g. -// D3D_TEXTURE_STAGE1 indicates that the texture is for use with texture -// stage one. Stage Zero is the default if no TEXTURE_STAGE flags are -// set. -// pWidth -// width in pixels; 0 or NULL is unacceptable -// returns corrected width -// pHeight -// height in pixels; 0 or NULL is unacceptable -// returns corrected height -// pPixelFormat -// surface format. D3DX_DEFAULT is unacceptable. -// returns actual format that was used -// pDDPal -// DDraw palette that is set (if present) on paletted surfaces. -// It is ignored even if it is set, for non-paletted surfaces. -// ppDDSurf -// The ddraw surface that will be created -// pNumMipMaps -// the number of mipmaps actually generated -// -// Notes: See notes for D3DXCheckTextureRequirements. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTexture( LPDIRECT3DDEVICE7 pd3dDevice, - LPDWORD pFlags, - LPDWORD pWidth, - LPDWORD pHeight, - D3DX_SURFACEFORMAT* pPixelFormat, - LPDIRECTDRAWPALETTE pDDPal, - LPDIRECTDRAWSURFACE7* ppDDSurf, - LPDWORD pNumMipMaps); - -//------------------------------------------------------------------------- -// D3DXCreateCubeMapTexture: Create blank cube-map texture -// ------------------------ -// -// Parameters: -// -// pd3dDevice -// The D3D device with which the texture is going to be used. -// pFlags -// allows specification of D3DX_TEXTURE_NOMIPMAP -// D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation -// is not supported. Additionally, D3DX_TEXTURE_STAGE can be specified -// to indicate which texture stage the texture is for e.g. -// D3D_TEXTURE_STAGE1 indicates that the texture is for use with texture -// stage one. Stage Zero is the default if no TEXTURE_STAGE flags are -// set. -// cubefaces -// allows specification of which faces of the cube-map to generate. -// D3DX_DEFAULT, 0, and DDSCAPS2_CUBEMAP_ALLFACES all mean -// "create all 6 faces of the cubemap". Any combination of -// DDSCAPS2_CUBEMAP_POSITIVEX, DDSCAPS2_CUBEMAP_NEGATIVEX, -// DDSCAPS2_CUBEMAP_POSITIVEY, DDSCAPS2_CUBEMAP_NEGATIVEY, -// DDSCAPS2_CUBEMAP_POSITIVEZ, or DDSCAPS2_CUBEMAP_NEGATIVEZ, is -// valid. -// colorEmptyFaces -// allows specification of the color to use for the faces that were not -// specified in the cubefaces parameter. -// pWidth -// width in pixels; 0 or NULL is unacceptable -// returns corrected width -// pHeight -// height in pixels; 0 or NULL is unacceptable -// returns corrected height -// pPixelFormat -// surface format. D3DX_DEFAULT is unacceptable. -// returns actual format that was used -// pDDPal -// DDraw palette that is set (if present) on paletted surfaces. -// It is ignored even if it is set, for non-paletted surfaces. -// ppDDSurf -// the ddraw surface that will be created -// pNumMipMaps -// the number of mipmaps generated for a particular face of the -// cubemap. -// -// Notes: See notes for D3DXCheckTextureRequirements. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateCubeMapTexture( LPDIRECT3DDEVICE7 pd3dDevice, - LPDWORD pFlags, - DWORD cubefaces, - D3DCOLOR colorEmptyFaces, - LPDWORD pWidth, - LPDWORD pHeight, - D3DX_SURFACEFORMAT *pPixelFormat, - LPDIRECTDRAWPALETTE pDDPal, - LPDIRECTDRAWSURFACE7* ppDDSurf, - LPDWORD pNumMipMaps); - - -//------------------------------------------------------------------------- -// D3DXCreateTextureFromFile: Create a texture object from a file or from the -// ------------------------- resource. Only BMP and DIB are supported from the -// resource portion of the executable. -// -// Parameters: -// -// pd3dDevice -// The D3D device with which the texture is going to be used. -// pFlags -// allows specification of D3DX_TEXTURE_NOMIPMAP -// D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation -// is not supported. Additionally, D3DX_TEXTURE_STAGE can be specified -// to indicate which texture stage the texture is for e.g. -// D3D_TEXTURE_STAGE1 indicates that the texture is for use with texture -// stage one. Stage Zero is the default if no TEXTURE_STAGE flags are -// set. -// pWidth -// Width in pixels. If 0 or D3DX_DEFAULT, the width will be taken -// from the file -// returns corrected width -// pHeight -// Height in pixels. If 0 or D3DX_DEFAULT, the height will be taken -// from the file -// returns corrected height -// pPixelFormat -// If D3DX_SF_UNKNOWN is passed in, pixel format closest to the bitmap -// will be chosen -// returns actual format that was used -// pDDPal -// DDraw palette that is set (if present) on paletted surfaces. -// It is ignored even if it is set, for non-paletted surfaces. -// ppDDSurf -// The ddraw surface that will be created. -// pNumMipMaps -// The number of mipmaps generated. -// pSrcName -// File name. BMP, DIB, DDS, are supported. -// -// TGA is supported for the following cases: 16, 24, 32bpp direct color and 8bpp palettized. -// Also, 8, 16bpp grayscale is supported. RLE versions of the above -// TGA formats are also supported. ColorKey and Premultiplied Alpha -// are not currently supported for TGA files. -// returns created format -// -// Notes: See notes for D3DXCheckTextureRequirements. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTextureFromFile( LPDIRECT3DDEVICE7 pd3dDevice, - LPDWORD pFlags, - LPDWORD pWidth, - LPDWORD pHeight, - D3DX_SURFACEFORMAT* pPixelFormat, - LPDIRECTDRAWPALETTE pDDPal, - LPDIRECTDRAWSURFACE7* ppDDSurf, - LPDWORD pNumMipMaps, - LPSTR pSrcName, - D3DX_FILTERTYPE filterType); - -//------------------------------------------------------------------------- -// D3DXLoadTextureFromFile: Load from a file into a mipmap level. Doing the -// ----------------------- necessary color conversion and rescaling. File -// format support is identical to -// D3DXCreateTextureFromFile's. -// -// pd3dDevice -// The D3D device with which the texture is going to be used. -// pTexture -// a pointer to a DD7Surface which was created with either -// CreateTextureFromFile or CreateTexture. -// mipMapLevel -// indicates mipmap level -// Note: -// 1. Error if mipmap level doesn't exist -// 2. If D3DX_DEFAULT and equal number of mipmap levels exist -// then all the source mip-levels are loaded -// 3. If the source has mipmaps and the dest doesn't, use the top one -// 4. If the dest has miplevels and source doesn't, we expand -// 5. If there are unequal numbers of miplevels, we expand -// pSrcName -// File name. BMP, DIB, DDS, are supported. -// For details on TGA support, refer to the comments for -// D3DXCreateTextureFromFile -// pSrcRect -// the source rectangle or null (whole surface) -// pDestRect -// the destination rectangle or null (whole surface) -// filterType -// filter used for mipmap generation -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXLoadTextureFromFile( LPDIRECT3DDEVICE7 pd3dDevice, - LPDIRECTDRAWSURFACE7 pTexture, - DWORD mipMapLevel, - LPSTR pSrcName, - RECT* pSrcRect, - RECT* pDestRect, - D3DX_FILTERTYPE filterType); - -//------------------------------------------------------------------------- -// D3DXLoadTextureFromSurface: Load from a DDraw Surface into a mipmap level. -// -------------------------- Doing the necessary color conversion. -// -// pd3dDevice -// The D3D device with which the texture is going to be used. -// pTexture -// a pointer to a DD7Surface which was created with either -// CreateTextureFromFile or CreateTexture. -// mipMapLevel -// indicates mipmap level -// Note: -// 1. Error if mipmap level doesn't exist -// 2. If D3DX_DEFAULT and equal number of mipmap levels exist -// then all the source mip-levels are loaded -// 3. If the source has mipmaps and the dest doesn't, use the top one -// 4. If the dest has miplevels and source doesn't, we expand -// 5. If there are unequal numbers of miplevels, we expand -// pSurfaceSrc -// the source surface -// pSrcRect -// the source rectangle or null (whole surface) -// pDestRect -// the destination rectangle or null (whole surface) -// filterType -// filter used for mipmap generation -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXLoadTextureFromSurface( LPDIRECT3DDEVICE7 pd3dDevice, - LPDIRECTDRAWSURFACE7 pTexture, - DWORD mipMapLevel, - LPDIRECTDRAWSURFACE7 pSurfaceSrc, - RECT* pSrcRect, - RECT* pDestRect, - D3DX_FILTERTYPE filterType); - -//------------------------------------------------------------------------- -// D3DXLoadTextureFromMemory: Load a mip level from memory. Doing the necessary -// ------------------------- color conversion. -// -// pd3dDevice -// The D3D device with which the texture is going to be used. -// pTexture -// a pointer to a DD7Surface which was created with either -// CreateTextureFromFile or CreateTexture. -// mipMapLevel -// indicates mipmap level -// Note: -// 1. Error if mipmap level doesn't exist -// 2. If D3DX_DEFAULT and equal number of mipmap levels exist -// then all the source mip-levels are loaded -// 3. If the source has mipmaps and the dest doesn't, use the top one -// 4. If the dest has miplevels and source doesn't, we expand -// 5. If there are unequal numbers of miplevels, we expand -// pMemory -// pointer to source memory from which the texture will be loaded -// pDDPal -// DirectDraw Palette, that the app passes in optionally if the memory is -// supposed to be paletteized. -// srcPixelFormat -// PixelFormat of the source. -// srcPitch -// The pitch of the memory or D3DX_DEFAULT (based on srcPixelFormat) -// pDestRect -// The destination rectangle or null (whole surface) -// filterType -// filter used for mipmap generation -// -// Assumptions: The source (memory) is loaded in full -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXLoadTextureFromMemory( LPDIRECT3DDEVICE7 pd3dDevice, - LPDIRECTDRAWSURFACE7 pTexture, - DWORD mipMapLevel, - LPVOID pMemory, - LPDIRECTDRAWPALETTE pDDPal, - D3DX_SURFACEFORMAT srcPixelFormat, - DWORD srcPitch, - RECT* pDestRect, - D3DX_FILTERTYPE filterType); - -#ifdef __cplusplus -} -#endif //__cplusplus - -//------------------------------------------------------------------------- -// Flags for texture create functions; applies to -// D3DXCreateTexture, D3DXCreateCubeMapTexture and D3DXCreateTextureFromFile. -// - -// Flag to indicate that mipmap generation is not desired. -#define D3DX_TEXTURE_NOMIPMAP (1 << 8) - -// Flags to indicate which texture stage the texture is -// intended for use with. Specifying the stage is necessary at -// texture creation time for HW devices that expose the -// D3DDEVCAPS_SEPARATETEXTUREMEMORIES bit in their D3DDEVICEDESC -// structure. -#define D3DX_TEXTURE_STAGE0 (0) -#define D3DX_TEXTURE_STAGE1 (1) -#define D3DX_TEXTURE_STAGE2 (2) -#define D3DX_TEXTURE_STAGE3 (3) -#define D3DX_TEXTURE_STAGE4 (4) -#define D3DX_TEXTURE_STAGE5 (5) -#define D3DX_TEXTURE_STAGE6 (6) -#define D3DX_TEXTURE_STAGE7 (7) - -// Mask to extract the texture stage value out of the flags to -// the texture create functions. -#define D3DX_TEXTURE_STAGE_MASK (0x7) - -#endif //__D3DXCORE_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dxcore.h +// Content: D3DX core types and functions +// +/////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DXCORE_H__ +#define __D3DXCORE_H__ + +#include +#include +#include "d3dxerr.h" + + +typedef struct ID3DXContext *LPD3DXCONTEXT; + +// {9B74ED7A-BBEF-11d2-9F8E-0000F8080835} +DEFINE_GUID(IID_ID3DXContext, + 0x9b74ed7a, 0xbbef, 0x11d2, 0x9f, 0x8e, 0x0, 0x0, 0xf8, 0x8, 0x8, 0x35); + + +/////////////////////////////////////////////////////////////////////////// +// Defines and Enumerators used below: +/////////////////////////////////////////////////////////////////////////// + +//------------------------------------------------------------------------- +// D3DX_DEFAULT: +// --------- +// A predefined value that could be used for any parameter in D3DX APIs or +// member functions that is an enumerant or a handle. The D3DX +// documentation indicates wherever D3DX_DEFAULT may be used, +// and how it will be interpreted in each situation. +//------------------------------------------------------------------------- +#define D3DX_DEFAULT ULONG_MAX + +//------------------------------------------------------------------------- +// D3DX_DEFAULT_FLOAT: +// ------------------ +// Similar to D3DX_DEFAULT, but used for floating point parameters. +// The D3DX documentation indicates wherever D3DX_DEFAULT_FLOAT may be used, +// and how it will be interpreted in each situation. +//------------------------------------------------------------------------- +#define D3DX_DEFAULT_FLOAT FLT_MAX + +//------------------------------------------------------------------------- +// Hardware Acceleration Level: +// --------------------------- +// These constants represent pre-defined hardware acceleration levels, +// and may be used as a default anywhere a (DWORD) deviceIndex is required. +// Each pre-define indicates a different level of hardware acceleration. +// They are an alternative to using explicit deviceIndices retrieved by +// D3DXGetDeviceDescription(). +// +// The only case these pre-defines should be used as device indices is if +// a particular level of acceleration is required, and given more than +// one capable device on the computer, it does not matter which one +// is used. +// +// The method of selection is as follows: If one of the D3DX devices on +// the primary DDraw device supports a requested hardware acceleration +// level, it will be used. Otherwise, the first matching device discovered +// by D3DX will be used. +// +// Of course, it is possible for no match to exist for any of the +// pre-defines on a particular computer. Passing such a value into the +// D3DX apis will simply cause them to fail, reporting that no match +// is available. +// +// D3DX_HWLEVEL_NULL: Null implementation (draws nothing) +// D3DX_HWLEVEL_REFERENCE: Reference implementation (slowest) +// D3DX_HWLEVEL_2D: 2D acceleration only (RGB rasterizer used) +// D3DX_HWLEVEL_RASTER: Rasterization acceleration (likely most useful) +// D3DX_HWLEVEL_TL: Transform and lighting acceleration +// D3DX_DEFAULT: The highest level of acceleration available +// on the primary DDraw device. +//------------------------------------------------------------------------- +#define D3DX_HWLEVEL_NULL (D3DX_DEFAULT - 1) +#define D3DX_HWLEVEL_REFERENCE (D3DX_DEFAULT - 2) +#define D3DX_HWLEVEL_2D (D3DX_DEFAULT - 3) +#define D3DX_HWLEVEL_RASTER (D3DX_DEFAULT - 4) +#define D3DX_HWLEVEL_TL (D3DX_DEFAULT - 5) + +//------------------------------------------------------------------------- +// Surface Class: +// ------------- +// These are the various types of 2D-surfaces classified according to their +// usage. Note that a number of them overlap. e.g. STENCILBUFFERS and +// DEPTHBUFFERS overlap (since in DX7 implementation the stencil and depth +// bits are part of the same pixel format). +// +// Mapping to the DX7 DDPIXELFORMAT concepts: +// ----------------------------------------- +// D3DX_SC_DEPTHBUFFER: All ddpfs which have the DDPF_ZPIXELS or the +// DDPF_ZBUFFER flags set. +// D3DX_SC_STENCILBUFFER: All ddpfs which have the DDPF_STENCILBUFFER +// flag set. +// D3DX_SC_BUMPMAP: All ddpfs which have the DDPF_BUMPLUMINANCE +// or the DDPF_BUMPDUDV flags set. +// D3DX_SC_LUMINANCEMAP: All ddpfs which have the DDPF_BUMPLUMINANCE +// or the DDPF_LUMINANCE flags set. +// D3DX_SC_COLORTEXTURE: All the surfaces that have color information in +// them and can be used for texturing. +// D3DX_SC_COLORRENDERTGT: All the surfaces that contain color +// information and can be used as render targets. +//------------------------------------------------------------------------- +#define D3DX_SC_DEPTHBUFFER 0x01 +#define D3DX_SC_STENCILBUFFER 0x02 +#define D3DX_SC_COLORTEXTURE 0x04 +#define D3DX_SC_BUMPMAP 0x08 +#define D3DX_SC_LUMINANCEMAP 0x10 +#define D3DX_SC_COLORRENDERTGT 0x20 + +//------------------------------------------------------------------------- +// Surface Formats: +// --------------- +// These are the various types of surface formats that can be enumerated, +// there is no DDPIXELFORMAT structure in D3DX, the enums carry the meaning +// (like FOURCCs). +// +// All the surface classes are represented here. +// +//------------------------------------------------------------------------- +typedef enum _D3DX_SURFACEFORMAT +{ + D3DX_SF_UNKNOWN = 0, + D3DX_SF_R8G8B8 = 1, + D3DX_SF_A8R8G8B8 = 2, + D3DX_SF_X8R8G8B8 = 3, + D3DX_SF_R5G6B5 = 4, + D3DX_SF_R5G5B5 = 5, + D3DX_SF_PALETTE4 = 6, + D3DX_SF_PALETTE8 = 7, + D3DX_SF_A1R5G5B5 = 8, + D3DX_SF_X4R4G4B4 = 9, + D3DX_SF_A4R4G4B4 =10, + D3DX_SF_L8 =11, // 8 bit luminance-only + D3DX_SF_A8L8 =12, // 16 bit alpha-luminance + D3DX_SF_U8V8 =13, // 16 bit bump map format + D3DX_SF_U5V5L6 =14, // 16 bit bump map format with luminance + D3DX_SF_U8V8L8 =15, // 24 bit bump map format with luminance + D3DX_SF_UYVY =16, // UYVY format (PC98 compliance) + D3DX_SF_YUY2 =17, // YUY2 format (PC98 compliance) + D3DX_SF_DXT1 =18, // S3 texture compression technique 1 + D3DX_SF_DXT3 =19, // S3 texture compression technique 3 + D3DX_SF_DXT5 =20, // S3 texture compression technique 5 + D3DX_SF_R3G3B2 =21, // 8 bit RGB texture format + D3DX_SF_A8 =22, // 8 bit alpha-only + D3DX_SF_TEXTUREMAX =23, // Last texture format + + D3DX_SF_Z16S0 =256, + D3DX_SF_Z32S0 =257, + D3DX_SF_Z15S1 =258, + D3DX_SF_Z24S8 =259, + D3DX_SF_S1Z15 =260, + D3DX_SF_S8Z24 =261, + D3DX_SF_DEPTHMAX =262, // Last depth format + + D3DX_SF_FORCEMAX = (DWORD)(-1) +} D3DX_SURFACEFORMAT; + +//------------------------------------------------------------------------- +// Filtering types for Texture APIs +// +// ------------- +// These are the various filter types for generation of mip-maps +// +// D3DX_FILTERTYPE +// ----------------------------------------- +// D3DX_FT_POINT: Point sampling only - no filtering +// D3DX_FT_LINEAR: Bi-linear filtering +// +//------------------------------------------------------------------------- +typedef enum _D3DX_FILTERTYPE +{ + D3DX_FT_POINT = 0x01, + D3DX_FT_LINEAR = 0x02, + D3DX_FT_DEFAULT = D3DX_DEFAULT +} D3DX_FILTERTYPE; + +/////////////////////////////////////////////////////////////////////////// +// Structures used below: +/////////////////////////////////////////////////////////////////////////// + +//------------------------------------------------------------------------- +// D3DX_VIDMODEDESC: Display mode description. +// ---------------- +// width: Screen Width +// height: Screen Height +// bpp: Bits per pixel +// refreshRate: Refresh rate +//------------------------------------------------------------------------- +typedef struct _D3DX_VIDMODEDESC +{ + DWORD width; + DWORD height; + DWORD bpp; + DWORD refreshRate; +} D3DX_VIDMODEDESC; + +//------------------------------------------------------------------------- +// D3DX_DEVICEDESC: Description of a device that can do 3D +// --------------- +// deviceIndex: Unique (DWORD) number for the device. +// hwLevel: Level of acceleration afforded. This is one of the +// predefined Device Indices, and exists in this +// structure for informational purposes only. More than +// one device on the system may have the same hwLevel. +// To refer to a particular device with the D3DX apis, +// use the value in the deviceIndex member instead. +// ddGuid: The ddraw GUID +// d3dDeviceGuid: Direct3D Device GUID +// ddDeviceID: DDraw's GetDeviceIdentifier GUID. This GUID is unique to +// a particular driver revision on a particular video card. +// driverDesc: String describing the driver +// monitor: Handle to the video monitor used by this device (multimon +// specific). Devices that use different monitors on a +// multimon system report different values in this field. +// Therefore, to test for a multimon system, an application +// should look for more than one different monitor handle in +// the list of D3DX devices. +// onPrimary: Indicates if this device is on the primary monitor +// (multimon specific). +//------------------------------------------------------------------------- +#define D3DX_DRIVERDESC_LENGTH 256 + +typedef struct _D3DX_DEVICEDESC +{ + DWORD deviceIndex; + DWORD hwLevel; + GUID ddGuid; + GUID d3dDeviceGuid; + GUID ddDeviceID; + char driverDesc[D3DX_DRIVERDESC_LENGTH]; + HMONITOR monitor; + BOOL onPrimary; +} D3DX_DEVICEDESC; + +/////////////////////////////////////////////////////////////////////////// +// APIs: +/////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +//------------------------------------------------------------------------- +// D3DXInitialize: The very first call a D3DX app must make. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXInitialize(); + +//------------------------------------------------------------------------- +// D3DXUninitialize: The very last call a D3DX app must make. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXUninitialize(); + +//------------------------------------------------------------------------- +// D3DXGetDeviceCount: Returns the maximum number of D3DXdevices +// ------------------ available. +// +// D3DXGetDeviceDescription: Lists the 2D and 3D capabilities of the devices. +// ------------------------ Also, the various guids needed by ddraw and d3d. +// +// Params: +// [in] DWORD deviceIndex: Which device? Starts at 0. +// [in] D3DX_DEVICEDESC* pd3dxDevice: Pointer to the D3DX_DEVICEDESC +// structure to be filled in. +//------------------------------------------------------------------------- +DWORD WINAPI + D3DXGetDeviceCount(); + +HRESULT WINAPI + D3DXGetDeviceDescription(DWORD deviceIndex, + D3DX_DEVICEDESC* pd3dxDeviceDesc); + +//------------------------------------------------------------------------- +// D3DXGetMaxNumVideoModes: Returns the maximum number of video-modes . +// ----------------------- +// +// Params: +// [in] DWORD deviceIndex: The device being referred to. +// [in] DWORD flags: If D3DX_GVM_REFRESHRATE is set, then the refresh +// rates are not ignored. +// +// D3DXGetVideoMode: Describes a particular video mode for this device +// ---------------- +// +// Note: These queries will simply give you a list of modes that the +// display adapter tells DirectX that it supports. +// There is no guarantee that D3DXCreateContext(Ex) will succeed +// with all listed video modes. This is a fundamental limitation +// of the current DirectX architecture which D3DX cannot hide in +// any clean way. +// +// Params: +// [in] DWORD deviceIndex: The device being referred to. +// [in] DWORD flags: If D3DX_GVM_REFRESHRATE is set, then the refresh +// rates are returned +// [in] DWORD which: Which VideoMode ? Starts at 0. +// [out] D3DX_VIDMODEDESC* pModeList: Pointer to the D3DX_VIDMODEDESC +// structure that will be filled in. +//------------------------------------------------------------------------- +DWORD WINAPI + D3DXGetMaxNumVideoModes(DWORD deviceIndex, + DWORD flags); + +HRESULT WINAPI + D3DXGetVideoMode(DWORD deviceIndex, + DWORD flags, + DWORD modeIndex, + D3DX_VIDMODEDESC* pModeDesc); + +#define D3DX_GVM_REFRESHRATE 0x00000001 +//------------------------------------------------------------------------- +// D3DXGetMaxSurfaceFormats: Returns the maximum number of surface +// ------------------------ formats supported by the device at that +// video mode. +// +// D3DXGetSurfaceFormat: Describes one of the supported surface formats. +// --------------------- +// +// Params: +// [in] DWORD deviceIndex: The device being referred to. +// [in] D3DX_VIDMODEDESC* pDesc: The display mode at which the supported +// surface formats are requested. If it is +// NULL, the current display mode is +// assumed. +// [in] DWORD surfClassFlags: Required surface classes. Only surface +// formats which support all specified +// surface classes will be returned. +// (Multiple surface classes may be specified +// using bitwise OR.) +// [in] DWORD which: Which surface formats to retrieve. Starts at 0. +// [out] D3DX_SURFACEFORMAT* pFormat: The surface format +//------------------------------------------------------------------------- +DWORD WINAPI + D3DXGetMaxSurfaceFormats(DWORD deviceIndex, + D3DX_VIDMODEDESC* pDesc, + DWORD surfClassFlags); +HRESULT WINAPI + D3DXGetSurfaceFormat(DWORD deviceIndex, + D3DX_VIDMODEDESC* pDesc, + DWORD surfClassFlags, + DWORD surfaceIndex, + D3DX_SURFACEFORMAT* pFormat); + + +//------------------------------------------------------------------------- +// D3DXGetCurrentVideoMode: Retrieves the current video mode for this device. +// ------------------- +// +// Params: +// [in] DWORD deviceIndex: The device being referred to. +// [out] D3DX_VIDMODEDESC* pVidMode: The current video mode +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXGetCurrentVideoMode(DWORD deviceIndex, + D3DX_VIDMODEDESC* pVidMode); + +//------------------------------------------------------------------------- +// D3DXGetDeviceCaps: Lists all the capabilities of a device at a display +// mode. +// ---------------- +// +// Params: +// [in] DWORD deviceIndex: The device being referred to. +// [in] D3DX_VIDMODEDESC* pDesc: If this is NULL, we will return the +// caps at the current display mode of +// the device. +// [out] D3DDEVICEDESC7* pD3DDeviceDesc7: D3D Caps ( NULL to ignore +// parameter) +// [out] DDCAPS7* pDDHalCaps: DDraw HAL Caps (NULL to ignore parameter) +// [out] DDCAPS7* pDDHelCaps: DDraw HEL Caps (NULL to ignore paramter) +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXGetDeviceCaps(DWORD deviceIndex, + D3DX_VIDMODEDESC* pVidMode, + D3DDEVICEDESC7* pD3DCaps, + DDCAPS* pDDHALCaps, + DDCAPS* pDDHELCaps); + +//------------------------------------------------------------------------- +// D3DXCreateContext: Initializes the chosen device. It is the simplest init +// ----------------- function available. Parameters are treated the same +// as the matching subset of parameters in +// D3DXCreateContextEx, documented below. +// Remaining D3DXCreateContextEx parameters that are +// not present in D3DXCreateContext are treated as +// D3DX_DEFAULT. Note that multimon is not supported +// with D3DXCreateContext. +// +// D3DXCreateContextEx: A more advanced function to initialize the device. +// ------------------- Also accepts D3DX_DEFAULT for most of the parameters +// and then will do what D3DXCreateContext did. +// +// Note: Do not expect D3DXCreateContext(Ex) to be fail-safe (as with any +// API). Supported device capablilites should be used as a guide +// for choosing parameter values. Keep in mind that there will +// inevitably be some combinations of parameters that just do not work. +// +// Params: +// [in] DWORD deviceIndex: The device being referred to. +// [in] DWORD flags: The valid flags are D3DX_CONTEXT_FULLSCREEN, and +// D3DX_CONTEXT_OFFSCREEN. These flags cannot both +// be specified. If no flags are specified, the +// context defaults to windowed mode. +// +// [in] HWND hwnd: Device window. See note. +// [in] HWND hwndFocus: Window which receives keyboard messages from +// the device window. The device window should be +// a child of focus window. Useful for multimon +// applications. See note. +// NOTE: +// windowed: +// hwnd must be a valid window. hwndFocus must be NULL or +// D3DX_DEFAULT. +// +// fullscreen: +// Either hwnd or hwndFocus must be a valid window. (Both cannot +// be NULL or D3DX_DEFAULT). If hwnd is NULL or D3DX_DEFAULT, +// a default device window will be created as a child of hwndFocus. +// +// offscreen: +// Both hwnd and hwndFocus must be NULL or D3DX_DEFAULT +// +// [in] DWORD numColorBits: If D3DX_DEFAULT is passed for windowed mode, +// the current desktop's color depth is chosen. +// For full screen mode, D3DX_DEFAULT causes 16 +// bit color to be used. +// [in] DWORD numAlphaBits: If D3DX_DEFAULT is passed, 0 is chosen. +// [in] DWORD numDepthbits: If D3DX_DEFAULT is passed, +// the highest available number of depth bits +// is chosen. See note. +// [in] DWORD numStencilBits: If D3DX_DEFAULT is passed, the highest +// available number of stencil bits is chosen. +// See note. +// +// NOTE: If both numDepthBits and numStencilBits are D3DX_DEFAULT, +// D3DX first picks the highest available number of stencil +// bits. Then, for the chosen number of stencil bits, +// the highest available number of depth bits is chosen. +// If only one of numStencilBits or numDepthBits +// is D3DX_DEFAULT, the highest number of bits available +// for this parameter is chosen out of only the formats +// that support the number of bits requested for the +// fixed parameter. +// +// [in] DWORD numBackBuffers: Number of back buffers, or D3DX_DEFAULT. +// See note. +// +// NOTE: +// windowed: D3DX_DEFAULT means 1. You must specify one back buffer. +// +// fullscreen: D3DX_DEFAULT means 1. Any number of back buffers can be +// specified. +// +// offscreen: D3DX_DEFAULT means 0. You cannot specify additional back +// buffers. +// +// [in] DWORD width: Width, in pixels, or D3DX_DEFAULT. See note. +// [in] DWORD height: Height, in pixels, or D3DX_DEFAULT. See note. +// +// NOTE: +// windowed: If either width or height is D3DX_DEFAULT, both values +// default to the dimensions of the client area of hwnd. +// +// fullscreen: If either width or height is D3DX_DEFAULT, width +// defaults to 640, and height defaults to 480. +// +// offscreen: An error is returned if either width or height is +// D3DX_DEFAULT. +// +// [in] DWORD refreshRate: D3DX_DEFAULT means we let ddraw choose for +// us. Ignored for windowed and offscreen modes. +// [out] LPD3DXCONTEXT* ppCtx: This is the Context object that is used for +// rendering on that device. +// +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateContext(DWORD deviceIndex, + DWORD flags, + HWND hwnd, + DWORD width, + DWORD height, + LPD3DXCONTEXT* ppCtx); + +HRESULT WINAPI + D3DXCreateContextEx(DWORD deviceIndex, + DWORD flags, + HWND hwnd, + HWND hwndFocus, + DWORD numColorBits, + DWORD numAlphaBits, + DWORD numDepthbits, + DWORD numStencilBits, + DWORD numBackBuffers, + DWORD width, + DWORD height, + DWORD refreshRate, + LPD3DXCONTEXT* ppCtx); + +// The D3DXCreateContext(Ex) flags are: +#define D3DX_CONTEXT_FULLSCREEN 0x00000001 +#define D3DX_CONTEXT_OFFSCREEN 0x00000002 + +//------------------------------------------------------------------------- +// D3DXGetErrorString: Prints out the error string given an hresult. Prints +// ------------------ Win32 as well as DX6 error messages besides the D3DX +// messages. +// +// Params: +// [in] HRESULT hr: The error code to be deciphered. +// [in] DWORD strLength: Length of the string passed in. +// [out] LPSTR pStr: The string output. This string of appropriate +// size needs to be passed in. +//------------------------------------------------------------------------- +void WINAPI + D3DXGetErrorString(HRESULT hr, + DWORD strLength, + LPSTR pStr); + +//------------------------------------------------------------------------- +// D3DXMakeDDPixelFormat: Fills in a DDPIXELFORMAT structure based on the +// --------------------- D3DX surface format requested. +// +// Params: +// [in] D3DX_SURFACEFORMAT d3dxFormat: Surface format. +// [out] DDPIXELFORMAT* pddpf: Pixel format matching the given +// surface format. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXMakeDDPixelFormat(D3DX_SURFACEFORMAT d3dxFormat, + DDPIXELFORMAT* pddpf); + +//------------------------------------------------------------------------- +// D3DXMakeSurfaceFormat: Determines the surface format corresponding to +// --------------------- a given DDPIXELFORMAT. +// +// Params: +// [in] DDPIXELFORMAT* pddpf: Pixel format. +// Return Value: +// D3DX_SURFACEFORMAT: Surface format matching the given pixel format. +// D3DX_SF_UNKNOWN if the format is not supported +//------------------------------------------------------------------------- +D3DX_SURFACEFORMAT WINAPI + D3DXMakeSurfaceFormat(DDPIXELFORMAT* pddpf); + +#ifdef __cplusplus +} +#endif //__cplusplus + +/////////////////////////////////////////////////////////////////////////// +// Interfaces: +/////////////////////////////////////////////////////////////////////////// + +//------------------------------------------------------------------------- +// ID3DXContext interface: +// +// This encapsulates all the stuff that the app might +// want to do at initialization time and any global control over d3d and +// ddraw. +//------------------------------------------------------------------------- + + +DECLARE_INTERFACE_(ID3DXContext, IUnknown) +{ + // + // IUnknown methods + // + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID* ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // Get the DDraw and Direct3D objects to call DirectDraw or + // Direct3D Immediate Mode functions. + // If the objects don't exist (because they have not + // been created for some reason) NULL is returned. + // All the objects returned in the following Get* functions + // are addref'ed. It is the application's responsibility to + // release them when no longer needed. + STDMETHOD_(LPDIRECTDRAW7,GetDD)(THIS) PURE; + STDMETHOD_(LPDIRECT3D7,GetD3D)(THIS) PURE; + STDMETHOD_(LPDIRECT3DDEVICE7,GetD3DDevice)(THIS) PURE; + + // Get the various buffers that get created at the init time + // These are addref'ed as well. It is the application's responsibility + // to release them before the app quits or when it needs a resize. + STDMETHOD_(LPDIRECTDRAWSURFACE7,GetPrimary)(THIS) PURE; + STDMETHOD_(LPDIRECTDRAWSURFACE7,GetZBuffer)(THIS) PURE; + STDMETHOD_(LPDIRECTDRAWSURFACE7,GetBackBuffer)(THIS_ DWORD which) PURE; + + // Get the associated window handles + STDMETHOD_(HWND,GetWindow)(THIS) PURE; + STDMETHOD_(HWND,GetFocusWindow)(THIS) PURE; + + // + // Various Get methods, in case the user had specified default + // parameters + // + STDMETHOD(GetDeviceIndex)(THIS_ + LPDWORD pDeviceIndex, + LPDWORD pHwLevel) PURE; + + STDMETHOD_(DWORD, GetNumBackBuffers)(THIS) PURE; + + STDMETHOD(GetNumBits)(THIS_ + LPDWORD pColorBits, + LPDWORD pDepthBits, + LPDWORD pAlphaBits, + LPDWORD pStencilBits) PURE; + + STDMETHOD(GetBufferSize)(THIS_ + LPDWORD pWidth, + LPDWORD pHeight) PURE; + + // Get the flags that were used to create this context + STDMETHOD_(DWORD, GetCreationFlags)(THIS) PURE; + STDMETHOD_(DWORD, GetRefreshRate)(THIS) PURE; + + // Restoring surfaces in case stuff is lost + STDMETHOD(RestoreSurfaces)(THIS) PURE; + + // Resize all the buffers to the new width and height + STDMETHOD(Resize)(THIS_ DWORD width, DWORD height) PURE; + + // Update the frame using a flip or a blit, + // If the D3DX_UPDATE_NOVSYNC flag is set, blit is used if the + // driver cannot flip without waiting for vsync in full-screen mode. + STDMETHOD(UpdateFrame)(THIS_ DWORD flags) PURE; + + // Render a string at the specified coordinates, with the specified + // colour. This is only provided as a convenience for + // debugging/information during development. + // topLeftX and topLeftY represent the location of the top left corner + // of the string, on the render target. + // The coordinate and color parameters each have a range of 0.0-1.0 + STDMETHOD(DrawDebugText)(THIS_ + float topLeftX, + float topLeftY, + D3DCOLOR color, + LPSTR pString) PURE; + + // Clears to the current viewport + // The following are the valid flags: + // D3DCLEAR_TARGET (to clear the render target ) + // D3DCLEAR_ZBUFFER (to clear the depth-buffer ) + // D3DCLEAR_STENCIL (to clear the stencil-buffer ) + STDMETHOD(Clear)(THIS_ DWORD ClearFlags) PURE; + + STDMETHOD(SetClearColor)(THIS_ D3DCOLOR color ) PURE; + STDMETHOD(SetClearDepth)(THIS_ float z) PURE; + STDMETHOD(SetClearStencil)(THIS_ DWORD stencil) PURE; +}; + + +//------------------------------------------------------------------------- +// Flags for Update member function: +// + +// Flag to indicate that blit should be used instead of a flip +// for full-screen rendering. +#define D3DX_UPDATE_NOVSYNC (1<<0) + +/////////////////////////////////////////////////////////////////////////// +// Texturing APIs: +/////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +//------------------------------------------------------------------------- +// D3DXCheckTextureRequirements: Return information about texture creation +// ---------------------------- (used by CreateTexture, CreateTextureFromFile +// and CreateCubeMapTexture) +// +// Parameters: +// +// pd3dDevice +// The D3D device with which the texture is going to be used. +// pFlags +// allows specification of D3DX_TEXTURE_NOMIPMAP +// D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation +// is not supported. +// pWidth +// width in pixels or NULL +// returns corrected width +// pHeight +// height in pixels or NULL +// returns corrected height +// pPixelFormat +// surface format +// returns best match to input format +// +// Notes: 1. Unless the flags is set to specifically prevent creating +// mipmaps, mipmaps are generated all the way till 1x1 surface. +// 2. width, height and pixelformat are altered based on available +// hardware. For example: +// a. Texture dimensions may be required to be powers of 2 +// b. We may require width == height for some devices +// c. If PixelFormat is unavailable, a best fit is made +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCheckTextureRequirements( LPDIRECT3DDEVICE7 pd3dDevice, + LPDWORD pFlags, + LPDWORD pWidth, + LPDWORD pHeight, + D3DX_SURFACEFORMAT* pPixelFormat); + +//------------------------------------------------------------------------- +// D3DXCreateTexture: Create an empty texture object +// ----------------- +// +// Parameters: +// +// pd3dDevice +// The D3D device with which the texture is going to be used. +// pFlags +// allows specification of D3DX_TEXTURE_NOMIPMAP +// D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation +// is not supported. Additionally, D3DX_TEXTURE_STAGE can be specified +// to indicate which texture stage the texture is for e.g. +// D3D_TEXTURE_STAGE1 indicates that the texture is for use with texture +// stage one. Stage Zero is the default if no TEXTURE_STAGE flags are +// set. +// pWidth +// width in pixels; 0 or NULL is unacceptable +// returns corrected width +// pHeight +// height in pixels; 0 or NULL is unacceptable +// returns corrected height +// pPixelFormat +// surface format. D3DX_DEFAULT is unacceptable. +// returns actual format that was used +// pDDPal +// DDraw palette that is set (if present) on paletted surfaces. +// It is ignored even if it is set, for non-paletted surfaces. +// ppDDSurf +// The ddraw surface that will be created +// pNumMipMaps +// the number of mipmaps actually generated +// +// Notes: See notes for D3DXCheckTextureRequirements. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTexture( LPDIRECT3DDEVICE7 pd3dDevice, + LPDWORD pFlags, + LPDWORD pWidth, + LPDWORD pHeight, + D3DX_SURFACEFORMAT* pPixelFormat, + LPDIRECTDRAWPALETTE pDDPal, + LPDIRECTDRAWSURFACE7* ppDDSurf, + LPDWORD pNumMipMaps); + +//------------------------------------------------------------------------- +// D3DXCreateCubeMapTexture: Create blank cube-map texture +// ------------------------ +// +// Parameters: +// +// pd3dDevice +// The D3D device with which the texture is going to be used. +// pFlags +// allows specification of D3DX_TEXTURE_NOMIPMAP +// D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation +// is not supported. Additionally, D3DX_TEXTURE_STAGE can be specified +// to indicate which texture stage the texture is for e.g. +// D3D_TEXTURE_STAGE1 indicates that the texture is for use with texture +// stage one. Stage Zero is the default if no TEXTURE_STAGE flags are +// set. +// cubefaces +// allows specification of which faces of the cube-map to generate. +// D3DX_DEFAULT, 0, and DDSCAPS2_CUBEMAP_ALLFACES all mean +// "create all 6 faces of the cubemap". Any combination of +// DDSCAPS2_CUBEMAP_POSITIVEX, DDSCAPS2_CUBEMAP_NEGATIVEX, +// DDSCAPS2_CUBEMAP_POSITIVEY, DDSCAPS2_CUBEMAP_NEGATIVEY, +// DDSCAPS2_CUBEMAP_POSITIVEZ, or DDSCAPS2_CUBEMAP_NEGATIVEZ, is +// valid. +// colorEmptyFaces +// allows specification of the color to use for the faces that were not +// specified in the cubefaces parameter. +// pWidth +// width in pixels; 0 or NULL is unacceptable +// returns corrected width +// pHeight +// height in pixels; 0 or NULL is unacceptable +// returns corrected height +// pPixelFormat +// surface format. D3DX_DEFAULT is unacceptable. +// returns actual format that was used +// pDDPal +// DDraw palette that is set (if present) on paletted surfaces. +// It is ignored even if it is set, for non-paletted surfaces. +// ppDDSurf +// the ddraw surface that will be created +// pNumMipMaps +// the number of mipmaps generated for a particular face of the +// cubemap. +// +// Notes: See notes for D3DXCheckTextureRequirements. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateCubeMapTexture( LPDIRECT3DDEVICE7 pd3dDevice, + LPDWORD pFlags, + DWORD cubefaces, + D3DCOLOR colorEmptyFaces, + LPDWORD pWidth, + LPDWORD pHeight, + D3DX_SURFACEFORMAT *pPixelFormat, + LPDIRECTDRAWPALETTE pDDPal, + LPDIRECTDRAWSURFACE7* ppDDSurf, + LPDWORD pNumMipMaps); + + +//------------------------------------------------------------------------- +// D3DXCreateTextureFromFile: Create a texture object from a file or from the +// ------------------------- resource. Only BMP and DIB are supported from the +// resource portion of the executable. +// +// Parameters: +// +// pd3dDevice +// The D3D device with which the texture is going to be used. +// pFlags +// allows specification of D3DX_TEXTURE_NOMIPMAP +// D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation +// is not supported. Additionally, D3DX_TEXTURE_STAGE can be specified +// to indicate which texture stage the texture is for e.g. +// D3D_TEXTURE_STAGE1 indicates that the texture is for use with texture +// stage one. Stage Zero is the default if no TEXTURE_STAGE flags are +// set. +// pWidth +// Width in pixels. If 0 or D3DX_DEFAULT, the width will be taken +// from the file +// returns corrected width +// pHeight +// Height in pixels. If 0 or D3DX_DEFAULT, the height will be taken +// from the file +// returns corrected height +// pPixelFormat +// If D3DX_SF_UNKNOWN is passed in, pixel format closest to the bitmap +// will be chosen +// returns actual format that was used +// pDDPal +// DDraw palette that is set (if present) on paletted surfaces. +// It is ignored even if it is set, for non-paletted surfaces. +// ppDDSurf +// The ddraw surface that will be created. +// pNumMipMaps +// The number of mipmaps generated. +// pSrcName +// File name. BMP, DIB, DDS, are supported. +// +// TGA is supported for the following cases: 16, 24, 32bpp direct color and 8bpp palettized. +// Also, 8, 16bpp grayscale is supported. RLE versions of the above +// TGA formats are also supported. ColorKey and Premultiplied Alpha +// are not currently supported for TGA files. +// returns created format +// +// Notes: See notes for D3DXCheckTextureRequirements. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTextureFromFile( LPDIRECT3DDEVICE7 pd3dDevice, + LPDWORD pFlags, + LPDWORD pWidth, + LPDWORD pHeight, + D3DX_SURFACEFORMAT* pPixelFormat, + LPDIRECTDRAWPALETTE pDDPal, + LPDIRECTDRAWSURFACE7* ppDDSurf, + LPDWORD pNumMipMaps, + LPSTR pSrcName, + D3DX_FILTERTYPE filterType); + +//------------------------------------------------------------------------- +// D3DXLoadTextureFromFile: Load from a file into a mipmap level. Doing the +// ----------------------- necessary color conversion and rescaling. File +// format support is identical to +// D3DXCreateTextureFromFile's. +// +// pd3dDevice +// The D3D device with which the texture is going to be used. +// pTexture +// a pointer to a DD7Surface which was created with either +// CreateTextureFromFile or CreateTexture. +// mipMapLevel +// indicates mipmap level +// Note: +// 1. Error if mipmap level doesn't exist +// 2. If D3DX_DEFAULT and equal number of mipmap levels exist +// then all the source mip-levels are loaded +// 3. If the source has mipmaps and the dest doesn't, use the top one +// 4. If the dest has miplevels and source doesn't, we expand +// 5. If there are unequal numbers of miplevels, we expand +// pSrcName +// File name. BMP, DIB, DDS, are supported. +// For details on TGA support, refer to the comments for +// D3DXCreateTextureFromFile +// pSrcRect +// the source rectangle or null (whole surface) +// pDestRect +// the destination rectangle or null (whole surface) +// filterType +// filter used for mipmap generation +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXLoadTextureFromFile( LPDIRECT3DDEVICE7 pd3dDevice, + LPDIRECTDRAWSURFACE7 pTexture, + DWORD mipMapLevel, + LPSTR pSrcName, + RECT* pSrcRect, + RECT* pDestRect, + D3DX_FILTERTYPE filterType); + +//------------------------------------------------------------------------- +// D3DXLoadTextureFromSurface: Load from a DDraw Surface into a mipmap level. +// -------------------------- Doing the necessary color conversion. +// +// pd3dDevice +// The D3D device with which the texture is going to be used. +// pTexture +// a pointer to a DD7Surface which was created with either +// CreateTextureFromFile or CreateTexture. +// mipMapLevel +// indicates mipmap level +// Note: +// 1. Error if mipmap level doesn't exist +// 2. If D3DX_DEFAULT and equal number of mipmap levels exist +// then all the source mip-levels are loaded +// 3. If the source has mipmaps and the dest doesn't, use the top one +// 4. If the dest has miplevels and source doesn't, we expand +// 5. If there are unequal numbers of miplevels, we expand +// pSurfaceSrc +// the source surface +// pSrcRect +// the source rectangle or null (whole surface) +// pDestRect +// the destination rectangle or null (whole surface) +// filterType +// filter used for mipmap generation +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXLoadTextureFromSurface( LPDIRECT3DDEVICE7 pd3dDevice, + LPDIRECTDRAWSURFACE7 pTexture, + DWORD mipMapLevel, + LPDIRECTDRAWSURFACE7 pSurfaceSrc, + RECT* pSrcRect, + RECT* pDestRect, + D3DX_FILTERTYPE filterType); + +//------------------------------------------------------------------------- +// D3DXLoadTextureFromMemory: Load a mip level from memory. Doing the necessary +// ------------------------- color conversion. +// +// pd3dDevice +// The D3D device with which the texture is going to be used. +// pTexture +// a pointer to a DD7Surface which was created with either +// CreateTextureFromFile or CreateTexture. +// mipMapLevel +// indicates mipmap level +// Note: +// 1. Error if mipmap level doesn't exist +// 2. If D3DX_DEFAULT and equal number of mipmap levels exist +// then all the source mip-levels are loaded +// 3. If the source has mipmaps and the dest doesn't, use the top one +// 4. If the dest has miplevels and source doesn't, we expand +// 5. If there are unequal numbers of miplevels, we expand +// pMemory +// pointer to source memory from which the texture will be loaded +// pDDPal +// DirectDraw Palette, that the app passes in optionally if the memory is +// supposed to be paletteized. +// srcPixelFormat +// PixelFormat of the source. +// srcPitch +// The pitch of the memory or D3DX_DEFAULT (based on srcPixelFormat) +// pDestRect +// The destination rectangle or null (whole surface) +// filterType +// filter used for mipmap generation +// +// Assumptions: The source (memory) is loaded in full +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXLoadTextureFromMemory( LPDIRECT3DDEVICE7 pd3dDevice, + LPDIRECTDRAWSURFACE7 pTexture, + DWORD mipMapLevel, + LPVOID pMemory, + LPDIRECTDRAWPALETTE pDDPal, + D3DX_SURFACEFORMAT srcPixelFormat, + DWORD srcPitch, + RECT* pDestRect, + D3DX_FILTERTYPE filterType); + +#ifdef __cplusplus +} +#endif //__cplusplus + +//------------------------------------------------------------------------- +// Flags for texture create functions; applies to +// D3DXCreateTexture, D3DXCreateCubeMapTexture and D3DXCreateTextureFromFile. +// + +// Flag to indicate that mipmap generation is not desired. +#define D3DX_TEXTURE_NOMIPMAP (1 << 8) + +// Flags to indicate which texture stage the texture is +// intended for use with. Specifying the stage is necessary at +// texture creation time for HW devices that expose the +// D3DDEVCAPS_SEPARATETEXTUREMEMORIES bit in their D3DDEVICEDESC +// structure. +#define D3DX_TEXTURE_STAGE0 (0) +#define D3DX_TEXTURE_STAGE1 (1) +#define D3DX_TEXTURE_STAGE2 (2) +#define D3DX_TEXTURE_STAGE3 (3) +#define D3DX_TEXTURE_STAGE4 (4) +#define D3DX_TEXTURE_STAGE5 (5) +#define D3DX_TEXTURE_STAGE6 (6) +#define D3DX_TEXTURE_STAGE7 (7) + +// Mask to extract the texture stage value out of the flags to +// the texture create functions. +#define D3DX_TEXTURE_STAGE_MASK (0x7) + +#endif //__D3DXCORE_H__ diff --git a/src/dep/include/DXSDK/include/d3dxerr.h b/src/dep/include/DXSDK/include/d3dxerr.h index dc97f56..155005b 100644 --- a/src/dep/include/DXSDK/include/d3dxerr.h +++ b/src/dep/include/DXSDK/include/d3dxerr.h @@ -1,407 +1,407 @@ -//---------------------------------------------------------------------- -// -// d3dxerr.h -- 0xC code definitions for the D3DX API -// -// Copyright (c) Microsoft Corp. All rights reserved. -// -//---------------------------------------------------------------------- -#ifndef __D3DXERR_H__ -#define __D3DXERR_H__ - -// -// -// Values are 32 bit values layed out as follows: -// -// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 -// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 -// +---+-+-+-----------------------+-------------------------------+ -// |Sev|C|R| Facility | Code | -// +---+-+-+-----------------------+-------------------------------+ -// -// where -// -// Sev - is the severity code -// -// 00 - Success -// 01 - Informational -// 10 - Warning -// 11 - Error -// -// C - is the Customer code flag -// -// R - is a reserved bit -// -// Facility - is the facility code -// -// Code - is the facility's status code -// -// -// Define the facility codes -// -#define FACILITY_D3DX 0x877 - - - -// -// MessageId: D3DXERR_NOMEMORY -// -// MessageText: -// -// Out of memory. -// -#define D3DXERR_NOMEMORY ((HRESULT)0xC8770BB8L) - - -// -// MessageId: D3DXERR_NULLPOINTER -// -// MessageText: -// -// A NULL pointer was passed as a parameter. -// -#define D3DXERR_NULLPOINTER ((HRESULT)0xC8770BB9L) - - -// -// MessageId: D3DXERR_INVALIDD3DXDEVICEINDEX -// -// MessageText: -// -// The Device Index passed in is invalid. -// -#define D3DXERR_INVALIDD3DXDEVICEINDEX ((HRESULT)0xC8770BBAL) - - -// -// MessageId: D3DXERR_NODIRECTDRAWAVAILABLE -// -// MessageText: -// -// DirectDraw has not been created. -// -#define D3DXERR_NODIRECTDRAWAVAILABLE ((HRESULT)0xC8770BBBL) - - -// -// MessageId: D3DXERR_NODIRECT3DAVAILABLE -// -// MessageText: -// -// Direct3D has not been created. -// -#define D3DXERR_NODIRECT3DAVAILABLE ((HRESULT)0xC8770BBCL) - - -// -// MessageId: D3DXERR_NODIRECT3DDEVICEAVAILABLE -// -// MessageText: -// -// Direct3D device has not been created. -// -#define D3DXERR_NODIRECT3DDEVICEAVAILABLE ((HRESULT)0xC8770BBDL) - - -// -// MessageId: D3DXERR_NOPRIMARYAVAILABLE -// -// MessageText: -// -// Primary surface has not been created. -// -#define D3DXERR_NOPRIMARYAVAILABLE ((HRESULT)0xC8770BBEL) - - -// -// MessageId: D3DXERR_NOZBUFFERAVAILABLE -// -// MessageText: -// -// Z buffer has not been created. -// -#define D3DXERR_NOZBUFFERAVAILABLE ((HRESULT)0xC8770BBFL) - - -// -// MessageId: D3DXERR_NOBACKBUFFERAVAILABLE -// -// MessageText: -// -// Backbuffer has not been created. -// -#define D3DXERR_NOBACKBUFFERAVAILABLE ((HRESULT)0xC8770BC0L) - - -// -// MessageId: D3DXERR_COULDNTUPDATECAPS -// -// MessageText: -// -// Failed to update caps database after changing display mode. -// -#define D3DXERR_COULDNTUPDATECAPS ((HRESULT)0xC8770BC1L) - - -// -// MessageId: D3DXERR_NOZBUFFER -// -// MessageText: -// -// Could not create Z buffer. -// -#define D3DXERR_NOZBUFFER ((HRESULT)0xC8770BC2L) - - -// -// MessageId: D3DXERR_INVALIDMODE -// -// MessageText: -// -// Display mode is not valid. -// -#define D3DXERR_INVALIDMODE ((HRESULT)0xC8770BC3L) - - -// -// MessageId: D3DXERR_INVALIDPARAMETER -// -// MessageText: -// -// One or more of the parameters passed is invalid. -// -#define D3DXERR_INVALIDPARAMETER ((HRESULT)0xC8770BC4L) - - -// -// MessageId: D3DXERR_INITFAILED -// -// MessageText: -// -// D3DX failed to initialize itself. -// -#define D3DXERR_INITFAILED ((HRESULT)0xC8770BC5L) - - -// -// MessageId: D3DXERR_STARTUPFAILED -// -// MessageText: -// -// D3DX failed to start up. -// -#define D3DXERR_STARTUPFAILED ((HRESULT)0xC8770BC6L) - - -// -// MessageId: D3DXERR_D3DXNOTSTARTEDYET -// -// MessageText: -// -// D3DXInitialize() must be called first. -// -#define D3DXERR_D3DXNOTSTARTEDYET ((HRESULT)0xC8770BC7L) - - -// -// MessageId: D3DXERR_NOTINITIALIZED -// -// MessageText: -// -// D3DX is not initialized yet. -// -#define D3DXERR_NOTINITIALIZED ((HRESULT)0xC8770BC8L) - - -// -// MessageId: D3DXERR_FAILEDDRAWTEXT -// -// MessageText: -// -// Failed to render text to the surface. -// -#define D3DXERR_FAILEDDRAWTEXT ((HRESULT)0xC8770BC9L) - - -// -// MessageId: D3DXERR_BADD3DXCONTEXT -// -// MessageText: -// -// Bad D3DX context. -// -#define D3DXERR_BADD3DXCONTEXT ((HRESULT)0xC8770BCAL) - - -// -// MessageId: D3DXERR_CAPSNOTSUPPORTED -// -// MessageText: -// -// The requested device capabilities are not supported. -// -#define D3DXERR_CAPSNOTSUPPORTED ((HRESULT)0xC8770BCBL) - - -// -// MessageId: D3DXERR_UNSUPPORTEDFILEFORMAT -// -// MessageText: -// -// The image file format is unrecognized. -// -#define D3DXERR_UNSUPPORTEDFILEFORMAT ((HRESULT)0xC8770BCCL) - - -// -// MessageId: D3DXERR_IFLERROR -// -// MessageText: -// -// The image file loading library error. -// -#define D3DXERR_IFLERROR ((HRESULT)0xC8770BCDL) - - -// -// MessageId: D3DXERR_FAILEDGETCAPS -// -// MessageText: -// -// Could not obtain device caps. -// -#define D3DXERR_FAILEDGETCAPS ((HRESULT)0xC8770BCEL) - - -// -// MessageId: D3DXERR_CANNOTRESIZEFULLSCREEN -// -// MessageText: -// -// Resize does not work for full-screen. -// -#define D3DXERR_CANNOTRESIZEFULLSCREEN ((HRESULT)0xC8770BCFL) - - -// -// MessageId: D3DXERR_CANNOTRESIZENONWINDOWED -// -// MessageText: -// -// Resize does not work for non-windowed contexts. -// -#define D3DXERR_CANNOTRESIZENONWINDOWED ((HRESULT)0xC8770BD0L) - - -// -// MessageId: D3DXERR_FRONTBUFFERALREADYEXISTS -// -// MessageText: -// -// Front buffer already exists. -// -#define D3DXERR_FRONTBUFFERALREADYEXISTS ((HRESULT)0xC8770BD1L) - - -// -// MessageId: D3DXERR_FULLSCREENPRIMARYEXISTS -// -// MessageText: -// -// The app is using the primary in full-screen mode. -// -#define D3DXERR_FULLSCREENPRIMARYEXISTS ((HRESULT)0xC8770BD2L) - - -// -// MessageId: D3DXERR_GETDCFAILED -// -// MessageText: -// -// Could not get device context. -// -#define D3DXERR_GETDCFAILED ((HRESULT)0xC8770BD3L) - - -// -// MessageId: D3DXERR_BITBLTFAILED -// -// MessageText: -// -// Could not bitBlt. -// -#define D3DXERR_BITBLTFAILED ((HRESULT)0xC8770BD4L) - - -// -// MessageId: D3DXERR_NOTEXTURE -// -// MessageText: -// -// There is no surface backing up this texture. -// -#define D3DXERR_NOTEXTURE ((HRESULT)0xC8770BD5L) - - -// -// MessageId: D3DXERR_MIPLEVELABSENT -// -// MessageText: -// -// There is no such miplevel for this surface. -// -#define D3DXERR_MIPLEVELABSENT ((HRESULT)0xC8770BD6L) - - -// -// MessageId: D3DXERR_SURFACENOTPALETTED -// -// MessageText: -// -// The surface is not paletted. -// -#define D3DXERR_SURFACENOTPALETTED ((HRESULT)0xC8770BD7L) - - -// -// MessageId: D3DXERR_ENUMFORMATSFAILED -// -// MessageText: -// -// An error occured while enumerating surface formats. -// -#define D3DXERR_ENUMFORMATSFAILED ((HRESULT)0xC8770BD8L) - - -// -// MessageId: D3DXERR_COLORDEPTHTOOLOW -// -// MessageText: -// -// D3DX only supports color depths of 16 bit or greater. -// -#define D3DXERR_COLORDEPTHTOOLOW ((HRESULT)0xC8770BD9L) - - -// -// MessageId: D3DXERR_INVALIDFILEFORMAT -// -// MessageText: -// -// The file format is invalid. -// -#define D3DXERR_INVALIDFILEFORMAT ((HRESULT)0xC8770BDAL) - - -// -// MessageId: D3DXERR_NOMATCHFOUND -// -// MessageText: -// -// No suitable match found. -// -#define D3DXERR_NOMATCHFOUND ((HRESULT)0xC8770BDBL) - - - -#endif //__D3DXERR_H__ - +//---------------------------------------------------------------------- +// +// d3dxerr.h -- 0xC code definitions for the D3DX API +// +// Copyright (c) Microsoft Corp. All rights reserved. +// +//---------------------------------------------------------------------- +#ifndef __D3DXERR_H__ +#define __D3DXERR_H__ + +// +// +// Values are 32 bit values layed out as follows: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +---+-+-+-----------------------+-------------------------------+ +// |Sev|C|R| Facility | Code | +// +---+-+-+-----------------------+-------------------------------+ +// +// where +// +// Sev - is the severity code +// +// 00 - Success +// 01 - Informational +// 10 - Warning +// 11 - Error +// +// C - is the Customer code flag +// +// R - is a reserved bit +// +// Facility - is the facility code +// +// Code - is the facility's status code +// +// +// Define the facility codes +// +#define FACILITY_D3DX 0x877 + + + +// +// MessageId: D3DXERR_NOMEMORY +// +// MessageText: +// +// Out of memory. +// +#define D3DXERR_NOMEMORY ((HRESULT)0xC8770BB8L) + + +// +// MessageId: D3DXERR_NULLPOINTER +// +// MessageText: +// +// A NULL pointer was passed as a parameter. +// +#define D3DXERR_NULLPOINTER ((HRESULT)0xC8770BB9L) + + +// +// MessageId: D3DXERR_INVALIDD3DXDEVICEINDEX +// +// MessageText: +// +// The Device Index passed in is invalid. +// +#define D3DXERR_INVALIDD3DXDEVICEINDEX ((HRESULT)0xC8770BBAL) + + +// +// MessageId: D3DXERR_NODIRECTDRAWAVAILABLE +// +// MessageText: +// +// DirectDraw has not been created. +// +#define D3DXERR_NODIRECTDRAWAVAILABLE ((HRESULT)0xC8770BBBL) + + +// +// MessageId: D3DXERR_NODIRECT3DAVAILABLE +// +// MessageText: +// +// Direct3D has not been created. +// +#define D3DXERR_NODIRECT3DAVAILABLE ((HRESULT)0xC8770BBCL) + + +// +// MessageId: D3DXERR_NODIRECT3DDEVICEAVAILABLE +// +// MessageText: +// +// Direct3D device has not been created. +// +#define D3DXERR_NODIRECT3DDEVICEAVAILABLE ((HRESULT)0xC8770BBDL) + + +// +// MessageId: D3DXERR_NOPRIMARYAVAILABLE +// +// MessageText: +// +// Primary surface has not been created. +// +#define D3DXERR_NOPRIMARYAVAILABLE ((HRESULT)0xC8770BBEL) + + +// +// MessageId: D3DXERR_NOZBUFFERAVAILABLE +// +// MessageText: +// +// Z buffer has not been created. +// +#define D3DXERR_NOZBUFFERAVAILABLE ((HRESULT)0xC8770BBFL) + + +// +// MessageId: D3DXERR_NOBACKBUFFERAVAILABLE +// +// MessageText: +// +// Backbuffer has not been created. +// +#define D3DXERR_NOBACKBUFFERAVAILABLE ((HRESULT)0xC8770BC0L) + + +// +// MessageId: D3DXERR_COULDNTUPDATECAPS +// +// MessageText: +// +// Failed to update caps database after changing display mode. +// +#define D3DXERR_COULDNTUPDATECAPS ((HRESULT)0xC8770BC1L) + + +// +// MessageId: D3DXERR_NOZBUFFER +// +// MessageText: +// +// Could not create Z buffer. +// +#define D3DXERR_NOZBUFFER ((HRESULT)0xC8770BC2L) + + +// +// MessageId: D3DXERR_INVALIDMODE +// +// MessageText: +// +// Display mode is not valid. +// +#define D3DXERR_INVALIDMODE ((HRESULT)0xC8770BC3L) + + +// +// MessageId: D3DXERR_INVALIDPARAMETER +// +// MessageText: +// +// One or more of the parameters passed is invalid. +// +#define D3DXERR_INVALIDPARAMETER ((HRESULT)0xC8770BC4L) + + +// +// MessageId: D3DXERR_INITFAILED +// +// MessageText: +// +// D3DX failed to initialize itself. +// +#define D3DXERR_INITFAILED ((HRESULT)0xC8770BC5L) + + +// +// MessageId: D3DXERR_STARTUPFAILED +// +// MessageText: +// +// D3DX failed to start up. +// +#define D3DXERR_STARTUPFAILED ((HRESULT)0xC8770BC6L) + + +// +// MessageId: D3DXERR_D3DXNOTSTARTEDYET +// +// MessageText: +// +// D3DXInitialize() must be called first. +// +#define D3DXERR_D3DXNOTSTARTEDYET ((HRESULT)0xC8770BC7L) + + +// +// MessageId: D3DXERR_NOTINITIALIZED +// +// MessageText: +// +// D3DX is not initialized yet. +// +#define D3DXERR_NOTINITIALIZED ((HRESULT)0xC8770BC8L) + + +// +// MessageId: D3DXERR_FAILEDDRAWTEXT +// +// MessageText: +// +// Failed to render text to the surface. +// +#define D3DXERR_FAILEDDRAWTEXT ((HRESULT)0xC8770BC9L) + + +// +// MessageId: D3DXERR_BADD3DXCONTEXT +// +// MessageText: +// +// Bad D3DX context. +// +#define D3DXERR_BADD3DXCONTEXT ((HRESULT)0xC8770BCAL) + + +// +// MessageId: D3DXERR_CAPSNOTSUPPORTED +// +// MessageText: +// +// The requested device capabilities are not supported. +// +#define D3DXERR_CAPSNOTSUPPORTED ((HRESULT)0xC8770BCBL) + + +// +// MessageId: D3DXERR_UNSUPPORTEDFILEFORMAT +// +// MessageText: +// +// The image file format is unrecognized. +// +#define D3DXERR_UNSUPPORTEDFILEFORMAT ((HRESULT)0xC8770BCCL) + + +// +// MessageId: D3DXERR_IFLERROR +// +// MessageText: +// +// The image file loading library error. +// +#define D3DXERR_IFLERROR ((HRESULT)0xC8770BCDL) + + +// +// MessageId: D3DXERR_FAILEDGETCAPS +// +// MessageText: +// +// Could not obtain device caps. +// +#define D3DXERR_FAILEDGETCAPS ((HRESULT)0xC8770BCEL) + + +// +// MessageId: D3DXERR_CANNOTRESIZEFULLSCREEN +// +// MessageText: +// +// Resize does not work for full-screen. +// +#define D3DXERR_CANNOTRESIZEFULLSCREEN ((HRESULT)0xC8770BCFL) + + +// +// MessageId: D3DXERR_CANNOTRESIZENONWINDOWED +// +// MessageText: +// +// Resize does not work for non-windowed contexts. +// +#define D3DXERR_CANNOTRESIZENONWINDOWED ((HRESULT)0xC8770BD0L) + + +// +// MessageId: D3DXERR_FRONTBUFFERALREADYEXISTS +// +// MessageText: +// +// Front buffer already exists. +// +#define D3DXERR_FRONTBUFFERALREADYEXISTS ((HRESULT)0xC8770BD1L) + + +// +// MessageId: D3DXERR_FULLSCREENPRIMARYEXISTS +// +// MessageText: +// +// The app is using the primary in full-screen mode. +// +#define D3DXERR_FULLSCREENPRIMARYEXISTS ((HRESULT)0xC8770BD2L) + + +// +// MessageId: D3DXERR_GETDCFAILED +// +// MessageText: +// +// Could not get device context. +// +#define D3DXERR_GETDCFAILED ((HRESULT)0xC8770BD3L) + + +// +// MessageId: D3DXERR_BITBLTFAILED +// +// MessageText: +// +// Could not bitBlt. +// +#define D3DXERR_BITBLTFAILED ((HRESULT)0xC8770BD4L) + + +// +// MessageId: D3DXERR_NOTEXTURE +// +// MessageText: +// +// There is no surface backing up this texture. +// +#define D3DXERR_NOTEXTURE ((HRESULT)0xC8770BD5L) + + +// +// MessageId: D3DXERR_MIPLEVELABSENT +// +// MessageText: +// +// There is no such miplevel for this surface. +// +#define D3DXERR_MIPLEVELABSENT ((HRESULT)0xC8770BD6L) + + +// +// MessageId: D3DXERR_SURFACENOTPALETTED +// +// MessageText: +// +// The surface is not paletted. +// +#define D3DXERR_SURFACENOTPALETTED ((HRESULT)0xC8770BD7L) + + +// +// MessageId: D3DXERR_ENUMFORMATSFAILED +// +// MessageText: +// +// An error occured while enumerating surface formats. +// +#define D3DXERR_ENUMFORMATSFAILED ((HRESULT)0xC8770BD8L) + + +// +// MessageId: D3DXERR_COLORDEPTHTOOLOW +// +// MessageText: +// +// D3DX only supports color depths of 16 bit or greater. +// +#define D3DXERR_COLORDEPTHTOOLOW ((HRESULT)0xC8770BD9L) + + +// +// MessageId: D3DXERR_INVALIDFILEFORMAT +// +// MessageText: +// +// The file format is invalid. +// +#define D3DXERR_INVALIDFILEFORMAT ((HRESULT)0xC8770BDAL) + + +// +// MessageId: D3DXERR_NOMATCHFOUND +// +// MessageText: +// +// No suitable match found. +// +#define D3DXERR_NOMATCHFOUND ((HRESULT)0xC8770BDBL) + + + +#endif //__D3DXERR_H__ + diff --git a/src/dep/include/DXSDK/include/d3dxmath.h b/src/dep/include/DXSDK/include/d3dxmath.h index 9491bbc..685cc33 100644 --- a/src/dep/include/DXSDK/include/d3dxmath.h +++ b/src/dep/include/DXSDK/include/d3dxmath.h @@ -1,1085 +1,1085 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dxmath.h -// Content: D3DX math types and functions -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DXMATH_H__ -#define __D3DXMATH_H__ - -#include -#include -#include -#include "d3dxerr.h" - -#ifndef D3DXINLINE -#ifdef __cplusplus -#define D3DXINLINE inline -#else -#define D3DXINLINE _inline -#endif -#endif - -#pragma warning(disable:4201) // anonymous unions warning - - - -typedef struct ID3DXMatrixStack *LPD3DXMATRIXSTACK; - -// {E3357330-CC5E-11d2-A434-00A0C90629A8} -DEFINE_GUID( IID_ID3DXMatrixStack, - 0xe3357330, 0xcc5e, 0x11d2, 0xa4, 0x34, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); - - -//=========================================================================== -// -// General purpose utilities -// -//=========================================================================== -#define D3DX_PI ((float) 3.141592654f) -#define D3DX_1BYPI ((float) 0.318309886f) - -#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) -#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) - - - -//=========================================================================== -// -// Vectors -// -//=========================================================================== - -//-------------------------- -// 2D Vector -//-------------------------- -typedef struct D3DXVECTOR2 -{ -#ifdef __cplusplus -public: - D3DXVECTOR2() {}; - D3DXVECTOR2( const float * ); - D3DXVECTOR2( float x, float y ); - - // casting - operator float* (); - operator const float* () const; - - // assignment operators - D3DXVECTOR2& operator += ( const D3DXVECTOR2& ); - D3DXVECTOR2& operator -= ( const D3DXVECTOR2& ); - D3DXVECTOR2& operator *= ( float ); - D3DXVECTOR2& operator /= ( float ); - - // unary operators - D3DXVECTOR2 operator + () const; - D3DXVECTOR2 operator - () const; - - // binary operators - D3DXVECTOR2 operator + ( const D3DXVECTOR2& ) const; - D3DXVECTOR2 operator - ( const D3DXVECTOR2& ) const; - D3DXVECTOR2 operator * ( float ) const; - D3DXVECTOR2 operator / ( float ) const; - - friend D3DXVECTOR2 operator * ( float, const D3DXVECTOR2& ); - - BOOL operator == ( const D3DXVECTOR2& ) const; - BOOL operator != ( const D3DXVECTOR2& ) const; - - -public: -#endif //__cplusplus - float x, y; -} D3DXVECTOR2, *LPD3DXVECTOR2; - - -//-------------------------- -// 3D Vector -//-------------------------- -typedef struct D3DXVECTOR3 -{ -#ifdef __cplusplus -public: - D3DXVECTOR3() {}; - D3DXVECTOR3( const float * ); - D3DXVECTOR3( const D3DVECTOR& ); - D3DXVECTOR3( float x, float y, float z ); - - // casting - operator float* (); - operator const float* () const; - - operator D3DVECTOR* (); - operator const D3DVECTOR* () const; - - operator D3DVECTOR& (); - operator const D3DVECTOR& () const; - - // assignment operators - D3DXVECTOR3& operator += ( const D3DXVECTOR3& ); - D3DXVECTOR3& operator -= ( const D3DXVECTOR3& ); - D3DXVECTOR3& operator *= ( float ); - D3DXVECTOR3& operator /= ( float ); - - // unary operators - D3DXVECTOR3 operator + () const; - D3DXVECTOR3 operator - () const; - - // binary operators - D3DXVECTOR3 operator + ( const D3DXVECTOR3& ) const; - D3DXVECTOR3 operator - ( const D3DXVECTOR3& ) const; - D3DXVECTOR3 operator * ( float ) const; - D3DXVECTOR3 operator / ( float ) const; - - friend D3DXVECTOR3 operator * ( float, const struct D3DXVECTOR3& ); - - BOOL operator == ( const D3DXVECTOR3& ) const; - BOOL operator != ( const D3DXVECTOR3& ) const; - -public: -#endif //__cplusplus - float x, y, z; -} D3DXVECTOR3, *LPD3DXVECTOR3; - - -//-------------------------- -// 4D Vector -//-------------------------- -typedef struct D3DXVECTOR4 -{ -#ifdef __cplusplus -public: - D3DXVECTOR4() {}; - D3DXVECTOR4( const float* ); - D3DXVECTOR4( float x, float y, float z, float w ); - - // casting - operator float* (); - operator const float* () const; - - // assignment operators - D3DXVECTOR4& operator += ( const D3DXVECTOR4& ); - D3DXVECTOR4& operator -= ( const D3DXVECTOR4& ); - D3DXVECTOR4& operator *= ( float ); - D3DXVECTOR4& operator /= ( float ); - - // unary operators - D3DXVECTOR4 operator + () const; - D3DXVECTOR4 operator - () const; - - // binary operators - D3DXVECTOR4 operator + ( const D3DXVECTOR4& ) const; - D3DXVECTOR4 operator - ( const D3DXVECTOR4& ) const; - D3DXVECTOR4 operator * ( float ) const; - D3DXVECTOR4 operator / ( float ) const; - - friend D3DXVECTOR4 operator * ( float, const D3DXVECTOR4& ); - - BOOL operator == ( const D3DXVECTOR4& ) const; - BOOL operator != ( const D3DXVECTOR4& ) const; - -public: -#endif //__cplusplus - float x, y, z, w; -} D3DXVECTOR4, *LPD3DXVECTOR4; - - -//=========================================================================== -// -// Matrices -// -//=========================================================================== -typedef struct D3DXMATRIX -{ -#ifdef __cplusplus -public: - D3DXMATRIX() {}; - D3DXMATRIX( const float * ); - D3DXMATRIX( const D3DMATRIX& ); - D3DXMATRIX( float m00, float m01, float m02, float m03, - float m10, float m11, float m12, float m13, - float m20, float m21, float m22, float m23, - float m30, float m31, float m32, float m33 ); - - - // access grants - float& operator () ( UINT iRow, UINT iCol ); - float operator () ( UINT iRow, UINT iCol ) const; - - // casting operators - operator float* (); - operator const float* () const; - - operator D3DMATRIX* (); - operator const D3DMATRIX* () const; - - operator D3DMATRIX& (); - operator const D3DMATRIX& () const; - - // assignment operators - D3DXMATRIX& operator *= ( const D3DXMATRIX& ); - D3DXMATRIX& operator += ( const D3DXMATRIX& ); - D3DXMATRIX& operator -= ( const D3DXMATRIX& ); - D3DXMATRIX& operator *= ( float ); - D3DXMATRIX& operator /= ( float ); - - // unary operators - D3DXMATRIX operator + () const; - D3DXMATRIX operator - () const; - - // binary operators - D3DXMATRIX operator * ( const D3DXMATRIX& ) const; - D3DXMATRIX operator + ( const D3DXMATRIX& ) const; - D3DXMATRIX operator - ( const D3DXMATRIX& ) const; - D3DXMATRIX operator * ( float ) const; - D3DXMATRIX operator / ( float ) const; - - friend D3DXMATRIX operator * ( float, const D3DXMATRIX& ); - - BOOL operator == ( const D3DXMATRIX& ) const; - BOOL operator != ( const D3DXMATRIX& ) const; - - -#endif //__cplusplus - - union - { - float m[4][4]; -#ifdef __cplusplus - struct - { - float m00, m01, m02, m03; - float m10, m11, m12, m13; - float m20, m21, m22, m23; - float m30, m31, m32, m33; - }; -#endif //__cplusplus - }; -} D3DXMATRIX, *LPD3DXMATRIX; - - -//=========================================================================== -// -// Quaternions -// -//=========================================================================== -typedef struct D3DXQUATERNION -{ -#ifdef __cplusplus -public: - D3DXQUATERNION() {} - D3DXQUATERNION( const float * ); - D3DXQUATERNION( float x, float y, float z, float w ); - - // casting - operator float* (); - operator const float* () const; - - // assignment operators - D3DXQUATERNION& operator += ( const D3DXQUATERNION& ); - D3DXQUATERNION& operator -= ( const D3DXQUATERNION& ); - D3DXQUATERNION& operator *= ( const D3DXQUATERNION& ); - D3DXQUATERNION& operator *= ( float ); - D3DXQUATERNION& operator /= ( float ); - - // unary operators - D3DXQUATERNION operator + () const; - D3DXQUATERNION operator - () const; - - // binary operators - D3DXQUATERNION operator + ( const D3DXQUATERNION& ) const; - D3DXQUATERNION operator - ( const D3DXQUATERNION& ) const; - D3DXQUATERNION operator * ( const D3DXQUATERNION& ) const; - D3DXQUATERNION operator * ( float ) const; - D3DXQUATERNION operator / ( float ) const; - - friend D3DXQUATERNION operator * (float, const D3DXQUATERNION& ); - - BOOL operator == ( const D3DXQUATERNION& ) const; - BOOL operator != ( const D3DXQUATERNION& ) const; - -#endif //__cplusplus - float x, y, z, w; -} D3DXQUATERNION, *LPD3DXQUATERNION; - - -//=========================================================================== -// -// Planes -// -//=========================================================================== -typedef struct D3DXPLANE -{ -#ifdef __cplusplus -public: - D3DXPLANE() {} - D3DXPLANE( const float* ); - D3DXPLANE( float a, float b, float c, float d ); - - // casting - operator float* (); - operator const float* () const; - - // unary operators - D3DXPLANE operator + () const; - D3DXPLANE operator - () const; - - // binary operators - BOOL operator == ( const D3DXPLANE& ) const; - BOOL operator != ( const D3DXPLANE& ) const; - -#endif //__cplusplus - float a, b, c, d; -} D3DXPLANE, *LPD3DXPLANE; - - -//=========================================================================== -// -// Colors -// -//=========================================================================== - -typedef struct D3DXCOLOR -{ -#ifdef __cplusplus -public: - D3DXCOLOR() {} - D3DXCOLOR( DWORD argb ); - D3DXCOLOR( const float * ); - D3DXCOLOR( const D3DCOLORVALUE& ); - D3DXCOLOR( float r, float g, float b, float a ); - - // casting - operator DWORD () const; - - operator float* (); - operator const float* () const; - - operator D3DCOLORVALUE* (); - operator const D3DCOLORVALUE* () const; - - operator D3DCOLORVALUE& (); - operator const D3DCOLORVALUE& () const; - - // assignment operators - D3DXCOLOR& operator += ( const D3DXCOLOR& ); - D3DXCOLOR& operator -= ( const D3DXCOLOR& ); - D3DXCOLOR& operator *= ( float ); - D3DXCOLOR& operator /= ( float ); - - // unary operators - D3DXCOLOR operator + () const; - D3DXCOLOR operator - () const; - - // binary operators - D3DXCOLOR operator + ( const D3DXCOLOR& ) const; - D3DXCOLOR operator - ( const D3DXCOLOR& ) const; - D3DXCOLOR operator * ( float ) const; - D3DXCOLOR operator / ( float ) const; - - friend D3DXCOLOR operator * (float, const D3DXCOLOR& ); - - BOOL operator == ( const D3DXCOLOR& ) const; - BOOL operator != ( const D3DXCOLOR& ) const; - -#endif //__cplusplus - FLOAT r, g, b, a; -} D3DXCOLOR, *LPD3DXCOLOR; - - - -//=========================================================================== -// -// D3DX math functions: -// -// NOTE: -// * All these functions can take the same object as in and out parameters. -// -// * Out parameters are typically also returned as return values, so that -// the output of one function may be used as a parameter to another. -// -//=========================================================================== - -//-------------------------- -// 2D Vector -//-------------------------- - -// inline - -float D3DXVec2Length - ( const D3DXVECTOR2 *pV ); - -float D3DXVec2LengthSq - ( const D3DXVECTOR2 *pV ); - -float D3DXVec2Dot - ( const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ); - -// Z component of ((x1,y1,0) cross (x2,y2,0)) -float D3DXVec2CCW - ( const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Add - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Subtract - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2) -D3DXVECTOR2* D3DXVec2Minimize - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2) -D3DXVECTOR2* D3DXVec2Maximize - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Scale - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV, float s ); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR2* D3DXVec2Lerp - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2, - float s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -D3DXVECTOR2* WINAPI D3DXVec2Normalize - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR2* WINAPI D3DXVec2Hermite - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pT1, - const D3DXVECTOR2 *pV2, const D3DXVECTOR2 *pT2, float s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR2* WINAPI D3DXVec2BaryCentric - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2, - D3DXVECTOR2 *pV3, float f, float g); - -// Transform (x, y, 0, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec2Transform - ( D3DXVECTOR4 *pOut, const D3DXVECTOR2 *pV, const D3DXMATRIX *pM ); - -// Transform (x, y, 0, 1) by matrix, project result back into w=1. -D3DXVECTOR2* WINAPI D3DXVec2TransformCoord - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV, const D3DXMATRIX *pM ); - -// Transform (x, y, 0, 0) by matrix. -D3DXVECTOR2* WINAPI D3DXVec2TransformNormal - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV, const D3DXMATRIX *pM ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// 3D Vector -//-------------------------- - -// inline - -float D3DXVec3Length - ( const D3DXVECTOR3 *pV ); - -float D3DXVec3LengthSq - ( const D3DXVECTOR3 *pV ); - -float D3DXVec3Dot - ( const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Cross - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Add - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Subtract - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... -D3DXVECTOR3* D3DXVec3Minimize - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... -D3DXVECTOR3* D3DXVec3Maximize - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Scale - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, float s); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR3* D3DXVec3Lerp - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2, - float s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -D3DXVECTOR3* WINAPI D3DXVec3Normalize - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR3* WINAPI D3DXVec3Hermite - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pT1, - const D3DXVECTOR3 *pV2, const D3DXVECTOR3 *pT2, float s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR3* WINAPI D3DXVec3BaryCentric - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2, - const D3DXVECTOR3 *pV3, float f, float g); - -// Transform (x, y, z, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec3Transform - ( D3DXVECTOR4 *pOut, const D3DXVECTOR3 *pV, const D3DXMATRIX *pM ); - -// Transform (x, y, z, 1) by matrix, project result back into w=1. -D3DXVECTOR3* WINAPI D3DXVec3TransformCoord - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, const D3DXMATRIX *pM ); - -// Transform (x, y, z, 0) by matrix. -D3DXVECTOR3* WINAPI D3DXVec3TransformNormal - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, const D3DXMATRIX *pM ); - -#ifdef __cplusplus -} -#endif - - - -//-------------------------- -// 4D Vector -//-------------------------- - -// inline - -float D3DXVec4Length - ( const D3DXVECTOR4 *pV ); - -float D3DXVec4LengthSq - ( const D3DXVECTOR4 *pV ); - -float D3DXVec4Dot - ( const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2 ); - -D3DXVECTOR4* D3DXVec4Add - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2); - -D3DXVECTOR4* D3DXVec4Subtract - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... -D3DXVECTOR4* D3DXVec4Minimize - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... -D3DXVECTOR4* D3DXVec4Maximize - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2); - -D3DXVECTOR4* D3DXVec4Scale - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV, float s); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR4* D3DXVec4Lerp - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2, - float s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Cross-product in 4 dimensions. -D3DXVECTOR4* WINAPI D3DXVec4Cross - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2, - const D3DXVECTOR4 *pV3); - -D3DXVECTOR4* WINAPI D3DXVec4Normalize - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR4* WINAPI D3DXVec4Hermite - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pT1, - const D3DXVECTOR4 *pV2, const D3DXVECTOR4 *pT2, float s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR4* WINAPI D3DXVec4BaryCentric - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2, - const D3DXVECTOR4 *pV3, float f, float g); - -// Transform vector by matrix. -D3DXVECTOR4* WINAPI D3DXVec4Transform - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV, const D3DXMATRIX *pM ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// 4D Matrix -//-------------------------- - -// inline - -D3DXMATRIX* D3DXMatrixIdentity - ( D3DXMATRIX *pOut ); - -BOOL D3DXMatrixIsIdentity - ( const D3DXMATRIX *pM ); - - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -float WINAPI D3DXMatrixfDeterminant - ( const D3DXMATRIX *pM ); - -// Matrix multiplication. The result represents the transformation M2 -// followed by the transformation M1. (Out = M1 * M2) -D3DXMATRIX* WINAPI D3DXMatrixMultiply - ( D3DXMATRIX *pOut, const D3DXMATRIX *pM1, const D3DXMATRIX *pM2 ); - -D3DXMATRIX* WINAPI D3DXMatrixTranspose - ( D3DXMATRIX *pOut, const D3DXMATRIX *pM ); - -// Calculate inverse of matrix. Inversion my fail, in which case NULL will -// be returned. The determinant of pM is also returned it pfDeterminant -// is non-NULL. -D3DXMATRIX* WINAPI D3DXMatrixInverse - ( D3DXMATRIX *pOut, float *pfDeterminant, const D3DXMATRIX *pM ); - -// Build a matrix which scales by (sx, sy, sz) -D3DXMATRIX* WINAPI D3DXMatrixScaling - ( D3DXMATRIX *pOut, float sx, float sy, float sz ); - -// Build a matrix which translates by (x, y, z) -D3DXMATRIX* WINAPI D3DXMatrixTranslation - ( D3DXMATRIX *pOut, float x, float y, float z ); - -// Build a matrix which rotates around the X axis -D3DXMATRIX* WINAPI D3DXMatrixRotationX - ( D3DXMATRIX *pOut, float angle ); - -// Build a matrix which rotates around the Y axis -D3DXMATRIX* WINAPI D3DXMatrixRotationY - ( D3DXMATRIX *pOut, float angle ); - -// Build a matrix which rotates around the Z axis -D3DXMATRIX* WINAPI D3DXMatrixRotationZ - ( D3DXMATRIX *pOut, float angle ); - -// Build a matrix which rotates around an arbitrary axis -D3DXMATRIX* WINAPI D3DXMatrixRotationAxis - ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pV, float angle ); - -// Build a matrix from a quaternion -D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion - ( D3DXMATRIX *pOut, const D3DXQUATERNION *pQ); - -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. -D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll - ( D3DXMATRIX *pOut, float yaw, float pitch, float roll ); - - -// Build transformation matrix. NULL arguments are treated as identity. -// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixTransformation - ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pScalingCenter, - const D3DXQUATERNION *pScalingRotation, const D3DXVECTOR3 *pScaling, - const D3DXVECTOR3 *pRotationCenter, const D3DXQUATERNION *pRotation, - const D3DXVECTOR3 *pTranslation); - -// Build affine transformation matrix. NULL arguments are treated as identity. -// Mout = Ms * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation - ( D3DXMATRIX *pOut, float Scaling, const D3DXVECTOR3 *pRotationCenter, - const D3DXQUATERNION *pRotation, const D3DXVECTOR3 *pTranslation); - -// Build a lookat matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixLookAt - ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pEye, const D3DXVECTOR3 *pAt, - const D3DXVECTOR3 *pUp ); - -// Build a lookat matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixLookAtLH - ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pEye, const D3DXVECTOR3 *pAt, - const D3DXVECTOR3 *pUp ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspective - ( D3DXMATRIX *pOut, float w, float h, float zn, float zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH - ( D3DXMATRIX *pOut, float w, float h, float zn, float zf ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFov - ( D3DXMATRIX *pOut, float fovy, float aspect, float zn, float zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH - ( D3DXMATRIX *pOut, float fovy, float aspect, float zn, float zf ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenter - ( D3DXMATRIX *pOut, float l, float r, float b, float t, float zn, - float zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH - ( D3DXMATRIX *pOut, float l, float r, float b, float t, float zn, - float zf ); - -// Build an ortho projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrtho - ( D3DXMATRIX *pOut, float w, float h, float zn, float zf ); - -// Build an ortho projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoLH - ( D3DXMATRIX *pOut, float w, float h, float zn, float zf ); - -// Build an ortho projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenter - ( D3DXMATRIX *pOut, float l, float r, float b, float t, float zn, - float zf ); - -// Build an ortho projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH - ( D3DXMATRIX *pOut, float l, float r, float b, float t, float zn, - float zf ); - -// Build a matrix which flattens geometry into a plane, as if casting -// a shadow from a light. -D3DXMATRIX* WINAPI D3DXMatrixShadow - ( D3DXMATRIX *pOut, const D3DXVECTOR4 *pLight, - const D3DXPLANE *pPlane ); - -// Build a matrix which reflects the coordinate system about a plane -D3DXMATRIX* WINAPI D3DXMatrixReflect - ( D3DXMATRIX *pOut, const D3DXPLANE *pPlane ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Quaternion -//-------------------------- - -// inline - -float D3DXQuaternionLength - ( const D3DXQUATERNION *pQ ); - -// Length squared, or "norm" -float D3DXQuaternionLengthSq - ( const D3DXQUATERNION *pQ ); - -float D3DXQuaternionDot - ( const D3DXQUATERNION *pQ1, const D3DXQUATERNION *pQ2 ); - -// (0, 0, 0, 1) -D3DXQUATERNION* D3DXQuaternionIdentity - ( D3DXQUATERNION *pOut ); - -BOOL D3DXQuaternionIsIdentity - ( const D3DXQUATERNION *pQ ); - -// (-x, -y, -z, w) -D3DXQUATERNION* D3DXQuaternionConjugate - ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ ); - - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. -void WINAPI D3DXQuaternionToAxisAngle - ( const D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, float *pAngle ); - -// Build a quaternion from a rotation matrix. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix - ( D3DXQUATERNION *pOut, const D3DXMATRIX *pM); - -// Rotation about arbitrary axis. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis - ( D3DXQUATERNION *pOut, const D3DXVECTOR3 *pV, float angle ); - -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll - ( D3DXQUATERNION *pOut, float yaw, float pitch, float roll ); - -// Quaternion multiplication. The result represents the rotation Q2 -// followed by the rotation Q1. (Out = Q2 * Q1) -D3DXQUATERNION* WINAPI D3DXQuaternionMultiply - ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1, - const D3DXQUATERNION *pQ2 ); - -D3DXQUATERNION* WINAPI D3DXQuaternionNormalize - ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ ); - -// Conjugate and re-norm -D3DXQUATERNION* WINAPI D3DXQuaternionInverse - ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ ); - -// Expects unit quaternions. -// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) -D3DXQUATERNION* WINAPI D3DXQuaternionLn - ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ ); - -// Expects pure quaternions. (w == 0) w is ignored in calculation. -// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) -D3DXQUATERNION* WINAPI D3DXQuaternionExp - ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ ); - -// Spherical linear interpolation between Q1 (s == 0) and Q2 (s == 1). -// Expects unit quaternions. -D3DXQUATERNION* WINAPI D3DXQuaternionSlerp - ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1, - const D3DXQUATERNION *pQ2, float t ); - -// Spherical quadrangle interpolation. -// Slerp(Slerp(Q1, Q4, t), Slerp(Q2, Q3, t), 2t(1-t)) -D3DXQUATERNION* WINAPI D3DXQuaternionSquad - ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1, - const D3DXQUATERNION *pQ2, const D3DXQUATERNION *pQ3, - const D3DXQUATERNION *pQ4, float t ); - -// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) -D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric - ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1, - const D3DXQUATERNION *pQ2, const D3DXQUATERNION *pQ3, - float f, float g ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Plane -//-------------------------- - -// inline - -// ax + by + cz + dw -float D3DXPlaneDot - ( const D3DXPLANE *pP, const D3DXVECTOR4 *pV); - -// ax + by + cz + d -float D3DXPlaneDotCoord - ( const D3DXPLANE *pP, const D3DXVECTOR3 *pV); - -// ax + by + cz -float D3DXPlaneDotNormal - ( const D3DXPLANE *pP, const D3DXVECTOR3 *pV); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Normalize plane (so that |a,b,c| == 1) -D3DXPLANE* WINAPI D3DXPlaneNormalize - ( D3DXPLANE *pOut, const D3DXPLANE *pP); - -// Find the intersection between a plane and a line. If the line is -// parallel to the plane, NULL is returned. -D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine - ( D3DXVECTOR3 *pOut, const D3DXPLANE *pP, const D3DXVECTOR3 *pV1, - const D3DXVECTOR3 *pV2); - -// Construct a plane from a point and a normal -D3DXPLANE* WINAPI D3DXPlaneFromPointNormal - ( D3DXPLANE *pOut, const D3DXVECTOR3 *pPoint, const D3DXVECTOR3 *pNormal); - -// Construct a plane from 3 points -D3DXPLANE* WINAPI D3DXPlaneFromPoints - ( D3DXPLANE *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2, - const D3DXVECTOR3 *pV3); - -// Transform a plane by a matrix. The vector (a,b,c) must be normal. -// M must be an affine transform. -D3DXPLANE* WINAPI D3DXPlaneTransform - ( D3DXPLANE *pOut, const D3DXPLANE *pP, const D3DXMATRIX *pM ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Color -//-------------------------- - -// inline - -// (1-r, 1-g, 1-b, a) -D3DXCOLOR* D3DXColorNegative - (D3DXCOLOR *pOut, const D3DXCOLOR *pC); - -D3DXCOLOR* D3DXColorAdd - (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2); - -D3DXCOLOR* D3DXColorSubtract - (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2); - -D3DXCOLOR* D3DXColorScale - (D3DXCOLOR *pOut, const D3DXCOLOR *pC, float s); - -// (r1*r2, g1*g2, b1*b2, a1*a2) -D3DXCOLOR* D3DXColorModulate - (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2); - -// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) -D3DXCOLOR* D3DXColorLerp - (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2, float s); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Interpolate r,g,b between desaturated color and color. -// DesaturatedColor + s(Color - DesaturatedColor) -D3DXCOLOR* WINAPI D3DXColorAdjustSaturation - (D3DXCOLOR *pOut, const D3DXCOLOR *pC, float s); - -// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) -D3DXCOLOR* WINAPI D3DXColorAdjustContrast - (D3DXCOLOR *pOut, const D3DXCOLOR *pC, float c); - -#ifdef __cplusplus -} -#endif - - - - - - -//=========================================================================== -// -// Matrix Stack -// -//=========================================================================== - -DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) -{ - // - // IUnknown methods - // - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - // - // ID3DXMatrixStack methods - // - - // Pops the top of the stack, returns the current top - // *after* popping the top. - STDMETHOD(Pop)(THIS) PURE; - - // Pushes the stack by one, duplicating the current matrix. - STDMETHOD(Push)(THIS) PURE; - - // Loads identity in the current matrix. - STDMETHOD(LoadIdentity)(THIS) PURE; - - // Loads the given matrix into the current matrix - STDMETHOD(LoadMatrix)(THIS_ const D3DXMATRIX* pM ) PURE; - - // Right-Multiplies the given matrix to the current matrix. - // (transformation is about the current world origin) - STDMETHOD(MultMatrix)(THIS_ const D3DXMATRIX* pM ) PURE; - - // Left-Multiplies the given matrix to the current matrix - // (transformation is about the local origin of the object) - STDMETHOD(MultMatrixLocal)(THIS_ const D3DXMATRIX* pM ) PURE; - - // Right multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the current world origin) - STDMETHOD(RotateAxis) - (THIS_ const D3DXVECTOR3* pV, float angle) PURE; - - // 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) - STDMETHOD(RotateAxisLocal) - (THIS_ const D3DXVECTOR3* pV, float angle) PURE; - - // Right multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // current world origin) - - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. - STDMETHOD(RotateYawPitchRoll) - (THIS_ float yaw, float pitch, float roll) PURE; - - // Left multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // local origin of the object) - - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. - STDMETHOD(RotateYawPitchRollLocal) - (THIS_ float yaw, float pitch, float roll) PURE; - - // Right multiply the current matrix with the computed scale - // matrix. (transformation is about the current world origin) - STDMETHOD(Scale)(THIS_ float x, float y, float z) PURE; - - // Left multiply the current matrix with the computed scale - // matrix. (transformation is about the local origin of the object) - STDMETHOD(ScaleLocal)(THIS_ float x, float y, float z) PURE; - - // Right multiply the current matrix with the computed translation - // matrix. (transformation is about the current world origin) - STDMETHOD(Translate)(THIS_ float x, float y, float z ) PURE; - - // Left multiply the current matrix with the computed translation - // matrix. (transformation is about the local origin of the object) - STDMETHOD(TranslateLocal)(THIS_ float x, float y, float z) PURE; - - // Obtain the current matrix at the top of the stack - STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; -}; - -#ifdef __cplusplus -extern "C" { -#endif - -HRESULT WINAPI D3DXCreateMatrixStack( DWORD flags, LPD3DXMATRIXSTACK *ppStack ); - -#ifdef __cplusplus -} -#endif - -#include "d3dxmath.inl" - -#pragma warning(default:4201) - -#endif // __D3DXMATH_H__ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dxmath.h +// Content: D3DX math types and functions +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DXMATH_H__ +#define __D3DXMATH_H__ + +#include +#include +#include +#include "d3dxerr.h" + +#ifndef D3DXINLINE +#ifdef __cplusplus +#define D3DXINLINE inline +#else +#define D3DXINLINE _inline +#endif +#endif + +#pragma warning(disable:4201) // anonymous unions warning + + + +typedef struct ID3DXMatrixStack *LPD3DXMATRIXSTACK; + +// {E3357330-CC5E-11d2-A434-00A0C90629A8} +DEFINE_GUID( IID_ID3DXMatrixStack, + 0xe3357330, 0xcc5e, 0x11d2, 0xa4, 0x34, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); + + +//=========================================================================== +// +// General purpose utilities +// +//=========================================================================== +#define D3DX_PI ((float) 3.141592654f) +#define D3DX_1BYPI ((float) 0.318309886f) + +#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) +#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) + + + +//=========================================================================== +// +// Vectors +// +//=========================================================================== + +//-------------------------- +// 2D Vector +//-------------------------- +typedef struct D3DXVECTOR2 +{ +#ifdef __cplusplus +public: + D3DXVECTOR2() {}; + D3DXVECTOR2( const float * ); + D3DXVECTOR2( float x, float y ); + + // casting + operator float* (); + operator const float* () const; + + // assignment operators + D3DXVECTOR2& operator += ( const D3DXVECTOR2& ); + D3DXVECTOR2& operator -= ( const D3DXVECTOR2& ); + D3DXVECTOR2& operator *= ( float ); + D3DXVECTOR2& operator /= ( float ); + + // unary operators + D3DXVECTOR2 operator + () const; + D3DXVECTOR2 operator - () const; + + // binary operators + D3DXVECTOR2 operator + ( const D3DXVECTOR2& ) const; + D3DXVECTOR2 operator - ( const D3DXVECTOR2& ) const; + D3DXVECTOR2 operator * ( float ) const; + D3DXVECTOR2 operator / ( float ) const; + + friend D3DXVECTOR2 operator * ( float, const D3DXVECTOR2& ); + + BOOL operator == ( const D3DXVECTOR2& ) const; + BOOL operator != ( const D3DXVECTOR2& ) const; + + +public: +#endif //__cplusplus + float x, y; +} D3DXVECTOR2, *LPD3DXVECTOR2; + + +//-------------------------- +// 3D Vector +//-------------------------- +typedef struct D3DXVECTOR3 +{ +#ifdef __cplusplus +public: + D3DXVECTOR3() {}; + D3DXVECTOR3( const float * ); + D3DXVECTOR3( const D3DVECTOR& ); + D3DXVECTOR3( float x, float y, float z ); + + // casting + operator float* (); + operator const float* () const; + + operator D3DVECTOR* (); + operator const D3DVECTOR* () const; + + operator D3DVECTOR& (); + operator const D3DVECTOR& () const; + + // assignment operators + D3DXVECTOR3& operator += ( const D3DXVECTOR3& ); + D3DXVECTOR3& operator -= ( const D3DXVECTOR3& ); + D3DXVECTOR3& operator *= ( float ); + D3DXVECTOR3& operator /= ( float ); + + // unary operators + D3DXVECTOR3 operator + () const; + D3DXVECTOR3 operator - () const; + + // binary operators + D3DXVECTOR3 operator + ( const D3DXVECTOR3& ) const; + D3DXVECTOR3 operator - ( const D3DXVECTOR3& ) const; + D3DXVECTOR3 operator * ( float ) const; + D3DXVECTOR3 operator / ( float ) const; + + friend D3DXVECTOR3 operator * ( float, const struct D3DXVECTOR3& ); + + BOOL operator == ( const D3DXVECTOR3& ) const; + BOOL operator != ( const D3DXVECTOR3& ) const; + +public: +#endif //__cplusplus + float x, y, z; +} D3DXVECTOR3, *LPD3DXVECTOR3; + + +//-------------------------- +// 4D Vector +//-------------------------- +typedef struct D3DXVECTOR4 +{ +#ifdef __cplusplus +public: + D3DXVECTOR4() {}; + D3DXVECTOR4( const float* ); + D3DXVECTOR4( float x, float y, float z, float w ); + + // casting + operator float* (); + operator const float* () const; + + // assignment operators + D3DXVECTOR4& operator += ( const D3DXVECTOR4& ); + D3DXVECTOR4& operator -= ( const D3DXVECTOR4& ); + D3DXVECTOR4& operator *= ( float ); + D3DXVECTOR4& operator /= ( float ); + + // unary operators + D3DXVECTOR4 operator + () const; + D3DXVECTOR4 operator - () const; + + // binary operators + D3DXVECTOR4 operator + ( const D3DXVECTOR4& ) const; + D3DXVECTOR4 operator - ( const D3DXVECTOR4& ) const; + D3DXVECTOR4 operator * ( float ) const; + D3DXVECTOR4 operator / ( float ) const; + + friend D3DXVECTOR4 operator * ( float, const D3DXVECTOR4& ); + + BOOL operator == ( const D3DXVECTOR4& ) const; + BOOL operator != ( const D3DXVECTOR4& ) const; + +public: +#endif //__cplusplus + float x, y, z, w; +} D3DXVECTOR4, *LPD3DXVECTOR4; + + +//=========================================================================== +// +// Matrices +// +//=========================================================================== +typedef struct D3DXMATRIX +{ +#ifdef __cplusplus +public: + D3DXMATRIX() {}; + D3DXMATRIX( const float * ); + D3DXMATRIX( const D3DMATRIX& ); + D3DXMATRIX( float m00, float m01, float m02, float m03, + float m10, float m11, float m12, float m13, + float m20, float m21, float m22, float m23, + float m30, float m31, float m32, float m33 ); + + + // access grants + float& operator () ( UINT iRow, UINT iCol ); + float operator () ( UINT iRow, UINT iCol ) const; + + // casting operators + operator float* (); + operator const float* () const; + + operator D3DMATRIX* (); + operator const D3DMATRIX* () const; + + operator D3DMATRIX& (); + operator const D3DMATRIX& () const; + + // assignment operators + D3DXMATRIX& operator *= ( const D3DXMATRIX& ); + D3DXMATRIX& operator += ( const D3DXMATRIX& ); + D3DXMATRIX& operator -= ( const D3DXMATRIX& ); + D3DXMATRIX& operator *= ( float ); + D3DXMATRIX& operator /= ( float ); + + // unary operators + D3DXMATRIX operator + () const; + D3DXMATRIX operator - () const; + + // binary operators + D3DXMATRIX operator * ( const D3DXMATRIX& ) const; + D3DXMATRIX operator + ( const D3DXMATRIX& ) const; + D3DXMATRIX operator - ( const D3DXMATRIX& ) const; + D3DXMATRIX operator * ( float ) const; + D3DXMATRIX operator / ( float ) const; + + friend D3DXMATRIX operator * ( float, const D3DXMATRIX& ); + + BOOL operator == ( const D3DXMATRIX& ) const; + BOOL operator != ( const D3DXMATRIX& ) const; + + +#endif //__cplusplus + + union + { + float m[4][4]; +#ifdef __cplusplus + struct + { + float m00, m01, m02, m03; + float m10, m11, m12, m13; + float m20, m21, m22, m23; + float m30, m31, m32, m33; + }; +#endif //__cplusplus + }; +} D3DXMATRIX, *LPD3DXMATRIX; + + +//=========================================================================== +// +// Quaternions +// +//=========================================================================== +typedef struct D3DXQUATERNION +{ +#ifdef __cplusplus +public: + D3DXQUATERNION() {} + D3DXQUATERNION( const float * ); + D3DXQUATERNION( float x, float y, float z, float w ); + + // casting + operator float* (); + operator const float* () const; + + // assignment operators + D3DXQUATERNION& operator += ( const D3DXQUATERNION& ); + D3DXQUATERNION& operator -= ( const D3DXQUATERNION& ); + D3DXQUATERNION& operator *= ( const D3DXQUATERNION& ); + D3DXQUATERNION& operator *= ( float ); + D3DXQUATERNION& operator /= ( float ); + + // unary operators + D3DXQUATERNION operator + () const; + D3DXQUATERNION operator - () const; + + // binary operators + D3DXQUATERNION operator + ( const D3DXQUATERNION& ) const; + D3DXQUATERNION operator - ( const D3DXQUATERNION& ) const; + D3DXQUATERNION operator * ( const D3DXQUATERNION& ) const; + D3DXQUATERNION operator * ( float ) const; + D3DXQUATERNION operator / ( float ) const; + + friend D3DXQUATERNION operator * (float, const D3DXQUATERNION& ); + + BOOL operator == ( const D3DXQUATERNION& ) const; + BOOL operator != ( const D3DXQUATERNION& ) const; + +#endif //__cplusplus + float x, y, z, w; +} D3DXQUATERNION, *LPD3DXQUATERNION; + + +//=========================================================================== +// +// Planes +// +//=========================================================================== +typedef struct D3DXPLANE +{ +#ifdef __cplusplus +public: + D3DXPLANE() {} + D3DXPLANE( const float* ); + D3DXPLANE( float a, float b, float c, float d ); + + // casting + operator float* (); + operator const float* () const; + + // unary operators + D3DXPLANE operator + () const; + D3DXPLANE operator - () const; + + // binary operators + BOOL operator == ( const D3DXPLANE& ) const; + BOOL operator != ( const D3DXPLANE& ) const; + +#endif //__cplusplus + float a, b, c, d; +} D3DXPLANE, *LPD3DXPLANE; + + +//=========================================================================== +// +// Colors +// +//=========================================================================== + +typedef struct D3DXCOLOR +{ +#ifdef __cplusplus +public: + D3DXCOLOR() {} + D3DXCOLOR( DWORD argb ); + D3DXCOLOR( const float * ); + D3DXCOLOR( const D3DCOLORVALUE& ); + D3DXCOLOR( float r, float g, float b, float a ); + + // casting + operator DWORD () const; + + operator float* (); + operator const float* () const; + + operator D3DCOLORVALUE* (); + operator const D3DCOLORVALUE* () const; + + operator D3DCOLORVALUE& (); + operator const D3DCOLORVALUE& () const; + + // assignment operators + D3DXCOLOR& operator += ( const D3DXCOLOR& ); + D3DXCOLOR& operator -= ( const D3DXCOLOR& ); + D3DXCOLOR& operator *= ( float ); + D3DXCOLOR& operator /= ( float ); + + // unary operators + D3DXCOLOR operator + () const; + D3DXCOLOR operator - () const; + + // binary operators + D3DXCOLOR operator + ( const D3DXCOLOR& ) const; + D3DXCOLOR operator - ( const D3DXCOLOR& ) const; + D3DXCOLOR operator * ( float ) const; + D3DXCOLOR operator / ( float ) const; + + friend D3DXCOLOR operator * (float, const D3DXCOLOR& ); + + BOOL operator == ( const D3DXCOLOR& ) const; + BOOL operator != ( const D3DXCOLOR& ) const; + +#endif //__cplusplus + FLOAT r, g, b, a; +} D3DXCOLOR, *LPD3DXCOLOR; + + + +//=========================================================================== +// +// D3DX math functions: +// +// NOTE: +// * All these functions can take the same object as in and out parameters. +// +// * Out parameters are typically also returned as return values, so that +// the output of one function may be used as a parameter to another. +// +//=========================================================================== + +//-------------------------- +// 2D Vector +//-------------------------- + +// inline + +float D3DXVec2Length + ( const D3DXVECTOR2 *pV ); + +float D3DXVec2LengthSq + ( const D3DXVECTOR2 *pV ); + +float D3DXVec2Dot + ( const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ); + +// Z component of ((x1,y1,0) cross (x2,y2,0)) +float D3DXVec2CCW + ( const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Add + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Subtract + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2) +D3DXVECTOR2* D3DXVec2Minimize + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2) +D3DXVECTOR2* D3DXVec2Maximize + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Scale + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV, float s ); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR2* D3DXVec2Lerp + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2, + float s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +D3DXVECTOR2* WINAPI D3DXVec2Normalize + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR2* WINAPI D3DXVec2Hermite + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pT1, + const D3DXVECTOR2 *pV2, const D3DXVECTOR2 *pT2, float s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR2* WINAPI D3DXVec2BaryCentric + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2, + D3DXVECTOR2 *pV3, float f, float g); + +// Transform (x, y, 0, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec2Transform + ( D3DXVECTOR4 *pOut, const D3DXVECTOR2 *pV, const D3DXMATRIX *pM ); + +// Transform (x, y, 0, 1) by matrix, project result back into w=1. +D3DXVECTOR2* WINAPI D3DXVec2TransformCoord + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV, const D3DXMATRIX *pM ); + +// Transform (x, y, 0, 0) by matrix. +D3DXVECTOR2* WINAPI D3DXVec2TransformNormal + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV, const D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 3D Vector +//-------------------------- + +// inline + +float D3DXVec3Length + ( const D3DXVECTOR3 *pV ); + +float D3DXVec3LengthSq + ( const D3DXVECTOR3 *pV ); + +float D3DXVec3Dot + ( const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Cross + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Add + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Subtract + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +D3DXVECTOR3* D3DXVec3Minimize + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +D3DXVECTOR3* D3DXVec3Maximize + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Scale + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, float s); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR3* D3DXVec3Lerp + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2, + float s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +D3DXVECTOR3* WINAPI D3DXVec3Normalize + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR3* WINAPI D3DXVec3Hermite + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pT1, + const D3DXVECTOR3 *pV2, const D3DXVECTOR3 *pT2, float s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR3* WINAPI D3DXVec3BaryCentric + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2, + const D3DXVECTOR3 *pV3, float f, float g); + +// Transform (x, y, z, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec3Transform + ( D3DXVECTOR4 *pOut, const D3DXVECTOR3 *pV, const D3DXMATRIX *pM ); + +// Transform (x, y, z, 1) by matrix, project result back into w=1. +D3DXVECTOR3* WINAPI D3DXVec3TransformCoord + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, const D3DXMATRIX *pM ); + +// Transform (x, y, z, 0) by matrix. +D3DXVECTOR3* WINAPI D3DXVec3TransformNormal + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, const D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + + +//-------------------------- +// 4D Vector +//-------------------------- + +// inline + +float D3DXVec4Length + ( const D3DXVECTOR4 *pV ); + +float D3DXVec4LengthSq + ( const D3DXVECTOR4 *pV ); + +float D3DXVec4Dot + ( const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2 ); + +D3DXVECTOR4* D3DXVec4Add + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2); + +D3DXVECTOR4* D3DXVec4Subtract + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +D3DXVECTOR4* D3DXVec4Minimize + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +D3DXVECTOR4* D3DXVec4Maximize + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2); + +D3DXVECTOR4* D3DXVec4Scale + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV, float s); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR4* D3DXVec4Lerp + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2, + float s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Cross-product in 4 dimensions. +D3DXVECTOR4* WINAPI D3DXVec4Cross + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2, + const D3DXVECTOR4 *pV3); + +D3DXVECTOR4* WINAPI D3DXVec4Normalize + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR4* WINAPI D3DXVec4Hermite + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pT1, + const D3DXVECTOR4 *pV2, const D3DXVECTOR4 *pT2, float s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR4* WINAPI D3DXVec4BaryCentric + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2, + const D3DXVECTOR4 *pV3, float f, float g); + +// Transform vector by matrix. +D3DXVECTOR4* WINAPI D3DXVec4Transform + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV, const D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 4D Matrix +//-------------------------- + +// inline + +D3DXMATRIX* D3DXMatrixIdentity + ( D3DXMATRIX *pOut ); + +BOOL D3DXMatrixIsIdentity + ( const D3DXMATRIX *pM ); + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +float WINAPI D3DXMatrixfDeterminant + ( const D3DXMATRIX *pM ); + +// Matrix multiplication. The result represents the transformation M2 +// followed by the transformation M1. (Out = M1 * M2) +D3DXMATRIX* WINAPI D3DXMatrixMultiply + ( D3DXMATRIX *pOut, const D3DXMATRIX *pM1, const D3DXMATRIX *pM2 ); + +D3DXMATRIX* WINAPI D3DXMatrixTranspose + ( D3DXMATRIX *pOut, const D3DXMATRIX *pM ); + +// Calculate inverse of matrix. Inversion my fail, in which case NULL will +// be returned. The determinant of pM is also returned it pfDeterminant +// is non-NULL. +D3DXMATRIX* WINAPI D3DXMatrixInverse + ( D3DXMATRIX *pOut, float *pfDeterminant, const D3DXMATRIX *pM ); + +// Build a matrix which scales by (sx, sy, sz) +D3DXMATRIX* WINAPI D3DXMatrixScaling + ( D3DXMATRIX *pOut, float sx, float sy, float sz ); + +// Build a matrix which translates by (x, y, z) +D3DXMATRIX* WINAPI D3DXMatrixTranslation + ( D3DXMATRIX *pOut, float x, float y, float z ); + +// Build a matrix which rotates around the X axis +D3DXMATRIX* WINAPI D3DXMatrixRotationX + ( D3DXMATRIX *pOut, float angle ); + +// Build a matrix which rotates around the Y axis +D3DXMATRIX* WINAPI D3DXMatrixRotationY + ( D3DXMATRIX *pOut, float angle ); + +// Build a matrix which rotates around the Z axis +D3DXMATRIX* WINAPI D3DXMatrixRotationZ + ( D3DXMATRIX *pOut, float angle ); + +// Build a matrix which rotates around an arbitrary axis +D3DXMATRIX* WINAPI D3DXMatrixRotationAxis + ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pV, float angle ); + +// Build a matrix from a quaternion +D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion + ( D3DXMATRIX *pOut, const D3DXQUATERNION *pQ); + +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. +D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll + ( D3DXMATRIX *pOut, float yaw, float pitch, float roll ); + + +// Build transformation matrix. NULL arguments are treated as identity. +// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixTransformation + ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pScalingCenter, + const D3DXQUATERNION *pScalingRotation, const D3DXVECTOR3 *pScaling, + const D3DXVECTOR3 *pRotationCenter, const D3DXQUATERNION *pRotation, + const D3DXVECTOR3 *pTranslation); + +// Build affine transformation matrix. NULL arguments are treated as identity. +// Mout = Ms * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation + ( D3DXMATRIX *pOut, float Scaling, const D3DXVECTOR3 *pRotationCenter, + const D3DXQUATERNION *pRotation, const D3DXVECTOR3 *pTranslation); + +// Build a lookat matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixLookAt + ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pEye, const D3DXVECTOR3 *pAt, + const D3DXVECTOR3 *pUp ); + +// Build a lookat matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixLookAtLH + ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pEye, const D3DXVECTOR3 *pAt, + const D3DXVECTOR3 *pUp ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspective + ( D3DXMATRIX *pOut, float w, float h, float zn, float zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH + ( D3DXMATRIX *pOut, float w, float h, float zn, float zf ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFov + ( D3DXMATRIX *pOut, float fovy, float aspect, float zn, float zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH + ( D3DXMATRIX *pOut, float fovy, float aspect, float zn, float zf ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenter + ( D3DXMATRIX *pOut, float l, float r, float b, float t, float zn, + float zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH + ( D3DXMATRIX *pOut, float l, float r, float b, float t, float zn, + float zf ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrtho + ( D3DXMATRIX *pOut, float w, float h, float zn, float zf ); + +// Build an ortho projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoLH + ( D3DXMATRIX *pOut, float w, float h, float zn, float zf ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenter + ( D3DXMATRIX *pOut, float l, float r, float b, float t, float zn, + float zf ); + +// Build an ortho projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH + ( D3DXMATRIX *pOut, float l, float r, float b, float t, float zn, + float zf ); + +// Build a matrix which flattens geometry into a plane, as if casting +// a shadow from a light. +D3DXMATRIX* WINAPI D3DXMatrixShadow + ( D3DXMATRIX *pOut, const D3DXVECTOR4 *pLight, + const D3DXPLANE *pPlane ); + +// Build a matrix which reflects the coordinate system about a plane +D3DXMATRIX* WINAPI D3DXMatrixReflect + ( D3DXMATRIX *pOut, const D3DXPLANE *pPlane ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Quaternion +//-------------------------- + +// inline + +float D3DXQuaternionLength + ( const D3DXQUATERNION *pQ ); + +// Length squared, or "norm" +float D3DXQuaternionLengthSq + ( const D3DXQUATERNION *pQ ); + +float D3DXQuaternionDot + ( const D3DXQUATERNION *pQ1, const D3DXQUATERNION *pQ2 ); + +// (0, 0, 0, 1) +D3DXQUATERNION* D3DXQuaternionIdentity + ( D3DXQUATERNION *pOut ); + +BOOL D3DXQuaternionIsIdentity + ( const D3DXQUATERNION *pQ ); + +// (-x, -y, -z, w) +D3DXQUATERNION* D3DXQuaternionConjugate + ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ ); + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. +void WINAPI D3DXQuaternionToAxisAngle + ( const D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, float *pAngle ); + +// Build a quaternion from a rotation matrix. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix + ( D3DXQUATERNION *pOut, const D3DXMATRIX *pM); + +// Rotation about arbitrary axis. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis + ( D3DXQUATERNION *pOut, const D3DXVECTOR3 *pV, float angle ); + +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll + ( D3DXQUATERNION *pOut, float yaw, float pitch, float roll ); + +// Quaternion multiplication. The result represents the rotation Q2 +// followed by the rotation Q1. (Out = Q2 * Q1) +D3DXQUATERNION* WINAPI D3DXQuaternionMultiply + ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1, + const D3DXQUATERNION *pQ2 ); + +D3DXQUATERNION* WINAPI D3DXQuaternionNormalize + ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ ); + +// Conjugate and re-norm +D3DXQUATERNION* WINAPI D3DXQuaternionInverse + ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ ); + +// Expects unit quaternions. +// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) +D3DXQUATERNION* WINAPI D3DXQuaternionLn + ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ ); + +// Expects pure quaternions. (w == 0) w is ignored in calculation. +// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) +D3DXQUATERNION* WINAPI D3DXQuaternionExp + ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ ); + +// Spherical linear interpolation between Q1 (s == 0) and Q2 (s == 1). +// Expects unit quaternions. +D3DXQUATERNION* WINAPI D3DXQuaternionSlerp + ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1, + const D3DXQUATERNION *pQ2, float t ); + +// Spherical quadrangle interpolation. +// Slerp(Slerp(Q1, Q4, t), Slerp(Q2, Q3, t), 2t(1-t)) +D3DXQUATERNION* WINAPI D3DXQuaternionSquad + ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1, + const D3DXQUATERNION *pQ2, const D3DXQUATERNION *pQ3, + const D3DXQUATERNION *pQ4, float t ); + +// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) +D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric + ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1, + const D3DXQUATERNION *pQ2, const D3DXQUATERNION *pQ3, + float f, float g ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Plane +//-------------------------- + +// inline + +// ax + by + cz + dw +float D3DXPlaneDot + ( const D3DXPLANE *pP, const D3DXVECTOR4 *pV); + +// ax + by + cz + d +float D3DXPlaneDotCoord + ( const D3DXPLANE *pP, const D3DXVECTOR3 *pV); + +// ax + by + cz +float D3DXPlaneDotNormal + ( const D3DXPLANE *pP, const D3DXVECTOR3 *pV); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Normalize plane (so that |a,b,c| == 1) +D3DXPLANE* WINAPI D3DXPlaneNormalize + ( D3DXPLANE *pOut, const D3DXPLANE *pP); + +// Find the intersection between a plane and a line. If the line is +// parallel to the plane, NULL is returned. +D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine + ( D3DXVECTOR3 *pOut, const D3DXPLANE *pP, const D3DXVECTOR3 *pV1, + const D3DXVECTOR3 *pV2); + +// Construct a plane from a point and a normal +D3DXPLANE* WINAPI D3DXPlaneFromPointNormal + ( D3DXPLANE *pOut, const D3DXVECTOR3 *pPoint, const D3DXVECTOR3 *pNormal); + +// Construct a plane from 3 points +D3DXPLANE* WINAPI D3DXPlaneFromPoints + ( D3DXPLANE *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2, + const D3DXVECTOR3 *pV3); + +// Transform a plane by a matrix. The vector (a,b,c) must be normal. +// M must be an affine transform. +D3DXPLANE* WINAPI D3DXPlaneTransform + ( D3DXPLANE *pOut, const D3DXPLANE *pP, const D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Color +//-------------------------- + +// inline + +// (1-r, 1-g, 1-b, a) +D3DXCOLOR* D3DXColorNegative + (D3DXCOLOR *pOut, const D3DXCOLOR *pC); + +D3DXCOLOR* D3DXColorAdd + (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2); + +D3DXCOLOR* D3DXColorSubtract + (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2); + +D3DXCOLOR* D3DXColorScale + (D3DXCOLOR *pOut, const D3DXCOLOR *pC, float s); + +// (r1*r2, g1*g2, b1*b2, a1*a2) +D3DXCOLOR* D3DXColorModulate + (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2); + +// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) +D3DXCOLOR* D3DXColorLerp + (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2, float s); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Interpolate r,g,b between desaturated color and color. +// DesaturatedColor + s(Color - DesaturatedColor) +D3DXCOLOR* WINAPI D3DXColorAdjustSaturation + (D3DXCOLOR *pOut, const D3DXCOLOR *pC, float s); + +// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) +D3DXCOLOR* WINAPI D3DXColorAdjustContrast + (D3DXCOLOR *pOut, const D3DXCOLOR *pC, float c); + +#ifdef __cplusplus +} +#endif + + + + + + +//=========================================================================== +// +// Matrix Stack +// +//=========================================================================== + +DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) +{ + // + // IUnknown methods + // + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // + // ID3DXMatrixStack methods + // + + // Pops the top of the stack, returns the current top + // *after* popping the top. + STDMETHOD(Pop)(THIS) PURE; + + // Pushes the stack by one, duplicating the current matrix. + STDMETHOD(Push)(THIS) PURE; + + // Loads identity in the current matrix. + STDMETHOD(LoadIdentity)(THIS) PURE; + + // Loads the given matrix into the current matrix + STDMETHOD(LoadMatrix)(THIS_ const D3DXMATRIX* pM ) PURE; + + // Right-Multiplies the given matrix to the current matrix. + // (transformation is about the current world origin) + STDMETHOD(MultMatrix)(THIS_ const D3DXMATRIX* pM ) PURE; + + // Left-Multiplies the given matrix to the current matrix + // (transformation is about the local origin of the object) + STDMETHOD(MultMatrixLocal)(THIS_ const D3DXMATRIX* pM ) PURE; + + // Right multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the current world origin) + STDMETHOD(RotateAxis) + (THIS_ const D3DXVECTOR3* pV, float angle) PURE; + + // 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) + STDMETHOD(RotateAxisLocal) + (THIS_ const D3DXVECTOR3* pV, float angle) PURE; + + // Right multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // current world origin) + + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. + STDMETHOD(RotateYawPitchRoll) + (THIS_ float yaw, float pitch, float roll) PURE; + + // Left multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // local origin of the object) + + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. + STDMETHOD(RotateYawPitchRollLocal) + (THIS_ float yaw, float pitch, float roll) PURE; + + // Right multiply the current matrix with the computed scale + // matrix. (transformation is about the current world origin) + STDMETHOD(Scale)(THIS_ float x, float y, float z) PURE; + + // Left multiply the current matrix with the computed scale + // matrix. (transformation is about the local origin of the object) + STDMETHOD(ScaleLocal)(THIS_ float x, float y, float z) PURE; + + // Right multiply the current matrix with the computed translation + // matrix. (transformation is about the current world origin) + STDMETHOD(Translate)(THIS_ float x, float y, float z ) PURE; + + // Left multiply the current matrix with the computed translation + // matrix. (transformation is about the local origin of the object) + STDMETHOD(TranslateLocal)(THIS_ float x, float y, float z) PURE; + + // Obtain the current matrix at the top of the stack + STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +HRESULT WINAPI D3DXCreateMatrixStack( DWORD flags, LPD3DXMATRIXSTACK *ppStack ); + +#ifdef __cplusplus +} +#endif + +#include "d3dxmath.inl" + +#pragma warning(default:4201) + +#endif // __D3DXMATH_H__ diff --git a/src/dep/include/DXSDK/include/d3dxmath.inl b/src/dep/include/DXSDK/include/d3dxmath.inl index 32b3b5f..05f0431 100644 --- a/src/dep/include/DXSDK/include/d3dxmath.inl +++ b/src/dep/include/DXSDK/include/d3dxmath.inl @@ -1,1809 +1,1809 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dxmath.inl -// Content: D3DX math inline functions -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DXMATH_INL__ -#define __D3DXMATH_INL__ - - -//=========================================================================== -// -// Inline Class Methods -// -//=========================================================================== - -#ifdef __cplusplus - -//-------------------------- -// 2D Vector -//-------------------------- - -D3DXINLINE -D3DXVECTOR2::D3DXVECTOR2( const float *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; -} - -D3DXINLINE -D3DXVECTOR2::D3DXVECTOR2( float fx, float fy ) -{ - x = fx; - y = fy; -} - -// casting -D3DXINLINE -D3DXVECTOR2::operator float* () -{ - return (float *) &x; -} - -D3DXINLINE -D3DXVECTOR2::operator const float* () const -{ - return (const float *) &x; -} - -// assignment operators -D3DXINLINE D3DXVECTOR2& -D3DXVECTOR2::operator += ( const D3DXVECTOR2& v ) -{ - x += v.x; - y += v.y; - return *this; -} - -D3DXINLINE D3DXVECTOR2& -D3DXVECTOR2::operator -= ( const D3DXVECTOR2& v ) -{ - x -= v.x; - y -= v.y; - return *this; -} - -D3DXINLINE D3DXVECTOR2& -D3DXVECTOR2::operator *= ( float f ) -{ - x *= f; - y *= f; - return *this; -} - -D3DXINLINE D3DXVECTOR2& -D3DXVECTOR2::operator /= ( float f ) -{ - float fInv = 1.0f / f; - x *= fInv; - y *= fInv; - return *this; -} - -// unary operators -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator - () const -{ - return D3DXVECTOR2(-x, -y); -} - -// binary operators -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator + ( const D3DXVECTOR2& v ) const -{ - return D3DXVECTOR2(x + v.x, y + v.y); -} - -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator - ( const D3DXVECTOR2& v ) const -{ - return D3DXVECTOR2(x - v.x, y - v.y); -} - -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator * ( float f ) const -{ - return D3DXVECTOR2(x * f, y * f); -} - -D3DXINLINE D3DXVECTOR2 -D3DXVECTOR2::operator / ( float f ) const -{ - float fInv = 1.0f / f; - return D3DXVECTOR2(x * fInv, y * fInv); -} - - -D3DXINLINE D3DXVECTOR2 -operator * ( float f, const D3DXVECTOR2& v ) -{ - return D3DXVECTOR2(f * v.x, f * v.y); -} - -D3DXINLINE BOOL -D3DXVECTOR2::operator == ( const D3DXVECTOR2& v ) const -{ - return x == v.x && y == v.y; -} - -D3DXINLINE BOOL -D3DXVECTOR2::operator != ( const D3DXVECTOR2& v ) const -{ - return x != v.x || y != v.y; -} - - - - -//-------------------------- -// 3D Vector -//-------------------------- -D3DXINLINE -D3DXVECTOR3::D3DXVECTOR3( const float *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; - z = pf[2]; -} - -D3DXINLINE -D3DXVECTOR3::D3DXVECTOR3( const D3DVECTOR& v ) -{ - x = v.x; - y = v.y; - z = v.z; -} - -D3DXINLINE -D3DXVECTOR3::D3DXVECTOR3( float fx, float fy, float fz ) -{ - x = fx; - y = fy; - z = fz; -} - - -// casting -D3DXINLINE -D3DXVECTOR3::operator float* () -{ - return (float *) &x; -} - -D3DXINLINE -D3DXVECTOR3::operator const float* () const -{ - return (const float *) &x; -} - - -D3DXINLINE -D3DXVECTOR3::operator D3DVECTOR* () -{ - return (D3DVECTOR *) &x; -} - -D3DXINLINE -D3DXVECTOR3::operator const D3DVECTOR* () const -{ - return (const D3DVECTOR *) &x; -} - - -D3DXINLINE -D3DXVECTOR3::operator D3DVECTOR& () -{ - return *((D3DVECTOR *) &x); -} - -D3DXINLINE -D3DXVECTOR3::operator const D3DVECTOR& () const -{ - return *((const D3DVECTOR *) &x); -} - - -// assignment operators -D3DXINLINE D3DXVECTOR3& -D3DXVECTOR3::operator += ( const D3DXVECTOR3& v ) -{ - x += v.x; - y += v.y; - z += v.z; - return *this; -} - -D3DXINLINE D3DXVECTOR3& -D3DXVECTOR3::operator -= ( const D3DXVECTOR3& v ) -{ - x -= v.x; - y -= v.y; - z -= v.z; - return *this; -} - -D3DXINLINE D3DXVECTOR3& -D3DXVECTOR3::operator *= ( float f ) -{ - x *= f; - y *= f; - z *= f; - return *this; -} - -D3DXINLINE D3DXVECTOR3& -D3DXVECTOR3::operator /= ( float f ) -{ - float fInv = 1.0f / f; - x *= fInv; - y *= fInv; - z *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator - () const -{ - return D3DXVECTOR3(-x, -y, -z); -} - - -// binary operators -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator + ( const D3DXVECTOR3& v ) const -{ - return D3DXVECTOR3(x + v.x, y + v.y, z + v.z); -} - -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator - ( const D3DXVECTOR3& v ) const -{ - return D3DXVECTOR3(x - v.x, y - v.y, z - v.z); -} - -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator * ( float f ) const -{ - return D3DXVECTOR3(x * f, y * f, z * f); -} - -D3DXINLINE D3DXVECTOR3 -D3DXVECTOR3::operator / ( float f ) const -{ - float fInv = 1.0f / f; - return D3DXVECTOR3(x * fInv, y * fInv, z * fInv); -} - - -D3DXINLINE D3DXVECTOR3 -operator * ( float f, const struct D3DXVECTOR3& v ) -{ - return D3DXVECTOR3(f * v.x, f * v.y, f * v.z); -} - - -D3DXINLINE BOOL -D3DXVECTOR3::operator == ( const D3DXVECTOR3& v ) const -{ - return x == v.x && y == v.y && z == v.z; -} - -D3DXINLINE BOOL -D3DXVECTOR3::operator != ( const D3DXVECTOR3& v ) const -{ - return x != v.x || y != v.y || z != v.z; -} - - - -//-------------------------- -// 4D Vector -//-------------------------- -D3DXINLINE -D3DXVECTOR4::D3DXVECTOR4( const float *pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; - z = pf[2]; - w = pf[3]; -} - -D3DXINLINE -D3DXVECTOR4::D3DXVECTOR4( float fx, float fy, float fz, float fw ) -{ - x = fx; - y = fy; - z = fz; - w = fw; -} - - -// casting -D3DXINLINE -D3DXVECTOR4::operator float* () -{ - return (float *) &x; -} - -D3DXINLINE -D3DXVECTOR4::operator const float* () const -{ - return (const float *) &x; -} - - -// assignment operators -D3DXINLINE D3DXVECTOR4& -D3DXVECTOR4::operator += ( const D3DXVECTOR4& v ) -{ - x += v.x; - y += v.y; - z += v.z; - w += v.w; - return *this; -} - -D3DXINLINE D3DXVECTOR4& -D3DXVECTOR4::operator -= ( const D3DXVECTOR4& v ) -{ - x -= v.x; - y -= v.y; - z -= v.z; - w -= v.w; - return *this; -} - -D3DXINLINE D3DXVECTOR4& -D3DXVECTOR4::operator *= ( float f ) -{ - x *= f; - y *= f; - z *= f; - w *= f; - return *this; -} - -D3DXINLINE D3DXVECTOR4& -D3DXVECTOR4::operator /= ( float f ) -{ - float fInv = 1.0f / f; - x *= fInv; - y *= fInv; - z *= fInv; - w *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator - () const -{ - return D3DXVECTOR4(-x, -y, -z, -w); -} - - -// binary operators -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator + ( const D3DXVECTOR4& v ) const -{ - return D3DXVECTOR4(x + v.x, y + v.y, z + v.z, w + v.w); -} - -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator - ( const D3DXVECTOR4& v ) const -{ - return D3DXVECTOR4(x - v.x, y - v.y, z - v.z, w - v.w); -} - -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator * ( float f ) const -{ - return D3DXVECTOR4(x * f, y * f, z * f, w * f); -} - -D3DXINLINE D3DXVECTOR4 -D3DXVECTOR4::operator / ( float f ) const -{ - float fInv = 1.0f / f; - return D3DXVECTOR4(x * fInv, y * fInv, z * fInv, w * fInv); -} - - -D3DXINLINE D3DXVECTOR4 -operator * ( float f, const D3DXVECTOR4& v ) -{ - return D3DXVECTOR4(f * v.x, f * v.y, f * v.z, f * v.w); -} - - -D3DXINLINE BOOL -D3DXVECTOR4::operator == ( const D3DXVECTOR4& v ) const -{ - return x == v.x && y == v.y && z == v.z && w == v.w; -} - -D3DXINLINE BOOL -D3DXVECTOR4::operator != ( const D3DXVECTOR4& v ) const -{ - return x != v.x || y != v.y || z != v.z || w != v.w; -} - - -//-------------------------- -// Matrix -//-------------------------- -D3DXINLINE -D3DXMATRIX::D3DXMATRIX( const float* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - memcpy(&m00, pf, sizeof(D3DXMATRIX)); -} - -D3DXINLINE -D3DXMATRIX::D3DXMATRIX( const D3DMATRIX& mat ) -{ - memcpy(&m00, &mat, sizeof(D3DXMATRIX)); -} - -D3DXINLINE -D3DXMATRIX::D3DXMATRIX( float f00, float f01, float f02, float f03, - float f10, float f11, float f12, float f13, - float f20, float f21, float f22, float f23, - float f30, float f31, float f32, float f33 ) -{ - m00 = f00; m01 = f01; m02 = f02; m03 = f03; - m10 = f10; m11 = f11; m12 = f12; m13 = f13; - m20 = f20; m21 = f21; m22 = f22; m23 = f23; - m30 = f30; m31 = f31; m32 = f32; m33 = f33; -} - - - -// access grants -D3DXINLINE float& -D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) -{ - return m[iRow][iCol]; -} - -D3DXINLINE float -D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) const -{ - return m[iRow][iCol]; -} - - -// casting operators -D3DXINLINE -D3DXMATRIX::operator float* () -{ - return (float *) &m00; -} - -D3DXINLINE -D3DXMATRIX::operator const float* () const -{ - return (const float *) &m00; -} - - -D3DXINLINE -D3DXMATRIX::operator D3DMATRIX* () -{ - return (D3DMATRIX *) &m00; -} - -D3DXINLINE -D3DXMATRIX::operator const D3DMATRIX* () const -{ - return (const D3DMATRIX *) &m00; -} - - -D3DXINLINE -D3DXMATRIX::operator D3DMATRIX& () -{ - return *((D3DMATRIX *) &m00); -} - -D3DXINLINE -D3DXMATRIX::operator const D3DMATRIX& () const -{ - return *((const D3DMATRIX *) &m00); -} - - -// assignment operators -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator *= ( const D3DXMATRIX& mat ) -{ - D3DXMatrixMultiply(this, this, &mat); - return *this; -} - -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator += ( const D3DXMATRIX& mat ) -{ - m00 += mat.m00; m01 += mat.m01; m02 += mat.m02; m03 += mat.m03; - m10 += mat.m10; m11 += mat.m11; m12 += mat.m12; m13 += mat.m13; - m20 += mat.m20; m21 += mat.m21; m22 += mat.m22; m23 += mat.m23; - m30 += mat.m30; m31 += mat.m31; m32 += mat.m32; m33 += mat.m33; - return *this; -} - -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator -= ( const D3DXMATRIX& mat ) -{ - m00 -= mat.m00; m01 -= mat.m01; m02 -= mat.m02; m03 -= mat.m03; - m10 -= mat.m10; m11 -= mat.m11; m12 -= mat.m12; m13 -= mat.m13; - m20 -= mat.m20; m21 -= mat.m21; m22 -= mat.m22; m23 -= mat.m23; - m30 -= mat.m30; m31 -= mat.m31; m32 -= mat.m32; m33 -= mat.m33; - return *this; -} - -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator *= ( float f ) -{ - m00 *= f; m01 *= f; m02 *= f; m03 *= f; - m10 *= f; m11 *= f; m12 *= f; m13 *= f; - m20 *= f; m21 *= f; m22 *= f; m23 *= f; - m30 *= f; m31 *= f; m32 *= f; m33 *= f; - return *this; -} - -D3DXINLINE D3DXMATRIX& -D3DXMATRIX::operator /= ( float f ) -{ - float fInv = 1.0f / f; - m00 *= fInv; m01 *= fInv; m02 *= fInv; m03 *= fInv; - m10 *= fInv; m11 *= fInv; m12 *= fInv; m13 *= fInv; - m20 *= fInv; m21 *= fInv; m22 *= fInv; m23 *= fInv; - m30 *= fInv; m31 *= fInv; m32 *= fInv; m33 *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator - () const -{ - return D3DXMATRIX(-m00, -m01, -m02, -m03, - -m10, -m11, -m12, -m13, - -m20, -m21, -m22, -m23, - -m30, -m31, -m32, -m33); -} - - -// binary operators -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator * ( const D3DXMATRIX& mat ) const -{ - D3DXMATRIX matT; - D3DXMatrixMultiply(&matT, this, &mat); - return matT; -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator + ( const D3DXMATRIX& mat ) const -{ - return D3DXMATRIX(m00 + mat.m00, m01 + mat.m01, m02 + mat.m02, m03 + mat.m03, - m10 + mat.m10, m11 + mat.m11, m12 + mat.m12, m13 + mat.m13, - m20 + mat.m20, m21 + mat.m21, m22 + mat.m22, m23 + mat.m23, - m30 + mat.m30, m31 + mat.m31, m32 + mat.m32, m33 + mat.m33); -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator - ( const D3DXMATRIX& mat ) const -{ - return D3DXMATRIX(m00 - mat.m00, m01 - mat.m01, m02 - mat.m02, m03 - mat.m03, - m10 - mat.m10, m11 - mat.m11, m12 - mat.m12, m13 - mat.m13, - m20 - mat.m20, m21 - mat.m21, m22 - mat.m22, m23 - mat.m23, - m30 - mat.m30, m31 - mat.m31, m32 - mat.m32, m33 - mat.m33); -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator * ( float f ) const -{ - return D3DXMATRIX(m00 * f, m01 * f, m02 * f, m03 * f, - m10 * f, m11 * f, m12 * f, m13 * f, - m20 * f, m21 * f, m22 * f, m23 * f, - m30 * f, m31 * f, m32 * f, m33 * f); -} - -D3DXINLINE D3DXMATRIX -D3DXMATRIX::operator / ( float f ) const -{ - float fInv = 1.0f / f; - return D3DXMATRIX(m00 * fInv, m01 * fInv, m02 * fInv, m03 * fInv, - m10 * fInv, m11 * fInv, m12 * fInv, m13 * fInv, - m20 * fInv, m21 * fInv, m22 * fInv, m23 * fInv, - m30 * fInv, m31 * fInv, m32 * fInv, m33 * fInv); -} - - -D3DXINLINE D3DXMATRIX -operator * ( float f, const D3DXMATRIX& mat ) -{ - return D3DXMATRIX(f * mat.m00, f * mat.m01, f * mat.m02, f * mat.m03, - f * mat.m10, f * mat.m11, f * mat.m12, f * mat.m13, - f * mat.m20, f * mat.m21, f * mat.m22, f * mat.m23, - f * mat.m30, f * mat.m31, f * mat.m32, f * mat.m33); -} - - -D3DXINLINE BOOL -D3DXMATRIX::operator == ( const D3DXMATRIX& mat ) const -{ - return 0 == memcmp(this, &mat, sizeof(D3DXMATRIX)); -} - -D3DXINLINE BOOL -D3DXMATRIX::operator != ( const D3DXMATRIX& mat ) const -{ - return 0 != memcmp(this, &mat, sizeof(D3DXMATRIX)); -} - - - -//-------------------------- -// Quaternion -//-------------------------- - -D3DXINLINE -D3DXQUATERNION::D3DXQUATERNION( const float* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - x = pf[0]; - y = pf[1]; - z = pf[2]; - w = pf[3]; -} - -D3DXINLINE -D3DXQUATERNION::D3DXQUATERNION( float fx, float fy, float fz, float fw ) -{ - x = fx; - y = fy; - z = fz; - w = fw; -} - - -// casting -D3DXINLINE -D3DXQUATERNION::operator float* () -{ - return (float *) &x; -} - -D3DXINLINE -D3DXQUATERNION::operator const float* () const -{ - return (const float *) &x; -} - - -// assignment operators -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator += ( const D3DXQUATERNION& q ) -{ - x += q.x; - y += q.y; - z += q.z; - w += q.w; - return *this; -} - -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator -= ( const D3DXQUATERNION& q ) -{ - x -= q.x; - y -= q.y; - z -= q.z; - w -= q.w; - return *this; -} - -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator *= ( const D3DXQUATERNION& q ) -{ - D3DXQuaternionMultiply(this, this, &q); - return *this; -} - -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator *= ( float f ) -{ - x *= f; - y *= f; - z *= f; - w *= f; - return *this; -} - -D3DXINLINE D3DXQUATERNION& -D3DXQUATERNION::operator /= ( float f ) -{ - float fInv = 1.0f / f; - x *= fInv; - y *= fInv; - z *= fInv; - w *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator - () const -{ - return D3DXQUATERNION(-x, -y, -z, -w); -} - - -// binary operators -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator + ( const D3DXQUATERNION& q ) const -{ - return D3DXQUATERNION(x + q.x, y + q.y, z + q.z, w + q.w); -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator - ( const D3DXQUATERNION& q ) const -{ - return D3DXQUATERNION(x - q.x, y - q.y, z - q.z, w - q.w); -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator * ( const D3DXQUATERNION& q ) const -{ - D3DXQUATERNION qT; - D3DXQuaternionMultiply(&qT, this, &q); - return qT; -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator * ( float f ) const -{ - return D3DXQUATERNION(x * f, y * f, z * f, w * f); -} - -D3DXINLINE D3DXQUATERNION -D3DXQUATERNION::operator / ( float f ) const -{ - float fInv = 1.0f / f; - return D3DXQUATERNION(x * fInv, y * fInv, z * fInv, w * fInv); -} - - -D3DXINLINE D3DXQUATERNION -operator * (float f, const D3DXQUATERNION& q ) -{ - return D3DXQUATERNION(f * q.x, f * q.y, f * q.z, f * q.w); -} - - -D3DXINLINE BOOL -D3DXQUATERNION::operator == ( const D3DXQUATERNION& q ) const -{ - return x == q.x && y == q.y && z == q.z && w == q.w; -} - -D3DXINLINE BOOL -D3DXQUATERNION::operator != ( const D3DXQUATERNION& q ) const -{ - return x != q.x || y != q.y || z != q.z || w != q.w; -} - - - -//-------------------------- -// Plane -//-------------------------- - -D3DXINLINE -D3DXPLANE::D3DXPLANE( const float* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - a = pf[0]; - b = pf[1]; - c = pf[2]; - d = pf[3]; -} - -D3DXINLINE -D3DXPLANE::D3DXPLANE( float fa, float fb, float fc, float fd ) -{ - a = fa; - b = fb; - c = fc; - d = fd; -} - - -// casting -D3DXINLINE -D3DXPLANE::operator float* () -{ - return (float *) &a; -} - -D3DXINLINE -D3DXPLANE::operator const float* () const -{ - return (const float *) &a; -} - - -// unary operators -D3DXINLINE D3DXPLANE -D3DXPLANE::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXPLANE -D3DXPLANE::operator - () const -{ - return D3DXPLANE(-a, -b, -c, -d); -} - - -// binary operators -D3DXINLINE BOOL -D3DXPLANE::operator == ( const D3DXPLANE& p ) const -{ - return a == p.a && b == p.b && c == p.c && d == p.d; -} - -D3DXINLINE BOOL -D3DXPLANE::operator != ( const D3DXPLANE& p ) const -{ - return a != p.a || b != p.b || c != p.c || d != p.d; -} - - - - -//-------------------------- -// Color -//-------------------------- - -D3DXINLINE -D3DXCOLOR::D3DXCOLOR( DWORD dw ) -{ - const float f = 1.0f / 255.0f; - r = f * (float) (unsigned char) (dw >> 16); - g = f * (float) (unsigned char) (dw >> 8); - b = f * (float) (unsigned char) (dw >> 0); - a = f * (float) (unsigned char) (dw >> 24); -} - -D3DXINLINE -D3DXCOLOR::D3DXCOLOR( const float* pf ) -{ -#ifdef D3DX_DEBUG - if(!pf) - return; -#endif - - r = pf[0]; - g = pf[1]; - b = pf[2]; - a = pf[3]; -} - -D3DXINLINE -D3DXCOLOR::D3DXCOLOR( const D3DCOLORVALUE& c ) -{ - r = c.r; - g = c.g; - b = c.b; - a = c.a; -} - -D3DXINLINE -D3DXCOLOR::D3DXCOLOR( float fr, float fg, float fb, float fa ) -{ - r = fr; - g = fg; - b = fb; - a = fa; -} - - -// casting -D3DXINLINE -D3DXCOLOR::operator DWORD () const -{ - DWORD dwR = r >= 1.0f ? 0xff : r <= 0.0f ? 0x00 : (DWORD) (r * 255.0f + 0.5f); - DWORD dwG = g >= 1.0f ? 0xff : g <= 0.0f ? 0x00 : (DWORD) (g * 255.0f + 0.5f); - DWORD dwB = b >= 1.0f ? 0xff : b <= 0.0f ? 0x00 : (DWORD) (b * 255.0f + 0.5f); - DWORD dwA = a >= 1.0f ? 0xff : a <= 0.0f ? 0x00 : (DWORD) (a * 255.0f + 0.5f); - - return (dwA << 24) | (dwR << 16) | (dwG << 8) | dwB; -} - - -D3DXINLINE -D3DXCOLOR::operator float * () -{ - return (float *) &r; -} - -D3DXINLINE -D3DXCOLOR::operator const float * () const -{ - return (const float *) &r; -} - - -D3DXINLINE -D3DXCOLOR::operator D3DCOLORVALUE * () -{ - return (D3DCOLORVALUE *) &r; -} - -D3DXINLINE -D3DXCOLOR::operator const D3DCOLORVALUE * () const -{ - return (const D3DCOLORVALUE *) &r; -} - - -D3DXINLINE -D3DXCOLOR::operator D3DCOLORVALUE& () -{ - return *((D3DCOLORVALUE *) &r); -} - -D3DXINLINE -D3DXCOLOR::operator const D3DCOLORVALUE& () const -{ - return *((const D3DCOLORVALUE *) &r); -} - - -// assignment operators -D3DXINLINE D3DXCOLOR& -D3DXCOLOR::operator += ( const D3DXCOLOR& c ) -{ - r += c.r; - g += c.g; - b += c.b; - a += c.a; - return *this; -} - -D3DXINLINE D3DXCOLOR& -D3DXCOLOR::operator -= ( const D3DXCOLOR& c ) -{ - r -= c.r; - g -= c.g; - b -= c.b; - a -= c.a; - return *this; -} - -D3DXINLINE D3DXCOLOR& -D3DXCOLOR::operator *= ( float f ) -{ - r *= f; - g *= f; - b *= f; - a *= f; - return *this; -} - -D3DXINLINE D3DXCOLOR& -D3DXCOLOR::operator /= ( float f ) -{ - float fInv = 1.0f / f; - r *= fInv; - g *= fInv; - b *= fInv; - a *= fInv; - return *this; -} - - -// unary operators -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator + () const -{ - return *this; -} - -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator - () const -{ - return D3DXCOLOR(-r, -g, -b, -a); -} - - -// binary operators -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator + ( const D3DXCOLOR& c ) const -{ - return D3DXCOLOR(r + c.r, g + c.g, b + c.b, a + c.a); -} - -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator - ( const D3DXCOLOR& c ) const -{ - return D3DXCOLOR(r - c.r, g - c.g, b - c.b, a - c.a); -} - -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator * ( float f ) const -{ - return D3DXCOLOR(r * f, g * f, b * f, a * f); -} - -D3DXINLINE D3DXCOLOR -D3DXCOLOR::operator / ( float f ) const -{ - float fInv = 1.0f / f; - return D3DXCOLOR(r * fInv, g * fInv, b * fInv, a * fInv); -} - - -D3DXINLINE D3DXCOLOR -operator * (float f, const D3DXCOLOR& c ) -{ - return D3DXCOLOR(f * c.r, f * c.g, f * c.b, f * c.a); -} - - -D3DXINLINE BOOL -D3DXCOLOR::operator == ( const D3DXCOLOR& c ) const -{ - return r == c.r && g == c.g && b == c.b && a == c.a; -} - -D3DXINLINE BOOL -D3DXCOLOR::operator != ( const D3DXCOLOR& c ) const -{ - return r != c.r || g != c.g || b != c.b || a != c.a; -} - - -#endif //__cplusplus - - - -//=========================================================================== -// -// Inline functions -// -//=========================================================================== - - -//-------------------------- -// 2D Vector -//-------------------------- - -D3DXINLINE float D3DXVec2Length - ( const D3DXVECTOR2 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pV->x * pV->x + pV->y * pV->y); -#else - return (float) sqrt(pV->x * pV->x + pV->y * pV->y); -#endif -} - -D3DXINLINE float D3DXVec2LengthSq - ( const D3DXVECTOR2 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - - return pV->x * pV->x + pV->y * pV->y; -} - -D3DXINLINE float D3DXVec2Dot - ( const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->x + pV1->y * pV2->y; -} - -D3DXINLINE float D3DXVec2CCW - ( const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->y - pV1->y * pV2->x; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Add - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + pV2->x; - pOut->y = pV1->y + pV2->y; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Subtract - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x - pV2->x; - pOut->y = pV1->y - pV2->y; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Minimize - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Maximize - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Scale - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV, float s ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV) - return NULL; -#endif - - pOut->x = pV->x * s; - pOut->y = pV->y * s; - return pOut; -} - -D3DXINLINE D3DXVECTOR2* D3DXVec2Lerp - ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2, - float s ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + s * (pV2->x - pV1->x); - pOut->y = pV1->y + s * (pV2->y - pV1->y); - return pOut; -} - - -//-------------------------- -// 3D Vector -//-------------------------- - -D3DXINLINE float D3DXVec3Length - ( const D3DXVECTOR3 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); -#else - return (float) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); -#endif -} - -D3DXINLINE float D3DXVec3LengthSq - ( const D3DXVECTOR3 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - - return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z; -} - -D3DXINLINE float D3DXVec3Dot - ( const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Cross - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ) -{ - D3DXVECTOR3 v; - -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - 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 D3DXVECTOR3* D3DXVec3Add - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + pV2->x; - pOut->y = pV1->y + pV2->y; - pOut->z = pV1->z + pV2->z; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Subtract - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x - pV2->x; - pOut->y = pV1->y - pV2->y; - pOut->z = pV1->z - pV2->z; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Minimize - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Maximize - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Scale - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, float s) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV) - return NULL; -#endif - - pOut->x = pV->x * s; - pOut->y = pV->y * s; - pOut->z = pV->z * s; - return pOut; -} - -D3DXINLINE D3DXVECTOR3* D3DXVec3Lerp - ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2, - float s ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + s * (pV2->x - pV1->x); - pOut->y = pV1->y + s * (pV2->y - pV1->y); - pOut->z = pV1->z + s * (pV2->z - pV1->z); - return pOut; -} - - -//-------------------------- -// 4D Vector -//-------------------------- - -D3DXINLINE float D3DXVec4Length - ( const D3DXVECTOR4 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); -#else - return (float) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); -#endif -} - -D3DXINLINE float D3DXVec4LengthSq - ( const D3DXVECTOR4 *pV ) -{ -#ifdef D3DX_DEBUG - if(!pV) - return 0.0f; -#endif - - return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w; -} - -D3DXINLINE float D3DXVec4Dot - ( const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2 ) -{ -#ifdef D3DX_DEBUG - if(!pV1 || !pV2) - return 0.0f; -#endif - - return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z + pV1->w * pV2->w; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Add - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + pV2->x; - pOut->y = pV1->y + pV2->y; - pOut->z = pV1->z + pV2->z; - pOut->w = pV1->w + pV2->w; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Subtract - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x - pV2->x; - pOut->y = pV1->y - pV2->y; - pOut->z = pV1->z - pV2->z; - pOut->w = pV1->w - pV2->w; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Minimize - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; - pOut->w = pV1->w < pV2->w ? pV1->w : pV2->w; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Maximize - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; - pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; - pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; - pOut->w = pV1->w > pV2->w ? pV1->w : pV2->w; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Scale - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV, float s) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV) - return NULL; -#endif - - pOut->x = pV->x * s; - pOut->y = pV->y * s; - pOut->z = pV->z * s; - pOut->w = pV->w * s; - return pOut; -} - -D3DXINLINE D3DXVECTOR4* D3DXVec4Lerp - ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2, - float s ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pV1 || !pV2) - return NULL; -#endif - - pOut->x = pV1->x + s * (pV2->x - pV1->x); - pOut->y = pV1->y + s * (pV2->y - pV1->y); - pOut->z = pV1->z + s * (pV2->z - pV1->z); - pOut->w = pV1->w + s * (pV2->w - pV1->w); - return pOut; -} - - -//-------------------------- -// 4D Matrix -//-------------------------- - -D3DXINLINE D3DXMATRIX* D3DXMatrixIdentity - ( D3DXMATRIX *pOut ) -{ -#ifdef D3DX_DEBUG - if(!pOut) - return NULL; -#endif - - pOut->m[0][1] = pOut->m[0][2] = pOut->m[0][3] = - pOut->m[1][0] = pOut->m[1][2] = pOut->m[1][3] = - pOut->m[2][0] = pOut->m[2][1] = pOut->m[2][3] = - pOut->m[3][0] = pOut->m[3][1] = pOut->m[3][2] = 0.0f; - - pOut->m[0][0] = pOut->m[1][1] = pOut->m[2][2] = pOut->m[3][3] = 1.0f; - return pOut; -} - - -D3DXINLINE BOOL D3DXMatrixIsIdentity - ( const D3DXMATRIX *pM ) -{ -#ifdef D3DX_DEBUG - if(!pM) - return FALSE; -#endif - - return pM->m[0][0] == 1.0f && pM->m[0][1] == 0.0f && pM->m[0][2] == 0.0f && pM->m[0][3] == 0.0f && - pM->m[1][0] == 0.0f && pM->m[1][1] == 1.0f && pM->m[1][2] == 0.0f && pM->m[1][3] == 0.0f && - pM->m[2][0] == 0.0f && pM->m[2][1] == 0.0f && pM->m[2][2] == 1.0f && pM->m[2][3] == 0.0f && - pM->m[3][0] == 0.0f && pM->m[3][1] == 0.0f && pM->m[3][2] == 0.0f && pM->m[3][3] == 1.0f; -} - - -//-------------------------- -// Quaternion -//-------------------------- - -D3DXINLINE float D3DXQuaternionLength - ( const D3DXQUATERNION *pQ ) -{ -#ifdef D3DX_DEBUG - if(!pQ) - return 0.0f; -#endif - -#ifdef __cplusplus - return sqrtf(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); -#else - return (float) sqrt(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); -#endif -} - -D3DXINLINE float D3DXQuaternionLengthSq - ( const D3DXQUATERNION *pQ ) -{ -#ifdef D3DX_DEBUG - if(!pQ) - return 0.0f; -#endif - - return pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w; -} - -D3DXINLINE float D3DXQuaternionDot - ( const D3DXQUATERNION *pQ1, const D3DXQUATERNION *pQ2 ) -{ -#ifdef D3DX_DEBUG - if(!pQ1 || !pQ2) - return 0.0f; -#endif - - return pQ1->x * pQ2->x + pQ1->y * pQ2->y + pQ1->z * pQ2->z + pQ1->w * pQ2->w; -} - - -D3DXINLINE D3DXQUATERNION* D3DXQuaternionIdentity - ( D3DXQUATERNION *pOut ) -{ -#ifdef D3DX_DEBUG - if(!pOut) - return NULL; -#endif - - pOut->x = pOut->y = pOut->z = 0.0f; - pOut->w = 1.0f; - return pOut; -} - -D3DXINLINE BOOL D3DXQuaternionIsIdentity - ( const D3DXQUATERNION *pQ ) -{ -#ifdef D3DX_DEBUG - if(!pQ) - return FALSE; -#endif - - return pQ->x == 0.0f && pQ->y == 0.0f && pQ->z == 0.0f && pQ->w == 1.0f; -} - - -D3DXINLINE D3DXQUATERNION* D3DXQuaternionConjugate - ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ ) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pQ) - return NULL; -#endif - - pOut->x = -pQ->x; - pOut->y = -pQ->y; - pOut->z = -pQ->z; - pOut->w = pQ->w; - return pOut; -} - - -//-------------------------- -// Plane -//-------------------------- - -D3DXINLINE float D3DXPlaneDot - ( const D3DXPLANE *pP, const D3DXVECTOR4 *pV) -{ -#ifdef D3DX_DEBUG - if(!pP || !pV) - return 0.0f; -#endif - - return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d * pV->w; -} - -D3DXINLINE float D3DXPlaneDotCoord - ( const D3DXPLANE *pP, const D3DXVECTOR3 *pV) -{ -#ifdef D3DX_DEBUG - if(!pP || !pV) - return 0.0f; -#endif - - return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d; -} - -D3DXINLINE float D3DXPlaneDotNormal - ( const D3DXPLANE *pP, const D3DXVECTOR3 *pV) -{ -#ifdef D3DX_DEBUG - if(!pP || !pV) - return 0.0f; -#endif - - return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z; -} - - -//-------------------------- -// Color -//-------------------------- - -D3DXINLINE D3DXCOLOR* D3DXColorNegative - (D3DXCOLOR *pOut, const D3DXCOLOR *pC) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC) - return NULL; -#endif - - pOut->r = 1.0f - pC->r; - pOut->g = 1.0f - pC->g; - pOut->b = 1.0f - pC->b; - pOut->a = pC->a; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorAdd - (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r + pC2->r; - pOut->g = pC1->g + pC2->g; - pOut->b = pC1->b + pC2->b; - pOut->a = pC1->a + pC2->a; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorSubtract - (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r - pC2->r; - pOut->g = pC1->g - pC2->g; - pOut->b = pC1->b - pC2->b; - pOut->a = pC1->a - pC2->a; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorScale - (D3DXCOLOR *pOut, const D3DXCOLOR *pC, float s) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC) - return NULL; -#endif - - pOut->r = pC->r * s; - pOut->g = pC->g * s; - pOut->b = pC->b * s; - pOut->a = pC->a * s; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorModulate - (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r * pC2->r; - pOut->g = pC1->g * pC2->g; - pOut->b = pC1->b * pC2->b; - pOut->a = pC1->a * pC2->a; - return pOut; -} - -D3DXINLINE D3DXCOLOR* D3DXColorLerp - (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2, float s) -{ -#ifdef D3DX_DEBUG - if(!pOut || !pC1 || !pC2) - return NULL; -#endif - - pOut->r = pC1->r + s * (pC2->r - pC1->r); - pOut->g = pC1->g + s * (pC2->g - pC1->g); - pOut->b = pC1->b + s * (pC2->b - pC1->b); - pOut->a = pC1->a + s * (pC2->a - pC1->a); - return pOut; -} - - -#endif // __D3DXMATH_INL__ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dxmath.inl +// Content: D3DX math inline functions +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DXMATH_INL__ +#define __D3DXMATH_INL__ + + +//=========================================================================== +// +// Inline Class Methods +// +//=========================================================================== + +#ifdef __cplusplus + +//-------------------------- +// 2D Vector +//-------------------------- + +D3DXINLINE +D3DXVECTOR2::D3DXVECTOR2( const float *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; +} + +D3DXINLINE +D3DXVECTOR2::D3DXVECTOR2( float fx, float fy ) +{ + x = fx; + y = fy; +} + +// casting +D3DXINLINE +D3DXVECTOR2::operator float* () +{ + return (float *) &x; +} + +D3DXINLINE +D3DXVECTOR2::operator const float* () const +{ + return (const float *) &x; +} + +// assignment operators +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator += ( const D3DXVECTOR2& v ) +{ + x += v.x; + y += v.y; + return *this; +} + +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator -= ( const D3DXVECTOR2& v ) +{ + x -= v.x; + y -= v.y; + return *this; +} + +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator *= ( float f ) +{ + x *= f; + y *= f; + return *this; +} + +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator /= ( float f ) +{ + float fInv = 1.0f / f; + x *= fInv; + y *= fInv; + return *this; +} + +// unary operators +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator - () const +{ + return D3DXVECTOR2(-x, -y); +} + +// binary operators +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator + ( const D3DXVECTOR2& v ) const +{ + return D3DXVECTOR2(x + v.x, y + v.y); +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator - ( const D3DXVECTOR2& v ) const +{ + return D3DXVECTOR2(x - v.x, y - v.y); +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator * ( float f ) const +{ + return D3DXVECTOR2(x * f, y * f); +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator / ( float f ) const +{ + float fInv = 1.0f / f; + return D3DXVECTOR2(x * fInv, y * fInv); +} + + +D3DXINLINE D3DXVECTOR2 +operator * ( float f, const D3DXVECTOR2& v ) +{ + return D3DXVECTOR2(f * v.x, f * v.y); +} + +D3DXINLINE BOOL +D3DXVECTOR2::operator == ( const D3DXVECTOR2& v ) const +{ + return x == v.x && y == v.y; +} + +D3DXINLINE BOOL +D3DXVECTOR2::operator != ( const D3DXVECTOR2& v ) const +{ + return x != v.x || y != v.y; +} + + + + +//-------------------------- +// 3D Vector +//-------------------------- +D3DXINLINE +D3DXVECTOR3::D3DXVECTOR3( const float *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; +} + +D3DXINLINE +D3DXVECTOR3::D3DXVECTOR3( const D3DVECTOR& v ) +{ + x = v.x; + y = v.y; + z = v.z; +} + +D3DXINLINE +D3DXVECTOR3::D3DXVECTOR3( float fx, float fy, float fz ) +{ + x = fx; + y = fy; + z = fz; +} + + +// casting +D3DXINLINE +D3DXVECTOR3::operator float* () +{ + return (float *) &x; +} + +D3DXINLINE +D3DXVECTOR3::operator const float* () const +{ + return (const float *) &x; +} + + +D3DXINLINE +D3DXVECTOR3::operator D3DVECTOR* () +{ + return (D3DVECTOR *) &x; +} + +D3DXINLINE +D3DXVECTOR3::operator const D3DVECTOR* () const +{ + return (const D3DVECTOR *) &x; +} + + +D3DXINLINE +D3DXVECTOR3::operator D3DVECTOR& () +{ + return *((D3DVECTOR *) &x); +} + +D3DXINLINE +D3DXVECTOR3::operator const D3DVECTOR& () const +{ + return *((const D3DVECTOR *) &x); +} + + +// assignment operators +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator += ( const D3DXVECTOR3& v ) +{ + x += v.x; + y += v.y; + z += v.z; + return *this; +} + +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator -= ( const D3DXVECTOR3& v ) +{ + x -= v.x; + y -= v.y; + z -= v.z; + return *this; +} + +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator *= ( float f ) +{ + x *= f; + y *= f; + z *= f; + return *this; +} + +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator /= ( float f ) +{ + float fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator - () const +{ + return D3DXVECTOR3(-x, -y, -z); +} + + +// binary operators +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator + ( const D3DXVECTOR3& v ) const +{ + return D3DXVECTOR3(x + v.x, y + v.y, z + v.z); +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator - ( const D3DXVECTOR3& v ) const +{ + return D3DXVECTOR3(x - v.x, y - v.y, z - v.z); +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator * ( float f ) const +{ + return D3DXVECTOR3(x * f, y * f, z * f); +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator / ( float f ) const +{ + float fInv = 1.0f / f; + return D3DXVECTOR3(x * fInv, y * fInv, z * fInv); +} + + +D3DXINLINE D3DXVECTOR3 +operator * ( float f, const struct D3DXVECTOR3& v ) +{ + return D3DXVECTOR3(f * v.x, f * v.y, f * v.z); +} + + +D3DXINLINE BOOL +D3DXVECTOR3::operator == ( const D3DXVECTOR3& v ) const +{ + return x == v.x && y == v.y && z == v.z; +} + +D3DXINLINE BOOL +D3DXVECTOR3::operator != ( const D3DXVECTOR3& v ) const +{ + return x != v.x || y != v.y || z != v.z; +} + + + +//-------------------------- +// 4D Vector +//-------------------------- +D3DXINLINE +D3DXVECTOR4::D3DXVECTOR4( const float *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; + w = pf[3]; +} + +D3DXINLINE +D3DXVECTOR4::D3DXVECTOR4( float fx, float fy, float fz, float fw ) +{ + x = fx; + y = fy; + z = fz; + w = fw; +} + + +// casting +D3DXINLINE +D3DXVECTOR4::operator float* () +{ + return (float *) &x; +} + +D3DXINLINE +D3DXVECTOR4::operator const float* () const +{ + return (const float *) &x; +} + + +// assignment operators +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator += ( const D3DXVECTOR4& v ) +{ + x += v.x; + y += v.y; + z += v.z; + w += v.w; + return *this; +} + +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator -= ( const D3DXVECTOR4& v ) +{ + x -= v.x; + y -= v.y; + z -= v.z; + w -= v.w; + return *this; +} + +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator *= ( float f ) +{ + x *= f; + y *= f; + z *= f; + w *= f; + return *this; +} + +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator /= ( float f ) +{ + float fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + w *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator - () const +{ + return D3DXVECTOR4(-x, -y, -z, -w); +} + + +// binary operators +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator + ( const D3DXVECTOR4& v ) const +{ + return D3DXVECTOR4(x + v.x, y + v.y, z + v.z, w + v.w); +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator - ( const D3DXVECTOR4& v ) const +{ + return D3DXVECTOR4(x - v.x, y - v.y, z - v.z, w - v.w); +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator * ( float f ) const +{ + return D3DXVECTOR4(x * f, y * f, z * f, w * f); +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator / ( float f ) const +{ + float fInv = 1.0f / f; + return D3DXVECTOR4(x * fInv, y * fInv, z * fInv, w * fInv); +} + + +D3DXINLINE D3DXVECTOR4 +operator * ( float f, const D3DXVECTOR4& v ) +{ + return D3DXVECTOR4(f * v.x, f * v.y, f * v.z, f * v.w); +} + + +D3DXINLINE BOOL +D3DXVECTOR4::operator == ( const D3DXVECTOR4& v ) const +{ + return x == v.x && y == v.y && z == v.z && w == v.w; +} + +D3DXINLINE BOOL +D3DXVECTOR4::operator != ( const D3DXVECTOR4& v ) const +{ + return x != v.x || y != v.y || z != v.z || w != v.w; +} + + +//-------------------------- +// Matrix +//-------------------------- +D3DXINLINE +D3DXMATRIX::D3DXMATRIX( const float* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + memcpy(&m00, pf, sizeof(D3DXMATRIX)); +} + +D3DXINLINE +D3DXMATRIX::D3DXMATRIX( const D3DMATRIX& mat ) +{ + memcpy(&m00, &mat, sizeof(D3DXMATRIX)); +} + +D3DXINLINE +D3DXMATRIX::D3DXMATRIX( float f00, float f01, float f02, float f03, + float f10, float f11, float f12, float f13, + float f20, float f21, float f22, float f23, + float f30, float f31, float f32, float f33 ) +{ + m00 = f00; m01 = f01; m02 = f02; m03 = f03; + m10 = f10; m11 = f11; m12 = f12; m13 = f13; + m20 = f20; m21 = f21; m22 = f22; m23 = f23; + m30 = f30; m31 = f31; m32 = f32; m33 = f33; +} + + + +// access grants +D3DXINLINE float& +D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) +{ + return m[iRow][iCol]; +} + +D3DXINLINE float +D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) const +{ + return m[iRow][iCol]; +} + + +// casting operators +D3DXINLINE +D3DXMATRIX::operator float* () +{ + return (float *) &m00; +} + +D3DXINLINE +D3DXMATRIX::operator const float* () const +{ + return (const float *) &m00; +} + + +D3DXINLINE +D3DXMATRIX::operator D3DMATRIX* () +{ + return (D3DMATRIX *) &m00; +} + +D3DXINLINE +D3DXMATRIX::operator const D3DMATRIX* () const +{ + return (const D3DMATRIX *) &m00; +} + + +D3DXINLINE +D3DXMATRIX::operator D3DMATRIX& () +{ + return *((D3DMATRIX *) &m00); +} + +D3DXINLINE +D3DXMATRIX::operator const D3DMATRIX& () const +{ + return *((const D3DMATRIX *) &m00); +} + + +// assignment operators +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator *= ( const D3DXMATRIX& mat ) +{ + D3DXMatrixMultiply(this, this, &mat); + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator += ( const D3DXMATRIX& mat ) +{ + m00 += mat.m00; m01 += mat.m01; m02 += mat.m02; m03 += mat.m03; + m10 += mat.m10; m11 += mat.m11; m12 += mat.m12; m13 += mat.m13; + m20 += mat.m20; m21 += mat.m21; m22 += mat.m22; m23 += mat.m23; + m30 += mat.m30; m31 += mat.m31; m32 += mat.m32; m33 += mat.m33; + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator -= ( const D3DXMATRIX& mat ) +{ + m00 -= mat.m00; m01 -= mat.m01; m02 -= mat.m02; m03 -= mat.m03; + m10 -= mat.m10; m11 -= mat.m11; m12 -= mat.m12; m13 -= mat.m13; + m20 -= mat.m20; m21 -= mat.m21; m22 -= mat.m22; m23 -= mat.m23; + m30 -= mat.m30; m31 -= mat.m31; m32 -= mat.m32; m33 -= mat.m33; + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator *= ( float f ) +{ + m00 *= f; m01 *= f; m02 *= f; m03 *= f; + m10 *= f; m11 *= f; m12 *= f; m13 *= f; + m20 *= f; m21 *= f; m22 *= f; m23 *= f; + m30 *= f; m31 *= f; m32 *= f; m33 *= f; + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator /= ( float f ) +{ + float fInv = 1.0f / f; + m00 *= fInv; m01 *= fInv; m02 *= fInv; m03 *= fInv; + m10 *= fInv; m11 *= fInv; m12 *= fInv; m13 *= fInv; + m20 *= fInv; m21 *= fInv; m22 *= fInv; m23 *= fInv; + m30 *= fInv; m31 *= fInv; m32 *= fInv; m33 *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator - () const +{ + return D3DXMATRIX(-m00, -m01, -m02, -m03, + -m10, -m11, -m12, -m13, + -m20, -m21, -m22, -m23, + -m30, -m31, -m32, -m33); +} + + +// binary operators +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator * ( const D3DXMATRIX& mat ) const +{ + D3DXMATRIX matT; + D3DXMatrixMultiply(&matT, this, &mat); + return matT; +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator + ( const D3DXMATRIX& mat ) const +{ + return D3DXMATRIX(m00 + mat.m00, m01 + mat.m01, m02 + mat.m02, m03 + mat.m03, + m10 + mat.m10, m11 + mat.m11, m12 + mat.m12, m13 + mat.m13, + m20 + mat.m20, m21 + mat.m21, m22 + mat.m22, m23 + mat.m23, + m30 + mat.m30, m31 + mat.m31, m32 + mat.m32, m33 + mat.m33); +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator - ( const D3DXMATRIX& mat ) const +{ + return D3DXMATRIX(m00 - mat.m00, m01 - mat.m01, m02 - mat.m02, m03 - mat.m03, + m10 - mat.m10, m11 - mat.m11, m12 - mat.m12, m13 - mat.m13, + m20 - mat.m20, m21 - mat.m21, m22 - mat.m22, m23 - mat.m23, + m30 - mat.m30, m31 - mat.m31, m32 - mat.m32, m33 - mat.m33); +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator * ( float f ) const +{ + return D3DXMATRIX(m00 * f, m01 * f, m02 * f, m03 * f, + m10 * f, m11 * f, m12 * f, m13 * f, + m20 * f, m21 * f, m22 * f, m23 * f, + m30 * f, m31 * f, m32 * f, m33 * f); +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator / ( float f ) const +{ + float fInv = 1.0f / f; + return D3DXMATRIX(m00 * fInv, m01 * fInv, m02 * fInv, m03 * fInv, + m10 * fInv, m11 * fInv, m12 * fInv, m13 * fInv, + m20 * fInv, m21 * fInv, m22 * fInv, m23 * fInv, + m30 * fInv, m31 * fInv, m32 * fInv, m33 * fInv); +} + + +D3DXINLINE D3DXMATRIX +operator * ( float f, const D3DXMATRIX& mat ) +{ + return D3DXMATRIX(f * mat.m00, f * mat.m01, f * mat.m02, f * mat.m03, + f * mat.m10, f * mat.m11, f * mat.m12, f * mat.m13, + f * mat.m20, f * mat.m21, f * mat.m22, f * mat.m23, + f * mat.m30, f * mat.m31, f * mat.m32, f * mat.m33); +} + + +D3DXINLINE BOOL +D3DXMATRIX::operator == ( const D3DXMATRIX& mat ) const +{ + return 0 == memcmp(this, &mat, sizeof(D3DXMATRIX)); +} + +D3DXINLINE BOOL +D3DXMATRIX::operator != ( const D3DXMATRIX& mat ) const +{ + return 0 != memcmp(this, &mat, sizeof(D3DXMATRIX)); +} + + + +//-------------------------- +// Quaternion +//-------------------------- + +D3DXINLINE +D3DXQUATERNION::D3DXQUATERNION( const float* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; + w = pf[3]; +} + +D3DXINLINE +D3DXQUATERNION::D3DXQUATERNION( float fx, float fy, float fz, float fw ) +{ + x = fx; + y = fy; + z = fz; + w = fw; +} + + +// casting +D3DXINLINE +D3DXQUATERNION::operator float* () +{ + return (float *) &x; +} + +D3DXINLINE +D3DXQUATERNION::operator const float* () const +{ + return (const float *) &x; +} + + +// assignment operators +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator += ( const D3DXQUATERNION& q ) +{ + x += q.x; + y += q.y; + z += q.z; + w += q.w; + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator -= ( const D3DXQUATERNION& q ) +{ + x -= q.x; + y -= q.y; + z -= q.z; + w -= q.w; + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator *= ( const D3DXQUATERNION& q ) +{ + D3DXQuaternionMultiply(this, this, &q); + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator *= ( float f ) +{ + x *= f; + y *= f; + z *= f; + w *= f; + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator /= ( float f ) +{ + float fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + w *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator - () const +{ + return D3DXQUATERNION(-x, -y, -z, -w); +} + + +// binary operators +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator + ( const D3DXQUATERNION& q ) const +{ + return D3DXQUATERNION(x + q.x, y + q.y, z + q.z, w + q.w); +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator - ( const D3DXQUATERNION& q ) const +{ + return D3DXQUATERNION(x - q.x, y - q.y, z - q.z, w - q.w); +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator * ( const D3DXQUATERNION& q ) const +{ + D3DXQUATERNION qT; + D3DXQuaternionMultiply(&qT, this, &q); + return qT; +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator * ( float f ) const +{ + return D3DXQUATERNION(x * f, y * f, z * f, w * f); +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator / ( float f ) const +{ + float fInv = 1.0f / f; + return D3DXQUATERNION(x * fInv, y * fInv, z * fInv, w * fInv); +} + + +D3DXINLINE D3DXQUATERNION +operator * (float f, const D3DXQUATERNION& q ) +{ + return D3DXQUATERNION(f * q.x, f * q.y, f * q.z, f * q.w); +} + + +D3DXINLINE BOOL +D3DXQUATERNION::operator == ( const D3DXQUATERNION& q ) const +{ + return x == q.x && y == q.y && z == q.z && w == q.w; +} + +D3DXINLINE BOOL +D3DXQUATERNION::operator != ( const D3DXQUATERNION& q ) const +{ + return x != q.x || y != q.y || z != q.z || w != q.w; +} + + + +//-------------------------- +// Plane +//-------------------------- + +D3DXINLINE +D3DXPLANE::D3DXPLANE( const float* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + a = pf[0]; + b = pf[1]; + c = pf[2]; + d = pf[3]; +} + +D3DXINLINE +D3DXPLANE::D3DXPLANE( float fa, float fb, float fc, float fd ) +{ + a = fa; + b = fb; + c = fc; + d = fd; +} + + +// casting +D3DXINLINE +D3DXPLANE::operator float* () +{ + return (float *) &a; +} + +D3DXINLINE +D3DXPLANE::operator const float* () const +{ + return (const float *) &a; +} + + +// unary operators +D3DXINLINE D3DXPLANE +D3DXPLANE::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXPLANE +D3DXPLANE::operator - () const +{ + return D3DXPLANE(-a, -b, -c, -d); +} + + +// binary operators +D3DXINLINE BOOL +D3DXPLANE::operator == ( const D3DXPLANE& p ) const +{ + return a == p.a && b == p.b && c == p.c && d == p.d; +} + +D3DXINLINE BOOL +D3DXPLANE::operator != ( const D3DXPLANE& p ) const +{ + return a != p.a || b != p.b || c != p.c || d != p.d; +} + + + + +//-------------------------- +// Color +//-------------------------- + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( DWORD dw ) +{ + const float f = 1.0f / 255.0f; + r = f * (float) (unsigned char) (dw >> 16); + g = f * (float) (unsigned char) (dw >> 8); + b = f * (float) (unsigned char) (dw >> 0); + a = f * (float) (unsigned char) (dw >> 24); +} + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( const float* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + r = pf[0]; + g = pf[1]; + b = pf[2]; + a = pf[3]; +} + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( const D3DCOLORVALUE& c ) +{ + r = c.r; + g = c.g; + b = c.b; + a = c.a; +} + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( float fr, float fg, float fb, float fa ) +{ + r = fr; + g = fg; + b = fb; + a = fa; +} + + +// casting +D3DXINLINE +D3DXCOLOR::operator DWORD () const +{ + DWORD dwR = r >= 1.0f ? 0xff : r <= 0.0f ? 0x00 : (DWORD) (r * 255.0f + 0.5f); + DWORD dwG = g >= 1.0f ? 0xff : g <= 0.0f ? 0x00 : (DWORD) (g * 255.0f + 0.5f); + DWORD dwB = b >= 1.0f ? 0xff : b <= 0.0f ? 0x00 : (DWORD) (b * 255.0f + 0.5f); + DWORD dwA = a >= 1.0f ? 0xff : a <= 0.0f ? 0x00 : (DWORD) (a * 255.0f + 0.5f); + + return (dwA << 24) | (dwR << 16) | (dwG << 8) | dwB; +} + + +D3DXINLINE +D3DXCOLOR::operator float * () +{ + return (float *) &r; +} + +D3DXINLINE +D3DXCOLOR::operator const float * () const +{ + return (const float *) &r; +} + + +D3DXINLINE +D3DXCOLOR::operator D3DCOLORVALUE * () +{ + return (D3DCOLORVALUE *) &r; +} + +D3DXINLINE +D3DXCOLOR::operator const D3DCOLORVALUE * () const +{ + return (const D3DCOLORVALUE *) &r; +} + + +D3DXINLINE +D3DXCOLOR::operator D3DCOLORVALUE& () +{ + return *((D3DCOLORVALUE *) &r); +} + +D3DXINLINE +D3DXCOLOR::operator const D3DCOLORVALUE& () const +{ + return *((const D3DCOLORVALUE *) &r); +} + + +// assignment operators +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator += ( const D3DXCOLOR& c ) +{ + r += c.r; + g += c.g; + b += c.b; + a += c.a; + return *this; +} + +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator -= ( const D3DXCOLOR& c ) +{ + r -= c.r; + g -= c.g; + b -= c.b; + a -= c.a; + return *this; +} + +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator *= ( float f ) +{ + r *= f; + g *= f; + b *= f; + a *= f; + return *this; +} + +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator /= ( float f ) +{ + float fInv = 1.0f / f; + r *= fInv; + g *= fInv; + b *= fInv; + a *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator - () const +{ + return D3DXCOLOR(-r, -g, -b, -a); +} + + +// binary operators +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator + ( const D3DXCOLOR& c ) const +{ + return D3DXCOLOR(r + c.r, g + c.g, b + c.b, a + c.a); +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator - ( const D3DXCOLOR& c ) const +{ + return D3DXCOLOR(r - c.r, g - c.g, b - c.b, a - c.a); +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator * ( float f ) const +{ + return D3DXCOLOR(r * f, g * f, b * f, a * f); +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator / ( float f ) const +{ + float fInv = 1.0f / f; + return D3DXCOLOR(r * fInv, g * fInv, b * fInv, a * fInv); +} + + +D3DXINLINE D3DXCOLOR +operator * (float f, const D3DXCOLOR& c ) +{ + return D3DXCOLOR(f * c.r, f * c.g, f * c.b, f * c.a); +} + + +D3DXINLINE BOOL +D3DXCOLOR::operator == ( const D3DXCOLOR& c ) const +{ + return r == c.r && g == c.g && b == c.b && a == c.a; +} + +D3DXINLINE BOOL +D3DXCOLOR::operator != ( const D3DXCOLOR& c ) const +{ + return r != c.r || g != c.g || b != c.b || a != c.a; +} + + +#endif //__cplusplus + + + +//=========================================================================== +// +// Inline functions +// +//=========================================================================== + + +//-------------------------- +// 2D Vector +//-------------------------- + +D3DXINLINE float D3DXVec2Length + ( const D3DXVECTOR2 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y); +#else + return (float) sqrt(pV->x * pV->x + pV->y * pV->y); +#endif +} + +D3DXINLINE float D3DXVec2LengthSq + ( const D3DXVECTOR2 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y; +} + +D3DXINLINE float D3DXVec2Dot + ( const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y; +} + +D3DXINLINE float D3DXVec2CCW + ( const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->y - pV1->y * pV2->x; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Add + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Subtract + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Minimize + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Maximize + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Scale + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV, float s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Lerp + ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2, + float s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + return pOut; +} + + +//-------------------------- +// 3D Vector +//-------------------------- + +D3DXINLINE float D3DXVec3Length + ( const D3DXVECTOR3 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); +#else + return (float) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); +#endif +} + +D3DXINLINE float D3DXVec3LengthSq + ( const D3DXVECTOR3 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z; +} + +D3DXINLINE float D3DXVec3Dot + ( const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Cross + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ) +{ + D3DXVECTOR3 v; + +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + 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 D3DXVECTOR3* D3DXVec3Add + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + pOut->z = pV1->z + pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Subtract + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + pOut->z = pV1->z - pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Minimize + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Maximize + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Scale + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, float s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + pOut->z = pV->z * s; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Lerp + ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2, + float s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + pOut->z = pV1->z + s * (pV2->z - pV1->z); + return pOut; +} + + +//-------------------------- +// 4D Vector +//-------------------------- + +D3DXINLINE float D3DXVec4Length + ( const D3DXVECTOR4 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); +#else + return (float) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); +#endif +} + +D3DXINLINE float D3DXVec4LengthSq + ( const D3DXVECTOR4 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w; +} + +D3DXINLINE float D3DXVec4Dot + ( const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z + pV1->w * pV2->w; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Add + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + pOut->z = pV1->z + pV2->z; + pOut->w = pV1->w + pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Subtract + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + pOut->z = pV1->z - pV2->z; + pOut->w = pV1->w - pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Minimize + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; + pOut->w = pV1->w < pV2->w ? pV1->w : pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Maximize + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; + pOut->w = pV1->w > pV2->w ? pV1->w : pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Scale + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV, float s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + pOut->z = pV->z * s; + pOut->w = pV->w * s; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Lerp + ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2, + float s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + pOut->z = pV1->z + s * (pV2->z - pV1->z); + pOut->w = pV1->w + s * (pV2->w - pV1->w); + return pOut; +} + + +//-------------------------- +// 4D Matrix +//-------------------------- + +D3DXINLINE D3DXMATRIX* D3DXMatrixIdentity + ( D3DXMATRIX *pOut ) +{ +#ifdef D3DX_DEBUG + if(!pOut) + return NULL; +#endif + + pOut->m[0][1] = pOut->m[0][2] = pOut->m[0][3] = + pOut->m[1][0] = pOut->m[1][2] = pOut->m[1][3] = + pOut->m[2][0] = pOut->m[2][1] = pOut->m[2][3] = + pOut->m[3][0] = pOut->m[3][1] = pOut->m[3][2] = 0.0f; + + pOut->m[0][0] = pOut->m[1][1] = pOut->m[2][2] = pOut->m[3][3] = 1.0f; + return pOut; +} + + +D3DXINLINE BOOL D3DXMatrixIsIdentity + ( const D3DXMATRIX *pM ) +{ +#ifdef D3DX_DEBUG + if(!pM) + return FALSE; +#endif + + return pM->m[0][0] == 1.0f && pM->m[0][1] == 0.0f && pM->m[0][2] == 0.0f && pM->m[0][3] == 0.0f && + pM->m[1][0] == 0.0f && pM->m[1][1] == 1.0f && pM->m[1][2] == 0.0f && pM->m[1][3] == 0.0f && + pM->m[2][0] == 0.0f && pM->m[2][1] == 0.0f && pM->m[2][2] == 1.0f && pM->m[2][3] == 0.0f && + pM->m[3][0] == 0.0f && pM->m[3][1] == 0.0f && pM->m[3][2] == 0.0f && pM->m[3][3] == 1.0f; +} + + +//-------------------------- +// Quaternion +//-------------------------- + +D3DXINLINE float D3DXQuaternionLength + ( const D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pQ) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); +#else + return (float) sqrt(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); +#endif +} + +D3DXINLINE float D3DXQuaternionLengthSq + ( const D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pQ) + return 0.0f; +#endif + + return pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w; +} + +D3DXINLINE float D3DXQuaternionDot + ( const D3DXQUATERNION *pQ1, const D3DXQUATERNION *pQ2 ) +{ +#ifdef D3DX_DEBUG + if(!pQ1 || !pQ2) + return 0.0f; +#endif + + return pQ1->x * pQ2->x + pQ1->y * pQ2->y + pQ1->z * pQ2->z + pQ1->w * pQ2->w; +} + + +D3DXINLINE D3DXQUATERNION* D3DXQuaternionIdentity + ( D3DXQUATERNION *pOut ) +{ +#ifdef D3DX_DEBUG + if(!pOut) + return NULL; +#endif + + pOut->x = pOut->y = pOut->z = 0.0f; + pOut->w = 1.0f; + return pOut; +} + +D3DXINLINE BOOL D3DXQuaternionIsIdentity + ( const D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pQ) + return FALSE; +#endif + + return pQ->x == 0.0f && pQ->y == 0.0f && pQ->z == 0.0f && pQ->w == 1.0f; +} + + +D3DXINLINE D3DXQUATERNION* D3DXQuaternionConjugate + ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pQ) + return NULL; +#endif + + pOut->x = -pQ->x; + pOut->y = -pQ->y; + pOut->z = -pQ->z; + pOut->w = pQ->w; + return pOut; +} + + +//-------------------------- +// Plane +//-------------------------- + +D3DXINLINE float D3DXPlaneDot + ( const D3DXPLANE *pP, const D3DXVECTOR4 *pV) +{ +#ifdef D3DX_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d * pV->w; +} + +D3DXINLINE float D3DXPlaneDotCoord + ( const D3DXPLANE *pP, const D3DXVECTOR3 *pV) +{ +#ifdef D3DX_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d; +} + +D3DXINLINE float D3DXPlaneDotNormal + ( const D3DXPLANE *pP, const D3DXVECTOR3 *pV) +{ +#ifdef D3DX_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z; +} + + +//-------------------------- +// Color +//-------------------------- + +D3DXINLINE D3DXCOLOR* D3DXColorNegative + (D3DXCOLOR *pOut, const D3DXCOLOR *pC) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC) + return NULL; +#endif + + pOut->r = 1.0f - pC->r; + pOut->g = 1.0f - pC->g; + pOut->b = 1.0f - pC->b; + pOut->a = pC->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorAdd + (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r + pC2->r; + pOut->g = pC1->g + pC2->g; + pOut->b = pC1->b + pC2->b; + pOut->a = pC1->a + pC2->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorSubtract + (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r - pC2->r; + pOut->g = pC1->g - pC2->g; + pOut->b = pC1->b - pC2->b; + pOut->a = pC1->a - pC2->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorScale + (D3DXCOLOR *pOut, const D3DXCOLOR *pC, float s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC) + return NULL; +#endif + + pOut->r = pC->r * s; + pOut->g = pC->g * s; + pOut->b = pC->b * s; + pOut->a = pC->a * s; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorModulate + (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r * pC2->r; + pOut->g = pC1->g * pC2->g; + pOut->b = pC1->b * pC2->b; + pOut->a = pC1->a * pC2->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorLerp + (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2, float s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r + s * (pC2->r - pC1->r); + pOut->g = pC1->g + s * (pC2->g - pC1->g); + pOut->b = pC1->b + s * (pC2->b - pC1->b); + pOut->a = pC1->a + s * (pC2->a - pC1->a); + return pOut; +} + + +#endif // __D3DXMATH_INL__ diff --git a/src/dep/include/DXSDK/include/d3dxshapes.h b/src/dep/include/DXSDK/include/d3dxshapes.h index b4ef209..765c59f 100644 --- a/src/dep/include/DXSDK/include/d3dxshapes.h +++ b/src/dep/include/DXSDK/include/d3dxshapes.h @@ -1,209 +1,209 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dxshapes.h -// Content: D3DX simple shapes -// -/////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DXSHAPES_H__ -#define __D3DXSHAPES_H__ - -#include -#include -#include "d3dxerr.h" - - -typedef struct ID3DXSimpleShape *LPD3DXSIMPLESHAPE; - -// {CFCD4602-EB7B-11d2-A440-00A0C90629A8} -DEFINE_GUID( IID_ID3DXSimpleShape, -0xcfcd4602, 0xeb7b, 0x11d2, 0xa4, 0x40, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8 ); - - -/////////////////////////////////////////////////////////////////////////// -// Interfaces: -/////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------- -// ID3DXSimpleShape interface: -//------------------------------------------------------------------------- - -DECLARE_INTERFACE_(ID3DXSimpleShape, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID* ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - // ID3DXSimpleShape methods - STDMETHOD_(LPDIRECT3DVERTEXBUFFER7, GetVB)(THIS) PURE; - STDMETHOD_(DWORD, GetIndices)(THIS_ LPWORD *ppIndices) PURE; - STDMETHOD(Draw)(THIS) PURE; -}; - - - -/////////////////////////////////////////////////////////////////////////// -// Functions: -/////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -//------------------------------------------------------------------------- -// D3DXCreatePolygon: Creates an 'n' sided polygon using the device -// ---------------- specified. It returns a vertex buffer that can be used -// for drawing or manipulation by the program later on. -// -// Params: -// [in] LPDIRECT3DDEVICE7 pDevice: The device to create off. -// [in] float sideSize: Length of a side. -// [in] DWORD numTexCoords: The number of texture coordinates desired -// in the vertex-buffer. (Default is 1) -// D3DX_DEFAULT is a valid input. -// [out] IDirect3DVertexBuffer7** ppVB: The output shape interface. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreatePolygon(LPDIRECT3DDEVICE7 pDevice, - float sideSize, - DWORD numSides, - DWORD numTexCoords, - LPD3DXSIMPLESHAPE* ppShape ); - -//------------------------------------------------------------------------- -// D3DXCreateBox: Creates a box (cuboid) of given dimensions using the -// ------------ device. It returns a vertex buffer that can -// be used for drawing or manipulation by the program later on. -// -// Params: -// [in] LPDIRECT3DDEVICE7 pDevice: The device to create off. -// [in] float width: Width of the box (along x-axis) -// [in] float height: Height of the box (along y-axis) -// [in] float depth: Depth of the box (along z-axis) -// [in] DWORD numTexCoords: The number of texture coordinates desired -// in the vertex-buffer. Default is 1. -// D3DX_DEFAULT is a valid input here. -// [out] LPD3DXSIMPLESHAPE* ppShape: The output vertex-buffer. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateBox(LPDIRECT3DDEVICE7 pDevice, - float width, - float height, - float depth, - DWORD numTexCoords, - LPD3DXSIMPLESHAPE* ppShape ); - -//------------------------------------------------------------------------- -// D3DXCreateCylinder: Creates a cylinder of given dimensions using the -// ----------------- device. It returns a vertex buffer that -// can be used for drawing or manipulation by the program -// later on. -// -// Params: -// [in] LPDIRECT3DDEVICE7 pDevice: The device to create off. -// [in] float baseRadius: Base-radius (default is 1.0f, shd be >= 0.0f) -// [in] float topRadius: Top-radius (default is 1.0f, shd be >= 0.0f) -// [in] float height: Height (default is 1.0f, shd be >= 0.0f) -// [in] DWORD numSlices: Number of slices about the main axis. -// (default is 8) D3DX_DEFAULT is a valid input. -// [in] DWORD numStacks: Number of stacks along the main axis. -// (default is 8) D3DX_DEFAULT is a valid input. -// [in] DWORD numTexCoords: The number of texture coordinates desired -// in the vertex-buffer. Default is 1. -// D3DX_DEFAULT is a valid input here. -// [out] LPD3DXSIMPLESHAPE* ppShape: The output shape interface. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateCylinder(LPDIRECT3DDEVICE7 pDevice, - float baseRadius, - float topRadius, - float height, - DWORD numSlices, - DWORD numStacks, - DWORD numTexCoords, - LPD3DXSIMPLESHAPE* ppShape ); - - -//------------------------------------------------------------------------- -// D3DXCreateTorus: Creates a torus of given dimensions using the -// -------------- device specified. It returns a vertex buffer that can -// be used for drawing or manipulation by the program later -// on. It draws a doughnut, centered at (0, 0, 0) whose axis -// is aligned with the z-axis. With the innerRadius used -// as the radius of the cross-section (minor-Radius) and -// the outerRadius used as the radius of the central 'hole'. -// -// Params: -// [in] LPDIRECT3DDEVICE7 pDevice: The device to create off. -// [in] float innerRadius: inner radius (default is 1.0f, shd be >= 0.0f) -// [in] float outerRadius: outer radius (default is 2.0f, shd be >= 0.0f) -// [in] DWORD numSides: Number of sides in the cross-section -// (default is 8). D3DX_DEFAULT is a valid input. -// [in] DWORD numRings: Number of rings making up the torus -// (default is 8) D3DX_DEFAULT is a valid input. -// [in] DWORD numTexCoords: The number of texture coordinates desired -// in the vertex-buffer. Default is 1. -// D3DX_DEFAULT is a valid input here. -// [out] LPD3DXSIMPLESHAPE* ppShape: The output shape interface. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTorus(LPDIRECT3DDEVICE7 pDevice, - float innerRadius, - float outerRadius, - DWORD numSides, - DWORD numRings, - DWORD numTexCoords, - LPD3DXSIMPLESHAPE* ppShape ); - -//------------------------------------------------------------------------- -// D3DXCreateTeapot: Creates a teapot using the device specified. -// ---------------- It returns a vertex buffer that can be used for -// drawing or manipulation by the program later on. -// -// Params: -// [in] LPDIRECT3DDEVICE7 pDevice: The device to create off. -// [in] DWORD numTexCoords: The number of texture coordinates desired -// in the vertex-buffer. Default is 1. -// D3DX_DEFAULT is a valid input here. -// [out] LPD3DXSIMPLESHAPE* ppShape: The output shape interface. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTeapot(LPDIRECT3DDEVICE7 pDevice, - DWORD numTexCoords, - LPD3DXSIMPLESHAPE* ppShape); - -//------------------------------------------------------------------------- -// D3DXCreateSphere: Creates a cylinder of given dimensions using the -// ---------------- device specified. -// It returns a vertex buffer that can be used for -// drawing or manipulation by the program later on. -// -// Params: -// [in] LPDIRECT3DDEVICE7 pDevice: The device to create off. -// [in] float radius: radius (default is 1.0f, shd be >= 0.0f) -// [in] float height: Height (default is 1.0f, shd be >= 0.0f) -// [in] DWORD numSlices: Number of slices about the main axis -// (default is 8) D3DX_DEFAULT is a valid input. -// [in] DWORD numStacks: Number of stacks along the main axis -// (default is 8) D3DX_DEFAULT is a valid input. -// [in] DWORD numTexCoords: The number of texture coordinates desired -// in the vertex-buffer. Default is 1. -// D3DX_DEFAULT is a valid input here. -// [out] LPD3DXSIMPLESHAPE* ppShape: The output shape interface. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateSphere(LPDIRECT3DDEVICE7 pDevice, - float radius, - DWORD numSlices, - DWORD numStacks, - DWORD numTexCoords, - LPD3DXSIMPLESHAPE* ppShape); - -#ifdef __cplusplus -} -#endif //__cplusplus -#endif //__D3DXSHAPES_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dxshapes.h +// Content: D3DX simple shapes +// +/////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DXSHAPES_H__ +#define __D3DXSHAPES_H__ + +#include +#include +#include "d3dxerr.h" + + +typedef struct ID3DXSimpleShape *LPD3DXSIMPLESHAPE; + +// {CFCD4602-EB7B-11d2-A440-00A0C90629A8} +DEFINE_GUID( IID_ID3DXSimpleShape, +0xcfcd4602, 0xeb7b, 0x11d2, 0xa4, 0x40, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8 ); + + +/////////////////////////////////////////////////////////////////////////// +// Interfaces: +/////////////////////////////////////////////////////////////////////////// + +//------------------------------------------------------------------------- +// ID3DXSimpleShape interface: +//------------------------------------------------------------------------- + +DECLARE_INTERFACE_(ID3DXSimpleShape, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID* ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // ID3DXSimpleShape methods + STDMETHOD_(LPDIRECT3DVERTEXBUFFER7, GetVB)(THIS) PURE; + STDMETHOD_(DWORD, GetIndices)(THIS_ LPWORD *ppIndices) PURE; + STDMETHOD(Draw)(THIS) PURE; +}; + + + +/////////////////////////////////////////////////////////////////////////// +// Functions: +/////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +//------------------------------------------------------------------------- +// D3DXCreatePolygon: Creates an 'n' sided polygon using the device +// ---------------- specified. It returns a vertex buffer that can be used +// for drawing or manipulation by the program later on. +// +// Params: +// [in] LPDIRECT3DDEVICE7 pDevice: The device to create off. +// [in] float sideSize: Length of a side. +// [in] DWORD numTexCoords: The number of texture coordinates desired +// in the vertex-buffer. (Default is 1) +// D3DX_DEFAULT is a valid input. +// [out] IDirect3DVertexBuffer7** ppVB: The output shape interface. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreatePolygon(LPDIRECT3DDEVICE7 pDevice, + float sideSize, + DWORD numSides, + DWORD numTexCoords, + LPD3DXSIMPLESHAPE* ppShape ); + +//------------------------------------------------------------------------- +// D3DXCreateBox: Creates a box (cuboid) of given dimensions using the +// ------------ device. It returns a vertex buffer that can +// be used for drawing or manipulation by the program later on. +// +// Params: +// [in] LPDIRECT3DDEVICE7 pDevice: The device to create off. +// [in] float width: Width of the box (along x-axis) +// [in] float height: Height of the box (along y-axis) +// [in] float depth: Depth of the box (along z-axis) +// [in] DWORD numTexCoords: The number of texture coordinates desired +// in the vertex-buffer. Default is 1. +// D3DX_DEFAULT is a valid input here. +// [out] LPD3DXSIMPLESHAPE* ppShape: The output vertex-buffer. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateBox(LPDIRECT3DDEVICE7 pDevice, + float width, + float height, + float depth, + DWORD numTexCoords, + LPD3DXSIMPLESHAPE* ppShape ); + +//------------------------------------------------------------------------- +// D3DXCreateCylinder: Creates a cylinder of given dimensions using the +// ----------------- device. It returns a vertex buffer that +// can be used for drawing or manipulation by the program +// later on. +// +// Params: +// [in] LPDIRECT3DDEVICE7 pDevice: The device to create off. +// [in] float baseRadius: Base-radius (default is 1.0f, shd be >= 0.0f) +// [in] float topRadius: Top-radius (default is 1.0f, shd be >= 0.0f) +// [in] float height: Height (default is 1.0f, shd be >= 0.0f) +// [in] DWORD numSlices: Number of slices about the main axis. +// (default is 8) D3DX_DEFAULT is a valid input. +// [in] DWORD numStacks: Number of stacks along the main axis. +// (default is 8) D3DX_DEFAULT is a valid input. +// [in] DWORD numTexCoords: The number of texture coordinates desired +// in the vertex-buffer. Default is 1. +// D3DX_DEFAULT is a valid input here. +// [out] LPD3DXSIMPLESHAPE* ppShape: The output shape interface. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateCylinder(LPDIRECT3DDEVICE7 pDevice, + float baseRadius, + float topRadius, + float height, + DWORD numSlices, + DWORD numStacks, + DWORD numTexCoords, + LPD3DXSIMPLESHAPE* ppShape ); + + +//------------------------------------------------------------------------- +// D3DXCreateTorus: Creates a torus of given dimensions using the +// -------------- device specified. It returns a vertex buffer that can +// be used for drawing or manipulation by the program later +// on. It draws a doughnut, centered at (0, 0, 0) whose axis +// is aligned with the z-axis. With the innerRadius used +// as the radius of the cross-section (minor-Radius) and +// the outerRadius used as the radius of the central 'hole'. +// +// Params: +// [in] LPDIRECT3DDEVICE7 pDevice: The device to create off. +// [in] float innerRadius: inner radius (default is 1.0f, shd be >= 0.0f) +// [in] float outerRadius: outer radius (default is 2.0f, shd be >= 0.0f) +// [in] DWORD numSides: Number of sides in the cross-section +// (default is 8). D3DX_DEFAULT is a valid input. +// [in] DWORD numRings: Number of rings making up the torus +// (default is 8) D3DX_DEFAULT is a valid input. +// [in] DWORD numTexCoords: The number of texture coordinates desired +// in the vertex-buffer. Default is 1. +// D3DX_DEFAULT is a valid input here. +// [out] LPD3DXSIMPLESHAPE* ppShape: The output shape interface. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTorus(LPDIRECT3DDEVICE7 pDevice, + float innerRadius, + float outerRadius, + DWORD numSides, + DWORD numRings, + DWORD numTexCoords, + LPD3DXSIMPLESHAPE* ppShape ); + +//------------------------------------------------------------------------- +// D3DXCreateTeapot: Creates a teapot using the device specified. +// ---------------- It returns a vertex buffer that can be used for +// drawing or manipulation by the program later on. +// +// Params: +// [in] LPDIRECT3DDEVICE7 pDevice: The device to create off. +// [in] DWORD numTexCoords: The number of texture coordinates desired +// in the vertex-buffer. Default is 1. +// D3DX_DEFAULT is a valid input here. +// [out] LPD3DXSIMPLESHAPE* ppShape: The output shape interface. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTeapot(LPDIRECT3DDEVICE7 pDevice, + DWORD numTexCoords, + LPD3DXSIMPLESHAPE* ppShape); + +//------------------------------------------------------------------------- +// D3DXCreateSphere: Creates a cylinder of given dimensions using the +// ---------------- device specified. +// It returns a vertex buffer that can be used for +// drawing or manipulation by the program later on. +// +// Params: +// [in] LPDIRECT3DDEVICE7 pDevice: The device to create off. +// [in] float radius: radius (default is 1.0f, shd be >= 0.0f) +// [in] float height: Height (default is 1.0f, shd be >= 0.0f) +// [in] DWORD numSlices: Number of slices about the main axis +// (default is 8) D3DX_DEFAULT is a valid input. +// [in] DWORD numStacks: Number of stacks along the main axis +// (default is 8) D3DX_DEFAULT is a valid input. +// [in] DWORD numTexCoords: The number of texture coordinates desired +// in the vertex-buffer. Default is 1. +// D3DX_DEFAULT is a valid input here. +// [out] LPD3DXSIMPLESHAPE* ppShape: The output shape interface. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateSphere(LPDIRECT3DDEVICE7 pDevice, + float radius, + DWORD numSlices, + DWORD numStacks, + DWORD numTexCoords, + LPD3DXSIMPLESHAPE* ppShape); + +#ifdef __cplusplus +} +#endif //__cplusplus +#endif //__D3DXSHAPES_H__ diff --git a/src/dep/include/DXSDK/include/d3dxsprite.h b/src/dep/include/DXSDK/include/d3dxsprite.h index 2e08d30..a08b4a9 100644 --- a/src/dep/include/DXSDK/include/d3dxsprite.h +++ b/src/dep/include/DXSDK/include/d3dxsprite.h @@ -1,321 +1,321 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dxsprite.h -// Content: D3DX sprite helper functions -// -// These functions allow you to use sprites with D3DX. A "sprite" is -// loosely defined as a 2D image that you want to transfer to the -// rendering target. The source image can be a texture created -// with the help of the D3DX texture loader; though advanced users may -// want to create their own. A helper function (PrepareDeviceForSprite) -// is provided to make it easy to set up render states on a device. -// (Again, advanced users can use their own created devices.) -// -// There are two general techniques for sprites; the simpler one just -// specifies a destination rectangle and a rotation anlge. A more -// powerful technique supports rendering to non-rectangular quads. -// -// Both techniques support clipping, alpha, and rotation. More -// details are below. -// -/////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DXSPRITE_H__ -#define __D3DXSPRITE_H__ - -#include -#include -#include "d3dxerr.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -//------------------------------------------------------------------------- -// D3DXPrepareDeviceForSprite: -// -// Call this function to set up all the render states necessary for -// BltSprite/WarpSprite to work correctly. (Advanced users may opt to -// not call this function first; in which case Blt/WarpSprite functions -// will use whatever render/texture states were set up on the device when -// they are called.) -// -// Warning: This function modifies render states and may impact performance -// negatively on some 3D hardware if it is called too often per frame. -// -// Warning: If the render state changes (other than through calls to -// BltSprite or WarpSprite), you will need to call this function again before -// calling BltSprite or WarpSprite. -// -// Details: This function modifies the the rendering first texture stage and -// it modifies some renderstates for the entire device. Here is the exact -// list: -// -// SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); -// SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); -// SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); -// SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); -// SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); -// SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_LINEAR); -// SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_LINEAR); -// -// SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); -// SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); -// SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); -// -// Depending on the value of ZEnable parameter, this function will -// will either call -// SetRenderState(D3DRENDERSTATE_ZENABLE, FALSE); -// - or - -// SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE); -// -// Parameters: -// pd3dDevice - a pointer to the d3d device that you wish to prepare -// for use with D3DX Sprite Services -// ZEnable - a flag indicating whether you want the sprites to -// check and update the Z buffer as part of rendering. -// If ZEnable is FALSE, OR you are using -// alpha-blending, then it is necessary to render your -// sprites from back-to-front. -// -//------------------------------------------------------------------------- - -#ifdef __cplusplus -HRESULT WINAPI - D3DXPrepareDeviceForSprite( LPDIRECT3DDEVICE7 pd3dDevice, - BOOL ZEnable = FALSE); -#else -HRESULT WINAPI - D3DXPrepareDeviceForSprite( LPDIRECT3DDEVICE7 pd3dDevice, - BOOL ZEnable); -#endif - - - -//------------------------------------------------------------------------- -// The D3DXDrawBasicSprite() function performs blitting of source images onto -// a 3D rendering device. This function only calls SetTexture on the first -// renderstage with the parameter (pd3dTexture) if that parameter is non-null. -// This function assumes that D3DXPrepareDeviceForSprite has been called on -// the device or that caller has in some other way correctly prepared the -// renderstates. -// -// This function supports scaling, rotations, alpha-blending, and choosing -// a source sub-rect. -// -// Rotation angle is specified in radians. Both rotations and scales -// are applied around the center of the sprite; where the center of the -// sprite is half the width/height of the sprite, plus the offset parameter. -// -// Use the offset parameter if you want the sprite's center to be something -// other than the image center. -// -// The destination point indicates where you would like the center of -// the sprite to draw to. -// -// Parameters: -// pd3dTexture - a pointer to the surface containing the texture -// pd3dDevice - a pointer to the d3d device to render to. It is -// assumed that render states are set up. (See -// D3DXPrepareDeviceForSprite) -// ppointDest - a pointer to the target point for the sprite. The -// components of the vector must be in screen -// space. -// alpha - alpha value to apply to sprite. 1.0 means totally -// opaque; and 0.0 means totally transparent. -// WARNING: If you are using alpha, then you should render -// from back to front in order to avoid rendering -// artifacts. -// angleRad - angle of rotation around the 'center' of the rect -// scale - a uniform scale that is applied to the source rect -// to specify the size of the image that is rendered -// pOffset - offset from the center of the source rect to use as the -// center of rotation -// pSourceRect - a rect that indicates what portion of the source -// source texture to use. If NULL is passed, then the -// entire source is used. If the source texture was -// created via D3DX, then the rect should be specified -// in the coordinates of the original image (so that you -// don't have to worry about stretching/scaling that D3DX -// may have done to make the image work with your current -// 3D Device.) Note that horizontal or vertical mirroring -// may be simply accomplished by swapping the left/right -// or top/bottom fields of this RECT. -//------------------------------------------------------------------------- - -#ifdef __cplusplus -HRESULT WINAPI - D3DXDrawSpriteSimple(LPDIRECTDRAWSURFACE7 pd3dTexture, - LPDIRECT3DDEVICE7 pd3dDevice, - const D3DXVECTOR3 *ppointDest, - float alpha = 1.0f, - float scale = 1.0f, - float angleRad = 0.0f, - const D3DXVECTOR2 *pOffset = NULL, - const RECT *pSourceRect = NULL); -#else -HRESULT WINAPI - D3DXDrawSpriteSimple(LPDIRECTDRAWSURFACE7 pd3dTexture, - LPDIRECT3DDEVICE7 pd3dDevice, - D3DXVECTOR3 *ppointDest, - float alpha, - float scale, - float angleRad, - D3DXVECTOR2 *pOffset, - RECT *pSourceRect); -#endif - -//------------------------------------------------------------------------- -// The D3DXDrawSprite() function transforms source images onto a 3D -// rendering device. It takes a general 4x4 matrix which is use to transform -// the points of a default rect: (left=-.5, top=-.5, right=+.5, bottom=+.5). -// (This default rect was chosen so that it was centered around the origin -// to ease setting up rotations. And it was chosen to have a width/height of one -// to ease setting up scales.) -// -// This function only calls SetTexture on the first -// renderstage with the parameter (pd3dTexture) if that parameter is non-null. -// This function assumes that D3DXPrepareDeviceForSprite has been called on -// the device or that caller has in some other way correctly prepared the -// renderstates. -// -// This function supports alpha-blending, and choosing -// a source sub-rect. (A value of NULL for source sub-rect means the entire -// texture is used.) -// -// Note that if the transformed points have a value for w (the homogenous -// coordinate) that is not 1, then this function will invert it and pass -// that value to D3D as the rhw field of a TLVERTEX. If the value for w is -// zero, then it use 1 as the rhw. -// -// Parameters: -// pd3dTexture - a pointer to the surface containing the texture -// pd3dDevice - a pointer to the d3d device to render to. It is -// assumed that render states are set up. (See -// D3DXPrepareDeviceForSprite) -// pMatrixTransform - 4x4 matrix that specifies the transformation -// that will be applied to the default -.5 to +.5 -// rectangle. -// alpha - alpha value to apply to sprite. 1.0 means totally -// opaque; and 0.0 means totally transparent. -// WARNING: If you are using alpha, then you should render -// from back to front in order to avoid rendering -// artifacts.Furthermore, you should avoid scenarios where -// semi-transparent objects intersect. -// pSourceRect - a rect that indicates what portion of the source -// source texture to use. If NULL is passed, then the -// entire source is used. If the source texture was -// created via D3DX, then the rect should be specified -// in the coordinates of the original image (so that you -// don't have to worry about stretching/scaling that D3DX -// may have done to make the image work with your current -// 3D Device.) Note that mirroring may be simply accomplished -// by swapping the left/right or top/bottom fields of -// this RECT. -// -//------------------------------------------------------------------------- - -#ifdef __cplusplus -HRESULT WINAPI - D3DXDrawSpriteTransform(LPDIRECTDRAWSURFACE7 pd3dTexture, - LPDIRECT3DDEVICE7 pd3dDevice, - const D3DXMATRIX *pMatrixTransform, - float alpha = 1.0f, - const RECT *pSourceRect = NULL); -#else -HRESULT WINAPI - D3DXDrawSpriteTransform(LPDIRECTDRAWSURFACE7 pd3dTexture, - LPDIRECT3DDEVICE7 pd3dDevice, - D3DXMATRIX *pMatrixTransform, - float alpha, - RECT *pSourceRect); -#endif - -//------------------------------------------------------------------------- -// The D3DXBuildSpriteTransform() function is a helper provided which -// creates a matrix corresponding to simple properties. This matrix is -// set up to pass directly to D3DXTransformSprite. -// -// Parameters: -// pMatrix - a pointer to the result matrix -// prectDest - a pointer to the target rectangle for the sprite -// angleRad - angle of rotation around the 'center' of the rect -// pOffset - offset from the center of the source rect to use as the -// center of rotation -// -//------------------------------------------------------------------------- - -#ifdef __cplusplus -void WINAPI - D3DXBuildSpriteTransform(D3DXMATRIX *pMatrix, - const RECT *prectDest, - float angleRad = 0.0f, - const D3DXVECTOR2 *pOffset = NULL); -#else -void WINAPI - D3DXBuildSpriteTransform(D3DXMATRIX *pMatrix, - RECT *prectDest, - float angleRad, - D3DXVECTOR2 *pOffset); -#endif - - -//------------------------------------------------------------------------- -// The D3DXDrawSprite3D() function renders a texture onto a 3D quad. The -// quad ABCD is broken into two triangles ABC and ACD which are rendered -// via DrawPrim. -// -// Parameters: -// pd3dTexture - a pointer to the surface containing the texture -// pd3dDevice - a pointer to the d3d device to render to. It is -// assumed that render states are set up. (See -// D3DXPrepareDeviceForSprite) -// quad - array of 4 points in the following order: -// upper-left, upper-right, lower-right, lower-left. -// If these vectors contain a W, then this function -// will take the reciprocal of that value to pass as -// as the rhw (i.e. reciprocal homogenous w). -// alpha - alpha value to apply to sprite. 1.0 means totally -// opaque; and 0.0 means totally transparent. -// WARNING: If you are using alpha, then you should render -// from back to front in order to avoid rendering -// artifacts.Furthermore, you should avoid scenarios where -// semi-transparent objects intersect. -// pSourceRect - a rect that indicates what portion of the source -// source texture to use. If NULL is passed, then the -// entire source is used. If the source texture was -// created via D3DX, then the rect should be specified -// in the coordinates of the original image (so that you -// don't have to worry about stretching/scaling that D3DX -// may have done to make the image work with your current -// 3D Device.) Note that mirroring may be simply accomplished -// by swapping the left/right or top/bottom fields of -// this RECT. -//------------------------------------------------------------------------- - -#ifdef __cplusplus -HRESULT WINAPI - D3DXDrawSprite3D(LPDIRECTDRAWSURFACE7 pd3dTexture, - LPDIRECT3DDEVICE7 pd3dDevice, - const D3DXVECTOR4 quad[4], - float alpha = 1.0f, - const RECT *pSourceRect = NULL); -#else -HRESULT WINAPI - D3DXDrawSprite3D(LPDIRECTDRAWSURFACE7 pd3dTexture, - LPDIRECT3DDEVICE7 pd3dDevice, - D3DXVECTOR4 quad[4], - float alpha, - RECT *pSourceRect); -#endif - - - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // __D3DXSPRITE_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dxsprite.h +// Content: D3DX sprite helper functions +// +// These functions allow you to use sprites with D3DX. A "sprite" is +// loosely defined as a 2D image that you want to transfer to the +// rendering target. The source image can be a texture created +// with the help of the D3DX texture loader; though advanced users may +// want to create their own. A helper function (PrepareDeviceForSprite) +// is provided to make it easy to set up render states on a device. +// (Again, advanced users can use their own created devices.) +// +// There are two general techniques for sprites; the simpler one just +// specifies a destination rectangle and a rotation anlge. A more +// powerful technique supports rendering to non-rectangular quads. +// +// Both techniques support clipping, alpha, and rotation. More +// details are below. +// +/////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DXSPRITE_H__ +#define __D3DXSPRITE_H__ + +#include +#include +#include "d3dxerr.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +//------------------------------------------------------------------------- +// D3DXPrepareDeviceForSprite: +// +// Call this function to set up all the render states necessary for +// BltSprite/WarpSprite to work correctly. (Advanced users may opt to +// not call this function first; in which case Blt/WarpSprite functions +// will use whatever render/texture states were set up on the device when +// they are called.) +// +// Warning: This function modifies render states and may impact performance +// negatively on some 3D hardware if it is called too often per frame. +// +// Warning: If the render state changes (other than through calls to +// BltSprite or WarpSprite), you will need to call this function again before +// calling BltSprite or WarpSprite. +// +// Details: This function modifies the the rendering first texture stage and +// it modifies some renderstates for the entire device. Here is the exact +// list: +// +// SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); +// SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); +// SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); +// SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); +// SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); +// SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_LINEAR); +// SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_LINEAR); +// +// SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); +// SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); +// SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); +// +// Depending on the value of ZEnable parameter, this function will +// will either call +// SetRenderState(D3DRENDERSTATE_ZENABLE, FALSE); +// - or - +// SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE); +// +// Parameters: +// pd3dDevice - a pointer to the d3d device that you wish to prepare +// for use with D3DX Sprite Services +// ZEnable - a flag indicating whether you want the sprites to +// check and update the Z buffer as part of rendering. +// If ZEnable is FALSE, OR you are using +// alpha-blending, then it is necessary to render your +// sprites from back-to-front. +// +//------------------------------------------------------------------------- + +#ifdef __cplusplus +HRESULT WINAPI + D3DXPrepareDeviceForSprite( LPDIRECT3DDEVICE7 pd3dDevice, + BOOL ZEnable = FALSE); +#else +HRESULT WINAPI + D3DXPrepareDeviceForSprite( LPDIRECT3DDEVICE7 pd3dDevice, + BOOL ZEnable); +#endif + + + +//------------------------------------------------------------------------- +// The D3DXDrawBasicSprite() function performs blitting of source images onto +// a 3D rendering device. This function only calls SetTexture on the first +// renderstage with the parameter (pd3dTexture) if that parameter is non-null. +// This function assumes that D3DXPrepareDeviceForSprite has been called on +// the device or that caller has in some other way correctly prepared the +// renderstates. +// +// This function supports scaling, rotations, alpha-blending, and choosing +// a source sub-rect. +// +// Rotation angle is specified in radians. Both rotations and scales +// are applied around the center of the sprite; where the center of the +// sprite is half the width/height of the sprite, plus the offset parameter. +// +// Use the offset parameter if you want the sprite's center to be something +// other than the image center. +// +// The destination point indicates where you would like the center of +// the sprite to draw to. +// +// Parameters: +// pd3dTexture - a pointer to the surface containing the texture +// pd3dDevice - a pointer to the d3d device to render to. It is +// assumed that render states are set up. (See +// D3DXPrepareDeviceForSprite) +// ppointDest - a pointer to the target point for the sprite. The +// components of the vector must be in screen +// space. +// alpha - alpha value to apply to sprite. 1.0 means totally +// opaque; and 0.0 means totally transparent. +// WARNING: If you are using alpha, then you should render +// from back to front in order to avoid rendering +// artifacts. +// angleRad - angle of rotation around the 'center' of the rect +// scale - a uniform scale that is applied to the source rect +// to specify the size of the image that is rendered +// pOffset - offset from the center of the source rect to use as the +// center of rotation +// pSourceRect - a rect that indicates what portion of the source +// source texture to use. If NULL is passed, then the +// entire source is used. If the source texture was +// created via D3DX, then the rect should be specified +// in the coordinates of the original image (so that you +// don't have to worry about stretching/scaling that D3DX +// may have done to make the image work with your current +// 3D Device.) Note that horizontal or vertical mirroring +// may be simply accomplished by swapping the left/right +// or top/bottom fields of this RECT. +//------------------------------------------------------------------------- + +#ifdef __cplusplus +HRESULT WINAPI + D3DXDrawSpriteSimple(LPDIRECTDRAWSURFACE7 pd3dTexture, + LPDIRECT3DDEVICE7 pd3dDevice, + const D3DXVECTOR3 *ppointDest, + float alpha = 1.0f, + float scale = 1.0f, + float angleRad = 0.0f, + const D3DXVECTOR2 *pOffset = NULL, + const RECT *pSourceRect = NULL); +#else +HRESULT WINAPI + D3DXDrawSpriteSimple(LPDIRECTDRAWSURFACE7 pd3dTexture, + LPDIRECT3DDEVICE7 pd3dDevice, + D3DXVECTOR3 *ppointDest, + float alpha, + float scale, + float angleRad, + D3DXVECTOR2 *pOffset, + RECT *pSourceRect); +#endif + +//------------------------------------------------------------------------- +// The D3DXDrawSprite() function transforms source images onto a 3D +// rendering device. It takes a general 4x4 matrix which is use to transform +// the points of a default rect: (left=-.5, top=-.5, right=+.5, bottom=+.5). +// (This default rect was chosen so that it was centered around the origin +// to ease setting up rotations. And it was chosen to have a width/height of one +// to ease setting up scales.) +// +// This function only calls SetTexture on the first +// renderstage with the parameter (pd3dTexture) if that parameter is non-null. +// This function assumes that D3DXPrepareDeviceForSprite has been called on +// the device or that caller has in some other way correctly prepared the +// renderstates. +// +// This function supports alpha-blending, and choosing +// a source sub-rect. (A value of NULL for source sub-rect means the entire +// texture is used.) +// +// Note that if the transformed points have a value for w (the homogenous +// coordinate) that is not 1, then this function will invert it and pass +// that value to D3D as the rhw field of a TLVERTEX. If the value for w is +// zero, then it use 1 as the rhw. +// +// Parameters: +// pd3dTexture - a pointer to the surface containing the texture +// pd3dDevice - a pointer to the d3d device to render to. It is +// assumed that render states are set up. (See +// D3DXPrepareDeviceForSprite) +// pMatrixTransform - 4x4 matrix that specifies the transformation +// that will be applied to the default -.5 to +.5 +// rectangle. +// alpha - alpha value to apply to sprite. 1.0 means totally +// opaque; and 0.0 means totally transparent. +// WARNING: If you are using alpha, then you should render +// from back to front in order to avoid rendering +// artifacts.Furthermore, you should avoid scenarios where +// semi-transparent objects intersect. +// pSourceRect - a rect that indicates what portion of the source +// source texture to use. If NULL is passed, then the +// entire source is used. If the source texture was +// created via D3DX, then the rect should be specified +// in the coordinates of the original image (so that you +// don't have to worry about stretching/scaling that D3DX +// may have done to make the image work with your current +// 3D Device.) Note that mirroring may be simply accomplished +// by swapping the left/right or top/bottom fields of +// this RECT. +// +//------------------------------------------------------------------------- + +#ifdef __cplusplus +HRESULT WINAPI + D3DXDrawSpriteTransform(LPDIRECTDRAWSURFACE7 pd3dTexture, + LPDIRECT3DDEVICE7 pd3dDevice, + const D3DXMATRIX *pMatrixTransform, + float alpha = 1.0f, + const RECT *pSourceRect = NULL); +#else +HRESULT WINAPI + D3DXDrawSpriteTransform(LPDIRECTDRAWSURFACE7 pd3dTexture, + LPDIRECT3DDEVICE7 pd3dDevice, + D3DXMATRIX *pMatrixTransform, + float alpha, + RECT *pSourceRect); +#endif + +//------------------------------------------------------------------------- +// The D3DXBuildSpriteTransform() function is a helper provided which +// creates a matrix corresponding to simple properties. This matrix is +// set up to pass directly to D3DXTransformSprite. +// +// Parameters: +// pMatrix - a pointer to the result matrix +// prectDest - a pointer to the target rectangle for the sprite +// angleRad - angle of rotation around the 'center' of the rect +// pOffset - offset from the center of the source rect to use as the +// center of rotation +// +//------------------------------------------------------------------------- + +#ifdef __cplusplus +void WINAPI + D3DXBuildSpriteTransform(D3DXMATRIX *pMatrix, + const RECT *prectDest, + float angleRad = 0.0f, + const D3DXVECTOR2 *pOffset = NULL); +#else +void WINAPI + D3DXBuildSpriteTransform(D3DXMATRIX *pMatrix, + RECT *prectDest, + float angleRad, + D3DXVECTOR2 *pOffset); +#endif + + +//------------------------------------------------------------------------- +// The D3DXDrawSprite3D() function renders a texture onto a 3D quad. The +// quad ABCD is broken into two triangles ABC and ACD which are rendered +// via DrawPrim. +// +// Parameters: +// pd3dTexture - a pointer to the surface containing the texture +// pd3dDevice - a pointer to the d3d device to render to. It is +// assumed that render states are set up. (See +// D3DXPrepareDeviceForSprite) +// quad - array of 4 points in the following order: +// upper-left, upper-right, lower-right, lower-left. +// If these vectors contain a W, then this function +// will take the reciprocal of that value to pass as +// as the rhw (i.e. reciprocal homogenous w). +// alpha - alpha value to apply to sprite. 1.0 means totally +// opaque; and 0.0 means totally transparent. +// WARNING: If you are using alpha, then you should render +// from back to front in order to avoid rendering +// artifacts.Furthermore, you should avoid scenarios where +// semi-transparent objects intersect. +// pSourceRect - a rect that indicates what portion of the source +// source texture to use. If NULL is passed, then the +// entire source is used. If the source texture was +// created via D3DX, then the rect should be specified +// in the coordinates of the original image (so that you +// don't have to worry about stretching/scaling that D3DX +// may have done to make the image work with your current +// 3D Device.) Note that mirroring may be simply accomplished +// by swapping the left/right or top/bottom fields of +// this RECT. +//------------------------------------------------------------------------- + +#ifdef __cplusplus +HRESULT WINAPI + D3DXDrawSprite3D(LPDIRECTDRAWSURFACE7 pd3dTexture, + LPDIRECT3DDEVICE7 pd3dDevice, + const D3DXVECTOR4 quad[4], + float alpha = 1.0f, + const RECT *pSourceRect = NULL); +#else +HRESULT WINAPI + D3DXDrawSprite3D(LPDIRECTDRAWSURFACE7 pd3dTexture, + LPDIRECT3DDEVICE7 pd3dDevice, + D3DXVECTOR4 quad[4], + float alpha, + RECT *pSourceRect); +#endif + + + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // __D3DXSPRITE_H__ diff --git a/src/dep/include/DXSDK/include/ddraw.h b/src/dep/include/DXSDK/include/ddraw.h index 0f204f8..e66314b 100644 --- a/src/dep/include/DXSDK/include/ddraw.h +++ b/src/dep/include/DXSDK/include/ddraw.h @@ -1,5792 +1,5792 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: ddraw.h - * Content: DirectDraw include file - * - ***************************************************************************/ - -#ifndef __DDRAW_INCLUDED__ -#define __DDRAW_INCLUDED__ - -//Disable the nameless union warning when building internally -#undef ENABLE_NAMELESS_UNION_PRAGMA -#ifdef DIRECTX_REDIST -#define ENABLE_NAMELESS_UNION_PRAGMA -#endif - -#ifdef ENABLE_NAMELESS_UNION_PRAGMA -#pragma warning(disable:4201) -#endif - -/* - * If you wish an application built against the newest version of DirectDraw - * to run against an older DirectDraw run time then define DIRECTDRAW_VERSION - * to be the earlies version of DirectDraw you wish to run against. For, - * example if you wish an application to run against a DX 3 runtime define - * DIRECTDRAW_VERSION to be 0x0300. - */ -#ifndef DIRECTDRAW_VERSION -#define DIRECTDRAW_VERSION 0x0700 -#endif /* DIRECTDRAW_VERSION */ - -#if defined( _WIN32 ) && !defined( _NO_COM ) -#define COM_NO_WINDOWS_H -#include -#else -#define IUnknown void -#if !defined( NT_BUILD_ENVIRONMENT ) && !defined(WINNT) - #define CO_E_NOTINITIALIZED 0x800401F0L -#endif -#endif - -#define _FACDD 0x876 -#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) - -#ifdef __cplusplus -extern "C" { -#endif - -// -// For compilers that don't support nameless unions, do a -// -// #define NONAMELESSUNION -// -// before #include -// -#ifndef DUMMYUNIONNAMEN -#if defined(__cplusplus) || !defined(NONAMELESSUNION) -#define DUMMYUNIONNAMEN(n) -#else -#define DUMMYUNIONNAMEN(n) u##n -#endif -#endif - -#ifndef MAKEFOURCC - #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ - ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) -#endif //defined(MAKEFOURCC) - -/* - * FOURCC codes for DX compressed-texture pixel formats - */ -#define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1')) -#define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2')) -#define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3')) -#define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4')) -#define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5')) - -/* - * GUIDS used by DirectDraw objects - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) - -DEFINE_GUID( CLSID_DirectDraw, 0xD7B70EE0,0x4340,0x11CF,0xB0,0x63,0x00,0x20,0xAF,0xC2,0xCD,0x35 ); -DEFINE_GUID( CLSID_DirectDraw7, 0x3c305196,0x50db,0x11d3,0x9c,0xfe,0x00,0xc0,0x4f,0xd9,0x30,0xc5 ); -DEFINE_GUID( CLSID_DirectDrawClipper, 0x593817A0,0x7DB3,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xb9,0x33,0x56 ); -DEFINE_GUID( IID_IDirectDraw, 0x6C14DB80,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); -DEFINE_GUID( IID_IDirectDraw2, 0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 ); -DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 ); -DEFINE_GUID( IID_IDirectDraw7, 0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b ); -DEFINE_GUID( IID_IDirectDrawSurface, 0x6C14DB81,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); -DEFINE_GUID( IID_IDirectDrawSurface2, 0x57805885,0x6eec,0x11cf,0x94,0x41,0xa8,0x23,0x03,0xc1,0x0e,0x27 ); -DEFINE_GUID( IID_IDirectDrawSurface3, 0xDA044E00,0x69B2,0x11D0,0xA1,0xD5,0x00,0xAA,0x00,0xB8,0xDF,0xBB ); -DEFINE_GUID( IID_IDirectDrawSurface4, 0x0B2B8630,0xAD35,0x11D0,0x8E,0xA6,0x00,0x60,0x97,0x97,0xEA,0x5B ); -DEFINE_GUID( IID_IDirectDrawSurface7, 0x06675a80,0x3b9b,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b ); -DEFINE_GUID( IID_IDirectDrawPalette, 0x6C14DB84,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); -DEFINE_GUID( IID_IDirectDrawClipper, 0x6C14DB85,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); -DEFINE_GUID( IID_IDirectDrawColorControl, 0x4B9F0EE0,0x0D7E,0x11D0,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8 ); -DEFINE_GUID( IID_IDirectDrawGammaControl, 0x69C11C3E,0xB46B,0x11D1,0xAD,0x7A,0x00,0xC0,0x4F,0xC2,0x9B,0x4E ); - -#endif - -/*============================================================================ - * - * DirectDraw Structures - * - * Various structures used to invoke DirectDraw. - * - *==========================================================================*/ - -struct IDirectDraw; -struct IDirectDrawSurface; -struct IDirectDrawPalette; -struct IDirectDrawClipper; - -typedef struct IDirectDraw FAR *LPDIRECTDRAW; -typedef struct IDirectDraw2 FAR *LPDIRECTDRAW2; -typedef struct IDirectDraw4 FAR *LPDIRECTDRAW4; -typedef struct IDirectDraw7 FAR *LPDIRECTDRAW7; -typedef struct IDirectDrawSurface FAR *LPDIRECTDRAWSURFACE; -typedef struct IDirectDrawSurface2 FAR *LPDIRECTDRAWSURFACE2; -typedef struct IDirectDrawSurface3 FAR *LPDIRECTDRAWSURFACE3; -typedef struct IDirectDrawSurface4 FAR *LPDIRECTDRAWSURFACE4; -typedef struct IDirectDrawSurface7 FAR *LPDIRECTDRAWSURFACE7; -typedef struct IDirectDrawPalette FAR *LPDIRECTDRAWPALETTE; -typedef struct IDirectDrawClipper FAR *LPDIRECTDRAWCLIPPER; -typedef struct IDirectDrawColorControl FAR *LPDIRECTDRAWCOLORCONTROL; -typedef struct IDirectDrawGammaControl FAR *LPDIRECTDRAWGAMMACONTROL; - -typedef struct _DDFXROP FAR *LPDDFXROP; -typedef struct _DDSURFACEDESC FAR *LPDDSURFACEDESC; -typedef struct _DDSURFACEDESC2 FAR *LPDDSURFACEDESC2; -typedef struct _DDCOLORCONTROL FAR *LPDDCOLORCONTROL; - -/* - * API's - */ -#if (defined (WIN32) || defined( _WIN32 ) ) && !defined( _NO_COM ) -//#if defined( _WIN32 ) && !defined( _NO_ENUM ) - typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKA)(GUID FAR *, LPSTR, LPSTR, LPVOID); - typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKW)(GUID FAR *, LPWSTR, LPWSTR, LPVOID); - extern HRESULT WINAPI DirectDrawEnumerateW( LPDDENUMCALLBACKW lpCallback, LPVOID lpContext ); - extern HRESULT WINAPI DirectDrawEnumerateA( LPDDENUMCALLBACKA lpCallback, LPVOID lpContext ); - /* - * Protect against old SDKs - */ - #if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) - #define HMONITOR_DECLARED - DECLARE_HANDLE(HMONITOR); - #endif - typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKEXA)(GUID FAR *, LPSTR, LPSTR, LPVOID, HMONITOR); - typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKEXW)(GUID FAR *, LPWSTR, LPWSTR, LPVOID, HMONITOR); - extern HRESULT WINAPI DirectDrawEnumerateExW( LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags); - extern HRESULT WINAPI DirectDrawEnumerateExA( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags); - typedef HRESULT (WINAPI * LPDIRECTDRAWENUMERATEEXA)( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags); - typedef HRESULT (WINAPI * LPDIRECTDRAWENUMERATEEXW)( LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags); - - #ifdef UNICODE - typedef LPDDENUMCALLBACKW LPDDENUMCALLBACK; - #define DirectDrawEnumerate DirectDrawEnumerateW - typedef LPDDENUMCALLBACKEXW LPDDENUMCALLBACKEX; - typedef LPDIRECTDRAWENUMERATEEXW LPDIRECTDRAWENUMERATEEX; - #define DirectDrawEnumerateEx DirectDrawEnumerateExW - #else - typedef LPDDENUMCALLBACKA LPDDENUMCALLBACK; - #define DirectDrawEnumerate DirectDrawEnumerateA - typedef LPDDENUMCALLBACKEXA LPDDENUMCALLBACKEX; - typedef LPDIRECTDRAWENUMERATEEXA LPDIRECTDRAWENUMERATEEX; - #define DirectDrawEnumerateEx DirectDrawEnumerateExA - #endif - extern HRESULT WINAPI DirectDrawCreate( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter ); - extern HRESULT WINAPI DirectDrawCreateEx( GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid,IUnknown FAR *pUnkOuter ); - extern HRESULT WINAPI DirectDrawCreateClipper( DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter ); -#endif -/* - * Flags for DirectDrawEnumerateEx - * DirectDrawEnumerateEx supercedes DirectDrawEnumerate. You must use GetProcAddress to - * obtain a function pointer (of type LPDIRECTDRAWENUMERATEEX) to DirectDrawEnumerateEx. - * By default, only the primary display device is enumerated. - * DirectDrawEnumerate is equivalent to DirectDrawEnumerate(,,DDENUM_NONDISPLAYDEVICES) - */ - -/* - * This flag causes enumeration of any GDI display devices which are part of - * the Windows Desktop - */ -#define DDENUM_ATTACHEDSECONDARYDEVICES 0x00000001L - -/* - * This flag causes enumeration of any GDI display devices which are not - * part of the Windows Desktop - */ -#define DDENUM_DETACHEDSECONDARYDEVICES 0x00000002L - -/* - * This flag causes enumeration of non-display devices - */ -#define DDENUM_NONDISPLAYDEVICES 0x00000004L - - -#define REGSTR_KEY_DDHW_DESCRIPTION "Description" -#define REGSTR_KEY_DDHW_DRIVERNAME "DriverName" -#define REGSTR_PATH_DDHW "Hardware\\DirectDrawDrivers" - -#define DDCREATE_HARDWAREONLY 0x00000001l -#define DDCREATE_EMULATIONONLY 0x00000002l - -#if defined(WINNT) || !defined(WIN32) -typedef long HRESULT; -#endif - -//#ifndef WINNT -typedef HRESULT (FAR PASCAL * LPDDENUMMODESCALLBACK)(LPDDSURFACEDESC, LPVOID); -typedef HRESULT (FAR PASCAL * LPDDENUMMODESCALLBACK2)(LPDDSURFACEDESC2, LPVOID); -typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK)(LPDIRECTDRAWSURFACE, LPDDSURFACEDESC, LPVOID); -typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK2)(LPDIRECTDRAWSURFACE4, LPDDSURFACEDESC2, LPVOID); -typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK7)(LPDIRECTDRAWSURFACE7, LPDDSURFACEDESC2, LPVOID); -//#endif - -/* - * Generic pixel format with 8-bit RGB and alpha components - */ -typedef struct _DDARGB -{ - BYTE blue; - BYTE green; - BYTE red; - BYTE alpha; -} DDARGB; - -typedef DDARGB FAR *LPDDARGB; - -/* - * This version of the structure remains for backwards source compatibility. - * The DDARGB structure is the one that should be used for all DirectDraw APIs. - */ -typedef struct _DDRGBA -{ - BYTE red; - BYTE green; - BYTE blue; - BYTE alpha; -} DDRGBA; - -typedef DDRGBA FAR *LPDDRGBA; - - -/* - * DDCOLORKEY - */ -typedef struct _DDCOLORKEY -{ - DWORD dwColorSpaceLowValue; // low boundary of color space that is to - // be treated as Color Key, inclusive - DWORD dwColorSpaceHighValue; // high boundary of color space that is - // to be treated as Color Key, inclusive -} DDCOLORKEY; - -typedef DDCOLORKEY FAR* LPDDCOLORKEY; - -/* - * DDBLTFX - * Used to pass override information to the DIRECTDRAWSURFACE callback Blt. - */ -typedef struct _DDBLTFX -{ - DWORD dwSize; // size of structure - DWORD dwDDFX; // FX operations - DWORD dwROP; // Win32 raster operations - DWORD dwDDROP; // Raster operations new for DirectDraw - DWORD dwRotationAngle; // Rotation angle for blt - DWORD dwZBufferOpCode; // ZBuffer compares - DWORD dwZBufferLow; // Low limit of Z buffer - DWORD dwZBufferHigh; // High limit of Z buffer - DWORD dwZBufferBaseDest; // Destination base value - DWORD dwZDestConstBitDepth; // Bit depth used to specify Z constant for destination - union - { - DWORD dwZDestConst; // Constant to use as Z buffer for dest - LPDIRECTDRAWSURFACE lpDDSZBufferDest; // Surface to use as Z buffer for dest - } DUMMYUNIONNAMEN(1); - DWORD dwZSrcConstBitDepth; // Bit depth used to specify Z constant for source - union - { - DWORD dwZSrcConst; // Constant to use as Z buffer for src - LPDIRECTDRAWSURFACE lpDDSZBufferSrc; // Surface to use as Z buffer for src - } DUMMYUNIONNAMEN(2); - DWORD dwAlphaEdgeBlendBitDepth; // Bit depth used to specify constant for alpha edge blend - DWORD dwAlphaEdgeBlend; // Alpha for edge blending - DWORD dwReserved; - DWORD dwAlphaDestConstBitDepth; // Bit depth used to specify alpha constant for destination - union - { - DWORD dwAlphaDestConst; // Constant to use as Alpha Channel - LPDIRECTDRAWSURFACE lpDDSAlphaDest; // Surface to use as Alpha Channel - } DUMMYUNIONNAMEN(3); - DWORD dwAlphaSrcConstBitDepth; // Bit depth used to specify alpha constant for source - union - { - DWORD dwAlphaSrcConst; // Constant to use as Alpha Channel - LPDIRECTDRAWSURFACE lpDDSAlphaSrc; // Surface to use as Alpha Channel - } DUMMYUNIONNAMEN(4); - union - { - DWORD dwFillColor; // color in RGB or Palettized - DWORD dwFillDepth; // depth value for z-buffer - DWORD dwFillPixel; // pixel value for RGBA or RGBZ - LPDIRECTDRAWSURFACE lpDDSPattern; // Surface to use as pattern - } DUMMYUNIONNAMEN(5); - DDCOLORKEY ddckDestColorkey; // DestColorkey override - DDCOLORKEY ddckSrcColorkey; // SrcColorkey override -} DDBLTFX; - -typedef DDBLTFX FAR* LPDDBLTFX; - - - -/* - * DDSCAPS - */ -typedef struct _DDSCAPS -{ - DWORD dwCaps; // capabilities of surface wanted -} DDSCAPS; - -typedef DDSCAPS FAR* LPDDSCAPS; - - -/* - * DDOSCAPS - */ -typedef struct _DDOSCAPS -{ - DWORD dwCaps; // capabilities of surface wanted -} DDOSCAPS; - -typedef DDOSCAPS FAR* LPDDOSCAPS; - -/* - * This structure is used internally by DirectDraw. - */ -typedef struct _DDSCAPSEX -{ - DWORD dwCaps2; - DWORD dwCaps3; - union - { - DWORD dwCaps4; - DWORD dwVolumeDepth; - } DUMMYUNIONNAMEN(1); -} DDSCAPSEX, FAR * LPDDSCAPSEX; - -/* - * DDSCAPS2 - */ -typedef struct _DDSCAPS2 -{ - DWORD dwCaps; // capabilities of surface wanted - DWORD dwCaps2; - DWORD dwCaps3; - union - { - DWORD dwCaps4; - DWORD dwVolumeDepth; - } DUMMYUNIONNAMEN(1); -} DDSCAPS2; - -typedef DDSCAPS2 FAR* LPDDSCAPS2; - -/* - * DDCAPS - */ -#define DD_ROP_SPACE (256/32) // space required to store ROP array -/* - * NOTE: Our choosen structure number scheme is to append a single digit to - * the end of the structure giving the version that structure is associated - * with. - */ - -/* - * This structure represents the DDCAPS structure released in DirectDraw 1.0. It is used internally - * by DirectDraw to interpret caps passed into ddraw by drivers written prior to the release of DirectDraw 2.0. - * New applications should use the DDCAPS structure defined below. - */ -typedef struct _DDCAPS_DX1 -{ - DWORD dwSize; // size of the DDDRIVERCAPS structure - DWORD dwCaps; // driver specific capabilities - DWORD dwCaps2; // more driver specific capabilites - DWORD dwCKeyCaps; // color key capabilities of the surface - DWORD dwFXCaps; // driver specific stretching and effects capabilites - DWORD dwFXAlphaCaps; // alpha driver specific capabilities - DWORD dwPalCaps; // palette capabilities - DWORD dwSVCaps; // stereo vision capabilities - DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 - DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 - DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 - DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 - DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 - DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 - DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 - DWORD dwVidMemTotal; // total amount of video memory - DWORD dwVidMemFree; // amount of free video memory - DWORD dwMaxVisibleOverlays; // maximum number of visible overlays - DWORD dwCurrVisibleOverlays; // current number of visible overlays - DWORD dwNumFourCCCodes; // number of four cc codes - DWORD dwAlignBoundarySrc; // source rectangle alignment - DWORD dwAlignSizeSrc; // source rectangle byte size - DWORD dwAlignBoundaryDest; // dest rectangle alignment - DWORD dwAlignSizeDest; // dest rectangle byte size - DWORD dwAlignStrideAlign; // stride alignment - DWORD dwRops[DD_ROP_SPACE]; // ROPS supported - DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities - DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwMinLiveVideoStretch; // OBSOLETE! This field remains for compatability reasons only - DWORD dwMaxLiveVideoStretch; // OBSOLETE! This field remains for compatability reasons only - DWORD dwMinHwCodecStretch; // OBSOLETE! This field remains for compatability reasons only - DWORD dwMaxHwCodecStretch; // OBSOLETE! This field remains for compatability reasons only - DWORD dwReserved1; // reserved - DWORD dwReserved2; // reserved - DWORD dwReserved3; // reserved -} DDCAPS_DX1; - -typedef DDCAPS_DX1 FAR* LPDDCAPS_DX1; - -/* - * This structure is the DDCAPS structure as it was in version 2 and 3 of Direct X. - * It is present for back compatability. - */ -typedef struct _DDCAPS_DX3 -{ - DWORD dwSize; // size of the DDDRIVERCAPS structure - DWORD dwCaps; // driver specific capabilities - DWORD dwCaps2; // more driver specific capabilites - DWORD dwCKeyCaps; // color key capabilities of the surface - DWORD dwFXCaps; // driver specific stretching and effects capabilites - DWORD dwFXAlphaCaps; // alpha driver specific capabilities - DWORD dwPalCaps; // palette capabilities - DWORD dwSVCaps; // stereo vision capabilities - DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 - DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 - DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 - DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 - DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 - DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 - DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 - DWORD dwVidMemTotal; // total amount of video memory - DWORD dwVidMemFree; // amount of free video memory - DWORD dwMaxVisibleOverlays; // maximum number of visible overlays - DWORD dwCurrVisibleOverlays; // current number of visible overlays - DWORD dwNumFourCCCodes; // number of four cc codes - DWORD dwAlignBoundarySrc; // source rectangle alignment - DWORD dwAlignSizeSrc; // source rectangle byte size - DWORD dwAlignBoundaryDest; // dest rectangle alignment - DWORD dwAlignSizeDest; // dest rectangle byte size - DWORD dwAlignStrideAlign; // stride alignment - DWORD dwRops[DD_ROP_SPACE]; // ROPS supported - DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities - DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwReserved1; // reserved - DWORD dwReserved2; // reserved - DWORD dwReserved3; // reserved - DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts - DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts - DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts - DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts - DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts - DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts - DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts - DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts - DWORD dwSSBCaps; // driver specific capabilities for System->System blts - DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts - DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts - DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts - DWORD dwReserved4; // reserved - DWORD dwReserved5; // reserved - DWORD dwReserved6; // reserved -} DDCAPS_DX3; -typedef DDCAPS_DX3 FAR* LPDDCAPS_DX3; - -/* - * This structure is the DDCAPS structure as it was in version 5 of Direct X. - * It is present for back compatability. - */ -typedef struct _DDCAPS_DX5 -{ -/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure -/* 4*/ DWORD dwCaps; // driver specific capabilities -/* 8*/ DWORD dwCaps2; // more driver specific capabilites -/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface -/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites -/* 14*/ DWORD dwFXAlphaCaps; // alpha driver specific capabilities -/* 18*/ DWORD dwPalCaps; // palette capabilities -/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities -/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 -/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 -/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 -/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 -/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 -/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 -/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 -/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory -/* 40*/ DWORD dwVidMemFree; // amount of free video memory -/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays -/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays -/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes -/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment -/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size -/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment -/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size -/* 60*/ DWORD dwAlignStrideAlign; // stride alignment -/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported -/* 84*/ DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities -/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* a0*/ DWORD dwReserved1; // reserved -/* a4*/ DWORD dwReserved2; // reserved -/* a8*/ DWORD dwReserved3; // reserved -/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts -/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts -/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts -/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts -/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts -/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts -/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts -/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts -/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts -/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts -/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts -/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts -// Members added for DX5: -/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports -/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used -/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts -/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts -/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts -/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts -/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts -/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts -} DDCAPS_DX5; -typedef DDCAPS_DX5 FAR* LPDDCAPS_DX5; - -typedef struct _DDCAPS_DX6 -{ -/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure -/* 4*/ DWORD dwCaps; // driver specific capabilities -/* 8*/ DWORD dwCaps2; // more driver specific capabilites -/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface -/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites -/* 14*/ DWORD dwFXAlphaCaps; // alpha caps -/* 18*/ DWORD dwPalCaps; // palette capabilities -/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities -/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 -/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 -/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 -/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 -/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 -/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 -/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 -/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory -/* 40*/ DWORD dwVidMemFree; // amount of free video memory -/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays -/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays -/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes -/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment -/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size -/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment -/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size -/* 60*/ DWORD dwAlignStrideAlign; // stride alignment -/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported -/* 84*/ DDSCAPS ddsOldCaps; // Was DDSCAPS ddsCaps. ddsCaps is of type DDSCAPS2 for DX6 -/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* a0*/ DWORD dwReserved1; // reserved -/* a4*/ DWORD dwReserved2; // reserved -/* a8*/ DWORD dwReserved3; // reserved -/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts -/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts -/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts -/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts -/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts -/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts -/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts -/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts -/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts -/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts -/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts -/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts -/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports -/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used -/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts -/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts -/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts -/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts -/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts -/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts -// Members added for DX6 release -/*16c*/ DDSCAPS2 ddsCaps; // Surface Caps -} DDCAPS_DX6; -typedef DDCAPS_DX6 FAR* LPDDCAPS_DX6; - -typedef struct _DDCAPS_DX7 -{ -/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure -/* 4*/ DWORD dwCaps; // driver specific capabilities -/* 8*/ DWORD dwCaps2; // more driver specific capabilites -/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface -/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites -/* 14*/ DWORD dwFXAlphaCaps; // alpha driver specific capabilities -/* 18*/ DWORD dwPalCaps; // palette capabilities -/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities -/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 -/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 -/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 -/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 -/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 -/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 -/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 -/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory -/* 40*/ DWORD dwVidMemFree; // amount of free video memory -/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays -/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays -/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes -/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment -/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size -/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment -/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size -/* 60*/ DWORD dwAlignStrideAlign; // stride alignment -/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported -/* 84*/ DDSCAPS ddsOldCaps; // Was DDSCAPS ddsCaps. ddsCaps is of type DDSCAPS2 for DX6 -/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* a0*/ DWORD dwReserved1; // reserved -/* a4*/ DWORD dwReserved2; // reserved -/* a8*/ DWORD dwReserved3; // reserved -/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts -/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts -/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts -/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts -/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts -/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts -/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts -/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts -/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts -/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts -/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts -/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts -/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports -/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used -/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts -/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts -/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts -/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts -/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts -/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts -// Members added for DX6 release -/*16c*/ DDSCAPS2 ddsCaps; // Surface Caps -} DDCAPS_DX7; -typedef DDCAPS_DX7 FAR* LPDDCAPS_DX7; - - -#if DIRECTDRAW_VERSION <= 0x300 - typedef DDCAPS_DX3 DDCAPS; -#elif DIRECTDRAW_VERSION <= 0x500 - typedef DDCAPS_DX5 DDCAPS; -#elif DIRECTDRAW_VERSION <= 0x600 - typedef DDCAPS_DX6 DDCAPS; -#else - typedef DDCAPS_DX7 DDCAPS; -#endif - -typedef DDCAPS FAR* LPDDCAPS; - - - -/* - * DDPIXELFORMAT - */ -typedef struct _DDPIXELFORMAT -{ - DWORD dwSize; // size of structure - DWORD dwFlags; // pixel format flags - DWORD dwFourCC; // (FOURCC code) - union - { - DWORD dwRGBBitCount; // how many bits per pixel - DWORD dwYUVBitCount; // how many bits per pixel - DWORD dwZBufferBitDepth; // how many total bits/pixel in z buffer (including any stencil bits) - DWORD dwAlphaBitDepth; // how many bits for alpha channels - DWORD dwLuminanceBitCount; // how many bits per pixel - DWORD dwBumpBitCount; // how many bits per "buxel", total - DWORD dwPrivateFormatBitCount;// Bits per pixel of private driver formats. Only valid in texture - // format list and if DDPF_D3DFORMAT is set - } DUMMYUNIONNAMEN(1); - union - { - DWORD dwRBitMask; // mask for red bit - DWORD dwYBitMask; // mask for Y bits - DWORD dwStencilBitDepth; // how many stencil bits (note: dwZBufferBitDepth-dwStencilBitDepth is total Z-only bits) - DWORD dwLuminanceBitMask; // mask for luminance bits - DWORD dwBumpDuBitMask; // mask for bump map U delta bits - DWORD dwOperations; // DDPF_D3DFORMAT Operations - } DUMMYUNIONNAMEN(2); - union - { - DWORD dwGBitMask; // mask for green bits - DWORD dwUBitMask; // mask for U bits - DWORD dwZBitMask; // mask for Z bits - DWORD dwBumpDvBitMask; // mask for bump map V delta bits - struct - { - WORD wFlipMSTypes; // Multisample methods supported via flip for this D3DFORMAT - WORD wBltMSTypes; // Multisample methods supported via blt for this D3DFORMAT - } MultiSampleCaps; - - } DUMMYUNIONNAMEN(3); - union - { - DWORD dwBBitMask; // mask for blue bits - DWORD dwVBitMask; // mask for V bits - DWORD dwStencilBitMask; // mask for stencil bits - DWORD dwBumpLuminanceBitMask; // mask for luminance in bump map - } DUMMYUNIONNAMEN(4); - union - { - DWORD dwRGBAlphaBitMask; // mask for alpha channel - DWORD dwYUVAlphaBitMask; // mask for alpha channel - DWORD dwLuminanceAlphaBitMask;// mask for alpha channel - DWORD dwRGBZBitMask; // mask for Z channel - DWORD dwYUVZBitMask; // mask for Z channel - } DUMMYUNIONNAMEN(5); -} DDPIXELFORMAT; - -typedef DDPIXELFORMAT FAR* LPDDPIXELFORMAT; - -/* - * DDOVERLAYFX - */ -typedef struct _DDOVERLAYFX -{ - DWORD dwSize; // size of structure - DWORD dwAlphaEdgeBlendBitDepth; // Bit depth used to specify constant for alpha edge blend - DWORD dwAlphaEdgeBlend; // Constant to use as alpha for edge blend - DWORD dwReserved; - DWORD dwAlphaDestConstBitDepth; // Bit depth used to specify alpha constant for destination - union - { - DWORD dwAlphaDestConst; // Constant to use as alpha channel for dest - LPDIRECTDRAWSURFACE lpDDSAlphaDest; // Surface to use as alpha channel for dest - } DUMMYUNIONNAMEN(1); - DWORD dwAlphaSrcConstBitDepth; // Bit depth used to specify alpha constant for source - union - { - DWORD dwAlphaSrcConst; // Constant to use as alpha channel for src - LPDIRECTDRAWSURFACE lpDDSAlphaSrc; // Surface to use as alpha channel for src - } DUMMYUNIONNAMEN(2); - DDCOLORKEY dckDestColorkey; // DestColorkey override - DDCOLORKEY dckSrcColorkey; // DestColorkey override - DWORD dwDDFX; // Overlay FX - DWORD dwFlags; // flags -} DDOVERLAYFX; - -typedef DDOVERLAYFX FAR *LPDDOVERLAYFX; - - -/* - * DDBLTBATCH: BltBatch entry structure - */ -typedef struct _DDBLTBATCH -{ - LPRECT lprDest; - LPDIRECTDRAWSURFACE lpDDSSrc; - LPRECT lprSrc; - DWORD dwFlags; - LPDDBLTFX lpDDBltFx; -} DDBLTBATCH; - -typedef DDBLTBATCH FAR * LPDDBLTBATCH; - - -/* - * DDGAMMARAMP - */ -typedef struct _DDGAMMARAMP -{ - WORD red[256]; - WORD green[256]; - WORD blue[256]; -} DDGAMMARAMP; -typedef DDGAMMARAMP FAR * LPDDGAMMARAMP; - -/* - * This is the structure within which DirectDraw returns data about the current graphics driver and chipset - */ - -#define MAX_DDDEVICEID_STRING 512 - -typedef struct tagDDDEVICEIDENTIFIER -{ - /* - * These elements are for presentation to the user only. They should not be used to identify particular - * drivers, since this is unreliable and many different strings may be associated with the same - * device, and the same driver from different vendors. - */ - char szDriver[MAX_DDDEVICEID_STRING]; - char szDescription[MAX_DDDEVICEID_STRING]; - - /* - * This element is the version of the DirectDraw/3D driver. It is legal to do <, > comparisons - * on the whole 64 bits. Caution should be exercised if you use this element to identify problematic - * drivers. It is recommended that guidDeviceIdentifier is used for this purpose. - * - * This version has the form: - * wProduct = HIWORD(liDriverVersion.HighPart) - * wVersion = LOWORD(liDriverVersion.HighPart) - * wSubVersion = HIWORD(liDriverVersion.LowPart) - * wBuild = LOWORD(liDriverVersion.LowPart) - */ -#ifdef _WIN32 - LARGE_INTEGER liDriverVersion; /* Defined for applications and other 32 bit components */ -#else - DWORD dwDriverVersionLowPart; /* Defined for 16 bit driver components */ - DWORD dwDriverVersionHighPart; -#endif - - - /* - * These elements can be used to identify particular chipsets. Use with extreme caution. - * dwVendorId Identifies the manufacturer. May be zero if unknown. - * dwDeviceId Identifies the type of chipset. May be zero if unknown. - * dwSubSysId Identifies the subsystem, typically this means the particular board. May be zero if unknown. - * dwRevision Identifies the revision level of the chipset. May be zero if unknown. - */ - DWORD dwVendorId; - DWORD dwDeviceId; - DWORD dwSubSysId; - DWORD dwRevision; - - /* - * This element can be used to check changes in driver/chipset. This GUID is a unique identifier for the - * driver/chipset pair. Use this element if you wish to track changes to the driver/chipset in order to - * reprofile the graphics subsystem. - * This element can also be used to identify particular problematic drivers. - */ - GUID guidDeviceIdentifier; -} DDDEVICEIDENTIFIER, * LPDDDEVICEIDENTIFIER; - -typedef struct tagDDDEVICEIDENTIFIER2 -{ - /* - * These elements are for presentation to the user only. They should not be used to identify particular - * drivers, since this is unreliable and many different strings may be associated with the same - * device, and the same driver from different vendors. - */ - char szDriver[MAX_DDDEVICEID_STRING]; - char szDescription[MAX_DDDEVICEID_STRING]; - - /* - * This element is the version of the DirectDraw/3D driver. It is legal to do <, > comparisons - * on the whole 64 bits. Caution should be exercised if you use this element to identify problematic - * drivers. It is recommended that guidDeviceIdentifier is used for this purpose. - * - * This version has the form: - * wProduct = HIWORD(liDriverVersion.HighPart) - * wVersion = LOWORD(liDriverVersion.HighPart) - * wSubVersion = HIWORD(liDriverVersion.LowPart) - * wBuild = LOWORD(liDriverVersion.LowPart) - */ -#ifdef _WIN32 - LARGE_INTEGER liDriverVersion; /* Defined for applications and other 32 bit components */ -#else - DWORD dwDriverVersionLowPart; /* Defined for 16 bit driver components */ - DWORD dwDriverVersionHighPart; -#endif - - - /* - * These elements can be used to identify particular chipsets. Use with extreme caution. - * dwVendorId Identifies the manufacturer. May be zero if unknown. - * dwDeviceId Identifies the type of chipset. May be zero if unknown. - * dwSubSysId Identifies the subsystem, typically this means the particular board. May be zero if unknown. - * dwRevision Identifies the revision level of the chipset. May be zero if unknown. - */ - DWORD dwVendorId; - DWORD dwDeviceId; - DWORD dwSubSysId; - DWORD dwRevision; - - /* - * This element can be used to check changes in driver/chipset. This GUID is a unique identifier for the - * driver/chipset pair. Use this element if you wish to track changes to the driver/chipset in order to - * reprofile the graphics subsystem. - * This element can also be used to identify particular problematic drivers. - */ - GUID guidDeviceIdentifier; - - /* - * This element is used to determine the Windows Hardware Quality Lab (WHQL) - * certification level for this driver/device pair. - */ - DWORD dwWHQLLevel; - -} DDDEVICEIDENTIFIER2, * LPDDDEVICEIDENTIFIER2; - -/* - * Flags for the IDirectDraw4::GetDeviceIdentifier method - */ - -/* - * This flag causes GetDeviceIdentifier to return information about the host (typically 2D) adapter in a system equipped - * with a stacked secondary 3D adapter. Such an adapter appears to the application as if it were part of the - * host adapter, but is typically physcially located on a separate card. The stacked secondary's information is - * returned when GetDeviceIdentifier's dwFlags field is zero, since this most accurately reflects the qualities - * of the DirectDraw object involved. - */ -#define DDGDI_GETHOSTIDENTIFIER 0x00000001L - -/* - * Macros for interpretting DDEVICEIDENTIFIER2.dwWHQLLevel - */ -#define GET_WHQL_YEAR( dwWHQLLevel ) \ - ( (dwWHQLLevel) / 0x10000 ) -#define GET_WHQL_MONTH( dwWHQLLevel ) \ - ( ( (dwWHQLLevel) / 0x100 ) & 0x00ff ) -#define GET_WHQL_DAY( dwWHQLLevel ) \ - ( (dwWHQLLevel) & 0xff ) - - -/* - * callbacks - */ -typedef DWORD (FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper, HWND hWnd, DWORD code, LPVOID lpContext ); -#ifdef STREAMING -typedef DWORD (FAR PASCAL *LPSURFACESTREAMINGCALLBACK)(DWORD); -#endif - - -/* - * INTERACES FOLLOW: - * IDirectDraw - * IDirectDrawClipper - * IDirectDrawPalette - * IDirectDrawSurface - */ - -/* - * IDirectDraw - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDraw -DECLARE_INTERFACE_( IDirectDraw, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDraw methods ***/ - STDMETHOD(Compact)(THIS) PURE; - STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *) PURE; - STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE FAR * ) PURE; - STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK ) PURE; - STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK ) PURE; - STDMETHOD(FlipToGDISurface)(THIS) PURE; - STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; - STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC) PURE; - STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; - STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE FAR *) PURE; - STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; - STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; - STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; - STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; - STDMETHOD(RestoreDisplayMode)(THIS) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; - STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD) PURE; - STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDraw_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDraw_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDraw_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDraw_Compact(p) (p)->lpVtbl->Compact(p) -#define IDirectDraw_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) -#define IDirectDraw_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) -#define IDirectDraw_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) -#define IDirectDraw_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) -#define IDirectDraw_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) -#define IDirectDraw_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) -#define IDirectDraw_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) -#define IDirectDraw_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) -#define IDirectDraw_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) -#define IDirectDraw_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) -#define IDirectDraw_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) -#define IDirectDraw_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) -#define IDirectDraw_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) -#define IDirectDraw_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) -#define IDirectDraw_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) -#define IDirectDraw_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) -#define IDirectDraw_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) -#define IDirectDraw_SetDisplayMode(p, a, b, c) (p)->lpVtbl->SetDisplayMode(p, a, b, c) -#define IDirectDraw_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) -#else -#define IDirectDraw_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDraw_AddRef(p) (p)->AddRef() -#define IDirectDraw_Release(p) (p)->Release() -#define IDirectDraw_Compact(p) (p)->Compact() -#define IDirectDraw_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) -#define IDirectDraw_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) -#define IDirectDraw_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) -#define IDirectDraw_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) -#define IDirectDraw_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) -#define IDirectDraw_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) -#define IDirectDraw_FlipToGDISurface(p) (p)->FlipToGDISurface() -#define IDirectDraw_GetCaps(p, a, b) (p)->GetCaps(a, b) -#define IDirectDraw_GetDisplayMode(p, a) (p)->GetDisplayMode(a) -#define IDirectDraw_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) -#define IDirectDraw_GetGDISurface(p, a) (p)->GetGDISurface(a) -#define IDirectDraw_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) -#define IDirectDraw_GetScanLine(p, a) (p)->GetScanLine(a) -#define IDirectDraw_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) -#define IDirectDraw_Initialize(p, a) (p)->Initialize(a) -#define IDirectDraw_RestoreDisplayMode(p) (p)->RestoreDisplayMode() -#define IDirectDraw_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) -#define IDirectDraw_SetDisplayMode(p, a, b, c) (p)->SetDisplayMode(a, b, c) -#define IDirectDraw_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) -#endif - -#endif - -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDraw2 -DECLARE_INTERFACE_( IDirectDraw2, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDraw methods ***/ - STDMETHOD(Compact)(THIS) PURE; - STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *) PURE; - STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE FAR * ) PURE; - STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK ) PURE; - STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK ) PURE; - STDMETHOD(FlipToGDISurface)(THIS) PURE; - STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; - STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC) PURE; - STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; - STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE FAR *) PURE; - STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; - STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; - STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; - STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; - STDMETHOD(RestoreDisplayMode)(THIS) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; - STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; - STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; - /*** Added in the v2 interface ***/ - STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS, LPDWORD, LPDWORD) PURE; -}; -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDraw2_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDraw2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDraw2_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDraw2_Compact(p) (p)->lpVtbl->Compact(p) -#define IDirectDraw2_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) -#define IDirectDraw2_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) -#define IDirectDraw2_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) -#define IDirectDraw2_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) -#define IDirectDraw2_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) -#define IDirectDraw2_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) -#define IDirectDraw2_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) -#define IDirectDraw2_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) -#define IDirectDraw2_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) -#define IDirectDraw2_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) -#define IDirectDraw2_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) -#define IDirectDraw2_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) -#define IDirectDraw2_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) -#define IDirectDraw2_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) -#define IDirectDraw2_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) -#define IDirectDraw2_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) -#define IDirectDraw2_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) -#define IDirectDraw2_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) -#define IDirectDraw2_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) -#define IDirectDraw2_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) -#else -#define IDirectDraw2_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDraw2_AddRef(p) (p)->AddRef() -#define IDirectDraw2_Release(p) (p)->Release() -#define IDirectDraw2_Compact(p) (p)->Compact() -#define IDirectDraw2_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) -#define IDirectDraw2_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) -#define IDirectDraw2_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) -#define IDirectDraw2_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) -#define IDirectDraw2_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) -#define IDirectDraw2_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) -#define IDirectDraw2_FlipToGDISurface(p) (p)->FlipToGDISurface() -#define IDirectDraw2_GetCaps(p, a, b) (p)->GetCaps(a, b) -#define IDirectDraw2_GetDisplayMode(p, a) (p)->GetDisplayMode(a) -#define IDirectDraw2_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) -#define IDirectDraw2_GetGDISurface(p, a) (p)->GetGDISurface(a) -#define IDirectDraw2_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) -#define IDirectDraw2_GetScanLine(p, a) (p)->GetScanLine(a) -#define IDirectDraw2_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) -#define IDirectDraw2_Initialize(p, a) (p)->Initialize(a) -#define IDirectDraw2_RestoreDisplayMode(p) (p)->RestoreDisplayMode() -#define IDirectDraw2_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) -#define IDirectDraw2_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) -#define IDirectDraw2_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) -#define IDirectDraw2_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) -#endif - -#endif - -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDraw4 -DECLARE_INTERFACE_( IDirectDraw4, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDraw methods ***/ - STDMETHOD(Compact)(THIS) PURE; - STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC2, LPDIRECTDRAWSURFACE4 FAR *, IUnknown FAR *) PURE; - STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE4, LPDIRECTDRAWSURFACE4 FAR * ) PURE; - STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC2, LPVOID, LPDDENUMMODESCALLBACK2 ) PURE; - STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC2, LPVOID,LPDDENUMSURFACESCALLBACK2 ) PURE; - STDMETHOD(FlipToGDISurface)(THIS) PURE; - STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; - STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC2) PURE; - STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; - STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE4 FAR *) PURE; - STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; - STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; - STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; - STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; - STDMETHOD(RestoreDisplayMode)(THIS) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; - STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; - STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; - /*** Added in the v2 interface ***/ - STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS2, LPDWORD, LPDWORD) PURE; - /*** Added in the V4 Interface ***/ - STDMETHOD(GetSurfaceFromDC) (THIS_ HDC, LPDIRECTDRAWSURFACE4 *) PURE; - STDMETHOD(RestoreAllSurfaces)(THIS) PURE; - STDMETHOD(TestCooperativeLevel)(THIS) PURE; - STDMETHOD(GetDeviceIdentifier)(THIS_ LPDDDEVICEIDENTIFIER, DWORD ) PURE; -}; -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDraw4_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDraw4_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDraw4_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDraw4_Compact(p) (p)->lpVtbl->Compact(p) -#define IDirectDraw4_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) -#define IDirectDraw4_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) -#define IDirectDraw4_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) -#define IDirectDraw4_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) -#define IDirectDraw4_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) -#define IDirectDraw4_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) -#define IDirectDraw4_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) -#define IDirectDraw4_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) -#define IDirectDraw4_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) -#define IDirectDraw4_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) -#define IDirectDraw4_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) -#define IDirectDraw4_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) -#define IDirectDraw4_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) -#define IDirectDraw4_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) -#define IDirectDraw4_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) -#define IDirectDraw4_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) -#define IDirectDraw4_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) -#define IDirectDraw4_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) -#define IDirectDraw4_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) -#define IDirectDraw4_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) -#define IDirectDraw4_GetSurfaceFromDC(p, a, b) (p)->lpVtbl->GetSurfaceFromDC(p, a, b) -#define IDirectDraw4_RestoreAllSurfaces(p) (p)->lpVtbl->RestoreAllSurfaces(p) -#define IDirectDraw4_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) -#define IDirectDraw4_GetDeviceIdentifier(p,a,b) (p)->lpVtbl->GetDeviceIdentifier(p,a,b) -#else -#define IDirectDraw4_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDraw4_AddRef(p) (p)->AddRef() -#define IDirectDraw4_Release(p) (p)->Release() -#define IDirectDraw4_Compact(p) (p)->Compact() -#define IDirectDraw4_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) -#define IDirectDraw4_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) -#define IDirectDraw4_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) -#define IDirectDraw4_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) -#define IDirectDraw4_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) -#define IDirectDraw4_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) -#define IDirectDraw4_FlipToGDISurface(p) (p)->FlipToGDISurface() -#define IDirectDraw4_GetCaps(p, a, b) (p)->GetCaps(a, b) -#define IDirectDraw4_GetDisplayMode(p, a) (p)->GetDisplayMode(a) -#define IDirectDraw4_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) -#define IDirectDraw4_GetGDISurface(p, a) (p)->GetGDISurface(a) -#define IDirectDraw4_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) -#define IDirectDraw4_GetScanLine(p, a) (p)->GetScanLine(a) -#define IDirectDraw4_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) -#define IDirectDraw4_Initialize(p, a) (p)->Initialize(a) -#define IDirectDraw4_RestoreDisplayMode(p) (p)->RestoreDisplayMode() -#define IDirectDraw4_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) -#define IDirectDraw4_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) -#define IDirectDraw4_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) -#define IDirectDraw4_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) -#define IDirectDraw4_GetSurfaceFromDC(p, a, b) (p)->GetSurfaceFromDC(a, b) -#define IDirectDraw4_RestoreAllSurfaces(p) (p)->RestoreAllSurfaces() -#define IDirectDraw4_TestCooperativeLevel(p) (p)->TestCooperativeLevel() -#define IDirectDraw4_GetDeviceIdentifier(p,a,b) (p)->GetDeviceIdentifier(a,b) -#endif - -#endif - -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDraw7 -DECLARE_INTERFACE_( IDirectDraw7, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDraw methods ***/ - STDMETHOD(Compact)(THIS) PURE; - STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC2, LPDIRECTDRAWSURFACE7 FAR *, IUnknown FAR *) PURE; - STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE7, LPDIRECTDRAWSURFACE7 FAR * ) PURE; - STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC2, LPVOID, LPDDENUMMODESCALLBACK2 ) PURE; - STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC2, LPVOID,LPDDENUMSURFACESCALLBACK7 ) PURE; - STDMETHOD(FlipToGDISurface)(THIS) PURE; - STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; - STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC2) PURE; - STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; - STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE7 FAR *) PURE; - STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; - STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; - STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; - STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; - STDMETHOD(RestoreDisplayMode)(THIS) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; - STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; - STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; - /*** Added in the v2 interface ***/ - STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS2, LPDWORD, LPDWORD) PURE; - /*** Added in the V4 Interface ***/ - STDMETHOD(GetSurfaceFromDC) (THIS_ HDC, LPDIRECTDRAWSURFACE7 *) PURE; - STDMETHOD(RestoreAllSurfaces)(THIS) PURE; - STDMETHOD(TestCooperativeLevel)(THIS) PURE; - STDMETHOD(GetDeviceIdentifier)(THIS_ LPDDDEVICEIDENTIFIER2, DWORD ) PURE; - STDMETHOD(StartModeTest)(THIS_ LPSIZE, DWORD, DWORD ) PURE; - STDMETHOD(EvaluateMode)(THIS_ DWORD, DWORD * ) PURE; -}; -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDraw7_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDraw7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDraw7_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDraw7_Compact(p) (p)->lpVtbl->Compact(p) -#define IDirectDraw7_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) -#define IDirectDraw7_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) -#define IDirectDraw7_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) -#define IDirectDraw7_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) -#define IDirectDraw7_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) -#define IDirectDraw7_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) -#define IDirectDraw7_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) -#define IDirectDraw7_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) -#define IDirectDraw7_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) -#define IDirectDraw7_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) -#define IDirectDraw7_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) -#define IDirectDraw7_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) -#define IDirectDraw7_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) -#define IDirectDraw7_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) -#define IDirectDraw7_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) -#define IDirectDraw7_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) -#define IDirectDraw7_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) -#define IDirectDraw7_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) -#define IDirectDraw7_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) -#define IDirectDraw7_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) -#define IDirectDraw7_GetSurfaceFromDC(p, a, b) (p)->lpVtbl->GetSurfaceFromDC(p, a, b) -#define IDirectDraw7_RestoreAllSurfaces(p) (p)->lpVtbl->RestoreAllSurfaces(p) -#define IDirectDraw7_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) -#define IDirectDraw7_GetDeviceIdentifier(p,a,b) (p)->lpVtbl->GetDeviceIdentifier(p,a,b) -#define IDirectDraw7_StartModeTest(p,a,b,c) (p)->lpVtbl->StartModeTest(p,a,b,c) -#define IDirectDraw7_EvaluateMode(p,a,b) (p)->lpVtbl->EvaluateMode(p,a,b) -#else -#define IDirectDraw7_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDraw7_AddRef(p) (p)->AddRef() -#define IDirectDraw7_Release(p) (p)->Release() -#define IDirectDraw7_Compact(p) (p)->Compact() -#define IDirectDraw7_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) -#define IDirectDraw7_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) -#define IDirectDraw7_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) -#define IDirectDraw7_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) -#define IDirectDraw7_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) -#define IDirectDraw7_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) -#define IDirectDraw7_FlipToGDISurface(p) (p)->FlipToGDISurface() -#define IDirectDraw7_GetCaps(p, a, b) (p)->GetCaps(a, b) -#define IDirectDraw7_GetDisplayMode(p, a) (p)->GetDisplayMode(a) -#define IDirectDraw7_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) -#define IDirectDraw7_GetGDISurface(p, a) (p)->GetGDISurface(a) -#define IDirectDraw7_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) -#define IDirectDraw7_GetScanLine(p, a) (p)->GetScanLine(a) -#define IDirectDraw7_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) -#define IDirectDraw7_Initialize(p, a) (p)->Initialize(a) -#define IDirectDraw7_RestoreDisplayMode(p) (p)->RestoreDisplayMode() -#define IDirectDraw7_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) -#define IDirectDraw7_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) -#define IDirectDraw7_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) -#define IDirectDraw7_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) -#define IDirectDraw7_GetSurfaceFromDC(p, a, b) (p)->GetSurfaceFromDC(a, b) -#define IDirectDraw7_RestoreAllSurfaces(p) (p)->RestoreAllSurfaces() -#define IDirectDraw7_TestCooperativeLevel(p) (p)->TestCooperativeLevel() -#define IDirectDraw7_GetDeviceIdentifier(p,a,b) (p)->GetDeviceIdentifier(a,b) -#define IDirectDraw7_StartModeTest(p,a,b,c) (p)->lpVtbl->StartModeTest(a,b,c) -#define IDirectDraw7_EvaluateMode(p,a,b) (p)->lpVtbl->EvaluateMode(a,b) -#endif - -#endif - - -/* - * IDirectDrawPalette - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDrawPalette -DECLARE_INTERFACE_( IDirectDrawPalette, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawPalette methods ***/ - STDMETHOD(GetCaps)(THIS_ LPDWORD) PURE; - STDMETHOD(GetEntries)(THIS_ DWORD,DWORD,DWORD,LPPALETTEENTRY) PURE; - STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, DWORD, LPPALETTEENTRY) PURE; - STDMETHOD(SetEntries)(THIS_ DWORD,DWORD,DWORD,LPPALETTEENTRY) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawPalette_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDrawPalette_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawPalette_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawPalette_GetCaps(p, a) (p)->lpVtbl->GetCaps(p, a) -#define IDirectDrawPalette_GetEntries(p, a, b, c, d) (p)->lpVtbl->GetEntries(p, a, b, c, d) -#define IDirectDrawPalette_Initialize(p, a, b, c) (p)->lpVtbl->Initialize(p, a, b, c) -#define IDirectDrawPalette_SetEntries(p, a, b, c, d) (p)->lpVtbl->SetEntries(p, a, b, c, d) -#else -#define IDirectDrawPalette_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDrawPalette_AddRef(p) (p)->AddRef() -#define IDirectDrawPalette_Release(p) (p)->Release() -#define IDirectDrawPalette_GetCaps(p, a) (p)->GetCaps(a) -#define IDirectDrawPalette_GetEntries(p, a, b, c, d) (p)->GetEntries(a, b, c, d) -#define IDirectDrawPalette_Initialize(p, a, b, c) (p)->Initialize(a, b, c) -#define IDirectDrawPalette_SetEntries(p, a, b, c, d) (p)->SetEntries(a, b, c, d) -#endif - -#endif - - -/* - * IDirectDrawClipper - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDrawClipper -DECLARE_INTERFACE_( IDirectDrawClipper, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawClipper methods ***/ - STDMETHOD(GetClipList)(THIS_ LPRECT, LPRGNDATA, LPDWORD) PURE; - STDMETHOD(GetHWnd)(THIS_ HWND FAR *) PURE; - STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, DWORD) PURE; - STDMETHOD(IsClipListChanged)(THIS_ BOOL FAR *) PURE; - STDMETHOD(SetClipList)(THIS_ LPRGNDATA,DWORD) PURE; - STDMETHOD(SetHWnd)(THIS_ DWORD, HWND ) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawClipper_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDrawClipper_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawClipper_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawClipper_GetClipList(p, a, b, c) (p)->lpVtbl->GetClipList(p, a, b, c) -#define IDirectDrawClipper_GetHWnd(p, a) (p)->lpVtbl->GetHWnd(p, a) -#define IDirectDrawClipper_Initialize(p, a, b) (p)->lpVtbl->Initialize(p, a, b) -#define IDirectDrawClipper_IsClipListChanged(p, a) (p)->lpVtbl->IsClipListChanged(p, a) -#define IDirectDrawClipper_SetClipList(p, a, b) (p)->lpVtbl->SetClipList(p, a, b) -#define IDirectDrawClipper_SetHWnd(p, a, b) (p)->lpVtbl->SetHWnd(p, a, b) -#else -#define IDirectDrawClipper_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDrawClipper_AddRef(p) (p)->AddRef() -#define IDirectDrawClipper_Release(p) (p)->Release() -#define IDirectDrawClipper_GetClipList(p, a, b, c) (p)->GetClipList(a, b, c) -#define IDirectDrawClipper_GetHWnd(p, a) (p)->GetHWnd(a) -#define IDirectDrawClipper_Initialize(p, a, b) (p)->Initialize(a, b) -#define IDirectDrawClipper_IsClipListChanged(p, a) (p)->IsClipListChanged(a) -#define IDirectDrawClipper_SetClipList(p, a, b) (p)->SetClipList(a, b) -#define IDirectDrawClipper_SetHWnd(p, a, b) (p)->SetHWnd(a, b) -#endif - -#endif - -/* - * IDirectDrawSurface and related interfaces - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDrawSurface -DECLARE_INTERFACE_( IDirectDrawSurface, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawSurface methods ***/ - STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE) PURE; - STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; - STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE, LPRECT,DWORD, LPDDBLTFX) PURE; - STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; - STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE, LPRECT,DWORD) PURE; - STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE) PURE; - STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; - STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; - STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE, DWORD) PURE; - STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE FAR *) PURE; - STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; - STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; - STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; - STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; - STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; - STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; - STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; - STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; - STDMETHOD(IsLost)(THIS) PURE; - STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; - STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; - STDMETHOD(Restore)(THIS) PURE; - STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; - STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; - STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; - STDMETHOD(Unlock)(THIS_ LPVOID) PURE; - STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE,LPRECT,DWORD, LPDDOVERLAYFX) PURE; - STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; - STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawSurface_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectDrawSurface_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawSurface_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawSurface_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) -#define IDirectDrawSurface_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) -#define IDirectDrawSurface_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) -#define IDirectDrawSurface_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) -#define IDirectDrawSurface_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) -#define IDirectDrawSurface_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) -#define IDirectDrawSurface_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) -#define IDirectDrawSurface_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) -#define IDirectDrawSurface_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) -#define IDirectDrawSurface_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) -#define IDirectDrawSurface_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) -#define IDirectDrawSurface_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) -#define IDirectDrawSurface_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) -#define IDirectDrawSurface_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) -#define IDirectDrawSurface_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) -#define IDirectDrawSurface_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) -#define IDirectDrawSurface_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) -#define IDirectDrawSurface_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) -#define IDirectDrawSurface_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) -#define IDirectDrawSurface_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) -#define IDirectDrawSurface_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectDrawSurface_IsLost(p) (p)->lpVtbl->IsLost(p) -#define IDirectDrawSurface_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirectDrawSurface_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) -#define IDirectDrawSurface_Restore(p) (p)->lpVtbl->Restore(p) -#define IDirectDrawSurface_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) -#define IDirectDrawSurface_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) -#define IDirectDrawSurface_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) -#define IDirectDrawSurface_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) -#define IDirectDrawSurface_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) -#define IDirectDrawSurface_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) -#define IDirectDrawSurface_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) -#define IDirectDrawSurface_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) -#else -#define IDirectDrawSurface_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectDrawSurface_AddRef(p) (p)->AddRef() -#define IDirectDrawSurface_Release(p) (p)->Release() -#define IDirectDrawSurface_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) -#define IDirectDrawSurface_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) -#define IDirectDrawSurface_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) -#define IDirectDrawSurface_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) -#define IDirectDrawSurface_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) -#define IDirectDrawSurface_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) -#define IDirectDrawSurface_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) -#define IDirectDrawSurface_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) -#define IDirectDrawSurface_Flip(p,a,b) (p)->Flip(a,b) -#define IDirectDrawSurface_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) -#define IDirectDrawSurface_GetBltStatus(p,a) (p)->GetBltStatus(a) -#define IDirectDrawSurface_GetCaps(p,b) (p)->GetCaps(b) -#define IDirectDrawSurface_GetClipper(p,a) (p)->GetClipper(a) -#define IDirectDrawSurface_GetColorKey(p,a,b) (p)->GetColorKey(a,b) -#define IDirectDrawSurface_GetDC(p,a) (p)->GetDC(a) -#define IDirectDrawSurface_GetFlipStatus(p,a) (p)->GetFlipStatus(a) -#define IDirectDrawSurface_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) -#define IDirectDrawSurface_GetPalette(p,a) (p)->GetPalette(a) -#define IDirectDrawSurface_GetPixelFormat(p,a) (p)->GetPixelFormat(a) -#define IDirectDrawSurface_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) -#define IDirectDrawSurface_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectDrawSurface_IsLost(p) (p)->IsLost() -#define IDirectDrawSurface_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirectDrawSurface_ReleaseDC(p,a) (p)->ReleaseDC(a) -#define IDirectDrawSurface_Restore(p) (p)->Restore() -#define IDirectDrawSurface_SetClipper(p,a) (p)->SetClipper(a) -#define IDirectDrawSurface_SetColorKey(p,a,b) (p)->SetColorKey(a,b) -#define IDirectDrawSurface_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) -#define IDirectDrawSurface_SetPalette(p,a) (p)->SetPalette(a) -#define IDirectDrawSurface_Unlock(p,b) (p)->Unlock(b) -#define IDirectDrawSurface_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) -#define IDirectDrawSurface_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) -#define IDirectDrawSurface_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) -#endif - -/* - * IDirectDrawSurface2 and related interfaces - */ -#undef INTERFACE -#define INTERFACE IDirectDrawSurface2 -DECLARE_INTERFACE_( IDirectDrawSurface2, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawSurface methods ***/ - STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE2) PURE; - STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; - STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE2, LPRECT,DWORD, LPDDBLTFX) PURE; - STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; - STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE2, LPRECT,DWORD) PURE; - STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE2) PURE; - STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; - STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; - STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE2, DWORD) PURE; - STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE2 FAR *) PURE; - STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; - STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; - STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; - STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; - STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; - STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; - STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; - STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; - STDMETHOD(IsLost)(THIS) PURE; - STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; - STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; - STDMETHOD(Restore)(THIS) PURE; - STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; - STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; - STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; - STDMETHOD(Unlock)(THIS_ LPVOID) PURE; - STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE2,LPRECT,DWORD, LPDDOVERLAYFX) PURE; - STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; - STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE2) PURE; - /*** Added in the v2 interface ***/ - STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; - STDMETHOD(PageLock)(THIS_ DWORD) PURE; - STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawSurface2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectDrawSurface2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawSurface2_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawSurface2_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) -#define IDirectDrawSurface2_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) -#define IDirectDrawSurface2_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) -#define IDirectDrawSurface2_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) -#define IDirectDrawSurface2_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) -#define IDirectDrawSurface2_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) -#define IDirectDrawSurface2_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) -#define IDirectDrawSurface2_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) -#define IDirectDrawSurface2_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) -#define IDirectDrawSurface2_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) -#define IDirectDrawSurface2_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) -#define IDirectDrawSurface2_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) -#define IDirectDrawSurface2_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) -#define IDirectDrawSurface2_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) -#define IDirectDrawSurface2_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) -#define IDirectDrawSurface2_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) -#define IDirectDrawSurface2_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) -#define IDirectDrawSurface2_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) -#define IDirectDrawSurface2_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) -#define IDirectDrawSurface2_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) -#define IDirectDrawSurface2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectDrawSurface2_IsLost(p) (p)->lpVtbl->IsLost(p) -#define IDirectDrawSurface2_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirectDrawSurface2_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) -#define IDirectDrawSurface2_Restore(p) (p)->lpVtbl->Restore(p) -#define IDirectDrawSurface2_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) -#define IDirectDrawSurface2_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) -#define IDirectDrawSurface2_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) -#define IDirectDrawSurface2_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) -#define IDirectDrawSurface2_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) -#define IDirectDrawSurface2_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) -#define IDirectDrawSurface2_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) -#define IDirectDrawSurface2_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) -#define IDirectDrawSurface2_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) -#define IDirectDrawSurface2_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) -#define IDirectDrawSurface2_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) -#else -#define IDirectDrawSurface2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectDrawSurface2_AddRef(p) (p)->AddRef() -#define IDirectDrawSurface2_Release(p) (p)->Release() -#define IDirectDrawSurface2_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) -#define IDirectDrawSurface2_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) -#define IDirectDrawSurface2_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) -#define IDirectDrawSurface2_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) -#define IDirectDrawSurface2_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) -#define IDirectDrawSurface2_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) -#define IDirectDrawSurface2_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) -#define IDirectDrawSurface2_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) -#define IDirectDrawSurface2_Flip(p,a,b) (p)->Flip(a,b) -#define IDirectDrawSurface2_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) -#define IDirectDrawSurface2_GetBltStatus(p,a) (p)->GetBltStatus(a) -#define IDirectDrawSurface2_GetCaps(p,b) (p)->GetCaps(b) -#define IDirectDrawSurface2_GetClipper(p,a) (p)->GetClipper(a) -#define IDirectDrawSurface2_GetColorKey(p,a,b) (p)->GetColorKey(a,b) -#define IDirectDrawSurface2_GetDC(p,a) (p)->GetDC(a) -#define IDirectDrawSurface2_GetFlipStatus(p,a) (p)->GetFlipStatus(a) -#define IDirectDrawSurface2_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) -#define IDirectDrawSurface2_GetPalette(p,a) (p)->GetPalette(a) -#define IDirectDrawSurface2_GetPixelFormat(p,a) (p)->GetPixelFormat(a) -#define IDirectDrawSurface2_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) -#define IDirectDrawSurface2_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectDrawSurface2_IsLost(p) (p)->IsLost() -#define IDirectDrawSurface2_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirectDrawSurface2_ReleaseDC(p,a) (p)->ReleaseDC(a) -#define IDirectDrawSurface2_Restore(p) (p)->Restore() -#define IDirectDrawSurface2_SetClipper(p,a) (p)->SetClipper(a) -#define IDirectDrawSurface2_SetColorKey(p,a,b) (p)->SetColorKey(a,b) -#define IDirectDrawSurface2_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) -#define IDirectDrawSurface2_SetPalette(p,a) (p)->SetPalette(a) -#define IDirectDrawSurface2_Unlock(p,b) (p)->Unlock(b) -#define IDirectDrawSurface2_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) -#define IDirectDrawSurface2_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) -#define IDirectDrawSurface2_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) -#define IDirectDrawSurface2_GetDDInterface(p,a) (p)->GetDDInterface(a) -#define IDirectDrawSurface2_PageLock(p,a) (p)->PageLock(a) -#define IDirectDrawSurface2_PageUnlock(p,a) (p)->PageUnlock(a) -#endif - -/* - * IDirectDrawSurface3 and related interfaces - */ -#undef INTERFACE -#define INTERFACE IDirectDrawSurface3 -DECLARE_INTERFACE_( IDirectDrawSurface3, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawSurface methods ***/ - STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE3) PURE; - STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; - STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE3, LPRECT,DWORD, LPDDBLTFX) PURE; - STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; - STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE3, LPRECT,DWORD) PURE; - STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE3) PURE; - STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; - STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; - STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE3, DWORD) PURE; - STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE3 FAR *) PURE; - STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; - STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; - STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; - STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; - STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; - STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; - STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; - STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; - STDMETHOD(IsLost)(THIS) PURE; - STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; - STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; - STDMETHOD(Restore)(THIS) PURE; - STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; - STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; - STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; - STDMETHOD(Unlock)(THIS_ LPVOID) PURE; - STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE3,LPRECT,DWORD, LPDDOVERLAYFX) PURE; - STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; - STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE3) PURE; - /*** Added in the v2 interface ***/ - STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; - STDMETHOD(PageLock)(THIS_ DWORD) PURE; - STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; - /*** Added in the V3 interface ***/ - STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC, DWORD) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawSurface3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectDrawSurface3_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawSurface3_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawSurface3_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) -#define IDirectDrawSurface3_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) -#define IDirectDrawSurface3_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) -#define IDirectDrawSurface3_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) -#define IDirectDrawSurface3_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) -#define IDirectDrawSurface3_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) -#define IDirectDrawSurface3_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) -#define IDirectDrawSurface3_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) -#define IDirectDrawSurface3_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) -#define IDirectDrawSurface3_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) -#define IDirectDrawSurface3_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) -#define IDirectDrawSurface3_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) -#define IDirectDrawSurface3_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) -#define IDirectDrawSurface3_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) -#define IDirectDrawSurface3_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) -#define IDirectDrawSurface3_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) -#define IDirectDrawSurface3_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) -#define IDirectDrawSurface3_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) -#define IDirectDrawSurface3_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) -#define IDirectDrawSurface3_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) -#define IDirectDrawSurface3_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectDrawSurface3_IsLost(p) (p)->lpVtbl->IsLost(p) -#define IDirectDrawSurface3_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirectDrawSurface3_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) -#define IDirectDrawSurface3_Restore(p) (p)->lpVtbl->Restore(p) -#define IDirectDrawSurface3_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) -#define IDirectDrawSurface3_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) -#define IDirectDrawSurface3_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) -#define IDirectDrawSurface3_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) -#define IDirectDrawSurface3_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) -#define IDirectDrawSurface3_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) -#define IDirectDrawSurface3_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) -#define IDirectDrawSurface3_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) -#define IDirectDrawSurface3_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) -#define IDirectDrawSurface3_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) -#define IDirectDrawSurface3_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) -#define IDirectDrawSurface3_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) -#else -#define IDirectDrawSurface3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectDrawSurface3_AddRef(p) (p)->AddRef() -#define IDirectDrawSurface3_Release(p) (p)->Release() -#define IDirectDrawSurface3_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) -#define IDirectDrawSurface3_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) -#define IDirectDrawSurface3_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) -#define IDirectDrawSurface3_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) -#define IDirectDrawSurface3_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) -#define IDirectDrawSurface3_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) -#define IDirectDrawSurface3_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) -#define IDirectDrawSurface3_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) -#define IDirectDrawSurface3_Flip(p,a,b) (p)->Flip(a,b) -#define IDirectDrawSurface3_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) -#define IDirectDrawSurface3_GetBltStatus(p,a) (p)->GetBltStatus(a) -#define IDirectDrawSurface3_GetCaps(p,b) (p)->GetCaps(b) -#define IDirectDrawSurface3_GetClipper(p,a) (p)->GetClipper(a) -#define IDirectDrawSurface3_GetColorKey(p,a,b) (p)->GetColorKey(a,b) -#define IDirectDrawSurface3_GetDC(p,a) (p)->GetDC(a) -#define IDirectDrawSurface3_GetFlipStatus(p,a) (p)->GetFlipStatus(a) -#define IDirectDrawSurface3_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) -#define IDirectDrawSurface3_GetPalette(p,a) (p)->GetPalette(a) -#define IDirectDrawSurface3_GetPixelFormat(p,a) (p)->GetPixelFormat(a) -#define IDirectDrawSurface3_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) -#define IDirectDrawSurface3_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectDrawSurface3_IsLost(p) (p)->IsLost() -#define IDirectDrawSurface3_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirectDrawSurface3_ReleaseDC(p,a) (p)->ReleaseDC(a) -#define IDirectDrawSurface3_Restore(p) (p)->Restore() -#define IDirectDrawSurface3_SetClipper(p,a) (p)->SetClipper(a) -#define IDirectDrawSurface3_SetColorKey(p,a,b) (p)->SetColorKey(a,b) -#define IDirectDrawSurface3_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) -#define IDirectDrawSurface3_SetPalette(p,a) (p)->SetPalette(a) -#define IDirectDrawSurface3_Unlock(p,b) (p)->Unlock(b) -#define IDirectDrawSurface3_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) -#define IDirectDrawSurface3_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) -#define IDirectDrawSurface3_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) -#define IDirectDrawSurface3_GetDDInterface(p,a) (p)->GetDDInterface(a) -#define IDirectDrawSurface3_PageLock(p,a) (p)->PageLock(a) -#define IDirectDrawSurface3_PageUnlock(p,a) (p)->PageUnlock(a) -#define IDirectDrawSurface3_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) -#endif - -/* - * IDirectDrawSurface4 and related interfaces - */ -#undef INTERFACE -#define INTERFACE IDirectDrawSurface4 -DECLARE_INTERFACE_( IDirectDrawSurface4, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawSurface methods ***/ - STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE4) PURE; - STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; - STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE4, LPRECT,DWORD, LPDDBLTFX) PURE; - STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; - STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE4, LPRECT,DWORD) PURE; - STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE4) PURE; - STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK2) PURE; - STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK2) PURE; - STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE4, DWORD) PURE; - STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS2, LPDIRECTDRAWSURFACE4 FAR *) PURE; - STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetCaps)(THIS_ LPDDSCAPS2) PURE; - STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; - STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; - STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; - STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; - STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; - STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC2) PURE; - STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC2) PURE; - STDMETHOD(IsLost)(THIS) PURE; - STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC2,DWORD,HANDLE) PURE; - STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; - STDMETHOD(Restore)(THIS) PURE; - STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; - STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; - STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; - STDMETHOD(Unlock)(THIS_ LPRECT) PURE; - STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE4,LPRECT,DWORD, LPDDOVERLAYFX) PURE; - STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; - STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE4) PURE; - /*** Added in the v2 interface ***/ - STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; - STDMETHOD(PageLock)(THIS_ DWORD) PURE; - STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; - /*** Added in the v3 interface ***/ - STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC2, DWORD) PURE; - /*** Added in the v4 interface ***/ - STDMETHOD(SetPrivateData)(THIS_ REFGUID, LPVOID, DWORD, DWORD) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID, LPVOID, LPDWORD) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID) PURE; - STDMETHOD(GetUniquenessValue)(THIS_ LPDWORD) PURE; - STDMETHOD(ChangeUniquenessValue)(THIS) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawSurface4_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectDrawSurface4_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawSurface4_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawSurface4_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) -#define IDirectDrawSurface4_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) -#define IDirectDrawSurface4_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) -#define IDirectDrawSurface4_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) -#define IDirectDrawSurface4_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) -#define IDirectDrawSurface4_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) -#define IDirectDrawSurface4_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) -#define IDirectDrawSurface4_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) -#define IDirectDrawSurface4_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) -#define IDirectDrawSurface4_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) -#define IDirectDrawSurface4_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) -#define IDirectDrawSurface4_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) -#define IDirectDrawSurface4_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) -#define IDirectDrawSurface4_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) -#define IDirectDrawSurface4_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) -#define IDirectDrawSurface4_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) -#define IDirectDrawSurface4_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) -#define IDirectDrawSurface4_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) -#define IDirectDrawSurface4_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) -#define IDirectDrawSurface4_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) -#define IDirectDrawSurface4_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectDrawSurface4_IsLost(p) (p)->lpVtbl->IsLost(p) -#define IDirectDrawSurface4_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirectDrawSurface4_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) -#define IDirectDrawSurface4_Restore(p) (p)->lpVtbl->Restore(p) -#define IDirectDrawSurface4_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) -#define IDirectDrawSurface4_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) -#define IDirectDrawSurface4_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) -#define IDirectDrawSurface4_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) -#define IDirectDrawSurface4_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) -#define IDirectDrawSurface4_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) -#define IDirectDrawSurface4_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) -#define IDirectDrawSurface4_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) -#define IDirectDrawSurface4_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) -#define IDirectDrawSurface4_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) -#define IDirectDrawSurface4_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) -#define IDirectDrawSurface4_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) -#define IDirectDrawSurface4_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirectDrawSurface4_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirectDrawSurface4_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirectDrawSurface4_GetUniquenessValue(p, a) (p)->lpVtbl->GetUniquenessValue(p, a) -#define IDirectDrawSurface4_ChangeUniquenessValue(p) (p)->lpVtbl->ChangeUniquenessValue(p) -#else -#define IDirectDrawSurface4_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectDrawSurface4_AddRef(p) (p)->AddRef() -#define IDirectDrawSurface4_Release(p) (p)->Release() -#define IDirectDrawSurface4_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) -#define IDirectDrawSurface4_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) -#define IDirectDrawSurface4_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) -#define IDirectDrawSurface4_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) -#define IDirectDrawSurface4_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) -#define IDirectDrawSurface4_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) -#define IDirectDrawSurface4_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) -#define IDirectDrawSurface4_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) -#define IDirectDrawSurface4_Flip(p,a,b) (p)->Flip(a,b) -#define IDirectDrawSurface4_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) -#define IDirectDrawSurface4_GetBltStatus(p,a) (p)->GetBltStatus(a) -#define IDirectDrawSurface4_GetCaps(p,b) (p)->GetCaps(b) -#define IDirectDrawSurface4_GetClipper(p,a) (p)->GetClipper(a) -#define IDirectDrawSurface4_GetColorKey(p,a,b) (p)->GetColorKey(a,b) -#define IDirectDrawSurface4_GetDC(p,a) (p)->GetDC(a) -#define IDirectDrawSurface4_GetFlipStatus(p,a) (p)->GetFlipStatus(a) -#define IDirectDrawSurface4_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) -#define IDirectDrawSurface4_GetPalette(p,a) (p)->GetPalette(a) -#define IDirectDrawSurface4_GetPixelFormat(p,a) (p)->GetPixelFormat(a) -#define IDirectDrawSurface4_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) -#define IDirectDrawSurface4_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectDrawSurface4_IsLost(p) (p)->IsLost() -#define IDirectDrawSurface4_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirectDrawSurface4_ReleaseDC(p,a) (p)->ReleaseDC(a) -#define IDirectDrawSurface4_Restore(p) (p)->Restore() -#define IDirectDrawSurface4_SetClipper(p,a) (p)->SetClipper(a) -#define IDirectDrawSurface4_SetColorKey(p,a,b) (p)->SetColorKey(a,b) -#define IDirectDrawSurface4_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) -#define IDirectDrawSurface4_SetPalette(p,a) (p)->SetPalette(a) -#define IDirectDrawSurface4_Unlock(p,b) (p)->Unlock(b) -#define IDirectDrawSurface4_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) -#define IDirectDrawSurface4_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) -#define IDirectDrawSurface4_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) -#define IDirectDrawSurface4_GetDDInterface(p,a) (p)->GetDDInterface(a) -#define IDirectDrawSurface4_PageLock(p,a) (p)->PageLock(a) -#define IDirectDrawSurface4_PageUnlock(p,a) (p)->PageUnlock(a) -#define IDirectDrawSurface4_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) -#define IDirectDrawSurface4_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirectDrawSurface4_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirectDrawSurface4_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirectDrawSurface4_GetUniquenessValue(p, a) (p)->GetUniquenessValue(a) -#define IDirectDrawSurface4_ChangeUniquenessValue(p) (p)->ChangeUniquenessValue() -#endif - -/* - * IDirectDrawSurface7 and related interfaces - */ -#undef INTERFACE -#define INTERFACE IDirectDrawSurface7 -DECLARE_INTERFACE_( IDirectDrawSurface7, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawSurface methods ***/ - STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE7) PURE; - STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; - STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE7, LPRECT,DWORD, LPDDBLTFX) PURE; - STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; - STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE7, LPRECT,DWORD) PURE; - STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE7) PURE; - STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK7) PURE; - STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK7) PURE; - STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE7, DWORD) PURE; - STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS2, LPDIRECTDRAWSURFACE7 FAR *) PURE; - STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetCaps)(THIS_ LPDDSCAPS2) PURE; - STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; - STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; - STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; - STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; - STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; - STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC2) PURE; - STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC2) PURE; - STDMETHOD(IsLost)(THIS) PURE; - STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC2,DWORD,HANDLE) PURE; - STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; - STDMETHOD(Restore)(THIS) PURE; - STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; - STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; - STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; - STDMETHOD(Unlock)(THIS_ LPRECT) PURE; - STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE7,LPRECT,DWORD, LPDDOVERLAYFX) PURE; - STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; - STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE7) PURE; - /*** Added in the v2 interface ***/ - STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; - STDMETHOD(PageLock)(THIS_ DWORD) PURE; - STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; - /*** Added in the v3 interface ***/ - STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC2, DWORD) PURE; - /*** Added in the v4 interface ***/ - STDMETHOD(SetPrivateData)(THIS_ REFGUID, LPVOID, DWORD, DWORD) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID, LPVOID, LPDWORD) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID) PURE; - STDMETHOD(GetUniquenessValue)(THIS_ LPDWORD) PURE; - STDMETHOD(ChangeUniquenessValue)(THIS) PURE; - /*** Moved Texture7 methods here ***/ - STDMETHOD(SetPriority)(THIS_ DWORD) PURE; - STDMETHOD(GetPriority)(THIS_ LPDWORD) PURE; - STDMETHOD(SetLOD)(THIS_ DWORD) PURE; - STDMETHOD(GetLOD)(THIS_ LPDWORD) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawSurface7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectDrawSurface7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawSurface7_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawSurface7_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) -#define IDirectDrawSurface7_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) -#define IDirectDrawSurface7_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) -#define IDirectDrawSurface7_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) -#define IDirectDrawSurface7_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) -#define IDirectDrawSurface7_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) -#define IDirectDrawSurface7_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) -#define IDirectDrawSurface7_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) -#define IDirectDrawSurface7_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) -#define IDirectDrawSurface7_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) -#define IDirectDrawSurface7_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) -#define IDirectDrawSurface7_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) -#define IDirectDrawSurface7_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) -#define IDirectDrawSurface7_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) -#define IDirectDrawSurface7_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) -#define IDirectDrawSurface7_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) -#define IDirectDrawSurface7_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) -#define IDirectDrawSurface7_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) -#define IDirectDrawSurface7_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) -#define IDirectDrawSurface7_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) -#define IDirectDrawSurface7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectDrawSurface7_IsLost(p) (p)->lpVtbl->IsLost(p) -#define IDirectDrawSurface7_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirectDrawSurface7_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) -#define IDirectDrawSurface7_Restore(p) (p)->lpVtbl->Restore(p) -#define IDirectDrawSurface7_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) -#define IDirectDrawSurface7_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) -#define IDirectDrawSurface7_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) -#define IDirectDrawSurface7_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) -#define IDirectDrawSurface7_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) -#define IDirectDrawSurface7_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) -#define IDirectDrawSurface7_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) -#define IDirectDrawSurface7_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) -#define IDirectDrawSurface7_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) -#define IDirectDrawSurface7_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) -#define IDirectDrawSurface7_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) -#define IDirectDrawSurface7_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) -#define IDirectDrawSurface7_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirectDrawSurface7_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirectDrawSurface7_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirectDrawSurface7_GetUniquenessValue(p, a) (p)->lpVtbl->GetUniquenessValue(p, a) -#define IDirectDrawSurface7_ChangeUniquenessValue(p) (p)->lpVtbl->ChangeUniquenessValue(p) -#define IDirectDrawSurface7_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirectDrawSurface7_GetPriority(p,a) (p)->lpVtbl->GetPriority(p,a) -#define IDirectDrawSurface7_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirectDrawSurface7_GetLOD(p,a) (p)->lpVtbl->GetLOD(p,a) -#else -#define IDirectDrawSurface7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectDrawSurface7_AddRef(p) (p)->AddRef() -#define IDirectDrawSurface7_Release(p) (p)->Release() -#define IDirectDrawSurface7_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) -#define IDirectDrawSurface7_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) -#define IDirectDrawSurface7_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) -#define IDirectDrawSurface7_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) -#define IDirectDrawSurface7_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) -#define IDirectDrawSurface7_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) -#define IDirectDrawSurface7_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) -#define IDirectDrawSurface7_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) -#define IDirectDrawSurface7_Flip(p,a,b) (p)->Flip(a,b) -#define IDirectDrawSurface7_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) -#define IDirectDrawSurface7_GetBltStatus(p,a) (p)->GetBltStatus(a) -#define IDirectDrawSurface7_GetCaps(p,b) (p)->GetCaps(b) -#define IDirectDrawSurface7_GetClipper(p,a) (p)->GetClipper(a) -#define IDirectDrawSurface7_GetColorKey(p,a,b) (p)->GetColorKey(a,b) -#define IDirectDrawSurface7_GetDC(p,a) (p)->GetDC(a) -#define IDirectDrawSurface7_GetFlipStatus(p,a) (p)->GetFlipStatus(a) -#define IDirectDrawSurface7_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) -#define IDirectDrawSurface7_GetPalette(p,a) (p)->GetPalette(a) -#define IDirectDrawSurface7_GetPixelFormat(p,a) (p)->GetPixelFormat(a) -#define IDirectDrawSurface7_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) -#define IDirectDrawSurface7_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectDrawSurface7_IsLost(p) (p)->IsLost() -#define IDirectDrawSurface7_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirectDrawSurface7_ReleaseDC(p,a) (p)->ReleaseDC(a) -#define IDirectDrawSurface7_Restore(p) (p)->Restore() -#define IDirectDrawSurface7_SetClipper(p,a) (p)->SetClipper(a) -#define IDirectDrawSurface7_SetColorKey(p,a,b) (p)->SetColorKey(a,b) -#define IDirectDrawSurface7_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) -#define IDirectDrawSurface7_SetPalette(p,a) (p)->SetPalette(a) -#define IDirectDrawSurface7_Unlock(p,b) (p)->Unlock(b) -#define IDirectDrawSurface7_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) -#define IDirectDrawSurface7_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) -#define IDirectDrawSurface7_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) -#define IDirectDrawSurface7_GetDDInterface(p,a) (p)->GetDDInterface(a) -#define IDirectDrawSurface7_PageLock(p,a) (p)->PageLock(a) -#define IDirectDrawSurface7_PageUnlock(p,a) (p)->PageUnlock(a) -#define IDirectDrawSurface7_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) -#define IDirectDrawSurface7_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirectDrawSurface7_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirectDrawSurface7_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirectDrawSurface7_GetUniquenessValue(p, a) (p)->GetUniquenessValue(a) -#define IDirectDrawSurface7_ChangeUniquenessValue(p) (p)->ChangeUniquenessValue() -#define IDirectDrawSurface7_SetPriority(p,a) (p)->SetPriority(a) -#define IDirectDrawSurface7_GetPriority(p,a) (p)->GetPriority(a) -#define IDirectDrawSurface7_SetLOD(p,a) (p)->SetLOD(a) -#define IDirectDrawSurface7_GetLOD(p,a) (p)->GetLOD(a) -#endif - - -/* - * IDirectDrawColorControl - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDrawColorControl -DECLARE_INTERFACE_( IDirectDrawColorControl, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawColorControl methods ***/ - STDMETHOD(GetColorControls)(THIS_ LPDDCOLORCONTROL) PURE; - STDMETHOD(SetColorControls)(THIS_ LPDDCOLORCONTROL) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawColorControl_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDrawColorControl_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawColorControl_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawColorControl_GetColorControls(p, a) (p)->lpVtbl->GetColorControls(p, a) -#define IDirectDrawColorControl_SetColorControls(p, a) (p)->lpVtbl->SetColorControls(p, a) -#else -#define IDirectDrawColorControl_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDrawColorControl_AddRef(p) (p)->AddRef() -#define IDirectDrawColorControl_Release(p) (p)->Release() -#define IDirectDrawColorControl_GetColorControls(p, a) (p)->GetColorControls(a) -#define IDirectDrawColorControl_SetColorControls(p, a) (p)->SetColorControls(a) -#endif - -#endif - - -/* - * IDirectDrawGammaControl - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDrawGammaControl -DECLARE_INTERFACE_( IDirectDrawGammaControl, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawGammaControl methods ***/ - STDMETHOD(GetGammaRamp)(THIS_ DWORD, LPDDGAMMARAMP) PURE; - STDMETHOD(SetGammaRamp)(THIS_ DWORD, LPDDGAMMARAMP) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawGammaControl_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDrawGammaControl_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawGammaControl_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawGammaControl_GetGammaRamp(p, a, b) (p)->lpVtbl->GetGammaRamp(p, a, b) -#define IDirectDrawGammaControl_SetGammaRamp(p, a, b) (p)->lpVtbl->SetGammaRamp(p, a, b) -#else -#define IDirectDrawGammaControl_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDrawGammaControl_AddRef(p) (p)->AddRef() -#define IDirectDrawGammaControl_Release(p) (p)->Release() -#define IDirectDrawGammaControl_GetGammaRamp(p, a, b) (p)->GetGammaRamp(a, b) -#define IDirectDrawGammaControl_SetGammaRamp(p, a, b) (p)->SetGammaRamp(a, b) -#endif - -#endif - - - -#endif - - -/* - * DDSURFACEDESC - */ -typedef struct _DDSURFACEDESC -{ - DWORD dwSize; // size of the DDSURFACEDESC structure - DWORD dwFlags; // determines what fields are valid - DWORD dwHeight; // height of surface to be created - DWORD dwWidth; // width of input surface - union - { - LONG lPitch; // distance to start of next line (return value only) - DWORD dwLinearSize; // Formless late-allocated optimized surface size - } DUMMYUNIONNAMEN(1); - DWORD dwBackBufferCount; // number of back buffers requested - union - { - DWORD dwMipMapCount; // number of mip-map levels requested - DWORD dwZBufferBitDepth; // depth of Z buffer requested - DWORD dwRefreshRate; // refresh rate (used when display mode is described) - } DUMMYUNIONNAMEN(2); - DWORD dwAlphaBitDepth; // depth of alpha buffer requested - DWORD dwReserved; // reserved - LPVOID lpSurface; // pointer to the associated surface memory - DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use - DDCOLORKEY ddckCKDestBlt; // color key for destination blt use - DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use - DDCOLORKEY ddckCKSrcBlt; // color key for source blt use - DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface - DDSCAPS ddsCaps; // direct draw surface capabilities -} DDSURFACEDESC; - -/* - * DDSURFACEDESC2 - */ -typedef struct _DDSURFACEDESC2 -{ - DWORD dwSize; // size of the DDSURFACEDESC structure - DWORD dwFlags; // determines what fields are valid - DWORD dwHeight; // height of surface to be created - DWORD dwWidth; // width of input surface - union - { - LONG lPitch; // distance to start of next line (return value only) - DWORD dwLinearSize; // Formless late-allocated optimized surface size - } DUMMYUNIONNAMEN(1); - union - { - DWORD dwBackBufferCount; // number of back buffers requested - DWORD dwDepth; // the depth if this is a volume texture - } DUMMYUNIONNAMEN(5); - union - { - DWORD dwMipMapCount; // number of mip-map levels requestde - // dwZBufferBitDepth removed, use ddpfPixelFormat one instead - DWORD dwRefreshRate; // refresh rate (used when display mode is described) - DWORD dwSrcVBHandle; // The source used in VB::Optimize - } DUMMYUNIONNAMEN(2); - DWORD dwAlphaBitDepth; // depth of alpha buffer requested - DWORD dwReserved; // reserved - LPVOID lpSurface; // pointer to the associated surface memory - union - { - DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use - DWORD dwEmptyFaceColor; // Physical color for empty cubemap faces - } DUMMYUNIONNAMEN(3); - DDCOLORKEY ddckCKDestBlt; // color key for destination blt use - DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use - DDCOLORKEY ddckCKSrcBlt; // color key for source blt use - union - { - DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface - DWORD dwFVF; // vertex format description of vertex buffers - } DUMMYUNIONNAMEN(4); - DDSCAPS2 ddsCaps; // direct draw surface capabilities - DWORD dwTextureStage; // stage in multitexture cascade -} DDSURFACEDESC2; - -/* - * ddsCaps field is valid. - */ -#define DDSD_CAPS 0x00000001l // default - -/* - * dwHeight field is valid. - */ -#define DDSD_HEIGHT 0x00000002l - -/* - * dwWidth field is valid. - */ -#define DDSD_WIDTH 0x00000004l - -/* - * lPitch is valid. - */ -#define DDSD_PITCH 0x00000008l - -/* - * dwBackBufferCount is valid. - */ -#define DDSD_BACKBUFFERCOUNT 0x00000020l - -/* - * dwZBufferBitDepth is valid. (shouldnt be used in DDSURFACEDESC2) - */ -#define DDSD_ZBUFFERBITDEPTH 0x00000040l - -/* - * dwAlphaBitDepth is valid. - */ -#define DDSD_ALPHABITDEPTH 0x00000080l - - -/* - * lpSurface is valid. - */ -#define DDSD_LPSURFACE 0x00000800l - -/* - * ddpfPixelFormat is valid. - */ -#define DDSD_PIXELFORMAT 0x00001000l - -/* - * ddckCKDestOverlay is valid. - */ -#define DDSD_CKDESTOVERLAY 0x00002000l - -/* - * ddckCKDestBlt is valid. - */ -#define DDSD_CKDESTBLT 0x00004000l - -/* - * ddckCKSrcOverlay is valid. - */ -#define DDSD_CKSRCOVERLAY 0x00008000l - -/* - * ddckCKSrcBlt is valid. - */ -#define DDSD_CKSRCBLT 0x00010000l - -/* - * dwMipMapCount is valid. - */ -#define DDSD_MIPMAPCOUNT 0x00020000l - - /* - * dwRefreshRate is valid - */ -#define DDSD_REFRESHRATE 0x00040000l - -/* - * dwLinearSize is valid - */ -#define DDSD_LINEARSIZE 0x00080000l - -/* - * dwTextureStage is valid - */ -#define DDSD_TEXTURESTAGE 0x00100000l -/* - * dwFVF is valid - */ -#define DDSD_FVF 0x00200000l -/* - * dwSrcVBHandle is valid - */ -#define DDSD_SRCVBHANDLE 0x00400000l - -/* - * dwDepth is valid - */ -#define DDSD_DEPTH 0x00800000l - -/* - * All input fields are valid. - */ -#define DDSD_ALL 0x00fff9eel - -/* - * DDOPTSURFACEDESC - */ -typedef struct _DDOPTSURFACEDESC -{ - DWORD dwSize; // size of the DDOPTSURFACEDESC structure - DWORD dwFlags; // determines what fields are valid - DDSCAPS2 ddSCaps; // Common caps like: Memory type - DDOSCAPS ddOSCaps; // Common caps like: Memory type - GUID guid; // Compression technique GUID - DWORD dwCompressionRatio; // Compression ratio -} DDOPTSURFACEDESC; - -/* - * guid field is valid. - */ -#define DDOSD_GUID 0x00000001l - -/* - * dwCompressionRatio field is valid. - */ -#define DDOSD_COMPRESSION_RATIO 0x00000002l - -/* - * ddSCaps field is valid. - */ -#define DDOSD_SCAPS 0x00000004l - -/* - * ddOSCaps field is valid. - */ -#define DDOSD_OSCAPS 0x00000008l - -/* - * All input fields are valid. - */ -#define DDOSD_ALL 0x0000000fl - -/* - * The surface's optimized pixelformat is compressed - */ -#define DDOSDCAPS_OPTCOMPRESSED 0x00000001l - -/* - * The surface's optimized pixelformat is reordered - */ -#define DDOSDCAPS_OPTREORDERED 0x00000002l - -/* - * The opt surface is a monolithic mipmap - */ -#define DDOSDCAPS_MONOLITHICMIPMAP 0x00000004l - -/* - * The valid Surf caps: - * #define DDSCAPS_SYSTEMMEMORY 0x00000800l - * #define DDSCAPS_VIDEOMEMORY 0x00004000l - * #define DDSCAPS_LOCALVIDMEM 0x10000000l - * #define DDSCAPS_NONLOCALVIDMEM 0x20000000l - */ -#define DDOSDCAPS_VALIDSCAPS 0x30004800l - -/* - * The valid OptSurf caps - */ -#define DDOSDCAPS_VALIDOSCAPS 0x00000007l - - -/* - * DDCOLORCONTROL - */ -typedef struct _DDCOLORCONTROL -{ - DWORD dwSize; - DWORD dwFlags; - LONG lBrightness; - LONG lContrast; - LONG lHue; - LONG lSaturation; - LONG lSharpness; - LONG lGamma; - LONG lColorEnable; - DWORD dwReserved1; -} DDCOLORCONTROL; - - -/* - * lBrightness field is valid. - */ -#define DDCOLOR_BRIGHTNESS 0x00000001l - -/* - * lContrast field is valid. - */ -#define DDCOLOR_CONTRAST 0x00000002l - -/* - * lHue field is valid. - */ -#define DDCOLOR_HUE 0x00000004l - -/* - * lSaturation field is valid. - */ -#define DDCOLOR_SATURATION 0x00000008l - -/* - * lSharpness field is valid. - */ -#define DDCOLOR_SHARPNESS 0x00000010l - -/* - * lGamma field is valid. - */ -#define DDCOLOR_GAMMA 0x00000020l - -/* - * lColorEnable field is valid. - */ -#define DDCOLOR_COLORENABLE 0x00000040l - - - -/*============================================================================ - * - * Direct Draw Capability Flags - * - * These flags are used to describe the capabilities of a given Surface. - * All flags are bit flags. - * - *==========================================================================*/ - -/**************************************************************************** - * - * DIRECTDRAWSURFACE CAPABILITY FLAGS - * - ****************************************************************************/ - -/* - * This bit is reserved. It should not be specified. - */ -#define DDSCAPS_RESERVED1 0x00000001l - -/* - * Indicates that this surface contains alpha-only information. - * (To determine if a surface is RGBA/YUVA, the pixel format must be - * interrogated.) - */ -#define DDSCAPS_ALPHA 0x00000002l - -/* - * Indicates that this surface is a backbuffer. It is generally - * set by CreateSurface when the DDSCAPS_FLIP capability bit is set. - * It indicates that this surface is THE back buffer of a surface - * flipping structure. DirectDraw supports N surfaces in a - * surface flipping structure. Only the surface that immediately - * precedeces the DDSCAPS_FRONTBUFFER has this capability bit set. - * The other surfaces are identified as back buffers by the presence - * of the DDSCAPS_FLIP capability, their attachment order, and the - * absence of the DDSCAPS_FRONTBUFFER and DDSCAPS_BACKBUFFER - * capabilities. The bit is sent to CreateSurface when a standalone - * back buffer is being created. This surface could be attached to - * a front buffer and/or back buffers to form a flipping surface - * structure after the CreateSurface call. See AddAttachments for - * a detailed description of the behaviors in this case. - */ -#define DDSCAPS_BACKBUFFER 0x00000004l - -/* - * Indicates a complex surface structure is being described. A - * complex surface structure results in the creation of more than - * one surface. The additional surfaces are attached to the root - * surface. The complex structure can only be destroyed by - * destroying the root. - */ -#define DDSCAPS_COMPLEX 0x00000008l - -/* - * Indicates that this surface is a part of a surface flipping structure. - * When it is passed to CreateSurface the DDSCAPS_FRONTBUFFER and - * DDSCAP_BACKBUFFER bits are not set. They are set by CreateSurface - * on the resulting creations. The dwBackBufferCount field in the - * DDSURFACEDESC structure must be set to at least 1 in order for - * the CreateSurface call to succeed. The DDSCAPS_COMPLEX capability - * must always be set with creating multiple surfaces through CreateSurface. - */ -#define DDSCAPS_FLIP 0x00000010l - -/* - * Indicates that this surface is THE front buffer of a surface flipping - * structure. It is generally set by CreateSurface when the DDSCAPS_FLIP - * capability bit is set. - * If this capability is sent to CreateSurface then a standalonw front buffer - * is created. This surface will not have the DDSCAPS_FLIP capability. - * It can be attached to other back buffers to form a flipping structure. - * See AddAttachments for a detailed description of the behaviors in this - * case. - */ -#define DDSCAPS_FRONTBUFFER 0x00000020l - -/* - * Indicates that this surface is any offscreen surface that is not an overlay, - * texture, zbuffer, front buffer, back buffer, or alpha surface. It is used - * to identify plain vanilla surfaces. - */ -#define DDSCAPS_OFFSCREENPLAIN 0x00000040l - -/* - * Indicates that this surface is an overlay. It may or may not be directly visible - * depending on whether or not it is currently being overlayed onto the primary - * surface. DDSCAPS_VISIBLE can be used to determine whether or not it is being - * overlayed at the moment. - */ -#define DDSCAPS_OVERLAY 0x00000080l - -/* - * Indicates that unique DirectDrawPalette objects can be created and - * attached to this surface. - */ -#define DDSCAPS_PALETTE 0x00000100l - -/* - * Indicates that this surface is the primary surface. The primary - * surface represents what the user is seeing at the moment. - */ -#define DDSCAPS_PRIMARYSURFACE 0x00000200l - - -/* - * This flag used to be DDSCAPS_PRIMARYSURFACELEFT, which is now - * obsolete. - */ -#define DDSCAPS_RESERVED3 0x00000400l -#define DDSCAPS_PRIMARYSURFACELEFT 0x00000000l - -/* - * Indicates that this surface memory was allocated in system memory - */ -#define DDSCAPS_SYSTEMMEMORY 0x00000800l - -/* - * Indicates that this surface can be used as a 3D texture. It does not - * indicate whether or not the surface is being used for that purpose. - */ -#define DDSCAPS_TEXTURE 0x00001000l - -/* - * Indicates that a surface may be a destination for 3D rendering. This - * bit must be set in order to query for a Direct3D Device Interface - * from this surface. - */ -#define DDSCAPS_3DDEVICE 0x00002000l - -/* - * Indicates that this surface exists in video memory. - */ -#define DDSCAPS_VIDEOMEMORY 0x00004000l - -/* - * Indicates that changes made to this surface are immediately visible. - * It is always set for the primary surface and is set for overlays while - * they are being overlayed and texture maps while they are being textured. - */ -#define DDSCAPS_VISIBLE 0x00008000l - -/* - * Indicates that only writes are permitted to the surface. Read accesses - * from the surface may or may not generate a protection fault, but the - * results of a read from this surface will not be meaningful. READ ONLY. - */ -#define DDSCAPS_WRITEONLY 0x00010000l - -/* - * Indicates that this surface is a z buffer. A z buffer does not contain - * displayable information. Instead it contains bit depth information that is - * used to determine which pixels are visible and which are obscured. - */ -#define DDSCAPS_ZBUFFER 0x00020000l - -/* - * Indicates surface will have a DC associated long term - */ -#define DDSCAPS_OWNDC 0x00040000l - -/* - * Indicates surface should be able to receive live video - */ -#define DDSCAPS_LIVEVIDEO 0x00080000l - -/* - * Indicates surface should be able to have a stream decompressed - * to it by the hardware. - */ -#define DDSCAPS_HWCODEC 0x00100000l - -/* - * Surface is a ModeX surface. - * - */ -#define DDSCAPS_MODEX 0x00200000l - -/* - * Indicates surface is one level of a mip-map. This surface will - * be attached to other DDSCAPS_MIPMAP surfaces to form the mip-map. - * This can be done explicitly, by creating a number of surfaces and - * attaching them with AddAttachedSurface or by implicitly by CreateSurface. - * If this bit is set then DDSCAPS_TEXTURE must also be set. - */ -#define DDSCAPS_MIPMAP 0x00400000l - -/* - * This bit is reserved. It should not be specified. - */ -#define DDSCAPS_RESERVED2 0x00800000l - - -/* - * Indicates that memory for the surface is not allocated until the surface - * is loaded (via the Direct3D texture Load() function). - */ -#define DDSCAPS_ALLOCONLOAD 0x04000000l - -/* - * Indicates that the surface will recieve data from a video port. - */ -#define DDSCAPS_VIDEOPORT 0x08000000l - -/* - * Indicates that a video memory surface is resident in true, local video - * memory rather than non-local video memory. If this flag is specified then - * so must DDSCAPS_VIDEOMEMORY. This flag is mutually exclusive with - * DDSCAPS_NONLOCALVIDMEM. - */ -#define DDSCAPS_LOCALVIDMEM 0x10000000l - -/* - * Indicates that a video memory surface is resident in non-local video - * memory rather than true, local video memory. If this flag is specified - * then so must DDSCAPS_VIDEOMEMORY. This flag is mutually exclusive with - * DDSCAPS_LOCALVIDMEM. - */ -#define DDSCAPS_NONLOCALVIDMEM 0x20000000l - -/* - * Indicates that this surface is a standard VGA mode surface, and not a - * ModeX surface. (This flag will never be set in combination with the - * DDSCAPS_MODEX flag). - */ -#define DDSCAPS_STANDARDVGAMODE 0x40000000l - -/* - * Indicates that this surface will be an optimized surface. This flag is - * currently only valid in conjunction with the DDSCAPS_TEXTURE flag. The surface - * will be created without any underlying video memory until loaded. - */ -#define DDSCAPS_OPTIMIZED 0x80000000l - - - -/* - * This bit is reserved - */ -#define DDSCAPS2_RESERVED4 0x00000002L -#define DDSCAPS2_HARDWAREDEINTERLACE 0x00000000L - -/* - * Indicates to the driver that this surface will be locked very frequently - * (for procedural textures, dynamic lightmaps, etc). Surfaces with this cap - * set must also have DDSCAPS_TEXTURE. This cap cannot be used with - * DDSCAPS2_HINTSTATIC and DDSCAPS2_OPAQUE. - */ -#define DDSCAPS2_HINTDYNAMIC 0x00000004L - -/* - * Indicates to the driver that this surface can be re-ordered/retiled on - * load. This operation will not change the size of the texture. It is - * relatively fast and symmetrical, since the application may lock these - * bits (although it will take a performance hit when doing so). Surfaces - * with this cap set must also have DDSCAPS_TEXTURE. This cap cannot be - * used with DDSCAPS2_HINTDYNAMIC and DDSCAPS2_OPAQUE. - */ -#define DDSCAPS2_HINTSTATIC 0x00000008L - -/* - * Indicates that the client would like this texture surface to be managed by the - * DirectDraw/Direct3D runtime. Surfaces with this cap set must also have - * DDSCAPS_TEXTURE set. - */ -#define DDSCAPS2_TEXTUREMANAGE 0x00000010L - -/* - * These bits are reserved for internal use */ -#define DDSCAPS2_RESERVED1 0x00000020L -#define DDSCAPS2_RESERVED2 0x00000040L - -/* - * Indicates to the driver that this surface will never be locked again. - * The driver is free to optimize this surface via retiling and actual compression. - * All calls to Lock() or Blts from this surface will fail. Surfaces with this - * cap set must also have DDSCAPS_TEXTURE. This cap cannot be used with - * DDSCAPS2_HINTDYNAMIC and DDSCAPS2_HINTSTATIC. - */ -#define DDSCAPS2_OPAQUE 0x00000080L - -/* - * Applications should set this bit at CreateSurface time to indicate that they - * intend to use antialiasing. Only valid if DDSCAPS_3DDEVICE is also set. - */ -#define DDSCAPS2_HINTANTIALIASING 0x00000100L - - -/* - * This flag is used at CreateSurface time to indicate that this set of - * surfaces is a cubic environment map - */ -#define DDSCAPS2_CUBEMAP 0x00000200L - -/* - * These flags preform two functions: - * - At CreateSurface time, they define which of the six cube faces are - * required by the application. - * - After creation, each face in the cubemap will have exactly one of these - * bits set. - */ -#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400L -#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800L -#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000L -#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000L -#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000L -#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000L - -/* - * This macro may be used to specify all faces of a cube map at CreateSurface time - */ -#define DDSCAPS2_CUBEMAP_ALLFACES ( DDSCAPS2_CUBEMAP_POSITIVEX |\ - DDSCAPS2_CUBEMAP_NEGATIVEX |\ - DDSCAPS2_CUBEMAP_POSITIVEY |\ - DDSCAPS2_CUBEMAP_NEGATIVEY |\ - DDSCAPS2_CUBEMAP_POSITIVEZ |\ - DDSCAPS2_CUBEMAP_NEGATIVEZ ) - - -/* - * This flag is an additional flag which is present on mipmap sublevels from DX7 onwards - * It enables easier use of GetAttachedSurface rather than EnumAttachedSurfaces for surface - * constructs such as Cube Maps, wherein there are more than one mipmap surface attached - * to the root surface. - * This caps bit is ignored by CreateSurface - */ -#define DDSCAPS2_MIPMAPSUBLEVEL 0x00010000L - -/* This flag indicates that the texture should be managed by D3D only */ -#define DDSCAPS2_D3DTEXTUREMANAGE 0x00020000L - -/* This flag indicates that the managed surface can be safely lost */ -#define DDSCAPS2_DONOTPERSIST 0x00040000L - -/* indicates that this surface is part of a stereo flipping chain */ -#define DDSCAPS2_STEREOSURFACELEFT 0x00080000L - - -/* - * Indicates that the surface is a volume. - * Can be combined with DDSCAPS_MIPMAP to indicate a multi-level volume - */ -#define DDSCAPS2_VOLUME 0x00200000L - -/* - * Indicates that the surface may be locked multiple times by the application. - * This cap cannot be used with DDSCAPS2_OPAQUE. - */ -#define DDSCAPS2_NOTUSERLOCKABLE 0x00400000L - -/* - * Indicates that the vertex buffer data can be used to render points and - * point sprites. - */ -#define DDSCAPS2_POINTS 0x00800000L - -/* - * Indicates that the vertex buffer data can be used to render rt pactches. - */ -#define DDSCAPS2_RTPATCHES 0x01000000L - -/* - * Indicates that the vertex buffer data can be used to render n patches. - */ -#define DDSCAPS2_NPATCHES 0x02000000L - -/* - * This bit is reserved for internal use - */ -#define DDSCAPS2_RESERVED3 0x04000000L - - -/* - * Indicates that the contents of the backbuffer do not have to be preserved - * the contents of the backbuffer after they are presented. - */ -#define DDSCAPS2_DISCARDBACKBUFFER 0x10000000L - -/* - * Indicates that all surfaces in this creation chain should be given an alpha channel. - * This flag will be set on primary surface chains that may have no explicit pixel format - * (and thus take on the format of the current display mode). - * The driver should infer that all these surfaces have a format having an alpha channel. - * (e.g. assume D3DFMT_A8R8G8B8 if the display mode is x888.) - */ -#define DDSCAPS2_ENABLEALPHACHANNEL 0x20000000L - -/* - * Indicates that all surfaces in this creation chain is extended primary surface format. - * This flag will be set on extended primary surface chains that always have explicit pixel - * format and the pixel format is typically GDI (Graphics Device Interface) couldn't handle, - * thus only used with fullscreen application. (e.g. D3DFMT_A2R10G10B10 format) - */ -#define DDSCAPS2_EXTENDEDFORMATPRIMARY 0x40000000L - -/* - * Indicates that all surfaces in this creation chain is additional primary surface. - * This flag will be set on primary surface chains which must present on the adapter - * id provided on dwCaps4. Typically this will be used to create secondary primary surface - * on DualView display adapter. - */ -#define DDSCAPS2_ADDITIONALPRIMARY 0x80000000L - -/* - * This is a mask that indicates the set of bits that may be set - * at createsurface time to indicate number of samples per pixel - * when multisampling - */ -#define DDSCAPS3_MULTISAMPLE_MASK 0x0000001FL - -/* - * This is a mask that indicates the set of bits that may be set - * at createsurface time to indicate the quality level of rendering - * for the current number of samples per pixel - */ -#define DDSCAPS3_MULTISAMPLE_QUALITY_MASK 0x000000E0L -#define DDSCAPS3_MULTISAMPLE_QUALITY_SHIFT 5 - -/* - * This bit is reserved for internal use - */ -#define DDSCAPS3_RESERVED1 0x00000100L - -/* - * This bit is reserved for internal use - */ -#define DDSCAPS3_RESERVED2 0x00000200L - -/* - * This indicates whether this surface has light-weight miplevels - */ -#define DDSCAPS3_LIGHTWEIGHTMIPMAP 0x00000400L - -/* - * This indicates that the mipsublevels for this surface are auto-generated - */ -#define DDSCAPS3_AUTOGENMIPMAP 0x00000800L - -/* - * This indicates that the mipsublevels for this surface are auto-generated - */ -#define DDSCAPS3_DMAP 0x00001000L - - - /**************************************************************************** - * - * DIRECTDRAW DRIVER CAPABILITY FLAGS - * - ****************************************************************************/ - -/* - * Display hardware has 3D acceleration. - */ -#define DDCAPS_3D 0x00000001l - -/* - * Indicates that DirectDraw will support only dest rectangles that are aligned - * on DIRECTDRAWCAPS.dwAlignBoundaryDest boundaries of the surface, respectively. - * READ ONLY. - */ -#define DDCAPS_ALIGNBOUNDARYDEST 0x00000002l - -/* - * Indicates that DirectDraw will support only source rectangles whose sizes in - * BYTEs are DIRECTDRAWCAPS.dwAlignSizeDest multiples, respectively. READ ONLY. - */ -#define DDCAPS_ALIGNSIZEDEST 0x00000004l -/* - * Indicates that DirectDraw will support only source rectangles that are aligned - * on DIRECTDRAWCAPS.dwAlignBoundarySrc boundaries of the surface, respectively. - * READ ONLY. - */ -#define DDCAPS_ALIGNBOUNDARYSRC 0x00000008l - -/* - * Indicates that DirectDraw will support only source rectangles whose sizes in - * BYTEs are DIRECTDRAWCAPS.dwAlignSizeSrc multiples, respectively. READ ONLY. - */ -#define DDCAPS_ALIGNSIZESRC 0x00000010l - -/* - * Indicates that DirectDraw will create video memory surfaces that have a stride - * alignment equal to DIRECTDRAWCAPS.dwAlignStride. READ ONLY. - */ -#define DDCAPS_ALIGNSTRIDE 0x00000020l - -/* - * Display hardware is capable of blt operations. - */ -#define DDCAPS_BLT 0x00000040l - -/* - * Display hardware is capable of asynchronous blt operations. - */ -#define DDCAPS_BLTQUEUE 0x00000080l - -/* - * Display hardware is capable of color space conversions during the blt operation. - */ -#define DDCAPS_BLTFOURCC 0x00000100l - -/* - * Display hardware is capable of stretching during blt operations. - */ -#define DDCAPS_BLTSTRETCH 0x00000200l - -/* - * Display hardware is shared with GDI. - */ -#define DDCAPS_GDI 0x00000400l - -/* - * Display hardware can overlay. - */ -#define DDCAPS_OVERLAY 0x00000800l - -/* - * Set if display hardware supports overlays but can not clip them. - */ -#define DDCAPS_OVERLAYCANTCLIP 0x00001000l - -/* - * Indicates that overlay hardware is capable of color space conversions during - * the overlay operation. - */ -#define DDCAPS_OVERLAYFOURCC 0x00002000l - -/* - * Indicates that stretching can be done by the overlay hardware. - */ -#define DDCAPS_OVERLAYSTRETCH 0x00004000l - -/* - * Indicates that unique DirectDrawPalettes can be created for DirectDrawSurfaces - * other than the primary surface. - */ -#define DDCAPS_PALETTE 0x00008000l - -/* - * Indicates that palette changes can be syncd with the veritcal refresh. - */ -#define DDCAPS_PALETTEVSYNC 0x00010000l - -/* - * Display hardware can return the current scan line. - */ -#define DDCAPS_READSCANLINE 0x00020000l - - -/* - * This flag used to bo DDCAPS_STEREOVIEW, which is now obsolete - */ -#define DDCAPS_RESERVED1 0x00040000l - -/* - * Display hardware is capable of generating a vertical blank interrupt. - */ -#define DDCAPS_VBI 0x00080000l - -/* - * Supports the use of z buffers with blt operations. - */ -#define DDCAPS_ZBLTS 0x00100000l - -/* - * Supports Z Ordering of overlays. - */ -#define DDCAPS_ZOVERLAYS 0x00200000l - -/* - * Supports color key - */ -#define DDCAPS_COLORKEY 0x00400000l - -/* - * Supports alpha surfaces - */ -#define DDCAPS_ALPHA 0x00800000l - -/* - * colorkey is hardware assisted(DDCAPS_COLORKEY will also be set) - */ -#define DDCAPS_COLORKEYHWASSIST 0x01000000l - -/* - * no hardware support at all - */ -#define DDCAPS_NOHARDWARE 0x02000000l - -/* - * Display hardware is capable of color fill with bltter - */ -#define DDCAPS_BLTCOLORFILL 0x04000000l - -/* - * Display hardware is bank switched, and potentially very slow at - * random access to VRAM. - */ -#define DDCAPS_BANKSWITCHED 0x08000000l - -/* - * Display hardware is capable of depth filling Z-buffers with bltter - */ -#define DDCAPS_BLTDEPTHFILL 0x10000000l - -/* - * Display hardware is capable of clipping while bltting. - */ -#define DDCAPS_CANCLIP 0x20000000l - -/* - * Display hardware is capable of clipping while stretch bltting. - */ -#define DDCAPS_CANCLIPSTRETCHED 0x40000000l - -/* - * Display hardware is capable of bltting to or from system memory - */ -#define DDCAPS_CANBLTSYSMEM 0x80000000l - - - /**************************************************************************** - * - * MORE DIRECTDRAW DRIVER CAPABILITY FLAGS (dwCaps2) - * - ****************************************************************************/ - -/* - * Display hardware is certified - */ -#define DDCAPS2_CERTIFIED 0x00000001l - -/* - * Driver cannot interleave 2D operations (lock and blt) to surfaces with - * Direct3D rendering operations between calls to BeginScene() and EndScene() - */ -#define DDCAPS2_NO2DDURING3DSCENE 0x00000002l - -/* - * Display hardware contains a video port - */ -#define DDCAPS2_VIDEOPORT 0x00000004l - -/* - * The overlay can be automatically flipped according to the video port - * VSYNCs, providing automatic doubled buffered display of video port - * data using an overlay - */ -#define DDCAPS2_AUTOFLIPOVERLAY 0x00000008l - -/* - * Overlay can display each field of interlaced data individually while - * it is interleaved in memory without causing jittery artifacts. - */ -#define DDCAPS2_CANBOBINTERLEAVED 0x00000010l - -/* - * Overlay can display each field of interlaced data individually while - * it is not interleaved in memory without causing jittery artifacts. - */ -#define DDCAPS2_CANBOBNONINTERLEAVED 0x00000020l - -/* - * The overlay surface contains color controls (brightness, sharpness, etc.) - */ -#define DDCAPS2_COLORCONTROLOVERLAY 0x00000040l - -/* - * The primary surface contains color controls (gamma, etc.) - */ -#define DDCAPS2_COLORCONTROLPRIMARY 0x00000080l - -/* - * RGBZ -> RGB supported for 16:16 RGB:Z - */ -#define DDCAPS2_CANDROPZ16BIT 0x00000100l - -/* - * Driver supports non-local video memory. - */ -#define DDCAPS2_NONLOCALVIDMEM 0x00000200l - -/* - * Dirver supports non-local video memory but has different capabilities for - * non-local video memory surfaces. If this bit is set then so must - * DDCAPS2_NONLOCALVIDMEM. - */ -#define DDCAPS2_NONLOCALVIDMEMCAPS 0x00000400l - -/* - * Driver neither requires nor prefers surfaces to be pagelocked when performing - * blts involving system memory surfaces - */ -#define DDCAPS2_NOPAGELOCKREQUIRED 0x00000800l - -/* - * Driver can create surfaces which are wider than the primary surface - */ -#define DDCAPS2_WIDESURFACES 0x00001000l - -/* - * Driver supports bob without using a video port by handling the - * DDFLIP_ODD and DDFLIP_EVEN flags specified in Flip. - */ -#define DDCAPS2_CANFLIPODDEVEN 0x00002000l - -/* - * Driver supports bob using hardware - */ -#define DDCAPS2_CANBOBHARDWARE 0x00004000l - -/* - * Driver supports bltting any FOURCC surface to another surface of the same FOURCC - */ -#define DDCAPS2_COPYFOURCC 0x00008000l - - -/* - * Driver supports loadable gamma ramps for the primary surface - */ -#define DDCAPS2_PRIMARYGAMMA 0x00020000l - -/* - * Driver can render in windowed mode. - */ -#define DDCAPS2_CANRENDERWINDOWED 0x00080000l - -/* - * A calibrator is available to adjust the gamma ramp according to the - * physical display properties so that the result will be identical on - * all calibrated systems. - */ -#define DDCAPS2_CANCALIBRATEGAMMA 0x00100000l - -/* - * Indicates that the driver will respond to DDFLIP_INTERVALn flags - */ -#define DDCAPS2_FLIPINTERVAL 0x00200000l - -/* - * Indicates that the driver will respond to DDFLIP_NOVSYNC - */ -#define DDCAPS2_FLIPNOVSYNC 0x00400000l - -/* - * Driver supports management of video memory, if this flag is ON, - * driver manages the texture if requested with DDSCAPS2_TEXTUREMANAGE on - * DirectX manages the texture if this flag is OFF and surface has DDSCAPS2_TEXTUREMANAGE on - */ -#define DDCAPS2_CANMANAGETEXTURE 0x00800000l - -/* - * The Direct3D texture manager uses this cap to decide whether to put managed - * surfaces in non-local video memory. If the cap is set, the texture manager will - * put managed surfaces in non-local vidmem. Drivers that cannot texture from - * local vidmem SHOULD NOT set this cap. - */ -#define DDCAPS2_TEXMANINNONLOCALVIDMEM 0x01000000l - -/* - * Indicates that the driver supports DX7 type of stereo in at least one mode (which may - * not necessarily be the current mode). Applications should use IDirectDraw7 (or higher) - * ::EnumDisplayModes and check the DDSURFACEDESC.ddsCaps.dwCaps2 field for the presence of - * DDSCAPS2_STEREOSURFACELEFT to check if a particular mode supports stereo. The application - * can also use IDirectDraw7(or higher)::GetDisplayMode to check the current mode. - */ -#define DDCAPS2_STEREO 0x02000000L - -/* - * This caps bit is intended for internal DirectDraw use. - * -It is only valid if DDCAPS2_NONLOCALVIDMEMCAPS is set. - * -If this bit is set, then DDCAPS_CANBLTSYSMEM MUST be set by the driver (and - * all the assoicated system memory blt caps must be correct). - * -It implies that the system->video blt caps in DDCAPS also apply to system to - * nonlocal blts. I.e. the dwSVBCaps, dwSVBCKeyCaps, dwSVBFXCaps and dwSVBRops - * members of DDCAPS (DDCORECAPS) are filled in correctly. - * -Any blt from system to nonlocal memory that matches these caps bits will - * be passed to the driver. - * - * NOTE: This is intended to enable the driver itself to do efficient reordering - * of textures. This is NOT meant to imply that hardware can write into AGP memory. - * This operation is not currently supported. - */ -#define DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL 0x04000000L - -/* - * was DDCAPS2_PUREHAL - */ -#define DDCAPS2_RESERVED1 0x08000000L - -/* - * Driver supports management of video memory, if this flag is ON, - * driver manages the resource if requested with DDSCAPS2_TEXTUREMANAGE on - * DirectX manages the resource if this flag is OFF and surface has DDSCAPS2_TEXTUREMANAGE on - */ -#define DDCAPS2_CANMANAGERESOURCE 0x10000000L - -/* - * Driver supports dynamic textures. This will allow the application to set - * D3DUSAGE_DYNAMIC (DDSCAPS2_HINTDYNAMIC for drivers) at texture create time. - * Video memory dynamic textures WILL be lockable by applications. It is - * expected that these locks will be very efficient (which implies that the - * driver should always maintain a linear copy, a pointer to which can be - * quickly handed out to the application). - */ -#define DDCAPS2_DYNAMICTEXTURES 0x20000000L - -/* - * Driver supports auto-generation of mipmaps. - */ -#define DDCAPS2_CANAUTOGENMIPMAP 0x40000000L - - -/**************************************************************************** - * - * DIRECTDRAW FX ALPHA CAPABILITY FLAGS - * - ****************************************************************************/ - -/* - * Supports alpha blending around the edge of a source color keyed surface. - * For Blt. - */ -#define DDFXALPHACAPS_BLTALPHAEDGEBLEND 0x00000001l - -/* - * Supports alpha information in the pixel format. The bit depth of alpha - * information in the pixel format can be 1,2,4, or 8. The alpha value becomes - * more opaque as the alpha value increases. (0 is transparent.) - * For Blt. - */ -#define DDFXALPHACAPS_BLTALPHAPIXELS 0x00000002l - -/* - * Supports alpha information in the pixel format. The bit depth of alpha - * information in the pixel format can be 1,2,4, or 8. The alpha value - * becomes more transparent as the alpha value increases. (0 is opaque.) - * This flag can only be set if DDCAPS_ALPHA is set. - * For Blt. - */ -#define DDFXALPHACAPS_BLTALPHAPIXELSNEG 0x00000004l - -/* - * Supports alpha only surfaces. The bit depth of an alpha only surface can be - * 1,2,4, or 8. The alpha value becomes more opaque as the alpha value increases. - * (0 is transparent.) - * For Blt. - */ -#define DDFXALPHACAPS_BLTALPHASURFACES 0x00000008l - -/* - * The depth of the alpha channel data can range can be 1,2,4, or 8. - * The NEG suffix indicates that this alpha channel becomes more transparent - * as the alpha value increases. (0 is opaque.) This flag can only be set if - * DDCAPS_ALPHA is set. - * For Blt. - */ -#define DDFXALPHACAPS_BLTALPHASURFACESNEG 0x00000010l - -/* - * Supports alpha blending around the edge of a source color keyed surface. - * For Overlays. - */ -#define DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND 0x00000020l - -/* - * Supports alpha information in the pixel format. The bit depth of alpha - * information in the pixel format can be 1,2,4, or 8. The alpha value becomes - * more opaque as the alpha value increases. (0 is transparent.) - * For Overlays. - */ -#define DDFXALPHACAPS_OVERLAYALPHAPIXELS 0x00000040l - -/* - * Supports alpha information in the pixel format. The bit depth of alpha - * information in the pixel format can be 1,2,4, or 8. The alpha value - * becomes more transparent as the alpha value increases. (0 is opaque.) - * This flag can only be set if DDCAPS_ALPHA is set. - * For Overlays. - */ -#define DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG 0x00000080l - -/* - * Supports alpha only surfaces. The bit depth of an alpha only surface can be - * 1,2,4, or 8. The alpha value becomes more opaque as the alpha value increases. - * (0 is transparent.) - * For Overlays. - */ -#define DDFXALPHACAPS_OVERLAYALPHASURFACES 0x00000100l - -/* - * The depth of the alpha channel data can range can be 1,2,4, or 8. - * The NEG suffix indicates that this alpha channel becomes more transparent - * as the alpha value increases. (0 is opaque.) This flag can only be set if - * DDCAPS_ALPHA is set. - * For Overlays. - */ -#define DDFXALPHACAPS_OVERLAYALPHASURFACESNEG 0x00000200l - -#if DIRECTDRAW_VERSION < 0x0600 -#endif //DIRECTDRAW_VERSION - - -/**************************************************************************** - * - * DIRECTDRAW FX CAPABILITY FLAGS - * - ****************************************************************************/ - -/* - * Uses arithmetic operations to stretch and shrink surfaces during blt - * rather than pixel doubling techniques. Along the Y axis. - */ -#define DDFXCAPS_BLTARITHSTRETCHY 0x00000020l - -/* - * Uses arithmetic operations to stretch during blt - * rather than pixel doubling techniques. Along the Y axis. Only - * works for x1, x2, etc. - */ -#define DDFXCAPS_BLTARITHSTRETCHYN 0x00000010l - -/* - * Supports mirroring left to right in blt. - */ -#define DDFXCAPS_BLTMIRRORLEFTRIGHT 0x00000040l - -/* - * Supports mirroring top to bottom in blt. - */ -#define DDFXCAPS_BLTMIRRORUPDOWN 0x00000080l - -/* - * Supports arbitrary rotation for blts. - */ -#define DDFXCAPS_BLTROTATION 0x00000100l - -/* - * Supports 90 degree rotations for blts. - */ -#define DDFXCAPS_BLTROTATION90 0x00000200l - -/* - * DirectDraw supports arbitrary shrinking of a surface along the - * x axis (horizontal direction) for blts. - */ -#define DDFXCAPS_BLTSHRINKX 0x00000400l - -/* - * DirectDraw supports integer shrinking (1x,2x,) of a surface - * along the x axis (horizontal direction) for blts. - */ -#define DDFXCAPS_BLTSHRINKXN 0x00000800l - -/* - * DirectDraw supports arbitrary shrinking of a surface along the - * y axis (horizontal direction) for blts. - */ -#define DDFXCAPS_BLTSHRINKY 0x00001000l - -/* - * DirectDraw supports integer shrinking (1x,2x,) of a surface - * along the y axis (vertical direction) for blts. - */ -#define DDFXCAPS_BLTSHRINKYN 0x00002000l - -/* - * DirectDraw supports arbitrary stretching of a surface along the - * x axis (horizontal direction) for blts. - */ -#define DDFXCAPS_BLTSTRETCHX 0x00004000l - -/* - * DirectDraw supports integer stretching (1x,2x,) of a surface - * along the x axis (horizontal direction) for blts. - */ -#define DDFXCAPS_BLTSTRETCHXN 0x00008000l - -/* - * DirectDraw supports arbitrary stretching of a surface along the - * y axis (horizontal direction) for blts. - */ -#define DDFXCAPS_BLTSTRETCHY 0x00010000l - -/* - * DirectDraw supports integer stretching (1x,2x,) of a surface - * along the y axis (vertical direction) for blts. - */ -#define DDFXCAPS_BLTSTRETCHYN 0x00020000l - -/* - * Uses arithmetic operations to stretch and shrink surfaces during - * overlay rather than pixel doubling techniques. Along the Y axis - * for overlays. - */ -#define DDFXCAPS_OVERLAYARITHSTRETCHY 0x00040000l - -/* - * Uses arithmetic operations to stretch surfaces during - * overlay rather than pixel doubling techniques. Along the Y axis - * for overlays. Only works for x1, x2, etc. - */ -#define DDFXCAPS_OVERLAYARITHSTRETCHYN 0x00000008l - -/* - * DirectDraw supports arbitrary shrinking of a surface along the - * x axis (horizontal direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSHRINKX 0x00080000l - -/* - * DirectDraw supports integer shrinking (1x,2x,) of a surface - * along the x axis (horizontal direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSHRINKXN 0x00100000l - -/* - * DirectDraw supports arbitrary shrinking of a surface along the - * y axis (horizontal direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSHRINKY 0x00200000l - -/* - * DirectDraw supports integer shrinking (1x,2x,) of a surface - * along the y axis (vertical direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSHRINKYN 0x00400000l - -/* - * DirectDraw supports arbitrary stretching of a surface along the - * x axis (horizontal direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSTRETCHX 0x00800000l - -/* - * DirectDraw supports integer stretching (1x,2x,) of a surface - * along the x axis (horizontal direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSTRETCHXN 0x01000000l - -/* - * DirectDraw supports arbitrary stretching of a surface along the - * y axis (horizontal direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSTRETCHY 0x02000000l - -/* - * DirectDraw supports integer stretching (1x,2x,) of a surface - * along the y axis (vertical direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSTRETCHYN 0x04000000l - -/* - * DirectDraw supports mirroring of overlays across the vertical axis - */ -#define DDFXCAPS_OVERLAYMIRRORLEFTRIGHT 0x08000000l - -/* - * DirectDraw supports mirroring of overlays across the horizontal axis - */ -#define DDFXCAPS_OVERLAYMIRRORUPDOWN 0x10000000l - -/* - * DirectDraw supports deinterlacing of overlay surfaces - */ -#define DDFXCAPS_OVERLAYDEINTERLACE 0x20000000l - -/* - * Driver can do alpha blending for blits. - */ -#define DDFXCAPS_BLTALPHA 0x00000001l - - -/* - * Driver can do surface-reconstruction filtering for warped blits. - */ -#define DDFXCAPS_BLTFILTER DDFXCAPS_BLTARITHSTRETCHY - -/* - * Driver can do alpha blending for overlays. - */ -#define DDFXCAPS_OVERLAYALPHA 0x00000004l - - -/* - * Driver can do surface-reconstruction filtering for warped overlays. - */ -#define DDFXCAPS_OVERLAYFILTER DDFXCAPS_OVERLAYARITHSTRETCHY - -/**************************************************************************** - * - * DIRECTDRAW STEREO VIEW CAPABILITIES - * - ****************************************************************************/ - -/* - * This flag used to be DDSVCAPS_ENIGMA, which is now obsolete - */ - -#define DDSVCAPS_RESERVED1 0x00000001l - -/* - * This flag used to be DDSVCAPS_FLICKER, which is now obsolete - */ -#define DDSVCAPS_RESERVED2 0x00000002l - -/* - * This flag used to be DDSVCAPS_REDBLUE, which is now obsolete - */ -#define DDSVCAPS_RESERVED3 0x00000004l - -/* - * This flag used to be DDSVCAPS_SPLIT, which is now obsolete - */ -#define DDSVCAPS_RESERVED4 0x00000008l - -/* - * The stereo view is accomplished with switching technology - */ - -#define DDSVCAPS_STEREOSEQUENTIAL 0x00000010L - - - -/**************************************************************************** - * - * DIRECTDRAWPALETTE CAPABILITIES - * - ****************************************************************************/ - -/* - * Index is 4 bits. There are sixteen color entries in the palette table. - */ -#define DDPCAPS_4BIT 0x00000001l - -/* - * Index is onto a 8 bit color index. This field is only valid with the - * DDPCAPS_1BIT, DDPCAPS_2BIT or DDPCAPS_4BIT capability and the target - * surface is in 8bpp. Each color entry is one byte long and is an index - * into destination surface's 8bpp palette. - */ -#define DDPCAPS_8BITENTRIES 0x00000002l - -/* - * Index is 8 bits. There are 256 color entries in the palette table. - */ -#define DDPCAPS_8BIT 0x00000004l - -/* - * Indicates that this DIRECTDRAWPALETTE should use the palette color array - * passed into the lpDDColorArray parameter to initialize the DIRECTDRAWPALETTE - * object. - * This flag is obsolete. DirectDraw always initializes the color array from - * the lpDDColorArray parameter. The definition remains for source-level - * compatibility. - */ -#define DDPCAPS_INITIALIZE 0x00000000l - -/* - * This palette is the one attached to the primary surface. Changing this - * table has immediate effect on the display unless DDPSETPAL_VSYNC is specified - * and supported. - */ -#define DDPCAPS_PRIMARYSURFACE 0x00000010l - -/* - * This palette is the one attached to the primary surface left. Changing - * this table has immediate effect on the display for the left eye unless - * DDPSETPAL_VSYNC is specified and supported. - */ -#define DDPCAPS_PRIMARYSURFACELEFT 0x00000020l - -/* - * This palette can have all 256 entries defined - */ -#define DDPCAPS_ALLOW256 0x00000040l - -/* - * This palette can have modifications to it synced with the monitors - * refresh rate. - */ -#define DDPCAPS_VSYNC 0x00000080l - -/* - * Index is 1 bit. There are two color entries in the palette table. - */ -#define DDPCAPS_1BIT 0x00000100l - -/* - * Index is 2 bit. There are four color entries in the palette table. - */ -#define DDPCAPS_2BIT 0x00000200l - -/* - * The peFlags member of PALETTEENTRY denotes an 8 bit alpha value - */ -#define DDPCAPS_ALPHA 0x00000400l - - -/**************************************************************************** - * - * DIRECTDRAWPALETTE SETENTRY CONSTANTS - * - ****************************************************************************/ - - -/**************************************************************************** - * - * DIRECTDRAWPALETTE GETENTRY CONSTANTS - * - ****************************************************************************/ - -/* 0 is the only legal value */ - -/**************************************************************************** - * - * DIRECTDRAWSURFACE SETPRIVATEDATA CONSTANTS - * - ****************************************************************************/ - -/* - * The passed pointer is an IUnknown ptr. The cbData argument to SetPrivateData - * must be set to sizeof(IUnknown*). DirectDraw will call AddRef through this - * pointer and Release when the private data is destroyed. This includes when - * the surface or palette is destroyed before such priovate data is destroyed. - */ -#define DDSPD_IUNKNOWNPOINTER 0x00000001L - -/* - * Private data is only valid for the current state of the object, - * as determined by the uniqueness value. - */ -#define DDSPD_VOLATILE 0x00000002L - - -/**************************************************************************** - * - * DIRECTDRAWSURFACE SETPALETTE CONSTANTS - * - ****************************************************************************/ - - -/**************************************************************************** - * - * DIRECTDRAW BITDEPTH CONSTANTS - * - * NOTE: These are only used to indicate supported bit depths. These - * are flags only, they are not to be used as an actual bit depth. The - * absolute numbers 1, 2, 4, 8, 16, 24 and 32 are used to indicate actual - * bit depths in a surface or for changing the display mode. - * - ****************************************************************************/ - -/* - * 1 bit per pixel. - */ -#define DDBD_1 0x00004000l - -/* - * 2 bits per pixel. - */ -#define DDBD_2 0x00002000l - -/* - * 4 bits per pixel. - */ -#define DDBD_4 0x00001000l - -/* - * 8 bits per pixel. - */ -#define DDBD_8 0x00000800l - -/* - * 16 bits per pixel. - */ -#define DDBD_16 0x00000400l - -/* - * 24 bits per pixel. - */ -#define DDBD_24 0X00000200l - -/* - * 32 bits per pixel. - */ -#define DDBD_32 0x00000100l - -/**************************************************************************** - * - * DIRECTDRAWSURFACE SET/GET COLOR KEY FLAGS - * - ****************************************************************************/ - -/* - * Set if the structure contains a color space. Not set if the structure - * contains a single color key. - */ -#define DDCKEY_COLORSPACE 0x00000001l - -/* - * Set if the structure specifies a color key or color space which is to be - * used as a destination color key for blt operations. - */ -#define DDCKEY_DESTBLT 0x00000002l - -/* - * Set if the structure specifies a color key or color space which is to be - * used as a destination color key for overlay operations. - */ -#define DDCKEY_DESTOVERLAY 0x00000004l - -/* - * Set if the structure specifies a color key or color space which is to be - * used as a source color key for blt operations. - */ -#define DDCKEY_SRCBLT 0x00000008l - -/* - * Set if the structure specifies a color key or color space which is to be - * used as a source color key for overlay operations. - */ -#define DDCKEY_SRCOVERLAY 0x00000010l - - -/**************************************************************************** - * - * DIRECTDRAW COLOR KEY CAPABILITY FLAGS - * - ****************************************************************************/ - -/* - * Supports transparent blting using a color key to identify the replaceable - * bits of the destination surface for RGB colors. - */ -#define DDCKEYCAPS_DESTBLT 0x00000001l - -/* - * Supports transparent blting using a color space to identify the replaceable - * bits of the destination surface for RGB colors. - */ -#define DDCKEYCAPS_DESTBLTCLRSPACE 0x00000002l - -/* - * Supports transparent blting using a color space to identify the replaceable - * bits of the destination surface for YUV colors. - */ -#define DDCKEYCAPS_DESTBLTCLRSPACEYUV 0x00000004l - -/* - * Supports transparent blting using a color key to identify the replaceable - * bits of the destination surface for YUV colors. - */ -#define DDCKEYCAPS_DESTBLTYUV 0x00000008l - -/* - * Supports overlaying using colorkeying of the replaceable bits of the surface - * being overlayed for RGB colors. - */ -#define DDCKEYCAPS_DESTOVERLAY 0x00000010l - -/* - * Supports a color space as the color key for the destination for RGB colors. - */ -#define DDCKEYCAPS_DESTOVERLAYCLRSPACE 0x00000020l - -/* - * Supports a color space as the color key for the destination for YUV colors. - */ -#define DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV 0x00000040l - -/* - * Supports only one active destination color key value for visible overlay - * surfaces. - */ -#define DDCKEYCAPS_DESTOVERLAYONEACTIVE 0x00000080l - -/* - * Supports overlaying using colorkeying of the replaceable bits of the - * surface being overlayed for YUV colors. - */ -#define DDCKEYCAPS_DESTOVERLAYYUV 0x00000100l - -/* - * Supports transparent blting using the color key for the source with - * this surface for RGB colors. - */ -#define DDCKEYCAPS_SRCBLT 0x00000200l - -/* - * Supports transparent blting using a color space for the source with - * this surface for RGB colors. - */ -#define DDCKEYCAPS_SRCBLTCLRSPACE 0x00000400l - -/* - * Supports transparent blting using a color space for the source with - * this surface for YUV colors. - */ -#define DDCKEYCAPS_SRCBLTCLRSPACEYUV 0x00000800l - -/* - * Supports transparent blting using the color key for the source with - * this surface for YUV colors. - */ -#define DDCKEYCAPS_SRCBLTYUV 0x00001000l - -/* - * Supports overlays using the color key for the source with this - * overlay surface for RGB colors. - */ -#define DDCKEYCAPS_SRCOVERLAY 0x00002000l - -/* - * Supports overlays using a color space as the source color key for - * the overlay surface for RGB colors. - */ -#define DDCKEYCAPS_SRCOVERLAYCLRSPACE 0x00004000l - -/* - * Supports overlays using a color space as the source color key for - * the overlay surface for YUV colors. - */ -#define DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV 0x00008000l - -/* - * Supports only one active source color key value for visible - * overlay surfaces. - */ -#define DDCKEYCAPS_SRCOVERLAYONEACTIVE 0x00010000l - -/* - * Supports overlays using the color key for the source with this - * overlay surface for YUV colors. - */ -#define DDCKEYCAPS_SRCOVERLAYYUV 0x00020000l - -/* - * there are no bandwidth trade-offs for using colorkey with an overlay - */ -#define DDCKEYCAPS_NOCOSTOVERLAY 0x00040000l - - -/**************************************************************************** - * - * DIRECTDRAW PIXELFORMAT FLAGS - * - ****************************************************************************/ - -/* - * The surface has alpha channel information in the pixel format. - */ -#define DDPF_ALPHAPIXELS 0x00000001l - -/* - * The pixel format contains alpha only information - */ -#define DDPF_ALPHA 0x00000002l - -/* - * The FourCC code is valid. - */ -#define DDPF_FOURCC 0x00000004l - -/* - * The surface is 4-bit color indexed. - */ -#define DDPF_PALETTEINDEXED4 0x00000008l - -/* - * The surface is indexed into a palette which stores indices - * into the destination surface's 8-bit palette. - */ -#define DDPF_PALETTEINDEXEDTO8 0x00000010l - -/* - * The surface is 8-bit color indexed. - */ -#define DDPF_PALETTEINDEXED8 0x00000020l - -/* - * The RGB data in the pixel format structure is valid. - */ -#define DDPF_RGB 0x00000040l - -/* - * The surface will accept pixel data in the format specified - * and compress it during the write. - */ -#define DDPF_COMPRESSED 0x00000080l - -/* - * The surface will accept RGB data and translate it during - * the write to YUV data. The format of the data to be written - * will be contained in the pixel format structure. The DDPF_RGB - * flag will be set. - */ -#define DDPF_RGBTOYUV 0x00000100l - -/* - * pixel format is YUV - YUV data in pixel format struct is valid - */ -#define DDPF_YUV 0x00000200l - -/* - * pixel format is a z buffer only surface - */ -#define DDPF_ZBUFFER 0x00000400l - -/* - * The surface is 1-bit color indexed. - */ -#define DDPF_PALETTEINDEXED1 0x00000800l - -/* - * The surface is 2-bit color indexed. - */ -#define DDPF_PALETTEINDEXED2 0x00001000l - -/* - * The surface contains Z information in the pixels - */ -#define DDPF_ZPIXELS 0x00002000l - -/* - * The surface contains stencil information along with Z - */ -#define DDPF_STENCILBUFFER 0x00004000l - -/* - * Premultiplied alpha format -- the color components have been - * premultiplied by the alpha component. - */ -#define DDPF_ALPHAPREMULT 0x00008000l - - -/* - * Luminance data in the pixel format is valid. - * Use this flag for luminance-only or luminance+alpha surfaces, - * the bit depth is then ddpf.dwLuminanceBitCount. - */ -#define DDPF_LUMINANCE 0x00020000l - -/* - * Luminance data in the pixel format is valid. - * Use this flag when hanging luminance off bumpmap surfaces, - * the bit mask for the luminance portion of the pixel is then - * ddpf.dwBumpLuminanceBitMask - */ -#define DDPF_BUMPLUMINANCE 0x00040000l - -/* - * Bump map dUdV data in the pixel format is valid. - */ -#define DDPF_BUMPDUDV 0x00080000l - - -/*=========================================================================== - * - * - * DIRECTDRAW CALLBACK FLAGS - * - * - *==========================================================================*/ - -/**************************************************************************** - * - * DIRECTDRAW ENUMSURFACES FLAGS - * - ****************************************************************************/ - -/* - * Enumerate all of the surfaces that meet the search criterion. - */ -#define DDENUMSURFACES_ALL 0x00000001l - -/* - * A search hit is a surface that matches the surface description. - */ -#define DDENUMSURFACES_MATCH 0x00000002l - -/* - * A search hit is a surface that does not match the surface description. - */ -#define DDENUMSURFACES_NOMATCH 0x00000004l - -/* - * Enumerate the first surface that can be created which meets the search criterion. - */ -#define DDENUMSURFACES_CANBECREATED 0x00000008l - -/* - * Enumerate the surfaces that already exist that meet the search criterion. - */ -#define DDENUMSURFACES_DOESEXIST 0x00000010l - - -/**************************************************************************** - * - * DIRECTDRAW SETDISPLAYMODE FLAGS - * - ****************************************************************************/ - -/* - * The desired mode is a standard VGA mode - */ -#define DDSDM_STANDARDVGAMODE 0x00000001l - - -/**************************************************************************** - * - * DIRECTDRAW ENUMDISPLAYMODES FLAGS - * - ****************************************************************************/ - -/* - * Enumerate Modes with different refresh rates. EnumDisplayModes guarantees - * that a particular mode will be enumerated only once. This flag specifies whether - * the refresh rate is taken into account when determining if a mode is unique. - */ -#define DDEDM_REFRESHRATES 0x00000001l - -/* - * Enumerate VGA modes. Specify this flag if you wish to enumerate supported VGA - * modes such as mode 0x13 in addition to the usual ModeX modes (which are always - * enumerated if the application has previously called SetCooperativeLevel with the - * DDSCL_ALLOWMODEX flag set). - */ -#define DDEDM_STANDARDVGAMODES 0x00000002L - - -/**************************************************************************** - * - * DIRECTDRAW SETCOOPERATIVELEVEL FLAGS - * - ****************************************************************************/ - -/* - * Exclusive mode owner will be responsible for the entire primary surface. - * GDI can be ignored. used with DD - */ -#define DDSCL_FULLSCREEN 0x00000001l - -/* - * allow CTRL_ALT_DEL to work while in fullscreen exclusive mode - */ -#define DDSCL_ALLOWREBOOT 0x00000002l - -/* - * prevents DDRAW from modifying the application window. - * prevents DDRAW from minimize/restore the application window on activation. - */ -#define DDSCL_NOWINDOWCHANGES 0x00000004l - -/* - * app wants to work as a regular Windows application - */ -#define DDSCL_NORMAL 0x00000008l - -/* - * app wants exclusive access - */ -#define DDSCL_EXCLUSIVE 0x00000010l - - -/* - * app can deal with non-windows display modes - */ -#define DDSCL_ALLOWMODEX 0x00000040l - -/* - * this window will receive the focus messages - */ -#define DDSCL_SETFOCUSWINDOW 0x00000080l - -/* - * this window is associated with the DDRAW object and will - * cover the screen in fullscreen mode - */ -#define DDSCL_SETDEVICEWINDOW 0x00000100l - -/* - * app wants DDRAW to create a window to be associated with the - * DDRAW object - */ -#define DDSCL_CREATEDEVICEWINDOW 0x00000200l - -/* - * App explicitly asks DDRAW/D3D to be multithread safe. This makes D3D - * take the global crtisec more frequently. - */ -#define DDSCL_MULTITHREADED 0x00000400l - -/* - * App specifies that it would like to keep the FPU set up for optimal Direct3D - * performance (single precision and exceptions disabled) so Direct3D - * does not need to explicitly set the FPU each time. This is assumed by - * default in DirectX 7. See also DDSCL_FPUPRESERVE - */ -#define DDSCL_FPUSETUP 0x00000800l - -/* - * App specifies that it needs either double precision FPU or FPU exceptions - * enabled. This makes Direct3D explicitly set the FPU state eah time it is - * called. Setting the flag will reduce Direct3D performance. The flag is - * assumed by default in DirectX 6 and earlier. See also DDSCL_FPUSETUP - */ -#define DDSCL_FPUPRESERVE 0x00001000l - - -/**************************************************************************** - * - * DIRECTDRAW BLT FLAGS - * - ****************************************************************************/ - -/* - * Use the alpha information in the pixel format or the alpha channel surface - * attached to the destination surface as the alpha channel for this blt. - */ -#define DDBLT_ALPHADEST 0x00000001l - -/* - * Use the dwConstAlphaDest field in the DDBLTFX structure as the alpha channel - * for the destination surface for this blt. - */ -#define DDBLT_ALPHADESTCONSTOVERRIDE 0x00000002l - -/* - * The NEG suffix indicates that the destination surface becomes more - * transparent as the alpha value increases. (0 is opaque) - */ -#define DDBLT_ALPHADESTNEG 0x00000004l - -/* - * Use the lpDDSAlphaDest field in the DDBLTFX structure as the alpha - * channel for the destination for this blt. - */ -#define DDBLT_ALPHADESTSURFACEOVERRIDE 0x00000008l - -/* - * Use the dwAlphaEdgeBlend field in the DDBLTFX structure as the alpha channel - * for the edges of the image that border the color key colors. - */ -#define DDBLT_ALPHAEDGEBLEND 0x00000010l - -/* - * Use the alpha information in the pixel format or the alpha channel surface - * attached to the source surface as the alpha channel for this blt. - */ -#define DDBLT_ALPHASRC 0x00000020l - -/* - * Use the dwConstAlphaSrc field in the DDBLTFX structure as the alpha channel - * for the source for this blt. - */ -#define DDBLT_ALPHASRCCONSTOVERRIDE 0x00000040l - -/* - * The NEG suffix indicates that the source surface becomes more transparent - * as the alpha value increases. (0 is opaque) - */ -#define DDBLT_ALPHASRCNEG 0x00000080l - -/* - * Use the lpDDSAlphaSrc field in the DDBLTFX structure as the alpha channel - * for the source for this blt. - */ -#define DDBLT_ALPHASRCSURFACEOVERRIDE 0x00000100l - -/* - * Do this blt asynchronously through the FIFO in the order received. If - * there is no room in the hardware FIFO fail the call. - */ -#define DDBLT_ASYNC 0x00000200l - -/* - * Uses the dwFillColor field in the DDBLTFX structure as the RGB color - * to fill the destination rectangle on the destination surface with. - */ -#define DDBLT_COLORFILL 0x00000400l - -/* - * Uses the dwDDFX field in the DDBLTFX structure to specify the effects - * to use for the blt. - */ -#define DDBLT_DDFX 0x00000800l - -/* - * Uses the dwDDROPS field in the DDBLTFX structure to specify the ROPS - * that are not part of the Win32 API. - */ -#define DDBLT_DDROPS 0x00001000l - -/* - * Use the color key associated with the destination surface. - */ -#define DDBLT_KEYDEST 0x00002000l - -/* - * Use the dckDestColorkey field in the DDBLTFX structure as the color key - * for the destination surface. - */ -#define DDBLT_KEYDESTOVERRIDE 0x00004000l - -/* - * Use the color key associated with the source surface. - */ -#define DDBLT_KEYSRC 0x00008000l - -/* - * Use the dckSrcColorkey field in the DDBLTFX structure as the color key - * for the source surface. - */ -#define DDBLT_KEYSRCOVERRIDE 0x00010000l - -/* - * Use the dwROP field in the DDBLTFX structure for the raster operation - * for this blt. These ROPs are the same as the ones defined in the Win32 API. - */ -#define DDBLT_ROP 0x00020000l - -/* - * Use the dwRotationAngle field in the DDBLTFX structure as the angle - * (specified in 1/100th of a degree) to rotate the surface. - */ -#define DDBLT_ROTATIONANGLE 0x00040000l - -/* - * Z-buffered blt using the z-buffers attached to the source and destination - * surfaces and the dwZBufferOpCode field in the DDBLTFX structure as the - * z-buffer opcode. - */ -#define DDBLT_ZBUFFER 0x00080000l - -/* - * Z-buffered blt using the dwConstDest Zfield and the dwZBufferOpCode field - * in the DDBLTFX structure as the z-buffer and z-buffer opcode respectively - * for the destination. - */ -#define DDBLT_ZBUFFERDESTCONSTOVERRIDE 0x00100000l - -/* - * Z-buffered blt using the lpDDSDestZBuffer field and the dwZBufferOpCode - * field in the DDBLTFX structure as the z-buffer and z-buffer opcode - * respectively for the destination. - */ -#define DDBLT_ZBUFFERDESTOVERRIDE 0x00200000l - -/* - * Z-buffered blt using the dwConstSrcZ field and the dwZBufferOpCode field - * in the DDBLTFX structure as the z-buffer and z-buffer opcode respectively - * for the source. - */ -#define DDBLT_ZBUFFERSRCCONSTOVERRIDE 0x00400000l - -/* - * Z-buffered blt using the lpDDSSrcZBuffer field and the dwZBufferOpCode - * field in the DDBLTFX structure as the z-buffer and z-buffer opcode - * respectively for the source. - */ -#define DDBLT_ZBUFFERSRCOVERRIDE 0x00800000l - -/* - * wait until the device is ready to handle the blt - * this will cause blt to not return DDERR_WASSTILLDRAWING - */ -#define DDBLT_WAIT 0x01000000l - -/* - * Uses the dwFillDepth field in the DDBLTFX structure as the depth value - * to fill the destination rectangle on the destination Z-buffer surface - * with. - */ -#define DDBLT_DEPTHFILL 0x02000000l - - -/* - * Return immediately (with DDERR_WASSTILLDRAWING) if the device is not - * ready to schedule the blt at the time Blt() is called. - */ -#define DDBLT_DONOTWAIT 0x08000000l - -/* - * These flags indicate a presentation blt (i.e. a blt - * that moves surface contents from an offscreen back buffer to the primary - * surface). The driver is not allowed to "queue" more than three such blts. - * The "end" of the presentation blt is indicated, since the - * blt may be clipped, in which case the runtime will call the driver with - * several blts. All blts (even if not clipped) are tagged with DDBLT_PRESENTATION - * and the last (even if not clipped) additionally with DDBLT_LAST_PRESENTATION. - * Thus the true rule is that the driver must not schedule a DDBLT_PRESENTATION - * blt if there are 3 or more DDBLT_PRESENTLAST blts in the hardware pipe. - * If there are such blts in the pipe, the driver should return DDERR_WASSTILLDRAWING - * until the oldest queued DDBLT_LAST_PRESENTATION blts has been retired (i.e. the - * pixels have been actually written to the primary surface). Once the oldest blt - * has been retired, the driver is free to schedule the current blt. - * The goal is to provide a mechanism whereby the device's hardware queue never - * gets more than 3 frames ahead of the frames being generated by the application. - * When excessive queueing occurs, applications become unusable because the application - * visibly lags user input, and such problems make windowed interactive applications impossible. - * Some drivers may not have sufficient knowledge of their hardware's FIFO to know - * when a certain blt has been retired. Such drivers should code cautiously, and - * simply not allow any frames to be queued at all. DDBLT_LAST_PRESENTATION should cause - * such drivers to return DDERR_WASSTILLDRAWING until the accelerator is completely - * finished- exactly as if the application had called Lock on the source surface - * before calling Blt. - * In other words, the driver is allowed and encouraged to - * generate as much latency as it can, but never more than 3 frames worth. - * Implementation detail: Drivers should count blts against the SOURCE surface, not - * against the primary surface. This enables multiple parallel windowed application - * to function more optimally. - * This flag is passed only to DX8 or higher drivers. - * - * APPLICATIONS DO NOT SET THESE FLAGS. THEY ARE SET BY THE DIRECTDRAW RUNTIME. - * - */ -#define DDBLT_PRESENTATION 0x10000000l -#define DDBLT_LAST_PRESENTATION 0x20000000l - -/* - * If DDBLT_EXTENDED_FLAGS is set, then the driver should re-interpret - * other flags according to the definitions that follow. - * For example, bit 0 (0x00000001L) means DDBLT_ALPHADEST, unless - * DDBLT_EXTENDED_FLAGS is also set, in which case bit 0 means - * DDBLT_EXTENDED_LINEAR_CONTENT. - * Only DirectX9 and higher drivers will be given extended blt flags. - * Only flags explicitly mentioned here should be re-interpreted. - * All other flags retain their original meanings. - * - * List of re-interpreted flags: - * - * Bit Hex value New meaning old meaning - * --------------------------------------------------------------- - * 2 0x00000004 DDBLT_EXTENDED_LINEAR_CONTENT DDBLT_ALPHADESTNEG - * 4 0x00000010 DDBLT_EXTENDED_PRESENTATION_STRETCHFACTOR DDBLT_ALPHAEDGEBLEND - * - * - * NOTE: APPLICATIONS SHOULD NOT SET THIS FLAG. THIS FLAG IS INTENDED - * FOR USE BY THE DIRECT3D RUNTIME. - */ -#define DDBLT_EXTENDED_FLAGS 0x40000000l - -/* - * EXTENDED FLAG. SEE DEFINITION OF DDBLT_EXTENDED_FLAGS. - * This flag indidcates that the source surface contains content in a - * linear color space. The driver may perform gamma correction to the - * desktop color space (i.e. sRGB, gamma 2.2) as part of this blt. - * If the device can perform such a conversion as part of the copy, - * the driver should also set D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION - * - * NOTE: APPLICATIONS SHOULD NOT SET THIS FLAG. THIS FLAG IS INTENDED - * FOR USE BY THE DIRECT3D RUNTIME. Use IDirect3DSwapChain9::Present - * and specify D3DPRESENT_LINEAR_CONTENT in order to use this functionality. - */ -#define DDBLT_EXTENDED_LINEAR_CONTENT 0x00000004l - - -/**************************************************************************** - * - * BLTFAST FLAGS - * - ****************************************************************************/ - -#define DDBLTFAST_NOCOLORKEY 0x00000000 -#define DDBLTFAST_SRCCOLORKEY 0x00000001 -#define DDBLTFAST_DESTCOLORKEY 0x00000002 -#define DDBLTFAST_WAIT 0x00000010 -#define DDBLTFAST_DONOTWAIT 0x00000020 - -/**************************************************************************** - * - * FLIP FLAGS - * - ****************************************************************************/ - -#define DDFLIP_WAIT 0x00000001L - -/* - * Indicates that the target surface contains the even field of video data. - * This flag is only valid with an overlay surface. - */ -#define DDFLIP_EVEN 0x00000002L - -/* - * Indicates that the target surface contains the odd field of video data. - * This flag is only valid with an overlay surface. - */ -#define DDFLIP_ODD 0x00000004L - -/* - * Causes DirectDraw to perform the physical flip immediately and return - * to the application. Typically, what was the front buffer but is now the back - * buffer will still be visible (depending on timing) until the next vertical - * retrace. Subsequent operations involving the two flipped surfaces will - * not check to see if the physical flip has finished (i.e. will not return - * DDERR_WASSTILLDRAWING for that reason (but may for other reasons)). - * This allows an application to perform Flips at a higher frequency than the - * monitor refresh rate, but may introduce visible artifacts. - * Only effective if DDCAPS2_FLIPNOVSYNC is set. If that bit is not set, - * DDFLIP_NOVSYNC has no effect. - */ -#define DDFLIP_NOVSYNC 0x00000008L - - -/* - * Flip Interval Flags. These flags indicate how many vertical retraces to wait between - * each flip. The default is one. DirectDraw will return DDERR_WASSTILLDRAWING for each - * surface involved in the flip until the specified number of vertical retraces has - * ocurred. Only effective if DDCAPS2_FLIPINTERVAL is set. If that bit is not set, - * DDFLIP_INTERVALn has no effect. - */ - -/* - * DirectDraw will flip on every other vertical sync - */ -#define DDFLIP_INTERVAL2 0x02000000L - - -/* - * DirectDraw will flip on every third vertical sync - */ -#define DDFLIP_INTERVAL3 0x03000000L - - -/* - * DirectDraw will flip on every fourth vertical sync - */ -#define DDFLIP_INTERVAL4 0x04000000L - -/* - * DirectDraw will flip and display a main stereo surface - */ -#define DDFLIP_STEREO 0x00000010L - -/* - * On IDirectDrawSurface7 and higher interfaces, the default is DDFLIP_WAIT. If you wish - * to override the default and use time when the accelerator is busy (as denoted by - * the DDERR_WASSTILLDRAWING return code) then use DDFLIP_DONOTWAIT. - */ -#define DDFLIP_DONOTWAIT 0x00000020L - - -/**************************************************************************** - * - * DIRECTDRAW SURFACE OVERLAY FLAGS - * - ****************************************************************************/ - -/* - * Use the alpha information in the pixel format or the alpha channel surface - * attached to the destination surface as the alpha channel for the - * destination overlay. - */ -#define DDOVER_ALPHADEST 0x00000001l - -/* - * Use the dwConstAlphaDest field in the DDOVERLAYFX structure as the - * destination alpha channel for this overlay. - */ -#define DDOVER_ALPHADESTCONSTOVERRIDE 0x00000002l - -/* - * The NEG suffix indicates that the destination surface becomes more - * transparent as the alpha value increases. - */ -#define DDOVER_ALPHADESTNEG 0x00000004l - -/* - * Use the lpDDSAlphaDest field in the DDOVERLAYFX structure as the alpha - * channel destination for this overlay. - */ -#define DDOVER_ALPHADESTSURFACEOVERRIDE 0x00000008l - -/* - * Use the dwAlphaEdgeBlend field in the DDOVERLAYFX structure as the alpha - * channel for the edges of the image that border the color key colors. - */ -#define DDOVER_ALPHAEDGEBLEND 0x00000010l - -/* - * Use the alpha information in the pixel format or the alpha channel surface - * attached to the source surface as the source alpha channel for this overlay. - */ -#define DDOVER_ALPHASRC 0x00000020l - -/* - * Use the dwConstAlphaSrc field in the DDOVERLAYFX structure as the source - * alpha channel for this overlay. - */ -#define DDOVER_ALPHASRCCONSTOVERRIDE 0x00000040l - -/* - * The NEG suffix indicates that the source surface becomes more transparent - * as the alpha value increases. - */ -#define DDOVER_ALPHASRCNEG 0x00000080l - -/* - * Use the lpDDSAlphaSrc field in the DDOVERLAYFX structure as the alpha channel - * source for this overlay. - */ -#define DDOVER_ALPHASRCSURFACEOVERRIDE 0x00000100l - -/* - * Turn this overlay off. - */ -#define DDOVER_HIDE 0x00000200l - -/* - * Use the color key associated with the destination surface. - */ -#define DDOVER_KEYDEST 0x00000400l - -/* - * Use the dckDestColorkey field in the DDOVERLAYFX structure as the color key - * for the destination surface - */ -#define DDOVER_KEYDESTOVERRIDE 0x00000800l - -/* - * Use the color key associated with the source surface. - */ -#define DDOVER_KEYSRC 0x00001000l - -/* - * Use the dckSrcColorkey field in the DDOVERLAYFX structure as the color key - * for the source surface. - */ -#define DDOVER_KEYSRCOVERRIDE 0x00002000l - -/* - * Turn this overlay on. - */ -#define DDOVER_SHOW 0x00004000l - -/* - * Add a dirty rect to an emulated overlayed surface. - */ -#define DDOVER_ADDDIRTYRECT 0x00008000l - -/* - * Redraw all dirty rects on an emulated overlayed surface. - */ -#define DDOVER_REFRESHDIRTYRECTS 0x00010000l - -/* - * Redraw the entire surface on an emulated overlayed surface. - */ -#define DDOVER_REFRESHALL 0x00020000l - - -/* - * Use the overlay FX flags to define special overlay FX - */ -#define DDOVER_DDFX 0x00080000l - -/* - * Autoflip the overlay when ever the video port autoflips - */ -#define DDOVER_AUTOFLIP 0x00100000l - -/* - * Display each field of video port data individually without - * causing any jittery artifacts - */ -#define DDOVER_BOB 0x00200000l - -/* - * Indicates that bob/weave decisions should not be overridden by other - * interfaces. - */ -#define DDOVER_OVERRIDEBOBWEAVE 0x00400000l - -/* - * Indicates that the surface memory is composed of interleaved fields. - */ -#define DDOVER_INTERLEAVED 0x00800000l - -/* - * Indicates that bob will be performed using hardware rather than - * software or emulated. - */ -#define DDOVER_BOBHARDWARE 0x01000000l - -/* - * Indicates that overlay FX structure contains valid ARGB scaling factors. - */ -#define DDOVER_ARGBSCALEFACTORS 0x02000000l - -/* - * Indicates that ARGB scaling factors can be degraded to fit driver capabilities. - */ -#define DDOVER_DEGRADEARGBSCALING 0x04000000l - - -/**************************************************************************** - * - * DIRECTDRAWSURFACE LOCK FLAGS - * - ****************************************************************************/ - -/* - * The default. Set to indicate that Lock should return a valid memory pointer - * to the top of the specified rectangle. If no rectangle is specified then a - * pointer to the top of the surface is returned. - */ -#define DDLOCK_SURFACEMEMORYPTR 0x00000000L // default - -/* - * Set to indicate that Lock should wait until it can obtain a valid memory - * pointer before returning. If this bit is set, Lock will never return - * DDERR_WASSTILLDRAWING. - */ -#define DDLOCK_WAIT 0x00000001L - -/* - * Set if an event handle is being passed to Lock. Lock will trigger the event - * when it can return the surface memory pointer requested. - */ -#define DDLOCK_EVENT 0x00000002L - -/* - * Indicates that the surface being locked will only be read from. - */ -#define DDLOCK_READONLY 0x00000010L - -/* - * Indicates that the surface being locked will only be written to - */ -#define DDLOCK_WRITEONLY 0x00000020L - - -/* - * Indicates that a system wide lock should not be taken when this surface - * is locked. This has several advantages (cursor responsiveness, ability - * to call more Windows functions, easier debugging) when locking video - * memory surfaces. However, an application specifying this flag must - * comply with a number of conditions documented in the help file. - * Furthermore, this flag cannot be specified when locking the primary. - */ -#define DDLOCK_NOSYSLOCK 0x00000800L - -/* - * Used only with Direct3D Vertex Buffer Locks. Indicates that no vertices - * that were referred to in Draw*PrimtiveVB calls since the start of the - * frame (or the last lock without this flag) will be modified during the - * lock. This can be useful when one is only appending data to the vertex - * buffer - */ -#define DDLOCK_NOOVERWRITE 0x00001000L - -/* - * Indicates that no assumptions will be made about the contents of the - * surface or vertex buffer during this lock. - * This enables two things: - * - Direct3D or the driver may provide an alternative memory - * area as the vertex buffer. This is useful when one plans to clear the - * contents of the vertex buffer and fill in new data. - * - Drivers sometimes store surface data in a re-ordered format. - * When the application locks the surface, the driver is forced to un-re-order - * the surface data before allowing the application to see the surface contents. - * This flag is a hint to the driver that it can skip the un-re-ordering process - * since the application plans to overwrite every single pixel in the surface - * or locked rectangle (and so erase any un-re-ordered pixels anyway). - * Applications should always set this flag when they intend to overwrite the entire - * surface or locked rectangle. - */ -#define DDLOCK_DISCARDCONTENTS 0x00002000L - /* - * DDLOCK_OKTOSWAP is an older, less informative name for DDLOCK_DISCARDCONTENTS - */ -#define DDLOCK_OKTOSWAP 0x00002000L - -/* - * On IDirectDrawSurface7 and higher interfaces, the default is DDLOCK_WAIT. If you wish - * to override the default and use time when the accelerator is busy (as denoted by - * the DDERR_WASSTILLDRAWING return code) then use DDLOCK_DONOTWAIT. - */ -#define DDLOCK_DONOTWAIT 0x00004000L - -/* - * This indicates volume texture lock with front and back specified. - */ -#define DDLOCK_HASVOLUMETEXTUREBOXRECT 0x00008000L - -/* - * This indicates that the driver should not update dirty rect information for this lock. - */ -#define DDLOCK_NODIRTYUPDATE 0x00010000L - - -/**************************************************************************** - * - * DIRECTDRAWSURFACE PAGELOCK FLAGS - * - ****************************************************************************/ - -/* - * No flags defined at present - */ - - -/**************************************************************************** - * - * DIRECTDRAWSURFACE PAGEUNLOCK FLAGS - * - ****************************************************************************/ - -/* - * No flags defined at present - */ - - -/**************************************************************************** - * - * DIRECTDRAWSURFACE BLT FX FLAGS - * - ****************************************************************************/ - -/* - * If stretching, use arithmetic stretching along the Y axis for this blt. - */ -#define DDBLTFX_ARITHSTRETCHY 0x00000001l - -/* - * Do this blt mirroring the surface left to right. Spin the - * surface around its y-axis. - */ -#define DDBLTFX_MIRRORLEFTRIGHT 0x00000002l - -/* - * Do this blt mirroring the surface up and down. Spin the surface - * around its x-axis. - */ -#define DDBLTFX_MIRRORUPDOWN 0x00000004l - -/* - * Schedule this blt to avoid tearing. - */ -#define DDBLTFX_NOTEARING 0x00000008l - -/* - * Do this blt rotating the surface one hundred and eighty degrees. - */ -#define DDBLTFX_ROTATE180 0x00000010l - -/* - * Do this blt rotating the surface two hundred and seventy degrees. - */ -#define DDBLTFX_ROTATE270 0x00000020l - -/* - * Do this blt rotating the surface ninety degrees. - */ -#define DDBLTFX_ROTATE90 0x00000040l - -/* - * Do this z blt using dwZBufferLow and dwZBufferHigh as range values - * specified to limit the bits copied from the source surface. - */ -#define DDBLTFX_ZBUFFERRANGE 0x00000080l - -/* - * Do this z blt adding the dwZBufferBaseDest to each of the sources z values - * before comparing it with the desting z values. - */ -#define DDBLTFX_ZBUFFERBASEDEST 0x00000100l - -/**************************************************************************** - * - * DIRECTDRAWSURFACE OVERLAY FX FLAGS - * - ****************************************************************************/ - -/* - * If stretching, use arithmetic stretching along the Y axis for this overlay. - */ -#define DDOVERFX_ARITHSTRETCHY 0x00000001l - -/* - * Mirror the overlay across the vertical axis - */ -#define DDOVERFX_MIRRORLEFTRIGHT 0x00000002l - -/* - * Mirror the overlay across the horizontal axis - */ -#define DDOVERFX_MIRRORUPDOWN 0x00000004l - -/* - * Deinterlace the overlay, if possible - */ -#define DDOVERFX_DEINTERLACE 0x00000008l - - -/**************************************************************************** - * - * DIRECTDRAW WAITFORVERTICALBLANK FLAGS - * - ****************************************************************************/ - -/* - * return when the vertical blank interval begins - */ -#define DDWAITVB_BLOCKBEGIN 0x00000001l - -/* - * set up an event to trigger when the vertical blank begins - */ -#define DDWAITVB_BLOCKBEGINEVENT 0x00000002l - -/* - * return when the vertical blank interval ends and display begins - */ -#define DDWAITVB_BLOCKEND 0x00000004l - -/**************************************************************************** - * - * DIRECTDRAW GETFLIPSTATUS FLAGS - * - ****************************************************************************/ - -/* - * is it OK to flip now? - */ -#define DDGFS_CANFLIP 0x00000001l - -/* - * is the last flip finished? - */ -#define DDGFS_ISFLIPDONE 0x00000002l - -/**************************************************************************** - * - * DIRECTDRAW GETBLTSTATUS FLAGS - * - ****************************************************************************/ - -/* - * is it OK to blt now? - */ -#define DDGBS_CANBLT 0x00000001l - -/* - * is the blt to the surface finished? - */ -#define DDGBS_ISBLTDONE 0x00000002l - - -/**************************************************************************** - * - * DIRECTDRAW ENUMOVERLAYZORDER FLAGS - * - ****************************************************************************/ - -/* - * Enumerate overlays back to front. - */ -#define DDENUMOVERLAYZ_BACKTOFRONT 0x00000000l - -/* - * Enumerate overlays front to back - */ -#define DDENUMOVERLAYZ_FRONTTOBACK 0x00000001l - -/**************************************************************************** - * - * DIRECTDRAW UPDATEOVERLAYZORDER FLAGS - * - ****************************************************************************/ - -/* - * Send overlay to front - */ -#define DDOVERZ_SENDTOFRONT 0x00000000l - -/* - * Send overlay to back - */ -#define DDOVERZ_SENDTOBACK 0x00000001l - -/* - * Move Overlay forward - */ -#define DDOVERZ_MOVEFORWARD 0x00000002l - -/* - * Move Overlay backward - */ -#define DDOVERZ_MOVEBACKWARD 0x00000003l - -/* - * Move Overlay in front of relative surface - */ -#define DDOVERZ_INSERTINFRONTOF 0x00000004l - -/* - * Move Overlay in back of relative surface - */ -#define DDOVERZ_INSERTINBACKOF 0x00000005l - - -/**************************************************************************** - * - * DIRECTDRAW SETGAMMARAMP FLAGS - * - ****************************************************************************/ - -/* - * Request calibrator to adjust the gamma ramp according to the physical - * properties of the display so that the result should appear identical - * on all systems. - */ -#define DDSGR_CALIBRATE 0x00000001L - - -/**************************************************************************** - * - * DIRECTDRAW STARTMODETEST FLAGS - * - ****************************************************************************/ - -/* - * Indicates that the mode being tested has passed - */ -#define DDSMT_ISTESTREQUIRED 0x00000001L - - -/**************************************************************************** - * - * DIRECTDRAW EVALUATEMODE FLAGS - * - ****************************************************************************/ - -/* - * Indicates that the mode being tested has passed - */ -#define DDEM_MODEPASSED 0x00000001L - -/* - * Indicates that the mode being tested has failed - */ -#define DDEM_MODEFAILED 0x00000002L - - -/*=========================================================================== - * - * - * DIRECTDRAW RETURN CODES - * - * The return values from DirectDraw Commands and Surface that return an HRESULT - * are codes from DirectDraw concerning the results of the action - * requested by DirectDraw. - * - *==========================================================================*/ - -/* - * Status is OK - * - * Issued by: DirectDraw Commands and all callbacks - */ -#define DD_OK S_OK -#define DD_FALSE S_FALSE - -/**************************************************************************** - * - * DIRECTDRAW ENUMCALLBACK RETURN VALUES - * - * EnumCallback returns are used to control the flow of the DIRECTDRAW and - * DIRECTDRAWSURFACE object enumerations. They can only be returned by - * enumeration callback routines. - * - ****************************************************************************/ - -/* - * stop the enumeration - */ -#define DDENUMRET_CANCEL 0 - -/* - * continue the enumeration - */ -#define DDENUMRET_OK 1 - -/**************************************************************************** - * - * DIRECTDRAW ERRORS - * - * Errors are represented by negative values and cannot be combined. - * - ****************************************************************************/ - -/* - * This object is already initialized - */ -#define DDERR_ALREADYINITIALIZED MAKE_DDHRESULT( 5 ) - -/* - * This surface can not be attached to the requested surface. - */ -#define DDERR_CANNOTATTACHSURFACE MAKE_DDHRESULT( 10 ) - -/* - * This surface can not be detached from the requested surface. - */ -#define DDERR_CANNOTDETACHSURFACE MAKE_DDHRESULT( 20 ) - -/* - * Support is currently not available. - */ -#define DDERR_CURRENTLYNOTAVAIL MAKE_DDHRESULT( 40 ) - -/* - * An exception was encountered while performing the requested operation - */ -#define DDERR_EXCEPTION MAKE_DDHRESULT( 55 ) - -/* - * Generic failure. - */ -#define DDERR_GENERIC E_FAIL - -/* - * Height of rectangle provided is not a multiple of reqd alignment - */ -#define DDERR_HEIGHTALIGN MAKE_DDHRESULT( 90 ) - -/* - * Unable to match primary surface creation request with existing - * primary surface. - */ -#define DDERR_INCOMPATIBLEPRIMARY MAKE_DDHRESULT( 95 ) - -/* - * One or more of the caps bits passed to the callback are incorrect. - */ -#define DDERR_INVALIDCAPS MAKE_DDHRESULT( 100 ) - -/* - * DirectDraw does not support provided Cliplist. - */ -#define DDERR_INVALIDCLIPLIST MAKE_DDHRESULT( 110 ) - -/* - * DirectDraw does not support the requested mode - */ -#define DDERR_INVALIDMODE MAKE_DDHRESULT( 120 ) - -/* - * DirectDraw received a pointer that was an invalid DIRECTDRAW object. - */ -#define DDERR_INVALIDOBJECT MAKE_DDHRESULT( 130 ) - -/* - * One or more of the parameters passed to the callback function are - * incorrect. - */ -#define DDERR_INVALIDPARAMS E_INVALIDARG - -/* - * pixel format was invalid as specified - */ -#define DDERR_INVALIDPIXELFORMAT MAKE_DDHRESULT( 145 ) - -/* - * Rectangle provided was invalid. - */ -#define DDERR_INVALIDRECT MAKE_DDHRESULT( 150 ) - -/* - * Operation could not be carried out because one or more surfaces are locked - */ -#define DDERR_LOCKEDSURFACES MAKE_DDHRESULT( 160 ) - -/* - * There is no 3D present. - */ -#define DDERR_NO3D MAKE_DDHRESULT( 170 ) - -/* - * Operation could not be carried out because there is no alpha accleration - * hardware present or available. - */ -#define DDERR_NOALPHAHW MAKE_DDHRESULT( 180 ) - -/* - * Operation could not be carried out because there is no stereo - * hardware present or available. - */ -#define DDERR_NOSTEREOHARDWARE MAKE_DDHRESULT( 181 ) - -/* - * Operation could not be carried out because there is no hardware - * present which supports stereo surfaces - */ -#define DDERR_NOSURFACELEFT MAKE_DDHRESULT( 182 ) - - - -/* - * no clip list available - */ -#define DDERR_NOCLIPLIST MAKE_DDHRESULT( 205 ) - -/* - * Operation could not be carried out because there is no color conversion - * hardware present or available. - */ -#define DDERR_NOCOLORCONVHW MAKE_DDHRESULT( 210 ) - -/* - * Create function called without DirectDraw object method SetCooperativeLevel - * being called. - */ -#define DDERR_NOCOOPERATIVELEVELSET MAKE_DDHRESULT( 212 ) - -/* - * Surface doesn't currently have a color key - */ -#define DDERR_NOCOLORKEY MAKE_DDHRESULT( 215 ) - -/* - * Operation could not be carried out because there is no hardware support - * of the dest color key. - */ -#define DDERR_NOCOLORKEYHW MAKE_DDHRESULT( 220 ) - -/* - * No DirectDraw support possible with current display driver - */ -#define DDERR_NODIRECTDRAWSUPPORT MAKE_DDHRESULT( 222 ) - -/* - * Operation requires the application to have exclusive mode but the - * application does not have exclusive mode. - */ -#define DDERR_NOEXCLUSIVEMODE MAKE_DDHRESULT( 225 ) - -/* - * Flipping visible surfaces is not supported. - */ -#define DDERR_NOFLIPHW MAKE_DDHRESULT( 230 ) - -/* - * There is no GDI present. - */ -#define DDERR_NOGDI MAKE_DDHRESULT( 240 ) - -/* - * Operation could not be carried out because there is no hardware present - * or available. - */ -#define DDERR_NOMIRRORHW MAKE_DDHRESULT( 250 ) - -/* - * Requested item was not found - */ -#define DDERR_NOTFOUND MAKE_DDHRESULT( 255 ) - -/* - * Operation could not be carried out because there is no overlay hardware - * present or available. - */ -#define DDERR_NOOVERLAYHW MAKE_DDHRESULT( 260 ) - -/* - * Operation could not be carried out because the source and destination - * rectangles are on the same surface and overlap each other. - */ -#define DDERR_OVERLAPPINGRECTS MAKE_DDHRESULT( 270 ) - -/* - * Operation could not be carried out because there is no appropriate raster - * op hardware present or available. - */ -#define DDERR_NORASTEROPHW MAKE_DDHRESULT( 280 ) - -/* - * Operation could not be carried out because there is no rotation hardware - * present or available. - */ -#define DDERR_NOROTATIONHW MAKE_DDHRESULT( 290 ) - -/* - * Operation could not be carried out because there is no hardware support - * for stretching - */ -#define DDERR_NOSTRETCHHW MAKE_DDHRESULT( 310 ) - -/* - * DirectDrawSurface is not in 4 bit color palette and the requested operation - * requires 4 bit color palette. - */ -#define DDERR_NOT4BITCOLOR MAKE_DDHRESULT( 316 ) - -/* - * DirectDrawSurface is not in 4 bit color index palette and the requested - * operation requires 4 bit color index palette. - */ -#define DDERR_NOT4BITCOLORINDEX MAKE_DDHRESULT( 317 ) - -/* - * DirectDraw Surface is not in 8 bit color mode and the requested operation - * requires 8 bit color. - */ -#define DDERR_NOT8BITCOLOR MAKE_DDHRESULT( 320 ) - -/* - * Operation could not be carried out because there is no texture mapping - * hardware present or available. - */ -#define DDERR_NOTEXTUREHW MAKE_DDHRESULT( 330 ) - -/* - * Operation could not be carried out because there is no hardware support - * for vertical blank synchronized operations. - */ -#define DDERR_NOVSYNCHW MAKE_DDHRESULT( 335 ) - -/* - * Operation could not be carried out because there is no hardware support - * for zbuffer blting. - */ -#define DDERR_NOZBUFFERHW MAKE_DDHRESULT( 340 ) - -/* - * Overlay surfaces could not be z layered based on their BltOrder because - * the hardware does not support z layering of overlays. - */ -#define DDERR_NOZOVERLAYHW MAKE_DDHRESULT( 350 ) - -/* - * The hardware needed for the requested operation has already been - * allocated. - */ -#define DDERR_OUTOFCAPS MAKE_DDHRESULT( 360 ) - -/* - * DirectDraw does not have enough memory to perform the operation. - */ -#define DDERR_OUTOFMEMORY E_OUTOFMEMORY - -/* - * DirectDraw does not have enough memory to perform the operation. - */ -#define DDERR_OUTOFVIDEOMEMORY MAKE_DDHRESULT( 380 ) - -/* - * hardware does not support clipped overlays - */ -#define DDERR_OVERLAYCANTCLIP MAKE_DDHRESULT( 382 ) - -/* - * Can only have ony color key active at one time for overlays - */ -#define DDERR_OVERLAYCOLORKEYONLYONEACTIVE MAKE_DDHRESULT( 384 ) - -/* - * Access to this palette is being refused because the palette is already - * locked by another thread. - */ -#define DDERR_PALETTEBUSY MAKE_DDHRESULT( 387 ) - -/* - * No src color key specified for this operation. - */ -#define DDERR_COLORKEYNOTSET MAKE_DDHRESULT( 400 ) - -/* - * This surface is already attached to the surface it is being attached to. - */ -#define DDERR_SURFACEALREADYATTACHED MAKE_DDHRESULT( 410 ) - -/* - * This surface is already a dependency of the surface it is being made a - * dependency of. - */ -#define DDERR_SURFACEALREADYDEPENDENT MAKE_DDHRESULT( 420 ) - -/* - * Access to this surface is being refused because the surface is already - * locked by another thread. - */ -#define DDERR_SURFACEBUSY MAKE_DDHRESULT( 430 ) - -/* - * Access to this surface is being refused because no driver exists - * which can supply a pointer to the surface. - * This is most likely to happen when attempting to lock the primary - * surface when no DCI provider is present. - * Will also happen on attempts to lock an optimized surface. - */ -#define DDERR_CANTLOCKSURFACE MAKE_DDHRESULT( 435 ) - -/* - * Access to Surface refused because Surface is obscured. - */ -#define DDERR_SURFACEISOBSCURED MAKE_DDHRESULT( 440 ) - -/* - * Access to this surface is being refused because the surface is gone. - * The DIRECTDRAWSURFACE object representing this surface should - * have Restore called on it. - */ -#define DDERR_SURFACELOST MAKE_DDHRESULT( 450 ) - -/* - * The requested surface is not attached. - */ -#define DDERR_SURFACENOTATTACHED MAKE_DDHRESULT( 460 ) - -/* - * Height requested by DirectDraw is too large. - */ -#define DDERR_TOOBIGHEIGHT MAKE_DDHRESULT( 470 ) - -/* - * Size requested by DirectDraw is too large -- The individual height and - * width are OK. - */ -#define DDERR_TOOBIGSIZE MAKE_DDHRESULT( 480 ) - -/* - * Width requested by DirectDraw is too large. - */ -#define DDERR_TOOBIGWIDTH MAKE_DDHRESULT( 490 ) - -/* - * Action not supported. - */ -#define DDERR_UNSUPPORTED E_NOTIMPL - -/* - * Pixel format requested is unsupported by DirectDraw - */ -#define DDERR_UNSUPPORTEDFORMAT MAKE_DDHRESULT( 510 ) - -/* - * Bitmask in the pixel format requested is unsupported by DirectDraw - */ -#define DDERR_UNSUPPORTEDMASK MAKE_DDHRESULT( 520 ) - -/* - * The specified stream contains invalid data - */ -#define DDERR_INVALIDSTREAM MAKE_DDHRESULT( 521 ) - -/* - * vertical blank is in progress - */ -#define DDERR_VERTICALBLANKINPROGRESS MAKE_DDHRESULT( 537 ) - -/* - * Informs DirectDraw that the previous Blt which is transfering information - * to or from this Surface is incomplete. - */ -#define DDERR_WASSTILLDRAWING MAKE_DDHRESULT( 540 ) - - -/* - * The specified surface type requires specification of the COMPLEX flag - */ -#define DDERR_DDSCAPSCOMPLEXREQUIRED MAKE_DDHRESULT( 542 ) - - -/* - * Rectangle provided was not horizontally aligned on reqd. boundary - */ -#define DDERR_XALIGN MAKE_DDHRESULT( 560 ) - -/* - * The GUID passed to DirectDrawCreate is not a valid DirectDraw driver - * identifier. - */ -#define DDERR_INVALIDDIRECTDRAWGUID MAKE_DDHRESULT( 561 ) - -/* - * A DirectDraw object representing this driver has already been created - * for this process. - */ -#define DDERR_DIRECTDRAWALREADYCREATED MAKE_DDHRESULT( 562 ) - -/* - * A hardware only DirectDraw object creation was attempted but the driver - * did not support any hardware. - */ -#define DDERR_NODIRECTDRAWHW MAKE_DDHRESULT( 563 ) - -/* - * this process already has created a primary surface - */ -#define DDERR_PRIMARYSURFACEALREADYEXISTS MAKE_DDHRESULT( 564 ) - -/* - * software emulation not available. - */ -#define DDERR_NOEMULATION MAKE_DDHRESULT( 565 ) - -/* - * region passed to Clipper::GetClipList is too small. - */ -#define DDERR_REGIONTOOSMALL MAKE_DDHRESULT( 566 ) - -/* - * an attempt was made to set a clip list for a clipper objec that - * is already monitoring an hwnd. - */ -#define DDERR_CLIPPERISUSINGHWND MAKE_DDHRESULT( 567 ) - -/* - * No clipper object attached to surface object - */ -#define DDERR_NOCLIPPERATTACHED MAKE_DDHRESULT( 568 ) - -/* - * Clipper notification requires an HWND or - * no HWND has previously been set as the CooperativeLevel HWND. - */ -#define DDERR_NOHWND MAKE_DDHRESULT( 569 ) - -/* - * HWND used by DirectDraw CooperativeLevel has been subclassed, - * this prevents DirectDraw from restoring state. - */ -#define DDERR_HWNDSUBCLASSED MAKE_DDHRESULT( 570 ) - -/* - * The CooperativeLevel HWND has already been set. - * It can not be reset while the process has surfaces or palettes created. - */ -#define DDERR_HWNDALREADYSET MAKE_DDHRESULT( 571 ) - -/* - * No palette object attached to this surface. - */ -#define DDERR_NOPALETTEATTACHED MAKE_DDHRESULT( 572 ) - -/* - * No hardware support for 16 or 256 color palettes. - */ -#define DDERR_NOPALETTEHW MAKE_DDHRESULT( 573 ) - -/* - * If a clipper object is attached to the source surface passed into a - * BltFast call. - */ -#define DDERR_BLTFASTCANTCLIP MAKE_DDHRESULT( 574 ) - -/* - * No blter. - */ -#define DDERR_NOBLTHW MAKE_DDHRESULT( 575 ) - -/* - * No DirectDraw ROP hardware. - */ -#define DDERR_NODDROPSHW MAKE_DDHRESULT( 576 ) - -/* - * returned when GetOverlayPosition is called on a hidden overlay - */ -#define DDERR_OVERLAYNOTVISIBLE MAKE_DDHRESULT( 577 ) - -/* - * returned when GetOverlayPosition is called on a overlay that UpdateOverlay - * has never been called on to establish a destionation. - */ -#define DDERR_NOOVERLAYDEST MAKE_DDHRESULT( 578 ) - -/* - * returned when the position of the overlay on the destionation is no longer - * legal for that destionation. - */ -#define DDERR_INVALIDPOSITION MAKE_DDHRESULT( 579 ) - -/* - * returned when an overlay member is called for a non-overlay surface - */ -#define DDERR_NOTAOVERLAYSURFACE MAKE_DDHRESULT( 580 ) - -/* - * An attempt was made to set the cooperative level when it was already - * set to exclusive. - */ -#define DDERR_EXCLUSIVEMODEALREADYSET MAKE_DDHRESULT( 581 ) - -/* - * An attempt has been made to flip a surface that is not flippable. - */ -#define DDERR_NOTFLIPPABLE MAKE_DDHRESULT( 582 ) - -/* - * Can't duplicate primary & 3D surfaces, or surfaces that are implicitly - * created. - */ -#define DDERR_CANTDUPLICATE MAKE_DDHRESULT( 583 ) - -/* - * Surface was not locked. An attempt to unlock a surface that was not - * locked at all, or by this process, has been attempted. - */ -#define DDERR_NOTLOCKED MAKE_DDHRESULT( 584 ) - -/* - * Windows can not create any more DCs, or a DC was requested for a paltte-indexed - * surface when the surface had no palette AND the display mode was not palette-indexed - * (in this case DirectDraw cannot select a proper palette into the DC) - */ -#define DDERR_CANTCREATEDC MAKE_DDHRESULT( 585 ) - -/* - * No DC was ever created for this surface. - */ -#define DDERR_NODC MAKE_DDHRESULT( 586 ) - -/* - * This surface can not be restored because it was created in a different - * mode. - */ -#define DDERR_WRONGMODE MAKE_DDHRESULT( 587 ) - -/* - * This surface can not be restored because it is an implicitly created - * surface. - */ -#define DDERR_IMPLICITLYCREATED MAKE_DDHRESULT( 588 ) - -/* - * The surface being used is not a palette-based surface - */ -#define DDERR_NOTPALETTIZED MAKE_DDHRESULT( 589 ) - - -/* - * The display is currently in an unsupported mode - */ -#define DDERR_UNSUPPORTEDMODE MAKE_DDHRESULT( 590 ) - -/* - * Operation could not be carried out because there is no mip-map - * texture mapping hardware present or available. - */ -#define DDERR_NOMIPMAPHW MAKE_DDHRESULT( 591 ) - -/* - * The requested action could not be performed because the surface was of - * the wrong type. - */ -#define DDERR_INVALIDSURFACETYPE MAKE_DDHRESULT( 592 ) - - -/* - * Device does not support optimized surfaces, therefore no video memory optimized surfaces - */ -#define DDERR_NOOPTIMIZEHW MAKE_DDHRESULT( 600 ) - -/* - * Surface is an optimized surface, but has not yet been allocated any memory - */ -#define DDERR_NOTLOADED MAKE_DDHRESULT( 601 ) - -/* - * Attempt was made to create or set a device window without first setting - * the focus window - */ -#define DDERR_NOFOCUSWINDOW MAKE_DDHRESULT( 602 ) - -/* - * Attempt was made to set a palette on a mipmap sublevel - */ -#define DDERR_NOTONMIPMAPSUBLEVEL MAKE_DDHRESULT( 603 ) - -/* - * A DC has already been returned for this surface. Only one DC can be - * retrieved per surface. - */ -#define DDERR_DCALREADYCREATED MAKE_DDHRESULT( 620 ) - -/* - * An attempt was made to allocate non-local video memory from a device - * that does not support non-local video memory. - */ -#define DDERR_NONONLOCALVIDMEM MAKE_DDHRESULT( 630 ) - -/* - * The attempt to page lock a surface failed. - */ -#define DDERR_CANTPAGELOCK MAKE_DDHRESULT( 640 ) - - -/* - * The attempt to page unlock a surface failed. - */ -#define DDERR_CANTPAGEUNLOCK MAKE_DDHRESULT( 660 ) - -/* - * An attempt was made to page unlock a surface with no outstanding page locks. - */ -#define DDERR_NOTPAGELOCKED MAKE_DDHRESULT( 680 ) - -/* - * There is more data available than the specified buffer size could hold - */ -#define DDERR_MOREDATA MAKE_DDHRESULT( 690 ) - -/* - * The data has expired and is therefore no longer valid. - */ -#define DDERR_EXPIRED MAKE_DDHRESULT( 691 ) - -/* - * The mode test has finished executing. - */ -#define DDERR_TESTFINISHED MAKE_DDHRESULT( 692 ) - -/* - * The mode test has switched to a new mode. - */ -#define DDERR_NEWMODE MAKE_DDHRESULT( 693 ) - -/* - * D3D has not yet been initialized. - */ -#define DDERR_D3DNOTINITIALIZED MAKE_DDHRESULT( 694 ) - -/* - * The video port is not active - */ -#define DDERR_VIDEONOTACTIVE MAKE_DDHRESULT( 695 ) - -/* - * The monitor does not have EDID data. - */ -#define DDERR_NOMONITORINFORMATION MAKE_DDHRESULT( 696 ) - -/* - * The driver does not enumerate display mode refresh rates. - */ -#define DDERR_NODRIVERSUPPORT MAKE_DDHRESULT( 697 ) - -/* - * Surfaces created by one direct draw device cannot be used directly by - * another direct draw device. - */ -#define DDERR_DEVICEDOESNTOWNSURFACE MAKE_DDHRESULT( 699 ) - - - -/* - * An attempt was made to invoke an interface member of a DirectDraw object - * created by CoCreateInstance() before it was initialized. - */ -#define DDERR_NOTINITIALIZED CO_E_NOTINITIALIZED - - -/* Alpha bit depth constants */ - - -#ifdef __cplusplus -}; -#endif - -#ifdef ENABLE_NAMELESS_UNION_PRAGMA -#pragma warning(default:4201) -#endif - -#endif //__DDRAW_INCLUDED__ - - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: ddraw.h + * Content: DirectDraw include file + * + ***************************************************************************/ + +#ifndef __DDRAW_INCLUDED__ +#define __DDRAW_INCLUDED__ + +//Disable the nameless union warning when building internally +#undef ENABLE_NAMELESS_UNION_PRAGMA +#ifdef DIRECTX_REDIST +#define ENABLE_NAMELESS_UNION_PRAGMA +#endif + +#ifdef ENABLE_NAMELESS_UNION_PRAGMA +#pragma warning(disable:4201) +#endif + +/* + * If you wish an application built against the newest version of DirectDraw + * to run against an older DirectDraw run time then define DIRECTDRAW_VERSION + * to be the earlies version of DirectDraw you wish to run against. For, + * example if you wish an application to run against a DX 3 runtime define + * DIRECTDRAW_VERSION to be 0x0300. + */ +#ifndef DIRECTDRAW_VERSION +#define DIRECTDRAW_VERSION 0x0700 +#endif /* DIRECTDRAW_VERSION */ + +#if defined( _WIN32 ) && !defined( _NO_COM ) +#define COM_NO_WINDOWS_H +#include +#else +#define IUnknown void +#if !defined( NT_BUILD_ENVIRONMENT ) && !defined(WINNT) + #define CO_E_NOTINITIALIZED 0x800401F0L +#endif +#endif + +#define _FACDD 0x876 +#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) + +#ifdef __cplusplus +extern "C" { +#endif + +// +// For compilers that don't support nameless unions, do a +// +// #define NONAMELESSUNION +// +// before #include +// +#ifndef DUMMYUNIONNAMEN +#if defined(__cplusplus) || !defined(NONAMELESSUNION) +#define DUMMYUNIONNAMEN(n) +#else +#define DUMMYUNIONNAMEN(n) u##n +#endif +#endif + +#ifndef MAKEFOURCC + #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ + ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ + ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) +#endif //defined(MAKEFOURCC) + +/* + * FOURCC codes for DX compressed-texture pixel formats + */ +#define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1')) +#define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2')) +#define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3')) +#define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4')) +#define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5')) + +/* + * GUIDS used by DirectDraw objects + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) + +DEFINE_GUID( CLSID_DirectDraw, 0xD7B70EE0,0x4340,0x11CF,0xB0,0x63,0x00,0x20,0xAF,0xC2,0xCD,0x35 ); +DEFINE_GUID( CLSID_DirectDraw7, 0x3c305196,0x50db,0x11d3,0x9c,0xfe,0x00,0xc0,0x4f,0xd9,0x30,0xc5 ); +DEFINE_GUID( CLSID_DirectDrawClipper, 0x593817A0,0x7DB3,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xb9,0x33,0x56 ); +DEFINE_GUID( IID_IDirectDraw, 0x6C14DB80,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); +DEFINE_GUID( IID_IDirectDraw2, 0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 ); +DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 ); +DEFINE_GUID( IID_IDirectDraw7, 0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b ); +DEFINE_GUID( IID_IDirectDrawSurface, 0x6C14DB81,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); +DEFINE_GUID( IID_IDirectDrawSurface2, 0x57805885,0x6eec,0x11cf,0x94,0x41,0xa8,0x23,0x03,0xc1,0x0e,0x27 ); +DEFINE_GUID( IID_IDirectDrawSurface3, 0xDA044E00,0x69B2,0x11D0,0xA1,0xD5,0x00,0xAA,0x00,0xB8,0xDF,0xBB ); +DEFINE_GUID( IID_IDirectDrawSurface4, 0x0B2B8630,0xAD35,0x11D0,0x8E,0xA6,0x00,0x60,0x97,0x97,0xEA,0x5B ); +DEFINE_GUID( IID_IDirectDrawSurface7, 0x06675a80,0x3b9b,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b ); +DEFINE_GUID( IID_IDirectDrawPalette, 0x6C14DB84,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); +DEFINE_GUID( IID_IDirectDrawClipper, 0x6C14DB85,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); +DEFINE_GUID( IID_IDirectDrawColorControl, 0x4B9F0EE0,0x0D7E,0x11D0,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8 ); +DEFINE_GUID( IID_IDirectDrawGammaControl, 0x69C11C3E,0xB46B,0x11D1,0xAD,0x7A,0x00,0xC0,0x4F,0xC2,0x9B,0x4E ); + +#endif + +/*============================================================================ + * + * DirectDraw Structures + * + * Various structures used to invoke DirectDraw. + * + *==========================================================================*/ + +struct IDirectDraw; +struct IDirectDrawSurface; +struct IDirectDrawPalette; +struct IDirectDrawClipper; + +typedef struct IDirectDraw FAR *LPDIRECTDRAW; +typedef struct IDirectDraw2 FAR *LPDIRECTDRAW2; +typedef struct IDirectDraw4 FAR *LPDIRECTDRAW4; +typedef struct IDirectDraw7 FAR *LPDIRECTDRAW7; +typedef struct IDirectDrawSurface FAR *LPDIRECTDRAWSURFACE; +typedef struct IDirectDrawSurface2 FAR *LPDIRECTDRAWSURFACE2; +typedef struct IDirectDrawSurface3 FAR *LPDIRECTDRAWSURFACE3; +typedef struct IDirectDrawSurface4 FAR *LPDIRECTDRAWSURFACE4; +typedef struct IDirectDrawSurface7 FAR *LPDIRECTDRAWSURFACE7; +typedef struct IDirectDrawPalette FAR *LPDIRECTDRAWPALETTE; +typedef struct IDirectDrawClipper FAR *LPDIRECTDRAWCLIPPER; +typedef struct IDirectDrawColorControl FAR *LPDIRECTDRAWCOLORCONTROL; +typedef struct IDirectDrawGammaControl FAR *LPDIRECTDRAWGAMMACONTROL; + +typedef struct _DDFXROP FAR *LPDDFXROP; +typedef struct _DDSURFACEDESC FAR *LPDDSURFACEDESC; +typedef struct _DDSURFACEDESC2 FAR *LPDDSURFACEDESC2; +typedef struct _DDCOLORCONTROL FAR *LPDDCOLORCONTROL; + +/* + * API's + */ +#if (defined (WIN32) || defined( _WIN32 ) ) && !defined( _NO_COM ) +//#if defined( _WIN32 ) && !defined( _NO_ENUM ) + typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKA)(GUID FAR *, LPSTR, LPSTR, LPVOID); + typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKW)(GUID FAR *, LPWSTR, LPWSTR, LPVOID); + extern HRESULT WINAPI DirectDrawEnumerateW( LPDDENUMCALLBACKW lpCallback, LPVOID lpContext ); + extern HRESULT WINAPI DirectDrawEnumerateA( LPDDENUMCALLBACKA lpCallback, LPVOID lpContext ); + /* + * Protect against old SDKs + */ + #if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) + #define HMONITOR_DECLARED + DECLARE_HANDLE(HMONITOR); + #endif + typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKEXA)(GUID FAR *, LPSTR, LPSTR, LPVOID, HMONITOR); + typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKEXW)(GUID FAR *, LPWSTR, LPWSTR, LPVOID, HMONITOR); + extern HRESULT WINAPI DirectDrawEnumerateExW( LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags); + extern HRESULT WINAPI DirectDrawEnumerateExA( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags); + typedef HRESULT (WINAPI * LPDIRECTDRAWENUMERATEEXA)( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags); + typedef HRESULT (WINAPI * LPDIRECTDRAWENUMERATEEXW)( LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags); + + #ifdef UNICODE + typedef LPDDENUMCALLBACKW LPDDENUMCALLBACK; + #define DirectDrawEnumerate DirectDrawEnumerateW + typedef LPDDENUMCALLBACKEXW LPDDENUMCALLBACKEX; + typedef LPDIRECTDRAWENUMERATEEXW LPDIRECTDRAWENUMERATEEX; + #define DirectDrawEnumerateEx DirectDrawEnumerateExW + #else + typedef LPDDENUMCALLBACKA LPDDENUMCALLBACK; + #define DirectDrawEnumerate DirectDrawEnumerateA + typedef LPDDENUMCALLBACKEXA LPDDENUMCALLBACKEX; + typedef LPDIRECTDRAWENUMERATEEXA LPDIRECTDRAWENUMERATEEX; + #define DirectDrawEnumerateEx DirectDrawEnumerateExA + #endif + extern HRESULT WINAPI DirectDrawCreate( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter ); + extern HRESULT WINAPI DirectDrawCreateEx( GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid,IUnknown FAR *pUnkOuter ); + extern HRESULT WINAPI DirectDrawCreateClipper( DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter ); +#endif +/* + * Flags for DirectDrawEnumerateEx + * DirectDrawEnumerateEx supercedes DirectDrawEnumerate. You must use GetProcAddress to + * obtain a function pointer (of type LPDIRECTDRAWENUMERATEEX) to DirectDrawEnumerateEx. + * By default, only the primary display device is enumerated. + * DirectDrawEnumerate is equivalent to DirectDrawEnumerate(,,DDENUM_NONDISPLAYDEVICES) + */ + +/* + * This flag causes enumeration of any GDI display devices which are part of + * the Windows Desktop + */ +#define DDENUM_ATTACHEDSECONDARYDEVICES 0x00000001L + +/* + * This flag causes enumeration of any GDI display devices which are not + * part of the Windows Desktop + */ +#define DDENUM_DETACHEDSECONDARYDEVICES 0x00000002L + +/* + * This flag causes enumeration of non-display devices + */ +#define DDENUM_NONDISPLAYDEVICES 0x00000004L + + +#define REGSTR_KEY_DDHW_DESCRIPTION "Description" +#define REGSTR_KEY_DDHW_DRIVERNAME "DriverName" +#define REGSTR_PATH_DDHW "Hardware\\DirectDrawDrivers" + +#define DDCREATE_HARDWAREONLY 0x00000001l +#define DDCREATE_EMULATIONONLY 0x00000002l + +#if defined(WINNT) || !defined(WIN32) +typedef long HRESULT; +#endif + +//#ifndef WINNT +typedef HRESULT (FAR PASCAL * LPDDENUMMODESCALLBACK)(LPDDSURFACEDESC, LPVOID); +typedef HRESULT (FAR PASCAL * LPDDENUMMODESCALLBACK2)(LPDDSURFACEDESC2, LPVOID); +typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK)(LPDIRECTDRAWSURFACE, LPDDSURFACEDESC, LPVOID); +typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK2)(LPDIRECTDRAWSURFACE4, LPDDSURFACEDESC2, LPVOID); +typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK7)(LPDIRECTDRAWSURFACE7, LPDDSURFACEDESC2, LPVOID); +//#endif + +/* + * Generic pixel format with 8-bit RGB and alpha components + */ +typedef struct _DDARGB +{ + BYTE blue; + BYTE green; + BYTE red; + BYTE alpha; +} DDARGB; + +typedef DDARGB FAR *LPDDARGB; + +/* + * This version of the structure remains for backwards source compatibility. + * The DDARGB structure is the one that should be used for all DirectDraw APIs. + */ +typedef struct _DDRGBA +{ + BYTE red; + BYTE green; + BYTE blue; + BYTE alpha; +} DDRGBA; + +typedef DDRGBA FAR *LPDDRGBA; + + +/* + * DDCOLORKEY + */ +typedef struct _DDCOLORKEY +{ + DWORD dwColorSpaceLowValue; // low boundary of color space that is to + // be treated as Color Key, inclusive + DWORD dwColorSpaceHighValue; // high boundary of color space that is + // to be treated as Color Key, inclusive +} DDCOLORKEY; + +typedef DDCOLORKEY FAR* LPDDCOLORKEY; + +/* + * DDBLTFX + * Used to pass override information to the DIRECTDRAWSURFACE callback Blt. + */ +typedef struct _DDBLTFX +{ + DWORD dwSize; // size of structure + DWORD dwDDFX; // FX operations + DWORD dwROP; // Win32 raster operations + DWORD dwDDROP; // Raster operations new for DirectDraw + DWORD dwRotationAngle; // Rotation angle for blt + DWORD dwZBufferOpCode; // ZBuffer compares + DWORD dwZBufferLow; // Low limit of Z buffer + DWORD dwZBufferHigh; // High limit of Z buffer + DWORD dwZBufferBaseDest; // Destination base value + DWORD dwZDestConstBitDepth; // Bit depth used to specify Z constant for destination + union + { + DWORD dwZDestConst; // Constant to use as Z buffer for dest + LPDIRECTDRAWSURFACE lpDDSZBufferDest; // Surface to use as Z buffer for dest + } DUMMYUNIONNAMEN(1); + DWORD dwZSrcConstBitDepth; // Bit depth used to specify Z constant for source + union + { + DWORD dwZSrcConst; // Constant to use as Z buffer for src + LPDIRECTDRAWSURFACE lpDDSZBufferSrc; // Surface to use as Z buffer for src + } DUMMYUNIONNAMEN(2); + DWORD dwAlphaEdgeBlendBitDepth; // Bit depth used to specify constant for alpha edge blend + DWORD dwAlphaEdgeBlend; // Alpha for edge blending + DWORD dwReserved; + DWORD dwAlphaDestConstBitDepth; // Bit depth used to specify alpha constant for destination + union + { + DWORD dwAlphaDestConst; // Constant to use as Alpha Channel + LPDIRECTDRAWSURFACE lpDDSAlphaDest; // Surface to use as Alpha Channel + } DUMMYUNIONNAMEN(3); + DWORD dwAlphaSrcConstBitDepth; // Bit depth used to specify alpha constant for source + union + { + DWORD dwAlphaSrcConst; // Constant to use as Alpha Channel + LPDIRECTDRAWSURFACE lpDDSAlphaSrc; // Surface to use as Alpha Channel + } DUMMYUNIONNAMEN(4); + union + { + DWORD dwFillColor; // color in RGB or Palettized + DWORD dwFillDepth; // depth value for z-buffer + DWORD dwFillPixel; // pixel value for RGBA or RGBZ + LPDIRECTDRAWSURFACE lpDDSPattern; // Surface to use as pattern + } DUMMYUNIONNAMEN(5); + DDCOLORKEY ddckDestColorkey; // DestColorkey override + DDCOLORKEY ddckSrcColorkey; // SrcColorkey override +} DDBLTFX; + +typedef DDBLTFX FAR* LPDDBLTFX; + + + +/* + * DDSCAPS + */ +typedef struct _DDSCAPS +{ + DWORD dwCaps; // capabilities of surface wanted +} DDSCAPS; + +typedef DDSCAPS FAR* LPDDSCAPS; + + +/* + * DDOSCAPS + */ +typedef struct _DDOSCAPS +{ + DWORD dwCaps; // capabilities of surface wanted +} DDOSCAPS; + +typedef DDOSCAPS FAR* LPDDOSCAPS; + +/* + * This structure is used internally by DirectDraw. + */ +typedef struct _DDSCAPSEX +{ + DWORD dwCaps2; + DWORD dwCaps3; + union + { + DWORD dwCaps4; + DWORD dwVolumeDepth; + } DUMMYUNIONNAMEN(1); +} DDSCAPSEX, FAR * LPDDSCAPSEX; + +/* + * DDSCAPS2 + */ +typedef struct _DDSCAPS2 +{ + DWORD dwCaps; // capabilities of surface wanted + DWORD dwCaps2; + DWORD dwCaps3; + union + { + DWORD dwCaps4; + DWORD dwVolumeDepth; + } DUMMYUNIONNAMEN(1); +} DDSCAPS2; + +typedef DDSCAPS2 FAR* LPDDSCAPS2; + +/* + * DDCAPS + */ +#define DD_ROP_SPACE (256/32) // space required to store ROP array +/* + * NOTE: Our choosen structure number scheme is to append a single digit to + * the end of the structure giving the version that structure is associated + * with. + */ + +/* + * This structure represents the DDCAPS structure released in DirectDraw 1.0. It is used internally + * by DirectDraw to interpret caps passed into ddraw by drivers written prior to the release of DirectDraw 2.0. + * New applications should use the DDCAPS structure defined below. + */ +typedef struct _DDCAPS_DX1 +{ + DWORD dwSize; // size of the DDDRIVERCAPS structure + DWORD dwCaps; // driver specific capabilities + DWORD dwCaps2; // more driver specific capabilites + DWORD dwCKeyCaps; // color key capabilities of the surface + DWORD dwFXCaps; // driver specific stretching and effects capabilites + DWORD dwFXAlphaCaps; // alpha driver specific capabilities + DWORD dwPalCaps; // palette capabilities + DWORD dwSVCaps; // stereo vision capabilities + DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 + DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 + DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 + DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 + DWORD dwVidMemTotal; // total amount of video memory + DWORD dwVidMemFree; // amount of free video memory + DWORD dwMaxVisibleOverlays; // maximum number of visible overlays + DWORD dwCurrVisibleOverlays; // current number of visible overlays + DWORD dwNumFourCCCodes; // number of four cc codes + DWORD dwAlignBoundarySrc; // source rectangle alignment + DWORD dwAlignSizeSrc; // source rectangle byte size + DWORD dwAlignBoundaryDest; // dest rectangle alignment + DWORD dwAlignSizeDest; // dest rectangle byte size + DWORD dwAlignStrideAlign; // stride alignment + DWORD dwRops[DD_ROP_SPACE]; // ROPS supported + DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities + DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMinLiveVideoStretch; // OBSOLETE! This field remains for compatability reasons only + DWORD dwMaxLiveVideoStretch; // OBSOLETE! This field remains for compatability reasons only + DWORD dwMinHwCodecStretch; // OBSOLETE! This field remains for compatability reasons only + DWORD dwMaxHwCodecStretch; // OBSOLETE! This field remains for compatability reasons only + DWORD dwReserved1; // reserved + DWORD dwReserved2; // reserved + DWORD dwReserved3; // reserved +} DDCAPS_DX1; + +typedef DDCAPS_DX1 FAR* LPDDCAPS_DX1; + +/* + * This structure is the DDCAPS structure as it was in version 2 and 3 of Direct X. + * It is present for back compatability. + */ +typedef struct _DDCAPS_DX3 +{ + DWORD dwSize; // size of the DDDRIVERCAPS structure + DWORD dwCaps; // driver specific capabilities + DWORD dwCaps2; // more driver specific capabilites + DWORD dwCKeyCaps; // color key capabilities of the surface + DWORD dwFXCaps; // driver specific stretching and effects capabilites + DWORD dwFXAlphaCaps; // alpha driver specific capabilities + DWORD dwPalCaps; // palette capabilities + DWORD dwSVCaps; // stereo vision capabilities + DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 + DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 + DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 + DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 + DWORD dwVidMemTotal; // total amount of video memory + DWORD dwVidMemFree; // amount of free video memory + DWORD dwMaxVisibleOverlays; // maximum number of visible overlays + DWORD dwCurrVisibleOverlays; // current number of visible overlays + DWORD dwNumFourCCCodes; // number of four cc codes + DWORD dwAlignBoundarySrc; // source rectangle alignment + DWORD dwAlignSizeSrc; // source rectangle byte size + DWORD dwAlignBoundaryDest; // dest rectangle alignment + DWORD dwAlignSizeDest; // dest rectangle byte size + DWORD dwAlignStrideAlign; // stride alignment + DWORD dwRops[DD_ROP_SPACE]; // ROPS supported + DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities + DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwReserved1; // reserved + DWORD dwReserved2; // reserved + DWORD dwReserved3; // reserved + DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts + DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts + DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts + DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts + DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts + DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts + DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts + DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts + DWORD dwSSBCaps; // driver specific capabilities for System->System blts + DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts + DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts + DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts + DWORD dwReserved4; // reserved + DWORD dwReserved5; // reserved + DWORD dwReserved6; // reserved +} DDCAPS_DX3; +typedef DDCAPS_DX3 FAR* LPDDCAPS_DX3; + +/* + * This structure is the DDCAPS structure as it was in version 5 of Direct X. + * It is present for back compatability. + */ +typedef struct _DDCAPS_DX5 +{ +/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure +/* 4*/ DWORD dwCaps; // driver specific capabilities +/* 8*/ DWORD dwCaps2; // more driver specific capabilites +/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface +/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites +/* 14*/ DWORD dwFXAlphaCaps; // alpha driver specific capabilities +/* 18*/ DWORD dwPalCaps; // palette capabilities +/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities +/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 +/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 +/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 +/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 +/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 +/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 +/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 +/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory +/* 40*/ DWORD dwVidMemFree; // amount of free video memory +/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays +/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays +/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes +/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment +/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size +/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment +/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size +/* 60*/ DWORD dwAlignStrideAlign; // stride alignment +/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported +/* 84*/ DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities +/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* a0*/ DWORD dwReserved1; // reserved +/* a4*/ DWORD dwReserved2; // reserved +/* a8*/ DWORD dwReserved3; // reserved +/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts +/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts +/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts +/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts +/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts +/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts +/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts +/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts +/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts +/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts +/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts +/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts +// Members added for DX5: +/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports +/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used +/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts +/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts +/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts +/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts +/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts +/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts +} DDCAPS_DX5; +typedef DDCAPS_DX5 FAR* LPDDCAPS_DX5; + +typedef struct _DDCAPS_DX6 +{ +/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure +/* 4*/ DWORD dwCaps; // driver specific capabilities +/* 8*/ DWORD dwCaps2; // more driver specific capabilites +/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface +/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites +/* 14*/ DWORD dwFXAlphaCaps; // alpha caps +/* 18*/ DWORD dwPalCaps; // palette capabilities +/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities +/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 +/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 +/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 +/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 +/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 +/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 +/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 +/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory +/* 40*/ DWORD dwVidMemFree; // amount of free video memory +/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays +/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays +/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes +/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment +/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size +/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment +/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size +/* 60*/ DWORD dwAlignStrideAlign; // stride alignment +/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported +/* 84*/ DDSCAPS ddsOldCaps; // Was DDSCAPS ddsCaps. ddsCaps is of type DDSCAPS2 for DX6 +/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* a0*/ DWORD dwReserved1; // reserved +/* a4*/ DWORD dwReserved2; // reserved +/* a8*/ DWORD dwReserved3; // reserved +/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts +/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts +/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts +/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts +/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts +/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts +/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts +/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts +/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts +/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts +/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts +/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts +/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports +/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used +/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts +/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts +/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts +/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts +/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts +/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts +// Members added for DX6 release +/*16c*/ DDSCAPS2 ddsCaps; // Surface Caps +} DDCAPS_DX6; +typedef DDCAPS_DX6 FAR* LPDDCAPS_DX6; + +typedef struct _DDCAPS_DX7 +{ +/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure +/* 4*/ DWORD dwCaps; // driver specific capabilities +/* 8*/ DWORD dwCaps2; // more driver specific capabilites +/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface +/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites +/* 14*/ DWORD dwFXAlphaCaps; // alpha driver specific capabilities +/* 18*/ DWORD dwPalCaps; // palette capabilities +/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities +/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 +/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 +/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 +/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 +/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 +/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 +/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 +/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory +/* 40*/ DWORD dwVidMemFree; // amount of free video memory +/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays +/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays +/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes +/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment +/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size +/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment +/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size +/* 60*/ DWORD dwAlignStrideAlign; // stride alignment +/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported +/* 84*/ DDSCAPS ddsOldCaps; // Was DDSCAPS ddsCaps. ddsCaps is of type DDSCAPS2 for DX6 +/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* a0*/ DWORD dwReserved1; // reserved +/* a4*/ DWORD dwReserved2; // reserved +/* a8*/ DWORD dwReserved3; // reserved +/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts +/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts +/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts +/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts +/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts +/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts +/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts +/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts +/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts +/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts +/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts +/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts +/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports +/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used +/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts +/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts +/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts +/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts +/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts +/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts +// Members added for DX6 release +/*16c*/ DDSCAPS2 ddsCaps; // Surface Caps +} DDCAPS_DX7; +typedef DDCAPS_DX7 FAR* LPDDCAPS_DX7; + + +#if DIRECTDRAW_VERSION <= 0x300 + typedef DDCAPS_DX3 DDCAPS; +#elif DIRECTDRAW_VERSION <= 0x500 + typedef DDCAPS_DX5 DDCAPS; +#elif DIRECTDRAW_VERSION <= 0x600 + typedef DDCAPS_DX6 DDCAPS; +#else + typedef DDCAPS_DX7 DDCAPS; +#endif + +typedef DDCAPS FAR* LPDDCAPS; + + + +/* + * DDPIXELFORMAT + */ +typedef struct _DDPIXELFORMAT +{ + DWORD dwSize; // size of structure + DWORD dwFlags; // pixel format flags + DWORD dwFourCC; // (FOURCC code) + union + { + DWORD dwRGBBitCount; // how many bits per pixel + DWORD dwYUVBitCount; // how many bits per pixel + DWORD dwZBufferBitDepth; // how many total bits/pixel in z buffer (including any stencil bits) + DWORD dwAlphaBitDepth; // how many bits for alpha channels + DWORD dwLuminanceBitCount; // how many bits per pixel + DWORD dwBumpBitCount; // how many bits per "buxel", total + DWORD dwPrivateFormatBitCount;// Bits per pixel of private driver formats. Only valid in texture + // format list and if DDPF_D3DFORMAT is set + } DUMMYUNIONNAMEN(1); + union + { + DWORD dwRBitMask; // mask for red bit + DWORD dwYBitMask; // mask for Y bits + DWORD dwStencilBitDepth; // how many stencil bits (note: dwZBufferBitDepth-dwStencilBitDepth is total Z-only bits) + DWORD dwLuminanceBitMask; // mask for luminance bits + DWORD dwBumpDuBitMask; // mask for bump map U delta bits + DWORD dwOperations; // DDPF_D3DFORMAT Operations + } DUMMYUNIONNAMEN(2); + union + { + DWORD dwGBitMask; // mask for green bits + DWORD dwUBitMask; // mask for U bits + DWORD dwZBitMask; // mask for Z bits + DWORD dwBumpDvBitMask; // mask for bump map V delta bits + struct + { + WORD wFlipMSTypes; // Multisample methods supported via flip for this D3DFORMAT + WORD wBltMSTypes; // Multisample methods supported via blt for this D3DFORMAT + } MultiSampleCaps; + + } DUMMYUNIONNAMEN(3); + union + { + DWORD dwBBitMask; // mask for blue bits + DWORD dwVBitMask; // mask for V bits + DWORD dwStencilBitMask; // mask for stencil bits + DWORD dwBumpLuminanceBitMask; // mask for luminance in bump map + } DUMMYUNIONNAMEN(4); + union + { + DWORD dwRGBAlphaBitMask; // mask for alpha channel + DWORD dwYUVAlphaBitMask; // mask for alpha channel + DWORD dwLuminanceAlphaBitMask;// mask for alpha channel + DWORD dwRGBZBitMask; // mask for Z channel + DWORD dwYUVZBitMask; // mask for Z channel + } DUMMYUNIONNAMEN(5); +} DDPIXELFORMAT; + +typedef DDPIXELFORMAT FAR* LPDDPIXELFORMAT; + +/* + * DDOVERLAYFX + */ +typedef struct _DDOVERLAYFX +{ + DWORD dwSize; // size of structure + DWORD dwAlphaEdgeBlendBitDepth; // Bit depth used to specify constant for alpha edge blend + DWORD dwAlphaEdgeBlend; // Constant to use as alpha for edge blend + DWORD dwReserved; + DWORD dwAlphaDestConstBitDepth; // Bit depth used to specify alpha constant for destination + union + { + DWORD dwAlphaDestConst; // Constant to use as alpha channel for dest + LPDIRECTDRAWSURFACE lpDDSAlphaDest; // Surface to use as alpha channel for dest + } DUMMYUNIONNAMEN(1); + DWORD dwAlphaSrcConstBitDepth; // Bit depth used to specify alpha constant for source + union + { + DWORD dwAlphaSrcConst; // Constant to use as alpha channel for src + LPDIRECTDRAWSURFACE lpDDSAlphaSrc; // Surface to use as alpha channel for src + } DUMMYUNIONNAMEN(2); + DDCOLORKEY dckDestColorkey; // DestColorkey override + DDCOLORKEY dckSrcColorkey; // DestColorkey override + DWORD dwDDFX; // Overlay FX + DWORD dwFlags; // flags +} DDOVERLAYFX; + +typedef DDOVERLAYFX FAR *LPDDOVERLAYFX; + + +/* + * DDBLTBATCH: BltBatch entry structure + */ +typedef struct _DDBLTBATCH +{ + LPRECT lprDest; + LPDIRECTDRAWSURFACE lpDDSSrc; + LPRECT lprSrc; + DWORD dwFlags; + LPDDBLTFX lpDDBltFx; +} DDBLTBATCH; + +typedef DDBLTBATCH FAR * LPDDBLTBATCH; + + +/* + * DDGAMMARAMP + */ +typedef struct _DDGAMMARAMP +{ + WORD red[256]; + WORD green[256]; + WORD blue[256]; +} DDGAMMARAMP; +typedef DDGAMMARAMP FAR * LPDDGAMMARAMP; + +/* + * This is the structure within which DirectDraw returns data about the current graphics driver and chipset + */ + +#define MAX_DDDEVICEID_STRING 512 + +typedef struct tagDDDEVICEIDENTIFIER +{ + /* + * These elements are for presentation to the user only. They should not be used to identify particular + * drivers, since this is unreliable and many different strings may be associated with the same + * device, and the same driver from different vendors. + */ + char szDriver[MAX_DDDEVICEID_STRING]; + char szDescription[MAX_DDDEVICEID_STRING]; + + /* + * This element is the version of the DirectDraw/3D driver. It is legal to do <, > comparisons + * on the whole 64 bits. Caution should be exercised if you use this element to identify problematic + * drivers. It is recommended that guidDeviceIdentifier is used for this purpose. + * + * This version has the form: + * wProduct = HIWORD(liDriverVersion.HighPart) + * wVersion = LOWORD(liDriverVersion.HighPart) + * wSubVersion = HIWORD(liDriverVersion.LowPart) + * wBuild = LOWORD(liDriverVersion.LowPart) + */ +#ifdef _WIN32 + LARGE_INTEGER liDriverVersion; /* Defined for applications and other 32 bit components */ +#else + DWORD dwDriverVersionLowPart; /* Defined for 16 bit driver components */ + DWORD dwDriverVersionHighPart; +#endif + + + /* + * These elements can be used to identify particular chipsets. Use with extreme caution. + * dwVendorId Identifies the manufacturer. May be zero if unknown. + * dwDeviceId Identifies the type of chipset. May be zero if unknown. + * dwSubSysId Identifies the subsystem, typically this means the particular board. May be zero if unknown. + * dwRevision Identifies the revision level of the chipset. May be zero if unknown. + */ + DWORD dwVendorId; + DWORD dwDeviceId; + DWORD dwSubSysId; + DWORD dwRevision; + + /* + * This element can be used to check changes in driver/chipset. This GUID is a unique identifier for the + * driver/chipset pair. Use this element if you wish to track changes to the driver/chipset in order to + * reprofile the graphics subsystem. + * This element can also be used to identify particular problematic drivers. + */ + GUID guidDeviceIdentifier; +} DDDEVICEIDENTIFIER, * LPDDDEVICEIDENTIFIER; + +typedef struct tagDDDEVICEIDENTIFIER2 +{ + /* + * These elements are for presentation to the user only. They should not be used to identify particular + * drivers, since this is unreliable and many different strings may be associated with the same + * device, and the same driver from different vendors. + */ + char szDriver[MAX_DDDEVICEID_STRING]; + char szDescription[MAX_DDDEVICEID_STRING]; + + /* + * This element is the version of the DirectDraw/3D driver. It is legal to do <, > comparisons + * on the whole 64 bits. Caution should be exercised if you use this element to identify problematic + * drivers. It is recommended that guidDeviceIdentifier is used for this purpose. + * + * This version has the form: + * wProduct = HIWORD(liDriverVersion.HighPart) + * wVersion = LOWORD(liDriverVersion.HighPart) + * wSubVersion = HIWORD(liDriverVersion.LowPart) + * wBuild = LOWORD(liDriverVersion.LowPart) + */ +#ifdef _WIN32 + LARGE_INTEGER liDriverVersion; /* Defined for applications and other 32 bit components */ +#else + DWORD dwDriverVersionLowPart; /* Defined for 16 bit driver components */ + DWORD dwDriverVersionHighPart; +#endif + + + /* + * These elements can be used to identify particular chipsets. Use with extreme caution. + * dwVendorId Identifies the manufacturer. May be zero if unknown. + * dwDeviceId Identifies the type of chipset. May be zero if unknown. + * dwSubSysId Identifies the subsystem, typically this means the particular board. May be zero if unknown. + * dwRevision Identifies the revision level of the chipset. May be zero if unknown. + */ + DWORD dwVendorId; + DWORD dwDeviceId; + DWORD dwSubSysId; + DWORD dwRevision; + + /* + * This element can be used to check changes in driver/chipset. This GUID is a unique identifier for the + * driver/chipset pair. Use this element if you wish to track changes to the driver/chipset in order to + * reprofile the graphics subsystem. + * This element can also be used to identify particular problematic drivers. + */ + GUID guidDeviceIdentifier; + + /* + * This element is used to determine the Windows Hardware Quality Lab (WHQL) + * certification level for this driver/device pair. + */ + DWORD dwWHQLLevel; + +} DDDEVICEIDENTIFIER2, * LPDDDEVICEIDENTIFIER2; + +/* + * Flags for the IDirectDraw4::GetDeviceIdentifier method + */ + +/* + * This flag causes GetDeviceIdentifier to return information about the host (typically 2D) adapter in a system equipped + * with a stacked secondary 3D adapter. Such an adapter appears to the application as if it were part of the + * host adapter, but is typically physcially located on a separate card. The stacked secondary's information is + * returned when GetDeviceIdentifier's dwFlags field is zero, since this most accurately reflects the qualities + * of the DirectDraw object involved. + */ +#define DDGDI_GETHOSTIDENTIFIER 0x00000001L + +/* + * Macros for interpretting DDEVICEIDENTIFIER2.dwWHQLLevel + */ +#define GET_WHQL_YEAR( dwWHQLLevel ) \ + ( (dwWHQLLevel) / 0x10000 ) +#define GET_WHQL_MONTH( dwWHQLLevel ) \ + ( ( (dwWHQLLevel) / 0x100 ) & 0x00ff ) +#define GET_WHQL_DAY( dwWHQLLevel ) \ + ( (dwWHQLLevel) & 0xff ) + + +/* + * callbacks + */ +typedef DWORD (FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper, HWND hWnd, DWORD code, LPVOID lpContext ); +#ifdef STREAMING +typedef DWORD (FAR PASCAL *LPSURFACESTREAMINGCALLBACK)(DWORD); +#endif + + +/* + * INTERACES FOLLOW: + * IDirectDraw + * IDirectDrawClipper + * IDirectDrawPalette + * IDirectDrawSurface + */ + +/* + * IDirectDraw + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDraw +DECLARE_INTERFACE_( IDirectDraw, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDraw methods ***/ + STDMETHOD(Compact)(THIS) PURE; + STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *) PURE; + STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE FAR * ) PURE; + STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK ) PURE; + STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK ) PURE; + STDMETHOD(FlipToGDISurface)(THIS) PURE; + STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; + STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; + STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE FAR *) PURE; + STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; + STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; + STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; + STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; + STDMETHOD(RestoreDisplayMode)(THIS) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; + STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD) PURE; + STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDraw_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDraw_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDraw_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDraw_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectDraw_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) +#define IDirectDraw_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) +#define IDirectDraw_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) +#define IDirectDraw_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) +#define IDirectDraw_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) +#define IDirectDraw_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) +#define IDirectDraw_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) +#define IDirectDraw_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) +#define IDirectDraw_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) +#define IDirectDraw_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) +#define IDirectDraw_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) +#define IDirectDraw_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) +#define IDirectDraw_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) +#define IDirectDraw_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) +#define IDirectDraw_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) +#define IDirectDraw_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) +#define IDirectDraw_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) +#define IDirectDraw_SetDisplayMode(p, a, b, c) (p)->lpVtbl->SetDisplayMode(p, a, b, c) +#define IDirectDraw_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) +#else +#define IDirectDraw_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDraw_AddRef(p) (p)->AddRef() +#define IDirectDraw_Release(p) (p)->Release() +#define IDirectDraw_Compact(p) (p)->Compact() +#define IDirectDraw_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) +#define IDirectDraw_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) +#define IDirectDraw_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) +#define IDirectDraw_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) +#define IDirectDraw_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) +#define IDirectDraw_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) +#define IDirectDraw_FlipToGDISurface(p) (p)->FlipToGDISurface() +#define IDirectDraw_GetCaps(p, a, b) (p)->GetCaps(a, b) +#define IDirectDraw_GetDisplayMode(p, a) (p)->GetDisplayMode(a) +#define IDirectDraw_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) +#define IDirectDraw_GetGDISurface(p, a) (p)->GetGDISurface(a) +#define IDirectDraw_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) +#define IDirectDraw_GetScanLine(p, a) (p)->GetScanLine(a) +#define IDirectDraw_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) +#define IDirectDraw_Initialize(p, a) (p)->Initialize(a) +#define IDirectDraw_RestoreDisplayMode(p) (p)->RestoreDisplayMode() +#define IDirectDraw_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) +#define IDirectDraw_SetDisplayMode(p, a, b, c) (p)->SetDisplayMode(a, b, c) +#define IDirectDraw_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) +#endif + +#endif + +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDraw2 +DECLARE_INTERFACE_( IDirectDraw2, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDraw methods ***/ + STDMETHOD(Compact)(THIS) PURE; + STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *) PURE; + STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE FAR * ) PURE; + STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK ) PURE; + STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK ) PURE; + STDMETHOD(FlipToGDISurface)(THIS) PURE; + STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; + STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; + STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE FAR *) PURE; + STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; + STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; + STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; + STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; + STDMETHOD(RestoreDisplayMode)(THIS) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; + STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; + STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS, LPDWORD, LPDWORD) PURE; +}; +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDraw2_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDraw2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDraw2_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDraw2_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectDraw2_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) +#define IDirectDraw2_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) +#define IDirectDraw2_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) +#define IDirectDraw2_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) +#define IDirectDraw2_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) +#define IDirectDraw2_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) +#define IDirectDraw2_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) +#define IDirectDraw2_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) +#define IDirectDraw2_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) +#define IDirectDraw2_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) +#define IDirectDraw2_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) +#define IDirectDraw2_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) +#define IDirectDraw2_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) +#define IDirectDraw2_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) +#define IDirectDraw2_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) +#define IDirectDraw2_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) +#define IDirectDraw2_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) +#define IDirectDraw2_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) +#define IDirectDraw2_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) +#define IDirectDraw2_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) +#else +#define IDirectDraw2_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDraw2_AddRef(p) (p)->AddRef() +#define IDirectDraw2_Release(p) (p)->Release() +#define IDirectDraw2_Compact(p) (p)->Compact() +#define IDirectDraw2_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) +#define IDirectDraw2_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) +#define IDirectDraw2_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) +#define IDirectDraw2_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) +#define IDirectDraw2_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) +#define IDirectDraw2_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) +#define IDirectDraw2_FlipToGDISurface(p) (p)->FlipToGDISurface() +#define IDirectDraw2_GetCaps(p, a, b) (p)->GetCaps(a, b) +#define IDirectDraw2_GetDisplayMode(p, a) (p)->GetDisplayMode(a) +#define IDirectDraw2_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) +#define IDirectDraw2_GetGDISurface(p, a) (p)->GetGDISurface(a) +#define IDirectDraw2_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) +#define IDirectDraw2_GetScanLine(p, a) (p)->GetScanLine(a) +#define IDirectDraw2_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) +#define IDirectDraw2_Initialize(p, a) (p)->Initialize(a) +#define IDirectDraw2_RestoreDisplayMode(p) (p)->RestoreDisplayMode() +#define IDirectDraw2_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) +#define IDirectDraw2_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) +#define IDirectDraw2_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) +#define IDirectDraw2_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) +#endif + +#endif + +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDraw4 +DECLARE_INTERFACE_( IDirectDraw4, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDraw methods ***/ + STDMETHOD(Compact)(THIS) PURE; + STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC2, LPDIRECTDRAWSURFACE4 FAR *, IUnknown FAR *) PURE; + STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE4, LPDIRECTDRAWSURFACE4 FAR * ) PURE; + STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC2, LPVOID, LPDDENUMMODESCALLBACK2 ) PURE; + STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC2, LPVOID,LPDDENUMSURFACESCALLBACK2 ) PURE; + STDMETHOD(FlipToGDISurface)(THIS) PURE; + STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; + STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC2) PURE; + STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; + STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE4 FAR *) PURE; + STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; + STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; + STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; + STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; + STDMETHOD(RestoreDisplayMode)(THIS) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; + STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; + STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS2, LPDWORD, LPDWORD) PURE; + /*** Added in the V4 Interface ***/ + STDMETHOD(GetSurfaceFromDC) (THIS_ HDC, LPDIRECTDRAWSURFACE4 *) PURE; + STDMETHOD(RestoreAllSurfaces)(THIS) PURE; + STDMETHOD(TestCooperativeLevel)(THIS) PURE; + STDMETHOD(GetDeviceIdentifier)(THIS_ LPDDDEVICEIDENTIFIER, DWORD ) PURE; +}; +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDraw4_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDraw4_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDraw4_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDraw4_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectDraw4_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) +#define IDirectDraw4_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) +#define IDirectDraw4_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) +#define IDirectDraw4_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) +#define IDirectDraw4_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) +#define IDirectDraw4_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) +#define IDirectDraw4_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) +#define IDirectDraw4_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) +#define IDirectDraw4_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) +#define IDirectDraw4_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) +#define IDirectDraw4_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) +#define IDirectDraw4_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) +#define IDirectDraw4_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) +#define IDirectDraw4_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) +#define IDirectDraw4_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) +#define IDirectDraw4_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) +#define IDirectDraw4_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) +#define IDirectDraw4_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) +#define IDirectDraw4_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) +#define IDirectDraw4_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) +#define IDirectDraw4_GetSurfaceFromDC(p, a, b) (p)->lpVtbl->GetSurfaceFromDC(p, a, b) +#define IDirectDraw4_RestoreAllSurfaces(p) (p)->lpVtbl->RestoreAllSurfaces(p) +#define IDirectDraw4_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) +#define IDirectDraw4_GetDeviceIdentifier(p,a,b) (p)->lpVtbl->GetDeviceIdentifier(p,a,b) +#else +#define IDirectDraw4_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDraw4_AddRef(p) (p)->AddRef() +#define IDirectDraw4_Release(p) (p)->Release() +#define IDirectDraw4_Compact(p) (p)->Compact() +#define IDirectDraw4_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) +#define IDirectDraw4_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) +#define IDirectDraw4_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) +#define IDirectDraw4_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) +#define IDirectDraw4_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) +#define IDirectDraw4_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) +#define IDirectDraw4_FlipToGDISurface(p) (p)->FlipToGDISurface() +#define IDirectDraw4_GetCaps(p, a, b) (p)->GetCaps(a, b) +#define IDirectDraw4_GetDisplayMode(p, a) (p)->GetDisplayMode(a) +#define IDirectDraw4_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) +#define IDirectDraw4_GetGDISurface(p, a) (p)->GetGDISurface(a) +#define IDirectDraw4_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) +#define IDirectDraw4_GetScanLine(p, a) (p)->GetScanLine(a) +#define IDirectDraw4_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) +#define IDirectDraw4_Initialize(p, a) (p)->Initialize(a) +#define IDirectDraw4_RestoreDisplayMode(p) (p)->RestoreDisplayMode() +#define IDirectDraw4_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) +#define IDirectDraw4_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) +#define IDirectDraw4_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) +#define IDirectDraw4_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) +#define IDirectDraw4_GetSurfaceFromDC(p, a, b) (p)->GetSurfaceFromDC(a, b) +#define IDirectDraw4_RestoreAllSurfaces(p) (p)->RestoreAllSurfaces() +#define IDirectDraw4_TestCooperativeLevel(p) (p)->TestCooperativeLevel() +#define IDirectDraw4_GetDeviceIdentifier(p,a,b) (p)->GetDeviceIdentifier(a,b) +#endif + +#endif + +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDraw7 +DECLARE_INTERFACE_( IDirectDraw7, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDraw methods ***/ + STDMETHOD(Compact)(THIS) PURE; + STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC2, LPDIRECTDRAWSURFACE7 FAR *, IUnknown FAR *) PURE; + STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE7, LPDIRECTDRAWSURFACE7 FAR * ) PURE; + STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC2, LPVOID, LPDDENUMMODESCALLBACK2 ) PURE; + STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC2, LPVOID,LPDDENUMSURFACESCALLBACK7 ) PURE; + STDMETHOD(FlipToGDISurface)(THIS) PURE; + STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; + STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC2) PURE; + STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; + STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE7 FAR *) PURE; + STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; + STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; + STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; + STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; + STDMETHOD(RestoreDisplayMode)(THIS) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; + STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; + STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS2, LPDWORD, LPDWORD) PURE; + /*** Added in the V4 Interface ***/ + STDMETHOD(GetSurfaceFromDC) (THIS_ HDC, LPDIRECTDRAWSURFACE7 *) PURE; + STDMETHOD(RestoreAllSurfaces)(THIS) PURE; + STDMETHOD(TestCooperativeLevel)(THIS) PURE; + STDMETHOD(GetDeviceIdentifier)(THIS_ LPDDDEVICEIDENTIFIER2, DWORD ) PURE; + STDMETHOD(StartModeTest)(THIS_ LPSIZE, DWORD, DWORD ) PURE; + STDMETHOD(EvaluateMode)(THIS_ DWORD, DWORD * ) PURE; +}; +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDraw7_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDraw7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDraw7_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDraw7_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectDraw7_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) +#define IDirectDraw7_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) +#define IDirectDraw7_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) +#define IDirectDraw7_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) +#define IDirectDraw7_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) +#define IDirectDraw7_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) +#define IDirectDraw7_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) +#define IDirectDraw7_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) +#define IDirectDraw7_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) +#define IDirectDraw7_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) +#define IDirectDraw7_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) +#define IDirectDraw7_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) +#define IDirectDraw7_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) +#define IDirectDraw7_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) +#define IDirectDraw7_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) +#define IDirectDraw7_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) +#define IDirectDraw7_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) +#define IDirectDraw7_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) +#define IDirectDraw7_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) +#define IDirectDraw7_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) +#define IDirectDraw7_GetSurfaceFromDC(p, a, b) (p)->lpVtbl->GetSurfaceFromDC(p, a, b) +#define IDirectDraw7_RestoreAllSurfaces(p) (p)->lpVtbl->RestoreAllSurfaces(p) +#define IDirectDraw7_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) +#define IDirectDraw7_GetDeviceIdentifier(p,a,b) (p)->lpVtbl->GetDeviceIdentifier(p,a,b) +#define IDirectDraw7_StartModeTest(p,a,b,c) (p)->lpVtbl->StartModeTest(p,a,b,c) +#define IDirectDraw7_EvaluateMode(p,a,b) (p)->lpVtbl->EvaluateMode(p,a,b) +#else +#define IDirectDraw7_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDraw7_AddRef(p) (p)->AddRef() +#define IDirectDraw7_Release(p) (p)->Release() +#define IDirectDraw7_Compact(p) (p)->Compact() +#define IDirectDraw7_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) +#define IDirectDraw7_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) +#define IDirectDraw7_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) +#define IDirectDraw7_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) +#define IDirectDraw7_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) +#define IDirectDraw7_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) +#define IDirectDraw7_FlipToGDISurface(p) (p)->FlipToGDISurface() +#define IDirectDraw7_GetCaps(p, a, b) (p)->GetCaps(a, b) +#define IDirectDraw7_GetDisplayMode(p, a) (p)->GetDisplayMode(a) +#define IDirectDraw7_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) +#define IDirectDraw7_GetGDISurface(p, a) (p)->GetGDISurface(a) +#define IDirectDraw7_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) +#define IDirectDraw7_GetScanLine(p, a) (p)->GetScanLine(a) +#define IDirectDraw7_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) +#define IDirectDraw7_Initialize(p, a) (p)->Initialize(a) +#define IDirectDraw7_RestoreDisplayMode(p) (p)->RestoreDisplayMode() +#define IDirectDraw7_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) +#define IDirectDraw7_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) +#define IDirectDraw7_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) +#define IDirectDraw7_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) +#define IDirectDraw7_GetSurfaceFromDC(p, a, b) (p)->GetSurfaceFromDC(a, b) +#define IDirectDraw7_RestoreAllSurfaces(p) (p)->RestoreAllSurfaces() +#define IDirectDraw7_TestCooperativeLevel(p) (p)->TestCooperativeLevel() +#define IDirectDraw7_GetDeviceIdentifier(p,a,b) (p)->GetDeviceIdentifier(a,b) +#define IDirectDraw7_StartModeTest(p,a,b,c) (p)->lpVtbl->StartModeTest(a,b,c) +#define IDirectDraw7_EvaluateMode(p,a,b) (p)->lpVtbl->EvaluateMode(a,b) +#endif + +#endif + + +/* + * IDirectDrawPalette + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawPalette +DECLARE_INTERFACE_( IDirectDrawPalette, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawPalette methods ***/ + STDMETHOD(GetCaps)(THIS_ LPDWORD) PURE; + STDMETHOD(GetEntries)(THIS_ DWORD,DWORD,DWORD,LPPALETTEENTRY) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, DWORD, LPPALETTEENTRY) PURE; + STDMETHOD(SetEntries)(THIS_ DWORD,DWORD,DWORD,LPPALETTEENTRY) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawPalette_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDrawPalette_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawPalette_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawPalette_GetCaps(p, a) (p)->lpVtbl->GetCaps(p, a) +#define IDirectDrawPalette_GetEntries(p, a, b, c, d) (p)->lpVtbl->GetEntries(p, a, b, c, d) +#define IDirectDrawPalette_Initialize(p, a, b, c) (p)->lpVtbl->Initialize(p, a, b, c) +#define IDirectDrawPalette_SetEntries(p, a, b, c, d) (p)->lpVtbl->SetEntries(p, a, b, c, d) +#else +#define IDirectDrawPalette_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDrawPalette_AddRef(p) (p)->AddRef() +#define IDirectDrawPalette_Release(p) (p)->Release() +#define IDirectDrawPalette_GetCaps(p, a) (p)->GetCaps(a) +#define IDirectDrawPalette_GetEntries(p, a, b, c, d) (p)->GetEntries(a, b, c, d) +#define IDirectDrawPalette_Initialize(p, a, b, c) (p)->Initialize(a, b, c) +#define IDirectDrawPalette_SetEntries(p, a, b, c, d) (p)->SetEntries(a, b, c, d) +#endif + +#endif + + +/* + * IDirectDrawClipper + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawClipper +DECLARE_INTERFACE_( IDirectDrawClipper, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawClipper methods ***/ + STDMETHOD(GetClipList)(THIS_ LPRECT, LPRGNDATA, LPDWORD) PURE; + STDMETHOD(GetHWnd)(THIS_ HWND FAR *) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, DWORD) PURE; + STDMETHOD(IsClipListChanged)(THIS_ BOOL FAR *) PURE; + STDMETHOD(SetClipList)(THIS_ LPRGNDATA,DWORD) PURE; + STDMETHOD(SetHWnd)(THIS_ DWORD, HWND ) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawClipper_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDrawClipper_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawClipper_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawClipper_GetClipList(p, a, b, c) (p)->lpVtbl->GetClipList(p, a, b, c) +#define IDirectDrawClipper_GetHWnd(p, a) (p)->lpVtbl->GetHWnd(p, a) +#define IDirectDrawClipper_Initialize(p, a, b) (p)->lpVtbl->Initialize(p, a, b) +#define IDirectDrawClipper_IsClipListChanged(p, a) (p)->lpVtbl->IsClipListChanged(p, a) +#define IDirectDrawClipper_SetClipList(p, a, b) (p)->lpVtbl->SetClipList(p, a, b) +#define IDirectDrawClipper_SetHWnd(p, a, b) (p)->lpVtbl->SetHWnd(p, a, b) +#else +#define IDirectDrawClipper_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDrawClipper_AddRef(p) (p)->AddRef() +#define IDirectDrawClipper_Release(p) (p)->Release() +#define IDirectDrawClipper_GetClipList(p, a, b, c) (p)->GetClipList(a, b, c) +#define IDirectDrawClipper_GetHWnd(p, a) (p)->GetHWnd(a) +#define IDirectDrawClipper_Initialize(p, a, b) (p)->Initialize(a, b) +#define IDirectDrawClipper_IsClipListChanged(p, a) (p)->IsClipListChanged(a) +#define IDirectDrawClipper_SetClipList(p, a, b) (p)->SetClipList(a, b) +#define IDirectDrawClipper_SetHWnd(p, a, b) (p)->SetHWnd(a, b) +#endif + +#endif + +/* + * IDirectDrawSurface and related interfaces + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawSurface +DECLARE_INTERFACE_( IDirectDrawSurface, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPVOID) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#else +#define IDirectDrawSurface_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface_Release(p) (p)->Release() +#define IDirectDrawSurface_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface_Restore(p) (p)->Restore() +#define IDirectDrawSurface_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#endif + +/* + * IDirectDrawSurface2 and related interfaces + */ +#undef INTERFACE +#define INTERFACE IDirectDrawSurface2 +DECLARE_INTERFACE_( IDirectDrawSurface2, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE2) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE2, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE2, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE2) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE2, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE2 FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPVOID) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE2,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE2) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; + STDMETHOD(PageLock)(THIS_ DWORD) PURE; + STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface2_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface2_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface2_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface2_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface2_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface2_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface2_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface2_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface2_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface2_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface2_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface2_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface2_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface2_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface2_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface2_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface2_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface2_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface2_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface2_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface2_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface2_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface2_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface2_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface2_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface2_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface2_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface2_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface2_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface2_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface2_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface2_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface2_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#define IDirectDrawSurface2_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) +#define IDirectDrawSurface2_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) +#define IDirectDrawSurface2_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) +#else +#define IDirectDrawSurface2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface2_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface2_Release(p) (p)->Release() +#define IDirectDrawSurface2_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface2_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface2_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface2_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface2_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface2_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface2_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface2_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface2_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface2_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface2_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface2_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface2_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface2_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface2_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface2_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface2_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface2_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface2_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface2_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface2_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface2_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface2_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface2_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface2_Restore(p) (p)->Restore() +#define IDirectDrawSurface2_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface2_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface2_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface2_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface2_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface2_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface2_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface2_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#define IDirectDrawSurface2_GetDDInterface(p,a) (p)->GetDDInterface(a) +#define IDirectDrawSurface2_PageLock(p,a) (p)->PageLock(a) +#define IDirectDrawSurface2_PageUnlock(p,a) (p)->PageUnlock(a) +#endif + +/* + * IDirectDrawSurface3 and related interfaces + */ +#undef INTERFACE +#define INTERFACE IDirectDrawSurface3 +DECLARE_INTERFACE_( IDirectDrawSurface3, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE3) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE3, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE3, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE3) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE3, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE3 FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPVOID) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE3,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE3) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; + STDMETHOD(PageLock)(THIS_ DWORD) PURE; + STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; + /*** Added in the V3 interface ***/ + STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC, DWORD) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface3_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface3_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface3_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface3_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface3_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface3_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface3_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface3_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface3_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface3_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface3_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface3_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface3_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface3_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface3_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface3_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface3_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface3_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface3_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface3_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface3_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface3_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface3_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface3_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface3_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface3_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface3_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface3_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface3_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface3_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface3_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface3_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface3_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface3_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface3_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#define IDirectDrawSurface3_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) +#define IDirectDrawSurface3_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) +#define IDirectDrawSurface3_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) +#define IDirectDrawSurface3_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) +#else +#define IDirectDrawSurface3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface3_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface3_Release(p) (p)->Release() +#define IDirectDrawSurface3_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface3_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface3_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface3_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface3_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface3_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface3_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface3_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface3_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface3_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface3_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface3_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface3_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface3_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface3_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface3_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface3_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface3_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface3_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface3_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface3_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface3_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface3_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface3_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface3_Restore(p) (p)->Restore() +#define IDirectDrawSurface3_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface3_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface3_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface3_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface3_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface3_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface3_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface3_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#define IDirectDrawSurface3_GetDDInterface(p,a) (p)->GetDDInterface(a) +#define IDirectDrawSurface3_PageLock(p,a) (p)->PageLock(a) +#define IDirectDrawSurface3_PageUnlock(p,a) (p)->PageUnlock(a) +#define IDirectDrawSurface3_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) +#endif + +/* + * IDirectDrawSurface4 and related interfaces + */ +#undef INTERFACE +#define INTERFACE IDirectDrawSurface4 +DECLARE_INTERFACE_( IDirectDrawSurface4, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE4) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE4, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE4, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE4) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK2) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK2) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE4, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS2, LPDIRECTDRAWSURFACE4 FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS2) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC2) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC2) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC2,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPRECT) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE4,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE4) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; + STDMETHOD(PageLock)(THIS_ DWORD) PURE; + STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; + /*** Added in the v3 interface ***/ + STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC2, DWORD) PURE; + /*** Added in the v4 interface ***/ + STDMETHOD(SetPrivateData)(THIS_ REFGUID, LPVOID, DWORD, DWORD) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID, LPVOID, LPDWORD) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID) PURE; + STDMETHOD(GetUniquenessValue)(THIS_ LPDWORD) PURE; + STDMETHOD(ChangeUniquenessValue)(THIS) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface4_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface4_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface4_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface4_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface4_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface4_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface4_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface4_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface4_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface4_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface4_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface4_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface4_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface4_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface4_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface4_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface4_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface4_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface4_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface4_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface4_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface4_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface4_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface4_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface4_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface4_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface4_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface4_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface4_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface4_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface4_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface4_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface4_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface4_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface4_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface4_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#define IDirectDrawSurface4_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) +#define IDirectDrawSurface4_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) +#define IDirectDrawSurface4_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) +#define IDirectDrawSurface4_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) +#define IDirectDrawSurface4_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirectDrawSurface4_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirectDrawSurface4_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirectDrawSurface4_GetUniquenessValue(p, a) (p)->lpVtbl->GetUniquenessValue(p, a) +#define IDirectDrawSurface4_ChangeUniquenessValue(p) (p)->lpVtbl->ChangeUniquenessValue(p) +#else +#define IDirectDrawSurface4_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface4_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface4_Release(p) (p)->Release() +#define IDirectDrawSurface4_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface4_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface4_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface4_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface4_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface4_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface4_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface4_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface4_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface4_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface4_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface4_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface4_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface4_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface4_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface4_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface4_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface4_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface4_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface4_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface4_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface4_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface4_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface4_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface4_Restore(p) (p)->Restore() +#define IDirectDrawSurface4_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface4_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface4_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface4_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface4_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface4_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface4_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface4_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#define IDirectDrawSurface4_GetDDInterface(p,a) (p)->GetDDInterface(a) +#define IDirectDrawSurface4_PageLock(p,a) (p)->PageLock(a) +#define IDirectDrawSurface4_PageUnlock(p,a) (p)->PageUnlock(a) +#define IDirectDrawSurface4_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) +#define IDirectDrawSurface4_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirectDrawSurface4_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirectDrawSurface4_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirectDrawSurface4_GetUniquenessValue(p, a) (p)->GetUniquenessValue(a) +#define IDirectDrawSurface4_ChangeUniquenessValue(p) (p)->ChangeUniquenessValue() +#endif + +/* + * IDirectDrawSurface7 and related interfaces + */ +#undef INTERFACE +#define INTERFACE IDirectDrawSurface7 +DECLARE_INTERFACE_( IDirectDrawSurface7, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE7) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE7, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE7, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE7) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK7) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK7) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE7, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS2, LPDIRECTDRAWSURFACE7 FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS2) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC2) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC2) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC2,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPRECT) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE7,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE7) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; + STDMETHOD(PageLock)(THIS_ DWORD) PURE; + STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; + /*** Added in the v3 interface ***/ + STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC2, DWORD) PURE; + /*** Added in the v4 interface ***/ + STDMETHOD(SetPrivateData)(THIS_ REFGUID, LPVOID, DWORD, DWORD) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID, LPVOID, LPDWORD) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID) PURE; + STDMETHOD(GetUniquenessValue)(THIS_ LPDWORD) PURE; + STDMETHOD(ChangeUniquenessValue)(THIS) PURE; + /*** Moved Texture7 methods here ***/ + STDMETHOD(SetPriority)(THIS_ DWORD) PURE; + STDMETHOD(GetPriority)(THIS_ LPDWORD) PURE; + STDMETHOD(SetLOD)(THIS_ DWORD) PURE; + STDMETHOD(GetLOD)(THIS_ LPDWORD) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface7_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface7_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface7_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface7_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface7_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface7_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface7_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface7_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface7_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface7_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface7_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface7_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface7_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface7_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface7_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface7_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface7_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface7_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface7_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface7_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface7_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface7_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface7_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface7_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface7_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface7_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface7_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface7_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface7_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface7_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface7_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface7_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface7_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#define IDirectDrawSurface7_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) +#define IDirectDrawSurface7_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) +#define IDirectDrawSurface7_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) +#define IDirectDrawSurface7_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) +#define IDirectDrawSurface7_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirectDrawSurface7_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirectDrawSurface7_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirectDrawSurface7_GetUniquenessValue(p, a) (p)->lpVtbl->GetUniquenessValue(p, a) +#define IDirectDrawSurface7_ChangeUniquenessValue(p) (p)->lpVtbl->ChangeUniquenessValue(p) +#define IDirectDrawSurface7_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirectDrawSurface7_GetPriority(p,a) (p)->lpVtbl->GetPriority(p,a) +#define IDirectDrawSurface7_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirectDrawSurface7_GetLOD(p,a) (p)->lpVtbl->GetLOD(p,a) +#else +#define IDirectDrawSurface7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface7_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface7_Release(p) (p)->Release() +#define IDirectDrawSurface7_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface7_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface7_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface7_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface7_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface7_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface7_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface7_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface7_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface7_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface7_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface7_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface7_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface7_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface7_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface7_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface7_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface7_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface7_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface7_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface7_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface7_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface7_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface7_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface7_Restore(p) (p)->Restore() +#define IDirectDrawSurface7_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface7_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface7_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface7_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface7_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface7_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface7_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface7_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#define IDirectDrawSurface7_GetDDInterface(p,a) (p)->GetDDInterface(a) +#define IDirectDrawSurface7_PageLock(p,a) (p)->PageLock(a) +#define IDirectDrawSurface7_PageUnlock(p,a) (p)->PageUnlock(a) +#define IDirectDrawSurface7_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) +#define IDirectDrawSurface7_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirectDrawSurface7_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirectDrawSurface7_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirectDrawSurface7_GetUniquenessValue(p, a) (p)->GetUniquenessValue(a) +#define IDirectDrawSurface7_ChangeUniquenessValue(p) (p)->ChangeUniquenessValue() +#define IDirectDrawSurface7_SetPriority(p,a) (p)->SetPriority(a) +#define IDirectDrawSurface7_GetPriority(p,a) (p)->GetPriority(a) +#define IDirectDrawSurface7_SetLOD(p,a) (p)->SetLOD(a) +#define IDirectDrawSurface7_GetLOD(p,a) (p)->GetLOD(a) +#endif + + +/* + * IDirectDrawColorControl + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawColorControl +DECLARE_INTERFACE_( IDirectDrawColorControl, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawColorControl methods ***/ + STDMETHOD(GetColorControls)(THIS_ LPDDCOLORCONTROL) PURE; + STDMETHOD(SetColorControls)(THIS_ LPDDCOLORCONTROL) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawColorControl_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDrawColorControl_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawColorControl_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawColorControl_GetColorControls(p, a) (p)->lpVtbl->GetColorControls(p, a) +#define IDirectDrawColorControl_SetColorControls(p, a) (p)->lpVtbl->SetColorControls(p, a) +#else +#define IDirectDrawColorControl_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDrawColorControl_AddRef(p) (p)->AddRef() +#define IDirectDrawColorControl_Release(p) (p)->Release() +#define IDirectDrawColorControl_GetColorControls(p, a) (p)->GetColorControls(a) +#define IDirectDrawColorControl_SetColorControls(p, a) (p)->SetColorControls(a) +#endif + +#endif + + +/* + * IDirectDrawGammaControl + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawGammaControl +DECLARE_INTERFACE_( IDirectDrawGammaControl, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawGammaControl methods ***/ + STDMETHOD(GetGammaRamp)(THIS_ DWORD, LPDDGAMMARAMP) PURE; + STDMETHOD(SetGammaRamp)(THIS_ DWORD, LPDDGAMMARAMP) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawGammaControl_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDrawGammaControl_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawGammaControl_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawGammaControl_GetGammaRamp(p, a, b) (p)->lpVtbl->GetGammaRamp(p, a, b) +#define IDirectDrawGammaControl_SetGammaRamp(p, a, b) (p)->lpVtbl->SetGammaRamp(p, a, b) +#else +#define IDirectDrawGammaControl_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDrawGammaControl_AddRef(p) (p)->AddRef() +#define IDirectDrawGammaControl_Release(p) (p)->Release() +#define IDirectDrawGammaControl_GetGammaRamp(p, a, b) (p)->GetGammaRamp(a, b) +#define IDirectDrawGammaControl_SetGammaRamp(p, a, b) (p)->SetGammaRamp(a, b) +#endif + +#endif + + + +#endif + + +/* + * DDSURFACEDESC + */ +typedef struct _DDSURFACEDESC +{ + DWORD dwSize; // size of the DDSURFACEDESC structure + DWORD dwFlags; // determines what fields are valid + DWORD dwHeight; // height of surface to be created + DWORD dwWidth; // width of input surface + union + { + LONG lPitch; // distance to start of next line (return value only) + DWORD dwLinearSize; // Formless late-allocated optimized surface size + } DUMMYUNIONNAMEN(1); + DWORD dwBackBufferCount; // number of back buffers requested + union + { + DWORD dwMipMapCount; // number of mip-map levels requested + DWORD dwZBufferBitDepth; // depth of Z buffer requested + DWORD dwRefreshRate; // refresh rate (used when display mode is described) + } DUMMYUNIONNAMEN(2); + DWORD dwAlphaBitDepth; // depth of alpha buffer requested + DWORD dwReserved; // reserved + LPVOID lpSurface; // pointer to the associated surface memory + DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use + DDCOLORKEY ddckCKDestBlt; // color key for destination blt use + DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use + DDCOLORKEY ddckCKSrcBlt; // color key for source blt use + DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface + DDSCAPS ddsCaps; // direct draw surface capabilities +} DDSURFACEDESC; + +/* + * DDSURFACEDESC2 + */ +typedef struct _DDSURFACEDESC2 +{ + DWORD dwSize; // size of the DDSURFACEDESC structure + DWORD dwFlags; // determines what fields are valid + DWORD dwHeight; // height of surface to be created + DWORD dwWidth; // width of input surface + union + { + LONG lPitch; // distance to start of next line (return value only) + DWORD dwLinearSize; // Formless late-allocated optimized surface size + } DUMMYUNIONNAMEN(1); + union + { + DWORD dwBackBufferCount; // number of back buffers requested + DWORD dwDepth; // the depth if this is a volume texture + } DUMMYUNIONNAMEN(5); + union + { + DWORD dwMipMapCount; // number of mip-map levels requestde + // dwZBufferBitDepth removed, use ddpfPixelFormat one instead + DWORD dwRefreshRate; // refresh rate (used when display mode is described) + DWORD dwSrcVBHandle; // The source used in VB::Optimize + } DUMMYUNIONNAMEN(2); + DWORD dwAlphaBitDepth; // depth of alpha buffer requested + DWORD dwReserved; // reserved + LPVOID lpSurface; // pointer to the associated surface memory + union + { + DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use + DWORD dwEmptyFaceColor; // Physical color for empty cubemap faces + } DUMMYUNIONNAMEN(3); + DDCOLORKEY ddckCKDestBlt; // color key for destination blt use + DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use + DDCOLORKEY ddckCKSrcBlt; // color key for source blt use + union + { + DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface + DWORD dwFVF; // vertex format description of vertex buffers + } DUMMYUNIONNAMEN(4); + DDSCAPS2 ddsCaps; // direct draw surface capabilities + DWORD dwTextureStage; // stage in multitexture cascade +} DDSURFACEDESC2; + +/* + * ddsCaps field is valid. + */ +#define DDSD_CAPS 0x00000001l // default + +/* + * dwHeight field is valid. + */ +#define DDSD_HEIGHT 0x00000002l + +/* + * dwWidth field is valid. + */ +#define DDSD_WIDTH 0x00000004l + +/* + * lPitch is valid. + */ +#define DDSD_PITCH 0x00000008l + +/* + * dwBackBufferCount is valid. + */ +#define DDSD_BACKBUFFERCOUNT 0x00000020l + +/* + * dwZBufferBitDepth is valid. (shouldnt be used in DDSURFACEDESC2) + */ +#define DDSD_ZBUFFERBITDEPTH 0x00000040l + +/* + * dwAlphaBitDepth is valid. + */ +#define DDSD_ALPHABITDEPTH 0x00000080l + + +/* + * lpSurface is valid. + */ +#define DDSD_LPSURFACE 0x00000800l + +/* + * ddpfPixelFormat is valid. + */ +#define DDSD_PIXELFORMAT 0x00001000l + +/* + * ddckCKDestOverlay is valid. + */ +#define DDSD_CKDESTOVERLAY 0x00002000l + +/* + * ddckCKDestBlt is valid. + */ +#define DDSD_CKDESTBLT 0x00004000l + +/* + * ddckCKSrcOverlay is valid. + */ +#define DDSD_CKSRCOVERLAY 0x00008000l + +/* + * ddckCKSrcBlt is valid. + */ +#define DDSD_CKSRCBLT 0x00010000l + +/* + * dwMipMapCount is valid. + */ +#define DDSD_MIPMAPCOUNT 0x00020000l + + /* + * dwRefreshRate is valid + */ +#define DDSD_REFRESHRATE 0x00040000l + +/* + * dwLinearSize is valid + */ +#define DDSD_LINEARSIZE 0x00080000l + +/* + * dwTextureStage is valid + */ +#define DDSD_TEXTURESTAGE 0x00100000l +/* + * dwFVF is valid + */ +#define DDSD_FVF 0x00200000l +/* + * dwSrcVBHandle is valid + */ +#define DDSD_SRCVBHANDLE 0x00400000l + +/* + * dwDepth is valid + */ +#define DDSD_DEPTH 0x00800000l + +/* + * All input fields are valid. + */ +#define DDSD_ALL 0x00fff9eel + +/* + * DDOPTSURFACEDESC + */ +typedef struct _DDOPTSURFACEDESC +{ + DWORD dwSize; // size of the DDOPTSURFACEDESC structure + DWORD dwFlags; // determines what fields are valid + DDSCAPS2 ddSCaps; // Common caps like: Memory type + DDOSCAPS ddOSCaps; // Common caps like: Memory type + GUID guid; // Compression technique GUID + DWORD dwCompressionRatio; // Compression ratio +} DDOPTSURFACEDESC; + +/* + * guid field is valid. + */ +#define DDOSD_GUID 0x00000001l + +/* + * dwCompressionRatio field is valid. + */ +#define DDOSD_COMPRESSION_RATIO 0x00000002l + +/* + * ddSCaps field is valid. + */ +#define DDOSD_SCAPS 0x00000004l + +/* + * ddOSCaps field is valid. + */ +#define DDOSD_OSCAPS 0x00000008l + +/* + * All input fields are valid. + */ +#define DDOSD_ALL 0x0000000fl + +/* + * The surface's optimized pixelformat is compressed + */ +#define DDOSDCAPS_OPTCOMPRESSED 0x00000001l + +/* + * The surface's optimized pixelformat is reordered + */ +#define DDOSDCAPS_OPTREORDERED 0x00000002l + +/* + * The opt surface is a monolithic mipmap + */ +#define DDOSDCAPS_MONOLITHICMIPMAP 0x00000004l + +/* + * The valid Surf caps: + * #define DDSCAPS_SYSTEMMEMORY 0x00000800l + * #define DDSCAPS_VIDEOMEMORY 0x00004000l + * #define DDSCAPS_LOCALVIDMEM 0x10000000l + * #define DDSCAPS_NONLOCALVIDMEM 0x20000000l + */ +#define DDOSDCAPS_VALIDSCAPS 0x30004800l + +/* + * The valid OptSurf caps + */ +#define DDOSDCAPS_VALIDOSCAPS 0x00000007l + + +/* + * DDCOLORCONTROL + */ +typedef struct _DDCOLORCONTROL +{ + DWORD dwSize; + DWORD dwFlags; + LONG lBrightness; + LONG lContrast; + LONG lHue; + LONG lSaturation; + LONG lSharpness; + LONG lGamma; + LONG lColorEnable; + DWORD dwReserved1; +} DDCOLORCONTROL; + + +/* + * lBrightness field is valid. + */ +#define DDCOLOR_BRIGHTNESS 0x00000001l + +/* + * lContrast field is valid. + */ +#define DDCOLOR_CONTRAST 0x00000002l + +/* + * lHue field is valid. + */ +#define DDCOLOR_HUE 0x00000004l + +/* + * lSaturation field is valid. + */ +#define DDCOLOR_SATURATION 0x00000008l + +/* + * lSharpness field is valid. + */ +#define DDCOLOR_SHARPNESS 0x00000010l + +/* + * lGamma field is valid. + */ +#define DDCOLOR_GAMMA 0x00000020l + +/* + * lColorEnable field is valid. + */ +#define DDCOLOR_COLORENABLE 0x00000040l + + + +/*============================================================================ + * + * Direct Draw Capability Flags + * + * These flags are used to describe the capabilities of a given Surface. + * All flags are bit flags. + * + *==========================================================================*/ + +/**************************************************************************** + * + * DIRECTDRAWSURFACE CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * This bit is reserved. It should not be specified. + */ +#define DDSCAPS_RESERVED1 0x00000001l + +/* + * Indicates that this surface contains alpha-only information. + * (To determine if a surface is RGBA/YUVA, the pixel format must be + * interrogated.) + */ +#define DDSCAPS_ALPHA 0x00000002l + +/* + * Indicates that this surface is a backbuffer. It is generally + * set by CreateSurface when the DDSCAPS_FLIP capability bit is set. + * It indicates that this surface is THE back buffer of a surface + * flipping structure. DirectDraw supports N surfaces in a + * surface flipping structure. Only the surface that immediately + * precedeces the DDSCAPS_FRONTBUFFER has this capability bit set. + * The other surfaces are identified as back buffers by the presence + * of the DDSCAPS_FLIP capability, their attachment order, and the + * absence of the DDSCAPS_FRONTBUFFER and DDSCAPS_BACKBUFFER + * capabilities. The bit is sent to CreateSurface when a standalone + * back buffer is being created. This surface could be attached to + * a front buffer and/or back buffers to form a flipping surface + * structure after the CreateSurface call. See AddAttachments for + * a detailed description of the behaviors in this case. + */ +#define DDSCAPS_BACKBUFFER 0x00000004l + +/* + * Indicates a complex surface structure is being described. A + * complex surface structure results in the creation of more than + * one surface. The additional surfaces are attached to the root + * surface. The complex structure can only be destroyed by + * destroying the root. + */ +#define DDSCAPS_COMPLEX 0x00000008l + +/* + * Indicates that this surface is a part of a surface flipping structure. + * When it is passed to CreateSurface the DDSCAPS_FRONTBUFFER and + * DDSCAP_BACKBUFFER bits are not set. They are set by CreateSurface + * on the resulting creations. The dwBackBufferCount field in the + * DDSURFACEDESC structure must be set to at least 1 in order for + * the CreateSurface call to succeed. The DDSCAPS_COMPLEX capability + * must always be set with creating multiple surfaces through CreateSurface. + */ +#define DDSCAPS_FLIP 0x00000010l + +/* + * Indicates that this surface is THE front buffer of a surface flipping + * structure. It is generally set by CreateSurface when the DDSCAPS_FLIP + * capability bit is set. + * If this capability is sent to CreateSurface then a standalonw front buffer + * is created. This surface will not have the DDSCAPS_FLIP capability. + * It can be attached to other back buffers to form a flipping structure. + * See AddAttachments for a detailed description of the behaviors in this + * case. + */ +#define DDSCAPS_FRONTBUFFER 0x00000020l + +/* + * Indicates that this surface is any offscreen surface that is not an overlay, + * texture, zbuffer, front buffer, back buffer, or alpha surface. It is used + * to identify plain vanilla surfaces. + */ +#define DDSCAPS_OFFSCREENPLAIN 0x00000040l + +/* + * Indicates that this surface is an overlay. It may or may not be directly visible + * depending on whether or not it is currently being overlayed onto the primary + * surface. DDSCAPS_VISIBLE can be used to determine whether or not it is being + * overlayed at the moment. + */ +#define DDSCAPS_OVERLAY 0x00000080l + +/* + * Indicates that unique DirectDrawPalette objects can be created and + * attached to this surface. + */ +#define DDSCAPS_PALETTE 0x00000100l + +/* + * Indicates that this surface is the primary surface. The primary + * surface represents what the user is seeing at the moment. + */ +#define DDSCAPS_PRIMARYSURFACE 0x00000200l + + +/* + * This flag used to be DDSCAPS_PRIMARYSURFACELEFT, which is now + * obsolete. + */ +#define DDSCAPS_RESERVED3 0x00000400l +#define DDSCAPS_PRIMARYSURFACELEFT 0x00000000l + +/* + * Indicates that this surface memory was allocated in system memory + */ +#define DDSCAPS_SYSTEMMEMORY 0x00000800l + +/* + * Indicates that this surface can be used as a 3D texture. It does not + * indicate whether or not the surface is being used for that purpose. + */ +#define DDSCAPS_TEXTURE 0x00001000l + +/* + * Indicates that a surface may be a destination for 3D rendering. This + * bit must be set in order to query for a Direct3D Device Interface + * from this surface. + */ +#define DDSCAPS_3DDEVICE 0x00002000l + +/* + * Indicates that this surface exists in video memory. + */ +#define DDSCAPS_VIDEOMEMORY 0x00004000l + +/* + * Indicates that changes made to this surface are immediately visible. + * It is always set for the primary surface and is set for overlays while + * they are being overlayed and texture maps while they are being textured. + */ +#define DDSCAPS_VISIBLE 0x00008000l + +/* + * Indicates that only writes are permitted to the surface. Read accesses + * from the surface may or may not generate a protection fault, but the + * results of a read from this surface will not be meaningful. READ ONLY. + */ +#define DDSCAPS_WRITEONLY 0x00010000l + +/* + * Indicates that this surface is a z buffer. A z buffer does not contain + * displayable information. Instead it contains bit depth information that is + * used to determine which pixels are visible and which are obscured. + */ +#define DDSCAPS_ZBUFFER 0x00020000l + +/* + * Indicates surface will have a DC associated long term + */ +#define DDSCAPS_OWNDC 0x00040000l + +/* + * Indicates surface should be able to receive live video + */ +#define DDSCAPS_LIVEVIDEO 0x00080000l + +/* + * Indicates surface should be able to have a stream decompressed + * to it by the hardware. + */ +#define DDSCAPS_HWCODEC 0x00100000l + +/* + * Surface is a ModeX surface. + * + */ +#define DDSCAPS_MODEX 0x00200000l + +/* + * Indicates surface is one level of a mip-map. This surface will + * be attached to other DDSCAPS_MIPMAP surfaces to form the mip-map. + * This can be done explicitly, by creating a number of surfaces and + * attaching them with AddAttachedSurface or by implicitly by CreateSurface. + * If this bit is set then DDSCAPS_TEXTURE must also be set. + */ +#define DDSCAPS_MIPMAP 0x00400000l + +/* + * This bit is reserved. It should not be specified. + */ +#define DDSCAPS_RESERVED2 0x00800000l + + +/* + * Indicates that memory for the surface is not allocated until the surface + * is loaded (via the Direct3D texture Load() function). + */ +#define DDSCAPS_ALLOCONLOAD 0x04000000l + +/* + * Indicates that the surface will recieve data from a video port. + */ +#define DDSCAPS_VIDEOPORT 0x08000000l + +/* + * Indicates that a video memory surface is resident in true, local video + * memory rather than non-local video memory. If this flag is specified then + * so must DDSCAPS_VIDEOMEMORY. This flag is mutually exclusive with + * DDSCAPS_NONLOCALVIDMEM. + */ +#define DDSCAPS_LOCALVIDMEM 0x10000000l + +/* + * Indicates that a video memory surface is resident in non-local video + * memory rather than true, local video memory. If this flag is specified + * then so must DDSCAPS_VIDEOMEMORY. This flag is mutually exclusive with + * DDSCAPS_LOCALVIDMEM. + */ +#define DDSCAPS_NONLOCALVIDMEM 0x20000000l + +/* + * Indicates that this surface is a standard VGA mode surface, and not a + * ModeX surface. (This flag will never be set in combination with the + * DDSCAPS_MODEX flag). + */ +#define DDSCAPS_STANDARDVGAMODE 0x40000000l + +/* + * Indicates that this surface will be an optimized surface. This flag is + * currently only valid in conjunction with the DDSCAPS_TEXTURE flag. The surface + * will be created without any underlying video memory until loaded. + */ +#define DDSCAPS_OPTIMIZED 0x80000000l + + + +/* + * This bit is reserved + */ +#define DDSCAPS2_RESERVED4 0x00000002L +#define DDSCAPS2_HARDWAREDEINTERLACE 0x00000000L + +/* + * Indicates to the driver that this surface will be locked very frequently + * (for procedural textures, dynamic lightmaps, etc). Surfaces with this cap + * set must also have DDSCAPS_TEXTURE. This cap cannot be used with + * DDSCAPS2_HINTSTATIC and DDSCAPS2_OPAQUE. + */ +#define DDSCAPS2_HINTDYNAMIC 0x00000004L + +/* + * Indicates to the driver that this surface can be re-ordered/retiled on + * load. This operation will not change the size of the texture. It is + * relatively fast and symmetrical, since the application may lock these + * bits (although it will take a performance hit when doing so). Surfaces + * with this cap set must also have DDSCAPS_TEXTURE. This cap cannot be + * used with DDSCAPS2_HINTDYNAMIC and DDSCAPS2_OPAQUE. + */ +#define DDSCAPS2_HINTSTATIC 0x00000008L + +/* + * Indicates that the client would like this texture surface to be managed by the + * DirectDraw/Direct3D runtime. Surfaces with this cap set must also have + * DDSCAPS_TEXTURE set. + */ +#define DDSCAPS2_TEXTUREMANAGE 0x00000010L + +/* + * These bits are reserved for internal use */ +#define DDSCAPS2_RESERVED1 0x00000020L +#define DDSCAPS2_RESERVED2 0x00000040L + +/* + * Indicates to the driver that this surface will never be locked again. + * The driver is free to optimize this surface via retiling and actual compression. + * All calls to Lock() or Blts from this surface will fail. Surfaces with this + * cap set must also have DDSCAPS_TEXTURE. This cap cannot be used with + * DDSCAPS2_HINTDYNAMIC and DDSCAPS2_HINTSTATIC. + */ +#define DDSCAPS2_OPAQUE 0x00000080L + +/* + * Applications should set this bit at CreateSurface time to indicate that they + * intend to use antialiasing. Only valid if DDSCAPS_3DDEVICE is also set. + */ +#define DDSCAPS2_HINTANTIALIASING 0x00000100L + + +/* + * This flag is used at CreateSurface time to indicate that this set of + * surfaces is a cubic environment map + */ +#define DDSCAPS2_CUBEMAP 0x00000200L + +/* + * These flags preform two functions: + * - At CreateSurface time, they define which of the six cube faces are + * required by the application. + * - After creation, each face in the cubemap will have exactly one of these + * bits set. + */ +#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400L +#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800L +#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000L +#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000L +#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000L +#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000L + +/* + * This macro may be used to specify all faces of a cube map at CreateSurface time + */ +#define DDSCAPS2_CUBEMAP_ALLFACES ( DDSCAPS2_CUBEMAP_POSITIVEX |\ + DDSCAPS2_CUBEMAP_NEGATIVEX |\ + DDSCAPS2_CUBEMAP_POSITIVEY |\ + DDSCAPS2_CUBEMAP_NEGATIVEY |\ + DDSCAPS2_CUBEMAP_POSITIVEZ |\ + DDSCAPS2_CUBEMAP_NEGATIVEZ ) + + +/* + * This flag is an additional flag which is present on mipmap sublevels from DX7 onwards + * It enables easier use of GetAttachedSurface rather than EnumAttachedSurfaces for surface + * constructs such as Cube Maps, wherein there are more than one mipmap surface attached + * to the root surface. + * This caps bit is ignored by CreateSurface + */ +#define DDSCAPS2_MIPMAPSUBLEVEL 0x00010000L + +/* This flag indicates that the texture should be managed by D3D only */ +#define DDSCAPS2_D3DTEXTUREMANAGE 0x00020000L + +/* This flag indicates that the managed surface can be safely lost */ +#define DDSCAPS2_DONOTPERSIST 0x00040000L + +/* indicates that this surface is part of a stereo flipping chain */ +#define DDSCAPS2_STEREOSURFACELEFT 0x00080000L + + +/* + * Indicates that the surface is a volume. + * Can be combined with DDSCAPS_MIPMAP to indicate a multi-level volume + */ +#define DDSCAPS2_VOLUME 0x00200000L + +/* + * Indicates that the surface may be locked multiple times by the application. + * This cap cannot be used with DDSCAPS2_OPAQUE. + */ +#define DDSCAPS2_NOTUSERLOCKABLE 0x00400000L + +/* + * Indicates that the vertex buffer data can be used to render points and + * point sprites. + */ +#define DDSCAPS2_POINTS 0x00800000L + +/* + * Indicates that the vertex buffer data can be used to render rt pactches. + */ +#define DDSCAPS2_RTPATCHES 0x01000000L + +/* + * Indicates that the vertex buffer data can be used to render n patches. + */ +#define DDSCAPS2_NPATCHES 0x02000000L + +/* + * This bit is reserved for internal use + */ +#define DDSCAPS2_RESERVED3 0x04000000L + + +/* + * Indicates that the contents of the backbuffer do not have to be preserved + * the contents of the backbuffer after they are presented. + */ +#define DDSCAPS2_DISCARDBACKBUFFER 0x10000000L + +/* + * Indicates that all surfaces in this creation chain should be given an alpha channel. + * This flag will be set on primary surface chains that may have no explicit pixel format + * (and thus take on the format of the current display mode). + * The driver should infer that all these surfaces have a format having an alpha channel. + * (e.g. assume D3DFMT_A8R8G8B8 if the display mode is x888.) + */ +#define DDSCAPS2_ENABLEALPHACHANNEL 0x20000000L + +/* + * Indicates that all surfaces in this creation chain is extended primary surface format. + * This flag will be set on extended primary surface chains that always have explicit pixel + * format and the pixel format is typically GDI (Graphics Device Interface) couldn't handle, + * thus only used with fullscreen application. (e.g. D3DFMT_A2R10G10B10 format) + */ +#define DDSCAPS2_EXTENDEDFORMATPRIMARY 0x40000000L + +/* + * Indicates that all surfaces in this creation chain is additional primary surface. + * This flag will be set on primary surface chains which must present on the adapter + * id provided on dwCaps4. Typically this will be used to create secondary primary surface + * on DualView display adapter. + */ +#define DDSCAPS2_ADDITIONALPRIMARY 0x80000000L + +/* + * This is a mask that indicates the set of bits that may be set + * at createsurface time to indicate number of samples per pixel + * when multisampling + */ +#define DDSCAPS3_MULTISAMPLE_MASK 0x0000001FL + +/* + * This is a mask that indicates the set of bits that may be set + * at createsurface time to indicate the quality level of rendering + * for the current number of samples per pixel + */ +#define DDSCAPS3_MULTISAMPLE_QUALITY_MASK 0x000000E0L +#define DDSCAPS3_MULTISAMPLE_QUALITY_SHIFT 5 + +/* + * This bit is reserved for internal use + */ +#define DDSCAPS3_RESERVED1 0x00000100L + +/* + * This bit is reserved for internal use + */ +#define DDSCAPS3_RESERVED2 0x00000200L + +/* + * This indicates whether this surface has light-weight miplevels + */ +#define DDSCAPS3_LIGHTWEIGHTMIPMAP 0x00000400L + +/* + * This indicates that the mipsublevels for this surface are auto-generated + */ +#define DDSCAPS3_AUTOGENMIPMAP 0x00000800L + +/* + * This indicates that the mipsublevels for this surface are auto-generated + */ +#define DDSCAPS3_DMAP 0x00001000L + + + /**************************************************************************** + * + * DIRECTDRAW DRIVER CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * Display hardware has 3D acceleration. + */ +#define DDCAPS_3D 0x00000001l + +/* + * Indicates that DirectDraw will support only dest rectangles that are aligned + * on DIRECTDRAWCAPS.dwAlignBoundaryDest boundaries of the surface, respectively. + * READ ONLY. + */ +#define DDCAPS_ALIGNBOUNDARYDEST 0x00000002l + +/* + * Indicates that DirectDraw will support only source rectangles whose sizes in + * BYTEs are DIRECTDRAWCAPS.dwAlignSizeDest multiples, respectively. READ ONLY. + */ +#define DDCAPS_ALIGNSIZEDEST 0x00000004l +/* + * Indicates that DirectDraw will support only source rectangles that are aligned + * on DIRECTDRAWCAPS.dwAlignBoundarySrc boundaries of the surface, respectively. + * READ ONLY. + */ +#define DDCAPS_ALIGNBOUNDARYSRC 0x00000008l + +/* + * Indicates that DirectDraw will support only source rectangles whose sizes in + * BYTEs are DIRECTDRAWCAPS.dwAlignSizeSrc multiples, respectively. READ ONLY. + */ +#define DDCAPS_ALIGNSIZESRC 0x00000010l + +/* + * Indicates that DirectDraw will create video memory surfaces that have a stride + * alignment equal to DIRECTDRAWCAPS.dwAlignStride. READ ONLY. + */ +#define DDCAPS_ALIGNSTRIDE 0x00000020l + +/* + * Display hardware is capable of blt operations. + */ +#define DDCAPS_BLT 0x00000040l + +/* + * Display hardware is capable of asynchronous blt operations. + */ +#define DDCAPS_BLTQUEUE 0x00000080l + +/* + * Display hardware is capable of color space conversions during the blt operation. + */ +#define DDCAPS_BLTFOURCC 0x00000100l + +/* + * Display hardware is capable of stretching during blt operations. + */ +#define DDCAPS_BLTSTRETCH 0x00000200l + +/* + * Display hardware is shared with GDI. + */ +#define DDCAPS_GDI 0x00000400l + +/* + * Display hardware can overlay. + */ +#define DDCAPS_OVERLAY 0x00000800l + +/* + * Set if display hardware supports overlays but can not clip them. + */ +#define DDCAPS_OVERLAYCANTCLIP 0x00001000l + +/* + * Indicates that overlay hardware is capable of color space conversions during + * the overlay operation. + */ +#define DDCAPS_OVERLAYFOURCC 0x00002000l + +/* + * Indicates that stretching can be done by the overlay hardware. + */ +#define DDCAPS_OVERLAYSTRETCH 0x00004000l + +/* + * Indicates that unique DirectDrawPalettes can be created for DirectDrawSurfaces + * other than the primary surface. + */ +#define DDCAPS_PALETTE 0x00008000l + +/* + * Indicates that palette changes can be syncd with the veritcal refresh. + */ +#define DDCAPS_PALETTEVSYNC 0x00010000l + +/* + * Display hardware can return the current scan line. + */ +#define DDCAPS_READSCANLINE 0x00020000l + + +/* + * This flag used to bo DDCAPS_STEREOVIEW, which is now obsolete + */ +#define DDCAPS_RESERVED1 0x00040000l + +/* + * Display hardware is capable of generating a vertical blank interrupt. + */ +#define DDCAPS_VBI 0x00080000l + +/* + * Supports the use of z buffers with blt operations. + */ +#define DDCAPS_ZBLTS 0x00100000l + +/* + * Supports Z Ordering of overlays. + */ +#define DDCAPS_ZOVERLAYS 0x00200000l + +/* + * Supports color key + */ +#define DDCAPS_COLORKEY 0x00400000l + +/* + * Supports alpha surfaces + */ +#define DDCAPS_ALPHA 0x00800000l + +/* + * colorkey is hardware assisted(DDCAPS_COLORKEY will also be set) + */ +#define DDCAPS_COLORKEYHWASSIST 0x01000000l + +/* + * no hardware support at all + */ +#define DDCAPS_NOHARDWARE 0x02000000l + +/* + * Display hardware is capable of color fill with bltter + */ +#define DDCAPS_BLTCOLORFILL 0x04000000l + +/* + * Display hardware is bank switched, and potentially very slow at + * random access to VRAM. + */ +#define DDCAPS_BANKSWITCHED 0x08000000l + +/* + * Display hardware is capable of depth filling Z-buffers with bltter + */ +#define DDCAPS_BLTDEPTHFILL 0x10000000l + +/* + * Display hardware is capable of clipping while bltting. + */ +#define DDCAPS_CANCLIP 0x20000000l + +/* + * Display hardware is capable of clipping while stretch bltting. + */ +#define DDCAPS_CANCLIPSTRETCHED 0x40000000l + +/* + * Display hardware is capable of bltting to or from system memory + */ +#define DDCAPS_CANBLTSYSMEM 0x80000000l + + + /**************************************************************************** + * + * MORE DIRECTDRAW DRIVER CAPABILITY FLAGS (dwCaps2) + * + ****************************************************************************/ + +/* + * Display hardware is certified + */ +#define DDCAPS2_CERTIFIED 0x00000001l + +/* + * Driver cannot interleave 2D operations (lock and blt) to surfaces with + * Direct3D rendering operations between calls to BeginScene() and EndScene() + */ +#define DDCAPS2_NO2DDURING3DSCENE 0x00000002l + +/* + * Display hardware contains a video port + */ +#define DDCAPS2_VIDEOPORT 0x00000004l + +/* + * The overlay can be automatically flipped according to the video port + * VSYNCs, providing automatic doubled buffered display of video port + * data using an overlay + */ +#define DDCAPS2_AUTOFLIPOVERLAY 0x00000008l + +/* + * Overlay can display each field of interlaced data individually while + * it is interleaved in memory without causing jittery artifacts. + */ +#define DDCAPS2_CANBOBINTERLEAVED 0x00000010l + +/* + * Overlay can display each field of interlaced data individually while + * it is not interleaved in memory without causing jittery artifacts. + */ +#define DDCAPS2_CANBOBNONINTERLEAVED 0x00000020l + +/* + * The overlay surface contains color controls (brightness, sharpness, etc.) + */ +#define DDCAPS2_COLORCONTROLOVERLAY 0x00000040l + +/* + * The primary surface contains color controls (gamma, etc.) + */ +#define DDCAPS2_COLORCONTROLPRIMARY 0x00000080l + +/* + * RGBZ -> RGB supported for 16:16 RGB:Z + */ +#define DDCAPS2_CANDROPZ16BIT 0x00000100l + +/* + * Driver supports non-local video memory. + */ +#define DDCAPS2_NONLOCALVIDMEM 0x00000200l + +/* + * Dirver supports non-local video memory but has different capabilities for + * non-local video memory surfaces. If this bit is set then so must + * DDCAPS2_NONLOCALVIDMEM. + */ +#define DDCAPS2_NONLOCALVIDMEMCAPS 0x00000400l + +/* + * Driver neither requires nor prefers surfaces to be pagelocked when performing + * blts involving system memory surfaces + */ +#define DDCAPS2_NOPAGELOCKREQUIRED 0x00000800l + +/* + * Driver can create surfaces which are wider than the primary surface + */ +#define DDCAPS2_WIDESURFACES 0x00001000l + +/* + * Driver supports bob without using a video port by handling the + * DDFLIP_ODD and DDFLIP_EVEN flags specified in Flip. + */ +#define DDCAPS2_CANFLIPODDEVEN 0x00002000l + +/* + * Driver supports bob using hardware + */ +#define DDCAPS2_CANBOBHARDWARE 0x00004000l + +/* + * Driver supports bltting any FOURCC surface to another surface of the same FOURCC + */ +#define DDCAPS2_COPYFOURCC 0x00008000l + + +/* + * Driver supports loadable gamma ramps for the primary surface + */ +#define DDCAPS2_PRIMARYGAMMA 0x00020000l + +/* + * Driver can render in windowed mode. + */ +#define DDCAPS2_CANRENDERWINDOWED 0x00080000l + +/* + * A calibrator is available to adjust the gamma ramp according to the + * physical display properties so that the result will be identical on + * all calibrated systems. + */ +#define DDCAPS2_CANCALIBRATEGAMMA 0x00100000l + +/* + * Indicates that the driver will respond to DDFLIP_INTERVALn flags + */ +#define DDCAPS2_FLIPINTERVAL 0x00200000l + +/* + * Indicates that the driver will respond to DDFLIP_NOVSYNC + */ +#define DDCAPS2_FLIPNOVSYNC 0x00400000l + +/* + * Driver supports management of video memory, if this flag is ON, + * driver manages the texture if requested with DDSCAPS2_TEXTUREMANAGE on + * DirectX manages the texture if this flag is OFF and surface has DDSCAPS2_TEXTUREMANAGE on + */ +#define DDCAPS2_CANMANAGETEXTURE 0x00800000l + +/* + * The Direct3D texture manager uses this cap to decide whether to put managed + * surfaces in non-local video memory. If the cap is set, the texture manager will + * put managed surfaces in non-local vidmem. Drivers that cannot texture from + * local vidmem SHOULD NOT set this cap. + */ +#define DDCAPS2_TEXMANINNONLOCALVIDMEM 0x01000000l + +/* + * Indicates that the driver supports DX7 type of stereo in at least one mode (which may + * not necessarily be the current mode). Applications should use IDirectDraw7 (or higher) + * ::EnumDisplayModes and check the DDSURFACEDESC.ddsCaps.dwCaps2 field for the presence of + * DDSCAPS2_STEREOSURFACELEFT to check if a particular mode supports stereo. The application + * can also use IDirectDraw7(or higher)::GetDisplayMode to check the current mode. + */ +#define DDCAPS2_STEREO 0x02000000L + +/* + * This caps bit is intended for internal DirectDraw use. + * -It is only valid if DDCAPS2_NONLOCALVIDMEMCAPS is set. + * -If this bit is set, then DDCAPS_CANBLTSYSMEM MUST be set by the driver (and + * all the assoicated system memory blt caps must be correct). + * -It implies that the system->video blt caps in DDCAPS also apply to system to + * nonlocal blts. I.e. the dwSVBCaps, dwSVBCKeyCaps, dwSVBFXCaps and dwSVBRops + * members of DDCAPS (DDCORECAPS) are filled in correctly. + * -Any blt from system to nonlocal memory that matches these caps bits will + * be passed to the driver. + * + * NOTE: This is intended to enable the driver itself to do efficient reordering + * of textures. This is NOT meant to imply that hardware can write into AGP memory. + * This operation is not currently supported. + */ +#define DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL 0x04000000L + +/* + * was DDCAPS2_PUREHAL + */ +#define DDCAPS2_RESERVED1 0x08000000L + +/* + * Driver supports management of video memory, if this flag is ON, + * driver manages the resource if requested with DDSCAPS2_TEXTUREMANAGE on + * DirectX manages the resource if this flag is OFF and surface has DDSCAPS2_TEXTUREMANAGE on + */ +#define DDCAPS2_CANMANAGERESOURCE 0x10000000L + +/* + * Driver supports dynamic textures. This will allow the application to set + * D3DUSAGE_DYNAMIC (DDSCAPS2_HINTDYNAMIC for drivers) at texture create time. + * Video memory dynamic textures WILL be lockable by applications. It is + * expected that these locks will be very efficient (which implies that the + * driver should always maintain a linear copy, a pointer to which can be + * quickly handed out to the application). + */ +#define DDCAPS2_DYNAMICTEXTURES 0x20000000L + +/* + * Driver supports auto-generation of mipmaps. + */ +#define DDCAPS2_CANAUTOGENMIPMAP 0x40000000L + + +/**************************************************************************** + * + * DIRECTDRAW FX ALPHA CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * Supports alpha blending around the edge of a source color keyed surface. + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHAEDGEBLEND 0x00000001l + +/* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value becomes + * more opaque as the alpha value increases. (0 is transparent.) + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHAPIXELS 0x00000002l + +/* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value + * becomes more transparent as the alpha value increases. (0 is opaque.) + * This flag can only be set if DDCAPS_ALPHA is set. + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHAPIXELSNEG 0x00000004l + +/* + * Supports alpha only surfaces. The bit depth of an alpha only surface can be + * 1,2,4, or 8. The alpha value becomes more opaque as the alpha value increases. + * (0 is transparent.) + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHASURFACES 0x00000008l + +/* + * The depth of the alpha channel data can range can be 1,2,4, or 8. + * The NEG suffix indicates that this alpha channel becomes more transparent + * as the alpha value increases. (0 is opaque.) This flag can only be set if + * DDCAPS_ALPHA is set. + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHASURFACESNEG 0x00000010l + +/* + * Supports alpha blending around the edge of a source color keyed surface. + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND 0x00000020l + +/* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value becomes + * more opaque as the alpha value increases. (0 is transparent.) + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHAPIXELS 0x00000040l + +/* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value + * becomes more transparent as the alpha value increases. (0 is opaque.) + * This flag can only be set if DDCAPS_ALPHA is set. + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG 0x00000080l + +/* + * Supports alpha only surfaces. The bit depth of an alpha only surface can be + * 1,2,4, or 8. The alpha value becomes more opaque as the alpha value increases. + * (0 is transparent.) + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHASURFACES 0x00000100l + +/* + * The depth of the alpha channel data can range can be 1,2,4, or 8. + * The NEG suffix indicates that this alpha channel becomes more transparent + * as the alpha value increases. (0 is opaque.) This flag can only be set if + * DDCAPS_ALPHA is set. + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHASURFACESNEG 0x00000200l + +#if DIRECTDRAW_VERSION < 0x0600 +#endif //DIRECTDRAW_VERSION + + +/**************************************************************************** + * + * DIRECTDRAW FX CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * Uses arithmetic operations to stretch and shrink surfaces during blt + * rather than pixel doubling techniques. Along the Y axis. + */ +#define DDFXCAPS_BLTARITHSTRETCHY 0x00000020l + +/* + * Uses arithmetic operations to stretch during blt + * rather than pixel doubling techniques. Along the Y axis. Only + * works for x1, x2, etc. + */ +#define DDFXCAPS_BLTARITHSTRETCHYN 0x00000010l + +/* + * Supports mirroring left to right in blt. + */ +#define DDFXCAPS_BLTMIRRORLEFTRIGHT 0x00000040l + +/* + * Supports mirroring top to bottom in blt. + */ +#define DDFXCAPS_BLTMIRRORUPDOWN 0x00000080l + +/* + * Supports arbitrary rotation for blts. + */ +#define DDFXCAPS_BLTROTATION 0x00000100l + +/* + * Supports 90 degree rotations for blts. + */ +#define DDFXCAPS_BLTROTATION90 0x00000200l + +/* + * DirectDraw supports arbitrary shrinking of a surface along the + * x axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSHRINKX 0x00000400l + +/* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the x axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSHRINKXN 0x00000800l + +/* + * DirectDraw supports arbitrary shrinking of a surface along the + * y axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSHRINKY 0x00001000l + +/* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the y axis (vertical direction) for blts. + */ +#define DDFXCAPS_BLTSHRINKYN 0x00002000l + +/* + * DirectDraw supports arbitrary stretching of a surface along the + * x axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSTRETCHX 0x00004000l + +/* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the x axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSTRETCHXN 0x00008000l + +/* + * DirectDraw supports arbitrary stretching of a surface along the + * y axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSTRETCHY 0x00010000l + +/* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the y axis (vertical direction) for blts. + */ +#define DDFXCAPS_BLTSTRETCHYN 0x00020000l + +/* + * Uses arithmetic operations to stretch and shrink surfaces during + * overlay rather than pixel doubling techniques. Along the Y axis + * for overlays. + */ +#define DDFXCAPS_OVERLAYARITHSTRETCHY 0x00040000l + +/* + * Uses arithmetic operations to stretch surfaces during + * overlay rather than pixel doubling techniques. Along the Y axis + * for overlays. Only works for x1, x2, etc. + */ +#define DDFXCAPS_OVERLAYARITHSTRETCHYN 0x00000008l + +/* + * DirectDraw supports arbitrary shrinking of a surface along the + * x axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSHRINKX 0x00080000l + +/* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the x axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSHRINKXN 0x00100000l + +/* + * DirectDraw supports arbitrary shrinking of a surface along the + * y axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSHRINKY 0x00200000l + +/* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the y axis (vertical direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSHRINKYN 0x00400000l + +/* + * DirectDraw supports arbitrary stretching of a surface along the + * x axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSTRETCHX 0x00800000l + +/* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the x axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSTRETCHXN 0x01000000l + +/* + * DirectDraw supports arbitrary stretching of a surface along the + * y axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSTRETCHY 0x02000000l + +/* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the y axis (vertical direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSTRETCHYN 0x04000000l + +/* + * DirectDraw supports mirroring of overlays across the vertical axis + */ +#define DDFXCAPS_OVERLAYMIRRORLEFTRIGHT 0x08000000l + +/* + * DirectDraw supports mirroring of overlays across the horizontal axis + */ +#define DDFXCAPS_OVERLAYMIRRORUPDOWN 0x10000000l + +/* + * DirectDraw supports deinterlacing of overlay surfaces + */ +#define DDFXCAPS_OVERLAYDEINTERLACE 0x20000000l + +/* + * Driver can do alpha blending for blits. + */ +#define DDFXCAPS_BLTALPHA 0x00000001l + + +/* + * Driver can do surface-reconstruction filtering for warped blits. + */ +#define DDFXCAPS_BLTFILTER DDFXCAPS_BLTARITHSTRETCHY + +/* + * Driver can do alpha blending for overlays. + */ +#define DDFXCAPS_OVERLAYALPHA 0x00000004l + + +/* + * Driver can do surface-reconstruction filtering for warped overlays. + */ +#define DDFXCAPS_OVERLAYFILTER DDFXCAPS_OVERLAYARITHSTRETCHY + +/**************************************************************************** + * + * DIRECTDRAW STEREO VIEW CAPABILITIES + * + ****************************************************************************/ + +/* + * This flag used to be DDSVCAPS_ENIGMA, which is now obsolete + */ + +#define DDSVCAPS_RESERVED1 0x00000001l + +/* + * This flag used to be DDSVCAPS_FLICKER, which is now obsolete + */ +#define DDSVCAPS_RESERVED2 0x00000002l + +/* + * This flag used to be DDSVCAPS_REDBLUE, which is now obsolete + */ +#define DDSVCAPS_RESERVED3 0x00000004l + +/* + * This flag used to be DDSVCAPS_SPLIT, which is now obsolete + */ +#define DDSVCAPS_RESERVED4 0x00000008l + +/* + * The stereo view is accomplished with switching technology + */ + +#define DDSVCAPS_STEREOSEQUENTIAL 0x00000010L + + + +/**************************************************************************** + * + * DIRECTDRAWPALETTE CAPABILITIES + * + ****************************************************************************/ + +/* + * Index is 4 bits. There are sixteen color entries in the palette table. + */ +#define DDPCAPS_4BIT 0x00000001l + +/* + * Index is onto a 8 bit color index. This field is only valid with the + * DDPCAPS_1BIT, DDPCAPS_2BIT or DDPCAPS_4BIT capability and the target + * surface is in 8bpp. Each color entry is one byte long and is an index + * into destination surface's 8bpp palette. + */ +#define DDPCAPS_8BITENTRIES 0x00000002l + +/* + * Index is 8 bits. There are 256 color entries in the palette table. + */ +#define DDPCAPS_8BIT 0x00000004l + +/* + * Indicates that this DIRECTDRAWPALETTE should use the palette color array + * passed into the lpDDColorArray parameter to initialize the DIRECTDRAWPALETTE + * object. + * This flag is obsolete. DirectDraw always initializes the color array from + * the lpDDColorArray parameter. The definition remains for source-level + * compatibility. + */ +#define DDPCAPS_INITIALIZE 0x00000000l + +/* + * This palette is the one attached to the primary surface. Changing this + * table has immediate effect on the display unless DDPSETPAL_VSYNC is specified + * and supported. + */ +#define DDPCAPS_PRIMARYSURFACE 0x00000010l + +/* + * This palette is the one attached to the primary surface left. Changing + * this table has immediate effect on the display for the left eye unless + * DDPSETPAL_VSYNC is specified and supported. + */ +#define DDPCAPS_PRIMARYSURFACELEFT 0x00000020l + +/* + * This palette can have all 256 entries defined + */ +#define DDPCAPS_ALLOW256 0x00000040l + +/* + * This palette can have modifications to it synced with the monitors + * refresh rate. + */ +#define DDPCAPS_VSYNC 0x00000080l + +/* + * Index is 1 bit. There are two color entries in the palette table. + */ +#define DDPCAPS_1BIT 0x00000100l + +/* + * Index is 2 bit. There are four color entries in the palette table. + */ +#define DDPCAPS_2BIT 0x00000200l + +/* + * The peFlags member of PALETTEENTRY denotes an 8 bit alpha value + */ +#define DDPCAPS_ALPHA 0x00000400l + + +/**************************************************************************** + * + * DIRECTDRAWPALETTE SETENTRY CONSTANTS + * + ****************************************************************************/ + + +/**************************************************************************** + * + * DIRECTDRAWPALETTE GETENTRY CONSTANTS + * + ****************************************************************************/ + +/* 0 is the only legal value */ + +/**************************************************************************** + * + * DIRECTDRAWSURFACE SETPRIVATEDATA CONSTANTS + * + ****************************************************************************/ + +/* + * The passed pointer is an IUnknown ptr. The cbData argument to SetPrivateData + * must be set to sizeof(IUnknown*). DirectDraw will call AddRef through this + * pointer and Release when the private data is destroyed. This includes when + * the surface or palette is destroyed before such priovate data is destroyed. + */ +#define DDSPD_IUNKNOWNPOINTER 0x00000001L + +/* + * Private data is only valid for the current state of the object, + * as determined by the uniqueness value. + */ +#define DDSPD_VOLATILE 0x00000002L + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE SETPALETTE CONSTANTS + * + ****************************************************************************/ + + +/**************************************************************************** + * + * DIRECTDRAW BITDEPTH CONSTANTS + * + * NOTE: These are only used to indicate supported bit depths. These + * are flags only, they are not to be used as an actual bit depth. The + * absolute numbers 1, 2, 4, 8, 16, 24 and 32 are used to indicate actual + * bit depths in a surface or for changing the display mode. + * + ****************************************************************************/ + +/* + * 1 bit per pixel. + */ +#define DDBD_1 0x00004000l + +/* + * 2 bits per pixel. + */ +#define DDBD_2 0x00002000l + +/* + * 4 bits per pixel. + */ +#define DDBD_4 0x00001000l + +/* + * 8 bits per pixel. + */ +#define DDBD_8 0x00000800l + +/* + * 16 bits per pixel. + */ +#define DDBD_16 0x00000400l + +/* + * 24 bits per pixel. + */ +#define DDBD_24 0X00000200l + +/* + * 32 bits per pixel. + */ +#define DDBD_32 0x00000100l + +/**************************************************************************** + * + * DIRECTDRAWSURFACE SET/GET COLOR KEY FLAGS + * + ****************************************************************************/ + +/* + * Set if the structure contains a color space. Not set if the structure + * contains a single color key. + */ +#define DDCKEY_COLORSPACE 0x00000001l + +/* + * Set if the structure specifies a color key or color space which is to be + * used as a destination color key for blt operations. + */ +#define DDCKEY_DESTBLT 0x00000002l + +/* + * Set if the structure specifies a color key or color space which is to be + * used as a destination color key for overlay operations. + */ +#define DDCKEY_DESTOVERLAY 0x00000004l + +/* + * Set if the structure specifies a color key or color space which is to be + * used as a source color key for blt operations. + */ +#define DDCKEY_SRCBLT 0x00000008l + +/* + * Set if the structure specifies a color key or color space which is to be + * used as a source color key for overlay operations. + */ +#define DDCKEY_SRCOVERLAY 0x00000010l + + +/**************************************************************************** + * + * DIRECTDRAW COLOR KEY CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * Supports transparent blting using a color key to identify the replaceable + * bits of the destination surface for RGB colors. + */ +#define DDCKEYCAPS_DESTBLT 0x00000001l + +/* + * Supports transparent blting using a color space to identify the replaceable + * bits of the destination surface for RGB colors. + */ +#define DDCKEYCAPS_DESTBLTCLRSPACE 0x00000002l + +/* + * Supports transparent blting using a color space to identify the replaceable + * bits of the destination surface for YUV colors. + */ +#define DDCKEYCAPS_DESTBLTCLRSPACEYUV 0x00000004l + +/* + * Supports transparent blting using a color key to identify the replaceable + * bits of the destination surface for YUV colors. + */ +#define DDCKEYCAPS_DESTBLTYUV 0x00000008l + +/* + * Supports overlaying using colorkeying of the replaceable bits of the surface + * being overlayed for RGB colors. + */ +#define DDCKEYCAPS_DESTOVERLAY 0x00000010l + +/* + * Supports a color space as the color key for the destination for RGB colors. + */ +#define DDCKEYCAPS_DESTOVERLAYCLRSPACE 0x00000020l + +/* + * Supports a color space as the color key for the destination for YUV colors. + */ +#define DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV 0x00000040l + +/* + * Supports only one active destination color key value for visible overlay + * surfaces. + */ +#define DDCKEYCAPS_DESTOVERLAYONEACTIVE 0x00000080l + +/* + * Supports overlaying using colorkeying of the replaceable bits of the + * surface being overlayed for YUV colors. + */ +#define DDCKEYCAPS_DESTOVERLAYYUV 0x00000100l + +/* + * Supports transparent blting using the color key for the source with + * this surface for RGB colors. + */ +#define DDCKEYCAPS_SRCBLT 0x00000200l + +/* + * Supports transparent blting using a color space for the source with + * this surface for RGB colors. + */ +#define DDCKEYCAPS_SRCBLTCLRSPACE 0x00000400l + +/* + * Supports transparent blting using a color space for the source with + * this surface for YUV colors. + */ +#define DDCKEYCAPS_SRCBLTCLRSPACEYUV 0x00000800l + +/* + * Supports transparent blting using the color key for the source with + * this surface for YUV colors. + */ +#define DDCKEYCAPS_SRCBLTYUV 0x00001000l + +/* + * Supports overlays using the color key for the source with this + * overlay surface for RGB colors. + */ +#define DDCKEYCAPS_SRCOVERLAY 0x00002000l + +/* + * Supports overlays using a color space as the source color key for + * the overlay surface for RGB colors. + */ +#define DDCKEYCAPS_SRCOVERLAYCLRSPACE 0x00004000l + +/* + * Supports overlays using a color space as the source color key for + * the overlay surface for YUV colors. + */ +#define DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV 0x00008000l + +/* + * Supports only one active source color key value for visible + * overlay surfaces. + */ +#define DDCKEYCAPS_SRCOVERLAYONEACTIVE 0x00010000l + +/* + * Supports overlays using the color key for the source with this + * overlay surface for YUV colors. + */ +#define DDCKEYCAPS_SRCOVERLAYYUV 0x00020000l + +/* + * there are no bandwidth trade-offs for using colorkey with an overlay + */ +#define DDCKEYCAPS_NOCOSTOVERLAY 0x00040000l + + +/**************************************************************************** + * + * DIRECTDRAW PIXELFORMAT FLAGS + * + ****************************************************************************/ + +/* + * The surface has alpha channel information in the pixel format. + */ +#define DDPF_ALPHAPIXELS 0x00000001l + +/* + * The pixel format contains alpha only information + */ +#define DDPF_ALPHA 0x00000002l + +/* + * The FourCC code is valid. + */ +#define DDPF_FOURCC 0x00000004l + +/* + * The surface is 4-bit color indexed. + */ +#define DDPF_PALETTEINDEXED4 0x00000008l + +/* + * The surface is indexed into a palette which stores indices + * into the destination surface's 8-bit palette. + */ +#define DDPF_PALETTEINDEXEDTO8 0x00000010l + +/* + * The surface is 8-bit color indexed. + */ +#define DDPF_PALETTEINDEXED8 0x00000020l + +/* + * The RGB data in the pixel format structure is valid. + */ +#define DDPF_RGB 0x00000040l + +/* + * The surface will accept pixel data in the format specified + * and compress it during the write. + */ +#define DDPF_COMPRESSED 0x00000080l + +/* + * The surface will accept RGB data and translate it during + * the write to YUV data. The format of the data to be written + * will be contained in the pixel format structure. The DDPF_RGB + * flag will be set. + */ +#define DDPF_RGBTOYUV 0x00000100l + +/* + * pixel format is YUV - YUV data in pixel format struct is valid + */ +#define DDPF_YUV 0x00000200l + +/* + * pixel format is a z buffer only surface + */ +#define DDPF_ZBUFFER 0x00000400l + +/* + * The surface is 1-bit color indexed. + */ +#define DDPF_PALETTEINDEXED1 0x00000800l + +/* + * The surface is 2-bit color indexed. + */ +#define DDPF_PALETTEINDEXED2 0x00001000l + +/* + * The surface contains Z information in the pixels + */ +#define DDPF_ZPIXELS 0x00002000l + +/* + * The surface contains stencil information along with Z + */ +#define DDPF_STENCILBUFFER 0x00004000l + +/* + * Premultiplied alpha format -- the color components have been + * premultiplied by the alpha component. + */ +#define DDPF_ALPHAPREMULT 0x00008000l + + +/* + * Luminance data in the pixel format is valid. + * Use this flag for luminance-only or luminance+alpha surfaces, + * the bit depth is then ddpf.dwLuminanceBitCount. + */ +#define DDPF_LUMINANCE 0x00020000l + +/* + * Luminance data in the pixel format is valid. + * Use this flag when hanging luminance off bumpmap surfaces, + * the bit mask for the luminance portion of the pixel is then + * ddpf.dwBumpLuminanceBitMask + */ +#define DDPF_BUMPLUMINANCE 0x00040000l + +/* + * Bump map dUdV data in the pixel format is valid. + */ +#define DDPF_BUMPDUDV 0x00080000l + + +/*=========================================================================== + * + * + * DIRECTDRAW CALLBACK FLAGS + * + * + *==========================================================================*/ + +/**************************************************************************** + * + * DIRECTDRAW ENUMSURFACES FLAGS + * + ****************************************************************************/ + +/* + * Enumerate all of the surfaces that meet the search criterion. + */ +#define DDENUMSURFACES_ALL 0x00000001l + +/* + * A search hit is a surface that matches the surface description. + */ +#define DDENUMSURFACES_MATCH 0x00000002l + +/* + * A search hit is a surface that does not match the surface description. + */ +#define DDENUMSURFACES_NOMATCH 0x00000004l + +/* + * Enumerate the first surface that can be created which meets the search criterion. + */ +#define DDENUMSURFACES_CANBECREATED 0x00000008l + +/* + * Enumerate the surfaces that already exist that meet the search criterion. + */ +#define DDENUMSURFACES_DOESEXIST 0x00000010l + + +/**************************************************************************** + * + * DIRECTDRAW SETDISPLAYMODE FLAGS + * + ****************************************************************************/ + +/* + * The desired mode is a standard VGA mode + */ +#define DDSDM_STANDARDVGAMODE 0x00000001l + + +/**************************************************************************** + * + * DIRECTDRAW ENUMDISPLAYMODES FLAGS + * + ****************************************************************************/ + +/* + * Enumerate Modes with different refresh rates. EnumDisplayModes guarantees + * that a particular mode will be enumerated only once. This flag specifies whether + * the refresh rate is taken into account when determining if a mode is unique. + */ +#define DDEDM_REFRESHRATES 0x00000001l + +/* + * Enumerate VGA modes. Specify this flag if you wish to enumerate supported VGA + * modes such as mode 0x13 in addition to the usual ModeX modes (which are always + * enumerated if the application has previously called SetCooperativeLevel with the + * DDSCL_ALLOWMODEX flag set). + */ +#define DDEDM_STANDARDVGAMODES 0x00000002L + + +/**************************************************************************** + * + * DIRECTDRAW SETCOOPERATIVELEVEL FLAGS + * + ****************************************************************************/ + +/* + * Exclusive mode owner will be responsible for the entire primary surface. + * GDI can be ignored. used with DD + */ +#define DDSCL_FULLSCREEN 0x00000001l + +/* + * allow CTRL_ALT_DEL to work while in fullscreen exclusive mode + */ +#define DDSCL_ALLOWREBOOT 0x00000002l + +/* + * prevents DDRAW from modifying the application window. + * prevents DDRAW from minimize/restore the application window on activation. + */ +#define DDSCL_NOWINDOWCHANGES 0x00000004l + +/* + * app wants to work as a regular Windows application + */ +#define DDSCL_NORMAL 0x00000008l + +/* + * app wants exclusive access + */ +#define DDSCL_EXCLUSIVE 0x00000010l + + +/* + * app can deal with non-windows display modes + */ +#define DDSCL_ALLOWMODEX 0x00000040l + +/* + * this window will receive the focus messages + */ +#define DDSCL_SETFOCUSWINDOW 0x00000080l + +/* + * this window is associated with the DDRAW object and will + * cover the screen in fullscreen mode + */ +#define DDSCL_SETDEVICEWINDOW 0x00000100l + +/* + * app wants DDRAW to create a window to be associated with the + * DDRAW object + */ +#define DDSCL_CREATEDEVICEWINDOW 0x00000200l + +/* + * App explicitly asks DDRAW/D3D to be multithread safe. This makes D3D + * take the global crtisec more frequently. + */ +#define DDSCL_MULTITHREADED 0x00000400l + +/* + * App specifies that it would like to keep the FPU set up for optimal Direct3D + * performance (single precision and exceptions disabled) so Direct3D + * does not need to explicitly set the FPU each time. This is assumed by + * default in DirectX 7. See also DDSCL_FPUPRESERVE + */ +#define DDSCL_FPUSETUP 0x00000800l + +/* + * App specifies that it needs either double precision FPU or FPU exceptions + * enabled. This makes Direct3D explicitly set the FPU state eah time it is + * called. Setting the flag will reduce Direct3D performance. The flag is + * assumed by default in DirectX 6 and earlier. See also DDSCL_FPUSETUP + */ +#define DDSCL_FPUPRESERVE 0x00001000l + + +/**************************************************************************** + * + * DIRECTDRAW BLT FLAGS + * + ****************************************************************************/ + +/* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the destination surface as the alpha channel for this blt. + */ +#define DDBLT_ALPHADEST 0x00000001l + +/* + * Use the dwConstAlphaDest field in the DDBLTFX structure as the alpha channel + * for the destination surface for this blt. + */ +#define DDBLT_ALPHADESTCONSTOVERRIDE 0x00000002l + +/* + * The NEG suffix indicates that the destination surface becomes more + * transparent as the alpha value increases. (0 is opaque) + */ +#define DDBLT_ALPHADESTNEG 0x00000004l + +/* + * Use the lpDDSAlphaDest field in the DDBLTFX structure as the alpha + * channel for the destination for this blt. + */ +#define DDBLT_ALPHADESTSURFACEOVERRIDE 0x00000008l + +/* + * Use the dwAlphaEdgeBlend field in the DDBLTFX structure as the alpha channel + * for the edges of the image that border the color key colors. + */ +#define DDBLT_ALPHAEDGEBLEND 0x00000010l + +/* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the source surface as the alpha channel for this blt. + */ +#define DDBLT_ALPHASRC 0x00000020l + +/* + * Use the dwConstAlphaSrc field in the DDBLTFX structure as the alpha channel + * for the source for this blt. + */ +#define DDBLT_ALPHASRCCONSTOVERRIDE 0x00000040l + +/* + * The NEG suffix indicates that the source surface becomes more transparent + * as the alpha value increases. (0 is opaque) + */ +#define DDBLT_ALPHASRCNEG 0x00000080l + +/* + * Use the lpDDSAlphaSrc field in the DDBLTFX structure as the alpha channel + * for the source for this blt. + */ +#define DDBLT_ALPHASRCSURFACEOVERRIDE 0x00000100l + +/* + * Do this blt asynchronously through the FIFO in the order received. If + * there is no room in the hardware FIFO fail the call. + */ +#define DDBLT_ASYNC 0x00000200l + +/* + * Uses the dwFillColor field in the DDBLTFX structure as the RGB color + * to fill the destination rectangle on the destination surface with. + */ +#define DDBLT_COLORFILL 0x00000400l + +/* + * Uses the dwDDFX field in the DDBLTFX structure to specify the effects + * to use for the blt. + */ +#define DDBLT_DDFX 0x00000800l + +/* + * Uses the dwDDROPS field in the DDBLTFX structure to specify the ROPS + * that are not part of the Win32 API. + */ +#define DDBLT_DDROPS 0x00001000l + +/* + * Use the color key associated with the destination surface. + */ +#define DDBLT_KEYDEST 0x00002000l + +/* + * Use the dckDestColorkey field in the DDBLTFX structure as the color key + * for the destination surface. + */ +#define DDBLT_KEYDESTOVERRIDE 0x00004000l + +/* + * Use the color key associated with the source surface. + */ +#define DDBLT_KEYSRC 0x00008000l + +/* + * Use the dckSrcColorkey field in the DDBLTFX structure as the color key + * for the source surface. + */ +#define DDBLT_KEYSRCOVERRIDE 0x00010000l + +/* + * Use the dwROP field in the DDBLTFX structure for the raster operation + * for this blt. These ROPs are the same as the ones defined in the Win32 API. + */ +#define DDBLT_ROP 0x00020000l + +/* + * Use the dwRotationAngle field in the DDBLTFX structure as the angle + * (specified in 1/100th of a degree) to rotate the surface. + */ +#define DDBLT_ROTATIONANGLE 0x00040000l + +/* + * Z-buffered blt using the z-buffers attached to the source and destination + * surfaces and the dwZBufferOpCode field in the DDBLTFX structure as the + * z-buffer opcode. + */ +#define DDBLT_ZBUFFER 0x00080000l + +/* + * Z-buffered blt using the dwConstDest Zfield and the dwZBufferOpCode field + * in the DDBLTFX structure as the z-buffer and z-buffer opcode respectively + * for the destination. + */ +#define DDBLT_ZBUFFERDESTCONSTOVERRIDE 0x00100000l + +/* + * Z-buffered blt using the lpDDSDestZBuffer field and the dwZBufferOpCode + * field in the DDBLTFX structure as the z-buffer and z-buffer opcode + * respectively for the destination. + */ +#define DDBLT_ZBUFFERDESTOVERRIDE 0x00200000l + +/* + * Z-buffered blt using the dwConstSrcZ field and the dwZBufferOpCode field + * in the DDBLTFX structure as the z-buffer and z-buffer opcode respectively + * for the source. + */ +#define DDBLT_ZBUFFERSRCCONSTOVERRIDE 0x00400000l + +/* + * Z-buffered blt using the lpDDSSrcZBuffer field and the dwZBufferOpCode + * field in the DDBLTFX structure as the z-buffer and z-buffer opcode + * respectively for the source. + */ +#define DDBLT_ZBUFFERSRCOVERRIDE 0x00800000l + +/* + * wait until the device is ready to handle the blt + * this will cause blt to not return DDERR_WASSTILLDRAWING + */ +#define DDBLT_WAIT 0x01000000l + +/* + * Uses the dwFillDepth field in the DDBLTFX structure as the depth value + * to fill the destination rectangle on the destination Z-buffer surface + * with. + */ +#define DDBLT_DEPTHFILL 0x02000000l + + +/* + * Return immediately (with DDERR_WASSTILLDRAWING) if the device is not + * ready to schedule the blt at the time Blt() is called. + */ +#define DDBLT_DONOTWAIT 0x08000000l + +/* + * These flags indicate a presentation blt (i.e. a blt + * that moves surface contents from an offscreen back buffer to the primary + * surface). The driver is not allowed to "queue" more than three such blts. + * The "end" of the presentation blt is indicated, since the + * blt may be clipped, in which case the runtime will call the driver with + * several blts. All blts (even if not clipped) are tagged with DDBLT_PRESENTATION + * and the last (even if not clipped) additionally with DDBLT_LAST_PRESENTATION. + * Thus the true rule is that the driver must not schedule a DDBLT_PRESENTATION + * blt if there are 3 or more DDBLT_PRESENTLAST blts in the hardware pipe. + * If there are such blts in the pipe, the driver should return DDERR_WASSTILLDRAWING + * until the oldest queued DDBLT_LAST_PRESENTATION blts has been retired (i.e. the + * pixels have been actually written to the primary surface). Once the oldest blt + * has been retired, the driver is free to schedule the current blt. + * The goal is to provide a mechanism whereby the device's hardware queue never + * gets more than 3 frames ahead of the frames being generated by the application. + * When excessive queueing occurs, applications become unusable because the application + * visibly lags user input, and such problems make windowed interactive applications impossible. + * Some drivers may not have sufficient knowledge of their hardware's FIFO to know + * when a certain blt has been retired. Such drivers should code cautiously, and + * simply not allow any frames to be queued at all. DDBLT_LAST_PRESENTATION should cause + * such drivers to return DDERR_WASSTILLDRAWING until the accelerator is completely + * finished- exactly as if the application had called Lock on the source surface + * before calling Blt. + * In other words, the driver is allowed and encouraged to + * generate as much latency as it can, but never more than 3 frames worth. + * Implementation detail: Drivers should count blts against the SOURCE surface, not + * against the primary surface. This enables multiple parallel windowed application + * to function more optimally. + * This flag is passed only to DX8 or higher drivers. + * + * APPLICATIONS DO NOT SET THESE FLAGS. THEY ARE SET BY THE DIRECTDRAW RUNTIME. + * + */ +#define DDBLT_PRESENTATION 0x10000000l +#define DDBLT_LAST_PRESENTATION 0x20000000l + +/* + * If DDBLT_EXTENDED_FLAGS is set, then the driver should re-interpret + * other flags according to the definitions that follow. + * For example, bit 0 (0x00000001L) means DDBLT_ALPHADEST, unless + * DDBLT_EXTENDED_FLAGS is also set, in which case bit 0 means + * DDBLT_EXTENDED_LINEAR_CONTENT. + * Only DirectX9 and higher drivers will be given extended blt flags. + * Only flags explicitly mentioned here should be re-interpreted. + * All other flags retain their original meanings. + * + * List of re-interpreted flags: + * + * Bit Hex value New meaning old meaning + * --------------------------------------------------------------- + * 2 0x00000004 DDBLT_EXTENDED_LINEAR_CONTENT DDBLT_ALPHADESTNEG + * 4 0x00000010 DDBLT_EXTENDED_PRESENTATION_STRETCHFACTOR DDBLT_ALPHAEDGEBLEND + * + * + * NOTE: APPLICATIONS SHOULD NOT SET THIS FLAG. THIS FLAG IS INTENDED + * FOR USE BY THE DIRECT3D RUNTIME. + */ +#define DDBLT_EXTENDED_FLAGS 0x40000000l + +/* + * EXTENDED FLAG. SEE DEFINITION OF DDBLT_EXTENDED_FLAGS. + * This flag indidcates that the source surface contains content in a + * linear color space. The driver may perform gamma correction to the + * desktop color space (i.e. sRGB, gamma 2.2) as part of this blt. + * If the device can perform such a conversion as part of the copy, + * the driver should also set D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION + * + * NOTE: APPLICATIONS SHOULD NOT SET THIS FLAG. THIS FLAG IS INTENDED + * FOR USE BY THE DIRECT3D RUNTIME. Use IDirect3DSwapChain9::Present + * and specify D3DPRESENT_LINEAR_CONTENT in order to use this functionality. + */ +#define DDBLT_EXTENDED_LINEAR_CONTENT 0x00000004l + + +/**************************************************************************** + * + * BLTFAST FLAGS + * + ****************************************************************************/ + +#define DDBLTFAST_NOCOLORKEY 0x00000000 +#define DDBLTFAST_SRCCOLORKEY 0x00000001 +#define DDBLTFAST_DESTCOLORKEY 0x00000002 +#define DDBLTFAST_WAIT 0x00000010 +#define DDBLTFAST_DONOTWAIT 0x00000020 + +/**************************************************************************** + * + * FLIP FLAGS + * + ****************************************************************************/ + +#define DDFLIP_WAIT 0x00000001L + +/* + * Indicates that the target surface contains the even field of video data. + * This flag is only valid with an overlay surface. + */ +#define DDFLIP_EVEN 0x00000002L + +/* + * Indicates that the target surface contains the odd field of video data. + * This flag is only valid with an overlay surface. + */ +#define DDFLIP_ODD 0x00000004L + +/* + * Causes DirectDraw to perform the physical flip immediately and return + * to the application. Typically, what was the front buffer but is now the back + * buffer will still be visible (depending on timing) until the next vertical + * retrace. Subsequent operations involving the two flipped surfaces will + * not check to see if the physical flip has finished (i.e. will not return + * DDERR_WASSTILLDRAWING for that reason (but may for other reasons)). + * This allows an application to perform Flips at a higher frequency than the + * monitor refresh rate, but may introduce visible artifacts. + * Only effective if DDCAPS2_FLIPNOVSYNC is set. If that bit is not set, + * DDFLIP_NOVSYNC has no effect. + */ +#define DDFLIP_NOVSYNC 0x00000008L + + +/* + * Flip Interval Flags. These flags indicate how many vertical retraces to wait between + * each flip. The default is one. DirectDraw will return DDERR_WASSTILLDRAWING for each + * surface involved in the flip until the specified number of vertical retraces has + * ocurred. Only effective if DDCAPS2_FLIPINTERVAL is set. If that bit is not set, + * DDFLIP_INTERVALn has no effect. + */ + +/* + * DirectDraw will flip on every other vertical sync + */ +#define DDFLIP_INTERVAL2 0x02000000L + + +/* + * DirectDraw will flip on every third vertical sync + */ +#define DDFLIP_INTERVAL3 0x03000000L + + +/* + * DirectDraw will flip on every fourth vertical sync + */ +#define DDFLIP_INTERVAL4 0x04000000L + +/* + * DirectDraw will flip and display a main stereo surface + */ +#define DDFLIP_STEREO 0x00000010L + +/* + * On IDirectDrawSurface7 and higher interfaces, the default is DDFLIP_WAIT. If you wish + * to override the default and use time when the accelerator is busy (as denoted by + * the DDERR_WASSTILLDRAWING return code) then use DDFLIP_DONOTWAIT. + */ +#define DDFLIP_DONOTWAIT 0x00000020L + + +/**************************************************************************** + * + * DIRECTDRAW SURFACE OVERLAY FLAGS + * + ****************************************************************************/ + +/* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the destination surface as the alpha channel for the + * destination overlay. + */ +#define DDOVER_ALPHADEST 0x00000001l + +/* + * Use the dwConstAlphaDest field in the DDOVERLAYFX structure as the + * destination alpha channel for this overlay. + */ +#define DDOVER_ALPHADESTCONSTOVERRIDE 0x00000002l + +/* + * The NEG suffix indicates that the destination surface becomes more + * transparent as the alpha value increases. + */ +#define DDOVER_ALPHADESTNEG 0x00000004l + +/* + * Use the lpDDSAlphaDest field in the DDOVERLAYFX structure as the alpha + * channel destination for this overlay. + */ +#define DDOVER_ALPHADESTSURFACEOVERRIDE 0x00000008l + +/* + * Use the dwAlphaEdgeBlend field in the DDOVERLAYFX structure as the alpha + * channel for the edges of the image that border the color key colors. + */ +#define DDOVER_ALPHAEDGEBLEND 0x00000010l + +/* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the source surface as the source alpha channel for this overlay. + */ +#define DDOVER_ALPHASRC 0x00000020l + +/* + * Use the dwConstAlphaSrc field in the DDOVERLAYFX structure as the source + * alpha channel for this overlay. + */ +#define DDOVER_ALPHASRCCONSTOVERRIDE 0x00000040l + +/* + * The NEG suffix indicates that the source surface becomes more transparent + * as the alpha value increases. + */ +#define DDOVER_ALPHASRCNEG 0x00000080l + +/* + * Use the lpDDSAlphaSrc field in the DDOVERLAYFX structure as the alpha channel + * source for this overlay. + */ +#define DDOVER_ALPHASRCSURFACEOVERRIDE 0x00000100l + +/* + * Turn this overlay off. + */ +#define DDOVER_HIDE 0x00000200l + +/* + * Use the color key associated with the destination surface. + */ +#define DDOVER_KEYDEST 0x00000400l + +/* + * Use the dckDestColorkey field in the DDOVERLAYFX structure as the color key + * for the destination surface + */ +#define DDOVER_KEYDESTOVERRIDE 0x00000800l + +/* + * Use the color key associated with the source surface. + */ +#define DDOVER_KEYSRC 0x00001000l + +/* + * Use the dckSrcColorkey field in the DDOVERLAYFX structure as the color key + * for the source surface. + */ +#define DDOVER_KEYSRCOVERRIDE 0x00002000l + +/* + * Turn this overlay on. + */ +#define DDOVER_SHOW 0x00004000l + +/* + * Add a dirty rect to an emulated overlayed surface. + */ +#define DDOVER_ADDDIRTYRECT 0x00008000l + +/* + * Redraw all dirty rects on an emulated overlayed surface. + */ +#define DDOVER_REFRESHDIRTYRECTS 0x00010000l + +/* + * Redraw the entire surface on an emulated overlayed surface. + */ +#define DDOVER_REFRESHALL 0x00020000l + + +/* + * Use the overlay FX flags to define special overlay FX + */ +#define DDOVER_DDFX 0x00080000l + +/* + * Autoflip the overlay when ever the video port autoflips + */ +#define DDOVER_AUTOFLIP 0x00100000l + +/* + * Display each field of video port data individually without + * causing any jittery artifacts + */ +#define DDOVER_BOB 0x00200000l + +/* + * Indicates that bob/weave decisions should not be overridden by other + * interfaces. + */ +#define DDOVER_OVERRIDEBOBWEAVE 0x00400000l + +/* + * Indicates that the surface memory is composed of interleaved fields. + */ +#define DDOVER_INTERLEAVED 0x00800000l + +/* + * Indicates that bob will be performed using hardware rather than + * software or emulated. + */ +#define DDOVER_BOBHARDWARE 0x01000000l + +/* + * Indicates that overlay FX structure contains valid ARGB scaling factors. + */ +#define DDOVER_ARGBSCALEFACTORS 0x02000000l + +/* + * Indicates that ARGB scaling factors can be degraded to fit driver capabilities. + */ +#define DDOVER_DEGRADEARGBSCALING 0x04000000l + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE LOCK FLAGS + * + ****************************************************************************/ + +/* + * The default. Set to indicate that Lock should return a valid memory pointer + * to the top of the specified rectangle. If no rectangle is specified then a + * pointer to the top of the surface is returned. + */ +#define DDLOCK_SURFACEMEMORYPTR 0x00000000L // default + +/* + * Set to indicate that Lock should wait until it can obtain a valid memory + * pointer before returning. If this bit is set, Lock will never return + * DDERR_WASSTILLDRAWING. + */ +#define DDLOCK_WAIT 0x00000001L + +/* + * Set if an event handle is being passed to Lock. Lock will trigger the event + * when it can return the surface memory pointer requested. + */ +#define DDLOCK_EVENT 0x00000002L + +/* + * Indicates that the surface being locked will only be read from. + */ +#define DDLOCK_READONLY 0x00000010L + +/* + * Indicates that the surface being locked will only be written to + */ +#define DDLOCK_WRITEONLY 0x00000020L + + +/* + * Indicates that a system wide lock should not be taken when this surface + * is locked. This has several advantages (cursor responsiveness, ability + * to call more Windows functions, easier debugging) when locking video + * memory surfaces. However, an application specifying this flag must + * comply with a number of conditions documented in the help file. + * Furthermore, this flag cannot be specified when locking the primary. + */ +#define DDLOCK_NOSYSLOCK 0x00000800L + +/* + * Used only with Direct3D Vertex Buffer Locks. Indicates that no vertices + * that were referred to in Draw*PrimtiveVB calls since the start of the + * frame (or the last lock without this flag) will be modified during the + * lock. This can be useful when one is only appending data to the vertex + * buffer + */ +#define DDLOCK_NOOVERWRITE 0x00001000L + +/* + * Indicates that no assumptions will be made about the contents of the + * surface or vertex buffer during this lock. + * This enables two things: + * - Direct3D or the driver may provide an alternative memory + * area as the vertex buffer. This is useful when one plans to clear the + * contents of the vertex buffer and fill in new data. + * - Drivers sometimes store surface data in a re-ordered format. + * When the application locks the surface, the driver is forced to un-re-order + * the surface data before allowing the application to see the surface contents. + * This flag is a hint to the driver that it can skip the un-re-ordering process + * since the application plans to overwrite every single pixel in the surface + * or locked rectangle (and so erase any un-re-ordered pixels anyway). + * Applications should always set this flag when they intend to overwrite the entire + * surface or locked rectangle. + */ +#define DDLOCK_DISCARDCONTENTS 0x00002000L + /* + * DDLOCK_OKTOSWAP is an older, less informative name for DDLOCK_DISCARDCONTENTS + */ +#define DDLOCK_OKTOSWAP 0x00002000L + +/* + * On IDirectDrawSurface7 and higher interfaces, the default is DDLOCK_WAIT. If you wish + * to override the default and use time when the accelerator is busy (as denoted by + * the DDERR_WASSTILLDRAWING return code) then use DDLOCK_DONOTWAIT. + */ +#define DDLOCK_DONOTWAIT 0x00004000L + +/* + * This indicates volume texture lock with front and back specified. + */ +#define DDLOCK_HASVOLUMETEXTUREBOXRECT 0x00008000L + +/* + * This indicates that the driver should not update dirty rect information for this lock. + */ +#define DDLOCK_NODIRTYUPDATE 0x00010000L + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE PAGELOCK FLAGS + * + ****************************************************************************/ + +/* + * No flags defined at present + */ + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE PAGEUNLOCK FLAGS + * + ****************************************************************************/ + +/* + * No flags defined at present + */ + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE BLT FX FLAGS + * + ****************************************************************************/ + +/* + * If stretching, use arithmetic stretching along the Y axis for this blt. + */ +#define DDBLTFX_ARITHSTRETCHY 0x00000001l + +/* + * Do this blt mirroring the surface left to right. Spin the + * surface around its y-axis. + */ +#define DDBLTFX_MIRRORLEFTRIGHT 0x00000002l + +/* + * Do this blt mirroring the surface up and down. Spin the surface + * around its x-axis. + */ +#define DDBLTFX_MIRRORUPDOWN 0x00000004l + +/* + * Schedule this blt to avoid tearing. + */ +#define DDBLTFX_NOTEARING 0x00000008l + +/* + * Do this blt rotating the surface one hundred and eighty degrees. + */ +#define DDBLTFX_ROTATE180 0x00000010l + +/* + * Do this blt rotating the surface two hundred and seventy degrees. + */ +#define DDBLTFX_ROTATE270 0x00000020l + +/* + * Do this blt rotating the surface ninety degrees. + */ +#define DDBLTFX_ROTATE90 0x00000040l + +/* + * Do this z blt using dwZBufferLow and dwZBufferHigh as range values + * specified to limit the bits copied from the source surface. + */ +#define DDBLTFX_ZBUFFERRANGE 0x00000080l + +/* + * Do this z blt adding the dwZBufferBaseDest to each of the sources z values + * before comparing it with the desting z values. + */ +#define DDBLTFX_ZBUFFERBASEDEST 0x00000100l + +/**************************************************************************** + * + * DIRECTDRAWSURFACE OVERLAY FX FLAGS + * + ****************************************************************************/ + +/* + * If stretching, use arithmetic stretching along the Y axis for this overlay. + */ +#define DDOVERFX_ARITHSTRETCHY 0x00000001l + +/* + * Mirror the overlay across the vertical axis + */ +#define DDOVERFX_MIRRORLEFTRIGHT 0x00000002l + +/* + * Mirror the overlay across the horizontal axis + */ +#define DDOVERFX_MIRRORUPDOWN 0x00000004l + +/* + * Deinterlace the overlay, if possible + */ +#define DDOVERFX_DEINTERLACE 0x00000008l + + +/**************************************************************************** + * + * DIRECTDRAW WAITFORVERTICALBLANK FLAGS + * + ****************************************************************************/ + +/* + * return when the vertical blank interval begins + */ +#define DDWAITVB_BLOCKBEGIN 0x00000001l + +/* + * set up an event to trigger when the vertical blank begins + */ +#define DDWAITVB_BLOCKBEGINEVENT 0x00000002l + +/* + * return when the vertical blank interval ends and display begins + */ +#define DDWAITVB_BLOCKEND 0x00000004l + +/**************************************************************************** + * + * DIRECTDRAW GETFLIPSTATUS FLAGS + * + ****************************************************************************/ + +/* + * is it OK to flip now? + */ +#define DDGFS_CANFLIP 0x00000001l + +/* + * is the last flip finished? + */ +#define DDGFS_ISFLIPDONE 0x00000002l + +/**************************************************************************** + * + * DIRECTDRAW GETBLTSTATUS FLAGS + * + ****************************************************************************/ + +/* + * is it OK to blt now? + */ +#define DDGBS_CANBLT 0x00000001l + +/* + * is the blt to the surface finished? + */ +#define DDGBS_ISBLTDONE 0x00000002l + + +/**************************************************************************** + * + * DIRECTDRAW ENUMOVERLAYZORDER FLAGS + * + ****************************************************************************/ + +/* + * Enumerate overlays back to front. + */ +#define DDENUMOVERLAYZ_BACKTOFRONT 0x00000000l + +/* + * Enumerate overlays front to back + */ +#define DDENUMOVERLAYZ_FRONTTOBACK 0x00000001l + +/**************************************************************************** + * + * DIRECTDRAW UPDATEOVERLAYZORDER FLAGS + * + ****************************************************************************/ + +/* + * Send overlay to front + */ +#define DDOVERZ_SENDTOFRONT 0x00000000l + +/* + * Send overlay to back + */ +#define DDOVERZ_SENDTOBACK 0x00000001l + +/* + * Move Overlay forward + */ +#define DDOVERZ_MOVEFORWARD 0x00000002l + +/* + * Move Overlay backward + */ +#define DDOVERZ_MOVEBACKWARD 0x00000003l + +/* + * Move Overlay in front of relative surface + */ +#define DDOVERZ_INSERTINFRONTOF 0x00000004l + +/* + * Move Overlay in back of relative surface + */ +#define DDOVERZ_INSERTINBACKOF 0x00000005l + + +/**************************************************************************** + * + * DIRECTDRAW SETGAMMARAMP FLAGS + * + ****************************************************************************/ + +/* + * Request calibrator to adjust the gamma ramp according to the physical + * properties of the display so that the result should appear identical + * on all systems. + */ +#define DDSGR_CALIBRATE 0x00000001L + + +/**************************************************************************** + * + * DIRECTDRAW STARTMODETEST FLAGS + * + ****************************************************************************/ + +/* + * Indicates that the mode being tested has passed + */ +#define DDSMT_ISTESTREQUIRED 0x00000001L + + +/**************************************************************************** + * + * DIRECTDRAW EVALUATEMODE FLAGS + * + ****************************************************************************/ + +/* + * Indicates that the mode being tested has passed + */ +#define DDEM_MODEPASSED 0x00000001L + +/* + * Indicates that the mode being tested has failed + */ +#define DDEM_MODEFAILED 0x00000002L + + +/*=========================================================================== + * + * + * DIRECTDRAW RETURN CODES + * + * The return values from DirectDraw Commands and Surface that return an HRESULT + * are codes from DirectDraw concerning the results of the action + * requested by DirectDraw. + * + *==========================================================================*/ + +/* + * Status is OK + * + * Issued by: DirectDraw Commands and all callbacks + */ +#define DD_OK S_OK +#define DD_FALSE S_FALSE + +/**************************************************************************** + * + * DIRECTDRAW ENUMCALLBACK RETURN VALUES + * + * EnumCallback returns are used to control the flow of the DIRECTDRAW and + * DIRECTDRAWSURFACE object enumerations. They can only be returned by + * enumeration callback routines. + * + ****************************************************************************/ + +/* + * stop the enumeration + */ +#define DDENUMRET_CANCEL 0 + +/* + * continue the enumeration + */ +#define DDENUMRET_OK 1 + +/**************************************************************************** + * + * DIRECTDRAW ERRORS + * + * Errors are represented by negative values and cannot be combined. + * + ****************************************************************************/ + +/* + * This object is already initialized + */ +#define DDERR_ALREADYINITIALIZED MAKE_DDHRESULT( 5 ) + +/* + * This surface can not be attached to the requested surface. + */ +#define DDERR_CANNOTATTACHSURFACE MAKE_DDHRESULT( 10 ) + +/* + * This surface can not be detached from the requested surface. + */ +#define DDERR_CANNOTDETACHSURFACE MAKE_DDHRESULT( 20 ) + +/* + * Support is currently not available. + */ +#define DDERR_CURRENTLYNOTAVAIL MAKE_DDHRESULT( 40 ) + +/* + * An exception was encountered while performing the requested operation + */ +#define DDERR_EXCEPTION MAKE_DDHRESULT( 55 ) + +/* + * Generic failure. + */ +#define DDERR_GENERIC E_FAIL + +/* + * Height of rectangle provided is not a multiple of reqd alignment + */ +#define DDERR_HEIGHTALIGN MAKE_DDHRESULT( 90 ) + +/* + * Unable to match primary surface creation request with existing + * primary surface. + */ +#define DDERR_INCOMPATIBLEPRIMARY MAKE_DDHRESULT( 95 ) + +/* + * One or more of the caps bits passed to the callback are incorrect. + */ +#define DDERR_INVALIDCAPS MAKE_DDHRESULT( 100 ) + +/* + * DirectDraw does not support provided Cliplist. + */ +#define DDERR_INVALIDCLIPLIST MAKE_DDHRESULT( 110 ) + +/* + * DirectDraw does not support the requested mode + */ +#define DDERR_INVALIDMODE MAKE_DDHRESULT( 120 ) + +/* + * DirectDraw received a pointer that was an invalid DIRECTDRAW object. + */ +#define DDERR_INVALIDOBJECT MAKE_DDHRESULT( 130 ) + +/* + * One or more of the parameters passed to the callback function are + * incorrect. + */ +#define DDERR_INVALIDPARAMS E_INVALIDARG + +/* + * pixel format was invalid as specified + */ +#define DDERR_INVALIDPIXELFORMAT MAKE_DDHRESULT( 145 ) + +/* + * Rectangle provided was invalid. + */ +#define DDERR_INVALIDRECT MAKE_DDHRESULT( 150 ) + +/* + * Operation could not be carried out because one or more surfaces are locked + */ +#define DDERR_LOCKEDSURFACES MAKE_DDHRESULT( 160 ) + +/* + * There is no 3D present. + */ +#define DDERR_NO3D MAKE_DDHRESULT( 170 ) + +/* + * Operation could not be carried out because there is no alpha accleration + * hardware present or available. + */ +#define DDERR_NOALPHAHW MAKE_DDHRESULT( 180 ) + +/* + * Operation could not be carried out because there is no stereo + * hardware present or available. + */ +#define DDERR_NOSTEREOHARDWARE MAKE_DDHRESULT( 181 ) + +/* + * Operation could not be carried out because there is no hardware + * present which supports stereo surfaces + */ +#define DDERR_NOSURFACELEFT MAKE_DDHRESULT( 182 ) + + + +/* + * no clip list available + */ +#define DDERR_NOCLIPLIST MAKE_DDHRESULT( 205 ) + +/* + * Operation could not be carried out because there is no color conversion + * hardware present or available. + */ +#define DDERR_NOCOLORCONVHW MAKE_DDHRESULT( 210 ) + +/* + * Create function called without DirectDraw object method SetCooperativeLevel + * being called. + */ +#define DDERR_NOCOOPERATIVELEVELSET MAKE_DDHRESULT( 212 ) + +/* + * Surface doesn't currently have a color key + */ +#define DDERR_NOCOLORKEY MAKE_DDHRESULT( 215 ) + +/* + * Operation could not be carried out because there is no hardware support + * of the dest color key. + */ +#define DDERR_NOCOLORKEYHW MAKE_DDHRESULT( 220 ) + +/* + * No DirectDraw support possible with current display driver + */ +#define DDERR_NODIRECTDRAWSUPPORT MAKE_DDHRESULT( 222 ) + +/* + * Operation requires the application to have exclusive mode but the + * application does not have exclusive mode. + */ +#define DDERR_NOEXCLUSIVEMODE MAKE_DDHRESULT( 225 ) + +/* + * Flipping visible surfaces is not supported. + */ +#define DDERR_NOFLIPHW MAKE_DDHRESULT( 230 ) + +/* + * There is no GDI present. + */ +#define DDERR_NOGDI MAKE_DDHRESULT( 240 ) + +/* + * Operation could not be carried out because there is no hardware present + * or available. + */ +#define DDERR_NOMIRRORHW MAKE_DDHRESULT( 250 ) + +/* + * Requested item was not found + */ +#define DDERR_NOTFOUND MAKE_DDHRESULT( 255 ) + +/* + * Operation could not be carried out because there is no overlay hardware + * present or available. + */ +#define DDERR_NOOVERLAYHW MAKE_DDHRESULT( 260 ) + +/* + * Operation could not be carried out because the source and destination + * rectangles are on the same surface and overlap each other. + */ +#define DDERR_OVERLAPPINGRECTS MAKE_DDHRESULT( 270 ) + +/* + * Operation could not be carried out because there is no appropriate raster + * op hardware present or available. + */ +#define DDERR_NORASTEROPHW MAKE_DDHRESULT( 280 ) + +/* + * Operation could not be carried out because there is no rotation hardware + * present or available. + */ +#define DDERR_NOROTATIONHW MAKE_DDHRESULT( 290 ) + +/* + * Operation could not be carried out because there is no hardware support + * for stretching + */ +#define DDERR_NOSTRETCHHW MAKE_DDHRESULT( 310 ) + +/* + * DirectDrawSurface is not in 4 bit color palette and the requested operation + * requires 4 bit color palette. + */ +#define DDERR_NOT4BITCOLOR MAKE_DDHRESULT( 316 ) + +/* + * DirectDrawSurface is not in 4 bit color index palette and the requested + * operation requires 4 bit color index palette. + */ +#define DDERR_NOT4BITCOLORINDEX MAKE_DDHRESULT( 317 ) + +/* + * DirectDraw Surface is not in 8 bit color mode and the requested operation + * requires 8 bit color. + */ +#define DDERR_NOT8BITCOLOR MAKE_DDHRESULT( 320 ) + +/* + * Operation could not be carried out because there is no texture mapping + * hardware present or available. + */ +#define DDERR_NOTEXTUREHW MAKE_DDHRESULT( 330 ) + +/* + * Operation could not be carried out because there is no hardware support + * for vertical blank synchronized operations. + */ +#define DDERR_NOVSYNCHW MAKE_DDHRESULT( 335 ) + +/* + * Operation could not be carried out because there is no hardware support + * for zbuffer blting. + */ +#define DDERR_NOZBUFFERHW MAKE_DDHRESULT( 340 ) + +/* + * Overlay surfaces could not be z layered based on their BltOrder because + * the hardware does not support z layering of overlays. + */ +#define DDERR_NOZOVERLAYHW MAKE_DDHRESULT( 350 ) + +/* + * The hardware needed for the requested operation has already been + * allocated. + */ +#define DDERR_OUTOFCAPS MAKE_DDHRESULT( 360 ) + +/* + * DirectDraw does not have enough memory to perform the operation. + */ +#define DDERR_OUTOFMEMORY E_OUTOFMEMORY + +/* + * DirectDraw does not have enough memory to perform the operation. + */ +#define DDERR_OUTOFVIDEOMEMORY MAKE_DDHRESULT( 380 ) + +/* + * hardware does not support clipped overlays + */ +#define DDERR_OVERLAYCANTCLIP MAKE_DDHRESULT( 382 ) + +/* + * Can only have ony color key active at one time for overlays + */ +#define DDERR_OVERLAYCOLORKEYONLYONEACTIVE MAKE_DDHRESULT( 384 ) + +/* + * Access to this palette is being refused because the palette is already + * locked by another thread. + */ +#define DDERR_PALETTEBUSY MAKE_DDHRESULT( 387 ) + +/* + * No src color key specified for this operation. + */ +#define DDERR_COLORKEYNOTSET MAKE_DDHRESULT( 400 ) + +/* + * This surface is already attached to the surface it is being attached to. + */ +#define DDERR_SURFACEALREADYATTACHED MAKE_DDHRESULT( 410 ) + +/* + * This surface is already a dependency of the surface it is being made a + * dependency of. + */ +#define DDERR_SURFACEALREADYDEPENDENT MAKE_DDHRESULT( 420 ) + +/* + * Access to this surface is being refused because the surface is already + * locked by another thread. + */ +#define DDERR_SURFACEBUSY MAKE_DDHRESULT( 430 ) + +/* + * Access to this surface is being refused because no driver exists + * which can supply a pointer to the surface. + * This is most likely to happen when attempting to lock the primary + * surface when no DCI provider is present. + * Will also happen on attempts to lock an optimized surface. + */ +#define DDERR_CANTLOCKSURFACE MAKE_DDHRESULT( 435 ) + +/* + * Access to Surface refused because Surface is obscured. + */ +#define DDERR_SURFACEISOBSCURED MAKE_DDHRESULT( 440 ) + +/* + * Access to this surface is being refused because the surface is gone. + * The DIRECTDRAWSURFACE object representing this surface should + * have Restore called on it. + */ +#define DDERR_SURFACELOST MAKE_DDHRESULT( 450 ) + +/* + * The requested surface is not attached. + */ +#define DDERR_SURFACENOTATTACHED MAKE_DDHRESULT( 460 ) + +/* + * Height requested by DirectDraw is too large. + */ +#define DDERR_TOOBIGHEIGHT MAKE_DDHRESULT( 470 ) + +/* + * Size requested by DirectDraw is too large -- The individual height and + * width are OK. + */ +#define DDERR_TOOBIGSIZE MAKE_DDHRESULT( 480 ) + +/* + * Width requested by DirectDraw is too large. + */ +#define DDERR_TOOBIGWIDTH MAKE_DDHRESULT( 490 ) + +/* + * Action not supported. + */ +#define DDERR_UNSUPPORTED E_NOTIMPL + +/* + * Pixel format requested is unsupported by DirectDraw + */ +#define DDERR_UNSUPPORTEDFORMAT MAKE_DDHRESULT( 510 ) + +/* + * Bitmask in the pixel format requested is unsupported by DirectDraw + */ +#define DDERR_UNSUPPORTEDMASK MAKE_DDHRESULT( 520 ) + +/* + * The specified stream contains invalid data + */ +#define DDERR_INVALIDSTREAM MAKE_DDHRESULT( 521 ) + +/* + * vertical blank is in progress + */ +#define DDERR_VERTICALBLANKINPROGRESS MAKE_DDHRESULT( 537 ) + +/* + * Informs DirectDraw that the previous Blt which is transfering information + * to or from this Surface is incomplete. + */ +#define DDERR_WASSTILLDRAWING MAKE_DDHRESULT( 540 ) + + +/* + * The specified surface type requires specification of the COMPLEX flag + */ +#define DDERR_DDSCAPSCOMPLEXREQUIRED MAKE_DDHRESULT( 542 ) + + +/* + * Rectangle provided was not horizontally aligned on reqd. boundary + */ +#define DDERR_XALIGN MAKE_DDHRESULT( 560 ) + +/* + * The GUID passed to DirectDrawCreate is not a valid DirectDraw driver + * identifier. + */ +#define DDERR_INVALIDDIRECTDRAWGUID MAKE_DDHRESULT( 561 ) + +/* + * A DirectDraw object representing this driver has already been created + * for this process. + */ +#define DDERR_DIRECTDRAWALREADYCREATED MAKE_DDHRESULT( 562 ) + +/* + * A hardware only DirectDraw object creation was attempted but the driver + * did not support any hardware. + */ +#define DDERR_NODIRECTDRAWHW MAKE_DDHRESULT( 563 ) + +/* + * this process already has created a primary surface + */ +#define DDERR_PRIMARYSURFACEALREADYEXISTS MAKE_DDHRESULT( 564 ) + +/* + * software emulation not available. + */ +#define DDERR_NOEMULATION MAKE_DDHRESULT( 565 ) + +/* + * region passed to Clipper::GetClipList is too small. + */ +#define DDERR_REGIONTOOSMALL MAKE_DDHRESULT( 566 ) + +/* + * an attempt was made to set a clip list for a clipper objec that + * is already monitoring an hwnd. + */ +#define DDERR_CLIPPERISUSINGHWND MAKE_DDHRESULT( 567 ) + +/* + * No clipper object attached to surface object + */ +#define DDERR_NOCLIPPERATTACHED MAKE_DDHRESULT( 568 ) + +/* + * Clipper notification requires an HWND or + * no HWND has previously been set as the CooperativeLevel HWND. + */ +#define DDERR_NOHWND MAKE_DDHRESULT( 569 ) + +/* + * HWND used by DirectDraw CooperativeLevel has been subclassed, + * this prevents DirectDraw from restoring state. + */ +#define DDERR_HWNDSUBCLASSED MAKE_DDHRESULT( 570 ) + +/* + * The CooperativeLevel HWND has already been set. + * It can not be reset while the process has surfaces or palettes created. + */ +#define DDERR_HWNDALREADYSET MAKE_DDHRESULT( 571 ) + +/* + * No palette object attached to this surface. + */ +#define DDERR_NOPALETTEATTACHED MAKE_DDHRESULT( 572 ) + +/* + * No hardware support for 16 or 256 color palettes. + */ +#define DDERR_NOPALETTEHW MAKE_DDHRESULT( 573 ) + +/* + * If a clipper object is attached to the source surface passed into a + * BltFast call. + */ +#define DDERR_BLTFASTCANTCLIP MAKE_DDHRESULT( 574 ) + +/* + * No blter. + */ +#define DDERR_NOBLTHW MAKE_DDHRESULT( 575 ) + +/* + * No DirectDraw ROP hardware. + */ +#define DDERR_NODDROPSHW MAKE_DDHRESULT( 576 ) + +/* + * returned when GetOverlayPosition is called on a hidden overlay + */ +#define DDERR_OVERLAYNOTVISIBLE MAKE_DDHRESULT( 577 ) + +/* + * returned when GetOverlayPosition is called on a overlay that UpdateOverlay + * has never been called on to establish a destionation. + */ +#define DDERR_NOOVERLAYDEST MAKE_DDHRESULT( 578 ) + +/* + * returned when the position of the overlay on the destionation is no longer + * legal for that destionation. + */ +#define DDERR_INVALIDPOSITION MAKE_DDHRESULT( 579 ) + +/* + * returned when an overlay member is called for a non-overlay surface + */ +#define DDERR_NOTAOVERLAYSURFACE MAKE_DDHRESULT( 580 ) + +/* + * An attempt was made to set the cooperative level when it was already + * set to exclusive. + */ +#define DDERR_EXCLUSIVEMODEALREADYSET MAKE_DDHRESULT( 581 ) + +/* + * An attempt has been made to flip a surface that is not flippable. + */ +#define DDERR_NOTFLIPPABLE MAKE_DDHRESULT( 582 ) + +/* + * Can't duplicate primary & 3D surfaces, or surfaces that are implicitly + * created. + */ +#define DDERR_CANTDUPLICATE MAKE_DDHRESULT( 583 ) + +/* + * Surface was not locked. An attempt to unlock a surface that was not + * locked at all, or by this process, has been attempted. + */ +#define DDERR_NOTLOCKED MAKE_DDHRESULT( 584 ) + +/* + * Windows can not create any more DCs, or a DC was requested for a paltte-indexed + * surface when the surface had no palette AND the display mode was not palette-indexed + * (in this case DirectDraw cannot select a proper palette into the DC) + */ +#define DDERR_CANTCREATEDC MAKE_DDHRESULT( 585 ) + +/* + * No DC was ever created for this surface. + */ +#define DDERR_NODC MAKE_DDHRESULT( 586 ) + +/* + * This surface can not be restored because it was created in a different + * mode. + */ +#define DDERR_WRONGMODE MAKE_DDHRESULT( 587 ) + +/* + * This surface can not be restored because it is an implicitly created + * surface. + */ +#define DDERR_IMPLICITLYCREATED MAKE_DDHRESULT( 588 ) + +/* + * The surface being used is not a palette-based surface + */ +#define DDERR_NOTPALETTIZED MAKE_DDHRESULT( 589 ) + + +/* + * The display is currently in an unsupported mode + */ +#define DDERR_UNSUPPORTEDMODE MAKE_DDHRESULT( 590 ) + +/* + * Operation could not be carried out because there is no mip-map + * texture mapping hardware present or available. + */ +#define DDERR_NOMIPMAPHW MAKE_DDHRESULT( 591 ) + +/* + * The requested action could not be performed because the surface was of + * the wrong type. + */ +#define DDERR_INVALIDSURFACETYPE MAKE_DDHRESULT( 592 ) + + +/* + * Device does not support optimized surfaces, therefore no video memory optimized surfaces + */ +#define DDERR_NOOPTIMIZEHW MAKE_DDHRESULT( 600 ) + +/* + * Surface is an optimized surface, but has not yet been allocated any memory + */ +#define DDERR_NOTLOADED MAKE_DDHRESULT( 601 ) + +/* + * Attempt was made to create or set a device window without first setting + * the focus window + */ +#define DDERR_NOFOCUSWINDOW MAKE_DDHRESULT( 602 ) + +/* + * Attempt was made to set a palette on a mipmap sublevel + */ +#define DDERR_NOTONMIPMAPSUBLEVEL MAKE_DDHRESULT( 603 ) + +/* + * A DC has already been returned for this surface. Only one DC can be + * retrieved per surface. + */ +#define DDERR_DCALREADYCREATED MAKE_DDHRESULT( 620 ) + +/* + * An attempt was made to allocate non-local video memory from a device + * that does not support non-local video memory. + */ +#define DDERR_NONONLOCALVIDMEM MAKE_DDHRESULT( 630 ) + +/* + * The attempt to page lock a surface failed. + */ +#define DDERR_CANTPAGELOCK MAKE_DDHRESULT( 640 ) + + +/* + * The attempt to page unlock a surface failed. + */ +#define DDERR_CANTPAGEUNLOCK MAKE_DDHRESULT( 660 ) + +/* + * An attempt was made to page unlock a surface with no outstanding page locks. + */ +#define DDERR_NOTPAGELOCKED MAKE_DDHRESULT( 680 ) + +/* + * There is more data available than the specified buffer size could hold + */ +#define DDERR_MOREDATA MAKE_DDHRESULT( 690 ) + +/* + * The data has expired and is therefore no longer valid. + */ +#define DDERR_EXPIRED MAKE_DDHRESULT( 691 ) + +/* + * The mode test has finished executing. + */ +#define DDERR_TESTFINISHED MAKE_DDHRESULT( 692 ) + +/* + * The mode test has switched to a new mode. + */ +#define DDERR_NEWMODE MAKE_DDHRESULT( 693 ) + +/* + * D3D has not yet been initialized. + */ +#define DDERR_D3DNOTINITIALIZED MAKE_DDHRESULT( 694 ) + +/* + * The video port is not active + */ +#define DDERR_VIDEONOTACTIVE MAKE_DDHRESULT( 695 ) + +/* + * The monitor does not have EDID data. + */ +#define DDERR_NOMONITORINFORMATION MAKE_DDHRESULT( 696 ) + +/* + * The driver does not enumerate display mode refresh rates. + */ +#define DDERR_NODRIVERSUPPORT MAKE_DDHRESULT( 697 ) + +/* + * Surfaces created by one direct draw device cannot be used directly by + * another direct draw device. + */ +#define DDERR_DEVICEDOESNTOWNSURFACE MAKE_DDHRESULT( 699 ) + + + +/* + * An attempt was made to invoke an interface member of a DirectDraw object + * created by CoCreateInstance() before it was initialized. + */ +#define DDERR_NOTINITIALIZED CO_E_NOTINITIALIZED + + +/* Alpha bit depth constants */ + + +#ifdef __cplusplus +}; +#endif + +#ifdef ENABLE_NAMELESS_UNION_PRAGMA +#pragma warning(default:4201) +#endif + +#endif //__DDRAW_INCLUDED__ + + diff --git a/src/dep/include/DXSDK/include/dinput.h b/src/dep/include/DXSDK/include/dinput.h index bf74e16..5aac256 100644 --- a/src/dep/include/DXSDK/include/dinput.h +++ b/src/dep/include/DXSDK/include/dinput.h @@ -1,4417 +1,4417 @@ -/**************************************************************************** - * - * Copyright (C) 1996-2000 Microsoft Corporation. All Rights Reserved. - * - * File: dinput.h - * Content: DirectInput include file - * - ****************************************************************************/ - -#ifndef __DINPUT_INCLUDED__ -#define __DINPUT_INCLUDED__ - -#ifndef DIJ_RINGZERO - -#ifdef _WIN32 -#define COM_NO_WINDOWS_H -#include -#endif - -#endif /* DIJ_RINGZERO */ - -#ifdef __cplusplus -extern "C" { -#endif - - - - - -/* - * To build applications for older versions of DirectInput - * - * #define DIRECTINPUT_VERSION [ 0x0300 | 0x0500 | 0x0700 ] - * - * before #include . By default, #include - * will produce a DirectX 8-compatible header file. - * - */ - -#define DIRECTINPUT_HEADER_VERSION 0x0800 -#ifndef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION DIRECTINPUT_HEADER_VERSION -#pragma message(__FILE__ ": DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800") -#endif - -#ifndef DIJ_RINGZERO - -/**************************************************************************** - * - * Class IDs - * - ****************************************************************************/ - -DEFINE_GUID(CLSID_DirectInput, 0x25E609E0,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(CLSID_DirectInputDevice, 0x25E609E1,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -DEFINE_GUID(CLSID_DirectInput8, 0x25E609E4,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(CLSID_DirectInputDevice8,0x25E609E5,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -/**************************************************************************** - * - * Interfaces - * - ****************************************************************************/ - -DEFINE_GUID(IID_IDirectInputA, 0x89521360,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputW, 0x89521361,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInput2A, 0x5944E662,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInput2W, 0x5944E663,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInput7A, 0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInput7W, 0x9A4CB685,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInput8A, 0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00); -DEFINE_GUID(IID_IDirectInput8W, 0xBF798031,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00); -DEFINE_GUID(IID_IDirectInputDeviceA, 0x5944E680,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDeviceW, 0x5944E681,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDevice2A,0x5944E682,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDevice2W,0x5944E683,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDevice7A,0x57D7C6BC,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInputDevice7W,0x57D7C6BD,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInputDevice8A,0x54D41080,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79); -DEFINE_GUID(IID_IDirectInputDevice8W,0x54D41081,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79); -DEFINE_GUID(IID_IDirectInputEffect, 0xE7E1F7C0,0x88D2,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); - -/**************************************************************************** - * - * Predefined object types - * - ****************************************************************************/ - -DEFINE_GUID(GUID_XAxis, 0xA36D02E0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_YAxis, 0xA36D02E1,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_ZAxis, 0xA36D02E2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_RxAxis, 0xA36D02F4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_RyAxis, 0xA36D02F5,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_RzAxis, 0xA36D02E3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Slider, 0xA36D02E4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -DEFINE_GUID(GUID_Button, 0xA36D02F0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Key, 0x55728220,0xD33C,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -DEFINE_GUID(GUID_POV, 0xA36D02F2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -DEFINE_GUID(GUID_Unknown, 0xA36D02F3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -/**************************************************************************** - * - * Predefined product GUIDs - * - ****************************************************************************/ - -DEFINE_GUID(GUID_SysMouse, 0x6F1D2B60,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysKeyboard,0x6F1D2B61,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Joystick ,0x6F1D2B70,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysMouseEm, 0x6F1D2B80,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysMouseEm2,0x6F1D2B81,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysKeyboardEm, 0x6F1D2B82,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysKeyboardEm2,0x6F1D2B83,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -/**************************************************************************** - * - * Predefined force feedback effects - * - ****************************************************************************/ - -DEFINE_GUID(GUID_ConstantForce, 0x13541C20,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_RampForce, 0x13541C21,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Square, 0x13541C22,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Sine, 0x13541C23,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Triangle, 0x13541C24,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_SawtoothUp, 0x13541C25,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_SawtoothDown, 0x13541C26,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Spring, 0x13541C27,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Damper, 0x13541C28,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Inertia, 0x13541C29,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Friction, 0x13541C2A,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_CustomForce, 0x13541C2B,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); - -#endif /* DIJ_RINGZERO */ - -/**************************************************************************** - * - * Interfaces and Structures... - * - ****************************************************************************/ - -#if(DIRECTINPUT_VERSION >= 0x0500) - -/**************************************************************************** - * - * IDirectInputEffect - * - ****************************************************************************/ - -#define DIEFT_ALL 0x00000000 - -#define DIEFT_CONSTANTFORCE 0x00000001 -#define DIEFT_RAMPFORCE 0x00000002 -#define DIEFT_PERIODIC 0x00000003 -#define DIEFT_CONDITION 0x00000004 -#define DIEFT_CUSTOMFORCE 0x00000005 -#define DIEFT_HARDWARE 0x000000FF -#define DIEFT_FFATTACK 0x00000200 -#define DIEFT_FFFADE 0x00000400 -#define DIEFT_SATURATION 0x00000800 -#define DIEFT_POSNEGCOEFFICIENTS 0x00001000 -#define DIEFT_POSNEGSATURATION 0x00002000 -#define DIEFT_DEADBAND 0x00004000 -#define DIEFT_STARTDELAY 0x00008000 -#define DIEFT_GETTYPE(n) LOBYTE(n) - -#define DI_DEGREES 100 -#define DI_FFNOMINALMAX 10000 -#define DI_SECONDS 1000000 - -typedef struct DICONSTANTFORCE { - LONG lMagnitude; -} DICONSTANTFORCE, *LPDICONSTANTFORCE; -typedef const DICONSTANTFORCE *LPCDICONSTANTFORCE; - -typedef struct DIRAMPFORCE { - LONG lStart; - LONG lEnd; -} DIRAMPFORCE, *LPDIRAMPFORCE; -typedef const DIRAMPFORCE *LPCDIRAMPFORCE; - -typedef struct DIPERIODIC { - DWORD dwMagnitude; - LONG lOffset; - DWORD dwPhase; - DWORD dwPeriod; -} DIPERIODIC, *LPDIPERIODIC; -typedef const DIPERIODIC *LPCDIPERIODIC; - -typedef struct DICONDITION { - LONG lOffset; - LONG lPositiveCoefficient; - LONG lNegativeCoefficient; - DWORD dwPositiveSaturation; - DWORD dwNegativeSaturation; - LONG lDeadBand; -} DICONDITION, *LPDICONDITION; -typedef const DICONDITION *LPCDICONDITION; - -typedef struct DICUSTOMFORCE { - DWORD cChannels; - DWORD dwSamplePeriod; - DWORD cSamples; - LPLONG rglForceData; -} DICUSTOMFORCE, *LPDICUSTOMFORCE; -typedef const DICUSTOMFORCE *LPCDICUSTOMFORCE; - - -typedef struct DIENVELOPE { - DWORD dwSize; /* sizeof(DIENVELOPE) */ - DWORD dwAttackLevel; - DWORD dwAttackTime; /* Microseconds */ - DWORD dwFadeLevel; - DWORD dwFadeTime; /* Microseconds */ -} DIENVELOPE, *LPDIENVELOPE; -typedef const DIENVELOPE *LPCDIENVELOPE; - - -/* This structure is defined for DirectX 5.0 compatibility */ -typedef struct DIEFFECT_DX5 { - DWORD dwSize; /* sizeof(DIEFFECT_DX5) */ - DWORD dwFlags; /* DIEFF_* */ - DWORD dwDuration; /* Microseconds */ - DWORD dwSamplePeriod; /* Microseconds */ - DWORD dwGain; - DWORD dwTriggerButton; /* or DIEB_NOTRIGGER */ - DWORD dwTriggerRepeatInterval; /* Microseconds */ - DWORD cAxes; /* Number of axes */ - LPDWORD rgdwAxes; /* Array of axes */ - LPLONG rglDirection; /* Array of directions */ - LPDIENVELOPE lpEnvelope; /* Optional */ - DWORD cbTypeSpecificParams; /* Size of params */ - LPVOID lpvTypeSpecificParams; /* Pointer to params */ -} DIEFFECT_DX5, *LPDIEFFECT_DX5; -typedef const DIEFFECT_DX5 *LPCDIEFFECT_DX5; - -typedef struct DIEFFECT { - DWORD dwSize; /* sizeof(DIEFFECT) */ - DWORD dwFlags; /* DIEFF_* */ - DWORD dwDuration; /* Microseconds */ - DWORD dwSamplePeriod; /* Microseconds */ - DWORD dwGain; - DWORD dwTriggerButton; /* or DIEB_NOTRIGGER */ - DWORD dwTriggerRepeatInterval; /* Microseconds */ - DWORD cAxes; /* Number of axes */ - LPDWORD rgdwAxes; /* Array of axes */ - LPLONG rglDirection; /* Array of directions */ - LPDIENVELOPE lpEnvelope; /* Optional */ - DWORD cbTypeSpecificParams; /* Size of params */ - LPVOID lpvTypeSpecificParams; /* Pointer to params */ -#if(DIRECTINPUT_VERSION >= 0x0600) - DWORD dwStartDelay; /* Microseconds */ -#endif /* DIRECTINPUT_VERSION >= 0x0600 */ -} DIEFFECT, *LPDIEFFECT; -typedef DIEFFECT DIEFFECT_DX6; -typedef LPDIEFFECT LPDIEFFECT_DX6; -typedef const DIEFFECT *LPCDIEFFECT; - - -#if(DIRECTINPUT_VERSION >= 0x0700) -#ifndef DIJ_RINGZERO -typedef struct DIFILEEFFECT{ - DWORD dwSize; - GUID GuidEffect; - LPCDIEFFECT lpDiEffect; - CHAR szFriendlyName[MAX_PATH]; -}DIFILEEFFECT, *LPDIFILEEFFECT; -typedef const DIFILEEFFECT *LPCDIFILEEFFECT; -typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSINFILECALLBACK)(LPCDIFILEEFFECT , LPVOID); -#endif /* DIJ_RINGZERO */ -#endif /* DIRECTINPUT_VERSION >= 0x0700 */ - -#define DIEFF_OBJECTIDS 0x00000001 -#define DIEFF_OBJECTOFFSETS 0x00000002 -#define DIEFF_CARTESIAN 0x00000010 -#define DIEFF_POLAR 0x00000020 -#define DIEFF_SPHERICAL 0x00000040 - -#define DIEP_DURATION 0x00000001 -#define DIEP_SAMPLEPERIOD 0x00000002 -#define DIEP_GAIN 0x00000004 -#define DIEP_TRIGGERBUTTON 0x00000008 -#define DIEP_TRIGGERREPEATINTERVAL 0x00000010 -#define DIEP_AXES 0x00000020 -#define DIEP_DIRECTION 0x00000040 -#define DIEP_ENVELOPE 0x00000080 -#define DIEP_TYPESPECIFICPARAMS 0x00000100 -#if(DIRECTINPUT_VERSION >= 0x0600) -#define DIEP_STARTDELAY 0x00000200 -#define DIEP_ALLPARAMS_DX5 0x000001FF -#define DIEP_ALLPARAMS 0x000003FF -#else /* DIRECTINPUT_VERSION < 0x0600 */ -#define DIEP_ALLPARAMS 0x000001FF -#endif /* DIRECTINPUT_VERSION < 0x0600 */ -#define DIEP_START 0x20000000 -#define DIEP_NORESTART 0x40000000 -#define DIEP_NODOWNLOAD 0x80000000 -#define DIEB_NOTRIGGER 0xFFFFFFFF - -#define DIES_SOLO 0x00000001 -#define DIES_NODOWNLOAD 0x80000000 - -#define DIEGES_PLAYING 0x00000001 -#define DIEGES_EMULATED 0x00000002 - -typedef struct DIEFFESCAPE { - DWORD dwSize; - DWORD dwCommand; - LPVOID lpvInBuffer; - DWORD cbInBuffer; - LPVOID lpvOutBuffer; - DWORD cbOutBuffer; -} DIEFFESCAPE, *LPDIEFFESCAPE; - -#ifndef DIJ_RINGZERO - -#undef INTERFACE -#define INTERFACE IDirectInputEffect - -DECLARE_INTERFACE_(IDirectInputEffect, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputEffect methods ***/ - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; - STDMETHOD(GetEffectGuid)(THIS_ LPGUID) PURE; - STDMETHOD(GetParameters)(THIS_ LPDIEFFECT,DWORD) PURE; - STDMETHOD(SetParameters)(THIS_ LPCDIEFFECT,DWORD) PURE; - STDMETHOD(Start)(THIS_ DWORD,DWORD) PURE; - STDMETHOD(Stop)(THIS) PURE; - STDMETHOD(GetEffectStatus)(THIS_ LPDWORD) PURE; - STDMETHOD(Download)(THIS) PURE; - STDMETHOD(Unload)(THIS) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; -}; - -typedef struct IDirectInputEffect *LPDIRECTINPUTEFFECT; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInputEffect_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputEffect_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputEffect_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInputEffect_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectInputEffect_GetEffectGuid(p,a) (p)->lpVtbl->GetEffectGuid(p,a) -#define IDirectInputEffect_GetParameters(p,a,b) (p)->lpVtbl->GetParameters(p,a,b) -#define IDirectInputEffect_SetParameters(p,a,b) (p)->lpVtbl->SetParameters(p,a,b) -#define IDirectInputEffect_Start(p,a,b) (p)->lpVtbl->Start(p,a,b) -#define IDirectInputEffect_Stop(p) (p)->lpVtbl->Stop(p) -#define IDirectInputEffect_GetEffectStatus(p,a) (p)->lpVtbl->GetEffectStatus(p,a) -#define IDirectInputEffect_Download(p) (p)->lpVtbl->Download(p) -#define IDirectInputEffect_Unload(p) (p)->lpVtbl->Unload(p) -#define IDirectInputEffect_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#else -#define IDirectInputEffect_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputEffect_AddRef(p) (p)->AddRef() -#define IDirectInputEffect_Release(p) (p)->Release() -#define IDirectInputEffect_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectInputEffect_GetEffectGuid(p,a) (p)->GetEffectGuid(a) -#define IDirectInputEffect_GetParameters(p,a,b) (p)->GetParameters(a,b) -#define IDirectInputEffect_SetParameters(p,a,b) (p)->SetParameters(a,b) -#define IDirectInputEffect_Start(p,a,b) (p)->Start(a,b) -#define IDirectInputEffect_Stop(p) (p)->Stop() -#define IDirectInputEffect_GetEffectStatus(p,a) (p)->GetEffectStatus(a) -#define IDirectInputEffect_Download(p) (p)->Download() -#define IDirectInputEffect_Unload(p) (p)->Unload() -#define IDirectInputEffect_Escape(p,a) (p)->Escape(a) -#endif - -#endif /* DIJ_RINGZERO */ - -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - -/**************************************************************************** - * - * IDirectInputDevice - * - ****************************************************************************/ - -#if DIRECTINPUT_VERSION <= 0x700 -#define DIDEVTYPE_DEVICE 1 -#define DIDEVTYPE_MOUSE 2 -#define DIDEVTYPE_KEYBOARD 3 -#define DIDEVTYPE_JOYSTICK 4 - -#else -#define DI8DEVCLASS_ALL 0 -#define DI8DEVCLASS_DEVICE 1 -#define DI8DEVCLASS_POINTER 2 -#define DI8DEVCLASS_KEYBOARD 3 -#define DI8DEVCLASS_GAMECTRL 4 - -#define DI8DEVTYPE_DEVICE 0x11 -#define DI8DEVTYPE_MOUSE 0x12 -#define DI8DEVTYPE_KEYBOARD 0x13 -#define DI8DEVTYPE_JOYSTICK 0x14 -#define DI8DEVTYPE_GAMEPAD 0x15 -#define DI8DEVTYPE_DRIVING 0x16 -#define DI8DEVTYPE_FLIGHT 0x17 -#define DI8DEVTYPE_1STPERSON 0x18 -#define DI8DEVTYPE_DEVICECTRL 0x19 -#define DI8DEVTYPE_SCREENPOINTER 0x1A -#define DI8DEVTYPE_REMOTE 0x1B -#define DI8DEVTYPE_SUPPLEMENTAL 0x1C -#endif /* DIRECTINPUT_VERSION <= 0x700 */ - -#define DIDEVTYPE_HID 0x00010000 - -#if DIRECTINPUT_VERSION <= 0x700 -#define DIDEVTYPEMOUSE_UNKNOWN 1 -#define DIDEVTYPEMOUSE_TRADITIONAL 2 -#define DIDEVTYPEMOUSE_FINGERSTICK 3 -#define DIDEVTYPEMOUSE_TOUCHPAD 4 -#define DIDEVTYPEMOUSE_TRACKBALL 5 - -#define DIDEVTYPEKEYBOARD_UNKNOWN 0 -#define DIDEVTYPEKEYBOARD_PCXT 1 -#define DIDEVTYPEKEYBOARD_OLIVETTI 2 -#define DIDEVTYPEKEYBOARD_PCAT 3 -#define DIDEVTYPEKEYBOARD_PCENH 4 -#define DIDEVTYPEKEYBOARD_NOKIA1050 5 -#define DIDEVTYPEKEYBOARD_NOKIA9140 6 -#define DIDEVTYPEKEYBOARD_NEC98 7 -#define DIDEVTYPEKEYBOARD_NEC98LAPTOP 8 -#define DIDEVTYPEKEYBOARD_NEC98106 9 -#define DIDEVTYPEKEYBOARD_JAPAN106 10 -#define DIDEVTYPEKEYBOARD_JAPANAX 11 -#define DIDEVTYPEKEYBOARD_J3100 12 - -#define DIDEVTYPEJOYSTICK_UNKNOWN 1 -#define DIDEVTYPEJOYSTICK_TRADITIONAL 2 -#define DIDEVTYPEJOYSTICK_FLIGHTSTICK 3 -#define DIDEVTYPEJOYSTICK_GAMEPAD 4 -#define DIDEVTYPEJOYSTICK_RUDDER 5 -#define DIDEVTYPEJOYSTICK_WHEEL 6 -#define DIDEVTYPEJOYSTICK_HEADTRACKER 7 - -#else -#define DI8DEVTYPEMOUSE_UNKNOWN 1 -#define DI8DEVTYPEMOUSE_TRADITIONAL 2 -#define DI8DEVTYPEMOUSE_FINGERSTICK 3 -#define DI8DEVTYPEMOUSE_TOUCHPAD 4 -#define DI8DEVTYPEMOUSE_TRACKBALL 5 -#define DI8DEVTYPEMOUSE_ABSOLUTE 6 - -#define DI8DEVTYPEKEYBOARD_UNKNOWN 0 -#define DI8DEVTYPEKEYBOARD_PCXT 1 -#define DI8DEVTYPEKEYBOARD_OLIVETTI 2 -#define DI8DEVTYPEKEYBOARD_PCAT 3 -#define DI8DEVTYPEKEYBOARD_PCENH 4 -#define DI8DEVTYPEKEYBOARD_NOKIA1050 5 -#define DI8DEVTYPEKEYBOARD_NOKIA9140 6 -#define DI8DEVTYPEKEYBOARD_NEC98 7 -#define DI8DEVTYPEKEYBOARD_NEC98LAPTOP 8 -#define DI8DEVTYPEKEYBOARD_NEC98106 9 -#define DI8DEVTYPEKEYBOARD_JAPAN106 10 -#define DI8DEVTYPEKEYBOARD_JAPANAX 11 -#define DI8DEVTYPEKEYBOARD_J3100 12 - -#define DI8DEVTYPE_LIMITEDGAMESUBTYPE 1 - -#define DI8DEVTYPEJOYSTICK_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEJOYSTICK_STANDARD 2 - -#define DI8DEVTYPEGAMEPAD_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEGAMEPAD_STANDARD 2 -#define DI8DEVTYPEGAMEPAD_TILT 3 - -#define DI8DEVTYPEDRIVING_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEDRIVING_COMBINEDPEDALS 2 -#define DI8DEVTYPEDRIVING_DUALPEDALS 3 -#define DI8DEVTYPEDRIVING_THREEPEDALS 4 -#define DI8DEVTYPEDRIVING_HANDHELD 5 - -#define DI8DEVTYPEFLIGHT_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEFLIGHT_STICK 2 -#define DI8DEVTYPEFLIGHT_YOKE 3 -#define DI8DEVTYPEFLIGHT_RC 4 - -#define DI8DEVTYPE1STPERSON_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPE1STPERSON_UNKNOWN 2 -#define DI8DEVTYPE1STPERSON_SIXDOF 3 -#define DI8DEVTYPE1STPERSON_SHOOTER 4 - -#define DI8DEVTYPESCREENPTR_UNKNOWN 2 -#define DI8DEVTYPESCREENPTR_LIGHTGUN 3 -#define DI8DEVTYPESCREENPTR_LIGHTPEN 4 -#define DI8DEVTYPESCREENPTR_TOUCH 5 - -#define DI8DEVTYPEREMOTE_UNKNOWN 2 - -#define DI8DEVTYPEDEVICECTRL_UNKNOWN 2 -#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION 3 -#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION_HARDWIRED 4 - -#define DI8DEVTYPESUPPLEMENTAL_UNKNOWN 2 -#define DI8DEVTYPESUPPLEMENTAL_2NDHANDCONTROLLER 3 -#define DI8DEVTYPESUPPLEMENTAL_HEADTRACKER 4 -#define DI8DEVTYPESUPPLEMENTAL_HANDTRACKER 5 -#define DI8DEVTYPESUPPLEMENTAL_SHIFTSTICKGATE 6 -#define DI8DEVTYPESUPPLEMENTAL_SHIFTER 7 -#define DI8DEVTYPESUPPLEMENTAL_THROTTLE 8 -#define DI8DEVTYPESUPPLEMENTAL_SPLITTHROTTLE 9 -#define DI8DEVTYPESUPPLEMENTAL_COMBINEDPEDALS 10 -#define DI8DEVTYPESUPPLEMENTAL_DUALPEDALS 11 -#define DI8DEVTYPESUPPLEMENTAL_THREEPEDALS 12 -#define DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS 13 -#endif /* DIRECTINPUT_VERSION <= 0x700 */ - -#define GET_DIDEVICE_TYPE(dwDevType) LOBYTE(dwDevType) -#define GET_DIDEVICE_SUBTYPE(dwDevType) HIBYTE(dwDevType) - -#if(DIRECTINPUT_VERSION >= 0x0500) -/* This structure is defined for DirectX 3.0 compatibility */ -typedef struct DIDEVCAPS_DX3 { - DWORD dwSize; - DWORD dwFlags; - DWORD dwDevType; - DWORD dwAxes; - DWORD dwButtons; - DWORD dwPOVs; -} DIDEVCAPS_DX3, *LPDIDEVCAPS_DX3; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - -typedef struct DIDEVCAPS { - DWORD dwSize; - DWORD dwFlags; - DWORD dwDevType; - DWORD dwAxes; - DWORD dwButtons; - DWORD dwPOVs; -#if(DIRECTINPUT_VERSION >= 0x0500) - DWORD dwFFSamplePeriod; - DWORD dwFFMinTimeResolution; - DWORD dwFirmwareRevision; - DWORD dwHardwareRevision; - DWORD dwFFDriverVersion; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVCAPS, *LPDIDEVCAPS; - -#define DIDC_ATTACHED 0x00000001 -#define DIDC_POLLEDDEVICE 0x00000002 -#define DIDC_EMULATED 0x00000004 -#define DIDC_POLLEDDATAFORMAT 0x00000008 -#if(DIRECTINPUT_VERSION >= 0x0500) -#define DIDC_FORCEFEEDBACK 0x00000100 -#define DIDC_FFATTACK 0x00000200 -#define DIDC_FFFADE 0x00000400 -#define DIDC_SATURATION 0x00000800 -#define DIDC_POSNEGCOEFFICIENTS 0x00001000 -#define DIDC_POSNEGSATURATION 0x00002000 -#define DIDC_DEADBAND 0x00004000 -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -#define DIDC_STARTDELAY 0x00008000 -#if(DIRECTINPUT_VERSION >= 0x050a) -#define DIDC_ALIAS 0x00010000 -#define DIDC_PHANTOM 0x00020000 -#endif /* DIRECTINPUT_VERSION >= 0x050a */ -#if(DIRECTINPUT_VERSION >= 0x0800) -#define DIDC_HIDDEN 0x00040000 -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -#define DIDFT_ALL 0x00000000 - -#define DIDFT_RELAXIS 0x00000001 -#define DIDFT_ABSAXIS 0x00000002 -#define DIDFT_AXIS 0x00000003 - -#define DIDFT_PSHBUTTON 0x00000004 -#define DIDFT_TGLBUTTON 0x00000008 -#define DIDFT_BUTTON 0x0000000C - -#define DIDFT_POV 0x00000010 -#define DIDFT_COLLECTION 0x00000040 -#define DIDFT_NODATA 0x00000080 - -#define DIDFT_ANYINSTANCE 0x00FFFF00 -#define DIDFT_INSTANCEMASK DIDFT_ANYINSTANCE -#define DIDFT_MAKEINSTANCE(n) ((WORD)(n) << 8) -#define DIDFT_GETTYPE(n) LOBYTE(n) -#define DIDFT_GETINSTANCE(n) LOWORD((n) >> 8) -#define DIDFT_FFACTUATOR 0x01000000 -#define DIDFT_FFEFFECTTRIGGER 0x02000000 -#if(DIRECTINPUT_VERSION >= 0x050a) -#define DIDFT_OUTPUT 0x10000000 -#define DIDFT_VENDORDEFINED 0x04000000 -#define DIDFT_ALIAS 0x08000000 -#endif /* DIRECTINPUT_VERSION >= 0x050a */ -#ifndef DIDFT_OPTIONAL -#define DIDFT_OPTIONAL 0x80000000 -#endif - -#define DIDFT_ENUMCOLLECTION(n) ((WORD)(n) << 8) -#define DIDFT_NOCOLLECTION 0x00FFFF00 - -#ifndef DIJ_RINGZERO - -typedef struct _DIOBJECTDATAFORMAT { - const GUID *pguid; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; -} DIOBJECTDATAFORMAT, *LPDIOBJECTDATAFORMAT; -typedef const DIOBJECTDATAFORMAT *LPCDIOBJECTDATAFORMAT; - -typedef struct _DIDATAFORMAT { - DWORD dwSize; - DWORD dwObjSize; - DWORD dwFlags; - DWORD dwDataSize; - DWORD dwNumObjs; - LPDIOBJECTDATAFORMAT rgodf; -} DIDATAFORMAT, *LPDIDATAFORMAT; -typedef const DIDATAFORMAT *LPCDIDATAFORMAT; - -#define DIDF_ABSAXIS 0x00000001 -#define DIDF_RELAXIS 0x00000002 - -#ifdef __cplusplus -extern "C" { -#endif -extern const DIDATAFORMAT c_dfDIMouse; - -#if(DIRECTINPUT_VERSION >= 0x0700) -extern const DIDATAFORMAT c_dfDIMouse2; -#endif /* DIRECTINPUT_VERSION >= 0x0700 */ - -extern const DIDATAFORMAT c_dfDIKeyboard; - -#if(DIRECTINPUT_VERSION >= 0x0500) -extern const DIDATAFORMAT c_dfDIJoystick; -extern const DIDATAFORMAT c_dfDIJoystick2; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - -#ifdef __cplusplus -}; -#endif - - -#if DIRECTINPUT_VERSION > 0x0700 - -typedef struct _DIACTIONA { - UINT_PTR uAppData; - DWORD dwSemantic; - OPTIONAL DWORD dwFlags; - OPTIONAL union { - LPCSTR lptszActionName; - UINT uResIdString; - }; - OPTIONAL GUID guidInstance; - OPTIONAL DWORD dwObjID; - OPTIONAL DWORD dwHow; -} DIACTIONA, *LPDIACTIONA ; -typedef struct _DIACTIONW { - UINT_PTR uAppData; - DWORD dwSemantic; - OPTIONAL DWORD dwFlags; - OPTIONAL union { - LPCWSTR lptszActionName; - UINT uResIdString; - }; - OPTIONAL GUID guidInstance; - OPTIONAL DWORD dwObjID; - OPTIONAL DWORD dwHow; -} DIACTIONW, *LPDIACTIONW ; -#ifdef UNICODE -typedef DIACTIONW DIACTION; -typedef LPDIACTIONW LPDIACTION; -#else -typedef DIACTIONA DIACTION; -typedef LPDIACTIONA LPDIACTION; -#endif // UNICODE - -typedef const DIACTIONA *LPCDIACTIONA; -typedef const DIACTIONW *LPCDIACTIONW; -#ifdef UNICODE -typedef DIACTIONW DIACTION; -typedef LPCDIACTIONW LPCDIACTION; -#else -typedef DIACTIONA DIACTION; -typedef LPCDIACTIONA LPCDIACTION; -#endif // UNICODE -typedef const DIACTION *LPCDIACTION; - - -#define DIA_FORCEFEEDBACK 0x00000001 -#define DIA_APPMAPPED 0x00000002 -#define DIA_APPNOMAP 0x00000004 -#define DIA_NORANGE 0x00000008 -#define DIA_APPFIXED 0x00000010 - -#define DIAH_UNMAPPED 0x00000000 -#define DIAH_USERCONFIG 0x00000001 -#define DIAH_APPREQUESTED 0x00000002 -#define DIAH_HWAPP 0x00000004 -#define DIAH_HWDEFAULT 0x00000008 -#define DIAH_DEFAULT 0x00000020 -#define DIAH_ERROR 0x80000000 - -typedef struct _DIACTIONFORMATA { - DWORD dwSize; - DWORD dwActionSize; - DWORD dwDataSize; - DWORD dwNumActions; - LPDIACTIONA rgoAction; - GUID guidActionMap; - DWORD dwGenre; - DWORD dwBufferSize; - OPTIONAL LONG lAxisMin; - OPTIONAL LONG lAxisMax; - OPTIONAL HINSTANCE hInstString; - FILETIME ftTimeStamp; - DWORD dwCRC; - CHAR tszActionMap[MAX_PATH]; -} DIACTIONFORMATA, *LPDIACTIONFORMATA; -typedef struct _DIACTIONFORMATW { - DWORD dwSize; - DWORD dwActionSize; - DWORD dwDataSize; - DWORD dwNumActions; - LPDIACTIONW rgoAction; - GUID guidActionMap; - DWORD dwGenre; - DWORD dwBufferSize; - OPTIONAL LONG lAxisMin; - OPTIONAL LONG lAxisMax; - OPTIONAL HINSTANCE hInstString; - FILETIME ftTimeStamp; - DWORD dwCRC; - WCHAR tszActionMap[MAX_PATH]; -} DIACTIONFORMATW, *LPDIACTIONFORMATW; -#ifdef UNICODE -typedef DIACTIONFORMATW DIACTIONFORMAT; -typedef LPDIACTIONFORMATW LPDIACTIONFORMAT; -#else -typedef DIACTIONFORMATA DIACTIONFORMAT; -typedef LPDIACTIONFORMATA LPDIACTIONFORMAT; -#endif // UNICODE -typedef const DIACTIONFORMATA *LPCDIACTIONFORMATA; -typedef const DIACTIONFORMATW *LPCDIACTIONFORMATW; -#ifdef UNICODE -typedef DIACTIONFORMATW DIACTIONFORMAT; -typedef LPCDIACTIONFORMATW LPCDIACTIONFORMAT; -#else -typedef DIACTIONFORMATA DIACTIONFORMAT; -typedef LPCDIACTIONFORMATA LPCDIACTIONFORMAT; -#endif // UNICODE -typedef const DIACTIONFORMAT *LPCDIACTIONFORMAT; - -#define DIAFTS_NEWDEVICELOW 0xFFFFFFFF -#define DIAFTS_NEWDEVICEHIGH 0xFFFFFFFF -#define DIAFTS_UNUSEDDEVICELOW 0x00000000 -#define DIAFTS_UNUSEDDEVICEHIGH 0x00000000 - -#define DIDBAM_DEFAULT 0x00000000 -#define DIDBAM_PRESERVE 0x00000001 -#define DIDBAM_INITIALIZE 0x00000002 -#define DIDBAM_HWDEFAULTS 0x00000004 - -#define DIDSAM_DEFAULT 0x00000000 -#define DIDSAM_NOUSER 0x00000001 -#define DIDSAM_FORCESAVE 0x00000002 - -#define DICD_DEFAULT 0x00000000 -#define DICD_EDIT 0x00000001 - -/* - * The following definition is normally defined in d3dtypes.h - */ -#ifndef D3DCOLOR_DEFINED -typedef DWORD D3DCOLOR; -#define D3DCOLOR_DEFINED -#endif - -typedef struct _DICOLORSET{ - DWORD dwSize; - D3DCOLOR cTextFore; - D3DCOLOR cTextHighlight; - D3DCOLOR cCalloutLine; - D3DCOLOR cCalloutHighlight; - D3DCOLOR cBorder; - D3DCOLOR cControlFill; - D3DCOLOR cHighlightFill; - D3DCOLOR cAreaFill; -} DICOLORSET, *LPDICOLORSET; -typedef const DICOLORSET *LPCDICOLORSET; - - -typedef struct _DICONFIGUREDEVICESPARAMSA{ - DWORD dwSize; - DWORD dwcUsers; - LPSTR lptszUserNames; - DWORD dwcFormats; - LPDIACTIONFORMATA lprgFormats; - HWND hwnd; - DICOLORSET dics; - IUnknown FAR * lpUnkDDSTarget; -} DICONFIGUREDEVICESPARAMSA, *LPDICONFIGUREDEVICESPARAMSA; -typedef struct _DICONFIGUREDEVICESPARAMSW{ - DWORD dwSize; - DWORD dwcUsers; - LPWSTR lptszUserNames; - DWORD dwcFormats; - LPDIACTIONFORMATW lprgFormats; - HWND hwnd; - DICOLORSET dics; - IUnknown FAR * lpUnkDDSTarget; -} DICONFIGUREDEVICESPARAMSW, *LPDICONFIGUREDEVICESPARAMSW; -#ifdef UNICODE -typedef DICONFIGUREDEVICESPARAMSW DICONFIGUREDEVICESPARAMS; -typedef LPDICONFIGUREDEVICESPARAMSW LPDICONFIGUREDEVICESPARAMS; -#else -typedef DICONFIGUREDEVICESPARAMSA DICONFIGUREDEVICESPARAMS; -typedef LPDICONFIGUREDEVICESPARAMSA LPDICONFIGUREDEVICESPARAMS; -#endif // UNICODE -typedef const DICONFIGUREDEVICESPARAMSA *LPCDICONFIGUREDEVICESPARAMSA; -typedef const DICONFIGUREDEVICESPARAMSW *LPCDICONFIGUREDEVICESPARAMSW; -#ifdef UNICODE -typedef DICONFIGUREDEVICESPARAMSW DICONFIGUREDEVICESPARAMS; -typedef LPCDICONFIGUREDEVICESPARAMSW LPCDICONFIGUREDEVICESPARAMS; -#else -typedef DICONFIGUREDEVICESPARAMSA DICONFIGUREDEVICESPARAMS; -typedef LPCDICONFIGUREDEVICESPARAMSA LPCDICONFIGUREDEVICESPARAMS; -#endif // UNICODE -typedef const DICONFIGUREDEVICESPARAMS *LPCDICONFIGUREDEVICESPARAMS; - - -#define DIDIFT_CONFIGURATION 0x00000001 -#define DIDIFT_OVERLAY 0x00000002 - -#define DIDAL_CENTERED 0x00000000 -#define DIDAL_LEFTALIGNED 0x00000001 -#define DIDAL_RIGHTALIGNED 0x00000002 -#define DIDAL_MIDDLE 0x00000000 -#define DIDAL_TOPALIGNED 0x00000004 -#define DIDAL_BOTTOMALIGNED 0x00000008 - -typedef struct _DIDEVICEIMAGEINFOA { - CHAR tszImagePath[MAX_PATH]; - DWORD dwFlags; - // These are valid if DIDIFT_OVERLAY is present in dwFlags. - DWORD dwViewID; - RECT rcOverlay; - DWORD dwObjID; - DWORD dwcValidPts; - POINT rgptCalloutLine[5]; - RECT rcCalloutRect; - DWORD dwTextAlign; -} DIDEVICEIMAGEINFOA, *LPDIDEVICEIMAGEINFOA; -typedef struct _DIDEVICEIMAGEINFOW { - WCHAR tszImagePath[MAX_PATH]; - DWORD dwFlags; - // These are valid if DIDIFT_OVERLAY is present in dwFlags. - DWORD dwViewID; - RECT rcOverlay; - DWORD dwObjID; - DWORD dwcValidPts; - POINT rgptCalloutLine[5]; - RECT rcCalloutRect; - DWORD dwTextAlign; -} DIDEVICEIMAGEINFOW, *LPDIDEVICEIMAGEINFOW; -#ifdef UNICODE -typedef DIDEVICEIMAGEINFOW DIDEVICEIMAGEINFO; -typedef LPDIDEVICEIMAGEINFOW LPDIDEVICEIMAGEINFO; -#else -typedef DIDEVICEIMAGEINFOA DIDEVICEIMAGEINFO; -typedef LPDIDEVICEIMAGEINFOA LPDIDEVICEIMAGEINFO; -#endif // UNICODE -typedef const DIDEVICEIMAGEINFOA *LPCDIDEVICEIMAGEINFOA; -typedef const DIDEVICEIMAGEINFOW *LPCDIDEVICEIMAGEINFOW; -#ifdef UNICODE -typedef DIDEVICEIMAGEINFOW DIDEVICEIMAGEINFO; -typedef LPCDIDEVICEIMAGEINFOW LPCDIDEVICEIMAGEINFO; -#else -typedef DIDEVICEIMAGEINFOA DIDEVICEIMAGEINFO; -typedef LPCDIDEVICEIMAGEINFOA LPCDIDEVICEIMAGEINFO; -#endif // UNICODE -typedef const DIDEVICEIMAGEINFO *LPCDIDEVICEIMAGEINFO; - -typedef struct _DIDEVICEIMAGEINFOHEADERA { - DWORD dwSize; - DWORD dwSizeImageInfo; - DWORD dwcViews; - DWORD dwcButtons; - DWORD dwcAxes; - DWORD dwcPOVs; - DWORD dwBufferSize; - DWORD dwBufferUsed; - LPDIDEVICEIMAGEINFOA lprgImageInfoArray; -} DIDEVICEIMAGEINFOHEADERA, *LPDIDEVICEIMAGEINFOHEADERA; -typedef struct _DIDEVICEIMAGEINFOHEADERW { - DWORD dwSize; - DWORD dwSizeImageInfo; - DWORD dwcViews; - DWORD dwcButtons; - DWORD dwcAxes; - DWORD dwcPOVs; - DWORD dwBufferSize; - DWORD dwBufferUsed; - LPDIDEVICEIMAGEINFOW lprgImageInfoArray; -} DIDEVICEIMAGEINFOHEADERW, *LPDIDEVICEIMAGEINFOHEADERW; -#ifdef UNICODE -typedef DIDEVICEIMAGEINFOHEADERW DIDEVICEIMAGEINFOHEADER; -typedef LPDIDEVICEIMAGEINFOHEADERW LPDIDEVICEIMAGEINFOHEADER; -#else -typedef DIDEVICEIMAGEINFOHEADERA DIDEVICEIMAGEINFOHEADER; -typedef LPDIDEVICEIMAGEINFOHEADERA LPDIDEVICEIMAGEINFOHEADER; -#endif // UNICODE -typedef const DIDEVICEIMAGEINFOHEADERA *LPCDIDEVICEIMAGEINFOHEADERA; -typedef const DIDEVICEIMAGEINFOHEADERW *LPCDIDEVICEIMAGEINFOHEADERW; -#ifdef UNICODE -typedef DIDEVICEIMAGEINFOHEADERW DIDEVICEIMAGEINFOHEADER; -typedef LPCDIDEVICEIMAGEINFOHEADERW LPCDIDEVICEIMAGEINFOHEADER; -#else -typedef DIDEVICEIMAGEINFOHEADERA DIDEVICEIMAGEINFOHEADER; -typedef LPCDIDEVICEIMAGEINFOHEADERA LPCDIDEVICEIMAGEINFOHEADER; -#endif // UNICODE -typedef const DIDEVICEIMAGEINFOHEADER *LPCDIDEVICEIMAGEINFOHEADER; - -#endif /* DIRECTINPUT_VERSION > 0x0700 */ - -#if(DIRECTINPUT_VERSION >= 0x0500) -/* These structures are defined for DirectX 3.0 compatibility */ - -typedef struct DIDEVICEOBJECTINSTANCE_DX3A { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - CHAR tszName[MAX_PATH]; -} DIDEVICEOBJECTINSTANCE_DX3A, *LPDIDEVICEOBJECTINSTANCE_DX3A; -typedef struct DIDEVICEOBJECTINSTANCE_DX3W { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - WCHAR tszName[MAX_PATH]; -} DIDEVICEOBJECTINSTANCE_DX3W, *LPDIDEVICEOBJECTINSTANCE_DX3W; -#ifdef UNICODE -typedef DIDEVICEOBJECTINSTANCE_DX3W DIDEVICEOBJECTINSTANCE_DX3; -typedef LPDIDEVICEOBJECTINSTANCE_DX3W LPDIDEVICEOBJECTINSTANCE_DX3; -#else -typedef DIDEVICEOBJECTINSTANCE_DX3A DIDEVICEOBJECTINSTANCE_DX3; -typedef LPDIDEVICEOBJECTINSTANCE_DX3A LPDIDEVICEOBJECTINSTANCE_DX3; -#endif // UNICODE -typedef const DIDEVICEOBJECTINSTANCE_DX3A *LPCDIDEVICEOBJECTINSTANCE_DX3A; -typedef const DIDEVICEOBJECTINSTANCE_DX3W *LPCDIDEVICEOBJECTINSTANCE_DX3W; -typedef const DIDEVICEOBJECTINSTANCE_DX3 *LPCDIDEVICEOBJECTINSTANCE_DX3; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - -typedef struct DIDEVICEOBJECTINSTANCEA { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - CHAR tszName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - DWORD dwFFMaxForce; - DWORD dwFFForceResolution; - WORD wCollectionNumber; - WORD wDesignatorIndex; - WORD wUsagePage; - WORD wUsage; - DWORD dwDimension; - WORD wExponent; - WORD wReportId; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEOBJECTINSTANCEA, *LPDIDEVICEOBJECTINSTANCEA; -typedef struct DIDEVICEOBJECTINSTANCEW { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - WCHAR tszName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - DWORD dwFFMaxForce; - DWORD dwFFForceResolution; - WORD wCollectionNumber; - WORD wDesignatorIndex; - WORD wUsagePage; - WORD wUsage; - DWORD dwDimension; - WORD wExponent; - WORD wReportId; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEOBJECTINSTANCEW, *LPDIDEVICEOBJECTINSTANCEW; -#ifdef UNICODE -typedef DIDEVICEOBJECTINSTANCEW DIDEVICEOBJECTINSTANCE; -typedef LPDIDEVICEOBJECTINSTANCEW LPDIDEVICEOBJECTINSTANCE; -#else -typedef DIDEVICEOBJECTINSTANCEA DIDEVICEOBJECTINSTANCE; -typedef LPDIDEVICEOBJECTINSTANCEA LPDIDEVICEOBJECTINSTANCE; -#endif // UNICODE -typedef const DIDEVICEOBJECTINSTANCEA *LPCDIDEVICEOBJECTINSTANCEA; -typedef const DIDEVICEOBJECTINSTANCEW *LPCDIDEVICEOBJECTINSTANCEW; -typedef const DIDEVICEOBJECTINSTANCE *LPCDIDEVICEOBJECTINSTANCE; - -typedef BOOL (FAR PASCAL * LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA, LPVOID); -typedef BOOL (FAR PASCAL * LPDIENUMDEVICEOBJECTSCALLBACKW)(LPCDIDEVICEOBJECTINSTANCEW, LPVOID); -#ifdef UNICODE -#define LPDIENUMDEVICEOBJECTSCALLBACK LPDIENUMDEVICEOBJECTSCALLBACKW -#else -#define LPDIENUMDEVICEOBJECTSCALLBACK LPDIENUMDEVICEOBJECTSCALLBACKA -#endif // !UNICODE - -#if(DIRECTINPUT_VERSION >= 0x0500) -#define DIDOI_FFACTUATOR 0x00000001 -#define DIDOI_FFEFFECTTRIGGER 0x00000002 -#define DIDOI_POLLED 0x00008000 -#define DIDOI_ASPECTPOSITION 0x00000100 -#define DIDOI_ASPECTVELOCITY 0x00000200 -#define DIDOI_ASPECTACCEL 0x00000300 -#define DIDOI_ASPECTFORCE 0x00000400 -#define DIDOI_ASPECTMASK 0x00000F00 -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -#if(DIRECTINPUT_VERSION >= 0x050a) -#define DIDOI_GUIDISUSAGE 0x00010000 -#endif /* DIRECTINPUT_VERSION >= 0x050a */ - -typedef struct DIPROPHEADER { - DWORD dwSize; - DWORD dwHeaderSize; - DWORD dwObj; - DWORD dwHow; -} DIPROPHEADER, *LPDIPROPHEADER; -typedef const DIPROPHEADER *LPCDIPROPHEADER; - -#define DIPH_DEVICE 0 -#define DIPH_BYOFFSET 1 -#define DIPH_BYID 2 -#if(DIRECTINPUT_VERSION >= 0x050a) -#define DIPH_BYUSAGE 3 -#endif /* DIRECTINPUT_VERSION >= 0x050a */ - -#if(DIRECTINPUT_VERSION >= 0x050a) -#define DIMAKEUSAGEDWORD(UsagePage, Usage) \ - (DWORD)MAKELONG(Usage, UsagePage) -#endif /* DIRECTINPUT_VERSION >= 0x050a */ - -typedef struct DIPROPDWORD { - DIPROPHEADER diph; - DWORD dwData; -} DIPROPDWORD, *LPDIPROPDWORD; -typedef const DIPROPDWORD *LPCDIPROPDWORD; - -#if(DIRECTINPUT_VERSION >= 0x0800) -typedef struct DIPROPPOINTER { - DIPROPHEADER diph; - UINT_PTR uData; -} DIPROPPOINTER, *LPDIPROPPOINTER; -typedef const DIPROPPOINTER *LPCDIPROPPOINTER; -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -typedef struct DIPROPRANGE { - DIPROPHEADER diph; - LONG lMin; - LONG lMax; -} DIPROPRANGE, *LPDIPROPRANGE; -typedef const DIPROPRANGE *LPCDIPROPRANGE; - -#define DIPROPRANGE_NOMIN ((LONG)0x80000000) -#define DIPROPRANGE_NOMAX ((LONG)0x7FFFFFFF) - -#if(DIRECTINPUT_VERSION >= 0x050a) -typedef struct DIPROPCAL { - DIPROPHEADER diph; - LONG lMin; - LONG lCenter; - LONG lMax; -} DIPROPCAL, *LPDIPROPCAL; -typedef const DIPROPCAL *LPCDIPROPCAL; - -typedef struct DIPROPCALPOV { - DIPROPHEADER diph; - LONG lMin[5]; - LONG lMax[5]; -} DIPROPCALPOV, *LPDIPROPCALPOV; -typedef const DIPROPCALPOV *LPCDIPROPCALPOV; - -typedef struct DIPROPGUIDANDPATH { - DIPROPHEADER diph; - GUID guidClass; - WCHAR wszPath[MAX_PATH]; -} DIPROPGUIDANDPATH, *LPDIPROPGUIDANDPATH; -typedef const DIPROPGUIDANDPATH *LPCDIPROPGUIDANDPATH; - -typedef struct DIPROPSTRING { - DIPROPHEADER diph; - WCHAR wsz[MAX_PATH]; -} DIPROPSTRING, *LPDIPROPSTRING; -typedef const DIPROPSTRING *LPCDIPROPSTRING; - -#endif /* DIRECTINPUT_VERSION >= 0x050a */ - -#if(DIRECTINPUT_VERSION >= 0x0800) -#define MAXCPOINTSNUM 8 - -typedef struct _CPOINT -{ - LONG lP; // raw value - DWORD dwLog; // logical_value / max_logical_value * 10000 -} CPOINT, *PCPOINT; - -typedef struct DIPROPCPOINTS { - DIPROPHEADER diph; - DWORD dwCPointsNum; - CPOINT cp[MAXCPOINTSNUM]; -} DIPROPCPOINTS, *LPDIPROPCPOINTS; -typedef const DIPROPCPOINTS *LPCDIPROPCPOINTS; -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - - -#ifdef __cplusplus -#define MAKEDIPROP(prop) (*(const GUID *)(prop)) -#else -#define MAKEDIPROP(prop) ((REFGUID)(prop)) -#endif - -#define DIPROP_BUFFERSIZE MAKEDIPROP(1) - -#define DIPROP_AXISMODE MAKEDIPROP(2) - -#define DIPROPAXISMODE_ABS 0 -#define DIPROPAXISMODE_REL 1 - -#define DIPROP_GRANULARITY MAKEDIPROP(3) - -#define DIPROP_RANGE MAKEDIPROP(4) - -#define DIPROP_DEADZONE MAKEDIPROP(5) - -#define DIPROP_SATURATION MAKEDIPROP(6) - -#define DIPROP_FFGAIN MAKEDIPROP(7) - -#define DIPROP_FFLOAD MAKEDIPROP(8) - -#define DIPROP_AUTOCENTER MAKEDIPROP(9) - -#define DIPROPAUTOCENTER_OFF 0 -#define DIPROPAUTOCENTER_ON 1 - -#define DIPROP_CALIBRATIONMODE MAKEDIPROP(10) - -#define DIPROPCALIBRATIONMODE_COOKED 0 -#define DIPROPCALIBRATIONMODE_RAW 1 - -#if(DIRECTINPUT_VERSION >= 0x050a) -#define DIPROP_CALIBRATION MAKEDIPROP(11) - -#define DIPROP_GUIDANDPATH MAKEDIPROP(12) - -#define DIPROP_INSTANCENAME MAKEDIPROP(13) - -#define DIPROP_PRODUCTNAME MAKEDIPROP(14) -#endif /* DIRECTINPUT_VERSION >= 0x050a */ - -#if(DIRECTINPUT_VERSION >= 0x05b2) -#define DIPROP_JOYSTICKID MAKEDIPROP(15) - -#define DIPROP_GETPORTDISPLAYNAME MAKEDIPROP(16) - -#endif /* DIRECTINPUT_VERSION >= 0x05b2 */ - -#if(DIRECTINPUT_VERSION >= 0x0700) -#define DIPROP_PHYSICALRANGE MAKEDIPROP(18) - -#define DIPROP_LOGICALRANGE MAKEDIPROP(19) -#endif /* DIRECTINPUT_VERSION >= 0x0700 */ - -#if(DIRECTINPUT_VERSION >= 0x0800) -#define DIPROP_KEYNAME MAKEDIPROP(20) - -#define DIPROP_CPOINTS MAKEDIPROP(21) - -#define DIPROP_APPDATA MAKEDIPROP(22) - -#define DIPROP_SCANCODE MAKEDIPROP(23) - -#define DIPROP_VIDPID MAKEDIPROP(24) - -#define DIPROP_USERNAME MAKEDIPROP(25) - -#define DIPROP_TYPENAME MAKEDIPROP(26) -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - - -typedef struct DIDEVICEOBJECTDATA_DX3 { - DWORD dwOfs; - DWORD dwData; - DWORD dwTimeStamp; - DWORD dwSequence; -} DIDEVICEOBJECTDATA_DX3, *LPDIDEVICEOBJECTDATA_DX3; -typedef const DIDEVICEOBJECTDATA_DX3 *LPCDIDEVICEOBJECTDATA_DX; - -typedef struct DIDEVICEOBJECTDATA { - DWORD dwOfs; - DWORD dwData; - DWORD dwTimeStamp; - DWORD dwSequence; -#if(DIRECTINPUT_VERSION >= 0x0800) - UINT_PTR uAppData; -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ -} DIDEVICEOBJECTDATA, *LPDIDEVICEOBJECTDATA; -typedef const DIDEVICEOBJECTDATA *LPCDIDEVICEOBJECTDATA; - -#define DIGDD_PEEK 0x00000001 - -#define DISEQUENCE_COMPARE(dwSequence1, cmp, dwSequence2) \ - ((int)((dwSequence1) - (dwSequence2)) cmp 0) -#define DISCL_EXCLUSIVE 0x00000001 -#define DISCL_NONEXCLUSIVE 0x00000002 -#define DISCL_FOREGROUND 0x00000004 -#define DISCL_BACKGROUND 0x00000008 -#define DISCL_NOWINKEY 0x00000010 - -#if(DIRECTINPUT_VERSION >= 0x0500) -/* These structures are defined for DirectX 3.0 compatibility */ - -typedef struct DIDEVICEINSTANCE_DX3A { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - CHAR tszInstanceName[MAX_PATH]; - CHAR tszProductName[MAX_PATH]; -} DIDEVICEINSTANCE_DX3A, *LPDIDEVICEINSTANCE_DX3A; -typedef struct DIDEVICEINSTANCE_DX3W { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - WCHAR tszInstanceName[MAX_PATH]; - WCHAR tszProductName[MAX_PATH]; -} DIDEVICEINSTANCE_DX3W, *LPDIDEVICEINSTANCE_DX3W; -#ifdef UNICODE -typedef DIDEVICEINSTANCE_DX3W DIDEVICEINSTANCE_DX3; -typedef LPDIDEVICEINSTANCE_DX3W LPDIDEVICEINSTANCE_DX3; -#else -typedef DIDEVICEINSTANCE_DX3A DIDEVICEINSTANCE_DX3; -typedef LPDIDEVICEINSTANCE_DX3A LPDIDEVICEINSTANCE_DX3; -#endif // UNICODE -typedef const DIDEVICEINSTANCE_DX3A *LPCDIDEVICEINSTANCE_DX3A; -typedef const DIDEVICEINSTANCE_DX3W *LPCDIDEVICEINSTANCE_DX3W; -typedef const DIDEVICEINSTANCE_DX3 *LPCDIDEVICEINSTANCE_DX3; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - -typedef struct DIDEVICEINSTANCEA { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - CHAR tszInstanceName[MAX_PATH]; - CHAR tszProductName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - GUID guidFFDriver; - WORD wUsagePage; - WORD wUsage; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEINSTANCEA, *LPDIDEVICEINSTANCEA; -typedef struct DIDEVICEINSTANCEW { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - WCHAR tszInstanceName[MAX_PATH]; - WCHAR tszProductName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - GUID guidFFDriver; - WORD wUsagePage; - WORD wUsage; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEINSTANCEW, *LPDIDEVICEINSTANCEW; -#ifdef UNICODE -typedef DIDEVICEINSTANCEW DIDEVICEINSTANCE; -typedef LPDIDEVICEINSTANCEW LPDIDEVICEINSTANCE; -#else -typedef DIDEVICEINSTANCEA DIDEVICEINSTANCE; -typedef LPDIDEVICEINSTANCEA LPDIDEVICEINSTANCE; -#endif // UNICODE - -typedef const DIDEVICEINSTANCEA *LPCDIDEVICEINSTANCEA; -typedef const DIDEVICEINSTANCEW *LPCDIDEVICEINSTANCEW; -#ifdef UNICODE -typedef DIDEVICEINSTANCEW DIDEVICEINSTANCE; -typedef LPCDIDEVICEINSTANCEW LPCDIDEVICEINSTANCE; -#else -typedef DIDEVICEINSTANCEA DIDEVICEINSTANCE; -typedef LPCDIDEVICEINSTANCEA LPCDIDEVICEINSTANCE; -#endif // UNICODE -typedef const DIDEVICEINSTANCE *LPCDIDEVICEINSTANCE; - -#undef INTERFACE -#define INTERFACE IDirectInputDeviceW - -DECLARE_INTERFACE_(IDirectInputDeviceW, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDeviceW methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; -}; - -typedef struct IDirectInputDeviceW *LPDIRECTINPUTDEVICEW; - -#undef INTERFACE -#define INTERFACE IDirectInputDeviceA - -DECLARE_INTERFACE_(IDirectInputDeviceA, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDeviceA methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; -}; - -typedef struct IDirectInputDeviceA *LPDIRECTINPUTDEVICEA; - -#ifdef UNICODE -#define IID_IDirectInputDevice IID_IDirectInputDeviceW -#define IDirectInputDevice IDirectInputDeviceW -#define IDirectInputDeviceVtbl IDirectInputDeviceWVtbl -#else -#define IID_IDirectInputDevice IID_IDirectInputDeviceA -#define IDirectInputDevice IDirectInputDeviceA -#define IDirectInputDeviceVtbl IDirectInputDeviceAVtbl -#endif -typedef struct IDirectInputDevice *LPDIRECTINPUTDEVICE; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInputDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInputDevice_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#else -#define IDirectInputDevice_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice_AddRef(p) (p)->AddRef() -#define IDirectInputDevice_Release(p) (p)->Release() -#define IDirectInputDevice_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice_Acquire(p) (p)->Acquire() -#define IDirectInputDevice_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#endif - -#endif /* DIJ_RINGZERO */ - - -#if(DIRECTINPUT_VERSION >= 0x0500) - -#define DISFFC_RESET 0x00000001 -#define DISFFC_STOPALL 0x00000002 -#define DISFFC_PAUSE 0x00000004 -#define DISFFC_CONTINUE 0x00000008 -#define DISFFC_SETACTUATORSON 0x00000010 -#define DISFFC_SETACTUATORSOFF 0x00000020 - -#define DIGFFS_EMPTY 0x00000001 -#define DIGFFS_STOPPED 0x00000002 -#define DIGFFS_PAUSED 0x00000004 -#define DIGFFS_ACTUATORSON 0x00000010 -#define DIGFFS_ACTUATORSOFF 0x00000020 -#define DIGFFS_POWERON 0x00000040 -#define DIGFFS_POWEROFF 0x00000080 -#define DIGFFS_SAFETYSWITCHON 0x00000100 -#define DIGFFS_SAFETYSWITCHOFF 0x00000200 -#define DIGFFS_USERFFSWITCHON 0x00000400 -#define DIGFFS_USERFFSWITCHOFF 0x00000800 -#define DIGFFS_DEVICELOST 0x80000000 - -#ifndef DIJ_RINGZERO - -typedef struct DIEFFECTINFOA { - DWORD dwSize; - GUID guid; - DWORD dwEffType; - DWORD dwStaticParams; - DWORD dwDynamicParams; - CHAR tszName[MAX_PATH]; -} DIEFFECTINFOA, *LPDIEFFECTINFOA; -typedef struct DIEFFECTINFOW { - DWORD dwSize; - GUID guid; - DWORD dwEffType; - DWORD dwStaticParams; - DWORD dwDynamicParams; - WCHAR tszName[MAX_PATH]; -} DIEFFECTINFOW, *LPDIEFFECTINFOW; -#ifdef UNICODE -typedef DIEFFECTINFOW DIEFFECTINFO; -typedef LPDIEFFECTINFOW LPDIEFFECTINFO; -#else -typedef DIEFFECTINFOA DIEFFECTINFO; -typedef LPDIEFFECTINFOA LPDIEFFECTINFO; -#endif // UNICODE -typedef const DIEFFECTINFOA *LPCDIEFFECTINFOA; -typedef const DIEFFECTINFOW *LPCDIEFFECTINFOW; -typedef const DIEFFECTINFO *LPCDIEFFECTINFO; - -#define DISDD_CONTINUE 0x00000001 - -typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSCALLBACKA)(LPCDIEFFECTINFOA, LPVOID); -typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSCALLBACKW)(LPCDIEFFECTINFOW, LPVOID); -#ifdef UNICODE -#define LPDIENUMEFFECTSCALLBACK LPDIENUMEFFECTSCALLBACKW -#else -#define LPDIENUMEFFECTSCALLBACK LPDIENUMEFFECTSCALLBACKA -#endif // !UNICODE -typedef BOOL (FAR PASCAL * LPDIENUMCREATEDEFFECTOBJECTSCALLBACK)(LPDIRECTINPUTEFFECT, LPVOID); - -#undef INTERFACE -#define INTERFACE IDirectInputDevice2W - -DECLARE_INTERFACE_(IDirectInputDevice2W, IDirectInputDeviceW) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDeviceW methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; - - /*** IDirectInputDevice2W methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; -}; - -typedef struct IDirectInputDevice2W *LPDIRECTINPUTDEVICE2W; - -#undef INTERFACE -#define INTERFACE IDirectInputDevice2A - -DECLARE_INTERFACE_(IDirectInputDevice2A, IDirectInputDeviceA) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDeviceA methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; - - /*** IDirectInputDevice2A methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; -}; - -typedef struct IDirectInputDevice2A *LPDIRECTINPUTDEVICE2A; - -#ifdef UNICODE -#define IID_IDirectInputDevice2 IID_IDirectInputDevice2W -#define IDirectInputDevice2 IDirectInputDevice2W -#define IDirectInputDevice2Vtbl IDirectInputDevice2WVtbl -#else -#define IID_IDirectInputDevice2 IID_IDirectInputDevice2A -#define IDirectInputDevice2 IDirectInputDevice2A -#define IDirectInputDevice2Vtbl IDirectInputDevice2AVtbl -#endif -typedef struct IDirectInputDevice2 *LPDIRECTINPUTDEVICE2; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice2_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInputDevice2_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice2_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice2_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice2_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice2_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice2_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice2_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) -#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) -#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) -#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) -#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) -#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) -#define IDirectInputDevice2_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#define IDirectInputDevice2_Poll(p) (p)->lpVtbl->Poll(p) -#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) -#else -#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice2_AddRef(p) (p)->AddRef() -#define IDirectInputDevice2_Release(p) (p)->Release() -#define IDirectInputDevice2_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice2_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice2_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice2_Acquire(p) (p)->Acquire() -#define IDirectInputDevice2_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice2_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice2_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) -#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) -#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) -#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) -#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) -#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) -#define IDirectInputDevice2_Escape(p,a) (p)->Escape(a) -#define IDirectInputDevice2_Poll(p) (p)->Poll() -#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) -#endif - -#endif /* DIJ_RINGZERO */ - -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - -#if(DIRECTINPUT_VERSION >= 0x0700) -#define DIFEF_DEFAULT 0x00000000 -#define DIFEF_INCLUDENONSTANDARD 0x00000001 -#define DIFEF_MODIFYIFNEEDED 0x00000010 - -#ifndef DIJ_RINGZERO - -#undef INTERFACE -#define INTERFACE IDirectInputDevice7W - -DECLARE_INTERFACE_(IDirectInputDevice7W, IDirectInputDevice2W) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDevice2W methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; - STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - - /*** IDirectInputDevice7W methods ***/ - STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; -}; - -typedef struct IDirectInputDevice7W *LPDIRECTINPUTDEVICE7W; - -#undef INTERFACE -#define INTERFACE IDirectInputDevice7A - -DECLARE_INTERFACE_(IDirectInputDevice7A, IDirectInputDevice2A) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDevice2A methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; - STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - - /*** IDirectInputDevice7A methods ***/ - STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; -}; - -typedef struct IDirectInputDevice7A *LPDIRECTINPUTDEVICE7A; - -#ifdef UNICODE -#define IID_IDirectInputDevice7 IID_IDirectInputDevice7W -#define IDirectInputDevice7 IDirectInputDevice7W -#define IDirectInputDevice7Vtbl IDirectInputDevice7WVtbl -#else -#define IID_IDirectInputDevice7 IID_IDirectInputDevice7A -#define IDirectInputDevice7 IDirectInputDevice7A -#define IDirectInputDevice7Vtbl IDirectInputDevice7AVtbl -#endif -typedef struct IDirectInputDevice7 *LPDIRECTINPUTDEVICE7; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice7_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInputDevice7_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice7_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice7_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice7_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice7_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice7_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice7_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) -#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) -#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) -#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) -#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) -#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) -#define IDirectInputDevice7_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#define IDirectInputDevice7_Poll(p) (p)->lpVtbl->Poll(p) -#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) -#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d) -#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d) -#else -#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice7_AddRef(p) (p)->AddRef() -#define IDirectInputDevice7_Release(p) (p)->Release() -#define IDirectInputDevice7_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice7_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice7_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice7_Acquire(p) (p)->Acquire() -#define IDirectInputDevice7_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice7_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice7_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) -#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) -#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) -#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) -#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) -#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) -#define IDirectInputDevice7_Escape(p,a) (p)->Escape(a) -#define IDirectInputDevice7_Poll(p) (p)->Poll() -#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) -#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d) -#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d) -#endif - -#endif /* DIJ_RINGZERO */ - -#endif /* DIRECTINPUT_VERSION >= 0x0700 */ - -#if(DIRECTINPUT_VERSION >= 0x0800) - -#ifndef DIJ_RINGZERO - -#undef INTERFACE -#define INTERFACE IDirectInputDevice8W - -DECLARE_INTERFACE_(IDirectInputDevice8W, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDevice8W methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; - STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; - STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATW,LPCWSTR,DWORD) PURE; - STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATW,LPCWSTR,DWORD) PURE; - STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERW) PURE; -}; - -typedef struct IDirectInputDevice8W *LPDIRECTINPUTDEVICE8W; - -#undef INTERFACE -#define INTERFACE IDirectInputDevice8A - -DECLARE_INTERFACE_(IDirectInputDevice8A, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDevice8A methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; - STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; - STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATA,LPCSTR,DWORD) PURE; - STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATA,LPCSTR,DWORD) PURE; - STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERA) PURE; -}; - -typedef struct IDirectInputDevice8A *LPDIRECTINPUTDEVICE8A; - -#ifdef UNICODE -#define IID_IDirectInputDevice8 IID_IDirectInputDevice8W -#define IDirectInputDevice8 IDirectInputDevice8W -#define IDirectInputDevice8Vtbl IDirectInputDevice8WVtbl -#else -#define IID_IDirectInputDevice8 IID_IDirectInputDevice8A -#define IDirectInputDevice8 IDirectInputDevice8A -#define IDirectInputDevice8Vtbl IDirectInputDevice8AVtbl -#endif -typedef struct IDirectInputDevice8 *LPDIRECTINPUTDEVICE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice8_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInputDevice8_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice8_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice8_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice8_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice8_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice8_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice8_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) -#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) -#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) -#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) -#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) -#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) -#define IDirectInputDevice8_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#define IDirectInputDevice8_Poll(p) (p)->lpVtbl->Poll(p) -#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) -#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d) -#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d) -#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->lpVtbl->BuildActionMap(p,a,b,c) -#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->lpVtbl->SetActionMap(p,a,b,c) -#define IDirectInputDevice8_GetImageInfo(p,a) (p)->lpVtbl->GetImageInfo(p,a) -#else -#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice8_AddRef(p) (p)->AddRef() -#define IDirectInputDevice8_Release(p) (p)->Release() -#define IDirectInputDevice8_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice8_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice8_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice8_Acquire(p) (p)->Acquire() -#define IDirectInputDevice8_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice8_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice8_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) -#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) -#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) -#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) -#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) -#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) -#define IDirectInputDevice8_Escape(p,a) (p)->Escape(a) -#define IDirectInputDevice8_Poll(p) (p)->Poll() -#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) -#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d) -#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d) -#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->BuildActionMap(a,b,c) -#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->SetActionMap(a,b,c) -#define IDirectInputDevice8_GetImageInfo(p,a) (p)->GetImageInfo(a) -#endif - -#endif /* DIJ_RINGZERO */ - -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -/**************************************************************************** - * - * Mouse - * - ****************************************************************************/ - -#ifndef DIJ_RINGZERO - -typedef struct _DIMOUSESTATE { - LONG lX; - LONG lY; - LONG lZ; - BYTE rgbButtons[4]; -} DIMOUSESTATE, *LPDIMOUSESTATE; - -#if DIRECTINPUT_VERSION >= 0x0700 -typedef struct _DIMOUSESTATE2 { - LONG lX; - LONG lY; - LONG lZ; - BYTE rgbButtons[8]; -} DIMOUSESTATE2, *LPDIMOUSESTATE2; -#endif - - -#define DIMOFS_X FIELD_OFFSET(DIMOUSESTATE, lX) -#define DIMOFS_Y FIELD_OFFSET(DIMOUSESTATE, lY) -#define DIMOFS_Z FIELD_OFFSET(DIMOUSESTATE, lZ) -#define DIMOFS_BUTTON0 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 0) -#define DIMOFS_BUTTON1 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 1) -#define DIMOFS_BUTTON2 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 2) -#define DIMOFS_BUTTON3 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 3) -#if (DIRECTINPUT_VERSION >= 0x0700) -#define DIMOFS_BUTTON4 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 4) -#define DIMOFS_BUTTON5 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 5) -#define DIMOFS_BUTTON6 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 6) -#define DIMOFS_BUTTON7 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 7) -#endif -#endif /* DIJ_RINGZERO */ - -/**************************************************************************** - * - * Keyboard - * - ****************************************************************************/ - -#ifndef DIJ_RINGZERO - -/**************************************************************************** - * - * DirectInput keyboard scan codes - * - ****************************************************************************/ -#define DIK_ESCAPE 0x01 -#define DIK_1 0x02 -#define DIK_2 0x03 -#define DIK_3 0x04 -#define DIK_4 0x05 -#define DIK_5 0x06 -#define DIK_6 0x07 -#define DIK_7 0x08 -#define DIK_8 0x09 -#define DIK_9 0x0A -#define DIK_0 0x0B -#define DIK_MINUS 0x0C /* - on main keyboard */ -#define DIK_EQUALS 0x0D -#define DIK_BACK 0x0E /* backspace */ -#define DIK_TAB 0x0F -#define DIK_Q 0x10 -#define DIK_W 0x11 -#define DIK_E 0x12 -#define DIK_R 0x13 -#define DIK_T 0x14 -#define DIK_Y 0x15 -#define DIK_U 0x16 -#define DIK_I 0x17 -#define DIK_O 0x18 -#define DIK_P 0x19 -#define DIK_LBRACKET 0x1A -#define DIK_RBRACKET 0x1B -#define DIK_RETURN 0x1C /* Enter on main keyboard */ -#define DIK_LCONTROL 0x1D -#define DIK_A 0x1E -#define DIK_S 0x1F -#define DIK_D 0x20 -#define DIK_F 0x21 -#define DIK_G 0x22 -#define DIK_H 0x23 -#define DIK_J 0x24 -#define DIK_K 0x25 -#define DIK_L 0x26 -#define DIK_SEMICOLON 0x27 -#define DIK_APOSTROPHE 0x28 -#define DIK_GRAVE 0x29 /* accent grave */ -#define DIK_LSHIFT 0x2A -#define DIK_BACKSLASH 0x2B -#define DIK_Z 0x2C -#define DIK_X 0x2D -#define DIK_C 0x2E -#define DIK_V 0x2F -#define DIK_B 0x30 -#define DIK_N 0x31 -#define DIK_M 0x32 -#define DIK_COMMA 0x33 -#define DIK_PERIOD 0x34 /* . on main keyboard */ -#define DIK_SLASH 0x35 /* / on main keyboard */ -#define DIK_RSHIFT 0x36 -#define DIK_MULTIPLY 0x37 /* * on numeric keypad */ -#define DIK_LMENU 0x38 /* left Alt */ -#define DIK_SPACE 0x39 -#define DIK_CAPITAL 0x3A -#define DIK_F1 0x3B -#define DIK_F2 0x3C -#define DIK_F3 0x3D -#define DIK_F4 0x3E -#define DIK_F5 0x3F -#define DIK_F6 0x40 -#define DIK_F7 0x41 -#define DIK_F8 0x42 -#define DIK_F9 0x43 -#define DIK_F10 0x44 -#define DIK_NUMLOCK 0x45 -#define DIK_SCROLL 0x46 /* Scroll Lock */ -#define DIK_NUMPAD7 0x47 -#define DIK_NUMPAD8 0x48 -#define DIK_NUMPAD9 0x49 -#define DIK_SUBTRACT 0x4A /* - on numeric keypad */ -#define DIK_NUMPAD4 0x4B -#define DIK_NUMPAD5 0x4C -#define DIK_NUMPAD6 0x4D -#define DIK_ADD 0x4E /* + on numeric keypad */ -#define DIK_NUMPAD1 0x4F -#define DIK_NUMPAD2 0x50 -#define DIK_NUMPAD3 0x51 -#define DIK_NUMPAD0 0x52 -#define DIK_DECIMAL 0x53 /* . on numeric keypad */ -#define DIK_OEM_102 0x56 /* <> or \| on RT 102-key keyboard (Non-U.S.) */ -#define DIK_F11 0x57 -#define DIK_F12 0x58 -#define DIK_F13 0x64 /* (NEC PC98) */ -#define DIK_F14 0x65 /* (NEC PC98) */ -#define DIK_F15 0x66 /* (NEC PC98) */ -#define DIK_KANA 0x70 /* (Japanese keyboard) */ -#define DIK_ABNT_C1 0x73 /* /? on Brazilian keyboard */ -#define DIK_CONVERT 0x79 /* (Japanese keyboard) */ -#define DIK_NOCONVERT 0x7B /* (Japanese keyboard) */ -#define DIK_YEN 0x7D /* (Japanese keyboard) */ -#define DIK_ABNT_C2 0x7E /* Numpad . on Brazilian keyboard */ -#define DIK_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */ -#define DIK_PREVTRACK 0x90 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */ -#define DIK_AT 0x91 /* (NEC PC98) */ -#define DIK_COLON 0x92 /* (NEC PC98) */ -#define DIK_UNDERLINE 0x93 /* (NEC PC98) */ -#define DIK_KANJI 0x94 /* (Japanese keyboard) */ -#define DIK_STOP 0x95 /* (NEC PC98) */ -#define DIK_AX 0x96 /* (Japan AX) */ -#define DIK_UNLABELED 0x97 /* (J3100) */ -#define DIK_NEXTTRACK 0x99 /* Next Track */ -#define DIK_NUMPADENTER 0x9C /* Enter on numeric keypad */ -#define DIK_RCONTROL 0x9D -#define DIK_MUTE 0xA0 /* Mute */ -#define DIK_CALCULATOR 0xA1 /* Calculator */ -#define DIK_PLAYPAUSE 0xA2 /* Play / Pause */ -#define DIK_MEDIASTOP 0xA4 /* Media Stop */ -#define DIK_VOLUMEDOWN 0xAE /* Volume - */ -#define DIK_VOLUMEUP 0xB0 /* Volume + */ -#define DIK_WEBHOME 0xB2 /* Web home */ -#define DIK_NUMPADCOMMA 0xB3 /* , on numeric keypad (NEC PC98) */ -#define DIK_DIVIDE 0xB5 /* / on numeric keypad */ -#define DIK_SYSRQ 0xB7 -#define DIK_RMENU 0xB8 /* right Alt */ -#define DIK_PAUSE 0xC5 /* Pause */ -#define DIK_HOME 0xC7 /* Home on arrow keypad */ -#define DIK_UP 0xC8 /* UpArrow on arrow keypad */ -#define DIK_PRIOR 0xC9 /* PgUp on arrow keypad */ -#define DIK_LEFT 0xCB /* LeftArrow on arrow keypad */ -#define DIK_RIGHT 0xCD /* RightArrow on arrow keypad */ -#define DIK_END 0xCF /* End on arrow keypad */ -#define DIK_DOWN 0xD0 /* DownArrow on arrow keypad */ -#define DIK_NEXT 0xD1 /* PgDn on arrow keypad */ -#define DIK_INSERT 0xD2 /* Insert on arrow keypad */ -#define DIK_DELETE 0xD3 /* Delete on arrow keypad */ -#define DIK_LWIN 0xDB /* Left Windows key */ -#define DIK_RWIN 0xDC /* Right Windows key */ -#define DIK_APPS 0xDD /* AppMenu key */ -#define DIK_POWER 0xDE /* System Power */ -#define DIK_SLEEP 0xDF /* System Sleep */ -#define DIK_WAKE 0xE3 /* System Wake */ -#define DIK_WEBSEARCH 0xE5 /* Web Search */ -#define DIK_WEBFAVORITES 0xE6 /* Web Favorites */ -#define DIK_WEBREFRESH 0xE7 /* Web Refresh */ -#define DIK_WEBSTOP 0xE8 /* Web Stop */ -#define DIK_WEBFORWARD 0xE9 /* Web Forward */ -#define DIK_WEBBACK 0xEA /* Web Back */ -#define DIK_MYCOMPUTER 0xEB /* My Computer */ -#define DIK_MAIL 0xEC /* Mail */ -#define DIK_MEDIASELECT 0xED /* Media Select */ - -/* - * Alternate names for keys, to facilitate transition from DOS. - */ -#define DIK_BACKSPACE DIK_BACK /* backspace */ -#define DIK_NUMPADSTAR DIK_MULTIPLY /* * on numeric keypad */ -#define DIK_LALT DIK_LMENU /* left Alt */ -#define DIK_CAPSLOCK DIK_CAPITAL /* CapsLock */ -#define DIK_NUMPADMINUS DIK_SUBTRACT /* - on numeric keypad */ -#define DIK_NUMPADPLUS DIK_ADD /* + on numeric keypad */ -#define DIK_NUMPADPERIOD DIK_DECIMAL /* . on numeric keypad */ -#define DIK_NUMPADSLASH DIK_DIVIDE /* / on numeric keypad */ -#define DIK_RALT DIK_RMENU /* right Alt */ -#define DIK_UPARROW DIK_UP /* UpArrow on arrow keypad */ -#define DIK_PGUP DIK_PRIOR /* PgUp on arrow keypad */ -#define DIK_LEFTARROW DIK_LEFT /* LeftArrow on arrow keypad */ -#define DIK_RIGHTARROW DIK_RIGHT /* RightArrow on arrow keypad */ -#define DIK_DOWNARROW DIK_DOWN /* DownArrow on arrow keypad */ -#define DIK_PGDN DIK_NEXT /* PgDn on arrow keypad */ - -/* - * Alternate names for keys originally not used on US keyboards. - */ -#define DIK_CIRCUMFLEX DIK_PREVTRACK /* Japanese keyboard */ - -#endif /* DIJ_RINGZERO */ - -/**************************************************************************** - * - * Joystick - * - ****************************************************************************/ - -#ifndef DIJ_RINGZERO - -typedef struct DIJOYSTATE { - LONG lX; /* x-axis position */ - LONG lY; /* y-axis position */ - LONG lZ; /* z-axis position */ - LONG lRx; /* x-axis rotation */ - LONG lRy; /* y-axis rotation */ - LONG lRz; /* z-axis rotation */ - LONG rglSlider[2]; /* extra axes positions */ - DWORD rgdwPOV[4]; /* POV directions */ - BYTE rgbButtons[32]; /* 32 buttons */ -} DIJOYSTATE, *LPDIJOYSTATE; - -typedef struct DIJOYSTATE2 { - LONG lX; /* x-axis position */ - LONG lY; /* y-axis position */ - LONG lZ; /* z-axis position */ - LONG lRx; /* x-axis rotation */ - LONG lRy; /* y-axis rotation */ - LONG lRz; /* z-axis rotation */ - LONG rglSlider[2]; /* extra axes positions */ - DWORD rgdwPOV[4]; /* POV directions */ - BYTE rgbButtons[128]; /* 128 buttons */ - LONG lVX; /* x-axis velocity */ - LONG lVY; /* y-axis velocity */ - LONG lVZ; /* z-axis velocity */ - LONG lVRx; /* x-axis angular velocity */ - LONG lVRy; /* y-axis angular velocity */ - LONG lVRz; /* z-axis angular velocity */ - LONG rglVSlider[2]; /* extra axes velocities */ - LONG lAX; /* x-axis acceleration */ - LONG lAY; /* y-axis acceleration */ - LONG lAZ; /* z-axis acceleration */ - LONG lARx; /* x-axis angular acceleration */ - LONG lARy; /* y-axis angular acceleration */ - LONG lARz; /* z-axis angular acceleration */ - LONG rglASlider[2]; /* extra axes accelerations */ - LONG lFX; /* x-axis force */ - LONG lFY; /* y-axis force */ - LONG lFZ; /* z-axis force */ - LONG lFRx; /* x-axis torque */ - LONG lFRy; /* y-axis torque */ - LONG lFRz; /* z-axis torque */ - LONG rglFSlider[2]; /* extra axes forces */ -} DIJOYSTATE2, *LPDIJOYSTATE2; - -#define DIJOFS_X FIELD_OFFSET(DIJOYSTATE, lX) -#define DIJOFS_Y FIELD_OFFSET(DIJOYSTATE, lY) -#define DIJOFS_Z FIELD_OFFSET(DIJOYSTATE, lZ) -#define DIJOFS_RX FIELD_OFFSET(DIJOYSTATE, lRx) -#define DIJOFS_RY FIELD_OFFSET(DIJOYSTATE, lRy) -#define DIJOFS_RZ FIELD_OFFSET(DIJOYSTATE, lRz) -#define DIJOFS_SLIDER(n) (FIELD_OFFSET(DIJOYSTATE, rglSlider) + \ - (n) * sizeof(LONG)) -#define DIJOFS_POV(n) (FIELD_OFFSET(DIJOYSTATE, rgdwPOV) + \ - (n) * sizeof(DWORD)) -#define DIJOFS_BUTTON(n) (FIELD_OFFSET(DIJOYSTATE, rgbButtons) + (n)) -#define DIJOFS_BUTTON0 DIJOFS_BUTTON(0) -#define DIJOFS_BUTTON1 DIJOFS_BUTTON(1) -#define DIJOFS_BUTTON2 DIJOFS_BUTTON(2) -#define DIJOFS_BUTTON3 DIJOFS_BUTTON(3) -#define DIJOFS_BUTTON4 DIJOFS_BUTTON(4) -#define DIJOFS_BUTTON5 DIJOFS_BUTTON(5) -#define DIJOFS_BUTTON6 DIJOFS_BUTTON(6) -#define DIJOFS_BUTTON7 DIJOFS_BUTTON(7) -#define DIJOFS_BUTTON8 DIJOFS_BUTTON(8) -#define DIJOFS_BUTTON9 DIJOFS_BUTTON(9) -#define DIJOFS_BUTTON10 DIJOFS_BUTTON(10) -#define DIJOFS_BUTTON11 DIJOFS_BUTTON(11) -#define DIJOFS_BUTTON12 DIJOFS_BUTTON(12) -#define DIJOFS_BUTTON13 DIJOFS_BUTTON(13) -#define DIJOFS_BUTTON14 DIJOFS_BUTTON(14) -#define DIJOFS_BUTTON15 DIJOFS_BUTTON(15) -#define DIJOFS_BUTTON16 DIJOFS_BUTTON(16) -#define DIJOFS_BUTTON17 DIJOFS_BUTTON(17) -#define DIJOFS_BUTTON18 DIJOFS_BUTTON(18) -#define DIJOFS_BUTTON19 DIJOFS_BUTTON(19) -#define DIJOFS_BUTTON20 DIJOFS_BUTTON(20) -#define DIJOFS_BUTTON21 DIJOFS_BUTTON(21) -#define DIJOFS_BUTTON22 DIJOFS_BUTTON(22) -#define DIJOFS_BUTTON23 DIJOFS_BUTTON(23) -#define DIJOFS_BUTTON24 DIJOFS_BUTTON(24) -#define DIJOFS_BUTTON25 DIJOFS_BUTTON(25) -#define DIJOFS_BUTTON26 DIJOFS_BUTTON(26) -#define DIJOFS_BUTTON27 DIJOFS_BUTTON(27) -#define DIJOFS_BUTTON28 DIJOFS_BUTTON(28) -#define DIJOFS_BUTTON29 DIJOFS_BUTTON(29) -#define DIJOFS_BUTTON30 DIJOFS_BUTTON(30) -#define DIJOFS_BUTTON31 DIJOFS_BUTTON(31) - - -#endif /* DIJ_RINGZERO */ - -/**************************************************************************** - * - * IDirectInput - * - ****************************************************************************/ - -#ifndef DIJ_RINGZERO - -#define DIENUM_STOP 0 -#define DIENUM_CONTINUE 1 - -typedef BOOL (FAR PASCAL * LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA, LPVOID); -typedef BOOL (FAR PASCAL * LPDIENUMDEVICESCALLBACKW)(LPCDIDEVICEINSTANCEW, LPVOID); -#ifdef UNICODE -#define LPDIENUMDEVICESCALLBACK LPDIENUMDEVICESCALLBACKW -#else -#define LPDIENUMDEVICESCALLBACK LPDIENUMDEVICESCALLBACKA -#endif // !UNICODE -typedef BOOL (FAR PASCAL * LPDICONFIGUREDEVICESCALLBACK)(IUnknown FAR *, LPVOID); - -#define DIEDFL_ALLDEVICES 0x00000000 -#define DIEDFL_ATTACHEDONLY 0x00000001 -#if(DIRECTINPUT_VERSION >= 0x0500) -#define DIEDFL_FORCEFEEDBACK 0x00000100 -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -#if(DIRECTINPUT_VERSION >= 0x050a) -#define DIEDFL_INCLUDEALIASES 0x00010000 -#define DIEDFL_INCLUDEPHANTOMS 0x00020000 -#endif /* DIRECTINPUT_VERSION >= 0x050a */ -#if(DIRECTINPUT_VERSION >= 0x0800) -#define DIEDFL_INCLUDEHIDDEN 0x00040000 -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - - -#if(DIRECTINPUT_VERSION >= 0x0800) -typedef BOOL (FAR PASCAL * LPDIENUMDEVICESBYSEMANTICSCBA)(LPCDIDEVICEINSTANCEA, LPDIRECTINPUTDEVICE8A, DWORD, DWORD, LPVOID); -typedef BOOL (FAR PASCAL * LPDIENUMDEVICESBYSEMANTICSCBW)(LPCDIDEVICEINSTANCEW, LPDIRECTINPUTDEVICE8W, DWORD, DWORD, LPVOID); -#ifdef UNICODE -#define LPDIENUMDEVICESBYSEMANTICSCB LPDIENUMDEVICESBYSEMANTICSCBW -#else -#define LPDIENUMDEVICESBYSEMANTICSCB LPDIENUMDEVICESBYSEMANTICSCBA -#endif // !UNICODE -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -#if(DIRECTINPUT_VERSION >= 0x0800) -#define DIEDBS_MAPPEDPRI1 0x00000001 -#define DIEDBS_MAPPEDPRI2 0x00000002 -#define DIEDBS_RECENTDEVICE 0x00000010 -#define DIEDBS_NEWDEVICE 0x00000020 -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -#if(DIRECTINPUT_VERSION >= 0x0800) -#define DIEDBSFL_ATTACHEDONLY 0x00000000 -#define DIEDBSFL_THISUSER 0x00000010 -#define DIEDBSFL_FORCEFEEDBACK DIEDFL_FORCEFEEDBACK -#define DIEDBSFL_AVAILABLEDEVICES 0x00001000 -#define DIEDBSFL_MULTIMICEKEYBOARDS 0x00002000 -#define DIEDBSFL_NONGAMINGDEVICES 0x00004000 -#define DIEDBSFL_VALID 0x00007110 -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -#undef INTERFACE -#define INTERFACE IDirectInputW - -DECLARE_INTERFACE_(IDirectInputW, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputW methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; -}; - -typedef struct IDirectInputW *LPDIRECTINPUTW; - -#undef INTERFACE -#define INTERFACE IDirectInputA - -DECLARE_INTERFACE_(IDirectInputA, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputA methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; -}; - -typedef struct IDirectInputA *LPDIRECTINPUTA; - -#ifdef UNICODE -#define IID_IDirectInput IID_IDirectInputW -#define IDirectInput IDirectInputW -#define IDirectInputVtbl IDirectInputWVtbl -#else -#define IID_IDirectInput IID_IDirectInputA -#define IDirectInput IDirectInputA -#define IDirectInputVtbl IDirectInputAVtbl -#endif -typedef struct IDirectInput *LPDIRECTINPUT; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInput_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInput_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#else -#define IDirectInput_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput_AddRef(p) (p)->AddRef() -#define IDirectInput_Release(p) (p)->Release() -#define IDirectInput_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput_Initialize(p,a,b) (p)->Initialize(a,b) -#endif - -#undef INTERFACE -#define INTERFACE IDirectInput2W - -DECLARE_INTERFACE_(IDirectInput2W, IDirectInputW) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputW methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; - - /*** IDirectInput2W methods ***/ - STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; -}; - -typedef struct IDirectInput2W *LPDIRECTINPUT2W; - -#undef INTERFACE -#define INTERFACE IDirectInput2A - -DECLARE_INTERFACE_(IDirectInput2A, IDirectInputA) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputA methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; - - /*** IDirectInput2A methods ***/ - STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; -}; - -typedef struct IDirectInput2A *LPDIRECTINPUT2A; - -#ifdef UNICODE -#define IID_IDirectInput2 IID_IDirectInput2W -#define IDirectInput2 IDirectInput2W -#define IDirectInput2Vtbl IDirectInput2WVtbl -#else -#define IID_IDirectInput2 IID_IDirectInput2A -#define IDirectInput2 IDirectInput2A -#define IDirectInput2Vtbl IDirectInput2AVtbl -#endif -typedef struct IDirectInput2 *LPDIRECTINPUT2; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInput2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput2_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInput2_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput2_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectInput2_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) -#else -#define IDirectInput2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput2_AddRef(p) (p)->AddRef() -#define IDirectInput2_Release(p) (p)->Release() -#define IDirectInput2_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput2_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput2_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectInput2_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) -#endif - - -#undef INTERFACE -#define INTERFACE IDirectInput7W - -DECLARE_INTERFACE_(IDirectInput7W, IDirectInput2W) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInput2W methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; - STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; - - /*** IDirectInput7W methods ***/ - STDMETHOD(CreateDeviceEx)(THIS_ REFGUID,REFIID,LPVOID *,LPUNKNOWN) PURE; -}; - -typedef struct IDirectInput7W *LPDIRECTINPUT7W; - -#undef INTERFACE -#define INTERFACE IDirectInput7A - -DECLARE_INTERFACE_(IDirectInput7A, IDirectInput2A) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInput2A methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; - STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; - - /*** IDirectInput7A methods ***/ - STDMETHOD(CreateDeviceEx)(THIS_ REFGUID,REFIID,LPVOID *,LPUNKNOWN) PURE; -}; - -typedef struct IDirectInput7A *LPDIRECTINPUT7A; - -#ifdef UNICODE -#define IID_IDirectInput7 IID_IDirectInput7W -#define IDirectInput7 IDirectInput7W -#define IDirectInput7Vtbl IDirectInput7WVtbl -#else -#define IID_IDirectInput7 IID_IDirectInput7A -#define IDirectInput7 IDirectInput7A -#define IDirectInput7Vtbl IDirectInput7AVtbl -#endif -typedef struct IDirectInput7 *LPDIRECTINPUT7; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInput7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput7_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInput7_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput7_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectInput7_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) -#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d) -#else -#define IDirectInput7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput7_AddRef(p) (p)->AddRef() -#define IDirectInput7_Release(p) (p)->Release() -#define IDirectInput7_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput7_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput7_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectInput7_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) -#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->CreateDeviceEx(a,b,c,d) -#endif - -#if(DIRECTINPUT_VERSION >= 0x0800) -#undef INTERFACE -#define INTERFACE IDirectInput8W - -DECLARE_INTERFACE_(IDirectInput8W, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInput8W methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICE8W *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; - STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; - STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCWSTR,LPDIACTIONFORMATW,LPDIENUMDEVICESBYSEMANTICSCBW,LPVOID,DWORD) PURE; - STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK,LPDICONFIGUREDEVICESPARAMSW,DWORD,LPVOID) PURE; -}; - -typedef struct IDirectInput8W *LPDIRECTINPUT8W; - -#undef INTERFACE -#define INTERFACE IDirectInput8A - -DECLARE_INTERFACE_(IDirectInput8A, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInput8A methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICE8A *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; - STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; - STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCSTR,LPDIACTIONFORMATA,LPDIENUMDEVICESBYSEMANTICSCBA,LPVOID,DWORD) PURE; - STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK,LPDICONFIGUREDEVICESPARAMSA,DWORD,LPVOID) PURE; -}; - -typedef struct IDirectInput8A *LPDIRECTINPUT8A; - -#ifdef UNICODE -#define IID_IDirectInput8 IID_IDirectInput8W -#define IDirectInput8 IDirectInput8W -#define IDirectInput8Vtbl IDirectInput8WVtbl -#else -#define IID_IDirectInput8 IID_IDirectInput8A -#define IDirectInput8 IDirectInput8A -#define IDirectInput8Vtbl IDirectInput8AVtbl -#endif -typedef struct IDirectInput8 *LPDIRECTINPUT8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInput8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput8_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInput8_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput8_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput8_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectInput8_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) -#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->lpVtbl->EnumDevicesBySemantics(p,a,b,c,d,e) -#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d) -#else -#define IDirectInput8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput8_AddRef(p) (p)->AddRef() -#define IDirectInput8_Release(p) (p)->Release() -#define IDirectInput8_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput8_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput8_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectInput8_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) -#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->EnumDevicesBySemantics(a,b,c,d,e) -#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->ConfigureDevices(a,b,c,d) -#endif -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -#if DIRECTINPUT_VERSION > 0x0700 - -extern HRESULT WINAPI DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter); - -#else -extern HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter); -extern HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter); -#ifdef UNICODE -#define DirectInputCreate DirectInputCreateW -#else -#define DirectInputCreate DirectInputCreateA -#endif // !UNICODE - -extern HRESULT WINAPI DirectInputCreateEx(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter); - -#endif /* DIRECTINPUT_VERSION > 0x700 */ - -#endif /* DIJ_RINGZERO */ - - -/**************************************************************************** - * - * Return Codes - * - ****************************************************************************/ - -/* - * The operation completed successfully. - */ -#define DI_OK S_OK - -/* - * The device exists but is not currently attached. - */ -#define DI_NOTATTACHED S_FALSE - -/* - * The device buffer overflowed. Some input was lost. - */ -#define DI_BUFFEROVERFLOW S_FALSE - -/* - * The change in device properties had no effect. - */ -#define DI_PROPNOEFFECT S_FALSE - -/* - * The operation had no effect. - */ -#define DI_NOEFFECT S_FALSE - -/* - * The device is a polled device. As a result, device buffering - * will not collect any data and event notifications will not be - * signalled until GetDeviceState is called. - */ -#define DI_POLLEDDEVICE ((HRESULT)0x00000002L) - -/* - * The parameters of the effect were successfully updated by - * IDirectInputEffect::SetParameters, but the effect was not - * downloaded because the device is not exclusively acquired - * or because the DIEP_NODOWNLOAD flag was passed. - */ -#define DI_DOWNLOADSKIPPED ((HRESULT)0x00000003L) - -/* - * The parameters of the effect were successfully updated by - * IDirectInputEffect::SetParameters, but in order to change - * the parameters, the effect needed to be restarted. - */ -#define DI_EFFECTRESTARTED ((HRESULT)0x00000004L) - -/* - * The parameters of the effect were successfully updated by - * IDirectInputEffect::SetParameters, but some of them were - * beyond the capabilities of the device and were truncated. - */ -#define DI_TRUNCATED ((HRESULT)0x00000008L) - -/* - * The settings have been successfully applied but could not be - * persisted. - */ -#define DI_SETTINGSNOTSAVED ((HRESULT)0x0000000BL) - -/* - * Equal to DI_EFFECTRESTARTED | DI_TRUNCATED. - */ -#define DI_TRUNCATEDANDRESTARTED ((HRESULT)0x0000000CL) - -/* - * A SUCCESS code indicating that settings cannot be modified. - */ -#define DI_WRITEPROTECT ((HRESULT)0x00000013L) - -/* - * The application requires a newer version of DirectInput. - */ -#define DIERR_OLDDIRECTINPUTVERSION \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_OLD_WIN_VERSION) - -/* - * The application was written for an unsupported prerelease version - * of DirectInput. - */ -#define DIERR_BETADIRECTINPUTVERSION \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_RMODE_APP) - -/* - * The object could not be created due to an incompatible driver version - * or mismatched or incomplete driver components. - */ -#define DIERR_BADDRIVERVER \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BAD_DRIVER_LEVEL) - -/* - * The device or device instance or effect is not registered with DirectInput. - */ -#define DIERR_DEVICENOTREG REGDB_E_CLASSNOTREG - -/* - * The requested object does not exist. - */ -#define DIERR_NOTFOUND \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND) - -/* - * The requested object does not exist. - */ -#define DIERR_OBJECTNOTFOUND \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND) - -/* - * An invalid parameter was passed to the returning function, - * or the object was not in a state that admitted the function - * to be called. - */ -#define DIERR_INVALIDPARAM E_INVALIDARG - -/* - * The specified interface is not supported by the object - */ -#define DIERR_NOINTERFACE E_NOINTERFACE - -/* - * An undetermined error occured inside the DInput subsystem - */ -#define DIERR_GENERIC E_FAIL - -/* - * The DInput subsystem couldn't allocate sufficient memory to complete the - * caller's request. - */ -#define DIERR_OUTOFMEMORY E_OUTOFMEMORY - -/* - * The function called is not supported at this time - */ -#define DIERR_UNSUPPORTED E_NOTIMPL - -/* - * This object has not been initialized - */ -#define DIERR_NOTINITIALIZED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_READY) - -/* - * This object is already initialized - */ -#define DIERR_ALREADYINITIALIZED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_ALREADY_INITIALIZED) - -/* - * This object does not support aggregation - */ -#define DIERR_NOAGGREGATION CLASS_E_NOAGGREGATION - -/* - * Another app has a higher priority level, preventing this call from - * succeeding. - */ -#define DIERR_OTHERAPPHASPRIO E_ACCESSDENIED - -/* - * Access to the device has been lost. It must be re-acquired. - */ -#define DIERR_INPUTLOST \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_READ_FAULT) - -/* - * The operation cannot be performed while the device is acquired. - */ -#define DIERR_ACQUIRED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BUSY) - -/* - * The operation cannot be performed unless the device is acquired. - */ -#define DIERR_NOTACQUIRED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_INVALID_ACCESS) - -/* - * The specified property cannot be changed. - */ -#define DIERR_READONLY E_ACCESSDENIED - -/* - * The device already has an event notification associated with it. - */ -#define DIERR_HANDLEEXISTS E_ACCESSDENIED - -/* - * Data is not yet available. - */ -#ifndef E_PENDING -#define E_PENDING 0x8000000AL -#endif - -/* - * Unable to IDirectInputJoyConfig_Acquire because the user - * does not have sufficient privileges to change the joystick - * configuration. - */ -#define DIERR_INSUFFICIENTPRIVS 0x80040200L - -/* - * The device is full. - */ -#define DIERR_DEVICEFULL 0x80040201L - -/* - * Not all the requested information fit into the buffer. - */ -#define DIERR_MOREDATA 0x80040202L - -/* - * The effect is not downloaded. - */ -#define DIERR_NOTDOWNLOADED 0x80040203L - -/* - * The device cannot be reinitialized because there are still effects - * attached to it. - */ -#define DIERR_HASEFFECTS 0x80040204L - -/* - * The operation cannot be performed unless the device is acquired - * in DISCL_EXCLUSIVE mode. - */ -#define DIERR_NOTEXCLUSIVEACQUIRED 0x80040205L - -/* - * The effect could not be downloaded because essential information - * is missing. For example, no axes have been associated with the - * effect, or no type-specific information has been created. - */ -#define DIERR_INCOMPLETEEFFECT 0x80040206L - -/* - * Attempted to read buffered device data from a device that is - * not buffered. - */ -#define DIERR_NOTBUFFERED 0x80040207L - -/* - * An attempt was made to modify parameters of an effect while it is - * playing. Not all hardware devices support altering the parameters - * of an effect while it is playing. - */ -#define DIERR_EFFECTPLAYING 0x80040208L - -/* - * The operation could not be completed because the device is not - * plugged in. - */ -#define DIERR_UNPLUGGED 0x80040209L - -/* - * SendDeviceData failed because more information was requested - * to be sent than can be sent to the device. Some devices have - * restrictions on how much data can be sent to them. (For example, - * there might be a limit on the number of buttons that can be - * pressed at once.) - */ -#define DIERR_REPORTFULL 0x8004020AL - - -/* - * A mapper file function failed because reading or writing the user or IHV - * settings file failed. - */ -#define DIERR_MAPFILEFAIL 0x8004020BL - - -/*--- DINPUT Mapper Definitions: New for Dx8 ---*/ - - -/*--- Keyboard - Physical Keyboard Device ---*/ - -#define DIKEYBOARD_ESCAPE 0x81000401 -#define DIKEYBOARD_1 0x81000402 -#define DIKEYBOARD_2 0x81000403 -#define DIKEYBOARD_3 0x81000404 -#define DIKEYBOARD_4 0x81000405 -#define DIKEYBOARD_5 0x81000406 -#define DIKEYBOARD_6 0x81000407 -#define DIKEYBOARD_7 0x81000408 -#define DIKEYBOARD_8 0x81000409 -#define DIKEYBOARD_9 0x8100040A -#define DIKEYBOARD_0 0x8100040B -#define DIKEYBOARD_MINUS 0x8100040C /* - on main keyboard */ -#define DIKEYBOARD_EQUALS 0x8100040D -#define DIKEYBOARD_BACK 0x8100040E /* backspace */ -#define DIKEYBOARD_TAB 0x8100040F -#define DIKEYBOARD_Q 0x81000410 -#define DIKEYBOARD_W 0x81000411 -#define DIKEYBOARD_E 0x81000412 -#define DIKEYBOARD_R 0x81000413 -#define DIKEYBOARD_T 0x81000414 -#define DIKEYBOARD_Y 0x81000415 -#define DIKEYBOARD_U 0x81000416 -#define DIKEYBOARD_I 0x81000417 -#define DIKEYBOARD_O 0x81000418 -#define DIKEYBOARD_P 0x81000419 -#define DIKEYBOARD_LBRACKET 0x8100041A -#define DIKEYBOARD_RBRACKET 0x8100041B -#define DIKEYBOARD_RETURN 0x8100041C /* Enter on main keyboard */ -#define DIKEYBOARD_LCONTROL 0x8100041D -#define DIKEYBOARD_A 0x8100041E -#define DIKEYBOARD_S 0x8100041F -#define DIKEYBOARD_D 0x81000420 -#define DIKEYBOARD_F 0x81000421 -#define DIKEYBOARD_G 0x81000422 -#define DIKEYBOARD_H 0x81000423 -#define DIKEYBOARD_J 0x81000424 -#define DIKEYBOARD_K 0x81000425 -#define DIKEYBOARD_L 0x81000426 -#define DIKEYBOARD_SEMICOLON 0x81000427 -#define DIKEYBOARD_APOSTROPHE 0x81000428 -#define DIKEYBOARD_GRAVE 0x81000429 /* accent grave */ -#define DIKEYBOARD_LSHIFT 0x8100042A -#define DIKEYBOARD_BACKSLASH 0x8100042B -#define DIKEYBOARD_Z 0x8100042C -#define DIKEYBOARD_X 0x8100042D -#define DIKEYBOARD_C 0x8100042E -#define DIKEYBOARD_V 0x8100042F -#define DIKEYBOARD_B 0x81000430 -#define DIKEYBOARD_N 0x81000431 -#define DIKEYBOARD_M 0x81000432 -#define DIKEYBOARD_COMMA 0x81000433 -#define DIKEYBOARD_PERIOD 0x81000434 /* . on main keyboard */ -#define DIKEYBOARD_SLASH 0x81000435 /* / on main keyboard */ -#define DIKEYBOARD_RSHIFT 0x81000436 -#define DIKEYBOARD_MULTIPLY 0x81000437 /* * on numeric keypad */ -#define DIKEYBOARD_LMENU 0x81000438 /* left Alt */ -#define DIKEYBOARD_SPACE 0x81000439 -#define DIKEYBOARD_CAPITAL 0x8100043A -#define DIKEYBOARD_F1 0x8100043B -#define DIKEYBOARD_F2 0x8100043C -#define DIKEYBOARD_F3 0x8100043D -#define DIKEYBOARD_F4 0x8100043E -#define DIKEYBOARD_F5 0x8100043F -#define DIKEYBOARD_F6 0x81000440 -#define DIKEYBOARD_F7 0x81000441 -#define DIKEYBOARD_F8 0x81000442 -#define DIKEYBOARD_F9 0x81000443 -#define DIKEYBOARD_F10 0x81000444 -#define DIKEYBOARD_NUMLOCK 0x81000445 -#define DIKEYBOARD_SCROLL 0x81000446 /* Scroll Lock */ -#define DIKEYBOARD_NUMPAD7 0x81000447 -#define DIKEYBOARD_NUMPAD8 0x81000448 -#define DIKEYBOARD_NUMPAD9 0x81000449 -#define DIKEYBOARD_SUBTRACT 0x8100044A /* - on numeric keypad */ -#define DIKEYBOARD_NUMPAD4 0x8100044B -#define DIKEYBOARD_NUMPAD5 0x8100044C -#define DIKEYBOARD_NUMPAD6 0x8100044D -#define DIKEYBOARD_ADD 0x8100044E /* + on numeric keypad */ -#define DIKEYBOARD_NUMPAD1 0x8100044F -#define DIKEYBOARD_NUMPAD2 0x81000450 -#define DIKEYBOARD_NUMPAD3 0x81000451 -#define DIKEYBOARD_NUMPAD0 0x81000452 -#define DIKEYBOARD_DECIMAL 0x81000453 /* . on numeric keypad */ -#define DIKEYBOARD_OEM_102 0x81000456 /* <> or \| on RT 102-key keyboard (Non-U.S.) */ -#define DIKEYBOARD_F11 0x81000457 -#define DIKEYBOARD_F12 0x81000458 -#define DIKEYBOARD_F13 0x81000464 /* (NEC PC98) */ -#define DIKEYBOARD_F14 0x81000465 /* (NEC PC98) */ -#define DIKEYBOARD_F15 0x81000466 /* (NEC PC98) */ -#define DIKEYBOARD_KANA 0x81000470 /* (Japanese keyboard) */ -#define DIKEYBOARD_ABNT_C1 0x81000473 /* /? on Brazilian keyboard */ -#define DIKEYBOARD_CONVERT 0x81000479 /* (Japanese keyboard) */ -#define DIKEYBOARD_NOCONVERT 0x8100047B /* (Japanese keyboard) */ -#define DIKEYBOARD_YEN 0x8100047D /* (Japanese keyboard) */ -#define DIKEYBOARD_ABNT_C2 0x8100047E /* Numpad . on Brazilian keyboard */ -#define DIKEYBOARD_NUMPADEQUALS 0x8100048D /* = on numeric keypad (NEC PC98) */ -#define DIKEYBOARD_PREVTRACK 0x81000490 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */ -#define DIKEYBOARD_AT 0x81000491 /* (NEC PC98) */ -#define DIKEYBOARD_COLON 0x81000492 /* (NEC PC98) */ -#define DIKEYBOARD_UNDERLINE 0x81000493 /* (NEC PC98) */ -#define DIKEYBOARD_KANJI 0x81000494 /* (Japanese keyboard) */ -#define DIKEYBOARD_STOP 0x81000495 /* (NEC PC98) */ -#define DIKEYBOARD_AX 0x81000496 /* (Japan AX) */ -#define DIKEYBOARD_UNLABELED 0x81000497 /* (J3100) */ -#define DIKEYBOARD_NEXTTRACK 0x81000499 /* Next Track */ -#define DIKEYBOARD_NUMPADENTER 0x8100049C /* Enter on numeric keypad */ -#define DIKEYBOARD_RCONTROL 0x8100049D -#define DIKEYBOARD_MUTE 0x810004A0 /* Mute */ -#define DIKEYBOARD_CALCULATOR 0x810004A1 /* Calculator */ -#define DIKEYBOARD_PLAYPAUSE 0x810004A2 /* Play / Pause */ -#define DIKEYBOARD_MEDIASTOP 0x810004A4 /* Media Stop */ -#define DIKEYBOARD_VOLUMEDOWN 0x810004AE /* Volume - */ -#define DIKEYBOARD_VOLUMEUP 0x810004B0 /* Volume + */ -#define DIKEYBOARD_WEBHOME 0x810004B2 /* Web home */ -#define DIKEYBOARD_NUMPADCOMMA 0x810004B3 /* , on numeric keypad (NEC PC98) */ -#define DIKEYBOARD_DIVIDE 0x810004B5 /* / on numeric keypad */ -#define DIKEYBOARD_SYSRQ 0x810004B7 -#define DIKEYBOARD_RMENU 0x810004B8 /* right Alt */ -#define DIKEYBOARD_PAUSE 0x810004C5 /* Pause */ -#define DIKEYBOARD_HOME 0x810004C7 /* Home on arrow keypad */ -#define DIKEYBOARD_UP 0x810004C8 /* UpArrow on arrow keypad */ -#define DIKEYBOARD_PRIOR 0x810004C9 /* PgUp on arrow keypad */ -#define DIKEYBOARD_LEFT 0x810004CB /* LeftArrow on arrow keypad */ -#define DIKEYBOARD_RIGHT 0x810004CD /* RightArrow on arrow keypad */ -#define DIKEYBOARD_END 0x810004CF /* End on arrow keypad */ -#define DIKEYBOARD_DOWN 0x810004D0 /* DownArrow on arrow keypad */ -#define DIKEYBOARD_NEXT 0x810004D1 /* PgDn on arrow keypad */ -#define DIKEYBOARD_INSERT 0x810004D2 /* Insert on arrow keypad */ -#define DIKEYBOARD_DELETE 0x810004D3 /* Delete on arrow keypad */ -#define DIKEYBOARD_LWIN 0x810004DB /* Left Windows key */ -#define DIKEYBOARD_RWIN 0x810004DC /* Right Windows key */ -#define DIKEYBOARD_APPS 0x810004DD /* AppMenu key */ -#define DIKEYBOARD_POWER 0x810004DE /* System Power */ -#define DIKEYBOARD_SLEEP 0x810004DF /* System Sleep */ -#define DIKEYBOARD_WAKE 0x810004E3 /* System Wake */ -#define DIKEYBOARD_WEBSEARCH 0x810004E5 /* Web Search */ -#define DIKEYBOARD_WEBFAVORITES 0x810004E6 /* Web Favorites */ -#define DIKEYBOARD_WEBREFRESH 0x810004E7 /* Web Refresh */ -#define DIKEYBOARD_WEBSTOP 0x810004E8 /* Web Stop */ -#define DIKEYBOARD_WEBFORWARD 0x810004E9 /* Web Forward */ -#define DIKEYBOARD_WEBBACK 0x810004EA /* Web Back */ -#define DIKEYBOARD_MYCOMPUTER 0x810004EB /* My Computer */ -#define DIKEYBOARD_MAIL 0x810004EC /* Mail */ -#define DIKEYBOARD_MEDIASELECT 0x810004ED /* Media Select */ - - -/*--- MOUSE - Physical Mouse Device ---*/ - -#define DIMOUSE_XAXISAB (0x82000200 |DIMOFS_X ) /* X Axis-absolute: Some mice natively report absolute coordinates */ -#define DIMOUSE_YAXISAB (0x82000200 |DIMOFS_Y ) /* Y Axis-absolute: Some mice natively report absolute coordinates */ -#define DIMOUSE_XAXIS (0x82000300 |DIMOFS_X ) /* X Axis */ -#define DIMOUSE_YAXIS (0x82000300 |DIMOFS_Y ) /* Y Axis */ -#define DIMOUSE_WHEEL (0x82000300 |DIMOFS_Z ) /* Z Axis */ -#define DIMOUSE_BUTTON0 (0x82000400 |DIMOFS_BUTTON0) /* Button 0 */ -#define DIMOUSE_BUTTON1 (0x82000400 |DIMOFS_BUTTON1) /* Button 1 */ -#define DIMOUSE_BUTTON2 (0x82000400 |DIMOFS_BUTTON2) /* Button 2 */ -#define DIMOUSE_BUTTON3 (0x82000400 |DIMOFS_BUTTON3) /* Button 3 */ -#define DIMOUSE_BUTTON4 (0x82000400 |DIMOFS_BUTTON4) /* Button 4 */ -#define DIMOUSE_BUTTON5 (0x82000400 |DIMOFS_BUTTON5) /* Button 5 */ -#define DIMOUSE_BUTTON6 (0x82000400 |DIMOFS_BUTTON6) /* Button 6 */ -#define DIMOUSE_BUTTON7 (0x82000400 |DIMOFS_BUTTON7) /* Button 7 */ - - -/*--- VOICE - Physical Dplay Voice Device ---*/ - -#define DIVOICE_CHANNEL1 0x83000401 -#define DIVOICE_CHANNEL2 0x83000402 -#define DIVOICE_CHANNEL3 0x83000403 -#define DIVOICE_CHANNEL4 0x83000404 -#define DIVOICE_CHANNEL5 0x83000405 -#define DIVOICE_CHANNEL6 0x83000406 -#define DIVOICE_CHANNEL7 0x83000407 -#define DIVOICE_CHANNEL8 0x83000408 -#define DIVOICE_TEAM 0x83000409 -#define DIVOICE_ALL 0x8300040A -#define DIVOICE_RECORDMUTE 0x8300040B -#define DIVOICE_PLAYBACKMUTE 0x8300040C -#define DIVOICE_TRANSMIT 0x8300040D - -#define DIVOICE_VOICECOMMAND 0x83000410 - - -/*--- Driving Simulator - Racing - Vehicle control is primary objective ---*/ -#define DIVIRTUAL_DRIVING_RACE 0x01000000 -#define DIAXIS_DRIVINGR_STEER 0x01008A01 /* Steering */ -#define DIAXIS_DRIVINGR_ACCELERATE 0x01039202 /* Accelerate */ -#define DIAXIS_DRIVINGR_BRAKE 0x01041203 /* Brake-Axis */ -#define DIBUTTON_DRIVINGR_SHIFTUP 0x01000C01 /* Shift to next higher gear */ -#define DIBUTTON_DRIVINGR_SHIFTDOWN 0x01000C02 /* Shift to next lower gear */ -#define DIBUTTON_DRIVINGR_VIEW 0x01001C03 /* Cycle through view options */ -#define DIBUTTON_DRIVINGR_MENU 0x010004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIAXIS_DRIVINGR_ACCEL_AND_BRAKE 0x01014A04 /* Some devices combine accelerate and brake in a single axis */ -#define DIHATSWITCH_DRIVINGR_GLANCE 0x01004601 /* Look around */ -#define DIBUTTON_DRIVINGR_BRAKE 0x01004C04 /* Brake-button */ -#define DIBUTTON_DRIVINGR_DASHBOARD 0x01004405 /* Select next dashboard option */ -#define DIBUTTON_DRIVINGR_AIDS 0x01004406 /* Driver correction aids */ -#define DIBUTTON_DRIVINGR_MAP 0x01004407 /* Display Driving Map */ -#define DIBUTTON_DRIVINGR_BOOST 0x01004408 /* Turbo Boost */ -#define DIBUTTON_DRIVINGR_PIT 0x01004409 /* Pit stop notification */ -#define DIBUTTON_DRIVINGR_ACCELERATE_LINK 0x0103D4E0 /* Fallback Accelerate button */ -#define DIBUTTON_DRIVINGR_STEER_LEFT_LINK 0x0100CCE4 /* Fallback Steer Left button */ -#define DIBUTTON_DRIVINGR_STEER_RIGHT_LINK 0x0100CCEC /* Fallback Steer Right button */ -#define DIBUTTON_DRIVINGR_GLANCE_LEFT_LINK 0x0107C4E4 /* Fallback Glance Left button */ -#define DIBUTTON_DRIVINGR_GLANCE_RIGHT_LINK 0x0107C4EC /* Fallback Glance Right button */ -#define DIBUTTON_DRIVINGR_DEVICE 0x010044FE /* Show input device and controls */ -#define DIBUTTON_DRIVINGR_PAUSE 0x010044FC /* Start / Pause / Restart game */ - -/*--- Driving Simulator - Combat - Combat from within a vehicle is primary objective ---*/ -#define DIVIRTUAL_DRIVING_COMBAT 0x02000000 -#define DIAXIS_DRIVINGC_STEER 0x02008A01 /* Steering */ -#define DIAXIS_DRIVINGC_ACCELERATE 0x02039202 /* Accelerate */ -#define DIAXIS_DRIVINGC_BRAKE 0x02041203 /* Brake-axis */ -#define DIBUTTON_DRIVINGC_FIRE 0x02000C01 /* Fire */ -#define DIBUTTON_DRIVINGC_WEAPONS 0x02000C02 /* Select next weapon */ -#define DIBUTTON_DRIVINGC_TARGET 0x02000C03 /* Select next available target */ -#define DIBUTTON_DRIVINGC_MENU 0x020004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIAXIS_DRIVINGC_ACCEL_AND_BRAKE 0x02014A04 /* Some devices combine accelerate and brake in a single axis */ -#define DIHATSWITCH_DRIVINGC_GLANCE 0x02004601 /* Look around */ -#define DIBUTTON_DRIVINGC_SHIFTUP 0x02004C04 /* Shift to next higher gear */ -#define DIBUTTON_DRIVINGC_SHIFTDOWN 0x02004C05 /* Shift to next lower gear */ -#define DIBUTTON_DRIVINGC_DASHBOARD 0x02004406 /* Select next dashboard option */ -#define DIBUTTON_DRIVINGC_AIDS 0x02004407 /* Driver correction aids */ -#define DIBUTTON_DRIVINGC_BRAKE 0x02004C08 /* Brake-button */ -#define DIBUTTON_DRIVINGC_FIRESECONDARY 0x02004C09 /* Alternative fire button */ -#define DIBUTTON_DRIVINGC_ACCELERATE_LINK 0x0203D4E0 /* Fallback Accelerate button */ -#define DIBUTTON_DRIVINGC_STEER_LEFT_LINK 0x0200CCE4 /* Fallback Steer Left button */ -#define DIBUTTON_DRIVINGC_STEER_RIGHT_LINK 0x0200CCEC /* Fallback Steer Right button */ -#define DIBUTTON_DRIVINGC_GLANCE_LEFT_LINK 0x0207C4E4 /* Fallback Glance Left button */ -#define DIBUTTON_DRIVINGC_GLANCE_RIGHT_LINK 0x0207C4EC /* Fallback Glance Right button */ -#define DIBUTTON_DRIVINGC_DEVICE 0x020044FE /* Show input device and controls */ -#define DIBUTTON_DRIVINGC_PAUSE 0x020044FC /* Start / Pause / Restart game */ - -/*--- Driving Simulator - Tank - Combat from withing a tank is primary objective ---*/ -#define DIVIRTUAL_DRIVING_TANK 0x03000000 -#define DIAXIS_DRIVINGT_STEER 0x03008A01 /* Turn tank left / right */ -#define DIAXIS_DRIVINGT_BARREL 0x03010202 /* Raise / lower barrel */ -#define DIAXIS_DRIVINGT_ACCELERATE 0x03039203 /* Accelerate */ -#define DIAXIS_DRIVINGT_ROTATE 0x03020204 /* Turn barrel left / right */ -#define DIBUTTON_DRIVINGT_FIRE 0x03000C01 /* Fire */ -#define DIBUTTON_DRIVINGT_WEAPONS 0x03000C02 /* Select next weapon */ -#define DIBUTTON_DRIVINGT_TARGET 0x03000C03 /* Selects next available target */ -#define DIBUTTON_DRIVINGT_MENU 0x030004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_DRIVINGT_GLANCE 0x03004601 /* Look around */ -#define DIAXIS_DRIVINGT_BRAKE 0x03045205 /* Brake-axis */ -#define DIAXIS_DRIVINGT_ACCEL_AND_BRAKE 0x03014A06 /* Some devices combine accelerate and brake in a single axis */ -#define DIBUTTON_DRIVINGT_VIEW 0x03005C04 /* Cycle through view options */ -#define DIBUTTON_DRIVINGT_DASHBOARD 0x03005C05 /* Select next dashboard option */ -#define DIBUTTON_DRIVINGT_BRAKE 0x03004C06 /* Brake-button */ -#define DIBUTTON_DRIVINGT_FIRESECONDARY 0x03004C07 /* Alternative fire button */ -#define DIBUTTON_DRIVINGT_ACCELERATE_LINK 0x0303D4E0 /* Fallback Accelerate button */ -#define DIBUTTON_DRIVINGT_STEER_LEFT_LINK 0x0300CCE4 /* Fallback Steer Left button */ -#define DIBUTTON_DRIVINGT_STEER_RIGHT_LINK 0x0300CCEC /* Fallback Steer Right button */ -#define DIBUTTON_DRIVINGT_BARREL_UP_LINK 0x030144E0 /* Fallback Barrel up button */ -#define DIBUTTON_DRIVINGT_BARREL_DOWN_LINK 0x030144E8 /* Fallback Barrel down button */ -#define DIBUTTON_DRIVINGT_ROTATE_LEFT_LINK 0x030244E4 /* Fallback Rotate left button */ -#define DIBUTTON_DRIVINGT_ROTATE_RIGHT_LINK 0x030244EC /* Fallback Rotate right button */ -#define DIBUTTON_DRIVINGT_GLANCE_LEFT_LINK 0x0307C4E4 /* Fallback Glance Left button */ -#define DIBUTTON_DRIVINGT_GLANCE_RIGHT_LINK 0x0307C4EC /* Fallback Glance Right button */ -#define DIBUTTON_DRIVINGT_DEVICE 0x030044FE /* Show input device and controls */ -#define DIBUTTON_DRIVINGT_PAUSE 0x030044FC /* Start / Pause / Restart game */ - -/*--- Flight Simulator - Civilian - Plane control is the primary objective ---*/ -#define DIVIRTUAL_FLYING_CIVILIAN 0x04000000 -#define DIAXIS_FLYINGC_BANK 0x04008A01 /* Roll ship left / right */ -#define DIAXIS_FLYINGC_PITCH 0x04010A02 /* Nose up / down */ -#define DIAXIS_FLYINGC_THROTTLE 0x04039203 /* Throttle */ -#define DIBUTTON_FLYINGC_VIEW 0x04002401 /* Cycle through view options */ -#define DIBUTTON_FLYINGC_DISPLAY 0x04002402 /* Select next dashboard / heads up display option */ -#define DIBUTTON_FLYINGC_GEAR 0x04002C03 /* Gear up / down */ -#define DIBUTTON_FLYINGC_MENU 0x040004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_FLYINGC_GLANCE 0x04004601 /* Look around */ -#define DIAXIS_FLYINGC_BRAKE 0x04046A04 /* Apply Brake */ -#define DIAXIS_FLYINGC_RUDDER 0x04025205 /* Yaw ship left/right */ -#define DIAXIS_FLYINGC_FLAPS 0x04055A06 /* Flaps */ -#define DIBUTTON_FLYINGC_FLAPSUP 0x04006404 /* Increment stepping up until fully retracted */ -#define DIBUTTON_FLYINGC_FLAPSDOWN 0x04006405 /* Decrement stepping down until fully extended */ -#define DIBUTTON_FLYINGC_BRAKE_LINK 0x04046CE0 /* Fallback brake button */ -#define DIBUTTON_FLYINGC_FASTER_LINK 0x0403D4E0 /* Fallback throttle up button */ -#define DIBUTTON_FLYINGC_SLOWER_LINK 0x0403D4E8 /* Fallback throttle down button */ -#define DIBUTTON_FLYINGC_GLANCE_LEFT_LINK 0x0407C4E4 /* Fallback Glance Left button */ -#define DIBUTTON_FLYINGC_GLANCE_RIGHT_LINK 0x0407C4EC /* Fallback Glance Right button */ -#define DIBUTTON_FLYINGC_GLANCE_UP_LINK 0x0407C4E0 /* Fallback Glance Up button */ -#define DIBUTTON_FLYINGC_GLANCE_DOWN_LINK 0x0407C4E8 /* Fallback Glance Down button */ -#define DIBUTTON_FLYINGC_DEVICE 0x040044FE /* Show input device and controls */ -#define DIBUTTON_FLYINGC_PAUSE 0x040044FC /* Start / Pause / Restart game */ - -/*--- Flight Simulator - Military - Aerial combat is the primary objective ---*/ -#define DIVIRTUAL_FLYING_MILITARY 0x05000000 -#define DIAXIS_FLYINGM_BANK 0x05008A01 /* Bank - Roll ship left / right */ -#define DIAXIS_FLYINGM_PITCH 0x05010A02 /* Pitch - Nose up / down */ -#define DIAXIS_FLYINGM_THROTTLE 0x05039203 /* Throttle - faster / slower */ -#define DIBUTTON_FLYINGM_FIRE 0x05000C01 /* Fire */ -#define DIBUTTON_FLYINGM_WEAPONS 0x05000C02 /* Select next weapon */ -#define DIBUTTON_FLYINGM_TARGET 0x05000C03 /* Selects next available target */ -#define DIBUTTON_FLYINGM_MENU 0x050004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_FLYINGM_GLANCE 0x05004601 /* Look around */ -#define DIBUTTON_FLYINGM_COUNTER 0x05005C04 /* Activate counter measures */ -#define DIAXIS_FLYINGM_RUDDER 0x05024A04 /* Rudder - Yaw ship left/right */ -#define DIAXIS_FLYINGM_BRAKE 0x05046205 /* Brake-axis */ -#define DIBUTTON_FLYINGM_VIEW 0x05006405 /* Cycle through view options */ -#define DIBUTTON_FLYINGM_DISPLAY 0x05006406 /* Select next dashboard option */ -#define DIAXIS_FLYINGM_FLAPS 0x05055206 /* Flaps */ -#define DIBUTTON_FLYINGM_FLAPSUP 0x05005407 /* Increment stepping up until fully retracted */ -#define DIBUTTON_FLYINGM_FLAPSDOWN 0x05005408 /* Decrement stepping down until fully extended */ -#define DIBUTTON_FLYINGM_FIRESECONDARY 0x05004C09 /* Alternative fire button */ -#define DIBUTTON_FLYINGM_GEAR 0x0500640A /* Gear up / down */ -#define DIBUTTON_FLYINGM_BRAKE_LINK 0x050464E0 /* Fallback brake button */ -#define DIBUTTON_FLYINGM_FASTER_LINK 0x0503D4E0 /* Fallback throttle up button */ -#define DIBUTTON_FLYINGM_SLOWER_LINK 0x0503D4E8 /* Fallback throttle down button */ -#define DIBUTTON_FLYINGM_GLANCE_LEFT_LINK 0x0507C4E4 /* Fallback Glance Left button */ -#define DIBUTTON_FLYINGM_GLANCE_RIGHT_LINK 0x0507C4EC /* Fallback Glance Right button */ -#define DIBUTTON_FLYINGM_GLANCE_UP_LINK 0x0507C4E0 /* Fallback Glance Up button */ -#define DIBUTTON_FLYINGM_GLANCE_DOWN_LINK 0x0507C4E8 /* Fallback Glance Down button */ -#define DIBUTTON_FLYINGM_DEVICE 0x050044FE /* Show input device and controls */ -#define DIBUTTON_FLYINGM_PAUSE 0x050044FC /* Start / Pause / Restart game */ - -/*--- Flight Simulator - Combat Helicopter - Combat from helicopter is primary objective ---*/ -#define DIVIRTUAL_FLYING_HELICOPTER 0x06000000 -#define DIAXIS_FLYINGH_BANK 0x06008A01 /* Bank - Roll ship left / right */ -#define DIAXIS_FLYINGH_PITCH 0x06010A02 /* Pitch - Nose up / down */ -#define DIAXIS_FLYINGH_COLLECTIVE 0x06018A03 /* Collective - Blade pitch/power */ -#define DIBUTTON_FLYINGH_FIRE 0x06001401 /* Fire */ -#define DIBUTTON_FLYINGH_WEAPONS 0x06001402 /* Select next weapon */ -#define DIBUTTON_FLYINGH_TARGET 0x06001403 /* Selects next available target */ -#define DIBUTTON_FLYINGH_MENU 0x060004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_FLYINGH_GLANCE 0x06004601 /* Look around */ -#define DIAXIS_FLYINGH_TORQUE 0x06025A04 /* Torque - Rotate ship around left / right axis */ -#define DIAXIS_FLYINGH_THROTTLE 0x0603DA05 /* Throttle */ -#define DIBUTTON_FLYINGH_COUNTER 0x06005404 /* Activate counter measures */ -#define DIBUTTON_FLYINGH_VIEW 0x06006405 /* Cycle through view options */ -#define DIBUTTON_FLYINGH_GEAR 0x06006406 /* Gear up / down */ -#define DIBUTTON_FLYINGH_FIRESECONDARY 0x06004C07 /* Alternative fire button */ -#define DIBUTTON_FLYINGH_FASTER_LINK 0x0603DCE0 /* Fallback throttle up button */ -#define DIBUTTON_FLYINGH_SLOWER_LINK 0x0603DCE8 /* Fallback throttle down button */ -#define DIBUTTON_FLYINGH_GLANCE_LEFT_LINK 0x0607C4E4 /* Fallback Glance Left button */ -#define DIBUTTON_FLYINGH_GLANCE_RIGHT_LINK 0x0607C4EC /* Fallback Glance Right button */ -#define DIBUTTON_FLYINGH_GLANCE_UP_LINK 0x0607C4E0 /* Fallback Glance Up button */ -#define DIBUTTON_FLYINGH_GLANCE_DOWN_LINK 0x0607C4E8 /* Fallback Glance Down button */ -#define DIBUTTON_FLYINGH_DEVICE 0x060044FE /* Show input device and controls */ -#define DIBUTTON_FLYINGH_PAUSE 0x060044FC /* Start / Pause / Restart game */ - -/*--- Space Simulator - Combat - Space Simulator with weapons ---*/ -#define DIVIRTUAL_SPACESIM 0x07000000 -#define DIAXIS_SPACESIM_LATERAL 0x07008201 /* Move ship left / right */ -#define DIAXIS_SPACESIM_MOVE 0x07010202 /* Move ship forward/backward */ -#define DIAXIS_SPACESIM_THROTTLE 0x07038203 /* Throttle - Engine speed */ -#define DIBUTTON_SPACESIM_FIRE 0x07000401 /* Fire */ -#define DIBUTTON_SPACESIM_WEAPONS 0x07000402 /* Select next weapon */ -#define DIBUTTON_SPACESIM_TARGET 0x07000403 /* Selects next available target */ -#define DIBUTTON_SPACESIM_MENU 0x070004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_SPACESIM_GLANCE 0x07004601 /* Look around */ -#define DIAXIS_SPACESIM_CLIMB 0x0701C204 /* Climb - Pitch ship up/down */ -#define DIAXIS_SPACESIM_ROTATE 0x07024205 /* Rotate - Turn ship left/right */ -#define DIBUTTON_SPACESIM_VIEW 0x07004404 /* Cycle through view options */ -#define DIBUTTON_SPACESIM_DISPLAY 0x07004405 /* Select next dashboard / heads up display option */ -#define DIBUTTON_SPACESIM_RAISE 0x07004406 /* Raise ship while maintaining current pitch */ -#define DIBUTTON_SPACESIM_LOWER 0x07004407 /* Lower ship while maintaining current pitch */ -#define DIBUTTON_SPACESIM_GEAR 0x07004408 /* Gear up / down */ -#define DIBUTTON_SPACESIM_FIRESECONDARY 0x07004409 /* Alternative fire button */ -#define DIBUTTON_SPACESIM_LEFT_LINK 0x0700C4E4 /* Fallback move left button */ -#define DIBUTTON_SPACESIM_RIGHT_LINK 0x0700C4EC /* Fallback move right button */ -#define DIBUTTON_SPACESIM_FORWARD_LINK 0x070144E0 /* Fallback move forward button */ -#define DIBUTTON_SPACESIM_BACKWARD_LINK 0x070144E8 /* Fallback move backwards button */ -#define DIBUTTON_SPACESIM_FASTER_LINK 0x0703C4E0 /* Fallback throttle up button */ -#define DIBUTTON_SPACESIM_SLOWER_LINK 0x0703C4E8 /* Fallback throttle down button */ -#define DIBUTTON_SPACESIM_TURN_LEFT_LINK 0x070244E4 /* Fallback turn left button */ -#define DIBUTTON_SPACESIM_TURN_RIGHT_LINK 0x070244EC /* Fallback turn right button */ -#define DIBUTTON_SPACESIM_GLANCE_LEFT_LINK 0x0707C4E4 /* Fallback Glance Left button */ -#define DIBUTTON_SPACESIM_GLANCE_RIGHT_LINK 0x0707C4EC /* Fallback Glance Right button */ -#define DIBUTTON_SPACESIM_GLANCE_UP_LINK 0x0707C4E0 /* Fallback Glance Up button */ -#define DIBUTTON_SPACESIM_GLANCE_DOWN_LINK 0x0707C4E8 /* Fallback Glance Down button */ -#define DIBUTTON_SPACESIM_DEVICE 0x070044FE /* Show input device and controls */ -#define DIBUTTON_SPACESIM_PAUSE 0x070044FC /* Start / Pause / Restart game */ - -/*--- Fighting - First Person - Hand to Hand combat is primary objective ---*/ -#define DIVIRTUAL_FIGHTING_HAND2HAND 0x08000000 -#define DIAXIS_FIGHTINGH_LATERAL 0x08008201 /* Sidestep left/right */ -#define DIAXIS_FIGHTINGH_MOVE 0x08010202 /* Move forward/backward */ -#define DIBUTTON_FIGHTINGH_PUNCH 0x08000401 /* Punch */ -#define DIBUTTON_FIGHTINGH_KICK 0x08000402 /* Kick */ -#define DIBUTTON_FIGHTINGH_BLOCK 0x08000403 /* Block */ -#define DIBUTTON_FIGHTINGH_CROUCH 0x08000404 /* Crouch */ -#define DIBUTTON_FIGHTINGH_JUMP 0x08000405 /* Jump */ -#define DIBUTTON_FIGHTINGH_SPECIAL1 0x08000406 /* Apply first special move */ -#define DIBUTTON_FIGHTINGH_SPECIAL2 0x08000407 /* Apply second special move */ -#define DIBUTTON_FIGHTINGH_MENU 0x080004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_FIGHTINGH_SELECT 0x08004408 /* Select special move */ -#define DIHATSWITCH_FIGHTINGH_SLIDE 0x08004601 /* Look around */ -#define DIBUTTON_FIGHTINGH_DISPLAY 0x08004409 /* Shows next on-screen display option */ -#define DIAXIS_FIGHTINGH_ROTATE 0x08024203 /* Rotate - Turn body left/right */ -#define DIBUTTON_FIGHTINGH_DODGE 0x0800440A /* Dodge */ -#define DIBUTTON_FIGHTINGH_LEFT_LINK 0x0800C4E4 /* Fallback left sidestep button */ -#define DIBUTTON_FIGHTINGH_RIGHT_LINK 0x0800C4EC /* Fallback right sidestep button */ -#define DIBUTTON_FIGHTINGH_FORWARD_LINK 0x080144E0 /* Fallback forward button */ -#define DIBUTTON_FIGHTINGH_BACKWARD_LINK 0x080144E8 /* Fallback backward button */ -#define DIBUTTON_FIGHTINGH_DEVICE 0x080044FE /* Show input device and controls */ -#define DIBUTTON_FIGHTINGH_PAUSE 0x080044FC /* Start / Pause / Restart game */ - -/*--- Fighting - First Person Shooting - Navigation and combat are primary objectives ---*/ -#define DIVIRTUAL_FIGHTING_FPS 0x09000000 -#define DIAXIS_FPS_ROTATE 0x09008201 /* Rotate character left/right */ -#define DIAXIS_FPS_MOVE 0x09010202 /* Move forward/backward */ -#define DIBUTTON_FPS_FIRE 0x09000401 /* Fire */ -#define DIBUTTON_FPS_WEAPONS 0x09000402 /* Select next weapon */ -#define DIBUTTON_FPS_APPLY 0x09000403 /* Use item */ -#define DIBUTTON_FPS_SELECT 0x09000404 /* Select next inventory item */ -#define DIBUTTON_FPS_CROUCH 0x09000405 /* Crouch/ climb down/ swim down */ -#define DIBUTTON_FPS_JUMP 0x09000406 /* Jump/ climb up/ swim up */ -#define DIAXIS_FPS_LOOKUPDOWN 0x09018203 /* Look up / down */ -#define DIBUTTON_FPS_STRAFE 0x09000407 /* Enable strafing while active */ -#define DIBUTTON_FPS_MENU 0x090004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_FPS_GLANCE 0x09004601 /* Look around */ -#define DIBUTTON_FPS_DISPLAY 0x09004408 /* Shows next on-screen display option/ map */ -#define DIAXIS_FPS_SIDESTEP 0x09024204 /* Sidestep */ -#define DIBUTTON_FPS_DODGE 0x09004409 /* Dodge */ -#define DIBUTTON_FPS_GLANCEL 0x0900440A /* Glance Left */ -#define DIBUTTON_FPS_GLANCER 0x0900440B /* Glance Right */ -#define DIBUTTON_FPS_FIRESECONDARY 0x0900440C /* Alternative fire button */ -#define DIBUTTON_FPS_ROTATE_LEFT_LINK 0x0900C4E4 /* Fallback rotate left button */ -#define DIBUTTON_FPS_ROTATE_RIGHT_LINK 0x0900C4EC /* Fallback rotate right button */ -#define DIBUTTON_FPS_FORWARD_LINK 0x090144E0 /* Fallback forward button */ -#define DIBUTTON_FPS_BACKWARD_LINK 0x090144E8 /* Fallback backward button */ -#define DIBUTTON_FPS_GLANCE_UP_LINK 0x0901C4E0 /* Fallback look up button */ -#define DIBUTTON_FPS_GLANCE_DOWN_LINK 0x0901C4E8 /* Fallback look down button */ -#define DIBUTTON_FPS_STEP_LEFT_LINK 0x090244E4 /* Fallback step left button */ -#define DIBUTTON_FPS_STEP_RIGHT_LINK 0x090244EC /* Fallback step right button */ -#define DIBUTTON_FPS_DEVICE 0x090044FE /* Show input device and controls */ -#define DIBUTTON_FPS_PAUSE 0x090044FC /* Start / Pause / Restart game */ - -/*--- Fighting - Third Person action - Perspective of camera is behind the main character ---*/ -#define DIVIRTUAL_FIGHTING_THIRDPERSON 0x0A000000 -#define DIAXIS_TPS_TURN 0x0A020201 /* Turn left/right */ -#define DIAXIS_TPS_MOVE 0x0A010202 /* Move forward/backward */ -#define DIBUTTON_TPS_RUN 0x0A000401 /* Run or walk toggle switch */ -#define DIBUTTON_TPS_ACTION 0x0A000402 /* Action Button */ -#define DIBUTTON_TPS_SELECT 0x0A000403 /* Select next weapon */ -#define DIBUTTON_TPS_USE 0x0A000404 /* Use inventory item currently selected */ -#define DIBUTTON_TPS_JUMP 0x0A000405 /* Character Jumps */ -#define DIBUTTON_TPS_MENU 0x0A0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_TPS_GLANCE 0x0A004601 /* Look around */ -#define DIBUTTON_TPS_VIEW 0x0A004406 /* Select camera view */ -#define DIBUTTON_TPS_STEPLEFT 0x0A004407 /* Character takes a left step */ -#define DIBUTTON_TPS_STEPRIGHT 0x0A004408 /* Character takes a right step */ -#define DIAXIS_TPS_STEP 0x0A00C203 /* Character steps left/right */ -#define DIBUTTON_TPS_DODGE 0x0A004409 /* Character dodges or ducks */ -#define DIBUTTON_TPS_INVENTORY 0x0A00440A /* Cycle through inventory */ -#define DIBUTTON_TPS_TURN_LEFT_LINK 0x0A0244E4 /* Fallback turn left button */ -#define DIBUTTON_TPS_TURN_RIGHT_LINK 0x0A0244EC /* Fallback turn right button */ -#define DIBUTTON_TPS_FORWARD_LINK 0x0A0144E0 /* Fallback forward button */ -#define DIBUTTON_TPS_BACKWARD_LINK 0x0A0144E8 /* Fallback backward button */ -#define DIBUTTON_TPS_GLANCE_UP_LINK 0x0A07C4E0 /* Fallback look up button */ -#define DIBUTTON_TPS_GLANCE_DOWN_LINK 0x0A07C4E8 /* Fallback look down button */ -#define DIBUTTON_TPS_GLANCE_LEFT_LINK 0x0A07C4E4 /* Fallback glance up button */ -#define DIBUTTON_TPS_GLANCE_RIGHT_LINK 0x0A07C4EC /* Fallback glance right button */ -#define DIBUTTON_TPS_DEVICE 0x0A0044FE /* Show input device and controls */ -#define DIBUTTON_TPS_PAUSE 0x0A0044FC /* Start / Pause / Restart game */ - -/*--- Strategy - Role Playing - Navigation and problem solving are primary actions ---*/ -#define DIVIRTUAL_STRATEGY_ROLEPLAYING 0x0B000000 -#define DIAXIS_STRATEGYR_LATERAL 0x0B008201 /* sidestep - left/right */ -#define DIAXIS_STRATEGYR_MOVE 0x0B010202 /* move forward/backward */ -#define DIBUTTON_STRATEGYR_GET 0x0B000401 /* Acquire item */ -#define DIBUTTON_STRATEGYR_APPLY 0x0B000402 /* Use selected item */ -#define DIBUTTON_STRATEGYR_SELECT 0x0B000403 /* Select nextitem */ -#define DIBUTTON_STRATEGYR_ATTACK 0x0B000404 /* Attack */ -#define DIBUTTON_STRATEGYR_CAST 0x0B000405 /* Cast Spell */ -#define DIBUTTON_STRATEGYR_CROUCH 0x0B000406 /* Crouch */ -#define DIBUTTON_STRATEGYR_JUMP 0x0B000407 /* Jump */ -#define DIBUTTON_STRATEGYR_MENU 0x0B0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_STRATEGYR_GLANCE 0x0B004601 /* Look around */ -#define DIBUTTON_STRATEGYR_MAP 0x0B004408 /* Cycle through map options */ -#define DIBUTTON_STRATEGYR_DISPLAY 0x0B004409 /* Shows next on-screen display option */ -#define DIAXIS_STRATEGYR_ROTATE 0x0B024203 /* Turn body left/right */ -#define DIBUTTON_STRATEGYR_LEFT_LINK 0x0B00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_STRATEGYR_RIGHT_LINK 0x0B00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_STRATEGYR_FORWARD_LINK 0x0B0144E0 /* Fallback move forward button */ -#define DIBUTTON_STRATEGYR_BACK_LINK 0x0B0144E8 /* Fallback move backward button */ -#define DIBUTTON_STRATEGYR_ROTATE_LEFT_LINK 0x0B0244E4 /* Fallback turn body left button */ -#define DIBUTTON_STRATEGYR_ROTATE_RIGHT_LINK 0x0B0244EC /* Fallback turn body right button */ -#define DIBUTTON_STRATEGYR_DEVICE 0x0B0044FE /* Show input device and controls */ -#define DIBUTTON_STRATEGYR_PAUSE 0x0B0044FC /* Start / Pause / Restart game */ - -/*--- Strategy - Turn based - Navigation and problem solving are primary actions ---*/ -#define DIVIRTUAL_STRATEGY_TURN 0x0C000000 -#define DIAXIS_STRATEGYT_LATERAL 0x0C008201 /* Sidestep left/right */ -#define DIAXIS_STRATEGYT_MOVE 0x0C010202 /* Move forward/backwards */ -#define DIBUTTON_STRATEGYT_SELECT 0x0C000401 /* Select unit or object */ -#define DIBUTTON_STRATEGYT_INSTRUCT 0x0C000402 /* Cycle through instructions */ -#define DIBUTTON_STRATEGYT_APPLY 0x0C000403 /* Apply selected instruction */ -#define DIBUTTON_STRATEGYT_TEAM 0x0C000404 /* Select next team / cycle through all */ -#define DIBUTTON_STRATEGYT_TURN 0x0C000405 /* Indicate turn over */ -#define DIBUTTON_STRATEGYT_MENU 0x0C0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_STRATEGYT_ZOOM 0x0C004406 /* Zoom - in / out */ -#define DIBUTTON_STRATEGYT_MAP 0x0C004407 /* cycle through map options */ -#define DIBUTTON_STRATEGYT_DISPLAY 0x0C004408 /* shows next on-screen display options */ -#define DIBUTTON_STRATEGYT_LEFT_LINK 0x0C00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_STRATEGYT_RIGHT_LINK 0x0C00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_STRATEGYT_FORWARD_LINK 0x0C0144E0 /* Fallback move forward button */ -#define DIBUTTON_STRATEGYT_BACK_LINK 0x0C0144E8 /* Fallback move back button */ -#define DIBUTTON_STRATEGYT_DEVICE 0x0C0044FE /* Show input device and controls */ -#define DIBUTTON_STRATEGYT_PAUSE 0x0C0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Hunting - Hunting ---*/ -#define DIVIRTUAL_SPORTS_HUNTING 0x0D000000 -#define DIAXIS_HUNTING_LATERAL 0x0D008201 /* sidestep left/right */ -#define DIAXIS_HUNTING_MOVE 0x0D010202 /* move forward/backwards */ -#define DIBUTTON_HUNTING_FIRE 0x0D000401 /* Fire selected weapon */ -#define DIBUTTON_HUNTING_AIM 0x0D000402 /* Select aim/move */ -#define DIBUTTON_HUNTING_WEAPON 0x0D000403 /* Select next weapon */ -#define DIBUTTON_HUNTING_BINOCULAR 0x0D000404 /* Look through Binoculars */ -#define DIBUTTON_HUNTING_CALL 0x0D000405 /* Make animal call */ -#define DIBUTTON_HUNTING_MAP 0x0D000406 /* View Map */ -#define DIBUTTON_HUNTING_SPECIAL 0x0D000407 /* Special game operation */ -#define DIBUTTON_HUNTING_MENU 0x0D0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_HUNTING_GLANCE 0x0D004601 /* Look around */ -#define DIBUTTON_HUNTING_DISPLAY 0x0D004408 /* show next on-screen display option */ -#define DIAXIS_HUNTING_ROTATE 0x0D024203 /* Turn body left/right */ -#define DIBUTTON_HUNTING_CROUCH 0x0D004409 /* Crouch/ Climb / Swim down */ -#define DIBUTTON_HUNTING_JUMP 0x0D00440A /* Jump/ Climb up / Swim up */ -#define DIBUTTON_HUNTING_FIRESECONDARY 0x0D00440B /* Alternative fire button */ -#define DIBUTTON_HUNTING_LEFT_LINK 0x0D00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_HUNTING_RIGHT_LINK 0x0D00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_HUNTING_FORWARD_LINK 0x0D0144E0 /* Fallback move forward button */ -#define DIBUTTON_HUNTING_BACK_LINK 0x0D0144E8 /* Fallback move back button */ -#define DIBUTTON_HUNTING_ROTATE_LEFT_LINK 0x0D0244E4 /* Fallback turn body left button */ -#define DIBUTTON_HUNTING_ROTATE_RIGHT_LINK 0x0D0244EC /* Fallback turn body right button */ -#define DIBUTTON_HUNTING_DEVICE 0x0D0044FE /* Show input device and controls */ -#define DIBUTTON_HUNTING_PAUSE 0x0D0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Fishing - Catching Fish is primary objective ---*/ -#define DIVIRTUAL_SPORTS_FISHING 0x0E000000 -#define DIAXIS_FISHING_LATERAL 0x0E008201 /* sidestep left/right */ -#define DIAXIS_FISHING_MOVE 0x0E010202 /* move forward/backwards */ -#define DIBUTTON_FISHING_CAST 0x0E000401 /* Cast line */ -#define DIBUTTON_FISHING_TYPE 0x0E000402 /* Select cast type */ -#define DIBUTTON_FISHING_BINOCULAR 0x0E000403 /* Look through Binocular */ -#define DIBUTTON_FISHING_BAIT 0x0E000404 /* Select type of Bait */ -#define DIBUTTON_FISHING_MAP 0x0E000405 /* View Map */ -#define DIBUTTON_FISHING_MENU 0x0E0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_FISHING_GLANCE 0x0E004601 /* Look around */ -#define DIBUTTON_FISHING_DISPLAY 0x0E004406 /* Show next on-screen display option */ -#define DIAXIS_FISHING_ROTATE 0x0E024203 /* Turn character left / right */ -#define DIBUTTON_FISHING_CROUCH 0x0E004407 /* Crouch/ Climb / Swim down */ -#define DIBUTTON_FISHING_JUMP 0x0E004408 /* Jump/ Climb up / Swim up */ -#define DIBUTTON_FISHING_LEFT_LINK 0x0E00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_FISHING_RIGHT_LINK 0x0E00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_FISHING_FORWARD_LINK 0x0E0144E0 /* Fallback move forward button */ -#define DIBUTTON_FISHING_BACK_LINK 0x0E0144E8 /* Fallback move back button */ -#define DIBUTTON_FISHING_ROTATE_LEFT_LINK 0x0E0244E4 /* Fallback turn body left button */ -#define DIBUTTON_FISHING_ROTATE_RIGHT_LINK 0x0E0244EC /* Fallback turn body right button */ -#define DIBUTTON_FISHING_DEVICE 0x0E0044FE /* Show input device and controls */ -#define DIBUTTON_FISHING_PAUSE 0x0E0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Baseball - Batting - Batter control is primary objective ---*/ -#define DIVIRTUAL_SPORTS_BASEBALL_BAT 0x0F000000 -#define DIAXIS_BASEBALLB_LATERAL 0x0F008201 /* Aim left / right */ -#define DIAXIS_BASEBALLB_MOVE 0x0F010202 /* Aim up / down */ -#define DIBUTTON_BASEBALLB_SELECT 0x0F000401 /* cycle through swing options */ -#define DIBUTTON_BASEBALLB_NORMAL 0x0F000402 /* normal swing */ -#define DIBUTTON_BASEBALLB_POWER 0x0F000403 /* swing for the fence */ -#define DIBUTTON_BASEBALLB_BUNT 0x0F000404 /* bunt */ -#define DIBUTTON_BASEBALLB_STEAL 0x0F000405 /* Base runner attempts to steal a base */ -#define DIBUTTON_BASEBALLB_BURST 0x0F000406 /* Base runner invokes burst of speed */ -#define DIBUTTON_BASEBALLB_SLIDE 0x0F000407 /* Base runner slides into base */ -#define DIBUTTON_BASEBALLB_CONTACT 0x0F000408 /* Contact swing */ -#define DIBUTTON_BASEBALLB_MENU 0x0F0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_BASEBALLB_NOSTEAL 0x0F004409 /* Base runner goes back to a base */ -#define DIBUTTON_BASEBALLB_BOX 0x0F00440A /* Enter or exit batting box */ -#define DIBUTTON_BASEBALLB_LEFT_LINK 0x0F00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_BASEBALLB_RIGHT_LINK 0x0F00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_BASEBALLB_FORWARD_LINK 0x0F0144E0 /* Fallback move forward button */ -#define DIBUTTON_BASEBALLB_BACK_LINK 0x0F0144E8 /* Fallback move back button */ -#define DIBUTTON_BASEBALLB_DEVICE 0x0F0044FE /* Show input device and controls */ -#define DIBUTTON_BASEBALLB_PAUSE 0x0F0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Baseball - Pitching - Pitcher control is primary objective ---*/ -#define DIVIRTUAL_SPORTS_BASEBALL_PITCH 0x10000000 -#define DIAXIS_BASEBALLP_LATERAL 0x10008201 /* Aim left / right */ -#define DIAXIS_BASEBALLP_MOVE 0x10010202 /* Aim up / down */ -#define DIBUTTON_BASEBALLP_SELECT 0x10000401 /* cycle through pitch selections */ -#define DIBUTTON_BASEBALLP_PITCH 0x10000402 /* throw pitch */ -#define DIBUTTON_BASEBALLP_BASE 0x10000403 /* select base to throw to */ -#define DIBUTTON_BASEBALLP_THROW 0x10000404 /* throw to base */ -#define DIBUTTON_BASEBALLP_FAKE 0x10000405 /* Fake a throw to a base */ -#define DIBUTTON_BASEBALLP_MENU 0x100004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_BASEBALLP_WALK 0x10004406 /* Throw intentional walk / pitch out */ -#define DIBUTTON_BASEBALLP_LOOK 0x10004407 /* Look at runners on bases */ -#define DIBUTTON_BASEBALLP_LEFT_LINK 0x1000C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_BASEBALLP_RIGHT_LINK 0x1000C4EC /* Fallback sidestep right button */ -#define DIBUTTON_BASEBALLP_FORWARD_LINK 0x100144E0 /* Fallback move forward button */ -#define DIBUTTON_BASEBALLP_BACK_LINK 0x100144E8 /* Fallback move back button */ -#define DIBUTTON_BASEBALLP_DEVICE 0x100044FE /* Show input device and controls */ -#define DIBUTTON_BASEBALLP_PAUSE 0x100044FC /* Start / Pause / Restart game */ - -/*--- Sports - Baseball - Fielding - Fielder control is primary objective ---*/ -#define DIVIRTUAL_SPORTS_BASEBALL_FIELD 0x11000000 -#define DIAXIS_BASEBALLF_LATERAL 0x11008201 /* Aim left / right */ -#define DIAXIS_BASEBALLF_MOVE 0x11010202 /* Aim up / down */ -#define DIBUTTON_BASEBALLF_NEAREST 0x11000401 /* Switch to fielder nearest to the ball */ -#define DIBUTTON_BASEBALLF_THROW1 0x11000402 /* Make conservative throw */ -#define DIBUTTON_BASEBALLF_THROW2 0x11000403 /* Make aggressive throw */ -#define DIBUTTON_BASEBALLF_BURST 0x11000404 /* Invoke burst of speed */ -#define DIBUTTON_BASEBALLF_JUMP 0x11000405 /* Jump to catch ball */ -#define DIBUTTON_BASEBALLF_DIVE 0x11000406 /* Dive to catch ball */ -#define DIBUTTON_BASEBALLF_MENU 0x110004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_BASEBALLF_SHIFTIN 0x11004407 /* Shift the infield positioning */ -#define DIBUTTON_BASEBALLF_SHIFTOUT 0x11004408 /* Shift the outfield positioning */ -#define DIBUTTON_BASEBALLF_AIM_LEFT_LINK 0x1100C4E4 /* Fallback aim left button */ -#define DIBUTTON_BASEBALLF_AIM_RIGHT_LINK 0x1100C4EC /* Fallback aim right button */ -#define DIBUTTON_BASEBALLF_FORWARD_LINK 0x110144E0 /* Fallback move forward button */ -#define DIBUTTON_BASEBALLF_BACK_LINK 0x110144E8 /* Fallback move back button */ -#define DIBUTTON_BASEBALLF_DEVICE 0x110044FE /* Show input device and controls */ -#define DIBUTTON_BASEBALLF_PAUSE 0x110044FC /* Start / Pause / Restart game */ - -/*--- Sports - Basketball - Offense - Offense ---*/ -#define DIVIRTUAL_SPORTS_BASKETBALL_OFFENSE 0x12000000 -#define DIAXIS_BBALLO_LATERAL 0x12008201 /* left / right */ -#define DIAXIS_BBALLO_MOVE 0x12010202 /* up / down */ -#define DIBUTTON_BBALLO_SHOOT 0x12000401 /* shoot basket */ -#define DIBUTTON_BBALLO_DUNK 0x12000402 /* dunk basket */ -#define DIBUTTON_BBALLO_PASS 0x12000403 /* throw pass */ -#define DIBUTTON_BBALLO_FAKE 0x12000404 /* fake shot or pass */ -#define DIBUTTON_BBALLO_SPECIAL 0x12000405 /* apply special move */ -#define DIBUTTON_BBALLO_PLAYER 0x12000406 /* select next player */ -#define DIBUTTON_BBALLO_BURST 0x12000407 /* invoke burst */ -#define DIBUTTON_BBALLO_CALL 0x12000408 /* call for ball / pass to me */ -#define DIBUTTON_BBALLO_MENU 0x120004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_BBALLO_GLANCE 0x12004601 /* scroll view */ -#define DIBUTTON_BBALLO_SCREEN 0x12004409 /* Call for screen */ -#define DIBUTTON_BBALLO_PLAY 0x1200440A /* Call for specific offensive play */ -#define DIBUTTON_BBALLO_JAB 0x1200440B /* Initiate fake drive to basket */ -#define DIBUTTON_BBALLO_POST 0x1200440C /* Perform post move */ -#define DIBUTTON_BBALLO_TIMEOUT 0x1200440D /* Time Out */ -#define DIBUTTON_BBALLO_SUBSTITUTE 0x1200440E /* substitute one player for another */ -#define DIBUTTON_BBALLO_LEFT_LINK 0x1200C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_BBALLO_RIGHT_LINK 0x1200C4EC /* Fallback sidestep right button */ -#define DIBUTTON_BBALLO_FORWARD_LINK 0x120144E0 /* Fallback move forward button */ -#define DIBUTTON_BBALLO_BACK_LINK 0x120144E8 /* Fallback move back button */ -#define DIBUTTON_BBALLO_DEVICE 0x120044FE /* Show input device and controls */ -#define DIBUTTON_BBALLO_PAUSE 0x120044FC /* Start / Pause / Restart game */ - -/*--- Sports - Basketball - Defense - Defense ---*/ -#define DIVIRTUAL_SPORTS_BASKETBALL_DEFENSE 0x13000000 -#define DIAXIS_BBALLD_LATERAL 0x13008201 /* left / right */ -#define DIAXIS_BBALLD_MOVE 0x13010202 /* up / down */ -#define DIBUTTON_BBALLD_JUMP 0x13000401 /* jump to block shot */ -#define DIBUTTON_BBALLD_STEAL 0x13000402 /* attempt to steal ball */ -#define DIBUTTON_BBALLD_FAKE 0x13000403 /* fake block or steal */ -#define DIBUTTON_BBALLD_SPECIAL 0x13000404 /* apply special move */ -#define DIBUTTON_BBALLD_PLAYER 0x13000405 /* select next player */ -#define DIBUTTON_BBALLD_BURST 0x13000406 /* invoke burst */ -#define DIBUTTON_BBALLD_PLAY 0x13000407 /* call for specific defensive play */ -#define DIBUTTON_BBALLD_MENU 0x130004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_BBALLD_GLANCE 0x13004601 /* scroll view */ -#define DIBUTTON_BBALLD_TIMEOUT 0x13004408 /* Time Out */ -#define DIBUTTON_BBALLD_SUBSTITUTE 0x13004409 /* substitute one player for another */ -#define DIBUTTON_BBALLD_LEFT_LINK 0x1300C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_BBALLD_RIGHT_LINK 0x1300C4EC /* Fallback sidestep right button */ -#define DIBUTTON_BBALLD_FORWARD_LINK 0x130144E0 /* Fallback move forward button */ -#define DIBUTTON_BBALLD_BACK_LINK 0x130144E8 /* Fallback move back button */ -#define DIBUTTON_BBALLD_DEVICE 0x130044FE /* Show input device and controls */ -#define DIBUTTON_BBALLD_PAUSE 0x130044FC /* Start / Pause / Restart game */ - -/*--- Sports - Football - Play - Play selection ---*/ -#define DIVIRTUAL_SPORTS_FOOTBALL_FIELD 0x14000000 -#define DIBUTTON_FOOTBALLP_PLAY 0x14000401 /* cycle through available plays */ -#define DIBUTTON_FOOTBALLP_SELECT 0x14000402 /* select play */ -#define DIBUTTON_FOOTBALLP_HELP 0x14000403 /* Bring up pop-up help */ -#define DIBUTTON_FOOTBALLP_MENU 0x140004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_FOOTBALLP_DEVICE 0x140044FE /* Show input device and controls */ -#define DIBUTTON_FOOTBALLP_PAUSE 0x140044FC /* Start / Pause / Restart game */ - -/*--- Sports - Football - QB - Offense: Quarterback / Kicker ---*/ -#define DIVIRTUAL_SPORTS_FOOTBALL_QBCK 0x15000000 -#define DIAXIS_FOOTBALLQ_LATERAL 0x15008201 /* Move / Aim: left / right */ -#define DIAXIS_FOOTBALLQ_MOVE 0x15010202 /* Move / Aim: up / down */ -#define DIBUTTON_FOOTBALLQ_SELECT 0x15000401 /* Select */ -#define DIBUTTON_FOOTBALLQ_SNAP 0x15000402 /* snap ball - start play */ -#define DIBUTTON_FOOTBALLQ_JUMP 0x15000403 /* jump over defender */ -#define DIBUTTON_FOOTBALLQ_SLIDE 0x15000404 /* Dive/Slide */ -#define DIBUTTON_FOOTBALLQ_PASS 0x15000405 /* throws pass to receiver */ -#define DIBUTTON_FOOTBALLQ_FAKE 0x15000406 /* pump fake pass or fake kick */ -#define DIBUTTON_FOOTBALLQ_MENU 0x150004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_FOOTBALLQ_FAKESNAP 0x15004407 /* Fake snap */ -#define DIBUTTON_FOOTBALLQ_MOTION 0x15004408 /* Send receivers in motion */ -#define DIBUTTON_FOOTBALLQ_AUDIBLE 0x15004409 /* Change offensive play at line of scrimmage */ -#define DIBUTTON_FOOTBALLQ_LEFT_LINK 0x1500C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_FOOTBALLQ_RIGHT_LINK 0x1500C4EC /* Fallback sidestep right button */ -#define DIBUTTON_FOOTBALLQ_FORWARD_LINK 0x150144E0 /* Fallback move forward button */ -#define DIBUTTON_FOOTBALLQ_BACK_LINK 0x150144E8 /* Fallback move back button */ -#define DIBUTTON_FOOTBALLQ_DEVICE 0x150044FE /* Show input device and controls */ -#define DIBUTTON_FOOTBALLQ_PAUSE 0x150044FC /* Start / Pause / Restart game */ - -/*--- Sports - Football - Offense - Offense - Runner ---*/ -#define DIVIRTUAL_SPORTS_FOOTBALL_OFFENSE 0x16000000 -#define DIAXIS_FOOTBALLO_LATERAL 0x16008201 /* Move / Aim: left / right */ -#define DIAXIS_FOOTBALLO_MOVE 0x16010202 /* Move / Aim: up / down */ -#define DIBUTTON_FOOTBALLO_JUMP 0x16000401 /* jump or hurdle over defender */ -#define DIBUTTON_FOOTBALLO_LEFTARM 0x16000402 /* holds out left arm */ -#define DIBUTTON_FOOTBALLO_RIGHTARM 0x16000403 /* holds out right arm */ -#define DIBUTTON_FOOTBALLO_THROW 0x16000404 /* throw pass or lateral ball to another runner */ -#define DIBUTTON_FOOTBALLO_SPIN 0x16000405 /* Spin to avoid defenders */ -#define DIBUTTON_FOOTBALLO_MENU 0x160004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_FOOTBALLO_JUKE 0x16004406 /* Use special move to avoid defenders */ -#define DIBUTTON_FOOTBALLO_SHOULDER 0x16004407 /* Lower shoulder to run over defenders */ -#define DIBUTTON_FOOTBALLO_TURBO 0x16004408 /* Speed burst past defenders */ -#define DIBUTTON_FOOTBALLO_DIVE 0x16004409 /* Dive over defenders */ -#define DIBUTTON_FOOTBALLO_ZOOM 0x1600440A /* Zoom view in / out */ -#define DIBUTTON_FOOTBALLO_SUBSTITUTE 0x1600440B /* substitute one player for another */ -#define DIBUTTON_FOOTBALLO_LEFT_LINK 0x1600C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_FOOTBALLO_RIGHT_LINK 0x1600C4EC /* Fallback sidestep right button */ -#define DIBUTTON_FOOTBALLO_FORWARD_LINK 0x160144E0 /* Fallback move forward button */ -#define DIBUTTON_FOOTBALLO_BACK_LINK 0x160144E8 /* Fallback move back button */ -#define DIBUTTON_FOOTBALLO_DEVICE 0x160044FE /* Show input device and controls */ -#define DIBUTTON_FOOTBALLO_PAUSE 0x160044FC /* Start / Pause / Restart game */ - -/*--- Sports - Football - Defense - Defense ---*/ -#define DIVIRTUAL_SPORTS_FOOTBALL_DEFENSE 0x17000000 -#define DIAXIS_FOOTBALLD_LATERAL 0x17008201 /* Move / Aim: left / right */ -#define DIAXIS_FOOTBALLD_MOVE 0x17010202 /* Move / Aim: up / down */ -#define DIBUTTON_FOOTBALLD_PLAY 0x17000401 /* cycle through available plays */ -#define DIBUTTON_FOOTBALLD_SELECT 0x17000402 /* select player closest to the ball */ -#define DIBUTTON_FOOTBALLD_JUMP 0x17000403 /* jump to intercept or block */ -#define DIBUTTON_FOOTBALLD_TACKLE 0x17000404 /* tackler runner */ -#define DIBUTTON_FOOTBALLD_FAKE 0x17000405 /* hold down to fake tackle or intercept */ -#define DIBUTTON_FOOTBALLD_SUPERTACKLE 0x17000406 /* Initiate special tackle */ -#define DIBUTTON_FOOTBALLD_MENU 0x170004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_FOOTBALLD_SPIN 0x17004407 /* Spin to beat offensive line */ -#define DIBUTTON_FOOTBALLD_SWIM 0x17004408 /* Swim to beat the offensive line */ -#define DIBUTTON_FOOTBALLD_BULLRUSH 0x17004409 /* Bull rush the offensive line */ -#define DIBUTTON_FOOTBALLD_RIP 0x1700440A /* Rip the offensive line */ -#define DIBUTTON_FOOTBALLD_AUDIBLE 0x1700440B /* Change defensive play at the line of scrimmage */ -#define DIBUTTON_FOOTBALLD_ZOOM 0x1700440C /* Zoom view in / out */ -#define DIBUTTON_FOOTBALLD_SUBSTITUTE 0x1700440D /* substitute one player for another */ -#define DIBUTTON_FOOTBALLD_LEFT_LINK 0x1700C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_FOOTBALLD_RIGHT_LINK 0x1700C4EC /* Fallback sidestep right button */ -#define DIBUTTON_FOOTBALLD_FORWARD_LINK 0x170144E0 /* Fallback move forward button */ -#define DIBUTTON_FOOTBALLD_BACK_LINK 0x170144E8 /* Fallback move back button */ -#define DIBUTTON_FOOTBALLD_DEVICE 0x170044FE /* Show input device and controls */ -#define DIBUTTON_FOOTBALLD_PAUSE 0x170044FC /* Start / Pause / Restart game */ - -/*--- Sports - Golf - ---*/ -#define DIVIRTUAL_SPORTS_GOLF 0x18000000 -#define DIAXIS_GOLF_LATERAL 0x18008201 /* Move / Aim: left / right */ -#define DIAXIS_GOLF_MOVE 0x18010202 /* Move / Aim: up / down */ -#define DIBUTTON_GOLF_SWING 0x18000401 /* swing club */ -#define DIBUTTON_GOLF_SELECT 0x18000402 /* cycle between: club / swing strength / ball arc / ball spin */ -#define DIBUTTON_GOLF_UP 0x18000403 /* increase selection */ -#define DIBUTTON_GOLF_DOWN 0x18000404 /* decrease selection */ -#define DIBUTTON_GOLF_TERRAIN 0x18000405 /* shows terrain detail */ -#define DIBUTTON_GOLF_FLYBY 0x18000406 /* view the hole via a flyby */ -#define DIBUTTON_GOLF_MENU 0x180004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_GOLF_SCROLL 0x18004601 /* scroll view */ -#define DIBUTTON_GOLF_ZOOM 0x18004407 /* Zoom view in / out */ -#define DIBUTTON_GOLF_TIMEOUT 0x18004408 /* Call for time out */ -#define DIBUTTON_GOLF_SUBSTITUTE 0x18004409 /* substitute one player for another */ -#define DIBUTTON_GOLF_LEFT_LINK 0x1800C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_GOLF_RIGHT_LINK 0x1800C4EC /* Fallback sidestep right button */ -#define DIBUTTON_GOLF_FORWARD_LINK 0x180144E0 /* Fallback move forward button */ -#define DIBUTTON_GOLF_BACK_LINK 0x180144E8 /* Fallback move back button */ -#define DIBUTTON_GOLF_DEVICE 0x180044FE /* Show input device and controls */ -#define DIBUTTON_GOLF_PAUSE 0x180044FC /* Start / Pause / Restart game */ - -/*--- Sports - Hockey - Offense - Offense ---*/ -#define DIVIRTUAL_SPORTS_HOCKEY_OFFENSE 0x19000000 -#define DIAXIS_HOCKEYO_LATERAL 0x19008201 /* Move / Aim: left / right */ -#define DIAXIS_HOCKEYO_MOVE 0x19010202 /* Move / Aim: up / down */ -#define DIBUTTON_HOCKEYO_SHOOT 0x19000401 /* Shoot */ -#define DIBUTTON_HOCKEYO_PASS 0x19000402 /* pass the puck */ -#define DIBUTTON_HOCKEYO_BURST 0x19000403 /* invoke speed burst */ -#define DIBUTTON_HOCKEYO_SPECIAL 0x19000404 /* invoke special move */ -#define DIBUTTON_HOCKEYO_FAKE 0x19000405 /* hold down to fake pass or kick */ -#define DIBUTTON_HOCKEYO_MENU 0x190004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_HOCKEYO_SCROLL 0x19004601 /* scroll view */ -#define DIBUTTON_HOCKEYO_ZOOM 0x19004406 /* Zoom view in / out */ -#define DIBUTTON_HOCKEYO_STRATEGY 0x19004407 /* Invoke coaching menu for strategy help */ -#define DIBUTTON_HOCKEYO_TIMEOUT 0x19004408 /* Call for time out */ -#define DIBUTTON_HOCKEYO_SUBSTITUTE 0x19004409 /* substitute one player for another */ -#define DIBUTTON_HOCKEYO_LEFT_LINK 0x1900C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_HOCKEYO_RIGHT_LINK 0x1900C4EC /* Fallback sidestep right button */ -#define DIBUTTON_HOCKEYO_FORWARD_LINK 0x190144E0 /* Fallback move forward button */ -#define DIBUTTON_HOCKEYO_BACK_LINK 0x190144E8 /* Fallback move back button */ -#define DIBUTTON_HOCKEYO_DEVICE 0x190044FE /* Show input device and controls */ -#define DIBUTTON_HOCKEYO_PAUSE 0x190044FC /* Start / Pause / Restart game */ - -/*--- Sports - Hockey - Defense - Defense ---*/ -#define DIVIRTUAL_SPORTS_HOCKEY_DEFENSE 0x1A000000 -#define DIAXIS_HOCKEYD_LATERAL 0x1A008201 /* Move / Aim: left / right */ -#define DIAXIS_HOCKEYD_MOVE 0x1A010202 /* Move / Aim: up / down */ -#define DIBUTTON_HOCKEYD_PLAYER 0x1A000401 /* control player closest to the puck */ -#define DIBUTTON_HOCKEYD_STEAL 0x1A000402 /* attempt steal */ -#define DIBUTTON_HOCKEYD_BURST 0x1A000403 /* speed burst or body check */ -#define DIBUTTON_HOCKEYD_BLOCK 0x1A000404 /* block puck */ -#define DIBUTTON_HOCKEYD_FAKE 0x1A000405 /* hold down to fake tackle or intercept */ -#define DIBUTTON_HOCKEYD_MENU 0x1A0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_HOCKEYD_SCROLL 0x1A004601 /* scroll view */ -#define DIBUTTON_HOCKEYD_ZOOM 0x1A004406 /* Zoom view in / out */ -#define DIBUTTON_HOCKEYD_STRATEGY 0x1A004407 /* Invoke coaching menu for strategy help */ -#define DIBUTTON_HOCKEYD_TIMEOUT 0x1A004408 /* Call for time out */ -#define DIBUTTON_HOCKEYD_SUBSTITUTE 0x1A004409 /* substitute one player for another */ -#define DIBUTTON_HOCKEYD_LEFT_LINK 0x1A00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_HOCKEYD_RIGHT_LINK 0x1A00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_HOCKEYD_FORWARD_LINK 0x1A0144E0 /* Fallback move forward button */ -#define DIBUTTON_HOCKEYD_BACK_LINK 0x1A0144E8 /* Fallback move back button */ -#define DIBUTTON_HOCKEYD_DEVICE 0x1A0044FE /* Show input device and controls */ -#define DIBUTTON_HOCKEYD_PAUSE 0x1A0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Hockey - Goalie - Goal tending ---*/ -#define DIVIRTUAL_SPORTS_HOCKEY_GOALIE 0x1B000000 -#define DIAXIS_HOCKEYG_LATERAL 0x1B008201 /* Move / Aim: left / right */ -#define DIAXIS_HOCKEYG_MOVE 0x1B010202 /* Move / Aim: up / down */ -#define DIBUTTON_HOCKEYG_PASS 0x1B000401 /* pass puck */ -#define DIBUTTON_HOCKEYG_POKE 0x1B000402 /* poke / check / hack */ -#define DIBUTTON_HOCKEYG_STEAL 0x1B000403 /* attempt steal */ -#define DIBUTTON_HOCKEYG_BLOCK 0x1B000404 /* block puck */ -#define DIBUTTON_HOCKEYG_MENU 0x1B0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_HOCKEYG_SCROLL 0x1B004601 /* scroll view */ -#define DIBUTTON_HOCKEYG_ZOOM 0x1B004405 /* Zoom view in / out */ -#define DIBUTTON_HOCKEYG_STRATEGY 0x1B004406 /* Invoke coaching menu for strategy help */ -#define DIBUTTON_HOCKEYG_TIMEOUT 0x1B004407 /* Call for time out */ -#define DIBUTTON_HOCKEYG_SUBSTITUTE 0x1B004408 /* substitute one player for another */ -#define DIBUTTON_HOCKEYG_LEFT_LINK 0x1B00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_HOCKEYG_RIGHT_LINK 0x1B00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_HOCKEYG_FORWARD_LINK 0x1B0144E0 /* Fallback move forward button */ -#define DIBUTTON_HOCKEYG_BACK_LINK 0x1B0144E8 /* Fallback move back button */ -#define DIBUTTON_HOCKEYG_DEVICE 0x1B0044FE /* Show input device and controls */ -#define DIBUTTON_HOCKEYG_PAUSE 0x1B0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Mountain Biking - ---*/ -#define DIVIRTUAL_SPORTS_BIKING_MOUNTAIN 0x1C000000 -#define DIAXIS_BIKINGM_TURN 0x1C008201 /* left / right */ -#define DIAXIS_BIKINGM_PEDAL 0x1C010202 /* Pedal faster / slower / brake */ -#define DIBUTTON_BIKINGM_JUMP 0x1C000401 /* jump over obstacle */ -#define DIBUTTON_BIKINGM_CAMERA 0x1C000402 /* switch camera view */ -#define DIBUTTON_BIKINGM_SPECIAL1 0x1C000403 /* perform first special move */ -#define DIBUTTON_BIKINGM_SELECT 0x1C000404 /* Select */ -#define DIBUTTON_BIKINGM_SPECIAL2 0x1C000405 /* perform second special move */ -#define DIBUTTON_BIKINGM_MENU 0x1C0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_BIKINGM_SCROLL 0x1C004601 /* scroll view */ -#define DIBUTTON_BIKINGM_ZOOM 0x1C004406 /* Zoom view in / out */ -#define DIAXIS_BIKINGM_BRAKE 0x1C044203 /* Brake axis */ -#define DIBUTTON_BIKINGM_LEFT_LINK 0x1C00C4E4 /* Fallback turn left button */ -#define DIBUTTON_BIKINGM_RIGHT_LINK 0x1C00C4EC /* Fallback turn right button */ -#define DIBUTTON_BIKINGM_FASTER_LINK 0x1C0144E0 /* Fallback pedal faster button */ -#define DIBUTTON_BIKINGM_SLOWER_LINK 0x1C0144E8 /* Fallback pedal slower button */ -#define DIBUTTON_BIKINGM_BRAKE_BUTTON_LINK 0x1C0444E8 /* Fallback brake button */ -#define DIBUTTON_BIKINGM_DEVICE 0x1C0044FE /* Show input device and controls */ -#define DIBUTTON_BIKINGM_PAUSE 0x1C0044FC /* Start / Pause / Restart game */ - -/*--- Sports: Skiing / Snowboarding / Skateboarding - ---*/ -#define DIVIRTUAL_SPORTS_SKIING 0x1D000000 -#define DIAXIS_SKIING_TURN 0x1D008201 /* left / right */ -#define DIAXIS_SKIING_SPEED 0x1D010202 /* faster / slower */ -#define DIBUTTON_SKIING_JUMP 0x1D000401 /* Jump */ -#define DIBUTTON_SKIING_CROUCH 0x1D000402 /* crouch down */ -#define DIBUTTON_SKIING_CAMERA 0x1D000403 /* switch camera view */ -#define DIBUTTON_SKIING_SPECIAL1 0x1D000404 /* perform first special move */ -#define DIBUTTON_SKIING_SELECT 0x1D000405 /* Select */ -#define DIBUTTON_SKIING_SPECIAL2 0x1D000406 /* perform second special move */ -#define DIBUTTON_SKIING_MENU 0x1D0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_SKIING_GLANCE 0x1D004601 /* scroll view */ -#define DIBUTTON_SKIING_ZOOM 0x1D004407 /* Zoom view in / out */ -#define DIBUTTON_SKIING_LEFT_LINK 0x1D00C4E4 /* Fallback turn left button */ -#define DIBUTTON_SKIING_RIGHT_LINK 0x1D00C4EC /* Fallback turn right button */ -#define DIBUTTON_SKIING_FASTER_LINK 0x1D0144E0 /* Fallback increase speed button */ -#define DIBUTTON_SKIING_SLOWER_LINK 0x1D0144E8 /* Fallback decrease speed button */ -#define DIBUTTON_SKIING_DEVICE 0x1D0044FE /* Show input device and controls */ -#define DIBUTTON_SKIING_PAUSE 0x1D0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Soccer - Offense - Offense ---*/ -#define DIVIRTUAL_SPORTS_SOCCER_OFFENSE 0x1E000000 -#define DIAXIS_SOCCERO_LATERAL 0x1E008201 /* Move / Aim: left / right */ -#define DIAXIS_SOCCERO_MOVE 0x1E010202 /* Move / Aim: up / down */ -#define DIAXIS_SOCCERO_BEND 0x1E018203 /* Bend to soccer shot/pass */ -#define DIBUTTON_SOCCERO_SHOOT 0x1E000401 /* Shoot the ball */ -#define DIBUTTON_SOCCERO_PASS 0x1E000402 /* Pass */ -#define DIBUTTON_SOCCERO_FAKE 0x1E000403 /* Fake */ -#define DIBUTTON_SOCCERO_PLAYER 0x1E000404 /* Select next player */ -#define DIBUTTON_SOCCERO_SPECIAL1 0x1E000405 /* Apply special move */ -#define DIBUTTON_SOCCERO_SELECT 0x1E000406 /* Select special move */ -#define DIBUTTON_SOCCERO_MENU 0x1E0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_SOCCERO_GLANCE 0x1E004601 /* scroll view */ -#define DIBUTTON_SOCCERO_SUBSTITUTE 0x1E004407 /* Substitute one player for another */ -#define DIBUTTON_SOCCERO_SHOOTLOW 0x1E004408 /* Shoot the ball low */ -#define DIBUTTON_SOCCERO_SHOOTHIGH 0x1E004409 /* Shoot the ball high */ -#define DIBUTTON_SOCCERO_PASSTHRU 0x1E00440A /* Make a thru pass */ -#define DIBUTTON_SOCCERO_SPRINT 0x1E00440B /* Sprint / turbo boost */ -#define DIBUTTON_SOCCERO_CONTROL 0x1E00440C /* Obtain control of the ball */ -#define DIBUTTON_SOCCERO_HEAD 0x1E00440D /* Attempt to head the ball */ -#define DIBUTTON_SOCCERO_LEFT_LINK 0x1E00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_SOCCERO_RIGHT_LINK 0x1E00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_SOCCERO_FORWARD_LINK 0x1E0144E0 /* Fallback move forward button */ -#define DIBUTTON_SOCCERO_BACK_LINK 0x1E0144E8 /* Fallback move back button */ -#define DIBUTTON_SOCCERO_DEVICE 0x1E0044FE /* Show input device and controls */ -#define DIBUTTON_SOCCERO_PAUSE 0x1E0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Soccer - Defense - Defense ---*/ -#define DIVIRTUAL_SPORTS_SOCCER_DEFENSE 0x1F000000 -#define DIAXIS_SOCCERD_LATERAL 0x1F008201 /* Move / Aim: left / right */ -#define DIAXIS_SOCCERD_MOVE 0x1F010202 /* Move / Aim: up / down */ -#define DIBUTTON_SOCCERD_BLOCK 0x1F000401 /* Attempt to block shot */ -#define DIBUTTON_SOCCERD_STEAL 0x1F000402 /* Attempt to steal ball */ -#define DIBUTTON_SOCCERD_FAKE 0x1F000403 /* Fake a block or a steal */ -#define DIBUTTON_SOCCERD_PLAYER 0x1F000404 /* Select next player */ -#define DIBUTTON_SOCCERD_SPECIAL 0x1F000405 /* Apply special move */ -#define DIBUTTON_SOCCERD_SELECT 0x1F000406 /* Select special move */ -#define DIBUTTON_SOCCERD_SLIDE 0x1F000407 /* Attempt a slide tackle */ -#define DIBUTTON_SOCCERD_MENU 0x1F0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_SOCCERD_GLANCE 0x1F004601 /* scroll view */ -#define DIBUTTON_SOCCERD_FOUL 0x1F004408 /* Initiate a foul / hard-foul */ -#define DIBUTTON_SOCCERD_HEAD 0x1F004409 /* Attempt a Header */ -#define DIBUTTON_SOCCERD_CLEAR 0x1F00440A /* Attempt to clear the ball down the field */ -#define DIBUTTON_SOCCERD_GOALIECHARGE 0x1F00440B /* Make the goalie charge out of the box */ -#define DIBUTTON_SOCCERD_SUBSTITUTE 0x1F00440C /* Substitute one player for another */ -#define DIBUTTON_SOCCERD_LEFT_LINK 0x1F00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_SOCCERD_RIGHT_LINK 0x1F00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_SOCCERD_FORWARD_LINK 0x1F0144E0 /* Fallback move forward button */ -#define DIBUTTON_SOCCERD_BACK_LINK 0x1F0144E8 /* Fallback move back button */ -#define DIBUTTON_SOCCERD_DEVICE 0x1F0044FE /* Show input device and controls */ -#define DIBUTTON_SOCCERD_PAUSE 0x1F0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Racquet - Tennis - Table-Tennis - Squash ---*/ -#define DIVIRTUAL_SPORTS_RACQUET 0x20000000 -#define DIAXIS_RACQUET_LATERAL 0x20008201 /* Move / Aim: left / right */ -#define DIAXIS_RACQUET_MOVE 0x20010202 /* Move / Aim: up / down */ -#define DIBUTTON_RACQUET_SWING 0x20000401 /* Swing racquet */ -#define DIBUTTON_RACQUET_BACKSWING 0x20000402 /* Swing backhand */ -#define DIBUTTON_RACQUET_SMASH 0x20000403 /* Smash shot */ -#define DIBUTTON_RACQUET_SPECIAL 0x20000404 /* Special shot */ -#define DIBUTTON_RACQUET_SELECT 0x20000405 /* Select special shot */ -#define DIBUTTON_RACQUET_MENU 0x200004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_RACQUET_GLANCE 0x20004601 /* scroll view */ -#define DIBUTTON_RACQUET_TIMEOUT 0x20004406 /* Call for time out */ -#define DIBUTTON_RACQUET_SUBSTITUTE 0x20004407 /* Substitute one player for another */ -#define DIBUTTON_RACQUET_LEFT_LINK 0x2000C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_RACQUET_RIGHT_LINK 0x2000C4EC /* Fallback sidestep right button */ -#define DIBUTTON_RACQUET_FORWARD_LINK 0x200144E0 /* Fallback move forward button */ -#define DIBUTTON_RACQUET_BACK_LINK 0x200144E8 /* Fallback move back button */ -#define DIBUTTON_RACQUET_DEVICE 0x200044FE /* Show input device and controls */ -#define DIBUTTON_RACQUET_PAUSE 0x200044FC /* Start / Pause / Restart game */ - -/*--- Arcade- 2D - Side to Side movement ---*/ -#define DIVIRTUAL_ARCADE_SIDE2SIDE 0x21000000 -#define DIAXIS_ARCADES_LATERAL 0x21008201 /* left / right */ -#define DIAXIS_ARCADES_MOVE 0x21010202 /* up / down */ -#define DIBUTTON_ARCADES_THROW 0x21000401 /* throw object */ -#define DIBUTTON_ARCADES_CARRY 0x21000402 /* carry object */ -#define DIBUTTON_ARCADES_ATTACK 0x21000403 /* attack */ -#define DIBUTTON_ARCADES_SPECIAL 0x21000404 /* apply special move */ -#define DIBUTTON_ARCADES_SELECT 0x21000405 /* select special move */ -#define DIBUTTON_ARCADES_MENU 0x210004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_ARCADES_VIEW 0x21004601 /* scroll view left / right / up / down */ -#define DIBUTTON_ARCADES_LEFT_LINK 0x2100C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_ARCADES_RIGHT_LINK 0x2100C4EC /* Fallback sidestep right button */ -#define DIBUTTON_ARCADES_FORWARD_LINK 0x210144E0 /* Fallback move forward button */ -#define DIBUTTON_ARCADES_BACK_LINK 0x210144E8 /* Fallback move back button */ -#define DIBUTTON_ARCADES_VIEW_UP_LINK 0x2107C4E0 /* Fallback scroll view up button */ -#define DIBUTTON_ARCADES_VIEW_DOWN_LINK 0x2107C4E8 /* Fallback scroll view down button */ -#define DIBUTTON_ARCADES_VIEW_LEFT_LINK 0x2107C4E4 /* Fallback scroll view left button */ -#define DIBUTTON_ARCADES_VIEW_RIGHT_LINK 0x2107C4EC /* Fallback scroll view right button */ -#define DIBUTTON_ARCADES_DEVICE 0x210044FE /* Show input device and controls */ -#define DIBUTTON_ARCADES_PAUSE 0x210044FC /* Start / Pause / Restart game */ - -/*--- Arcade - Platform Game - Character moves around on screen ---*/ -#define DIVIRTUAL_ARCADE_PLATFORM 0x22000000 -#define DIAXIS_ARCADEP_LATERAL 0x22008201 /* Left / right */ -#define DIAXIS_ARCADEP_MOVE 0x22010202 /* Up / down */ -#define DIBUTTON_ARCADEP_JUMP 0x22000401 /* Jump */ -#define DIBUTTON_ARCADEP_FIRE 0x22000402 /* Fire */ -#define DIBUTTON_ARCADEP_CROUCH 0x22000403 /* Crouch */ -#define DIBUTTON_ARCADEP_SPECIAL 0x22000404 /* Apply special move */ -#define DIBUTTON_ARCADEP_SELECT 0x22000405 /* Select special move */ -#define DIBUTTON_ARCADEP_MENU 0x220004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_ARCADEP_VIEW 0x22004601 /* Scroll view */ -#define DIBUTTON_ARCADEP_FIRESECONDARY 0x22004406 /* Alternative fire button */ -#define DIBUTTON_ARCADEP_LEFT_LINK 0x2200C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_ARCADEP_RIGHT_LINK 0x2200C4EC /* Fallback sidestep right button */ -#define DIBUTTON_ARCADEP_FORWARD_LINK 0x220144E0 /* Fallback move forward button */ -#define DIBUTTON_ARCADEP_BACK_LINK 0x220144E8 /* Fallback move back button */ -#define DIBUTTON_ARCADEP_VIEW_UP_LINK 0x2207C4E0 /* Fallback scroll view up button */ -#define DIBUTTON_ARCADEP_VIEW_DOWN_LINK 0x2207C4E8 /* Fallback scroll view down button */ -#define DIBUTTON_ARCADEP_VIEW_LEFT_LINK 0x2207C4E4 /* Fallback scroll view left button */ -#define DIBUTTON_ARCADEP_VIEW_RIGHT_LINK 0x2207C4EC /* Fallback scroll view right button */ -#define DIBUTTON_ARCADEP_DEVICE 0x220044FE /* Show input device and controls */ -#define DIBUTTON_ARCADEP_PAUSE 0x220044FC /* Start / Pause / Restart game */ - -/*--- CAD - 2D Object Control - Controls to select and move objects in 2D ---*/ -#define DIVIRTUAL_CAD_2DCONTROL 0x23000000 -#define DIAXIS_2DCONTROL_LATERAL 0x23008201 /* Move view left / right */ -#define DIAXIS_2DCONTROL_MOVE 0x23010202 /* Move view up / down */ -#define DIAXIS_2DCONTROL_INOUT 0x23018203 /* Zoom - in / out */ -#define DIBUTTON_2DCONTROL_SELECT 0x23000401 /* Select Object */ -#define DIBUTTON_2DCONTROL_SPECIAL1 0x23000402 /* Do first special operation */ -#define DIBUTTON_2DCONTROL_SPECIAL 0x23000403 /* Select special operation */ -#define DIBUTTON_2DCONTROL_SPECIAL2 0x23000404 /* Do second special operation */ -#define DIBUTTON_2DCONTROL_MENU 0x230004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_2DCONTROL_HATSWITCH 0x23004601 /* Hat switch */ -#define DIAXIS_2DCONTROL_ROTATEZ 0x23024204 /* Rotate view clockwise / counterclockwise */ -#define DIBUTTON_2DCONTROL_DISPLAY 0x23004405 /* Shows next on-screen display options */ -#define DIBUTTON_2DCONTROL_DEVICE 0x230044FE /* Show input device and controls */ -#define DIBUTTON_2DCONTROL_PAUSE 0x230044FC /* Start / Pause / Restart game */ - -/*--- CAD - 3D object control - Controls to select and move objects within a 3D environment ---*/ -#define DIVIRTUAL_CAD_3DCONTROL 0x24000000 -#define DIAXIS_3DCONTROL_LATERAL 0x24008201 /* Move view left / right */ -#define DIAXIS_3DCONTROL_MOVE 0x24010202 /* Move view up / down */ -#define DIAXIS_3DCONTROL_INOUT 0x24018203 /* Zoom - in / out */ -#define DIBUTTON_3DCONTROL_SELECT 0x24000401 /* Select Object */ -#define DIBUTTON_3DCONTROL_SPECIAL1 0x24000402 /* Do first special operation */ -#define DIBUTTON_3DCONTROL_SPECIAL 0x24000403 /* Select special operation */ -#define DIBUTTON_3DCONTROL_SPECIAL2 0x24000404 /* Do second special operation */ -#define DIBUTTON_3DCONTROL_MENU 0x240004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_3DCONTROL_HATSWITCH 0x24004601 /* Hat switch */ -#define DIAXIS_3DCONTROL_ROTATEX 0x24034204 /* Rotate view forward or up / backward or down */ -#define DIAXIS_3DCONTROL_ROTATEY 0x2402C205 /* Rotate view clockwise / counterclockwise */ -#define DIAXIS_3DCONTROL_ROTATEZ 0x24024206 /* Rotate view left / right */ -#define DIBUTTON_3DCONTROL_DISPLAY 0x24004405 /* Show next on-screen display options */ -#define DIBUTTON_3DCONTROL_DEVICE 0x240044FE /* Show input device and controls */ -#define DIBUTTON_3DCONTROL_PAUSE 0x240044FC /* Start / Pause / Restart game */ - -/*--- CAD - 3D Navigation - Fly through - Controls for 3D modeling ---*/ -#define DIVIRTUAL_CAD_FLYBY 0x25000000 -#define DIAXIS_CADF_LATERAL 0x25008201 /* move view left / right */ -#define DIAXIS_CADF_MOVE 0x25010202 /* move view up / down */ -#define DIAXIS_CADF_INOUT 0x25018203 /* in / out */ -#define DIBUTTON_CADF_SELECT 0x25000401 /* Select Object */ -#define DIBUTTON_CADF_SPECIAL1 0x25000402 /* do first special operation */ -#define DIBUTTON_CADF_SPECIAL 0x25000403 /* Select special operation */ -#define DIBUTTON_CADF_SPECIAL2 0x25000404 /* do second special operation */ -#define DIBUTTON_CADF_MENU 0x250004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_CADF_HATSWITCH 0x25004601 /* Hat switch */ -#define DIAXIS_CADF_ROTATEX 0x25034204 /* Rotate view forward or up / backward or down */ -#define DIAXIS_CADF_ROTATEY 0x2502C205 /* Rotate view clockwise / counterclockwise */ -#define DIAXIS_CADF_ROTATEZ 0x25024206 /* Rotate view left / right */ -#define DIBUTTON_CADF_DISPLAY 0x25004405 /* shows next on-screen display options */ -#define DIBUTTON_CADF_DEVICE 0x250044FE /* Show input device and controls */ -#define DIBUTTON_CADF_PAUSE 0x250044FC /* Start / Pause / Restart game */ - -/*--- CAD - 3D Model Control - Controls for 3D modeling ---*/ -#define DIVIRTUAL_CAD_MODEL 0x26000000 -#define DIAXIS_CADM_LATERAL 0x26008201 /* move view left / right */ -#define DIAXIS_CADM_MOVE 0x26010202 /* move view up / down */ -#define DIAXIS_CADM_INOUT 0x26018203 /* in / out */ -#define DIBUTTON_CADM_SELECT 0x26000401 /* Select Object */ -#define DIBUTTON_CADM_SPECIAL1 0x26000402 /* do first special operation */ -#define DIBUTTON_CADM_SPECIAL 0x26000403 /* Select special operation */ -#define DIBUTTON_CADM_SPECIAL2 0x26000404 /* do second special operation */ -#define DIBUTTON_CADM_MENU 0x260004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_CADM_HATSWITCH 0x26004601 /* Hat switch */ -#define DIAXIS_CADM_ROTATEX 0x26034204 /* Rotate view forward or up / backward or down */ -#define DIAXIS_CADM_ROTATEY 0x2602C205 /* Rotate view clockwise / counterclockwise */ -#define DIAXIS_CADM_ROTATEZ 0x26024206 /* Rotate view left / right */ -#define DIBUTTON_CADM_DISPLAY 0x26004405 /* shows next on-screen display options */ -#define DIBUTTON_CADM_DEVICE 0x260044FE /* Show input device and controls */ -#define DIBUTTON_CADM_PAUSE 0x260044FC /* Start / Pause / Restart game */ - -/*--- Control - Media Equipment - Remote ---*/ -#define DIVIRTUAL_REMOTE_CONTROL 0x27000000 -#define DIAXIS_REMOTE_SLIDER 0x27050201 /* Slider for adjustment: volume / color / bass / etc */ -#define DIBUTTON_REMOTE_MUTE 0x27000401 /* Set volume on current device to zero */ -#define DIBUTTON_REMOTE_SELECT 0x27000402 /* Next/previous: channel/ track / chapter / picture / station */ -#define DIBUTTON_REMOTE_PLAY 0x27002403 /* Start or pause entertainment on current device */ -#define DIBUTTON_REMOTE_CUE 0x27002404 /* Move through current media */ -#define DIBUTTON_REMOTE_REVIEW 0x27002405 /* Move through current media */ -#define DIBUTTON_REMOTE_CHANGE 0x27002406 /* Select next device */ -#define DIBUTTON_REMOTE_RECORD 0x27002407 /* Start recording the current media */ -#define DIBUTTON_REMOTE_MENU 0x270004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIAXIS_REMOTE_SLIDER2 0x27054202 /* Slider for adjustment: volume */ -#define DIBUTTON_REMOTE_TV 0x27005C08 /* Select TV */ -#define DIBUTTON_REMOTE_CABLE 0x27005C09 /* Select cable box */ -#define DIBUTTON_REMOTE_CD 0x27005C0A /* Select CD player */ -#define DIBUTTON_REMOTE_VCR 0x27005C0B /* Select VCR */ -#define DIBUTTON_REMOTE_TUNER 0x27005C0C /* Select tuner */ -#define DIBUTTON_REMOTE_DVD 0x27005C0D /* Select DVD player */ -#define DIBUTTON_REMOTE_ADJUST 0x27005C0E /* Enter device adjustment menu */ -#define DIBUTTON_REMOTE_DIGIT0 0x2700540F /* Digit 0 */ -#define DIBUTTON_REMOTE_DIGIT1 0x27005410 /* Digit 1 */ -#define DIBUTTON_REMOTE_DIGIT2 0x27005411 /* Digit 2 */ -#define DIBUTTON_REMOTE_DIGIT3 0x27005412 /* Digit 3 */ -#define DIBUTTON_REMOTE_DIGIT4 0x27005413 /* Digit 4 */ -#define DIBUTTON_REMOTE_DIGIT5 0x27005414 /* Digit 5 */ -#define DIBUTTON_REMOTE_DIGIT6 0x27005415 /* Digit 6 */ -#define DIBUTTON_REMOTE_DIGIT7 0x27005416 /* Digit 7 */ -#define DIBUTTON_REMOTE_DIGIT8 0x27005417 /* Digit 8 */ -#define DIBUTTON_REMOTE_DIGIT9 0x27005418 /* Digit 9 */ -#define DIBUTTON_REMOTE_DEVICE 0x270044FE /* Show input device and controls */ -#define DIBUTTON_REMOTE_PAUSE 0x270044FC /* Start / Pause / Restart game */ - -/*--- Control- Web - Help or Browser ---*/ -#define DIVIRTUAL_BROWSER_CONTROL 0x28000000 -#define DIAXIS_BROWSER_LATERAL 0x28008201 /* Move on screen pointer */ -#define DIAXIS_BROWSER_MOVE 0x28010202 /* Move on screen pointer */ -#define DIBUTTON_BROWSER_SELECT 0x28000401 /* Select current item */ -#define DIAXIS_BROWSER_VIEW 0x28018203 /* Move view up/down */ -#define DIBUTTON_BROWSER_REFRESH 0x28000402 /* Refresh */ -#define DIBUTTON_BROWSER_MENU 0x280004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_BROWSER_SEARCH 0x28004403 /* Use search tool */ -#define DIBUTTON_BROWSER_STOP 0x28004404 /* Cease current update */ -#define DIBUTTON_BROWSER_HOME 0x28004405 /* Go directly to "home" location */ -#define DIBUTTON_BROWSER_FAVORITES 0x28004406 /* Mark current site as favorite */ -#define DIBUTTON_BROWSER_NEXT 0x28004407 /* Select Next page */ -#define DIBUTTON_BROWSER_PREVIOUS 0x28004408 /* Select Previous page */ -#define DIBUTTON_BROWSER_HISTORY 0x28004409 /* Show/Hide History */ -#define DIBUTTON_BROWSER_PRINT 0x2800440A /* Print current page */ -#define DIBUTTON_BROWSER_DEVICE 0x280044FE /* Show input device and controls */ -#define DIBUTTON_BROWSER_PAUSE 0x280044FC /* Start / Pause / Restart game */ - -/*--- Driving Simulator - Giant Walking Robot - Walking tank with weapons ---*/ -#define DIVIRTUAL_DRIVING_MECHA 0x29000000 -#define DIAXIS_MECHA_STEER 0x29008201 /* Turns mecha left/right */ -#define DIAXIS_MECHA_TORSO 0x29010202 /* Tilts torso forward/backward */ -#define DIAXIS_MECHA_ROTATE 0x29020203 /* Turns torso left/right */ -#define DIAXIS_MECHA_THROTTLE 0x29038204 /* Engine Speed */ -#define DIBUTTON_MECHA_FIRE 0x29000401 /* Fire */ -#define DIBUTTON_MECHA_WEAPONS 0x29000402 /* Select next weapon group */ -#define DIBUTTON_MECHA_TARGET 0x29000403 /* Select closest enemy available target */ -#define DIBUTTON_MECHA_REVERSE 0x29000404 /* Toggles throttle in/out of reverse */ -#define DIBUTTON_MECHA_ZOOM 0x29000405 /* Zoom in/out targeting reticule */ -#define DIBUTTON_MECHA_JUMP 0x29000406 /* Fires jump jets */ -#define DIBUTTON_MECHA_MENU 0x290004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_MECHA_CENTER 0x29004407 /* Center torso to legs */ -#define DIHATSWITCH_MECHA_GLANCE 0x29004601 /* Look around */ -#define DIBUTTON_MECHA_VIEW 0x29004408 /* Cycle through view options */ -#define DIBUTTON_MECHA_FIRESECONDARY 0x29004409 /* Alternative fire button */ -#define DIBUTTON_MECHA_LEFT_LINK 0x2900C4E4 /* Fallback steer left button */ -#define DIBUTTON_MECHA_RIGHT_LINK 0x2900C4EC /* Fallback steer right button */ -#define DIBUTTON_MECHA_FORWARD_LINK 0x290144E0 /* Fallback tilt torso forward button */ -#define DIBUTTON_MECHA_BACK_LINK 0x290144E8 /* Fallback tilt toroso backward button */ -#define DIBUTTON_MECHA_ROTATE_LEFT_LINK 0x290244E4 /* Fallback rotate toroso right button */ -#define DIBUTTON_MECHA_ROTATE_RIGHT_LINK 0x290244EC /* Fallback rotate torso left button */ -#define DIBUTTON_MECHA_FASTER_LINK 0x2903C4E0 /* Fallback increase engine speed */ -#define DIBUTTON_MECHA_SLOWER_LINK 0x2903C4E8 /* Fallback decrease engine speed */ -#define DIBUTTON_MECHA_DEVICE 0x290044FE /* Show input device and controls */ -#define DIBUTTON_MECHA_PAUSE 0x290044FC /* Start / Pause / Restart game */ - -/* - * "ANY" semantics can be used as a last resort to get mappings for actions - * that match nothing in the chosen virtual genre. These semantics will be - * mapped at a lower priority that virtual genre semantics. Also, hardware - * vendors will not be able to provide sensible mappings for these unless - * they provide application specific mappings. - */ -#define DIAXIS_ANY_X_1 0xFF00C201 -#define DIAXIS_ANY_X_2 0xFF00C202 -#define DIAXIS_ANY_Y_1 0xFF014201 -#define DIAXIS_ANY_Y_2 0xFF014202 -#define DIAXIS_ANY_Z_1 0xFF01C201 -#define DIAXIS_ANY_Z_2 0xFF01C202 -#define DIAXIS_ANY_R_1 0xFF024201 -#define DIAXIS_ANY_R_2 0xFF024202 -#define DIAXIS_ANY_U_1 0xFF02C201 -#define DIAXIS_ANY_U_2 0xFF02C202 -#define DIAXIS_ANY_V_1 0xFF034201 -#define DIAXIS_ANY_V_2 0xFF034202 -#define DIAXIS_ANY_A_1 0xFF03C201 -#define DIAXIS_ANY_A_2 0xFF03C202 -#define DIAXIS_ANY_B_1 0xFF044201 -#define DIAXIS_ANY_B_2 0xFF044202 -#define DIAXIS_ANY_C_1 0xFF04C201 -#define DIAXIS_ANY_C_2 0xFF04C202 -#define DIAXIS_ANY_S_1 0xFF054201 -#define DIAXIS_ANY_S_2 0xFF054202 - -#define DIAXIS_ANY_1 0xFF004201 -#define DIAXIS_ANY_2 0xFF004202 -#define DIAXIS_ANY_3 0xFF004203 -#define DIAXIS_ANY_4 0xFF004204 - -#define DIPOV_ANY_1 0xFF004601 -#define DIPOV_ANY_2 0xFF004602 -#define DIPOV_ANY_3 0xFF004603 -#define DIPOV_ANY_4 0xFF004604 - -#define DIBUTTON_ANY(instance) ( 0xFF004400 | instance ) - - -#ifdef __cplusplus -}; -#endif - -#endif /* __DINPUT_INCLUDED__ */ - -/**************************************************************************** - * - * Definitions for non-IDirectInput (VJoyD) features defined more recently - * than the current sdk files - * - ****************************************************************************/ - -#ifdef _INC_MMSYSTEM -#ifndef MMNOJOY - -#ifndef __VJOYDX_INCLUDED__ -#define __VJOYDX_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Flag to indicate that the dwReserved2 field of the JOYINFOEX structure - * contains mini-driver specific data to be passed by VJoyD to the mini- - * driver instead of doing a poll. - */ -#define JOY_PASSDRIVERDATA 0x10000000l - -/* - * Informs the joystick driver that the configuration has been changed - * and should be reloaded from the registery. - * dwFlags is reserved and should be set to zero - */ -WINMMAPI MMRESULT WINAPI joyConfigChanged( DWORD dwFlags ); - -#ifndef DIJ_RINGZERO -/* - * Invoke the joystick control panel directly, using the passed window handle - * as the parent of the dialog. This API is only supported for compatibility - * purposes; new applications should use the RunControlPanel method of a - * device interface for a game controller. - * The API is called by using the function pointer returned by - * GetProcAddress( hCPL, TEXT("ShowJoyCPL") ) where hCPL is a HMODULE returned - * by LoadLibrary( TEXT("joy.cpl") ). The typedef is provided to allow - * declaration and casting of an appropriately typed variable. - */ -void WINAPI ShowJoyCPL( HWND hWnd ); -typedef void (WINAPI* LPFNSHOWJOYCPL)( HWND hWnd ); -#endif /* DIJ_RINGZERO */ - - -/* - * Hardware Setting indicating that the device is a headtracker - */ -#define JOY_HWS_ISHEADTRACKER 0x02000000l - -/* - * Hardware Setting indicating that the VxD is used to replace - * the standard analog polling - */ -#define JOY_HWS_ISGAMEPORTDRIVER 0x04000000l - -/* - * Hardware Setting indicating that the driver needs a standard - * gameport in order to communicate with the device. - */ -#define JOY_HWS_ISANALOGPORTDRIVER 0x08000000l - -/* - * Hardware Setting indicating that VJoyD should not load this - * driver, it will be loaded externally and will register with - * VJoyD of it's own accord. - */ -#define JOY_HWS_AUTOLOAD 0x10000000l - -/* - * Hardware Setting indicating that the driver acquires any - * resources needed without needing a devnode through VJoyD. - */ -#define JOY_HWS_NODEVNODE 0x20000000l - - -/* - * Hardware Setting indicating that the device is a gameport bus - */ -#define JOY_HWS_ISGAMEPORTBUS 0x80000000l -#define JOY_HWS_GAMEPORTBUSBUSY 0x00000001l - -/* - * Usage Setting indicating that the settings are volatile and - * should be removed if still present on a reboot. - */ -#define JOY_US_VOLATILE 0x00000008L - -#ifdef __cplusplus -}; -#endif - -#endif /* __VJOYDX_INCLUDED__ */ - -#endif /* not MMNOJOY */ -#endif /* _INC_MMSYSTEM */ - -/**************************************************************************** - * - * Definitions for non-IDirectInput (VJoyD) features defined more recently - * than the current ddk files - * - ****************************************************************************/ - -#ifndef DIJ_RINGZERO - -#ifdef _INC_MMDDK -#ifndef MMNOJOYDEV - -#ifndef __VJOYDXD_INCLUDED__ -#define __VJOYDXD_INCLUDED__ -/* - * Poll type in which the do_other field of the JOYOEMPOLLDATA - * structure contains mini-driver specific data passed from an app. - */ -#define JOY_OEMPOLL_PASSDRIVERDATA 7 - -#endif /* __VJOYDXD_INCLUDED__ */ - -#endif /* not MMNOJOYDEV */ -#endif /* _INC_MMDDK */ - -#endif /* DIJ_RINGZERO */ - +/**************************************************************************** + * + * Copyright (C) 1996-2000 Microsoft Corporation. All Rights Reserved. + * + * File: dinput.h + * Content: DirectInput include file + * + ****************************************************************************/ + +#ifndef __DINPUT_INCLUDED__ +#define __DINPUT_INCLUDED__ + +#ifndef DIJ_RINGZERO + +#ifdef _WIN32 +#define COM_NO_WINDOWS_H +#include +#endif + +#endif /* DIJ_RINGZERO */ + +#ifdef __cplusplus +extern "C" { +#endif + + + + + +/* + * To build applications for older versions of DirectInput + * + * #define DIRECTINPUT_VERSION [ 0x0300 | 0x0500 | 0x0700 ] + * + * before #include . By default, #include + * will produce a DirectX 8-compatible header file. + * + */ + +#define DIRECTINPUT_HEADER_VERSION 0x0800 +#ifndef DIRECTINPUT_VERSION +#define DIRECTINPUT_VERSION DIRECTINPUT_HEADER_VERSION +#pragma message(__FILE__ ": DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800") +#endif + +#ifndef DIJ_RINGZERO + +/**************************************************************************** + * + * Class IDs + * + ****************************************************************************/ + +DEFINE_GUID(CLSID_DirectInput, 0x25E609E0,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(CLSID_DirectInputDevice, 0x25E609E1,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +DEFINE_GUID(CLSID_DirectInput8, 0x25E609E4,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(CLSID_DirectInputDevice8,0x25E609E5,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +/**************************************************************************** + * + * Interfaces + * + ****************************************************************************/ + +DEFINE_GUID(IID_IDirectInputA, 0x89521360,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputW, 0x89521361,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInput2A, 0x5944E662,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInput2W, 0x5944E663,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInput7A, 0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); +DEFINE_GUID(IID_IDirectInput7W, 0x9A4CB685,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); +DEFINE_GUID(IID_IDirectInput8A, 0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00); +DEFINE_GUID(IID_IDirectInput8W, 0xBF798031,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00); +DEFINE_GUID(IID_IDirectInputDeviceA, 0x5944E680,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputDeviceW, 0x5944E681,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputDevice2A,0x5944E682,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputDevice2W,0x5944E683,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputDevice7A,0x57D7C6BC,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); +DEFINE_GUID(IID_IDirectInputDevice7W,0x57D7C6BD,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); +DEFINE_GUID(IID_IDirectInputDevice8A,0x54D41080,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79); +DEFINE_GUID(IID_IDirectInputDevice8W,0x54D41081,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79); +DEFINE_GUID(IID_IDirectInputEffect, 0xE7E1F7C0,0x88D2,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); + +/**************************************************************************** + * + * Predefined object types + * + ****************************************************************************/ + +DEFINE_GUID(GUID_XAxis, 0xA36D02E0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_YAxis, 0xA36D02E1,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_ZAxis, 0xA36D02E2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_RxAxis, 0xA36D02F4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_RyAxis, 0xA36D02F5,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_RzAxis, 0xA36D02E3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_Slider, 0xA36D02E4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +DEFINE_GUID(GUID_Button, 0xA36D02F0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_Key, 0x55728220,0xD33C,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +DEFINE_GUID(GUID_POV, 0xA36D02F2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +DEFINE_GUID(GUID_Unknown, 0xA36D02F3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +/**************************************************************************** + * + * Predefined product GUIDs + * + ****************************************************************************/ + +DEFINE_GUID(GUID_SysMouse, 0x6F1D2B60,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysKeyboard,0x6F1D2B61,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_Joystick ,0x6F1D2B70,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysMouseEm, 0x6F1D2B80,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysMouseEm2,0x6F1D2B81,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysKeyboardEm, 0x6F1D2B82,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysKeyboardEm2,0x6F1D2B83,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +/**************************************************************************** + * + * Predefined force feedback effects + * + ****************************************************************************/ + +DEFINE_GUID(GUID_ConstantForce, 0x13541C20,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_RampForce, 0x13541C21,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Square, 0x13541C22,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Sine, 0x13541C23,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Triangle, 0x13541C24,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_SawtoothUp, 0x13541C25,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_SawtoothDown, 0x13541C26,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Spring, 0x13541C27,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Damper, 0x13541C28,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Inertia, 0x13541C29,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Friction, 0x13541C2A,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_CustomForce, 0x13541C2B,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); + +#endif /* DIJ_RINGZERO */ + +/**************************************************************************** + * + * Interfaces and Structures... + * + ****************************************************************************/ + +#if(DIRECTINPUT_VERSION >= 0x0500) + +/**************************************************************************** + * + * IDirectInputEffect + * + ****************************************************************************/ + +#define DIEFT_ALL 0x00000000 + +#define DIEFT_CONSTANTFORCE 0x00000001 +#define DIEFT_RAMPFORCE 0x00000002 +#define DIEFT_PERIODIC 0x00000003 +#define DIEFT_CONDITION 0x00000004 +#define DIEFT_CUSTOMFORCE 0x00000005 +#define DIEFT_HARDWARE 0x000000FF +#define DIEFT_FFATTACK 0x00000200 +#define DIEFT_FFFADE 0x00000400 +#define DIEFT_SATURATION 0x00000800 +#define DIEFT_POSNEGCOEFFICIENTS 0x00001000 +#define DIEFT_POSNEGSATURATION 0x00002000 +#define DIEFT_DEADBAND 0x00004000 +#define DIEFT_STARTDELAY 0x00008000 +#define DIEFT_GETTYPE(n) LOBYTE(n) + +#define DI_DEGREES 100 +#define DI_FFNOMINALMAX 10000 +#define DI_SECONDS 1000000 + +typedef struct DICONSTANTFORCE { + LONG lMagnitude; +} DICONSTANTFORCE, *LPDICONSTANTFORCE; +typedef const DICONSTANTFORCE *LPCDICONSTANTFORCE; + +typedef struct DIRAMPFORCE { + LONG lStart; + LONG lEnd; +} DIRAMPFORCE, *LPDIRAMPFORCE; +typedef const DIRAMPFORCE *LPCDIRAMPFORCE; + +typedef struct DIPERIODIC { + DWORD dwMagnitude; + LONG lOffset; + DWORD dwPhase; + DWORD dwPeriod; +} DIPERIODIC, *LPDIPERIODIC; +typedef const DIPERIODIC *LPCDIPERIODIC; + +typedef struct DICONDITION { + LONG lOffset; + LONG lPositiveCoefficient; + LONG lNegativeCoefficient; + DWORD dwPositiveSaturation; + DWORD dwNegativeSaturation; + LONG lDeadBand; +} DICONDITION, *LPDICONDITION; +typedef const DICONDITION *LPCDICONDITION; + +typedef struct DICUSTOMFORCE { + DWORD cChannels; + DWORD dwSamplePeriod; + DWORD cSamples; + LPLONG rglForceData; +} DICUSTOMFORCE, *LPDICUSTOMFORCE; +typedef const DICUSTOMFORCE *LPCDICUSTOMFORCE; + + +typedef struct DIENVELOPE { + DWORD dwSize; /* sizeof(DIENVELOPE) */ + DWORD dwAttackLevel; + DWORD dwAttackTime; /* Microseconds */ + DWORD dwFadeLevel; + DWORD dwFadeTime; /* Microseconds */ +} DIENVELOPE, *LPDIENVELOPE; +typedef const DIENVELOPE *LPCDIENVELOPE; + + +/* This structure is defined for DirectX 5.0 compatibility */ +typedef struct DIEFFECT_DX5 { + DWORD dwSize; /* sizeof(DIEFFECT_DX5) */ + DWORD dwFlags; /* DIEFF_* */ + DWORD dwDuration; /* Microseconds */ + DWORD dwSamplePeriod; /* Microseconds */ + DWORD dwGain; + DWORD dwTriggerButton; /* or DIEB_NOTRIGGER */ + DWORD dwTriggerRepeatInterval; /* Microseconds */ + DWORD cAxes; /* Number of axes */ + LPDWORD rgdwAxes; /* Array of axes */ + LPLONG rglDirection; /* Array of directions */ + LPDIENVELOPE lpEnvelope; /* Optional */ + DWORD cbTypeSpecificParams; /* Size of params */ + LPVOID lpvTypeSpecificParams; /* Pointer to params */ +} DIEFFECT_DX5, *LPDIEFFECT_DX5; +typedef const DIEFFECT_DX5 *LPCDIEFFECT_DX5; + +typedef struct DIEFFECT { + DWORD dwSize; /* sizeof(DIEFFECT) */ + DWORD dwFlags; /* DIEFF_* */ + DWORD dwDuration; /* Microseconds */ + DWORD dwSamplePeriod; /* Microseconds */ + DWORD dwGain; + DWORD dwTriggerButton; /* or DIEB_NOTRIGGER */ + DWORD dwTriggerRepeatInterval; /* Microseconds */ + DWORD cAxes; /* Number of axes */ + LPDWORD rgdwAxes; /* Array of axes */ + LPLONG rglDirection; /* Array of directions */ + LPDIENVELOPE lpEnvelope; /* Optional */ + DWORD cbTypeSpecificParams; /* Size of params */ + LPVOID lpvTypeSpecificParams; /* Pointer to params */ +#if(DIRECTINPUT_VERSION >= 0x0600) + DWORD dwStartDelay; /* Microseconds */ +#endif /* DIRECTINPUT_VERSION >= 0x0600 */ +} DIEFFECT, *LPDIEFFECT; +typedef DIEFFECT DIEFFECT_DX6; +typedef LPDIEFFECT LPDIEFFECT_DX6; +typedef const DIEFFECT *LPCDIEFFECT; + + +#if(DIRECTINPUT_VERSION >= 0x0700) +#ifndef DIJ_RINGZERO +typedef struct DIFILEEFFECT{ + DWORD dwSize; + GUID GuidEffect; + LPCDIEFFECT lpDiEffect; + CHAR szFriendlyName[MAX_PATH]; +}DIFILEEFFECT, *LPDIFILEEFFECT; +typedef const DIFILEEFFECT *LPCDIFILEEFFECT; +typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSINFILECALLBACK)(LPCDIFILEEFFECT , LPVOID); +#endif /* DIJ_RINGZERO */ +#endif /* DIRECTINPUT_VERSION >= 0x0700 */ + +#define DIEFF_OBJECTIDS 0x00000001 +#define DIEFF_OBJECTOFFSETS 0x00000002 +#define DIEFF_CARTESIAN 0x00000010 +#define DIEFF_POLAR 0x00000020 +#define DIEFF_SPHERICAL 0x00000040 + +#define DIEP_DURATION 0x00000001 +#define DIEP_SAMPLEPERIOD 0x00000002 +#define DIEP_GAIN 0x00000004 +#define DIEP_TRIGGERBUTTON 0x00000008 +#define DIEP_TRIGGERREPEATINTERVAL 0x00000010 +#define DIEP_AXES 0x00000020 +#define DIEP_DIRECTION 0x00000040 +#define DIEP_ENVELOPE 0x00000080 +#define DIEP_TYPESPECIFICPARAMS 0x00000100 +#if(DIRECTINPUT_VERSION >= 0x0600) +#define DIEP_STARTDELAY 0x00000200 +#define DIEP_ALLPARAMS_DX5 0x000001FF +#define DIEP_ALLPARAMS 0x000003FF +#else /* DIRECTINPUT_VERSION < 0x0600 */ +#define DIEP_ALLPARAMS 0x000001FF +#endif /* DIRECTINPUT_VERSION < 0x0600 */ +#define DIEP_START 0x20000000 +#define DIEP_NORESTART 0x40000000 +#define DIEP_NODOWNLOAD 0x80000000 +#define DIEB_NOTRIGGER 0xFFFFFFFF + +#define DIES_SOLO 0x00000001 +#define DIES_NODOWNLOAD 0x80000000 + +#define DIEGES_PLAYING 0x00000001 +#define DIEGES_EMULATED 0x00000002 + +typedef struct DIEFFESCAPE { + DWORD dwSize; + DWORD dwCommand; + LPVOID lpvInBuffer; + DWORD cbInBuffer; + LPVOID lpvOutBuffer; + DWORD cbOutBuffer; +} DIEFFESCAPE, *LPDIEFFESCAPE; + +#ifndef DIJ_RINGZERO + +#undef INTERFACE +#define INTERFACE IDirectInputEffect + +DECLARE_INTERFACE_(IDirectInputEffect, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputEffect methods ***/ + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(GetEffectGuid)(THIS_ LPGUID) PURE; + STDMETHOD(GetParameters)(THIS_ LPDIEFFECT,DWORD) PURE; + STDMETHOD(SetParameters)(THIS_ LPCDIEFFECT,DWORD) PURE; + STDMETHOD(Start)(THIS_ DWORD,DWORD) PURE; + STDMETHOD(Stop)(THIS) PURE; + STDMETHOD(GetEffectStatus)(THIS_ LPDWORD) PURE; + STDMETHOD(Download)(THIS) PURE; + STDMETHOD(Unload)(THIS) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; +}; + +typedef struct IDirectInputEffect *LPDIRECTINPUTEFFECT; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputEffect_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputEffect_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputEffect_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputEffect_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectInputEffect_GetEffectGuid(p,a) (p)->lpVtbl->GetEffectGuid(p,a) +#define IDirectInputEffect_GetParameters(p,a,b) (p)->lpVtbl->GetParameters(p,a,b) +#define IDirectInputEffect_SetParameters(p,a,b) (p)->lpVtbl->SetParameters(p,a,b) +#define IDirectInputEffect_Start(p,a,b) (p)->lpVtbl->Start(p,a,b) +#define IDirectInputEffect_Stop(p) (p)->lpVtbl->Stop(p) +#define IDirectInputEffect_GetEffectStatus(p,a) (p)->lpVtbl->GetEffectStatus(p,a) +#define IDirectInputEffect_Download(p) (p)->lpVtbl->Download(p) +#define IDirectInputEffect_Unload(p) (p)->lpVtbl->Unload(p) +#define IDirectInputEffect_Escape(p,a) (p)->lpVtbl->Escape(p,a) +#else +#define IDirectInputEffect_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputEffect_AddRef(p) (p)->AddRef() +#define IDirectInputEffect_Release(p) (p)->Release() +#define IDirectInputEffect_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectInputEffect_GetEffectGuid(p,a) (p)->GetEffectGuid(a) +#define IDirectInputEffect_GetParameters(p,a,b) (p)->GetParameters(a,b) +#define IDirectInputEffect_SetParameters(p,a,b) (p)->SetParameters(a,b) +#define IDirectInputEffect_Start(p,a,b) (p)->Start(a,b) +#define IDirectInputEffect_Stop(p) (p)->Stop() +#define IDirectInputEffect_GetEffectStatus(p,a) (p)->GetEffectStatus(a) +#define IDirectInputEffect_Download(p) (p)->Download() +#define IDirectInputEffect_Unload(p) (p)->Unload() +#define IDirectInputEffect_Escape(p,a) (p)->Escape(a) +#endif + +#endif /* DIJ_RINGZERO */ + +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +/**************************************************************************** + * + * IDirectInputDevice + * + ****************************************************************************/ + +#if DIRECTINPUT_VERSION <= 0x700 +#define DIDEVTYPE_DEVICE 1 +#define DIDEVTYPE_MOUSE 2 +#define DIDEVTYPE_KEYBOARD 3 +#define DIDEVTYPE_JOYSTICK 4 + +#else +#define DI8DEVCLASS_ALL 0 +#define DI8DEVCLASS_DEVICE 1 +#define DI8DEVCLASS_POINTER 2 +#define DI8DEVCLASS_KEYBOARD 3 +#define DI8DEVCLASS_GAMECTRL 4 + +#define DI8DEVTYPE_DEVICE 0x11 +#define DI8DEVTYPE_MOUSE 0x12 +#define DI8DEVTYPE_KEYBOARD 0x13 +#define DI8DEVTYPE_JOYSTICK 0x14 +#define DI8DEVTYPE_GAMEPAD 0x15 +#define DI8DEVTYPE_DRIVING 0x16 +#define DI8DEVTYPE_FLIGHT 0x17 +#define DI8DEVTYPE_1STPERSON 0x18 +#define DI8DEVTYPE_DEVICECTRL 0x19 +#define DI8DEVTYPE_SCREENPOINTER 0x1A +#define DI8DEVTYPE_REMOTE 0x1B +#define DI8DEVTYPE_SUPPLEMENTAL 0x1C +#endif /* DIRECTINPUT_VERSION <= 0x700 */ + +#define DIDEVTYPE_HID 0x00010000 + +#if DIRECTINPUT_VERSION <= 0x700 +#define DIDEVTYPEMOUSE_UNKNOWN 1 +#define DIDEVTYPEMOUSE_TRADITIONAL 2 +#define DIDEVTYPEMOUSE_FINGERSTICK 3 +#define DIDEVTYPEMOUSE_TOUCHPAD 4 +#define DIDEVTYPEMOUSE_TRACKBALL 5 + +#define DIDEVTYPEKEYBOARD_UNKNOWN 0 +#define DIDEVTYPEKEYBOARD_PCXT 1 +#define DIDEVTYPEKEYBOARD_OLIVETTI 2 +#define DIDEVTYPEKEYBOARD_PCAT 3 +#define DIDEVTYPEKEYBOARD_PCENH 4 +#define DIDEVTYPEKEYBOARD_NOKIA1050 5 +#define DIDEVTYPEKEYBOARD_NOKIA9140 6 +#define DIDEVTYPEKEYBOARD_NEC98 7 +#define DIDEVTYPEKEYBOARD_NEC98LAPTOP 8 +#define DIDEVTYPEKEYBOARD_NEC98106 9 +#define DIDEVTYPEKEYBOARD_JAPAN106 10 +#define DIDEVTYPEKEYBOARD_JAPANAX 11 +#define DIDEVTYPEKEYBOARD_J3100 12 + +#define DIDEVTYPEJOYSTICK_UNKNOWN 1 +#define DIDEVTYPEJOYSTICK_TRADITIONAL 2 +#define DIDEVTYPEJOYSTICK_FLIGHTSTICK 3 +#define DIDEVTYPEJOYSTICK_GAMEPAD 4 +#define DIDEVTYPEJOYSTICK_RUDDER 5 +#define DIDEVTYPEJOYSTICK_WHEEL 6 +#define DIDEVTYPEJOYSTICK_HEADTRACKER 7 + +#else +#define DI8DEVTYPEMOUSE_UNKNOWN 1 +#define DI8DEVTYPEMOUSE_TRADITIONAL 2 +#define DI8DEVTYPEMOUSE_FINGERSTICK 3 +#define DI8DEVTYPEMOUSE_TOUCHPAD 4 +#define DI8DEVTYPEMOUSE_TRACKBALL 5 +#define DI8DEVTYPEMOUSE_ABSOLUTE 6 + +#define DI8DEVTYPEKEYBOARD_UNKNOWN 0 +#define DI8DEVTYPEKEYBOARD_PCXT 1 +#define DI8DEVTYPEKEYBOARD_OLIVETTI 2 +#define DI8DEVTYPEKEYBOARD_PCAT 3 +#define DI8DEVTYPEKEYBOARD_PCENH 4 +#define DI8DEVTYPEKEYBOARD_NOKIA1050 5 +#define DI8DEVTYPEKEYBOARD_NOKIA9140 6 +#define DI8DEVTYPEKEYBOARD_NEC98 7 +#define DI8DEVTYPEKEYBOARD_NEC98LAPTOP 8 +#define DI8DEVTYPEKEYBOARD_NEC98106 9 +#define DI8DEVTYPEKEYBOARD_JAPAN106 10 +#define DI8DEVTYPEKEYBOARD_JAPANAX 11 +#define DI8DEVTYPEKEYBOARD_J3100 12 + +#define DI8DEVTYPE_LIMITEDGAMESUBTYPE 1 + +#define DI8DEVTYPEJOYSTICK_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPEJOYSTICK_STANDARD 2 + +#define DI8DEVTYPEGAMEPAD_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPEGAMEPAD_STANDARD 2 +#define DI8DEVTYPEGAMEPAD_TILT 3 + +#define DI8DEVTYPEDRIVING_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPEDRIVING_COMBINEDPEDALS 2 +#define DI8DEVTYPEDRIVING_DUALPEDALS 3 +#define DI8DEVTYPEDRIVING_THREEPEDALS 4 +#define DI8DEVTYPEDRIVING_HANDHELD 5 + +#define DI8DEVTYPEFLIGHT_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPEFLIGHT_STICK 2 +#define DI8DEVTYPEFLIGHT_YOKE 3 +#define DI8DEVTYPEFLIGHT_RC 4 + +#define DI8DEVTYPE1STPERSON_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPE1STPERSON_UNKNOWN 2 +#define DI8DEVTYPE1STPERSON_SIXDOF 3 +#define DI8DEVTYPE1STPERSON_SHOOTER 4 + +#define DI8DEVTYPESCREENPTR_UNKNOWN 2 +#define DI8DEVTYPESCREENPTR_LIGHTGUN 3 +#define DI8DEVTYPESCREENPTR_LIGHTPEN 4 +#define DI8DEVTYPESCREENPTR_TOUCH 5 + +#define DI8DEVTYPEREMOTE_UNKNOWN 2 + +#define DI8DEVTYPEDEVICECTRL_UNKNOWN 2 +#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION 3 +#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION_HARDWIRED 4 + +#define DI8DEVTYPESUPPLEMENTAL_UNKNOWN 2 +#define DI8DEVTYPESUPPLEMENTAL_2NDHANDCONTROLLER 3 +#define DI8DEVTYPESUPPLEMENTAL_HEADTRACKER 4 +#define DI8DEVTYPESUPPLEMENTAL_HANDTRACKER 5 +#define DI8DEVTYPESUPPLEMENTAL_SHIFTSTICKGATE 6 +#define DI8DEVTYPESUPPLEMENTAL_SHIFTER 7 +#define DI8DEVTYPESUPPLEMENTAL_THROTTLE 8 +#define DI8DEVTYPESUPPLEMENTAL_SPLITTHROTTLE 9 +#define DI8DEVTYPESUPPLEMENTAL_COMBINEDPEDALS 10 +#define DI8DEVTYPESUPPLEMENTAL_DUALPEDALS 11 +#define DI8DEVTYPESUPPLEMENTAL_THREEPEDALS 12 +#define DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS 13 +#endif /* DIRECTINPUT_VERSION <= 0x700 */ + +#define GET_DIDEVICE_TYPE(dwDevType) LOBYTE(dwDevType) +#define GET_DIDEVICE_SUBTYPE(dwDevType) HIBYTE(dwDevType) + +#if(DIRECTINPUT_VERSION >= 0x0500) +/* This structure is defined for DirectX 3.0 compatibility */ +typedef struct DIDEVCAPS_DX3 { + DWORD dwSize; + DWORD dwFlags; + DWORD dwDevType; + DWORD dwAxes; + DWORD dwButtons; + DWORD dwPOVs; +} DIDEVCAPS_DX3, *LPDIDEVCAPS_DX3; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +typedef struct DIDEVCAPS { + DWORD dwSize; + DWORD dwFlags; + DWORD dwDevType; + DWORD dwAxes; + DWORD dwButtons; + DWORD dwPOVs; +#if(DIRECTINPUT_VERSION >= 0x0500) + DWORD dwFFSamplePeriod; + DWORD dwFFMinTimeResolution; + DWORD dwFirmwareRevision; + DWORD dwHardwareRevision; + DWORD dwFFDriverVersion; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVCAPS, *LPDIDEVCAPS; + +#define DIDC_ATTACHED 0x00000001 +#define DIDC_POLLEDDEVICE 0x00000002 +#define DIDC_EMULATED 0x00000004 +#define DIDC_POLLEDDATAFORMAT 0x00000008 +#if(DIRECTINPUT_VERSION >= 0x0500) +#define DIDC_FORCEFEEDBACK 0x00000100 +#define DIDC_FFATTACK 0x00000200 +#define DIDC_FFFADE 0x00000400 +#define DIDC_SATURATION 0x00000800 +#define DIDC_POSNEGCOEFFICIENTS 0x00001000 +#define DIDC_POSNEGSATURATION 0x00002000 +#define DIDC_DEADBAND 0x00004000 +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +#define DIDC_STARTDELAY 0x00008000 +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIDC_ALIAS 0x00010000 +#define DIDC_PHANTOM 0x00020000 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIDC_HIDDEN 0x00040000 +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#define DIDFT_ALL 0x00000000 + +#define DIDFT_RELAXIS 0x00000001 +#define DIDFT_ABSAXIS 0x00000002 +#define DIDFT_AXIS 0x00000003 + +#define DIDFT_PSHBUTTON 0x00000004 +#define DIDFT_TGLBUTTON 0x00000008 +#define DIDFT_BUTTON 0x0000000C + +#define DIDFT_POV 0x00000010 +#define DIDFT_COLLECTION 0x00000040 +#define DIDFT_NODATA 0x00000080 + +#define DIDFT_ANYINSTANCE 0x00FFFF00 +#define DIDFT_INSTANCEMASK DIDFT_ANYINSTANCE +#define DIDFT_MAKEINSTANCE(n) ((WORD)(n) << 8) +#define DIDFT_GETTYPE(n) LOBYTE(n) +#define DIDFT_GETINSTANCE(n) LOWORD((n) >> 8) +#define DIDFT_FFACTUATOR 0x01000000 +#define DIDFT_FFEFFECTTRIGGER 0x02000000 +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIDFT_OUTPUT 0x10000000 +#define DIDFT_VENDORDEFINED 0x04000000 +#define DIDFT_ALIAS 0x08000000 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ +#ifndef DIDFT_OPTIONAL +#define DIDFT_OPTIONAL 0x80000000 +#endif + +#define DIDFT_ENUMCOLLECTION(n) ((WORD)(n) << 8) +#define DIDFT_NOCOLLECTION 0x00FFFF00 + +#ifndef DIJ_RINGZERO + +typedef struct _DIOBJECTDATAFORMAT { + const GUID *pguid; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; +} DIOBJECTDATAFORMAT, *LPDIOBJECTDATAFORMAT; +typedef const DIOBJECTDATAFORMAT *LPCDIOBJECTDATAFORMAT; + +typedef struct _DIDATAFORMAT { + DWORD dwSize; + DWORD dwObjSize; + DWORD dwFlags; + DWORD dwDataSize; + DWORD dwNumObjs; + LPDIOBJECTDATAFORMAT rgodf; +} DIDATAFORMAT, *LPDIDATAFORMAT; +typedef const DIDATAFORMAT *LPCDIDATAFORMAT; + +#define DIDF_ABSAXIS 0x00000001 +#define DIDF_RELAXIS 0x00000002 + +#ifdef __cplusplus +extern "C" { +#endif +extern const DIDATAFORMAT c_dfDIMouse; + +#if(DIRECTINPUT_VERSION >= 0x0700) +extern const DIDATAFORMAT c_dfDIMouse2; +#endif /* DIRECTINPUT_VERSION >= 0x0700 */ + +extern const DIDATAFORMAT c_dfDIKeyboard; + +#if(DIRECTINPUT_VERSION >= 0x0500) +extern const DIDATAFORMAT c_dfDIJoystick; +extern const DIDATAFORMAT c_dfDIJoystick2; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +#ifdef __cplusplus +}; +#endif + + +#if DIRECTINPUT_VERSION > 0x0700 + +typedef struct _DIACTIONA { + UINT_PTR uAppData; + DWORD dwSemantic; + OPTIONAL DWORD dwFlags; + OPTIONAL union { + LPCSTR lptszActionName; + UINT uResIdString; + }; + OPTIONAL GUID guidInstance; + OPTIONAL DWORD dwObjID; + OPTIONAL DWORD dwHow; +} DIACTIONA, *LPDIACTIONA ; +typedef struct _DIACTIONW { + UINT_PTR uAppData; + DWORD dwSemantic; + OPTIONAL DWORD dwFlags; + OPTIONAL union { + LPCWSTR lptszActionName; + UINT uResIdString; + }; + OPTIONAL GUID guidInstance; + OPTIONAL DWORD dwObjID; + OPTIONAL DWORD dwHow; +} DIACTIONW, *LPDIACTIONW ; +#ifdef UNICODE +typedef DIACTIONW DIACTION; +typedef LPDIACTIONW LPDIACTION; +#else +typedef DIACTIONA DIACTION; +typedef LPDIACTIONA LPDIACTION; +#endif // UNICODE + +typedef const DIACTIONA *LPCDIACTIONA; +typedef const DIACTIONW *LPCDIACTIONW; +#ifdef UNICODE +typedef DIACTIONW DIACTION; +typedef LPCDIACTIONW LPCDIACTION; +#else +typedef DIACTIONA DIACTION; +typedef LPCDIACTIONA LPCDIACTION; +#endif // UNICODE +typedef const DIACTION *LPCDIACTION; + + +#define DIA_FORCEFEEDBACK 0x00000001 +#define DIA_APPMAPPED 0x00000002 +#define DIA_APPNOMAP 0x00000004 +#define DIA_NORANGE 0x00000008 +#define DIA_APPFIXED 0x00000010 + +#define DIAH_UNMAPPED 0x00000000 +#define DIAH_USERCONFIG 0x00000001 +#define DIAH_APPREQUESTED 0x00000002 +#define DIAH_HWAPP 0x00000004 +#define DIAH_HWDEFAULT 0x00000008 +#define DIAH_DEFAULT 0x00000020 +#define DIAH_ERROR 0x80000000 + +typedef struct _DIACTIONFORMATA { + DWORD dwSize; + DWORD dwActionSize; + DWORD dwDataSize; + DWORD dwNumActions; + LPDIACTIONA rgoAction; + GUID guidActionMap; + DWORD dwGenre; + DWORD dwBufferSize; + OPTIONAL LONG lAxisMin; + OPTIONAL LONG lAxisMax; + OPTIONAL HINSTANCE hInstString; + FILETIME ftTimeStamp; + DWORD dwCRC; + CHAR tszActionMap[MAX_PATH]; +} DIACTIONFORMATA, *LPDIACTIONFORMATA; +typedef struct _DIACTIONFORMATW { + DWORD dwSize; + DWORD dwActionSize; + DWORD dwDataSize; + DWORD dwNumActions; + LPDIACTIONW rgoAction; + GUID guidActionMap; + DWORD dwGenre; + DWORD dwBufferSize; + OPTIONAL LONG lAxisMin; + OPTIONAL LONG lAxisMax; + OPTIONAL HINSTANCE hInstString; + FILETIME ftTimeStamp; + DWORD dwCRC; + WCHAR tszActionMap[MAX_PATH]; +} DIACTIONFORMATW, *LPDIACTIONFORMATW; +#ifdef UNICODE +typedef DIACTIONFORMATW DIACTIONFORMAT; +typedef LPDIACTIONFORMATW LPDIACTIONFORMAT; +#else +typedef DIACTIONFORMATA DIACTIONFORMAT; +typedef LPDIACTIONFORMATA LPDIACTIONFORMAT; +#endif // UNICODE +typedef const DIACTIONFORMATA *LPCDIACTIONFORMATA; +typedef const DIACTIONFORMATW *LPCDIACTIONFORMATW; +#ifdef UNICODE +typedef DIACTIONFORMATW DIACTIONFORMAT; +typedef LPCDIACTIONFORMATW LPCDIACTIONFORMAT; +#else +typedef DIACTIONFORMATA DIACTIONFORMAT; +typedef LPCDIACTIONFORMATA LPCDIACTIONFORMAT; +#endif // UNICODE +typedef const DIACTIONFORMAT *LPCDIACTIONFORMAT; + +#define DIAFTS_NEWDEVICELOW 0xFFFFFFFF +#define DIAFTS_NEWDEVICEHIGH 0xFFFFFFFF +#define DIAFTS_UNUSEDDEVICELOW 0x00000000 +#define DIAFTS_UNUSEDDEVICEHIGH 0x00000000 + +#define DIDBAM_DEFAULT 0x00000000 +#define DIDBAM_PRESERVE 0x00000001 +#define DIDBAM_INITIALIZE 0x00000002 +#define DIDBAM_HWDEFAULTS 0x00000004 + +#define DIDSAM_DEFAULT 0x00000000 +#define DIDSAM_NOUSER 0x00000001 +#define DIDSAM_FORCESAVE 0x00000002 + +#define DICD_DEFAULT 0x00000000 +#define DICD_EDIT 0x00000001 + +/* + * The following definition is normally defined in d3dtypes.h + */ +#ifndef D3DCOLOR_DEFINED +typedef DWORD D3DCOLOR; +#define D3DCOLOR_DEFINED +#endif + +typedef struct _DICOLORSET{ + DWORD dwSize; + D3DCOLOR cTextFore; + D3DCOLOR cTextHighlight; + D3DCOLOR cCalloutLine; + D3DCOLOR cCalloutHighlight; + D3DCOLOR cBorder; + D3DCOLOR cControlFill; + D3DCOLOR cHighlightFill; + D3DCOLOR cAreaFill; +} DICOLORSET, *LPDICOLORSET; +typedef const DICOLORSET *LPCDICOLORSET; + + +typedef struct _DICONFIGUREDEVICESPARAMSA{ + DWORD dwSize; + DWORD dwcUsers; + LPSTR lptszUserNames; + DWORD dwcFormats; + LPDIACTIONFORMATA lprgFormats; + HWND hwnd; + DICOLORSET dics; + IUnknown FAR * lpUnkDDSTarget; +} DICONFIGUREDEVICESPARAMSA, *LPDICONFIGUREDEVICESPARAMSA; +typedef struct _DICONFIGUREDEVICESPARAMSW{ + DWORD dwSize; + DWORD dwcUsers; + LPWSTR lptszUserNames; + DWORD dwcFormats; + LPDIACTIONFORMATW lprgFormats; + HWND hwnd; + DICOLORSET dics; + IUnknown FAR * lpUnkDDSTarget; +} DICONFIGUREDEVICESPARAMSW, *LPDICONFIGUREDEVICESPARAMSW; +#ifdef UNICODE +typedef DICONFIGUREDEVICESPARAMSW DICONFIGUREDEVICESPARAMS; +typedef LPDICONFIGUREDEVICESPARAMSW LPDICONFIGUREDEVICESPARAMS; +#else +typedef DICONFIGUREDEVICESPARAMSA DICONFIGUREDEVICESPARAMS; +typedef LPDICONFIGUREDEVICESPARAMSA LPDICONFIGUREDEVICESPARAMS; +#endif // UNICODE +typedef const DICONFIGUREDEVICESPARAMSA *LPCDICONFIGUREDEVICESPARAMSA; +typedef const DICONFIGUREDEVICESPARAMSW *LPCDICONFIGUREDEVICESPARAMSW; +#ifdef UNICODE +typedef DICONFIGUREDEVICESPARAMSW DICONFIGUREDEVICESPARAMS; +typedef LPCDICONFIGUREDEVICESPARAMSW LPCDICONFIGUREDEVICESPARAMS; +#else +typedef DICONFIGUREDEVICESPARAMSA DICONFIGUREDEVICESPARAMS; +typedef LPCDICONFIGUREDEVICESPARAMSA LPCDICONFIGUREDEVICESPARAMS; +#endif // UNICODE +typedef const DICONFIGUREDEVICESPARAMS *LPCDICONFIGUREDEVICESPARAMS; + + +#define DIDIFT_CONFIGURATION 0x00000001 +#define DIDIFT_OVERLAY 0x00000002 + +#define DIDAL_CENTERED 0x00000000 +#define DIDAL_LEFTALIGNED 0x00000001 +#define DIDAL_RIGHTALIGNED 0x00000002 +#define DIDAL_MIDDLE 0x00000000 +#define DIDAL_TOPALIGNED 0x00000004 +#define DIDAL_BOTTOMALIGNED 0x00000008 + +typedef struct _DIDEVICEIMAGEINFOA { + CHAR tszImagePath[MAX_PATH]; + DWORD dwFlags; + // These are valid if DIDIFT_OVERLAY is present in dwFlags. + DWORD dwViewID; + RECT rcOverlay; + DWORD dwObjID; + DWORD dwcValidPts; + POINT rgptCalloutLine[5]; + RECT rcCalloutRect; + DWORD dwTextAlign; +} DIDEVICEIMAGEINFOA, *LPDIDEVICEIMAGEINFOA; +typedef struct _DIDEVICEIMAGEINFOW { + WCHAR tszImagePath[MAX_PATH]; + DWORD dwFlags; + // These are valid if DIDIFT_OVERLAY is present in dwFlags. + DWORD dwViewID; + RECT rcOverlay; + DWORD dwObjID; + DWORD dwcValidPts; + POINT rgptCalloutLine[5]; + RECT rcCalloutRect; + DWORD dwTextAlign; +} DIDEVICEIMAGEINFOW, *LPDIDEVICEIMAGEINFOW; +#ifdef UNICODE +typedef DIDEVICEIMAGEINFOW DIDEVICEIMAGEINFO; +typedef LPDIDEVICEIMAGEINFOW LPDIDEVICEIMAGEINFO; +#else +typedef DIDEVICEIMAGEINFOA DIDEVICEIMAGEINFO; +typedef LPDIDEVICEIMAGEINFOA LPDIDEVICEIMAGEINFO; +#endif // UNICODE +typedef const DIDEVICEIMAGEINFOA *LPCDIDEVICEIMAGEINFOA; +typedef const DIDEVICEIMAGEINFOW *LPCDIDEVICEIMAGEINFOW; +#ifdef UNICODE +typedef DIDEVICEIMAGEINFOW DIDEVICEIMAGEINFO; +typedef LPCDIDEVICEIMAGEINFOW LPCDIDEVICEIMAGEINFO; +#else +typedef DIDEVICEIMAGEINFOA DIDEVICEIMAGEINFO; +typedef LPCDIDEVICEIMAGEINFOA LPCDIDEVICEIMAGEINFO; +#endif // UNICODE +typedef const DIDEVICEIMAGEINFO *LPCDIDEVICEIMAGEINFO; + +typedef struct _DIDEVICEIMAGEINFOHEADERA { + DWORD dwSize; + DWORD dwSizeImageInfo; + DWORD dwcViews; + DWORD dwcButtons; + DWORD dwcAxes; + DWORD dwcPOVs; + DWORD dwBufferSize; + DWORD dwBufferUsed; + LPDIDEVICEIMAGEINFOA lprgImageInfoArray; +} DIDEVICEIMAGEINFOHEADERA, *LPDIDEVICEIMAGEINFOHEADERA; +typedef struct _DIDEVICEIMAGEINFOHEADERW { + DWORD dwSize; + DWORD dwSizeImageInfo; + DWORD dwcViews; + DWORD dwcButtons; + DWORD dwcAxes; + DWORD dwcPOVs; + DWORD dwBufferSize; + DWORD dwBufferUsed; + LPDIDEVICEIMAGEINFOW lprgImageInfoArray; +} DIDEVICEIMAGEINFOHEADERW, *LPDIDEVICEIMAGEINFOHEADERW; +#ifdef UNICODE +typedef DIDEVICEIMAGEINFOHEADERW DIDEVICEIMAGEINFOHEADER; +typedef LPDIDEVICEIMAGEINFOHEADERW LPDIDEVICEIMAGEINFOHEADER; +#else +typedef DIDEVICEIMAGEINFOHEADERA DIDEVICEIMAGEINFOHEADER; +typedef LPDIDEVICEIMAGEINFOHEADERA LPDIDEVICEIMAGEINFOHEADER; +#endif // UNICODE +typedef const DIDEVICEIMAGEINFOHEADERA *LPCDIDEVICEIMAGEINFOHEADERA; +typedef const DIDEVICEIMAGEINFOHEADERW *LPCDIDEVICEIMAGEINFOHEADERW; +#ifdef UNICODE +typedef DIDEVICEIMAGEINFOHEADERW DIDEVICEIMAGEINFOHEADER; +typedef LPCDIDEVICEIMAGEINFOHEADERW LPCDIDEVICEIMAGEINFOHEADER; +#else +typedef DIDEVICEIMAGEINFOHEADERA DIDEVICEIMAGEINFOHEADER; +typedef LPCDIDEVICEIMAGEINFOHEADERA LPCDIDEVICEIMAGEINFOHEADER; +#endif // UNICODE +typedef const DIDEVICEIMAGEINFOHEADER *LPCDIDEVICEIMAGEINFOHEADER; + +#endif /* DIRECTINPUT_VERSION > 0x0700 */ + +#if(DIRECTINPUT_VERSION >= 0x0500) +/* These structures are defined for DirectX 3.0 compatibility */ + +typedef struct DIDEVICEOBJECTINSTANCE_DX3A { + DWORD dwSize; + GUID guidType; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; + CHAR tszName[MAX_PATH]; +} DIDEVICEOBJECTINSTANCE_DX3A, *LPDIDEVICEOBJECTINSTANCE_DX3A; +typedef struct DIDEVICEOBJECTINSTANCE_DX3W { + DWORD dwSize; + GUID guidType; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; + WCHAR tszName[MAX_PATH]; +} DIDEVICEOBJECTINSTANCE_DX3W, *LPDIDEVICEOBJECTINSTANCE_DX3W; +#ifdef UNICODE +typedef DIDEVICEOBJECTINSTANCE_DX3W DIDEVICEOBJECTINSTANCE_DX3; +typedef LPDIDEVICEOBJECTINSTANCE_DX3W LPDIDEVICEOBJECTINSTANCE_DX3; +#else +typedef DIDEVICEOBJECTINSTANCE_DX3A DIDEVICEOBJECTINSTANCE_DX3; +typedef LPDIDEVICEOBJECTINSTANCE_DX3A LPDIDEVICEOBJECTINSTANCE_DX3; +#endif // UNICODE +typedef const DIDEVICEOBJECTINSTANCE_DX3A *LPCDIDEVICEOBJECTINSTANCE_DX3A; +typedef const DIDEVICEOBJECTINSTANCE_DX3W *LPCDIDEVICEOBJECTINSTANCE_DX3W; +typedef const DIDEVICEOBJECTINSTANCE_DX3 *LPCDIDEVICEOBJECTINSTANCE_DX3; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +typedef struct DIDEVICEOBJECTINSTANCEA { + DWORD dwSize; + GUID guidType; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; + CHAR tszName[MAX_PATH]; +#if(DIRECTINPUT_VERSION >= 0x0500) + DWORD dwFFMaxForce; + DWORD dwFFForceResolution; + WORD wCollectionNumber; + WORD wDesignatorIndex; + WORD wUsagePage; + WORD wUsage; + DWORD dwDimension; + WORD wExponent; + WORD wReportId; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVICEOBJECTINSTANCEA, *LPDIDEVICEOBJECTINSTANCEA; +typedef struct DIDEVICEOBJECTINSTANCEW { + DWORD dwSize; + GUID guidType; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; + WCHAR tszName[MAX_PATH]; +#if(DIRECTINPUT_VERSION >= 0x0500) + DWORD dwFFMaxForce; + DWORD dwFFForceResolution; + WORD wCollectionNumber; + WORD wDesignatorIndex; + WORD wUsagePage; + WORD wUsage; + DWORD dwDimension; + WORD wExponent; + WORD wReportId; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVICEOBJECTINSTANCEW, *LPDIDEVICEOBJECTINSTANCEW; +#ifdef UNICODE +typedef DIDEVICEOBJECTINSTANCEW DIDEVICEOBJECTINSTANCE; +typedef LPDIDEVICEOBJECTINSTANCEW LPDIDEVICEOBJECTINSTANCE; +#else +typedef DIDEVICEOBJECTINSTANCEA DIDEVICEOBJECTINSTANCE; +typedef LPDIDEVICEOBJECTINSTANCEA LPDIDEVICEOBJECTINSTANCE; +#endif // UNICODE +typedef const DIDEVICEOBJECTINSTANCEA *LPCDIDEVICEOBJECTINSTANCEA; +typedef const DIDEVICEOBJECTINSTANCEW *LPCDIDEVICEOBJECTINSTANCEW; +typedef const DIDEVICEOBJECTINSTANCE *LPCDIDEVICEOBJECTINSTANCE; + +typedef BOOL (FAR PASCAL * LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA, LPVOID); +typedef BOOL (FAR PASCAL * LPDIENUMDEVICEOBJECTSCALLBACKW)(LPCDIDEVICEOBJECTINSTANCEW, LPVOID); +#ifdef UNICODE +#define LPDIENUMDEVICEOBJECTSCALLBACK LPDIENUMDEVICEOBJECTSCALLBACKW +#else +#define LPDIENUMDEVICEOBJECTSCALLBACK LPDIENUMDEVICEOBJECTSCALLBACKA +#endif // !UNICODE + +#if(DIRECTINPUT_VERSION >= 0x0500) +#define DIDOI_FFACTUATOR 0x00000001 +#define DIDOI_FFEFFECTTRIGGER 0x00000002 +#define DIDOI_POLLED 0x00008000 +#define DIDOI_ASPECTPOSITION 0x00000100 +#define DIDOI_ASPECTVELOCITY 0x00000200 +#define DIDOI_ASPECTACCEL 0x00000300 +#define DIDOI_ASPECTFORCE 0x00000400 +#define DIDOI_ASPECTMASK 0x00000F00 +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIDOI_GUIDISUSAGE 0x00010000 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +typedef struct DIPROPHEADER { + DWORD dwSize; + DWORD dwHeaderSize; + DWORD dwObj; + DWORD dwHow; +} DIPROPHEADER, *LPDIPROPHEADER; +typedef const DIPROPHEADER *LPCDIPROPHEADER; + +#define DIPH_DEVICE 0 +#define DIPH_BYOFFSET 1 +#define DIPH_BYID 2 +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIPH_BYUSAGE 3 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIMAKEUSAGEDWORD(UsagePage, Usage) \ + (DWORD)MAKELONG(Usage, UsagePage) +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +typedef struct DIPROPDWORD { + DIPROPHEADER diph; + DWORD dwData; +} DIPROPDWORD, *LPDIPROPDWORD; +typedef const DIPROPDWORD *LPCDIPROPDWORD; + +#if(DIRECTINPUT_VERSION >= 0x0800) +typedef struct DIPROPPOINTER { + DIPROPHEADER diph; + UINT_PTR uData; +} DIPROPPOINTER, *LPDIPROPPOINTER; +typedef const DIPROPPOINTER *LPCDIPROPPOINTER; +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +typedef struct DIPROPRANGE { + DIPROPHEADER diph; + LONG lMin; + LONG lMax; +} DIPROPRANGE, *LPDIPROPRANGE; +typedef const DIPROPRANGE *LPCDIPROPRANGE; + +#define DIPROPRANGE_NOMIN ((LONG)0x80000000) +#define DIPROPRANGE_NOMAX ((LONG)0x7FFFFFFF) + +#if(DIRECTINPUT_VERSION >= 0x050a) +typedef struct DIPROPCAL { + DIPROPHEADER diph; + LONG lMin; + LONG lCenter; + LONG lMax; +} DIPROPCAL, *LPDIPROPCAL; +typedef const DIPROPCAL *LPCDIPROPCAL; + +typedef struct DIPROPCALPOV { + DIPROPHEADER diph; + LONG lMin[5]; + LONG lMax[5]; +} DIPROPCALPOV, *LPDIPROPCALPOV; +typedef const DIPROPCALPOV *LPCDIPROPCALPOV; + +typedef struct DIPROPGUIDANDPATH { + DIPROPHEADER diph; + GUID guidClass; + WCHAR wszPath[MAX_PATH]; +} DIPROPGUIDANDPATH, *LPDIPROPGUIDANDPATH; +typedef const DIPROPGUIDANDPATH *LPCDIPROPGUIDANDPATH; + +typedef struct DIPROPSTRING { + DIPROPHEADER diph; + WCHAR wsz[MAX_PATH]; +} DIPROPSTRING, *LPDIPROPSTRING; +typedef const DIPROPSTRING *LPCDIPROPSTRING; + +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +#if(DIRECTINPUT_VERSION >= 0x0800) +#define MAXCPOINTSNUM 8 + +typedef struct _CPOINT +{ + LONG lP; // raw value + DWORD dwLog; // logical_value / max_logical_value * 10000 +} CPOINT, *PCPOINT; + +typedef struct DIPROPCPOINTS { + DIPROPHEADER diph; + DWORD dwCPointsNum; + CPOINT cp[MAXCPOINTSNUM]; +} DIPROPCPOINTS, *LPDIPROPCPOINTS; +typedef const DIPROPCPOINTS *LPCDIPROPCPOINTS; +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + + +#ifdef __cplusplus +#define MAKEDIPROP(prop) (*(const GUID *)(prop)) +#else +#define MAKEDIPROP(prop) ((REFGUID)(prop)) +#endif + +#define DIPROP_BUFFERSIZE MAKEDIPROP(1) + +#define DIPROP_AXISMODE MAKEDIPROP(2) + +#define DIPROPAXISMODE_ABS 0 +#define DIPROPAXISMODE_REL 1 + +#define DIPROP_GRANULARITY MAKEDIPROP(3) + +#define DIPROP_RANGE MAKEDIPROP(4) + +#define DIPROP_DEADZONE MAKEDIPROP(5) + +#define DIPROP_SATURATION MAKEDIPROP(6) + +#define DIPROP_FFGAIN MAKEDIPROP(7) + +#define DIPROP_FFLOAD MAKEDIPROP(8) + +#define DIPROP_AUTOCENTER MAKEDIPROP(9) + +#define DIPROPAUTOCENTER_OFF 0 +#define DIPROPAUTOCENTER_ON 1 + +#define DIPROP_CALIBRATIONMODE MAKEDIPROP(10) + +#define DIPROPCALIBRATIONMODE_COOKED 0 +#define DIPROPCALIBRATIONMODE_RAW 1 + +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIPROP_CALIBRATION MAKEDIPROP(11) + +#define DIPROP_GUIDANDPATH MAKEDIPROP(12) + +#define DIPROP_INSTANCENAME MAKEDIPROP(13) + +#define DIPROP_PRODUCTNAME MAKEDIPROP(14) +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +#if(DIRECTINPUT_VERSION >= 0x05b2) +#define DIPROP_JOYSTICKID MAKEDIPROP(15) + +#define DIPROP_GETPORTDISPLAYNAME MAKEDIPROP(16) + +#endif /* DIRECTINPUT_VERSION >= 0x05b2 */ + +#if(DIRECTINPUT_VERSION >= 0x0700) +#define DIPROP_PHYSICALRANGE MAKEDIPROP(18) + +#define DIPROP_LOGICALRANGE MAKEDIPROP(19) +#endif /* DIRECTINPUT_VERSION >= 0x0700 */ + +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIPROP_KEYNAME MAKEDIPROP(20) + +#define DIPROP_CPOINTS MAKEDIPROP(21) + +#define DIPROP_APPDATA MAKEDIPROP(22) + +#define DIPROP_SCANCODE MAKEDIPROP(23) + +#define DIPROP_VIDPID MAKEDIPROP(24) + +#define DIPROP_USERNAME MAKEDIPROP(25) + +#define DIPROP_TYPENAME MAKEDIPROP(26) +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + + +typedef struct DIDEVICEOBJECTDATA_DX3 { + DWORD dwOfs; + DWORD dwData; + DWORD dwTimeStamp; + DWORD dwSequence; +} DIDEVICEOBJECTDATA_DX3, *LPDIDEVICEOBJECTDATA_DX3; +typedef const DIDEVICEOBJECTDATA_DX3 *LPCDIDEVICEOBJECTDATA_DX; + +typedef struct DIDEVICEOBJECTDATA { + DWORD dwOfs; + DWORD dwData; + DWORD dwTimeStamp; + DWORD dwSequence; +#if(DIRECTINPUT_VERSION >= 0x0800) + UINT_PTR uAppData; +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ +} DIDEVICEOBJECTDATA, *LPDIDEVICEOBJECTDATA; +typedef const DIDEVICEOBJECTDATA *LPCDIDEVICEOBJECTDATA; + +#define DIGDD_PEEK 0x00000001 + +#define DISEQUENCE_COMPARE(dwSequence1, cmp, dwSequence2) \ + ((int)((dwSequence1) - (dwSequence2)) cmp 0) +#define DISCL_EXCLUSIVE 0x00000001 +#define DISCL_NONEXCLUSIVE 0x00000002 +#define DISCL_FOREGROUND 0x00000004 +#define DISCL_BACKGROUND 0x00000008 +#define DISCL_NOWINKEY 0x00000010 + +#if(DIRECTINPUT_VERSION >= 0x0500) +/* These structures are defined for DirectX 3.0 compatibility */ + +typedef struct DIDEVICEINSTANCE_DX3A { + DWORD dwSize; + GUID guidInstance; + GUID guidProduct; + DWORD dwDevType; + CHAR tszInstanceName[MAX_PATH]; + CHAR tszProductName[MAX_PATH]; +} DIDEVICEINSTANCE_DX3A, *LPDIDEVICEINSTANCE_DX3A; +typedef struct DIDEVICEINSTANCE_DX3W { + DWORD dwSize; + GUID guidInstance; + GUID guidProduct; + DWORD dwDevType; + WCHAR tszInstanceName[MAX_PATH]; + WCHAR tszProductName[MAX_PATH]; +} DIDEVICEINSTANCE_DX3W, *LPDIDEVICEINSTANCE_DX3W; +#ifdef UNICODE +typedef DIDEVICEINSTANCE_DX3W DIDEVICEINSTANCE_DX3; +typedef LPDIDEVICEINSTANCE_DX3W LPDIDEVICEINSTANCE_DX3; +#else +typedef DIDEVICEINSTANCE_DX3A DIDEVICEINSTANCE_DX3; +typedef LPDIDEVICEINSTANCE_DX3A LPDIDEVICEINSTANCE_DX3; +#endif // UNICODE +typedef const DIDEVICEINSTANCE_DX3A *LPCDIDEVICEINSTANCE_DX3A; +typedef const DIDEVICEINSTANCE_DX3W *LPCDIDEVICEINSTANCE_DX3W; +typedef const DIDEVICEINSTANCE_DX3 *LPCDIDEVICEINSTANCE_DX3; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +typedef struct DIDEVICEINSTANCEA { + DWORD dwSize; + GUID guidInstance; + GUID guidProduct; + DWORD dwDevType; + CHAR tszInstanceName[MAX_PATH]; + CHAR tszProductName[MAX_PATH]; +#if(DIRECTINPUT_VERSION >= 0x0500) + GUID guidFFDriver; + WORD wUsagePage; + WORD wUsage; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVICEINSTANCEA, *LPDIDEVICEINSTANCEA; +typedef struct DIDEVICEINSTANCEW { + DWORD dwSize; + GUID guidInstance; + GUID guidProduct; + DWORD dwDevType; + WCHAR tszInstanceName[MAX_PATH]; + WCHAR tszProductName[MAX_PATH]; +#if(DIRECTINPUT_VERSION >= 0x0500) + GUID guidFFDriver; + WORD wUsagePage; + WORD wUsage; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVICEINSTANCEW, *LPDIDEVICEINSTANCEW; +#ifdef UNICODE +typedef DIDEVICEINSTANCEW DIDEVICEINSTANCE; +typedef LPDIDEVICEINSTANCEW LPDIDEVICEINSTANCE; +#else +typedef DIDEVICEINSTANCEA DIDEVICEINSTANCE; +typedef LPDIDEVICEINSTANCEA LPDIDEVICEINSTANCE; +#endif // UNICODE + +typedef const DIDEVICEINSTANCEA *LPCDIDEVICEINSTANCEA; +typedef const DIDEVICEINSTANCEW *LPCDIDEVICEINSTANCEW; +#ifdef UNICODE +typedef DIDEVICEINSTANCEW DIDEVICEINSTANCE; +typedef LPCDIDEVICEINSTANCEW LPCDIDEVICEINSTANCE; +#else +typedef DIDEVICEINSTANCEA DIDEVICEINSTANCE; +typedef LPCDIDEVICEINSTANCEA LPCDIDEVICEINSTANCE; +#endif // UNICODE +typedef const DIDEVICEINSTANCE *LPCDIDEVICEINSTANCE; + +#undef INTERFACE +#define INTERFACE IDirectInputDeviceW + +DECLARE_INTERFACE_(IDirectInputDeviceW, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDeviceW methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; +}; + +typedef struct IDirectInputDeviceW *LPDIRECTINPUTDEVICEW; + +#undef INTERFACE +#define INTERFACE IDirectInputDeviceA + +DECLARE_INTERFACE_(IDirectInputDeviceA, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDeviceA methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; +}; + +typedef struct IDirectInputDeviceA *LPDIRECTINPUTDEVICEA; + +#ifdef UNICODE +#define IID_IDirectInputDevice IID_IDirectInputDeviceW +#define IDirectInputDevice IDirectInputDeviceW +#define IDirectInputDeviceVtbl IDirectInputDeviceWVtbl +#else +#define IID_IDirectInputDevice IID_IDirectInputDeviceA +#define IDirectInputDevice IDirectInputDeviceA +#define IDirectInputDeviceVtbl IDirectInputDeviceAVtbl +#endif +typedef struct IDirectInputDevice *LPDIRECTINPUTDEVICE; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputDevice_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputDevice_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputDevice_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) +#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) +#define IDirectInputDevice_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) +#define IDirectInputDevice_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) +#define IDirectInputDevice_Acquire(p) (p)->lpVtbl->Acquire(p) +#define IDirectInputDevice_Unacquire(p) (p)->lpVtbl->Unacquire(p) +#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) +#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) +#define IDirectInputDevice_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) +#define IDirectInputDevice_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) +#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) +#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) +#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInputDevice_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#else +#define IDirectInputDevice_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputDevice_AddRef(p) (p)->AddRef() +#define IDirectInputDevice_Release(p) (p)->Release() +#define IDirectInputDevice_GetCapabilities(p,a) (p)->GetCapabilities(a) +#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) +#define IDirectInputDevice_GetProperty(p,a,b) (p)->GetProperty(a,b) +#define IDirectInputDevice_SetProperty(p,a,b) (p)->SetProperty(a,b) +#define IDirectInputDevice_Acquire(p) (p)->Acquire() +#define IDirectInputDevice_Unacquire(p) (p)->Unacquire() +#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) +#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) +#define IDirectInputDevice_SetDataFormat(p,a) (p)->SetDataFormat(a) +#define IDirectInputDevice_SetEventNotification(p,a) (p)->SetEventNotification(a) +#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) +#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) +#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInputDevice_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#endif + +#endif /* DIJ_RINGZERO */ + + +#if(DIRECTINPUT_VERSION >= 0x0500) + +#define DISFFC_RESET 0x00000001 +#define DISFFC_STOPALL 0x00000002 +#define DISFFC_PAUSE 0x00000004 +#define DISFFC_CONTINUE 0x00000008 +#define DISFFC_SETACTUATORSON 0x00000010 +#define DISFFC_SETACTUATORSOFF 0x00000020 + +#define DIGFFS_EMPTY 0x00000001 +#define DIGFFS_STOPPED 0x00000002 +#define DIGFFS_PAUSED 0x00000004 +#define DIGFFS_ACTUATORSON 0x00000010 +#define DIGFFS_ACTUATORSOFF 0x00000020 +#define DIGFFS_POWERON 0x00000040 +#define DIGFFS_POWEROFF 0x00000080 +#define DIGFFS_SAFETYSWITCHON 0x00000100 +#define DIGFFS_SAFETYSWITCHOFF 0x00000200 +#define DIGFFS_USERFFSWITCHON 0x00000400 +#define DIGFFS_USERFFSWITCHOFF 0x00000800 +#define DIGFFS_DEVICELOST 0x80000000 + +#ifndef DIJ_RINGZERO + +typedef struct DIEFFECTINFOA { + DWORD dwSize; + GUID guid; + DWORD dwEffType; + DWORD dwStaticParams; + DWORD dwDynamicParams; + CHAR tszName[MAX_PATH]; +} DIEFFECTINFOA, *LPDIEFFECTINFOA; +typedef struct DIEFFECTINFOW { + DWORD dwSize; + GUID guid; + DWORD dwEffType; + DWORD dwStaticParams; + DWORD dwDynamicParams; + WCHAR tszName[MAX_PATH]; +} DIEFFECTINFOW, *LPDIEFFECTINFOW; +#ifdef UNICODE +typedef DIEFFECTINFOW DIEFFECTINFO; +typedef LPDIEFFECTINFOW LPDIEFFECTINFO; +#else +typedef DIEFFECTINFOA DIEFFECTINFO; +typedef LPDIEFFECTINFOA LPDIEFFECTINFO; +#endif // UNICODE +typedef const DIEFFECTINFOA *LPCDIEFFECTINFOA; +typedef const DIEFFECTINFOW *LPCDIEFFECTINFOW; +typedef const DIEFFECTINFO *LPCDIEFFECTINFO; + +#define DISDD_CONTINUE 0x00000001 + +typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSCALLBACKA)(LPCDIEFFECTINFOA, LPVOID); +typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSCALLBACKW)(LPCDIEFFECTINFOW, LPVOID); +#ifdef UNICODE +#define LPDIENUMEFFECTSCALLBACK LPDIENUMEFFECTSCALLBACKW +#else +#define LPDIENUMEFFECTSCALLBACK LPDIENUMEFFECTSCALLBACKA +#endif // !UNICODE +typedef BOOL (FAR PASCAL * LPDIENUMCREATEDEFFECTOBJECTSCALLBACK)(LPDIRECTINPUTEFFECT, LPVOID); + +#undef INTERFACE +#define INTERFACE IDirectInputDevice2W + +DECLARE_INTERFACE_(IDirectInputDevice2W, IDirectInputDeviceW) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDeviceW methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + + /*** IDirectInputDevice2W methods ***/ + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; +}; + +typedef struct IDirectInputDevice2W *LPDIRECTINPUTDEVICE2W; + +#undef INTERFACE +#define INTERFACE IDirectInputDevice2A + +DECLARE_INTERFACE_(IDirectInputDevice2A, IDirectInputDeviceA) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDeviceA methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + + /*** IDirectInputDevice2A methods ***/ + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; +}; + +typedef struct IDirectInputDevice2A *LPDIRECTINPUTDEVICE2A; + +#ifdef UNICODE +#define IID_IDirectInputDevice2 IID_IDirectInputDevice2W +#define IDirectInputDevice2 IDirectInputDevice2W +#define IDirectInputDevice2Vtbl IDirectInputDevice2WVtbl +#else +#define IID_IDirectInputDevice2 IID_IDirectInputDevice2A +#define IDirectInputDevice2 IDirectInputDevice2A +#define IDirectInputDevice2Vtbl IDirectInputDevice2AVtbl +#endif +typedef struct IDirectInputDevice2 *LPDIRECTINPUTDEVICE2; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputDevice2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputDevice2_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputDevice2_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) +#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) +#define IDirectInputDevice2_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) +#define IDirectInputDevice2_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) +#define IDirectInputDevice2_Acquire(p) (p)->lpVtbl->Acquire(p) +#define IDirectInputDevice2_Unacquire(p) (p)->lpVtbl->Unacquire(p) +#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) +#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) +#define IDirectInputDevice2_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) +#define IDirectInputDevice2_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) +#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) +#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) +#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) +#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) +#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) +#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) +#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) +#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) +#define IDirectInputDevice2_Escape(p,a) (p)->lpVtbl->Escape(p,a) +#define IDirectInputDevice2_Poll(p) (p)->lpVtbl->Poll(p) +#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) +#else +#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputDevice2_AddRef(p) (p)->AddRef() +#define IDirectInputDevice2_Release(p) (p)->Release() +#define IDirectInputDevice2_GetCapabilities(p,a) (p)->GetCapabilities(a) +#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) +#define IDirectInputDevice2_GetProperty(p,a,b) (p)->GetProperty(a,b) +#define IDirectInputDevice2_SetProperty(p,a,b) (p)->SetProperty(a,b) +#define IDirectInputDevice2_Acquire(p) (p)->Acquire() +#define IDirectInputDevice2_Unacquire(p) (p)->Unacquire() +#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) +#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) +#define IDirectInputDevice2_SetDataFormat(p,a) (p)->SetDataFormat(a) +#define IDirectInputDevice2_SetEventNotification(p,a) (p)->SetEventNotification(a) +#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) +#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) +#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) +#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) +#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) +#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) +#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) +#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) +#define IDirectInputDevice2_Escape(p,a) (p)->Escape(a) +#define IDirectInputDevice2_Poll(p) (p)->Poll() +#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) +#endif + +#endif /* DIJ_RINGZERO */ + +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +#if(DIRECTINPUT_VERSION >= 0x0700) +#define DIFEF_DEFAULT 0x00000000 +#define DIFEF_INCLUDENONSTANDARD 0x00000001 +#define DIFEF_MODIFYIFNEEDED 0x00000010 + +#ifndef DIJ_RINGZERO + +#undef INTERFACE +#define INTERFACE IDirectInputDevice7W + +DECLARE_INTERFACE_(IDirectInputDevice7W, IDirectInputDevice2W) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDevice2W methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + + /*** IDirectInputDevice7W methods ***/ + STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; +}; + +typedef struct IDirectInputDevice7W *LPDIRECTINPUTDEVICE7W; + +#undef INTERFACE +#define INTERFACE IDirectInputDevice7A + +DECLARE_INTERFACE_(IDirectInputDevice7A, IDirectInputDevice2A) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDevice2A methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + + /*** IDirectInputDevice7A methods ***/ + STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; +}; + +typedef struct IDirectInputDevice7A *LPDIRECTINPUTDEVICE7A; + +#ifdef UNICODE +#define IID_IDirectInputDevice7 IID_IDirectInputDevice7W +#define IDirectInputDevice7 IDirectInputDevice7W +#define IDirectInputDevice7Vtbl IDirectInputDevice7WVtbl +#else +#define IID_IDirectInputDevice7 IID_IDirectInputDevice7A +#define IDirectInputDevice7 IDirectInputDevice7A +#define IDirectInputDevice7Vtbl IDirectInputDevice7AVtbl +#endif +typedef struct IDirectInputDevice7 *LPDIRECTINPUTDEVICE7; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputDevice7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputDevice7_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputDevice7_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) +#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) +#define IDirectInputDevice7_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) +#define IDirectInputDevice7_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) +#define IDirectInputDevice7_Acquire(p) (p)->lpVtbl->Acquire(p) +#define IDirectInputDevice7_Unacquire(p) (p)->lpVtbl->Unacquire(p) +#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) +#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) +#define IDirectInputDevice7_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) +#define IDirectInputDevice7_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) +#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) +#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) +#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) +#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) +#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) +#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) +#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) +#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) +#define IDirectInputDevice7_Escape(p,a) (p)->lpVtbl->Escape(p,a) +#define IDirectInputDevice7_Poll(p) (p)->lpVtbl->Poll(p) +#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) +#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d) +#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d) +#else +#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputDevice7_AddRef(p) (p)->AddRef() +#define IDirectInputDevice7_Release(p) (p)->Release() +#define IDirectInputDevice7_GetCapabilities(p,a) (p)->GetCapabilities(a) +#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) +#define IDirectInputDevice7_GetProperty(p,a,b) (p)->GetProperty(a,b) +#define IDirectInputDevice7_SetProperty(p,a,b) (p)->SetProperty(a,b) +#define IDirectInputDevice7_Acquire(p) (p)->Acquire() +#define IDirectInputDevice7_Unacquire(p) (p)->Unacquire() +#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) +#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) +#define IDirectInputDevice7_SetDataFormat(p,a) (p)->SetDataFormat(a) +#define IDirectInputDevice7_SetEventNotification(p,a) (p)->SetEventNotification(a) +#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) +#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) +#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) +#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) +#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) +#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) +#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) +#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) +#define IDirectInputDevice7_Escape(p,a) (p)->Escape(a) +#define IDirectInputDevice7_Poll(p) (p)->Poll() +#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) +#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d) +#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d) +#endif + +#endif /* DIJ_RINGZERO */ + +#endif /* DIRECTINPUT_VERSION >= 0x0700 */ + +#if(DIRECTINPUT_VERSION >= 0x0800) + +#ifndef DIJ_RINGZERO + +#undef INTERFACE +#define INTERFACE IDirectInputDevice8W + +DECLARE_INTERFACE_(IDirectInputDevice8W, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDevice8W methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; + STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATW,LPCWSTR,DWORD) PURE; + STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATW,LPCWSTR,DWORD) PURE; + STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERW) PURE; +}; + +typedef struct IDirectInputDevice8W *LPDIRECTINPUTDEVICE8W; + +#undef INTERFACE +#define INTERFACE IDirectInputDevice8A + +DECLARE_INTERFACE_(IDirectInputDevice8A, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDevice8A methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; + STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATA,LPCSTR,DWORD) PURE; + STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATA,LPCSTR,DWORD) PURE; + STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERA) PURE; +}; + +typedef struct IDirectInputDevice8A *LPDIRECTINPUTDEVICE8A; + +#ifdef UNICODE +#define IID_IDirectInputDevice8 IID_IDirectInputDevice8W +#define IDirectInputDevice8 IDirectInputDevice8W +#define IDirectInputDevice8Vtbl IDirectInputDevice8WVtbl +#else +#define IID_IDirectInputDevice8 IID_IDirectInputDevice8A +#define IDirectInputDevice8 IDirectInputDevice8A +#define IDirectInputDevice8Vtbl IDirectInputDevice8AVtbl +#endif +typedef struct IDirectInputDevice8 *LPDIRECTINPUTDEVICE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputDevice8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputDevice8_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputDevice8_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) +#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) +#define IDirectInputDevice8_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) +#define IDirectInputDevice8_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) +#define IDirectInputDevice8_Acquire(p) (p)->lpVtbl->Acquire(p) +#define IDirectInputDevice8_Unacquire(p) (p)->lpVtbl->Unacquire(p) +#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) +#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) +#define IDirectInputDevice8_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) +#define IDirectInputDevice8_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) +#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) +#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) +#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) +#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) +#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) +#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) +#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) +#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) +#define IDirectInputDevice8_Escape(p,a) (p)->lpVtbl->Escape(p,a) +#define IDirectInputDevice8_Poll(p) (p)->lpVtbl->Poll(p) +#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) +#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d) +#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d) +#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->lpVtbl->BuildActionMap(p,a,b,c) +#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->lpVtbl->SetActionMap(p,a,b,c) +#define IDirectInputDevice8_GetImageInfo(p,a) (p)->lpVtbl->GetImageInfo(p,a) +#else +#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputDevice8_AddRef(p) (p)->AddRef() +#define IDirectInputDevice8_Release(p) (p)->Release() +#define IDirectInputDevice8_GetCapabilities(p,a) (p)->GetCapabilities(a) +#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) +#define IDirectInputDevice8_GetProperty(p,a,b) (p)->GetProperty(a,b) +#define IDirectInputDevice8_SetProperty(p,a,b) (p)->SetProperty(a,b) +#define IDirectInputDevice8_Acquire(p) (p)->Acquire() +#define IDirectInputDevice8_Unacquire(p) (p)->Unacquire() +#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) +#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) +#define IDirectInputDevice8_SetDataFormat(p,a) (p)->SetDataFormat(a) +#define IDirectInputDevice8_SetEventNotification(p,a) (p)->SetEventNotification(a) +#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) +#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) +#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) +#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) +#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) +#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) +#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) +#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) +#define IDirectInputDevice8_Escape(p,a) (p)->Escape(a) +#define IDirectInputDevice8_Poll(p) (p)->Poll() +#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) +#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d) +#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d) +#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->BuildActionMap(a,b,c) +#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->SetActionMap(a,b,c) +#define IDirectInputDevice8_GetImageInfo(p,a) (p)->GetImageInfo(a) +#endif + +#endif /* DIJ_RINGZERO */ + +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +/**************************************************************************** + * + * Mouse + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +typedef struct _DIMOUSESTATE { + LONG lX; + LONG lY; + LONG lZ; + BYTE rgbButtons[4]; +} DIMOUSESTATE, *LPDIMOUSESTATE; + +#if DIRECTINPUT_VERSION >= 0x0700 +typedef struct _DIMOUSESTATE2 { + LONG lX; + LONG lY; + LONG lZ; + BYTE rgbButtons[8]; +} DIMOUSESTATE2, *LPDIMOUSESTATE2; +#endif + + +#define DIMOFS_X FIELD_OFFSET(DIMOUSESTATE, lX) +#define DIMOFS_Y FIELD_OFFSET(DIMOUSESTATE, lY) +#define DIMOFS_Z FIELD_OFFSET(DIMOUSESTATE, lZ) +#define DIMOFS_BUTTON0 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 0) +#define DIMOFS_BUTTON1 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 1) +#define DIMOFS_BUTTON2 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 2) +#define DIMOFS_BUTTON3 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 3) +#if (DIRECTINPUT_VERSION >= 0x0700) +#define DIMOFS_BUTTON4 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 4) +#define DIMOFS_BUTTON5 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 5) +#define DIMOFS_BUTTON6 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 6) +#define DIMOFS_BUTTON7 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 7) +#endif +#endif /* DIJ_RINGZERO */ + +/**************************************************************************** + * + * Keyboard + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +/**************************************************************************** + * + * DirectInput keyboard scan codes + * + ****************************************************************************/ +#define DIK_ESCAPE 0x01 +#define DIK_1 0x02 +#define DIK_2 0x03 +#define DIK_3 0x04 +#define DIK_4 0x05 +#define DIK_5 0x06 +#define DIK_6 0x07 +#define DIK_7 0x08 +#define DIK_8 0x09 +#define DIK_9 0x0A +#define DIK_0 0x0B +#define DIK_MINUS 0x0C /* - on main keyboard */ +#define DIK_EQUALS 0x0D +#define DIK_BACK 0x0E /* backspace */ +#define DIK_TAB 0x0F +#define DIK_Q 0x10 +#define DIK_W 0x11 +#define DIK_E 0x12 +#define DIK_R 0x13 +#define DIK_T 0x14 +#define DIK_Y 0x15 +#define DIK_U 0x16 +#define DIK_I 0x17 +#define DIK_O 0x18 +#define DIK_P 0x19 +#define DIK_LBRACKET 0x1A +#define DIK_RBRACKET 0x1B +#define DIK_RETURN 0x1C /* Enter on main keyboard */ +#define DIK_LCONTROL 0x1D +#define DIK_A 0x1E +#define DIK_S 0x1F +#define DIK_D 0x20 +#define DIK_F 0x21 +#define DIK_G 0x22 +#define DIK_H 0x23 +#define DIK_J 0x24 +#define DIK_K 0x25 +#define DIK_L 0x26 +#define DIK_SEMICOLON 0x27 +#define DIK_APOSTROPHE 0x28 +#define DIK_GRAVE 0x29 /* accent grave */ +#define DIK_LSHIFT 0x2A +#define DIK_BACKSLASH 0x2B +#define DIK_Z 0x2C +#define DIK_X 0x2D +#define DIK_C 0x2E +#define DIK_V 0x2F +#define DIK_B 0x30 +#define DIK_N 0x31 +#define DIK_M 0x32 +#define DIK_COMMA 0x33 +#define DIK_PERIOD 0x34 /* . on main keyboard */ +#define DIK_SLASH 0x35 /* / on main keyboard */ +#define DIK_RSHIFT 0x36 +#define DIK_MULTIPLY 0x37 /* * on numeric keypad */ +#define DIK_LMENU 0x38 /* left Alt */ +#define DIK_SPACE 0x39 +#define DIK_CAPITAL 0x3A +#define DIK_F1 0x3B +#define DIK_F2 0x3C +#define DIK_F3 0x3D +#define DIK_F4 0x3E +#define DIK_F5 0x3F +#define DIK_F6 0x40 +#define DIK_F7 0x41 +#define DIK_F8 0x42 +#define DIK_F9 0x43 +#define DIK_F10 0x44 +#define DIK_NUMLOCK 0x45 +#define DIK_SCROLL 0x46 /* Scroll Lock */ +#define DIK_NUMPAD7 0x47 +#define DIK_NUMPAD8 0x48 +#define DIK_NUMPAD9 0x49 +#define DIK_SUBTRACT 0x4A /* - on numeric keypad */ +#define DIK_NUMPAD4 0x4B +#define DIK_NUMPAD5 0x4C +#define DIK_NUMPAD6 0x4D +#define DIK_ADD 0x4E /* + on numeric keypad */ +#define DIK_NUMPAD1 0x4F +#define DIK_NUMPAD2 0x50 +#define DIK_NUMPAD3 0x51 +#define DIK_NUMPAD0 0x52 +#define DIK_DECIMAL 0x53 /* . on numeric keypad */ +#define DIK_OEM_102 0x56 /* <> or \| on RT 102-key keyboard (Non-U.S.) */ +#define DIK_F11 0x57 +#define DIK_F12 0x58 +#define DIK_F13 0x64 /* (NEC PC98) */ +#define DIK_F14 0x65 /* (NEC PC98) */ +#define DIK_F15 0x66 /* (NEC PC98) */ +#define DIK_KANA 0x70 /* (Japanese keyboard) */ +#define DIK_ABNT_C1 0x73 /* /? on Brazilian keyboard */ +#define DIK_CONVERT 0x79 /* (Japanese keyboard) */ +#define DIK_NOCONVERT 0x7B /* (Japanese keyboard) */ +#define DIK_YEN 0x7D /* (Japanese keyboard) */ +#define DIK_ABNT_C2 0x7E /* Numpad . on Brazilian keyboard */ +#define DIK_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */ +#define DIK_PREVTRACK 0x90 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */ +#define DIK_AT 0x91 /* (NEC PC98) */ +#define DIK_COLON 0x92 /* (NEC PC98) */ +#define DIK_UNDERLINE 0x93 /* (NEC PC98) */ +#define DIK_KANJI 0x94 /* (Japanese keyboard) */ +#define DIK_STOP 0x95 /* (NEC PC98) */ +#define DIK_AX 0x96 /* (Japan AX) */ +#define DIK_UNLABELED 0x97 /* (J3100) */ +#define DIK_NEXTTRACK 0x99 /* Next Track */ +#define DIK_NUMPADENTER 0x9C /* Enter on numeric keypad */ +#define DIK_RCONTROL 0x9D +#define DIK_MUTE 0xA0 /* Mute */ +#define DIK_CALCULATOR 0xA1 /* Calculator */ +#define DIK_PLAYPAUSE 0xA2 /* Play / Pause */ +#define DIK_MEDIASTOP 0xA4 /* Media Stop */ +#define DIK_VOLUMEDOWN 0xAE /* Volume - */ +#define DIK_VOLUMEUP 0xB0 /* Volume + */ +#define DIK_WEBHOME 0xB2 /* Web home */ +#define DIK_NUMPADCOMMA 0xB3 /* , on numeric keypad (NEC PC98) */ +#define DIK_DIVIDE 0xB5 /* / on numeric keypad */ +#define DIK_SYSRQ 0xB7 +#define DIK_RMENU 0xB8 /* right Alt */ +#define DIK_PAUSE 0xC5 /* Pause */ +#define DIK_HOME 0xC7 /* Home on arrow keypad */ +#define DIK_UP 0xC8 /* UpArrow on arrow keypad */ +#define DIK_PRIOR 0xC9 /* PgUp on arrow keypad */ +#define DIK_LEFT 0xCB /* LeftArrow on arrow keypad */ +#define DIK_RIGHT 0xCD /* RightArrow on arrow keypad */ +#define DIK_END 0xCF /* End on arrow keypad */ +#define DIK_DOWN 0xD0 /* DownArrow on arrow keypad */ +#define DIK_NEXT 0xD1 /* PgDn on arrow keypad */ +#define DIK_INSERT 0xD2 /* Insert on arrow keypad */ +#define DIK_DELETE 0xD3 /* Delete on arrow keypad */ +#define DIK_LWIN 0xDB /* Left Windows key */ +#define DIK_RWIN 0xDC /* Right Windows key */ +#define DIK_APPS 0xDD /* AppMenu key */ +#define DIK_POWER 0xDE /* System Power */ +#define DIK_SLEEP 0xDF /* System Sleep */ +#define DIK_WAKE 0xE3 /* System Wake */ +#define DIK_WEBSEARCH 0xE5 /* Web Search */ +#define DIK_WEBFAVORITES 0xE6 /* Web Favorites */ +#define DIK_WEBREFRESH 0xE7 /* Web Refresh */ +#define DIK_WEBSTOP 0xE8 /* Web Stop */ +#define DIK_WEBFORWARD 0xE9 /* Web Forward */ +#define DIK_WEBBACK 0xEA /* Web Back */ +#define DIK_MYCOMPUTER 0xEB /* My Computer */ +#define DIK_MAIL 0xEC /* Mail */ +#define DIK_MEDIASELECT 0xED /* Media Select */ + +/* + * Alternate names for keys, to facilitate transition from DOS. + */ +#define DIK_BACKSPACE DIK_BACK /* backspace */ +#define DIK_NUMPADSTAR DIK_MULTIPLY /* * on numeric keypad */ +#define DIK_LALT DIK_LMENU /* left Alt */ +#define DIK_CAPSLOCK DIK_CAPITAL /* CapsLock */ +#define DIK_NUMPADMINUS DIK_SUBTRACT /* - on numeric keypad */ +#define DIK_NUMPADPLUS DIK_ADD /* + on numeric keypad */ +#define DIK_NUMPADPERIOD DIK_DECIMAL /* . on numeric keypad */ +#define DIK_NUMPADSLASH DIK_DIVIDE /* / on numeric keypad */ +#define DIK_RALT DIK_RMENU /* right Alt */ +#define DIK_UPARROW DIK_UP /* UpArrow on arrow keypad */ +#define DIK_PGUP DIK_PRIOR /* PgUp on arrow keypad */ +#define DIK_LEFTARROW DIK_LEFT /* LeftArrow on arrow keypad */ +#define DIK_RIGHTARROW DIK_RIGHT /* RightArrow on arrow keypad */ +#define DIK_DOWNARROW DIK_DOWN /* DownArrow on arrow keypad */ +#define DIK_PGDN DIK_NEXT /* PgDn on arrow keypad */ + +/* + * Alternate names for keys originally not used on US keyboards. + */ +#define DIK_CIRCUMFLEX DIK_PREVTRACK /* Japanese keyboard */ + +#endif /* DIJ_RINGZERO */ + +/**************************************************************************** + * + * Joystick + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +typedef struct DIJOYSTATE { + LONG lX; /* x-axis position */ + LONG lY; /* y-axis position */ + LONG lZ; /* z-axis position */ + LONG lRx; /* x-axis rotation */ + LONG lRy; /* y-axis rotation */ + LONG lRz; /* z-axis rotation */ + LONG rglSlider[2]; /* extra axes positions */ + DWORD rgdwPOV[4]; /* POV directions */ + BYTE rgbButtons[32]; /* 32 buttons */ +} DIJOYSTATE, *LPDIJOYSTATE; + +typedef struct DIJOYSTATE2 { + LONG lX; /* x-axis position */ + LONG lY; /* y-axis position */ + LONG lZ; /* z-axis position */ + LONG lRx; /* x-axis rotation */ + LONG lRy; /* y-axis rotation */ + LONG lRz; /* z-axis rotation */ + LONG rglSlider[2]; /* extra axes positions */ + DWORD rgdwPOV[4]; /* POV directions */ + BYTE rgbButtons[128]; /* 128 buttons */ + LONG lVX; /* x-axis velocity */ + LONG lVY; /* y-axis velocity */ + LONG lVZ; /* z-axis velocity */ + LONG lVRx; /* x-axis angular velocity */ + LONG lVRy; /* y-axis angular velocity */ + LONG lVRz; /* z-axis angular velocity */ + LONG rglVSlider[2]; /* extra axes velocities */ + LONG lAX; /* x-axis acceleration */ + LONG lAY; /* y-axis acceleration */ + LONG lAZ; /* z-axis acceleration */ + LONG lARx; /* x-axis angular acceleration */ + LONG lARy; /* y-axis angular acceleration */ + LONG lARz; /* z-axis angular acceleration */ + LONG rglASlider[2]; /* extra axes accelerations */ + LONG lFX; /* x-axis force */ + LONG lFY; /* y-axis force */ + LONG lFZ; /* z-axis force */ + LONG lFRx; /* x-axis torque */ + LONG lFRy; /* y-axis torque */ + LONG lFRz; /* z-axis torque */ + LONG rglFSlider[2]; /* extra axes forces */ +} DIJOYSTATE2, *LPDIJOYSTATE2; + +#define DIJOFS_X FIELD_OFFSET(DIJOYSTATE, lX) +#define DIJOFS_Y FIELD_OFFSET(DIJOYSTATE, lY) +#define DIJOFS_Z FIELD_OFFSET(DIJOYSTATE, lZ) +#define DIJOFS_RX FIELD_OFFSET(DIJOYSTATE, lRx) +#define DIJOFS_RY FIELD_OFFSET(DIJOYSTATE, lRy) +#define DIJOFS_RZ FIELD_OFFSET(DIJOYSTATE, lRz) +#define DIJOFS_SLIDER(n) (FIELD_OFFSET(DIJOYSTATE, rglSlider) + \ + (n) * sizeof(LONG)) +#define DIJOFS_POV(n) (FIELD_OFFSET(DIJOYSTATE, rgdwPOV) + \ + (n) * sizeof(DWORD)) +#define DIJOFS_BUTTON(n) (FIELD_OFFSET(DIJOYSTATE, rgbButtons) + (n)) +#define DIJOFS_BUTTON0 DIJOFS_BUTTON(0) +#define DIJOFS_BUTTON1 DIJOFS_BUTTON(1) +#define DIJOFS_BUTTON2 DIJOFS_BUTTON(2) +#define DIJOFS_BUTTON3 DIJOFS_BUTTON(3) +#define DIJOFS_BUTTON4 DIJOFS_BUTTON(4) +#define DIJOFS_BUTTON5 DIJOFS_BUTTON(5) +#define DIJOFS_BUTTON6 DIJOFS_BUTTON(6) +#define DIJOFS_BUTTON7 DIJOFS_BUTTON(7) +#define DIJOFS_BUTTON8 DIJOFS_BUTTON(8) +#define DIJOFS_BUTTON9 DIJOFS_BUTTON(9) +#define DIJOFS_BUTTON10 DIJOFS_BUTTON(10) +#define DIJOFS_BUTTON11 DIJOFS_BUTTON(11) +#define DIJOFS_BUTTON12 DIJOFS_BUTTON(12) +#define DIJOFS_BUTTON13 DIJOFS_BUTTON(13) +#define DIJOFS_BUTTON14 DIJOFS_BUTTON(14) +#define DIJOFS_BUTTON15 DIJOFS_BUTTON(15) +#define DIJOFS_BUTTON16 DIJOFS_BUTTON(16) +#define DIJOFS_BUTTON17 DIJOFS_BUTTON(17) +#define DIJOFS_BUTTON18 DIJOFS_BUTTON(18) +#define DIJOFS_BUTTON19 DIJOFS_BUTTON(19) +#define DIJOFS_BUTTON20 DIJOFS_BUTTON(20) +#define DIJOFS_BUTTON21 DIJOFS_BUTTON(21) +#define DIJOFS_BUTTON22 DIJOFS_BUTTON(22) +#define DIJOFS_BUTTON23 DIJOFS_BUTTON(23) +#define DIJOFS_BUTTON24 DIJOFS_BUTTON(24) +#define DIJOFS_BUTTON25 DIJOFS_BUTTON(25) +#define DIJOFS_BUTTON26 DIJOFS_BUTTON(26) +#define DIJOFS_BUTTON27 DIJOFS_BUTTON(27) +#define DIJOFS_BUTTON28 DIJOFS_BUTTON(28) +#define DIJOFS_BUTTON29 DIJOFS_BUTTON(29) +#define DIJOFS_BUTTON30 DIJOFS_BUTTON(30) +#define DIJOFS_BUTTON31 DIJOFS_BUTTON(31) + + +#endif /* DIJ_RINGZERO */ + +/**************************************************************************** + * + * IDirectInput + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +#define DIENUM_STOP 0 +#define DIENUM_CONTINUE 1 + +typedef BOOL (FAR PASCAL * LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA, LPVOID); +typedef BOOL (FAR PASCAL * LPDIENUMDEVICESCALLBACKW)(LPCDIDEVICEINSTANCEW, LPVOID); +#ifdef UNICODE +#define LPDIENUMDEVICESCALLBACK LPDIENUMDEVICESCALLBACKW +#else +#define LPDIENUMDEVICESCALLBACK LPDIENUMDEVICESCALLBACKA +#endif // !UNICODE +typedef BOOL (FAR PASCAL * LPDICONFIGUREDEVICESCALLBACK)(IUnknown FAR *, LPVOID); + +#define DIEDFL_ALLDEVICES 0x00000000 +#define DIEDFL_ATTACHEDONLY 0x00000001 +#if(DIRECTINPUT_VERSION >= 0x0500) +#define DIEDFL_FORCEFEEDBACK 0x00000100 +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIEDFL_INCLUDEALIASES 0x00010000 +#define DIEDFL_INCLUDEPHANTOMS 0x00020000 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIEDFL_INCLUDEHIDDEN 0x00040000 +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + + +#if(DIRECTINPUT_VERSION >= 0x0800) +typedef BOOL (FAR PASCAL * LPDIENUMDEVICESBYSEMANTICSCBA)(LPCDIDEVICEINSTANCEA, LPDIRECTINPUTDEVICE8A, DWORD, DWORD, LPVOID); +typedef BOOL (FAR PASCAL * LPDIENUMDEVICESBYSEMANTICSCBW)(LPCDIDEVICEINSTANCEW, LPDIRECTINPUTDEVICE8W, DWORD, DWORD, LPVOID); +#ifdef UNICODE +#define LPDIENUMDEVICESBYSEMANTICSCB LPDIENUMDEVICESBYSEMANTICSCBW +#else +#define LPDIENUMDEVICESBYSEMANTICSCB LPDIENUMDEVICESBYSEMANTICSCBA +#endif // !UNICODE +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIEDBS_MAPPEDPRI1 0x00000001 +#define DIEDBS_MAPPEDPRI2 0x00000002 +#define DIEDBS_RECENTDEVICE 0x00000010 +#define DIEDBS_NEWDEVICE 0x00000020 +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIEDBSFL_ATTACHEDONLY 0x00000000 +#define DIEDBSFL_THISUSER 0x00000010 +#define DIEDBSFL_FORCEFEEDBACK DIEDFL_FORCEFEEDBACK +#define DIEDBSFL_AVAILABLEDEVICES 0x00001000 +#define DIEDBSFL_MULTIMICEKEYBOARDS 0x00002000 +#define DIEDBSFL_NONGAMINGDEVICES 0x00004000 +#define DIEDBSFL_VALID 0x00007110 +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#undef INTERFACE +#define INTERFACE IDirectInputW + +DECLARE_INTERFACE_(IDirectInputW, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputW methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; +}; + +typedef struct IDirectInputW *LPDIRECTINPUTW; + +#undef INTERFACE +#define INTERFACE IDirectInputA + +DECLARE_INTERFACE_(IDirectInputA, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputA methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; +}; + +typedef struct IDirectInputA *LPDIRECTINPUTA; + +#ifdef UNICODE +#define IID_IDirectInput IID_IDirectInputW +#define IDirectInput IDirectInputW +#define IDirectInputVtbl IDirectInputWVtbl +#else +#define IID_IDirectInput IID_IDirectInputA +#define IDirectInput IDirectInputA +#define IDirectInputVtbl IDirectInputAVtbl +#endif +typedef struct IDirectInput *LPDIRECTINPUT; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInput_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInput_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInput_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInput_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) +#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) +#define IDirectInput_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) +#define IDirectInput_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInput_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#else +#define IDirectInput_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInput_AddRef(p) (p)->AddRef() +#define IDirectInput_Release(p) (p)->Release() +#define IDirectInput_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) +#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) +#define IDirectInput_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) +#define IDirectInput_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInput_Initialize(p,a,b) (p)->Initialize(a,b) +#endif + +#undef INTERFACE +#define INTERFACE IDirectInput2W + +DECLARE_INTERFACE_(IDirectInput2W, IDirectInputW) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputW methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + + /*** IDirectInput2W methods ***/ + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; +}; + +typedef struct IDirectInput2W *LPDIRECTINPUT2W; + +#undef INTERFACE +#define INTERFACE IDirectInput2A + +DECLARE_INTERFACE_(IDirectInput2A, IDirectInputA) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputA methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + + /*** IDirectInput2A methods ***/ + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; +}; + +typedef struct IDirectInput2A *LPDIRECTINPUT2A; + +#ifdef UNICODE +#define IID_IDirectInput2 IID_IDirectInput2W +#define IDirectInput2 IDirectInput2W +#define IDirectInput2Vtbl IDirectInput2WVtbl +#else +#define IID_IDirectInput2 IID_IDirectInput2A +#define IDirectInput2 IDirectInput2A +#define IDirectInput2Vtbl IDirectInput2AVtbl +#endif +typedef struct IDirectInput2 *LPDIRECTINPUT2; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInput2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInput2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInput2_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInput2_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) +#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) +#define IDirectInput2_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) +#define IDirectInput2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInput2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectInput2_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) +#else +#define IDirectInput2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInput2_AddRef(p) (p)->AddRef() +#define IDirectInput2_Release(p) (p)->Release() +#define IDirectInput2_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) +#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) +#define IDirectInput2_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) +#define IDirectInput2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInput2_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectInput2_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) +#endif + + +#undef INTERFACE +#define INTERFACE IDirectInput7W + +DECLARE_INTERFACE_(IDirectInput7W, IDirectInput2W) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInput2W methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; + + /*** IDirectInput7W methods ***/ + STDMETHOD(CreateDeviceEx)(THIS_ REFGUID,REFIID,LPVOID *,LPUNKNOWN) PURE; +}; + +typedef struct IDirectInput7W *LPDIRECTINPUT7W; + +#undef INTERFACE +#define INTERFACE IDirectInput7A + +DECLARE_INTERFACE_(IDirectInput7A, IDirectInput2A) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInput2A methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; + + /*** IDirectInput7A methods ***/ + STDMETHOD(CreateDeviceEx)(THIS_ REFGUID,REFIID,LPVOID *,LPUNKNOWN) PURE; +}; + +typedef struct IDirectInput7A *LPDIRECTINPUT7A; + +#ifdef UNICODE +#define IID_IDirectInput7 IID_IDirectInput7W +#define IDirectInput7 IDirectInput7W +#define IDirectInput7Vtbl IDirectInput7WVtbl +#else +#define IID_IDirectInput7 IID_IDirectInput7A +#define IDirectInput7 IDirectInput7A +#define IDirectInput7Vtbl IDirectInput7AVtbl +#endif +typedef struct IDirectInput7 *LPDIRECTINPUT7; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInput7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInput7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInput7_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInput7_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) +#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) +#define IDirectInput7_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) +#define IDirectInput7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInput7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectInput7_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) +#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d) +#else +#define IDirectInput7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInput7_AddRef(p) (p)->AddRef() +#define IDirectInput7_Release(p) (p)->Release() +#define IDirectInput7_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) +#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) +#define IDirectInput7_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) +#define IDirectInput7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInput7_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectInput7_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) +#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->CreateDeviceEx(a,b,c,d) +#endif + +#if(DIRECTINPUT_VERSION >= 0x0800) +#undef INTERFACE +#define INTERFACE IDirectInput8W + +DECLARE_INTERFACE_(IDirectInput8W, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInput8W methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICE8W *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; + STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCWSTR,LPDIACTIONFORMATW,LPDIENUMDEVICESBYSEMANTICSCBW,LPVOID,DWORD) PURE; + STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK,LPDICONFIGUREDEVICESPARAMSW,DWORD,LPVOID) PURE; +}; + +typedef struct IDirectInput8W *LPDIRECTINPUT8W; + +#undef INTERFACE +#define INTERFACE IDirectInput8A + +DECLARE_INTERFACE_(IDirectInput8A, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInput8A methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICE8A *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; + STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCSTR,LPDIACTIONFORMATA,LPDIENUMDEVICESBYSEMANTICSCBA,LPVOID,DWORD) PURE; + STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK,LPDICONFIGUREDEVICESPARAMSA,DWORD,LPVOID) PURE; +}; + +typedef struct IDirectInput8A *LPDIRECTINPUT8A; + +#ifdef UNICODE +#define IID_IDirectInput8 IID_IDirectInput8W +#define IDirectInput8 IDirectInput8W +#define IDirectInput8Vtbl IDirectInput8WVtbl +#else +#define IID_IDirectInput8 IID_IDirectInput8A +#define IDirectInput8 IDirectInput8A +#define IDirectInput8Vtbl IDirectInput8AVtbl +#endif +typedef struct IDirectInput8 *LPDIRECTINPUT8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInput8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInput8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInput8_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInput8_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) +#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) +#define IDirectInput8_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) +#define IDirectInput8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInput8_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectInput8_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) +#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->lpVtbl->EnumDevicesBySemantics(p,a,b,c,d,e) +#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d) +#else +#define IDirectInput8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInput8_AddRef(p) (p)->AddRef() +#define IDirectInput8_Release(p) (p)->Release() +#define IDirectInput8_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) +#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) +#define IDirectInput8_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) +#define IDirectInput8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInput8_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectInput8_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) +#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->EnumDevicesBySemantics(a,b,c,d,e) +#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->ConfigureDevices(a,b,c,d) +#endif +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#if DIRECTINPUT_VERSION > 0x0700 + +extern HRESULT WINAPI DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter); + +#else +extern HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter); +extern HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter); +#ifdef UNICODE +#define DirectInputCreate DirectInputCreateW +#else +#define DirectInputCreate DirectInputCreateA +#endif // !UNICODE + +extern HRESULT WINAPI DirectInputCreateEx(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter); + +#endif /* DIRECTINPUT_VERSION > 0x700 */ + +#endif /* DIJ_RINGZERO */ + + +/**************************************************************************** + * + * Return Codes + * + ****************************************************************************/ + +/* + * The operation completed successfully. + */ +#define DI_OK S_OK + +/* + * The device exists but is not currently attached. + */ +#define DI_NOTATTACHED S_FALSE + +/* + * The device buffer overflowed. Some input was lost. + */ +#define DI_BUFFEROVERFLOW S_FALSE + +/* + * The change in device properties had no effect. + */ +#define DI_PROPNOEFFECT S_FALSE + +/* + * The operation had no effect. + */ +#define DI_NOEFFECT S_FALSE + +/* + * The device is a polled device. As a result, device buffering + * will not collect any data and event notifications will not be + * signalled until GetDeviceState is called. + */ +#define DI_POLLEDDEVICE ((HRESULT)0x00000002L) + +/* + * The parameters of the effect were successfully updated by + * IDirectInputEffect::SetParameters, but the effect was not + * downloaded because the device is not exclusively acquired + * or because the DIEP_NODOWNLOAD flag was passed. + */ +#define DI_DOWNLOADSKIPPED ((HRESULT)0x00000003L) + +/* + * The parameters of the effect were successfully updated by + * IDirectInputEffect::SetParameters, but in order to change + * the parameters, the effect needed to be restarted. + */ +#define DI_EFFECTRESTARTED ((HRESULT)0x00000004L) + +/* + * The parameters of the effect were successfully updated by + * IDirectInputEffect::SetParameters, but some of them were + * beyond the capabilities of the device and were truncated. + */ +#define DI_TRUNCATED ((HRESULT)0x00000008L) + +/* + * The settings have been successfully applied but could not be + * persisted. + */ +#define DI_SETTINGSNOTSAVED ((HRESULT)0x0000000BL) + +/* + * Equal to DI_EFFECTRESTARTED | DI_TRUNCATED. + */ +#define DI_TRUNCATEDANDRESTARTED ((HRESULT)0x0000000CL) + +/* + * A SUCCESS code indicating that settings cannot be modified. + */ +#define DI_WRITEPROTECT ((HRESULT)0x00000013L) + +/* + * The application requires a newer version of DirectInput. + */ +#define DIERR_OLDDIRECTINPUTVERSION \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_OLD_WIN_VERSION) + +/* + * The application was written for an unsupported prerelease version + * of DirectInput. + */ +#define DIERR_BETADIRECTINPUTVERSION \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_RMODE_APP) + +/* + * The object could not be created due to an incompatible driver version + * or mismatched or incomplete driver components. + */ +#define DIERR_BADDRIVERVER \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BAD_DRIVER_LEVEL) + +/* + * The device or device instance or effect is not registered with DirectInput. + */ +#define DIERR_DEVICENOTREG REGDB_E_CLASSNOTREG + +/* + * The requested object does not exist. + */ +#define DIERR_NOTFOUND \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND) + +/* + * The requested object does not exist. + */ +#define DIERR_OBJECTNOTFOUND \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND) + +/* + * An invalid parameter was passed to the returning function, + * or the object was not in a state that admitted the function + * to be called. + */ +#define DIERR_INVALIDPARAM E_INVALIDARG + +/* + * The specified interface is not supported by the object + */ +#define DIERR_NOINTERFACE E_NOINTERFACE + +/* + * An undetermined error occured inside the DInput subsystem + */ +#define DIERR_GENERIC E_FAIL + +/* + * The DInput subsystem couldn't allocate sufficient memory to complete the + * caller's request. + */ +#define DIERR_OUTOFMEMORY E_OUTOFMEMORY + +/* + * The function called is not supported at this time + */ +#define DIERR_UNSUPPORTED E_NOTIMPL + +/* + * This object has not been initialized + */ +#define DIERR_NOTINITIALIZED \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_READY) + +/* + * This object is already initialized + */ +#define DIERR_ALREADYINITIALIZED \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_ALREADY_INITIALIZED) + +/* + * This object does not support aggregation + */ +#define DIERR_NOAGGREGATION CLASS_E_NOAGGREGATION + +/* + * Another app has a higher priority level, preventing this call from + * succeeding. + */ +#define DIERR_OTHERAPPHASPRIO E_ACCESSDENIED + +/* + * Access to the device has been lost. It must be re-acquired. + */ +#define DIERR_INPUTLOST \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_READ_FAULT) + +/* + * The operation cannot be performed while the device is acquired. + */ +#define DIERR_ACQUIRED \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BUSY) + +/* + * The operation cannot be performed unless the device is acquired. + */ +#define DIERR_NOTACQUIRED \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_INVALID_ACCESS) + +/* + * The specified property cannot be changed. + */ +#define DIERR_READONLY E_ACCESSDENIED + +/* + * The device already has an event notification associated with it. + */ +#define DIERR_HANDLEEXISTS E_ACCESSDENIED + +/* + * Data is not yet available. + */ +#ifndef E_PENDING +#define E_PENDING 0x8000000AL +#endif + +/* + * Unable to IDirectInputJoyConfig_Acquire because the user + * does not have sufficient privileges to change the joystick + * configuration. + */ +#define DIERR_INSUFFICIENTPRIVS 0x80040200L + +/* + * The device is full. + */ +#define DIERR_DEVICEFULL 0x80040201L + +/* + * Not all the requested information fit into the buffer. + */ +#define DIERR_MOREDATA 0x80040202L + +/* + * The effect is not downloaded. + */ +#define DIERR_NOTDOWNLOADED 0x80040203L + +/* + * The device cannot be reinitialized because there are still effects + * attached to it. + */ +#define DIERR_HASEFFECTS 0x80040204L + +/* + * The operation cannot be performed unless the device is acquired + * in DISCL_EXCLUSIVE mode. + */ +#define DIERR_NOTEXCLUSIVEACQUIRED 0x80040205L + +/* + * The effect could not be downloaded because essential information + * is missing. For example, no axes have been associated with the + * effect, or no type-specific information has been created. + */ +#define DIERR_INCOMPLETEEFFECT 0x80040206L + +/* + * Attempted to read buffered device data from a device that is + * not buffered. + */ +#define DIERR_NOTBUFFERED 0x80040207L + +/* + * An attempt was made to modify parameters of an effect while it is + * playing. Not all hardware devices support altering the parameters + * of an effect while it is playing. + */ +#define DIERR_EFFECTPLAYING 0x80040208L + +/* + * The operation could not be completed because the device is not + * plugged in. + */ +#define DIERR_UNPLUGGED 0x80040209L + +/* + * SendDeviceData failed because more information was requested + * to be sent than can be sent to the device. Some devices have + * restrictions on how much data can be sent to them. (For example, + * there might be a limit on the number of buttons that can be + * pressed at once.) + */ +#define DIERR_REPORTFULL 0x8004020AL + + +/* + * A mapper file function failed because reading or writing the user or IHV + * settings file failed. + */ +#define DIERR_MAPFILEFAIL 0x8004020BL + + +/*--- DINPUT Mapper Definitions: New for Dx8 ---*/ + + +/*--- Keyboard + Physical Keyboard Device ---*/ + +#define DIKEYBOARD_ESCAPE 0x81000401 +#define DIKEYBOARD_1 0x81000402 +#define DIKEYBOARD_2 0x81000403 +#define DIKEYBOARD_3 0x81000404 +#define DIKEYBOARD_4 0x81000405 +#define DIKEYBOARD_5 0x81000406 +#define DIKEYBOARD_6 0x81000407 +#define DIKEYBOARD_7 0x81000408 +#define DIKEYBOARD_8 0x81000409 +#define DIKEYBOARD_9 0x8100040A +#define DIKEYBOARD_0 0x8100040B +#define DIKEYBOARD_MINUS 0x8100040C /* - on main keyboard */ +#define DIKEYBOARD_EQUALS 0x8100040D +#define DIKEYBOARD_BACK 0x8100040E /* backspace */ +#define DIKEYBOARD_TAB 0x8100040F +#define DIKEYBOARD_Q 0x81000410 +#define DIKEYBOARD_W 0x81000411 +#define DIKEYBOARD_E 0x81000412 +#define DIKEYBOARD_R 0x81000413 +#define DIKEYBOARD_T 0x81000414 +#define DIKEYBOARD_Y 0x81000415 +#define DIKEYBOARD_U 0x81000416 +#define DIKEYBOARD_I 0x81000417 +#define DIKEYBOARD_O 0x81000418 +#define DIKEYBOARD_P 0x81000419 +#define DIKEYBOARD_LBRACKET 0x8100041A +#define DIKEYBOARD_RBRACKET 0x8100041B +#define DIKEYBOARD_RETURN 0x8100041C /* Enter on main keyboard */ +#define DIKEYBOARD_LCONTROL 0x8100041D +#define DIKEYBOARD_A 0x8100041E +#define DIKEYBOARD_S 0x8100041F +#define DIKEYBOARD_D 0x81000420 +#define DIKEYBOARD_F 0x81000421 +#define DIKEYBOARD_G 0x81000422 +#define DIKEYBOARD_H 0x81000423 +#define DIKEYBOARD_J 0x81000424 +#define DIKEYBOARD_K 0x81000425 +#define DIKEYBOARD_L 0x81000426 +#define DIKEYBOARD_SEMICOLON 0x81000427 +#define DIKEYBOARD_APOSTROPHE 0x81000428 +#define DIKEYBOARD_GRAVE 0x81000429 /* accent grave */ +#define DIKEYBOARD_LSHIFT 0x8100042A +#define DIKEYBOARD_BACKSLASH 0x8100042B +#define DIKEYBOARD_Z 0x8100042C +#define DIKEYBOARD_X 0x8100042D +#define DIKEYBOARD_C 0x8100042E +#define DIKEYBOARD_V 0x8100042F +#define DIKEYBOARD_B 0x81000430 +#define DIKEYBOARD_N 0x81000431 +#define DIKEYBOARD_M 0x81000432 +#define DIKEYBOARD_COMMA 0x81000433 +#define DIKEYBOARD_PERIOD 0x81000434 /* . on main keyboard */ +#define DIKEYBOARD_SLASH 0x81000435 /* / on main keyboard */ +#define DIKEYBOARD_RSHIFT 0x81000436 +#define DIKEYBOARD_MULTIPLY 0x81000437 /* * on numeric keypad */ +#define DIKEYBOARD_LMENU 0x81000438 /* left Alt */ +#define DIKEYBOARD_SPACE 0x81000439 +#define DIKEYBOARD_CAPITAL 0x8100043A +#define DIKEYBOARD_F1 0x8100043B +#define DIKEYBOARD_F2 0x8100043C +#define DIKEYBOARD_F3 0x8100043D +#define DIKEYBOARD_F4 0x8100043E +#define DIKEYBOARD_F5 0x8100043F +#define DIKEYBOARD_F6 0x81000440 +#define DIKEYBOARD_F7 0x81000441 +#define DIKEYBOARD_F8 0x81000442 +#define DIKEYBOARD_F9 0x81000443 +#define DIKEYBOARD_F10 0x81000444 +#define DIKEYBOARD_NUMLOCK 0x81000445 +#define DIKEYBOARD_SCROLL 0x81000446 /* Scroll Lock */ +#define DIKEYBOARD_NUMPAD7 0x81000447 +#define DIKEYBOARD_NUMPAD8 0x81000448 +#define DIKEYBOARD_NUMPAD9 0x81000449 +#define DIKEYBOARD_SUBTRACT 0x8100044A /* - on numeric keypad */ +#define DIKEYBOARD_NUMPAD4 0x8100044B +#define DIKEYBOARD_NUMPAD5 0x8100044C +#define DIKEYBOARD_NUMPAD6 0x8100044D +#define DIKEYBOARD_ADD 0x8100044E /* + on numeric keypad */ +#define DIKEYBOARD_NUMPAD1 0x8100044F +#define DIKEYBOARD_NUMPAD2 0x81000450 +#define DIKEYBOARD_NUMPAD3 0x81000451 +#define DIKEYBOARD_NUMPAD0 0x81000452 +#define DIKEYBOARD_DECIMAL 0x81000453 /* . on numeric keypad */ +#define DIKEYBOARD_OEM_102 0x81000456 /* <> or \| on RT 102-key keyboard (Non-U.S.) */ +#define DIKEYBOARD_F11 0x81000457 +#define DIKEYBOARD_F12 0x81000458 +#define DIKEYBOARD_F13 0x81000464 /* (NEC PC98) */ +#define DIKEYBOARD_F14 0x81000465 /* (NEC PC98) */ +#define DIKEYBOARD_F15 0x81000466 /* (NEC PC98) */ +#define DIKEYBOARD_KANA 0x81000470 /* (Japanese keyboard) */ +#define DIKEYBOARD_ABNT_C1 0x81000473 /* /? on Brazilian keyboard */ +#define DIKEYBOARD_CONVERT 0x81000479 /* (Japanese keyboard) */ +#define DIKEYBOARD_NOCONVERT 0x8100047B /* (Japanese keyboard) */ +#define DIKEYBOARD_YEN 0x8100047D /* (Japanese keyboard) */ +#define DIKEYBOARD_ABNT_C2 0x8100047E /* Numpad . on Brazilian keyboard */ +#define DIKEYBOARD_NUMPADEQUALS 0x8100048D /* = on numeric keypad (NEC PC98) */ +#define DIKEYBOARD_PREVTRACK 0x81000490 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */ +#define DIKEYBOARD_AT 0x81000491 /* (NEC PC98) */ +#define DIKEYBOARD_COLON 0x81000492 /* (NEC PC98) */ +#define DIKEYBOARD_UNDERLINE 0x81000493 /* (NEC PC98) */ +#define DIKEYBOARD_KANJI 0x81000494 /* (Japanese keyboard) */ +#define DIKEYBOARD_STOP 0x81000495 /* (NEC PC98) */ +#define DIKEYBOARD_AX 0x81000496 /* (Japan AX) */ +#define DIKEYBOARD_UNLABELED 0x81000497 /* (J3100) */ +#define DIKEYBOARD_NEXTTRACK 0x81000499 /* Next Track */ +#define DIKEYBOARD_NUMPADENTER 0x8100049C /* Enter on numeric keypad */ +#define DIKEYBOARD_RCONTROL 0x8100049D +#define DIKEYBOARD_MUTE 0x810004A0 /* Mute */ +#define DIKEYBOARD_CALCULATOR 0x810004A1 /* Calculator */ +#define DIKEYBOARD_PLAYPAUSE 0x810004A2 /* Play / Pause */ +#define DIKEYBOARD_MEDIASTOP 0x810004A4 /* Media Stop */ +#define DIKEYBOARD_VOLUMEDOWN 0x810004AE /* Volume - */ +#define DIKEYBOARD_VOLUMEUP 0x810004B0 /* Volume + */ +#define DIKEYBOARD_WEBHOME 0x810004B2 /* Web home */ +#define DIKEYBOARD_NUMPADCOMMA 0x810004B3 /* , on numeric keypad (NEC PC98) */ +#define DIKEYBOARD_DIVIDE 0x810004B5 /* / on numeric keypad */ +#define DIKEYBOARD_SYSRQ 0x810004B7 +#define DIKEYBOARD_RMENU 0x810004B8 /* right Alt */ +#define DIKEYBOARD_PAUSE 0x810004C5 /* Pause */ +#define DIKEYBOARD_HOME 0x810004C7 /* Home on arrow keypad */ +#define DIKEYBOARD_UP 0x810004C8 /* UpArrow on arrow keypad */ +#define DIKEYBOARD_PRIOR 0x810004C9 /* PgUp on arrow keypad */ +#define DIKEYBOARD_LEFT 0x810004CB /* LeftArrow on arrow keypad */ +#define DIKEYBOARD_RIGHT 0x810004CD /* RightArrow on arrow keypad */ +#define DIKEYBOARD_END 0x810004CF /* End on arrow keypad */ +#define DIKEYBOARD_DOWN 0x810004D0 /* DownArrow on arrow keypad */ +#define DIKEYBOARD_NEXT 0x810004D1 /* PgDn on arrow keypad */ +#define DIKEYBOARD_INSERT 0x810004D2 /* Insert on arrow keypad */ +#define DIKEYBOARD_DELETE 0x810004D3 /* Delete on arrow keypad */ +#define DIKEYBOARD_LWIN 0x810004DB /* Left Windows key */ +#define DIKEYBOARD_RWIN 0x810004DC /* Right Windows key */ +#define DIKEYBOARD_APPS 0x810004DD /* AppMenu key */ +#define DIKEYBOARD_POWER 0x810004DE /* System Power */ +#define DIKEYBOARD_SLEEP 0x810004DF /* System Sleep */ +#define DIKEYBOARD_WAKE 0x810004E3 /* System Wake */ +#define DIKEYBOARD_WEBSEARCH 0x810004E5 /* Web Search */ +#define DIKEYBOARD_WEBFAVORITES 0x810004E6 /* Web Favorites */ +#define DIKEYBOARD_WEBREFRESH 0x810004E7 /* Web Refresh */ +#define DIKEYBOARD_WEBSTOP 0x810004E8 /* Web Stop */ +#define DIKEYBOARD_WEBFORWARD 0x810004E9 /* Web Forward */ +#define DIKEYBOARD_WEBBACK 0x810004EA /* Web Back */ +#define DIKEYBOARD_MYCOMPUTER 0x810004EB /* My Computer */ +#define DIKEYBOARD_MAIL 0x810004EC /* Mail */ +#define DIKEYBOARD_MEDIASELECT 0x810004ED /* Media Select */ + + +/*--- MOUSE + Physical Mouse Device ---*/ + +#define DIMOUSE_XAXISAB (0x82000200 |DIMOFS_X ) /* X Axis-absolute: Some mice natively report absolute coordinates */ +#define DIMOUSE_YAXISAB (0x82000200 |DIMOFS_Y ) /* Y Axis-absolute: Some mice natively report absolute coordinates */ +#define DIMOUSE_XAXIS (0x82000300 |DIMOFS_X ) /* X Axis */ +#define DIMOUSE_YAXIS (0x82000300 |DIMOFS_Y ) /* Y Axis */ +#define DIMOUSE_WHEEL (0x82000300 |DIMOFS_Z ) /* Z Axis */ +#define DIMOUSE_BUTTON0 (0x82000400 |DIMOFS_BUTTON0) /* Button 0 */ +#define DIMOUSE_BUTTON1 (0x82000400 |DIMOFS_BUTTON1) /* Button 1 */ +#define DIMOUSE_BUTTON2 (0x82000400 |DIMOFS_BUTTON2) /* Button 2 */ +#define DIMOUSE_BUTTON3 (0x82000400 |DIMOFS_BUTTON3) /* Button 3 */ +#define DIMOUSE_BUTTON4 (0x82000400 |DIMOFS_BUTTON4) /* Button 4 */ +#define DIMOUSE_BUTTON5 (0x82000400 |DIMOFS_BUTTON5) /* Button 5 */ +#define DIMOUSE_BUTTON6 (0x82000400 |DIMOFS_BUTTON6) /* Button 6 */ +#define DIMOUSE_BUTTON7 (0x82000400 |DIMOFS_BUTTON7) /* Button 7 */ + + +/*--- VOICE + Physical Dplay Voice Device ---*/ + +#define DIVOICE_CHANNEL1 0x83000401 +#define DIVOICE_CHANNEL2 0x83000402 +#define DIVOICE_CHANNEL3 0x83000403 +#define DIVOICE_CHANNEL4 0x83000404 +#define DIVOICE_CHANNEL5 0x83000405 +#define DIVOICE_CHANNEL6 0x83000406 +#define DIVOICE_CHANNEL7 0x83000407 +#define DIVOICE_CHANNEL8 0x83000408 +#define DIVOICE_TEAM 0x83000409 +#define DIVOICE_ALL 0x8300040A +#define DIVOICE_RECORDMUTE 0x8300040B +#define DIVOICE_PLAYBACKMUTE 0x8300040C +#define DIVOICE_TRANSMIT 0x8300040D + +#define DIVOICE_VOICECOMMAND 0x83000410 + + +/*--- Driving Simulator - Racing + Vehicle control is primary objective ---*/ +#define DIVIRTUAL_DRIVING_RACE 0x01000000 +#define DIAXIS_DRIVINGR_STEER 0x01008A01 /* Steering */ +#define DIAXIS_DRIVINGR_ACCELERATE 0x01039202 /* Accelerate */ +#define DIAXIS_DRIVINGR_BRAKE 0x01041203 /* Brake-Axis */ +#define DIBUTTON_DRIVINGR_SHIFTUP 0x01000C01 /* Shift to next higher gear */ +#define DIBUTTON_DRIVINGR_SHIFTDOWN 0x01000C02 /* Shift to next lower gear */ +#define DIBUTTON_DRIVINGR_VIEW 0x01001C03 /* Cycle through view options */ +#define DIBUTTON_DRIVINGR_MENU 0x010004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIAXIS_DRIVINGR_ACCEL_AND_BRAKE 0x01014A04 /* Some devices combine accelerate and brake in a single axis */ +#define DIHATSWITCH_DRIVINGR_GLANCE 0x01004601 /* Look around */ +#define DIBUTTON_DRIVINGR_BRAKE 0x01004C04 /* Brake-button */ +#define DIBUTTON_DRIVINGR_DASHBOARD 0x01004405 /* Select next dashboard option */ +#define DIBUTTON_DRIVINGR_AIDS 0x01004406 /* Driver correction aids */ +#define DIBUTTON_DRIVINGR_MAP 0x01004407 /* Display Driving Map */ +#define DIBUTTON_DRIVINGR_BOOST 0x01004408 /* Turbo Boost */ +#define DIBUTTON_DRIVINGR_PIT 0x01004409 /* Pit stop notification */ +#define DIBUTTON_DRIVINGR_ACCELERATE_LINK 0x0103D4E0 /* Fallback Accelerate button */ +#define DIBUTTON_DRIVINGR_STEER_LEFT_LINK 0x0100CCE4 /* Fallback Steer Left button */ +#define DIBUTTON_DRIVINGR_STEER_RIGHT_LINK 0x0100CCEC /* Fallback Steer Right button */ +#define DIBUTTON_DRIVINGR_GLANCE_LEFT_LINK 0x0107C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_DRIVINGR_GLANCE_RIGHT_LINK 0x0107C4EC /* Fallback Glance Right button */ +#define DIBUTTON_DRIVINGR_DEVICE 0x010044FE /* Show input device and controls */ +#define DIBUTTON_DRIVINGR_PAUSE 0x010044FC /* Start / Pause / Restart game */ + +/*--- Driving Simulator - Combat + Combat from within a vehicle is primary objective ---*/ +#define DIVIRTUAL_DRIVING_COMBAT 0x02000000 +#define DIAXIS_DRIVINGC_STEER 0x02008A01 /* Steering */ +#define DIAXIS_DRIVINGC_ACCELERATE 0x02039202 /* Accelerate */ +#define DIAXIS_DRIVINGC_BRAKE 0x02041203 /* Brake-axis */ +#define DIBUTTON_DRIVINGC_FIRE 0x02000C01 /* Fire */ +#define DIBUTTON_DRIVINGC_WEAPONS 0x02000C02 /* Select next weapon */ +#define DIBUTTON_DRIVINGC_TARGET 0x02000C03 /* Select next available target */ +#define DIBUTTON_DRIVINGC_MENU 0x020004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIAXIS_DRIVINGC_ACCEL_AND_BRAKE 0x02014A04 /* Some devices combine accelerate and brake in a single axis */ +#define DIHATSWITCH_DRIVINGC_GLANCE 0x02004601 /* Look around */ +#define DIBUTTON_DRIVINGC_SHIFTUP 0x02004C04 /* Shift to next higher gear */ +#define DIBUTTON_DRIVINGC_SHIFTDOWN 0x02004C05 /* Shift to next lower gear */ +#define DIBUTTON_DRIVINGC_DASHBOARD 0x02004406 /* Select next dashboard option */ +#define DIBUTTON_DRIVINGC_AIDS 0x02004407 /* Driver correction aids */ +#define DIBUTTON_DRIVINGC_BRAKE 0x02004C08 /* Brake-button */ +#define DIBUTTON_DRIVINGC_FIRESECONDARY 0x02004C09 /* Alternative fire button */ +#define DIBUTTON_DRIVINGC_ACCELERATE_LINK 0x0203D4E0 /* Fallback Accelerate button */ +#define DIBUTTON_DRIVINGC_STEER_LEFT_LINK 0x0200CCE4 /* Fallback Steer Left button */ +#define DIBUTTON_DRIVINGC_STEER_RIGHT_LINK 0x0200CCEC /* Fallback Steer Right button */ +#define DIBUTTON_DRIVINGC_GLANCE_LEFT_LINK 0x0207C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_DRIVINGC_GLANCE_RIGHT_LINK 0x0207C4EC /* Fallback Glance Right button */ +#define DIBUTTON_DRIVINGC_DEVICE 0x020044FE /* Show input device and controls */ +#define DIBUTTON_DRIVINGC_PAUSE 0x020044FC /* Start / Pause / Restart game */ + +/*--- Driving Simulator - Tank + Combat from withing a tank is primary objective ---*/ +#define DIVIRTUAL_DRIVING_TANK 0x03000000 +#define DIAXIS_DRIVINGT_STEER 0x03008A01 /* Turn tank left / right */ +#define DIAXIS_DRIVINGT_BARREL 0x03010202 /* Raise / lower barrel */ +#define DIAXIS_DRIVINGT_ACCELERATE 0x03039203 /* Accelerate */ +#define DIAXIS_DRIVINGT_ROTATE 0x03020204 /* Turn barrel left / right */ +#define DIBUTTON_DRIVINGT_FIRE 0x03000C01 /* Fire */ +#define DIBUTTON_DRIVINGT_WEAPONS 0x03000C02 /* Select next weapon */ +#define DIBUTTON_DRIVINGT_TARGET 0x03000C03 /* Selects next available target */ +#define DIBUTTON_DRIVINGT_MENU 0x030004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_DRIVINGT_GLANCE 0x03004601 /* Look around */ +#define DIAXIS_DRIVINGT_BRAKE 0x03045205 /* Brake-axis */ +#define DIAXIS_DRIVINGT_ACCEL_AND_BRAKE 0x03014A06 /* Some devices combine accelerate and brake in a single axis */ +#define DIBUTTON_DRIVINGT_VIEW 0x03005C04 /* Cycle through view options */ +#define DIBUTTON_DRIVINGT_DASHBOARD 0x03005C05 /* Select next dashboard option */ +#define DIBUTTON_DRIVINGT_BRAKE 0x03004C06 /* Brake-button */ +#define DIBUTTON_DRIVINGT_FIRESECONDARY 0x03004C07 /* Alternative fire button */ +#define DIBUTTON_DRIVINGT_ACCELERATE_LINK 0x0303D4E0 /* Fallback Accelerate button */ +#define DIBUTTON_DRIVINGT_STEER_LEFT_LINK 0x0300CCE4 /* Fallback Steer Left button */ +#define DIBUTTON_DRIVINGT_STEER_RIGHT_LINK 0x0300CCEC /* Fallback Steer Right button */ +#define DIBUTTON_DRIVINGT_BARREL_UP_LINK 0x030144E0 /* Fallback Barrel up button */ +#define DIBUTTON_DRIVINGT_BARREL_DOWN_LINK 0x030144E8 /* Fallback Barrel down button */ +#define DIBUTTON_DRIVINGT_ROTATE_LEFT_LINK 0x030244E4 /* Fallback Rotate left button */ +#define DIBUTTON_DRIVINGT_ROTATE_RIGHT_LINK 0x030244EC /* Fallback Rotate right button */ +#define DIBUTTON_DRIVINGT_GLANCE_LEFT_LINK 0x0307C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_DRIVINGT_GLANCE_RIGHT_LINK 0x0307C4EC /* Fallback Glance Right button */ +#define DIBUTTON_DRIVINGT_DEVICE 0x030044FE /* Show input device and controls */ +#define DIBUTTON_DRIVINGT_PAUSE 0x030044FC /* Start / Pause / Restart game */ + +/*--- Flight Simulator - Civilian + Plane control is the primary objective ---*/ +#define DIVIRTUAL_FLYING_CIVILIAN 0x04000000 +#define DIAXIS_FLYINGC_BANK 0x04008A01 /* Roll ship left / right */ +#define DIAXIS_FLYINGC_PITCH 0x04010A02 /* Nose up / down */ +#define DIAXIS_FLYINGC_THROTTLE 0x04039203 /* Throttle */ +#define DIBUTTON_FLYINGC_VIEW 0x04002401 /* Cycle through view options */ +#define DIBUTTON_FLYINGC_DISPLAY 0x04002402 /* Select next dashboard / heads up display option */ +#define DIBUTTON_FLYINGC_GEAR 0x04002C03 /* Gear up / down */ +#define DIBUTTON_FLYINGC_MENU 0x040004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FLYINGC_GLANCE 0x04004601 /* Look around */ +#define DIAXIS_FLYINGC_BRAKE 0x04046A04 /* Apply Brake */ +#define DIAXIS_FLYINGC_RUDDER 0x04025205 /* Yaw ship left/right */ +#define DIAXIS_FLYINGC_FLAPS 0x04055A06 /* Flaps */ +#define DIBUTTON_FLYINGC_FLAPSUP 0x04006404 /* Increment stepping up until fully retracted */ +#define DIBUTTON_FLYINGC_FLAPSDOWN 0x04006405 /* Decrement stepping down until fully extended */ +#define DIBUTTON_FLYINGC_BRAKE_LINK 0x04046CE0 /* Fallback brake button */ +#define DIBUTTON_FLYINGC_FASTER_LINK 0x0403D4E0 /* Fallback throttle up button */ +#define DIBUTTON_FLYINGC_SLOWER_LINK 0x0403D4E8 /* Fallback throttle down button */ +#define DIBUTTON_FLYINGC_GLANCE_LEFT_LINK 0x0407C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_FLYINGC_GLANCE_RIGHT_LINK 0x0407C4EC /* Fallback Glance Right button */ +#define DIBUTTON_FLYINGC_GLANCE_UP_LINK 0x0407C4E0 /* Fallback Glance Up button */ +#define DIBUTTON_FLYINGC_GLANCE_DOWN_LINK 0x0407C4E8 /* Fallback Glance Down button */ +#define DIBUTTON_FLYINGC_DEVICE 0x040044FE /* Show input device and controls */ +#define DIBUTTON_FLYINGC_PAUSE 0x040044FC /* Start / Pause / Restart game */ + +/*--- Flight Simulator - Military + Aerial combat is the primary objective ---*/ +#define DIVIRTUAL_FLYING_MILITARY 0x05000000 +#define DIAXIS_FLYINGM_BANK 0x05008A01 /* Bank - Roll ship left / right */ +#define DIAXIS_FLYINGM_PITCH 0x05010A02 /* Pitch - Nose up / down */ +#define DIAXIS_FLYINGM_THROTTLE 0x05039203 /* Throttle - faster / slower */ +#define DIBUTTON_FLYINGM_FIRE 0x05000C01 /* Fire */ +#define DIBUTTON_FLYINGM_WEAPONS 0x05000C02 /* Select next weapon */ +#define DIBUTTON_FLYINGM_TARGET 0x05000C03 /* Selects next available target */ +#define DIBUTTON_FLYINGM_MENU 0x050004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FLYINGM_GLANCE 0x05004601 /* Look around */ +#define DIBUTTON_FLYINGM_COUNTER 0x05005C04 /* Activate counter measures */ +#define DIAXIS_FLYINGM_RUDDER 0x05024A04 /* Rudder - Yaw ship left/right */ +#define DIAXIS_FLYINGM_BRAKE 0x05046205 /* Brake-axis */ +#define DIBUTTON_FLYINGM_VIEW 0x05006405 /* Cycle through view options */ +#define DIBUTTON_FLYINGM_DISPLAY 0x05006406 /* Select next dashboard option */ +#define DIAXIS_FLYINGM_FLAPS 0x05055206 /* Flaps */ +#define DIBUTTON_FLYINGM_FLAPSUP 0x05005407 /* Increment stepping up until fully retracted */ +#define DIBUTTON_FLYINGM_FLAPSDOWN 0x05005408 /* Decrement stepping down until fully extended */ +#define DIBUTTON_FLYINGM_FIRESECONDARY 0x05004C09 /* Alternative fire button */ +#define DIBUTTON_FLYINGM_GEAR 0x0500640A /* Gear up / down */ +#define DIBUTTON_FLYINGM_BRAKE_LINK 0x050464E0 /* Fallback brake button */ +#define DIBUTTON_FLYINGM_FASTER_LINK 0x0503D4E0 /* Fallback throttle up button */ +#define DIBUTTON_FLYINGM_SLOWER_LINK 0x0503D4E8 /* Fallback throttle down button */ +#define DIBUTTON_FLYINGM_GLANCE_LEFT_LINK 0x0507C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_FLYINGM_GLANCE_RIGHT_LINK 0x0507C4EC /* Fallback Glance Right button */ +#define DIBUTTON_FLYINGM_GLANCE_UP_LINK 0x0507C4E0 /* Fallback Glance Up button */ +#define DIBUTTON_FLYINGM_GLANCE_DOWN_LINK 0x0507C4E8 /* Fallback Glance Down button */ +#define DIBUTTON_FLYINGM_DEVICE 0x050044FE /* Show input device and controls */ +#define DIBUTTON_FLYINGM_PAUSE 0x050044FC /* Start / Pause / Restart game */ + +/*--- Flight Simulator - Combat Helicopter + Combat from helicopter is primary objective ---*/ +#define DIVIRTUAL_FLYING_HELICOPTER 0x06000000 +#define DIAXIS_FLYINGH_BANK 0x06008A01 /* Bank - Roll ship left / right */ +#define DIAXIS_FLYINGH_PITCH 0x06010A02 /* Pitch - Nose up / down */ +#define DIAXIS_FLYINGH_COLLECTIVE 0x06018A03 /* Collective - Blade pitch/power */ +#define DIBUTTON_FLYINGH_FIRE 0x06001401 /* Fire */ +#define DIBUTTON_FLYINGH_WEAPONS 0x06001402 /* Select next weapon */ +#define DIBUTTON_FLYINGH_TARGET 0x06001403 /* Selects next available target */ +#define DIBUTTON_FLYINGH_MENU 0x060004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FLYINGH_GLANCE 0x06004601 /* Look around */ +#define DIAXIS_FLYINGH_TORQUE 0x06025A04 /* Torque - Rotate ship around left / right axis */ +#define DIAXIS_FLYINGH_THROTTLE 0x0603DA05 /* Throttle */ +#define DIBUTTON_FLYINGH_COUNTER 0x06005404 /* Activate counter measures */ +#define DIBUTTON_FLYINGH_VIEW 0x06006405 /* Cycle through view options */ +#define DIBUTTON_FLYINGH_GEAR 0x06006406 /* Gear up / down */ +#define DIBUTTON_FLYINGH_FIRESECONDARY 0x06004C07 /* Alternative fire button */ +#define DIBUTTON_FLYINGH_FASTER_LINK 0x0603DCE0 /* Fallback throttle up button */ +#define DIBUTTON_FLYINGH_SLOWER_LINK 0x0603DCE8 /* Fallback throttle down button */ +#define DIBUTTON_FLYINGH_GLANCE_LEFT_LINK 0x0607C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_FLYINGH_GLANCE_RIGHT_LINK 0x0607C4EC /* Fallback Glance Right button */ +#define DIBUTTON_FLYINGH_GLANCE_UP_LINK 0x0607C4E0 /* Fallback Glance Up button */ +#define DIBUTTON_FLYINGH_GLANCE_DOWN_LINK 0x0607C4E8 /* Fallback Glance Down button */ +#define DIBUTTON_FLYINGH_DEVICE 0x060044FE /* Show input device and controls */ +#define DIBUTTON_FLYINGH_PAUSE 0x060044FC /* Start / Pause / Restart game */ + +/*--- Space Simulator - Combat + Space Simulator with weapons ---*/ +#define DIVIRTUAL_SPACESIM 0x07000000 +#define DIAXIS_SPACESIM_LATERAL 0x07008201 /* Move ship left / right */ +#define DIAXIS_SPACESIM_MOVE 0x07010202 /* Move ship forward/backward */ +#define DIAXIS_SPACESIM_THROTTLE 0x07038203 /* Throttle - Engine speed */ +#define DIBUTTON_SPACESIM_FIRE 0x07000401 /* Fire */ +#define DIBUTTON_SPACESIM_WEAPONS 0x07000402 /* Select next weapon */ +#define DIBUTTON_SPACESIM_TARGET 0x07000403 /* Selects next available target */ +#define DIBUTTON_SPACESIM_MENU 0x070004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_SPACESIM_GLANCE 0x07004601 /* Look around */ +#define DIAXIS_SPACESIM_CLIMB 0x0701C204 /* Climb - Pitch ship up/down */ +#define DIAXIS_SPACESIM_ROTATE 0x07024205 /* Rotate - Turn ship left/right */ +#define DIBUTTON_SPACESIM_VIEW 0x07004404 /* Cycle through view options */ +#define DIBUTTON_SPACESIM_DISPLAY 0x07004405 /* Select next dashboard / heads up display option */ +#define DIBUTTON_SPACESIM_RAISE 0x07004406 /* Raise ship while maintaining current pitch */ +#define DIBUTTON_SPACESIM_LOWER 0x07004407 /* Lower ship while maintaining current pitch */ +#define DIBUTTON_SPACESIM_GEAR 0x07004408 /* Gear up / down */ +#define DIBUTTON_SPACESIM_FIRESECONDARY 0x07004409 /* Alternative fire button */ +#define DIBUTTON_SPACESIM_LEFT_LINK 0x0700C4E4 /* Fallback move left button */ +#define DIBUTTON_SPACESIM_RIGHT_LINK 0x0700C4EC /* Fallback move right button */ +#define DIBUTTON_SPACESIM_FORWARD_LINK 0x070144E0 /* Fallback move forward button */ +#define DIBUTTON_SPACESIM_BACKWARD_LINK 0x070144E8 /* Fallback move backwards button */ +#define DIBUTTON_SPACESIM_FASTER_LINK 0x0703C4E0 /* Fallback throttle up button */ +#define DIBUTTON_SPACESIM_SLOWER_LINK 0x0703C4E8 /* Fallback throttle down button */ +#define DIBUTTON_SPACESIM_TURN_LEFT_LINK 0x070244E4 /* Fallback turn left button */ +#define DIBUTTON_SPACESIM_TURN_RIGHT_LINK 0x070244EC /* Fallback turn right button */ +#define DIBUTTON_SPACESIM_GLANCE_LEFT_LINK 0x0707C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_SPACESIM_GLANCE_RIGHT_LINK 0x0707C4EC /* Fallback Glance Right button */ +#define DIBUTTON_SPACESIM_GLANCE_UP_LINK 0x0707C4E0 /* Fallback Glance Up button */ +#define DIBUTTON_SPACESIM_GLANCE_DOWN_LINK 0x0707C4E8 /* Fallback Glance Down button */ +#define DIBUTTON_SPACESIM_DEVICE 0x070044FE /* Show input device and controls */ +#define DIBUTTON_SPACESIM_PAUSE 0x070044FC /* Start / Pause / Restart game */ + +/*--- Fighting - First Person + Hand to Hand combat is primary objective ---*/ +#define DIVIRTUAL_FIGHTING_HAND2HAND 0x08000000 +#define DIAXIS_FIGHTINGH_LATERAL 0x08008201 /* Sidestep left/right */ +#define DIAXIS_FIGHTINGH_MOVE 0x08010202 /* Move forward/backward */ +#define DIBUTTON_FIGHTINGH_PUNCH 0x08000401 /* Punch */ +#define DIBUTTON_FIGHTINGH_KICK 0x08000402 /* Kick */ +#define DIBUTTON_FIGHTINGH_BLOCK 0x08000403 /* Block */ +#define DIBUTTON_FIGHTINGH_CROUCH 0x08000404 /* Crouch */ +#define DIBUTTON_FIGHTINGH_JUMP 0x08000405 /* Jump */ +#define DIBUTTON_FIGHTINGH_SPECIAL1 0x08000406 /* Apply first special move */ +#define DIBUTTON_FIGHTINGH_SPECIAL2 0x08000407 /* Apply second special move */ +#define DIBUTTON_FIGHTINGH_MENU 0x080004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FIGHTINGH_SELECT 0x08004408 /* Select special move */ +#define DIHATSWITCH_FIGHTINGH_SLIDE 0x08004601 /* Look around */ +#define DIBUTTON_FIGHTINGH_DISPLAY 0x08004409 /* Shows next on-screen display option */ +#define DIAXIS_FIGHTINGH_ROTATE 0x08024203 /* Rotate - Turn body left/right */ +#define DIBUTTON_FIGHTINGH_DODGE 0x0800440A /* Dodge */ +#define DIBUTTON_FIGHTINGH_LEFT_LINK 0x0800C4E4 /* Fallback left sidestep button */ +#define DIBUTTON_FIGHTINGH_RIGHT_LINK 0x0800C4EC /* Fallback right sidestep button */ +#define DIBUTTON_FIGHTINGH_FORWARD_LINK 0x080144E0 /* Fallback forward button */ +#define DIBUTTON_FIGHTINGH_BACKWARD_LINK 0x080144E8 /* Fallback backward button */ +#define DIBUTTON_FIGHTINGH_DEVICE 0x080044FE /* Show input device and controls */ +#define DIBUTTON_FIGHTINGH_PAUSE 0x080044FC /* Start / Pause / Restart game */ + +/*--- Fighting - First Person Shooting + Navigation and combat are primary objectives ---*/ +#define DIVIRTUAL_FIGHTING_FPS 0x09000000 +#define DIAXIS_FPS_ROTATE 0x09008201 /* Rotate character left/right */ +#define DIAXIS_FPS_MOVE 0x09010202 /* Move forward/backward */ +#define DIBUTTON_FPS_FIRE 0x09000401 /* Fire */ +#define DIBUTTON_FPS_WEAPONS 0x09000402 /* Select next weapon */ +#define DIBUTTON_FPS_APPLY 0x09000403 /* Use item */ +#define DIBUTTON_FPS_SELECT 0x09000404 /* Select next inventory item */ +#define DIBUTTON_FPS_CROUCH 0x09000405 /* Crouch/ climb down/ swim down */ +#define DIBUTTON_FPS_JUMP 0x09000406 /* Jump/ climb up/ swim up */ +#define DIAXIS_FPS_LOOKUPDOWN 0x09018203 /* Look up / down */ +#define DIBUTTON_FPS_STRAFE 0x09000407 /* Enable strafing while active */ +#define DIBUTTON_FPS_MENU 0x090004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FPS_GLANCE 0x09004601 /* Look around */ +#define DIBUTTON_FPS_DISPLAY 0x09004408 /* Shows next on-screen display option/ map */ +#define DIAXIS_FPS_SIDESTEP 0x09024204 /* Sidestep */ +#define DIBUTTON_FPS_DODGE 0x09004409 /* Dodge */ +#define DIBUTTON_FPS_GLANCEL 0x0900440A /* Glance Left */ +#define DIBUTTON_FPS_GLANCER 0x0900440B /* Glance Right */ +#define DIBUTTON_FPS_FIRESECONDARY 0x0900440C /* Alternative fire button */ +#define DIBUTTON_FPS_ROTATE_LEFT_LINK 0x0900C4E4 /* Fallback rotate left button */ +#define DIBUTTON_FPS_ROTATE_RIGHT_LINK 0x0900C4EC /* Fallback rotate right button */ +#define DIBUTTON_FPS_FORWARD_LINK 0x090144E0 /* Fallback forward button */ +#define DIBUTTON_FPS_BACKWARD_LINK 0x090144E8 /* Fallback backward button */ +#define DIBUTTON_FPS_GLANCE_UP_LINK 0x0901C4E0 /* Fallback look up button */ +#define DIBUTTON_FPS_GLANCE_DOWN_LINK 0x0901C4E8 /* Fallback look down button */ +#define DIBUTTON_FPS_STEP_LEFT_LINK 0x090244E4 /* Fallback step left button */ +#define DIBUTTON_FPS_STEP_RIGHT_LINK 0x090244EC /* Fallback step right button */ +#define DIBUTTON_FPS_DEVICE 0x090044FE /* Show input device and controls */ +#define DIBUTTON_FPS_PAUSE 0x090044FC /* Start / Pause / Restart game */ + +/*--- Fighting - Third Person action + Perspective of camera is behind the main character ---*/ +#define DIVIRTUAL_FIGHTING_THIRDPERSON 0x0A000000 +#define DIAXIS_TPS_TURN 0x0A020201 /* Turn left/right */ +#define DIAXIS_TPS_MOVE 0x0A010202 /* Move forward/backward */ +#define DIBUTTON_TPS_RUN 0x0A000401 /* Run or walk toggle switch */ +#define DIBUTTON_TPS_ACTION 0x0A000402 /* Action Button */ +#define DIBUTTON_TPS_SELECT 0x0A000403 /* Select next weapon */ +#define DIBUTTON_TPS_USE 0x0A000404 /* Use inventory item currently selected */ +#define DIBUTTON_TPS_JUMP 0x0A000405 /* Character Jumps */ +#define DIBUTTON_TPS_MENU 0x0A0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_TPS_GLANCE 0x0A004601 /* Look around */ +#define DIBUTTON_TPS_VIEW 0x0A004406 /* Select camera view */ +#define DIBUTTON_TPS_STEPLEFT 0x0A004407 /* Character takes a left step */ +#define DIBUTTON_TPS_STEPRIGHT 0x0A004408 /* Character takes a right step */ +#define DIAXIS_TPS_STEP 0x0A00C203 /* Character steps left/right */ +#define DIBUTTON_TPS_DODGE 0x0A004409 /* Character dodges or ducks */ +#define DIBUTTON_TPS_INVENTORY 0x0A00440A /* Cycle through inventory */ +#define DIBUTTON_TPS_TURN_LEFT_LINK 0x0A0244E4 /* Fallback turn left button */ +#define DIBUTTON_TPS_TURN_RIGHT_LINK 0x0A0244EC /* Fallback turn right button */ +#define DIBUTTON_TPS_FORWARD_LINK 0x0A0144E0 /* Fallback forward button */ +#define DIBUTTON_TPS_BACKWARD_LINK 0x0A0144E8 /* Fallback backward button */ +#define DIBUTTON_TPS_GLANCE_UP_LINK 0x0A07C4E0 /* Fallback look up button */ +#define DIBUTTON_TPS_GLANCE_DOWN_LINK 0x0A07C4E8 /* Fallback look down button */ +#define DIBUTTON_TPS_GLANCE_LEFT_LINK 0x0A07C4E4 /* Fallback glance up button */ +#define DIBUTTON_TPS_GLANCE_RIGHT_LINK 0x0A07C4EC /* Fallback glance right button */ +#define DIBUTTON_TPS_DEVICE 0x0A0044FE /* Show input device and controls */ +#define DIBUTTON_TPS_PAUSE 0x0A0044FC /* Start / Pause / Restart game */ + +/*--- Strategy - Role Playing + Navigation and problem solving are primary actions ---*/ +#define DIVIRTUAL_STRATEGY_ROLEPLAYING 0x0B000000 +#define DIAXIS_STRATEGYR_LATERAL 0x0B008201 /* sidestep - left/right */ +#define DIAXIS_STRATEGYR_MOVE 0x0B010202 /* move forward/backward */ +#define DIBUTTON_STRATEGYR_GET 0x0B000401 /* Acquire item */ +#define DIBUTTON_STRATEGYR_APPLY 0x0B000402 /* Use selected item */ +#define DIBUTTON_STRATEGYR_SELECT 0x0B000403 /* Select nextitem */ +#define DIBUTTON_STRATEGYR_ATTACK 0x0B000404 /* Attack */ +#define DIBUTTON_STRATEGYR_CAST 0x0B000405 /* Cast Spell */ +#define DIBUTTON_STRATEGYR_CROUCH 0x0B000406 /* Crouch */ +#define DIBUTTON_STRATEGYR_JUMP 0x0B000407 /* Jump */ +#define DIBUTTON_STRATEGYR_MENU 0x0B0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_STRATEGYR_GLANCE 0x0B004601 /* Look around */ +#define DIBUTTON_STRATEGYR_MAP 0x0B004408 /* Cycle through map options */ +#define DIBUTTON_STRATEGYR_DISPLAY 0x0B004409 /* Shows next on-screen display option */ +#define DIAXIS_STRATEGYR_ROTATE 0x0B024203 /* Turn body left/right */ +#define DIBUTTON_STRATEGYR_LEFT_LINK 0x0B00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_STRATEGYR_RIGHT_LINK 0x0B00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_STRATEGYR_FORWARD_LINK 0x0B0144E0 /* Fallback move forward button */ +#define DIBUTTON_STRATEGYR_BACK_LINK 0x0B0144E8 /* Fallback move backward button */ +#define DIBUTTON_STRATEGYR_ROTATE_LEFT_LINK 0x0B0244E4 /* Fallback turn body left button */ +#define DIBUTTON_STRATEGYR_ROTATE_RIGHT_LINK 0x0B0244EC /* Fallback turn body right button */ +#define DIBUTTON_STRATEGYR_DEVICE 0x0B0044FE /* Show input device and controls */ +#define DIBUTTON_STRATEGYR_PAUSE 0x0B0044FC /* Start / Pause / Restart game */ + +/*--- Strategy - Turn based + Navigation and problem solving are primary actions ---*/ +#define DIVIRTUAL_STRATEGY_TURN 0x0C000000 +#define DIAXIS_STRATEGYT_LATERAL 0x0C008201 /* Sidestep left/right */ +#define DIAXIS_STRATEGYT_MOVE 0x0C010202 /* Move forward/backwards */ +#define DIBUTTON_STRATEGYT_SELECT 0x0C000401 /* Select unit or object */ +#define DIBUTTON_STRATEGYT_INSTRUCT 0x0C000402 /* Cycle through instructions */ +#define DIBUTTON_STRATEGYT_APPLY 0x0C000403 /* Apply selected instruction */ +#define DIBUTTON_STRATEGYT_TEAM 0x0C000404 /* Select next team / cycle through all */ +#define DIBUTTON_STRATEGYT_TURN 0x0C000405 /* Indicate turn over */ +#define DIBUTTON_STRATEGYT_MENU 0x0C0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_STRATEGYT_ZOOM 0x0C004406 /* Zoom - in / out */ +#define DIBUTTON_STRATEGYT_MAP 0x0C004407 /* cycle through map options */ +#define DIBUTTON_STRATEGYT_DISPLAY 0x0C004408 /* shows next on-screen display options */ +#define DIBUTTON_STRATEGYT_LEFT_LINK 0x0C00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_STRATEGYT_RIGHT_LINK 0x0C00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_STRATEGYT_FORWARD_LINK 0x0C0144E0 /* Fallback move forward button */ +#define DIBUTTON_STRATEGYT_BACK_LINK 0x0C0144E8 /* Fallback move back button */ +#define DIBUTTON_STRATEGYT_DEVICE 0x0C0044FE /* Show input device and controls */ +#define DIBUTTON_STRATEGYT_PAUSE 0x0C0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Hunting + Hunting ---*/ +#define DIVIRTUAL_SPORTS_HUNTING 0x0D000000 +#define DIAXIS_HUNTING_LATERAL 0x0D008201 /* sidestep left/right */ +#define DIAXIS_HUNTING_MOVE 0x0D010202 /* move forward/backwards */ +#define DIBUTTON_HUNTING_FIRE 0x0D000401 /* Fire selected weapon */ +#define DIBUTTON_HUNTING_AIM 0x0D000402 /* Select aim/move */ +#define DIBUTTON_HUNTING_WEAPON 0x0D000403 /* Select next weapon */ +#define DIBUTTON_HUNTING_BINOCULAR 0x0D000404 /* Look through Binoculars */ +#define DIBUTTON_HUNTING_CALL 0x0D000405 /* Make animal call */ +#define DIBUTTON_HUNTING_MAP 0x0D000406 /* View Map */ +#define DIBUTTON_HUNTING_SPECIAL 0x0D000407 /* Special game operation */ +#define DIBUTTON_HUNTING_MENU 0x0D0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_HUNTING_GLANCE 0x0D004601 /* Look around */ +#define DIBUTTON_HUNTING_DISPLAY 0x0D004408 /* show next on-screen display option */ +#define DIAXIS_HUNTING_ROTATE 0x0D024203 /* Turn body left/right */ +#define DIBUTTON_HUNTING_CROUCH 0x0D004409 /* Crouch/ Climb / Swim down */ +#define DIBUTTON_HUNTING_JUMP 0x0D00440A /* Jump/ Climb up / Swim up */ +#define DIBUTTON_HUNTING_FIRESECONDARY 0x0D00440B /* Alternative fire button */ +#define DIBUTTON_HUNTING_LEFT_LINK 0x0D00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_HUNTING_RIGHT_LINK 0x0D00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_HUNTING_FORWARD_LINK 0x0D0144E0 /* Fallback move forward button */ +#define DIBUTTON_HUNTING_BACK_LINK 0x0D0144E8 /* Fallback move back button */ +#define DIBUTTON_HUNTING_ROTATE_LEFT_LINK 0x0D0244E4 /* Fallback turn body left button */ +#define DIBUTTON_HUNTING_ROTATE_RIGHT_LINK 0x0D0244EC /* Fallback turn body right button */ +#define DIBUTTON_HUNTING_DEVICE 0x0D0044FE /* Show input device and controls */ +#define DIBUTTON_HUNTING_PAUSE 0x0D0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Fishing + Catching Fish is primary objective ---*/ +#define DIVIRTUAL_SPORTS_FISHING 0x0E000000 +#define DIAXIS_FISHING_LATERAL 0x0E008201 /* sidestep left/right */ +#define DIAXIS_FISHING_MOVE 0x0E010202 /* move forward/backwards */ +#define DIBUTTON_FISHING_CAST 0x0E000401 /* Cast line */ +#define DIBUTTON_FISHING_TYPE 0x0E000402 /* Select cast type */ +#define DIBUTTON_FISHING_BINOCULAR 0x0E000403 /* Look through Binocular */ +#define DIBUTTON_FISHING_BAIT 0x0E000404 /* Select type of Bait */ +#define DIBUTTON_FISHING_MAP 0x0E000405 /* View Map */ +#define DIBUTTON_FISHING_MENU 0x0E0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FISHING_GLANCE 0x0E004601 /* Look around */ +#define DIBUTTON_FISHING_DISPLAY 0x0E004406 /* Show next on-screen display option */ +#define DIAXIS_FISHING_ROTATE 0x0E024203 /* Turn character left / right */ +#define DIBUTTON_FISHING_CROUCH 0x0E004407 /* Crouch/ Climb / Swim down */ +#define DIBUTTON_FISHING_JUMP 0x0E004408 /* Jump/ Climb up / Swim up */ +#define DIBUTTON_FISHING_LEFT_LINK 0x0E00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_FISHING_RIGHT_LINK 0x0E00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_FISHING_FORWARD_LINK 0x0E0144E0 /* Fallback move forward button */ +#define DIBUTTON_FISHING_BACK_LINK 0x0E0144E8 /* Fallback move back button */ +#define DIBUTTON_FISHING_ROTATE_LEFT_LINK 0x0E0244E4 /* Fallback turn body left button */ +#define DIBUTTON_FISHING_ROTATE_RIGHT_LINK 0x0E0244EC /* Fallback turn body right button */ +#define DIBUTTON_FISHING_DEVICE 0x0E0044FE /* Show input device and controls */ +#define DIBUTTON_FISHING_PAUSE 0x0E0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Baseball - Batting + Batter control is primary objective ---*/ +#define DIVIRTUAL_SPORTS_BASEBALL_BAT 0x0F000000 +#define DIAXIS_BASEBALLB_LATERAL 0x0F008201 /* Aim left / right */ +#define DIAXIS_BASEBALLB_MOVE 0x0F010202 /* Aim up / down */ +#define DIBUTTON_BASEBALLB_SELECT 0x0F000401 /* cycle through swing options */ +#define DIBUTTON_BASEBALLB_NORMAL 0x0F000402 /* normal swing */ +#define DIBUTTON_BASEBALLB_POWER 0x0F000403 /* swing for the fence */ +#define DIBUTTON_BASEBALLB_BUNT 0x0F000404 /* bunt */ +#define DIBUTTON_BASEBALLB_STEAL 0x0F000405 /* Base runner attempts to steal a base */ +#define DIBUTTON_BASEBALLB_BURST 0x0F000406 /* Base runner invokes burst of speed */ +#define DIBUTTON_BASEBALLB_SLIDE 0x0F000407 /* Base runner slides into base */ +#define DIBUTTON_BASEBALLB_CONTACT 0x0F000408 /* Contact swing */ +#define DIBUTTON_BASEBALLB_MENU 0x0F0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_BASEBALLB_NOSTEAL 0x0F004409 /* Base runner goes back to a base */ +#define DIBUTTON_BASEBALLB_BOX 0x0F00440A /* Enter or exit batting box */ +#define DIBUTTON_BASEBALLB_LEFT_LINK 0x0F00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_BASEBALLB_RIGHT_LINK 0x0F00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_BASEBALLB_FORWARD_LINK 0x0F0144E0 /* Fallback move forward button */ +#define DIBUTTON_BASEBALLB_BACK_LINK 0x0F0144E8 /* Fallback move back button */ +#define DIBUTTON_BASEBALLB_DEVICE 0x0F0044FE /* Show input device and controls */ +#define DIBUTTON_BASEBALLB_PAUSE 0x0F0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Baseball - Pitching + Pitcher control is primary objective ---*/ +#define DIVIRTUAL_SPORTS_BASEBALL_PITCH 0x10000000 +#define DIAXIS_BASEBALLP_LATERAL 0x10008201 /* Aim left / right */ +#define DIAXIS_BASEBALLP_MOVE 0x10010202 /* Aim up / down */ +#define DIBUTTON_BASEBALLP_SELECT 0x10000401 /* cycle through pitch selections */ +#define DIBUTTON_BASEBALLP_PITCH 0x10000402 /* throw pitch */ +#define DIBUTTON_BASEBALLP_BASE 0x10000403 /* select base to throw to */ +#define DIBUTTON_BASEBALLP_THROW 0x10000404 /* throw to base */ +#define DIBUTTON_BASEBALLP_FAKE 0x10000405 /* Fake a throw to a base */ +#define DIBUTTON_BASEBALLP_MENU 0x100004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_BASEBALLP_WALK 0x10004406 /* Throw intentional walk / pitch out */ +#define DIBUTTON_BASEBALLP_LOOK 0x10004407 /* Look at runners on bases */ +#define DIBUTTON_BASEBALLP_LEFT_LINK 0x1000C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_BASEBALLP_RIGHT_LINK 0x1000C4EC /* Fallback sidestep right button */ +#define DIBUTTON_BASEBALLP_FORWARD_LINK 0x100144E0 /* Fallback move forward button */ +#define DIBUTTON_BASEBALLP_BACK_LINK 0x100144E8 /* Fallback move back button */ +#define DIBUTTON_BASEBALLP_DEVICE 0x100044FE /* Show input device and controls */ +#define DIBUTTON_BASEBALLP_PAUSE 0x100044FC /* Start / Pause / Restart game */ + +/*--- Sports - Baseball - Fielding + Fielder control is primary objective ---*/ +#define DIVIRTUAL_SPORTS_BASEBALL_FIELD 0x11000000 +#define DIAXIS_BASEBALLF_LATERAL 0x11008201 /* Aim left / right */ +#define DIAXIS_BASEBALLF_MOVE 0x11010202 /* Aim up / down */ +#define DIBUTTON_BASEBALLF_NEAREST 0x11000401 /* Switch to fielder nearest to the ball */ +#define DIBUTTON_BASEBALLF_THROW1 0x11000402 /* Make conservative throw */ +#define DIBUTTON_BASEBALLF_THROW2 0x11000403 /* Make aggressive throw */ +#define DIBUTTON_BASEBALLF_BURST 0x11000404 /* Invoke burst of speed */ +#define DIBUTTON_BASEBALLF_JUMP 0x11000405 /* Jump to catch ball */ +#define DIBUTTON_BASEBALLF_DIVE 0x11000406 /* Dive to catch ball */ +#define DIBUTTON_BASEBALLF_MENU 0x110004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_BASEBALLF_SHIFTIN 0x11004407 /* Shift the infield positioning */ +#define DIBUTTON_BASEBALLF_SHIFTOUT 0x11004408 /* Shift the outfield positioning */ +#define DIBUTTON_BASEBALLF_AIM_LEFT_LINK 0x1100C4E4 /* Fallback aim left button */ +#define DIBUTTON_BASEBALLF_AIM_RIGHT_LINK 0x1100C4EC /* Fallback aim right button */ +#define DIBUTTON_BASEBALLF_FORWARD_LINK 0x110144E0 /* Fallback move forward button */ +#define DIBUTTON_BASEBALLF_BACK_LINK 0x110144E8 /* Fallback move back button */ +#define DIBUTTON_BASEBALLF_DEVICE 0x110044FE /* Show input device and controls */ +#define DIBUTTON_BASEBALLF_PAUSE 0x110044FC /* Start / Pause / Restart game */ + +/*--- Sports - Basketball - Offense + Offense ---*/ +#define DIVIRTUAL_SPORTS_BASKETBALL_OFFENSE 0x12000000 +#define DIAXIS_BBALLO_LATERAL 0x12008201 /* left / right */ +#define DIAXIS_BBALLO_MOVE 0x12010202 /* up / down */ +#define DIBUTTON_BBALLO_SHOOT 0x12000401 /* shoot basket */ +#define DIBUTTON_BBALLO_DUNK 0x12000402 /* dunk basket */ +#define DIBUTTON_BBALLO_PASS 0x12000403 /* throw pass */ +#define DIBUTTON_BBALLO_FAKE 0x12000404 /* fake shot or pass */ +#define DIBUTTON_BBALLO_SPECIAL 0x12000405 /* apply special move */ +#define DIBUTTON_BBALLO_PLAYER 0x12000406 /* select next player */ +#define DIBUTTON_BBALLO_BURST 0x12000407 /* invoke burst */ +#define DIBUTTON_BBALLO_CALL 0x12000408 /* call for ball / pass to me */ +#define DIBUTTON_BBALLO_MENU 0x120004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_BBALLO_GLANCE 0x12004601 /* scroll view */ +#define DIBUTTON_BBALLO_SCREEN 0x12004409 /* Call for screen */ +#define DIBUTTON_BBALLO_PLAY 0x1200440A /* Call for specific offensive play */ +#define DIBUTTON_BBALLO_JAB 0x1200440B /* Initiate fake drive to basket */ +#define DIBUTTON_BBALLO_POST 0x1200440C /* Perform post move */ +#define DIBUTTON_BBALLO_TIMEOUT 0x1200440D /* Time Out */ +#define DIBUTTON_BBALLO_SUBSTITUTE 0x1200440E /* substitute one player for another */ +#define DIBUTTON_BBALLO_LEFT_LINK 0x1200C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_BBALLO_RIGHT_LINK 0x1200C4EC /* Fallback sidestep right button */ +#define DIBUTTON_BBALLO_FORWARD_LINK 0x120144E0 /* Fallback move forward button */ +#define DIBUTTON_BBALLO_BACK_LINK 0x120144E8 /* Fallback move back button */ +#define DIBUTTON_BBALLO_DEVICE 0x120044FE /* Show input device and controls */ +#define DIBUTTON_BBALLO_PAUSE 0x120044FC /* Start / Pause / Restart game */ + +/*--- Sports - Basketball - Defense + Defense ---*/ +#define DIVIRTUAL_SPORTS_BASKETBALL_DEFENSE 0x13000000 +#define DIAXIS_BBALLD_LATERAL 0x13008201 /* left / right */ +#define DIAXIS_BBALLD_MOVE 0x13010202 /* up / down */ +#define DIBUTTON_BBALLD_JUMP 0x13000401 /* jump to block shot */ +#define DIBUTTON_BBALLD_STEAL 0x13000402 /* attempt to steal ball */ +#define DIBUTTON_BBALLD_FAKE 0x13000403 /* fake block or steal */ +#define DIBUTTON_BBALLD_SPECIAL 0x13000404 /* apply special move */ +#define DIBUTTON_BBALLD_PLAYER 0x13000405 /* select next player */ +#define DIBUTTON_BBALLD_BURST 0x13000406 /* invoke burst */ +#define DIBUTTON_BBALLD_PLAY 0x13000407 /* call for specific defensive play */ +#define DIBUTTON_BBALLD_MENU 0x130004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_BBALLD_GLANCE 0x13004601 /* scroll view */ +#define DIBUTTON_BBALLD_TIMEOUT 0x13004408 /* Time Out */ +#define DIBUTTON_BBALLD_SUBSTITUTE 0x13004409 /* substitute one player for another */ +#define DIBUTTON_BBALLD_LEFT_LINK 0x1300C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_BBALLD_RIGHT_LINK 0x1300C4EC /* Fallback sidestep right button */ +#define DIBUTTON_BBALLD_FORWARD_LINK 0x130144E0 /* Fallback move forward button */ +#define DIBUTTON_BBALLD_BACK_LINK 0x130144E8 /* Fallback move back button */ +#define DIBUTTON_BBALLD_DEVICE 0x130044FE /* Show input device and controls */ +#define DIBUTTON_BBALLD_PAUSE 0x130044FC /* Start / Pause / Restart game */ + +/*--- Sports - Football - Play + Play selection ---*/ +#define DIVIRTUAL_SPORTS_FOOTBALL_FIELD 0x14000000 +#define DIBUTTON_FOOTBALLP_PLAY 0x14000401 /* cycle through available plays */ +#define DIBUTTON_FOOTBALLP_SELECT 0x14000402 /* select play */ +#define DIBUTTON_FOOTBALLP_HELP 0x14000403 /* Bring up pop-up help */ +#define DIBUTTON_FOOTBALLP_MENU 0x140004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FOOTBALLP_DEVICE 0x140044FE /* Show input device and controls */ +#define DIBUTTON_FOOTBALLP_PAUSE 0x140044FC /* Start / Pause / Restart game */ + +/*--- Sports - Football - QB + Offense: Quarterback / Kicker ---*/ +#define DIVIRTUAL_SPORTS_FOOTBALL_QBCK 0x15000000 +#define DIAXIS_FOOTBALLQ_LATERAL 0x15008201 /* Move / Aim: left / right */ +#define DIAXIS_FOOTBALLQ_MOVE 0x15010202 /* Move / Aim: up / down */ +#define DIBUTTON_FOOTBALLQ_SELECT 0x15000401 /* Select */ +#define DIBUTTON_FOOTBALLQ_SNAP 0x15000402 /* snap ball - start play */ +#define DIBUTTON_FOOTBALLQ_JUMP 0x15000403 /* jump over defender */ +#define DIBUTTON_FOOTBALLQ_SLIDE 0x15000404 /* Dive/Slide */ +#define DIBUTTON_FOOTBALLQ_PASS 0x15000405 /* throws pass to receiver */ +#define DIBUTTON_FOOTBALLQ_FAKE 0x15000406 /* pump fake pass or fake kick */ +#define DIBUTTON_FOOTBALLQ_MENU 0x150004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FOOTBALLQ_FAKESNAP 0x15004407 /* Fake snap */ +#define DIBUTTON_FOOTBALLQ_MOTION 0x15004408 /* Send receivers in motion */ +#define DIBUTTON_FOOTBALLQ_AUDIBLE 0x15004409 /* Change offensive play at line of scrimmage */ +#define DIBUTTON_FOOTBALLQ_LEFT_LINK 0x1500C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_FOOTBALLQ_RIGHT_LINK 0x1500C4EC /* Fallback sidestep right button */ +#define DIBUTTON_FOOTBALLQ_FORWARD_LINK 0x150144E0 /* Fallback move forward button */ +#define DIBUTTON_FOOTBALLQ_BACK_LINK 0x150144E8 /* Fallback move back button */ +#define DIBUTTON_FOOTBALLQ_DEVICE 0x150044FE /* Show input device and controls */ +#define DIBUTTON_FOOTBALLQ_PAUSE 0x150044FC /* Start / Pause / Restart game */ + +/*--- Sports - Football - Offense + Offense - Runner ---*/ +#define DIVIRTUAL_SPORTS_FOOTBALL_OFFENSE 0x16000000 +#define DIAXIS_FOOTBALLO_LATERAL 0x16008201 /* Move / Aim: left / right */ +#define DIAXIS_FOOTBALLO_MOVE 0x16010202 /* Move / Aim: up / down */ +#define DIBUTTON_FOOTBALLO_JUMP 0x16000401 /* jump or hurdle over defender */ +#define DIBUTTON_FOOTBALLO_LEFTARM 0x16000402 /* holds out left arm */ +#define DIBUTTON_FOOTBALLO_RIGHTARM 0x16000403 /* holds out right arm */ +#define DIBUTTON_FOOTBALLO_THROW 0x16000404 /* throw pass or lateral ball to another runner */ +#define DIBUTTON_FOOTBALLO_SPIN 0x16000405 /* Spin to avoid defenders */ +#define DIBUTTON_FOOTBALLO_MENU 0x160004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FOOTBALLO_JUKE 0x16004406 /* Use special move to avoid defenders */ +#define DIBUTTON_FOOTBALLO_SHOULDER 0x16004407 /* Lower shoulder to run over defenders */ +#define DIBUTTON_FOOTBALLO_TURBO 0x16004408 /* Speed burst past defenders */ +#define DIBUTTON_FOOTBALLO_DIVE 0x16004409 /* Dive over defenders */ +#define DIBUTTON_FOOTBALLO_ZOOM 0x1600440A /* Zoom view in / out */ +#define DIBUTTON_FOOTBALLO_SUBSTITUTE 0x1600440B /* substitute one player for another */ +#define DIBUTTON_FOOTBALLO_LEFT_LINK 0x1600C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_FOOTBALLO_RIGHT_LINK 0x1600C4EC /* Fallback sidestep right button */ +#define DIBUTTON_FOOTBALLO_FORWARD_LINK 0x160144E0 /* Fallback move forward button */ +#define DIBUTTON_FOOTBALLO_BACK_LINK 0x160144E8 /* Fallback move back button */ +#define DIBUTTON_FOOTBALLO_DEVICE 0x160044FE /* Show input device and controls */ +#define DIBUTTON_FOOTBALLO_PAUSE 0x160044FC /* Start / Pause / Restart game */ + +/*--- Sports - Football - Defense + Defense ---*/ +#define DIVIRTUAL_SPORTS_FOOTBALL_DEFENSE 0x17000000 +#define DIAXIS_FOOTBALLD_LATERAL 0x17008201 /* Move / Aim: left / right */ +#define DIAXIS_FOOTBALLD_MOVE 0x17010202 /* Move / Aim: up / down */ +#define DIBUTTON_FOOTBALLD_PLAY 0x17000401 /* cycle through available plays */ +#define DIBUTTON_FOOTBALLD_SELECT 0x17000402 /* select player closest to the ball */ +#define DIBUTTON_FOOTBALLD_JUMP 0x17000403 /* jump to intercept or block */ +#define DIBUTTON_FOOTBALLD_TACKLE 0x17000404 /* tackler runner */ +#define DIBUTTON_FOOTBALLD_FAKE 0x17000405 /* hold down to fake tackle or intercept */ +#define DIBUTTON_FOOTBALLD_SUPERTACKLE 0x17000406 /* Initiate special tackle */ +#define DIBUTTON_FOOTBALLD_MENU 0x170004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FOOTBALLD_SPIN 0x17004407 /* Spin to beat offensive line */ +#define DIBUTTON_FOOTBALLD_SWIM 0x17004408 /* Swim to beat the offensive line */ +#define DIBUTTON_FOOTBALLD_BULLRUSH 0x17004409 /* Bull rush the offensive line */ +#define DIBUTTON_FOOTBALLD_RIP 0x1700440A /* Rip the offensive line */ +#define DIBUTTON_FOOTBALLD_AUDIBLE 0x1700440B /* Change defensive play at the line of scrimmage */ +#define DIBUTTON_FOOTBALLD_ZOOM 0x1700440C /* Zoom view in / out */ +#define DIBUTTON_FOOTBALLD_SUBSTITUTE 0x1700440D /* substitute one player for another */ +#define DIBUTTON_FOOTBALLD_LEFT_LINK 0x1700C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_FOOTBALLD_RIGHT_LINK 0x1700C4EC /* Fallback sidestep right button */ +#define DIBUTTON_FOOTBALLD_FORWARD_LINK 0x170144E0 /* Fallback move forward button */ +#define DIBUTTON_FOOTBALLD_BACK_LINK 0x170144E8 /* Fallback move back button */ +#define DIBUTTON_FOOTBALLD_DEVICE 0x170044FE /* Show input device and controls */ +#define DIBUTTON_FOOTBALLD_PAUSE 0x170044FC /* Start / Pause / Restart game */ + +/*--- Sports - Golf + ---*/ +#define DIVIRTUAL_SPORTS_GOLF 0x18000000 +#define DIAXIS_GOLF_LATERAL 0x18008201 /* Move / Aim: left / right */ +#define DIAXIS_GOLF_MOVE 0x18010202 /* Move / Aim: up / down */ +#define DIBUTTON_GOLF_SWING 0x18000401 /* swing club */ +#define DIBUTTON_GOLF_SELECT 0x18000402 /* cycle between: club / swing strength / ball arc / ball spin */ +#define DIBUTTON_GOLF_UP 0x18000403 /* increase selection */ +#define DIBUTTON_GOLF_DOWN 0x18000404 /* decrease selection */ +#define DIBUTTON_GOLF_TERRAIN 0x18000405 /* shows terrain detail */ +#define DIBUTTON_GOLF_FLYBY 0x18000406 /* view the hole via a flyby */ +#define DIBUTTON_GOLF_MENU 0x180004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_GOLF_SCROLL 0x18004601 /* scroll view */ +#define DIBUTTON_GOLF_ZOOM 0x18004407 /* Zoom view in / out */ +#define DIBUTTON_GOLF_TIMEOUT 0x18004408 /* Call for time out */ +#define DIBUTTON_GOLF_SUBSTITUTE 0x18004409 /* substitute one player for another */ +#define DIBUTTON_GOLF_LEFT_LINK 0x1800C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_GOLF_RIGHT_LINK 0x1800C4EC /* Fallback sidestep right button */ +#define DIBUTTON_GOLF_FORWARD_LINK 0x180144E0 /* Fallback move forward button */ +#define DIBUTTON_GOLF_BACK_LINK 0x180144E8 /* Fallback move back button */ +#define DIBUTTON_GOLF_DEVICE 0x180044FE /* Show input device and controls */ +#define DIBUTTON_GOLF_PAUSE 0x180044FC /* Start / Pause / Restart game */ + +/*--- Sports - Hockey - Offense + Offense ---*/ +#define DIVIRTUAL_SPORTS_HOCKEY_OFFENSE 0x19000000 +#define DIAXIS_HOCKEYO_LATERAL 0x19008201 /* Move / Aim: left / right */ +#define DIAXIS_HOCKEYO_MOVE 0x19010202 /* Move / Aim: up / down */ +#define DIBUTTON_HOCKEYO_SHOOT 0x19000401 /* Shoot */ +#define DIBUTTON_HOCKEYO_PASS 0x19000402 /* pass the puck */ +#define DIBUTTON_HOCKEYO_BURST 0x19000403 /* invoke speed burst */ +#define DIBUTTON_HOCKEYO_SPECIAL 0x19000404 /* invoke special move */ +#define DIBUTTON_HOCKEYO_FAKE 0x19000405 /* hold down to fake pass or kick */ +#define DIBUTTON_HOCKEYO_MENU 0x190004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_HOCKEYO_SCROLL 0x19004601 /* scroll view */ +#define DIBUTTON_HOCKEYO_ZOOM 0x19004406 /* Zoom view in / out */ +#define DIBUTTON_HOCKEYO_STRATEGY 0x19004407 /* Invoke coaching menu for strategy help */ +#define DIBUTTON_HOCKEYO_TIMEOUT 0x19004408 /* Call for time out */ +#define DIBUTTON_HOCKEYO_SUBSTITUTE 0x19004409 /* substitute one player for another */ +#define DIBUTTON_HOCKEYO_LEFT_LINK 0x1900C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_HOCKEYO_RIGHT_LINK 0x1900C4EC /* Fallback sidestep right button */ +#define DIBUTTON_HOCKEYO_FORWARD_LINK 0x190144E0 /* Fallback move forward button */ +#define DIBUTTON_HOCKEYO_BACK_LINK 0x190144E8 /* Fallback move back button */ +#define DIBUTTON_HOCKEYO_DEVICE 0x190044FE /* Show input device and controls */ +#define DIBUTTON_HOCKEYO_PAUSE 0x190044FC /* Start / Pause / Restart game */ + +/*--- Sports - Hockey - Defense + Defense ---*/ +#define DIVIRTUAL_SPORTS_HOCKEY_DEFENSE 0x1A000000 +#define DIAXIS_HOCKEYD_LATERAL 0x1A008201 /* Move / Aim: left / right */ +#define DIAXIS_HOCKEYD_MOVE 0x1A010202 /* Move / Aim: up / down */ +#define DIBUTTON_HOCKEYD_PLAYER 0x1A000401 /* control player closest to the puck */ +#define DIBUTTON_HOCKEYD_STEAL 0x1A000402 /* attempt steal */ +#define DIBUTTON_HOCKEYD_BURST 0x1A000403 /* speed burst or body check */ +#define DIBUTTON_HOCKEYD_BLOCK 0x1A000404 /* block puck */ +#define DIBUTTON_HOCKEYD_FAKE 0x1A000405 /* hold down to fake tackle or intercept */ +#define DIBUTTON_HOCKEYD_MENU 0x1A0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_HOCKEYD_SCROLL 0x1A004601 /* scroll view */ +#define DIBUTTON_HOCKEYD_ZOOM 0x1A004406 /* Zoom view in / out */ +#define DIBUTTON_HOCKEYD_STRATEGY 0x1A004407 /* Invoke coaching menu for strategy help */ +#define DIBUTTON_HOCKEYD_TIMEOUT 0x1A004408 /* Call for time out */ +#define DIBUTTON_HOCKEYD_SUBSTITUTE 0x1A004409 /* substitute one player for another */ +#define DIBUTTON_HOCKEYD_LEFT_LINK 0x1A00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_HOCKEYD_RIGHT_LINK 0x1A00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_HOCKEYD_FORWARD_LINK 0x1A0144E0 /* Fallback move forward button */ +#define DIBUTTON_HOCKEYD_BACK_LINK 0x1A0144E8 /* Fallback move back button */ +#define DIBUTTON_HOCKEYD_DEVICE 0x1A0044FE /* Show input device and controls */ +#define DIBUTTON_HOCKEYD_PAUSE 0x1A0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Hockey - Goalie + Goal tending ---*/ +#define DIVIRTUAL_SPORTS_HOCKEY_GOALIE 0x1B000000 +#define DIAXIS_HOCKEYG_LATERAL 0x1B008201 /* Move / Aim: left / right */ +#define DIAXIS_HOCKEYG_MOVE 0x1B010202 /* Move / Aim: up / down */ +#define DIBUTTON_HOCKEYG_PASS 0x1B000401 /* pass puck */ +#define DIBUTTON_HOCKEYG_POKE 0x1B000402 /* poke / check / hack */ +#define DIBUTTON_HOCKEYG_STEAL 0x1B000403 /* attempt steal */ +#define DIBUTTON_HOCKEYG_BLOCK 0x1B000404 /* block puck */ +#define DIBUTTON_HOCKEYG_MENU 0x1B0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_HOCKEYG_SCROLL 0x1B004601 /* scroll view */ +#define DIBUTTON_HOCKEYG_ZOOM 0x1B004405 /* Zoom view in / out */ +#define DIBUTTON_HOCKEYG_STRATEGY 0x1B004406 /* Invoke coaching menu for strategy help */ +#define DIBUTTON_HOCKEYG_TIMEOUT 0x1B004407 /* Call for time out */ +#define DIBUTTON_HOCKEYG_SUBSTITUTE 0x1B004408 /* substitute one player for another */ +#define DIBUTTON_HOCKEYG_LEFT_LINK 0x1B00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_HOCKEYG_RIGHT_LINK 0x1B00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_HOCKEYG_FORWARD_LINK 0x1B0144E0 /* Fallback move forward button */ +#define DIBUTTON_HOCKEYG_BACK_LINK 0x1B0144E8 /* Fallback move back button */ +#define DIBUTTON_HOCKEYG_DEVICE 0x1B0044FE /* Show input device and controls */ +#define DIBUTTON_HOCKEYG_PAUSE 0x1B0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Mountain Biking + ---*/ +#define DIVIRTUAL_SPORTS_BIKING_MOUNTAIN 0x1C000000 +#define DIAXIS_BIKINGM_TURN 0x1C008201 /* left / right */ +#define DIAXIS_BIKINGM_PEDAL 0x1C010202 /* Pedal faster / slower / brake */ +#define DIBUTTON_BIKINGM_JUMP 0x1C000401 /* jump over obstacle */ +#define DIBUTTON_BIKINGM_CAMERA 0x1C000402 /* switch camera view */ +#define DIBUTTON_BIKINGM_SPECIAL1 0x1C000403 /* perform first special move */ +#define DIBUTTON_BIKINGM_SELECT 0x1C000404 /* Select */ +#define DIBUTTON_BIKINGM_SPECIAL2 0x1C000405 /* perform second special move */ +#define DIBUTTON_BIKINGM_MENU 0x1C0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_BIKINGM_SCROLL 0x1C004601 /* scroll view */ +#define DIBUTTON_BIKINGM_ZOOM 0x1C004406 /* Zoom view in / out */ +#define DIAXIS_BIKINGM_BRAKE 0x1C044203 /* Brake axis */ +#define DIBUTTON_BIKINGM_LEFT_LINK 0x1C00C4E4 /* Fallback turn left button */ +#define DIBUTTON_BIKINGM_RIGHT_LINK 0x1C00C4EC /* Fallback turn right button */ +#define DIBUTTON_BIKINGM_FASTER_LINK 0x1C0144E0 /* Fallback pedal faster button */ +#define DIBUTTON_BIKINGM_SLOWER_LINK 0x1C0144E8 /* Fallback pedal slower button */ +#define DIBUTTON_BIKINGM_BRAKE_BUTTON_LINK 0x1C0444E8 /* Fallback brake button */ +#define DIBUTTON_BIKINGM_DEVICE 0x1C0044FE /* Show input device and controls */ +#define DIBUTTON_BIKINGM_PAUSE 0x1C0044FC /* Start / Pause / Restart game */ + +/*--- Sports: Skiing / Snowboarding / Skateboarding + ---*/ +#define DIVIRTUAL_SPORTS_SKIING 0x1D000000 +#define DIAXIS_SKIING_TURN 0x1D008201 /* left / right */ +#define DIAXIS_SKIING_SPEED 0x1D010202 /* faster / slower */ +#define DIBUTTON_SKIING_JUMP 0x1D000401 /* Jump */ +#define DIBUTTON_SKIING_CROUCH 0x1D000402 /* crouch down */ +#define DIBUTTON_SKIING_CAMERA 0x1D000403 /* switch camera view */ +#define DIBUTTON_SKIING_SPECIAL1 0x1D000404 /* perform first special move */ +#define DIBUTTON_SKIING_SELECT 0x1D000405 /* Select */ +#define DIBUTTON_SKIING_SPECIAL2 0x1D000406 /* perform second special move */ +#define DIBUTTON_SKIING_MENU 0x1D0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_SKIING_GLANCE 0x1D004601 /* scroll view */ +#define DIBUTTON_SKIING_ZOOM 0x1D004407 /* Zoom view in / out */ +#define DIBUTTON_SKIING_LEFT_LINK 0x1D00C4E4 /* Fallback turn left button */ +#define DIBUTTON_SKIING_RIGHT_LINK 0x1D00C4EC /* Fallback turn right button */ +#define DIBUTTON_SKIING_FASTER_LINK 0x1D0144E0 /* Fallback increase speed button */ +#define DIBUTTON_SKIING_SLOWER_LINK 0x1D0144E8 /* Fallback decrease speed button */ +#define DIBUTTON_SKIING_DEVICE 0x1D0044FE /* Show input device and controls */ +#define DIBUTTON_SKIING_PAUSE 0x1D0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Soccer - Offense + Offense ---*/ +#define DIVIRTUAL_SPORTS_SOCCER_OFFENSE 0x1E000000 +#define DIAXIS_SOCCERO_LATERAL 0x1E008201 /* Move / Aim: left / right */ +#define DIAXIS_SOCCERO_MOVE 0x1E010202 /* Move / Aim: up / down */ +#define DIAXIS_SOCCERO_BEND 0x1E018203 /* Bend to soccer shot/pass */ +#define DIBUTTON_SOCCERO_SHOOT 0x1E000401 /* Shoot the ball */ +#define DIBUTTON_SOCCERO_PASS 0x1E000402 /* Pass */ +#define DIBUTTON_SOCCERO_FAKE 0x1E000403 /* Fake */ +#define DIBUTTON_SOCCERO_PLAYER 0x1E000404 /* Select next player */ +#define DIBUTTON_SOCCERO_SPECIAL1 0x1E000405 /* Apply special move */ +#define DIBUTTON_SOCCERO_SELECT 0x1E000406 /* Select special move */ +#define DIBUTTON_SOCCERO_MENU 0x1E0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_SOCCERO_GLANCE 0x1E004601 /* scroll view */ +#define DIBUTTON_SOCCERO_SUBSTITUTE 0x1E004407 /* Substitute one player for another */ +#define DIBUTTON_SOCCERO_SHOOTLOW 0x1E004408 /* Shoot the ball low */ +#define DIBUTTON_SOCCERO_SHOOTHIGH 0x1E004409 /* Shoot the ball high */ +#define DIBUTTON_SOCCERO_PASSTHRU 0x1E00440A /* Make a thru pass */ +#define DIBUTTON_SOCCERO_SPRINT 0x1E00440B /* Sprint / turbo boost */ +#define DIBUTTON_SOCCERO_CONTROL 0x1E00440C /* Obtain control of the ball */ +#define DIBUTTON_SOCCERO_HEAD 0x1E00440D /* Attempt to head the ball */ +#define DIBUTTON_SOCCERO_LEFT_LINK 0x1E00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_SOCCERO_RIGHT_LINK 0x1E00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_SOCCERO_FORWARD_LINK 0x1E0144E0 /* Fallback move forward button */ +#define DIBUTTON_SOCCERO_BACK_LINK 0x1E0144E8 /* Fallback move back button */ +#define DIBUTTON_SOCCERO_DEVICE 0x1E0044FE /* Show input device and controls */ +#define DIBUTTON_SOCCERO_PAUSE 0x1E0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Soccer - Defense + Defense ---*/ +#define DIVIRTUAL_SPORTS_SOCCER_DEFENSE 0x1F000000 +#define DIAXIS_SOCCERD_LATERAL 0x1F008201 /* Move / Aim: left / right */ +#define DIAXIS_SOCCERD_MOVE 0x1F010202 /* Move / Aim: up / down */ +#define DIBUTTON_SOCCERD_BLOCK 0x1F000401 /* Attempt to block shot */ +#define DIBUTTON_SOCCERD_STEAL 0x1F000402 /* Attempt to steal ball */ +#define DIBUTTON_SOCCERD_FAKE 0x1F000403 /* Fake a block or a steal */ +#define DIBUTTON_SOCCERD_PLAYER 0x1F000404 /* Select next player */ +#define DIBUTTON_SOCCERD_SPECIAL 0x1F000405 /* Apply special move */ +#define DIBUTTON_SOCCERD_SELECT 0x1F000406 /* Select special move */ +#define DIBUTTON_SOCCERD_SLIDE 0x1F000407 /* Attempt a slide tackle */ +#define DIBUTTON_SOCCERD_MENU 0x1F0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_SOCCERD_GLANCE 0x1F004601 /* scroll view */ +#define DIBUTTON_SOCCERD_FOUL 0x1F004408 /* Initiate a foul / hard-foul */ +#define DIBUTTON_SOCCERD_HEAD 0x1F004409 /* Attempt a Header */ +#define DIBUTTON_SOCCERD_CLEAR 0x1F00440A /* Attempt to clear the ball down the field */ +#define DIBUTTON_SOCCERD_GOALIECHARGE 0x1F00440B /* Make the goalie charge out of the box */ +#define DIBUTTON_SOCCERD_SUBSTITUTE 0x1F00440C /* Substitute one player for another */ +#define DIBUTTON_SOCCERD_LEFT_LINK 0x1F00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_SOCCERD_RIGHT_LINK 0x1F00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_SOCCERD_FORWARD_LINK 0x1F0144E0 /* Fallback move forward button */ +#define DIBUTTON_SOCCERD_BACK_LINK 0x1F0144E8 /* Fallback move back button */ +#define DIBUTTON_SOCCERD_DEVICE 0x1F0044FE /* Show input device and controls */ +#define DIBUTTON_SOCCERD_PAUSE 0x1F0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Racquet + Tennis - Table-Tennis - Squash ---*/ +#define DIVIRTUAL_SPORTS_RACQUET 0x20000000 +#define DIAXIS_RACQUET_LATERAL 0x20008201 /* Move / Aim: left / right */ +#define DIAXIS_RACQUET_MOVE 0x20010202 /* Move / Aim: up / down */ +#define DIBUTTON_RACQUET_SWING 0x20000401 /* Swing racquet */ +#define DIBUTTON_RACQUET_BACKSWING 0x20000402 /* Swing backhand */ +#define DIBUTTON_RACQUET_SMASH 0x20000403 /* Smash shot */ +#define DIBUTTON_RACQUET_SPECIAL 0x20000404 /* Special shot */ +#define DIBUTTON_RACQUET_SELECT 0x20000405 /* Select special shot */ +#define DIBUTTON_RACQUET_MENU 0x200004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_RACQUET_GLANCE 0x20004601 /* scroll view */ +#define DIBUTTON_RACQUET_TIMEOUT 0x20004406 /* Call for time out */ +#define DIBUTTON_RACQUET_SUBSTITUTE 0x20004407 /* Substitute one player for another */ +#define DIBUTTON_RACQUET_LEFT_LINK 0x2000C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_RACQUET_RIGHT_LINK 0x2000C4EC /* Fallback sidestep right button */ +#define DIBUTTON_RACQUET_FORWARD_LINK 0x200144E0 /* Fallback move forward button */ +#define DIBUTTON_RACQUET_BACK_LINK 0x200144E8 /* Fallback move back button */ +#define DIBUTTON_RACQUET_DEVICE 0x200044FE /* Show input device and controls */ +#define DIBUTTON_RACQUET_PAUSE 0x200044FC /* Start / Pause / Restart game */ + +/*--- Arcade- 2D + Side to Side movement ---*/ +#define DIVIRTUAL_ARCADE_SIDE2SIDE 0x21000000 +#define DIAXIS_ARCADES_LATERAL 0x21008201 /* left / right */ +#define DIAXIS_ARCADES_MOVE 0x21010202 /* up / down */ +#define DIBUTTON_ARCADES_THROW 0x21000401 /* throw object */ +#define DIBUTTON_ARCADES_CARRY 0x21000402 /* carry object */ +#define DIBUTTON_ARCADES_ATTACK 0x21000403 /* attack */ +#define DIBUTTON_ARCADES_SPECIAL 0x21000404 /* apply special move */ +#define DIBUTTON_ARCADES_SELECT 0x21000405 /* select special move */ +#define DIBUTTON_ARCADES_MENU 0x210004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_ARCADES_VIEW 0x21004601 /* scroll view left / right / up / down */ +#define DIBUTTON_ARCADES_LEFT_LINK 0x2100C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_ARCADES_RIGHT_LINK 0x2100C4EC /* Fallback sidestep right button */ +#define DIBUTTON_ARCADES_FORWARD_LINK 0x210144E0 /* Fallback move forward button */ +#define DIBUTTON_ARCADES_BACK_LINK 0x210144E8 /* Fallback move back button */ +#define DIBUTTON_ARCADES_VIEW_UP_LINK 0x2107C4E0 /* Fallback scroll view up button */ +#define DIBUTTON_ARCADES_VIEW_DOWN_LINK 0x2107C4E8 /* Fallback scroll view down button */ +#define DIBUTTON_ARCADES_VIEW_LEFT_LINK 0x2107C4E4 /* Fallback scroll view left button */ +#define DIBUTTON_ARCADES_VIEW_RIGHT_LINK 0x2107C4EC /* Fallback scroll view right button */ +#define DIBUTTON_ARCADES_DEVICE 0x210044FE /* Show input device and controls */ +#define DIBUTTON_ARCADES_PAUSE 0x210044FC /* Start / Pause / Restart game */ + +/*--- Arcade - Platform Game + Character moves around on screen ---*/ +#define DIVIRTUAL_ARCADE_PLATFORM 0x22000000 +#define DIAXIS_ARCADEP_LATERAL 0x22008201 /* Left / right */ +#define DIAXIS_ARCADEP_MOVE 0x22010202 /* Up / down */ +#define DIBUTTON_ARCADEP_JUMP 0x22000401 /* Jump */ +#define DIBUTTON_ARCADEP_FIRE 0x22000402 /* Fire */ +#define DIBUTTON_ARCADEP_CROUCH 0x22000403 /* Crouch */ +#define DIBUTTON_ARCADEP_SPECIAL 0x22000404 /* Apply special move */ +#define DIBUTTON_ARCADEP_SELECT 0x22000405 /* Select special move */ +#define DIBUTTON_ARCADEP_MENU 0x220004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_ARCADEP_VIEW 0x22004601 /* Scroll view */ +#define DIBUTTON_ARCADEP_FIRESECONDARY 0x22004406 /* Alternative fire button */ +#define DIBUTTON_ARCADEP_LEFT_LINK 0x2200C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_ARCADEP_RIGHT_LINK 0x2200C4EC /* Fallback sidestep right button */ +#define DIBUTTON_ARCADEP_FORWARD_LINK 0x220144E0 /* Fallback move forward button */ +#define DIBUTTON_ARCADEP_BACK_LINK 0x220144E8 /* Fallback move back button */ +#define DIBUTTON_ARCADEP_VIEW_UP_LINK 0x2207C4E0 /* Fallback scroll view up button */ +#define DIBUTTON_ARCADEP_VIEW_DOWN_LINK 0x2207C4E8 /* Fallback scroll view down button */ +#define DIBUTTON_ARCADEP_VIEW_LEFT_LINK 0x2207C4E4 /* Fallback scroll view left button */ +#define DIBUTTON_ARCADEP_VIEW_RIGHT_LINK 0x2207C4EC /* Fallback scroll view right button */ +#define DIBUTTON_ARCADEP_DEVICE 0x220044FE /* Show input device and controls */ +#define DIBUTTON_ARCADEP_PAUSE 0x220044FC /* Start / Pause / Restart game */ + +/*--- CAD - 2D Object Control + Controls to select and move objects in 2D ---*/ +#define DIVIRTUAL_CAD_2DCONTROL 0x23000000 +#define DIAXIS_2DCONTROL_LATERAL 0x23008201 /* Move view left / right */ +#define DIAXIS_2DCONTROL_MOVE 0x23010202 /* Move view up / down */ +#define DIAXIS_2DCONTROL_INOUT 0x23018203 /* Zoom - in / out */ +#define DIBUTTON_2DCONTROL_SELECT 0x23000401 /* Select Object */ +#define DIBUTTON_2DCONTROL_SPECIAL1 0x23000402 /* Do first special operation */ +#define DIBUTTON_2DCONTROL_SPECIAL 0x23000403 /* Select special operation */ +#define DIBUTTON_2DCONTROL_SPECIAL2 0x23000404 /* Do second special operation */ +#define DIBUTTON_2DCONTROL_MENU 0x230004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_2DCONTROL_HATSWITCH 0x23004601 /* Hat switch */ +#define DIAXIS_2DCONTROL_ROTATEZ 0x23024204 /* Rotate view clockwise / counterclockwise */ +#define DIBUTTON_2DCONTROL_DISPLAY 0x23004405 /* Shows next on-screen display options */ +#define DIBUTTON_2DCONTROL_DEVICE 0x230044FE /* Show input device and controls */ +#define DIBUTTON_2DCONTROL_PAUSE 0x230044FC /* Start / Pause / Restart game */ + +/*--- CAD - 3D object control + Controls to select and move objects within a 3D environment ---*/ +#define DIVIRTUAL_CAD_3DCONTROL 0x24000000 +#define DIAXIS_3DCONTROL_LATERAL 0x24008201 /* Move view left / right */ +#define DIAXIS_3DCONTROL_MOVE 0x24010202 /* Move view up / down */ +#define DIAXIS_3DCONTROL_INOUT 0x24018203 /* Zoom - in / out */ +#define DIBUTTON_3DCONTROL_SELECT 0x24000401 /* Select Object */ +#define DIBUTTON_3DCONTROL_SPECIAL1 0x24000402 /* Do first special operation */ +#define DIBUTTON_3DCONTROL_SPECIAL 0x24000403 /* Select special operation */ +#define DIBUTTON_3DCONTROL_SPECIAL2 0x24000404 /* Do second special operation */ +#define DIBUTTON_3DCONTROL_MENU 0x240004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_3DCONTROL_HATSWITCH 0x24004601 /* Hat switch */ +#define DIAXIS_3DCONTROL_ROTATEX 0x24034204 /* Rotate view forward or up / backward or down */ +#define DIAXIS_3DCONTROL_ROTATEY 0x2402C205 /* Rotate view clockwise / counterclockwise */ +#define DIAXIS_3DCONTROL_ROTATEZ 0x24024206 /* Rotate view left / right */ +#define DIBUTTON_3DCONTROL_DISPLAY 0x24004405 /* Show next on-screen display options */ +#define DIBUTTON_3DCONTROL_DEVICE 0x240044FE /* Show input device and controls */ +#define DIBUTTON_3DCONTROL_PAUSE 0x240044FC /* Start / Pause / Restart game */ + +/*--- CAD - 3D Navigation - Fly through + Controls for 3D modeling ---*/ +#define DIVIRTUAL_CAD_FLYBY 0x25000000 +#define DIAXIS_CADF_LATERAL 0x25008201 /* move view left / right */ +#define DIAXIS_CADF_MOVE 0x25010202 /* move view up / down */ +#define DIAXIS_CADF_INOUT 0x25018203 /* in / out */ +#define DIBUTTON_CADF_SELECT 0x25000401 /* Select Object */ +#define DIBUTTON_CADF_SPECIAL1 0x25000402 /* do first special operation */ +#define DIBUTTON_CADF_SPECIAL 0x25000403 /* Select special operation */ +#define DIBUTTON_CADF_SPECIAL2 0x25000404 /* do second special operation */ +#define DIBUTTON_CADF_MENU 0x250004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_CADF_HATSWITCH 0x25004601 /* Hat switch */ +#define DIAXIS_CADF_ROTATEX 0x25034204 /* Rotate view forward or up / backward or down */ +#define DIAXIS_CADF_ROTATEY 0x2502C205 /* Rotate view clockwise / counterclockwise */ +#define DIAXIS_CADF_ROTATEZ 0x25024206 /* Rotate view left / right */ +#define DIBUTTON_CADF_DISPLAY 0x25004405 /* shows next on-screen display options */ +#define DIBUTTON_CADF_DEVICE 0x250044FE /* Show input device and controls */ +#define DIBUTTON_CADF_PAUSE 0x250044FC /* Start / Pause / Restart game */ + +/*--- CAD - 3D Model Control + Controls for 3D modeling ---*/ +#define DIVIRTUAL_CAD_MODEL 0x26000000 +#define DIAXIS_CADM_LATERAL 0x26008201 /* move view left / right */ +#define DIAXIS_CADM_MOVE 0x26010202 /* move view up / down */ +#define DIAXIS_CADM_INOUT 0x26018203 /* in / out */ +#define DIBUTTON_CADM_SELECT 0x26000401 /* Select Object */ +#define DIBUTTON_CADM_SPECIAL1 0x26000402 /* do first special operation */ +#define DIBUTTON_CADM_SPECIAL 0x26000403 /* Select special operation */ +#define DIBUTTON_CADM_SPECIAL2 0x26000404 /* do second special operation */ +#define DIBUTTON_CADM_MENU 0x260004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_CADM_HATSWITCH 0x26004601 /* Hat switch */ +#define DIAXIS_CADM_ROTATEX 0x26034204 /* Rotate view forward or up / backward or down */ +#define DIAXIS_CADM_ROTATEY 0x2602C205 /* Rotate view clockwise / counterclockwise */ +#define DIAXIS_CADM_ROTATEZ 0x26024206 /* Rotate view left / right */ +#define DIBUTTON_CADM_DISPLAY 0x26004405 /* shows next on-screen display options */ +#define DIBUTTON_CADM_DEVICE 0x260044FE /* Show input device and controls */ +#define DIBUTTON_CADM_PAUSE 0x260044FC /* Start / Pause / Restart game */ + +/*--- Control - Media Equipment + Remote ---*/ +#define DIVIRTUAL_REMOTE_CONTROL 0x27000000 +#define DIAXIS_REMOTE_SLIDER 0x27050201 /* Slider for adjustment: volume / color / bass / etc */ +#define DIBUTTON_REMOTE_MUTE 0x27000401 /* Set volume on current device to zero */ +#define DIBUTTON_REMOTE_SELECT 0x27000402 /* Next/previous: channel/ track / chapter / picture / station */ +#define DIBUTTON_REMOTE_PLAY 0x27002403 /* Start or pause entertainment on current device */ +#define DIBUTTON_REMOTE_CUE 0x27002404 /* Move through current media */ +#define DIBUTTON_REMOTE_REVIEW 0x27002405 /* Move through current media */ +#define DIBUTTON_REMOTE_CHANGE 0x27002406 /* Select next device */ +#define DIBUTTON_REMOTE_RECORD 0x27002407 /* Start recording the current media */ +#define DIBUTTON_REMOTE_MENU 0x270004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIAXIS_REMOTE_SLIDER2 0x27054202 /* Slider for adjustment: volume */ +#define DIBUTTON_REMOTE_TV 0x27005C08 /* Select TV */ +#define DIBUTTON_REMOTE_CABLE 0x27005C09 /* Select cable box */ +#define DIBUTTON_REMOTE_CD 0x27005C0A /* Select CD player */ +#define DIBUTTON_REMOTE_VCR 0x27005C0B /* Select VCR */ +#define DIBUTTON_REMOTE_TUNER 0x27005C0C /* Select tuner */ +#define DIBUTTON_REMOTE_DVD 0x27005C0D /* Select DVD player */ +#define DIBUTTON_REMOTE_ADJUST 0x27005C0E /* Enter device adjustment menu */ +#define DIBUTTON_REMOTE_DIGIT0 0x2700540F /* Digit 0 */ +#define DIBUTTON_REMOTE_DIGIT1 0x27005410 /* Digit 1 */ +#define DIBUTTON_REMOTE_DIGIT2 0x27005411 /* Digit 2 */ +#define DIBUTTON_REMOTE_DIGIT3 0x27005412 /* Digit 3 */ +#define DIBUTTON_REMOTE_DIGIT4 0x27005413 /* Digit 4 */ +#define DIBUTTON_REMOTE_DIGIT5 0x27005414 /* Digit 5 */ +#define DIBUTTON_REMOTE_DIGIT6 0x27005415 /* Digit 6 */ +#define DIBUTTON_REMOTE_DIGIT7 0x27005416 /* Digit 7 */ +#define DIBUTTON_REMOTE_DIGIT8 0x27005417 /* Digit 8 */ +#define DIBUTTON_REMOTE_DIGIT9 0x27005418 /* Digit 9 */ +#define DIBUTTON_REMOTE_DEVICE 0x270044FE /* Show input device and controls */ +#define DIBUTTON_REMOTE_PAUSE 0x270044FC /* Start / Pause / Restart game */ + +/*--- Control- Web + Help or Browser ---*/ +#define DIVIRTUAL_BROWSER_CONTROL 0x28000000 +#define DIAXIS_BROWSER_LATERAL 0x28008201 /* Move on screen pointer */ +#define DIAXIS_BROWSER_MOVE 0x28010202 /* Move on screen pointer */ +#define DIBUTTON_BROWSER_SELECT 0x28000401 /* Select current item */ +#define DIAXIS_BROWSER_VIEW 0x28018203 /* Move view up/down */ +#define DIBUTTON_BROWSER_REFRESH 0x28000402 /* Refresh */ +#define DIBUTTON_BROWSER_MENU 0x280004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_BROWSER_SEARCH 0x28004403 /* Use search tool */ +#define DIBUTTON_BROWSER_STOP 0x28004404 /* Cease current update */ +#define DIBUTTON_BROWSER_HOME 0x28004405 /* Go directly to "home" location */ +#define DIBUTTON_BROWSER_FAVORITES 0x28004406 /* Mark current site as favorite */ +#define DIBUTTON_BROWSER_NEXT 0x28004407 /* Select Next page */ +#define DIBUTTON_BROWSER_PREVIOUS 0x28004408 /* Select Previous page */ +#define DIBUTTON_BROWSER_HISTORY 0x28004409 /* Show/Hide History */ +#define DIBUTTON_BROWSER_PRINT 0x2800440A /* Print current page */ +#define DIBUTTON_BROWSER_DEVICE 0x280044FE /* Show input device and controls */ +#define DIBUTTON_BROWSER_PAUSE 0x280044FC /* Start / Pause / Restart game */ + +/*--- Driving Simulator - Giant Walking Robot + Walking tank with weapons ---*/ +#define DIVIRTUAL_DRIVING_MECHA 0x29000000 +#define DIAXIS_MECHA_STEER 0x29008201 /* Turns mecha left/right */ +#define DIAXIS_MECHA_TORSO 0x29010202 /* Tilts torso forward/backward */ +#define DIAXIS_MECHA_ROTATE 0x29020203 /* Turns torso left/right */ +#define DIAXIS_MECHA_THROTTLE 0x29038204 /* Engine Speed */ +#define DIBUTTON_MECHA_FIRE 0x29000401 /* Fire */ +#define DIBUTTON_MECHA_WEAPONS 0x29000402 /* Select next weapon group */ +#define DIBUTTON_MECHA_TARGET 0x29000403 /* Select closest enemy available target */ +#define DIBUTTON_MECHA_REVERSE 0x29000404 /* Toggles throttle in/out of reverse */ +#define DIBUTTON_MECHA_ZOOM 0x29000405 /* Zoom in/out targeting reticule */ +#define DIBUTTON_MECHA_JUMP 0x29000406 /* Fires jump jets */ +#define DIBUTTON_MECHA_MENU 0x290004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_MECHA_CENTER 0x29004407 /* Center torso to legs */ +#define DIHATSWITCH_MECHA_GLANCE 0x29004601 /* Look around */ +#define DIBUTTON_MECHA_VIEW 0x29004408 /* Cycle through view options */ +#define DIBUTTON_MECHA_FIRESECONDARY 0x29004409 /* Alternative fire button */ +#define DIBUTTON_MECHA_LEFT_LINK 0x2900C4E4 /* Fallback steer left button */ +#define DIBUTTON_MECHA_RIGHT_LINK 0x2900C4EC /* Fallback steer right button */ +#define DIBUTTON_MECHA_FORWARD_LINK 0x290144E0 /* Fallback tilt torso forward button */ +#define DIBUTTON_MECHA_BACK_LINK 0x290144E8 /* Fallback tilt toroso backward button */ +#define DIBUTTON_MECHA_ROTATE_LEFT_LINK 0x290244E4 /* Fallback rotate toroso right button */ +#define DIBUTTON_MECHA_ROTATE_RIGHT_LINK 0x290244EC /* Fallback rotate torso left button */ +#define DIBUTTON_MECHA_FASTER_LINK 0x2903C4E0 /* Fallback increase engine speed */ +#define DIBUTTON_MECHA_SLOWER_LINK 0x2903C4E8 /* Fallback decrease engine speed */ +#define DIBUTTON_MECHA_DEVICE 0x290044FE /* Show input device and controls */ +#define DIBUTTON_MECHA_PAUSE 0x290044FC /* Start / Pause / Restart game */ + +/* + * "ANY" semantics can be used as a last resort to get mappings for actions + * that match nothing in the chosen virtual genre. These semantics will be + * mapped at a lower priority that virtual genre semantics. Also, hardware + * vendors will not be able to provide sensible mappings for these unless + * they provide application specific mappings. + */ +#define DIAXIS_ANY_X_1 0xFF00C201 +#define DIAXIS_ANY_X_2 0xFF00C202 +#define DIAXIS_ANY_Y_1 0xFF014201 +#define DIAXIS_ANY_Y_2 0xFF014202 +#define DIAXIS_ANY_Z_1 0xFF01C201 +#define DIAXIS_ANY_Z_2 0xFF01C202 +#define DIAXIS_ANY_R_1 0xFF024201 +#define DIAXIS_ANY_R_2 0xFF024202 +#define DIAXIS_ANY_U_1 0xFF02C201 +#define DIAXIS_ANY_U_2 0xFF02C202 +#define DIAXIS_ANY_V_1 0xFF034201 +#define DIAXIS_ANY_V_2 0xFF034202 +#define DIAXIS_ANY_A_1 0xFF03C201 +#define DIAXIS_ANY_A_2 0xFF03C202 +#define DIAXIS_ANY_B_1 0xFF044201 +#define DIAXIS_ANY_B_2 0xFF044202 +#define DIAXIS_ANY_C_1 0xFF04C201 +#define DIAXIS_ANY_C_2 0xFF04C202 +#define DIAXIS_ANY_S_1 0xFF054201 +#define DIAXIS_ANY_S_2 0xFF054202 + +#define DIAXIS_ANY_1 0xFF004201 +#define DIAXIS_ANY_2 0xFF004202 +#define DIAXIS_ANY_3 0xFF004203 +#define DIAXIS_ANY_4 0xFF004204 + +#define DIPOV_ANY_1 0xFF004601 +#define DIPOV_ANY_2 0xFF004602 +#define DIPOV_ANY_3 0xFF004603 +#define DIPOV_ANY_4 0xFF004604 + +#define DIBUTTON_ANY(instance) ( 0xFF004400 | instance ) + + +#ifdef __cplusplus +}; +#endif + +#endif /* __DINPUT_INCLUDED__ */ + +/**************************************************************************** + * + * Definitions for non-IDirectInput (VJoyD) features defined more recently + * than the current sdk files + * + ****************************************************************************/ + +#ifdef _INC_MMSYSTEM +#ifndef MMNOJOY + +#ifndef __VJOYDX_INCLUDED__ +#define __VJOYDX_INCLUDED__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Flag to indicate that the dwReserved2 field of the JOYINFOEX structure + * contains mini-driver specific data to be passed by VJoyD to the mini- + * driver instead of doing a poll. + */ +#define JOY_PASSDRIVERDATA 0x10000000l + +/* + * Informs the joystick driver that the configuration has been changed + * and should be reloaded from the registery. + * dwFlags is reserved and should be set to zero + */ +WINMMAPI MMRESULT WINAPI joyConfigChanged( DWORD dwFlags ); + +#ifndef DIJ_RINGZERO +/* + * Invoke the joystick control panel directly, using the passed window handle + * as the parent of the dialog. This API is only supported for compatibility + * purposes; new applications should use the RunControlPanel method of a + * device interface for a game controller. + * The API is called by using the function pointer returned by + * GetProcAddress( hCPL, TEXT("ShowJoyCPL") ) where hCPL is a HMODULE returned + * by LoadLibrary( TEXT("joy.cpl") ). The typedef is provided to allow + * declaration and casting of an appropriately typed variable. + */ +void WINAPI ShowJoyCPL( HWND hWnd ); +typedef void (WINAPI* LPFNSHOWJOYCPL)( HWND hWnd ); +#endif /* DIJ_RINGZERO */ + + +/* + * Hardware Setting indicating that the device is a headtracker + */ +#define JOY_HWS_ISHEADTRACKER 0x02000000l + +/* + * Hardware Setting indicating that the VxD is used to replace + * the standard analog polling + */ +#define JOY_HWS_ISGAMEPORTDRIVER 0x04000000l + +/* + * Hardware Setting indicating that the driver needs a standard + * gameport in order to communicate with the device. + */ +#define JOY_HWS_ISANALOGPORTDRIVER 0x08000000l + +/* + * Hardware Setting indicating that VJoyD should not load this + * driver, it will be loaded externally and will register with + * VJoyD of it's own accord. + */ +#define JOY_HWS_AUTOLOAD 0x10000000l + +/* + * Hardware Setting indicating that the driver acquires any + * resources needed without needing a devnode through VJoyD. + */ +#define JOY_HWS_NODEVNODE 0x20000000l + + +/* + * Hardware Setting indicating that the device is a gameport bus + */ +#define JOY_HWS_ISGAMEPORTBUS 0x80000000l +#define JOY_HWS_GAMEPORTBUSBUSY 0x00000001l + +/* + * Usage Setting indicating that the settings are volatile and + * should be removed if still present on a reboot. + */ +#define JOY_US_VOLATILE 0x00000008L + +#ifdef __cplusplus +}; +#endif + +#endif /* __VJOYDX_INCLUDED__ */ + +#endif /* not MMNOJOY */ +#endif /* _INC_MMSYSTEM */ + +/**************************************************************************** + * + * Definitions for non-IDirectInput (VJoyD) features defined more recently + * than the current ddk files + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +#ifdef _INC_MMDDK +#ifndef MMNOJOYDEV + +#ifndef __VJOYDXD_INCLUDED__ +#define __VJOYDXD_INCLUDED__ +/* + * Poll type in which the do_other field of the JOYOEMPOLLDATA + * structure contains mini-driver specific data passed from an app. + */ +#define JOY_OEMPOLL_PASSDRIVERDATA 7 + +#endif /* __VJOYDXD_INCLUDED__ */ + +#endif /* not MMNOJOYDEV */ +#endif /* _INC_MMDDK */ + +#endif /* DIJ_RINGZERO */ + diff --git a/src/dep/include/DXSDK/include/dinputd.h b/src/dep/include/DXSDK/include/dinputd.h index d27039a..f534353 100644 --- a/src/dep/include/DXSDK/include/dinputd.h +++ b/src/dep/include/DXSDK/include/dinputd.h @@ -1,755 +1,755 @@ -/**************************************************************************** - * - * Copyright (C) 1995-2000 Microsoft Corporation. All Rights Reserved. - * - * File: dinputd.h - * Content: DirectInput include file for device driver implementors - * - ****************************************************************************/ -#ifndef __DINPUTD_INCLUDED__ -#define __DINPUTD_INCLUDED__ - -#ifndef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION 0x0800 -#pragma message(__FILE__ ": DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800") -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/**************************************************************************** - * - * Interfaces - * - ****************************************************************************/ - -#ifndef DIJ_RINGZERO - -DEFINE_GUID(IID_IDirectInputEffectDriver, 0x02538130,0x898F,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(IID_IDirectInputJoyConfig, 0x1DE12AB1,0xC9F5,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputPIDDriver, 0xEEC6993A,0xB3FD,0x11D2,0xA9,0x16,0x00,0xC0,0x4F,0xB9,0x86,0x38); - -DEFINE_GUID(IID_IDirectInputJoyConfig8, 0xeb0d7dfa,0x1990,0x4f27,0xb4,0xd6,0xed,0xf2,0xee,0xc4,0xa4,0x4c); - -#endif /* DIJ_RINGZERO */ - - -/**************************************************************************** - * - * IDirectInputEffectDriver - * - ****************************************************************************/ - -typedef struct DIOBJECTATTRIBUTES { - DWORD dwFlags; - WORD wUsagePage; - WORD wUsage; -} DIOBJECTATTRIBUTES, *LPDIOBJECTATTRIBUTES; -typedef const DIOBJECTATTRIBUTES *LPCDIOBJECTATTRIBUTES; - -typedef struct DIFFOBJECTATTRIBUTES { - DWORD dwFFMaxForce; - DWORD dwFFForceResolution; -} DIFFOBJECTATTRIBUTES, *LPDIFFOBJECTATTRIBUTES; -typedef const DIFFOBJECTATTRIBUTES *LPCDIFFOBJECTATTRIBUTES; - -typedef struct DIOBJECTCALIBRATION { - LONG lMin; - LONG lCenter; - LONG lMax; -} DIOBJECTCALIBRATION, *LPDIOBJECTCALIBRATION; -typedef const DIOBJECTCALIBRATION *LPCDIOBJECTCALIBRATION; - -typedef struct DIPOVCALIBRATION { - LONG lMin[5]; - LONG lMax[5]; -} DIPOVCALIBRATION, *LPDIPOVCALIBRATION; -typedef const DIPOVCALIBRATION *LPCDIPOVCALIBRATION; - -typedef struct DIEFFECTATTRIBUTES { - DWORD dwEffectId; - DWORD dwEffType; - DWORD dwStaticParams; - DWORD dwDynamicParams; - DWORD dwCoords; -} DIEFFECTATTRIBUTES, *LPDIEFFECTATTRIBUTES; -typedef const DIEFFECTATTRIBUTES *LPCDIEFFECTATTRIBUTES; - -typedef struct DIFFDEVICEATTRIBUTES { - DWORD dwFlags; - DWORD dwFFSamplePeriod; - DWORD dwFFMinTimeResolution; -} DIFFDEVICEATTRIBUTES, *LPDIFFDEVICEATTRIBUTES; -typedef const DIFFDEVICEATTRIBUTES *LPCDIFFDEVICEATTRIBUTES; - -typedef struct DIDRIVERVERSIONS { - DWORD dwSize; - DWORD dwFirmwareRevision; - DWORD dwHardwareRevision; - DWORD dwFFDriverVersion; -} DIDRIVERVERSIONS, *LPDIDRIVERVERSIONS; -typedef const DIDRIVERVERSIONS *LPCDIDRIVERVERSIONS; - -typedef struct DIDEVICESTATE { - DWORD dwSize; - DWORD dwState; - DWORD dwLoad; -} DIDEVICESTATE, *LPDIDEVICESTATE; - -#define DEV_STS_EFFECT_RUNNING DIEGES_PLAYING - -#ifndef DIJ_RINGZERO - -typedef struct DIHIDFFINITINFO { - DWORD dwSize; - LPWSTR pwszDeviceInterface; - GUID GuidInstance; -} DIHIDFFINITINFO, *LPDIHIDFFINITINFO; - -#undef INTERFACE -#define INTERFACE IDirectInputEffectDriver - -DECLARE_INTERFACE_(IDirectInputEffectDriver, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputEffectDriver methods ***/ - STDMETHOD(DeviceID)(THIS_ DWORD,DWORD,DWORD,DWORD,LPVOID) PURE; - STDMETHOD(GetVersions)(THIS_ LPDIDRIVERVERSIONS) PURE; - STDMETHOD(Escape)(THIS_ DWORD,DWORD,LPDIEFFESCAPE) PURE; - STDMETHOD(SetGain)(THIS_ DWORD,DWORD) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD,DWORD) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ DWORD,LPDIDEVICESTATE) PURE; - STDMETHOD(DownloadEffect)(THIS_ DWORD,DWORD,LPDWORD,LPCDIEFFECT,DWORD) PURE; - STDMETHOD(DestroyEffect)(THIS_ DWORD,DWORD) PURE; - STDMETHOD(StartEffect)(THIS_ DWORD,DWORD,DWORD,DWORD) PURE; - STDMETHOD(StopEffect)(THIS_ DWORD,DWORD) PURE; - STDMETHOD(GetEffectStatus)(THIS_ DWORD,DWORD,LPDWORD) PURE; -}; - -typedef struct IDirectInputEffectDriver *LPDIRECTINPUTEFFECTDRIVER; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInputEffectDriver_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputEffectDriver_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputEffectDriver_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInputEffectDriver_DeviceID(p,a,b,c,d,e) (p)->lpVtbl->DeviceID(p,a,b,c,d,e) -#define IDirectInputEffectDriver_GetVersions(p,a) (p)->lpVtbl->GetVersions(p,a) -#define IDirectInputEffectDriver_Escape(p,a,b,c) (p)->lpVtbl->Escape(p,a,b,c) -#define IDirectInputEffectDriver_SetGain(p,a,b) (p)->lpVtbl->SetGain(p,a,b) -#define IDirectInputEffectDriver_SendForceFeedbackCommand(p,a,b) (p)->lpVtbl->SendForceFeedbackCommand(p,a,b) -#define IDirectInputEffectDriver_GetForceFeedbackState(p,a,b) (p)->lpVtbl->GetForceFeedbackState(p,a,b) -#define IDirectInputEffectDriver_DownloadEffect(p,a,b,c,d,e) (p)->lpVtbl->DownloadEffect(p,a,b,c,d,e) -#define IDirectInputEffectDriver_DestroyEffect(p,a,b) (p)->lpVtbl->DestroyEffect(p,a,b) -#define IDirectInputEffectDriver_StartEffect(p,a,b,c,d) (p)->lpVtbl->StartEffect(p,a,b,c,d) -#define IDirectInputEffectDriver_StopEffect(p,a,b) (p)->lpVtbl->StopEffect(p,a,b) -#define IDirectInputEffectDriver_GetEffectStatus(p,a,b,c) (p)->lpVtbl->GetEffectStatus(p,a,b,c) -#else -#define IDirectInputEffectDriver_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputEffectDriver_AddRef(p) (p)->AddRef() -#define IDirectInputEffectDriver_Release(p) (p)->Release() -#define IDirectInputEffectDriver_DeviceID(p,a,b,c,d,e) (p)->DeviceID(a,b,c,d,e) -#define IDirectInputEffectDriver_GetVersions(p,a) (p)->GetVersions(a) -#define IDirectInputEffectDriver_Escape(p,a,b,c) (p)->Escape(a,b,c) -#define IDirectInputEffectDriver_SetGain(p,a,b) (p)->SetGain(a,b) -#define IDirectInputEffectDriver_SendForceFeedbackCommand(p,a,b) (p)->SendForceFeedbackCommand(a,b) -#define IDirectInputEffectDriver_GetForceFeedbackState(p,a,b) (p)->GetForceFeedbackState(a,b) -#define IDirectInputEffectDriver_DownloadEffect(p,a,b,c,d,e) (p)->DownloadEffect(a,b,c,d,e) -#define IDirectInputEffectDriver_DestroyEffect(p,a,b) (p)->DestroyEffect(a,b) -#define IDirectInputEffectDriver_StartEffect(p,a,b,c,d) (p)->StartEffect(a,b,c,d) -#define IDirectInputEffectDriver_StopEffect(p,a,b) (p)->StopEffect(a,b) -#define IDirectInputEffectDriver_GetEffectStatus(p,a,b,c) (p)->GetEffectStatus(a,b,c) -#endif - - -#endif /* DIJ_RINGZERO */ - - -/**************************************************************************** - * - * IDirectInputJoyConfig - * - ****************************************************************************/ - -/**************************************************************************** - * - * Definitions copied from the DDK - * - ****************************************************************************/ - -#ifndef JOY_HW_NONE - -/* pre-defined joystick types */ -#define JOY_HW_NONE 0 -#define JOY_HW_CUSTOM 1 -#define JOY_HW_2A_2B_GENERIC 2 -#define JOY_HW_2A_4B_GENERIC 3 -#define JOY_HW_2B_GAMEPAD 4 -#define JOY_HW_2B_FLIGHTYOKE 5 -#define JOY_HW_2B_FLIGHTYOKETHROTTLE 6 -#define JOY_HW_3A_2B_GENERIC 7 -#define JOY_HW_3A_4B_GENERIC 8 -#define JOY_HW_4B_GAMEPAD 9 -#define JOY_HW_4B_FLIGHTYOKE 10 -#define JOY_HW_4B_FLIGHTYOKETHROTTLE 11 -#define JOY_HW_TWO_2A_2B_WITH_Y 12 -#define JOY_HW_LASTENTRY 13 - - -/* calibration flags */ -#define JOY_ISCAL_XY 0x00000001l /* XY are calibrated */ -#define JOY_ISCAL_Z 0x00000002l /* Z is calibrated */ -#define JOY_ISCAL_R 0x00000004l /* R is calibrated */ -#define JOY_ISCAL_U 0x00000008l /* U is calibrated */ -#define JOY_ISCAL_V 0x00000010l /* V is calibrated */ -#define JOY_ISCAL_POV 0x00000020l /* POV is calibrated */ - -/* point of view constants */ -#define JOY_POV_NUMDIRS 4 -#define JOY_POVVAL_FORWARD 0 -#define JOY_POVVAL_BACKWARD 1 -#define JOY_POVVAL_LEFT 2 -#define JOY_POVVAL_RIGHT 3 - -/* Specific settings for joystick hardware */ -#define JOY_HWS_HASZ 0x00000001l /* has Z info? */ -#define JOY_HWS_HASPOV 0x00000002l /* point of view hat present */ -#define JOY_HWS_POVISBUTTONCOMBOS 0x00000004l /* pov done through combo of buttons */ -#define JOY_HWS_POVISPOLL 0x00000008l /* pov done through polling */ -#define JOY_HWS_ISYOKE 0x00000010l /* joystick is a flight yoke */ -#define JOY_HWS_ISGAMEPAD 0x00000020l /* joystick is a game pad */ -#define JOY_HWS_ISCARCTRL 0x00000040l /* joystick is a car controller */ -/* X defaults to J1 X axis */ -#define JOY_HWS_XISJ1Y 0x00000080l /* X is on J1 Y axis */ -#define JOY_HWS_XISJ2X 0x00000100l /* X is on J2 X axis */ -#define JOY_HWS_XISJ2Y 0x00000200l /* X is on J2 Y axis */ -/* Y defaults to J1 Y axis */ -#define JOY_HWS_YISJ1X 0x00000400l /* Y is on J1 X axis */ -#define JOY_HWS_YISJ2X 0x00000800l /* Y is on J2 X axis */ -#define JOY_HWS_YISJ2Y 0x00001000l /* Y is on J2 Y axis */ -/* Z defaults to J2 Y axis */ -#define JOY_HWS_ZISJ1X 0x00002000l /* Z is on J1 X axis */ -#define JOY_HWS_ZISJ1Y 0x00004000l /* Z is on J1 Y axis */ -#define JOY_HWS_ZISJ2X 0x00008000l /* Z is on J2 X axis */ -/* POV defaults to J2 Y axis, if it is not button based */ -#define JOY_HWS_POVISJ1X 0x00010000l /* pov done through J1 X axis */ -#define JOY_HWS_POVISJ1Y 0x00020000l /* pov done through J1 Y axis */ -#define JOY_HWS_POVISJ2X 0x00040000l /* pov done through J2 X axis */ -/* R defaults to J2 X axis */ -#define JOY_HWS_HASR 0x00080000l /* has R (4th axis) info */ -#define JOY_HWS_RISJ1X 0x00100000l /* R done through J1 X axis */ -#define JOY_HWS_RISJ1Y 0x00200000l /* R done through J1 Y axis */ -#define JOY_HWS_RISJ2Y 0x00400000l /* R done through J2 X axis */ -/* U & V for future hardware */ -#define JOY_HWS_HASU 0x00800000l /* has U (5th axis) info */ -#define JOY_HWS_HASV 0x01000000l /* has V (6th axis) info */ - -/* Usage settings */ -#define JOY_US_HASRUDDER 0x00000001l /* joystick configured with rudder */ -#define JOY_US_PRESENT 0x00000002l /* is joystick actually present? */ -#define JOY_US_ISOEM 0x00000004l /* joystick is an OEM defined type */ - -/* reserved for future use -> as link to next possible dword */ -#define JOY_US_RESERVED 0x80000000l /* reserved */ - - -/* Settings for TypeInfo Flags1 */ -#define JOYTYPE_ZEROGAMEENUMOEMDATA 0x00000001l /* Zero GameEnum's OEM data field */ -#define JOYTYPE_NOAUTODETECTGAMEPORT 0x00000002l /* Device does not support Autodetect gameport*/ -#define JOYTYPE_NOHIDDIRECT 0x00000004l /* Do not use HID directly for this device */ -#define JOYTYPE_ANALOGCOMPAT 0x00000008l /* Expose the analog compatible ID */ -#define JOYTYPE_DEFAULTPROPSHEET 0x80000000l /* CPL overrides custom property sheet */ - -/* Settings for TypeInfo Flags2 */ -#define JOYTYPE_DEVICEHIDE 0x00010000l /* Hide unclassified devices */ -#define JOYTYPE_MOUSEHIDE 0x00020000l /* Hide mice */ -#define JOYTYPE_KEYBHIDE 0x00040000l /* Hide keyboards */ -#define JOYTYPE_GAMEHIDE 0x00080000l /* Hide game controllers */ -#define JOYTYPE_HIDEACTIVE 0x00100000l /* Hide flags are active */ -#define JOYTYPE_INFOMASK 0x00E00000l /* Mask for type specific info */ -#define JOYTYPE_INFODEFAULT 0x00000000l /* Use default axis mappings */ -#define JOYTYPE_INFOYYPEDALS 0x00200000l /* Use Y as a combined pedals axis */ -#define JOYTYPE_INFOZYPEDALS 0x00400000l /* Use Z for accelerate, Y for brake */ -#define JOYTYPE_INFOYRPEDALS 0x00600000l /* Use Y for accelerate, R for brake */ -#define JOYTYPE_INFOZRPEDALS 0x00800000l /* Use Z for accelerate, R for brake */ -#define JOYTYPE_INFOZISSLIDER 0x00200000l /* Use Z as a slider */ -#define JOYTYPE_INFOZISZ 0x00400000l /* Use Z as Z axis */ -#define JOYTYPE_ENABLEINPUTREPORT 0x01000000l /* Enable initial input reports */ - -/* struct for storing x,y, z, and rudder values */ -typedef struct joypos_tag { - DWORD dwX; - DWORD dwY; - DWORD dwZ; - DWORD dwR; - DWORD dwU; - DWORD dwV; -} JOYPOS, FAR *LPJOYPOS; - -/* struct for storing ranges */ -typedef struct joyrange_tag { - JOYPOS jpMin; - JOYPOS jpMax; - JOYPOS jpCenter; -} JOYRANGE,FAR *LPJOYRANGE; - -/* - * dwTimeout - value at which to timeout joystick polling - * jrvRanges - range of values app wants returned for axes - * jpDeadZone - area around center to be considered - * as "dead". specified as a percentage - * (0-100). Only X & Y handled by system driver - */ -typedef struct joyreguservalues_tag { - DWORD dwTimeOut; - JOYRANGE jrvRanges; - JOYPOS jpDeadZone; -} JOYREGUSERVALUES, FAR *LPJOYREGUSERVALUES; - -typedef struct joyreghwsettings_tag { - DWORD dwFlags; - DWORD dwNumButtons; -} JOYREGHWSETTINGS, FAR *LPJOYHWSETTINGS; - -/* range of values returned by the hardware (filled in by calibration) */ -/* - * jrvHardware - values returned by hardware - * dwPOVValues - POV values returned by hardware - * dwCalFlags - what has been calibrated - */ -typedef struct joyreghwvalues_tag { - JOYRANGE jrvHardware; - DWORD dwPOVValues[JOY_POV_NUMDIRS]; - DWORD dwCalFlags; -} JOYREGHWVALUES, FAR *LPJOYREGHWVALUES; - -/* hardware configuration */ -/* - * hws - hardware settings - * dwUsageSettings - usage settings - * hwv - values returned by hardware - * dwType - type of joystick - * dwReserved - reserved for OEM drivers - */ -typedef struct joyreghwconfig_tag { - JOYREGHWSETTINGS hws; - DWORD dwUsageSettings; - JOYREGHWVALUES hwv; - DWORD dwType; - DWORD dwReserved; -} JOYREGHWCONFIG, FAR *LPJOYREGHWCONFIG; - -/* joystick calibration info structure */ -typedef struct joycalibrate_tag { - UINT wXbase; - UINT wXdelta; - UINT wYbase; - UINT wYdelta; - UINT wZbase; - UINT wZdelta; -} JOYCALIBRATE; -typedef JOYCALIBRATE FAR *LPJOYCALIBRATE; - -#endif - -#ifndef DIJ_RINGZERO - -#define MAX_JOYSTRING 256 -typedef BOOL (FAR PASCAL * LPDIJOYTYPECALLBACK)(LPCWSTR, LPVOID); - -#ifndef MAX_JOYSTICKOEMVXDNAME -#define MAX_JOYSTICKOEMVXDNAME 260 -#endif - -#define DITC_REGHWSETTINGS 0x00000001 -#define DITC_CLSIDCONFIG 0x00000002 -#define DITC_DISPLAYNAME 0x00000004 -#define DITC_CALLOUT 0x00000008 -#define DITC_HARDWAREID 0x00000010 -#define DITC_FLAGS1 0x00000020 -#define DITC_FLAGS2 0x00000040 -#define DITC_MAPFILE 0x00000080 - - - -/* This structure is defined for DirectX 5.0 compatibility */ - -typedef struct DIJOYTYPEINFO_DX5 { - DWORD dwSize; - JOYREGHWSETTINGS hws; - CLSID clsidConfig; - WCHAR wszDisplayName[MAX_JOYSTRING]; - WCHAR wszCallout[MAX_JOYSTICKOEMVXDNAME]; -} DIJOYTYPEINFO_DX5, *LPDIJOYTYPEINFO_DX5; -typedef const DIJOYTYPEINFO_DX5 *LPCDIJOYTYPEINFO_DX5; - -/* This structure is defined for DirectX 6.1 compatibility */ -typedef struct DIJOYTYPEINFO_DX6 { - DWORD dwSize; - JOYREGHWSETTINGS hws; - CLSID clsidConfig; - WCHAR wszDisplayName[MAX_JOYSTRING]; - WCHAR wszCallout[MAX_JOYSTICKOEMVXDNAME]; - WCHAR wszHardwareId[MAX_JOYSTRING]; - DWORD dwFlags1; -} DIJOYTYPEINFO_DX6, *LPDIJOYTYPEINFO_DX6; -typedef const DIJOYTYPEINFO_DX6 *LPCDIJOYTYPEINFO_DX6; - -typedef struct DIJOYTYPEINFO { - DWORD dwSize; - JOYREGHWSETTINGS hws; - CLSID clsidConfig; - WCHAR wszDisplayName[MAX_JOYSTRING]; - WCHAR wszCallout[MAX_JOYSTICKOEMVXDNAME]; -#if(DIRECTINPUT_VERSION >= 0x05b2) - WCHAR wszHardwareId[MAX_JOYSTRING]; - DWORD dwFlags1; -#if(DIRECTINPUT_VERSION >= 0x0800) - DWORD dwFlags2; - WCHAR wszMapFile[MAX_JOYSTRING]; -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ -#endif /* DIRECTINPUT_VERSION >= 0x05b2 */ -} DIJOYTYPEINFO, *LPDIJOYTYPEINFO; -typedef const DIJOYTYPEINFO *LPCDIJOYTYPEINFO; -#define DIJC_GUIDINSTANCE 0x00000001 -#define DIJC_REGHWCONFIGTYPE 0x00000002 -#define DIJC_GAIN 0x00000004 -#define DIJC_CALLOUT 0x00000008 -#define DIJC_WDMGAMEPORT 0x00000010 - -/* This structure is defined for DirectX 5.0 compatibility */ - -typedef struct DIJOYCONFIG_DX5 { - DWORD dwSize; - GUID guidInstance; - JOYREGHWCONFIG hwc; - DWORD dwGain; - WCHAR wszType[MAX_JOYSTRING]; - WCHAR wszCallout[MAX_JOYSTRING]; -} DIJOYCONFIG_DX5, *LPDIJOYCONFIG_DX5; -typedef const DIJOYCONFIG_DX5 *LPCDIJOYCONFIG_DX5; - -typedef struct DIJOYCONFIG { - DWORD dwSize; - GUID guidInstance; - JOYREGHWCONFIG hwc; - DWORD dwGain; - WCHAR wszType[MAX_JOYSTRING]; - WCHAR wszCallout[MAX_JOYSTRING]; -#if(DIRECTINPUT_VERSION >= 0x05b2) - GUID guidGameport; -#endif /* DIRECTINPUT_VERSION >= 0x05b2 */ - } DIJOYCONFIG, *LPDIJOYCONFIG; -typedef const DIJOYCONFIG *LPCDIJOYCONFIG; - - -#define DIJU_USERVALUES 0x00000001 -#define DIJU_GLOBALDRIVER 0x00000002 -#define DIJU_GAMEPORTEMULATOR 0x00000004 - -typedef struct DIJOYUSERVALUES { - DWORD dwSize; - JOYREGUSERVALUES ruv; - WCHAR wszGlobalDriver[MAX_JOYSTRING]; - WCHAR wszGameportEmulator[MAX_JOYSTRING]; -} DIJOYUSERVALUES, *LPDIJOYUSERVALUES; -typedef const DIJOYUSERVALUES *LPCDIJOYUSERVALUES; - -DEFINE_GUID(GUID_KeyboardClass, 0x4D36E96B,0xE325,0x11CE,0xBF,0xC1,0x08,0x00,0x2B,0xE1,0x03,0x18); -DEFINE_GUID(GUID_MediaClass, 0x4D36E96C,0xE325,0x11CE,0xBF,0xC1,0x08,0x00,0x2B,0xE1,0x03,0x18); -DEFINE_GUID(GUID_MouseClass, 0x4D36E96F,0xE325,0x11CE,0xBF,0xC1,0x08,0x00,0x2B,0xE1,0x03,0x18); -DEFINE_GUID(GUID_HIDClass, 0x745A17A0,0x74D3,0x11D0,0xB6,0xFE,0x00,0xA0,0xC9,0x0F,0x57,0xDA); - -#undef INTERFACE -#define INTERFACE IDirectInputJoyConfig - -DECLARE_INTERFACE_(IDirectInputJoyConfig, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputJoyConfig methods ***/ - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(SendNotify)(THIS) PURE; - STDMETHOD(EnumTypes)(THIS_ LPDIJOYTYPECALLBACK,LPVOID) PURE; - STDMETHOD(GetTypeInfo)(THIS_ LPCWSTR,LPDIJOYTYPEINFO,DWORD) PURE; - STDMETHOD(SetTypeInfo)(THIS_ LPCWSTR,LPCDIJOYTYPEINFO,DWORD) PURE; - STDMETHOD(DeleteType)(THIS_ LPCWSTR) PURE; - STDMETHOD(GetConfig)(THIS_ UINT,LPDIJOYCONFIG,DWORD) PURE; - STDMETHOD(SetConfig)(THIS_ UINT,LPCDIJOYCONFIG,DWORD) PURE; - STDMETHOD(DeleteConfig)(THIS_ UINT) PURE; - STDMETHOD(GetUserValues)(THIS_ LPDIJOYUSERVALUES,DWORD) PURE; - STDMETHOD(SetUserValues)(THIS_ LPCDIJOYUSERVALUES,DWORD) PURE; - STDMETHOD(AddNewHardware)(THIS_ HWND,REFGUID) PURE; - STDMETHOD(OpenTypeKey)(THIS_ LPCWSTR,DWORD,PHKEY) PURE; - STDMETHOD(OpenConfigKey)(THIS_ UINT,DWORD,PHKEY) PURE; -}; - -typedef struct IDirectInputJoyConfig *LPDIRECTINPUTJOYCONFIG; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInputJoyConfig_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputJoyConfig_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputJoyConfig_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInputJoyConfig_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputJoyConfig_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputJoyConfig_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputJoyConfig_SendNotify(p) (p)->lpVtbl->SendNotify(p) -#define IDirectInputJoyConfig_EnumTypes(p,a,b) (p)->lpVtbl->EnumTypes(p,a,b) -#define IDirectInputJoyConfig_GetTypeInfo(p,a,b,c) (p)->lpVtbl->GetTypeInfo(p,a,b,c) -#define IDirectInputJoyConfig_SetTypeInfo(p,a,b,c) (p)->lpVtbl->SetTypeInfo(p,a,b,c) -#define IDirectInputJoyConfig_DeleteType(p,a) (p)->lpVtbl->DeleteType(p,a) -#define IDirectInputJoyConfig_GetConfig(p,a,b,c) (p)->lpVtbl->GetConfig(p,a,b,c) -#define IDirectInputJoyConfig_SetConfig(p,a,b,c) (p)->lpVtbl->SetConfig(p,a,b,c) -#define IDirectInputJoyConfig_DeleteConfig(p,a) (p)->lpVtbl->DeleteConfig(p,a) -#define IDirectInputJoyConfig_GetUserValues(p,a,b) (p)->lpVtbl->GetUserValues(p,a,b) -#define IDirectInputJoyConfig_SetUserValues(p,a,b) (p)->lpVtbl->SetUserValues(p,a,b) -#define IDirectInputJoyConfig_AddNewHardware(p,a,b) (p)->lpVtbl->AddNewHardware(p,a,b) -#define IDirectInputJoyConfig_OpenTypeKey(p,a,b,c) (p)->lpVtbl->OpenTypeKey(p,a,b,c) -#define IDirectInputJoyConfig_OpenConfigKey(p,a,b,c) (p)->lpVtbl->OpenConfigKey(p,a,b,c) -#else -#define IDirectInputJoyConfig_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputJoyConfig_AddRef(p) (p)->AddRef() -#define IDirectInputJoyConfig_Release(p) (p)->Release() -#define IDirectInputJoyConfig_Acquire(p) (p)->Acquire() -#define IDirectInputJoyConfig_Unacquire(p) (p)->Unacquire() -#define IDirectInputJoyConfig_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputJoyConfig_SendNotify(p) (p)->SendNotify() -#define IDirectInputJoyConfig_EnumTypes(p,a,b) (p)->EnumTypes(a,b) -#define IDirectInputJoyConfig_GetTypeInfo(p,a,b,c) (p)->GetTypeInfo(a,b,c) -#define IDirectInputJoyConfig_SetTypeInfo(p,a,b,c) (p)->SetTypeInfo(a,b,c) -#define IDirectInputJoyConfig_DeleteType(p,a) (p)->DeleteType(a) -#define IDirectInputJoyConfig_GetConfig(p,a,b,c) (p)->GetConfig(a,b,c) -#define IDirectInputJoyConfig_SetConfig(p,a,b,c) (p)->SetConfig(a,b,c) -#define IDirectInputJoyConfig_DeleteConfig(p,a) (p)->DeleteConfig(a) -#define IDirectInputJoyConfig_GetUserValues(p,a,b) (p)->GetUserValues(a,b) -#define IDirectInputJoyConfig_SetUserValues(p,a,b) (p)->SetUserValues(a,b) -#define IDirectInputJoyConfig_AddNewHardware(p,a,b) (p)->AddNewHardware(a,b) -#define IDirectInputJoyConfig_OpenTypeKey(p,a,b,c) (p)->OpenTypeKey(a,b,c) -#define IDirectInputJoyConfig_OpenConfigKey(p,a,b,c) (p)->OpenConfigKey(a,b,c) -#endif - -#endif /* DIJ_RINGZERO */ - -#if(DIRECTINPUT_VERSION >= 0x0800) - -#ifndef DIJ_RINGZERO - -#undef INTERFACE -#define INTERFACE IDirectInputJoyConfig8 - -DECLARE_INTERFACE_(IDirectInputJoyConfig8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputJoyConfig8 methods ***/ - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(SendNotify)(THIS) PURE; - STDMETHOD(EnumTypes)(THIS_ LPDIJOYTYPECALLBACK,LPVOID) PURE; - STDMETHOD(GetTypeInfo)(THIS_ LPCWSTR,LPDIJOYTYPEINFO,DWORD) PURE; - STDMETHOD(SetTypeInfo)(THIS_ LPCWSTR,LPCDIJOYTYPEINFO,DWORD,LPWSTR) PURE; - STDMETHOD(DeleteType)(THIS_ LPCWSTR) PURE; - STDMETHOD(GetConfig)(THIS_ UINT,LPDIJOYCONFIG,DWORD) PURE; - STDMETHOD(SetConfig)(THIS_ UINT,LPCDIJOYCONFIG,DWORD) PURE; - STDMETHOD(DeleteConfig)(THIS_ UINT) PURE; - STDMETHOD(GetUserValues)(THIS_ LPDIJOYUSERVALUES,DWORD) PURE; - STDMETHOD(SetUserValues)(THIS_ LPCDIJOYUSERVALUES,DWORD) PURE; - STDMETHOD(AddNewHardware)(THIS_ HWND,REFGUID) PURE; - STDMETHOD(OpenTypeKey)(THIS_ LPCWSTR,DWORD,PHKEY) PURE; - STDMETHOD(OpenAppStatusKey)(THIS_ PHKEY) PURE; -}; - -typedef struct IDirectInputJoyConfig8 *LPDIRECTINPUTJOYCONFIG8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInputJoyConfig8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputJoyConfig8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputJoyConfig8_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInputJoyConfig8_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputJoyConfig8_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputJoyConfig8_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputJoyConfig8_SendNotify(p) (p)->lpVtbl->SendNotify(p) -#define IDirectInputJoyConfig8_EnumTypes(p,a,b) (p)->lpVtbl->EnumTypes(p,a,b) -#define IDirectInputJoyConfig8_GetTypeInfo(p,a,b,c) (p)->lpVtbl->GetTypeInfo(p,a,b,c) -#define IDirectInputJoyConfig8_SetTypeInfo(p,a,b,c,d) (p)->lpVtbl->SetTypeInfo(p,a,b,c,d) -#define IDirectInputJoyConfig8_DeleteType(p,a) (p)->lpVtbl->DeleteType(p,a) -#define IDirectInputJoyConfig8_GetConfig(p,a,b,c) (p)->lpVtbl->GetConfig(p,a,b,c) -#define IDirectInputJoyConfig8_SetConfig(p,a,b,c) (p)->lpVtbl->SetConfig(p,a,b,c) -#define IDirectInputJoyConfig8_DeleteConfig(p,a) (p)->lpVtbl->DeleteConfig(p,a) -#define IDirectInputJoyConfig8_GetUserValues(p,a,b) (p)->lpVtbl->GetUserValues(p,a,b) -#define IDirectInputJoyConfig8_SetUserValues(p,a,b) (p)->lpVtbl->SetUserValues(p,a,b) -#define IDirectInputJoyConfig8_AddNewHardware(p,a,b) (p)->lpVtbl->AddNewHardware(p,a,b) -#define IDirectInputJoyConfig8_OpenTypeKey(p,a,b,c) (p)->lpVtbl->OpenTypeKey(p,a,b,c) -#define IDirectInputJoyConfig8_OpenAppStatusKey(p,a) (p)->lpVtbl->OpenAppStatusKey(p,a) -#else -#define IDirectInputJoyConfig8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputJoyConfig8_AddRef(p) (p)->AddRef() -#define IDirectInputJoyConfig8_Release(p) (p)->Release() -#define IDirectInputJoyConfig8_Acquire(p) (p)->Acquire() -#define IDirectInputJoyConfig8_Unacquire(p) (p)->Unacquire() -#define IDirectInputJoyConfig8_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputJoyConfig8_SendNotify(p) (p)->SendNotify() -#define IDirectInputJoyConfig8_EnumTypes(p,a,b) (p)->EnumTypes(a,b) -#define IDirectInputJoyConfig8_GetTypeInfo(p,a,b,c) (p)->GetTypeInfo(a,b,c) -#define IDirectInputJoyConfig8_SetTypeInfo(p,a,b,c,d) (p)->SetTypeInfo(a,b,c,d) -#define IDirectInputJoyConfig8_DeleteType(p,a) (p)->DeleteType(a) -#define IDirectInputJoyConfig8_GetConfig(p,a,b,c) (p)->GetConfig(a,b,c) -#define IDirectInputJoyConfig8_SetConfig(p,a,b,c) (p)->SetConfig(a,b,c) -#define IDirectInputJoyConfig8_DeleteConfig(p,a) (p)->DeleteConfig(a) -#define IDirectInputJoyConfig8_GetUserValues(p,a,b) (p)->GetUserValues(a,b) -#define IDirectInputJoyConfig8_SetUserValues(p,a,b) (p)->SetUserValues(a,b) -#define IDirectInputJoyConfig8_AddNewHardware(p,a,b) (p)->AddNewHardware(a,b) -#define IDirectInputJoyConfig8_OpenTypeKey(p,a,b,c) (p)->OpenTypeKey(a,b,c) -#define IDirectInputJoyConfig8_OpenAppStatusKey(p,a) (p)->OpenAppStatusKey(a) -#endif - -#endif /* DIJ_RINGZERO */ - -/**************************************************************************** - * - * Notification Messages - * - ****************************************************************************/ - -/* RegisterWindowMessage with this to get DirectInput notification messages */ -#define DIRECTINPUT_NOTIFICATION_MSGSTRINGA "DIRECTINPUT_NOTIFICATION_MSGSTRING" -#define DIRECTINPUT_NOTIFICATION_MSGSTRINGW L"DIRECTINPUT_NOTIFICATION_MSGSTRING" - -#ifdef UNICODE -#define DIRECTINPUT_NOTIFICATION_MSGSTRING DIRECTINPUT_NOTIFICATION_MSGSTRINGW -#else -#define DIRECTINPUT_NOTIFICATION_MSGSTRING DIRECTINPUT_NOTIFICATION_MSGSTRINGA -#endif - -#define DIMSGWP_NEWAPPSTART 0x00000001 -#define DIMSGWP_DX8APPSTART 0x00000002 -#define DIMSGWP_DX8MAPPERAPPSTART 0x00000003 - -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -#define DIAPPIDFLAG_NOTIME 0x00000001 -#define DIAPPIDFLAG_NOSIZE 0x00000002 - -#define DIRECTINPUT_REGSTR_VAL_APPIDFLAGA "AppIdFlag" -#define DIRECTINPUT_REGSTR_KEY_LASTAPPA "MostRecentApplication" -#define DIRECTINPUT_REGSTR_KEY_LASTMAPAPPA "MostRecentMapperApplication" -#define DIRECTINPUT_REGSTR_VAL_VERSIONA "Version" -#define DIRECTINPUT_REGSTR_VAL_NAMEA "Name" -#define DIRECTINPUT_REGSTR_VAL_IDA "Id" -#define DIRECTINPUT_REGSTR_VAL_MAPPERA "UsesMapper" -#define DIRECTINPUT_REGSTR_VAL_LASTSTARTA "MostRecentStart" - -#define DIRECTINPUT_REGSTR_VAL_APPIDFLAGW L"AppIdFlag" -#define DIRECTINPUT_REGSTR_KEY_LASTAPPW L"MostRecentApplication" -#define DIRECTINPUT_REGSTR_KEY_LASTMAPAPPW L"MostRecentMapperApplication" -#define DIRECTINPUT_REGSTR_VAL_VERSIONW L"Version" -#define DIRECTINPUT_REGSTR_VAL_NAMEW L"Name" -#define DIRECTINPUT_REGSTR_VAL_IDW L"Id" -#define DIRECTINPUT_REGSTR_VAL_MAPPERW L"UsesMapper" -#define DIRECTINPUT_REGSTR_VAL_LASTSTARTW L"MostRecentStart" - -#ifdef UNICODE -#define DIRECTINPUT_REGSTR_VAL_APPIDFLAG DIRECTINPUT_REGSTR_VAL_APPIDFLAGW -#define DIRECTINPUT_REGSTR_KEY_LASTAPP DIRECTINPUT_REGSTR_KEY_LASTAPPW -#define DIRECTINPUT_REGSTR_KEY_LASTMAPAPP DIRECTINPUT_REGSTR_KEY_LASTMAPAPPW -#define DIRECTINPUT_REGSTR_VAL_VERSION DIRECTINPUT_REGSTR_VAL_VERSIONW -#define DIRECTINPUT_REGSTR_VAL_NAME DIRECTINPUT_REGSTR_VAL_NAMEW -#define DIRECTINPUT_REGSTR_VAL_ID DIRECTINPUT_REGSTR_VAL_IDW -#define DIRECTINPUT_REGSTR_VAL_MAPPER DIRECTINPUT_REGSTR_VAL_MAPPERW -#define DIRECTINPUT_REGSTR_VAL_LASTSTART DIRECTINPUT_REGSTR_VAL_LASTSTARTW -#else -#define DIRECTINPUT_REGSTR_VAL_APPIDFLAG DIRECTINPUT_REGSTR_VAL_APPIDFLAGA -#define DIRECTINPUT_REGSTR_KEY_LASTAPP DIRECTINPUT_REGSTR_KEY_LASTAPPA -#define DIRECTINPUT_REGSTR_KEY_LASTMAPAPP DIRECTINPUT_REGSTR_KEY_LASTMAPAPPA -#define DIRECTINPUT_REGSTR_VAL_VERSION DIRECTINPUT_REGSTR_VAL_VERSIONA -#define DIRECTINPUT_REGSTR_VAL_NAME DIRECTINPUT_REGSTR_VAL_NAMEA -#define DIRECTINPUT_REGSTR_VAL_ID DIRECTINPUT_REGSTR_VAL_IDA -#define DIRECTINPUT_REGSTR_VAL_MAPPER DIRECTINPUT_REGSTR_VAL_MAPPERA -#define DIRECTINPUT_REGSTR_VAL_LASTSTART DIRECTINPUT_REGSTR_VAL_LASTSTARTA -#endif - - -/**************************************************************************** - * - * Return Codes - * - ****************************************************************************/ - -#define DIERR_NOMOREITEMS \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NO_MORE_ITEMS) - -/* - * Device driver-specific codes. - */ - -#define DIERR_DRIVERFIRST 0x80040300L -#define DIERR_DRIVERLAST 0x800403FFL - -/* - * Unless the specific driver has been precisely identified, no meaning - * should be attributed to these values other than that the driver - * originated the error. However, to illustrate the types of error that - * may be causing the failure, the PID force feedback driver distributed - * with DirectX 7 could return the following errors: - * - * DIERR_DRIVERFIRST + 1 - * The requested usage was not found. - * DIERR_DRIVERFIRST + 2 - * The parameter block couldn't be downloaded to the device. - * DIERR_DRIVERFIRST + 3 - * PID initialization failed. - * DIERR_DRIVERFIRST + 4 - * The provided values couldn't be scaled. - */ - - -/* - * Device installer errors. - */ - -/* - * Registry entry or DLL for class installer invalid - * or class installer not found. - */ -#define DIERR_INVALIDCLASSINSTALLER 0x80040400L - -/* - * The user cancelled the install operation. - */ -#define DIERR_CANCELLED 0x80040401L - -/* - * The INF file for the selected device could not be - * found or is invalid or is damaged. - */ -#define DIERR_BADINF 0x80040402L - -/**************************************************************************** - * - * Map files - * - ****************************************************************************/ - -/* - * Delete particular data from default map file. - */ -#define DIDIFT_DELETE 0x01000000 - -#ifdef __cplusplus -}; -#endif - -#endif /* __DINPUTD_INCLUDED__ */ +/**************************************************************************** + * + * Copyright (C) 1995-2000 Microsoft Corporation. All Rights Reserved. + * + * File: dinputd.h + * Content: DirectInput include file for device driver implementors + * + ****************************************************************************/ +#ifndef __DINPUTD_INCLUDED__ +#define __DINPUTD_INCLUDED__ + +#ifndef DIRECTINPUT_VERSION +#define DIRECTINPUT_VERSION 0x0800 +#pragma message(__FILE__ ": DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800") +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/**************************************************************************** + * + * Interfaces + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +DEFINE_GUID(IID_IDirectInputEffectDriver, 0x02538130,0x898F,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(IID_IDirectInputJoyConfig, 0x1DE12AB1,0xC9F5,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputPIDDriver, 0xEEC6993A,0xB3FD,0x11D2,0xA9,0x16,0x00,0xC0,0x4F,0xB9,0x86,0x38); + +DEFINE_GUID(IID_IDirectInputJoyConfig8, 0xeb0d7dfa,0x1990,0x4f27,0xb4,0xd6,0xed,0xf2,0xee,0xc4,0xa4,0x4c); + +#endif /* DIJ_RINGZERO */ + + +/**************************************************************************** + * + * IDirectInputEffectDriver + * + ****************************************************************************/ + +typedef struct DIOBJECTATTRIBUTES { + DWORD dwFlags; + WORD wUsagePage; + WORD wUsage; +} DIOBJECTATTRIBUTES, *LPDIOBJECTATTRIBUTES; +typedef const DIOBJECTATTRIBUTES *LPCDIOBJECTATTRIBUTES; + +typedef struct DIFFOBJECTATTRIBUTES { + DWORD dwFFMaxForce; + DWORD dwFFForceResolution; +} DIFFOBJECTATTRIBUTES, *LPDIFFOBJECTATTRIBUTES; +typedef const DIFFOBJECTATTRIBUTES *LPCDIFFOBJECTATTRIBUTES; + +typedef struct DIOBJECTCALIBRATION { + LONG lMin; + LONG lCenter; + LONG lMax; +} DIOBJECTCALIBRATION, *LPDIOBJECTCALIBRATION; +typedef const DIOBJECTCALIBRATION *LPCDIOBJECTCALIBRATION; + +typedef struct DIPOVCALIBRATION { + LONG lMin[5]; + LONG lMax[5]; +} DIPOVCALIBRATION, *LPDIPOVCALIBRATION; +typedef const DIPOVCALIBRATION *LPCDIPOVCALIBRATION; + +typedef struct DIEFFECTATTRIBUTES { + DWORD dwEffectId; + DWORD dwEffType; + DWORD dwStaticParams; + DWORD dwDynamicParams; + DWORD dwCoords; +} DIEFFECTATTRIBUTES, *LPDIEFFECTATTRIBUTES; +typedef const DIEFFECTATTRIBUTES *LPCDIEFFECTATTRIBUTES; + +typedef struct DIFFDEVICEATTRIBUTES { + DWORD dwFlags; + DWORD dwFFSamplePeriod; + DWORD dwFFMinTimeResolution; +} DIFFDEVICEATTRIBUTES, *LPDIFFDEVICEATTRIBUTES; +typedef const DIFFDEVICEATTRIBUTES *LPCDIFFDEVICEATTRIBUTES; + +typedef struct DIDRIVERVERSIONS { + DWORD dwSize; + DWORD dwFirmwareRevision; + DWORD dwHardwareRevision; + DWORD dwFFDriverVersion; +} DIDRIVERVERSIONS, *LPDIDRIVERVERSIONS; +typedef const DIDRIVERVERSIONS *LPCDIDRIVERVERSIONS; + +typedef struct DIDEVICESTATE { + DWORD dwSize; + DWORD dwState; + DWORD dwLoad; +} DIDEVICESTATE, *LPDIDEVICESTATE; + +#define DEV_STS_EFFECT_RUNNING DIEGES_PLAYING + +#ifndef DIJ_RINGZERO + +typedef struct DIHIDFFINITINFO { + DWORD dwSize; + LPWSTR pwszDeviceInterface; + GUID GuidInstance; +} DIHIDFFINITINFO, *LPDIHIDFFINITINFO; + +#undef INTERFACE +#define INTERFACE IDirectInputEffectDriver + +DECLARE_INTERFACE_(IDirectInputEffectDriver, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputEffectDriver methods ***/ + STDMETHOD(DeviceID)(THIS_ DWORD,DWORD,DWORD,DWORD,LPVOID) PURE; + STDMETHOD(GetVersions)(THIS_ LPDIDRIVERVERSIONS) PURE; + STDMETHOD(Escape)(THIS_ DWORD,DWORD,LPDIEFFESCAPE) PURE; + STDMETHOD(SetGain)(THIS_ DWORD,DWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD,DWORD) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ DWORD,LPDIDEVICESTATE) PURE; + STDMETHOD(DownloadEffect)(THIS_ DWORD,DWORD,LPDWORD,LPCDIEFFECT,DWORD) PURE; + STDMETHOD(DestroyEffect)(THIS_ DWORD,DWORD) PURE; + STDMETHOD(StartEffect)(THIS_ DWORD,DWORD,DWORD,DWORD) PURE; + STDMETHOD(StopEffect)(THIS_ DWORD,DWORD) PURE; + STDMETHOD(GetEffectStatus)(THIS_ DWORD,DWORD,LPDWORD) PURE; +}; + +typedef struct IDirectInputEffectDriver *LPDIRECTINPUTEFFECTDRIVER; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputEffectDriver_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputEffectDriver_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputEffectDriver_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputEffectDriver_DeviceID(p,a,b,c,d,e) (p)->lpVtbl->DeviceID(p,a,b,c,d,e) +#define IDirectInputEffectDriver_GetVersions(p,a) (p)->lpVtbl->GetVersions(p,a) +#define IDirectInputEffectDriver_Escape(p,a,b,c) (p)->lpVtbl->Escape(p,a,b,c) +#define IDirectInputEffectDriver_SetGain(p,a,b) (p)->lpVtbl->SetGain(p,a,b) +#define IDirectInputEffectDriver_SendForceFeedbackCommand(p,a,b) (p)->lpVtbl->SendForceFeedbackCommand(p,a,b) +#define IDirectInputEffectDriver_GetForceFeedbackState(p,a,b) (p)->lpVtbl->GetForceFeedbackState(p,a,b) +#define IDirectInputEffectDriver_DownloadEffect(p,a,b,c,d,e) (p)->lpVtbl->DownloadEffect(p,a,b,c,d,e) +#define IDirectInputEffectDriver_DestroyEffect(p,a,b) (p)->lpVtbl->DestroyEffect(p,a,b) +#define IDirectInputEffectDriver_StartEffect(p,a,b,c,d) (p)->lpVtbl->StartEffect(p,a,b,c,d) +#define IDirectInputEffectDriver_StopEffect(p,a,b) (p)->lpVtbl->StopEffect(p,a,b) +#define IDirectInputEffectDriver_GetEffectStatus(p,a,b,c) (p)->lpVtbl->GetEffectStatus(p,a,b,c) +#else +#define IDirectInputEffectDriver_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputEffectDriver_AddRef(p) (p)->AddRef() +#define IDirectInputEffectDriver_Release(p) (p)->Release() +#define IDirectInputEffectDriver_DeviceID(p,a,b,c,d,e) (p)->DeviceID(a,b,c,d,e) +#define IDirectInputEffectDriver_GetVersions(p,a) (p)->GetVersions(a) +#define IDirectInputEffectDriver_Escape(p,a,b,c) (p)->Escape(a,b,c) +#define IDirectInputEffectDriver_SetGain(p,a,b) (p)->SetGain(a,b) +#define IDirectInputEffectDriver_SendForceFeedbackCommand(p,a,b) (p)->SendForceFeedbackCommand(a,b) +#define IDirectInputEffectDriver_GetForceFeedbackState(p,a,b) (p)->GetForceFeedbackState(a,b) +#define IDirectInputEffectDriver_DownloadEffect(p,a,b,c,d,e) (p)->DownloadEffect(a,b,c,d,e) +#define IDirectInputEffectDriver_DestroyEffect(p,a,b) (p)->DestroyEffect(a,b) +#define IDirectInputEffectDriver_StartEffect(p,a,b,c,d) (p)->StartEffect(a,b,c,d) +#define IDirectInputEffectDriver_StopEffect(p,a,b) (p)->StopEffect(a,b) +#define IDirectInputEffectDriver_GetEffectStatus(p,a,b,c) (p)->GetEffectStatus(a,b,c) +#endif + + +#endif /* DIJ_RINGZERO */ + + +/**************************************************************************** + * + * IDirectInputJoyConfig + * + ****************************************************************************/ + +/**************************************************************************** + * + * Definitions copied from the DDK + * + ****************************************************************************/ + +#ifndef JOY_HW_NONE + +/* pre-defined joystick types */ +#define JOY_HW_NONE 0 +#define JOY_HW_CUSTOM 1 +#define JOY_HW_2A_2B_GENERIC 2 +#define JOY_HW_2A_4B_GENERIC 3 +#define JOY_HW_2B_GAMEPAD 4 +#define JOY_HW_2B_FLIGHTYOKE 5 +#define JOY_HW_2B_FLIGHTYOKETHROTTLE 6 +#define JOY_HW_3A_2B_GENERIC 7 +#define JOY_HW_3A_4B_GENERIC 8 +#define JOY_HW_4B_GAMEPAD 9 +#define JOY_HW_4B_FLIGHTYOKE 10 +#define JOY_HW_4B_FLIGHTYOKETHROTTLE 11 +#define JOY_HW_TWO_2A_2B_WITH_Y 12 +#define JOY_HW_LASTENTRY 13 + + +/* calibration flags */ +#define JOY_ISCAL_XY 0x00000001l /* XY are calibrated */ +#define JOY_ISCAL_Z 0x00000002l /* Z is calibrated */ +#define JOY_ISCAL_R 0x00000004l /* R is calibrated */ +#define JOY_ISCAL_U 0x00000008l /* U is calibrated */ +#define JOY_ISCAL_V 0x00000010l /* V is calibrated */ +#define JOY_ISCAL_POV 0x00000020l /* POV is calibrated */ + +/* point of view constants */ +#define JOY_POV_NUMDIRS 4 +#define JOY_POVVAL_FORWARD 0 +#define JOY_POVVAL_BACKWARD 1 +#define JOY_POVVAL_LEFT 2 +#define JOY_POVVAL_RIGHT 3 + +/* Specific settings for joystick hardware */ +#define JOY_HWS_HASZ 0x00000001l /* has Z info? */ +#define JOY_HWS_HASPOV 0x00000002l /* point of view hat present */ +#define JOY_HWS_POVISBUTTONCOMBOS 0x00000004l /* pov done through combo of buttons */ +#define JOY_HWS_POVISPOLL 0x00000008l /* pov done through polling */ +#define JOY_HWS_ISYOKE 0x00000010l /* joystick is a flight yoke */ +#define JOY_HWS_ISGAMEPAD 0x00000020l /* joystick is a game pad */ +#define JOY_HWS_ISCARCTRL 0x00000040l /* joystick is a car controller */ +/* X defaults to J1 X axis */ +#define JOY_HWS_XISJ1Y 0x00000080l /* X is on J1 Y axis */ +#define JOY_HWS_XISJ2X 0x00000100l /* X is on J2 X axis */ +#define JOY_HWS_XISJ2Y 0x00000200l /* X is on J2 Y axis */ +/* Y defaults to J1 Y axis */ +#define JOY_HWS_YISJ1X 0x00000400l /* Y is on J1 X axis */ +#define JOY_HWS_YISJ2X 0x00000800l /* Y is on J2 X axis */ +#define JOY_HWS_YISJ2Y 0x00001000l /* Y is on J2 Y axis */ +/* Z defaults to J2 Y axis */ +#define JOY_HWS_ZISJ1X 0x00002000l /* Z is on J1 X axis */ +#define JOY_HWS_ZISJ1Y 0x00004000l /* Z is on J1 Y axis */ +#define JOY_HWS_ZISJ2X 0x00008000l /* Z is on J2 X axis */ +/* POV defaults to J2 Y axis, if it is not button based */ +#define JOY_HWS_POVISJ1X 0x00010000l /* pov done through J1 X axis */ +#define JOY_HWS_POVISJ1Y 0x00020000l /* pov done through J1 Y axis */ +#define JOY_HWS_POVISJ2X 0x00040000l /* pov done through J2 X axis */ +/* R defaults to J2 X axis */ +#define JOY_HWS_HASR 0x00080000l /* has R (4th axis) info */ +#define JOY_HWS_RISJ1X 0x00100000l /* R done through J1 X axis */ +#define JOY_HWS_RISJ1Y 0x00200000l /* R done through J1 Y axis */ +#define JOY_HWS_RISJ2Y 0x00400000l /* R done through J2 X axis */ +/* U & V for future hardware */ +#define JOY_HWS_HASU 0x00800000l /* has U (5th axis) info */ +#define JOY_HWS_HASV 0x01000000l /* has V (6th axis) info */ + +/* Usage settings */ +#define JOY_US_HASRUDDER 0x00000001l /* joystick configured with rudder */ +#define JOY_US_PRESENT 0x00000002l /* is joystick actually present? */ +#define JOY_US_ISOEM 0x00000004l /* joystick is an OEM defined type */ + +/* reserved for future use -> as link to next possible dword */ +#define JOY_US_RESERVED 0x80000000l /* reserved */ + + +/* Settings for TypeInfo Flags1 */ +#define JOYTYPE_ZEROGAMEENUMOEMDATA 0x00000001l /* Zero GameEnum's OEM data field */ +#define JOYTYPE_NOAUTODETECTGAMEPORT 0x00000002l /* Device does not support Autodetect gameport*/ +#define JOYTYPE_NOHIDDIRECT 0x00000004l /* Do not use HID directly for this device */ +#define JOYTYPE_ANALOGCOMPAT 0x00000008l /* Expose the analog compatible ID */ +#define JOYTYPE_DEFAULTPROPSHEET 0x80000000l /* CPL overrides custom property sheet */ + +/* Settings for TypeInfo Flags2 */ +#define JOYTYPE_DEVICEHIDE 0x00010000l /* Hide unclassified devices */ +#define JOYTYPE_MOUSEHIDE 0x00020000l /* Hide mice */ +#define JOYTYPE_KEYBHIDE 0x00040000l /* Hide keyboards */ +#define JOYTYPE_GAMEHIDE 0x00080000l /* Hide game controllers */ +#define JOYTYPE_HIDEACTIVE 0x00100000l /* Hide flags are active */ +#define JOYTYPE_INFOMASK 0x00E00000l /* Mask for type specific info */ +#define JOYTYPE_INFODEFAULT 0x00000000l /* Use default axis mappings */ +#define JOYTYPE_INFOYYPEDALS 0x00200000l /* Use Y as a combined pedals axis */ +#define JOYTYPE_INFOZYPEDALS 0x00400000l /* Use Z for accelerate, Y for brake */ +#define JOYTYPE_INFOYRPEDALS 0x00600000l /* Use Y for accelerate, R for brake */ +#define JOYTYPE_INFOZRPEDALS 0x00800000l /* Use Z for accelerate, R for brake */ +#define JOYTYPE_INFOZISSLIDER 0x00200000l /* Use Z as a slider */ +#define JOYTYPE_INFOZISZ 0x00400000l /* Use Z as Z axis */ +#define JOYTYPE_ENABLEINPUTREPORT 0x01000000l /* Enable initial input reports */ + +/* struct for storing x,y, z, and rudder values */ +typedef struct joypos_tag { + DWORD dwX; + DWORD dwY; + DWORD dwZ; + DWORD dwR; + DWORD dwU; + DWORD dwV; +} JOYPOS, FAR *LPJOYPOS; + +/* struct for storing ranges */ +typedef struct joyrange_tag { + JOYPOS jpMin; + JOYPOS jpMax; + JOYPOS jpCenter; +} JOYRANGE,FAR *LPJOYRANGE; + +/* + * dwTimeout - value at which to timeout joystick polling + * jrvRanges - range of values app wants returned for axes + * jpDeadZone - area around center to be considered + * as "dead". specified as a percentage + * (0-100). Only X & Y handled by system driver + */ +typedef struct joyreguservalues_tag { + DWORD dwTimeOut; + JOYRANGE jrvRanges; + JOYPOS jpDeadZone; +} JOYREGUSERVALUES, FAR *LPJOYREGUSERVALUES; + +typedef struct joyreghwsettings_tag { + DWORD dwFlags; + DWORD dwNumButtons; +} JOYREGHWSETTINGS, FAR *LPJOYHWSETTINGS; + +/* range of values returned by the hardware (filled in by calibration) */ +/* + * jrvHardware - values returned by hardware + * dwPOVValues - POV values returned by hardware + * dwCalFlags - what has been calibrated + */ +typedef struct joyreghwvalues_tag { + JOYRANGE jrvHardware; + DWORD dwPOVValues[JOY_POV_NUMDIRS]; + DWORD dwCalFlags; +} JOYREGHWVALUES, FAR *LPJOYREGHWVALUES; + +/* hardware configuration */ +/* + * hws - hardware settings + * dwUsageSettings - usage settings + * hwv - values returned by hardware + * dwType - type of joystick + * dwReserved - reserved for OEM drivers + */ +typedef struct joyreghwconfig_tag { + JOYREGHWSETTINGS hws; + DWORD dwUsageSettings; + JOYREGHWVALUES hwv; + DWORD dwType; + DWORD dwReserved; +} JOYREGHWCONFIG, FAR *LPJOYREGHWCONFIG; + +/* joystick calibration info structure */ +typedef struct joycalibrate_tag { + UINT wXbase; + UINT wXdelta; + UINT wYbase; + UINT wYdelta; + UINT wZbase; + UINT wZdelta; +} JOYCALIBRATE; +typedef JOYCALIBRATE FAR *LPJOYCALIBRATE; + +#endif + +#ifndef DIJ_RINGZERO + +#define MAX_JOYSTRING 256 +typedef BOOL (FAR PASCAL * LPDIJOYTYPECALLBACK)(LPCWSTR, LPVOID); + +#ifndef MAX_JOYSTICKOEMVXDNAME +#define MAX_JOYSTICKOEMVXDNAME 260 +#endif + +#define DITC_REGHWSETTINGS 0x00000001 +#define DITC_CLSIDCONFIG 0x00000002 +#define DITC_DISPLAYNAME 0x00000004 +#define DITC_CALLOUT 0x00000008 +#define DITC_HARDWAREID 0x00000010 +#define DITC_FLAGS1 0x00000020 +#define DITC_FLAGS2 0x00000040 +#define DITC_MAPFILE 0x00000080 + + + +/* This structure is defined for DirectX 5.0 compatibility */ + +typedef struct DIJOYTYPEINFO_DX5 { + DWORD dwSize; + JOYREGHWSETTINGS hws; + CLSID clsidConfig; + WCHAR wszDisplayName[MAX_JOYSTRING]; + WCHAR wszCallout[MAX_JOYSTICKOEMVXDNAME]; +} DIJOYTYPEINFO_DX5, *LPDIJOYTYPEINFO_DX5; +typedef const DIJOYTYPEINFO_DX5 *LPCDIJOYTYPEINFO_DX5; + +/* This structure is defined for DirectX 6.1 compatibility */ +typedef struct DIJOYTYPEINFO_DX6 { + DWORD dwSize; + JOYREGHWSETTINGS hws; + CLSID clsidConfig; + WCHAR wszDisplayName[MAX_JOYSTRING]; + WCHAR wszCallout[MAX_JOYSTICKOEMVXDNAME]; + WCHAR wszHardwareId[MAX_JOYSTRING]; + DWORD dwFlags1; +} DIJOYTYPEINFO_DX6, *LPDIJOYTYPEINFO_DX6; +typedef const DIJOYTYPEINFO_DX6 *LPCDIJOYTYPEINFO_DX6; + +typedef struct DIJOYTYPEINFO { + DWORD dwSize; + JOYREGHWSETTINGS hws; + CLSID clsidConfig; + WCHAR wszDisplayName[MAX_JOYSTRING]; + WCHAR wszCallout[MAX_JOYSTICKOEMVXDNAME]; +#if(DIRECTINPUT_VERSION >= 0x05b2) + WCHAR wszHardwareId[MAX_JOYSTRING]; + DWORD dwFlags1; +#if(DIRECTINPUT_VERSION >= 0x0800) + DWORD dwFlags2; + WCHAR wszMapFile[MAX_JOYSTRING]; +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ +#endif /* DIRECTINPUT_VERSION >= 0x05b2 */ +} DIJOYTYPEINFO, *LPDIJOYTYPEINFO; +typedef const DIJOYTYPEINFO *LPCDIJOYTYPEINFO; +#define DIJC_GUIDINSTANCE 0x00000001 +#define DIJC_REGHWCONFIGTYPE 0x00000002 +#define DIJC_GAIN 0x00000004 +#define DIJC_CALLOUT 0x00000008 +#define DIJC_WDMGAMEPORT 0x00000010 + +/* This structure is defined for DirectX 5.0 compatibility */ + +typedef struct DIJOYCONFIG_DX5 { + DWORD dwSize; + GUID guidInstance; + JOYREGHWCONFIG hwc; + DWORD dwGain; + WCHAR wszType[MAX_JOYSTRING]; + WCHAR wszCallout[MAX_JOYSTRING]; +} DIJOYCONFIG_DX5, *LPDIJOYCONFIG_DX5; +typedef const DIJOYCONFIG_DX5 *LPCDIJOYCONFIG_DX5; + +typedef struct DIJOYCONFIG { + DWORD dwSize; + GUID guidInstance; + JOYREGHWCONFIG hwc; + DWORD dwGain; + WCHAR wszType[MAX_JOYSTRING]; + WCHAR wszCallout[MAX_JOYSTRING]; +#if(DIRECTINPUT_VERSION >= 0x05b2) + GUID guidGameport; +#endif /* DIRECTINPUT_VERSION >= 0x05b2 */ + } DIJOYCONFIG, *LPDIJOYCONFIG; +typedef const DIJOYCONFIG *LPCDIJOYCONFIG; + + +#define DIJU_USERVALUES 0x00000001 +#define DIJU_GLOBALDRIVER 0x00000002 +#define DIJU_GAMEPORTEMULATOR 0x00000004 + +typedef struct DIJOYUSERVALUES { + DWORD dwSize; + JOYREGUSERVALUES ruv; + WCHAR wszGlobalDriver[MAX_JOYSTRING]; + WCHAR wszGameportEmulator[MAX_JOYSTRING]; +} DIJOYUSERVALUES, *LPDIJOYUSERVALUES; +typedef const DIJOYUSERVALUES *LPCDIJOYUSERVALUES; + +DEFINE_GUID(GUID_KeyboardClass, 0x4D36E96B,0xE325,0x11CE,0xBF,0xC1,0x08,0x00,0x2B,0xE1,0x03,0x18); +DEFINE_GUID(GUID_MediaClass, 0x4D36E96C,0xE325,0x11CE,0xBF,0xC1,0x08,0x00,0x2B,0xE1,0x03,0x18); +DEFINE_GUID(GUID_MouseClass, 0x4D36E96F,0xE325,0x11CE,0xBF,0xC1,0x08,0x00,0x2B,0xE1,0x03,0x18); +DEFINE_GUID(GUID_HIDClass, 0x745A17A0,0x74D3,0x11D0,0xB6,0xFE,0x00,0xA0,0xC9,0x0F,0x57,0xDA); + +#undef INTERFACE +#define INTERFACE IDirectInputJoyConfig + +DECLARE_INTERFACE_(IDirectInputJoyConfig, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputJoyConfig methods ***/ + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(SendNotify)(THIS) PURE; + STDMETHOD(EnumTypes)(THIS_ LPDIJOYTYPECALLBACK,LPVOID) PURE; + STDMETHOD(GetTypeInfo)(THIS_ LPCWSTR,LPDIJOYTYPEINFO,DWORD) PURE; + STDMETHOD(SetTypeInfo)(THIS_ LPCWSTR,LPCDIJOYTYPEINFO,DWORD) PURE; + STDMETHOD(DeleteType)(THIS_ LPCWSTR) PURE; + STDMETHOD(GetConfig)(THIS_ UINT,LPDIJOYCONFIG,DWORD) PURE; + STDMETHOD(SetConfig)(THIS_ UINT,LPCDIJOYCONFIG,DWORD) PURE; + STDMETHOD(DeleteConfig)(THIS_ UINT) PURE; + STDMETHOD(GetUserValues)(THIS_ LPDIJOYUSERVALUES,DWORD) PURE; + STDMETHOD(SetUserValues)(THIS_ LPCDIJOYUSERVALUES,DWORD) PURE; + STDMETHOD(AddNewHardware)(THIS_ HWND,REFGUID) PURE; + STDMETHOD(OpenTypeKey)(THIS_ LPCWSTR,DWORD,PHKEY) PURE; + STDMETHOD(OpenConfigKey)(THIS_ UINT,DWORD,PHKEY) PURE; +}; + +typedef struct IDirectInputJoyConfig *LPDIRECTINPUTJOYCONFIG; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputJoyConfig_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputJoyConfig_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputJoyConfig_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputJoyConfig_Acquire(p) (p)->lpVtbl->Acquire(p) +#define IDirectInputJoyConfig_Unacquire(p) (p)->lpVtbl->Unacquire(p) +#define IDirectInputJoyConfig_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectInputJoyConfig_SendNotify(p) (p)->lpVtbl->SendNotify(p) +#define IDirectInputJoyConfig_EnumTypes(p,a,b) (p)->lpVtbl->EnumTypes(p,a,b) +#define IDirectInputJoyConfig_GetTypeInfo(p,a,b,c) (p)->lpVtbl->GetTypeInfo(p,a,b,c) +#define IDirectInputJoyConfig_SetTypeInfo(p,a,b,c) (p)->lpVtbl->SetTypeInfo(p,a,b,c) +#define IDirectInputJoyConfig_DeleteType(p,a) (p)->lpVtbl->DeleteType(p,a) +#define IDirectInputJoyConfig_GetConfig(p,a,b,c) (p)->lpVtbl->GetConfig(p,a,b,c) +#define IDirectInputJoyConfig_SetConfig(p,a,b,c) (p)->lpVtbl->SetConfig(p,a,b,c) +#define IDirectInputJoyConfig_DeleteConfig(p,a) (p)->lpVtbl->DeleteConfig(p,a) +#define IDirectInputJoyConfig_GetUserValues(p,a,b) (p)->lpVtbl->GetUserValues(p,a,b) +#define IDirectInputJoyConfig_SetUserValues(p,a,b) (p)->lpVtbl->SetUserValues(p,a,b) +#define IDirectInputJoyConfig_AddNewHardware(p,a,b) (p)->lpVtbl->AddNewHardware(p,a,b) +#define IDirectInputJoyConfig_OpenTypeKey(p,a,b,c) (p)->lpVtbl->OpenTypeKey(p,a,b,c) +#define IDirectInputJoyConfig_OpenConfigKey(p,a,b,c) (p)->lpVtbl->OpenConfigKey(p,a,b,c) +#else +#define IDirectInputJoyConfig_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputJoyConfig_AddRef(p) (p)->AddRef() +#define IDirectInputJoyConfig_Release(p) (p)->Release() +#define IDirectInputJoyConfig_Acquire(p) (p)->Acquire() +#define IDirectInputJoyConfig_Unacquire(p) (p)->Unacquire() +#define IDirectInputJoyConfig_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectInputJoyConfig_SendNotify(p) (p)->SendNotify() +#define IDirectInputJoyConfig_EnumTypes(p,a,b) (p)->EnumTypes(a,b) +#define IDirectInputJoyConfig_GetTypeInfo(p,a,b,c) (p)->GetTypeInfo(a,b,c) +#define IDirectInputJoyConfig_SetTypeInfo(p,a,b,c) (p)->SetTypeInfo(a,b,c) +#define IDirectInputJoyConfig_DeleteType(p,a) (p)->DeleteType(a) +#define IDirectInputJoyConfig_GetConfig(p,a,b,c) (p)->GetConfig(a,b,c) +#define IDirectInputJoyConfig_SetConfig(p,a,b,c) (p)->SetConfig(a,b,c) +#define IDirectInputJoyConfig_DeleteConfig(p,a) (p)->DeleteConfig(a) +#define IDirectInputJoyConfig_GetUserValues(p,a,b) (p)->GetUserValues(a,b) +#define IDirectInputJoyConfig_SetUserValues(p,a,b) (p)->SetUserValues(a,b) +#define IDirectInputJoyConfig_AddNewHardware(p,a,b) (p)->AddNewHardware(a,b) +#define IDirectInputJoyConfig_OpenTypeKey(p,a,b,c) (p)->OpenTypeKey(a,b,c) +#define IDirectInputJoyConfig_OpenConfigKey(p,a,b,c) (p)->OpenConfigKey(a,b,c) +#endif + +#endif /* DIJ_RINGZERO */ + +#if(DIRECTINPUT_VERSION >= 0x0800) + +#ifndef DIJ_RINGZERO + +#undef INTERFACE +#define INTERFACE IDirectInputJoyConfig8 + +DECLARE_INTERFACE_(IDirectInputJoyConfig8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputJoyConfig8 methods ***/ + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(SendNotify)(THIS) PURE; + STDMETHOD(EnumTypes)(THIS_ LPDIJOYTYPECALLBACK,LPVOID) PURE; + STDMETHOD(GetTypeInfo)(THIS_ LPCWSTR,LPDIJOYTYPEINFO,DWORD) PURE; + STDMETHOD(SetTypeInfo)(THIS_ LPCWSTR,LPCDIJOYTYPEINFO,DWORD,LPWSTR) PURE; + STDMETHOD(DeleteType)(THIS_ LPCWSTR) PURE; + STDMETHOD(GetConfig)(THIS_ UINT,LPDIJOYCONFIG,DWORD) PURE; + STDMETHOD(SetConfig)(THIS_ UINT,LPCDIJOYCONFIG,DWORD) PURE; + STDMETHOD(DeleteConfig)(THIS_ UINT) PURE; + STDMETHOD(GetUserValues)(THIS_ LPDIJOYUSERVALUES,DWORD) PURE; + STDMETHOD(SetUserValues)(THIS_ LPCDIJOYUSERVALUES,DWORD) PURE; + STDMETHOD(AddNewHardware)(THIS_ HWND,REFGUID) PURE; + STDMETHOD(OpenTypeKey)(THIS_ LPCWSTR,DWORD,PHKEY) PURE; + STDMETHOD(OpenAppStatusKey)(THIS_ PHKEY) PURE; +}; + +typedef struct IDirectInputJoyConfig8 *LPDIRECTINPUTJOYCONFIG8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputJoyConfig8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputJoyConfig8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputJoyConfig8_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputJoyConfig8_Acquire(p) (p)->lpVtbl->Acquire(p) +#define IDirectInputJoyConfig8_Unacquire(p) (p)->lpVtbl->Unacquire(p) +#define IDirectInputJoyConfig8_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectInputJoyConfig8_SendNotify(p) (p)->lpVtbl->SendNotify(p) +#define IDirectInputJoyConfig8_EnumTypes(p,a,b) (p)->lpVtbl->EnumTypes(p,a,b) +#define IDirectInputJoyConfig8_GetTypeInfo(p,a,b,c) (p)->lpVtbl->GetTypeInfo(p,a,b,c) +#define IDirectInputJoyConfig8_SetTypeInfo(p,a,b,c,d) (p)->lpVtbl->SetTypeInfo(p,a,b,c,d) +#define IDirectInputJoyConfig8_DeleteType(p,a) (p)->lpVtbl->DeleteType(p,a) +#define IDirectInputJoyConfig8_GetConfig(p,a,b,c) (p)->lpVtbl->GetConfig(p,a,b,c) +#define IDirectInputJoyConfig8_SetConfig(p,a,b,c) (p)->lpVtbl->SetConfig(p,a,b,c) +#define IDirectInputJoyConfig8_DeleteConfig(p,a) (p)->lpVtbl->DeleteConfig(p,a) +#define IDirectInputJoyConfig8_GetUserValues(p,a,b) (p)->lpVtbl->GetUserValues(p,a,b) +#define IDirectInputJoyConfig8_SetUserValues(p,a,b) (p)->lpVtbl->SetUserValues(p,a,b) +#define IDirectInputJoyConfig8_AddNewHardware(p,a,b) (p)->lpVtbl->AddNewHardware(p,a,b) +#define IDirectInputJoyConfig8_OpenTypeKey(p,a,b,c) (p)->lpVtbl->OpenTypeKey(p,a,b,c) +#define IDirectInputJoyConfig8_OpenAppStatusKey(p,a) (p)->lpVtbl->OpenAppStatusKey(p,a) +#else +#define IDirectInputJoyConfig8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputJoyConfig8_AddRef(p) (p)->AddRef() +#define IDirectInputJoyConfig8_Release(p) (p)->Release() +#define IDirectInputJoyConfig8_Acquire(p) (p)->Acquire() +#define IDirectInputJoyConfig8_Unacquire(p) (p)->Unacquire() +#define IDirectInputJoyConfig8_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectInputJoyConfig8_SendNotify(p) (p)->SendNotify() +#define IDirectInputJoyConfig8_EnumTypes(p,a,b) (p)->EnumTypes(a,b) +#define IDirectInputJoyConfig8_GetTypeInfo(p,a,b,c) (p)->GetTypeInfo(a,b,c) +#define IDirectInputJoyConfig8_SetTypeInfo(p,a,b,c,d) (p)->SetTypeInfo(a,b,c,d) +#define IDirectInputJoyConfig8_DeleteType(p,a) (p)->DeleteType(a) +#define IDirectInputJoyConfig8_GetConfig(p,a,b,c) (p)->GetConfig(a,b,c) +#define IDirectInputJoyConfig8_SetConfig(p,a,b,c) (p)->SetConfig(a,b,c) +#define IDirectInputJoyConfig8_DeleteConfig(p,a) (p)->DeleteConfig(a) +#define IDirectInputJoyConfig8_GetUserValues(p,a,b) (p)->GetUserValues(a,b) +#define IDirectInputJoyConfig8_SetUserValues(p,a,b) (p)->SetUserValues(a,b) +#define IDirectInputJoyConfig8_AddNewHardware(p,a,b) (p)->AddNewHardware(a,b) +#define IDirectInputJoyConfig8_OpenTypeKey(p,a,b,c) (p)->OpenTypeKey(a,b,c) +#define IDirectInputJoyConfig8_OpenAppStatusKey(p,a) (p)->OpenAppStatusKey(a) +#endif + +#endif /* DIJ_RINGZERO */ + +/**************************************************************************** + * + * Notification Messages + * + ****************************************************************************/ + +/* RegisterWindowMessage with this to get DirectInput notification messages */ +#define DIRECTINPUT_NOTIFICATION_MSGSTRINGA "DIRECTINPUT_NOTIFICATION_MSGSTRING" +#define DIRECTINPUT_NOTIFICATION_MSGSTRINGW L"DIRECTINPUT_NOTIFICATION_MSGSTRING" + +#ifdef UNICODE +#define DIRECTINPUT_NOTIFICATION_MSGSTRING DIRECTINPUT_NOTIFICATION_MSGSTRINGW +#else +#define DIRECTINPUT_NOTIFICATION_MSGSTRING DIRECTINPUT_NOTIFICATION_MSGSTRINGA +#endif + +#define DIMSGWP_NEWAPPSTART 0x00000001 +#define DIMSGWP_DX8APPSTART 0x00000002 +#define DIMSGWP_DX8MAPPERAPPSTART 0x00000003 + +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#define DIAPPIDFLAG_NOTIME 0x00000001 +#define DIAPPIDFLAG_NOSIZE 0x00000002 + +#define DIRECTINPUT_REGSTR_VAL_APPIDFLAGA "AppIdFlag" +#define DIRECTINPUT_REGSTR_KEY_LASTAPPA "MostRecentApplication" +#define DIRECTINPUT_REGSTR_KEY_LASTMAPAPPA "MostRecentMapperApplication" +#define DIRECTINPUT_REGSTR_VAL_VERSIONA "Version" +#define DIRECTINPUT_REGSTR_VAL_NAMEA "Name" +#define DIRECTINPUT_REGSTR_VAL_IDA "Id" +#define DIRECTINPUT_REGSTR_VAL_MAPPERA "UsesMapper" +#define DIRECTINPUT_REGSTR_VAL_LASTSTARTA "MostRecentStart" + +#define DIRECTINPUT_REGSTR_VAL_APPIDFLAGW L"AppIdFlag" +#define DIRECTINPUT_REGSTR_KEY_LASTAPPW L"MostRecentApplication" +#define DIRECTINPUT_REGSTR_KEY_LASTMAPAPPW L"MostRecentMapperApplication" +#define DIRECTINPUT_REGSTR_VAL_VERSIONW L"Version" +#define DIRECTINPUT_REGSTR_VAL_NAMEW L"Name" +#define DIRECTINPUT_REGSTR_VAL_IDW L"Id" +#define DIRECTINPUT_REGSTR_VAL_MAPPERW L"UsesMapper" +#define DIRECTINPUT_REGSTR_VAL_LASTSTARTW L"MostRecentStart" + +#ifdef UNICODE +#define DIRECTINPUT_REGSTR_VAL_APPIDFLAG DIRECTINPUT_REGSTR_VAL_APPIDFLAGW +#define DIRECTINPUT_REGSTR_KEY_LASTAPP DIRECTINPUT_REGSTR_KEY_LASTAPPW +#define DIRECTINPUT_REGSTR_KEY_LASTMAPAPP DIRECTINPUT_REGSTR_KEY_LASTMAPAPPW +#define DIRECTINPUT_REGSTR_VAL_VERSION DIRECTINPUT_REGSTR_VAL_VERSIONW +#define DIRECTINPUT_REGSTR_VAL_NAME DIRECTINPUT_REGSTR_VAL_NAMEW +#define DIRECTINPUT_REGSTR_VAL_ID DIRECTINPUT_REGSTR_VAL_IDW +#define DIRECTINPUT_REGSTR_VAL_MAPPER DIRECTINPUT_REGSTR_VAL_MAPPERW +#define DIRECTINPUT_REGSTR_VAL_LASTSTART DIRECTINPUT_REGSTR_VAL_LASTSTARTW +#else +#define DIRECTINPUT_REGSTR_VAL_APPIDFLAG DIRECTINPUT_REGSTR_VAL_APPIDFLAGA +#define DIRECTINPUT_REGSTR_KEY_LASTAPP DIRECTINPUT_REGSTR_KEY_LASTAPPA +#define DIRECTINPUT_REGSTR_KEY_LASTMAPAPP DIRECTINPUT_REGSTR_KEY_LASTMAPAPPA +#define DIRECTINPUT_REGSTR_VAL_VERSION DIRECTINPUT_REGSTR_VAL_VERSIONA +#define DIRECTINPUT_REGSTR_VAL_NAME DIRECTINPUT_REGSTR_VAL_NAMEA +#define DIRECTINPUT_REGSTR_VAL_ID DIRECTINPUT_REGSTR_VAL_IDA +#define DIRECTINPUT_REGSTR_VAL_MAPPER DIRECTINPUT_REGSTR_VAL_MAPPERA +#define DIRECTINPUT_REGSTR_VAL_LASTSTART DIRECTINPUT_REGSTR_VAL_LASTSTARTA +#endif + + +/**************************************************************************** + * + * Return Codes + * + ****************************************************************************/ + +#define DIERR_NOMOREITEMS \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NO_MORE_ITEMS) + +/* + * Device driver-specific codes. + */ + +#define DIERR_DRIVERFIRST 0x80040300L +#define DIERR_DRIVERLAST 0x800403FFL + +/* + * Unless the specific driver has been precisely identified, no meaning + * should be attributed to these values other than that the driver + * originated the error. However, to illustrate the types of error that + * may be causing the failure, the PID force feedback driver distributed + * with DirectX 7 could return the following errors: + * + * DIERR_DRIVERFIRST + 1 + * The requested usage was not found. + * DIERR_DRIVERFIRST + 2 + * The parameter block couldn't be downloaded to the device. + * DIERR_DRIVERFIRST + 3 + * PID initialization failed. + * DIERR_DRIVERFIRST + 4 + * The provided values couldn't be scaled. + */ + + +/* + * Device installer errors. + */ + +/* + * Registry entry or DLL for class installer invalid + * or class installer not found. + */ +#define DIERR_INVALIDCLASSINSTALLER 0x80040400L + +/* + * The user cancelled the install operation. + */ +#define DIERR_CANCELLED 0x80040401L + +/* + * The INF file for the selected device could not be + * found or is invalid or is damaged. + */ +#define DIERR_BADINF 0x80040402L + +/**************************************************************************** + * + * Map files + * + ****************************************************************************/ + +/* + * Delete particular data from default map file. + */ +#define DIDIFT_DELETE 0x01000000 + +#ifdef __cplusplus +}; +#endif + +#endif /* __DINPUTD_INCLUDED__ */ diff --git a/src/dep/include/DXSDK/include/dls1.h b/src/dep/include/DXSDK/include/dls1.h index b33425d..fc88a31 100644 --- a/src/dep/include/DXSDK/include/dls1.h +++ b/src/dep/include/DXSDK/include/dls1.h @@ -1,267 +1,267 @@ -/*==========================================================================; -// -// dls1.h -// -// -// Description: -// -// Interface defines and structures for the Instrument Collection Form -// RIFF DLS. -// -// -// Written by Sonic Foundry 1996. Released for public use. -// -//=========================================================================*/ - -#ifndef _INC_DLS1 -#define _INC_DLS1 - -/*////////////////////////////////////////////////////////////////////////// -// -// -// Layout of an instrument collection: -// -// -// RIFF [] 'DLS ' [dlid,colh,INSTLIST,WAVEPOOL,INFOLIST] -// -// INSTLIST -// LIST [] 'lins' -// LIST [] 'ins ' [dlid,insh,RGNLIST,ARTLIST,INFOLIST] -// LIST [] 'ins ' [dlid,insh,RGNLIST,ARTLIST,INFOLIST] -// LIST [] 'ins ' [dlid,insh,RGNLIST,ARTLIST,INFOLIST] -// -// RGNLIST -// LIST [] 'lrgn' -// LIST [] 'rgn ' [rgnh,wsmp,wlnk,ARTLIST] -// LIST [] 'rgn ' [rgnh,wsmp,wlnk,ARTLIST] -// LIST [] 'rgn ' [rgnh,wsmp,wlnk,ARTLIST] -// -// ARTLIST -// LIST [] 'lart' -// 'art1' level 1 Articulation connection graph -// 'art2' level 2 Articulation connection graph -// '3rd1' Possible 3rd party articulation structure 1 -// '3rd2' Possible 3rd party articulation structure 2 .... and so on -// -// WAVEPOOL -// ptbl [] [pool table] -// LIST [] 'wvpl' -// [path], -// [path], -// LIST [] 'wave' [dlid,RIFFWAVE] -// LIST [] 'wave' [dlid,RIFFWAVE] -// LIST [] 'wave' [dlid,RIFFWAVE] -// LIST [] 'wave' [dlid,RIFFWAVE] -// LIST [] 'wave' [dlid,RIFFWAVE] -// -// INFOLIST -// LIST [] 'INFO' -// 'icmt' 'One of those crazy comments.' -// 'icop' 'Copyright (C) 1996 Sonic Foundry' -// -/////////////////////////////////////////////////////////////////////////*/ - - -/*///////////////////////////////////////////////////////////////////////// -// FOURCC's used in the DLS file -/////////////////////////////////////////////////////////////////////////*/ - -#define FOURCC_DLS mmioFOURCC('D','L','S',' ') -#define FOURCC_DLID mmioFOURCC('d','l','i','d') -#define FOURCC_COLH mmioFOURCC('c','o','l','h') -#define FOURCC_WVPL mmioFOURCC('w','v','p','l') -#define FOURCC_PTBL mmioFOURCC('p','t','b','l') -#define FOURCC_PATH mmioFOURCC('p','a','t','h') -#define FOURCC_wave mmioFOURCC('w','a','v','e') -#define FOURCC_LINS mmioFOURCC('l','i','n','s') -#define FOURCC_INS mmioFOURCC('i','n','s',' ') -#define FOURCC_INSH mmioFOURCC('i','n','s','h') -#define FOURCC_LRGN mmioFOURCC('l','r','g','n') -#define FOURCC_RGN mmioFOURCC('r','g','n',' ') -#define FOURCC_RGNH mmioFOURCC('r','g','n','h') -#define FOURCC_LART mmioFOURCC('l','a','r','t') -#define FOURCC_ART1 mmioFOURCC('a','r','t','1') -#define FOURCC_WLNK mmioFOURCC('w','l','n','k') -#define FOURCC_WSMP mmioFOURCC('w','s','m','p') -#define FOURCC_VERS mmioFOURCC('v','e','r','s') - -/*///////////////////////////////////////////////////////////////////////// -// Articulation connection graph definitions -/////////////////////////////////////////////////////////////////////////*/ - -/* Generic Sources */ -#define CONN_SRC_NONE 0x0000 -#define CONN_SRC_LFO 0x0001 -#define CONN_SRC_KEYONVELOCITY 0x0002 -#define CONN_SRC_KEYNUMBER 0x0003 -#define CONN_SRC_EG1 0x0004 -#define CONN_SRC_EG2 0x0005 -#define CONN_SRC_PITCHWHEEL 0x0006 - -/* Midi Controllers 0-127 */ -#define CONN_SRC_CC1 0x0081 -#define CONN_SRC_CC7 0x0087 -#define CONN_SRC_CC10 0x008a -#define CONN_SRC_CC11 0x008b - -/* Generic Destinations */ -#define CONN_DST_NONE 0x0000 -#define CONN_DST_ATTENUATION 0x0001 -#define CONN_DST_PITCH 0x0003 -#define CONN_DST_PAN 0x0004 - -/* LFO Destinations */ -#define CONN_DST_LFO_FREQUENCY 0x0104 -#define CONN_DST_LFO_STARTDELAY 0x0105 - -/* EG1 Destinations */ -#define CONN_DST_EG1_ATTACKTIME 0x0206 -#define CONN_DST_EG1_DECAYTIME 0x0207 -#define CONN_DST_EG1_RELEASETIME 0x0209 -#define CONN_DST_EG1_SUSTAINLEVEL 0x020a - -/* EG2 Destinations */ -#define CONN_DST_EG2_ATTACKTIME 0x030a -#define CONN_DST_EG2_DECAYTIME 0x030b -#define CONN_DST_EG2_RELEASETIME 0x030d -#define CONN_DST_EG2_SUSTAINLEVEL 0x030e - -#define CONN_TRN_NONE 0x0000 -#define CONN_TRN_CONCAVE 0x0001 - -typedef struct _DLSID { - ULONG ulData1; - USHORT usData2; - USHORT usData3; - BYTE abData4[8]; -} DLSID, FAR *LPDLSID; - -typedef struct _DLSVERSION { - DWORD dwVersionMS; - DWORD dwVersionLS; -}DLSVERSION, FAR *LPDLSVERSION; - - -typedef struct _CONNECTION { - USHORT usSource; - USHORT usControl; - USHORT usDestination; - USHORT usTransform; - LONG lScale; - }CONNECTION, FAR *LPCONNECTION; - - -/* Level 1 Articulation Data */ - -typedef struct _CONNECTIONLIST { - ULONG cbSize; /* size of the connection list structure */ - ULONG cConnections; /* count of connections in the list */ - } CONNECTIONLIST, FAR *LPCONNECTIONLIST; - - - -/*///////////////////////////////////////////////////////////////////////// -// Generic type defines for regions and instruments -/////////////////////////////////////////////////////////////////////////*/ - -typedef struct _RGNRANGE { - USHORT usLow; - USHORT usHigh; -}RGNRANGE, FAR * LPRGNRANGE; - -#define F_INSTRUMENT_DRUMS 0x80000000 - -typedef struct _MIDILOCALE { - ULONG ulBank; - ULONG ulInstrument; -}MIDILOCALE, FAR *LPMIDILOCALE; - -/*///////////////////////////////////////////////////////////////////////// -// Header structures found in an DLS file for collection, instruments, and -// regions. -/////////////////////////////////////////////////////////////////////////*/ - -#define F_RGN_OPTION_SELFNONEXCLUSIVE 0x0001 - -typedef struct _RGNHEADER { - RGNRANGE RangeKey; /* Key range */ - RGNRANGE RangeVelocity; /* Velocity Range */ - USHORT fusOptions; /* Synthesis options for this range */ - USHORT usKeyGroup; /* Key grouping for non simultaneous play */ - /* 0 = no group, 1 up is group */ - /* for Level 1 only groups 1-15 are allowed */ -}RGNHEADER, FAR *LPRGNHEADER; - -typedef struct _INSTHEADER { - ULONG cRegions; /* Count of regions in this instrument */ - MIDILOCALE Locale; /* Intended MIDI locale of this instrument */ -}INSTHEADER, FAR *LPINSTHEADER; - -typedef struct _DLSHEADER { - ULONG cInstruments; /* Count of instruments in the collection */ -}DLSHEADER, FAR *LPDLSHEADER; - -/*//////////////////////////////////////////////////////////////////////////// -// definitions for the Wave link structure -////////////////////////////////////////////////////////////////////////////*/ - -/* **** For level 1 only WAVELINK_CHANNEL_MONO is valid **** */ -/* ulChannel allows for up to 32 channels of audio with each bit position */ -/* specifiying a channel of playback */ - -#define WAVELINK_CHANNEL_LEFT 0x0001l -#define WAVELINK_CHANNEL_RIGHT 0x0002l - -#define F_WAVELINK_PHASE_MASTER 0x0001 - -typedef struct _WAVELINK { /* any paths or links are stored right after struct */ - USHORT fusOptions; /* options flags for this wave */ - USHORT usPhaseGroup; /* Phase grouping for locking channels */ - ULONG ulChannel; /* channel placement */ - ULONG ulTableIndex; /* index into the wave pool table, 0 based */ -}WAVELINK, FAR *LPWAVELINK; - -#define POOL_CUE_NULL 0xffffffffl - -typedef struct _POOLCUE { - ULONG ulOffset; /* Offset to the entry in the list */ -}POOLCUE, FAR *LPPOOLCUE; - -typedef struct _POOLTABLE { - ULONG cbSize; /* size of the pool table structure */ - ULONG cCues; /* count of cues in the list */ - } POOLTABLE, FAR *LPPOOLTABLE; - -/*//////////////////////////////////////////////////////////////////////////// -// Structures for the "wsmp" chunk -////////////////////////////////////////////////////////////////////////////*/ - -#define F_WSMP_NO_TRUNCATION 0x0001l -#define F_WSMP_NO_COMPRESSION 0x0002l - - -typedef struct _rwsmp { - ULONG cbSize; - USHORT usUnityNote; /* MIDI Unity Playback Note */ - SHORT sFineTune; /* Fine Tune in log tuning */ - LONG lAttenuation; /* Overall Attenuation to be applied to data */ - ULONG fulOptions; /* Flag options */ - ULONG cSampleLoops; /* Count of Sample loops, 0 loops is one shot */ - } WSMPL, FAR *LPWSMPL; - - -/* This loop type is a normal forward playing loop which is continually */ -/* played until the envelope reaches an off threshold in the release */ -/* portion of the volume envelope */ - -#define WLOOP_TYPE_FORWARD 0 - -typedef struct _rloop { - ULONG cbSize; - ULONG ulType; /* Loop Type */ - ULONG ulStart; /* Start of loop in samples */ - ULONG ulLength; /* Length of loop in samples */ -} WLOOP, FAR *LPWLOOP; - -#endif /*_INC_DLS1 */ - +/*==========================================================================; +// +// dls1.h +// +// +// Description: +// +// Interface defines and structures for the Instrument Collection Form +// RIFF DLS. +// +// +// Written by Sonic Foundry 1996. Released for public use. +// +//=========================================================================*/ + +#ifndef _INC_DLS1 +#define _INC_DLS1 + +/*////////////////////////////////////////////////////////////////////////// +// +// +// Layout of an instrument collection: +// +// +// RIFF [] 'DLS ' [dlid,colh,INSTLIST,WAVEPOOL,INFOLIST] +// +// INSTLIST +// LIST [] 'lins' +// LIST [] 'ins ' [dlid,insh,RGNLIST,ARTLIST,INFOLIST] +// LIST [] 'ins ' [dlid,insh,RGNLIST,ARTLIST,INFOLIST] +// LIST [] 'ins ' [dlid,insh,RGNLIST,ARTLIST,INFOLIST] +// +// RGNLIST +// LIST [] 'lrgn' +// LIST [] 'rgn ' [rgnh,wsmp,wlnk,ARTLIST] +// LIST [] 'rgn ' [rgnh,wsmp,wlnk,ARTLIST] +// LIST [] 'rgn ' [rgnh,wsmp,wlnk,ARTLIST] +// +// ARTLIST +// LIST [] 'lart' +// 'art1' level 1 Articulation connection graph +// 'art2' level 2 Articulation connection graph +// '3rd1' Possible 3rd party articulation structure 1 +// '3rd2' Possible 3rd party articulation structure 2 .... and so on +// +// WAVEPOOL +// ptbl [] [pool table] +// LIST [] 'wvpl' +// [path], +// [path], +// LIST [] 'wave' [dlid,RIFFWAVE] +// LIST [] 'wave' [dlid,RIFFWAVE] +// LIST [] 'wave' [dlid,RIFFWAVE] +// LIST [] 'wave' [dlid,RIFFWAVE] +// LIST [] 'wave' [dlid,RIFFWAVE] +// +// INFOLIST +// LIST [] 'INFO' +// 'icmt' 'One of those crazy comments.' +// 'icop' 'Copyright (C) 1996 Sonic Foundry' +// +/////////////////////////////////////////////////////////////////////////*/ + + +/*///////////////////////////////////////////////////////////////////////// +// FOURCC's used in the DLS file +/////////////////////////////////////////////////////////////////////////*/ + +#define FOURCC_DLS mmioFOURCC('D','L','S',' ') +#define FOURCC_DLID mmioFOURCC('d','l','i','d') +#define FOURCC_COLH mmioFOURCC('c','o','l','h') +#define FOURCC_WVPL mmioFOURCC('w','v','p','l') +#define FOURCC_PTBL mmioFOURCC('p','t','b','l') +#define FOURCC_PATH mmioFOURCC('p','a','t','h') +#define FOURCC_wave mmioFOURCC('w','a','v','e') +#define FOURCC_LINS mmioFOURCC('l','i','n','s') +#define FOURCC_INS mmioFOURCC('i','n','s',' ') +#define FOURCC_INSH mmioFOURCC('i','n','s','h') +#define FOURCC_LRGN mmioFOURCC('l','r','g','n') +#define FOURCC_RGN mmioFOURCC('r','g','n',' ') +#define FOURCC_RGNH mmioFOURCC('r','g','n','h') +#define FOURCC_LART mmioFOURCC('l','a','r','t') +#define FOURCC_ART1 mmioFOURCC('a','r','t','1') +#define FOURCC_WLNK mmioFOURCC('w','l','n','k') +#define FOURCC_WSMP mmioFOURCC('w','s','m','p') +#define FOURCC_VERS mmioFOURCC('v','e','r','s') + +/*///////////////////////////////////////////////////////////////////////// +// Articulation connection graph definitions +/////////////////////////////////////////////////////////////////////////*/ + +/* Generic Sources */ +#define CONN_SRC_NONE 0x0000 +#define CONN_SRC_LFO 0x0001 +#define CONN_SRC_KEYONVELOCITY 0x0002 +#define CONN_SRC_KEYNUMBER 0x0003 +#define CONN_SRC_EG1 0x0004 +#define CONN_SRC_EG2 0x0005 +#define CONN_SRC_PITCHWHEEL 0x0006 + +/* Midi Controllers 0-127 */ +#define CONN_SRC_CC1 0x0081 +#define CONN_SRC_CC7 0x0087 +#define CONN_SRC_CC10 0x008a +#define CONN_SRC_CC11 0x008b + +/* Generic Destinations */ +#define CONN_DST_NONE 0x0000 +#define CONN_DST_ATTENUATION 0x0001 +#define CONN_DST_PITCH 0x0003 +#define CONN_DST_PAN 0x0004 + +/* LFO Destinations */ +#define CONN_DST_LFO_FREQUENCY 0x0104 +#define CONN_DST_LFO_STARTDELAY 0x0105 + +/* EG1 Destinations */ +#define CONN_DST_EG1_ATTACKTIME 0x0206 +#define CONN_DST_EG1_DECAYTIME 0x0207 +#define CONN_DST_EG1_RELEASETIME 0x0209 +#define CONN_DST_EG1_SUSTAINLEVEL 0x020a + +/* EG2 Destinations */ +#define CONN_DST_EG2_ATTACKTIME 0x030a +#define CONN_DST_EG2_DECAYTIME 0x030b +#define CONN_DST_EG2_RELEASETIME 0x030d +#define CONN_DST_EG2_SUSTAINLEVEL 0x030e + +#define CONN_TRN_NONE 0x0000 +#define CONN_TRN_CONCAVE 0x0001 + +typedef struct _DLSID { + ULONG ulData1; + USHORT usData2; + USHORT usData3; + BYTE abData4[8]; +} DLSID, FAR *LPDLSID; + +typedef struct _DLSVERSION { + DWORD dwVersionMS; + DWORD dwVersionLS; +}DLSVERSION, FAR *LPDLSVERSION; + + +typedef struct _CONNECTION { + USHORT usSource; + USHORT usControl; + USHORT usDestination; + USHORT usTransform; + LONG lScale; + }CONNECTION, FAR *LPCONNECTION; + + +/* Level 1 Articulation Data */ + +typedef struct _CONNECTIONLIST { + ULONG cbSize; /* size of the connection list structure */ + ULONG cConnections; /* count of connections in the list */ + } CONNECTIONLIST, FAR *LPCONNECTIONLIST; + + + +/*///////////////////////////////////////////////////////////////////////// +// Generic type defines for regions and instruments +/////////////////////////////////////////////////////////////////////////*/ + +typedef struct _RGNRANGE { + USHORT usLow; + USHORT usHigh; +}RGNRANGE, FAR * LPRGNRANGE; + +#define F_INSTRUMENT_DRUMS 0x80000000 + +typedef struct _MIDILOCALE { + ULONG ulBank; + ULONG ulInstrument; +}MIDILOCALE, FAR *LPMIDILOCALE; + +/*///////////////////////////////////////////////////////////////////////// +// Header structures found in an DLS file for collection, instruments, and +// regions. +/////////////////////////////////////////////////////////////////////////*/ + +#define F_RGN_OPTION_SELFNONEXCLUSIVE 0x0001 + +typedef struct _RGNHEADER { + RGNRANGE RangeKey; /* Key range */ + RGNRANGE RangeVelocity; /* Velocity Range */ + USHORT fusOptions; /* Synthesis options for this range */ + USHORT usKeyGroup; /* Key grouping for non simultaneous play */ + /* 0 = no group, 1 up is group */ + /* for Level 1 only groups 1-15 are allowed */ +}RGNHEADER, FAR *LPRGNHEADER; + +typedef struct _INSTHEADER { + ULONG cRegions; /* Count of regions in this instrument */ + MIDILOCALE Locale; /* Intended MIDI locale of this instrument */ +}INSTHEADER, FAR *LPINSTHEADER; + +typedef struct _DLSHEADER { + ULONG cInstruments; /* Count of instruments in the collection */ +}DLSHEADER, FAR *LPDLSHEADER; + +/*//////////////////////////////////////////////////////////////////////////// +// definitions for the Wave link structure +////////////////////////////////////////////////////////////////////////////*/ + +/* **** For level 1 only WAVELINK_CHANNEL_MONO is valid **** */ +/* ulChannel allows for up to 32 channels of audio with each bit position */ +/* specifiying a channel of playback */ + +#define WAVELINK_CHANNEL_LEFT 0x0001l +#define WAVELINK_CHANNEL_RIGHT 0x0002l + +#define F_WAVELINK_PHASE_MASTER 0x0001 + +typedef struct _WAVELINK { /* any paths or links are stored right after struct */ + USHORT fusOptions; /* options flags for this wave */ + USHORT usPhaseGroup; /* Phase grouping for locking channels */ + ULONG ulChannel; /* channel placement */ + ULONG ulTableIndex; /* index into the wave pool table, 0 based */ +}WAVELINK, FAR *LPWAVELINK; + +#define POOL_CUE_NULL 0xffffffffl + +typedef struct _POOLCUE { + ULONG ulOffset; /* Offset to the entry in the list */ +}POOLCUE, FAR *LPPOOLCUE; + +typedef struct _POOLTABLE { + ULONG cbSize; /* size of the pool table structure */ + ULONG cCues; /* count of cues in the list */ + } POOLTABLE, FAR *LPPOOLTABLE; + +/*//////////////////////////////////////////////////////////////////////////// +// Structures for the "wsmp" chunk +////////////////////////////////////////////////////////////////////////////*/ + +#define F_WSMP_NO_TRUNCATION 0x0001l +#define F_WSMP_NO_COMPRESSION 0x0002l + + +typedef struct _rwsmp { + ULONG cbSize; + USHORT usUnityNote; /* MIDI Unity Playback Note */ + SHORT sFineTune; /* Fine Tune in log tuning */ + LONG lAttenuation; /* Overall Attenuation to be applied to data */ + ULONG fulOptions; /* Flag options */ + ULONG cSampleLoops; /* Count of Sample loops, 0 loops is one shot */ + } WSMPL, FAR *LPWSMPL; + + +/* This loop type is a normal forward playing loop which is continually */ +/* played until the envelope reaches an off threshold in the release */ +/* portion of the volume envelope */ + +#define WLOOP_TYPE_FORWARD 0 + +typedef struct _rloop { + ULONG cbSize; + ULONG ulType; /* Loop Type */ + ULONG ulStart; /* Start of loop in samples */ + ULONG ulLength; /* Length of loop in samples */ +} WLOOP, FAR *LPWLOOP; + +#endif /*_INC_DLS1 */ + diff --git a/src/dep/include/DXSDK/include/dls2.h b/src/dep/include/DXSDK/include/dls2.h index b372f35..30cec23 100644 --- a/src/dep/include/DXSDK/include/dls2.h +++ b/src/dep/include/DXSDK/include/dls2.h @@ -1,130 +1,130 @@ -/* - - dls2.h - - Description: - - Interface defines and structures for the DLS2 extensions of DLS. - - - Written by Microsoft 1998. Released for public use. - -*/ - -#ifndef _INC_DLS2 -#define _INC_DLS2 - -/* - FOURCC's used in the DLS2 file, in addition to DLS1 chunks -*/ - -#define FOURCC_RGN2 mmioFOURCC('r','g','n','2') -#define FOURCC_LAR2 mmioFOURCC('l','a','r','2') -#define FOURCC_ART2 mmioFOURCC('a','r','t','2') -#define FOURCC_CDL mmioFOURCC('c','d','l',' ') -#define FOURCC_DLID mmioFOURCC('d','l','i','d') - -/* - Articulation connection graph definitions. These are in addition to - the definitions in the DLS1 header. -*/ - -/* Generic Sources (in addition to DLS1 sources. */ -#define CONN_SRC_POLYPRESSURE 0x0007 /* Polyphonic Pressure */ -#define CONN_SRC_CHANNELPRESSURE 0x0008 /* Channel Pressure */ -#define CONN_SRC_VIBRATO 0x0009 /* Vibrato LFO */ -#define CONN_SRC_MONOPRESSURE 0x000a /* MIDI Mono pressure */ - - -/* Midi Controllers */ -#define CONN_SRC_CC91 0x00db /* Reverb Send */ -#define CONN_SRC_CC93 0x00dd /* Chorus Send */ - - -/* Generic Destinations */ -#define CONN_DST_GAIN 0x0001 /* Same as CONN_DST_ ATTENUATION, but more appropriate terminology. */ -#define CONN_DST_KEYNUMBER 0x0005 /* Key Number Generator */ - -/* Audio Channel Output Destinations */ -#define CONN_DST_LEFT 0x0010 /* Left Channel Send */ -#define CONN_DST_RIGHT 0x0011 /* Right Channel Send */ -#define CONN_DST_CENTER 0x0012 /* Center Channel Send */ -#define CONN_DST_LEFTREAR 0x0013 /* Left Rear Channel Send */ -#define CONN_DST_RIGHTREAR 0x0014 /* Right Rear Channel Send */ -#define CONN_DST_LFE_CHANNEL 0x0015 /* LFE Channel Send */ -#define CONN_DST_CHORUS 0x0080 /* Chorus Send */ -#define CONN_DST_REVERB 0x0081 /* Reverb Send */ - -/* Vibrato LFO Destinations */ -#define CONN_DST_VIB_FREQUENCY 0x0114 /* Vibrato Frequency */ -#define CONN_DST_VIB_STARTDELAY 0x0115 /* Vibrato Start Delay */ - -/* EG1 Destinations */ -#define CONN_DST_EG1_DELAYTIME 0x020B /* EG1 Delay Time */ -#define CONN_DST_EG1_HOLDTIME 0x020C /* EG1 Hold Time */ -#define CONN_DST_EG1_SHUTDOWNTIME 0x020D /* EG1 Shutdown Time */ - - -/* EG2 Destinations */ -#define CONN_DST_EG2_DELAYTIME 0x030F /* EG2 Delay Time */ -#define CONN_DST_EG2_HOLDTIME 0x0310 /* EG2 Hold Time */ - - -/* Filter Destinations */ -#define CONN_DST_FILTER_CUTOFF 0x0500 /* Filter Cutoff Frequency */ -#define CONN_DST_FILTER_Q 0x0501 /* Filter Resonance */ - - -/* Transforms */ -#define CONN_TRN_CONVEX 0x0002 /* Convex Transform */ -#define CONN_TRN_SWITCH 0x0003 /* Switch Transform */ - - -/* Conditional chunk operators */ - #define DLS_CDL_AND 0x0001 /* X = X & Y */ - #define DLS_CDL_OR 0x0002 /* X = X | Y */ - #define DLS_CDL_XOR 0x0003 /* X = X ^ Y */ - #define DLS_CDL_ADD 0x0004 /* X = X + Y */ - #define DLS_CDL_SUBTRACT 0x0005 /* X = X - Y */ - #define DLS_CDL_MULTIPLY 0x0006 /* X = X * Y */ - #define DLS_CDL_DIVIDE 0x0007 /* X = X / Y */ - #define DLS_CDL_LOGICAL_AND 0x0008 /* X = X && Y */ - #define DLS_CDL_LOGICAL_OR 0x0009 /* X = X || Y */ - #define DLS_CDL_LT 0x000A /* X = (X < Y) */ - #define DLS_CDL_LE 0x000B /* X = (X <= Y) */ - #define DLS_CDL_GT 0x000C /* X = (X > Y) */ - #define DLS_CDL_GE 0x000D /* X = (X >= Y) */ - #define DLS_CDL_EQ 0x000E /* X = (X == Y) */ - #define DLS_CDL_NOT 0x000F /* X = !X */ - #define DLS_CDL_CONST 0x0010 /* 32-bit constant */ - #define DLS_CDL_QUERY 0x0011 /* 32-bit value returned from query */ - #define DLS_CDL_QUERYSUPPORTED 0x0012 /* Test to see if query is supported by synth */ - -/* - Loop and release -*/ - -#define WLOOP_TYPE_RELEASE 1 - -/* - WaveLink chunk -*/ - -#define F_WAVELINK_MULTICHANNEL 0x0002 - - -/* - DLSID queries for -*/ - -DEFINE_GUID(DLSID_GMInHardware, 0x178f2f24, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); -DEFINE_GUID(DLSID_GSInHardware, 0x178f2f25, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); -DEFINE_GUID(DLSID_XGInHardware, 0x178f2f26, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); -DEFINE_GUID(DLSID_SupportsDLS1, 0x178f2f27, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); -DEFINE_GUID(DLSID_SupportsDLS2, 0xf14599e5, 0x4689, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); -DEFINE_GUID(DLSID_SampleMemorySize, 0x178f2f28, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); -DEFINE_GUID(DLSID_ManufacturersID, 0xb03e1181, 0x8095, 0x11d2, 0xa1, 0xef, 0x0, 0x60, 0x8, 0x33, 0xdb, 0xd8); -DEFINE_GUID(DLSID_ProductID, 0xb03e1182, 0x8095, 0x11d2, 0xa1, 0xef, 0x0, 0x60, 0x8, 0x33, 0xdb, 0xd8); -DEFINE_GUID(DLSID_SamplePlaybackRate, 0x2a91f713, 0xa4bf, 0x11d2, 0xbb, 0xdf, 0x0, 0x60, 0x8, 0x33, 0xdb, 0xd8); - -#endif /* _INC_DLS2 */ +/* + + dls2.h + + Description: + + Interface defines and structures for the DLS2 extensions of DLS. + + + Written by Microsoft 1998. Released for public use. + +*/ + +#ifndef _INC_DLS2 +#define _INC_DLS2 + +/* + FOURCC's used in the DLS2 file, in addition to DLS1 chunks +*/ + +#define FOURCC_RGN2 mmioFOURCC('r','g','n','2') +#define FOURCC_LAR2 mmioFOURCC('l','a','r','2') +#define FOURCC_ART2 mmioFOURCC('a','r','t','2') +#define FOURCC_CDL mmioFOURCC('c','d','l',' ') +#define FOURCC_DLID mmioFOURCC('d','l','i','d') + +/* + Articulation connection graph definitions. These are in addition to + the definitions in the DLS1 header. +*/ + +/* Generic Sources (in addition to DLS1 sources. */ +#define CONN_SRC_POLYPRESSURE 0x0007 /* Polyphonic Pressure */ +#define CONN_SRC_CHANNELPRESSURE 0x0008 /* Channel Pressure */ +#define CONN_SRC_VIBRATO 0x0009 /* Vibrato LFO */ +#define CONN_SRC_MONOPRESSURE 0x000a /* MIDI Mono pressure */ + + +/* Midi Controllers */ +#define CONN_SRC_CC91 0x00db /* Reverb Send */ +#define CONN_SRC_CC93 0x00dd /* Chorus Send */ + + +/* Generic Destinations */ +#define CONN_DST_GAIN 0x0001 /* Same as CONN_DST_ ATTENUATION, but more appropriate terminology. */ +#define CONN_DST_KEYNUMBER 0x0005 /* Key Number Generator */ + +/* Audio Channel Output Destinations */ +#define CONN_DST_LEFT 0x0010 /* Left Channel Send */ +#define CONN_DST_RIGHT 0x0011 /* Right Channel Send */ +#define CONN_DST_CENTER 0x0012 /* Center Channel Send */ +#define CONN_DST_LEFTREAR 0x0013 /* Left Rear Channel Send */ +#define CONN_DST_RIGHTREAR 0x0014 /* Right Rear Channel Send */ +#define CONN_DST_LFE_CHANNEL 0x0015 /* LFE Channel Send */ +#define CONN_DST_CHORUS 0x0080 /* Chorus Send */ +#define CONN_DST_REVERB 0x0081 /* Reverb Send */ + +/* Vibrato LFO Destinations */ +#define CONN_DST_VIB_FREQUENCY 0x0114 /* Vibrato Frequency */ +#define CONN_DST_VIB_STARTDELAY 0x0115 /* Vibrato Start Delay */ + +/* EG1 Destinations */ +#define CONN_DST_EG1_DELAYTIME 0x020B /* EG1 Delay Time */ +#define CONN_DST_EG1_HOLDTIME 0x020C /* EG1 Hold Time */ +#define CONN_DST_EG1_SHUTDOWNTIME 0x020D /* EG1 Shutdown Time */ + + +/* EG2 Destinations */ +#define CONN_DST_EG2_DELAYTIME 0x030F /* EG2 Delay Time */ +#define CONN_DST_EG2_HOLDTIME 0x0310 /* EG2 Hold Time */ + + +/* Filter Destinations */ +#define CONN_DST_FILTER_CUTOFF 0x0500 /* Filter Cutoff Frequency */ +#define CONN_DST_FILTER_Q 0x0501 /* Filter Resonance */ + + +/* Transforms */ +#define CONN_TRN_CONVEX 0x0002 /* Convex Transform */ +#define CONN_TRN_SWITCH 0x0003 /* Switch Transform */ + + +/* Conditional chunk operators */ + #define DLS_CDL_AND 0x0001 /* X = X & Y */ + #define DLS_CDL_OR 0x0002 /* X = X | Y */ + #define DLS_CDL_XOR 0x0003 /* X = X ^ Y */ + #define DLS_CDL_ADD 0x0004 /* X = X + Y */ + #define DLS_CDL_SUBTRACT 0x0005 /* X = X - Y */ + #define DLS_CDL_MULTIPLY 0x0006 /* X = X * Y */ + #define DLS_CDL_DIVIDE 0x0007 /* X = X / Y */ + #define DLS_CDL_LOGICAL_AND 0x0008 /* X = X && Y */ + #define DLS_CDL_LOGICAL_OR 0x0009 /* X = X || Y */ + #define DLS_CDL_LT 0x000A /* X = (X < Y) */ + #define DLS_CDL_LE 0x000B /* X = (X <= Y) */ + #define DLS_CDL_GT 0x000C /* X = (X > Y) */ + #define DLS_CDL_GE 0x000D /* X = (X >= Y) */ + #define DLS_CDL_EQ 0x000E /* X = (X == Y) */ + #define DLS_CDL_NOT 0x000F /* X = !X */ + #define DLS_CDL_CONST 0x0010 /* 32-bit constant */ + #define DLS_CDL_QUERY 0x0011 /* 32-bit value returned from query */ + #define DLS_CDL_QUERYSUPPORTED 0x0012 /* Test to see if query is supported by synth */ + +/* + Loop and release +*/ + +#define WLOOP_TYPE_RELEASE 1 + +/* + WaveLink chunk +*/ + +#define F_WAVELINK_MULTICHANNEL 0x0002 + + +/* + DLSID queries for +*/ + +DEFINE_GUID(DLSID_GMInHardware, 0x178f2f24, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); +DEFINE_GUID(DLSID_GSInHardware, 0x178f2f25, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); +DEFINE_GUID(DLSID_XGInHardware, 0x178f2f26, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); +DEFINE_GUID(DLSID_SupportsDLS1, 0x178f2f27, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); +DEFINE_GUID(DLSID_SupportsDLS2, 0xf14599e5, 0x4689, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); +DEFINE_GUID(DLSID_SampleMemorySize, 0x178f2f28, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); +DEFINE_GUID(DLSID_ManufacturersID, 0xb03e1181, 0x8095, 0x11d2, 0xa1, 0xef, 0x0, 0x60, 0x8, 0x33, 0xdb, 0xd8); +DEFINE_GUID(DLSID_ProductID, 0xb03e1182, 0x8095, 0x11d2, 0xa1, 0xef, 0x0, 0x60, 0x8, 0x33, 0xdb, 0xd8); +DEFINE_GUID(DLSID_SamplePlaybackRate, 0x2a91f713, 0xa4bf, 0x11d2, 0xbb, 0xdf, 0x0, 0x60, 0x8, 0x33, 0xdb, 0xd8); + +#endif /* _INC_DLS2 */ diff --git a/src/dep/include/DXSDK/include/dmdls.h b/src/dep/include/DXSDK/include/dmdls.h index 8d06778..c507268 100644 --- a/src/dep/include/DXSDK/include/dmdls.h +++ b/src/dep/include/DXSDK/include/dmdls.h @@ -1,199 +1,199 @@ -/************************************************************************ -* * -* dmdls.h -- DLS download definitions for DirectMusic API's * -* * -* Copyright (c) Microsoft Corporation. All rights reserved. * -* * -************************************************************************/ - -#ifndef _DMDLS_ -#define _DMDLS_ - -#include "dls1.h" - -typedef long PCENT; /* Pitch cents */ -typedef long GCENT; /* Gain cents */ -typedef long TCENT; /* Time cents */ -typedef long PERCENT; /* Per.. cent! */ - -typedef LONGLONG REFERENCE_TIME; -typedef REFERENCE_TIME *LPREFERENCE_TIME; - -#ifndef MAKE_FOURCC -#define MAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ - ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) - - -typedef DWORD FOURCC; /* a four character code */ -#endif - -typedef struct _DMUS_DOWNLOADINFO -{ - DWORD dwDLType; /* Instrument or Wave */ - DWORD dwDLId; /* Unique identifier to tag this download. */ - DWORD dwNumOffsetTableEntries; /* Number of index in the offset address table. */ - DWORD cbSize; /* Total size of this memory chunk. */ -} DMUS_DOWNLOADINFO; - -#define DMUS_DOWNLOADINFO_INSTRUMENT 1 -#define DMUS_DOWNLOADINFO_WAVE 2 -#define DMUS_DOWNLOADINFO_INSTRUMENT2 3 /* New version for better DLS2 support. */ - -/* Support for oneshot and streaming wave data - */ -#define DMUS_DOWNLOADINFO_WAVEARTICULATION 4 /* Wave articulation data */ -#define DMUS_DOWNLOADINFO_STREAMINGWAVE 5 /* One chunk of a streaming */ -#define DMUS_DOWNLOADINFO_ONESHOTWAVE 6 - -#define DMUS_DEFAULT_SIZE_OFFSETTABLE 1 - -/* Flags for DMUS_INSTRUMENT's ulFlags member */ - -#define DMUS_INSTRUMENT_GM_INSTRUMENT (1 << 0) - -typedef struct _DMUS_OFFSETTABLE -{ - ULONG ulOffsetTable[DMUS_DEFAULT_SIZE_OFFSETTABLE]; -} DMUS_OFFSETTABLE; - -typedef struct _DMUS_INSTRUMENT -{ - ULONG ulPatch; - ULONG ulFirstRegionIdx; - ULONG ulGlobalArtIdx; /* If zero the instrument does not have an articulation */ - ULONG ulFirstExtCkIdx; /* If zero no 3rd party entenstion chunks associated with the instrument */ - ULONG ulCopyrightIdx; /* If zero no Copyright information associated with the instrument */ - ULONG ulFlags; -} DMUS_INSTRUMENT; - -typedef struct _DMUS_REGION -{ - RGNRANGE RangeKey; - RGNRANGE RangeVelocity; - USHORT fusOptions; - USHORT usKeyGroup; - ULONG ulRegionArtIdx; /* If zero the region does not have an articulation */ - ULONG ulNextRegionIdx; /* If zero no more regions */ - ULONG ulFirstExtCkIdx; /* If zero no 3rd party entenstion chunks associated with the region */ - WAVELINK WaveLink; - WSMPL WSMP; /* If WSMP.cSampleLoops > 1 then a WLOOP is included */ - WLOOP WLOOP[1]; -} DMUS_REGION; - -typedef struct _DMUS_LFOPARAMS -{ - PCENT pcFrequency; - TCENT tcDelay; - GCENT gcVolumeScale; - PCENT pcPitchScale; - GCENT gcMWToVolume; - PCENT pcMWToPitch; -} DMUS_LFOPARAMS; - -typedef struct _DMUS_VEGPARAMS -{ - TCENT tcAttack; - TCENT tcDecay; - PERCENT ptSustain; - TCENT tcRelease; - TCENT tcVel2Attack; - TCENT tcKey2Decay; -} DMUS_VEGPARAMS; - -typedef struct _DMUS_PEGPARAMS -{ - TCENT tcAttack; - TCENT tcDecay; - PERCENT ptSustain; - TCENT tcRelease; - TCENT tcVel2Attack; - TCENT tcKey2Decay; - PCENT pcRange; -} DMUS_PEGPARAMS; - -typedef struct _DMUS_MSCPARAMS -{ - PERCENT ptDefaultPan; -} DMUS_MSCPARAMS; - -typedef struct _DMUS_ARTICPARAMS -{ - DMUS_LFOPARAMS LFO; - DMUS_VEGPARAMS VolEG; - DMUS_PEGPARAMS PitchEG; - DMUS_MSCPARAMS Misc; -} DMUS_ARTICPARAMS; - -typedef struct _DMUS_ARTICULATION /* Articulation chunk for DMUS_DOWNLOADINFO_INSTRUMENT format. */ -{ - ULONG ulArt1Idx; /* DLS Level 1 articulation chunk */ - ULONG ulFirstExtCkIdx; /* 3rd party extenstion chunks associated with the articulation */ -} DMUS_ARTICULATION; - -typedef struct _DMUS_ARTICULATION2 /* Articulation chunk for DMUS_DOWNLOADINFO_INSTRUMENT2 format. */ -{ - ULONG ulArtIdx; /* DLS Level 1/2 articulation chunk */ - ULONG ulFirstExtCkIdx; /* 3rd party extenstion chunks associated with the articulation */ - ULONG ulNextArtIdx; /* Additional articulation chunks */ -} DMUS_ARTICULATION2; - -#define DMUS_MIN_DATA_SIZE 4 -/* The actual number is determined by cbSize of struct _DMUS_EXTENSIONCHUNK */ - -typedef struct _DMUS_EXTENSIONCHUNK -{ - ULONG cbSize; /* Size of extension chunk */ - ULONG ulNextExtCkIdx; /* If zero no more 3rd party entenstion chunks */ - FOURCC ExtCkID; - BYTE byExtCk[DMUS_MIN_DATA_SIZE]; /* The actual number that follows is determined by cbSize */ -} DMUS_EXTENSIONCHUNK; - -/* The actual number is determined by cbSize of struct _DMUS_COPYRIGHT */ - -typedef struct _DMUS_COPYRIGHT -{ - ULONG cbSize; /* Size of copyright information */ - BYTE byCopyright[DMUS_MIN_DATA_SIZE]; /* The actual number that follows is determined by cbSize */ -} DMUS_COPYRIGHT; - -typedef struct _DMUS_WAVEDATA -{ - ULONG cbSize; - BYTE byData[DMUS_MIN_DATA_SIZE]; -} DMUS_WAVEDATA; - -typedef struct _DMUS_WAVE -{ - ULONG ulFirstExtCkIdx; /* If zero no 3rd party entenstion chunks associated with the wave */ - ULONG ulCopyrightIdx; /* If zero no Copyright information associated with the wave */ - ULONG ulWaveDataIdx; /* Location of actual wave data. */ - WAVEFORMATEX WaveformatEx; -} DMUS_WAVE; - -typedef struct _DMUS_NOTERANGE *LPDMUS_NOTERANGE; -typedef struct _DMUS_NOTERANGE -{ - DWORD dwLowNote; /* Sets the low note for the range of MIDI note events to which the instrument responds.*/ - DWORD dwHighNote; /* Sets the high note for the range of MIDI note events to which the instrument responds.*/ -} DMUS_NOTERANGE; - -typedef struct _DMUS_WAVEARTDL -{ - ULONG ulDownloadIdIdx; /* Download ID's of each buffer */ - ULONG ulBus; /* Playback bus */ - ULONG ulBuffers; /* Buffers */ - ULONG ulMasterDLId; /* Download ID of master voice of slave group */ - USHORT usOptions; /* Same as DLS2 region options */ -} DMUS_WAVEARTDL, - *LPDMUS_WAVEARTDL; - -typedef struct _DMUS_WAVEDL -{ - ULONG cbWaveData; /* Bytes of wave data */ -} DMUS_WAVEDL, - *LPDMUS_WAVEDL; - -#endif - - +/************************************************************************ +* * +* dmdls.h -- DLS download definitions for DirectMusic API's * +* * +* Copyright (c) Microsoft Corporation. All rights reserved. * +* * +************************************************************************/ + +#ifndef _DMDLS_ +#define _DMDLS_ + +#include "dls1.h" + +typedef long PCENT; /* Pitch cents */ +typedef long GCENT; /* Gain cents */ +typedef long TCENT; /* Time cents */ +typedef long PERCENT; /* Per.. cent! */ + +typedef LONGLONG REFERENCE_TIME; +typedef REFERENCE_TIME *LPREFERENCE_TIME; + +#ifndef MAKE_FOURCC +#define MAKEFOURCC(ch0, ch1, ch2, ch3) \ + ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ + ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) + + +typedef DWORD FOURCC; /* a four character code */ +#endif + +typedef struct _DMUS_DOWNLOADINFO +{ + DWORD dwDLType; /* Instrument or Wave */ + DWORD dwDLId; /* Unique identifier to tag this download. */ + DWORD dwNumOffsetTableEntries; /* Number of index in the offset address table. */ + DWORD cbSize; /* Total size of this memory chunk. */ +} DMUS_DOWNLOADINFO; + +#define DMUS_DOWNLOADINFO_INSTRUMENT 1 +#define DMUS_DOWNLOADINFO_WAVE 2 +#define DMUS_DOWNLOADINFO_INSTRUMENT2 3 /* New version for better DLS2 support. */ + +/* Support for oneshot and streaming wave data + */ +#define DMUS_DOWNLOADINFO_WAVEARTICULATION 4 /* Wave articulation data */ +#define DMUS_DOWNLOADINFO_STREAMINGWAVE 5 /* One chunk of a streaming */ +#define DMUS_DOWNLOADINFO_ONESHOTWAVE 6 + +#define DMUS_DEFAULT_SIZE_OFFSETTABLE 1 + +/* Flags for DMUS_INSTRUMENT's ulFlags member */ + +#define DMUS_INSTRUMENT_GM_INSTRUMENT (1 << 0) + +typedef struct _DMUS_OFFSETTABLE +{ + ULONG ulOffsetTable[DMUS_DEFAULT_SIZE_OFFSETTABLE]; +} DMUS_OFFSETTABLE; + +typedef struct _DMUS_INSTRUMENT +{ + ULONG ulPatch; + ULONG ulFirstRegionIdx; + ULONG ulGlobalArtIdx; /* If zero the instrument does not have an articulation */ + ULONG ulFirstExtCkIdx; /* If zero no 3rd party entenstion chunks associated with the instrument */ + ULONG ulCopyrightIdx; /* If zero no Copyright information associated with the instrument */ + ULONG ulFlags; +} DMUS_INSTRUMENT; + +typedef struct _DMUS_REGION +{ + RGNRANGE RangeKey; + RGNRANGE RangeVelocity; + USHORT fusOptions; + USHORT usKeyGroup; + ULONG ulRegionArtIdx; /* If zero the region does not have an articulation */ + ULONG ulNextRegionIdx; /* If zero no more regions */ + ULONG ulFirstExtCkIdx; /* If zero no 3rd party entenstion chunks associated with the region */ + WAVELINK WaveLink; + WSMPL WSMP; /* If WSMP.cSampleLoops > 1 then a WLOOP is included */ + WLOOP WLOOP[1]; +} DMUS_REGION; + +typedef struct _DMUS_LFOPARAMS +{ + PCENT pcFrequency; + TCENT tcDelay; + GCENT gcVolumeScale; + PCENT pcPitchScale; + GCENT gcMWToVolume; + PCENT pcMWToPitch; +} DMUS_LFOPARAMS; + +typedef struct _DMUS_VEGPARAMS +{ + TCENT tcAttack; + TCENT tcDecay; + PERCENT ptSustain; + TCENT tcRelease; + TCENT tcVel2Attack; + TCENT tcKey2Decay; +} DMUS_VEGPARAMS; + +typedef struct _DMUS_PEGPARAMS +{ + TCENT tcAttack; + TCENT tcDecay; + PERCENT ptSustain; + TCENT tcRelease; + TCENT tcVel2Attack; + TCENT tcKey2Decay; + PCENT pcRange; +} DMUS_PEGPARAMS; + +typedef struct _DMUS_MSCPARAMS +{ + PERCENT ptDefaultPan; +} DMUS_MSCPARAMS; + +typedef struct _DMUS_ARTICPARAMS +{ + DMUS_LFOPARAMS LFO; + DMUS_VEGPARAMS VolEG; + DMUS_PEGPARAMS PitchEG; + DMUS_MSCPARAMS Misc; +} DMUS_ARTICPARAMS; + +typedef struct _DMUS_ARTICULATION /* Articulation chunk for DMUS_DOWNLOADINFO_INSTRUMENT format. */ +{ + ULONG ulArt1Idx; /* DLS Level 1 articulation chunk */ + ULONG ulFirstExtCkIdx; /* 3rd party extenstion chunks associated with the articulation */ +} DMUS_ARTICULATION; + +typedef struct _DMUS_ARTICULATION2 /* Articulation chunk for DMUS_DOWNLOADINFO_INSTRUMENT2 format. */ +{ + ULONG ulArtIdx; /* DLS Level 1/2 articulation chunk */ + ULONG ulFirstExtCkIdx; /* 3rd party extenstion chunks associated with the articulation */ + ULONG ulNextArtIdx; /* Additional articulation chunks */ +} DMUS_ARTICULATION2; + +#define DMUS_MIN_DATA_SIZE 4 +/* The actual number is determined by cbSize of struct _DMUS_EXTENSIONCHUNK */ + +typedef struct _DMUS_EXTENSIONCHUNK +{ + ULONG cbSize; /* Size of extension chunk */ + ULONG ulNextExtCkIdx; /* If zero no more 3rd party entenstion chunks */ + FOURCC ExtCkID; + BYTE byExtCk[DMUS_MIN_DATA_SIZE]; /* The actual number that follows is determined by cbSize */ +} DMUS_EXTENSIONCHUNK; + +/* The actual number is determined by cbSize of struct _DMUS_COPYRIGHT */ + +typedef struct _DMUS_COPYRIGHT +{ + ULONG cbSize; /* Size of copyright information */ + BYTE byCopyright[DMUS_MIN_DATA_SIZE]; /* The actual number that follows is determined by cbSize */ +} DMUS_COPYRIGHT; + +typedef struct _DMUS_WAVEDATA +{ + ULONG cbSize; + BYTE byData[DMUS_MIN_DATA_SIZE]; +} DMUS_WAVEDATA; + +typedef struct _DMUS_WAVE +{ + ULONG ulFirstExtCkIdx; /* If zero no 3rd party entenstion chunks associated with the wave */ + ULONG ulCopyrightIdx; /* If zero no Copyright information associated with the wave */ + ULONG ulWaveDataIdx; /* Location of actual wave data. */ + WAVEFORMATEX WaveformatEx; +} DMUS_WAVE; + +typedef struct _DMUS_NOTERANGE *LPDMUS_NOTERANGE; +typedef struct _DMUS_NOTERANGE +{ + DWORD dwLowNote; /* Sets the low note for the range of MIDI note events to which the instrument responds.*/ + DWORD dwHighNote; /* Sets the high note for the range of MIDI note events to which the instrument responds.*/ +} DMUS_NOTERANGE; + +typedef struct _DMUS_WAVEARTDL +{ + ULONG ulDownloadIdIdx; /* Download ID's of each buffer */ + ULONG ulBus; /* Playback bus */ + ULONG ulBuffers; /* Buffers */ + ULONG ulMasterDLId; /* Download ID of master voice of slave group */ + USHORT usOptions; /* Same as DLS2 region options */ +} DMUS_WAVEARTDL, + *LPDMUS_WAVEARTDL; + +typedef struct _DMUS_WAVEDL +{ + ULONG cbWaveData; /* Bytes of wave data */ +} DMUS_WAVEDL, + *LPDMUS_WAVEDL; + +#endif + + diff --git a/src/dep/include/DXSDK/include/dmerror.h b/src/dep/include/DXSDK/include/dmerror.h index 9279f73..a0a61ff 100644 --- a/src/dep/include/DXSDK/include/dmerror.h +++ b/src/dep/include/DXSDK/include/dmerror.h @@ -1,843 +1,843 @@ -/************************************************************************ -* * -* dmerror.h -- Error codes returned by DirectMusic API's * -* * -* Copyright (c) Microsoft Corporation. All rights reserved. * -* * -************************************************************************/ - -#ifndef _DMERROR_ -#define _DMERROR_ - -#define FACILITY_DIRECTMUSIC 0x878 /* Shared with DirectSound */ -#define DMUS_ERRBASE 0x1000 /* Make error codes human readable in hex */ - -#ifndef MAKE_HRESULT -#define MAKE_HRESULT(sev,fac,code) \ - ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) ) -#endif - -#define MAKE_DMHRESULTSUCCESS(code) MAKE_HRESULT(0, FACILITY_DIRECTMUSIC, (DMUS_ERRBASE + (code))) -#define MAKE_DMHRESULTERROR(code) MAKE_HRESULT(1, FACILITY_DIRECTMUSIC, (DMUS_ERRBASE + (code))) - -/* DMUS_S_PARTIALLOAD - * - * The object could only load partially. This can happen if some components are - * not registered properly, such as embedded tracks and tools. This can also happen - * if some content is missing. For example, if a segment uses a DLS collection that - * is not in the loader's current search directory. - */ -#define DMUS_S_PARTIALLOAD MAKE_DMHRESULTSUCCESS(0x091) - -/* DMUS_S_PARTIALDOWNLOAD - * - * Return value from IDirectMusicBand::Download() which indicates that - * some of the instruments safely downloaded, but others failed. This usually - * occurs when some instruments are on PChannels not supported by the performance - * or port. - */ -#define DMUS_S_PARTIALDOWNLOAD MAKE_DMHRESULTSUCCESS(0x092) - -/* DMUS_S_REQUEUE - * - * Return value from IDirectMusicTool::ProcessPMsg() which indicates to the - * performance that it should cue the PMsg again automatically. - */ -#define DMUS_S_REQUEUE MAKE_DMHRESULTSUCCESS(0x200) - -/* DMUS_S_FREE - * - * Return value from IDirectMusicTool::ProcessPMsg() which indicates to the - * performance that it should free the PMsg automatically. - */ -#define DMUS_S_FREE MAKE_DMHRESULTSUCCESS(0x201) - -/* DMUS_S_END - * - * Return value from IDirectMusicTrack::Play() which indicates to the - * segment that the track has no more data after mtEnd. - */ -#define DMUS_S_END MAKE_DMHRESULTSUCCESS(0x202) - -/* DMUS_S_STRING_TRUNCATED - * - * Returned string has been truncated to fit the buffer size. - */ -#define DMUS_S_STRING_TRUNCATED MAKE_DMHRESULTSUCCESS(0x210) - -/* DMUS_S_LAST_TOOL - * - * Returned from IDirectMusicGraph::StampPMsg(), this indicates that the PMsg - * is already stamped with the last tool in the graph. The returned PMsg's - * tool pointer is now NULL. - */ -#define DMUS_S_LAST_TOOL MAKE_DMHRESULTSUCCESS(0x211) - -/* DMUS_S_OVER_CHORD - * - * Returned from IDirectMusicPerformance::MusicToMIDI(), this indicates - * that no note has been calculated because the music value has the note - * at a position higher than the top note of the chord. This applies only - * to DMUS_PLAYMODE_NORMALCHORD play mode. This success code indicates - * that the caller should not do anything with the note. It is not meant - * to be played against this chord. - */ -#define DMUS_S_OVER_CHORD MAKE_DMHRESULTSUCCESS(0x212) - -/* DMUS_S_UP_OCTAVE - * - * Returned from IDirectMusicPerformance::MIDIToMusic(), and - * IDirectMusicPerformance::MusicToMIDI(), this indicates - * that the note conversion generated a note value that is below 0, - * so it has been bumped up one or more octaves to be in the proper - * MIDI range of 0 through 127. - * Note that this is valid for MIDIToMusic() when using play modes - * DMUS_PLAYMODE_FIXEDTOCHORD and DMUS_PLAYMODE_FIXEDTOKEY, both of - * which store MIDI values in wMusicValue. With MusicToMIDI(), it is - * valid for all play modes. - * Ofcourse, DMUS_PLAYMODE_FIXED will never return this success code. - */ -#define DMUS_S_UP_OCTAVE MAKE_DMHRESULTSUCCESS(0x213) - -/* DMUS_S_DOWN_OCTAVE - * - * Returned from IDirectMusicPerformance::MIDIToMusic(), and - * IDirectMusicPerformance::MusicToMIDI(), this indicates - * that the note conversion generated a note value that is above 127, - * so it has been bumped down one or more octaves to be in the proper - * MIDI range of 0 through 127. - * Note that this is valid for MIDIToMusic() when using play modes - * DMUS_PLAYMODE_FIXEDTOCHORD and DMUS_PLAYMODE_FIXEDTOKEY, both of - * which store MIDI values in wMusicValue. With MusicToMIDI(), it is - * valid for all play modes. - * Ofcourse, DMUS_PLAYMODE_FIXED will never return this success code. - */ -#define DMUS_S_DOWN_OCTAVE MAKE_DMHRESULTSUCCESS(0x214) - -/* DMUS_S_NOBUFFERCONTROL - * - * Although the audio output from the port will be routed to the - * same device as the given DirectSound buffer, buffer controls - * such as pan and volume will not affect the output. - * - */ -#define DMUS_S_NOBUFFERCONTROL MAKE_DMHRESULTSUCCESS(0x215) - -/* DMUS_S_GARBAGE_COLLECTED - * - * The requested operation was not performed because during CollectGarbage - * the loader determined that the object had been released. - */ -#define DMUS_S_GARBAGE_COLLECTED MAKE_DMHRESULTSUCCESS(0x216) - -/* DMUS_E_DRIVER_FAILED - * - * An unexpected error was returned from a device driver, indicating - * possible failure of the driver or hardware. - */ -#define DMUS_E_DRIVER_FAILED MAKE_DMHRESULTERROR(0x0101) - -/* DMUS_E_PORTS_OPEN - * - * The requested operation cannot be performed while there are - * instantiated ports in any process in the system. - */ -#define DMUS_E_PORTS_OPEN MAKE_DMHRESULTERROR(0x0102) - -/* DMUS_E_DEVICE_IN_USE - * - * The requested device is already in use (possibly by a non-DirectMusic - * client) and cannot be opened again. - */ -#define DMUS_E_DEVICE_IN_USE MAKE_DMHRESULTERROR(0x0103) - -/* DMUS_E_INSUFFICIENTBUFFER - * - * Buffer is not large enough for requested operation. - */ -#define DMUS_E_INSUFFICIENTBUFFER MAKE_DMHRESULTERROR(0x0104) - -/* DMUS_E_BUFFERNOTSET - * - * No buffer was prepared for the download data. - */ -#define DMUS_E_BUFFERNOTSET MAKE_DMHRESULTERROR(0x0105) - -/* DMUS_E_BUFFERNOTAVAILABLE - * - * Download failed due to inability to access or create download buffer. - */ -#define DMUS_E_BUFFERNOTAVAILABLE MAKE_DMHRESULTERROR(0x0106) - -/* DMUS_E_NOTADLSCOL - * - * Error parsing DLS collection. File is corrupt. - */ -#define DMUS_E_NOTADLSCOL MAKE_DMHRESULTERROR(0x0108) - -/* DMUS_E_INVALIDOFFSET - * - * Wave chunks in DLS collection file are at incorrect offsets. - */ -#define DMUS_E_INVALIDOFFSET MAKE_DMHRESULTERROR(0x0109) - -/* DMUS_E_ALREADY_LOADED - * - * Second attempt to load a DLS collection that is currently open. - */ -#define DMUS_E_ALREADY_LOADED MAKE_DMHRESULTERROR(0x0111) - -/* DMUS_E_INVALIDPOS - * - * Error reading wave data from DLS collection. Indicates bad file. - */ -#define DMUS_E_INVALIDPOS MAKE_DMHRESULTERROR(0x0113) - -/* DMUS_E_INVALIDPATCH - * - * There is no instrument in the collection that matches patch number. - */ -#define DMUS_E_INVALIDPATCH MAKE_DMHRESULTERROR(0x0114) - -/* DMUS_E_CANNOTSEEK - * - * The IStream* doesn't support Seek(). - */ -#define DMUS_E_CANNOTSEEK MAKE_DMHRESULTERROR(0x0115) - -/* DMUS_E_CANNOTWRITE - * - * The IStream* doesn't support Write(). - */ -#define DMUS_E_CANNOTWRITE MAKE_DMHRESULTERROR(0x0116) - -/* DMUS_E_CHUNKNOTFOUND - * - * The RIFF parser doesn't contain a required chunk while parsing file. - */ -#define DMUS_E_CHUNKNOTFOUND MAKE_DMHRESULTERROR(0x0117) - -/* DMUS_E_INVALID_DOWNLOADID - * - * Invalid download id was used in the process of creating a download buffer. - */ -#define DMUS_E_INVALID_DOWNLOADID MAKE_DMHRESULTERROR(0x0119) - -/* DMUS_E_NOT_DOWNLOADED_TO_PORT - * - * Tried to unload an object that was not downloaded or previously unloaded. - */ -#define DMUS_E_NOT_DOWNLOADED_TO_PORT MAKE_DMHRESULTERROR(0x0120) - -/* DMUS_E_ALREADY_DOWNLOADED - * - * Buffer was already downloaded to synth. - */ -#define DMUS_E_ALREADY_DOWNLOADED MAKE_DMHRESULTERROR(0x0121) - -/* DMUS_E_UNKNOWN_PROPERTY - * - * The specified property item was not recognized by the target object. - */ -#define DMUS_E_UNKNOWN_PROPERTY MAKE_DMHRESULTERROR(0x0122) - -/* DMUS_E_SET_UNSUPPORTED - * - * The specified property item may not be set on the target object. - */ -#define DMUS_E_SET_UNSUPPORTED MAKE_DMHRESULTERROR(0x0123) - -/* DMUS_E_GET_UNSUPPORTED - * - * The specified property item may not be retrieved from the target object. - */ -#define DMUS_E_GET_UNSUPPORTED MAKE_DMHRESULTERROR(0x0124) - -/* DMUS_E_NOTMONO - * - * Wave chunk has more than one interleaved channel. DLS format requires MONO. - */ -#define DMUS_E_NOTMONO MAKE_DMHRESULTERROR(0x0125) - -/* DMUS_E_BADARTICULATION - * - * Invalid articulation chunk in DLS collection. - */ -#define DMUS_E_BADARTICULATION MAKE_DMHRESULTERROR(0x0126) - -/* DMUS_E_BADINSTRUMENT - * - * Invalid instrument chunk in DLS collection. - */ -#define DMUS_E_BADINSTRUMENT MAKE_DMHRESULTERROR(0x0127) - -/* DMUS_E_BADWAVELINK - * - * Wavelink chunk in DLS collection points to invalid wave. - */ -#define DMUS_E_BADWAVELINK MAKE_DMHRESULTERROR(0x0128) - -/* DMUS_E_NOARTICULATION - * - * Articulation missing from instrument in DLS collection. - */ -#define DMUS_E_NOARTICULATION MAKE_DMHRESULTERROR(0x0129) - -/* DMUS_E_NOTPCM - * - * Downoaded DLS wave is not in PCM format. -*/ -#define DMUS_E_NOTPCM MAKE_DMHRESULTERROR(0x012A) - -/* DMUS_E_BADWAVE - * - * Bad wave chunk in DLS collection - */ -#define DMUS_E_BADWAVE MAKE_DMHRESULTERROR(0x012B) - -/* DMUS_E_BADOFFSETTABLE - * - * Offset Table for download buffer has errors. - */ -#define DMUS_E_BADOFFSETTABLE MAKE_DMHRESULTERROR(0x012C) - -/* DMUS_E_UNKNOWNDOWNLOAD - * - * Attempted to download unknown data type. - */ -#define DMUS_E_UNKNOWNDOWNLOAD MAKE_DMHRESULTERROR(0x012D) - -/* DMUS_E_NOSYNTHSINK - * - * The operation could not be completed because no sink was connected to - * the synthesizer. - */ -#define DMUS_E_NOSYNTHSINK MAKE_DMHRESULTERROR(0x012E) - -/* DMUS_E_ALREADYOPEN - * - * An attempt was made to open the software synthesizer while it was already - * open. - * ASSERT? - */ -#define DMUS_E_ALREADYOPEN MAKE_DMHRESULTERROR(0x012F) - -/* DMUS_E_ALREADYCLOSE - * - * An attempt was made to close the software synthesizer while it was already - * open. - * ASSERT? - */ -#define DMUS_E_ALREADYCLOSED MAKE_DMHRESULTERROR(0x0130) - -/* DMUS_E_SYNTHNOTCONFIGURED - * - * The operation could not be completed because the software synth has not - * yet been fully configured. - * ASSERT? - */ -#define DMUS_E_SYNTHNOTCONFIGURED MAKE_DMHRESULTERROR(0x0131) - -/* DMUS_E_SYNTHACTIVE - * - * The operation cannot be carried out while the synthesizer is active. - */ -#define DMUS_E_SYNTHACTIVE MAKE_DMHRESULTERROR(0x0132) - -/* DMUS_E_CANNOTREAD - * - * An error occurred while attempting to read from the IStream* object. - */ -#define DMUS_E_CANNOTREAD MAKE_DMHRESULTERROR(0x0133) - -/* DMUS_E_DMUSIC_RELEASED - * - * The operation cannot be performed because the final instance of the - * DirectMusic object was released. Ports cannot be used after final - * release of the DirectMusic object. - */ -#define DMUS_E_DMUSIC_RELEASED MAKE_DMHRESULTERROR(0x0134) - -/* DMUS_E_BUFFER_EMPTY - * - * There was no data in the referenced buffer. - */ -#define DMUS_E_BUFFER_EMPTY MAKE_DMHRESULTERROR(0x0135) - -/* DMUS_E_BUFFER_FULL - * - * There is insufficient space to insert the given event into the buffer. - */ -#define DMUS_E_BUFFER_FULL MAKE_DMHRESULTERROR(0x0136) - -/* DMUS_E_PORT_NOT_CAPTURE - * - * The given operation could not be carried out because the port is a - * capture port. - */ -#define DMUS_E_PORT_NOT_CAPTURE MAKE_DMHRESULTERROR(0x0137) - -/* DMUS_E_PORT_NOT_RENDER - * - * The given operation could not be carried out because the port is a - * render port. - */ -#define DMUS_E_PORT_NOT_RENDER MAKE_DMHRESULTERROR(0x0138) - -/* DMUS_E_DSOUND_NOT_SET - * - * The port could not be created because no DirectSound has been specified. - * Specify a DirectSound interface via the IDirectMusic::SetDirectSound - * method; pass NULL to have DirectMusic manage usage of DirectSound. - */ -#define DMUS_E_DSOUND_NOT_SET MAKE_DMHRESULTERROR(0x0139) - -/* DMUS_E_ALREADY_ACTIVATED - * - * The operation cannot be carried out while the port is active. - */ -#define DMUS_E_ALREADY_ACTIVATED MAKE_DMHRESULTERROR(0x013A) - -/* DMUS_E_INVALIDBUFFER - * - * Invalid DirectSound buffer was handed to port. - */ -#define DMUS_E_INVALIDBUFFER MAKE_DMHRESULTERROR(0x013B) - -/* DMUS_E_WAVEFORMATNOTSUPPORTED - * - * Invalid buffer format was handed to the synth sink. - */ -#define DMUS_E_WAVEFORMATNOTSUPPORTED MAKE_DMHRESULTERROR(0x013C) - -/* DMUS_E_SYNTHINACTIVE - * - * The operation cannot be carried out while the synthesizer is inactive. - */ -#define DMUS_E_SYNTHINACTIVE MAKE_DMHRESULTERROR(0x013D) - -/* DMUS_E_DSOUND_ALREADY_SET - * - * IDirectMusic::SetDirectSound has already been called. It may not be - * changed while in use. - */ -#define DMUS_E_DSOUND_ALREADY_SET MAKE_DMHRESULTERROR(0x013E) - -/* DMUS_E_INVALID_EVENT - * - * The given event is invalid (either it is not a valid MIDI message - * or it makes use of running status). The event cannot be packed - * into the buffer. - */ -#define DMUS_E_INVALID_EVENT MAKE_DMHRESULTERROR(0x013F) - -/* DMUS_E_UNSUPPORTED_STREAM - * - * The IStream* object does not contain data supported by the loading object. - */ -#define DMUS_E_UNSUPPORTED_STREAM MAKE_DMHRESULTERROR(0x0150) - -/* DMUS_E_ALREADY_INITED - * - * The object has already been initialized. - */ -#define DMUS_E_ALREADY_INITED MAKE_DMHRESULTERROR(0x0151) - -/* DMUS_E_INVALID_BAND - * - * The file does not contain a valid band. - */ -#define DMUS_E_INVALID_BAND MAKE_DMHRESULTERROR(0x0152) - -/* DMUS_E_TRACK_HDR_NOT_FIRST_CK - * - * The IStream* object's data does not have a track header as the first chunk, - * and therefore can not be read by the segment object. - */ -#define DMUS_E_TRACK_HDR_NOT_FIRST_CK MAKE_DMHRESULTERROR(0x0155) - -/* DMUS_E_TOOL_HDR_NOT_FIRST_CK - * - * The IStream* object's data does not have a tool header as the first chunk, - * and therefore can not be read by the graph object. - */ -#define DMUS_E_TOOL_HDR_NOT_FIRST_CK MAKE_DMHRESULTERROR(0x0156) - -/* DMUS_E_INVALID_TRACK_HDR - * - * The IStream* object's data contains an invalid track header (ckid is 0 and - * fccType is NULL,) and therefore can not be read by the segment object. - */ -#define DMUS_E_INVALID_TRACK_HDR MAKE_DMHRESULTERROR(0x0157) - -/* DMUS_E_INVALID_TOOL_HDR - * - * The IStream* object's data contains an invalid tool header (ckid is 0 and - * fccType is NULL,) and therefore can not be read by the graph object. - */ -#define DMUS_E_INVALID_TOOL_HDR MAKE_DMHRESULTERROR(0x0158) - -/* DMUS_E_ALL_TOOLS_FAILED - * - * The graph object was unable to load all tools from the IStream* object data. - * This may be due to errors in the stream, or the tools being incorrectly - * registered on the client. - */ -#define DMUS_E_ALL_TOOLS_FAILED MAKE_DMHRESULTERROR(0x0159) - -/* DMUS_E_ALL_TRACKS_FAILED - * - * The segment object was unable to load all tracks from the IStream* object data. - * This may be due to errors in the stream, or the tracks being incorrectly - * registered on the client. - */ -#define DMUS_E_ALL_TRACKS_FAILED MAKE_DMHRESULTERROR(0x0160) - -/* DMUS_E_NOT_FOUND - * - * The requested item was not contained by the object. - */ -#define DMUS_E_NOT_FOUND MAKE_DMHRESULTERROR(0x0161) - -/* DMUS_E_NOT_INIT - * - * A required object is not initialized or failed to initialize. - */ -#define DMUS_E_NOT_INIT MAKE_DMHRESULTERROR(0x0162) - -/* DMUS_E_TYPE_DISABLED - * - * The requested parameter type is currently disabled. Parameter types may - * be enabled and disabled by certain calls to SetParam(). - */ -#define DMUS_E_TYPE_DISABLED MAKE_DMHRESULTERROR(0x0163) - -/* DMUS_E_TYPE_UNSUPPORTED - * - * The requested parameter type is not supported on the object. - */ -#define DMUS_E_TYPE_UNSUPPORTED MAKE_DMHRESULTERROR(0x0164) - -/* DMUS_E_TIME_PAST - * - * The time is in the past, and the operation can not succeed. - */ -#define DMUS_E_TIME_PAST MAKE_DMHRESULTERROR(0x0165) - -/* DMUS_E_TRACK_NOT_FOUND - * - * The requested track is not contained by the segment. - */ -#define DMUS_E_TRACK_NOT_FOUND MAKE_DMHRESULTERROR(0x0166) - -/* DMUS_E_TRACK_NO_CLOCKTIME_SUPPORT - * - * The track does not support clock time playback or getparam. - */ -#define DMUS_E_TRACK_NO_CLOCKTIME_SUPPORT MAKE_DMHRESULTERROR(0x0167) - -/* DMUS_E_NO_MASTER_CLOCK - * - * There is no master clock in the performance. Be sure to call - * IDirectMusicPerformance::Init(). - */ -#define DMUS_E_NO_MASTER_CLOCK MAKE_DMHRESULTERROR(0x0170) - -/* DMUS_E_LOADER_NOCLASSID - * - * The class id field is required and missing in the DMUS_OBJECTDESC. - */ -#define DMUS_E_LOADER_NOCLASSID MAKE_DMHRESULTERROR(0x0180) - -/* DMUS_E_LOADER_BADPATH - * - * The requested file path is invalid. - */ -#define DMUS_E_LOADER_BADPATH MAKE_DMHRESULTERROR(0x0181) - -/* DMUS_E_LOADER_FAILEDOPEN - * - * File open failed - either file doesn't exist or is locked. - */ -#define DMUS_E_LOADER_FAILEDOPEN MAKE_DMHRESULTERROR(0x0182) - -/* DMUS_E_LOADER_FORMATNOTSUPPORTED - * - * Search data type is not supported. - */ -#define DMUS_E_LOADER_FORMATNOTSUPPORTED MAKE_DMHRESULTERROR(0x0183) - -/* DMUS_E_LOADER_FAILEDCREATE - * - * Unable to find or create object. - */ -#define DMUS_E_LOADER_FAILEDCREATE MAKE_DMHRESULTERROR(0x0184) - -/* DMUS_E_LOADER_OBJECTNOTFOUND - * - * Object was not found. - */ -#define DMUS_E_LOADER_OBJECTNOTFOUND MAKE_DMHRESULTERROR(0x0185) - -/* DMUS_E_LOADER_NOFILENAME - * - * The file name is missing from the DMUS_OBJECTDESC. - */ -#define DMUS_E_LOADER_NOFILENAME MAKE_DMHRESULTERROR(0x0186) - -/* DMUS_E_INVALIDFILE - * - * The file requested is not a valid file. - */ -#define DMUS_E_INVALIDFILE MAKE_DMHRESULTERROR(0x0200) - -/* DMUS_E_ALREADY_EXISTS - * - * The tool is already contained in the graph. Create a new instance. - */ -#define DMUS_E_ALREADY_EXISTS MAKE_DMHRESULTERROR(0x0201) - -/* DMUS_E_OUT_OF_RANGE - * - * Value is out of range, for instance the requested length is longer than - * the segment. - */ -#define DMUS_E_OUT_OF_RANGE MAKE_DMHRESULTERROR(0x0202) - -/* DMUS_E_SEGMENT_INIT_FAILED - * - * Segment initialization failed, most likely due to a critical memory situation. - */ -#define DMUS_E_SEGMENT_INIT_FAILED MAKE_DMHRESULTERROR(0x0203) - -/* DMUS_E_ALREADY_SENT - * - * The DMUS_PMSG has already been sent to the performance object via - * IDirectMusicPerformance::SendPMsg(). - */ -#define DMUS_E_ALREADY_SENT MAKE_DMHRESULTERROR(0x0204) - -/* DMUS_E_CANNOT_FREE - * - * The DMUS_PMSG was either not allocated by the performance via - * IDirectMusicPerformance::AllocPMsg(), or it was already freed via - * IDirectMusicPerformance::FreePMsg(). - */ -#define DMUS_E_CANNOT_FREE MAKE_DMHRESULTERROR(0x0205) - -/* DMUS_E_CANNOT_OPEN_PORT - * - * The default system port could not be opened. - */ -#define DMUS_E_CANNOT_OPEN_PORT MAKE_DMHRESULTERROR(0x0206) - -/* DMUS_E_CANNOT_CONVERT - * - * A call to MIDIToMusic() or MusicToMIDI() resulted in an error because - * the requested conversion could not happen. This usually occurs when the - * provided DMUS_CHORD_KEY structure has an invalid chord or scale pattern. - */ -#define DMUS_E_CANNOT_CONVERT MAKE_DMHRESULTERROR(0x0207) -/* misspelling in previous versions of DirectX preserved for backward compatibility */ -#define DMUS_E_CONNOT_CONVERT DMUS_E_CANNOT_CONVERT - -/* DMUS_E_DESCEND_CHUNK_FAIL - * - * DMUS_E_DESCEND_CHUNK_FAIL is returned when the end of the file - * was reached before the desired chunk was found. - */ -#define DMUS_E_DESCEND_CHUNK_FAIL MAKE_DMHRESULTERROR(0x0210) - -/* DMUS_E_NOT_LOADED - * - * An attempt to use this object failed because it first needs to - * be loaded. - */ -#define DMUS_E_NOT_LOADED MAKE_DMHRESULTERROR(0x0211) - -/* DMUS_E_SCRIPT_LANGUAGE_INCOMPATIBLE - * - * The activeX scripting engine for the script's language is not compatible with - * DirectMusic. - * - */ -#define DMUS_E_SCRIPT_LANGUAGE_INCOMPATIBLE MAKE_DMHRESULTERROR(0x0213) - -/* DMUS_E_SCRIPT_UNSUPPORTED_VARTYPE - * - * A varient was used that had a type that is not supported by DirectMusic. - * - */ -#define DMUS_E_SCRIPT_UNSUPPORTED_VARTYPE MAKE_DMHRESULTERROR(0x0214) - -/* DMUS_E_SCRIPT_ERROR_IN_SCRIPT - * - * An error was encountered while parsing or executing the script. - * The pErrorInfo parameter (if supplied) was filled with information about the error. - */ -#define DMUS_E_SCRIPT_ERROR_IN_SCRIPT MAKE_DMHRESULTERROR(0x0215) - -/* DMUS_E_SCRIPT_CANTLOAD_OLEAUT32 - * - * Loading of oleaut32.dll failed. VBScript and other activeX scripting languages - * require use of oleaut32.dll. On platforms where oleaut32.dll is not present, only - * the DirectMusicScript language, which doesn't require oleaut32.dll can be used. - */ -#define DMUS_E_SCRIPT_CANTLOAD_OLEAUT32 MAKE_DMHRESULTERROR(0x0216) - -/* DMUS_E_SCRIPT_LOADSCRIPT_ERROR - * - * An error occured while parsing a script loaded using LoadScript. The script that - * was loaded contains an error. - */ -#define DMUS_E_SCRIPT_LOADSCRIPT_ERROR MAKE_DMHRESULTERROR(0x0217) - -/* DMUS_E_SCRIPT_INVALID_FILE - * - * The script file is invalid. - */ -#define DMUS_E_SCRIPT_INVALID_FILE MAKE_DMHRESULTERROR(0x0218) - -/* DMUS_E_INVALID_SCRIPTTRACK - * - * The file contains an invalid script track. - */ -#define DMUS_E_INVALID_SCRIPTTRACK MAKE_DMHRESULTERROR(0x0219) - -/* DMUS_E_SCRIPT_VARIABLE_NOT_FOUND - * - * The script does not contain a variable with the specified name. - */ -#define DMUS_E_SCRIPT_VARIABLE_NOT_FOUND MAKE_DMHRESULTERROR(0x021A) - -/* DMUS_E_SCRIPT_ROUTINE_NOT_FOUND - * - * The script does not contain a routine with the specified name. - */ -#define DMUS_E_SCRIPT_ROUTINE_NOT_FOUND MAKE_DMHRESULTERROR(0x021B) - -/* DMUS_E_SCRIPT_CONTENT_READONLY - * - * Scripts variables for content referenced or embedded in a script cannot be set. - */ -#define DMUS_E_SCRIPT_CONTENT_READONLY MAKE_DMHRESULTERROR(0x021C) - -/* DMUS_E_SCRIPT_NOT_A_REFERENCE - * - * Attempt was made to set a script's variable by reference to a value that was - * not an object type. - */ -#define DMUS_E_SCRIPT_NOT_A_REFERENCE MAKE_DMHRESULTERROR(0x021D) - -/* DMUS_E_SCRIPT_VALUE_NOT_SUPPORTED - * - * Attempt was made to set a script's variable by value to an object that does - * not support a default value property. - */ -#define DMUS_E_SCRIPT_VALUE_NOT_SUPPORTED MAKE_DMHRESULTERROR(0x021E) - -/* DMUS_E_INVALID_SEGMENTTRIGGERTRACK - * - * The file contains an invalid segment trigger track. - */ -#define DMUS_E_INVALID_SEGMENTTRIGGERTRACK MAKE_DMHRESULTERROR(0x0220) - -/* DMUS_E_INVALID_LYRICSTRACK - * - * The file contains an invalid lyrics track. - */ -#define DMUS_E_INVALID_LYRICSTRACK MAKE_DMHRESULTERROR(0x0221) - -/* DMUS_E_INVALID_PARAMCONTROLTRACK - * - * The file contains an invalid parameter control track. - */ -#define DMUS_E_INVALID_PARAMCONTROLTRACK MAKE_DMHRESULTERROR(0x0222) - -/* DMUS_E_AUDIOVBSCRIPT_SYNTAXERROR - * - * A script written in AudioVBScript could not be read because it contained a statement that - * is not allowed by the AudioVBScript language. - */ -#define DMUS_E_AUDIOVBSCRIPT_SYNTAXERROR MAKE_DMHRESULTERROR(0x0223) - -/* DMUS_E_AUDIOVBSCRIPT_RUNTIMEERROR - * - * A script routine written in AudioVBScript failed because an invalid operation occurred. For example, - * adding the number 3 to a segment object would produce this error. So would attempting to call a routine - * that doesn't exist. - */ -#define DMUS_E_AUDIOVBSCRIPT_RUNTIMEERROR MAKE_DMHRESULTERROR(0x0224) - -/* DMUS_E_AUDIOVBSCRIPT_OPERATIONFAILURE - * - * A script routine written in AudioVBScript failed because a function outside of a script failed to complete. - * For example, a call to PlaySegment that fails to play because of low memory would return this error. - */ -#define DMUS_E_AUDIOVBSCRIPT_OPERATIONFAILURE MAKE_DMHRESULTERROR(0x0225) - -/* DMUS_E_AUDIOPATHS_NOT_VALID - * - * The Performance has set up some PChannels using the AssignPChannel command, which - * makes it not capable of supporting audio paths. - */ -#define DMUS_E_AUDIOPATHS_NOT_VALID MAKE_DMHRESULTERROR(0x0226) - -/* DMUS_E_AUDIOPATHS_IN_USE - * - * This is the inverse of the previous error. - * The Performance has set up some audio paths, which makes is incompatible - * with the calls to allocate pchannels, etc. - */ -#define DMUS_E_AUDIOPATHS_IN_USE MAKE_DMHRESULTERROR(0x0227) - -/* DMUS_E_NO_AUDIOPATH_CONFIG - * - * A segment was asked for its embedded audio path configuration, - * but there isn't any. - */ -#define DMUS_E_NO_AUDIOPATH_CONFIG MAKE_DMHRESULTERROR(0x0228) - -/* DMUS_E_AUDIOPATH_INACTIVE - * - * An audiopath is inactive, perhaps because closedown was called. - */ -#define DMUS_E_AUDIOPATH_INACTIVE MAKE_DMHRESULTERROR(0x0229) - -/* DMUS_E_AUDIOPATH_NOBUFFER - * - * An audiopath failed to create because a requested buffer could not be created. - */ -#define DMUS_E_AUDIOPATH_NOBUFFER MAKE_DMHRESULTERROR(0x022A) - -/* DMUS_E_AUDIOPATH_NOPORT - * - * An audiopath could not be used for playback because it lacked port assignments. - */ -#define DMUS_E_AUDIOPATH_NOPORT MAKE_DMHRESULTERROR(0x022B) - -/* DMUS_E_NO_AUDIOPATH - * - * Attempt was made to play segment in audiopath mode and there was no audiopath. - */ -#define DMUS_E_NO_AUDIOPATH MAKE_DMHRESULTERROR(0x022C) - -/* DMUS_E_INVALIDCHUNK - * - * Invalid data was found in a RIFF file chunk. - */ -#define DMUS_E_INVALIDCHUNK MAKE_DMHRESULTERROR(0x022D) - -/* DMUS_E_AUDIOPATH_NOGLOBALFXBUFFER - * - * Attempt was made to create an audiopath that sends to a global effects buffer which did not exist. - */ -#define DMUS_E_AUDIOPATH_NOGLOBALFXBUFFER MAKE_DMHRESULTERROR(0x022E) - -/* DMUS_E_INVALID_CONTAINER_OBJECT - * - * The file does not contain a valid container object. - */ -#define DMUS_E_INVALID_CONTAINER_OBJECT MAKE_DMHRESULTERROR(0x022F) - -#endif +/************************************************************************ +* * +* dmerror.h -- Error codes returned by DirectMusic API's * +* * +* Copyright (c) Microsoft Corporation. All rights reserved. * +* * +************************************************************************/ + +#ifndef _DMERROR_ +#define _DMERROR_ + +#define FACILITY_DIRECTMUSIC 0x878 /* Shared with DirectSound */ +#define DMUS_ERRBASE 0x1000 /* Make error codes human readable in hex */ + +#ifndef MAKE_HRESULT +#define MAKE_HRESULT(sev,fac,code) \ + ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) ) +#endif + +#define MAKE_DMHRESULTSUCCESS(code) MAKE_HRESULT(0, FACILITY_DIRECTMUSIC, (DMUS_ERRBASE + (code))) +#define MAKE_DMHRESULTERROR(code) MAKE_HRESULT(1, FACILITY_DIRECTMUSIC, (DMUS_ERRBASE + (code))) + +/* DMUS_S_PARTIALLOAD + * + * The object could only load partially. This can happen if some components are + * not registered properly, such as embedded tracks and tools. This can also happen + * if some content is missing. For example, if a segment uses a DLS collection that + * is not in the loader's current search directory. + */ +#define DMUS_S_PARTIALLOAD MAKE_DMHRESULTSUCCESS(0x091) + +/* DMUS_S_PARTIALDOWNLOAD + * + * Return value from IDirectMusicBand::Download() which indicates that + * some of the instruments safely downloaded, but others failed. This usually + * occurs when some instruments are on PChannels not supported by the performance + * or port. + */ +#define DMUS_S_PARTIALDOWNLOAD MAKE_DMHRESULTSUCCESS(0x092) + +/* DMUS_S_REQUEUE + * + * Return value from IDirectMusicTool::ProcessPMsg() which indicates to the + * performance that it should cue the PMsg again automatically. + */ +#define DMUS_S_REQUEUE MAKE_DMHRESULTSUCCESS(0x200) + +/* DMUS_S_FREE + * + * Return value from IDirectMusicTool::ProcessPMsg() which indicates to the + * performance that it should free the PMsg automatically. + */ +#define DMUS_S_FREE MAKE_DMHRESULTSUCCESS(0x201) + +/* DMUS_S_END + * + * Return value from IDirectMusicTrack::Play() which indicates to the + * segment that the track has no more data after mtEnd. + */ +#define DMUS_S_END MAKE_DMHRESULTSUCCESS(0x202) + +/* DMUS_S_STRING_TRUNCATED + * + * Returned string has been truncated to fit the buffer size. + */ +#define DMUS_S_STRING_TRUNCATED MAKE_DMHRESULTSUCCESS(0x210) + +/* DMUS_S_LAST_TOOL + * + * Returned from IDirectMusicGraph::StampPMsg(), this indicates that the PMsg + * is already stamped with the last tool in the graph. The returned PMsg's + * tool pointer is now NULL. + */ +#define DMUS_S_LAST_TOOL MAKE_DMHRESULTSUCCESS(0x211) + +/* DMUS_S_OVER_CHORD + * + * Returned from IDirectMusicPerformance::MusicToMIDI(), this indicates + * that no note has been calculated because the music value has the note + * at a position higher than the top note of the chord. This applies only + * to DMUS_PLAYMODE_NORMALCHORD play mode. This success code indicates + * that the caller should not do anything with the note. It is not meant + * to be played against this chord. + */ +#define DMUS_S_OVER_CHORD MAKE_DMHRESULTSUCCESS(0x212) + +/* DMUS_S_UP_OCTAVE + * + * Returned from IDirectMusicPerformance::MIDIToMusic(), and + * IDirectMusicPerformance::MusicToMIDI(), this indicates + * that the note conversion generated a note value that is below 0, + * so it has been bumped up one or more octaves to be in the proper + * MIDI range of 0 through 127. + * Note that this is valid for MIDIToMusic() when using play modes + * DMUS_PLAYMODE_FIXEDTOCHORD and DMUS_PLAYMODE_FIXEDTOKEY, both of + * which store MIDI values in wMusicValue. With MusicToMIDI(), it is + * valid for all play modes. + * Ofcourse, DMUS_PLAYMODE_FIXED will never return this success code. + */ +#define DMUS_S_UP_OCTAVE MAKE_DMHRESULTSUCCESS(0x213) + +/* DMUS_S_DOWN_OCTAVE + * + * Returned from IDirectMusicPerformance::MIDIToMusic(), and + * IDirectMusicPerformance::MusicToMIDI(), this indicates + * that the note conversion generated a note value that is above 127, + * so it has been bumped down one or more octaves to be in the proper + * MIDI range of 0 through 127. + * Note that this is valid for MIDIToMusic() when using play modes + * DMUS_PLAYMODE_FIXEDTOCHORD and DMUS_PLAYMODE_FIXEDTOKEY, both of + * which store MIDI values in wMusicValue. With MusicToMIDI(), it is + * valid for all play modes. + * Ofcourse, DMUS_PLAYMODE_FIXED will never return this success code. + */ +#define DMUS_S_DOWN_OCTAVE MAKE_DMHRESULTSUCCESS(0x214) + +/* DMUS_S_NOBUFFERCONTROL + * + * Although the audio output from the port will be routed to the + * same device as the given DirectSound buffer, buffer controls + * such as pan and volume will not affect the output. + * + */ +#define DMUS_S_NOBUFFERCONTROL MAKE_DMHRESULTSUCCESS(0x215) + +/* DMUS_S_GARBAGE_COLLECTED + * + * The requested operation was not performed because during CollectGarbage + * the loader determined that the object had been released. + */ +#define DMUS_S_GARBAGE_COLLECTED MAKE_DMHRESULTSUCCESS(0x216) + +/* DMUS_E_DRIVER_FAILED + * + * An unexpected error was returned from a device driver, indicating + * possible failure of the driver or hardware. + */ +#define DMUS_E_DRIVER_FAILED MAKE_DMHRESULTERROR(0x0101) + +/* DMUS_E_PORTS_OPEN + * + * The requested operation cannot be performed while there are + * instantiated ports in any process in the system. + */ +#define DMUS_E_PORTS_OPEN MAKE_DMHRESULTERROR(0x0102) + +/* DMUS_E_DEVICE_IN_USE + * + * The requested device is already in use (possibly by a non-DirectMusic + * client) and cannot be opened again. + */ +#define DMUS_E_DEVICE_IN_USE MAKE_DMHRESULTERROR(0x0103) + +/* DMUS_E_INSUFFICIENTBUFFER + * + * Buffer is not large enough for requested operation. + */ +#define DMUS_E_INSUFFICIENTBUFFER MAKE_DMHRESULTERROR(0x0104) + +/* DMUS_E_BUFFERNOTSET + * + * No buffer was prepared for the download data. + */ +#define DMUS_E_BUFFERNOTSET MAKE_DMHRESULTERROR(0x0105) + +/* DMUS_E_BUFFERNOTAVAILABLE + * + * Download failed due to inability to access or create download buffer. + */ +#define DMUS_E_BUFFERNOTAVAILABLE MAKE_DMHRESULTERROR(0x0106) + +/* DMUS_E_NOTADLSCOL + * + * Error parsing DLS collection. File is corrupt. + */ +#define DMUS_E_NOTADLSCOL MAKE_DMHRESULTERROR(0x0108) + +/* DMUS_E_INVALIDOFFSET + * + * Wave chunks in DLS collection file are at incorrect offsets. + */ +#define DMUS_E_INVALIDOFFSET MAKE_DMHRESULTERROR(0x0109) + +/* DMUS_E_ALREADY_LOADED + * + * Second attempt to load a DLS collection that is currently open. + */ +#define DMUS_E_ALREADY_LOADED MAKE_DMHRESULTERROR(0x0111) + +/* DMUS_E_INVALIDPOS + * + * Error reading wave data from DLS collection. Indicates bad file. + */ +#define DMUS_E_INVALIDPOS MAKE_DMHRESULTERROR(0x0113) + +/* DMUS_E_INVALIDPATCH + * + * There is no instrument in the collection that matches patch number. + */ +#define DMUS_E_INVALIDPATCH MAKE_DMHRESULTERROR(0x0114) + +/* DMUS_E_CANNOTSEEK + * + * The IStream* doesn't support Seek(). + */ +#define DMUS_E_CANNOTSEEK MAKE_DMHRESULTERROR(0x0115) + +/* DMUS_E_CANNOTWRITE + * + * The IStream* doesn't support Write(). + */ +#define DMUS_E_CANNOTWRITE MAKE_DMHRESULTERROR(0x0116) + +/* DMUS_E_CHUNKNOTFOUND + * + * The RIFF parser doesn't contain a required chunk while parsing file. + */ +#define DMUS_E_CHUNKNOTFOUND MAKE_DMHRESULTERROR(0x0117) + +/* DMUS_E_INVALID_DOWNLOADID + * + * Invalid download id was used in the process of creating a download buffer. + */ +#define DMUS_E_INVALID_DOWNLOADID MAKE_DMHRESULTERROR(0x0119) + +/* DMUS_E_NOT_DOWNLOADED_TO_PORT + * + * Tried to unload an object that was not downloaded or previously unloaded. + */ +#define DMUS_E_NOT_DOWNLOADED_TO_PORT MAKE_DMHRESULTERROR(0x0120) + +/* DMUS_E_ALREADY_DOWNLOADED + * + * Buffer was already downloaded to synth. + */ +#define DMUS_E_ALREADY_DOWNLOADED MAKE_DMHRESULTERROR(0x0121) + +/* DMUS_E_UNKNOWN_PROPERTY + * + * The specified property item was not recognized by the target object. + */ +#define DMUS_E_UNKNOWN_PROPERTY MAKE_DMHRESULTERROR(0x0122) + +/* DMUS_E_SET_UNSUPPORTED + * + * The specified property item may not be set on the target object. + */ +#define DMUS_E_SET_UNSUPPORTED MAKE_DMHRESULTERROR(0x0123) + +/* DMUS_E_GET_UNSUPPORTED + * + * The specified property item may not be retrieved from the target object. + */ +#define DMUS_E_GET_UNSUPPORTED MAKE_DMHRESULTERROR(0x0124) + +/* DMUS_E_NOTMONO + * + * Wave chunk has more than one interleaved channel. DLS format requires MONO. + */ +#define DMUS_E_NOTMONO MAKE_DMHRESULTERROR(0x0125) + +/* DMUS_E_BADARTICULATION + * + * Invalid articulation chunk in DLS collection. + */ +#define DMUS_E_BADARTICULATION MAKE_DMHRESULTERROR(0x0126) + +/* DMUS_E_BADINSTRUMENT + * + * Invalid instrument chunk in DLS collection. + */ +#define DMUS_E_BADINSTRUMENT MAKE_DMHRESULTERROR(0x0127) + +/* DMUS_E_BADWAVELINK + * + * Wavelink chunk in DLS collection points to invalid wave. + */ +#define DMUS_E_BADWAVELINK MAKE_DMHRESULTERROR(0x0128) + +/* DMUS_E_NOARTICULATION + * + * Articulation missing from instrument in DLS collection. + */ +#define DMUS_E_NOARTICULATION MAKE_DMHRESULTERROR(0x0129) + +/* DMUS_E_NOTPCM + * + * Downoaded DLS wave is not in PCM format. +*/ +#define DMUS_E_NOTPCM MAKE_DMHRESULTERROR(0x012A) + +/* DMUS_E_BADWAVE + * + * Bad wave chunk in DLS collection + */ +#define DMUS_E_BADWAVE MAKE_DMHRESULTERROR(0x012B) + +/* DMUS_E_BADOFFSETTABLE + * + * Offset Table for download buffer has errors. + */ +#define DMUS_E_BADOFFSETTABLE MAKE_DMHRESULTERROR(0x012C) + +/* DMUS_E_UNKNOWNDOWNLOAD + * + * Attempted to download unknown data type. + */ +#define DMUS_E_UNKNOWNDOWNLOAD MAKE_DMHRESULTERROR(0x012D) + +/* DMUS_E_NOSYNTHSINK + * + * The operation could not be completed because no sink was connected to + * the synthesizer. + */ +#define DMUS_E_NOSYNTHSINK MAKE_DMHRESULTERROR(0x012E) + +/* DMUS_E_ALREADYOPEN + * + * An attempt was made to open the software synthesizer while it was already + * open. + * ASSERT? + */ +#define DMUS_E_ALREADYOPEN MAKE_DMHRESULTERROR(0x012F) + +/* DMUS_E_ALREADYCLOSE + * + * An attempt was made to close the software synthesizer while it was already + * open. + * ASSERT? + */ +#define DMUS_E_ALREADYCLOSED MAKE_DMHRESULTERROR(0x0130) + +/* DMUS_E_SYNTHNOTCONFIGURED + * + * The operation could not be completed because the software synth has not + * yet been fully configured. + * ASSERT? + */ +#define DMUS_E_SYNTHNOTCONFIGURED MAKE_DMHRESULTERROR(0x0131) + +/* DMUS_E_SYNTHACTIVE + * + * The operation cannot be carried out while the synthesizer is active. + */ +#define DMUS_E_SYNTHACTIVE MAKE_DMHRESULTERROR(0x0132) + +/* DMUS_E_CANNOTREAD + * + * An error occurred while attempting to read from the IStream* object. + */ +#define DMUS_E_CANNOTREAD MAKE_DMHRESULTERROR(0x0133) + +/* DMUS_E_DMUSIC_RELEASED + * + * The operation cannot be performed because the final instance of the + * DirectMusic object was released. Ports cannot be used after final + * release of the DirectMusic object. + */ +#define DMUS_E_DMUSIC_RELEASED MAKE_DMHRESULTERROR(0x0134) + +/* DMUS_E_BUFFER_EMPTY + * + * There was no data in the referenced buffer. + */ +#define DMUS_E_BUFFER_EMPTY MAKE_DMHRESULTERROR(0x0135) + +/* DMUS_E_BUFFER_FULL + * + * There is insufficient space to insert the given event into the buffer. + */ +#define DMUS_E_BUFFER_FULL MAKE_DMHRESULTERROR(0x0136) + +/* DMUS_E_PORT_NOT_CAPTURE + * + * The given operation could not be carried out because the port is a + * capture port. + */ +#define DMUS_E_PORT_NOT_CAPTURE MAKE_DMHRESULTERROR(0x0137) + +/* DMUS_E_PORT_NOT_RENDER + * + * The given operation could not be carried out because the port is a + * render port. + */ +#define DMUS_E_PORT_NOT_RENDER MAKE_DMHRESULTERROR(0x0138) + +/* DMUS_E_DSOUND_NOT_SET + * + * The port could not be created because no DirectSound has been specified. + * Specify a DirectSound interface via the IDirectMusic::SetDirectSound + * method; pass NULL to have DirectMusic manage usage of DirectSound. + */ +#define DMUS_E_DSOUND_NOT_SET MAKE_DMHRESULTERROR(0x0139) + +/* DMUS_E_ALREADY_ACTIVATED + * + * The operation cannot be carried out while the port is active. + */ +#define DMUS_E_ALREADY_ACTIVATED MAKE_DMHRESULTERROR(0x013A) + +/* DMUS_E_INVALIDBUFFER + * + * Invalid DirectSound buffer was handed to port. + */ +#define DMUS_E_INVALIDBUFFER MAKE_DMHRESULTERROR(0x013B) + +/* DMUS_E_WAVEFORMATNOTSUPPORTED + * + * Invalid buffer format was handed to the synth sink. + */ +#define DMUS_E_WAVEFORMATNOTSUPPORTED MAKE_DMHRESULTERROR(0x013C) + +/* DMUS_E_SYNTHINACTIVE + * + * The operation cannot be carried out while the synthesizer is inactive. + */ +#define DMUS_E_SYNTHINACTIVE MAKE_DMHRESULTERROR(0x013D) + +/* DMUS_E_DSOUND_ALREADY_SET + * + * IDirectMusic::SetDirectSound has already been called. It may not be + * changed while in use. + */ +#define DMUS_E_DSOUND_ALREADY_SET MAKE_DMHRESULTERROR(0x013E) + +/* DMUS_E_INVALID_EVENT + * + * The given event is invalid (either it is not a valid MIDI message + * or it makes use of running status). The event cannot be packed + * into the buffer. + */ +#define DMUS_E_INVALID_EVENT MAKE_DMHRESULTERROR(0x013F) + +/* DMUS_E_UNSUPPORTED_STREAM + * + * The IStream* object does not contain data supported by the loading object. + */ +#define DMUS_E_UNSUPPORTED_STREAM MAKE_DMHRESULTERROR(0x0150) + +/* DMUS_E_ALREADY_INITED + * + * The object has already been initialized. + */ +#define DMUS_E_ALREADY_INITED MAKE_DMHRESULTERROR(0x0151) + +/* DMUS_E_INVALID_BAND + * + * The file does not contain a valid band. + */ +#define DMUS_E_INVALID_BAND MAKE_DMHRESULTERROR(0x0152) + +/* DMUS_E_TRACK_HDR_NOT_FIRST_CK + * + * The IStream* object's data does not have a track header as the first chunk, + * and therefore can not be read by the segment object. + */ +#define DMUS_E_TRACK_HDR_NOT_FIRST_CK MAKE_DMHRESULTERROR(0x0155) + +/* DMUS_E_TOOL_HDR_NOT_FIRST_CK + * + * The IStream* object's data does not have a tool header as the first chunk, + * and therefore can not be read by the graph object. + */ +#define DMUS_E_TOOL_HDR_NOT_FIRST_CK MAKE_DMHRESULTERROR(0x0156) + +/* DMUS_E_INVALID_TRACK_HDR + * + * The IStream* object's data contains an invalid track header (ckid is 0 and + * fccType is NULL,) and therefore can not be read by the segment object. + */ +#define DMUS_E_INVALID_TRACK_HDR MAKE_DMHRESULTERROR(0x0157) + +/* DMUS_E_INVALID_TOOL_HDR + * + * The IStream* object's data contains an invalid tool header (ckid is 0 and + * fccType is NULL,) and therefore can not be read by the graph object. + */ +#define DMUS_E_INVALID_TOOL_HDR MAKE_DMHRESULTERROR(0x0158) + +/* DMUS_E_ALL_TOOLS_FAILED + * + * The graph object was unable to load all tools from the IStream* object data. + * This may be due to errors in the stream, or the tools being incorrectly + * registered on the client. + */ +#define DMUS_E_ALL_TOOLS_FAILED MAKE_DMHRESULTERROR(0x0159) + +/* DMUS_E_ALL_TRACKS_FAILED + * + * The segment object was unable to load all tracks from the IStream* object data. + * This may be due to errors in the stream, or the tracks being incorrectly + * registered on the client. + */ +#define DMUS_E_ALL_TRACKS_FAILED MAKE_DMHRESULTERROR(0x0160) + +/* DMUS_E_NOT_FOUND + * + * The requested item was not contained by the object. + */ +#define DMUS_E_NOT_FOUND MAKE_DMHRESULTERROR(0x0161) + +/* DMUS_E_NOT_INIT + * + * A required object is not initialized or failed to initialize. + */ +#define DMUS_E_NOT_INIT MAKE_DMHRESULTERROR(0x0162) + +/* DMUS_E_TYPE_DISABLED + * + * The requested parameter type is currently disabled. Parameter types may + * be enabled and disabled by certain calls to SetParam(). + */ +#define DMUS_E_TYPE_DISABLED MAKE_DMHRESULTERROR(0x0163) + +/* DMUS_E_TYPE_UNSUPPORTED + * + * The requested parameter type is not supported on the object. + */ +#define DMUS_E_TYPE_UNSUPPORTED MAKE_DMHRESULTERROR(0x0164) + +/* DMUS_E_TIME_PAST + * + * The time is in the past, and the operation can not succeed. + */ +#define DMUS_E_TIME_PAST MAKE_DMHRESULTERROR(0x0165) + +/* DMUS_E_TRACK_NOT_FOUND + * + * The requested track is not contained by the segment. + */ +#define DMUS_E_TRACK_NOT_FOUND MAKE_DMHRESULTERROR(0x0166) + +/* DMUS_E_TRACK_NO_CLOCKTIME_SUPPORT + * + * The track does not support clock time playback or getparam. + */ +#define DMUS_E_TRACK_NO_CLOCKTIME_SUPPORT MAKE_DMHRESULTERROR(0x0167) + +/* DMUS_E_NO_MASTER_CLOCK + * + * There is no master clock in the performance. Be sure to call + * IDirectMusicPerformance::Init(). + */ +#define DMUS_E_NO_MASTER_CLOCK MAKE_DMHRESULTERROR(0x0170) + +/* DMUS_E_LOADER_NOCLASSID + * + * The class id field is required and missing in the DMUS_OBJECTDESC. + */ +#define DMUS_E_LOADER_NOCLASSID MAKE_DMHRESULTERROR(0x0180) + +/* DMUS_E_LOADER_BADPATH + * + * The requested file path is invalid. + */ +#define DMUS_E_LOADER_BADPATH MAKE_DMHRESULTERROR(0x0181) + +/* DMUS_E_LOADER_FAILEDOPEN + * + * File open failed - either file doesn't exist or is locked. + */ +#define DMUS_E_LOADER_FAILEDOPEN MAKE_DMHRESULTERROR(0x0182) + +/* DMUS_E_LOADER_FORMATNOTSUPPORTED + * + * Search data type is not supported. + */ +#define DMUS_E_LOADER_FORMATNOTSUPPORTED MAKE_DMHRESULTERROR(0x0183) + +/* DMUS_E_LOADER_FAILEDCREATE + * + * Unable to find or create object. + */ +#define DMUS_E_LOADER_FAILEDCREATE MAKE_DMHRESULTERROR(0x0184) + +/* DMUS_E_LOADER_OBJECTNOTFOUND + * + * Object was not found. + */ +#define DMUS_E_LOADER_OBJECTNOTFOUND MAKE_DMHRESULTERROR(0x0185) + +/* DMUS_E_LOADER_NOFILENAME + * + * The file name is missing from the DMUS_OBJECTDESC. + */ +#define DMUS_E_LOADER_NOFILENAME MAKE_DMHRESULTERROR(0x0186) + +/* DMUS_E_INVALIDFILE + * + * The file requested is not a valid file. + */ +#define DMUS_E_INVALIDFILE MAKE_DMHRESULTERROR(0x0200) + +/* DMUS_E_ALREADY_EXISTS + * + * The tool is already contained in the graph. Create a new instance. + */ +#define DMUS_E_ALREADY_EXISTS MAKE_DMHRESULTERROR(0x0201) + +/* DMUS_E_OUT_OF_RANGE + * + * Value is out of range, for instance the requested length is longer than + * the segment. + */ +#define DMUS_E_OUT_OF_RANGE MAKE_DMHRESULTERROR(0x0202) + +/* DMUS_E_SEGMENT_INIT_FAILED + * + * Segment initialization failed, most likely due to a critical memory situation. + */ +#define DMUS_E_SEGMENT_INIT_FAILED MAKE_DMHRESULTERROR(0x0203) + +/* DMUS_E_ALREADY_SENT + * + * The DMUS_PMSG has already been sent to the performance object via + * IDirectMusicPerformance::SendPMsg(). + */ +#define DMUS_E_ALREADY_SENT MAKE_DMHRESULTERROR(0x0204) + +/* DMUS_E_CANNOT_FREE + * + * The DMUS_PMSG was either not allocated by the performance via + * IDirectMusicPerformance::AllocPMsg(), or it was already freed via + * IDirectMusicPerformance::FreePMsg(). + */ +#define DMUS_E_CANNOT_FREE MAKE_DMHRESULTERROR(0x0205) + +/* DMUS_E_CANNOT_OPEN_PORT + * + * The default system port could not be opened. + */ +#define DMUS_E_CANNOT_OPEN_PORT MAKE_DMHRESULTERROR(0x0206) + +/* DMUS_E_CANNOT_CONVERT + * + * A call to MIDIToMusic() or MusicToMIDI() resulted in an error because + * the requested conversion could not happen. This usually occurs when the + * provided DMUS_CHORD_KEY structure has an invalid chord or scale pattern. + */ +#define DMUS_E_CANNOT_CONVERT MAKE_DMHRESULTERROR(0x0207) +/* misspelling in previous versions of DirectX preserved for backward compatibility */ +#define DMUS_E_CONNOT_CONVERT DMUS_E_CANNOT_CONVERT + +/* DMUS_E_DESCEND_CHUNK_FAIL + * + * DMUS_E_DESCEND_CHUNK_FAIL is returned when the end of the file + * was reached before the desired chunk was found. + */ +#define DMUS_E_DESCEND_CHUNK_FAIL MAKE_DMHRESULTERROR(0x0210) + +/* DMUS_E_NOT_LOADED + * + * An attempt to use this object failed because it first needs to + * be loaded. + */ +#define DMUS_E_NOT_LOADED MAKE_DMHRESULTERROR(0x0211) + +/* DMUS_E_SCRIPT_LANGUAGE_INCOMPATIBLE + * + * The activeX scripting engine for the script's language is not compatible with + * DirectMusic. + * + */ +#define DMUS_E_SCRIPT_LANGUAGE_INCOMPATIBLE MAKE_DMHRESULTERROR(0x0213) + +/* DMUS_E_SCRIPT_UNSUPPORTED_VARTYPE + * + * A varient was used that had a type that is not supported by DirectMusic. + * + */ +#define DMUS_E_SCRIPT_UNSUPPORTED_VARTYPE MAKE_DMHRESULTERROR(0x0214) + +/* DMUS_E_SCRIPT_ERROR_IN_SCRIPT + * + * An error was encountered while parsing or executing the script. + * The pErrorInfo parameter (if supplied) was filled with information about the error. + */ +#define DMUS_E_SCRIPT_ERROR_IN_SCRIPT MAKE_DMHRESULTERROR(0x0215) + +/* DMUS_E_SCRIPT_CANTLOAD_OLEAUT32 + * + * Loading of oleaut32.dll failed. VBScript and other activeX scripting languages + * require use of oleaut32.dll. On platforms where oleaut32.dll is not present, only + * the DirectMusicScript language, which doesn't require oleaut32.dll can be used. + */ +#define DMUS_E_SCRIPT_CANTLOAD_OLEAUT32 MAKE_DMHRESULTERROR(0x0216) + +/* DMUS_E_SCRIPT_LOADSCRIPT_ERROR + * + * An error occured while parsing a script loaded using LoadScript. The script that + * was loaded contains an error. + */ +#define DMUS_E_SCRIPT_LOADSCRIPT_ERROR MAKE_DMHRESULTERROR(0x0217) + +/* DMUS_E_SCRIPT_INVALID_FILE + * + * The script file is invalid. + */ +#define DMUS_E_SCRIPT_INVALID_FILE MAKE_DMHRESULTERROR(0x0218) + +/* DMUS_E_INVALID_SCRIPTTRACK + * + * The file contains an invalid script track. + */ +#define DMUS_E_INVALID_SCRIPTTRACK MAKE_DMHRESULTERROR(0x0219) + +/* DMUS_E_SCRIPT_VARIABLE_NOT_FOUND + * + * The script does not contain a variable with the specified name. + */ +#define DMUS_E_SCRIPT_VARIABLE_NOT_FOUND MAKE_DMHRESULTERROR(0x021A) + +/* DMUS_E_SCRIPT_ROUTINE_NOT_FOUND + * + * The script does not contain a routine with the specified name. + */ +#define DMUS_E_SCRIPT_ROUTINE_NOT_FOUND MAKE_DMHRESULTERROR(0x021B) + +/* DMUS_E_SCRIPT_CONTENT_READONLY + * + * Scripts variables for content referenced or embedded in a script cannot be set. + */ +#define DMUS_E_SCRIPT_CONTENT_READONLY MAKE_DMHRESULTERROR(0x021C) + +/* DMUS_E_SCRIPT_NOT_A_REFERENCE + * + * Attempt was made to set a script's variable by reference to a value that was + * not an object type. + */ +#define DMUS_E_SCRIPT_NOT_A_REFERENCE MAKE_DMHRESULTERROR(0x021D) + +/* DMUS_E_SCRIPT_VALUE_NOT_SUPPORTED + * + * Attempt was made to set a script's variable by value to an object that does + * not support a default value property. + */ +#define DMUS_E_SCRIPT_VALUE_NOT_SUPPORTED MAKE_DMHRESULTERROR(0x021E) + +/* DMUS_E_INVALID_SEGMENTTRIGGERTRACK + * + * The file contains an invalid segment trigger track. + */ +#define DMUS_E_INVALID_SEGMENTTRIGGERTRACK MAKE_DMHRESULTERROR(0x0220) + +/* DMUS_E_INVALID_LYRICSTRACK + * + * The file contains an invalid lyrics track. + */ +#define DMUS_E_INVALID_LYRICSTRACK MAKE_DMHRESULTERROR(0x0221) + +/* DMUS_E_INVALID_PARAMCONTROLTRACK + * + * The file contains an invalid parameter control track. + */ +#define DMUS_E_INVALID_PARAMCONTROLTRACK MAKE_DMHRESULTERROR(0x0222) + +/* DMUS_E_AUDIOVBSCRIPT_SYNTAXERROR + * + * A script written in AudioVBScript could not be read because it contained a statement that + * is not allowed by the AudioVBScript language. + */ +#define DMUS_E_AUDIOVBSCRIPT_SYNTAXERROR MAKE_DMHRESULTERROR(0x0223) + +/* DMUS_E_AUDIOVBSCRIPT_RUNTIMEERROR + * + * A script routine written in AudioVBScript failed because an invalid operation occurred. For example, + * adding the number 3 to a segment object would produce this error. So would attempting to call a routine + * that doesn't exist. + */ +#define DMUS_E_AUDIOVBSCRIPT_RUNTIMEERROR MAKE_DMHRESULTERROR(0x0224) + +/* DMUS_E_AUDIOVBSCRIPT_OPERATIONFAILURE + * + * A script routine written in AudioVBScript failed because a function outside of a script failed to complete. + * For example, a call to PlaySegment that fails to play because of low memory would return this error. + */ +#define DMUS_E_AUDIOVBSCRIPT_OPERATIONFAILURE MAKE_DMHRESULTERROR(0x0225) + +/* DMUS_E_AUDIOPATHS_NOT_VALID + * + * The Performance has set up some PChannels using the AssignPChannel command, which + * makes it not capable of supporting audio paths. + */ +#define DMUS_E_AUDIOPATHS_NOT_VALID MAKE_DMHRESULTERROR(0x0226) + +/* DMUS_E_AUDIOPATHS_IN_USE + * + * This is the inverse of the previous error. + * The Performance has set up some audio paths, which makes is incompatible + * with the calls to allocate pchannels, etc. + */ +#define DMUS_E_AUDIOPATHS_IN_USE MAKE_DMHRESULTERROR(0x0227) + +/* DMUS_E_NO_AUDIOPATH_CONFIG + * + * A segment was asked for its embedded audio path configuration, + * but there isn't any. + */ +#define DMUS_E_NO_AUDIOPATH_CONFIG MAKE_DMHRESULTERROR(0x0228) + +/* DMUS_E_AUDIOPATH_INACTIVE + * + * An audiopath is inactive, perhaps because closedown was called. + */ +#define DMUS_E_AUDIOPATH_INACTIVE MAKE_DMHRESULTERROR(0x0229) + +/* DMUS_E_AUDIOPATH_NOBUFFER + * + * An audiopath failed to create because a requested buffer could not be created. + */ +#define DMUS_E_AUDIOPATH_NOBUFFER MAKE_DMHRESULTERROR(0x022A) + +/* DMUS_E_AUDIOPATH_NOPORT + * + * An audiopath could not be used for playback because it lacked port assignments. + */ +#define DMUS_E_AUDIOPATH_NOPORT MAKE_DMHRESULTERROR(0x022B) + +/* DMUS_E_NO_AUDIOPATH + * + * Attempt was made to play segment in audiopath mode and there was no audiopath. + */ +#define DMUS_E_NO_AUDIOPATH MAKE_DMHRESULTERROR(0x022C) + +/* DMUS_E_INVALIDCHUNK + * + * Invalid data was found in a RIFF file chunk. + */ +#define DMUS_E_INVALIDCHUNK MAKE_DMHRESULTERROR(0x022D) + +/* DMUS_E_AUDIOPATH_NOGLOBALFXBUFFER + * + * Attempt was made to create an audiopath that sends to a global effects buffer which did not exist. + */ +#define DMUS_E_AUDIOPATH_NOGLOBALFXBUFFER MAKE_DMHRESULTERROR(0x022E) + +/* DMUS_E_INVALID_CONTAINER_OBJECT + * + * The file does not contain a valid container object. + */ +#define DMUS_E_INVALID_CONTAINER_OBJECT MAKE_DMHRESULTERROR(0x022F) + +#endif diff --git a/src/dep/include/DXSDK/include/dmksctrl.h b/src/dep/include/DXSDK/include/dmksctrl.h index 2f81bac..f53e714 100644 --- a/src/dep/include/DXSDK/include/dmksctrl.h +++ b/src/dep/include/DXSDK/include/dmksctrl.h @@ -1,166 +1,166 @@ -/************************************************************************ -* * -* dmksctrl.h -- Definition of IKsControl * -* * -* Copyright (c) Microsoft Corporation. All rights reserved. * -* * -* This header file contains the definition of IKsControl, which * -* duplicates definitions from ks.h and ksproxy.h. Your code should * -* include ks.h and ksproxy.h directly if you have them (they are * -* provided in the Windows 98 DDK and will be in the Windows NT 5 * -* SDK). * -* * -************************************************************************/ - -#ifndef _DMKSCTRL_ -#define _DMKSCTRL_ - -#if _MSC_VER >= 1200 -#pragma warning(push) -#endif -#pragma warning(disable:4201) /* Disable warnings on anonymous unions */ - -#include - -#include - -#if !defined(_NTRTL_) - #ifndef DEFINE_GUIDEX - #define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name - #endif /* !defined(DEFINE_GUIDEX) */ - - #ifndef STATICGUIDOF - #define STATICGUIDOF(guid) STATIC_##guid - #endif /* !defined(STATICGUIDOF) */ -#endif /* !defined(_NTRTL_) */ - -#ifndef STATIC_IID_IKsControl -#define STATIC_IID_IKsControl\ - 0x28F54685L, 0x06FD, 0x11D2, 0xB2, 0x7A, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96 -#endif /* STATIC_IID_IKsControl */ - -/* - * Warning: This will prevent the rest of ks.h from being pulled in if ks.h is - * included after dmksctrl.h. Make sure you do not include both headers in - * the same source file. - */ -#ifndef _KS_ -#define _KS_ - -#if (defined(_MSC_EXTENSIONS) || defined(__cplusplus)) && !defined(CINTERFACE) -typedef struct { - union { - struct { - GUID Set; - ULONG Id; - ULONG Flags; - }; - LONGLONG Alignment; - }; -} KSIDENTIFIER, *PKSIDENTIFIER; -#else -typedef struct { - union { - struct { - GUID Set; - ULONG Id; - ULONG Flags; - } Data; - LONGLONG Alignment; - }; -} KSIDENTIFIER, *PKSIDENTIFIER; -#endif - -typedef KSIDENTIFIER KSPROPERTY, *PKSPROPERTY, KSMETHOD, *PKSMETHOD, KSEVENT, *PKSEVENT; - -#define KSMETHOD_TYPE_NONE 0x00000000 -#define KSMETHOD_TYPE_READ 0x00000001 -#define KSMETHOD_TYPE_WRITE 0x00000002 -#define KSMETHOD_TYPE_MODIFY 0x00000003 -#define KSMETHOD_TYPE_SOURCE 0x00000004 - -#define KSMETHOD_TYPE_SEND 0x00000001 -#define KSMETHOD_TYPE_SETSUPPORT 0x00000100 -#define KSMETHOD_TYPE_BASICSUPPORT 0x00000200 - -#define KSPROPERTY_TYPE_GET 0x00000001 -#define KSPROPERTY_TYPE_SET 0x00000002 -#define KSPROPERTY_TYPE_SETSUPPORT 0x00000100 -#define KSPROPERTY_TYPE_BASICSUPPORT 0x00000200 -#define KSPROPERTY_TYPE_RELATIONS 0x00000400 -#define KSPROPERTY_TYPE_SERIALIZESET 0x00000800 -#define KSPROPERTY_TYPE_UNSERIALIZESET 0x00001000 -#define KSPROPERTY_TYPE_SERIALIZERAW 0x00002000 -#define KSPROPERTY_TYPE_UNSERIALIZERAW 0x00004000 -#define KSPROPERTY_TYPE_SERIALIZESIZE 0x00008000 -#define KSPROPERTY_TYPE_DEFAULTVALUES 0x00010000 - -#define KSPROPERTY_TYPE_TOPOLOGY 0x10000000 -#endif /* _KS_ */ - -#ifndef _IKsControl_ -#define _IKsControl_ - -#ifdef DECLARE_INTERFACE_ - - -#undef INTERFACE -#define INTERFACE IKsControl -DECLARE_INTERFACE_(IKsControl, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /*IKsControl*/ - STDMETHOD(KsProperty)( - THIS_ - IN PKSPROPERTY Property, - IN ULONG PropertyLength, - IN OUT LPVOID PropertyData, - IN ULONG DataLength, - OUT ULONG* BytesReturned - ) PURE; - STDMETHOD(KsMethod)( - THIS_ - IN PKSMETHOD Method, - IN ULONG MethodLength, - IN OUT LPVOID MethodData, - IN ULONG DataLength, - OUT ULONG* BytesReturned - ) PURE; - STDMETHOD(KsEvent)( - THIS_ - IN PKSEVENT Event OPTIONAL, - IN ULONG EventLength, - IN OUT LPVOID EventData, - IN ULONG DataLength, - OUT ULONG* BytesReturned - ) PURE; -}; - -#endif /* DECLARE_INTERFACE_ */ -#endif /* _IKsControl_ */ - -#include - -DEFINE_GUID(IID_IKsControl, 0x28F54685, 0x06FD, 0x11D2, 0xB2, 0x7A, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96); - -/* These formats are in ksmedia.h - */ -#ifndef _KSMEDIA_ - -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_MIDI, 0x1D262760L, 0xE957, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00); -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_DIRECTMUSIC, 0x1a82f8bc, 0x3f8b, 0x11d2, 0xb7, 0x74, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1); - -#endif - -#if _MSC_VER >= 1200 -#pragma warning(pop) -#endif - -#endif /* _DMKSCTRL */ - - - +/************************************************************************ +* * +* dmksctrl.h -- Definition of IKsControl * +* * +* Copyright (c) Microsoft Corporation. All rights reserved. * +* * +* This header file contains the definition of IKsControl, which * +* duplicates definitions from ks.h and ksproxy.h. Your code should * +* include ks.h and ksproxy.h directly if you have them (they are * +* provided in the Windows 98 DDK and will be in the Windows NT 5 * +* SDK). * +* * +************************************************************************/ + +#ifndef _DMKSCTRL_ +#define _DMKSCTRL_ + +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif +#pragma warning(disable:4201) /* Disable warnings on anonymous unions */ + +#include + +#include + +#if !defined(_NTRTL_) + #ifndef DEFINE_GUIDEX + #define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name + #endif /* !defined(DEFINE_GUIDEX) */ + + #ifndef STATICGUIDOF + #define STATICGUIDOF(guid) STATIC_##guid + #endif /* !defined(STATICGUIDOF) */ +#endif /* !defined(_NTRTL_) */ + +#ifndef STATIC_IID_IKsControl +#define STATIC_IID_IKsControl\ + 0x28F54685L, 0x06FD, 0x11D2, 0xB2, 0x7A, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96 +#endif /* STATIC_IID_IKsControl */ + +/* + * Warning: This will prevent the rest of ks.h from being pulled in if ks.h is + * included after dmksctrl.h. Make sure you do not include both headers in + * the same source file. + */ +#ifndef _KS_ +#define _KS_ + +#if (defined(_MSC_EXTENSIONS) || defined(__cplusplus)) && !defined(CINTERFACE) +typedef struct { + union { + struct { + GUID Set; + ULONG Id; + ULONG Flags; + }; + LONGLONG Alignment; + }; +} KSIDENTIFIER, *PKSIDENTIFIER; +#else +typedef struct { + union { + struct { + GUID Set; + ULONG Id; + ULONG Flags; + } Data; + LONGLONG Alignment; + }; +} KSIDENTIFIER, *PKSIDENTIFIER; +#endif + +typedef KSIDENTIFIER KSPROPERTY, *PKSPROPERTY, KSMETHOD, *PKSMETHOD, KSEVENT, *PKSEVENT; + +#define KSMETHOD_TYPE_NONE 0x00000000 +#define KSMETHOD_TYPE_READ 0x00000001 +#define KSMETHOD_TYPE_WRITE 0x00000002 +#define KSMETHOD_TYPE_MODIFY 0x00000003 +#define KSMETHOD_TYPE_SOURCE 0x00000004 + +#define KSMETHOD_TYPE_SEND 0x00000001 +#define KSMETHOD_TYPE_SETSUPPORT 0x00000100 +#define KSMETHOD_TYPE_BASICSUPPORT 0x00000200 + +#define KSPROPERTY_TYPE_GET 0x00000001 +#define KSPROPERTY_TYPE_SET 0x00000002 +#define KSPROPERTY_TYPE_SETSUPPORT 0x00000100 +#define KSPROPERTY_TYPE_BASICSUPPORT 0x00000200 +#define KSPROPERTY_TYPE_RELATIONS 0x00000400 +#define KSPROPERTY_TYPE_SERIALIZESET 0x00000800 +#define KSPROPERTY_TYPE_UNSERIALIZESET 0x00001000 +#define KSPROPERTY_TYPE_SERIALIZERAW 0x00002000 +#define KSPROPERTY_TYPE_UNSERIALIZERAW 0x00004000 +#define KSPROPERTY_TYPE_SERIALIZESIZE 0x00008000 +#define KSPROPERTY_TYPE_DEFAULTVALUES 0x00010000 + +#define KSPROPERTY_TYPE_TOPOLOGY 0x10000000 +#endif /* _KS_ */ + +#ifndef _IKsControl_ +#define _IKsControl_ + +#ifdef DECLARE_INTERFACE_ + + +#undef INTERFACE +#define INTERFACE IKsControl +DECLARE_INTERFACE_(IKsControl, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /*IKsControl*/ + STDMETHOD(KsProperty)( + THIS_ + IN PKSPROPERTY Property, + IN ULONG PropertyLength, + IN OUT LPVOID PropertyData, + IN ULONG DataLength, + OUT ULONG* BytesReturned + ) PURE; + STDMETHOD(KsMethod)( + THIS_ + IN PKSMETHOD Method, + IN ULONG MethodLength, + IN OUT LPVOID MethodData, + IN ULONG DataLength, + OUT ULONG* BytesReturned + ) PURE; + STDMETHOD(KsEvent)( + THIS_ + IN PKSEVENT Event OPTIONAL, + IN ULONG EventLength, + IN OUT LPVOID EventData, + IN ULONG DataLength, + OUT ULONG* BytesReturned + ) PURE; +}; + +#endif /* DECLARE_INTERFACE_ */ +#endif /* _IKsControl_ */ + +#include + +DEFINE_GUID(IID_IKsControl, 0x28F54685, 0x06FD, 0x11D2, 0xB2, 0x7A, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96); + +/* These formats are in ksmedia.h + */ +#ifndef _KSMEDIA_ + +DEFINE_GUID(KSDATAFORMAT_SUBTYPE_MIDI, 0x1D262760L, 0xE957, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00); +DEFINE_GUID(KSDATAFORMAT_SUBTYPE_DIRECTMUSIC, 0x1a82f8bc, 0x3f8b, 0x11d2, 0xb7, 0x74, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1); + +#endif + +#if _MSC_VER >= 1200 +#pragma warning(pop) +#endif + +#endif /* _DMKSCTRL */ + + + diff --git a/src/dep/include/DXSDK/include/dmplugin.h b/src/dep/include/DXSDK/include/dmplugin.h index 7c7d311..3f3e141 100644 --- a/src/dep/include/DXSDK/include/dmplugin.h +++ b/src/dep/include/DXSDK/include/dmplugin.h @@ -1,280 +1,280 @@ -/************************************************************************ -* * -* dmplugin.h -- This module contains the API for plugins for the * -* DirectMusic performance layer * -* * -* Copyright (c) Microsoft Corporation. All rights reserved. * -* * -************************************************************************/ - -#ifndef _DMPLUGIN_ -#define _DMPLUGIN_ - -#include - -#define COM_NO_WINDOWS_H -#include - -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -interface IDirectMusicTrack; -interface IDirectMusicTool; -interface IDirectMusicTool8; -interface IDirectMusicTrack8; -interface IDirectMusicPerformance; -interface IDirectMusicPerformance8; -interface IDirectMusicSegment; -interface IDirectMusicSegment8; -interface IDirectMusicSegmentState; -interface IDirectMusicSegmentState8; -interface IDirectMusicGraph; -#ifndef __cplusplus -typedef interface IDirectMusicTrack IDirectMusicTrack; -typedef interface IDirectMusicTool IDirectMusicTool; -typedef interface IDirectMusicTool8 IDirectMusicTool8; -typedef interface IDirectMusicTrack8 IDirectMusicTrack8; -typedef interface IDirectMusicPerformance IDirectMusicPerformance; -typedef interface IDirectMusicPerformance8 IDirectMusicPerformance8; -typedef interface IDirectMusicSegment IDirectMusicSegment; -typedef interface IDirectMusicSegment8 IDirectMusicSegment8; -typedef interface IDirectMusicSegmentState IDirectMusicSegmentState; -typedef interface IDirectMusicSegmentState8 IDirectMusicSegmentState8; -typedef interface IDirectMusicGraph IDirectMusicGraph; -#endif - -typedef struct _DMUS_PMSG DMUS_PMSG; -typedef long MUSIC_TIME; - -/* Registry location for tools */ -#define DMUS_REGSTR_PATH_TOOLS "Software\\Microsoft\\DirectMusic\\Tools" - -/*//////////////////////////////////////////////////////////////////// -// IDirectMusicTool */ -#undef INTERFACE -#define INTERFACE IDirectMusicTool -DECLARE_INTERFACE_(IDirectMusicTool, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicTool */ - STDMETHOD(Init) (THIS_ IDirectMusicGraph* pGraph) PURE; - STDMETHOD(GetMsgDeliveryType) (THIS_ DWORD* pdwDeliveryType ) PURE; - STDMETHOD(GetMediaTypeArraySize)(THIS_ DWORD* pdwNumElements ) PURE; - STDMETHOD(GetMediaTypes) (THIS_ DWORD** padwMediaTypes, - DWORD dwNumElements) PURE; - STDMETHOD(ProcessPMsg) (THIS_ IDirectMusicPerformance* pPerf, - DMUS_PMSG* pPMSG) PURE; - STDMETHOD(Flush) (THIS_ IDirectMusicPerformance* pPerf, - DMUS_PMSG* pPMSG, - REFERENCE_TIME rtTime) PURE; -}; - -/*//////////////////////////////////////////////////////////////////// -// IDirectMusicTool8 */ -#undef INTERFACE -#define INTERFACE IDirectMusicTool8 -DECLARE_INTERFACE_(IDirectMusicTool8, IDirectMusicTool) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicTool */ - STDMETHOD(Init) (THIS_ IDirectMusicGraph* pGraph) PURE; - STDMETHOD(GetMsgDeliveryType) (THIS_ DWORD* pdwDeliveryType ) PURE; - STDMETHOD(GetMediaTypeArraySize)(THIS_ DWORD* pdwNumElements ) PURE; - STDMETHOD(GetMediaTypes) (THIS_ DWORD** padwMediaTypes, - DWORD dwNumElements) PURE; - STDMETHOD(ProcessPMsg) (THIS_ IDirectMusicPerformance* pPerf, - DMUS_PMSG* pPMSG) PURE; - STDMETHOD(Flush) (THIS_ IDirectMusicPerformance* pPerf, - DMUS_PMSG* pPMSG, - REFERENCE_TIME rtTime) PURE; - /* IDirectMusicTool8 */ - STDMETHOD(Clone) (THIS_ IDirectMusicTool ** ppTool) PURE; -}; - - -/* The following flags are sent in the IDirectMusicTrack::Play() method */ -/* inside the dwFlags parameter */ -typedef enum enumDMUS_TRACKF_FLAGS -{ - DMUS_TRACKF_SEEK = 1, /* set on a seek */ - DMUS_TRACKF_LOOP = 2, /* set on a loop (repeat) */ - DMUS_TRACKF_START = 4, /* set on first call to Play */ - DMUS_TRACKF_FLUSH = 8, /* set when this call is in response to a flush on the perfomance */ - DMUS_TRACKF_DIRTY = 0x10, /* set when the track should consider any cached values from a previous call to GetParam to be invalidated */ - /* The following flags are DX8 only. */ - DMUS_TRACKF_NOTIFY_OFF = 0x20, /* tells track not to send notifications. */ - DMUS_TRACKF_PLAY_OFF = 0x40, /* tells track not to play anything (but can still send notifications.) */ - DMUS_TRACKF_LOOPEND = 0x80, /* set when the end of range is also a loop end. */ - DMUS_TRACKF_STOP = 0x100, /* set when the end of range is also end of playing this segment. */ - DMUS_TRACKF_RECOMPOSE = 0x200, /* set to indicate the track should compose. */ - DMUS_TRACKF_CLOCK = 0x400, /* set when time parameters are in reference (clock) time. Only valid for PlayEx(). */ -} DMUS_TRACKF_FLAGS; - -/* The following flags are sent in the IDirectMusicTrack8::GetParamEx() and SetParamEx() methods */ -/* inside the dwFlags parameter */ -#define DMUS_TRACK_PARAMF_CLOCK 0x01 /* set when the time is measured is in reference (clock) time */ - -/*//////////////////////////////////////////////////////////////////// -// IDirectMusicTrack */ -#undef INTERFACE -#define INTERFACE IDirectMusicTrack -DECLARE_INTERFACE_(IDirectMusicTrack, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicTrack */ - STDMETHOD(Init) (THIS_ IDirectMusicSegment* pSegment) PURE; - STDMETHOD(InitPlay) (THIS_ IDirectMusicSegmentState* pSegmentState, - IDirectMusicPerformance* pPerformance, - void** ppStateData, - DWORD dwVirtualTrackID, - DWORD dwFlags) PURE; - STDMETHOD(EndPlay) (THIS_ void* pStateData) PURE; - STDMETHOD(Play) (THIS_ void* pStateData, - MUSIC_TIME mtStart, - MUSIC_TIME mtEnd, - MUSIC_TIME mtOffset, - DWORD dwFlags, - IDirectMusicPerformance* pPerf, - IDirectMusicSegmentState* pSegSt, - DWORD dwVirtualID) PURE; - STDMETHOD(GetParam) (THIS_ REFGUID rguidType, - MUSIC_TIME mtTime, - MUSIC_TIME* pmtNext, - void* pParam) PURE; - STDMETHOD(SetParam) (THIS_ REFGUID rguidType, - MUSIC_TIME mtTime, - void* pParam) PURE; - STDMETHOD(IsParamSupported) (THIS_ REFGUID rguidType) PURE; - STDMETHOD(AddNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; - STDMETHOD(RemoveNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; - STDMETHOD(Clone) (THIS_ MUSIC_TIME mtStart, - MUSIC_TIME mtEnd, - IDirectMusicTrack** ppTrack) PURE; -}; - -/*//////////////////////////////////////////////////////////////////// -// IDirectMusicTrack8 */ -#undef INTERFACE -#define INTERFACE IDirectMusicTrack8 -DECLARE_INTERFACE_(IDirectMusicTrack8, IDirectMusicTrack) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicTrack */ - STDMETHOD(Init) (THIS_ IDirectMusicSegment* pSegment) PURE; - STDMETHOD(InitPlay) (THIS_ IDirectMusicSegmentState* pSegmentState, - IDirectMusicPerformance* pPerformance, - void** ppStateData, - DWORD dwVirtualTrackID, - DWORD dwFlags) PURE; - STDMETHOD(EndPlay) (THIS_ void* pStateData) PURE; - STDMETHOD(Play) (THIS_ void* pStateData, - MUSIC_TIME mtStart, - MUSIC_TIME mtEnd, - MUSIC_TIME mtOffset, - DWORD dwFlags, - IDirectMusicPerformance* pPerf, - IDirectMusicSegmentState* pSegSt, - DWORD dwVirtualID) PURE; - STDMETHOD(GetParam) (THIS_ REFGUID rguidType, - MUSIC_TIME mtTime, - MUSIC_TIME* pmtNext, - void* pParam) PURE; - STDMETHOD(SetParam) (THIS_ REFGUID rguidType, - MUSIC_TIME mtTime, - void* pParam) PURE; - STDMETHOD(IsParamSupported) (THIS_ REFGUID rguidType) PURE; - STDMETHOD(AddNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; - STDMETHOD(RemoveNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; - STDMETHOD(Clone) (THIS_ MUSIC_TIME mtStart, - MUSIC_TIME mtEnd, - IDirectMusicTrack** ppTrack) PURE; - /* IDirectMusicTrack8 */ - STDMETHOD(PlayEx) (THIS_ void* pStateData, - REFERENCE_TIME rtStart, - REFERENCE_TIME rtEnd, - REFERENCE_TIME rtOffset, - DWORD dwFlags, - IDirectMusicPerformance* pPerf, - IDirectMusicSegmentState* pSegSt, - DWORD dwVirtualID) PURE; - STDMETHOD(GetParamEx) (THIS_ REFGUID rguidType, /* Command type. */ - REFERENCE_TIME rtTime, /* Time, in ref time if dwFlags == DMUS_TRACK_PARAMF_CLOCK. Otherwise, music time. */ - REFERENCE_TIME* prtNext, /* Time of next parameter, relative to rtTime, in music or clock time units. */ - void* pParam, /* Pointer to the parameter data. */ - void * pStateData, /* State data for track instance. */ - DWORD dwFlags) PURE; /* Control flags. */ - STDMETHOD(SetParamEx) (THIS_ REFGUID rguidType, - REFERENCE_TIME rtTime, - void* pParam, /* Pointer to the parameter data. */ - void * pStateData, /* State data for track instance. */ - DWORD dwFlags) PURE; /* Control flags. */ - STDMETHOD(Compose) (THIS_ IUnknown* pContext, /* Context for composition */ - DWORD dwTrackGroup, - IDirectMusicTrack** ppResultTrack) PURE; - STDMETHOD(Join) (THIS_ IDirectMusicTrack* pNewTrack, - MUSIC_TIME mtJoin, - IUnknown* pContext, /* Context for joining */ - DWORD dwTrackGroup, - IDirectMusicTrack** ppResultTrack) PURE; -}; - -/* CLSID's */ -DEFINE_GUID(CLSID_DirectMusicTempoTrack,0xd2ac2885, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicSeqTrack,0xd2ac2886, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicSysExTrack,0xd2ac2887, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicTimeSigTrack,0xd2ac2888, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicChordTrack,0xd2ac288b, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicCommandTrack,0xd2ac288c, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicStyleTrack,0xd2ac288d, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicMotifTrack,0xd2ac288e, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicSignPostTrack,0xf17e8672, 0xc3b4, 0x11d1, 0x87, 0xb, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicBandTrack,0xd2ac2894, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicChordMapTrack,0xd2ac2896, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicMuteTrack,0xd2ac2898, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* New CLSID's for DX8 */ -DEFINE_GUID(CLSID_DirectMusicScriptTrack,0x4108fa85, 0x3586, 0x11d3, 0x8b, 0xd7, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xb6); /* {4108FA85-3586-11d3-8BD7-00600893B1B6} */ -DEFINE_GUID(CLSID_DirectMusicMarkerTrack,0x55a8fd00, 0x4288, 0x11d3, 0x9b, 0xd1, 0x8a, 0xd, 0x61, 0xc8, 0x88, 0x35); -DEFINE_GUID(CLSID_DirectMusicSegmentTriggerTrack, 0xbae4d665, 0x4ea1, 0x11d3, 0x8b, 0xda, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xb6); /* {BAE4D665-4EA1-11d3-8BDA-00600893B1B6} */ -DEFINE_GUID(CLSID_DirectMusicLyricsTrack, 0x995c1cf5, 0x54ff, 0x11d3, 0x8b, 0xda, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xb6); /* {995C1CF5-54FF-11d3-8BDA-00600893B1B6} */ -DEFINE_GUID(CLSID_DirectMusicParamControlTrack, 0x4be0537b, 0x5c19, 0x11d3, 0x8b, 0xdc, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xb6); /* {4BE0537B-5C19-11d3-8BDC-00600893B1B6} */ -DEFINE_GUID(CLSID_DirectMusicWaveTrack,0xeed36461, 0x9ea5, 0x11d3, 0x9b, 0xd1, 0x0, 0x80, 0xc7, 0x15, 0xa, 0x74); - -/* IID's */ -DEFINE_GUID(IID_IDirectMusicTrack, 0xf96029a1, 0x4282, 0x11d2, 0x87, 0x17, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(IID_IDirectMusicTool,0xd2ac28ba, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Interface IDs for DX8 */ -/* changed interfaces (GUID only) */ -DEFINE_GUID(IID_IDirectMusicTool8, 0xe674303, 0x3b05, 0x11d3, 0x9b, 0xd1, 0xf9, 0xe7, 0xf0, 0xa0, 0x15, 0x36); -DEFINE_GUID(IID_IDirectMusicTrack8, 0xe674304, 0x3b05, 0x11d3, 0x9b, 0xd1, 0xf9, 0xe7, 0xf0, 0xa0, 0x15, 0x36); - -#ifdef __cplusplus -}; /* extern "C" */ -#endif - -#include - -#endif /* #ifndef _DMPLUGIN_ */ +/************************************************************************ +* * +* dmplugin.h -- This module contains the API for plugins for the * +* DirectMusic performance layer * +* * +* Copyright (c) Microsoft Corporation. All rights reserved. * +* * +************************************************************************/ + +#ifndef _DMPLUGIN_ +#define _DMPLUGIN_ + +#include + +#define COM_NO_WINDOWS_H +#include + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +interface IDirectMusicTrack; +interface IDirectMusicTool; +interface IDirectMusicTool8; +interface IDirectMusicTrack8; +interface IDirectMusicPerformance; +interface IDirectMusicPerformance8; +interface IDirectMusicSegment; +interface IDirectMusicSegment8; +interface IDirectMusicSegmentState; +interface IDirectMusicSegmentState8; +interface IDirectMusicGraph; +#ifndef __cplusplus +typedef interface IDirectMusicTrack IDirectMusicTrack; +typedef interface IDirectMusicTool IDirectMusicTool; +typedef interface IDirectMusicTool8 IDirectMusicTool8; +typedef interface IDirectMusicTrack8 IDirectMusicTrack8; +typedef interface IDirectMusicPerformance IDirectMusicPerformance; +typedef interface IDirectMusicPerformance8 IDirectMusicPerformance8; +typedef interface IDirectMusicSegment IDirectMusicSegment; +typedef interface IDirectMusicSegment8 IDirectMusicSegment8; +typedef interface IDirectMusicSegmentState IDirectMusicSegmentState; +typedef interface IDirectMusicSegmentState8 IDirectMusicSegmentState8; +typedef interface IDirectMusicGraph IDirectMusicGraph; +#endif + +typedef struct _DMUS_PMSG DMUS_PMSG; +typedef long MUSIC_TIME; + +/* Registry location for tools */ +#define DMUS_REGSTR_PATH_TOOLS "Software\\Microsoft\\DirectMusic\\Tools" + +/*//////////////////////////////////////////////////////////////////// +// IDirectMusicTool */ +#undef INTERFACE +#define INTERFACE IDirectMusicTool +DECLARE_INTERFACE_(IDirectMusicTool, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicTool */ + STDMETHOD(Init) (THIS_ IDirectMusicGraph* pGraph) PURE; + STDMETHOD(GetMsgDeliveryType) (THIS_ DWORD* pdwDeliveryType ) PURE; + STDMETHOD(GetMediaTypeArraySize)(THIS_ DWORD* pdwNumElements ) PURE; + STDMETHOD(GetMediaTypes) (THIS_ DWORD** padwMediaTypes, + DWORD dwNumElements) PURE; + STDMETHOD(ProcessPMsg) (THIS_ IDirectMusicPerformance* pPerf, + DMUS_PMSG* pPMSG) PURE; + STDMETHOD(Flush) (THIS_ IDirectMusicPerformance* pPerf, + DMUS_PMSG* pPMSG, + REFERENCE_TIME rtTime) PURE; +}; + +/*//////////////////////////////////////////////////////////////////// +// IDirectMusicTool8 */ +#undef INTERFACE +#define INTERFACE IDirectMusicTool8 +DECLARE_INTERFACE_(IDirectMusicTool8, IDirectMusicTool) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicTool */ + STDMETHOD(Init) (THIS_ IDirectMusicGraph* pGraph) PURE; + STDMETHOD(GetMsgDeliveryType) (THIS_ DWORD* pdwDeliveryType ) PURE; + STDMETHOD(GetMediaTypeArraySize)(THIS_ DWORD* pdwNumElements ) PURE; + STDMETHOD(GetMediaTypes) (THIS_ DWORD** padwMediaTypes, + DWORD dwNumElements) PURE; + STDMETHOD(ProcessPMsg) (THIS_ IDirectMusicPerformance* pPerf, + DMUS_PMSG* pPMSG) PURE; + STDMETHOD(Flush) (THIS_ IDirectMusicPerformance* pPerf, + DMUS_PMSG* pPMSG, + REFERENCE_TIME rtTime) PURE; + /* IDirectMusicTool8 */ + STDMETHOD(Clone) (THIS_ IDirectMusicTool ** ppTool) PURE; +}; + + +/* The following flags are sent in the IDirectMusicTrack::Play() method */ +/* inside the dwFlags parameter */ +typedef enum enumDMUS_TRACKF_FLAGS +{ + DMUS_TRACKF_SEEK = 1, /* set on a seek */ + DMUS_TRACKF_LOOP = 2, /* set on a loop (repeat) */ + DMUS_TRACKF_START = 4, /* set on first call to Play */ + DMUS_TRACKF_FLUSH = 8, /* set when this call is in response to a flush on the perfomance */ + DMUS_TRACKF_DIRTY = 0x10, /* set when the track should consider any cached values from a previous call to GetParam to be invalidated */ + /* The following flags are DX8 only. */ + DMUS_TRACKF_NOTIFY_OFF = 0x20, /* tells track not to send notifications. */ + DMUS_TRACKF_PLAY_OFF = 0x40, /* tells track not to play anything (but can still send notifications.) */ + DMUS_TRACKF_LOOPEND = 0x80, /* set when the end of range is also a loop end. */ + DMUS_TRACKF_STOP = 0x100, /* set when the end of range is also end of playing this segment. */ + DMUS_TRACKF_RECOMPOSE = 0x200, /* set to indicate the track should compose. */ + DMUS_TRACKF_CLOCK = 0x400, /* set when time parameters are in reference (clock) time. Only valid for PlayEx(). */ +} DMUS_TRACKF_FLAGS; + +/* The following flags are sent in the IDirectMusicTrack8::GetParamEx() and SetParamEx() methods */ +/* inside the dwFlags parameter */ +#define DMUS_TRACK_PARAMF_CLOCK 0x01 /* set when the time is measured is in reference (clock) time */ + +/*//////////////////////////////////////////////////////////////////// +// IDirectMusicTrack */ +#undef INTERFACE +#define INTERFACE IDirectMusicTrack +DECLARE_INTERFACE_(IDirectMusicTrack, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicTrack */ + STDMETHOD(Init) (THIS_ IDirectMusicSegment* pSegment) PURE; + STDMETHOD(InitPlay) (THIS_ IDirectMusicSegmentState* pSegmentState, + IDirectMusicPerformance* pPerformance, + void** ppStateData, + DWORD dwVirtualTrackID, + DWORD dwFlags) PURE; + STDMETHOD(EndPlay) (THIS_ void* pStateData) PURE; + STDMETHOD(Play) (THIS_ void* pStateData, + MUSIC_TIME mtStart, + MUSIC_TIME mtEnd, + MUSIC_TIME mtOffset, + DWORD dwFlags, + IDirectMusicPerformance* pPerf, + IDirectMusicSegmentState* pSegSt, + DWORD dwVirtualID) PURE; + STDMETHOD(GetParam) (THIS_ REFGUID rguidType, + MUSIC_TIME mtTime, + MUSIC_TIME* pmtNext, + void* pParam) PURE; + STDMETHOD(SetParam) (THIS_ REFGUID rguidType, + MUSIC_TIME mtTime, + void* pParam) PURE; + STDMETHOD(IsParamSupported) (THIS_ REFGUID rguidType) PURE; + STDMETHOD(AddNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; + STDMETHOD(RemoveNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; + STDMETHOD(Clone) (THIS_ MUSIC_TIME mtStart, + MUSIC_TIME mtEnd, + IDirectMusicTrack** ppTrack) PURE; +}; + +/*//////////////////////////////////////////////////////////////////// +// IDirectMusicTrack8 */ +#undef INTERFACE +#define INTERFACE IDirectMusicTrack8 +DECLARE_INTERFACE_(IDirectMusicTrack8, IDirectMusicTrack) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicTrack */ + STDMETHOD(Init) (THIS_ IDirectMusicSegment* pSegment) PURE; + STDMETHOD(InitPlay) (THIS_ IDirectMusicSegmentState* pSegmentState, + IDirectMusicPerformance* pPerformance, + void** ppStateData, + DWORD dwVirtualTrackID, + DWORD dwFlags) PURE; + STDMETHOD(EndPlay) (THIS_ void* pStateData) PURE; + STDMETHOD(Play) (THIS_ void* pStateData, + MUSIC_TIME mtStart, + MUSIC_TIME mtEnd, + MUSIC_TIME mtOffset, + DWORD dwFlags, + IDirectMusicPerformance* pPerf, + IDirectMusicSegmentState* pSegSt, + DWORD dwVirtualID) PURE; + STDMETHOD(GetParam) (THIS_ REFGUID rguidType, + MUSIC_TIME mtTime, + MUSIC_TIME* pmtNext, + void* pParam) PURE; + STDMETHOD(SetParam) (THIS_ REFGUID rguidType, + MUSIC_TIME mtTime, + void* pParam) PURE; + STDMETHOD(IsParamSupported) (THIS_ REFGUID rguidType) PURE; + STDMETHOD(AddNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; + STDMETHOD(RemoveNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; + STDMETHOD(Clone) (THIS_ MUSIC_TIME mtStart, + MUSIC_TIME mtEnd, + IDirectMusicTrack** ppTrack) PURE; + /* IDirectMusicTrack8 */ + STDMETHOD(PlayEx) (THIS_ void* pStateData, + REFERENCE_TIME rtStart, + REFERENCE_TIME rtEnd, + REFERENCE_TIME rtOffset, + DWORD dwFlags, + IDirectMusicPerformance* pPerf, + IDirectMusicSegmentState* pSegSt, + DWORD dwVirtualID) PURE; + STDMETHOD(GetParamEx) (THIS_ REFGUID rguidType, /* Command type. */ + REFERENCE_TIME rtTime, /* Time, in ref time if dwFlags == DMUS_TRACK_PARAMF_CLOCK. Otherwise, music time. */ + REFERENCE_TIME* prtNext, /* Time of next parameter, relative to rtTime, in music or clock time units. */ + void* pParam, /* Pointer to the parameter data. */ + void * pStateData, /* State data for track instance. */ + DWORD dwFlags) PURE; /* Control flags. */ + STDMETHOD(SetParamEx) (THIS_ REFGUID rguidType, + REFERENCE_TIME rtTime, + void* pParam, /* Pointer to the parameter data. */ + void * pStateData, /* State data for track instance. */ + DWORD dwFlags) PURE; /* Control flags. */ + STDMETHOD(Compose) (THIS_ IUnknown* pContext, /* Context for composition */ + DWORD dwTrackGroup, + IDirectMusicTrack** ppResultTrack) PURE; + STDMETHOD(Join) (THIS_ IDirectMusicTrack* pNewTrack, + MUSIC_TIME mtJoin, + IUnknown* pContext, /* Context for joining */ + DWORD dwTrackGroup, + IDirectMusicTrack** ppResultTrack) PURE; +}; + +/* CLSID's */ +DEFINE_GUID(CLSID_DirectMusicTempoTrack,0xd2ac2885, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicSeqTrack,0xd2ac2886, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicSysExTrack,0xd2ac2887, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicTimeSigTrack,0xd2ac2888, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicChordTrack,0xd2ac288b, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicCommandTrack,0xd2ac288c, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicStyleTrack,0xd2ac288d, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicMotifTrack,0xd2ac288e, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicSignPostTrack,0xf17e8672, 0xc3b4, 0x11d1, 0x87, 0xb, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicBandTrack,0xd2ac2894, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicChordMapTrack,0xd2ac2896, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicMuteTrack,0xd2ac2898, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* New CLSID's for DX8 */ +DEFINE_GUID(CLSID_DirectMusicScriptTrack,0x4108fa85, 0x3586, 0x11d3, 0x8b, 0xd7, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xb6); /* {4108FA85-3586-11d3-8BD7-00600893B1B6} */ +DEFINE_GUID(CLSID_DirectMusicMarkerTrack,0x55a8fd00, 0x4288, 0x11d3, 0x9b, 0xd1, 0x8a, 0xd, 0x61, 0xc8, 0x88, 0x35); +DEFINE_GUID(CLSID_DirectMusicSegmentTriggerTrack, 0xbae4d665, 0x4ea1, 0x11d3, 0x8b, 0xda, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xb6); /* {BAE4D665-4EA1-11d3-8BDA-00600893B1B6} */ +DEFINE_GUID(CLSID_DirectMusicLyricsTrack, 0x995c1cf5, 0x54ff, 0x11d3, 0x8b, 0xda, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xb6); /* {995C1CF5-54FF-11d3-8BDA-00600893B1B6} */ +DEFINE_GUID(CLSID_DirectMusicParamControlTrack, 0x4be0537b, 0x5c19, 0x11d3, 0x8b, 0xdc, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xb6); /* {4BE0537B-5C19-11d3-8BDC-00600893B1B6} */ +DEFINE_GUID(CLSID_DirectMusicWaveTrack,0xeed36461, 0x9ea5, 0x11d3, 0x9b, 0xd1, 0x0, 0x80, 0xc7, 0x15, 0xa, 0x74); + +/* IID's */ +DEFINE_GUID(IID_IDirectMusicTrack, 0xf96029a1, 0x4282, 0x11d2, 0x87, 0x17, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(IID_IDirectMusicTool,0xd2ac28ba, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Interface IDs for DX8 */ +/* changed interfaces (GUID only) */ +DEFINE_GUID(IID_IDirectMusicTool8, 0xe674303, 0x3b05, 0x11d3, 0x9b, 0xd1, 0xf9, 0xe7, 0xf0, 0xa0, 0x15, 0x36); +DEFINE_GUID(IID_IDirectMusicTrack8, 0xe674304, 0x3b05, 0x11d3, 0x9b, 0xd1, 0xf9, 0xe7, 0xf0, 0xa0, 0x15, 0x36); + +#ifdef __cplusplus +}; /* extern "C" */ +#endif + +#include + +#endif /* #ifndef _DMPLUGIN_ */ diff --git a/src/dep/include/DXSDK/include/dmusbuff.h b/src/dep/include/DXSDK/include/dmusbuff.h index 6841401..5488453 100644 --- a/src/dep/include/DXSDK/include/dmusbuff.h +++ b/src/dep/include/DXSDK/include/dmusbuff.h @@ -1,41 +1,41 @@ -/*************************************************************************** -* * -* DMusBuff.h -- This module defines the buffer format for DirectMusic * -* Shared file between user mode and kernel mode components * -* * -* Copyright (c) 1998, Microsoft Corp. All rights reserved. * -* * -***************************************************************************/ - -#ifndef _DMusBuff_ -#define _DMusBuff_ - -/* Format of DirectMusic events in a buffer - * - * A buffer contains 1 or more events, each with the following header. - * Immediately following the header is the event data. The header+data - * size is rounded to the nearest quadword (8 bytes). - */ - -#include /* Do not pad at end - that's where the data is */ -typedef struct _DMUS_EVENTHEADER *LPDMUS_EVENTHEADER; -typedef struct _DMUS_EVENTHEADER -{ - DWORD cbEvent; /* Unrounded bytes in event */ - DWORD dwChannelGroup; /* Channel group of event */ - REFERENCE_TIME rtDelta; /* Delta from start time of entire buffer */ - DWORD dwFlags; /* Flags DMUS_EVENT_xxx */ -} DMUS_EVENTHEADER; -#include - -#define DMUS_EVENT_STRUCTURED 0x00000001 /* Unstructured data (SysEx, etc.) */ - -/* The number of bytes to allocate for an event with 'cb' data bytes. - */ -#define QWORD_ALIGN(x) (((x) + 7) & ~7) -#define DMUS_EVENT_SIZE(cb) QWORD_ALIGN(sizeof(DMUS_EVENTHEADER) + cb) - - -#endif /* _DMusBuff_ */ - - +/*************************************************************************** +* * +* DMusBuff.h -- This module defines the buffer format for DirectMusic * +* Shared file between user mode and kernel mode components * +* * +* Copyright (c) 1998, Microsoft Corp. All rights reserved. * +* * +***************************************************************************/ + +#ifndef _DMusBuff_ +#define _DMusBuff_ + +/* Format of DirectMusic events in a buffer + * + * A buffer contains 1 or more events, each with the following header. + * Immediately following the header is the event data. The header+data + * size is rounded to the nearest quadword (8 bytes). + */ + +#include /* Do not pad at end - that's where the data is */ +typedef struct _DMUS_EVENTHEADER *LPDMUS_EVENTHEADER; +typedef struct _DMUS_EVENTHEADER +{ + DWORD cbEvent; /* Unrounded bytes in event */ + DWORD dwChannelGroup; /* Channel group of event */ + REFERENCE_TIME rtDelta; /* Delta from start time of entire buffer */ + DWORD dwFlags; /* Flags DMUS_EVENT_xxx */ +} DMUS_EVENTHEADER; +#include + +#define DMUS_EVENT_STRUCTURED 0x00000001 /* Unstructured data (SysEx, etc.) */ + +/* The number of bytes to allocate for an event with 'cb' data bytes. + */ +#define QWORD_ALIGN(x) (((x) + 7) & ~7) +#define DMUS_EVENT_SIZE(cb) QWORD_ALIGN(sizeof(DMUS_EVENTHEADER) + cb) + + +#endif /* _DMusBuff_ */ + + diff --git a/src/dep/include/DXSDK/include/dmusicc.h b/src/dep/include/DXSDK/include/dmusicc.h index 74f1868..0d0afb2 100644 --- a/src/dep/include/DXSDK/include/dmusicc.h +++ b/src/dep/include/DXSDK/include/dmusicc.h @@ -1,784 +1,784 @@ -/************************************************************************ -* * -* dmusicc.h -- This module defines the DirectMusic core API's * -* * -* Copyright (c) Microsoft Corporation. All rights reserved. * -* * -************************************************************************/ - -#ifndef _DMUSICC_ -#define _DMUSICC_ - -#include - -#define COM_NO_WINDOWS_H -#include - -#include - -#include "dls1.h" -#include "dmerror.h" -#include "dmdls.h" -#include "dsound.h" -#include "dmusbuff.h" - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef ULONGLONG SAMPLE_TIME; -typedef ULONGLONG SAMPLE_POSITION; -typedef SAMPLE_TIME *LPSAMPLE_TIME; - -#define DMUS_MAX_DESCRIPTION 128 -#define DMUS_MAX_DRIVER 128 - -typedef struct _DMUS_BUFFERDESC *LPDMUS_BUFFERDESC; -typedef struct _DMUS_BUFFERDESC -{ - DWORD dwSize; - DWORD dwFlags; - GUID guidBufferFormat; - DWORD cbBuffer; -} DMUS_BUFFERDESC; - -/* DMUS_EFFECT_ flags are used in the dwEffectFlags fields of both DMUS_PORTCAPS - * and DMUS_PORTPARAMS. - */ -#define DMUS_EFFECT_NONE 0x00000000 -#define DMUS_EFFECT_REVERB 0x00000001 -#define DMUS_EFFECT_CHORUS 0x00000002 -#define DMUS_EFFECT_DELAY 0x00000004 - -/* For DMUS_PORTCAPS dwClass - */ -#define DMUS_PC_INPUTCLASS (0) -#define DMUS_PC_OUTPUTCLASS (1) - -/* For DMUS_PORTCAPS dwFlags - */ -#define DMUS_PC_DLS (0x00000001) // Supports DLS downloading and DLS level 1. -#define DMUS_PC_EXTERNAL (0x00000002) // External MIDI module. -#define DMUS_PC_SOFTWARESYNTH (0x00000004) // Software synthesizer. -#define DMUS_PC_MEMORYSIZEFIXED (0x00000008) // Memory size is fixed. -#define DMUS_PC_GMINHARDWARE (0x00000010) // GM sound set is built in, no need to download. -#define DMUS_PC_GSINHARDWARE (0x00000020) // GS sound set is built in. -#define DMUS_PC_XGINHARDWARE (0x00000040) // XG sound set is built in. -#define DMUS_PC_DIRECTSOUND (0x00000080) // Connects to DirectSound via a DirectSound buffer. -#define DMUS_PC_SHAREABLE (0x00000100) // Synth can be actively shared by multiple apps at once. -#define DMUS_PC_DLS2 (0x00000200) // Supports DLS2 instruments. -#define DMUS_PC_AUDIOPATH (0x00000400) // Multiple outputs can be connected to DirectSound for audiopaths. -#define DMUS_PC_WAVE (0x00000800) // Supports streaming and one shot waves. - -#define DMUS_PC_SYSTEMMEMORY (0x7FFFFFFF) // Sample memory is system memory. - - -typedef struct _DMUS_PORTCAPS -{ - DWORD dwSize; - DWORD dwFlags; - GUID guidPort; - DWORD dwClass; - DWORD dwType; - DWORD dwMemorySize; - DWORD dwMaxChannelGroups; - DWORD dwMaxVoices; - DWORD dwMaxAudioChannels; - DWORD dwEffectFlags; - WCHAR wszDescription[DMUS_MAX_DESCRIPTION]; -} DMUS_PORTCAPS; - -typedef DMUS_PORTCAPS *LPDMUS_PORTCAPS; - -/* Values for DMUS_PORTCAPS dwType. This field indicates the underlying - * driver type of the port. - */ -#define DMUS_PORT_WINMM_DRIVER (0) -#define DMUS_PORT_USER_MODE_SYNTH (1) -#define DMUS_PORT_KERNEL_MODE (2) - -/* These flags (set in dwValidParams) indicate which other members of the */ -/* DMUS_PORTPARAMS are valid. */ -/* */ -#define DMUS_PORTPARAMS_VOICES 0x00000001 -#define DMUS_PORTPARAMS_CHANNELGROUPS 0x00000002 -#define DMUS_PORTPARAMS_AUDIOCHANNELS 0x00000004 -#define DMUS_PORTPARAMS_SAMPLERATE 0x00000008 -#define DMUS_PORTPARAMS_EFFECTS 0x00000020 -#define DMUS_PORTPARAMS_SHARE 0x00000040 -#define DMUS_PORTPARAMS_FEATURES 0x00000080 /* DirectX 8.0 and above */ - -typedef struct _DMUS_PORTPARAMS -{ - DWORD dwSize; - DWORD dwValidParams; - DWORD dwVoices; - DWORD dwChannelGroups; - DWORD dwAudioChannels; - DWORD dwSampleRate; - DWORD dwEffectFlags; - BOOL fShare; -} DMUS_PORTPARAMS7; - -typedef struct _DMUS_PORTPARAMS8 -{ - DWORD dwSize; - DWORD dwValidParams; - DWORD dwVoices; - DWORD dwChannelGroups; - DWORD dwAudioChannels; - DWORD dwSampleRate; - DWORD dwEffectFlags; - BOOL fShare; - DWORD dwFeatures; -} DMUS_PORTPARAMS8; - -#define DMUS_PORT_FEATURE_AUDIOPATH 0x00000001 /* Supports audiopath connection to DirectSound buffers. */ -#define DMUS_PORT_FEATURE_STREAMING 0x00000002 /* Supports streaming waves through the synth. */ - - -typedef DMUS_PORTPARAMS8 DMUS_PORTPARAMS; -typedef DMUS_PORTPARAMS *LPDMUS_PORTPARAMS; - -typedef struct _DMUS_SYNTHSTATS *LPDMUS_SYNTHSTATS; -typedef struct _DMUS_SYNTHSTATS8 *LPDMUS_SYNTHSTATS8; -typedef struct _DMUS_SYNTHSTATS -{ - DWORD dwSize; /* Size in bytes of the structure */ - DWORD dwValidStats; /* Flags indicating which fields below are valid. */ - DWORD dwVoices; /* Average number of voices playing. */ - DWORD dwTotalCPU; /* Total CPU usage as percent * 100. */ - DWORD dwCPUPerVoice; /* CPU per voice as percent * 100. */ - DWORD dwLostNotes; /* Number of notes lost in 1 second. */ - DWORD dwFreeMemory; /* Free memory in bytes */ - long lPeakVolume; /* Decibel level * 100. */ -} DMUS_SYNTHSTATS; - -typedef struct _DMUS_SYNTHSTATS8 -{ - DWORD dwSize; /* Size in bytes of the structure */ - DWORD dwValidStats; /* Flags indicating which fields below are valid. */ - DWORD dwVoices; /* Average number of voices playing. */ - DWORD dwTotalCPU; /* Total CPU usage as percent * 100. */ - DWORD dwCPUPerVoice; /* CPU per voice as percent * 100. */ - DWORD dwLostNotes; /* Number of notes lost in 1 second. */ - DWORD dwFreeMemory; /* Free memory in bytes */ - long lPeakVolume; /* Decibel level * 100. */ - DWORD dwSynthMemUse; /* Memory used by synth wave data */ -} DMUS_SYNTHSTATS8; - -#define DMUS_SYNTHSTATS_VOICES (1 << 0) -#define DMUS_SYNTHSTATS_TOTAL_CPU (1 << 1) -#define DMUS_SYNTHSTATS_CPU_PER_VOICE (1 << 2) -#define DMUS_SYNTHSTATS_LOST_NOTES (1 << 3) -#define DMUS_SYNTHSTATS_PEAK_VOLUME (1 << 4) -#define DMUS_SYNTHSTATS_FREE_MEMORY (1 << 5) - -#define DMUS_SYNTHSTATS_SYSTEMMEMORY DMUS_PC_SYSTEMMEMORY - -typedef struct _DMUS_WAVES_REVERB_PARAMS -{ - float fInGain; /* Input gain in dB (to avoid output overflows) */ - float fReverbMix; /* Reverb mix in dB. 0dB means 100% wet reverb (no direct signal) - Negative values gives less wet signal. - The coeficients are calculated so that the overall output level stays - (approximately) constant regardless of the ammount of reverb mix. */ - float fReverbTime; /* The reverb decay time, in milliseconds. */ - float fHighFreqRTRatio; /* The ratio of the high frequencies to the global reverb time. - Unless very 'splashy-bright' reverbs are wanted, this should be set to - a value < 1.0. - For example if dRevTime==1000ms and dHighFreqRTRatio=0.1 than the - decay time for high frequencies will be 100ms.*/ - -} DMUS_WAVES_REVERB_PARAMS; - -/* Note: Default values for Reverb are: - fInGain = 0.0dB (no change in level) - fReverbMix = -10.0dB (a reasonable reverb mix) - fReverbTime = 1000.0ms (one second global reverb time) - fHighFreqRTRatio = 0.001 (the ratio of the high frequencies to the global reverb time) -*/ - -typedef enum -{ - DMUS_CLOCK_SYSTEM = 0, - DMUS_CLOCK_WAVE = 1 -} DMUS_CLOCKTYPE; - -#define DMUS_CLOCKF_GLOBAL 0x00000001 - -typedef struct _DMUS_CLOCKINFO7 *LPDMUS_CLOCKINFO7; -typedef struct _DMUS_CLOCKINFO7 -{ - DWORD dwSize; - DMUS_CLOCKTYPE ctType; - GUID guidClock; /* Identifies this time source */ - WCHAR wszDescription[DMUS_MAX_DESCRIPTION]; -} DMUS_CLOCKINFO7; - -typedef struct _DMUS_CLOCKINFO8 *LPDMUS_CLOCKINFO8; -typedef struct _DMUS_CLOCKINFO8 -{ - DWORD dwSize; - DMUS_CLOCKTYPE ctType; - GUID guidClock; /* Identifies this time source */ - WCHAR wszDescription[DMUS_MAX_DESCRIPTION]; - DWORD dwFlags; -} DMUS_CLOCKINFO8; - -typedef DMUS_CLOCKINFO8 DMUS_CLOCKINFO; -typedef DMUS_CLOCKINFO *LPDMUS_CLOCKINFO; - -/* Default bus identifiers - * - * The first 17 are direct mappings to the destinations defined in both - * the MMA DLS Level 2 specification and the Microsoft Multi-Channel audio - * specification. - */ -#define DSBUSID_FIRST_SPKR_LOC 0 -#define DSBUSID_FRONT_LEFT 0 -#define DSBUSID_LEFT 0 /* Front left is also just left */ -#define DSBUSID_FRONT_RIGHT 1 -#define DSBUSID_RIGHT 1 /* Ditto front right */ -#define DSBUSID_FRONT_CENTER 2 -#define DSBUSID_LOW_FREQUENCY 3 -#define DSBUSID_BACK_LEFT 4 -#define DSBUSID_BACK_RIGHT 5 -#define DSBUSID_FRONT_LEFT_OF_CENTER 6 -#define DSBUSID_FRONT_RIGHT_OF_CENTER 7 -#define DSBUSID_BACK_CENTER 8 -#define DSBUSID_SIDE_LEFT 9 -#define DSBUSID_SIDE_RIGHT 10 -#define DSBUSID_TOP_CENTER 11 -#define DSBUSID_TOP_FRONT_LEFT 12 -#define DSBUSID_TOP_FRONT_CENTER 13 -#define DSBUSID_TOP_FRONT_RIGHT 14 -#define DSBUSID_TOP_BACK_LEFT 15 -#define DSBUSID_TOP_BACK_CENTER 16 -#define DSBUSID_TOP_BACK_RIGHT 17 -#define DSBUSID_LAST_SPKR_LOC 17 - -#define DSBUSID_IS_SPKR_LOC(id) ( ((id) >= DSBUSID_FIRST_SPKR_LOC) && ((id) <= DSBUSID_LAST_SPKR_LOC) ) - -/* These bus identifiers are for the standard DLS effect sends - */ -#define DSBUSID_REVERB_SEND 64 -#define DSBUSID_CHORUS_SEND 65 - -/* Dynamic bus identifiers start here. See the documentation for how - * synthesizers map the output of voices to static and dynamic - * bus identifiers. - */ -#define DSBUSID_DYNAMIC_0 512 - -/* Null bus, used to identify busses that have no function mapping. -*/ -#define DSBUSID_NULL 0xFFFFFFFF - -interface IDirectMusic; -interface IDirectMusic8; -interface IDirectMusicBuffer; -interface IDirectMusicPort; -interface IDirectMusicThru; -interface IReferenceClock; - -#ifndef __cplusplus - -typedef interface IDirectMusic IDirectMusic; -typedef interface IDirectMusic8 IDirectMusic8; -typedef interface IDirectMusicPort IDirectMusicPort; -typedef interface IDirectMusicBuffer IDirectMusicBuffer; -typedef interface IDirectMusicThru IDirectMusicThru; -typedef interface IReferenceClock IReferenceClock; - -#endif /* C++ */ - -typedef IDirectMusic *LPDIRECTMUSIC; -typedef IDirectMusic8 *LPDIRECTMUSIC8; -typedef IDirectMusicPort *LPDIRECTMUSICPORT; -typedef IDirectMusicBuffer *LPDIRECTMUSICBUFFER; - -#undef INTERFACE -#define INTERFACE IDirectMusic -DECLARE_INTERFACE_(IDirectMusic, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusic */ - STDMETHOD(EnumPort) (THIS_ DWORD dwIndex, - LPDMUS_PORTCAPS pPortCaps) PURE; - STDMETHOD(CreateMusicBuffer) (THIS_ LPDMUS_BUFFERDESC pBufferDesc, - LPDIRECTMUSICBUFFER *ppBuffer, - LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(CreatePort) (THIS_ REFCLSID rclsidPort, - LPDMUS_PORTPARAMS pPortParams, - LPDIRECTMUSICPORT *ppPort, - LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumMasterClock) (THIS_ DWORD dwIndex, - LPDMUS_CLOCKINFO lpClockInfo) PURE; - STDMETHOD(GetMasterClock) (THIS_ LPGUID pguidClock, - IReferenceClock **ppReferenceClock) PURE; - STDMETHOD(SetMasterClock) (THIS_ REFGUID rguidClock) PURE; - STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE; - STDMETHOD(GetDefaultPort) (THIS_ LPGUID pguidPort) PURE; - STDMETHOD(SetDirectSound) (THIS_ LPDIRECTSOUND pDirectSound, - HWND hWnd) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirectMusic8 -DECLARE_INTERFACE_(IDirectMusic8, IDirectMusic) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusic */ - STDMETHOD(EnumPort) (THIS_ DWORD dwIndex, - LPDMUS_PORTCAPS pPortCaps) PURE; - STDMETHOD(CreateMusicBuffer) (THIS_ LPDMUS_BUFFERDESC pBufferDesc, - LPDIRECTMUSICBUFFER *ppBuffer, - LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(CreatePort) (THIS_ REFCLSID rclsidPort, - LPDMUS_PORTPARAMS pPortParams, - LPDIRECTMUSICPORT *ppPort, - LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumMasterClock) (THIS_ DWORD dwIndex, - LPDMUS_CLOCKINFO lpClockInfo) PURE; - STDMETHOD(GetMasterClock) (THIS_ LPGUID pguidClock, - IReferenceClock **ppReferenceClock) PURE; - STDMETHOD(SetMasterClock) (THIS_ REFGUID rguidClock) PURE; - STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE; - STDMETHOD(GetDefaultPort) (THIS_ LPGUID pguidPort) PURE; - STDMETHOD(SetDirectSound) (THIS_ LPDIRECTSOUND pDirectSound, - HWND hWnd) PURE; - /* IDirectMusic8 */ - STDMETHOD(SetExternalMasterClock) - (THIS_ IReferenceClock *pClock) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirectMusicBuffer -DECLARE_INTERFACE_(IDirectMusicBuffer, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicBuffer */ - STDMETHOD(Flush) (THIS) PURE; - STDMETHOD(TotalTime) (THIS_ LPREFERENCE_TIME prtTime) PURE; - - STDMETHOD(PackStructured) (THIS_ REFERENCE_TIME rt, - DWORD dwChannelGroup, - DWORD dwChannelMessage) PURE; - - STDMETHOD(PackUnstructured) (THIS_ REFERENCE_TIME rt, - DWORD dwChannelGroup, - DWORD cb, - LPBYTE lpb) PURE; - - STDMETHOD(ResetReadPtr) (THIS) PURE; - STDMETHOD(GetNextEvent) (THIS_ LPREFERENCE_TIME prt, - LPDWORD pdwChannelGroup, - LPDWORD pdwLength, - LPBYTE *ppData) PURE; - - STDMETHOD(GetRawBufferPtr) (THIS_ LPBYTE *ppData) PURE; - STDMETHOD(GetStartTime) (THIS_ LPREFERENCE_TIME prt) PURE; - STDMETHOD(GetUsedBytes) (THIS_ LPDWORD pcb) PURE; - STDMETHOD(GetMaxBytes) (THIS_ LPDWORD pcb) PURE; - STDMETHOD(GetBufferFormat) (THIS_ LPGUID pGuidFormat) PURE; - - STDMETHOD(SetStartTime) (THIS_ REFERENCE_TIME rt) PURE; - STDMETHOD(SetUsedBytes) (THIS_ DWORD cb) PURE; -}; - -typedef IDirectMusicBuffer IDirectMusicBuffer8; -typedef IDirectMusicBuffer8 *LPDIRECTMUSICBUFFER8; - -#undef INTERFACE -#define INTERFACE IDirectMusicInstrument -DECLARE_INTERFACE_(IDirectMusicInstrument, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicInstrument */ - STDMETHOD(GetPatch) (THIS_ DWORD* pdwPatch) PURE; - STDMETHOD(SetPatch) (THIS_ DWORD dwPatch) PURE; -}; - -typedef IDirectMusicInstrument IDirectMusicInstrument8; -typedef IDirectMusicInstrument8 *LPDIRECTMUSICINSTRUMENT8; - -#undef INTERFACE -#define INTERFACE IDirectMusicDownloadedInstrument -DECLARE_INTERFACE_(IDirectMusicDownloadedInstrument, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicDownloadedInstrument */ - /* None at this time */ -}; - -typedef IDirectMusicDownloadedInstrument IDirectMusicDownloadedInstrument8; -typedef IDirectMusicDownloadedInstrument8 *LPDIRECTMUSICDOWNLOADEDINSTRUMENT8; - -#undef INTERFACE -#define INTERFACE IDirectMusicCollection -DECLARE_INTERFACE_(IDirectMusicCollection, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicCollection */ - STDMETHOD(GetInstrument) (THIS_ DWORD dwPatch, - IDirectMusicInstrument** ppInstrument) PURE; - STDMETHOD(EnumInstrument) (THIS_ DWORD dwIndex, - DWORD* pdwPatch, - LPWSTR pwszName, - DWORD dwNameLen) PURE; -}; - -typedef IDirectMusicCollection IDirectMusicCollection8; -typedef IDirectMusicCollection8 *LPDIRECTMUSICCOLLECTION8; - -#undef INTERFACE -#define INTERFACE IDirectMusicDownload -DECLARE_INTERFACE_(IDirectMusicDownload , IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicDownload */ - STDMETHOD(GetBuffer) (THIS_ void** ppvBuffer, - DWORD* pdwSize) PURE; -}; - -typedef IDirectMusicDownload IDirectMusicDownload8; -typedef IDirectMusicDownload8 *LPDIRECTMUSICDOWNLOAD8; - -#undef INTERFACE -#define INTERFACE IDirectMusicPortDownload -DECLARE_INTERFACE_(IDirectMusicPortDownload, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicPortDownload */ - STDMETHOD(GetBuffer) (THIS_ DWORD dwDLId, - IDirectMusicDownload** ppIDMDownload) PURE; - STDMETHOD(AllocateBuffer) (THIS_ DWORD dwSize, - IDirectMusicDownload** ppIDMDownload) PURE; - STDMETHOD(GetDLId) (THIS_ DWORD* pdwStartDLId, - DWORD dwCount) PURE; - STDMETHOD(GetAppend) (THIS_ DWORD* pdwAppend) PURE; - STDMETHOD(Download) (THIS_ IDirectMusicDownload* pIDMDownload) PURE; - STDMETHOD(Unload) (THIS_ IDirectMusicDownload* pIDMDownload) PURE; -}; - -typedef IDirectMusicPortDownload IDirectMusicPortDownload8; -typedef IDirectMusicPortDownload8 *LPDIRECTMUSICPORTDOWNLOAD8; - -/* Standard values for voice priorities. Numerically higher priorities are higher in priority. - * These priorities are used to set the voice priority for all voices on a channel. They are - * used in the dwPriority parameter of IDirectMusicPort::GetPriority and returned in the - * lpwPriority parameter of pdwPriority. - * - * These priorities are shared with DirectSound. - */ - -#ifndef _DIRECTAUDIO_PRIORITIES_DEFINED_ -#define _DIRECTAUDIO_PRIORITIES_DEFINED_ - -#define DAUD_CRITICAL_VOICE_PRIORITY (0xF0000000) -#define DAUD_HIGH_VOICE_PRIORITY (0xC0000000) -#define DAUD_STANDARD_VOICE_PRIORITY (0x80000000) -#define DAUD_LOW_VOICE_PRIORITY (0x40000000) -#define DAUD_PERSIST_VOICE_PRIORITY (0x10000000) - -/* These are the default priorities assigned if not overridden. By default priorities are - * equal across channel groups (e.g. channel 5 on channel group 1 has the same priority as - * channel 5 on channel group 2). - * - * In accordance with DLS level 1, channel 10 has the highest priority, followed by 1 through 16 - * except for 10. - */ -#define DAUD_CHAN1_VOICE_PRIORITY_OFFSET (0x0000000E) -#define DAUD_CHAN2_VOICE_PRIORITY_OFFSET (0x0000000D) -#define DAUD_CHAN3_VOICE_PRIORITY_OFFSET (0x0000000C) -#define DAUD_CHAN4_VOICE_PRIORITY_OFFSET (0x0000000B) -#define DAUD_CHAN5_VOICE_PRIORITY_OFFSET (0x0000000A) -#define DAUD_CHAN6_VOICE_PRIORITY_OFFSET (0x00000009) -#define DAUD_CHAN7_VOICE_PRIORITY_OFFSET (0x00000008) -#define DAUD_CHAN8_VOICE_PRIORITY_OFFSET (0x00000007) -#define DAUD_CHAN9_VOICE_PRIORITY_OFFSET (0x00000006) -#define DAUD_CHAN10_VOICE_PRIORITY_OFFSET (0x0000000F) -#define DAUD_CHAN11_VOICE_PRIORITY_OFFSET (0x00000005) -#define DAUD_CHAN12_VOICE_PRIORITY_OFFSET (0x00000004) -#define DAUD_CHAN13_VOICE_PRIORITY_OFFSET (0x00000003) -#define DAUD_CHAN14_VOICE_PRIORITY_OFFSET (0x00000002) -#define DAUD_CHAN15_VOICE_PRIORITY_OFFSET (0x00000001) -#define DAUD_CHAN16_VOICE_PRIORITY_OFFSET (0x00000000) - - -#define DAUD_CHAN1_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN1_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN2_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN2_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN3_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN3_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN4_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN4_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN5_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN5_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN6_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN6_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN7_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN7_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN8_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN8_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN9_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN9_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN10_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN10_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN11_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN11_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN12_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN12_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN13_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN13_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN14_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN14_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN15_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN15_VOICE_PRIORITY_OFFSET) -#define DAUD_CHAN16_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN16_VOICE_PRIORITY_OFFSET) - -#endif /* _DIRECTAUDIO_PRIORITIES_DEFINED_ */ - - -#undef INTERFACE -#define INTERFACE IDirectMusicPort -DECLARE_INTERFACE_(IDirectMusicPort, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicPort */ - /* */ - STDMETHOD(PlayBuffer) (THIS_ LPDIRECTMUSICBUFFER pBuffer) PURE; - STDMETHOD(SetReadNotificationHandle) (THIS_ HANDLE hEvent) PURE; - STDMETHOD(Read) (THIS_ LPDIRECTMUSICBUFFER pBuffer) PURE; - STDMETHOD(DownloadInstrument) (THIS_ IDirectMusicInstrument *pInstrument, - IDirectMusicDownloadedInstrument **ppDownloadedInstrument, - DMUS_NOTERANGE *pNoteRanges, - DWORD dwNumNoteRanges) PURE; - STDMETHOD(UnloadInstrument) (THIS_ IDirectMusicDownloadedInstrument *pDownloadedInstrument) PURE; - STDMETHOD(GetLatencyClock) (THIS_ IReferenceClock **ppClock) PURE; - STDMETHOD(GetRunningStats) (THIS_ LPDMUS_SYNTHSTATS pStats) PURE; - STDMETHOD(Compact) (THIS) PURE; - STDMETHOD(GetCaps) (THIS_ LPDMUS_PORTCAPS pPortCaps) PURE; - STDMETHOD(DeviceIoControl) (THIS_ DWORD dwIoControlCode, - LPVOID lpInBuffer, - DWORD nInBufferSize, - LPVOID lpOutBuffer, - DWORD nOutBufferSize, - LPDWORD lpBytesReturned, - LPOVERLAPPED lpOverlapped) PURE; - STDMETHOD(SetNumChannelGroups) (THIS_ DWORD dwChannelGroups) PURE; - STDMETHOD(GetNumChannelGroups) (THIS_ LPDWORD pdwChannelGroups) PURE; - STDMETHOD(Activate) (THIS_ BOOL fActive) PURE; - STDMETHOD(SetChannelPriority) (THIS_ DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority) PURE; - STDMETHOD(GetChannelPriority) (THIS_ DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority) PURE; - STDMETHOD(SetDirectSound) (THIS_ LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer) PURE; - STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize, LPDWORD pdwBufferSize) PURE; -}; - -typedef IDirectMusicPort IDirectMusicPort8; -typedef IDirectMusicPort8 *LPDIRECTMUSICPORT8; - -#undef INTERFACE -#define INTERFACE IDirectMusicThru -DECLARE_INTERFACE_(IDirectMusicThru, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicThru - */ - STDMETHOD(ThruChannel) (THIS_ DWORD dwSourceChannelGroup, - DWORD dwSourceChannel, - DWORD dwDestinationChannelGroup, - DWORD dwDestinationChannel, - LPDIRECTMUSICPORT pDestinationPort) PURE; -}; - -typedef IDirectMusicThru IDirectMusicThru8; -typedef IDirectMusicThru8 *LPDIRECTMUSICTHRU8; - -#ifndef __IReferenceClock_INTERFACE_DEFINED__ -#define __IReferenceClock_INTERFACE_DEFINED__ - -DEFINE_GUID(IID_IReferenceClock,0x56a86897,0x0ad4,0x11ce,0xb0,0x3a,0x00,0x20,0xaf,0x0b,0xa7,0x70); - -#undef INTERFACE -#define INTERFACE IReferenceClock -DECLARE_INTERFACE_(IReferenceClock, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IReferenceClock */ - /* */ - - /* get the time now */ - STDMETHOD(GetTime) (THIS_ REFERENCE_TIME *pTime) PURE; - - /* ask for an async notification that a time has elapsed */ - STDMETHOD(AdviseTime) (THIS_ REFERENCE_TIME baseTime, /* base time */ - REFERENCE_TIME streamTime, /* stream offset time */ - HANDLE hEvent, /* advise via this event */ - DWORD * pdwAdviseCookie) PURE; /* where your cookie goes */ - - /* ask for an async periodic notification that a time has elapsed */ - STDMETHOD(AdvisePeriodic) (THIS_ REFERENCE_TIME startTime, /* starting at this time */ - REFERENCE_TIME periodTime, /* time between notifications */ - HANDLE hSemaphore, /* advise via a semaphore */ - DWORD * pdwAdviseCookie) PURE; /* where your cookie goes */ - - /* cancel a request for notification */ - STDMETHOD(Unadvise) (THIS_ DWORD dwAdviseCookie) PURE; -}; - -#endif /* __IReferenceClock_INTERFACE_DEFINED__ */ - -DEFINE_GUID(CLSID_DirectMusic,0x636b9f10,0x0c7d,0x11d1,0x95,0xb2,0x00,0x20,0xaf,0xdc,0x74,0x21); -DEFINE_GUID(CLSID_DirectMusicCollection,0x480ff4b0, 0x28b2, 0x11d1, 0xbe, 0xf7, 0x0, 0xc0, 0x4f, 0xbf, 0x8f, 0xef); -DEFINE_GUID(CLSID_DirectMusicSynth,0x58C2B4D0,0x46E7,0x11D1,0x89,0xAC,0x00,0xA0,0xC9,0x05,0x41,0x29); - -DEFINE_GUID(IID_IDirectMusic,0x6536115a,0x7b2d,0x11d2,0xba,0x18,0x00,0x00,0xf8,0x75,0xac,0x12); -DEFINE_GUID(IID_IDirectMusicBuffer,0xd2ac2878, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(IID_IDirectMusicPort, 0x08f2d8c9,0x37c2,0x11d2,0xb9,0xf9,0x00,0x00,0xf8,0x75,0xac,0x12); -DEFINE_GUID(IID_IDirectMusicThru, 0xced153e7, 0x3606, 0x11d2, 0xb9, 0xf9, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); -DEFINE_GUID(IID_IDirectMusicPortDownload,0xd2ac287a, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(IID_IDirectMusicDownload,0xd2ac287b, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(IID_IDirectMusicCollection,0xd2ac287c, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(IID_IDirectMusicInstrument,0xd2ac287d, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(IID_IDirectMusicDownloadedInstrument,0xd2ac287e, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - - -/* Alternate interface ID for IID_IDirectMusic, available in DX7 release and after. */ -DEFINE_GUID(IID_IDirectMusic2,0x6fc2cae1, 0xbc78, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); - -DEFINE_GUID(IID_IDirectMusic8,0x2d3629f7,0x813d,0x4939,0x85,0x08,0xf0,0x5c,0x6b,0x75,0xfd,0x97); - -#define IID_IDirectMusicThru8 IID_IDirectMusicThru -#define IID_IDirectMusicPortDownload8 IID_IDirectMusicPortDownload -#define IID_IDirectMusicDownload8 IID_IDirectMusicDownload -#define IID_IDirectMusicCollection8 IID_IDirectMusicCollection -#define IID_IDirectMusicInstrument8 IID_IDirectMusicInstrument -#define IID_IDirectMusicDownloadedInstrument8 IID_IDirectMusicDownloadedInstrument -#define IID_IDirectMusicPort8 IID_IDirectMusicPort - - -/* Property Query GUID_DMUS_PROP_GM_Hardware - Local GM set, no need to download - * Property Query GUID_DMUS_PROP_GS_Hardware - Local GS set, no need to download - * Property Query GUID_DMUS_PROP_XG_Hardware - Local XG set, no need to download - * Property Query GUID_DMUS_PROP_DLS1 - Support DLS level 1 - * Property Query GUID_DMUS_PROP_INSTRUMENT2 - Support new INSTRUMENT2 download format - * Property Query GUID_DMUS_PROP_XG_Capable - Support minimum requirements of XG - * Property Query GUID_DMUS_PROP_GS_Capable - Support minimum requirements of GS - * Property Query GUID_DMUS_PROP_SynthSink_DSOUND - Synthsink talks to DirectSound - * Property Query GUID_DMUS_PROP_SynthSink_WAVE - Synthsink talks to Wave device - * - * Item 0: Supported - * Returns a DWORD which is non-zero if the feature is supported - */ -DEFINE_GUID(GUID_DMUS_PROP_GM_Hardware, 0x178f2f24, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); -DEFINE_GUID(GUID_DMUS_PROP_GS_Hardware, 0x178f2f25, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); -DEFINE_GUID(GUID_DMUS_PROP_XG_Hardware, 0x178f2f26, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); -DEFINE_GUID(GUID_DMUS_PROP_XG_Capable, 0x6496aba1, 0x61b0, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); -DEFINE_GUID(GUID_DMUS_PROP_GS_Capable, 0x6496aba2, 0x61b0, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); -DEFINE_GUID(GUID_DMUS_PROP_DLS1, 0x178f2f27, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); -DEFINE_GUID(GUID_DMUS_PROP_DLS2, 0xf14599e5, 0x4689, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); -DEFINE_GUID(GUID_DMUS_PROP_INSTRUMENT2, 0x865fd372, 0x9f67, 0x11d2, 0x87, 0x2a, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(GUID_DMUS_PROP_SynthSink_DSOUND,0xaa97844, 0xc877, 0x11d1, 0x87, 0xc, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(GUID_DMUS_PROP_SynthSink_WAVE,0xaa97845, 0xc877, 0x11d1, 0x87, 0xc, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(GUID_DMUS_PROP_SampleMemorySize, 0x178f2f28, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); -DEFINE_GUID(GUID_DMUS_PROP_SamplePlaybackRate, 0x2a91f713, 0xa4bf, 0x11d2, 0xbb, 0xdf, 0x0, 0x60, 0x8, 0x33, 0xdb, 0xd8); - -/* Property Get/Set GUID_DMUS_PROP_WriteLatency - * - * Item 0: Synth buffer write latency, in milliseconds - * Get/Set SynthSink latency, the average time after the play head that the next buffer gets written. - */ -DEFINE_GUID(GUID_DMUS_PROP_WriteLatency,0x268a0fa0, 0x60f2, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); - -/* Property Get/Set GUID_DMUS_PROP_WritePeriod - * - * Item 0: Synth buffer write period, in milliseconds - * Get/Set SynthSink buffer write period, time span between successive writes. - */ -DEFINE_GUID(GUID_DMUS_PROP_WritePeriod,0x268a0fa1, 0x60f2, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); - -/* Property Get GUID_DMUS_PROP_MemorySize - * - * Item 0: Memory size - * Returns a DWORD containing the total number of bytes of sample RAM - */ -DEFINE_GUID(GUID_DMUS_PROP_MemorySize, 0x178f2f28, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); - -/* Property Set GUID_DMUS_PROP_WavesReverb - * - * Item 0: DMUS_WAVES_REVERB structure - * Sets reverb parameters - */ -DEFINE_GUID(GUID_DMUS_PROP_WavesReverb,0x4cb5622, 0x32e5, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); - -/* Property Set GUID_DMUS_PROP_Effects - * - * Item 0: DWORD with effects flags. - * Get/Set effects bits, same as dwEffectFlags in DMUS_PORTPARAMS and DMUS_PORTCAPS: - * DMUS_EFFECT_NONE - * DMUS_EFFECT_REVERB - * DMUS_EFFECT_CHORUS - */ -DEFINE_GUID(GUID_DMUS_PROP_Effects, 0xcda8d611, 0x684a, 0x11d2, 0x87, 0x1e, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Property Set GUID_DMUS_PROP_LegacyCaps - * - * Item 0: The MIDINCAPS or MIDIOUTCAPS which describes the port's underlying WinMM device. This property is only supported - * by ports which wrap WinMM devices. - */ - -DEFINE_GUID(GUID_DMUS_PROP_LegacyCaps,0xcfa7cdc2, 0x00a1, 0x11d2, 0xaa, 0xd5, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); - -/* Property Set GUID_DMUS_PROP_Volume - * - * Item 0: A long which contains an offset, in 1/100 dB, to be added to the final volume - * - */ -DEFINE_GUID(GUID_DMUS_PROP_Volume, 0xfedfae25L, 0xe46e, 0x11d1, 0xaa, 0xce, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); - -/* Min and Max values for setting volume with GUID_DMUS_PROP_Volume */ - -#define DMUS_VOLUME_MAX 2000 /* +20 dB */ -#define DMUS_VOLUME_MIN -20000 /* -200 dB */ - -#ifdef __cplusplus -}; /* extern "C" */ -#endif - -#include - -#endif /* #ifndef _DMUSICC_ */ +/************************************************************************ +* * +* dmusicc.h -- This module defines the DirectMusic core API's * +* * +* Copyright (c) Microsoft Corporation. All rights reserved. * +* * +************************************************************************/ + +#ifndef _DMUSICC_ +#define _DMUSICC_ + +#include + +#define COM_NO_WINDOWS_H +#include + +#include + +#include "dls1.h" +#include "dmerror.h" +#include "dmdls.h" +#include "dsound.h" +#include "dmusbuff.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef ULONGLONG SAMPLE_TIME; +typedef ULONGLONG SAMPLE_POSITION; +typedef SAMPLE_TIME *LPSAMPLE_TIME; + +#define DMUS_MAX_DESCRIPTION 128 +#define DMUS_MAX_DRIVER 128 + +typedef struct _DMUS_BUFFERDESC *LPDMUS_BUFFERDESC; +typedef struct _DMUS_BUFFERDESC +{ + DWORD dwSize; + DWORD dwFlags; + GUID guidBufferFormat; + DWORD cbBuffer; +} DMUS_BUFFERDESC; + +/* DMUS_EFFECT_ flags are used in the dwEffectFlags fields of both DMUS_PORTCAPS + * and DMUS_PORTPARAMS. + */ +#define DMUS_EFFECT_NONE 0x00000000 +#define DMUS_EFFECT_REVERB 0x00000001 +#define DMUS_EFFECT_CHORUS 0x00000002 +#define DMUS_EFFECT_DELAY 0x00000004 + +/* For DMUS_PORTCAPS dwClass + */ +#define DMUS_PC_INPUTCLASS (0) +#define DMUS_PC_OUTPUTCLASS (1) + +/* For DMUS_PORTCAPS dwFlags + */ +#define DMUS_PC_DLS (0x00000001) // Supports DLS downloading and DLS level 1. +#define DMUS_PC_EXTERNAL (0x00000002) // External MIDI module. +#define DMUS_PC_SOFTWARESYNTH (0x00000004) // Software synthesizer. +#define DMUS_PC_MEMORYSIZEFIXED (0x00000008) // Memory size is fixed. +#define DMUS_PC_GMINHARDWARE (0x00000010) // GM sound set is built in, no need to download. +#define DMUS_PC_GSINHARDWARE (0x00000020) // GS sound set is built in. +#define DMUS_PC_XGINHARDWARE (0x00000040) // XG sound set is built in. +#define DMUS_PC_DIRECTSOUND (0x00000080) // Connects to DirectSound via a DirectSound buffer. +#define DMUS_PC_SHAREABLE (0x00000100) // Synth can be actively shared by multiple apps at once. +#define DMUS_PC_DLS2 (0x00000200) // Supports DLS2 instruments. +#define DMUS_PC_AUDIOPATH (0x00000400) // Multiple outputs can be connected to DirectSound for audiopaths. +#define DMUS_PC_WAVE (0x00000800) // Supports streaming and one shot waves. + +#define DMUS_PC_SYSTEMMEMORY (0x7FFFFFFF) // Sample memory is system memory. + + +typedef struct _DMUS_PORTCAPS +{ + DWORD dwSize; + DWORD dwFlags; + GUID guidPort; + DWORD dwClass; + DWORD dwType; + DWORD dwMemorySize; + DWORD dwMaxChannelGroups; + DWORD dwMaxVoices; + DWORD dwMaxAudioChannels; + DWORD dwEffectFlags; + WCHAR wszDescription[DMUS_MAX_DESCRIPTION]; +} DMUS_PORTCAPS; + +typedef DMUS_PORTCAPS *LPDMUS_PORTCAPS; + +/* Values for DMUS_PORTCAPS dwType. This field indicates the underlying + * driver type of the port. + */ +#define DMUS_PORT_WINMM_DRIVER (0) +#define DMUS_PORT_USER_MODE_SYNTH (1) +#define DMUS_PORT_KERNEL_MODE (2) + +/* These flags (set in dwValidParams) indicate which other members of the */ +/* DMUS_PORTPARAMS are valid. */ +/* */ +#define DMUS_PORTPARAMS_VOICES 0x00000001 +#define DMUS_PORTPARAMS_CHANNELGROUPS 0x00000002 +#define DMUS_PORTPARAMS_AUDIOCHANNELS 0x00000004 +#define DMUS_PORTPARAMS_SAMPLERATE 0x00000008 +#define DMUS_PORTPARAMS_EFFECTS 0x00000020 +#define DMUS_PORTPARAMS_SHARE 0x00000040 +#define DMUS_PORTPARAMS_FEATURES 0x00000080 /* DirectX 8.0 and above */ + +typedef struct _DMUS_PORTPARAMS +{ + DWORD dwSize; + DWORD dwValidParams; + DWORD dwVoices; + DWORD dwChannelGroups; + DWORD dwAudioChannels; + DWORD dwSampleRate; + DWORD dwEffectFlags; + BOOL fShare; +} DMUS_PORTPARAMS7; + +typedef struct _DMUS_PORTPARAMS8 +{ + DWORD dwSize; + DWORD dwValidParams; + DWORD dwVoices; + DWORD dwChannelGroups; + DWORD dwAudioChannels; + DWORD dwSampleRate; + DWORD dwEffectFlags; + BOOL fShare; + DWORD dwFeatures; +} DMUS_PORTPARAMS8; + +#define DMUS_PORT_FEATURE_AUDIOPATH 0x00000001 /* Supports audiopath connection to DirectSound buffers. */ +#define DMUS_PORT_FEATURE_STREAMING 0x00000002 /* Supports streaming waves through the synth. */ + + +typedef DMUS_PORTPARAMS8 DMUS_PORTPARAMS; +typedef DMUS_PORTPARAMS *LPDMUS_PORTPARAMS; + +typedef struct _DMUS_SYNTHSTATS *LPDMUS_SYNTHSTATS; +typedef struct _DMUS_SYNTHSTATS8 *LPDMUS_SYNTHSTATS8; +typedef struct _DMUS_SYNTHSTATS +{ + DWORD dwSize; /* Size in bytes of the structure */ + DWORD dwValidStats; /* Flags indicating which fields below are valid. */ + DWORD dwVoices; /* Average number of voices playing. */ + DWORD dwTotalCPU; /* Total CPU usage as percent * 100. */ + DWORD dwCPUPerVoice; /* CPU per voice as percent * 100. */ + DWORD dwLostNotes; /* Number of notes lost in 1 second. */ + DWORD dwFreeMemory; /* Free memory in bytes */ + long lPeakVolume; /* Decibel level * 100. */ +} DMUS_SYNTHSTATS; + +typedef struct _DMUS_SYNTHSTATS8 +{ + DWORD dwSize; /* Size in bytes of the structure */ + DWORD dwValidStats; /* Flags indicating which fields below are valid. */ + DWORD dwVoices; /* Average number of voices playing. */ + DWORD dwTotalCPU; /* Total CPU usage as percent * 100. */ + DWORD dwCPUPerVoice; /* CPU per voice as percent * 100. */ + DWORD dwLostNotes; /* Number of notes lost in 1 second. */ + DWORD dwFreeMemory; /* Free memory in bytes */ + long lPeakVolume; /* Decibel level * 100. */ + DWORD dwSynthMemUse; /* Memory used by synth wave data */ +} DMUS_SYNTHSTATS8; + +#define DMUS_SYNTHSTATS_VOICES (1 << 0) +#define DMUS_SYNTHSTATS_TOTAL_CPU (1 << 1) +#define DMUS_SYNTHSTATS_CPU_PER_VOICE (1 << 2) +#define DMUS_SYNTHSTATS_LOST_NOTES (1 << 3) +#define DMUS_SYNTHSTATS_PEAK_VOLUME (1 << 4) +#define DMUS_SYNTHSTATS_FREE_MEMORY (1 << 5) + +#define DMUS_SYNTHSTATS_SYSTEMMEMORY DMUS_PC_SYSTEMMEMORY + +typedef struct _DMUS_WAVES_REVERB_PARAMS +{ + float fInGain; /* Input gain in dB (to avoid output overflows) */ + float fReverbMix; /* Reverb mix in dB. 0dB means 100% wet reverb (no direct signal) + Negative values gives less wet signal. + The coeficients are calculated so that the overall output level stays + (approximately) constant regardless of the ammount of reverb mix. */ + float fReverbTime; /* The reverb decay time, in milliseconds. */ + float fHighFreqRTRatio; /* The ratio of the high frequencies to the global reverb time. + Unless very 'splashy-bright' reverbs are wanted, this should be set to + a value < 1.0. + For example if dRevTime==1000ms and dHighFreqRTRatio=0.1 than the + decay time for high frequencies will be 100ms.*/ + +} DMUS_WAVES_REVERB_PARAMS; + +/* Note: Default values for Reverb are: + fInGain = 0.0dB (no change in level) + fReverbMix = -10.0dB (a reasonable reverb mix) + fReverbTime = 1000.0ms (one second global reverb time) + fHighFreqRTRatio = 0.001 (the ratio of the high frequencies to the global reverb time) +*/ + +typedef enum +{ + DMUS_CLOCK_SYSTEM = 0, + DMUS_CLOCK_WAVE = 1 +} DMUS_CLOCKTYPE; + +#define DMUS_CLOCKF_GLOBAL 0x00000001 + +typedef struct _DMUS_CLOCKINFO7 *LPDMUS_CLOCKINFO7; +typedef struct _DMUS_CLOCKINFO7 +{ + DWORD dwSize; + DMUS_CLOCKTYPE ctType; + GUID guidClock; /* Identifies this time source */ + WCHAR wszDescription[DMUS_MAX_DESCRIPTION]; +} DMUS_CLOCKINFO7; + +typedef struct _DMUS_CLOCKINFO8 *LPDMUS_CLOCKINFO8; +typedef struct _DMUS_CLOCKINFO8 +{ + DWORD dwSize; + DMUS_CLOCKTYPE ctType; + GUID guidClock; /* Identifies this time source */ + WCHAR wszDescription[DMUS_MAX_DESCRIPTION]; + DWORD dwFlags; +} DMUS_CLOCKINFO8; + +typedef DMUS_CLOCKINFO8 DMUS_CLOCKINFO; +typedef DMUS_CLOCKINFO *LPDMUS_CLOCKINFO; + +/* Default bus identifiers + * + * The first 17 are direct mappings to the destinations defined in both + * the MMA DLS Level 2 specification and the Microsoft Multi-Channel audio + * specification. + */ +#define DSBUSID_FIRST_SPKR_LOC 0 +#define DSBUSID_FRONT_LEFT 0 +#define DSBUSID_LEFT 0 /* Front left is also just left */ +#define DSBUSID_FRONT_RIGHT 1 +#define DSBUSID_RIGHT 1 /* Ditto front right */ +#define DSBUSID_FRONT_CENTER 2 +#define DSBUSID_LOW_FREQUENCY 3 +#define DSBUSID_BACK_LEFT 4 +#define DSBUSID_BACK_RIGHT 5 +#define DSBUSID_FRONT_LEFT_OF_CENTER 6 +#define DSBUSID_FRONT_RIGHT_OF_CENTER 7 +#define DSBUSID_BACK_CENTER 8 +#define DSBUSID_SIDE_LEFT 9 +#define DSBUSID_SIDE_RIGHT 10 +#define DSBUSID_TOP_CENTER 11 +#define DSBUSID_TOP_FRONT_LEFT 12 +#define DSBUSID_TOP_FRONT_CENTER 13 +#define DSBUSID_TOP_FRONT_RIGHT 14 +#define DSBUSID_TOP_BACK_LEFT 15 +#define DSBUSID_TOP_BACK_CENTER 16 +#define DSBUSID_TOP_BACK_RIGHT 17 +#define DSBUSID_LAST_SPKR_LOC 17 + +#define DSBUSID_IS_SPKR_LOC(id) ( ((id) >= DSBUSID_FIRST_SPKR_LOC) && ((id) <= DSBUSID_LAST_SPKR_LOC) ) + +/* These bus identifiers are for the standard DLS effect sends + */ +#define DSBUSID_REVERB_SEND 64 +#define DSBUSID_CHORUS_SEND 65 + +/* Dynamic bus identifiers start here. See the documentation for how + * synthesizers map the output of voices to static and dynamic + * bus identifiers. + */ +#define DSBUSID_DYNAMIC_0 512 + +/* Null bus, used to identify busses that have no function mapping. +*/ +#define DSBUSID_NULL 0xFFFFFFFF + +interface IDirectMusic; +interface IDirectMusic8; +interface IDirectMusicBuffer; +interface IDirectMusicPort; +interface IDirectMusicThru; +interface IReferenceClock; + +#ifndef __cplusplus + +typedef interface IDirectMusic IDirectMusic; +typedef interface IDirectMusic8 IDirectMusic8; +typedef interface IDirectMusicPort IDirectMusicPort; +typedef interface IDirectMusicBuffer IDirectMusicBuffer; +typedef interface IDirectMusicThru IDirectMusicThru; +typedef interface IReferenceClock IReferenceClock; + +#endif /* C++ */ + +typedef IDirectMusic *LPDIRECTMUSIC; +typedef IDirectMusic8 *LPDIRECTMUSIC8; +typedef IDirectMusicPort *LPDIRECTMUSICPORT; +typedef IDirectMusicBuffer *LPDIRECTMUSICBUFFER; + +#undef INTERFACE +#define INTERFACE IDirectMusic +DECLARE_INTERFACE_(IDirectMusic, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusic */ + STDMETHOD(EnumPort) (THIS_ DWORD dwIndex, + LPDMUS_PORTCAPS pPortCaps) PURE; + STDMETHOD(CreateMusicBuffer) (THIS_ LPDMUS_BUFFERDESC pBufferDesc, + LPDIRECTMUSICBUFFER *ppBuffer, + LPUNKNOWN pUnkOuter) PURE; + STDMETHOD(CreatePort) (THIS_ REFCLSID rclsidPort, + LPDMUS_PORTPARAMS pPortParams, + LPDIRECTMUSICPORT *ppPort, + LPUNKNOWN pUnkOuter) PURE; + STDMETHOD(EnumMasterClock) (THIS_ DWORD dwIndex, + LPDMUS_CLOCKINFO lpClockInfo) PURE; + STDMETHOD(GetMasterClock) (THIS_ LPGUID pguidClock, + IReferenceClock **ppReferenceClock) PURE; + STDMETHOD(SetMasterClock) (THIS_ REFGUID rguidClock) PURE; + STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE; + STDMETHOD(GetDefaultPort) (THIS_ LPGUID pguidPort) PURE; + STDMETHOD(SetDirectSound) (THIS_ LPDIRECTSOUND pDirectSound, + HWND hWnd) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirectMusic8 +DECLARE_INTERFACE_(IDirectMusic8, IDirectMusic) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusic */ + STDMETHOD(EnumPort) (THIS_ DWORD dwIndex, + LPDMUS_PORTCAPS pPortCaps) PURE; + STDMETHOD(CreateMusicBuffer) (THIS_ LPDMUS_BUFFERDESC pBufferDesc, + LPDIRECTMUSICBUFFER *ppBuffer, + LPUNKNOWN pUnkOuter) PURE; + STDMETHOD(CreatePort) (THIS_ REFCLSID rclsidPort, + LPDMUS_PORTPARAMS pPortParams, + LPDIRECTMUSICPORT *ppPort, + LPUNKNOWN pUnkOuter) PURE; + STDMETHOD(EnumMasterClock) (THIS_ DWORD dwIndex, + LPDMUS_CLOCKINFO lpClockInfo) PURE; + STDMETHOD(GetMasterClock) (THIS_ LPGUID pguidClock, + IReferenceClock **ppReferenceClock) PURE; + STDMETHOD(SetMasterClock) (THIS_ REFGUID rguidClock) PURE; + STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE; + STDMETHOD(GetDefaultPort) (THIS_ LPGUID pguidPort) PURE; + STDMETHOD(SetDirectSound) (THIS_ LPDIRECTSOUND pDirectSound, + HWND hWnd) PURE; + /* IDirectMusic8 */ + STDMETHOD(SetExternalMasterClock) + (THIS_ IReferenceClock *pClock) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirectMusicBuffer +DECLARE_INTERFACE_(IDirectMusicBuffer, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicBuffer */ + STDMETHOD(Flush) (THIS) PURE; + STDMETHOD(TotalTime) (THIS_ LPREFERENCE_TIME prtTime) PURE; + + STDMETHOD(PackStructured) (THIS_ REFERENCE_TIME rt, + DWORD dwChannelGroup, + DWORD dwChannelMessage) PURE; + + STDMETHOD(PackUnstructured) (THIS_ REFERENCE_TIME rt, + DWORD dwChannelGroup, + DWORD cb, + LPBYTE lpb) PURE; + + STDMETHOD(ResetReadPtr) (THIS) PURE; + STDMETHOD(GetNextEvent) (THIS_ LPREFERENCE_TIME prt, + LPDWORD pdwChannelGroup, + LPDWORD pdwLength, + LPBYTE *ppData) PURE; + + STDMETHOD(GetRawBufferPtr) (THIS_ LPBYTE *ppData) PURE; + STDMETHOD(GetStartTime) (THIS_ LPREFERENCE_TIME prt) PURE; + STDMETHOD(GetUsedBytes) (THIS_ LPDWORD pcb) PURE; + STDMETHOD(GetMaxBytes) (THIS_ LPDWORD pcb) PURE; + STDMETHOD(GetBufferFormat) (THIS_ LPGUID pGuidFormat) PURE; + + STDMETHOD(SetStartTime) (THIS_ REFERENCE_TIME rt) PURE; + STDMETHOD(SetUsedBytes) (THIS_ DWORD cb) PURE; +}; + +typedef IDirectMusicBuffer IDirectMusicBuffer8; +typedef IDirectMusicBuffer8 *LPDIRECTMUSICBUFFER8; + +#undef INTERFACE +#define INTERFACE IDirectMusicInstrument +DECLARE_INTERFACE_(IDirectMusicInstrument, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicInstrument */ + STDMETHOD(GetPatch) (THIS_ DWORD* pdwPatch) PURE; + STDMETHOD(SetPatch) (THIS_ DWORD dwPatch) PURE; +}; + +typedef IDirectMusicInstrument IDirectMusicInstrument8; +typedef IDirectMusicInstrument8 *LPDIRECTMUSICINSTRUMENT8; + +#undef INTERFACE +#define INTERFACE IDirectMusicDownloadedInstrument +DECLARE_INTERFACE_(IDirectMusicDownloadedInstrument, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicDownloadedInstrument */ + /* None at this time */ +}; + +typedef IDirectMusicDownloadedInstrument IDirectMusicDownloadedInstrument8; +typedef IDirectMusicDownloadedInstrument8 *LPDIRECTMUSICDOWNLOADEDINSTRUMENT8; + +#undef INTERFACE +#define INTERFACE IDirectMusicCollection +DECLARE_INTERFACE_(IDirectMusicCollection, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicCollection */ + STDMETHOD(GetInstrument) (THIS_ DWORD dwPatch, + IDirectMusicInstrument** ppInstrument) PURE; + STDMETHOD(EnumInstrument) (THIS_ DWORD dwIndex, + DWORD* pdwPatch, + LPWSTR pwszName, + DWORD dwNameLen) PURE; +}; + +typedef IDirectMusicCollection IDirectMusicCollection8; +typedef IDirectMusicCollection8 *LPDIRECTMUSICCOLLECTION8; + +#undef INTERFACE +#define INTERFACE IDirectMusicDownload +DECLARE_INTERFACE_(IDirectMusicDownload , IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicDownload */ + STDMETHOD(GetBuffer) (THIS_ void** ppvBuffer, + DWORD* pdwSize) PURE; +}; + +typedef IDirectMusicDownload IDirectMusicDownload8; +typedef IDirectMusicDownload8 *LPDIRECTMUSICDOWNLOAD8; + +#undef INTERFACE +#define INTERFACE IDirectMusicPortDownload +DECLARE_INTERFACE_(IDirectMusicPortDownload, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicPortDownload */ + STDMETHOD(GetBuffer) (THIS_ DWORD dwDLId, + IDirectMusicDownload** ppIDMDownload) PURE; + STDMETHOD(AllocateBuffer) (THIS_ DWORD dwSize, + IDirectMusicDownload** ppIDMDownload) PURE; + STDMETHOD(GetDLId) (THIS_ DWORD* pdwStartDLId, + DWORD dwCount) PURE; + STDMETHOD(GetAppend) (THIS_ DWORD* pdwAppend) PURE; + STDMETHOD(Download) (THIS_ IDirectMusicDownload* pIDMDownload) PURE; + STDMETHOD(Unload) (THIS_ IDirectMusicDownload* pIDMDownload) PURE; +}; + +typedef IDirectMusicPortDownload IDirectMusicPortDownload8; +typedef IDirectMusicPortDownload8 *LPDIRECTMUSICPORTDOWNLOAD8; + +/* Standard values for voice priorities. Numerically higher priorities are higher in priority. + * These priorities are used to set the voice priority for all voices on a channel. They are + * used in the dwPriority parameter of IDirectMusicPort::GetPriority and returned in the + * lpwPriority parameter of pdwPriority. + * + * These priorities are shared with DirectSound. + */ + +#ifndef _DIRECTAUDIO_PRIORITIES_DEFINED_ +#define _DIRECTAUDIO_PRIORITIES_DEFINED_ + +#define DAUD_CRITICAL_VOICE_PRIORITY (0xF0000000) +#define DAUD_HIGH_VOICE_PRIORITY (0xC0000000) +#define DAUD_STANDARD_VOICE_PRIORITY (0x80000000) +#define DAUD_LOW_VOICE_PRIORITY (0x40000000) +#define DAUD_PERSIST_VOICE_PRIORITY (0x10000000) + +/* These are the default priorities assigned if not overridden. By default priorities are + * equal across channel groups (e.g. channel 5 on channel group 1 has the same priority as + * channel 5 on channel group 2). + * + * In accordance with DLS level 1, channel 10 has the highest priority, followed by 1 through 16 + * except for 10. + */ +#define DAUD_CHAN1_VOICE_PRIORITY_OFFSET (0x0000000E) +#define DAUD_CHAN2_VOICE_PRIORITY_OFFSET (0x0000000D) +#define DAUD_CHAN3_VOICE_PRIORITY_OFFSET (0x0000000C) +#define DAUD_CHAN4_VOICE_PRIORITY_OFFSET (0x0000000B) +#define DAUD_CHAN5_VOICE_PRIORITY_OFFSET (0x0000000A) +#define DAUD_CHAN6_VOICE_PRIORITY_OFFSET (0x00000009) +#define DAUD_CHAN7_VOICE_PRIORITY_OFFSET (0x00000008) +#define DAUD_CHAN8_VOICE_PRIORITY_OFFSET (0x00000007) +#define DAUD_CHAN9_VOICE_PRIORITY_OFFSET (0x00000006) +#define DAUD_CHAN10_VOICE_PRIORITY_OFFSET (0x0000000F) +#define DAUD_CHAN11_VOICE_PRIORITY_OFFSET (0x00000005) +#define DAUD_CHAN12_VOICE_PRIORITY_OFFSET (0x00000004) +#define DAUD_CHAN13_VOICE_PRIORITY_OFFSET (0x00000003) +#define DAUD_CHAN14_VOICE_PRIORITY_OFFSET (0x00000002) +#define DAUD_CHAN15_VOICE_PRIORITY_OFFSET (0x00000001) +#define DAUD_CHAN16_VOICE_PRIORITY_OFFSET (0x00000000) + + +#define DAUD_CHAN1_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN1_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN2_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN2_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN3_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN3_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN4_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN4_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN5_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN5_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN6_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN6_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN7_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN7_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN8_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN8_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN9_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN9_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN10_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN10_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN11_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN11_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN12_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN12_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN13_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN13_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN14_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN14_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN15_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN15_VOICE_PRIORITY_OFFSET) +#define DAUD_CHAN16_DEF_VOICE_PRIORITY (DAUD_STANDARD_VOICE_PRIORITY | DAUD_CHAN16_VOICE_PRIORITY_OFFSET) + +#endif /* _DIRECTAUDIO_PRIORITIES_DEFINED_ */ + + +#undef INTERFACE +#define INTERFACE IDirectMusicPort +DECLARE_INTERFACE_(IDirectMusicPort, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicPort */ + /* */ + STDMETHOD(PlayBuffer) (THIS_ LPDIRECTMUSICBUFFER pBuffer) PURE; + STDMETHOD(SetReadNotificationHandle) (THIS_ HANDLE hEvent) PURE; + STDMETHOD(Read) (THIS_ LPDIRECTMUSICBUFFER pBuffer) PURE; + STDMETHOD(DownloadInstrument) (THIS_ IDirectMusicInstrument *pInstrument, + IDirectMusicDownloadedInstrument **ppDownloadedInstrument, + DMUS_NOTERANGE *pNoteRanges, + DWORD dwNumNoteRanges) PURE; + STDMETHOD(UnloadInstrument) (THIS_ IDirectMusicDownloadedInstrument *pDownloadedInstrument) PURE; + STDMETHOD(GetLatencyClock) (THIS_ IReferenceClock **ppClock) PURE; + STDMETHOD(GetRunningStats) (THIS_ LPDMUS_SYNTHSTATS pStats) PURE; + STDMETHOD(Compact) (THIS) PURE; + STDMETHOD(GetCaps) (THIS_ LPDMUS_PORTCAPS pPortCaps) PURE; + STDMETHOD(DeviceIoControl) (THIS_ DWORD dwIoControlCode, + LPVOID lpInBuffer, + DWORD nInBufferSize, + LPVOID lpOutBuffer, + DWORD nOutBufferSize, + LPDWORD lpBytesReturned, + LPOVERLAPPED lpOverlapped) PURE; + STDMETHOD(SetNumChannelGroups) (THIS_ DWORD dwChannelGroups) PURE; + STDMETHOD(GetNumChannelGroups) (THIS_ LPDWORD pdwChannelGroups) PURE; + STDMETHOD(Activate) (THIS_ BOOL fActive) PURE; + STDMETHOD(SetChannelPriority) (THIS_ DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority) PURE; + STDMETHOD(GetChannelPriority) (THIS_ DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority) PURE; + STDMETHOD(SetDirectSound) (THIS_ LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize, LPDWORD pdwBufferSize) PURE; +}; + +typedef IDirectMusicPort IDirectMusicPort8; +typedef IDirectMusicPort8 *LPDIRECTMUSICPORT8; + +#undef INTERFACE +#define INTERFACE IDirectMusicThru +DECLARE_INTERFACE_(IDirectMusicThru, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicThru + */ + STDMETHOD(ThruChannel) (THIS_ DWORD dwSourceChannelGroup, + DWORD dwSourceChannel, + DWORD dwDestinationChannelGroup, + DWORD dwDestinationChannel, + LPDIRECTMUSICPORT pDestinationPort) PURE; +}; + +typedef IDirectMusicThru IDirectMusicThru8; +typedef IDirectMusicThru8 *LPDIRECTMUSICTHRU8; + +#ifndef __IReferenceClock_INTERFACE_DEFINED__ +#define __IReferenceClock_INTERFACE_DEFINED__ + +DEFINE_GUID(IID_IReferenceClock,0x56a86897,0x0ad4,0x11ce,0xb0,0x3a,0x00,0x20,0xaf,0x0b,0xa7,0x70); + +#undef INTERFACE +#define INTERFACE IReferenceClock +DECLARE_INTERFACE_(IReferenceClock, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IReferenceClock */ + /* */ + + /* get the time now */ + STDMETHOD(GetTime) (THIS_ REFERENCE_TIME *pTime) PURE; + + /* ask for an async notification that a time has elapsed */ + STDMETHOD(AdviseTime) (THIS_ REFERENCE_TIME baseTime, /* base time */ + REFERENCE_TIME streamTime, /* stream offset time */ + HANDLE hEvent, /* advise via this event */ + DWORD * pdwAdviseCookie) PURE; /* where your cookie goes */ + + /* ask for an async periodic notification that a time has elapsed */ + STDMETHOD(AdvisePeriodic) (THIS_ REFERENCE_TIME startTime, /* starting at this time */ + REFERENCE_TIME periodTime, /* time between notifications */ + HANDLE hSemaphore, /* advise via a semaphore */ + DWORD * pdwAdviseCookie) PURE; /* where your cookie goes */ + + /* cancel a request for notification */ + STDMETHOD(Unadvise) (THIS_ DWORD dwAdviseCookie) PURE; +}; + +#endif /* __IReferenceClock_INTERFACE_DEFINED__ */ + +DEFINE_GUID(CLSID_DirectMusic,0x636b9f10,0x0c7d,0x11d1,0x95,0xb2,0x00,0x20,0xaf,0xdc,0x74,0x21); +DEFINE_GUID(CLSID_DirectMusicCollection,0x480ff4b0, 0x28b2, 0x11d1, 0xbe, 0xf7, 0x0, 0xc0, 0x4f, 0xbf, 0x8f, 0xef); +DEFINE_GUID(CLSID_DirectMusicSynth,0x58C2B4D0,0x46E7,0x11D1,0x89,0xAC,0x00,0xA0,0xC9,0x05,0x41,0x29); + +DEFINE_GUID(IID_IDirectMusic,0x6536115a,0x7b2d,0x11d2,0xba,0x18,0x00,0x00,0xf8,0x75,0xac,0x12); +DEFINE_GUID(IID_IDirectMusicBuffer,0xd2ac2878, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(IID_IDirectMusicPort, 0x08f2d8c9,0x37c2,0x11d2,0xb9,0xf9,0x00,0x00,0xf8,0x75,0xac,0x12); +DEFINE_GUID(IID_IDirectMusicThru, 0xced153e7, 0x3606, 0x11d2, 0xb9, 0xf9, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); +DEFINE_GUID(IID_IDirectMusicPortDownload,0xd2ac287a, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(IID_IDirectMusicDownload,0xd2ac287b, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(IID_IDirectMusicCollection,0xd2ac287c, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(IID_IDirectMusicInstrument,0xd2ac287d, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(IID_IDirectMusicDownloadedInstrument,0xd2ac287e, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + + +/* Alternate interface ID for IID_IDirectMusic, available in DX7 release and after. */ +DEFINE_GUID(IID_IDirectMusic2,0x6fc2cae1, 0xbc78, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); + +DEFINE_GUID(IID_IDirectMusic8,0x2d3629f7,0x813d,0x4939,0x85,0x08,0xf0,0x5c,0x6b,0x75,0xfd,0x97); + +#define IID_IDirectMusicThru8 IID_IDirectMusicThru +#define IID_IDirectMusicPortDownload8 IID_IDirectMusicPortDownload +#define IID_IDirectMusicDownload8 IID_IDirectMusicDownload +#define IID_IDirectMusicCollection8 IID_IDirectMusicCollection +#define IID_IDirectMusicInstrument8 IID_IDirectMusicInstrument +#define IID_IDirectMusicDownloadedInstrument8 IID_IDirectMusicDownloadedInstrument +#define IID_IDirectMusicPort8 IID_IDirectMusicPort + + +/* Property Query GUID_DMUS_PROP_GM_Hardware - Local GM set, no need to download + * Property Query GUID_DMUS_PROP_GS_Hardware - Local GS set, no need to download + * Property Query GUID_DMUS_PROP_XG_Hardware - Local XG set, no need to download + * Property Query GUID_DMUS_PROP_DLS1 - Support DLS level 1 + * Property Query GUID_DMUS_PROP_INSTRUMENT2 - Support new INSTRUMENT2 download format + * Property Query GUID_DMUS_PROP_XG_Capable - Support minimum requirements of XG + * Property Query GUID_DMUS_PROP_GS_Capable - Support minimum requirements of GS + * Property Query GUID_DMUS_PROP_SynthSink_DSOUND - Synthsink talks to DirectSound + * Property Query GUID_DMUS_PROP_SynthSink_WAVE - Synthsink talks to Wave device + * + * Item 0: Supported + * Returns a DWORD which is non-zero if the feature is supported + */ +DEFINE_GUID(GUID_DMUS_PROP_GM_Hardware, 0x178f2f24, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); +DEFINE_GUID(GUID_DMUS_PROP_GS_Hardware, 0x178f2f25, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); +DEFINE_GUID(GUID_DMUS_PROP_XG_Hardware, 0x178f2f26, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); +DEFINE_GUID(GUID_DMUS_PROP_XG_Capable, 0x6496aba1, 0x61b0, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); +DEFINE_GUID(GUID_DMUS_PROP_GS_Capable, 0x6496aba2, 0x61b0, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); +DEFINE_GUID(GUID_DMUS_PROP_DLS1, 0x178f2f27, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); +DEFINE_GUID(GUID_DMUS_PROP_DLS2, 0xf14599e5, 0x4689, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); +DEFINE_GUID(GUID_DMUS_PROP_INSTRUMENT2, 0x865fd372, 0x9f67, 0x11d2, 0x87, 0x2a, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(GUID_DMUS_PROP_SynthSink_DSOUND,0xaa97844, 0xc877, 0x11d1, 0x87, 0xc, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(GUID_DMUS_PROP_SynthSink_WAVE,0xaa97845, 0xc877, 0x11d1, 0x87, 0xc, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(GUID_DMUS_PROP_SampleMemorySize, 0x178f2f28, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); +DEFINE_GUID(GUID_DMUS_PROP_SamplePlaybackRate, 0x2a91f713, 0xa4bf, 0x11d2, 0xbb, 0xdf, 0x0, 0x60, 0x8, 0x33, 0xdb, 0xd8); + +/* Property Get/Set GUID_DMUS_PROP_WriteLatency + * + * Item 0: Synth buffer write latency, in milliseconds + * Get/Set SynthSink latency, the average time after the play head that the next buffer gets written. + */ +DEFINE_GUID(GUID_DMUS_PROP_WriteLatency,0x268a0fa0, 0x60f2, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); + +/* Property Get/Set GUID_DMUS_PROP_WritePeriod + * + * Item 0: Synth buffer write period, in milliseconds + * Get/Set SynthSink buffer write period, time span between successive writes. + */ +DEFINE_GUID(GUID_DMUS_PROP_WritePeriod,0x268a0fa1, 0x60f2, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); + +/* Property Get GUID_DMUS_PROP_MemorySize + * + * Item 0: Memory size + * Returns a DWORD containing the total number of bytes of sample RAM + */ +DEFINE_GUID(GUID_DMUS_PROP_MemorySize, 0x178f2f28, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); + +/* Property Set GUID_DMUS_PROP_WavesReverb + * + * Item 0: DMUS_WAVES_REVERB structure + * Sets reverb parameters + */ +DEFINE_GUID(GUID_DMUS_PROP_WavesReverb,0x4cb5622, 0x32e5, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); + +/* Property Set GUID_DMUS_PROP_Effects + * + * Item 0: DWORD with effects flags. + * Get/Set effects bits, same as dwEffectFlags in DMUS_PORTPARAMS and DMUS_PORTCAPS: + * DMUS_EFFECT_NONE + * DMUS_EFFECT_REVERB + * DMUS_EFFECT_CHORUS + */ +DEFINE_GUID(GUID_DMUS_PROP_Effects, 0xcda8d611, 0x684a, 0x11d2, 0x87, 0x1e, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Property Set GUID_DMUS_PROP_LegacyCaps + * + * Item 0: The MIDINCAPS or MIDIOUTCAPS which describes the port's underlying WinMM device. This property is only supported + * by ports which wrap WinMM devices. + */ + +DEFINE_GUID(GUID_DMUS_PROP_LegacyCaps,0xcfa7cdc2, 0x00a1, 0x11d2, 0xaa, 0xd5, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); + +/* Property Set GUID_DMUS_PROP_Volume + * + * Item 0: A long which contains an offset, in 1/100 dB, to be added to the final volume + * + */ +DEFINE_GUID(GUID_DMUS_PROP_Volume, 0xfedfae25L, 0xe46e, 0x11d1, 0xaa, 0xce, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); + +/* Min and Max values for setting volume with GUID_DMUS_PROP_Volume */ + +#define DMUS_VOLUME_MAX 2000 /* +20 dB */ +#define DMUS_VOLUME_MIN -20000 /* -200 dB */ + +#ifdef __cplusplus +}; /* extern "C" */ +#endif + +#include + +#endif /* #ifndef _DMUSICC_ */ diff --git a/src/dep/include/DXSDK/include/dmusicf.h b/src/dep/include/DXSDK/include/dmusicf.h index 4f51838..920b2fc 100644 --- a/src/dep/include/DXSDK/include/dmusicf.h +++ b/src/dep/include/DXSDK/include/dmusicf.h @@ -1,2199 +1,2199 @@ -/************************************************************************ -* * -* dmusicf.h -- This module defines the DirectMusic file formats * -* * -* Copyright (c) Microsoft Corporation. All rights reserved. * -* * -************************************************************************/ - -#ifndef _DMUSICF_ -#define _DMUSICF_ - - -#include - -#define COM_NO_WINDOWS_H -#include - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -interface IDirectMusicCollection; -#ifndef __cplusplus -typedef interface IDirectMusicCollection IDirectMusicCollection; -#endif - -/* Common chunks */ - -#define DMUS_FOURCC_GUID_CHUNK mmioFOURCC('g','u','i','d') -#define DMUS_FOURCC_INFO_LIST mmioFOURCC('I','N','F','O') -#define DMUS_FOURCC_UNFO_LIST mmioFOURCC('U','N','F','O') -#define DMUS_FOURCC_UNAM_CHUNK mmioFOURCC('U','N','A','M') -#define DMUS_FOURCC_UART_CHUNK mmioFOURCC('U','A','R','T') -#define DMUS_FOURCC_UCOP_CHUNK mmioFOURCC('U','C','O','P') -#define DMUS_FOURCC_USBJ_CHUNK mmioFOURCC('U','S','B','J') -#define DMUS_FOURCC_UCMT_CHUNK mmioFOURCC('U','C','M','T') -#define DMUS_FOURCC_CATEGORY_CHUNK mmioFOURCC('c','a','t','g') -#define DMUS_FOURCC_VERSION_CHUNK mmioFOURCC('v','e','r','s') - -/* The following structures are used by the Tracks, and are the packed structures */ -/* that are passed to the Tracks inside the IStream. */ - - -typedef struct _DMUS_IO_SEQ_ITEM -{ - MUSIC_TIME mtTime; - MUSIC_TIME mtDuration; - DWORD dwPChannel; - short nOffset; - BYTE bStatus; - BYTE bByte1; - BYTE bByte2; -} DMUS_IO_SEQ_ITEM; - - -typedef struct _DMUS_IO_CURVE_ITEM -{ - MUSIC_TIME mtStart; - MUSIC_TIME mtDuration; - MUSIC_TIME mtResetDuration; - DWORD dwPChannel; - short nOffset; - short nStartValue; - short nEndValue; - short nResetValue; - BYTE bType; - BYTE bCurveShape; - BYTE bCCData; - BYTE bFlags; - /* Following was added for DirectX8. */ - WORD wParamType; /* RPN or NRPN parameter number. */ - WORD wMergeIndex; /* Allows multiple parameters to be merged (pitchbend, volume, and expression.) */ -} DMUS_IO_CURVE_ITEM; - - -typedef struct _DMUS_IO_TEMPO_ITEM -{ - MUSIC_TIME lTime; - double dblTempo; -} DMUS_IO_TEMPO_ITEM; - - -typedef struct _DMUS_IO_SYSEX_ITEM -{ - MUSIC_TIME mtTime; - DWORD dwPChannel; - DWORD dwSysExLength; -} DMUS_IO_SYSEX_ITEM; - -typedef DMUS_CHORD_KEY DMUS_CHORD_PARAM; /* DMUS_CHORD_KEY defined in dmusici.h */ - -typedef struct _DMUS_RHYTHM_PARAM -{ - DMUS_TIMESIGNATURE TimeSig; - DWORD dwRhythmPattern; -} DMUS_RHYTHM_PARAM; - -typedef struct _DMUS_TEMPO_PARAM -{ - MUSIC_TIME mtTime; - double dblTempo; -} DMUS_TEMPO_PARAM; - - -typedef struct _DMUS_MUTE_PARAM -{ - DWORD dwPChannel; - DWORD dwPChannelMap; - BOOL fMute; -} DMUS_MUTE_PARAM; - -/* Style chunks */ - -#define DMUS_FOURCC_STYLE_FORM mmioFOURCC('D','M','S','T') -#define DMUS_FOURCC_STYLE_CHUNK mmioFOURCC('s','t','y','h') -#define DMUS_FOURCC_PART_LIST mmioFOURCC('p','a','r','t') -#define DMUS_FOURCC_PART_CHUNK mmioFOURCC('p','r','t','h') -#define DMUS_FOURCC_NOTE_CHUNK mmioFOURCC('n','o','t','e') -#define DMUS_FOURCC_CURVE_CHUNK mmioFOURCC('c','r','v','e') -#define DMUS_FOURCC_MARKER_CHUNK mmioFOURCC('m','r','k','r') -#define DMUS_FOURCC_RESOLUTION_CHUNK mmioFOURCC('r','s','l','n') -#define DMUS_FOURCC_ANTICIPATION_CHUNK mmioFOURCC('a','n','p','n') -#define DMUS_FOURCC_PATTERN_LIST mmioFOURCC('p','t','t','n') -#define DMUS_FOURCC_PATTERN_CHUNK mmioFOURCC('p','t','n','h') -#define DMUS_FOURCC_RHYTHM_CHUNK mmioFOURCC('r','h','t','m') -#define DMUS_FOURCC_PARTREF_LIST mmioFOURCC('p','r','e','f') -#define DMUS_FOURCC_PARTREF_CHUNK mmioFOURCC('p','r','f','c') -#define DMUS_FOURCC_STYLE_PERS_REF_LIST mmioFOURCC('p','r','r','f') -#define DMUS_FOURCC_MOTIFSETTINGS_CHUNK mmioFOURCC('m','t','f','s') - -/* Flags used by variations: these make up the DWORDs in dwVariationChoices. */ - -/* These flags determine the types of chords supported by a given variation in DirectMusic */ -/* mode. The first seven flags (bits 1-7) are set if the variation supports major chords */ -/* rooted in scale positions, so, e.g., if bits 1, 2, and 4 are set, the variation */ -/* supports major chords rooted in the tonic, second, and fourth scale positions. The */ -/* next seven flags serve the same purpose, but for minor chords, and the following seven */ -/* flags serve the same purpose for chords that are not major or minor (e.g., SUS 4 */ -/* chords). Bits 22, 23, and 24 are set if the variation supports chords rooted in the */ -/* scale, chords rooted sharp of scale tones, and chords rooted flat of scale tones, */ -/* respectively. For example, to support a C# minor chord in the scale of C Major, */ -/* bits 8 (for tonic minor) and 24 (for sharp) need to be set. Bits 25, 26, an 27 handle */ -/* chords that are triads, 6th or 7th chords, and chords with extensions, respectively. */ -/* bits 28 and 29 handle chords that are followed by tonic and dominant chords, */ -/* respectively. */ -#define DMUS_VARIATIONF_MAJOR 0x0000007F /* Seven positions in the scale - major chords. */ -#define DMUS_VARIATIONF_MINOR 0x00003F80 /* Seven positions in the scale - minor chords. */ -#define DMUS_VARIATIONF_OTHER 0x001FC000 /* Seven positions in the scale - other chords. */ -#define DMUS_VARIATIONF_ROOT_SCALE 0x00200000 /* Handles chord roots in the scale. */ -#define DMUS_VARIATIONF_ROOT_FLAT 0x00400000 /* Handles flat chord roots (based on scale notes). */ -#define DMUS_VARIATIONF_ROOT_SHARP 0x00800000 /* Handles sharp chord roots (based on scale notes). */ -#define DMUS_VARIATIONF_TYPE_TRIAD 0x01000000 /* Handles simple chords - triads. */ -#define DMUS_VARIATIONF_TYPE_6AND7 0x02000000 /* Handles simple chords - 6 and 7. */ -#define DMUS_VARIATIONF_TYPE_COMPLEX 0x04000000 /* Handles complex chords. */ -#define DMUS_VARIATIONF_DEST_TO1 0x08000000 /* Handles transitions to 1 chord. */ -#define DMUS_VARIATIONF_DEST_TO5 0x10000000 /* Handles transitions to 5 chord. */ -#define DMUS_VARIATIONF_DEST_OTHER 0x40000000 /* Handles transitions to chords other than 1 . */ - -/* legacy mask for variation modes */ -#define DMUS_VARIATIONF_MODES 0xE0000000 -/* Bits 29 and 31 of the variation flags are the Mode bits. If both are 0, it's IMA. */ -/* If bit 29 is 1, it's Direct Music. */ -#define DMUS_VARIATIONF_MODES_EX (0x20000000 | 0x80000000) -#define DMUS_VARIATIONF_IMA25_MODE 0x00000000 -#define DMUS_VARIATIONF_DMUS_MODE 0x20000000 - -/* Set this if the part uses marker events */ -#define DMUS_PARTF_USE_MARKERS 0x1 -/* Set this if the part is allowed to switch only on chord-aligned markers */ -#define DMUS_PARTF_ALIGN_CHORDS 0x2 - -/* These specify if the marker event signals whether to stop a variation or start a -pattern/variation (or both), and whether new variations must align with a chord */ -#define DMUS_MARKERF_START 0x1 -#define DMUS_MARKERF_STOP 0x2 -#define DMUS_MARKERF_CHORD_ALIGN 0x4 - -/* if this flag is set, variation settings in a playing pattern-based track's state data will -persist in the track after it stops playing */ -#define DMUS_PATTERNF_PERSIST_CONTROL 0x1 - -/* These specify possible values for DMUS_IO_PARTREF.bRandomVariation - all but DMUS_VARIATIONT_SEQUENTIAL and DMUS_VARIATIONT_RANDOM are DirectX8. */ -typedef enum enumDMUS_VARIATIONT_TYPES -{ - DMUS_VARIATIONT_SEQUENTIAL = 0, /* Play sequential starting with variation 1. */ - DMUS_VARIATIONT_RANDOM = 1, /* Play randomly. */ - DMUS_VARIATIONT_RANDOM_START = 2, /* Play sequential starting with a random variation. */ - DMUS_VARIATIONT_NO_REPEAT = 3, /* Play randomly, but don't play the same variation twice. */ - DMUS_VARIATIONT_RANDOM_ROW = 4 /* Play randomly as a row: don't repeat any variation until all have played. */ -} DMUS_VARIATIONT_TYPES; - -/* These specify possible values for DMUS_IO_PATTERN.wEmbellishment (DirectX8) */ -typedef enum enumDMUS_EMBELLISHT_TYPES -{ - DMUS_EMBELLISHT_NORMAL = 0, - DMUS_EMBELLISHT_FILL = 1, - DMUS_EMBELLISHT_BREAK = 2, - DMUS_EMBELLISHT_INTRO = 4, - DMUS_EMBELLISHT_END = 8, - DMUS_EMBELLISHT_MOTIF = 16, - DMUS_EMBELLISHT_ALL = 0xFFFF -} DMUS_EMBELLISHT_TYPES; - -#pragma pack(2) - -typedef struct _DMUS_IO_TIMESIG -{ - /* Time signatures define how many beats per measure, which note receives */ - /* the beat, and the grid resolution. */ - BYTE bBeatsPerMeasure; /* beats per measure (top of time sig) */ - BYTE bBeat; /* what note receives the beat (bottom of time sig.) */ - /* we can assume that 0 means 256th note */ - WORD wGridsPerBeat; /* grids per beat */ -} DMUS_IO_TIMESIG; - -typedef struct _DMUS_IO_STYLE -{ - DMUS_IO_TIMESIG timeSig; /* Styles have a default Time Signature */ - double dblTempo; -} DMUS_IO_STYLE; - -typedef struct _DMUS_IO_VERSION -{ - DWORD dwVersionMS; /* Version # high-order 32 bits */ - DWORD dwVersionLS; /* Version # low-order 32 bits */ -} DMUS_IO_VERSION; - -typedef struct _DMUS_IO_PATTERN -{ - DMUS_IO_TIMESIG timeSig; /* Patterns can override the Style's Time sig. */ - BYTE bGrooveBottom; /* bottom of groove range */ - BYTE bGrooveTop; /* top of groove range */ - WORD wEmbellishment; /* Fill, Break, Intro, End, Normal, Motif */ - WORD wNbrMeasures; /* length in measures */ - BYTE bDestGrooveBottom; /* bottom of groove range for next pattern */ - BYTE bDestGrooveTop; /* top of groove range for next pattern */ - DWORD dwFlags; /* various flags */ -} DMUS_IO_PATTERN; - -typedef struct _DMUS_IO_STYLEPART -{ - DMUS_IO_TIMESIG timeSig; /* can override pattern's */ - DWORD dwVariationChoices[32]; /* MOAW choice bitfield */ - GUID guidPartID; /* identifies the part */ - WORD wNbrMeasures; /* length of the Part */ - BYTE bPlayModeFlags; /* see PLAYMODE flags */ - BYTE bInvertUpper; /* inversion upper limit */ - BYTE bInvertLower; /* inversion lower limit */ - BYTE bPad[3]; /* for DWORD alignment */ - DWORD dwFlags; /* various flags */ -} DMUS_IO_STYLEPART; - -typedef struct _DMUS_IO_PARTREF -{ - GUID guidPartID; /* unique ID for matching up with parts */ - WORD wLogicalPartID; /* corresponds to port/device/midi channel OBSOLETE */ - BYTE bVariationLockID; /* parts with the same ID lock variations. */ - /* high bit is used to identify master Part */ - BYTE bSubChordLevel; /* tells which sub chord level this part wants */ - BYTE bPriority; /* 256 priority levels. Parts with lower priority */ - /* aren't played first when a device runs out of */ - /* notes */ - BYTE bRandomVariation; /* when set, matching variations play in random order */ - /* when clear, matching variations play sequentially */ - WORD wPad; /* not used */ - DWORD dwPChannel; /* replaces wLogicalPartID */ -} DMUS_IO_PARTREF; - -typedef struct _DMUS_IO_STYLENOTE -{ - MUSIC_TIME mtGridStart; /* when this note occurs */ - DWORD dwVariation; /* variation bits */ - MUSIC_TIME mtDuration; /* how long this note lasts */ - short nTimeOffset; /* offset from mtGridStart */ - WORD wMusicValue; /* Position in scale. */ - BYTE bVelocity; /* Note velocity. */ - BYTE bTimeRange; /* Range to randomize start time. */ - BYTE bDurRange; /* Range to randomize duration. */ - BYTE bVelRange; /* Range to randomize velocity. */ - BYTE bInversionID; /* Identifies inversion group to which this note belongs */ - BYTE bPlayModeFlags; /* Can override part */ - /* Following exists only under DirectX8 and on */ - BYTE bNoteFlags; /* values from DMUS_NOTEF_FLAGS */ -} DMUS_IO_STYLENOTE; - -typedef struct _DMUS_IO_STYLECURVE -{ - MUSIC_TIME mtGridStart; /* when this curve occurs */ - DWORD dwVariation; /* variation bits */ - MUSIC_TIME mtDuration; /* how long this curve lasts */ - MUSIC_TIME mtResetDuration;/* how long after the end of the curve to reset the curve */ - short nTimeOffset; /* offset from mtGridStart */ - short nStartValue; /* curve's start value */ - short nEndValue; /* curve's end value */ - short nResetValue; /* the value to which to reset the curve */ - BYTE bEventType; /* type of curve */ - BYTE bCurveShape; /* shape of curve */ - BYTE bCCData; /* CC# */ - BYTE bFlags; /* Bit 1=TRUE means to send nResetValue. Otherwise, don't. - Other bits are reserved. */ - /* Following was added for DirectX8. */ - WORD wParamType; /* RPN or NRPN parameter number. */ - WORD wMergeIndex; /* Allows multiple parameters to be merged (pitchbend, volume, and expression.) */ -} DMUS_IO_STYLECURVE; - -typedef struct _DMUS_IO_STYLEMARKER -{ - MUSIC_TIME mtGridStart; /* when this marker occurs */ - DWORD dwVariation; /* variation bits */ - WORD wMarkerFlags; /* how the marker is used */ -} DMUS_IO_STYLEMARKER; - -typedef struct _DMUS_IO_STYLERESOLUTION -{ - DWORD dwVariation; /* variation bits */ - WORD wMusicValue; /* Position in scale. */ - BYTE bInversionID; /* Identifies inversion group to which this note belongs */ - BYTE bPlayModeFlags; /* Can override part */ -} DMUS_IO_STYLERESOLUTION; - -typedef struct _DMUS_IO_STYLE_ANTICIPATION -{ - MUSIC_TIME mtGridStart; /* when this anticipation occurs */ - DWORD dwVariation; /* variation bits */ - short nTimeOffset; /* offset from mtGridStart */ - BYTE bTimeRange; /* Range to randomize start time. */ -} DMUS_IO_STYLE_ANTICIPATION; - -typedef struct _DMUS_IO_MOTIFSETTINGS -{ - DWORD dwRepeats; /* Number of repeats. By default, 0. */ - MUSIC_TIME mtPlayStart; /* Start of playback. By default, 0. */ - MUSIC_TIME mtLoopStart; /* Start of looping portion. By default, 0. */ - MUSIC_TIME mtLoopEnd; /* End of loop. Must be greater than mtLoopStart. Or, 0, indicating loop full motif. */ - DWORD dwResolution; /* Default resolution. */ -} DMUS_IO_MOTIFSETTINGS; - -#pragma pack() - - -/* -RIFF -( - 'DMST' // Style - // Style header chunk - // Every Style has a GUID - [] // Name, author, copyright info., comments - [] // version chunk - ... // Array of parts in the Style, used by patterns - ... // Array of patterns in the Style - ... // Array of bands in the Style - []...// Optional array of chord map references in the Style -) - - // - styh - ( - - ) - - // - guid - ( - - ) - - // - vers - ( - - ) - - // - LIST - ( - 'part' - // Part header chunk - [] // Name, author, copyright info., comments - [] // Optional chunk containing an array of notes in Part - [] // Optional chunk containing an array of curves in Part - [] // Optional chunk containing an array of markers in Part - [] // Optional chunk containing an array of variation resolutions in Part - [] // Optional chunk containing an array of resolution anticipations in Part - ) - - // - prth - ( - - ) - - // - 'note' - ( - // sizeof DMUS_IO_STYLENOTE:DWORD - ... - ) - - // - 'crve' - ( - // sizeof DMUS_IO_STYLECURVE:DWORD - ... - ) - - // - 'mrkr' - ( - // sizeof DMUS_IO_STYLEMARKER:DWORD - ... - ) - - // - 'rsln' - ( - // sizeof DMUS_IO_STYLERESOLUTION:DWORD - ... - ) - - // - 'anpn' - ( - // sizeof DMUS_IO_STYLE_ANTICIPATION:DWORD - ... - ) - - // - LIST - ( - 'pttn' - // Pattern header chunk - // Chunk containing an array of rhythms for chord matching - [] // Name, author, copyright info., comments - [] // Motif settings chunk - [] // Optional band to be associated with the pattern (for motifs) - ... // Array of part reference id's - ) - - // - ptnh - ( - - ) - - // - 'rhtm' - ( - // DWORD's representing rhythms for chord matching based on number - // of measures in the pattern - ) - - - // pref-list - LIST - ( - 'pref' - // part ref chunk - ) - - // - prfc - ( - - ) - - // - mtfs - ( - - ) - - // - LIST - ( - 'prrf' - ... // Array of Chordmap references - ) -*/ - -/* Pattern chunk, for use in Pattern tracks */ - -#define DMUS_FOURCC_PATTERN_FORM mmioFOURCC('D','M','P','T') - -/* -RIFF -( - 'DMPT' // Pattern - // Style header chunk - // The pattern, in single pattern format (includes DMUS_FOURCC_PART_LIST chunks) -) -*/ - - -/* Chord and command file formats */ - -/* These specify possible values for DMUS_IO_COMMAND.bRepeatMode (DirectX8) */ -typedef enum enumDMUS_PATTERNT_TYPES -{ - DMUS_PATTERNT_RANDOM = 0, /* Play randomly. (DirectX7 behavior) */ - DMUS_PATTERNT_REPEAT = 1, /* Repeat last pattern. */ - DMUS_PATTERNT_SEQUENTIAL = 2, /* Play sequential starting with first matching pattern. */ - DMUS_PATTERNT_RANDOM_START = 3, /* Play sequential starting with a random pattern. */ - DMUS_PATTERNT_NO_REPEAT = 4, /* Play randomly, but don't play the same pattern twice. */ - DMUS_PATTERNT_RANDOM_ROW = 5 /* Play randomly as a row: don't repeat any pattern until all have played. */ -} DMUS_PATTERNT_TYPES; - - -#define DMUS_FOURCC_CHORDTRACK_LIST mmioFOURCC('c','o','r','d') -#define DMUS_FOURCC_CHORDTRACKHEADER_CHUNK mmioFOURCC('c','r','d','h') -#define DMUS_FOURCC_CHORDTRACKBODY_CHUNK mmioFOURCC('c','r','d','b') - -#define DMUS_FOURCC_COMMANDTRACK_CHUNK mmioFOURCC('c','m','n','d') - -typedef struct _DMUS_IO_CHORD -{ - WCHAR wszName[16]; /* Name of the chord */ - MUSIC_TIME mtTime; /* Time of this chord */ - WORD wMeasure; /* Measure this falls on */ - BYTE bBeat; /* Beat this falls on */ - BYTE bFlags; /* Various flags */ -} DMUS_IO_CHORD; - -typedef struct _DMUS_IO_SUBCHORD -{ - DWORD dwChordPattern; /* Notes in the subchord */ - DWORD dwScalePattern; /* Notes in the scale */ - DWORD dwInversionPoints; /* Where inversions can occur */ - DWORD dwLevels; /* Which levels are supported by this subchord */ - BYTE bChordRoot; /* Root of the subchord */ - BYTE bScaleRoot; /* Root of the scale */ -} DMUS_IO_SUBCHORD; - -typedef struct _DMUS_IO_COMMAND -{ - MUSIC_TIME mtTime; /* Time of this command */ - WORD wMeasure; /* Measure this falls on */ - BYTE bBeat; /* Beat this falls on */ - BYTE bCommand; /* Command type (see #defines below) */ - BYTE bGrooveLevel; /* Groove level (0 if command is not a groove) */ - BYTE bGrooveRange; /* Groove range */ - BYTE bRepeatMode; /* Used to control selection of patterns with same groove level */ -} DMUS_IO_COMMAND; - - -/* - - // - LIST - ( - 'cord' - - ... // Chord body chunks - ) - - // - crdh - ( - // Scale: dword (upper 8 bits for root, lower 24 for scale) - ) - - // - crdb - ( - // sizeof DMUS_IO_CHORD:dword - - // # of DMUS_IO_SUBCHORDS:dword - // sizeof DMUS_IO_SUBCHORDS:dword - // a number of - ) - - - // - 'cmnd' - ( - //sizeof DMUS_IO_COMMAND: DWORD - ... - ) - -*/ - -/* File io for DirectMusic Tool and ToolGraph objects -*/ - -/* RIFF ids: */ - -#define DMUS_FOURCC_TOOLGRAPH_FORM mmioFOURCC('D','M','T','G') -#define DMUS_FOURCC_TOOL_LIST mmioFOURCC('t','o','l','l') -#define DMUS_FOURCC_TOOL_FORM mmioFOURCC('D','M','T','L') -#define DMUS_FOURCC_TOOL_CHUNK mmioFOURCC('t','o','l','h') - -/* io structures: */ - -typedef struct _DMUS_IO_TOOL_HEADER -{ - GUID guidClassID; /* Class id of tool. */ - long lIndex; /* Position in graph. */ - DWORD cPChannels; /* Number of items in channels array. */ - FOURCC ckid; /* chunk ID of tool's data chunk if 0 fccType valid. */ - FOURCC fccType; /* list type if NULL ckid valid. */ - DWORD dwPChannels[1]; /* Array of PChannels, size determined by cPChannels. */ -} DMUS_IO_TOOL_HEADER; - -/* -RIFF -( - 'DMTG' // DirectMusic ToolGraph chunk - [] // GUID for ToolGraph - [] // Optional version info - [] // Name, author, copyright info., comments - // List of Tools -) - - // - 'guid' - ( - - ) - - // - vers - ( - - ) - - // - LIST - ( - 'toll' // Array of tools - ... // Each tool is encapsulated in a RIFF chunk - ) - -// Tools are embedded in a graph. Theoretically, they can be saved as individual files too. -RIFF -( - 'DMTL' - - [] // Tool data. Must be a RIFF readable chunk. -) - - // // Tool header chunk - ( - 'tolh' - // Tool header - ) -*/ - -/* The AudioPath file carries everything for describing a specific audio path, - including Tool Graph and Buffer Descriptor. - This can even be used for configuring a complete performance. -*/ - -#define DMUS_FOURCC_AUDIOPATH_FORM mmioFOURCC('D','M','A','P') - -/* -RIFF -( - 'DMAP' // DirectMusic AudioPath chunk - [] // GUID for this Audio Path configuration - [] // Optional version info - [] // Name, author, copyright info., comments - [] // Optional ToolGraph - [] // Optional list of port configurations - []...// Optional array of DirectSound buffer descriptors -) -*/ - -#define DMUS_FOURCC_PORTCONFIGS_LIST mmioFOURCC('p','c','s','l') -#define DMUS_FOURCC_PORTCONFIG_LIST mmioFOURCC('p','c','f','l') -#define DMUS_FOURCC_PORTCONFIG_ITEM mmioFOURCC('p','c','f','h') -#define DMUS_FOURCC_PORTPARAMS_ITEM mmioFOURCC('p','p','r','h') -#define DMUS_FOURCC_DSBUFFER_LIST mmioFOURCC('d','b','f','l') -#define DMUS_FOURCC_DSBUFFATTR_ITEM mmioFOURCC('d','d','a','h') -#define DMUS_FOURCC_PCHANNELS_LIST mmioFOURCC('p','c','h','l') -#define DMUS_FOURCC_PCHANNELS_ITEM mmioFOURCC('p','c','h','h') - -typedef struct _DMUS_IO_PORTCONFIG_HEADER -{ - GUID guidPort; /* GUID of requested port. */ - DWORD dwPChannelBase; /* PChannel that this should start on. */ - DWORD dwPChannelCount; /* How many channels. */ - DWORD dwFlags; /* Various flags. */ -} DMUS_IO_PORTCONFIG_HEADER; - -#define DMUS_PORTCONFIGF_DRUMSON10 1 /* This port configured for drums on channel 10. */ -#define DMUS_PORTCONFIGF_USEDEFAULT 2 /* Use the default port. */ - -/* Each portconfig has one or more pchannel to buffer mappings. Each buffer - is identified by a guid. Each pchannel can map to one or more buffers. - This is defined with one or more DMUS_IO_PCHANNELTOBUFFER_HEADER - structures. Each defines a range of PChannels and the set of buffers - that they connect to. -*/ - -typedef struct _DMUS_IO_PCHANNELTOBUFFER_HEADER -{ - DWORD dwPChannelBase; /* PChannel that this should start on. */ - DWORD dwPChannelCount; /* How many PChannels. */ - DWORD dwBufferCount; /* How many buffers do these connect to. */ - DWORD dwFlags; /* Various flags. Currently reserved for future use. Must be 0. */ -} DMUS_IO_PCHANNELTOBUFFER_HEADER; - -/* Each buffer is represented by an DSBC form. This is wrapped by the - DMUS_IO_BUFFER_ATTRIBUTES_HEADER which identifies how to use the - buffer. In particular, it indicates whether this gets dynamically duplicated - or all references to this should share the same instance. - To resolve references, the unique GUID of the buffer is also stored - in this structure. -*/ - -typedef struct _DMUS_IO_BUFFER_ATTRIBUTES_HEADER -{ - GUID guidBufferID; /* Each buffer config has a unique ID. */ - DWORD dwFlags; /* Various flags. */ -} DMUS_IO_BUFFER_ATTRIBUTES_HEADER; - -/* DMUS_IO_BUFFER_ATTRIBUTES_HEADER.dwFlags: */ -#define DMUS_BUFFERF_SHARED 1 /* Share this with other audio paths, instead of creating unique copies. */ -#define DMUS_BUFFERF_DEFINED 2 /* Use one of the standard predefined buffers (see GUID_Buffer... in dmusici.h.) */ -#define DMUS_BUFFERF_MIXIN 8 /* This is a mixin buffer. */ - -/* - -LIST -( - 'pcsl' // Array of port configurations - ... // One or more port configurations, each in a list chunk -) - -LIST -( - 'pcfl' // List container for one port configuration. - // Portconfig header chunk. - // Port params, to be used to create the port. - []...// Optional array of DirectSound buffer descriptors - [] // Optional list of pchannel to buffer assignments - -) - - // // Port config header chunk - ( - 'pcfh' - // Port config header - ) - - // // Port params header chunk - ( - 'pprh' - // Port params header - ) - -LIST -( - 'pchl' // List container for one or more pchannel to buffer assignments. - ... // One or more pchannel to buffer assignment headers and data. - - // - ( - 'pchh' - // Description of PChannels - ... // Array of GUIDs defining the buffers they all connect to. - ) -) - -LIST -( - 'dbfl' // List container for one buffer and buffer attributes header. - // Buffer attributes header. - [] // Buffer configuration. Not required when header uses a predefined buffer type. - - // - ( - 'ddah' - // Buffer attributes. - ) -) -*/ - -/* File io for DirectMusic Band Track object */ - - -/* RIFF ids: */ -#define DMUS_FOURCC_BANDTRACK_FORM mmioFOURCC('D','M','B','T') -#define DMUS_FOURCC_BANDTRACK_CHUNK mmioFOURCC('b','d','t','h') -#define DMUS_FOURCC_BANDS_LIST mmioFOURCC('l','b','d','l') -#define DMUS_FOURCC_BAND_LIST mmioFOURCC('l','b','n','d') -#define DMUS_FOURCC_BANDITEM_CHUNK mmioFOURCC('b','d','i','h') -#define DMUS_FOURCC_BANDITEM_CHUNK2 mmioFOURCC('b','d','2','h') - -/* io structures */ -typedef struct _DMUS_IO_BAND_TRACK_HEADER -{ - BOOL bAutoDownload; /* Determines if Auto-Download is enabled. */ -} DMUS_IO_BAND_TRACK_HEADER; - -typedef struct _DMUS_IO_BAND_ITEM_HEADER -{ - MUSIC_TIME lBandTime; /* Position in track list. */ -} DMUS_IO_BAND_ITEM_HEADER; - -typedef struct _DMUS_IO_BAND_ITEM_HEADER2 -{ - MUSIC_TIME lBandTimeLogical; /* Position in track list. Time in the music with which band change is associated. */ - MUSIC_TIME lBandTimePhysical; /* Precise time band change will take effect. Should be close to logical time. */ -} DMUS_IO_BAND_ITEM_HEADER2; - -/* -RIFF -( - 'DMBT' // DirectMusic Band Track form-type - [] // Band track header - [] // GUID for band track - [] // Optional version info - [] // Name, author, copyright info., comments - // List of Band items -) - - // - 'bdth' - ( - - ) - - // - 'guid' - ( - - ) - - // - vers - ( - - ) - - // - LIST - ( - 'lbdl' - ... // Array of bands, each encapsulated in a list chunk - ) - - // - LIST - ( - 'lbnd' - or // bdih is a legacy format. bd2h is preferred for new content. - // Band - ) - - // or // band item header - ( - or // Band item header - ) -*/ - - -/* File io for DirectMusic Band object -*/ - -/* RIFF ids: */ - -#define DMUS_FOURCC_BAND_FORM mmioFOURCC('D','M','B','D') -#define DMUS_FOURCC_INSTRUMENTS_LIST mmioFOURCC('l','b','i','l') -#define DMUS_FOURCC_INSTRUMENT_LIST mmioFOURCC('l','b','i','n') -#define DMUS_FOURCC_INSTRUMENT_CHUNK mmioFOURCC('b','i','n','s') - -/* Flags for DMUS_IO_INSTRUMENT - */ -#define DMUS_IO_INST_PATCH (1 << 0) /* dwPatch is valid. */ -#define DMUS_IO_INST_BANKSELECT (1 << 1) /* dwPatch contains a valid Bank Select MSB and LSB part */ -#define DMUS_IO_INST_ASSIGN_PATCH (1 << 3) /* dwAssignPatch is valid */ -#define DMUS_IO_INST_NOTERANGES (1 << 4) /* dwNoteRanges is valid */ -#define DMUS_IO_INST_PAN (1 << 5) /* bPan is valid */ -#define DMUS_IO_INST_VOLUME (1 << 6 ) /* bVolume is valid */ -#define DMUS_IO_INST_TRANSPOSE (1 << 7) /* nTranspose is valid */ -#define DMUS_IO_INST_GM (1 << 8) /* Instrument is from GM collection */ -#define DMUS_IO_INST_GS (1 << 9) /* Instrument is from GS collection */ -#define DMUS_IO_INST_XG (1 << 10) /* Instrument is from XG collection */ -#define DMUS_IO_INST_CHANNEL_PRIORITY (1 << 11) /* dwChannelPriority is valid */ -#define DMUS_IO_INST_USE_DEFAULT_GM_SET (1 << 12) /* Always use the default GM set for this patch, */ - /* don't rely on the synth caps stating GM or GS in hardware. */ -#define DMUS_IO_INST_PITCHBENDRANGE (1 << 13) /* nPitchBendRange is valid */ - -/* io structures */ -typedef struct _DMUS_IO_INSTRUMENT -{ - DWORD dwPatch; /* MSB, LSB and Program change to define instrument */ - DWORD dwAssignPatch; /* MSB, LSB and Program change to assign to instrument when downloading */ - DWORD dwNoteRanges[4]; /* 128 bits; one for each MIDI note instrument needs to able to play */ - DWORD dwPChannel; /* PChannel instrument plays on */ - DWORD dwFlags; /* DMUS_IO_INST_ flags */ - BYTE bPan; /* Pan for instrument */ - BYTE bVolume; /* Volume for instrument */ - short nTranspose; /* Number of semitones to transpose notes */ - DWORD dwChannelPriority; /* Channel priority */ - short nPitchBendRange; /* Number of semitones shifted by pitch bend */ -} DMUS_IO_INSTRUMENT; - -/* -// bands can be embedded in other forms -RIFF -( - 'DMBD' // DirectMusic Band chunk - [] // GUID for band - [] // Optional version info - [] // Name, author, copyright info., comments - // List of Instruments -) - - // - 'guid' - ( - - ) - - // - vers - ( - - ) - - // - LIST - ( - 'lbil' // Array of instruments - ... // Each instrument is encapsulated in a list - ) - - // - LIST - ( - 'lbin' - - [] // Optional reference to DLS Collection file. - ) - - // // Instrument chunk - ( - 'bins' - // Instrument header - ) -*/ - -/* This RIFF id and io struct have been added to allow wave files (and the wave object) to - differentiate between streaming and one-shot waves, and to give a prefetch for streaming - waves */ - -#define DMUS_FOURCC_WAVEHEADER_CHUNK mmioFOURCC('w','a','v','h') - -typedef struct _DMUS_IO_WAVE_HEADER -{ - REFERENCE_TIME rtReadAhead; /* How far ahead in the stream wave data will be read (in REFERENCE_TIME). Ignored for one-shot waves. */ - DWORD dwFlags; /* Various flags, including whether this is a streaming wave and whether it can be invalidated. */ -} DMUS_IO_WAVE_HEADER; - - -/* File io for Wave track */ - -/* RIFF ids: */ - -#define DMUS_FOURCC_WAVETRACK_LIST mmioFOURCC('w','a','v','t') -#define DMUS_FOURCC_WAVETRACK_CHUNK mmioFOURCC('w','a','t','h') -#define DMUS_FOURCC_WAVEPART_LIST mmioFOURCC('w','a','v','p') -#define DMUS_FOURCC_WAVEPART_CHUNK mmioFOURCC('w','a','p','h') -#define DMUS_FOURCC_WAVEITEM_LIST mmioFOURCC('w','a','v','i') -#define DMUS_FOURCC_WAVE_LIST mmioFOURCC('w','a','v','e') -#define DMUS_FOURCC_WAVEITEM_CHUNK mmioFOURCC('w','a','i','h') - -/* This flag is included in DMUS_IO_WAVE_TRACK_HEADER.dwFlags. If set, the track will get its - variations from a pattern track, via GetParam(GUID_Variations). */ -#define DMUS_WAVETRACKF_SYNC_VAR 0x1 -/* This is also included in DMUS_IO_WAVE_TRACK_HEADER.dwFlags. If set, variation control - information will persist from one playback instance to the next.*/ -#define DMUS_WAVETRACKF_PERSIST_CONTROL 0x2 - -typedef struct _DMUS_IO_WAVE_TRACK_HEADER -{ - long lVolume; /* Gain, in 1/100th of dB, to be applied to all waves. Note: All gain values should be negative. */ - DWORD dwFlags; /* Flags, including whether this track syncs to a pattern track for its variations. */ -} DMUS_IO_WAVE_TRACK_HEADER; - -typedef struct _DMUS_IO_WAVE_PART_HEADER -{ - long lVolume; /* Gain, in 1/100th of dB, to be applied to all waves in wave part. Note: All gain values should be negative. */ - DWORD dwVariations; /* Variation mask for which of 32 variations */ - DWORD dwPChannel; /* PChannel */ - DWORD dwLockToPart; /* Part ID to lock to. */ - DWORD dwFlags; /* Flags, including stuff for managing how variations are chosen (in low-order nibble) */ - DWORD dwIndex; /* Index for distinguishing multiple parts on the same PChannel*/ -} DMUS_IO_WAVE_PART_HEADER; - -typedef struct _DMUS_IO_WAVE_ITEM_HEADER -{ - long lVolume; /* Gain, in 1/100th of dB. Note: All gain values should be negative. */ - long lPitch; /* Pitch offset in 1/100th of a semitone. */ - DWORD dwVariations; /* Variation flags for which of 32 variations this wave belongs to. */ - REFERENCE_TIME rtTime; /* Start time, in REFERENCE_TIME, if clock time track, or MUSIC_TIME for music time track. */ - REFERENCE_TIME rtStartOffset; /* Distance into wave to start playback, in reference time units. */ - REFERENCE_TIME rtReserved; /* Reserved field. */ - REFERENCE_TIME rtDuration; /* Duration, in REFERENCE_TIME or MUSIC_TIME, depending on track timing format. */ - MUSIC_TIME mtLogicalTime; /* If in music track format, this indicates the musical boundary where this belongs. Otherwise, ignored. */ - DWORD dwLoopStart; /* Start point for a looping wave. */ - DWORD dwLoopEnd; /* End point for a looping wave. */ - DWORD dwFlags; /* Various flags, including whether this is a streaming wave and whether it can be invalidated. */ - WORD wVolumeRange; /* Random range for volume. */ - WORD wPitchRange; /* Random range for pitch. */ -} DMUS_IO_WAVE_ITEM_HEADER; - -/* -LIST -{ - 'wavt' // Wave track chunk - // Wave track header - ... // Array of Wave Parts -} - // - 'wath' - { - - } - - // - LIST - { - 'wavp' - // Wave Part Header - // List of wave items - } - - // - 'waph' - { - - } - - // - LIST - { - 'wavi' - ... // Array of waves; each wave is encapsulated in a list - } - - // - LIST - { - 'wave' - // Wave item header - // Reference to wave object - } - - // - 'waih' - { - - } - -*/ - -/* File io for DirectMusic Container file. This embeds a set of related files. And, - in turn, it can be embedded within a segment or script file. -*/ - -#define DMUS_FOURCC_CONTAINER_FORM mmioFOURCC('D','M','C','N') -#define DMUS_FOURCC_CONTAINER_CHUNK mmioFOURCC('c','o','n','h') -#define DMUS_FOURCC_CONTAINED_ALIAS_CHUNK mmioFOURCC('c','o','b','a') -#define DMUS_FOURCC_CONTAINED_OBJECT_CHUNK mmioFOURCC('c','o','b','h') -#define DMUS_FOURCC_CONTAINED_OBJECTS_LIST mmioFOURCC('c','o','s','l') -#define DMUS_FOURCC_CONTAINED_OBJECT_LIST mmioFOURCC('c','o','b','l') - -typedef struct _DMUS_IO_CONTAINER_HEADER -{ - DWORD dwFlags; /* Flags. */ -} DMUS_IO_CONTAINER_HEADER; - -#define DMUS_CONTAINER_NOLOADS (1 << 1) /* Contained items are not loaded when the container is loaded. - Entries will be created in the loader (via SetObject) but - the actual objects will not be created until they are - specifically loaded at a later time. */ - -typedef struct _DMUS_IO_CONTAINED_OBJECT_HEADER -{ - GUID guidClassID; /* Class id of object. */ - DWORD dwFlags; /* Flags, for example DMUS_CONTAINED_OBJF_KEEP. */ - FOURCC ckid; /* chunk ID of track's data chunk if 0 fccType valid. */ - FOURCC fccType; /* list type if NULL ckid valid */ - /* Note that LIST:DMRF may be used for ckid and fccType in order to reference an - object instead of embedding it within the container. */ -} DMUS_IO_CONTAINED_OBJECT_HEADER; - -#define DMUS_CONTAINED_OBJF_KEEP 1 /* Keep the object cached in the loader after the container is released. */ - -/* -RIFF -( - 'DMCN' // DirectMusic Container chunk - // Container header chunk - [] // GUID for container - [] // Optional version info - [] // Name, author, copyright info., comments - // List of objects. -) - - // - 'conh' - ( - - ) - - // - 'guid' - ( - - ) - - // - vers - ( - - ) - - LIST - ( - 'cosl' // Array of embedded objects. - ... // Each object is encapsulated in a LIST chunk - ) - - // // Encapsulates one object - LIST - ( - 'cobl' - [] // Alias. An alternative name by which this object is known - // within the container. - // Required header, includes CLASS ID for object. - [] or // Object data of the type specified in . - // If DMRF, it is a reference of where to find the object. - // Otherwise, it could be any RIFF readable chunk in the - // exact same format as a file. The object will load - // itself from this data. - ) - - // - 'coba' - ( - // Alias, stored as NULL terminated string of WCHARs - ) - - // - 'cobh' - ( - - ) -*/ - -/* File io for DirectMusic Segment object */ - -/* RIFF ids: */ - -#define DMUS_FOURCC_SEGMENT_FORM mmioFOURCC('D','M','S','G') -#define DMUS_FOURCC_SEGMENT_CHUNK mmioFOURCC('s','e','g','h') -#define DMUS_FOURCC_TRACK_LIST mmioFOURCC('t','r','k','l') -#define DMUS_FOURCC_TRACK_FORM mmioFOURCC('D','M','T','K') -#define DMUS_FOURCC_TRACK_CHUNK mmioFOURCC('t','r','k','h') -#define DMUS_FOURCC_TRACK_EXTRAS_CHUNK mmioFOURCC('t','r','k','x') - -/* io structures:*/ - -typedef struct _DMUS_IO_SEGMENT_HEADER -{ - DWORD dwRepeats; /* Number of repeats. By default, 0. */ - MUSIC_TIME mtLength; /* Length, in music time. */ - MUSIC_TIME mtPlayStart; /* Start of playback. By default, 0. */ - MUSIC_TIME mtLoopStart; /* Start of looping portion. By default, 0. */ - MUSIC_TIME mtLoopEnd; /* End of loop. Must be greater than dwPlayStart. Or, 0, indicating loop full segment. */ - DWORD dwResolution; /* Default resolution. */ - /* Following added for DirectX8: */ - REFERENCE_TIME rtLength; /* Length, in reference time (overrides music time length.) */ - DWORD dwFlags; - DWORD dwReserved; /* Reserved. */ - /* Added for DirectX9: */ - REFERENCE_TIME rtLoopStart; /* Clock time loop start. */ - REFERENCE_TIME rtLoopEnd; /* Clock time loop end. */ - REFERENCE_TIME rtPlayStart; /* Start of playback in clock time. */ -} DMUS_IO_SEGMENT_HEADER; - -#define DMUS_SEGIOF_REFLENGTH 1 /* Use the time in rtLength for the segment length. */ -#define DMUS_SEGIOF_CLOCKTIME 2 /* This is a clock time segment. */ - -typedef struct _DMUS_IO_TRACK_HEADER -{ - GUID guidClassID; /* Class id of track. */ - DWORD dwPosition; /* Position in track list. */ - DWORD dwGroup; /* Group bits for track. */ - FOURCC ckid; /* chunk ID of track's data chunk. */ - FOURCC fccType; /* list type if ckid is RIFF or LIST */ -} DMUS_IO_TRACK_HEADER; - -/* Additional parameters for the track header chunk, introduced in DirectX8 and - on, are stored in a separate chunk. */ - -typedef struct _DMUS_IO_TRACK_EXTRAS_HEADER -{ - DWORD dwFlags; /* DirectX8 Added flags for control tracks. */ - DWORD dwPriority; /* Priority for composition. */ -} DMUS_IO_TRACK_EXTRAS_HEADER; - -/* -RIFF -( - 'DMSG' // DirectMusic Segment chunk - // Segment header chunk - [] // GUID for segment - [] // Optional version info - [] // Name, author, copyright info., comments - [] // Optional container of objects embedded in file. Must precede tracklist. - // List of Tracks - [] // Optional ToolGraph - [] // Optional Audio Path -) - - // - 'segh' - ( - - ) - - // - 'guid' - ( - - ) - - // - vers - ( - - ) - - // - LIST - ( - 'trkl' // Array of tracks - ... // Each track is encapsulated in a RIFF chunk - ) - - // // Tracks can be embedded in a segment or stored as separate files. - RIFF - ( - 'DMTK' - - [] // Optional track flags. - [] // Optional GUID for track object instance (not to be confused with Class id in track header) - [] // Optional version info - [] // Optional name, author, copyright info., comments - [] // Track data. Must be a RIFF readable chunk. - ) - - // // Track header chunk - ( - 'trkh' - // Track header - ) - - // // Track flags chunk - ( - 'trkx' - // DirectX8 Track flags header - ) -*/ - -/* File io for DirectMusic reference chunk. - This is used to embed a reference to an object. -*/ - -/* RIFF ids: */ - -#define DMUS_FOURCC_REF_LIST mmioFOURCC('D','M','R','F') -#define DMUS_FOURCC_REF_CHUNK mmioFOURCC('r','e','f','h') -#define DMUS_FOURCC_DATE_CHUNK mmioFOURCC('d','a','t','e') -#define DMUS_FOURCC_NAME_CHUNK mmioFOURCC('n','a','m','e') -#define DMUS_FOURCC_FILE_CHUNK mmioFOURCC('f','i','l','e') - -typedef struct _DMUS_IO_REFERENCE -{ - GUID guidClassID; /* Class id is always required. */ - DWORD dwValidData; /* Flags. */ -} DMUS_IO_REFERENCE; - -/* -LIST -( - 'DMRF' // DirectMusic Reference chunk - // Reference header chunk - [] // Optional object GUID. - [] // Optional file date. - [] // Optional name. - [] // Optional file name. - [] // Optional category name. - [] // Optional version info. -) - - // - 'refh' - ( - - ) - - // - 'guid' - ( - - ) - - // - date - ( - - ) - - // - name - ( - // Name, stored as NULL terminated string of WCHARs - ) - - // - file - ( - // File name, stored as NULL terminated string of WCHARs - ) - - // - catg - ( - // Category name, stored as NULL terminated string of WCHARs - ) - - // - vers - ( - - ) -*/ - -/* Chord Maps */ - -/* runtime chunks */ -#define DMUS_FOURCC_CHORDMAP_FORM mmioFOURCC('D','M','P','R') -#define DMUS_FOURCC_IOCHORDMAP_CHUNK mmioFOURCC('p','e','r','h') -#define DMUS_FOURCC_SUBCHORD_CHUNK mmioFOURCC('c','h','d','t') -#define DMUS_FOURCC_CHORDENTRY_CHUNK mmioFOURCC('c','h','e','h') -#define DMUS_FOURCC_SUBCHORDID_CHUNK mmioFOURCC('s','b','c','n') -#define DMUS_FOURCC_IONEXTCHORD_CHUNK mmioFOURCC('n','c','r','d') -#define DMUS_FOURCC_NEXTCHORDSEQ_CHUNK mmioFOURCC('n','c','s','q') -#define DMUS_FOURCC_IOSIGNPOST_CHUNK mmioFOURCC('s','p','s','h') -#define DMUS_FOURCC_CHORDNAME_CHUNK mmioFOURCC('I','N','A','M') - -/* runtime list chunks */ -#define DMUS_FOURCC_CHORDENTRY_LIST mmioFOURCC('c','h','o','e') -#define DMUS_FOURCC_CHORDMAP_LIST mmioFOURCC('c','m','a','p') -#define DMUS_FOURCC_CHORD_LIST mmioFOURCC('c','h','r','d') -#define DMUS_FOURCC_CHORDPALETTE_LIST mmioFOURCC('c','h','p','l') -#define DMUS_FOURCC_CADENCE_LIST mmioFOURCC('c','a','d','e') -#define DMUS_FOURCC_SIGNPOSTITEM_LIST mmioFOURCC('s','p','s','t') - -#define DMUS_FOURCC_SIGNPOST_LIST mmioFOURCC('s','p','s','q') - -/* values for dwChord field of DMUS_IO_PERS_SIGNPOST */ -/* DMUS_SIGNPOSTF_ flags are also used in templates (DMUS_IO_SIGNPOST) */ -#define DMUS_SIGNPOSTF_A 1 -#define DMUS_SIGNPOSTF_B 2 -#define DMUS_SIGNPOSTF_C 4 -#define DMUS_SIGNPOSTF_D 8 -#define DMUS_SIGNPOSTF_E 0x10 -#define DMUS_SIGNPOSTF_F 0x20 -#define DMUS_SIGNPOSTF_LETTER (DMUS_SIGNPOSTF_A | DMUS_SIGNPOSTF_B | DMUS_SIGNPOSTF_C | DMUS_SIGNPOSTF_D | DMUS_SIGNPOSTF_E | DMUS_SIGNPOSTF_F) -#define DMUS_SIGNPOSTF_1 0x100 -#define DMUS_SIGNPOSTF_2 0x200 -#define DMUS_SIGNPOSTF_3 0x400 -#define DMUS_SIGNPOSTF_4 0x800 -#define DMUS_SIGNPOSTF_5 0x1000 -#define DMUS_SIGNPOSTF_6 0x2000 -#define DMUS_SIGNPOSTF_7 0x4000 -#define DMUS_SIGNPOSTF_ROOT (DMUS_SIGNPOSTF_1 | DMUS_SIGNPOSTF_2 | DMUS_SIGNPOSTF_3 | DMUS_SIGNPOSTF_4 | DMUS_SIGNPOSTF_5 | DMUS_SIGNPOSTF_6 | DMUS_SIGNPOSTF_7) -#define DMUS_SIGNPOSTF_CADENCE 0x8000 - -/* values for dwFlags field of DMUS_IO_CHORDMAP */ -#define DMUS_CHORDMAPF_VERSION8 1 /* Chordmap is version 8 or above. */ - -/* values for dwChord field of DMUS_IO_PERS_SIGNPOST */ -#define DMUS_SPOSTCADENCEF_1 2 /* Use the first cadence chord. */ -#define DMUS_SPOSTCADENCEF_2 4 /* Use the second cadence chord. */ - -/* run time data structs */ -typedef struct _DMUS_IO_CHORDMAP -{ - WCHAR wszLoadName[20]; - DWORD dwScalePattern; - DWORD dwFlags; /* Various flags. Only lower 16 bits are significant. */ -} DMUS_IO_CHORDMAP; - -typedef struct _DMUS_IO_CHORDMAP_SUBCHORD -{ - DWORD dwChordPattern; - DWORD dwScalePattern; - DWORD dwInvertPattern; - BYTE bChordRoot; - BYTE bScaleRoot; - WORD wCFlags; - DWORD dwLevels; /* parts or which subchord levels this chord supports */ -} DMUS_IO_CHORDMAP_SUBCHORD; - -/* Legacy name... */ -typedef DMUS_IO_CHORDMAP_SUBCHORD DMUS_IO_PERS_SUBCHORD; - -typedef struct _DMUS_IO_CHORDENTRY -{ - DWORD dwFlags; - WORD wConnectionID; /* replaces runtime "pointer to this" */ -} DMUS_IO_CHORDENTRY; - -typedef struct _DMUS_IO_NEXTCHORD -{ - DWORD dwFlags; - WORD nWeight; - WORD wMinBeats; - WORD wMaxBeats; - WORD wConnectionID; /* points to an ioChordEntry */ -} DMUS_IO_NEXTCHORD; - -typedef struct _DMUS_IO_CHORDMAP_SIGNPOST -{ - DWORD dwChords; /* 1bit per group */ - DWORD dwFlags; -} DMUS_IO_CHORDMAP_SIGNPOST; - -/* Legacy name... */ -typedef DMUS_IO_CHORDMAP_SIGNPOST DMUS_IO_PERS_SIGNPOST; - -/* -RIFF -( - 'DMPR' - // Chord map header chunk - [] // guid chunk - [] // version chunk (two DWORDS) - [] // Unfo chunk - // subchord database - // chord palette - // chord map - // signpost list - ) - - ::= LIST('cmap' ) - - ::= LIST('choe' - // chord entry data - // chord definition - // connecting(next) chords - ) - - ::= LIST('chrd' - // name of chord in wide char format - // list of subchords composing chord - ) - - ::= LIST('chpl' - ... // chord definition - ) - - ::== LIST('spsq' ... ) - - ::= LIST('spst' - - - [] - ) - - ::= LIST('cade' ...) - - ::= perh() - - ::= chdt( - ... ) - - ::= cheh() - - ::= sbcn( ...) - - ::= ncsq( - ...) - - ::= spsh() - -*/ - -/* File io for DirectMusic Script object */ - -/* RIFF ids: */ - -#define DMUS_FOURCC_SCRIPT_FORM mmioFOURCC('D','M','S','C') -#define DMUS_FOURCC_SCRIPT_CHUNK mmioFOURCC('s','c','h','d') -#define DMUS_FOURCC_SCRIPTVERSION_CHUNK mmioFOURCC('s','c','v','e') -#define DMUS_FOURCC_SCRIPTLANGUAGE_CHUNK mmioFOURCC('s','c','l','a') -#define DMUS_FOURCC_SCRIPTSOURCE_CHUNK mmioFOURCC('s','c','s','r') - -/* io structures:*/ - -typedef struct _DMUS_IO_SCRIPT_HEADER -{ - DWORD dwFlags; /* DMUS_SCRIPTIOF_ flags */ -} DMUS_IO_SCRIPT_HEADER; - -#define DMUS_SCRIPTIOF_LOAD_ALL_CONTENT (1 << 0) - /* If set, when the script loads it will also load all the content in its container. */ -#define DMUS_SCRIPTIOF_DOWNLOAD_ALL_SEGMENTS (1 << 1) - /* If set and LOAD_ALL_CONTENT is also set, when the script initializes it will also download all the segments in its container. - If set and LOAD_ALL_CONTENT is not set, when the script calls segment.Load on a segment then the segment will also be downloaded. - If not set, the script must manually download and unload by calling segment.DownloadSoundData and segment.UnloadSoundData. */ - -/* -RIFF -( - 'DMSC' // DirectMusic Script chunk - // Script header chunk - [] // GUID for script - [] // Optional version info - [] // Name, author, copyright info., comments - // Version of DirectMusic this script was authored to run against - // Container of content referenced by the script. - // ActiveX scripting language in which the script is written - or // The script's source code. - // If scsr-ck, the source is embedding in the chunk. - // If DMRF, it is a reference of where to find a text file with the source. - // Class id (guidClassID in DMUS_IO_REFERENCE) must be GUID_NULL because - // this text file is not a DirectMusic object in its own right. -) - - // - 'schd' - ( - - ) - - // - 'guid' - ( - - ) - - // - vers - ( - - ) - - // - scve - ( - - ) - - 'scla' - ( - // Language name, stored as NULL terminated string of WCHARs - ) - - 'scsr' - ( - // Source code, stored as NULL terminated string of WCHARs - ) -*/ - -/* Signpost tracks */ - -#define DMUS_FOURCC_SIGNPOST_TRACK_CHUNK mmioFOURCC( 's', 'g', 'n', 'p' ) - - -typedef struct _DMUS_IO_SIGNPOST -{ - MUSIC_TIME mtTime; - DWORD dwChords; - WORD wMeasure; -} DMUS_IO_SIGNPOST; - -/* - - // - 'sgnp' - ( - //sizeof DMUS_IO_SIGNPOST: DWORD - ... - ) - -*/ - -#define DMUS_FOURCC_MUTE_CHUNK mmioFOURCC('m','u','t','e') - -typedef struct _DMUS_IO_MUTE -{ - MUSIC_TIME mtTime; - DWORD dwPChannel; - DWORD dwPChannelMap; -} DMUS_IO_MUTE; - -/* - - // - 'mute' - ( - //sizeof DMUS_IO_MUTE:DWORD - ... - ) - - -*/ - -/* Used for both style and chord map tracks */ - -#define DMUS_FOURCC_TIME_STAMP_CHUNK mmioFOURCC('s', 't', 'm', 'p') - -/* Style tracks */ - -#define DMUS_FOURCC_STYLE_TRACK_LIST mmioFOURCC('s', 't', 't', 'r') -#define DMUS_FOURCC_STYLE_REF_LIST mmioFOURCC('s', 't', 'r', 'f') - -/* - - // - LIST('sttr' - ( - ... // Array of Style references - ) - - // - LIST('strf' - ( - - - ) - - // - 'stmp' - ( - // time:DWORD - ) - -*/ - -/* Chord map tracks */ - -#define DMUS_FOURCC_PERS_TRACK_LIST mmioFOURCC('p', 'f', 't', 'r') -#define DMUS_FOURCC_PERS_REF_LIST mmioFOURCC('p', 'f', 'r', 'f') - -/* - - // - LIST('pftr' - ( - ... // Array of Chord map references - ) - - // - LIST('pfrf' - ( - - - ) - - // - 'stmp' - ( - // time:DWORD - ) - -*/ - -#define DMUS_FOURCC_TEMPO_TRACK mmioFOURCC('t','e','t','r') - -/* - // tempo array - 'tetr' - ( - // sizeof DMUS_IO_TEMPO_ITEM: DWORD - ... - ) - */ - -#define DMUS_FOURCC_SEQ_TRACK mmioFOURCC('s','e','q','t') -#define DMUS_FOURCC_SEQ_LIST mmioFOURCC('e','v','t','l') -#define DMUS_FOURCC_CURVE_LIST mmioFOURCC('c','u','r','l') - -/* - // sequence track - 'seqt' - ( - // sequence array - 'evtl' - ( - // sizeof DMUS_IO_SEQ_ITEM: DWORD - ... - ) - // curve array - 'curl' - ( - // sizeof DMUS_IO_CURVE_ITEM: DWORD - ... - ) - ) -*/ - -#define DMUS_FOURCC_SYSEX_TRACK mmioFOURCC('s','y','e','x') - -/* - // sysex track - 'syex' - ( - { - - ... // Array of bytes, length defined in the DMUS_IO_SYSEXITEM structure - }... - ) -*/ - -#define DMUS_FOURCC_TIMESIGNATURE_TRACK mmioFOURCC('t','i','m','s') - -typedef struct _DMUS_IO_TIMESIGNATURE_ITEM -{ - MUSIC_TIME lTime; - BYTE bBeatsPerMeasure; /* beats per measure (top of time sig) */ - BYTE bBeat; /* what note receives the beat (bottom of time sig.) */ - /* we can assume that 0 means 256th note */ - WORD wGridsPerBeat; /* grids per beat */ -} DMUS_IO_TIMESIGNATURE_ITEM; - -/* DirectX6 time signature track - - 'tims' - ( - // size of DMUS_IO_TIMESIGNATURE_ITEM : DWORD - ... - ) -*/ - -/* DirectX8 Time signature track. The track has been updated from DirectX7 to support a list of - RIFF chunks. This will allow the time signature track to expand in the future. -*/ - -#define DMUS_FOURCC_TIMESIGTRACK_LIST mmioFOURCC('T','I','M','S') -#define DMUS_FOURCC_TIMESIG_CHUNK DMUS_FOURCC_TIMESIGNATURE_TRACK - -/* -LIST -( - 'TIMS' // Time Signature Track list-type - // Chunk containing an array of time signatures -) - - 'tims' - ( - // size of DMUS_IO_TIMESIGNATURE_ITEM : DWORD - ... - ) - -*/ - -/* DirectX8 Marker track. This is used to store valid start points and other - flow control parameters that may come later. For example, if we want - to implement more sophisticated looping and branching constructs, they - would live in this track. -*/ - -#define DMUS_FOURCC_MARKERTRACK_LIST mmioFOURCC('M','A','R','K') -#define DMUS_FOURCC_VALIDSTART_CHUNK mmioFOURCC('v','a','l','s') -#define DMUS_FOURCC_PLAYMARKER_CHUNK mmioFOURCC('p','l','a','y') - -/* io structures */ -typedef struct _DMUS_IO_VALID_START -{ - MUSIC_TIME mtTime; /* Time of a legal start. */ -} DMUS_IO_VALID_START; - -typedef struct _DMUS_IO_PLAY_MARKER -{ - MUSIC_TIME mtTime; /* Time of a next legal play point marker. */ -} DMUS_IO_PLAY_MARKER; - -/* -LIST -( - 'MARK' // Marker Track list-type - [] // Chunk containing an array of start points - [] // Chunk containing an array of play start markers -) - - 'vals' - ( - // size of DMUS_IO_VALID_START : DWORD - ... - ) - - 'play' - ( - // size of DMUS_IO_PLAY_MARKER : DWORD - ... - ) - -*/ - -/* segment trigger tracks */ - -/* RIFF ids: */ -#define DMUS_FOURCC_SEGTRACK_LIST mmioFOURCC('s','e','g','t') -#define DMUS_FOURCC_SEGTRACK_CHUNK mmioFOURCC('s','g','t','h') -#define DMUS_FOURCC_SEGMENTS_LIST mmioFOURCC('l','s','g','l') -#define DMUS_FOURCC_SEGMENT_LIST mmioFOURCC('l','s','e','g') -#define DMUS_FOURCC_SEGMENTITEM_CHUNK mmioFOURCC('s','g','i','h') -#define DMUS_FOURCC_SEGMENTITEMNAME_CHUNK mmioFOURCC('s','n','a','m') - -/* io structures */ -typedef struct _DMUS_IO_SEGMENT_TRACK_HEADER -{ - DWORD dwFlags; /* Reserved leave as 0. */ -} DMUS_IO_SEGMENT_TRACK_HEADER; - -typedef struct _DMUS_IO_SEGMENT_ITEM_HEADER -{ - MUSIC_TIME lTimeLogical; /* Position in track list. Time in the music with which the event is associated. */ - MUSIC_TIME lTimePhysical; /* Precise time event will be triggered. Should be close to logical time. */ - DWORD dwPlayFlags; /* Flags for PlaySegment(). */ - DWORD dwFlags; /* Flags. */ -} DMUS_IO_SEGMENT_ITEM_HEADER; - -/* values for dwflags field of DMUS_IO_SEGMENT_ITEM_HEADER */ -#define DMUS_SEGMENTTRACKF_MOTIF 1 /* interpret DMRF as link to style, and use snam as the name of a motif within the style */ - -/* -LIST -( - 'segt' // DirectMusic Segment Trigger Track form-type - [] // Segment track header - // List of Segment Lists -) - - // - 'sgth' - ( - - ) - - // - LIST - ( - 'lsgl' // Array of segments - ... // Each segment is encapsulated in a list (that way it can still be riff parsed.) - ) - - // - LIST - ( - 'lseg' - - // Link to a segment or style file. - [] // Name field. Used with DMUS_SEGMENTTRACKF_MOTIF flag. - ) - - // // segment item header - ( - // Segment item header - ) - - // - ( - // Name, stored as NULL terminated string of WCHARs - ) -*/ - -/* Script track. */ - -/* RIFF ids: */ -#define DMUS_FOURCC_SCRIPTTRACK_LIST mmioFOURCC('s','c','r','t') -#define DMUS_FOURCC_SCRIPTTRACKEVENTS_LIST mmioFOURCC('s','c','r','l') -#define DMUS_FOURCC_SCRIPTTRACKEVENT_LIST mmioFOURCC('s','c','r','e') -#define DMUS_FOURCC_SCRIPTTRACKEVENTHEADER_CHUNK mmioFOURCC('s','c','r','h') -#define DMUS_FOURCC_SCRIPTTRACKEVENTNAME_CHUNK mmioFOURCC('s','c','r','n') - -/* Flags for DMUS_IO_SCRIPTTRACK_TIMING - */ -#define DMUS_IO_SCRIPTTRACKF_PREPARE (1 << 0) /* Fire event in advance of time stamp, at Prepare time. This is the default because it leaves the script time to change the music happening at the target time. */ -#define DMUS_IO_SCRIPTTRACKF_QUEUE (1 << 1) /* Fire event just before time stamp, at Queue time. */ -#define DMUS_IO_SCRIPTTRACKF_ATTIME (1 << 2) /* Fire event right at the time stamp. */ - -typedef struct _DMUS_IO_SCRIPTTRACK_EVENTHEADER -{ - DWORD dwFlags; /* various bits (see DMUS_IO_SCRIPTTRACKF_*) */ - MUSIC_TIME lTimeLogical; /* Position in track list. Time in the music with which the event is associated. */ - MUSIC_TIME lTimePhysical; /* Precise time event will be triggered. Should be close to logical time. */ -} DMUS_IO_SCRIPTTRACK_EVENTHEADER; - -/* - // Script Track - - // - LIST - ( - // List of script events - ) - - // - LIST - ( - ... // Array of event descriptions - ) - - // - LIST - ( - // Event header chunk - - // Routine name - ) - - 'scrh' - ( - - ) - - 'scrn' - ( - // Name, stored as NULL terminated string of WCHARs - ) -*/ - -/* Lyrics/Notification track. */ - -/* RIFF ids: */ -#define DMUS_FOURCC_LYRICSTRACK_LIST mmioFOURCC('l','y','r','t') -#define DMUS_FOURCC_LYRICSTRACKEVENTS_LIST mmioFOURCC('l','y','r','l') -#define DMUS_FOURCC_LYRICSTRACKEVENT_LIST mmioFOURCC('l','y','r','e') -#define DMUS_FOURCC_LYRICSTRACKEVENTHEADER_CHUNK mmioFOURCC('l','y','r','h') -#define DMUS_FOURCC_LYRICSTRACKEVENTTEXT_CHUNK mmioFOURCC('l','y','r','n') - -typedef struct _DMUS_IO_LYRICSTRACK_EVENTHEADER -{ - DWORD dwFlags; /* Reserved leave as 0. */ - DWORD dwTimingFlags; /* Combination DMUS_PMSGF_TOOL_* flags. Determines the precise timing of when the notification happens. Invalid with the flag DMUS_PMSGF_REFTIME, DMUS_PMSGF_MUSICTIME, DMUS_PMSGF_TOOL_FLUSH, or DMUS_PMSGF_LOCKTOREFTIME. */ - MUSIC_TIME lTimeLogical; /* Position in track list. Time in the music with which the event is associated. */ - MUSIC_TIME lTimePhysical; /* Precise time event will be triggered. Should be close to logical time. */ -} DMUS_IO_LYRICSTRACK_EVENTHEADER; - -/* - // Lyrics/Notification Track - - // - LIST - ( - // List of notification events - ) - - // - LIST - ( - ... // Array of event descriptions - ) - - // - LIST - ( - // Event header chunk - // Notification text - ) - - 'lyrh' - ( - - ) - - 'lyrn' - ( - // Name, stored as NULL terminated string of WCHARs - ) -*/ - -/* Parameter control track */ - -/* RIFF ids: */ -#define DMUS_FOURCC_PARAMCONTROLTRACK_TRACK_LIST mmioFOURCC('p','r','m','t') -#define DMUS_FOURCC_PARAMCONTROLTRACK_OBJECT_LIST mmioFOURCC('p','r','o','l') -#define DMUS_FOURCC_PARAMCONTROLTRACK_OBJECT_CHUNK mmioFOURCC('p','r','o','h') -#define DMUS_FOURCC_PARAMCONTROLTRACK_PARAM_LIST mmioFOURCC('p','r','p','l') -#define DMUS_FOURCC_PARAMCONTROLTRACK_PARAM_CHUNK mmioFOURCC('p','r','p','h') -#define DMUS_FOURCC_PARAMCONTROLTRACK_CURVES_CHUNK mmioFOURCC('p','r','c','c') - -typedef struct _DMUS_IO_PARAMCONTROLTRACK_OBJECTHEADER -{ - DWORD dwFlags; /* Reserved. Must be zero. */ - GUID guidTimeFormat; /* Time format to set the object to. Must be GUID_TIME_REFERNCE or GUID_TIME_MUSIC from medparam.h. */ - /* Path for finding the object. These fields correspond to the first five parameters of IDirectMusicSegmentState::GetObjectInPath. */ - DWORD dwPChannel; - DWORD dwStage; - DWORD dwBuffer; - GUID guidObject; - DWORD dwIndex; -} DMUS_IO_PARAMCONTROLTRACK_OBJECTHEADER; - -typedef struct _DMUS_IO_PARAMCONTROLTRACK_PARAMHEADER -{ - DWORD dwFlags; /* Reserved. Must be zero. */ - DWORD dwIndex; /* Index number of the parameter on the object */ -} DMUS_IO_PARAMCONTROLTRACK_PARAMHEADER; - -typedef struct _DMUS_IO_PARAMCONTROLTRACK_CURVEINFO -{ - MUSIC_TIME mtStartTime; - MUSIC_TIME mtEndTime; - float fltStartValue; - float fltEndValue; - DWORD dwCurveType; /* One of the items from the MP_CURVE_TYPE enum in medparam.h */ - DWORD dwFlags; /* A combination of the MPF_ENVLP_* constants in medparam.h */ -} DMUS_IO_PARAMCONTROLTRACK_CURVEINFO; - -/* - // - LIST - ( - ... // one for each object - ) - - // - LIST - ( - // object header chunk - ... // one for each parameter - ) - - // - proh - ( - - ) - - // - LIST - ( - // parameter header chunk - // chunk containing an array of curves - ) - - // - prph - ( - - ) - - // - prcc - ( - // sizeof DMUS_IO_PARAMCONTROLTRACK_CURVEINFO:DWORD - ... // curves, sorted in order of mtTime - ) -*/ - -#if (DIRECTSOUND_VERSION >= 0x0800) - -/* DirectSoundBufferConfig FX Map */ - -/* RIFF ids: */ - -#define DMUS_FOURCC_DSBC_FORM mmioFOURCC('D','S','B','C') -#define DMUS_FOURCC_DSBD_CHUNK mmioFOURCC('d','s','b','d') -#define DMUS_FOURCC_BSID_CHUNK mmioFOURCC('b','s','i','d') -#define DMUS_FOURCC_DS3D_CHUNK mmioFOURCC('d','s','3','d') -#define DMUS_FOURCC_DSBC_LIST mmioFOURCC('f','x','l','s') -#define DMUS_FOURCC_DSFX_FORM mmioFOURCC('D','S','F','X') -#define DMUS_FOURCC_DSFX_CHUNK mmioFOURCC('f','x','h','r') -#define DMUS_FOURCC_DSFX_DATA mmioFOURCC('d','a','t','a') - -/* io structures */ - -typedef struct _DSOUND_IO_DSBUFFERDESC -{ - DWORD dwFlags; /* DirectSound buffer creation flags */ - WORD nChannels; /* No. of channels (rest of buffer format is determined by owning sink) */ - LONG lVolume; /* Initial pan; only used if CTRLVOLUME is specified */ - LONG lPan; /* Initial pan; only used if CTRLPAN is specified */ - DWORD dwReserved; /* Reserved - must be 0 */ -} DSOUND_IO_DSBUFFERDESC; - -typedef struct _DSOUND_IO_DSBUSID -{ - DWORD busid[1]; /* Array size determined from chunk size */ -} DSOUND_IO_DSBUSID; - -typedef struct _DSOUND_IO_3D -{ - GUID guid3DAlgorithm; /* GUID identifying the 3D algorithm to use (defined in dsound.h) */ - DS3DBUFFER ds3d; /* Initial 3D parameters */ -} DSOUND_IO_3D; - -typedef struct _DSOUND_IO_DXDMO_HEADER -{ - DWORD dwEffectFlags; /* Effect creation flags - equivalent to DSEFFECTDESC::dwFlags */ - GUID guidDSFXClass; /* GUID identifying the effect to use - corresponds to a COM CLSID */ - GUID guidReserved; /* Reserved - must be the null GUID */ - GUID guidSendBuffer; /* GUID identifying the buffer to send to if this is a send effect */ - DWORD dwReserved; /* Reserved - must be 0 */ -} DSOUND_IO_DXDMO_HEADER; - -typedef struct _DSOUND_IO_DXDMO_DATA -{ - DWORD data[1]; /* Array size determined by the DMO involved */ -} DSOUND_IO_DXDMO_DATA; - -/* -RIFF -( - 'DSBC' // DirectSoundBufferConfig chunk - [] // GUID identifier for this DirectSoundBufferConfig - [] // Optional version info - [] // Name, author, copyright info., comments - // DirectSound Buffer descriptor chunk - [] // Optional bus id array - [] // Optional 3d Parameters - [] // Optional list of FX descriptors -) - - // - 'guid' - ( - - ) - - // - 'vers' - ( - - ) - - // - 'dsbd' - ( - // Creation parameters and initial settings for the buffer - ) - - // - 'bsid' - ( - // The size of DSOUND_IO_DSBUSID is determined by the chunk size - ) - - // - 'ds3d' - ( - // Initial 3D buffer parameters: position, etc. - ) - - // - LIST - ( - 'fxls' // Array of DMO creation parameter blocks - ... // Each DMO is encapsulated in a RIFF chunk - ) - -// // DMOs can be embedded in a buffer configuration or stored as separate files -RIFF -( - 'DSFX' - // FX header chunk - [] // FX initial settings chunk -) - - // - 'fxhr' - ( - - ) - - // - 'data' - ( - // Opaque data block used by the DMO to load itself. - // For our standard included DMOs, this is simply the structure accepted by - // the DMO's SetAllParameters() method - e.g. struct DSFXChorus for Chorus. - ) -*/ - -#endif - -#ifdef __cplusplus -}; /* extern "C" */ -#endif - -#include - -#endif /* #ifndef _DMUSICF_ */ +/************************************************************************ +* * +* dmusicf.h -- This module defines the DirectMusic file formats * +* * +* Copyright (c) Microsoft Corporation. All rights reserved. * +* * +************************************************************************/ + +#ifndef _DMUSICF_ +#define _DMUSICF_ + + +#include + +#define COM_NO_WINDOWS_H +#include + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +interface IDirectMusicCollection; +#ifndef __cplusplus +typedef interface IDirectMusicCollection IDirectMusicCollection; +#endif + +/* Common chunks */ + +#define DMUS_FOURCC_GUID_CHUNK mmioFOURCC('g','u','i','d') +#define DMUS_FOURCC_INFO_LIST mmioFOURCC('I','N','F','O') +#define DMUS_FOURCC_UNFO_LIST mmioFOURCC('U','N','F','O') +#define DMUS_FOURCC_UNAM_CHUNK mmioFOURCC('U','N','A','M') +#define DMUS_FOURCC_UART_CHUNK mmioFOURCC('U','A','R','T') +#define DMUS_FOURCC_UCOP_CHUNK mmioFOURCC('U','C','O','P') +#define DMUS_FOURCC_USBJ_CHUNK mmioFOURCC('U','S','B','J') +#define DMUS_FOURCC_UCMT_CHUNK mmioFOURCC('U','C','M','T') +#define DMUS_FOURCC_CATEGORY_CHUNK mmioFOURCC('c','a','t','g') +#define DMUS_FOURCC_VERSION_CHUNK mmioFOURCC('v','e','r','s') + +/* The following structures are used by the Tracks, and are the packed structures */ +/* that are passed to the Tracks inside the IStream. */ + + +typedef struct _DMUS_IO_SEQ_ITEM +{ + MUSIC_TIME mtTime; + MUSIC_TIME mtDuration; + DWORD dwPChannel; + short nOffset; + BYTE bStatus; + BYTE bByte1; + BYTE bByte2; +} DMUS_IO_SEQ_ITEM; + + +typedef struct _DMUS_IO_CURVE_ITEM +{ + MUSIC_TIME mtStart; + MUSIC_TIME mtDuration; + MUSIC_TIME mtResetDuration; + DWORD dwPChannel; + short nOffset; + short nStartValue; + short nEndValue; + short nResetValue; + BYTE bType; + BYTE bCurveShape; + BYTE bCCData; + BYTE bFlags; + /* Following was added for DirectX8. */ + WORD wParamType; /* RPN or NRPN parameter number. */ + WORD wMergeIndex; /* Allows multiple parameters to be merged (pitchbend, volume, and expression.) */ +} DMUS_IO_CURVE_ITEM; + + +typedef struct _DMUS_IO_TEMPO_ITEM +{ + MUSIC_TIME lTime; + double dblTempo; +} DMUS_IO_TEMPO_ITEM; + + +typedef struct _DMUS_IO_SYSEX_ITEM +{ + MUSIC_TIME mtTime; + DWORD dwPChannel; + DWORD dwSysExLength; +} DMUS_IO_SYSEX_ITEM; + +typedef DMUS_CHORD_KEY DMUS_CHORD_PARAM; /* DMUS_CHORD_KEY defined in dmusici.h */ + +typedef struct _DMUS_RHYTHM_PARAM +{ + DMUS_TIMESIGNATURE TimeSig; + DWORD dwRhythmPattern; +} DMUS_RHYTHM_PARAM; + +typedef struct _DMUS_TEMPO_PARAM +{ + MUSIC_TIME mtTime; + double dblTempo; +} DMUS_TEMPO_PARAM; + + +typedef struct _DMUS_MUTE_PARAM +{ + DWORD dwPChannel; + DWORD dwPChannelMap; + BOOL fMute; +} DMUS_MUTE_PARAM; + +/* Style chunks */ + +#define DMUS_FOURCC_STYLE_FORM mmioFOURCC('D','M','S','T') +#define DMUS_FOURCC_STYLE_CHUNK mmioFOURCC('s','t','y','h') +#define DMUS_FOURCC_PART_LIST mmioFOURCC('p','a','r','t') +#define DMUS_FOURCC_PART_CHUNK mmioFOURCC('p','r','t','h') +#define DMUS_FOURCC_NOTE_CHUNK mmioFOURCC('n','o','t','e') +#define DMUS_FOURCC_CURVE_CHUNK mmioFOURCC('c','r','v','e') +#define DMUS_FOURCC_MARKER_CHUNK mmioFOURCC('m','r','k','r') +#define DMUS_FOURCC_RESOLUTION_CHUNK mmioFOURCC('r','s','l','n') +#define DMUS_FOURCC_ANTICIPATION_CHUNK mmioFOURCC('a','n','p','n') +#define DMUS_FOURCC_PATTERN_LIST mmioFOURCC('p','t','t','n') +#define DMUS_FOURCC_PATTERN_CHUNK mmioFOURCC('p','t','n','h') +#define DMUS_FOURCC_RHYTHM_CHUNK mmioFOURCC('r','h','t','m') +#define DMUS_FOURCC_PARTREF_LIST mmioFOURCC('p','r','e','f') +#define DMUS_FOURCC_PARTREF_CHUNK mmioFOURCC('p','r','f','c') +#define DMUS_FOURCC_STYLE_PERS_REF_LIST mmioFOURCC('p','r','r','f') +#define DMUS_FOURCC_MOTIFSETTINGS_CHUNK mmioFOURCC('m','t','f','s') + +/* Flags used by variations: these make up the DWORDs in dwVariationChoices. */ + +/* These flags determine the types of chords supported by a given variation in DirectMusic */ +/* mode. The first seven flags (bits 1-7) are set if the variation supports major chords */ +/* rooted in scale positions, so, e.g., if bits 1, 2, and 4 are set, the variation */ +/* supports major chords rooted in the tonic, second, and fourth scale positions. The */ +/* next seven flags serve the same purpose, but for minor chords, and the following seven */ +/* flags serve the same purpose for chords that are not major or minor (e.g., SUS 4 */ +/* chords). Bits 22, 23, and 24 are set if the variation supports chords rooted in the */ +/* scale, chords rooted sharp of scale tones, and chords rooted flat of scale tones, */ +/* respectively. For example, to support a C# minor chord in the scale of C Major, */ +/* bits 8 (for tonic minor) and 24 (for sharp) need to be set. Bits 25, 26, an 27 handle */ +/* chords that are triads, 6th or 7th chords, and chords with extensions, respectively. */ +/* bits 28 and 29 handle chords that are followed by tonic and dominant chords, */ +/* respectively. */ +#define DMUS_VARIATIONF_MAJOR 0x0000007F /* Seven positions in the scale - major chords. */ +#define DMUS_VARIATIONF_MINOR 0x00003F80 /* Seven positions in the scale - minor chords. */ +#define DMUS_VARIATIONF_OTHER 0x001FC000 /* Seven positions in the scale - other chords. */ +#define DMUS_VARIATIONF_ROOT_SCALE 0x00200000 /* Handles chord roots in the scale. */ +#define DMUS_VARIATIONF_ROOT_FLAT 0x00400000 /* Handles flat chord roots (based on scale notes). */ +#define DMUS_VARIATIONF_ROOT_SHARP 0x00800000 /* Handles sharp chord roots (based on scale notes). */ +#define DMUS_VARIATIONF_TYPE_TRIAD 0x01000000 /* Handles simple chords - triads. */ +#define DMUS_VARIATIONF_TYPE_6AND7 0x02000000 /* Handles simple chords - 6 and 7. */ +#define DMUS_VARIATIONF_TYPE_COMPLEX 0x04000000 /* Handles complex chords. */ +#define DMUS_VARIATIONF_DEST_TO1 0x08000000 /* Handles transitions to 1 chord. */ +#define DMUS_VARIATIONF_DEST_TO5 0x10000000 /* Handles transitions to 5 chord. */ +#define DMUS_VARIATIONF_DEST_OTHER 0x40000000 /* Handles transitions to chords other than 1 . */ + +/* legacy mask for variation modes */ +#define DMUS_VARIATIONF_MODES 0xE0000000 +/* Bits 29 and 31 of the variation flags are the Mode bits. If both are 0, it's IMA. */ +/* If bit 29 is 1, it's Direct Music. */ +#define DMUS_VARIATIONF_MODES_EX (0x20000000 | 0x80000000) +#define DMUS_VARIATIONF_IMA25_MODE 0x00000000 +#define DMUS_VARIATIONF_DMUS_MODE 0x20000000 + +/* Set this if the part uses marker events */ +#define DMUS_PARTF_USE_MARKERS 0x1 +/* Set this if the part is allowed to switch only on chord-aligned markers */ +#define DMUS_PARTF_ALIGN_CHORDS 0x2 + +/* These specify if the marker event signals whether to stop a variation or start a +pattern/variation (or both), and whether new variations must align with a chord */ +#define DMUS_MARKERF_START 0x1 +#define DMUS_MARKERF_STOP 0x2 +#define DMUS_MARKERF_CHORD_ALIGN 0x4 + +/* if this flag is set, variation settings in a playing pattern-based track's state data will +persist in the track after it stops playing */ +#define DMUS_PATTERNF_PERSIST_CONTROL 0x1 + +/* These specify possible values for DMUS_IO_PARTREF.bRandomVariation + all but DMUS_VARIATIONT_SEQUENTIAL and DMUS_VARIATIONT_RANDOM are DirectX8. */ +typedef enum enumDMUS_VARIATIONT_TYPES +{ + DMUS_VARIATIONT_SEQUENTIAL = 0, /* Play sequential starting with variation 1. */ + DMUS_VARIATIONT_RANDOM = 1, /* Play randomly. */ + DMUS_VARIATIONT_RANDOM_START = 2, /* Play sequential starting with a random variation. */ + DMUS_VARIATIONT_NO_REPEAT = 3, /* Play randomly, but don't play the same variation twice. */ + DMUS_VARIATIONT_RANDOM_ROW = 4 /* Play randomly as a row: don't repeat any variation until all have played. */ +} DMUS_VARIATIONT_TYPES; + +/* These specify possible values for DMUS_IO_PATTERN.wEmbellishment (DirectX8) */ +typedef enum enumDMUS_EMBELLISHT_TYPES +{ + DMUS_EMBELLISHT_NORMAL = 0, + DMUS_EMBELLISHT_FILL = 1, + DMUS_EMBELLISHT_BREAK = 2, + DMUS_EMBELLISHT_INTRO = 4, + DMUS_EMBELLISHT_END = 8, + DMUS_EMBELLISHT_MOTIF = 16, + DMUS_EMBELLISHT_ALL = 0xFFFF +} DMUS_EMBELLISHT_TYPES; + +#pragma pack(2) + +typedef struct _DMUS_IO_TIMESIG +{ + /* Time signatures define how many beats per measure, which note receives */ + /* the beat, and the grid resolution. */ + BYTE bBeatsPerMeasure; /* beats per measure (top of time sig) */ + BYTE bBeat; /* what note receives the beat (bottom of time sig.) */ + /* we can assume that 0 means 256th note */ + WORD wGridsPerBeat; /* grids per beat */ +} DMUS_IO_TIMESIG; + +typedef struct _DMUS_IO_STYLE +{ + DMUS_IO_TIMESIG timeSig; /* Styles have a default Time Signature */ + double dblTempo; +} DMUS_IO_STYLE; + +typedef struct _DMUS_IO_VERSION +{ + DWORD dwVersionMS; /* Version # high-order 32 bits */ + DWORD dwVersionLS; /* Version # low-order 32 bits */ +} DMUS_IO_VERSION; + +typedef struct _DMUS_IO_PATTERN +{ + DMUS_IO_TIMESIG timeSig; /* Patterns can override the Style's Time sig. */ + BYTE bGrooveBottom; /* bottom of groove range */ + BYTE bGrooveTop; /* top of groove range */ + WORD wEmbellishment; /* Fill, Break, Intro, End, Normal, Motif */ + WORD wNbrMeasures; /* length in measures */ + BYTE bDestGrooveBottom; /* bottom of groove range for next pattern */ + BYTE bDestGrooveTop; /* top of groove range for next pattern */ + DWORD dwFlags; /* various flags */ +} DMUS_IO_PATTERN; + +typedef struct _DMUS_IO_STYLEPART +{ + DMUS_IO_TIMESIG timeSig; /* can override pattern's */ + DWORD dwVariationChoices[32]; /* MOAW choice bitfield */ + GUID guidPartID; /* identifies the part */ + WORD wNbrMeasures; /* length of the Part */ + BYTE bPlayModeFlags; /* see PLAYMODE flags */ + BYTE bInvertUpper; /* inversion upper limit */ + BYTE bInvertLower; /* inversion lower limit */ + BYTE bPad[3]; /* for DWORD alignment */ + DWORD dwFlags; /* various flags */ +} DMUS_IO_STYLEPART; + +typedef struct _DMUS_IO_PARTREF +{ + GUID guidPartID; /* unique ID for matching up with parts */ + WORD wLogicalPartID; /* corresponds to port/device/midi channel OBSOLETE */ + BYTE bVariationLockID; /* parts with the same ID lock variations. */ + /* high bit is used to identify master Part */ + BYTE bSubChordLevel; /* tells which sub chord level this part wants */ + BYTE bPriority; /* 256 priority levels. Parts with lower priority */ + /* aren't played first when a device runs out of */ + /* notes */ + BYTE bRandomVariation; /* when set, matching variations play in random order */ + /* when clear, matching variations play sequentially */ + WORD wPad; /* not used */ + DWORD dwPChannel; /* replaces wLogicalPartID */ +} DMUS_IO_PARTREF; + +typedef struct _DMUS_IO_STYLENOTE +{ + MUSIC_TIME mtGridStart; /* when this note occurs */ + DWORD dwVariation; /* variation bits */ + MUSIC_TIME mtDuration; /* how long this note lasts */ + short nTimeOffset; /* offset from mtGridStart */ + WORD wMusicValue; /* Position in scale. */ + BYTE bVelocity; /* Note velocity. */ + BYTE bTimeRange; /* Range to randomize start time. */ + BYTE bDurRange; /* Range to randomize duration. */ + BYTE bVelRange; /* Range to randomize velocity. */ + BYTE bInversionID; /* Identifies inversion group to which this note belongs */ + BYTE bPlayModeFlags; /* Can override part */ + /* Following exists only under DirectX8 and on */ + BYTE bNoteFlags; /* values from DMUS_NOTEF_FLAGS */ +} DMUS_IO_STYLENOTE; + +typedef struct _DMUS_IO_STYLECURVE +{ + MUSIC_TIME mtGridStart; /* when this curve occurs */ + DWORD dwVariation; /* variation bits */ + MUSIC_TIME mtDuration; /* how long this curve lasts */ + MUSIC_TIME mtResetDuration;/* how long after the end of the curve to reset the curve */ + short nTimeOffset; /* offset from mtGridStart */ + short nStartValue; /* curve's start value */ + short nEndValue; /* curve's end value */ + short nResetValue; /* the value to which to reset the curve */ + BYTE bEventType; /* type of curve */ + BYTE bCurveShape; /* shape of curve */ + BYTE bCCData; /* CC# */ + BYTE bFlags; /* Bit 1=TRUE means to send nResetValue. Otherwise, don't. + Other bits are reserved. */ + /* Following was added for DirectX8. */ + WORD wParamType; /* RPN or NRPN parameter number. */ + WORD wMergeIndex; /* Allows multiple parameters to be merged (pitchbend, volume, and expression.) */ +} DMUS_IO_STYLECURVE; + +typedef struct _DMUS_IO_STYLEMARKER +{ + MUSIC_TIME mtGridStart; /* when this marker occurs */ + DWORD dwVariation; /* variation bits */ + WORD wMarkerFlags; /* how the marker is used */ +} DMUS_IO_STYLEMARKER; + +typedef struct _DMUS_IO_STYLERESOLUTION +{ + DWORD dwVariation; /* variation bits */ + WORD wMusicValue; /* Position in scale. */ + BYTE bInversionID; /* Identifies inversion group to which this note belongs */ + BYTE bPlayModeFlags; /* Can override part */ +} DMUS_IO_STYLERESOLUTION; + +typedef struct _DMUS_IO_STYLE_ANTICIPATION +{ + MUSIC_TIME mtGridStart; /* when this anticipation occurs */ + DWORD dwVariation; /* variation bits */ + short nTimeOffset; /* offset from mtGridStart */ + BYTE bTimeRange; /* Range to randomize start time. */ +} DMUS_IO_STYLE_ANTICIPATION; + +typedef struct _DMUS_IO_MOTIFSETTINGS +{ + DWORD dwRepeats; /* Number of repeats. By default, 0. */ + MUSIC_TIME mtPlayStart; /* Start of playback. By default, 0. */ + MUSIC_TIME mtLoopStart; /* Start of looping portion. By default, 0. */ + MUSIC_TIME mtLoopEnd; /* End of loop. Must be greater than mtLoopStart. Or, 0, indicating loop full motif. */ + DWORD dwResolution; /* Default resolution. */ +} DMUS_IO_MOTIFSETTINGS; + +#pragma pack() + + +/* +RIFF +( + 'DMST' // Style + // Style header chunk + // Every Style has a GUID + [] // Name, author, copyright info., comments + [] // version chunk + ... // Array of parts in the Style, used by patterns + ... // Array of patterns in the Style + ... // Array of bands in the Style + []...// Optional array of chord map references in the Style +) + + // + styh + ( + + ) + + // + guid + ( + + ) + + // + vers + ( + + ) + + // + LIST + ( + 'part' + // Part header chunk + [] // Name, author, copyright info., comments + [] // Optional chunk containing an array of notes in Part + [] // Optional chunk containing an array of curves in Part + [] // Optional chunk containing an array of markers in Part + [] // Optional chunk containing an array of variation resolutions in Part + [] // Optional chunk containing an array of resolution anticipations in Part + ) + + // + prth + ( + + ) + + // + 'note' + ( + // sizeof DMUS_IO_STYLENOTE:DWORD + ... + ) + + // + 'crve' + ( + // sizeof DMUS_IO_STYLECURVE:DWORD + ... + ) + + // + 'mrkr' + ( + // sizeof DMUS_IO_STYLEMARKER:DWORD + ... + ) + + // + 'rsln' + ( + // sizeof DMUS_IO_STYLERESOLUTION:DWORD + ... + ) + + // + 'anpn' + ( + // sizeof DMUS_IO_STYLE_ANTICIPATION:DWORD + ... + ) + + // + LIST + ( + 'pttn' + // Pattern header chunk + // Chunk containing an array of rhythms for chord matching + [] // Name, author, copyright info., comments + [] // Motif settings chunk + [] // Optional band to be associated with the pattern (for motifs) + ... // Array of part reference id's + ) + + // + ptnh + ( + + ) + + // + 'rhtm' + ( + // DWORD's representing rhythms for chord matching based on number + // of measures in the pattern + ) + + + // pref-list + LIST + ( + 'pref' + // part ref chunk + ) + + // + prfc + ( + + ) + + // + mtfs + ( + + ) + + // + LIST + ( + 'prrf' + ... // Array of Chordmap references + ) +*/ + +/* Pattern chunk, for use in Pattern tracks */ + +#define DMUS_FOURCC_PATTERN_FORM mmioFOURCC('D','M','P','T') + +/* +RIFF +( + 'DMPT' // Pattern + // Style header chunk + // The pattern, in single pattern format (includes DMUS_FOURCC_PART_LIST chunks) +) +*/ + + +/* Chord and command file formats */ + +/* These specify possible values for DMUS_IO_COMMAND.bRepeatMode (DirectX8) */ +typedef enum enumDMUS_PATTERNT_TYPES +{ + DMUS_PATTERNT_RANDOM = 0, /* Play randomly. (DirectX7 behavior) */ + DMUS_PATTERNT_REPEAT = 1, /* Repeat last pattern. */ + DMUS_PATTERNT_SEQUENTIAL = 2, /* Play sequential starting with first matching pattern. */ + DMUS_PATTERNT_RANDOM_START = 3, /* Play sequential starting with a random pattern. */ + DMUS_PATTERNT_NO_REPEAT = 4, /* Play randomly, but don't play the same pattern twice. */ + DMUS_PATTERNT_RANDOM_ROW = 5 /* Play randomly as a row: don't repeat any pattern until all have played. */ +} DMUS_PATTERNT_TYPES; + + +#define DMUS_FOURCC_CHORDTRACK_LIST mmioFOURCC('c','o','r','d') +#define DMUS_FOURCC_CHORDTRACKHEADER_CHUNK mmioFOURCC('c','r','d','h') +#define DMUS_FOURCC_CHORDTRACKBODY_CHUNK mmioFOURCC('c','r','d','b') + +#define DMUS_FOURCC_COMMANDTRACK_CHUNK mmioFOURCC('c','m','n','d') + +typedef struct _DMUS_IO_CHORD +{ + WCHAR wszName[16]; /* Name of the chord */ + MUSIC_TIME mtTime; /* Time of this chord */ + WORD wMeasure; /* Measure this falls on */ + BYTE bBeat; /* Beat this falls on */ + BYTE bFlags; /* Various flags */ +} DMUS_IO_CHORD; + +typedef struct _DMUS_IO_SUBCHORD +{ + DWORD dwChordPattern; /* Notes in the subchord */ + DWORD dwScalePattern; /* Notes in the scale */ + DWORD dwInversionPoints; /* Where inversions can occur */ + DWORD dwLevels; /* Which levels are supported by this subchord */ + BYTE bChordRoot; /* Root of the subchord */ + BYTE bScaleRoot; /* Root of the scale */ +} DMUS_IO_SUBCHORD; + +typedef struct _DMUS_IO_COMMAND +{ + MUSIC_TIME mtTime; /* Time of this command */ + WORD wMeasure; /* Measure this falls on */ + BYTE bBeat; /* Beat this falls on */ + BYTE bCommand; /* Command type (see #defines below) */ + BYTE bGrooveLevel; /* Groove level (0 if command is not a groove) */ + BYTE bGrooveRange; /* Groove range */ + BYTE bRepeatMode; /* Used to control selection of patterns with same groove level */ +} DMUS_IO_COMMAND; + + +/* + + // + LIST + ( + 'cord' + + ... // Chord body chunks + ) + + // + crdh + ( + // Scale: dword (upper 8 bits for root, lower 24 for scale) + ) + + // + crdb + ( + // sizeof DMUS_IO_CHORD:dword + + // # of DMUS_IO_SUBCHORDS:dword + // sizeof DMUS_IO_SUBCHORDS:dword + // a number of + ) + + + // + 'cmnd' + ( + //sizeof DMUS_IO_COMMAND: DWORD + ... + ) + +*/ + +/* File io for DirectMusic Tool and ToolGraph objects +*/ + +/* RIFF ids: */ + +#define DMUS_FOURCC_TOOLGRAPH_FORM mmioFOURCC('D','M','T','G') +#define DMUS_FOURCC_TOOL_LIST mmioFOURCC('t','o','l','l') +#define DMUS_FOURCC_TOOL_FORM mmioFOURCC('D','M','T','L') +#define DMUS_FOURCC_TOOL_CHUNK mmioFOURCC('t','o','l','h') + +/* io structures: */ + +typedef struct _DMUS_IO_TOOL_HEADER +{ + GUID guidClassID; /* Class id of tool. */ + long lIndex; /* Position in graph. */ + DWORD cPChannels; /* Number of items in channels array. */ + FOURCC ckid; /* chunk ID of tool's data chunk if 0 fccType valid. */ + FOURCC fccType; /* list type if NULL ckid valid. */ + DWORD dwPChannels[1]; /* Array of PChannels, size determined by cPChannels. */ +} DMUS_IO_TOOL_HEADER; + +/* +RIFF +( + 'DMTG' // DirectMusic ToolGraph chunk + [] // GUID for ToolGraph + [] // Optional version info + [] // Name, author, copyright info., comments + // List of Tools +) + + // + 'guid' + ( + + ) + + // + vers + ( + + ) + + // + LIST + ( + 'toll' // Array of tools + ... // Each tool is encapsulated in a RIFF chunk + ) + +// Tools are embedded in a graph. Theoretically, they can be saved as individual files too. +RIFF +( + 'DMTL' + + [] // Tool data. Must be a RIFF readable chunk. +) + + // // Tool header chunk + ( + 'tolh' + // Tool header + ) +*/ + +/* The AudioPath file carries everything for describing a specific audio path, + including Tool Graph and Buffer Descriptor. + This can even be used for configuring a complete performance. +*/ + +#define DMUS_FOURCC_AUDIOPATH_FORM mmioFOURCC('D','M','A','P') + +/* +RIFF +( + 'DMAP' // DirectMusic AudioPath chunk + [] // GUID for this Audio Path configuration + [] // Optional version info + [] // Name, author, copyright info., comments + [] // Optional ToolGraph + [] // Optional list of port configurations + []...// Optional array of DirectSound buffer descriptors +) +*/ + +#define DMUS_FOURCC_PORTCONFIGS_LIST mmioFOURCC('p','c','s','l') +#define DMUS_FOURCC_PORTCONFIG_LIST mmioFOURCC('p','c','f','l') +#define DMUS_FOURCC_PORTCONFIG_ITEM mmioFOURCC('p','c','f','h') +#define DMUS_FOURCC_PORTPARAMS_ITEM mmioFOURCC('p','p','r','h') +#define DMUS_FOURCC_DSBUFFER_LIST mmioFOURCC('d','b','f','l') +#define DMUS_FOURCC_DSBUFFATTR_ITEM mmioFOURCC('d','d','a','h') +#define DMUS_FOURCC_PCHANNELS_LIST mmioFOURCC('p','c','h','l') +#define DMUS_FOURCC_PCHANNELS_ITEM mmioFOURCC('p','c','h','h') + +typedef struct _DMUS_IO_PORTCONFIG_HEADER +{ + GUID guidPort; /* GUID of requested port. */ + DWORD dwPChannelBase; /* PChannel that this should start on. */ + DWORD dwPChannelCount; /* How many channels. */ + DWORD dwFlags; /* Various flags. */ +} DMUS_IO_PORTCONFIG_HEADER; + +#define DMUS_PORTCONFIGF_DRUMSON10 1 /* This port configured for drums on channel 10. */ +#define DMUS_PORTCONFIGF_USEDEFAULT 2 /* Use the default port. */ + +/* Each portconfig has one or more pchannel to buffer mappings. Each buffer + is identified by a guid. Each pchannel can map to one or more buffers. + This is defined with one or more DMUS_IO_PCHANNELTOBUFFER_HEADER + structures. Each defines a range of PChannels and the set of buffers + that they connect to. +*/ + +typedef struct _DMUS_IO_PCHANNELTOBUFFER_HEADER +{ + DWORD dwPChannelBase; /* PChannel that this should start on. */ + DWORD dwPChannelCount; /* How many PChannels. */ + DWORD dwBufferCount; /* How many buffers do these connect to. */ + DWORD dwFlags; /* Various flags. Currently reserved for future use. Must be 0. */ +} DMUS_IO_PCHANNELTOBUFFER_HEADER; + +/* Each buffer is represented by an DSBC form. This is wrapped by the + DMUS_IO_BUFFER_ATTRIBUTES_HEADER which identifies how to use the + buffer. In particular, it indicates whether this gets dynamically duplicated + or all references to this should share the same instance. + To resolve references, the unique GUID of the buffer is also stored + in this structure. +*/ + +typedef struct _DMUS_IO_BUFFER_ATTRIBUTES_HEADER +{ + GUID guidBufferID; /* Each buffer config has a unique ID. */ + DWORD dwFlags; /* Various flags. */ +} DMUS_IO_BUFFER_ATTRIBUTES_HEADER; + +/* DMUS_IO_BUFFER_ATTRIBUTES_HEADER.dwFlags: */ +#define DMUS_BUFFERF_SHARED 1 /* Share this with other audio paths, instead of creating unique copies. */ +#define DMUS_BUFFERF_DEFINED 2 /* Use one of the standard predefined buffers (see GUID_Buffer... in dmusici.h.) */ +#define DMUS_BUFFERF_MIXIN 8 /* This is a mixin buffer. */ + +/* + +LIST +( + 'pcsl' // Array of port configurations + ... // One or more port configurations, each in a list chunk +) + +LIST +( + 'pcfl' // List container for one port configuration. + // Portconfig header chunk. + // Port params, to be used to create the port. + []...// Optional array of DirectSound buffer descriptors + [] // Optional list of pchannel to buffer assignments + +) + + // // Port config header chunk + ( + 'pcfh' + // Port config header + ) + + // // Port params header chunk + ( + 'pprh' + // Port params header + ) + +LIST +( + 'pchl' // List container for one or more pchannel to buffer assignments. + ... // One or more pchannel to buffer assignment headers and data. + + // + ( + 'pchh' + // Description of PChannels + ... // Array of GUIDs defining the buffers they all connect to. + ) +) + +LIST +( + 'dbfl' // List container for one buffer and buffer attributes header. + // Buffer attributes header. + [] // Buffer configuration. Not required when header uses a predefined buffer type. + + // + ( + 'ddah' + // Buffer attributes. + ) +) +*/ + +/* File io for DirectMusic Band Track object */ + + +/* RIFF ids: */ +#define DMUS_FOURCC_BANDTRACK_FORM mmioFOURCC('D','M','B','T') +#define DMUS_FOURCC_BANDTRACK_CHUNK mmioFOURCC('b','d','t','h') +#define DMUS_FOURCC_BANDS_LIST mmioFOURCC('l','b','d','l') +#define DMUS_FOURCC_BAND_LIST mmioFOURCC('l','b','n','d') +#define DMUS_FOURCC_BANDITEM_CHUNK mmioFOURCC('b','d','i','h') +#define DMUS_FOURCC_BANDITEM_CHUNK2 mmioFOURCC('b','d','2','h') + +/* io structures */ +typedef struct _DMUS_IO_BAND_TRACK_HEADER +{ + BOOL bAutoDownload; /* Determines if Auto-Download is enabled. */ +} DMUS_IO_BAND_TRACK_HEADER; + +typedef struct _DMUS_IO_BAND_ITEM_HEADER +{ + MUSIC_TIME lBandTime; /* Position in track list. */ +} DMUS_IO_BAND_ITEM_HEADER; + +typedef struct _DMUS_IO_BAND_ITEM_HEADER2 +{ + MUSIC_TIME lBandTimeLogical; /* Position in track list. Time in the music with which band change is associated. */ + MUSIC_TIME lBandTimePhysical; /* Precise time band change will take effect. Should be close to logical time. */ +} DMUS_IO_BAND_ITEM_HEADER2; + +/* +RIFF +( + 'DMBT' // DirectMusic Band Track form-type + [] // Band track header + [] // GUID for band track + [] // Optional version info + [] // Name, author, copyright info., comments + // List of Band items +) + + // + 'bdth' + ( + + ) + + // + 'guid' + ( + + ) + + // + vers + ( + + ) + + // + LIST + ( + 'lbdl' + ... // Array of bands, each encapsulated in a list chunk + ) + + // + LIST + ( + 'lbnd' + or // bdih is a legacy format. bd2h is preferred for new content. + // Band + ) + + // or // band item header + ( + or // Band item header + ) +*/ + + +/* File io for DirectMusic Band object +*/ + +/* RIFF ids: */ + +#define DMUS_FOURCC_BAND_FORM mmioFOURCC('D','M','B','D') +#define DMUS_FOURCC_INSTRUMENTS_LIST mmioFOURCC('l','b','i','l') +#define DMUS_FOURCC_INSTRUMENT_LIST mmioFOURCC('l','b','i','n') +#define DMUS_FOURCC_INSTRUMENT_CHUNK mmioFOURCC('b','i','n','s') + +/* Flags for DMUS_IO_INSTRUMENT + */ +#define DMUS_IO_INST_PATCH (1 << 0) /* dwPatch is valid. */ +#define DMUS_IO_INST_BANKSELECT (1 << 1) /* dwPatch contains a valid Bank Select MSB and LSB part */ +#define DMUS_IO_INST_ASSIGN_PATCH (1 << 3) /* dwAssignPatch is valid */ +#define DMUS_IO_INST_NOTERANGES (1 << 4) /* dwNoteRanges is valid */ +#define DMUS_IO_INST_PAN (1 << 5) /* bPan is valid */ +#define DMUS_IO_INST_VOLUME (1 << 6 ) /* bVolume is valid */ +#define DMUS_IO_INST_TRANSPOSE (1 << 7) /* nTranspose is valid */ +#define DMUS_IO_INST_GM (1 << 8) /* Instrument is from GM collection */ +#define DMUS_IO_INST_GS (1 << 9) /* Instrument is from GS collection */ +#define DMUS_IO_INST_XG (1 << 10) /* Instrument is from XG collection */ +#define DMUS_IO_INST_CHANNEL_PRIORITY (1 << 11) /* dwChannelPriority is valid */ +#define DMUS_IO_INST_USE_DEFAULT_GM_SET (1 << 12) /* Always use the default GM set for this patch, */ + /* don't rely on the synth caps stating GM or GS in hardware. */ +#define DMUS_IO_INST_PITCHBENDRANGE (1 << 13) /* nPitchBendRange is valid */ + +/* io structures */ +typedef struct _DMUS_IO_INSTRUMENT +{ + DWORD dwPatch; /* MSB, LSB and Program change to define instrument */ + DWORD dwAssignPatch; /* MSB, LSB and Program change to assign to instrument when downloading */ + DWORD dwNoteRanges[4]; /* 128 bits; one for each MIDI note instrument needs to able to play */ + DWORD dwPChannel; /* PChannel instrument plays on */ + DWORD dwFlags; /* DMUS_IO_INST_ flags */ + BYTE bPan; /* Pan for instrument */ + BYTE bVolume; /* Volume for instrument */ + short nTranspose; /* Number of semitones to transpose notes */ + DWORD dwChannelPriority; /* Channel priority */ + short nPitchBendRange; /* Number of semitones shifted by pitch bend */ +} DMUS_IO_INSTRUMENT; + +/* +// bands can be embedded in other forms +RIFF +( + 'DMBD' // DirectMusic Band chunk + [] // GUID for band + [] // Optional version info + [] // Name, author, copyright info., comments + // List of Instruments +) + + // + 'guid' + ( + + ) + + // + vers + ( + + ) + + // + LIST + ( + 'lbil' // Array of instruments + ... // Each instrument is encapsulated in a list + ) + + // + LIST + ( + 'lbin' + + [] // Optional reference to DLS Collection file. + ) + + // // Instrument chunk + ( + 'bins' + // Instrument header + ) +*/ + +/* This RIFF id and io struct have been added to allow wave files (and the wave object) to + differentiate between streaming and one-shot waves, and to give a prefetch for streaming + waves */ + +#define DMUS_FOURCC_WAVEHEADER_CHUNK mmioFOURCC('w','a','v','h') + +typedef struct _DMUS_IO_WAVE_HEADER +{ + REFERENCE_TIME rtReadAhead; /* How far ahead in the stream wave data will be read (in REFERENCE_TIME). Ignored for one-shot waves. */ + DWORD dwFlags; /* Various flags, including whether this is a streaming wave and whether it can be invalidated. */ +} DMUS_IO_WAVE_HEADER; + + +/* File io for Wave track */ + +/* RIFF ids: */ + +#define DMUS_FOURCC_WAVETRACK_LIST mmioFOURCC('w','a','v','t') +#define DMUS_FOURCC_WAVETRACK_CHUNK mmioFOURCC('w','a','t','h') +#define DMUS_FOURCC_WAVEPART_LIST mmioFOURCC('w','a','v','p') +#define DMUS_FOURCC_WAVEPART_CHUNK mmioFOURCC('w','a','p','h') +#define DMUS_FOURCC_WAVEITEM_LIST mmioFOURCC('w','a','v','i') +#define DMUS_FOURCC_WAVE_LIST mmioFOURCC('w','a','v','e') +#define DMUS_FOURCC_WAVEITEM_CHUNK mmioFOURCC('w','a','i','h') + +/* This flag is included in DMUS_IO_WAVE_TRACK_HEADER.dwFlags. If set, the track will get its + variations from a pattern track, via GetParam(GUID_Variations). */ +#define DMUS_WAVETRACKF_SYNC_VAR 0x1 +/* This is also included in DMUS_IO_WAVE_TRACK_HEADER.dwFlags. If set, variation control + information will persist from one playback instance to the next.*/ +#define DMUS_WAVETRACKF_PERSIST_CONTROL 0x2 + +typedef struct _DMUS_IO_WAVE_TRACK_HEADER +{ + long lVolume; /* Gain, in 1/100th of dB, to be applied to all waves. Note: All gain values should be negative. */ + DWORD dwFlags; /* Flags, including whether this track syncs to a pattern track for its variations. */ +} DMUS_IO_WAVE_TRACK_HEADER; + +typedef struct _DMUS_IO_WAVE_PART_HEADER +{ + long lVolume; /* Gain, in 1/100th of dB, to be applied to all waves in wave part. Note: All gain values should be negative. */ + DWORD dwVariations; /* Variation mask for which of 32 variations */ + DWORD dwPChannel; /* PChannel */ + DWORD dwLockToPart; /* Part ID to lock to. */ + DWORD dwFlags; /* Flags, including stuff for managing how variations are chosen (in low-order nibble) */ + DWORD dwIndex; /* Index for distinguishing multiple parts on the same PChannel*/ +} DMUS_IO_WAVE_PART_HEADER; + +typedef struct _DMUS_IO_WAVE_ITEM_HEADER +{ + long lVolume; /* Gain, in 1/100th of dB. Note: All gain values should be negative. */ + long lPitch; /* Pitch offset in 1/100th of a semitone. */ + DWORD dwVariations; /* Variation flags for which of 32 variations this wave belongs to. */ + REFERENCE_TIME rtTime; /* Start time, in REFERENCE_TIME, if clock time track, or MUSIC_TIME for music time track. */ + REFERENCE_TIME rtStartOffset; /* Distance into wave to start playback, in reference time units. */ + REFERENCE_TIME rtReserved; /* Reserved field. */ + REFERENCE_TIME rtDuration; /* Duration, in REFERENCE_TIME or MUSIC_TIME, depending on track timing format. */ + MUSIC_TIME mtLogicalTime; /* If in music track format, this indicates the musical boundary where this belongs. Otherwise, ignored. */ + DWORD dwLoopStart; /* Start point for a looping wave. */ + DWORD dwLoopEnd; /* End point for a looping wave. */ + DWORD dwFlags; /* Various flags, including whether this is a streaming wave and whether it can be invalidated. */ + WORD wVolumeRange; /* Random range for volume. */ + WORD wPitchRange; /* Random range for pitch. */ +} DMUS_IO_WAVE_ITEM_HEADER; + +/* +LIST +{ + 'wavt' // Wave track chunk + // Wave track header + ... // Array of Wave Parts +} + // + 'wath' + { + + } + + // + LIST + { + 'wavp' + // Wave Part Header + // List of wave items + } + + // + 'waph' + { + + } + + // + LIST + { + 'wavi' + ... // Array of waves; each wave is encapsulated in a list + } + + // + LIST + { + 'wave' + // Wave item header + // Reference to wave object + } + + // + 'waih' + { + + } + +*/ + +/* File io for DirectMusic Container file. This embeds a set of related files. And, + in turn, it can be embedded within a segment or script file. +*/ + +#define DMUS_FOURCC_CONTAINER_FORM mmioFOURCC('D','M','C','N') +#define DMUS_FOURCC_CONTAINER_CHUNK mmioFOURCC('c','o','n','h') +#define DMUS_FOURCC_CONTAINED_ALIAS_CHUNK mmioFOURCC('c','o','b','a') +#define DMUS_FOURCC_CONTAINED_OBJECT_CHUNK mmioFOURCC('c','o','b','h') +#define DMUS_FOURCC_CONTAINED_OBJECTS_LIST mmioFOURCC('c','o','s','l') +#define DMUS_FOURCC_CONTAINED_OBJECT_LIST mmioFOURCC('c','o','b','l') + +typedef struct _DMUS_IO_CONTAINER_HEADER +{ + DWORD dwFlags; /* Flags. */ +} DMUS_IO_CONTAINER_HEADER; + +#define DMUS_CONTAINER_NOLOADS (1 << 1) /* Contained items are not loaded when the container is loaded. + Entries will be created in the loader (via SetObject) but + the actual objects will not be created until they are + specifically loaded at a later time. */ + +typedef struct _DMUS_IO_CONTAINED_OBJECT_HEADER +{ + GUID guidClassID; /* Class id of object. */ + DWORD dwFlags; /* Flags, for example DMUS_CONTAINED_OBJF_KEEP. */ + FOURCC ckid; /* chunk ID of track's data chunk if 0 fccType valid. */ + FOURCC fccType; /* list type if NULL ckid valid */ + /* Note that LIST:DMRF may be used for ckid and fccType in order to reference an + object instead of embedding it within the container. */ +} DMUS_IO_CONTAINED_OBJECT_HEADER; + +#define DMUS_CONTAINED_OBJF_KEEP 1 /* Keep the object cached in the loader after the container is released. */ + +/* +RIFF +( + 'DMCN' // DirectMusic Container chunk + // Container header chunk + [] // GUID for container + [] // Optional version info + [] // Name, author, copyright info., comments + // List of objects. +) + + // + 'conh' + ( + + ) + + // + 'guid' + ( + + ) + + // + vers + ( + + ) + + LIST + ( + 'cosl' // Array of embedded objects. + ... // Each object is encapsulated in a LIST chunk + ) + + // // Encapsulates one object + LIST + ( + 'cobl' + [] // Alias. An alternative name by which this object is known + // within the container. + // Required header, includes CLASS ID for object. + [] or // Object data of the type specified in . + // If DMRF, it is a reference of where to find the object. + // Otherwise, it could be any RIFF readable chunk in the + // exact same format as a file. The object will load + // itself from this data. + ) + + // + 'coba' + ( + // Alias, stored as NULL terminated string of WCHARs + ) + + // + 'cobh' + ( + + ) +*/ + +/* File io for DirectMusic Segment object */ + +/* RIFF ids: */ + +#define DMUS_FOURCC_SEGMENT_FORM mmioFOURCC('D','M','S','G') +#define DMUS_FOURCC_SEGMENT_CHUNK mmioFOURCC('s','e','g','h') +#define DMUS_FOURCC_TRACK_LIST mmioFOURCC('t','r','k','l') +#define DMUS_FOURCC_TRACK_FORM mmioFOURCC('D','M','T','K') +#define DMUS_FOURCC_TRACK_CHUNK mmioFOURCC('t','r','k','h') +#define DMUS_FOURCC_TRACK_EXTRAS_CHUNK mmioFOURCC('t','r','k','x') + +/* io structures:*/ + +typedef struct _DMUS_IO_SEGMENT_HEADER +{ + DWORD dwRepeats; /* Number of repeats. By default, 0. */ + MUSIC_TIME mtLength; /* Length, in music time. */ + MUSIC_TIME mtPlayStart; /* Start of playback. By default, 0. */ + MUSIC_TIME mtLoopStart; /* Start of looping portion. By default, 0. */ + MUSIC_TIME mtLoopEnd; /* End of loop. Must be greater than dwPlayStart. Or, 0, indicating loop full segment. */ + DWORD dwResolution; /* Default resolution. */ + /* Following added for DirectX8: */ + REFERENCE_TIME rtLength; /* Length, in reference time (overrides music time length.) */ + DWORD dwFlags; + DWORD dwReserved; /* Reserved. */ + /* Added for DirectX9: */ + REFERENCE_TIME rtLoopStart; /* Clock time loop start. */ + REFERENCE_TIME rtLoopEnd; /* Clock time loop end. */ + REFERENCE_TIME rtPlayStart; /* Start of playback in clock time. */ +} DMUS_IO_SEGMENT_HEADER; + +#define DMUS_SEGIOF_REFLENGTH 1 /* Use the time in rtLength for the segment length. */ +#define DMUS_SEGIOF_CLOCKTIME 2 /* This is a clock time segment. */ + +typedef struct _DMUS_IO_TRACK_HEADER +{ + GUID guidClassID; /* Class id of track. */ + DWORD dwPosition; /* Position in track list. */ + DWORD dwGroup; /* Group bits for track. */ + FOURCC ckid; /* chunk ID of track's data chunk. */ + FOURCC fccType; /* list type if ckid is RIFF or LIST */ +} DMUS_IO_TRACK_HEADER; + +/* Additional parameters for the track header chunk, introduced in DirectX8 and + on, are stored in a separate chunk. */ + +typedef struct _DMUS_IO_TRACK_EXTRAS_HEADER +{ + DWORD dwFlags; /* DirectX8 Added flags for control tracks. */ + DWORD dwPriority; /* Priority for composition. */ +} DMUS_IO_TRACK_EXTRAS_HEADER; + +/* +RIFF +( + 'DMSG' // DirectMusic Segment chunk + // Segment header chunk + [] // GUID for segment + [] // Optional version info + [] // Name, author, copyright info., comments + [] // Optional container of objects embedded in file. Must precede tracklist. + // List of Tracks + [] // Optional ToolGraph + [] // Optional Audio Path +) + + // + 'segh' + ( + + ) + + // + 'guid' + ( + + ) + + // + vers + ( + + ) + + // + LIST + ( + 'trkl' // Array of tracks + ... // Each track is encapsulated in a RIFF chunk + ) + + // // Tracks can be embedded in a segment or stored as separate files. + RIFF + ( + 'DMTK' + + [] // Optional track flags. + [] // Optional GUID for track object instance (not to be confused with Class id in track header) + [] // Optional version info + [] // Optional name, author, copyright info., comments + [] // Track data. Must be a RIFF readable chunk. + ) + + // // Track header chunk + ( + 'trkh' + // Track header + ) + + // // Track flags chunk + ( + 'trkx' + // DirectX8 Track flags header + ) +*/ + +/* File io for DirectMusic reference chunk. + This is used to embed a reference to an object. +*/ + +/* RIFF ids: */ + +#define DMUS_FOURCC_REF_LIST mmioFOURCC('D','M','R','F') +#define DMUS_FOURCC_REF_CHUNK mmioFOURCC('r','e','f','h') +#define DMUS_FOURCC_DATE_CHUNK mmioFOURCC('d','a','t','e') +#define DMUS_FOURCC_NAME_CHUNK mmioFOURCC('n','a','m','e') +#define DMUS_FOURCC_FILE_CHUNK mmioFOURCC('f','i','l','e') + +typedef struct _DMUS_IO_REFERENCE +{ + GUID guidClassID; /* Class id is always required. */ + DWORD dwValidData; /* Flags. */ +} DMUS_IO_REFERENCE; + +/* +LIST +( + 'DMRF' // DirectMusic Reference chunk + // Reference header chunk + [] // Optional object GUID. + [] // Optional file date. + [] // Optional name. + [] // Optional file name. + [] // Optional category name. + [] // Optional version info. +) + + // + 'refh' + ( + + ) + + // + 'guid' + ( + + ) + + // + date + ( + + ) + + // + name + ( + // Name, stored as NULL terminated string of WCHARs + ) + + // + file + ( + // File name, stored as NULL terminated string of WCHARs + ) + + // + catg + ( + // Category name, stored as NULL terminated string of WCHARs + ) + + // + vers + ( + + ) +*/ + +/* Chord Maps */ + +/* runtime chunks */ +#define DMUS_FOURCC_CHORDMAP_FORM mmioFOURCC('D','M','P','R') +#define DMUS_FOURCC_IOCHORDMAP_CHUNK mmioFOURCC('p','e','r','h') +#define DMUS_FOURCC_SUBCHORD_CHUNK mmioFOURCC('c','h','d','t') +#define DMUS_FOURCC_CHORDENTRY_CHUNK mmioFOURCC('c','h','e','h') +#define DMUS_FOURCC_SUBCHORDID_CHUNK mmioFOURCC('s','b','c','n') +#define DMUS_FOURCC_IONEXTCHORD_CHUNK mmioFOURCC('n','c','r','d') +#define DMUS_FOURCC_NEXTCHORDSEQ_CHUNK mmioFOURCC('n','c','s','q') +#define DMUS_FOURCC_IOSIGNPOST_CHUNK mmioFOURCC('s','p','s','h') +#define DMUS_FOURCC_CHORDNAME_CHUNK mmioFOURCC('I','N','A','M') + +/* runtime list chunks */ +#define DMUS_FOURCC_CHORDENTRY_LIST mmioFOURCC('c','h','o','e') +#define DMUS_FOURCC_CHORDMAP_LIST mmioFOURCC('c','m','a','p') +#define DMUS_FOURCC_CHORD_LIST mmioFOURCC('c','h','r','d') +#define DMUS_FOURCC_CHORDPALETTE_LIST mmioFOURCC('c','h','p','l') +#define DMUS_FOURCC_CADENCE_LIST mmioFOURCC('c','a','d','e') +#define DMUS_FOURCC_SIGNPOSTITEM_LIST mmioFOURCC('s','p','s','t') + +#define DMUS_FOURCC_SIGNPOST_LIST mmioFOURCC('s','p','s','q') + +/* values for dwChord field of DMUS_IO_PERS_SIGNPOST */ +/* DMUS_SIGNPOSTF_ flags are also used in templates (DMUS_IO_SIGNPOST) */ +#define DMUS_SIGNPOSTF_A 1 +#define DMUS_SIGNPOSTF_B 2 +#define DMUS_SIGNPOSTF_C 4 +#define DMUS_SIGNPOSTF_D 8 +#define DMUS_SIGNPOSTF_E 0x10 +#define DMUS_SIGNPOSTF_F 0x20 +#define DMUS_SIGNPOSTF_LETTER (DMUS_SIGNPOSTF_A | DMUS_SIGNPOSTF_B | DMUS_SIGNPOSTF_C | DMUS_SIGNPOSTF_D | DMUS_SIGNPOSTF_E | DMUS_SIGNPOSTF_F) +#define DMUS_SIGNPOSTF_1 0x100 +#define DMUS_SIGNPOSTF_2 0x200 +#define DMUS_SIGNPOSTF_3 0x400 +#define DMUS_SIGNPOSTF_4 0x800 +#define DMUS_SIGNPOSTF_5 0x1000 +#define DMUS_SIGNPOSTF_6 0x2000 +#define DMUS_SIGNPOSTF_7 0x4000 +#define DMUS_SIGNPOSTF_ROOT (DMUS_SIGNPOSTF_1 | DMUS_SIGNPOSTF_2 | DMUS_SIGNPOSTF_3 | DMUS_SIGNPOSTF_4 | DMUS_SIGNPOSTF_5 | DMUS_SIGNPOSTF_6 | DMUS_SIGNPOSTF_7) +#define DMUS_SIGNPOSTF_CADENCE 0x8000 + +/* values for dwFlags field of DMUS_IO_CHORDMAP */ +#define DMUS_CHORDMAPF_VERSION8 1 /* Chordmap is version 8 or above. */ + +/* values for dwChord field of DMUS_IO_PERS_SIGNPOST */ +#define DMUS_SPOSTCADENCEF_1 2 /* Use the first cadence chord. */ +#define DMUS_SPOSTCADENCEF_2 4 /* Use the second cadence chord. */ + +/* run time data structs */ +typedef struct _DMUS_IO_CHORDMAP +{ + WCHAR wszLoadName[20]; + DWORD dwScalePattern; + DWORD dwFlags; /* Various flags. Only lower 16 bits are significant. */ +} DMUS_IO_CHORDMAP; + +typedef struct _DMUS_IO_CHORDMAP_SUBCHORD +{ + DWORD dwChordPattern; + DWORD dwScalePattern; + DWORD dwInvertPattern; + BYTE bChordRoot; + BYTE bScaleRoot; + WORD wCFlags; + DWORD dwLevels; /* parts or which subchord levels this chord supports */ +} DMUS_IO_CHORDMAP_SUBCHORD; + +/* Legacy name... */ +typedef DMUS_IO_CHORDMAP_SUBCHORD DMUS_IO_PERS_SUBCHORD; + +typedef struct _DMUS_IO_CHORDENTRY +{ + DWORD dwFlags; + WORD wConnectionID; /* replaces runtime "pointer to this" */ +} DMUS_IO_CHORDENTRY; + +typedef struct _DMUS_IO_NEXTCHORD +{ + DWORD dwFlags; + WORD nWeight; + WORD wMinBeats; + WORD wMaxBeats; + WORD wConnectionID; /* points to an ioChordEntry */ +} DMUS_IO_NEXTCHORD; + +typedef struct _DMUS_IO_CHORDMAP_SIGNPOST +{ + DWORD dwChords; /* 1bit per group */ + DWORD dwFlags; +} DMUS_IO_CHORDMAP_SIGNPOST; + +/* Legacy name... */ +typedef DMUS_IO_CHORDMAP_SIGNPOST DMUS_IO_PERS_SIGNPOST; + +/* +RIFF +( + 'DMPR' + // Chord map header chunk + [] // guid chunk + [] // version chunk (two DWORDS) + [] // Unfo chunk + // subchord database + // chord palette + // chord map + // signpost list + ) + + ::= LIST('cmap' ) + + ::= LIST('choe' + // chord entry data + // chord definition + // connecting(next) chords + ) + + ::= LIST('chrd' + // name of chord in wide char format + // list of subchords composing chord + ) + + ::= LIST('chpl' + ... // chord definition + ) + + ::== LIST('spsq' ... ) + + ::= LIST('spst' + + + [] + ) + + ::= LIST('cade' ...) + + ::= perh() + + ::= chdt( + ... ) + + ::= cheh() + + ::= sbcn( ...) + + ::= ncsq( + ...) + + ::= spsh() + +*/ + +/* File io for DirectMusic Script object */ + +/* RIFF ids: */ + +#define DMUS_FOURCC_SCRIPT_FORM mmioFOURCC('D','M','S','C') +#define DMUS_FOURCC_SCRIPT_CHUNK mmioFOURCC('s','c','h','d') +#define DMUS_FOURCC_SCRIPTVERSION_CHUNK mmioFOURCC('s','c','v','e') +#define DMUS_FOURCC_SCRIPTLANGUAGE_CHUNK mmioFOURCC('s','c','l','a') +#define DMUS_FOURCC_SCRIPTSOURCE_CHUNK mmioFOURCC('s','c','s','r') + +/* io structures:*/ + +typedef struct _DMUS_IO_SCRIPT_HEADER +{ + DWORD dwFlags; /* DMUS_SCRIPTIOF_ flags */ +} DMUS_IO_SCRIPT_HEADER; + +#define DMUS_SCRIPTIOF_LOAD_ALL_CONTENT (1 << 0) + /* If set, when the script loads it will also load all the content in its container. */ +#define DMUS_SCRIPTIOF_DOWNLOAD_ALL_SEGMENTS (1 << 1) + /* If set and LOAD_ALL_CONTENT is also set, when the script initializes it will also download all the segments in its container. + If set and LOAD_ALL_CONTENT is not set, when the script calls segment.Load on a segment then the segment will also be downloaded. + If not set, the script must manually download and unload by calling segment.DownloadSoundData and segment.UnloadSoundData. */ + +/* +RIFF +( + 'DMSC' // DirectMusic Script chunk + // Script header chunk + [] // GUID for script + [] // Optional version info + [] // Name, author, copyright info., comments + // Version of DirectMusic this script was authored to run against + // Container of content referenced by the script. + // ActiveX scripting language in which the script is written + or // The script's source code. + // If scsr-ck, the source is embedding in the chunk. + // If DMRF, it is a reference of where to find a text file with the source. + // Class id (guidClassID in DMUS_IO_REFERENCE) must be GUID_NULL because + // this text file is not a DirectMusic object in its own right. +) + + // + 'schd' + ( + + ) + + // + 'guid' + ( + + ) + + // + vers + ( + + ) + + // + scve + ( + + ) + + 'scla' + ( + // Language name, stored as NULL terminated string of WCHARs + ) + + 'scsr' + ( + // Source code, stored as NULL terminated string of WCHARs + ) +*/ + +/* Signpost tracks */ + +#define DMUS_FOURCC_SIGNPOST_TRACK_CHUNK mmioFOURCC( 's', 'g', 'n', 'p' ) + + +typedef struct _DMUS_IO_SIGNPOST +{ + MUSIC_TIME mtTime; + DWORD dwChords; + WORD wMeasure; +} DMUS_IO_SIGNPOST; + +/* + + // + 'sgnp' + ( + //sizeof DMUS_IO_SIGNPOST: DWORD + ... + ) + +*/ + +#define DMUS_FOURCC_MUTE_CHUNK mmioFOURCC('m','u','t','e') + +typedef struct _DMUS_IO_MUTE +{ + MUSIC_TIME mtTime; + DWORD dwPChannel; + DWORD dwPChannelMap; +} DMUS_IO_MUTE; + +/* + + // + 'mute' + ( + //sizeof DMUS_IO_MUTE:DWORD + ... + ) + + +*/ + +/* Used for both style and chord map tracks */ + +#define DMUS_FOURCC_TIME_STAMP_CHUNK mmioFOURCC('s', 't', 'm', 'p') + +/* Style tracks */ + +#define DMUS_FOURCC_STYLE_TRACK_LIST mmioFOURCC('s', 't', 't', 'r') +#define DMUS_FOURCC_STYLE_REF_LIST mmioFOURCC('s', 't', 'r', 'f') + +/* + + // + LIST('sttr' + ( + ... // Array of Style references + ) + + // + LIST('strf' + ( + + + ) + + // + 'stmp' + ( + // time:DWORD + ) + +*/ + +/* Chord map tracks */ + +#define DMUS_FOURCC_PERS_TRACK_LIST mmioFOURCC('p', 'f', 't', 'r') +#define DMUS_FOURCC_PERS_REF_LIST mmioFOURCC('p', 'f', 'r', 'f') + +/* + + // + LIST('pftr' + ( + ... // Array of Chord map references + ) + + // + LIST('pfrf' + ( + + + ) + + // + 'stmp' + ( + // time:DWORD + ) + +*/ + +#define DMUS_FOURCC_TEMPO_TRACK mmioFOURCC('t','e','t','r') + +/* + // tempo array + 'tetr' + ( + // sizeof DMUS_IO_TEMPO_ITEM: DWORD + ... + ) + */ + +#define DMUS_FOURCC_SEQ_TRACK mmioFOURCC('s','e','q','t') +#define DMUS_FOURCC_SEQ_LIST mmioFOURCC('e','v','t','l') +#define DMUS_FOURCC_CURVE_LIST mmioFOURCC('c','u','r','l') + +/* + // sequence track + 'seqt' + ( + // sequence array + 'evtl' + ( + // sizeof DMUS_IO_SEQ_ITEM: DWORD + ... + ) + // curve array + 'curl' + ( + // sizeof DMUS_IO_CURVE_ITEM: DWORD + ... + ) + ) +*/ + +#define DMUS_FOURCC_SYSEX_TRACK mmioFOURCC('s','y','e','x') + +/* + // sysex track + 'syex' + ( + { + + ... // Array of bytes, length defined in the DMUS_IO_SYSEXITEM structure + }... + ) +*/ + +#define DMUS_FOURCC_TIMESIGNATURE_TRACK mmioFOURCC('t','i','m','s') + +typedef struct _DMUS_IO_TIMESIGNATURE_ITEM +{ + MUSIC_TIME lTime; + BYTE bBeatsPerMeasure; /* beats per measure (top of time sig) */ + BYTE bBeat; /* what note receives the beat (bottom of time sig.) */ + /* we can assume that 0 means 256th note */ + WORD wGridsPerBeat; /* grids per beat */ +} DMUS_IO_TIMESIGNATURE_ITEM; + +/* DirectX6 time signature track + + 'tims' + ( + // size of DMUS_IO_TIMESIGNATURE_ITEM : DWORD + ... + ) +*/ + +/* DirectX8 Time signature track. The track has been updated from DirectX7 to support a list of + RIFF chunks. This will allow the time signature track to expand in the future. +*/ + +#define DMUS_FOURCC_TIMESIGTRACK_LIST mmioFOURCC('T','I','M','S') +#define DMUS_FOURCC_TIMESIG_CHUNK DMUS_FOURCC_TIMESIGNATURE_TRACK + +/* +LIST +( + 'TIMS' // Time Signature Track list-type + // Chunk containing an array of time signatures +) + + 'tims' + ( + // size of DMUS_IO_TIMESIGNATURE_ITEM : DWORD + ... + ) + +*/ + +/* DirectX8 Marker track. This is used to store valid start points and other + flow control parameters that may come later. For example, if we want + to implement more sophisticated looping and branching constructs, they + would live in this track. +*/ + +#define DMUS_FOURCC_MARKERTRACK_LIST mmioFOURCC('M','A','R','K') +#define DMUS_FOURCC_VALIDSTART_CHUNK mmioFOURCC('v','a','l','s') +#define DMUS_FOURCC_PLAYMARKER_CHUNK mmioFOURCC('p','l','a','y') + +/* io structures */ +typedef struct _DMUS_IO_VALID_START +{ + MUSIC_TIME mtTime; /* Time of a legal start. */ +} DMUS_IO_VALID_START; + +typedef struct _DMUS_IO_PLAY_MARKER +{ + MUSIC_TIME mtTime; /* Time of a next legal play point marker. */ +} DMUS_IO_PLAY_MARKER; + +/* +LIST +( + 'MARK' // Marker Track list-type + [] // Chunk containing an array of start points + [] // Chunk containing an array of play start markers +) + + 'vals' + ( + // size of DMUS_IO_VALID_START : DWORD + ... + ) + + 'play' + ( + // size of DMUS_IO_PLAY_MARKER : DWORD + ... + ) + +*/ + +/* segment trigger tracks */ + +/* RIFF ids: */ +#define DMUS_FOURCC_SEGTRACK_LIST mmioFOURCC('s','e','g','t') +#define DMUS_FOURCC_SEGTRACK_CHUNK mmioFOURCC('s','g','t','h') +#define DMUS_FOURCC_SEGMENTS_LIST mmioFOURCC('l','s','g','l') +#define DMUS_FOURCC_SEGMENT_LIST mmioFOURCC('l','s','e','g') +#define DMUS_FOURCC_SEGMENTITEM_CHUNK mmioFOURCC('s','g','i','h') +#define DMUS_FOURCC_SEGMENTITEMNAME_CHUNK mmioFOURCC('s','n','a','m') + +/* io structures */ +typedef struct _DMUS_IO_SEGMENT_TRACK_HEADER +{ + DWORD dwFlags; /* Reserved leave as 0. */ +} DMUS_IO_SEGMENT_TRACK_HEADER; + +typedef struct _DMUS_IO_SEGMENT_ITEM_HEADER +{ + MUSIC_TIME lTimeLogical; /* Position in track list. Time in the music with which the event is associated. */ + MUSIC_TIME lTimePhysical; /* Precise time event will be triggered. Should be close to logical time. */ + DWORD dwPlayFlags; /* Flags for PlaySegment(). */ + DWORD dwFlags; /* Flags. */ +} DMUS_IO_SEGMENT_ITEM_HEADER; + +/* values for dwflags field of DMUS_IO_SEGMENT_ITEM_HEADER */ +#define DMUS_SEGMENTTRACKF_MOTIF 1 /* interpret DMRF as link to style, and use snam as the name of a motif within the style */ + +/* +LIST +( + 'segt' // DirectMusic Segment Trigger Track form-type + [] // Segment track header + // List of Segment Lists +) + + // + 'sgth' + ( + + ) + + // + LIST + ( + 'lsgl' // Array of segments + ... // Each segment is encapsulated in a list (that way it can still be riff parsed.) + ) + + // + LIST + ( + 'lseg' + + // Link to a segment or style file. + [] // Name field. Used with DMUS_SEGMENTTRACKF_MOTIF flag. + ) + + // // segment item header + ( + // Segment item header + ) + + // + ( + // Name, stored as NULL terminated string of WCHARs + ) +*/ + +/* Script track. */ + +/* RIFF ids: */ +#define DMUS_FOURCC_SCRIPTTRACK_LIST mmioFOURCC('s','c','r','t') +#define DMUS_FOURCC_SCRIPTTRACKEVENTS_LIST mmioFOURCC('s','c','r','l') +#define DMUS_FOURCC_SCRIPTTRACKEVENT_LIST mmioFOURCC('s','c','r','e') +#define DMUS_FOURCC_SCRIPTTRACKEVENTHEADER_CHUNK mmioFOURCC('s','c','r','h') +#define DMUS_FOURCC_SCRIPTTRACKEVENTNAME_CHUNK mmioFOURCC('s','c','r','n') + +/* Flags for DMUS_IO_SCRIPTTRACK_TIMING + */ +#define DMUS_IO_SCRIPTTRACKF_PREPARE (1 << 0) /* Fire event in advance of time stamp, at Prepare time. This is the default because it leaves the script time to change the music happening at the target time. */ +#define DMUS_IO_SCRIPTTRACKF_QUEUE (1 << 1) /* Fire event just before time stamp, at Queue time. */ +#define DMUS_IO_SCRIPTTRACKF_ATTIME (1 << 2) /* Fire event right at the time stamp. */ + +typedef struct _DMUS_IO_SCRIPTTRACK_EVENTHEADER +{ + DWORD dwFlags; /* various bits (see DMUS_IO_SCRIPTTRACKF_*) */ + MUSIC_TIME lTimeLogical; /* Position in track list. Time in the music with which the event is associated. */ + MUSIC_TIME lTimePhysical; /* Precise time event will be triggered. Should be close to logical time. */ +} DMUS_IO_SCRIPTTRACK_EVENTHEADER; + +/* + // Script Track + + // + LIST + ( + // List of script events + ) + + // + LIST + ( + ... // Array of event descriptions + ) + + // + LIST + ( + // Event header chunk + + // Routine name + ) + + 'scrh' + ( + + ) + + 'scrn' + ( + // Name, stored as NULL terminated string of WCHARs + ) +*/ + +/* Lyrics/Notification track. */ + +/* RIFF ids: */ +#define DMUS_FOURCC_LYRICSTRACK_LIST mmioFOURCC('l','y','r','t') +#define DMUS_FOURCC_LYRICSTRACKEVENTS_LIST mmioFOURCC('l','y','r','l') +#define DMUS_FOURCC_LYRICSTRACKEVENT_LIST mmioFOURCC('l','y','r','e') +#define DMUS_FOURCC_LYRICSTRACKEVENTHEADER_CHUNK mmioFOURCC('l','y','r','h') +#define DMUS_FOURCC_LYRICSTRACKEVENTTEXT_CHUNK mmioFOURCC('l','y','r','n') + +typedef struct _DMUS_IO_LYRICSTRACK_EVENTHEADER +{ + DWORD dwFlags; /* Reserved leave as 0. */ + DWORD dwTimingFlags; /* Combination DMUS_PMSGF_TOOL_* flags. Determines the precise timing of when the notification happens. Invalid with the flag DMUS_PMSGF_REFTIME, DMUS_PMSGF_MUSICTIME, DMUS_PMSGF_TOOL_FLUSH, or DMUS_PMSGF_LOCKTOREFTIME. */ + MUSIC_TIME lTimeLogical; /* Position in track list. Time in the music with which the event is associated. */ + MUSIC_TIME lTimePhysical; /* Precise time event will be triggered. Should be close to logical time. */ +} DMUS_IO_LYRICSTRACK_EVENTHEADER; + +/* + // Lyrics/Notification Track + + // + LIST + ( + // List of notification events + ) + + // + LIST + ( + ... // Array of event descriptions + ) + + // + LIST + ( + // Event header chunk + // Notification text + ) + + 'lyrh' + ( + + ) + + 'lyrn' + ( + // Name, stored as NULL terminated string of WCHARs + ) +*/ + +/* Parameter control track */ + +/* RIFF ids: */ +#define DMUS_FOURCC_PARAMCONTROLTRACK_TRACK_LIST mmioFOURCC('p','r','m','t') +#define DMUS_FOURCC_PARAMCONTROLTRACK_OBJECT_LIST mmioFOURCC('p','r','o','l') +#define DMUS_FOURCC_PARAMCONTROLTRACK_OBJECT_CHUNK mmioFOURCC('p','r','o','h') +#define DMUS_FOURCC_PARAMCONTROLTRACK_PARAM_LIST mmioFOURCC('p','r','p','l') +#define DMUS_FOURCC_PARAMCONTROLTRACK_PARAM_CHUNK mmioFOURCC('p','r','p','h') +#define DMUS_FOURCC_PARAMCONTROLTRACK_CURVES_CHUNK mmioFOURCC('p','r','c','c') + +typedef struct _DMUS_IO_PARAMCONTROLTRACK_OBJECTHEADER +{ + DWORD dwFlags; /* Reserved. Must be zero. */ + GUID guidTimeFormat; /* Time format to set the object to. Must be GUID_TIME_REFERNCE or GUID_TIME_MUSIC from medparam.h. */ + /* Path for finding the object. These fields correspond to the first five parameters of IDirectMusicSegmentState::GetObjectInPath. */ + DWORD dwPChannel; + DWORD dwStage; + DWORD dwBuffer; + GUID guidObject; + DWORD dwIndex; +} DMUS_IO_PARAMCONTROLTRACK_OBJECTHEADER; + +typedef struct _DMUS_IO_PARAMCONTROLTRACK_PARAMHEADER +{ + DWORD dwFlags; /* Reserved. Must be zero. */ + DWORD dwIndex; /* Index number of the parameter on the object */ +} DMUS_IO_PARAMCONTROLTRACK_PARAMHEADER; + +typedef struct _DMUS_IO_PARAMCONTROLTRACK_CURVEINFO +{ + MUSIC_TIME mtStartTime; + MUSIC_TIME mtEndTime; + float fltStartValue; + float fltEndValue; + DWORD dwCurveType; /* One of the items from the MP_CURVE_TYPE enum in medparam.h */ + DWORD dwFlags; /* A combination of the MPF_ENVLP_* constants in medparam.h */ +} DMUS_IO_PARAMCONTROLTRACK_CURVEINFO; + +/* + // + LIST + ( + ... // one for each object + ) + + // + LIST + ( + // object header chunk + ... // one for each parameter + ) + + // + proh + ( + + ) + + // + LIST + ( + // parameter header chunk + // chunk containing an array of curves + ) + + // + prph + ( + + ) + + // + prcc + ( + // sizeof DMUS_IO_PARAMCONTROLTRACK_CURVEINFO:DWORD + ... // curves, sorted in order of mtTime + ) +*/ + +#if (DIRECTSOUND_VERSION >= 0x0800) + +/* DirectSoundBufferConfig FX Map */ + +/* RIFF ids: */ + +#define DMUS_FOURCC_DSBC_FORM mmioFOURCC('D','S','B','C') +#define DMUS_FOURCC_DSBD_CHUNK mmioFOURCC('d','s','b','d') +#define DMUS_FOURCC_BSID_CHUNK mmioFOURCC('b','s','i','d') +#define DMUS_FOURCC_DS3D_CHUNK mmioFOURCC('d','s','3','d') +#define DMUS_FOURCC_DSBC_LIST mmioFOURCC('f','x','l','s') +#define DMUS_FOURCC_DSFX_FORM mmioFOURCC('D','S','F','X') +#define DMUS_FOURCC_DSFX_CHUNK mmioFOURCC('f','x','h','r') +#define DMUS_FOURCC_DSFX_DATA mmioFOURCC('d','a','t','a') + +/* io structures */ + +typedef struct _DSOUND_IO_DSBUFFERDESC +{ + DWORD dwFlags; /* DirectSound buffer creation flags */ + WORD nChannels; /* No. of channels (rest of buffer format is determined by owning sink) */ + LONG lVolume; /* Initial pan; only used if CTRLVOLUME is specified */ + LONG lPan; /* Initial pan; only used if CTRLPAN is specified */ + DWORD dwReserved; /* Reserved - must be 0 */ +} DSOUND_IO_DSBUFFERDESC; + +typedef struct _DSOUND_IO_DSBUSID +{ + DWORD busid[1]; /* Array size determined from chunk size */ +} DSOUND_IO_DSBUSID; + +typedef struct _DSOUND_IO_3D +{ + GUID guid3DAlgorithm; /* GUID identifying the 3D algorithm to use (defined in dsound.h) */ + DS3DBUFFER ds3d; /* Initial 3D parameters */ +} DSOUND_IO_3D; + +typedef struct _DSOUND_IO_DXDMO_HEADER +{ + DWORD dwEffectFlags; /* Effect creation flags - equivalent to DSEFFECTDESC::dwFlags */ + GUID guidDSFXClass; /* GUID identifying the effect to use - corresponds to a COM CLSID */ + GUID guidReserved; /* Reserved - must be the null GUID */ + GUID guidSendBuffer; /* GUID identifying the buffer to send to if this is a send effect */ + DWORD dwReserved; /* Reserved - must be 0 */ +} DSOUND_IO_DXDMO_HEADER; + +typedef struct _DSOUND_IO_DXDMO_DATA +{ + DWORD data[1]; /* Array size determined by the DMO involved */ +} DSOUND_IO_DXDMO_DATA; + +/* +RIFF +( + 'DSBC' // DirectSoundBufferConfig chunk + [] // GUID identifier for this DirectSoundBufferConfig + [] // Optional version info + [] // Name, author, copyright info., comments + // DirectSound Buffer descriptor chunk + [] // Optional bus id array + [] // Optional 3d Parameters + [] // Optional list of FX descriptors +) + + // + 'guid' + ( + + ) + + // + 'vers' + ( + + ) + + // + 'dsbd' + ( + // Creation parameters and initial settings for the buffer + ) + + // + 'bsid' + ( + // The size of DSOUND_IO_DSBUSID is determined by the chunk size + ) + + // + 'ds3d' + ( + // Initial 3D buffer parameters: position, etc. + ) + + // + LIST + ( + 'fxls' // Array of DMO creation parameter blocks + ... // Each DMO is encapsulated in a RIFF chunk + ) + +// // DMOs can be embedded in a buffer configuration or stored as separate files +RIFF +( + 'DSFX' + // FX header chunk + [] // FX initial settings chunk +) + + // + 'fxhr' + ( + + ) + + // + 'data' + ( + // Opaque data block used by the DMO to load itself. + // For our standard included DMOs, this is simply the structure accepted by + // the DMO's SetAllParameters() method - e.g. struct DSFXChorus for Chorus. + ) +*/ + +#endif + +#ifdef __cplusplus +}; /* extern "C" */ +#endif + +#include + +#endif /* #ifndef _DMUSICF_ */ diff --git a/src/dep/include/DXSDK/include/dmusici.h b/src/dep/include/DXSDK/include/dmusici.h index 0af3a12..65bf7f6 100644 --- a/src/dep/include/DXSDK/include/dmusici.h +++ b/src/dep/include/DXSDK/include/dmusici.h @@ -1,1883 +1,1883 @@ -/************************************************************************ -* * -* dmusici.h -- This module contains the API for the * -* DirectMusic performance layer * -* * -* Copyright (c) Microsoft Corporation. All rights reserved. * -* * -************************************************************************/ - -#ifndef _DMUSICI_ -#define _DMUSICI_ - -#include - -#define COM_NO_WINDOWS_H -#include - -#include -#include -/* plugin (track and tool) interfaces. This #include will eventually go away. */ -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef WORD TRANSITION_TYPE; -typedef __int64 REFERENCE_TIME; -typedef long MUSIC_TIME; - -#define MT_MIN 0x80000000 /* Minimum music time value. */ -#define MT_MAX 0x7FFFFFFF /* Maximum music time value. */ - -#define DMUS_PPQ 768 /* parts per quarter note */ - -interface IDirectMusicTrack; -interface IDirectMusicPerformance; -interface IDirectMusicPerformance8; -interface IDirectMusicTool; -interface IDirectMusicSegment; -interface IDirectMusicSegment8; -interface IDirectMusicSegmentState; -interface IDirectMusicSegmentState8; -interface IDirectMusicGraph; -interface IDirectMusicBuffer; -interface IDirectMusicInstrument; -interface IDirectMusicDownloadedInstrument; -interface IDirectMusicBand; -interface IDirectMusicChordMap; -interface IDirectMusicLoader; -interface IDirectMusicLoader8; -interface IDirectMusicScript; -interface IDirectMusicObject; -interface IDirectMusicStyle8; -interface IDirectMusicPatternTrack; -interface IDirectMusicContainer; -interface IDirectMusicTool8; -interface IDirectMusicTrack8; -interface IDirectMusicAudioPath; -#ifndef __cplusplus -typedef interface IDirectMusicTrack IDirectMusicTrack; -typedef interface IDirectMusicPerformance IDirectMusicPerformance; -typedef interface IDirectMusicPerformance8 IDirectMusicPerformance8; -typedef interface IDirectMusicTool IDirectMusicTool; -typedef interface IDirectMusicSegment IDirectMusicSegment; -typedef interface IDirectMusicSegment8 IDirectMusicSegment8; -typedef interface IDirectMusicSegmentState IDirectMusicSegmentState; -typedef interface IDirectMusicSegmentState8 IDirectMusicSegmentState8; -typedef interface IDirectMusicGraph IDirectMusicGraph; -typedef interface IDirectMusicBuffer IDirectMusicBuffer; -typedef interface IDirectMusicInstrument IDirectMusicInstrument; -typedef interface IDirectMusicDownloadedInstrument IDirectMusicDownloadedInstrument; -typedef interface IDirectMusicBand IDirectMusicBand; -typedef interface IDirectMusicChordMap IDirectMusicChordMap; -typedef interface IDirectMusicObject IDirectMusicObject; -typedef interface IDirectMusicLoader IDirectMusicLoader; -typedef interface IDirectMusicLoader8 IDirectMusicLoader8; -typedef interface IDirectMusicScript IDirectMusicScript; -typedef interface IDirectMusicStyle8 IDirectMusicStyle8; -typedef interface IDirectMusicPatternTrack IDirectMusicPatternTrack; -typedef interface IDirectMusicContainer IDirectMusicContainer; -typedef interface IDirectMusicTool8 IDirectMusicTool8; -typedef interface IDirectMusicTrack8 IDirectMusicTrack8; -typedef interface IDirectMusicAudioPath IDirectMusicAudioPath; -#endif - -typedef enum enumDMUS_STYLET_TYPES -{ - DMUS_STYLET_PATTERN = 0, - DMUS_STYLET_MOTIF = 1, -} DMUS_STYLET_TYPES; - - -typedef enum enumDMUS_COMMANDT_TYPES -{ - DMUS_COMMANDT_GROOVE = 0, - DMUS_COMMANDT_FILL = 1, - DMUS_COMMANDT_INTRO = 2, - DMUS_COMMANDT_BREAK = 3, - DMUS_COMMANDT_END = 4, - DMUS_COMMANDT_ENDANDINTRO = 5 -} DMUS_COMMANDT_TYPES; - -typedef enum enumDMUS_SHAPET_TYPES -{ - DMUS_SHAPET_FALLING = 0, - DMUS_SHAPET_LEVEL = 1, - DMUS_SHAPET_LOOPABLE = 2, - DMUS_SHAPET_LOUD = 3, - DMUS_SHAPET_QUIET = 4, - DMUS_SHAPET_PEAKING = 5, - DMUS_SHAPET_RANDOM = 6, - DMUS_SHAPET_RISING = 7, - DMUS_SHAPET_SONG = 8 -} DMUS_SHAPET_TYPES; - -typedef enum enumDMUS_COMPOSEF_FLAGS -{ - DMUS_COMPOSEF_NONE = 0, - DMUS_COMPOSEF_ALIGN = 0x1, - DMUS_COMPOSEF_OVERLAP = 0x2, - DMUS_COMPOSEF_IMMEDIATE = 0x4, - DMUS_COMPOSEF_GRID = 0x8, - DMUS_COMPOSEF_BEAT = 0x10, - DMUS_COMPOSEF_MEASURE = 0x20, - DMUS_COMPOSEF_AFTERPREPARETIME = 0x40, - DMUS_COMPOSEF_VALID_START_BEAT = 0x80, /* In conjunction with DMUS_COMPOSEF_ALIGN, allows the switch to occur on any beat. */ - DMUS_COMPOSEF_VALID_START_GRID = 0x100, /* In conjunction with DMUS_COMPOSEF_ALIGN, allows the switch to occur on any grid. */ - DMUS_COMPOSEF_VALID_START_TICK = 0x200, /* In conjunction with DMUS_COMPOSEF_ALIGN, allows the switch to occur any time. */ - DMUS_COMPOSEF_SEGMENTEND = 0x400, /* Play the transition at the end of the current segment. */ - DMUS_COMPOSEF_MARKER = 0x800, /* Play the transition at the next marker in the current segment. */ - DMUS_COMPOSEF_MODULATE = 0x1000, - DMUS_COMPOSEF_LONG = 0x2000, - DMUS_COMPOSEF_ENTIRE_TRANSITION = 0x4000, /* play the entire transition pattern */ - DMUS_COMPOSEF_1BAR_TRANSITION = 0x8000, /* play one bar of the transition pattern */ - DMUS_COMPOSEF_ENTIRE_ADDITION = 0x10000, /* play the additional pattern in its entirety */ - DMUS_COMPOSEF_1BAR_ADDITION = 0x20000, /* play one bar of the additional pattern */ - DMUS_COMPOSEF_VALID_START_MEASURE = 0x40000, /* In conjunction with DMUS_COMPOSEF_ALIGN, allows the switch to occur on any bar. */ - DMUS_COMPOSEF_DEFAULT = 0x80000, /* Use segment's default boundary */ - DMUS_COMPOSEF_NOINVALIDATE = 0x100000, /* Play without invalidating the currently playing segment(s) */ - DMUS_COMPOSEF_USE_AUDIOPATH = 0x200000, /* Uses the audio paths that are embedded in the segments */ - DMUS_COMPOSEF_INVALIDATE_PRI = 0x400000 /* Invalidate only the current primary seg state */ -} DMUS_COMPOSEF_FLAGS; - -#define DMUS_PMSG_PART \ - DWORD dwSize; \ - REFERENCE_TIME rtTime; /* real time (in 100 nanosecond increments) */ \ - MUSIC_TIME mtTime; /* music time */ \ - DWORD dwFlags; /* various bits (see DMUS_PMSGF_FLAGS enumeration) */ \ - DWORD dwPChannel; /* Performance Channel. The Performance can */ \ - /* use this to determine the port/channel. */ \ - DWORD dwVirtualTrackID; /* virtual track ID */ \ - IDirectMusicTool* pTool; /* tool interface pointer */ \ - IDirectMusicGraph* pGraph; /* tool graph interface pointer */ \ - DWORD dwType; /* PMSG type (see DMUS_PMSGT_TYPES defines) */ \ - DWORD dwVoiceID; /* unique voice id which allows synthesizers to */ \ - /* identify a specific event. For DirectX 6.0, */ \ - /* this field should always be 0. */ \ - DWORD dwGroupID; /* Track group id */ \ - IUnknown* punkUser; /* user com pointer, auto released upon PMSG free */ - -/* every DMUS_PMSG is based off of this structure. The Performance needs - to access these members consistently in every PMSG that goes through it. */ -typedef struct _DMUS_PMSG -{ - /* begin DMUS_PMSG_PART */ - DMUS_PMSG_PART - /* end DMUS_PMSG_PART */ - -} DMUS_PMSG; - -#define DMUS_PCHANNEL_BROADCAST_PERFORMANCE 0xFFFFFFFF /* PMsg is sent on all PChannels of the performance. */ -#define DMUS_PCHANNEL_BROADCAST_AUDIOPATH 0xFFFFFFFE /* PMsg is sent on all PChannels of the audio path. */ -#define DMUS_PCHANNEL_BROADCAST_SEGMENT 0xFFFFFFFD /* PMsg is sent on all PChannels of the segment. */ -#define DMUS_PCHANNEL_BROADCAST_GROUPS 0xFFFFFFFC /* A duplicate PMsg is for each Channels Groups in the performance. */ - -/* The DMUS_PATH constants are used in conjunction with GetObjectInPath to find a requested - interface at a particular stage in the audio path. -*/ -#define DMUS_PATH_SEGMENT 0x1000 /* Get the segment itself (from a segment state.) */ -#define DMUS_PATH_SEGMENT_TRACK 0x1100 /* Look in Track List of Segment. */ -#define DMUS_PATH_SEGMENT_GRAPH 0x1200 /* Get the segment's tool graph. */ -#define DMUS_PATH_SEGMENT_TOOL 0x1300 /* Look in Tool Graph of Segment. */ -#define DMUS_PATH_AUDIOPATH 0x2000 /* Get the audiopath itself (from a segment state.) */ -#define DMUS_PATH_AUDIOPATH_GRAPH 0x2200 /* Get the audiopath's tool graph. */ -#define DMUS_PATH_AUDIOPATH_TOOL 0x2300 /* Look in Tool Graph of Audio Path. */ -#define DMUS_PATH_PERFORMANCE 0x3000 /* Access the performance. */ -#define DMUS_PATH_PERFORMANCE_GRAPH 0x3200 /* Get the performance's tool graph. */ -#define DMUS_PATH_PERFORMANCE_TOOL 0x3300 /* Look in Tool Graph of Performance. */ -#define DMUS_PATH_PORT 0x4000 /* Access the synth. */ -#define DMUS_PATH_BUFFER 0x6000 /* Look in DirectSoundBuffer. */ -#define DMUS_PATH_BUFFER_DMO 0x6100 /* Access a DMO in the buffer. */ -#define DMUS_PATH_MIXIN_BUFFER 0x7000 /* Look in a global mixin buffer. */ -#define DMUS_PATH_MIXIN_BUFFER_DMO 0x7100 /* Access a DMO in a global mixin buffer. */ -#define DMUS_PATH_PRIMARY_BUFFER 0x8000 /* Access the primary buffer. */ - -/* To ignore PChannels when calling GetObjectInPath(), use the DMUS_PCHANNEL_ALL constant. */ -#define DMUS_PCHANNEL_ALL 0xFFFFFFFB - -/* The DMUS_APATH types are used in conjunction with CreateStandardAudioPath to - build default path types. _SHARED_ means the same buffer is shared across multiple - instantiations of the audiopath type. _DYNAMIC_ means a unique buffer is created - every time. -*/ - -#define DMUS_APATH_SHARED_STEREOPLUSREVERB 1 /* A standard music set up with stereo outs and reverb. */ -#define DMUS_APATH_DYNAMIC_3D 6 /* An audio path with one dynamic bus from the synth feeding to a dynamic 3d buffer. Does not send to env reverb. */ -#define DMUS_APATH_DYNAMIC_MONO 7 /* An audio path with one dynamic bus from the synth feeding to a dynamic mono buffer. */ -#define DMUS_APATH_DYNAMIC_STEREO 8 /* An audio path with two dynamic buses from the synth feeding to a dynamic stereo buffer. */ - -typedef struct _DMUS_AUDIOPARAMS -{ - DWORD dwSize; /* Size of this structure. */ - BOOL fInitNow; /* If true, the sink and synth are created immediately and results returned in this structure. */ - DWORD dwValidData; /* Flags indicating which fields below are valid. */ - DWORD dwFeatures; /* Required DMUS_AUDIOF features. */ - DWORD dwVoices; /* Required number of voices. */ - DWORD dwSampleRate; /* Sample rate of synths and sink. */ - CLSID clsidDefaultSynth; /* Class ID of default synthesizer. */ -} DMUS_AUDIOPARAMS; - -/* dwFeatures flags. These indicate which features are required for the audio environment. */ -#define DMUS_AUDIOF_3D 0x1 /* Require 3D buffers. */ -#define DMUS_AUDIOF_ENVIRON 0x2 /* Require environmental modeling. */ -#define DMUS_AUDIOF_EAX 0x4 /* Require use of EAX effects. */ -#define DMUS_AUDIOF_DMOS 0x8 /* Require use of additional DMOs. */ -#define DMUS_AUDIOF_STREAMING 0x10 /* Require support for streaming waves. */ -#define DMUS_AUDIOF_BUFFERS 0x20 /* Require support for multiple buffers (all above cases need this.) */ -#define DMUS_AUDIOF_ALL 0x3F /* Requires everything. */ - -/* dwValidData flags. These indicate which fields in DMUS_AUDIOPARAMS have been filled in. If fInitNow is set, these also return what was allocated. */ -#define DMUS_AUDIOPARAMS_FEATURES 0x00000001 -#define DMUS_AUDIOPARAMS_VOICES 0x00000002 -#define DMUS_AUDIOPARAMS_SAMPLERATE 0x00000004 -#define DMUS_AUDIOPARAMS_DEFAULTSYNTH 0x00000008 - -/* DMUS_PMSGF_FLAGS fill the DMUS_PMSG's dwFlags member */ -typedef enum enumDMUS_PMSGF_FLAGS -{ - DMUS_PMSGF_REFTIME = 1, /* if rtTime is valid */ - DMUS_PMSGF_MUSICTIME = 2, /* if mtTime is valid */ - DMUS_PMSGF_TOOL_IMMEDIATE = 4, /* if PMSG should be processed immediately */ - DMUS_PMSGF_TOOL_QUEUE = 8, /* if PMSG should be processed a little early, at Queue time */ - DMUS_PMSGF_TOOL_ATTIME = 0x10, /* if PMSG should be processed at the time stamp */ - DMUS_PMSGF_TOOL_FLUSH = 0x20, /* if PMSG is being flushed */ - DMUS_PMSGF_LOCKTOREFTIME = 0x40, /* if rtTime can not be overriden by a tempo change. */ - DMUS_PMSGF_DX8 = 0x80 /* if the message has DX8 or later extensions. */ - /* The values of DMUS_TIME_RESOLVE_FLAGS may also be used inside the */ - /* DMUS_PMSG's dwFlags member. */ -} DMUS_PMSGF_FLAGS; - -/* DMUS_PMSGT_TYPES fill the DMUS_PMSG's dwType member */ -typedef enum enumDMUS_PMSGT_TYPES -{ - DMUS_PMSGT_MIDI = 0, /* MIDI short message */ - DMUS_PMSGT_NOTE = 1, /* Interactive Music Note */ - DMUS_PMSGT_SYSEX = 2, /* MIDI long message (system exclusive message) */ - DMUS_PMSGT_NOTIFICATION = 3, /* Notification message */ - DMUS_PMSGT_TEMPO = 4, /* Tempo message */ - DMUS_PMSGT_CURVE = 5, /* Control change / pitch bend, etc. curve */ - DMUS_PMSGT_TIMESIG = 6, /* Time signature */ - DMUS_PMSGT_PATCH = 7, /* Patch changes */ - DMUS_PMSGT_TRANSPOSE = 8, /* Transposition messages */ - DMUS_PMSGT_CHANNEL_PRIORITY = 9, /* Channel priority */ - DMUS_PMSGT_STOP = 10, /* Stop message */ - DMUS_PMSGT_DIRTY = 11, /* Tells Tools that cache GetParam() info to refresh */ - DMUS_PMSGT_WAVE = 12, /* Carries control information for playing a wave. */ - DMUS_PMSGT_LYRIC = 13, /* Lyric message from lyric track. */ - DMUS_PMSGT_SCRIPTLYRIC = 14, /* Lyric message sent by a script with the Trace function. */ - DMUS_PMSGT_USER = 255 /* User message */ -} DMUS_PMSGT_TYPES; - -/* DMUS_SEGF_FLAGS correspond to IDirectMusicPerformance::PlaySegment, and other API */ -typedef enum enumDMUS_SEGF_FLAGS -{ - DMUS_SEGF_REFTIME = 1<<6, /* 0x40 Time parameter is in reference time */ - DMUS_SEGF_SECONDARY = 1<<7, /* 0x80 Secondary segment */ - DMUS_SEGF_QUEUE = 1<<8, /* 0x100 Queue at the end of the primary segment queue (primary only) */ - DMUS_SEGF_CONTROL = 1<<9, /* 0x200 Play as a control track (secondary segments only) */ - DMUS_SEGF_AFTERPREPARETIME = 1<<10, /* 0x400 Play after the prepare time (See IDirectMusicPerformance::GetPrepareTime) */ - DMUS_SEGF_GRID = 1<<11, /* 0x800 Play on grid boundary */ - DMUS_SEGF_BEAT = 1<<12, /* 0x1000 Play on beat boundary */ - DMUS_SEGF_MEASURE = 1<<13, /* 0x2000 Play on measure boundary */ - DMUS_SEGF_DEFAULT = 1<<14, /* 0x4000 Use segment's default boundary */ - DMUS_SEGF_NOINVALIDATE = 1<<15, /* 0x8000 Play without invalidating the currently playing segment(s) */ - DMUS_SEGF_ALIGN = 1<<16, /* 0x10000 Align segment with requested boundary, but switch at first valid point */ - DMUS_SEGF_VALID_START_BEAT = 1<<17, /* 0x20000 In conjunction with DMUS_SEGF_ALIGN, allows the switch to occur on any beat. */ - DMUS_SEGF_VALID_START_GRID = 1<<18, /* 0x40000 In conjunction with DMUS_SEGF_ALIGN, allows the switch to occur on any grid. */ - DMUS_SEGF_VALID_START_TICK = 1<<19, /* 0x80000 In conjunction with DMUS_SEGF_ALIGN, allows the switch to occur any time. */ - DMUS_SEGF_AUTOTRANSITION = 1<<20, /* 0x100000 Compose and play a transition segment, using the transition template. */ - DMUS_SEGF_AFTERQUEUETIME = 1<<21, /* 0x200000 Make sure to play after the queue time. This is default for primary segments */ - DMUS_SEGF_AFTERLATENCYTIME = 1<<22, /* 0x400000 Make sure to play after the latency time. This is true for all segments, so this is a nop */ - DMUS_SEGF_SEGMENTEND = 1<<23, /* 0x800000 Play at the next end of segment. */ - DMUS_SEGF_MARKER = 1<<24, /* 0x1000000 Play at next marker in the primary segment. If there are no markers, default to any other resolution requests. */ - DMUS_SEGF_TIMESIG_ALWAYS = 1<<25, /* 0x2000000 Even if there is no primary segment, align start time with current time signature. */ - DMUS_SEGF_USE_AUDIOPATH = 1<<26, /* 0x4000000 Uses the audio path that is embedded in the segment. */ - DMUS_SEGF_VALID_START_MEASURE = 1<<27, /* 0x8000000 In conjunction with DMUS_SEGF_ALIGN, allows the switch to occur on any bar. */ - DMUS_SEGF_INVALIDATE_PRI = 1<<28 /* 0x10000000 invalidate only the current primary seg state */ -} DMUS_SEGF_FLAGS; - -#define DMUS_SEG_REPEAT_INFINITE 0xFFFFFFFF /* For IDirectMusicSegment::SetRepeat*/ -#define DMUS_SEG_ALLTRACKS 0x80000000 /* For IDirectMusicSegment::SetParam() and SetTrackConfig() - selects all tracks instead on nth index. */ -#define DMUS_SEG_ANYTRACK 0x80000000 /* For IDirectMusicSegment::GetParam() - checks each track until it finds one that returns data (not DMUS_E_NOT_FOUND.) */ - - -/* DMUS_TIME_RESOLVE_FLAGS correspond to IDirectMusicPerformance::GetResolvedTime, and can */ -/* also be used interchangeably with the corresponding DMUS_SEGF_FLAGS, since their values */ -/* are intentionally the same */ -typedef enum enumDMUS_TIME_RESOLVE_FLAGS -{ - DMUS_TIME_RESOLVE_AFTERPREPARETIME = DMUS_SEGF_AFTERPREPARETIME, - DMUS_TIME_RESOLVE_AFTERQUEUETIME = DMUS_SEGF_AFTERQUEUETIME, - DMUS_TIME_RESOLVE_AFTERLATENCYTIME = DMUS_SEGF_AFTERLATENCYTIME, - DMUS_TIME_RESOLVE_GRID = DMUS_SEGF_GRID, - DMUS_TIME_RESOLVE_BEAT = DMUS_SEGF_BEAT, - DMUS_TIME_RESOLVE_MEASURE = DMUS_SEGF_MEASURE, - DMUS_TIME_RESOLVE_MARKER = DMUS_SEGF_MARKER, - DMUS_TIME_RESOLVE_SEGMENTEND = DMUS_SEGF_SEGMENTEND, -} DMUS_TIME_RESOLVE_FLAGS; - -/* The following flags are sent inside the DMUS_CHORD_KEY.dwFlags parameter */ -typedef enum enumDMUS_CHORDKEYF_FLAGS -{ - DMUS_CHORDKEYF_SILENT = 1, /* is the chord silent? */ -} DMUS_CHORDKEYF_FLAGS; - -#define DMUS_MAXSUBCHORD 8 - -typedef struct _DMUS_SUBCHORD -{ - DWORD dwChordPattern; /* Notes in the subchord */ - DWORD dwScalePattern; /* Notes in the scale */ - DWORD dwInversionPoints; /* Where inversions can occur */ - DWORD dwLevels; /* Which levels are supported by this subchord */ - BYTE bChordRoot; /* Root of the subchord */ - BYTE bScaleRoot; /* Root of the scale */ -} DMUS_SUBCHORD; - -typedef struct _DMUS_CHORD_KEY -{ - WCHAR wszName[16]; /* Name of the chord */ - WORD wMeasure; /* Measure this falls on */ - BYTE bBeat; /* Beat this falls on */ - BYTE bSubChordCount; /* Number of chords in the list of subchords */ - DMUS_SUBCHORD SubChordList[DMUS_MAXSUBCHORD]; /* List of sub chords */ - DWORD dwScale; /* Scale underlying the entire chord */ - BYTE bKey; /* Key underlying the entire chord */ - BYTE bFlags; /* Miscelaneous flags */ -} DMUS_CHORD_KEY; - -/* DMUS_NOTE_PMSG */ -typedef struct _DMUS_NOTE_PMSG -{ - /* begin DMUS_PMSG_PART */ - DMUS_PMSG_PART - /* end DMUS_PMSG_PART */ - - MUSIC_TIME mtDuration; /* duration */ - WORD wMusicValue; /* Description of note in chord and key. */ - WORD wMeasure; /* Measure in which this note occurs */ - short nOffset; /* Offset from grid at which this note occurs */ - BYTE bBeat; /* Beat (in measure) at which this note occurs */ - BYTE bGrid; /* Grid offset from beat at which this note occurs */ - BYTE bVelocity; /* Note velocity */ - BYTE bFlags; /* see DMUS_NOTEF_FLAGS */ - BYTE bTimeRange; /* Range to randomize time. */ - BYTE bDurRange; /* Range to randomize duration. */ - BYTE bVelRange; /* Range to randomize velocity. */ - BYTE bPlayModeFlags; /* Play mode */ - BYTE bSubChordLevel; /* Which subchord level this note uses. */ - BYTE bMidiValue; /* The MIDI note value, converted from wMusicValue */ - char cTranspose; /* Transposition to add to midi note value after converted from wMusicValue. */ -} DMUS_NOTE_PMSG; - -typedef enum enumDMUS_NOTEF_FLAGS -{ - DMUS_NOTEF_NOTEON = 1, /* Set if this is a MIDI Note On. Otherwise, it is MIDI Note Off */ - /* DX8 flags: */ - DMUS_NOTEF_NOINVALIDATE = 2, /* Don't invalidate this note off. */ - DMUS_NOTEF_NOINVALIDATE_INSCALE = 4,/* Don't invalidate if still within the scale. */ - DMUS_NOTEF_NOINVALIDATE_INCHORD = 8,/* Don't invalidate if still within the chord. */ - DMUS_NOTEF_REGENERATE = 0x10, /* Regenerate the note on an invalidate. */ -} DMUS_NOTEF_FLAGS; - -/* The DMUS_PLAYMODE_FLAGS are used to determine how to convert wMusicValue - into the appropriate bMidiValue. -*/ - -typedef enum enumDMUS_PLAYMODE_FLAGS -{ - DMUS_PLAYMODE_KEY_ROOT = 1, /* Transpose on top of the key root. */ - DMUS_PLAYMODE_CHORD_ROOT = 2, /* Transpose on top of the chord root. */ - DMUS_PLAYMODE_SCALE_INTERVALS = 4, /* Use scale intervals from scale pattern. */ - DMUS_PLAYMODE_CHORD_INTERVALS = 8, /* Use chord intervals from chord pattern. */ - DMUS_PLAYMODE_NONE = 16, /* No mode. Indicates the parent part's mode should be used. */ -} DMUS_PLAYMODE_FLAGS; - -/* The following are playback modes that can be created by combining the DMUS_PLAYMODE_FLAGS - in various ways: -*/ - -/* Fixed. wMusicValue holds final MIDI note value. This is used for drums, sound effects, and sequenced - notes that should not be transposed by the chord or scale. -*/ -#define DMUS_PLAYMODE_FIXED 0 -/* In fixed to key, the musicvalue is again a fixed MIDI value, but it - is transposed on top of the key root. -*/ -#define DMUS_PLAYMODE_FIXEDTOKEY DMUS_PLAYMODE_KEY_ROOT -/* In fixed to chord, the musicvalue is also a fixed MIDI value, but it - is transposed on top of the chord root. -*/ -#define DMUS_PLAYMODE_FIXEDTOCHORD DMUS_PLAYMODE_CHORD_ROOT -/* In Pedalpoint, the key root is used and the notes only track the intervals in - the scale. The chord root and intervals are completely ignored. This is useful - for melodic lines that play relative to the key root. -*/ -#define DMUS_PLAYMODE_PEDALPOINT (DMUS_PLAYMODE_KEY_ROOT | DMUS_PLAYMODE_SCALE_INTERVALS) -/* In the Melodic mode, the chord root is used but the notes only track the intervals in - the scale. The key root and chord intervals are completely ignored. This is useful - for melodic lines that play relative to the chord root. -*/ -#define DMUS_PLAYMODE_MELODIC (DMUS_PLAYMODE_CHORD_ROOT | DMUS_PLAYMODE_SCALE_INTERVALS) -/* Normal chord mode is the prevalent playback mode. - The notes track the intervals in the chord, which is based on the chord root. - If there is a scale component to the MusicValue, the additional intervals - are pulled from the scale and added. - If the chord does not have an interval to match the chord component of - the MusicValue, the note is silent. -*/ -#define DMUS_PLAYMODE_NORMALCHORD (DMUS_PLAYMODE_CHORD_ROOT | DMUS_PLAYMODE_CHORD_INTERVALS) -/* If it is desirable to play a note that is above the top of the chord, the - always play mode (known as "purpleized" in a former life) finds a position - for the note by using intervals from the scale. Essentially, this mode is - a combination of the Normal and Melodic playback modes, where a failure - in Normal causes a second try in Melodic mode. -*/ -#define DMUS_PLAYMODE_ALWAYSPLAY (DMUS_PLAYMODE_MELODIC | DMUS_PLAYMODE_NORMALCHORD) - -/* These playmodes are new for dx8. */ -/* In PedalpointChord, the key root is used and the notes only track the intervals in - the chord. The chord root and scale intervals are completely ignored. This is useful - for chordal lines that play relative to the key root. -*/ -#define DMUS_PLAYMODE_PEDALPOINTCHORD (DMUS_PLAYMODE_KEY_ROOT | DMUS_PLAYMODE_CHORD_INTERVALS) - -/* For completeness, here's a mode that tries for pedalpointchord, but if it fails - uses scale intervals -*/ -#define DMUS_PLAYMODE_PEDALPOINTALWAYS (DMUS_PLAYMODE_PEDALPOINT | DMUS_PLAYMODE_PEDALPOINTCHORD) - - -/* Legacy names for modes... */ -#define DMUS_PLAYMODE_PURPLEIZED DMUS_PLAYMODE_ALWAYSPLAY -#define DMUS_PLAYMODE_SCALE_ROOT DMUS_PLAYMODE_KEY_ROOT -#define DMUS_PLAYMODE_FIXEDTOSCALE DMUS_PLAYMODE_FIXEDTOKEY - - -/* DMUS_MIDI_PMSG */ -typedef struct _DMUS_MIDI_PMSG -{ - /* begin DMUS_PMSG_PART */ - DMUS_PMSG_PART - /* end DMUS_PMSG_PART */ - - BYTE bStatus; - BYTE bByte1; - BYTE bByte2; - BYTE bPad[1]; -} DMUS_MIDI_PMSG; - -/* DMUS_PATCH_PMSG */ -typedef struct _DMUS_PATCH_PMSG -{ - /* begin DMUS_PMSG_PART */ - DMUS_PMSG_PART - /* end DMUS_PMSG_PART */ - - BYTE byInstrument; - BYTE byMSB; - BYTE byLSB; - BYTE byPad[1]; -} DMUS_PATCH_PMSG; - -/* DMUS_TRANSPOSE_PMSG */ -typedef struct _DMUS_TRANSPOSE_PMSG -{ - /* begin DMUS_PMSG_PART */ - DMUS_PMSG_PART - /* end DMUS_PMSG_PART */ - - short nTranspose; - /* Following exists only under DX8 and on (check dwFlags for DMUS_PMSGF_DX8) */ - WORD wMergeIndex; /* Allows multiple parameters to be merged (pitchbend, volume, and expression.)*/ -} DMUS_TRANSPOSE_PMSG; - -/* DMUS_CHANNEL_PRIORITY_PMSG */ -typedef struct _DMUS_CHANNEL_PRIORITY_PMSG -{ - /* begin DMUS_PMSG_PART */ - DMUS_PMSG_PART - /* end DMUS_PMSG_PART */ - - DWORD dwChannelPriority; -} DMUS_CHANNEL_PRIORITY_PMSG; - -/* DMUS_TEMPO_PMSG */ -typedef struct _DMUS_TEMPO_PMSG -{ - /* begin DMUS_PMSG_PART */ - DMUS_PMSG_PART - /* end DMUS_PMSG_PART */ - - double dblTempo; /* the tempo */ -} DMUS_TEMPO_PMSG; - -#define DMUS_TEMPO_MAX 1000 -#define DMUS_TEMPO_MIN 1 - -#define DMUS_MASTERTEMPO_MAX 100.0f -#define DMUS_MASTERTEMPO_MIN 0.01f - -/* DMUS_SYSEX_PMSG */ -typedef struct _DMUS_SYSEX_PMSG -{ - /* begin DMUS_PMSG_PART */ - DMUS_PMSG_PART - /* end DMUS_PMSG_PART */ - - DWORD dwLen; /* length of the data */ - BYTE abData[1]; /* array of data, length equal to dwLen */ -} DMUS_SYSEX_PMSG; - -/* DMUS_CURVE_PMSG */ -typedef struct _DMUS_CURVE_PMSG -{ - /* begin DMUS_PMSG_PART */ - DMUS_PMSG_PART - /* end DMUS_PMSG_PART */ - - MUSIC_TIME mtDuration; /* how long this curve lasts */ - MUSIC_TIME mtOriginalStart; /* must be set to either zero when this PMSG is created or to the original mtTime of the curve */ - MUSIC_TIME mtResetDuration; /* how long after the curve is finished to allow a flush or - invalidation to reset to the reset value, nResetValue */ - short nStartValue; /* curve's start value */ - short nEndValue; /* curve's end value */ - short nResetValue; /* curve's reset value, set when a flush or invalidation - occurs within mtDuration + mtResetDuration */ - WORD wMeasure; /* Measure in which this curve occurs */ - short nOffset; /* Offset from grid at which this curve occurs */ - BYTE bBeat; /* Beat (in measure) at which this curve occurs */ - BYTE bGrid; /* Grid offset from beat at which this curve occurs */ - BYTE bType; /* type of curve */ - BYTE bCurveShape; /* shape of curve */ - BYTE bCCData; /* CC# if this is a control change type */ - BYTE bFlags; /* Curve reset and start from current value flags. */ - /* Following exists only under DX8 and on (check dwFlags for DMUS_PMSGF_DX8) */ - WORD wParamType; /* RPN or NRPN parameter number. */ - WORD wMergeIndex; /* Allows multiple parameters to be merged (pitchbend, volume, and expression.)*/ -} DMUS_CURVE_PMSG; - -typedef enum enumDMUS_CURVE_FLAGS -{ - DMUS_CURVE_RESET = 1, /* When set, the nResetValue must be sent when the - time is reached or an invalidate occurs because - of a transition. If not set, the curve stays - permanently stuck at the new value. */ - DMUS_CURVE_START_FROM_CURRENT = 2/* Ignore Start, start the curve at the current value. - This only works for volume, expression, and pitchbend. */ -} DMUS_CURVE_FLAGS; - - -#define DMUS_CURVE_RESET 1 - -/* Curve shapes */ -enum -{ - DMUS_CURVES_LINEAR = 0, - DMUS_CURVES_INSTANT = 1, - DMUS_CURVES_EXP = 2, - DMUS_CURVES_LOG = 3, - DMUS_CURVES_SINE = 4 -}; -/* curve types */ -#define DMUS_CURVET_PBCURVE 0x03 /* Pitch bend curve. */ -#define DMUS_CURVET_CCCURVE 0x04 /* Control change curve. */ -#define DMUS_CURVET_MATCURVE 0x05 /* Mono aftertouch curve. */ -#define DMUS_CURVET_PATCURVE 0x06 /* Poly aftertouch curve. */ -#define DMUS_CURVET_RPNCURVE 0x07 /* RPN curve with curve type in wParamType. */ -#define DMUS_CURVET_NRPNCURVE 0x08 /* NRPN curve with curve type in wParamType. */ - -/* DMUS_TIMESIG_PMSG */ -typedef struct _DMUS_TIMESIG_PMSG -{ - /* begin DMUS_PMSG_PART */ - DMUS_PMSG_PART - /* end DMUS_PMSG_PART */ - - /* Time signatures define how many beats per measure, which note receives */ - /* the beat, and the grid resolution. */ - BYTE bBeatsPerMeasure; /* beats per measure (top of time sig) */ - BYTE bBeat; /* what note receives the beat (bottom of time sig.) */ - /* we can assume that 0 means 256th note */ - WORD wGridsPerBeat; /* grids per beat */ -} DMUS_TIMESIG_PMSG; - - - -/* notification type values */ -/* The following correspond to GUID_NOTIFICATION_SEGMENT */ -#define DMUS_NOTIFICATION_SEGSTART 0 -#define DMUS_NOTIFICATION_SEGEND 1 -#define DMUS_NOTIFICATION_SEGALMOSTEND 2 -#define DMUS_NOTIFICATION_SEGLOOP 3 -#define DMUS_NOTIFICATION_SEGABORT 4 -/* The following correspond to GUID_NOTIFICATION_PERFORMANCE */ -#define DMUS_NOTIFICATION_MUSICSTARTED 0 -#define DMUS_NOTIFICATION_MUSICSTOPPED 1 -#define DMUS_NOTIFICATION_MUSICALMOSTEND 2 -/* The following corresponds to GUID_NOTIFICATION_MEASUREANDBEAT */ -#define DMUS_NOTIFICATION_MEASUREBEAT 0 -/* The following corresponds to GUID_NOTIFICATION_CHORD */ -#define DMUS_NOTIFICATION_CHORD 0 -/* The following correspond to GUID_NOTIFICATION_COMMAND */ -#define DMUS_NOTIFICATION_GROOVE 0 -#define DMUS_NOTIFICATION_EMBELLISHMENT 1 -/* The following corresponds to GUID_NOTIFICATION_RECOMPOSE */ -#define DMUS_NOTIFICATION_RECOMPOSE 0 - -/* DMUS_NOTIFICATION_PMSG */ -typedef struct _DMUS_NOTIFICATION_PMSG -{ - /* begin DMUS_PMSG_PART */ - DMUS_PMSG_PART - /* end DMUS_PMSG_PART */ - - GUID guidNotificationType; - DWORD dwNotificationOption; - DWORD dwField1; - DWORD dwField2; -} DMUS_NOTIFICATION_PMSG; - -/* DMUS_WAVE_PMSG */ -typedef struct _DMUS_WAVE_PMSG -{ - /* begin DMUS_PMSG_PART */ - DMUS_PMSG_PART - /* end DMUS_PMSG_PART */ - - REFERENCE_TIME rtStartOffset; /* How far into the wave to start, in reference time units only. */ - REFERENCE_TIME rtDuration; /* Duration of the wave, in either reference time or music time. */ - long lOffset; /* Offset from actual time to logical time, in music or ref time. */ - long lVolume; /* Initial volume, in 100ths of a dB. */ - long lPitch; /* Initial pitch, in 100ths of a semitone. */ - BYTE bFlags; /* Flags, including DMUS_WAVEF_OFF... */ -} DMUS_WAVE_PMSG; - -#define DMUS_WAVEF_OFF 1 /* If wave is playing and this is the off message. */ -#define DMUS_WAVEF_STREAMING 2 /* If wave is streaming. */ -#define DMUS_WAVEF_NOINVALIDATE 4 /* Don't invalidate this wave. */ -#define DMUS_WAVEF_NOPREROLL 8 /* Don't preroll any wave data. */ -#define DMUS_WAVEF_IGNORELOOPS 0x20 /* Ignore segment looping. */ - -/* DMUS_LYRIC_PMSG */ -typedef struct _DMUS_LYRIC_PMSG -{ - /* begin DMUS_PMSG_PART */ - DMUS_PMSG_PART - /* end DMUS_PMSG_PART */ - - WCHAR wszString[1]; /* null-terminated Unicode lyric string (structure is actually larger than size 1) */ -} DMUS_LYRIC_PMSG; - -#define DMUS_MAX_NAME 64 /* Maximum object name length. */ -#define DMUS_MAX_CATEGORY 64 /* Maximum object category name length. */ -#define DMUS_MAX_FILENAME MAX_PATH - -typedef struct _DMUS_VERSION { - DWORD dwVersionMS; - DWORD dwVersionLS; -}DMUS_VERSION, FAR *LPDMUS_VERSION; - -/* Time Signature structure, used by IDirectMusicStyle */ -/* Also used as a parameter for GetParam() and SetParam */ -typedef struct _DMUS_TIMESIGNATURE -{ - MUSIC_TIME mtTime; - BYTE bBeatsPerMeasure; /* beats per measure (top of time sig) */ - BYTE bBeat; /* what note receives the beat (bottom of time sig.) */ - /* we can assume that 0 means 256th note */ - WORD wGridsPerBeat; /* grids per beat */ -} DMUS_TIMESIGNATURE; - -typedef struct _DMUS_VALID_START_PARAM -{ - MUSIC_TIME mtTime; /* Time of the first legal start - point after (or including) the requested time. - This is a returned value. - Time format is the relative offset from requested time. */ -} DMUS_VALID_START_PARAM; - -typedef struct _DMUS_PLAY_MARKER_PARAM -{ - MUSIC_TIME mtTime; /* Time of the first legal segment play - marker before (or including) the requested time. - This is a returned value. - Time format is the relative offset from requested time. */ -} DMUS_PLAY_MARKER_PARAM; - -/* The DMUSOBJECTDESC structure is used to communicate everything you could */ -/* possibly use to describe a DirectMusic object. */ - -typedef struct _DMUS_OBJECTDESC -{ - DWORD dwSize; /* Size of this structure. */ - DWORD dwValidData; /* Flags indicating which fields below are valid. */ - GUID guidObject; /* Unique ID for this object. */ - GUID guidClass; /* GUID for the class of object. */ - FILETIME ftDate; /* Last edited date of object. */ - DMUS_VERSION vVersion; /* Version. */ - WCHAR wszName[DMUS_MAX_NAME]; /* Name of object. */ - WCHAR wszCategory[DMUS_MAX_CATEGORY]; /* Category for object (optional). */ - WCHAR wszFileName[DMUS_MAX_FILENAME]; /* File path. */ - LONGLONG llMemLength; /* Size of Memory data. */ - LPBYTE pbMemData; /* Memory pointer for data. */ - IStream * pStream; /* Stream with data. */ -} DMUS_OBJECTDESC; - -typedef DMUS_OBJECTDESC *LPDMUS_OBJECTDESC; - -/* Flags for dwValidData. When set, a flag indicates that the */ -/* corresponding field in DMUSOBJECTDESC holds valid data. */ - -#define DMUS_OBJ_OBJECT (1 << 0) /* Object GUID is valid. */ -#define DMUS_OBJ_CLASS (1 << 1) /* Class GUID is valid. */ -#define DMUS_OBJ_NAME (1 << 2) /* Name is valid. */ -#define DMUS_OBJ_CATEGORY (1 << 3) /* Category is valid. */ -#define DMUS_OBJ_FILENAME (1 << 4) /* File path is valid. */ -#define DMUS_OBJ_FULLPATH (1 << 5) /* Path is full path. */ -#define DMUS_OBJ_URL (1 << 6) /* Path is URL. */ -#define DMUS_OBJ_VERSION (1 << 7) /* Version is valid. */ -#define DMUS_OBJ_DATE (1 << 8) /* Date is valid. */ -#define DMUS_OBJ_LOADED (1 << 9) /* Object is currently loaded in memory. */ -#define DMUS_OBJ_MEMORY (1 << 10) /* Object is pointed to by pbMemData. */ -#define DMUS_OBJ_STREAM (1 << 11) /* Object is stored in pStream. */ - -/* The DMUS_SCRIPT_ERRORINFO structure describes an error that occurred in a script. - It is returned by methods in IDirectMusicScript. */ -typedef struct _DMUS_SCRIPT_ERRORINFO -{ - DWORD dwSize; /* Size of this structure. */ - HRESULT hr; - ULONG ulLineNumber; - LONG ichCharPosition; - WCHAR wszSourceFile[DMUS_MAX_FILENAME]; - WCHAR wszSourceComponent[DMUS_MAX_FILENAME]; - WCHAR wszDescription[DMUS_MAX_FILENAME]; - WCHAR wszSourceLineText[DMUS_MAX_FILENAME]; -} DMUS_SCRIPT_ERRORINFO; - -/* Track configuration flags, used with IDirectMusicSegment8::SetTrackConfig() */ - -#define DMUS_TRACKCONFIG_OVERRIDE_ALL 1 /* This track should get parameters from this segment before controlling and primary tracks. */ -#define DMUS_TRACKCONFIG_OVERRIDE_PRIMARY 2 /* This track should get parameters from this segment before the primary segment tracks. */ -#define DMUS_TRACKCONFIG_FALLBACK 4 /* This track should get parameters from this segment if the primary and controlling segments don't succeed. */ -#define DMUS_TRACKCONFIG_CONTROL_ENABLED 8 /* GetParam() enabled for this track. */ -#define DMUS_TRACKCONFIG_PLAY_ENABLED 0x10 /* Play() enabled for this track. */ -#define DMUS_TRACKCONFIG_NOTIFICATION_ENABLED 0x20 /* Notifications enabled for this track. */ -#define DMUS_TRACKCONFIG_PLAY_CLOCKTIME 0x40 /* This track plays in clock time, not music time. */ -#define DMUS_TRACKCONFIG_PLAY_COMPOSE 0x80 /* This track should regenerate data each time it starts playing. */ -#define DMUS_TRACKCONFIG_LOOP_COMPOSE 0x100 /* This track should regenerate data each time it repeats. */ -#define DMUS_TRACKCONFIG_COMPOSING 0x200 /* This track is used to compose other tracks. */ -#define DMUS_TRACKCONFIG_CONTROL_PLAY 0x10000 /* This track, when played in a controlling segment, overrides playback of primary segment tracks. */ -#define DMUS_TRACKCONFIG_CONTROL_NOTIFICATION 0x20000 /* This track, when played in a controlling segment, overrides notification of primary segment tracks. */ -/* Additional track config flags for composing transitions */ -#define DMUS_TRACKCONFIG_TRANS1_FROMSEGSTART 0x400 /* Get track info from start of From segment */ -#define DMUS_TRACKCONFIG_TRANS1_FROMSEGCURRENT 0x800 /* Get track info from current place in From segment */ -#define DMUS_TRACKCONFIG_TRANS1_TOSEGSTART 0x1000 /* Get track info from start of To segment */ -#define DMUS_TRACKCONFIG_DEFAULT (DMUS_TRACKCONFIG_CONTROL_ENABLED | DMUS_TRACKCONFIG_PLAY_ENABLED | DMUS_TRACKCONFIG_NOTIFICATION_ENABLED) - -/* Get/SetParam structs for commands */ -/* PARAM structures, used by GetParam() and SetParam() */ -typedef struct _DMUS_COMMAND_PARAM -{ - BYTE bCommand; - BYTE bGrooveLevel; - BYTE bGrooveRange; - BYTE bRepeatMode; -} DMUS_COMMAND_PARAM; - -typedef struct _DMUS_COMMAND_PARAM_2 -{ - MUSIC_TIME mtTime; - BYTE bCommand; - BYTE bGrooveLevel; - BYTE bGrooveRange; - BYTE bRepeatMode; -} DMUS_COMMAND_PARAM_2; - -typedef IDirectMusicObject __RPC_FAR *LPDMUS_OBJECT; -typedef IDirectMusicLoader __RPC_FAR *LPDMUS_LOADER; -typedef IDirectMusicBand __RPC_FAR *LPDMUS_BAND; - -#define DMUSB_LOADED (1 << 0) /* Set when band has been loaded */ -#define DMUSB_DEFAULT (1 << 1) /* Set when band is default band for a style */ - -/*//////////////////////////////////////////////////////////////////// -// IDirectMusicBand */ -#undef INTERFACE -#define INTERFACE IDirectMusicBand -DECLARE_INTERFACE_(IDirectMusicBand, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicBand */ - STDMETHOD(CreateSegment) (THIS_ IDirectMusicSegment** ppSegment) PURE; - STDMETHOD(Download) (THIS_ IDirectMusicPerformance* pPerformance) PURE; - STDMETHOD(Unload) (THIS_ IDirectMusicPerformance* pPerformance) PURE; -}; - -typedef IDirectMusicBand IDirectMusicBand8; - -/*//////////////////////////////////////////////////////////////////// -// IDirectMusicObject */ -#undef INTERFACE -#define INTERFACE IDirectMusicObject -DECLARE_INTERFACE_(IDirectMusicObject, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicObject */ - STDMETHOD(GetDescriptor) (THIS_ LPDMUS_OBJECTDESC pDesc) PURE; - STDMETHOD(SetDescriptor) (THIS_ LPDMUS_OBJECTDESC pDesc) PURE; - STDMETHOD(ParseDescriptor) (THIS_ LPSTREAM pStream, - LPDMUS_OBJECTDESC pDesc) PURE; -}; - -typedef IDirectMusicObject IDirectMusicObject8; - -/*//////////////////////////////////////////////////////////////////// -// IDirectMusicLoader */ -#undef INTERFACE -#define INTERFACE IDirectMusicLoader -DECLARE_INTERFACE_(IDirectMusicLoader, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicLoader */ - STDMETHOD(GetObject) (THIS_ LPDMUS_OBJECTDESC pDesc, - REFIID riid, - LPVOID FAR *ppv) PURE; - STDMETHOD(SetObject) (THIS_ LPDMUS_OBJECTDESC pDesc) PURE; - STDMETHOD(SetSearchDirectory) (THIS_ REFGUID rguidClass, - WCHAR *pwzPath, - BOOL fClear) PURE; - STDMETHOD(ScanDirectory) (THIS_ REFGUID rguidClass, - WCHAR *pwzFileExtension, - WCHAR *pwzScanFileName) PURE; - STDMETHOD(CacheObject) (THIS_ IDirectMusicObject * pObject) PURE; - STDMETHOD(ReleaseObject) (THIS_ IDirectMusicObject * pObject) PURE; - STDMETHOD(ClearCache) (THIS_ REFGUID rguidClass) PURE; - STDMETHOD(EnableCache) (THIS_ REFGUID rguidClass, - BOOL fEnable) PURE; - STDMETHOD(EnumObject) (THIS_ REFGUID rguidClass, - DWORD dwIndex, - LPDMUS_OBJECTDESC pDesc) PURE; -}; - -/*//////////////////////////////////////////////////////////////////// -// IDirectMusicLoader8 */ -#undef INTERFACE -#define INTERFACE IDirectMusicLoader8 -DECLARE_INTERFACE_(IDirectMusicLoader8, IDirectMusicLoader) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicLoader */ - STDMETHOD(GetObject) (THIS_ LPDMUS_OBJECTDESC pDesc, - REFIID riid, - LPVOID FAR *ppv) PURE; - STDMETHOD(SetObject) (THIS_ LPDMUS_OBJECTDESC pDesc) PURE; - STDMETHOD(SetSearchDirectory) (THIS_ REFGUID rguidClass, - WCHAR *pwzPath, - BOOL fClear) PURE; - STDMETHOD(ScanDirectory) (THIS_ REFGUID rguidClass, - WCHAR *pwzFileExtension, - WCHAR *pwzScanFileName) PURE; - STDMETHOD(CacheObject) (THIS_ IDirectMusicObject * pObject) PURE; - STDMETHOD(ReleaseObject) (THIS_ IDirectMusicObject * pObject) PURE; - STDMETHOD(ClearCache) (THIS_ REFGUID rguidClass) PURE; - STDMETHOD(EnableCache) (THIS_ REFGUID rguidClass, - BOOL fEnable) PURE; - STDMETHOD(EnumObject) (THIS_ REFGUID rguidClass, - DWORD dwIndex, - LPDMUS_OBJECTDESC pDesc) PURE; - - /* IDirectMusicLoader8 */ - STDMETHOD_(void, CollectGarbage) (THIS) PURE; - STDMETHOD(ReleaseObjectByUnknown) (THIS_ IUnknown *pObject) PURE; - STDMETHOD(LoadObjectFromFile) (THIS_ REFGUID rguidClassID, - REFIID iidInterfaceID, - WCHAR *pwzFilePath, - void ** ppObject) PURE; -}; - -/* Stream object supports IDirectMusicGetLoader interface to access loader while file parsing. */ - -#undef INTERFACE -#define INTERFACE IDirectMusicGetLoader -DECLARE_INTERFACE_(IDirectMusicGetLoader, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicGetLoader */ - STDMETHOD(GetLoader) (THIS_ IDirectMusicLoader ** ppLoader) PURE; -}; - -typedef IDirectMusicGetLoader IDirectMusicGetLoader8; - -/*//////////////////////////////////////////////////////////////////// -// IDirectMusicSegment */ -#undef INTERFACE -#define INTERFACE IDirectMusicSegment -DECLARE_INTERFACE_(IDirectMusicSegment, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicSegment */ - STDMETHOD(GetLength) (THIS_ MUSIC_TIME* pmtLength) PURE; - STDMETHOD(SetLength) (THIS_ MUSIC_TIME mtLength) PURE; - STDMETHOD(GetRepeats) (THIS_ DWORD* pdwRepeats) PURE; - STDMETHOD(SetRepeats) (THIS_ DWORD dwRepeats) PURE; - STDMETHOD(GetDefaultResolution) (THIS_ DWORD* pdwResolution) PURE; - STDMETHOD(SetDefaultResolution) (THIS_ DWORD dwResolution) PURE; - STDMETHOD(GetTrack) (THIS_ REFGUID rguidType, - DWORD dwGroupBits, - DWORD dwIndex, - IDirectMusicTrack** ppTrack) PURE; - STDMETHOD(GetTrackGroup) (THIS_ IDirectMusicTrack* pTrack, - DWORD* pdwGroupBits) PURE; - STDMETHOD(InsertTrack) (THIS_ IDirectMusicTrack* pTrack, - DWORD dwGroupBits) PURE; - STDMETHOD(RemoveTrack) (THIS_ IDirectMusicTrack* pTrack) PURE; - STDMETHOD(InitPlay) (THIS_ IDirectMusicSegmentState** ppSegState, - IDirectMusicPerformance* pPerformance, - DWORD dwFlags) PURE; - STDMETHOD(GetGraph) (THIS_ IDirectMusicGraph** ppGraph) PURE; - STDMETHOD(SetGraph) (THIS_ IDirectMusicGraph* pGraph) PURE; - STDMETHOD(AddNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; - STDMETHOD(RemoveNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; - STDMETHOD(GetParam) (THIS_ REFGUID rguidType, - DWORD dwGroupBits, - DWORD dwIndex, - MUSIC_TIME mtTime, - MUSIC_TIME* pmtNext, - void* pParam) PURE; - STDMETHOD(SetParam) (THIS_ REFGUID rguidType, - DWORD dwGroupBits, - DWORD dwIndex, - MUSIC_TIME mtTime, - void* pParam) PURE; - STDMETHOD(Clone) (THIS_ MUSIC_TIME mtStart, - MUSIC_TIME mtEnd, - IDirectMusicSegment** ppSegment) PURE; - STDMETHOD(SetStartPoint) (THIS_ MUSIC_TIME mtStart) PURE; - STDMETHOD(GetStartPoint) (THIS_ MUSIC_TIME* pmtStart) PURE; - STDMETHOD(SetLoopPoints) (THIS_ MUSIC_TIME mtStart, - MUSIC_TIME mtEnd) PURE; - STDMETHOD(GetLoopPoints) (THIS_ MUSIC_TIME* pmtStart, - MUSIC_TIME* pmtEnd) PURE; - STDMETHOD(SetPChannelsUsed) (THIS_ DWORD dwNumPChannels, - DWORD* paPChannels) PURE; -}; - -/*//////////////////////////////////////////////////////////////////// -// IDirectMusicSegment8 */ -#undef INTERFACE -#define INTERFACE IDirectMusicSegment8 -DECLARE_INTERFACE_(IDirectMusicSegment8, IDirectMusicSegment) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicSegment */ - STDMETHOD(GetLength) (THIS_ MUSIC_TIME* pmtLength) PURE; - STDMETHOD(SetLength) (THIS_ MUSIC_TIME mtLength) PURE; - STDMETHOD(GetRepeats) (THIS_ DWORD* pdwRepeats) PURE; - STDMETHOD(SetRepeats) (THIS_ DWORD dwRepeats) PURE; - STDMETHOD(GetDefaultResolution) (THIS_ DWORD* pdwResolution) PURE; - STDMETHOD(SetDefaultResolution) (THIS_ DWORD dwResolution) PURE; - STDMETHOD(GetTrack) (THIS_ REFGUID rguidType, - DWORD dwGroupBits, - DWORD dwIndex, - IDirectMusicTrack** ppTrack) PURE; - STDMETHOD(GetTrackGroup) (THIS_ IDirectMusicTrack* pTrack, - DWORD* pdwGroupBits) PURE; - STDMETHOD(InsertTrack) (THIS_ IDirectMusicTrack* pTrack, - DWORD dwGroupBits) PURE; - STDMETHOD(RemoveTrack) (THIS_ IDirectMusicTrack* pTrack) PURE; - STDMETHOD(InitPlay) (THIS_ IDirectMusicSegmentState** ppSegState, - IDirectMusicPerformance* pPerformance, - DWORD dwFlags) PURE; - STDMETHOD(GetGraph) (THIS_ IDirectMusicGraph** ppGraph) PURE; - STDMETHOD(SetGraph) (THIS_ IDirectMusicGraph* pGraph) PURE; - STDMETHOD(AddNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; - STDMETHOD(RemoveNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; - STDMETHOD(GetParam) (THIS_ REFGUID rguidType, - DWORD dwGroupBits, - DWORD dwIndex, - MUSIC_TIME mtTime, - MUSIC_TIME* pmtNext, - void* pParam) PURE; - STDMETHOD(SetParam) (THIS_ REFGUID rguidType, - DWORD dwGroupBits, - DWORD dwIndex, - MUSIC_TIME mtTime, - void* pParam) PURE; - STDMETHOD(Clone) (THIS_ MUSIC_TIME mtStart, - MUSIC_TIME mtEnd, - IDirectMusicSegment** ppSegment) PURE; - STDMETHOD(SetStartPoint) (THIS_ MUSIC_TIME mtStart) PURE; - STDMETHOD(GetStartPoint) (THIS_ MUSIC_TIME* pmtStart) PURE; - STDMETHOD(SetLoopPoints) (THIS_ MUSIC_TIME mtStart, - MUSIC_TIME mtEnd) PURE; - STDMETHOD(GetLoopPoints) (THIS_ MUSIC_TIME* pmtStart, - MUSIC_TIME* pmtEnd) PURE; - STDMETHOD(SetPChannelsUsed) (THIS_ DWORD dwNumPChannels, - DWORD* paPChannels) PURE; - /* IDirectMusicSegment8 */ - STDMETHOD(SetTrackConfig) (THIS_ REFGUID rguidTrackClassID, /* Class ID of the type of track on which to set the configuration flags. */ - DWORD dwGroupBits, /* Group bits. */ - DWORD dwIndex, /* Nth track (or DMUS_SEG_ALLTRACKS) that matches class id and group id. */ - DWORD dwFlagsOn, /* DMUS_TRACKCONFIG_ flags to enable. */ - DWORD dwFlagsOff) PURE; /* DMUS_TRACKCONFIG_ flags to disable. */ - STDMETHOD(GetAudioPathConfig) (THIS_ IUnknown ** ppAudioPathConfig) PURE; - STDMETHOD(Compose) (THIS_ MUSIC_TIME mtTime, - IDirectMusicSegment* pFromSegment, - IDirectMusicSegment* pToSegment, - IDirectMusicSegment** ppComposedSegment) PURE; - STDMETHOD(Download) (THIS_ IUnknown *pAudioPath) PURE; - STDMETHOD(Unload) (THIS_ IUnknown *pAudioPath) PURE; -}; - -/*///////////////////////////////////////////////////////////////////// -// IDirectMusicSegmentState */ -#undef INTERFACE -#define INTERFACE IDirectMusicSegmentState -DECLARE_INTERFACE_(IDirectMusicSegmentState, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicSegmentState */ - STDMETHOD(GetRepeats) (THIS_ DWORD* pdwRepeats) PURE; - STDMETHOD(GetSegment ) (THIS_ IDirectMusicSegment** ppSegment) PURE; - STDMETHOD(GetStartTime) (THIS_ MUSIC_TIME* pmtStart) PURE; - STDMETHOD(GetSeek) (THIS_ MUSIC_TIME* pmtSeek) PURE; - STDMETHOD(GetStartPoint) (THIS_ MUSIC_TIME* pmtStart) PURE; -}; - -/*///////////////////////////////////////////////////////////////////// -// IDirectMusicSegmentState8 */ -#undef INTERFACE -#define INTERFACE IDirectMusicSegmentState8 -DECLARE_INTERFACE_(IDirectMusicSegmentState8, IDirectMusicSegmentState) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicSegmentState */ - STDMETHOD(GetRepeats) (THIS_ DWORD* pdwRepeats) PURE; - STDMETHOD(GetSegment ) (THIS_ IDirectMusicSegment** ppSegment) PURE; - STDMETHOD(GetStartTime) (THIS_ MUSIC_TIME* pmtStart) PURE; - STDMETHOD(GetSeek) (THIS_ MUSIC_TIME* pmtSeek) PURE; - STDMETHOD(GetStartPoint) (THIS_ MUSIC_TIME* pmtStart) PURE; - - /* IDirectMusicSegmentState8 */ - STDMETHOD(SetTrackConfig) (THIS_ REFGUID rguidTrackClassID, /* Class ID of the type of track on which to set the configuration flags. */ - DWORD dwGroupBits, /* Group bits. */ - DWORD dwIndex, /* Nth track (or DMUS_SEG_ALLTRACKS) that matches class id and group id. */ - DWORD dwFlagsOn, /* DMUS_TRACKCONFIG_ flags to enable. */ - DWORD dwFlagsOff) PURE; /* DMUS_TRACKCONFIG_ flags to disable. */ - STDMETHOD(GetObjectInPath) (THIS_ DWORD dwPChannel, /* PChannel to search. */ - DWORD dwStage, /* Which stage in the path. */ - DWORD dwBuffer, /* Which buffer to address, if more than one. */ - REFGUID guidObject, /* ClassID of object. */ - DWORD dwIndex, /* Which object of that class. */ - REFGUID iidInterface,/* Requested COM interface. */ - void ** ppObject) PURE; /* Pointer to interface. */ -}; - -/*//////////////////////////////////////////////////////////////////// -// IDirectMusicAudioPath */ -#undef INTERFACE -#define INTERFACE IDirectMusicAudioPath -DECLARE_INTERFACE_(IDirectMusicAudioPath, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicAudioPath */ - STDMETHOD(GetObjectInPath) (THIS_ DWORD dwPChannel, /* PChannel to search. */ - DWORD dwStage, /* Which stage in the path. */ - DWORD dwBuffer, /* Which buffer to address, if more than one. */ - REFGUID guidObject, /* ClassID of object. */ - DWORD dwIndex, /* Which object of that class. */ - REFGUID iidInterface,/* Requested COM interface. */ - void ** ppObject) PURE; /* Pointer to interface. */ - STDMETHOD(Activate) (THIS_ BOOL fActivate) PURE;/* True to activate, False to deactivate. */ - STDMETHOD(SetVolume) (THIS_ long lVolume, /* Gain, in 100ths of a dB. This must be negative (0 represents full volume.) */ - DWORD dwDuration) PURE;/* Duration of volume ramp in milliseconds. Note that 0 is more efficient. */ - STDMETHOD(ConvertPChannel) (THIS_ DWORD dwPChannelIn, /* Pchannel of source. */ - DWORD *pdwPChannelOut) PURE; /* Equivalent pchannel on performance. */ -}; - -typedef IDirectMusicAudioPath IDirectMusicAudioPath8; - -/*//////////////////////////////////////////////////////////////////// -// IDirectMusicPerformance */ -#undef INTERFACE -#define INTERFACE IDirectMusicPerformance -DECLARE_INTERFACE_(IDirectMusicPerformance, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicPerformance */ - STDMETHOD(Init) (THIS_ IDirectMusic** ppDirectMusic, - LPDIRECTSOUND pDirectSound, - HWND hWnd) PURE; - STDMETHOD(PlaySegment) (THIS_ IDirectMusicSegment* pSegment, - DWORD dwFlags, - __int64 i64StartTime, - IDirectMusicSegmentState** ppSegmentState) PURE; - STDMETHOD(Stop) (THIS_ IDirectMusicSegment* pSegment, - IDirectMusicSegmentState* pSegmentState, - MUSIC_TIME mtTime, - DWORD dwFlags) PURE; - STDMETHOD(GetSegmentState) (THIS_ IDirectMusicSegmentState** ppSegmentState, - MUSIC_TIME mtTime) PURE; - STDMETHOD(SetPrepareTime) (THIS_ DWORD dwMilliSeconds) PURE; - STDMETHOD(GetPrepareTime) (THIS_ DWORD* pdwMilliSeconds) PURE; - STDMETHOD(SetBumperLength) (THIS_ DWORD dwMilliSeconds) PURE; - STDMETHOD(GetBumperLength) (THIS_ DWORD* pdwMilliSeconds) PURE; - STDMETHOD(SendPMsg) (THIS_ DMUS_PMSG* pPMSG) PURE; - STDMETHOD(MusicToReferenceTime) (THIS_ MUSIC_TIME mtTime, - REFERENCE_TIME* prtTime) PURE; - STDMETHOD(ReferenceToMusicTime) (THIS_ REFERENCE_TIME rtTime, - MUSIC_TIME* pmtTime) PURE; - STDMETHOD(IsPlaying) (THIS_ IDirectMusicSegment* pSegment, - IDirectMusicSegmentState* pSegState) PURE; - STDMETHOD(GetTime) (THIS_ REFERENCE_TIME* prtNow, - MUSIC_TIME* pmtNow) PURE; - STDMETHOD(AllocPMsg) (THIS_ ULONG cb, - DMUS_PMSG** ppPMSG) PURE; - STDMETHOD(FreePMsg) (THIS_ DMUS_PMSG* pPMSG) PURE; - STDMETHOD(GetGraph) (THIS_ IDirectMusicGraph** ppGraph) PURE; - STDMETHOD(SetGraph) (THIS_ IDirectMusicGraph* pGraph) PURE; - STDMETHOD(SetNotificationHandle)(THIS_ HANDLE hNotification, - REFERENCE_TIME rtMinimum) PURE; - STDMETHOD(GetNotificationPMsg) (THIS_ DMUS_NOTIFICATION_PMSG** ppNotificationPMsg) PURE; - STDMETHOD(AddNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; - STDMETHOD(RemoveNotificationType)(THIS_ REFGUID rguidNotificationType) PURE; - STDMETHOD(AddPort) (THIS_ IDirectMusicPort* pPort) PURE; - STDMETHOD(RemovePort) (THIS_ IDirectMusicPort* pPort ) PURE; - STDMETHOD(AssignPChannelBlock) (THIS_ DWORD dwBlockNum, - IDirectMusicPort* pPort, - DWORD dwGroup ) PURE; - STDMETHOD(AssignPChannel) (THIS_ DWORD dwPChannel, - IDirectMusicPort* pPort, - DWORD dwGroup, - DWORD dwMChannel ) PURE; - STDMETHOD(PChannelInfo) (THIS_ DWORD dwPChannel, - IDirectMusicPort** ppPort, - DWORD* pdwGroup, - DWORD* pdwMChannel ) PURE; - STDMETHOD(DownloadInstrument) (THIS_ IDirectMusicInstrument* pInst, - DWORD dwPChannel, - IDirectMusicDownloadedInstrument** ppDownInst, - DMUS_NOTERANGE* pNoteRanges, - DWORD dwNumNoteRanges, - IDirectMusicPort** ppPort, - DWORD* pdwGroup, - DWORD* pdwMChannel ) PURE; - STDMETHOD(Invalidate) (THIS_ MUSIC_TIME mtTime, - DWORD dwFlags) PURE; - STDMETHOD(GetParam) (THIS_ REFGUID rguidType, - DWORD dwGroupBits, - DWORD dwIndex, - MUSIC_TIME mtTime, - MUSIC_TIME* pmtNext, - void* pParam) PURE; - STDMETHOD(SetParam) (THIS_ REFGUID rguidType, - DWORD dwGroupBits, - DWORD dwIndex, - MUSIC_TIME mtTime, - void* pParam) PURE; - STDMETHOD(GetGlobalParam) (THIS_ REFGUID rguidType, - void* pParam, - DWORD dwSize) PURE; - STDMETHOD(SetGlobalParam) (THIS_ REFGUID rguidType, - void* pParam, - DWORD dwSize) PURE; - STDMETHOD(GetLatencyTime) (THIS_ REFERENCE_TIME* prtTime) PURE; - STDMETHOD(GetQueueTime) (THIS_ REFERENCE_TIME* prtTime) PURE; - STDMETHOD(AdjustTime) (THIS_ REFERENCE_TIME rtAmount) PURE; - STDMETHOD(CloseDown) (THIS) PURE; - STDMETHOD(GetResolvedTime) (THIS_ REFERENCE_TIME rtTime, - REFERENCE_TIME* prtResolved, - DWORD dwTimeResolveFlags) PURE; - STDMETHOD(MIDIToMusic) (THIS_ BYTE bMIDIValue, - DMUS_CHORD_KEY* pChord, - BYTE bPlayMode, - BYTE bChordLevel, - WORD *pwMusicValue) PURE; - STDMETHOD(MusicToMIDI) (THIS_ WORD wMusicValue, - DMUS_CHORD_KEY* pChord, - BYTE bPlayMode, - BYTE bChordLevel, - BYTE *pbMIDIValue) PURE; - STDMETHOD(TimeToRhythm) (THIS_ MUSIC_TIME mtTime, - DMUS_TIMESIGNATURE *pTimeSig, - WORD *pwMeasure, - BYTE *pbBeat, - BYTE *pbGrid, - short *pnOffset) PURE; - STDMETHOD(RhythmToTime) (THIS_ WORD wMeasure, - BYTE bBeat, - BYTE bGrid, - short nOffset, - DMUS_TIMESIGNATURE *pTimeSig, - MUSIC_TIME *pmtTime) PURE; -}; - -/*//////////////////////////////////////////////////////////////////// -// IDirectMusicPerformance8 */ -#undef INTERFACE -#define INTERFACE IDirectMusicPerformance8 -DECLARE_INTERFACE_(IDirectMusicPerformance8, IDirectMusicPerformance) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicPerformance */ - STDMETHOD(Init) (THIS_ IDirectMusic** ppDirectMusic, - LPDIRECTSOUND pDirectSound, - HWND hWnd) PURE; - STDMETHOD(PlaySegment) (THIS_ IDirectMusicSegment* pSegment, - DWORD dwFlags, - __int64 i64StartTime, - IDirectMusicSegmentState** ppSegmentState) PURE; - STDMETHOD(Stop) (THIS_ IDirectMusicSegment* pSegment, - IDirectMusicSegmentState* pSegmentState, - MUSIC_TIME mtTime, - DWORD dwFlags) PURE; - STDMETHOD(GetSegmentState) (THIS_ IDirectMusicSegmentState** ppSegmentState, - MUSIC_TIME mtTime) PURE; - STDMETHOD(SetPrepareTime) (THIS_ DWORD dwMilliSeconds) PURE; - STDMETHOD(GetPrepareTime) (THIS_ DWORD* pdwMilliSeconds) PURE; - STDMETHOD(SetBumperLength) (THIS_ DWORD dwMilliSeconds) PURE; - STDMETHOD(GetBumperLength) (THIS_ DWORD* pdwMilliSeconds) PURE; - STDMETHOD(SendPMsg) (THIS_ DMUS_PMSG* pPMSG) PURE; - STDMETHOD(MusicToReferenceTime) (THIS_ MUSIC_TIME mtTime, - REFERENCE_TIME* prtTime) PURE; - STDMETHOD(ReferenceToMusicTime) (THIS_ REFERENCE_TIME rtTime, - MUSIC_TIME* pmtTime) PURE; - STDMETHOD(IsPlaying) (THIS_ IDirectMusicSegment* pSegment, - IDirectMusicSegmentState* pSegState) PURE; - STDMETHOD(GetTime) (THIS_ REFERENCE_TIME* prtNow, - MUSIC_TIME* pmtNow) PURE; - STDMETHOD(AllocPMsg) (THIS_ ULONG cb, - DMUS_PMSG** ppPMSG) PURE; - STDMETHOD(FreePMsg) (THIS_ DMUS_PMSG* pPMSG) PURE; - STDMETHOD(GetGraph) (THIS_ IDirectMusicGraph** ppGraph) PURE; - STDMETHOD(SetGraph) (THIS_ IDirectMusicGraph* pGraph) PURE; - STDMETHOD(SetNotificationHandle)(THIS_ HANDLE hNotification, - REFERENCE_TIME rtMinimum) PURE; - STDMETHOD(GetNotificationPMsg) (THIS_ DMUS_NOTIFICATION_PMSG** ppNotificationPMsg) PURE; - STDMETHOD(AddNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; - STDMETHOD(RemoveNotificationType)(THIS_ REFGUID rguidNotificationType) PURE; - STDMETHOD(AddPort) (THIS_ IDirectMusicPort* pPort) PURE; - STDMETHOD(RemovePort) (THIS_ IDirectMusicPort* pPort ) PURE; - STDMETHOD(AssignPChannelBlock) (THIS_ DWORD dwBlockNum, - IDirectMusicPort* pPort, - DWORD dwGroup ) PURE; - STDMETHOD(AssignPChannel) (THIS_ DWORD dwPChannel, - IDirectMusicPort* pPort, - DWORD dwGroup, - DWORD dwMChannel ) PURE; - STDMETHOD(PChannelInfo) (THIS_ DWORD dwPChannel, - IDirectMusicPort** ppPort, - DWORD* pdwGroup, - DWORD* pdwMChannel ) PURE; - STDMETHOD(DownloadInstrument) (THIS_ IDirectMusicInstrument* pInst, - DWORD dwPChannel, - IDirectMusicDownloadedInstrument** ppDownInst, - DMUS_NOTERANGE* pNoteRanges, - DWORD dwNumNoteRanges, - IDirectMusicPort** ppPort, - DWORD* pdwGroup, - DWORD* pdwMChannel ) PURE; - STDMETHOD(Invalidate) (THIS_ MUSIC_TIME mtTime, - DWORD dwFlags) PURE; - STDMETHOD(GetParam) (THIS_ REFGUID rguidType, - DWORD dwGroupBits, - DWORD dwIndex, - MUSIC_TIME mtTime, - MUSIC_TIME* pmtNext, - void* pParam) PURE; - STDMETHOD(SetParam) (THIS_ REFGUID rguidType, - DWORD dwGroupBits, - DWORD dwIndex, - MUSIC_TIME mtTime, - void* pParam) PURE; - STDMETHOD(GetGlobalParam) (THIS_ REFGUID rguidType, - void* pParam, - DWORD dwSize) PURE; - STDMETHOD(SetGlobalParam) (THIS_ REFGUID rguidType, - void* pParam, - DWORD dwSize) PURE; - STDMETHOD(GetLatencyTime) (THIS_ REFERENCE_TIME* prtTime) PURE; - STDMETHOD(GetQueueTime) (THIS_ REFERENCE_TIME* prtTime) PURE; - STDMETHOD(AdjustTime) (THIS_ REFERENCE_TIME rtAmount) PURE; - STDMETHOD(CloseDown) (THIS) PURE; - STDMETHOD(GetResolvedTime) (THIS_ REFERENCE_TIME rtTime, - REFERENCE_TIME* prtResolved, - DWORD dwTimeResolveFlags) PURE; - STDMETHOD(MIDIToMusic) (THIS_ BYTE bMIDIValue, - DMUS_CHORD_KEY* pChord, - BYTE bPlayMode, - BYTE bChordLevel, - WORD *pwMusicValue) PURE; - STDMETHOD(MusicToMIDI) (THIS_ WORD wMusicValue, - DMUS_CHORD_KEY* pChord, - BYTE bPlayMode, - BYTE bChordLevel, - BYTE *pbMIDIValue) PURE; - STDMETHOD(TimeToRhythm) (THIS_ MUSIC_TIME mtTime, - DMUS_TIMESIGNATURE *pTimeSig, - WORD *pwMeasure, - BYTE *pbBeat, - BYTE *pbGrid, - short *pnOffset) PURE; - STDMETHOD(RhythmToTime) (THIS_ WORD wMeasure, - BYTE bBeat, - BYTE bGrid, - short nOffset, - DMUS_TIMESIGNATURE *pTimeSig, - MUSIC_TIME *pmtTime) PURE; - /* IDirectMusicPerformance8 */ - STDMETHOD(InitAudio) (THIS_ IDirectMusic** ppDirectMusic, /* Optional DirectMusic pointer. */ - IDirectSound** ppDirectSound, /* Optional DirectSound pointer. */ - HWND hWnd, /* HWND for DirectSound. */ - DWORD dwDefaultPathType, /* Requested default audio path type, also optional. */ - DWORD dwPChannelCount, /* Number of PChannels, if default audio path to be created. */ - DWORD dwFlags, /* DMUS_AUDIOF flags, if no pParams structure. */ - DMUS_AUDIOPARAMS *pParams) PURE; /* Optional initialization structure, defining required voices, buffers, etc. */ - STDMETHOD(PlaySegmentEx) (THIS_ IUnknown* pSource, /* Segment to play. */ - WCHAR *pwzSegmentName, /* Not supported in DX8. */ - IUnknown* pTransition, /* Optional template segment to compose transition with. */ - DWORD dwFlags, /* DMUS_SEGF_ flags. */ - __int64 i64StartTime, /* Time to start playback. */ - IDirectMusicSegmentState** ppSegmentState, /* Returned Segment State. */ - IUnknown *pFrom, /* Optional segmentstate or audiopath to replace. */ - IUnknown *pAudioPath) PURE; /* Optional audioPath to play on. */ - STDMETHOD(StopEx) (THIS_ IUnknown *pObjectToStop, /* Segstate, AudioPath, or Segment. */ - __int64 i64StopTime, - DWORD dwFlags) PURE; - STDMETHOD(ClonePMsg) (THIS_ DMUS_PMSG* pSourcePMSG, - DMUS_PMSG** ppCopyPMSG) PURE; - STDMETHOD(CreateAudioPath) (THIS_ IUnknown *pSourceConfig, /* Source configuration, from AudioPathConfig file. */ - BOOL fActivate, /* TRUE to activate on creation. */ - IDirectMusicAudioPath **ppNewPath) PURE; /* Returns created audiopath. */ - STDMETHOD(CreateStandardAudioPath)(THIS_ DWORD dwType, /* Type of path to create. */ - DWORD dwPChannelCount, /* How many PChannels to allocate for it. */ - BOOL fActivate, /* TRUE to activate on creation. */ - IDirectMusicAudioPath **ppNewPath) PURE; /* Returns created audiopath. */ - STDMETHOD(SetDefaultAudioPath) (THIS_ IDirectMusicAudioPath *pAudioPath) PURE; - STDMETHOD(GetDefaultAudioPath) (THIS_ IDirectMusicAudioPath **ppAudioPath) PURE; - STDMETHOD(GetParamEx) (THIS_ REFGUID rguidType, /* GetParam command ID. */ - DWORD dwTrackID, /* Virtual track ID of caller. */ - DWORD dwGroupBits, /* Group bits of caller. */ - DWORD dwIndex, /* Index to Nth parameter. */ - MUSIC_TIME mtTime, /* Time of requested parameter. */ - MUSIC_TIME* pmtNext, /* Returned delta to next parameter. */ - void* pParam) PURE; /* Data structure to fill with parameter. */ -}; - - - -/*//////////////////////////////////////////////////////////////////// -// IDirectMusicGraph */ -#undef INTERFACE -#define INTERFACE IDirectMusicGraph -DECLARE_INTERFACE_(IDirectMusicGraph, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicGraph */ - STDMETHOD(StampPMsg) (THIS_ DMUS_PMSG* pPMSG) PURE; - STDMETHOD(InsertTool) (THIS_ IDirectMusicTool* pTool, - DWORD* pdwPChannels, - DWORD cPChannels, - LONG lIndex) PURE; - STDMETHOD(GetTool) (THIS_ DWORD dwIndex, - IDirectMusicTool** ppTool) PURE; - STDMETHOD(RemoveTool) (THIS_ IDirectMusicTool* pTool) PURE; -}; - -typedef IDirectMusicGraph IDirectMusicGraph8; - - -/*///////////////////////////////////////////////////////////////////// -// IDirectMusicStyle */ -#undef INTERFACE -#define INTERFACE IDirectMusicStyle -DECLARE_INTERFACE_(IDirectMusicStyle, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicStyle */ - STDMETHOD(GetBand) (THIS_ WCHAR* pwszName, - IDirectMusicBand** ppBand) PURE; - STDMETHOD(EnumBand) (THIS_ DWORD dwIndex, - WCHAR *pwszName) PURE; - STDMETHOD(GetDefaultBand) (THIS_ IDirectMusicBand** ppBand) PURE; - STDMETHOD(EnumMotif) (THIS_ DWORD dwIndex, - WCHAR* pwszName) PURE; - STDMETHOD(GetMotif) (THIS_ WCHAR* pwszName, - IDirectMusicSegment** ppSegment) PURE; - STDMETHOD(GetDefaultChordMap) (THIS_ IDirectMusicChordMap** ppChordMap) PURE; - STDMETHOD(EnumChordMap) (THIS_ DWORD dwIndex, - WCHAR *pwszName) PURE; - STDMETHOD(GetChordMap) (THIS_ WCHAR* pwszName, - IDirectMusicChordMap** ppChordMap) PURE; - STDMETHOD(GetTimeSignature) (THIS_ DMUS_TIMESIGNATURE* pTimeSig) PURE; - STDMETHOD(GetEmbellishmentLength) (THIS_ DWORD dwType, - DWORD dwLevel, - DWORD* pdwMin, - DWORD* pdwMax) PURE; - STDMETHOD(GetTempo) (THIS_ double* pTempo) PURE; -}; - -/*///////////////////////////////////////////////////////////////////// -// IDirectMusicStyle8 */ -#undef INTERFACE -#define INTERFACE IDirectMusicStyle8 -DECLARE_INTERFACE_(IDirectMusicStyle8, IDirectMusicStyle) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicStyle */ - STDMETHOD(GetBand) (THIS_ WCHAR* pwszName, - IDirectMusicBand** ppBand) PURE; - STDMETHOD(EnumBand) (THIS_ DWORD dwIndex, - WCHAR *pwszName) PURE; - STDMETHOD(GetDefaultBand) (THIS_ IDirectMusicBand** ppBand) PURE; - STDMETHOD(EnumMotif) (THIS_ DWORD dwIndex, - WCHAR* pwszName) PURE; - STDMETHOD(GetMotif) (THIS_ WCHAR* pwszName, - IDirectMusicSegment** ppSegment) PURE; - STDMETHOD(GetDefaultChordMap) (THIS_ IDirectMusicChordMap** ppChordMap) PURE; - STDMETHOD(EnumChordMap) (THIS_ DWORD dwIndex, - WCHAR *pwszName) PURE; - STDMETHOD(GetChordMap) (THIS_ WCHAR* pwszName, - IDirectMusicChordMap** ppChordMap) PURE; - STDMETHOD(GetTimeSignature) (THIS_ DMUS_TIMESIGNATURE* pTimeSig) PURE; - STDMETHOD(GetEmbellishmentLength) (THIS_ DWORD dwType, - DWORD dwLevel, - DWORD* pdwMin, - DWORD* pdwMax) PURE; - STDMETHOD(GetTempo) (THIS_ double* pTempo) PURE; - - /* IDirectMusicStyle8 */ - STDMETHOD(EnumPattern) (THIS_ DWORD dwIndex, - DWORD dwPatternType, - WCHAR* pwszName) PURE; -}; - -/*///////////////////////////////////////////////////////////////////// -// IDirectMusicChordMap */ -#undef INTERFACE -#define INTERFACE IDirectMusicChordMap -DECLARE_INTERFACE_(IDirectMusicChordMap, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicChordMap */ - STDMETHOD(GetScale) (THIS_ DWORD* pdwScale) PURE; -}; - -typedef IDirectMusicChordMap IDirectMusicChordMap8; - -/*///////////////////////////////////////////////////////////////////// -// IDirectMusicComposer */ -#undef INTERFACE -#define INTERFACE IDirectMusicComposer -DECLARE_INTERFACE_(IDirectMusicComposer, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicComposer */ - STDMETHOD(ComposeSegmentFromTemplate) (THIS_ IDirectMusicStyle* pStyle, - IDirectMusicSegment* pTemplate, - WORD wActivity, - IDirectMusicChordMap* pChordMap, - IDirectMusicSegment** ppSegment) PURE; - STDMETHOD(ComposeSegmentFromShape) (THIS_ IDirectMusicStyle* pStyle, - WORD wNumMeasures, - WORD wShape, - WORD wActivity, - BOOL fIntro, - BOOL fEnd, - IDirectMusicChordMap* pChordMap, - IDirectMusicSegment** ppSegment ) PURE; - STDMETHOD(ComposeTransition) (THIS_ IDirectMusicSegment* pFromSeg, - IDirectMusicSegment* pToSeg, - MUSIC_TIME mtTime, - WORD wCommand, - DWORD dwFlags, - IDirectMusicChordMap* pChordMap, - IDirectMusicSegment** ppTransSeg) PURE; - STDMETHOD(AutoTransition) (THIS_ IDirectMusicPerformance* pPerformance, - IDirectMusicSegment* pToSeg, - WORD wCommand, - DWORD dwFlags, - IDirectMusicChordMap* pChordMap, - IDirectMusicSegment** ppTransSeg, - IDirectMusicSegmentState** ppToSegState, - IDirectMusicSegmentState** ppTransSegState) PURE; - STDMETHOD(ComposeTemplateFromShape) (THIS_ WORD wNumMeasures, - WORD wShape, - BOOL fIntro, - BOOL fEnd, - WORD wEndLength, - IDirectMusicSegment** ppTemplate) PURE; - STDMETHOD(ChangeChordMap) (THIS_ IDirectMusicSegment* pSegment, - BOOL fTrackScale, - IDirectMusicChordMap* pChordMap) PURE; -}; - -typedef IDirectMusicComposer IDirectMusicComposer8; - -/*///////////////////////////////////////////////////////////////////// -// IDirectMusicPatternTrack */ - -#undef INTERFACE -#define INTERFACE IDirectMusicPatternTrack -DECLARE_INTERFACE_(IDirectMusicPatternTrack, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicPatternTrack */ - STDMETHOD(CreateSegment) (THIS_ IDirectMusicStyle* pStyle, - IDirectMusicSegment** ppSegment) PURE; - STDMETHOD(SetVariation) (THIS_ IDirectMusicSegmentState* pSegState, - DWORD dwVariationFlags, - DWORD dwPart) PURE; - STDMETHOD(SetPatternByName) (THIS_ IDirectMusicSegmentState* pSegState, - WCHAR* wszName, - IDirectMusicStyle* pStyle, - DWORD dwPatternType, - DWORD* pdwLength) PURE; -}; - -typedef IDirectMusicPatternTrack IDirectMusicPatternTrack8; - -/*///////////////////////////////////////////////////////////////////// -// IDirectMusicScript */ - -#undef INTERFACE -#define INTERFACE IDirectMusicScript -DECLARE_INTERFACE_(IDirectMusicScript, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicScript */ - STDMETHOD(Init) (THIS_ IDirectMusicPerformance *pPerformance, - DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; - STDMETHOD(CallRoutine) (THIS_ WCHAR *pwszRoutineName, - DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; - STDMETHOD(SetVariableVariant) (THIS_ WCHAR *pwszVariableName, - VARIANT varValue, - BOOL fSetRef, - DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; - STDMETHOD(GetVariableVariant) (THIS_ WCHAR *pwszVariableName, - VARIANT *pvarValue, - DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; - STDMETHOD(SetVariableNumber) (THIS_ WCHAR *pwszVariableName, - LONG lValue, - DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; - STDMETHOD(GetVariableNumber) (THIS_ WCHAR *pwszVariableName, - LONG *plValue, - DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; - STDMETHOD(SetVariableObject) (THIS_ WCHAR *pwszVariableName, - IUnknown *punkValue, - DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; - STDMETHOD(GetVariableObject) (THIS_ WCHAR *pwszVariableName, - REFIID riid, - LPVOID FAR *ppv, - DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; - STDMETHOD(EnumRoutine) (THIS_ DWORD dwIndex, - WCHAR *pwszName) PURE; - STDMETHOD(EnumVariable) (THIS_ DWORD dwIndex, - WCHAR *pwszName) PURE; -}; - -typedef IDirectMusicScript IDirectMusicScript8; - -/*///////////////////////////////////////////////////////////////////// -// IDirectMusicContainer */ - -#undef INTERFACE -#define INTERFACE IDirectMusicContainer -DECLARE_INTERFACE_(IDirectMusicContainer, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicContainer */ - STDMETHOD(EnumObject) (THIS_ REFGUID rguidClass, - DWORD dwIndex, - LPDMUS_OBJECTDESC pDesc, - WCHAR *pwszAlias) PURE; -}; - -typedef IDirectMusicContainer IDirectMusicContainer8; - -/* CLSID's */ -DEFINE_GUID(CLSID_DirectMusicPerformance,0xd2ac2881, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicSegment,0xd2ac2882, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicSegmentState,0xd2ac2883, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicGraph,0xd2ac2884, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicStyle,0xd2ac288a, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicChordMap,0xd2ac288f, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicComposer,0xd2ac2890, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicLoader,0xd2ac2892, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicBand,0x79ba9e00, 0xb6ee, 0x11d1, 0x86, 0xbe, 0x0, 0xc0, 0x4f, 0xbf, 0x8f, 0xef); - -/* New CLSID's for DX8 */ -DEFINE_GUID(CLSID_DirectMusicPatternTrack,0xd2ac2897, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(CLSID_DirectMusicScript,0x810b5013, 0xe88d, 0x11d2, 0x8b, 0xc1, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xb6); /* {810B5013-E88D-11d2-8BC1-00600893B1B6} */ -DEFINE_GUID(CLSID_DirectMusicContainer,0x9301e380, 0x1f22, 0x11d3, 0x82, 0x26, 0xd2, 0xfa, 0x76, 0x25, 0x5d, 0x47); -DEFINE_GUID(CLSID_DirectSoundWave,0x8a667154, 0xf9cb, 0x11d2, 0xad, 0x8a, 0x0, 0x60, 0xb0, 0x57, 0x5a, 0xbc); -DEFINE_GUID(CLSID_DirectMusicAudioPathConfig,0xee0b9ca0, 0xa81e, 0x11d3, 0x9b, 0xd1, 0x0, 0x80, 0xc7, 0x15, 0xa, 0x74); - -/* Special GUID for all object types. This is used by the loader. */ -DEFINE_GUID(GUID_DirectMusicAllTypes,0xd2ac2893, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Notification guids */ -DEFINE_GUID(GUID_NOTIFICATION_SEGMENT,0xd2ac2899, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(GUID_NOTIFICATION_PERFORMANCE,0x81f75bc5, 0x4e5d, 0x11d2, 0xbc, 0xc7, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); -DEFINE_GUID(GUID_NOTIFICATION_MEASUREANDBEAT,0xd2ac289a, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(GUID_NOTIFICATION_CHORD,0xd2ac289b, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(GUID_NOTIFICATION_COMMAND,0xd2ac289c, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(GUID_NOTIFICATION_RECOMPOSE, 0xd348372b, 0x945b, 0x45ae, 0xa5, 0x22, 0x45, 0xf, 0x12, 0x5b, 0x84, 0xa5); - -/* Track param type guids */ -/* Use to get/set a DMUS_COMMAND_PARAM param in the Command track */ -DEFINE_GUID(GUID_CommandParam,0xd2ac289d, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Use to get a DMUS_COMMAND_PARAM_2 param in the Command track */ -DEFINE_GUID(GUID_CommandParam2, 0x28f97ef7, 0x9538, 0x11d2, 0x97, 0xa9, 0x0, 0xc0, 0x4f, 0xa3, 0x6e, 0x58); - -/* Use to get/set a DMUS_COMMAND_PARAM_2 param to be used as the command following all commands in -the Command track (this information can't be saved) */ -DEFINE_GUID(GUID_CommandParamNext, 0x472afe7a, 0x281b, 0x11d3, 0x81, 0x7d, 0x0, 0xc0, 0x4f, 0xa3, 0x6e, 0x58); - -/* Use to get/set a DMUS_CHORD_PARAM param in the Chord track */ -DEFINE_GUID(GUID_ChordParam,0xd2ac289e, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Use to get a DMUS_RHYTHM_PARAM param in the Chord track */ -DEFINE_GUID(GUID_RhythmParam,0xd2ac289f, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Use to get/set an IDirectMusicStyle param in the Style track */ -DEFINE_GUID(GUID_IDirectMusicStyle,0xd2ac28a1, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Use to get a DMUS_TIMESIGNATURE param in the Style and TimeSig tracks */ -DEFINE_GUID(GUID_TimeSignature,0xd2ac28a4, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Use to get/set a DMUS_TEMPO_PARAM param in the Tempo track */ -DEFINE_GUID(GUID_TempoParam,0xd2ac28a5, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Use to get the next valid point in a segment at which it may start */ -DEFINE_GUID(GUID_Valid_Start_Time,0x7f6b1760, 0x1fdb, 0x11d3, 0x82, 0x26, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0); - -/* Use to get the next point in the currently playing primary segment at which a new segment may start */ -DEFINE_GUID(GUID_Play_Marker,0xd8761a41, 0x801a, 0x11d3, 0x9b, 0xd1, 0xda, 0xf7, 0xe1, 0xc3, 0xd8, 0x34); - -/* Use to get (GetParam) or add (SetParam) bands in the Band track */ -DEFINE_GUID(GUID_BandParam,0x2bb1938, 0xcb8b, 0x11d2, 0x8b, 0xb9, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xb6); -typedef struct _DMUS_BAND_PARAM -{ - MUSIC_TIME mtTimePhysical; /* Note: If this is a clock-time track, then this field is interpreted in the track's internal time format, which is the number of milliseconds after the beginning of playback. */ - IDirectMusicBand *pBand; -} DMUS_BAND_PARAM; - -/* Obsolete -- doesn't distinguish physical and logical time. Use GUID_BandParam instead. */ -DEFINE_GUID(GUID_IDirectMusicBand,0xd2ac28ac, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Use to get/set an IDirectMusicChordMap param in the ChordMap track */ -DEFINE_GUID(GUID_IDirectMusicChordMap,0xd2ac28ad, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Use to get/set a DMUS_MUTE_PARAM param in the Mute track */ -DEFINE_GUID(GUID_MuteParam,0xd2ac28af, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* These guids are used in IDirectMusicSegment::SetParam to tell the band track to perform various actions. - Some of these guids (where noted) also apply to wave tracks. - */ -/* Download bands/waves for the IDirectMusicSegment */ -DEFINE_GUID(GUID_Download,0xd2ac28a7, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Unload bands/waves for the IDirectMusicSegment */ -DEFINE_GUID(GUID_Unload,0xd2ac28a8, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Connect segment's bands to an IDirectMusicCollection */ -DEFINE_GUID(GUID_ConnectToDLSCollection, 0x1db1ae6b, 0xe92e, 0x11d1, 0xa8, 0xc5, 0x0, 0xc0, 0x4f, 0xa3, 0x72, 0x6e); - -/* Enable/disable autodownloading of bands/waves */ -DEFINE_GUID(GUID_Enable_Auto_Download,0xd2ac28a9, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(GUID_Disable_Auto_Download,0xd2ac28aa, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Clear all bands */ -DEFINE_GUID(GUID_Clear_All_Bands,0xd2ac28ab, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Set segment to manage all program changes, bank selects, etc. for simple playback of a standard MIDI file */ -DEFINE_GUID(GUID_StandardMIDIFile, 0x6621075, 0xe92e, 0x11d1, 0xa8, 0xc5, 0x0, 0xc0, 0x4f, 0xa3, 0x72, 0x6e); -/* For compatibility with beta releases... */ -#define GUID_IgnoreBankSelectForGM GUID_StandardMIDIFile - -/* Disable/enable param guids. Use these in SetParam calls to disable or enable sending - * specific PMsg types. - */ -DEFINE_GUID(GUID_DisableTimeSig, 0x45fc707b, 0x1db4, 0x11d2, 0xbc, 0xac, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); -DEFINE_GUID(GUID_EnableTimeSig, 0x45fc707c, 0x1db4, 0x11d2, 0xbc, 0xac, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); -DEFINE_GUID(GUID_DisableTempo, 0x45fc707d, 0x1db4, 0x11d2, 0xbc, 0xac, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); -DEFINE_GUID(GUID_EnableTempo, 0x45fc707e, 0x1db4, 0x11d2, 0xbc, 0xac, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); - -/* Used in SetParam calls for pattern-based tracks. A nonzero value seeds the random number -generator for variation selection; a value of zero reverts to the default behavior of -getting the seed from the system clock. -*/ -DEFINE_GUID(GUID_SeedVariations, 0x65b76fa5, 0xff37, 0x11d2, 0x81, 0x4e, 0x0, 0xc0, 0x4f, 0xa3, 0x6e, 0x58); - -/* Used to get the variations currently in effect across PChannels */ -DEFINE_GUID(GUID_Variations, 0x11f72cce, 0x26e6, 0x4ecd, 0xaf, 0x2e, 0xd6, 0x68, 0xe6, 0x67, 0x7, 0xd8); -typedef struct _DMUS_VARIATIONS_PARAM -{ - DWORD dwPChannelsUsed; /* number of PChannels in use */ - DWORD* padwPChannels; /* array of PChannels in use */ - DWORD* padwVariations; /* array of variations in effect for each PChannel */ -} DMUS_VARIATIONS_PARAM; - -/* Download bands/waves for the IDirectMusicSegment, passed an IDirectMusicAudioPath instead of an IDirectMusicPerformance */ -DEFINE_GUID(GUID_DownloadToAudioPath,0x9f2c0341, 0xc5c4, 0x11d3, 0x9b, 0xd1, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0); - -/* Unload bands/waves for the IDirectMusicSegment, passed an IDirectMusicAudioPath instead of an IDirectMusicPerformance */ -DEFINE_GUID(GUID_UnloadFromAudioPath,0x9f2c0342, 0xc5c4, 0x11d3, 0x9b, 0xd1, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0); - - -/* Global data guids */ -DEFINE_GUID(GUID_PerfMasterTempo,0xd2ac28b0, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(GUID_PerfMasterVolume,0xd2ac28b1, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(GUID_PerfMasterGrooveLevel,0xd2ac28b2, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(GUID_PerfAutoDownload, 0xfb09565b, 0x3631, 0x11d2, 0xbc, 0xb8, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); - -/* GUID for default GM/GS dls collection. */ -DEFINE_GUID(GUID_DefaultGMCollection, 0xf17e8673, 0xc3b4, 0x11d1, 0x87, 0xb, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* GUID to define default synth, placed in AudioPath configuration file. */ -DEFINE_GUID(GUID_Synth_Default,0x26bb9432, 0x45fe, 0x48d3, 0xa3, 0x75, 0x24, 0x72, 0xc5, 0xe3, 0xe7, 0x86); - -/* GUIDs to define default buffer configurations to place in AudioPath configuration file. */ -DEFINE_GUID(GUID_Buffer_Reverb,0x186cc541, 0xdb29, 0x11d3, 0x9b, 0xd1, 0x0, 0x80, 0xc7, 0x15, 0xa, 0x74); -DEFINE_GUID(GUID_Buffer_EnvReverb,0x186cc542, 0xdb29, 0x11d3, 0x9b, 0xd1, 0x0, 0x80, 0xc7, 0x15, 0xa, 0x74); -DEFINE_GUID(GUID_Buffer_Stereo,0x186cc545, 0xdb29, 0x11d3, 0x9b, 0xd1, 0x0, 0x80, 0xc7, 0x15, 0xa, 0x74); -DEFINE_GUID(GUID_Buffer_3D_Dry,0x186cc546, 0xdb29, 0x11d3, 0x9b, 0xd1, 0x0, 0x80, 0xc7, 0x15, 0xa, 0x74); -DEFINE_GUID(GUID_Buffer_Mono,0x186cc547, 0xdb29, 0x11d3, 0x9b, 0xd1, 0x0, 0x80, 0xc7, 0x15, 0xa, 0x74); - -/* IID's */ -DEFINE_GUID(IID_IDirectMusicLoader, 0x2ffaaca2, 0x5dca, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); -DEFINE_GUID(IID_IDirectMusicGetLoader,0x68a04844, 0xd13d, 0x11d1, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); -DEFINE_GUID(IID_IDirectMusicObject,0xd2ac28b5, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(IID_IDirectMusicSegment, 0xf96029a2, 0x4282, 0x11d2, 0x87, 0x17, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(IID_IDirectMusicSegmentState, 0xa3afdcc7, 0xd3ee, 0x11d1, 0xbc, 0x8d, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); -DEFINE_GUID(IID_IDirectMusicPerformance,0x7d43d03, 0x6523, 0x11d2, 0x87, 0x1d, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(IID_IDirectMusicGraph,0x2befc277, 0x5497, 0x11d2, 0xbc, 0xcb, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); -DEFINE_GUID(IID_IDirectMusicStyle,0xd2ac28bd, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(IID_IDirectMusicChordMap,0xd2ac28be, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(IID_IDirectMusicComposer,0xd2ac28bf, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); -DEFINE_GUID(IID_IDirectMusicBand,0xd2ac28c0, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Alternate interface IDs, available in DX7 release and after. */ -DEFINE_GUID(IID_IDirectMusicPerformance2,0x6fc2cae0, 0xbc78, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); -DEFINE_GUID(IID_IDirectMusicSegment2, 0xd38894d1, 0xc052, 0x11d2, 0x87, 0x2f, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); - -/* Interface IDs for DX8 */ -/* changed interfaces (GUID only) */ -DEFINE_GUID(IID_IDirectMusicLoader8, 0x19e7c08c, 0xa44, 0x4e6a, 0xa1, 0x16, 0x59, 0x5a, 0x7c, 0xd5, 0xde, 0x8c); -DEFINE_GUID(IID_IDirectMusicPerformance8, 0x679c4137, 0xc62e, 0x4147, 0xb2, 0xb4, 0x9d, 0x56, 0x9a, 0xcb, 0x25, 0x4c); -DEFINE_GUID(IID_IDirectMusicSegment8,0xc6784488, 0x41a3, 0x418f, 0xaa, 0x15, 0xb3, 0x50, 0x93, 0xba, 0x42, 0xd4); -DEFINE_GUID(IID_IDirectMusicSegmentState8, 0xa50e4730, 0xae4, 0x48a7, 0x98, 0x39, 0xbc, 0x4, 0xbf, 0xe0, 0x77, 0x72); -DEFINE_GUID(IID_IDirectMusicStyle8, 0xfd24ad8a, 0xa260, 0x453d, 0xbf, 0x50, 0x6f, 0x93, 0x84, 0xf7, 0x9, 0x85); -/* new interfaces (GUID + alias) */ -DEFINE_GUID(IID_IDirectMusicPatternTrack, 0x51c22e10, 0xb49f, 0x46fc, 0xbe, 0xc2, 0xe6, 0x28, 0x8f, 0xb9, 0xed, 0xe6); -#define IID_IDirectMusicPatternTrack8 IID_IDirectMusicPatternTrack -DEFINE_GUID(IID_IDirectMusicScript, 0x2252373a, 0x5814, 0x489b, 0x82, 0x9, 0x31, 0xfe, 0xde, 0xba, 0xf1, 0x37); /* {2252373A-5814-489b-8209-31FEDEBAF137} */ -#define IID_IDirectMusicScript8 IID_IDirectMusicScript -DEFINE_GUID(IID_IDirectMusicContainer, 0x9301e386, 0x1f22, 0x11d3, 0x82, 0x26, 0xd2, 0xfa, 0x76, 0x25, 0x5d, 0x47); -#define IID_IDirectMusicContainer8 IID_IDirectMusicContainer -DEFINE_GUID(IID_IDirectMusicAudioPath,0xc87631f5, 0x23be, 0x4986, 0x88, 0x36, 0x5, 0x83, 0x2f, 0xcc, 0x48, 0xf9); -#define IID_IDirectMusicAudioPath8 IID_IDirectMusicAudioPath -/* unchanged interfaces (alias only) */ -#define IID_IDirectMusicGetLoader8 IID_IDirectMusicGetLoader -#define IID_IDirectMusicChordMap8 IID_IDirectMusicChordMap -#define IID_IDirectMusicGraph8 IID_IDirectMusicGraph -#define IID_IDirectMusicBand8 IID_IDirectMusicBand -#define IID_IDirectMusicObject8 IID_IDirectMusicObject -#define IID_IDirectMusicComposer8 IID_IDirectMusicComposer - - -#ifdef __cplusplus -}; /* extern "C" */ -#endif - -#include - -#endif /* #ifndef _DMUSICI_ */ +/************************************************************************ +* * +* dmusici.h -- This module contains the API for the * +* DirectMusic performance layer * +* * +* Copyright (c) Microsoft Corporation. All rights reserved. * +* * +************************************************************************/ + +#ifndef _DMUSICI_ +#define _DMUSICI_ + +#include + +#define COM_NO_WINDOWS_H +#include + +#include +#include +/* plugin (track and tool) interfaces. This #include will eventually go away. */ +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef WORD TRANSITION_TYPE; +typedef __int64 REFERENCE_TIME; +typedef long MUSIC_TIME; + +#define MT_MIN 0x80000000 /* Minimum music time value. */ +#define MT_MAX 0x7FFFFFFF /* Maximum music time value. */ + +#define DMUS_PPQ 768 /* parts per quarter note */ + +interface IDirectMusicTrack; +interface IDirectMusicPerformance; +interface IDirectMusicPerformance8; +interface IDirectMusicTool; +interface IDirectMusicSegment; +interface IDirectMusicSegment8; +interface IDirectMusicSegmentState; +interface IDirectMusicSegmentState8; +interface IDirectMusicGraph; +interface IDirectMusicBuffer; +interface IDirectMusicInstrument; +interface IDirectMusicDownloadedInstrument; +interface IDirectMusicBand; +interface IDirectMusicChordMap; +interface IDirectMusicLoader; +interface IDirectMusicLoader8; +interface IDirectMusicScript; +interface IDirectMusicObject; +interface IDirectMusicStyle8; +interface IDirectMusicPatternTrack; +interface IDirectMusicContainer; +interface IDirectMusicTool8; +interface IDirectMusicTrack8; +interface IDirectMusicAudioPath; +#ifndef __cplusplus +typedef interface IDirectMusicTrack IDirectMusicTrack; +typedef interface IDirectMusicPerformance IDirectMusicPerformance; +typedef interface IDirectMusicPerformance8 IDirectMusicPerformance8; +typedef interface IDirectMusicTool IDirectMusicTool; +typedef interface IDirectMusicSegment IDirectMusicSegment; +typedef interface IDirectMusicSegment8 IDirectMusicSegment8; +typedef interface IDirectMusicSegmentState IDirectMusicSegmentState; +typedef interface IDirectMusicSegmentState8 IDirectMusicSegmentState8; +typedef interface IDirectMusicGraph IDirectMusicGraph; +typedef interface IDirectMusicBuffer IDirectMusicBuffer; +typedef interface IDirectMusicInstrument IDirectMusicInstrument; +typedef interface IDirectMusicDownloadedInstrument IDirectMusicDownloadedInstrument; +typedef interface IDirectMusicBand IDirectMusicBand; +typedef interface IDirectMusicChordMap IDirectMusicChordMap; +typedef interface IDirectMusicObject IDirectMusicObject; +typedef interface IDirectMusicLoader IDirectMusicLoader; +typedef interface IDirectMusicLoader8 IDirectMusicLoader8; +typedef interface IDirectMusicScript IDirectMusicScript; +typedef interface IDirectMusicStyle8 IDirectMusicStyle8; +typedef interface IDirectMusicPatternTrack IDirectMusicPatternTrack; +typedef interface IDirectMusicContainer IDirectMusicContainer; +typedef interface IDirectMusicTool8 IDirectMusicTool8; +typedef interface IDirectMusicTrack8 IDirectMusicTrack8; +typedef interface IDirectMusicAudioPath IDirectMusicAudioPath; +#endif + +typedef enum enumDMUS_STYLET_TYPES +{ + DMUS_STYLET_PATTERN = 0, + DMUS_STYLET_MOTIF = 1, +} DMUS_STYLET_TYPES; + + +typedef enum enumDMUS_COMMANDT_TYPES +{ + DMUS_COMMANDT_GROOVE = 0, + DMUS_COMMANDT_FILL = 1, + DMUS_COMMANDT_INTRO = 2, + DMUS_COMMANDT_BREAK = 3, + DMUS_COMMANDT_END = 4, + DMUS_COMMANDT_ENDANDINTRO = 5 +} DMUS_COMMANDT_TYPES; + +typedef enum enumDMUS_SHAPET_TYPES +{ + DMUS_SHAPET_FALLING = 0, + DMUS_SHAPET_LEVEL = 1, + DMUS_SHAPET_LOOPABLE = 2, + DMUS_SHAPET_LOUD = 3, + DMUS_SHAPET_QUIET = 4, + DMUS_SHAPET_PEAKING = 5, + DMUS_SHAPET_RANDOM = 6, + DMUS_SHAPET_RISING = 7, + DMUS_SHAPET_SONG = 8 +} DMUS_SHAPET_TYPES; + +typedef enum enumDMUS_COMPOSEF_FLAGS +{ + DMUS_COMPOSEF_NONE = 0, + DMUS_COMPOSEF_ALIGN = 0x1, + DMUS_COMPOSEF_OVERLAP = 0x2, + DMUS_COMPOSEF_IMMEDIATE = 0x4, + DMUS_COMPOSEF_GRID = 0x8, + DMUS_COMPOSEF_BEAT = 0x10, + DMUS_COMPOSEF_MEASURE = 0x20, + DMUS_COMPOSEF_AFTERPREPARETIME = 0x40, + DMUS_COMPOSEF_VALID_START_BEAT = 0x80, /* In conjunction with DMUS_COMPOSEF_ALIGN, allows the switch to occur on any beat. */ + DMUS_COMPOSEF_VALID_START_GRID = 0x100, /* In conjunction with DMUS_COMPOSEF_ALIGN, allows the switch to occur on any grid. */ + DMUS_COMPOSEF_VALID_START_TICK = 0x200, /* In conjunction with DMUS_COMPOSEF_ALIGN, allows the switch to occur any time. */ + DMUS_COMPOSEF_SEGMENTEND = 0x400, /* Play the transition at the end of the current segment. */ + DMUS_COMPOSEF_MARKER = 0x800, /* Play the transition at the next marker in the current segment. */ + DMUS_COMPOSEF_MODULATE = 0x1000, + DMUS_COMPOSEF_LONG = 0x2000, + DMUS_COMPOSEF_ENTIRE_TRANSITION = 0x4000, /* play the entire transition pattern */ + DMUS_COMPOSEF_1BAR_TRANSITION = 0x8000, /* play one bar of the transition pattern */ + DMUS_COMPOSEF_ENTIRE_ADDITION = 0x10000, /* play the additional pattern in its entirety */ + DMUS_COMPOSEF_1BAR_ADDITION = 0x20000, /* play one bar of the additional pattern */ + DMUS_COMPOSEF_VALID_START_MEASURE = 0x40000, /* In conjunction with DMUS_COMPOSEF_ALIGN, allows the switch to occur on any bar. */ + DMUS_COMPOSEF_DEFAULT = 0x80000, /* Use segment's default boundary */ + DMUS_COMPOSEF_NOINVALIDATE = 0x100000, /* Play without invalidating the currently playing segment(s) */ + DMUS_COMPOSEF_USE_AUDIOPATH = 0x200000, /* Uses the audio paths that are embedded in the segments */ + DMUS_COMPOSEF_INVALIDATE_PRI = 0x400000 /* Invalidate only the current primary seg state */ +} DMUS_COMPOSEF_FLAGS; + +#define DMUS_PMSG_PART \ + DWORD dwSize; \ + REFERENCE_TIME rtTime; /* real time (in 100 nanosecond increments) */ \ + MUSIC_TIME mtTime; /* music time */ \ + DWORD dwFlags; /* various bits (see DMUS_PMSGF_FLAGS enumeration) */ \ + DWORD dwPChannel; /* Performance Channel. The Performance can */ \ + /* use this to determine the port/channel. */ \ + DWORD dwVirtualTrackID; /* virtual track ID */ \ + IDirectMusicTool* pTool; /* tool interface pointer */ \ + IDirectMusicGraph* pGraph; /* tool graph interface pointer */ \ + DWORD dwType; /* PMSG type (see DMUS_PMSGT_TYPES defines) */ \ + DWORD dwVoiceID; /* unique voice id which allows synthesizers to */ \ + /* identify a specific event. For DirectX 6.0, */ \ + /* this field should always be 0. */ \ + DWORD dwGroupID; /* Track group id */ \ + IUnknown* punkUser; /* user com pointer, auto released upon PMSG free */ + +/* every DMUS_PMSG is based off of this structure. The Performance needs + to access these members consistently in every PMSG that goes through it. */ +typedef struct _DMUS_PMSG +{ + /* begin DMUS_PMSG_PART */ + DMUS_PMSG_PART + /* end DMUS_PMSG_PART */ + +} DMUS_PMSG; + +#define DMUS_PCHANNEL_BROADCAST_PERFORMANCE 0xFFFFFFFF /* PMsg is sent on all PChannels of the performance. */ +#define DMUS_PCHANNEL_BROADCAST_AUDIOPATH 0xFFFFFFFE /* PMsg is sent on all PChannels of the audio path. */ +#define DMUS_PCHANNEL_BROADCAST_SEGMENT 0xFFFFFFFD /* PMsg is sent on all PChannels of the segment. */ +#define DMUS_PCHANNEL_BROADCAST_GROUPS 0xFFFFFFFC /* A duplicate PMsg is for each Channels Groups in the performance. */ + +/* The DMUS_PATH constants are used in conjunction with GetObjectInPath to find a requested + interface at a particular stage in the audio path. +*/ +#define DMUS_PATH_SEGMENT 0x1000 /* Get the segment itself (from a segment state.) */ +#define DMUS_PATH_SEGMENT_TRACK 0x1100 /* Look in Track List of Segment. */ +#define DMUS_PATH_SEGMENT_GRAPH 0x1200 /* Get the segment's tool graph. */ +#define DMUS_PATH_SEGMENT_TOOL 0x1300 /* Look in Tool Graph of Segment. */ +#define DMUS_PATH_AUDIOPATH 0x2000 /* Get the audiopath itself (from a segment state.) */ +#define DMUS_PATH_AUDIOPATH_GRAPH 0x2200 /* Get the audiopath's tool graph. */ +#define DMUS_PATH_AUDIOPATH_TOOL 0x2300 /* Look in Tool Graph of Audio Path. */ +#define DMUS_PATH_PERFORMANCE 0x3000 /* Access the performance. */ +#define DMUS_PATH_PERFORMANCE_GRAPH 0x3200 /* Get the performance's tool graph. */ +#define DMUS_PATH_PERFORMANCE_TOOL 0x3300 /* Look in Tool Graph of Performance. */ +#define DMUS_PATH_PORT 0x4000 /* Access the synth. */ +#define DMUS_PATH_BUFFER 0x6000 /* Look in DirectSoundBuffer. */ +#define DMUS_PATH_BUFFER_DMO 0x6100 /* Access a DMO in the buffer. */ +#define DMUS_PATH_MIXIN_BUFFER 0x7000 /* Look in a global mixin buffer. */ +#define DMUS_PATH_MIXIN_BUFFER_DMO 0x7100 /* Access a DMO in a global mixin buffer. */ +#define DMUS_PATH_PRIMARY_BUFFER 0x8000 /* Access the primary buffer. */ + +/* To ignore PChannels when calling GetObjectInPath(), use the DMUS_PCHANNEL_ALL constant. */ +#define DMUS_PCHANNEL_ALL 0xFFFFFFFB + +/* The DMUS_APATH types are used in conjunction with CreateStandardAudioPath to + build default path types. _SHARED_ means the same buffer is shared across multiple + instantiations of the audiopath type. _DYNAMIC_ means a unique buffer is created + every time. +*/ + +#define DMUS_APATH_SHARED_STEREOPLUSREVERB 1 /* A standard music set up with stereo outs and reverb. */ +#define DMUS_APATH_DYNAMIC_3D 6 /* An audio path with one dynamic bus from the synth feeding to a dynamic 3d buffer. Does not send to env reverb. */ +#define DMUS_APATH_DYNAMIC_MONO 7 /* An audio path with one dynamic bus from the synth feeding to a dynamic mono buffer. */ +#define DMUS_APATH_DYNAMIC_STEREO 8 /* An audio path with two dynamic buses from the synth feeding to a dynamic stereo buffer. */ + +typedef struct _DMUS_AUDIOPARAMS +{ + DWORD dwSize; /* Size of this structure. */ + BOOL fInitNow; /* If true, the sink and synth are created immediately and results returned in this structure. */ + DWORD dwValidData; /* Flags indicating which fields below are valid. */ + DWORD dwFeatures; /* Required DMUS_AUDIOF features. */ + DWORD dwVoices; /* Required number of voices. */ + DWORD dwSampleRate; /* Sample rate of synths and sink. */ + CLSID clsidDefaultSynth; /* Class ID of default synthesizer. */ +} DMUS_AUDIOPARAMS; + +/* dwFeatures flags. These indicate which features are required for the audio environment. */ +#define DMUS_AUDIOF_3D 0x1 /* Require 3D buffers. */ +#define DMUS_AUDIOF_ENVIRON 0x2 /* Require environmental modeling. */ +#define DMUS_AUDIOF_EAX 0x4 /* Require use of EAX effects. */ +#define DMUS_AUDIOF_DMOS 0x8 /* Require use of additional DMOs. */ +#define DMUS_AUDIOF_STREAMING 0x10 /* Require support for streaming waves. */ +#define DMUS_AUDIOF_BUFFERS 0x20 /* Require support for multiple buffers (all above cases need this.) */ +#define DMUS_AUDIOF_ALL 0x3F /* Requires everything. */ + +/* dwValidData flags. These indicate which fields in DMUS_AUDIOPARAMS have been filled in. If fInitNow is set, these also return what was allocated. */ +#define DMUS_AUDIOPARAMS_FEATURES 0x00000001 +#define DMUS_AUDIOPARAMS_VOICES 0x00000002 +#define DMUS_AUDIOPARAMS_SAMPLERATE 0x00000004 +#define DMUS_AUDIOPARAMS_DEFAULTSYNTH 0x00000008 + +/* DMUS_PMSGF_FLAGS fill the DMUS_PMSG's dwFlags member */ +typedef enum enumDMUS_PMSGF_FLAGS +{ + DMUS_PMSGF_REFTIME = 1, /* if rtTime is valid */ + DMUS_PMSGF_MUSICTIME = 2, /* if mtTime is valid */ + DMUS_PMSGF_TOOL_IMMEDIATE = 4, /* if PMSG should be processed immediately */ + DMUS_PMSGF_TOOL_QUEUE = 8, /* if PMSG should be processed a little early, at Queue time */ + DMUS_PMSGF_TOOL_ATTIME = 0x10, /* if PMSG should be processed at the time stamp */ + DMUS_PMSGF_TOOL_FLUSH = 0x20, /* if PMSG is being flushed */ + DMUS_PMSGF_LOCKTOREFTIME = 0x40, /* if rtTime can not be overriden by a tempo change. */ + DMUS_PMSGF_DX8 = 0x80 /* if the message has DX8 or later extensions. */ + /* The values of DMUS_TIME_RESOLVE_FLAGS may also be used inside the */ + /* DMUS_PMSG's dwFlags member. */ +} DMUS_PMSGF_FLAGS; + +/* DMUS_PMSGT_TYPES fill the DMUS_PMSG's dwType member */ +typedef enum enumDMUS_PMSGT_TYPES +{ + DMUS_PMSGT_MIDI = 0, /* MIDI short message */ + DMUS_PMSGT_NOTE = 1, /* Interactive Music Note */ + DMUS_PMSGT_SYSEX = 2, /* MIDI long message (system exclusive message) */ + DMUS_PMSGT_NOTIFICATION = 3, /* Notification message */ + DMUS_PMSGT_TEMPO = 4, /* Tempo message */ + DMUS_PMSGT_CURVE = 5, /* Control change / pitch bend, etc. curve */ + DMUS_PMSGT_TIMESIG = 6, /* Time signature */ + DMUS_PMSGT_PATCH = 7, /* Patch changes */ + DMUS_PMSGT_TRANSPOSE = 8, /* Transposition messages */ + DMUS_PMSGT_CHANNEL_PRIORITY = 9, /* Channel priority */ + DMUS_PMSGT_STOP = 10, /* Stop message */ + DMUS_PMSGT_DIRTY = 11, /* Tells Tools that cache GetParam() info to refresh */ + DMUS_PMSGT_WAVE = 12, /* Carries control information for playing a wave. */ + DMUS_PMSGT_LYRIC = 13, /* Lyric message from lyric track. */ + DMUS_PMSGT_SCRIPTLYRIC = 14, /* Lyric message sent by a script with the Trace function. */ + DMUS_PMSGT_USER = 255 /* User message */ +} DMUS_PMSGT_TYPES; + +/* DMUS_SEGF_FLAGS correspond to IDirectMusicPerformance::PlaySegment, and other API */ +typedef enum enumDMUS_SEGF_FLAGS +{ + DMUS_SEGF_REFTIME = 1<<6, /* 0x40 Time parameter is in reference time */ + DMUS_SEGF_SECONDARY = 1<<7, /* 0x80 Secondary segment */ + DMUS_SEGF_QUEUE = 1<<8, /* 0x100 Queue at the end of the primary segment queue (primary only) */ + DMUS_SEGF_CONTROL = 1<<9, /* 0x200 Play as a control track (secondary segments only) */ + DMUS_SEGF_AFTERPREPARETIME = 1<<10, /* 0x400 Play after the prepare time (See IDirectMusicPerformance::GetPrepareTime) */ + DMUS_SEGF_GRID = 1<<11, /* 0x800 Play on grid boundary */ + DMUS_SEGF_BEAT = 1<<12, /* 0x1000 Play on beat boundary */ + DMUS_SEGF_MEASURE = 1<<13, /* 0x2000 Play on measure boundary */ + DMUS_SEGF_DEFAULT = 1<<14, /* 0x4000 Use segment's default boundary */ + DMUS_SEGF_NOINVALIDATE = 1<<15, /* 0x8000 Play without invalidating the currently playing segment(s) */ + DMUS_SEGF_ALIGN = 1<<16, /* 0x10000 Align segment with requested boundary, but switch at first valid point */ + DMUS_SEGF_VALID_START_BEAT = 1<<17, /* 0x20000 In conjunction with DMUS_SEGF_ALIGN, allows the switch to occur on any beat. */ + DMUS_SEGF_VALID_START_GRID = 1<<18, /* 0x40000 In conjunction with DMUS_SEGF_ALIGN, allows the switch to occur on any grid. */ + DMUS_SEGF_VALID_START_TICK = 1<<19, /* 0x80000 In conjunction with DMUS_SEGF_ALIGN, allows the switch to occur any time. */ + DMUS_SEGF_AUTOTRANSITION = 1<<20, /* 0x100000 Compose and play a transition segment, using the transition template. */ + DMUS_SEGF_AFTERQUEUETIME = 1<<21, /* 0x200000 Make sure to play after the queue time. This is default for primary segments */ + DMUS_SEGF_AFTERLATENCYTIME = 1<<22, /* 0x400000 Make sure to play after the latency time. This is true for all segments, so this is a nop */ + DMUS_SEGF_SEGMENTEND = 1<<23, /* 0x800000 Play at the next end of segment. */ + DMUS_SEGF_MARKER = 1<<24, /* 0x1000000 Play at next marker in the primary segment. If there are no markers, default to any other resolution requests. */ + DMUS_SEGF_TIMESIG_ALWAYS = 1<<25, /* 0x2000000 Even if there is no primary segment, align start time with current time signature. */ + DMUS_SEGF_USE_AUDIOPATH = 1<<26, /* 0x4000000 Uses the audio path that is embedded in the segment. */ + DMUS_SEGF_VALID_START_MEASURE = 1<<27, /* 0x8000000 In conjunction with DMUS_SEGF_ALIGN, allows the switch to occur on any bar. */ + DMUS_SEGF_INVALIDATE_PRI = 1<<28 /* 0x10000000 invalidate only the current primary seg state */ +} DMUS_SEGF_FLAGS; + +#define DMUS_SEG_REPEAT_INFINITE 0xFFFFFFFF /* For IDirectMusicSegment::SetRepeat*/ +#define DMUS_SEG_ALLTRACKS 0x80000000 /* For IDirectMusicSegment::SetParam() and SetTrackConfig() - selects all tracks instead on nth index. */ +#define DMUS_SEG_ANYTRACK 0x80000000 /* For IDirectMusicSegment::GetParam() - checks each track until it finds one that returns data (not DMUS_E_NOT_FOUND.) */ + + +/* DMUS_TIME_RESOLVE_FLAGS correspond to IDirectMusicPerformance::GetResolvedTime, and can */ +/* also be used interchangeably with the corresponding DMUS_SEGF_FLAGS, since their values */ +/* are intentionally the same */ +typedef enum enumDMUS_TIME_RESOLVE_FLAGS +{ + DMUS_TIME_RESOLVE_AFTERPREPARETIME = DMUS_SEGF_AFTERPREPARETIME, + DMUS_TIME_RESOLVE_AFTERQUEUETIME = DMUS_SEGF_AFTERQUEUETIME, + DMUS_TIME_RESOLVE_AFTERLATENCYTIME = DMUS_SEGF_AFTERLATENCYTIME, + DMUS_TIME_RESOLVE_GRID = DMUS_SEGF_GRID, + DMUS_TIME_RESOLVE_BEAT = DMUS_SEGF_BEAT, + DMUS_TIME_RESOLVE_MEASURE = DMUS_SEGF_MEASURE, + DMUS_TIME_RESOLVE_MARKER = DMUS_SEGF_MARKER, + DMUS_TIME_RESOLVE_SEGMENTEND = DMUS_SEGF_SEGMENTEND, +} DMUS_TIME_RESOLVE_FLAGS; + +/* The following flags are sent inside the DMUS_CHORD_KEY.dwFlags parameter */ +typedef enum enumDMUS_CHORDKEYF_FLAGS +{ + DMUS_CHORDKEYF_SILENT = 1, /* is the chord silent? */ +} DMUS_CHORDKEYF_FLAGS; + +#define DMUS_MAXSUBCHORD 8 + +typedef struct _DMUS_SUBCHORD +{ + DWORD dwChordPattern; /* Notes in the subchord */ + DWORD dwScalePattern; /* Notes in the scale */ + DWORD dwInversionPoints; /* Where inversions can occur */ + DWORD dwLevels; /* Which levels are supported by this subchord */ + BYTE bChordRoot; /* Root of the subchord */ + BYTE bScaleRoot; /* Root of the scale */ +} DMUS_SUBCHORD; + +typedef struct _DMUS_CHORD_KEY +{ + WCHAR wszName[16]; /* Name of the chord */ + WORD wMeasure; /* Measure this falls on */ + BYTE bBeat; /* Beat this falls on */ + BYTE bSubChordCount; /* Number of chords in the list of subchords */ + DMUS_SUBCHORD SubChordList[DMUS_MAXSUBCHORD]; /* List of sub chords */ + DWORD dwScale; /* Scale underlying the entire chord */ + BYTE bKey; /* Key underlying the entire chord */ + BYTE bFlags; /* Miscelaneous flags */ +} DMUS_CHORD_KEY; + +/* DMUS_NOTE_PMSG */ +typedef struct _DMUS_NOTE_PMSG +{ + /* begin DMUS_PMSG_PART */ + DMUS_PMSG_PART + /* end DMUS_PMSG_PART */ + + MUSIC_TIME mtDuration; /* duration */ + WORD wMusicValue; /* Description of note in chord and key. */ + WORD wMeasure; /* Measure in which this note occurs */ + short nOffset; /* Offset from grid at which this note occurs */ + BYTE bBeat; /* Beat (in measure) at which this note occurs */ + BYTE bGrid; /* Grid offset from beat at which this note occurs */ + BYTE bVelocity; /* Note velocity */ + BYTE bFlags; /* see DMUS_NOTEF_FLAGS */ + BYTE bTimeRange; /* Range to randomize time. */ + BYTE bDurRange; /* Range to randomize duration. */ + BYTE bVelRange; /* Range to randomize velocity. */ + BYTE bPlayModeFlags; /* Play mode */ + BYTE bSubChordLevel; /* Which subchord level this note uses. */ + BYTE bMidiValue; /* The MIDI note value, converted from wMusicValue */ + char cTranspose; /* Transposition to add to midi note value after converted from wMusicValue. */ +} DMUS_NOTE_PMSG; + +typedef enum enumDMUS_NOTEF_FLAGS +{ + DMUS_NOTEF_NOTEON = 1, /* Set if this is a MIDI Note On. Otherwise, it is MIDI Note Off */ + /* DX8 flags: */ + DMUS_NOTEF_NOINVALIDATE = 2, /* Don't invalidate this note off. */ + DMUS_NOTEF_NOINVALIDATE_INSCALE = 4,/* Don't invalidate if still within the scale. */ + DMUS_NOTEF_NOINVALIDATE_INCHORD = 8,/* Don't invalidate if still within the chord. */ + DMUS_NOTEF_REGENERATE = 0x10, /* Regenerate the note on an invalidate. */ +} DMUS_NOTEF_FLAGS; + +/* The DMUS_PLAYMODE_FLAGS are used to determine how to convert wMusicValue + into the appropriate bMidiValue. +*/ + +typedef enum enumDMUS_PLAYMODE_FLAGS +{ + DMUS_PLAYMODE_KEY_ROOT = 1, /* Transpose on top of the key root. */ + DMUS_PLAYMODE_CHORD_ROOT = 2, /* Transpose on top of the chord root. */ + DMUS_PLAYMODE_SCALE_INTERVALS = 4, /* Use scale intervals from scale pattern. */ + DMUS_PLAYMODE_CHORD_INTERVALS = 8, /* Use chord intervals from chord pattern. */ + DMUS_PLAYMODE_NONE = 16, /* No mode. Indicates the parent part's mode should be used. */ +} DMUS_PLAYMODE_FLAGS; + +/* The following are playback modes that can be created by combining the DMUS_PLAYMODE_FLAGS + in various ways: +*/ + +/* Fixed. wMusicValue holds final MIDI note value. This is used for drums, sound effects, and sequenced + notes that should not be transposed by the chord or scale. +*/ +#define DMUS_PLAYMODE_FIXED 0 +/* In fixed to key, the musicvalue is again a fixed MIDI value, but it + is transposed on top of the key root. +*/ +#define DMUS_PLAYMODE_FIXEDTOKEY DMUS_PLAYMODE_KEY_ROOT +/* In fixed to chord, the musicvalue is also a fixed MIDI value, but it + is transposed on top of the chord root. +*/ +#define DMUS_PLAYMODE_FIXEDTOCHORD DMUS_PLAYMODE_CHORD_ROOT +/* In Pedalpoint, the key root is used and the notes only track the intervals in + the scale. The chord root and intervals are completely ignored. This is useful + for melodic lines that play relative to the key root. +*/ +#define DMUS_PLAYMODE_PEDALPOINT (DMUS_PLAYMODE_KEY_ROOT | DMUS_PLAYMODE_SCALE_INTERVALS) +/* In the Melodic mode, the chord root is used but the notes only track the intervals in + the scale. The key root and chord intervals are completely ignored. This is useful + for melodic lines that play relative to the chord root. +*/ +#define DMUS_PLAYMODE_MELODIC (DMUS_PLAYMODE_CHORD_ROOT | DMUS_PLAYMODE_SCALE_INTERVALS) +/* Normal chord mode is the prevalent playback mode. + The notes track the intervals in the chord, which is based on the chord root. + If there is a scale component to the MusicValue, the additional intervals + are pulled from the scale and added. + If the chord does not have an interval to match the chord component of + the MusicValue, the note is silent. +*/ +#define DMUS_PLAYMODE_NORMALCHORD (DMUS_PLAYMODE_CHORD_ROOT | DMUS_PLAYMODE_CHORD_INTERVALS) +/* If it is desirable to play a note that is above the top of the chord, the + always play mode (known as "purpleized" in a former life) finds a position + for the note by using intervals from the scale. Essentially, this mode is + a combination of the Normal and Melodic playback modes, where a failure + in Normal causes a second try in Melodic mode. +*/ +#define DMUS_PLAYMODE_ALWAYSPLAY (DMUS_PLAYMODE_MELODIC | DMUS_PLAYMODE_NORMALCHORD) + +/* These playmodes are new for dx8. */ +/* In PedalpointChord, the key root is used and the notes only track the intervals in + the chord. The chord root and scale intervals are completely ignored. This is useful + for chordal lines that play relative to the key root. +*/ +#define DMUS_PLAYMODE_PEDALPOINTCHORD (DMUS_PLAYMODE_KEY_ROOT | DMUS_PLAYMODE_CHORD_INTERVALS) + +/* For completeness, here's a mode that tries for pedalpointchord, but if it fails + uses scale intervals +*/ +#define DMUS_PLAYMODE_PEDALPOINTALWAYS (DMUS_PLAYMODE_PEDALPOINT | DMUS_PLAYMODE_PEDALPOINTCHORD) + + +/* Legacy names for modes... */ +#define DMUS_PLAYMODE_PURPLEIZED DMUS_PLAYMODE_ALWAYSPLAY +#define DMUS_PLAYMODE_SCALE_ROOT DMUS_PLAYMODE_KEY_ROOT +#define DMUS_PLAYMODE_FIXEDTOSCALE DMUS_PLAYMODE_FIXEDTOKEY + + +/* DMUS_MIDI_PMSG */ +typedef struct _DMUS_MIDI_PMSG +{ + /* begin DMUS_PMSG_PART */ + DMUS_PMSG_PART + /* end DMUS_PMSG_PART */ + + BYTE bStatus; + BYTE bByte1; + BYTE bByte2; + BYTE bPad[1]; +} DMUS_MIDI_PMSG; + +/* DMUS_PATCH_PMSG */ +typedef struct _DMUS_PATCH_PMSG +{ + /* begin DMUS_PMSG_PART */ + DMUS_PMSG_PART + /* end DMUS_PMSG_PART */ + + BYTE byInstrument; + BYTE byMSB; + BYTE byLSB; + BYTE byPad[1]; +} DMUS_PATCH_PMSG; + +/* DMUS_TRANSPOSE_PMSG */ +typedef struct _DMUS_TRANSPOSE_PMSG +{ + /* begin DMUS_PMSG_PART */ + DMUS_PMSG_PART + /* end DMUS_PMSG_PART */ + + short nTranspose; + /* Following exists only under DX8 and on (check dwFlags for DMUS_PMSGF_DX8) */ + WORD wMergeIndex; /* Allows multiple parameters to be merged (pitchbend, volume, and expression.)*/ +} DMUS_TRANSPOSE_PMSG; + +/* DMUS_CHANNEL_PRIORITY_PMSG */ +typedef struct _DMUS_CHANNEL_PRIORITY_PMSG +{ + /* begin DMUS_PMSG_PART */ + DMUS_PMSG_PART + /* end DMUS_PMSG_PART */ + + DWORD dwChannelPriority; +} DMUS_CHANNEL_PRIORITY_PMSG; + +/* DMUS_TEMPO_PMSG */ +typedef struct _DMUS_TEMPO_PMSG +{ + /* begin DMUS_PMSG_PART */ + DMUS_PMSG_PART + /* end DMUS_PMSG_PART */ + + double dblTempo; /* the tempo */ +} DMUS_TEMPO_PMSG; + +#define DMUS_TEMPO_MAX 1000 +#define DMUS_TEMPO_MIN 1 + +#define DMUS_MASTERTEMPO_MAX 100.0f +#define DMUS_MASTERTEMPO_MIN 0.01f + +/* DMUS_SYSEX_PMSG */ +typedef struct _DMUS_SYSEX_PMSG +{ + /* begin DMUS_PMSG_PART */ + DMUS_PMSG_PART + /* end DMUS_PMSG_PART */ + + DWORD dwLen; /* length of the data */ + BYTE abData[1]; /* array of data, length equal to dwLen */ +} DMUS_SYSEX_PMSG; + +/* DMUS_CURVE_PMSG */ +typedef struct _DMUS_CURVE_PMSG +{ + /* begin DMUS_PMSG_PART */ + DMUS_PMSG_PART + /* end DMUS_PMSG_PART */ + + MUSIC_TIME mtDuration; /* how long this curve lasts */ + MUSIC_TIME mtOriginalStart; /* must be set to either zero when this PMSG is created or to the original mtTime of the curve */ + MUSIC_TIME mtResetDuration; /* how long after the curve is finished to allow a flush or + invalidation to reset to the reset value, nResetValue */ + short nStartValue; /* curve's start value */ + short nEndValue; /* curve's end value */ + short nResetValue; /* curve's reset value, set when a flush or invalidation + occurs within mtDuration + mtResetDuration */ + WORD wMeasure; /* Measure in which this curve occurs */ + short nOffset; /* Offset from grid at which this curve occurs */ + BYTE bBeat; /* Beat (in measure) at which this curve occurs */ + BYTE bGrid; /* Grid offset from beat at which this curve occurs */ + BYTE bType; /* type of curve */ + BYTE bCurveShape; /* shape of curve */ + BYTE bCCData; /* CC# if this is a control change type */ + BYTE bFlags; /* Curve reset and start from current value flags. */ + /* Following exists only under DX8 and on (check dwFlags for DMUS_PMSGF_DX8) */ + WORD wParamType; /* RPN or NRPN parameter number. */ + WORD wMergeIndex; /* Allows multiple parameters to be merged (pitchbend, volume, and expression.)*/ +} DMUS_CURVE_PMSG; + +typedef enum enumDMUS_CURVE_FLAGS +{ + DMUS_CURVE_RESET = 1, /* When set, the nResetValue must be sent when the + time is reached or an invalidate occurs because + of a transition. If not set, the curve stays + permanently stuck at the new value. */ + DMUS_CURVE_START_FROM_CURRENT = 2/* Ignore Start, start the curve at the current value. + This only works for volume, expression, and pitchbend. */ +} DMUS_CURVE_FLAGS; + + +#define DMUS_CURVE_RESET 1 + +/* Curve shapes */ +enum +{ + DMUS_CURVES_LINEAR = 0, + DMUS_CURVES_INSTANT = 1, + DMUS_CURVES_EXP = 2, + DMUS_CURVES_LOG = 3, + DMUS_CURVES_SINE = 4 +}; +/* curve types */ +#define DMUS_CURVET_PBCURVE 0x03 /* Pitch bend curve. */ +#define DMUS_CURVET_CCCURVE 0x04 /* Control change curve. */ +#define DMUS_CURVET_MATCURVE 0x05 /* Mono aftertouch curve. */ +#define DMUS_CURVET_PATCURVE 0x06 /* Poly aftertouch curve. */ +#define DMUS_CURVET_RPNCURVE 0x07 /* RPN curve with curve type in wParamType. */ +#define DMUS_CURVET_NRPNCURVE 0x08 /* NRPN curve with curve type in wParamType. */ + +/* DMUS_TIMESIG_PMSG */ +typedef struct _DMUS_TIMESIG_PMSG +{ + /* begin DMUS_PMSG_PART */ + DMUS_PMSG_PART + /* end DMUS_PMSG_PART */ + + /* Time signatures define how many beats per measure, which note receives */ + /* the beat, and the grid resolution. */ + BYTE bBeatsPerMeasure; /* beats per measure (top of time sig) */ + BYTE bBeat; /* what note receives the beat (bottom of time sig.) */ + /* we can assume that 0 means 256th note */ + WORD wGridsPerBeat; /* grids per beat */ +} DMUS_TIMESIG_PMSG; + + + +/* notification type values */ +/* The following correspond to GUID_NOTIFICATION_SEGMENT */ +#define DMUS_NOTIFICATION_SEGSTART 0 +#define DMUS_NOTIFICATION_SEGEND 1 +#define DMUS_NOTIFICATION_SEGALMOSTEND 2 +#define DMUS_NOTIFICATION_SEGLOOP 3 +#define DMUS_NOTIFICATION_SEGABORT 4 +/* The following correspond to GUID_NOTIFICATION_PERFORMANCE */ +#define DMUS_NOTIFICATION_MUSICSTARTED 0 +#define DMUS_NOTIFICATION_MUSICSTOPPED 1 +#define DMUS_NOTIFICATION_MUSICALMOSTEND 2 +/* The following corresponds to GUID_NOTIFICATION_MEASUREANDBEAT */ +#define DMUS_NOTIFICATION_MEASUREBEAT 0 +/* The following corresponds to GUID_NOTIFICATION_CHORD */ +#define DMUS_NOTIFICATION_CHORD 0 +/* The following correspond to GUID_NOTIFICATION_COMMAND */ +#define DMUS_NOTIFICATION_GROOVE 0 +#define DMUS_NOTIFICATION_EMBELLISHMENT 1 +/* The following corresponds to GUID_NOTIFICATION_RECOMPOSE */ +#define DMUS_NOTIFICATION_RECOMPOSE 0 + +/* DMUS_NOTIFICATION_PMSG */ +typedef struct _DMUS_NOTIFICATION_PMSG +{ + /* begin DMUS_PMSG_PART */ + DMUS_PMSG_PART + /* end DMUS_PMSG_PART */ + + GUID guidNotificationType; + DWORD dwNotificationOption; + DWORD dwField1; + DWORD dwField2; +} DMUS_NOTIFICATION_PMSG; + +/* DMUS_WAVE_PMSG */ +typedef struct _DMUS_WAVE_PMSG +{ + /* begin DMUS_PMSG_PART */ + DMUS_PMSG_PART + /* end DMUS_PMSG_PART */ + + REFERENCE_TIME rtStartOffset; /* How far into the wave to start, in reference time units only. */ + REFERENCE_TIME rtDuration; /* Duration of the wave, in either reference time or music time. */ + long lOffset; /* Offset from actual time to logical time, in music or ref time. */ + long lVolume; /* Initial volume, in 100ths of a dB. */ + long lPitch; /* Initial pitch, in 100ths of a semitone. */ + BYTE bFlags; /* Flags, including DMUS_WAVEF_OFF... */ +} DMUS_WAVE_PMSG; + +#define DMUS_WAVEF_OFF 1 /* If wave is playing and this is the off message. */ +#define DMUS_WAVEF_STREAMING 2 /* If wave is streaming. */ +#define DMUS_WAVEF_NOINVALIDATE 4 /* Don't invalidate this wave. */ +#define DMUS_WAVEF_NOPREROLL 8 /* Don't preroll any wave data. */ +#define DMUS_WAVEF_IGNORELOOPS 0x20 /* Ignore segment looping. */ + +/* DMUS_LYRIC_PMSG */ +typedef struct _DMUS_LYRIC_PMSG +{ + /* begin DMUS_PMSG_PART */ + DMUS_PMSG_PART + /* end DMUS_PMSG_PART */ + + WCHAR wszString[1]; /* null-terminated Unicode lyric string (structure is actually larger than size 1) */ +} DMUS_LYRIC_PMSG; + +#define DMUS_MAX_NAME 64 /* Maximum object name length. */ +#define DMUS_MAX_CATEGORY 64 /* Maximum object category name length. */ +#define DMUS_MAX_FILENAME MAX_PATH + +typedef struct _DMUS_VERSION { + DWORD dwVersionMS; + DWORD dwVersionLS; +}DMUS_VERSION, FAR *LPDMUS_VERSION; + +/* Time Signature structure, used by IDirectMusicStyle */ +/* Also used as a parameter for GetParam() and SetParam */ +typedef struct _DMUS_TIMESIGNATURE +{ + MUSIC_TIME mtTime; + BYTE bBeatsPerMeasure; /* beats per measure (top of time sig) */ + BYTE bBeat; /* what note receives the beat (bottom of time sig.) */ + /* we can assume that 0 means 256th note */ + WORD wGridsPerBeat; /* grids per beat */ +} DMUS_TIMESIGNATURE; + +typedef struct _DMUS_VALID_START_PARAM +{ + MUSIC_TIME mtTime; /* Time of the first legal start + point after (or including) the requested time. + This is a returned value. + Time format is the relative offset from requested time. */ +} DMUS_VALID_START_PARAM; + +typedef struct _DMUS_PLAY_MARKER_PARAM +{ + MUSIC_TIME mtTime; /* Time of the first legal segment play + marker before (or including) the requested time. + This is a returned value. + Time format is the relative offset from requested time. */ +} DMUS_PLAY_MARKER_PARAM; + +/* The DMUSOBJECTDESC structure is used to communicate everything you could */ +/* possibly use to describe a DirectMusic object. */ + +typedef struct _DMUS_OBJECTDESC +{ + DWORD dwSize; /* Size of this structure. */ + DWORD dwValidData; /* Flags indicating which fields below are valid. */ + GUID guidObject; /* Unique ID for this object. */ + GUID guidClass; /* GUID for the class of object. */ + FILETIME ftDate; /* Last edited date of object. */ + DMUS_VERSION vVersion; /* Version. */ + WCHAR wszName[DMUS_MAX_NAME]; /* Name of object. */ + WCHAR wszCategory[DMUS_MAX_CATEGORY]; /* Category for object (optional). */ + WCHAR wszFileName[DMUS_MAX_FILENAME]; /* File path. */ + LONGLONG llMemLength; /* Size of Memory data. */ + LPBYTE pbMemData; /* Memory pointer for data. */ + IStream * pStream; /* Stream with data. */ +} DMUS_OBJECTDESC; + +typedef DMUS_OBJECTDESC *LPDMUS_OBJECTDESC; + +/* Flags for dwValidData. When set, a flag indicates that the */ +/* corresponding field in DMUSOBJECTDESC holds valid data. */ + +#define DMUS_OBJ_OBJECT (1 << 0) /* Object GUID is valid. */ +#define DMUS_OBJ_CLASS (1 << 1) /* Class GUID is valid. */ +#define DMUS_OBJ_NAME (1 << 2) /* Name is valid. */ +#define DMUS_OBJ_CATEGORY (1 << 3) /* Category is valid. */ +#define DMUS_OBJ_FILENAME (1 << 4) /* File path is valid. */ +#define DMUS_OBJ_FULLPATH (1 << 5) /* Path is full path. */ +#define DMUS_OBJ_URL (1 << 6) /* Path is URL. */ +#define DMUS_OBJ_VERSION (1 << 7) /* Version is valid. */ +#define DMUS_OBJ_DATE (1 << 8) /* Date is valid. */ +#define DMUS_OBJ_LOADED (1 << 9) /* Object is currently loaded in memory. */ +#define DMUS_OBJ_MEMORY (1 << 10) /* Object is pointed to by pbMemData. */ +#define DMUS_OBJ_STREAM (1 << 11) /* Object is stored in pStream. */ + +/* The DMUS_SCRIPT_ERRORINFO structure describes an error that occurred in a script. + It is returned by methods in IDirectMusicScript. */ +typedef struct _DMUS_SCRIPT_ERRORINFO +{ + DWORD dwSize; /* Size of this structure. */ + HRESULT hr; + ULONG ulLineNumber; + LONG ichCharPosition; + WCHAR wszSourceFile[DMUS_MAX_FILENAME]; + WCHAR wszSourceComponent[DMUS_MAX_FILENAME]; + WCHAR wszDescription[DMUS_MAX_FILENAME]; + WCHAR wszSourceLineText[DMUS_MAX_FILENAME]; +} DMUS_SCRIPT_ERRORINFO; + +/* Track configuration flags, used with IDirectMusicSegment8::SetTrackConfig() */ + +#define DMUS_TRACKCONFIG_OVERRIDE_ALL 1 /* This track should get parameters from this segment before controlling and primary tracks. */ +#define DMUS_TRACKCONFIG_OVERRIDE_PRIMARY 2 /* This track should get parameters from this segment before the primary segment tracks. */ +#define DMUS_TRACKCONFIG_FALLBACK 4 /* This track should get parameters from this segment if the primary and controlling segments don't succeed. */ +#define DMUS_TRACKCONFIG_CONTROL_ENABLED 8 /* GetParam() enabled for this track. */ +#define DMUS_TRACKCONFIG_PLAY_ENABLED 0x10 /* Play() enabled for this track. */ +#define DMUS_TRACKCONFIG_NOTIFICATION_ENABLED 0x20 /* Notifications enabled for this track. */ +#define DMUS_TRACKCONFIG_PLAY_CLOCKTIME 0x40 /* This track plays in clock time, not music time. */ +#define DMUS_TRACKCONFIG_PLAY_COMPOSE 0x80 /* This track should regenerate data each time it starts playing. */ +#define DMUS_TRACKCONFIG_LOOP_COMPOSE 0x100 /* This track should regenerate data each time it repeats. */ +#define DMUS_TRACKCONFIG_COMPOSING 0x200 /* This track is used to compose other tracks. */ +#define DMUS_TRACKCONFIG_CONTROL_PLAY 0x10000 /* This track, when played in a controlling segment, overrides playback of primary segment tracks. */ +#define DMUS_TRACKCONFIG_CONTROL_NOTIFICATION 0x20000 /* This track, when played in a controlling segment, overrides notification of primary segment tracks. */ +/* Additional track config flags for composing transitions */ +#define DMUS_TRACKCONFIG_TRANS1_FROMSEGSTART 0x400 /* Get track info from start of From segment */ +#define DMUS_TRACKCONFIG_TRANS1_FROMSEGCURRENT 0x800 /* Get track info from current place in From segment */ +#define DMUS_TRACKCONFIG_TRANS1_TOSEGSTART 0x1000 /* Get track info from start of To segment */ +#define DMUS_TRACKCONFIG_DEFAULT (DMUS_TRACKCONFIG_CONTROL_ENABLED | DMUS_TRACKCONFIG_PLAY_ENABLED | DMUS_TRACKCONFIG_NOTIFICATION_ENABLED) + +/* Get/SetParam structs for commands */ +/* PARAM structures, used by GetParam() and SetParam() */ +typedef struct _DMUS_COMMAND_PARAM +{ + BYTE bCommand; + BYTE bGrooveLevel; + BYTE bGrooveRange; + BYTE bRepeatMode; +} DMUS_COMMAND_PARAM; + +typedef struct _DMUS_COMMAND_PARAM_2 +{ + MUSIC_TIME mtTime; + BYTE bCommand; + BYTE bGrooveLevel; + BYTE bGrooveRange; + BYTE bRepeatMode; +} DMUS_COMMAND_PARAM_2; + +typedef IDirectMusicObject __RPC_FAR *LPDMUS_OBJECT; +typedef IDirectMusicLoader __RPC_FAR *LPDMUS_LOADER; +typedef IDirectMusicBand __RPC_FAR *LPDMUS_BAND; + +#define DMUSB_LOADED (1 << 0) /* Set when band has been loaded */ +#define DMUSB_DEFAULT (1 << 1) /* Set when band is default band for a style */ + +/*//////////////////////////////////////////////////////////////////// +// IDirectMusicBand */ +#undef INTERFACE +#define INTERFACE IDirectMusicBand +DECLARE_INTERFACE_(IDirectMusicBand, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicBand */ + STDMETHOD(CreateSegment) (THIS_ IDirectMusicSegment** ppSegment) PURE; + STDMETHOD(Download) (THIS_ IDirectMusicPerformance* pPerformance) PURE; + STDMETHOD(Unload) (THIS_ IDirectMusicPerformance* pPerformance) PURE; +}; + +typedef IDirectMusicBand IDirectMusicBand8; + +/*//////////////////////////////////////////////////////////////////// +// IDirectMusicObject */ +#undef INTERFACE +#define INTERFACE IDirectMusicObject +DECLARE_INTERFACE_(IDirectMusicObject, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicObject */ + STDMETHOD(GetDescriptor) (THIS_ LPDMUS_OBJECTDESC pDesc) PURE; + STDMETHOD(SetDescriptor) (THIS_ LPDMUS_OBJECTDESC pDesc) PURE; + STDMETHOD(ParseDescriptor) (THIS_ LPSTREAM pStream, + LPDMUS_OBJECTDESC pDesc) PURE; +}; + +typedef IDirectMusicObject IDirectMusicObject8; + +/*//////////////////////////////////////////////////////////////////// +// IDirectMusicLoader */ +#undef INTERFACE +#define INTERFACE IDirectMusicLoader +DECLARE_INTERFACE_(IDirectMusicLoader, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicLoader */ + STDMETHOD(GetObject) (THIS_ LPDMUS_OBJECTDESC pDesc, + REFIID riid, + LPVOID FAR *ppv) PURE; + STDMETHOD(SetObject) (THIS_ LPDMUS_OBJECTDESC pDesc) PURE; + STDMETHOD(SetSearchDirectory) (THIS_ REFGUID rguidClass, + WCHAR *pwzPath, + BOOL fClear) PURE; + STDMETHOD(ScanDirectory) (THIS_ REFGUID rguidClass, + WCHAR *pwzFileExtension, + WCHAR *pwzScanFileName) PURE; + STDMETHOD(CacheObject) (THIS_ IDirectMusicObject * pObject) PURE; + STDMETHOD(ReleaseObject) (THIS_ IDirectMusicObject * pObject) PURE; + STDMETHOD(ClearCache) (THIS_ REFGUID rguidClass) PURE; + STDMETHOD(EnableCache) (THIS_ REFGUID rguidClass, + BOOL fEnable) PURE; + STDMETHOD(EnumObject) (THIS_ REFGUID rguidClass, + DWORD dwIndex, + LPDMUS_OBJECTDESC pDesc) PURE; +}; + +/*//////////////////////////////////////////////////////////////////// +// IDirectMusicLoader8 */ +#undef INTERFACE +#define INTERFACE IDirectMusicLoader8 +DECLARE_INTERFACE_(IDirectMusicLoader8, IDirectMusicLoader) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicLoader */ + STDMETHOD(GetObject) (THIS_ LPDMUS_OBJECTDESC pDesc, + REFIID riid, + LPVOID FAR *ppv) PURE; + STDMETHOD(SetObject) (THIS_ LPDMUS_OBJECTDESC pDesc) PURE; + STDMETHOD(SetSearchDirectory) (THIS_ REFGUID rguidClass, + WCHAR *pwzPath, + BOOL fClear) PURE; + STDMETHOD(ScanDirectory) (THIS_ REFGUID rguidClass, + WCHAR *pwzFileExtension, + WCHAR *pwzScanFileName) PURE; + STDMETHOD(CacheObject) (THIS_ IDirectMusicObject * pObject) PURE; + STDMETHOD(ReleaseObject) (THIS_ IDirectMusicObject * pObject) PURE; + STDMETHOD(ClearCache) (THIS_ REFGUID rguidClass) PURE; + STDMETHOD(EnableCache) (THIS_ REFGUID rguidClass, + BOOL fEnable) PURE; + STDMETHOD(EnumObject) (THIS_ REFGUID rguidClass, + DWORD dwIndex, + LPDMUS_OBJECTDESC pDesc) PURE; + + /* IDirectMusicLoader8 */ + STDMETHOD_(void, CollectGarbage) (THIS) PURE; + STDMETHOD(ReleaseObjectByUnknown) (THIS_ IUnknown *pObject) PURE; + STDMETHOD(LoadObjectFromFile) (THIS_ REFGUID rguidClassID, + REFIID iidInterfaceID, + WCHAR *pwzFilePath, + void ** ppObject) PURE; +}; + +/* Stream object supports IDirectMusicGetLoader interface to access loader while file parsing. */ + +#undef INTERFACE +#define INTERFACE IDirectMusicGetLoader +DECLARE_INTERFACE_(IDirectMusicGetLoader, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicGetLoader */ + STDMETHOD(GetLoader) (THIS_ IDirectMusicLoader ** ppLoader) PURE; +}; + +typedef IDirectMusicGetLoader IDirectMusicGetLoader8; + +/*//////////////////////////////////////////////////////////////////// +// IDirectMusicSegment */ +#undef INTERFACE +#define INTERFACE IDirectMusicSegment +DECLARE_INTERFACE_(IDirectMusicSegment, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicSegment */ + STDMETHOD(GetLength) (THIS_ MUSIC_TIME* pmtLength) PURE; + STDMETHOD(SetLength) (THIS_ MUSIC_TIME mtLength) PURE; + STDMETHOD(GetRepeats) (THIS_ DWORD* pdwRepeats) PURE; + STDMETHOD(SetRepeats) (THIS_ DWORD dwRepeats) PURE; + STDMETHOD(GetDefaultResolution) (THIS_ DWORD* pdwResolution) PURE; + STDMETHOD(SetDefaultResolution) (THIS_ DWORD dwResolution) PURE; + STDMETHOD(GetTrack) (THIS_ REFGUID rguidType, + DWORD dwGroupBits, + DWORD dwIndex, + IDirectMusicTrack** ppTrack) PURE; + STDMETHOD(GetTrackGroup) (THIS_ IDirectMusicTrack* pTrack, + DWORD* pdwGroupBits) PURE; + STDMETHOD(InsertTrack) (THIS_ IDirectMusicTrack* pTrack, + DWORD dwGroupBits) PURE; + STDMETHOD(RemoveTrack) (THIS_ IDirectMusicTrack* pTrack) PURE; + STDMETHOD(InitPlay) (THIS_ IDirectMusicSegmentState** ppSegState, + IDirectMusicPerformance* pPerformance, + DWORD dwFlags) PURE; + STDMETHOD(GetGraph) (THIS_ IDirectMusicGraph** ppGraph) PURE; + STDMETHOD(SetGraph) (THIS_ IDirectMusicGraph* pGraph) PURE; + STDMETHOD(AddNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; + STDMETHOD(RemoveNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; + STDMETHOD(GetParam) (THIS_ REFGUID rguidType, + DWORD dwGroupBits, + DWORD dwIndex, + MUSIC_TIME mtTime, + MUSIC_TIME* pmtNext, + void* pParam) PURE; + STDMETHOD(SetParam) (THIS_ REFGUID rguidType, + DWORD dwGroupBits, + DWORD dwIndex, + MUSIC_TIME mtTime, + void* pParam) PURE; + STDMETHOD(Clone) (THIS_ MUSIC_TIME mtStart, + MUSIC_TIME mtEnd, + IDirectMusicSegment** ppSegment) PURE; + STDMETHOD(SetStartPoint) (THIS_ MUSIC_TIME mtStart) PURE; + STDMETHOD(GetStartPoint) (THIS_ MUSIC_TIME* pmtStart) PURE; + STDMETHOD(SetLoopPoints) (THIS_ MUSIC_TIME mtStart, + MUSIC_TIME mtEnd) PURE; + STDMETHOD(GetLoopPoints) (THIS_ MUSIC_TIME* pmtStart, + MUSIC_TIME* pmtEnd) PURE; + STDMETHOD(SetPChannelsUsed) (THIS_ DWORD dwNumPChannels, + DWORD* paPChannels) PURE; +}; + +/*//////////////////////////////////////////////////////////////////// +// IDirectMusicSegment8 */ +#undef INTERFACE +#define INTERFACE IDirectMusicSegment8 +DECLARE_INTERFACE_(IDirectMusicSegment8, IDirectMusicSegment) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicSegment */ + STDMETHOD(GetLength) (THIS_ MUSIC_TIME* pmtLength) PURE; + STDMETHOD(SetLength) (THIS_ MUSIC_TIME mtLength) PURE; + STDMETHOD(GetRepeats) (THIS_ DWORD* pdwRepeats) PURE; + STDMETHOD(SetRepeats) (THIS_ DWORD dwRepeats) PURE; + STDMETHOD(GetDefaultResolution) (THIS_ DWORD* pdwResolution) PURE; + STDMETHOD(SetDefaultResolution) (THIS_ DWORD dwResolution) PURE; + STDMETHOD(GetTrack) (THIS_ REFGUID rguidType, + DWORD dwGroupBits, + DWORD dwIndex, + IDirectMusicTrack** ppTrack) PURE; + STDMETHOD(GetTrackGroup) (THIS_ IDirectMusicTrack* pTrack, + DWORD* pdwGroupBits) PURE; + STDMETHOD(InsertTrack) (THIS_ IDirectMusicTrack* pTrack, + DWORD dwGroupBits) PURE; + STDMETHOD(RemoveTrack) (THIS_ IDirectMusicTrack* pTrack) PURE; + STDMETHOD(InitPlay) (THIS_ IDirectMusicSegmentState** ppSegState, + IDirectMusicPerformance* pPerformance, + DWORD dwFlags) PURE; + STDMETHOD(GetGraph) (THIS_ IDirectMusicGraph** ppGraph) PURE; + STDMETHOD(SetGraph) (THIS_ IDirectMusicGraph* pGraph) PURE; + STDMETHOD(AddNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; + STDMETHOD(RemoveNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; + STDMETHOD(GetParam) (THIS_ REFGUID rguidType, + DWORD dwGroupBits, + DWORD dwIndex, + MUSIC_TIME mtTime, + MUSIC_TIME* pmtNext, + void* pParam) PURE; + STDMETHOD(SetParam) (THIS_ REFGUID rguidType, + DWORD dwGroupBits, + DWORD dwIndex, + MUSIC_TIME mtTime, + void* pParam) PURE; + STDMETHOD(Clone) (THIS_ MUSIC_TIME mtStart, + MUSIC_TIME mtEnd, + IDirectMusicSegment** ppSegment) PURE; + STDMETHOD(SetStartPoint) (THIS_ MUSIC_TIME mtStart) PURE; + STDMETHOD(GetStartPoint) (THIS_ MUSIC_TIME* pmtStart) PURE; + STDMETHOD(SetLoopPoints) (THIS_ MUSIC_TIME mtStart, + MUSIC_TIME mtEnd) PURE; + STDMETHOD(GetLoopPoints) (THIS_ MUSIC_TIME* pmtStart, + MUSIC_TIME* pmtEnd) PURE; + STDMETHOD(SetPChannelsUsed) (THIS_ DWORD dwNumPChannels, + DWORD* paPChannels) PURE; + /* IDirectMusicSegment8 */ + STDMETHOD(SetTrackConfig) (THIS_ REFGUID rguidTrackClassID, /* Class ID of the type of track on which to set the configuration flags. */ + DWORD dwGroupBits, /* Group bits. */ + DWORD dwIndex, /* Nth track (or DMUS_SEG_ALLTRACKS) that matches class id and group id. */ + DWORD dwFlagsOn, /* DMUS_TRACKCONFIG_ flags to enable. */ + DWORD dwFlagsOff) PURE; /* DMUS_TRACKCONFIG_ flags to disable. */ + STDMETHOD(GetAudioPathConfig) (THIS_ IUnknown ** ppAudioPathConfig) PURE; + STDMETHOD(Compose) (THIS_ MUSIC_TIME mtTime, + IDirectMusicSegment* pFromSegment, + IDirectMusicSegment* pToSegment, + IDirectMusicSegment** ppComposedSegment) PURE; + STDMETHOD(Download) (THIS_ IUnknown *pAudioPath) PURE; + STDMETHOD(Unload) (THIS_ IUnknown *pAudioPath) PURE; +}; + +/*///////////////////////////////////////////////////////////////////// +// IDirectMusicSegmentState */ +#undef INTERFACE +#define INTERFACE IDirectMusicSegmentState +DECLARE_INTERFACE_(IDirectMusicSegmentState, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicSegmentState */ + STDMETHOD(GetRepeats) (THIS_ DWORD* pdwRepeats) PURE; + STDMETHOD(GetSegment ) (THIS_ IDirectMusicSegment** ppSegment) PURE; + STDMETHOD(GetStartTime) (THIS_ MUSIC_TIME* pmtStart) PURE; + STDMETHOD(GetSeek) (THIS_ MUSIC_TIME* pmtSeek) PURE; + STDMETHOD(GetStartPoint) (THIS_ MUSIC_TIME* pmtStart) PURE; +}; + +/*///////////////////////////////////////////////////////////////////// +// IDirectMusicSegmentState8 */ +#undef INTERFACE +#define INTERFACE IDirectMusicSegmentState8 +DECLARE_INTERFACE_(IDirectMusicSegmentState8, IDirectMusicSegmentState) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicSegmentState */ + STDMETHOD(GetRepeats) (THIS_ DWORD* pdwRepeats) PURE; + STDMETHOD(GetSegment ) (THIS_ IDirectMusicSegment** ppSegment) PURE; + STDMETHOD(GetStartTime) (THIS_ MUSIC_TIME* pmtStart) PURE; + STDMETHOD(GetSeek) (THIS_ MUSIC_TIME* pmtSeek) PURE; + STDMETHOD(GetStartPoint) (THIS_ MUSIC_TIME* pmtStart) PURE; + + /* IDirectMusicSegmentState8 */ + STDMETHOD(SetTrackConfig) (THIS_ REFGUID rguidTrackClassID, /* Class ID of the type of track on which to set the configuration flags. */ + DWORD dwGroupBits, /* Group bits. */ + DWORD dwIndex, /* Nth track (or DMUS_SEG_ALLTRACKS) that matches class id and group id. */ + DWORD dwFlagsOn, /* DMUS_TRACKCONFIG_ flags to enable. */ + DWORD dwFlagsOff) PURE; /* DMUS_TRACKCONFIG_ flags to disable. */ + STDMETHOD(GetObjectInPath) (THIS_ DWORD dwPChannel, /* PChannel to search. */ + DWORD dwStage, /* Which stage in the path. */ + DWORD dwBuffer, /* Which buffer to address, if more than one. */ + REFGUID guidObject, /* ClassID of object. */ + DWORD dwIndex, /* Which object of that class. */ + REFGUID iidInterface,/* Requested COM interface. */ + void ** ppObject) PURE; /* Pointer to interface. */ +}; + +/*//////////////////////////////////////////////////////////////////// +// IDirectMusicAudioPath */ +#undef INTERFACE +#define INTERFACE IDirectMusicAudioPath +DECLARE_INTERFACE_(IDirectMusicAudioPath, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicAudioPath */ + STDMETHOD(GetObjectInPath) (THIS_ DWORD dwPChannel, /* PChannel to search. */ + DWORD dwStage, /* Which stage in the path. */ + DWORD dwBuffer, /* Which buffer to address, if more than one. */ + REFGUID guidObject, /* ClassID of object. */ + DWORD dwIndex, /* Which object of that class. */ + REFGUID iidInterface,/* Requested COM interface. */ + void ** ppObject) PURE; /* Pointer to interface. */ + STDMETHOD(Activate) (THIS_ BOOL fActivate) PURE;/* True to activate, False to deactivate. */ + STDMETHOD(SetVolume) (THIS_ long lVolume, /* Gain, in 100ths of a dB. This must be negative (0 represents full volume.) */ + DWORD dwDuration) PURE;/* Duration of volume ramp in milliseconds. Note that 0 is more efficient. */ + STDMETHOD(ConvertPChannel) (THIS_ DWORD dwPChannelIn, /* Pchannel of source. */ + DWORD *pdwPChannelOut) PURE; /* Equivalent pchannel on performance. */ +}; + +typedef IDirectMusicAudioPath IDirectMusicAudioPath8; + +/*//////////////////////////////////////////////////////////////////// +// IDirectMusicPerformance */ +#undef INTERFACE +#define INTERFACE IDirectMusicPerformance +DECLARE_INTERFACE_(IDirectMusicPerformance, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicPerformance */ + STDMETHOD(Init) (THIS_ IDirectMusic** ppDirectMusic, + LPDIRECTSOUND pDirectSound, + HWND hWnd) PURE; + STDMETHOD(PlaySegment) (THIS_ IDirectMusicSegment* pSegment, + DWORD dwFlags, + __int64 i64StartTime, + IDirectMusicSegmentState** ppSegmentState) PURE; + STDMETHOD(Stop) (THIS_ IDirectMusicSegment* pSegment, + IDirectMusicSegmentState* pSegmentState, + MUSIC_TIME mtTime, + DWORD dwFlags) PURE; + STDMETHOD(GetSegmentState) (THIS_ IDirectMusicSegmentState** ppSegmentState, + MUSIC_TIME mtTime) PURE; + STDMETHOD(SetPrepareTime) (THIS_ DWORD dwMilliSeconds) PURE; + STDMETHOD(GetPrepareTime) (THIS_ DWORD* pdwMilliSeconds) PURE; + STDMETHOD(SetBumperLength) (THIS_ DWORD dwMilliSeconds) PURE; + STDMETHOD(GetBumperLength) (THIS_ DWORD* pdwMilliSeconds) PURE; + STDMETHOD(SendPMsg) (THIS_ DMUS_PMSG* pPMSG) PURE; + STDMETHOD(MusicToReferenceTime) (THIS_ MUSIC_TIME mtTime, + REFERENCE_TIME* prtTime) PURE; + STDMETHOD(ReferenceToMusicTime) (THIS_ REFERENCE_TIME rtTime, + MUSIC_TIME* pmtTime) PURE; + STDMETHOD(IsPlaying) (THIS_ IDirectMusicSegment* pSegment, + IDirectMusicSegmentState* pSegState) PURE; + STDMETHOD(GetTime) (THIS_ REFERENCE_TIME* prtNow, + MUSIC_TIME* pmtNow) PURE; + STDMETHOD(AllocPMsg) (THIS_ ULONG cb, + DMUS_PMSG** ppPMSG) PURE; + STDMETHOD(FreePMsg) (THIS_ DMUS_PMSG* pPMSG) PURE; + STDMETHOD(GetGraph) (THIS_ IDirectMusicGraph** ppGraph) PURE; + STDMETHOD(SetGraph) (THIS_ IDirectMusicGraph* pGraph) PURE; + STDMETHOD(SetNotificationHandle)(THIS_ HANDLE hNotification, + REFERENCE_TIME rtMinimum) PURE; + STDMETHOD(GetNotificationPMsg) (THIS_ DMUS_NOTIFICATION_PMSG** ppNotificationPMsg) PURE; + STDMETHOD(AddNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; + STDMETHOD(RemoveNotificationType)(THIS_ REFGUID rguidNotificationType) PURE; + STDMETHOD(AddPort) (THIS_ IDirectMusicPort* pPort) PURE; + STDMETHOD(RemovePort) (THIS_ IDirectMusicPort* pPort ) PURE; + STDMETHOD(AssignPChannelBlock) (THIS_ DWORD dwBlockNum, + IDirectMusicPort* pPort, + DWORD dwGroup ) PURE; + STDMETHOD(AssignPChannel) (THIS_ DWORD dwPChannel, + IDirectMusicPort* pPort, + DWORD dwGroup, + DWORD dwMChannel ) PURE; + STDMETHOD(PChannelInfo) (THIS_ DWORD dwPChannel, + IDirectMusicPort** ppPort, + DWORD* pdwGroup, + DWORD* pdwMChannel ) PURE; + STDMETHOD(DownloadInstrument) (THIS_ IDirectMusicInstrument* pInst, + DWORD dwPChannel, + IDirectMusicDownloadedInstrument** ppDownInst, + DMUS_NOTERANGE* pNoteRanges, + DWORD dwNumNoteRanges, + IDirectMusicPort** ppPort, + DWORD* pdwGroup, + DWORD* pdwMChannel ) PURE; + STDMETHOD(Invalidate) (THIS_ MUSIC_TIME mtTime, + DWORD dwFlags) PURE; + STDMETHOD(GetParam) (THIS_ REFGUID rguidType, + DWORD dwGroupBits, + DWORD dwIndex, + MUSIC_TIME mtTime, + MUSIC_TIME* pmtNext, + void* pParam) PURE; + STDMETHOD(SetParam) (THIS_ REFGUID rguidType, + DWORD dwGroupBits, + DWORD dwIndex, + MUSIC_TIME mtTime, + void* pParam) PURE; + STDMETHOD(GetGlobalParam) (THIS_ REFGUID rguidType, + void* pParam, + DWORD dwSize) PURE; + STDMETHOD(SetGlobalParam) (THIS_ REFGUID rguidType, + void* pParam, + DWORD dwSize) PURE; + STDMETHOD(GetLatencyTime) (THIS_ REFERENCE_TIME* prtTime) PURE; + STDMETHOD(GetQueueTime) (THIS_ REFERENCE_TIME* prtTime) PURE; + STDMETHOD(AdjustTime) (THIS_ REFERENCE_TIME rtAmount) PURE; + STDMETHOD(CloseDown) (THIS) PURE; + STDMETHOD(GetResolvedTime) (THIS_ REFERENCE_TIME rtTime, + REFERENCE_TIME* prtResolved, + DWORD dwTimeResolveFlags) PURE; + STDMETHOD(MIDIToMusic) (THIS_ BYTE bMIDIValue, + DMUS_CHORD_KEY* pChord, + BYTE bPlayMode, + BYTE bChordLevel, + WORD *pwMusicValue) PURE; + STDMETHOD(MusicToMIDI) (THIS_ WORD wMusicValue, + DMUS_CHORD_KEY* pChord, + BYTE bPlayMode, + BYTE bChordLevel, + BYTE *pbMIDIValue) PURE; + STDMETHOD(TimeToRhythm) (THIS_ MUSIC_TIME mtTime, + DMUS_TIMESIGNATURE *pTimeSig, + WORD *pwMeasure, + BYTE *pbBeat, + BYTE *pbGrid, + short *pnOffset) PURE; + STDMETHOD(RhythmToTime) (THIS_ WORD wMeasure, + BYTE bBeat, + BYTE bGrid, + short nOffset, + DMUS_TIMESIGNATURE *pTimeSig, + MUSIC_TIME *pmtTime) PURE; +}; + +/*//////////////////////////////////////////////////////////////////// +// IDirectMusicPerformance8 */ +#undef INTERFACE +#define INTERFACE IDirectMusicPerformance8 +DECLARE_INTERFACE_(IDirectMusicPerformance8, IDirectMusicPerformance) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicPerformance */ + STDMETHOD(Init) (THIS_ IDirectMusic** ppDirectMusic, + LPDIRECTSOUND pDirectSound, + HWND hWnd) PURE; + STDMETHOD(PlaySegment) (THIS_ IDirectMusicSegment* pSegment, + DWORD dwFlags, + __int64 i64StartTime, + IDirectMusicSegmentState** ppSegmentState) PURE; + STDMETHOD(Stop) (THIS_ IDirectMusicSegment* pSegment, + IDirectMusicSegmentState* pSegmentState, + MUSIC_TIME mtTime, + DWORD dwFlags) PURE; + STDMETHOD(GetSegmentState) (THIS_ IDirectMusicSegmentState** ppSegmentState, + MUSIC_TIME mtTime) PURE; + STDMETHOD(SetPrepareTime) (THIS_ DWORD dwMilliSeconds) PURE; + STDMETHOD(GetPrepareTime) (THIS_ DWORD* pdwMilliSeconds) PURE; + STDMETHOD(SetBumperLength) (THIS_ DWORD dwMilliSeconds) PURE; + STDMETHOD(GetBumperLength) (THIS_ DWORD* pdwMilliSeconds) PURE; + STDMETHOD(SendPMsg) (THIS_ DMUS_PMSG* pPMSG) PURE; + STDMETHOD(MusicToReferenceTime) (THIS_ MUSIC_TIME mtTime, + REFERENCE_TIME* prtTime) PURE; + STDMETHOD(ReferenceToMusicTime) (THIS_ REFERENCE_TIME rtTime, + MUSIC_TIME* pmtTime) PURE; + STDMETHOD(IsPlaying) (THIS_ IDirectMusicSegment* pSegment, + IDirectMusicSegmentState* pSegState) PURE; + STDMETHOD(GetTime) (THIS_ REFERENCE_TIME* prtNow, + MUSIC_TIME* pmtNow) PURE; + STDMETHOD(AllocPMsg) (THIS_ ULONG cb, + DMUS_PMSG** ppPMSG) PURE; + STDMETHOD(FreePMsg) (THIS_ DMUS_PMSG* pPMSG) PURE; + STDMETHOD(GetGraph) (THIS_ IDirectMusicGraph** ppGraph) PURE; + STDMETHOD(SetGraph) (THIS_ IDirectMusicGraph* pGraph) PURE; + STDMETHOD(SetNotificationHandle)(THIS_ HANDLE hNotification, + REFERENCE_TIME rtMinimum) PURE; + STDMETHOD(GetNotificationPMsg) (THIS_ DMUS_NOTIFICATION_PMSG** ppNotificationPMsg) PURE; + STDMETHOD(AddNotificationType) (THIS_ REFGUID rguidNotificationType) PURE; + STDMETHOD(RemoveNotificationType)(THIS_ REFGUID rguidNotificationType) PURE; + STDMETHOD(AddPort) (THIS_ IDirectMusicPort* pPort) PURE; + STDMETHOD(RemovePort) (THIS_ IDirectMusicPort* pPort ) PURE; + STDMETHOD(AssignPChannelBlock) (THIS_ DWORD dwBlockNum, + IDirectMusicPort* pPort, + DWORD dwGroup ) PURE; + STDMETHOD(AssignPChannel) (THIS_ DWORD dwPChannel, + IDirectMusicPort* pPort, + DWORD dwGroup, + DWORD dwMChannel ) PURE; + STDMETHOD(PChannelInfo) (THIS_ DWORD dwPChannel, + IDirectMusicPort** ppPort, + DWORD* pdwGroup, + DWORD* pdwMChannel ) PURE; + STDMETHOD(DownloadInstrument) (THIS_ IDirectMusicInstrument* pInst, + DWORD dwPChannel, + IDirectMusicDownloadedInstrument** ppDownInst, + DMUS_NOTERANGE* pNoteRanges, + DWORD dwNumNoteRanges, + IDirectMusicPort** ppPort, + DWORD* pdwGroup, + DWORD* pdwMChannel ) PURE; + STDMETHOD(Invalidate) (THIS_ MUSIC_TIME mtTime, + DWORD dwFlags) PURE; + STDMETHOD(GetParam) (THIS_ REFGUID rguidType, + DWORD dwGroupBits, + DWORD dwIndex, + MUSIC_TIME mtTime, + MUSIC_TIME* pmtNext, + void* pParam) PURE; + STDMETHOD(SetParam) (THIS_ REFGUID rguidType, + DWORD dwGroupBits, + DWORD dwIndex, + MUSIC_TIME mtTime, + void* pParam) PURE; + STDMETHOD(GetGlobalParam) (THIS_ REFGUID rguidType, + void* pParam, + DWORD dwSize) PURE; + STDMETHOD(SetGlobalParam) (THIS_ REFGUID rguidType, + void* pParam, + DWORD dwSize) PURE; + STDMETHOD(GetLatencyTime) (THIS_ REFERENCE_TIME* prtTime) PURE; + STDMETHOD(GetQueueTime) (THIS_ REFERENCE_TIME* prtTime) PURE; + STDMETHOD(AdjustTime) (THIS_ REFERENCE_TIME rtAmount) PURE; + STDMETHOD(CloseDown) (THIS) PURE; + STDMETHOD(GetResolvedTime) (THIS_ REFERENCE_TIME rtTime, + REFERENCE_TIME* prtResolved, + DWORD dwTimeResolveFlags) PURE; + STDMETHOD(MIDIToMusic) (THIS_ BYTE bMIDIValue, + DMUS_CHORD_KEY* pChord, + BYTE bPlayMode, + BYTE bChordLevel, + WORD *pwMusicValue) PURE; + STDMETHOD(MusicToMIDI) (THIS_ WORD wMusicValue, + DMUS_CHORD_KEY* pChord, + BYTE bPlayMode, + BYTE bChordLevel, + BYTE *pbMIDIValue) PURE; + STDMETHOD(TimeToRhythm) (THIS_ MUSIC_TIME mtTime, + DMUS_TIMESIGNATURE *pTimeSig, + WORD *pwMeasure, + BYTE *pbBeat, + BYTE *pbGrid, + short *pnOffset) PURE; + STDMETHOD(RhythmToTime) (THIS_ WORD wMeasure, + BYTE bBeat, + BYTE bGrid, + short nOffset, + DMUS_TIMESIGNATURE *pTimeSig, + MUSIC_TIME *pmtTime) PURE; + /* IDirectMusicPerformance8 */ + STDMETHOD(InitAudio) (THIS_ IDirectMusic** ppDirectMusic, /* Optional DirectMusic pointer. */ + IDirectSound** ppDirectSound, /* Optional DirectSound pointer. */ + HWND hWnd, /* HWND for DirectSound. */ + DWORD dwDefaultPathType, /* Requested default audio path type, also optional. */ + DWORD dwPChannelCount, /* Number of PChannels, if default audio path to be created. */ + DWORD dwFlags, /* DMUS_AUDIOF flags, if no pParams structure. */ + DMUS_AUDIOPARAMS *pParams) PURE; /* Optional initialization structure, defining required voices, buffers, etc. */ + STDMETHOD(PlaySegmentEx) (THIS_ IUnknown* pSource, /* Segment to play. */ + WCHAR *pwzSegmentName, /* Not supported in DX8. */ + IUnknown* pTransition, /* Optional template segment to compose transition with. */ + DWORD dwFlags, /* DMUS_SEGF_ flags. */ + __int64 i64StartTime, /* Time to start playback. */ + IDirectMusicSegmentState** ppSegmentState, /* Returned Segment State. */ + IUnknown *pFrom, /* Optional segmentstate or audiopath to replace. */ + IUnknown *pAudioPath) PURE; /* Optional audioPath to play on. */ + STDMETHOD(StopEx) (THIS_ IUnknown *pObjectToStop, /* Segstate, AudioPath, or Segment. */ + __int64 i64StopTime, + DWORD dwFlags) PURE; + STDMETHOD(ClonePMsg) (THIS_ DMUS_PMSG* pSourcePMSG, + DMUS_PMSG** ppCopyPMSG) PURE; + STDMETHOD(CreateAudioPath) (THIS_ IUnknown *pSourceConfig, /* Source configuration, from AudioPathConfig file. */ + BOOL fActivate, /* TRUE to activate on creation. */ + IDirectMusicAudioPath **ppNewPath) PURE; /* Returns created audiopath. */ + STDMETHOD(CreateStandardAudioPath)(THIS_ DWORD dwType, /* Type of path to create. */ + DWORD dwPChannelCount, /* How many PChannels to allocate for it. */ + BOOL fActivate, /* TRUE to activate on creation. */ + IDirectMusicAudioPath **ppNewPath) PURE; /* Returns created audiopath. */ + STDMETHOD(SetDefaultAudioPath) (THIS_ IDirectMusicAudioPath *pAudioPath) PURE; + STDMETHOD(GetDefaultAudioPath) (THIS_ IDirectMusicAudioPath **ppAudioPath) PURE; + STDMETHOD(GetParamEx) (THIS_ REFGUID rguidType, /* GetParam command ID. */ + DWORD dwTrackID, /* Virtual track ID of caller. */ + DWORD dwGroupBits, /* Group bits of caller. */ + DWORD dwIndex, /* Index to Nth parameter. */ + MUSIC_TIME mtTime, /* Time of requested parameter. */ + MUSIC_TIME* pmtNext, /* Returned delta to next parameter. */ + void* pParam) PURE; /* Data structure to fill with parameter. */ +}; + + + +/*//////////////////////////////////////////////////////////////////// +// IDirectMusicGraph */ +#undef INTERFACE +#define INTERFACE IDirectMusicGraph +DECLARE_INTERFACE_(IDirectMusicGraph, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicGraph */ + STDMETHOD(StampPMsg) (THIS_ DMUS_PMSG* pPMSG) PURE; + STDMETHOD(InsertTool) (THIS_ IDirectMusicTool* pTool, + DWORD* pdwPChannels, + DWORD cPChannels, + LONG lIndex) PURE; + STDMETHOD(GetTool) (THIS_ DWORD dwIndex, + IDirectMusicTool** ppTool) PURE; + STDMETHOD(RemoveTool) (THIS_ IDirectMusicTool* pTool) PURE; +}; + +typedef IDirectMusicGraph IDirectMusicGraph8; + + +/*///////////////////////////////////////////////////////////////////// +// IDirectMusicStyle */ +#undef INTERFACE +#define INTERFACE IDirectMusicStyle +DECLARE_INTERFACE_(IDirectMusicStyle, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicStyle */ + STDMETHOD(GetBand) (THIS_ WCHAR* pwszName, + IDirectMusicBand** ppBand) PURE; + STDMETHOD(EnumBand) (THIS_ DWORD dwIndex, + WCHAR *pwszName) PURE; + STDMETHOD(GetDefaultBand) (THIS_ IDirectMusicBand** ppBand) PURE; + STDMETHOD(EnumMotif) (THIS_ DWORD dwIndex, + WCHAR* pwszName) PURE; + STDMETHOD(GetMotif) (THIS_ WCHAR* pwszName, + IDirectMusicSegment** ppSegment) PURE; + STDMETHOD(GetDefaultChordMap) (THIS_ IDirectMusicChordMap** ppChordMap) PURE; + STDMETHOD(EnumChordMap) (THIS_ DWORD dwIndex, + WCHAR *pwszName) PURE; + STDMETHOD(GetChordMap) (THIS_ WCHAR* pwszName, + IDirectMusicChordMap** ppChordMap) PURE; + STDMETHOD(GetTimeSignature) (THIS_ DMUS_TIMESIGNATURE* pTimeSig) PURE; + STDMETHOD(GetEmbellishmentLength) (THIS_ DWORD dwType, + DWORD dwLevel, + DWORD* pdwMin, + DWORD* pdwMax) PURE; + STDMETHOD(GetTempo) (THIS_ double* pTempo) PURE; +}; + +/*///////////////////////////////////////////////////////////////////// +// IDirectMusicStyle8 */ +#undef INTERFACE +#define INTERFACE IDirectMusicStyle8 +DECLARE_INTERFACE_(IDirectMusicStyle8, IDirectMusicStyle) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicStyle */ + STDMETHOD(GetBand) (THIS_ WCHAR* pwszName, + IDirectMusicBand** ppBand) PURE; + STDMETHOD(EnumBand) (THIS_ DWORD dwIndex, + WCHAR *pwszName) PURE; + STDMETHOD(GetDefaultBand) (THIS_ IDirectMusicBand** ppBand) PURE; + STDMETHOD(EnumMotif) (THIS_ DWORD dwIndex, + WCHAR* pwszName) PURE; + STDMETHOD(GetMotif) (THIS_ WCHAR* pwszName, + IDirectMusicSegment** ppSegment) PURE; + STDMETHOD(GetDefaultChordMap) (THIS_ IDirectMusicChordMap** ppChordMap) PURE; + STDMETHOD(EnumChordMap) (THIS_ DWORD dwIndex, + WCHAR *pwszName) PURE; + STDMETHOD(GetChordMap) (THIS_ WCHAR* pwszName, + IDirectMusicChordMap** ppChordMap) PURE; + STDMETHOD(GetTimeSignature) (THIS_ DMUS_TIMESIGNATURE* pTimeSig) PURE; + STDMETHOD(GetEmbellishmentLength) (THIS_ DWORD dwType, + DWORD dwLevel, + DWORD* pdwMin, + DWORD* pdwMax) PURE; + STDMETHOD(GetTempo) (THIS_ double* pTempo) PURE; + + /* IDirectMusicStyle8 */ + STDMETHOD(EnumPattern) (THIS_ DWORD dwIndex, + DWORD dwPatternType, + WCHAR* pwszName) PURE; +}; + +/*///////////////////////////////////////////////////////////////////// +// IDirectMusicChordMap */ +#undef INTERFACE +#define INTERFACE IDirectMusicChordMap +DECLARE_INTERFACE_(IDirectMusicChordMap, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicChordMap */ + STDMETHOD(GetScale) (THIS_ DWORD* pdwScale) PURE; +}; + +typedef IDirectMusicChordMap IDirectMusicChordMap8; + +/*///////////////////////////////////////////////////////////////////// +// IDirectMusicComposer */ +#undef INTERFACE +#define INTERFACE IDirectMusicComposer +DECLARE_INTERFACE_(IDirectMusicComposer, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicComposer */ + STDMETHOD(ComposeSegmentFromTemplate) (THIS_ IDirectMusicStyle* pStyle, + IDirectMusicSegment* pTemplate, + WORD wActivity, + IDirectMusicChordMap* pChordMap, + IDirectMusicSegment** ppSegment) PURE; + STDMETHOD(ComposeSegmentFromShape) (THIS_ IDirectMusicStyle* pStyle, + WORD wNumMeasures, + WORD wShape, + WORD wActivity, + BOOL fIntro, + BOOL fEnd, + IDirectMusicChordMap* pChordMap, + IDirectMusicSegment** ppSegment ) PURE; + STDMETHOD(ComposeTransition) (THIS_ IDirectMusicSegment* pFromSeg, + IDirectMusicSegment* pToSeg, + MUSIC_TIME mtTime, + WORD wCommand, + DWORD dwFlags, + IDirectMusicChordMap* pChordMap, + IDirectMusicSegment** ppTransSeg) PURE; + STDMETHOD(AutoTransition) (THIS_ IDirectMusicPerformance* pPerformance, + IDirectMusicSegment* pToSeg, + WORD wCommand, + DWORD dwFlags, + IDirectMusicChordMap* pChordMap, + IDirectMusicSegment** ppTransSeg, + IDirectMusicSegmentState** ppToSegState, + IDirectMusicSegmentState** ppTransSegState) PURE; + STDMETHOD(ComposeTemplateFromShape) (THIS_ WORD wNumMeasures, + WORD wShape, + BOOL fIntro, + BOOL fEnd, + WORD wEndLength, + IDirectMusicSegment** ppTemplate) PURE; + STDMETHOD(ChangeChordMap) (THIS_ IDirectMusicSegment* pSegment, + BOOL fTrackScale, + IDirectMusicChordMap* pChordMap) PURE; +}; + +typedef IDirectMusicComposer IDirectMusicComposer8; + +/*///////////////////////////////////////////////////////////////////// +// IDirectMusicPatternTrack */ + +#undef INTERFACE +#define INTERFACE IDirectMusicPatternTrack +DECLARE_INTERFACE_(IDirectMusicPatternTrack, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicPatternTrack */ + STDMETHOD(CreateSegment) (THIS_ IDirectMusicStyle* pStyle, + IDirectMusicSegment** ppSegment) PURE; + STDMETHOD(SetVariation) (THIS_ IDirectMusicSegmentState* pSegState, + DWORD dwVariationFlags, + DWORD dwPart) PURE; + STDMETHOD(SetPatternByName) (THIS_ IDirectMusicSegmentState* pSegState, + WCHAR* wszName, + IDirectMusicStyle* pStyle, + DWORD dwPatternType, + DWORD* pdwLength) PURE; +}; + +typedef IDirectMusicPatternTrack IDirectMusicPatternTrack8; + +/*///////////////////////////////////////////////////////////////////// +// IDirectMusicScript */ + +#undef INTERFACE +#define INTERFACE IDirectMusicScript +DECLARE_INTERFACE_(IDirectMusicScript, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicScript */ + STDMETHOD(Init) (THIS_ IDirectMusicPerformance *pPerformance, + DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; + STDMETHOD(CallRoutine) (THIS_ WCHAR *pwszRoutineName, + DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; + STDMETHOD(SetVariableVariant) (THIS_ WCHAR *pwszVariableName, + VARIANT varValue, + BOOL fSetRef, + DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; + STDMETHOD(GetVariableVariant) (THIS_ WCHAR *pwszVariableName, + VARIANT *pvarValue, + DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; + STDMETHOD(SetVariableNumber) (THIS_ WCHAR *pwszVariableName, + LONG lValue, + DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; + STDMETHOD(GetVariableNumber) (THIS_ WCHAR *pwszVariableName, + LONG *plValue, + DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; + STDMETHOD(SetVariableObject) (THIS_ WCHAR *pwszVariableName, + IUnknown *punkValue, + DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; + STDMETHOD(GetVariableObject) (THIS_ WCHAR *pwszVariableName, + REFIID riid, + LPVOID FAR *ppv, + DMUS_SCRIPT_ERRORINFO *pErrorInfo) PURE; + STDMETHOD(EnumRoutine) (THIS_ DWORD dwIndex, + WCHAR *pwszName) PURE; + STDMETHOD(EnumVariable) (THIS_ DWORD dwIndex, + WCHAR *pwszName) PURE; +}; + +typedef IDirectMusicScript IDirectMusicScript8; + +/*///////////////////////////////////////////////////////////////////// +// IDirectMusicContainer */ + +#undef INTERFACE +#define INTERFACE IDirectMusicContainer +DECLARE_INTERFACE_(IDirectMusicContainer, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicContainer */ + STDMETHOD(EnumObject) (THIS_ REFGUID rguidClass, + DWORD dwIndex, + LPDMUS_OBJECTDESC pDesc, + WCHAR *pwszAlias) PURE; +}; + +typedef IDirectMusicContainer IDirectMusicContainer8; + +/* CLSID's */ +DEFINE_GUID(CLSID_DirectMusicPerformance,0xd2ac2881, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicSegment,0xd2ac2882, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicSegmentState,0xd2ac2883, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicGraph,0xd2ac2884, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicStyle,0xd2ac288a, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicChordMap,0xd2ac288f, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicComposer,0xd2ac2890, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicLoader,0xd2ac2892, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicBand,0x79ba9e00, 0xb6ee, 0x11d1, 0x86, 0xbe, 0x0, 0xc0, 0x4f, 0xbf, 0x8f, 0xef); + +/* New CLSID's for DX8 */ +DEFINE_GUID(CLSID_DirectMusicPatternTrack,0xd2ac2897, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(CLSID_DirectMusicScript,0x810b5013, 0xe88d, 0x11d2, 0x8b, 0xc1, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xb6); /* {810B5013-E88D-11d2-8BC1-00600893B1B6} */ +DEFINE_GUID(CLSID_DirectMusicContainer,0x9301e380, 0x1f22, 0x11d3, 0x82, 0x26, 0xd2, 0xfa, 0x76, 0x25, 0x5d, 0x47); +DEFINE_GUID(CLSID_DirectSoundWave,0x8a667154, 0xf9cb, 0x11d2, 0xad, 0x8a, 0x0, 0x60, 0xb0, 0x57, 0x5a, 0xbc); +DEFINE_GUID(CLSID_DirectMusicAudioPathConfig,0xee0b9ca0, 0xa81e, 0x11d3, 0x9b, 0xd1, 0x0, 0x80, 0xc7, 0x15, 0xa, 0x74); + +/* Special GUID for all object types. This is used by the loader. */ +DEFINE_GUID(GUID_DirectMusicAllTypes,0xd2ac2893, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Notification guids */ +DEFINE_GUID(GUID_NOTIFICATION_SEGMENT,0xd2ac2899, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(GUID_NOTIFICATION_PERFORMANCE,0x81f75bc5, 0x4e5d, 0x11d2, 0xbc, 0xc7, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); +DEFINE_GUID(GUID_NOTIFICATION_MEASUREANDBEAT,0xd2ac289a, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(GUID_NOTIFICATION_CHORD,0xd2ac289b, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(GUID_NOTIFICATION_COMMAND,0xd2ac289c, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(GUID_NOTIFICATION_RECOMPOSE, 0xd348372b, 0x945b, 0x45ae, 0xa5, 0x22, 0x45, 0xf, 0x12, 0x5b, 0x84, 0xa5); + +/* Track param type guids */ +/* Use to get/set a DMUS_COMMAND_PARAM param in the Command track */ +DEFINE_GUID(GUID_CommandParam,0xd2ac289d, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Use to get a DMUS_COMMAND_PARAM_2 param in the Command track */ +DEFINE_GUID(GUID_CommandParam2, 0x28f97ef7, 0x9538, 0x11d2, 0x97, 0xa9, 0x0, 0xc0, 0x4f, 0xa3, 0x6e, 0x58); + +/* Use to get/set a DMUS_COMMAND_PARAM_2 param to be used as the command following all commands in +the Command track (this information can't be saved) */ +DEFINE_GUID(GUID_CommandParamNext, 0x472afe7a, 0x281b, 0x11d3, 0x81, 0x7d, 0x0, 0xc0, 0x4f, 0xa3, 0x6e, 0x58); + +/* Use to get/set a DMUS_CHORD_PARAM param in the Chord track */ +DEFINE_GUID(GUID_ChordParam,0xd2ac289e, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Use to get a DMUS_RHYTHM_PARAM param in the Chord track */ +DEFINE_GUID(GUID_RhythmParam,0xd2ac289f, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Use to get/set an IDirectMusicStyle param in the Style track */ +DEFINE_GUID(GUID_IDirectMusicStyle,0xd2ac28a1, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Use to get a DMUS_TIMESIGNATURE param in the Style and TimeSig tracks */ +DEFINE_GUID(GUID_TimeSignature,0xd2ac28a4, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Use to get/set a DMUS_TEMPO_PARAM param in the Tempo track */ +DEFINE_GUID(GUID_TempoParam,0xd2ac28a5, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Use to get the next valid point in a segment at which it may start */ +DEFINE_GUID(GUID_Valid_Start_Time,0x7f6b1760, 0x1fdb, 0x11d3, 0x82, 0x26, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0); + +/* Use to get the next point in the currently playing primary segment at which a new segment may start */ +DEFINE_GUID(GUID_Play_Marker,0xd8761a41, 0x801a, 0x11d3, 0x9b, 0xd1, 0xda, 0xf7, 0xe1, 0xc3, 0xd8, 0x34); + +/* Use to get (GetParam) or add (SetParam) bands in the Band track */ +DEFINE_GUID(GUID_BandParam,0x2bb1938, 0xcb8b, 0x11d2, 0x8b, 0xb9, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xb6); +typedef struct _DMUS_BAND_PARAM +{ + MUSIC_TIME mtTimePhysical; /* Note: If this is a clock-time track, then this field is interpreted in the track's internal time format, which is the number of milliseconds after the beginning of playback. */ + IDirectMusicBand *pBand; +} DMUS_BAND_PARAM; + +/* Obsolete -- doesn't distinguish physical and logical time. Use GUID_BandParam instead. */ +DEFINE_GUID(GUID_IDirectMusicBand,0xd2ac28ac, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Use to get/set an IDirectMusicChordMap param in the ChordMap track */ +DEFINE_GUID(GUID_IDirectMusicChordMap,0xd2ac28ad, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Use to get/set a DMUS_MUTE_PARAM param in the Mute track */ +DEFINE_GUID(GUID_MuteParam,0xd2ac28af, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* These guids are used in IDirectMusicSegment::SetParam to tell the band track to perform various actions. + Some of these guids (where noted) also apply to wave tracks. + */ +/* Download bands/waves for the IDirectMusicSegment */ +DEFINE_GUID(GUID_Download,0xd2ac28a7, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Unload bands/waves for the IDirectMusicSegment */ +DEFINE_GUID(GUID_Unload,0xd2ac28a8, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Connect segment's bands to an IDirectMusicCollection */ +DEFINE_GUID(GUID_ConnectToDLSCollection, 0x1db1ae6b, 0xe92e, 0x11d1, 0xa8, 0xc5, 0x0, 0xc0, 0x4f, 0xa3, 0x72, 0x6e); + +/* Enable/disable autodownloading of bands/waves */ +DEFINE_GUID(GUID_Enable_Auto_Download,0xd2ac28a9, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(GUID_Disable_Auto_Download,0xd2ac28aa, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Clear all bands */ +DEFINE_GUID(GUID_Clear_All_Bands,0xd2ac28ab, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Set segment to manage all program changes, bank selects, etc. for simple playback of a standard MIDI file */ +DEFINE_GUID(GUID_StandardMIDIFile, 0x6621075, 0xe92e, 0x11d1, 0xa8, 0xc5, 0x0, 0xc0, 0x4f, 0xa3, 0x72, 0x6e); +/* For compatibility with beta releases... */ +#define GUID_IgnoreBankSelectForGM GUID_StandardMIDIFile + +/* Disable/enable param guids. Use these in SetParam calls to disable or enable sending + * specific PMsg types. + */ +DEFINE_GUID(GUID_DisableTimeSig, 0x45fc707b, 0x1db4, 0x11d2, 0xbc, 0xac, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); +DEFINE_GUID(GUID_EnableTimeSig, 0x45fc707c, 0x1db4, 0x11d2, 0xbc, 0xac, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); +DEFINE_GUID(GUID_DisableTempo, 0x45fc707d, 0x1db4, 0x11d2, 0xbc, 0xac, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); +DEFINE_GUID(GUID_EnableTempo, 0x45fc707e, 0x1db4, 0x11d2, 0xbc, 0xac, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); + +/* Used in SetParam calls for pattern-based tracks. A nonzero value seeds the random number +generator for variation selection; a value of zero reverts to the default behavior of +getting the seed from the system clock. +*/ +DEFINE_GUID(GUID_SeedVariations, 0x65b76fa5, 0xff37, 0x11d2, 0x81, 0x4e, 0x0, 0xc0, 0x4f, 0xa3, 0x6e, 0x58); + +/* Used to get the variations currently in effect across PChannels */ +DEFINE_GUID(GUID_Variations, 0x11f72cce, 0x26e6, 0x4ecd, 0xaf, 0x2e, 0xd6, 0x68, 0xe6, 0x67, 0x7, 0xd8); +typedef struct _DMUS_VARIATIONS_PARAM +{ + DWORD dwPChannelsUsed; /* number of PChannels in use */ + DWORD* padwPChannels; /* array of PChannels in use */ + DWORD* padwVariations; /* array of variations in effect for each PChannel */ +} DMUS_VARIATIONS_PARAM; + +/* Download bands/waves for the IDirectMusicSegment, passed an IDirectMusicAudioPath instead of an IDirectMusicPerformance */ +DEFINE_GUID(GUID_DownloadToAudioPath,0x9f2c0341, 0xc5c4, 0x11d3, 0x9b, 0xd1, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0); + +/* Unload bands/waves for the IDirectMusicSegment, passed an IDirectMusicAudioPath instead of an IDirectMusicPerformance */ +DEFINE_GUID(GUID_UnloadFromAudioPath,0x9f2c0342, 0xc5c4, 0x11d3, 0x9b, 0xd1, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0); + + +/* Global data guids */ +DEFINE_GUID(GUID_PerfMasterTempo,0xd2ac28b0, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(GUID_PerfMasterVolume,0xd2ac28b1, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(GUID_PerfMasterGrooveLevel,0xd2ac28b2, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(GUID_PerfAutoDownload, 0xfb09565b, 0x3631, 0x11d2, 0xbc, 0xb8, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); + +/* GUID for default GM/GS dls collection. */ +DEFINE_GUID(GUID_DefaultGMCollection, 0xf17e8673, 0xc3b4, 0x11d1, 0x87, 0xb, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* GUID to define default synth, placed in AudioPath configuration file. */ +DEFINE_GUID(GUID_Synth_Default,0x26bb9432, 0x45fe, 0x48d3, 0xa3, 0x75, 0x24, 0x72, 0xc5, 0xe3, 0xe7, 0x86); + +/* GUIDs to define default buffer configurations to place in AudioPath configuration file. */ +DEFINE_GUID(GUID_Buffer_Reverb,0x186cc541, 0xdb29, 0x11d3, 0x9b, 0xd1, 0x0, 0x80, 0xc7, 0x15, 0xa, 0x74); +DEFINE_GUID(GUID_Buffer_EnvReverb,0x186cc542, 0xdb29, 0x11d3, 0x9b, 0xd1, 0x0, 0x80, 0xc7, 0x15, 0xa, 0x74); +DEFINE_GUID(GUID_Buffer_Stereo,0x186cc545, 0xdb29, 0x11d3, 0x9b, 0xd1, 0x0, 0x80, 0xc7, 0x15, 0xa, 0x74); +DEFINE_GUID(GUID_Buffer_3D_Dry,0x186cc546, 0xdb29, 0x11d3, 0x9b, 0xd1, 0x0, 0x80, 0xc7, 0x15, 0xa, 0x74); +DEFINE_GUID(GUID_Buffer_Mono,0x186cc547, 0xdb29, 0x11d3, 0x9b, 0xd1, 0x0, 0x80, 0xc7, 0x15, 0xa, 0x74); + +/* IID's */ +DEFINE_GUID(IID_IDirectMusicLoader, 0x2ffaaca2, 0x5dca, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); +DEFINE_GUID(IID_IDirectMusicGetLoader,0x68a04844, 0xd13d, 0x11d1, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); +DEFINE_GUID(IID_IDirectMusicObject,0xd2ac28b5, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(IID_IDirectMusicSegment, 0xf96029a2, 0x4282, 0x11d2, 0x87, 0x17, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(IID_IDirectMusicSegmentState, 0xa3afdcc7, 0xd3ee, 0x11d1, 0xbc, 0x8d, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); +DEFINE_GUID(IID_IDirectMusicPerformance,0x7d43d03, 0x6523, 0x11d2, 0x87, 0x1d, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(IID_IDirectMusicGraph,0x2befc277, 0x5497, 0x11d2, 0xbc, 0xcb, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xeb); +DEFINE_GUID(IID_IDirectMusicStyle,0xd2ac28bd, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(IID_IDirectMusicChordMap,0xd2ac28be, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(IID_IDirectMusicComposer,0xd2ac28bf, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); +DEFINE_GUID(IID_IDirectMusicBand,0xd2ac28c0, 0xb39b, 0x11d1, 0x87, 0x4, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Alternate interface IDs, available in DX7 release and after. */ +DEFINE_GUID(IID_IDirectMusicPerformance2,0x6fc2cae0, 0xbc78, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); +DEFINE_GUID(IID_IDirectMusicSegment2, 0xd38894d1, 0xc052, 0x11d2, 0x87, 0x2f, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd); + +/* Interface IDs for DX8 */ +/* changed interfaces (GUID only) */ +DEFINE_GUID(IID_IDirectMusicLoader8, 0x19e7c08c, 0xa44, 0x4e6a, 0xa1, 0x16, 0x59, 0x5a, 0x7c, 0xd5, 0xde, 0x8c); +DEFINE_GUID(IID_IDirectMusicPerformance8, 0x679c4137, 0xc62e, 0x4147, 0xb2, 0xb4, 0x9d, 0x56, 0x9a, 0xcb, 0x25, 0x4c); +DEFINE_GUID(IID_IDirectMusicSegment8,0xc6784488, 0x41a3, 0x418f, 0xaa, 0x15, 0xb3, 0x50, 0x93, 0xba, 0x42, 0xd4); +DEFINE_GUID(IID_IDirectMusicSegmentState8, 0xa50e4730, 0xae4, 0x48a7, 0x98, 0x39, 0xbc, 0x4, 0xbf, 0xe0, 0x77, 0x72); +DEFINE_GUID(IID_IDirectMusicStyle8, 0xfd24ad8a, 0xa260, 0x453d, 0xbf, 0x50, 0x6f, 0x93, 0x84, 0xf7, 0x9, 0x85); +/* new interfaces (GUID + alias) */ +DEFINE_GUID(IID_IDirectMusicPatternTrack, 0x51c22e10, 0xb49f, 0x46fc, 0xbe, 0xc2, 0xe6, 0x28, 0x8f, 0xb9, 0xed, 0xe6); +#define IID_IDirectMusicPatternTrack8 IID_IDirectMusicPatternTrack +DEFINE_GUID(IID_IDirectMusicScript, 0x2252373a, 0x5814, 0x489b, 0x82, 0x9, 0x31, 0xfe, 0xde, 0xba, 0xf1, 0x37); /* {2252373A-5814-489b-8209-31FEDEBAF137} */ +#define IID_IDirectMusicScript8 IID_IDirectMusicScript +DEFINE_GUID(IID_IDirectMusicContainer, 0x9301e386, 0x1f22, 0x11d3, 0x82, 0x26, 0xd2, 0xfa, 0x76, 0x25, 0x5d, 0x47); +#define IID_IDirectMusicContainer8 IID_IDirectMusicContainer +DEFINE_GUID(IID_IDirectMusicAudioPath,0xc87631f5, 0x23be, 0x4986, 0x88, 0x36, 0x5, 0x83, 0x2f, 0xcc, 0x48, 0xf9); +#define IID_IDirectMusicAudioPath8 IID_IDirectMusicAudioPath +/* unchanged interfaces (alias only) */ +#define IID_IDirectMusicGetLoader8 IID_IDirectMusicGetLoader +#define IID_IDirectMusicChordMap8 IID_IDirectMusicChordMap +#define IID_IDirectMusicGraph8 IID_IDirectMusicGraph +#define IID_IDirectMusicBand8 IID_IDirectMusicBand +#define IID_IDirectMusicObject8 IID_IDirectMusicObject +#define IID_IDirectMusicComposer8 IID_IDirectMusicComposer + + +#ifdef __cplusplus +}; /* extern "C" */ +#endif + +#include + +#endif /* #ifndef _DMUSICI_ */ diff --git a/src/dep/include/DXSDK/include/dmusics.h b/src/dep/include/DXSDK/include/dmusics.h index f90d3b8..8f1e45d 100644 --- a/src/dep/include/DXSDK/include/dmusics.h +++ b/src/dep/include/DXSDK/include/dmusics.h @@ -1,193 +1,193 @@ -/************************************************************************ -* * -* dmusics.h -- Definitions for created a DirectMusic software synth * -* * -* Copyright (c) Microsoft Corporation. All rights reserved. * -* * -************************************************************************/ - -#ifndef _DMUSICS_ -#define _DMUSICS_ - -#include "dmusicc.h" - -/* Software synths are enumerated from under this registry key. - */ -#define REGSTR_PATH_SOFTWARESYNTHS "Software\\Microsoft\\DirectMusic\\SoftwareSynths" - -interface IDirectMusicSynth; -interface IDirectMusicSynthSink; - -#ifndef __cplusplus -typedef interface IDirectMusicSynth IDirectMusicSynth; -typedef interface IDirectMusicSynthSink IDirectMusicSynthSink; -#endif - -#ifndef _DMUS_VOICE_STATE_DEFINED -#define _DMUS_VOICE_STATE_DEFINED - -typedef struct _DMUS_VOICE_STATE -{ - BOOL bExists; - SAMPLE_POSITION spPosition; -} DMUS_VOICE_STATE; - -#endif /* _DMUS_VOICE_STATE_DEFINED */ - -/* IDirectMusicSynth::Refresh - * - * This is the last buffer of the stream. It may be a partial block. - */ -#define REFRESH_F_LASTBUFFER 0x00000001 - -#undef INTERFACE -#define INTERFACE IDirectMusicSynth -DECLARE_INTERFACE_(IDirectMusicSynth, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicSynth */ - STDMETHOD(Open) (THIS_ LPDMUS_PORTPARAMS pPortParams) PURE; - STDMETHOD(Close) (THIS) PURE; - STDMETHOD(SetNumChannelGroups) (THIS_ DWORD dwGroups) PURE; - STDMETHOD(Download) (THIS_ LPHANDLE phDownload, - LPVOID pvData, - LPBOOL pbFree ) PURE; - STDMETHOD(Unload) (THIS_ HANDLE hDownload, - HRESULT ( CALLBACK *lpFreeHandle)(HANDLE,HANDLE), - HANDLE hUserData ) PURE; - STDMETHOD(PlayBuffer) (THIS_ REFERENCE_TIME rt, - LPBYTE pbBuffer, - DWORD cbBuffer) PURE; - STDMETHOD(GetRunningStats) (THIS_ LPDMUS_SYNTHSTATS pStats) PURE; - STDMETHOD(GetPortCaps) (THIS_ LPDMUS_PORTCAPS pCaps) PURE; - STDMETHOD(SetMasterClock) (THIS_ IReferenceClock *pClock) PURE; - STDMETHOD(GetLatencyClock) (THIS_ IReferenceClock **ppClock) PURE; - STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE; - STDMETHOD(SetSynthSink) (THIS_ IDirectMusicSynthSink *pSynthSink) PURE; - STDMETHOD(Render) (THIS_ short *pBuffer, - DWORD dwLength, - LONGLONG llPosition) PURE; - STDMETHOD(SetChannelPriority) (THIS_ DWORD dwChannelGroup, - DWORD dwChannel, - DWORD dwPriority) PURE; - STDMETHOD(GetChannelPriority) (THIS_ DWORD dwChannelGroup, - DWORD dwChannel, - LPDWORD pdwPriority) PURE; - STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pWaveFormatEx, - LPDWORD pdwWaveFormatExSize) PURE; - STDMETHOD(GetAppend) (THIS_ DWORD* pdwAppend) PURE; -}; - -#undef INTERFACE - -#define INTERFACE IDirectMusicSynth8 -DECLARE_INTERFACE_(IDirectMusicSynth8, IDirectMusicSynth) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicSynth */ - STDMETHOD(Open) (THIS_ LPDMUS_PORTPARAMS pPortParams) PURE; - STDMETHOD(Close) (THIS) PURE; - STDMETHOD(SetNumChannelGroups) (THIS_ DWORD dwGroups) PURE; - STDMETHOD(Download) (THIS_ LPHANDLE phDownload, - LPVOID pvData, - LPBOOL pbFree ) PURE; - STDMETHOD(Unload) (THIS_ HANDLE hDownload, - HRESULT ( CALLBACK *lpFreeHandle)(HANDLE,HANDLE), - HANDLE hUserData ) PURE; - STDMETHOD(PlayBuffer) (THIS_ REFERENCE_TIME rt, - LPBYTE pbBuffer, - DWORD cbBuffer) PURE; - STDMETHOD(GetRunningStats) (THIS_ LPDMUS_SYNTHSTATS pStats) PURE; - STDMETHOD(GetPortCaps) (THIS_ LPDMUS_PORTCAPS pCaps) PURE; - STDMETHOD(SetMasterClock) (THIS_ IReferenceClock *pClock) PURE; - STDMETHOD(GetLatencyClock) (THIS_ IReferenceClock **ppClock) PURE; - STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE; - STDMETHOD(SetSynthSink) (THIS_ IDirectMusicSynthSink *pSynthSink) PURE; - STDMETHOD(Render) (THIS_ short *pBuffer, - DWORD dwLength, - LONGLONG llPosition) PURE; - STDMETHOD(SetChannelPriority) (THIS_ DWORD dwChannelGroup, - DWORD dwChannel, - DWORD dwPriority) PURE; - STDMETHOD(GetChannelPriority) (THIS_ DWORD dwChannelGroup, - DWORD dwChannel, - LPDWORD pdwPriority) PURE; - STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pWaveFormatEx, - LPDWORD pdwWaveFormatExSize) PURE; - STDMETHOD(GetAppend) (THIS_ DWORD* pdwAppend) PURE; - - /* IDirectMusicSynth8 */ - STDMETHOD(PlayVoice) (THIS_ REFERENCE_TIME rt, - DWORD dwVoiceId, - DWORD dwChannelGroup, - DWORD dwChannel, - DWORD dwDLId, - long prPitch, /* PREL not defined here */ - long vrVolume, /* VREL not defined here */ - SAMPLE_TIME stVoiceStart, - SAMPLE_TIME stLoopStart, - SAMPLE_TIME stLoopEnd) PURE; - - STDMETHOD(StopVoice) (THIS_ REFERENCE_TIME rt, - DWORD dwVoiceId ) PURE; - - STDMETHOD(GetVoiceState) (THIS_ DWORD dwVoice[], - DWORD cbVoice, - DMUS_VOICE_STATE dwVoiceState[] ) PURE; - STDMETHOD(Refresh) (THIS_ DWORD dwDownloadID, - DWORD dwFlags) PURE; - STDMETHOD(AssignChannelToBuses) (THIS_ DWORD dwChannelGroup, - DWORD dwChannel, - LPDWORD pdwBuses, - DWORD cBuses) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirectMusicSynthSink -DECLARE_INTERFACE_(IDirectMusicSynthSink, IUnknown) -{ - /* IUnknown */ - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectMusicSynthSink */ - STDMETHOD(Init) (THIS_ IDirectMusicSynth *pSynth) PURE; - STDMETHOD(SetMasterClock) (THIS_ IReferenceClock *pClock) PURE; - STDMETHOD(GetLatencyClock) (THIS_ IReferenceClock **ppClock) PURE; - STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE; - STDMETHOD(SampleToRefTime) (THIS_ LONGLONG llSampleTime, - REFERENCE_TIME *prfTime) PURE; - STDMETHOD(RefTimeToSample) (THIS_ REFERENCE_TIME rfTime, - LONGLONG *pllSampleTime) PURE; - STDMETHOD(SetDirectSound) (THIS_ LPDIRECTSOUND pDirectSound, - LPDIRECTSOUNDBUFFER pDirectSoundBuffer) PURE; - STDMETHOD(GetDesiredBufferSize) (THIS_ LPDWORD pdwBufferSizeInSamples) PURE; -}; - -DEFINE_GUID(IID_IDirectMusicSynth, 0x9823661, 0x5c85, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); -DEFINE_GUID(IID_IDirectMusicSynth8,0x53cab625, 0x2711, 0x4c9f, 0x9d, 0xe7, 0x1b, 0x7f, 0x92, 0x5f, 0x6f, 0xc8); -DEFINE_GUID(IID_IDirectMusicSynthSink,0x9823663, 0x5c85, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); - -/* Property Set GUID_DMUS_PROP_SetSynthSink - * - * Item 0: An IUnknown on which the port can QueryInterface for a user-mode synth sink. - */ -DEFINE_GUID(GUID_DMUS_PROP_SetSynthSink,0x0a3a5ba5, 0x37b6, 0x11d2, 0xb9, 0xf9, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); - -/* Property Set GUID_DMUS_PROP_SinkUsesDSound - * - * Item 0: A DWORD boolean indicating whether or not the sink requires an IDirectSound interface. The - * default is FALSE if this property item is not implemented by the sink. - */ -DEFINE_GUID(GUID_DMUS_PROP_SinkUsesDSound, 0xbe208857, 0x8952, 0x11d2, 0xba, 0x1c, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); - -#endif +/************************************************************************ +* * +* dmusics.h -- Definitions for created a DirectMusic software synth * +* * +* Copyright (c) Microsoft Corporation. All rights reserved. * +* * +************************************************************************/ + +#ifndef _DMUSICS_ +#define _DMUSICS_ + +#include "dmusicc.h" + +/* Software synths are enumerated from under this registry key. + */ +#define REGSTR_PATH_SOFTWARESYNTHS "Software\\Microsoft\\DirectMusic\\SoftwareSynths" + +interface IDirectMusicSynth; +interface IDirectMusicSynthSink; + +#ifndef __cplusplus +typedef interface IDirectMusicSynth IDirectMusicSynth; +typedef interface IDirectMusicSynthSink IDirectMusicSynthSink; +#endif + +#ifndef _DMUS_VOICE_STATE_DEFINED +#define _DMUS_VOICE_STATE_DEFINED + +typedef struct _DMUS_VOICE_STATE +{ + BOOL bExists; + SAMPLE_POSITION spPosition; +} DMUS_VOICE_STATE; + +#endif /* _DMUS_VOICE_STATE_DEFINED */ + +/* IDirectMusicSynth::Refresh + * + * This is the last buffer of the stream. It may be a partial block. + */ +#define REFRESH_F_LASTBUFFER 0x00000001 + +#undef INTERFACE +#define INTERFACE IDirectMusicSynth +DECLARE_INTERFACE_(IDirectMusicSynth, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicSynth */ + STDMETHOD(Open) (THIS_ LPDMUS_PORTPARAMS pPortParams) PURE; + STDMETHOD(Close) (THIS) PURE; + STDMETHOD(SetNumChannelGroups) (THIS_ DWORD dwGroups) PURE; + STDMETHOD(Download) (THIS_ LPHANDLE phDownload, + LPVOID pvData, + LPBOOL pbFree ) PURE; + STDMETHOD(Unload) (THIS_ HANDLE hDownload, + HRESULT ( CALLBACK *lpFreeHandle)(HANDLE,HANDLE), + HANDLE hUserData ) PURE; + STDMETHOD(PlayBuffer) (THIS_ REFERENCE_TIME rt, + LPBYTE pbBuffer, + DWORD cbBuffer) PURE; + STDMETHOD(GetRunningStats) (THIS_ LPDMUS_SYNTHSTATS pStats) PURE; + STDMETHOD(GetPortCaps) (THIS_ LPDMUS_PORTCAPS pCaps) PURE; + STDMETHOD(SetMasterClock) (THIS_ IReferenceClock *pClock) PURE; + STDMETHOD(GetLatencyClock) (THIS_ IReferenceClock **ppClock) PURE; + STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE; + STDMETHOD(SetSynthSink) (THIS_ IDirectMusicSynthSink *pSynthSink) PURE; + STDMETHOD(Render) (THIS_ short *pBuffer, + DWORD dwLength, + LONGLONG llPosition) PURE; + STDMETHOD(SetChannelPriority) (THIS_ DWORD dwChannelGroup, + DWORD dwChannel, + DWORD dwPriority) PURE; + STDMETHOD(GetChannelPriority) (THIS_ DWORD dwChannelGroup, + DWORD dwChannel, + LPDWORD pdwPriority) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pWaveFormatEx, + LPDWORD pdwWaveFormatExSize) PURE; + STDMETHOD(GetAppend) (THIS_ DWORD* pdwAppend) PURE; +}; + +#undef INTERFACE + +#define INTERFACE IDirectMusicSynth8 +DECLARE_INTERFACE_(IDirectMusicSynth8, IDirectMusicSynth) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicSynth */ + STDMETHOD(Open) (THIS_ LPDMUS_PORTPARAMS pPortParams) PURE; + STDMETHOD(Close) (THIS) PURE; + STDMETHOD(SetNumChannelGroups) (THIS_ DWORD dwGroups) PURE; + STDMETHOD(Download) (THIS_ LPHANDLE phDownload, + LPVOID pvData, + LPBOOL pbFree ) PURE; + STDMETHOD(Unload) (THIS_ HANDLE hDownload, + HRESULT ( CALLBACK *lpFreeHandle)(HANDLE,HANDLE), + HANDLE hUserData ) PURE; + STDMETHOD(PlayBuffer) (THIS_ REFERENCE_TIME rt, + LPBYTE pbBuffer, + DWORD cbBuffer) PURE; + STDMETHOD(GetRunningStats) (THIS_ LPDMUS_SYNTHSTATS pStats) PURE; + STDMETHOD(GetPortCaps) (THIS_ LPDMUS_PORTCAPS pCaps) PURE; + STDMETHOD(SetMasterClock) (THIS_ IReferenceClock *pClock) PURE; + STDMETHOD(GetLatencyClock) (THIS_ IReferenceClock **ppClock) PURE; + STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE; + STDMETHOD(SetSynthSink) (THIS_ IDirectMusicSynthSink *pSynthSink) PURE; + STDMETHOD(Render) (THIS_ short *pBuffer, + DWORD dwLength, + LONGLONG llPosition) PURE; + STDMETHOD(SetChannelPriority) (THIS_ DWORD dwChannelGroup, + DWORD dwChannel, + DWORD dwPriority) PURE; + STDMETHOD(GetChannelPriority) (THIS_ DWORD dwChannelGroup, + DWORD dwChannel, + LPDWORD pdwPriority) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pWaveFormatEx, + LPDWORD pdwWaveFormatExSize) PURE; + STDMETHOD(GetAppend) (THIS_ DWORD* pdwAppend) PURE; + + /* IDirectMusicSynth8 */ + STDMETHOD(PlayVoice) (THIS_ REFERENCE_TIME rt, + DWORD dwVoiceId, + DWORD dwChannelGroup, + DWORD dwChannel, + DWORD dwDLId, + long prPitch, /* PREL not defined here */ + long vrVolume, /* VREL not defined here */ + SAMPLE_TIME stVoiceStart, + SAMPLE_TIME stLoopStart, + SAMPLE_TIME stLoopEnd) PURE; + + STDMETHOD(StopVoice) (THIS_ REFERENCE_TIME rt, + DWORD dwVoiceId ) PURE; + + STDMETHOD(GetVoiceState) (THIS_ DWORD dwVoice[], + DWORD cbVoice, + DMUS_VOICE_STATE dwVoiceState[] ) PURE; + STDMETHOD(Refresh) (THIS_ DWORD dwDownloadID, + DWORD dwFlags) PURE; + STDMETHOD(AssignChannelToBuses) (THIS_ DWORD dwChannelGroup, + DWORD dwChannel, + LPDWORD pdwBuses, + DWORD cBuses) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirectMusicSynthSink +DECLARE_INTERFACE_(IDirectMusicSynthSink, IUnknown) +{ + /* IUnknown */ + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectMusicSynthSink */ + STDMETHOD(Init) (THIS_ IDirectMusicSynth *pSynth) PURE; + STDMETHOD(SetMasterClock) (THIS_ IReferenceClock *pClock) PURE; + STDMETHOD(GetLatencyClock) (THIS_ IReferenceClock **ppClock) PURE; + STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE; + STDMETHOD(SampleToRefTime) (THIS_ LONGLONG llSampleTime, + REFERENCE_TIME *prfTime) PURE; + STDMETHOD(RefTimeToSample) (THIS_ REFERENCE_TIME rfTime, + LONGLONG *pllSampleTime) PURE; + STDMETHOD(SetDirectSound) (THIS_ LPDIRECTSOUND pDirectSound, + LPDIRECTSOUNDBUFFER pDirectSoundBuffer) PURE; + STDMETHOD(GetDesiredBufferSize) (THIS_ LPDWORD pdwBufferSizeInSamples) PURE; +}; + +DEFINE_GUID(IID_IDirectMusicSynth, 0x9823661, 0x5c85, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); +DEFINE_GUID(IID_IDirectMusicSynth8,0x53cab625, 0x2711, 0x4c9f, 0x9d, 0xe7, 0x1b, 0x7f, 0x92, 0x5f, 0x6f, 0xc8); +DEFINE_GUID(IID_IDirectMusicSynthSink,0x9823663, 0x5c85, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); + +/* Property Set GUID_DMUS_PROP_SetSynthSink + * + * Item 0: An IUnknown on which the port can QueryInterface for a user-mode synth sink. + */ +DEFINE_GUID(GUID_DMUS_PROP_SetSynthSink,0x0a3a5ba5, 0x37b6, 0x11d2, 0xb9, 0xf9, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); + +/* Property Set GUID_DMUS_PROP_SinkUsesDSound + * + * Item 0: A DWORD boolean indicating whether or not the sink requires an IDirectSound interface. The + * default is FALSE if this property item is not implemented by the sink. + */ +DEFINE_GUID(GUID_DMUS_PROP_SinkUsesDSound, 0xbe208857, 0x8952, 0x11d2, 0xba, 0x1c, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); + +#endif diff --git a/src/dep/include/DXSDK/include/dpaddr.h b/src/dep/include/DXSDK/include/dpaddr.h index f5097f4..6e3fccf 100644 --- a/src/dep/include/DXSDK/include/dpaddr.h +++ b/src/dep/include/DXSDK/include/dpaddr.h @@ -1,392 +1,392 @@ -/*==========================================================================; - * - * Copyright (C) 2000-2002 Microsoft Corporation. All Rights Reserved. - * - * File: dpaddr.h - * Content: DirectPlayAddress include file - ***************************************************************************/ - -#ifndef __DIRECTPLAYADDRESS__ -#define __DIRECTPLAYADDRESS__ - -#include // for DECLARE_INTERFACE_ and HRESULT - -#ifdef __cplusplus -extern "C" { -#endif - -#include "dplay8.h" - - - -/**************************************************************************** - * - * DirectPlay8Address CLSIDs - * - ****************************************************************************/ - -// {934A9523-A3CA-4bc5-ADA0-D6D95D979421} -DEFINE_GUID(CLSID_DirectPlay8Address, -0x934a9523, 0xa3ca, 0x4bc5, 0xad, 0xa0, 0xd6, 0xd9, 0x5d, 0x97, 0x94, 0x21); - - -/**************************************************************************** - * - * DirectPlay8Address Interface IIDs - * - ****************************************************************************/ - - -typedef REFIID DPNAREFIID; - -// {83783300-4063-4c8a-9DB3-82830A7FEB31} -DEFINE_GUID(IID_IDirectPlay8Address, -0x83783300, 0x4063, 0x4c8a, 0x9d, 0xb3, 0x82, 0x83, 0xa, 0x7f, 0xeb, 0x31); - -// {E5A0E990-2BAD-430b-87DA-A142CF75DE58} -DEFINE_GUID(IID_IDirectPlay8AddressIP, -0xe5a0e990, 0x2bad, 0x430b, 0x87, 0xda, 0xa1, 0x42, 0xcf, 0x75, 0xde, 0x58); - - - -/**************************************************************************** - * - * DirectPlay8Address Interface Pointer definitions - * - ****************************************************************************/ - -typedef struct IDirectPlay8Address *PDIRECTPLAY8ADDRESS, *LPDIRECTPLAY8ADDRESS; -typedef struct IDirectPlay8AddressIP *PDIRECTPLAY8ADDRESSIP, *LPDIRECTPLAY8ADDRESSIP; - - -/**************************************************************************** - * - * DirectPlay8Address Forward Declarations For External Types - * - ****************************************************************************/ - -typedef struct sockaddr SOCKADDR; - -/**************************************************************************** - * - * DirectPlay8Address Constants - * - ****************************************************************************/ -// -// Asynchronous operation flags -// -#define DPNA_DATATYPE_STRING 0x00000001 -#define DPNA_DATATYPE_DWORD 0x00000002 -#define DPNA_DATATYPE_GUID 0x00000003 -#define DPNA_DATATYPE_BINARY 0x00000004 -#define DPNA_DATATYPE_STRING_ANSI 0x00000005 - -#define DPNA_DPNSVR_PORT 6073 - -#define DPNA_INDEX_INVALID 0xFFFFFFFF - -/**************************************************************************** - * - * DirectPlay8Address Address Elements - * - ****************************************************************************/ - -#define DPNA_SEPARATOR_KEYVALUE L'=' -#define DPNA_SEPARATOR_USERDATA L'#' -#define DPNA_SEPARATOR_COMPONENT L';' -#define DPNA_ESCAPECHAR L'%' - -// Header -#define DPNA_HEADER L"x-directplay:/" - -// key names for address components -#define DPNA_KEY_NAT_RESOLVER L"natresolver" -#define DPNA_KEY_NAT_RESOLVER_USER_STRING L"natresolveruserstring" -#define DPNA_KEY_APPLICATION_INSTANCE L"applicationinstance" -#define DPNA_KEY_DEVICE L"device" -#define DPNA_KEY_HOSTNAME L"hostname" -#define DPNA_KEY_PORT L"port" -#define DPNA_KEY_NAMEINFO L"nameinfo" -#define DPNA_KEY_PROCESSOR L"processor" -#define DPNA_KEY_PROGRAM L"program" -#define DPNA_KEY_PROVIDER L"provider" -#define DPNA_KEY_SCOPE L"scope" -#define DPNA_KEY_TRAVERSALMODE L"traversalmode" -#define DPNA_KEY_BAUD L"baud" -#define DPNA_KEY_FLOWCONTROL L"flowcontrol" -#define DPNA_KEY_PARITY L"parity" -#define DPNA_KEY_PHONENUMBER L"phonenumber" -#define DPNA_KEY_STOPBITS L"stopbits" - -// values for baud rate -#define DPNA_BAUD_RATE_9600 9600 -#define DPNA_BAUD_RATE_14400 14400 -#define DPNA_BAUD_RATE_19200 19200 -#define DPNA_BAUD_RATE_38400 38400 -#define DPNA_BAUD_RATE_56000 56000 -#define DPNA_BAUD_RATE_57600 57600 -#define DPNA_BAUD_RATE_115200 115200 - -// values for stop bits -#define DPNA_STOP_BITS_ONE L"1" -#define DPNA_STOP_BITS_ONE_FIVE L"1.5" -#define DPNA_STOP_BITS_TWO L"2" - -// values for parity -#define DPNA_PARITY_NONE L"NONE" -#define DPNA_PARITY_EVEN L"EVEN" -#define DPNA_PARITY_ODD L"ODD" -#define DPNA_PARITY_MARK L"MARK" -#define DPNA_PARITY_SPACE L"SPACE" - -// values for flow control -#define DPNA_FLOW_CONTROL_NONE L"NONE" -#define DPNA_FLOW_CONTROL_XONXOFF L"XONXOFF" -#define DPNA_FLOW_CONTROL_RTS L"RTS" -#define DPNA_FLOW_CONTROL_DTR L"DTR" -#define DPNA_FLOW_CONTROL_RTSDTR L"RTSDTR" -// values for traversal mode -#define DPNA_TRAVERSALMODE_NONE 0 -#define DPNA_TRAVERSALMODE_PORTREQUIRED 1 -#define DPNA_TRAVERSALMODE_PORTRECOMMENDED 2 -// Shortcut values -// -// These can be used instead of the corresponding CLSID_DP8SP_XXXX guids -// -#define DPNA_VALUE_TCPIPPROVIDER L"IP" -#define DPNA_VALUE_IPXPROVIDER L"IPX" -#define DPNA_VALUE_MODEMPROVIDER L"MODEM" -#define DPNA_VALUE_SERIALPROVIDER L"SERIAL" - -//// ANSI DEFINITIONS - -// Header -#define DPNA_HEADER_A "x-directplay:/" -#define DPNA_SEPARATOR_KEYVALUE_A '=' -#define DPNA_SEPARATOR_USERDATA_A '#' -#define DPNA_SEPARATOR_COMPONENT_A ';' -#define DPNA_ESCAPECHAR_A '%' - -// key names for address components -#define DPNA_KEY_NAT_RESOLVER_A "natresolver" -#define DPNA_KEY_NAT_RESOLVER_USER_STRING_A "natresolveruserstring" -#define DPNA_KEY_APPLICATION_INSTANCE_A "applicationinstance" -#define DPNA_KEY_DEVICE_A "device" -#define DPNA_KEY_HOSTNAME_A "hostname" -#define DPNA_KEY_PORT_A "port" -#define DPNA_KEY_NAMEINFO_A "nameinfo" -#define DPNA_KEY_PROCESSOR_A "processor" -#define DPNA_KEY_PROGRAM_A "program" -#define DPNA_KEY_PROVIDER_A "provider" -#define DPNA_KEY_SCOPE_A "scope" -#define DPNA_KEY_TRAVERSALMODE_A "traversalmode" -#define DPNA_KEY_BAUD_A "baud" -#define DPNA_KEY_FLOWCONTROL_A "flowcontrol" -#define DPNA_KEY_PARITY_A "parity" -#define DPNA_KEY_PHONENUMBER_A "phonenumber" -#define DPNA_KEY_STOPBITS_A "stopbits" - -// values for stop bits -#define DPNA_STOP_BITS_ONE_A "1" -#define DPNA_STOP_BITS_ONE_FIVE_A "1.5" -#define DPNA_STOP_BITS_TWO_A "2" - -// values for parity -#define DPNA_PARITY_NONE_A "NONE" -#define DPNA_PARITY_EVEN_A "EVEN" -#define DPNA_PARITY_ODD_A "ODD" -#define DPNA_PARITY_MARK_A "MARK" -#define DPNA_PARITY_SPACE_A "SPACE" - -// values for flow control -#define DPNA_FLOW_CONTROL_NONE_A "NONE" -#define DPNA_FLOW_CONTROL_XONXOFF_A "XONXOFF" -#define DPNA_FLOW_CONTROL_RTS_A "RTS" -#define DPNA_FLOW_CONTROL_DTR_A "DTR" -#define DPNA_FLOW_CONTROL_RTSDTR_A "RTSDTR" -// Shortcut values -// -// These can be used instead of the corresponding CLSID_DP8SP_XXXX guids -// -#define DPNA_VALUE_TCPIPPROVIDER_A "IP" -#define DPNA_VALUE_IPXPROVIDER_A "IPX" -#define DPNA_VALUE_MODEMPROVIDER_A "MODEM" -#define DPNA_VALUE_SERIALPROVIDER_A "SERIAL" - -/**************************************************************************** - * - * DirectPlay8Address Functions - * - ****************************************************************************/ - - -/* - * - * This function is no longer supported. It is recommended that CoCreateInstance be used to create - * DirectPlay8 address objects. - * - * HRESULT WINAPI DirectPlay8AddressCreate( const GUID * pcIID, void **ppvInterface, IUnknown *pUnknown); - * - */ - - -/**************************************************************************** - * - * DirectPlay8Address Application Interfaces - * - ****************************************************************************/ - -// -// COM definition for IDirectPlay8Address Generic Interface -// -#undef INTERFACE // External COM Implementation -#define INTERFACE IDirectPlay8Address -DECLARE_INTERFACE_(IDirectPlay8Address,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ DPNAREFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /*** IDirectPlay8Address methods ***/ - STDMETHOD(BuildFromURLW)(THIS_ WCHAR *pwszSourceURL ) PURE; - STDMETHOD(BuildFromURLA)(THIS_ CHAR *pszSourceURL ) PURE; - STDMETHOD(Duplicate)(THIS_ PDIRECTPLAY8ADDRESS *ppdpaNewAddress ) PURE; - STDMETHOD(SetEqual)(THIS_ PDIRECTPLAY8ADDRESS pdpaAddress ) PURE; - STDMETHOD(IsEqual)(THIS_ PDIRECTPLAY8ADDRESS pdpaAddress ) PURE; - STDMETHOD(Clear)(THIS ) PURE; - STDMETHOD(GetURLW)(THIS_ WCHAR *pwszURL, PDWORD pdwNumChars ) PURE; - STDMETHOD(GetURLA)(THIS_ CHAR *pszURL, PDWORD pdwNumChars) PURE; - STDMETHOD(GetSP)(THIS_ GUID *pguidSP ) PURE; - STDMETHOD(GetUserData)(THIS_ void *pvUserData, PDWORD pdwBufferSize) PURE; - STDMETHOD(SetSP)(THIS_ const GUID * const pguidSP ) PURE; - STDMETHOD(SetUserData)(THIS_ const void * const pvUserData, const DWORD dwDataSize) PURE; - STDMETHOD(GetNumComponents)(THIS_ PDWORD pdwNumComponents ) PURE; - STDMETHOD(GetComponentByName)(THIS_ const WCHAR * const pwszName, void *pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType ) PURE; - STDMETHOD(GetComponentByIndex)(THIS_ const DWORD dwComponentID, WCHAR * pwszName, PDWORD pdwNameLen, void *pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType ) PURE; - STDMETHOD(AddComponent)(THIS_ const WCHAR * const pwszName, const void * const lpvData, const DWORD dwDataSize, const DWORD dwDataType ) PURE; - STDMETHOD(GetDevice)(THIS_ GUID * ) PURE; - STDMETHOD(SetDevice)(THIS_ const GUID * const) PURE; - STDMETHOD(BuildFromDPADDRESS)( THIS_ LPVOID pvAddress, DWORD dwDataSize ) PURE; -}; - -// -// COM definition for IDirectPlay8AddressIP Generic Interface -// -#undef INTERFACE // External COM Implementation -#define INTERFACE IDirectPlay8AddressIP -DECLARE_INTERFACE_(IDirectPlay8AddressIP,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ DPNAREFIID, PVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /*** IDirectPlay8AddressIP methods ***/ - - // Constructs a IDirectPlay8 TCP Address from a SOCKADDR structure - STDMETHOD(BuildFromSockAddr)(THIS_ const SOCKADDR * const ) PURE; - - // Constructs a TCP Address from a string (hostname) and port - STDMETHOD(BuildAddress)(THIS_ const WCHAR * const wszAddress, const USHORT usPort ) PURE; - - // Builds a local TCP Address - STDMETHOD(BuildLocalAddress)(THIS_ const GUID * const pguidAdapter, const USHORT usPort ) PURE; - - // Gets the address from the structure in SOCKADR format - STDMETHOD(GetSockAddress)(THIS_ SOCKADDR *, PDWORD ) PURE; - - // Gets the local afddress - STDMETHOD(GetLocalAddress)(THIS_ GUID *pguidAdapter, USHORT *pusPort ) PURE; - - // Gets the remote address - STDMETHOD(GetAddress)(THIS_ WCHAR *wszAddress, PDWORD pdwAddressLength, USHORT *psPort ) PURE; -}; - - -/**************************************************************************** - * - * IDirectPlay8 application interface macros - * - ****************************************************************************/ - -#if !defined(__cplusplus) || defined(CINTERFACE) - -#define IDirectPlay8Address_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlay8Address_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlay8Address_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlay8Address_BuildFromURLW(p,a) (p)->lpVtbl->BuildFromURLW(p,a) -#define IDirectPlay8Address_BuildFromURLA(p,a) (p)->lpVtbl->BuildFromURLA(p,a) -#define IDirectPlay8Address_Duplicate(p,a) (p)->lpVtbl->Duplicate(p,a) -#define IDirectPlay8Address_SetEqual(p,a) (p)->lpVtbl->SetEqual(p,a) -#define IDirectPlay8Address_IsEqual(p,a) (p)->lpVtbl->IsEqual(p,a) -#define IDirectPlay8Address_Clear(p) (p)->lpVtbl->Clear(p) -#define IDirectPlay8Address_GetURLW(p,a,b) (p)->lpVtbl->GetURLW(p,a,b) -#define IDirectPlay8Address_GetURLA(p,a,b) (p)->lpVtbl->GetURLA(p,a,b) -#define IDirectPlay8Address_GetSP(p,a) (p)->lpVtbl->GetSP(p,a) -#define IDirectPlay8Address_GetUserData(p,a,b) (p)->lpVtbl->GetUserData(p,a,b) -#define IDirectPlay8Address_SetSP(p,a) (p)->lpVtbl->SetSP(p,a) -#define IDirectPlay8Address_SetUserData(p,a,b) (p)->lpVtbl->SetUserData(p,a,b) -#define IDirectPlay8Address_GetNumComponents(p,a) (p)->lpVtbl->GetNumComponents(p,a) -#define IDirectPlay8Address_GetComponentByName(p,a,b,c,d) (p)->lpVtbl->GetComponentByName(p,a,b,c,d) -#define IDirectPlay8Address_GetComponentByIndex(p,a,b,c,d,e,f) (p)->lpVtbl->GetComponentByIndex(p,a,b,c,d,e,f) -#define IDirectPlay8Address_AddComponent(p,a,b,c,d) (p)->lpVtbl->AddComponent(p,a,b,c,d) -#define IDirectPlay8Address_SetDevice(p,a) (p)->lpVtbl->SetDevice(p,a) -#define IDirectPlay8Address_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirectPlay8Address_BuildFromDirectPlay4Address(p,a,b) (p)->lpVtbl->BuildFromDirectPlay4Address(p,a,b) - -#define IDirectPlay8AddressIP_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlay8AddressIP_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlay8AddressIP_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlay8AddressIP_BuildFromSockAddr(p,a) (p)->lpVtbl->BuildFromSockAddr(p,a) -#define IDirectPlay8AddressIP_BuildAddress(p,a,b) (p)->lpVtbl->BuildAddress(p,a,b) -#define IDirectPlay8AddressIP_BuildLocalAddress(p,a,b) (p)->lpVtbl->BuildLocalAddress(p,a,b) -#define IDirectPlay8AddressIP_GetSockAddress(p,a,b) (p)->lpVtbl->GetSockAddress(p,a,b) -#define IDirectPlay8AddressIP_GetLocalAddress(p,a,b) (p)->lpVtbl->GetLocalAddress(p,a,b) -#define IDirectPlay8AddressIP_GetAddress(p,a,b,c) (p)->lpVtbl->GetAddress(p,a,b,c) - -#else /* C++ */ - -#define IDirectPlay8Address_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlay8Address_AddRef(p) (p)->AddRef() -#define IDirectPlay8Address_Release(p) (p)->Release() -#define IDirectPlay8Address_BuildFromURLW(p,a) (p)->BuildFromURLW(a) -#define IDirectPlay8Address_BuildFromURLA(p,a) (p)->BuildFromURLA(a) -#define IDirectPlay8Address_Duplicate(p,a) (p)->Duplicate(a) -#define IDirectPlay8Address_SetEqual(p,a) (p)->SetEqual(a) -#define IDirectPlay8Address_IsEqual(p,a) (p)->IsEqual(a) -#define IDirectPlay8Address_Clear(p) (p)->Clear() -#define IDirectPlay8Address_GetURLW(p,a,b) (p)->GetURLW(a,b) -#define IDirectPlay8Address_GetURLA(p,a,b) (p)->GetURLA(a,b) -#define IDirectPlay8Address_GetSP(p,a) (p)->GetSP(a) -#define IDirectPlay8Address_GetUserData(p,a,b) (p)->GetUserData(a,b) -#define IDirectPlay8Address_SetSP(p,a) (p)->SetSP(a) -#define IDirectPlay8Address_SetUserData(p,a,b) (p)->SetUserData(a,b) -#define IDirectPlay8Address_GetNumComponents(p,a) (p)->GetNumComponents(a) -#define IDirectPlay8Address_GetComponentByName(p,a,b,c,d) (p)->GetComponentByName(a,b,c,d) -#define IDirectPlay8Address_GetComponentByIndex(p,a,b,c,d,e,f) (p)->GetComponentByIndex(a,b,c,d,e,f) -#define IDirectPlay8Address_AddComponent(p,a,b,c,d) (p)->AddComponent(a,b,c,d) -#define IDirectPlay8Address_SetDevice(p,a) (p)->SetDevice(a) -#define IDirectPlay8Address_GetDevice(p,a) (p)->GetDevice(a) -#define IDirectPlay8Address_BuildFromDirectPlay4Address(p,a,b) (p)->BuildFromDirectPlay4Address(a,b) - -#define IDirectPlay8AddressIP_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlay8AddressIP_AddRef(p) (p)->AddRef() -#define IDirectPlay8AddressIP_Release(p) (p)->Release() -#define IDirectPlay8AddressIP_BuildFromSockAddr(p,a) (p)->BuildFromSockAddr(a) -#define IDirectPlay8AddressIP_BuildAddress(p,a,b) (p)->BuildAddress(a,b) -#define IDirectPlay8AddressIP_BuildLocalAddress(p,a,b) (p)->BuildLocalAddress(a,b) -#define IDirectPlay8AddressIP_GetSockAddress(p,a,b) (p)->GetSockAddress(a,b) -#define IDirectPlay8AddressIP_GetLocalAddress(p,a,b) (p)->GetLocalAddress(a,b) -#define IDirectPlay8AddressIP_GetAddress(p,a,b,c) (p)->GetAddress(a,b,c) - -#endif - - -#ifdef __cplusplus -} -#endif - -#endif - - +/*==========================================================================; + * + * Copyright (C) 2000-2002 Microsoft Corporation. All Rights Reserved. + * + * File: dpaddr.h + * Content: DirectPlayAddress include file + ***************************************************************************/ + +#ifndef __DIRECTPLAYADDRESS__ +#define __DIRECTPLAYADDRESS__ + +#include // for DECLARE_INTERFACE_ and HRESULT + +#ifdef __cplusplus +extern "C" { +#endif + +#include "dplay8.h" + + + +/**************************************************************************** + * + * DirectPlay8Address CLSIDs + * + ****************************************************************************/ + +// {934A9523-A3CA-4bc5-ADA0-D6D95D979421} +DEFINE_GUID(CLSID_DirectPlay8Address, +0x934a9523, 0xa3ca, 0x4bc5, 0xad, 0xa0, 0xd6, 0xd9, 0x5d, 0x97, 0x94, 0x21); + + +/**************************************************************************** + * + * DirectPlay8Address Interface IIDs + * + ****************************************************************************/ + + +typedef REFIID DPNAREFIID; + +// {83783300-4063-4c8a-9DB3-82830A7FEB31} +DEFINE_GUID(IID_IDirectPlay8Address, +0x83783300, 0x4063, 0x4c8a, 0x9d, 0xb3, 0x82, 0x83, 0xa, 0x7f, 0xeb, 0x31); + +// {E5A0E990-2BAD-430b-87DA-A142CF75DE58} +DEFINE_GUID(IID_IDirectPlay8AddressIP, +0xe5a0e990, 0x2bad, 0x430b, 0x87, 0xda, 0xa1, 0x42, 0xcf, 0x75, 0xde, 0x58); + + + +/**************************************************************************** + * + * DirectPlay8Address Interface Pointer definitions + * + ****************************************************************************/ + +typedef struct IDirectPlay8Address *PDIRECTPLAY8ADDRESS, *LPDIRECTPLAY8ADDRESS; +typedef struct IDirectPlay8AddressIP *PDIRECTPLAY8ADDRESSIP, *LPDIRECTPLAY8ADDRESSIP; + + +/**************************************************************************** + * + * DirectPlay8Address Forward Declarations For External Types + * + ****************************************************************************/ + +typedef struct sockaddr SOCKADDR; + +/**************************************************************************** + * + * DirectPlay8Address Constants + * + ****************************************************************************/ +// +// Asynchronous operation flags +// +#define DPNA_DATATYPE_STRING 0x00000001 +#define DPNA_DATATYPE_DWORD 0x00000002 +#define DPNA_DATATYPE_GUID 0x00000003 +#define DPNA_DATATYPE_BINARY 0x00000004 +#define DPNA_DATATYPE_STRING_ANSI 0x00000005 + +#define DPNA_DPNSVR_PORT 6073 + +#define DPNA_INDEX_INVALID 0xFFFFFFFF + +/**************************************************************************** + * + * DirectPlay8Address Address Elements + * + ****************************************************************************/ + +#define DPNA_SEPARATOR_KEYVALUE L'=' +#define DPNA_SEPARATOR_USERDATA L'#' +#define DPNA_SEPARATOR_COMPONENT L';' +#define DPNA_ESCAPECHAR L'%' + +// Header +#define DPNA_HEADER L"x-directplay:/" + +// key names for address components +#define DPNA_KEY_NAT_RESOLVER L"natresolver" +#define DPNA_KEY_NAT_RESOLVER_USER_STRING L"natresolveruserstring" +#define DPNA_KEY_APPLICATION_INSTANCE L"applicationinstance" +#define DPNA_KEY_DEVICE L"device" +#define DPNA_KEY_HOSTNAME L"hostname" +#define DPNA_KEY_PORT L"port" +#define DPNA_KEY_NAMEINFO L"nameinfo" +#define DPNA_KEY_PROCESSOR L"processor" +#define DPNA_KEY_PROGRAM L"program" +#define DPNA_KEY_PROVIDER L"provider" +#define DPNA_KEY_SCOPE L"scope" +#define DPNA_KEY_TRAVERSALMODE L"traversalmode" +#define DPNA_KEY_BAUD L"baud" +#define DPNA_KEY_FLOWCONTROL L"flowcontrol" +#define DPNA_KEY_PARITY L"parity" +#define DPNA_KEY_PHONENUMBER L"phonenumber" +#define DPNA_KEY_STOPBITS L"stopbits" + +// values for baud rate +#define DPNA_BAUD_RATE_9600 9600 +#define DPNA_BAUD_RATE_14400 14400 +#define DPNA_BAUD_RATE_19200 19200 +#define DPNA_BAUD_RATE_38400 38400 +#define DPNA_BAUD_RATE_56000 56000 +#define DPNA_BAUD_RATE_57600 57600 +#define DPNA_BAUD_RATE_115200 115200 + +// values for stop bits +#define DPNA_STOP_BITS_ONE L"1" +#define DPNA_STOP_BITS_ONE_FIVE L"1.5" +#define DPNA_STOP_BITS_TWO L"2" + +// values for parity +#define DPNA_PARITY_NONE L"NONE" +#define DPNA_PARITY_EVEN L"EVEN" +#define DPNA_PARITY_ODD L"ODD" +#define DPNA_PARITY_MARK L"MARK" +#define DPNA_PARITY_SPACE L"SPACE" + +// values for flow control +#define DPNA_FLOW_CONTROL_NONE L"NONE" +#define DPNA_FLOW_CONTROL_XONXOFF L"XONXOFF" +#define DPNA_FLOW_CONTROL_RTS L"RTS" +#define DPNA_FLOW_CONTROL_DTR L"DTR" +#define DPNA_FLOW_CONTROL_RTSDTR L"RTSDTR" +// values for traversal mode +#define DPNA_TRAVERSALMODE_NONE 0 +#define DPNA_TRAVERSALMODE_PORTREQUIRED 1 +#define DPNA_TRAVERSALMODE_PORTRECOMMENDED 2 +// Shortcut values +// +// These can be used instead of the corresponding CLSID_DP8SP_XXXX guids +// +#define DPNA_VALUE_TCPIPPROVIDER L"IP" +#define DPNA_VALUE_IPXPROVIDER L"IPX" +#define DPNA_VALUE_MODEMPROVIDER L"MODEM" +#define DPNA_VALUE_SERIALPROVIDER L"SERIAL" + +//// ANSI DEFINITIONS + +// Header +#define DPNA_HEADER_A "x-directplay:/" +#define DPNA_SEPARATOR_KEYVALUE_A '=' +#define DPNA_SEPARATOR_USERDATA_A '#' +#define DPNA_SEPARATOR_COMPONENT_A ';' +#define DPNA_ESCAPECHAR_A '%' + +// key names for address components +#define DPNA_KEY_NAT_RESOLVER_A "natresolver" +#define DPNA_KEY_NAT_RESOLVER_USER_STRING_A "natresolveruserstring" +#define DPNA_KEY_APPLICATION_INSTANCE_A "applicationinstance" +#define DPNA_KEY_DEVICE_A "device" +#define DPNA_KEY_HOSTNAME_A "hostname" +#define DPNA_KEY_PORT_A "port" +#define DPNA_KEY_NAMEINFO_A "nameinfo" +#define DPNA_KEY_PROCESSOR_A "processor" +#define DPNA_KEY_PROGRAM_A "program" +#define DPNA_KEY_PROVIDER_A "provider" +#define DPNA_KEY_SCOPE_A "scope" +#define DPNA_KEY_TRAVERSALMODE_A "traversalmode" +#define DPNA_KEY_BAUD_A "baud" +#define DPNA_KEY_FLOWCONTROL_A "flowcontrol" +#define DPNA_KEY_PARITY_A "parity" +#define DPNA_KEY_PHONENUMBER_A "phonenumber" +#define DPNA_KEY_STOPBITS_A "stopbits" + +// values for stop bits +#define DPNA_STOP_BITS_ONE_A "1" +#define DPNA_STOP_BITS_ONE_FIVE_A "1.5" +#define DPNA_STOP_BITS_TWO_A "2" + +// values for parity +#define DPNA_PARITY_NONE_A "NONE" +#define DPNA_PARITY_EVEN_A "EVEN" +#define DPNA_PARITY_ODD_A "ODD" +#define DPNA_PARITY_MARK_A "MARK" +#define DPNA_PARITY_SPACE_A "SPACE" + +// values for flow control +#define DPNA_FLOW_CONTROL_NONE_A "NONE" +#define DPNA_FLOW_CONTROL_XONXOFF_A "XONXOFF" +#define DPNA_FLOW_CONTROL_RTS_A "RTS" +#define DPNA_FLOW_CONTROL_DTR_A "DTR" +#define DPNA_FLOW_CONTROL_RTSDTR_A "RTSDTR" +// Shortcut values +// +// These can be used instead of the corresponding CLSID_DP8SP_XXXX guids +// +#define DPNA_VALUE_TCPIPPROVIDER_A "IP" +#define DPNA_VALUE_IPXPROVIDER_A "IPX" +#define DPNA_VALUE_MODEMPROVIDER_A "MODEM" +#define DPNA_VALUE_SERIALPROVIDER_A "SERIAL" + +/**************************************************************************** + * + * DirectPlay8Address Functions + * + ****************************************************************************/ + + +/* + * + * This function is no longer supported. It is recommended that CoCreateInstance be used to create + * DirectPlay8 address objects. + * + * HRESULT WINAPI DirectPlay8AddressCreate( const GUID * pcIID, void **ppvInterface, IUnknown *pUnknown); + * + */ + + +/**************************************************************************** + * + * DirectPlay8Address Application Interfaces + * + ****************************************************************************/ + +// +// COM definition for IDirectPlay8Address Generic Interface +// +#undef INTERFACE // External COM Implementation +#define INTERFACE IDirectPlay8Address +DECLARE_INTERFACE_(IDirectPlay8Address,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ DPNAREFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /*** IDirectPlay8Address methods ***/ + STDMETHOD(BuildFromURLW)(THIS_ WCHAR *pwszSourceURL ) PURE; + STDMETHOD(BuildFromURLA)(THIS_ CHAR *pszSourceURL ) PURE; + STDMETHOD(Duplicate)(THIS_ PDIRECTPLAY8ADDRESS *ppdpaNewAddress ) PURE; + STDMETHOD(SetEqual)(THIS_ PDIRECTPLAY8ADDRESS pdpaAddress ) PURE; + STDMETHOD(IsEqual)(THIS_ PDIRECTPLAY8ADDRESS pdpaAddress ) PURE; + STDMETHOD(Clear)(THIS ) PURE; + STDMETHOD(GetURLW)(THIS_ WCHAR *pwszURL, PDWORD pdwNumChars ) PURE; + STDMETHOD(GetURLA)(THIS_ CHAR *pszURL, PDWORD pdwNumChars) PURE; + STDMETHOD(GetSP)(THIS_ GUID *pguidSP ) PURE; + STDMETHOD(GetUserData)(THIS_ void *pvUserData, PDWORD pdwBufferSize) PURE; + STDMETHOD(SetSP)(THIS_ const GUID * const pguidSP ) PURE; + STDMETHOD(SetUserData)(THIS_ const void * const pvUserData, const DWORD dwDataSize) PURE; + STDMETHOD(GetNumComponents)(THIS_ PDWORD pdwNumComponents ) PURE; + STDMETHOD(GetComponentByName)(THIS_ const WCHAR * const pwszName, void *pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType ) PURE; + STDMETHOD(GetComponentByIndex)(THIS_ const DWORD dwComponentID, WCHAR * pwszName, PDWORD pdwNameLen, void *pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType ) PURE; + STDMETHOD(AddComponent)(THIS_ const WCHAR * const pwszName, const void * const lpvData, const DWORD dwDataSize, const DWORD dwDataType ) PURE; + STDMETHOD(GetDevice)(THIS_ GUID * ) PURE; + STDMETHOD(SetDevice)(THIS_ const GUID * const) PURE; + STDMETHOD(BuildFromDPADDRESS)( THIS_ LPVOID pvAddress, DWORD dwDataSize ) PURE; +}; + +// +// COM definition for IDirectPlay8AddressIP Generic Interface +// +#undef INTERFACE // External COM Implementation +#define INTERFACE IDirectPlay8AddressIP +DECLARE_INTERFACE_(IDirectPlay8AddressIP,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ DPNAREFIID, PVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /*** IDirectPlay8AddressIP methods ***/ + + // Constructs a IDirectPlay8 TCP Address from a SOCKADDR structure + STDMETHOD(BuildFromSockAddr)(THIS_ const SOCKADDR * const ) PURE; + + // Constructs a TCP Address from a string (hostname) and port + STDMETHOD(BuildAddress)(THIS_ const WCHAR * const wszAddress, const USHORT usPort ) PURE; + + // Builds a local TCP Address + STDMETHOD(BuildLocalAddress)(THIS_ const GUID * const pguidAdapter, const USHORT usPort ) PURE; + + // Gets the address from the structure in SOCKADR format + STDMETHOD(GetSockAddress)(THIS_ SOCKADDR *, PDWORD ) PURE; + + // Gets the local afddress + STDMETHOD(GetLocalAddress)(THIS_ GUID *pguidAdapter, USHORT *pusPort ) PURE; + + // Gets the remote address + STDMETHOD(GetAddress)(THIS_ WCHAR *wszAddress, PDWORD pdwAddressLength, USHORT *psPort ) PURE; +}; + + +/**************************************************************************** + * + * IDirectPlay8 application interface macros + * + ****************************************************************************/ + +#if !defined(__cplusplus) || defined(CINTERFACE) + +#define IDirectPlay8Address_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlay8Address_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlay8Address_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlay8Address_BuildFromURLW(p,a) (p)->lpVtbl->BuildFromURLW(p,a) +#define IDirectPlay8Address_BuildFromURLA(p,a) (p)->lpVtbl->BuildFromURLA(p,a) +#define IDirectPlay8Address_Duplicate(p,a) (p)->lpVtbl->Duplicate(p,a) +#define IDirectPlay8Address_SetEqual(p,a) (p)->lpVtbl->SetEqual(p,a) +#define IDirectPlay8Address_IsEqual(p,a) (p)->lpVtbl->IsEqual(p,a) +#define IDirectPlay8Address_Clear(p) (p)->lpVtbl->Clear(p) +#define IDirectPlay8Address_GetURLW(p,a,b) (p)->lpVtbl->GetURLW(p,a,b) +#define IDirectPlay8Address_GetURLA(p,a,b) (p)->lpVtbl->GetURLA(p,a,b) +#define IDirectPlay8Address_GetSP(p,a) (p)->lpVtbl->GetSP(p,a) +#define IDirectPlay8Address_GetUserData(p,a,b) (p)->lpVtbl->GetUserData(p,a,b) +#define IDirectPlay8Address_SetSP(p,a) (p)->lpVtbl->SetSP(p,a) +#define IDirectPlay8Address_SetUserData(p,a,b) (p)->lpVtbl->SetUserData(p,a,b) +#define IDirectPlay8Address_GetNumComponents(p,a) (p)->lpVtbl->GetNumComponents(p,a) +#define IDirectPlay8Address_GetComponentByName(p,a,b,c,d) (p)->lpVtbl->GetComponentByName(p,a,b,c,d) +#define IDirectPlay8Address_GetComponentByIndex(p,a,b,c,d,e,f) (p)->lpVtbl->GetComponentByIndex(p,a,b,c,d,e,f) +#define IDirectPlay8Address_AddComponent(p,a,b,c,d) (p)->lpVtbl->AddComponent(p,a,b,c,d) +#define IDirectPlay8Address_SetDevice(p,a) (p)->lpVtbl->SetDevice(p,a) +#define IDirectPlay8Address_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirectPlay8Address_BuildFromDirectPlay4Address(p,a,b) (p)->lpVtbl->BuildFromDirectPlay4Address(p,a,b) + +#define IDirectPlay8AddressIP_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlay8AddressIP_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlay8AddressIP_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlay8AddressIP_BuildFromSockAddr(p,a) (p)->lpVtbl->BuildFromSockAddr(p,a) +#define IDirectPlay8AddressIP_BuildAddress(p,a,b) (p)->lpVtbl->BuildAddress(p,a,b) +#define IDirectPlay8AddressIP_BuildLocalAddress(p,a,b) (p)->lpVtbl->BuildLocalAddress(p,a,b) +#define IDirectPlay8AddressIP_GetSockAddress(p,a,b) (p)->lpVtbl->GetSockAddress(p,a,b) +#define IDirectPlay8AddressIP_GetLocalAddress(p,a,b) (p)->lpVtbl->GetLocalAddress(p,a,b) +#define IDirectPlay8AddressIP_GetAddress(p,a,b,c) (p)->lpVtbl->GetAddress(p,a,b,c) + +#else /* C++ */ + +#define IDirectPlay8Address_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlay8Address_AddRef(p) (p)->AddRef() +#define IDirectPlay8Address_Release(p) (p)->Release() +#define IDirectPlay8Address_BuildFromURLW(p,a) (p)->BuildFromURLW(a) +#define IDirectPlay8Address_BuildFromURLA(p,a) (p)->BuildFromURLA(a) +#define IDirectPlay8Address_Duplicate(p,a) (p)->Duplicate(a) +#define IDirectPlay8Address_SetEqual(p,a) (p)->SetEqual(a) +#define IDirectPlay8Address_IsEqual(p,a) (p)->IsEqual(a) +#define IDirectPlay8Address_Clear(p) (p)->Clear() +#define IDirectPlay8Address_GetURLW(p,a,b) (p)->GetURLW(a,b) +#define IDirectPlay8Address_GetURLA(p,a,b) (p)->GetURLA(a,b) +#define IDirectPlay8Address_GetSP(p,a) (p)->GetSP(a) +#define IDirectPlay8Address_GetUserData(p,a,b) (p)->GetUserData(a,b) +#define IDirectPlay8Address_SetSP(p,a) (p)->SetSP(a) +#define IDirectPlay8Address_SetUserData(p,a,b) (p)->SetUserData(a,b) +#define IDirectPlay8Address_GetNumComponents(p,a) (p)->GetNumComponents(a) +#define IDirectPlay8Address_GetComponentByName(p,a,b,c,d) (p)->GetComponentByName(a,b,c,d) +#define IDirectPlay8Address_GetComponentByIndex(p,a,b,c,d,e,f) (p)->GetComponentByIndex(a,b,c,d,e,f) +#define IDirectPlay8Address_AddComponent(p,a,b,c,d) (p)->AddComponent(a,b,c,d) +#define IDirectPlay8Address_SetDevice(p,a) (p)->SetDevice(a) +#define IDirectPlay8Address_GetDevice(p,a) (p)->GetDevice(a) +#define IDirectPlay8Address_BuildFromDirectPlay4Address(p,a,b) (p)->BuildFromDirectPlay4Address(a,b) + +#define IDirectPlay8AddressIP_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlay8AddressIP_AddRef(p) (p)->AddRef() +#define IDirectPlay8AddressIP_Release(p) (p)->Release() +#define IDirectPlay8AddressIP_BuildFromSockAddr(p,a) (p)->BuildFromSockAddr(a) +#define IDirectPlay8AddressIP_BuildAddress(p,a,b) (p)->BuildAddress(a,b) +#define IDirectPlay8AddressIP_BuildLocalAddress(p,a,b) (p)->BuildLocalAddress(a,b) +#define IDirectPlay8AddressIP_GetSockAddress(p,a,b) (p)->GetSockAddress(a,b) +#define IDirectPlay8AddressIP_GetLocalAddress(p,a,b) (p)->GetLocalAddress(a,b) +#define IDirectPlay8AddressIP_GetAddress(p,a,b,c) (p)->GetAddress(a,b,c) + +#endif + + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/dep/include/DXSDK/include/dplay.h b/src/dep/include/DXSDK/include/dplay.h index 402b852..d91c0a5 100644 --- a/src/dep/include/DXSDK/include/dplay.h +++ b/src/dep/include/DXSDK/include/dplay.h @@ -1,2154 +1,2154 @@ -/*==========================================================================; - * - * Copyright (C) 1994-1997 Microsoft Corporation. All Rights Reserved. - * - * File: dplay.h - * Content: DirectPlay include file - * - ***************************************************************************/ - -#ifndef __DPLAY_INCLUDED__ -#define __DPLAY_INCLUDED__ - -#include // for DECLARE_INTERFACE and HRESULT - -/* avoid warnings in MSVC at Level4 */ -#if _MSC_VER >= 1200 -#pragma warning(push) -#endif -#pragma warning(disable:4201) - - -/* - * Some types - */ - -#ifndef _WIN64 -#define DWORD_PTR DWORD -#endif - -typedef LPVOID (*LPRGLPVOID)[]; -typedef LPRGLPVOID PRGPVOID, LPRGPVOID, PRGLPVOID, PAPVOID, LPAPVOID, PALPVOID, LPALPVOID; - -#define VOL volatile -typedef VOID *VOL LPVOIDV; - - -#define _FACDP 0x877 -#define MAKE_DPHRESULT( code ) MAKE_HRESULT( 1, _FACDP, code ) - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * GUIDS used by DirectPlay objects - */ -DEFINE_GUID(IID_IDirectPlay2, 0x2b74f7c0, 0x9154, 0x11cf, 0xa9, 0xcd, 0x0, 0xaa, 0x0, 0x68, 0x86, 0xe3); -DEFINE_GUID(IID_IDirectPlay2A,0x9d460580, 0xa822, 0x11cf, 0x96, 0xc, 0x0, 0x80, 0xc7, 0x53, 0x4e, 0x82); - -DEFINE_GUID(IID_IDirectPlay3, 0x133efe40, 0x32dc, 0x11d0, 0x9c, 0xfb, 0x0, 0xa0, 0xc9, 0xa, 0x43, 0xcb); -DEFINE_GUID(IID_IDirectPlay3A,0x133efe41, 0x32dc, 0x11d0, 0x9c, 0xfb, 0x0, 0xa0, 0xc9, 0xa, 0x43, 0xcb); - -DEFINE_GUID(IID_IDirectPlay4, 0xab1c530, 0x4745, 0x11d1, 0xa7, 0xa1, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc); -DEFINE_GUID(IID_IDirectPlay4A,0xab1c531, 0x4745, 0x11d1, 0xa7, 0xa1, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc); - -// {D1EB6D20-8923-11d0-9D97-00A0C90A43CB} -DEFINE_GUID(CLSID_DirectPlay,0xd1eb6d20, 0x8923, 0x11d0, 0x9d, 0x97, 0x0, 0xa0, 0xc9, 0xa, 0x43, 0xcb); - -/* - * GUIDS used by Service Providers shipped with DirectPlay - * Use these to identify Service Provider returned by EnumConnections - */ - -// GUID for IPX service provider -// {685BC400-9D2C-11cf-A9CD-00AA006886E3} -DEFINE_GUID(DPSPGUID_IPX, -0x685bc400, 0x9d2c, 0x11cf, 0xa9, 0xcd, 0x0, 0xaa, 0x0, 0x68, 0x86, 0xe3); - -// GUID for TCP/IP service provider -// 36E95EE0-8577-11cf-960C-0080C7534E82 -DEFINE_GUID(DPSPGUID_TCPIP, -0x36E95EE0, 0x8577, 0x11cf, 0x96, 0xc, 0x0, 0x80, 0xc7, 0x53, 0x4e, 0x82); - -// GUID for Serial service provider -// {0F1D6860-88D9-11cf-9C4E-00A0C905425E} -DEFINE_GUID(DPSPGUID_SERIAL, -0xf1d6860, 0x88d9, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); - -// GUID for Modem service provider -// {44EAA760-CB68-11cf-9C4E-00A0C905425E} -DEFINE_GUID(DPSPGUID_MODEM, -0x44eaa760, 0xcb68, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); - -/**************************************************************************** - * - * DirectPlay Structures - * - * Various structures used to invoke DirectPlay. - * - ****************************************************************************/ - -#ifndef IDIRECTPLAY2_OR_GREATER -typedef struct IDirectPlay FAR *LPDIRECTPLAY; -#else -typedef struct IUnknown FAR *LPDIRECTPLAY; -#endif - -typedef struct IDirectPlay2 FAR *LPDIRECTPLAY2; -typedef struct IDirectPlay2 FAR *LPDIRECTPLAY2A; -typedef struct IDirectPlay2 IDirectPlay2A; - -typedef struct IDirectPlay3 FAR *LPDIRECTPLAY3; -typedef struct IDirectPlay3 FAR *LPDIRECTPLAY3A; -typedef struct IDirectPlay3 IDirectPlay3A; - -typedef struct IDirectPlay4 FAR *LPDIRECTPLAY4; -typedef struct IDirectPlay4 FAR *LPDIRECTPLAY4A; -typedef struct IDirectPlay4 IDirectPlay4A; - -/* - * DPID - * DirectPlay player and group ID - */ -typedef DWORD DPID, FAR *LPDPID; - -/* - * DPID that system messages come from - */ -#define DPID_SYSMSG 0 - -/* - * DPID representing all players in the session - */ -#define DPID_ALLPLAYERS 0 - -/* - * DPID representing the server player - */ -#define DPID_SERVERPLAYER 1 - - -/* - * DPID representing the maxiumum ID in the range of DPID's reserved for - * use by DirectPlay. - */ -#define DPID_RESERVEDRANGE 100 - -/* - * The player ID is unknown (used with e.g. DPSESSION_NOMESSAGEID) - */ -#define DPID_UNKNOWN 0xFFFFFFFF - -/* - * DPCAPS - * Used to obtain the capabilities of a DirectPlay object - */ -typedef struct -{ - DWORD dwSize; // Size of structure, in bytes - DWORD dwFlags; // DPCAPS_xxx flags - DWORD dwMaxBufferSize; // Maximum message size, in bytes, for this service provider - DWORD dwMaxQueueSize; // Obsolete. - DWORD dwMaxPlayers; // Maximum players/groups (local + remote) - DWORD dwHundredBaud; // Bandwidth in 100 bits per second units; - // i.e. 24 is 2400, 96 is 9600, etc. - DWORD dwLatency; // Estimated latency; 0 = unknown - DWORD dwMaxLocalPlayers; // Maximum # of locally created players allowed - DWORD dwHeaderLength; // Maximum header length, in bytes, on messages - // added by the service provider - DWORD dwTimeout; // Service provider's suggested timeout value - // This is how long DirectPlay will wait for - // responses to system messages -} DPCAPS, FAR *LPDPCAPS; - -/* - * This DirectPlay object is the session host. If the host exits the - * session, another application will become the host and receive a - * DPSYS_HOST system message. - */ -#define DPCAPS_ISHOST 0x00000002 - -/* - * The service provider bound to this DirectPlay object can optimize - * group messaging. - */ -#define DPCAPS_GROUPOPTIMIZED 0x00000008 - -/* - * The service provider bound to this DirectPlay object can optimize - * keep alives (see DPSESSION_KEEPALIVE) - */ -#define DPCAPS_KEEPALIVEOPTIMIZED 0x00000010 - -/* - * The service provider bound to this DirectPlay object can optimize - * guaranteed message delivery. - */ -#define DPCAPS_GUARANTEEDOPTIMIZED 0x00000020 - -/* - * This DirectPlay object supports guaranteed message delivery. - */ -#define DPCAPS_GUARANTEEDSUPPORTED 0x00000040 - -/* - * This DirectPlay object supports digital signing of messages. - */ -#define DPCAPS_SIGNINGSUPPORTED 0x00000080 - -/* - * This DirectPlay object supports encryption of messages. - */ -#define DPCAPS_ENCRYPTIONSUPPORTED 0x00000100 - -/* - * This DirectPlay player was created on this machine - */ -#define DPPLAYERCAPS_LOCAL 0x00000800 - -/* - * Current Open settings supports all forms of Cancel - */ -#define DPCAPS_ASYNCCANCELSUPPORTED 0x00001000 - -/* - * Current Open settings supports CancelAll, but not Cancel - */ -#define DPCAPS_ASYNCCANCELALLSUPPORTED 0x00002000 - -/* - * Current Open settings supports Send Timeouts for sends - */ -#define DPCAPS_SENDTIMEOUTSUPPORTED 0x00004000 - -/* - * Current Open settings supports send priority - */ -#define DPCAPS_SENDPRIORITYSUPPORTED 0x00008000 - -/* - * Current Open settings supports DPSEND_ASYNC flag - */ -#define DPCAPS_ASYNCSUPPORTED 0x00010000 - - -/* - * DPSESSIONDESC2 - * Used to describe the properties of a DirectPlay - * session instance - */ -typedef struct -{ - DWORD dwSize; // Size of structure - DWORD dwFlags; // DPSESSION_xxx flags - GUID guidInstance; // ID for the session instance - GUID guidApplication; // GUID of the DirectPlay application. - // GUID_NULL for all applications. - DWORD dwMaxPlayers; // Maximum # players allowed in session - DWORD dwCurrentPlayers; // Current # players in session (read only) - union - { // Name of the session - LPWSTR lpszSessionName; // Unicode - LPSTR lpszSessionNameA; // ANSI - }; - union - { // Password of the session (optional) - LPWSTR lpszPassword; // Unicode - LPSTR lpszPasswordA; // ANSI - }; - DWORD_PTR dwReserved1; // Reserved for future MS use. - DWORD_PTR dwReserved2; - DWORD_PTR dwUser1; // For use by the application - DWORD_PTR dwUser2; - DWORD_PTR dwUser3; - DWORD_PTR dwUser4; -} DPSESSIONDESC2, FAR *LPDPSESSIONDESC2; - -typedef DPSESSIONDESC2 * VOL LPDPSESSIONDESC2_V; - -/* - * LPCDPSESSIONDESC2 - * A constant pointer to DPSESSIONDESC2 - */ -typedef const DPSESSIONDESC2 FAR *LPCDPSESSIONDESC2; - -/* - * Applications cannot create new players in this session. - */ -#define DPSESSION_NEWPLAYERSDISABLED 0x00000001 - -/* - * If the DirectPlay object that created the session, the host, - * quits, then the host will attempt to migrate to another - * DirectPlay object so that new players can continue to be created - * and new applications can join the session. - */ -#define DPSESSION_MIGRATEHOST 0x00000004 - -/* - * This flag tells DirectPlay not to set the idPlayerTo and idPlayerFrom - * fields in player messages. This cuts two DWORD's off the message - * overhead. - */ -#define DPSESSION_NOMESSAGEID 0x00000008 - - -/* - * This flag tells DirectPlay to not allow any new applications to - * join the session. Applications already in the session can still - * create new players. - */ -#define DPSESSION_JOINDISABLED 0x00000020 - -/* - * This flag tells DirectPlay to detect when remote players - * exit abnormally (e.g. their computer or modem gets unplugged) - */ -#define DPSESSION_KEEPALIVE 0x00000040 - -/* - * This flag tells DirectPlay not to send a message to all players - * when a players remote data changes - */ -#define DPSESSION_NODATAMESSAGES 0x00000080 - -/* - * This flag indicates that the session belongs to a secure server - * and needs user authentication - */ -#define DPSESSION_SECURESERVER 0x00000100 - -/* - * This flag indicates that the session is private and requirs a password - * for EnumSessions as well as Open. - */ -#define DPSESSION_PRIVATE 0x00000200 - -/* - * This flag indicates that the session requires a password for joining. - */ -#define DPSESSION_PASSWORDREQUIRED 0x00000400 - -/* - * This flag tells DirectPlay to route all messages through the server - */ -#define DPSESSION_MULTICASTSERVER 0x00000800 - -/* - * This flag tells DirectPlay to only download information about the - * DPPLAYER_SERVERPLAYER. - */ -#define DPSESSION_CLIENTSERVER 0x00001000 - -/* - * This flag tells DirectPlay to use the protocol built into dplay - * for reliability and statistics all the time. When this bit is - * set, only other sessions with this bit set can join or be joined. - */ -#define DPSESSION_DIRECTPLAYPROTOCOL 0x00002000 - -/* - * This flag tells DirectPlay that preserving order of received - * packets is not important, when using reliable delivery. This - * will allow messages to be indicated out of order if preceding - * messages have not yet arrived. Otherwise DPLAY will wait for - * earlier messages before delivering later reliable messages. - */ -#define DPSESSION_NOPRESERVEORDER 0x00004000 - - -/* - * This flag tells DirectPlay to optimize communication for latency - */ -#define DPSESSION_OPTIMIZELATENCY 0x00008000 - -/* - * This flag allows lobby launched games that aren't voice enabled - * to get voice capabilities. - */ -#define DPSESSION_ALLOWVOICERETRO 0x00010000 - -/* - * This flag supresses transmission of session desc changes. - * DPSESSION_NODATAMESSAGES was supposed to do that, but SetSessionDesc - * was ignoring the flag and some apps depended on the broken behavior, this - * flag allows applications to get the right behaviour without breaking apps depending - * on old broken behavior. - */ -#define DPSESSION_NOSESSIONDESCMESSAGES 0x00020000 - -/* - * DPNAME - * Used to hold the name of a DirectPlay entity - * like a player or a group - */ -typedef struct -{ - DWORD dwSize; // Size of structure - DWORD dwFlags; // Not used. Must be zero. - union - { // The short or friendly name - LPWSTR lpszShortName; // Unicode - LPSTR lpszShortNameA; // ANSI - }; - union - { // The long or formal name - LPWSTR lpszLongName; // Unicode - LPSTR lpszLongNameA; // ANSI - }; - -} DPNAME, FAR *LPDPNAME; - -/* - * LPCDPNAME - * A constant pointer to DPNAME - */ -typedef const DPNAME FAR *LPCDPNAME; - -/* - * DPCREDENTIALS - * Used to hold the user name and password of a DirectPlay user - */ -typedef struct -{ - DWORD dwSize; // Size of structure - DWORD dwFlags; // Not used. Must be zero. - union - { // User name of the account - LPWSTR lpszUsername; // Unicode - LPSTR lpszUsernameA; // ANSI - }; - union - { // Password of the account - LPWSTR lpszPassword; // Unicode - LPSTR lpszPasswordA; // ANSI - }; - union - { // Domain name of the account - LPWSTR lpszDomain; // Unicode - LPSTR lpszDomainA; // ANSI - }; -} DPCREDENTIALS, FAR *LPDPCREDENTIALS; - -typedef const DPCREDENTIALS FAR *LPCDPCREDENTIALS; - -/* - * DPSECURITYDESC - * Used to describe the security properties of a DirectPlay - * session instance - */ -typedef struct -{ - DWORD dwSize; // Size of structure - DWORD dwFlags; // Not used. Must be zero. - union - { // SSPI provider name - LPWSTR lpszSSPIProvider; // Unicode - LPSTR lpszSSPIProviderA; // ANSI - }; - union - { // CAPI provider name - LPWSTR lpszCAPIProvider; // Unicode - LPSTR lpszCAPIProviderA; // ANSI - }; - DWORD dwCAPIProviderType; // Crypto Service Provider type - DWORD dwEncryptionAlgorithm; // Encryption Algorithm type -} DPSECURITYDESC, FAR *LPDPSECURITYDESC; - -typedef const DPSECURITYDESC FAR *LPCDPSECURITYDESC; - -/* - * DPACCOUNTDESC - * Used to describe a user membership account - */ -typedef struct -{ - DWORD dwSize; // Size of structure - DWORD dwFlags; // Not used. Must be zero. - union - { // Account identifier - LPWSTR lpszAccountID; // Unicode - LPSTR lpszAccountIDA; // ANSI - }; -} DPACCOUNTDESC, FAR *LPDPACCOUNTDESC; - -typedef const DPACCOUNTDESC FAR *LPCDPACCOUNTDESC; - -/* - * LPCGUID - * A constant pointer to a guid - */ -typedef const GUID FAR *LPCGUID; - -/* - * DPLCONNECTION - * Used to hold all in the informaion needed to connect - * an application to a session or create a session - */ -typedef struct -{ - DWORD dwSize; // Size of this structure - DWORD dwFlags; // Flags specific to this structure - LPDPSESSIONDESC2 lpSessionDesc; // Pointer to session desc to use on connect - LPDPNAME lpPlayerName; // Pointer to Player name structure - GUID guidSP; // GUID of the DPlay SP to use - LPVOID lpAddress; // Address for service provider - DWORD dwAddressSize; // Size of address data -} DPLCONNECTION, FAR *LPDPLCONNECTION; - -/* - * LPCDPLCONNECTION - * A constant pointer to DPLCONNECTION - */ -typedef const DPLCONNECTION FAR *LPCDPLCONNECTION; - -/* - * DPCHAT - * Used to hold the a DirectPlay chat message - */ -typedef struct -{ - DWORD dwSize; - DWORD dwFlags; - union - { // Message string - LPWSTR lpszMessage; // Unicode - LPSTR lpszMessageA; // ANSI - }; -} DPCHAT, FAR * LPDPCHAT; - -/* - * SGBUFFER - * Scatter Gather Buffer used for SendEx - */ -typedef struct -{ - UINT len; // length of buffer data - PUCHAR pData; // pointer to buffer data -} SGBUFFER, *PSGBUFFER, FAR *LPSGBUFFER; - - -/**************************************************************************** - * - * Prototypes for DirectPlay callback functions - * - ****************************************************************************/ - -/* - * Callback for IDirectPlay2::EnumSessions - */ -typedef BOOL (FAR PASCAL * LPDPENUMSESSIONSCALLBACK2)( - LPCDPSESSIONDESC2 lpThisSD, - LPDWORD lpdwTimeOut, - DWORD dwFlags, - LPVOID lpContext ); - -/* - * This flag is set on the EnumSessions callback dwFlags parameter when - * the time out has occurred. There will be no session data for this - * callback. If *lpdwTimeOut is set to a non-zero value and the - * EnumSessionsCallback function returns TRUE then EnumSessions will - * continue waiting until the next timeout occurs. Timeouts are in - * milliseconds. - */ -#define DPESC_TIMEDOUT 0x00000001 - - -/* - * Callback for IDirectPlay2::EnumPlayers - * IDirectPlay2::EnumGroups - * IDirectPlay2::EnumGroupPlayers - */ -typedef BOOL (FAR PASCAL *LPDPENUMPLAYERSCALLBACK2)( - DPID dpId, - DWORD dwPlayerType, - LPCDPNAME lpName, - DWORD dwFlags, - LPVOID lpContext ); - - -/* - * Unicode callback for DirectPlayEnumerate - * This callback prototype will be used if compiling - * for Unicode strings - */ -typedef BOOL (FAR PASCAL * LPDPENUMDPCALLBACK)( - LPGUID lpguidSP, - LPWSTR lpSPName, - DWORD dwMajorVersion, - DWORD dwMinorVersion, - LPVOID lpContext); - -/* - * ANSI callback for DirectPlayEnumerate - * This callback prototype will be used if compiling - * for ANSI strings - */ -typedef BOOL (FAR PASCAL * LPDPENUMDPCALLBACKA)( - LPGUID lpguidSP, - LPSTR lpSPName, - DWORD dwMajorVersion, - DWORD dwMinorVersion, - LPVOID lpContext); - -/* - * Callback for IDirectPlay3(A)::EnumConnections - */ -typedef BOOL (FAR PASCAL * LPDPENUMCONNECTIONSCALLBACK)( - LPCGUID lpguidSP, - LPVOID lpConnection, - DWORD dwConnectionSize, - LPCDPNAME lpName, - DWORD dwFlags, - LPVOID lpContext); - - -/* - * API's - */ - -#ifdef UNICODE -#define DirectPlayEnumerate DirectPlayEnumerateW -#else -#define DirectPlayEnumerate DirectPlayEnumerateA -#endif // UNICODE - -extern HRESULT WINAPI DirectPlayEnumerateA( LPDPENUMDPCALLBACKA, LPVOID ); -extern HRESULT WINAPI DirectPlayEnumerateW( LPDPENUMDPCALLBACK, LPVOID ); -extern HRESULT WINAPI DirectPlayCreate( LPGUID lpGUID, LPDIRECTPLAY *lplpDP, IUnknown *pUnk); - -/**************************************************************************** - * - * IDirectPlay2 (and IDirectPlay2A) Interface - * - ****************************************************************************/ - -#undef INTERFACE -#define INTERFACE IDirectPlay2 -DECLARE_INTERFACE_( IDirectPlay2, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectPlay2 methods ***/ - STDMETHOD(AddPlayerToGroup) (THIS_ DPID, DPID) PURE; - STDMETHOD(Close) (THIS) PURE; - STDMETHOD(CreateGroup) (THIS_ LPDPID,LPDPNAME,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(CreatePlayer) (THIS_ LPDPID,LPDPNAME,HANDLE,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(DeletePlayerFromGroup)(THIS_ DPID,DPID) PURE; - STDMETHOD(DestroyGroup) (THIS_ DPID) PURE; - STDMETHOD(DestroyPlayer) (THIS_ DPID) PURE; - STDMETHOD(EnumGroupPlayers) (THIS_ DPID,LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; - STDMETHOD(EnumGroups) (THIS_ LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; - STDMETHOD(EnumPlayers) (THIS_ LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; - STDMETHOD(EnumSessions) (THIS_ LPDPSESSIONDESC2,DWORD,LPDPENUMSESSIONSCALLBACK2,LPVOID,DWORD) PURE; - STDMETHOD(GetCaps) (THIS_ LPDPCAPS,DWORD) PURE; - STDMETHOD(GetGroupData) (THIS_ DPID,LPVOID,LPDWORD,DWORD) PURE; - STDMETHOD(GetGroupName) (THIS_ DPID,LPVOID,LPDWORD) PURE; - STDMETHOD(GetMessageCount) (THIS_ DPID, LPDWORD) PURE; - STDMETHOD(GetPlayerAddress) (THIS_ DPID,LPVOID,LPDWORD) PURE; - STDMETHOD(GetPlayerCaps) (THIS_ DPID,LPDPCAPS,DWORD) PURE; - STDMETHOD(GetPlayerData) (THIS_ DPID,LPVOID,LPDWORD,DWORD) PURE; - STDMETHOD(GetPlayerName) (THIS_ DPID,LPVOID,LPDWORD) PURE; - STDMETHOD(GetSessionDesc) (THIS_ LPVOID,LPDWORD) PURE; - STDMETHOD(Initialize) (THIS_ LPGUID) PURE; - STDMETHOD(Open) (THIS_ LPDPSESSIONDESC2,DWORD) PURE; - STDMETHOD(Receive) (THIS_ LPDPID,LPDPID,DWORD,LPVOID,LPDWORD) PURE; - STDMETHOD(Send) (THIS_ DPID, DPID, DWORD, LPVOID, DWORD) PURE; - STDMETHOD(SetGroupData) (THIS_ DPID,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(SetGroupName) (THIS_ DPID,LPDPNAME,DWORD) PURE; - STDMETHOD(SetPlayerData) (THIS_ DPID,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(SetPlayerName) (THIS_ DPID,LPDPNAME,DWORD) PURE; - STDMETHOD(SetSessionDesc) (THIS_ LPDPSESSIONDESC2,DWORD) PURE; -}; - -/**************************************************************************** - * - * IDirectPlay2 interface macros - * - ****************************************************************************/ - -#if !defined(__cplusplus) || defined(CINTERFACE) - -#define IDirectPlay2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlay2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlay2_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlay2_AddPlayerToGroup(p,a,b) (p)->lpVtbl->AddPlayerToGroup(p,a,b) -#define IDirectPlay2_Close(p) (p)->lpVtbl->Close(p) -#define IDirectPlay2_CreateGroup(p,a,b,c,d,e) (p)->lpVtbl->CreateGroup(p,a,b,c,d,e) -#define IDirectPlay2_CreatePlayer(p,a,b,c,d,e,f) (p)->lpVtbl->CreatePlayer(p,a,b,c,d,e,f) -#define IDirectPlay2_DeletePlayerFromGroup(p,a,b) (p)->lpVtbl->DeletePlayerFromGroup(p,a,b) -#define IDirectPlay2_DestroyGroup(p,a) (p)->lpVtbl->DestroyGroup(p,a) -#define IDirectPlay2_DestroyPlayer(p,a) (p)->lpVtbl->DestroyPlayer(p,a) -#define IDirectPlay2_EnumGroupPlayers(p,a,b,c,d,e) (p)->lpVtbl->EnumGroupPlayers(p,a,b,c,d,e) -#define IDirectPlay2_EnumGroups(p,a,b,c,d) (p)->lpVtbl->EnumGroups(p,a,b,c,d) -#define IDirectPlay2_EnumPlayers(p,a,b,c,d) (p)->lpVtbl->EnumPlayers(p,a,b,c,d) -#define IDirectPlay2_EnumSessions(p,a,b,c,d,e) (p)->lpVtbl->EnumSessions(p,a,b,c,d,e) -#define IDirectPlay2_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) -#define IDirectPlay2_GetMessageCount(p,a,b) (p)->lpVtbl->GetMessageCount(p,a,b) -#define IDirectPlay2_GetGroupData(p,a,b,c,d) (p)->lpVtbl->GetGroupData(p,a,b,c,d) -#define IDirectPlay2_GetGroupName(p,a,b,c) (p)->lpVtbl->GetGroupName(p,a,b,c) -#define IDirectPlay2_GetPlayerAddress(p,a,b,c) (p)->lpVtbl->GetPlayerAddress(p,a,b,c) -#define IDirectPlay2_GetPlayerCaps(p,a,b,c) (p)->lpVtbl->GetPlayerCaps(p,a,b,c) -#define IDirectPlay2_GetPlayerData(p,a,b,c,d) (p)->lpVtbl->GetPlayerData(p,a,b,c,d) -#define IDirectPlay2_GetPlayerName(p,a,b,c) (p)->lpVtbl->GetPlayerName(p,a,b,c) -#define IDirectPlay2_GetSessionDesc(p,a,b) (p)->lpVtbl->GetSessionDesc(p,a,b) -#define IDirectPlay2_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#define IDirectPlay2_Open(p,a,b) (p)->lpVtbl->Open(p,a,b) -#define IDirectPlay2_Receive(p,a,b,c,d,e) (p)->lpVtbl->Receive(p,a,b,c,d,e) -#define IDirectPlay2_Send(p,a,b,c,d,e) (p)->lpVtbl->Send(p,a,b,c,d,e) -#define IDirectPlay2_SetGroupData(p,a,b,c,d) (p)->lpVtbl->SetGroupData(p,a,b,c,d) -#define IDirectPlay2_SetGroupName(p,a,b,c) (p)->lpVtbl->SetGroupName(p,a,b,c) -#define IDirectPlay2_SetPlayerData(p,a,b,c,d) (p)->lpVtbl->SetPlayerData(p,a,b,c,d) -#define IDirectPlay2_SetPlayerName(p,a,b,c) (p)->lpVtbl->SetPlayerName(p,a,b,c) -#define IDirectPlay2_SetSessionDesc(p,a,b) (p)->lpVtbl->SetSessionDesc(p,a,b) - -#else /* C++ */ - -#define IDirectPlay2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlay2_AddRef(p) (p)->AddRef() -#define IDirectPlay2_Release(p) (p)->Release() -#define IDirectPlay2_AddPlayerToGroup(p,a,b) (p)->AddPlayerToGroup(a,b) -#define IDirectPlay2_Close(p) (p)->Close() -#define IDirectPlay2_CreateGroup(p,a,b,c,d,e) (p)->CreateGroup(a,b,c,d,e) -#define IDirectPlay2_CreatePlayer(p,a,b,c,d,e,f) (p)->CreatePlayer(a,b,c,d,e,f) -#define IDirectPlay2_DeletePlayerFromGroup(p,a,b) (p)->DeletePlayerFromGroup(a,b) -#define IDirectPlay2_DestroyGroup(p,a) (p)->DestroyGroup(a) -#define IDirectPlay2_DestroyPlayer(p,a) (p)->DestroyPlayer(a) -#define IDirectPlay2_EnumGroupPlayers(p,a,b,c,d,e) (p)->EnumGroupPlayers(a,b,c,d,e) -#define IDirectPlay2_EnumGroups(p,a,b,c,d) (p)->EnumGroups(a,b,c,d) -#define IDirectPlay2_EnumPlayers(p,a,b,c,d) (p)->EnumPlayers(a,b,c,d) -#define IDirectPlay2_EnumSessions(p,a,b,c,d,e) (p)->EnumSessions(a,b,c,d,e) -#define IDirectPlay2_GetCaps(p,a,b) (p)->GetCaps(a,b) -#define IDirectPlay2_GetMessageCount(p,a,b) (p)->GetMessageCount(a,b) -#define IDirectPlay2_GetGroupData(p,a,b,c,d) (p)->GetGroupData(a,b,c,d) -#define IDirectPlay2_GetGroupName(p,a,b,c) (p)->GetGroupName(a,b,c) -#define IDirectPlay2_GetPlayerAddress(p,a,b,c) (p)->GetPlayerAddress(a,b,c) -#define IDirectPlay2_GetPlayerCaps(p,a,b,c) (p)->GetPlayerCaps(a,b,c) -#define IDirectPlay2_GetPlayerData(p,a,b,c,d) (p)->GetPlayerData(a,b,c,d) -#define IDirectPlay2_GetPlayerName(p,a,b,c) (p)->GetPlayerName(a,b,c) -#define IDirectPlay2_GetSessionDesc(p,a,b) (p)->GetSessionDesc(a,b) -#define IDirectPlay2_Initialize(p,a) (p)->Initialize(a) -#define IDirectPlay2_Open(p,a,b) (p)->Open(a,b) -#define IDirectPlay2_Receive(p,a,b,c,d,e) (p)->Receive(a,b,c,d,e) -#define IDirectPlay2_Send(p,a,b,c,d,e) (p)->Send(a,b,c,d,e) -#define IDirectPlay2_SetGroupData(p,a,b,c,d) (p)->SetGroupData(a,b,c,d) -#define IDirectPlay2_SetGroupName(p,a,b,c) (p)->SetGroupName(a,b,c) -#define IDirectPlay2_SetPlayerData(p,a,b,c,d) (p)->SetPlayerData(a,b,c,d) -#define IDirectPlay2_SetPlayerName(p,a,b,c) (p)->SetPlayerName(a,b,c) -#define IDirectPlay2_SetSessionDesc(p,a,b) (p)->SetSessionDesc(a,b) - -#endif - -/**************************************************************************** - * - * IDirectPlay3 (and IDirectPlay3A) Interface - * - ****************************************************************************/ - -#undef INTERFACE -#define INTERFACE IDirectPlay3 -DECLARE_INTERFACE_( IDirectPlay3, IDirectPlay2 ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectPlay2 methods ***/ - STDMETHOD(AddPlayerToGroup) (THIS_ DPID, DPID) PURE; - STDMETHOD(Close) (THIS) PURE; - STDMETHOD(CreateGroup) (THIS_ LPDPID,LPDPNAME,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(CreatePlayer) (THIS_ LPDPID,LPDPNAME,HANDLE,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(DeletePlayerFromGroup)(THIS_ DPID,DPID) PURE; - STDMETHOD(DestroyGroup) (THIS_ DPID) PURE; - STDMETHOD(DestroyPlayer) (THIS_ DPID) PURE; - STDMETHOD(EnumGroupPlayers) (THIS_ DPID,LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; - STDMETHOD(EnumGroups) (THIS_ LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; - STDMETHOD(EnumPlayers) (THIS_ LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; - STDMETHOD(EnumSessions) (THIS_ LPDPSESSIONDESC2,DWORD,LPDPENUMSESSIONSCALLBACK2,LPVOID,DWORD) PURE; - STDMETHOD(GetCaps) (THIS_ LPDPCAPS,DWORD) PURE; - STDMETHOD(GetGroupData) (THIS_ DPID,LPVOID,LPDWORD,DWORD) PURE; - STDMETHOD(GetGroupName) (THIS_ DPID,LPVOID,LPDWORD) PURE; - STDMETHOD(GetMessageCount) (THIS_ DPID, LPDWORD) PURE; - STDMETHOD(GetPlayerAddress) (THIS_ DPID,LPVOID,LPDWORD) PURE; - STDMETHOD(GetPlayerCaps) (THIS_ DPID,LPDPCAPS,DWORD) PURE; - STDMETHOD(GetPlayerData) (THIS_ DPID,LPVOID,LPDWORD,DWORD) PURE; - STDMETHOD(GetPlayerName) (THIS_ DPID,LPVOID,LPDWORD) PURE; - STDMETHOD(GetSessionDesc) (THIS_ LPVOID,LPDWORD) PURE; - STDMETHOD(Initialize) (THIS_ LPGUID) PURE; - STDMETHOD(Open) (THIS_ LPDPSESSIONDESC2,DWORD) PURE; - STDMETHOD(Receive) (THIS_ LPDPID,LPDPID,DWORD,LPVOID,LPDWORD) PURE; - STDMETHOD(Send) (THIS_ DPID, DPID, DWORD, LPVOID, DWORD) PURE; - STDMETHOD(SetGroupData) (THIS_ DPID,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(SetGroupName) (THIS_ DPID,LPDPNAME,DWORD) PURE; - STDMETHOD(SetPlayerData) (THIS_ DPID,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(SetPlayerName) (THIS_ DPID,LPDPNAME,DWORD) PURE; - STDMETHOD(SetSessionDesc) (THIS_ LPDPSESSIONDESC2,DWORD) PURE; - /*** IDirectPlay3 methods ***/ - STDMETHOD(AddGroupToGroup) (THIS_ DPID, DPID) PURE; - STDMETHOD(CreateGroupInGroup) (THIS_ DPID,LPDPID,LPDPNAME,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(DeleteGroupFromGroup) (THIS_ DPID,DPID) PURE; - STDMETHOD(EnumConnections) (THIS_ LPCGUID,LPDPENUMCONNECTIONSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(EnumGroupsInGroup) (THIS_ DPID,LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; - STDMETHOD(GetGroupConnectionSettings)(THIS_ DWORD, DPID, LPVOID, LPDWORD) PURE; - STDMETHOD(InitializeConnection) (THIS_ LPVOID,DWORD) PURE; - STDMETHOD(SecureOpen) (THIS_ LPCDPSESSIONDESC2,DWORD,LPCDPSECURITYDESC,LPCDPCREDENTIALS) PURE; - STDMETHOD(SendChatMessage) (THIS_ DPID,DPID,DWORD,LPDPCHAT) PURE; - STDMETHOD(SetGroupConnectionSettings)(THIS_ DWORD,DPID,LPDPLCONNECTION) PURE; - STDMETHOD(StartSession) (THIS_ DWORD,DPID) PURE; - STDMETHOD(GetGroupFlags) (THIS_ DPID,LPDWORD) PURE; - STDMETHOD(GetGroupParent) (THIS_ DPID,LPDPID) PURE; - STDMETHOD(GetPlayerAccount) (THIS_ DPID, DWORD, LPVOID, LPDWORD) PURE; - STDMETHOD(GetPlayerFlags) (THIS_ DPID,LPDWORD) PURE; -}; - -/**************************************************************************** - * - * IDirectPlay3 interface macros - * - ****************************************************************************/ - -#if !defined(__cplusplus) || defined(CINTERFACE) - -#define IDirectPlay3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlay3_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlay3_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlay3_AddPlayerToGroup(p,a,b) (p)->lpVtbl->AddPlayerToGroup(p,a,b) -#define IDirectPlay3_Close(p) (p)->lpVtbl->Close(p) -#define IDirectPlay3_CreateGroup(p,a,b,c,d,e) (p)->lpVtbl->CreateGroup(p,a,b,c,d,e) -#define IDirectPlay3_CreatePlayer(p,a,b,c,d,e,f) (p)->lpVtbl->CreatePlayer(p,a,b,c,d,e,f) -#define IDirectPlay3_DeletePlayerFromGroup(p,a,b) (p)->lpVtbl->DeletePlayerFromGroup(p,a,b) -#define IDirectPlay3_DestroyGroup(p,a) (p)->lpVtbl->DestroyGroup(p,a) -#define IDirectPlay3_DestroyPlayer(p,a) (p)->lpVtbl->DestroyPlayer(p,a) -#define IDirectPlay3_EnumGroupPlayers(p,a,b,c,d,e) (p)->lpVtbl->EnumGroupPlayers(p,a,b,c,d,e) -#define IDirectPlay3_EnumGroups(p,a,b,c,d) (p)->lpVtbl->EnumGroups(p,a,b,c,d) -#define IDirectPlay3_EnumPlayers(p,a,b,c,d) (p)->lpVtbl->EnumPlayers(p,a,b,c,d) -#define IDirectPlay3_EnumSessions(p,a,b,c,d,e) (p)->lpVtbl->EnumSessions(p,a,b,c,d,e) -#define IDirectPlay3_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) -#define IDirectPlay3_GetMessageCount(p,a,b) (p)->lpVtbl->GetMessageCount(p,a,b) -#define IDirectPlay3_GetGroupData(p,a,b,c,d) (p)->lpVtbl->GetGroupData(p,a,b,c,d) -#define IDirectPlay3_GetGroupName(p,a,b,c) (p)->lpVtbl->GetGroupName(p,a,b,c) -#define IDirectPlay3_GetPlayerAddress(p,a,b,c) (p)->lpVtbl->GetPlayerAddress(p,a,b,c) -#define IDirectPlay3_GetPlayerCaps(p,a,b,c) (p)->lpVtbl->GetPlayerCaps(p,a,b,c) -#define IDirectPlay3_GetPlayerData(p,a,b,c,d) (p)->lpVtbl->GetPlayerData(p,a,b,c,d) -#define IDirectPlay3_GetPlayerName(p,a,b,c) (p)->lpVtbl->GetPlayerName(p,a,b,c) -#define IDirectPlay3_GetSessionDesc(p,a,b) (p)->lpVtbl->GetSessionDesc(p,a,b) -#define IDirectPlay3_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#define IDirectPlay3_Open(p,a,b) (p)->lpVtbl->Open(p,a,b) -#define IDirectPlay3_Receive(p,a,b,c,d,e) (p)->lpVtbl->Receive(p,a,b,c,d,e) -#define IDirectPlay3_Send(p,a,b,c,d,e) (p)->lpVtbl->Send(p,a,b,c,d,e) -#define IDirectPlay3_SetGroupData(p,a,b,c,d) (p)->lpVtbl->SetGroupData(p,a,b,c,d) -#define IDirectPlay3_SetGroupName(p,a,b,c) (p)->lpVtbl->SetGroupName(p,a,b,c) -#define IDirectPlay3_SetPlayerData(p,a,b,c,d) (p)->lpVtbl->SetPlayerData(p,a,b,c,d) -#define IDirectPlay3_SetPlayerName(p,a,b,c) (p)->lpVtbl->SetPlayerName(p,a,b,c) -#define IDirectPlay3_SetSessionDesc(p,a,b) (p)->lpVtbl->SetSessionDesc(p,a,b) -#define IDirectPlay3_AddGroupToGroup(p,a,b) (p)->lpVtbl->AddGroupToGroup(p,a,b) -#define IDirectPlay3_CreateGroupInGroup(p,a,b,c,d,e,f) (p)->lpVtbl->CreateGroupInGroup(p,a,b,c,d,e,f) -#define IDirectPlay3_DeleteGroupFromGroup(p,a,b) (p)->lpVtbl->DeleteGroupFromGroup(p,a,b) -#define IDirectPlay3_EnumConnections(p,a,b,c,d) (p)->lpVtbl->EnumConnections(p,a,b,c,d) -#define IDirectPlay3_EnumGroupsInGroup(p,a,b,c,d,e) (p)->lpVtbl->EnumGroupsInGroup(p,a,b,c,d,e) -#define IDirectPlay3_GetGroupConnectionSettings(p,a,b,c,d) (p)->lpVtbl->GetGroupConnectionSettings(p,a,b,c,d) -#define IDirectPlay3_InitializeConnection(p,a,b) (p)->lpVtbl->InitializeConnection(p,a,b) -#define IDirectPlay3_SecureOpen(p,a,b,c,d) (p)->lpVtbl->SecureOpen(p,a,b,c,d) -#define IDirectPlay3_SendChatMessage(p,a,b,c,d) (p)->lpVtbl->SendChatMessage(p,a,b,c,d) -#define IDirectPlay3_SetGroupConnectionSettings(p,a,b,c) (p)->lpVtbl->SetGroupConnectionSettings(p,a,b,c) -#define IDirectPlay3_StartSession(p,a,b) (p)->lpVtbl->StartSession(p,a,b) -#define IDirectPlay3_GetGroupFlags(p,a,b) (p)->lpVtbl->GetGroupFlags(p,a,b) -#define IDirectPlay3_GetGroupParent(p,a,b) (p)->lpVtbl->GetGroupParent(p,a,b) -#define IDirectPlay3_GetPlayerAccount(p,a,b,c,d) (p)->lpVtbl->GetPlayerAccount(p,a,b,c,d) -#define IDirectPlay3_GetPlayerFlags(p,a,b) (p)->lpVtbl->GetPlayerFlags(p,a,b) - -#else /* C++ */ - -#define IDirectPlay3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlay3_AddRef(p) (p)->AddRef() -#define IDirectPlay3_Release(p) (p)->Release() -#define IDirectPlay3_AddPlayerToGroup(p,a,b) (p)->AddPlayerToGroup(a,b) -#define IDirectPlay3_Close(p) (p)->Close() -#define IDirectPlay3_CreateGroup(p,a,b,c,d,e) (p)->CreateGroup(a,b,c,d,e) -#define IDirectPlay3_CreatePlayer(p,a,b,c,d,e,f) (p)->CreatePlayer(a,b,c,d,e,f) -#define IDirectPlay3_DeletePlayerFromGroup(p,a,b) (p)->DeletePlayerFromGroup(a,b) -#define IDirectPlay3_DestroyGroup(p,a) (p)->DestroyGroup(a) -#define IDirectPlay3_DestroyPlayer(p,a) (p)->DestroyPlayer(a) -#define IDirectPlay3_EnumGroupPlayers(p,a,b,c,d,e) (p)->EnumGroupPlayers(a,b,c,d,e) -#define IDirectPlay3_EnumGroups(p,a,b,c,d) (p)->EnumGroups(a,b,c,d) -#define IDirectPlay3_EnumPlayers(p,a,b,c,d) (p)->EnumPlayers(a,b,c,d) -#define IDirectPlay3_EnumSessions(p,a,b,c,d,e) (p)->EnumSessions(a,b,c,d,e) -#define IDirectPlay3_GetCaps(p,a,b) (p)->GetCaps(a,b) -#define IDirectPlay3_GetMessageCount(p,a,b) (p)->GetMessageCount(a,b) -#define IDirectPlay3_GetGroupData(p,a,b,c,d) (p)->GetGroupData(a,b,c,d) -#define IDirectPlay3_GetGroupName(p,a,b,c) (p)->GetGroupName(a,b,c) -#define IDirectPlay3_GetPlayerAddress(p,a,b,c) (p)->GetPlayerAddress(a,b,c) -#define IDirectPlay3_GetPlayerCaps(p,a,b,c) (p)->GetPlayerCaps(a,b,c) -#define IDirectPlay3_GetPlayerData(p,a,b,c,d) (p)->GetPlayerData(a,b,c,d) -#define IDirectPlay3_GetPlayerName(p,a,b,c) (p)->GetPlayerName(a,b,c) -#define IDirectPlay3_GetSessionDesc(p,a,b) (p)->GetSessionDesc(a,b) -#define IDirectPlay3_Initialize(p,a) (p)->Initialize(a) -#define IDirectPlay3_Open(p,a,b) (p)->Open(a,b) -#define IDirectPlay3_Receive(p,a,b,c,d,e) (p)->Receive(a,b,c,d,e) -#define IDirectPlay3_Send(p,a,b,c,d,e) (p)->Send(a,b,c,d,e) -#define IDirectPlay3_SetGroupData(p,a,b,c,d) (p)->SetGroupData(a,b,c,d) -#define IDirectPlay3_SetGroupName(p,a,b,c) (p)->SetGroupName(a,b,c) -#define IDirectPlay3_SetPlayerData(p,a,b,c,d) (p)->SetPlayerData(a,b,c,d) -#define IDirectPlay3_SetPlayerName(p,a,b,c) (p)->SetPlayerName(a,b,c) -#define IDirectPlay3_SetSessionDesc(p,a,b) (p)->SetSessionDesc(a,b) -#define IDirectPlay3_AddGroupToGroup(p,a,b) (p)->AddGroupToGroup(a,b) -#define IDirectPlay3_CreateGroupInGroup(p,a,b,c,d,e,f) (p)->CreateGroupInGroup(a,b,c,d,e,f) -#define IDirectPlay3_DeleteGroupFromGroup(p,a,b) (p)->DeleteGroupFromGroup(a,b) -#define IDirectPlay3_EnumConnections(p,a,b,c,d) (p)->EnumConnections(a,b,c,d) -#define IDirectPlay3_EnumGroupsInGroup(p,a,b,c,d,e) (p)->EnumGroupsInGroup(a,b,c,d,e) -#define IDirectPlay3_GetGroupConnectionSettings(p,a,b,c,d) (p)->GetGroupConnectionSettings(a,b,c,d) -#define IDirectPlay3_InitializeConnection(p,a,b) (p)->InitializeConnection(a,b) -#define IDirectPlay3_SecureOpen(p,a,b,c,d) (p)->SecureOpen(a,b,c,d) -#define IDirectPlay3_SendChatMessage(p,a,b,c,d) (p)->SendChatMessage(a,b,c,d) -#define IDirectPlay3_SetGroupConnectionSettings(p,a,b,c) (p)->SetGroupConnectionSettings(a,b,c) -#define IDirectPlay3_StartSession(p,a,b) (p)->StartSession(a,b) -#define IDirectPlay3_GetGroupFlags(p,a,b) (p)->GetGroupFlags(a,b) -#define IDirectPlay3_GetGroupParent(p,a,b) (p)->GetGroupParent(a,b) -#define IDirectPlay3_GetPlayerAccount(p,a,b,c,d) (p)->GetPlayerAccount(a,b,c,d) -#define IDirectPlay3_GetPlayerFlags(p,a,b) (p)->GetPlayerFlags(a,b) - -#endif - -/**************************************************************************** - * - * IDirectPlay4 (and IDirectPlay4A) Interface - * - ****************************************************************************/ - -#undef INTERFACE -#define INTERFACE IDirectPlay4 -DECLARE_INTERFACE_( IDirectPlay4, IDirectPlay3 ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectPlay2 methods ***/ - STDMETHOD(AddPlayerToGroup) (THIS_ DPID, DPID) PURE; - STDMETHOD(Close) (THIS) PURE; - STDMETHOD(CreateGroup) (THIS_ LPDPID,LPDPNAME,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(CreatePlayer) (THIS_ LPDPID,LPDPNAME,HANDLE,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(DeletePlayerFromGroup)(THIS_ DPID,DPID) PURE; - STDMETHOD(DestroyGroup) (THIS_ DPID) PURE; - STDMETHOD(DestroyPlayer) (THIS_ DPID) PURE; - STDMETHOD(EnumGroupPlayers) (THIS_ DPID,LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; - STDMETHOD(EnumGroups) (THIS_ LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; - STDMETHOD(EnumPlayers) (THIS_ LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; - STDMETHOD(EnumSessions) (THIS_ LPDPSESSIONDESC2,DWORD,LPDPENUMSESSIONSCALLBACK2,LPVOID,DWORD) PURE; - STDMETHOD(GetCaps) (THIS_ LPDPCAPS,DWORD) PURE; - STDMETHOD(GetGroupData) (THIS_ DPID,LPVOID,LPDWORD,DWORD) PURE; - STDMETHOD(GetGroupName) (THIS_ DPID,LPVOID,LPDWORD) PURE; - STDMETHOD(GetMessageCount) (THIS_ DPID, LPDWORD) PURE; - STDMETHOD(GetPlayerAddress) (THIS_ DPID,LPVOID,LPDWORD) PURE; - STDMETHOD(GetPlayerCaps) (THIS_ DPID,LPDPCAPS,DWORD) PURE; - STDMETHOD(GetPlayerData) (THIS_ DPID,LPVOID,LPDWORD,DWORD) PURE; - STDMETHOD(GetPlayerName) (THIS_ DPID,LPVOID,LPDWORD) PURE; - STDMETHOD(GetSessionDesc) (THIS_ LPVOID,LPDWORD) PURE; - STDMETHOD(Initialize) (THIS_ LPGUID) PURE; - STDMETHOD(Open) (THIS_ LPDPSESSIONDESC2,DWORD) PURE; - STDMETHOD(Receive) (THIS_ LPDPID,LPDPID,DWORD,LPVOID,LPDWORD) PURE; - STDMETHOD(Send) (THIS_ DPID, DPID, DWORD, LPVOID, DWORD) PURE; - STDMETHOD(SetGroupData) (THIS_ DPID,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(SetGroupName) (THIS_ DPID,LPDPNAME,DWORD) PURE; - STDMETHOD(SetPlayerData) (THIS_ DPID,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(SetPlayerName) (THIS_ DPID,LPDPNAME,DWORD) PURE; - STDMETHOD(SetSessionDesc) (THIS_ LPDPSESSIONDESC2,DWORD) PURE; - /*** IDirectPlay3 methods ***/ - STDMETHOD(AddGroupToGroup) (THIS_ DPID, DPID) PURE; - STDMETHOD(CreateGroupInGroup) (THIS_ DPID,LPDPID,LPDPNAME,LPVOID,DWORD,DWORD) PURE; - STDMETHOD(DeleteGroupFromGroup) (THIS_ DPID,DPID) PURE; - STDMETHOD(EnumConnections) (THIS_ LPCGUID,LPDPENUMCONNECTIONSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(EnumGroupsInGroup) (THIS_ DPID,LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; - STDMETHOD(GetGroupConnectionSettings)(THIS_ DWORD, DPID, LPVOID, LPDWORD) PURE; - STDMETHOD(InitializeConnection) (THIS_ LPVOID,DWORD) PURE; - STDMETHOD(SecureOpen) (THIS_ LPCDPSESSIONDESC2,DWORD,LPCDPSECURITYDESC,LPCDPCREDENTIALS) PURE; - STDMETHOD(SendChatMessage) (THIS_ DPID,DPID,DWORD,LPDPCHAT) PURE; - STDMETHOD(SetGroupConnectionSettings)(THIS_ DWORD,DPID,LPDPLCONNECTION) PURE; - STDMETHOD(StartSession) (THIS_ DWORD,DPID) PURE; - STDMETHOD(GetGroupFlags) (THIS_ DPID,LPDWORD) PURE; - STDMETHOD(GetGroupParent) (THIS_ DPID,LPDPID) PURE; - STDMETHOD(GetPlayerAccount) (THIS_ DPID, DWORD, LPVOID, LPDWORD) PURE; - STDMETHOD(GetPlayerFlags) (THIS_ DPID,LPDWORD) PURE; - /*** IDirectPlay4 methods ***/ - STDMETHOD(GetGroupOwner) (THIS_ DPID, LPDPID) PURE; - STDMETHOD(SetGroupOwner) (THIS_ DPID, DPID) PURE; - STDMETHOD(SendEx) (THIS_ DPID, DPID, DWORD, LPVOID, DWORD, DWORD, DWORD, LPVOID, DWORD_PTR *) PURE; - STDMETHOD(GetMessageQueue) (THIS_ DPID, DPID, DWORD, LPDWORD, LPDWORD) PURE; - STDMETHOD(CancelMessage) (THIS_ DWORD, DWORD) PURE; - STDMETHOD(CancelPriority) (THIS_ DWORD, DWORD, DWORD) PURE; -}; - -/**************************************************************************** - * - * IDirectPlayX interface macros (for IDirectPlay4 and beyond) - * - ****************************************************************************/ - -#if !defined(__cplusplus) || defined(CINTERFACE) - -#define IDirectPlayX_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlayX_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlayX_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlayX_AddPlayerToGroup(p,a,b) (p)->lpVtbl->AddPlayerToGroup(p,a,b) -#define IDirectPlayX_CancelMessage(p,a,b) (p)->lpVtbl->CancelMessage(p,a,b) -#define IDirectPlayX_CancelPriority(p,a,b,c) (p)->lpVtbl->CancelPriority(p,a,b,c) -#define IDirectPlayX_Close(p) (p)->lpVtbl->Close(p) -#define IDirectPlayX_CreateGroup(p,a,b,c,d,e) (p)->lpVtbl->CreateGroup(p,a,b,c,d,e) -#define IDirectPlayX_CreatePlayer(p,a,b,c,d,e,f) (p)->lpVtbl->CreatePlayer(p,a,b,c,d,e,f) -#define IDirectPlayX_DeletePlayerFromGroup(p,a,b) (p)->lpVtbl->DeletePlayerFromGroup(p,a,b) -#define IDirectPlayX_DestroyGroup(p,a) (p)->lpVtbl->DestroyGroup(p,a) -#define IDirectPlayX_DestroyPlayer(p,a) (p)->lpVtbl->DestroyPlayer(p,a) -#define IDirectPlayX_EnumGroupPlayers(p,a,b,c,d,e) (p)->lpVtbl->EnumGroupPlayers(p,a,b,c,d,e) -#define IDirectPlayX_EnumGroups(p,a,b,c,d) (p)->lpVtbl->EnumGroups(p,a,b,c,d) -#define IDirectPlayX_EnumPlayers(p,a,b,c,d) (p)->lpVtbl->EnumPlayers(p,a,b,c,d) -#define IDirectPlayX_EnumSessions(p,a,b,c,d,e) (p)->lpVtbl->EnumSessions(p,a,b,c,d,e) -#define IDirectPlayX_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) -#define IDirectPlayX_GetMessageCount(p,a,b) (p)->lpVtbl->GetMessageCount(p,a,b) -#define IDirectPlayX_GetMessageQueue(p,a,b,c,d,e) (p)->lpVtbl->GetMessageQueue(p,a,b,c,d,e) -#define IDirectPlayX_GetGroupData(p,a,b,c,d) (p)->lpVtbl->GetGroupData(p,a,b,c,d) -#define IDirectPlayX_GetGroupName(p,a,b,c) (p)->lpVtbl->GetGroupName(p,a,b,c) -#define IDirectPlayX_GetPlayerAddress(p,a,b,c) (p)->lpVtbl->GetPlayerAddress(p,a,b,c) -#define IDirectPlayX_GetPlayerCaps(p,a,b,c) (p)->lpVtbl->GetPlayerCaps(p,a,b,c) -#define IDirectPlayX_GetPlayerData(p,a,b,c,d) (p)->lpVtbl->GetPlayerData(p,a,b,c,d) -#define IDirectPlayX_GetPlayerName(p,a,b,c) (p)->lpVtbl->GetPlayerName(p,a,b,c) -#define IDirectPlayX_GetSessionDesc(p,a,b) (p)->lpVtbl->GetSessionDesc(p,a,b) -#define IDirectPlayX_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#define IDirectPlayX_Open(p,a,b) (p)->lpVtbl->Open(p,a,b) -#define IDirectPlayX_Receive(p,a,b,c,d,e) (p)->lpVtbl->Receive(p,a,b,c,d,e) -#define IDirectPlayX_Send(p,a,b,c,d,e) (p)->lpVtbl->Send(p,a,b,c,d,e) -#define IDirectPlayX_SendEx(p,a,b,c,d,e,f,g,h,i) (p)->lpVtbl->SendEx(p,a,b,c,d,e,f,g,h,i) -#define IDirectPlayX_SetGroupData(p,a,b,c,d) (p)->lpVtbl->SetGroupData(p,a,b,c,d) -#define IDirectPlayX_SetGroupName(p,a,b,c) (p)->lpVtbl->SetGroupName(p,a,b,c) -#define IDirectPlayX_SetPlayerData(p,a,b,c,d) (p)->lpVtbl->SetPlayerData(p,a,b,c,d) -#define IDirectPlayX_SetPlayerName(p,a,b,c) (p)->lpVtbl->SetPlayerName(p,a,b,c) -#define IDirectPlayX_SetSessionDesc(p,a,b) (p)->lpVtbl->SetSessionDesc(p,a,b) -#define IDirectPlayX_AddGroupToGroup(p,a,b) (p)->lpVtbl->AddGroupToGroup(p,a,b) -#define IDirectPlayX_CreateGroupInGroup(p,a,b,c,d,e,f) (p)->lpVtbl->CreateGroupInGroup(p,a,b,c,d,e,f) -#define IDirectPlayX_DeleteGroupFromGroup(p,a,b) (p)->lpVtbl->DeleteGroupFromGroup(p,a,b) -#define IDirectPlayX_EnumConnections(p,a,b,c,d) (p)->lpVtbl->EnumConnections(p,a,b,c,d) -#define IDirectPlayX_EnumGroupsInGroup(p,a,b,c,d,e) (p)->lpVtbl->EnumGroupsInGroup(p,a,b,c,d,e) -#define IDirectPlayX_GetGroupConnectionSettings(p,a,b,c,d) (p)->lpVtbl->GetGroupConnectionSettings(p,a,b,c,d) -#define IDirectPlayX_InitializeConnection(p,a,b) (p)->lpVtbl->InitializeConnection(p,a,b) -#define IDirectPlayX_SecureOpen(p,a,b,c,d) (p)->lpVtbl->SecureOpen(p,a,b,c,d) -#define IDirectPlayX_SendChatMessage(p,a,b,c,d) (p)->lpVtbl->SendChatMessage(p,a,b,c,d) -#define IDirectPlayX_SetGroupConnectionSettings(p,a,b,c) (p)->lpVtbl->SetGroupConnectionSettings(p,a,b,c) -#define IDirectPlayX_StartSession(p,a,b) (p)->lpVtbl->StartSession(p,a,b) -#define IDirectPlayX_GetGroupFlags(p,a,b) (p)->lpVtbl->GetGroupFlags(p,a,b) -#define IDirectPlayX_GetGroupParent(p,a,b) (p)->lpVtbl->GetGroupParent(p,a,b) -#define IDirectPlayX_GetPlayerAccount(p,a,b,c,d) (p)->lpVtbl->GetPlayerAccount(p,a,b,c,d) -#define IDirectPlayX_GetPlayerFlags(p,a,b) (p)->lpVtbl->GetPlayerFlags(p,a,b) -#define IDirectPlayX_GetGroupOwner(p,a,b) (p)->lpVtbl->GetGroupOwner(p,a,b) -#define IDirectPlayX_SetGroupOwner(p,a,b) (p)->lpVtbl->SetGroupOwner(p,a,b) - -#else /* C++ */ - -#define IDirectPlayX_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlayX_AddRef(p) (p)->AddRef() -#define IDirectPlayX_Release(p) (p)->Release() -#define IDirectPlayX_AddPlayerToGroup(p,a,b) (p)->AddPlayerToGroup(a,b) -#define IDirectPlayX_CancelMessage(p,a,b) (p)->CancelMessage(a,b) -#define IDirectPlayX_CancelPriority(p,a,b,c) (p)->CancelPriority(a,b,c) -#define IDirectPlayX_Close(p) (p)->Close() -#define IDirectPlayX_CreateGroup(p,a,b,c,d,e) (p)->CreateGroup(a,b,c,d,e) -#define IDirectPlayX_CreatePlayer(p,a,b,c,d,e,f) (p)->CreatePlayer(a,b,c,d,e,f) -#define IDirectPlayX_DeletePlayerFromGroup(p,a,b) (p)->DeletePlayerFromGroup(a,b) -#define IDirectPlayX_DestroyGroup(p,a) (p)->DestroyGroup(a) -#define IDirectPlayX_DestroyPlayer(p,a) (p)->DestroyPlayer(a) -#define IDirectPlayX_EnumGroupPlayers(p,a,b,c,d,e) (p)->EnumGroupPlayers(a,b,c,d,e) -#define IDirectPlayX_EnumGroups(p,a,b,c,d) (p)->EnumGroups(a,b,c,d) -#define IDirectPlayX_EnumPlayers(p,a,b,c,d) (p)->EnumPlayers(a,b,c,d) -#define IDirectPlayX_EnumSessions(p,a,b,c,d,e) (p)->EnumSessions(a,b,c,d,e) -#define IDirectPlayX_GetCaps(p,a,b) (p)->GetCaps(a,b) -#define IDirectPlayX_GetMessageCount(p,a,b) (p)->GetMessageCount(a,b) -#define IDirectPlayX_GetMessageQueue(p,a,b,c,d,e) (p)->GetMessageQueue(a,b,c,d,e) -#define IDirectPlayX_GetGroupData(p,a,b,c,d) (p)->GetGroupData(a,b,c,d) -#define IDirectPlayX_GetGroupName(p,a,b,c) (p)->GetGroupName(a,b,c) -#define IDirectPlayX_GetPlayerAddress(p,a,b,c) (p)->GetPlayerAddress(a,b,c) -#define IDirectPlayX_GetPlayerCaps(p,a,b,c) (p)->GetPlayerCaps(a,b,c) -#define IDirectPlayX_GetPlayerData(p,a,b,c,d) (p)->GetPlayerData(a,b,c,d) -#define IDirectPlayX_GetPlayerName(p,a,b,c) (p)->GetPlayerName(a,b,c) -#define IDirectPlayX_GetSessionDesc(p,a,b) (p)->GetSessionDesc(a,b) -#define IDirectPlayX_Initialize(p,a) (p)->Initialize(a) -#define IDirectPlayX_Open(p,a,b) (p)->Open(a,b) -#define IDirectPlayX_Receive(p,a,b,c,d,e) (p)->Receive(a,b,c,d,e) -#define IDirectPlayX_Send(p,a,b,c,d,e) (p)->Send(a,b,c,d,e) -#define IDirectPlayX_SendEx(p,a,b,c,d,e,f,g,h,i) (p)->SendEx(a,b,c,d,e,f,g,h,i) -#define IDirectPlayX_SetGroupData(p,a,b,c,d) (p)->SetGroupData(a,b,c,d) -#define IDirectPlayX_SetGroupName(p,a,b,c) (p)->SetGroupName(a,b,c) -#define IDirectPlayX_SetPlayerData(p,a,b,c,d) (p)->SetPlayerData(a,b,c,d) -#define IDirectPlayX_SetPlayerName(p,a,b,c) (p)->SetPlayerName(a,b,c) -#define IDirectPlayX_SetSessionDesc(p,a,b) (p)->SetSessionDesc(a,b) -#define IDirectPlayX_AddGroupToGroup(p,a,b) (p)->AddGroupToGroup(a,b) -#define IDirectPlayX_CreateGroupInGroup(p,a,b,c,d,e,f) (p)->CreateGroupInGroup(a,b,c,d,e,f) -#define IDirectPlayX_DeleteGroupFromGroup(p,a,b) (p)->DeleteGroupFromGroup(a,b) -#define IDirectPlayX_EnumConnections(p,a,b,c,d) (p)->EnumConnections(a,b,c,d) -#define IDirectPlayX_EnumGroupsInGroup(p,a,b,c,d,e) (p)->EnumGroupsInGroup(a,b,c,d,e) -#define IDirectPlayX_GetGroupConnectionSettings(p,a,b,c,d) (p)->GetGroupConnectionSettings(a,b,c,d) -#define IDirectPlayX_InitializeConnection(p,a,b) (p)->InitializeConnection(a,b) -#define IDirectPlayX_SecureOpen(p,a,b,c,d) (p)->SecureOpen(a,b,c,d) -#define IDirectPlayX_SendChatMessage(p,a,b,c,d) (p)->SendChatMessage(a,b,c,d) -#define IDirectPlayX_SetGroupConnectionSettings(p,a,b,c) (p)->SetGroupConnectionSettings(a,b,c) -#define IDirectPlayX_StartSession(p,a,b) (p)->StartSession(a,b) -#define IDirectPlayX_GetGroupFlags(p,a,b) (p)->GetGroupFlags(a,b) -#define IDirectPlayX_GetGroupParent(p,a,b) (p)->GetGroupParent(a,b) -#define IDirectPlayX_GetPlayerAccount(p,a,b,c,d) (p)->GetPlayerAccount(a,b,c,d) -#define IDirectPlayX_GetPlayerFlags(p,a,b) (p)->GetPlayerFlags(a,b) -#define IDirectPlayX_GetGroupOwner(p,a,b) (p)->GetGroupOwner(a,b) -#define IDirectPlayX_SetGroupOwner(p,a,b) (p)->SetGroupOwner(a,b) - -#endif - -/**************************************************************************** - * - * EnumConnections API flags - * - ****************************************************************************/ - -/* - * Enumerate Service Providers - */ -#define DPCONNECTION_DIRECTPLAY 0x00000001 - -/* - * Enumerate Lobby Providers - */ -#define DPCONNECTION_DIRECTPLAYLOBBY 0x00000002 - - -/**************************************************************************** - * - * EnumPlayers API flags - * - ****************************************************************************/ - -/* - * Enumerate all players in the current session - */ -#define DPENUMPLAYERS_ALL 0x00000000 -#define DPENUMGROUPS_ALL DPENUMPLAYERS_ALL - - -/* - * Enumerate only local (created by this application) players - * or groups - */ -#define DPENUMPLAYERS_LOCAL 0x00000008 -#define DPENUMGROUPS_LOCAL DPENUMPLAYERS_LOCAL - -/* - * Enumerate only remote (non-local) players - * or groups - */ -#define DPENUMPLAYERS_REMOTE 0x00000010 -#define DPENUMGROUPS_REMOTE DPENUMPLAYERS_REMOTE - -/* - * Enumerate groups along with the players - */ -#define DPENUMPLAYERS_GROUP 0x00000020 - -/* - * Enumerate players or groups in another session - * (must supply lpguidInstance) - */ -#define DPENUMPLAYERS_SESSION 0x00000080 -#define DPENUMGROUPS_SESSION DPENUMPLAYERS_SESSION - -/* - * Enumerate server players - */ -#define DPENUMPLAYERS_SERVERPLAYER 0x00000100 - -/* - * Enumerate spectator players - */ -#define DPENUMPLAYERS_SPECTATOR 0x00000200 - -/* - * Enumerate shortcut groups - */ -#define DPENUMGROUPS_SHORTCUT 0x00000400 - -/* - * Enumerate staging area groups - */ -#define DPENUMGROUPS_STAGINGAREA 0x00000800 - -/* - * Enumerate hidden groups - */ -#define DPENUMGROUPS_HIDDEN 0x00001000 - -/* - * Enumerate the group's owner - */ -#define DPENUMPLAYERS_OWNER 0x00002000 - - -/**************************************************************************** - * - * CreatePlayer API flags - * - ****************************************************************************/ - -/* - * This flag indicates that this player should be designated - * the server player. The app should specify this at CreatePlayer. - */ -#define DPPLAYER_SERVERPLAYER DPENUMPLAYERS_SERVERPLAYER - -/* - * This flag indicates that this player should be designated - * a spectator. The app should specify this at CreatePlayer. - */ -#define DPPLAYER_SPECTATOR DPENUMPLAYERS_SPECTATOR - -/* - * This flag indicates that this player was created locally. - * (returned from GetPlayerFlags) - */ -#define DPPLAYER_LOCAL DPENUMPLAYERS_LOCAL - -/* - * This flag indicates that this player is the group's owner - * (Only returned in EnumGroupPlayers) - */ -#define DPPLAYER_OWNER DPENUMPLAYERS_OWNER - -/**************************************************************************** - * - * CreateGroup API flags - * - ****************************************************************************/ - - -/* - * This flag indicates that the StartSession can be called on the group. - * The app should specify this at CreateGroup, or CreateGroupInGroup. - */ -#define DPGROUP_STAGINGAREA DPENUMGROUPS_STAGINGAREA - -/* - * This flag indicates that this group was created locally. - * (returned from GetGroupFlags) - */ -#define DPGROUP_LOCAL DPENUMGROUPS_LOCAL - -/* - * This flag indicates that this group was created hidden. - */ -#define DPGROUP_HIDDEN DPENUMGROUPS_HIDDEN - - -/**************************************************************************** - * - * EnumSessions API flags - * - ****************************************************************************/ - -/* - * Enumerate sessions which can be joined - */ -#define DPENUMSESSIONS_AVAILABLE 0x00000001 - -/* - * Enumerate all sessions even if they can't be joined. - */ -#define DPENUMSESSIONS_ALL 0x00000002 - - -/* - * Start an asynchronous enum sessions - */ - #define DPENUMSESSIONS_ASYNC 0x00000010 - -/* - * Stop an asynchronous enum sessions - */ - #define DPENUMSESSIONS_STOPASYNC 0x00000020 - -/* - * Enumerate sessions even if they require a password - */ - #define DPENUMSESSIONS_PASSWORDREQUIRED 0x00000040 - -/* - * Return status about progress of enumeration instead of - * showing any status dialogs. - */ - #define DPENUMSESSIONS_RETURNSTATUS 0x00000080 - -/**************************************************************************** - * - * GetCaps and GetPlayerCaps API flags - * - ****************************************************************************/ - -/* - * The latency returned should be for guaranteed message sending. - * Default is non-guaranteed messaging. - */ -#define DPGETCAPS_GUARANTEED 0x00000001 - - -/**************************************************************************** - * - * GetGroupData, GetPlayerData API flags - * Remote and local Group/Player data is maintained separately. - * Default is DPGET_REMOTE. - * - ****************************************************************************/ - -/* - * Get the remote data (set by any DirectPlay object in - * the session using DPSET_REMOTE) - */ -#define DPGET_REMOTE 0x00000000 - -/* - * Get the local data (set by this DirectPlay object - * using DPSET_LOCAL) - */ -#define DPGET_LOCAL 0x00000001 - - -/**************************************************************************** - * - * Open API flags - * - ****************************************************************************/ - -/* - * Join the session that is described by the DPSESSIONDESC2 structure - */ -#define DPOPEN_JOIN 0x00000001 - -/* - * Create a new session as described by the DPSESSIONDESC2 structure - */ -#define DPOPEN_CREATE 0x00000002 - -/* - * Return status about progress of open instead of showing - * any status dialogs. - */ - #define DPOPEN_RETURNSTATUS DPENUMSESSIONS_RETURNSTATUS - - -/**************************************************************************** - * - * DPLCONNECTION flags - * - ****************************************************************************/ - -/* - * This application should create a new session as - * described by the DPSESIONDESC structure - */ -#define DPLCONNECTION_CREATESESSION DPOPEN_CREATE - -/* - * This application should join the session described by - * the DPSESIONDESC structure with the lpAddress data - */ -#define DPLCONNECTION_JOINSESSION DPOPEN_JOIN - -/**************************************************************************** - * - * Receive API flags - * Default is DPRECEIVE_ALL - * - ****************************************************************************/ - -/* - * Get the first message in the queue - */ -#define DPRECEIVE_ALL 0x00000001 - -/* - * Get the first message in the queue directed to a specific player - */ -#define DPRECEIVE_TOPLAYER 0x00000002 - -/* - * Get the first message in the queue from a specific player - */ -#define DPRECEIVE_FROMPLAYER 0x00000004 - -/* - * Get the message but don't remove it from the queue - */ -#define DPRECEIVE_PEEK 0x00000008 - - -/**************************************************************************** - * - * Send API flags - * - ****************************************************************************/ - -/* - * Send the message using a guaranteed send method. - * Default is non-guaranteed. - */ -#define DPSEND_GUARANTEED 0x00000001 - - -/* - * This flag is obsolete. It is ignored by DirectPlay - */ -#define DPSEND_HIGHPRIORITY 0x00000002 - -/* - * This flag is obsolete. It is ignored by DirectPlay - */ -#define DPSEND_OPENSTREAM 0x00000008 - -/* - * This flag is obsolete. It is ignored by DirectPlay - */ -#define DPSEND_CLOSESTREAM 0x00000010 - -/* - * Send the message digitally signed to ensure authenticity. - */ -#define DPSEND_SIGNED 0x00000020 - -/* - * Send the message with encryption to ensure privacy. - */ -#define DPSEND_ENCRYPTED 0x00000040 - -/* - * The message is a lobby system message - */ -#define DPSEND_LOBBYSYSTEMMESSAGE 0x00000080 - - -/* - * Send message asynchronously, must check caps - * before using this flag. It is always provided - * if the protocol flag is set. - */ -#define DPSEND_ASYNC 0x00000200 - -/* - * When an message is completed, don't tell me. - * by default the application is notified with a system message. - */ -#define DPSEND_NOSENDCOMPLETEMSG 0x00000400 - - -/* - * Maximum priority for sends available to applications - */ -#define DPSEND_MAX_PRI 0x0000FFFF -#define DPSEND_MAX_PRIORITY DPSEND_MAX_PRI - - -/**************************************************************************** - * - * SetGroupData, SetGroupName, SetPlayerData, SetPlayerName, - * SetSessionDesc API flags. - * Default is DPSET_REMOTE. - * - ****************************************************************************/ - -/* - * Propagate the data to all players in the session - */ -#define DPSET_REMOTE 0x00000000 - -/* - * Do not propagate the data to other players - */ -#define DPSET_LOCAL 0x00000001 - -/* - * Used with DPSET_REMOTE, use guaranteed message send to - * propagate the data - */ -#define DPSET_GUARANTEED 0x00000002 - -/**************************************************************************** - * - * GetMessageQueue API flags. - * Default is DPMESSAGEQUEUE_SEND - * - ****************************************************************************/ - -/* - * Get Send Queue - requires Service Provider Support - */ -#define DPMESSAGEQUEUE_SEND 0x00000001 - -/* - * Get Receive Queue - */ -#define DPMESSAGEQUEUE_RECEIVE 0x00000002 - - -/**************************************************************************** - * - * Connect API flags - * - ****************************************************************************/ - - -/* - * Start an asynchronous connect which returns status codes - */ -#define DPCONNECT_RETURNSTATUS (DPENUMSESSIONS_RETURNSTATUS) - - -/**************************************************************************** - * - * DirectPlay system messages and message data structures - * - * All system message come 'From' player DPID_SYSMSG. To determine what type - * of message it is, cast the lpData from Receive to DPMSG_GENERIC and check - * the dwType member against one of the following DPSYS_xxx constants. Once - * a match is found, cast the lpData to the corresponding of the DPMSG_xxx - * structures to access the data of the message. - * - ****************************************************************************/ - -/* - * A new player or group has been created in the session - * Use DPMSG_CREATEPLAYERORGROUP. Check dwPlayerType to see if it - * is a player or a group. - */ -#define DPSYS_CREATEPLAYERORGROUP 0x0003 - -/* - * A player has been deleted from the session - * Use DPMSG_DESTROYPLAYERORGROUP - */ -#define DPSYS_DESTROYPLAYERORGROUP 0x0005 - -/* - * A player has been added to a group - * Use DPMSG_ADDPLAYERTOGROUP - */ -#define DPSYS_ADDPLAYERTOGROUP 0x0007 - -/* - * A player has been removed from a group - * Use DPMSG_DELETEPLAYERFROMGROUP - */ -#define DPSYS_DELETEPLAYERFROMGROUP 0x0021 - -/* - * This DirectPlay object lost its connection with all the - * other players in the session. - * Use DPMSG_SESSIONLOST. - */ -#define DPSYS_SESSIONLOST 0x0031 - -/* - * The current host has left the session. - * This DirectPlay object is now the host. - * Use DPMSG_HOST. - */ -#define DPSYS_HOST 0x0101 - -/* - * The remote data associated with a player or - * group has changed. Check dwPlayerType to see - * if it is a player or a group - * Use DPMSG_SETPLAYERORGROUPDATA - */ -#define DPSYS_SETPLAYERORGROUPDATA 0x0102 - -/* - * The name of a player or group has changed. - * Check dwPlayerType to see if it is a player - * or a group. - * Use DPMSG_SETPLAYERORGROUPNAME - */ -#define DPSYS_SETPLAYERORGROUPNAME 0x0103 - -/* - * The session description has changed. - * Use DPMSG_SETSESSIONDESC - */ -#define DPSYS_SETSESSIONDESC 0x0104 - -/* - * A group has been added to a group - * Use DPMSG_ADDGROUPTOGROUP - */ -#define DPSYS_ADDGROUPTOGROUP 0x0105 - -/* - * A group has been removed from a group - * Use DPMSG_DELETEGROUPFROMGROUP - */ -#define DPSYS_DELETEGROUPFROMGROUP 0x0106 - -/* - * A secure player-player message has arrived. - * Use DPMSG_SECUREMESSAGE - */ -#define DPSYS_SECUREMESSAGE 0x0107 - -/* - * Start a new session. - * Use DPMSG_STARTSESSION - */ -#define DPSYS_STARTSESSION 0x0108 - -/* - * A chat message has arrived - * Use DPMSG_CHAT - */ -#define DPSYS_CHAT 0x0109 - -/* - * The owner of a group has changed - * Use DPMSG_SETGROUPOWNER - */ -#define DPSYS_SETGROUPOWNER 0x010A - -/* - * An async send has finished, failed or been cancelled - * Use DPMSG_SENDCOMPLETE - */ -#define DPSYS_SENDCOMPLETE 0x010d - - -/* - * Used in the dwPlayerType field to indicate if it applies to a group - * or a player - */ -#define DPPLAYERTYPE_GROUP 0x00000000 -#define DPPLAYERTYPE_PLAYER 0x00000001 - - -/* - * DPMSG_GENERIC - * Generic message structure used to identify the message type. - */ -typedef struct -{ - DWORD dwType; // Message type -} DPMSG_GENERIC, FAR *LPDPMSG_GENERIC; - -/* - * DPMSG_CREATEPLAYERORGROUP - * System message generated when a new player or group - * created in the session with information about it. - */ -typedef struct -{ - DWORD dwType; // Message type - DWORD dwPlayerType; // Is it a player or group - DPID dpId; // ID of the player or group - DWORD dwCurrentPlayers; // current # players & groups in session - LPVOID lpData; // pointer to remote data - DWORD dwDataSize; // size of remote data - DPNAME dpnName; // structure with name info - // the following fields are only available when using - // the IDirectPlay3 interface or greater - DPID dpIdParent; // id of parent group - DWORD dwFlags; // player or group flags -} DPMSG_CREATEPLAYERORGROUP, FAR *LPDPMSG_CREATEPLAYERORGROUP; - -/* - * DPMSG_DESTROYPLAYERORGROUP - * System message generated when a player or group is being - * destroyed in the session with information about it. - */ -typedef struct -{ - DWORD dwType; // Message type - DWORD dwPlayerType; // Is it a player or group - DPID dpId; // player ID being deleted - LPVOID lpLocalData; // copy of players local data - DWORD dwLocalDataSize; // sizeof local data - LPVOID lpRemoteData; // copy of players remote data - DWORD dwRemoteDataSize; // sizeof remote data - // the following fields are only available when using - // the IDirectPlay3 interface or greater - DPNAME dpnName; // structure with name info - DPID dpIdParent; // id of parent group - DWORD dwFlags; // player or group flags -} DPMSG_DESTROYPLAYERORGROUP, FAR *LPDPMSG_DESTROYPLAYERORGROUP; - -/* - * DPMSG_ADDPLAYERTOGROUP - * System message generated when a player is being added - * to a group. - */ -typedef struct -{ - DWORD dwType; // Message type - DPID dpIdGroup; // group ID being added to - DPID dpIdPlayer; // player ID being added -} DPMSG_ADDPLAYERTOGROUP, FAR *LPDPMSG_ADDPLAYERTOGROUP; - -/* - * DPMSG_DELETEPLAYERFROMGROUP - * System message generated when a player is being - * removed from a group - */ -typedef DPMSG_ADDPLAYERTOGROUP DPMSG_DELETEPLAYERFROMGROUP; -typedef DPMSG_DELETEPLAYERFROMGROUP FAR *LPDPMSG_DELETEPLAYERFROMGROUP; - -/* - * DPMSG_ADDGROUPTOGROUP - * System message generated when a group is being added - * to a group. - */ -typedef struct -{ - DWORD dwType; // Message type - DPID dpIdParentGroup; // group ID being added to - DPID dpIdGroup; // group ID being added -} DPMSG_ADDGROUPTOGROUP, FAR *LPDPMSG_ADDGROUPTOGROUP; - -/* - * DPMSG_DELETEGROUPFROMGROUP - * System message generated when a GROUP is being - * removed from a group - */ -typedef DPMSG_ADDGROUPTOGROUP DPMSG_DELETEGROUPFROMGROUP; -typedef DPMSG_DELETEGROUPFROMGROUP FAR *LPDPMSG_DELETEGROUPFROMGROUP; - -/* - * DPMSG_SETPLAYERORGROUPDATA - * System message generated when remote data for a player or - * group has changed. - */ -typedef struct -{ - DWORD dwType; // Message type - DWORD dwPlayerType; // Is it a player or group - DPID dpId; // ID of player or group - LPVOID lpData; // pointer to remote data - DWORD dwDataSize; // size of remote data -} DPMSG_SETPLAYERORGROUPDATA, FAR *LPDPMSG_SETPLAYERORGROUPDATA; - -/* - * DPMSG_SETPLAYERORGROUPNAME - * System message generated when the name of a player or - * group has changed. - */ -typedef struct -{ - DWORD dwType; // Message type - DWORD dwPlayerType; // Is it a player or group - DPID dpId; // ID of player or group - DPNAME dpnName; // structure with new name info -} DPMSG_SETPLAYERORGROUPNAME, FAR *LPDPMSG_SETPLAYERORGROUPNAME; - -/* - * DPMSG_SETSESSIONDESC - * System message generated when session desc has changed - */ -typedef struct -{ - DWORD dwType; // Message type - DPSESSIONDESC2 dpDesc; // Session desc -} DPMSG_SETSESSIONDESC, FAR *LPDPMSG_SETSESSIONDESC; - -/* - * DPMSG_HOST - * System message generated when the host has migrated to this - * DirectPlay object. - * - */ -typedef DPMSG_GENERIC DPMSG_HOST; -typedef DPMSG_HOST FAR *LPDPMSG_HOST; - -/* - * DPMSG_SESSIONLOST - * System message generated when the connection to the session is lost. - * - */ -typedef DPMSG_GENERIC DPMSG_SESSIONLOST; -typedef DPMSG_SESSIONLOST FAR *LPDPMSG_SESSIONLOST; - -/* - * DPMSG_SECUREMESSAGE - * System message generated when a player requests a secure send - */ -typedef struct -{ - DWORD dwType; // Message Type - DWORD dwFlags; // Signed/Encrypted - DPID dpIdFrom; // ID of Sending Player - LPVOID lpData; // Player message - DWORD dwDataSize; // Size of player message -} DPMSG_SECUREMESSAGE, FAR *LPDPMSG_SECUREMESSAGE; - -/* - * DPMSG_STARTSESSION - * System message containing all information required to - * start a new session - */ -typedef struct -{ - DWORD dwType; // Message type - LPDPLCONNECTION lpConn; // DPLCONNECTION structure -} DPMSG_STARTSESSION, FAR *LPDPMSG_STARTSESSION; - -/* - * DPMSG_CHAT - * System message containing a chat message - */ -typedef struct -{ - DWORD dwType; // Message type - DWORD dwFlags; // Message flags - DPID idFromPlayer; // ID of the Sending Player - DPID idToPlayer; // ID of the To Player - DPID idToGroup; // ID of the To Group - LPDPCHAT lpChat; // Pointer to a structure containing the chat message -} DPMSG_CHAT, FAR *LPDPMSG_CHAT; - -/* - * DPMSG_SETGROUPOWNER - * System message generated when the owner of a group has changed - */ -typedef struct -{ - DWORD dwType; // Message type - DPID idGroup; // ID of the group - DPID idNewOwner; // ID of the player that is the new owner - DPID idOldOwner; // ID of the player that used to be the owner -} DPMSG_SETGROUPOWNER, FAR *LPDPMSG_SETGROUPOWNER; - -/* - * DPMSG_SENDCOMPLETE - * System message generated when finished with an Async Send message - * - * NOTE SENDPARMS has an overlay for DPMSG_SENDCOMPLETE, don't - * change this message w/o changing SENDPARMS. - */ -typedef struct -{ - DWORD dwType; - DPID idFrom; - DPID idTo; - DWORD dwFlags; - DWORD dwPriority; - DWORD dwTimeout; - LPVOID lpvContext; - DWORD dwMsgID; - HRESULT hr; - DWORD dwSendTime; -} DPMSG_SENDCOMPLETE, *LPDPMSG_SENDCOMPLETE; - -/**************************************************************************** - * - * DIRECTPLAY ERRORS - * - * Errors are represented by negative values and cannot be combined. - * - ****************************************************************************/ -#define DP_OK S_OK -#define DPERR_ALREADYINITIALIZED MAKE_DPHRESULT( 5 ) -#define DPERR_ACCESSDENIED MAKE_DPHRESULT( 10 ) -#define DPERR_ACTIVEPLAYERS MAKE_DPHRESULT( 20 ) -#define DPERR_BUFFERTOOSMALL MAKE_DPHRESULT( 30 ) -#define DPERR_CANTADDPLAYER MAKE_DPHRESULT( 40 ) -#define DPERR_CANTCREATEGROUP MAKE_DPHRESULT( 50 ) -#define DPERR_CANTCREATEPLAYER MAKE_DPHRESULT( 60 ) -#define DPERR_CANTCREATESESSION MAKE_DPHRESULT( 70 ) -#define DPERR_CAPSNOTAVAILABLEYET MAKE_DPHRESULT( 80 ) -#define DPERR_EXCEPTION MAKE_DPHRESULT( 90 ) -#define DPERR_GENERIC E_FAIL -#define DPERR_INVALIDFLAGS MAKE_DPHRESULT( 120 ) -#define DPERR_INVALIDOBJECT MAKE_DPHRESULT( 130 ) -#define DPERR_INVALIDPARAM E_INVALIDARG -#define DPERR_INVALIDPARAMS DPERR_INVALIDPARAM -#define DPERR_INVALIDPLAYER MAKE_DPHRESULT( 150 ) -#define DPERR_INVALIDGROUP MAKE_DPHRESULT( 155 ) -#define DPERR_NOCAPS MAKE_DPHRESULT( 160 ) -#define DPERR_NOCONNECTION MAKE_DPHRESULT( 170 ) -#define DPERR_NOMEMORY E_OUTOFMEMORY -#define DPERR_OUTOFMEMORY DPERR_NOMEMORY -#define DPERR_NOMESSAGES MAKE_DPHRESULT( 190 ) -#define DPERR_NONAMESERVERFOUND MAKE_DPHRESULT( 200 ) -#define DPERR_NOPLAYERS MAKE_DPHRESULT( 210 ) -#define DPERR_NOSESSIONS MAKE_DPHRESULT( 220 ) -#define DPERR_PENDING E_PENDING -#define DPERR_SENDTOOBIG MAKE_DPHRESULT( 230 ) -#define DPERR_TIMEOUT MAKE_DPHRESULT( 240 ) -#define DPERR_UNAVAILABLE MAKE_DPHRESULT( 250 ) -#define DPERR_UNSUPPORTED E_NOTIMPL -#define DPERR_BUSY MAKE_DPHRESULT( 270 ) -#define DPERR_USERCANCEL MAKE_DPHRESULT( 280 ) -#define DPERR_NOINTERFACE E_NOINTERFACE -#define DPERR_CANNOTCREATESERVER MAKE_DPHRESULT( 290 ) -#define DPERR_PLAYERLOST MAKE_DPHRESULT( 300 ) -#define DPERR_SESSIONLOST MAKE_DPHRESULT( 310 ) -#define DPERR_UNINITIALIZED MAKE_DPHRESULT( 320 ) -#define DPERR_NONEWPLAYERS MAKE_DPHRESULT( 330 ) -#define DPERR_INVALIDPASSWORD MAKE_DPHRESULT( 340 ) -#define DPERR_CONNECTING MAKE_DPHRESULT( 350 ) -#define DPERR_CONNECTIONLOST MAKE_DPHRESULT( 360 ) -#define DPERR_UNKNOWNMESSAGE MAKE_DPHRESULT( 370 ) -#define DPERR_CANCELFAILED MAKE_DPHRESULT( 380 ) -#define DPERR_INVALIDPRIORITY MAKE_DPHRESULT( 390 ) -#define DPERR_NOTHANDLED MAKE_DPHRESULT( 400 ) -#define DPERR_CANCELLED MAKE_DPHRESULT( 410 ) -#define DPERR_ABORTED MAKE_DPHRESULT( 420 ) - - -#define DPERR_BUFFERTOOLARGE MAKE_DPHRESULT( 1000 ) -#define DPERR_CANTCREATEPROCESS MAKE_DPHRESULT( 1010 ) -#define DPERR_APPNOTSTARTED MAKE_DPHRESULT( 1020 ) -#define DPERR_INVALIDINTERFACE MAKE_DPHRESULT( 1030 ) -#define DPERR_NOSERVICEPROVIDER MAKE_DPHRESULT( 1040 ) -#define DPERR_UNKNOWNAPPLICATION MAKE_DPHRESULT( 1050 ) -#define DPERR_NOTLOBBIED MAKE_DPHRESULT( 1070 ) -#define DPERR_SERVICEPROVIDERLOADED MAKE_DPHRESULT( 1080 ) -#define DPERR_ALREADYREGISTERED MAKE_DPHRESULT( 1090 ) -#define DPERR_NOTREGISTERED MAKE_DPHRESULT( 1100 ) - -// -// Security related errors -// -#define DPERR_AUTHENTICATIONFAILED MAKE_DPHRESULT( 2000 ) -#define DPERR_CANTLOADSSPI MAKE_DPHRESULT( 2010 ) -#define DPERR_ENCRYPTIONFAILED MAKE_DPHRESULT( 2020 ) -#define DPERR_SIGNFAILED MAKE_DPHRESULT( 2030 ) -#define DPERR_CANTLOADSECURITYPACKAGE MAKE_DPHRESULT( 2040 ) -#define DPERR_ENCRYPTIONNOTSUPPORTED MAKE_DPHRESULT( 2050 ) -#define DPERR_CANTLOADCAPI MAKE_DPHRESULT( 2060 ) -#define DPERR_NOTLOGGEDIN MAKE_DPHRESULT( 2070 ) -#define DPERR_LOGONDENIED MAKE_DPHRESULT( 2080 ) - - -/**************************************************************************** - * - * dplay 1.0 obsolete structures + interfaces - * Included for compatibility only. New apps should - * use IDirectPlay2 - * - ****************************************************************************/ - -// define this to ignore obsolete interfaces and constants -#ifndef IDIRECTPLAY2_OR_GREATER - -#define DPOPEN_OPENSESSION DPOPEN_JOIN -#define DPOPEN_CREATESESSION DPOPEN_CREATE - -#define DPENUMSESSIONS_PREVIOUS 0x00000004 - -#define DPENUMPLAYERS_PREVIOUS 0x00000004 - -#define DPSEND_GUARANTEE DPSEND_GUARANTEED -#define DPSEND_TRYONCE 0x00000004 - -#define DPCAPS_NAMESERVICE 0x00000001 -#define DPCAPS_NAMESERVER DPCAPS_ISHOST -#define DPCAPS_GUARANTEED 0x00000004 - -#define DPLONGNAMELEN 52 -#define DPSHORTNAMELEN 20 -#define DPSESSIONNAMELEN 32 -#define DPPASSWORDLEN 16 -#define DPUSERRESERVED 16 - -#define DPSYS_ADDPLAYER 0x0003 -#define DPSYS_DELETEPLAYER 0x0005 - -#define DPSYS_DELETEGROUP 0x0020 -#define DPSYS_DELETEPLAYERFROMGRP 0x0021 -#define DPSYS_CONNECT 0x484b - -typedef struct -{ - DWORD dwType; - DWORD dwPlayerType; - DPID dpId; - char szLongName[DPLONGNAMELEN]; - char szShortName[DPSHORTNAMELEN]; - DWORD dwCurrentPlayers; -} DPMSG_ADDPLAYER; - -typedef DPMSG_ADDPLAYER DPMSG_ADDGROUP; - -typedef struct -{ - DWORD dwType; - DPID dpIdGroup; - DPID dpIdPlayer; -} DPMSG_GROUPADD; - -typedef DPMSG_GROUPADD DPMSG_GROUPDELETE; -typedef struct -{ - DWORD dwType; - DPID dpId; -} DPMSG_DELETEPLAYER; - -typedef BOOL (PASCAL *LPDPENUMPLAYERSCALLBACK)( - DPID dpId, - LPSTR lpFriendlyName, - LPSTR lpFormalName, - DWORD dwFlags, - LPVOID lpContext ); - -typedef struct -{ - DWORD dwSize; - GUID guidSession; - DWORD_PTR dwSession; - DWORD dwMaxPlayers; - DWORD dwCurrentPlayers; - DWORD dwFlags; - char szSessionName[DPSESSIONNAMELEN]; - char szUserField[DPUSERRESERVED]; - DWORD_PTR dwReserved1; - char szPassword[DPPASSWORDLEN]; - DWORD_PTR dwReserved2; - DWORD_PTR dwUser1; - DWORD_PTR dwUser2; - DWORD_PTR dwUser3; - DWORD_PTR dwUser4; -} DPSESSIONDESC,*LPDPSESSIONDESC; - -typedef BOOL (PASCAL * LPDPENUMSESSIONSCALLBACK)( - LPDPSESSIONDESC lpDPSessionDesc, - LPVOID lpContext, - LPDWORD lpdwTimeOut, - DWORD dwFlags); - -/* - * IDirectPlay - */ -#undef INTERFACE -#define INTERFACE IDirectPlay -DECLARE_INTERFACE_( IDirectPlay, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectPlay methods ***/ - STDMETHOD(AddPlayerToGroup) (THIS_ DPID, DPID) PURE; - STDMETHOD(Close) (THIS) PURE; - STDMETHOD(CreatePlayer) (THIS_ LPDPID,LPSTR,LPSTR,LPHANDLE) PURE; - STDMETHOD(CreateGroup) (THIS_ LPDPID,LPSTR,LPSTR) PURE; - STDMETHOD(DeletePlayerFromGroup)(THIS_ DPID,DPID) PURE; - STDMETHOD(DestroyPlayer) (THIS_ DPID) PURE; - STDMETHOD(DestroyGroup) (THIS_ DPID) PURE; - STDMETHOD(EnableNewPlayers) (THIS_ BOOL) PURE; - STDMETHOD(EnumGroupPlayers) (THIS_ DPID, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(EnumGroups) (THIS_ DWORD_PTR, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(EnumPlayers) (THIS_ DWORD_PTR, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(EnumSessions) (THIS_ LPDPSESSIONDESC,DWORD,LPDPENUMSESSIONSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(GetCaps) (THIS_ LPDPCAPS) PURE; - STDMETHOD(GetMessageCount) (THIS_ DPID, LPDWORD) PURE; - STDMETHOD(GetPlayerCaps) (THIS_ DPID, LPDPCAPS) PURE; - STDMETHOD(GetPlayerName) (THIS_ DPID,LPSTR,LPDWORD,LPSTR,LPDWORD) PURE; - STDMETHOD(Initialize) (THIS_ LPGUID) PURE; - STDMETHOD(Open) (THIS_ LPDPSESSIONDESC) PURE; - STDMETHOD(Receive) (THIS_ LPDPID,LPDPID,DWORD,LPVOID,LPDWORD) PURE; - STDMETHOD(SaveSession) (THIS_ LPSTR) PURE; - STDMETHOD(Send) (THIS_ DPID, DPID, DWORD, LPVOID, DWORD) PURE; - STDMETHOD(SetPlayerName) (THIS_ DPID,LPSTR,LPSTR) PURE; -}; - -/**************************************************************************** - * - * IDirectPlay interface macros - * - ****************************************************************************/ - -#if !defined(__cplusplus) || defined(CINTERFACE) - -#define IDirectPlay_AddPlayerToGroup(p,a,b) (p)->lpVtbl->AddPlayerToGroup(p,a,b) -#define IDirectPlay_Close(p) (p)->lpVtbl->Close(p) -#define IDirectPlay_CreateGroup(p,a,b,c) (p)->lpVtbl->CreateGroup(p,a,b,c) -#define IDirectPlay_CreatePlayer(p,a,b,c,d) (p)->lpVtbl->CreatePlayer(p,a,b,c,d) -#define IDirectPlay_DeletePlayerFromGroup(p,a,b) (p)->lpVtbl->DeletePlayerFromGroup(p,a,b) -#define IDirectPlay_DestroyGroup(p,a) (p)->lpVtbl->DestroyGroup(p,a) -#define IDirectPlay_DestroyPlayer(p,a) (p)->lpVtbl->DestroyPlayer(p,a) -#define IDirectPlay_EnableNewPlayers(p,a) (p)->lpVtbl->EnableNewPlayers(p,a) -#define IDirectPlay_EnumGroupPlayers(p,a,b,c,d) (p)->lpVtbl->EnumGroupPlayers(p,a,b,c,d) -#define IDirectPlay_EnumGroups(p,a,b,c,d) (p)->lpVtbl->EnumGroups(p,a,b,c,d) -#define IDirectPlay_EnumPlayers(p,a,b,c,d) (p)->lpVtbl->EnumPlayers(p,a,b,c,d) -#define IDirectPlay_EnumSessions(p,a,b,c,d,e) (p)->lpVtbl->EnumSessions(p,a,b,c,d,e) -#define IDirectPlay_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) -#define IDirectPlay_GetMessageCount(p,a,b) (p)->lpVtbl->GetMessageCount(p,a,b) -#define IDirectPlay_GetPlayerCaps(p,a,b) (p)->lpVtbl->GetPlayerCaps(p,a,b) -#define IDirectPlay_GetPlayerName(p,a,b,c,d,e) (p)->lpVtbl->GetPlayerName(p,a,b,c,d,e) -#define IDirectPlay_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#define IDirectPlay_Open(p,a) (p)->lpVtbl->Open(p,a) -#define IDirectPlay_Receive(p,a,b,c,d,e) (p)->lpVtbl->Receive(p,a,b,c,d,e) -#define IDirectPlay_SaveSession(p,a) (p)->lpVtbl->SaveSession(p,a) -#define IDirectPlay_Send(p,a,b,c,d,e) (p)->lpVtbl->Send(p,a,b,c,d,e) -#define IDirectPlay_SetPlayerName(p,a,b,c) (p)->lpVtbl->SetPlayerName(p,a,b,c) - -#else /* C++ */ - -#define IDirectPlay_AddPlayerToGroup(p,a,b) (p)->AddPlayerToGroup(a,b) -#define IDirectPlay_Close(p) (p)->Close() -#define IDirectPlay_CreateGroup(p,a,b,c) (p)->CreateGroup(a,b,c) -#define IDirectPlay_CreatePlayer(p,a,b,c,d) (p)->CreatePlayer(a,b,c,d) -#define IDirectPlay_DeletePlayerFromGroup(p,a,b) (p)->DeletePlayerFromGroup(a,b) -#define IDirectPlay_DestroyGroup(p,a) (p)->DestroyGroup(a) -#define IDirectPlay_DestroyPlayer(p,a) (p)->DestroyPlayer(a) -#define IDirectPlay_EnableNewPlayers(p,a) (p)->EnableNewPlayers(a) -#define IDirectPlay_EnumGroupPlayers(p,a,b,c,d) (p)->EnumGroupPlayers(a,b,c,d) -#define IDirectPlay_EnumGroups(p,a,b,c,d) (p)->EnumGroups(a,b,c,d) -#define IDirectPlay_EnumPlayers(p,a,b,c,d) (p)->EnumPlayers(a,b,c,d) -#define IDirectPlay_EnumSessions(p,a,b,c,d,e) (p)->EnumSessions(a,b,c,d,e) -#define IDirectPlay_GetCaps(p,a) (p)->GetCaps(a) -#define IDirectPlay_GetMessageCount(p,a,b) (p)->GetMessageCount(a,b) -#define IDirectPlay_GetPlayerCaps(p,a,b) (p)->GetPlayerCaps(a,b) -#define IDirectPlay_GetPlayerName(p,a,b,c,d,e) (p)->GetPlayerName(a,b,c,d,e) -#define IDirectPlay_Initialize(p,a) (p)->Initialize(a) -#define IDirectPlay_Open(p,a) (p)->Open(a) -#define IDirectPlay_Receive(p,a,b,c,d,e) (p)->Receive(a,b,c,d,e) -#define IDirectPlay_SaveSession(p,a) (p)->SaveSession(a) -#define IDirectPlay_Send(p,a,b,c,d,e) (p)->Send(a,b,c,d,e) -#define IDirectPlay_SetPlayerName(p,a,b,c) (p)->SetPlayerName(a,b,c) - -#endif - -DEFINE_GUID(IID_IDirectPlay, 0x5454e9a0, 0xdb65, 0x11ce, 0x92, 0x1c, 0x00, 0xaa, 0x00, 0x6c, 0x49, 0x72); - -#endif // IDIRECTPLAY2_OR_GREATER - -/**************************************************************************** - * - * IDirectPlay macros (included regardless of IDIRECTPLAY2_OR_GREATER flag) - * - ****************************************************************************/ - -#if !defined(__cplusplus) || defined(CINTERFACE) - -#define IDirectPlay_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlay_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlay_Release(p) (p)->lpVtbl->Release(p) - -#else - -#define IDirectPlay_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlay_AddRef(p) (p)->AddRef() -#define IDirectPlay_Release(p) (p)->Release() - -#endif // IDirectPlay interface macros - -#ifdef __cplusplus -}; -#endif - -/* restore warning settings */ -#if _MSC_VER >= 1200 -#pragma warning(pop) -#else -#pragma warning(default:4201) -#endif - -#endif - +/*==========================================================================; + * + * Copyright (C) 1994-1997 Microsoft Corporation. All Rights Reserved. + * + * File: dplay.h + * Content: DirectPlay include file + * + ***************************************************************************/ + +#ifndef __DPLAY_INCLUDED__ +#define __DPLAY_INCLUDED__ + +#include // for DECLARE_INTERFACE and HRESULT + +/* avoid warnings in MSVC at Level4 */ +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif +#pragma warning(disable:4201) + + +/* + * Some types + */ + +#ifndef _WIN64 +#define DWORD_PTR DWORD +#endif + +typedef LPVOID (*LPRGLPVOID)[]; +typedef LPRGLPVOID PRGPVOID, LPRGPVOID, PRGLPVOID, PAPVOID, LPAPVOID, PALPVOID, LPALPVOID; + +#define VOL volatile +typedef VOID *VOL LPVOIDV; + + +#define _FACDP 0x877 +#define MAKE_DPHRESULT( code ) MAKE_HRESULT( 1, _FACDP, code ) + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * GUIDS used by DirectPlay objects + */ +DEFINE_GUID(IID_IDirectPlay2, 0x2b74f7c0, 0x9154, 0x11cf, 0xa9, 0xcd, 0x0, 0xaa, 0x0, 0x68, 0x86, 0xe3); +DEFINE_GUID(IID_IDirectPlay2A,0x9d460580, 0xa822, 0x11cf, 0x96, 0xc, 0x0, 0x80, 0xc7, 0x53, 0x4e, 0x82); + +DEFINE_GUID(IID_IDirectPlay3, 0x133efe40, 0x32dc, 0x11d0, 0x9c, 0xfb, 0x0, 0xa0, 0xc9, 0xa, 0x43, 0xcb); +DEFINE_GUID(IID_IDirectPlay3A,0x133efe41, 0x32dc, 0x11d0, 0x9c, 0xfb, 0x0, 0xa0, 0xc9, 0xa, 0x43, 0xcb); + +DEFINE_GUID(IID_IDirectPlay4, 0xab1c530, 0x4745, 0x11d1, 0xa7, 0xa1, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc); +DEFINE_GUID(IID_IDirectPlay4A,0xab1c531, 0x4745, 0x11d1, 0xa7, 0xa1, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc); + +// {D1EB6D20-8923-11d0-9D97-00A0C90A43CB} +DEFINE_GUID(CLSID_DirectPlay,0xd1eb6d20, 0x8923, 0x11d0, 0x9d, 0x97, 0x0, 0xa0, 0xc9, 0xa, 0x43, 0xcb); + +/* + * GUIDS used by Service Providers shipped with DirectPlay + * Use these to identify Service Provider returned by EnumConnections + */ + +// GUID for IPX service provider +// {685BC400-9D2C-11cf-A9CD-00AA006886E3} +DEFINE_GUID(DPSPGUID_IPX, +0x685bc400, 0x9d2c, 0x11cf, 0xa9, 0xcd, 0x0, 0xaa, 0x0, 0x68, 0x86, 0xe3); + +// GUID for TCP/IP service provider +// 36E95EE0-8577-11cf-960C-0080C7534E82 +DEFINE_GUID(DPSPGUID_TCPIP, +0x36E95EE0, 0x8577, 0x11cf, 0x96, 0xc, 0x0, 0x80, 0xc7, 0x53, 0x4e, 0x82); + +// GUID for Serial service provider +// {0F1D6860-88D9-11cf-9C4E-00A0C905425E} +DEFINE_GUID(DPSPGUID_SERIAL, +0xf1d6860, 0x88d9, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); + +// GUID for Modem service provider +// {44EAA760-CB68-11cf-9C4E-00A0C905425E} +DEFINE_GUID(DPSPGUID_MODEM, +0x44eaa760, 0xcb68, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); + +/**************************************************************************** + * + * DirectPlay Structures + * + * Various structures used to invoke DirectPlay. + * + ****************************************************************************/ + +#ifndef IDIRECTPLAY2_OR_GREATER +typedef struct IDirectPlay FAR *LPDIRECTPLAY; +#else +typedef struct IUnknown FAR *LPDIRECTPLAY; +#endif + +typedef struct IDirectPlay2 FAR *LPDIRECTPLAY2; +typedef struct IDirectPlay2 FAR *LPDIRECTPLAY2A; +typedef struct IDirectPlay2 IDirectPlay2A; + +typedef struct IDirectPlay3 FAR *LPDIRECTPLAY3; +typedef struct IDirectPlay3 FAR *LPDIRECTPLAY3A; +typedef struct IDirectPlay3 IDirectPlay3A; + +typedef struct IDirectPlay4 FAR *LPDIRECTPLAY4; +typedef struct IDirectPlay4 FAR *LPDIRECTPLAY4A; +typedef struct IDirectPlay4 IDirectPlay4A; + +/* + * DPID + * DirectPlay player and group ID + */ +typedef DWORD DPID, FAR *LPDPID; + +/* + * DPID that system messages come from + */ +#define DPID_SYSMSG 0 + +/* + * DPID representing all players in the session + */ +#define DPID_ALLPLAYERS 0 + +/* + * DPID representing the server player + */ +#define DPID_SERVERPLAYER 1 + + +/* + * DPID representing the maxiumum ID in the range of DPID's reserved for + * use by DirectPlay. + */ +#define DPID_RESERVEDRANGE 100 + +/* + * The player ID is unknown (used with e.g. DPSESSION_NOMESSAGEID) + */ +#define DPID_UNKNOWN 0xFFFFFFFF + +/* + * DPCAPS + * Used to obtain the capabilities of a DirectPlay object + */ +typedef struct +{ + DWORD dwSize; // Size of structure, in bytes + DWORD dwFlags; // DPCAPS_xxx flags + DWORD dwMaxBufferSize; // Maximum message size, in bytes, for this service provider + DWORD dwMaxQueueSize; // Obsolete. + DWORD dwMaxPlayers; // Maximum players/groups (local + remote) + DWORD dwHundredBaud; // Bandwidth in 100 bits per second units; + // i.e. 24 is 2400, 96 is 9600, etc. + DWORD dwLatency; // Estimated latency; 0 = unknown + DWORD dwMaxLocalPlayers; // Maximum # of locally created players allowed + DWORD dwHeaderLength; // Maximum header length, in bytes, on messages + // added by the service provider + DWORD dwTimeout; // Service provider's suggested timeout value + // This is how long DirectPlay will wait for + // responses to system messages +} DPCAPS, FAR *LPDPCAPS; + +/* + * This DirectPlay object is the session host. If the host exits the + * session, another application will become the host and receive a + * DPSYS_HOST system message. + */ +#define DPCAPS_ISHOST 0x00000002 + +/* + * The service provider bound to this DirectPlay object can optimize + * group messaging. + */ +#define DPCAPS_GROUPOPTIMIZED 0x00000008 + +/* + * The service provider bound to this DirectPlay object can optimize + * keep alives (see DPSESSION_KEEPALIVE) + */ +#define DPCAPS_KEEPALIVEOPTIMIZED 0x00000010 + +/* + * The service provider bound to this DirectPlay object can optimize + * guaranteed message delivery. + */ +#define DPCAPS_GUARANTEEDOPTIMIZED 0x00000020 + +/* + * This DirectPlay object supports guaranteed message delivery. + */ +#define DPCAPS_GUARANTEEDSUPPORTED 0x00000040 + +/* + * This DirectPlay object supports digital signing of messages. + */ +#define DPCAPS_SIGNINGSUPPORTED 0x00000080 + +/* + * This DirectPlay object supports encryption of messages. + */ +#define DPCAPS_ENCRYPTIONSUPPORTED 0x00000100 + +/* + * This DirectPlay player was created on this machine + */ +#define DPPLAYERCAPS_LOCAL 0x00000800 + +/* + * Current Open settings supports all forms of Cancel + */ +#define DPCAPS_ASYNCCANCELSUPPORTED 0x00001000 + +/* + * Current Open settings supports CancelAll, but not Cancel + */ +#define DPCAPS_ASYNCCANCELALLSUPPORTED 0x00002000 + +/* + * Current Open settings supports Send Timeouts for sends + */ +#define DPCAPS_SENDTIMEOUTSUPPORTED 0x00004000 + +/* + * Current Open settings supports send priority + */ +#define DPCAPS_SENDPRIORITYSUPPORTED 0x00008000 + +/* + * Current Open settings supports DPSEND_ASYNC flag + */ +#define DPCAPS_ASYNCSUPPORTED 0x00010000 + + +/* + * DPSESSIONDESC2 + * Used to describe the properties of a DirectPlay + * session instance + */ +typedef struct +{ + DWORD dwSize; // Size of structure + DWORD dwFlags; // DPSESSION_xxx flags + GUID guidInstance; // ID for the session instance + GUID guidApplication; // GUID of the DirectPlay application. + // GUID_NULL for all applications. + DWORD dwMaxPlayers; // Maximum # players allowed in session + DWORD dwCurrentPlayers; // Current # players in session (read only) + union + { // Name of the session + LPWSTR lpszSessionName; // Unicode + LPSTR lpszSessionNameA; // ANSI + }; + union + { // Password of the session (optional) + LPWSTR lpszPassword; // Unicode + LPSTR lpszPasswordA; // ANSI + }; + DWORD_PTR dwReserved1; // Reserved for future MS use. + DWORD_PTR dwReserved2; + DWORD_PTR dwUser1; // For use by the application + DWORD_PTR dwUser2; + DWORD_PTR dwUser3; + DWORD_PTR dwUser4; +} DPSESSIONDESC2, FAR *LPDPSESSIONDESC2; + +typedef DPSESSIONDESC2 * VOL LPDPSESSIONDESC2_V; + +/* + * LPCDPSESSIONDESC2 + * A constant pointer to DPSESSIONDESC2 + */ +typedef const DPSESSIONDESC2 FAR *LPCDPSESSIONDESC2; + +/* + * Applications cannot create new players in this session. + */ +#define DPSESSION_NEWPLAYERSDISABLED 0x00000001 + +/* + * If the DirectPlay object that created the session, the host, + * quits, then the host will attempt to migrate to another + * DirectPlay object so that new players can continue to be created + * and new applications can join the session. + */ +#define DPSESSION_MIGRATEHOST 0x00000004 + +/* + * This flag tells DirectPlay not to set the idPlayerTo and idPlayerFrom + * fields in player messages. This cuts two DWORD's off the message + * overhead. + */ +#define DPSESSION_NOMESSAGEID 0x00000008 + + +/* + * This flag tells DirectPlay to not allow any new applications to + * join the session. Applications already in the session can still + * create new players. + */ +#define DPSESSION_JOINDISABLED 0x00000020 + +/* + * This flag tells DirectPlay to detect when remote players + * exit abnormally (e.g. their computer or modem gets unplugged) + */ +#define DPSESSION_KEEPALIVE 0x00000040 + +/* + * This flag tells DirectPlay not to send a message to all players + * when a players remote data changes + */ +#define DPSESSION_NODATAMESSAGES 0x00000080 + +/* + * This flag indicates that the session belongs to a secure server + * and needs user authentication + */ +#define DPSESSION_SECURESERVER 0x00000100 + +/* + * This flag indicates that the session is private and requirs a password + * for EnumSessions as well as Open. + */ +#define DPSESSION_PRIVATE 0x00000200 + +/* + * This flag indicates that the session requires a password for joining. + */ +#define DPSESSION_PASSWORDREQUIRED 0x00000400 + +/* + * This flag tells DirectPlay to route all messages through the server + */ +#define DPSESSION_MULTICASTSERVER 0x00000800 + +/* + * This flag tells DirectPlay to only download information about the + * DPPLAYER_SERVERPLAYER. + */ +#define DPSESSION_CLIENTSERVER 0x00001000 + +/* + * This flag tells DirectPlay to use the protocol built into dplay + * for reliability and statistics all the time. When this bit is + * set, only other sessions with this bit set can join or be joined. + */ +#define DPSESSION_DIRECTPLAYPROTOCOL 0x00002000 + +/* + * This flag tells DirectPlay that preserving order of received + * packets is not important, when using reliable delivery. This + * will allow messages to be indicated out of order if preceding + * messages have not yet arrived. Otherwise DPLAY will wait for + * earlier messages before delivering later reliable messages. + */ +#define DPSESSION_NOPRESERVEORDER 0x00004000 + + +/* + * This flag tells DirectPlay to optimize communication for latency + */ +#define DPSESSION_OPTIMIZELATENCY 0x00008000 + +/* + * This flag allows lobby launched games that aren't voice enabled + * to get voice capabilities. + */ +#define DPSESSION_ALLOWVOICERETRO 0x00010000 + +/* + * This flag supresses transmission of session desc changes. + * DPSESSION_NODATAMESSAGES was supposed to do that, but SetSessionDesc + * was ignoring the flag and some apps depended on the broken behavior, this + * flag allows applications to get the right behaviour without breaking apps depending + * on old broken behavior. + */ +#define DPSESSION_NOSESSIONDESCMESSAGES 0x00020000 + +/* + * DPNAME + * Used to hold the name of a DirectPlay entity + * like a player or a group + */ +typedef struct +{ + DWORD dwSize; // Size of structure + DWORD dwFlags; // Not used. Must be zero. + union + { // The short or friendly name + LPWSTR lpszShortName; // Unicode + LPSTR lpszShortNameA; // ANSI + }; + union + { // The long or formal name + LPWSTR lpszLongName; // Unicode + LPSTR lpszLongNameA; // ANSI + }; + +} DPNAME, FAR *LPDPNAME; + +/* + * LPCDPNAME + * A constant pointer to DPNAME + */ +typedef const DPNAME FAR *LPCDPNAME; + +/* + * DPCREDENTIALS + * Used to hold the user name and password of a DirectPlay user + */ +typedef struct +{ + DWORD dwSize; // Size of structure + DWORD dwFlags; // Not used. Must be zero. + union + { // User name of the account + LPWSTR lpszUsername; // Unicode + LPSTR lpszUsernameA; // ANSI + }; + union + { // Password of the account + LPWSTR lpszPassword; // Unicode + LPSTR lpszPasswordA; // ANSI + }; + union + { // Domain name of the account + LPWSTR lpszDomain; // Unicode + LPSTR lpszDomainA; // ANSI + }; +} DPCREDENTIALS, FAR *LPDPCREDENTIALS; + +typedef const DPCREDENTIALS FAR *LPCDPCREDENTIALS; + +/* + * DPSECURITYDESC + * Used to describe the security properties of a DirectPlay + * session instance + */ +typedef struct +{ + DWORD dwSize; // Size of structure + DWORD dwFlags; // Not used. Must be zero. + union + { // SSPI provider name + LPWSTR lpszSSPIProvider; // Unicode + LPSTR lpszSSPIProviderA; // ANSI + }; + union + { // CAPI provider name + LPWSTR lpszCAPIProvider; // Unicode + LPSTR lpszCAPIProviderA; // ANSI + }; + DWORD dwCAPIProviderType; // Crypto Service Provider type + DWORD dwEncryptionAlgorithm; // Encryption Algorithm type +} DPSECURITYDESC, FAR *LPDPSECURITYDESC; + +typedef const DPSECURITYDESC FAR *LPCDPSECURITYDESC; + +/* + * DPACCOUNTDESC + * Used to describe a user membership account + */ +typedef struct +{ + DWORD dwSize; // Size of structure + DWORD dwFlags; // Not used. Must be zero. + union + { // Account identifier + LPWSTR lpszAccountID; // Unicode + LPSTR lpszAccountIDA; // ANSI + }; +} DPACCOUNTDESC, FAR *LPDPACCOUNTDESC; + +typedef const DPACCOUNTDESC FAR *LPCDPACCOUNTDESC; + +/* + * LPCGUID + * A constant pointer to a guid + */ +typedef const GUID FAR *LPCGUID; + +/* + * DPLCONNECTION + * Used to hold all in the informaion needed to connect + * an application to a session or create a session + */ +typedef struct +{ + DWORD dwSize; // Size of this structure + DWORD dwFlags; // Flags specific to this structure + LPDPSESSIONDESC2 lpSessionDesc; // Pointer to session desc to use on connect + LPDPNAME lpPlayerName; // Pointer to Player name structure + GUID guidSP; // GUID of the DPlay SP to use + LPVOID lpAddress; // Address for service provider + DWORD dwAddressSize; // Size of address data +} DPLCONNECTION, FAR *LPDPLCONNECTION; + +/* + * LPCDPLCONNECTION + * A constant pointer to DPLCONNECTION + */ +typedef const DPLCONNECTION FAR *LPCDPLCONNECTION; + +/* + * DPCHAT + * Used to hold the a DirectPlay chat message + */ +typedef struct +{ + DWORD dwSize; + DWORD dwFlags; + union + { // Message string + LPWSTR lpszMessage; // Unicode + LPSTR lpszMessageA; // ANSI + }; +} DPCHAT, FAR * LPDPCHAT; + +/* + * SGBUFFER + * Scatter Gather Buffer used for SendEx + */ +typedef struct +{ + UINT len; // length of buffer data + PUCHAR pData; // pointer to buffer data +} SGBUFFER, *PSGBUFFER, FAR *LPSGBUFFER; + + +/**************************************************************************** + * + * Prototypes for DirectPlay callback functions + * + ****************************************************************************/ + +/* + * Callback for IDirectPlay2::EnumSessions + */ +typedef BOOL (FAR PASCAL * LPDPENUMSESSIONSCALLBACK2)( + LPCDPSESSIONDESC2 lpThisSD, + LPDWORD lpdwTimeOut, + DWORD dwFlags, + LPVOID lpContext ); + +/* + * This flag is set on the EnumSessions callback dwFlags parameter when + * the time out has occurred. There will be no session data for this + * callback. If *lpdwTimeOut is set to a non-zero value and the + * EnumSessionsCallback function returns TRUE then EnumSessions will + * continue waiting until the next timeout occurs. Timeouts are in + * milliseconds. + */ +#define DPESC_TIMEDOUT 0x00000001 + + +/* + * Callback for IDirectPlay2::EnumPlayers + * IDirectPlay2::EnumGroups + * IDirectPlay2::EnumGroupPlayers + */ +typedef BOOL (FAR PASCAL *LPDPENUMPLAYERSCALLBACK2)( + DPID dpId, + DWORD dwPlayerType, + LPCDPNAME lpName, + DWORD dwFlags, + LPVOID lpContext ); + + +/* + * Unicode callback for DirectPlayEnumerate + * This callback prototype will be used if compiling + * for Unicode strings + */ +typedef BOOL (FAR PASCAL * LPDPENUMDPCALLBACK)( + LPGUID lpguidSP, + LPWSTR lpSPName, + DWORD dwMajorVersion, + DWORD dwMinorVersion, + LPVOID lpContext); + +/* + * ANSI callback for DirectPlayEnumerate + * This callback prototype will be used if compiling + * for ANSI strings + */ +typedef BOOL (FAR PASCAL * LPDPENUMDPCALLBACKA)( + LPGUID lpguidSP, + LPSTR lpSPName, + DWORD dwMajorVersion, + DWORD dwMinorVersion, + LPVOID lpContext); + +/* + * Callback for IDirectPlay3(A)::EnumConnections + */ +typedef BOOL (FAR PASCAL * LPDPENUMCONNECTIONSCALLBACK)( + LPCGUID lpguidSP, + LPVOID lpConnection, + DWORD dwConnectionSize, + LPCDPNAME lpName, + DWORD dwFlags, + LPVOID lpContext); + + +/* + * API's + */ + +#ifdef UNICODE +#define DirectPlayEnumerate DirectPlayEnumerateW +#else +#define DirectPlayEnumerate DirectPlayEnumerateA +#endif // UNICODE + +extern HRESULT WINAPI DirectPlayEnumerateA( LPDPENUMDPCALLBACKA, LPVOID ); +extern HRESULT WINAPI DirectPlayEnumerateW( LPDPENUMDPCALLBACK, LPVOID ); +extern HRESULT WINAPI DirectPlayCreate( LPGUID lpGUID, LPDIRECTPLAY *lplpDP, IUnknown *pUnk); + +/**************************************************************************** + * + * IDirectPlay2 (and IDirectPlay2A) Interface + * + ****************************************************************************/ + +#undef INTERFACE +#define INTERFACE IDirectPlay2 +DECLARE_INTERFACE_( IDirectPlay2, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectPlay2 methods ***/ + STDMETHOD(AddPlayerToGroup) (THIS_ DPID, DPID) PURE; + STDMETHOD(Close) (THIS) PURE; + STDMETHOD(CreateGroup) (THIS_ LPDPID,LPDPNAME,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(CreatePlayer) (THIS_ LPDPID,LPDPNAME,HANDLE,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(DeletePlayerFromGroup)(THIS_ DPID,DPID) PURE; + STDMETHOD(DestroyGroup) (THIS_ DPID) PURE; + STDMETHOD(DestroyPlayer) (THIS_ DPID) PURE; + STDMETHOD(EnumGroupPlayers) (THIS_ DPID,LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; + STDMETHOD(EnumGroups) (THIS_ LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; + STDMETHOD(EnumPlayers) (THIS_ LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; + STDMETHOD(EnumSessions) (THIS_ LPDPSESSIONDESC2,DWORD,LPDPENUMSESSIONSCALLBACK2,LPVOID,DWORD) PURE; + STDMETHOD(GetCaps) (THIS_ LPDPCAPS,DWORD) PURE; + STDMETHOD(GetGroupData) (THIS_ DPID,LPVOID,LPDWORD,DWORD) PURE; + STDMETHOD(GetGroupName) (THIS_ DPID,LPVOID,LPDWORD) PURE; + STDMETHOD(GetMessageCount) (THIS_ DPID, LPDWORD) PURE; + STDMETHOD(GetPlayerAddress) (THIS_ DPID,LPVOID,LPDWORD) PURE; + STDMETHOD(GetPlayerCaps) (THIS_ DPID,LPDPCAPS,DWORD) PURE; + STDMETHOD(GetPlayerData) (THIS_ DPID,LPVOID,LPDWORD,DWORD) PURE; + STDMETHOD(GetPlayerName) (THIS_ DPID,LPVOID,LPDWORD) PURE; + STDMETHOD(GetSessionDesc) (THIS_ LPVOID,LPDWORD) PURE; + STDMETHOD(Initialize) (THIS_ LPGUID) PURE; + STDMETHOD(Open) (THIS_ LPDPSESSIONDESC2,DWORD) PURE; + STDMETHOD(Receive) (THIS_ LPDPID,LPDPID,DWORD,LPVOID,LPDWORD) PURE; + STDMETHOD(Send) (THIS_ DPID, DPID, DWORD, LPVOID, DWORD) PURE; + STDMETHOD(SetGroupData) (THIS_ DPID,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(SetGroupName) (THIS_ DPID,LPDPNAME,DWORD) PURE; + STDMETHOD(SetPlayerData) (THIS_ DPID,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(SetPlayerName) (THIS_ DPID,LPDPNAME,DWORD) PURE; + STDMETHOD(SetSessionDesc) (THIS_ LPDPSESSIONDESC2,DWORD) PURE; +}; + +/**************************************************************************** + * + * IDirectPlay2 interface macros + * + ****************************************************************************/ + +#if !defined(__cplusplus) || defined(CINTERFACE) + +#define IDirectPlay2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlay2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlay2_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlay2_AddPlayerToGroup(p,a,b) (p)->lpVtbl->AddPlayerToGroup(p,a,b) +#define IDirectPlay2_Close(p) (p)->lpVtbl->Close(p) +#define IDirectPlay2_CreateGroup(p,a,b,c,d,e) (p)->lpVtbl->CreateGroup(p,a,b,c,d,e) +#define IDirectPlay2_CreatePlayer(p,a,b,c,d,e,f) (p)->lpVtbl->CreatePlayer(p,a,b,c,d,e,f) +#define IDirectPlay2_DeletePlayerFromGroup(p,a,b) (p)->lpVtbl->DeletePlayerFromGroup(p,a,b) +#define IDirectPlay2_DestroyGroup(p,a) (p)->lpVtbl->DestroyGroup(p,a) +#define IDirectPlay2_DestroyPlayer(p,a) (p)->lpVtbl->DestroyPlayer(p,a) +#define IDirectPlay2_EnumGroupPlayers(p,a,b,c,d,e) (p)->lpVtbl->EnumGroupPlayers(p,a,b,c,d,e) +#define IDirectPlay2_EnumGroups(p,a,b,c,d) (p)->lpVtbl->EnumGroups(p,a,b,c,d) +#define IDirectPlay2_EnumPlayers(p,a,b,c,d) (p)->lpVtbl->EnumPlayers(p,a,b,c,d) +#define IDirectPlay2_EnumSessions(p,a,b,c,d,e) (p)->lpVtbl->EnumSessions(p,a,b,c,d,e) +#define IDirectPlay2_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) +#define IDirectPlay2_GetMessageCount(p,a,b) (p)->lpVtbl->GetMessageCount(p,a,b) +#define IDirectPlay2_GetGroupData(p,a,b,c,d) (p)->lpVtbl->GetGroupData(p,a,b,c,d) +#define IDirectPlay2_GetGroupName(p,a,b,c) (p)->lpVtbl->GetGroupName(p,a,b,c) +#define IDirectPlay2_GetPlayerAddress(p,a,b,c) (p)->lpVtbl->GetPlayerAddress(p,a,b,c) +#define IDirectPlay2_GetPlayerCaps(p,a,b,c) (p)->lpVtbl->GetPlayerCaps(p,a,b,c) +#define IDirectPlay2_GetPlayerData(p,a,b,c,d) (p)->lpVtbl->GetPlayerData(p,a,b,c,d) +#define IDirectPlay2_GetPlayerName(p,a,b,c) (p)->lpVtbl->GetPlayerName(p,a,b,c) +#define IDirectPlay2_GetSessionDesc(p,a,b) (p)->lpVtbl->GetSessionDesc(p,a,b) +#define IDirectPlay2_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#define IDirectPlay2_Open(p,a,b) (p)->lpVtbl->Open(p,a,b) +#define IDirectPlay2_Receive(p,a,b,c,d,e) (p)->lpVtbl->Receive(p,a,b,c,d,e) +#define IDirectPlay2_Send(p,a,b,c,d,e) (p)->lpVtbl->Send(p,a,b,c,d,e) +#define IDirectPlay2_SetGroupData(p,a,b,c,d) (p)->lpVtbl->SetGroupData(p,a,b,c,d) +#define IDirectPlay2_SetGroupName(p,a,b,c) (p)->lpVtbl->SetGroupName(p,a,b,c) +#define IDirectPlay2_SetPlayerData(p,a,b,c,d) (p)->lpVtbl->SetPlayerData(p,a,b,c,d) +#define IDirectPlay2_SetPlayerName(p,a,b,c) (p)->lpVtbl->SetPlayerName(p,a,b,c) +#define IDirectPlay2_SetSessionDesc(p,a,b) (p)->lpVtbl->SetSessionDesc(p,a,b) + +#else /* C++ */ + +#define IDirectPlay2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlay2_AddRef(p) (p)->AddRef() +#define IDirectPlay2_Release(p) (p)->Release() +#define IDirectPlay2_AddPlayerToGroup(p,a,b) (p)->AddPlayerToGroup(a,b) +#define IDirectPlay2_Close(p) (p)->Close() +#define IDirectPlay2_CreateGroup(p,a,b,c,d,e) (p)->CreateGroup(a,b,c,d,e) +#define IDirectPlay2_CreatePlayer(p,a,b,c,d,e,f) (p)->CreatePlayer(a,b,c,d,e,f) +#define IDirectPlay2_DeletePlayerFromGroup(p,a,b) (p)->DeletePlayerFromGroup(a,b) +#define IDirectPlay2_DestroyGroup(p,a) (p)->DestroyGroup(a) +#define IDirectPlay2_DestroyPlayer(p,a) (p)->DestroyPlayer(a) +#define IDirectPlay2_EnumGroupPlayers(p,a,b,c,d,e) (p)->EnumGroupPlayers(a,b,c,d,e) +#define IDirectPlay2_EnumGroups(p,a,b,c,d) (p)->EnumGroups(a,b,c,d) +#define IDirectPlay2_EnumPlayers(p,a,b,c,d) (p)->EnumPlayers(a,b,c,d) +#define IDirectPlay2_EnumSessions(p,a,b,c,d,e) (p)->EnumSessions(a,b,c,d,e) +#define IDirectPlay2_GetCaps(p,a,b) (p)->GetCaps(a,b) +#define IDirectPlay2_GetMessageCount(p,a,b) (p)->GetMessageCount(a,b) +#define IDirectPlay2_GetGroupData(p,a,b,c,d) (p)->GetGroupData(a,b,c,d) +#define IDirectPlay2_GetGroupName(p,a,b,c) (p)->GetGroupName(a,b,c) +#define IDirectPlay2_GetPlayerAddress(p,a,b,c) (p)->GetPlayerAddress(a,b,c) +#define IDirectPlay2_GetPlayerCaps(p,a,b,c) (p)->GetPlayerCaps(a,b,c) +#define IDirectPlay2_GetPlayerData(p,a,b,c,d) (p)->GetPlayerData(a,b,c,d) +#define IDirectPlay2_GetPlayerName(p,a,b,c) (p)->GetPlayerName(a,b,c) +#define IDirectPlay2_GetSessionDesc(p,a,b) (p)->GetSessionDesc(a,b) +#define IDirectPlay2_Initialize(p,a) (p)->Initialize(a) +#define IDirectPlay2_Open(p,a,b) (p)->Open(a,b) +#define IDirectPlay2_Receive(p,a,b,c,d,e) (p)->Receive(a,b,c,d,e) +#define IDirectPlay2_Send(p,a,b,c,d,e) (p)->Send(a,b,c,d,e) +#define IDirectPlay2_SetGroupData(p,a,b,c,d) (p)->SetGroupData(a,b,c,d) +#define IDirectPlay2_SetGroupName(p,a,b,c) (p)->SetGroupName(a,b,c) +#define IDirectPlay2_SetPlayerData(p,a,b,c,d) (p)->SetPlayerData(a,b,c,d) +#define IDirectPlay2_SetPlayerName(p,a,b,c) (p)->SetPlayerName(a,b,c) +#define IDirectPlay2_SetSessionDesc(p,a,b) (p)->SetSessionDesc(a,b) + +#endif + +/**************************************************************************** + * + * IDirectPlay3 (and IDirectPlay3A) Interface + * + ****************************************************************************/ + +#undef INTERFACE +#define INTERFACE IDirectPlay3 +DECLARE_INTERFACE_( IDirectPlay3, IDirectPlay2 ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectPlay2 methods ***/ + STDMETHOD(AddPlayerToGroup) (THIS_ DPID, DPID) PURE; + STDMETHOD(Close) (THIS) PURE; + STDMETHOD(CreateGroup) (THIS_ LPDPID,LPDPNAME,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(CreatePlayer) (THIS_ LPDPID,LPDPNAME,HANDLE,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(DeletePlayerFromGroup)(THIS_ DPID,DPID) PURE; + STDMETHOD(DestroyGroup) (THIS_ DPID) PURE; + STDMETHOD(DestroyPlayer) (THIS_ DPID) PURE; + STDMETHOD(EnumGroupPlayers) (THIS_ DPID,LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; + STDMETHOD(EnumGroups) (THIS_ LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; + STDMETHOD(EnumPlayers) (THIS_ LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; + STDMETHOD(EnumSessions) (THIS_ LPDPSESSIONDESC2,DWORD,LPDPENUMSESSIONSCALLBACK2,LPVOID,DWORD) PURE; + STDMETHOD(GetCaps) (THIS_ LPDPCAPS,DWORD) PURE; + STDMETHOD(GetGroupData) (THIS_ DPID,LPVOID,LPDWORD,DWORD) PURE; + STDMETHOD(GetGroupName) (THIS_ DPID,LPVOID,LPDWORD) PURE; + STDMETHOD(GetMessageCount) (THIS_ DPID, LPDWORD) PURE; + STDMETHOD(GetPlayerAddress) (THIS_ DPID,LPVOID,LPDWORD) PURE; + STDMETHOD(GetPlayerCaps) (THIS_ DPID,LPDPCAPS,DWORD) PURE; + STDMETHOD(GetPlayerData) (THIS_ DPID,LPVOID,LPDWORD,DWORD) PURE; + STDMETHOD(GetPlayerName) (THIS_ DPID,LPVOID,LPDWORD) PURE; + STDMETHOD(GetSessionDesc) (THIS_ LPVOID,LPDWORD) PURE; + STDMETHOD(Initialize) (THIS_ LPGUID) PURE; + STDMETHOD(Open) (THIS_ LPDPSESSIONDESC2,DWORD) PURE; + STDMETHOD(Receive) (THIS_ LPDPID,LPDPID,DWORD,LPVOID,LPDWORD) PURE; + STDMETHOD(Send) (THIS_ DPID, DPID, DWORD, LPVOID, DWORD) PURE; + STDMETHOD(SetGroupData) (THIS_ DPID,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(SetGroupName) (THIS_ DPID,LPDPNAME,DWORD) PURE; + STDMETHOD(SetPlayerData) (THIS_ DPID,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(SetPlayerName) (THIS_ DPID,LPDPNAME,DWORD) PURE; + STDMETHOD(SetSessionDesc) (THIS_ LPDPSESSIONDESC2,DWORD) PURE; + /*** IDirectPlay3 methods ***/ + STDMETHOD(AddGroupToGroup) (THIS_ DPID, DPID) PURE; + STDMETHOD(CreateGroupInGroup) (THIS_ DPID,LPDPID,LPDPNAME,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(DeleteGroupFromGroup) (THIS_ DPID,DPID) PURE; + STDMETHOD(EnumConnections) (THIS_ LPCGUID,LPDPENUMCONNECTIONSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(EnumGroupsInGroup) (THIS_ DPID,LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; + STDMETHOD(GetGroupConnectionSettings)(THIS_ DWORD, DPID, LPVOID, LPDWORD) PURE; + STDMETHOD(InitializeConnection) (THIS_ LPVOID,DWORD) PURE; + STDMETHOD(SecureOpen) (THIS_ LPCDPSESSIONDESC2,DWORD,LPCDPSECURITYDESC,LPCDPCREDENTIALS) PURE; + STDMETHOD(SendChatMessage) (THIS_ DPID,DPID,DWORD,LPDPCHAT) PURE; + STDMETHOD(SetGroupConnectionSettings)(THIS_ DWORD,DPID,LPDPLCONNECTION) PURE; + STDMETHOD(StartSession) (THIS_ DWORD,DPID) PURE; + STDMETHOD(GetGroupFlags) (THIS_ DPID,LPDWORD) PURE; + STDMETHOD(GetGroupParent) (THIS_ DPID,LPDPID) PURE; + STDMETHOD(GetPlayerAccount) (THIS_ DPID, DWORD, LPVOID, LPDWORD) PURE; + STDMETHOD(GetPlayerFlags) (THIS_ DPID,LPDWORD) PURE; +}; + +/**************************************************************************** + * + * IDirectPlay3 interface macros + * + ****************************************************************************/ + +#if !defined(__cplusplus) || defined(CINTERFACE) + +#define IDirectPlay3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlay3_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlay3_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlay3_AddPlayerToGroup(p,a,b) (p)->lpVtbl->AddPlayerToGroup(p,a,b) +#define IDirectPlay3_Close(p) (p)->lpVtbl->Close(p) +#define IDirectPlay3_CreateGroup(p,a,b,c,d,e) (p)->lpVtbl->CreateGroup(p,a,b,c,d,e) +#define IDirectPlay3_CreatePlayer(p,a,b,c,d,e,f) (p)->lpVtbl->CreatePlayer(p,a,b,c,d,e,f) +#define IDirectPlay3_DeletePlayerFromGroup(p,a,b) (p)->lpVtbl->DeletePlayerFromGroup(p,a,b) +#define IDirectPlay3_DestroyGroup(p,a) (p)->lpVtbl->DestroyGroup(p,a) +#define IDirectPlay3_DestroyPlayer(p,a) (p)->lpVtbl->DestroyPlayer(p,a) +#define IDirectPlay3_EnumGroupPlayers(p,a,b,c,d,e) (p)->lpVtbl->EnumGroupPlayers(p,a,b,c,d,e) +#define IDirectPlay3_EnumGroups(p,a,b,c,d) (p)->lpVtbl->EnumGroups(p,a,b,c,d) +#define IDirectPlay3_EnumPlayers(p,a,b,c,d) (p)->lpVtbl->EnumPlayers(p,a,b,c,d) +#define IDirectPlay3_EnumSessions(p,a,b,c,d,e) (p)->lpVtbl->EnumSessions(p,a,b,c,d,e) +#define IDirectPlay3_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) +#define IDirectPlay3_GetMessageCount(p,a,b) (p)->lpVtbl->GetMessageCount(p,a,b) +#define IDirectPlay3_GetGroupData(p,a,b,c,d) (p)->lpVtbl->GetGroupData(p,a,b,c,d) +#define IDirectPlay3_GetGroupName(p,a,b,c) (p)->lpVtbl->GetGroupName(p,a,b,c) +#define IDirectPlay3_GetPlayerAddress(p,a,b,c) (p)->lpVtbl->GetPlayerAddress(p,a,b,c) +#define IDirectPlay3_GetPlayerCaps(p,a,b,c) (p)->lpVtbl->GetPlayerCaps(p,a,b,c) +#define IDirectPlay3_GetPlayerData(p,a,b,c,d) (p)->lpVtbl->GetPlayerData(p,a,b,c,d) +#define IDirectPlay3_GetPlayerName(p,a,b,c) (p)->lpVtbl->GetPlayerName(p,a,b,c) +#define IDirectPlay3_GetSessionDesc(p,a,b) (p)->lpVtbl->GetSessionDesc(p,a,b) +#define IDirectPlay3_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#define IDirectPlay3_Open(p,a,b) (p)->lpVtbl->Open(p,a,b) +#define IDirectPlay3_Receive(p,a,b,c,d,e) (p)->lpVtbl->Receive(p,a,b,c,d,e) +#define IDirectPlay3_Send(p,a,b,c,d,e) (p)->lpVtbl->Send(p,a,b,c,d,e) +#define IDirectPlay3_SetGroupData(p,a,b,c,d) (p)->lpVtbl->SetGroupData(p,a,b,c,d) +#define IDirectPlay3_SetGroupName(p,a,b,c) (p)->lpVtbl->SetGroupName(p,a,b,c) +#define IDirectPlay3_SetPlayerData(p,a,b,c,d) (p)->lpVtbl->SetPlayerData(p,a,b,c,d) +#define IDirectPlay3_SetPlayerName(p,a,b,c) (p)->lpVtbl->SetPlayerName(p,a,b,c) +#define IDirectPlay3_SetSessionDesc(p,a,b) (p)->lpVtbl->SetSessionDesc(p,a,b) +#define IDirectPlay3_AddGroupToGroup(p,a,b) (p)->lpVtbl->AddGroupToGroup(p,a,b) +#define IDirectPlay3_CreateGroupInGroup(p,a,b,c,d,e,f) (p)->lpVtbl->CreateGroupInGroup(p,a,b,c,d,e,f) +#define IDirectPlay3_DeleteGroupFromGroup(p,a,b) (p)->lpVtbl->DeleteGroupFromGroup(p,a,b) +#define IDirectPlay3_EnumConnections(p,a,b,c,d) (p)->lpVtbl->EnumConnections(p,a,b,c,d) +#define IDirectPlay3_EnumGroupsInGroup(p,a,b,c,d,e) (p)->lpVtbl->EnumGroupsInGroup(p,a,b,c,d,e) +#define IDirectPlay3_GetGroupConnectionSettings(p,a,b,c,d) (p)->lpVtbl->GetGroupConnectionSettings(p,a,b,c,d) +#define IDirectPlay3_InitializeConnection(p,a,b) (p)->lpVtbl->InitializeConnection(p,a,b) +#define IDirectPlay3_SecureOpen(p,a,b,c,d) (p)->lpVtbl->SecureOpen(p,a,b,c,d) +#define IDirectPlay3_SendChatMessage(p,a,b,c,d) (p)->lpVtbl->SendChatMessage(p,a,b,c,d) +#define IDirectPlay3_SetGroupConnectionSettings(p,a,b,c) (p)->lpVtbl->SetGroupConnectionSettings(p,a,b,c) +#define IDirectPlay3_StartSession(p,a,b) (p)->lpVtbl->StartSession(p,a,b) +#define IDirectPlay3_GetGroupFlags(p,a,b) (p)->lpVtbl->GetGroupFlags(p,a,b) +#define IDirectPlay3_GetGroupParent(p,a,b) (p)->lpVtbl->GetGroupParent(p,a,b) +#define IDirectPlay3_GetPlayerAccount(p,a,b,c,d) (p)->lpVtbl->GetPlayerAccount(p,a,b,c,d) +#define IDirectPlay3_GetPlayerFlags(p,a,b) (p)->lpVtbl->GetPlayerFlags(p,a,b) + +#else /* C++ */ + +#define IDirectPlay3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlay3_AddRef(p) (p)->AddRef() +#define IDirectPlay3_Release(p) (p)->Release() +#define IDirectPlay3_AddPlayerToGroup(p,a,b) (p)->AddPlayerToGroup(a,b) +#define IDirectPlay3_Close(p) (p)->Close() +#define IDirectPlay3_CreateGroup(p,a,b,c,d,e) (p)->CreateGroup(a,b,c,d,e) +#define IDirectPlay3_CreatePlayer(p,a,b,c,d,e,f) (p)->CreatePlayer(a,b,c,d,e,f) +#define IDirectPlay3_DeletePlayerFromGroup(p,a,b) (p)->DeletePlayerFromGroup(a,b) +#define IDirectPlay3_DestroyGroup(p,a) (p)->DestroyGroup(a) +#define IDirectPlay3_DestroyPlayer(p,a) (p)->DestroyPlayer(a) +#define IDirectPlay3_EnumGroupPlayers(p,a,b,c,d,e) (p)->EnumGroupPlayers(a,b,c,d,e) +#define IDirectPlay3_EnumGroups(p,a,b,c,d) (p)->EnumGroups(a,b,c,d) +#define IDirectPlay3_EnumPlayers(p,a,b,c,d) (p)->EnumPlayers(a,b,c,d) +#define IDirectPlay3_EnumSessions(p,a,b,c,d,e) (p)->EnumSessions(a,b,c,d,e) +#define IDirectPlay3_GetCaps(p,a,b) (p)->GetCaps(a,b) +#define IDirectPlay3_GetMessageCount(p,a,b) (p)->GetMessageCount(a,b) +#define IDirectPlay3_GetGroupData(p,a,b,c,d) (p)->GetGroupData(a,b,c,d) +#define IDirectPlay3_GetGroupName(p,a,b,c) (p)->GetGroupName(a,b,c) +#define IDirectPlay3_GetPlayerAddress(p,a,b,c) (p)->GetPlayerAddress(a,b,c) +#define IDirectPlay3_GetPlayerCaps(p,a,b,c) (p)->GetPlayerCaps(a,b,c) +#define IDirectPlay3_GetPlayerData(p,a,b,c,d) (p)->GetPlayerData(a,b,c,d) +#define IDirectPlay3_GetPlayerName(p,a,b,c) (p)->GetPlayerName(a,b,c) +#define IDirectPlay3_GetSessionDesc(p,a,b) (p)->GetSessionDesc(a,b) +#define IDirectPlay3_Initialize(p,a) (p)->Initialize(a) +#define IDirectPlay3_Open(p,a,b) (p)->Open(a,b) +#define IDirectPlay3_Receive(p,a,b,c,d,e) (p)->Receive(a,b,c,d,e) +#define IDirectPlay3_Send(p,a,b,c,d,e) (p)->Send(a,b,c,d,e) +#define IDirectPlay3_SetGroupData(p,a,b,c,d) (p)->SetGroupData(a,b,c,d) +#define IDirectPlay3_SetGroupName(p,a,b,c) (p)->SetGroupName(a,b,c) +#define IDirectPlay3_SetPlayerData(p,a,b,c,d) (p)->SetPlayerData(a,b,c,d) +#define IDirectPlay3_SetPlayerName(p,a,b,c) (p)->SetPlayerName(a,b,c) +#define IDirectPlay3_SetSessionDesc(p,a,b) (p)->SetSessionDesc(a,b) +#define IDirectPlay3_AddGroupToGroup(p,a,b) (p)->AddGroupToGroup(a,b) +#define IDirectPlay3_CreateGroupInGroup(p,a,b,c,d,e,f) (p)->CreateGroupInGroup(a,b,c,d,e,f) +#define IDirectPlay3_DeleteGroupFromGroup(p,a,b) (p)->DeleteGroupFromGroup(a,b) +#define IDirectPlay3_EnumConnections(p,a,b,c,d) (p)->EnumConnections(a,b,c,d) +#define IDirectPlay3_EnumGroupsInGroup(p,a,b,c,d,e) (p)->EnumGroupsInGroup(a,b,c,d,e) +#define IDirectPlay3_GetGroupConnectionSettings(p,a,b,c,d) (p)->GetGroupConnectionSettings(a,b,c,d) +#define IDirectPlay3_InitializeConnection(p,a,b) (p)->InitializeConnection(a,b) +#define IDirectPlay3_SecureOpen(p,a,b,c,d) (p)->SecureOpen(a,b,c,d) +#define IDirectPlay3_SendChatMessage(p,a,b,c,d) (p)->SendChatMessage(a,b,c,d) +#define IDirectPlay3_SetGroupConnectionSettings(p,a,b,c) (p)->SetGroupConnectionSettings(a,b,c) +#define IDirectPlay3_StartSession(p,a,b) (p)->StartSession(a,b) +#define IDirectPlay3_GetGroupFlags(p,a,b) (p)->GetGroupFlags(a,b) +#define IDirectPlay3_GetGroupParent(p,a,b) (p)->GetGroupParent(a,b) +#define IDirectPlay3_GetPlayerAccount(p,a,b,c,d) (p)->GetPlayerAccount(a,b,c,d) +#define IDirectPlay3_GetPlayerFlags(p,a,b) (p)->GetPlayerFlags(a,b) + +#endif + +/**************************************************************************** + * + * IDirectPlay4 (and IDirectPlay4A) Interface + * + ****************************************************************************/ + +#undef INTERFACE +#define INTERFACE IDirectPlay4 +DECLARE_INTERFACE_( IDirectPlay4, IDirectPlay3 ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectPlay2 methods ***/ + STDMETHOD(AddPlayerToGroup) (THIS_ DPID, DPID) PURE; + STDMETHOD(Close) (THIS) PURE; + STDMETHOD(CreateGroup) (THIS_ LPDPID,LPDPNAME,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(CreatePlayer) (THIS_ LPDPID,LPDPNAME,HANDLE,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(DeletePlayerFromGroup)(THIS_ DPID,DPID) PURE; + STDMETHOD(DestroyGroup) (THIS_ DPID) PURE; + STDMETHOD(DestroyPlayer) (THIS_ DPID) PURE; + STDMETHOD(EnumGroupPlayers) (THIS_ DPID,LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; + STDMETHOD(EnumGroups) (THIS_ LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; + STDMETHOD(EnumPlayers) (THIS_ LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; + STDMETHOD(EnumSessions) (THIS_ LPDPSESSIONDESC2,DWORD,LPDPENUMSESSIONSCALLBACK2,LPVOID,DWORD) PURE; + STDMETHOD(GetCaps) (THIS_ LPDPCAPS,DWORD) PURE; + STDMETHOD(GetGroupData) (THIS_ DPID,LPVOID,LPDWORD,DWORD) PURE; + STDMETHOD(GetGroupName) (THIS_ DPID,LPVOID,LPDWORD) PURE; + STDMETHOD(GetMessageCount) (THIS_ DPID, LPDWORD) PURE; + STDMETHOD(GetPlayerAddress) (THIS_ DPID,LPVOID,LPDWORD) PURE; + STDMETHOD(GetPlayerCaps) (THIS_ DPID,LPDPCAPS,DWORD) PURE; + STDMETHOD(GetPlayerData) (THIS_ DPID,LPVOID,LPDWORD,DWORD) PURE; + STDMETHOD(GetPlayerName) (THIS_ DPID,LPVOID,LPDWORD) PURE; + STDMETHOD(GetSessionDesc) (THIS_ LPVOID,LPDWORD) PURE; + STDMETHOD(Initialize) (THIS_ LPGUID) PURE; + STDMETHOD(Open) (THIS_ LPDPSESSIONDESC2,DWORD) PURE; + STDMETHOD(Receive) (THIS_ LPDPID,LPDPID,DWORD,LPVOID,LPDWORD) PURE; + STDMETHOD(Send) (THIS_ DPID, DPID, DWORD, LPVOID, DWORD) PURE; + STDMETHOD(SetGroupData) (THIS_ DPID,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(SetGroupName) (THIS_ DPID,LPDPNAME,DWORD) PURE; + STDMETHOD(SetPlayerData) (THIS_ DPID,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(SetPlayerName) (THIS_ DPID,LPDPNAME,DWORD) PURE; + STDMETHOD(SetSessionDesc) (THIS_ LPDPSESSIONDESC2,DWORD) PURE; + /*** IDirectPlay3 methods ***/ + STDMETHOD(AddGroupToGroup) (THIS_ DPID, DPID) PURE; + STDMETHOD(CreateGroupInGroup) (THIS_ DPID,LPDPID,LPDPNAME,LPVOID,DWORD,DWORD) PURE; + STDMETHOD(DeleteGroupFromGroup) (THIS_ DPID,DPID) PURE; + STDMETHOD(EnumConnections) (THIS_ LPCGUID,LPDPENUMCONNECTIONSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(EnumGroupsInGroup) (THIS_ DPID,LPGUID,LPDPENUMPLAYERSCALLBACK2,LPVOID,DWORD) PURE; + STDMETHOD(GetGroupConnectionSettings)(THIS_ DWORD, DPID, LPVOID, LPDWORD) PURE; + STDMETHOD(InitializeConnection) (THIS_ LPVOID,DWORD) PURE; + STDMETHOD(SecureOpen) (THIS_ LPCDPSESSIONDESC2,DWORD,LPCDPSECURITYDESC,LPCDPCREDENTIALS) PURE; + STDMETHOD(SendChatMessage) (THIS_ DPID,DPID,DWORD,LPDPCHAT) PURE; + STDMETHOD(SetGroupConnectionSettings)(THIS_ DWORD,DPID,LPDPLCONNECTION) PURE; + STDMETHOD(StartSession) (THIS_ DWORD,DPID) PURE; + STDMETHOD(GetGroupFlags) (THIS_ DPID,LPDWORD) PURE; + STDMETHOD(GetGroupParent) (THIS_ DPID,LPDPID) PURE; + STDMETHOD(GetPlayerAccount) (THIS_ DPID, DWORD, LPVOID, LPDWORD) PURE; + STDMETHOD(GetPlayerFlags) (THIS_ DPID,LPDWORD) PURE; + /*** IDirectPlay4 methods ***/ + STDMETHOD(GetGroupOwner) (THIS_ DPID, LPDPID) PURE; + STDMETHOD(SetGroupOwner) (THIS_ DPID, DPID) PURE; + STDMETHOD(SendEx) (THIS_ DPID, DPID, DWORD, LPVOID, DWORD, DWORD, DWORD, LPVOID, DWORD_PTR *) PURE; + STDMETHOD(GetMessageQueue) (THIS_ DPID, DPID, DWORD, LPDWORD, LPDWORD) PURE; + STDMETHOD(CancelMessage) (THIS_ DWORD, DWORD) PURE; + STDMETHOD(CancelPriority) (THIS_ DWORD, DWORD, DWORD) PURE; +}; + +/**************************************************************************** + * + * IDirectPlayX interface macros (for IDirectPlay4 and beyond) + * + ****************************************************************************/ + +#if !defined(__cplusplus) || defined(CINTERFACE) + +#define IDirectPlayX_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlayX_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlayX_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlayX_AddPlayerToGroup(p,a,b) (p)->lpVtbl->AddPlayerToGroup(p,a,b) +#define IDirectPlayX_CancelMessage(p,a,b) (p)->lpVtbl->CancelMessage(p,a,b) +#define IDirectPlayX_CancelPriority(p,a,b,c) (p)->lpVtbl->CancelPriority(p,a,b,c) +#define IDirectPlayX_Close(p) (p)->lpVtbl->Close(p) +#define IDirectPlayX_CreateGroup(p,a,b,c,d,e) (p)->lpVtbl->CreateGroup(p,a,b,c,d,e) +#define IDirectPlayX_CreatePlayer(p,a,b,c,d,e,f) (p)->lpVtbl->CreatePlayer(p,a,b,c,d,e,f) +#define IDirectPlayX_DeletePlayerFromGroup(p,a,b) (p)->lpVtbl->DeletePlayerFromGroup(p,a,b) +#define IDirectPlayX_DestroyGroup(p,a) (p)->lpVtbl->DestroyGroup(p,a) +#define IDirectPlayX_DestroyPlayer(p,a) (p)->lpVtbl->DestroyPlayer(p,a) +#define IDirectPlayX_EnumGroupPlayers(p,a,b,c,d,e) (p)->lpVtbl->EnumGroupPlayers(p,a,b,c,d,e) +#define IDirectPlayX_EnumGroups(p,a,b,c,d) (p)->lpVtbl->EnumGroups(p,a,b,c,d) +#define IDirectPlayX_EnumPlayers(p,a,b,c,d) (p)->lpVtbl->EnumPlayers(p,a,b,c,d) +#define IDirectPlayX_EnumSessions(p,a,b,c,d,e) (p)->lpVtbl->EnumSessions(p,a,b,c,d,e) +#define IDirectPlayX_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) +#define IDirectPlayX_GetMessageCount(p,a,b) (p)->lpVtbl->GetMessageCount(p,a,b) +#define IDirectPlayX_GetMessageQueue(p,a,b,c,d,e) (p)->lpVtbl->GetMessageQueue(p,a,b,c,d,e) +#define IDirectPlayX_GetGroupData(p,a,b,c,d) (p)->lpVtbl->GetGroupData(p,a,b,c,d) +#define IDirectPlayX_GetGroupName(p,a,b,c) (p)->lpVtbl->GetGroupName(p,a,b,c) +#define IDirectPlayX_GetPlayerAddress(p,a,b,c) (p)->lpVtbl->GetPlayerAddress(p,a,b,c) +#define IDirectPlayX_GetPlayerCaps(p,a,b,c) (p)->lpVtbl->GetPlayerCaps(p,a,b,c) +#define IDirectPlayX_GetPlayerData(p,a,b,c,d) (p)->lpVtbl->GetPlayerData(p,a,b,c,d) +#define IDirectPlayX_GetPlayerName(p,a,b,c) (p)->lpVtbl->GetPlayerName(p,a,b,c) +#define IDirectPlayX_GetSessionDesc(p,a,b) (p)->lpVtbl->GetSessionDesc(p,a,b) +#define IDirectPlayX_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#define IDirectPlayX_Open(p,a,b) (p)->lpVtbl->Open(p,a,b) +#define IDirectPlayX_Receive(p,a,b,c,d,e) (p)->lpVtbl->Receive(p,a,b,c,d,e) +#define IDirectPlayX_Send(p,a,b,c,d,e) (p)->lpVtbl->Send(p,a,b,c,d,e) +#define IDirectPlayX_SendEx(p,a,b,c,d,e,f,g,h,i) (p)->lpVtbl->SendEx(p,a,b,c,d,e,f,g,h,i) +#define IDirectPlayX_SetGroupData(p,a,b,c,d) (p)->lpVtbl->SetGroupData(p,a,b,c,d) +#define IDirectPlayX_SetGroupName(p,a,b,c) (p)->lpVtbl->SetGroupName(p,a,b,c) +#define IDirectPlayX_SetPlayerData(p,a,b,c,d) (p)->lpVtbl->SetPlayerData(p,a,b,c,d) +#define IDirectPlayX_SetPlayerName(p,a,b,c) (p)->lpVtbl->SetPlayerName(p,a,b,c) +#define IDirectPlayX_SetSessionDesc(p,a,b) (p)->lpVtbl->SetSessionDesc(p,a,b) +#define IDirectPlayX_AddGroupToGroup(p,a,b) (p)->lpVtbl->AddGroupToGroup(p,a,b) +#define IDirectPlayX_CreateGroupInGroup(p,a,b,c,d,e,f) (p)->lpVtbl->CreateGroupInGroup(p,a,b,c,d,e,f) +#define IDirectPlayX_DeleteGroupFromGroup(p,a,b) (p)->lpVtbl->DeleteGroupFromGroup(p,a,b) +#define IDirectPlayX_EnumConnections(p,a,b,c,d) (p)->lpVtbl->EnumConnections(p,a,b,c,d) +#define IDirectPlayX_EnumGroupsInGroup(p,a,b,c,d,e) (p)->lpVtbl->EnumGroupsInGroup(p,a,b,c,d,e) +#define IDirectPlayX_GetGroupConnectionSettings(p,a,b,c,d) (p)->lpVtbl->GetGroupConnectionSettings(p,a,b,c,d) +#define IDirectPlayX_InitializeConnection(p,a,b) (p)->lpVtbl->InitializeConnection(p,a,b) +#define IDirectPlayX_SecureOpen(p,a,b,c,d) (p)->lpVtbl->SecureOpen(p,a,b,c,d) +#define IDirectPlayX_SendChatMessage(p,a,b,c,d) (p)->lpVtbl->SendChatMessage(p,a,b,c,d) +#define IDirectPlayX_SetGroupConnectionSettings(p,a,b,c) (p)->lpVtbl->SetGroupConnectionSettings(p,a,b,c) +#define IDirectPlayX_StartSession(p,a,b) (p)->lpVtbl->StartSession(p,a,b) +#define IDirectPlayX_GetGroupFlags(p,a,b) (p)->lpVtbl->GetGroupFlags(p,a,b) +#define IDirectPlayX_GetGroupParent(p,a,b) (p)->lpVtbl->GetGroupParent(p,a,b) +#define IDirectPlayX_GetPlayerAccount(p,a,b,c,d) (p)->lpVtbl->GetPlayerAccount(p,a,b,c,d) +#define IDirectPlayX_GetPlayerFlags(p,a,b) (p)->lpVtbl->GetPlayerFlags(p,a,b) +#define IDirectPlayX_GetGroupOwner(p,a,b) (p)->lpVtbl->GetGroupOwner(p,a,b) +#define IDirectPlayX_SetGroupOwner(p,a,b) (p)->lpVtbl->SetGroupOwner(p,a,b) + +#else /* C++ */ + +#define IDirectPlayX_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlayX_AddRef(p) (p)->AddRef() +#define IDirectPlayX_Release(p) (p)->Release() +#define IDirectPlayX_AddPlayerToGroup(p,a,b) (p)->AddPlayerToGroup(a,b) +#define IDirectPlayX_CancelMessage(p,a,b) (p)->CancelMessage(a,b) +#define IDirectPlayX_CancelPriority(p,a,b,c) (p)->CancelPriority(a,b,c) +#define IDirectPlayX_Close(p) (p)->Close() +#define IDirectPlayX_CreateGroup(p,a,b,c,d,e) (p)->CreateGroup(a,b,c,d,e) +#define IDirectPlayX_CreatePlayer(p,a,b,c,d,e,f) (p)->CreatePlayer(a,b,c,d,e,f) +#define IDirectPlayX_DeletePlayerFromGroup(p,a,b) (p)->DeletePlayerFromGroup(a,b) +#define IDirectPlayX_DestroyGroup(p,a) (p)->DestroyGroup(a) +#define IDirectPlayX_DestroyPlayer(p,a) (p)->DestroyPlayer(a) +#define IDirectPlayX_EnumGroupPlayers(p,a,b,c,d,e) (p)->EnumGroupPlayers(a,b,c,d,e) +#define IDirectPlayX_EnumGroups(p,a,b,c,d) (p)->EnumGroups(a,b,c,d) +#define IDirectPlayX_EnumPlayers(p,a,b,c,d) (p)->EnumPlayers(a,b,c,d) +#define IDirectPlayX_EnumSessions(p,a,b,c,d,e) (p)->EnumSessions(a,b,c,d,e) +#define IDirectPlayX_GetCaps(p,a,b) (p)->GetCaps(a,b) +#define IDirectPlayX_GetMessageCount(p,a,b) (p)->GetMessageCount(a,b) +#define IDirectPlayX_GetMessageQueue(p,a,b,c,d,e) (p)->GetMessageQueue(a,b,c,d,e) +#define IDirectPlayX_GetGroupData(p,a,b,c,d) (p)->GetGroupData(a,b,c,d) +#define IDirectPlayX_GetGroupName(p,a,b,c) (p)->GetGroupName(a,b,c) +#define IDirectPlayX_GetPlayerAddress(p,a,b,c) (p)->GetPlayerAddress(a,b,c) +#define IDirectPlayX_GetPlayerCaps(p,a,b,c) (p)->GetPlayerCaps(a,b,c) +#define IDirectPlayX_GetPlayerData(p,a,b,c,d) (p)->GetPlayerData(a,b,c,d) +#define IDirectPlayX_GetPlayerName(p,a,b,c) (p)->GetPlayerName(a,b,c) +#define IDirectPlayX_GetSessionDesc(p,a,b) (p)->GetSessionDesc(a,b) +#define IDirectPlayX_Initialize(p,a) (p)->Initialize(a) +#define IDirectPlayX_Open(p,a,b) (p)->Open(a,b) +#define IDirectPlayX_Receive(p,a,b,c,d,e) (p)->Receive(a,b,c,d,e) +#define IDirectPlayX_Send(p,a,b,c,d,e) (p)->Send(a,b,c,d,e) +#define IDirectPlayX_SendEx(p,a,b,c,d,e,f,g,h,i) (p)->SendEx(a,b,c,d,e,f,g,h,i) +#define IDirectPlayX_SetGroupData(p,a,b,c,d) (p)->SetGroupData(a,b,c,d) +#define IDirectPlayX_SetGroupName(p,a,b,c) (p)->SetGroupName(a,b,c) +#define IDirectPlayX_SetPlayerData(p,a,b,c,d) (p)->SetPlayerData(a,b,c,d) +#define IDirectPlayX_SetPlayerName(p,a,b,c) (p)->SetPlayerName(a,b,c) +#define IDirectPlayX_SetSessionDesc(p,a,b) (p)->SetSessionDesc(a,b) +#define IDirectPlayX_AddGroupToGroup(p,a,b) (p)->AddGroupToGroup(a,b) +#define IDirectPlayX_CreateGroupInGroup(p,a,b,c,d,e,f) (p)->CreateGroupInGroup(a,b,c,d,e,f) +#define IDirectPlayX_DeleteGroupFromGroup(p,a,b) (p)->DeleteGroupFromGroup(a,b) +#define IDirectPlayX_EnumConnections(p,a,b,c,d) (p)->EnumConnections(a,b,c,d) +#define IDirectPlayX_EnumGroupsInGroup(p,a,b,c,d,e) (p)->EnumGroupsInGroup(a,b,c,d,e) +#define IDirectPlayX_GetGroupConnectionSettings(p,a,b,c,d) (p)->GetGroupConnectionSettings(a,b,c,d) +#define IDirectPlayX_InitializeConnection(p,a,b) (p)->InitializeConnection(a,b) +#define IDirectPlayX_SecureOpen(p,a,b,c,d) (p)->SecureOpen(a,b,c,d) +#define IDirectPlayX_SendChatMessage(p,a,b,c,d) (p)->SendChatMessage(a,b,c,d) +#define IDirectPlayX_SetGroupConnectionSettings(p,a,b,c) (p)->SetGroupConnectionSettings(a,b,c) +#define IDirectPlayX_StartSession(p,a,b) (p)->StartSession(a,b) +#define IDirectPlayX_GetGroupFlags(p,a,b) (p)->GetGroupFlags(a,b) +#define IDirectPlayX_GetGroupParent(p,a,b) (p)->GetGroupParent(a,b) +#define IDirectPlayX_GetPlayerAccount(p,a,b,c,d) (p)->GetPlayerAccount(a,b,c,d) +#define IDirectPlayX_GetPlayerFlags(p,a,b) (p)->GetPlayerFlags(a,b) +#define IDirectPlayX_GetGroupOwner(p,a,b) (p)->GetGroupOwner(a,b) +#define IDirectPlayX_SetGroupOwner(p,a,b) (p)->SetGroupOwner(a,b) + +#endif + +/**************************************************************************** + * + * EnumConnections API flags + * + ****************************************************************************/ + +/* + * Enumerate Service Providers + */ +#define DPCONNECTION_DIRECTPLAY 0x00000001 + +/* + * Enumerate Lobby Providers + */ +#define DPCONNECTION_DIRECTPLAYLOBBY 0x00000002 + + +/**************************************************************************** + * + * EnumPlayers API flags + * + ****************************************************************************/ + +/* + * Enumerate all players in the current session + */ +#define DPENUMPLAYERS_ALL 0x00000000 +#define DPENUMGROUPS_ALL DPENUMPLAYERS_ALL + + +/* + * Enumerate only local (created by this application) players + * or groups + */ +#define DPENUMPLAYERS_LOCAL 0x00000008 +#define DPENUMGROUPS_LOCAL DPENUMPLAYERS_LOCAL + +/* + * Enumerate only remote (non-local) players + * or groups + */ +#define DPENUMPLAYERS_REMOTE 0x00000010 +#define DPENUMGROUPS_REMOTE DPENUMPLAYERS_REMOTE + +/* + * Enumerate groups along with the players + */ +#define DPENUMPLAYERS_GROUP 0x00000020 + +/* + * Enumerate players or groups in another session + * (must supply lpguidInstance) + */ +#define DPENUMPLAYERS_SESSION 0x00000080 +#define DPENUMGROUPS_SESSION DPENUMPLAYERS_SESSION + +/* + * Enumerate server players + */ +#define DPENUMPLAYERS_SERVERPLAYER 0x00000100 + +/* + * Enumerate spectator players + */ +#define DPENUMPLAYERS_SPECTATOR 0x00000200 + +/* + * Enumerate shortcut groups + */ +#define DPENUMGROUPS_SHORTCUT 0x00000400 + +/* + * Enumerate staging area groups + */ +#define DPENUMGROUPS_STAGINGAREA 0x00000800 + +/* + * Enumerate hidden groups + */ +#define DPENUMGROUPS_HIDDEN 0x00001000 + +/* + * Enumerate the group's owner + */ +#define DPENUMPLAYERS_OWNER 0x00002000 + + +/**************************************************************************** + * + * CreatePlayer API flags + * + ****************************************************************************/ + +/* + * This flag indicates that this player should be designated + * the server player. The app should specify this at CreatePlayer. + */ +#define DPPLAYER_SERVERPLAYER DPENUMPLAYERS_SERVERPLAYER + +/* + * This flag indicates that this player should be designated + * a spectator. The app should specify this at CreatePlayer. + */ +#define DPPLAYER_SPECTATOR DPENUMPLAYERS_SPECTATOR + +/* + * This flag indicates that this player was created locally. + * (returned from GetPlayerFlags) + */ +#define DPPLAYER_LOCAL DPENUMPLAYERS_LOCAL + +/* + * This flag indicates that this player is the group's owner + * (Only returned in EnumGroupPlayers) + */ +#define DPPLAYER_OWNER DPENUMPLAYERS_OWNER + +/**************************************************************************** + * + * CreateGroup API flags + * + ****************************************************************************/ + + +/* + * This flag indicates that the StartSession can be called on the group. + * The app should specify this at CreateGroup, or CreateGroupInGroup. + */ +#define DPGROUP_STAGINGAREA DPENUMGROUPS_STAGINGAREA + +/* + * This flag indicates that this group was created locally. + * (returned from GetGroupFlags) + */ +#define DPGROUP_LOCAL DPENUMGROUPS_LOCAL + +/* + * This flag indicates that this group was created hidden. + */ +#define DPGROUP_HIDDEN DPENUMGROUPS_HIDDEN + + +/**************************************************************************** + * + * EnumSessions API flags + * + ****************************************************************************/ + +/* + * Enumerate sessions which can be joined + */ +#define DPENUMSESSIONS_AVAILABLE 0x00000001 + +/* + * Enumerate all sessions even if they can't be joined. + */ +#define DPENUMSESSIONS_ALL 0x00000002 + + +/* + * Start an asynchronous enum sessions + */ + #define DPENUMSESSIONS_ASYNC 0x00000010 + +/* + * Stop an asynchronous enum sessions + */ + #define DPENUMSESSIONS_STOPASYNC 0x00000020 + +/* + * Enumerate sessions even if they require a password + */ + #define DPENUMSESSIONS_PASSWORDREQUIRED 0x00000040 + +/* + * Return status about progress of enumeration instead of + * showing any status dialogs. + */ + #define DPENUMSESSIONS_RETURNSTATUS 0x00000080 + +/**************************************************************************** + * + * GetCaps and GetPlayerCaps API flags + * + ****************************************************************************/ + +/* + * The latency returned should be for guaranteed message sending. + * Default is non-guaranteed messaging. + */ +#define DPGETCAPS_GUARANTEED 0x00000001 + + +/**************************************************************************** + * + * GetGroupData, GetPlayerData API flags + * Remote and local Group/Player data is maintained separately. + * Default is DPGET_REMOTE. + * + ****************************************************************************/ + +/* + * Get the remote data (set by any DirectPlay object in + * the session using DPSET_REMOTE) + */ +#define DPGET_REMOTE 0x00000000 + +/* + * Get the local data (set by this DirectPlay object + * using DPSET_LOCAL) + */ +#define DPGET_LOCAL 0x00000001 + + +/**************************************************************************** + * + * Open API flags + * + ****************************************************************************/ + +/* + * Join the session that is described by the DPSESSIONDESC2 structure + */ +#define DPOPEN_JOIN 0x00000001 + +/* + * Create a new session as described by the DPSESSIONDESC2 structure + */ +#define DPOPEN_CREATE 0x00000002 + +/* + * Return status about progress of open instead of showing + * any status dialogs. + */ + #define DPOPEN_RETURNSTATUS DPENUMSESSIONS_RETURNSTATUS + + +/**************************************************************************** + * + * DPLCONNECTION flags + * + ****************************************************************************/ + +/* + * This application should create a new session as + * described by the DPSESIONDESC structure + */ +#define DPLCONNECTION_CREATESESSION DPOPEN_CREATE + +/* + * This application should join the session described by + * the DPSESIONDESC structure with the lpAddress data + */ +#define DPLCONNECTION_JOINSESSION DPOPEN_JOIN + +/**************************************************************************** + * + * Receive API flags + * Default is DPRECEIVE_ALL + * + ****************************************************************************/ + +/* + * Get the first message in the queue + */ +#define DPRECEIVE_ALL 0x00000001 + +/* + * Get the first message in the queue directed to a specific player + */ +#define DPRECEIVE_TOPLAYER 0x00000002 + +/* + * Get the first message in the queue from a specific player + */ +#define DPRECEIVE_FROMPLAYER 0x00000004 + +/* + * Get the message but don't remove it from the queue + */ +#define DPRECEIVE_PEEK 0x00000008 + + +/**************************************************************************** + * + * Send API flags + * + ****************************************************************************/ + +/* + * Send the message using a guaranteed send method. + * Default is non-guaranteed. + */ +#define DPSEND_GUARANTEED 0x00000001 + + +/* + * This flag is obsolete. It is ignored by DirectPlay + */ +#define DPSEND_HIGHPRIORITY 0x00000002 + +/* + * This flag is obsolete. It is ignored by DirectPlay + */ +#define DPSEND_OPENSTREAM 0x00000008 + +/* + * This flag is obsolete. It is ignored by DirectPlay + */ +#define DPSEND_CLOSESTREAM 0x00000010 + +/* + * Send the message digitally signed to ensure authenticity. + */ +#define DPSEND_SIGNED 0x00000020 + +/* + * Send the message with encryption to ensure privacy. + */ +#define DPSEND_ENCRYPTED 0x00000040 + +/* + * The message is a lobby system message + */ +#define DPSEND_LOBBYSYSTEMMESSAGE 0x00000080 + + +/* + * Send message asynchronously, must check caps + * before using this flag. It is always provided + * if the protocol flag is set. + */ +#define DPSEND_ASYNC 0x00000200 + +/* + * When an message is completed, don't tell me. + * by default the application is notified with a system message. + */ +#define DPSEND_NOSENDCOMPLETEMSG 0x00000400 + + +/* + * Maximum priority for sends available to applications + */ +#define DPSEND_MAX_PRI 0x0000FFFF +#define DPSEND_MAX_PRIORITY DPSEND_MAX_PRI + + +/**************************************************************************** + * + * SetGroupData, SetGroupName, SetPlayerData, SetPlayerName, + * SetSessionDesc API flags. + * Default is DPSET_REMOTE. + * + ****************************************************************************/ + +/* + * Propagate the data to all players in the session + */ +#define DPSET_REMOTE 0x00000000 + +/* + * Do not propagate the data to other players + */ +#define DPSET_LOCAL 0x00000001 + +/* + * Used with DPSET_REMOTE, use guaranteed message send to + * propagate the data + */ +#define DPSET_GUARANTEED 0x00000002 + +/**************************************************************************** + * + * GetMessageQueue API flags. + * Default is DPMESSAGEQUEUE_SEND + * + ****************************************************************************/ + +/* + * Get Send Queue - requires Service Provider Support + */ +#define DPMESSAGEQUEUE_SEND 0x00000001 + +/* + * Get Receive Queue + */ +#define DPMESSAGEQUEUE_RECEIVE 0x00000002 + + +/**************************************************************************** + * + * Connect API flags + * + ****************************************************************************/ + + +/* + * Start an asynchronous connect which returns status codes + */ +#define DPCONNECT_RETURNSTATUS (DPENUMSESSIONS_RETURNSTATUS) + + +/**************************************************************************** + * + * DirectPlay system messages and message data structures + * + * All system message come 'From' player DPID_SYSMSG. To determine what type + * of message it is, cast the lpData from Receive to DPMSG_GENERIC and check + * the dwType member against one of the following DPSYS_xxx constants. Once + * a match is found, cast the lpData to the corresponding of the DPMSG_xxx + * structures to access the data of the message. + * + ****************************************************************************/ + +/* + * A new player or group has been created in the session + * Use DPMSG_CREATEPLAYERORGROUP. Check dwPlayerType to see if it + * is a player or a group. + */ +#define DPSYS_CREATEPLAYERORGROUP 0x0003 + +/* + * A player has been deleted from the session + * Use DPMSG_DESTROYPLAYERORGROUP + */ +#define DPSYS_DESTROYPLAYERORGROUP 0x0005 + +/* + * A player has been added to a group + * Use DPMSG_ADDPLAYERTOGROUP + */ +#define DPSYS_ADDPLAYERTOGROUP 0x0007 + +/* + * A player has been removed from a group + * Use DPMSG_DELETEPLAYERFROMGROUP + */ +#define DPSYS_DELETEPLAYERFROMGROUP 0x0021 + +/* + * This DirectPlay object lost its connection with all the + * other players in the session. + * Use DPMSG_SESSIONLOST. + */ +#define DPSYS_SESSIONLOST 0x0031 + +/* + * The current host has left the session. + * This DirectPlay object is now the host. + * Use DPMSG_HOST. + */ +#define DPSYS_HOST 0x0101 + +/* + * The remote data associated with a player or + * group has changed. Check dwPlayerType to see + * if it is a player or a group + * Use DPMSG_SETPLAYERORGROUPDATA + */ +#define DPSYS_SETPLAYERORGROUPDATA 0x0102 + +/* + * The name of a player or group has changed. + * Check dwPlayerType to see if it is a player + * or a group. + * Use DPMSG_SETPLAYERORGROUPNAME + */ +#define DPSYS_SETPLAYERORGROUPNAME 0x0103 + +/* + * The session description has changed. + * Use DPMSG_SETSESSIONDESC + */ +#define DPSYS_SETSESSIONDESC 0x0104 + +/* + * A group has been added to a group + * Use DPMSG_ADDGROUPTOGROUP + */ +#define DPSYS_ADDGROUPTOGROUP 0x0105 + +/* + * A group has been removed from a group + * Use DPMSG_DELETEGROUPFROMGROUP + */ +#define DPSYS_DELETEGROUPFROMGROUP 0x0106 + +/* + * A secure player-player message has arrived. + * Use DPMSG_SECUREMESSAGE + */ +#define DPSYS_SECUREMESSAGE 0x0107 + +/* + * Start a new session. + * Use DPMSG_STARTSESSION + */ +#define DPSYS_STARTSESSION 0x0108 + +/* + * A chat message has arrived + * Use DPMSG_CHAT + */ +#define DPSYS_CHAT 0x0109 + +/* + * The owner of a group has changed + * Use DPMSG_SETGROUPOWNER + */ +#define DPSYS_SETGROUPOWNER 0x010A + +/* + * An async send has finished, failed or been cancelled + * Use DPMSG_SENDCOMPLETE + */ +#define DPSYS_SENDCOMPLETE 0x010d + + +/* + * Used in the dwPlayerType field to indicate if it applies to a group + * or a player + */ +#define DPPLAYERTYPE_GROUP 0x00000000 +#define DPPLAYERTYPE_PLAYER 0x00000001 + + +/* + * DPMSG_GENERIC + * Generic message structure used to identify the message type. + */ +typedef struct +{ + DWORD dwType; // Message type +} DPMSG_GENERIC, FAR *LPDPMSG_GENERIC; + +/* + * DPMSG_CREATEPLAYERORGROUP + * System message generated when a new player or group + * created in the session with information about it. + */ +typedef struct +{ + DWORD dwType; // Message type + DWORD dwPlayerType; // Is it a player or group + DPID dpId; // ID of the player or group + DWORD dwCurrentPlayers; // current # players & groups in session + LPVOID lpData; // pointer to remote data + DWORD dwDataSize; // size of remote data + DPNAME dpnName; // structure with name info + // the following fields are only available when using + // the IDirectPlay3 interface or greater + DPID dpIdParent; // id of parent group + DWORD dwFlags; // player or group flags +} DPMSG_CREATEPLAYERORGROUP, FAR *LPDPMSG_CREATEPLAYERORGROUP; + +/* + * DPMSG_DESTROYPLAYERORGROUP + * System message generated when a player or group is being + * destroyed in the session with information about it. + */ +typedef struct +{ + DWORD dwType; // Message type + DWORD dwPlayerType; // Is it a player or group + DPID dpId; // player ID being deleted + LPVOID lpLocalData; // copy of players local data + DWORD dwLocalDataSize; // sizeof local data + LPVOID lpRemoteData; // copy of players remote data + DWORD dwRemoteDataSize; // sizeof remote data + // the following fields are only available when using + // the IDirectPlay3 interface or greater + DPNAME dpnName; // structure with name info + DPID dpIdParent; // id of parent group + DWORD dwFlags; // player or group flags +} DPMSG_DESTROYPLAYERORGROUP, FAR *LPDPMSG_DESTROYPLAYERORGROUP; + +/* + * DPMSG_ADDPLAYERTOGROUP + * System message generated when a player is being added + * to a group. + */ +typedef struct +{ + DWORD dwType; // Message type + DPID dpIdGroup; // group ID being added to + DPID dpIdPlayer; // player ID being added +} DPMSG_ADDPLAYERTOGROUP, FAR *LPDPMSG_ADDPLAYERTOGROUP; + +/* + * DPMSG_DELETEPLAYERFROMGROUP + * System message generated when a player is being + * removed from a group + */ +typedef DPMSG_ADDPLAYERTOGROUP DPMSG_DELETEPLAYERFROMGROUP; +typedef DPMSG_DELETEPLAYERFROMGROUP FAR *LPDPMSG_DELETEPLAYERFROMGROUP; + +/* + * DPMSG_ADDGROUPTOGROUP + * System message generated when a group is being added + * to a group. + */ +typedef struct +{ + DWORD dwType; // Message type + DPID dpIdParentGroup; // group ID being added to + DPID dpIdGroup; // group ID being added +} DPMSG_ADDGROUPTOGROUP, FAR *LPDPMSG_ADDGROUPTOGROUP; + +/* + * DPMSG_DELETEGROUPFROMGROUP + * System message generated when a GROUP is being + * removed from a group + */ +typedef DPMSG_ADDGROUPTOGROUP DPMSG_DELETEGROUPFROMGROUP; +typedef DPMSG_DELETEGROUPFROMGROUP FAR *LPDPMSG_DELETEGROUPFROMGROUP; + +/* + * DPMSG_SETPLAYERORGROUPDATA + * System message generated when remote data for a player or + * group has changed. + */ +typedef struct +{ + DWORD dwType; // Message type + DWORD dwPlayerType; // Is it a player or group + DPID dpId; // ID of player or group + LPVOID lpData; // pointer to remote data + DWORD dwDataSize; // size of remote data +} DPMSG_SETPLAYERORGROUPDATA, FAR *LPDPMSG_SETPLAYERORGROUPDATA; + +/* + * DPMSG_SETPLAYERORGROUPNAME + * System message generated when the name of a player or + * group has changed. + */ +typedef struct +{ + DWORD dwType; // Message type + DWORD dwPlayerType; // Is it a player or group + DPID dpId; // ID of player or group + DPNAME dpnName; // structure with new name info +} DPMSG_SETPLAYERORGROUPNAME, FAR *LPDPMSG_SETPLAYERORGROUPNAME; + +/* + * DPMSG_SETSESSIONDESC + * System message generated when session desc has changed + */ +typedef struct +{ + DWORD dwType; // Message type + DPSESSIONDESC2 dpDesc; // Session desc +} DPMSG_SETSESSIONDESC, FAR *LPDPMSG_SETSESSIONDESC; + +/* + * DPMSG_HOST + * System message generated when the host has migrated to this + * DirectPlay object. + * + */ +typedef DPMSG_GENERIC DPMSG_HOST; +typedef DPMSG_HOST FAR *LPDPMSG_HOST; + +/* + * DPMSG_SESSIONLOST + * System message generated when the connection to the session is lost. + * + */ +typedef DPMSG_GENERIC DPMSG_SESSIONLOST; +typedef DPMSG_SESSIONLOST FAR *LPDPMSG_SESSIONLOST; + +/* + * DPMSG_SECUREMESSAGE + * System message generated when a player requests a secure send + */ +typedef struct +{ + DWORD dwType; // Message Type + DWORD dwFlags; // Signed/Encrypted + DPID dpIdFrom; // ID of Sending Player + LPVOID lpData; // Player message + DWORD dwDataSize; // Size of player message +} DPMSG_SECUREMESSAGE, FAR *LPDPMSG_SECUREMESSAGE; + +/* + * DPMSG_STARTSESSION + * System message containing all information required to + * start a new session + */ +typedef struct +{ + DWORD dwType; // Message type + LPDPLCONNECTION lpConn; // DPLCONNECTION structure +} DPMSG_STARTSESSION, FAR *LPDPMSG_STARTSESSION; + +/* + * DPMSG_CHAT + * System message containing a chat message + */ +typedef struct +{ + DWORD dwType; // Message type + DWORD dwFlags; // Message flags + DPID idFromPlayer; // ID of the Sending Player + DPID idToPlayer; // ID of the To Player + DPID idToGroup; // ID of the To Group + LPDPCHAT lpChat; // Pointer to a structure containing the chat message +} DPMSG_CHAT, FAR *LPDPMSG_CHAT; + +/* + * DPMSG_SETGROUPOWNER + * System message generated when the owner of a group has changed + */ +typedef struct +{ + DWORD dwType; // Message type + DPID idGroup; // ID of the group + DPID idNewOwner; // ID of the player that is the new owner + DPID idOldOwner; // ID of the player that used to be the owner +} DPMSG_SETGROUPOWNER, FAR *LPDPMSG_SETGROUPOWNER; + +/* + * DPMSG_SENDCOMPLETE + * System message generated when finished with an Async Send message + * + * NOTE SENDPARMS has an overlay for DPMSG_SENDCOMPLETE, don't + * change this message w/o changing SENDPARMS. + */ +typedef struct +{ + DWORD dwType; + DPID idFrom; + DPID idTo; + DWORD dwFlags; + DWORD dwPriority; + DWORD dwTimeout; + LPVOID lpvContext; + DWORD dwMsgID; + HRESULT hr; + DWORD dwSendTime; +} DPMSG_SENDCOMPLETE, *LPDPMSG_SENDCOMPLETE; + +/**************************************************************************** + * + * DIRECTPLAY ERRORS + * + * Errors are represented by negative values and cannot be combined. + * + ****************************************************************************/ +#define DP_OK S_OK +#define DPERR_ALREADYINITIALIZED MAKE_DPHRESULT( 5 ) +#define DPERR_ACCESSDENIED MAKE_DPHRESULT( 10 ) +#define DPERR_ACTIVEPLAYERS MAKE_DPHRESULT( 20 ) +#define DPERR_BUFFERTOOSMALL MAKE_DPHRESULT( 30 ) +#define DPERR_CANTADDPLAYER MAKE_DPHRESULT( 40 ) +#define DPERR_CANTCREATEGROUP MAKE_DPHRESULT( 50 ) +#define DPERR_CANTCREATEPLAYER MAKE_DPHRESULT( 60 ) +#define DPERR_CANTCREATESESSION MAKE_DPHRESULT( 70 ) +#define DPERR_CAPSNOTAVAILABLEYET MAKE_DPHRESULT( 80 ) +#define DPERR_EXCEPTION MAKE_DPHRESULT( 90 ) +#define DPERR_GENERIC E_FAIL +#define DPERR_INVALIDFLAGS MAKE_DPHRESULT( 120 ) +#define DPERR_INVALIDOBJECT MAKE_DPHRESULT( 130 ) +#define DPERR_INVALIDPARAM E_INVALIDARG +#define DPERR_INVALIDPARAMS DPERR_INVALIDPARAM +#define DPERR_INVALIDPLAYER MAKE_DPHRESULT( 150 ) +#define DPERR_INVALIDGROUP MAKE_DPHRESULT( 155 ) +#define DPERR_NOCAPS MAKE_DPHRESULT( 160 ) +#define DPERR_NOCONNECTION MAKE_DPHRESULT( 170 ) +#define DPERR_NOMEMORY E_OUTOFMEMORY +#define DPERR_OUTOFMEMORY DPERR_NOMEMORY +#define DPERR_NOMESSAGES MAKE_DPHRESULT( 190 ) +#define DPERR_NONAMESERVERFOUND MAKE_DPHRESULT( 200 ) +#define DPERR_NOPLAYERS MAKE_DPHRESULT( 210 ) +#define DPERR_NOSESSIONS MAKE_DPHRESULT( 220 ) +#define DPERR_PENDING E_PENDING +#define DPERR_SENDTOOBIG MAKE_DPHRESULT( 230 ) +#define DPERR_TIMEOUT MAKE_DPHRESULT( 240 ) +#define DPERR_UNAVAILABLE MAKE_DPHRESULT( 250 ) +#define DPERR_UNSUPPORTED E_NOTIMPL +#define DPERR_BUSY MAKE_DPHRESULT( 270 ) +#define DPERR_USERCANCEL MAKE_DPHRESULT( 280 ) +#define DPERR_NOINTERFACE E_NOINTERFACE +#define DPERR_CANNOTCREATESERVER MAKE_DPHRESULT( 290 ) +#define DPERR_PLAYERLOST MAKE_DPHRESULT( 300 ) +#define DPERR_SESSIONLOST MAKE_DPHRESULT( 310 ) +#define DPERR_UNINITIALIZED MAKE_DPHRESULT( 320 ) +#define DPERR_NONEWPLAYERS MAKE_DPHRESULT( 330 ) +#define DPERR_INVALIDPASSWORD MAKE_DPHRESULT( 340 ) +#define DPERR_CONNECTING MAKE_DPHRESULT( 350 ) +#define DPERR_CONNECTIONLOST MAKE_DPHRESULT( 360 ) +#define DPERR_UNKNOWNMESSAGE MAKE_DPHRESULT( 370 ) +#define DPERR_CANCELFAILED MAKE_DPHRESULT( 380 ) +#define DPERR_INVALIDPRIORITY MAKE_DPHRESULT( 390 ) +#define DPERR_NOTHANDLED MAKE_DPHRESULT( 400 ) +#define DPERR_CANCELLED MAKE_DPHRESULT( 410 ) +#define DPERR_ABORTED MAKE_DPHRESULT( 420 ) + + +#define DPERR_BUFFERTOOLARGE MAKE_DPHRESULT( 1000 ) +#define DPERR_CANTCREATEPROCESS MAKE_DPHRESULT( 1010 ) +#define DPERR_APPNOTSTARTED MAKE_DPHRESULT( 1020 ) +#define DPERR_INVALIDINTERFACE MAKE_DPHRESULT( 1030 ) +#define DPERR_NOSERVICEPROVIDER MAKE_DPHRESULT( 1040 ) +#define DPERR_UNKNOWNAPPLICATION MAKE_DPHRESULT( 1050 ) +#define DPERR_NOTLOBBIED MAKE_DPHRESULT( 1070 ) +#define DPERR_SERVICEPROVIDERLOADED MAKE_DPHRESULT( 1080 ) +#define DPERR_ALREADYREGISTERED MAKE_DPHRESULT( 1090 ) +#define DPERR_NOTREGISTERED MAKE_DPHRESULT( 1100 ) + +// +// Security related errors +// +#define DPERR_AUTHENTICATIONFAILED MAKE_DPHRESULT( 2000 ) +#define DPERR_CANTLOADSSPI MAKE_DPHRESULT( 2010 ) +#define DPERR_ENCRYPTIONFAILED MAKE_DPHRESULT( 2020 ) +#define DPERR_SIGNFAILED MAKE_DPHRESULT( 2030 ) +#define DPERR_CANTLOADSECURITYPACKAGE MAKE_DPHRESULT( 2040 ) +#define DPERR_ENCRYPTIONNOTSUPPORTED MAKE_DPHRESULT( 2050 ) +#define DPERR_CANTLOADCAPI MAKE_DPHRESULT( 2060 ) +#define DPERR_NOTLOGGEDIN MAKE_DPHRESULT( 2070 ) +#define DPERR_LOGONDENIED MAKE_DPHRESULT( 2080 ) + + +/**************************************************************************** + * + * dplay 1.0 obsolete structures + interfaces + * Included for compatibility only. New apps should + * use IDirectPlay2 + * + ****************************************************************************/ + +// define this to ignore obsolete interfaces and constants +#ifndef IDIRECTPLAY2_OR_GREATER + +#define DPOPEN_OPENSESSION DPOPEN_JOIN +#define DPOPEN_CREATESESSION DPOPEN_CREATE + +#define DPENUMSESSIONS_PREVIOUS 0x00000004 + +#define DPENUMPLAYERS_PREVIOUS 0x00000004 + +#define DPSEND_GUARANTEE DPSEND_GUARANTEED +#define DPSEND_TRYONCE 0x00000004 + +#define DPCAPS_NAMESERVICE 0x00000001 +#define DPCAPS_NAMESERVER DPCAPS_ISHOST +#define DPCAPS_GUARANTEED 0x00000004 + +#define DPLONGNAMELEN 52 +#define DPSHORTNAMELEN 20 +#define DPSESSIONNAMELEN 32 +#define DPPASSWORDLEN 16 +#define DPUSERRESERVED 16 + +#define DPSYS_ADDPLAYER 0x0003 +#define DPSYS_DELETEPLAYER 0x0005 + +#define DPSYS_DELETEGROUP 0x0020 +#define DPSYS_DELETEPLAYERFROMGRP 0x0021 +#define DPSYS_CONNECT 0x484b + +typedef struct +{ + DWORD dwType; + DWORD dwPlayerType; + DPID dpId; + char szLongName[DPLONGNAMELEN]; + char szShortName[DPSHORTNAMELEN]; + DWORD dwCurrentPlayers; +} DPMSG_ADDPLAYER; + +typedef DPMSG_ADDPLAYER DPMSG_ADDGROUP; + +typedef struct +{ + DWORD dwType; + DPID dpIdGroup; + DPID dpIdPlayer; +} DPMSG_GROUPADD; + +typedef DPMSG_GROUPADD DPMSG_GROUPDELETE; +typedef struct +{ + DWORD dwType; + DPID dpId; +} DPMSG_DELETEPLAYER; + +typedef BOOL (PASCAL *LPDPENUMPLAYERSCALLBACK)( + DPID dpId, + LPSTR lpFriendlyName, + LPSTR lpFormalName, + DWORD dwFlags, + LPVOID lpContext ); + +typedef struct +{ + DWORD dwSize; + GUID guidSession; + DWORD_PTR dwSession; + DWORD dwMaxPlayers; + DWORD dwCurrentPlayers; + DWORD dwFlags; + char szSessionName[DPSESSIONNAMELEN]; + char szUserField[DPUSERRESERVED]; + DWORD_PTR dwReserved1; + char szPassword[DPPASSWORDLEN]; + DWORD_PTR dwReserved2; + DWORD_PTR dwUser1; + DWORD_PTR dwUser2; + DWORD_PTR dwUser3; + DWORD_PTR dwUser4; +} DPSESSIONDESC,*LPDPSESSIONDESC; + +typedef BOOL (PASCAL * LPDPENUMSESSIONSCALLBACK)( + LPDPSESSIONDESC lpDPSessionDesc, + LPVOID lpContext, + LPDWORD lpdwTimeOut, + DWORD dwFlags); + +/* + * IDirectPlay + */ +#undef INTERFACE +#define INTERFACE IDirectPlay +DECLARE_INTERFACE_( IDirectPlay, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectPlay methods ***/ + STDMETHOD(AddPlayerToGroup) (THIS_ DPID, DPID) PURE; + STDMETHOD(Close) (THIS) PURE; + STDMETHOD(CreatePlayer) (THIS_ LPDPID,LPSTR,LPSTR,LPHANDLE) PURE; + STDMETHOD(CreateGroup) (THIS_ LPDPID,LPSTR,LPSTR) PURE; + STDMETHOD(DeletePlayerFromGroup)(THIS_ DPID,DPID) PURE; + STDMETHOD(DestroyPlayer) (THIS_ DPID) PURE; + STDMETHOD(DestroyGroup) (THIS_ DPID) PURE; + STDMETHOD(EnableNewPlayers) (THIS_ BOOL) PURE; + STDMETHOD(EnumGroupPlayers) (THIS_ DPID, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(EnumGroups) (THIS_ DWORD_PTR, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(EnumPlayers) (THIS_ DWORD_PTR, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(EnumSessions) (THIS_ LPDPSESSIONDESC,DWORD,LPDPENUMSESSIONSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(GetCaps) (THIS_ LPDPCAPS) PURE; + STDMETHOD(GetMessageCount) (THIS_ DPID, LPDWORD) PURE; + STDMETHOD(GetPlayerCaps) (THIS_ DPID, LPDPCAPS) PURE; + STDMETHOD(GetPlayerName) (THIS_ DPID,LPSTR,LPDWORD,LPSTR,LPDWORD) PURE; + STDMETHOD(Initialize) (THIS_ LPGUID) PURE; + STDMETHOD(Open) (THIS_ LPDPSESSIONDESC) PURE; + STDMETHOD(Receive) (THIS_ LPDPID,LPDPID,DWORD,LPVOID,LPDWORD) PURE; + STDMETHOD(SaveSession) (THIS_ LPSTR) PURE; + STDMETHOD(Send) (THIS_ DPID, DPID, DWORD, LPVOID, DWORD) PURE; + STDMETHOD(SetPlayerName) (THIS_ DPID,LPSTR,LPSTR) PURE; +}; + +/**************************************************************************** + * + * IDirectPlay interface macros + * + ****************************************************************************/ + +#if !defined(__cplusplus) || defined(CINTERFACE) + +#define IDirectPlay_AddPlayerToGroup(p,a,b) (p)->lpVtbl->AddPlayerToGroup(p,a,b) +#define IDirectPlay_Close(p) (p)->lpVtbl->Close(p) +#define IDirectPlay_CreateGroup(p,a,b,c) (p)->lpVtbl->CreateGroup(p,a,b,c) +#define IDirectPlay_CreatePlayer(p,a,b,c,d) (p)->lpVtbl->CreatePlayer(p,a,b,c,d) +#define IDirectPlay_DeletePlayerFromGroup(p,a,b) (p)->lpVtbl->DeletePlayerFromGroup(p,a,b) +#define IDirectPlay_DestroyGroup(p,a) (p)->lpVtbl->DestroyGroup(p,a) +#define IDirectPlay_DestroyPlayer(p,a) (p)->lpVtbl->DestroyPlayer(p,a) +#define IDirectPlay_EnableNewPlayers(p,a) (p)->lpVtbl->EnableNewPlayers(p,a) +#define IDirectPlay_EnumGroupPlayers(p,a,b,c,d) (p)->lpVtbl->EnumGroupPlayers(p,a,b,c,d) +#define IDirectPlay_EnumGroups(p,a,b,c,d) (p)->lpVtbl->EnumGroups(p,a,b,c,d) +#define IDirectPlay_EnumPlayers(p,a,b,c,d) (p)->lpVtbl->EnumPlayers(p,a,b,c,d) +#define IDirectPlay_EnumSessions(p,a,b,c,d,e) (p)->lpVtbl->EnumSessions(p,a,b,c,d,e) +#define IDirectPlay_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectPlay_GetMessageCount(p,a,b) (p)->lpVtbl->GetMessageCount(p,a,b) +#define IDirectPlay_GetPlayerCaps(p,a,b) (p)->lpVtbl->GetPlayerCaps(p,a,b) +#define IDirectPlay_GetPlayerName(p,a,b,c,d,e) (p)->lpVtbl->GetPlayerName(p,a,b,c,d,e) +#define IDirectPlay_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#define IDirectPlay_Open(p,a) (p)->lpVtbl->Open(p,a) +#define IDirectPlay_Receive(p,a,b,c,d,e) (p)->lpVtbl->Receive(p,a,b,c,d,e) +#define IDirectPlay_SaveSession(p,a) (p)->lpVtbl->SaveSession(p,a) +#define IDirectPlay_Send(p,a,b,c,d,e) (p)->lpVtbl->Send(p,a,b,c,d,e) +#define IDirectPlay_SetPlayerName(p,a,b,c) (p)->lpVtbl->SetPlayerName(p,a,b,c) + +#else /* C++ */ + +#define IDirectPlay_AddPlayerToGroup(p,a,b) (p)->AddPlayerToGroup(a,b) +#define IDirectPlay_Close(p) (p)->Close() +#define IDirectPlay_CreateGroup(p,a,b,c) (p)->CreateGroup(a,b,c) +#define IDirectPlay_CreatePlayer(p,a,b,c,d) (p)->CreatePlayer(a,b,c,d) +#define IDirectPlay_DeletePlayerFromGroup(p,a,b) (p)->DeletePlayerFromGroup(a,b) +#define IDirectPlay_DestroyGroup(p,a) (p)->DestroyGroup(a) +#define IDirectPlay_DestroyPlayer(p,a) (p)->DestroyPlayer(a) +#define IDirectPlay_EnableNewPlayers(p,a) (p)->EnableNewPlayers(a) +#define IDirectPlay_EnumGroupPlayers(p,a,b,c,d) (p)->EnumGroupPlayers(a,b,c,d) +#define IDirectPlay_EnumGroups(p,a,b,c,d) (p)->EnumGroups(a,b,c,d) +#define IDirectPlay_EnumPlayers(p,a,b,c,d) (p)->EnumPlayers(a,b,c,d) +#define IDirectPlay_EnumSessions(p,a,b,c,d,e) (p)->EnumSessions(a,b,c,d,e) +#define IDirectPlay_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectPlay_GetMessageCount(p,a,b) (p)->GetMessageCount(a,b) +#define IDirectPlay_GetPlayerCaps(p,a,b) (p)->GetPlayerCaps(a,b) +#define IDirectPlay_GetPlayerName(p,a,b,c,d,e) (p)->GetPlayerName(a,b,c,d,e) +#define IDirectPlay_Initialize(p,a) (p)->Initialize(a) +#define IDirectPlay_Open(p,a) (p)->Open(a) +#define IDirectPlay_Receive(p,a,b,c,d,e) (p)->Receive(a,b,c,d,e) +#define IDirectPlay_SaveSession(p,a) (p)->SaveSession(a) +#define IDirectPlay_Send(p,a,b,c,d,e) (p)->Send(a,b,c,d,e) +#define IDirectPlay_SetPlayerName(p,a,b,c) (p)->SetPlayerName(a,b,c) + +#endif + +DEFINE_GUID(IID_IDirectPlay, 0x5454e9a0, 0xdb65, 0x11ce, 0x92, 0x1c, 0x00, 0xaa, 0x00, 0x6c, 0x49, 0x72); + +#endif // IDIRECTPLAY2_OR_GREATER + +/**************************************************************************** + * + * IDirectPlay macros (included regardless of IDIRECTPLAY2_OR_GREATER flag) + * + ****************************************************************************/ + +#if !defined(__cplusplus) || defined(CINTERFACE) + +#define IDirectPlay_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlay_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlay_Release(p) (p)->lpVtbl->Release(p) + +#else + +#define IDirectPlay_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlay_AddRef(p) (p)->AddRef() +#define IDirectPlay_Release(p) (p)->Release() + +#endif // IDirectPlay interface macros + +#ifdef __cplusplus +}; +#endif + +/* restore warning settings */ +#if _MSC_VER >= 1200 +#pragma warning(pop) +#else +#pragma warning(default:4201) +#endif + +#endif + diff --git a/src/dep/include/DXSDK/include/dplay8.h b/src/dep/include/DXSDK/include/dplay8.h index bc63d5b..c6799a9 100644 --- a/src/dep/include/DXSDK/include/dplay8.h +++ b/src/dep/include/DXSDK/include/dplay8.h @@ -1,1456 +1,1456 @@ -/*========================================================================== - * - * Copyright (C) 1998-2002 Microsoft Corporation. All Rights Reserved. - * - * File: DPlay8.h - * Content: DirectPlay8 include file - * - ***************************************************************************/ - -#ifndef __DIRECTPLAY8_H__ -#define __DIRECTPLAY8_H__ - -#include // for DECLARE_INTERFACE_ and HRESULT - -#include "dpaddr.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - - -/**************************************************************************** - * - * DirectPlay8 CLSIDs - * - ****************************************************************************/ - -// {743F1DC6-5ABA-429f-8BDF-C54D03253DC2} -DEFINE_GUID(CLSID_DirectPlay8Client, -0x743f1dc6, 0x5aba, 0x429f, 0x8b, 0xdf, 0xc5, 0x4d, 0x3, 0x25, 0x3d, 0xc2); - -// {DA825E1B-6830-43d7-835D-0B5AD82956A2} -DEFINE_GUID(CLSID_DirectPlay8Server, -0xda825e1b, 0x6830, 0x43d7, 0x83, 0x5d, 0xb, 0x5a, 0xd8, 0x29, 0x56, 0xa2); - -// {286F484D-375E-4458-A272-B138E2F80A6A} -DEFINE_GUID(CLSID_DirectPlay8Peer, -0x286f484d, 0x375e, 0x4458, 0xa2, 0x72, 0xb1, 0x38, 0xe2, 0xf8, 0xa, 0x6a); - - -// CLSIDs added for DirectX 9 - -// {FC47060E-6153-4b34-B975-8E4121EB7F3C} -DEFINE_GUID(CLSID_DirectPlay8ThreadPool, -0xfc47060e, 0x6153, 0x4b34, 0xb9, 0x75, 0x8e, 0x41, 0x21, 0xeb, 0x7f, 0x3c); - -// {E4C1D9A2-CBF7-48bd-9A69-34A55E0D8941} -DEFINE_GUID(CLSID_DirectPlay8NATResolver, -0xe4c1d9a2, 0xcbf7, 0x48bd, 0x9a, 0x69, 0x34, 0xa5, 0x5e, 0xd, 0x89, 0x41); - -/**************************************************************************** - * - * DirectPlay8 Interface IIDs - * - ****************************************************************************/ - -typedef REFIID DP8REFIID; - - -// {5102DACD-241B-11d3-AEA7-006097B01411} -DEFINE_GUID(IID_IDirectPlay8Client, -0x5102dacd, 0x241b, 0x11d3, 0xae, 0xa7, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); - -// {5102DACE-241B-11d3-AEA7-006097B01411} -DEFINE_GUID(IID_IDirectPlay8Server, -0x5102dace, 0x241b, 0x11d3, 0xae, 0xa7, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); - -// {5102DACF-241B-11d3-AEA7-006097B01411} -DEFINE_GUID(IID_IDirectPlay8Peer, -0x5102dacf, 0x241b, 0x11d3, 0xae, 0xa7, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); - - -// IIDs added for DirectX 9 - -// {0D22EE73-4A46-4a0d-89B2-045B4D666425} -DEFINE_GUID(IID_IDirectPlay8ThreadPool, -0xd22ee73, 0x4a46, 0x4a0d, 0x89, 0xb2, 0x4, 0x5b, 0x4d, 0x66, 0x64, 0x25); - -// {A9E213F2-9A60-486f-BF3B-53408B6D1CBB} -DEFINE_GUID(IID_IDirectPlay8NATResolver, -0xa9e213f2, 0x9a60, 0x486f, 0xbf, 0x3b, 0x53, 0x40, 0x8b, 0x6d, 0x1c, 0xbb); - -/**************************************************************************** - * - * DirectPlay8 Service Provider GUIDs - * - ****************************************************************************/ - - -// {53934290-628D-11D2-AE0F-006097B01411} -DEFINE_GUID(CLSID_DP8SP_IPX, -0x53934290, 0x628d, 0x11d2, 0xae, 0xf, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); - - -// {6D4A3650-628D-11D2-AE0F-006097B01411} -DEFINE_GUID(CLSID_DP8SP_MODEM, -0x6d4a3650, 0x628d, 0x11d2, 0xae, 0xf, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); - - -// {743B5D60-628D-11D2-AE0F-006097B01411} -DEFINE_GUID(CLSID_DP8SP_SERIAL, -0x743b5d60, 0x628d, 0x11d2, 0xae, 0xf, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); - - -// {EBFE7BA0-628D-11D2-AE0F-006097B01411} -DEFINE_GUID(CLSID_DP8SP_TCPIP, -0xebfe7ba0, 0x628d, 0x11d2, 0xae, 0xf, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); - - -// Service providers added for DirectX 9 - - -// {995513AF-3027-4b9a-956E-C772B3F78006} -DEFINE_GUID(CLSID_DP8SP_BLUETOOTH, -0x995513af, 0x3027, 0x4b9a, 0x95, 0x6e, 0xc7, 0x72, 0xb3, 0xf7, 0x80, 0x6); - - -/**************************************************************************** - * - * DirectPlay8 Interface Pointer definitions - * - ****************************************************************************/ - -typedef struct IDirectPlay8Client *PDIRECTPLAY8CLIENT; - -typedef struct IDirectPlay8Server *PDIRECTPLAY8SERVER; - -typedef struct IDirectPlay8Peer *PDIRECTPLAY8PEER; - - -// Interface pointers added for DirectX 9 - -typedef struct IDirectPlay8ThreadPool *PDIRECTPLAY8THREADPOOL; - -typedef struct IDirectPlay8NATResolver *PDIRECTPLAY8NATRESOLVER; - -/**************************************************************************** - * - * DirectPlay8 Forward Declarations For External Types - * - ****************************************************************************/ - -typedef struct IDirectPlay8LobbiedApplication *PDNLOBBIEDAPPLICATION; -typedef struct IDirectPlay8Address IDirectPlay8Address; - -/**************************************************************************** - * - * DirectPlay8 Callback Functions - * - ****************************************************************************/ - -// -// Callback Function Type Definition -// -typedef HRESULT (WINAPI *PFNDPNMESSAGEHANDLER)(PVOID,DWORD,PVOID); - -/**************************************************************************** - * - * DirectPlay8 Datatypes (Non-Structure / Non-Message) - * - ****************************************************************************/ - -// -// Player IDs. Used to uniquely identify a player in a session -// -typedef DWORD DPNID, *PDPNID; - -// -// Used as identifiers for operations -// -typedef DWORD DPNHANDLE, *PDPNHANDLE; - - - - -/**************************************************************************** - * - * DirectPlay8 Message Identifiers - * - ****************************************************************************/ - -#define DPN_MSGID_OFFSET 0xFFFF0000 -#define DPN_MSGID_ADD_PLAYER_TO_GROUP ( DPN_MSGID_OFFSET | 0x0001 ) -#define DPN_MSGID_APPLICATION_DESC ( DPN_MSGID_OFFSET | 0x0002 ) -#define DPN_MSGID_ASYNC_OP_COMPLETE ( DPN_MSGID_OFFSET | 0x0003 ) -#define DPN_MSGID_CLIENT_INFO ( DPN_MSGID_OFFSET | 0x0004 ) -#define DPN_MSGID_CONNECT_COMPLETE ( DPN_MSGID_OFFSET | 0x0005 ) -#define DPN_MSGID_CREATE_GROUP ( DPN_MSGID_OFFSET | 0x0006 ) -#define DPN_MSGID_CREATE_PLAYER ( DPN_MSGID_OFFSET | 0x0007 ) -#define DPN_MSGID_DESTROY_GROUP ( DPN_MSGID_OFFSET | 0x0008 ) -#define DPN_MSGID_DESTROY_PLAYER ( DPN_MSGID_OFFSET | 0x0009 ) -#define DPN_MSGID_ENUM_HOSTS_QUERY ( DPN_MSGID_OFFSET | 0x000a ) -#define DPN_MSGID_ENUM_HOSTS_RESPONSE ( DPN_MSGID_OFFSET | 0x000b ) -#define DPN_MSGID_GROUP_INFO ( DPN_MSGID_OFFSET | 0x000c ) -#define DPN_MSGID_HOST_MIGRATE ( DPN_MSGID_OFFSET | 0x000d ) -#define DPN_MSGID_INDICATE_CONNECT ( DPN_MSGID_OFFSET | 0x000e ) -#define DPN_MSGID_INDICATED_CONNECT_ABORTED ( DPN_MSGID_OFFSET | 0x000f ) -#define DPN_MSGID_PEER_INFO ( DPN_MSGID_OFFSET | 0x0010 ) -#define DPN_MSGID_RECEIVE ( DPN_MSGID_OFFSET | 0x0011 ) -#define DPN_MSGID_REMOVE_PLAYER_FROM_GROUP ( DPN_MSGID_OFFSET | 0x0012 ) -#define DPN_MSGID_RETURN_BUFFER ( DPN_MSGID_OFFSET | 0x0013 ) -#define DPN_MSGID_SEND_COMPLETE ( DPN_MSGID_OFFSET | 0x0014 ) -#define DPN_MSGID_SERVER_INFO ( DPN_MSGID_OFFSET | 0x0015 ) -#define DPN_MSGID_TERMINATE_SESSION ( DPN_MSGID_OFFSET | 0x0016 ) - -// Messages added for DirectX 9 -#define DPN_MSGID_CREATE_THREAD ( DPN_MSGID_OFFSET | 0x0017 ) -#define DPN_MSGID_DESTROY_THREAD ( DPN_MSGID_OFFSET | 0x0018 ) -#define DPN_MSGID_NAT_RESOLVER_QUERY ( DPN_MSGID_OFFSET | 0x0101 ) - -/**************************************************************************** - * - * DirectPlay8 Constants - * - ****************************************************************************/ - -#define DPNID_ALL_PLAYERS_GROUP 0 - -// -// DESTROY_GROUP reasons -// -#define DPNDESTROYGROUPREASON_NORMAL 0x0001 -#define DPNDESTROYGROUPREASON_AUTODESTRUCTED 0x0002 -#define DPNDESTROYGROUPREASON_SESSIONTERMINATED 0x0003 - -// -// DESTROY_PLAYER reasons -// -#define DPNDESTROYPLAYERREASON_NORMAL 0x0001 -#define DPNDESTROYPLAYERREASON_CONNECTIONLOST 0x0002 -#define DPNDESTROYPLAYERREASON_SESSIONTERMINATED 0x0003 -#define DPNDESTROYPLAYERREASON_HOSTDESTROYEDPLAYER 0x0004 - -#define DPN_MAX_APPDESC_RESERVEDDATA_SIZE 64 - - - -/**************************************************************************** - * - * DirectPlay8 Flags - * - ****************************************************************************/ - -// -// Asynchronous operation flags (for Async Ops) -// -#define DPNOP_SYNC 0x80000000 - -// -// Add player to group flags (for AddPlayerToGroup) -// -#define DPNADDPLAYERTOGROUP_SYNC DPNOP_SYNC - -// -// Cancel flags -// -#define DPNCANCEL_CONNECT 0x00000001 -#define DPNCANCEL_ENUM 0x00000002 -#define DPNCANCEL_SEND 0x00000004 -#define DPNCANCEL_ALL_OPERATIONS 0x00008000 -// Flags added for DirectX 9 -#define DPNCANCEL_PLAYER_SENDS 0x80000000 -#define DPNCANCEL_PLAYER_SENDS_PRIORITY_HIGH (DPNCANCEL_PLAYER_SENDS | 0x00010000) -#define DPNCANCEL_PLAYER_SENDS_PRIORITY_NORMAL (DPNCANCEL_PLAYER_SENDS | 0x00020000) -#define DPNCANCEL_PLAYER_SENDS_PRIORITY_LOW (DPNCANCEL_PLAYER_SENDS | 0x00040000) - -// -// Close flags (for Close, added for DirectX 9) -// -#define DPNCLOSE_IMMEDIATE 0x00000001 - -// -// Connect flags (for Connect) -// -#define DPNCONNECT_SYNC DPNOP_SYNC -#define DPNCONNECT_OKTOQUERYFORADDRESSING 0x0001 - -// -// Create group flags (for CreateGroup) -// -#define DPNCREATEGROUP_SYNC DPNOP_SYNC - -// -// Destroy group flags (for DestroyGroup) -// -#define DPNDESTROYGROUP_SYNC DPNOP_SYNC - -// -// Enumerate clients and groups flags (for EnumPlayersAndGroups) -// -#define DPNENUM_PLAYERS 0x0001 -#define DPNENUM_GROUPS 0x0010 - -// -// Enum hosts flags (for EnumHosts) -// -#define DPNENUMHOSTS_SYNC DPNOP_SYNC -#define DPNENUMHOSTS_OKTOQUERYFORADDRESSING 0x0001 -#define DPNENUMHOSTS_NOBROADCASTFALLBACK 0x0002 - -// -// Enum service provider flags (for EnumSP) -// -#define DPNENUMSERVICEPROVIDERS_ALL 0x0001 - -// -// GetLocalHostAddresses flags (added for DirectX 9) -// -#define DPNGETLOCALHOSTADDRESSES_COMBINED 0x0001 - -// -// Get send queue info flags (for GetSendQueueInfo) -// -#define DPNGETSENDQUEUEINFO_PRIORITY_NORMAL 0x0001 -#define DPNGETSENDQUEUEINFO_PRIORITY_HIGH 0x0002 -#define DPNGETSENDQUEUEINFO_PRIORITY_LOW 0x0004 - -// -// Group information flags (for Group Info) -// -#define DPNGROUP_AUTODESTRUCT 0x0001 - -// -// Host flags (for Host) -// -#define DPNHOST_OKTOQUERYFORADDRESSING 0x0001 - -// -// Set info -// -#define DPNINFO_NAME 0x0001 -#define DPNINFO_DATA 0x0002 - -// -// Initialize flags (for Initialize) -// -#define DPNINITIALIZE_DISABLEPARAMVAL 0x0001 -// Flags added for DirectX 9 -#define DPNINITIALIZE_HINT_LANSESSION 0x0002 -#define DPNINITIALIZE_DISABLELINKTUNING 0x0004 - - -// -// Register Lobby flags -// -#define DPNLOBBY_REGISTER 0x0001 -#define DPNLOBBY_UNREGISTER 0x0002 - -// -// Player information flags (for Player Info / Player Messages) -// -#define DPNPLAYER_LOCAL 0x0002 -#define DPNPLAYER_HOST 0x0004 - -// -// Receive indication flags (added for DirectX 9) -// -#define DPNRECEIVE_GUARANTEED 0x0001 -#define DPNRECEIVE_COALESCED 0x0002 - -// -// Remove player from group flags (for RemovePlayerFromGroup) -// -#define DPNREMOVEPLAYERFROMGROUP_SYNC DPNOP_SYNC - -// -// Send flags (for Send/SendTo) -// -#define DPNSEND_SYNC DPNOP_SYNC -#define DPNSEND_NOCOPY 0x0001 -#define DPNSEND_NOCOMPLETE 0x0002 -#define DPNSEND_COMPLETEONPROCESS 0x0004 -#define DPNSEND_GUARANTEED 0x0008 -#define DPNSEND_NONSEQUENTIAL 0x0010 -#define DPNSEND_NOLOOPBACK 0x0020 -#define DPNSEND_PRIORITY_LOW 0x0040 -#define DPNSEND_PRIORITY_HIGH 0x0080 -// Flag added for DirectX 9 -#define DPNSEND_COALESCE 0x0100 - -// -// Send complete indication flags (added for DirectX 9) -// -#define DPNSENDCOMPLETE_GUARANTEED 0x0001 -#define DPNSENDCOMPLETE_COALESCED 0x0002 - -// -// Session Flags (for DPN_APPLICATION_DESC) -// -#define DPNSESSION_CLIENT_SERVER 0x0001 -#define DPNSESSION_MIGRATE_HOST 0x0004 -#define DPNSESSION_NODPNSVR 0x0040 -#define DPNSESSION_REQUIREPASSWORD 0x0080 -// Flag added for DirectX 9 -#define DPNSESSION_NOENUMS 0x0100 -#define DPNSESSION_FAST_SIGNED 0x0200 -#define DPNSESSION_FULL_SIGNED 0x0400 - -// -// Set client info flags (for SetClientInfo) -// -#define DPNSETCLIENTINFO_SYNC DPNOP_SYNC - -// -// Set group info flags (for SetGroupInfo) -// -#define DPNSETGROUPINFO_SYNC DPNOP_SYNC - -// -// Set peer info flags (for SetPeerInfo) -// -#define DPNSETPEERINFO_SYNC DPNOP_SYNC - -// -// Set server info flags (for SetServerInfo) -// -#define DPNSETSERVERINFO_SYNC DPNOP_SYNC - -// -// SP capabilities flags -// -#define DPNSPCAPS_SUPPORTSDPNSVR 0x0001 -#define DPNSPCAPS_SUPPORTSDPNSRV DPNSPCAPS_SUPPORTSDPNSVR -#define DPNSPCAPS_SUPPORTSBROADCAST 0x0002 -#define DPNSPCAPS_SUPPORTSALLADAPTERS 0x0004 -// Flags added for DirectX 9 -#define DPNSPCAPS_SUPPORTSTHREADPOOL 0x0008 -#define DPNSPCAPS_NETWORKSIMULATOR 0x0010 - -// -// SP information flags (added for DirectX 9) -// -#define DPNSPINFO_NETWORKSIMULATORDEVICE 0x0001 - -/**************************************************************************** - * - * DirectPlay8 Structures (Non-Message) - * - ****************************************************************************/ - -// -// Application description -// -typedef struct _DPN_APPLICATION_DESC -{ - DWORD dwSize; // Size of this structure - DWORD dwFlags; // Flags (DPNSESSION_...) - GUID guidInstance; // Instance GUID - GUID guidApplication; // Application GUID - DWORD dwMaxPlayers; // Maximum # of players allowed (0=no limit) - DWORD dwCurrentPlayers; // Current # of players allowed - WCHAR *pwszSessionName; // Name of the session - WCHAR *pwszPassword; // Password for the session - PVOID pvReservedData; - DWORD dwReservedDataSize; - PVOID pvApplicationReservedData; - DWORD dwApplicationReservedDataSize; -} DPN_APPLICATION_DESC, *PDPN_APPLICATION_DESC; - -// -// Generic Buffer Description -// -typedef struct _BUFFERDESC -{ - DWORD dwBufferSize; - BYTE * pBufferData; -} BUFFERDESC, DPN_BUFFER_DESC, *PDPN_BUFFER_DESC; - -typedef BUFFERDESC FAR * PBUFFERDESC; - -// -// DirectPlay8 capabilities -// -typedef struct _DPN_CAPS -{ - DWORD dwSize; // Size of this structure - DWORD dwFlags; // Flags - DWORD dwConnectTimeout; // ms before a connect request times out - DWORD dwConnectRetries; // # of times to attempt the connection - DWORD dwTimeoutUntilKeepAlive; // ms of inactivity before a keep alive is sent -} DPN_CAPS, *PDPN_CAPS; - -// -// Extended capabilities structures (added for DirectX 9) -// -typedef struct _DPN_CAPS_EX -{ - DWORD dwSize; // Size of this structure - DWORD dwFlags; // Flags - DWORD dwConnectTimeout; // ms before a connect request times out - DWORD dwConnectRetries; // # of times to attempt the connection - DWORD dwTimeoutUntilKeepAlive; // ms of inactivity before a keep alive is sent - DWORD dwMaxRecvMsgSize; // maximum size in bytes of message that can be received - DWORD dwNumSendRetries; // maximum number of send retries before link is considered dead - DWORD dwMaxSendRetryInterval; // maximum period in msec between send retries - DWORD dwDropThresholdRate; // percentage of dropped packets before throttling - DWORD dwThrottleRate; // percentage amount to reduce send window when throttling - DWORD dwNumHardDisconnectSends; // number of hard disconnect frames to send when close immediate flag is specified - DWORD dwMaxHardDisconnectPeriod; // maximum period between hard disconnect sends -} DPN_CAPS_EX, *PDPN_CAPS_EX; - -// -// Connection Statistics information -// -typedef struct _DPN_CONNECTION_INFO -{ - DWORD dwSize; - DWORD dwRoundTripLatencyMS; - DWORD dwThroughputBPS; - DWORD dwPeakThroughputBPS; - - DWORD dwBytesSentGuaranteed; - DWORD dwPacketsSentGuaranteed; - DWORD dwBytesSentNonGuaranteed; - DWORD dwPacketsSentNonGuaranteed; - - DWORD dwBytesRetried; // Guaranteed only - DWORD dwPacketsRetried; // Guaranteed only - DWORD dwBytesDropped; // Non Guaranteed only - DWORD dwPacketsDropped; // Non Guaranteed only - - DWORD dwMessagesTransmittedHighPriority; - DWORD dwMessagesTimedOutHighPriority; - DWORD dwMessagesTransmittedNormalPriority; - DWORD dwMessagesTimedOutNormalPriority; - DWORD dwMessagesTransmittedLowPriority; - DWORD dwMessagesTimedOutLowPriority; - - DWORD dwBytesReceivedGuaranteed; - DWORD dwPacketsReceivedGuaranteed; - DWORD dwBytesReceivedNonGuaranteed; - DWORD dwPacketsReceivedNonGuaranteed; - DWORD dwMessagesReceived; - -} DPN_CONNECTION_INFO, *PDPN_CONNECTION_INFO; - - -// -// Group information structure -// -typedef struct _DPN_GROUP_INFO -{ - DWORD dwSize; // size of this structure - DWORD dwInfoFlags; // information contained - PWSTR pwszName; // Unicode Name - PVOID pvData; // data block - DWORD dwDataSize; // size in BYTES of data block - DWORD dwGroupFlags; // group flags (DPNGROUP_...) -} DPN_GROUP_INFO, *PDPN_GROUP_INFO; - -// -// Player information structure -// -typedef struct _DPN_PLAYER_INFO -{ - DWORD dwSize; // size of this structure - DWORD dwInfoFlags; // information contained - PWSTR pwszName; // Unicode Name - PVOID pvData; // data block - DWORD dwDataSize; // size in BYTES of data block - DWORD dwPlayerFlags; // player flags (DPNPLAYER_...) -} DPN_PLAYER_INFO, *PDPN_PLAYER_INFO; - -typedef struct _DPN_SECURITY_CREDENTIALS DPN_SECURITY_CREDENTIALS, *PDPN_SECURITY_CREDENTIALS; -typedef struct _DPN_SECURITY_DESC DPN_SECURITY_DESC, *PDPN_SECURITY_DESC; - -// -// Service provider & adapter enumeration structure -// -typedef struct _DPN_SERVICE_PROVIDER_INFO -{ - DWORD dwFlags; - GUID guid; // SP Guid - WCHAR *pwszName; // Friendly Name - PVOID pvReserved; - DWORD dwReserved; -} DPN_SERVICE_PROVIDER_INFO, *PDPN_SERVICE_PROVIDER_INFO; - -// -// Service provider caps structure -// -typedef struct _DPN_SP_CAPS -{ - DWORD dwSize; // Size of this structure - DWORD dwFlags; // Flags (DPNSPCAPS_...) - DWORD dwNumThreads; // # of worker threads to use - DWORD dwDefaultEnumCount; // default # of enum requests - DWORD dwDefaultEnumRetryInterval; // default ms between enum requests - DWORD dwDefaultEnumTimeout; // default enum timeout - DWORD dwMaxEnumPayloadSize; // maximum size in bytes for enum payload data - DWORD dwBuffersPerThread; // number of receive buffers per thread - DWORD dwSystemBufferSize; // amount of buffering to do in addition to posted receive buffers -} DPN_SP_CAPS, *PDPN_SP_CAPS; - - -/**************************************************************************** - * - * IDirectPlay8 message handler call back structures - * - ****************************************************************************/ - -// -// Add player to group structure for message handler -// (DPN_MSGID_ADD_PLAYER_TO_GROUP) -// -typedef struct _DPNMSG_ADD_PLAYER_TO_GROUP -{ - DWORD dwSize; // Size of this structure - DPNID dpnidGroup; // DPNID of group - PVOID pvGroupContext; // Group context value - DPNID dpnidPlayer; // DPNID of added player - PVOID pvPlayerContext; // Player context value -} DPNMSG_ADD_PLAYER_TO_GROUP, *PDPNMSG_ADD_PLAYER_TO_GROUP; - -// -// Async operation completion structure for message handler -// (DPN_MSGID_ASYNC_OP_COMPLETE) -// -typedef struct _DPNMSG_ASYNC_OP_COMPLETE -{ - DWORD dwSize; // Size of this structure - DPNHANDLE hAsyncOp; // DirectPlay8 async operation handle - PVOID pvUserContext; // User context supplied - HRESULT hResultCode; // HRESULT of operation -} DPNMSG_ASYNC_OP_COMPLETE, *PDPNMSG_ASYNC_OP_COMPLETE; - -// -// Client info structure for message handler -// (DPN_MSGID_CLIENT_INFO) -// -typedef struct _DPNMSG_CLIENT_INFO -{ - DWORD dwSize; // Size of this structure - DPNID dpnidClient; // DPNID of client - PVOID pvPlayerContext; // Player context value -} DPNMSG_CLIENT_INFO, *PDPNMSG_CLIENT_INFO; - -// -// Connect complete structure for message handler -// (DPN_MSGID_CONNECT_COMPLETE) -// -typedef struct _DPNMSG_CONNECT_COMPLETE -{ - DWORD dwSize; // Size of this structure - DPNHANDLE hAsyncOp; // DirectPlay8 Async operation handle - PVOID pvUserContext; // User context supplied at Connect - HRESULT hResultCode; // HRESULT of connection attempt - PVOID pvApplicationReplyData; // Connection reply data from Host/Server - DWORD dwApplicationReplyDataSize; // Size (in bytes) of pvApplicationReplyData - - // Fields added for DirectX 9 - DPNID dpnidLocal; // DPNID of local player -} DPNMSG_CONNECT_COMPLETE, *PDPNMSG_CONNECT_COMPLETE; - -// -// Create group structure for message handler -// (DPN_MSGID_CREATE_GROUP) -// -typedef struct _DPNMSG_CREATE_GROUP -{ - DWORD dwSize; // Size of this structure - DPNID dpnidGroup; // DPNID of new group - DPNID dpnidOwner; // Owner of newgroup - PVOID pvGroupContext; // Group context value - - // Fields added for DirectX 9 - PVOID pvOwnerContext; // Owner context value -} DPNMSG_CREATE_GROUP, *PDPNMSG_CREATE_GROUP; - -// -// Create player structure for message handler -// (DPN_MSGID_CREATE_PLAYER) -// -typedef struct _DPNMSG_CREATE_PLAYER -{ - DWORD dwSize; // Size of this structure - DPNID dpnidPlayer; // DPNID of new player - PVOID pvPlayerContext; // Player context value -} DPNMSG_CREATE_PLAYER, *PDPNMSG_CREATE_PLAYER; - -// -// Destroy group structure for message handler -// (DPN_MSGID_DESTROY_GROUP) -// -typedef struct _DPNMSG_DESTROY_GROUP -{ - DWORD dwSize; // Size of this structure - DPNID dpnidGroup; // DPNID of destroyed group - PVOID pvGroupContext; // Group context value - DWORD dwReason; // Information only -} DPNMSG_DESTROY_GROUP, *PDPNMSG_DESTROY_GROUP; - -// -// Destroy player structure for message handler -// (DPN_MSGID_DESTROY_PLAYER) -// -typedef struct _DPNMSG_DESTROY_PLAYER -{ - DWORD dwSize; // Size of this structure - DPNID dpnidPlayer; // DPNID of leaving player - PVOID pvPlayerContext; // Player context value - DWORD dwReason; // Information only -} DPNMSG_DESTROY_PLAYER, *PDPNMSG_DESTROY_PLAYER; - -// -// Enumeration request received structure for message handler -// (DPN_MSGID_ENUM_HOSTS_QUERY) -// -typedef struct _DPNMSG_ENUM_HOSTS_QUERY -{ - DWORD dwSize; // Size of this structure. - IDirectPlay8Address *pAddressSender; // Address of client who sent the request - IDirectPlay8Address *pAddressDevice; // Address of device request was received on - PVOID pvReceivedData; // Request data (set on client) - DWORD dwReceivedDataSize; // Request data size (set on client) - DWORD dwMaxResponseDataSize; // Max allowable size of enum response - PVOID pvResponseData; // Optional query repsonse (user set) - DWORD dwResponseDataSize; // Optional query response size (user set) - PVOID pvResponseContext; // Optional query response context (user set) -} DPNMSG_ENUM_HOSTS_QUERY, *PDPNMSG_ENUM_HOSTS_QUERY; - -// -// Enumeration response received structure for message handler -// (DPN_MSGID_ENUM_HOSTS_RESPONSE) -// -typedef struct _DPNMSG_ENUM_HOSTS_RESPONSE -{ - DWORD dwSize; // Size of this structure - IDirectPlay8Address *pAddressSender; // Address of host who responded - IDirectPlay8Address *pAddressDevice; // Device response was received on - const DPN_APPLICATION_DESC *pApplicationDescription; // Application description for the session - PVOID pvResponseData; // Optional response data (set on host) - DWORD dwResponseDataSize; // Optional response data size (set on host) - PVOID pvUserContext; // Context value supplied for enumeration - DWORD dwRoundTripLatencyMS; // Round trip latency in MS -} DPNMSG_ENUM_HOSTS_RESPONSE, *PDPNMSG_ENUM_HOSTS_RESPONSE; - -// -// Group info structure for message handler -// (DPN_MSGID_GROUP_INFO) -// -typedef struct _DPNMSG_GROUP_INFO -{ - DWORD dwSize; // Size of this structure - DPNID dpnidGroup; // DPNID of group - PVOID pvGroupContext; // Group context value -} DPNMSG_GROUP_INFO, *PDPNMSG_GROUP_INFO; - -// -// Migrate host structure for message handler -// (DPN_MSGID_HOST_MIGRATE) -// -typedef struct _DPNMSG_HOST_MIGRATE -{ - DWORD dwSize; // Size of this structure - DPNID dpnidNewHost; // DPNID of new Host player - PVOID pvPlayerContext; // Player context value -} DPNMSG_HOST_MIGRATE, *PDPNMSG_HOST_MIGRATE; - -// -// Indicate connect structure for message handler -// (DPN_MSGID_INDICATE_CONNECT) -// -typedef struct _DPNMSG_INDICATE_CONNECT -{ - DWORD dwSize; // Size of this structure - PVOID pvUserConnectData; // Connecting player data - DWORD dwUserConnectDataSize; // Size (in bytes) of pvUserConnectData - PVOID pvReplyData; // Connection reply data - DWORD dwReplyDataSize; // Size (in bytes) of pvReplyData - PVOID pvReplyContext; // Buffer context for pvReplyData - PVOID pvPlayerContext; // Player context preset - IDirectPlay8Address *pAddressPlayer; // Address of connecting player - IDirectPlay8Address *pAddressDevice; // Address of device receiving connect attempt -} DPNMSG_INDICATE_CONNECT, *PDPNMSG_INDICATE_CONNECT; - -// -// Indicated connect aborted structure for message handler -// (DPN_MSGID_INDICATED_CONNECT_ABORTED) -// -typedef struct _DPNMSG_INDICATED_CONNECT_ABORTED -{ - DWORD dwSize; // Size of this structure - PVOID pvPlayerContext; // Player context preset from DPNMSG_INDICATE_CONNECT -} DPNMSG_INDICATED_CONNECT_ABORTED, *PDPNMSG_INDICATED_CONNECT_ABORTED; - -// -// Peer info structure for message handler -// (DPN_MSGID_PEER_INFO) -// -typedef struct _DPNMSG_PEER_INFO -{ - DWORD dwSize; // Size of this structure - DPNID dpnidPeer; // DPNID of peer - PVOID pvPlayerContext; // Player context value -} DPNMSG_PEER_INFO, *PDPNMSG_PEER_INFO; - -// -// Receive structure for message handler -// (DPN_MSGID_RECEIVE) -// -typedef struct _DPNMSG_RECEIVE -{ - DWORD dwSize; // Size of this structure - DPNID dpnidSender; // DPNID of sending player - PVOID pvPlayerContext; // Player context value of sending player - PBYTE pReceiveData; // Received data - DWORD dwReceiveDataSize; // Size (in bytes) of pReceiveData - DPNHANDLE hBufferHandle; // Buffer handle for pReceiveData - - // Fields added for DirectX 9 - DWORD dwReceiveFlags; // Flags describing how message was received -} DPNMSG_RECEIVE, *PDPNMSG_RECEIVE; - -// -// Remove player from group structure for message handler -// (DPN_MSGID_REMOVE_PLAYER_FROM_GROUP) -// -typedef struct _DPNMSG_REMOVE_PLAYER_FROM_GROUP -{ - DWORD dwSize; // Size of this structure - DPNID dpnidGroup; // DPNID of group - PVOID pvGroupContext; // Group context value - DPNID dpnidPlayer; // DPNID of deleted player - PVOID pvPlayerContext; // Player context value -} DPNMSG_REMOVE_PLAYER_FROM_GROUP, *PDPNMSG_REMOVE_PLAYER_FROM_GROUP; - -// -// Returned buffer structure for message handler -// (DPN_MSGID_RETURN_BUFFER) -// -typedef struct _DPNMSG_RETURN_BUFFER -{ - DWORD dwSize; // Size of this structure - HRESULT hResultCode; // Return value of operation - PVOID pvBuffer; // Buffer being returned - PVOID pvUserContext; // Context associated with buffer -} DPNMSG_RETURN_BUFFER, *PDPNMSG_RETURN_BUFFER; - -// -// Send complete structure for message handler -// (DPN_MSGID_SEND_COMPLETE) -// -typedef struct _DPNMSG_SEND_COMPLETE -{ - DWORD dwSize; // Size of this structure - DPNHANDLE hAsyncOp; // DirectPlay8 Async operation handle - PVOID pvUserContext; // User context supplied at Send/SendTo - HRESULT hResultCode; // HRESULT of send - DWORD dwSendTime; // Send time in ms - - // Fields added for DirectX 9 - DWORD dwFirstFrameRTT; // RTT of the first frame in the message - DWORD dwFirstFrameRetryCount; // Retry count of the first frame - DWORD dwSendCompleteFlags; // Flags describing how message was sent - DPN_BUFFER_DESC *pBuffers; // Pointer to array of buffers sent, if DirectPlay did not make a copy - DWORD dwNumBuffers; // Number of buffers in previous array -} DPNMSG_SEND_COMPLETE, *PDPNMSG_SEND_COMPLETE; - -// -// Server info structure for message handler -// (DPN_MSGID_SERVER_INFO) -// -typedef struct _DPNMSG_SERVER_INFO -{ - DWORD dwSize; // Size of this structure - DPNID dpnidServer; // DPNID of server - PVOID pvPlayerContext; // Player context value -} DPNMSG_SERVER_INFO, *PDPNMSG_SERVER_INFO; - -// -// Terminated session structure for message handler -// (DPN_MSGID_TERMINATE_SESSION) -// -typedef struct _DPNMSG_TERMINATE_SESSION -{ - DWORD dwSize; // Size of this structure - HRESULT hResultCode; // Reason - PVOID pvTerminateData; // Data passed from Host/Server - DWORD dwTerminateDataSize;// Size (in bytes) of pvTerminateData -} DPNMSG_TERMINATE_SESSION, *PDPNMSG_TERMINATE_SESSION; - - -// -// Message structures added for DirectX 9 -// - -// -// Create thread info structure for message handler -// (DPN_MSGID_CREATE_THREAD) -// -typedef struct _DPNMSG_CREATE_THREAD -{ - DWORD dwSize; // Size of this structure - DWORD dwFlags; // Flags describing this thread - DWORD dwProcessorNum; // Index of processor to which thread is bound - PVOID pvUserContext; // Thread context value -} DPNMSG_CREATE_THREAD, *PDPNMSG_CREATE_THREAD; - -// -// Destroy thread info structure for message handler -// (DPN_MSGID_DESTROY_THREAD) -// -typedef struct _DPNMSG_DESTROY_THREAD -{ - DWORD dwSize; // Size of this structure - DWORD dwProcessorNum; // Index of processor to which thread was bound - PVOID pvUserContext; // Thread context value -} DPNMSG_DESTROY_THREAD, *PDPNMSG_DESTROY_THREAD; - - -// -// Query-to-resolve-NAT-address structure for message handler -// (DPN_MSGID_NAT_RESOLVER_QUERY) -// -typedef struct _DPNMSG_NAT_RESOLVER_QUERY -{ - DWORD dwSize; // Size of this structure. - IDirectPlay8Address *pAddressSender; // Address of client that sent the query - IDirectPlay8Address *pAddressDevice; // Address of device on which query was received - WCHAR *pwszUserString; // User specified string, or NULL if none -} DPNMSG_NAT_RESOLVER_QUERY, *PDPNMSG_NAT_RESOLVER_QUERY; - -/**************************************************************************** - * - * DirectPlay8 Functions - * - ****************************************************************************/ - - - -/* - * This function is no longer supported. It is recommended that CoCreateInstance be used to create - * DirectPlay8 objects. - * - * extern HRESULT WINAPI DirectPlay8Create( const CLSID * pcIID, void **ppvInterface, IUnknown *pUnknown ); - * - */ - - -/**************************************************************************** - * - * DirectPlay8 Application Interfaces - * - ****************************************************************************/ - -// -// COM definition for DirectPlay8 Client interface -// -#undef INTERFACE // External COM Implementation -#define INTERFACE IDirectPlay8Client -DECLARE_INTERFACE_(IDirectPlay8Client,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ DP8REFIID riid, LPVOID *ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectPlay8Client methods ***/ - STDMETHOD(Initialize) (THIS_ PVOID const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags) PURE; - STDMETHOD(EnumServiceProviders) (THIS_ const GUID *const pguidServiceProvider, const GUID *const pguidApplication, DPN_SERVICE_PROVIDER_INFO *const pSPInfoBuffer, PDWORD const pcbEnumData, PDWORD const pcReturned, const DWORD dwFlags) PURE; - STDMETHOD(EnumHosts) (THIS_ PDPN_APPLICATION_DESC const pApplicationDesc,IDirectPlay8Address *const pAddrHost,IDirectPlay8Address *const pDeviceInfo,PVOID const pUserEnumData,const DWORD dwUserEnumDataSize,const DWORD dwEnumCount,const DWORD dwRetryInterval,const DWORD dwTimeOut,PVOID const pvUserContext,DPNHANDLE *const pAsyncHandle,const DWORD dwFlags) PURE; - STDMETHOD(CancelAsyncOperation) (THIS_ const DPNHANDLE hAsyncHandle, const DWORD dwFlags) PURE; - STDMETHOD(Connect) (THIS_ const DPN_APPLICATION_DESC *const pdnAppDesc,IDirectPlay8Address *const pHostAddr,IDirectPlay8Address *const pDeviceInfo,const DPN_SECURITY_DESC *const pdnSecurity,const DPN_SECURITY_CREDENTIALS *const pdnCredentials,const void *const pvUserConnectData,const DWORD dwUserConnectDataSize,void *const pvAsyncContext,DPNHANDLE *const phAsyncHandle,const DWORD dwFlags) PURE; - STDMETHOD(Send) (THIS_ const DPN_BUFFER_DESC *const prgBufferDesc,const DWORD cBufferDesc,const DWORD dwTimeOut,void *const pvAsyncContext,DPNHANDLE *const phAsyncHandle,const DWORD dwFlags) PURE; - STDMETHOD(GetSendQueueInfo) (THIS_ DWORD *const pdwNumMsgs, DWORD *const pdwNumBytes, const DWORD dwFlags) PURE; - STDMETHOD(GetApplicationDesc) (THIS_ DPN_APPLICATION_DESC *const pAppDescBuffer, DWORD *const pcbDataSize, const DWORD dwFlags) PURE; - STDMETHOD(SetClientInfo) (THIS_ const DPN_PLAYER_INFO *const pdpnPlayerInfo,PVOID const pvAsyncContext,DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; - STDMETHOD(GetServerInfo) (THIS_ DPN_PLAYER_INFO *const pdpnPlayerInfo,DWORD *const pdwSize,const DWORD dwFlags) PURE; - STDMETHOD(GetServerAddress) (THIS_ IDirectPlay8Address **const pAddress,const DWORD dwFlags) PURE; - STDMETHOD(Close) (THIS_ const DWORD dwFlags) PURE; - STDMETHOD(ReturnBuffer) (THIS_ const DPNHANDLE hBufferHandle,const DWORD dwFlags) PURE; - STDMETHOD(GetCaps) (THIS_ DPN_CAPS *const pdpCaps,const DWORD dwFlags) PURE; - STDMETHOD(SetCaps) (THIS_ const DPN_CAPS *const pdpCaps, const DWORD dwFlags) PURE; - STDMETHOD(SetSPCaps) (THIS_ const GUID * const pguidSP, const DPN_SP_CAPS *const pdpspCaps, const DWORD dwFlags ) PURE; - STDMETHOD(GetSPCaps) (THIS_ const GUID * const pguidSP,DPN_SP_CAPS *const pdpspCaps,const DWORD dwFlags) PURE; - STDMETHOD(GetConnectionInfo) (THIS_ DPN_CONNECTION_INFO *const pdpConnectionInfo,const DWORD dwFlags) PURE; - STDMETHOD(RegisterLobby) (THIS_ const DPNHANDLE dpnHandle, struct IDirectPlay8LobbiedApplication *const pIDP8LobbiedApplication,const DWORD dwFlags) PURE; -}; - -// -// COM definition for DirectPlay8 Server interface -// -#undef INTERFACE // External COM Implementation -#define INTERFACE IDirectPlay8Server -DECLARE_INTERFACE_(IDirectPlay8Server,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ DP8REFIID riid, LPVOID *ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectPlay8Server methods ***/ - STDMETHOD(Initialize) (THIS_ PVOID const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags) PURE; - STDMETHOD(EnumServiceProviders) (THIS_ const GUID *const pguidServiceProvider,const GUID *const pguidApplication,DPN_SERVICE_PROVIDER_INFO *const pSPInfoBuffer,PDWORD const pcbEnumData,PDWORD const pcReturned,const DWORD dwFlags) PURE; - STDMETHOD(CancelAsyncOperation) (THIS_ const DPNHANDLE hAsyncHandle,const DWORD dwFlags) PURE; - STDMETHOD(GetSendQueueInfo) (THIS_ const DPNID dpnid,DWORD *const pdwNumMsgs, DWORD *const pdwNumBytes, const DWORD dwFlags) PURE; - STDMETHOD(GetApplicationDesc) (THIS_ DPN_APPLICATION_DESC *const pAppDescBuffer, DWORD *const pcbDataSize, const DWORD dwFlags) PURE; - STDMETHOD(SetServerInfo) (THIS_ const DPN_PLAYER_INFO *const pdpnPlayerInfo,PVOID const pvAsyncContext, DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; - STDMETHOD(GetClientInfo) (THIS_ const DPNID dpnid,DPN_PLAYER_INFO *const pdpnPlayerInfo,DWORD *const pdwSize,const DWORD dwFlags) PURE; - STDMETHOD(GetClientAddress) (THIS_ const DPNID dpnid,IDirectPlay8Address **const pAddress,const DWORD dwFlags) PURE; - STDMETHOD(GetLocalHostAddresses) (THIS_ IDirectPlay8Address **const prgpAddress,DWORD *const pcAddress,const DWORD dwFlags) PURE; - STDMETHOD(SetApplicationDesc) (THIS_ const DPN_APPLICATION_DESC *const pad, const DWORD dwFlags) PURE; - STDMETHOD(Host) (THIS_ const DPN_APPLICATION_DESC *const pdnAppDesc,IDirectPlay8Address **const prgpDeviceInfo,const DWORD cDeviceInfo,const DPN_SECURITY_DESC *const pdnSecurity,const DPN_SECURITY_CREDENTIALS *const pdnCredentials,void *const pvPlayerContext,const DWORD dwFlags) PURE; - STDMETHOD(SendTo) (THIS_ const DPNID dpnid,const DPN_BUFFER_DESC *const prgBufferDesc,const DWORD cBufferDesc,const DWORD dwTimeOut,void *const pvAsyncContext,DPNHANDLE *const phAsyncHandle,const DWORD dwFlags) PURE; - STDMETHOD(CreateGroup) (THIS_ const DPN_GROUP_INFO *const pdpnGroupInfo,void *const pvGroupContext,void *const pvAsyncContext,DPNHANDLE *const phAsyncHandle,const DWORD dwFlags) PURE; - STDMETHOD(DestroyGroup) (THIS_ const DPNID idGroup, PVOID const pvAsyncContext, DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; - STDMETHOD(AddPlayerToGroup) (THIS_ const DPNID idGroup, const DPNID idClient, PVOID const pvAsyncContext, DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; - STDMETHOD(RemovePlayerFromGroup) (THIS_ const DPNID idGroup, const DPNID idClient, PVOID const pvAsyncContext, DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; - STDMETHOD(SetGroupInfo) (THIS_ const DPNID dpnid,DPN_GROUP_INFO *const pdpnGroupInfo,PVOID const pvAsyncContext,DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; - STDMETHOD(GetGroupInfo) (THIS_ const DPNID dpnid,DPN_GROUP_INFO *const pdpnGroupInfo,DWORD *const pdwSize,const DWORD dwFlags) PURE; - STDMETHOD(EnumPlayersAndGroups) (THIS_ DPNID *const prgdpnid, DWORD *const pcdpnid, const DWORD dwFlags) PURE; - STDMETHOD(EnumGroupMembers) (THIS_ const DPNID dpnid, DPNID *const prgdpnid, DWORD *const pcdpnid, const DWORD dwFlags) PURE; - STDMETHOD(Close) (THIS_ const DWORD dwFlags) PURE; - STDMETHOD(DestroyClient) (THIS_ const DPNID dpnidClient, const void *const pvDestroyData, const DWORD dwDestroyDataSize, const DWORD dwFlags) PURE; - STDMETHOD(ReturnBuffer) (THIS_ const DPNHANDLE hBufferHandle,const DWORD dwFlags) PURE; - STDMETHOD(GetPlayerContext) (THIS_ const DPNID dpnid,PVOID *const ppvPlayerContext,const DWORD dwFlags) PURE; - STDMETHOD(GetGroupContext) (THIS_ const DPNID dpnid,PVOID *const ppvGroupContext,const DWORD dwFlags) PURE; - STDMETHOD(GetCaps) (THIS_ DPN_CAPS *const pdpCaps,const DWORD dwFlags) PURE; - STDMETHOD(SetCaps) (THIS_ const DPN_CAPS *const pdpCaps, const DWORD dwFlags) PURE; - STDMETHOD(SetSPCaps) (THIS_ const GUID * const pguidSP, const DPN_SP_CAPS *const pdpspCaps, const DWORD dwFlags ) PURE; - STDMETHOD(GetSPCaps) (THIS_ const GUID * const pguidSP, DPN_SP_CAPS *const pdpspCaps,const DWORD dwFlags) PURE; - STDMETHOD(GetConnectionInfo) (THIS_ const DPNID dpnid, DPN_CONNECTION_INFO *const pdpConnectionInfo,const DWORD dwFlags) PURE; - STDMETHOD(RegisterLobby) (THIS_ const DPNHANDLE dpnHandle, struct IDirectPlay8LobbiedApplication *const pIDP8LobbiedApplication,const DWORD dwFlags) PURE; -}; - -// -// COM definition for DirectPlay8 Peer interface -// -#undef INTERFACE // External COM Implementation -#define INTERFACE IDirectPlay8Peer -DECLARE_INTERFACE_(IDirectPlay8Peer,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ DP8REFIID riid, LPVOID *ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectPlay8Peer methods ***/ - STDMETHOD(Initialize) (THIS_ PVOID const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags) PURE; - STDMETHOD(EnumServiceProviders) (THIS_ const GUID *const pguidServiceProvider, const GUID *const pguidApplication, DPN_SERVICE_PROVIDER_INFO *const pSPInfoBuffer, DWORD *const pcbEnumData, DWORD *const pcReturned, const DWORD dwFlags) PURE; - STDMETHOD(CancelAsyncOperation) (THIS_ const DPNHANDLE hAsyncHandle, const DWORD dwFlags) PURE; - STDMETHOD(Connect) (THIS_ const DPN_APPLICATION_DESC *const pdnAppDesc,IDirectPlay8Address *const pHostAddr,IDirectPlay8Address *const pDeviceInfo,const DPN_SECURITY_DESC *const pdnSecurity,const DPN_SECURITY_CREDENTIALS *const pdnCredentials,const void *const pvUserConnectData,const DWORD dwUserConnectDataSize,void *const pvPlayerContext,void *const pvAsyncContext,DPNHANDLE *const phAsyncHandle,const DWORD dwFlags) PURE; - STDMETHOD(SendTo) (THIS_ const DPNID dpnid,const DPN_BUFFER_DESC *const prgBufferDesc,const DWORD cBufferDesc,const DWORD dwTimeOut,void *const pvAsyncContext,DPNHANDLE *const phAsyncHandle,const DWORD dwFlags) PURE; - STDMETHOD(GetSendQueueInfo) (THIS_ const DPNID dpnid, DWORD *const pdwNumMsgs, DWORD *const pdwNumBytes, const DWORD dwFlags) PURE; - STDMETHOD(Host) (THIS_ const DPN_APPLICATION_DESC *const pdnAppDesc,IDirectPlay8Address **const prgpDeviceInfo,const DWORD cDeviceInfo,const DPN_SECURITY_DESC *const pdnSecurity,const DPN_SECURITY_CREDENTIALS *const pdnCredentials,void *const pvPlayerContext,const DWORD dwFlags) PURE; - STDMETHOD(GetApplicationDesc) (THIS_ DPN_APPLICATION_DESC *const pAppDescBuffer, DWORD *const pcbDataSize, const DWORD dwFlags) PURE; - STDMETHOD(SetApplicationDesc) (THIS_ const DPN_APPLICATION_DESC *const pad, const DWORD dwFlags) PURE; - STDMETHOD(CreateGroup) (THIS_ const DPN_GROUP_INFO *const pdpnGroupInfo,void *const pvGroupContext,void *const pvAsyncContext,DPNHANDLE *const phAsyncHandle,const DWORD dwFlags) PURE; - STDMETHOD(DestroyGroup) (THIS_ const DPNID idGroup, PVOID const pvAsyncContext, DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; - STDMETHOD(AddPlayerToGroup) (THIS_ const DPNID idGroup, const DPNID idClient, PVOID const pvAsyncContext, DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; - STDMETHOD(RemovePlayerFromGroup) (THIS_ const DPNID idGroup, const DPNID idClient, PVOID const pvAsyncContext, DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; - STDMETHOD(SetGroupInfo) (THIS_ const DPNID dpnid,DPN_GROUP_INFO *const pdpnGroupInfo,PVOID const pvAsyncContext,DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; - STDMETHOD(GetGroupInfo) (THIS_ const DPNID dpnid,DPN_GROUP_INFO *const pdpnGroupInfo,DWORD *const pdwSize,const DWORD dwFlags) PURE; - STDMETHOD(EnumPlayersAndGroups) (THIS_ DPNID *const prgdpnid, DWORD *const pcdpnid, const DWORD dwFlags) PURE; - STDMETHOD(EnumGroupMembers) (THIS_ const DPNID dpnid, DPNID *const prgdpnid, DWORD *const pcdpnid, const DWORD dwFlags) PURE; - STDMETHOD(SetPeerInfo) (THIS_ const DPN_PLAYER_INFO *const pdpnPlayerInfo,PVOID const pvAsyncContext,DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; - STDMETHOD(GetPeerInfo) (THIS_ const DPNID dpnid,DPN_PLAYER_INFO *const pdpnPlayerInfo,DWORD *const pdwSize,const DWORD dwFlags) PURE; - STDMETHOD(GetPeerAddress) (THIS_ const DPNID dpnid,IDirectPlay8Address **const ppAddress,const DWORD dwFlags) PURE; - STDMETHOD(GetLocalHostAddresses) (THIS_ IDirectPlay8Address **const prgpAddress,DWORD *const pcAddress,const DWORD dwFlags) PURE; - STDMETHOD(Close) (THIS_ const DWORD dwFlags) PURE; - STDMETHOD(EnumHosts) (THIS_ PDPN_APPLICATION_DESC const pApplicationDesc,IDirectPlay8Address *const pAddrHost,IDirectPlay8Address *const pDeviceInfo,PVOID const pUserEnumData,const DWORD dwUserEnumDataSize,const DWORD dwEnumCount,const DWORD dwRetryInterval,const DWORD dwTimeOut,PVOID const pvUserContext,DPNHANDLE *const pAsyncHandle,const DWORD dwFlags) PURE; - STDMETHOD(DestroyPeer) (THIS_ const DPNID dpnidClient, const void *const pvDestroyData, const DWORD dwDestroyDataSize, const DWORD dwFlags) PURE; - STDMETHOD(ReturnBuffer) (THIS_ const DPNHANDLE hBufferHandle,const DWORD dwFlags) PURE; - STDMETHOD(GetPlayerContext) (THIS_ const DPNID dpnid,PVOID *const ppvPlayerContext,const DWORD dwFlags) PURE; - STDMETHOD(GetGroupContext) (THIS_ const DPNID dpnid,PVOID *const ppvGroupContext,const DWORD dwFlags) PURE; - STDMETHOD(GetCaps) (THIS_ DPN_CAPS *const pdpCaps,const DWORD dwFlags) PURE; - STDMETHOD(SetCaps) (THIS_ const DPN_CAPS *const pdpCaps, const DWORD dwFlags) PURE; - STDMETHOD(SetSPCaps) (THIS_ const GUID * const pguidSP, const DPN_SP_CAPS *const pdpspCaps, const DWORD dwFlags ) PURE; - STDMETHOD(GetSPCaps) (THIS_ const GUID * const pguidSP, DPN_SP_CAPS *const pdpspCaps,const DWORD dwFlags) PURE; - STDMETHOD(GetConnectionInfo) (THIS_ const DPNID dpnid, DPN_CONNECTION_INFO *const pdpConnectionInfo,const DWORD dwFlags) PURE; - STDMETHOD(RegisterLobby) (THIS_ const DPNHANDLE dpnHandle, struct IDirectPlay8LobbiedApplication *const pIDP8LobbiedApplication,const DWORD dwFlags) PURE; - STDMETHOD(TerminateSession) (THIS_ void *const pvTerminateData,const DWORD dwTerminateDataSize,const DWORD dwFlags) PURE; -}; - - - -// -// COM definition for DirectPlay8 Thread Pool interface -// -#undef INTERFACE // External COM Implementation -#define INTERFACE IDirectPlay8ThreadPool -DECLARE_INTERFACE_(IDirectPlay8ThreadPool,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ DP8REFIID riid, LPVOID *ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectPlay8ThreadPool methods ***/ - STDMETHOD(Initialize) (THIS_ PVOID const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags) PURE; - STDMETHOD(Close) (THIS_ const DWORD dwFlags) PURE; - STDMETHOD(GetThreadCount) (THIS_ const DWORD dwProcessorNum, DWORD *const pdwNumThreads, const DWORD dwFlags) PURE; - STDMETHOD(SetThreadCount) (THIS_ const DWORD dwProcessorNum, const DWORD dwNumThreads, const DWORD dwFlags) PURE; - STDMETHOD(DoWork) (THIS_ const DWORD dwAllowedTimeSlice, const DWORD dwFlags) PURE; -}; - - -// -// COM definition for DirectPlay8 NAT Resolver interface -// -#undef INTERFACE // External COM Implementation -#define INTERFACE IDirectPlay8NATResolver -DECLARE_INTERFACE_(IDirectPlay8NATResolver,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ DP8REFIID riid, LPVOID *ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectPlay8NATResolver methods ***/ - STDMETHOD(Initialize) (THIS_ PVOID const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags) PURE; - STDMETHOD(Start) (THIS_ IDirectPlay8Address **const ppDevices, const DWORD dwNumDevices, const DWORD dwFlags) PURE; - STDMETHOD(Close) (THIS_ const DWORD dwFlags) PURE; - STDMETHOD(EnumDevices) (THIS_ DPN_SERVICE_PROVIDER_INFO *const pSPInfoBuffer, PDWORD const pdwBufferSize, PDWORD const pdwNumDevices, const DWORD dwFlags) PURE; - STDMETHOD(GetAddresses) (THIS_ IDirectPlay8Address **const ppAddresses, DWORD *const pdwNumAddresses, const DWORD dwFlags) PURE; -}; - - -/**************************************************************************** - * - * IDirectPlay8 application interface macros - * - ****************************************************************************/ - -#if !defined(__cplusplus) || defined(CINTERFACE) - -#define IDirectPlay8Client_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlay8Client_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlay8Client_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlay8Client_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectPlay8Client_EnumServiceProviders(p,a,b,c,d,e,f) (p)->lpVtbl->EnumServiceProviders(p,a,b,c,d,e,f) -#define IDirectPlay8Client_EnumHosts(p,a,b,c,d,e,f,g,h,i,j,k) (p)->lpVtbl->EnumHosts(p,a,b,c,d,e,f,g,h,i,j,k) -#define IDirectPlay8Client_CancelAsyncOperation(p,a,b) (p)->lpVtbl->CancelAsyncOperation(p,a,b) -#define IDirectPlay8Client_Connect(p,a,b,c,d,e,f,g,h,i,j) (p)->lpVtbl->Connect(p,a,b,c,d,e,f,g,h,i,j) -#define IDirectPlay8Client_Send(p,a,b,c,d,e,f) (p)->lpVtbl->Send(p,a,b,c,d,e,f) -#define IDirectPlay8Client_GetSendQueueInfo(p,a,b,c) (p)->lpVtbl->GetSendQueueInfo(p,a,b,c) -#define IDirectPlay8Client_GetApplicationDesc(p,a,b,c) (p)->lpVtbl->GetApplicationDesc(p,a,b,c) -#define IDirectPlay8Client_SetClientInfo(p,a,b,c,d) (p)->lpVtbl->SetClientInfo(p,a,b,c,d) -#define IDirectPlay8Client_GetServerInfo(p,a,b,c) (p)->lpVtbl->GetServerInfo(p,a,b,c) -#define IDirectPlay8Client_GetServerAddress(p,a,b) (p)->lpVtbl->GetServerAddress(p,a,b) -#define IDirectPlay8Client_Close(p,a) (p)->lpVtbl->Close(p,a) -#define IDirectPlay8Client_ReturnBuffer(p,a,b) (p)->lpVtbl->ReturnBuffer(p,a,b) -#define IDirectPlay8Client_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) -#define IDirectPlay8Client_SetCaps(p,a,b) (p)->lpVtbl->SetCaps(p,a,b) -#define IDirectPlay8Client_SetSPCaps(p,a,b,c) (p)->lpVtbl->SetSPCaps(p,a,b,c) -#define IDirectPlay8Client_GetSPCaps(p,a,b,c) (p)->lpVtbl->GetSPCaps(p,a,b,c) -#define IDirectPlay8Client_GetConnectionInfo(p,a,b) (p)->lpVtbl->GetConnectionInfo(p,a,b) -#define IDirectPlay8Client_RegisterLobby(p,a,b,c) (p)->lpVtbl->RegisterLobby(p,a,b,c) - -#define IDirectPlay8Server_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlay8Server_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlay8Server_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlay8Server_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectPlay8Server_EnumServiceProviders(p,a,b,c,d,e,f) (p)->lpVtbl->EnumServiceProviders(p,a,b,c,d,e,f) -#define IDirectPlay8Server_CancelAsyncOperation(p,a,b) (p)->lpVtbl->CancelAsyncOperation(p,a,b) -#define IDirectPlay8Server_GetSendQueueInfo(p,a,b,c,d) (p)->lpVtbl->GetSendQueueInfo(p,a,b,c,d) -#define IDirectPlay8Server_GetApplicationDesc(p,a,b,c) (p)->lpVtbl->GetApplicationDesc(p,a,b,c) -#define IDirectPlay8Server_SetServerInfo(p,a,b,c,d) (p)->lpVtbl->SetServerInfo(p,a,b,c,d) -#define IDirectPlay8Server_GetClientInfo(p,a,b,c,d) (p)->lpVtbl->GetClientInfo(p,a,b,c,d) -#define IDirectPlay8Server_GetClientAddress(p,a,b,c) (p)->lpVtbl->GetClientAddress(p,a,b,c) -#define IDirectPlay8Server_GetLocalHostAddresses(p,a,b,c) (p)->lpVtbl->GetLocalHostAddresses(p,a,b,c) -#define IDirectPlay8Server_SetApplicationDesc(p,a,b) (p)->lpVtbl->SetApplicationDesc(p,a,b) -#define IDirectPlay8Server_Host(p,a,b,c,d,e,f,g) (p)->lpVtbl->Host(p,a,b,c,d,e,f,g) -#define IDirectPlay8Server_SendTo(p,a,b,c,d,e,f,g) (p)->lpVtbl->SendTo(p,a,b,c,d,e,f,g) -#define IDirectPlay8Server_CreateGroup(p,a,b,c,d,e) (p)->lpVtbl->CreateGroup(p,a,b,c,d,e) -#define IDirectPlay8Server_DestroyGroup(p,a,b,c,d) (p)->lpVtbl->DestroyGroup(p,a,b,c,d) -#define IDirectPlay8Server_AddPlayerToGroup(p,a,b,c,d,e) (p)->lpVtbl->AddPlayerToGroup(p,a,b,c,d,e) -#define IDirectPlay8Server_RemovePlayerFromGroup(p,a,b,c,d,e) (p)->lpVtbl->RemovePlayerFromGroup(p,a,b,c,d,e) -#define IDirectPlay8Server_SetGroupInfo(p,a,b,c,d,e) (p)->lpVtbl->SetGroupInfo(p,a,b,c,d,e) -#define IDirectPlay8Server_GetGroupInfo(p,a,b,c,d) (p)->lpVtbl->GetGroupInfo(p,a,b,c,d) -#define IDirectPlay8Server_EnumPlayersAndGroups(p,a,b,c) (p)->lpVtbl->EnumPlayersAndGroups(p,a,b,c) -#define IDirectPlay8Server_EnumGroupMembers(p,a,b,c,d) (p)->lpVtbl->EnumGroupMembers(p,a,b,c,d) -#define IDirectPlay8Server_Close(p,a) (p)->lpVtbl->Close(p,a) -#define IDirectPlay8Server_DestroyClient(p,a,b,c,d) (p)->lpVtbl->DestroyClient(p,a,b,c,d) -#define IDirectPlay8Server_ReturnBuffer(p,a,b) (p)->lpVtbl->ReturnBuffer(p,a,b) -#define IDirectPlay8Server_GetPlayerContext(p,a,b,c) (p)->lpVtbl->GetPlayerContext(p,a,b,c) -#define IDirectPlay8Server_GetGroupContext(p,a,b,c) (p)->lpVtbl->GetGroupContext(p,a,b,c) -#define IDirectPlay8Server_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) -#define IDirectPlay8Server_SetCaps(p,a,b) (p)->lpVtbl->SetCaps(p,a,b) -#define IDirectPlay8Server_SetSPCaps(p,a,b,c) (p)->lpVtbl->SetSPCaps(p,a,b,c) -#define IDirectPlay8Server_GetSPCaps(p,a,b,c) (p)->lpVtbl->GetSPCaps(p,a,b,c) -#define IDirectPlay8Server_GetConnectionInfo(p,a,b,c) (p)->lpVtbl->GetConnectionInfo(p,a,b,c) -#define IDirectPlay8Server_RegisterLobby(p,a,b,c) (p)->lpVtbl->RegisterLobby(p,a,b,c) - -#define IDirectPlay8Peer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlay8Peer_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlay8Peer_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlay8Peer_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectPlay8Peer_EnumServiceProviders(p,a,b,c,d,e,f) (p)->lpVtbl->EnumServiceProviders(p,a,b,c,d,e,f) -#define IDirectPlay8Peer_CancelAsyncOperation(p,a,b) (p)->lpVtbl->CancelAsyncOperation(p,a,b) -#define IDirectPlay8Peer_Connect(p,a,b,c,d,e,f,g,h,i,j,k) (p)->lpVtbl->Connect(p,a,b,c,d,e,f,g,h,i,j,k) -#define IDirectPlay8Peer_SendTo(p,a,b,c,d,e,f,g) (p)->lpVtbl->SendTo(p,a,b,c,d,e,f,g) -#define IDirectPlay8Peer_GetSendQueueInfo(p,a,b,c,d) (p)->lpVtbl->GetSendQueueInfo(p,a,b,c,d) -#define IDirectPlay8Peer_Host(p,a,b,c,d,e,f,g) (p)->lpVtbl->Host(p,a,b,c,d,e,f,g) -#define IDirectPlay8Peer_GetApplicationDesc(p,a,b,c) (p)->lpVtbl->GetApplicationDesc(p,a,b,c) -#define IDirectPlay8Peer_SetApplicationDesc(p,a,b) (p)->lpVtbl->SetApplicationDesc(p,a,b) -#define IDirectPlay8Peer_CreateGroup(p,a,b,c,d,e) (p)->lpVtbl->CreateGroup(p,a,b,c,d,e) -#define IDirectPlay8Peer_DestroyGroup(p,a,b,c,d) (p)->lpVtbl->DestroyGroup(p,a,b,c,d) -#define IDirectPlay8Peer_AddPlayerToGroup(p,a,b,c,d,e) (p)->lpVtbl->AddPlayerToGroup(p,a,b,c,d,e) -#define IDirectPlay8Peer_RemovePlayerFromGroup(p,a,b,c,d,e) (p)->lpVtbl->RemovePlayerFromGroup(p,a,b,c,d,e) -#define IDirectPlay8Peer_SetGroupInfo(p,a,b,c,d,e) (p)->lpVtbl->SetGroupInfo(p,a,b,c,d,e) -#define IDirectPlay8Peer_GetGroupInfo(p,a,b,c,d) (p)->lpVtbl->GetGroupInfo(p,a,b,c,d) -#define IDirectPlay8Peer_EnumPlayersAndGroups(p,a,b,c) (p)->lpVtbl->EnumPlayersAndGroups(p,a,b,c) -#define IDirectPlay8Peer_EnumGroupMembers(p,a,b,c,d) (p)->lpVtbl->EnumGroupMembers(p,a,b,c,d) -#define IDirectPlay8Peer_SetPeerInfo(p,a,b,c,d) (p)->lpVtbl->SetPeerInfo(p,a,b,c,d) -#define IDirectPlay8Peer_GetPeerInfo(p,a,b,c,d) (p)->lpVtbl->GetPeerInfo(p,a,b,c,d) -#define IDirectPlay8Peer_GetPeerAddress(p,a,b,c) (p)->lpVtbl->GetPeerAddress(p,a,b,c) -#define IDirectPlay8Peer_GetLocalHostAddresses(p,a,b,c) (p)->lpVtbl->GetLocalHostAddresses(p,a,b,c) -#define IDirectPlay8Peer_Close(p,a) (p)->lpVtbl->Close(p,a) -#define IDirectPlay8Peer_EnumHosts(p,a,b,c,d,e,f,g,h,i,j,k) (p)->lpVtbl->EnumHosts(p,a,b,c,d,e,f,g,h,i,j,k) -#define IDirectPlay8Peer_DestroyPeer(p,a,b,c,d) (p)->lpVtbl->DestroyPeer(p,a,b,c,d) -#define IDirectPlay8Peer_ReturnBuffer(p,a,b) (p)->lpVtbl->ReturnBuffer(p,a,b) -#define IDirectPlay8Peer_GetPlayerContext(p,a,b,c) (p)->lpVtbl->GetPlayerContext(p,a,b,c) -#define IDirectPlay8Peer_GetGroupContext(p,a,b,c) (p)->lpVtbl->GetGroupContext(p,a,b,c) -#define IDirectPlay8Peer_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) -#define IDirectPlay8Peer_SetCaps(p,a,b) (p)->lpVtbl->SetCaps(p,a,b) -#define IDirectPlay8Peer_SetSPCaps(p,a,b,c) (p)->lpVtbl->SetSPCaps(p,a,b,c) -#define IDirectPlay8Peer_GetSPCaps(p,a,b,c) (p)->lpVtbl->GetSPCaps(p,a,b,c) -#define IDirectPlay8Peer_GetConnectionInfo(p,a,b,c) (p)->lpVtbl->GetConnectionInfo(p,a,b,c) -#define IDirectPlay8Peer_RegisterLobby(p,a,b,c) (p)->lpVtbl->RegisterLobby(p,a,b,c) -#define IDirectPlay8Peer_TerminateSession(p,a,b,c) (p)->lpVtbl->TerminateSession(p,a,b,c) - -#define IDirectPlay8ThreadPool_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlay8ThreadPool_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlay8ThreadPool_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlay8ThreadPool_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectPlay8ThreadPool_Close(p,a) (p)->lpVtbl->Close(p,a) -#define IDirectPlay8ThreadPool_GetThreadCount(p,a,b,c) (p)->lpVtbl->GetThreadCount(p,a,b,c) -#define IDirectPlay8ThreadPool_SetThreadCount(p,a,b,c) (p)->lpVtbl->SetThreadCount(p,a,b,c) -#define IDirectPlay8ThreadPool_DoWork(p,a,b) (p)->lpVtbl->DoWork(p,a,b) - -#define IDirectPlay8NATResolver_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlay8NATResolver_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlay8NATResolver_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlay8NATResolver_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectPlay8NATResolver_Start(p,a,b,c) (p)->lpVtbl->Start(p,a,b,c) -#define IDirectPlay8NATResolver_Close(p,a) (p)->lpVtbl->Close(p,a) -#define IDirectPlay8NATResolver_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectPlay8NATResolver_GetAddresses(p,a,b,c) (p)->lpVtbl->GetAddresses(p,a,b,c) - -#else /* C++ */ - -#define IDirectPlay8Client_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlay8Client_AddRef(p) (p)->AddRef() -#define IDirectPlay8Client_Release(p) (p)->Release() -#define IDirectPlay8Client_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectPlay8Client_EnumServiceProviders(p,a,b,c,d,e,f) (p)->EnumServiceProviders(a,b,c,d,e,f) -#define IDirectPlay8Client_EnumHosts(p,a,b,c,d,e,f,g,h,i,j,k) (p)->EnumHosts(a,b,c,d,e,f,g,h,i,j,k) -#define IDirectPlay8Client_CancelAsyncOperation(p,a,b) (p)->CancelAsyncOperation(a,b) -#define IDirectPlay8Client_Connect(p,a,b,c,d,e,f,g,h,i,j) (p)->Connect(a,b,c,d,e,f,g,h,i,j) -#define IDirectPlay8Client_Send(p,a,b,c,d,e,f) (p)->Send(a,b,c,d,e,f) -#define IDirectPlay8Client_GetSendQueueInfo(p,a,b,c) (p)->GetSendQueueInfo(a,b,c) -#define IDirectPlay8Client_GetApplicationDesc(p,a,b,c) (p)->GetApplicationDesc(a,b,c) -#define IDirectPlay8Client_SetClientInfo(p,a,b,c,d) (p)->SetClientInfo(a,b,c,d) -#define IDirectPlay8Client_GetServerInfo(p,a,b,c) (p)->GetServerInfo(a,b,c) -#define IDirectPlay8Client_GetServerAddress(p,a,b) (p)->GetServerAddress(a,b) -#define IDirectPlay8Client_Close(p,a) (p)->Close(a) -#define IDirectPlay8Client_ReturnBuffer(p,a,b) (p)->ReturnBuffer(a,b) -#define IDirectPlay8Client_GetCaps(p,a,b) (p)->GetCaps(a,b) -#define IDirectPlay8Client_SetCaps(p,a,b) (p)->SetCaps(a,b) -#define IDirectPlay8Client_SetSPCaps(p,a,b,c) (p)->SetSPCaps(a,b,c) -#define IDirectPlay8Client_GetSPCaps(p,a,b,c) (p)->GetSPCaps(a,b,c) -#define IDirectPlay8Client_GetConnectionInfo(p,a,b) (p)->GetConnectionInfo(a,b) -#define IDirectPlay8Client_RegisterLobby(p,a,b,c) (p)->RegisterLobby(a,b,c) - -#define IDirectPlay8Server_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlay8Server_AddRef(p) (p)->AddRef() -#define IDirectPlay8Server_Release(p) (p)->Release() -#define IDirectPlay8Server_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectPlay8Server_EnumServiceProviders(p,a,b,c,d,e,f) (p)->EnumServiceProviders(a,b,c,d,e,f) -#define IDirectPlay8Server_CancelAsyncOperation(p,a,b) (p)->CancelAsyncOperation(a,b) -#define IDirectPlay8Server_GetSendQueueInfo(p,a,b,c,d) (p)->GetSendQueueInfo(a,b,c,d) -#define IDirectPlay8Server_GetApplicationDesc(p,a,b,c) (p)->GetApplicationDesc(a,b,c) -#define IDirectPlay8Server_SetServerInfo(p,a,b,c,d) (p)->SetServerInfo(a,b,c,d) -#define IDirectPlay8Server_GetClientInfo(p,a,b,c,d) (p)->GetClientInfo(a,b,c,d) -#define IDirectPlay8Server_GetClientAddress(p,a,b,c) (p)->GetClientAddress(a,b,c) -#define IDirectPlay8Server_GetLocalHostAddresses(p,a,b,c) (p)->GetLocalHostAddresses(a,b,c) -#define IDirectPlay8Server_SetApplicationDesc(p,a,b) (p)->SetApplicationDesc(a,b) -#define IDirectPlay8Server_Host(p,a,b,c,d,e,f,g) (p)->Host(a,b,c,d,e,f,g) -#define IDirectPlay8Server_SendTo(p,a,b,c,d,e,f,g) (p)->SendTo(a,b,c,d,e,f,g) -#define IDirectPlay8Server_CreateGroup(p,a,b,c,d,e) (p)->CreateGroup(a,b,c,d,e) -#define IDirectPlay8Server_DestroyGroup(p,a,b,c,d) (p)->DestroyGroup(a,b,c,d) -#define IDirectPlay8Server_AddPlayerToGroup(p,a,b,c,d,e) (p)->AddPlayerToGroup(a,b,c,d,e) -#define IDirectPlay8Server_RemovePlayerFromGroup(p,a,b,c,d,e) (p)->RemovePlayerFromGroup(a,b,c,d,e) -#define IDirectPlay8Server_SetGroupInfo(p,a,b,c,d,e) (p)->SetGroupInfo(a,b,c,d,e) -#define IDirectPlay8Server_GetGroupInfo(p,a,b,c,d) (p)->GetGroupInfo(a,b,c,d) -#define IDirectPlay8Server_EnumPlayersAndGroups(p,a,b,c) (p)->EnumPlayersAndGroups(a,b,c) -#define IDirectPlay8Server_EnumGroupMembers(p,a,b,c,d) (p)->EnumGroupMembers(a,b,c,d) -#define IDirectPlay8Server_Close(p,a) (p)->Close(a) -#define IDirectPlay8Server_DestroyClient(p,a,b,c,d) (p)->DestroyClient(a,b,c,d) -#define IDirectPlay8Server_ReturnBuffer(p,a,b) (p)->ReturnBuffer(a,b) -#define IDirectPlay8Server_GetPlayerContext(p,a,b,c) (p)->GetPlayerContext(a,b,c) -#define IDirectPlay8Server_GetGroupContext(p,a,b,c) (p)->GetGroupContext(a,b,c) -#define IDirectPlay8Server_GetCaps(p,a,b) (p)->GetCaps(a,b) -#define IDirectPlay8Server_SetCaps(p,a,b) (p)->SetCaps(a,b) -#define IDirectPlay8Server_SetSPCaps(p,a,b,c) (p)->SetSPCaps(a,b,c) -#define IDirectPlay8Server_GetSPCaps(p,a,b,c) (p)->GetSPCaps(a,b,c) -#define IDirectPlay8Server_GetConnectionInfo(p,a,b,c) (p)->GetConnectionInfo(a,b,c) -#define IDirectPlay8Server_RegisterLobby(p,a,b,c) (p)->RegisterLobby(a,b,c) - -#define IDirectPlay8Peer_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlay8Peer_AddRef(p) (p)->AddRef() -#define IDirectPlay8Peer_Release(p) (p)->Release() -#define IDirectPlay8Peer_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectPlay8Peer_EnumServiceProviders(p,a,b,c,d,e,f) (p)->EnumServiceProviders(a,b,c,d,e,f) -#define IDirectPlay8Peer_CancelAsyncOperation(p,a,b) (p)->CancelAsyncOperation(a,b) -#define IDirectPlay8Peer_Connect(p,a,b,c,d,e,f,g,h,i,j,k) (p)->Connect(a,b,c,d,e,f,g,h,i,j,k) -#define IDirectPlay8Peer_SendTo(p,a,b,c,d,e,f,g) (p)->SendTo(a,b,c,d,e,f,g) -#define IDirectPlay8Peer_GetSendQueueInfo(p,a,b,c,d) (p)->GetSendQueueInfo(a,b,c,d) -#define IDirectPlay8Peer_Host(p,a,b,c,d,e,f,g) (p)->Host(a,b,c,d,e,f,g) -#define IDirectPlay8Peer_GetApplicationDesc(p,a,b,c) (p)->GetApplicationDesc(a,b,c) -#define IDirectPlay8Peer_SetApplicationDesc(p,a,b) (p)->SetApplicationDesc(a,b) -#define IDirectPlay8Peer_CreateGroup(p,a,b,c,d,e) (p)->CreateGroup(a,b,c,d,e) -#define IDirectPlay8Peer_DestroyGroup(p,a,b,c,d) (p)->DestroyGroup(a,b,c,d) -#define IDirectPlay8Peer_AddPlayerToGroup(p,a,b,c,d,e) (p)->AddPlayerToGroup(a,b,c,d,e) -#define IDirectPlay8Peer_RemovePlayerFromGroup(p,a,b,c,d,e) (p)->RemovePlayerFromGroup(a,b,c,d,e) -#define IDirectPlay8Peer_SetGroupInfo(p,a,b,c,d,e) (p)->SetGroupInfo(a,b,c,d,e) -#define IDirectPlay8Peer_GetGroupInfo(p,a,b,c,d) (p)->GetGroupInfo(a,b,c,d) -#define IDirectPlay8Peer_EnumPlayersAndGroups(p,a,b,c) (p)->EnumPlayersAndGroups(a,b,c) -#define IDirectPlay8Peer_EnumGroupMembers(p,a,b,c,d) (p)->EnumGroupMembers(a,b,c,d) -#define IDirectPlay8Peer_SetPeerInfo(p,a,b,c,d) (p)->SetPeerInfo(a,b,c,d) -#define IDirectPlay8Peer_GetPeerInfo(p,a,b,c,d) (p)->GetPeerInfo(a,b,c,d) -#define IDirectPlay8Peer_GetPeerAddress(p,a,b,c) (p)->GetPeerAddress(a,b,c) -#define IDirectPlay8Peer_GetLocalHostAddresses(p,a,b,c) (p)->GetLocalHostAddresses(a,b,c) -#define IDirectPlay8Peer_Close(p,a) (p)->Close(a) -#define IDirectPlay8Peer_EnumHosts(p,a,b,c,d,e,f,g,h,i,j,k) (p)->EnumHosts(a,b,c,d,e,f,g,h,i,j,k) -#define IDirectPlay8Peer_DestroyPeer(p,a,b,c,d) (p)->DestroyPeer(a,b,c,d) -#define IDirectPlay8Peer_ReturnBuffer(p,a,b) (p)->ReturnBuffer(a,b) -#define IDirectPlay8Peer_GetPlayerContext(p,a,b,c) (p)->GetPlayerContext(a,b,c) -#define IDirectPlay8Peer_GetGroupContext(p,a,b,c) (p)->GetGroupContext(a,b,c) -#define IDirectPlay8Peer_GetCaps(p,a,b) (p)->GetCaps(a,b) -#define IDirectPlay8Peer_SetCaps(p,a,b) (p)->SetCaps(a,b) -#define IDirectPlay8Peer_SetSPCaps(p,a,b,c) (p)->SetSPCaps(a,b,c) -#define IDirectPlay8Peer_GetSPCaps(p,a,b,c) (p)->GetSPCaps(a,b,c) -#define IDirectPlay8Peer_GetConnectionInfo(p,a,b,c) (p)->GetConnectionInfo(a,b,c) -#define IDirectPlay8Peer_RegisterLobby(p,a,b,c) (p)->RegisterLobby(a,b,c) -#define IDirectPlay8Peer_TerminateSession(p,a,b,c) (p)->TerminateSession(a,b,c) - -#define IDirectPlay8ThreadPool_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlay8ThreadPool_AddRef(p) (p)->AddRef() -#define IDirectPlay8ThreadPool_Release(p) (p)->Release() -#define IDirectPlay8ThreadPool_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectPlay8ThreadPool_Close(p,a) (p)->Close(a) -#define IDirectPlay8ThreadPool_GetThreadCount(p,a,b,c) (p)->GetThreadCount(a,b,c) -#define IDirectPlay8ThreadPool_SetThreadCount(p,a,b,c) (p)->SetThreadCount(a,b,c) -#define IDirectPlay8ThreadPool_DoWork(p,a,b) (p)->DoWork(a,b) - -#define IDirectPlay8NATResolver_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlay8NATResolver_AddRef(p) (p)->AddRef() -#define IDirectPlay8NATResolver_Release(p) (p)->Release() -#define IDirectPlay8NATResolver_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectPlay8NATResolver_Start(p,a,b,c) (p)->Start(a,b,c) -#define IDirectPlay8NATResolver_Close(p,a) (p)->Close(a) -#define IDirectPlay8NATResolver_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectPlay8NATResolver_GetAddresses(p,a,b,c) (p)->GetAddresses(a,b,c) - -#endif - - - -/**************************************************************************** - * - * DIRECTPLAY8 ERRORS - * - * Errors are represented by negative values and cannot be combined. - * - ****************************************************************************/ - -#define _DPN_FACILITY_CODE 0x015 -#define _DPNHRESULT_BASE 0x8000 -#define MAKE_DPNHRESULT( code ) MAKE_HRESULT( 1, _DPN_FACILITY_CODE, ( code + _DPNHRESULT_BASE ) ) - -#define DPN_OK S_OK - -#define DPNSUCCESS_EQUAL MAKE_HRESULT( 0, _DPN_FACILITY_CODE, ( 0x5 + _DPNHRESULT_BASE ) ) -#define DPNSUCCESS_NOPLAYERSINGROUP MAKE_HRESULT( 0, _DPN_FACILITY_CODE, ( 0x8 + _DPNHRESULT_BASE ) ) // added for DirectX 9 -#define DPNSUCCESS_NOTEQUAL MAKE_HRESULT( 0, _DPN_FACILITY_CODE, (0x0A + _DPNHRESULT_BASE ) ) -#define DPNSUCCESS_PENDING MAKE_HRESULT( 0, _DPN_FACILITY_CODE, (0x0e + _DPNHRESULT_BASE ) ) - -#define DPNERR_ABORTED MAKE_DPNHRESULT( 0x30 ) -#define DPNERR_ADDRESSING MAKE_DPNHRESULT( 0x40 ) -#define DPNERR_ALREADYCLOSING MAKE_DPNHRESULT( 0x50 ) -#define DPNERR_ALREADYCONNECTED MAKE_DPNHRESULT( 0x60 ) -#define DPNERR_ALREADYDISCONNECTING MAKE_DPNHRESULT( 0x70 ) -#define DPNERR_ALREADYINITIALIZED MAKE_DPNHRESULT( 0x80 ) -#define DPNERR_ALREADYREGISTERED MAKE_DPNHRESULT( 0x90 ) -#define DPNERR_BUFFERTOOSMALL MAKE_DPNHRESULT( 0x100 ) -#define DPNERR_CANNOTCANCEL MAKE_DPNHRESULT( 0x110 ) -#define DPNERR_CANTCREATEGROUP MAKE_DPNHRESULT( 0x120 ) -#define DPNERR_CANTCREATEPLAYER MAKE_DPNHRESULT( 0x130 ) -#define DPNERR_CANTLAUNCHAPPLICATION MAKE_DPNHRESULT( 0x140 ) -#define DPNERR_CONNECTING MAKE_DPNHRESULT( 0x150 ) -#define DPNERR_CONNECTIONLOST MAKE_DPNHRESULT( 0x160 ) -#define DPNERR_CONVERSION MAKE_DPNHRESULT( 0x170 ) -#define DPNERR_DATATOOLARGE MAKE_DPNHRESULT( 0x175 ) -#define DPNERR_DOESNOTEXIST MAKE_DPNHRESULT( 0x180 ) -#define DPNERR_DPNSVRNOTAVAILABLE MAKE_DPNHRESULT( 0x185 ) -#define DPNERR_DUPLICATECOMMAND MAKE_DPNHRESULT( 0x190 ) -#define DPNERR_ENDPOINTNOTRECEIVING MAKE_DPNHRESULT( 0x200 ) -#define DPNERR_ENUMQUERYTOOLARGE MAKE_DPNHRESULT( 0x210 ) -#define DPNERR_ENUMRESPONSETOOLARGE MAKE_DPNHRESULT( 0x220 ) -#define DPNERR_EXCEPTION MAKE_DPNHRESULT( 0x230 ) -#define DPNERR_GENERIC E_FAIL -#define DPNERR_GROUPNOTEMPTY MAKE_DPNHRESULT( 0x240 ) -#define DPNERR_HOSTING MAKE_DPNHRESULT( 0x250 ) -#define DPNERR_HOSTREJECTEDCONNECTION MAKE_DPNHRESULT( 0x260 ) -#define DPNERR_HOSTTERMINATEDSESSION MAKE_DPNHRESULT( 0x270 ) -#define DPNERR_INCOMPLETEADDRESS MAKE_DPNHRESULT( 0x280 ) -#define DPNERR_INVALIDADDRESSFORMAT MAKE_DPNHRESULT( 0x290 ) -#define DPNERR_INVALIDAPPLICATION MAKE_DPNHRESULT( 0x300 ) -#define DPNERR_INVALIDCOMMAND MAKE_DPNHRESULT( 0x310 ) -#define DPNERR_INVALIDDEVICEADDRESS MAKE_DPNHRESULT( 0x320 ) -#define DPNERR_INVALIDENDPOINT MAKE_DPNHRESULT( 0x330 ) -#define DPNERR_INVALIDFLAGS MAKE_DPNHRESULT( 0x340 ) -#define DPNERR_INVALIDGROUP MAKE_DPNHRESULT( 0x350 ) -#define DPNERR_INVALIDHANDLE MAKE_DPNHRESULT( 0x360 ) -#define DPNERR_INVALIDHOSTADDRESS MAKE_DPNHRESULT( 0x370 ) -#define DPNERR_INVALIDINSTANCE MAKE_DPNHRESULT( 0x380 ) -#define DPNERR_INVALIDINTERFACE MAKE_DPNHRESULT( 0x390 ) -#define DPNERR_INVALIDOBJECT MAKE_DPNHRESULT( 0x400 ) -#define DPNERR_INVALIDPARAM E_INVALIDARG -#define DPNERR_INVALIDPASSWORD MAKE_DPNHRESULT( 0x410 ) -#define DPNERR_INVALIDPLAYER MAKE_DPNHRESULT( 0x420 ) -#define DPNERR_INVALIDPOINTER E_POINTER -#define DPNERR_INVALIDPRIORITY MAKE_DPNHRESULT( 0x430 ) -#define DPNERR_INVALIDSTRING MAKE_DPNHRESULT( 0x440 ) -#define DPNERR_INVALIDURL MAKE_DPNHRESULT( 0x450 ) -#define DPNERR_INVALIDVERSION MAKE_DPNHRESULT( 0x460 ) -#define DPNERR_NOCAPS MAKE_DPNHRESULT( 0x470 ) -#define DPNERR_NOCONNECTION MAKE_DPNHRESULT( 0x480 ) -#define DPNERR_NOHOSTPLAYER MAKE_DPNHRESULT( 0x490 ) -#define DPNERR_NOINTERFACE E_NOINTERFACE -#define DPNERR_NOMOREADDRESSCOMPONENTS MAKE_DPNHRESULT( 0x500 ) -#define DPNERR_NORESPONSE MAKE_DPNHRESULT( 0x510 ) -#define DPNERR_NOTALLOWED MAKE_DPNHRESULT( 0x520 ) -#define DPNERR_NOTHOST MAKE_DPNHRESULT( 0x530 ) -#define DPNERR_NOTREADY MAKE_DPNHRESULT( 0x540 ) -#define DPNERR_NOTREGISTERED MAKE_DPNHRESULT( 0x550 ) -#define DPNERR_OUTOFMEMORY E_OUTOFMEMORY -#define DPNERR_PENDING DPNSUCCESS_PENDING -#define DPNERR_PLAYERALREADYINGROUP MAKE_DPNHRESULT( 0x560 ) -#define DPNERR_PLAYERLOST MAKE_DPNHRESULT( 0x570 ) -#define DPNERR_PLAYERNOTINGROUP MAKE_DPNHRESULT( 0x580 ) -#define DPNERR_PLAYERNOTREACHABLE MAKE_DPNHRESULT( 0x590 ) -#define DPNERR_SENDTOOLARGE MAKE_DPNHRESULT( 0x600 ) -#define DPNERR_SESSIONFULL MAKE_DPNHRESULT( 0x610 ) -#define DPNERR_TABLEFULL MAKE_DPNHRESULT( 0x620 ) -#define DPNERR_TIMEDOUT MAKE_DPNHRESULT( 0x630 ) -#define DPNERR_UNINITIALIZED MAKE_DPNHRESULT( 0x640 ) -#define DPNERR_UNSUPPORTED E_NOTIMPL -#define DPNERR_USERCANCEL MAKE_DPNHRESULT( 0x650 ) - -#ifdef __cplusplus -} -#endif - -#endif - +/*========================================================================== + * + * Copyright (C) 1998-2002 Microsoft Corporation. All Rights Reserved. + * + * File: DPlay8.h + * Content: DirectPlay8 include file + * + ***************************************************************************/ + +#ifndef __DIRECTPLAY8_H__ +#define __DIRECTPLAY8_H__ + +#include // for DECLARE_INTERFACE_ and HRESULT + +#include "dpaddr.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + + +/**************************************************************************** + * + * DirectPlay8 CLSIDs + * + ****************************************************************************/ + +// {743F1DC6-5ABA-429f-8BDF-C54D03253DC2} +DEFINE_GUID(CLSID_DirectPlay8Client, +0x743f1dc6, 0x5aba, 0x429f, 0x8b, 0xdf, 0xc5, 0x4d, 0x3, 0x25, 0x3d, 0xc2); + +// {DA825E1B-6830-43d7-835D-0B5AD82956A2} +DEFINE_GUID(CLSID_DirectPlay8Server, +0xda825e1b, 0x6830, 0x43d7, 0x83, 0x5d, 0xb, 0x5a, 0xd8, 0x29, 0x56, 0xa2); + +// {286F484D-375E-4458-A272-B138E2F80A6A} +DEFINE_GUID(CLSID_DirectPlay8Peer, +0x286f484d, 0x375e, 0x4458, 0xa2, 0x72, 0xb1, 0x38, 0xe2, 0xf8, 0xa, 0x6a); + + +// CLSIDs added for DirectX 9 + +// {FC47060E-6153-4b34-B975-8E4121EB7F3C} +DEFINE_GUID(CLSID_DirectPlay8ThreadPool, +0xfc47060e, 0x6153, 0x4b34, 0xb9, 0x75, 0x8e, 0x41, 0x21, 0xeb, 0x7f, 0x3c); + +// {E4C1D9A2-CBF7-48bd-9A69-34A55E0D8941} +DEFINE_GUID(CLSID_DirectPlay8NATResolver, +0xe4c1d9a2, 0xcbf7, 0x48bd, 0x9a, 0x69, 0x34, 0xa5, 0x5e, 0xd, 0x89, 0x41); + +/**************************************************************************** + * + * DirectPlay8 Interface IIDs + * + ****************************************************************************/ + +typedef REFIID DP8REFIID; + + +// {5102DACD-241B-11d3-AEA7-006097B01411} +DEFINE_GUID(IID_IDirectPlay8Client, +0x5102dacd, 0x241b, 0x11d3, 0xae, 0xa7, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); + +// {5102DACE-241B-11d3-AEA7-006097B01411} +DEFINE_GUID(IID_IDirectPlay8Server, +0x5102dace, 0x241b, 0x11d3, 0xae, 0xa7, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); + +// {5102DACF-241B-11d3-AEA7-006097B01411} +DEFINE_GUID(IID_IDirectPlay8Peer, +0x5102dacf, 0x241b, 0x11d3, 0xae, 0xa7, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); + + +// IIDs added for DirectX 9 + +// {0D22EE73-4A46-4a0d-89B2-045B4D666425} +DEFINE_GUID(IID_IDirectPlay8ThreadPool, +0xd22ee73, 0x4a46, 0x4a0d, 0x89, 0xb2, 0x4, 0x5b, 0x4d, 0x66, 0x64, 0x25); + +// {A9E213F2-9A60-486f-BF3B-53408B6D1CBB} +DEFINE_GUID(IID_IDirectPlay8NATResolver, +0xa9e213f2, 0x9a60, 0x486f, 0xbf, 0x3b, 0x53, 0x40, 0x8b, 0x6d, 0x1c, 0xbb); + +/**************************************************************************** + * + * DirectPlay8 Service Provider GUIDs + * + ****************************************************************************/ + + +// {53934290-628D-11D2-AE0F-006097B01411} +DEFINE_GUID(CLSID_DP8SP_IPX, +0x53934290, 0x628d, 0x11d2, 0xae, 0xf, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); + + +// {6D4A3650-628D-11D2-AE0F-006097B01411} +DEFINE_GUID(CLSID_DP8SP_MODEM, +0x6d4a3650, 0x628d, 0x11d2, 0xae, 0xf, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); + + +// {743B5D60-628D-11D2-AE0F-006097B01411} +DEFINE_GUID(CLSID_DP8SP_SERIAL, +0x743b5d60, 0x628d, 0x11d2, 0xae, 0xf, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); + + +// {EBFE7BA0-628D-11D2-AE0F-006097B01411} +DEFINE_GUID(CLSID_DP8SP_TCPIP, +0xebfe7ba0, 0x628d, 0x11d2, 0xae, 0xf, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); + + +// Service providers added for DirectX 9 + + +// {995513AF-3027-4b9a-956E-C772B3F78006} +DEFINE_GUID(CLSID_DP8SP_BLUETOOTH, +0x995513af, 0x3027, 0x4b9a, 0x95, 0x6e, 0xc7, 0x72, 0xb3, 0xf7, 0x80, 0x6); + + +/**************************************************************************** + * + * DirectPlay8 Interface Pointer definitions + * + ****************************************************************************/ + +typedef struct IDirectPlay8Client *PDIRECTPLAY8CLIENT; + +typedef struct IDirectPlay8Server *PDIRECTPLAY8SERVER; + +typedef struct IDirectPlay8Peer *PDIRECTPLAY8PEER; + + +// Interface pointers added for DirectX 9 + +typedef struct IDirectPlay8ThreadPool *PDIRECTPLAY8THREADPOOL; + +typedef struct IDirectPlay8NATResolver *PDIRECTPLAY8NATRESOLVER; + +/**************************************************************************** + * + * DirectPlay8 Forward Declarations For External Types + * + ****************************************************************************/ + +typedef struct IDirectPlay8LobbiedApplication *PDNLOBBIEDAPPLICATION; +typedef struct IDirectPlay8Address IDirectPlay8Address; + +/**************************************************************************** + * + * DirectPlay8 Callback Functions + * + ****************************************************************************/ + +// +// Callback Function Type Definition +// +typedef HRESULT (WINAPI *PFNDPNMESSAGEHANDLER)(PVOID,DWORD,PVOID); + +/**************************************************************************** + * + * DirectPlay8 Datatypes (Non-Structure / Non-Message) + * + ****************************************************************************/ + +// +// Player IDs. Used to uniquely identify a player in a session +// +typedef DWORD DPNID, *PDPNID; + +// +// Used as identifiers for operations +// +typedef DWORD DPNHANDLE, *PDPNHANDLE; + + + + +/**************************************************************************** + * + * DirectPlay8 Message Identifiers + * + ****************************************************************************/ + +#define DPN_MSGID_OFFSET 0xFFFF0000 +#define DPN_MSGID_ADD_PLAYER_TO_GROUP ( DPN_MSGID_OFFSET | 0x0001 ) +#define DPN_MSGID_APPLICATION_DESC ( DPN_MSGID_OFFSET | 0x0002 ) +#define DPN_MSGID_ASYNC_OP_COMPLETE ( DPN_MSGID_OFFSET | 0x0003 ) +#define DPN_MSGID_CLIENT_INFO ( DPN_MSGID_OFFSET | 0x0004 ) +#define DPN_MSGID_CONNECT_COMPLETE ( DPN_MSGID_OFFSET | 0x0005 ) +#define DPN_MSGID_CREATE_GROUP ( DPN_MSGID_OFFSET | 0x0006 ) +#define DPN_MSGID_CREATE_PLAYER ( DPN_MSGID_OFFSET | 0x0007 ) +#define DPN_MSGID_DESTROY_GROUP ( DPN_MSGID_OFFSET | 0x0008 ) +#define DPN_MSGID_DESTROY_PLAYER ( DPN_MSGID_OFFSET | 0x0009 ) +#define DPN_MSGID_ENUM_HOSTS_QUERY ( DPN_MSGID_OFFSET | 0x000a ) +#define DPN_MSGID_ENUM_HOSTS_RESPONSE ( DPN_MSGID_OFFSET | 0x000b ) +#define DPN_MSGID_GROUP_INFO ( DPN_MSGID_OFFSET | 0x000c ) +#define DPN_MSGID_HOST_MIGRATE ( DPN_MSGID_OFFSET | 0x000d ) +#define DPN_MSGID_INDICATE_CONNECT ( DPN_MSGID_OFFSET | 0x000e ) +#define DPN_MSGID_INDICATED_CONNECT_ABORTED ( DPN_MSGID_OFFSET | 0x000f ) +#define DPN_MSGID_PEER_INFO ( DPN_MSGID_OFFSET | 0x0010 ) +#define DPN_MSGID_RECEIVE ( DPN_MSGID_OFFSET | 0x0011 ) +#define DPN_MSGID_REMOVE_PLAYER_FROM_GROUP ( DPN_MSGID_OFFSET | 0x0012 ) +#define DPN_MSGID_RETURN_BUFFER ( DPN_MSGID_OFFSET | 0x0013 ) +#define DPN_MSGID_SEND_COMPLETE ( DPN_MSGID_OFFSET | 0x0014 ) +#define DPN_MSGID_SERVER_INFO ( DPN_MSGID_OFFSET | 0x0015 ) +#define DPN_MSGID_TERMINATE_SESSION ( DPN_MSGID_OFFSET | 0x0016 ) + +// Messages added for DirectX 9 +#define DPN_MSGID_CREATE_THREAD ( DPN_MSGID_OFFSET | 0x0017 ) +#define DPN_MSGID_DESTROY_THREAD ( DPN_MSGID_OFFSET | 0x0018 ) +#define DPN_MSGID_NAT_RESOLVER_QUERY ( DPN_MSGID_OFFSET | 0x0101 ) + +/**************************************************************************** + * + * DirectPlay8 Constants + * + ****************************************************************************/ + +#define DPNID_ALL_PLAYERS_GROUP 0 + +// +// DESTROY_GROUP reasons +// +#define DPNDESTROYGROUPREASON_NORMAL 0x0001 +#define DPNDESTROYGROUPREASON_AUTODESTRUCTED 0x0002 +#define DPNDESTROYGROUPREASON_SESSIONTERMINATED 0x0003 + +// +// DESTROY_PLAYER reasons +// +#define DPNDESTROYPLAYERREASON_NORMAL 0x0001 +#define DPNDESTROYPLAYERREASON_CONNECTIONLOST 0x0002 +#define DPNDESTROYPLAYERREASON_SESSIONTERMINATED 0x0003 +#define DPNDESTROYPLAYERREASON_HOSTDESTROYEDPLAYER 0x0004 + +#define DPN_MAX_APPDESC_RESERVEDDATA_SIZE 64 + + + +/**************************************************************************** + * + * DirectPlay8 Flags + * + ****************************************************************************/ + +// +// Asynchronous operation flags (for Async Ops) +// +#define DPNOP_SYNC 0x80000000 + +// +// Add player to group flags (for AddPlayerToGroup) +// +#define DPNADDPLAYERTOGROUP_SYNC DPNOP_SYNC + +// +// Cancel flags +// +#define DPNCANCEL_CONNECT 0x00000001 +#define DPNCANCEL_ENUM 0x00000002 +#define DPNCANCEL_SEND 0x00000004 +#define DPNCANCEL_ALL_OPERATIONS 0x00008000 +// Flags added for DirectX 9 +#define DPNCANCEL_PLAYER_SENDS 0x80000000 +#define DPNCANCEL_PLAYER_SENDS_PRIORITY_HIGH (DPNCANCEL_PLAYER_SENDS | 0x00010000) +#define DPNCANCEL_PLAYER_SENDS_PRIORITY_NORMAL (DPNCANCEL_PLAYER_SENDS | 0x00020000) +#define DPNCANCEL_PLAYER_SENDS_PRIORITY_LOW (DPNCANCEL_PLAYER_SENDS | 0x00040000) + +// +// Close flags (for Close, added for DirectX 9) +// +#define DPNCLOSE_IMMEDIATE 0x00000001 + +// +// Connect flags (for Connect) +// +#define DPNCONNECT_SYNC DPNOP_SYNC +#define DPNCONNECT_OKTOQUERYFORADDRESSING 0x0001 + +// +// Create group flags (for CreateGroup) +// +#define DPNCREATEGROUP_SYNC DPNOP_SYNC + +// +// Destroy group flags (for DestroyGroup) +// +#define DPNDESTROYGROUP_SYNC DPNOP_SYNC + +// +// Enumerate clients and groups flags (for EnumPlayersAndGroups) +// +#define DPNENUM_PLAYERS 0x0001 +#define DPNENUM_GROUPS 0x0010 + +// +// Enum hosts flags (for EnumHosts) +// +#define DPNENUMHOSTS_SYNC DPNOP_SYNC +#define DPNENUMHOSTS_OKTOQUERYFORADDRESSING 0x0001 +#define DPNENUMHOSTS_NOBROADCASTFALLBACK 0x0002 + +// +// Enum service provider flags (for EnumSP) +// +#define DPNENUMSERVICEPROVIDERS_ALL 0x0001 + +// +// GetLocalHostAddresses flags (added for DirectX 9) +// +#define DPNGETLOCALHOSTADDRESSES_COMBINED 0x0001 + +// +// Get send queue info flags (for GetSendQueueInfo) +// +#define DPNGETSENDQUEUEINFO_PRIORITY_NORMAL 0x0001 +#define DPNGETSENDQUEUEINFO_PRIORITY_HIGH 0x0002 +#define DPNGETSENDQUEUEINFO_PRIORITY_LOW 0x0004 + +// +// Group information flags (for Group Info) +// +#define DPNGROUP_AUTODESTRUCT 0x0001 + +// +// Host flags (for Host) +// +#define DPNHOST_OKTOQUERYFORADDRESSING 0x0001 + +// +// Set info +// +#define DPNINFO_NAME 0x0001 +#define DPNINFO_DATA 0x0002 + +// +// Initialize flags (for Initialize) +// +#define DPNINITIALIZE_DISABLEPARAMVAL 0x0001 +// Flags added for DirectX 9 +#define DPNINITIALIZE_HINT_LANSESSION 0x0002 +#define DPNINITIALIZE_DISABLELINKTUNING 0x0004 + + +// +// Register Lobby flags +// +#define DPNLOBBY_REGISTER 0x0001 +#define DPNLOBBY_UNREGISTER 0x0002 + +// +// Player information flags (for Player Info / Player Messages) +// +#define DPNPLAYER_LOCAL 0x0002 +#define DPNPLAYER_HOST 0x0004 + +// +// Receive indication flags (added for DirectX 9) +// +#define DPNRECEIVE_GUARANTEED 0x0001 +#define DPNRECEIVE_COALESCED 0x0002 + +// +// Remove player from group flags (for RemovePlayerFromGroup) +// +#define DPNREMOVEPLAYERFROMGROUP_SYNC DPNOP_SYNC + +// +// Send flags (for Send/SendTo) +// +#define DPNSEND_SYNC DPNOP_SYNC +#define DPNSEND_NOCOPY 0x0001 +#define DPNSEND_NOCOMPLETE 0x0002 +#define DPNSEND_COMPLETEONPROCESS 0x0004 +#define DPNSEND_GUARANTEED 0x0008 +#define DPNSEND_NONSEQUENTIAL 0x0010 +#define DPNSEND_NOLOOPBACK 0x0020 +#define DPNSEND_PRIORITY_LOW 0x0040 +#define DPNSEND_PRIORITY_HIGH 0x0080 +// Flag added for DirectX 9 +#define DPNSEND_COALESCE 0x0100 + +// +// Send complete indication flags (added for DirectX 9) +// +#define DPNSENDCOMPLETE_GUARANTEED 0x0001 +#define DPNSENDCOMPLETE_COALESCED 0x0002 + +// +// Session Flags (for DPN_APPLICATION_DESC) +// +#define DPNSESSION_CLIENT_SERVER 0x0001 +#define DPNSESSION_MIGRATE_HOST 0x0004 +#define DPNSESSION_NODPNSVR 0x0040 +#define DPNSESSION_REQUIREPASSWORD 0x0080 +// Flag added for DirectX 9 +#define DPNSESSION_NOENUMS 0x0100 +#define DPNSESSION_FAST_SIGNED 0x0200 +#define DPNSESSION_FULL_SIGNED 0x0400 + +// +// Set client info flags (for SetClientInfo) +// +#define DPNSETCLIENTINFO_SYNC DPNOP_SYNC + +// +// Set group info flags (for SetGroupInfo) +// +#define DPNSETGROUPINFO_SYNC DPNOP_SYNC + +// +// Set peer info flags (for SetPeerInfo) +// +#define DPNSETPEERINFO_SYNC DPNOP_SYNC + +// +// Set server info flags (for SetServerInfo) +// +#define DPNSETSERVERINFO_SYNC DPNOP_SYNC + +// +// SP capabilities flags +// +#define DPNSPCAPS_SUPPORTSDPNSVR 0x0001 +#define DPNSPCAPS_SUPPORTSDPNSRV DPNSPCAPS_SUPPORTSDPNSVR +#define DPNSPCAPS_SUPPORTSBROADCAST 0x0002 +#define DPNSPCAPS_SUPPORTSALLADAPTERS 0x0004 +// Flags added for DirectX 9 +#define DPNSPCAPS_SUPPORTSTHREADPOOL 0x0008 +#define DPNSPCAPS_NETWORKSIMULATOR 0x0010 + +// +// SP information flags (added for DirectX 9) +// +#define DPNSPINFO_NETWORKSIMULATORDEVICE 0x0001 + +/**************************************************************************** + * + * DirectPlay8 Structures (Non-Message) + * + ****************************************************************************/ + +// +// Application description +// +typedef struct _DPN_APPLICATION_DESC +{ + DWORD dwSize; // Size of this structure + DWORD dwFlags; // Flags (DPNSESSION_...) + GUID guidInstance; // Instance GUID + GUID guidApplication; // Application GUID + DWORD dwMaxPlayers; // Maximum # of players allowed (0=no limit) + DWORD dwCurrentPlayers; // Current # of players allowed + WCHAR *pwszSessionName; // Name of the session + WCHAR *pwszPassword; // Password for the session + PVOID pvReservedData; + DWORD dwReservedDataSize; + PVOID pvApplicationReservedData; + DWORD dwApplicationReservedDataSize; +} DPN_APPLICATION_DESC, *PDPN_APPLICATION_DESC; + +// +// Generic Buffer Description +// +typedef struct _BUFFERDESC +{ + DWORD dwBufferSize; + BYTE * pBufferData; +} BUFFERDESC, DPN_BUFFER_DESC, *PDPN_BUFFER_DESC; + +typedef BUFFERDESC FAR * PBUFFERDESC; + +// +// DirectPlay8 capabilities +// +typedef struct _DPN_CAPS +{ + DWORD dwSize; // Size of this structure + DWORD dwFlags; // Flags + DWORD dwConnectTimeout; // ms before a connect request times out + DWORD dwConnectRetries; // # of times to attempt the connection + DWORD dwTimeoutUntilKeepAlive; // ms of inactivity before a keep alive is sent +} DPN_CAPS, *PDPN_CAPS; + +// +// Extended capabilities structures (added for DirectX 9) +// +typedef struct _DPN_CAPS_EX +{ + DWORD dwSize; // Size of this structure + DWORD dwFlags; // Flags + DWORD dwConnectTimeout; // ms before a connect request times out + DWORD dwConnectRetries; // # of times to attempt the connection + DWORD dwTimeoutUntilKeepAlive; // ms of inactivity before a keep alive is sent + DWORD dwMaxRecvMsgSize; // maximum size in bytes of message that can be received + DWORD dwNumSendRetries; // maximum number of send retries before link is considered dead + DWORD dwMaxSendRetryInterval; // maximum period in msec between send retries + DWORD dwDropThresholdRate; // percentage of dropped packets before throttling + DWORD dwThrottleRate; // percentage amount to reduce send window when throttling + DWORD dwNumHardDisconnectSends; // number of hard disconnect frames to send when close immediate flag is specified + DWORD dwMaxHardDisconnectPeriod; // maximum period between hard disconnect sends +} DPN_CAPS_EX, *PDPN_CAPS_EX; + +// +// Connection Statistics information +// +typedef struct _DPN_CONNECTION_INFO +{ + DWORD dwSize; + DWORD dwRoundTripLatencyMS; + DWORD dwThroughputBPS; + DWORD dwPeakThroughputBPS; + + DWORD dwBytesSentGuaranteed; + DWORD dwPacketsSentGuaranteed; + DWORD dwBytesSentNonGuaranteed; + DWORD dwPacketsSentNonGuaranteed; + + DWORD dwBytesRetried; // Guaranteed only + DWORD dwPacketsRetried; // Guaranteed only + DWORD dwBytesDropped; // Non Guaranteed only + DWORD dwPacketsDropped; // Non Guaranteed only + + DWORD dwMessagesTransmittedHighPriority; + DWORD dwMessagesTimedOutHighPriority; + DWORD dwMessagesTransmittedNormalPriority; + DWORD dwMessagesTimedOutNormalPriority; + DWORD dwMessagesTransmittedLowPriority; + DWORD dwMessagesTimedOutLowPriority; + + DWORD dwBytesReceivedGuaranteed; + DWORD dwPacketsReceivedGuaranteed; + DWORD dwBytesReceivedNonGuaranteed; + DWORD dwPacketsReceivedNonGuaranteed; + DWORD dwMessagesReceived; + +} DPN_CONNECTION_INFO, *PDPN_CONNECTION_INFO; + + +// +// Group information structure +// +typedef struct _DPN_GROUP_INFO +{ + DWORD dwSize; // size of this structure + DWORD dwInfoFlags; // information contained + PWSTR pwszName; // Unicode Name + PVOID pvData; // data block + DWORD dwDataSize; // size in BYTES of data block + DWORD dwGroupFlags; // group flags (DPNGROUP_...) +} DPN_GROUP_INFO, *PDPN_GROUP_INFO; + +// +// Player information structure +// +typedef struct _DPN_PLAYER_INFO +{ + DWORD dwSize; // size of this structure + DWORD dwInfoFlags; // information contained + PWSTR pwszName; // Unicode Name + PVOID pvData; // data block + DWORD dwDataSize; // size in BYTES of data block + DWORD dwPlayerFlags; // player flags (DPNPLAYER_...) +} DPN_PLAYER_INFO, *PDPN_PLAYER_INFO; + +typedef struct _DPN_SECURITY_CREDENTIALS DPN_SECURITY_CREDENTIALS, *PDPN_SECURITY_CREDENTIALS; +typedef struct _DPN_SECURITY_DESC DPN_SECURITY_DESC, *PDPN_SECURITY_DESC; + +// +// Service provider & adapter enumeration structure +// +typedef struct _DPN_SERVICE_PROVIDER_INFO +{ + DWORD dwFlags; + GUID guid; // SP Guid + WCHAR *pwszName; // Friendly Name + PVOID pvReserved; + DWORD dwReserved; +} DPN_SERVICE_PROVIDER_INFO, *PDPN_SERVICE_PROVIDER_INFO; + +// +// Service provider caps structure +// +typedef struct _DPN_SP_CAPS +{ + DWORD dwSize; // Size of this structure + DWORD dwFlags; // Flags (DPNSPCAPS_...) + DWORD dwNumThreads; // # of worker threads to use + DWORD dwDefaultEnumCount; // default # of enum requests + DWORD dwDefaultEnumRetryInterval; // default ms between enum requests + DWORD dwDefaultEnumTimeout; // default enum timeout + DWORD dwMaxEnumPayloadSize; // maximum size in bytes for enum payload data + DWORD dwBuffersPerThread; // number of receive buffers per thread + DWORD dwSystemBufferSize; // amount of buffering to do in addition to posted receive buffers +} DPN_SP_CAPS, *PDPN_SP_CAPS; + + +/**************************************************************************** + * + * IDirectPlay8 message handler call back structures + * + ****************************************************************************/ + +// +// Add player to group structure for message handler +// (DPN_MSGID_ADD_PLAYER_TO_GROUP) +// +typedef struct _DPNMSG_ADD_PLAYER_TO_GROUP +{ + DWORD dwSize; // Size of this structure + DPNID dpnidGroup; // DPNID of group + PVOID pvGroupContext; // Group context value + DPNID dpnidPlayer; // DPNID of added player + PVOID pvPlayerContext; // Player context value +} DPNMSG_ADD_PLAYER_TO_GROUP, *PDPNMSG_ADD_PLAYER_TO_GROUP; + +// +// Async operation completion structure for message handler +// (DPN_MSGID_ASYNC_OP_COMPLETE) +// +typedef struct _DPNMSG_ASYNC_OP_COMPLETE +{ + DWORD dwSize; // Size of this structure + DPNHANDLE hAsyncOp; // DirectPlay8 async operation handle + PVOID pvUserContext; // User context supplied + HRESULT hResultCode; // HRESULT of operation +} DPNMSG_ASYNC_OP_COMPLETE, *PDPNMSG_ASYNC_OP_COMPLETE; + +// +// Client info structure for message handler +// (DPN_MSGID_CLIENT_INFO) +// +typedef struct _DPNMSG_CLIENT_INFO +{ + DWORD dwSize; // Size of this structure + DPNID dpnidClient; // DPNID of client + PVOID pvPlayerContext; // Player context value +} DPNMSG_CLIENT_INFO, *PDPNMSG_CLIENT_INFO; + +// +// Connect complete structure for message handler +// (DPN_MSGID_CONNECT_COMPLETE) +// +typedef struct _DPNMSG_CONNECT_COMPLETE +{ + DWORD dwSize; // Size of this structure + DPNHANDLE hAsyncOp; // DirectPlay8 Async operation handle + PVOID pvUserContext; // User context supplied at Connect + HRESULT hResultCode; // HRESULT of connection attempt + PVOID pvApplicationReplyData; // Connection reply data from Host/Server + DWORD dwApplicationReplyDataSize; // Size (in bytes) of pvApplicationReplyData + + // Fields added for DirectX 9 + DPNID dpnidLocal; // DPNID of local player +} DPNMSG_CONNECT_COMPLETE, *PDPNMSG_CONNECT_COMPLETE; + +// +// Create group structure for message handler +// (DPN_MSGID_CREATE_GROUP) +// +typedef struct _DPNMSG_CREATE_GROUP +{ + DWORD dwSize; // Size of this structure + DPNID dpnidGroup; // DPNID of new group + DPNID dpnidOwner; // Owner of newgroup + PVOID pvGroupContext; // Group context value + + // Fields added for DirectX 9 + PVOID pvOwnerContext; // Owner context value +} DPNMSG_CREATE_GROUP, *PDPNMSG_CREATE_GROUP; + +// +// Create player structure for message handler +// (DPN_MSGID_CREATE_PLAYER) +// +typedef struct _DPNMSG_CREATE_PLAYER +{ + DWORD dwSize; // Size of this structure + DPNID dpnidPlayer; // DPNID of new player + PVOID pvPlayerContext; // Player context value +} DPNMSG_CREATE_PLAYER, *PDPNMSG_CREATE_PLAYER; + +// +// Destroy group structure for message handler +// (DPN_MSGID_DESTROY_GROUP) +// +typedef struct _DPNMSG_DESTROY_GROUP +{ + DWORD dwSize; // Size of this structure + DPNID dpnidGroup; // DPNID of destroyed group + PVOID pvGroupContext; // Group context value + DWORD dwReason; // Information only +} DPNMSG_DESTROY_GROUP, *PDPNMSG_DESTROY_GROUP; + +// +// Destroy player structure for message handler +// (DPN_MSGID_DESTROY_PLAYER) +// +typedef struct _DPNMSG_DESTROY_PLAYER +{ + DWORD dwSize; // Size of this structure + DPNID dpnidPlayer; // DPNID of leaving player + PVOID pvPlayerContext; // Player context value + DWORD dwReason; // Information only +} DPNMSG_DESTROY_PLAYER, *PDPNMSG_DESTROY_PLAYER; + +// +// Enumeration request received structure for message handler +// (DPN_MSGID_ENUM_HOSTS_QUERY) +// +typedef struct _DPNMSG_ENUM_HOSTS_QUERY +{ + DWORD dwSize; // Size of this structure. + IDirectPlay8Address *pAddressSender; // Address of client who sent the request + IDirectPlay8Address *pAddressDevice; // Address of device request was received on + PVOID pvReceivedData; // Request data (set on client) + DWORD dwReceivedDataSize; // Request data size (set on client) + DWORD dwMaxResponseDataSize; // Max allowable size of enum response + PVOID pvResponseData; // Optional query repsonse (user set) + DWORD dwResponseDataSize; // Optional query response size (user set) + PVOID pvResponseContext; // Optional query response context (user set) +} DPNMSG_ENUM_HOSTS_QUERY, *PDPNMSG_ENUM_HOSTS_QUERY; + +// +// Enumeration response received structure for message handler +// (DPN_MSGID_ENUM_HOSTS_RESPONSE) +// +typedef struct _DPNMSG_ENUM_HOSTS_RESPONSE +{ + DWORD dwSize; // Size of this structure + IDirectPlay8Address *pAddressSender; // Address of host who responded + IDirectPlay8Address *pAddressDevice; // Device response was received on + const DPN_APPLICATION_DESC *pApplicationDescription; // Application description for the session + PVOID pvResponseData; // Optional response data (set on host) + DWORD dwResponseDataSize; // Optional response data size (set on host) + PVOID pvUserContext; // Context value supplied for enumeration + DWORD dwRoundTripLatencyMS; // Round trip latency in MS +} DPNMSG_ENUM_HOSTS_RESPONSE, *PDPNMSG_ENUM_HOSTS_RESPONSE; + +// +// Group info structure for message handler +// (DPN_MSGID_GROUP_INFO) +// +typedef struct _DPNMSG_GROUP_INFO +{ + DWORD dwSize; // Size of this structure + DPNID dpnidGroup; // DPNID of group + PVOID pvGroupContext; // Group context value +} DPNMSG_GROUP_INFO, *PDPNMSG_GROUP_INFO; + +// +// Migrate host structure for message handler +// (DPN_MSGID_HOST_MIGRATE) +// +typedef struct _DPNMSG_HOST_MIGRATE +{ + DWORD dwSize; // Size of this structure + DPNID dpnidNewHost; // DPNID of new Host player + PVOID pvPlayerContext; // Player context value +} DPNMSG_HOST_MIGRATE, *PDPNMSG_HOST_MIGRATE; + +// +// Indicate connect structure for message handler +// (DPN_MSGID_INDICATE_CONNECT) +// +typedef struct _DPNMSG_INDICATE_CONNECT +{ + DWORD dwSize; // Size of this structure + PVOID pvUserConnectData; // Connecting player data + DWORD dwUserConnectDataSize; // Size (in bytes) of pvUserConnectData + PVOID pvReplyData; // Connection reply data + DWORD dwReplyDataSize; // Size (in bytes) of pvReplyData + PVOID pvReplyContext; // Buffer context for pvReplyData + PVOID pvPlayerContext; // Player context preset + IDirectPlay8Address *pAddressPlayer; // Address of connecting player + IDirectPlay8Address *pAddressDevice; // Address of device receiving connect attempt +} DPNMSG_INDICATE_CONNECT, *PDPNMSG_INDICATE_CONNECT; + +// +// Indicated connect aborted structure for message handler +// (DPN_MSGID_INDICATED_CONNECT_ABORTED) +// +typedef struct _DPNMSG_INDICATED_CONNECT_ABORTED +{ + DWORD dwSize; // Size of this structure + PVOID pvPlayerContext; // Player context preset from DPNMSG_INDICATE_CONNECT +} DPNMSG_INDICATED_CONNECT_ABORTED, *PDPNMSG_INDICATED_CONNECT_ABORTED; + +// +// Peer info structure for message handler +// (DPN_MSGID_PEER_INFO) +// +typedef struct _DPNMSG_PEER_INFO +{ + DWORD dwSize; // Size of this structure + DPNID dpnidPeer; // DPNID of peer + PVOID pvPlayerContext; // Player context value +} DPNMSG_PEER_INFO, *PDPNMSG_PEER_INFO; + +// +// Receive structure for message handler +// (DPN_MSGID_RECEIVE) +// +typedef struct _DPNMSG_RECEIVE +{ + DWORD dwSize; // Size of this structure + DPNID dpnidSender; // DPNID of sending player + PVOID pvPlayerContext; // Player context value of sending player + PBYTE pReceiveData; // Received data + DWORD dwReceiveDataSize; // Size (in bytes) of pReceiveData + DPNHANDLE hBufferHandle; // Buffer handle for pReceiveData + + // Fields added for DirectX 9 + DWORD dwReceiveFlags; // Flags describing how message was received +} DPNMSG_RECEIVE, *PDPNMSG_RECEIVE; + +// +// Remove player from group structure for message handler +// (DPN_MSGID_REMOVE_PLAYER_FROM_GROUP) +// +typedef struct _DPNMSG_REMOVE_PLAYER_FROM_GROUP +{ + DWORD dwSize; // Size of this structure + DPNID dpnidGroup; // DPNID of group + PVOID pvGroupContext; // Group context value + DPNID dpnidPlayer; // DPNID of deleted player + PVOID pvPlayerContext; // Player context value +} DPNMSG_REMOVE_PLAYER_FROM_GROUP, *PDPNMSG_REMOVE_PLAYER_FROM_GROUP; + +// +// Returned buffer structure for message handler +// (DPN_MSGID_RETURN_BUFFER) +// +typedef struct _DPNMSG_RETURN_BUFFER +{ + DWORD dwSize; // Size of this structure + HRESULT hResultCode; // Return value of operation + PVOID pvBuffer; // Buffer being returned + PVOID pvUserContext; // Context associated with buffer +} DPNMSG_RETURN_BUFFER, *PDPNMSG_RETURN_BUFFER; + +// +// Send complete structure for message handler +// (DPN_MSGID_SEND_COMPLETE) +// +typedef struct _DPNMSG_SEND_COMPLETE +{ + DWORD dwSize; // Size of this structure + DPNHANDLE hAsyncOp; // DirectPlay8 Async operation handle + PVOID pvUserContext; // User context supplied at Send/SendTo + HRESULT hResultCode; // HRESULT of send + DWORD dwSendTime; // Send time in ms + + // Fields added for DirectX 9 + DWORD dwFirstFrameRTT; // RTT of the first frame in the message + DWORD dwFirstFrameRetryCount; // Retry count of the first frame + DWORD dwSendCompleteFlags; // Flags describing how message was sent + DPN_BUFFER_DESC *pBuffers; // Pointer to array of buffers sent, if DirectPlay did not make a copy + DWORD dwNumBuffers; // Number of buffers in previous array +} DPNMSG_SEND_COMPLETE, *PDPNMSG_SEND_COMPLETE; + +// +// Server info structure for message handler +// (DPN_MSGID_SERVER_INFO) +// +typedef struct _DPNMSG_SERVER_INFO +{ + DWORD dwSize; // Size of this structure + DPNID dpnidServer; // DPNID of server + PVOID pvPlayerContext; // Player context value +} DPNMSG_SERVER_INFO, *PDPNMSG_SERVER_INFO; + +// +// Terminated session structure for message handler +// (DPN_MSGID_TERMINATE_SESSION) +// +typedef struct _DPNMSG_TERMINATE_SESSION +{ + DWORD dwSize; // Size of this structure + HRESULT hResultCode; // Reason + PVOID pvTerminateData; // Data passed from Host/Server + DWORD dwTerminateDataSize;// Size (in bytes) of pvTerminateData +} DPNMSG_TERMINATE_SESSION, *PDPNMSG_TERMINATE_SESSION; + + +// +// Message structures added for DirectX 9 +// + +// +// Create thread info structure for message handler +// (DPN_MSGID_CREATE_THREAD) +// +typedef struct _DPNMSG_CREATE_THREAD +{ + DWORD dwSize; // Size of this structure + DWORD dwFlags; // Flags describing this thread + DWORD dwProcessorNum; // Index of processor to which thread is bound + PVOID pvUserContext; // Thread context value +} DPNMSG_CREATE_THREAD, *PDPNMSG_CREATE_THREAD; + +// +// Destroy thread info structure for message handler +// (DPN_MSGID_DESTROY_THREAD) +// +typedef struct _DPNMSG_DESTROY_THREAD +{ + DWORD dwSize; // Size of this structure + DWORD dwProcessorNum; // Index of processor to which thread was bound + PVOID pvUserContext; // Thread context value +} DPNMSG_DESTROY_THREAD, *PDPNMSG_DESTROY_THREAD; + + +// +// Query-to-resolve-NAT-address structure for message handler +// (DPN_MSGID_NAT_RESOLVER_QUERY) +// +typedef struct _DPNMSG_NAT_RESOLVER_QUERY +{ + DWORD dwSize; // Size of this structure. + IDirectPlay8Address *pAddressSender; // Address of client that sent the query + IDirectPlay8Address *pAddressDevice; // Address of device on which query was received + WCHAR *pwszUserString; // User specified string, or NULL if none +} DPNMSG_NAT_RESOLVER_QUERY, *PDPNMSG_NAT_RESOLVER_QUERY; + +/**************************************************************************** + * + * DirectPlay8 Functions + * + ****************************************************************************/ + + + +/* + * This function is no longer supported. It is recommended that CoCreateInstance be used to create + * DirectPlay8 objects. + * + * extern HRESULT WINAPI DirectPlay8Create( const CLSID * pcIID, void **ppvInterface, IUnknown *pUnknown ); + * + */ + + +/**************************************************************************** + * + * DirectPlay8 Application Interfaces + * + ****************************************************************************/ + +// +// COM definition for DirectPlay8 Client interface +// +#undef INTERFACE // External COM Implementation +#define INTERFACE IDirectPlay8Client +DECLARE_INTERFACE_(IDirectPlay8Client,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ DP8REFIID riid, LPVOID *ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectPlay8Client methods ***/ + STDMETHOD(Initialize) (THIS_ PVOID const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags) PURE; + STDMETHOD(EnumServiceProviders) (THIS_ const GUID *const pguidServiceProvider, const GUID *const pguidApplication, DPN_SERVICE_PROVIDER_INFO *const pSPInfoBuffer, PDWORD const pcbEnumData, PDWORD const pcReturned, const DWORD dwFlags) PURE; + STDMETHOD(EnumHosts) (THIS_ PDPN_APPLICATION_DESC const pApplicationDesc,IDirectPlay8Address *const pAddrHost,IDirectPlay8Address *const pDeviceInfo,PVOID const pUserEnumData,const DWORD dwUserEnumDataSize,const DWORD dwEnumCount,const DWORD dwRetryInterval,const DWORD dwTimeOut,PVOID const pvUserContext,DPNHANDLE *const pAsyncHandle,const DWORD dwFlags) PURE; + STDMETHOD(CancelAsyncOperation) (THIS_ const DPNHANDLE hAsyncHandle, const DWORD dwFlags) PURE; + STDMETHOD(Connect) (THIS_ const DPN_APPLICATION_DESC *const pdnAppDesc,IDirectPlay8Address *const pHostAddr,IDirectPlay8Address *const pDeviceInfo,const DPN_SECURITY_DESC *const pdnSecurity,const DPN_SECURITY_CREDENTIALS *const pdnCredentials,const void *const pvUserConnectData,const DWORD dwUserConnectDataSize,void *const pvAsyncContext,DPNHANDLE *const phAsyncHandle,const DWORD dwFlags) PURE; + STDMETHOD(Send) (THIS_ const DPN_BUFFER_DESC *const prgBufferDesc,const DWORD cBufferDesc,const DWORD dwTimeOut,void *const pvAsyncContext,DPNHANDLE *const phAsyncHandle,const DWORD dwFlags) PURE; + STDMETHOD(GetSendQueueInfo) (THIS_ DWORD *const pdwNumMsgs, DWORD *const pdwNumBytes, const DWORD dwFlags) PURE; + STDMETHOD(GetApplicationDesc) (THIS_ DPN_APPLICATION_DESC *const pAppDescBuffer, DWORD *const pcbDataSize, const DWORD dwFlags) PURE; + STDMETHOD(SetClientInfo) (THIS_ const DPN_PLAYER_INFO *const pdpnPlayerInfo,PVOID const pvAsyncContext,DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; + STDMETHOD(GetServerInfo) (THIS_ DPN_PLAYER_INFO *const pdpnPlayerInfo,DWORD *const pdwSize,const DWORD dwFlags) PURE; + STDMETHOD(GetServerAddress) (THIS_ IDirectPlay8Address **const pAddress,const DWORD dwFlags) PURE; + STDMETHOD(Close) (THIS_ const DWORD dwFlags) PURE; + STDMETHOD(ReturnBuffer) (THIS_ const DPNHANDLE hBufferHandle,const DWORD dwFlags) PURE; + STDMETHOD(GetCaps) (THIS_ DPN_CAPS *const pdpCaps,const DWORD dwFlags) PURE; + STDMETHOD(SetCaps) (THIS_ const DPN_CAPS *const pdpCaps, const DWORD dwFlags) PURE; + STDMETHOD(SetSPCaps) (THIS_ const GUID * const pguidSP, const DPN_SP_CAPS *const pdpspCaps, const DWORD dwFlags ) PURE; + STDMETHOD(GetSPCaps) (THIS_ const GUID * const pguidSP,DPN_SP_CAPS *const pdpspCaps,const DWORD dwFlags) PURE; + STDMETHOD(GetConnectionInfo) (THIS_ DPN_CONNECTION_INFO *const pdpConnectionInfo,const DWORD dwFlags) PURE; + STDMETHOD(RegisterLobby) (THIS_ const DPNHANDLE dpnHandle, struct IDirectPlay8LobbiedApplication *const pIDP8LobbiedApplication,const DWORD dwFlags) PURE; +}; + +// +// COM definition for DirectPlay8 Server interface +// +#undef INTERFACE // External COM Implementation +#define INTERFACE IDirectPlay8Server +DECLARE_INTERFACE_(IDirectPlay8Server,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ DP8REFIID riid, LPVOID *ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectPlay8Server methods ***/ + STDMETHOD(Initialize) (THIS_ PVOID const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags) PURE; + STDMETHOD(EnumServiceProviders) (THIS_ const GUID *const pguidServiceProvider,const GUID *const pguidApplication,DPN_SERVICE_PROVIDER_INFO *const pSPInfoBuffer,PDWORD const pcbEnumData,PDWORD const pcReturned,const DWORD dwFlags) PURE; + STDMETHOD(CancelAsyncOperation) (THIS_ const DPNHANDLE hAsyncHandle,const DWORD dwFlags) PURE; + STDMETHOD(GetSendQueueInfo) (THIS_ const DPNID dpnid,DWORD *const pdwNumMsgs, DWORD *const pdwNumBytes, const DWORD dwFlags) PURE; + STDMETHOD(GetApplicationDesc) (THIS_ DPN_APPLICATION_DESC *const pAppDescBuffer, DWORD *const pcbDataSize, const DWORD dwFlags) PURE; + STDMETHOD(SetServerInfo) (THIS_ const DPN_PLAYER_INFO *const pdpnPlayerInfo,PVOID const pvAsyncContext, DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; + STDMETHOD(GetClientInfo) (THIS_ const DPNID dpnid,DPN_PLAYER_INFO *const pdpnPlayerInfo,DWORD *const pdwSize,const DWORD dwFlags) PURE; + STDMETHOD(GetClientAddress) (THIS_ const DPNID dpnid,IDirectPlay8Address **const pAddress,const DWORD dwFlags) PURE; + STDMETHOD(GetLocalHostAddresses) (THIS_ IDirectPlay8Address **const prgpAddress,DWORD *const pcAddress,const DWORD dwFlags) PURE; + STDMETHOD(SetApplicationDesc) (THIS_ const DPN_APPLICATION_DESC *const pad, const DWORD dwFlags) PURE; + STDMETHOD(Host) (THIS_ const DPN_APPLICATION_DESC *const pdnAppDesc,IDirectPlay8Address **const prgpDeviceInfo,const DWORD cDeviceInfo,const DPN_SECURITY_DESC *const pdnSecurity,const DPN_SECURITY_CREDENTIALS *const pdnCredentials,void *const pvPlayerContext,const DWORD dwFlags) PURE; + STDMETHOD(SendTo) (THIS_ const DPNID dpnid,const DPN_BUFFER_DESC *const prgBufferDesc,const DWORD cBufferDesc,const DWORD dwTimeOut,void *const pvAsyncContext,DPNHANDLE *const phAsyncHandle,const DWORD dwFlags) PURE; + STDMETHOD(CreateGroup) (THIS_ const DPN_GROUP_INFO *const pdpnGroupInfo,void *const pvGroupContext,void *const pvAsyncContext,DPNHANDLE *const phAsyncHandle,const DWORD dwFlags) PURE; + STDMETHOD(DestroyGroup) (THIS_ const DPNID idGroup, PVOID const pvAsyncContext, DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; + STDMETHOD(AddPlayerToGroup) (THIS_ const DPNID idGroup, const DPNID idClient, PVOID const pvAsyncContext, DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; + STDMETHOD(RemovePlayerFromGroup) (THIS_ const DPNID idGroup, const DPNID idClient, PVOID const pvAsyncContext, DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; + STDMETHOD(SetGroupInfo) (THIS_ const DPNID dpnid,DPN_GROUP_INFO *const pdpnGroupInfo,PVOID const pvAsyncContext,DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; + STDMETHOD(GetGroupInfo) (THIS_ const DPNID dpnid,DPN_GROUP_INFO *const pdpnGroupInfo,DWORD *const pdwSize,const DWORD dwFlags) PURE; + STDMETHOD(EnumPlayersAndGroups) (THIS_ DPNID *const prgdpnid, DWORD *const pcdpnid, const DWORD dwFlags) PURE; + STDMETHOD(EnumGroupMembers) (THIS_ const DPNID dpnid, DPNID *const prgdpnid, DWORD *const pcdpnid, const DWORD dwFlags) PURE; + STDMETHOD(Close) (THIS_ const DWORD dwFlags) PURE; + STDMETHOD(DestroyClient) (THIS_ const DPNID dpnidClient, const void *const pvDestroyData, const DWORD dwDestroyDataSize, const DWORD dwFlags) PURE; + STDMETHOD(ReturnBuffer) (THIS_ const DPNHANDLE hBufferHandle,const DWORD dwFlags) PURE; + STDMETHOD(GetPlayerContext) (THIS_ const DPNID dpnid,PVOID *const ppvPlayerContext,const DWORD dwFlags) PURE; + STDMETHOD(GetGroupContext) (THIS_ const DPNID dpnid,PVOID *const ppvGroupContext,const DWORD dwFlags) PURE; + STDMETHOD(GetCaps) (THIS_ DPN_CAPS *const pdpCaps,const DWORD dwFlags) PURE; + STDMETHOD(SetCaps) (THIS_ const DPN_CAPS *const pdpCaps, const DWORD dwFlags) PURE; + STDMETHOD(SetSPCaps) (THIS_ const GUID * const pguidSP, const DPN_SP_CAPS *const pdpspCaps, const DWORD dwFlags ) PURE; + STDMETHOD(GetSPCaps) (THIS_ const GUID * const pguidSP, DPN_SP_CAPS *const pdpspCaps,const DWORD dwFlags) PURE; + STDMETHOD(GetConnectionInfo) (THIS_ const DPNID dpnid, DPN_CONNECTION_INFO *const pdpConnectionInfo,const DWORD dwFlags) PURE; + STDMETHOD(RegisterLobby) (THIS_ const DPNHANDLE dpnHandle, struct IDirectPlay8LobbiedApplication *const pIDP8LobbiedApplication,const DWORD dwFlags) PURE; +}; + +// +// COM definition for DirectPlay8 Peer interface +// +#undef INTERFACE // External COM Implementation +#define INTERFACE IDirectPlay8Peer +DECLARE_INTERFACE_(IDirectPlay8Peer,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ DP8REFIID riid, LPVOID *ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectPlay8Peer methods ***/ + STDMETHOD(Initialize) (THIS_ PVOID const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags) PURE; + STDMETHOD(EnumServiceProviders) (THIS_ const GUID *const pguidServiceProvider, const GUID *const pguidApplication, DPN_SERVICE_PROVIDER_INFO *const pSPInfoBuffer, DWORD *const pcbEnumData, DWORD *const pcReturned, const DWORD dwFlags) PURE; + STDMETHOD(CancelAsyncOperation) (THIS_ const DPNHANDLE hAsyncHandle, const DWORD dwFlags) PURE; + STDMETHOD(Connect) (THIS_ const DPN_APPLICATION_DESC *const pdnAppDesc,IDirectPlay8Address *const pHostAddr,IDirectPlay8Address *const pDeviceInfo,const DPN_SECURITY_DESC *const pdnSecurity,const DPN_SECURITY_CREDENTIALS *const pdnCredentials,const void *const pvUserConnectData,const DWORD dwUserConnectDataSize,void *const pvPlayerContext,void *const pvAsyncContext,DPNHANDLE *const phAsyncHandle,const DWORD dwFlags) PURE; + STDMETHOD(SendTo) (THIS_ const DPNID dpnid,const DPN_BUFFER_DESC *const prgBufferDesc,const DWORD cBufferDesc,const DWORD dwTimeOut,void *const pvAsyncContext,DPNHANDLE *const phAsyncHandle,const DWORD dwFlags) PURE; + STDMETHOD(GetSendQueueInfo) (THIS_ const DPNID dpnid, DWORD *const pdwNumMsgs, DWORD *const pdwNumBytes, const DWORD dwFlags) PURE; + STDMETHOD(Host) (THIS_ const DPN_APPLICATION_DESC *const pdnAppDesc,IDirectPlay8Address **const prgpDeviceInfo,const DWORD cDeviceInfo,const DPN_SECURITY_DESC *const pdnSecurity,const DPN_SECURITY_CREDENTIALS *const pdnCredentials,void *const pvPlayerContext,const DWORD dwFlags) PURE; + STDMETHOD(GetApplicationDesc) (THIS_ DPN_APPLICATION_DESC *const pAppDescBuffer, DWORD *const pcbDataSize, const DWORD dwFlags) PURE; + STDMETHOD(SetApplicationDesc) (THIS_ const DPN_APPLICATION_DESC *const pad, const DWORD dwFlags) PURE; + STDMETHOD(CreateGroup) (THIS_ const DPN_GROUP_INFO *const pdpnGroupInfo,void *const pvGroupContext,void *const pvAsyncContext,DPNHANDLE *const phAsyncHandle,const DWORD dwFlags) PURE; + STDMETHOD(DestroyGroup) (THIS_ const DPNID idGroup, PVOID const pvAsyncContext, DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; + STDMETHOD(AddPlayerToGroup) (THIS_ const DPNID idGroup, const DPNID idClient, PVOID const pvAsyncContext, DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; + STDMETHOD(RemovePlayerFromGroup) (THIS_ const DPNID idGroup, const DPNID idClient, PVOID const pvAsyncContext, DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; + STDMETHOD(SetGroupInfo) (THIS_ const DPNID dpnid,DPN_GROUP_INFO *const pdpnGroupInfo,PVOID const pvAsyncContext,DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; + STDMETHOD(GetGroupInfo) (THIS_ const DPNID dpnid,DPN_GROUP_INFO *const pdpnGroupInfo,DWORD *const pdwSize,const DWORD dwFlags) PURE; + STDMETHOD(EnumPlayersAndGroups) (THIS_ DPNID *const prgdpnid, DWORD *const pcdpnid, const DWORD dwFlags) PURE; + STDMETHOD(EnumGroupMembers) (THIS_ const DPNID dpnid, DPNID *const prgdpnid, DWORD *const pcdpnid, const DWORD dwFlags) PURE; + STDMETHOD(SetPeerInfo) (THIS_ const DPN_PLAYER_INFO *const pdpnPlayerInfo,PVOID const pvAsyncContext,DPNHANDLE *const phAsyncHandle, const DWORD dwFlags) PURE; + STDMETHOD(GetPeerInfo) (THIS_ const DPNID dpnid,DPN_PLAYER_INFO *const pdpnPlayerInfo,DWORD *const pdwSize,const DWORD dwFlags) PURE; + STDMETHOD(GetPeerAddress) (THIS_ const DPNID dpnid,IDirectPlay8Address **const ppAddress,const DWORD dwFlags) PURE; + STDMETHOD(GetLocalHostAddresses) (THIS_ IDirectPlay8Address **const prgpAddress,DWORD *const pcAddress,const DWORD dwFlags) PURE; + STDMETHOD(Close) (THIS_ const DWORD dwFlags) PURE; + STDMETHOD(EnumHosts) (THIS_ PDPN_APPLICATION_DESC const pApplicationDesc,IDirectPlay8Address *const pAddrHost,IDirectPlay8Address *const pDeviceInfo,PVOID const pUserEnumData,const DWORD dwUserEnumDataSize,const DWORD dwEnumCount,const DWORD dwRetryInterval,const DWORD dwTimeOut,PVOID const pvUserContext,DPNHANDLE *const pAsyncHandle,const DWORD dwFlags) PURE; + STDMETHOD(DestroyPeer) (THIS_ const DPNID dpnidClient, const void *const pvDestroyData, const DWORD dwDestroyDataSize, const DWORD dwFlags) PURE; + STDMETHOD(ReturnBuffer) (THIS_ const DPNHANDLE hBufferHandle,const DWORD dwFlags) PURE; + STDMETHOD(GetPlayerContext) (THIS_ const DPNID dpnid,PVOID *const ppvPlayerContext,const DWORD dwFlags) PURE; + STDMETHOD(GetGroupContext) (THIS_ const DPNID dpnid,PVOID *const ppvGroupContext,const DWORD dwFlags) PURE; + STDMETHOD(GetCaps) (THIS_ DPN_CAPS *const pdpCaps,const DWORD dwFlags) PURE; + STDMETHOD(SetCaps) (THIS_ const DPN_CAPS *const pdpCaps, const DWORD dwFlags) PURE; + STDMETHOD(SetSPCaps) (THIS_ const GUID * const pguidSP, const DPN_SP_CAPS *const pdpspCaps, const DWORD dwFlags ) PURE; + STDMETHOD(GetSPCaps) (THIS_ const GUID * const pguidSP, DPN_SP_CAPS *const pdpspCaps,const DWORD dwFlags) PURE; + STDMETHOD(GetConnectionInfo) (THIS_ const DPNID dpnid, DPN_CONNECTION_INFO *const pdpConnectionInfo,const DWORD dwFlags) PURE; + STDMETHOD(RegisterLobby) (THIS_ const DPNHANDLE dpnHandle, struct IDirectPlay8LobbiedApplication *const pIDP8LobbiedApplication,const DWORD dwFlags) PURE; + STDMETHOD(TerminateSession) (THIS_ void *const pvTerminateData,const DWORD dwTerminateDataSize,const DWORD dwFlags) PURE; +}; + + + +// +// COM definition for DirectPlay8 Thread Pool interface +// +#undef INTERFACE // External COM Implementation +#define INTERFACE IDirectPlay8ThreadPool +DECLARE_INTERFACE_(IDirectPlay8ThreadPool,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ DP8REFIID riid, LPVOID *ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectPlay8ThreadPool methods ***/ + STDMETHOD(Initialize) (THIS_ PVOID const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags) PURE; + STDMETHOD(Close) (THIS_ const DWORD dwFlags) PURE; + STDMETHOD(GetThreadCount) (THIS_ const DWORD dwProcessorNum, DWORD *const pdwNumThreads, const DWORD dwFlags) PURE; + STDMETHOD(SetThreadCount) (THIS_ const DWORD dwProcessorNum, const DWORD dwNumThreads, const DWORD dwFlags) PURE; + STDMETHOD(DoWork) (THIS_ const DWORD dwAllowedTimeSlice, const DWORD dwFlags) PURE; +}; + + +// +// COM definition for DirectPlay8 NAT Resolver interface +// +#undef INTERFACE // External COM Implementation +#define INTERFACE IDirectPlay8NATResolver +DECLARE_INTERFACE_(IDirectPlay8NATResolver,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ DP8REFIID riid, LPVOID *ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectPlay8NATResolver methods ***/ + STDMETHOD(Initialize) (THIS_ PVOID const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags) PURE; + STDMETHOD(Start) (THIS_ IDirectPlay8Address **const ppDevices, const DWORD dwNumDevices, const DWORD dwFlags) PURE; + STDMETHOD(Close) (THIS_ const DWORD dwFlags) PURE; + STDMETHOD(EnumDevices) (THIS_ DPN_SERVICE_PROVIDER_INFO *const pSPInfoBuffer, PDWORD const pdwBufferSize, PDWORD const pdwNumDevices, const DWORD dwFlags) PURE; + STDMETHOD(GetAddresses) (THIS_ IDirectPlay8Address **const ppAddresses, DWORD *const pdwNumAddresses, const DWORD dwFlags) PURE; +}; + + +/**************************************************************************** + * + * IDirectPlay8 application interface macros + * + ****************************************************************************/ + +#if !defined(__cplusplus) || defined(CINTERFACE) + +#define IDirectPlay8Client_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlay8Client_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlay8Client_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlay8Client_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectPlay8Client_EnumServiceProviders(p,a,b,c,d,e,f) (p)->lpVtbl->EnumServiceProviders(p,a,b,c,d,e,f) +#define IDirectPlay8Client_EnumHosts(p,a,b,c,d,e,f,g,h,i,j,k) (p)->lpVtbl->EnumHosts(p,a,b,c,d,e,f,g,h,i,j,k) +#define IDirectPlay8Client_CancelAsyncOperation(p,a,b) (p)->lpVtbl->CancelAsyncOperation(p,a,b) +#define IDirectPlay8Client_Connect(p,a,b,c,d,e,f,g,h,i,j) (p)->lpVtbl->Connect(p,a,b,c,d,e,f,g,h,i,j) +#define IDirectPlay8Client_Send(p,a,b,c,d,e,f) (p)->lpVtbl->Send(p,a,b,c,d,e,f) +#define IDirectPlay8Client_GetSendQueueInfo(p,a,b,c) (p)->lpVtbl->GetSendQueueInfo(p,a,b,c) +#define IDirectPlay8Client_GetApplicationDesc(p,a,b,c) (p)->lpVtbl->GetApplicationDesc(p,a,b,c) +#define IDirectPlay8Client_SetClientInfo(p,a,b,c,d) (p)->lpVtbl->SetClientInfo(p,a,b,c,d) +#define IDirectPlay8Client_GetServerInfo(p,a,b,c) (p)->lpVtbl->GetServerInfo(p,a,b,c) +#define IDirectPlay8Client_GetServerAddress(p,a,b) (p)->lpVtbl->GetServerAddress(p,a,b) +#define IDirectPlay8Client_Close(p,a) (p)->lpVtbl->Close(p,a) +#define IDirectPlay8Client_ReturnBuffer(p,a,b) (p)->lpVtbl->ReturnBuffer(p,a,b) +#define IDirectPlay8Client_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) +#define IDirectPlay8Client_SetCaps(p,a,b) (p)->lpVtbl->SetCaps(p,a,b) +#define IDirectPlay8Client_SetSPCaps(p,a,b,c) (p)->lpVtbl->SetSPCaps(p,a,b,c) +#define IDirectPlay8Client_GetSPCaps(p,a,b,c) (p)->lpVtbl->GetSPCaps(p,a,b,c) +#define IDirectPlay8Client_GetConnectionInfo(p,a,b) (p)->lpVtbl->GetConnectionInfo(p,a,b) +#define IDirectPlay8Client_RegisterLobby(p,a,b,c) (p)->lpVtbl->RegisterLobby(p,a,b,c) + +#define IDirectPlay8Server_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlay8Server_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlay8Server_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlay8Server_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectPlay8Server_EnumServiceProviders(p,a,b,c,d,e,f) (p)->lpVtbl->EnumServiceProviders(p,a,b,c,d,e,f) +#define IDirectPlay8Server_CancelAsyncOperation(p,a,b) (p)->lpVtbl->CancelAsyncOperation(p,a,b) +#define IDirectPlay8Server_GetSendQueueInfo(p,a,b,c,d) (p)->lpVtbl->GetSendQueueInfo(p,a,b,c,d) +#define IDirectPlay8Server_GetApplicationDesc(p,a,b,c) (p)->lpVtbl->GetApplicationDesc(p,a,b,c) +#define IDirectPlay8Server_SetServerInfo(p,a,b,c,d) (p)->lpVtbl->SetServerInfo(p,a,b,c,d) +#define IDirectPlay8Server_GetClientInfo(p,a,b,c,d) (p)->lpVtbl->GetClientInfo(p,a,b,c,d) +#define IDirectPlay8Server_GetClientAddress(p,a,b,c) (p)->lpVtbl->GetClientAddress(p,a,b,c) +#define IDirectPlay8Server_GetLocalHostAddresses(p,a,b,c) (p)->lpVtbl->GetLocalHostAddresses(p,a,b,c) +#define IDirectPlay8Server_SetApplicationDesc(p,a,b) (p)->lpVtbl->SetApplicationDesc(p,a,b) +#define IDirectPlay8Server_Host(p,a,b,c,d,e,f,g) (p)->lpVtbl->Host(p,a,b,c,d,e,f,g) +#define IDirectPlay8Server_SendTo(p,a,b,c,d,e,f,g) (p)->lpVtbl->SendTo(p,a,b,c,d,e,f,g) +#define IDirectPlay8Server_CreateGroup(p,a,b,c,d,e) (p)->lpVtbl->CreateGroup(p,a,b,c,d,e) +#define IDirectPlay8Server_DestroyGroup(p,a,b,c,d) (p)->lpVtbl->DestroyGroup(p,a,b,c,d) +#define IDirectPlay8Server_AddPlayerToGroup(p,a,b,c,d,e) (p)->lpVtbl->AddPlayerToGroup(p,a,b,c,d,e) +#define IDirectPlay8Server_RemovePlayerFromGroup(p,a,b,c,d,e) (p)->lpVtbl->RemovePlayerFromGroup(p,a,b,c,d,e) +#define IDirectPlay8Server_SetGroupInfo(p,a,b,c,d,e) (p)->lpVtbl->SetGroupInfo(p,a,b,c,d,e) +#define IDirectPlay8Server_GetGroupInfo(p,a,b,c,d) (p)->lpVtbl->GetGroupInfo(p,a,b,c,d) +#define IDirectPlay8Server_EnumPlayersAndGroups(p,a,b,c) (p)->lpVtbl->EnumPlayersAndGroups(p,a,b,c) +#define IDirectPlay8Server_EnumGroupMembers(p,a,b,c,d) (p)->lpVtbl->EnumGroupMembers(p,a,b,c,d) +#define IDirectPlay8Server_Close(p,a) (p)->lpVtbl->Close(p,a) +#define IDirectPlay8Server_DestroyClient(p,a,b,c,d) (p)->lpVtbl->DestroyClient(p,a,b,c,d) +#define IDirectPlay8Server_ReturnBuffer(p,a,b) (p)->lpVtbl->ReturnBuffer(p,a,b) +#define IDirectPlay8Server_GetPlayerContext(p,a,b,c) (p)->lpVtbl->GetPlayerContext(p,a,b,c) +#define IDirectPlay8Server_GetGroupContext(p,a,b,c) (p)->lpVtbl->GetGroupContext(p,a,b,c) +#define IDirectPlay8Server_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) +#define IDirectPlay8Server_SetCaps(p,a,b) (p)->lpVtbl->SetCaps(p,a,b) +#define IDirectPlay8Server_SetSPCaps(p,a,b,c) (p)->lpVtbl->SetSPCaps(p,a,b,c) +#define IDirectPlay8Server_GetSPCaps(p,a,b,c) (p)->lpVtbl->GetSPCaps(p,a,b,c) +#define IDirectPlay8Server_GetConnectionInfo(p,a,b,c) (p)->lpVtbl->GetConnectionInfo(p,a,b,c) +#define IDirectPlay8Server_RegisterLobby(p,a,b,c) (p)->lpVtbl->RegisterLobby(p,a,b,c) + +#define IDirectPlay8Peer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlay8Peer_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlay8Peer_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlay8Peer_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectPlay8Peer_EnumServiceProviders(p,a,b,c,d,e,f) (p)->lpVtbl->EnumServiceProviders(p,a,b,c,d,e,f) +#define IDirectPlay8Peer_CancelAsyncOperation(p,a,b) (p)->lpVtbl->CancelAsyncOperation(p,a,b) +#define IDirectPlay8Peer_Connect(p,a,b,c,d,e,f,g,h,i,j,k) (p)->lpVtbl->Connect(p,a,b,c,d,e,f,g,h,i,j,k) +#define IDirectPlay8Peer_SendTo(p,a,b,c,d,e,f,g) (p)->lpVtbl->SendTo(p,a,b,c,d,e,f,g) +#define IDirectPlay8Peer_GetSendQueueInfo(p,a,b,c,d) (p)->lpVtbl->GetSendQueueInfo(p,a,b,c,d) +#define IDirectPlay8Peer_Host(p,a,b,c,d,e,f,g) (p)->lpVtbl->Host(p,a,b,c,d,e,f,g) +#define IDirectPlay8Peer_GetApplicationDesc(p,a,b,c) (p)->lpVtbl->GetApplicationDesc(p,a,b,c) +#define IDirectPlay8Peer_SetApplicationDesc(p,a,b) (p)->lpVtbl->SetApplicationDesc(p,a,b) +#define IDirectPlay8Peer_CreateGroup(p,a,b,c,d,e) (p)->lpVtbl->CreateGroup(p,a,b,c,d,e) +#define IDirectPlay8Peer_DestroyGroup(p,a,b,c,d) (p)->lpVtbl->DestroyGroup(p,a,b,c,d) +#define IDirectPlay8Peer_AddPlayerToGroup(p,a,b,c,d,e) (p)->lpVtbl->AddPlayerToGroup(p,a,b,c,d,e) +#define IDirectPlay8Peer_RemovePlayerFromGroup(p,a,b,c,d,e) (p)->lpVtbl->RemovePlayerFromGroup(p,a,b,c,d,e) +#define IDirectPlay8Peer_SetGroupInfo(p,a,b,c,d,e) (p)->lpVtbl->SetGroupInfo(p,a,b,c,d,e) +#define IDirectPlay8Peer_GetGroupInfo(p,a,b,c,d) (p)->lpVtbl->GetGroupInfo(p,a,b,c,d) +#define IDirectPlay8Peer_EnumPlayersAndGroups(p,a,b,c) (p)->lpVtbl->EnumPlayersAndGroups(p,a,b,c) +#define IDirectPlay8Peer_EnumGroupMembers(p,a,b,c,d) (p)->lpVtbl->EnumGroupMembers(p,a,b,c,d) +#define IDirectPlay8Peer_SetPeerInfo(p,a,b,c,d) (p)->lpVtbl->SetPeerInfo(p,a,b,c,d) +#define IDirectPlay8Peer_GetPeerInfo(p,a,b,c,d) (p)->lpVtbl->GetPeerInfo(p,a,b,c,d) +#define IDirectPlay8Peer_GetPeerAddress(p,a,b,c) (p)->lpVtbl->GetPeerAddress(p,a,b,c) +#define IDirectPlay8Peer_GetLocalHostAddresses(p,a,b,c) (p)->lpVtbl->GetLocalHostAddresses(p,a,b,c) +#define IDirectPlay8Peer_Close(p,a) (p)->lpVtbl->Close(p,a) +#define IDirectPlay8Peer_EnumHosts(p,a,b,c,d,e,f,g,h,i,j,k) (p)->lpVtbl->EnumHosts(p,a,b,c,d,e,f,g,h,i,j,k) +#define IDirectPlay8Peer_DestroyPeer(p,a,b,c,d) (p)->lpVtbl->DestroyPeer(p,a,b,c,d) +#define IDirectPlay8Peer_ReturnBuffer(p,a,b) (p)->lpVtbl->ReturnBuffer(p,a,b) +#define IDirectPlay8Peer_GetPlayerContext(p,a,b,c) (p)->lpVtbl->GetPlayerContext(p,a,b,c) +#define IDirectPlay8Peer_GetGroupContext(p,a,b,c) (p)->lpVtbl->GetGroupContext(p,a,b,c) +#define IDirectPlay8Peer_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) +#define IDirectPlay8Peer_SetCaps(p,a,b) (p)->lpVtbl->SetCaps(p,a,b) +#define IDirectPlay8Peer_SetSPCaps(p,a,b,c) (p)->lpVtbl->SetSPCaps(p,a,b,c) +#define IDirectPlay8Peer_GetSPCaps(p,a,b,c) (p)->lpVtbl->GetSPCaps(p,a,b,c) +#define IDirectPlay8Peer_GetConnectionInfo(p,a,b,c) (p)->lpVtbl->GetConnectionInfo(p,a,b,c) +#define IDirectPlay8Peer_RegisterLobby(p,a,b,c) (p)->lpVtbl->RegisterLobby(p,a,b,c) +#define IDirectPlay8Peer_TerminateSession(p,a,b,c) (p)->lpVtbl->TerminateSession(p,a,b,c) + +#define IDirectPlay8ThreadPool_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlay8ThreadPool_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlay8ThreadPool_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlay8ThreadPool_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectPlay8ThreadPool_Close(p,a) (p)->lpVtbl->Close(p,a) +#define IDirectPlay8ThreadPool_GetThreadCount(p,a,b,c) (p)->lpVtbl->GetThreadCount(p,a,b,c) +#define IDirectPlay8ThreadPool_SetThreadCount(p,a,b,c) (p)->lpVtbl->SetThreadCount(p,a,b,c) +#define IDirectPlay8ThreadPool_DoWork(p,a,b) (p)->lpVtbl->DoWork(p,a,b) + +#define IDirectPlay8NATResolver_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlay8NATResolver_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlay8NATResolver_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlay8NATResolver_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectPlay8NATResolver_Start(p,a,b,c) (p)->lpVtbl->Start(p,a,b,c) +#define IDirectPlay8NATResolver_Close(p,a) (p)->lpVtbl->Close(p,a) +#define IDirectPlay8NATResolver_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) +#define IDirectPlay8NATResolver_GetAddresses(p,a,b,c) (p)->lpVtbl->GetAddresses(p,a,b,c) + +#else /* C++ */ + +#define IDirectPlay8Client_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlay8Client_AddRef(p) (p)->AddRef() +#define IDirectPlay8Client_Release(p) (p)->Release() +#define IDirectPlay8Client_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectPlay8Client_EnumServiceProviders(p,a,b,c,d,e,f) (p)->EnumServiceProviders(a,b,c,d,e,f) +#define IDirectPlay8Client_EnumHosts(p,a,b,c,d,e,f,g,h,i,j,k) (p)->EnumHosts(a,b,c,d,e,f,g,h,i,j,k) +#define IDirectPlay8Client_CancelAsyncOperation(p,a,b) (p)->CancelAsyncOperation(a,b) +#define IDirectPlay8Client_Connect(p,a,b,c,d,e,f,g,h,i,j) (p)->Connect(a,b,c,d,e,f,g,h,i,j) +#define IDirectPlay8Client_Send(p,a,b,c,d,e,f) (p)->Send(a,b,c,d,e,f) +#define IDirectPlay8Client_GetSendQueueInfo(p,a,b,c) (p)->GetSendQueueInfo(a,b,c) +#define IDirectPlay8Client_GetApplicationDesc(p,a,b,c) (p)->GetApplicationDesc(a,b,c) +#define IDirectPlay8Client_SetClientInfo(p,a,b,c,d) (p)->SetClientInfo(a,b,c,d) +#define IDirectPlay8Client_GetServerInfo(p,a,b,c) (p)->GetServerInfo(a,b,c) +#define IDirectPlay8Client_GetServerAddress(p,a,b) (p)->GetServerAddress(a,b) +#define IDirectPlay8Client_Close(p,a) (p)->Close(a) +#define IDirectPlay8Client_ReturnBuffer(p,a,b) (p)->ReturnBuffer(a,b) +#define IDirectPlay8Client_GetCaps(p,a,b) (p)->GetCaps(a,b) +#define IDirectPlay8Client_SetCaps(p,a,b) (p)->SetCaps(a,b) +#define IDirectPlay8Client_SetSPCaps(p,a,b,c) (p)->SetSPCaps(a,b,c) +#define IDirectPlay8Client_GetSPCaps(p,a,b,c) (p)->GetSPCaps(a,b,c) +#define IDirectPlay8Client_GetConnectionInfo(p,a,b) (p)->GetConnectionInfo(a,b) +#define IDirectPlay8Client_RegisterLobby(p,a,b,c) (p)->RegisterLobby(a,b,c) + +#define IDirectPlay8Server_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlay8Server_AddRef(p) (p)->AddRef() +#define IDirectPlay8Server_Release(p) (p)->Release() +#define IDirectPlay8Server_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectPlay8Server_EnumServiceProviders(p,a,b,c,d,e,f) (p)->EnumServiceProviders(a,b,c,d,e,f) +#define IDirectPlay8Server_CancelAsyncOperation(p,a,b) (p)->CancelAsyncOperation(a,b) +#define IDirectPlay8Server_GetSendQueueInfo(p,a,b,c,d) (p)->GetSendQueueInfo(a,b,c,d) +#define IDirectPlay8Server_GetApplicationDesc(p,a,b,c) (p)->GetApplicationDesc(a,b,c) +#define IDirectPlay8Server_SetServerInfo(p,a,b,c,d) (p)->SetServerInfo(a,b,c,d) +#define IDirectPlay8Server_GetClientInfo(p,a,b,c,d) (p)->GetClientInfo(a,b,c,d) +#define IDirectPlay8Server_GetClientAddress(p,a,b,c) (p)->GetClientAddress(a,b,c) +#define IDirectPlay8Server_GetLocalHostAddresses(p,a,b,c) (p)->GetLocalHostAddresses(a,b,c) +#define IDirectPlay8Server_SetApplicationDesc(p,a,b) (p)->SetApplicationDesc(a,b) +#define IDirectPlay8Server_Host(p,a,b,c,d,e,f,g) (p)->Host(a,b,c,d,e,f,g) +#define IDirectPlay8Server_SendTo(p,a,b,c,d,e,f,g) (p)->SendTo(a,b,c,d,e,f,g) +#define IDirectPlay8Server_CreateGroup(p,a,b,c,d,e) (p)->CreateGroup(a,b,c,d,e) +#define IDirectPlay8Server_DestroyGroup(p,a,b,c,d) (p)->DestroyGroup(a,b,c,d) +#define IDirectPlay8Server_AddPlayerToGroup(p,a,b,c,d,e) (p)->AddPlayerToGroup(a,b,c,d,e) +#define IDirectPlay8Server_RemovePlayerFromGroup(p,a,b,c,d,e) (p)->RemovePlayerFromGroup(a,b,c,d,e) +#define IDirectPlay8Server_SetGroupInfo(p,a,b,c,d,e) (p)->SetGroupInfo(a,b,c,d,e) +#define IDirectPlay8Server_GetGroupInfo(p,a,b,c,d) (p)->GetGroupInfo(a,b,c,d) +#define IDirectPlay8Server_EnumPlayersAndGroups(p,a,b,c) (p)->EnumPlayersAndGroups(a,b,c) +#define IDirectPlay8Server_EnumGroupMembers(p,a,b,c,d) (p)->EnumGroupMembers(a,b,c,d) +#define IDirectPlay8Server_Close(p,a) (p)->Close(a) +#define IDirectPlay8Server_DestroyClient(p,a,b,c,d) (p)->DestroyClient(a,b,c,d) +#define IDirectPlay8Server_ReturnBuffer(p,a,b) (p)->ReturnBuffer(a,b) +#define IDirectPlay8Server_GetPlayerContext(p,a,b,c) (p)->GetPlayerContext(a,b,c) +#define IDirectPlay8Server_GetGroupContext(p,a,b,c) (p)->GetGroupContext(a,b,c) +#define IDirectPlay8Server_GetCaps(p,a,b) (p)->GetCaps(a,b) +#define IDirectPlay8Server_SetCaps(p,a,b) (p)->SetCaps(a,b) +#define IDirectPlay8Server_SetSPCaps(p,a,b,c) (p)->SetSPCaps(a,b,c) +#define IDirectPlay8Server_GetSPCaps(p,a,b,c) (p)->GetSPCaps(a,b,c) +#define IDirectPlay8Server_GetConnectionInfo(p,a,b,c) (p)->GetConnectionInfo(a,b,c) +#define IDirectPlay8Server_RegisterLobby(p,a,b,c) (p)->RegisterLobby(a,b,c) + +#define IDirectPlay8Peer_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlay8Peer_AddRef(p) (p)->AddRef() +#define IDirectPlay8Peer_Release(p) (p)->Release() +#define IDirectPlay8Peer_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectPlay8Peer_EnumServiceProviders(p,a,b,c,d,e,f) (p)->EnumServiceProviders(a,b,c,d,e,f) +#define IDirectPlay8Peer_CancelAsyncOperation(p,a,b) (p)->CancelAsyncOperation(a,b) +#define IDirectPlay8Peer_Connect(p,a,b,c,d,e,f,g,h,i,j,k) (p)->Connect(a,b,c,d,e,f,g,h,i,j,k) +#define IDirectPlay8Peer_SendTo(p,a,b,c,d,e,f,g) (p)->SendTo(a,b,c,d,e,f,g) +#define IDirectPlay8Peer_GetSendQueueInfo(p,a,b,c,d) (p)->GetSendQueueInfo(a,b,c,d) +#define IDirectPlay8Peer_Host(p,a,b,c,d,e,f,g) (p)->Host(a,b,c,d,e,f,g) +#define IDirectPlay8Peer_GetApplicationDesc(p,a,b,c) (p)->GetApplicationDesc(a,b,c) +#define IDirectPlay8Peer_SetApplicationDesc(p,a,b) (p)->SetApplicationDesc(a,b) +#define IDirectPlay8Peer_CreateGroup(p,a,b,c,d,e) (p)->CreateGroup(a,b,c,d,e) +#define IDirectPlay8Peer_DestroyGroup(p,a,b,c,d) (p)->DestroyGroup(a,b,c,d) +#define IDirectPlay8Peer_AddPlayerToGroup(p,a,b,c,d,e) (p)->AddPlayerToGroup(a,b,c,d,e) +#define IDirectPlay8Peer_RemovePlayerFromGroup(p,a,b,c,d,e) (p)->RemovePlayerFromGroup(a,b,c,d,e) +#define IDirectPlay8Peer_SetGroupInfo(p,a,b,c,d,e) (p)->SetGroupInfo(a,b,c,d,e) +#define IDirectPlay8Peer_GetGroupInfo(p,a,b,c,d) (p)->GetGroupInfo(a,b,c,d) +#define IDirectPlay8Peer_EnumPlayersAndGroups(p,a,b,c) (p)->EnumPlayersAndGroups(a,b,c) +#define IDirectPlay8Peer_EnumGroupMembers(p,a,b,c,d) (p)->EnumGroupMembers(a,b,c,d) +#define IDirectPlay8Peer_SetPeerInfo(p,a,b,c,d) (p)->SetPeerInfo(a,b,c,d) +#define IDirectPlay8Peer_GetPeerInfo(p,a,b,c,d) (p)->GetPeerInfo(a,b,c,d) +#define IDirectPlay8Peer_GetPeerAddress(p,a,b,c) (p)->GetPeerAddress(a,b,c) +#define IDirectPlay8Peer_GetLocalHostAddresses(p,a,b,c) (p)->GetLocalHostAddresses(a,b,c) +#define IDirectPlay8Peer_Close(p,a) (p)->Close(a) +#define IDirectPlay8Peer_EnumHosts(p,a,b,c,d,e,f,g,h,i,j,k) (p)->EnumHosts(a,b,c,d,e,f,g,h,i,j,k) +#define IDirectPlay8Peer_DestroyPeer(p,a,b,c,d) (p)->DestroyPeer(a,b,c,d) +#define IDirectPlay8Peer_ReturnBuffer(p,a,b) (p)->ReturnBuffer(a,b) +#define IDirectPlay8Peer_GetPlayerContext(p,a,b,c) (p)->GetPlayerContext(a,b,c) +#define IDirectPlay8Peer_GetGroupContext(p,a,b,c) (p)->GetGroupContext(a,b,c) +#define IDirectPlay8Peer_GetCaps(p,a,b) (p)->GetCaps(a,b) +#define IDirectPlay8Peer_SetCaps(p,a,b) (p)->SetCaps(a,b) +#define IDirectPlay8Peer_SetSPCaps(p,a,b,c) (p)->SetSPCaps(a,b,c) +#define IDirectPlay8Peer_GetSPCaps(p,a,b,c) (p)->GetSPCaps(a,b,c) +#define IDirectPlay8Peer_GetConnectionInfo(p,a,b,c) (p)->GetConnectionInfo(a,b,c) +#define IDirectPlay8Peer_RegisterLobby(p,a,b,c) (p)->RegisterLobby(a,b,c) +#define IDirectPlay8Peer_TerminateSession(p,a,b,c) (p)->TerminateSession(a,b,c) + +#define IDirectPlay8ThreadPool_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlay8ThreadPool_AddRef(p) (p)->AddRef() +#define IDirectPlay8ThreadPool_Release(p) (p)->Release() +#define IDirectPlay8ThreadPool_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectPlay8ThreadPool_Close(p,a) (p)->Close(a) +#define IDirectPlay8ThreadPool_GetThreadCount(p,a,b,c) (p)->GetThreadCount(a,b,c) +#define IDirectPlay8ThreadPool_SetThreadCount(p,a,b,c) (p)->SetThreadCount(a,b,c) +#define IDirectPlay8ThreadPool_DoWork(p,a,b) (p)->DoWork(a,b) + +#define IDirectPlay8NATResolver_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlay8NATResolver_AddRef(p) (p)->AddRef() +#define IDirectPlay8NATResolver_Release(p) (p)->Release() +#define IDirectPlay8NATResolver_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectPlay8NATResolver_Start(p,a,b,c) (p)->Start(a,b,c) +#define IDirectPlay8NATResolver_Close(p,a) (p)->Close(a) +#define IDirectPlay8NATResolver_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) +#define IDirectPlay8NATResolver_GetAddresses(p,a,b,c) (p)->GetAddresses(a,b,c) + +#endif + + + +/**************************************************************************** + * + * DIRECTPLAY8 ERRORS + * + * Errors are represented by negative values and cannot be combined. + * + ****************************************************************************/ + +#define _DPN_FACILITY_CODE 0x015 +#define _DPNHRESULT_BASE 0x8000 +#define MAKE_DPNHRESULT( code ) MAKE_HRESULT( 1, _DPN_FACILITY_CODE, ( code + _DPNHRESULT_BASE ) ) + +#define DPN_OK S_OK + +#define DPNSUCCESS_EQUAL MAKE_HRESULT( 0, _DPN_FACILITY_CODE, ( 0x5 + _DPNHRESULT_BASE ) ) +#define DPNSUCCESS_NOPLAYERSINGROUP MAKE_HRESULT( 0, _DPN_FACILITY_CODE, ( 0x8 + _DPNHRESULT_BASE ) ) // added for DirectX 9 +#define DPNSUCCESS_NOTEQUAL MAKE_HRESULT( 0, _DPN_FACILITY_CODE, (0x0A + _DPNHRESULT_BASE ) ) +#define DPNSUCCESS_PENDING MAKE_HRESULT( 0, _DPN_FACILITY_CODE, (0x0e + _DPNHRESULT_BASE ) ) + +#define DPNERR_ABORTED MAKE_DPNHRESULT( 0x30 ) +#define DPNERR_ADDRESSING MAKE_DPNHRESULT( 0x40 ) +#define DPNERR_ALREADYCLOSING MAKE_DPNHRESULT( 0x50 ) +#define DPNERR_ALREADYCONNECTED MAKE_DPNHRESULT( 0x60 ) +#define DPNERR_ALREADYDISCONNECTING MAKE_DPNHRESULT( 0x70 ) +#define DPNERR_ALREADYINITIALIZED MAKE_DPNHRESULT( 0x80 ) +#define DPNERR_ALREADYREGISTERED MAKE_DPNHRESULT( 0x90 ) +#define DPNERR_BUFFERTOOSMALL MAKE_DPNHRESULT( 0x100 ) +#define DPNERR_CANNOTCANCEL MAKE_DPNHRESULT( 0x110 ) +#define DPNERR_CANTCREATEGROUP MAKE_DPNHRESULT( 0x120 ) +#define DPNERR_CANTCREATEPLAYER MAKE_DPNHRESULT( 0x130 ) +#define DPNERR_CANTLAUNCHAPPLICATION MAKE_DPNHRESULT( 0x140 ) +#define DPNERR_CONNECTING MAKE_DPNHRESULT( 0x150 ) +#define DPNERR_CONNECTIONLOST MAKE_DPNHRESULT( 0x160 ) +#define DPNERR_CONVERSION MAKE_DPNHRESULT( 0x170 ) +#define DPNERR_DATATOOLARGE MAKE_DPNHRESULT( 0x175 ) +#define DPNERR_DOESNOTEXIST MAKE_DPNHRESULT( 0x180 ) +#define DPNERR_DPNSVRNOTAVAILABLE MAKE_DPNHRESULT( 0x185 ) +#define DPNERR_DUPLICATECOMMAND MAKE_DPNHRESULT( 0x190 ) +#define DPNERR_ENDPOINTNOTRECEIVING MAKE_DPNHRESULT( 0x200 ) +#define DPNERR_ENUMQUERYTOOLARGE MAKE_DPNHRESULT( 0x210 ) +#define DPNERR_ENUMRESPONSETOOLARGE MAKE_DPNHRESULT( 0x220 ) +#define DPNERR_EXCEPTION MAKE_DPNHRESULT( 0x230 ) +#define DPNERR_GENERIC E_FAIL +#define DPNERR_GROUPNOTEMPTY MAKE_DPNHRESULT( 0x240 ) +#define DPNERR_HOSTING MAKE_DPNHRESULT( 0x250 ) +#define DPNERR_HOSTREJECTEDCONNECTION MAKE_DPNHRESULT( 0x260 ) +#define DPNERR_HOSTTERMINATEDSESSION MAKE_DPNHRESULT( 0x270 ) +#define DPNERR_INCOMPLETEADDRESS MAKE_DPNHRESULT( 0x280 ) +#define DPNERR_INVALIDADDRESSFORMAT MAKE_DPNHRESULT( 0x290 ) +#define DPNERR_INVALIDAPPLICATION MAKE_DPNHRESULT( 0x300 ) +#define DPNERR_INVALIDCOMMAND MAKE_DPNHRESULT( 0x310 ) +#define DPNERR_INVALIDDEVICEADDRESS MAKE_DPNHRESULT( 0x320 ) +#define DPNERR_INVALIDENDPOINT MAKE_DPNHRESULT( 0x330 ) +#define DPNERR_INVALIDFLAGS MAKE_DPNHRESULT( 0x340 ) +#define DPNERR_INVALIDGROUP MAKE_DPNHRESULT( 0x350 ) +#define DPNERR_INVALIDHANDLE MAKE_DPNHRESULT( 0x360 ) +#define DPNERR_INVALIDHOSTADDRESS MAKE_DPNHRESULT( 0x370 ) +#define DPNERR_INVALIDINSTANCE MAKE_DPNHRESULT( 0x380 ) +#define DPNERR_INVALIDINTERFACE MAKE_DPNHRESULT( 0x390 ) +#define DPNERR_INVALIDOBJECT MAKE_DPNHRESULT( 0x400 ) +#define DPNERR_INVALIDPARAM E_INVALIDARG +#define DPNERR_INVALIDPASSWORD MAKE_DPNHRESULT( 0x410 ) +#define DPNERR_INVALIDPLAYER MAKE_DPNHRESULT( 0x420 ) +#define DPNERR_INVALIDPOINTER E_POINTER +#define DPNERR_INVALIDPRIORITY MAKE_DPNHRESULT( 0x430 ) +#define DPNERR_INVALIDSTRING MAKE_DPNHRESULT( 0x440 ) +#define DPNERR_INVALIDURL MAKE_DPNHRESULT( 0x450 ) +#define DPNERR_INVALIDVERSION MAKE_DPNHRESULT( 0x460 ) +#define DPNERR_NOCAPS MAKE_DPNHRESULT( 0x470 ) +#define DPNERR_NOCONNECTION MAKE_DPNHRESULT( 0x480 ) +#define DPNERR_NOHOSTPLAYER MAKE_DPNHRESULT( 0x490 ) +#define DPNERR_NOINTERFACE E_NOINTERFACE +#define DPNERR_NOMOREADDRESSCOMPONENTS MAKE_DPNHRESULT( 0x500 ) +#define DPNERR_NORESPONSE MAKE_DPNHRESULT( 0x510 ) +#define DPNERR_NOTALLOWED MAKE_DPNHRESULT( 0x520 ) +#define DPNERR_NOTHOST MAKE_DPNHRESULT( 0x530 ) +#define DPNERR_NOTREADY MAKE_DPNHRESULT( 0x540 ) +#define DPNERR_NOTREGISTERED MAKE_DPNHRESULT( 0x550 ) +#define DPNERR_OUTOFMEMORY E_OUTOFMEMORY +#define DPNERR_PENDING DPNSUCCESS_PENDING +#define DPNERR_PLAYERALREADYINGROUP MAKE_DPNHRESULT( 0x560 ) +#define DPNERR_PLAYERLOST MAKE_DPNHRESULT( 0x570 ) +#define DPNERR_PLAYERNOTINGROUP MAKE_DPNHRESULT( 0x580 ) +#define DPNERR_PLAYERNOTREACHABLE MAKE_DPNHRESULT( 0x590 ) +#define DPNERR_SENDTOOLARGE MAKE_DPNHRESULT( 0x600 ) +#define DPNERR_SESSIONFULL MAKE_DPNHRESULT( 0x610 ) +#define DPNERR_TABLEFULL MAKE_DPNHRESULT( 0x620 ) +#define DPNERR_TIMEDOUT MAKE_DPNHRESULT( 0x630 ) +#define DPNERR_UNINITIALIZED MAKE_DPNHRESULT( 0x640 ) +#define DPNERR_UNSUPPORTED E_NOTIMPL +#define DPNERR_USERCANCEL MAKE_DPNHRESULT( 0x650 ) + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/dep/include/DXSDK/include/dplobby.h b/src/dep/include/DXSDK/include/dplobby.h index 32339ee..c91d323 100644 --- a/src/dep/include/DXSDK/include/dplobby.h +++ b/src/dep/include/DXSDK/include/dplobby.h @@ -1,853 +1,853 @@ -/*==========================================================================; - * - * Copyright (C) 1996-1997 Microsoft Corporation. All Rights Reserved. - * - * File: dplobby.h - * Content: DirectPlayLobby include file - ***************************************************************************/ -#ifndef __DPLOBBY_INCLUDED__ -#define __DPLOBBY_INCLUDED__ - -#include "dplay.h" - -/* avoid warnings at Level 4 */ -#pragma warning(disable:4201) - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * GUIDS used by DirectPlay objects - */ - -/* {AF465C71-9588-11cf-A020-00AA006157AC} */ -DEFINE_GUID(IID_IDirectPlayLobby, 0xaf465c71, 0x9588, 0x11cf, 0xa0, 0x20, 0x0, 0xaa, 0x0, 0x61, 0x57, 0xac); -/* {26C66A70-B367-11cf-A024-00AA006157AC} */ -DEFINE_GUID(IID_IDirectPlayLobbyA, 0x26c66a70, 0xb367, 0x11cf, 0xa0, 0x24, 0x0, 0xaa, 0x0, 0x61, 0x57, 0xac); -/* {0194C220-A303-11d0-9C4F-00A0C905425E} */ -DEFINE_GUID(IID_IDirectPlayLobby2, 0x194c220, 0xa303, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); -/* {1BB4AF80-A303-11d0-9C4F-00A0C905425E} */ -DEFINE_GUID(IID_IDirectPlayLobby2A, 0x1bb4af80, 0xa303, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); -/* {2DB72490-652C-11d1-A7A8-0000F803ABFC} */ -DEFINE_GUID(IID_IDirectPlayLobby3, 0x2db72490, 0x652c, 0x11d1, 0xa7, 0xa8, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc); -/* {2DB72491-652C-11d1-A7A8-0000F803ABFC} */ -DEFINE_GUID(IID_IDirectPlayLobby3A, 0x2db72491, 0x652c, 0x11d1, 0xa7, 0xa8, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc); -/* {2FE8F810-B2A5-11d0-A787-0000F803ABFC} */ -DEFINE_GUID(CLSID_DirectPlayLobby, 0x2fe8f810, 0xb2a5, 0x11d0, 0xa7, 0x87, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc); - - -/**************************************************************************** - * - * IDirectPlayLobby Structures - * - * Various structures used to invoke DirectPlayLobby. - * - ****************************************************************************/ - -typedef struct IDirectPlayLobby FAR *LPDIRECTPLAYLOBBY; -typedef struct IDirectPlayLobby FAR *LPDIRECTPLAYLOBBYA; -typedef struct IDirectPlayLobby IDirectPlayLobbyA; - -typedef struct IDirectPlayLobby2 FAR *LPDIRECTPLAYLOBBY2; -typedef struct IDirectPlayLobby2 FAR *LPDIRECTPLAYLOBBY2A; -typedef struct IDirectPlayLobby2 IDirectPlayLobby2A; - -typedef struct IDirectPlayLobby3 FAR *LPDIRECTPLAYLOBBY3; -typedef struct IDirectPlayLobby3 FAR *LPDIRECTPLAYLOBBY3A; -typedef struct IDirectPlayLobby3 IDirectPlayLobby3A; - - -/* - * DPLAPPINFO - * Used to hold information about a registered DirectPlay - * application - */ -typedef struct DPLAPPINFO -{ - DWORD dwSize; // Size of this structure - GUID guidApplication; // GUID of the Application - union - { - LPSTR lpszAppNameA; // Pointer to the Application Name - LPWSTR lpszAppName; - }; - -} DPLAPPINFO, FAR *LPDPLAPPINFO; - -/* - * LPCDPLAPPINFO - * A constant pointer to DPLAPPINFO - */ -typedef const DPLAPPINFO FAR *LPCDPLAPPINFO; - -/* - * DPCOMPOUNDADDRESSELEMENT - * - * An array of these is passed to CreateCompoundAddresses() - */ -typedef struct DPCOMPOUNDADDRESSELEMENT -{ - GUID guidDataType; - DWORD dwDataSize; - LPVOID lpData; -} DPCOMPOUNDADDRESSELEMENT, FAR *LPDPCOMPOUNDADDRESSELEMENT; - -/* - * LPCDPCOMPOUNDADDRESSELEMENT - * A constant pointer to DPCOMPOUNDADDRESSELEMENT - */ -typedef const DPCOMPOUNDADDRESSELEMENT FAR *LPCDPCOMPOUNDADDRESSELEMENT; - -/* - * LPDPAPPLICATIONDESC - * Used to register a DirectPlay application - */ -typedef struct DPAPPLICATIONDESC -{ - DWORD dwSize; - DWORD dwFlags; - union - { - LPSTR lpszApplicationNameA; - LPWSTR lpszApplicationName; - }; - GUID guidApplication; - union - { - LPSTR lpszFilenameA; - LPWSTR lpszFilename; - }; - union - { - LPSTR lpszCommandLineA; - LPWSTR lpszCommandLine; - }; - union - { - LPSTR lpszPathA; - LPWSTR lpszPath; - }; - union - { - LPSTR lpszCurrentDirectoryA; - LPWSTR lpszCurrentDirectory; - }; - LPSTR lpszDescriptionA; - LPWSTR lpszDescriptionW; -} DPAPPLICATIONDESC, *LPDPAPPLICATIONDESC; - -/* - * LPDPAPPLICATIONDESC2 - * Used to register a DirectPlay application - */ -typedef struct DPAPPLICATIONDESC2 -{ - DWORD dwSize; - DWORD dwFlags; - union - { - LPSTR lpszApplicationNameA; - LPWSTR lpszApplicationName; - }; - GUID guidApplication; - union - { - LPSTR lpszFilenameA; - LPWSTR lpszFilename; - }; - union - { - LPSTR lpszCommandLineA; - LPWSTR lpszCommandLine; - }; - union - { - LPSTR lpszPathA; - LPWSTR lpszPath; - }; - union - { - LPSTR lpszCurrentDirectoryA; - LPWSTR lpszCurrentDirectory; - }; - LPSTR lpszDescriptionA; - LPWSTR lpszDescriptionW; - union - { - LPSTR lpszAppLauncherNameA; - LPWSTR lpszAppLauncherName; - }; -} DPAPPLICATIONDESC2, *LPDPAPPLICATIONDESC2; - - -/**************************************************************************** - * - * Enumeration Method Callback Prototypes - * - ****************************************************************************/ - -/* - * Callback for EnumAddress() - */ -typedef BOOL (FAR PASCAL *LPDPENUMADDRESSCALLBACK)( - REFGUID guidDataType, - DWORD dwDataSize, - LPCVOID lpData, - LPVOID lpContext); - -/* - * Callback for EnumAddressTypes() - */ -typedef BOOL (FAR PASCAL *LPDPLENUMADDRESSTYPESCALLBACK)( - REFGUID guidDataType, - LPVOID lpContext, - DWORD dwFlags); - -/* - * Callback for EnumLocalApplications() - */ -typedef BOOL (FAR PASCAL * LPDPLENUMLOCALAPPLICATIONSCALLBACK)( - LPCDPLAPPINFO lpAppInfo, - LPVOID lpContext, - DWORD dwFlags); - - -/**************************************************************************** - * - * DirectPlayLobby API Prototypes - * - ****************************************************************************/ -#ifdef UNICODE -#define DirectPlayLobbyCreate DirectPlayLobbyCreateW -#else -#define DirectPlayLobbyCreate DirectPlayLobbyCreateA -#endif /* UNICODE */ - -extern HRESULT WINAPI DirectPlayLobbyCreateW(LPGUID, LPDIRECTPLAYLOBBY *, IUnknown *, LPVOID, DWORD ); -extern HRESULT WINAPI DirectPlayLobbyCreateA(LPGUID, LPDIRECTPLAYLOBBYA *, IUnknown *, LPVOID, DWORD ); - - -/**************************************************************************** - * - * IDirectPlayLobby (and IDirectPlayLobbyA) Interface - * - ****************************************************************************/ -#undef INTERFACE -#define INTERFACE IDirectPlayLobby -DECLARE_INTERFACE_( IDirectPlayLobby, IUnknown ) -{ - /* IUnknown Methods */ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectPlayLobby Methods */ - STDMETHOD(Connect) (THIS_ DWORD, LPDIRECTPLAY2 *, IUnknown FAR *) PURE; - STDMETHOD(CreateAddress) (THIS_ REFGUID, REFGUID, LPCVOID, DWORD, LPVOID, LPDWORD) PURE; - STDMETHOD(EnumAddress) (THIS_ LPDPENUMADDRESSCALLBACK, LPCVOID, DWORD, LPVOID) PURE; - STDMETHOD(EnumAddressTypes) (THIS_ LPDPLENUMADDRESSTYPESCALLBACK, REFGUID, LPVOID, DWORD) PURE; - STDMETHOD(EnumLocalApplications)(THIS_ LPDPLENUMLOCALAPPLICATIONSCALLBACK, LPVOID, DWORD) PURE; - STDMETHOD(GetConnectionSettings)(THIS_ DWORD, LPVOID, LPDWORD) PURE; - STDMETHOD(ReceiveLobbyMessage) (THIS_ DWORD, DWORD, LPDWORD, LPVOID, LPDWORD) PURE; - STDMETHOD(RunApplication) (THIS_ DWORD, LPDWORD, LPDPLCONNECTION, HANDLE) PURE; - STDMETHOD(SendLobbyMessage) (THIS_ DWORD, DWORD, LPVOID, DWORD) PURE; - STDMETHOD(SetConnectionSettings)(THIS_ DWORD, DWORD, LPDPLCONNECTION) PURE; - STDMETHOD(SetLobbyMessageEvent) (THIS_ DWORD, DWORD, HANDLE) PURE; - -}; - -/**************************************************************************** - * - * IDirectPlayLobby2 (and IDirectPlayLobby2A) Interface - * - ****************************************************************************/ -#undef INTERFACE -#define INTERFACE IDirectPlayLobby2 -DECLARE_INTERFACE_( IDirectPlayLobby2, IDirectPlayLobby ) -{ - /* IUnknown Methods */ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectPlayLobby Methods */ - STDMETHOD(Connect) (THIS_ DWORD, LPDIRECTPLAY2 *, IUnknown FAR *) PURE; - STDMETHOD(CreateAddress) (THIS_ REFGUID, REFGUID, LPCVOID, DWORD, LPVOID, LPDWORD) PURE; - STDMETHOD(EnumAddress) (THIS_ LPDPENUMADDRESSCALLBACK, LPCVOID, DWORD, LPVOID) PURE; - STDMETHOD(EnumAddressTypes) (THIS_ LPDPLENUMADDRESSTYPESCALLBACK, REFGUID, LPVOID, DWORD) PURE; - STDMETHOD(EnumLocalApplications)(THIS_ LPDPLENUMLOCALAPPLICATIONSCALLBACK, LPVOID, DWORD) PURE; - STDMETHOD(GetConnectionSettings)(THIS_ DWORD, LPVOID, LPDWORD) PURE; - STDMETHOD(ReceiveLobbyMessage) (THIS_ DWORD, DWORD, LPDWORD, LPVOID, LPDWORD) PURE; - STDMETHOD(RunApplication) (THIS_ DWORD, LPDWORD, LPDPLCONNECTION, HANDLE) PURE; - STDMETHOD(SendLobbyMessage) (THIS_ DWORD, DWORD, LPVOID, DWORD) PURE; - STDMETHOD(SetConnectionSettings)(THIS_ DWORD, DWORD, LPDPLCONNECTION) PURE; - STDMETHOD(SetLobbyMessageEvent) (THIS_ DWORD, DWORD, HANDLE) PURE; - - /* IDirectPlayLobby2 Methods */ - STDMETHOD(CreateCompoundAddress)(THIS_ LPCDPCOMPOUNDADDRESSELEMENT,DWORD,LPVOID,LPDWORD) PURE; -}; - -/**************************************************************************** - * - * IDirectPlayLobby3 (and IDirectPlayLobby3A) Interface - * - ****************************************************************************/ -#undef INTERFACE -#define INTERFACE IDirectPlayLobby3 -DECLARE_INTERFACE_( IDirectPlayLobby3, IDirectPlayLobby ) -{ - /* IUnknown Methods */ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /* IDirectPlayLobby Methods */ - STDMETHOD(Connect) (THIS_ DWORD, LPDIRECTPLAY2 *, IUnknown FAR *) PURE; - STDMETHOD(CreateAddress) (THIS_ REFGUID, REFGUID, LPCVOID, DWORD, LPVOID, LPDWORD) PURE; - STDMETHOD(EnumAddress) (THIS_ LPDPENUMADDRESSCALLBACK, LPCVOID, DWORD, LPVOID) PURE; - STDMETHOD(EnumAddressTypes) (THIS_ LPDPLENUMADDRESSTYPESCALLBACK, REFGUID, LPVOID, DWORD) PURE; - STDMETHOD(EnumLocalApplications)(THIS_ LPDPLENUMLOCALAPPLICATIONSCALLBACK, LPVOID, DWORD) PURE; - STDMETHOD(GetConnectionSettings)(THIS_ DWORD, LPVOID, LPDWORD) PURE; - STDMETHOD(ReceiveLobbyMessage) (THIS_ DWORD, DWORD, LPDWORD, LPVOID, LPDWORD) PURE; - STDMETHOD(RunApplication) (THIS_ DWORD, LPDWORD, LPDPLCONNECTION, HANDLE) PURE; - STDMETHOD(SendLobbyMessage) (THIS_ DWORD, DWORD, LPVOID, DWORD) PURE; - STDMETHOD(SetConnectionSettings)(THIS_ DWORD, DWORD, LPDPLCONNECTION) PURE; - STDMETHOD(SetLobbyMessageEvent) (THIS_ DWORD, DWORD, HANDLE) PURE; - - /* IDirectPlayLobby2 Methods */ - STDMETHOD(CreateCompoundAddress)(THIS_ LPCDPCOMPOUNDADDRESSELEMENT,DWORD,LPVOID,LPDWORD) PURE; - - /* IDirectPlayLobby3 Methods */ - STDMETHOD(ConnectEx) (THIS_ DWORD, REFIID, LPVOID *, IUnknown FAR *) PURE; - STDMETHOD(RegisterApplication) (THIS_ DWORD, LPVOID) PURE; - STDMETHOD(UnregisterApplication)(THIS_ DWORD, REFGUID) PURE; - STDMETHOD(WaitForConnectionSettings)(THIS_ DWORD) PURE; -}; - -/**************************************************************************** - * - * IDirectPlayLobby interface macros - * - ****************************************************************************/ - -#if !defined(__cplusplus) || defined(CINTERFACE) - -#define IDirectPlayLobby_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlayLobby_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlayLobby_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlayLobby_Connect(p,a,b,c) (p)->lpVtbl->Connect(p,a,b,c) -#define IDirectPlayLobby_ConnectEx(p,a,b,c,d) (p)->lpVtbl->ConnectEx(p,a,b,c,d) -#define IDirectPlayLobby_CreateAddress(p,a,b,c,d,e,f) (p)->lpVtbl->CreateAddress(p,a,b,c,d,e,f) -#define IDirectPlayLobby_CreateCompoundAddress(p,a,b,c,d) (p)->lpVtbl->CreateCompoundAddress(p,a,b,c,d) -#define IDirectPlayLobby_EnumAddress(p,a,b,c,d) (p)->lpVtbl->EnumAddress(p,a,b,c,d) -#define IDirectPlayLobby_EnumAddressTypes(p,a,b,c,d) (p)->lpVtbl->EnumAddressTypes(p,a,b,c,d) -#define IDirectPlayLobby_EnumLocalApplications(p,a,b,c) (p)->lpVtbl->EnumLocalApplications(p,a,b,c) -#define IDirectPlayLobby_GetConnectionSettings(p,a,b,c) (p)->lpVtbl->GetConnectionSettings(p,a,b,c) -#define IDirectPlayLobby_ReceiveLobbyMessage(p,a,b,c,d,e) (p)->lpVtbl->ReceiveLobbyMessage(p,a,b,c,d,e) -#define IDirectPlayLobby_RegisterApplication(p,a,b) (p)->lpVtbl->RegisterApplication(p,a,b) -#define IDirectPlayLobby_RunApplication(p,a,b,c,d) (p)->lpVtbl->RunApplication(p,a,b,c,d) -#define IDirectPlayLobby_SendLobbyMessage(p,a,b,c,d) (p)->lpVtbl->SendLobbyMessage(p,a,b,c,d) -#define IDirectPlayLobby_SetConnectionSettings(p,a,b,c) (p)->lpVtbl->SetConnectionSettings(p,a,b,c) -#define IDirectPlayLobby_SetLobbyMessageEvent(p,a,b,c) (p)->lpVtbl->SetLobbyMessageEvent(p,a,b,c) -#define IDirectPlayLobby_UnregisterApplication(p,a,b) (p)->lpVtbl->UnregisterApplication(p,a,b) -#define IDirectPlayLobby_WaitForConnectionSettings(p,a) (p)->lpVtbl->WaitForConnectionSettings(p,a) - -#else /* C++ */ - -#define IDirectPlayLobby_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlayLobby_AddRef(p) (p)->AddRef() -#define IDirectPlayLobby_Release(p) (p)->Release() -#define IDirectPlayLobby_Connect(p,a,b,c) (p)->Connect(a,b,c) -#define IDirectPlayLobby_ConnectEx(p,a,b,c,d) (p)->ConnectEx(a,b,c,d) -#define IDirectPlayLobby_CreateAddress(p,a,b,c,d,e,f) (p)->CreateAddress(a,b,c,d,e,f) -#define IDirectPlayLobby_CreateCompoundAddress(p,a,b,c,d) (p)->CreateCompoundAddress(a,b,c,d) -#define IDirectPlayLobby_EnumAddress(p,a,b,c,d) (p)->EnumAddress(a,b,c,d) -#define IDirectPlayLobby_EnumAddressTypes(p,a,b,c,d) (p)->EnumAddressTypes(a,b,c,d) -#define IDirectPlayLobby_EnumLocalApplications(p,a,b,c) (p)->EnumLocalApplications(a,b,c) -#define IDirectPlayLobby_GetConnectionSettings(p,a,b,c) (p)->GetConnectionSettings(a,b,c) -#define IDirectPlayLobby_ReceiveLobbyMessage(p,a,b,c,d,e) (p)->ReceiveLobbyMessage(a,b,c,d,e) -#define IDirectPlayLobby_RegisterApplication(p,a,b) (p)->RegisterApplication(a,b) -#define IDirectPlayLobby_RunApplication(p,a,b,c,d) (p)->RunApplication(a,b,c,d) -#define IDirectPlayLobby_SendLobbyMessage(p,a,b,c,d) (p)->SendLobbyMessage(a,b,c,d) -#define IDirectPlayLobby_SetConnectionSettings(p,a,b,c) (p)->SetConnectionSettings(a,b,c) -#define IDirectPlayLobby_SetLobbyMessageEvent(p,a,b,c) (p)->SetLobbyMessageEvent(a,b,c) -#define IDirectPlayLobby_UnregisterApplication(p,a,b) (p)->UnregisterApplication(a,b) -#define IDirectPlayLobby_WaitForConnectionSettings(p,a) (p)->WaitForConnectionSettings(a) - -#endif - -/**************************************************************************** - * - * DirectPlayLobby Flags - * - ****************************************************************************/ - -/* - * This flag is used by IDirectPlayLobby->WaitForConnectionSettings to - * cancel a current wait that is in progress. - */ -#define DPLWAIT_CANCEL 0x00000001 - - -/* - * This is a message flag used by ReceiveLobbyMessage. It can be - * returned in the dwMessageFlags parameter to indicate a message from - * the system. - */ -#define DPLMSG_SYSTEM 0x00000001 - -/* - * This is a message flag used by ReceiveLobbyMessage and SendLobbyMessage. - * It is used to indicate that the message is a standard lobby message. - * DPLMSG_SETPROPERTY, DPLMSG_SETPROPERTYRESPONSE, DPLMSG_GETPROPERTY, - * DPLMSG_GETPROPERTYRESPONSE - */ -#define DPLMSG_STANDARD 0x00000002 - -/* - * Lobbyable Application registration flags - */ - -/* - * Applications registered with this flag will not show up when - * applications are enumerated in the lobby. This application - * will only be able to be launched by a lobby client that already - * knows about the application. - */ -#define DPLAPP_NOENUM 0x80000000 - -/* - * Applications registered with this flag want voice to automatically - * be enabled for their application. All players will be launched into - * an 'n'-way voice conference when the application is started. The - * user will be able to enable this flag for existing non-voice - * directplay applications. - */ -#define DPLAPP_AUTOVOICE 0x00000001 - -/* - * Applications that do their own voice conferencing should register with - * this flag to avoid allowing the user to enable other voice chat - * capabilites during the same session. This is to avoid users forcing - * the DPLAPP_AUTOVOICE flag for the application. - */ -#define DPLAPP_SELFVOICE 0x00000002 - -/**************************************************************************** - * - * DirectPlayLobby messages and message data structures - * - * All system messages have a dwMessageFlags value of DPLMSG_SYSTEM returned - * from a call to ReceiveLobbyMessage. - * - * All standard messages have a dwMessageFlags value of DPLMSG_STANDARD returned - * from a call to ReceiveLobbyMessage. - * - ****************************************************************************/ - -/* - * DPLMSG_GENERIC - * Generic message structure used to identify the message type. - */ -typedef struct _DPLMSG_GENERIC -{ - DWORD dwType; // Message type -} DPLMSG_GENERIC, FAR *LPDPLMSG_GENERIC; - -/* - * DPLMSG_SYSTEMMESSAGE - * Generic message format for all system messages -- - * DPLSYS_CONNECTIONSETTINGSREAD, DPLSYS_DPLYCONNECTSUCCEEDED, - * DPLSYS_DPLAYCONNECTFAILED, DPLSYS_APPTERMINATED, DPLSYS_NEWCONNECTIONSETTINGS - */ -typedef struct _DPLMSG_SYSTEMMESSAGE -{ - DWORD dwType; // Message type - GUID guidInstance; // Instance GUID of the dplay session the message corresponds to -} DPLMSG_SYSTEMMESSAGE, FAR *LPDPLMSG_SYSTEMMESSAGE; - -/* - * DPLMSG_SETPROPERTY - * Standard message sent by an application to a lobby to set a - * property - */ -typedef struct _DPLMSG_SETPROPERTY -{ - DWORD dwType; // Message type - DWORD dwRequestID; // Request ID (DPL_NOCONFIRMATION if no confirmation desired) - GUID guidPlayer; // Player GUID - GUID guidPropertyTag; // Property GUID - DWORD dwDataSize; // Size of data - DWORD dwPropertyData[1]; // Buffer containing data -} DPLMSG_SETPROPERTY, FAR *LPDPLMSG_SETPROPERTY; - -#define DPL_NOCONFIRMATION 0 - -/* - * DPLMSG_SETPROPERTYRESPONSE - * Standard message returned by a lobby to confirm a - * DPLMSG_SETPROPERTY message. - */ -typedef struct _DPLMSG_SETPROPERTYRESPONSE -{ - DWORD dwType; // Message type - DWORD dwRequestID; // Request ID - GUID guidPlayer; // Player GUID - GUID guidPropertyTag; // Property GUID - HRESULT hr; // Return Code -} DPLMSG_SETPROPERTYRESPONSE, FAR *LPDPLMSG_SETPROPERTYRESPONSE; - -/* - * DPLMSG_GETPROPERTY - * Standard message sent by an application to a lobby to request - * the current value of a property - */ -typedef struct _DPLMSG_GETPROPERTY -{ - DWORD dwType; // Message type - DWORD dwRequestID; // Request ID - GUID guidPlayer; // Player GUID - GUID guidPropertyTag; // Property GUID -} DPLMSG_GETPROPERTY, FAR *LPDPLMSG_GETPROPERTY; - -/* - * DPLMSG_GETPROPERTYRESPONSE - * Standard message returned by a lobby in response to a - * DPLMSG_GETPROPERTY message. - */ -typedef struct _DPLMSG_GETPROPERTYRESPONSE -{ - DWORD dwType; // Message type - DWORD dwRequestID; // Request ID - GUID guidPlayer; // Player GUID - GUID guidPropertyTag; // Property GUID - HRESULT hr; // Return Code - DWORD dwDataSize; // Size of data - DWORD dwPropertyData[1]; // Buffer containing data -} DPLMSG_GETPROPERTYRESPONSE, FAR *LPDPLMSG_GETPROPERTYRESPONSE; - -/* - * DPLMSG_NEWSESSIONHOST - * Standard message returned by a lobby in response to a - * the session host migrating to a new client - */ -typedef struct _DPLMSG_NEWSESSIONHOST -{ - DWORD dwType; // Message type - GUID guidInstance; // GUID Instance of the session -} DPLMSG_NEWSESSIONHOST, FAR *LPDPLMSG_NEWSESSIONHOST; - - -/****************************************** - * - * DirectPlay Lobby message dwType values - * - *****************************************/ - -/* - * The application has read the connection settings. - * It is now O.K. for the lobby client to release - * its IDirectPlayLobby interface. - */ -#define DPLSYS_CONNECTIONSETTINGSREAD 0x00000001 - -/* - * The application's call to DirectPlayConnect failed - */ -#define DPLSYS_DPLAYCONNECTFAILED 0x00000002 - -/* - * The application has created a DirectPlay session. - */ -#define DPLSYS_DPLAYCONNECTSUCCEEDED 0x00000003 - -/* - * The application has terminated. - */ -#define DPLSYS_APPTERMINATED 0x00000004 - -/* - * The message is a DPLMSG_SETPROPERTY message. - */ -#define DPLSYS_SETPROPERTY 0x00000005 - -/* - * The message is a DPLMSG_SETPROPERTYRESPONSE message. - */ -#define DPLSYS_SETPROPERTYRESPONSE 0x00000006 - -/* - * The message is a DPLMSG_GETPROPERTY message. - */ -#define DPLSYS_GETPROPERTY 0x00000007 - -/* - * The message is a DPLMSG_GETPROPERTYRESPONSE message. - */ -#define DPLSYS_GETPROPERTYRESPONSE 0x00000008 - -/* - * The message is a DPLMSG_NEWSESSIONHOST message. - */ -#define DPLSYS_NEWSESSIONHOST 0x00000009 - -/* - * New connection settings are available. - */ -#define DPLSYS_NEWCONNECTIONSETTINGS 0x0000000A - -/* - * The Lobby Client has released the DirectPlayLobby Interface - */ -#define DPLSYS_LOBBYCLIENTRELEASE 0x0000000B - -/**************************************************************************** - * - * DirectPlay defined property GUIDs and associated data structures - * - ****************************************************************************/ - -/* - * DPLPROPERTY_MessagesSupported - * - * Request whether the lobby supports standard. Lobby with respond with either - * TRUE or FALSE or may not respond at all. - * - * Property data is a single BOOL with TRUE or FALSE - */ -// {762CCDA1-D916-11d0-BA39-00C04FD7ED67} -DEFINE_GUID(DPLPROPERTY_MessagesSupported, -0x762ccda1, 0xd916, 0x11d0, 0xba, 0x39, 0x0, 0xc0, 0x4f, 0xd7, 0xed, 0x67); - -/* - * DPLPROPERTY_LobbyGuid - * - * Request the GUID that identifies the lobby software that the application - * is communicating with. - * - * Property data is a single GUID. - */ -// {F56920A0-D218-11d0-BA39-00C04FD7ED67} -DEFINE_GUID(DPLPROPERTY_LobbyGuid, -0xf56920a0, 0xd218, 0x11d0, 0xba, 0x39, 0x0, 0xc0, 0x4f, 0xd7, 0xed, 0x67); - -/* - * DPLPROPERTY_PlayerGuid - * - * Request the GUID that identifies the player on this machine for sending - * property data back to the lobby. - * - * Property data is the DPLDATA_PLAYERDATA structure - */ -// {B4319322-D20D-11d0-BA39-00C04FD7ED67} -DEFINE_GUID(DPLPROPERTY_PlayerGuid, -0xb4319322, 0xd20d, 0x11d0, 0xba, 0x39, 0x0, 0xc0, 0x4f, 0xd7, 0xed, 0x67); - -/* - * DPLDATA_PLAYERGUID - * - * Data structure to hold the GUID of the player and player creation flags - * from the lobby. - */ -typedef struct _DPLDATA_PLAYERGUID -{ - GUID guidPlayer; - DWORD dwPlayerFlags; -} DPLDATA_PLAYERGUID, FAR *LPDPLDATA_PLAYERGUID; - -/* - * DPLPROPERTY_PlayerScore - * - * Used to send an array of long integers to the lobby indicating the - * score of a player. - * - * Property data is the DPLDATA_PLAYERSCORE structure. - */ -// {48784000-D219-11d0-BA39-00C04FD7ED67} -DEFINE_GUID(DPLPROPERTY_PlayerScore, -0x48784000, 0xd219, 0x11d0, 0xba, 0x39, 0x0, 0xc0, 0x4f, 0xd7, 0xed, 0x67); - -/* - * DPLDATA_PLAYERSCORE - * - * Data structure to hold an array of long integers representing a player score. - * Application must allocate enough memory to hold all the scores. - */ -typedef struct _DPLDATA_PLAYERSCORE -{ - DWORD dwScoreCount; - LONG Score[1]; -} DPLDATA_PLAYERSCORE, FAR *LPDPLDATA_PLAYERSCORE; - -/**************************************************************************** - * - * DirectPlay Address ID's - * - ****************************************************************************/ - -/* DirectPlay Address - * - * A DirectPlay address consists of multiple chunks of data, each tagged - * with a GUID signifying the type of data in the chunk. The chunk also - * has a length so that unknown chunk types can be skipped. - * - * The EnumAddress() function is used to parse these address data chunks. - */ - -/* - * DPADDRESS - * - * Header for block of address data elements - */ -typedef struct _DPADDRESS -{ - GUID guidDataType; - DWORD dwDataSize; -} DPADDRESS; - -typedef DPADDRESS FAR *LPDPADDRESS; - -/* - * DPAID_TotalSize - * - * Chunk is a DWORD containing size of entire DPADDRESS structure - */ - -// {1318F560-912C-11d0-9DAA-00A0C90A43CB} -DEFINE_GUID(DPAID_TotalSize, -0x1318f560, 0x912c, 0x11d0, 0x9d, 0xaa, 0x0, 0xa0, 0xc9, 0xa, 0x43, 0xcb); - -/* - * DPAID_ServiceProvider - * - * Chunk is a GUID describing the service provider that created the chunk. - * All addresses must contain this chunk. - */ - -// {07D916C0-E0AF-11cf-9C4E-00A0C905425E} -DEFINE_GUID(DPAID_ServiceProvider, -0x7d916c0, 0xe0af, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); - -/* - * DPAID_LobbyProvider - * - * Chunk is a GUID describing the lobby provider that created the chunk. - * All addresses must contain this chunk. - */ - -// {59B95640-9667-11d0-A77D-0000F803ABFC} -DEFINE_GUID(DPAID_LobbyProvider, -0x59b95640, 0x9667, 0x11d0, 0xa7, 0x7d, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc); - -/* - * DPAID_Phone and DPAID_PhoneW - * - * Chunk is a string containing a phone number (i.e. "1-800-555-1212") - * in ANSI or UNICODE format - */ - -// {78EC89A0-E0AF-11cf-9C4E-00A0C905425E} -DEFINE_GUID(DPAID_Phone, -0x78ec89a0, 0xe0af, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); - -// {BA5A7A70-9DBF-11d0-9CC1-00A0C905425E} -DEFINE_GUID(DPAID_PhoneW, -0xba5a7a70, 0x9dbf, 0x11d0, 0x9c, 0xc1, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); - -/* - * DPAID_Modem and DPAID_ModemW - * - * Chunk is a string containing a modem name registered with TAPI - * in ANSI or UNICODE format - */ - -// {F6DCC200-A2FE-11d0-9C4F-00A0C905425E} -DEFINE_GUID(DPAID_Modem, -0xf6dcc200, 0xa2fe, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); - -// {01FD92E0-A2FF-11d0-9C4F-00A0C905425E} -DEFINE_GUID(DPAID_ModemW, -0x1fd92e0, 0xa2ff, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); - -/* - * DPAID_Inet and DPAID_InetW - * - * Chunk is a string containing a TCP/IP host name or an IP address - * (i.e. "dplay.microsoft.com" or "137.55.100.173") in ANSI or UNICODE format - */ - -// {C4A54DA0-E0AF-11cf-9C4E-00A0C905425E} -DEFINE_GUID(DPAID_INet, -0xc4a54da0, 0xe0af, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); - -// {E63232A0-9DBF-11d0-9CC1-00A0C905425E} -DEFINE_GUID(DPAID_INetW, -0xe63232a0, 0x9dbf, 0x11d0, 0x9c, 0xc1, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); - -/* - * DPAID_InetPort - * - * Chunk is the port number used for creating the apps TCP and UDP sockets. - * WORD value (i.e. 47624). - */ - -// {E4524541-8EA5-11d1-8A96-006097B01411} -DEFINE_GUID(DPAID_INetPort, -0xe4524541, 0x8ea5, 0x11d1, 0x8a, 0x96, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); - -#ifdef BIGMESSAGEDEFENSE -#endif - -/* - * DPCOMPORTADDRESS - * - * Used to specify com port settings. The constants that define baud rate, - * stop bits and parity are defined in WINBASE.H. The constants for flow - * control are given below. - */ - -#define DPCPA_NOFLOW 0 // no flow control -#define DPCPA_XONXOFFFLOW 1 // software flow control -#define DPCPA_RTSFLOW 2 // hardware flow control with RTS -#define DPCPA_DTRFLOW 3 // hardware flow control with DTR -#define DPCPA_RTSDTRFLOW 4 // hardware flow control with RTS and DTR - -typedef struct _DPCOMPORTADDRESS -{ - DWORD dwComPort; // COM port to use (1-4) - DWORD dwBaudRate; // baud rate (100-256k) - DWORD dwStopBits; // no. stop bits (1-2) - DWORD dwParity; // parity (none, odd, even, mark) - DWORD dwFlowControl; // flow control (none, xon/xoff, rts, dtr) -} DPCOMPORTADDRESS; - -typedef DPCOMPORTADDRESS FAR *LPDPCOMPORTADDRESS; - -/* - * DPAID_ComPort - * - * Chunk contains a DPCOMPORTADDRESS structure defining the serial port. - */ - -// {F2F0CE00-E0AF-11cf-9C4E-00A0C905425E} -DEFINE_GUID(DPAID_ComPort, -0xf2f0ce00, 0xe0af, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); - -/**************************************************************************** - * - * dplobby 1.0 obsolete definitions - * Included for compatibility only. - * - ****************************************************************************/ -#define DPLAD_SYSTEM DPLMSG_SYSTEM - - -#ifdef __cplusplus -}; -#endif /* __cplusplus */ - -#pragma warning(default:4201) - -#endif /* __DPLOBBY_INCLUDED__ */ - +/*==========================================================================; + * + * Copyright (C) 1996-1997 Microsoft Corporation. All Rights Reserved. + * + * File: dplobby.h + * Content: DirectPlayLobby include file + ***************************************************************************/ +#ifndef __DPLOBBY_INCLUDED__ +#define __DPLOBBY_INCLUDED__ + +#include "dplay.h" + +/* avoid warnings at Level 4 */ +#pragma warning(disable:4201) + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * GUIDS used by DirectPlay objects + */ + +/* {AF465C71-9588-11cf-A020-00AA006157AC} */ +DEFINE_GUID(IID_IDirectPlayLobby, 0xaf465c71, 0x9588, 0x11cf, 0xa0, 0x20, 0x0, 0xaa, 0x0, 0x61, 0x57, 0xac); +/* {26C66A70-B367-11cf-A024-00AA006157AC} */ +DEFINE_GUID(IID_IDirectPlayLobbyA, 0x26c66a70, 0xb367, 0x11cf, 0xa0, 0x24, 0x0, 0xaa, 0x0, 0x61, 0x57, 0xac); +/* {0194C220-A303-11d0-9C4F-00A0C905425E} */ +DEFINE_GUID(IID_IDirectPlayLobby2, 0x194c220, 0xa303, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); +/* {1BB4AF80-A303-11d0-9C4F-00A0C905425E} */ +DEFINE_GUID(IID_IDirectPlayLobby2A, 0x1bb4af80, 0xa303, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); +/* {2DB72490-652C-11d1-A7A8-0000F803ABFC} */ +DEFINE_GUID(IID_IDirectPlayLobby3, 0x2db72490, 0x652c, 0x11d1, 0xa7, 0xa8, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc); +/* {2DB72491-652C-11d1-A7A8-0000F803ABFC} */ +DEFINE_GUID(IID_IDirectPlayLobby3A, 0x2db72491, 0x652c, 0x11d1, 0xa7, 0xa8, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc); +/* {2FE8F810-B2A5-11d0-A787-0000F803ABFC} */ +DEFINE_GUID(CLSID_DirectPlayLobby, 0x2fe8f810, 0xb2a5, 0x11d0, 0xa7, 0x87, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc); + + +/**************************************************************************** + * + * IDirectPlayLobby Structures + * + * Various structures used to invoke DirectPlayLobby. + * + ****************************************************************************/ + +typedef struct IDirectPlayLobby FAR *LPDIRECTPLAYLOBBY; +typedef struct IDirectPlayLobby FAR *LPDIRECTPLAYLOBBYA; +typedef struct IDirectPlayLobby IDirectPlayLobbyA; + +typedef struct IDirectPlayLobby2 FAR *LPDIRECTPLAYLOBBY2; +typedef struct IDirectPlayLobby2 FAR *LPDIRECTPLAYLOBBY2A; +typedef struct IDirectPlayLobby2 IDirectPlayLobby2A; + +typedef struct IDirectPlayLobby3 FAR *LPDIRECTPLAYLOBBY3; +typedef struct IDirectPlayLobby3 FAR *LPDIRECTPLAYLOBBY3A; +typedef struct IDirectPlayLobby3 IDirectPlayLobby3A; + + +/* + * DPLAPPINFO + * Used to hold information about a registered DirectPlay + * application + */ +typedef struct DPLAPPINFO +{ + DWORD dwSize; // Size of this structure + GUID guidApplication; // GUID of the Application + union + { + LPSTR lpszAppNameA; // Pointer to the Application Name + LPWSTR lpszAppName; + }; + +} DPLAPPINFO, FAR *LPDPLAPPINFO; + +/* + * LPCDPLAPPINFO + * A constant pointer to DPLAPPINFO + */ +typedef const DPLAPPINFO FAR *LPCDPLAPPINFO; + +/* + * DPCOMPOUNDADDRESSELEMENT + * + * An array of these is passed to CreateCompoundAddresses() + */ +typedef struct DPCOMPOUNDADDRESSELEMENT +{ + GUID guidDataType; + DWORD dwDataSize; + LPVOID lpData; +} DPCOMPOUNDADDRESSELEMENT, FAR *LPDPCOMPOUNDADDRESSELEMENT; + +/* + * LPCDPCOMPOUNDADDRESSELEMENT + * A constant pointer to DPCOMPOUNDADDRESSELEMENT + */ +typedef const DPCOMPOUNDADDRESSELEMENT FAR *LPCDPCOMPOUNDADDRESSELEMENT; + +/* + * LPDPAPPLICATIONDESC + * Used to register a DirectPlay application + */ +typedef struct DPAPPLICATIONDESC +{ + DWORD dwSize; + DWORD dwFlags; + union + { + LPSTR lpszApplicationNameA; + LPWSTR lpszApplicationName; + }; + GUID guidApplication; + union + { + LPSTR lpszFilenameA; + LPWSTR lpszFilename; + }; + union + { + LPSTR lpszCommandLineA; + LPWSTR lpszCommandLine; + }; + union + { + LPSTR lpszPathA; + LPWSTR lpszPath; + }; + union + { + LPSTR lpszCurrentDirectoryA; + LPWSTR lpszCurrentDirectory; + }; + LPSTR lpszDescriptionA; + LPWSTR lpszDescriptionW; +} DPAPPLICATIONDESC, *LPDPAPPLICATIONDESC; + +/* + * LPDPAPPLICATIONDESC2 + * Used to register a DirectPlay application + */ +typedef struct DPAPPLICATIONDESC2 +{ + DWORD dwSize; + DWORD dwFlags; + union + { + LPSTR lpszApplicationNameA; + LPWSTR lpszApplicationName; + }; + GUID guidApplication; + union + { + LPSTR lpszFilenameA; + LPWSTR lpszFilename; + }; + union + { + LPSTR lpszCommandLineA; + LPWSTR lpszCommandLine; + }; + union + { + LPSTR lpszPathA; + LPWSTR lpszPath; + }; + union + { + LPSTR lpszCurrentDirectoryA; + LPWSTR lpszCurrentDirectory; + }; + LPSTR lpszDescriptionA; + LPWSTR lpszDescriptionW; + union + { + LPSTR lpszAppLauncherNameA; + LPWSTR lpszAppLauncherName; + }; +} DPAPPLICATIONDESC2, *LPDPAPPLICATIONDESC2; + + +/**************************************************************************** + * + * Enumeration Method Callback Prototypes + * + ****************************************************************************/ + +/* + * Callback for EnumAddress() + */ +typedef BOOL (FAR PASCAL *LPDPENUMADDRESSCALLBACK)( + REFGUID guidDataType, + DWORD dwDataSize, + LPCVOID lpData, + LPVOID lpContext); + +/* + * Callback for EnumAddressTypes() + */ +typedef BOOL (FAR PASCAL *LPDPLENUMADDRESSTYPESCALLBACK)( + REFGUID guidDataType, + LPVOID lpContext, + DWORD dwFlags); + +/* + * Callback for EnumLocalApplications() + */ +typedef BOOL (FAR PASCAL * LPDPLENUMLOCALAPPLICATIONSCALLBACK)( + LPCDPLAPPINFO lpAppInfo, + LPVOID lpContext, + DWORD dwFlags); + + +/**************************************************************************** + * + * DirectPlayLobby API Prototypes + * + ****************************************************************************/ +#ifdef UNICODE +#define DirectPlayLobbyCreate DirectPlayLobbyCreateW +#else +#define DirectPlayLobbyCreate DirectPlayLobbyCreateA +#endif /* UNICODE */ + +extern HRESULT WINAPI DirectPlayLobbyCreateW(LPGUID, LPDIRECTPLAYLOBBY *, IUnknown *, LPVOID, DWORD ); +extern HRESULT WINAPI DirectPlayLobbyCreateA(LPGUID, LPDIRECTPLAYLOBBYA *, IUnknown *, LPVOID, DWORD ); + + +/**************************************************************************** + * + * IDirectPlayLobby (and IDirectPlayLobbyA) Interface + * + ****************************************************************************/ +#undef INTERFACE +#define INTERFACE IDirectPlayLobby +DECLARE_INTERFACE_( IDirectPlayLobby, IUnknown ) +{ + /* IUnknown Methods */ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectPlayLobby Methods */ + STDMETHOD(Connect) (THIS_ DWORD, LPDIRECTPLAY2 *, IUnknown FAR *) PURE; + STDMETHOD(CreateAddress) (THIS_ REFGUID, REFGUID, LPCVOID, DWORD, LPVOID, LPDWORD) PURE; + STDMETHOD(EnumAddress) (THIS_ LPDPENUMADDRESSCALLBACK, LPCVOID, DWORD, LPVOID) PURE; + STDMETHOD(EnumAddressTypes) (THIS_ LPDPLENUMADDRESSTYPESCALLBACK, REFGUID, LPVOID, DWORD) PURE; + STDMETHOD(EnumLocalApplications)(THIS_ LPDPLENUMLOCALAPPLICATIONSCALLBACK, LPVOID, DWORD) PURE; + STDMETHOD(GetConnectionSettings)(THIS_ DWORD, LPVOID, LPDWORD) PURE; + STDMETHOD(ReceiveLobbyMessage) (THIS_ DWORD, DWORD, LPDWORD, LPVOID, LPDWORD) PURE; + STDMETHOD(RunApplication) (THIS_ DWORD, LPDWORD, LPDPLCONNECTION, HANDLE) PURE; + STDMETHOD(SendLobbyMessage) (THIS_ DWORD, DWORD, LPVOID, DWORD) PURE; + STDMETHOD(SetConnectionSettings)(THIS_ DWORD, DWORD, LPDPLCONNECTION) PURE; + STDMETHOD(SetLobbyMessageEvent) (THIS_ DWORD, DWORD, HANDLE) PURE; + +}; + +/**************************************************************************** + * + * IDirectPlayLobby2 (and IDirectPlayLobby2A) Interface + * + ****************************************************************************/ +#undef INTERFACE +#define INTERFACE IDirectPlayLobby2 +DECLARE_INTERFACE_( IDirectPlayLobby2, IDirectPlayLobby ) +{ + /* IUnknown Methods */ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectPlayLobby Methods */ + STDMETHOD(Connect) (THIS_ DWORD, LPDIRECTPLAY2 *, IUnknown FAR *) PURE; + STDMETHOD(CreateAddress) (THIS_ REFGUID, REFGUID, LPCVOID, DWORD, LPVOID, LPDWORD) PURE; + STDMETHOD(EnumAddress) (THIS_ LPDPENUMADDRESSCALLBACK, LPCVOID, DWORD, LPVOID) PURE; + STDMETHOD(EnumAddressTypes) (THIS_ LPDPLENUMADDRESSTYPESCALLBACK, REFGUID, LPVOID, DWORD) PURE; + STDMETHOD(EnumLocalApplications)(THIS_ LPDPLENUMLOCALAPPLICATIONSCALLBACK, LPVOID, DWORD) PURE; + STDMETHOD(GetConnectionSettings)(THIS_ DWORD, LPVOID, LPDWORD) PURE; + STDMETHOD(ReceiveLobbyMessage) (THIS_ DWORD, DWORD, LPDWORD, LPVOID, LPDWORD) PURE; + STDMETHOD(RunApplication) (THIS_ DWORD, LPDWORD, LPDPLCONNECTION, HANDLE) PURE; + STDMETHOD(SendLobbyMessage) (THIS_ DWORD, DWORD, LPVOID, DWORD) PURE; + STDMETHOD(SetConnectionSettings)(THIS_ DWORD, DWORD, LPDPLCONNECTION) PURE; + STDMETHOD(SetLobbyMessageEvent) (THIS_ DWORD, DWORD, HANDLE) PURE; + + /* IDirectPlayLobby2 Methods */ + STDMETHOD(CreateCompoundAddress)(THIS_ LPCDPCOMPOUNDADDRESSELEMENT,DWORD,LPVOID,LPDWORD) PURE; +}; + +/**************************************************************************** + * + * IDirectPlayLobby3 (and IDirectPlayLobby3A) Interface + * + ****************************************************************************/ +#undef INTERFACE +#define INTERFACE IDirectPlayLobby3 +DECLARE_INTERFACE_( IDirectPlayLobby3, IDirectPlayLobby ) +{ + /* IUnknown Methods */ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /* IDirectPlayLobby Methods */ + STDMETHOD(Connect) (THIS_ DWORD, LPDIRECTPLAY2 *, IUnknown FAR *) PURE; + STDMETHOD(CreateAddress) (THIS_ REFGUID, REFGUID, LPCVOID, DWORD, LPVOID, LPDWORD) PURE; + STDMETHOD(EnumAddress) (THIS_ LPDPENUMADDRESSCALLBACK, LPCVOID, DWORD, LPVOID) PURE; + STDMETHOD(EnumAddressTypes) (THIS_ LPDPLENUMADDRESSTYPESCALLBACK, REFGUID, LPVOID, DWORD) PURE; + STDMETHOD(EnumLocalApplications)(THIS_ LPDPLENUMLOCALAPPLICATIONSCALLBACK, LPVOID, DWORD) PURE; + STDMETHOD(GetConnectionSettings)(THIS_ DWORD, LPVOID, LPDWORD) PURE; + STDMETHOD(ReceiveLobbyMessage) (THIS_ DWORD, DWORD, LPDWORD, LPVOID, LPDWORD) PURE; + STDMETHOD(RunApplication) (THIS_ DWORD, LPDWORD, LPDPLCONNECTION, HANDLE) PURE; + STDMETHOD(SendLobbyMessage) (THIS_ DWORD, DWORD, LPVOID, DWORD) PURE; + STDMETHOD(SetConnectionSettings)(THIS_ DWORD, DWORD, LPDPLCONNECTION) PURE; + STDMETHOD(SetLobbyMessageEvent) (THIS_ DWORD, DWORD, HANDLE) PURE; + + /* IDirectPlayLobby2 Methods */ + STDMETHOD(CreateCompoundAddress)(THIS_ LPCDPCOMPOUNDADDRESSELEMENT,DWORD,LPVOID,LPDWORD) PURE; + + /* IDirectPlayLobby3 Methods */ + STDMETHOD(ConnectEx) (THIS_ DWORD, REFIID, LPVOID *, IUnknown FAR *) PURE; + STDMETHOD(RegisterApplication) (THIS_ DWORD, LPVOID) PURE; + STDMETHOD(UnregisterApplication)(THIS_ DWORD, REFGUID) PURE; + STDMETHOD(WaitForConnectionSettings)(THIS_ DWORD) PURE; +}; + +/**************************************************************************** + * + * IDirectPlayLobby interface macros + * + ****************************************************************************/ + +#if !defined(__cplusplus) || defined(CINTERFACE) + +#define IDirectPlayLobby_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlayLobby_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlayLobby_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlayLobby_Connect(p,a,b,c) (p)->lpVtbl->Connect(p,a,b,c) +#define IDirectPlayLobby_ConnectEx(p,a,b,c,d) (p)->lpVtbl->ConnectEx(p,a,b,c,d) +#define IDirectPlayLobby_CreateAddress(p,a,b,c,d,e,f) (p)->lpVtbl->CreateAddress(p,a,b,c,d,e,f) +#define IDirectPlayLobby_CreateCompoundAddress(p,a,b,c,d) (p)->lpVtbl->CreateCompoundAddress(p,a,b,c,d) +#define IDirectPlayLobby_EnumAddress(p,a,b,c,d) (p)->lpVtbl->EnumAddress(p,a,b,c,d) +#define IDirectPlayLobby_EnumAddressTypes(p,a,b,c,d) (p)->lpVtbl->EnumAddressTypes(p,a,b,c,d) +#define IDirectPlayLobby_EnumLocalApplications(p,a,b,c) (p)->lpVtbl->EnumLocalApplications(p,a,b,c) +#define IDirectPlayLobby_GetConnectionSettings(p,a,b,c) (p)->lpVtbl->GetConnectionSettings(p,a,b,c) +#define IDirectPlayLobby_ReceiveLobbyMessage(p,a,b,c,d,e) (p)->lpVtbl->ReceiveLobbyMessage(p,a,b,c,d,e) +#define IDirectPlayLobby_RegisterApplication(p,a,b) (p)->lpVtbl->RegisterApplication(p,a,b) +#define IDirectPlayLobby_RunApplication(p,a,b,c,d) (p)->lpVtbl->RunApplication(p,a,b,c,d) +#define IDirectPlayLobby_SendLobbyMessage(p,a,b,c,d) (p)->lpVtbl->SendLobbyMessage(p,a,b,c,d) +#define IDirectPlayLobby_SetConnectionSettings(p,a,b,c) (p)->lpVtbl->SetConnectionSettings(p,a,b,c) +#define IDirectPlayLobby_SetLobbyMessageEvent(p,a,b,c) (p)->lpVtbl->SetLobbyMessageEvent(p,a,b,c) +#define IDirectPlayLobby_UnregisterApplication(p,a,b) (p)->lpVtbl->UnregisterApplication(p,a,b) +#define IDirectPlayLobby_WaitForConnectionSettings(p,a) (p)->lpVtbl->WaitForConnectionSettings(p,a) + +#else /* C++ */ + +#define IDirectPlayLobby_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlayLobby_AddRef(p) (p)->AddRef() +#define IDirectPlayLobby_Release(p) (p)->Release() +#define IDirectPlayLobby_Connect(p,a,b,c) (p)->Connect(a,b,c) +#define IDirectPlayLobby_ConnectEx(p,a,b,c,d) (p)->ConnectEx(a,b,c,d) +#define IDirectPlayLobby_CreateAddress(p,a,b,c,d,e,f) (p)->CreateAddress(a,b,c,d,e,f) +#define IDirectPlayLobby_CreateCompoundAddress(p,a,b,c,d) (p)->CreateCompoundAddress(a,b,c,d) +#define IDirectPlayLobby_EnumAddress(p,a,b,c,d) (p)->EnumAddress(a,b,c,d) +#define IDirectPlayLobby_EnumAddressTypes(p,a,b,c,d) (p)->EnumAddressTypes(a,b,c,d) +#define IDirectPlayLobby_EnumLocalApplications(p,a,b,c) (p)->EnumLocalApplications(a,b,c) +#define IDirectPlayLobby_GetConnectionSettings(p,a,b,c) (p)->GetConnectionSettings(a,b,c) +#define IDirectPlayLobby_ReceiveLobbyMessage(p,a,b,c,d,e) (p)->ReceiveLobbyMessage(a,b,c,d,e) +#define IDirectPlayLobby_RegisterApplication(p,a,b) (p)->RegisterApplication(a,b) +#define IDirectPlayLobby_RunApplication(p,a,b,c,d) (p)->RunApplication(a,b,c,d) +#define IDirectPlayLobby_SendLobbyMessage(p,a,b,c,d) (p)->SendLobbyMessage(a,b,c,d) +#define IDirectPlayLobby_SetConnectionSettings(p,a,b,c) (p)->SetConnectionSettings(a,b,c) +#define IDirectPlayLobby_SetLobbyMessageEvent(p,a,b,c) (p)->SetLobbyMessageEvent(a,b,c) +#define IDirectPlayLobby_UnregisterApplication(p,a,b) (p)->UnregisterApplication(a,b) +#define IDirectPlayLobby_WaitForConnectionSettings(p,a) (p)->WaitForConnectionSettings(a) + +#endif + +/**************************************************************************** + * + * DirectPlayLobby Flags + * + ****************************************************************************/ + +/* + * This flag is used by IDirectPlayLobby->WaitForConnectionSettings to + * cancel a current wait that is in progress. + */ +#define DPLWAIT_CANCEL 0x00000001 + + +/* + * This is a message flag used by ReceiveLobbyMessage. It can be + * returned in the dwMessageFlags parameter to indicate a message from + * the system. + */ +#define DPLMSG_SYSTEM 0x00000001 + +/* + * This is a message flag used by ReceiveLobbyMessage and SendLobbyMessage. + * It is used to indicate that the message is a standard lobby message. + * DPLMSG_SETPROPERTY, DPLMSG_SETPROPERTYRESPONSE, DPLMSG_GETPROPERTY, + * DPLMSG_GETPROPERTYRESPONSE + */ +#define DPLMSG_STANDARD 0x00000002 + +/* + * Lobbyable Application registration flags + */ + +/* + * Applications registered with this flag will not show up when + * applications are enumerated in the lobby. This application + * will only be able to be launched by a lobby client that already + * knows about the application. + */ +#define DPLAPP_NOENUM 0x80000000 + +/* + * Applications registered with this flag want voice to automatically + * be enabled for their application. All players will be launched into + * an 'n'-way voice conference when the application is started. The + * user will be able to enable this flag for existing non-voice + * directplay applications. + */ +#define DPLAPP_AUTOVOICE 0x00000001 + +/* + * Applications that do their own voice conferencing should register with + * this flag to avoid allowing the user to enable other voice chat + * capabilites during the same session. This is to avoid users forcing + * the DPLAPP_AUTOVOICE flag for the application. + */ +#define DPLAPP_SELFVOICE 0x00000002 + +/**************************************************************************** + * + * DirectPlayLobby messages and message data structures + * + * All system messages have a dwMessageFlags value of DPLMSG_SYSTEM returned + * from a call to ReceiveLobbyMessage. + * + * All standard messages have a dwMessageFlags value of DPLMSG_STANDARD returned + * from a call to ReceiveLobbyMessage. + * + ****************************************************************************/ + +/* + * DPLMSG_GENERIC + * Generic message structure used to identify the message type. + */ +typedef struct _DPLMSG_GENERIC +{ + DWORD dwType; // Message type +} DPLMSG_GENERIC, FAR *LPDPLMSG_GENERIC; + +/* + * DPLMSG_SYSTEMMESSAGE + * Generic message format for all system messages -- + * DPLSYS_CONNECTIONSETTINGSREAD, DPLSYS_DPLYCONNECTSUCCEEDED, + * DPLSYS_DPLAYCONNECTFAILED, DPLSYS_APPTERMINATED, DPLSYS_NEWCONNECTIONSETTINGS + */ +typedef struct _DPLMSG_SYSTEMMESSAGE +{ + DWORD dwType; // Message type + GUID guidInstance; // Instance GUID of the dplay session the message corresponds to +} DPLMSG_SYSTEMMESSAGE, FAR *LPDPLMSG_SYSTEMMESSAGE; + +/* + * DPLMSG_SETPROPERTY + * Standard message sent by an application to a lobby to set a + * property + */ +typedef struct _DPLMSG_SETPROPERTY +{ + DWORD dwType; // Message type + DWORD dwRequestID; // Request ID (DPL_NOCONFIRMATION if no confirmation desired) + GUID guidPlayer; // Player GUID + GUID guidPropertyTag; // Property GUID + DWORD dwDataSize; // Size of data + DWORD dwPropertyData[1]; // Buffer containing data +} DPLMSG_SETPROPERTY, FAR *LPDPLMSG_SETPROPERTY; + +#define DPL_NOCONFIRMATION 0 + +/* + * DPLMSG_SETPROPERTYRESPONSE + * Standard message returned by a lobby to confirm a + * DPLMSG_SETPROPERTY message. + */ +typedef struct _DPLMSG_SETPROPERTYRESPONSE +{ + DWORD dwType; // Message type + DWORD dwRequestID; // Request ID + GUID guidPlayer; // Player GUID + GUID guidPropertyTag; // Property GUID + HRESULT hr; // Return Code +} DPLMSG_SETPROPERTYRESPONSE, FAR *LPDPLMSG_SETPROPERTYRESPONSE; + +/* + * DPLMSG_GETPROPERTY + * Standard message sent by an application to a lobby to request + * the current value of a property + */ +typedef struct _DPLMSG_GETPROPERTY +{ + DWORD dwType; // Message type + DWORD dwRequestID; // Request ID + GUID guidPlayer; // Player GUID + GUID guidPropertyTag; // Property GUID +} DPLMSG_GETPROPERTY, FAR *LPDPLMSG_GETPROPERTY; + +/* + * DPLMSG_GETPROPERTYRESPONSE + * Standard message returned by a lobby in response to a + * DPLMSG_GETPROPERTY message. + */ +typedef struct _DPLMSG_GETPROPERTYRESPONSE +{ + DWORD dwType; // Message type + DWORD dwRequestID; // Request ID + GUID guidPlayer; // Player GUID + GUID guidPropertyTag; // Property GUID + HRESULT hr; // Return Code + DWORD dwDataSize; // Size of data + DWORD dwPropertyData[1]; // Buffer containing data +} DPLMSG_GETPROPERTYRESPONSE, FAR *LPDPLMSG_GETPROPERTYRESPONSE; + +/* + * DPLMSG_NEWSESSIONHOST + * Standard message returned by a lobby in response to a + * the session host migrating to a new client + */ +typedef struct _DPLMSG_NEWSESSIONHOST +{ + DWORD dwType; // Message type + GUID guidInstance; // GUID Instance of the session +} DPLMSG_NEWSESSIONHOST, FAR *LPDPLMSG_NEWSESSIONHOST; + + +/****************************************** + * + * DirectPlay Lobby message dwType values + * + *****************************************/ + +/* + * The application has read the connection settings. + * It is now O.K. for the lobby client to release + * its IDirectPlayLobby interface. + */ +#define DPLSYS_CONNECTIONSETTINGSREAD 0x00000001 + +/* + * The application's call to DirectPlayConnect failed + */ +#define DPLSYS_DPLAYCONNECTFAILED 0x00000002 + +/* + * The application has created a DirectPlay session. + */ +#define DPLSYS_DPLAYCONNECTSUCCEEDED 0x00000003 + +/* + * The application has terminated. + */ +#define DPLSYS_APPTERMINATED 0x00000004 + +/* + * The message is a DPLMSG_SETPROPERTY message. + */ +#define DPLSYS_SETPROPERTY 0x00000005 + +/* + * The message is a DPLMSG_SETPROPERTYRESPONSE message. + */ +#define DPLSYS_SETPROPERTYRESPONSE 0x00000006 + +/* + * The message is a DPLMSG_GETPROPERTY message. + */ +#define DPLSYS_GETPROPERTY 0x00000007 + +/* + * The message is a DPLMSG_GETPROPERTYRESPONSE message. + */ +#define DPLSYS_GETPROPERTYRESPONSE 0x00000008 + +/* + * The message is a DPLMSG_NEWSESSIONHOST message. + */ +#define DPLSYS_NEWSESSIONHOST 0x00000009 + +/* + * New connection settings are available. + */ +#define DPLSYS_NEWCONNECTIONSETTINGS 0x0000000A + +/* + * The Lobby Client has released the DirectPlayLobby Interface + */ +#define DPLSYS_LOBBYCLIENTRELEASE 0x0000000B + +/**************************************************************************** + * + * DirectPlay defined property GUIDs and associated data structures + * + ****************************************************************************/ + +/* + * DPLPROPERTY_MessagesSupported + * + * Request whether the lobby supports standard. Lobby with respond with either + * TRUE or FALSE or may not respond at all. + * + * Property data is a single BOOL with TRUE or FALSE + */ +// {762CCDA1-D916-11d0-BA39-00C04FD7ED67} +DEFINE_GUID(DPLPROPERTY_MessagesSupported, +0x762ccda1, 0xd916, 0x11d0, 0xba, 0x39, 0x0, 0xc0, 0x4f, 0xd7, 0xed, 0x67); + +/* + * DPLPROPERTY_LobbyGuid + * + * Request the GUID that identifies the lobby software that the application + * is communicating with. + * + * Property data is a single GUID. + */ +// {F56920A0-D218-11d0-BA39-00C04FD7ED67} +DEFINE_GUID(DPLPROPERTY_LobbyGuid, +0xf56920a0, 0xd218, 0x11d0, 0xba, 0x39, 0x0, 0xc0, 0x4f, 0xd7, 0xed, 0x67); + +/* + * DPLPROPERTY_PlayerGuid + * + * Request the GUID that identifies the player on this machine for sending + * property data back to the lobby. + * + * Property data is the DPLDATA_PLAYERDATA structure + */ +// {B4319322-D20D-11d0-BA39-00C04FD7ED67} +DEFINE_GUID(DPLPROPERTY_PlayerGuid, +0xb4319322, 0xd20d, 0x11d0, 0xba, 0x39, 0x0, 0xc0, 0x4f, 0xd7, 0xed, 0x67); + +/* + * DPLDATA_PLAYERGUID + * + * Data structure to hold the GUID of the player and player creation flags + * from the lobby. + */ +typedef struct _DPLDATA_PLAYERGUID +{ + GUID guidPlayer; + DWORD dwPlayerFlags; +} DPLDATA_PLAYERGUID, FAR *LPDPLDATA_PLAYERGUID; + +/* + * DPLPROPERTY_PlayerScore + * + * Used to send an array of long integers to the lobby indicating the + * score of a player. + * + * Property data is the DPLDATA_PLAYERSCORE structure. + */ +// {48784000-D219-11d0-BA39-00C04FD7ED67} +DEFINE_GUID(DPLPROPERTY_PlayerScore, +0x48784000, 0xd219, 0x11d0, 0xba, 0x39, 0x0, 0xc0, 0x4f, 0xd7, 0xed, 0x67); + +/* + * DPLDATA_PLAYERSCORE + * + * Data structure to hold an array of long integers representing a player score. + * Application must allocate enough memory to hold all the scores. + */ +typedef struct _DPLDATA_PLAYERSCORE +{ + DWORD dwScoreCount; + LONG Score[1]; +} DPLDATA_PLAYERSCORE, FAR *LPDPLDATA_PLAYERSCORE; + +/**************************************************************************** + * + * DirectPlay Address ID's + * + ****************************************************************************/ + +/* DirectPlay Address + * + * A DirectPlay address consists of multiple chunks of data, each tagged + * with a GUID signifying the type of data in the chunk. The chunk also + * has a length so that unknown chunk types can be skipped. + * + * The EnumAddress() function is used to parse these address data chunks. + */ + +/* + * DPADDRESS + * + * Header for block of address data elements + */ +typedef struct _DPADDRESS +{ + GUID guidDataType; + DWORD dwDataSize; +} DPADDRESS; + +typedef DPADDRESS FAR *LPDPADDRESS; + +/* + * DPAID_TotalSize + * + * Chunk is a DWORD containing size of entire DPADDRESS structure + */ + +// {1318F560-912C-11d0-9DAA-00A0C90A43CB} +DEFINE_GUID(DPAID_TotalSize, +0x1318f560, 0x912c, 0x11d0, 0x9d, 0xaa, 0x0, 0xa0, 0xc9, 0xa, 0x43, 0xcb); + +/* + * DPAID_ServiceProvider + * + * Chunk is a GUID describing the service provider that created the chunk. + * All addresses must contain this chunk. + */ + +// {07D916C0-E0AF-11cf-9C4E-00A0C905425E} +DEFINE_GUID(DPAID_ServiceProvider, +0x7d916c0, 0xe0af, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); + +/* + * DPAID_LobbyProvider + * + * Chunk is a GUID describing the lobby provider that created the chunk. + * All addresses must contain this chunk. + */ + +// {59B95640-9667-11d0-A77D-0000F803ABFC} +DEFINE_GUID(DPAID_LobbyProvider, +0x59b95640, 0x9667, 0x11d0, 0xa7, 0x7d, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc); + +/* + * DPAID_Phone and DPAID_PhoneW + * + * Chunk is a string containing a phone number (i.e. "1-800-555-1212") + * in ANSI or UNICODE format + */ + +// {78EC89A0-E0AF-11cf-9C4E-00A0C905425E} +DEFINE_GUID(DPAID_Phone, +0x78ec89a0, 0xe0af, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); + +// {BA5A7A70-9DBF-11d0-9CC1-00A0C905425E} +DEFINE_GUID(DPAID_PhoneW, +0xba5a7a70, 0x9dbf, 0x11d0, 0x9c, 0xc1, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); + +/* + * DPAID_Modem and DPAID_ModemW + * + * Chunk is a string containing a modem name registered with TAPI + * in ANSI or UNICODE format + */ + +// {F6DCC200-A2FE-11d0-9C4F-00A0C905425E} +DEFINE_GUID(DPAID_Modem, +0xf6dcc200, 0xa2fe, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); + +// {01FD92E0-A2FF-11d0-9C4F-00A0C905425E} +DEFINE_GUID(DPAID_ModemW, +0x1fd92e0, 0xa2ff, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); + +/* + * DPAID_Inet and DPAID_InetW + * + * Chunk is a string containing a TCP/IP host name or an IP address + * (i.e. "dplay.microsoft.com" or "137.55.100.173") in ANSI or UNICODE format + */ + +// {C4A54DA0-E0AF-11cf-9C4E-00A0C905425E} +DEFINE_GUID(DPAID_INet, +0xc4a54da0, 0xe0af, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); + +// {E63232A0-9DBF-11d0-9CC1-00A0C905425E} +DEFINE_GUID(DPAID_INetW, +0xe63232a0, 0x9dbf, 0x11d0, 0x9c, 0xc1, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); + +/* + * DPAID_InetPort + * + * Chunk is the port number used for creating the apps TCP and UDP sockets. + * WORD value (i.e. 47624). + */ + +// {E4524541-8EA5-11d1-8A96-006097B01411} +DEFINE_GUID(DPAID_INetPort, +0xe4524541, 0x8ea5, 0x11d1, 0x8a, 0x96, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); + +#ifdef BIGMESSAGEDEFENSE +#endif + +/* + * DPCOMPORTADDRESS + * + * Used to specify com port settings. The constants that define baud rate, + * stop bits and parity are defined in WINBASE.H. The constants for flow + * control are given below. + */ + +#define DPCPA_NOFLOW 0 // no flow control +#define DPCPA_XONXOFFFLOW 1 // software flow control +#define DPCPA_RTSFLOW 2 // hardware flow control with RTS +#define DPCPA_DTRFLOW 3 // hardware flow control with DTR +#define DPCPA_RTSDTRFLOW 4 // hardware flow control with RTS and DTR + +typedef struct _DPCOMPORTADDRESS +{ + DWORD dwComPort; // COM port to use (1-4) + DWORD dwBaudRate; // baud rate (100-256k) + DWORD dwStopBits; // no. stop bits (1-2) + DWORD dwParity; // parity (none, odd, even, mark) + DWORD dwFlowControl; // flow control (none, xon/xoff, rts, dtr) +} DPCOMPORTADDRESS; + +typedef DPCOMPORTADDRESS FAR *LPDPCOMPORTADDRESS; + +/* + * DPAID_ComPort + * + * Chunk contains a DPCOMPORTADDRESS structure defining the serial port. + */ + +// {F2F0CE00-E0AF-11cf-9C4E-00A0C905425E} +DEFINE_GUID(DPAID_ComPort, +0xf2f0ce00, 0xe0af, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e); + +/**************************************************************************** + * + * dplobby 1.0 obsolete definitions + * Included for compatibility only. + * + ****************************************************************************/ +#define DPLAD_SYSTEM DPLMSG_SYSTEM + + +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#pragma warning(default:4201) + +#endif /* __DPLOBBY_INCLUDED__ */ + diff --git a/src/dep/include/DXSDK/include/dplobby8.h b/src/dep/include/DXSDK/include/dplobby8.h index 31f7bf8..e63a5aa 100644 --- a/src/dep/include/DXSDK/include/dplobby8.h +++ b/src/dep/include/DXSDK/include/dplobby8.h @@ -1,407 +1,407 @@ -/*========================================================================== - * - * Copyright (C) 2000 Microsoft Corporation. All Rights Reserved. - * - * File: DPLobby.h - * Content: DirectPlay8 Lobby Include File - * - ***************************************************************************/ - -#ifndef __DPLOBBY_H__ -#define __DPLOBBY_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/**************************************************************************** - * - * DirectPlay8Lobby CLSIDs - * - ****************************************************************************/ - -// {667955AD-6B3B-43ca-B949-BC69B5BAFF7F} -DEFINE_GUID(CLSID_DirectPlay8LobbiedApplication, -0x667955ad, 0x6b3b, 0x43ca, 0xb9, 0x49, 0xbc, 0x69, 0xb5, 0xba, 0xff, 0x7f); - -// {3B2B6775-70B6-45af-8DEA-A209C69559F3} -DEFINE_GUID(CLSID_DirectPlay8LobbyClient, -0x3b2b6775, 0x70b6, 0x45af, 0x8d, 0xea, 0xa2, 0x9, 0xc6, 0x95, 0x59, 0xf3); - -/**************************************************************************** - * - * DirectPlay8Lobby Interface IIDs - * - ****************************************************************************/ - -// {819074A3-016C-11d3-AE14-006097B01411} -DEFINE_GUID(IID_IDirectPlay8LobbiedApplication, -0x819074a3, 0x16c, 0x11d3, 0xae, 0x14, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); - -// {819074A2-016C-11d3-AE14-006097B01411} -DEFINE_GUID(IID_IDirectPlay8LobbyClient, -0x819074a2, 0x16c, 0x11d3, 0xae, 0x14, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); - -/**************************************************************************** - * - * DirectPlay8Lobby Interface Pointer - * - ****************************************************************************/ - -typedef struct IDirectPlay8LobbiedApplication *PDIRECTPLAY8LOBBIEDAPPLICATION; -typedef struct IDirectPlay8LobbyClient *PDIRECTPLAY8LOBBYCLIENT; - -/**************************************************************************** - * - * DirectPlay8 Lobby Message IDs - * - ****************************************************************************/ - -#define DPL_MSGID_LOBBY 0x8000 -#define DPL_MSGID_RECEIVE (0x0001 | DPL_MSGID_LOBBY) -#define DPL_MSGID_CONNECT (0x0002 | DPL_MSGID_LOBBY) -#define DPL_MSGID_DISCONNECT (0x0003 | DPL_MSGID_LOBBY) -#define DPL_MSGID_SESSION_STATUS (0x0004 | DPL_MSGID_LOBBY) -#define DPL_MSGID_CONNECTION_SETTINGS (0x0005 | DPL_MSGID_LOBBY) - -/**************************************************************************** - * - * DirectPlay8Lobby Constants - * - ****************************************************************************/ - -// -// Specifies that operation should be performed on all open connections -// -#define DPLHANDLE_ALLCONNECTIONS 0xFFFFFFFF - -// -// The associated game session has suceeded in connecting / hosting -// -#define DPLSESSION_CONNECTED 0x0001 - -// The associated game session failed connecting / hosting -// -#define DPLSESSION_COULDNOTCONNECT 0x0002 - -// -// The associated game session has disconnected -// -#define DPLSESSION_DISCONNECTED 0x0003 - -// -// The associated game session has terminated -// -#define DPLSESSION_TERMINATED 0x0004 - -// -// The associated game session's host has migrated -// -#define DPLSESSION_HOSTMIGRATED 0x0005 - -// -// The associated game session's host has migrated to the local client -// -#define DPLSESSION_HOSTMIGRATEDHERE 0x0006 - - -/**************************************************************************** - * - * DirectPlay8 Lobby Flags - * - ****************************************************************************/ - -// -// Do not automatically make the lobby app unavailable when a connection is established -// -#define DPLAVAILABLE_ALLOWMULTIPLECONNECT 0x0001 - -// -// Launch a new instance of the application to connect to -// -#define DPLCONNECT_LAUNCHNEW 0x0001 - -// -// Launch a new instance of the application if one is not waiting -// -#define DPLCONNECT_LAUNCHNOTFOUND 0x0002 - -// -// When starting the associated game session, start it as a host -// -#define DPLCONNECTSETTINGS_HOST 0x0001 - -// -// Disable parameter validation -// -#define DPLINITIALIZE_DISABLEPARAMVAL 0x0001 - -/**************************************************************************** - * - * DirectPlay8Lobby Structures (Non-Message) - * - ****************************************************************************/ - -// -// Information on a registered game -// -typedef struct _DPL_APPLICATION_INFO { - GUID guidApplication; // GUID of the application - PWSTR pwszApplicationName; // Name of the application - DWORD dwNumRunning; // # of instances of this application running - DWORD dwNumWaiting; // # of instances of this application waiting - DWORD dwFlags; // Flags -} DPL_APPLICATION_INFO, *PDPL_APPLICATION_INFO; - -// -// Settings to be used for connecting / hosting a game session -// -typedef struct _DPL_CONNECTION_SETTINGS { - DWORD dwSize; // Size of this structure - DWORD dwFlags; // Connection settings flags (DPLCONNECTSETTINGS_...) - DPN_APPLICATION_DESC dpnAppDesc; // Application desc for the associated DirectPlay session - IDirectPlay8Address *pdp8HostAddress; // Address of host to connect to - IDirectPlay8Address **ppdp8DeviceAddresses; // Address of device to connect from / host on - DWORD cNumDeviceAddresses; // # of addresses specified in ppdp8DeviceAddresses - PWSTR pwszPlayerName; // Name to give the player -} DPL_CONNECTION_SETTINGS, *PDPL_CONNECTION_SETTINGS; - -// -// Information for performing a lobby connect -// (ConnectApplication) -// -typedef struct _DPL_CONNECT_INFO { - DWORD dwSize; // Size of this structure - DWORD dwFlags; // Flags (DPLCONNECT_...) - GUID guidApplication; // GUID of application to launch - PDPL_CONNECTION_SETTINGS pdplConnectionSettings; - // Settings application should use - PVOID pvLobbyConnectData; // User defined data block - DWORD dwLobbyConnectDataSize; - // Size of user defined data block -} DPL_CONNECT_INFO, *PDPL_CONNECT_INFO; - -// -// Information for registering an application -// (RegisterApplication) -// -typedef struct _DPL_PROGRAM_DESC { - DWORD dwSize; - DWORD dwFlags; - GUID guidApplication; // Application GUID - PWSTR pwszApplicationName; // Unicode application name - PWSTR pwszCommandLine; // Unicode command line arguments - PWSTR pwszCurrentDirectory; // Unicode current directory - PWSTR pwszDescription; // Unicode application description - PWSTR pwszExecutableFilename; // Unicode filename of application executable - PWSTR pwszExecutablePath; // Unicode path of application executable - PWSTR pwszLauncherFilename; // Unicode filename of launcher executable - PWSTR pwszLauncherPath; // Unicode path of launcher executable -} DPL_PROGRAM_DESC, *PDPL_PROGRAM_DESC; - -/**************************************************************************** - * - * DirectPlay8 Lobby Message Structures - * - ****************************************************************************/ - -// -// A connection was established -// (DPL_MSGID_CONNECT) -// -typedef struct _DPL_MESSAGE_CONNECT -{ - DWORD dwSize; // Size of this structure - DPNHANDLE hConnectId; // Handle of new connection - PDPL_CONNECTION_SETTINGS pdplConnectionSettings; // Connection settings for this connection - PVOID pvLobbyConnectData; // User defined lobby data block - DWORD dwLobbyConnectDataSize; // Size of user defined lobby data block - PVOID pvConnectionContext; // Context value for this connection (user set) -} DPL_MESSAGE_CONNECT, *PDPL_MESSAGE_CONNECT; - -// -// Connection settings have been updated -// (DPL_MSGID_CONNECTION_SETTINGS) -// -typedef struct _DPL_MESSAGE_CONNECTION_SETTINGS -{ - DWORD dwSize; // Size of this structure - DPNHANDLE hSender; // Handle of the connection for these settings - PDPL_CONNECTION_SETTINGS pdplConnectionSettings; // Connection settings - PVOID pvConnectionContext; // Context value for this connection -} DPL_MESSAGE_CONNECTION_SETTINGS, *PDPL_MESSAGE_CONNECTION_SETTINGS; - -// -// A connection has been disconnected -// (DPL_MSGID_DISCONNECT) -// -typedef struct _DPL_MESSAGE_DISCONNECT -{ - DWORD dwSize; // Size of this structure - DPNHANDLE hDisconnectId; // Handle of the connection that was terminated - HRESULT hrReason; // Reason the connection was broken - PVOID pvConnectionContext; // Context value for this connection -} DPL_MESSAGE_DISCONNECT, *PDPL_MESSAGE_DISCONNECT; - -// -// Data was received through a connection -// (DPL_MSGID_RECEIVE) -// -typedef struct _DPL_MESSAGE_RECEIVE -{ - DWORD dwSize; // Size of this structure - DPNHANDLE hSender; // Handle of the connection that is from - BYTE *pBuffer; // Contents of the message - DWORD dwBufferSize; // Size of the message context - PVOID pvConnectionContext; // Context value for this connection -} DPL_MESSAGE_RECEIVE, *PDPL_MESSAGE_RECEIVE; - -// -// Current status of the associated connection -// (DPL_MSGID_SESSION_STATUS) -// -typedef struct _DPL_MESSAGE_SESSION_STATUS -{ - DWORD dwSize; // Size of this structure - DPNHANDLE hSender; // Handle of the connection that this is from - DWORD dwStatus; // Status (DPLSESSION_...) - PVOID pvConnectionContext; // Context value for this connection -} DPL_MESSAGE_SESSION_STATUS, *PDPL_MESSAGE_SESSION_STATUS; - -/**************************************************************************** - * - * DirectPlay8Lobby Create - * - ****************************************************************************/ - -/* - * This function is no longer supported. It is recommended that CoCreateInstance be used to create - * DirectPlay8 lobby objects. - * - * extern HRESULT WINAPI DirectPlay8LobbyCreate( const GUID * pcIID, void **ppvInterface, IUnknown *pUnknown); - * - */ - -/**************************************************************************** - * - * DirectPlay8 Functions - * - ****************************************************************************/ - -// -// COM definition for DirectPlayLobbyClient -// -#undef INTERFACE // External COM Implementation -#define INTERFACE IDirectPlay8LobbyClient -DECLARE_INTERFACE_(IDirectPlay8LobbyClient,IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - // IDirectPlayLobbyClient methods - STDMETHOD(Initialize) (THIS_ const PVOID pvUserContext,const PFNDPNMESSAGEHANDLER pfn,const DWORD dwFlags) PURE; - STDMETHOD(EnumLocalPrograms) (THIS_ GUID *const pGuidApplication,BYTE *const pEnumData,DWORD *const pdwEnumData,DWORD *const pdwItems, const DWORD dwFlags) PURE; - STDMETHOD(ConnectApplication) (THIS_ DPL_CONNECT_INFO *const pdplConnectionInfo,const PVOID pvConnectionContext,DPNHANDLE *const hApplication,const DWORD dwTimeOut,const DWORD dwFlags) PURE; - STDMETHOD(Send) (THIS_ const DPNHANDLE hConnection,BYTE *const pBuffer,const DWORD pBufferSize,const DWORD dwFlags) PURE; - STDMETHOD(ReleaseApplication) (THIS_ const DPNHANDLE hConnection, const DWORD dwFlags ) PURE; - STDMETHOD(Close) (THIS_ const DWORD dwFlags ) PURE; - STDMETHOD(GetConnectionSettings) (THIS_ const DPNHANDLE hConnection, DPL_CONNECTION_SETTINGS * const pdplSessionInfo, DWORD *pdwInfoSize, const DWORD dwFlags ) PURE; - STDMETHOD(SetConnectionSettings) (THIS_ const DPNHANDLE hConnection, const DPL_CONNECTION_SETTINGS * const pdplSessionInfo, const DWORD dwFlags ) PURE; -}; - - -// -// COM definition for DirectPlayLobbiedApplication -// -#undef INTERFACE // External COM Implementation -#define INTERFACE IDirectPlay8LobbiedApplication -DECLARE_INTERFACE_(IDirectPlay8LobbiedApplication,IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID *ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - // IDirectPlayLobbiedApplication methods - STDMETHOD(Initialize) (THIS_ const PVOID pvUserContext,const PFNDPNMESSAGEHANDLER pfn,DPNHANDLE * const pdpnhConnection, const DWORD dwFlags) PURE; - STDMETHOD(RegisterProgram) (THIS_ PDPL_PROGRAM_DESC pdplProgramDesc,const DWORD dwFlags) PURE; - STDMETHOD(UnRegisterProgram) (THIS_ GUID *pguidApplication,const DWORD dwFlags) PURE; - STDMETHOD(Send) (THIS_ const DPNHANDLE hConnection,BYTE *const pBuffer,const DWORD pBufferSize,const DWORD dwFlags) PURE; - STDMETHOD(SetAppAvailable) (THIS_ const BOOL fAvailable, const DWORD dwFlags ) PURE; - STDMETHOD(UpdateStatus) (THIS_ const DPNHANDLE hConnection, const DWORD dwStatus, const DWORD dwFlags ) PURE; - STDMETHOD(Close) (THIS_ const DWORD dwFlags ) PURE; - STDMETHOD(GetConnectionSettings) (THIS_ const DPNHANDLE hConnection, DPL_CONNECTION_SETTINGS * const pdplSessionInfo, DWORD *pdwInfoSize, const DWORD dwFlags ) PURE; - STDMETHOD(SetConnectionSettings) (THIS_ const DPNHANDLE hConnection, const DPL_CONNECTION_SETTINGS * const pdplSessionInfo, const DWORD dwFlags ) PURE; -}; - - -/**************************************************************************** - * - * DirectPlayLobby Interface Macros - * - ****************************************************************************/ - -#if !defined(__cplusplus) || defined(CINTERFACE) - -#define IDirectPlay8LobbyClient_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlay8LobbyClient_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlay8LobbyClient_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlay8LobbyClient_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectPlay8LobbyClient_EnumLocalPrograms(p,a,b,c,d,e) (p)->lpVtbl->EnumLocalPrograms(p,a,b,c,d,e) -#define IDirectPlay8LobbyClient_ConnectApplication(p,a,b,c,d,e) (p)->lpVtbl->ConnectApplication(p,a,b,c,d,e) -#define IDirectPlay8LobbyClient_Send(p,a,b,c,d) (p)->lpVtbl->Send(p,a,b,c,d) -#define IDirectPlay8LobbyClient_ReleaseApplication(p,a,b) (p)->lpVtbl->ReleaseApplication(p,a,b) -#define IDirectPlay8LobbyClient_Close(p,a) (p)->lpVtbl->Close(p,a) -#define IDirectPlay8LobbyClient_GetConnectionSettings(p,a,b,c,d) (p)->lpVtbl->GetConnectionSettings(p,a,b,c,d) -#define IDirectPlay8LobbyClient_SetConnectionSettings(p,a,b,c) (p)->lpVtbl->SetConnectionSettings(p,a,b,c) - -#define IDirectPlay8LobbiedApplication_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlay8LobbiedApplication_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlay8LobbiedApplication_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlay8LobbiedApplication_Initialize(p,a,b,c,d) (p)->lpVtbl->Initialize(p,a,b,c,d) -#define IDirectPlay8LobbiedApplication_RegisterProgram(p,a,b) (p)->lpVtbl->RegisterProgram(p,a,b) -#define IDirectPlay8LobbiedApplication_UnRegisterProgram(p,a,b) (p)->lpVtbl->UnRegisterProgram(p,a,b) -#define IDirectPlay8LobbiedApplication_Send(p,a,b,c,d) (p)->lpVtbl->Send(p,a,b,c,d) -#define IDirectPlay8LobbiedApplication_SetAppAvailable(p,a,b) (p)->lpVtbl->SetAppAvailable(p,a,b) -#define IDirectPlay8LobbiedApplication_UpdateStatus(p,a,b,c) (p)->lpVtbl->UpdateStatus(p,a,b,c) -#define IDirectPlay8LobbiedApplication_Close(p,a) (p)->lpVtbl->Close(p,a) -#define IDirectPlay8LobbiedApplication_GetConnectionSettings(p,a,b,c,d) (p)->lpVtbl->GetConnectionSettings(p,a,b,c,d) -#define IDirectPlay8LobbiedApplication_SetConnectionSettings(p,a,b,c) (p)->lpVtbl->SetConnectionSettings(p,a,b,c) - -#else /* C++ */ - -#define IDirectPlay8LobbyClient_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlay8LobbyClient_AddRef(p) (p)->AddRef() -#define IDirectPlay8LobbyClient_Release(p) (p)->Release() -#define IDirectPlay8LobbyClient_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectPlay8LobbyClient_EnumLocalPrograms(p,a,b,c,d,e) (p)->EnumLocalPrograms(a,b,c,d,e) -#define IDirectPlay8LobbyClient_ConnectApplication(p,a,b,c,d,e) (p)->ConnectApplication(a,b,c,d,e) -#define IDirectPlay8LobbyClient_Send(p,a,b,c,d) (p)->Send(a,b,c,d) -#define IDirectPlay8LobbyClient_ReleaseApplication(p,a,b) (p)->ReleaseApplication(a,b) -#define IDirectPlay8LobbyClient_Close(p,a) (p)->Close(a) -#define IDirectPlay8LobbyClient_GetConnectionSettings(p,a,b,c,d) (p)->GetConnectionSettings(a,b,c,d) -#define IDirectPlay8LobbyClient_SetConnectionSettings(p,a,b,c) (p)->SetConnectionSettings(a,b,c) - -#define IDirectPlay8LobbiedApplication_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlay8LobbiedApplication_AddRef(p) (p)->AddRef() -#define IDirectPlay8LobbiedApplication_Release(p) (p)->Release() -#define IDirectPlay8LobbiedApplication_Initialize(p,a,b,c,d) (p)->Initialize(a,b,c,d) -#define IDirectPlay8LobbiedApplication_RegisterProgram(p,a,b) (p)->RegisterProgram(a,b) -#define IDirectPlay8LobbiedApplication_UnRegisterProgram(p,a,b) (p)->UnRegisterProgram(a,b) -#define IDirectPlay8LobbiedApplication_Send(p,a,b,c,d) (p)->Send(a,b,c,d) -#define IDirectPlay8LobbiedApplication_SetAppAvailable(p,a,b) (p)->SetAppAvailable(a,b) -#define IDirectPlay8LobbiedApplication_UpdateStatus(p,a,b,c) (p)->UpdateStatus(a,b,c) -#define IDirectPlay8LobbiedApplication_Close(p,a) (p)->Close(a) -#define IDirectPlay8LobbiedApplication_GetConnectionSettings(p,a,b,c,d) (p)->GetConnectionSettings(a,b,c,d) -#define IDirectPlay8LobbiedApplication_SetConnectionSettings(p,a,b,c) (p)->SetConnectionSettings(a,b,c) - -#endif - -#ifdef __cplusplus -} -#endif - -#endif // __DPLOBBY_H__ - +/*========================================================================== + * + * Copyright (C) 2000 Microsoft Corporation. All Rights Reserved. + * + * File: DPLobby.h + * Content: DirectPlay8 Lobby Include File + * + ***************************************************************************/ + +#ifndef __DPLOBBY_H__ +#define __DPLOBBY_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/**************************************************************************** + * + * DirectPlay8Lobby CLSIDs + * + ****************************************************************************/ + +// {667955AD-6B3B-43ca-B949-BC69B5BAFF7F} +DEFINE_GUID(CLSID_DirectPlay8LobbiedApplication, +0x667955ad, 0x6b3b, 0x43ca, 0xb9, 0x49, 0xbc, 0x69, 0xb5, 0xba, 0xff, 0x7f); + +// {3B2B6775-70B6-45af-8DEA-A209C69559F3} +DEFINE_GUID(CLSID_DirectPlay8LobbyClient, +0x3b2b6775, 0x70b6, 0x45af, 0x8d, 0xea, 0xa2, 0x9, 0xc6, 0x95, 0x59, 0xf3); + +/**************************************************************************** + * + * DirectPlay8Lobby Interface IIDs + * + ****************************************************************************/ + +// {819074A3-016C-11d3-AE14-006097B01411} +DEFINE_GUID(IID_IDirectPlay8LobbiedApplication, +0x819074a3, 0x16c, 0x11d3, 0xae, 0x14, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); + +// {819074A2-016C-11d3-AE14-006097B01411} +DEFINE_GUID(IID_IDirectPlay8LobbyClient, +0x819074a2, 0x16c, 0x11d3, 0xae, 0x14, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11); + +/**************************************************************************** + * + * DirectPlay8Lobby Interface Pointer + * + ****************************************************************************/ + +typedef struct IDirectPlay8LobbiedApplication *PDIRECTPLAY8LOBBIEDAPPLICATION; +typedef struct IDirectPlay8LobbyClient *PDIRECTPLAY8LOBBYCLIENT; + +/**************************************************************************** + * + * DirectPlay8 Lobby Message IDs + * + ****************************************************************************/ + +#define DPL_MSGID_LOBBY 0x8000 +#define DPL_MSGID_RECEIVE (0x0001 | DPL_MSGID_LOBBY) +#define DPL_MSGID_CONNECT (0x0002 | DPL_MSGID_LOBBY) +#define DPL_MSGID_DISCONNECT (0x0003 | DPL_MSGID_LOBBY) +#define DPL_MSGID_SESSION_STATUS (0x0004 | DPL_MSGID_LOBBY) +#define DPL_MSGID_CONNECTION_SETTINGS (0x0005 | DPL_MSGID_LOBBY) + +/**************************************************************************** + * + * DirectPlay8Lobby Constants + * + ****************************************************************************/ + +// +// Specifies that operation should be performed on all open connections +// +#define DPLHANDLE_ALLCONNECTIONS 0xFFFFFFFF + +// +// The associated game session has suceeded in connecting / hosting +// +#define DPLSESSION_CONNECTED 0x0001 + +// The associated game session failed connecting / hosting +// +#define DPLSESSION_COULDNOTCONNECT 0x0002 + +// +// The associated game session has disconnected +// +#define DPLSESSION_DISCONNECTED 0x0003 + +// +// The associated game session has terminated +// +#define DPLSESSION_TERMINATED 0x0004 + +// +// The associated game session's host has migrated +// +#define DPLSESSION_HOSTMIGRATED 0x0005 + +// +// The associated game session's host has migrated to the local client +// +#define DPLSESSION_HOSTMIGRATEDHERE 0x0006 + + +/**************************************************************************** + * + * DirectPlay8 Lobby Flags + * + ****************************************************************************/ + +// +// Do not automatically make the lobby app unavailable when a connection is established +// +#define DPLAVAILABLE_ALLOWMULTIPLECONNECT 0x0001 + +// +// Launch a new instance of the application to connect to +// +#define DPLCONNECT_LAUNCHNEW 0x0001 + +// +// Launch a new instance of the application if one is not waiting +// +#define DPLCONNECT_LAUNCHNOTFOUND 0x0002 + +// +// When starting the associated game session, start it as a host +// +#define DPLCONNECTSETTINGS_HOST 0x0001 + +// +// Disable parameter validation +// +#define DPLINITIALIZE_DISABLEPARAMVAL 0x0001 + +/**************************************************************************** + * + * DirectPlay8Lobby Structures (Non-Message) + * + ****************************************************************************/ + +// +// Information on a registered game +// +typedef struct _DPL_APPLICATION_INFO { + GUID guidApplication; // GUID of the application + PWSTR pwszApplicationName; // Name of the application + DWORD dwNumRunning; // # of instances of this application running + DWORD dwNumWaiting; // # of instances of this application waiting + DWORD dwFlags; // Flags +} DPL_APPLICATION_INFO, *PDPL_APPLICATION_INFO; + +// +// Settings to be used for connecting / hosting a game session +// +typedef struct _DPL_CONNECTION_SETTINGS { + DWORD dwSize; // Size of this structure + DWORD dwFlags; // Connection settings flags (DPLCONNECTSETTINGS_...) + DPN_APPLICATION_DESC dpnAppDesc; // Application desc for the associated DirectPlay session + IDirectPlay8Address *pdp8HostAddress; // Address of host to connect to + IDirectPlay8Address **ppdp8DeviceAddresses; // Address of device to connect from / host on + DWORD cNumDeviceAddresses; // # of addresses specified in ppdp8DeviceAddresses + PWSTR pwszPlayerName; // Name to give the player +} DPL_CONNECTION_SETTINGS, *PDPL_CONNECTION_SETTINGS; + +// +// Information for performing a lobby connect +// (ConnectApplication) +// +typedef struct _DPL_CONNECT_INFO { + DWORD dwSize; // Size of this structure + DWORD dwFlags; // Flags (DPLCONNECT_...) + GUID guidApplication; // GUID of application to launch + PDPL_CONNECTION_SETTINGS pdplConnectionSettings; + // Settings application should use + PVOID pvLobbyConnectData; // User defined data block + DWORD dwLobbyConnectDataSize; + // Size of user defined data block +} DPL_CONNECT_INFO, *PDPL_CONNECT_INFO; + +// +// Information for registering an application +// (RegisterApplication) +// +typedef struct _DPL_PROGRAM_DESC { + DWORD dwSize; + DWORD dwFlags; + GUID guidApplication; // Application GUID + PWSTR pwszApplicationName; // Unicode application name + PWSTR pwszCommandLine; // Unicode command line arguments + PWSTR pwszCurrentDirectory; // Unicode current directory + PWSTR pwszDescription; // Unicode application description + PWSTR pwszExecutableFilename; // Unicode filename of application executable + PWSTR pwszExecutablePath; // Unicode path of application executable + PWSTR pwszLauncherFilename; // Unicode filename of launcher executable + PWSTR pwszLauncherPath; // Unicode path of launcher executable +} DPL_PROGRAM_DESC, *PDPL_PROGRAM_DESC; + +/**************************************************************************** + * + * DirectPlay8 Lobby Message Structures + * + ****************************************************************************/ + +// +// A connection was established +// (DPL_MSGID_CONNECT) +// +typedef struct _DPL_MESSAGE_CONNECT +{ + DWORD dwSize; // Size of this structure + DPNHANDLE hConnectId; // Handle of new connection + PDPL_CONNECTION_SETTINGS pdplConnectionSettings; // Connection settings for this connection + PVOID pvLobbyConnectData; // User defined lobby data block + DWORD dwLobbyConnectDataSize; // Size of user defined lobby data block + PVOID pvConnectionContext; // Context value for this connection (user set) +} DPL_MESSAGE_CONNECT, *PDPL_MESSAGE_CONNECT; + +// +// Connection settings have been updated +// (DPL_MSGID_CONNECTION_SETTINGS) +// +typedef struct _DPL_MESSAGE_CONNECTION_SETTINGS +{ + DWORD dwSize; // Size of this structure + DPNHANDLE hSender; // Handle of the connection for these settings + PDPL_CONNECTION_SETTINGS pdplConnectionSettings; // Connection settings + PVOID pvConnectionContext; // Context value for this connection +} DPL_MESSAGE_CONNECTION_SETTINGS, *PDPL_MESSAGE_CONNECTION_SETTINGS; + +// +// A connection has been disconnected +// (DPL_MSGID_DISCONNECT) +// +typedef struct _DPL_MESSAGE_DISCONNECT +{ + DWORD dwSize; // Size of this structure + DPNHANDLE hDisconnectId; // Handle of the connection that was terminated + HRESULT hrReason; // Reason the connection was broken + PVOID pvConnectionContext; // Context value for this connection +} DPL_MESSAGE_DISCONNECT, *PDPL_MESSAGE_DISCONNECT; + +// +// Data was received through a connection +// (DPL_MSGID_RECEIVE) +// +typedef struct _DPL_MESSAGE_RECEIVE +{ + DWORD dwSize; // Size of this structure + DPNHANDLE hSender; // Handle of the connection that is from + BYTE *pBuffer; // Contents of the message + DWORD dwBufferSize; // Size of the message context + PVOID pvConnectionContext; // Context value for this connection +} DPL_MESSAGE_RECEIVE, *PDPL_MESSAGE_RECEIVE; + +// +// Current status of the associated connection +// (DPL_MSGID_SESSION_STATUS) +// +typedef struct _DPL_MESSAGE_SESSION_STATUS +{ + DWORD dwSize; // Size of this structure + DPNHANDLE hSender; // Handle of the connection that this is from + DWORD dwStatus; // Status (DPLSESSION_...) + PVOID pvConnectionContext; // Context value for this connection +} DPL_MESSAGE_SESSION_STATUS, *PDPL_MESSAGE_SESSION_STATUS; + +/**************************************************************************** + * + * DirectPlay8Lobby Create + * + ****************************************************************************/ + +/* + * This function is no longer supported. It is recommended that CoCreateInstance be used to create + * DirectPlay8 lobby objects. + * + * extern HRESULT WINAPI DirectPlay8LobbyCreate( const GUID * pcIID, void **ppvInterface, IUnknown *pUnknown); + * + */ + +/**************************************************************************** + * + * DirectPlay8 Functions + * + ****************************************************************************/ + +// +// COM definition for DirectPlayLobbyClient +// +#undef INTERFACE // External COM Implementation +#define INTERFACE IDirectPlay8LobbyClient +DECLARE_INTERFACE_(IDirectPlay8LobbyClient,IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + // IDirectPlayLobbyClient methods + STDMETHOD(Initialize) (THIS_ const PVOID pvUserContext,const PFNDPNMESSAGEHANDLER pfn,const DWORD dwFlags) PURE; + STDMETHOD(EnumLocalPrograms) (THIS_ GUID *const pGuidApplication,BYTE *const pEnumData,DWORD *const pdwEnumData,DWORD *const pdwItems, const DWORD dwFlags) PURE; + STDMETHOD(ConnectApplication) (THIS_ DPL_CONNECT_INFO *const pdplConnectionInfo,const PVOID pvConnectionContext,DPNHANDLE *const hApplication,const DWORD dwTimeOut,const DWORD dwFlags) PURE; + STDMETHOD(Send) (THIS_ const DPNHANDLE hConnection,BYTE *const pBuffer,const DWORD pBufferSize,const DWORD dwFlags) PURE; + STDMETHOD(ReleaseApplication) (THIS_ const DPNHANDLE hConnection, const DWORD dwFlags ) PURE; + STDMETHOD(Close) (THIS_ const DWORD dwFlags ) PURE; + STDMETHOD(GetConnectionSettings) (THIS_ const DPNHANDLE hConnection, DPL_CONNECTION_SETTINGS * const pdplSessionInfo, DWORD *pdwInfoSize, const DWORD dwFlags ) PURE; + STDMETHOD(SetConnectionSettings) (THIS_ const DPNHANDLE hConnection, const DPL_CONNECTION_SETTINGS * const pdplSessionInfo, const DWORD dwFlags ) PURE; +}; + + +// +// COM definition for DirectPlayLobbiedApplication +// +#undef INTERFACE // External COM Implementation +#define INTERFACE IDirectPlay8LobbiedApplication +DECLARE_INTERFACE_(IDirectPlay8LobbiedApplication,IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID *ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + // IDirectPlayLobbiedApplication methods + STDMETHOD(Initialize) (THIS_ const PVOID pvUserContext,const PFNDPNMESSAGEHANDLER pfn,DPNHANDLE * const pdpnhConnection, const DWORD dwFlags) PURE; + STDMETHOD(RegisterProgram) (THIS_ PDPL_PROGRAM_DESC pdplProgramDesc,const DWORD dwFlags) PURE; + STDMETHOD(UnRegisterProgram) (THIS_ GUID *pguidApplication,const DWORD dwFlags) PURE; + STDMETHOD(Send) (THIS_ const DPNHANDLE hConnection,BYTE *const pBuffer,const DWORD pBufferSize,const DWORD dwFlags) PURE; + STDMETHOD(SetAppAvailable) (THIS_ const BOOL fAvailable, const DWORD dwFlags ) PURE; + STDMETHOD(UpdateStatus) (THIS_ const DPNHANDLE hConnection, const DWORD dwStatus, const DWORD dwFlags ) PURE; + STDMETHOD(Close) (THIS_ const DWORD dwFlags ) PURE; + STDMETHOD(GetConnectionSettings) (THIS_ const DPNHANDLE hConnection, DPL_CONNECTION_SETTINGS * const pdplSessionInfo, DWORD *pdwInfoSize, const DWORD dwFlags ) PURE; + STDMETHOD(SetConnectionSettings) (THIS_ const DPNHANDLE hConnection, const DPL_CONNECTION_SETTINGS * const pdplSessionInfo, const DWORD dwFlags ) PURE; +}; + + +/**************************************************************************** + * + * DirectPlayLobby Interface Macros + * + ****************************************************************************/ + +#if !defined(__cplusplus) || defined(CINTERFACE) + +#define IDirectPlay8LobbyClient_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlay8LobbyClient_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlay8LobbyClient_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlay8LobbyClient_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectPlay8LobbyClient_EnumLocalPrograms(p,a,b,c,d,e) (p)->lpVtbl->EnumLocalPrograms(p,a,b,c,d,e) +#define IDirectPlay8LobbyClient_ConnectApplication(p,a,b,c,d,e) (p)->lpVtbl->ConnectApplication(p,a,b,c,d,e) +#define IDirectPlay8LobbyClient_Send(p,a,b,c,d) (p)->lpVtbl->Send(p,a,b,c,d) +#define IDirectPlay8LobbyClient_ReleaseApplication(p,a,b) (p)->lpVtbl->ReleaseApplication(p,a,b) +#define IDirectPlay8LobbyClient_Close(p,a) (p)->lpVtbl->Close(p,a) +#define IDirectPlay8LobbyClient_GetConnectionSettings(p,a,b,c,d) (p)->lpVtbl->GetConnectionSettings(p,a,b,c,d) +#define IDirectPlay8LobbyClient_SetConnectionSettings(p,a,b,c) (p)->lpVtbl->SetConnectionSettings(p,a,b,c) + +#define IDirectPlay8LobbiedApplication_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlay8LobbiedApplication_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlay8LobbiedApplication_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlay8LobbiedApplication_Initialize(p,a,b,c,d) (p)->lpVtbl->Initialize(p,a,b,c,d) +#define IDirectPlay8LobbiedApplication_RegisterProgram(p,a,b) (p)->lpVtbl->RegisterProgram(p,a,b) +#define IDirectPlay8LobbiedApplication_UnRegisterProgram(p,a,b) (p)->lpVtbl->UnRegisterProgram(p,a,b) +#define IDirectPlay8LobbiedApplication_Send(p,a,b,c,d) (p)->lpVtbl->Send(p,a,b,c,d) +#define IDirectPlay8LobbiedApplication_SetAppAvailable(p,a,b) (p)->lpVtbl->SetAppAvailable(p,a,b) +#define IDirectPlay8LobbiedApplication_UpdateStatus(p,a,b,c) (p)->lpVtbl->UpdateStatus(p,a,b,c) +#define IDirectPlay8LobbiedApplication_Close(p,a) (p)->lpVtbl->Close(p,a) +#define IDirectPlay8LobbiedApplication_GetConnectionSettings(p,a,b,c,d) (p)->lpVtbl->GetConnectionSettings(p,a,b,c,d) +#define IDirectPlay8LobbiedApplication_SetConnectionSettings(p,a,b,c) (p)->lpVtbl->SetConnectionSettings(p,a,b,c) + +#else /* C++ */ + +#define IDirectPlay8LobbyClient_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlay8LobbyClient_AddRef(p) (p)->AddRef() +#define IDirectPlay8LobbyClient_Release(p) (p)->Release() +#define IDirectPlay8LobbyClient_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectPlay8LobbyClient_EnumLocalPrograms(p,a,b,c,d,e) (p)->EnumLocalPrograms(a,b,c,d,e) +#define IDirectPlay8LobbyClient_ConnectApplication(p,a,b,c,d,e) (p)->ConnectApplication(a,b,c,d,e) +#define IDirectPlay8LobbyClient_Send(p,a,b,c,d) (p)->Send(a,b,c,d) +#define IDirectPlay8LobbyClient_ReleaseApplication(p,a,b) (p)->ReleaseApplication(a,b) +#define IDirectPlay8LobbyClient_Close(p,a) (p)->Close(a) +#define IDirectPlay8LobbyClient_GetConnectionSettings(p,a,b,c,d) (p)->GetConnectionSettings(a,b,c,d) +#define IDirectPlay8LobbyClient_SetConnectionSettings(p,a,b,c) (p)->SetConnectionSettings(a,b,c) + +#define IDirectPlay8LobbiedApplication_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlay8LobbiedApplication_AddRef(p) (p)->AddRef() +#define IDirectPlay8LobbiedApplication_Release(p) (p)->Release() +#define IDirectPlay8LobbiedApplication_Initialize(p,a,b,c,d) (p)->Initialize(a,b,c,d) +#define IDirectPlay8LobbiedApplication_RegisterProgram(p,a,b) (p)->RegisterProgram(a,b) +#define IDirectPlay8LobbiedApplication_UnRegisterProgram(p,a,b) (p)->UnRegisterProgram(a,b) +#define IDirectPlay8LobbiedApplication_Send(p,a,b,c,d) (p)->Send(a,b,c,d) +#define IDirectPlay8LobbiedApplication_SetAppAvailable(p,a,b) (p)->SetAppAvailable(a,b) +#define IDirectPlay8LobbiedApplication_UpdateStatus(p,a,b,c) (p)->UpdateStatus(a,b,c) +#define IDirectPlay8LobbiedApplication_Close(p,a) (p)->Close(a) +#define IDirectPlay8LobbiedApplication_GetConnectionSettings(p,a,b,c,d) (p)->GetConnectionSettings(a,b,c,d) +#define IDirectPlay8LobbiedApplication_SetConnectionSettings(p,a,b,c) (p)->SetConnectionSettings(a,b,c) + +#endif + +#ifdef __cplusplus +} +#endif + +#endif // __DPLOBBY_H__ + diff --git a/src/dep/include/DXSDK/include/dpnathlp.h b/src/dep/include/DXSDK/include/dpnathlp.h index b90e2f1..720e43a 100644 --- a/src/dep/include/DXSDK/include/dpnathlp.h +++ b/src/dep/include/DXSDK/include/dpnathlp.h @@ -1,318 +1,318 @@ -/*************************************************************************** - * - * Copyright (C) 2001-2002 Microsoft Corporation. All Rights Reserved. - * - * File: dpnathlp.h - * - * Content: Header for using DirectPlayNATHelp interface. - * - * - * NOTE: This interface is deprecated and should no longer be used. - * - * - ***************************************************************************/ - - - -#ifndef __DPNATHLP_H__ -#define __DPNATHLP_H__ - - - -#include // for DECLARE_INTERFACE and HRESULT - - - -#ifndef DPNATHLP_EXPORTS -#define DPNATHLPAPI DECLSPEC_IMPORT -#else -#define DPNATHLPAPI -#endif - - - -#ifdef __cplusplus -extern "C" { -#endif - - - - - -/**************************************************************************** - * - * DirectPlay NAT Helper object class IDs - * - ****************************************************************************/ - -// {B9C2E9C4-68C1-4d42-A7A1-E76A26982AD6} -DEFINE_GUID(CLSID_DirectPlayNATHelpUPnP, -0xb9c2e9c4, 0x68c1, 0x4d42, 0xa7, 0xa1, 0xe7, 0x6a, 0x26, 0x98, 0x2a, 0xd6); - -// {963AB779-16A1-477c-A36D-CB5E711938F7} -DEFINE_GUID(CLSID_DirectPlayNATHelpPAST, -0x963ab779, 0x16a1, 0x477c, 0xa3, 0x6d, 0xcb, 0x5e, 0x71, 0x19, 0x38, 0xf7); - - -/**************************************************************************** - * - * DirectPlay NAT Helper interface ID - * - ****************************************************************************/ - -// {154940B6-2278-4a2f-9101-9BA9F431F603} -DEFINE_GUID(IID_IDirectPlayNATHelp, -0x154940b6, 0x2278, 0x4a2f, 0x91, 0x1, 0x9b, 0xa9, 0xf4, 0x31, 0xf6, 0x3); - -/**************************************************************************** - * - * DirectPlay NAT Helper interface pointer definitions - * - ****************************************************************************/ - -typedef struct IDirectPlayNATHelp *PDIRECTPLAYNATHELP; - - - - -/**************************************************************************** - * - * DirectPlay NAT Helper data types - * - ****************************************************************************/ - -// -// Handles used to identify specific port binding groups. If multiple ports -// are registered at the same time, the DPNHHANDLE refers to all ports. -// -typedef DWORD_PTR DPNHHANDLE, * PDPNHHANDLE; - - - - -/**************************************************************************** - * - * DirectPlay NAT Helper constants - * - ****************************************************************************/ - -#define DPNH_MAX_SIMULTANEOUS_PORTS 16 // up to 16 ports may be specified in a single RegisterPorts call - - - - -/**************************************************************************** - * - * DirectPlay NAT Helper API flags - * - ****************************************************************************/ - -// -// Flags that can be passed to Initialize -// -#define DPNHINITIALIZE_DISABLEGATEWAYSUPPORT 0x01 // disables Internet gateway traversal support (cannot be specified with DPNHINITIALIZE_DISABLELOCALFIREWALLSUPPORT) -#define DPNHINITIALIZE_DISABLELOCALFIREWALLSUPPORT 0x02 // disables local firewall traversal support (cannot be specified with DPNHINITIALIZE_DISABLEGATEWAYSUPPORT) - -// -// Flags that can be passed to GetCaps. -// -#define DPNHGETCAPS_UPDATESERVERSTATUS 0x01 // automatically extend expiring leases and detect changes in server status - -// -// Flags that can be passed to RegisterPorts. -// -#define DPNHREGISTERPORTS_TCP 0x01 // request TCP ports instead of UDP -#define DPNHREGISTERPORTS_FIXEDPORTS 0x02 // asks the server to use the same port numbers on the public interface -#define DPNHREGISTERPORTS_SHAREDPORTS 0x04 // requests that the server allow the UDP fixed ports to be shared with other clients (must be specified with DPNHREGISTERPORTS_FIXEDPORTS and cannot be specified with DPNHREGISTERPORTS_TCP) - -// -// Flags that can be passed to GetRegisteredAddresses. -// -#define DPNHGETREGISTEREDADDRESSES_LOCALFIREWALLREMAPONLY 0x01 // retrieve the public address for the local firewall only, even if mapped on remote Internet gateway - -// -// Flags that can be passed to QueryAddress. -// -#define DPNHQUERYADDRESS_TCP 0x01 // request a TCP port instead of UDP -#define DPNHQUERYADDRESS_CACHEFOUND 0x02 // cache the discovered address if found -#define DPNHQUERYADDRESS_CACHENOTFOUND 0x04 // cache the fact that no address was found, if that is the case -#define DPNHQUERYADDRESS_CHECKFORPRIVATEBUTUNMAPPED 0x08 // determine if the address is behind the same Internet gateway, but not mapped on that Internet gateway - -/**************************************************************************** - * - * DirectPlay NAT Helper structure flags - * - ****************************************************************************/ - -// -// DPNHCAPS flags -// -#define DPNHCAPSFLAG_LOCALFIREWALLPRESENT 0x01 // at least one network connection has a local firewall present -#define DPNHCAPSFLAG_GATEWAYPRESENT 0x02 // at least one network connection has an Internet gateway present -#define DPNHCAPSFLAG_GATEWAYISLOCAL 0x04 // a detected Internet gateway is local (i.e. the public address is another network interface on the same machine) -#define DPNHCAPSFLAG_PUBLICADDRESSAVAILABLE 0x08 // at least one server has a valid public address for registered mappings -#define DPNHCAPSFLAG_NOTALLSUPPORTACTIVENOTIFY 0x10 // at least one available server does not support an active-notification mechanisms and must be polled - - - -/**************************************************************************** - * - * DirectPlay NAT Helper structures - * - ****************************************************************************/ - -typedef struct _DPNHCAPS -{ - DWORD dwSize; // size of this structure, must be filled in prior to calling GetCaps - DWORD dwFlags; // flags indicating capabilities of Internet gateway server(s) - DWORD dwNumRegisteredPorts; // number of ports currently registered, including multiple ports registered at the same time (so this may not be equal to the number of DPNHHANDLEs given out) - DWORD dwMinLeaseTimeRemaining; // approximate time remaining, in milliseconds, for the lease that will expire soonest - DWORD dwRecommendedGetCapsInterval; // recommended time, in milliseconds, after which GetCaps should be called again (with DPNHGETCAPS_UPDATESERVERSTATUS flag) -} DPNHCAPS, * PDPNHCAPS; - - - -/**************************************************************************** - * - * Address type flags (returned by GetRegisteredAddresses) - * - ****************************************************************************/ - -#define DPNHADDRESSTYPE_TCP 0x01 // the mappings are for TCP ports instead of UDP -#define DPNHADDRESSTYPE_FIXEDPORTS 0x02 // the mappings are for ports which are the same on the Internet gateway -#define DPNHADDRESSTYPE_SHAREDPORTS 0x04 // the mappings are for shared UDP fixed ports -#define DPNHADDRESSTYPE_LOCALFIREWALL 0x08 // the addresses are opened on a local firewall -#define DPNHADDRESSTYPE_GATEWAY 0x10 // the addresses are registered with an Internet gateway -#define DPNHADDRESSTYPE_GATEWAYISLOCAL 0x20 // the Internet gateway is local (i.e. the public address is another network interface on the same machine) - - - - -/**************************************************************************** - * - * DirectPlay NAT Helper DLL exported functions - * - ****************************************************************************/ - -typedef HRESULT (WINAPI * PFN_DIRECTPLAYNATHELPCREATE)(const GUID * pIID, void ** ppvInterface); - - - - - -/**************************************************************************** - * - * DirectPlay NAT Helper application interfaces - * - ****************************************************************************/ - -#undef INTERFACE -#define INTERFACE IDirectPlayNATHelp -DECLARE_INTERFACE_(IDirectPlayNATHelp, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /*** IDirectPlayNATHelp methods ***/ - STDMETHOD(Initialize) (THIS_ const DWORD dwFlags) PURE; - STDMETHOD(Close) (THIS_ const DWORD dwFlags) PURE; - STDMETHOD(GetCaps) (THIS_ DPNHCAPS * const dpnhcaps, const DWORD dwFlags) PURE; - STDMETHOD(RegisterPorts) (THIS_ const SOCKADDR * const aLocalAddresses, const DWORD dwAddressesSize, const DWORD dwNumAddresses, const DWORD dwLeaseTime, DPNHHANDLE * const phRegisteredPorts, const DWORD dwFlags) PURE; - STDMETHOD(GetRegisteredAddresses) (THIS_ const DPNHHANDLE hRegisteredPorts, SOCKADDR * const paPublicAddresses, DWORD * const pdwPublicAddressesSize, DWORD * const pdwAddressTypeFlags, DWORD * const pdwLeaseTimeRemaining, const DWORD dwFlags) PURE; - STDMETHOD(DeregisterPorts) (THIS_ const DPNHHANDLE hRegisteredPorts, const DWORD dwFlags) PURE; - STDMETHOD(QueryAddress) (THIS_ const SOCKADDR * const pSourceAddress, const SOCKADDR * const pQueryAddress, SOCKADDR * const pResponseAddress, const int iAddressesSize, const DWORD dwFlags) PURE; - STDMETHOD(SetAlertEvent) (THIS_ const HANDLE hEvent, const DWORD dwFlags) PURE; - STDMETHOD(SetAlertIOCompletionPort) (THIS_ const HANDLE hIOCompletionPort, const DWORD dwCompletionKey, const DWORD dwNumConcurrentThreads, const DWORD dwFlags) PURE; - STDMETHOD(ExtendRegisteredPortsLease) (THIS_ const DPNHHANDLE hRegisteredPorts, const DWORD dwLeaseTime, const DWORD dwFlags) PURE; -}; - - -/**************************************************************************** - * - * DirectPlay NAT Helper application interface macros - * - ****************************************************************************/ - -#if (! defined(__cplusplus) || defined(CINTERFACE)) - -#define IDirectPlayNATHelp_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlayNATHelp_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlayNATHelp_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlayNATHelp_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#define IDirectPlayNATHelp_Close(p,a) (p)->lpVtbl->Close(p,a) -#define IDirectPlayNATHelp_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) -#define IDirectPlayNATHelp_RegisterPorts(p,a,b,c,d,e,f) (p)->lpVtbl->RegisterPorts(p,a,b,c,d,e,f) -#define IDirectPlayNATHelp_GetRegisteredAddresses(p,a,b,c,d,e,f) (p)->lpVtbl->GetRegisteredAddresses(p,a,b,c,d,e,f) -#define IDirectPlayNATHelp_DeregisterPorts(p,a,b) (p)->lpVtbl->DeregisterPorts(p,a,b) -#define IDirectPlayNATHelp_QueryAddress(p,a,b,c,d,e) (p)->lpVtbl->QueryAddress(p,a,b,c,d,e) -#define IDirectPlayNATHelp_SetAlertEvent(p,a,b) (p)->lpVtbl->SetAlertEvent(p,a,b) -#define IDirectPlayNATHelp_SetAlertIOCompletionPort(p,a,b,c,d) (p)->lpVtbl->SetAlertIOCompletionPort(p,a,b,c,d) -#define IDirectPlayNATHelp_ExtendRegisteredPortsLease(p,a,b,c) (p)->lpVtbl->ExtendRegisteredPortsLease(p,a,b,c) - - -#else // C++ - -#define IDirectPlayNATHelp_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlayNATHelp_AddRef(p) (p)->AddRef() -#define IDirectPlayNATHelp_Release(p) (p)->Release() -#define IDirectPlayNATHelp_Initialize(p,a) (p)->Initialize(a) -#define IDirectPlayNATHelp_Close(p,a) (p)->Close(a) -#define IDirectPlayNATHelp_GetCaps(p,a,b) (p)->GetCaps(a,b) -#define IDirectPlayNATHelp_RegisterPorts(p,a,b,c,d,e,f) (p)->RegisterPorts(a,b,c,d,e,f) -#define IDirectPlayNATHelp_GetRegisteredAddresses(p,a,b,c,d,e,f) (p)->GetRegisteredAddresses(a,b,c,d,e,f) -#define IDirectPlayNATHelp_DeregisterPorts(p,a,b) (p)->DeregisterPorts(a,b) -#define IDirectPlayNATHelp_QueryAddress(p,a,b,c,d,e) (p)->QueryAddress(a,b,c,d,e) -#define IDirectPlayNATHelp_SetAlertEvent(p,a,b) (p)->SetAlertEvent(a,b) -#define IDirectPlayNATHelp_SetAlertIOCompletionPort(p,a,b,c,d) (p)->SetAlertIOCompletionPort(a,b,c,d) -#define IDirectPlayNATHelp_ExtendRegisteredPortsLease(p,a,b,c) (p)->ExtendRegisteredPortsLease(a,b,c) - - -#endif - - - -/**************************************************************************** - * - * DirectPlay NAT Helper return codes - * - * Errors are represented by negative values and cannot be combined. - * - ****************************************************************************/ - -#define _DPNH_FACILITY_CODE 0x015 -#define _DPNH_HRESULT_BASE 0xF000 - -#define MAKE_DPNHSUCCESS(code) MAKE_HRESULT(0, _DPNH_FACILITY_CODE, (code + _DPNH_HRESULT_BASE)) -#define MAKE_DPNHFAILURE(code) MAKE_HRESULT(1, _DPNH_FACILITY_CODE, (code + _DPNH_HRESULT_BASE)) - - - -#define DPNH_OK S_OK - -#define DPNHSUCCESS_ADDRESSESCHANGED MAKE_DPNHSUCCESS(0x10) - -#define DPNHERR_ALREADYINITIALIZED MAKE_DPNHFAILURE(0x10) -#define DPNHERR_BUFFERTOOSMALL MAKE_DPNHFAILURE(0x20) -#define DPNHERR_GENERIC E_FAIL -#define DPNHERR_INVALIDFLAGS MAKE_DPNHFAILURE(0x30) -#define DPNHERR_INVALIDOBJECT MAKE_DPNHFAILURE(0x40) -#define DPNHERR_INVALIDPARAM E_INVALIDARG -#define DPNHERR_INVALIDPOINTER E_POINTER -#define DPNHERR_NOMAPPING MAKE_DPNHFAILURE(0x50) -#define DPNHERR_NOMAPPINGBUTPRIVATE MAKE_DPNHFAILURE(0x60) -#define DPNHERR_NOTINITIALIZED MAKE_DPNHFAILURE(0x70) -#define DPNHERR_OUTOFMEMORY E_OUTOFMEMORY -#define DPNHERR_PORTALREADYREGISTERED MAKE_DPNHFAILURE(0x80) -#define DPNHERR_PORTUNAVAILABLE MAKE_DPNHFAILURE(0x90) -#define DPNHERR_REENTRANT MAKE_DPNHFAILURE(0x95) -#define DPNHERR_SERVERNOTAVAILABLE MAKE_DPNHFAILURE(0xA0) -#define DPNHERR_UPDATESERVERSTATUS MAKE_DPNHFAILURE(0xC0) - -#ifdef __cplusplus -} -#endif - -#endif // __DPNATHLP_H__ - +/*************************************************************************** + * + * Copyright (C) 2001-2002 Microsoft Corporation. All Rights Reserved. + * + * File: dpnathlp.h + * + * Content: Header for using DirectPlayNATHelp interface. + * + * + * NOTE: This interface is deprecated and should no longer be used. + * + * + ***************************************************************************/ + + + +#ifndef __DPNATHLP_H__ +#define __DPNATHLP_H__ + + + +#include // for DECLARE_INTERFACE and HRESULT + + + +#ifndef DPNATHLP_EXPORTS +#define DPNATHLPAPI DECLSPEC_IMPORT +#else +#define DPNATHLPAPI +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + + + + +/**************************************************************************** + * + * DirectPlay NAT Helper object class IDs + * + ****************************************************************************/ + +// {B9C2E9C4-68C1-4d42-A7A1-E76A26982AD6} +DEFINE_GUID(CLSID_DirectPlayNATHelpUPnP, +0xb9c2e9c4, 0x68c1, 0x4d42, 0xa7, 0xa1, 0xe7, 0x6a, 0x26, 0x98, 0x2a, 0xd6); + +// {963AB779-16A1-477c-A36D-CB5E711938F7} +DEFINE_GUID(CLSID_DirectPlayNATHelpPAST, +0x963ab779, 0x16a1, 0x477c, 0xa3, 0x6d, 0xcb, 0x5e, 0x71, 0x19, 0x38, 0xf7); + + +/**************************************************************************** + * + * DirectPlay NAT Helper interface ID + * + ****************************************************************************/ + +// {154940B6-2278-4a2f-9101-9BA9F431F603} +DEFINE_GUID(IID_IDirectPlayNATHelp, +0x154940b6, 0x2278, 0x4a2f, 0x91, 0x1, 0x9b, 0xa9, 0xf4, 0x31, 0xf6, 0x3); + +/**************************************************************************** + * + * DirectPlay NAT Helper interface pointer definitions + * + ****************************************************************************/ + +typedef struct IDirectPlayNATHelp *PDIRECTPLAYNATHELP; + + + + +/**************************************************************************** + * + * DirectPlay NAT Helper data types + * + ****************************************************************************/ + +// +// Handles used to identify specific port binding groups. If multiple ports +// are registered at the same time, the DPNHHANDLE refers to all ports. +// +typedef DWORD_PTR DPNHHANDLE, * PDPNHHANDLE; + + + + +/**************************************************************************** + * + * DirectPlay NAT Helper constants + * + ****************************************************************************/ + +#define DPNH_MAX_SIMULTANEOUS_PORTS 16 // up to 16 ports may be specified in a single RegisterPorts call + + + + +/**************************************************************************** + * + * DirectPlay NAT Helper API flags + * + ****************************************************************************/ + +// +// Flags that can be passed to Initialize +// +#define DPNHINITIALIZE_DISABLEGATEWAYSUPPORT 0x01 // disables Internet gateway traversal support (cannot be specified with DPNHINITIALIZE_DISABLELOCALFIREWALLSUPPORT) +#define DPNHINITIALIZE_DISABLELOCALFIREWALLSUPPORT 0x02 // disables local firewall traversal support (cannot be specified with DPNHINITIALIZE_DISABLEGATEWAYSUPPORT) + +// +// Flags that can be passed to GetCaps. +// +#define DPNHGETCAPS_UPDATESERVERSTATUS 0x01 // automatically extend expiring leases and detect changes in server status + +// +// Flags that can be passed to RegisterPorts. +// +#define DPNHREGISTERPORTS_TCP 0x01 // request TCP ports instead of UDP +#define DPNHREGISTERPORTS_FIXEDPORTS 0x02 // asks the server to use the same port numbers on the public interface +#define DPNHREGISTERPORTS_SHAREDPORTS 0x04 // requests that the server allow the UDP fixed ports to be shared with other clients (must be specified with DPNHREGISTERPORTS_FIXEDPORTS and cannot be specified with DPNHREGISTERPORTS_TCP) + +// +// Flags that can be passed to GetRegisteredAddresses. +// +#define DPNHGETREGISTEREDADDRESSES_LOCALFIREWALLREMAPONLY 0x01 // retrieve the public address for the local firewall only, even if mapped on remote Internet gateway + +// +// Flags that can be passed to QueryAddress. +// +#define DPNHQUERYADDRESS_TCP 0x01 // request a TCP port instead of UDP +#define DPNHQUERYADDRESS_CACHEFOUND 0x02 // cache the discovered address if found +#define DPNHQUERYADDRESS_CACHENOTFOUND 0x04 // cache the fact that no address was found, if that is the case +#define DPNHQUERYADDRESS_CHECKFORPRIVATEBUTUNMAPPED 0x08 // determine if the address is behind the same Internet gateway, but not mapped on that Internet gateway + +/**************************************************************************** + * + * DirectPlay NAT Helper structure flags + * + ****************************************************************************/ + +// +// DPNHCAPS flags +// +#define DPNHCAPSFLAG_LOCALFIREWALLPRESENT 0x01 // at least one network connection has a local firewall present +#define DPNHCAPSFLAG_GATEWAYPRESENT 0x02 // at least one network connection has an Internet gateway present +#define DPNHCAPSFLAG_GATEWAYISLOCAL 0x04 // a detected Internet gateway is local (i.e. the public address is another network interface on the same machine) +#define DPNHCAPSFLAG_PUBLICADDRESSAVAILABLE 0x08 // at least one server has a valid public address for registered mappings +#define DPNHCAPSFLAG_NOTALLSUPPORTACTIVENOTIFY 0x10 // at least one available server does not support an active-notification mechanisms and must be polled + + + +/**************************************************************************** + * + * DirectPlay NAT Helper structures + * + ****************************************************************************/ + +typedef struct _DPNHCAPS +{ + DWORD dwSize; // size of this structure, must be filled in prior to calling GetCaps + DWORD dwFlags; // flags indicating capabilities of Internet gateway server(s) + DWORD dwNumRegisteredPorts; // number of ports currently registered, including multiple ports registered at the same time (so this may not be equal to the number of DPNHHANDLEs given out) + DWORD dwMinLeaseTimeRemaining; // approximate time remaining, in milliseconds, for the lease that will expire soonest + DWORD dwRecommendedGetCapsInterval; // recommended time, in milliseconds, after which GetCaps should be called again (with DPNHGETCAPS_UPDATESERVERSTATUS flag) +} DPNHCAPS, * PDPNHCAPS; + + + +/**************************************************************************** + * + * Address type flags (returned by GetRegisteredAddresses) + * + ****************************************************************************/ + +#define DPNHADDRESSTYPE_TCP 0x01 // the mappings are for TCP ports instead of UDP +#define DPNHADDRESSTYPE_FIXEDPORTS 0x02 // the mappings are for ports which are the same on the Internet gateway +#define DPNHADDRESSTYPE_SHAREDPORTS 0x04 // the mappings are for shared UDP fixed ports +#define DPNHADDRESSTYPE_LOCALFIREWALL 0x08 // the addresses are opened on a local firewall +#define DPNHADDRESSTYPE_GATEWAY 0x10 // the addresses are registered with an Internet gateway +#define DPNHADDRESSTYPE_GATEWAYISLOCAL 0x20 // the Internet gateway is local (i.e. the public address is another network interface on the same machine) + + + + +/**************************************************************************** + * + * DirectPlay NAT Helper DLL exported functions + * + ****************************************************************************/ + +typedef HRESULT (WINAPI * PFN_DIRECTPLAYNATHELPCREATE)(const GUID * pIID, void ** ppvInterface); + + + + + +/**************************************************************************** + * + * DirectPlay NAT Helper application interfaces + * + ****************************************************************************/ + +#undef INTERFACE +#define INTERFACE IDirectPlayNATHelp +DECLARE_INTERFACE_(IDirectPlayNATHelp, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /*** IDirectPlayNATHelp methods ***/ + STDMETHOD(Initialize) (THIS_ const DWORD dwFlags) PURE; + STDMETHOD(Close) (THIS_ const DWORD dwFlags) PURE; + STDMETHOD(GetCaps) (THIS_ DPNHCAPS * const dpnhcaps, const DWORD dwFlags) PURE; + STDMETHOD(RegisterPorts) (THIS_ const SOCKADDR * const aLocalAddresses, const DWORD dwAddressesSize, const DWORD dwNumAddresses, const DWORD dwLeaseTime, DPNHHANDLE * const phRegisteredPorts, const DWORD dwFlags) PURE; + STDMETHOD(GetRegisteredAddresses) (THIS_ const DPNHHANDLE hRegisteredPorts, SOCKADDR * const paPublicAddresses, DWORD * const pdwPublicAddressesSize, DWORD * const pdwAddressTypeFlags, DWORD * const pdwLeaseTimeRemaining, const DWORD dwFlags) PURE; + STDMETHOD(DeregisterPorts) (THIS_ const DPNHHANDLE hRegisteredPorts, const DWORD dwFlags) PURE; + STDMETHOD(QueryAddress) (THIS_ const SOCKADDR * const pSourceAddress, const SOCKADDR * const pQueryAddress, SOCKADDR * const pResponseAddress, const int iAddressesSize, const DWORD dwFlags) PURE; + STDMETHOD(SetAlertEvent) (THIS_ const HANDLE hEvent, const DWORD dwFlags) PURE; + STDMETHOD(SetAlertIOCompletionPort) (THIS_ const HANDLE hIOCompletionPort, const DWORD dwCompletionKey, const DWORD dwNumConcurrentThreads, const DWORD dwFlags) PURE; + STDMETHOD(ExtendRegisteredPortsLease) (THIS_ const DPNHHANDLE hRegisteredPorts, const DWORD dwLeaseTime, const DWORD dwFlags) PURE; +}; + + +/**************************************************************************** + * + * DirectPlay NAT Helper application interface macros + * + ****************************************************************************/ + +#if (! defined(__cplusplus) || defined(CINTERFACE)) + +#define IDirectPlayNATHelp_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlayNATHelp_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlayNATHelp_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlayNATHelp_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#define IDirectPlayNATHelp_Close(p,a) (p)->lpVtbl->Close(p,a) +#define IDirectPlayNATHelp_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) +#define IDirectPlayNATHelp_RegisterPorts(p,a,b,c,d,e,f) (p)->lpVtbl->RegisterPorts(p,a,b,c,d,e,f) +#define IDirectPlayNATHelp_GetRegisteredAddresses(p,a,b,c,d,e,f) (p)->lpVtbl->GetRegisteredAddresses(p,a,b,c,d,e,f) +#define IDirectPlayNATHelp_DeregisterPorts(p,a,b) (p)->lpVtbl->DeregisterPorts(p,a,b) +#define IDirectPlayNATHelp_QueryAddress(p,a,b,c,d,e) (p)->lpVtbl->QueryAddress(p,a,b,c,d,e) +#define IDirectPlayNATHelp_SetAlertEvent(p,a,b) (p)->lpVtbl->SetAlertEvent(p,a,b) +#define IDirectPlayNATHelp_SetAlertIOCompletionPort(p,a,b,c,d) (p)->lpVtbl->SetAlertIOCompletionPort(p,a,b,c,d) +#define IDirectPlayNATHelp_ExtendRegisteredPortsLease(p,a,b,c) (p)->lpVtbl->ExtendRegisteredPortsLease(p,a,b,c) + + +#else // C++ + +#define IDirectPlayNATHelp_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlayNATHelp_AddRef(p) (p)->AddRef() +#define IDirectPlayNATHelp_Release(p) (p)->Release() +#define IDirectPlayNATHelp_Initialize(p,a) (p)->Initialize(a) +#define IDirectPlayNATHelp_Close(p,a) (p)->Close(a) +#define IDirectPlayNATHelp_GetCaps(p,a,b) (p)->GetCaps(a,b) +#define IDirectPlayNATHelp_RegisterPorts(p,a,b,c,d,e,f) (p)->RegisterPorts(a,b,c,d,e,f) +#define IDirectPlayNATHelp_GetRegisteredAddresses(p,a,b,c,d,e,f) (p)->GetRegisteredAddresses(a,b,c,d,e,f) +#define IDirectPlayNATHelp_DeregisterPorts(p,a,b) (p)->DeregisterPorts(a,b) +#define IDirectPlayNATHelp_QueryAddress(p,a,b,c,d,e) (p)->QueryAddress(a,b,c,d,e) +#define IDirectPlayNATHelp_SetAlertEvent(p,a,b) (p)->SetAlertEvent(a,b) +#define IDirectPlayNATHelp_SetAlertIOCompletionPort(p,a,b,c,d) (p)->SetAlertIOCompletionPort(a,b,c,d) +#define IDirectPlayNATHelp_ExtendRegisteredPortsLease(p,a,b,c) (p)->ExtendRegisteredPortsLease(a,b,c) + + +#endif + + + +/**************************************************************************** + * + * DirectPlay NAT Helper return codes + * + * Errors are represented by negative values and cannot be combined. + * + ****************************************************************************/ + +#define _DPNH_FACILITY_CODE 0x015 +#define _DPNH_HRESULT_BASE 0xF000 + +#define MAKE_DPNHSUCCESS(code) MAKE_HRESULT(0, _DPNH_FACILITY_CODE, (code + _DPNH_HRESULT_BASE)) +#define MAKE_DPNHFAILURE(code) MAKE_HRESULT(1, _DPNH_FACILITY_CODE, (code + _DPNH_HRESULT_BASE)) + + + +#define DPNH_OK S_OK + +#define DPNHSUCCESS_ADDRESSESCHANGED MAKE_DPNHSUCCESS(0x10) + +#define DPNHERR_ALREADYINITIALIZED MAKE_DPNHFAILURE(0x10) +#define DPNHERR_BUFFERTOOSMALL MAKE_DPNHFAILURE(0x20) +#define DPNHERR_GENERIC E_FAIL +#define DPNHERR_INVALIDFLAGS MAKE_DPNHFAILURE(0x30) +#define DPNHERR_INVALIDOBJECT MAKE_DPNHFAILURE(0x40) +#define DPNHERR_INVALIDPARAM E_INVALIDARG +#define DPNHERR_INVALIDPOINTER E_POINTER +#define DPNHERR_NOMAPPING MAKE_DPNHFAILURE(0x50) +#define DPNHERR_NOMAPPINGBUTPRIVATE MAKE_DPNHFAILURE(0x60) +#define DPNHERR_NOTINITIALIZED MAKE_DPNHFAILURE(0x70) +#define DPNHERR_OUTOFMEMORY E_OUTOFMEMORY +#define DPNHERR_PORTALREADYREGISTERED MAKE_DPNHFAILURE(0x80) +#define DPNHERR_PORTUNAVAILABLE MAKE_DPNHFAILURE(0x90) +#define DPNHERR_REENTRANT MAKE_DPNHFAILURE(0x95) +#define DPNHERR_SERVERNOTAVAILABLE MAKE_DPNHFAILURE(0xA0) +#define DPNHERR_UPDATESERVERSTATUS MAKE_DPNHFAILURE(0xC0) + +#ifdef __cplusplus +} +#endif + +#endif // __DPNATHLP_H__ + diff --git a/src/dep/include/DXSDK/include/dsconf.h b/src/dep/include/DXSDK/include/dsconf.h index 64d724c..018f65a 100644 --- a/src/dep/include/DXSDK/include/dsconf.h +++ b/src/dep/include/DXSDK/include/dsconf.h @@ -1,195 +1,195 @@ -/*==========================================================================; - * - * Copyright (c) Microsoft Corporation. All rights reserved. - * - * File: dsconf.h - * Content: DirectSound configuration interface include file - * - **************************************************************************/ - -#ifndef __DSCONF_INCLUDED__ -#define __DSCONF_INCLUDED__ - -#ifndef __DSOUND_INCLUDED__ -#error dsound.h not included -#endif // __DSOUND_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - - -// DirectSound Private Component GUID {11AB3EC0-25EC-11d1-A4D8-00C04FC28ACA} -DEFINE_GUID(CLSID_DirectSoundPrivate, 0x11ab3ec0, 0x25ec, 0x11d1, 0xa4, 0xd8, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); - - -// -// DirectSound Device Properties {84624F82-25EC-11d1-A4D8-00C04FC28ACA} -// - -DEFINE_GUID(DSPROPSETID_DirectSoundDevice, 0x84624f82, 0x25ec, 0x11d1, 0xa4, 0xd8, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); - -typedef enum -{ - DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A = 1, - DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1 = 2, - DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 = 3, - DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W = 4, - DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A = 5, - DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W = 6, - DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A = 7, - DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W = 8, -} DSPROPERTY_DIRECTSOUNDDEVICE; - -#if DIRECTSOUND_VERSION >= 0x0700 -#ifdef UNICODE -#define DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W -#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W -#define DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W -#else // UNICODE -#define DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A -#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A -#define DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A -#endif // UNICODE -#else // DIRECTSOUND_VERSION >= 0x0700 -#define DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A -#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1 -#define DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 -#endif // DIRECTSOUND_VERSION >= 0x0700 - -typedef enum -{ - DIRECTSOUNDDEVICE_TYPE_EMULATED, - DIRECTSOUNDDEVICE_TYPE_VXD, - DIRECTSOUNDDEVICE_TYPE_WDM -} DIRECTSOUNDDEVICE_TYPE; - -typedef enum -{ - DIRECTSOUNDDEVICE_DATAFLOW_RENDER, - DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE -} DIRECTSOUNDDEVICE_DATAFLOW; - - -typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA -{ - LPSTR DeviceName; // waveIn/waveOut device name - DIRECTSOUNDDEVICE_DATAFLOW DataFlow; // Data flow (i.e. waveIn or waveOut) - GUID DeviceId; // DirectSound device id -} DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA; - -typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA -{ - LPWSTR DeviceName; // waveIn/waveOut device name - DIRECTSOUNDDEVICE_DATAFLOW DataFlow; // Data flow (i.e. waveIn or waveOut) - GUID DeviceId; // DirectSound device id -} DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA; - -#ifdef UNICODE -#define DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_DATA DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA -#define PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA -#else // UNICODE -#define DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_DATA DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA -#define PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA -#endif // UNICODE - -typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA -{ - GUID DeviceId; // DirectSound device id - CHAR DescriptionA[0x100]; // Device description (ANSI) - WCHAR DescriptionW[0x100]; // Device description (Unicode) - CHAR ModuleA[MAX_PATH]; // Device driver module (ANSI) - WCHAR ModuleW[MAX_PATH]; // Device driver module (Unicode) - DIRECTSOUNDDEVICE_TYPE Type; // Device type - DIRECTSOUNDDEVICE_DATAFLOW DataFlow; // Device dataflow - ULONG WaveDeviceId; // Wave device id - ULONG Devnode; // Devnode (or DevInst) -} DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA; - -typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA -{ - DIRECTSOUNDDEVICE_TYPE Type; // Device type - DIRECTSOUNDDEVICE_DATAFLOW DataFlow; // Device dataflow - GUID DeviceId; // DirectSound device id - LPSTR Description; // Device description - LPSTR Module; // Device driver module - LPSTR Interface; // Device interface - ULONG WaveDeviceId; // Wave device id -} DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA; - -typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA -{ - DIRECTSOUNDDEVICE_TYPE Type; // Device type - DIRECTSOUNDDEVICE_DATAFLOW DataFlow; // Device dataflow - GUID DeviceId; // DirectSound device id - LPWSTR Description; // Device description - LPWSTR Module; // Device driver module - LPWSTR Interface; // Device interface - ULONG WaveDeviceId; // Wave device id -} DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA; - -#if DIRECTSOUND_VERSION >= 0x0700 -#ifdef UNICODE -#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA -#define PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA -#else // UNICODE -#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA -#define PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA -#endif // UNICODE -#else // DIRECTSOUND_VERSION >= 0x0700 -#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA -#define PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA -#endif // DIRECTSOUND_VERSION >= 0x0700 - -typedef BOOL (CALLBACK *LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK1)(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA, LPVOID); -typedef BOOL (CALLBACK *LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKA)(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA, LPVOID); -typedef BOOL (CALLBACK *LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKW)(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA, LPVOID); - -#if DIRECTSOUND_VERSION >= 0x0700 -#ifdef UNICODE -#define LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKW -#else // UNICODE -#define LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKA -#endif // UNICODE -#else // DIRECTSOUND_VERSION >= 0x0700 -#define LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK1 -#endif // DIRECTSOUND_VERSION >= 0x0700 - -typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA -{ - LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK1 Callback; // Callback function pointer - LPVOID Context; // Callback function context argument -} DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA; - -typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA -{ - LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKA Callback; // Callback function pointer - LPVOID Context; // Callback function context argument -} DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA; - -typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA -{ - LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKW Callback; // Callback function pointer - LPVOID Context; // Callback function context argument -} DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA; - -#if DIRECTSOUND_VERSION >= 0x0700 -#ifdef UNICODE -#define DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA -#define PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA -#else // UNICODE -#define DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA -#define PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA -#endif // UNICODE -#else // DIRECTSOUND_VERSION >= 0x0700 -#define DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA -#define PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA -#endif // DIRECTSOUND_VERSION >= 0x0700 - - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // __DSCONF_INCLUDED__ - +/*==========================================================================; + * + * Copyright (c) Microsoft Corporation. All rights reserved. + * + * File: dsconf.h + * Content: DirectSound configuration interface include file + * + **************************************************************************/ + +#ifndef __DSCONF_INCLUDED__ +#define __DSCONF_INCLUDED__ + +#ifndef __DSOUND_INCLUDED__ +#error dsound.h not included +#endif // __DSOUND_INCLUDED__ + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + + +// DirectSound Private Component GUID {11AB3EC0-25EC-11d1-A4D8-00C04FC28ACA} +DEFINE_GUID(CLSID_DirectSoundPrivate, 0x11ab3ec0, 0x25ec, 0x11d1, 0xa4, 0xd8, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); + + +// +// DirectSound Device Properties {84624F82-25EC-11d1-A4D8-00C04FC28ACA} +// + +DEFINE_GUID(DSPROPSETID_DirectSoundDevice, 0x84624f82, 0x25ec, 0x11d1, 0xa4, 0xd8, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); + +typedef enum +{ + DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A = 1, + DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1 = 2, + DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 = 3, + DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W = 4, + DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A = 5, + DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W = 6, + DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A = 7, + DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W = 8, +} DSPROPERTY_DIRECTSOUNDDEVICE; + +#if DIRECTSOUND_VERSION >= 0x0700 +#ifdef UNICODE +#define DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W +#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W +#define DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W +#else // UNICODE +#define DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A +#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A +#define DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A +#endif // UNICODE +#else // DIRECTSOUND_VERSION >= 0x0700 +#define DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A +#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1 +#define DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 +#endif // DIRECTSOUND_VERSION >= 0x0700 + +typedef enum +{ + DIRECTSOUNDDEVICE_TYPE_EMULATED, + DIRECTSOUNDDEVICE_TYPE_VXD, + DIRECTSOUNDDEVICE_TYPE_WDM +} DIRECTSOUNDDEVICE_TYPE; + +typedef enum +{ + DIRECTSOUNDDEVICE_DATAFLOW_RENDER, + DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE +} DIRECTSOUNDDEVICE_DATAFLOW; + + +typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA +{ + LPSTR DeviceName; // waveIn/waveOut device name + DIRECTSOUNDDEVICE_DATAFLOW DataFlow; // Data flow (i.e. waveIn or waveOut) + GUID DeviceId; // DirectSound device id +} DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA; + +typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA +{ + LPWSTR DeviceName; // waveIn/waveOut device name + DIRECTSOUNDDEVICE_DATAFLOW DataFlow; // Data flow (i.e. waveIn or waveOut) + GUID DeviceId; // DirectSound device id +} DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA; + +#ifdef UNICODE +#define DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_DATA DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA +#define PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA +#else // UNICODE +#define DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_DATA DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA +#define PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA +#endif // UNICODE + +typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA +{ + GUID DeviceId; // DirectSound device id + CHAR DescriptionA[0x100]; // Device description (ANSI) + WCHAR DescriptionW[0x100]; // Device description (Unicode) + CHAR ModuleA[MAX_PATH]; // Device driver module (ANSI) + WCHAR ModuleW[MAX_PATH]; // Device driver module (Unicode) + DIRECTSOUNDDEVICE_TYPE Type; // Device type + DIRECTSOUNDDEVICE_DATAFLOW DataFlow; // Device dataflow + ULONG WaveDeviceId; // Wave device id + ULONG Devnode; // Devnode (or DevInst) +} DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA; + +typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA +{ + DIRECTSOUNDDEVICE_TYPE Type; // Device type + DIRECTSOUNDDEVICE_DATAFLOW DataFlow; // Device dataflow + GUID DeviceId; // DirectSound device id + LPSTR Description; // Device description + LPSTR Module; // Device driver module + LPSTR Interface; // Device interface + ULONG WaveDeviceId; // Wave device id +} DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA; + +typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA +{ + DIRECTSOUNDDEVICE_TYPE Type; // Device type + DIRECTSOUNDDEVICE_DATAFLOW DataFlow; // Device dataflow + GUID DeviceId; // DirectSound device id + LPWSTR Description; // Device description + LPWSTR Module; // Device driver module + LPWSTR Interface; // Device interface + ULONG WaveDeviceId; // Wave device id +} DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA; + +#if DIRECTSOUND_VERSION >= 0x0700 +#ifdef UNICODE +#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA +#define PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA +#else // UNICODE +#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA +#define PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA +#endif // UNICODE +#else // DIRECTSOUND_VERSION >= 0x0700 +#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA +#define PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA +#endif // DIRECTSOUND_VERSION >= 0x0700 + +typedef BOOL (CALLBACK *LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK1)(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA, LPVOID); +typedef BOOL (CALLBACK *LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKA)(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA, LPVOID); +typedef BOOL (CALLBACK *LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKW)(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA, LPVOID); + +#if DIRECTSOUND_VERSION >= 0x0700 +#ifdef UNICODE +#define LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKW +#else // UNICODE +#define LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKA +#endif // UNICODE +#else // DIRECTSOUND_VERSION >= 0x0700 +#define LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK1 +#endif // DIRECTSOUND_VERSION >= 0x0700 + +typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA +{ + LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK1 Callback; // Callback function pointer + LPVOID Context; // Callback function context argument +} DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA; + +typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA +{ + LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKA Callback; // Callback function pointer + LPVOID Context; // Callback function context argument +} DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA; + +typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA +{ + LPFNDIRECTSOUNDDEVICEENUMERATECALLBACKW Callback; // Callback function pointer + LPVOID Context; // Callback function context argument +} DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA; + +#if DIRECTSOUND_VERSION >= 0x0700 +#ifdef UNICODE +#define DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA +#define PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA +#else // UNICODE +#define DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA +#define PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA +#endif // UNICODE +#else // DIRECTSOUND_VERSION >= 0x0700 +#define DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA +#define PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA +#endif // DIRECTSOUND_VERSION >= 0x0700 + + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // __DSCONF_INCLUDED__ + diff --git a/src/dep/include/DXSDK/include/dsetup.h b/src/dep/include/DXSDK/include/dsetup.h index 4c917d5..58f79fb 100644 --- a/src/dep/include/DXSDK/include/dsetup.h +++ b/src/dep/include/DXSDK/include/dsetup.h @@ -1,286 +1,286 @@ -/*========================================================================== - * - * Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved. - * - * File: dsetup.h - * Content: DirectXSetup, error codes and flags - ***************************************************************************/ - -#ifndef __DSETUP_H__ -#define __DSETUP_H__ - -#include // windows stuff - -#ifdef _WIN32 -#define COM_NO_WINDOWS_H -#include -#else -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -#define FOURCC_VERS mmioFOURCC('v','e','r','s') - -// DSETUP Error Codes, must remain compatible with previous setup. -#define DSETUPERR_SUCCESS_RESTART 1 -#define DSETUPERR_SUCCESS 0 -#define DSETUPERR_BADWINDOWSVERSION -1 -#define DSETUPERR_SOURCEFILENOTFOUND -2 -#define DSETUPERR_NOCOPY -5 -#define DSETUPERR_OUTOFDISKSPACE -6 -#define DSETUPERR_CANTFINDINF -7 -#define DSETUPERR_CANTFINDDIR -8 -#define DSETUPERR_INTERNAL -9 -#define DSETUPERR_UNKNOWNOS -11 -#define DSETUPERR_NEWERVERSION -14 -#define DSETUPERR_NOTADMIN -15 -#define DSETUPERR_UNSUPPORTEDPROCESSOR -16 -#define DSETUPERR_MISSINGCAB_MANAGEDDX -17 -#define DSETUPERR_NODOTNETFRAMEWORKINSTALLED -18 -#define DSETUPERR_CABDOWNLOADFAIL -19 -#define DSETUPERR_DXCOMPONENTFILEINUSE -20 -#define DSETUPERR_UNTRUSTEDCABINETFILE -21 - -// DSETUP flags. DirectX 5.0 apps should use these flags only. -#define DSETUP_DDRAWDRV 0x00000008 /* install DirectDraw Drivers */ -#define DSETUP_DSOUNDDRV 0x00000010 /* install DirectSound Drivers */ -#define DSETUP_DXCORE 0x00010000 /* install DirectX runtime */ -#define DSETUP_DIRECTX (DSETUP_DXCORE|DSETUP_DDRAWDRV|DSETUP_DSOUNDDRV) -#define DSETUP_MANAGEDDX 0x00004000 /* OBSOLETE. install managed DirectX */ -#define DSETUP_TESTINSTALL 0x00020000 /* just test install, don't do anything */ - -// These OBSOLETE flags are here for compatibility with pre-DX5 apps only. -// They are present to allow DX3 apps to be recompiled with DX5 and still work. -// DO NOT USE THEM for DX5. They will go away in future DX releases. -#define DSETUP_DDRAW 0x00000001 /* OBSOLETE. install DirectDraw */ -#define DSETUP_DSOUND 0x00000002 /* OBSOLETE. install DirectSound */ -#define DSETUP_DPLAY 0x00000004 /* OBSOLETE. install DirectPlay */ -#define DSETUP_DPLAYSP 0x00000020 /* OBSOLETE. install DirectPlay Providers */ -#define DSETUP_DVIDEO 0x00000040 /* OBSOLETE. install DirectVideo */ -#define DSETUP_D3D 0x00000200 /* OBSOLETE. install Direct3D */ -#define DSETUP_DINPUT 0x00000800 /* OBSOLETE. install DirectInput */ -#define DSETUP_DIRECTXSETUP 0x00001000 /* OBSOLETE. install DirectXSetup DLL's */ -#define DSETUP_NOUI 0x00002000 /* OBSOLETE. install DirectX with NO UI */ -#define DSETUP_PROMPTFORDRIVERS 0x10000000 /* OBSOLETE. prompt when replacing display/audio drivers */ -#define DSETUP_RESTOREDRIVERS 0x20000000 /* OBSOLETE. restore display/audio drivers */ - - -//****************************************************************** -// DirectX Setup Callback mechanism -//****************************************************************** - -// DSETUP Message Info Codes, passed to callback as Reason parameter. -#define DSETUP_CB_MSG_NOMESSAGE 0 -#define DSETUP_CB_MSG_INTERNAL_ERROR 10 -#define DSETUP_CB_MSG_BEGIN_INSTALL 13 -#define DSETUP_CB_MSG_BEGIN_INSTALL_RUNTIME 14 -#define DSETUP_CB_MSG_PROGRESS 18 -#define DSETUP_CB_MSG_WARNING_DISABLED_COMPONENT 19 - - -typedef struct _DSETUP_CB_PROGRESS -{ - DWORD dwPhase; - DWORD dwInPhaseMaximum; - DWORD dwInPhaseProgress; - DWORD dwOverallMaximum; - DWORD dwOverallProgress; -} DSETUP_CB_PROGRESS; - - -enum _DSETUP_CB_PROGRESS_PHASE -{ - DSETUP_INITIALIZING, - DSETUP_EXTRACTING, - DSETUP_COPYING, - DSETUP_FINALIZING -}; - - -#ifdef _WIN32 -// -// Data Structures -// -#ifndef UNICODE_ONLY - -typedef struct _DIRECTXREGISTERAPPA { - DWORD dwSize; - DWORD dwFlags; - LPSTR lpszApplicationName; - LPGUID lpGUID; - LPSTR lpszFilename; - LPSTR lpszCommandLine; - LPSTR lpszPath; - LPSTR lpszCurrentDirectory; -} DIRECTXREGISTERAPPA, *PDIRECTXREGISTERAPPA, *LPDIRECTXREGISTERAPPA; - -typedef struct _DIRECTXREGISTERAPP2A { - DWORD dwSize; - DWORD dwFlags; - LPSTR lpszApplicationName; - LPGUID lpGUID; - LPSTR lpszFilename; - LPSTR lpszCommandLine; - LPSTR lpszPath; - LPSTR lpszCurrentDirectory; - LPSTR lpszLauncherName; -} DIRECTXREGISTERAPP2A, *PDIRECTXREGISTERAPP2A, *LPDIRECTXREGISTERAPP2A; - -#endif //!UNICODE_ONLY -#ifndef ANSI_ONLY - -typedef struct _DIRECTXREGISTERAPPW { - DWORD dwSize; - DWORD dwFlags; - LPWSTR lpszApplicationName; - LPGUID lpGUID; - LPWSTR lpszFilename; - LPWSTR lpszCommandLine; - LPWSTR lpszPath; - LPWSTR lpszCurrentDirectory; -} DIRECTXREGISTERAPPW, *PDIRECTXREGISTERAPPW, *LPDIRECTXREGISTERAPPW; - -typedef struct _DIRECTXREGISTERAPP2W { - DWORD dwSize; - DWORD dwFlags; - LPWSTR lpszApplicationName; - LPGUID lpGUID; - LPWSTR lpszFilename; - LPWSTR lpszCommandLine; - LPWSTR lpszPath; - LPWSTR lpszCurrentDirectory; - LPWSTR lpszLauncherName; -} DIRECTXREGISTERAPP2W, *PDIRECTXREGISTERAPP2W, *LPDIRECTXREGISTERAPP2W; -#endif //!ANSI_ONLY -#ifdef UNICODE -typedef DIRECTXREGISTERAPPW DIRECTXREGISTERAPP; -typedef PDIRECTXREGISTERAPPW PDIRECTXREGISTERAPP; -typedef LPDIRECTXREGISTERAPPW LPDIRECTXREGISTERAPP; -typedef DIRECTXREGISTERAPP2W DIRECTXREGISTERAPP2; -typedef PDIRECTXREGISTERAPP2W PDIRECTXREGISTERAPP2; -typedef LPDIRECTXREGISTERAPP2W LPDIRECTXREGISTERAPP2; -#else -typedef DIRECTXREGISTERAPPA DIRECTXREGISTERAPP; -typedef PDIRECTXREGISTERAPPA PDIRECTXREGISTERAPP; -typedef LPDIRECTXREGISTERAPPA LPDIRECTXREGISTERAPP; -typedef DIRECTXREGISTERAPP2A DIRECTXREGISTERAPP2; -typedef PDIRECTXREGISTERAPP2A PDIRECTXREGISTERAPP2; -typedef LPDIRECTXREGISTERAPP2A LPDIRECTXREGISTERAPP2; -#endif // UNICODE - - -// -// API -// - -#ifndef UNICODE_ONLY -INT -WINAPI -DirectXSetupA( - HWND hWnd, - LPSTR lpszRootPath, - DWORD dwFlags - ); -#endif //!UNICODE_ONLY -#ifndef ANSI_ONLY -INT -WINAPI -DirectXSetupW( - HWND hWnd, - LPWSTR lpszRootPath, - DWORD dwFlags - ); -#endif //!ANSI_ONLY -#ifdef UNICODE -#define DirectXSetup DirectXSetupW -#else -#define DirectXSetup DirectXSetupA -#endif // !UNICODE - -#ifndef UNICODE_ONLY -INT -WINAPI -DirectXRegisterApplicationA( - HWND hWnd, - LPVOID lpDXRegApp - ); -#endif //!UNICODE_ONLY -#ifndef ANSI_ONLY -INT -WINAPI -DirectXRegisterApplicationW( - HWND hWnd, - LPVOID lpDXRegApp - ); -#endif //!ANSI_ONLY -#ifdef UNICODE -#define DirectXRegisterApplication DirectXRegisterApplicationW -#else -#define DirectXRegisterApplication DirectXRegisterApplicationA -#endif // !UNICODE - -INT -WINAPI -DirectXUnRegisterApplication( - HWND hWnd, - LPGUID lpGUID - ); - -// -// Function Pointers -// -#ifdef UNICODE -typedef INT (WINAPI * LPDIRECTXSETUP)(HWND, LPWSTR, DWORD); -typedef INT (WINAPI * LPDIRECTXREGISTERAPPLICATION)(HWND, LPVOID); -#else -typedef INT (WINAPI * LPDIRECTXSETUP)(HWND, LPSTR, DWORD); -typedef INT (WINAPI * LPDIRECTXREGISTERAPPLICATION)(HWND, LPVOID); -#endif // UNICODE - -typedef DWORD (FAR PASCAL * DSETUP_CALLBACK)(DWORD Reason, - DWORD MsgType, /* Same as flags to MessageBox */ - LPSTR szMessage, - LPSTR szName, - void *pInfo); - -INT WINAPI DirectXSetupSetCallback(DSETUP_CALLBACK Callback); -INT WINAPI DirectXSetupGetVersion(DWORD *lpdwVersion, DWORD *lpdwMinorVersion); -INT WINAPI DirectXSetupShowEULA(HWND hWndParent); -#ifndef UNICODE_ONLY -UINT -WINAPI -DirectXSetupGetEULAA( - LPSTR lpszEULA, - UINT cchEULA, - WORD LangID - ); -#endif //!UNICODE_ONLY -#ifndef ANSI_ONLY -UINT -WINAPI -DirectXSetupGetEULAW( - LPWSTR lpszEULA, - UINT cchEULA, - WORD LangID - ); -#endif //!ANSI_ONLY -#ifdef UNICODE -#define DirectXSetupGetEULA DirectXSetupGetEULAW -typedef UINT (WINAPI * LPDIRECTXSETUPGETEULA)(LPWSTR, UINT, WORD); -#else -#define DirectXSetupGetEULA DirectXSetupGetEULAA -typedef UINT (WINAPI * LPDIRECTXSETUPGETEULA)(LPSTR, UINT, WORD); -#endif // !UNICODE - -#endif // WIN32 - - -#ifdef __cplusplus -}; -#endif - -#endif - +/*========================================================================== + * + * Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved. + * + * File: dsetup.h + * Content: DirectXSetup, error codes and flags + ***************************************************************************/ + +#ifndef __DSETUP_H__ +#define __DSETUP_H__ + +#include // windows stuff + +#ifdef _WIN32 +#define COM_NO_WINDOWS_H +#include +#else +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +#define FOURCC_VERS mmioFOURCC('v','e','r','s') + +// DSETUP Error Codes, must remain compatible with previous setup. +#define DSETUPERR_SUCCESS_RESTART 1 +#define DSETUPERR_SUCCESS 0 +#define DSETUPERR_BADWINDOWSVERSION -1 +#define DSETUPERR_SOURCEFILENOTFOUND -2 +#define DSETUPERR_NOCOPY -5 +#define DSETUPERR_OUTOFDISKSPACE -6 +#define DSETUPERR_CANTFINDINF -7 +#define DSETUPERR_CANTFINDDIR -8 +#define DSETUPERR_INTERNAL -9 +#define DSETUPERR_UNKNOWNOS -11 +#define DSETUPERR_NEWERVERSION -14 +#define DSETUPERR_NOTADMIN -15 +#define DSETUPERR_UNSUPPORTEDPROCESSOR -16 +#define DSETUPERR_MISSINGCAB_MANAGEDDX -17 +#define DSETUPERR_NODOTNETFRAMEWORKINSTALLED -18 +#define DSETUPERR_CABDOWNLOADFAIL -19 +#define DSETUPERR_DXCOMPONENTFILEINUSE -20 +#define DSETUPERR_UNTRUSTEDCABINETFILE -21 + +// DSETUP flags. DirectX 5.0 apps should use these flags only. +#define DSETUP_DDRAWDRV 0x00000008 /* install DirectDraw Drivers */ +#define DSETUP_DSOUNDDRV 0x00000010 /* install DirectSound Drivers */ +#define DSETUP_DXCORE 0x00010000 /* install DirectX runtime */ +#define DSETUP_DIRECTX (DSETUP_DXCORE|DSETUP_DDRAWDRV|DSETUP_DSOUNDDRV) +#define DSETUP_MANAGEDDX 0x00004000 /* OBSOLETE. install managed DirectX */ +#define DSETUP_TESTINSTALL 0x00020000 /* just test install, don't do anything */ + +// These OBSOLETE flags are here for compatibility with pre-DX5 apps only. +// They are present to allow DX3 apps to be recompiled with DX5 and still work. +// DO NOT USE THEM for DX5. They will go away in future DX releases. +#define DSETUP_DDRAW 0x00000001 /* OBSOLETE. install DirectDraw */ +#define DSETUP_DSOUND 0x00000002 /* OBSOLETE. install DirectSound */ +#define DSETUP_DPLAY 0x00000004 /* OBSOLETE. install DirectPlay */ +#define DSETUP_DPLAYSP 0x00000020 /* OBSOLETE. install DirectPlay Providers */ +#define DSETUP_DVIDEO 0x00000040 /* OBSOLETE. install DirectVideo */ +#define DSETUP_D3D 0x00000200 /* OBSOLETE. install Direct3D */ +#define DSETUP_DINPUT 0x00000800 /* OBSOLETE. install DirectInput */ +#define DSETUP_DIRECTXSETUP 0x00001000 /* OBSOLETE. install DirectXSetup DLL's */ +#define DSETUP_NOUI 0x00002000 /* OBSOLETE. install DirectX with NO UI */ +#define DSETUP_PROMPTFORDRIVERS 0x10000000 /* OBSOLETE. prompt when replacing display/audio drivers */ +#define DSETUP_RESTOREDRIVERS 0x20000000 /* OBSOLETE. restore display/audio drivers */ + + +//****************************************************************** +// DirectX Setup Callback mechanism +//****************************************************************** + +// DSETUP Message Info Codes, passed to callback as Reason parameter. +#define DSETUP_CB_MSG_NOMESSAGE 0 +#define DSETUP_CB_MSG_INTERNAL_ERROR 10 +#define DSETUP_CB_MSG_BEGIN_INSTALL 13 +#define DSETUP_CB_MSG_BEGIN_INSTALL_RUNTIME 14 +#define DSETUP_CB_MSG_PROGRESS 18 +#define DSETUP_CB_MSG_WARNING_DISABLED_COMPONENT 19 + + +typedef struct _DSETUP_CB_PROGRESS +{ + DWORD dwPhase; + DWORD dwInPhaseMaximum; + DWORD dwInPhaseProgress; + DWORD dwOverallMaximum; + DWORD dwOverallProgress; +} DSETUP_CB_PROGRESS; + + +enum _DSETUP_CB_PROGRESS_PHASE +{ + DSETUP_INITIALIZING, + DSETUP_EXTRACTING, + DSETUP_COPYING, + DSETUP_FINALIZING +}; + + +#ifdef _WIN32 +// +// Data Structures +// +#ifndef UNICODE_ONLY + +typedef struct _DIRECTXREGISTERAPPA { + DWORD dwSize; + DWORD dwFlags; + LPSTR lpszApplicationName; + LPGUID lpGUID; + LPSTR lpszFilename; + LPSTR lpszCommandLine; + LPSTR lpszPath; + LPSTR lpszCurrentDirectory; +} DIRECTXREGISTERAPPA, *PDIRECTXREGISTERAPPA, *LPDIRECTXREGISTERAPPA; + +typedef struct _DIRECTXREGISTERAPP2A { + DWORD dwSize; + DWORD dwFlags; + LPSTR lpszApplicationName; + LPGUID lpGUID; + LPSTR lpszFilename; + LPSTR lpszCommandLine; + LPSTR lpszPath; + LPSTR lpszCurrentDirectory; + LPSTR lpszLauncherName; +} DIRECTXREGISTERAPP2A, *PDIRECTXREGISTERAPP2A, *LPDIRECTXREGISTERAPP2A; + +#endif //!UNICODE_ONLY +#ifndef ANSI_ONLY + +typedef struct _DIRECTXREGISTERAPPW { + DWORD dwSize; + DWORD dwFlags; + LPWSTR lpszApplicationName; + LPGUID lpGUID; + LPWSTR lpszFilename; + LPWSTR lpszCommandLine; + LPWSTR lpszPath; + LPWSTR lpszCurrentDirectory; +} DIRECTXREGISTERAPPW, *PDIRECTXREGISTERAPPW, *LPDIRECTXREGISTERAPPW; + +typedef struct _DIRECTXREGISTERAPP2W { + DWORD dwSize; + DWORD dwFlags; + LPWSTR lpszApplicationName; + LPGUID lpGUID; + LPWSTR lpszFilename; + LPWSTR lpszCommandLine; + LPWSTR lpszPath; + LPWSTR lpszCurrentDirectory; + LPWSTR lpszLauncherName; +} DIRECTXREGISTERAPP2W, *PDIRECTXREGISTERAPP2W, *LPDIRECTXREGISTERAPP2W; +#endif //!ANSI_ONLY +#ifdef UNICODE +typedef DIRECTXREGISTERAPPW DIRECTXREGISTERAPP; +typedef PDIRECTXREGISTERAPPW PDIRECTXREGISTERAPP; +typedef LPDIRECTXREGISTERAPPW LPDIRECTXREGISTERAPP; +typedef DIRECTXREGISTERAPP2W DIRECTXREGISTERAPP2; +typedef PDIRECTXREGISTERAPP2W PDIRECTXREGISTERAPP2; +typedef LPDIRECTXREGISTERAPP2W LPDIRECTXREGISTERAPP2; +#else +typedef DIRECTXREGISTERAPPA DIRECTXREGISTERAPP; +typedef PDIRECTXREGISTERAPPA PDIRECTXREGISTERAPP; +typedef LPDIRECTXREGISTERAPPA LPDIRECTXREGISTERAPP; +typedef DIRECTXREGISTERAPP2A DIRECTXREGISTERAPP2; +typedef PDIRECTXREGISTERAPP2A PDIRECTXREGISTERAPP2; +typedef LPDIRECTXREGISTERAPP2A LPDIRECTXREGISTERAPP2; +#endif // UNICODE + + +// +// API +// + +#ifndef UNICODE_ONLY +INT +WINAPI +DirectXSetupA( + HWND hWnd, + LPSTR lpszRootPath, + DWORD dwFlags + ); +#endif //!UNICODE_ONLY +#ifndef ANSI_ONLY +INT +WINAPI +DirectXSetupW( + HWND hWnd, + LPWSTR lpszRootPath, + DWORD dwFlags + ); +#endif //!ANSI_ONLY +#ifdef UNICODE +#define DirectXSetup DirectXSetupW +#else +#define DirectXSetup DirectXSetupA +#endif // !UNICODE + +#ifndef UNICODE_ONLY +INT +WINAPI +DirectXRegisterApplicationA( + HWND hWnd, + LPVOID lpDXRegApp + ); +#endif //!UNICODE_ONLY +#ifndef ANSI_ONLY +INT +WINAPI +DirectXRegisterApplicationW( + HWND hWnd, + LPVOID lpDXRegApp + ); +#endif //!ANSI_ONLY +#ifdef UNICODE +#define DirectXRegisterApplication DirectXRegisterApplicationW +#else +#define DirectXRegisterApplication DirectXRegisterApplicationA +#endif // !UNICODE + +INT +WINAPI +DirectXUnRegisterApplication( + HWND hWnd, + LPGUID lpGUID + ); + +// +// Function Pointers +// +#ifdef UNICODE +typedef INT (WINAPI * LPDIRECTXSETUP)(HWND, LPWSTR, DWORD); +typedef INT (WINAPI * LPDIRECTXREGISTERAPPLICATION)(HWND, LPVOID); +#else +typedef INT (WINAPI * LPDIRECTXSETUP)(HWND, LPSTR, DWORD); +typedef INT (WINAPI * LPDIRECTXREGISTERAPPLICATION)(HWND, LPVOID); +#endif // UNICODE + +typedef DWORD (FAR PASCAL * DSETUP_CALLBACK)(DWORD Reason, + DWORD MsgType, /* Same as flags to MessageBox */ + LPSTR szMessage, + LPSTR szName, + void *pInfo); + +INT WINAPI DirectXSetupSetCallback(DSETUP_CALLBACK Callback); +INT WINAPI DirectXSetupGetVersion(DWORD *lpdwVersion, DWORD *lpdwMinorVersion); +INT WINAPI DirectXSetupShowEULA(HWND hWndParent); +#ifndef UNICODE_ONLY +UINT +WINAPI +DirectXSetupGetEULAA( + LPSTR lpszEULA, + UINT cchEULA, + WORD LangID + ); +#endif //!UNICODE_ONLY +#ifndef ANSI_ONLY +UINT +WINAPI +DirectXSetupGetEULAW( + LPWSTR lpszEULA, + UINT cchEULA, + WORD LangID + ); +#endif //!ANSI_ONLY +#ifdef UNICODE +#define DirectXSetupGetEULA DirectXSetupGetEULAW +typedef UINT (WINAPI * LPDIRECTXSETUPGETEULA)(LPWSTR, UINT, WORD); +#else +#define DirectXSetupGetEULA DirectXSetupGetEULAA +typedef UINT (WINAPI * LPDIRECTXSETUPGETEULA)(LPSTR, UINT, WORD); +#endif // !UNICODE + +#endif // WIN32 + + +#ifdef __cplusplus +}; +#endif + +#endif + diff --git a/src/dep/include/DXSDK/include/dsound.h b/src/dep/include/DXSDK/include/dsound.h index c088b63..8020a66 100644 --- a/src/dep/include/DXSDK/include/dsound.h +++ b/src/dep/include/DXSDK/include/dsound.h @@ -1,2358 +1,2358 @@ -/*==========================================================================; - * - * Copyright (c) Microsoft Corporation. All rights reserved. - * - * File: dsound.h - * Content: DirectSound include file - * - **************************************************************************/ - -#define COM_NO_WINDOWS_H -#include -#include - -#ifndef DIRECTSOUND_VERSION -#define DIRECTSOUND_VERSION 0x0900 /* Version 9.0 */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -#ifndef __DSOUND_INCLUDED__ -#define __DSOUND_INCLUDED__ - -/* Type definitions shared with Direct3D */ - -#ifndef DX_SHARED_DEFINES - -typedef float D3DVALUE, *LPD3DVALUE; - -#ifndef D3DCOLOR_DEFINED -typedef DWORD D3DCOLOR; -#define D3DCOLOR_DEFINED -#endif - -#ifndef LPD3DCOLOR_DEFINED -typedef DWORD *LPD3DCOLOR; -#define LPD3DCOLOR_DEFINED -#endif - -#ifndef D3DVECTOR_DEFINED -typedef struct _D3DVECTOR { - float x; - float y; - float z; -} D3DVECTOR; -#define D3DVECTOR_DEFINED -#endif - -#ifndef LPD3DVECTOR_DEFINED -typedef D3DVECTOR *LPD3DVECTOR; -#define LPD3DVECTOR_DEFINED -#endif - -#define DX_SHARED_DEFINES -#endif // DX_SHARED_DEFINES - -#define _FACDS 0x878 /* DirectSound's facility code */ -#define MAKE_DSHRESULT(code) MAKE_HRESULT(1, _FACDS, code) - -// DirectSound Component GUID {47D4D946-62E8-11CF-93BC-444553540000} -DEFINE_GUID(CLSID_DirectSound, 0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0); - -// DirectSound 8.0 Component GUID {3901CC3F-84B5-4FA4-BA35-AA8172B8A09B} -DEFINE_GUID(CLSID_DirectSound8, 0x3901cc3f, 0x84b5, 0x4fa4, 0xba, 0x35, 0xaa, 0x81, 0x72, 0xb8, 0xa0, 0x9b); - -// DirectSound Capture Component GUID {B0210780-89CD-11D0-AF08-00A0C925CD16} -DEFINE_GUID(CLSID_DirectSoundCapture, 0xb0210780, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); - -// DirectSound 8.0 Capture Component GUID {E4BCAC13-7F99-4908-9A8E-74E3BF24B6E1} -DEFINE_GUID(CLSID_DirectSoundCapture8, 0xe4bcac13, 0x7f99, 0x4908, 0x9a, 0x8e, 0x74, 0xe3, 0xbf, 0x24, 0xb6, 0xe1); - -// DirectSound Full Duplex Component GUID {FEA4300C-7959-4147-B26A-2377B9E7A91D} -DEFINE_GUID(CLSID_DirectSoundFullDuplex, 0xfea4300c, 0x7959, 0x4147, 0xb2, 0x6a, 0x23, 0x77, 0xb9, 0xe7, 0xa9, 0x1d); - - -// DirectSound default playback device GUID {DEF00000-9C6D-47ED-AAF1-4DDA8F2B5C03} -DEFINE_GUID(DSDEVID_DefaultPlayback, 0xdef00000, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); - -// DirectSound default capture device GUID {DEF00001-9C6D-47ED-AAF1-4DDA8F2B5C03} -DEFINE_GUID(DSDEVID_DefaultCapture, 0xdef00001, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); - -// DirectSound default device for voice playback {DEF00002-9C6D-47ED-AAF1-4DDA8F2B5C03} -DEFINE_GUID(DSDEVID_DefaultVoicePlayback, 0xdef00002, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); - -// DirectSound default device for voice capture {DEF00003-9C6D-47ED-AAF1-4DDA8F2B5C03} -DEFINE_GUID(DSDEVID_DefaultVoiceCapture, 0xdef00003, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); - - -// -// Forward declarations for interfaces. -// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined -// - -#ifdef __cplusplus -struct IDirectSound; -struct IDirectSoundBuffer; -struct IDirectSound3DListener; -struct IDirectSound3DBuffer; -struct IDirectSoundCapture; -struct IDirectSoundCaptureBuffer; -struct IDirectSoundNotify; -#endif // __cplusplus - - -// -// DirectSound 8.0 interfaces. -// - -#if DIRECTSOUND_VERSION >= 0x0800 - -#ifdef __cplusplus -struct IDirectSound8; -struct IDirectSoundBuffer8; -struct IDirectSoundCaptureBuffer8; -struct IDirectSoundFXGargle; -struct IDirectSoundFXChorus; -struct IDirectSoundFXFlanger; -struct IDirectSoundFXEcho; -struct IDirectSoundFXDistortion; -struct IDirectSoundFXCompressor; -struct IDirectSoundFXParamEq; -struct IDirectSoundFXWavesReverb; -struct IDirectSoundFXI3DL2Reverb; -struct IDirectSoundCaptureFXAec; -struct IDirectSoundCaptureFXNoiseSuppress; -struct IDirectSoundFullDuplex; -#endif // __cplusplus - -// IDirectSound8, IDirectSoundBuffer8 and IDirectSoundCaptureBuffer8 are the -// only DirectSound 7.0 interfaces with changed functionality in version 8.0. -// The other level 8 interfaces as equivalent to their level 7 counterparts: - -#define IDirectSoundCapture8 IDirectSoundCapture -#define IDirectSound3DListener8 IDirectSound3DListener -#define IDirectSound3DBuffer8 IDirectSound3DBuffer -#define IDirectSoundNotify8 IDirectSoundNotify -#define IDirectSoundFXGargle8 IDirectSoundFXGargle -#define IDirectSoundFXChorus8 IDirectSoundFXChorus -#define IDirectSoundFXFlanger8 IDirectSoundFXFlanger -#define IDirectSoundFXEcho8 IDirectSoundFXEcho -#define IDirectSoundFXDistortion8 IDirectSoundFXDistortion -#define IDirectSoundFXCompressor8 IDirectSoundFXCompressor -#define IDirectSoundFXParamEq8 IDirectSoundFXParamEq -#define IDirectSoundFXWavesReverb8 IDirectSoundFXWavesReverb -#define IDirectSoundFXI3DL2Reverb8 IDirectSoundFXI3DL2Reverb -#define IDirectSoundCaptureFXAec8 IDirectSoundCaptureFXAec -#define IDirectSoundCaptureFXNoiseSuppress8 IDirectSoundCaptureFXNoiseSuppress -#define IDirectSoundFullDuplex8 IDirectSoundFullDuplex - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -typedef struct IDirectSound *LPDIRECTSOUND; -typedef struct IDirectSoundBuffer *LPDIRECTSOUNDBUFFER; -typedef struct IDirectSound3DListener *LPDIRECTSOUND3DLISTENER; -typedef struct IDirectSound3DBuffer *LPDIRECTSOUND3DBUFFER; -typedef struct IDirectSoundCapture *LPDIRECTSOUNDCAPTURE; -typedef struct IDirectSoundCaptureBuffer *LPDIRECTSOUNDCAPTUREBUFFER; -typedef struct IDirectSoundNotify *LPDIRECTSOUNDNOTIFY; - - -#if DIRECTSOUND_VERSION >= 0x0800 - -typedef struct IDirectSoundFXGargle *LPDIRECTSOUNDFXGARGLE; -typedef struct IDirectSoundFXChorus *LPDIRECTSOUNDFXCHORUS; -typedef struct IDirectSoundFXFlanger *LPDIRECTSOUNDFXFLANGER; -typedef struct IDirectSoundFXEcho *LPDIRECTSOUNDFXECHO; -typedef struct IDirectSoundFXDistortion *LPDIRECTSOUNDFXDISTORTION; -typedef struct IDirectSoundFXCompressor *LPDIRECTSOUNDFXCOMPRESSOR; -typedef struct IDirectSoundFXParamEq *LPDIRECTSOUNDFXPARAMEQ; -typedef struct IDirectSoundFXWavesReverb *LPDIRECTSOUNDFXWAVESREVERB; -typedef struct IDirectSoundFXI3DL2Reverb *LPDIRECTSOUNDFXI3DL2REVERB; -typedef struct IDirectSoundCaptureFXAec *LPDIRECTSOUNDCAPTUREFXAEC; -typedef struct IDirectSoundCaptureFXNoiseSuppress *LPDIRECTSOUNDCAPTUREFXNOISESUPPRESS; -typedef struct IDirectSoundFullDuplex *LPDIRECTSOUNDFULLDUPLEX; - -typedef struct IDirectSound8 *LPDIRECTSOUND8; -typedef struct IDirectSoundBuffer8 *LPDIRECTSOUNDBUFFER8; -typedef struct IDirectSound3DListener8 *LPDIRECTSOUND3DLISTENER8; -typedef struct IDirectSound3DBuffer8 *LPDIRECTSOUND3DBUFFER8; -typedef struct IDirectSoundCapture8 *LPDIRECTSOUNDCAPTURE8; -typedef struct IDirectSoundCaptureBuffer8 *LPDIRECTSOUNDCAPTUREBUFFER8; -typedef struct IDirectSoundNotify8 *LPDIRECTSOUNDNOTIFY8; -typedef struct IDirectSoundFXGargle8 *LPDIRECTSOUNDFXGARGLE8; -typedef struct IDirectSoundFXChorus8 *LPDIRECTSOUNDFXCHORUS8; -typedef struct IDirectSoundFXFlanger8 *LPDIRECTSOUNDFXFLANGER8; -typedef struct IDirectSoundFXEcho8 *LPDIRECTSOUNDFXECHO8; -typedef struct IDirectSoundFXDistortion8 *LPDIRECTSOUNDFXDISTORTION8; -typedef struct IDirectSoundFXCompressor8 *LPDIRECTSOUNDFXCOMPRESSOR8; -typedef struct IDirectSoundFXParamEq8 *LPDIRECTSOUNDFXPARAMEQ8; -typedef struct IDirectSoundFXWavesReverb8 *LPDIRECTSOUNDFXWAVESREVERB8; -typedef struct IDirectSoundFXI3DL2Reverb8 *LPDIRECTSOUNDFXI3DL2REVERB8; -typedef struct IDirectSoundCaptureFXAec8 *LPDIRECTSOUNDCAPTUREFXAEC8; -typedef struct IDirectSoundCaptureFXNoiseSuppress8 *LPDIRECTSOUNDCAPTUREFXNOISESUPPRESS8; -typedef struct IDirectSoundFullDuplex8 *LPDIRECTSOUNDFULLDUPLEX8; - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -// -// IID definitions for the unchanged DirectSound 8.0 interfaces -// - -#if DIRECTSOUND_VERSION >= 0x0800 - -#define IID_IDirectSoundCapture8 IID_IDirectSoundCapture -#define IID_IDirectSound3DListener8 IID_IDirectSound3DListener -#define IID_IDirectSound3DBuffer8 IID_IDirectSound3DBuffer -#define IID_IDirectSoundNotify8 IID_IDirectSoundNotify -#define IID_IDirectSoundFXGargle8 IID_IDirectSoundFXGargle -#define IID_IDirectSoundFXChorus8 IID_IDirectSoundFXChorus -#define IID_IDirectSoundFXFlanger8 IID_IDirectSoundFXFlanger -#define IID_IDirectSoundFXEcho8 IID_IDirectSoundFXEcho -#define IID_IDirectSoundFXDistortion8 IID_IDirectSoundFXDistortion -#define IID_IDirectSoundFXCompressor8 IID_IDirectSoundFXCompressor -#define IID_IDirectSoundFXParamEq8 IID_IDirectSoundFXParamEq -#define IID_IDirectSoundFXWavesReverb8 IID_IDirectSoundFXWavesReverb -#define IID_IDirectSoundFXI3DL2Reverb8 IID_IDirectSoundFXI3DL2Reverb -#define IID_IDirectSoundCaptureFXAec8 IID_IDirectSoundCaptureFXAec -#define IID_IDirectSoundCaptureFXNoiseSuppress8 IID_IDirectSoundCaptureFXNoiseSuppress -#define IID_IDirectSoundFullDuplex8 IID_IDirectSoundFullDuplex - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -// -// Compatibility typedefs -// - -#ifndef _LPCWAVEFORMATEX_DEFINED -#define _LPCWAVEFORMATEX_DEFINED -typedef const WAVEFORMATEX *LPCWAVEFORMATEX; -#endif // _LPCWAVEFORMATEX_DEFINED - -#ifndef __LPCGUID_DEFINED__ -#define __LPCGUID_DEFINED__ -typedef const GUID *LPCGUID; -#endif // __LPCGUID_DEFINED__ - -typedef LPDIRECTSOUND *LPLPDIRECTSOUND; -typedef LPDIRECTSOUNDBUFFER *LPLPDIRECTSOUNDBUFFER; -typedef LPDIRECTSOUND3DLISTENER *LPLPDIRECTSOUND3DLISTENER; -typedef LPDIRECTSOUND3DBUFFER *LPLPDIRECTSOUND3DBUFFER; -typedef LPDIRECTSOUNDCAPTURE *LPLPDIRECTSOUNDCAPTURE; -typedef LPDIRECTSOUNDCAPTUREBUFFER *LPLPDIRECTSOUNDCAPTUREBUFFER; -typedef LPDIRECTSOUNDNOTIFY *LPLPDIRECTSOUNDNOTIFY; - -#if DIRECTSOUND_VERSION >= 0x0800 -typedef LPDIRECTSOUND8 *LPLPDIRECTSOUND8; -typedef LPDIRECTSOUNDBUFFER8 *LPLPDIRECTSOUNDBUFFER8; -typedef LPDIRECTSOUNDCAPTURE8 *LPLPDIRECTSOUNDCAPTURE8; -typedef LPDIRECTSOUNDCAPTUREBUFFER8 *LPLPDIRECTSOUNDCAPTUREBUFFER8; -#endif // DIRECTSOUND_VERSION >= 0x0800 - -// -// Structures -// - -typedef struct _DSCAPS -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwMinSecondarySampleRate; - DWORD dwMaxSecondarySampleRate; - DWORD dwPrimaryBuffers; - DWORD dwMaxHwMixingAllBuffers; - DWORD dwMaxHwMixingStaticBuffers; - DWORD dwMaxHwMixingStreamingBuffers; - DWORD dwFreeHwMixingAllBuffers; - DWORD dwFreeHwMixingStaticBuffers; - DWORD dwFreeHwMixingStreamingBuffers; - DWORD dwMaxHw3DAllBuffers; - DWORD dwMaxHw3DStaticBuffers; - DWORD dwMaxHw3DStreamingBuffers; - DWORD dwFreeHw3DAllBuffers; - DWORD dwFreeHw3DStaticBuffers; - DWORD dwFreeHw3DStreamingBuffers; - DWORD dwTotalHwMemBytes; - DWORD dwFreeHwMemBytes; - DWORD dwMaxContigFreeHwMemBytes; - DWORD dwUnlockTransferRateHwBuffers; - DWORD dwPlayCpuOverheadSwBuffers; - DWORD dwReserved1; - DWORD dwReserved2; -} DSCAPS, *LPDSCAPS; - -typedef const DSCAPS *LPCDSCAPS; - -typedef struct _DSBCAPS -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwBufferBytes; - DWORD dwUnlockTransferRate; - DWORD dwPlayCpuOverhead; -} DSBCAPS, *LPDSBCAPS; - -typedef const DSBCAPS *LPCDSBCAPS; - -#if DIRECTSOUND_VERSION >= 0x0800 - - typedef struct _DSEFFECTDESC - { - DWORD dwSize; - DWORD dwFlags; - GUID guidDSFXClass; - DWORD_PTR dwReserved1; - DWORD_PTR dwReserved2; - } DSEFFECTDESC, *LPDSEFFECTDESC; - typedef const DSEFFECTDESC *LPCDSEFFECTDESC; - - #define DSFX_LOCHARDWARE 0x00000001 - #define DSFX_LOCSOFTWARE 0x00000002 - - enum - { - DSFXR_PRESENT, // 0 - DSFXR_LOCHARDWARE, // 1 - DSFXR_LOCSOFTWARE, // 2 - DSFXR_UNALLOCATED, // 3 - DSFXR_FAILED, // 4 - DSFXR_UNKNOWN, // 5 - DSFXR_SENDLOOP // 6 - }; - - typedef struct _DSCEFFECTDESC - { - DWORD dwSize; - DWORD dwFlags; - GUID guidDSCFXClass; - GUID guidDSCFXInstance; - DWORD dwReserved1; - DWORD dwReserved2; - } DSCEFFECTDESC, *LPDSCEFFECTDESC; - typedef const DSCEFFECTDESC *LPCDSCEFFECTDESC; - - #define DSCFX_LOCHARDWARE 0x00000001 - #define DSCFX_LOCSOFTWARE 0x00000002 - - #define DSCFXR_LOCHARDWARE 0x00000010 - #define DSCFXR_LOCSOFTWARE 0x00000020 - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -typedef struct _DSBUFFERDESC -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwBufferBytes; - DWORD dwReserved; - LPWAVEFORMATEX lpwfxFormat; -#if DIRECTSOUND_VERSION >= 0x0700 - GUID guid3DAlgorithm; -#endif -} DSBUFFERDESC, *LPDSBUFFERDESC; - -typedef const DSBUFFERDESC *LPCDSBUFFERDESC; - -// Older version of this structure: - -typedef struct _DSBUFFERDESC1 -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwBufferBytes; - DWORD dwReserved; - LPWAVEFORMATEX lpwfxFormat; -} DSBUFFERDESC1, *LPDSBUFFERDESC1; - -typedef const DSBUFFERDESC1 *LPCDSBUFFERDESC1; - -typedef struct _DS3DBUFFER -{ - DWORD dwSize; - D3DVECTOR vPosition; - D3DVECTOR vVelocity; - DWORD dwInsideConeAngle; - DWORD dwOutsideConeAngle; - D3DVECTOR vConeOrientation; - LONG lConeOutsideVolume; - D3DVALUE flMinDistance; - D3DVALUE flMaxDistance; - DWORD dwMode; -} DS3DBUFFER, *LPDS3DBUFFER; - -typedef const DS3DBUFFER *LPCDS3DBUFFER; - -typedef struct _DS3DLISTENER -{ - DWORD dwSize; - D3DVECTOR vPosition; - D3DVECTOR vVelocity; - D3DVECTOR vOrientFront; - D3DVECTOR vOrientTop; - D3DVALUE flDistanceFactor; - D3DVALUE flRolloffFactor; - D3DVALUE flDopplerFactor; -} DS3DLISTENER, *LPDS3DLISTENER; - -typedef const DS3DLISTENER *LPCDS3DLISTENER; - -typedef struct _DSCCAPS -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwFormats; - DWORD dwChannels; -} DSCCAPS, *LPDSCCAPS; - -typedef const DSCCAPS *LPCDSCCAPS; - -typedef struct _DSCBUFFERDESC1 -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwBufferBytes; - DWORD dwReserved; - LPWAVEFORMATEX lpwfxFormat; -} DSCBUFFERDESC1, *LPDSCBUFFERDESC1; - -typedef struct _DSCBUFFERDESC -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwBufferBytes; - DWORD dwReserved; - LPWAVEFORMATEX lpwfxFormat; -#if DIRECTSOUND_VERSION >= 0x0800 - DWORD dwFXCount; - LPDSCEFFECTDESC lpDSCFXDesc; -#endif -} DSCBUFFERDESC, *LPDSCBUFFERDESC; - -typedef const DSCBUFFERDESC *LPCDSCBUFFERDESC; - -typedef struct _DSCBCAPS -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwBufferBytes; - DWORD dwReserved; -} DSCBCAPS, *LPDSCBCAPS; - -typedef const DSCBCAPS *LPCDSCBCAPS; - -typedef struct _DSBPOSITIONNOTIFY -{ - DWORD dwOffset; - HANDLE hEventNotify; -} DSBPOSITIONNOTIFY, *LPDSBPOSITIONNOTIFY; - -typedef const DSBPOSITIONNOTIFY *LPCDSBPOSITIONNOTIFY; - -// -// DirectSound API -// - -typedef BOOL (CALLBACK *LPDSENUMCALLBACKA)(LPGUID, LPCSTR, LPCSTR, LPVOID); -typedef BOOL (CALLBACK *LPDSENUMCALLBACKW)(LPGUID, LPCWSTR, LPCWSTR, LPVOID); - -extern HRESULT WINAPI DirectSoundCreate(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter); -extern HRESULT WINAPI DirectSoundEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext); -extern HRESULT WINAPI DirectSoundEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext); - -extern HRESULT WINAPI DirectSoundCaptureCreate(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE *ppDSC, LPUNKNOWN pUnkOuter); -extern HRESULT WINAPI DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext); -extern HRESULT WINAPI DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext); - -#if DIRECTSOUND_VERSION >= 0x0800 -extern HRESULT WINAPI DirectSoundCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUND8 *ppDS8, LPUNKNOWN pUnkOuter); -extern HRESULT WINAPI DirectSoundCaptureCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE8 *ppDSC8, LPUNKNOWN pUnkOuter); -extern HRESULT WINAPI DirectSoundFullDuplexCreate(LPCGUID pcGuidCaptureDevice, LPCGUID pcGuidRenderDevice, - LPCDSCBUFFERDESC pcDSCBufferDesc, LPCDSBUFFERDESC pcDSBufferDesc, HWND hWnd, - DWORD dwLevel, LPDIRECTSOUNDFULLDUPLEX* ppDSFD, LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8, - LPDIRECTSOUNDBUFFER8 *ppDSBuffer8, LPUNKNOWN pUnkOuter); -#define DirectSoundFullDuplexCreate8 DirectSoundFullDuplexCreate - -extern HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest); -#endif // DIRECTSOUND_VERSION >= 0x0800 - -#ifdef UNICODE -#define LPDSENUMCALLBACK LPDSENUMCALLBACKW -#define DirectSoundEnumerate DirectSoundEnumerateW -#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateW -#else // UNICODE -#define LPDSENUMCALLBACK LPDSENUMCALLBACKA -#define DirectSoundEnumerate DirectSoundEnumerateA -#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateA -#endif // UNICODE - -// -// IUnknown -// - -#if !defined(__cplusplus) || defined(CINTERFACE) -#ifndef IUnknown_QueryInterface -#define IUnknown_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#endif // IUnknown_QueryInterface -#ifndef IUnknown_AddRef -#define IUnknown_AddRef(p) (p)->lpVtbl->AddRef(p) -#endif // IUnknown_AddRef -#ifndef IUnknown_Release -#define IUnknown_Release(p) (p)->lpVtbl->Release(p) -#endif // IUnknown_Release -#else // !defined(__cplusplus) || defined(CINTERFACE) -#ifndef IUnknown_QueryInterface -#define IUnknown_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#endif // IUnknown_QueryInterface -#ifndef IUnknown_AddRef -#define IUnknown_AddRef(p) (p)->AddRef() -#endif // IUnknown_AddRef -#ifndef IUnknown_Release -#define IUnknown_Release(p) (p)->Release() -#endif // IUnknown_Release -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#ifndef __IReferenceClock_INTERFACE_DEFINED__ -#define __IReferenceClock_INTERFACE_DEFINED__ - -typedef LONGLONG REFERENCE_TIME; -typedef REFERENCE_TIME *LPREFERENCE_TIME; - -DEFINE_GUID(IID_IReferenceClock, 0x56a86897, 0x0ad4, 0x11ce, 0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70); - -#undef INTERFACE -#define INTERFACE IReferenceClock - -DECLARE_INTERFACE_(IReferenceClock, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IReferenceClock methods - STDMETHOD(GetTime) (THIS_ REFERENCE_TIME *pTime) PURE; - STDMETHOD(AdviseTime) (THIS_ REFERENCE_TIME rtBaseTime, REFERENCE_TIME rtStreamTime, - HANDLE hEvent, LPDWORD pdwAdviseCookie) PURE; - STDMETHOD(AdvisePeriodic) (THIS_ REFERENCE_TIME rtStartTime, REFERENCE_TIME rtPeriodTime, - HANDLE hSemaphore, LPDWORD pdwAdviseCookie) PURE; - STDMETHOD(Unadvise) (THIS_ DWORD dwAdviseCookie) PURE; -}; - -#endif // __IReferenceClock_INTERFACE_DEFINED__ - -#ifndef IReferenceClock_QueryInterface - -#define IReferenceClock_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IReferenceClock_AddRef(p) IUnknown_AddRef(p) -#define IReferenceClock_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IReferenceClock_GetTime(p,a) (p)->lpVtbl->GetTime(p,a) -#define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->lpVtbl->AdviseTime(p,a,b,c,d) -#define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->lpVtbl->AdvisePeriodic(p,a,b,c,d) -#define IReferenceClock_Unadvise(p,a) (p)->lpVtbl->Unadvise(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IReferenceClock_GetTime(p,a) (p)->GetTime(a) -#define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->AdviseTime(a,b,c,d) -#define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->AdvisePeriodic(a,b,c,d) -#define IReferenceClock_Unadvise(p,a) (p)->Unadvise(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#endif // IReferenceClock_QueryInterface - -// -// IDirectSound -// - -DEFINE_GUID(IID_IDirectSound, 0x279AFA83, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); - -#undef INTERFACE -#define INTERFACE IDirectSound - -DECLARE_INTERFACE_(IDirectSound, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSound methods - STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(GetCaps) (THIS_ LPDSCAPS pDSCaps) PURE; - STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE; - STDMETHOD(SetCooperativeLevel) (THIS_ HWND hwnd, DWORD dwLevel) PURE; - STDMETHOD(Compact) (THIS) PURE; - STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD pdwSpeakerConfig) PURE; - STDMETHOD(SetSpeakerConfig) (THIS_ DWORD dwSpeakerConfig) PURE; - STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; -}; - -#define IDirectSound_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSound_AddRef(p) IUnknown_AddRef(p) -#define IDirectSound_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->lpVtbl->CreateSoundBuffer(p,a,b,c) -#define IDirectSound_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) -#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->lpVtbl->DuplicateSoundBuffer(p,a,b) -#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectSound_Compact(p) (p)->lpVtbl->Compact(p) -#define IDirectSound_GetSpeakerConfig(p,a) (p)->lpVtbl->GetSpeakerConfig(p,a) -#define IDirectSound_SetSpeakerConfig(p,b) (p)->lpVtbl->SetSpeakerConfig(p,b) -#define IDirectSound_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->CreateSoundBuffer(a,b,c) -#define IDirectSound_GetCaps(p,a) (p)->GetCaps(a) -#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->DuplicateSoundBuffer(a,b) -#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectSound_Compact(p) (p)->Compact() -#define IDirectSound_GetSpeakerConfig(p,a) (p)->GetSpeakerConfig(a) -#define IDirectSound_SetSpeakerConfig(p,b) (p)->SetSpeakerConfig(b) -#define IDirectSound_Initialize(p,a) (p)->Initialize(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#if DIRECTSOUND_VERSION >= 0x0800 - -// -// IDirectSound8 -// - -DEFINE_GUID(IID_IDirectSound8, 0xC50A7E93, 0xF395, 0x4834, 0x9E, 0xF6, 0x7F, 0xA9, 0x9D, 0xE5, 0x09, 0x66); - -#undef INTERFACE -#define INTERFACE IDirectSound8 - -DECLARE_INTERFACE_(IDirectSound8, IDirectSound) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSound methods - STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(GetCaps) (THIS_ LPDSCAPS pDSCaps) PURE; - STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE; - STDMETHOD(SetCooperativeLevel) (THIS_ HWND hwnd, DWORD dwLevel) PURE; - STDMETHOD(Compact) (THIS) PURE; - STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD pdwSpeakerConfig) PURE; - STDMETHOD(SetSpeakerConfig) (THIS_ DWORD dwSpeakerConfig) PURE; - STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; - - // IDirectSound8 methods - STDMETHOD(VerifyCertification) (THIS_ LPDWORD pdwCertified) PURE; -}; - -#define IDirectSound8_QueryInterface(p,a,b) IDirectSound_QueryInterface(p,a,b) -#define IDirectSound8_AddRef(p) IDirectSound_AddRef(p) -#define IDirectSound8_Release(p) IDirectSound_Release(p) -#define IDirectSound8_CreateSoundBuffer(p,a,b,c) IDirectSound_CreateSoundBuffer(p,a,b,c) -#define IDirectSound8_GetCaps(p,a) IDirectSound_GetCaps(p,a) -#define IDirectSound8_DuplicateSoundBuffer(p,a,b) IDirectSound_DuplicateSoundBuffer(p,a,b) -#define IDirectSound8_SetCooperativeLevel(p,a,b) IDirectSound_SetCooperativeLevel(p,a,b) -#define IDirectSound8_Compact(p) IDirectSound_Compact(p) -#define IDirectSound8_GetSpeakerConfig(p,a) IDirectSound_GetSpeakerConfig(p,a) -#define IDirectSound8_SetSpeakerConfig(p,a) IDirectSound_SetSpeakerConfig(p,a) -#define IDirectSound8_Initialize(p,a) IDirectSound_Initialize(p,a) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound8_VerifyCertification(p,a) (p)->lpVtbl->VerifyCertification(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound8_VerifyCertification(p,a) (p)->VerifyCertification(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -// -// IDirectSoundBuffer -// - -DEFINE_GUID(IID_IDirectSoundBuffer, 0x279AFA85, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); - -#undef INTERFACE -#define INTERFACE IDirectSoundBuffer - -DECLARE_INTERFACE_(IDirectSoundBuffer, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundBuffer methods - STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE; - STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor) PURE; - STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; - STDMETHOD(GetVolume) (THIS_ LPLONG plVolume) PURE; - STDMETHOD(GetPan) (THIS_ LPLONG plPan) PURE; - STDMETHOD(GetFrequency) (THIS_ LPDWORD pdwFrequency) PURE; - STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc) PURE; - STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, - LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; - STDMETHOD(Play) (THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE; - STDMETHOD(SetCurrentPosition) (THIS_ DWORD dwNewPosition) PURE; - STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX pcfxFormat) PURE; - STDMETHOD(SetVolume) (THIS_ LONG lVolume) PURE; - STDMETHOD(SetPan) (THIS_ LONG lPan) PURE; - STDMETHOD(SetFrequency) (THIS_ DWORD dwFrequency) PURE; - STDMETHOD(Stop) (THIS) PURE; - STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; - STDMETHOD(Restore) (THIS) PURE; -}; - -#define IDirectSoundBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundBuffer_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundBuffer_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) -#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b) -#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c) -#define IDirectSoundBuffer_GetVolume(p,a) (p)->lpVtbl->GetVolume(p,a) -#define IDirectSoundBuffer_GetPan(p,a) (p)->lpVtbl->GetPan(p,a) -#define IDirectSoundBuffer_GetFrequency(p,a) (p)->lpVtbl->GetFrequency(p,a) -#define IDirectSoundBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a) -#define IDirectSoundBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g) -#define IDirectSoundBuffer_Play(p,a,b,c) (p)->lpVtbl->Play(p,a,b,c) -#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->lpVtbl->SetCurrentPosition(p,a) -#define IDirectSoundBuffer_SetFormat(p,a) (p)->lpVtbl->SetFormat(p,a) -#define IDirectSoundBuffer_SetVolume(p,a) (p)->lpVtbl->SetVolume(p,a) -#define IDirectSoundBuffer_SetPan(p,a) (p)->lpVtbl->SetPan(p,a) -#define IDirectSoundBuffer_SetFrequency(p,a) (p)->lpVtbl->SetFrequency(p,a) -#define IDirectSoundBuffer_Stop(p) (p)->lpVtbl->Stop(p) -#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d) -#define IDirectSoundBuffer_Restore(p) (p)->lpVtbl->Restore(p) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundBuffer_GetCaps(p,a) (p)->GetCaps(a) -#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b) -#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c) -#define IDirectSoundBuffer_GetVolume(p,a) (p)->GetVolume(a) -#define IDirectSoundBuffer_GetPan(p,a) (p)->GetPan(a) -#define IDirectSoundBuffer_GetFrequency(p,a) (p)->GetFrequency(a) -#define IDirectSoundBuffer_GetStatus(p,a) (p)->GetStatus(a) -#define IDirectSoundBuffer_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g) -#define IDirectSoundBuffer_Play(p,a,b,c) (p)->Play(a,b,c) -#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->SetCurrentPosition(a) -#define IDirectSoundBuffer_SetFormat(p,a) (p)->SetFormat(a) -#define IDirectSoundBuffer_SetVolume(p,a) (p)->SetVolume(a) -#define IDirectSoundBuffer_SetPan(p,a) (p)->SetPan(a) -#define IDirectSoundBuffer_SetFrequency(p,a) (p)->SetFrequency(a) -#define IDirectSoundBuffer_Stop(p) (p)->Stop() -#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d) -#define IDirectSoundBuffer_Restore(p) (p)->Restore() -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#if DIRECTSOUND_VERSION >= 0x0800 - -// -// IDirectSoundBuffer8 -// - -DEFINE_GUID(IID_IDirectSoundBuffer8, 0x6825a449, 0x7524, 0x4d82, 0x92, 0x0f, 0x50, 0xe3, 0x6a, 0xb3, 0xab, 0x1e); - -#undef INTERFACE -#define INTERFACE IDirectSoundBuffer8 - -DECLARE_INTERFACE_(IDirectSoundBuffer8, IDirectSoundBuffer) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundBuffer methods - STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE; - STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor) PURE; - STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; - STDMETHOD(GetVolume) (THIS_ LPLONG plVolume) PURE; - STDMETHOD(GetPan) (THIS_ LPLONG plPan) PURE; - STDMETHOD(GetFrequency) (THIS_ LPDWORD pdwFrequency) PURE; - STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc) PURE; - STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, - LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; - STDMETHOD(Play) (THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE; - STDMETHOD(SetCurrentPosition) (THIS_ DWORD dwNewPosition) PURE; - STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX pcfxFormat) PURE; - STDMETHOD(SetVolume) (THIS_ LONG lVolume) PURE; - STDMETHOD(SetPan) (THIS_ LONG lPan) PURE; - STDMETHOD(SetFrequency) (THIS_ DWORD dwFrequency) PURE; - STDMETHOD(Stop) (THIS) PURE; - STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; - STDMETHOD(Restore) (THIS) PURE; - - // IDirectSoundBuffer8 methods - STDMETHOD(SetFX) (THIS_ DWORD dwEffectsCount, LPDSEFFECTDESC pDSFXDesc, LPDWORD pdwResultCodes) PURE; - STDMETHOD(AcquireResources) (THIS_ DWORD dwFlags, DWORD dwEffectsCount, LPDWORD pdwResultCodes) PURE; - STDMETHOD(GetObjectInPath) (THIS_ REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject) PURE; -}; - -// Special GUID meaning "select all objects" for use in GetObjectInPath() -DEFINE_GUID(GUID_All_Objects, 0xaa114de5, 0xc262, 0x4169, 0xa1, 0xc8, 0x23, 0xd6, 0x98, 0xcc, 0x73, 0xb5); - -#define IDirectSoundBuffer8_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundBuffer8_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundBuffer8_Release(p) IUnknown_Release(p) - -#define IDirectSoundBuffer8_GetCaps(p,a) IDirectSoundBuffer_GetCaps(p,a) -#define IDirectSoundBuffer8_GetCurrentPosition(p,a,b) IDirectSoundBuffer_GetCurrentPosition(p,a,b) -#define IDirectSoundBuffer8_GetFormat(p,a,b,c) IDirectSoundBuffer_GetFormat(p,a,b,c) -#define IDirectSoundBuffer8_GetVolume(p,a) IDirectSoundBuffer_GetVolume(p,a) -#define IDirectSoundBuffer8_GetPan(p,a) IDirectSoundBuffer_GetPan(p,a) -#define IDirectSoundBuffer8_GetFrequency(p,a) IDirectSoundBuffer_GetFrequency(p,a) -#define IDirectSoundBuffer8_GetStatus(p,a) IDirectSoundBuffer_GetStatus(p,a) -#define IDirectSoundBuffer8_Initialize(p,a,b) IDirectSoundBuffer_Initialize(p,a,b) -#define IDirectSoundBuffer8_Lock(p,a,b,c,d,e,f,g) IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) -#define IDirectSoundBuffer8_Play(p,a,b,c) IDirectSoundBuffer_Play(p,a,b,c) -#define IDirectSoundBuffer8_SetCurrentPosition(p,a) IDirectSoundBuffer_SetCurrentPosition(p,a) -#define IDirectSoundBuffer8_SetFormat(p,a) IDirectSoundBuffer_SetFormat(p,a) -#define IDirectSoundBuffer8_SetVolume(p,a) IDirectSoundBuffer_SetVolume(p,a) -#define IDirectSoundBuffer8_SetPan(p,a) IDirectSoundBuffer_SetPan(p,a) -#define IDirectSoundBuffer8_SetFrequency(p,a) IDirectSoundBuffer_SetFrequency(p,a) -#define IDirectSoundBuffer8_Stop(p) IDirectSoundBuffer_Stop(p) -#define IDirectSoundBuffer8_Unlock(p,a,b,c,d) IDirectSoundBuffer_Unlock(p,a,b,c,d) -#define IDirectSoundBuffer8_Restore(p) IDirectSoundBuffer_Restore(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundBuffer8_SetFX(p,a,b,c) (p)->lpVtbl->SetFX(p,a,b,c) -#define IDirectSoundBuffer8_AcquireResources(p,a,b,c) (p)->lpVtbl->AcquireResources(p,a,b,c) -#define IDirectSoundBuffer8_GetObjectInPath(p,a,b,c,d) (p)->lpVtbl->GetObjectInPath(p,a,b,c,d) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundBuffer8_SetFX(p,a,b,c) (p)->SetFX(a,b,c) -#define IDirectSoundBuffer8_AcquireResources(p,a,b,c) (p)->AcquireResources(a,b,c) -#define IDirectSoundBuffer8_GetObjectInPath(p,a,b,c,d) (p)->GetObjectInPath(a,b,c,d) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -// -// IDirectSound3DListener -// - -DEFINE_GUID(IID_IDirectSound3DListener, 0x279AFA84, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); - -#undef INTERFACE -#define INTERFACE IDirectSound3DListener - -DECLARE_INTERFACE_(IDirectSound3DListener, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSound3DListener methods - STDMETHOD(GetAllParameters) (THIS_ LPDS3DLISTENER pListener) PURE; - STDMETHOD(GetDistanceFactor) (THIS_ D3DVALUE* pflDistanceFactor) PURE; - STDMETHOD(GetDopplerFactor) (THIS_ D3DVALUE* pflDopplerFactor) PURE; - STDMETHOD(GetOrientation) (THIS_ D3DVECTOR* pvOrientFront, D3DVECTOR* pvOrientTop) PURE; - STDMETHOD(GetPosition) (THIS_ D3DVECTOR* pvPosition) PURE; - STDMETHOD(GetRolloffFactor) (THIS_ D3DVALUE* pflRolloffFactor) PURE; - STDMETHOD(GetVelocity) (THIS_ D3DVECTOR* pvVelocity) PURE; - STDMETHOD(SetAllParameters) (THIS_ LPCDS3DLISTENER pcListener, DWORD dwApply) PURE; - STDMETHOD(SetDistanceFactor) (THIS_ D3DVALUE flDistanceFactor, DWORD dwApply) PURE; - STDMETHOD(SetDopplerFactor) (THIS_ D3DVALUE flDopplerFactor, DWORD dwApply) PURE; - STDMETHOD(SetOrientation) (THIS_ D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront, - D3DVALUE xTop, D3DVALUE yTop, D3DVALUE zTop, DWORD dwApply) PURE; - STDMETHOD(SetPosition) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; - STDMETHOD(SetRolloffFactor) (THIS_ D3DVALUE flRolloffFactor, DWORD dwApply) PURE; - STDMETHOD(SetVelocity) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; - STDMETHOD(CommitDeferredSettings) (THIS) PURE; -}; - -#define IDirectSound3DListener_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSound3DListener_AddRef(p) IUnknown_AddRef(p) -#define IDirectSound3DListener_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound3DListener_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->lpVtbl->GetDistanceFactor(p,a) -#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->lpVtbl->GetDopplerFactor(p,a) -#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->lpVtbl->GetOrientation(p,a,b) -#define IDirectSound3DListener_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a) -#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->lpVtbl->GetRolloffFactor(p,a) -#define IDirectSound3DListener_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a) -#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b) -#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->lpVtbl->SetDistanceFactor(p,a,b) -#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->lpVtbl->SetDopplerFactor(p,a,b) -#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->lpVtbl->SetOrientation(p,a,b,c,d,e,f,g) -#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d) -#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->lpVtbl->SetRolloffFactor(p,a,b) -#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d) -#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->lpVtbl->CommitDeferredSettings(p) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound3DListener_GetAllParameters(p,a) (p)->GetAllParameters(a) -#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->GetDistanceFactor(a) -#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->GetDopplerFactor(a) -#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->GetOrientation(a,b) -#define IDirectSound3DListener_GetPosition(p,a) (p)->GetPosition(a) -#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->GetRolloffFactor(a) -#define IDirectSound3DListener_GetVelocity(p,a) (p)->GetVelocity(a) -#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b) -#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->SetDistanceFactor(a,b) -#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->SetDopplerFactor(a,b) -#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->SetOrientation(a,b,c,d,e,f,g) -#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d) -#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->SetRolloffFactor(a,b) -#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d) -#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->CommitDeferredSettings() -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSound3DBuffer -// - -DEFINE_GUID(IID_IDirectSound3DBuffer, 0x279AFA86, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); - -#undef INTERFACE -#define INTERFACE IDirectSound3DBuffer - -DECLARE_INTERFACE_(IDirectSound3DBuffer, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSound3DBuffer methods - STDMETHOD(GetAllParameters) (THIS_ LPDS3DBUFFER pDs3dBuffer) PURE; - STDMETHOD(GetConeAngles) (THIS_ LPDWORD pdwInsideConeAngle, LPDWORD pdwOutsideConeAngle) PURE; - STDMETHOD(GetConeOrientation) (THIS_ D3DVECTOR* pvOrientation) PURE; - STDMETHOD(GetConeOutsideVolume) (THIS_ LPLONG plConeOutsideVolume) PURE; - STDMETHOD(GetMaxDistance) (THIS_ D3DVALUE* pflMaxDistance) PURE; - STDMETHOD(GetMinDistance) (THIS_ D3DVALUE* pflMinDistance) PURE; - STDMETHOD(GetMode) (THIS_ LPDWORD pdwMode) PURE; - STDMETHOD(GetPosition) (THIS_ D3DVECTOR* pvPosition) PURE; - STDMETHOD(GetVelocity) (THIS_ D3DVECTOR* pvVelocity) PURE; - STDMETHOD(SetAllParameters) (THIS_ LPCDS3DBUFFER pcDs3dBuffer, DWORD dwApply) PURE; - STDMETHOD(SetConeAngles) (THIS_ DWORD dwInsideConeAngle, DWORD dwOutsideConeAngle, DWORD dwApply) PURE; - STDMETHOD(SetConeOrientation) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; - STDMETHOD(SetConeOutsideVolume) (THIS_ LONG lConeOutsideVolume, DWORD dwApply) PURE; - STDMETHOD(SetMaxDistance) (THIS_ D3DVALUE flMaxDistance, DWORD dwApply) PURE; - STDMETHOD(SetMinDistance) (THIS_ D3DVALUE flMinDistance, DWORD dwApply) PURE; - STDMETHOD(SetMode) (THIS_ DWORD dwMode, DWORD dwApply) PURE; - STDMETHOD(SetPosition) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; - STDMETHOD(SetVelocity) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; -}; - -#define IDirectSound3DBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSound3DBuffer_AddRef(p) IUnknown_AddRef(p) -#define IDirectSound3DBuffer_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->lpVtbl->GetConeAngles(p,a,b) -#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->lpVtbl->GetConeOrientation(p,a) -#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->lpVtbl->GetConeOutsideVolume(p,a) -#define IDirectSound3DBuffer_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a) -#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->lpVtbl->GetMinDistance(p,a) -#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->lpVtbl->GetMaxDistance(p,a) -#define IDirectSound3DBuffer_GetMode(p,a) (p)->lpVtbl->GetMode(p,a) -#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a) -#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b) -#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->lpVtbl->SetConeAngles(p,a,b,c) -#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->lpVtbl->SetConeOrientation(p,a,b,c,d) -#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->lpVtbl->SetConeOutsideVolume(p,a,b) -#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d) -#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->lpVtbl->SetMinDistance(p,a,b) -#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->lpVtbl->SetMaxDistance(p,a,b) -#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->lpVtbl->SetMode(p,a,b) -#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->GetAllParameters(a) -#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->GetConeAngles(a,b) -#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->GetConeOrientation(a) -#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->GetConeOutsideVolume(a) -#define IDirectSound3DBuffer_GetPosition(p,a) (p)->GetPosition(a) -#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->GetMinDistance(a) -#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->GetMaxDistance(a) -#define IDirectSound3DBuffer_GetMode(p,a) (p)->GetMode(a) -#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->GetVelocity(a) -#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b) -#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->SetConeAngles(a,b,c) -#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->SetConeOrientation(a,b,c,d) -#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->SetConeOutsideVolume(a,b) -#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d) -#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->SetMinDistance(a,b) -#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->SetMaxDistance(a,b) -#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->SetMode(a,b) -#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundCapture -// - -DEFINE_GUID(IID_IDirectSoundCapture, 0xb0210781, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); - -#undef INTERFACE -#define INTERFACE IDirectSoundCapture - -DECLARE_INTERFACE_(IDirectSoundCapture, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundCapture methods - STDMETHOD(CreateCaptureBuffer) (THIS_ LPCDSCBUFFERDESC pcDSCBufferDesc, LPDIRECTSOUNDCAPTUREBUFFER *ppDSCBuffer, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(GetCaps) (THIS_ LPDSCCAPS pDSCCaps) PURE; - STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; -}; - -#define IDirectSoundCapture_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundCapture_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundCapture_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->lpVtbl->CreateCaptureBuffer(p,a,b,c) -#define IDirectSoundCapture_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) -#define IDirectSoundCapture_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->CreateCaptureBuffer(a,b,c) -#define IDirectSoundCapture_GetCaps(p,a) (p)->GetCaps(a) -#define IDirectSoundCapture_Initialize(p,a) (p)->Initialize(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundCaptureBuffer -// - -DEFINE_GUID(IID_IDirectSoundCaptureBuffer, 0xb0210782, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); - -#undef INTERFACE -#define INTERFACE IDirectSoundCaptureBuffer - -DECLARE_INTERFACE_(IDirectSoundCaptureBuffer, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundCaptureBuffer methods - STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS pDSCBCaps) PURE; - STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCapturePosition, LPDWORD pdwReadPosition) PURE; - STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; - STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE pDirectSoundCapture, LPCDSCBUFFERDESC pcDSCBufferDesc) PURE; - STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, - LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; - STDMETHOD(Start) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(Stop) (THIS) PURE; - STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; -}; - -#define IDirectSoundCaptureBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundCaptureBuffer_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundCaptureBuffer_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) -#define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b) -#define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c) -#define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a) -#define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g) -#define IDirectSoundCaptureBuffer_Start(p,a) (p)->lpVtbl->Start(p,a) -#define IDirectSoundCaptureBuffer_Stop(p) (p)->lpVtbl->Stop(p) -#define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->GetCaps(a) -#define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b) -#define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c) -#define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->GetStatus(a) -#define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g) -#define IDirectSoundCaptureBuffer_Start(p,a) (p)->Start(a) -#define IDirectSoundCaptureBuffer_Stop(p) (p)->Stop() -#define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - - -#if DIRECTSOUND_VERSION >= 0x0800 - -// -// IDirectSoundCaptureBuffer8 -// - -DEFINE_GUID(IID_IDirectSoundCaptureBuffer8, 0x990df4, 0xdbb, 0x4872, 0x83, 0x3e, 0x6d, 0x30, 0x3e, 0x80, 0xae, 0xb6); - -#undef INTERFACE -#define INTERFACE IDirectSoundCaptureBuffer8 - -DECLARE_INTERFACE_(IDirectSoundCaptureBuffer8, IDirectSoundCaptureBuffer) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundCaptureBuffer methods - STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS pDSCBCaps) PURE; - STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCapturePosition, LPDWORD pdwReadPosition) PURE; - STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; - STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE pDirectSoundCapture, LPCDSCBUFFERDESC pcDSCBufferDesc) PURE; - STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, - LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; - STDMETHOD(Start) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(Stop) (THIS) PURE; - STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; - - // IDirectSoundCaptureBuffer8 methods - STDMETHOD(GetObjectInPath) (THIS_ REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject) PURE; - STDMETHOD(GetFXStatus) (DWORD dwFXCount, LPDWORD pdwFXStatus) PURE; -}; - -#define IDirectSoundCaptureBuffer8_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundCaptureBuffer8_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundCaptureBuffer8_Release(p) IUnknown_Release(p) - -#define IDirectSoundCaptureBuffer8_GetCaps(p,a) IDirectSoundCaptureBuffer_GetCaps(p,a) -#define IDirectSoundCaptureBuffer8_GetCurrentPosition(p,a,b) IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) -#define IDirectSoundCaptureBuffer8_GetFormat(p,a,b,c) IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) -#define IDirectSoundCaptureBuffer8_GetStatus(p,a) IDirectSoundCaptureBuffer_GetStatus(p,a) -#define IDirectSoundCaptureBuffer8_Initialize(p,a,b) IDirectSoundCaptureBuffer_Initialize(p,a,b) -#define IDirectSoundCaptureBuffer8_Lock(p,a,b,c,d,e,f,g) IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) -#define IDirectSoundCaptureBuffer8_Start(p,a) IDirectSoundCaptureBuffer_Start(p,a) -#define IDirectSoundCaptureBuffer8_Stop(p) IDirectSoundCaptureBuffer_Stop(p)) -#define IDirectSoundCaptureBuffer8_Unlock(p,a,b,c,d) IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureBuffer8_GetObjectInPath(p,a,b,c,d) (p)->lpVtbl->GetObjectInPath(p,a,b,c,d) -#define IDirectSoundCaptureBuffer8_GetFXStatus(p,a,b) (p)->lpVtbl->GetFXStatus(p,a,b) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureBuffer8_GetObjectInPath(p,a,b,c,d) (p)->GetObjectInPath(a,b,c,d) -#define IDirectSoundCaptureBuffer8_GetFXStatus(p,a,b) (p)->GetFXStatus(a,b) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -// -// IDirectSoundNotify -// - -DEFINE_GUID(IID_IDirectSoundNotify, 0xb0210783, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); - -#undef INTERFACE -#define INTERFACE IDirectSoundNotify - -DECLARE_INTERFACE_(IDirectSoundNotify, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundNotify methods - STDMETHOD(SetNotificationPositions) (THIS_ DWORD dwPositionNotifies, LPCDSBPOSITIONNOTIFY pcPositionNotifies) PURE; -}; - -#define IDirectSoundNotify_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundNotify_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundNotify_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->lpVtbl->SetNotificationPositions(p,a,b) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->SetNotificationPositions(a,b) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IKsPropertySet -// - -#ifndef _IKsPropertySet_ -#define _IKsPropertySet_ - -#ifdef __cplusplus -// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined -struct IKsPropertySet; -#endif // __cplusplus - -typedef struct IKsPropertySet *LPKSPROPERTYSET; - -#define KSPROPERTY_SUPPORT_GET 0x00000001 -#define KSPROPERTY_SUPPORT_SET 0x00000002 - -DEFINE_GUID(IID_IKsPropertySet, 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93); - -#undef INTERFACE -#define INTERFACE IKsPropertySet - -DECLARE_INTERFACE_(IKsPropertySet, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IKsPropertySet methods - STDMETHOD(Get) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength, - LPVOID pPropertyData, ULONG ulDataLength, PULONG pulBytesReturned) PURE; - STDMETHOD(Set) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength, - LPVOID pPropertyData, ULONG ulDataLength) PURE; - STDMETHOD(QuerySupport) (THIS_ REFGUID rguidPropSet, ULONG ulId, PULONG pulTypeSupport) PURE; -}; - -#define IKsPropertySet_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IKsPropertySet_AddRef(p) IUnknown_AddRef(p) -#define IKsPropertySet_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->lpVtbl->Get(p,a,b,c,d,e,f,g) -#define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->lpVtbl->Set(p,a,b,c,d,e,f) -#define IKsPropertySet_QuerySupport(p,a,b,c) (p)->lpVtbl->QuerySupport(p,a,b,c) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->Get(a,b,c,d,e,f,g) -#define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->Set(a,b,c,d,e,f) -#define IKsPropertySet_QuerySupport(p,a,b,c) (p)->QuerySupport(a,b,c) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#endif // _IKsPropertySet_ - -#if DIRECTSOUND_VERSION >= 0x0800 - -// -// IDirectSoundFXGargle -// - -DEFINE_GUID(IID_IDirectSoundFXGargle, 0xd616f352, 0xd622, 0x11ce, 0xaa, 0xc5, 0x00, 0x20, 0xaf, 0x0b, 0x99, 0xa3); - -typedef struct _DSFXGargle -{ - DWORD dwRateHz; // Rate of modulation in hz - DWORD dwWaveShape; // DSFXGARGLE_WAVE_xxx -} DSFXGargle, *LPDSFXGargle; - -#define DSFXGARGLE_WAVE_TRIANGLE 0 -#define DSFXGARGLE_WAVE_SQUARE 1 - -typedef const DSFXGargle *LPCDSFXGargle; - -#define DSFXGARGLE_RATEHZ_MIN 1 -#define DSFXGARGLE_RATEHZ_MAX 1000 - -#undef INTERFACE -#define INTERFACE IDirectSoundFXGargle - -DECLARE_INTERFACE_(IDirectSoundFXGargle, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXGargle methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXGargle pcDsFxGargle) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXGargle pDsFxGargle) PURE; -}; - -#define IDirectSoundFXGargle_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXGargle_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXGargle_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXGargle_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXGargle_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXGargle_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXGargle_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXChorus -// - -DEFINE_GUID(IID_IDirectSoundFXChorus, 0x880842e3, 0x145f, 0x43e6, 0xa9, 0x34, 0xa7, 0x18, 0x06, 0xe5, 0x05, 0x47); - -typedef struct _DSFXChorus -{ - FLOAT fWetDryMix; - FLOAT fDepth; - FLOAT fFeedback; - FLOAT fFrequency; - LONG lWaveform; // LFO shape; DSFXCHORUS_WAVE_xxx - FLOAT fDelay; - LONG lPhase; -} DSFXChorus, *LPDSFXChorus; - -typedef const DSFXChorus *LPCDSFXChorus; - -#define DSFXCHORUS_WAVE_TRIANGLE 0 -#define DSFXCHORUS_WAVE_SIN 1 - -#define DSFXCHORUS_WETDRYMIX_MIN 0.0f -#define DSFXCHORUS_WETDRYMIX_MAX 100.0f -#define DSFXCHORUS_DEPTH_MIN 0.0f -#define DSFXCHORUS_DEPTH_MAX 100.0f -#define DSFXCHORUS_FEEDBACK_MIN -99.0f -#define DSFXCHORUS_FEEDBACK_MAX 99.0f -#define DSFXCHORUS_FREQUENCY_MIN 0.0f -#define DSFXCHORUS_FREQUENCY_MAX 10.0f -#define DSFXCHORUS_DELAY_MIN 0.0f -#define DSFXCHORUS_DELAY_MAX 20.0f -#define DSFXCHORUS_PHASE_MIN 0 -#define DSFXCHORUS_PHASE_MAX 4 - -#define DSFXCHORUS_PHASE_NEG_180 0 -#define DSFXCHORUS_PHASE_NEG_90 1 -#define DSFXCHORUS_PHASE_ZERO 2 -#define DSFXCHORUS_PHASE_90 3 -#define DSFXCHORUS_PHASE_180 4 - -#undef INTERFACE -#define INTERFACE IDirectSoundFXChorus - -DECLARE_INTERFACE_(IDirectSoundFXChorus, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXChorus methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXChorus pcDsFxChorus) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXChorus pDsFxChorus) PURE; -}; - -#define IDirectSoundFXChorus_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXChorus_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXChorus_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXChorus_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXChorus_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXChorus_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXChorus_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXFlanger -// - -DEFINE_GUID(IID_IDirectSoundFXFlanger, 0x903e9878, 0x2c92, 0x4072, 0x9b, 0x2c, 0xea, 0x68, 0xf5, 0x39, 0x67, 0x83); - -typedef struct _DSFXFlanger -{ - FLOAT fWetDryMix; - FLOAT fDepth; - FLOAT fFeedback; - FLOAT fFrequency; - LONG lWaveform; - FLOAT fDelay; - LONG lPhase; -} DSFXFlanger, *LPDSFXFlanger; - -typedef const DSFXFlanger *LPCDSFXFlanger; - -#define DSFXFLANGER_WAVE_TRIANGLE 0 -#define DSFXFLANGER_WAVE_SIN 1 - -#define DSFXFLANGER_WETDRYMIX_MIN 0.0f -#define DSFXFLANGER_WETDRYMIX_MAX 100.0f -#define DSFXFLANGER_FREQUENCY_MIN 0.0f -#define DSFXFLANGER_FREQUENCY_MAX 10.0f -#define DSFXFLANGER_DEPTH_MIN 0.0f -#define DSFXFLANGER_DEPTH_MAX 100.0f -#define DSFXFLANGER_PHASE_MIN 0 -#define DSFXFLANGER_PHASE_MAX 4 -#define DSFXFLANGER_FEEDBACK_MIN -99.0f -#define DSFXFLANGER_FEEDBACK_MAX 99.0f -#define DSFXFLANGER_DELAY_MIN 0.0f -#define DSFXFLANGER_DELAY_MAX 4.0f - -#define DSFXFLANGER_PHASE_NEG_180 0 -#define DSFXFLANGER_PHASE_NEG_90 1 -#define DSFXFLANGER_PHASE_ZERO 2 -#define DSFXFLANGER_PHASE_90 3 -#define DSFXFLANGER_PHASE_180 4 - -#undef INTERFACE -#define INTERFACE IDirectSoundFXFlanger - -DECLARE_INTERFACE_(IDirectSoundFXFlanger, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXFlanger methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXFlanger pcDsFxFlanger) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXFlanger pDsFxFlanger) PURE; -}; - -#define IDirectSoundFXFlanger_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXFlanger_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXFlanger_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXFlanger_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXFlanger_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXFlanger_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXFlanger_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXEcho -// - -DEFINE_GUID(IID_IDirectSoundFXEcho, 0x8bd28edf, 0x50db, 0x4e92, 0xa2, 0xbd, 0x44, 0x54, 0x88, 0xd1, 0xed, 0x42); - -typedef struct _DSFXEcho -{ - FLOAT fWetDryMix; - FLOAT fFeedback; - FLOAT fLeftDelay; - FLOAT fRightDelay; - LONG lPanDelay; -} DSFXEcho, *LPDSFXEcho; - -typedef const DSFXEcho *LPCDSFXEcho; - -#define DSFXECHO_WETDRYMIX_MIN 0.0f -#define DSFXECHO_WETDRYMIX_MAX 100.0f -#define DSFXECHO_FEEDBACK_MIN 0.0f -#define DSFXECHO_FEEDBACK_MAX 100.0f -#define DSFXECHO_LEFTDELAY_MIN 1.0f -#define DSFXECHO_LEFTDELAY_MAX 2000.0f -#define DSFXECHO_RIGHTDELAY_MIN 1.0f -#define DSFXECHO_RIGHTDELAY_MAX 2000.0f -#define DSFXECHO_PANDELAY_MIN 0 -#define DSFXECHO_PANDELAY_MAX 1 - -#undef INTERFACE -#define INTERFACE IDirectSoundFXEcho - -DECLARE_INTERFACE_(IDirectSoundFXEcho, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXEcho methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXEcho pcDsFxEcho) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXEcho pDsFxEcho) PURE; -}; - -#define IDirectSoundFXEcho_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXEcho_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXEcho_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXEcho_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXEcho_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXEcho_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXEcho_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXDistortion -// - -DEFINE_GUID(IID_IDirectSoundFXDistortion, 0x8ecf4326, 0x455f, 0x4d8b, 0xbd, 0xa9, 0x8d, 0x5d, 0x3e, 0x9e, 0x3e, 0x0b); - -typedef struct _DSFXDistortion -{ - FLOAT fGain; - FLOAT fEdge; - FLOAT fPostEQCenterFrequency; - FLOAT fPostEQBandwidth; - FLOAT fPreLowpassCutoff; -} DSFXDistortion, *LPDSFXDistortion; - -typedef const DSFXDistortion *LPCDSFXDistortion; - -#define DSFXDISTORTION_GAIN_MIN -60.0f -#define DSFXDISTORTION_GAIN_MAX 0.0f -#define DSFXDISTORTION_EDGE_MIN 0.0f -#define DSFXDISTORTION_EDGE_MAX 100.0f -#define DSFXDISTORTION_POSTEQCENTERFREQUENCY_MIN 100.0f -#define DSFXDISTORTION_POSTEQCENTERFREQUENCY_MAX 8000.0f -#define DSFXDISTORTION_POSTEQBANDWIDTH_MIN 100.0f -#define DSFXDISTORTION_POSTEQBANDWIDTH_MAX 8000.0f -#define DSFXDISTORTION_PRELOWPASSCUTOFF_MIN 100.0f -#define DSFXDISTORTION_PRELOWPASSCUTOFF_MAX 8000.0f - -#undef INTERFACE -#define INTERFACE IDirectSoundFXDistortion - -DECLARE_INTERFACE_(IDirectSoundFXDistortion, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXDistortion methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXDistortion pcDsFxDistortion) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXDistortion pDsFxDistortion) PURE; -}; - -#define IDirectSoundFXDistortion_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXDistortion_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXDistortion_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXDistortion_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXDistortion_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXDistortion_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXDistortion_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXCompressor -// - -DEFINE_GUID(IID_IDirectSoundFXCompressor, 0x4bbd1154, 0x62f6, 0x4e2c, 0xa1, 0x5c, 0xd3, 0xb6, 0xc4, 0x17, 0xf7, 0xa0); - -typedef struct _DSFXCompressor -{ - FLOAT fGain; - FLOAT fAttack; - FLOAT fRelease; - FLOAT fThreshold; - FLOAT fRatio; - FLOAT fPredelay; -} DSFXCompressor, *LPDSFXCompressor; - -typedef const DSFXCompressor *LPCDSFXCompressor; - -#define DSFXCOMPRESSOR_GAIN_MIN -60.0f -#define DSFXCOMPRESSOR_GAIN_MAX 60.0f -#define DSFXCOMPRESSOR_ATTACK_MIN 0.01f -#define DSFXCOMPRESSOR_ATTACK_MAX 500.0f -#define DSFXCOMPRESSOR_RELEASE_MIN 50.0f -#define DSFXCOMPRESSOR_RELEASE_MAX 3000.0f -#define DSFXCOMPRESSOR_THRESHOLD_MIN -60.0f -#define DSFXCOMPRESSOR_THRESHOLD_MAX 0.0f -#define DSFXCOMPRESSOR_RATIO_MIN 1.0f -#define DSFXCOMPRESSOR_RATIO_MAX 100.0f -#define DSFXCOMPRESSOR_PREDELAY_MIN 0.0f -#define DSFXCOMPRESSOR_PREDELAY_MAX 4.0f - -#undef INTERFACE -#define INTERFACE IDirectSoundFXCompressor - -DECLARE_INTERFACE_(IDirectSoundFXCompressor, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXCompressor methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXCompressor pcDsFxCompressor) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXCompressor pDsFxCompressor) PURE; -}; - -#define IDirectSoundFXCompressor_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXCompressor_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXCompressor_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXCompressor_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXCompressor_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXCompressor_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXCompressor_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXParamEq -// - -DEFINE_GUID(IID_IDirectSoundFXParamEq, 0xc03ca9fe, 0xfe90, 0x4204, 0x80, 0x78, 0x82, 0x33, 0x4c, 0xd1, 0x77, 0xda); - -typedef struct _DSFXParamEq -{ - FLOAT fCenter; - FLOAT fBandwidth; - FLOAT fGain; -} DSFXParamEq, *LPDSFXParamEq; - -typedef const DSFXParamEq *LPCDSFXParamEq; - -#define DSFXPARAMEQ_CENTER_MIN 80.0f -#define DSFXPARAMEQ_CENTER_MAX 16000.0f -#define DSFXPARAMEQ_BANDWIDTH_MIN 1.0f -#define DSFXPARAMEQ_BANDWIDTH_MAX 36.0f -#define DSFXPARAMEQ_GAIN_MIN -15.0f -#define DSFXPARAMEQ_GAIN_MAX 15.0f - -#undef INTERFACE -#define INTERFACE IDirectSoundFXParamEq - -DECLARE_INTERFACE_(IDirectSoundFXParamEq, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXParamEq methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXParamEq pcDsFxParamEq) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXParamEq pDsFxParamEq) PURE; -}; - -#define IDirectSoundFXParamEq_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXParamEq_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXParamEq_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXParamEq_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXParamEq_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXParamEq_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXParamEq_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXI3DL2Reverb -// - -DEFINE_GUID(IID_IDirectSoundFXI3DL2Reverb, 0x4b166a6a, 0x0d66, 0x43f3, 0x80, 0xe3, 0xee, 0x62, 0x80, 0xde, 0xe1, 0xa4); - -typedef struct _DSFXI3DL2Reverb -{ - LONG lRoom; // [-10000, 0] default: -1000 mB - LONG lRoomHF; // [-10000, 0] default: 0 mB - FLOAT flRoomRolloffFactor; // [0.0, 10.0] default: 0.0 - FLOAT flDecayTime; // [0.1, 20.0] default: 1.49s - FLOAT flDecayHFRatio; // [0.1, 2.0] default: 0.83 - LONG lReflections; // [-10000, 1000] default: -2602 mB - FLOAT flReflectionsDelay; // [0.0, 0.3] default: 0.007 s - LONG lReverb; // [-10000, 2000] default: 200 mB - FLOAT flReverbDelay; // [0.0, 0.1] default: 0.011 s - FLOAT flDiffusion; // [0.0, 100.0] default: 100.0 % - FLOAT flDensity; // [0.0, 100.0] default: 100.0 % - FLOAT flHFReference; // [20.0, 20000.0] default: 5000.0 Hz -} DSFXI3DL2Reverb, *LPDSFXI3DL2Reverb; - -typedef const DSFXI3DL2Reverb *LPCDSFXI3DL2Reverb; - -#define DSFX_I3DL2REVERB_ROOM_MIN (-10000) -#define DSFX_I3DL2REVERB_ROOM_MAX 0 -#define DSFX_I3DL2REVERB_ROOM_DEFAULT (-1000) - -#define DSFX_I3DL2REVERB_ROOMHF_MIN (-10000) -#define DSFX_I3DL2REVERB_ROOMHF_MAX 0 -#define DSFX_I3DL2REVERB_ROOMHF_DEFAULT (-100) - -#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MIN 0.0f -#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MAX 10.0f -#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_DEFAULT 0.0f - -#define DSFX_I3DL2REVERB_DECAYTIME_MIN 0.1f -#define DSFX_I3DL2REVERB_DECAYTIME_MAX 20.0f -#define DSFX_I3DL2REVERB_DECAYTIME_DEFAULT 1.49f - -#define DSFX_I3DL2REVERB_DECAYHFRATIO_MIN 0.1f -#define DSFX_I3DL2REVERB_DECAYHFRATIO_MAX 2.0f -#define DSFX_I3DL2REVERB_DECAYHFRATIO_DEFAULT 0.83f - -#define DSFX_I3DL2REVERB_REFLECTIONS_MIN (-10000) -#define DSFX_I3DL2REVERB_REFLECTIONS_MAX 1000 -#define DSFX_I3DL2REVERB_REFLECTIONS_DEFAULT (-2602) - -#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_MIN 0.0f -#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_MAX 0.3f -#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_DEFAULT 0.007f - -#define DSFX_I3DL2REVERB_REVERB_MIN (-10000) -#define DSFX_I3DL2REVERB_REVERB_MAX 2000 -#define DSFX_I3DL2REVERB_REVERB_DEFAULT (200) - -#define DSFX_I3DL2REVERB_REVERBDELAY_MIN 0.0f -#define DSFX_I3DL2REVERB_REVERBDELAY_MAX 0.1f -#define DSFX_I3DL2REVERB_REVERBDELAY_DEFAULT 0.011f - -#define DSFX_I3DL2REVERB_DIFFUSION_MIN 0.0f -#define DSFX_I3DL2REVERB_DIFFUSION_MAX 100.0f -#define DSFX_I3DL2REVERB_DIFFUSION_DEFAULT 100.0f - -#define DSFX_I3DL2REVERB_DENSITY_MIN 0.0f -#define DSFX_I3DL2REVERB_DENSITY_MAX 100.0f -#define DSFX_I3DL2REVERB_DENSITY_DEFAULT 100.0f - -#define DSFX_I3DL2REVERB_HFREFERENCE_MIN 20.0f -#define DSFX_I3DL2REVERB_HFREFERENCE_MAX 20000.0f -#define DSFX_I3DL2REVERB_HFREFERENCE_DEFAULT 5000.0f - -#define DSFX_I3DL2REVERB_QUALITY_MIN 0 -#define DSFX_I3DL2REVERB_QUALITY_MAX 3 -#define DSFX_I3DL2REVERB_QUALITY_DEFAULT 2 - -#undef INTERFACE -#define INTERFACE IDirectSoundFXI3DL2Reverb - -DECLARE_INTERFACE_(IDirectSoundFXI3DL2Reverb, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXI3DL2Reverb methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXI3DL2Reverb pcDsFxI3DL2Reverb) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXI3DL2Reverb pDsFxI3DL2Reverb) PURE; - STDMETHOD(SetPreset) (THIS_ DWORD dwPreset) PURE; - STDMETHOD(GetPreset) (THIS_ LPDWORD pdwPreset) PURE; - STDMETHOD(SetQuality) (THIS_ LONG lQuality) PURE; - STDMETHOD(GetQuality) (THIS_ LONG *plQuality) PURE; -}; - -#define IDirectSoundFXI3DL2Reverb_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXI3DL2Reverb_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXI3DL2Reverb_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXI3DL2Reverb_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXI3DL2Reverb_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#define IDirectSoundFXI3DL2Reverb_SetPreset(p,a) (p)->lpVtbl->SetPreset(p,a) -#define IDirectSoundFXI3DL2Reverb_GetPreset(p,a) (p)->lpVtbl->GetPreset(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXI3DL2Reverb_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXI3DL2Reverb_GetAllParameters(p,a) (p)->GetAllParameters(a) -#define IDirectSoundFXI3DL2Reverb_SetPreset(p,a) (p)->SetPreset(a) -#define IDirectSoundFXI3DL2Reverb_GetPreset(p,a) (p)->GetPreset(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXWavesReverb -// - -DEFINE_GUID(IID_IDirectSoundFXWavesReverb,0x46858c3a,0x0dc6,0x45e3,0xb7,0x60,0xd4,0xee,0xf1,0x6c,0xb3,0x25); - -typedef struct _DSFXWavesReverb -{ - FLOAT fInGain; // [-96.0,0.0] default: 0.0 dB - FLOAT fReverbMix; // [-96.0,0.0] default: 0.0 db - FLOAT fReverbTime; // [0.001,3000.0] default: 1000.0 ms - FLOAT fHighFreqRTRatio; // [0.001,0.999] default: 0.001 -} DSFXWavesReverb, *LPDSFXWavesReverb; - -typedef const DSFXWavesReverb *LPCDSFXWavesReverb; - -#define DSFX_WAVESREVERB_INGAIN_MIN -96.0f -#define DSFX_WAVESREVERB_INGAIN_MAX 0.0f -#define DSFX_WAVESREVERB_INGAIN_DEFAULT 0.0f -#define DSFX_WAVESREVERB_REVERBMIX_MIN -96.0f -#define DSFX_WAVESREVERB_REVERBMIX_MAX 0.0f -#define DSFX_WAVESREVERB_REVERBMIX_DEFAULT 0.0f -#define DSFX_WAVESREVERB_REVERBTIME_MIN 0.001f -#define DSFX_WAVESREVERB_REVERBTIME_MAX 3000.0f -#define DSFX_WAVESREVERB_REVERBTIME_DEFAULT 1000.0f -#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_MIN 0.001f -#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_MAX 0.999f -#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_DEFAULT 0.001f - -#undef INTERFACE -#define INTERFACE IDirectSoundFXWavesReverb - -DECLARE_INTERFACE_(IDirectSoundFXWavesReverb, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXWavesReverb methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXWavesReverb pcDsFxWavesReverb) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXWavesReverb pDsFxWavesReverb) PURE; -}; - -#define IDirectSoundFXWavesReverb_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXWavesReverb_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXWavesReverb_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXWavesReverb_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXWavesReverb_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXWavesReverb_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXWavesReverb_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundCaptureFXAec -// - -DEFINE_GUID(IID_IDirectSoundCaptureFXAec, 0xad74143d, 0x903d, 0x4ab7, 0x80, 0x66, 0x28, 0xd3, 0x63, 0x03, 0x6d, 0x65); - -typedef struct _DSCFXAec -{ - BOOL fEnable; - BOOL fNoiseFill; - DWORD dwMode; -} DSCFXAec, *LPDSCFXAec; - -typedef const DSCFXAec *LPCDSCFXAec; - -// These match the AEC_MODE_* constants in the DDK's ksmedia.h file -#define DSCFX_AEC_MODE_PASS_THROUGH 0x0 -#define DSCFX_AEC_MODE_HALF_DUPLEX 0x1 -#define DSCFX_AEC_MODE_FULL_DUPLEX 0x2 - -// These match the AEC_STATUS_* constants in ksmedia.h -#define DSCFX_AEC_STATUS_HISTORY_UNINITIALIZED 0x0 -#define DSCFX_AEC_STATUS_HISTORY_CONTINUOUSLY_CONVERGED 0x1 -#define DSCFX_AEC_STATUS_HISTORY_PREVIOUSLY_DIVERGED 0x2 -#define DSCFX_AEC_STATUS_CURRENTLY_CONVERGED 0x8 - -#undef INTERFACE -#define INTERFACE IDirectSoundCaptureFXAec - -DECLARE_INTERFACE_(IDirectSoundCaptureFXAec, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundCaptureFXAec methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSCFXAec pDscFxAec) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSCFXAec pDscFxAec) PURE; - STDMETHOD(GetStatus) (THIS_ PDWORD pdwStatus) PURE; - STDMETHOD(Reset) (THIS) PURE; -}; - -#define IDirectSoundCaptureFXAec_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundCaptureFXAec_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundCaptureFXAec_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureFXAec_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundCaptureFXAec_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureFXAec_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundCaptureFXAec_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - - -// -// IDirectSoundCaptureFXNoiseSuppress -// - -DEFINE_GUID(IID_IDirectSoundCaptureFXNoiseSuppress, 0xed311e41, 0xfbae, 0x4175, 0x96, 0x25, 0xcd, 0x8, 0x54, 0xf6, 0x93, 0xca); - -typedef struct _DSCFXNoiseSuppress -{ - BOOL fEnable; -} DSCFXNoiseSuppress, *LPDSCFXNoiseSuppress; - -typedef const DSCFXNoiseSuppress *LPCDSCFXNoiseSuppress; - -#undef INTERFACE -#define INTERFACE IDirectSoundCaptureFXNoiseSuppress - -DECLARE_INTERFACE_(IDirectSoundCaptureFXNoiseSuppress, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundCaptureFXNoiseSuppress methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSCFXNoiseSuppress pcDscFxNoiseSuppress) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSCFXNoiseSuppress pDscFxNoiseSuppress) PURE; - STDMETHOD(Reset) (THIS) PURE; -}; - -#define IDirectSoundCaptureFXNoiseSuppress_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundCaptureFXNoiseSuppress_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundCaptureFXNoiseSuppress_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureFXNoiseSuppress_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundCaptureFXNoiseSuppress_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureFXNoiseSuppress_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundCaptureFXNoiseSuppress_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - - -// -// IDirectSoundFullDuplex -// - -#ifndef _IDirectSoundFullDuplex_ -#define _IDirectSoundFullDuplex_ - -#ifdef __cplusplus -// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined -struct IDirectSoundFullDuplex; -#endif // __cplusplus - -typedef struct IDirectSoundFullDuplex *LPDIRECTSOUNDFULLDUPLEX; - -DEFINE_GUID(IID_IDirectSoundFullDuplex, 0xedcb4c7a, 0xdaab, 0x4216, 0xa4, 0x2e, 0x6c, 0x50, 0x59, 0x6d, 0xdc, 0x1d); - -#undef INTERFACE -#define INTERFACE IDirectSoundFullDuplex - -DECLARE_INTERFACE_(IDirectSoundFullDuplex, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFullDuplex methods - STDMETHOD(Initialize) (THIS_ LPCGUID pCaptureGuid, LPCGUID pRenderGuid, LPCDSCBUFFERDESC lpDscBufferDesc, LPCDSBUFFERDESC lpDsBufferDesc, HWND hWnd, DWORD dwLevel, LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8, LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8) PURE; -}; - -#define IDirectSoundFullDuplex_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFullDuplex_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFullDuplex_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFullDuplex_Initialize(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->Initialize(p,a,b,c,d,e,f,g,h) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFullDuplex_Initialize(p,a,b,c,d,e,f,g,h) (p)->Initialize(a,b,c,d,e,f,g,h) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#endif // _IDirectSoundFullDuplex_ - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -// -// Return Codes -// - -// The function completed successfully -#define DS_OK S_OK - -// The call succeeded, but we had to substitute the 3D algorithm -#define DS_NO_VIRTUALIZATION MAKE_HRESULT(0, _FACDS, 10) - -// The call failed because resources (such as a priority level) -// were already being used by another caller -#define DSERR_ALLOCATED MAKE_DSHRESULT(10) - -// The control (vol, pan, etc.) requested by the caller is not available -#define DSERR_CONTROLUNAVAIL MAKE_DSHRESULT(30) - -// An invalid parameter was passed to the returning function -#define DSERR_INVALIDPARAM E_INVALIDARG - -// This call is not valid for the current state of this object -#define DSERR_INVALIDCALL MAKE_DSHRESULT(50) - -// An undetermined error occurred inside the DirectSound subsystem -#define DSERR_GENERIC E_FAIL - -// The caller does not have the priority level required for the function to -// succeed -#define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT(70) - -// Not enough free memory is available to complete the operation -#define DSERR_OUTOFMEMORY E_OUTOFMEMORY - -// The specified WAVE format is not supported -#define DSERR_BADFORMAT MAKE_DSHRESULT(100) - -// The function called is not supported at this time -#define DSERR_UNSUPPORTED E_NOTIMPL - -// No sound driver is available for use -#define DSERR_NODRIVER MAKE_DSHRESULT(120) - -// This object is already initialized -#define DSERR_ALREADYINITIALIZED MAKE_DSHRESULT(130) - -// This object does not support aggregation -#define DSERR_NOAGGREGATION CLASS_E_NOAGGREGATION - -// The buffer memory has been lost, and must be restored -#define DSERR_BUFFERLOST MAKE_DSHRESULT(150) - -// Another app has a higher priority level, preventing this call from -// succeeding -#define DSERR_OTHERAPPHASPRIO MAKE_DSHRESULT(160) - -// This object has not been initialized -#define DSERR_UNINITIALIZED MAKE_DSHRESULT(170) - -// The requested COM interface is not available -#define DSERR_NOINTERFACE E_NOINTERFACE - -// Access is denied -#define DSERR_ACCESSDENIED E_ACCESSDENIED - -// Tried to create a DSBCAPS_CTRLFX buffer shorter than DSBSIZE_FX_MIN milliseconds -#define DSERR_BUFFERTOOSMALL MAKE_DSHRESULT(180) - -// Attempt to use DirectSound 8 functionality on an older DirectSound object -#define DSERR_DS8_REQUIRED MAKE_DSHRESULT(190) - -// A circular loop of send effects was detected -#define DSERR_SENDLOOP MAKE_DSHRESULT(200) - -// The GUID specified in an audiopath file does not match a valid MIXIN buffer -#define DSERR_BADSENDBUFFERGUID MAKE_DSHRESULT(210) - -// The object requested was not found (numerically equal to DMUS_E_NOT_FOUND) -#define DSERR_OBJECTNOTFOUND MAKE_DSHRESULT(4449) - -// The effects requested could not be found on the system, or they were found -// but in the wrong order, or in the wrong hardware/software locations. -#define DSERR_FXUNAVAILABLE MAKE_DSHRESULT(220) - -// -// Flags -// - -#define DSCAPS_PRIMARYMONO 0x00000001 -#define DSCAPS_PRIMARYSTEREO 0x00000002 -#define DSCAPS_PRIMARY8BIT 0x00000004 -#define DSCAPS_PRIMARY16BIT 0x00000008 -#define DSCAPS_CONTINUOUSRATE 0x00000010 -#define DSCAPS_EMULDRIVER 0x00000020 -#define DSCAPS_CERTIFIED 0x00000040 -#define DSCAPS_SECONDARYMONO 0x00000100 -#define DSCAPS_SECONDARYSTEREO 0x00000200 -#define DSCAPS_SECONDARY8BIT 0x00000400 -#define DSCAPS_SECONDARY16BIT 0x00000800 - -#define DSSCL_NORMAL 0x00000001 -#define DSSCL_PRIORITY 0x00000002 -#define DSSCL_EXCLUSIVE 0x00000003 -#define DSSCL_WRITEPRIMARY 0x00000004 - -#define DSSPEAKER_DIRECTOUT 0x00000000 -#define DSSPEAKER_HEADPHONE 0x00000001 -#define DSSPEAKER_MONO 0x00000002 -#define DSSPEAKER_QUAD 0x00000003 -#define DSSPEAKER_STEREO 0x00000004 -#define DSSPEAKER_SURROUND 0x00000005 -#define DSSPEAKER_5POINT1 0x00000006 -#define DSSPEAKER_7POINT1 0x00000007 - -#define DSSPEAKER_GEOMETRY_MIN 0x00000005 // 5 degrees -#define DSSPEAKER_GEOMETRY_NARROW 0x0000000A // 10 degrees -#define DSSPEAKER_GEOMETRY_WIDE 0x00000014 // 20 degrees -#define DSSPEAKER_GEOMETRY_MAX 0x000000B4 // 180 degrees - -#define DSSPEAKER_COMBINED(c, g) ((DWORD)(((BYTE)(c)) | ((DWORD)((BYTE)(g))) << 16)) -#define DSSPEAKER_CONFIG(a) ((BYTE)(a)) -#define DSSPEAKER_GEOMETRY(a) ((BYTE)(((DWORD)(a) >> 16) & 0x00FF)) - -#define DSBCAPS_PRIMARYBUFFER 0x00000001 -#define DSBCAPS_STATIC 0x00000002 -#define DSBCAPS_LOCHARDWARE 0x00000004 -#define DSBCAPS_LOCSOFTWARE 0x00000008 -#define DSBCAPS_CTRL3D 0x00000010 -#define DSBCAPS_CTRLFREQUENCY 0x00000020 -#define DSBCAPS_CTRLPAN 0x00000040 -#define DSBCAPS_CTRLVOLUME 0x00000080 -#define DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100 -#define DSBCAPS_CTRLFX 0x00000200 -#define DSBCAPS_STICKYFOCUS 0x00004000 -#define DSBCAPS_GLOBALFOCUS 0x00008000 -#define DSBCAPS_GETCURRENTPOSITION2 0x00010000 -#define DSBCAPS_MUTE3DATMAXDISTANCE 0x00020000 -#define DSBCAPS_LOCDEFER 0x00040000 - -#define DSBPLAY_LOOPING 0x00000001 -#define DSBPLAY_LOCHARDWARE 0x00000002 -#define DSBPLAY_LOCSOFTWARE 0x00000004 -#define DSBPLAY_TERMINATEBY_TIME 0x00000008 -#define DSBPLAY_TERMINATEBY_DISTANCE 0x000000010 -#define DSBPLAY_TERMINATEBY_PRIORITY 0x000000020 - -#define DSBSTATUS_PLAYING 0x00000001 -#define DSBSTATUS_BUFFERLOST 0x00000002 -#define DSBSTATUS_LOOPING 0x00000004 -#define DSBSTATUS_LOCHARDWARE 0x00000008 -#define DSBSTATUS_LOCSOFTWARE 0x00000010 -#define DSBSTATUS_TERMINATED 0x00000020 - -#define DSBLOCK_FROMWRITECURSOR 0x00000001 -#define DSBLOCK_ENTIREBUFFER 0x00000002 - -#define DSBFREQUENCY_ORIGINAL 0 -#define DSBFREQUENCY_MIN 100 -#if DIRECTSOUND_VERSION >= 0x0900 -#define DSBFREQUENCY_MAX 200000 -#else -#define DSBFREQUENCY_MAX 100000 -#endif - -#define DSBPAN_LEFT -10000 -#define DSBPAN_CENTER 0 -#define DSBPAN_RIGHT 10000 - -#define DSBVOLUME_MIN -10000 -#define DSBVOLUME_MAX 0 - -#define DSBSIZE_MIN 4 -#define DSBSIZE_MAX 0x0FFFFFFF -#define DSBSIZE_FX_MIN 150 // NOTE: Milliseconds, not bytes - -#define DS3DMODE_NORMAL 0x00000000 -#define DS3DMODE_HEADRELATIVE 0x00000001 -#define DS3DMODE_DISABLE 0x00000002 - -#define DS3D_IMMEDIATE 0x00000000 -#define DS3D_DEFERRED 0x00000001 - -#define DS3D_MINDISTANCEFACTOR FLT_MIN -#define DS3D_MAXDISTANCEFACTOR FLT_MAX -#define DS3D_DEFAULTDISTANCEFACTOR 1.0f - -#define DS3D_MINROLLOFFFACTOR 0.0f -#define DS3D_MAXROLLOFFFACTOR 10.0f -#define DS3D_DEFAULTROLLOFFFACTOR 1.0f - -#define DS3D_MINDOPPLERFACTOR 0.0f -#define DS3D_MAXDOPPLERFACTOR 10.0f -#define DS3D_DEFAULTDOPPLERFACTOR 1.0f - -#define DS3D_DEFAULTMINDISTANCE 1.0f -#define DS3D_DEFAULTMAXDISTANCE 1000000000.0f - -#define DS3D_MINCONEANGLE 0 -#define DS3D_MAXCONEANGLE 360 -#define DS3D_DEFAULTCONEANGLE 360 - -#define DS3D_DEFAULTCONEOUTSIDEVOLUME DSBVOLUME_MAX - -// IDirectSoundCapture attributes - -#define DSCCAPS_EMULDRIVER DSCAPS_EMULDRIVER -#define DSCCAPS_CERTIFIED DSCAPS_CERTIFIED -#define DSCCAPS_MULTIPLECAPTURE 0x00000001 - -// IDirectSoundCaptureBuffer attributes - -#define DSCBCAPS_WAVEMAPPED 0x80000000 - -#if DIRECTSOUND_VERSION >= 0x0800 -#define DSCBCAPS_CTRLFX 0x00000200 -#endif - - -#define DSCBLOCK_ENTIREBUFFER 0x00000001 - -#define DSCBSTATUS_CAPTURING 0x00000001 -#define DSCBSTATUS_LOOPING 0x00000002 - -#define DSCBSTART_LOOPING 0x00000001 - -#define DSBPN_OFFSETSTOP 0xFFFFFFFF - -#define DS_CERTIFIED 0x00000000 -#define DS_UNCERTIFIED 0x00000001 - - -// -// Flags for the I3DL2 effects -// - -// -// I3DL2 Material Presets -// - -enum -{ - DSFX_I3DL2_MATERIAL_PRESET_SINGLEWINDOW, - DSFX_I3DL2_MATERIAL_PRESET_DOUBLEWINDOW, - DSFX_I3DL2_MATERIAL_PRESET_THINDOOR, - DSFX_I3DL2_MATERIAL_PRESET_THICKDOOR, - DSFX_I3DL2_MATERIAL_PRESET_WOODWALL, - DSFX_I3DL2_MATERIAL_PRESET_BRICKWALL, - DSFX_I3DL2_MATERIAL_PRESET_STONEWALL, - DSFX_I3DL2_MATERIAL_PRESET_CURTAIN -}; - -#define I3DL2_MATERIAL_PRESET_SINGLEWINDOW -2800,0.71f -#define I3DL2_MATERIAL_PRESET_DOUBLEWINDOW -5000,0.40f -#define I3DL2_MATERIAL_PRESET_THINDOOR -1800,0.66f -#define I3DL2_MATERIAL_PRESET_THICKDOOR -4400,0.64f -#define I3DL2_MATERIAL_PRESET_WOODWALL -4000,0.50f -#define I3DL2_MATERIAL_PRESET_BRICKWALL -5000,0.60f -#define I3DL2_MATERIAL_PRESET_STONEWALL -6000,0.68f -#define I3DL2_MATERIAL_PRESET_CURTAIN -1200,0.15f - -enum -{ - DSFX_I3DL2_ENVIRONMENT_PRESET_DEFAULT, - DSFX_I3DL2_ENVIRONMENT_PRESET_GENERIC, - DSFX_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL, - DSFX_I3DL2_ENVIRONMENT_PRESET_ROOM, - DSFX_I3DL2_ENVIRONMENT_PRESET_BATHROOM, - DSFX_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM, - DSFX_I3DL2_ENVIRONMENT_PRESET_STONEROOM, - DSFX_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM, - DSFX_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL, - DSFX_I3DL2_ENVIRONMENT_PRESET_CAVE, - DSFX_I3DL2_ENVIRONMENT_PRESET_ARENA, - DSFX_I3DL2_ENVIRONMENT_PRESET_HANGAR, - DSFX_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY, - DSFX_I3DL2_ENVIRONMENT_PRESET_HALLWAY, - DSFX_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR, - DSFX_I3DL2_ENVIRONMENT_PRESET_ALLEY, - DSFX_I3DL2_ENVIRONMENT_PRESET_FOREST, - DSFX_I3DL2_ENVIRONMENT_PRESET_CITY, - DSFX_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS, - DSFX_I3DL2_ENVIRONMENT_PRESET_QUARRY, - DSFX_I3DL2_ENVIRONMENT_PRESET_PLAIN, - DSFX_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT, - DSFX_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE, - DSFX_I3DL2_ENVIRONMENT_PRESET_UNDERWATER, - DSFX_I3DL2_ENVIRONMENT_PRESET_SMALLROOM, - DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM, - DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEROOM, - DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL, - DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEHALL, - DSFX_I3DL2_ENVIRONMENT_PRESET_PLATE -}; - -// -// I3DL2 Reverberation Presets Values -// - -#define I3DL2_ENVIRONMENT_PRESET_DEFAULT -1000, -100, 0.0f, 1.49f, 0.83f, -2602, 0.007f, 200, 0.011f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_GENERIC -1000, -100, 0.0f, 1.49f, 0.83f, -2602, 0.007f, 200, 0.011f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_PADDEDCELL -1000,-6000, 0.0f, 0.17f, 0.10f, -1204, 0.001f, 207, 0.002f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_ROOM -1000, -454, 0.0f, 0.40f, 0.83f, -1646, 0.002f, 53, 0.003f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_BATHROOM -1000,-1200, 0.0f, 1.49f, 0.54f, -370, 0.007f, 1030, 0.011f, 100.0f, 60.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_LIVINGROOM -1000,-6000, 0.0f, 0.50f, 0.10f, -1376, 0.003f, -1104, 0.004f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_STONEROOM -1000, -300, 0.0f, 2.31f, 0.64f, -711, 0.012f, 83, 0.017f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_AUDITORIUM -1000, -476, 0.0f, 4.32f, 0.59f, -789, 0.020f, -289, 0.030f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_CONCERTHALL -1000, -500, 0.0f, 3.92f, 0.70f, -1230, 0.020f, -2, 0.029f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_CAVE -1000, 0, 0.0f, 2.91f, 1.30f, -602, 0.015f, -302, 0.022f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_ARENA -1000, -698, 0.0f, 7.24f, 0.33f, -1166, 0.020f, 16, 0.030f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_HANGAR -1000,-1000, 0.0f,10.05f, 0.23f, -602, 0.020f, 198, 0.030f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY -1000,-4000, 0.0f, 0.30f, 0.10f, -1831, 0.002f, -1630, 0.030f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_HALLWAY -1000, -300, 0.0f, 1.49f, 0.59f, -1219, 0.007f, 441, 0.011f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR -1000, -237, 0.0f, 2.70f, 0.79f, -1214, 0.013f, 395, 0.020f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_ALLEY -1000, -270, 0.0f, 1.49f, 0.86f, -1204, 0.007f, -4, 0.011f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_FOREST -1000,-3300, 0.0f, 1.49f, 0.54f, -2560, 0.162f, -613, 0.088f, 79.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_CITY -1000, -800, 0.0f, 1.49f, 0.67f, -2273, 0.007f, -2217, 0.011f, 50.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_MOUNTAINS -1000,-2500, 0.0f, 1.49f, 0.21f, -2780, 0.300f, -2014, 0.100f, 27.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_QUARRY -1000,-1000, 0.0f, 1.49f, 0.83f,-10000, 0.061f, 500, 0.025f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_PLAIN -1000,-2000, 0.0f, 1.49f, 0.50f, -2466, 0.179f, -2514, 0.100f, 21.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_PARKINGLOT -1000, 0, 0.0f, 1.65f, 1.50f, -1363, 0.008f, -1153, 0.012f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_SEWERPIPE -1000,-1000, 0.0f, 2.81f, 0.14f, 429, 0.014f, 648, 0.021f, 80.0f, 60.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_UNDERWATER -1000,-4000, 0.0f, 1.49f, 0.10f, -449, 0.007f, 1700, 0.011f, 100.0f, 100.0f, 5000.0f - -// -// Examples simulating 'musical' reverb presets -// -// Name Decay time Description -// Small Room 1.1s A small size room with a length of 5m or so. -// Medium Room 1.3s A medium size room with a length of 10m or so. -// Large Room 1.5s A large size room suitable for live performances. -// Medium Hall 1.8s A medium size concert hall. -// Large Hall 1.8s A large size concert hall suitable for a full orchestra. -// Plate 1.3s A plate reverb simulation. -// - -#define I3DL2_ENVIRONMENT_PRESET_SMALLROOM -1000, -600, 0.0f, 1.10f, 0.83f, -400, 0.005f, 500, 0.010f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM -1000, -600, 0.0f, 1.30f, 0.83f, -1000, 0.010f, -200, 0.020f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_LARGEROOM -1000, -600, 0.0f, 1.50f, 0.83f, -1600, 0.020f, -1000, 0.040f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL -1000, -600, 0.0f, 1.80f, 0.70f, -1300, 0.015f, -800, 0.030f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_LARGEHALL -1000, -600, 0.0f, 1.80f, 0.70f, -2000, 0.030f, -1400, 0.060f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_PLATE -1000, -200, 0.0f, 1.30f, 0.90f, 0, 0.002f, 0, 0.010f, 100.0f, 75.0f, 5000.0f - -// -// DirectSound3D Algorithms -// - -// Default DirectSound3D algorithm {00000000-0000-0000-0000-000000000000} -#define DS3DALG_DEFAULT GUID_NULL - -// No virtualization (Pan3D) {C241333F-1C1B-11d2-94F5-00C04FC28ACA} -DEFINE_GUID(DS3DALG_NO_VIRTUALIZATION, 0xc241333f, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); - -// High-quality HRTF algorithm {C2413340-1C1B-11d2-94F5-00C04FC28ACA} -DEFINE_GUID(DS3DALG_HRTF_FULL, 0xc2413340, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); - -// Lower-quality HRTF algorithm {C2413342-1C1B-11d2-94F5-00C04FC28ACA} -DEFINE_GUID(DS3DALG_HRTF_LIGHT, 0xc2413342, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); - - -#if DIRECTSOUND_VERSION >= 0x0800 - -// -// DirectSound Internal Effect Algorithms -// - - -// Gargle {DAFD8210-5711-4B91-9FE3-F75B7AE279BF} -DEFINE_GUID(GUID_DSFX_STANDARD_GARGLE, 0xdafd8210, 0x5711, 0x4b91, 0x9f, 0xe3, 0xf7, 0x5b, 0x7a, 0xe2, 0x79, 0xbf); - -// Chorus {EFE6629C-81F7-4281-BD91-C9D604A95AF6} -DEFINE_GUID(GUID_DSFX_STANDARD_CHORUS, 0xefe6629c, 0x81f7, 0x4281, 0xbd, 0x91, 0xc9, 0xd6, 0x04, 0xa9, 0x5a, 0xf6); - -// Flanger {EFCA3D92-DFD8-4672-A603-7420894BAD98} -DEFINE_GUID(GUID_DSFX_STANDARD_FLANGER, 0xefca3d92, 0xdfd8, 0x4672, 0xa6, 0x03, 0x74, 0x20, 0x89, 0x4b, 0xad, 0x98); - -// Echo/Delay {EF3E932C-D40B-4F51-8CCF-3F98F1B29D5D} -DEFINE_GUID(GUID_DSFX_STANDARD_ECHO, 0xef3e932c, 0xd40b, 0x4f51, 0x8c, 0xcf, 0x3f, 0x98, 0xf1, 0xb2, 0x9d, 0x5d); - -// Distortion {EF114C90-CD1D-484E-96E5-09CFAF912A21} -DEFINE_GUID(GUID_DSFX_STANDARD_DISTORTION, 0xef114c90, 0xcd1d, 0x484e, 0x96, 0xe5, 0x09, 0xcf, 0xaf, 0x91, 0x2a, 0x21); - -// Compressor/Limiter {EF011F79-4000-406D-87AF-BFFB3FC39D57} -DEFINE_GUID(GUID_DSFX_STANDARD_COMPRESSOR, 0xef011f79, 0x4000, 0x406d, 0x87, 0xaf, 0xbf, 0xfb, 0x3f, 0xc3, 0x9d, 0x57); - -// Parametric Equalization {120CED89-3BF4-4173-A132-3CB406CF3231} -DEFINE_GUID(GUID_DSFX_STANDARD_PARAMEQ, 0x120ced89, 0x3bf4, 0x4173, 0xa1, 0x32, 0x3c, 0xb4, 0x06, 0xcf, 0x32, 0x31); - -// I3DL2 Environmental Reverberation: Reverb (Listener) Effect {EF985E71-D5C7-42D4-BA4D-2D073E2E96F4} -DEFINE_GUID(GUID_DSFX_STANDARD_I3DL2REVERB, 0xef985e71, 0xd5c7, 0x42d4, 0xba, 0x4d, 0x2d, 0x07, 0x3e, 0x2e, 0x96, 0xf4); - -// Waves Reverberation {87FC0268-9A55-4360-95AA-004A1D9DE26C} -DEFINE_GUID(GUID_DSFX_WAVES_REVERB, 0x87fc0268, 0x9a55, 0x4360, 0x95, 0xaa, 0x00, 0x4a, 0x1d, 0x9d, 0xe2, 0x6c); - -// -// DirectSound Capture Effect Algorithms -// - - -// Acoustic Echo Canceller {BF963D80-C559-11D0-8A2B-00A0C9255AC1} -// Matches KSNODETYPE_ACOUSTIC_ECHO_CANCEL in ksmedia.h -DEFINE_GUID(GUID_DSCFX_CLASS_AEC, 0xBF963D80L, 0xC559, 0x11D0, 0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1); - -// Microsoft AEC {CDEBB919-379A-488a-8765-F53CFD36DE40} -DEFINE_GUID(GUID_DSCFX_MS_AEC, 0xcdebb919, 0x379a, 0x488a, 0x87, 0x65, 0xf5, 0x3c, 0xfd, 0x36, 0xde, 0x40); - -// System AEC {1C22C56D-9879-4f5b-A389-27996DDC2810} -DEFINE_GUID(GUID_DSCFX_SYSTEM_AEC, 0x1c22c56d, 0x9879, 0x4f5b, 0xa3, 0x89, 0x27, 0x99, 0x6d, 0xdc, 0x28, 0x10); - -// Noise Supression {E07F903F-62FD-4e60-8CDD-DEA7236665B5} -// Matches KSNODETYPE_NOISE_SUPPRESS in post Windows ME DDK's ksmedia.h -DEFINE_GUID(GUID_DSCFX_CLASS_NS, 0xe07f903f, 0x62fd, 0x4e60, 0x8c, 0xdd, 0xde, 0xa7, 0x23, 0x66, 0x65, 0xb5); - -// Microsoft Noise Suppresion {11C5C73B-66E9-4ba1-A0BA-E814C6EED92D} -DEFINE_GUID(GUID_DSCFX_MS_NS, 0x11c5c73b, 0x66e9, 0x4ba1, 0xa0, 0xba, 0xe8, 0x14, 0xc6, 0xee, 0xd9, 0x2d); - -// System Noise Suppresion {5AB0882E-7274-4516-877D-4EEE99BA4FD0} -DEFINE_GUID(GUID_DSCFX_SYSTEM_NS, 0x5ab0882e, 0x7274, 0x4516, 0x87, 0x7d, 0x4e, 0xee, 0x99, 0xba, 0x4f, 0xd0); - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -#endif // __DSOUND_INCLUDED__ - - - -#ifdef __cplusplus -}; -#endif // __cplusplus - - +/*==========================================================================; + * + * Copyright (c) Microsoft Corporation. All rights reserved. + * + * File: dsound.h + * Content: DirectSound include file + * + **************************************************************************/ + +#define COM_NO_WINDOWS_H +#include +#include + +#ifndef DIRECTSOUND_VERSION +#define DIRECTSOUND_VERSION 0x0900 /* Version 9.0 */ +#endif + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +#ifndef __DSOUND_INCLUDED__ +#define __DSOUND_INCLUDED__ + +/* Type definitions shared with Direct3D */ + +#ifndef DX_SHARED_DEFINES + +typedef float D3DVALUE, *LPD3DVALUE; + +#ifndef D3DCOLOR_DEFINED +typedef DWORD D3DCOLOR; +#define D3DCOLOR_DEFINED +#endif + +#ifndef LPD3DCOLOR_DEFINED +typedef DWORD *LPD3DCOLOR; +#define LPD3DCOLOR_DEFINED +#endif + +#ifndef D3DVECTOR_DEFINED +typedef struct _D3DVECTOR { + float x; + float y; + float z; +} D3DVECTOR; +#define D3DVECTOR_DEFINED +#endif + +#ifndef LPD3DVECTOR_DEFINED +typedef D3DVECTOR *LPD3DVECTOR; +#define LPD3DVECTOR_DEFINED +#endif + +#define DX_SHARED_DEFINES +#endif // DX_SHARED_DEFINES + +#define _FACDS 0x878 /* DirectSound's facility code */ +#define MAKE_DSHRESULT(code) MAKE_HRESULT(1, _FACDS, code) + +// DirectSound Component GUID {47D4D946-62E8-11CF-93BC-444553540000} +DEFINE_GUID(CLSID_DirectSound, 0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0); + +// DirectSound 8.0 Component GUID {3901CC3F-84B5-4FA4-BA35-AA8172B8A09B} +DEFINE_GUID(CLSID_DirectSound8, 0x3901cc3f, 0x84b5, 0x4fa4, 0xba, 0x35, 0xaa, 0x81, 0x72, 0xb8, 0xa0, 0x9b); + +// DirectSound Capture Component GUID {B0210780-89CD-11D0-AF08-00A0C925CD16} +DEFINE_GUID(CLSID_DirectSoundCapture, 0xb0210780, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); + +// DirectSound 8.0 Capture Component GUID {E4BCAC13-7F99-4908-9A8E-74E3BF24B6E1} +DEFINE_GUID(CLSID_DirectSoundCapture8, 0xe4bcac13, 0x7f99, 0x4908, 0x9a, 0x8e, 0x74, 0xe3, 0xbf, 0x24, 0xb6, 0xe1); + +// DirectSound Full Duplex Component GUID {FEA4300C-7959-4147-B26A-2377B9E7A91D} +DEFINE_GUID(CLSID_DirectSoundFullDuplex, 0xfea4300c, 0x7959, 0x4147, 0xb2, 0x6a, 0x23, 0x77, 0xb9, 0xe7, 0xa9, 0x1d); + + +// DirectSound default playback device GUID {DEF00000-9C6D-47ED-AAF1-4DDA8F2B5C03} +DEFINE_GUID(DSDEVID_DefaultPlayback, 0xdef00000, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); + +// DirectSound default capture device GUID {DEF00001-9C6D-47ED-AAF1-4DDA8F2B5C03} +DEFINE_GUID(DSDEVID_DefaultCapture, 0xdef00001, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); + +// DirectSound default device for voice playback {DEF00002-9C6D-47ED-AAF1-4DDA8F2B5C03} +DEFINE_GUID(DSDEVID_DefaultVoicePlayback, 0xdef00002, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); + +// DirectSound default device for voice capture {DEF00003-9C6D-47ED-AAF1-4DDA8F2B5C03} +DEFINE_GUID(DSDEVID_DefaultVoiceCapture, 0xdef00003, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); + + +// +// Forward declarations for interfaces. +// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined +// + +#ifdef __cplusplus +struct IDirectSound; +struct IDirectSoundBuffer; +struct IDirectSound3DListener; +struct IDirectSound3DBuffer; +struct IDirectSoundCapture; +struct IDirectSoundCaptureBuffer; +struct IDirectSoundNotify; +#endif // __cplusplus + + +// +// DirectSound 8.0 interfaces. +// + +#if DIRECTSOUND_VERSION >= 0x0800 + +#ifdef __cplusplus +struct IDirectSound8; +struct IDirectSoundBuffer8; +struct IDirectSoundCaptureBuffer8; +struct IDirectSoundFXGargle; +struct IDirectSoundFXChorus; +struct IDirectSoundFXFlanger; +struct IDirectSoundFXEcho; +struct IDirectSoundFXDistortion; +struct IDirectSoundFXCompressor; +struct IDirectSoundFXParamEq; +struct IDirectSoundFXWavesReverb; +struct IDirectSoundFXI3DL2Reverb; +struct IDirectSoundCaptureFXAec; +struct IDirectSoundCaptureFXNoiseSuppress; +struct IDirectSoundFullDuplex; +#endif // __cplusplus + +// IDirectSound8, IDirectSoundBuffer8 and IDirectSoundCaptureBuffer8 are the +// only DirectSound 7.0 interfaces with changed functionality in version 8.0. +// The other level 8 interfaces as equivalent to their level 7 counterparts: + +#define IDirectSoundCapture8 IDirectSoundCapture +#define IDirectSound3DListener8 IDirectSound3DListener +#define IDirectSound3DBuffer8 IDirectSound3DBuffer +#define IDirectSoundNotify8 IDirectSoundNotify +#define IDirectSoundFXGargle8 IDirectSoundFXGargle +#define IDirectSoundFXChorus8 IDirectSoundFXChorus +#define IDirectSoundFXFlanger8 IDirectSoundFXFlanger +#define IDirectSoundFXEcho8 IDirectSoundFXEcho +#define IDirectSoundFXDistortion8 IDirectSoundFXDistortion +#define IDirectSoundFXCompressor8 IDirectSoundFXCompressor +#define IDirectSoundFXParamEq8 IDirectSoundFXParamEq +#define IDirectSoundFXWavesReverb8 IDirectSoundFXWavesReverb +#define IDirectSoundFXI3DL2Reverb8 IDirectSoundFXI3DL2Reverb +#define IDirectSoundCaptureFXAec8 IDirectSoundCaptureFXAec +#define IDirectSoundCaptureFXNoiseSuppress8 IDirectSoundCaptureFXNoiseSuppress +#define IDirectSoundFullDuplex8 IDirectSoundFullDuplex + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +typedef struct IDirectSound *LPDIRECTSOUND; +typedef struct IDirectSoundBuffer *LPDIRECTSOUNDBUFFER; +typedef struct IDirectSound3DListener *LPDIRECTSOUND3DLISTENER; +typedef struct IDirectSound3DBuffer *LPDIRECTSOUND3DBUFFER; +typedef struct IDirectSoundCapture *LPDIRECTSOUNDCAPTURE; +typedef struct IDirectSoundCaptureBuffer *LPDIRECTSOUNDCAPTUREBUFFER; +typedef struct IDirectSoundNotify *LPDIRECTSOUNDNOTIFY; + + +#if DIRECTSOUND_VERSION >= 0x0800 + +typedef struct IDirectSoundFXGargle *LPDIRECTSOUNDFXGARGLE; +typedef struct IDirectSoundFXChorus *LPDIRECTSOUNDFXCHORUS; +typedef struct IDirectSoundFXFlanger *LPDIRECTSOUNDFXFLANGER; +typedef struct IDirectSoundFXEcho *LPDIRECTSOUNDFXECHO; +typedef struct IDirectSoundFXDistortion *LPDIRECTSOUNDFXDISTORTION; +typedef struct IDirectSoundFXCompressor *LPDIRECTSOUNDFXCOMPRESSOR; +typedef struct IDirectSoundFXParamEq *LPDIRECTSOUNDFXPARAMEQ; +typedef struct IDirectSoundFXWavesReverb *LPDIRECTSOUNDFXWAVESREVERB; +typedef struct IDirectSoundFXI3DL2Reverb *LPDIRECTSOUNDFXI3DL2REVERB; +typedef struct IDirectSoundCaptureFXAec *LPDIRECTSOUNDCAPTUREFXAEC; +typedef struct IDirectSoundCaptureFXNoiseSuppress *LPDIRECTSOUNDCAPTUREFXNOISESUPPRESS; +typedef struct IDirectSoundFullDuplex *LPDIRECTSOUNDFULLDUPLEX; + +typedef struct IDirectSound8 *LPDIRECTSOUND8; +typedef struct IDirectSoundBuffer8 *LPDIRECTSOUNDBUFFER8; +typedef struct IDirectSound3DListener8 *LPDIRECTSOUND3DLISTENER8; +typedef struct IDirectSound3DBuffer8 *LPDIRECTSOUND3DBUFFER8; +typedef struct IDirectSoundCapture8 *LPDIRECTSOUNDCAPTURE8; +typedef struct IDirectSoundCaptureBuffer8 *LPDIRECTSOUNDCAPTUREBUFFER8; +typedef struct IDirectSoundNotify8 *LPDIRECTSOUNDNOTIFY8; +typedef struct IDirectSoundFXGargle8 *LPDIRECTSOUNDFXGARGLE8; +typedef struct IDirectSoundFXChorus8 *LPDIRECTSOUNDFXCHORUS8; +typedef struct IDirectSoundFXFlanger8 *LPDIRECTSOUNDFXFLANGER8; +typedef struct IDirectSoundFXEcho8 *LPDIRECTSOUNDFXECHO8; +typedef struct IDirectSoundFXDistortion8 *LPDIRECTSOUNDFXDISTORTION8; +typedef struct IDirectSoundFXCompressor8 *LPDIRECTSOUNDFXCOMPRESSOR8; +typedef struct IDirectSoundFXParamEq8 *LPDIRECTSOUNDFXPARAMEQ8; +typedef struct IDirectSoundFXWavesReverb8 *LPDIRECTSOUNDFXWAVESREVERB8; +typedef struct IDirectSoundFXI3DL2Reverb8 *LPDIRECTSOUNDFXI3DL2REVERB8; +typedef struct IDirectSoundCaptureFXAec8 *LPDIRECTSOUNDCAPTUREFXAEC8; +typedef struct IDirectSoundCaptureFXNoiseSuppress8 *LPDIRECTSOUNDCAPTUREFXNOISESUPPRESS8; +typedef struct IDirectSoundFullDuplex8 *LPDIRECTSOUNDFULLDUPLEX8; + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// IID definitions for the unchanged DirectSound 8.0 interfaces +// + +#if DIRECTSOUND_VERSION >= 0x0800 + +#define IID_IDirectSoundCapture8 IID_IDirectSoundCapture +#define IID_IDirectSound3DListener8 IID_IDirectSound3DListener +#define IID_IDirectSound3DBuffer8 IID_IDirectSound3DBuffer +#define IID_IDirectSoundNotify8 IID_IDirectSoundNotify +#define IID_IDirectSoundFXGargle8 IID_IDirectSoundFXGargle +#define IID_IDirectSoundFXChorus8 IID_IDirectSoundFXChorus +#define IID_IDirectSoundFXFlanger8 IID_IDirectSoundFXFlanger +#define IID_IDirectSoundFXEcho8 IID_IDirectSoundFXEcho +#define IID_IDirectSoundFXDistortion8 IID_IDirectSoundFXDistortion +#define IID_IDirectSoundFXCompressor8 IID_IDirectSoundFXCompressor +#define IID_IDirectSoundFXParamEq8 IID_IDirectSoundFXParamEq +#define IID_IDirectSoundFXWavesReverb8 IID_IDirectSoundFXWavesReverb +#define IID_IDirectSoundFXI3DL2Reverb8 IID_IDirectSoundFXI3DL2Reverb +#define IID_IDirectSoundCaptureFXAec8 IID_IDirectSoundCaptureFXAec +#define IID_IDirectSoundCaptureFXNoiseSuppress8 IID_IDirectSoundCaptureFXNoiseSuppress +#define IID_IDirectSoundFullDuplex8 IID_IDirectSoundFullDuplex + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// Compatibility typedefs +// + +#ifndef _LPCWAVEFORMATEX_DEFINED +#define _LPCWAVEFORMATEX_DEFINED +typedef const WAVEFORMATEX *LPCWAVEFORMATEX; +#endif // _LPCWAVEFORMATEX_DEFINED + +#ifndef __LPCGUID_DEFINED__ +#define __LPCGUID_DEFINED__ +typedef const GUID *LPCGUID; +#endif // __LPCGUID_DEFINED__ + +typedef LPDIRECTSOUND *LPLPDIRECTSOUND; +typedef LPDIRECTSOUNDBUFFER *LPLPDIRECTSOUNDBUFFER; +typedef LPDIRECTSOUND3DLISTENER *LPLPDIRECTSOUND3DLISTENER; +typedef LPDIRECTSOUND3DBUFFER *LPLPDIRECTSOUND3DBUFFER; +typedef LPDIRECTSOUNDCAPTURE *LPLPDIRECTSOUNDCAPTURE; +typedef LPDIRECTSOUNDCAPTUREBUFFER *LPLPDIRECTSOUNDCAPTUREBUFFER; +typedef LPDIRECTSOUNDNOTIFY *LPLPDIRECTSOUNDNOTIFY; + +#if DIRECTSOUND_VERSION >= 0x0800 +typedef LPDIRECTSOUND8 *LPLPDIRECTSOUND8; +typedef LPDIRECTSOUNDBUFFER8 *LPLPDIRECTSOUNDBUFFER8; +typedef LPDIRECTSOUNDCAPTURE8 *LPLPDIRECTSOUNDCAPTURE8; +typedef LPDIRECTSOUNDCAPTUREBUFFER8 *LPLPDIRECTSOUNDCAPTUREBUFFER8; +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// Structures +// + +typedef struct _DSCAPS +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwMinSecondarySampleRate; + DWORD dwMaxSecondarySampleRate; + DWORD dwPrimaryBuffers; + DWORD dwMaxHwMixingAllBuffers; + DWORD dwMaxHwMixingStaticBuffers; + DWORD dwMaxHwMixingStreamingBuffers; + DWORD dwFreeHwMixingAllBuffers; + DWORD dwFreeHwMixingStaticBuffers; + DWORD dwFreeHwMixingStreamingBuffers; + DWORD dwMaxHw3DAllBuffers; + DWORD dwMaxHw3DStaticBuffers; + DWORD dwMaxHw3DStreamingBuffers; + DWORD dwFreeHw3DAllBuffers; + DWORD dwFreeHw3DStaticBuffers; + DWORD dwFreeHw3DStreamingBuffers; + DWORD dwTotalHwMemBytes; + DWORD dwFreeHwMemBytes; + DWORD dwMaxContigFreeHwMemBytes; + DWORD dwUnlockTransferRateHwBuffers; + DWORD dwPlayCpuOverheadSwBuffers; + DWORD dwReserved1; + DWORD dwReserved2; +} DSCAPS, *LPDSCAPS; + +typedef const DSCAPS *LPCDSCAPS; + +typedef struct _DSBCAPS +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwUnlockTransferRate; + DWORD dwPlayCpuOverhead; +} DSBCAPS, *LPDSBCAPS; + +typedef const DSBCAPS *LPCDSBCAPS; + +#if DIRECTSOUND_VERSION >= 0x0800 + + typedef struct _DSEFFECTDESC + { + DWORD dwSize; + DWORD dwFlags; + GUID guidDSFXClass; + DWORD_PTR dwReserved1; + DWORD_PTR dwReserved2; + } DSEFFECTDESC, *LPDSEFFECTDESC; + typedef const DSEFFECTDESC *LPCDSEFFECTDESC; + + #define DSFX_LOCHARDWARE 0x00000001 + #define DSFX_LOCSOFTWARE 0x00000002 + + enum + { + DSFXR_PRESENT, // 0 + DSFXR_LOCHARDWARE, // 1 + DSFXR_LOCSOFTWARE, // 2 + DSFXR_UNALLOCATED, // 3 + DSFXR_FAILED, // 4 + DSFXR_UNKNOWN, // 5 + DSFXR_SENDLOOP // 6 + }; + + typedef struct _DSCEFFECTDESC + { + DWORD dwSize; + DWORD dwFlags; + GUID guidDSCFXClass; + GUID guidDSCFXInstance; + DWORD dwReserved1; + DWORD dwReserved2; + } DSCEFFECTDESC, *LPDSCEFFECTDESC; + typedef const DSCEFFECTDESC *LPCDSCEFFECTDESC; + + #define DSCFX_LOCHARDWARE 0x00000001 + #define DSCFX_LOCSOFTWARE 0x00000002 + + #define DSCFXR_LOCHARDWARE 0x00000010 + #define DSCFXR_LOCSOFTWARE 0x00000020 + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +typedef struct _DSBUFFERDESC +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; + LPWAVEFORMATEX lpwfxFormat; +#if DIRECTSOUND_VERSION >= 0x0700 + GUID guid3DAlgorithm; +#endif +} DSBUFFERDESC, *LPDSBUFFERDESC; + +typedef const DSBUFFERDESC *LPCDSBUFFERDESC; + +// Older version of this structure: + +typedef struct _DSBUFFERDESC1 +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; + LPWAVEFORMATEX lpwfxFormat; +} DSBUFFERDESC1, *LPDSBUFFERDESC1; + +typedef const DSBUFFERDESC1 *LPCDSBUFFERDESC1; + +typedef struct _DS3DBUFFER +{ + DWORD dwSize; + D3DVECTOR vPosition; + D3DVECTOR vVelocity; + DWORD dwInsideConeAngle; + DWORD dwOutsideConeAngle; + D3DVECTOR vConeOrientation; + LONG lConeOutsideVolume; + D3DVALUE flMinDistance; + D3DVALUE flMaxDistance; + DWORD dwMode; +} DS3DBUFFER, *LPDS3DBUFFER; + +typedef const DS3DBUFFER *LPCDS3DBUFFER; + +typedef struct _DS3DLISTENER +{ + DWORD dwSize; + D3DVECTOR vPosition; + D3DVECTOR vVelocity; + D3DVECTOR vOrientFront; + D3DVECTOR vOrientTop; + D3DVALUE flDistanceFactor; + D3DVALUE flRolloffFactor; + D3DVALUE flDopplerFactor; +} DS3DLISTENER, *LPDS3DLISTENER; + +typedef const DS3DLISTENER *LPCDS3DLISTENER; + +typedef struct _DSCCAPS +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwFormats; + DWORD dwChannels; +} DSCCAPS, *LPDSCCAPS; + +typedef const DSCCAPS *LPCDSCCAPS; + +typedef struct _DSCBUFFERDESC1 +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; + LPWAVEFORMATEX lpwfxFormat; +} DSCBUFFERDESC1, *LPDSCBUFFERDESC1; + +typedef struct _DSCBUFFERDESC +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; + LPWAVEFORMATEX lpwfxFormat; +#if DIRECTSOUND_VERSION >= 0x0800 + DWORD dwFXCount; + LPDSCEFFECTDESC lpDSCFXDesc; +#endif +} DSCBUFFERDESC, *LPDSCBUFFERDESC; + +typedef const DSCBUFFERDESC *LPCDSCBUFFERDESC; + +typedef struct _DSCBCAPS +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; +} DSCBCAPS, *LPDSCBCAPS; + +typedef const DSCBCAPS *LPCDSCBCAPS; + +typedef struct _DSBPOSITIONNOTIFY +{ + DWORD dwOffset; + HANDLE hEventNotify; +} DSBPOSITIONNOTIFY, *LPDSBPOSITIONNOTIFY; + +typedef const DSBPOSITIONNOTIFY *LPCDSBPOSITIONNOTIFY; + +// +// DirectSound API +// + +typedef BOOL (CALLBACK *LPDSENUMCALLBACKA)(LPGUID, LPCSTR, LPCSTR, LPVOID); +typedef BOOL (CALLBACK *LPDSENUMCALLBACKW)(LPGUID, LPCWSTR, LPCWSTR, LPVOID); + +extern HRESULT WINAPI DirectSoundCreate(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter); +extern HRESULT WINAPI DirectSoundEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext); +extern HRESULT WINAPI DirectSoundEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext); + +extern HRESULT WINAPI DirectSoundCaptureCreate(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE *ppDSC, LPUNKNOWN pUnkOuter); +extern HRESULT WINAPI DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext); +extern HRESULT WINAPI DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext); + +#if DIRECTSOUND_VERSION >= 0x0800 +extern HRESULT WINAPI DirectSoundCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUND8 *ppDS8, LPUNKNOWN pUnkOuter); +extern HRESULT WINAPI DirectSoundCaptureCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE8 *ppDSC8, LPUNKNOWN pUnkOuter); +extern HRESULT WINAPI DirectSoundFullDuplexCreate(LPCGUID pcGuidCaptureDevice, LPCGUID pcGuidRenderDevice, + LPCDSCBUFFERDESC pcDSCBufferDesc, LPCDSBUFFERDESC pcDSBufferDesc, HWND hWnd, + DWORD dwLevel, LPDIRECTSOUNDFULLDUPLEX* ppDSFD, LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8, + LPDIRECTSOUNDBUFFER8 *ppDSBuffer8, LPUNKNOWN pUnkOuter); +#define DirectSoundFullDuplexCreate8 DirectSoundFullDuplexCreate + +extern HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest); +#endif // DIRECTSOUND_VERSION >= 0x0800 + +#ifdef UNICODE +#define LPDSENUMCALLBACK LPDSENUMCALLBACKW +#define DirectSoundEnumerate DirectSoundEnumerateW +#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateW +#else // UNICODE +#define LPDSENUMCALLBACK LPDSENUMCALLBACKA +#define DirectSoundEnumerate DirectSoundEnumerateA +#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateA +#endif // UNICODE + +// +// IUnknown +// + +#if !defined(__cplusplus) || defined(CINTERFACE) +#ifndef IUnknown_QueryInterface +#define IUnknown_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#endif // IUnknown_QueryInterface +#ifndef IUnknown_AddRef +#define IUnknown_AddRef(p) (p)->lpVtbl->AddRef(p) +#endif // IUnknown_AddRef +#ifndef IUnknown_Release +#define IUnknown_Release(p) (p)->lpVtbl->Release(p) +#endif // IUnknown_Release +#else // !defined(__cplusplus) || defined(CINTERFACE) +#ifndef IUnknown_QueryInterface +#define IUnknown_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#endif // IUnknown_QueryInterface +#ifndef IUnknown_AddRef +#define IUnknown_AddRef(p) (p)->AddRef() +#endif // IUnknown_AddRef +#ifndef IUnknown_Release +#define IUnknown_Release(p) (p)->Release() +#endif // IUnknown_Release +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#ifndef __IReferenceClock_INTERFACE_DEFINED__ +#define __IReferenceClock_INTERFACE_DEFINED__ + +typedef LONGLONG REFERENCE_TIME; +typedef REFERENCE_TIME *LPREFERENCE_TIME; + +DEFINE_GUID(IID_IReferenceClock, 0x56a86897, 0x0ad4, 0x11ce, 0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70); + +#undef INTERFACE +#define INTERFACE IReferenceClock + +DECLARE_INTERFACE_(IReferenceClock, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IReferenceClock methods + STDMETHOD(GetTime) (THIS_ REFERENCE_TIME *pTime) PURE; + STDMETHOD(AdviseTime) (THIS_ REFERENCE_TIME rtBaseTime, REFERENCE_TIME rtStreamTime, + HANDLE hEvent, LPDWORD pdwAdviseCookie) PURE; + STDMETHOD(AdvisePeriodic) (THIS_ REFERENCE_TIME rtStartTime, REFERENCE_TIME rtPeriodTime, + HANDLE hSemaphore, LPDWORD pdwAdviseCookie) PURE; + STDMETHOD(Unadvise) (THIS_ DWORD dwAdviseCookie) PURE; +}; + +#endif // __IReferenceClock_INTERFACE_DEFINED__ + +#ifndef IReferenceClock_QueryInterface + +#define IReferenceClock_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IReferenceClock_AddRef(p) IUnknown_AddRef(p) +#define IReferenceClock_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IReferenceClock_GetTime(p,a) (p)->lpVtbl->GetTime(p,a) +#define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->lpVtbl->AdviseTime(p,a,b,c,d) +#define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->lpVtbl->AdvisePeriodic(p,a,b,c,d) +#define IReferenceClock_Unadvise(p,a) (p)->lpVtbl->Unadvise(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IReferenceClock_GetTime(p,a) (p)->GetTime(a) +#define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->AdviseTime(a,b,c,d) +#define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->AdvisePeriodic(a,b,c,d) +#define IReferenceClock_Unadvise(p,a) (p)->Unadvise(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // IReferenceClock_QueryInterface + +// +// IDirectSound +// + +DEFINE_GUID(IID_IDirectSound, 0x279AFA83, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); + +#undef INTERFACE +#define INTERFACE IDirectSound + +DECLARE_INTERFACE_(IDirectSound, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSound methods + STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE; + STDMETHOD(GetCaps) (THIS_ LPDSCAPS pDSCaps) PURE; + STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE; + STDMETHOD(SetCooperativeLevel) (THIS_ HWND hwnd, DWORD dwLevel) PURE; + STDMETHOD(Compact) (THIS) PURE; + STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD pdwSpeakerConfig) PURE; + STDMETHOD(SetSpeakerConfig) (THIS_ DWORD dwSpeakerConfig) PURE; + STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; +}; + +#define IDirectSound_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSound_AddRef(p) IUnknown_AddRef(p) +#define IDirectSound_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->lpVtbl->CreateSoundBuffer(p,a,b,c) +#define IDirectSound_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->lpVtbl->DuplicateSoundBuffer(p,a,b) +#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectSound_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectSound_GetSpeakerConfig(p,a) (p)->lpVtbl->GetSpeakerConfig(p,a) +#define IDirectSound_SetSpeakerConfig(p,b) (p)->lpVtbl->SetSpeakerConfig(p,b) +#define IDirectSound_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->CreateSoundBuffer(a,b,c) +#define IDirectSound_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->DuplicateSoundBuffer(a,b) +#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectSound_Compact(p) (p)->Compact() +#define IDirectSound_GetSpeakerConfig(p,a) (p)->GetSpeakerConfig(a) +#define IDirectSound_SetSpeakerConfig(p,b) (p)->SetSpeakerConfig(b) +#define IDirectSound_Initialize(p,a) (p)->Initialize(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSound8 +// + +DEFINE_GUID(IID_IDirectSound8, 0xC50A7E93, 0xF395, 0x4834, 0x9E, 0xF6, 0x7F, 0xA9, 0x9D, 0xE5, 0x09, 0x66); + +#undef INTERFACE +#define INTERFACE IDirectSound8 + +DECLARE_INTERFACE_(IDirectSound8, IDirectSound) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSound methods + STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE; + STDMETHOD(GetCaps) (THIS_ LPDSCAPS pDSCaps) PURE; + STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE; + STDMETHOD(SetCooperativeLevel) (THIS_ HWND hwnd, DWORD dwLevel) PURE; + STDMETHOD(Compact) (THIS) PURE; + STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD pdwSpeakerConfig) PURE; + STDMETHOD(SetSpeakerConfig) (THIS_ DWORD dwSpeakerConfig) PURE; + STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; + + // IDirectSound8 methods + STDMETHOD(VerifyCertification) (THIS_ LPDWORD pdwCertified) PURE; +}; + +#define IDirectSound8_QueryInterface(p,a,b) IDirectSound_QueryInterface(p,a,b) +#define IDirectSound8_AddRef(p) IDirectSound_AddRef(p) +#define IDirectSound8_Release(p) IDirectSound_Release(p) +#define IDirectSound8_CreateSoundBuffer(p,a,b,c) IDirectSound_CreateSoundBuffer(p,a,b,c) +#define IDirectSound8_GetCaps(p,a) IDirectSound_GetCaps(p,a) +#define IDirectSound8_DuplicateSoundBuffer(p,a,b) IDirectSound_DuplicateSoundBuffer(p,a,b) +#define IDirectSound8_SetCooperativeLevel(p,a,b) IDirectSound_SetCooperativeLevel(p,a,b) +#define IDirectSound8_Compact(p) IDirectSound_Compact(p) +#define IDirectSound8_GetSpeakerConfig(p,a) IDirectSound_GetSpeakerConfig(p,a) +#define IDirectSound8_SetSpeakerConfig(p,a) IDirectSound_SetSpeakerConfig(p,a) +#define IDirectSound8_Initialize(p,a) IDirectSound_Initialize(p,a) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound8_VerifyCertification(p,a) (p)->lpVtbl->VerifyCertification(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound8_VerifyCertification(p,a) (p)->VerifyCertification(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundBuffer +// + +DEFINE_GUID(IID_IDirectSoundBuffer, 0x279AFA85, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); + +#undef INTERFACE +#define INTERFACE IDirectSoundBuffer + +DECLARE_INTERFACE_(IDirectSoundBuffer, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundBuffer methods + STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE; + STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; + STDMETHOD(GetVolume) (THIS_ LPLONG plVolume) PURE; + STDMETHOD(GetPan) (THIS_ LPLONG plPan) PURE; + STDMETHOD(GetFrequency) (THIS_ LPDWORD pdwFrequency) PURE; + STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; + STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc) PURE; + STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; + STDMETHOD(Play) (THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE; + STDMETHOD(SetCurrentPosition) (THIS_ DWORD dwNewPosition) PURE; + STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX pcfxFormat) PURE; + STDMETHOD(SetVolume) (THIS_ LONG lVolume) PURE; + STDMETHOD(SetPan) (THIS_ LONG lPan) PURE; + STDMETHOD(SetFrequency) (THIS_ DWORD dwFrequency) PURE; + STDMETHOD(Stop) (THIS) PURE; + STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; + STDMETHOD(Restore) (THIS) PURE; +}; + +#define IDirectSoundBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundBuffer_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundBuffer_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b) +#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c) +#define IDirectSoundBuffer_GetVolume(p,a) (p)->lpVtbl->GetVolume(p,a) +#define IDirectSoundBuffer_GetPan(p,a) (p)->lpVtbl->GetPan(p,a) +#define IDirectSoundBuffer_GetFrequency(p,a) (p)->lpVtbl->GetFrequency(p,a) +#define IDirectSoundBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a) +#define IDirectSoundBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g) +#define IDirectSoundBuffer_Play(p,a,b,c) (p)->lpVtbl->Play(p,a,b,c) +#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->lpVtbl->SetCurrentPosition(p,a) +#define IDirectSoundBuffer_SetFormat(p,a) (p)->lpVtbl->SetFormat(p,a) +#define IDirectSoundBuffer_SetVolume(p,a) (p)->lpVtbl->SetVolume(p,a) +#define IDirectSoundBuffer_SetPan(p,a) (p)->lpVtbl->SetPan(p,a) +#define IDirectSoundBuffer_SetFrequency(p,a) (p)->lpVtbl->SetFrequency(p,a) +#define IDirectSoundBuffer_Stop(p) (p)->lpVtbl->Stop(p) +#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d) +#define IDirectSoundBuffer_Restore(p) (p)->lpVtbl->Restore(p) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundBuffer_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b) +#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c) +#define IDirectSoundBuffer_GetVolume(p,a) (p)->GetVolume(a) +#define IDirectSoundBuffer_GetPan(p,a) (p)->GetPan(a) +#define IDirectSoundBuffer_GetFrequency(p,a) (p)->GetFrequency(a) +#define IDirectSoundBuffer_GetStatus(p,a) (p)->GetStatus(a) +#define IDirectSoundBuffer_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g) +#define IDirectSoundBuffer_Play(p,a,b,c) (p)->Play(a,b,c) +#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->SetCurrentPosition(a) +#define IDirectSoundBuffer_SetFormat(p,a) (p)->SetFormat(a) +#define IDirectSoundBuffer_SetVolume(p,a) (p)->SetVolume(a) +#define IDirectSoundBuffer_SetPan(p,a) (p)->SetPan(a) +#define IDirectSoundBuffer_SetFrequency(p,a) (p)->SetFrequency(a) +#define IDirectSoundBuffer_Stop(p) (p)->Stop() +#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d) +#define IDirectSoundBuffer_Restore(p) (p)->Restore() +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundBuffer8 +// + +DEFINE_GUID(IID_IDirectSoundBuffer8, 0x6825a449, 0x7524, 0x4d82, 0x92, 0x0f, 0x50, 0xe3, 0x6a, 0xb3, 0xab, 0x1e); + +#undef INTERFACE +#define INTERFACE IDirectSoundBuffer8 + +DECLARE_INTERFACE_(IDirectSoundBuffer8, IDirectSoundBuffer) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundBuffer methods + STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE; + STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; + STDMETHOD(GetVolume) (THIS_ LPLONG plVolume) PURE; + STDMETHOD(GetPan) (THIS_ LPLONG plPan) PURE; + STDMETHOD(GetFrequency) (THIS_ LPDWORD pdwFrequency) PURE; + STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; + STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc) PURE; + STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; + STDMETHOD(Play) (THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE; + STDMETHOD(SetCurrentPosition) (THIS_ DWORD dwNewPosition) PURE; + STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX pcfxFormat) PURE; + STDMETHOD(SetVolume) (THIS_ LONG lVolume) PURE; + STDMETHOD(SetPan) (THIS_ LONG lPan) PURE; + STDMETHOD(SetFrequency) (THIS_ DWORD dwFrequency) PURE; + STDMETHOD(Stop) (THIS) PURE; + STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; + STDMETHOD(Restore) (THIS) PURE; + + // IDirectSoundBuffer8 methods + STDMETHOD(SetFX) (THIS_ DWORD dwEffectsCount, LPDSEFFECTDESC pDSFXDesc, LPDWORD pdwResultCodes) PURE; + STDMETHOD(AcquireResources) (THIS_ DWORD dwFlags, DWORD dwEffectsCount, LPDWORD pdwResultCodes) PURE; + STDMETHOD(GetObjectInPath) (THIS_ REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject) PURE; +}; + +// Special GUID meaning "select all objects" for use in GetObjectInPath() +DEFINE_GUID(GUID_All_Objects, 0xaa114de5, 0xc262, 0x4169, 0xa1, 0xc8, 0x23, 0xd6, 0x98, 0xcc, 0x73, 0xb5); + +#define IDirectSoundBuffer8_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundBuffer8_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundBuffer8_Release(p) IUnknown_Release(p) + +#define IDirectSoundBuffer8_GetCaps(p,a) IDirectSoundBuffer_GetCaps(p,a) +#define IDirectSoundBuffer8_GetCurrentPosition(p,a,b) IDirectSoundBuffer_GetCurrentPosition(p,a,b) +#define IDirectSoundBuffer8_GetFormat(p,a,b,c) IDirectSoundBuffer_GetFormat(p,a,b,c) +#define IDirectSoundBuffer8_GetVolume(p,a) IDirectSoundBuffer_GetVolume(p,a) +#define IDirectSoundBuffer8_GetPan(p,a) IDirectSoundBuffer_GetPan(p,a) +#define IDirectSoundBuffer8_GetFrequency(p,a) IDirectSoundBuffer_GetFrequency(p,a) +#define IDirectSoundBuffer8_GetStatus(p,a) IDirectSoundBuffer_GetStatus(p,a) +#define IDirectSoundBuffer8_Initialize(p,a,b) IDirectSoundBuffer_Initialize(p,a,b) +#define IDirectSoundBuffer8_Lock(p,a,b,c,d,e,f,g) IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) +#define IDirectSoundBuffer8_Play(p,a,b,c) IDirectSoundBuffer_Play(p,a,b,c) +#define IDirectSoundBuffer8_SetCurrentPosition(p,a) IDirectSoundBuffer_SetCurrentPosition(p,a) +#define IDirectSoundBuffer8_SetFormat(p,a) IDirectSoundBuffer_SetFormat(p,a) +#define IDirectSoundBuffer8_SetVolume(p,a) IDirectSoundBuffer_SetVolume(p,a) +#define IDirectSoundBuffer8_SetPan(p,a) IDirectSoundBuffer_SetPan(p,a) +#define IDirectSoundBuffer8_SetFrequency(p,a) IDirectSoundBuffer_SetFrequency(p,a) +#define IDirectSoundBuffer8_Stop(p) IDirectSoundBuffer_Stop(p) +#define IDirectSoundBuffer8_Unlock(p,a,b,c,d) IDirectSoundBuffer_Unlock(p,a,b,c,d) +#define IDirectSoundBuffer8_Restore(p) IDirectSoundBuffer_Restore(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundBuffer8_SetFX(p,a,b,c) (p)->lpVtbl->SetFX(p,a,b,c) +#define IDirectSoundBuffer8_AcquireResources(p,a,b,c) (p)->lpVtbl->AcquireResources(p,a,b,c) +#define IDirectSoundBuffer8_GetObjectInPath(p,a,b,c,d) (p)->lpVtbl->GetObjectInPath(p,a,b,c,d) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundBuffer8_SetFX(p,a,b,c) (p)->SetFX(a,b,c) +#define IDirectSoundBuffer8_AcquireResources(p,a,b,c) (p)->AcquireResources(a,b,c) +#define IDirectSoundBuffer8_GetObjectInPath(p,a,b,c,d) (p)->GetObjectInPath(a,b,c,d) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSound3DListener +// + +DEFINE_GUID(IID_IDirectSound3DListener, 0x279AFA84, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); + +#undef INTERFACE +#define INTERFACE IDirectSound3DListener + +DECLARE_INTERFACE_(IDirectSound3DListener, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSound3DListener methods + STDMETHOD(GetAllParameters) (THIS_ LPDS3DLISTENER pListener) PURE; + STDMETHOD(GetDistanceFactor) (THIS_ D3DVALUE* pflDistanceFactor) PURE; + STDMETHOD(GetDopplerFactor) (THIS_ D3DVALUE* pflDopplerFactor) PURE; + STDMETHOD(GetOrientation) (THIS_ D3DVECTOR* pvOrientFront, D3DVECTOR* pvOrientTop) PURE; + STDMETHOD(GetPosition) (THIS_ D3DVECTOR* pvPosition) PURE; + STDMETHOD(GetRolloffFactor) (THIS_ D3DVALUE* pflRolloffFactor) PURE; + STDMETHOD(GetVelocity) (THIS_ D3DVECTOR* pvVelocity) PURE; + STDMETHOD(SetAllParameters) (THIS_ LPCDS3DLISTENER pcListener, DWORD dwApply) PURE; + STDMETHOD(SetDistanceFactor) (THIS_ D3DVALUE flDistanceFactor, DWORD dwApply) PURE; + STDMETHOD(SetDopplerFactor) (THIS_ D3DVALUE flDopplerFactor, DWORD dwApply) PURE; + STDMETHOD(SetOrientation) (THIS_ D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront, + D3DVALUE xTop, D3DVALUE yTop, D3DVALUE zTop, DWORD dwApply) PURE; + STDMETHOD(SetPosition) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; + STDMETHOD(SetRolloffFactor) (THIS_ D3DVALUE flRolloffFactor, DWORD dwApply) PURE; + STDMETHOD(SetVelocity) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; + STDMETHOD(CommitDeferredSettings) (THIS) PURE; +}; + +#define IDirectSound3DListener_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSound3DListener_AddRef(p) IUnknown_AddRef(p) +#define IDirectSound3DListener_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound3DListener_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->lpVtbl->GetDistanceFactor(p,a) +#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->lpVtbl->GetDopplerFactor(p,a) +#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->lpVtbl->GetOrientation(p,a,b) +#define IDirectSound3DListener_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a) +#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->lpVtbl->GetRolloffFactor(p,a) +#define IDirectSound3DListener_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a) +#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b) +#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->lpVtbl->SetDistanceFactor(p,a,b) +#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->lpVtbl->SetDopplerFactor(p,a,b) +#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->lpVtbl->SetOrientation(p,a,b,c,d,e,f,g) +#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d) +#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->lpVtbl->SetRolloffFactor(p,a,b) +#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d) +#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->lpVtbl->CommitDeferredSettings(p) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound3DListener_GetAllParameters(p,a) (p)->GetAllParameters(a) +#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->GetDistanceFactor(a) +#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->GetDopplerFactor(a) +#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->GetOrientation(a,b) +#define IDirectSound3DListener_GetPosition(p,a) (p)->GetPosition(a) +#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->GetRolloffFactor(a) +#define IDirectSound3DListener_GetVelocity(p,a) (p)->GetVelocity(a) +#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b) +#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->SetDistanceFactor(a,b) +#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->SetDopplerFactor(a,b) +#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->SetOrientation(a,b,c,d,e,f,g) +#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d) +#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->SetRolloffFactor(a,b) +#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d) +#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->CommitDeferredSettings() +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSound3DBuffer +// + +DEFINE_GUID(IID_IDirectSound3DBuffer, 0x279AFA86, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); + +#undef INTERFACE +#define INTERFACE IDirectSound3DBuffer + +DECLARE_INTERFACE_(IDirectSound3DBuffer, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSound3DBuffer methods + STDMETHOD(GetAllParameters) (THIS_ LPDS3DBUFFER pDs3dBuffer) PURE; + STDMETHOD(GetConeAngles) (THIS_ LPDWORD pdwInsideConeAngle, LPDWORD pdwOutsideConeAngle) PURE; + STDMETHOD(GetConeOrientation) (THIS_ D3DVECTOR* pvOrientation) PURE; + STDMETHOD(GetConeOutsideVolume) (THIS_ LPLONG plConeOutsideVolume) PURE; + STDMETHOD(GetMaxDistance) (THIS_ D3DVALUE* pflMaxDistance) PURE; + STDMETHOD(GetMinDistance) (THIS_ D3DVALUE* pflMinDistance) PURE; + STDMETHOD(GetMode) (THIS_ LPDWORD pdwMode) PURE; + STDMETHOD(GetPosition) (THIS_ D3DVECTOR* pvPosition) PURE; + STDMETHOD(GetVelocity) (THIS_ D3DVECTOR* pvVelocity) PURE; + STDMETHOD(SetAllParameters) (THIS_ LPCDS3DBUFFER pcDs3dBuffer, DWORD dwApply) PURE; + STDMETHOD(SetConeAngles) (THIS_ DWORD dwInsideConeAngle, DWORD dwOutsideConeAngle, DWORD dwApply) PURE; + STDMETHOD(SetConeOrientation) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; + STDMETHOD(SetConeOutsideVolume) (THIS_ LONG lConeOutsideVolume, DWORD dwApply) PURE; + STDMETHOD(SetMaxDistance) (THIS_ D3DVALUE flMaxDistance, DWORD dwApply) PURE; + STDMETHOD(SetMinDistance) (THIS_ D3DVALUE flMinDistance, DWORD dwApply) PURE; + STDMETHOD(SetMode) (THIS_ DWORD dwMode, DWORD dwApply) PURE; + STDMETHOD(SetPosition) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; + STDMETHOD(SetVelocity) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; +}; + +#define IDirectSound3DBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSound3DBuffer_AddRef(p) IUnknown_AddRef(p) +#define IDirectSound3DBuffer_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->lpVtbl->GetConeAngles(p,a,b) +#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->lpVtbl->GetConeOrientation(p,a) +#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->lpVtbl->GetConeOutsideVolume(p,a) +#define IDirectSound3DBuffer_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a) +#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->lpVtbl->GetMinDistance(p,a) +#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->lpVtbl->GetMaxDistance(p,a) +#define IDirectSound3DBuffer_GetMode(p,a) (p)->lpVtbl->GetMode(p,a) +#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a) +#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b) +#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->lpVtbl->SetConeAngles(p,a,b,c) +#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->lpVtbl->SetConeOrientation(p,a,b,c,d) +#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->lpVtbl->SetConeOutsideVolume(p,a,b) +#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d) +#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->lpVtbl->SetMinDistance(p,a,b) +#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->lpVtbl->SetMaxDistance(p,a,b) +#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->lpVtbl->SetMode(p,a,b) +#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->GetAllParameters(a) +#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->GetConeAngles(a,b) +#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->GetConeOrientation(a) +#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->GetConeOutsideVolume(a) +#define IDirectSound3DBuffer_GetPosition(p,a) (p)->GetPosition(a) +#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->GetMinDistance(a) +#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->GetMaxDistance(a) +#define IDirectSound3DBuffer_GetMode(p,a) (p)->GetMode(a) +#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->GetVelocity(a) +#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b) +#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->SetConeAngles(a,b,c) +#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->SetConeOrientation(a,b,c,d) +#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->SetConeOutsideVolume(a,b) +#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d) +#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->SetMinDistance(a,b) +#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->SetMaxDistance(a,b) +#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->SetMode(a,b) +#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundCapture +// + +DEFINE_GUID(IID_IDirectSoundCapture, 0xb0210781, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); + +#undef INTERFACE +#define INTERFACE IDirectSoundCapture + +DECLARE_INTERFACE_(IDirectSoundCapture, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCapture methods + STDMETHOD(CreateCaptureBuffer) (THIS_ LPCDSCBUFFERDESC pcDSCBufferDesc, LPDIRECTSOUNDCAPTUREBUFFER *ppDSCBuffer, LPUNKNOWN pUnkOuter) PURE; + STDMETHOD(GetCaps) (THIS_ LPDSCCAPS pDSCCaps) PURE; + STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; +}; + +#define IDirectSoundCapture_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCapture_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCapture_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->lpVtbl->CreateCaptureBuffer(p,a,b,c) +#define IDirectSoundCapture_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectSoundCapture_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->CreateCaptureBuffer(a,b,c) +#define IDirectSoundCapture_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectSoundCapture_Initialize(p,a) (p)->Initialize(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundCaptureBuffer +// + +DEFINE_GUID(IID_IDirectSoundCaptureBuffer, 0xb0210782, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); + +#undef INTERFACE +#define INTERFACE IDirectSoundCaptureBuffer + +DECLARE_INTERFACE_(IDirectSoundCaptureBuffer, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCaptureBuffer methods + STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS pDSCBCaps) PURE; + STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCapturePosition, LPDWORD pdwReadPosition) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; + STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; + STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE pDirectSoundCapture, LPCDSCBUFFERDESC pcDSCBufferDesc) PURE; + STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; + STDMETHOD(Start) (THIS_ DWORD dwFlags) PURE; + STDMETHOD(Stop) (THIS) PURE; + STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; +}; + +#define IDirectSoundCaptureBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCaptureBuffer_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCaptureBuffer_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b) +#define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c) +#define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a) +#define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g) +#define IDirectSoundCaptureBuffer_Start(p,a) (p)->lpVtbl->Start(p,a) +#define IDirectSoundCaptureBuffer_Stop(p) (p)->lpVtbl->Stop(p) +#define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b) +#define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c) +#define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->GetStatus(a) +#define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g) +#define IDirectSoundCaptureBuffer_Start(p,a) (p)->Start(a) +#define IDirectSoundCaptureBuffer_Stop(p) (p)->Stop() +#define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundCaptureBuffer8 +// + +DEFINE_GUID(IID_IDirectSoundCaptureBuffer8, 0x990df4, 0xdbb, 0x4872, 0x83, 0x3e, 0x6d, 0x30, 0x3e, 0x80, 0xae, 0xb6); + +#undef INTERFACE +#define INTERFACE IDirectSoundCaptureBuffer8 + +DECLARE_INTERFACE_(IDirectSoundCaptureBuffer8, IDirectSoundCaptureBuffer) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCaptureBuffer methods + STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS pDSCBCaps) PURE; + STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCapturePosition, LPDWORD pdwReadPosition) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; + STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; + STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE pDirectSoundCapture, LPCDSCBUFFERDESC pcDSCBufferDesc) PURE; + STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; + STDMETHOD(Start) (THIS_ DWORD dwFlags) PURE; + STDMETHOD(Stop) (THIS) PURE; + STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; + + // IDirectSoundCaptureBuffer8 methods + STDMETHOD(GetObjectInPath) (THIS_ REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject) PURE; + STDMETHOD(GetFXStatus) (DWORD dwFXCount, LPDWORD pdwFXStatus) PURE; +}; + +#define IDirectSoundCaptureBuffer8_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCaptureBuffer8_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCaptureBuffer8_Release(p) IUnknown_Release(p) + +#define IDirectSoundCaptureBuffer8_GetCaps(p,a) IDirectSoundCaptureBuffer_GetCaps(p,a) +#define IDirectSoundCaptureBuffer8_GetCurrentPosition(p,a,b) IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) +#define IDirectSoundCaptureBuffer8_GetFormat(p,a,b,c) IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) +#define IDirectSoundCaptureBuffer8_GetStatus(p,a) IDirectSoundCaptureBuffer_GetStatus(p,a) +#define IDirectSoundCaptureBuffer8_Initialize(p,a,b) IDirectSoundCaptureBuffer_Initialize(p,a,b) +#define IDirectSoundCaptureBuffer8_Lock(p,a,b,c,d,e,f,g) IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) +#define IDirectSoundCaptureBuffer8_Start(p,a) IDirectSoundCaptureBuffer_Start(p,a) +#define IDirectSoundCaptureBuffer8_Stop(p) IDirectSoundCaptureBuffer_Stop(p)) +#define IDirectSoundCaptureBuffer8_Unlock(p,a,b,c,d) IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureBuffer8_GetObjectInPath(p,a,b,c,d) (p)->lpVtbl->GetObjectInPath(p,a,b,c,d) +#define IDirectSoundCaptureBuffer8_GetFXStatus(p,a,b) (p)->lpVtbl->GetFXStatus(p,a,b) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureBuffer8_GetObjectInPath(p,a,b,c,d) (p)->GetObjectInPath(a,b,c,d) +#define IDirectSoundCaptureBuffer8_GetFXStatus(p,a,b) (p)->GetFXStatus(a,b) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundNotify +// + +DEFINE_GUID(IID_IDirectSoundNotify, 0xb0210783, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); + +#undef INTERFACE +#define INTERFACE IDirectSoundNotify + +DECLARE_INTERFACE_(IDirectSoundNotify, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundNotify methods + STDMETHOD(SetNotificationPositions) (THIS_ DWORD dwPositionNotifies, LPCDSBPOSITIONNOTIFY pcPositionNotifies) PURE; +}; + +#define IDirectSoundNotify_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundNotify_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundNotify_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->lpVtbl->SetNotificationPositions(p,a,b) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->SetNotificationPositions(a,b) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IKsPropertySet +// + +#ifndef _IKsPropertySet_ +#define _IKsPropertySet_ + +#ifdef __cplusplus +// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined +struct IKsPropertySet; +#endif // __cplusplus + +typedef struct IKsPropertySet *LPKSPROPERTYSET; + +#define KSPROPERTY_SUPPORT_GET 0x00000001 +#define KSPROPERTY_SUPPORT_SET 0x00000002 + +DEFINE_GUID(IID_IKsPropertySet, 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93); + +#undef INTERFACE +#define INTERFACE IKsPropertySet + +DECLARE_INTERFACE_(IKsPropertySet, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IKsPropertySet methods + STDMETHOD(Get) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength, + LPVOID pPropertyData, ULONG ulDataLength, PULONG pulBytesReturned) PURE; + STDMETHOD(Set) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength, + LPVOID pPropertyData, ULONG ulDataLength) PURE; + STDMETHOD(QuerySupport) (THIS_ REFGUID rguidPropSet, ULONG ulId, PULONG pulTypeSupport) PURE; +}; + +#define IKsPropertySet_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IKsPropertySet_AddRef(p) IUnknown_AddRef(p) +#define IKsPropertySet_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->lpVtbl->Get(p,a,b,c,d,e,f,g) +#define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->lpVtbl->Set(p,a,b,c,d,e,f) +#define IKsPropertySet_QuerySupport(p,a,b,c) (p)->lpVtbl->QuerySupport(p,a,b,c) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->Get(a,b,c,d,e,f,g) +#define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->Set(a,b,c,d,e,f) +#define IKsPropertySet_QuerySupport(p,a,b,c) (p)->QuerySupport(a,b,c) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // _IKsPropertySet_ + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundFXGargle +// + +DEFINE_GUID(IID_IDirectSoundFXGargle, 0xd616f352, 0xd622, 0x11ce, 0xaa, 0xc5, 0x00, 0x20, 0xaf, 0x0b, 0x99, 0xa3); + +typedef struct _DSFXGargle +{ + DWORD dwRateHz; // Rate of modulation in hz + DWORD dwWaveShape; // DSFXGARGLE_WAVE_xxx +} DSFXGargle, *LPDSFXGargle; + +#define DSFXGARGLE_WAVE_TRIANGLE 0 +#define DSFXGARGLE_WAVE_SQUARE 1 + +typedef const DSFXGargle *LPCDSFXGargle; + +#define DSFXGARGLE_RATEHZ_MIN 1 +#define DSFXGARGLE_RATEHZ_MAX 1000 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXGargle + +DECLARE_INTERFACE_(IDirectSoundFXGargle, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXGargle methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXGargle pcDsFxGargle) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXGargle pDsFxGargle) PURE; +}; + +#define IDirectSoundFXGargle_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXGargle_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXGargle_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXGargle_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXGargle_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXGargle_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXGargle_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXChorus +// + +DEFINE_GUID(IID_IDirectSoundFXChorus, 0x880842e3, 0x145f, 0x43e6, 0xa9, 0x34, 0xa7, 0x18, 0x06, 0xe5, 0x05, 0x47); + +typedef struct _DSFXChorus +{ + FLOAT fWetDryMix; + FLOAT fDepth; + FLOAT fFeedback; + FLOAT fFrequency; + LONG lWaveform; // LFO shape; DSFXCHORUS_WAVE_xxx + FLOAT fDelay; + LONG lPhase; +} DSFXChorus, *LPDSFXChorus; + +typedef const DSFXChorus *LPCDSFXChorus; + +#define DSFXCHORUS_WAVE_TRIANGLE 0 +#define DSFXCHORUS_WAVE_SIN 1 + +#define DSFXCHORUS_WETDRYMIX_MIN 0.0f +#define DSFXCHORUS_WETDRYMIX_MAX 100.0f +#define DSFXCHORUS_DEPTH_MIN 0.0f +#define DSFXCHORUS_DEPTH_MAX 100.0f +#define DSFXCHORUS_FEEDBACK_MIN -99.0f +#define DSFXCHORUS_FEEDBACK_MAX 99.0f +#define DSFXCHORUS_FREQUENCY_MIN 0.0f +#define DSFXCHORUS_FREQUENCY_MAX 10.0f +#define DSFXCHORUS_DELAY_MIN 0.0f +#define DSFXCHORUS_DELAY_MAX 20.0f +#define DSFXCHORUS_PHASE_MIN 0 +#define DSFXCHORUS_PHASE_MAX 4 + +#define DSFXCHORUS_PHASE_NEG_180 0 +#define DSFXCHORUS_PHASE_NEG_90 1 +#define DSFXCHORUS_PHASE_ZERO 2 +#define DSFXCHORUS_PHASE_90 3 +#define DSFXCHORUS_PHASE_180 4 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXChorus + +DECLARE_INTERFACE_(IDirectSoundFXChorus, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXChorus methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXChorus pcDsFxChorus) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXChorus pDsFxChorus) PURE; +}; + +#define IDirectSoundFXChorus_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXChorus_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXChorus_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXChorus_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXChorus_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXChorus_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXChorus_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXFlanger +// + +DEFINE_GUID(IID_IDirectSoundFXFlanger, 0x903e9878, 0x2c92, 0x4072, 0x9b, 0x2c, 0xea, 0x68, 0xf5, 0x39, 0x67, 0x83); + +typedef struct _DSFXFlanger +{ + FLOAT fWetDryMix; + FLOAT fDepth; + FLOAT fFeedback; + FLOAT fFrequency; + LONG lWaveform; + FLOAT fDelay; + LONG lPhase; +} DSFXFlanger, *LPDSFXFlanger; + +typedef const DSFXFlanger *LPCDSFXFlanger; + +#define DSFXFLANGER_WAVE_TRIANGLE 0 +#define DSFXFLANGER_WAVE_SIN 1 + +#define DSFXFLANGER_WETDRYMIX_MIN 0.0f +#define DSFXFLANGER_WETDRYMIX_MAX 100.0f +#define DSFXFLANGER_FREQUENCY_MIN 0.0f +#define DSFXFLANGER_FREQUENCY_MAX 10.0f +#define DSFXFLANGER_DEPTH_MIN 0.0f +#define DSFXFLANGER_DEPTH_MAX 100.0f +#define DSFXFLANGER_PHASE_MIN 0 +#define DSFXFLANGER_PHASE_MAX 4 +#define DSFXFLANGER_FEEDBACK_MIN -99.0f +#define DSFXFLANGER_FEEDBACK_MAX 99.0f +#define DSFXFLANGER_DELAY_MIN 0.0f +#define DSFXFLANGER_DELAY_MAX 4.0f + +#define DSFXFLANGER_PHASE_NEG_180 0 +#define DSFXFLANGER_PHASE_NEG_90 1 +#define DSFXFLANGER_PHASE_ZERO 2 +#define DSFXFLANGER_PHASE_90 3 +#define DSFXFLANGER_PHASE_180 4 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXFlanger + +DECLARE_INTERFACE_(IDirectSoundFXFlanger, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXFlanger methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXFlanger pcDsFxFlanger) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXFlanger pDsFxFlanger) PURE; +}; + +#define IDirectSoundFXFlanger_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXFlanger_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXFlanger_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXFlanger_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXFlanger_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXFlanger_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXFlanger_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXEcho +// + +DEFINE_GUID(IID_IDirectSoundFXEcho, 0x8bd28edf, 0x50db, 0x4e92, 0xa2, 0xbd, 0x44, 0x54, 0x88, 0xd1, 0xed, 0x42); + +typedef struct _DSFXEcho +{ + FLOAT fWetDryMix; + FLOAT fFeedback; + FLOAT fLeftDelay; + FLOAT fRightDelay; + LONG lPanDelay; +} DSFXEcho, *LPDSFXEcho; + +typedef const DSFXEcho *LPCDSFXEcho; + +#define DSFXECHO_WETDRYMIX_MIN 0.0f +#define DSFXECHO_WETDRYMIX_MAX 100.0f +#define DSFXECHO_FEEDBACK_MIN 0.0f +#define DSFXECHO_FEEDBACK_MAX 100.0f +#define DSFXECHO_LEFTDELAY_MIN 1.0f +#define DSFXECHO_LEFTDELAY_MAX 2000.0f +#define DSFXECHO_RIGHTDELAY_MIN 1.0f +#define DSFXECHO_RIGHTDELAY_MAX 2000.0f +#define DSFXECHO_PANDELAY_MIN 0 +#define DSFXECHO_PANDELAY_MAX 1 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXEcho + +DECLARE_INTERFACE_(IDirectSoundFXEcho, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXEcho methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXEcho pcDsFxEcho) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXEcho pDsFxEcho) PURE; +}; + +#define IDirectSoundFXEcho_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXEcho_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXEcho_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXEcho_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXEcho_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXEcho_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXEcho_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXDistortion +// + +DEFINE_GUID(IID_IDirectSoundFXDistortion, 0x8ecf4326, 0x455f, 0x4d8b, 0xbd, 0xa9, 0x8d, 0x5d, 0x3e, 0x9e, 0x3e, 0x0b); + +typedef struct _DSFXDistortion +{ + FLOAT fGain; + FLOAT fEdge; + FLOAT fPostEQCenterFrequency; + FLOAT fPostEQBandwidth; + FLOAT fPreLowpassCutoff; +} DSFXDistortion, *LPDSFXDistortion; + +typedef const DSFXDistortion *LPCDSFXDistortion; + +#define DSFXDISTORTION_GAIN_MIN -60.0f +#define DSFXDISTORTION_GAIN_MAX 0.0f +#define DSFXDISTORTION_EDGE_MIN 0.0f +#define DSFXDISTORTION_EDGE_MAX 100.0f +#define DSFXDISTORTION_POSTEQCENTERFREQUENCY_MIN 100.0f +#define DSFXDISTORTION_POSTEQCENTERFREQUENCY_MAX 8000.0f +#define DSFXDISTORTION_POSTEQBANDWIDTH_MIN 100.0f +#define DSFXDISTORTION_POSTEQBANDWIDTH_MAX 8000.0f +#define DSFXDISTORTION_PRELOWPASSCUTOFF_MIN 100.0f +#define DSFXDISTORTION_PRELOWPASSCUTOFF_MAX 8000.0f + +#undef INTERFACE +#define INTERFACE IDirectSoundFXDistortion + +DECLARE_INTERFACE_(IDirectSoundFXDistortion, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXDistortion methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXDistortion pcDsFxDistortion) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXDistortion pDsFxDistortion) PURE; +}; + +#define IDirectSoundFXDistortion_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXDistortion_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXDistortion_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXDistortion_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXDistortion_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXDistortion_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXDistortion_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXCompressor +// + +DEFINE_GUID(IID_IDirectSoundFXCompressor, 0x4bbd1154, 0x62f6, 0x4e2c, 0xa1, 0x5c, 0xd3, 0xb6, 0xc4, 0x17, 0xf7, 0xa0); + +typedef struct _DSFXCompressor +{ + FLOAT fGain; + FLOAT fAttack; + FLOAT fRelease; + FLOAT fThreshold; + FLOAT fRatio; + FLOAT fPredelay; +} DSFXCompressor, *LPDSFXCompressor; + +typedef const DSFXCompressor *LPCDSFXCompressor; + +#define DSFXCOMPRESSOR_GAIN_MIN -60.0f +#define DSFXCOMPRESSOR_GAIN_MAX 60.0f +#define DSFXCOMPRESSOR_ATTACK_MIN 0.01f +#define DSFXCOMPRESSOR_ATTACK_MAX 500.0f +#define DSFXCOMPRESSOR_RELEASE_MIN 50.0f +#define DSFXCOMPRESSOR_RELEASE_MAX 3000.0f +#define DSFXCOMPRESSOR_THRESHOLD_MIN -60.0f +#define DSFXCOMPRESSOR_THRESHOLD_MAX 0.0f +#define DSFXCOMPRESSOR_RATIO_MIN 1.0f +#define DSFXCOMPRESSOR_RATIO_MAX 100.0f +#define DSFXCOMPRESSOR_PREDELAY_MIN 0.0f +#define DSFXCOMPRESSOR_PREDELAY_MAX 4.0f + +#undef INTERFACE +#define INTERFACE IDirectSoundFXCompressor + +DECLARE_INTERFACE_(IDirectSoundFXCompressor, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXCompressor methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXCompressor pcDsFxCompressor) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXCompressor pDsFxCompressor) PURE; +}; + +#define IDirectSoundFXCompressor_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXCompressor_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXCompressor_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXCompressor_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXCompressor_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXCompressor_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXCompressor_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXParamEq +// + +DEFINE_GUID(IID_IDirectSoundFXParamEq, 0xc03ca9fe, 0xfe90, 0x4204, 0x80, 0x78, 0x82, 0x33, 0x4c, 0xd1, 0x77, 0xda); + +typedef struct _DSFXParamEq +{ + FLOAT fCenter; + FLOAT fBandwidth; + FLOAT fGain; +} DSFXParamEq, *LPDSFXParamEq; + +typedef const DSFXParamEq *LPCDSFXParamEq; + +#define DSFXPARAMEQ_CENTER_MIN 80.0f +#define DSFXPARAMEQ_CENTER_MAX 16000.0f +#define DSFXPARAMEQ_BANDWIDTH_MIN 1.0f +#define DSFXPARAMEQ_BANDWIDTH_MAX 36.0f +#define DSFXPARAMEQ_GAIN_MIN -15.0f +#define DSFXPARAMEQ_GAIN_MAX 15.0f + +#undef INTERFACE +#define INTERFACE IDirectSoundFXParamEq + +DECLARE_INTERFACE_(IDirectSoundFXParamEq, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXParamEq methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXParamEq pcDsFxParamEq) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXParamEq pDsFxParamEq) PURE; +}; + +#define IDirectSoundFXParamEq_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXParamEq_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXParamEq_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXParamEq_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXParamEq_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXParamEq_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXParamEq_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXI3DL2Reverb +// + +DEFINE_GUID(IID_IDirectSoundFXI3DL2Reverb, 0x4b166a6a, 0x0d66, 0x43f3, 0x80, 0xe3, 0xee, 0x62, 0x80, 0xde, 0xe1, 0xa4); + +typedef struct _DSFXI3DL2Reverb +{ + LONG lRoom; // [-10000, 0] default: -1000 mB + LONG lRoomHF; // [-10000, 0] default: 0 mB + FLOAT flRoomRolloffFactor; // [0.0, 10.0] default: 0.0 + FLOAT flDecayTime; // [0.1, 20.0] default: 1.49s + FLOAT flDecayHFRatio; // [0.1, 2.0] default: 0.83 + LONG lReflections; // [-10000, 1000] default: -2602 mB + FLOAT flReflectionsDelay; // [0.0, 0.3] default: 0.007 s + LONG lReverb; // [-10000, 2000] default: 200 mB + FLOAT flReverbDelay; // [0.0, 0.1] default: 0.011 s + FLOAT flDiffusion; // [0.0, 100.0] default: 100.0 % + FLOAT flDensity; // [0.0, 100.0] default: 100.0 % + FLOAT flHFReference; // [20.0, 20000.0] default: 5000.0 Hz +} DSFXI3DL2Reverb, *LPDSFXI3DL2Reverb; + +typedef const DSFXI3DL2Reverb *LPCDSFXI3DL2Reverb; + +#define DSFX_I3DL2REVERB_ROOM_MIN (-10000) +#define DSFX_I3DL2REVERB_ROOM_MAX 0 +#define DSFX_I3DL2REVERB_ROOM_DEFAULT (-1000) + +#define DSFX_I3DL2REVERB_ROOMHF_MIN (-10000) +#define DSFX_I3DL2REVERB_ROOMHF_MAX 0 +#define DSFX_I3DL2REVERB_ROOMHF_DEFAULT (-100) + +#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MIN 0.0f +#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MAX 10.0f +#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_DEFAULT 0.0f + +#define DSFX_I3DL2REVERB_DECAYTIME_MIN 0.1f +#define DSFX_I3DL2REVERB_DECAYTIME_MAX 20.0f +#define DSFX_I3DL2REVERB_DECAYTIME_DEFAULT 1.49f + +#define DSFX_I3DL2REVERB_DECAYHFRATIO_MIN 0.1f +#define DSFX_I3DL2REVERB_DECAYHFRATIO_MAX 2.0f +#define DSFX_I3DL2REVERB_DECAYHFRATIO_DEFAULT 0.83f + +#define DSFX_I3DL2REVERB_REFLECTIONS_MIN (-10000) +#define DSFX_I3DL2REVERB_REFLECTIONS_MAX 1000 +#define DSFX_I3DL2REVERB_REFLECTIONS_DEFAULT (-2602) + +#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_MIN 0.0f +#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_MAX 0.3f +#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_DEFAULT 0.007f + +#define DSFX_I3DL2REVERB_REVERB_MIN (-10000) +#define DSFX_I3DL2REVERB_REVERB_MAX 2000 +#define DSFX_I3DL2REVERB_REVERB_DEFAULT (200) + +#define DSFX_I3DL2REVERB_REVERBDELAY_MIN 0.0f +#define DSFX_I3DL2REVERB_REVERBDELAY_MAX 0.1f +#define DSFX_I3DL2REVERB_REVERBDELAY_DEFAULT 0.011f + +#define DSFX_I3DL2REVERB_DIFFUSION_MIN 0.0f +#define DSFX_I3DL2REVERB_DIFFUSION_MAX 100.0f +#define DSFX_I3DL2REVERB_DIFFUSION_DEFAULT 100.0f + +#define DSFX_I3DL2REVERB_DENSITY_MIN 0.0f +#define DSFX_I3DL2REVERB_DENSITY_MAX 100.0f +#define DSFX_I3DL2REVERB_DENSITY_DEFAULT 100.0f + +#define DSFX_I3DL2REVERB_HFREFERENCE_MIN 20.0f +#define DSFX_I3DL2REVERB_HFREFERENCE_MAX 20000.0f +#define DSFX_I3DL2REVERB_HFREFERENCE_DEFAULT 5000.0f + +#define DSFX_I3DL2REVERB_QUALITY_MIN 0 +#define DSFX_I3DL2REVERB_QUALITY_MAX 3 +#define DSFX_I3DL2REVERB_QUALITY_DEFAULT 2 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXI3DL2Reverb + +DECLARE_INTERFACE_(IDirectSoundFXI3DL2Reverb, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXI3DL2Reverb methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXI3DL2Reverb pcDsFxI3DL2Reverb) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXI3DL2Reverb pDsFxI3DL2Reverb) PURE; + STDMETHOD(SetPreset) (THIS_ DWORD dwPreset) PURE; + STDMETHOD(GetPreset) (THIS_ LPDWORD pdwPreset) PURE; + STDMETHOD(SetQuality) (THIS_ LONG lQuality) PURE; + STDMETHOD(GetQuality) (THIS_ LONG *plQuality) PURE; +}; + +#define IDirectSoundFXI3DL2Reverb_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXI3DL2Reverb_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXI3DL2Reverb_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXI3DL2Reverb_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXI3DL2Reverb_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#define IDirectSoundFXI3DL2Reverb_SetPreset(p,a) (p)->lpVtbl->SetPreset(p,a) +#define IDirectSoundFXI3DL2Reverb_GetPreset(p,a) (p)->lpVtbl->GetPreset(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXI3DL2Reverb_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXI3DL2Reverb_GetAllParameters(p,a) (p)->GetAllParameters(a) +#define IDirectSoundFXI3DL2Reverb_SetPreset(p,a) (p)->SetPreset(a) +#define IDirectSoundFXI3DL2Reverb_GetPreset(p,a) (p)->GetPreset(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXWavesReverb +// + +DEFINE_GUID(IID_IDirectSoundFXWavesReverb,0x46858c3a,0x0dc6,0x45e3,0xb7,0x60,0xd4,0xee,0xf1,0x6c,0xb3,0x25); + +typedef struct _DSFXWavesReverb +{ + FLOAT fInGain; // [-96.0,0.0] default: 0.0 dB + FLOAT fReverbMix; // [-96.0,0.0] default: 0.0 db + FLOAT fReverbTime; // [0.001,3000.0] default: 1000.0 ms + FLOAT fHighFreqRTRatio; // [0.001,0.999] default: 0.001 +} DSFXWavesReverb, *LPDSFXWavesReverb; + +typedef const DSFXWavesReverb *LPCDSFXWavesReverb; + +#define DSFX_WAVESREVERB_INGAIN_MIN -96.0f +#define DSFX_WAVESREVERB_INGAIN_MAX 0.0f +#define DSFX_WAVESREVERB_INGAIN_DEFAULT 0.0f +#define DSFX_WAVESREVERB_REVERBMIX_MIN -96.0f +#define DSFX_WAVESREVERB_REVERBMIX_MAX 0.0f +#define DSFX_WAVESREVERB_REVERBMIX_DEFAULT 0.0f +#define DSFX_WAVESREVERB_REVERBTIME_MIN 0.001f +#define DSFX_WAVESREVERB_REVERBTIME_MAX 3000.0f +#define DSFX_WAVESREVERB_REVERBTIME_DEFAULT 1000.0f +#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_MIN 0.001f +#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_MAX 0.999f +#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_DEFAULT 0.001f + +#undef INTERFACE +#define INTERFACE IDirectSoundFXWavesReverb + +DECLARE_INTERFACE_(IDirectSoundFXWavesReverb, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXWavesReverb methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXWavesReverb pcDsFxWavesReverb) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXWavesReverb pDsFxWavesReverb) PURE; +}; + +#define IDirectSoundFXWavesReverb_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXWavesReverb_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXWavesReverb_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXWavesReverb_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXWavesReverb_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXWavesReverb_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXWavesReverb_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundCaptureFXAec +// + +DEFINE_GUID(IID_IDirectSoundCaptureFXAec, 0xad74143d, 0x903d, 0x4ab7, 0x80, 0x66, 0x28, 0xd3, 0x63, 0x03, 0x6d, 0x65); + +typedef struct _DSCFXAec +{ + BOOL fEnable; + BOOL fNoiseFill; + DWORD dwMode; +} DSCFXAec, *LPDSCFXAec; + +typedef const DSCFXAec *LPCDSCFXAec; + +// These match the AEC_MODE_* constants in the DDK's ksmedia.h file +#define DSCFX_AEC_MODE_PASS_THROUGH 0x0 +#define DSCFX_AEC_MODE_HALF_DUPLEX 0x1 +#define DSCFX_AEC_MODE_FULL_DUPLEX 0x2 + +// These match the AEC_STATUS_* constants in ksmedia.h +#define DSCFX_AEC_STATUS_HISTORY_UNINITIALIZED 0x0 +#define DSCFX_AEC_STATUS_HISTORY_CONTINUOUSLY_CONVERGED 0x1 +#define DSCFX_AEC_STATUS_HISTORY_PREVIOUSLY_DIVERGED 0x2 +#define DSCFX_AEC_STATUS_CURRENTLY_CONVERGED 0x8 + +#undef INTERFACE +#define INTERFACE IDirectSoundCaptureFXAec + +DECLARE_INTERFACE_(IDirectSoundCaptureFXAec, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCaptureFXAec methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSCFXAec pDscFxAec) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSCFXAec pDscFxAec) PURE; + STDMETHOD(GetStatus) (THIS_ PDWORD pdwStatus) PURE; + STDMETHOD(Reset) (THIS) PURE; +}; + +#define IDirectSoundCaptureFXAec_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCaptureFXAec_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCaptureFXAec_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureFXAec_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundCaptureFXAec_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureFXAec_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundCaptureFXAec_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + + +// +// IDirectSoundCaptureFXNoiseSuppress +// + +DEFINE_GUID(IID_IDirectSoundCaptureFXNoiseSuppress, 0xed311e41, 0xfbae, 0x4175, 0x96, 0x25, 0xcd, 0x8, 0x54, 0xf6, 0x93, 0xca); + +typedef struct _DSCFXNoiseSuppress +{ + BOOL fEnable; +} DSCFXNoiseSuppress, *LPDSCFXNoiseSuppress; + +typedef const DSCFXNoiseSuppress *LPCDSCFXNoiseSuppress; + +#undef INTERFACE +#define INTERFACE IDirectSoundCaptureFXNoiseSuppress + +DECLARE_INTERFACE_(IDirectSoundCaptureFXNoiseSuppress, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCaptureFXNoiseSuppress methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSCFXNoiseSuppress pcDscFxNoiseSuppress) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSCFXNoiseSuppress pDscFxNoiseSuppress) PURE; + STDMETHOD(Reset) (THIS) PURE; +}; + +#define IDirectSoundCaptureFXNoiseSuppress_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCaptureFXNoiseSuppress_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCaptureFXNoiseSuppress_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureFXNoiseSuppress_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundCaptureFXNoiseSuppress_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureFXNoiseSuppress_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundCaptureFXNoiseSuppress_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + + +// +// IDirectSoundFullDuplex +// + +#ifndef _IDirectSoundFullDuplex_ +#define _IDirectSoundFullDuplex_ + +#ifdef __cplusplus +// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined +struct IDirectSoundFullDuplex; +#endif // __cplusplus + +typedef struct IDirectSoundFullDuplex *LPDIRECTSOUNDFULLDUPLEX; + +DEFINE_GUID(IID_IDirectSoundFullDuplex, 0xedcb4c7a, 0xdaab, 0x4216, 0xa4, 0x2e, 0x6c, 0x50, 0x59, 0x6d, 0xdc, 0x1d); + +#undef INTERFACE +#define INTERFACE IDirectSoundFullDuplex + +DECLARE_INTERFACE_(IDirectSoundFullDuplex, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFullDuplex methods + STDMETHOD(Initialize) (THIS_ LPCGUID pCaptureGuid, LPCGUID pRenderGuid, LPCDSCBUFFERDESC lpDscBufferDesc, LPCDSBUFFERDESC lpDsBufferDesc, HWND hWnd, DWORD dwLevel, LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8, LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8) PURE; +}; + +#define IDirectSoundFullDuplex_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFullDuplex_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFullDuplex_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFullDuplex_Initialize(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->Initialize(p,a,b,c,d,e,f,g,h) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFullDuplex_Initialize(p,a,b,c,d,e,f,g,h) (p)->Initialize(a,b,c,d,e,f,g,h) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // _IDirectSoundFullDuplex_ + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// Return Codes +// + +// The function completed successfully +#define DS_OK S_OK + +// The call succeeded, but we had to substitute the 3D algorithm +#define DS_NO_VIRTUALIZATION MAKE_HRESULT(0, _FACDS, 10) + +// The call failed because resources (such as a priority level) +// were already being used by another caller +#define DSERR_ALLOCATED MAKE_DSHRESULT(10) + +// The control (vol, pan, etc.) requested by the caller is not available +#define DSERR_CONTROLUNAVAIL MAKE_DSHRESULT(30) + +// An invalid parameter was passed to the returning function +#define DSERR_INVALIDPARAM E_INVALIDARG + +// This call is not valid for the current state of this object +#define DSERR_INVALIDCALL MAKE_DSHRESULT(50) + +// An undetermined error occurred inside the DirectSound subsystem +#define DSERR_GENERIC E_FAIL + +// The caller does not have the priority level required for the function to +// succeed +#define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT(70) + +// Not enough free memory is available to complete the operation +#define DSERR_OUTOFMEMORY E_OUTOFMEMORY + +// The specified WAVE format is not supported +#define DSERR_BADFORMAT MAKE_DSHRESULT(100) + +// The function called is not supported at this time +#define DSERR_UNSUPPORTED E_NOTIMPL + +// No sound driver is available for use +#define DSERR_NODRIVER MAKE_DSHRESULT(120) + +// This object is already initialized +#define DSERR_ALREADYINITIALIZED MAKE_DSHRESULT(130) + +// This object does not support aggregation +#define DSERR_NOAGGREGATION CLASS_E_NOAGGREGATION + +// The buffer memory has been lost, and must be restored +#define DSERR_BUFFERLOST MAKE_DSHRESULT(150) + +// Another app has a higher priority level, preventing this call from +// succeeding +#define DSERR_OTHERAPPHASPRIO MAKE_DSHRESULT(160) + +// This object has not been initialized +#define DSERR_UNINITIALIZED MAKE_DSHRESULT(170) + +// The requested COM interface is not available +#define DSERR_NOINTERFACE E_NOINTERFACE + +// Access is denied +#define DSERR_ACCESSDENIED E_ACCESSDENIED + +// Tried to create a DSBCAPS_CTRLFX buffer shorter than DSBSIZE_FX_MIN milliseconds +#define DSERR_BUFFERTOOSMALL MAKE_DSHRESULT(180) + +// Attempt to use DirectSound 8 functionality on an older DirectSound object +#define DSERR_DS8_REQUIRED MAKE_DSHRESULT(190) + +// A circular loop of send effects was detected +#define DSERR_SENDLOOP MAKE_DSHRESULT(200) + +// The GUID specified in an audiopath file does not match a valid MIXIN buffer +#define DSERR_BADSENDBUFFERGUID MAKE_DSHRESULT(210) + +// The object requested was not found (numerically equal to DMUS_E_NOT_FOUND) +#define DSERR_OBJECTNOTFOUND MAKE_DSHRESULT(4449) + +// The effects requested could not be found on the system, or they were found +// but in the wrong order, or in the wrong hardware/software locations. +#define DSERR_FXUNAVAILABLE MAKE_DSHRESULT(220) + +// +// Flags +// + +#define DSCAPS_PRIMARYMONO 0x00000001 +#define DSCAPS_PRIMARYSTEREO 0x00000002 +#define DSCAPS_PRIMARY8BIT 0x00000004 +#define DSCAPS_PRIMARY16BIT 0x00000008 +#define DSCAPS_CONTINUOUSRATE 0x00000010 +#define DSCAPS_EMULDRIVER 0x00000020 +#define DSCAPS_CERTIFIED 0x00000040 +#define DSCAPS_SECONDARYMONO 0x00000100 +#define DSCAPS_SECONDARYSTEREO 0x00000200 +#define DSCAPS_SECONDARY8BIT 0x00000400 +#define DSCAPS_SECONDARY16BIT 0x00000800 + +#define DSSCL_NORMAL 0x00000001 +#define DSSCL_PRIORITY 0x00000002 +#define DSSCL_EXCLUSIVE 0x00000003 +#define DSSCL_WRITEPRIMARY 0x00000004 + +#define DSSPEAKER_DIRECTOUT 0x00000000 +#define DSSPEAKER_HEADPHONE 0x00000001 +#define DSSPEAKER_MONO 0x00000002 +#define DSSPEAKER_QUAD 0x00000003 +#define DSSPEAKER_STEREO 0x00000004 +#define DSSPEAKER_SURROUND 0x00000005 +#define DSSPEAKER_5POINT1 0x00000006 +#define DSSPEAKER_7POINT1 0x00000007 + +#define DSSPEAKER_GEOMETRY_MIN 0x00000005 // 5 degrees +#define DSSPEAKER_GEOMETRY_NARROW 0x0000000A // 10 degrees +#define DSSPEAKER_GEOMETRY_WIDE 0x00000014 // 20 degrees +#define DSSPEAKER_GEOMETRY_MAX 0x000000B4 // 180 degrees + +#define DSSPEAKER_COMBINED(c, g) ((DWORD)(((BYTE)(c)) | ((DWORD)((BYTE)(g))) << 16)) +#define DSSPEAKER_CONFIG(a) ((BYTE)(a)) +#define DSSPEAKER_GEOMETRY(a) ((BYTE)(((DWORD)(a) >> 16) & 0x00FF)) + +#define DSBCAPS_PRIMARYBUFFER 0x00000001 +#define DSBCAPS_STATIC 0x00000002 +#define DSBCAPS_LOCHARDWARE 0x00000004 +#define DSBCAPS_LOCSOFTWARE 0x00000008 +#define DSBCAPS_CTRL3D 0x00000010 +#define DSBCAPS_CTRLFREQUENCY 0x00000020 +#define DSBCAPS_CTRLPAN 0x00000040 +#define DSBCAPS_CTRLVOLUME 0x00000080 +#define DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100 +#define DSBCAPS_CTRLFX 0x00000200 +#define DSBCAPS_STICKYFOCUS 0x00004000 +#define DSBCAPS_GLOBALFOCUS 0x00008000 +#define DSBCAPS_GETCURRENTPOSITION2 0x00010000 +#define DSBCAPS_MUTE3DATMAXDISTANCE 0x00020000 +#define DSBCAPS_LOCDEFER 0x00040000 + +#define DSBPLAY_LOOPING 0x00000001 +#define DSBPLAY_LOCHARDWARE 0x00000002 +#define DSBPLAY_LOCSOFTWARE 0x00000004 +#define DSBPLAY_TERMINATEBY_TIME 0x00000008 +#define DSBPLAY_TERMINATEBY_DISTANCE 0x000000010 +#define DSBPLAY_TERMINATEBY_PRIORITY 0x000000020 + +#define DSBSTATUS_PLAYING 0x00000001 +#define DSBSTATUS_BUFFERLOST 0x00000002 +#define DSBSTATUS_LOOPING 0x00000004 +#define DSBSTATUS_LOCHARDWARE 0x00000008 +#define DSBSTATUS_LOCSOFTWARE 0x00000010 +#define DSBSTATUS_TERMINATED 0x00000020 + +#define DSBLOCK_FROMWRITECURSOR 0x00000001 +#define DSBLOCK_ENTIREBUFFER 0x00000002 + +#define DSBFREQUENCY_ORIGINAL 0 +#define DSBFREQUENCY_MIN 100 +#if DIRECTSOUND_VERSION >= 0x0900 +#define DSBFREQUENCY_MAX 200000 +#else +#define DSBFREQUENCY_MAX 100000 +#endif + +#define DSBPAN_LEFT -10000 +#define DSBPAN_CENTER 0 +#define DSBPAN_RIGHT 10000 + +#define DSBVOLUME_MIN -10000 +#define DSBVOLUME_MAX 0 + +#define DSBSIZE_MIN 4 +#define DSBSIZE_MAX 0x0FFFFFFF +#define DSBSIZE_FX_MIN 150 // NOTE: Milliseconds, not bytes + +#define DS3DMODE_NORMAL 0x00000000 +#define DS3DMODE_HEADRELATIVE 0x00000001 +#define DS3DMODE_DISABLE 0x00000002 + +#define DS3D_IMMEDIATE 0x00000000 +#define DS3D_DEFERRED 0x00000001 + +#define DS3D_MINDISTANCEFACTOR FLT_MIN +#define DS3D_MAXDISTANCEFACTOR FLT_MAX +#define DS3D_DEFAULTDISTANCEFACTOR 1.0f + +#define DS3D_MINROLLOFFFACTOR 0.0f +#define DS3D_MAXROLLOFFFACTOR 10.0f +#define DS3D_DEFAULTROLLOFFFACTOR 1.0f + +#define DS3D_MINDOPPLERFACTOR 0.0f +#define DS3D_MAXDOPPLERFACTOR 10.0f +#define DS3D_DEFAULTDOPPLERFACTOR 1.0f + +#define DS3D_DEFAULTMINDISTANCE 1.0f +#define DS3D_DEFAULTMAXDISTANCE 1000000000.0f + +#define DS3D_MINCONEANGLE 0 +#define DS3D_MAXCONEANGLE 360 +#define DS3D_DEFAULTCONEANGLE 360 + +#define DS3D_DEFAULTCONEOUTSIDEVOLUME DSBVOLUME_MAX + +// IDirectSoundCapture attributes + +#define DSCCAPS_EMULDRIVER DSCAPS_EMULDRIVER +#define DSCCAPS_CERTIFIED DSCAPS_CERTIFIED +#define DSCCAPS_MULTIPLECAPTURE 0x00000001 + +// IDirectSoundCaptureBuffer attributes + +#define DSCBCAPS_WAVEMAPPED 0x80000000 + +#if DIRECTSOUND_VERSION >= 0x0800 +#define DSCBCAPS_CTRLFX 0x00000200 +#endif + + +#define DSCBLOCK_ENTIREBUFFER 0x00000001 + +#define DSCBSTATUS_CAPTURING 0x00000001 +#define DSCBSTATUS_LOOPING 0x00000002 + +#define DSCBSTART_LOOPING 0x00000001 + +#define DSBPN_OFFSETSTOP 0xFFFFFFFF + +#define DS_CERTIFIED 0x00000000 +#define DS_UNCERTIFIED 0x00000001 + + +// +// Flags for the I3DL2 effects +// + +// +// I3DL2 Material Presets +// + +enum +{ + DSFX_I3DL2_MATERIAL_PRESET_SINGLEWINDOW, + DSFX_I3DL2_MATERIAL_PRESET_DOUBLEWINDOW, + DSFX_I3DL2_MATERIAL_PRESET_THINDOOR, + DSFX_I3DL2_MATERIAL_PRESET_THICKDOOR, + DSFX_I3DL2_MATERIAL_PRESET_WOODWALL, + DSFX_I3DL2_MATERIAL_PRESET_BRICKWALL, + DSFX_I3DL2_MATERIAL_PRESET_STONEWALL, + DSFX_I3DL2_MATERIAL_PRESET_CURTAIN +}; + +#define I3DL2_MATERIAL_PRESET_SINGLEWINDOW -2800,0.71f +#define I3DL2_MATERIAL_PRESET_DOUBLEWINDOW -5000,0.40f +#define I3DL2_MATERIAL_PRESET_THINDOOR -1800,0.66f +#define I3DL2_MATERIAL_PRESET_THICKDOOR -4400,0.64f +#define I3DL2_MATERIAL_PRESET_WOODWALL -4000,0.50f +#define I3DL2_MATERIAL_PRESET_BRICKWALL -5000,0.60f +#define I3DL2_MATERIAL_PRESET_STONEWALL -6000,0.68f +#define I3DL2_MATERIAL_PRESET_CURTAIN -1200,0.15f + +enum +{ + DSFX_I3DL2_ENVIRONMENT_PRESET_DEFAULT, + DSFX_I3DL2_ENVIRONMENT_PRESET_GENERIC, + DSFX_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL, + DSFX_I3DL2_ENVIRONMENT_PRESET_ROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_BATHROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_STONEROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM, + DSFX_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL, + DSFX_I3DL2_ENVIRONMENT_PRESET_CAVE, + DSFX_I3DL2_ENVIRONMENT_PRESET_ARENA, + DSFX_I3DL2_ENVIRONMENT_PRESET_HANGAR, + DSFX_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY, + DSFX_I3DL2_ENVIRONMENT_PRESET_HALLWAY, + DSFX_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR, + DSFX_I3DL2_ENVIRONMENT_PRESET_ALLEY, + DSFX_I3DL2_ENVIRONMENT_PRESET_FOREST, + DSFX_I3DL2_ENVIRONMENT_PRESET_CITY, + DSFX_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS, + DSFX_I3DL2_ENVIRONMENT_PRESET_QUARRY, + DSFX_I3DL2_ENVIRONMENT_PRESET_PLAIN, + DSFX_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT, + DSFX_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE, + DSFX_I3DL2_ENVIRONMENT_PRESET_UNDERWATER, + DSFX_I3DL2_ENVIRONMENT_PRESET_SMALLROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL, + DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEHALL, + DSFX_I3DL2_ENVIRONMENT_PRESET_PLATE +}; + +// +// I3DL2 Reverberation Presets Values +// + +#define I3DL2_ENVIRONMENT_PRESET_DEFAULT -1000, -100, 0.0f, 1.49f, 0.83f, -2602, 0.007f, 200, 0.011f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_GENERIC -1000, -100, 0.0f, 1.49f, 0.83f, -2602, 0.007f, 200, 0.011f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_PADDEDCELL -1000,-6000, 0.0f, 0.17f, 0.10f, -1204, 0.001f, 207, 0.002f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_ROOM -1000, -454, 0.0f, 0.40f, 0.83f, -1646, 0.002f, 53, 0.003f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_BATHROOM -1000,-1200, 0.0f, 1.49f, 0.54f, -370, 0.007f, 1030, 0.011f, 100.0f, 60.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_LIVINGROOM -1000,-6000, 0.0f, 0.50f, 0.10f, -1376, 0.003f, -1104, 0.004f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_STONEROOM -1000, -300, 0.0f, 2.31f, 0.64f, -711, 0.012f, 83, 0.017f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_AUDITORIUM -1000, -476, 0.0f, 4.32f, 0.59f, -789, 0.020f, -289, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_CONCERTHALL -1000, -500, 0.0f, 3.92f, 0.70f, -1230, 0.020f, -2, 0.029f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_CAVE -1000, 0, 0.0f, 2.91f, 1.30f, -602, 0.015f, -302, 0.022f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_ARENA -1000, -698, 0.0f, 7.24f, 0.33f, -1166, 0.020f, 16, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_HANGAR -1000,-1000, 0.0f,10.05f, 0.23f, -602, 0.020f, 198, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY -1000,-4000, 0.0f, 0.30f, 0.10f, -1831, 0.002f, -1630, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_HALLWAY -1000, -300, 0.0f, 1.49f, 0.59f, -1219, 0.007f, 441, 0.011f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR -1000, -237, 0.0f, 2.70f, 0.79f, -1214, 0.013f, 395, 0.020f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_ALLEY -1000, -270, 0.0f, 1.49f, 0.86f, -1204, 0.007f, -4, 0.011f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_FOREST -1000,-3300, 0.0f, 1.49f, 0.54f, -2560, 0.162f, -613, 0.088f, 79.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_CITY -1000, -800, 0.0f, 1.49f, 0.67f, -2273, 0.007f, -2217, 0.011f, 50.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_MOUNTAINS -1000,-2500, 0.0f, 1.49f, 0.21f, -2780, 0.300f, -2014, 0.100f, 27.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_QUARRY -1000,-1000, 0.0f, 1.49f, 0.83f,-10000, 0.061f, 500, 0.025f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_PLAIN -1000,-2000, 0.0f, 1.49f, 0.50f, -2466, 0.179f, -2514, 0.100f, 21.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_PARKINGLOT -1000, 0, 0.0f, 1.65f, 1.50f, -1363, 0.008f, -1153, 0.012f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_SEWERPIPE -1000,-1000, 0.0f, 2.81f, 0.14f, 429, 0.014f, 648, 0.021f, 80.0f, 60.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_UNDERWATER -1000,-4000, 0.0f, 1.49f, 0.10f, -449, 0.007f, 1700, 0.011f, 100.0f, 100.0f, 5000.0f + +// +// Examples simulating 'musical' reverb presets +// +// Name Decay time Description +// Small Room 1.1s A small size room with a length of 5m or so. +// Medium Room 1.3s A medium size room with a length of 10m or so. +// Large Room 1.5s A large size room suitable for live performances. +// Medium Hall 1.8s A medium size concert hall. +// Large Hall 1.8s A large size concert hall suitable for a full orchestra. +// Plate 1.3s A plate reverb simulation. +// + +#define I3DL2_ENVIRONMENT_PRESET_SMALLROOM -1000, -600, 0.0f, 1.10f, 0.83f, -400, 0.005f, 500, 0.010f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM -1000, -600, 0.0f, 1.30f, 0.83f, -1000, 0.010f, -200, 0.020f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_LARGEROOM -1000, -600, 0.0f, 1.50f, 0.83f, -1600, 0.020f, -1000, 0.040f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL -1000, -600, 0.0f, 1.80f, 0.70f, -1300, 0.015f, -800, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_LARGEHALL -1000, -600, 0.0f, 1.80f, 0.70f, -2000, 0.030f, -1400, 0.060f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_PLATE -1000, -200, 0.0f, 1.30f, 0.90f, 0, 0.002f, 0, 0.010f, 100.0f, 75.0f, 5000.0f + +// +// DirectSound3D Algorithms +// + +// Default DirectSound3D algorithm {00000000-0000-0000-0000-000000000000} +#define DS3DALG_DEFAULT GUID_NULL + +// No virtualization (Pan3D) {C241333F-1C1B-11d2-94F5-00C04FC28ACA} +DEFINE_GUID(DS3DALG_NO_VIRTUALIZATION, 0xc241333f, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); + +// High-quality HRTF algorithm {C2413340-1C1B-11d2-94F5-00C04FC28ACA} +DEFINE_GUID(DS3DALG_HRTF_FULL, 0xc2413340, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); + +// Lower-quality HRTF algorithm {C2413342-1C1B-11d2-94F5-00C04FC28ACA} +DEFINE_GUID(DS3DALG_HRTF_LIGHT, 0xc2413342, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); + + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// DirectSound Internal Effect Algorithms +// + + +// Gargle {DAFD8210-5711-4B91-9FE3-F75B7AE279BF} +DEFINE_GUID(GUID_DSFX_STANDARD_GARGLE, 0xdafd8210, 0x5711, 0x4b91, 0x9f, 0xe3, 0xf7, 0x5b, 0x7a, 0xe2, 0x79, 0xbf); + +// Chorus {EFE6629C-81F7-4281-BD91-C9D604A95AF6} +DEFINE_GUID(GUID_DSFX_STANDARD_CHORUS, 0xefe6629c, 0x81f7, 0x4281, 0xbd, 0x91, 0xc9, 0xd6, 0x04, 0xa9, 0x5a, 0xf6); + +// Flanger {EFCA3D92-DFD8-4672-A603-7420894BAD98} +DEFINE_GUID(GUID_DSFX_STANDARD_FLANGER, 0xefca3d92, 0xdfd8, 0x4672, 0xa6, 0x03, 0x74, 0x20, 0x89, 0x4b, 0xad, 0x98); + +// Echo/Delay {EF3E932C-D40B-4F51-8CCF-3F98F1B29D5D} +DEFINE_GUID(GUID_DSFX_STANDARD_ECHO, 0xef3e932c, 0xd40b, 0x4f51, 0x8c, 0xcf, 0x3f, 0x98, 0xf1, 0xb2, 0x9d, 0x5d); + +// Distortion {EF114C90-CD1D-484E-96E5-09CFAF912A21} +DEFINE_GUID(GUID_DSFX_STANDARD_DISTORTION, 0xef114c90, 0xcd1d, 0x484e, 0x96, 0xe5, 0x09, 0xcf, 0xaf, 0x91, 0x2a, 0x21); + +// Compressor/Limiter {EF011F79-4000-406D-87AF-BFFB3FC39D57} +DEFINE_GUID(GUID_DSFX_STANDARD_COMPRESSOR, 0xef011f79, 0x4000, 0x406d, 0x87, 0xaf, 0xbf, 0xfb, 0x3f, 0xc3, 0x9d, 0x57); + +// Parametric Equalization {120CED89-3BF4-4173-A132-3CB406CF3231} +DEFINE_GUID(GUID_DSFX_STANDARD_PARAMEQ, 0x120ced89, 0x3bf4, 0x4173, 0xa1, 0x32, 0x3c, 0xb4, 0x06, 0xcf, 0x32, 0x31); + +// I3DL2 Environmental Reverberation: Reverb (Listener) Effect {EF985E71-D5C7-42D4-BA4D-2D073E2E96F4} +DEFINE_GUID(GUID_DSFX_STANDARD_I3DL2REVERB, 0xef985e71, 0xd5c7, 0x42d4, 0xba, 0x4d, 0x2d, 0x07, 0x3e, 0x2e, 0x96, 0xf4); + +// Waves Reverberation {87FC0268-9A55-4360-95AA-004A1D9DE26C} +DEFINE_GUID(GUID_DSFX_WAVES_REVERB, 0x87fc0268, 0x9a55, 0x4360, 0x95, 0xaa, 0x00, 0x4a, 0x1d, 0x9d, 0xe2, 0x6c); + +// +// DirectSound Capture Effect Algorithms +// + + +// Acoustic Echo Canceller {BF963D80-C559-11D0-8A2B-00A0C9255AC1} +// Matches KSNODETYPE_ACOUSTIC_ECHO_CANCEL in ksmedia.h +DEFINE_GUID(GUID_DSCFX_CLASS_AEC, 0xBF963D80L, 0xC559, 0x11D0, 0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1); + +// Microsoft AEC {CDEBB919-379A-488a-8765-F53CFD36DE40} +DEFINE_GUID(GUID_DSCFX_MS_AEC, 0xcdebb919, 0x379a, 0x488a, 0x87, 0x65, 0xf5, 0x3c, 0xfd, 0x36, 0xde, 0x40); + +// System AEC {1C22C56D-9879-4f5b-A389-27996DDC2810} +DEFINE_GUID(GUID_DSCFX_SYSTEM_AEC, 0x1c22c56d, 0x9879, 0x4f5b, 0xa3, 0x89, 0x27, 0x99, 0x6d, 0xdc, 0x28, 0x10); + +// Noise Supression {E07F903F-62FD-4e60-8CDD-DEA7236665B5} +// Matches KSNODETYPE_NOISE_SUPPRESS in post Windows ME DDK's ksmedia.h +DEFINE_GUID(GUID_DSCFX_CLASS_NS, 0xe07f903f, 0x62fd, 0x4e60, 0x8c, 0xdd, 0xde, 0xa7, 0x23, 0x66, 0x65, 0xb5); + +// Microsoft Noise Suppresion {11C5C73B-66E9-4ba1-A0BA-E814C6EED92D} +DEFINE_GUID(GUID_DSCFX_MS_NS, 0x11c5c73b, 0x66e9, 0x4ba1, 0xa0, 0xba, 0xe8, 0x14, 0xc6, 0xee, 0xd9, 0x2d); + +// System Noise Suppresion {5AB0882E-7274-4516-877D-4EEE99BA4FD0} +DEFINE_GUID(GUID_DSCFX_SYSTEM_NS, 0x5ab0882e, 0x7274, 0x4516, 0x87, 0x7d, 0x4e, 0xee, 0x99, 0xba, 0x4f, 0xd0); + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +#endif // __DSOUND_INCLUDED__ + + + +#ifdef __cplusplus +}; +#endif // __cplusplus + + diff --git a/src/dep/include/DXSDK/include/dvoice.h b/src/dep/include/DXSDK/include/dvoice.h index 7b4fd18..000ac51 100644 --- a/src/dep/include/DXSDK/include/dvoice.h +++ b/src/dep/include/DXSDK/include/dvoice.h @@ -1,857 +1,857 @@ -/*==========================================================================; - * - * Copyright (C) 1999 Microsoft Corporation. All Rights Reserved. - * - * File: dpvoice.h - * Content: DirectPlayVoice include file - ***************************************************************************/ - -#ifndef __DVOICE__ -#define __DVOICE__ - -#include // for DECLARE_INTERFACE and HRESULT -#include -#include -#include -#include "dsound.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/**************************************************************************** - * - * DirectPlayVoice CLSIDs - * - ****************************************************************************/ - - -// {B9F3EB85-B781-4ac1-8D90-93A05EE37D7D} -DEFINE_GUID(CLSID_DirectPlayVoiceClient, -0xb9f3eb85, 0xb781, 0x4ac1, 0x8d, 0x90, 0x93, 0xa0, 0x5e, 0xe3, 0x7d, 0x7d); - -// {D3F5B8E6-9B78-4a4c-94EA-CA2397B663D3} -DEFINE_GUID(CLSID_DirectPlayVoiceServer, -0xd3f5b8e6, 0x9b78, 0x4a4c, 0x94, 0xea, 0xca, 0x23, 0x97, 0xb6, 0x63, 0xd3); - -// {0F0F094B-B01C-4091-A14D-DD0CD807711A} -DEFINE_GUID(CLSID_DirectPlayVoiceTest, -0xf0f094b, 0xb01c, 0x4091, 0xa1, 0x4d, 0xdd, 0xc, 0xd8, 0x7, 0x71, 0x1a); - -/**************************************************************************** - * - * DirectPlayVoice Interface IIDs - * - ****************************************************************************/ - - -// {1DFDC8EA-BCF7-41d6-B295-AB64B3B23306} -DEFINE_GUID(IID_IDirectPlayVoiceClient, -0x1dfdc8ea, 0xbcf7, 0x41d6, 0xb2, 0x95, 0xab, 0x64, 0xb3, 0xb2, 0x33, 0x6); - -// {FAA1C173-0468-43b6-8A2A-EA8A4F2076C9} -DEFINE_GUID(IID_IDirectPlayVoiceServer, -0xfaa1c173, 0x468, 0x43b6, 0x8a, 0x2a, 0xea, 0x8a, 0x4f, 0x20, 0x76, 0xc9); - -// {D26AF734-208B-41da-8224-E0CE79810BE1} -DEFINE_GUID(IID_IDirectPlayVoiceTest, -0xd26af734, 0x208b, 0x41da, 0x82, 0x24, 0xe0, 0xce, 0x79, 0x81, 0xb, 0xe1); - -/**************************************************************************** - * - * DirectPlayVoice Compression Type GUIDs - * - ****************************************************************************/ - -// MS-ADPCM 32.8 kbit/s -// -// {699B52C1-A885-46a8-A308-97172419ADC7} -DEFINE_GUID(DPVCTGUID_ADPCM, -0x699b52c1, 0xa885, 0x46a8, 0xa3, 0x8, 0x97, 0x17, 0x24, 0x19, 0xad, 0xc7); - -// Microsoft GSM 6.10 13 kbit/s -// -// {24768C60-5A0D-11d3-9BE4-525400D985E7} -DEFINE_GUID(DPVCTGUID_GSM, -0x24768c60, 0x5a0d, 0x11d3, 0x9b, 0xe4, 0x52, 0x54, 0x0, 0xd9, 0x85, 0xe7); - -// MS-PCM 64 kbit/s -// -// {8DE12FD4-7CB3-48ce-A7E8-9C47A22E8AC5} -DEFINE_GUID(DPVCTGUID_NONE, -0x8de12fd4, 0x7cb3, 0x48ce, 0xa7, 0xe8, 0x9c, 0x47, 0xa2, 0x2e, 0x8a, 0xc5); - -// Voxware SC03 3.2kbit/s -// -// {7D82A29B-2242-4f82-8F39-5D1153DF3E41} -DEFINE_GUID(DPVCTGUID_SC03, -0x7d82a29b, 0x2242, 0x4f82, 0x8f, 0x39, 0x5d, 0x11, 0x53, 0xdf, 0x3e, 0x41); - -// Voxware SC06 6.4kbit/s -// -// {53DEF900-7168-4633-B47F-D143916A13C7} -DEFINE_GUID(DPVCTGUID_SC06, -0x53def900, 0x7168, 0x4633, 0xb4, 0x7f, 0xd1, 0x43, 0x91, 0x6a, 0x13, 0xc7); - -// TrueSpeech(TM) 8.6 kbit/s -// -// {D7954361-5A0B-11d3-9BE4-525400D985E7} -DEFINE_GUID(DPVCTGUID_TRUESPEECH, -0xd7954361, 0x5a0b, 0x11d3, 0x9b, 0xe4, 0x52, 0x54, 0x0, 0xd9, 0x85, 0xe7); - -// Voxware VR12 1.4kbit/s -// -// {FE44A9FE-8ED4-48bf-9D66-1B1ADFF9FF6D} -DEFINE_GUID(DPVCTGUID_VR12, -0xfe44a9fe, 0x8ed4, 0x48bf, 0x9d, 0x66, 0x1b, 0x1a, 0xdf, 0xf9, 0xff, 0x6d); - -// Define the default compression type -#define DPVCTGUID_DEFAULT DPVCTGUID_SC03 - -/**************************************************************************** - * - * DirectPlayVoice Interface Pointer definitions - * - ****************************************************************************/ - -typedef struct IDirectPlayVoiceClient FAR *LPDIRECTPLAYVOICECLIENT, *PDIRECTPLAYVOICECLIENT; -typedef struct IDirectPlayVoiceServer FAR *LPDIRECTPLAYVOICESERVER, *PDIRECTPLAYVOICESERVER; -typedef struct IDirectPlayVoiceTest FAR *LPDIRECTPLAYVOICETEST, *PDIRECTPLAYVOICETEST; - -/**************************************************************************** - * - * DirectPlayVoice Callback Functions - * - ****************************************************************************/ -typedef HRESULT (FAR PASCAL *PDVMESSAGEHANDLER)( - PVOID pvUserContext, - DWORD dwMessageType, - LPVOID lpMessage -); - -typedef PDVMESSAGEHANDLER LPDVMESSAGEHANDLER; - -/**************************************************************************** - * - * DirectPlayVoice Datatypes (Non-Structure / Non-Message) - * - ****************************************************************************/ - -typedef DWORD DVID, *LPDVID, *PDVID; - -/**************************************************************************** - * - * DirectPlayVoice Message Types - * - ****************************************************************************/ - -#define DVMSGID_BASE 0x0000 - -#define DVMSGID_MINBASE (DVMSGID_CREATEVOICEPLAYER) -#define DVMSGID_CREATEVOICEPLAYER (DVMSGID_BASE+0x0001) -#define DVMSGID_DELETEVOICEPLAYER (DVMSGID_BASE+0x0002) -#define DVMSGID_SESSIONLOST (DVMSGID_BASE+0x0003) -#define DVMSGID_PLAYERVOICESTART (DVMSGID_BASE+0x0004) -#define DVMSGID_PLAYERVOICESTOP (DVMSGID_BASE+0x0005) -#define DVMSGID_RECORDSTART (DVMSGID_BASE+0x0006) -#define DVMSGID_RECORDSTOP (DVMSGID_BASE+0x0007) -#define DVMSGID_CONNECTRESULT (DVMSGID_BASE+0x0008) -#define DVMSGID_DISCONNECTRESULT (DVMSGID_BASE+0x0009) -#define DVMSGID_INPUTLEVEL (DVMSGID_BASE+0x000A) -#define DVMSGID_OUTPUTLEVEL (DVMSGID_BASE+0x000B) -#define DVMSGID_HOSTMIGRATED (DVMSGID_BASE+0x000C) -#define DVMSGID_SETTARGETS (DVMSGID_BASE+0x000D) -#define DVMSGID_PLAYEROUTPUTLEVEL (DVMSGID_BASE+0x000E) -#define DVMSGID_LOSTFOCUS (DVMSGID_BASE+0x0010) -#define DVMSGID_GAINFOCUS (DVMSGID_BASE+0x0011) -#define DVMSGID_LOCALHOSTSETUP (DVMSGID_BASE+0x0012) -#define DVMSGID_MAXBASE (DVMSGID_LOCALHOSTSETUP) - -/**************************************************************************** - * - * DirectPlayVoice Constants - * - ****************************************************************************/ - -// -// Buffer Aggresiveness Value Ranges -// -#define DVBUFFERAGGRESSIVENESS_MIN 0x00000001 -#define DVBUFFERAGGRESSIVENESS_MAX 0x00000064 -#define DVBUFFERAGGRESSIVENESS_DEFAULT 0x00000000 - -// -// Buffer Quality Value Ranges -// -#define DVBUFFERQUALITY_MIN 0x00000001 -#define DVBUFFERQUALITY_MAX 0x00000064 -#define DVBUFFERQUALITY_DEFAULT 0x00000000 - -#define DVID_SYS 0 - -// -// Used to identify the session host in client/server -// -#define DVID_SERVERPLAYER 1 - -// -// Used to target all players -// -#define DVID_ALLPLAYERS 0 - -// -// Used to identify the main buffer -// -#define DVID_REMAINING 0xFFFFFFFF - -// -// Input level range -// -#define DVINPUTLEVEL_MIN 0x00000000 -#define DVINPUTLEVEL_MAX 0x00000063 // 99 decimal - -#define DVNOTIFYPERIOD_MINPERIOD 20 - - -#define DVPLAYBACKVOLUME_DEFAULT DSBVOLUME_MAX - -#define DVRECORDVOLUME_LAST 0x00000001 - - -// -// Use the default value -// -#define DVTHRESHOLD_DEFAULT 0xFFFFFFFF - -// -// Threshold Ranges -// -#define DVTHRESHOLD_MIN 0x00000000 -#define DVTHRESHOLD_MAX 0x00000063 // 99 decimal - -// -// Threshold field is not used -// -#define DVTHRESHOLD_UNUSED 0xFFFFFFFE - -// -// Session Types -// -#define DVSESSIONTYPE_PEER 0x00000001 -#define DVSESSIONTYPE_MIXING 0x00000002 -#define DVSESSIONTYPE_FORWARDING 0x00000003 -#define DVSESSIONTYPE_ECHO 0x00000004 - -/**************************************************************************** - * - * DirectPlayVoice Flags - * - ****************************************************************************/ - - -// -// Enable automatic adjustment of the recording volume -// -#define DVCLIENTCONFIG_AUTORECORDVOLUME 0x00000008 - -// -// Enable automatic voice activation -// -#define DVCLIENTCONFIG_AUTOVOICEACTIVATED 0x00000020 - -// -// Enable echo suppression -// -#define DVCLIENTCONFIG_ECHOSUPPRESSION 0x08000000 - -// -// Voice Activation manual mode -// -#define DVCLIENTCONFIG_MANUALVOICEACTIVATED 0x00000004 - -// -// Only playback voices that have buffers created for them -// -#define DVCLIENTCONFIG_MUTEGLOBAL 0x00000010 - -// -// Mute the playback -// -#define DVCLIENTCONFIG_PLAYBACKMUTE 0x00000002 - -// -// Mute the recording -// -#define DVCLIENTCONFIG_RECORDMUTE 0x00000001 - -// -// Complete the operation before returning -// -#define DVFLAGS_SYNC 0x00000001 - -// -// Just check to see if wizard has been run, and if so what it's results were -// -#define DVFLAGS_QUERYONLY 0x00000002 - -// -// Shutdown the voice session without migrating the host -// -#define DVFLAGS_NOHOSTMIGRATE 0x00000008 - -// -// Allow the back button to be enabled in the wizard -// -#define DVFLAGS_ALLOWBACK 0x00000010 - -// -// Disable host migration in the voice session -// -#define DVSESSION_NOHOSTMIGRATION 0x00000001 - -// -// Server controlled targetting -// -#define DVSESSION_SERVERCONTROLTARGET 0x00000002 - -// -// Use DirectSound Normal Mode instead of priority -// -#define DVSOUNDCONFIG_NORMALMODE 0x00000001 - -// -// Automatically select the microphone -// -#define DVSOUNDCONFIG_AUTOSELECT 0x00000002 - -// -// Run in half duplex mode -// -#define DVSOUNDCONFIG_HALFDUPLEX 0x00000004 - -// -// No volume controls are available for the recording device -// -#define DVSOUNDCONFIG_NORECVOLAVAILABLE 0x00000010 - -// -// Disable capture sharing -// -#define DVSOUNDCONFIG_NOFOCUS 0x20000000 - -// -// Set system conversion quality to high -// -#define DVSOUNDCONFIG_SETCONVERSIONQUALITY 0x00000008 - -// -// Enable strict focus mode -// -#define DVSOUNDCONFIG_STRICTFOCUS 0x40000000 - -// -// Player is in half duplex mode -// -#define DVPLAYERCAPS_HALFDUPLEX 0x00000001 - -// -// Specifies that player is the local player -// -#define DVPLAYERCAPS_LOCAL 0x00000002 - -/**************************************************************************** - * - * DirectPlayVoice Structures (Non-Message) - * - ****************************************************************************/ - - -// -// DirectPlayVoice Caps -// (GetCaps / SetCaps) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DWORD dwFlags; // Caps flags -} DVCAPS, *LPDVCAPS, *PDVCAPS; - -// -// DirectPlayVoice Client Configuration -// (Connect / GetClientConfig) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DWORD dwFlags; // Flags for client config (DVCLIENTCONFIG_...) - LONG lRecordVolume; // Recording volume - LONG lPlaybackVolume; // Playback volume - DWORD dwThreshold; // Voice Activation Threshold - DWORD dwBufferQuality; // Buffer quality - DWORD dwBufferAggressiveness; // Buffer aggressiveness - DWORD dwNotifyPeriod; // Period of notification messages (ms) -} DVCLIENTCONFIG, *LPDVCLIENTCONFIG, *PDVCLIENTCONFIG; - -// -// DirectPlayVoice Compression Type Information -// (GetCompressionTypes) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - GUID guidType; // GUID that identifies this compression type - LPWSTR lpszName; // String name of this compression type - LPWSTR lpszDescription; // Description for this compression type - DWORD dwFlags; // Flags for this compression type - DWORD dwMaxBitsPerSecond; // Maximum # of bit/s this compression type uses -} DVCOMPRESSIONINFO, *LPDVCOMPRESSIONINFO, *PDVCOMPRESSIONINFO; - -// -// DirectPlayVoice Session Description -// (Host / GetSessionDesc) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DWORD dwFlags; // Session flags (DVSESSION_...) - DWORD dwSessionType; // Session type (DVSESSIONTYPE_...) - GUID guidCT; // Compression Type to use - DWORD dwBufferQuality; // Buffer quality - DWORD dwBufferAggressiveness; // Buffer aggresiveness -} DVSESSIONDESC, *LPDVSESSIONDESC, *PDVSESSIONDESC; - -// -// DirectPlayVoice Client Sound Device Configuration -// (Connect / GetSoundDeviceConfig) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DWORD dwFlags; // Flags for sound config (DVSOUNDCONFIG_...) - GUID guidPlaybackDevice; // GUID of the playback device to use - LPDIRECTSOUND lpdsPlaybackDevice; // DirectSound Object to use (optional) - GUID guidCaptureDevice; // GUID of the capture device to use - LPDIRECTSOUNDCAPTURE lpdsCaptureDevice; // DirectSoundCapture Object to use (optional) - HWND hwndAppWindow; // HWND of your application's top-level window - LPDIRECTSOUNDBUFFER lpdsMainBuffer; // DirectSoundBuffer to use for playback (optional) - DWORD dwMainBufferFlags; // Flags to pass to Play() on the main buffer - DWORD dwMainBufferPriority; // Priority to set when calling Play() on the main buffer -} DVSOUNDDEVICECONFIG, *LPDVSOUNDDEVICECONFIG, *PDVSOUNDDEVICECONFIG; - -/**************************************************************************** - * - * DirectPlayVoice message handler call back structures - * - ****************************************************************************/ - -// -// Result of the Connect() call. (If it wasn't called Async) -// (DVMSGID_CONNECTRESULT) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - HRESULT hrResult; // Result of the Connect() call -} DVMSG_CONNECTRESULT, *LPDVMSG_CONNECTRESULT, *PDVMSG_CONNECTRESULT; - -// -// A new player has entered the voice session -// (DVMSGID_CREATEVOICEPLAYER) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DVID dvidPlayer; // DVID of the player who joined - DWORD dwFlags; // Player flags (DVPLAYERCAPS_...) - PVOID pvPlayerContext; // Context value for this player (user set) -} DVMSG_CREATEVOICEPLAYER, *LPDVMSG_CREATEVOICEPLAYER, *PDVMSG_CREATEVOICEPLAYER; - -// -// A player has left the voice session -// (DVMSGID_DELETEVOICEPLAYER) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DVID dvidPlayer; // DVID of the player who left - PVOID pvPlayerContext; // Context value for the player -} DVMSG_DELETEVOICEPLAYER, *LPDVMSG_DELETEVOICEPLAYER, *PDVMSG_DELETEVOICEPLAYER; - -// -// Result of the Disconnect() call. (If it wasn't called Async) -// (DVMSGID_DISCONNECTRESULT) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - HRESULT hrResult; // Result of the Disconnect() call -} DVMSG_DISCONNECTRESULT, *LPDVMSG_DISCONNECTRESULT, *PDVMSG_DISCONNECTRESULT; - -// -// The voice session host has migrated. -// (DVMSGID_HOSTMIGRATED) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DVID dvidNewHostID; // DVID of the player who is now the host - LPDIRECTPLAYVOICESERVER pdvServerInterface; - // Pointer to the new host object (if local player is now host) -} DVMSG_HOSTMIGRATED, *LPDVMSG_HOSTMIGRATED, *PDVMSG_HOSTMIGRATED; - -// -// The current input level / recording volume on the local machine -// (DVMSGID_INPUTLEVEL) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DWORD dwPeakLevel; // Current peak level of the audio - LONG lRecordVolume; // Current recording volume - PVOID pvLocalPlayerContext; // Context value for the local player -} DVMSG_INPUTLEVEL, *LPDVMSG_INPUTLEVEL, *PDVMSG_INPUTLEVEL; - -// -// The local client is about to become the new host -// (DVMSGID_LOCALHOSTSETUP) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - PVOID pvContext; // Context value to be passed to Initialize() of new host object - PDVMESSAGEHANDLER pMessageHandler; // Message handler to be used by new host object -} DVMSG_LOCALHOSTSETUP, *LPDVMSG_LOCALHOSTSETUP, *PDVMSG_LOCALHOSTSETUP; - -// -// The current output level for the combined output of all incoming streams. -// (DVMSGID_OUTPUTLEVEL) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DWORD dwPeakLevel; // Current peak level of the output - LONG lOutputVolume; // Current playback volume - PVOID pvLocalPlayerContext; // Context value for the local player -} DVMSG_OUTPUTLEVEL, *LPDVMSG_OUTPUTLEVEL, *PDVMSG_OUTPUTLEVEL; - -// -// The current peak level of an individual player's incoming audio stream as it is -// being played back. -// (DVMSGID_PLAYEROUTPUTLEVEL) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DVID dvidSourcePlayerID; // DVID of the player - DWORD dwPeakLevel; // Peak level of the player's stream - PVOID pvPlayerContext; // Context value for the player -} DVMSG_PLAYEROUTPUTLEVEL, *LPDVMSG_PLAYEROUTPUTLEVEL, *PDVMSG_PLAYEROUTPUTLEVEL; - -// -// An audio stream from the specified player has started playing back on the local client. -// (DVMSGID_PLAYERVOICESTART). -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DVID dvidSourcePlayerID; // DVID of the Player - PVOID pvPlayerContext; // Context value for this player -} DVMSG_PLAYERVOICESTART, *LPDVMSG_PLAYERVOICESTART, *PDVMSG_PLAYERVOICESTART; - -// -// The audio stream from the specified player has stopped playing back on the local client. -// (DVMSGID_PLAYERVOICESTOP) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DVID dvidSourcePlayerID; // DVID of the player - PVOID pvPlayerContext; // Context value for this player -} DVMSG_PLAYERVOICESTOP, *LPDVMSG_PLAYERVOICESTOP, *PDVMSG_PLAYERVOICESTOP; - -// -// Transmission has started on the local machine -// (DVMSGID_RECORDSTART) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DWORD dwPeakLevel; // Peak level that caused transmission to start - PVOID pvLocalPlayerContext; // Context value for the local player -} DVMSG_RECORDSTART, *LPDVMSG_RECORDSTART, *PDVMSG_RECORDSTART; - -// -// Transmission has stopped on the local machine -// (DVMSGID_RECORDSTOP) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DWORD dwPeakLevel; // Peak level that caused transmission to stop - PVOID pvLocalPlayerContext; // Context value for the local player -} DVMSG_RECORDSTOP, *LPDVMSG_RECORDSTOP, *PDVMSG_RECORDSTOP; - -// -// The voice session has been lost -// (DVMSGID_SESSIONLOST) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - HRESULT hrResult; // Reason the session was disconnected -} DVMSG_SESSIONLOST, *LPDVMSG_SESSIONLOST, *PDVMSG_SESSIONLOST; - -// -// The target list has been updated for the local client -// (DVMSGID_SETTARGETS) -// -typedef struct -{ - DWORD dwSize; // Size of this structure - DWORD dwNumTargets; // # of targets - PDVID pdvidTargets; // An array of DVIDs specifying the current targets -} DVMSG_SETTARGETS, *LPDVMSG_SETTARGETS, *PDVMSG_SETTARGETS; - - -/**************************************************************************** - * - * DirectPlayVoice Functions - * - ****************************************************************************/ - -/* - * - * This function is no longer supported. It is recommended that CoCreateInstance be used to create - * DirectPlay voice objects. - * - * extern HRESULT WINAPI DirectPlayVoiceCreate( const GUID * pcIID, void **ppvInterface, IUnknown *pUnknown); - * - */ - -/**************************************************************************** - * - * DirectPlay8 Application Interfaces - * - ****************************************************************************/ - -#undef INTERFACE -#define INTERFACE IDirectPlayVoiceClient -DECLARE_INTERFACE_( IDirectPlayVoiceClient, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, PVOID *ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectPlayVoiceClient methods ***/ - STDMETHOD_(HRESULT, Initialize) (THIS_ LPUNKNOWN, PDVMESSAGEHANDLER, PVOID, PDWORD, DWORD ) PURE; - STDMETHOD_(HRESULT, Connect) (THIS_ PDVSOUNDDEVICECONFIG, PDVCLIENTCONFIG, DWORD ) PURE; - STDMETHOD_(HRESULT, Disconnect) (THIS_ DWORD ) PURE; - STDMETHOD_(HRESULT, GetSessionDesc)(THIS_ PDVSESSIONDESC ) PURE; - STDMETHOD_(HRESULT, GetClientConfig)(THIS_ PDVCLIENTCONFIG ) PURE; - STDMETHOD_(HRESULT, SetClientConfig)(THIS_ PDVCLIENTCONFIG ) PURE; - STDMETHOD_(HRESULT, GetCaps) (THIS_ PDVCAPS ) PURE; - STDMETHOD_(HRESULT, GetCompressionTypes)( THIS_ PVOID, PDWORD, PDWORD, DWORD ) PURE; - STDMETHOD_(HRESULT, SetTransmitTargets)( THIS_ PDVID, DWORD, DWORD ) PURE; - STDMETHOD_(HRESULT, GetTransmitTargets)( THIS_ PDVID, PDWORD, DWORD ) PURE; - STDMETHOD_(HRESULT, Create3DSoundBuffer)( THIS_ DVID, LPDIRECTSOUNDBUFFER, DWORD, DWORD, LPDIRECTSOUND3DBUFFER * ) PURE; - STDMETHOD_(HRESULT, Delete3DSoundBuffer)( THIS_ DVID, LPDIRECTSOUND3DBUFFER * ) PURE; - STDMETHOD_(HRESULT, SetNotifyMask)( THIS_ PDWORD, DWORD ) PURE; - STDMETHOD_(HRESULT, GetSoundDeviceConfig)( THIS_ PDVSOUNDDEVICECONFIG, PDWORD ) PURE; -}; - - -#undef INTERFACE -#define INTERFACE IDirectPlayVoiceServer -DECLARE_INTERFACE_( IDirectPlayVoiceServer, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectPlayVoiceServer methods ***/ - STDMETHOD_(HRESULT, Initialize) (THIS_ LPUNKNOWN, PDVMESSAGEHANDLER, PVOID, LPDWORD, DWORD ) PURE; - STDMETHOD_(HRESULT, StartSession) (THIS_ PDVSESSIONDESC, DWORD ) PURE; - STDMETHOD_(HRESULT, StopSession) (THIS_ DWORD ) PURE; - STDMETHOD_(HRESULT, GetSessionDesc)(THIS_ PDVSESSIONDESC ) PURE; - STDMETHOD_(HRESULT, SetSessionDesc)(THIS_ PDVSESSIONDESC ) PURE; - STDMETHOD_(HRESULT, GetCaps) (THIS_ PDVCAPS ) PURE; - STDMETHOD_(HRESULT, GetCompressionTypes)( THIS_ PVOID, PDWORD, PDWORD, DWORD ) PURE; - STDMETHOD_(HRESULT, SetTransmitTargets)( THIS_ DVID, PDVID, DWORD, DWORD ) PURE; - STDMETHOD_(HRESULT, GetTransmitTargets)( THIS_ DVID, PDVID, PDWORD, DWORD ) PURE; - STDMETHOD_(HRESULT, SetNotifyMask)( THIS_ PDWORD, DWORD ) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirectPlayVoiceTest -DECLARE_INTERFACE_( IDirectPlayVoiceTest, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, PVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectPlayVoiceTest methods ***/ - STDMETHOD_(HRESULT, CheckAudioSetup) (THIS_ const GUID *, const GUID * , HWND, DWORD ) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) - -#define IDirectPlayVoiceClient_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlayVoiceClient_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlayVoiceClient_Release(p) (p)->lpVtbl->Release(p) - -#define IDirectPlayVoiceClient_Initialize(p,a,b,c,d,e) (p)->lpVtbl->Initialize(p,a,b,c,d,e) -#define IDirectPlayVoiceClient_Connect(p,a,b,c) (p)->lpVtbl->Connect(p,a,b,c) -#define IDirectPlayVoiceClient_Disconnect(p,a) (p)->lpVtbl->Disconnect(p,a) -#define IDirectPlayVoiceClient_GetSessionDesc(p,a) (p)->lpVtbl->GetSessionDesc(p,a) -#define IDirectPlayVoiceClient_GetClientConfig(p,a) (p)->lpVtbl->GetClientConfig(p,a) -#define IDirectPlayVoiceClient_SetClientConfig(p,a) (p)->lpVtbl->SetClientConfig(p,a) -#define IDirectPlayVoiceClient_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) -#define IDirectPlayVoiceClient_GetCompressionTypes(p,a,b,c,d) (p)->lpVtbl->GetCompressionTypes(p,a,b,c,d) -#define IDirectPlayVoiceClient_SetTransmitTargets(p,a,b,c) (p)->lpVtbl->SetTransmitTargets(p,a,b,c) -#define IDirectPlayVoiceClient_GetTransmitTargets(p,a,b,c) (p)->lpVtbl->GetTransmitTargets(p,a,b,c) -#define IDirectPlayVoiceClient_Create3DSoundBuffer(p,a,b,c,d,e) (p)->lpVtbl->Create3DSoundBuffer(p,a,b,c,d,e) -#define IDirectPlayVoiceClient_Delete3DSoundBuffer(p,a,b) (p)->lpVtbl->Delete3DSoundBuffer(p,a,b) -#define IDirectPlayVoiceClient_SetNotifyMask(p,a,b) (p)->lpVtbl->SetNotifyMask(p,a,b) -#define IDirectPlayVoiceClient_GetSoundDeviceConfig(p,a,b) (p)->lpVtbl->GetSoundDeviceConfig(p,a,b) - -#define IDirectPlayVoiceServer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlayVoiceServer_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlayVoiceServer_Release(p) (p)->lpVtbl->Release(p) - -#define IDirectPlayVoiceServer_Initialize(p,a,b,c,d,e) (p)->lpVtbl->Initialize(p,a,b,c,d,e) -#define IDirectPlayVoiceServer_StartSession(p,a,b) (p)->lpVtbl->StartSession(p,a,b) -#define IDirectPlayVoiceServer_StopSession(p,a) (p)->lpVtbl->StopSession(p,a) -#define IDirectPlayVoiceServer_GetSessionDesc(p,a) (p)->lpVtbl->GetSessionDesc(p,a) -#define IDirectPlayVoiceServer_SetSessionDesc(p,a) (p)->lpVtbl->SetSessionDesc(p,a) -#define IDirectPlayVoiceServer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) -#define IDirectPlayVoiceServer_GetCompressionTypes(p,a,b,c,d) (p)->lpVtbl->GetCompressionTypes(p,a,b,c,d) -#define IDirectPlayVoiceServer_SetTransmitTargets(p,a,b,c,d) (p)->lpVtbl->SetTransmitTargets(p,a,b,c,d) -#define IDirectPlayVoiceServer_GetTransmitTargets(p,a,b,c,d) (p)->lpVtbl->GetTransmitTargets(p,a,b,c,d) -#define IDirectPlayVoiceServer_SetNotifyMask(p,a,b) (p)->lpVtbl->SetNotifyMask(p,a,b) -#define IDirectPlayVoiceTest_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectPlayVoiceTest_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectPlayVoiceTest_Release(p) (p)->lpVtbl->Release(p) -#define IDirectPlayVoiceTest_CheckAudioSetup(p,a,b,c,d) (p)->lpVtbl->CheckAudioSetup(p,a,b,c,d) - - -#else /* C++ */ - -#define IDirectPlayVoiceClient_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlayVoiceClient_AddRef(p) (p)->AddRef() -#define IDirectPlayVoiceClient_Release(p) (p)->Release() - -#define IDirectPlayVoiceClient_Initialize(p,a,b,c,d,e) (p)->Initialize(a,b,c,d,e) -#define IDirectPlayVoiceClient_Connect(p,a,b,c) (p)->Connect(a,b,c) -#define IDirectPlayVoiceClient_Disconnect(p,a) (p)->Disconnect(a) -#define IDirectPlayVoiceClient_GetSessionDesc(p,a) (p)->GetSessionDesc(a) -#define IDirectPlayVoiceClient_GetClientConfig(p,a) (p)->GetClientConfig(a) -#define IDirectPlayVoiceClient_SetClientConfig(p,a) (p)->SetClientConfig(a) -#define IDirectPlayVoiceClient_GetCaps(p,a) (p)->GetCaps(a) -#define IDirectPlayVoiceClient_GetCompressionTypes(p,a,b,c,d) (p)->GetCompressionTypes(a,b,c,d) -#define IDirectPlayVoiceClient_SetTransmitTargets(p,a,b,c) (p)->SetTransmitTargets(a,b,c) -#define IDirectPlayVoiceClient_GetTransmitTargets(p,a,b,c) (p)->GetTransmitTargets(a,b,c) -#define IDirectPlayVoiceClient_Create3DSoundBuffer(p,a,b,c,d,e) (p)->Create3DSoundBuffer(a,b,c,d,e) -#define IDirectPlayVoiceClient_Delete3DSoundBuffer(p,a,b) (p)->Delete3DSoundBuffer(a,b) -#define IDirectPlayVoiceClient_SetNotifyMask(p,a,b) (p)->SetNotifyMask(a,b) -#define IDirectPlayVoiceClient_GetSoundDeviceConfig(p,a,b) (p)->GetSoundDeviceConfig(a,b) - -#define IDirectPlayVoiceServer_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlayVoiceServer_AddRef(p) (p)->AddRef() -#define IDirectPlayVoiceServer_Release(p) (p)->Release() - -#define IDirectPlayVoiceServer_Initialize(p,a,b,c,d,e) (p)->Initialize(a,b,c,d,e) -#define IDirectPlayVoiceServer_StartSession(p,a,b) (p)->StartSession(a,b) -#define IDirectPlayVoiceServer_StopSession(p,a) (p)->StopSession(a) -#define IDirectPlayVoiceServer_GetSessionDesc(p,a) (p)->GetSessionDesc(a) -#define IDirectPlayVoiceServer_SetSessionDesc(p,a) (p)->SetSessionDesc(a) -#define IDirectPlayVoiceServer_GetCaps(p,a) (p)->GetCaps(a) -#define IDirectPlayVoiceServer_GetCompressionTypes(p,a,b,c,d) (p)->GetCompressionTypes(a,b,c,d) -#define IDirectPlayVoiceServer_SetTransmitTargets(p,a,b,c,d) (p)->SetTransmitTargets(a,b,c,d) -#define IDirectPlayVoiceServer_GetTransmitTargets(p,a,b,c,d) (p)->GetTransmitTargets(a,b,c,d) -#define IDirectPlayVoiceServer_SetNotifyMask(p,a,b) (p)->SetNotifyMask(a,b) - -#define IDirectPlayVoiceTest_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectPlayVoiceTest_AddRef(p) (p)->AddRef() -#define IDirectPlayVoiceTest_Release(p) (p)->Release() -#define IDirectPlayVoiceTest_CheckAudioSetup(p,a,b,c,d) (p)->CheckAudioSetup(a,b,c,d) - - -#endif - - -/**************************************************************************** - * - * DIRECTPLAYVOICE ERRORS - * - * Errors are represented by negative values and cannot be combined. - * - ****************************************************************************/ - -#define _FACDPV 0x15 -#define MAKE_DVHRESULT( code ) MAKE_HRESULT( 1, _FACDPV, code ) - -#define DV_OK S_OK -#define DV_FULLDUPLEX MAKE_HRESULT( 0, _FACDPV, 0x0005 ) -#define DV_HALFDUPLEX MAKE_HRESULT( 0, _FACDPV, 0x000A ) -#define DV_PENDING MAKE_HRESULT( 0, _FACDPV, 0x0010 ) - -#define DVERR_BUFFERTOOSMALL MAKE_DVHRESULT( 0x001E ) -#define DVERR_EXCEPTION MAKE_DVHRESULT( 0x004A ) -#define DVERR_GENERIC E_FAIL -#define DVERR_INVALIDFLAGS MAKE_DVHRESULT( 0x0078 ) -#define DVERR_INVALIDOBJECT MAKE_DVHRESULT( 0x0082 ) -#define DVERR_INVALIDPARAM E_INVALIDARG -#define DVERR_INVALIDPLAYER MAKE_DVHRESULT( 0x0087 ) -#define DVERR_INVALIDGROUP MAKE_DVHRESULT( 0x0091 ) -#define DVERR_INVALIDHANDLE MAKE_DVHRESULT( 0x0096 ) -#define DVERR_OUTOFMEMORY E_OUTOFMEMORY -#define DVERR_PENDING DV_PENDING -#define DVERR_NOTSUPPORTED E_NOTIMPL -#define DVERR_NOINTERFACE E_NOINTERFACE -#define DVERR_SESSIONLOST MAKE_DVHRESULT( 0x012C ) -#define DVERR_NOVOICESESSION MAKE_DVHRESULT( 0x012E ) -#define DVERR_CONNECTIONLOST MAKE_DVHRESULT( 0x0168 ) -#define DVERR_NOTINITIALIZED MAKE_DVHRESULT( 0x0169 ) -#define DVERR_CONNECTED MAKE_DVHRESULT( 0x016A ) -#define DVERR_NOTCONNECTED MAKE_DVHRESULT( 0x016B ) -#define DVERR_CONNECTABORTING MAKE_DVHRESULT( 0x016E ) -#define DVERR_NOTALLOWED MAKE_DVHRESULT( 0x016F ) -#define DVERR_INVALIDTARGET MAKE_DVHRESULT( 0x0170 ) -#define DVERR_TRANSPORTNOTHOST MAKE_DVHRESULT( 0x0171 ) -#define DVERR_COMPRESSIONNOTSUPPORTED MAKE_DVHRESULT( 0x0172 ) -#define DVERR_ALREADYPENDING MAKE_DVHRESULT( 0x0173 ) -#define DVERR_SOUNDINITFAILURE MAKE_DVHRESULT( 0x0174 ) -#define DVERR_TIMEOUT MAKE_DVHRESULT( 0x0175 ) -#define DVERR_CONNECTABORTED MAKE_DVHRESULT( 0x0176 ) -#define DVERR_NO3DSOUND MAKE_DVHRESULT( 0x0177 ) -#define DVERR_ALREADYBUFFERED MAKE_DVHRESULT( 0x0178 ) -#define DVERR_NOTBUFFERED MAKE_DVHRESULT( 0x0179 ) -#define DVERR_HOSTING MAKE_DVHRESULT( 0x017A ) -#define DVERR_NOTHOSTING MAKE_DVHRESULT( 0x017B ) -#define DVERR_INVALIDDEVICE MAKE_DVHRESULT( 0x017C ) -#define DVERR_RECORDSYSTEMERROR MAKE_DVHRESULT( 0x017D ) -#define DVERR_PLAYBACKSYSTEMERROR MAKE_DVHRESULT( 0x017E ) -#define DVERR_SENDERROR MAKE_DVHRESULT( 0x017F ) -#define DVERR_USERCANCEL MAKE_DVHRESULT( 0x0180 ) -#define DVERR_RUNSETUP MAKE_DVHRESULT( 0x0183 ) -#define DVERR_INCOMPATIBLEVERSION MAKE_DVHRESULT( 0x0184 ) -#define DVERR_INITIALIZED MAKE_DVHRESULT( 0x0187 ) -#define DVERR_INVALIDPOINTER E_POINTER -#define DVERR_NOTRANSPORT MAKE_DVHRESULT( 0x0188 ) -#define DVERR_NOCALLBACK MAKE_DVHRESULT( 0x0189 ) -#define DVERR_TRANSPORTNOTINIT MAKE_DVHRESULT( 0x018A ) -#define DVERR_TRANSPORTNOSESSION MAKE_DVHRESULT( 0x018B ) -#define DVERR_TRANSPORTNOPLAYER MAKE_DVHRESULT( 0x018C ) -#define DVERR_USERBACK MAKE_DVHRESULT( 0x018D ) -#define DVERR_NORECVOLAVAILABLE MAKE_DVHRESULT( 0x018E ) -#define DVERR_INVALIDBUFFER MAKE_DVHRESULT( 0x018F ) -#define DVERR_LOCKEDBUFFER MAKE_DVHRESULT( 0x0190 ) - -#ifdef __cplusplus -} -#endif - -#endif - - +/*==========================================================================; + * + * Copyright (C) 1999 Microsoft Corporation. All Rights Reserved. + * + * File: dpvoice.h + * Content: DirectPlayVoice include file + ***************************************************************************/ + +#ifndef __DVOICE__ +#define __DVOICE__ + +#include // for DECLARE_INTERFACE and HRESULT +#include +#include +#include +#include "dsound.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/**************************************************************************** + * + * DirectPlayVoice CLSIDs + * + ****************************************************************************/ + + +// {B9F3EB85-B781-4ac1-8D90-93A05EE37D7D} +DEFINE_GUID(CLSID_DirectPlayVoiceClient, +0xb9f3eb85, 0xb781, 0x4ac1, 0x8d, 0x90, 0x93, 0xa0, 0x5e, 0xe3, 0x7d, 0x7d); + +// {D3F5B8E6-9B78-4a4c-94EA-CA2397B663D3} +DEFINE_GUID(CLSID_DirectPlayVoiceServer, +0xd3f5b8e6, 0x9b78, 0x4a4c, 0x94, 0xea, 0xca, 0x23, 0x97, 0xb6, 0x63, 0xd3); + +// {0F0F094B-B01C-4091-A14D-DD0CD807711A} +DEFINE_GUID(CLSID_DirectPlayVoiceTest, +0xf0f094b, 0xb01c, 0x4091, 0xa1, 0x4d, 0xdd, 0xc, 0xd8, 0x7, 0x71, 0x1a); + +/**************************************************************************** + * + * DirectPlayVoice Interface IIDs + * + ****************************************************************************/ + + +// {1DFDC8EA-BCF7-41d6-B295-AB64B3B23306} +DEFINE_GUID(IID_IDirectPlayVoiceClient, +0x1dfdc8ea, 0xbcf7, 0x41d6, 0xb2, 0x95, 0xab, 0x64, 0xb3, 0xb2, 0x33, 0x6); + +// {FAA1C173-0468-43b6-8A2A-EA8A4F2076C9} +DEFINE_GUID(IID_IDirectPlayVoiceServer, +0xfaa1c173, 0x468, 0x43b6, 0x8a, 0x2a, 0xea, 0x8a, 0x4f, 0x20, 0x76, 0xc9); + +// {D26AF734-208B-41da-8224-E0CE79810BE1} +DEFINE_GUID(IID_IDirectPlayVoiceTest, +0xd26af734, 0x208b, 0x41da, 0x82, 0x24, 0xe0, 0xce, 0x79, 0x81, 0xb, 0xe1); + +/**************************************************************************** + * + * DirectPlayVoice Compression Type GUIDs + * + ****************************************************************************/ + +// MS-ADPCM 32.8 kbit/s +// +// {699B52C1-A885-46a8-A308-97172419ADC7} +DEFINE_GUID(DPVCTGUID_ADPCM, +0x699b52c1, 0xa885, 0x46a8, 0xa3, 0x8, 0x97, 0x17, 0x24, 0x19, 0xad, 0xc7); + +// Microsoft GSM 6.10 13 kbit/s +// +// {24768C60-5A0D-11d3-9BE4-525400D985E7} +DEFINE_GUID(DPVCTGUID_GSM, +0x24768c60, 0x5a0d, 0x11d3, 0x9b, 0xe4, 0x52, 0x54, 0x0, 0xd9, 0x85, 0xe7); + +// MS-PCM 64 kbit/s +// +// {8DE12FD4-7CB3-48ce-A7E8-9C47A22E8AC5} +DEFINE_GUID(DPVCTGUID_NONE, +0x8de12fd4, 0x7cb3, 0x48ce, 0xa7, 0xe8, 0x9c, 0x47, 0xa2, 0x2e, 0x8a, 0xc5); + +// Voxware SC03 3.2kbit/s +// +// {7D82A29B-2242-4f82-8F39-5D1153DF3E41} +DEFINE_GUID(DPVCTGUID_SC03, +0x7d82a29b, 0x2242, 0x4f82, 0x8f, 0x39, 0x5d, 0x11, 0x53, 0xdf, 0x3e, 0x41); + +// Voxware SC06 6.4kbit/s +// +// {53DEF900-7168-4633-B47F-D143916A13C7} +DEFINE_GUID(DPVCTGUID_SC06, +0x53def900, 0x7168, 0x4633, 0xb4, 0x7f, 0xd1, 0x43, 0x91, 0x6a, 0x13, 0xc7); + +// TrueSpeech(TM) 8.6 kbit/s +// +// {D7954361-5A0B-11d3-9BE4-525400D985E7} +DEFINE_GUID(DPVCTGUID_TRUESPEECH, +0xd7954361, 0x5a0b, 0x11d3, 0x9b, 0xe4, 0x52, 0x54, 0x0, 0xd9, 0x85, 0xe7); + +// Voxware VR12 1.4kbit/s +// +// {FE44A9FE-8ED4-48bf-9D66-1B1ADFF9FF6D} +DEFINE_GUID(DPVCTGUID_VR12, +0xfe44a9fe, 0x8ed4, 0x48bf, 0x9d, 0x66, 0x1b, 0x1a, 0xdf, 0xf9, 0xff, 0x6d); + +// Define the default compression type +#define DPVCTGUID_DEFAULT DPVCTGUID_SC03 + +/**************************************************************************** + * + * DirectPlayVoice Interface Pointer definitions + * + ****************************************************************************/ + +typedef struct IDirectPlayVoiceClient FAR *LPDIRECTPLAYVOICECLIENT, *PDIRECTPLAYVOICECLIENT; +typedef struct IDirectPlayVoiceServer FAR *LPDIRECTPLAYVOICESERVER, *PDIRECTPLAYVOICESERVER; +typedef struct IDirectPlayVoiceTest FAR *LPDIRECTPLAYVOICETEST, *PDIRECTPLAYVOICETEST; + +/**************************************************************************** + * + * DirectPlayVoice Callback Functions + * + ****************************************************************************/ +typedef HRESULT (FAR PASCAL *PDVMESSAGEHANDLER)( + PVOID pvUserContext, + DWORD dwMessageType, + LPVOID lpMessage +); + +typedef PDVMESSAGEHANDLER LPDVMESSAGEHANDLER; + +/**************************************************************************** + * + * DirectPlayVoice Datatypes (Non-Structure / Non-Message) + * + ****************************************************************************/ + +typedef DWORD DVID, *LPDVID, *PDVID; + +/**************************************************************************** + * + * DirectPlayVoice Message Types + * + ****************************************************************************/ + +#define DVMSGID_BASE 0x0000 + +#define DVMSGID_MINBASE (DVMSGID_CREATEVOICEPLAYER) +#define DVMSGID_CREATEVOICEPLAYER (DVMSGID_BASE+0x0001) +#define DVMSGID_DELETEVOICEPLAYER (DVMSGID_BASE+0x0002) +#define DVMSGID_SESSIONLOST (DVMSGID_BASE+0x0003) +#define DVMSGID_PLAYERVOICESTART (DVMSGID_BASE+0x0004) +#define DVMSGID_PLAYERVOICESTOP (DVMSGID_BASE+0x0005) +#define DVMSGID_RECORDSTART (DVMSGID_BASE+0x0006) +#define DVMSGID_RECORDSTOP (DVMSGID_BASE+0x0007) +#define DVMSGID_CONNECTRESULT (DVMSGID_BASE+0x0008) +#define DVMSGID_DISCONNECTRESULT (DVMSGID_BASE+0x0009) +#define DVMSGID_INPUTLEVEL (DVMSGID_BASE+0x000A) +#define DVMSGID_OUTPUTLEVEL (DVMSGID_BASE+0x000B) +#define DVMSGID_HOSTMIGRATED (DVMSGID_BASE+0x000C) +#define DVMSGID_SETTARGETS (DVMSGID_BASE+0x000D) +#define DVMSGID_PLAYEROUTPUTLEVEL (DVMSGID_BASE+0x000E) +#define DVMSGID_LOSTFOCUS (DVMSGID_BASE+0x0010) +#define DVMSGID_GAINFOCUS (DVMSGID_BASE+0x0011) +#define DVMSGID_LOCALHOSTSETUP (DVMSGID_BASE+0x0012) +#define DVMSGID_MAXBASE (DVMSGID_LOCALHOSTSETUP) + +/**************************************************************************** + * + * DirectPlayVoice Constants + * + ****************************************************************************/ + +// +// Buffer Aggresiveness Value Ranges +// +#define DVBUFFERAGGRESSIVENESS_MIN 0x00000001 +#define DVBUFFERAGGRESSIVENESS_MAX 0x00000064 +#define DVBUFFERAGGRESSIVENESS_DEFAULT 0x00000000 + +// +// Buffer Quality Value Ranges +// +#define DVBUFFERQUALITY_MIN 0x00000001 +#define DVBUFFERQUALITY_MAX 0x00000064 +#define DVBUFFERQUALITY_DEFAULT 0x00000000 + +#define DVID_SYS 0 + +// +// Used to identify the session host in client/server +// +#define DVID_SERVERPLAYER 1 + +// +// Used to target all players +// +#define DVID_ALLPLAYERS 0 + +// +// Used to identify the main buffer +// +#define DVID_REMAINING 0xFFFFFFFF + +// +// Input level range +// +#define DVINPUTLEVEL_MIN 0x00000000 +#define DVINPUTLEVEL_MAX 0x00000063 // 99 decimal + +#define DVNOTIFYPERIOD_MINPERIOD 20 + + +#define DVPLAYBACKVOLUME_DEFAULT DSBVOLUME_MAX + +#define DVRECORDVOLUME_LAST 0x00000001 + + +// +// Use the default value +// +#define DVTHRESHOLD_DEFAULT 0xFFFFFFFF + +// +// Threshold Ranges +// +#define DVTHRESHOLD_MIN 0x00000000 +#define DVTHRESHOLD_MAX 0x00000063 // 99 decimal + +// +// Threshold field is not used +// +#define DVTHRESHOLD_UNUSED 0xFFFFFFFE + +// +// Session Types +// +#define DVSESSIONTYPE_PEER 0x00000001 +#define DVSESSIONTYPE_MIXING 0x00000002 +#define DVSESSIONTYPE_FORWARDING 0x00000003 +#define DVSESSIONTYPE_ECHO 0x00000004 + +/**************************************************************************** + * + * DirectPlayVoice Flags + * + ****************************************************************************/ + + +// +// Enable automatic adjustment of the recording volume +// +#define DVCLIENTCONFIG_AUTORECORDVOLUME 0x00000008 + +// +// Enable automatic voice activation +// +#define DVCLIENTCONFIG_AUTOVOICEACTIVATED 0x00000020 + +// +// Enable echo suppression +// +#define DVCLIENTCONFIG_ECHOSUPPRESSION 0x08000000 + +// +// Voice Activation manual mode +// +#define DVCLIENTCONFIG_MANUALVOICEACTIVATED 0x00000004 + +// +// Only playback voices that have buffers created for them +// +#define DVCLIENTCONFIG_MUTEGLOBAL 0x00000010 + +// +// Mute the playback +// +#define DVCLIENTCONFIG_PLAYBACKMUTE 0x00000002 + +// +// Mute the recording +// +#define DVCLIENTCONFIG_RECORDMUTE 0x00000001 + +// +// Complete the operation before returning +// +#define DVFLAGS_SYNC 0x00000001 + +// +// Just check to see if wizard has been run, and if so what it's results were +// +#define DVFLAGS_QUERYONLY 0x00000002 + +// +// Shutdown the voice session without migrating the host +// +#define DVFLAGS_NOHOSTMIGRATE 0x00000008 + +// +// Allow the back button to be enabled in the wizard +// +#define DVFLAGS_ALLOWBACK 0x00000010 + +// +// Disable host migration in the voice session +// +#define DVSESSION_NOHOSTMIGRATION 0x00000001 + +// +// Server controlled targetting +// +#define DVSESSION_SERVERCONTROLTARGET 0x00000002 + +// +// Use DirectSound Normal Mode instead of priority +// +#define DVSOUNDCONFIG_NORMALMODE 0x00000001 + +// +// Automatically select the microphone +// +#define DVSOUNDCONFIG_AUTOSELECT 0x00000002 + +// +// Run in half duplex mode +// +#define DVSOUNDCONFIG_HALFDUPLEX 0x00000004 + +// +// No volume controls are available for the recording device +// +#define DVSOUNDCONFIG_NORECVOLAVAILABLE 0x00000010 + +// +// Disable capture sharing +// +#define DVSOUNDCONFIG_NOFOCUS 0x20000000 + +// +// Set system conversion quality to high +// +#define DVSOUNDCONFIG_SETCONVERSIONQUALITY 0x00000008 + +// +// Enable strict focus mode +// +#define DVSOUNDCONFIG_STRICTFOCUS 0x40000000 + +// +// Player is in half duplex mode +// +#define DVPLAYERCAPS_HALFDUPLEX 0x00000001 + +// +// Specifies that player is the local player +// +#define DVPLAYERCAPS_LOCAL 0x00000002 + +/**************************************************************************** + * + * DirectPlayVoice Structures (Non-Message) + * + ****************************************************************************/ + + +// +// DirectPlayVoice Caps +// (GetCaps / SetCaps) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DWORD dwFlags; // Caps flags +} DVCAPS, *LPDVCAPS, *PDVCAPS; + +// +// DirectPlayVoice Client Configuration +// (Connect / GetClientConfig) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DWORD dwFlags; // Flags for client config (DVCLIENTCONFIG_...) + LONG lRecordVolume; // Recording volume + LONG lPlaybackVolume; // Playback volume + DWORD dwThreshold; // Voice Activation Threshold + DWORD dwBufferQuality; // Buffer quality + DWORD dwBufferAggressiveness; // Buffer aggressiveness + DWORD dwNotifyPeriod; // Period of notification messages (ms) +} DVCLIENTCONFIG, *LPDVCLIENTCONFIG, *PDVCLIENTCONFIG; + +// +// DirectPlayVoice Compression Type Information +// (GetCompressionTypes) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + GUID guidType; // GUID that identifies this compression type + LPWSTR lpszName; // String name of this compression type + LPWSTR lpszDescription; // Description for this compression type + DWORD dwFlags; // Flags for this compression type + DWORD dwMaxBitsPerSecond; // Maximum # of bit/s this compression type uses +} DVCOMPRESSIONINFO, *LPDVCOMPRESSIONINFO, *PDVCOMPRESSIONINFO; + +// +// DirectPlayVoice Session Description +// (Host / GetSessionDesc) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DWORD dwFlags; // Session flags (DVSESSION_...) + DWORD dwSessionType; // Session type (DVSESSIONTYPE_...) + GUID guidCT; // Compression Type to use + DWORD dwBufferQuality; // Buffer quality + DWORD dwBufferAggressiveness; // Buffer aggresiveness +} DVSESSIONDESC, *LPDVSESSIONDESC, *PDVSESSIONDESC; + +// +// DirectPlayVoice Client Sound Device Configuration +// (Connect / GetSoundDeviceConfig) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DWORD dwFlags; // Flags for sound config (DVSOUNDCONFIG_...) + GUID guidPlaybackDevice; // GUID of the playback device to use + LPDIRECTSOUND lpdsPlaybackDevice; // DirectSound Object to use (optional) + GUID guidCaptureDevice; // GUID of the capture device to use + LPDIRECTSOUNDCAPTURE lpdsCaptureDevice; // DirectSoundCapture Object to use (optional) + HWND hwndAppWindow; // HWND of your application's top-level window + LPDIRECTSOUNDBUFFER lpdsMainBuffer; // DirectSoundBuffer to use for playback (optional) + DWORD dwMainBufferFlags; // Flags to pass to Play() on the main buffer + DWORD dwMainBufferPriority; // Priority to set when calling Play() on the main buffer +} DVSOUNDDEVICECONFIG, *LPDVSOUNDDEVICECONFIG, *PDVSOUNDDEVICECONFIG; + +/**************************************************************************** + * + * DirectPlayVoice message handler call back structures + * + ****************************************************************************/ + +// +// Result of the Connect() call. (If it wasn't called Async) +// (DVMSGID_CONNECTRESULT) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + HRESULT hrResult; // Result of the Connect() call +} DVMSG_CONNECTRESULT, *LPDVMSG_CONNECTRESULT, *PDVMSG_CONNECTRESULT; + +// +// A new player has entered the voice session +// (DVMSGID_CREATEVOICEPLAYER) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DVID dvidPlayer; // DVID of the player who joined + DWORD dwFlags; // Player flags (DVPLAYERCAPS_...) + PVOID pvPlayerContext; // Context value for this player (user set) +} DVMSG_CREATEVOICEPLAYER, *LPDVMSG_CREATEVOICEPLAYER, *PDVMSG_CREATEVOICEPLAYER; + +// +// A player has left the voice session +// (DVMSGID_DELETEVOICEPLAYER) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DVID dvidPlayer; // DVID of the player who left + PVOID pvPlayerContext; // Context value for the player +} DVMSG_DELETEVOICEPLAYER, *LPDVMSG_DELETEVOICEPLAYER, *PDVMSG_DELETEVOICEPLAYER; + +// +// Result of the Disconnect() call. (If it wasn't called Async) +// (DVMSGID_DISCONNECTRESULT) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + HRESULT hrResult; // Result of the Disconnect() call +} DVMSG_DISCONNECTRESULT, *LPDVMSG_DISCONNECTRESULT, *PDVMSG_DISCONNECTRESULT; + +// +// The voice session host has migrated. +// (DVMSGID_HOSTMIGRATED) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DVID dvidNewHostID; // DVID of the player who is now the host + LPDIRECTPLAYVOICESERVER pdvServerInterface; + // Pointer to the new host object (if local player is now host) +} DVMSG_HOSTMIGRATED, *LPDVMSG_HOSTMIGRATED, *PDVMSG_HOSTMIGRATED; + +// +// The current input level / recording volume on the local machine +// (DVMSGID_INPUTLEVEL) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DWORD dwPeakLevel; // Current peak level of the audio + LONG lRecordVolume; // Current recording volume + PVOID pvLocalPlayerContext; // Context value for the local player +} DVMSG_INPUTLEVEL, *LPDVMSG_INPUTLEVEL, *PDVMSG_INPUTLEVEL; + +// +// The local client is about to become the new host +// (DVMSGID_LOCALHOSTSETUP) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + PVOID pvContext; // Context value to be passed to Initialize() of new host object + PDVMESSAGEHANDLER pMessageHandler; // Message handler to be used by new host object +} DVMSG_LOCALHOSTSETUP, *LPDVMSG_LOCALHOSTSETUP, *PDVMSG_LOCALHOSTSETUP; + +// +// The current output level for the combined output of all incoming streams. +// (DVMSGID_OUTPUTLEVEL) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DWORD dwPeakLevel; // Current peak level of the output + LONG lOutputVolume; // Current playback volume + PVOID pvLocalPlayerContext; // Context value for the local player +} DVMSG_OUTPUTLEVEL, *LPDVMSG_OUTPUTLEVEL, *PDVMSG_OUTPUTLEVEL; + +// +// The current peak level of an individual player's incoming audio stream as it is +// being played back. +// (DVMSGID_PLAYEROUTPUTLEVEL) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DVID dvidSourcePlayerID; // DVID of the player + DWORD dwPeakLevel; // Peak level of the player's stream + PVOID pvPlayerContext; // Context value for the player +} DVMSG_PLAYEROUTPUTLEVEL, *LPDVMSG_PLAYEROUTPUTLEVEL, *PDVMSG_PLAYEROUTPUTLEVEL; + +// +// An audio stream from the specified player has started playing back on the local client. +// (DVMSGID_PLAYERVOICESTART). +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DVID dvidSourcePlayerID; // DVID of the Player + PVOID pvPlayerContext; // Context value for this player +} DVMSG_PLAYERVOICESTART, *LPDVMSG_PLAYERVOICESTART, *PDVMSG_PLAYERVOICESTART; + +// +// The audio stream from the specified player has stopped playing back on the local client. +// (DVMSGID_PLAYERVOICESTOP) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DVID dvidSourcePlayerID; // DVID of the player + PVOID pvPlayerContext; // Context value for this player +} DVMSG_PLAYERVOICESTOP, *LPDVMSG_PLAYERVOICESTOP, *PDVMSG_PLAYERVOICESTOP; + +// +// Transmission has started on the local machine +// (DVMSGID_RECORDSTART) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DWORD dwPeakLevel; // Peak level that caused transmission to start + PVOID pvLocalPlayerContext; // Context value for the local player +} DVMSG_RECORDSTART, *LPDVMSG_RECORDSTART, *PDVMSG_RECORDSTART; + +// +// Transmission has stopped on the local machine +// (DVMSGID_RECORDSTOP) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DWORD dwPeakLevel; // Peak level that caused transmission to stop + PVOID pvLocalPlayerContext; // Context value for the local player +} DVMSG_RECORDSTOP, *LPDVMSG_RECORDSTOP, *PDVMSG_RECORDSTOP; + +// +// The voice session has been lost +// (DVMSGID_SESSIONLOST) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + HRESULT hrResult; // Reason the session was disconnected +} DVMSG_SESSIONLOST, *LPDVMSG_SESSIONLOST, *PDVMSG_SESSIONLOST; + +// +// The target list has been updated for the local client +// (DVMSGID_SETTARGETS) +// +typedef struct +{ + DWORD dwSize; // Size of this structure + DWORD dwNumTargets; // # of targets + PDVID pdvidTargets; // An array of DVIDs specifying the current targets +} DVMSG_SETTARGETS, *LPDVMSG_SETTARGETS, *PDVMSG_SETTARGETS; + + +/**************************************************************************** + * + * DirectPlayVoice Functions + * + ****************************************************************************/ + +/* + * + * This function is no longer supported. It is recommended that CoCreateInstance be used to create + * DirectPlay voice objects. + * + * extern HRESULT WINAPI DirectPlayVoiceCreate( const GUID * pcIID, void **ppvInterface, IUnknown *pUnknown); + * + */ + +/**************************************************************************** + * + * DirectPlay8 Application Interfaces + * + ****************************************************************************/ + +#undef INTERFACE +#define INTERFACE IDirectPlayVoiceClient +DECLARE_INTERFACE_( IDirectPlayVoiceClient, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, PVOID *ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + /*** IDirectPlayVoiceClient methods ***/ + STDMETHOD_(HRESULT, Initialize) (THIS_ LPUNKNOWN, PDVMESSAGEHANDLER, PVOID, PDWORD, DWORD ) PURE; + STDMETHOD_(HRESULT, Connect) (THIS_ PDVSOUNDDEVICECONFIG, PDVCLIENTCONFIG, DWORD ) PURE; + STDMETHOD_(HRESULT, Disconnect) (THIS_ DWORD ) PURE; + STDMETHOD_(HRESULT, GetSessionDesc)(THIS_ PDVSESSIONDESC ) PURE; + STDMETHOD_(HRESULT, GetClientConfig)(THIS_ PDVCLIENTCONFIG ) PURE; + STDMETHOD_(HRESULT, SetClientConfig)(THIS_ PDVCLIENTCONFIG ) PURE; + STDMETHOD_(HRESULT, GetCaps) (THIS_ PDVCAPS ) PURE; + STDMETHOD_(HRESULT, GetCompressionTypes)( THIS_ PVOID, PDWORD, PDWORD, DWORD ) PURE; + STDMETHOD_(HRESULT, SetTransmitTargets)( THIS_ PDVID, DWORD, DWORD ) PURE; + STDMETHOD_(HRESULT, GetTransmitTargets)( THIS_ PDVID, PDWORD, DWORD ) PURE; + STDMETHOD_(HRESULT, Create3DSoundBuffer)( THIS_ DVID, LPDIRECTSOUNDBUFFER, DWORD, DWORD, LPDIRECTSOUND3DBUFFER * ) PURE; + STDMETHOD_(HRESULT, Delete3DSoundBuffer)( THIS_ DVID, LPDIRECTSOUND3DBUFFER * ) PURE; + STDMETHOD_(HRESULT, SetNotifyMask)( THIS_ PDWORD, DWORD ) PURE; + STDMETHOD_(HRESULT, GetSoundDeviceConfig)( THIS_ PDVSOUNDDEVICECONFIG, PDWORD ) PURE; +}; + + +#undef INTERFACE +#define INTERFACE IDirectPlayVoiceServer +DECLARE_INTERFACE_( IDirectPlayVoiceServer, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectPlayVoiceServer methods ***/ + STDMETHOD_(HRESULT, Initialize) (THIS_ LPUNKNOWN, PDVMESSAGEHANDLER, PVOID, LPDWORD, DWORD ) PURE; + STDMETHOD_(HRESULT, StartSession) (THIS_ PDVSESSIONDESC, DWORD ) PURE; + STDMETHOD_(HRESULT, StopSession) (THIS_ DWORD ) PURE; + STDMETHOD_(HRESULT, GetSessionDesc)(THIS_ PDVSESSIONDESC ) PURE; + STDMETHOD_(HRESULT, SetSessionDesc)(THIS_ PDVSESSIONDESC ) PURE; + STDMETHOD_(HRESULT, GetCaps) (THIS_ PDVCAPS ) PURE; + STDMETHOD_(HRESULT, GetCompressionTypes)( THIS_ PVOID, PDWORD, PDWORD, DWORD ) PURE; + STDMETHOD_(HRESULT, SetTransmitTargets)( THIS_ DVID, PDVID, DWORD, DWORD ) PURE; + STDMETHOD_(HRESULT, GetTransmitTargets)( THIS_ DVID, PDVID, PDWORD, DWORD ) PURE; + STDMETHOD_(HRESULT, SetNotifyMask)( THIS_ PDWORD, DWORD ) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirectPlayVoiceTest +DECLARE_INTERFACE_( IDirectPlayVoiceTest, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, PVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectPlayVoiceTest methods ***/ + STDMETHOD_(HRESULT, CheckAudioSetup) (THIS_ const GUID *, const GUID * , HWND, DWORD ) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) + +#define IDirectPlayVoiceClient_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlayVoiceClient_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlayVoiceClient_Release(p) (p)->lpVtbl->Release(p) + +#define IDirectPlayVoiceClient_Initialize(p,a,b,c,d,e) (p)->lpVtbl->Initialize(p,a,b,c,d,e) +#define IDirectPlayVoiceClient_Connect(p,a,b,c) (p)->lpVtbl->Connect(p,a,b,c) +#define IDirectPlayVoiceClient_Disconnect(p,a) (p)->lpVtbl->Disconnect(p,a) +#define IDirectPlayVoiceClient_GetSessionDesc(p,a) (p)->lpVtbl->GetSessionDesc(p,a) +#define IDirectPlayVoiceClient_GetClientConfig(p,a) (p)->lpVtbl->GetClientConfig(p,a) +#define IDirectPlayVoiceClient_SetClientConfig(p,a) (p)->lpVtbl->SetClientConfig(p,a) +#define IDirectPlayVoiceClient_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectPlayVoiceClient_GetCompressionTypes(p,a,b,c,d) (p)->lpVtbl->GetCompressionTypes(p,a,b,c,d) +#define IDirectPlayVoiceClient_SetTransmitTargets(p,a,b,c) (p)->lpVtbl->SetTransmitTargets(p,a,b,c) +#define IDirectPlayVoiceClient_GetTransmitTargets(p,a,b,c) (p)->lpVtbl->GetTransmitTargets(p,a,b,c) +#define IDirectPlayVoiceClient_Create3DSoundBuffer(p,a,b,c,d,e) (p)->lpVtbl->Create3DSoundBuffer(p,a,b,c,d,e) +#define IDirectPlayVoiceClient_Delete3DSoundBuffer(p,a,b) (p)->lpVtbl->Delete3DSoundBuffer(p,a,b) +#define IDirectPlayVoiceClient_SetNotifyMask(p,a,b) (p)->lpVtbl->SetNotifyMask(p,a,b) +#define IDirectPlayVoiceClient_GetSoundDeviceConfig(p,a,b) (p)->lpVtbl->GetSoundDeviceConfig(p,a,b) + +#define IDirectPlayVoiceServer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlayVoiceServer_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlayVoiceServer_Release(p) (p)->lpVtbl->Release(p) + +#define IDirectPlayVoiceServer_Initialize(p,a,b,c,d,e) (p)->lpVtbl->Initialize(p,a,b,c,d,e) +#define IDirectPlayVoiceServer_StartSession(p,a,b) (p)->lpVtbl->StartSession(p,a,b) +#define IDirectPlayVoiceServer_StopSession(p,a) (p)->lpVtbl->StopSession(p,a) +#define IDirectPlayVoiceServer_GetSessionDesc(p,a) (p)->lpVtbl->GetSessionDesc(p,a) +#define IDirectPlayVoiceServer_SetSessionDesc(p,a) (p)->lpVtbl->SetSessionDesc(p,a) +#define IDirectPlayVoiceServer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectPlayVoiceServer_GetCompressionTypes(p,a,b,c,d) (p)->lpVtbl->GetCompressionTypes(p,a,b,c,d) +#define IDirectPlayVoiceServer_SetTransmitTargets(p,a,b,c,d) (p)->lpVtbl->SetTransmitTargets(p,a,b,c,d) +#define IDirectPlayVoiceServer_GetTransmitTargets(p,a,b,c,d) (p)->lpVtbl->GetTransmitTargets(p,a,b,c,d) +#define IDirectPlayVoiceServer_SetNotifyMask(p,a,b) (p)->lpVtbl->SetNotifyMask(p,a,b) +#define IDirectPlayVoiceTest_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectPlayVoiceTest_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectPlayVoiceTest_Release(p) (p)->lpVtbl->Release(p) +#define IDirectPlayVoiceTest_CheckAudioSetup(p,a,b,c,d) (p)->lpVtbl->CheckAudioSetup(p,a,b,c,d) + + +#else /* C++ */ + +#define IDirectPlayVoiceClient_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlayVoiceClient_AddRef(p) (p)->AddRef() +#define IDirectPlayVoiceClient_Release(p) (p)->Release() + +#define IDirectPlayVoiceClient_Initialize(p,a,b,c,d,e) (p)->Initialize(a,b,c,d,e) +#define IDirectPlayVoiceClient_Connect(p,a,b,c) (p)->Connect(a,b,c) +#define IDirectPlayVoiceClient_Disconnect(p,a) (p)->Disconnect(a) +#define IDirectPlayVoiceClient_GetSessionDesc(p,a) (p)->GetSessionDesc(a) +#define IDirectPlayVoiceClient_GetClientConfig(p,a) (p)->GetClientConfig(a) +#define IDirectPlayVoiceClient_SetClientConfig(p,a) (p)->SetClientConfig(a) +#define IDirectPlayVoiceClient_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectPlayVoiceClient_GetCompressionTypes(p,a,b,c,d) (p)->GetCompressionTypes(a,b,c,d) +#define IDirectPlayVoiceClient_SetTransmitTargets(p,a,b,c) (p)->SetTransmitTargets(a,b,c) +#define IDirectPlayVoiceClient_GetTransmitTargets(p,a,b,c) (p)->GetTransmitTargets(a,b,c) +#define IDirectPlayVoiceClient_Create3DSoundBuffer(p,a,b,c,d,e) (p)->Create3DSoundBuffer(a,b,c,d,e) +#define IDirectPlayVoiceClient_Delete3DSoundBuffer(p,a,b) (p)->Delete3DSoundBuffer(a,b) +#define IDirectPlayVoiceClient_SetNotifyMask(p,a,b) (p)->SetNotifyMask(a,b) +#define IDirectPlayVoiceClient_GetSoundDeviceConfig(p,a,b) (p)->GetSoundDeviceConfig(a,b) + +#define IDirectPlayVoiceServer_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlayVoiceServer_AddRef(p) (p)->AddRef() +#define IDirectPlayVoiceServer_Release(p) (p)->Release() + +#define IDirectPlayVoiceServer_Initialize(p,a,b,c,d,e) (p)->Initialize(a,b,c,d,e) +#define IDirectPlayVoiceServer_StartSession(p,a,b) (p)->StartSession(a,b) +#define IDirectPlayVoiceServer_StopSession(p,a) (p)->StopSession(a) +#define IDirectPlayVoiceServer_GetSessionDesc(p,a) (p)->GetSessionDesc(a) +#define IDirectPlayVoiceServer_SetSessionDesc(p,a) (p)->SetSessionDesc(a) +#define IDirectPlayVoiceServer_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectPlayVoiceServer_GetCompressionTypes(p,a,b,c,d) (p)->GetCompressionTypes(a,b,c,d) +#define IDirectPlayVoiceServer_SetTransmitTargets(p,a,b,c,d) (p)->SetTransmitTargets(a,b,c,d) +#define IDirectPlayVoiceServer_GetTransmitTargets(p,a,b,c,d) (p)->GetTransmitTargets(a,b,c,d) +#define IDirectPlayVoiceServer_SetNotifyMask(p,a,b) (p)->SetNotifyMask(a,b) + +#define IDirectPlayVoiceTest_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectPlayVoiceTest_AddRef(p) (p)->AddRef() +#define IDirectPlayVoiceTest_Release(p) (p)->Release() +#define IDirectPlayVoiceTest_CheckAudioSetup(p,a,b,c,d) (p)->CheckAudioSetup(a,b,c,d) + + +#endif + + +/**************************************************************************** + * + * DIRECTPLAYVOICE ERRORS + * + * Errors are represented by negative values and cannot be combined. + * + ****************************************************************************/ + +#define _FACDPV 0x15 +#define MAKE_DVHRESULT( code ) MAKE_HRESULT( 1, _FACDPV, code ) + +#define DV_OK S_OK +#define DV_FULLDUPLEX MAKE_HRESULT( 0, _FACDPV, 0x0005 ) +#define DV_HALFDUPLEX MAKE_HRESULT( 0, _FACDPV, 0x000A ) +#define DV_PENDING MAKE_HRESULT( 0, _FACDPV, 0x0010 ) + +#define DVERR_BUFFERTOOSMALL MAKE_DVHRESULT( 0x001E ) +#define DVERR_EXCEPTION MAKE_DVHRESULT( 0x004A ) +#define DVERR_GENERIC E_FAIL +#define DVERR_INVALIDFLAGS MAKE_DVHRESULT( 0x0078 ) +#define DVERR_INVALIDOBJECT MAKE_DVHRESULT( 0x0082 ) +#define DVERR_INVALIDPARAM E_INVALIDARG +#define DVERR_INVALIDPLAYER MAKE_DVHRESULT( 0x0087 ) +#define DVERR_INVALIDGROUP MAKE_DVHRESULT( 0x0091 ) +#define DVERR_INVALIDHANDLE MAKE_DVHRESULT( 0x0096 ) +#define DVERR_OUTOFMEMORY E_OUTOFMEMORY +#define DVERR_PENDING DV_PENDING +#define DVERR_NOTSUPPORTED E_NOTIMPL +#define DVERR_NOINTERFACE E_NOINTERFACE +#define DVERR_SESSIONLOST MAKE_DVHRESULT( 0x012C ) +#define DVERR_NOVOICESESSION MAKE_DVHRESULT( 0x012E ) +#define DVERR_CONNECTIONLOST MAKE_DVHRESULT( 0x0168 ) +#define DVERR_NOTINITIALIZED MAKE_DVHRESULT( 0x0169 ) +#define DVERR_CONNECTED MAKE_DVHRESULT( 0x016A ) +#define DVERR_NOTCONNECTED MAKE_DVHRESULT( 0x016B ) +#define DVERR_CONNECTABORTING MAKE_DVHRESULT( 0x016E ) +#define DVERR_NOTALLOWED MAKE_DVHRESULT( 0x016F ) +#define DVERR_INVALIDTARGET MAKE_DVHRESULT( 0x0170 ) +#define DVERR_TRANSPORTNOTHOST MAKE_DVHRESULT( 0x0171 ) +#define DVERR_COMPRESSIONNOTSUPPORTED MAKE_DVHRESULT( 0x0172 ) +#define DVERR_ALREADYPENDING MAKE_DVHRESULT( 0x0173 ) +#define DVERR_SOUNDINITFAILURE MAKE_DVHRESULT( 0x0174 ) +#define DVERR_TIMEOUT MAKE_DVHRESULT( 0x0175 ) +#define DVERR_CONNECTABORTED MAKE_DVHRESULT( 0x0176 ) +#define DVERR_NO3DSOUND MAKE_DVHRESULT( 0x0177 ) +#define DVERR_ALREADYBUFFERED MAKE_DVHRESULT( 0x0178 ) +#define DVERR_NOTBUFFERED MAKE_DVHRESULT( 0x0179 ) +#define DVERR_HOSTING MAKE_DVHRESULT( 0x017A ) +#define DVERR_NOTHOSTING MAKE_DVHRESULT( 0x017B ) +#define DVERR_INVALIDDEVICE MAKE_DVHRESULT( 0x017C ) +#define DVERR_RECORDSYSTEMERROR MAKE_DVHRESULT( 0x017D ) +#define DVERR_PLAYBACKSYSTEMERROR MAKE_DVHRESULT( 0x017E ) +#define DVERR_SENDERROR MAKE_DVHRESULT( 0x017F ) +#define DVERR_USERCANCEL MAKE_DVHRESULT( 0x0180 ) +#define DVERR_RUNSETUP MAKE_DVHRESULT( 0x0183 ) +#define DVERR_INCOMPATIBLEVERSION MAKE_DVHRESULT( 0x0184 ) +#define DVERR_INITIALIZED MAKE_DVHRESULT( 0x0187 ) +#define DVERR_INVALIDPOINTER E_POINTER +#define DVERR_NOTRANSPORT MAKE_DVHRESULT( 0x0188 ) +#define DVERR_NOCALLBACK MAKE_DVHRESULT( 0x0189 ) +#define DVERR_TRANSPORTNOTINIT MAKE_DVHRESULT( 0x018A ) +#define DVERR_TRANSPORTNOSESSION MAKE_DVHRESULT( 0x018B ) +#define DVERR_TRANSPORTNOPLAYER MAKE_DVHRESULT( 0x018C ) +#define DVERR_USERBACK MAKE_DVHRESULT( 0x018D ) +#define DVERR_NORECVOLAVAILABLE MAKE_DVHRESULT( 0x018E ) +#define DVERR_INVALIDBUFFER MAKE_DVHRESULT( 0x018F ) +#define DVERR_LOCKEDBUFFER MAKE_DVHRESULT( 0x0190 ) + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/dep/include/DXSDK/include/dvp.h b/src/dep/include/DXSDK/include/dvp.h index 126f5f5..c40dc79 100644 --- a/src/dep/include/DXSDK/include/dvp.h +++ b/src/dep/include/DXSDK/include/dvp.h @@ -1,966 +1,966 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: dvp.h - * Content: DirectDrawVideoPort include file - * - ***************************************************************************/ - -#ifndef __DVP_INCLUDED__ -#define __DVP_INCLUDED__ - -/* - * GUIDS used by DirectDrawVideoPort objects - */ -#if defined( _WIN32 ) && (!defined( _NO_COM ) || defined( DEFINE_GUID )) -DEFINE_GUID( IID_IDDVideoPortContainer, 0x6C142760,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); -DEFINE_GUID( IID_IDirectDrawVideoPort, 0xB36D93E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 ); -DEFINE_GUID( IID_IDirectDrawVideoPortNotify, 0xA655FB94,0x0589,0x4E57,0xB3,0x33,0x56,0x7A,0x89,0x46,0x8C,0x88); - - - -DEFINE_GUID( DDVPTYPE_E_HREFH_VREFH, 0x54F39980L,0xDA60,0x11CF,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8); -DEFINE_GUID( DDVPTYPE_E_HREFH_VREFL, 0x92783220L,0xDA60,0x11CF,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8); -DEFINE_GUID( DDVPTYPE_E_HREFL_VREFH, 0xA07A02E0L,0xDA60,0x11CF,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8); -DEFINE_GUID( DDVPTYPE_E_HREFL_VREFL, 0xE09C77E0L,0xDA60,0x11CF,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8); -DEFINE_GUID( DDVPTYPE_CCIR656, 0xFCA326A0L,0xDA60,0x11CF,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8); -DEFINE_GUID( DDVPTYPE_BROOKTREE, 0x1352A560L,0xDA61,0x11CF,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8); -DEFINE_GUID( DDVPTYPE_PHILIPS, 0x332CF160L,0xDA61,0x11CF,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8); -#endif - -#ifndef GUID_DEFS_ONLY - -#if defined( _WIN32 ) && !defined( _NO_COM ) -#define COM_NO_WINDOWS_H -#include -#else -#define IUnknown void -#endif - -/* - * These definitions are required to allow polymorphic structure members (i.e. those - * that are referred to both as DWORDs and as pointers) to resolve into a type - * of correct size to hold the largest of those two types (i.e. pointer) on 64 bit - * systems. For 32 bit environments, ULONG_PTR resolves to a DWORD. - */ -#ifndef MAXULONG_PTR -#define ULONG_PTR DWORD -#endif //MAXULONG_PTR - -#ifdef __cplusplus -extern "C" { -#endif - -/*============================================================================ - * - * DirectDraw Structures - * - * Various structures used to invoke DirectDraw. - * - *==========================================================================*/ - -struct IDirectDraw; -struct IDirectDrawSurface; -struct IDirectDrawPalette; -struct IDirectDrawClipper; - -typedef struct IDDVideoPortContainer FAR *LPDDVIDEOPORTCONTAINER; -typedef struct IDirectDrawVideoPort FAR *LPDIRECTDRAWVIDEOPORT; -typedef struct IDirectDrawVideoPortNotify FAR *LPDIRECTDRAWVIDEOPORTNOTIFY; - -typedef struct _DDVIDEOPORTCONNECT FAR *LPDDVIDEOPORTCONNECT; -typedef struct _DDVIDEOPORTCAPS FAR *LPDDVIDEOPORTCAPS; -typedef struct _DDVIDEOPORTDESC FAR *LPDDVIDEOPORTDESC; -typedef struct _DDVIDEOPORTINFO FAR *LPDDVIDEOPORTINFO; -typedef struct _DDVIDEOPORTBANDWIDTH FAR *LPDDVIDEOPORTBANDWIDTH; -typedef struct _DDVIDEOPORTSTATUS FAR *LPDDVIDEOPORTSTATUS; -typedef struct _DDVIDEOPORTNOTIFY FAR *LPDDVIDEOPORTNOTIFY; - -typedef struct IDDVideoPortContainerVtbl DDVIDEOPORTCONTAINERCALLBACKS; -typedef struct IDirectDrawVideoPortVtbl DIRECTDRAWVIDEOPORTCALLBACKS; -typedef struct IDirectDrawVideoPortNotifyVtbl DIRECTDRAWVIDEOPORTNOTIFYCALLBACKS; - - -/* - * API's - */ -typedef HRESULT (FAR PASCAL * LPDDENUMVIDEOCALLBACK)(LPDDVIDEOPORTCAPS, LPVOID); - - -/* - * INTERACES FOLLOW: - * IDirectDrawVideoPort - * IVideoPort - */ - -/* - * IDirectDrawVideoPortContainer - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDDVideoPortContainer -DECLARE_INTERFACE_( IDDVideoPortContainer, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawVideoPort methods ***/ - STDMETHOD(CreateVideoPort)(THIS_ DWORD, LPDDVIDEOPORTDESC, LPDIRECTDRAWVIDEOPORT FAR *, IUnknown FAR *) PURE; - STDMETHOD(EnumVideoPorts)(THIS_ DWORD, LPDDVIDEOPORTCAPS, LPVOID,LPDDENUMVIDEOCALLBACK ) PURE; - STDMETHOD(GetVideoPortConnectInfo)(THIS_ DWORD, LPDWORD, LPDDVIDEOPORTCONNECT ) PURE; - STDMETHOD(QueryVideoPortStatus)(THIS_ DWORD, LPDDVIDEOPORTSTATUS ) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IVideoPortContainer_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IVideoPortContainer_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IVideoPortContainer_Release(p) (p)->lpVtbl->Release(p) -#define IVideoPortContainer_CreateVideoPort(p, a, b, c, d) (p)->lpVtbl->CreateVideoPort(p, a, b, c, d) -#define IVideoPortContainer_EnumVideoPorts(p, a, b, c, d) (p)->lpVtbl->EnumVideoPorts(p, a, b, c, d) -#define IVideoPortContainer_GetVideoPortConnectInfo(p, a, b, c) (p)->lpVtbl->GetVideoPortConnectInfo(p, a, b, c) -#define IVideoPortContainer_QueryVideoPortStatus(p, a, b) (p)->lpVtbl->QueryVideoPortStatus(p, a, b) -#else -#define IVideoPortContainer_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IVideoPortContainer_AddRef(p) (p)->AddRef() -#define IVideoPortContainer_Release(p) (p)->Release() -#define IVideoPortContainer_CreateVideoPort(p, a, b, c, d) (p)->CreateVideoPort(a, b, c, d) -#define IVideoPortContainer_EnumVideoPorts(p, a, b, c, d) (p)->EnumVideoPorts(a, b, c, d) -#define IVideoPortContainer_GetVideoPortConnectInfo(p, a, b, c) (p)->GetVideoPortConnectInfo(a, b, c) -#define IVideoPortContainer_QueryVideoPortStatus(p, a, b) (p)->QueryVideoPortStatus(a, b) -#endif - -#endif - - -/* - * IDirectDrawVideoPort - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDrawVideoPort -DECLARE_INTERFACE_( IDirectDrawVideoPort, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IVideoPort methods ***/ - STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE, DWORD) PURE; - STDMETHOD(GetBandwidthInfo)(THIS_ LPDDPIXELFORMAT, DWORD, DWORD, DWORD, LPDDVIDEOPORTBANDWIDTH) PURE; - STDMETHOD(GetColorControls)(THIS_ LPDDCOLORCONTROL) PURE; - STDMETHOD(GetInputFormats)(THIS_ LPDWORD, LPDDPIXELFORMAT, DWORD) PURE; - STDMETHOD(GetOutputFormats)(THIS_ LPDDPIXELFORMAT, LPDWORD, LPDDPIXELFORMAT, DWORD) PURE; - STDMETHOD(GetFieldPolarity)(THIS_ LPBOOL) PURE; - STDMETHOD(GetVideoLine)(THIS_ LPDWORD) PURE; - STDMETHOD(GetVideoSignalStatus)(THIS_ LPDWORD) PURE; - STDMETHOD(SetColorControls)(THIS_ LPDDCOLORCONTROL) PURE; - STDMETHOD(SetTargetSurface)(THIS_ LPDIRECTDRAWSURFACE, DWORD) PURE; - STDMETHOD(StartVideo)(THIS_ LPDDVIDEOPORTINFO) PURE; - STDMETHOD(StopVideo)(THIS) PURE; - STDMETHOD(UpdateVideo)(THIS_ LPDDVIDEOPORTINFO) PURE; - STDMETHOD(WaitForSync)(THIS_ DWORD, DWORD, DWORD) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IVideoPort_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IVideoPort_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IVideoPort_Release(p) (p)->lpVtbl->Release(p) -#define IVideoPort_SetTargetSurface(p,a,b) (p)->lpVtbl->SetTargetSurface(p,a,b) -#define IVideoPort_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) -#define IVideoPort_GetBandwidthInfo(p,a,b,c,d,e) (p)->lpVtbl->GetBandwidthInfo(p,a,b,c,d,e) -#define IVideoPort_GetColorControls(p,a) (p)->lpVtbl->GetColorControls(p,a) -#define IVideoPort_GetInputFormats(p,a,b,c) (p)->lpVtbl->GetInputFormats(p,a,b,c) -#define IVideoPort_GetOutputFormats(p,a,b,c,d) (p)->lpVtbl->GetOutputFormats(p,a,b,c,d) -#define IVideoPort_GetFieldPolarity(p,a) (p)->lpVtbl->GetFieldPolarity(p,a) -#define IVideoPort_GetVideoLine(p,a) (p)->lpVtbl->GetVideoLine(p,a) -#define IVideoPort_GetVideoSignalStatus(p,a) (p)->lpVtbl->GetVideoSignalStatus(p,a) -#define IVideoPort_SetColorControls(p,a) (p)->lpVtbl->SetColorControls(p,a) -#define IVideoPort_StartVideo(p,a) (p)->lpVtbl->StartVideo(p,a) -#define IVideoPort_StopVideo(p) (p)->lpVtbl->StopVideo(p) -#define IVideoPort_UpdateVideo(p,a) (p)->lpVtbl->UpdateVideo(p,a) -#define IVideoPort_WaitForSync(p,a,b,c) (p)->lpVtbl->WaitForSync(p,a,b,c) -#else -#define IVideoPort_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IVideoPort_AddRef(p) (p)->AddRef() -#define IVideoPort_Release(p) (p)->Release() -#define IVideoPort_SetTargetSurface(p,a,b) (p)->SetTargetSurface(a,b) -#define IVideoPort_Flip(p,a,b) (p)->Flip(a,b) -#define IVideoPort_GetBandwidthInfo(p,a,b,c,d,e) (p)->GetBandwidthInfo(a,b,c,d,e) -#define IVideoPort_GetColorControls(p,a) (p)->GetColorControls(a) -#define IVideoPort_GetInputFormats(p,a,b,c) (p)->GetInputFormats(a,b,c) -#define IVideoPort_GetOutputFormats(p,a,b,c,d) (p)->GetOutputFormats(a,b,c,d) -#define IVideoPort_GetFieldPolarity(p,a) (p)->GetFieldPolarity(a) -#define IVideoPort_GetVideoLine(p,a) (p)->GetVideoLine(a) -#define IVideoPort_GetVideoSignalStatus(p,a) (p)->GetVideoSignalStatus(a) -#define IVideoPort_SetColorControls(p,a) (p)->SetColorControls(a) -#define IVideoPort_StartVideo(p,a) (p)->StartVideo(a) -#define IVideoPort_StopVideo(p) (p)->StopVideo() -#define IVideoPort_UpdateVideo(p,a) (p)->UpdateVideo(a) -#define IVideoPort_WaitForSync(p,a,b,c) (p)->WaitForSync(a,b,c) -#endif - -#endif - -/* - * IDirectDrawVideoPort - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDrawVideoPortNotify -DECLARE_INTERFACE_( IDirectDrawVideoPortNotify, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IVideoPort methods ***/ - STDMETHOD(AcquireNotification)(THIS_ HANDLE *, LPDDVIDEOPORTNOTIFY) PURE; - STDMETHOD(ReleaseNotification)(THIS_ HANDLE) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IVideoPortNotify_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IVideoPortNotify_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IVideoPortNotify_Release(p) (p)->lpVtbl->Release(p) -#define IVideoPortNotify_AcquireNotification(p,a,b) (p)->lpVtbl->AcquireNotification(p,a,b) -#define IVideoPortNotify_ReleaseNotification(p,a) (p)->lpVtbl->ReleaseNotification(p,a) -#else -#define IVideoPortNotify_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IVideoPortNotify_AddRef(p) (p)->AddRef() -#define IVideoPortNotify_Release(p) (p)->Release() -#define IVideoPortNotify_AcquireNotification(p,a,b) (p)->lpVtbl->AcquireNotification(a,b) -#define IVideoPortNotify_ReleaseNotification(p,a) (p)->lpVtbl->ReleaseNotification(a) -#endif - -#endif - -/* - * DDVIDEOPORTCONNECT - */ -typedef struct _DDVIDEOPORTCONNECT -{ - DWORD dwSize; // size of the DDVIDEOPORTCONNECT structure - DWORD dwPortWidth; // Width of the video port - GUID guidTypeID; // Description of video port connection - DWORD dwFlags; // Connection flags - ULONG_PTR dwReserved1; // Reserved, set to zero. -} DDVIDEOPORTCONNECT; - - -/* - * DDVIDEOPORTCAPS - */ -typedef struct _DDVIDEOPORTCAPS -{ - DWORD dwSize; // size of the DDVIDEOPORTCAPS structure - DWORD dwFlags; // indicates which fields contain data - DWORD dwMaxWidth; // max width of the video port field - DWORD dwMaxVBIWidth; // max width of the VBI data - DWORD dwMaxHeight; // max height of the video port field - DWORD dwVideoPortID; // Video port ID (0 - (dwMaxVideoPorts -1)) - DWORD dwCaps; // Video port capabilities - DWORD dwFX; // More video port capabilities - DWORD dwNumAutoFlipSurfaces; // Max number of autoflippable surfaces allowed - DWORD dwAlignVideoPortBoundary; // Byte restriction of placement within the surface - DWORD dwAlignVideoPortPrescaleWidth;// Byte restriction of width after prescaling - DWORD dwAlignVideoPortCropBoundary; // Byte restriction of left cropping - DWORD dwAlignVideoPortCropWidth; // Byte restriction of cropping width - DWORD dwPreshrinkXStep; // Width can be shrunk in steps of 1/x - DWORD dwPreshrinkYStep; // Height can be shrunk in steps of 1/x - DWORD dwNumVBIAutoFlipSurfaces; // Max number of VBI autoflippable surfaces allowed - DWORD dwNumPreferredAutoflip; // Optimal number of autoflippable surfaces for hardware - WORD wNumFilterTapsX; // Number of taps the prescaler uses in the X direction (0 - no prescale, 1 - replication, etc.) - WORD wNumFilterTapsY; // Number of taps the prescaler uses in the Y direction (0 - no prescale, 1 - replication, etc.) -} DDVIDEOPORTCAPS; - -/* - * The dwMaxWidth and dwMaxVBIWidth members are valid - */ -#define DDVPD_WIDTH 0x00000001l - -/* - * The dwMaxHeight member is valid - */ -#define DDVPD_HEIGHT 0x00000002l - -/* - * The dwVideoPortID member is valid - */ -#define DDVPD_ID 0x00000004l - -/* - * The dwCaps member is valid - */ -#define DDVPD_CAPS 0x00000008l - -/* - * The dwFX member is valid - */ -#define DDVPD_FX 0x00000010l - -/* - * The dwNumAutoFlipSurfaces member is valid - */ -#define DDVPD_AUTOFLIP 0x00000020l - -/* - * All of the alignment members are valid - */ -#define DDVPD_ALIGN 0x00000040l - -/* - * The dwNumPreferredAutoflip member is valid - */ -#define DDVPD_PREFERREDAUTOFLIP 0x00000080l - -/* - * The wNumFilterTapsX and wNumFilterTapsY fields are valid - */ -#define DDVPD_FILTERQUALITY 0x00000100l - -/* - * DDVIDEOPORTDESC - */ -typedef struct _DDVIDEOPORTDESC -{ - DWORD dwSize; // size of the DDVIDEOPORTDESC structure - DWORD dwFieldWidth; // width of the video port field - DWORD dwVBIWidth; // width of the VBI data - DWORD dwFieldHeight; // height of the video port field - DWORD dwMicrosecondsPerField; // Microseconds per video field - DWORD dwMaxPixelsPerSecond; // Maximum pixel rate per second - DWORD dwVideoPortID; // Video port ID (0 - (dwMaxVideoPorts -1)) - DWORD dwReserved1; // Reserved for future use - set to zero (struct padding) - DDVIDEOPORTCONNECT VideoPortType; // Description of video port connection - ULONG_PTR dwReserved2; // Reserved for future use - set to zero - ULONG_PTR dwReserved3; // Reserved for future use - set to zero -} DDVIDEOPORTDESC; - - -/* - * DDVIDEOPORTINFO - */ -typedef struct _DDVIDEOPORTINFO -{ - DWORD dwSize; // Size of the structure - DWORD dwOriginX; // Placement of the video data within the surface. - DWORD dwOriginY; // Placement of the video data within the surface. - DWORD dwVPFlags; // Video port options - RECT rCrop; // Cropping rectangle (optional). - DWORD dwPrescaleWidth; // Determines pre-scaling/zooming in the X direction (optional). - DWORD dwPrescaleHeight; // Determines pre-scaling/zooming in the Y direction (optional). - LPDDPIXELFORMAT lpddpfInputFormat; // Video format written to the video port - LPDDPIXELFORMAT lpddpfVBIInputFormat; // Input format of the VBI data - LPDDPIXELFORMAT lpddpfVBIOutputFormat;// Output format of the data - DWORD dwVBIHeight; // Specifies the number of lines of data within the vertical blanking interval. - ULONG_PTR dwReserved1; // Reserved for future use - set to zero - ULONG_PTR dwReserved2; // Reserved for future use - set to zero -} DDVIDEOPORTINFO; - - -/* - * DDVIDEOPORTBANDWIDTH - */ -typedef struct _DDVIDEOPORTBANDWIDTH -{ - DWORD dwSize; // Size of the structure - DWORD dwCaps; - DWORD dwOverlay; // Zoom factor at which overlay is supported - DWORD dwColorkey; // Zoom factor at which overlay w/ colorkey is supported - DWORD dwYInterpolate; // Zoom factor at which overlay w/ Y interpolation is supported - DWORD dwYInterpAndColorkey; // Zoom factor at which ovelray w/ Y interpolation and colorkeying is supported - ULONG_PTR dwReserved1; // Reserved for future use - set to zero - ULONG_PTR dwReserved2; // Reserved for future use - set to zero -} DDVIDEOPORTBANDWIDTH; - - -/* - * DDVIDEOPORTSTATUS - */ -typedef struct _DDVIDEOPORTSTATUS -{ - DWORD dwSize; // Size of the structure - BOOL bInUse; // TRUE if video port is currently being used - DWORD dwFlags; // Currently not used - DWORD dwReserved1; // Reserved for future use - DDVIDEOPORTCONNECT VideoPortType; // Information about the connection - ULONG_PTR dwReserved2; // Reserved for future use - ULONG_PTR dwReserved3; // Reserved for future use -} DDVIDEOPORTSTATUS; - -/* - * DDVIDEOPORTNOTIFY - */ -typedef struct _DDVIDEOPORTNOTIFY -{ - LARGE_INTEGER ApproximateTimeStamp; // Timestamp in the event notification - LONG lField; // 0 if even, 1 if odd, -1 if unknown - UINT dwSurfaceIndex; // Index in the surface chain of the surface that received the sample - LONG lDone; // Call InterlockedIncrement on this when done with sample -} DDVIDEOPORTNOTIFY; - - -/*============================================================================ - * - * Video Port Flags - * - * All flags are bit flags. - * - *==========================================================================*/ - -/**************************************************************************** - * - * VIDEOPORT DDVIDEOPORTCONNECT FLAGS - * - ****************************************************************************/ - -/* - * When this is set by the driver and passed to the client, this - * indicates that the video port is capable of double clocking the data. - * When this is set by the client, this indicates that the video port - * should enable double clocking. This flag is only valid with external - * syncs. - */ -#define DDVPCONNECT_DOUBLECLOCK 0x00000001l - -/* - * When this is set by the driver and passed to the client, this - * indicates that the video port is capable of using an external VACT - * signal. When this is set by the client, this indicates that the - * video port should use the external VACT signal. - */ -#define DDVPCONNECT_VACT 0x00000002l - -/* - * When this is set by the driver and passed to the client, this - * indicates that the video port is capable of treating even fields - * like odd fields and visa versa. When this is set by the client, - * this indicates that the video port should treat even fields like odd - * fields. - */ -#define DDVPCONNECT_INVERTPOLARITY 0x00000004l - -/* - * Indicates that any data written to the video port during the VREF - * period will not be written into the frame buffer. This flag is read only. - */ -#define DDVPCONNECT_DISCARDSVREFDATA 0x00000008l - -/* - * When this is set be the driver and passed to the client, this - * indicates that the device will write half lines into the frame buffer - * if half lines are provided by the decoder. If this is set by the client, - * this indicates that the decoder will be supplying half lines. - */ -#define DDVPCONNECT_HALFLINE 0x00000010l - -/* - * Indicates that the signal is interlaced. This flag is only - * set by the client. - */ -#define DDVPCONNECT_INTERLACED 0x00000020l - -/* - * Indicates that video port is shareable and that this video port - * will use the even fields. This flag is only set by the client. - */ -#define DDVPCONNECT_SHAREEVEN 0x00000040l - -/* - * Indicates that video port is shareable and that this video port - * will use the odd fields. This flag is only set by the client. - */ -#define DDVPCONNECT_SHAREODD 0x00000080l - -/**************************************************************************** - * - * VIDEOPORT DDVIDEOPORTDESC CAPS - * - ****************************************************************************/ - -/* - * Flip can be performed automatically to avoid tearing. - */ -#define DDVPCAPS_AUTOFLIP 0x00000001l - -/* - * Supports interlaced video - */ -#define DDVPCAPS_INTERLACED 0x00000002l - -/* - * Supports non-interlaced video - */ -#define DDVPCAPS_NONINTERLACED 0x00000004l - -/* - * Indicates that the device can return whether the current field - * of an interlaced signal is even or odd. - */ -#define DDVPCAPS_READBACKFIELD 0x00000008l - -/* - * Indicates that the device can return the current line of video - * being written into the frame buffer. - */ -#define DDVPCAPS_READBACKLINE 0x00000010l - -/* - * Allows two gen-locked video streams to share a single video port, - * where one stream uses the even fields and the other uses the odd - * fields. Separate parameters (including address, scaling, - * cropping, etc.) are maintained for both fields.) - */ -#define DDVPCAPS_SHAREABLE 0x00000020l - -/* - * Even fields of video can be automatically discarded. - */ -#define DDVPCAPS_SKIPEVENFIELDS 0x00000040l - -/* - * Odd fields of video can be automatically discarded. - */ -#define DDVPCAPS_SKIPODDFIELDS 0x00000080l - -/* - * Indicates that the device is capable of driving the graphics - * VSYNC with the video port VSYNC. - */ -#define DDVPCAPS_SYNCMASTER 0x00000100l - -/* - * Indicates that data within the vertical blanking interval can - * be written to a different surface. - */ -#define DDVPCAPS_VBISURFACE 0x00000200l - -/* - * Indicates that the video port can perform color operations - * on the incoming data before it is written to the frame buffer. - */ -#define DDVPCAPS_COLORCONTROL 0x00000400l - -/* - * Indicates that the video port can accept VBI data in a different - * width or format than the regular video data. - */ -#define DDVPCAPS_OVERSAMPLEDVBI 0x00000800l - -/* - * Indicates that the video port can write data directly to system memory - */ -#define DDVPCAPS_SYSTEMMEMORY 0x00001000l - -/* - * Indicates that the VBI and video portions of the video stream can - * be controlled by an independent processes. - */ -#define DDVPCAPS_VBIANDVIDEOINDEPENDENT 0x00002000l - -/* - * Indicates that the video port contains high quality hardware - * de-interlacing hardware that should be used instead of the - * bob/weave algorithms. - */ -#define DDVPCAPS_HARDWAREDEINTERLACE 0x00004000l - - -/**************************************************************************** - * - * VIDEOPORT DDVIDEOPORTDESC FX - * - ****************************************************************************/ - -/* - * Limited cropping is available to crop out the vertical interval data. - */ -#define DDVPFX_CROPTOPDATA 0x00000001l - -/* - * Incoming data can be cropped in the X direction before it is written - * to the surface. - */ -#define DDVPFX_CROPX 0x00000002l - -/* - * Incoming data can be cropped in the Y direction before it is written - * to the surface. - */ -#define DDVPFX_CROPY 0x00000004l - -/* - * Supports interleaving interlaced fields in memory. - */ -#define DDVPFX_INTERLEAVE 0x00000008l - -/* - * Supports mirroring left to right as the video data is written - * into the frame buffer. - */ -#define DDVPFX_MIRRORLEFTRIGHT 0x00000010l - -/* - * Supports mirroring top to bottom as the video data is written - * into the frame buffer. - */ -#define DDVPFX_MIRRORUPDOWN 0x00000020l - -/* - * Data can be arbitrarily shrunk in the X direction before it - * is written to the surface. - */ -#define DDVPFX_PRESHRINKX 0x00000040l - -/* - * Data can be arbitrarily shrunk in the Y direction before it - * is written to the surface. - */ -#define DDVPFX_PRESHRINKY 0x00000080l - -/* - * Data can be binary shrunk (1/2, 1/4, 1/8, etc.) in the X - * direction before it is written to the surface. - */ -#define DDVPFX_PRESHRINKXB 0x00000100l - -/* - * Data can be binary shrunk (1/2, 1/4, 1/8, etc.) in the Y - * direction before it is written to the surface. - */ -#define DDVPFX_PRESHRINKYB 0x00000200l - -/* - * Data can be shrunk in increments of 1/x in the X direction - * (where X is specified in the DDVIDEOPORTCAPS.dwPreshrinkXStep) - * before it is written to the surface. - */ -#define DDVPFX_PRESHRINKXS 0x00000400l - -/* - * Data can be shrunk in increments of 1/x in the Y direction - * (where X is specified in the DDVIDEOPORTCAPS.dwPreshrinkYStep) - * before it is written to the surface. - */ -#define DDVPFX_PRESHRINKYS 0x00000800l - -/* - * Data can be arbitrarily stretched in the X direction before - * it is written to the surface. - */ -#define DDVPFX_PRESTRETCHX 0x00001000l - -/* - * Data can be arbitrarily stretched in the Y direction before - * it is written to the surface. - */ -#define DDVPFX_PRESTRETCHY 0x00002000l - -/* - * Data can be integer stretched in the X direction before it is - * written to the surface. - */ -#define DDVPFX_PRESTRETCHXN 0x00004000l - -/* - * Data can be integer stretched in the Y direction before it is - * written to the surface. - */ -#define DDVPFX_PRESTRETCHYN 0x00008000l - -/* - * Indicates that data within the vertical blanking interval can - * be converted independently of the remaining video data. - */ -#define DDVPFX_VBICONVERT 0x00010000l - -/* - * Indicates that scaling can be disabled for data within the - * vertical blanking interval. - */ -#define DDVPFX_VBINOSCALE 0x00020000l - -/* - * Indicates that the video data can ignore the left and right - * cropping coordinates when cropping oversampled VBI data. - */ -#define DDVPFX_IGNOREVBIXCROP 0x00040000l - -/* - * Indicates that interleaving can be disabled for data within the - * vertical blanking interval. - */ -#define DDVPFX_VBINOINTERLEAVE 0x00080000l - - -/**************************************************************************** - * - * VIDEOPORT DDVIDEOPORTINFO FLAGS - * - ****************************************************************************/ - -/* - * Perform automatic flipping. Auto-flipping is performed between - * the overlay surface that was attached to the video port using - * IDirectDrawVideoPort::AttachSurface and the overlay surfaces that - * are attached to the surface via the IDirectDrawSurface::AttachSurface - * method. The flip order is the order in which the overlay surfaces - * were. attached. - */ -#define DDVP_AUTOFLIP 0x00000001l - -/* - * Perform conversion using the ddpfOutputFormat information. - */ -#define DDVP_CONVERT 0x00000002l - -/* - * Perform cropping using the specified rectangle. - */ -#define DDVP_CROP 0x00000004l - -/* - * Indicates that interlaced fields should be interleaved in memory. - */ -#define DDVP_INTERLEAVE 0x00000008l - -/* - * Indicates that the data should be mirrored left to right as it's - * written into the frame buffer. - */ -#define DDVP_MIRRORLEFTRIGHT 0x00000010l - -/* - * Indicates that the data should be mirrored top to bottom as it's - * written into the frame buffer. - */ -#define DDVP_MIRRORUPDOWN 0x00000020l - -/* - * Perform pre-scaling/zooming based on the pre-scale parameters. - */ -#define DDVP_PRESCALE 0x00000040l - -/* - * Ignore input of even fields. - */ -#define DDVP_SKIPEVENFIELDS 0x00000080l - -/* - * Ignore input of odd fields. - */ -#define DDVP_SKIPODDFIELDS 0x00000100l - -/* - * Drive the graphics VSYNCs using the video port VYSNCs. - */ -#define DDVP_SYNCMASTER 0x00000200l - -/* - * The ddpfVBIOutputFormatFormat member contains data that should be used - * to convert the data within the vertical blanking interval. - */ -#define DDVP_VBICONVERT 0x00000400l - -/* - * Indicates that data within the vertical blanking interval - * should not be scaled. - */ -#define DDVP_VBINOSCALE 0x00000800l - -/* - * Indicates that these bob/weave decisions should not be - * overriden by other interfaces. - */ -#define DDVP_OVERRIDEBOBWEAVE 0x00001000l - -/* - * Indicates that the video data should ignore the left and right - * cropping coordinates when cropping the VBI data. - */ -#define DDVP_IGNOREVBIXCROP 0x00002000l - -/* - * Indicates that interleaving can be disabled for data within the - * vertical blanking interval. - */ -#define DDVP_VBINOINTERLEAVE 0x00004000l - -/* - * Indicates that the video port should use the hardware - * de-interlacing hardware. - */ -#define DDVP_HARDWAREDEINTERLACE 0x00008000l - -/**************************************************************************** - * - * DIRIRECTDRAWVIDEOPORT GETINPUTFORMAT/GETOUTPUTFORMAT FLAGS - * - ****************************************************************************/ - -/* - * Return formats for the video data - */ -#define DDVPFORMAT_VIDEO 0x00000001l - -/* - * Return formats for the VBI data - */ -#define DDVPFORMAT_VBI 0x00000002l - -/**************************************************************************** - * - * DIRIRECTDRAWVIDEOPORT SETTARGETSURFACE FLAGS - * - ****************************************************************************/ - -/* - * Surface should receive video data (and VBI data if a surface - * is not explicitly attached for that purpose) - */ -#define DDVPTARGET_VIDEO 0x00000001l - -/* - * Surface should receive VBI data - */ -#define DDVPTARGET_VBI 0x00000002l - - -/**************************************************************************** - * - * DIRIRECTDRAWVIDEOPORT WAITFORSYNC FLAGS - * - ****************************************************************************/ - -/* - * Waits until the beginning of the next VSYNC - */ -#define DDVPWAIT_BEGIN 0x00000001l - -/* - * Waits until the end of the next/current VSYNC - */ -#define DDVPWAIT_END 0x00000002l - -/* - * Waits until the beginning of the specified line - */ -#define DDVPWAIT_LINE 0x00000003l - -/**************************************************************************** - * - * DIRECTDRAWVIDEOPORT FLIP FLAGS - * - ****************************************************************************/ - -/* - * Flips the normal video surface - */ -#define DDVPFLIP_VIDEO 0x00000001l - -/* - * Flips the VBI surface - */ -#define DDVPFLIP_VBI 0x00000002l - -/**************************************************************************** - * - * DIRIRECTDRAWVIDEOPORT GETVIDEOSIGNALSTATUS VALUES - * - ****************************************************************************/ - -/* - * No video signal is present at the video port - */ -#define DDVPSQ_NOSIGNAL 0x00000001l - -/* - * A valid video signal is present at the video port - */ -#define DDVPSQ_SIGNALOK 0x00000002l - -/**************************************************************************** - * - * VIDEOPORTBANDWIDTH Flags - * - ****************************************************************************/ - -/* - * The specified height/width refer to the size of the video port data - * written into memory, after prescaling has occured. - */ -#define DDVPB_VIDEOPORT 0x00000001l - -/* - * The specified height/width refer to the source size of the overlay. - */ -#define DDVPB_OVERLAY 0x00000002l - -/* - * This is a query for the device to return which caps this device requires. - */ -#define DDVPB_TYPE 0x00000004l - -/**************************************************************************** - * - * VIDEOPORTBANDWIDTH Caps - * - ****************************************************************************/ - -/* - * The bandwidth for this device is dependant on the overlay source size. - */ -#define DDVPBCAPS_SOURCE 0x00000001l - -/* - * The bandwidth for this device is dependant on the overlay destination - * size. - */ -#define DDVPBCAPS_DESTINATION 0x00000002l - -/**************************************************************************** - * - * DDVIDEOPORTCONTAINER CreateVideoPort flags - * - ****************************************************************************/ - -/* - * The process only wants to control the VBI portion of the video stream. - */ -#define DDVPCREATE_VBIONLY 0x00000001l - -/* - * The process only wants to control the non-VBI (video) portion of - * the video stream. - */ -#define DDVPCREATE_VIDEOONLY 0x00000002l - -/**************************************************************************** - * - * DDVIDEOPORTSTATUS flags - * - ****************************************************************************/ - -/* - * The video port interface is only controlling the VBI portion of the - * video stream - */ -#define DDVPSTATUS_VBIONLY 0x00000001l - -/* - * The video port interface is only controlling the video portion of the - * video stream - */ -#define DDVPSTATUS_VIDEOONLY 0x00000002l - - -#ifdef __cplusplus -}; -#endif - -#endif // GUID_DEFS_ONLY - -#endif - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: dvp.h + * Content: DirectDrawVideoPort include file + * + ***************************************************************************/ + +#ifndef __DVP_INCLUDED__ +#define __DVP_INCLUDED__ + +/* + * GUIDS used by DirectDrawVideoPort objects + */ +#if defined( _WIN32 ) && (!defined( _NO_COM ) || defined( DEFINE_GUID )) +DEFINE_GUID( IID_IDDVideoPortContainer, 0x6C142760,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); +DEFINE_GUID( IID_IDirectDrawVideoPort, 0xB36D93E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 ); +DEFINE_GUID( IID_IDirectDrawVideoPortNotify, 0xA655FB94,0x0589,0x4E57,0xB3,0x33,0x56,0x7A,0x89,0x46,0x8C,0x88); + + + +DEFINE_GUID( DDVPTYPE_E_HREFH_VREFH, 0x54F39980L,0xDA60,0x11CF,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8); +DEFINE_GUID( DDVPTYPE_E_HREFH_VREFL, 0x92783220L,0xDA60,0x11CF,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8); +DEFINE_GUID( DDVPTYPE_E_HREFL_VREFH, 0xA07A02E0L,0xDA60,0x11CF,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8); +DEFINE_GUID( DDVPTYPE_E_HREFL_VREFL, 0xE09C77E0L,0xDA60,0x11CF,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8); +DEFINE_GUID( DDVPTYPE_CCIR656, 0xFCA326A0L,0xDA60,0x11CF,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8); +DEFINE_GUID( DDVPTYPE_BROOKTREE, 0x1352A560L,0xDA61,0x11CF,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8); +DEFINE_GUID( DDVPTYPE_PHILIPS, 0x332CF160L,0xDA61,0x11CF,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8); +#endif + +#ifndef GUID_DEFS_ONLY + +#if defined( _WIN32 ) && !defined( _NO_COM ) +#define COM_NO_WINDOWS_H +#include +#else +#define IUnknown void +#endif + +/* + * These definitions are required to allow polymorphic structure members (i.e. those + * that are referred to both as DWORDs and as pointers) to resolve into a type + * of correct size to hold the largest of those two types (i.e. pointer) on 64 bit + * systems. For 32 bit environments, ULONG_PTR resolves to a DWORD. + */ +#ifndef MAXULONG_PTR +#define ULONG_PTR DWORD +#endif //MAXULONG_PTR + +#ifdef __cplusplus +extern "C" { +#endif + +/*============================================================================ + * + * DirectDraw Structures + * + * Various structures used to invoke DirectDraw. + * + *==========================================================================*/ + +struct IDirectDraw; +struct IDirectDrawSurface; +struct IDirectDrawPalette; +struct IDirectDrawClipper; + +typedef struct IDDVideoPortContainer FAR *LPDDVIDEOPORTCONTAINER; +typedef struct IDirectDrawVideoPort FAR *LPDIRECTDRAWVIDEOPORT; +typedef struct IDirectDrawVideoPortNotify FAR *LPDIRECTDRAWVIDEOPORTNOTIFY; + +typedef struct _DDVIDEOPORTCONNECT FAR *LPDDVIDEOPORTCONNECT; +typedef struct _DDVIDEOPORTCAPS FAR *LPDDVIDEOPORTCAPS; +typedef struct _DDVIDEOPORTDESC FAR *LPDDVIDEOPORTDESC; +typedef struct _DDVIDEOPORTINFO FAR *LPDDVIDEOPORTINFO; +typedef struct _DDVIDEOPORTBANDWIDTH FAR *LPDDVIDEOPORTBANDWIDTH; +typedef struct _DDVIDEOPORTSTATUS FAR *LPDDVIDEOPORTSTATUS; +typedef struct _DDVIDEOPORTNOTIFY FAR *LPDDVIDEOPORTNOTIFY; + +typedef struct IDDVideoPortContainerVtbl DDVIDEOPORTCONTAINERCALLBACKS; +typedef struct IDirectDrawVideoPortVtbl DIRECTDRAWVIDEOPORTCALLBACKS; +typedef struct IDirectDrawVideoPortNotifyVtbl DIRECTDRAWVIDEOPORTNOTIFYCALLBACKS; + + +/* + * API's + */ +typedef HRESULT (FAR PASCAL * LPDDENUMVIDEOCALLBACK)(LPDDVIDEOPORTCAPS, LPVOID); + + +/* + * INTERACES FOLLOW: + * IDirectDrawVideoPort + * IVideoPort + */ + +/* + * IDirectDrawVideoPortContainer + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDDVideoPortContainer +DECLARE_INTERFACE_( IDDVideoPortContainer, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawVideoPort methods ***/ + STDMETHOD(CreateVideoPort)(THIS_ DWORD, LPDDVIDEOPORTDESC, LPDIRECTDRAWVIDEOPORT FAR *, IUnknown FAR *) PURE; + STDMETHOD(EnumVideoPorts)(THIS_ DWORD, LPDDVIDEOPORTCAPS, LPVOID,LPDDENUMVIDEOCALLBACK ) PURE; + STDMETHOD(GetVideoPortConnectInfo)(THIS_ DWORD, LPDWORD, LPDDVIDEOPORTCONNECT ) PURE; + STDMETHOD(QueryVideoPortStatus)(THIS_ DWORD, LPDDVIDEOPORTSTATUS ) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IVideoPortContainer_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IVideoPortContainer_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IVideoPortContainer_Release(p) (p)->lpVtbl->Release(p) +#define IVideoPortContainer_CreateVideoPort(p, a, b, c, d) (p)->lpVtbl->CreateVideoPort(p, a, b, c, d) +#define IVideoPortContainer_EnumVideoPorts(p, a, b, c, d) (p)->lpVtbl->EnumVideoPorts(p, a, b, c, d) +#define IVideoPortContainer_GetVideoPortConnectInfo(p, a, b, c) (p)->lpVtbl->GetVideoPortConnectInfo(p, a, b, c) +#define IVideoPortContainer_QueryVideoPortStatus(p, a, b) (p)->lpVtbl->QueryVideoPortStatus(p, a, b) +#else +#define IVideoPortContainer_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IVideoPortContainer_AddRef(p) (p)->AddRef() +#define IVideoPortContainer_Release(p) (p)->Release() +#define IVideoPortContainer_CreateVideoPort(p, a, b, c, d) (p)->CreateVideoPort(a, b, c, d) +#define IVideoPortContainer_EnumVideoPorts(p, a, b, c, d) (p)->EnumVideoPorts(a, b, c, d) +#define IVideoPortContainer_GetVideoPortConnectInfo(p, a, b, c) (p)->GetVideoPortConnectInfo(a, b, c) +#define IVideoPortContainer_QueryVideoPortStatus(p, a, b) (p)->QueryVideoPortStatus(a, b) +#endif + +#endif + + +/* + * IDirectDrawVideoPort + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawVideoPort +DECLARE_INTERFACE_( IDirectDrawVideoPort, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IVideoPort methods ***/ + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE, DWORD) PURE; + STDMETHOD(GetBandwidthInfo)(THIS_ LPDDPIXELFORMAT, DWORD, DWORD, DWORD, LPDDVIDEOPORTBANDWIDTH) PURE; + STDMETHOD(GetColorControls)(THIS_ LPDDCOLORCONTROL) PURE; + STDMETHOD(GetInputFormats)(THIS_ LPDWORD, LPDDPIXELFORMAT, DWORD) PURE; + STDMETHOD(GetOutputFormats)(THIS_ LPDDPIXELFORMAT, LPDWORD, LPDDPIXELFORMAT, DWORD) PURE; + STDMETHOD(GetFieldPolarity)(THIS_ LPBOOL) PURE; + STDMETHOD(GetVideoLine)(THIS_ LPDWORD) PURE; + STDMETHOD(GetVideoSignalStatus)(THIS_ LPDWORD) PURE; + STDMETHOD(SetColorControls)(THIS_ LPDDCOLORCONTROL) PURE; + STDMETHOD(SetTargetSurface)(THIS_ LPDIRECTDRAWSURFACE, DWORD) PURE; + STDMETHOD(StartVideo)(THIS_ LPDDVIDEOPORTINFO) PURE; + STDMETHOD(StopVideo)(THIS) PURE; + STDMETHOD(UpdateVideo)(THIS_ LPDDVIDEOPORTINFO) PURE; + STDMETHOD(WaitForSync)(THIS_ DWORD, DWORD, DWORD) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IVideoPort_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IVideoPort_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IVideoPort_Release(p) (p)->lpVtbl->Release(p) +#define IVideoPort_SetTargetSurface(p,a,b) (p)->lpVtbl->SetTargetSurface(p,a,b) +#define IVideoPort_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IVideoPort_GetBandwidthInfo(p,a,b,c,d,e) (p)->lpVtbl->GetBandwidthInfo(p,a,b,c,d,e) +#define IVideoPort_GetColorControls(p,a) (p)->lpVtbl->GetColorControls(p,a) +#define IVideoPort_GetInputFormats(p,a,b,c) (p)->lpVtbl->GetInputFormats(p,a,b,c) +#define IVideoPort_GetOutputFormats(p,a,b,c,d) (p)->lpVtbl->GetOutputFormats(p,a,b,c,d) +#define IVideoPort_GetFieldPolarity(p,a) (p)->lpVtbl->GetFieldPolarity(p,a) +#define IVideoPort_GetVideoLine(p,a) (p)->lpVtbl->GetVideoLine(p,a) +#define IVideoPort_GetVideoSignalStatus(p,a) (p)->lpVtbl->GetVideoSignalStatus(p,a) +#define IVideoPort_SetColorControls(p,a) (p)->lpVtbl->SetColorControls(p,a) +#define IVideoPort_StartVideo(p,a) (p)->lpVtbl->StartVideo(p,a) +#define IVideoPort_StopVideo(p) (p)->lpVtbl->StopVideo(p) +#define IVideoPort_UpdateVideo(p,a) (p)->lpVtbl->UpdateVideo(p,a) +#define IVideoPort_WaitForSync(p,a,b,c) (p)->lpVtbl->WaitForSync(p,a,b,c) +#else +#define IVideoPort_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IVideoPort_AddRef(p) (p)->AddRef() +#define IVideoPort_Release(p) (p)->Release() +#define IVideoPort_SetTargetSurface(p,a,b) (p)->SetTargetSurface(a,b) +#define IVideoPort_Flip(p,a,b) (p)->Flip(a,b) +#define IVideoPort_GetBandwidthInfo(p,a,b,c,d,e) (p)->GetBandwidthInfo(a,b,c,d,e) +#define IVideoPort_GetColorControls(p,a) (p)->GetColorControls(a) +#define IVideoPort_GetInputFormats(p,a,b,c) (p)->GetInputFormats(a,b,c) +#define IVideoPort_GetOutputFormats(p,a,b,c,d) (p)->GetOutputFormats(a,b,c,d) +#define IVideoPort_GetFieldPolarity(p,a) (p)->GetFieldPolarity(a) +#define IVideoPort_GetVideoLine(p,a) (p)->GetVideoLine(a) +#define IVideoPort_GetVideoSignalStatus(p,a) (p)->GetVideoSignalStatus(a) +#define IVideoPort_SetColorControls(p,a) (p)->SetColorControls(a) +#define IVideoPort_StartVideo(p,a) (p)->StartVideo(a) +#define IVideoPort_StopVideo(p) (p)->StopVideo() +#define IVideoPort_UpdateVideo(p,a) (p)->UpdateVideo(a) +#define IVideoPort_WaitForSync(p,a,b,c) (p)->WaitForSync(a,b,c) +#endif + +#endif + +/* + * IDirectDrawVideoPort + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawVideoPortNotify +DECLARE_INTERFACE_( IDirectDrawVideoPortNotify, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IVideoPort methods ***/ + STDMETHOD(AcquireNotification)(THIS_ HANDLE *, LPDDVIDEOPORTNOTIFY) PURE; + STDMETHOD(ReleaseNotification)(THIS_ HANDLE) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IVideoPortNotify_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IVideoPortNotify_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IVideoPortNotify_Release(p) (p)->lpVtbl->Release(p) +#define IVideoPortNotify_AcquireNotification(p,a,b) (p)->lpVtbl->AcquireNotification(p,a,b) +#define IVideoPortNotify_ReleaseNotification(p,a) (p)->lpVtbl->ReleaseNotification(p,a) +#else +#define IVideoPortNotify_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IVideoPortNotify_AddRef(p) (p)->AddRef() +#define IVideoPortNotify_Release(p) (p)->Release() +#define IVideoPortNotify_AcquireNotification(p,a,b) (p)->lpVtbl->AcquireNotification(a,b) +#define IVideoPortNotify_ReleaseNotification(p,a) (p)->lpVtbl->ReleaseNotification(a) +#endif + +#endif + +/* + * DDVIDEOPORTCONNECT + */ +typedef struct _DDVIDEOPORTCONNECT +{ + DWORD dwSize; // size of the DDVIDEOPORTCONNECT structure + DWORD dwPortWidth; // Width of the video port + GUID guidTypeID; // Description of video port connection + DWORD dwFlags; // Connection flags + ULONG_PTR dwReserved1; // Reserved, set to zero. +} DDVIDEOPORTCONNECT; + + +/* + * DDVIDEOPORTCAPS + */ +typedef struct _DDVIDEOPORTCAPS +{ + DWORD dwSize; // size of the DDVIDEOPORTCAPS structure + DWORD dwFlags; // indicates which fields contain data + DWORD dwMaxWidth; // max width of the video port field + DWORD dwMaxVBIWidth; // max width of the VBI data + DWORD dwMaxHeight; // max height of the video port field + DWORD dwVideoPortID; // Video port ID (0 - (dwMaxVideoPorts -1)) + DWORD dwCaps; // Video port capabilities + DWORD dwFX; // More video port capabilities + DWORD dwNumAutoFlipSurfaces; // Max number of autoflippable surfaces allowed + DWORD dwAlignVideoPortBoundary; // Byte restriction of placement within the surface + DWORD dwAlignVideoPortPrescaleWidth;// Byte restriction of width after prescaling + DWORD dwAlignVideoPortCropBoundary; // Byte restriction of left cropping + DWORD dwAlignVideoPortCropWidth; // Byte restriction of cropping width + DWORD dwPreshrinkXStep; // Width can be shrunk in steps of 1/x + DWORD dwPreshrinkYStep; // Height can be shrunk in steps of 1/x + DWORD dwNumVBIAutoFlipSurfaces; // Max number of VBI autoflippable surfaces allowed + DWORD dwNumPreferredAutoflip; // Optimal number of autoflippable surfaces for hardware + WORD wNumFilterTapsX; // Number of taps the prescaler uses in the X direction (0 - no prescale, 1 - replication, etc.) + WORD wNumFilterTapsY; // Number of taps the prescaler uses in the Y direction (0 - no prescale, 1 - replication, etc.) +} DDVIDEOPORTCAPS; + +/* + * The dwMaxWidth and dwMaxVBIWidth members are valid + */ +#define DDVPD_WIDTH 0x00000001l + +/* + * The dwMaxHeight member is valid + */ +#define DDVPD_HEIGHT 0x00000002l + +/* + * The dwVideoPortID member is valid + */ +#define DDVPD_ID 0x00000004l + +/* + * The dwCaps member is valid + */ +#define DDVPD_CAPS 0x00000008l + +/* + * The dwFX member is valid + */ +#define DDVPD_FX 0x00000010l + +/* + * The dwNumAutoFlipSurfaces member is valid + */ +#define DDVPD_AUTOFLIP 0x00000020l + +/* + * All of the alignment members are valid + */ +#define DDVPD_ALIGN 0x00000040l + +/* + * The dwNumPreferredAutoflip member is valid + */ +#define DDVPD_PREFERREDAUTOFLIP 0x00000080l + +/* + * The wNumFilterTapsX and wNumFilterTapsY fields are valid + */ +#define DDVPD_FILTERQUALITY 0x00000100l + +/* + * DDVIDEOPORTDESC + */ +typedef struct _DDVIDEOPORTDESC +{ + DWORD dwSize; // size of the DDVIDEOPORTDESC structure + DWORD dwFieldWidth; // width of the video port field + DWORD dwVBIWidth; // width of the VBI data + DWORD dwFieldHeight; // height of the video port field + DWORD dwMicrosecondsPerField; // Microseconds per video field + DWORD dwMaxPixelsPerSecond; // Maximum pixel rate per second + DWORD dwVideoPortID; // Video port ID (0 - (dwMaxVideoPorts -1)) + DWORD dwReserved1; // Reserved for future use - set to zero (struct padding) + DDVIDEOPORTCONNECT VideoPortType; // Description of video port connection + ULONG_PTR dwReserved2; // Reserved for future use - set to zero + ULONG_PTR dwReserved3; // Reserved for future use - set to zero +} DDVIDEOPORTDESC; + + +/* + * DDVIDEOPORTINFO + */ +typedef struct _DDVIDEOPORTINFO +{ + DWORD dwSize; // Size of the structure + DWORD dwOriginX; // Placement of the video data within the surface. + DWORD dwOriginY; // Placement of the video data within the surface. + DWORD dwVPFlags; // Video port options + RECT rCrop; // Cropping rectangle (optional). + DWORD dwPrescaleWidth; // Determines pre-scaling/zooming in the X direction (optional). + DWORD dwPrescaleHeight; // Determines pre-scaling/zooming in the Y direction (optional). + LPDDPIXELFORMAT lpddpfInputFormat; // Video format written to the video port + LPDDPIXELFORMAT lpddpfVBIInputFormat; // Input format of the VBI data + LPDDPIXELFORMAT lpddpfVBIOutputFormat;// Output format of the data + DWORD dwVBIHeight; // Specifies the number of lines of data within the vertical blanking interval. + ULONG_PTR dwReserved1; // Reserved for future use - set to zero + ULONG_PTR dwReserved2; // Reserved for future use - set to zero +} DDVIDEOPORTINFO; + + +/* + * DDVIDEOPORTBANDWIDTH + */ +typedef struct _DDVIDEOPORTBANDWIDTH +{ + DWORD dwSize; // Size of the structure + DWORD dwCaps; + DWORD dwOverlay; // Zoom factor at which overlay is supported + DWORD dwColorkey; // Zoom factor at which overlay w/ colorkey is supported + DWORD dwYInterpolate; // Zoom factor at which overlay w/ Y interpolation is supported + DWORD dwYInterpAndColorkey; // Zoom factor at which ovelray w/ Y interpolation and colorkeying is supported + ULONG_PTR dwReserved1; // Reserved for future use - set to zero + ULONG_PTR dwReserved2; // Reserved for future use - set to zero +} DDVIDEOPORTBANDWIDTH; + + +/* + * DDVIDEOPORTSTATUS + */ +typedef struct _DDVIDEOPORTSTATUS +{ + DWORD dwSize; // Size of the structure + BOOL bInUse; // TRUE if video port is currently being used + DWORD dwFlags; // Currently not used + DWORD dwReserved1; // Reserved for future use + DDVIDEOPORTCONNECT VideoPortType; // Information about the connection + ULONG_PTR dwReserved2; // Reserved for future use + ULONG_PTR dwReserved3; // Reserved for future use +} DDVIDEOPORTSTATUS; + +/* + * DDVIDEOPORTNOTIFY + */ +typedef struct _DDVIDEOPORTNOTIFY +{ + LARGE_INTEGER ApproximateTimeStamp; // Timestamp in the event notification + LONG lField; // 0 if even, 1 if odd, -1 if unknown + UINT dwSurfaceIndex; // Index in the surface chain of the surface that received the sample + LONG lDone; // Call InterlockedIncrement on this when done with sample +} DDVIDEOPORTNOTIFY; + + +/*============================================================================ + * + * Video Port Flags + * + * All flags are bit flags. + * + *==========================================================================*/ + +/**************************************************************************** + * + * VIDEOPORT DDVIDEOPORTCONNECT FLAGS + * + ****************************************************************************/ + +/* + * When this is set by the driver and passed to the client, this + * indicates that the video port is capable of double clocking the data. + * When this is set by the client, this indicates that the video port + * should enable double clocking. This flag is only valid with external + * syncs. + */ +#define DDVPCONNECT_DOUBLECLOCK 0x00000001l + +/* + * When this is set by the driver and passed to the client, this + * indicates that the video port is capable of using an external VACT + * signal. When this is set by the client, this indicates that the + * video port should use the external VACT signal. + */ +#define DDVPCONNECT_VACT 0x00000002l + +/* + * When this is set by the driver and passed to the client, this + * indicates that the video port is capable of treating even fields + * like odd fields and visa versa. When this is set by the client, + * this indicates that the video port should treat even fields like odd + * fields. + */ +#define DDVPCONNECT_INVERTPOLARITY 0x00000004l + +/* + * Indicates that any data written to the video port during the VREF + * period will not be written into the frame buffer. This flag is read only. + */ +#define DDVPCONNECT_DISCARDSVREFDATA 0x00000008l + +/* + * When this is set be the driver and passed to the client, this + * indicates that the device will write half lines into the frame buffer + * if half lines are provided by the decoder. If this is set by the client, + * this indicates that the decoder will be supplying half lines. + */ +#define DDVPCONNECT_HALFLINE 0x00000010l + +/* + * Indicates that the signal is interlaced. This flag is only + * set by the client. + */ +#define DDVPCONNECT_INTERLACED 0x00000020l + +/* + * Indicates that video port is shareable and that this video port + * will use the even fields. This flag is only set by the client. + */ +#define DDVPCONNECT_SHAREEVEN 0x00000040l + +/* + * Indicates that video port is shareable and that this video port + * will use the odd fields. This flag is only set by the client. + */ +#define DDVPCONNECT_SHAREODD 0x00000080l + +/**************************************************************************** + * + * VIDEOPORT DDVIDEOPORTDESC CAPS + * + ****************************************************************************/ + +/* + * Flip can be performed automatically to avoid tearing. + */ +#define DDVPCAPS_AUTOFLIP 0x00000001l + +/* + * Supports interlaced video + */ +#define DDVPCAPS_INTERLACED 0x00000002l + +/* + * Supports non-interlaced video + */ +#define DDVPCAPS_NONINTERLACED 0x00000004l + +/* + * Indicates that the device can return whether the current field + * of an interlaced signal is even or odd. + */ +#define DDVPCAPS_READBACKFIELD 0x00000008l + +/* + * Indicates that the device can return the current line of video + * being written into the frame buffer. + */ +#define DDVPCAPS_READBACKLINE 0x00000010l + +/* + * Allows two gen-locked video streams to share a single video port, + * where one stream uses the even fields and the other uses the odd + * fields. Separate parameters (including address, scaling, + * cropping, etc.) are maintained for both fields.) + */ +#define DDVPCAPS_SHAREABLE 0x00000020l + +/* + * Even fields of video can be automatically discarded. + */ +#define DDVPCAPS_SKIPEVENFIELDS 0x00000040l + +/* + * Odd fields of video can be automatically discarded. + */ +#define DDVPCAPS_SKIPODDFIELDS 0x00000080l + +/* + * Indicates that the device is capable of driving the graphics + * VSYNC with the video port VSYNC. + */ +#define DDVPCAPS_SYNCMASTER 0x00000100l + +/* + * Indicates that data within the vertical blanking interval can + * be written to a different surface. + */ +#define DDVPCAPS_VBISURFACE 0x00000200l + +/* + * Indicates that the video port can perform color operations + * on the incoming data before it is written to the frame buffer. + */ +#define DDVPCAPS_COLORCONTROL 0x00000400l + +/* + * Indicates that the video port can accept VBI data in a different + * width or format than the regular video data. + */ +#define DDVPCAPS_OVERSAMPLEDVBI 0x00000800l + +/* + * Indicates that the video port can write data directly to system memory + */ +#define DDVPCAPS_SYSTEMMEMORY 0x00001000l + +/* + * Indicates that the VBI and video portions of the video stream can + * be controlled by an independent processes. + */ +#define DDVPCAPS_VBIANDVIDEOINDEPENDENT 0x00002000l + +/* + * Indicates that the video port contains high quality hardware + * de-interlacing hardware that should be used instead of the + * bob/weave algorithms. + */ +#define DDVPCAPS_HARDWAREDEINTERLACE 0x00004000l + + +/**************************************************************************** + * + * VIDEOPORT DDVIDEOPORTDESC FX + * + ****************************************************************************/ + +/* + * Limited cropping is available to crop out the vertical interval data. + */ +#define DDVPFX_CROPTOPDATA 0x00000001l + +/* + * Incoming data can be cropped in the X direction before it is written + * to the surface. + */ +#define DDVPFX_CROPX 0x00000002l + +/* + * Incoming data can be cropped in the Y direction before it is written + * to the surface. + */ +#define DDVPFX_CROPY 0x00000004l + +/* + * Supports interleaving interlaced fields in memory. + */ +#define DDVPFX_INTERLEAVE 0x00000008l + +/* + * Supports mirroring left to right as the video data is written + * into the frame buffer. + */ +#define DDVPFX_MIRRORLEFTRIGHT 0x00000010l + +/* + * Supports mirroring top to bottom as the video data is written + * into the frame buffer. + */ +#define DDVPFX_MIRRORUPDOWN 0x00000020l + +/* + * Data can be arbitrarily shrunk in the X direction before it + * is written to the surface. + */ +#define DDVPFX_PRESHRINKX 0x00000040l + +/* + * Data can be arbitrarily shrunk in the Y direction before it + * is written to the surface. + */ +#define DDVPFX_PRESHRINKY 0x00000080l + +/* + * Data can be binary shrunk (1/2, 1/4, 1/8, etc.) in the X + * direction before it is written to the surface. + */ +#define DDVPFX_PRESHRINKXB 0x00000100l + +/* + * Data can be binary shrunk (1/2, 1/4, 1/8, etc.) in the Y + * direction before it is written to the surface. + */ +#define DDVPFX_PRESHRINKYB 0x00000200l + +/* + * Data can be shrunk in increments of 1/x in the X direction + * (where X is specified in the DDVIDEOPORTCAPS.dwPreshrinkXStep) + * before it is written to the surface. + */ +#define DDVPFX_PRESHRINKXS 0x00000400l + +/* + * Data can be shrunk in increments of 1/x in the Y direction + * (where X is specified in the DDVIDEOPORTCAPS.dwPreshrinkYStep) + * before it is written to the surface. + */ +#define DDVPFX_PRESHRINKYS 0x00000800l + +/* + * Data can be arbitrarily stretched in the X direction before + * it is written to the surface. + */ +#define DDVPFX_PRESTRETCHX 0x00001000l + +/* + * Data can be arbitrarily stretched in the Y direction before + * it is written to the surface. + */ +#define DDVPFX_PRESTRETCHY 0x00002000l + +/* + * Data can be integer stretched in the X direction before it is + * written to the surface. + */ +#define DDVPFX_PRESTRETCHXN 0x00004000l + +/* + * Data can be integer stretched in the Y direction before it is + * written to the surface. + */ +#define DDVPFX_PRESTRETCHYN 0x00008000l + +/* + * Indicates that data within the vertical blanking interval can + * be converted independently of the remaining video data. + */ +#define DDVPFX_VBICONVERT 0x00010000l + +/* + * Indicates that scaling can be disabled for data within the + * vertical blanking interval. + */ +#define DDVPFX_VBINOSCALE 0x00020000l + +/* + * Indicates that the video data can ignore the left and right + * cropping coordinates when cropping oversampled VBI data. + */ +#define DDVPFX_IGNOREVBIXCROP 0x00040000l + +/* + * Indicates that interleaving can be disabled for data within the + * vertical blanking interval. + */ +#define DDVPFX_VBINOINTERLEAVE 0x00080000l + + +/**************************************************************************** + * + * VIDEOPORT DDVIDEOPORTINFO FLAGS + * + ****************************************************************************/ + +/* + * Perform automatic flipping. Auto-flipping is performed between + * the overlay surface that was attached to the video port using + * IDirectDrawVideoPort::AttachSurface and the overlay surfaces that + * are attached to the surface via the IDirectDrawSurface::AttachSurface + * method. The flip order is the order in which the overlay surfaces + * were. attached. + */ +#define DDVP_AUTOFLIP 0x00000001l + +/* + * Perform conversion using the ddpfOutputFormat information. + */ +#define DDVP_CONVERT 0x00000002l + +/* + * Perform cropping using the specified rectangle. + */ +#define DDVP_CROP 0x00000004l + +/* + * Indicates that interlaced fields should be interleaved in memory. + */ +#define DDVP_INTERLEAVE 0x00000008l + +/* + * Indicates that the data should be mirrored left to right as it's + * written into the frame buffer. + */ +#define DDVP_MIRRORLEFTRIGHT 0x00000010l + +/* + * Indicates that the data should be mirrored top to bottom as it's + * written into the frame buffer. + */ +#define DDVP_MIRRORUPDOWN 0x00000020l + +/* + * Perform pre-scaling/zooming based on the pre-scale parameters. + */ +#define DDVP_PRESCALE 0x00000040l + +/* + * Ignore input of even fields. + */ +#define DDVP_SKIPEVENFIELDS 0x00000080l + +/* + * Ignore input of odd fields. + */ +#define DDVP_SKIPODDFIELDS 0x00000100l + +/* + * Drive the graphics VSYNCs using the video port VYSNCs. + */ +#define DDVP_SYNCMASTER 0x00000200l + +/* + * The ddpfVBIOutputFormatFormat member contains data that should be used + * to convert the data within the vertical blanking interval. + */ +#define DDVP_VBICONVERT 0x00000400l + +/* + * Indicates that data within the vertical blanking interval + * should not be scaled. + */ +#define DDVP_VBINOSCALE 0x00000800l + +/* + * Indicates that these bob/weave decisions should not be + * overriden by other interfaces. + */ +#define DDVP_OVERRIDEBOBWEAVE 0x00001000l + +/* + * Indicates that the video data should ignore the left and right + * cropping coordinates when cropping the VBI data. + */ +#define DDVP_IGNOREVBIXCROP 0x00002000l + +/* + * Indicates that interleaving can be disabled for data within the + * vertical blanking interval. + */ +#define DDVP_VBINOINTERLEAVE 0x00004000l + +/* + * Indicates that the video port should use the hardware + * de-interlacing hardware. + */ +#define DDVP_HARDWAREDEINTERLACE 0x00008000l + +/**************************************************************************** + * + * DIRIRECTDRAWVIDEOPORT GETINPUTFORMAT/GETOUTPUTFORMAT FLAGS + * + ****************************************************************************/ + +/* + * Return formats for the video data + */ +#define DDVPFORMAT_VIDEO 0x00000001l + +/* + * Return formats for the VBI data + */ +#define DDVPFORMAT_VBI 0x00000002l + +/**************************************************************************** + * + * DIRIRECTDRAWVIDEOPORT SETTARGETSURFACE FLAGS + * + ****************************************************************************/ + +/* + * Surface should receive video data (and VBI data if a surface + * is not explicitly attached for that purpose) + */ +#define DDVPTARGET_VIDEO 0x00000001l + +/* + * Surface should receive VBI data + */ +#define DDVPTARGET_VBI 0x00000002l + + +/**************************************************************************** + * + * DIRIRECTDRAWVIDEOPORT WAITFORSYNC FLAGS + * + ****************************************************************************/ + +/* + * Waits until the beginning of the next VSYNC + */ +#define DDVPWAIT_BEGIN 0x00000001l + +/* + * Waits until the end of the next/current VSYNC + */ +#define DDVPWAIT_END 0x00000002l + +/* + * Waits until the beginning of the specified line + */ +#define DDVPWAIT_LINE 0x00000003l + +/**************************************************************************** + * + * DIRECTDRAWVIDEOPORT FLIP FLAGS + * + ****************************************************************************/ + +/* + * Flips the normal video surface + */ +#define DDVPFLIP_VIDEO 0x00000001l + +/* + * Flips the VBI surface + */ +#define DDVPFLIP_VBI 0x00000002l + +/**************************************************************************** + * + * DIRIRECTDRAWVIDEOPORT GETVIDEOSIGNALSTATUS VALUES + * + ****************************************************************************/ + +/* + * No video signal is present at the video port + */ +#define DDVPSQ_NOSIGNAL 0x00000001l + +/* + * A valid video signal is present at the video port + */ +#define DDVPSQ_SIGNALOK 0x00000002l + +/**************************************************************************** + * + * VIDEOPORTBANDWIDTH Flags + * + ****************************************************************************/ + +/* + * The specified height/width refer to the size of the video port data + * written into memory, after prescaling has occured. + */ +#define DDVPB_VIDEOPORT 0x00000001l + +/* + * The specified height/width refer to the source size of the overlay. + */ +#define DDVPB_OVERLAY 0x00000002l + +/* + * This is a query for the device to return which caps this device requires. + */ +#define DDVPB_TYPE 0x00000004l + +/**************************************************************************** + * + * VIDEOPORTBANDWIDTH Caps + * + ****************************************************************************/ + +/* + * The bandwidth for this device is dependant on the overlay source size. + */ +#define DDVPBCAPS_SOURCE 0x00000001l + +/* + * The bandwidth for this device is dependant on the overlay destination + * size. + */ +#define DDVPBCAPS_DESTINATION 0x00000002l + +/**************************************************************************** + * + * DDVIDEOPORTCONTAINER CreateVideoPort flags + * + ****************************************************************************/ + +/* + * The process only wants to control the VBI portion of the video stream. + */ +#define DDVPCREATE_VBIONLY 0x00000001l + +/* + * The process only wants to control the non-VBI (video) portion of + * the video stream. + */ +#define DDVPCREATE_VIDEOONLY 0x00000002l + +/**************************************************************************** + * + * DDVIDEOPORTSTATUS flags + * + ****************************************************************************/ + +/* + * The video port interface is only controlling the VBI portion of the + * video stream + */ +#define DDVPSTATUS_VBIONLY 0x00000001l + +/* + * The video port interface is only controlling the video portion of the + * video stream + */ +#define DDVPSTATUS_VIDEOONLY 0x00000002l + + +#ifdef __cplusplus +}; +#endif + +#endif // GUID_DEFS_ONLY + +#endif + diff --git a/src/dep/include/DXSDK/include/dx7todx8.h b/src/dep/include/DXSDK/include/dx7todx8.h index caaef28..a513d69 100644 --- a/src/dep/include/DXSDK/include/dx7todx8.h +++ b/src/dep/include/DXSDK/include/dx7todx8.h @@ -1,98 +1,98 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: dx7todx8.h - * Content: DX7 to DX8 Direct3D aliases to aid porting DX7 apps to DX8 - * - ***************************************************************************/ - -#ifndef _DX7TODX8_H_ - -/////////////////////////////////////////////////////////////////////////////// -// -// d3d8types.h -// -/////////////////////////////////////////////////////////////////////////////// - -#define D3DTRANSFORMSTATE_WORLD D3DTS_WORLD -#define D3DTRANSFORMSTATE_VIEW D3DTS_VIEW -#define D3DTRANSFORMSTATE_PROJECTION D3DTS_PROJECTION -#define D3DTRANSFORMSTATE_WORLD1 D3DTS_WORLD1 -#define D3DTRANSFORMSTATE_WORLD2 D3DTS_WORLD2 -#define D3DTRANSFORMSTATE_WORLD3 D3DTS_WORLD3 -#define D3DTRANSFORMSTATE_TEXTURE0 D3DTS_TEXTURE0 -#define D3DTRANSFORMSTATE_TEXTURE1 D3DTS_TEXTURE1 -#define D3DTRANSFORMSTATE_TEXTURE2 D3DTS_TEXTURE2 -#define D3DTRANSFORMSTATE_TEXTURE3 D3DTS_TEXTURE3 -#define D3DTRANSFORMSTATE_TEXTURE4 D3DTS_TEXTURE4 -#define D3DTRANSFORMSTATE_TEXTURE5 D3DTS_TEXTURE5 -#define D3DTRANSFORMSTATE_TEXTURE6 D3DTS_TEXTURE6 -#define D3DTRANSFORMSTATE_TEXTURE7 D3DTS_TEXTURE7 -#define D3DTRANSFORMSTATE_FORCE_DWORD D3DTS_FORCE_DWORD - -#define D3DRENDERSTATE_ZENABLE D3DRS_ZENABLE -#define D3DRENDERSTATE_FILLMODE D3DRS_FILLMODE -#define D3DRENDERSTATE_SHADEMODE D3DRS_SHADEMODE -#define D3DRENDERSTATE_LINEPATTERN D3DRS_LINEPATTERN -#define D3DRENDERSTATE_ZWRITEENABLE D3DRS_ZWRITEENABLE -#define D3DRENDERSTATE_ALPHATESTENABLE D3DRS_ALPHATESTENABLE -#define D3DRENDERSTATE_LASTPIXEL D3DRS_LASTPIXEL -#define D3DRENDERSTATE_SRCBLEND D3DRS_SRCBLEND -#define D3DRENDERSTATE_DESTBLEND D3DRS_DESTBLEND -#define D3DRENDERSTATE_CULLMODE D3DRS_CULLMODE -#define D3DRENDERSTATE_ZFUNC D3DRS_ZFUNC -#define D3DRENDERSTATE_ALPHAREF D3DRS_ALPHAREF -#define D3DRENDERSTATE_ALPHAFUNC D3DRS_ALPHAFUNC -#define D3DRENDERSTATE_DITHERENABLE D3DRS_DITHERENABLE -#define D3DRENDERSTATE_ALPHABLENDENABLE D3DRS_ALPHABLENDENABLE -#define D3DRENDERSTATE_FOGENABLE D3DRS_FOGENABLE -#define D3DRENDERSTATE_SPECULARENABLE D3DRS_SPECULARENABLE -#define D3DRENDERSTATE_ZVISIBLE D3DRS_ZVISIBLE -#define D3DRENDERSTATE_FOGCOLOR D3DRS_FOGCOLOR -#define D3DRENDERSTATE_FOGTABLEMODE D3DRS_FOGTABLEMODE -#define D3DRENDERSTATE_FOGSTART D3DRS_FOGSTART -#define D3DRENDERSTATE_FOGEND D3DRS_FOGEND -#define D3DRENDERSTATE_FOGDENSITY D3DRS_FOGDENSITY -#define D3DRENDERSTATE_EDGEANTIALIAS D3DRS_EDGEANTIALIAS -#define D3DRENDERSTATE_ZBIAS D3DRS_ZBIAS -#define D3DRENDERSTATE_RANGEFOGENABLE D3DRS_RANGEFOGENABLE -#define D3DRENDERSTATE_STENCILENABLE D3DRS_STENCILENABLE -#define D3DRENDERSTATE_STENCILFAIL D3DRS_STENCILFAIL -#define D3DRENDERSTATE_STENCILZFAIL D3DRS_STENCILZFAIL -#define D3DRENDERSTATE_STENCILPASS D3DRS_STENCILPASS -#define D3DRENDERSTATE_STENCILFUNC D3DRS_STENCILFUNC -#define D3DRENDERSTATE_STENCILREF D3DRS_STENCILREF -#define D3DRENDERSTATE_STENCILMASK D3DRS_STENCILMASK -#define D3DRENDERSTATE_STENCILWRITEMASK D3DRS_STENCILWRITEMASK -#define D3DRENDERSTATE_TEXTUREFACTOR D3DRS_TEXTUREFACTOR -#define D3DRENDERSTATE_WRAP0 D3DRS_WRAP0 -#define D3DRENDERSTATE_WRAP1 D3DRS_WRAP1 -#define D3DRENDERSTATE_WRAP2 D3DRS_WRAP2 -#define D3DRENDERSTATE_WRAP3 D3DRS_WRAP3 -#define D3DRENDERSTATE_WRAP4 D3DRS_WRAP4 -#define D3DRENDERSTATE_WRAP5 D3DRS_WRAP5 -#define D3DRENDERSTATE_WRAP6 D3DRS_WRAP6 -#define D3DRENDERSTATE_WRAP7 D3DRS_WRAP7 -#define D3DRENDERSTATE_CLIPPING D3DRS_CLIPPING -#define D3DRENDERSTATE_LIGHTING D3DRS_LIGHTING -#define D3DRENDERSTATE_EXTENTS D3DRS_EXTENTS -#define D3DRENDERSTATE_AMBIENT D3DRS_AMBIENT -#define D3DRENDERSTATE_FOGVERTEXMODE D3DRS_FOGVERTEXMODE -#define D3DRENDERSTATE_COLORVERTEX D3DRS_COLORVERTEX -#define D3DRENDERSTATE_LOCALVIEWER D3DRS_LOCALVIEWER -#define D3DRENDERSTATE_NORMALIZENORMALS D3DRS_NORMALIZENORMALS -#define D3DRENDERSTATE_DIFFUSEMATERIALSOURCE D3DRS_DIFFUSEMATERIALSOURCE -#define D3DRENDERSTATE_SPECULARMATERIALSOURCE D3DRS_SPECULARMATERIALSOURCE -#define D3DRENDERSTATE_AMBIENTMATERIALSOURCE D3DRS_AMBIENTMATERIALSOURCE -#define D3DRENDERSTATE_EMISSIVEMATERIALSOURCE D3DRS_EMISSIVEMATERIALSOURCE -#define D3DRENDERSTATE_VERTEXBLEND D3DRS_VERTEXBLEND -#define D3DRENDERSTATE_CLIPPLANEENABLE D3DRS_CLIPPLANEENABLE - -#define RGBA_MAKE D3DCOLOR_RGBA -#define RGB_MAKE D3DCOLOR_XRGB -#define D3DRGBA D3DCOLOR_COLORVALUE -#define D3DRGB(_r,_g,_b) D3DCOLOR_COLORVALUE(_r,_g,_b,1.f) - -#define _DX7TODX8_H_ -#endif //_DX7TODX8_H_ +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: dx7todx8.h + * Content: DX7 to DX8 Direct3D aliases to aid porting DX7 apps to DX8 + * + ***************************************************************************/ + +#ifndef _DX7TODX8_H_ + +/////////////////////////////////////////////////////////////////////////////// +// +// d3d8types.h +// +/////////////////////////////////////////////////////////////////////////////// + +#define D3DTRANSFORMSTATE_WORLD D3DTS_WORLD +#define D3DTRANSFORMSTATE_VIEW D3DTS_VIEW +#define D3DTRANSFORMSTATE_PROJECTION D3DTS_PROJECTION +#define D3DTRANSFORMSTATE_WORLD1 D3DTS_WORLD1 +#define D3DTRANSFORMSTATE_WORLD2 D3DTS_WORLD2 +#define D3DTRANSFORMSTATE_WORLD3 D3DTS_WORLD3 +#define D3DTRANSFORMSTATE_TEXTURE0 D3DTS_TEXTURE0 +#define D3DTRANSFORMSTATE_TEXTURE1 D3DTS_TEXTURE1 +#define D3DTRANSFORMSTATE_TEXTURE2 D3DTS_TEXTURE2 +#define D3DTRANSFORMSTATE_TEXTURE3 D3DTS_TEXTURE3 +#define D3DTRANSFORMSTATE_TEXTURE4 D3DTS_TEXTURE4 +#define D3DTRANSFORMSTATE_TEXTURE5 D3DTS_TEXTURE5 +#define D3DTRANSFORMSTATE_TEXTURE6 D3DTS_TEXTURE6 +#define D3DTRANSFORMSTATE_TEXTURE7 D3DTS_TEXTURE7 +#define D3DTRANSFORMSTATE_FORCE_DWORD D3DTS_FORCE_DWORD + +#define D3DRENDERSTATE_ZENABLE D3DRS_ZENABLE +#define D3DRENDERSTATE_FILLMODE D3DRS_FILLMODE +#define D3DRENDERSTATE_SHADEMODE D3DRS_SHADEMODE +#define D3DRENDERSTATE_LINEPATTERN D3DRS_LINEPATTERN +#define D3DRENDERSTATE_ZWRITEENABLE D3DRS_ZWRITEENABLE +#define D3DRENDERSTATE_ALPHATESTENABLE D3DRS_ALPHATESTENABLE +#define D3DRENDERSTATE_LASTPIXEL D3DRS_LASTPIXEL +#define D3DRENDERSTATE_SRCBLEND D3DRS_SRCBLEND +#define D3DRENDERSTATE_DESTBLEND D3DRS_DESTBLEND +#define D3DRENDERSTATE_CULLMODE D3DRS_CULLMODE +#define D3DRENDERSTATE_ZFUNC D3DRS_ZFUNC +#define D3DRENDERSTATE_ALPHAREF D3DRS_ALPHAREF +#define D3DRENDERSTATE_ALPHAFUNC D3DRS_ALPHAFUNC +#define D3DRENDERSTATE_DITHERENABLE D3DRS_DITHERENABLE +#define D3DRENDERSTATE_ALPHABLENDENABLE D3DRS_ALPHABLENDENABLE +#define D3DRENDERSTATE_FOGENABLE D3DRS_FOGENABLE +#define D3DRENDERSTATE_SPECULARENABLE D3DRS_SPECULARENABLE +#define D3DRENDERSTATE_ZVISIBLE D3DRS_ZVISIBLE +#define D3DRENDERSTATE_FOGCOLOR D3DRS_FOGCOLOR +#define D3DRENDERSTATE_FOGTABLEMODE D3DRS_FOGTABLEMODE +#define D3DRENDERSTATE_FOGSTART D3DRS_FOGSTART +#define D3DRENDERSTATE_FOGEND D3DRS_FOGEND +#define D3DRENDERSTATE_FOGDENSITY D3DRS_FOGDENSITY +#define D3DRENDERSTATE_EDGEANTIALIAS D3DRS_EDGEANTIALIAS +#define D3DRENDERSTATE_ZBIAS D3DRS_ZBIAS +#define D3DRENDERSTATE_RANGEFOGENABLE D3DRS_RANGEFOGENABLE +#define D3DRENDERSTATE_STENCILENABLE D3DRS_STENCILENABLE +#define D3DRENDERSTATE_STENCILFAIL D3DRS_STENCILFAIL +#define D3DRENDERSTATE_STENCILZFAIL D3DRS_STENCILZFAIL +#define D3DRENDERSTATE_STENCILPASS D3DRS_STENCILPASS +#define D3DRENDERSTATE_STENCILFUNC D3DRS_STENCILFUNC +#define D3DRENDERSTATE_STENCILREF D3DRS_STENCILREF +#define D3DRENDERSTATE_STENCILMASK D3DRS_STENCILMASK +#define D3DRENDERSTATE_STENCILWRITEMASK D3DRS_STENCILWRITEMASK +#define D3DRENDERSTATE_TEXTUREFACTOR D3DRS_TEXTUREFACTOR +#define D3DRENDERSTATE_WRAP0 D3DRS_WRAP0 +#define D3DRENDERSTATE_WRAP1 D3DRS_WRAP1 +#define D3DRENDERSTATE_WRAP2 D3DRS_WRAP2 +#define D3DRENDERSTATE_WRAP3 D3DRS_WRAP3 +#define D3DRENDERSTATE_WRAP4 D3DRS_WRAP4 +#define D3DRENDERSTATE_WRAP5 D3DRS_WRAP5 +#define D3DRENDERSTATE_WRAP6 D3DRS_WRAP6 +#define D3DRENDERSTATE_WRAP7 D3DRS_WRAP7 +#define D3DRENDERSTATE_CLIPPING D3DRS_CLIPPING +#define D3DRENDERSTATE_LIGHTING D3DRS_LIGHTING +#define D3DRENDERSTATE_EXTENTS D3DRS_EXTENTS +#define D3DRENDERSTATE_AMBIENT D3DRS_AMBIENT +#define D3DRENDERSTATE_FOGVERTEXMODE D3DRS_FOGVERTEXMODE +#define D3DRENDERSTATE_COLORVERTEX D3DRS_COLORVERTEX +#define D3DRENDERSTATE_LOCALVIEWER D3DRS_LOCALVIEWER +#define D3DRENDERSTATE_NORMALIZENORMALS D3DRS_NORMALIZENORMALS +#define D3DRENDERSTATE_DIFFUSEMATERIALSOURCE D3DRS_DIFFUSEMATERIALSOURCE +#define D3DRENDERSTATE_SPECULARMATERIALSOURCE D3DRS_SPECULARMATERIALSOURCE +#define D3DRENDERSTATE_AMBIENTMATERIALSOURCE D3DRS_AMBIENTMATERIALSOURCE +#define D3DRENDERSTATE_EMISSIVEMATERIALSOURCE D3DRS_EMISSIVEMATERIALSOURCE +#define D3DRENDERSTATE_VERTEXBLEND D3DRS_VERTEXBLEND +#define D3DRENDERSTATE_CLIPPLANEENABLE D3DRS_CLIPPLANEENABLE + +#define RGBA_MAKE D3DCOLOR_RGBA +#define RGB_MAKE D3DCOLOR_XRGB +#define D3DRGBA D3DCOLOR_COLORVALUE +#define D3DRGB(_r,_g,_b) D3DCOLOR_COLORVALUE(_r,_g,_b,1.f) + +#define _DX7TODX8_H_ +#endif //_DX7TODX8_H_ diff --git a/src/dep/include/DXSDK/include/dxdiag.h b/src/dep/include/DXSDK/include/dxdiag.h index 54a535f..602c88f 100644 --- a/src/dep/include/DXSDK/include/dxdiag.h +++ b/src/dep/include/DXSDK/include/dxdiag.h @@ -1,187 +1,187 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: dxdiag.h - * Content: DirectX Diagnostic Tool include file - * - ****************************************************************************/ - -#ifndef _DXDIAG_H_ -#define _DXDIAG_H_ - -#include // for DECLARE_INTERFACE_ and HRESULT - -// This identifier is passed to IDxDiagProvider::Initialize in order to ensure that an -// application was built against the correct header files. This number is -// incremented whenever a header (or other) change would require applications -// to be rebuilt. If the version doesn't match, IDxDiagProvider::Initialize will fail. -// (The number itself has no meaning.) -#define DXDIAG_DX9_SDK_VERSION 111 - -#ifdef __cplusplus -extern "C" { -#endif - - -/**************************************************************************** - * - * DxDiag Errors - * - ****************************************************************************/ -#define DXDIAG_E_INSUFFICIENT_BUFFER ((HRESULT)0x8007007AL) // HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) - - -/**************************************************************************** - * - * DxDiag CLSIDs - * - ****************************************************************************/ - -// {A65B8071-3BFE-4213-9A5B-491DA4461CA7} -DEFINE_GUID(CLSID_DxDiagProvider, -0xA65B8071, 0x3BFE, 0x4213, 0x9A, 0x5B, 0x49, 0x1D, 0xA4, 0x46, 0x1C, 0xA7); - - -/**************************************************************************** - * - * DxDiag Interface IIDs - * - ****************************************************************************/ - -// {9C6B4CB0-23F8-49CC-A3ED-45A55000A6D2} -DEFINE_GUID(IID_IDxDiagProvider, -0x9C6B4CB0, 0x23F8, 0x49CC, 0xA3, 0xED, 0x45, 0xA5, 0x50, 0x00, 0xA6, 0xD2); - -// {0x7D0F462F-0x4064-0x4862-BC7F-933E5058C10F} -DEFINE_GUID(IID_IDxDiagContainer, -0x7D0F462F, 0x4064, 0x4862, 0xBC, 0x7F, 0x93, 0x3E, 0x50, 0x58, 0xC1, 0x0F); - - -/**************************************************************************** - * - * DxDiag Interface Pointer definitions - * - ****************************************************************************/ - -typedef struct IDxDiagProvider *LPDXDIAGPROVIDER, *PDXDIAGPROVIDER; - -typedef struct IDxDiagContainer *LPDXDIAGCONTAINER, *PDXDIAGCONTAINER; - - -/**************************************************************************** - * - * DxDiag Structures - * - ****************************************************************************/ - -typedef struct _DXDIAG_INIT_PARAMS -{ - DWORD dwSize; // Size of this structure. - DWORD dwDxDiagHeaderVersion; // Pass in DXDIAG_DX9_SDK_VERSION. This verifies - // the header and dll are correctly matched. - BOOL bAllowWHQLChecks; // If true, allow dxdiag to check if drivers are - // digital signed as logo'd by WHQL which may - // connect via internet to update WHQL certificates. - VOID* pReserved; // Reserved. Must be NULL. -} DXDIAG_INIT_PARAMS; - - -/**************************************************************************** - * - * DxDiag Application Interfaces - * - ****************************************************************************/ - -// -// COM definition for IDxDiagProvider -// -#undef INTERFACE // External COM Implementation -#define INTERFACE IDxDiagProvider -DECLARE_INTERFACE_(IDxDiagProvider,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /*** IDxDiagProvider methods ***/ - STDMETHOD(Initialize) (THIS_ DXDIAG_INIT_PARAMS* pParams) PURE; - STDMETHOD(GetRootContainer) (THIS_ IDxDiagContainer **ppInstance) PURE; -}; - - -// -// COM definition for IDxDiagContainer -// -#undef INTERFACE // External COM Implementation -#define INTERFACE IDxDiagContainer -DECLARE_INTERFACE_(IDxDiagContainer,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - /*** IDxDiagContainer methods ***/ - STDMETHOD(GetNumberOfChildContainers) (THIS_ DWORD *pdwCount) PURE; - STDMETHOD(EnumChildContainerNames) (THIS_ DWORD dwIndex, LPWSTR pwszContainer, DWORD cchContainer) PURE; - STDMETHOD(GetChildContainer) (THIS_ LPCWSTR pwszContainer, IDxDiagContainer **ppInstance) PURE; - STDMETHOD(GetNumberOfProps) (THIS_ DWORD *pdwCount) PURE; - STDMETHOD(EnumPropNames) (THIS_ DWORD dwIndex, LPWSTR pwszPropName, DWORD cchPropName) PURE; - STDMETHOD(GetProp) (THIS_ LPCWSTR pwszPropName, VARIANT *pvarProp) PURE; -}; - - -/**************************************************************************** - * - * DxDiag application interface macros - * - ****************************************************************************/ - -#if !defined(__cplusplus) || defined(CINTERFACE) - -#define IDxDiagProvider_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDxDiagProvider_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDxDiagProvider_Release(p) (p)->lpVtbl->Release(p) -#define IDxDiagProvider_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDxDiagProvider_GetRootContainer(p,a) (p)->lpVtbl->GetRootContainer(p,a) - -#define IDxDiagContainer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDxDiagContainer_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDxDiagContainer_Release(p) (p)->lpVtbl->Release(p) -#define IDxDiagContainer_GetNumberOfChildContainers(p,a) (p)->lpVtbl->GetNumberOfChildContainers(p,a) -#define IDxDiagContainer_EnumChildContainerNames(p,a,b,c) (p)->lpVtbl->EnumChildContainerNames(p,a,b,c) -#define IDxDiagContainer_GetChildContainer(p,a,b) (p)->lpVtbl->GetChildContainer(p,a,b) -#define IDxDiagContainer_GetNumberOfProps(p,a) (p)->lpVtbl->GetNumberOfProps(p,a) -#define IDxDiagContainer_EnumProps(p,a,b) (p)->lpVtbl->EnumProps(p,a,b,c) -#define IDxDiagContainer_GetProp(p,a,b) (p)->lpVtbl->GetProp(p,a,b) - -#else /* C++ */ - -#define IDxDiagProvider_QueryInterface(p,a,b) (p)->QueryInterface(p,a,b) -#define IDxDiagProvider_AddRef(p) (p)->AddRef(p) -#define IDxDiagProvider_Release(p) (p)->Release(p) -#define IDxDiagProvider_Initialize(p,a,b) (p)->Initialize(p,a,b) -#define IDxDiagProvider_GetRootContainer(p,a) (p)->GetRootContainer(p,a) - -#define IDxDiagContainer_QueryInterface(p,a,b) (p)->QueryInterface(p,a,b) -#define IDxDiagContainer_AddRef(p) (p)->AddRef(p) -#define IDxDiagContainer_Release(p) (p)->Release(p) -#define IDxDiagContainer_GetNumberOfChildContainers(p,a) (p)->GetNumberOfChildContainers(p,a) -#define IDxDiagContainer_EnumChildContainerNames(p,a,b,c) (p)->EnumChildContainerNames(p,a,b,c) -#define IDxDiagContainer_GetChildContainer(p,a,b) (p)->GetChildContainer(p,a,b) -#define IDxDiagContainer_GetNumberOfProps(p,a) (p)->GetNumberOfProps(p,a) -#define IDxDiagContainer_EnumProps(p,a,b) (p)->EnumProps(p,a,b,c) -#define IDxDiagContainer_GetProp(p,a,b) (p)->GetProp(p,a,b) - -#endif - - -#ifdef __cplusplus -} -#endif - -#endif /* _DXDIAG_H_ */ - - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: dxdiag.h + * Content: DirectX Diagnostic Tool include file + * + ****************************************************************************/ + +#ifndef _DXDIAG_H_ +#define _DXDIAG_H_ + +#include // for DECLARE_INTERFACE_ and HRESULT + +// This identifier is passed to IDxDiagProvider::Initialize in order to ensure that an +// application was built against the correct header files. This number is +// incremented whenever a header (or other) change would require applications +// to be rebuilt. If the version doesn't match, IDxDiagProvider::Initialize will fail. +// (The number itself has no meaning.) +#define DXDIAG_DX9_SDK_VERSION 111 + +#ifdef __cplusplus +extern "C" { +#endif + + +/**************************************************************************** + * + * DxDiag Errors + * + ****************************************************************************/ +#define DXDIAG_E_INSUFFICIENT_BUFFER ((HRESULT)0x8007007AL) // HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) + + +/**************************************************************************** + * + * DxDiag CLSIDs + * + ****************************************************************************/ + +// {A65B8071-3BFE-4213-9A5B-491DA4461CA7} +DEFINE_GUID(CLSID_DxDiagProvider, +0xA65B8071, 0x3BFE, 0x4213, 0x9A, 0x5B, 0x49, 0x1D, 0xA4, 0x46, 0x1C, 0xA7); + + +/**************************************************************************** + * + * DxDiag Interface IIDs + * + ****************************************************************************/ + +// {9C6B4CB0-23F8-49CC-A3ED-45A55000A6D2} +DEFINE_GUID(IID_IDxDiagProvider, +0x9C6B4CB0, 0x23F8, 0x49CC, 0xA3, 0xED, 0x45, 0xA5, 0x50, 0x00, 0xA6, 0xD2); + +// {0x7D0F462F-0x4064-0x4862-BC7F-933E5058C10F} +DEFINE_GUID(IID_IDxDiagContainer, +0x7D0F462F, 0x4064, 0x4862, 0xBC, 0x7F, 0x93, 0x3E, 0x50, 0x58, 0xC1, 0x0F); + + +/**************************************************************************** + * + * DxDiag Interface Pointer definitions + * + ****************************************************************************/ + +typedef struct IDxDiagProvider *LPDXDIAGPROVIDER, *PDXDIAGPROVIDER; + +typedef struct IDxDiagContainer *LPDXDIAGCONTAINER, *PDXDIAGCONTAINER; + + +/**************************************************************************** + * + * DxDiag Structures + * + ****************************************************************************/ + +typedef struct _DXDIAG_INIT_PARAMS +{ + DWORD dwSize; // Size of this structure. + DWORD dwDxDiagHeaderVersion; // Pass in DXDIAG_DX9_SDK_VERSION. This verifies + // the header and dll are correctly matched. + BOOL bAllowWHQLChecks; // If true, allow dxdiag to check if drivers are + // digital signed as logo'd by WHQL which may + // connect via internet to update WHQL certificates. + VOID* pReserved; // Reserved. Must be NULL. +} DXDIAG_INIT_PARAMS; + + +/**************************************************************************** + * + * DxDiag Application Interfaces + * + ****************************************************************************/ + +// +// COM definition for IDxDiagProvider +// +#undef INTERFACE // External COM Implementation +#define INTERFACE IDxDiagProvider +DECLARE_INTERFACE_(IDxDiagProvider,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /*** IDxDiagProvider methods ***/ + STDMETHOD(Initialize) (THIS_ DXDIAG_INIT_PARAMS* pParams) PURE; + STDMETHOD(GetRootContainer) (THIS_ IDxDiagContainer **ppInstance) PURE; +}; + + +// +// COM definition for IDxDiagContainer +// +#undef INTERFACE // External COM Implementation +#define INTERFACE IDxDiagContainer +DECLARE_INTERFACE_(IDxDiagContainer,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + /*** IDxDiagContainer methods ***/ + STDMETHOD(GetNumberOfChildContainers) (THIS_ DWORD *pdwCount) PURE; + STDMETHOD(EnumChildContainerNames) (THIS_ DWORD dwIndex, LPWSTR pwszContainer, DWORD cchContainer) PURE; + STDMETHOD(GetChildContainer) (THIS_ LPCWSTR pwszContainer, IDxDiagContainer **ppInstance) PURE; + STDMETHOD(GetNumberOfProps) (THIS_ DWORD *pdwCount) PURE; + STDMETHOD(EnumPropNames) (THIS_ DWORD dwIndex, LPWSTR pwszPropName, DWORD cchPropName) PURE; + STDMETHOD(GetProp) (THIS_ LPCWSTR pwszPropName, VARIANT *pvarProp) PURE; +}; + + +/**************************************************************************** + * + * DxDiag application interface macros + * + ****************************************************************************/ + +#if !defined(__cplusplus) || defined(CINTERFACE) + +#define IDxDiagProvider_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDxDiagProvider_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDxDiagProvider_Release(p) (p)->lpVtbl->Release(p) +#define IDxDiagProvider_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDxDiagProvider_GetRootContainer(p,a) (p)->lpVtbl->GetRootContainer(p,a) + +#define IDxDiagContainer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDxDiagContainer_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDxDiagContainer_Release(p) (p)->lpVtbl->Release(p) +#define IDxDiagContainer_GetNumberOfChildContainers(p,a) (p)->lpVtbl->GetNumberOfChildContainers(p,a) +#define IDxDiagContainer_EnumChildContainerNames(p,a,b,c) (p)->lpVtbl->EnumChildContainerNames(p,a,b,c) +#define IDxDiagContainer_GetChildContainer(p,a,b) (p)->lpVtbl->GetChildContainer(p,a,b) +#define IDxDiagContainer_GetNumberOfProps(p,a) (p)->lpVtbl->GetNumberOfProps(p,a) +#define IDxDiagContainer_EnumProps(p,a,b) (p)->lpVtbl->EnumProps(p,a,b,c) +#define IDxDiagContainer_GetProp(p,a,b) (p)->lpVtbl->GetProp(p,a,b) + +#else /* C++ */ + +#define IDxDiagProvider_QueryInterface(p,a,b) (p)->QueryInterface(p,a,b) +#define IDxDiagProvider_AddRef(p) (p)->AddRef(p) +#define IDxDiagProvider_Release(p) (p)->Release(p) +#define IDxDiagProvider_Initialize(p,a,b) (p)->Initialize(p,a,b) +#define IDxDiagProvider_GetRootContainer(p,a) (p)->GetRootContainer(p,a) + +#define IDxDiagContainer_QueryInterface(p,a,b) (p)->QueryInterface(p,a,b) +#define IDxDiagContainer_AddRef(p) (p)->AddRef(p) +#define IDxDiagContainer_Release(p) (p)->Release(p) +#define IDxDiagContainer_GetNumberOfChildContainers(p,a) (p)->GetNumberOfChildContainers(p,a) +#define IDxDiagContainer_EnumChildContainerNames(p,a,b,c) (p)->EnumChildContainerNames(p,a,b,c) +#define IDxDiagContainer_GetChildContainer(p,a,b) (p)->GetChildContainer(p,a,b) +#define IDxDiagContainer_GetNumberOfProps(p,a) (p)->GetNumberOfProps(p,a) +#define IDxDiagContainer_EnumProps(p,a,b) (p)->EnumProps(p,a,b,c) +#define IDxDiagContainer_GetProp(p,a,b) (p)->GetProp(p,a,b) + +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _DXDIAG_H_ */ + + diff --git a/src/dep/include/DXSDK/include/dxerr8.h b/src/dep/include/DXSDK/include/dxerr8.h index c274430..4f4d848 100644 --- a/src/dep/include/DXSDK/include/dxerr8.h +++ b/src/dep/include/DXSDK/include/dxerr8.h @@ -1,99 +1,99 @@ -/*==========================================================================; - * - * - * File: dxerr8.h - * Content: DirectX Error Library Include File - * - ****************************************************************************/ - -#ifndef _DXERR8_H_ -#define _DXERR8_H_ - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -// -// DXGetErrorString8 -// -// Desc: Converts a DirectX HRESULT to a string -// -// Args: HRESULT hr Can be any error code from -// D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW -// -// Return: Converted string -// -const char* WINAPI DXGetErrorString8A(HRESULT hr); -const WCHAR* WINAPI DXGetErrorString8W(HRESULT hr); - -#ifdef UNICODE -#define DXGetErrorString8 DXGetErrorString8W -#else -#define DXGetErrorString8 DXGetErrorString8A -#endif - - -// -// DXGetErrorDescription8 -// -// Desc: Returns a string description of a DirectX HRESULT -// -// Args: HRESULT hr Can be any error code from -// D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW -// -// Return: String description -// -const char* WINAPI DXGetErrorDescription8A(HRESULT hr); -const WCHAR* WINAPI DXGetErrorDescription8W(HRESULT hr); - -#ifdef UNICODE - #define DXGetErrorDescription8 DXGetErrorDescription8W -#else - #define DXGetErrorDescription8 DXGetErrorDescription8A -#endif - - -// -// DXTrace -// -// Desc: Outputs a formatted error message to the debug stream -// -// Args: CHAR* strFile The current file, typically passed in using the -// __FILE__ macro. -// DWORD dwLine The current line number, typically passed in using the -// __LINE__ macro. -// HRESULT hr An HRESULT that will be traced to the debug stream. -// CHAR* strMsg A string that will be traced to the debug stream (may be NULL) -// BOOL bPopMsgBox If TRUE, then a message box will popup also containing the passed info. -// -// Return: The hr that was passed in. -// -HRESULT WINAPI DXTraceA( const char* strFile, DWORD dwLine, HRESULT hr, const char* strMsg, BOOL bPopMsgBox ); -HRESULT WINAPI DXTraceW( const char* strFile, DWORD dwLine, HRESULT hr, const WCHAR* strMsg, BOOL bPopMsgBox ); - -#ifdef UNICODE -#define DXTrace DXTraceW -#else -#define DXTrace DXTraceA -#endif - - -// -// Helper macros -// -#if defined(DEBUG) | defined(_DEBUG) -#define DXTRACE_MSG(str) DXTrace( __FILE__, (DWORD)__LINE__, 0, str, FALSE ) -#define DXTRACE_ERR(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, TRUE ) -#define DXTRACE_ERR_NOMSGBOX(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, FALSE ) -#else -#define DXTRACE_MSG(str) (0L) -#define DXTRACE_ERR(str,hr) (hr) -#define DXTRACE_ERR_NOMSGBOX(str,hr) (hr) -#endif - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif // _DXERR8_H_ +/*==========================================================================; + * + * + * File: dxerr8.h + * Content: DirectX Error Library Include File + * + ****************************************************************************/ + +#ifndef _DXERR8_H_ +#define _DXERR8_H_ + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +// +// DXGetErrorString8 +// +// Desc: Converts a DirectX HRESULT to a string +// +// Args: HRESULT hr Can be any error code from +// D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW +// +// Return: Converted string +// +const char* WINAPI DXGetErrorString8A(HRESULT hr); +const WCHAR* WINAPI DXGetErrorString8W(HRESULT hr); + +#ifdef UNICODE +#define DXGetErrorString8 DXGetErrorString8W +#else +#define DXGetErrorString8 DXGetErrorString8A +#endif + + +// +// DXGetErrorDescription8 +// +// Desc: Returns a string description of a DirectX HRESULT +// +// Args: HRESULT hr Can be any error code from +// D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW +// +// Return: String description +// +const char* WINAPI DXGetErrorDescription8A(HRESULT hr); +const WCHAR* WINAPI DXGetErrorDescription8W(HRESULT hr); + +#ifdef UNICODE + #define DXGetErrorDescription8 DXGetErrorDescription8W +#else + #define DXGetErrorDescription8 DXGetErrorDescription8A +#endif + + +// +// DXTrace +// +// Desc: Outputs a formatted error message to the debug stream +// +// Args: CHAR* strFile The current file, typically passed in using the +// __FILE__ macro. +// DWORD dwLine The current line number, typically passed in using the +// __LINE__ macro. +// HRESULT hr An HRESULT that will be traced to the debug stream. +// CHAR* strMsg A string that will be traced to the debug stream (may be NULL) +// BOOL bPopMsgBox If TRUE, then a message box will popup also containing the passed info. +// +// Return: The hr that was passed in. +// +HRESULT WINAPI DXTraceA( const char* strFile, DWORD dwLine, HRESULT hr, const char* strMsg, BOOL bPopMsgBox ); +HRESULT WINAPI DXTraceW( const char* strFile, DWORD dwLine, HRESULT hr, const WCHAR* strMsg, BOOL bPopMsgBox ); + +#ifdef UNICODE +#define DXTrace DXTraceW +#else +#define DXTrace DXTraceA +#endif + + +// +// Helper macros +// +#if defined(DEBUG) | defined(_DEBUG) +#define DXTRACE_MSG(str) DXTrace( __FILE__, (DWORD)__LINE__, 0, str, FALSE ) +#define DXTRACE_ERR(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, TRUE ) +#define DXTRACE_ERR_NOMSGBOX(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, FALSE ) +#else +#define DXTRACE_MSG(str) (0L) +#define DXTRACE_ERR(str,hr) (hr) +#define DXTRACE_ERR_NOMSGBOX(str,hr) (hr) +#endif + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif // _DXERR8_H_ diff --git a/src/dep/include/DXSDK/include/dxerr9.h b/src/dep/include/DXSDK/include/dxerr9.h index 56a5275..baf6968 100644 --- a/src/dep/include/DXSDK/include/dxerr9.h +++ b/src/dep/include/DXSDK/include/dxerr9.h @@ -1,99 +1,99 @@ -/*==========================================================================; - * - * - * File: dxerr9.h - * Content: DirectX Error Library Include File - * - ****************************************************************************/ - -#ifndef _DXERR9_H_ -#define _DXERR9_H_ - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -// -// DXGetErrorString9 -// -// Desc: Converts a DirectX 9 or earlier HRESULT to a string -// -// Args: HRESULT hr Can be any error code from -// D3D9 D3DX9 D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW -// -// Return: Converted string -// -const char* WINAPI DXGetErrorString9A(HRESULT hr); -const WCHAR* WINAPI DXGetErrorString9W(HRESULT hr); - -#ifdef UNICODE -#define DXGetErrorString9 DXGetErrorString9W -#else -#define DXGetErrorString9 DXGetErrorString9A -#endif - - -// -// DXGetErrorDescription9 -// -// Desc: Returns a string description of a DirectX 9 or earlier HRESULT -// -// Args: HRESULT hr Can be any error code from -// D3D9 D3DX9 D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW -// -// Return: String description -// -const char* WINAPI DXGetErrorDescription9A(HRESULT hr); -const WCHAR* WINAPI DXGetErrorDescription9W(HRESULT hr); - -#ifdef UNICODE - #define DXGetErrorDescription9 DXGetErrorDescription9W -#else - #define DXGetErrorDescription9 DXGetErrorDescription9A -#endif - - -// -// DXTrace -// -// Desc: Outputs a formatted error message to the debug stream -// -// Args: CHAR* strFile The current file, typically passed in using the -// __FILE__ macro. -// DWORD dwLine The current line number, typically passed in using the -// __LINE__ macro. -// HRESULT hr An HRESULT that will be traced to the debug stream. -// CHAR* strMsg A string that will be traced to the debug stream (may be NULL) -// BOOL bPopMsgBox If TRUE, then a message box will popup also containing the passed info. -// -// Return: The hr that was passed in. -// -HRESULT WINAPI DXTraceA( const char* strFile, DWORD dwLine, HRESULT hr, const char* strMsg, BOOL bPopMsgBox ); -HRESULT WINAPI DXTraceW( const char* strFile, DWORD dwLine, HRESULT hr, const WCHAR* strMsg, BOOL bPopMsgBox ); - -#ifdef UNICODE -#define DXTrace DXTraceW -#else -#define DXTrace DXTraceA -#endif - - -// -// Helper macros -// -#if defined(DEBUG) | defined(_DEBUG) -#define DXTRACE_MSG(str) DXTrace( __FILE__, (DWORD)__LINE__, 0, str, FALSE ) -#define DXTRACE_ERR(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, FALSE ) -#define DXTRACE_ERR_MSGBOX(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, TRUE ) -#else -#define DXTRACE_MSG(str) (0L) -#define DXTRACE_ERR(str,hr) (hr) -#define DXTRACE_ERR_MSGBOX(str,hr) (hr) -#endif - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif // _DXERR9_H_ +/*==========================================================================; + * + * + * File: dxerr9.h + * Content: DirectX Error Library Include File + * + ****************************************************************************/ + +#ifndef _DXERR9_H_ +#define _DXERR9_H_ + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +// +// DXGetErrorString9 +// +// Desc: Converts a DirectX 9 or earlier HRESULT to a string +// +// Args: HRESULT hr Can be any error code from +// D3D9 D3DX9 D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW +// +// Return: Converted string +// +const char* WINAPI DXGetErrorString9A(HRESULT hr); +const WCHAR* WINAPI DXGetErrorString9W(HRESULT hr); + +#ifdef UNICODE +#define DXGetErrorString9 DXGetErrorString9W +#else +#define DXGetErrorString9 DXGetErrorString9A +#endif + + +// +// DXGetErrorDescription9 +// +// Desc: Returns a string description of a DirectX 9 or earlier HRESULT +// +// Args: HRESULT hr Can be any error code from +// D3D9 D3DX9 D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW +// +// Return: String description +// +const char* WINAPI DXGetErrorDescription9A(HRESULT hr); +const WCHAR* WINAPI DXGetErrorDescription9W(HRESULT hr); + +#ifdef UNICODE + #define DXGetErrorDescription9 DXGetErrorDescription9W +#else + #define DXGetErrorDescription9 DXGetErrorDescription9A +#endif + + +// +// DXTrace +// +// Desc: Outputs a formatted error message to the debug stream +// +// Args: CHAR* strFile The current file, typically passed in using the +// __FILE__ macro. +// DWORD dwLine The current line number, typically passed in using the +// __LINE__ macro. +// HRESULT hr An HRESULT that will be traced to the debug stream. +// CHAR* strMsg A string that will be traced to the debug stream (may be NULL) +// BOOL bPopMsgBox If TRUE, then a message box will popup also containing the passed info. +// +// Return: The hr that was passed in. +// +HRESULT WINAPI DXTraceA( const char* strFile, DWORD dwLine, HRESULT hr, const char* strMsg, BOOL bPopMsgBox ); +HRESULT WINAPI DXTraceW( const char* strFile, DWORD dwLine, HRESULT hr, const WCHAR* strMsg, BOOL bPopMsgBox ); + +#ifdef UNICODE +#define DXTrace DXTraceW +#else +#define DXTrace DXTraceA +#endif + + +// +// Helper macros +// +#if defined(DEBUG) | defined(_DEBUG) +#define DXTRACE_MSG(str) DXTrace( __FILE__, (DWORD)__LINE__, 0, str, FALSE ) +#define DXTRACE_ERR(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, FALSE ) +#define DXTRACE_ERR_MSGBOX(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, TRUE ) +#else +#define DXTRACE_MSG(str) (0L) +#define DXTRACE_ERR(str,hr) (hr) +#define DXTRACE_ERR_MSGBOX(str,hr) (hr) +#endif + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif // _DXERR9_H_ diff --git a/src/dep/include/DXSDK/include/dxfile.h b/src/dep/include/DXSDK/include/dxfile.h index 5a981ce..8b5995a 100644 --- a/src/dep/include/DXSDK/include/dxfile.h +++ b/src/dep/include/DXSDK/include/dxfile.h @@ -1,240 +1,240 @@ -/*************************************************************************** - * - * Copyright (C) 1998-1999 Microsoft Corporation. All Rights Reserved. - * - * File: dxfile.h - * - * Content: DirectX File public header file - * - ***************************************************************************/ - -#ifndef __DXFILE_H__ -#define __DXFILE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef DWORD DXFILEFORMAT; - -#define DXFILEFORMAT_BINARY 0 -#define DXFILEFORMAT_TEXT 1 -#define DXFILEFORMAT_COMPRESSED 2 - -typedef DWORD DXFILELOADOPTIONS; - -#define DXFILELOAD_FROMFILE 0x00L -#define DXFILELOAD_FROMRESOURCE 0x01L -#define DXFILELOAD_FROMMEMORY 0x02L -#define DXFILELOAD_FROMSTREAM 0x04L -#define DXFILELOAD_FROMURL 0x08L - -typedef struct _DXFILELOADRESOURCE { - HMODULE hModule; - LPCTSTR lpName; - LPCTSTR lpType; -}DXFILELOADRESOURCE, *LPDXFILELOADRESOURCE; - -typedef struct _DXFILELOADMEMORY { - LPVOID lpMemory; - DWORD dSize; -}DXFILELOADMEMORY, *LPDXFILELOADMEMORY; - -/* - * DirectX File object types. - */ - -#ifndef WIN_TYPES -#define WIN_TYPES(itype, ptype) typedef interface itype *LP##ptype, **LPLP##ptype -#endif - -WIN_TYPES(IDirectXFile, DIRECTXFILE); -WIN_TYPES(IDirectXFileEnumObject, DIRECTXFILEENUMOBJECT); -WIN_TYPES(IDirectXFileSaveObject, DIRECTXFILESAVEOBJECT); -WIN_TYPES(IDirectXFileObject, DIRECTXFILEOBJECT); -WIN_TYPES(IDirectXFileData, DIRECTXFILEDATA); -WIN_TYPES(IDirectXFileDataReference, DIRECTXFILEDATAREFERENCE); -WIN_TYPES(IDirectXFileBinary, DIRECTXFILEBINARY); - -/* - * API for creating IDirectXFile interface. - */ - -STDAPI DirectXFileCreate(LPDIRECTXFILE *lplpDirectXFile); - -/* - * The methods for IUnknown - */ - -#define IUNKNOWN_METHODS(kind) \ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) kind; \ - STDMETHOD_(ULONG, AddRef) (THIS) kind; \ - STDMETHOD_(ULONG, Release) (THIS) kind - -/* - * The methods for IDirectXFileObject - */ - -#define IDIRECTXFILEOBJECT_METHODS(kind) \ - STDMETHOD(GetName) (THIS_ LPSTR, LPDWORD) kind; \ - STDMETHOD(GetId) (THIS_ LPGUID) kind - -/* - * DirectX File interfaces. - */ - -#undef INTERFACE -#define INTERFACE IDirectXFile - -DECLARE_INTERFACE_(IDirectXFile, IUnknown) -{ - IUNKNOWN_METHODS(PURE); - STDMETHOD(CreateEnumObject) (THIS_ LPVOID, DXFILELOADOPTIONS, - LPDIRECTXFILEENUMOBJECT *) PURE; - STDMETHOD(CreateSaveObject) (THIS_ LPCSTR, DXFILEFORMAT, - LPDIRECTXFILESAVEOBJECT *) PURE; - STDMETHOD(RegisterTemplates) (THIS_ LPVOID, DWORD) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirectXFileEnumObject - -DECLARE_INTERFACE_(IDirectXFileEnumObject, IUnknown) -{ - IUNKNOWN_METHODS(PURE); - STDMETHOD(GetNextDataObject) (THIS_ LPDIRECTXFILEDATA *) PURE; - STDMETHOD(GetDataObjectById) (THIS_ REFGUID, LPDIRECTXFILEDATA *) PURE; - STDMETHOD(GetDataObjectByName) (THIS_ LPCSTR, LPDIRECTXFILEDATA *) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirectXFileSaveObject - -DECLARE_INTERFACE_(IDirectXFileSaveObject, IUnknown) -{ - IUNKNOWN_METHODS(PURE); - STDMETHOD(SaveTemplates) (THIS_ DWORD, const GUID **) PURE; - STDMETHOD(CreateDataObject) (THIS_ REFGUID, LPCSTR, const GUID *, - DWORD, LPVOID, LPDIRECTXFILEDATA *) PURE; - STDMETHOD(SaveData) (THIS_ LPDIRECTXFILEDATA) PURE; -}; - - -#undef INTERFACE -#define INTERFACE IDirectXFileObject - -DECLARE_INTERFACE_(IDirectXFileObject, IUnknown) -{ - IUNKNOWN_METHODS(PURE); - IDIRECTXFILEOBJECT_METHODS(PURE); -}; - -#undef INTERFACE -#define INTERFACE IDirectXFileData - -DECLARE_INTERFACE_(IDirectXFileData, IDirectXFileObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECTXFILEOBJECT_METHODS(PURE); - - STDMETHOD(GetData) (THIS_ LPCSTR, DWORD *, void **) PURE; - STDMETHOD(GetType) (THIS_ const GUID **) PURE; - STDMETHOD(GetNextObject) (THIS_ LPDIRECTXFILEOBJECT *) PURE; - STDMETHOD(AddDataObject) (THIS_ LPDIRECTXFILEDATA) PURE; - STDMETHOD(AddDataReference) (THIS_ LPCSTR, const GUID *) PURE; - STDMETHOD(AddBinaryObject) (THIS_ LPCSTR, const GUID *, LPCSTR, LPVOID, DWORD) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirectXFileDataReference - -DECLARE_INTERFACE_(IDirectXFileDataReference, IDirectXFileObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECTXFILEOBJECT_METHODS(PURE); - - STDMETHOD(Resolve) (THIS_ LPDIRECTXFILEDATA *) PURE; -}; - -#undef INTERFACE -#define INTERFACE IDirectXFileBinary - -DECLARE_INTERFACE_(IDirectXFileBinary, IDirectXFileObject) -{ - IUNKNOWN_METHODS(PURE); - IDIRECTXFILEOBJECT_METHODS(PURE); - - STDMETHOD(GetSize) (THIS_ DWORD *) PURE; - STDMETHOD(GetMimeType) (THIS_ LPCSTR *) PURE; - STDMETHOD(Read) (THIS_ LPVOID, DWORD, LPDWORD) PURE; -}; - -/* - * DirectXFile Object Class Id (for CoCreateInstance()) - */ - -DEFINE_GUID(CLSID_CDirectXFile, 0x4516ec43, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); - -/* - * DirectX File Interface GUIDs. - */ - -DEFINE_GUID(IID_IDirectXFile, 0x3d82ab40, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); -DEFINE_GUID(IID_IDirectXFileEnumObject, 0x3d82ab41, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); -DEFINE_GUID(IID_IDirectXFileSaveObject, 0x3d82ab42, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); -DEFINE_GUID(IID_IDirectXFileObject, 0x3d82ab43, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); -DEFINE_GUID(IID_IDirectXFileData, 0x3d82ab44, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); -DEFINE_GUID(IID_IDirectXFileDataReference, 0x3d82ab45, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); -DEFINE_GUID(IID_IDirectXFileBinary, 0x3d82ab46, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); - -/* - * DirectX File Header template's GUID. - */ - -DEFINE_GUID(TID_DXFILEHeader, 0x3d82ab43, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); - - -/* - * DirectX File errors. - */ - -#define _FACDD 0x876 -#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) - -#define DXFILE_OK 0 - -#define DXFILEERR_BADOBJECT MAKE_DDHRESULT(850) -#define DXFILEERR_BADVALUE MAKE_DDHRESULT(851) -#define DXFILEERR_BADTYPE MAKE_DDHRESULT(852) -#define DXFILEERR_BADSTREAMHANDLE MAKE_DDHRESULT(853) -#define DXFILEERR_BADALLOC MAKE_DDHRESULT(854) -#define DXFILEERR_NOTFOUND MAKE_DDHRESULT(855) -#define DXFILEERR_NOTDONEYET MAKE_DDHRESULT(856) -#define DXFILEERR_FILENOTFOUND MAKE_DDHRESULT(857) -#define DXFILEERR_RESOURCENOTFOUND MAKE_DDHRESULT(858) -#define DXFILEERR_URLNOTFOUND MAKE_DDHRESULT(859) -#define DXFILEERR_BADRESOURCE MAKE_DDHRESULT(860) -#define DXFILEERR_BADFILETYPE MAKE_DDHRESULT(861) -#define DXFILEERR_BADFILEVERSION MAKE_DDHRESULT(862) -#define DXFILEERR_BADFILEFLOATSIZE MAKE_DDHRESULT(863) -#define DXFILEERR_BADFILECOMPRESSIONTYPE MAKE_DDHRESULT(864) -#define DXFILEERR_BADFILE MAKE_DDHRESULT(865) -#define DXFILEERR_PARSEERROR MAKE_DDHRESULT(866) -#define DXFILEERR_NOTEMPLATE MAKE_DDHRESULT(867) -#define DXFILEERR_BADARRAYSIZE MAKE_DDHRESULT(868) -#define DXFILEERR_BADDATAREFERENCE MAKE_DDHRESULT(869) -#define DXFILEERR_INTERNALERROR MAKE_DDHRESULT(870) -#define DXFILEERR_NOMOREOBJECTS MAKE_DDHRESULT(871) -#define DXFILEERR_BADINTRINSICS MAKE_DDHRESULT(872) -#define DXFILEERR_NOMORESTREAMHANDLES MAKE_DDHRESULT(873) -#define DXFILEERR_NOMOREDATA MAKE_DDHRESULT(874) -#define DXFILEERR_BADCACHEFILE MAKE_DDHRESULT(875) -#define DXFILEERR_NOINTERNET MAKE_DDHRESULT(876) - - -#ifdef __cplusplus -}; -#endif - -#endif /* _DXFILE_H_ */ +/*************************************************************************** + * + * Copyright (C) 1998-1999 Microsoft Corporation. All Rights Reserved. + * + * File: dxfile.h + * + * Content: DirectX File public header file + * + ***************************************************************************/ + +#ifndef __DXFILE_H__ +#define __DXFILE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef DWORD DXFILEFORMAT; + +#define DXFILEFORMAT_BINARY 0 +#define DXFILEFORMAT_TEXT 1 +#define DXFILEFORMAT_COMPRESSED 2 + +typedef DWORD DXFILELOADOPTIONS; + +#define DXFILELOAD_FROMFILE 0x00L +#define DXFILELOAD_FROMRESOURCE 0x01L +#define DXFILELOAD_FROMMEMORY 0x02L +#define DXFILELOAD_FROMSTREAM 0x04L +#define DXFILELOAD_FROMURL 0x08L + +typedef struct _DXFILELOADRESOURCE { + HMODULE hModule; + LPCTSTR lpName; + LPCTSTR lpType; +}DXFILELOADRESOURCE, *LPDXFILELOADRESOURCE; + +typedef struct _DXFILELOADMEMORY { + LPVOID lpMemory; + DWORD dSize; +}DXFILELOADMEMORY, *LPDXFILELOADMEMORY; + +/* + * DirectX File object types. + */ + +#ifndef WIN_TYPES +#define WIN_TYPES(itype, ptype) typedef interface itype *LP##ptype, **LPLP##ptype +#endif + +WIN_TYPES(IDirectXFile, DIRECTXFILE); +WIN_TYPES(IDirectXFileEnumObject, DIRECTXFILEENUMOBJECT); +WIN_TYPES(IDirectXFileSaveObject, DIRECTXFILESAVEOBJECT); +WIN_TYPES(IDirectXFileObject, DIRECTXFILEOBJECT); +WIN_TYPES(IDirectXFileData, DIRECTXFILEDATA); +WIN_TYPES(IDirectXFileDataReference, DIRECTXFILEDATAREFERENCE); +WIN_TYPES(IDirectXFileBinary, DIRECTXFILEBINARY); + +/* + * API for creating IDirectXFile interface. + */ + +STDAPI DirectXFileCreate(LPDIRECTXFILE *lplpDirectXFile); + +/* + * The methods for IUnknown + */ + +#define IUNKNOWN_METHODS(kind) \ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) kind; \ + STDMETHOD_(ULONG, AddRef) (THIS) kind; \ + STDMETHOD_(ULONG, Release) (THIS) kind + +/* + * The methods for IDirectXFileObject + */ + +#define IDIRECTXFILEOBJECT_METHODS(kind) \ + STDMETHOD(GetName) (THIS_ LPSTR, LPDWORD) kind; \ + STDMETHOD(GetId) (THIS_ LPGUID) kind + +/* + * DirectX File interfaces. + */ + +#undef INTERFACE +#define INTERFACE IDirectXFile + +DECLARE_INTERFACE_(IDirectXFile, IUnknown) +{ + IUNKNOWN_METHODS(PURE); + STDMETHOD(CreateEnumObject) (THIS_ LPVOID, DXFILELOADOPTIONS, + LPDIRECTXFILEENUMOBJECT *) PURE; + STDMETHOD(CreateSaveObject) (THIS_ LPCSTR, DXFILEFORMAT, + LPDIRECTXFILESAVEOBJECT *) PURE; + STDMETHOD(RegisterTemplates) (THIS_ LPVOID, DWORD) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirectXFileEnumObject + +DECLARE_INTERFACE_(IDirectXFileEnumObject, IUnknown) +{ + IUNKNOWN_METHODS(PURE); + STDMETHOD(GetNextDataObject) (THIS_ LPDIRECTXFILEDATA *) PURE; + STDMETHOD(GetDataObjectById) (THIS_ REFGUID, LPDIRECTXFILEDATA *) PURE; + STDMETHOD(GetDataObjectByName) (THIS_ LPCSTR, LPDIRECTXFILEDATA *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirectXFileSaveObject + +DECLARE_INTERFACE_(IDirectXFileSaveObject, IUnknown) +{ + IUNKNOWN_METHODS(PURE); + STDMETHOD(SaveTemplates) (THIS_ DWORD, const GUID **) PURE; + STDMETHOD(CreateDataObject) (THIS_ REFGUID, LPCSTR, const GUID *, + DWORD, LPVOID, LPDIRECTXFILEDATA *) PURE; + STDMETHOD(SaveData) (THIS_ LPDIRECTXFILEDATA) PURE; +}; + + +#undef INTERFACE +#define INTERFACE IDirectXFileObject + +DECLARE_INTERFACE_(IDirectXFileObject, IUnknown) +{ + IUNKNOWN_METHODS(PURE); + IDIRECTXFILEOBJECT_METHODS(PURE); +}; + +#undef INTERFACE +#define INTERFACE IDirectXFileData + +DECLARE_INTERFACE_(IDirectXFileData, IDirectXFileObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECTXFILEOBJECT_METHODS(PURE); + + STDMETHOD(GetData) (THIS_ LPCSTR, DWORD *, void **) PURE; + STDMETHOD(GetType) (THIS_ const GUID **) PURE; + STDMETHOD(GetNextObject) (THIS_ LPDIRECTXFILEOBJECT *) PURE; + STDMETHOD(AddDataObject) (THIS_ LPDIRECTXFILEDATA) PURE; + STDMETHOD(AddDataReference) (THIS_ LPCSTR, const GUID *) PURE; + STDMETHOD(AddBinaryObject) (THIS_ LPCSTR, const GUID *, LPCSTR, LPVOID, DWORD) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirectXFileDataReference + +DECLARE_INTERFACE_(IDirectXFileDataReference, IDirectXFileObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECTXFILEOBJECT_METHODS(PURE); + + STDMETHOD(Resolve) (THIS_ LPDIRECTXFILEDATA *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirectXFileBinary + +DECLARE_INTERFACE_(IDirectXFileBinary, IDirectXFileObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECTXFILEOBJECT_METHODS(PURE); + + STDMETHOD(GetSize) (THIS_ DWORD *) PURE; + STDMETHOD(GetMimeType) (THIS_ LPCSTR *) PURE; + STDMETHOD(Read) (THIS_ LPVOID, DWORD, LPDWORD) PURE; +}; + +/* + * DirectXFile Object Class Id (for CoCreateInstance()) + */ + +DEFINE_GUID(CLSID_CDirectXFile, 0x4516ec43, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); + +/* + * DirectX File Interface GUIDs. + */ + +DEFINE_GUID(IID_IDirectXFile, 0x3d82ab40, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); +DEFINE_GUID(IID_IDirectXFileEnumObject, 0x3d82ab41, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); +DEFINE_GUID(IID_IDirectXFileSaveObject, 0x3d82ab42, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); +DEFINE_GUID(IID_IDirectXFileObject, 0x3d82ab43, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); +DEFINE_GUID(IID_IDirectXFileData, 0x3d82ab44, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); +DEFINE_GUID(IID_IDirectXFileDataReference, 0x3d82ab45, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); +DEFINE_GUID(IID_IDirectXFileBinary, 0x3d82ab46, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + +/* + * DirectX File Header template's GUID. + */ + +DEFINE_GUID(TID_DXFILEHeader, 0x3d82ab43, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + + +/* + * DirectX File errors. + */ + +#define _FACDD 0x876 +#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) + +#define DXFILE_OK 0 + +#define DXFILEERR_BADOBJECT MAKE_DDHRESULT(850) +#define DXFILEERR_BADVALUE MAKE_DDHRESULT(851) +#define DXFILEERR_BADTYPE MAKE_DDHRESULT(852) +#define DXFILEERR_BADSTREAMHANDLE MAKE_DDHRESULT(853) +#define DXFILEERR_BADALLOC MAKE_DDHRESULT(854) +#define DXFILEERR_NOTFOUND MAKE_DDHRESULT(855) +#define DXFILEERR_NOTDONEYET MAKE_DDHRESULT(856) +#define DXFILEERR_FILENOTFOUND MAKE_DDHRESULT(857) +#define DXFILEERR_RESOURCENOTFOUND MAKE_DDHRESULT(858) +#define DXFILEERR_URLNOTFOUND MAKE_DDHRESULT(859) +#define DXFILEERR_BADRESOURCE MAKE_DDHRESULT(860) +#define DXFILEERR_BADFILETYPE MAKE_DDHRESULT(861) +#define DXFILEERR_BADFILEVERSION MAKE_DDHRESULT(862) +#define DXFILEERR_BADFILEFLOATSIZE MAKE_DDHRESULT(863) +#define DXFILEERR_BADFILECOMPRESSIONTYPE MAKE_DDHRESULT(864) +#define DXFILEERR_BADFILE MAKE_DDHRESULT(865) +#define DXFILEERR_PARSEERROR MAKE_DDHRESULT(866) +#define DXFILEERR_NOTEMPLATE MAKE_DDHRESULT(867) +#define DXFILEERR_BADARRAYSIZE MAKE_DDHRESULT(868) +#define DXFILEERR_BADDATAREFERENCE MAKE_DDHRESULT(869) +#define DXFILEERR_INTERNALERROR MAKE_DDHRESULT(870) +#define DXFILEERR_NOMOREOBJECTS MAKE_DDHRESULT(871) +#define DXFILEERR_BADINTRINSICS MAKE_DDHRESULT(872) +#define DXFILEERR_NOMORESTREAMHANDLES MAKE_DDHRESULT(873) +#define DXFILEERR_NOMOREDATA MAKE_DDHRESULT(874) +#define DXFILEERR_BADCACHEFILE MAKE_DDHRESULT(875) +#define DXFILEERR_NOINTERNET MAKE_DDHRESULT(876) + + +#ifdef __cplusplus +}; +#endif + +#endif /* _DXFILE_H_ */  \ No newline at end of file diff --git a/src/dep/include/DXSDK/include/dxsdkver.h b/src/dep/include/DXSDK/include/dxsdkver.h index 170bb32..cda0ce6 100644 --- a/src/dep/include/DXSDK/include/dxsdkver.h +++ b/src/dep/include/DXSDK/include/dxsdkver.h @@ -1,18 +1,18 @@ -/*==========================================================================; - * - * - * File: dxsdkver.h - * Content: DirectX SDK Version Include File - * - ****************************************************************************/ - -#ifndef _DXSDKVER_H_ -#define _DXSDKVER_H_ - -#define _DXSDK_PRODUCT_MAJOR 9 -#define _DXSDK_PRODUCT_MINOR 12 -#define _DXSDK_BUILD_MAJOR 589 -#define _DXSDK_BUILD_MINOR 0000 - -#endif // _DXSDKVER_H_ - +/*==========================================================================; + * + * + * File: dxsdkver.h + * Content: DirectX SDK Version Include File + * + ****************************************************************************/ + +#ifndef _DXSDKVER_H_ +#define _DXSDKVER_H_ + +#define _DXSDK_PRODUCT_MAJOR 9 +#define _DXSDK_PRODUCT_MINOR 12 +#define _DXSDK_BUILD_MAJOR 589 +#define _DXSDK_BUILD_MINOR 0000 + +#endif // _DXSDKVER_H_ + diff --git a/src/dep/include/DXSDK/include/dxtrans.h b/src/dep/include/DXSDK/include/dxtrans.h index 504877a..8df2ff7 100644 --- a/src/dep/include/DXSDK/include/dxtrans.h +++ b/src/dep/include/DXSDK/include/dxtrans.h @@ -1,5362 +1,5362 @@ - -#pragma warning( disable: 4049 ) /* more than 64k source lines */ - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 6.00.0357 */ -/* Compiler settings for dxtrans.idl: - Oicf, W1, Zp8, env=Win32 (32b run) - protocol : dce , ms_ext, c_ext - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() -*/ -//@@MIDL_FILE_HEADING( ) - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 440 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ - -#ifndef COM_NO_WINDOWS_H -#include "windows.h" -#include "ole2.h" -#endif /*COM_NO_WINDOWS_H*/ - -#ifndef __dxtrans_h__ -#define __dxtrans_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -/* Forward Declarations */ - -#ifndef __IDXBaseObject_FWD_DEFINED__ -#define __IDXBaseObject_FWD_DEFINED__ -typedef interface IDXBaseObject IDXBaseObject; -#endif /* __IDXBaseObject_FWD_DEFINED__ */ - - -#ifndef __IDXTransformFactory_FWD_DEFINED__ -#define __IDXTransformFactory_FWD_DEFINED__ -typedef interface IDXTransformFactory IDXTransformFactory; -#endif /* __IDXTransformFactory_FWD_DEFINED__ */ - - -#ifndef __IDXTransform_FWD_DEFINED__ -#define __IDXTransform_FWD_DEFINED__ -typedef interface IDXTransform IDXTransform; -#endif /* __IDXTransform_FWD_DEFINED__ */ - - -#ifndef __IDXSurfacePick_FWD_DEFINED__ -#define __IDXSurfacePick_FWD_DEFINED__ -typedef interface IDXSurfacePick IDXSurfacePick; -#endif /* __IDXSurfacePick_FWD_DEFINED__ */ - - -#ifndef __IDXTBindHost_FWD_DEFINED__ -#define __IDXTBindHost_FWD_DEFINED__ -typedef interface IDXTBindHost IDXTBindHost; -#endif /* __IDXTBindHost_FWD_DEFINED__ */ - - -#ifndef __IDXTaskManager_FWD_DEFINED__ -#define __IDXTaskManager_FWD_DEFINED__ -typedef interface IDXTaskManager IDXTaskManager; -#endif /* __IDXTaskManager_FWD_DEFINED__ */ - - -#ifndef __IDXSurfaceFactory_FWD_DEFINED__ -#define __IDXSurfaceFactory_FWD_DEFINED__ -typedef interface IDXSurfaceFactory IDXSurfaceFactory; -#endif /* __IDXSurfaceFactory_FWD_DEFINED__ */ - - -#ifndef __IDXSurfaceModifier_FWD_DEFINED__ -#define __IDXSurfaceModifier_FWD_DEFINED__ -typedef interface IDXSurfaceModifier IDXSurfaceModifier; -#endif /* __IDXSurfaceModifier_FWD_DEFINED__ */ - - -#ifndef __IDXSurface_FWD_DEFINED__ -#define __IDXSurface_FWD_DEFINED__ -typedef interface IDXSurface IDXSurface; -#endif /* __IDXSurface_FWD_DEFINED__ */ - - -#ifndef __IDXSurfaceInit_FWD_DEFINED__ -#define __IDXSurfaceInit_FWD_DEFINED__ -typedef interface IDXSurfaceInit IDXSurfaceInit; -#endif /* __IDXSurfaceInit_FWD_DEFINED__ */ - - -#ifndef __IDXARGBSurfaceInit_FWD_DEFINED__ -#define __IDXARGBSurfaceInit_FWD_DEFINED__ -typedef interface IDXARGBSurfaceInit IDXARGBSurfaceInit; -#endif /* __IDXARGBSurfaceInit_FWD_DEFINED__ */ - - -#ifndef __IDXARGBReadPtr_FWD_DEFINED__ -#define __IDXARGBReadPtr_FWD_DEFINED__ -typedef interface IDXARGBReadPtr IDXARGBReadPtr; -#endif /* __IDXARGBReadPtr_FWD_DEFINED__ */ - - -#ifndef __IDXARGBReadWritePtr_FWD_DEFINED__ -#define __IDXARGBReadWritePtr_FWD_DEFINED__ -typedef interface IDXARGBReadWritePtr IDXARGBReadWritePtr; -#endif /* __IDXARGBReadWritePtr_FWD_DEFINED__ */ - - -#ifndef __IDXDCLock_FWD_DEFINED__ -#define __IDXDCLock_FWD_DEFINED__ -typedef interface IDXDCLock IDXDCLock; -#endif /* __IDXDCLock_FWD_DEFINED__ */ - - -#ifndef __IDXTScaleOutput_FWD_DEFINED__ -#define __IDXTScaleOutput_FWD_DEFINED__ -typedef interface IDXTScaleOutput IDXTScaleOutput; -#endif /* __IDXTScaleOutput_FWD_DEFINED__ */ - - -#ifndef __IDXGradient_FWD_DEFINED__ -#define __IDXGradient_FWD_DEFINED__ -typedef interface IDXGradient IDXGradient; -#endif /* __IDXGradient_FWD_DEFINED__ */ - - -#ifndef __IDXTScale_FWD_DEFINED__ -#define __IDXTScale_FWD_DEFINED__ -typedef interface IDXTScale IDXTScale; -#endif /* __IDXTScale_FWD_DEFINED__ */ - - -#ifndef __IDXEffect_FWD_DEFINED__ -#define __IDXEffect_FWD_DEFINED__ -typedef interface IDXEffect IDXEffect; -#endif /* __IDXEffect_FWD_DEFINED__ */ - - -#ifndef __IDXLookupTable_FWD_DEFINED__ -#define __IDXLookupTable_FWD_DEFINED__ -typedef interface IDXLookupTable IDXLookupTable; -#endif /* __IDXLookupTable_FWD_DEFINED__ */ - - -#ifndef __IDXRawSurface_FWD_DEFINED__ -#define __IDXRawSurface_FWD_DEFINED__ -typedef interface IDXRawSurface IDXRawSurface; -#endif /* __IDXRawSurface_FWD_DEFINED__ */ - - -#ifndef __IHTMLDXTransform_FWD_DEFINED__ -#define __IHTMLDXTransform_FWD_DEFINED__ -typedef interface IHTMLDXTransform IHTMLDXTransform; -#endif /* __IHTMLDXTransform_FWD_DEFINED__ */ - - -#ifndef __ICSSFilterDispatch_FWD_DEFINED__ -#define __ICSSFilterDispatch_FWD_DEFINED__ -typedef interface ICSSFilterDispatch ICSSFilterDispatch; -#endif /* __ICSSFilterDispatch_FWD_DEFINED__ */ - - -#ifndef __DXTransformFactory_FWD_DEFINED__ -#define __DXTransformFactory_FWD_DEFINED__ - -#ifdef __cplusplus -typedef class DXTransformFactory DXTransformFactory; -#else -typedef struct DXTransformFactory DXTransformFactory; -#endif /* __cplusplus */ - -#endif /* __DXTransformFactory_FWD_DEFINED__ */ - - -#ifndef __DXTaskManager_FWD_DEFINED__ -#define __DXTaskManager_FWD_DEFINED__ - -#ifdef __cplusplus -typedef class DXTaskManager DXTaskManager; -#else -typedef struct DXTaskManager DXTaskManager; -#endif /* __cplusplus */ - -#endif /* __DXTaskManager_FWD_DEFINED__ */ - - -#ifndef __DXTScale_FWD_DEFINED__ -#define __DXTScale_FWD_DEFINED__ - -#ifdef __cplusplus -typedef class DXTScale DXTScale; -#else -typedef struct DXTScale DXTScale; -#endif /* __cplusplus */ - -#endif /* __DXTScale_FWD_DEFINED__ */ - - -#ifndef __DXSurface_FWD_DEFINED__ -#define __DXSurface_FWD_DEFINED__ - -#ifdef __cplusplus -typedef class DXSurface DXSurface; -#else -typedef struct DXSurface DXSurface; -#endif /* __cplusplus */ - -#endif /* __DXSurface_FWD_DEFINED__ */ - - -#ifndef __DXSurfaceModifier_FWD_DEFINED__ -#define __DXSurfaceModifier_FWD_DEFINED__ - -#ifdef __cplusplus -typedef class DXSurfaceModifier DXSurfaceModifier; -#else -typedef struct DXSurfaceModifier DXSurfaceModifier; -#endif /* __cplusplus */ - -#endif /* __DXSurfaceModifier_FWD_DEFINED__ */ - - -#ifndef __DXGradient_FWD_DEFINED__ -#define __DXGradient_FWD_DEFINED__ - -#ifdef __cplusplus -typedef class DXGradient DXGradient; -#else -typedef struct DXGradient DXGradient; -#endif /* __cplusplus */ - -#endif /* __DXGradient_FWD_DEFINED__ */ - - -#ifndef __DXTFilter_FWD_DEFINED__ -#define __DXTFilter_FWD_DEFINED__ - -#ifdef __cplusplus -typedef class DXTFilter DXTFilter; -#else -typedef struct DXTFilter DXTFilter; -#endif /* __cplusplus */ - -#endif /* __DXTFilter_FWD_DEFINED__ */ - - -/* header files for imported files */ -#include "oaidl.h" -#include "ocidl.h" -#include "comcat.h" - -#ifdef __cplusplus -extern "C"{ -#endif - -void * __RPC_USER MIDL_user_allocate(size_t); -void __RPC_USER MIDL_user_free( void * ); - -/* interface __MIDL_itf_dxtrans_0000 */ -/* [local] */ - -#include -#include -#include -#include -#include -#if 0 -// Bogus definition used to make MIDL compiler happy -typedef void DDSURFACEDESC; - -typedef void D3DRMBOX; - -typedef void D3DVECTOR; - -typedef void D3DRMMATRIX4D; - -typedef void *LPSECURITY_ATTRIBUTES; - -#endif -#ifdef _DXTRANSIMPL - #define _DXTRANS_IMPL_EXT _declspec(dllexport) -#else - #define _DXTRANS_IMPL_EXT _declspec(dllimport) -#endif - - - - - - - - - - - - - - - - -// -// All GUIDs for DXTransform are declared in DXTGUID.C in the SDK include directory -// -EXTERN_C const GUID DDPF_RGB1; -EXTERN_C const GUID DDPF_RGB2; -EXTERN_C const GUID DDPF_RGB4; -EXTERN_C const GUID DDPF_RGB8; -EXTERN_C const GUID DDPF_RGB332; -EXTERN_C const GUID DDPF_ARGB4444; -EXTERN_C const GUID DDPF_RGB565; -EXTERN_C const GUID DDPF_BGR565; -EXTERN_C const GUID DDPF_RGB555; -EXTERN_C const GUID DDPF_ARGB1555; -EXTERN_C const GUID DDPF_RGB24; -EXTERN_C const GUID DDPF_BGR24; -EXTERN_C const GUID DDPF_RGB32; -EXTERN_C const GUID DDPF_BGR32; -EXTERN_C const GUID DDPF_ABGR32; -EXTERN_C const GUID DDPF_ARGB32; -EXTERN_C const GUID DDPF_PMARGB32; -EXTERN_C const GUID DDPF_A1; -EXTERN_C const GUID DDPF_A2; -EXTERN_C const GUID DDPF_A4; -EXTERN_C const GUID DDPF_A8; -EXTERN_C const GUID DDPF_Z8; -EXTERN_C const GUID DDPF_Z16; -EXTERN_C const GUID DDPF_Z24; -EXTERN_C const GUID DDPF_Z32; -// -// Component categories -// -EXTERN_C const GUID CATID_DXImageTransform; -EXTERN_C const GUID CATID_DX3DTransform; -EXTERN_C const GUID CATID_DXAuthoringTransform; -EXTERN_C const GUID CATID_DXSurface; -// -// Service IDs -// -EXTERN_C const GUID SID_SDirectDraw; -EXTERN_C const GUID SID_SDirect3DRM; -#define SID_SDXTaskManager CLSID_DXTaskManager -#define SID_SDXSurfaceFactory IID_IDXSurfaceFactory -#define SID_SDXTransformFactory IID_IDXTransformFactory -// -// DXTransforms Core Type Library Version Info -// -#define DXTRANS_TLB_MAJOR_VER 1 -#define DXTRANS_TLB_MINOR_VER 1 - - -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0000_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0000_v0_0_s_ifspec; - -#ifndef __IDXBaseObject_INTERFACE_DEFINED__ -#define __IDXBaseObject_INTERFACE_DEFINED__ - -/* interface IDXBaseObject */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXBaseObject; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("17B59B2B-9CC8-11d1-9053-00C04FD9189D") - IDXBaseObject : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE GetGenerationId( - /* [out] */ ULONG *pID) = 0; - - virtual HRESULT STDMETHODCALLTYPE IncrementGenerationId( - /* [in] */ BOOL bRefresh) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetObjectSize( - /* [out] */ ULONG *pcbSize) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXBaseObjectVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXBaseObject * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXBaseObject * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXBaseObject * This); - - HRESULT ( STDMETHODCALLTYPE *GetGenerationId )( - IDXBaseObject * This, - /* [out] */ ULONG *pID); - - HRESULT ( STDMETHODCALLTYPE *IncrementGenerationId )( - IDXBaseObject * This, - /* [in] */ BOOL bRefresh); - - HRESULT ( STDMETHODCALLTYPE *GetObjectSize )( - IDXBaseObject * This, - /* [out] */ ULONG *pcbSize); - - END_INTERFACE - } IDXBaseObjectVtbl; - - interface IDXBaseObject - { - CONST_VTBL struct IDXBaseObjectVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXBaseObject_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXBaseObject_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXBaseObject_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXBaseObject_GetGenerationId(This,pID) \ - (This)->lpVtbl -> GetGenerationId(This,pID) - -#define IDXBaseObject_IncrementGenerationId(This,bRefresh) \ - (This)->lpVtbl -> IncrementGenerationId(This,bRefresh) - -#define IDXBaseObject_GetObjectSize(This,pcbSize) \ - (This)->lpVtbl -> GetObjectSize(This,pcbSize) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXBaseObject_GetGenerationId_Proxy( - IDXBaseObject * This, - /* [out] */ ULONG *pID); - - -void __RPC_STUB IDXBaseObject_GetGenerationId_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXBaseObject_IncrementGenerationId_Proxy( - IDXBaseObject * This, - /* [in] */ BOOL bRefresh); - - -void __RPC_STUB IDXBaseObject_IncrementGenerationId_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXBaseObject_GetObjectSize_Proxy( - IDXBaseObject * This, - /* [out] */ ULONG *pcbSize); - - -void __RPC_STUB IDXBaseObject_GetObjectSize_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXBaseObject_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxtrans_0260 */ -/* [local] */ - -typedef -enum DXBNDID - { DXB_X = 0, - DXB_Y = 1, - DXB_Z = 2, - DXB_T = 3 - } DXBNDID; - -typedef -enum DXBNDTYPE - { DXBT_DISCRETE = 0, - DXBT_DISCRETE64 = DXBT_DISCRETE + 1, - DXBT_CONTINUOUS = DXBT_DISCRETE64 + 1, - DXBT_CONTINUOUS64 = DXBT_CONTINUOUS + 1 - } DXBNDTYPE; - -typedef struct DXDBND - { - long Min; - long Max; - } DXDBND; - -typedef DXDBND DXDBNDS[ 4 ]; - -typedef struct DXDBND64 - { - LONGLONG Min; - LONGLONG Max; - } DXDBND64; - -typedef DXDBND64 DXDBNDS64[ 4 ]; - -typedef struct DXCBND - { - float Min; - float Max; - } DXCBND; - -typedef DXCBND DXCBNDS[ 4 ]; - -typedef struct DXCBND64 - { - double Min; - double Max; - } DXCBND64; - -typedef DXCBND64 DXCBNDS64[ 4 ]; - -typedef struct DXBNDS - { - DXBNDTYPE eType; - /* [switch_is] */ /* [switch_type] */ union __MIDL___MIDL_itf_dxtrans_0260_0001 - { - /* [case()] */ DXDBND D[ 4 ]; - /* [case()] */ DXDBND64 LD[ 4 ]; - /* [case()] */ DXCBND C[ 4 ]; - /* [case()] */ DXCBND64 LC[ 4 ]; - } u; - } DXBNDS; - -typedef long DXDVEC[ 4 ]; - -typedef LONGLONG DXDVEC64[ 4 ]; - -typedef float DXCVEC[ 4 ]; - -typedef double DXCVEC64[ 4 ]; - -typedef struct DXVEC - { - DXBNDTYPE eType; - /* [switch_is] */ /* [switch_type] */ union __MIDL___MIDL_itf_dxtrans_0260_0002 - { - /* [case()] */ long D[ 4 ]; - /* [case()] */ LONGLONG LD[ 4 ]; - /* [case()] */ float C[ 4 ]; - /* [case()] */ double LC[ 4 ]; - } u; - } DXVEC; - - - -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0260_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0260_v0_0_s_ifspec; - -#ifndef __IDXTransformFactory_INTERFACE_DEFINED__ -#define __IDXTransformFactory_INTERFACE_DEFINED__ - -/* interface IDXTransformFactory */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXTransformFactory; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("6A950B2B-A971-11d1-81C8-0000F87557DB") - IDXTransformFactory : public IServiceProvider - { - public: - virtual HRESULT STDMETHODCALLTYPE SetService( - /* [in] */ REFGUID guidService, - /* [in] */ IUnknown *pUnkService, - /* [in] */ BOOL bWeakReference) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateTransform( - /* [size_is][in] */ IUnknown **punkInputs, - /* [in] */ ULONG ulNumInputs, - /* [size_is][in] */ IUnknown **punkOutputs, - /* [in] */ ULONG ulNumOutputs, - /* [in] */ IPropertyBag *pInitProps, - /* [in] */ IErrorLog *pErrLog, - /* [in] */ REFCLSID TransCLSID, - /* [in] */ REFIID TransIID, - /* [iid_is][out] */ void **ppTransform) = 0; - - virtual HRESULT STDMETHODCALLTYPE InitializeTransform( - /* [in] */ IDXTransform *pTransform, - /* [size_is][in] */ IUnknown **punkInputs, - /* [in] */ ULONG ulNumInputs, - /* [size_is][in] */ IUnknown **punkOutputs, - /* [in] */ ULONG ulNumOutputs, - /* [in] */ IPropertyBag *pInitProps, - /* [in] */ IErrorLog *pErrLog) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXTransformFactoryVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXTransformFactory * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXTransformFactory * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXTransformFactory * This); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *QueryService )( - IDXTransformFactory * This, - /* [in] */ REFGUID guidService, - /* [in] */ REFIID riid, - /* [out] */ void **ppvObject); - - HRESULT ( STDMETHODCALLTYPE *SetService )( - IDXTransformFactory * This, - /* [in] */ REFGUID guidService, - /* [in] */ IUnknown *pUnkService, - /* [in] */ BOOL bWeakReference); - - HRESULT ( STDMETHODCALLTYPE *CreateTransform )( - IDXTransformFactory * This, - /* [size_is][in] */ IUnknown **punkInputs, - /* [in] */ ULONG ulNumInputs, - /* [size_is][in] */ IUnknown **punkOutputs, - /* [in] */ ULONG ulNumOutputs, - /* [in] */ IPropertyBag *pInitProps, - /* [in] */ IErrorLog *pErrLog, - /* [in] */ REFCLSID TransCLSID, - /* [in] */ REFIID TransIID, - /* [iid_is][out] */ void **ppTransform); - - HRESULT ( STDMETHODCALLTYPE *InitializeTransform )( - IDXTransformFactory * This, - /* [in] */ IDXTransform *pTransform, - /* [size_is][in] */ IUnknown **punkInputs, - /* [in] */ ULONG ulNumInputs, - /* [size_is][in] */ IUnknown **punkOutputs, - /* [in] */ ULONG ulNumOutputs, - /* [in] */ IPropertyBag *pInitProps, - /* [in] */ IErrorLog *pErrLog); - - END_INTERFACE - } IDXTransformFactoryVtbl; - - interface IDXTransformFactory - { - CONST_VTBL struct IDXTransformFactoryVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXTransformFactory_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXTransformFactory_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXTransformFactory_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXTransformFactory_QueryService(This,guidService,riid,ppvObject) \ - (This)->lpVtbl -> QueryService(This,guidService,riid,ppvObject) - - -#define IDXTransformFactory_SetService(This,guidService,pUnkService,bWeakReference) \ - (This)->lpVtbl -> SetService(This,guidService,pUnkService,bWeakReference) - -#define IDXTransformFactory_CreateTransform(This,punkInputs,ulNumInputs,punkOutputs,ulNumOutputs,pInitProps,pErrLog,TransCLSID,TransIID,ppTransform) \ - (This)->lpVtbl -> CreateTransform(This,punkInputs,ulNumInputs,punkOutputs,ulNumOutputs,pInitProps,pErrLog,TransCLSID,TransIID,ppTransform) - -#define IDXTransformFactory_InitializeTransform(This,pTransform,punkInputs,ulNumInputs,punkOutputs,ulNumOutputs,pInitProps,pErrLog) \ - (This)->lpVtbl -> InitializeTransform(This,pTransform,punkInputs,ulNumInputs,punkOutputs,ulNumOutputs,pInitProps,pErrLog) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXTransformFactory_SetService_Proxy( - IDXTransformFactory * This, - /* [in] */ REFGUID guidService, - /* [in] */ IUnknown *pUnkService, - /* [in] */ BOOL bWeakReference); - - -void __RPC_STUB IDXTransformFactory_SetService_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTransformFactory_CreateTransform_Proxy( - IDXTransformFactory * This, - /* [size_is][in] */ IUnknown **punkInputs, - /* [in] */ ULONG ulNumInputs, - /* [size_is][in] */ IUnknown **punkOutputs, - /* [in] */ ULONG ulNumOutputs, - /* [in] */ IPropertyBag *pInitProps, - /* [in] */ IErrorLog *pErrLog, - /* [in] */ REFCLSID TransCLSID, - /* [in] */ REFIID TransIID, - /* [iid_is][out] */ void **ppTransform); - - -void __RPC_STUB IDXTransformFactory_CreateTransform_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTransformFactory_InitializeTransform_Proxy( - IDXTransformFactory * This, - /* [in] */ IDXTransform *pTransform, - /* [size_is][in] */ IUnknown **punkInputs, - /* [in] */ ULONG ulNumInputs, - /* [size_is][in] */ IUnknown **punkOutputs, - /* [in] */ ULONG ulNumOutputs, - /* [in] */ IPropertyBag *pInitProps, - /* [in] */ IErrorLog *pErrLog); - - -void __RPC_STUB IDXTransformFactory_InitializeTransform_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXTransformFactory_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxtrans_0261 */ -/* [local] */ - -typedef -enum DXTMISCFLAGS - { DXTMF_BLEND_WITH_OUTPUT = 1L << 0, - DXTMF_DITHER_OUTPUT = 1L << 1, - DXTMF_OPTION_MASK = 0xffff, - DXTMF_VALID_OPTIONS = DXTMF_BLEND_WITH_OUTPUT | DXTMF_DITHER_OUTPUT, - DXTMF_BLEND_SUPPORTED = 1L << 16, - DXTMF_DITHER_SUPPORTED = 1L << 17, - DXTMF_INPLACE_OPERATION = 1L << 24, - DXTMF_BOUNDS_SUPPORTED = 1L << 25, - DXTMF_PLACEMENT_SUPPORTED = 1L << 26, - DXTMF_QUALITY_SUPPORTED = 1L << 27, - DXTMF_OPAQUE_RESULT = 1L << 28 - } DXTMISCFLAGS; - -typedef -enum DXINOUTINFOFLAGS - { DXINOUTF_OPTIONAL = 1L << 0 - } DXINOUTINFOFLAGS; - - - -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0261_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0261_v0_0_s_ifspec; - -#ifndef __IDXTransform_INTERFACE_DEFINED__ -#define __IDXTransform_INTERFACE_DEFINED__ - -/* interface IDXTransform */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXTransform; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("30A5FB78-E11F-11d1-9064-00C04FD9189D") - IDXTransform : public IDXBaseObject - { - public: - virtual HRESULT STDMETHODCALLTYPE Setup( - /* [size_is][in] */ IUnknown *const *punkInputs, - /* [in] */ ULONG ulNumInputs, - /* [size_is][in] */ IUnknown *const *punkOutputs, - /* [in] */ ULONG ulNumOutputs, - /* [in] */ DWORD dwFlags) = 0; - - virtual HRESULT STDMETHODCALLTYPE Execute( - /* [in] */ const GUID *pRequestID, - /* [in] */ const DXBNDS *pClipBnds, - /* [in] */ const DXVEC *pPlacement) = 0; - - virtual HRESULT STDMETHODCALLTYPE MapBoundsIn2Out( - /* [in] */ const DXBNDS *pInBounds, - /* [in] */ ULONG ulNumInBnds, - /* [in] */ ULONG ulOutIndex, - /* [out] */ DXBNDS *pOutBounds) = 0; - - virtual HRESULT STDMETHODCALLTYPE MapBoundsOut2In( - /* [in] */ ULONG ulOutIndex, - /* [in] */ const DXBNDS *pOutBounds, - /* [in] */ ULONG ulInIndex, - /* [out] */ DXBNDS *pInBounds) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetMiscFlags( - /* [in] */ DWORD dwMiscFlags) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetMiscFlags( - /* [out] */ DWORD *pdwMiscFlags) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetInOutInfo( - /* [in] */ BOOL bIsOutput, - /* [in] */ ULONG ulIndex, - /* [out] */ DWORD *pdwFlags, - /* [size_is][out] */ GUID *pIDs, - /* [out][in] */ ULONG *pcIDs, - /* [out] */ IUnknown **ppUnkCurrentObject) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetQuality( - /* [in] */ float fQuality) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetQuality( - /* [out] */ float *fQuality) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXTransformVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXTransform * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXTransform * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXTransform * This); - - HRESULT ( STDMETHODCALLTYPE *GetGenerationId )( - IDXTransform * This, - /* [out] */ ULONG *pID); - - HRESULT ( STDMETHODCALLTYPE *IncrementGenerationId )( - IDXTransform * This, - /* [in] */ BOOL bRefresh); - - HRESULT ( STDMETHODCALLTYPE *GetObjectSize )( - IDXTransform * This, - /* [out] */ ULONG *pcbSize); - - HRESULT ( STDMETHODCALLTYPE *Setup )( - IDXTransform * This, - /* [size_is][in] */ IUnknown *const *punkInputs, - /* [in] */ ULONG ulNumInputs, - /* [size_is][in] */ IUnknown *const *punkOutputs, - /* [in] */ ULONG ulNumOutputs, - /* [in] */ DWORD dwFlags); - - HRESULT ( STDMETHODCALLTYPE *Execute )( - IDXTransform * This, - /* [in] */ const GUID *pRequestID, - /* [in] */ const DXBNDS *pClipBnds, - /* [in] */ const DXVEC *pPlacement); - - HRESULT ( STDMETHODCALLTYPE *MapBoundsIn2Out )( - IDXTransform * This, - /* [in] */ const DXBNDS *pInBounds, - /* [in] */ ULONG ulNumInBnds, - /* [in] */ ULONG ulOutIndex, - /* [out] */ DXBNDS *pOutBounds); - - HRESULT ( STDMETHODCALLTYPE *MapBoundsOut2In )( - IDXTransform * This, - /* [in] */ ULONG ulOutIndex, - /* [in] */ const DXBNDS *pOutBounds, - /* [in] */ ULONG ulInIndex, - /* [out] */ DXBNDS *pInBounds); - - HRESULT ( STDMETHODCALLTYPE *SetMiscFlags )( - IDXTransform * This, - /* [in] */ DWORD dwMiscFlags); - - HRESULT ( STDMETHODCALLTYPE *GetMiscFlags )( - IDXTransform * This, - /* [out] */ DWORD *pdwMiscFlags); - - HRESULT ( STDMETHODCALLTYPE *GetInOutInfo )( - IDXTransform * This, - /* [in] */ BOOL bIsOutput, - /* [in] */ ULONG ulIndex, - /* [out] */ DWORD *pdwFlags, - /* [size_is][out] */ GUID *pIDs, - /* [out][in] */ ULONG *pcIDs, - /* [out] */ IUnknown **ppUnkCurrentObject); - - HRESULT ( STDMETHODCALLTYPE *SetQuality )( - IDXTransform * This, - /* [in] */ float fQuality); - - HRESULT ( STDMETHODCALLTYPE *GetQuality )( - IDXTransform * This, - /* [out] */ float *fQuality); - - END_INTERFACE - } IDXTransformVtbl; - - interface IDXTransform - { - CONST_VTBL struct IDXTransformVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXTransform_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXTransform_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXTransform_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXTransform_GetGenerationId(This,pID) \ - (This)->lpVtbl -> GetGenerationId(This,pID) - -#define IDXTransform_IncrementGenerationId(This,bRefresh) \ - (This)->lpVtbl -> IncrementGenerationId(This,bRefresh) - -#define IDXTransform_GetObjectSize(This,pcbSize) \ - (This)->lpVtbl -> GetObjectSize(This,pcbSize) - - -#define IDXTransform_Setup(This,punkInputs,ulNumInputs,punkOutputs,ulNumOutputs,dwFlags) \ - (This)->lpVtbl -> Setup(This,punkInputs,ulNumInputs,punkOutputs,ulNumOutputs,dwFlags) - -#define IDXTransform_Execute(This,pRequestID,pClipBnds,pPlacement) \ - (This)->lpVtbl -> Execute(This,pRequestID,pClipBnds,pPlacement) - -#define IDXTransform_MapBoundsIn2Out(This,pInBounds,ulNumInBnds,ulOutIndex,pOutBounds) \ - (This)->lpVtbl -> MapBoundsIn2Out(This,pInBounds,ulNumInBnds,ulOutIndex,pOutBounds) - -#define IDXTransform_MapBoundsOut2In(This,ulOutIndex,pOutBounds,ulInIndex,pInBounds) \ - (This)->lpVtbl -> MapBoundsOut2In(This,ulOutIndex,pOutBounds,ulInIndex,pInBounds) - -#define IDXTransform_SetMiscFlags(This,dwMiscFlags) \ - (This)->lpVtbl -> SetMiscFlags(This,dwMiscFlags) - -#define IDXTransform_GetMiscFlags(This,pdwMiscFlags) \ - (This)->lpVtbl -> GetMiscFlags(This,pdwMiscFlags) - -#define IDXTransform_GetInOutInfo(This,bIsOutput,ulIndex,pdwFlags,pIDs,pcIDs,ppUnkCurrentObject) \ - (This)->lpVtbl -> GetInOutInfo(This,bIsOutput,ulIndex,pdwFlags,pIDs,pcIDs,ppUnkCurrentObject) - -#define IDXTransform_SetQuality(This,fQuality) \ - (This)->lpVtbl -> SetQuality(This,fQuality) - -#define IDXTransform_GetQuality(This,fQuality) \ - (This)->lpVtbl -> GetQuality(This,fQuality) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXTransform_Setup_Proxy( - IDXTransform * This, - /* [size_is][in] */ IUnknown *const *punkInputs, - /* [in] */ ULONG ulNumInputs, - /* [size_is][in] */ IUnknown *const *punkOutputs, - /* [in] */ ULONG ulNumOutputs, - /* [in] */ DWORD dwFlags); - - -void __RPC_STUB IDXTransform_Setup_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTransform_Execute_Proxy( - IDXTransform * This, - /* [in] */ const GUID *pRequestID, - /* [in] */ const DXBNDS *pClipBnds, - /* [in] */ const DXVEC *pPlacement); - - -void __RPC_STUB IDXTransform_Execute_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTransform_MapBoundsIn2Out_Proxy( - IDXTransform * This, - /* [in] */ const DXBNDS *pInBounds, - /* [in] */ ULONG ulNumInBnds, - /* [in] */ ULONG ulOutIndex, - /* [out] */ DXBNDS *pOutBounds); - - -void __RPC_STUB IDXTransform_MapBoundsIn2Out_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTransform_MapBoundsOut2In_Proxy( - IDXTransform * This, - /* [in] */ ULONG ulOutIndex, - /* [in] */ const DXBNDS *pOutBounds, - /* [in] */ ULONG ulInIndex, - /* [out] */ DXBNDS *pInBounds); - - -void __RPC_STUB IDXTransform_MapBoundsOut2In_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTransform_SetMiscFlags_Proxy( - IDXTransform * This, - /* [in] */ DWORD dwMiscFlags); - - -void __RPC_STUB IDXTransform_SetMiscFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTransform_GetMiscFlags_Proxy( - IDXTransform * This, - /* [out] */ DWORD *pdwMiscFlags); - - -void __RPC_STUB IDXTransform_GetMiscFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTransform_GetInOutInfo_Proxy( - IDXTransform * This, - /* [in] */ BOOL bIsOutput, - /* [in] */ ULONG ulIndex, - /* [out] */ DWORD *pdwFlags, - /* [size_is][out] */ GUID *pIDs, - /* [out][in] */ ULONG *pcIDs, - /* [out] */ IUnknown **ppUnkCurrentObject); - - -void __RPC_STUB IDXTransform_GetInOutInfo_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTransform_SetQuality_Proxy( - IDXTransform * This, - /* [in] */ float fQuality); - - -void __RPC_STUB IDXTransform_SetQuality_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTransform_GetQuality_Proxy( - IDXTransform * This, - /* [out] */ float *fQuality); - - -void __RPC_STUB IDXTransform_GetQuality_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXTransform_INTERFACE_DEFINED__ */ - - -#ifndef __IDXSurfacePick_INTERFACE_DEFINED__ -#define __IDXSurfacePick_INTERFACE_DEFINED__ - -/* interface IDXSurfacePick */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXSurfacePick; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("30A5FB79-E11F-11d1-9064-00C04FD9189D") - IDXSurfacePick : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE PointPick( - /* [in] */ const DXVEC *pPoint, - /* [out] */ ULONG *pulInputSurfaceIndex, - /* [out] */ DXVEC *pInputPoint) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXSurfacePickVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXSurfacePick * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXSurfacePick * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXSurfacePick * This); - - HRESULT ( STDMETHODCALLTYPE *PointPick )( - IDXSurfacePick * This, - /* [in] */ const DXVEC *pPoint, - /* [out] */ ULONG *pulInputSurfaceIndex, - /* [out] */ DXVEC *pInputPoint); - - END_INTERFACE - } IDXSurfacePickVtbl; - - interface IDXSurfacePick - { - CONST_VTBL struct IDXSurfacePickVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXSurfacePick_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXSurfacePick_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXSurfacePick_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXSurfacePick_PointPick(This,pPoint,pulInputSurfaceIndex,pInputPoint) \ - (This)->lpVtbl -> PointPick(This,pPoint,pulInputSurfaceIndex,pInputPoint) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXSurfacePick_PointPick_Proxy( - IDXSurfacePick * This, - /* [in] */ const DXVEC *pPoint, - /* [out] */ ULONG *pulInputSurfaceIndex, - /* [out] */ DXVEC *pInputPoint); - - -void __RPC_STUB IDXSurfacePick_PointPick_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXSurfacePick_INTERFACE_DEFINED__ */ - - -#ifndef __IDXTBindHost_INTERFACE_DEFINED__ -#define __IDXTBindHost_INTERFACE_DEFINED__ - -/* interface IDXTBindHost */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXTBindHost; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("D26BCE55-E9DC-11d1-9066-00C04FD9189D") - IDXTBindHost : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE SetBindHost( - /* [in] */ IBindHost *pBindHost) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXTBindHostVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXTBindHost * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXTBindHost * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXTBindHost * This); - - HRESULT ( STDMETHODCALLTYPE *SetBindHost )( - IDXTBindHost * This, - /* [in] */ IBindHost *pBindHost); - - END_INTERFACE - } IDXTBindHostVtbl; - - interface IDXTBindHost - { - CONST_VTBL struct IDXTBindHostVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXTBindHost_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXTBindHost_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXTBindHost_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXTBindHost_SetBindHost(This,pBindHost) \ - (This)->lpVtbl -> SetBindHost(This,pBindHost) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXTBindHost_SetBindHost_Proxy( - IDXTBindHost * This, - /* [in] */ IBindHost *pBindHost); - - -void __RPC_STUB IDXTBindHost_SetBindHost_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXTBindHost_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxtrans_0264 */ -/* [local] */ - -typedef void __stdcall __stdcall DXTASKPROC( - void *pTaskData, - BOOL *pbContinueProcessing); - -typedef DXTASKPROC *PFNDXTASKPROC; - -typedef void __stdcall __stdcall DXAPCPROC( - DWORD dwData); - -typedef DXAPCPROC *PFNDXAPCPROC; - -#ifdef __cplusplus -typedef struct DXTMTASKINFO -{ - PFNDXTASKPROC pfnTaskProc; // Pointer to function to execute - PVOID pTaskData; // Pointer to argument data - PFNDXAPCPROC pfnCompletionAPC; // Pointer to completion APC proc - DWORD dwCompletionData; // Pointer to APC proc data - const GUID* pRequestID; // Used to identify groups of tasks -} DXTMTASKINFO; -#else -typedef struct DXTMTASKINFO - { - PVOID pfnTaskProc; - PVOID pTaskData; - PVOID pfnCompletionAPC; - DWORD dwCompletionData; - const GUID *pRequestID; - } DXTMTASKINFO; - -#endif - - -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0264_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0264_v0_0_s_ifspec; - -#ifndef __IDXTaskManager_INTERFACE_DEFINED__ -#define __IDXTaskManager_INTERFACE_DEFINED__ - -/* interface IDXTaskManager */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXTaskManager; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("254DBBC1-F922-11d0-883A-3C8B00C10000") - IDXTaskManager : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE QueryNumProcessors( - /* [out] */ ULONG *pulNumProc) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetThreadPoolSize( - /* [in] */ ULONG ulNumThreads) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetThreadPoolSize( - /* [out] */ ULONG *pulNumThreads) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetConcurrencyLimit( - /* [in] */ ULONG ulNumThreads) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetConcurrencyLimit( - /* [out] */ ULONG *pulNumThreads) = 0; - - virtual HRESULT STDMETHODCALLTYPE ScheduleTasks( - /* [in] */ DXTMTASKINFO TaskInfo[ ], - /* [in] */ HANDLE Events[ ], - /* [out] */ DWORD TaskIDs[ ], - /* [in] */ ULONG ulNumTasks, - /* [in] */ ULONG ulWaitPeriod) = 0; - - virtual HRESULT STDMETHODCALLTYPE TerminateTasks( - /* [in] */ DWORD TaskIDs[ ], - /* [in] */ ULONG ulCount, - /* [in] */ ULONG ulTimeOut) = 0; - - virtual HRESULT STDMETHODCALLTYPE TerminateRequest( - /* [in] */ REFIID RequestID, - /* [in] */ ULONG ulTimeOut) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXTaskManagerVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXTaskManager * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXTaskManager * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXTaskManager * This); - - HRESULT ( STDMETHODCALLTYPE *QueryNumProcessors )( - IDXTaskManager * This, - /* [out] */ ULONG *pulNumProc); - - HRESULT ( STDMETHODCALLTYPE *SetThreadPoolSize )( - IDXTaskManager * This, - /* [in] */ ULONG ulNumThreads); - - HRESULT ( STDMETHODCALLTYPE *GetThreadPoolSize )( - IDXTaskManager * This, - /* [out] */ ULONG *pulNumThreads); - - HRESULT ( STDMETHODCALLTYPE *SetConcurrencyLimit )( - IDXTaskManager * This, - /* [in] */ ULONG ulNumThreads); - - HRESULT ( STDMETHODCALLTYPE *GetConcurrencyLimit )( - IDXTaskManager * This, - /* [out] */ ULONG *pulNumThreads); - - HRESULT ( STDMETHODCALLTYPE *ScheduleTasks )( - IDXTaskManager * This, - /* [in] */ DXTMTASKINFO TaskInfo[ ], - /* [in] */ HANDLE Events[ ], - /* [out] */ DWORD TaskIDs[ ], - /* [in] */ ULONG ulNumTasks, - /* [in] */ ULONG ulWaitPeriod); - - HRESULT ( STDMETHODCALLTYPE *TerminateTasks )( - IDXTaskManager * This, - /* [in] */ DWORD TaskIDs[ ], - /* [in] */ ULONG ulCount, - /* [in] */ ULONG ulTimeOut); - - HRESULT ( STDMETHODCALLTYPE *TerminateRequest )( - IDXTaskManager * This, - /* [in] */ REFIID RequestID, - /* [in] */ ULONG ulTimeOut); - - END_INTERFACE - } IDXTaskManagerVtbl; - - interface IDXTaskManager - { - CONST_VTBL struct IDXTaskManagerVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXTaskManager_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXTaskManager_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXTaskManager_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXTaskManager_QueryNumProcessors(This,pulNumProc) \ - (This)->lpVtbl -> QueryNumProcessors(This,pulNumProc) - -#define IDXTaskManager_SetThreadPoolSize(This,ulNumThreads) \ - (This)->lpVtbl -> SetThreadPoolSize(This,ulNumThreads) - -#define IDXTaskManager_GetThreadPoolSize(This,pulNumThreads) \ - (This)->lpVtbl -> GetThreadPoolSize(This,pulNumThreads) - -#define IDXTaskManager_SetConcurrencyLimit(This,ulNumThreads) \ - (This)->lpVtbl -> SetConcurrencyLimit(This,ulNumThreads) - -#define IDXTaskManager_GetConcurrencyLimit(This,pulNumThreads) \ - (This)->lpVtbl -> GetConcurrencyLimit(This,pulNumThreads) - -#define IDXTaskManager_ScheduleTasks(This,TaskInfo,Events,TaskIDs,ulNumTasks,ulWaitPeriod) \ - (This)->lpVtbl -> ScheduleTasks(This,TaskInfo,Events,TaskIDs,ulNumTasks,ulWaitPeriod) - -#define IDXTaskManager_TerminateTasks(This,TaskIDs,ulCount,ulTimeOut) \ - (This)->lpVtbl -> TerminateTasks(This,TaskIDs,ulCount,ulTimeOut) - -#define IDXTaskManager_TerminateRequest(This,RequestID,ulTimeOut) \ - (This)->lpVtbl -> TerminateRequest(This,RequestID,ulTimeOut) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXTaskManager_QueryNumProcessors_Proxy( - IDXTaskManager * This, - /* [out] */ ULONG *pulNumProc); - - -void __RPC_STUB IDXTaskManager_QueryNumProcessors_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTaskManager_SetThreadPoolSize_Proxy( - IDXTaskManager * This, - /* [in] */ ULONG ulNumThreads); - - -void __RPC_STUB IDXTaskManager_SetThreadPoolSize_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTaskManager_GetThreadPoolSize_Proxy( - IDXTaskManager * This, - /* [out] */ ULONG *pulNumThreads); - - -void __RPC_STUB IDXTaskManager_GetThreadPoolSize_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTaskManager_SetConcurrencyLimit_Proxy( - IDXTaskManager * This, - /* [in] */ ULONG ulNumThreads); - - -void __RPC_STUB IDXTaskManager_SetConcurrencyLimit_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTaskManager_GetConcurrencyLimit_Proxy( - IDXTaskManager * This, - /* [out] */ ULONG *pulNumThreads); - - -void __RPC_STUB IDXTaskManager_GetConcurrencyLimit_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTaskManager_ScheduleTasks_Proxy( - IDXTaskManager * This, - /* [in] */ DXTMTASKINFO TaskInfo[ ], - /* [in] */ HANDLE Events[ ], - /* [out] */ DWORD TaskIDs[ ], - /* [in] */ ULONG ulNumTasks, - /* [in] */ ULONG ulWaitPeriod); - - -void __RPC_STUB IDXTaskManager_ScheduleTasks_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTaskManager_TerminateTasks_Proxy( - IDXTaskManager * This, - /* [in] */ DWORD TaskIDs[ ], - /* [in] */ ULONG ulCount, - /* [in] */ ULONG ulTimeOut); - - -void __RPC_STUB IDXTaskManager_TerminateTasks_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTaskManager_TerminateRequest_Proxy( - IDXTaskManager * This, - /* [in] */ REFIID RequestID, - /* [in] */ ULONG ulTimeOut); - - -void __RPC_STUB IDXTaskManager_TerminateRequest_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXTaskManager_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxtrans_0265 */ -/* [local] */ - -#ifdef __cplusplus -///////////////////////////////////////////////////// - -class DXBASESAMPLE; -class DXSAMPLE; -class DXPMSAMPLE; - -///////////////////////////////////////////////////// - -class DXBASESAMPLE -{ -public: - BYTE Blue; - BYTE Green; - BYTE Red; - BYTE Alpha; - DXBASESAMPLE() {} - DXBASESAMPLE(const BYTE alpha, const BYTE red, const BYTE green, const BYTE blue) : - Alpha(alpha), - Red(red), - Green(green), - Blue(blue) {} - DXBASESAMPLE(const DWORD val) { *this = (*(DXBASESAMPLE *)&val); } - operator DWORD () const {return *((DWORD *)this); } - DWORD operator=(const DWORD val) { return *this = *((DXBASESAMPLE *)&val); } -}; // DXBASESAMPLE - -///////////////////////////////////////////////////// - -class DXSAMPLE : public DXBASESAMPLE -{ -public: - DXSAMPLE() {} - DXSAMPLE(const BYTE alpha, const BYTE red, const BYTE green, const BYTE blue) : - DXBASESAMPLE(alpha, red, green, blue) {} - DXSAMPLE(const DWORD val) { *this = (*(DXSAMPLE *)&val); } - operator DWORD () const {return *((DWORD *)this); } - DWORD operator=(const DWORD val) { return *this = *((DXSAMPLE *)&val); } - operator DXPMSAMPLE() const; -}; // DXSAMPLE - -///////////////////////////////////////////////////// - -class DXPMSAMPLE : public DXBASESAMPLE -{ -public: - DXPMSAMPLE() {} - DXPMSAMPLE(const BYTE alpha, const BYTE red, const BYTE green, const BYTE blue) : - DXBASESAMPLE(alpha, red, green, blue) {} - DXPMSAMPLE(const DWORD val) { *this = (*(DXPMSAMPLE *)&val); } - operator DWORD () const {return *((DWORD *)this); } - DWORD operator=(const DWORD val) { return *this = *((DXPMSAMPLE *)&val); } - operator DXSAMPLE() const; -}; // DXPMSAMPLE - -// -// The following cast operators are to prevent a direct assignment of a DXSAMPLE to a DXPMSAMPLE -// -inline DXSAMPLE::operator DXPMSAMPLE() const { return *((DXPMSAMPLE *)this); } -inline DXPMSAMPLE::operator DXSAMPLE() const { return *((DXSAMPLE *)this); } -#else // !__cplusplus -typedef struct DXBASESAMPLE - { - BYTE Blue; - BYTE Green; - BYTE Red; - BYTE Alpha; - } DXBASESAMPLE; - -typedef struct DXSAMPLE - { - BYTE Blue; - BYTE Green; - BYTE Red; - BYTE Alpha; - } DXSAMPLE; - -typedef struct DXPMSAMPLE - { - BYTE Blue; - BYTE Green; - BYTE Red; - BYTE Alpha; - } DXPMSAMPLE; - -#endif // !__cplusplus -typedef -enum DXRUNTYPE - { DXRUNTYPE_CLEAR = 0, - DXRUNTYPE_OPAQUE = 1, - DXRUNTYPE_TRANS = 2, - DXRUNTYPE_UNKNOWN = 3 - } DXRUNTYPE; - -#define DX_MAX_RUN_INFO_COUNT ( 128 ) - -// Ignore the definition used by MIDL for TLB generation -#if 0 -typedef struct DXRUNINFO - { - ULONG Bitfields; - } DXRUNINFO; - -#endif // 0 -typedef struct DXRUNINFO -{ - ULONG Type : 2; // Type - ULONG Count : 30; // Number of samples in run -} DXRUNINFO; -typedef -enum DXSFCREATE - { DXSF_FORMAT_IS_CLSID = 1L << 0, - DXSF_NO_LAZY_DDRAW_LOCK = 1L << 1 - } DXSFCREATE; - -typedef -enum DXBLTOPTIONS - { DXBOF_DO_OVER = 1L << 0, - DXBOF_DITHER = 1L << 1 - } DXBLTOPTIONS; - - - -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0265_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0265_v0_0_s_ifspec; - -#ifndef __IDXSurfaceFactory_INTERFACE_DEFINED__ -#define __IDXSurfaceFactory_INTERFACE_DEFINED__ - -/* interface IDXSurfaceFactory */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXSurfaceFactory; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("144946F5-C4D4-11d1-81D1-0000F87557DB") - IDXSurfaceFactory : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE CreateSurface( - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pFormatID, - /* [in] */ const DXBNDS *pBounds, - /* [in] */ DWORD dwFlags, - /* [in] */ IUnknown *punkOuter, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppDXSurface) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateFromDDSurface( - /* [in] */ IUnknown *pDDrawSurface, - /* [in] */ const GUID *pFormatID, - /* [in] */ DWORD dwFlags, - /* [in] */ IUnknown *punkOuter, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppDXSurface) = 0; - - virtual HRESULT STDMETHODCALLTYPE LoadImage( - /* [in] */ const LPWSTR pszFileName, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pFormatID, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppDXSurface) = 0; - - virtual HRESULT STDMETHODCALLTYPE LoadImageFromStream( - /* [in] */ IStream *pStream, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pFormatID, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppDXSurface) = 0; - - virtual HRESULT STDMETHODCALLTYPE CopySurfaceToNewFormat( - /* [in] */ IDXSurface *pSrc, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pDestFormatID, - /* [out] */ IDXSurface **ppNewSurface) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateD3DRMTexture( - /* [in] */ IDXSurface *pSrc, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ IUnknown *pD3DRM3, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppTexture3) = 0; - - virtual HRESULT STDMETHODCALLTYPE BitBlt( - /* [in] */ IDXSurface *pDest, - /* [in] */ const DXVEC *pPlacement, - /* [in] */ IDXSurface *pSrc, - /* [in] */ const DXBNDS *pClipBounds, - /* [in] */ DWORD dwFlags) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXSurfaceFactoryVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXSurfaceFactory * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXSurfaceFactory * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXSurfaceFactory * This); - - HRESULT ( STDMETHODCALLTYPE *CreateSurface )( - IDXSurfaceFactory * This, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pFormatID, - /* [in] */ const DXBNDS *pBounds, - /* [in] */ DWORD dwFlags, - /* [in] */ IUnknown *punkOuter, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppDXSurface); - - HRESULT ( STDMETHODCALLTYPE *CreateFromDDSurface )( - IDXSurfaceFactory * This, - /* [in] */ IUnknown *pDDrawSurface, - /* [in] */ const GUID *pFormatID, - /* [in] */ DWORD dwFlags, - /* [in] */ IUnknown *punkOuter, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppDXSurface); - - HRESULT ( STDMETHODCALLTYPE *LoadImage )( - IDXSurfaceFactory * This, - /* [in] */ const LPWSTR pszFileName, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pFormatID, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppDXSurface); - - HRESULT ( STDMETHODCALLTYPE *LoadImageFromStream )( - IDXSurfaceFactory * This, - /* [in] */ IStream *pStream, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pFormatID, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppDXSurface); - - HRESULT ( STDMETHODCALLTYPE *CopySurfaceToNewFormat )( - IDXSurfaceFactory * This, - /* [in] */ IDXSurface *pSrc, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pDestFormatID, - /* [out] */ IDXSurface **ppNewSurface); - - HRESULT ( STDMETHODCALLTYPE *CreateD3DRMTexture )( - IDXSurfaceFactory * This, - /* [in] */ IDXSurface *pSrc, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ IUnknown *pD3DRM3, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppTexture3); - - HRESULT ( STDMETHODCALLTYPE *BitBlt )( - IDXSurfaceFactory * This, - /* [in] */ IDXSurface *pDest, - /* [in] */ const DXVEC *pPlacement, - /* [in] */ IDXSurface *pSrc, - /* [in] */ const DXBNDS *pClipBounds, - /* [in] */ DWORD dwFlags); - - END_INTERFACE - } IDXSurfaceFactoryVtbl; - - interface IDXSurfaceFactory - { - CONST_VTBL struct IDXSurfaceFactoryVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXSurfaceFactory_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXSurfaceFactory_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXSurfaceFactory_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXSurfaceFactory_CreateSurface(This,pDirectDraw,pDDSurfaceDesc,pFormatID,pBounds,dwFlags,punkOuter,riid,ppDXSurface) \ - (This)->lpVtbl -> CreateSurface(This,pDirectDraw,pDDSurfaceDesc,pFormatID,pBounds,dwFlags,punkOuter,riid,ppDXSurface) - -#define IDXSurfaceFactory_CreateFromDDSurface(This,pDDrawSurface,pFormatID,dwFlags,punkOuter,riid,ppDXSurface) \ - (This)->lpVtbl -> CreateFromDDSurface(This,pDDrawSurface,pFormatID,dwFlags,punkOuter,riid,ppDXSurface) - -#define IDXSurfaceFactory_LoadImage(This,pszFileName,pDirectDraw,pDDSurfaceDesc,pFormatID,riid,ppDXSurface) \ - (This)->lpVtbl -> LoadImage(This,pszFileName,pDirectDraw,pDDSurfaceDesc,pFormatID,riid,ppDXSurface) - -#define IDXSurfaceFactory_LoadImageFromStream(This,pStream,pDirectDraw,pDDSurfaceDesc,pFormatID,riid,ppDXSurface) \ - (This)->lpVtbl -> LoadImageFromStream(This,pStream,pDirectDraw,pDDSurfaceDesc,pFormatID,riid,ppDXSurface) - -#define IDXSurfaceFactory_CopySurfaceToNewFormat(This,pSrc,pDirectDraw,pDDSurfaceDesc,pDestFormatID,ppNewSurface) \ - (This)->lpVtbl -> CopySurfaceToNewFormat(This,pSrc,pDirectDraw,pDDSurfaceDesc,pDestFormatID,ppNewSurface) - -#define IDXSurfaceFactory_CreateD3DRMTexture(This,pSrc,pDirectDraw,pD3DRM3,riid,ppTexture3) \ - (This)->lpVtbl -> CreateD3DRMTexture(This,pSrc,pDirectDraw,pD3DRM3,riid,ppTexture3) - -#define IDXSurfaceFactory_BitBlt(This,pDest,pPlacement,pSrc,pClipBounds,dwFlags) \ - (This)->lpVtbl -> BitBlt(This,pDest,pPlacement,pSrc,pClipBounds,dwFlags) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXSurfaceFactory_CreateSurface_Proxy( - IDXSurfaceFactory * This, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pFormatID, - /* [in] */ const DXBNDS *pBounds, - /* [in] */ DWORD dwFlags, - /* [in] */ IUnknown *punkOuter, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppDXSurface); - - -void __RPC_STUB IDXSurfaceFactory_CreateSurface_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceFactory_CreateFromDDSurface_Proxy( - IDXSurfaceFactory * This, - /* [in] */ IUnknown *pDDrawSurface, - /* [in] */ const GUID *pFormatID, - /* [in] */ DWORD dwFlags, - /* [in] */ IUnknown *punkOuter, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppDXSurface); - - -void __RPC_STUB IDXSurfaceFactory_CreateFromDDSurface_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceFactory_LoadImage_Proxy( - IDXSurfaceFactory * This, - /* [in] */ const LPWSTR pszFileName, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pFormatID, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppDXSurface); - - -void __RPC_STUB IDXSurfaceFactory_LoadImage_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceFactory_LoadImageFromStream_Proxy( - IDXSurfaceFactory * This, - /* [in] */ IStream *pStream, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pFormatID, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppDXSurface); - - -void __RPC_STUB IDXSurfaceFactory_LoadImageFromStream_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceFactory_CopySurfaceToNewFormat_Proxy( - IDXSurfaceFactory * This, - /* [in] */ IDXSurface *pSrc, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pDestFormatID, - /* [out] */ IDXSurface **ppNewSurface); - - -void __RPC_STUB IDXSurfaceFactory_CopySurfaceToNewFormat_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceFactory_CreateD3DRMTexture_Proxy( - IDXSurfaceFactory * This, - /* [in] */ IDXSurface *pSrc, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ IUnknown *pD3DRM3, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppTexture3); - - -void __RPC_STUB IDXSurfaceFactory_CreateD3DRMTexture_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceFactory_BitBlt_Proxy( - IDXSurfaceFactory * This, - /* [in] */ IDXSurface *pDest, - /* [in] */ const DXVEC *pPlacement, - /* [in] */ IDXSurface *pSrc, - /* [in] */ const DXBNDS *pClipBounds, - /* [in] */ DWORD dwFlags); - - -void __RPC_STUB IDXSurfaceFactory_BitBlt_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXSurfaceFactory_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxtrans_0266 */ -/* [local] */ - -typedef -enum DXSURFMODCOMPOP - { DXSURFMOD_COMP_OVER = 0, - DXSURFMOD_COMP_ALPHA_MASK = 1, - DXSURFMOD_COMP_MAX_VALID = 1 - } DXSURFMODCOMPOP; - - - -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0266_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0266_v0_0_s_ifspec; - -#ifndef __IDXSurfaceModifier_INTERFACE_DEFINED__ -#define __IDXSurfaceModifier_INTERFACE_DEFINED__ - -/* interface IDXSurfaceModifier */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXSurfaceModifier; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9EA3B637-C37D-11d1-905E-00C04FD9189D") - IDXSurfaceModifier : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE SetFillColor( - /* [in] */ DXSAMPLE Color) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetFillColor( - /* [out] */ DXSAMPLE *pColor) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetBounds( - /* [in] */ const DXBNDS *pBounds) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetBackground( - /* [in] */ IDXSurface *pSurface) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetBackground( - /* [out] */ IDXSurface **ppSurface) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetCompositeOperation( - /* [in] */ DXSURFMODCOMPOP CompOp) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetCompositeOperation( - /* [out] */ DXSURFMODCOMPOP *pCompOp) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetForeground( - /* [in] */ IDXSurface *pSurface, - /* [in] */ BOOL bTile, - /* [in] */ const POINT *pOrigin) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetForeground( - /* [out] */ IDXSurface **ppSurface, - /* [out] */ BOOL *pbTile, - /* [out] */ POINT *pOrigin) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetOpacity( - /* [in] */ float Opacity) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetOpacity( - /* [out] */ float *pOpacity) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetLookup( - /* [in] */ IDXLookupTable *pLookupTable) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetLookup( - /* [out] */ IDXLookupTable **ppLookupTable) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXSurfaceModifierVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXSurfaceModifier * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXSurfaceModifier * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXSurfaceModifier * This); - - HRESULT ( STDMETHODCALLTYPE *SetFillColor )( - IDXSurfaceModifier * This, - /* [in] */ DXSAMPLE Color); - - HRESULT ( STDMETHODCALLTYPE *GetFillColor )( - IDXSurfaceModifier * This, - /* [out] */ DXSAMPLE *pColor); - - HRESULT ( STDMETHODCALLTYPE *SetBounds )( - IDXSurfaceModifier * This, - /* [in] */ const DXBNDS *pBounds); - - HRESULT ( STDMETHODCALLTYPE *SetBackground )( - IDXSurfaceModifier * This, - /* [in] */ IDXSurface *pSurface); - - HRESULT ( STDMETHODCALLTYPE *GetBackground )( - IDXSurfaceModifier * This, - /* [out] */ IDXSurface **ppSurface); - - HRESULT ( STDMETHODCALLTYPE *SetCompositeOperation )( - IDXSurfaceModifier * This, - /* [in] */ DXSURFMODCOMPOP CompOp); - - HRESULT ( STDMETHODCALLTYPE *GetCompositeOperation )( - IDXSurfaceModifier * This, - /* [out] */ DXSURFMODCOMPOP *pCompOp); - - HRESULT ( STDMETHODCALLTYPE *SetForeground )( - IDXSurfaceModifier * This, - /* [in] */ IDXSurface *pSurface, - /* [in] */ BOOL bTile, - /* [in] */ const POINT *pOrigin); - - HRESULT ( STDMETHODCALLTYPE *GetForeground )( - IDXSurfaceModifier * This, - /* [out] */ IDXSurface **ppSurface, - /* [out] */ BOOL *pbTile, - /* [out] */ POINT *pOrigin); - - HRESULT ( STDMETHODCALLTYPE *SetOpacity )( - IDXSurfaceModifier * This, - /* [in] */ float Opacity); - - HRESULT ( STDMETHODCALLTYPE *GetOpacity )( - IDXSurfaceModifier * This, - /* [out] */ float *pOpacity); - - HRESULT ( STDMETHODCALLTYPE *SetLookup )( - IDXSurfaceModifier * This, - /* [in] */ IDXLookupTable *pLookupTable); - - HRESULT ( STDMETHODCALLTYPE *GetLookup )( - IDXSurfaceModifier * This, - /* [out] */ IDXLookupTable **ppLookupTable); - - END_INTERFACE - } IDXSurfaceModifierVtbl; - - interface IDXSurfaceModifier - { - CONST_VTBL struct IDXSurfaceModifierVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXSurfaceModifier_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXSurfaceModifier_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXSurfaceModifier_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXSurfaceModifier_SetFillColor(This,Color) \ - (This)->lpVtbl -> SetFillColor(This,Color) - -#define IDXSurfaceModifier_GetFillColor(This,pColor) \ - (This)->lpVtbl -> GetFillColor(This,pColor) - -#define IDXSurfaceModifier_SetBounds(This,pBounds) \ - (This)->lpVtbl -> SetBounds(This,pBounds) - -#define IDXSurfaceModifier_SetBackground(This,pSurface) \ - (This)->lpVtbl -> SetBackground(This,pSurface) - -#define IDXSurfaceModifier_GetBackground(This,ppSurface) \ - (This)->lpVtbl -> GetBackground(This,ppSurface) - -#define IDXSurfaceModifier_SetCompositeOperation(This,CompOp) \ - (This)->lpVtbl -> SetCompositeOperation(This,CompOp) - -#define IDXSurfaceModifier_GetCompositeOperation(This,pCompOp) \ - (This)->lpVtbl -> GetCompositeOperation(This,pCompOp) - -#define IDXSurfaceModifier_SetForeground(This,pSurface,bTile,pOrigin) \ - (This)->lpVtbl -> SetForeground(This,pSurface,bTile,pOrigin) - -#define IDXSurfaceModifier_GetForeground(This,ppSurface,pbTile,pOrigin) \ - (This)->lpVtbl -> GetForeground(This,ppSurface,pbTile,pOrigin) - -#define IDXSurfaceModifier_SetOpacity(This,Opacity) \ - (This)->lpVtbl -> SetOpacity(This,Opacity) - -#define IDXSurfaceModifier_GetOpacity(This,pOpacity) \ - (This)->lpVtbl -> GetOpacity(This,pOpacity) - -#define IDXSurfaceModifier_SetLookup(This,pLookupTable) \ - (This)->lpVtbl -> SetLookup(This,pLookupTable) - -#define IDXSurfaceModifier_GetLookup(This,ppLookupTable) \ - (This)->lpVtbl -> GetLookup(This,ppLookupTable) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_SetFillColor_Proxy( - IDXSurfaceModifier * This, - /* [in] */ DXSAMPLE Color); - - -void __RPC_STUB IDXSurfaceModifier_SetFillColor_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_GetFillColor_Proxy( - IDXSurfaceModifier * This, - /* [out] */ DXSAMPLE *pColor); - - -void __RPC_STUB IDXSurfaceModifier_GetFillColor_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_SetBounds_Proxy( - IDXSurfaceModifier * This, - /* [in] */ const DXBNDS *pBounds); - - -void __RPC_STUB IDXSurfaceModifier_SetBounds_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_SetBackground_Proxy( - IDXSurfaceModifier * This, - /* [in] */ IDXSurface *pSurface); - - -void __RPC_STUB IDXSurfaceModifier_SetBackground_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_GetBackground_Proxy( - IDXSurfaceModifier * This, - /* [out] */ IDXSurface **ppSurface); - - -void __RPC_STUB IDXSurfaceModifier_GetBackground_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_SetCompositeOperation_Proxy( - IDXSurfaceModifier * This, - /* [in] */ DXSURFMODCOMPOP CompOp); - - -void __RPC_STUB IDXSurfaceModifier_SetCompositeOperation_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_GetCompositeOperation_Proxy( - IDXSurfaceModifier * This, - /* [out] */ DXSURFMODCOMPOP *pCompOp); - - -void __RPC_STUB IDXSurfaceModifier_GetCompositeOperation_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_SetForeground_Proxy( - IDXSurfaceModifier * This, - /* [in] */ IDXSurface *pSurface, - /* [in] */ BOOL bTile, - /* [in] */ const POINT *pOrigin); - - -void __RPC_STUB IDXSurfaceModifier_SetForeground_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_GetForeground_Proxy( - IDXSurfaceModifier * This, - /* [out] */ IDXSurface **ppSurface, - /* [out] */ BOOL *pbTile, - /* [out] */ POINT *pOrigin); - - -void __RPC_STUB IDXSurfaceModifier_GetForeground_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_SetOpacity_Proxy( - IDXSurfaceModifier * This, - /* [in] */ float Opacity); - - -void __RPC_STUB IDXSurfaceModifier_SetOpacity_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_GetOpacity_Proxy( - IDXSurfaceModifier * This, - /* [out] */ float *pOpacity); - - -void __RPC_STUB IDXSurfaceModifier_GetOpacity_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_SetLookup_Proxy( - IDXSurfaceModifier * This, - /* [in] */ IDXLookupTable *pLookupTable); - - -void __RPC_STUB IDXSurfaceModifier_SetLookup_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_GetLookup_Proxy( - IDXSurfaceModifier * This, - /* [out] */ IDXLookupTable **ppLookupTable); - - -void __RPC_STUB IDXSurfaceModifier_GetLookup_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXSurfaceModifier_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxtrans_0267 */ -/* [local] */ - -typedef -enum DXSAMPLEFORMATENUM - { DXPF_FLAGSMASK = 0xffff0000, - DXPF_NONPREMULT = 0x10000, - DXPF_TRANSPARENCY = 0x20000, - DXPF_TRANSLUCENCY = 0x40000, - DXPF_2BITERROR = 0x200000, - DXPF_3BITERROR = 0x300000, - DXPF_4BITERROR = 0x400000, - DXPF_5BITERROR = 0x500000, - DXPF_ERRORMASK = 0x700000, - DXPF_NONSTANDARD = 0, - DXPF_PMARGB32 = 1 | DXPF_TRANSPARENCY | DXPF_TRANSLUCENCY, - DXPF_ARGB32 = 2 | DXPF_NONPREMULT | DXPF_TRANSPARENCY | DXPF_TRANSLUCENCY, - DXPF_ARGB4444 = 3 | DXPF_NONPREMULT | DXPF_TRANSPARENCY | DXPF_TRANSLUCENCY | DXPF_4BITERROR, - DXPF_A8 = 4 | DXPF_TRANSPARENCY | DXPF_TRANSLUCENCY, - DXPF_RGB32 = 5, - DXPF_RGB24 = 6, - DXPF_RGB565 = 7 | DXPF_3BITERROR, - DXPF_RGB555 = 8 | DXPF_3BITERROR, - DXPF_RGB8 = 9 | DXPF_5BITERROR, - DXPF_ARGB1555 = 10 | DXPF_TRANSPARENCY | DXPF_3BITERROR, - DXPF_RGB32_CK = DXPF_RGB32 | DXPF_TRANSPARENCY, - DXPF_RGB24_CK = DXPF_RGB24 | DXPF_TRANSPARENCY, - DXPF_RGB555_CK = DXPF_RGB555 | DXPF_TRANSPARENCY, - DXPF_RGB565_CK = DXPF_RGB565 | DXPF_TRANSPARENCY, - DXPF_RGB8_CK = DXPF_RGB8 | DXPF_TRANSPARENCY - } DXSAMPLEFORMATENUM; - -typedef -enum DXLOCKSURF - { DXLOCKF_READ = 0, - DXLOCKF_READWRITE = 1 << 0, - DXLOCKF_EXISTINGINFOONLY = 1 << 1, - DXLOCKF_WANTRUNINFO = 1 << 2, - DXLOCKF_NONPREMULT = 1 << 16, - DXLOCKF_VALIDFLAGS = DXLOCKF_READWRITE | DXLOCKF_EXISTINGINFOONLY | DXLOCKF_WANTRUNINFO | DXLOCKF_NONPREMULT - } DXLOCKSURF; - -typedef -enum DXSURFSTATUS - { DXSURF_TRANSIENT = 1 << 0, - DXSURF_READONLY = 1 << 1, - DXSURF_VALIDFLAGS = DXSURF_TRANSIENT | DXSURF_READONLY - } DXSURFSTATUS; - - - -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0267_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0267_v0_0_s_ifspec; - -#ifndef __IDXSurface_INTERFACE_DEFINED__ -#define __IDXSurface_INTERFACE_DEFINED__ - -/* interface IDXSurface */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXSurface; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("B39FD73F-E139-11d1-9065-00C04FD9189D") - IDXSurface : public IDXBaseObject - { - public: - virtual HRESULT STDMETHODCALLTYPE GetPixelFormat( - /* [out] */ GUID *pFormatID, - /* [out] */ DXSAMPLEFORMATENUM *pSampleFormatEnum) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetBounds( - /* [out] */ DXBNDS *pBounds) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetStatusFlags( - /* [out] */ DWORD *pdwStatusFlags) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetStatusFlags( - /* [in] */ DWORD dwStatusFlags) = 0; - - virtual HRESULT STDMETHODCALLTYPE LockSurface( - /* [in] */ const DXBNDS *pBounds, - /* [in] */ ULONG ulTimeOut, - /* [in] */ DWORD dwFlags, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppPointer, - /* [out] */ ULONG *pulGenerationId) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetDirectDrawSurface( - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppSurface) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetColorKey( - DXSAMPLE *pColorKey) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetColorKey( - DXSAMPLE ColorKey) = 0; - - virtual HRESULT STDMETHODCALLTYPE LockSurfaceDC( - /* [in] */ const DXBNDS *pBounds, - /* [in] */ ULONG ulTimeOut, - /* [in] */ DWORD dwFlags, - /* [out] */ IDXDCLock **ppDCLock) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetAppData( - DWORD_PTR dwAppData) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetAppData( - DWORD_PTR *pdwAppData) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXSurfaceVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXSurface * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXSurface * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXSurface * This); - - HRESULT ( STDMETHODCALLTYPE *GetGenerationId )( - IDXSurface * This, - /* [out] */ ULONG *pID); - - HRESULT ( STDMETHODCALLTYPE *IncrementGenerationId )( - IDXSurface * This, - /* [in] */ BOOL bRefresh); - - HRESULT ( STDMETHODCALLTYPE *GetObjectSize )( - IDXSurface * This, - /* [out] */ ULONG *pcbSize); - - HRESULT ( STDMETHODCALLTYPE *GetPixelFormat )( - IDXSurface * This, - /* [out] */ GUID *pFormatID, - /* [out] */ DXSAMPLEFORMATENUM *pSampleFormatEnum); - - HRESULT ( STDMETHODCALLTYPE *GetBounds )( - IDXSurface * This, - /* [out] */ DXBNDS *pBounds); - - HRESULT ( STDMETHODCALLTYPE *GetStatusFlags )( - IDXSurface * This, - /* [out] */ DWORD *pdwStatusFlags); - - HRESULT ( STDMETHODCALLTYPE *SetStatusFlags )( - IDXSurface * This, - /* [in] */ DWORD dwStatusFlags); - - HRESULT ( STDMETHODCALLTYPE *LockSurface )( - IDXSurface * This, - /* [in] */ const DXBNDS *pBounds, - /* [in] */ ULONG ulTimeOut, - /* [in] */ DWORD dwFlags, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppPointer, - /* [out] */ ULONG *pulGenerationId); - - HRESULT ( STDMETHODCALLTYPE *GetDirectDrawSurface )( - IDXSurface * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppSurface); - - HRESULT ( STDMETHODCALLTYPE *GetColorKey )( - IDXSurface * This, - DXSAMPLE *pColorKey); - - HRESULT ( STDMETHODCALLTYPE *SetColorKey )( - IDXSurface * This, - DXSAMPLE ColorKey); - - HRESULT ( STDMETHODCALLTYPE *LockSurfaceDC )( - IDXSurface * This, - /* [in] */ const DXBNDS *pBounds, - /* [in] */ ULONG ulTimeOut, - /* [in] */ DWORD dwFlags, - /* [out] */ IDXDCLock **ppDCLock); - - HRESULT ( STDMETHODCALLTYPE *SetAppData )( - IDXSurface * This, - DWORD_PTR dwAppData); - - HRESULT ( STDMETHODCALLTYPE *GetAppData )( - IDXSurface * This, - DWORD_PTR *pdwAppData); - - END_INTERFACE - } IDXSurfaceVtbl; - - interface IDXSurface - { - CONST_VTBL struct IDXSurfaceVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXSurface_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXSurface_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXSurface_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXSurface_GetGenerationId(This,pID) \ - (This)->lpVtbl -> GetGenerationId(This,pID) - -#define IDXSurface_IncrementGenerationId(This,bRefresh) \ - (This)->lpVtbl -> IncrementGenerationId(This,bRefresh) - -#define IDXSurface_GetObjectSize(This,pcbSize) \ - (This)->lpVtbl -> GetObjectSize(This,pcbSize) - - -#define IDXSurface_GetPixelFormat(This,pFormatID,pSampleFormatEnum) \ - (This)->lpVtbl -> GetPixelFormat(This,pFormatID,pSampleFormatEnum) - -#define IDXSurface_GetBounds(This,pBounds) \ - (This)->lpVtbl -> GetBounds(This,pBounds) - -#define IDXSurface_GetStatusFlags(This,pdwStatusFlags) \ - (This)->lpVtbl -> GetStatusFlags(This,pdwStatusFlags) - -#define IDXSurface_SetStatusFlags(This,dwStatusFlags) \ - (This)->lpVtbl -> SetStatusFlags(This,dwStatusFlags) - -#define IDXSurface_LockSurface(This,pBounds,ulTimeOut,dwFlags,riid,ppPointer,pulGenerationId) \ - (This)->lpVtbl -> LockSurface(This,pBounds,ulTimeOut,dwFlags,riid,ppPointer,pulGenerationId) - -#define IDXSurface_GetDirectDrawSurface(This,riid,ppSurface) \ - (This)->lpVtbl -> GetDirectDrawSurface(This,riid,ppSurface) - -#define IDXSurface_GetColorKey(This,pColorKey) \ - (This)->lpVtbl -> GetColorKey(This,pColorKey) - -#define IDXSurface_SetColorKey(This,ColorKey) \ - (This)->lpVtbl -> SetColorKey(This,ColorKey) - -#define IDXSurface_LockSurfaceDC(This,pBounds,ulTimeOut,dwFlags,ppDCLock) \ - (This)->lpVtbl -> LockSurfaceDC(This,pBounds,ulTimeOut,dwFlags,ppDCLock) - -#define IDXSurface_SetAppData(This,dwAppData) \ - (This)->lpVtbl -> SetAppData(This,dwAppData) - -#define IDXSurface_GetAppData(This,pdwAppData) \ - (This)->lpVtbl -> GetAppData(This,pdwAppData) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXSurface_GetPixelFormat_Proxy( - IDXSurface * This, - /* [out] */ GUID *pFormatID, - /* [out] */ DXSAMPLEFORMATENUM *pSampleFormatEnum); - - -void __RPC_STUB IDXSurface_GetPixelFormat_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurface_GetBounds_Proxy( - IDXSurface * This, - /* [out] */ DXBNDS *pBounds); - - -void __RPC_STUB IDXSurface_GetBounds_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurface_GetStatusFlags_Proxy( - IDXSurface * This, - /* [out] */ DWORD *pdwStatusFlags); - - -void __RPC_STUB IDXSurface_GetStatusFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurface_SetStatusFlags_Proxy( - IDXSurface * This, - /* [in] */ DWORD dwStatusFlags); - - -void __RPC_STUB IDXSurface_SetStatusFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurface_LockSurface_Proxy( - IDXSurface * This, - /* [in] */ const DXBNDS *pBounds, - /* [in] */ ULONG ulTimeOut, - /* [in] */ DWORD dwFlags, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppPointer, - /* [out] */ ULONG *pulGenerationId); - - -void __RPC_STUB IDXSurface_LockSurface_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurface_GetDirectDrawSurface_Proxy( - IDXSurface * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppSurface); - - -void __RPC_STUB IDXSurface_GetDirectDrawSurface_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurface_GetColorKey_Proxy( - IDXSurface * This, - DXSAMPLE *pColorKey); - - -void __RPC_STUB IDXSurface_GetColorKey_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurface_SetColorKey_Proxy( - IDXSurface * This, - DXSAMPLE ColorKey); - - -void __RPC_STUB IDXSurface_SetColorKey_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurface_LockSurfaceDC_Proxy( - IDXSurface * This, - /* [in] */ const DXBNDS *pBounds, - /* [in] */ ULONG ulTimeOut, - /* [in] */ DWORD dwFlags, - /* [out] */ IDXDCLock **ppDCLock); - - -void __RPC_STUB IDXSurface_LockSurfaceDC_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurface_SetAppData_Proxy( - IDXSurface * This, - DWORD_PTR dwAppData); - - -void __RPC_STUB IDXSurface_SetAppData_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXSurface_GetAppData_Proxy( - IDXSurface * This, - DWORD_PTR *pdwAppData); - - -void __RPC_STUB IDXSurface_GetAppData_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXSurface_INTERFACE_DEFINED__ */ - - -#ifndef __IDXSurfaceInit_INTERFACE_DEFINED__ -#define __IDXSurfaceInit_INTERFACE_DEFINED__ - -/* interface IDXSurfaceInit */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXSurfaceInit; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9EA3B639-C37D-11d1-905E-00C04FD9189D") - IDXSurfaceInit : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE InitSurface( - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pFormatID, - /* [in] */ const DXBNDS *pBounds, - /* [in] */ DWORD dwFlags) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXSurfaceInitVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXSurfaceInit * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXSurfaceInit * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXSurfaceInit * This); - - HRESULT ( STDMETHODCALLTYPE *InitSurface )( - IDXSurfaceInit * This, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pFormatID, - /* [in] */ const DXBNDS *pBounds, - /* [in] */ DWORD dwFlags); - - END_INTERFACE - } IDXSurfaceInitVtbl; - - interface IDXSurfaceInit - { - CONST_VTBL struct IDXSurfaceInitVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXSurfaceInit_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXSurfaceInit_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXSurfaceInit_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXSurfaceInit_InitSurface(This,pDirectDraw,pDDSurfaceDesc,pFormatID,pBounds,dwFlags) \ - (This)->lpVtbl -> InitSurface(This,pDirectDraw,pDDSurfaceDesc,pFormatID,pBounds,dwFlags) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXSurfaceInit_InitSurface_Proxy( - IDXSurfaceInit * This, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pFormatID, - /* [in] */ const DXBNDS *pBounds, - /* [in] */ DWORD dwFlags); - - -void __RPC_STUB IDXSurfaceInit_InitSurface_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXSurfaceInit_INTERFACE_DEFINED__ */ - - -#ifndef __IDXARGBSurfaceInit_INTERFACE_DEFINED__ -#define __IDXARGBSurfaceInit_INTERFACE_DEFINED__ - -/* interface IDXARGBSurfaceInit */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXARGBSurfaceInit; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9EA3B63A-C37D-11d1-905E-00C04FD9189D") - IDXARGBSurfaceInit : public IDXSurfaceInit - { - public: - virtual HRESULT STDMETHODCALLTYPE InitFromDDSurface( - /* [in] */ IUnknown *pDDrawSurface, - /* [in] */ const GUID *pFormatID, - /* [in] */ DWORD dwFlags) = 0; - - virtual HRESULT STDMETHODCALLTYPE InitFromRawSurface( - /* [in] */ IDXRawSurface *pRawSurface) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXARGBSurfaceInitVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXARGBSurfaceInit * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXARGBSurfaceInit * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXARGBSurfaceInit * This); - - HRESULT ( STDMETHODCALLTYPE *InitSurface )( - IDXARGBSurfaceInit * This, - /* [in] */ IUnknown *pDirectDraw, - /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, - /* [in] */ const GUID *pFormatID, - /* [in] */ const DXBNDS *pBounds, - /* [in] */ DWORD dwFlags); - - HRESULT ( STDMETHODCALLTYPE *InitFromDDSurface )( - IDXARGBSurfaceInit * This, - /* [in] */ IUnknown *pDDrawSurface, - /* [in] */ const GUID *pFormatID, - /* [in] */ DWORD dwFlags); - - HRESULT ( STDMETHODCALLTYPE *InitFromRawSurface )( - IDXARGBSurfaceInit * This, - /* [in] */ IDXRawSurface *pRawSurface); - - END_INTERFACE - } IDXARGBSurfaceInitVtbl; - - interface IDXARGBSurfaceInit - { - CONST_VTBL struct IDXARGBSurfaceInitVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXARGBSurfaceInit_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXARGBSurfaceInit_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXARGBSurfaceInit_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXARGBSurfaceInit_InitSurface(This,pDirectDraw,pDDSurfaceDesc,pFormatID,pBounds,dwFlags) \ - (This)->lpVtbl -> InitSurface(This,pDirectDraw,pDDSurfaceDesc,pFormatID,pBounds,dwFlags) - - -#define IDXARGBSurfaceInit_InitFromDDSurface(This,pDDrawSurface,pFormatID,dwFlags) \ - (This)->lpVtbl -> InitFromDDSurface(This,pDDrawSurface,pFormatID,dwFlags) - -#define IDXARGBSurfaceInit_InitFromRawSurface(This,pRawSurface) \ - (This)->lpVtbl -> InitFromRawSurface(This,pRawSurface) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXARGBSurfaceInit_InitFromDDSurface_Proxy( - IDXARGBSurfaceInit * This, - /* [in] */ IUnknown *pDDrawSurface, - /* [in] */ const GUID *pFormatID, - /* [in] */ DWORD dwFlags); - - -void __RPC_STUB IDXARGBSurfaceInit_InitFromDDSurface_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXARGBSurfaceInit_InitFromRawSurface_Proxy( - IDXARGBSurfaceInit * This, - /* [in] */ IDXRawSurface *pRawSurface); - - -void __RPC_STUB IDXARGBSurfaceInit_InitFromRawSurface_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXARGBSurfaceInit_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxtrans_0270 */ -/* [local] */ - -typedef struct tagDXNATIVETYPEINFO - { - BYTE *pCurrentData; - BYTE *pFirstByte; - long lPitch; - DWORD dwColorKey; - } DXNATIVETYPEINFO; - -typedef struct tagDXPACKEDRECTDESC - { - DXBASESAMPLE *pSamples; - BOOL bPremult; - RECT rect; - long lRowPadding; - } DXPACKEDRECTDESC; - -typedef struct tagDXOVERSAMPLEDESC - { - POINT p; - DXPMSAMPLE Color; - } DXOVERSAMPLEDESC; - - - -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0270_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0270_v0_0_s_ifspec; - -#ifndef __IDXARGBReadPtr_INTERFACE_DEFINED__ -#define __IDXARGBReadPtr_INTERFACE_DEFINED__ - -/* interface IDXARGBReadPtr */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXARGBReadPtr; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("EAAAC2D6-C290-11d1-905D-00C04FD9189D") - IDXARGBReadPtr : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE GetSurface( - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppSurface) = 0; - - virtual DXSAMPLEFORMATENUM STDMETHODCALLTYPE GetNativeType( - /* [out] */ DXNATIVETYPEINFO *pInfo) = 0; - - virtual void STDMETHODCALLTYPE Move( - /* [in] */ long cSamples) = 0; - - virtual void STDMETHODCALLTYPE MoveToRow( - /* [in] */ ULONG y) = 0; - - virtual void STDMETHODCALLTYPE MoveToXY( - /* [in] */ ULONG x, - /* [in] */ ULONG y) = 0; - - virtual ULONG STDMETHODCALLTYPE MoveAndGetRunInfo( - /* [in] */ ULONG Row, - /* [out] */ const DXRUNINFO **ppInfo) = 0; - - virtual DXSAMPLE *STDMETHODCALLTYPE Unpack( - /* [in] */ DXSAMPLE *pSamples, - /* [in] */ ULONG cSamples, - /* [in] */ BOOL bMove) = 0; - - virtual DXPMSAMPLE *STDMETHODCALLTYPE UnpackPremult( - /* [in] */ DXPMSAMPLE *pSamples, - /* [in] */ ULONG cSamples, - /* [in] */ BOOL bMove) = 0; - - virtual void STDMETHODCALLTYPE UnpackRect( - /* [in] */ const DXPACKEDRECTDESC *pRectDesc) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXARGBReadPtrVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXARGBReadPtr * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXARGBReadPtr * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXARGBReadPtr * This); - - HRESULT ( STDMETHODCALLTYPE *GetSurface )( - IDXARGBReadPtr * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppSurface); - - DXSAMPLEFORMATENUM ( STDMETHODCALLTYPE *GetNativeType )( - IDXARGBReadPtr * This, - /* [out] */ DXNATIVETYPEINFO *pInfo); - - void ( STDMETHODCALLTYPE *Move )( - IDXARGBReadPtr * This, - /* [in] */ long cSamples); - - void ( STDMETHODCALLTYPE *MoveToRow )( - IDXARGBReadPtr * This, - /* [in] */ ULONG y); - - void ( STDMETHODCALLTYPE *MoveToXY )( - IDXARGBReadPtr * This, - /* [in] */ ULONG x, - /* [in] */ ULONG y); - - ULONG ( STDMETHODCALLTYPE *MoveAndGetRunInfo )( - IDXARGBReadPtr * This, - /* [in] */ ULONG Row, - /* [out] */ const DXRUNINFO **ppInfo); - - DXSAMPLE *( STDMETHODCALLTYPE *Unpack )( - IDXARGBReadPtr * This, - /* [in] */ DXSAMPLE *pSamples, - /* [in] */ ULONG cSamples, - /* [in] */ BOOL bMove); - - DXPMSAMPLE *( STDMETHODCALLTYPE *UnpackPremult )( - IDXARGBReadPtr * This, - /* [in] */ DXPMSAMPLE *pSamples, - /* [in] */ ULONG cSamples, - /* [in] */ BOOL bMove); - - void ( STDMETHODCALLTYPE *UnpackRect )( - IDXARGBReadPtr * This, - /* [in] */ const DXPACKEDRECTDESC *pRectDesc); - - END_INTERFACE - } IDXARGBReadPtrVtbl; - - interface IDXARGBReadPtr - { - CONST_VTBL struct IDXARGBReadPtrVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXARGBReadPtr_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXARGBReadPtr_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXARGBReadPtr_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXARGBReadPtr_GetSurface(This,riid,ppSurface) \ - (This)->lpVtbl -> GetSurface(This,riid,ppSurface) - -#define IDXARGBReadPtr_GetNativeType(This,pInfo) \ - (This)->lpVtbl -> GetNativeType(This,pInfo) - -#define IDXARGBReadPtr_Move(This,cSamples) \ - (This)->lpVtbl -> Move(This,cSamples) - -#define IDXARGBReadPtr_MoveToRow(This,y) \ - (This)->lpVtbl -> MoveToRow(This,y) - -#define IDXARGBReadPtr_MoveToXY(This,x,y) \ - (This)->lpVtbl -> MoveToXY(This,x,y) - -#define IDXARGBReadPtr_MoveAndGetRunInfo(This,Row,ppInfo) \ - (This)->lpVtbl -> MoveAndGetRunInfo(This,Row,ppInfo) - -#define IDXARGBReadPtr_Unpack(This,pSamples,cSamples,bMove) \ - (This)->lpVtbl -> Unpack(This,pSamples,cSamples,bMove) - -#define IDXARGBReadPtr_UnpackPremult(This,pSamples,cSamples,bMove) \ - (This)->lpVtbl -> UnpackPremult(This,pSamples,cSamples,bMove) - -#define IDXARGBReadPtr_UnpackRect(This,pRectDesc) \ - (This)->lpVtbl -> UnpackRect(This,pRectDesc) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXARGBReadPtr_GetSurface_Proxy( - IDXARGBReadPtr * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppSurface); - - -void __RPC_STUB IDXARGBReadPtr_GetSurface_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -DXSAMPLEFORMATENUM STDMETHODCALLTYPE IDXARGBReadPtr_GetNativeType_Proxy( - IDXARGBReadPtr * This, - /* [out] */ DXNATIVETYPEINFO *pInfo); - - -void __RPC_STUB IDXARGBReadPtr_GetNativeType_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -void STDMETHODCALLTYPE IDXARGBReadPtr_Move_Proxy( - IDXARGBReadPtr * This, - /* [in] */ long cSamples); - - -void __RPC_STUB IDXARGBReadPtr_Move_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -void STDMETHODCALLTYPE IDXARGBReadPtr_MoveToRow_Proxy( - IDXARGBReadPtr * This, - /* [in] */ ULONG y); - - -void __RPC_STUB IDXARGBReadPtr_MoveToRow_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -void STDMETHODCALLTYPE IDXARGBReadPtr_MoveToXY_Proxy( - IDXARGBReadPtr * This, - /* [in] */ ULONG x, - /* [in] */ ULONG y); - - -void __RPC_STUB IDXARGBReadPtr_MoveToXY_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -ULONG STDMETHODCALLTYPE IDXARGBReadPtr_MoveAndGetRunInfo_Proxy( - IDXARGBReadPtr * This, - /* [in] */ ULONG Row, - /* [out] */ const DXRUNINFO **ppInfo); - - -void __RPC_STUB IDXARGBReadPtr_MoveAndGetRunInfo_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -DXSAMPLE *STDMETHODCALLTYPE IDXARGBReadPtr_Unpack_Proxy( - IDXARGBReadPtr * This, - /* [in] */ DXSAMPLE *pSamples, - /* [in] */ ULONG cSamples, - /* [in] */ BOOL bMove); - - -void __RPC_STUB IDXARGBReadPtr_Unpack_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -DXPMSAMPLE *STDMETHODCALLTYPE IDXARGBReadPtr_UnpackPremult_Proxy( - IDXARGBReadPtr * This, - /* [in] */ DXPMSAMPLE *pSamples, - /* [in] */ ULONG cSamples, - /* [in] */ BOOL bMove); - - -void __RPC_STUB IDXARGBReadPtr_UnpackPremult_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -void STDMETHODCALLTYPE IDXARGBReadPtr_UnpackRect_Proxy( - IDXARGBReadPtr * This, - /* [in] */ const DXPACKEDRECTDESC *pRectDesc); - - -void __RPC_STUB IDXARGBReadPtr_UnpackRect_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXARGBReadPtr_INTERFACE_DEFINED__ */ - - -#ifndef __IDXARGBReadWritePtr_INTERFACE_DEFINED__ -#define __IDXARGBReadWritePtr_INTERFACE_DEFINED__ - -/* interface IDXARGBReadWritePtr */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXARGBReadWritePtr; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("EAAAC2D7-C290-11d1-905D-00C04FD9189D") - IDXARGBReadWritePtr : public IDXARGBReadPtr - { - public: - virtual void STDMETHODCALLTYPE PackAndMove( - /* [in] */ const DXSAMPLE *pSamples, - /* [in] */ ULONG cSamples) = 0; - - virtual void STDMETHODCALLTYPE PackPremultAndMove( - /* [in] */ const DXPMSAMPLE *pSamples, - /* [in] */ ULONG cSamples) = 0; - - virtual void STDMETHODCALLTYPE PackRect( - /* [in] */ const DXPACKEDRECTDESC *pRectDesc) = 0; - - virtual void STDMETHODCALLTYPE CopyAndMoveBoth( - /* [in] */ DXBASESAMPLE *pScratchBuffer, - /* [in] */ IDXARGBReadPtr *pSrc, - /* [in] */ ULONG cSamples, - /* [in] */ BOOL bIsOpaque) = 0; - - virtual void STDMETHODCALLTYPE CopyRect( - /* [in] */ DXBASESAMPLE *pScratchBuffer, - /* [in] */ const RECT *pDestRect, - /* [in] */ IDXARGBReadPtr *pSrc, - /* [in] */ const POINT *pSrcOrigin, - /* [in] */ BOOL bIsOpaque) = 0; - - virtual void STDMETHODCALLTYPE FillAndMove( - /* [in] */ DXBASESAMPLE *pScratchBuffer, - /* [in] */ DXPMSAMPLE SampVal, - /* [in] */ ULONG cSamples, - /* [in] */ BOOL bDoOver) = 0; - - virtual void STDMETHODCALLTYPE FillRect( - /* [in] */ const RECT *pRect, - /* [in] */ DXPMSAMPLE SampVal, - /* [in] */ BOOL bDoOver) = 0; - - virtual void STDMETHODCALLTYPE OverSample( - /* [in] */ const DXOVERSAMPLEDESC *pOverDesc) = 0; - - virtual void STDMETHODCALLTYPE OverArrayAndMove( - /* [in] */ DXBASESAMPLE *pScratchBuffer, - /* [in] */ const DXPMSAMPLE *pSrc, - /* [in] */ ULONG cSamples) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXARGBReadWritePtrVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXARGBReadWritePtr * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXARGBReadWritePtr * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXARGBReadWritePtr * This); - - HRESULT ( STDMETHODCALLTYPE *GetSurface )( - IDXARGBReadWritePtr * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppSurface); - - DXSAMPLEFORMATENUM ( STDMETHODCALLTYPE *GetNativeType )( - IDXARGBReadWritePtr * This, - /* [out] */ DXNATIVETYPEINFO *pInfo); - - void ( STDMETHODCALLTYPE *Move )( - IDXARGBReadWritePtr * This, - /* [in] */ long cSamples); - - void ( STDMETHODCALLTYPE *MoveToRow )( - IDXARGBReadWritePtr * This, - /* [in] */ ULONG y); - - void ( STDMETHODCALLTYPE *MoveToXY )( - IDXARGBReadWritePtr * This, - /* [in] */ ULONG x, - /* [in] */ ULONG y); - - ULONG ( STDMETHODCALLTYPE *MoveAndGetRunInfo )( - IDXARGBReadWritePtr * This, - /* [in] */ ULONG Row, - /* [out] */ const DXRUNINFO **ppInfo); - - DXSAMPLE *( STDMETHODCALLTYPE *Unpack )( - IDXARGBReadWritePtr * This, - /* [in] */ DXSAMPLE *pSamples, - /* [in] */ ULONG cSamples, - /* [in] */ BOOL bMove); - - DXPMSAMPLE *( STDMETHODCALLTYPE *UnpackPremult )( - IDXARGBReadWritePtr * This, - /* [in] */ DXPMSAMPLE *pSamples, - /* [in] */ ULONG cSamples, - /* [in] */ BOOL bMove); - - void ( STDMETHODCALLTYPE *UnpackRect )( - IDXARGBReadWritePtr * This, - /* [in] */ const DXPACKEDRECTDESC *pRectDesc); - - void ( STDMETHODCALLTYPE *PackAndMove )( - IDXARGBReadWritePtr * This, - /* [in] */ const DXSAMPLE *pSamples, - /* [in] */ ULONG cSamples); - - void ( STDMETHODCALLTYPE *PackPremultAndMove )( - IDXARGBReadWritePtr * This, - /* [in] */ const DXPMSAMPLE *pSamples, - /* [in] */ ULONG cSamples); - - void ( STDMETHODCALLTYPE *PackRect )( - IDXARGBReadWritePtr * This, - /* [in] */ const DXPACKEDRECTDESC *pRectDesc); - - void ( STDMETHODCALLTYPE *CopyAndMoveBoth )( - IDXARGBReadWritePtr * This, - /* [in] */ DXBASESAMPLE *pScratchBuffer, - /* [in] */ IDXARGBReadPtr *pSrc, - /* [in] */ ULONG cSamples, - /* [in] */ BOOL bIsOpaque); - - void ( STDMETHODCALLTYPE *CopyRect )( - IDXARGBReadWritePtr * This, - /* [in] */ DXBASESAMPLE *pScratchBuffer, - /* [in] */ const RECT *pDestRect, - /* [in] */ IDXARGBReadPtr *pSrc, - /* [in] */ const POINT *pSrcOrigin, - /* [in] */ BOOL bIsOpaque); - - void ( STDMETHODCALLTYPE *FillAndMove )( - IDXARGBReadWritePtr * This, - /* [in] */ DXBASESAMPLE *pScratchBuffer, - /* [in] */ DXPMSAMPLE SampVal, - /* [in] */ ULONG cSamples, - /* [in] */ BOOL bDoOver); - - void ( STDMETHODCALLTYPE *FillRect )( - IDXARGBReadWritePtr * This, - /* [in] */ const RECT *pRect, - /* [in] */ DXPMSAMPLE SampVal, - /* [in] */ BOOL bDoOver); - - void ( STDMETHODCALLTYPE *OverSample )( - IDXARGBReadWritePtr * This, - /* [in] */ const DXOVERSAMPLEDESC *pOverDesc); - - void ( STDMETHODCALLTYPE *OverArrayAndMove )( - IDXARGBReadWritePtr * This, - /* [in] */ DXBASESAMPLE *pScratchBuffer, - /* [in] */ const DXPMSAMPLE *pSrc, - /* [in] */ ULONG cSamples); - - END_INTERFACE - } IDXARGBReadWritePtrVtbl; - - interface IDXARGBReadWritePtr - { - CONST_VTBL struct IDXARGBReadWritePtrVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXARGBReadWritePtr_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXARGBReadWritePtr_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXARGBReadWritePtr_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXARGBReadWritePtr_GetSurface(This,riid,ppSurface) \ - (This)->lpVtbl -> GetSurface(This,riid,ppSurface) - -#define IDXARGBReadWritePtr_GetNativeType(This,pInfo) \ - (This)->lpVtbl -> GetNativeType(This,pInfo) - -#define IDXARGBReadWritePtr_Move(This,cSamples) \ - (This)->lpVtbl -> Move(This,cSamples) - -#define IDXARGBReadWritePtr_MoveToRow(This,y) \ - (This)->lpVtbl -> MoveToRow(This,y) - -#define IDXARGBReadWritePtr_MoveToXY(This,x,y) \ - (This)->lpVtbl -> MoveToXY(This,x,y) - -#define IDXARGBReadWritePtr_MoveAndGetRunInfo(This,Row,ppInfo) \ - (This)->lpVtbl -> MoveAndGetRunInfo(This,Row,ppInfo) - -#define IDXARGBReadWritePtr_Unpack(This,pSamples,cSamples,bMove) \ - (This)->lpVtbl -> Unpack(This,pSamples,cSamples,bMove) - -#define IDXARGBReadWritePtr_UnpackPremult(This,pSamples,cSamples,bMove) \ - (This)->lpVtbl -> UnpackPremult(This,pSamples,cSamples,bMove) - -#define IDXARGBReadWritePtr_UnpackRect(This,pRectDesc) \ - (This)->lpVtbl -> UnpackRect(This,pRectDesc) - - -#define IDXARGBReadWritePtr_PackAndMove(This,pSamples,cSamples) \ - (This)->lpVtbl -> PackAndMove(This,pSamples,cSamples) - -#define IDXARGBReadWritePtr_PackPremultAndMove(This,pSamples,cSamples) \ - (This)->lpVtbl -> PackPremultAndMove(This,pSamples,cSamples) - -#define IDXARGBReadWritePtr_PackRect(This,pRectDesc) \ - (This)->lpVtbl -> PackRect(This,pRectDesc) - -#define IDXARGBReadWritePtr_CopyAndMoveBoth(This,pScratchBuffer,pSrc,cSamples,bIsOpaque) \ - (This)->lpVtbl -> CopyAndMoveBoth(This,pScratchBuffer,pSrc,cSamples,bIsOpaque) - -#define IDXARGBReadWritePtr_CopyRect(This,pScratchBuffer,pDestRect,pSrc,pSrcOrigin,bIsOpaque) \ - (This)->lpVtbl -> CopyRect(This,pScratchBuffer,pDestRect,pSrc,pSrcOrigin,bIsOpaque) - -#define IDXARGBReadWritePtr_FillAndMove(This,pScratchBuffer,SampVal,cSamples,bDoOver) \ - (This)->lpVtbl -> FillAndMove(This,pScratchBuffer,SampVal,cSamples,bDoOver) - -#define IDXARGBReadWritePtr_FillRect(This,pRect,SampVal,bDoOver) \ - (This)->lpVtbl -> FillRect(This,pRect,SampVal,bDoOver) - -#define IDXARGBReadWritePtr_OverSample(This,pOverDesc) \ - (This)->lpVtbl -> OverSample(This,pOverDesc) - -#define IDXARGBReadWritePtr_OverArrayAndMove(This,pScratchBuffer,pSrc,cSamples) \ - (This)->lpVtbl -> OverArrayAndMove(This,pScratchBuffer,pSrc,cSamples) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -void STDMETHODCALLTYPE IDXARGBReadWritePtr_PackAndMove_Proxy( - IDXARGBReadWritePtr * This, - /* [in] */ const DXSAMPLE *pSamples, - /* [in] */ ULONG cSamples); - - -void __RPC_STUB IDXARGBReadWritePtr_PackAndMove_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -void STDMETHODCALLTYPE IDXARGBReadWritePtr_PackPremultAndMove_Proxy( - IDXARGBReadWritePtr * This, - /* [in] */ const DXPMSAMPLE *pSamples, - /* [in] */ ULONG cSamples); - - -void __RPC_STUB IDXARGBReadWritePtr_PackPremultAndMove_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -void STDMETHODCALLTYPE IDXARGBReadWritePtr_PackRect_Proxy( - IDXARGBReadWritePtr * This, - /* [in] */ const DXPACKEDRECTDESC *pRectDesc); - - -void __RPC_STUB IDXARGBReadWritePtr_PackRect_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -void STDMETHODCALLTYPE IDXARGBReadWritePtr_CopyAndMoveBoth_Proxy( - IDXARGBReadWritePtr * This, - /* [in] */ DXBASESAMPLE *pScratchBuffer, - /* [in] */ IDXARGBReadPtr *pSrc, - /* [in] */ ULONG cSamples, - /* [in] */ BOOL bIsOpaque); - - -void __RPC_STUB IDXARGBReadWritePtr_CopyAndMoveBoth_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -void STDMETHODCALLTYPE IDXARGBReadWritePtr_CopyRect_Proxy( - IDXARGBReadWritePtr * This, - /* [in] */ DXBASESAMPLE *pScratchBuffer, - /* [in] */ const RECT *pDestRect, - /* [in] */ IDXARGBReadPtr *pSrc, - /* [in] */ const POINT *pSrcOrigin, - /* [in] */ BOOL bIsOpaque); - - -void __RPC_STUB IDXARGBReadWritePtr_CopyRect_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -void STDMETHODCALLTYPE IDXARGBReadWritePtr_FillAndMove_Proxy( - IDXARGBReadWritePtr * This, - /* [in] */ DXBASESAMPLE *pScratchBuffer, - /* [in] */ DXPMSAMPLE SampVal, - /* [in] */ ULONG cSamples, - /* [in] */ BOOL bDoOver); - - -void __RPC_STUB IDXARGBReadWritePtr_FillAndMove_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -void STDMETHODCALLTYPE IDXARGBReadWritePtr_FillRect_Proxy( - IDXARGBReadWritePtr * This, - /* [in] */ const RECT *pRect, - /* [in] */ DXPMSAMPLE SampVal, - /* [in] */ BOOL bDoOver); - - -void __RPC_STUB IDXARGBReadWritePtr_FillRect_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -void STDMETHODCALLTYPE IDXARGBReadWritePtr_OverSample_Proxy( - IDXARGBReadWritePtr * This, - /* [in] */ const DXOVERSAMPLEDESC *pOverDesc); - - -void __RPC_STUB IDXARGBReadWritePtr_OverSample_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -void STDMETHODCALLTYPE IDXARGBReadWritePtr_OverArrayAndMove_Proxy( - IDXARGBReadWritePtr * This, - /* [in] */ DXBASESAMPLE *pScratchBuffer, - /* [in] */ const DXPMSAMPLE *pSrc, - /* [in] */ ULONG cSamples); - - -void __RPC_STUB IDXARGBReadWritePtr_OverArrayAndMove_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXARGBReadWritePtr_INTERFACE_DEFINED__ */ - - -#ifndef __IDXDCLock_INTERFACE_DEFINED__ -#define __IDXDCLock_INTERFACE_DEFINED__ - -/* interface IDXDCLock */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXDCLock; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("0F619456-CF39-11d1-905E-00C04FD9189D") - IDXDCLock : public IUnknown - { - public: - virtual HDC STDMETHODCALLTYPE GetDC( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXDCLockVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXDCLock * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXDCLock * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXDCLock * This); - - HDC ( STDMETHODCALLTYPE *GetDC )( - IDXDCLock * This); - - END_INTERFACE - } IDXDCLockVtbl; - - interface IDXDCLock - { - CONST_VTBL struct IDXDCLockVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXDCLock_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXDCLock_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXDCLock_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXDCLock_GetDC(This) \ - (This)->lpVtbl -> GetDC(This) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HDC STDMETHODCALLTYPE IDXDCLock_GetDC_Proxy( - IDXDCLock * This); - - -void __RPC_STUB IDXDCLock_GetDC_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXDCLock_INTERFACE_DEFINED__ */ - - -#ifndef __IDXTScaleOutput_INTERFACE_DEFINED__ -#define __IDXTScaleOutput_INTERFACE_DEFINED__ - -/* interface IDXTScaleOutput */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXTScaleOutput; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("B2024B50-EE77-11d1-9066-00C04FD9189D") - IDXTScaleOutput : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE SetOutputSize( - /* [in] */ const SIZE OutSize, - /* [in] */ BOOL bMaintainAspect) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXTScaleOutputVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXTScaleOutput * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXTScaleOutput * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXTScaleOutput * This); - - HRESULT ( STDMETHODCALLTYPE *SetOutputSize )( - IDXTScaleOutput * This, - /* [in] */ const SIZE OutSize, - /* [in] */ BOOL bMaintainAspect); - - END_INTERFACE - } IDXTScaleOutputVtbl; - - interface IDXTScaleOutput - { - CONST_VTBL struct IDXTScaleOutputVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXTScaleOutput_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXTScaleOutput_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXTScaleOutput_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXTScaleOutput_SetOutputSize(This,OutSize,bMaintainAspect) \ - (This)->lpVtbl -> SetOutputSize(This,OutSize,bMaintainAspect) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXTScaleOutput_SetOutputSize_Proxy( - IDXTScaleOutput * This, - /* [in] */ const SIZE OutSize, - /* [in] */ BOOL bMaintainAspect); - - -void __RPC_STUB IDXTScaleOutput_SetOutputSize_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXTScaleOutput_INTERFACE_DEFINED__ */ - - -#ifndef __IDXGradient_INTERFACE_DEFINED__ -#define __IDXGradient_INTERFACE_DEFINED__ - -/* interface IDXGradient */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXGradient; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("B2024B51-EE77-11d1-9066-00C04FD9189D") - IDXGradient : public IDXTScaleOutput - { - public: - virtual HRESULT STDMETHODCALLTYPE SetGradient( - DXSAMPLE StartColor, - DXSAMPLE EndColor, - BOOL bHorizontal) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetOutputSize( - /* [out] */ SIZE *pOutSize) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXGradientVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGradient * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGradient * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGradient * This); - - HRESULT ( STDMETHODCALLTYPE *SetOutputSize )( - IDXGradient * This, - /* [in] */ const SIZE OutSize, - /* [in] */ BOOL bMaintainAspect); - - HRESULT ( STDMETHODCALLTYPE *SetGradient )( - IDXGradient * This, - DXSAMPLE StartColor, - DXSAMPLE EndColor, - BOOL bHorizontal); - - HRESULT ( STDMETHODCALLTYPE *GetOutputSize )( - IDXGradient * This, - /* [out] */ SIZE *pOutSize); - - END_INTERFACE - } IDXGradientVtbl; - - interface IDXGradient - { - CONST_VTBL struct IDXGradientVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGradient_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXGradient_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXGradient_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXGradient_SetOutputSize(This,OutSize,bMaintainAspect) \ - (This)->lpVtbl -> SetOutputSize(This,OutSize,bMaintainAspect) - - -#define IDXGradient_SetGradient(This,StartColor,EndColor,bHorizontal) \ - (This)->lpVtbl -> SetGradient(This,StartColor,EndColor,bHorizontal) - -#define IDXGradient_GetOutputSize(This,pOutSize) \ - (This)->lpVtbl -> GetOutputSize(This,pOutSize) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXGradient_SetGradient_Proxy( - IDXGradient * This, - DXSAMPLE StartColor, - DXSAMPLE EndColor, - BOOL bHorizontal); - - -void __RPC_STUB IDXGradient_SetGradient_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXGradient_GetOutputSize_Proxy( - IDXGradient * This, - /* [out] */ SIZE *pOutSize); - - -void __RPC_STUB IDXGradient_GetOutputSize_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXGradient_INTERFACE_DEFINED__ */ - - -#ifndef __IDXTScale_INTERFACE_DEFINED__ -#define __IDXTScale_INTERFACE_DEFINED__ - -/* interface IDXTScale */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXTScale; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("B39FD742-E139-11d1-9065-00C04FD9189D") - IDXTScale : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE SetScales( - /* [in] */ float Scales[ 2 ]) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetScales( - /* [out] */ float Scales[ 2 ]) = 0; - - virtual HRESULT STDMETHODCALLTYPE ScaleFitToSize( - /* [out][in] */ DXBNDS *pClipBounds, - /* [in] */ SIZE FitToSize, - /* [in] */ BOOL bMaintainAspect) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXTScaleVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXTScale * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXTScale * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXTScale * This); - - HRESULT ( STDMETHODCALLTYPE *SetScales )( - IDXTScale * This, - /* [in] */ float Scales[ 2 ]); - - HRESULT ( STDMETHODCALLTYPE *GetScales )( - IDXTScale * This, - /* [out] */ float Scales[ 2 ]); - - HRESULT ( STDMETHODCALLTYPE *ScaleFitToSize )( - IDXTScale * This, - /* [out][in] */ DXBNDS *pClipBounds, - /* [in] */ SIZE FitToSize, - /* [in] */ BOOL bMaintainAspect); - - END_INTERFACE - } IDXTScaleVtbl; - - interface IDXTScale - { - CONST_VTBL struct IDXTScaleVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXTScale_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXTScale_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXTScale_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXTScale_SetScales(This,Scales) \ - (This)->lpVtbl -> SetScales(This,Scales) - -#define IDXTScale_GetScales(This,Scales) \ - (This)->lpVtbl -> GetScales(This,Scales) - -#define IDXTScale_ScaleFitToSize(This,pClipBounds,FitToSize,bMaintainAspect) \ - (This)->lpVtbl -> ScaleFitToSize(This,pClipBounds,FitToSize,bMaintainAspect) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXTScale_SetScales_Proxy( - IDXTScale * This, - /* [in] */ float Scales[ 2 ]); - - -void __RPC_STUB IDXTScale_SetScales_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTScale_GetScales_Proxy( - IDXTScale * This, - /* [out] */ float Scales[ 2 ]); - - -void __RPC_STUB IDXTScale_GetScales_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXTScale_ScaleFitToSize_Proxy( - IDXTScale * This, - /* [out][in] */ DXBNDS *pClipBounds, - /* [in] */ SIZE FitToSize, - /* [in] */ BOOL bMaintainAspect); - - -void __RPC_STUB IDXTScale_ScaleFitToSize_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXTScale_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxtrans_0276 */ -/* [local] */ - -typedef -enum DISPIDDXEFFECT - { DISPID_DXECAPABILITIES = 10000, - DISPID_DXEPROGRESS = DISPID_DXECAPABILITIES + 1, - DISPID_DXESTEP = DISPID_DXEPROGRESS + 1, - DISPID_DXEDURATION = DISPID_DXESTEP + 1, - DISPID_DXE_NEXT_ID = DISPID_DXEDURATION + 1 - } DISPIDDXBOUNDEDEFFECT; - -typedef -enum DXEFFECTTYPE - { DXTET_PERIODIC = 1 << 0, - DXTET_MORPH = 1 << 1 - } DXEFFECTTYPE; - - - -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0276_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0276_v0_0_s_ifspec; - -#ifndef __IDXEffect_INTERFACE_DEFINED__ -#define __IDXEffect_INTERFACE_DEFINED__ - -/* interface IDXEffect */ -/* [dual][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXEffect; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("E31FB81B-1335-11d1-8189-0000F87557DB") - IDXEffect : public IDispatch - { - public: - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Capabilities( - /* [retval][out] */ long *pVal) = 0; - - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Progress( - /* [retval][out] */ float *pVal) = 0; - - virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Progress( - /* [in] */ float newVal) = 0; - - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_StepResolution( - /* [retval][out] */ float *pVal) = 0; - - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Duration( - /* [retval][out] */ float *pVal) = 0; - - virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Duration( - /* [in] */ float newVal) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXEffectVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXEffect * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXEffect * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXEffect * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - IDXEffect * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - IDXEffect * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - IDXEffect * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - IDXEffect * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Capabilities )( - IDXEffect * This, - /* [retval][out] */ long *pVal); - - /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Progress )( - IDXEffect * This, - /* [retval][out] */ float *pVal); - - /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Progress )( - IDXEffect * This, - /* [in] */ float newVal); - - /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_StepResolution )( - IDXEffect * This, - /* [retval][out] */ float *pVal); - - /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Duration )( - IDXEffect * This, - /* [retval][out] */ float *pVal); - - /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Duration )( - IDXEffect * This, - /* [in] */ float newVal); - - END_INTERFACE - } IDXEffectVtbl; - - interface IDXEffect - { - CONST_VTBL struct IDXEffectVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXEffect_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXEffect_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXEffect_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXEffect_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define IDXEffect_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define IDXEffect_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define IDXEffect_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define IDXEffect_get_Capabilities(This,pVal) \ - (This)->lpVtbl -> get_Capabilities(This,pVal) - -#define IDXEffect_get_Progress(This,pVal) \ - (This)->lpVtbl -> get_Progress(This,pVal) - -#define IDXEffect_put_Progress(This,newVal) \ - (This)->lpVtbl -> put_Progress(This,newVal) - -#define IDXEffect_get_StepResolution(This,pVal) \ - (This)->lpVtbl -> get_StepResolution(This,pVal) - -#define IDXEffect_get_Duration(This,pVal) \ - (This)->lpVtbl -> get_Duration(This,pVal) - -#define IDXEffect_put_Duration(This,newVal) \ - (This)->lpVtbl -> put_Duration(This,newVal) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [id][propget] */ HRESULT STDMETHODCALLTYPE IDXEffect_get_Capabilities_Proxy( - IDXEffect * This, - /* [retval][out] */ long *pVal); - - -void __RPC_STUB IDXEffect_get_Capabilities_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][propget] */ HRESULT STDMETHODCALLTYPE IDXEffect_get_Progress_Proxy( - IDXEffect * This, - /* [retval][out] */ float *pVal); - - -void __RPC_STUB IDXEffect_get_Progress_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][propput] */ HRESULT STDMETHODCALLTYPE IDXEffect_put_Progress_Proxy( - IDXEffect * This, - /* [in] */ float newVal); - - -void __RPC_STUB IDXEffect_put_Progress_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][propget] */ HRESULT STDMETHODCALLTYPE IDXEffect_get_StepResolution_Proxy( - IDXEffect * This, - /* [retval][out] */ float *pVal); - - -void __RPC_STUB IDXEffect_get_StepResolution_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][propget] */ HRESULT STDMETHODCALLTYPE IDXEffect_get_Duration_Proxy( - IDXEffect * This, - /* [retval][out] */ float *pVal); - - -void __RPC_STUB IDXEffect_get_Duration_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][propput] */ HRESULT STDMETHODCALLTYPE IDXEffect_put_Duration_Proxy( - IDXEffect * This, - /* [in] */ float newVal); - - -void __RPC_STUB IDXEffect_put_Duration_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXEffect_INTERFACE_DEFINED__ */ - - -#ifndef __IDXLookupTable_INTERFACE_DEFINED__ -#define __IDXLookupTable_INTERFACE_DEFINED__ - -/* interface IDXLookupTable */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXLookupTable; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("01BAFC7F-9E63-11d1-9053-00C04FD9189D") - IDXLookupTable : public IDXBaseObject - { - public: - virtual HRESULT STDMETHODCALLTYPE GetTables( - /* [out] */ BYTE RedLUT[ 256 ], - /* [out] */ BYTE GreenLUT[ 256 ], - /* [out] */ BYTE BlueLUT[ 256 ], - /* [out] */ BYTE AlphaLUT[ 256 ]) = 0; - - virtual HRESULT STDMETHODCALLTYPE IsChannelIdentity( - /* [out] */ DXBASESAMPLE *pSampleBools) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetIndexValues( - /* [in] */ ULONG Index, - /* [out] */ DXBASESAMPLE *pSample) = 0; - - virtual HRESULT STDMETHODCALLTYPE ApplyTables( - /* [out][in] */ DXSAMPLE *pSamples, - /* [in] */ ULONG cSamples) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXLookupTableVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXLookupTable * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXLookupTable * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXLookupTable * This); - - HRESULT ( STDMETHODCALLTYPE *GetGenerationId )( - IDXLookupTable * This, - /* [out] */ ULONG *pID); - - HRESULT ( STDMETHODCALLTYPE *IncrementGenerationId )( - IDXLookupTable * This, - /* [in] */ BOOL bRefresh); - - HRESULT ( STDMETHODCALLTYPE *GetObjectSize )( - IDXLookupTable * This, - /* [out] */ ULONG *pcbSize); - - HRESULT ( STDMETHODCALLTYPE *GetTables )( - IDXLookupTable * This, - /* [out] */ BYTE RedLUT[ 256 ], - /* [out] */ BYTE GreenLUT[ 256 ], - /* [out] */ BYTE BlueLUT[ 256 ], - /* [out] */ BYTE AlphaLUT[ 256 ]); - - HRESULT ( STDMETHODCALLTYPE *IsChannelIdentity )( - IDXLookupTable * This, - /* [out] */ DXBASESAMPLE *pSampleBools); - - HRESULT ( STDMETHODCALLTYPE *GetIndexValues )( - IDXLookupTable * This, - /* [in] */ ULONG Index, - /* [out] */ DXBASESAMPLE *pSample); - - HRESULT ( STDMETHODCALLTYPE *ApplyTables )( - IDXLookupTable * This, - /* [out][in] */ DXSAMPLE *pSamples, - /* [in] */ ULONG cSamples); - - END_INTERFACE - } IDXLookupTableVtbl; - - interface IDXLookupTable - { - CONST_VTBL struct IDXLookupTableVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXLookupTable_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXLookupTable_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXLookupTable_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXLookupTable_GetGenerationId(This,pID) \ - (This)->lpVtbl -> GetGenerationId(This,pID) - -#define IDXLookupTable_IncrementGenerationId(This,bRefresh) \ - (This)->lpVtbl -> IncrementGenerationId(This,bRefresh) - -#define IDXLookupTable_GetObjectSize(This,pcbSize) \ - (This)->lpVtbl -> GetObjectSize(This,pcbSize) - - -#define IDXLookupTable_GetTables(This,RedLUT,GreenLUT,BlueLUT,AlphaLUT) \ - (This)->lpVtbl -> GetTables(This,RedLUT,GreenLUT,BlueLUT,AlphaLUT) - -#define IDXLookupTable_IsChannelIdentity(This,pSampleBools) \ - (This)->lpVtbl -> IsChannelIdentity(This,pSampleBools) - -#define IDXLookupTable_GetIndexValues(This,Index,pSample) \ - (This)->lpVtbl -> GetIndexValues(This,Index,pSample) - -#define IDXLookupTable_ApplyTables(This,pSamples,cSamples) \ - (This)->lpVtbl -> ApplyTables(This,pSamples,cSamples) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXLookupTable_GetTables_Proxy( - IDXLookupTable * This, - /* [out] */ BYTE RedLUT[ 256 ], - /* [out] */ BYTE GreenLUT[ 256 ], - /* [out] */ BYTE BlueLUT[ 256 ], - /* [out] */ BYTE AlphaLUT[ 256 ]); - - -void __RPC_STUB IDXLookupTable_GetTables_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXLookupTable_IsChannelIdentity_Proxy( - IDXLookupTable * This, - /* [out] */ DXBASESAMPLE *pSampleBools); - - -void __RPC_STUB IDXLookupTable_IsChannelIdentity_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXLookupTable_GetIndexValues_Proxy( - IDXLookupTable * This, - /* [in] */ ULONG Index, - /* [out] */ DXBASESAMPLE *pSample); - - -void __RPC_STUB IDXLookupTable_GetIndexValues_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDXLookupTable_ApplyTables_Proxy( - IDXLookupTable * This, - /* [out][in] */ DXSAMPLE *pSamples, - /* [in] */ ULONG cSamples); - - -void __RPC_STUB IDXLookupTable_ApplyTables_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXLookupTable_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxtrans_0278 */ -/* [local] */ - -typedef struct DXRAWSURFACEINFO - { - BYTE *pFirstByte; - long lPitch; - ULONG Width; - ULONG Height; - const GUID *pPixelFormat; - HDC hdc; - DWORD dwColorKey; - DXBASESAMPLE *pPalette; - } DXRAWSURFACEINFO; - - - -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0278_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0278_v0_0_s_ifspec; - -#ifndef __IDXRawSurface_INTERFACE_DEFINED__ -#define __IDXRawSurface_INTERFACE_DEFINED__ - -/* interface IDXRawSurface */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IDXRawSurface; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("09756C8A-D96A-11d1-9062-00C04FD9189D") - IDXRawSurface : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE GetSurfaceInfo( - DXRAWSURFACEINFO *pSurfaceInfo) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDXRawSurfaceVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXRawSurface * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXRawSurface * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXRawSurface * This); - - HRESULT ( STDMETHODCALLTYPE *GetSurfaceInfo )( - IDXRawSurface * This, - DXRAWSURFACEINFO *pSurfaceInfo); - - END_INTERFACE - } IDXRawSurfaceVtbl; - - interface IDXRawSurface - { - CONST_VTBL struct IDXRawSurfaceVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXRawSurface_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDXRawSurface_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDXRawSurface_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDXRawSurface_GetSurfaceInfo(This,pSurfaceInfo) \ - (This)->lpVtbl -> GetSurfaceInfo(This,pSurfaceInfo) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDXRawSurface_GetSurfaceInfo_Proxy( - IDXRawSurface * This, - DXRAWSURFACEINFO *pSurfaceInfo); - - -void __RPC_STUB IDXRawSurface_GetSurfaceInfo_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDXRawSurface_INTERFACE_DEFINED__ */ - - -#ifndef __IHTMLDXTransform_INTERFACE_DEFINED__ -#define __IHTMLDXTransform_INTERFACE_DEFINED__ - -/* interface IHTMLDXTransform */ -/* [local][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IHTMLDXTransform; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("30E2AB7D-4FDD-4159-B7EA-DC722BF4ADE5") - IHTMLDXTransform : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE SetHostUrl( - BSTR bstrHostUrl) = 0; - - }; - -#else /* C style interface */ - - typedef struct IHTMLDXTransformVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IHTMLDXTransform * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IHTMLDXTransform * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IHTMLDXTransform * This); - - HRESULT ( STDMETHODCALLTYPE *SetHostUrl )( - IHTMLDXTransform * This, - BSTR bstrHostUrl); - - END_INTERFACE - } IHTMLDXTransformVtbl; - - interface IHTMLDXTransform - { - CONST_VTBL struct IHTMLDXTransformVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IHTMLDXTransform_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IHTMLDXTransform_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IHTMLDXTransform_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IHTMLDXTransform_SetHostUrl(This,bstrHostUrl) \ - (This)->lpVtbl -> SetHostUrl(This,bstrHostUrl) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IHTMLDXTransform_SetHostUrl_Proxy( - IHTMLDXTransform * This, - BSTR bstrHostUrl); - - -void __RPC_STUB IHTMLDXTransform_SetHostUrl_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IHTMLDXTransform_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxtrans_0280 */ -/* [local] */ - -typedef -enum DXTFILTER_STATUS - { DXTFILTER_STATUS_Stopped = 0, - DXTFILTER_STATUS_Applied = DXTFILTER_STATUS_Stopped + 1, - DXTFILTER_STATUS_Playing = DXTFILTER_STATUS_Applied + 1, - DXTFILTER_STATUS_MAX = DXTFILTER_STATUS_Playing + 1 - } DXTFILTER_STATUS; - -typedef -enum DXTFILTER_DISPID - { DISPID_DXTFilter_Percent = 1, - DISPID_DXTFilter_Duration = DISPID_DXTFilter_Percent + 1, - DISPID_DXTFilter_Enabled = DISPID_DXTFilter_Duration + 1, - DISPID_DXTFilter_Status = DISPID_DXTFilter_Enabled + 1, - DISPID_DXTFilter_Apply = DISPID_DXTFilter_Status + 1, - DISPID_DXTFilter_Play = DISPID_DXTFilter_Apply + 1, - DISPID_DXTFilter_Stop = DISPID_DXTFilter_Play + 1, - DISPID_DXTFilter_MAX = DISPID_DXTFilter_Stop + 1 - } DXTFILTER_DISPID; - - - -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0280_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0280_v0_0_s_ifspec; - -#ifndef __ICSSFilterDispatch_INTERFACE_DEFINED__ -#define __ICSSFilterDispatch_INTERFACE_DEFINED__ - -/* interface ICSSFilterDispatch */ -/* [dual][unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_ICSSFilterDispatch; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9519152B-9484-4A6C-B6A7-4F25E92D6C6B") - ICSSFilterDispatch : public IDispatch - { - public: - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Percent( - /* [retval][out] */ float *pVal) = 0; - - virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Percent( - /* [in] */ float newVal) = 0; - - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Duration( - /* [retval][out] */ float *pVal) = 0; - - virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Duration( - /* [in] */ float newVal) = 0; - - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Enabled( - /* [retval][out] */ VARIANT_BOOL *pfVal) = 0; - - virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Enabled( - /* [in] */ VARIANT_BOOL fVal) = 0; - - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Status( - /* [retval][out] */ DXTFILTER_STATUS *peVal) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE Apply( void) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE Play( - /* [optional][in] */ VARIANT varDuration) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE Stop( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct ICSSFilterDispatchVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ICSSFilterDispatch * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - ICSSFilterDispatch * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - ICSSFilterDispatch * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - ICSSFilterDispatch * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - ICSSFilterDispatch * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - ICSSFilterDispatch * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - ICSSFilterDispatch * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Percent )( - ICSSFilterDispatch * This, - /* [retval][out] */ float *pVal); - - /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Percent )( - ICSSFilterDispatch * This, - /* [in] */ float newVal); - - /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Duration )( - ICSSFilterDispatch * This, - /* [retval][out] */ float *pVal); - - /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Duration )( - ICSSFilterDispatch * This, - /* [in] */ float newVal); - - /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Enabled )( - ICSSFilterDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pfVal); - - /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Enabled )( - ICSSFilterDispatch * This, - /* [in] */ VARIANT_BOOL fVal); - - /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Status )( - ICSSFilterDispatch * This, - /* [retval][out] */ DXTFILTER_STATUS *peVal); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *Apply )( - ICSSFilterDispatch * This); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *Play )( - ICSSFilterDispatch * This, - /* [optional][in] */ VARIANT varDuration); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *Stop )( - ICSSFilterDispatch * This); - - END_INTERFACE - } ICSSFilterDispatchVtbl; - - interface ICSSFilterDispatch - { - CONST_VTBL struct ICSSFilterDispatchVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ICSSFilterDispatch_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define ICSSFilterDispatch_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define ICSSFilterDispatch_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define ICSSFilterDispatch_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define ICSSFilterDispatch_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define ICSSFilterDispatch_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define ICSSFilterDispatch_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define ICSSFilterDispatch_get_Percent(This,pVal) \ - (This)->lpVtbl -> get_Percent(This,pVal) - -#define ICSSFilterDispatch_put_Percent(This,newVal) \ - (This)->lpVtbl -> put_Percent(This,newVal) - -#define ICSSFilterDispatch_get_Duration(This,pVal) \ - (This)->lpVtbl -> get_Duration(This,pVal) - -#define ICSSFilterDispatch_put_Duration(This,newVal) \ - (This)->lpVtbl -> put_Duration(This,newVal) - -#define ICSSFilterDispatch_get_Enabled(This,pfVal) \ - (This)->lpVtbl -> get_Enabled(This,pfVal) - -#define ICSSFilterDispatch_put_Enabled(This,fVal) \ - (This)->lpVtbl -> put_Enabled(This,fVal) - -#define ICSSFilterDispatch_get_Status(This,peVal) \ - (This)->lpVtbl -> get_Status(This,peVal) - -#define ICSSFilterDispatch_Apply(This) \ - (This)->lpVtbl -> Apply(This) - -#define ICSSFilterDispatch_Play(This,varDuration) \ - (This)->lpVtbl -> Play(This,varDuration) - -#define ICSSFilterDispatch_Stop(This) \ - (This)->lpVtbl -> Stop(This) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [id][propget] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_get_Percent_Proxy( - ICSSFilterDispatch * This, - /* [retval][out] */ float *pVal); - - -void __RPC_STUB ICSSFilterDispatch_get_Percent_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][propput] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_put_Percent_Proxy( - ICSSFilterDispatch * This, - /* [in] */ float newVal); - - -void __RPC_STUB ICSSFilterDispatch_put_Percent_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][propget] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_get_Duration_Proxy( - ICSSFilterDispatch * This, - /* [retval][out] */ float *pVal); - - -void __RPC_STUB ICSSFilterDispatch_get_Duration_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][propput] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_put_Duration_Proxy( - ICSSFilterDispatch * This, - /* [in] */ float newVal); - - -void __RPC_STUB ICSSFilterDispatch_put_Duration_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][propget] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_get_Enabled_Proxy( - ICSSFilterDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pfVal); - - -void __RPC_STUB ICSSFilterDispatch_get_Enabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][propput] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_put_Enabled_Proxy( - ICSSFilterDispatch * This, - /* [in] */ VARIANT_BOOL fVal); - - -void __RPC_STUB ICSSFilterDispatch_put_Enabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][propget] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_get_Status_Proxy( - ICSSFilterDispatch * This, - /* [retval][out] */ DXTFILTER_STATUS *peVal); - - -void __RPC_STUB ICSSFilterDispatch_get_Status_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_Apply_Proxy( - ICSSFilterDispatch * This); - - -void __RPC_STUB ICSSFilterDispatch_Apply_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_Play_Proxy( - ICSSFilterDispatch * This, - /* [optional][in] */ VARIANT varDuration); - - -void __RPC_STUB ICSSFilterDispatch_Play_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_Stop_Proxy( - ICSSFilterDispatch * This); - - -void __RPC_STUB ICSSFilterDispatch_Stop_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __ICSSFilterDispatch_INTERFACE_DEFINED__ */ - - - -#ifndef __DXTRANSLib_LIBRARY_DEFINED__ -#define __DXTRANSLib_LIBRARY_DEFINED__ - -/* library DXTRANSLib */ -/* [helpstring][version][uuid] */ - - -EXTERN_C const IID LIBID_DXTRANSLib; - -EXTERN_C const CLSID CLSID_DXTransformFactory; - -#ifdef __cplusplus - -class DECLSPEC_UUID("D1FE6762-FC48-11D0-883A-3C8B00C10000") -DXTransformFactory; -#endif - -EXTERN_C const CLSID CLSID_DXTaskManager; - -#ifdef __cplusplus - -class DECLSPEC_UUID("4CB26C03-FF93-11d0-817E-0000F87557DB") -DXTaskManager; -#endif - -EXTERN_C const CLSID CLSID_DXTScale; - -#ifdef __cplusplus - -class DECLSPEC_UUID("555278E2-05DB-11D1-883A-3C8B00C10000") -DXTScale; -#endif - -EXTERN_C const CLSID CLSID_DXSurface; - -#ifdef __cplusplus - -class DECLSPEC_UUID("0E890F83-5F79-11D1-9043-00C04FD9189D") -DXSurface; -#endif - -EXTERN_C const CLSID CLSID_DXSurfaceModifier; - -#ifdef __cplusplus - -class DECLSPEC_UUID("3E669F1D-9C23-11d1-9053-00C04FD9189D") -DXSurfaceModifier; -#endif - -EXTERN_C const CLSID CLSID_DXGradient; - -#ifdef __cplusplus - -class DECLSPEC_UUID("C6365470-F667-11d1-9067-00C04FD9189D") -DXGradient; -#endif - -EXTERN_C const CLSID CLSID_DXTFilter; - -#ifdef __cplusplus - -class DECLSPEC_UUID("385A91BC-1E8A-4e4a-A7A6-F4FC1E6CA1BD") -DXTFilter; -#endif -#endif /* __DXTRANSLib_LIBRARY_DEFINED__ */ - -/* Additional Prototypes for ALL interfaces */ - -unsigned long __RPC_USER VARIANT_UserSize( unsigned long *, unsigned long , VARIANT * ); -unsigned char * __RPC_USER VARIANT_UserMarshal( unsigned long *, unsigned char *, VARIANT * ); -unsigned char * __RPC_USER VARIANT_UserUnmarshal(unsigned long *, unsigned char *, VARIANT * ); -void __RPC_USER VARIANT_UserFree( unsigned long *, VARIANT * ); - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 6.00.0357 */ +/* Compiler settings for dxtrans.idl: + Oicf, W1, Zp8, env=Win32 (32b run) + protocol : dce , ms_ext, c_ext + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +//@@MIDL_FILE_HEADING( ) + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 440 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif // __RPCNDR_H_VERSION__ + +#ifndef COM_NO_WINDOWS_H +#include "windows.h" +#include "ole2.h" +#endif /*COM_NO_WINDOWS_H*/ + +#ifndef __dxtrans_h__ +#define __dxtrans_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +#ifndef __IDXBaseObject_FWD_DEFINED__ +#define __IDXBaseObject_FWD_DEFINED__ +typedef interface IDXBaseObject IDXBaseObject; +#endif /* __IDXBaseObject_FWD_DEFINED__ */ + + +#ifndef __IDXTransformFactory_FWD_DEFINED__ +#define __IDXTransformFactory_FWD_DEFINED__ +typedef interface IDXTransformFactory IDXTransformFactory; +#endif /* __IDXTransformFactory_FWD_DEFINED__ */ + + +#ifndef __IDXTransform_FWD_DEFINED__ +#define __IDXTransform_FWD_DEFINED__ +typedef interface IDXTransform IDXTransform; +#endif /* __IDXTransform_FWD_DEFINED__ */ + + +#ifndef __IDXSurfacePick_FWD_DEFINED__ +#define __IDXSurfacePick_FWD_DEFINED__ +typedef interface IDXSurfacePick IDXSurfacePick; +#endif /* __IDXSurfacePick_FWD_DEFINED__ */ + + +#ifndef __IDXTBindHost_FWD_DEFINED__ +#define __IDXTBindHost_FWD_DEFINED__ +typedef interface IDXTBindHost IDXTBindHost; +#endif /* __IDXTBindHost_FWD_DEFINED__ */ + + +#ifndef __IDXTaskManager_FWD_DEFINED__ +#define __IDXTaskManager_FWD_DEFINED__ +typedef interface IDXTaskManager IDXTaskManager; +#endif /* __IDXTaskManager_FWD_DEFINED__ */ + + +#ifndef __IDXSurfaceFactory_FWD_DEFINED__ +#define __IDXSurfaceFactory_FWD_DEFINED__ +typedef interface IDXSurfaceFactory IDXSurfaceFactory; +#endif /* __IDXSurfaceFactory_FWD_DEFINED__ */ + + +#ifndef __IDXSurfaceModifier_FWD_DEFINED__ +#define __IDXSurfaceModifier_FWD_DEFINED__ +typedef interface IDXSurfaceModifier IDXSurfaceModifier; +#endif /* __IDXSurfaceModifier_FWD_DEFINED__ */ + + +#ifndef __IDXSurface_FWD_DEFINED__ +#define __IDXSurface_FWD_DEFINED__ +typedef interface IDXSurface IDXSurface; +#endif /* __IDXSurface_FWD_DEFINED__ */ + + +#ifndef __IDXSurfaceInit_FWD_DEFINED__ +#define __IDXSurfaceInit_FWD_DEFINED__ +typedef interface IDXSurfaceInit IDXSurfaceInit; +#endif /* __IDXSurfaceInit_FWD_DEFINED__ */ + + +#ifndef __IDXARGBSurfaceInit_FWD_DEFINED__ +#define __IDXARGBSurfaceInit_FWD_DEFINED__ +typedef interface IDXARGBSurfaceInit IDXARGBSurfaceInit; +#endif /* __IDXARGBSurfaceInit_FWD_DEFINED__ */ + + +#ifndef __IDXARGBReadPtr_FWD_DEFINED__ +#define __IDXARGBReadPtr_FWD_DEFINED__ +typedef interface IDXARGBReadPtr IDXARGBReadPtr; +#endif /* __IDXARGBReadPtr_FWD_DEFINED__ */ + + +#ifndef __IDXARGBReadWritePtr_FWD_DEFINED__ +#define __IDXARGBReadWritePtr_FWD_DEFINED__ +typedef interface IDXARGBReadWritePtr IDXARGBReadWritePtr; +#endif /* __IDXARGBReadWritePtr_FWD_DEFINED__ */ + + +#ifndef __IDXDCLock_FWD_DEFINED__ +#define __IDXDCLock_FWD_DEFINED__ +typedef interface IDXDCLock IDXDCLock; +#endif /* __IDXDCLock_FWD_DEFINED__ */ + + +#ifndef __IDXTScaleOutput_FWD_DEFINED__ +#define __IDXTScaleOutput_FWD_DEFINED__ +typedef interface IDXTScaleOutput IDXTScaleOutput; +#endif /* __IDXTScaleOutput_FWD_DEFINED__ */ + + +#ifndef __IDXGradient_FWD_DEFINED__ +#define __IDXGradient_FWD_DEFINED__ +typedef interface IDXGradient IDXGradient; +#endif /* __IDXGradient_FWD_DEFINED__ */ + + +#ifndef __IDXTScale_FWD_DEFINED__ +#define __IDXTScale_FWD_DEFINED__ +typedef interface IDXTScale IDXTScale; +#endif /* __IDXTScale_FWD_DEFINED__ */ + + +#ifndef __IDXEffect_FWD_DEFINED__ +#define __IDXEffect_FWD_DEFINED__ +typedef interface IDXEffect IDXEffect; +#endif /* __IDXEffect_FWD_DEFINED__ */ + + +#ifndef __IDXLookupTable_FWD_DEFINED__ +#define __IDXLookupTable_FWD_DEFINED__ +typedef interface IDXLookupTable IDXLookupTable; +#endif /* __IDXLookupTable_FWD_DEFINED__ */ + + +#ifndef __IDXRawSurface_FWD_DEFINED__ +#define __IDXRawSurface_FWD_DEFINED__ +typedef interface IDXRawSurface IDXRawSurface; +#endif /* __IDXRawSurface_FWD_DEFINED__ */ + + +#ifndef __IHTMLDXTransform_FWD_DEFINED__ +#define __IHTMLDXTransform_FWD_DEFINED__ +typedef interface IHTMLDXTransform IHTMLDXTransform; +#endif /* __IHTMLDXTransform_FWD_DEFINED__ */ + + +#ifndef __ICSSFilterDispatch_FWD_DEFINED__ +#define __ICSSFilterDispatch_FWD_DEFINED__ +typedef interface ICSSFilterDispatch ICSSFilterDispatch; +#endif /* __ICSSFilterDispatch_FWD_DEFINED__ */ + + +#ifndef __DXTransformFactory_FWD_DEFINED__ +#define __DXTransformFactory_FWD_DEFINED__ + +#ifdef __cplusplus +typedef class DXTransformFactory DXTransformFactory; +#else +typedef struct DXTransformFactory DXTransformFactory; +#endif /* __cplusplus */ + +#endif /* __DXTransformFactory_FWD_DEFINED__ */ + + +#ifndef __DXTaskManager_FWD_DEFINED__ +#define __DXTaskManager_FWD_DEFINED__ + +#ifdef __cplusplus +typedef class DXTaskManager DXTaskManager; +#else +typedef struct DXTaskManager DXTaskManager; +#endif /* __cplusplus */ + +#endif /* __DXTaskManager_FWD_DEFINED__ */ + + +#ifndef __DXTScale_FWD_DEFINED__ +#define __DXTScale_FWD_DEFINED__ + +#ifdef __cplusplus +typedef class DXTScale DXTScale; +#else +typedef struct DXTScale DXTScale; +#endif /* __cplusplus */ + +#endif /* __DXTScale_FWD_DEFINED__ */ + + +#ifndef __DXSurface_FWD_DEFINED__ +#define __DXSurface_FWD_DEFINED__ + +#ifdef __cplusplus +typedef class DXSurface DXSurface; +#else +typedef struct DXSurface DXSurface; +#endif /* __cplusplus */ + +#endif /* __DXSurface_FWD_DEFINED__ */ + + +#ifndef __DXSurfaceModifier_FWD_DEFINED__ +#define __DXSurfaceModifier_FWD_DEFINED__ + +#ifdef __cplusplus +typedef class DXSurfaceModifier DXSurfaceModifier; +#else +typedef struct DXSurfaceModifier DXSurfaceModifier; +#endif /* __cplusplus */ + +#endif /* __DXSurfaceModifier_FWD_DEFINED__ */ + + +#ifndef __DXGradient_FWD_DEFINED__ +#define __DXGradient_FWD_DEFINED__ + +#ifdef __cplusplus +typedef class DXGradient DXGradient; +#else +typedef struct DXGradient DXGradient; +#endif /* __cplusplus */ + +#endif /* __DXGradient_FWD_DEFINED__ */ + + +#ifndef __DXTFilter_FWD_DEFINED__ +#define __DXTFilter_FWD_DEFINED__ + +#ifdef __cplusplus +typedef class DXTFilter DXTFilter; +#else +typedef struct DXTFilter DXTFilter; +#endif /* __cplusplus */ + +#endif /* __DXTFilter_FWD_DEFINED__ */ + + +/* header files for imported files */ +#include "oaidl.h" +#include "ocidl.h" +#include "comcat.h" + +#ifdef __cplusplus +extern "C"{ +#endif + +void * __RPC_USER MIDL_user_allocate(size_t); +void __RPC_USER MIDL_user_free( void * ); + +/* interface __MIDL_itf_dxtrans_0000 */ +/* [local] */ + +#include +#include +#include +#include +#include +#if 0 +// Bogus definition used to make MIDL compiler happy +typedef void DDSURFACEDESC; + +typedef void D3DRMBOX; + +typedef void D3DVECTOR; + +typedef void D3DRMMATRIX4D; + +typedef void *LPSECURITY_ATTRIBUTES; + +#endif +#ifdef _DXTRANSIMPL + #define _DXTRANS_IMPL_EXT _declspec(dllexport) +#else + #define _DXTRANS_IMPL_EXT _declspec(dllimport) +#endif + + + + + + + + + + + + + + + + +// +// All GUIDs for DXTransform are declared in DXTGUID.C in the SDK include directory +// +EXTERN_C const GUID DDPF_RGB1; +EXTERN_C const GUID DDPF_RGB2; +EXTERN_C const GUID DDPF_RGB4; +EXTERN_C const GUID DDPF_RGB8; +EXTERN_C const GUID DDPF_RGB332; +EXTERN_C const GUID DDPF_ARGB4444; +EXTERN_C const GUID DDPF_RGB565; +EXTERN_C const GUID DDPF_BGR565; +EXTERN_C const GUID DDPF_RGB555; +EXTERN_C const GUID DDPF_ARGB1555; +EXTERN_C const GUID DDPF_RGB24; +EXTERN_C const GUID DDPF_BGR24; +EXTERN_C const GUID DDPF_RGB32; +EXTERN_C const GUID DDPF_BGR32; +EXTERN_C const GUID DDPF_ABGR32; +EXTERN_C const GUID DDPF_ARGB32; +EXTERN_C const GUID DDPF_PMARGB32; +EXTERN_C const GUID DDPF_A1; +EXTERN_C const GUID DDPF_A2; +EXTERN_C const GUID DDPF_A4; +EXTERN_C const GUID DDPF_A8; +EXTERN_C const GUID DDPF_Z8; +EXTERN_C const GUID DDPF_Z16; +EXTERN_C const GUID DDPF_Z24; +EXTERN_C const GUID DDPF_Z32; +// +// Component categories +// +EXTERN_C const GUID CATID_DXImageTransform; +EXTERN_C const GUID CATID_DX3DTransform; +EXTERN_C const GUID CATID_DXAuthoringTransform; +EXTERN_C const GUID CATID_DXSurface; +// +// Service IDs +// +EXTERN_C const GUID SID_SDirectDraw; +EXTERN_C const GUID SID_SDirect3DRM; +#define SID_SDXTaskManager CLSID_DXTaskManager +#define SID_SDXSurfaceFactory IID_IDXSurfaceFactory +#define SID_SDXTransformFactory IID_IDXTransformFactory +// +// DXTransforms Core Type Library Version Info +// +#define DXTRANS_TLB_MAJOR_VER 1 +#define DXTRANS_TLB_MINOR_VER 1 + + +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0000_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0000_v0_0_s_ifspec; + +#ifndef __IDXBaseObject_INTERFACE_DEFINED__ +#define __IDXBaseObject_INTERFACE_DEFINED__ + +/* interface IDXBaseObject */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXBaseObject; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("17B59B2B-9CC8-11d1-9053-00C04FD9189D") + IDXBaseObject : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE GetGenerationId( + /* [out] */ ULONG *pID) = 0; + + virtual HRESULT STDMETHODCALLTYPE IncrementGenerationId( + /* [in] */ BOOL bRefresh) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetObjectSize( + /* [out] */ ULONG *pcbSize) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXBaseObjectVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXBaseObject * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXBaseObject * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXBaseObject * This); + + HRESULT ( STDMETHODCALLTYPE *GetGenerationId )( + IDXBaseObject * This, + /* [out] */ ULONG *pID); + + HRESULT ( STDMETHODCALLTYPE *IncrementGenerationId )( + IDXBaseObject * This, + /* [in] */ BOOL bRefresh); + + HRESULT ( STDMETHODCALLTYPE *GetObjectSize )( + IDXBaseObject * This, + /* [out] */ ULONG *pcbSize); + + END_INTERFACE + } IDXBaseObjectVtbl; + + interface IDXBaseObject + { + CONST_VTBL struct IDXBaseObjectVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXBaseObject_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXBaseObject_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXBaseObject_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXBaseObject_GetGenerationId(This,pID) \ + (This)->lpVtbl -> GetGenerationId(This,pID) + +#define IDXBaseObject_IncrementGenerationId(This,bRefresh) \ + (This)->lpVtbl -> IncrementGenerationId(This,bRefresh) + +#define IDXBaseObject_GetObjectSize(This,pcbSize) \ + (This)->lpVtbl -> GetObjectSize(This,pcbSize) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXBaseObject_GetGenerationId_Proxy( + IDXBaseObject * This, + /* [out] */ ULONG *pID); + + +void __RPC_STUB IDXBaseObject_GetGenerationId_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXBaseObject_IncrementGenerationId_Proxy( + IDXBaseObject * This, + /* [in] */ BOOL bRefresh); + + +void __RPC_STUB IDXBaseObject_IncrementGenerationId_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXBaseObject_GetObjectSize_Proxy( + IDXBaseObject * This, + /* [out] */ ULONG *pcbSize); + + +void __RPC_STUB IDXBaseObject_GetObjectSize_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXBaseObject_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxtrans_0260 */ +/* [local] */ + +typedef +enum DXBNDID + { DXB_X = 0, + DXB_Y = 1, + DXB_Z = 2, + DXB_T = 3 + } DXBNDID; + +typedef +enum DXBNDTYPE + { DXBT_DISCRETE = 0, + DXBT_DISCRETE64 = DXBT_DISCRETE + 1, + DXBT_CONTINUOUS = DXBT_DISCRETE64 + 1, + DXBT_CONTINUOUS64 = DXBT_CONTINUOUS + 1 + } DXBNDTYPE; + +typedef struct DXDBND + { + long Min; + long Max; + } DXDBND; + +typedef DXDBND DXDBNDS[ 4 ]; + +typedef struct DXDBND64 + { + LONGLONG Min; + LONGLONG Max; + } DXDBND64; + +typedef DXDBND64 DXDBNDS64[ 4 ]; + +typedef struct DXCBND + { + float Min; + float Max; + } DXCBND; + +typedef DXCBND DXCBNDS[ 4 ]; + +typedef struct DXCBND64 + { + double Min; + double Max; + } DXCBND64; + +typedef DXCBND64 DXCBNDS64[ 4 ]; + +typedef struct DXBNDS + { + DXBNDTYPE eType; + /* [switch_is] */ /* [switch_type] */ union __MIDL___MIDL_itf_dxtrans_0260_0001 + { + /* [case()] */ DXDBND D[ 4 ]; + /* [case()] */ DXDBND64 LD[ 4 ]; + /* [case()] */ DXCBND C[ 4 ]; + /* [case()] */ DXCBND64 LC[ 4 ]; + } u; + } DXBNDS; + +typedef long DXDVEC[ 4 ]; + +typedef LONGLONG DXDVEC64[ 4 ]; + +typedef float DXCVEC[ 4 ]; + +typedef double DXCVEC64[ 4 ]; + +typedef struct DXVEC + { + DXBNDTYPE eType; + /* [switch_is] */ /* [switch_type] */ union __MIDL___MIDL_itf_dxtrans_0260_0002 + { + /* [case()] */ long D[ 4 ]; + /* [case()] */ LONGLONG LD[ 4 ]; + /* [case()] */ float C[ 4 ]; + /* [case()] */ double LC[ 4 ]; + } u; + } DXVEC; + + + +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0260_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0260_v0_0_s_ifspec; + +#ifndef __IDXTransformFactory_INTERFACE_DEFINED__ +#define __IDXTransformFactory_INTERFACE_DEFINED__ + +/* interface IDXTransformFactory */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXTransformFactory; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("6A950B2B-A971-11d1-81C8-0000F87557DB") + IDXTransformFactory : public IServiceProvider + { + public: + virtual HRESULT STDMETHODCALLTYPE SetService( + /* [in] */ REFGUID guidService, + /* [in] */ IUnknown *pUnkService, + /* [in] */ BOOL bWeakReference) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateTransform( + /* [size_is][in] */ IUnknown **punkInputs, + /* [in] */ ULONG ulNumInputs, + /* [size_is][in] */ IUnknown **punkOutputs, + /* [in] */ ULONG ulNumOutputs, + /* [in] */ IPropertyBag *pInitProps, + /* [in] */ IErrorLog *pErrLog, + /* [in] */ REFCLSID TransCLSID, + /* [in] */ REFIID TransIID, + /* [iid_is][out] */ void **ppTransform) = 0; + + virtual HRESULT STDMETHODCALLTYPE InitializeTransform( + /* [in] */ IDXTransform *pTransform, + /* [size_is][in] */ IUnknown **punkInputs, + /* [in] */ ULONG ulNumInputs, + /* [size_is][in] */ IUnknown **punkOutputs, + /* [in] */ ULONG ulNumOutputs, + /* [in] */ IPropertyBag *pInitProps, + /* [in] */ IErrorLog *pErrLog) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXTransformFactoryVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXTransformFactory * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXTransformFactory * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXTransformFactory * This); + + /* [local] */ HRESULT ( STDMETHODCALLTYPE *QueryService )( + IDXTransformFactory * This, + /* [in] */ REFGUID guidService, + /* [in] */ REFIID riid, + /* [out] */ void **ppvObject); + + HRESULT ( STDMETHODCALLTYPE *SetService )( + IDXTransformFactory * This, + /* [in] */ REFGUID guidService, + /* [in] */ IUnknown *pUnkService, + /* [in] */ BOOL bWeakReference); + + HRESULT ( STDMETHODCALLTYPE *CreateTransform )( + IDXTransformFactory * This, + /* [size_is][in] */ IUnknown **punkInputs, + /* [in] */ ULONG ulNumInputs, + /* [size_is][in] */ IUnknown **punkOutputs, + /* [in] */ ULONG ulNumOutputs, + /* [in] */ IPropertyBag *pInitProps, + /* [in] */ IErrorLog *pErrLog, + /* [in] */ REFCLSID TransCLSID, + /* [in] */ REFIID TransIID, + /* [iid_is][out] */ void **ppTransform); + + HRESULT ( STDMETHODCALLTYPE *InitializeTransform )( + IDXTransformFactory * This, + /* [in] */ IDXTransform *pTransform, + /* [size_is][in] */ IUnknown **punkInputs, + /* [in] */ ULONG ulNumInputs, + /* [size_is][in] */ IUnknown **punkOutputs, + /* [in] */ ULONG ulNumOutputs, + /* [in] */ IPropertyBag *pInitProps, + /* [in] */ IErrorLog *pErrLog); + + END_INTERFACE + } IDXTransformFactoryVtbl; + + interface IDXTransformFactory + { + CONST_VTBL struct IDXTransformFactoryVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXTransformFactory_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXTransformFactory_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXTransformFactory_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXTransformFactory_QueryService(This,guidService,riid,ppvObject) \ + (This)->lpVtbl -> QueryService(This,guidService,riid,ppvObject) + + +#define IDXTransformFactory_SetService(This,guidService,pUnkService,bWeakReference) \ + (This)->lpVtbl -> SetService(This,guidService,pUnkService,bWeakReference) + +#define IDXTransformFactory_CreateTransform(This,punkInputs,ulNumInputs,punkOutputs,ulNumOutputs,pInitProps,pErrLog,TransCLSID,TransIID,ppTransform) \ + (This)->lpVtbl -> CreateTransform(This,punkInputs,ulNumInputs,punkOutputs,ulNumOutputs,pInitProps,pErrLog,TransCLSID,TransIID,ppTransform) + +#define IDXTransformFactory_InitializeTransform(This,pTransform,punkInputs,ulNumInputs,punkOutputs,ulNumOutputs,pInitProps,pErrLog) \ + (This)->lpVtbl -> InitializeTransform(This,pTransform,punkInputs,ulNumInputs,punkOutputs,ulNumOutputs,pInitProps,pErrLog) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXTransformFactory_SetService_Proxy( + IDXTransformFactory * This, + /* [in] */ REFGUID guidService, + /* [in] */ IUnknown *pUnkService, + /* [in] */ BOOL bWeakReference); + + +void __RPC_STUB IDXTransformFactory_SetService_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTransformFactory_CreateTransform_Proxy( + IDXTransformFactory * This, + /* [size_is][in] */ IUnknown **punkInputs, + /* [in] */ ULONG ulNumInputs, + /* [size_is][in] */ IUnknown **punkOutputs, + /* [in] */ ULONG ulNumOutputs, + /* [in] */ IPropertyBag *pInitProps, + /* [in] */ IErrorLog *pErrLog, + /* [in] */ REFCLSID TransCLSID, + /* [in] */ REFIID TransIID, + /* [iid_is][out] */ void **ppTransform); + + +void __RPC_STUB IDXTransformFactory_CreateTransform_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTransformFactory_InitializeTransform_Proxy( + IDXTransformFactory * This, + /* [in] */ IDXTransform *pTransform, + /* [size_is][in] */ IUnknown **punkInputs, + /* [in] */ ULONG ulNumInputs, + /* [size_is][in] */ IUnknown **punkOutputs, + /* [in] */ ULONG ulNumOutputs, + /* [in] */ IPropertyBag *pInitProps, + /* [in] */ IErrorLog *pErrLog); + + +void __RPC_STUB IDXTransformFactory_InitializeTransform_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXTransformFactory_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxtrans_0261 */ +/* [local] */ + +typedef +enum DXTMISCFLAGS + { DXTMF_BLEND_WITH_OUTPUT = 1L << 0, + DXTMF_DITHER_OUTPUT = 1L << 1, + DXTMF_OPTION_MASK = 0xffff, + DXTMF_VALID_OPTIONS = DXTMF_BLEND_WITH_OUTPUT | DXTMF_DITHER_OUTPUT, + DXTMF_BLEND_SUPPORTED = 1L << 16, + DXTMF_DITHER_SUPPORTED = 1L << 17, + DXTMF_INPLACE_OPERATION = 1L << 24, + DXTMF_BOUNDS_SUPPORTED = 1L << 25, + DXTMF_PLACEMENT_SUPPORTED = 1L << 26, + DXTMF_QUALITY_SUPPORTED = 1L << 27, + DXTMF_OPAQUE_RESULT = 1L << 28 + } DXTMISCFLAGS; + +typedef +enum DXINOUTINFOFLAGS + { DXINOUTF_OPTIONAL = 1L << 0 + } DXINOUTINFOFLAGS; + + + +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0261_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0261_v0_0_s_ifspec; + +#ifndef __IDXTransform_INTERFACE_DEFINED__ +#define __IDXTransform_INTERFACE_DEFINED__ + +/* interface IDXTransform */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXTransform; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("30A5FB78-E11F-11d1-9064-00C04FD9189D") + IDXTransform : public IDXBaseObject + { + public: + virtual HRESULT STDMETHODCALLTYPE Setup( + /* [size_is][in] */ IUnknown *const *punkInputs, + /* [in] */ ULONG ulNumInputs, + /* [size_is][in] */ IUnknown *const *punkOutputs, + /* [in] */ ULONG ulNumOutputs, + /* [in] */ DWORD dwFlags) = 0; + + virtual HRESULT STDMETHODCALLTYPE Execute( + /* [in] */ const GUID *pRequestID, + /* [in] */ const DXBNDS *pClipBnds, + /* [in] */ const DXVEC *pPlacement) = 0; + + virtual HRESULT STDMETHODCALLTYPE MapBoundsIn2Out( + /* [in] */ const DXBNDS *pInBounds, + /* [in] */ ULONG ulNumInBnds, + /* [in] */ ULONG ulOutIndex, + /* [out] */ DXBNDS *pOutBounds) = 0; + + virtual HRESULT STDMETHODCALLTYPE MapBoundsOut2In( + /* [in] */ ULONG ulOutIndex, + /* [in] */ const DXBNDS *pOutBounds, + /* [in] */ ULONG ulInIndex, + /* [out] */ DXBNDS *pInBounds) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetMiscFlags( + /* [in] */ DWORD dwMiscFlags) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetMiscFlags( + /* [out] */ DWORD *pdwMiscFlags) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetInOutInfo( + /* [in] */ BOOL bIsOutput, + /* [in] */ ULONG ulIndex, + /* [out] */ DWORD *pdwFlags, + /* [size_is][out] */ GUID *pIDs, + /* [out][in] */ ULONG *pcIDs, + /* [out] */ IUnknown **ppUnkCurrentObject) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetQuality( + /* [in] */ float fQuality) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetQuality( + /* [out] */ float *fQuality) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXTransformVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXTransform * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXTransform * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXTransform * This); + + HRESULT ( STDMETHODCALLTYPE *GetGenerationId )( + IDXTransform * This, + /* [out] */ ULONG *pID); + + HRESULT ( STDMETHODCALLTYPE *IncrementGenerationId )( + IDXTransform * This, + /* [in] */ BOOL bRefresh); + + HRESULT ( STDMETHODCALLTYPE *GetObjectSize )( + IDXTransform * This, + /* [out] */ ULONG *pcbSize); + + HRESULT ( STDMETHODCALLTYPE *Setup )( + IDXTransform * This, + /* [size_is][in] */ IUnknown *const *punkInputs, + /* [in] */ ULONG ulNumInputs, + /* [size_is][in] */ IUnknown *const *punkOutputs, + /* [in] */ ULONG ulNumOutputs, + /* [in] */ DWORD dwFlags); + + HRESULT ( STDMETHODCALLTYPE *Execute )( + IDXTransform * This, + /* [in] */ const GUID *pRequestID, + /* [in] */ const DXBNDS *pClipBnds, + /* [in] */ const DXVEC *pPlacement); + + HRESULT ( STDMETHODCALLTYPE *MapBoundsIn2Out )( + IDXTransform * This, + /* [in] */ const DXBNDS *pInBounds, + /* [in] */ ULONG ulNumInBnds, + /* [in] */ ULONG ulOutIndex, + /* [out] */ DXBNDS *pOutBounds); + + HRESULT ( STDMETHODCALLTYPE *MapBoundsOut2In )( + IDXTransform * This, + /* [in] */ ULONG ulOutIndex, + /* [in] */ const DXBNDS *pOutBounds, + /* [in] */ ULONG ulInIndex, + /* [out] */ DXBNDS *pInBounds); + + HRESULT ( STDMETHODCALLTYPE *SetMiscFlags )( + IDXTransform * This, + /* [in] */ DWORD dwMiscFlags); + + HRESULT ( STDMETHODCALLTYPE *GetMiscFlags )( + IDXTransform * This, + /* [out] */ DWORD *pdwMiscFlags); + + HRESULT ( STDMETHODCALLTYPE *GetInOutInfo )( + IDXTransform * This, + /* [in] */ BOOL bIsOutput, + /* [in] */ ULONG ulIndex, + /* [out] */ DWORD *pdwFlags, + /* [size_is][out] */ GUID *pIDs, + /* [out][in] */ ULONG *pcIDs, + /* [out] */ IUnknown **ppUnkCurrentObject); + + HRESULT ( STDMETHODCALLTYPE *SetQuality )( + IDXTransform * This, + /* [in] */ float fQuality); + + HRESULT ( STDMETHODCALLTYPE *GetQuality )( + IDXTransform * This, + /* [out] */ float *fQuality); + + END_INTERFACE + } IDXTransformVtbl; + + interface IDXTransform + { + CONST_VTBL struct IDXTransformVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXTransform_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXTransform_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXTransform_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXTransform_GetGenerationId(This,pID) \ + (This)->lpVtbl -> GetGenerationId(This,pID) + +#define IDXTransform_IncrementGenerationId(This,bRefresh) \ + (This)->lpVtbl -> IncrementGenerationId(This,bRefresh) + +#define IDXTransform_GetObjectSize(This,pcbSize) \ + (This)->lpVtbl -> GetObjectSize(This,pcbSize) + + +#define IDXTransform_Setup(This,punkInputs,ulNumInputs,punkOutputs,ulNumOutputs,dwFlags) \ + (This)->lpVtbl -> Setup(This,punkInputs,ulNumInputs,punkOutputs,ulNumOutputs,dwFlags) + +#define IDXTransform_Execute(This,pRequestID,pClipBnds,pPlacement) \ + (This)->lpVtbl -> Execute(This,pRequestID,pClipBnds,pPlacement) + +#define IDXTransform_MapBoundsIn2Out(This,pInBounds,ulNumInBnds,ulOutIndex,pOutBounds) \ + (This)->lpVtbl -> MapBoundsIn2Out(This,pInBounds,ulNumInBnds,ulOutIndex,pOutBounds) + +#define IDXTransform_MapBoundsOut2In(This,ulOutIndex,pOutBounds,ulInIndex,pInBounds) \ + (This)->lpVtbl -> MapBoundsOut2In(This,ulOutIndex,pOutBounds,ulInIndex,pInBounds) + +#define IDXTransform_SetMiscFlags(This,dwMiscFlags) \ + (This)->lpVtbl -> SetMiscFlags(This,dwMiscFlags) + +#define IDXTransform_GetMiscFlags(This,pdwMiscFlags) \ + (This)->lpVtbl -> GetMiscFlags(This,pdwMiscFlags) + +#define IDXTransform_GetInOutInfo(This,bIsOutput,ulIndex,pdwFlags,pIDs,pcIDs,ppUnkCurrentObject) \ + (This)->lpVtbl -> GetInOutInfo(This,bIsOutput,ulIndex,pdwFlags,pIDs,pcIDs,ppUnkCurrentObject) + +#define IDXTransform_SetQuality(This,fQuality) \ + (This)->lpVtbl -> SetQuality(This,fQuality) + +#define IDXTransform_GetQuality(This,fQuality) \ + (This)->lpVtbl -> GetQuality(This,fQuality) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXTransform_Setup_Proxy( + IDXTransform * This, + /* [size_is][in] */ IUnknown *const *punkInputs, + /* [in] */ ULONG ulNumInputs, + /* [size_is][in] */ IUnknown *const *punkOutputs, + /* [in] */ ULONG ulNumOutputs, + /* [in] */ DWORD dwFlags); + + +void __RPC_STUB IDXTransform_Setup_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTransform_Execute_Proxy( + IDXTransform * This, + /* [in] */ const GUID *pRequestID, + /* [in] */ const DXBNDS *pClipBnds, + /* [in] */ const DXVEC *pPlacement); + + +void __RPC_STUB IDXTransform_Execute_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTransform_MapBoundsIn2Out_Proxy( + IDXTransform * This, + /* [in] */ const DXBNDS *pInBounds, + /* [in] */ ULONG ulNumInBnds, + /* [in] */ ULONG ulOutIndex, + /* [out] */ DXBNDS *pOutBounds); + + +void __RPC_STUB IDXTransform_MapBoundsIn2Out_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTransform_MapBoundsOut2In_Proxy( + IDXTransform * This, + /* [in] */ ULONG ulOutIndex, + /* [in] */ const DXBNDS *pOutBounds, + /* [in] */ ULONG ulInIndex, + /* [out] */ DXBNDS *pInBounds); + + +void __RPC_STUB IDXTransform_MapBoundsOut2In_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTransform_SetMiscFlags_Proxy( + IDXTransform * This, + /* [in] */ DWORD dwMiscFlags); + + +void __RPC_STUB IDXTransform_SetMiscFlags_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTransform_GetMiscFlags_Proxy( + IDXTransform * This, + /* [out] */ DWORD *pdwMiscFlags); + + +void __RPC_STUB IDXTransform_GetMiscFlags_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTransform_GetInOutInfo_Proxy( + IDXTransform * This, + /* [in] */ BOOL bIsOutput, + /* [in] */ ULONG ulIndex, + /* [out] */ DWORD *pdwFlags, + /* [size_is][out] */ GUID *pIDs, + /* [out][in] */ ULONG *pcIDs, + /* [out] */ IUnknown **ppUnkCurrentObject); + + +void __RPC_STUB IDXTransform_GetInOutInfo_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTransform_SetQuality_Proxy( + IDXTransform * This, + /* [in] */ float fQuality); + + +void __RPC_STUB IDXTransform_SetQuality_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTransform_GetQuality_Proxy( + IDXTransform * This, + /* [out] */ float *fQuality); + + +void __RPC_STUB IDXTransform_GetQuality_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXTransform_INTERFACE_DEFINED__ */ + + +#ifndef __IDXSurfacePick_INTERFACE_DEFINED__ +#define __IDXSurfacePick_INTERFACE_DEFINED__ + +/* interface IDXSurfacePick */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXSurfacePick; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("30A5FB79-E11F-11d1-9064-00C04FD9189D") + IDXSurfacePick : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE PointPick( + /* [in] */ const DXVEC *pPoint, + /* [out] */ ULONG *pulInputSurfaceIndex, + /* [out] */ DXVEC *pInputPoint) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXSurfacePickVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXSurfacePick * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXSurfacePick * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXSurfacePick * This); + + HRESULT ( STDMETHODCALLTYPE *PointPick )( + IDXSurfacePick * This, + /* [in] */ const DXVEC *pPoint, + /* [out] */ ULONG *pulInputSurfaceIndex, + /* [out] */ DXVEC *pInputPoint); + + END_INTERFACE + } IDXSurfacePickVtbl; + + interface IDXSurfacePick + { + CONST_VTBL struct IDXSurfacePickVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXSurfacePick_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXSurfacePick_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXSurfacePick_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXSurfacePick_PointPick(This,pPoint,pulInputSurfaceIndex,pInputPoint) \ + (This)->lpVtbl -> PointPick(This,pPoint,pulInputSurfaceIndex,pInputPoint) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXSurfacePick_PointPick_Proxy( + IDXSurfacePick * This, + /* [in] */ const DXVEC *pPoint, + /* [out] */ ULONG *pulInputSurfaceIndex, + /* [out] */ DXVEC *pInputPoint); + + +void __RPC_STUB IDXSurfacePick_PointPick_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXSurfacePick_INTERFACE_DEFINED__ */ + + +#ifndef __IDXTBindHost_INTERFACE_DEFINED__ +#define __IDXTBindHost_INTERFACE_DEFINED__ + +/* interface IDXTBindHost */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXTBindHost; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("D26BCE55-E9DC-11d1-9066-00C04FD9189D") + IDXTBindHost : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE SetBindHost( + /* [in] */ IBindHost *pBindHost) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXTBindHostVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXTBindHost * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXTBindHost * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXTBindHost * This); + + HRESULT ( STDMETHODCALLTYPE *SetBindHost )( + IDXTBindHost * This, + /* [in] */ IBindHost *pBindHost); + + END_INTERFACE + } IDXTBindHostVtbl; + + interface IDXTBindHost + { + CONST_VTBL struct IDXTBindHostVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXTBindHost_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXTBindHost_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXTBindHost_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXTBindHost_SetBindHost(This,pBindHost) \ + (This)->lpVtbl -> SetBindHost(This,pBindHost) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXTBindHost_SetBindHost_Proxy( + IDXTBindHost * This, + /* [in] */ IBindHost *pBindHost); + + +void __RPC_STUB IDXTBindHost_SetBindHost_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXTBindHost_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxtrans_0264 */ +/* [local] */ + +typedef void __stdcall __stdcall DXTASKPROC( + void *pTaskData, + BOOL *pbContinueProcessing); + +typedef DXTASKPROC *PFNDXTASKPROC; + +typedef void __stdcall __stdcall DXAPCPROC( + DWORD dwData); + +typedef DXAPCPROC *PFNDXAPCPROC; + +#ifdef __cplusplus +typedef struct DXTMTASKINFO +{ + PFNDXTASKPROC pfnTaskProc; // Pointer to function to execute + PVOID pTaskData; // Pointer to argument data + PFNDXAPCPROC pfnCompletionAPC; // Pointer to completion APC proc + DWORD dwCompletionData; // Pointer to APC proc data + const GUID* pRequestID; // Used to identify groups of tasks +} DXTMTASKINFO; +#else +typedef struct DXTMTASKINFO + { + PVOID pfnTaskProc; + PVOID pTaskData; + PVOID pfnCompletionAPC; + DWORD dwCompletionData; + const GUID *pRequestID; + } DXTMTASKINFO; + +#endif + + +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0264_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0264_v0_0_s_ifspec; + +#ifndef __IDXTaskManager_INTERFACE_DEFINED__ +#define __IDXTaskManager_INTERFACE_DEFINED__ + +/* interface IDXTaskManager */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXTaskManager; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("254DBBC1-F922-11d0-883A-3C8B00C10000") + IDXTaskManager : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE QueryNumProcessors( + /* [out] */ ULONG *pulNumProc) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetThreadPoolSize( + /* [in] */ ULONG ulNumThreads) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetThreadPoolSize( + /* [out] */ ULONG *pulNumThreads) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetConcurrencyLimit( + /* [in] */ ULONG ulNumThreads) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetConcurrencyLimit( + /* [out] */ ULONG *pulNumThreads) = 0; + + virtual HRESULT STDMETHODCALLTYPE ScheduleTasks( + /* [in] */ DXTMTASKINFO TaskInfo[ ], + /* [in] */ HANDLE Events[ ], + /* [out] */ DWORD TaskIDs[ ], + /* [in] */ ULONG ulNumTasks, + /* [in] */ ULONG ulWaitPeriod) = 0; + + virtual HRESULT STDMETHODCALLTYPE TerminateTasks( + /* [in] */ DWORD TaskIDs[ ], + /* [in] */ ULONG ulCount, + /* [in] */ ULONG ulTimeOut) = 0; + + virtual HRESULT STDMETHODCALLTYPE TerminateRequest( + /* [in] */ REFIID RequestID, + /* [in] */ ULONG ulTimeOut) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXTaskManagerVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXTaskManager * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXTaskManager * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXTaskManager * This); + + HRESULT ( STDMETHODCALLTYPE *QueryNumProcessors )( + IDXTaskManager * This, + /* [out] */ ULONG *pulNumProc); + + HRESULT ( STDMETHODCALLTYPE *SetThreadPoolSize )( + IDXTaskManager * This, + /* [in] */ ULONG ulNumThreads); + + HRESULT ( STDMETHODCALLTYPE *GetThreadPoolSize )( + IDXTaskManager * This, + /* [out] */ ULONG *pulNumThreads); + + HRESULT ( STDMETHODCALLTYPE *SetConcurrencyLimit )( + IDXTaskManager * This, + /* [in] */ ULONG ulNumThreads); + + HRESULT ( STDMETHODCALLTYPE *GetConcurrencyLimit )( + IDXTaskManager * This, + /* [out] */ ULONG *pulNumThreads); + + HRESULT ( STDMETHODCALLTYPE *ScheduleTasks )( + IDXTaskManager * This, + /* [in] */ DXTMTASKINFO TaskInfo[ ], + /* [in] */ HANDLE Events[ ], + /* [out] */ DWORD TaskIDs[ ], + /* [in] */ ULONG ulNumTasks, + /* [in] */ ULONG ulWaitPeriod); + + HRESULT ( STDMETHODCALLTYPE *TerminateTasks )( + IDXTaskManager * This, + /* [in] */ DWORD TaskIDs[ ], + /* [in] */ ULONG ulCount, + /* [in] */ ULONG ulTimeOut); + + HRESULT ( STDMETHODCALLTYPE *TerminateRequest )( + IDXTaskManager * This, + /* [in] */ REFIID RequestID, + /* [in] */ ULONG ulTimeOut); + + END_INTERFACE + } IDXTaskManagerVtbl; + + interface IDXTaskManager + { + CONST_VTBL struct IDXTaskManagerVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXTaskManager_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXTaskManager_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXTaskManager_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXTaskManager_QueryNumProcessors(This,pulNumProc) \ + (This)->lpVtbl -> QueryNumProcessors(This,pulNumProc) + +#define IDXTaskManager_SetThreadPoolSize(This,ulNumThreads) \ + (This)->lpVtbl -> SetThreadPoolSize(This,ulNumThreads) + +#define IDXTaskManager_GetThreadPoolSize(This,pulNumThreads) \ + (This)->lpVtbl -> GetThreadPoolSize(This,pulNumThreads) + +#define IDXTaskManager_SetConcurrencyLimit(This,ulNumThreads) \ + (This)->lpVtbl -> SetConcurrencyLimit(This,ulNumThreads) + +#define IDXTaskManager_GetConcurrencyLimit(This,pulNumThreads) \ + (This)->lpVtbl -> GetConcurrencyLimit(This,pulNumThreads) + +#define IDXTaskManager_ScheduleTasks(This,TaskInfo,Events,TaskIDs,ulNumTasks,ulWaitPeriod) \ + (This)->lpVtbl -> ScheduleTasks(This,TaskInfo,Events,TaskIDs,ulNumTasks,ulWaitPeriod) + +#define IDXTaskManager_TerminateTasks(This,TaskIDs,ulCount,ulTimeOut) \ + (This)->lpVtbl -> TerminateTasks(This,TaskIDs,ulCount,ulTimeOut) + +#define IDXTaskManager_TerminateRequest(This,RequestID,ulTimeOut) \ + (This)->lpVtbl -> TerminateRequest(This,RequestID,ulTimeOut) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXTaskManager_QueryNumProcessors_Proxy( + IDXTaskManager * This, + /* [out] */ ULONG *pulNumProc); + + +void __RPC_STUB IDXTaskManager_QueryNumProcessors_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTaskManager_SetThreadPoolSize_Proxy( + IDXTaskManager * This, + /* [in] */ ULONG ulNumThreads); + + +void __RPC_STUB IDXTaskManager_SetThreadPoolSize_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTaskManager_GetThreadPoolSize_Proxy( + IDXTaskManager * This, + /* [out] */ ULONG *pulNumThreads); + + +void __RPC_STUB IDXTaskManager_GetThreadPoolSize_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTaskManager_SetConcurrencyLimit_Proxy( + IDXTaskManager * This, + /* [in] */ ULONG ulNumThreads); + + +void __RPC_STUB IDXTaskManager_SetConcurrencyLimit_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTaskManager_GetConcurrencyLimit_Proxy( + IDXTaskManager * This, + /* [out] */ ULONG *pulNumThreads); + + +void __RPC_STUB IDXTaskManager_GetConcurrencyLimit_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTaskManager_ScheduleTasks_Proxy( + IDXTaskManager * This, + /* [in] */ DXTMTASKINFO TaskInfo[ ], + /* [in] */ HANDLE Events[ ], + /* [out] */ DWORD TaskIDs[ ], + /* [in] */ ULONG ulNumTasks, + /* [in] */ ULONG ulWaitPeriod); + + +void __RPC_STUB IDXTaskManager_ScheduleTasks_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTaskManager_TerminateTasks_Proxy( + IDXTaskManager * This, + /* [in] */ DWORD TaskIDs[ ], + /* [in] */ ULONG ulCount, + /* [in] */ ULONG ulTimeOut); + + +void __RPC_STUB IDXTaskManager_TerminateTasks_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTaskManager_TerminateRequest_Proxy( + IDXTaskManager * This, + /* [in] */ REFIID RequestID, + /* [in] */ ULONG ulTimeOut); + + +void __RPC_STUB IDXTaskManager_TerminateRequest_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXTaskManager_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxtrans_0265 */ +/* [local] */ + +#ifdef __cplusplus +///////////////////////////////////////////////////// + +class DXBASESAMPLE; +class DXSAMPLE; +class DXPMSAMPLE; + +///////////////////////////////////////////////////// + +class DXBASESAMPLE +{ +public: + BYTE Blue; + BYTE Green; + BYTE Red; + BYTE Alpha; + DXBASESAMPLE() {} + DXBASESAMPLE(const BYTE alpha, const BYTE red, const BYTE green, const BYTE blue) : + Alpha(alpha), + Red(red), + Green(green), + Blue(blue) {} + DXBASESAMPLE(const DWORD val) { *this = (*(DXBASESAMPLE *)&val); } + operator DWORD () const {return *((DWORD *)this); } + DWORD operator=(const DWORD val) { return *this = *((DXBASESAMPLE *)&val); } +}; // DXBASESAMPLE + +///////////////////////////////////////////////////// + +class DXSAMPLE : public DXBASESAMPLE +{ +public: + DXSAMPLE() {} + DXSAMPLE(const BYTE alpha, const BYTE red, const BYTE green, const BYTE blue) : + DXBASESAMPLE(alpha, red, green, blue) {} + DXSAMPLE(const DWORD val) { *this = (*(DXSAMPLE *)&val); } + operator DWORD () const {return *((DWORD *)this); } + DWORD operator=(const DWORD val) { return *this = *((DXSAMPLE *)&val); } + operator DXPMSAMPLE() const; +}; // DXSAMPLE + +///////////////////////////////////////////////////// + +class DXPMSAMPLE : public DXBASESAMPLE +{ +public: + DXPMSAMPLE() {} + DXPMSAMPLE(const BYTE alpha, const BYTE red, const BYTE green, const BYTE blue) : + DXBASESAMPLE(alpha, red, green, blue) {} + DXPMSAMPLE(const DWORD val) { *this = (*(DXPMSAMPLE *)&val); } + operator DWORD () const {return *((DWORD *)this); } + DWORD operator=(const DWORD val) { return *this = *((DXPMSAMPLE *)&val); } + operator DXSAMPLE() const; +}; // DXPMSAMPLE + +// +// The following cast operators are to prevent a direct assignment of a DXSAMPLE to a DXPMSAMPLE +// +inline DXSAMPLE::operator DXPMSAMPLE() const { return *((DXPMSAMPLE *)this); } +inline DXPMSAMPLE::operator DXSAMPLE() const { return *((DXSAMPLE *)this); } +#else // !__cplusplus +typedef struct DXBASESAMPLE + { + BYTE Blue; + BYTE Green; + BYTE Red; + BYTE Alpha; + } DXBASESAMPLE; + +typedef struct DXSAMPLE + { + BYTE Blue; + BYTE Green; + BYTE Red; + BYTE Alpha; + } DXSAMPLE; + +typedef struct DXPMSAMPLE + { + BYTE Blue; + BYTE Green; + BYTE Red; + BYTE Alpha; + } DXPMSAMPLE; + +#endif // !__cplusplus +typedef +enum DXRUNTYPE + { DXRUNTYPE_CLEAR = 0, + DXRUNTYPE_OPAQUE = 1, + DXRUNTYPE_TRANS = 2, + DXRUNTYPE_UNKNOWN = 3 + } DXRUNTYPE; + +#define DX_MAX_RUN_INFO_COUNT ( 128 ) + +// Ignore the definition used by MIDL for TLB generation +#if 0 +typedef struct DXRUNINFO + { + ULONG Bitfields; + } DXRUNINFO; + +#endif // 0 +typedef struct DXRUNINFO +{ + ULONG Type : 2; // Type + ULONG Count : 30; // Number of samples in run +} DXRUNINFO; +typedef +enum DXSFCREATE + { DXSF_FORMAT_IS_CLSID = 1L << 0, + DXSF_NO_LAZY_DDRAW_LOCK = 1L << 1 + } DXSFCREATE; + +typedef +enum DXBLTOPTIONS + { DXBOF_DO_OVER = 1L << 0, + DXBOF_DITHER = 1L << 1 + } DXBLTOPTIONS; + + + +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0265_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0265_v0_0_s_ifspec; + +#ifndef __IDXSurfaceFactory_INTERFACE_DEFINED__ +#define __IDXSurfaceFactory_INTERFACE_DEFINED__ + +/* interface IDXSurfaceFactory */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXSurfaceFactory; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("144946F5-C4D4-11d1-81D1-0000F87557DB") + IDXSurfaceFactory : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE CreateSurface( + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pFormatID, + /* [in] */ const DXBNDS *pBounds, + /* [in] */ DWORD dwFlags, + /* [in] */ IUnknown *punkOuter, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppDXSurface) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateFromDDSurface( + /* [in] */ IUnknown *pDDrawSurface, + /* [in] */ const GUID *pFormatID, + /* [in] */ DWORD dwFlags, + /* [in] */ IUnknown *punkOuter, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppDXSurface) = 0; + + virtual HRESULT STDMETHODCALLTYPE LoadImage( + /* [in] */ const LPWSTR pszFileName, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pFormatID, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppDXSurface) = 0; + + virtual HRESULT STDMETHODCALLTYPE LoadImageFromStream( + /* [in] */ IStream *pStream, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pFormatID, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppDXSurface) = 0; + + virtual HRESULT STDMETHODCALLTYPE CopySurfaceToNewFormat( + /* [in] */ IDXSurface *pSrc, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pDestFormatID, + /* [out] */ IDXSurface **ppNewSurface) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateD3DRMTexture( + /* [in] */ IDXSurface *pSrc, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ IUnknown *pD3DRM3, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppTexture3) = 0; + + virtual HRESULT STDMETHODCALLTYPE BitBlt( + /* [in] */ IDXSurface *pDest, + /* [in] */ const DXVEC *pPlacement, + /* [in] */ IDXSurface *pSrc, + /* [in] */ const DXBNDS *pClipBounds, + /* [in] */ DWORD dwFlags) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXSurfaceFactoryVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXSurfaceFactory * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXSurfaceFactory * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXSurfaceFactory * This); + + HRESULT ( STDMETHODCALLTYPE *CreateSurface )( + IDXSurfaceFactory * This, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pFormatID, + /* [in] */ const DXBNDS *pBounds, + /* [in] */ DWORD dwFlags, + /* [in] */ IUnknown *punkOuter, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppDXSurface); + + HRESULT ( STDMETHODCALLTYPE *CreateFromDDSurface )( + IDXSurfaceFactory * This, + /* [in] */ IUnknown *pDDrawSurface, + /* [in] */ const GUID *pFormatID, + /* [in] */ DWORD dwFlags, + /* [in] */ IUnknown *punkOuter, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppDXSurface); + + HRESULT ( STDMETHODCALLTYPE *LoadImage )( + IDXSurfaceFactory * This, + /* [in] */ const LPWSTR pszFileName, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pFormatID, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppDXSurface); + + HRESULT ( STDMETHODCALLTYPE *LoadImageFromStream )( + IDXSurfaceFactory * This, + /* [in] */ IStream *pStream, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pFormatID, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppDXSurface); + + HRESULT ( STDMETHODCALLTYPE *CopySurfaceToNewFormat )( + IDXSurfaceFactory * This, + /* [in] */ IDXSurface *pSrc, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pDestFormatID, + /* [out] */ IDXSurface **ppNewSurface); + + HRESULT ( STDMETHODCALLTYPE *CreateD3DRMTexture )( + IDXSurfaceFactory * This, + /* [in] */ IDXSurface *pSrc, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ IUnknown *pD3DRM3, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppTexture3); + + HRESULT ( STDMETHODCALLTYPE *BitBlt )( + IDXSurfaceFactory * This, + /* [in] */ IDXSurface *pDest, + /* [in] */ const DXVEC *pPlacement, + /* [in] */ IDXSurface *pSrc, + /* [in] */ const DXBNDS *pClipBounds, + /* [in] */ DWORD dwFlags); + + END_INTERFACE + } IDXSurfaceFactoryVtbl; + + interface IDXSurfaceFactory + { + CONST_VTBL struct IDXSurfaceFactoryVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXSurfaceFactory_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXSurfaceFactory_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXSurfaceFactory_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXSurfaceFactory_CreateSurface(This,pDirectDraw,pDDSurfaceDesc,pFormatID,pBounds,dwFlags,punkOuter,riid,ppDXSurface) \ + (This)->lpVtbl -> CreateSurface(This,pDirectDraw,pDDSurfaceDesc,pFormatID,pBounds,dwFlags,punkOuter,riid,ppDXSurface) + +#define IDXSurfaceFactory_CreateFromDDSurface(This,pDDrawSurface,pFormatID,dwFlags,punkOuter,riid,ppDXSurface) \ + (This)->lpVtbl -> CreateFromDDSurface(This,pDDrawSurface,pFormatID,dwFlags,punkOuter,riid,ppDXSurface) + +#define IDXSurfaceFactory_LoadImage(This,pszFileName,pDirectDraw,pDDSurfaceDesc,pFormatID,riid,ppDXSurface) \ + (This)->lpVtbl -> LoadImage(This,pszFileName,pDirectDraw,pDDSurfaceDesc,pFormatID,riid,ppDXSurface) + +#define IDXSurfaceFactory_LoadImageFromStream(This,pStream,pDirectDraw,pDDSurfaceDesc,pFormatID,riid,ppDXSurface) \ + (This)->lpVtbl -> LoadImageFromStream(This,pStream,pDirectDraw,pDDSurfaceDesc,pFormatID,riid,ppDXSurface) + +#define IDXSurfaceFactory_CopySurfaceToNewFormat(This,pSrc,pDirectDraw,pDDSurfaceDesc,pDestFormatID,ppNewSurface) \ + (This)->lpVtbl -> CopySurfaceToNewFormat(This,pSrc,pDirectDraw,pDDSurfaceDesc,pDestFormatID,ppNewSurface) + +#define IDXSurfaceFactory_CreateD3DRMTexture(This,pSrc,pDirectDraw,pD3DRM3,riid,ppTexture3) \ + (This)->lpVtbl -> CreateD3DRMTexture(This,pSrc,pDirectDraw,pD3DRM3,riid,ppTexture3) + +#define IDXSurfaceFactory_BitBlt(This,pDest,pPlacement,pSrc,pClipBounds,dwFlags) \ + (This)->lpVtbl -> BitBlt(This,pDest,pPlacement,pSrc,pClipBounds,dwFlags) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXSurfaceFactory_CreateSurface_Proxy( + IDXSurfaceFactory * This, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pFormatID, + /* [in] */ const DXBNDS *pBounds, + /* [in] */ DWORD dwFlags, + /* [in] */ IUnknown *punkOuter, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppDXSurface); + + +void __RPC_STUB IDXSurfaceFactory_CreateSurface_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceFactory_CreateFromDDSurface_Proxy( + IDXSurfaceFactory * This, + /* [in] */ IUnknown *pDDrawSurface, + /* [in] */ const GUID *pFormatID, + /* [in] */ DWORD dwFlags, + /* [in] */ IUnknown *punkOuter, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppDXSurface); + + +void __RPC_STUB IDXSurfaceFactory_CreateFromDDSurface_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceFactory_LoadImage_Proxy( + IDXSurfaceFactory * This, + /* [in] */ const LPWSTR pszFileName, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pFormatID, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppDXSurface); + + +void __RPC_STUB IDXSurfaceFactory_LoadImage_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceFactory_LoadImageFromStream_Proxy( + IDXSurfaceFactory * This, + /* [in] */ IStream *pStream, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pFormatID, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppDXSurface); + + +void __RPC_STUB IDXSurfaceFactory_LoadImageFromStream_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceFactory_CopySurfaceToNewFormat_Proxy( + IDXSurfaceFactory * This, + /* [in] */ IDXSurface *pSrc, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pDestFormatID, + /* [out] */ IDXSurface **ppNewSurface); + + +void __RPC_STUB IDXSurfaceFactory_CopySurfaceToNewFormat_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceFactory_CreateD3DRMTexture_Proxy( + IDXSurfaceFactory * This, + /* [in] */ IDXSurface *pSrc, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ IUnknown *pD3DRM3, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppTexture3); + + +void __RPC_STUB IDXSurfaceFactory_CreateD3DRMTexture_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceFactory_BitBlt_Proxy( + IDXSurfaceFactory * This, + /* [in] */ IDXSurface *pDest, + /* [in] */ const DXVEC *pPlacement, + /* [in] */ IDXSurface *pSrc, + /* [in] */ const DXBNDS *pClipBounds, + /* [in] */ DWORD dwFlags); + + +void __RPC_STUB IDXSurfaceFactory_BitBlt_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXSurfaceFactory_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxtrans_0266 */ +/* [local] */ + +typedef +enum DXSURFMODCOMPOP + { DXSURFMOD_COMP_OVER = 0, + DXSURFMOD_COMP_ALPHA_MASK = 1, + DXSURFMOD_COMP_MAX_VALID = 1 + } DXSURFMODCOMPOP; + + + +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0266_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0266_v0_0_s_ifspec; + +#ifndef __IDXSurfaceModifier_INTERFACE_DEFINED__ +#define __IDXSurfaceModifier_INTERFACE_DEFINED__ + +/* interface IDXSurfaceModifier */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXSurfaceModifier; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9EA3B637-C37D-11d1-905E-00C04FD9189D") + IDXSurfaceModifier : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE SetFillColor( + /* [in] */ DXSAMPLE Color) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetFillColor( + /* [out] */ DXSAMPLE *pColor) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetBounds( + /* [in] */ const DXBNDS *pBounds) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetBackground( + /* [in] */ IDXSurface *pSurface) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetBackground( + /* [out] */ IDXSurface **ppSurface) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetCompositeOperation( + /* [in] */ DXSURFMODCOMPOP CompOp) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetCompositeOperation( + /* [out] */ DXSURFMODCOMPOP *pCompOp) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetForeground( + /* [in] */ IDXSurface *pSurface, + /* [in] */ BOOL bTile, + /* [in] */ const POINT *pOrigin) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetForeground( + /* [out] */ IDXSurface **ppSurface, + /* [out] */ BOOL *pbTile, + /* [out] */ POINT *pOrigin) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetOpacity( + /* [in] */ float Opacity) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetOpacity( + /* [out] */ float *pOpacity) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetLookup( + /* [in] */ IDXLookupTable *pLookupTable) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetLookup( + /* [out] */ IDXLookupTable **ppLookupTable) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXSurfaceModifierVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXSurfaceModifier * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXSurfaceModifier * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXSurfaceModifier * This); + + HRESULT ( STDMETHODCALLTYPE *SetFillColor )( + IDXSurfaceModifier * This, + /* [in] */ DXSAMPLE Color); + + HRESULT ( STDMETHODCALLTYPE *GetFillColor )( + IDXSurfaceModifier * This, + /* [out] */ DXSAMPLE *pColor); + + HRESULT ( STDMETHODCALLTYPE *SetBounds )( + IDXSurfaceModifier * This, + /* [in] */ const DXBNDS *pBounds); + + HRESULT ( STDMETHODCALLTYPE *SetBackground )( + IDXSurfaceModifier * This, + /* [in] */ IDXSurface *pSurface); + + HRESULT ( STDMETHODCALLTYPE *GetBackground )( + IDXSurfaceModifier * This, + /* [out] */ IDXSurface **ppSurface); + + HRESULT ( STDMETHODCALLTYPE *SetCompositeOperation )( + IDXSurfaceModifier * This, + /* [in] */ DXSURFMODCOMPOP CompOp); + + HRESULT ( STDMETHODCALLTYPE *GetCompositeOperation )( + IDXSurfaceModifier * This, + /* [out] */ DXSURFMODCOMPOP *pCompOp); + + HRESULT ( STDMETHODCALLTYPE *SetForeground )( + IDXSurfaceModifier * This, + /* [in] */ IDXSurface *pSurface, + /* [in] */ BOOL bTile, + /* [in] */ const POINT *pOrigin); + + HRESULT ( STDMETHODCALLTYPE *GetForeground )( + IDXSurfaceModifier * This, + /* [out] */ IDXSurface **ppSurface, + /* [out] */ BOOL *pbTile, + /* [out] */ POINT *pOrigin); + + HRESULT ( STDMETHODCALLTYPE *SetOpacity )( + IDXSurfaceModifier * This, + /* [in] */ float Opacity); + + HRESULT ( STDMETHODCALLTYPE *GetOpacity )( + IDXSurfaceModifier * This, + /* [out] */ float *pOpacity); + + HRESULT ( STDMETHODCALLTYPE *SetLookup )( + IDXSurfaceModifier * This, + /* [in] */ IDXLookupTable *pLookupTable); + + HRESULT ( STDMETHODCALLTYPE *GetLookup )( + IDXSurfaceModifier * This, + /* [out] */ IDXLookupTable **ppLookupTable); + + END_INTERFACE + } IDXSurfaceModifierVtbl; + + interface IDXSurfaceModifier + { + CONST_VTBL struct IDXSurfaceModifierVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXSurfaceModifier_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXSurfaceModifier_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXSurfaceModifier_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXSurfaceModifier_SetFillColor(This,Color) \ + (This)->lpVtbl -> SetFillColor(This,Color) + +#define IDXSurfaceModifier_GetFillColor(This,pColor) \ + (This)->lpVtbl -> GetFillColor(This,pColor) + +#define IDXSurfaceModifier_SetBounds(This,pBounds) \ + (This)->lpVtbl -> SetBounds(This,pBounds) + +#define IDXSurfaceModifier_SetBackground(This,pSurface) \ + (This)->lpVtbl -> SetBackground(This,pSurface) + +#define IDXSurfaceModifier_GetBackground(This,ppSurface) \ + (This)->lpVtbl -> GetBackground(This,ppSurface) + +#define IDXSurfaceModifier_SetCompositeOperation(This,CompOp) \ + (This)->lpVtbl -> SetCompositeOperation(This,CompOp) + +#define IDXSurfaceModifier_GetCompositeOperation(This,pCompOp) \ + (This)->lpVtbl -> GetCompositeOperation(This,pCompOp) + +#define IDXSurfaceModifier_SetForeground(This,pSurface,bTile,pOrigin) \ + (This)->lpVtbl -> SetForeground(This,pSurface,bTile,pOrigin) + +#define IDXSurfaceModifier_GetForeground(This,ppSurface,pbTile,pOrigin) \ + (This)->lpVtbl -> GetForeground(This,ppSurface,pbTile,pOrigin) + +#define IDXSurfaceModifier_SetOpacity(This,Opacity) \ + (This)->lpVtbl -> SetOpacity(This,Opacity) + +#define IDXSurfaceModifier_GetOpacity(This,pOpacity) \ + (This)->lpVtbl -> GetOpacity(This,pOpacity) + +#define IDXSurfaceModifier_SetLookup(This,pLookupTable) \ + (This)->lpVtbl -> SetLookup(This,pLookupTable) + +#define IDXSurfaceModifier_GetLookup(This,ppLookupTable) \ + (This)->lpVtbl -> GetLookup(This,ppLookupTable) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_SetFillColor_Proxy( + IDXSurfaceModifier * This, + /* [in] */ DXSAMPLE Color); + + +void __RPC_STUB IDXSurfaceModifier_SetFillColor_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_GetFillColor_Proxy( + IDXSurfaceModifier * This, + /* [out] */ DXSAMPLE *pColor); + + +void __RPC_STUB IDXSurfaceModifier_GetFillColor_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_SetBounds_Proxy( + IDXSurfaceModifier * This, + /* [in] */ const DXBNDS *pBounds); + + +void __RPC_STUB IDXSurfaceModifier_SetBounds_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_SetBackground_Proxy( + IDXSurfaceModifier * This, + /* [in] */ IDXSurface *pSurface); + + +void __RPC_STUB IDXSurfaceModifier_SetBackground_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_GetBackground_Proxy( + IDXSurfaceModifier * This, + /* [out] */ IDXSurface **ppSurface); + + +void __RPC_STUB IDXSurfaceModifier_GetBackground_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_SetCompositeOperation_Proxy( + IDXSurfaceModifier * This, + /* [in] */ DXSURFMODCOMPOP CompOp); + + +void __RPC_STUB IDXSurfaceModifier_SetCompositeOperation_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_GetCompositeOperation_Proxy( + IDXSurfaceModifier * This, + /* [out] */ DXSURFMODCOMPOP *pCompOp); + + +void __RPC_STUB IDXSurfaceModifier_GetCompositeOperation_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_SetForeground_Proxy( + IDXSurfaceModifier * This, + /* [in] */ IDXSurface *pSurface, + /* [in] */ BOOL bTile, + /* [in] */ const POINT *pOrigin); + + +void __RPC_STUB IDXSurfaceModifier_SetForeground_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_GetForeground_Proxy( + IDXSurfaceModifier * This, + /* [out] */ IDXSurface **ppSurface, + /* [out] */ BOOL *pbTile, + /* [out] */ POINT *pOrigin); + + +void __RPC_STUB IDXSurfaceModifier_GetForeground_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_SetOpacity_Proxy( + IDXSurfaceModifier * This, + /* [in] */ float Opacity); + + +void __RPC_STUB IDXSurfaceModifier_SetOpacity_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_GetOpacity_Proxy( + IDXSurfaceModifier * This, + /* [out] */ float *pOpacity); + + +void __RPC_STUB IDXSurfaceModifier_GetOpacity_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_SetLookup_Proxy( + IDXSurfaceModifier * This, + /* [in] */ IDXLookupTable *pLookupTable); + + +void __RPC_STUB IDXSurfaceModifier_SetLookup_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurfaceModifier_GetLookup_Proxy( + IDXSurfaceModifier * This, + /* [out] */ IDXLookupTable **ppLookupTable); + + +void __RPC_STUB IDXSurfaceModifier_GetLookup_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXSurfaceModifier_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxtrans_0267 */ +/* [local] */ + +typedef +enum DXSAMPLEFORMATENUM + { DXPF_FLAGSMASK = 0xffff0000, + DXPF_NONPREMULT = 0x10000, + DXPF_TRANSPARENCY = 0x20000, + DXPF_TRANSLUCENCY = 0x40000, + DXPF_2BITERROR = 0x200000, + DXPF_3BITERROR = 0x300000, + DXPF_4BITERROR = 0x400000, + DXPF_5BITERROR = 0x500000, + DXPF_ERRORMASK = 0x700000, + DXPF_NONSTANDARD = 0, + DXPF_PMARGB32 = 1 | DXPF_TRANSPARENCY | DXPF_TRANSLUCENCY, + DXPF_ARGB32 = 2 | DXPF_NONPREMULT | DXPF_TRANSPARENCY | DXPF_TRANSLUCENCY, + DXPF_ARGB4444 = 3 | DXPF_NONPREMULT | DXPF_TRANSPARENCY | DXPF_TRANSLUCENCY | DXPF_4BITERROR, + DXPF_A8 = 4 | DXPF_TRANSPARENCY | DXPF_TRANSLUCENCY, + DXPF_RGB32 = 5, + DXPF_RGB24 = 6, + DXPF_RGB565 = 7 | DXPF_3BITERROR, + DXPF_RGB555 = 8 | DXPF_3BITERROR, + DXPF_RGB8 = 9 | DXPF_5BITERROR, + DXPF_ARGB1555 = 10 | DXPF_TRANSPARENCY | DXPF_3BITERROR, + DXPF_RGB32_CK = DXPF_RGB32 | DXPF_TRANSPARENCY, + DXPF_RGB24_CK = DXPF_RGB24 | DXPF_TRANSPARENCY, + DXPF_RGB555_CK = DXPF_RGB555 | DXPF_TRANSPARENCY, + DXPF_RGB565_CK = DXPF_RGB565 | DXPF_TRANSPARENCY, + DXPF_RGB8_CK = DXPF_RGB8 | DXPF_TRANSPARENCY + } DXSAMPLEFORMATENUM; + +typedef +enum DXLOCKSURF + { DXLOCKF_READ = 0, + DXLOCKF_READWRITE = 1 << 0, + DXLOCKF_EXISTINGINFOONLY = 1 << 1, + DXLOCKF_WANTRUNINFO = 1 << 2, + DXLOCKF_NONPREMULT = 1 << 16, + DXLOCKF_VALIDFLAGS = DXLOCKF_READWRITE | DXLOCKF_EXISTINGINFOONLY | DXLOCKF_WANTRUNINFO | DXLOCKF_NONPREMULT + } DXLOCKSURF; + +typedef +enum DXSURFSTATUS + { DXSURF_TRANSIENT = 1 << 0, + DXSURF_READONLY = 1 << 1, + DXSURF_VALIDFLAGS = DXSURF_TRANSIENT | DXSURF_READONLY + } DXSURFSTATUS; + + + +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0267_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0267_v0_0_s_ifspec; + +#ifndef __IDXSurface_INTERFACE_DEFINED__ +#define __IDXSurface_INTERFACE_DEFINED__ + +/* interface IDXSurface */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXSurface; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("B39FD73F-E139-11d1-9065-00C04FD9189D") + IDXSurface : public IDXBaseObject + { + public: + virtual HRESULT STDMETHODCALLTYPE GetPixelFormat( + /* [out] */ GUID *pFormatID, + /* [out] */ DXSAMPLEFORMATENUM *pSampleFormatEnum) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetBounds( + /* [out] */ DXBNDS *pBounds) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetStatusFlags( + /* [out] */ DWORD *pdwStatusFlags) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetStatusFlags( + /* [in] */ DWORD dwStatusFlags) = 0; + + virtual HRESULT STDMETHODCALLTYPE LockSurface( + /* [in] */ const DXBNDS *pBounds, + /* [in] */ ULONG ulTimeOut, + /* [in] */ DWORD dwFlags, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppPointer, + /* [out] */ ULONG *pulGenerationId) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetDirectDrawSurface( + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppSurface) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetColorKey( + DXSAMPLE *pColorKey) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetColorKey( + DXSAMPLE ColorKey) = 0; + + virtual HRESULT STDMETHODCALLTYPE LockSurfaceDC( + /* [in] */ const DXBNDS *pBounds, + /* [in] */ ULONG ulTimeOut, + /* [in] */ DWORD dwFlags, + /* [out] */ IDXDCLock **ppDCLock) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetAppData( + DWORD_PTR dwAppData) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetAppData( + DWORD_PTR *pdwAppData) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXSurfaceVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXSurface * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXSurface * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXSurface * This); + + HRESULT ( STDMETHODCALLTYPE *GetGenerationId )( + IDXSurface * This, + /* [out] */ ULONG *pID); + + HRESULT ( STDMETHODCALLTYPE *IncrementGenerationId )( + IDXSurface * This, + /* [in] */ BOOL bRefresh); + + HRESULT ( STDMETHODCALLTYPE *GetObjectSize )( + IDXSurface * This, + /* [out] */ ULONG *pcbSize); + + HRESULT ( STDMETHODCALLTYPE *GetPixelFormat )( + IDXSurface * This, + /* [out] */ GUID *pFormatID, + /* [out] */ DXSAMPLEFORMATENUM *pSampleFormatEnum); + + HRESULT ( STDMETHODCALLTYPE *GetBounds )( + IDXSurface * This, + /* [out] */ DXBNDS *pBounds); + + HRESULT ( STDMETHODCALLTYPE *GetStatusFlags )( + IDXSurface * This, + /* [out] */ DWORD *pdwStatusFlags); + + HRESULT ( STDMETHODCALLTYPE *SetStatusFlags )( + IDXSurface * This, + /* [in] */ DWORD dwStatusFlags); + + HRESULT ( STDMETHODCALLTYPE *LockSurface )( + IDXSurface * This, + /* [in] */ const DXBNDS *pBounds, + /* [in] */ ULONG ulTimeOut, + /* [in] */ DWORD dwFlags, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppPointer, + /* [out] */ ULONG *pulGenerationId); + + HRESULT ( STDMETHODCALLTYPE *GetDirectDrawSurface )( + IDXSurface * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppSurface); + + HRESULT ( STDMETHODCALLTYPE *GetColorKey )( + IDXSurface * This, + DXSAMPLE *pColorKey); + + HRESULT ( STDMETHODCALLTYPE *SetColorKey )( + IDXSurface * This, + DXSAMPLE ColorKey); + + HRESULT ( STDMETHODCALLTYPE *LockSurfaceDC )( + IDXSurface * This, + /* [in] */ const DXBNDS *pBounds, + /* [in] */ ULONG ulTimeOut, + /* [in] */ DWORD dwFlags, + /* [out] */ IDXDCLock **ppDCLock); + + HRESULT ( STDMETHODCALLTYPE *SetAppData )( + IDXSurface * This, + DWORD_PTR dwAppData); + + HRESULT ( STDMETHODCALLTYPE *GetAppData )( + IDXSurface * This, + DWORD_PTR *pdwAppData); + + END_INTERFACE + } IDXSurfaceVtbl; + + interface IDXSurface + { + CONST_VTBL struct IDXSurfaceVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXSurface_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXSurface_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXSurface_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXSurface_GetGenerationId(This,pID) \ + (This)->lpVtbl -> GetGenerationId(This,pID) + +#define IDXSurface_IncrementGenerationId(This,bRefresh) \ + (This)->lpVtbl -> IncrementGenerationId(This,bRefresh) + +#define IDXSurface_GetObjectSize(This,pcbSize) \ + (This)->lpVtbl -> GetObjectSize(This,pcbSize) + + +#define IDXSurface_GetPixelFormat(This,pFormatID,pSampleFormatEnum) \ + (This)->lpVtbl -> GetPixelFormat(This,pFormatID,pSampleFormatEnum) + +#define IDXSurface_GetBounds(This,pBounds) \ + (This)->lpVtbl -> GetBounds(This,pBounds) + +#define IDXSurface_GetStatusFlags(This,pdwStatusFlags) \ + (This)->lpVtbl -> GetStatusFlags(This,pdwStatusFlags) + +#define IDXSurface_SetStatusFlags(This,dwStatusFlags) \ + (This)->lpVtbl -> SetStatusFlags(This,dwStatusFlags) + +#define IDXSurface_LockSurface(This,pBounds,ulTimeOut,dwFlags,riid,ppPointer,pulGenerationId) \ + (This)->lpVtbl -> LockSurface(This,pBounds,ulTimeOut,dwFlags,riid,ppPointer,pulGenerationId) + +#define IDXSurface_GetDirectDrawSurface(This,riid,ppSurface) \ + (This)->lpVtbl -> GetDirectDrawSurface(This,riid,ppSurface) + +#define IDXSurface_GetColorKey(This,pColorKey) \ + (This)->lpVtbl -> GetColorKey(This,pColorKey) + +#define IDXSurface_SetColorKey(This,ColorKey) \ + (This)->lpVtbl -> SetColorKey(This,ColorKey) + +#define IDXSurface_LockSurfaceDC(This,pBounds,ulTimeOut,dwFlags,ppDCLock) \ + (This)->lpVtbl -> LockSurfaceDC(This,pBounds,ulTimeOut,dwFlags,ppDCLock) + +#define IDXSurface_SetAppData(This,dwAppData) \ + (This)->lpVtbl -> SetAppData(This,dwAppData) + +#define IDXSurface_GetAppData(This,pdwAppData) \ + (This)->lpVtbl -> GetAppData(This,pdwAppData) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXSurface_GetPixelFormat_Proxy( + IDXSurface * This, + /* [out] */ GUID *pFormatID, + /* [out] */ DXSAMPLEFORMATENUM *pSampleFormatEnum); + + +void __RPC_STUB IDXSurface_GetPixelFormat_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurface_GetBounds_Proxy( + IDXSurface * This, + /* [out] */ DXBNDS *pBounds); + + +void __RPC_STUB IDXSurface_GetBounds_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurface_GetStatusFlags_Proxy( + IDXSurface * This, + /* [out] */ DWORD *pdwStatusFlags); + + +void __RPC_STUB IDXSurface_GetStatusFlags_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurface_SetStatusFlags_Proxy( + IDXSurface * This, + /* [in] */ DWORD dwStatusFlags); + + +void __RPC_STUB IDXSurface_SetStatusFlags_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurface_LockSurface_Proxy( + IDXSurface * This, + /* [in] */ const DXBNDS *pBounds, + /* [in] */ ULONG ulTimeOut, + /* [in] */ DWORD dwFlags, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppPointer, + /* [out] */ ULONG *pulGenerationId); + + +void __RPC_STUB IDXSurface_LockSurface_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurface_GetDirectDrawSurface_Proxy( + IDXSurface * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppSurface); + + +void __RPC_STUB IDXSurface_GetDirectDrawSurface_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurface_GetColorKey_Proxy( + IDXSurface * This, + DXSAMPLE *pColorKey); + + +void __RPC_STUB IDXSurface_GetColorKey_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurface_SetColorKey_Proxy( + IDXSurface * This, + DXSAMPLE ColorKey); + + +void __RPC_STUB IDXSurface_SetColorKey_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurface_LockSurfaceDC_Proxy( + IDXSurface * This, + /* [in] */ const DXBNDS *pBounds, + /* [in] */ ULONG ulTimeOut, + /* [in] */ DWORD dwFlags, + /* [out] */ IDXDCLock **ppDCLock); + + +void __RPC_STUB IDXSurface_LockSurfaceDC_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurface_SetAppData_Proxy( + IDXSurface * This, + DWORD_PTR dwAppData); + + +void __RPC_STUB IDXSurface_SetAppData_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXSurface_GetAppData_Proxy( + IDXSurface * This, + DWORD_PTR *pdwAppData); + + +void __RPC_STUB IDXSurface_GetAppData_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXSurface_INTERFACE_DEFINED__ */ + + +#ifndef __IDXSurfaceInit_INTERFACE_DEFINED__ +#define __IDXSurfaceInit_INTERFACE_DEFINED__ + +/* interface IDXSurfaceInit */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXSurfaceInit; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9EA3B639-C37D-11d1-905E-00C04FD9189D") + IDXSurfaceInit : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE InitSurface( + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pFormatID, + /* [in] */ const DXBNDS *pBounds, + /* [in] */ DWORD dwFlags) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXSurfaceInitVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXSurfaceInit * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXSurfaceInit * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXSurfaceInit * This); + + HRESULT ( STDMETHODCALLTYPE *InitSurface )( + IDXSurfaceInit * This, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pFormatID, + /* [in] */ const DXBNDS *pBounds, + /* [in] */ DWORD dwFlags); + + END_INTERFACE + } IDXSurfaceInitVtbl; + + interface IDXSurfaceInit + { + CONST_VTBL struct IDXSurfaceInitVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXSurfaceInit_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXSurfaceInit_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXSurfaceInit_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXSurfaceInit_InitSurface(This,pDirectDraw,pDDSurfaceDesc,pFormatID,pBounds,dwFlags) \ + (This)->lpVtbl -> InitSurface(This,pDirectDraw,pDDSurfaceDesc,pFormatID,pBounds,dwFlags) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXSurfaceInit_InitSurface_Proxy( + IDXSurfaceInit * This, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pFormatID, + /* [in] */ const DXBNDS *pBounds, + /* [in] */ DWORD dwFlags); + + +void __RPC_STUB IDXSurfaceInit_InitSurface_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXSurfaceInit_INTERFACE_DEFINED__ */ + + +#ifndef __IDXARGBSurfaceInit_INTERFACE_DEFINED__ +#define __IDXARGBSurfaceInit_INTERFACE_DEFINED__ + +/* interface IDXARGBSurfaceInit */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXARGBSurfaceInit; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9EA3B63A-C37D-11d1-905E-00C04FD9189D") + IDXARGBSurfaceInit : public IDXSurfaceInit + { + public: + virtual HRESULT STDMETHODCALLTYPE InitFromDDSurface( + /* [in] */ IUnknown *pDDrawSurface, + /* [in] */ const GUID *pFormatID, + /* [in] */ DWORD dwFlags) = 0; + + virtual HRESULT STDMETHODCALLTYPE InitFromRawSurface( + /* [in] */ IDXRawSurface *pRawSurface) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXARGBSurfaceInitVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXARGBSurfaceInit * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXARGBSurfaceInit * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXARGBSurfaceInit * This); + + HRESULT ( STDMETHODCALLTYPE *InitSurface )( + IDXARGBSurfaceInit * This, + /* [in] */ IUnknown *pDirectDraw, + /* [in] */ const DDSURFACEDESC *pDDSurfaceDesc, + /* [in] */ const GUID *pFormatID, + /* [in] */ const DXBNDS *pBounds, + /* [in] */ DWORD dwFlags); + + HRESULT ( STDMETHODCALLTYPE *InitFromDDSurface )( + IDXARGBSurfaceInit * This, + /* [in] */ IUnknown *pDDrawSurface, + /* [in] */ const GUID *pFormatID, + /* [in] */ DWORD dwFlags); + + HRESULT ( STDMETHODCALLTYPE *InitFromRawSurface )( + IDXARGBSurfaceInit * This, + /* [in] */ IDXRawSurface *pRawSurface); + + END_INTERFACE + } IDXARGBSurfaceInitVtbl; + + interface IDXARGBSurfaceInit + { + CONST_VTBL struct IDXARGBSurfaceInitVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXARGBSurfaceInit_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXARGBSurfaceInit_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXARGBSurfaceInit_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXARGBSurfaceInit_InitSurface(This,pDirectDraw,pDDSurfaceDesc,pFormatID,pBounds,dwFlags) \ + (This)->lpVtbl -> InitSurface(This,pDirectDraw,pDDSurfaceDesc,pFormatID,pBounds,dwFlags) + + +#define IDXARGBSurfaceInit_InitFromDDSurface(This,pDDrawSurface,pFormatID,dwFlags) \ + (This)->lpVtbl -> InitFromDDSurface(This,pDDrawSurface,pFormatID,dwFlags) + +#define IDXARGBSurfaceInit_InitFromRawSurface(This,pRawSurface) \ + (This)->lpVtbl -> InitFromRawSurface(This,pRawSurface) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXARGBSurfaceInit_InitFromDDSurface_Proxy( + IDXARGBSurfaceInit * This, + /* [in] */ IUnknown *pDDrawSurface, + /* [in] */ const GUID *pFormatID, + /* [in] */ DWORD dwFlags); + + +void __RPC_STUB IDXARGBSurfaceInit_InitFromDDSurface_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXARGBSurfaceInit_InitFromRawSurface_Proxy( + IDXARGBSurfaceInit * This, + /* [in] */ IDXRawSurface *pRawSurface); + + +void __RPC_STUB IDXARGBSurfaceInit_InitFromRawSurface_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXARGBSurfaceInit_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxtrans_0270 */ +/* [local] */ + +typedef struct tagDXNATIVETYPEINFO + { + BYTE *pCurrentData; + BYTE *pFirstByte; + long lPitch; + DWORD dwColorKey; + } DXNATIVETYPEINFO; + +typedef struct tagDXPACKEDRECTDESC + { + DXBASESAMPLE *pSamples; + BOOL bPremult; + RECT rect; + long lRowPadding; + } DXPACKEDRECTDESC; + +typedef struct tagDXOVERSAMPLEDESC + { + POINT p; + DXPMSAMPLE Color; + } DXOVERSAMPLEDESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0270_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0270_v0_0_s_ifspec; + +#ifndef __IDXARGBReadPtr_INTERFACE_DEFINED__ +#define __IDXARGBReadPtr_INTERFACE_DEFINED__ + +/* interface IDXARGBReadPtr */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXARGBReadPtr; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("EAAAC2D6-C290-11d1-905D-00C04FD9189D") + IDXARGBReadPtr : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE GetSurface( + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppSurface) = 0; + + virtual DXSAMPLEFORMATENUM STDMETHODCALLTYPE GetNativeType( + /* [out] */ DXNATIVETYPEINFO *pInfo) = 0; + + virtual void STDMETHODCALLTYPE Move( + /* [in] */ long cSamples) = 0; + + virtual void STDMETHODCALLTYPE MoveToRow( + /* [in] */ ULONG y) = 0; + + virtual void STDMETHODCALLTYPE MoveToXY( + /* [in] */ ULONG x, + /* [in] */ ULONG y) = 0; + + virtual ULONG STDMETHODCALLTYPE MoveAndGetRunInfo( + /* [in] */ ULONG Row, + /* [out] */ const DXRUNINFO **ppInfo) = 0; + + virtual DXSAMPLE *STDMETHODCALLTYPE Unpack( + /* [in] */ DXSAMPLE *pSamples, + /* [in] */ ULONG cSamples, + /* [in] */ BOOL bMove) = 0; + + virtual DXPMSAMPLE *STDMETHODCALLTYPE UnpackPremult( + /* [in] */ DXPMSAMPLE *pSamples, + /* [in] */ ULONG cSamples, + /* [in] */ BOOL bMove) = 0; + + virtual void STDMETHODCALLTYPE UnpackRect( + /* [in] */ const DXPACKEDRECTDESC *pRectDesc) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXARGBReadPtrVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXARGBReadPtr * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXARGBReadPtr * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXARGBReadPtr * This); + + HRESULT ( STDMETHODCALLTYPE *GetSurface )( + IDXARGBReadPtr * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppSurface); + + DXSAMPLEFORMATENUM ( STDMETHODCALLTYPE *GetNativeType )( + IDXARGBReadPtr * This, + /* [out] */ DXNATIVETYPEINFO *pInfo); + + void ( STDMETHODCALLTYPE *Move )( + IDXARGBReadPtr * This, + /* [in] */ long cSamples); + + void ( STDMETHODCALLTYPE *MoveToRow )( + IDXARGBReadPtr * This, + /* [in] */ ULONG y); + + void ( STDMETHODCALLTYPE *MoveToXY )( + IDXARGBReadPtr * This, + /* [in] */ ULONG x, + /* [in] */ ULONG y); + + ULONG ( STDMETHODCALLTYPE *MoveAndGetRunInfo )( + IDXARGBReadPtr * This, + /* [in] */ ULONG Row, + /* [out] */ const DXRUNINFO **ppInfo); + + DXSAMPLE *( STDMETHODCALLTYPE *Unpack )( + IDXARGBReadPtr * This, + /* [in] */ DXSAMPLE *pSamples, + /* [in] */ ULONG cSamples, + /* [in] */ BOOL bMove); + + DXPMSAMPLE *( STDMETHODCALLTYPE *UnpackPremult )( + IDXARGBReadPtr * This, + /* [in] */ DXPMSAMPLE *pSamples, + /* [in] */ ULONG cSamples, + /* [in] */ BOOL bMove); + + void ( STDMETHODCALLTYPE *UnpackRect )( + IDXARGBReadPtr * This, + /* [in] */ const DXPACKEDRECTDESC *pRectDesc); + + END_INTERFACE + } IDXARGBReadPtrVtbl; + + interface IDXARGBReadPtr + { + CONST_VTBL struct IDXARGBReadPtrVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXARGBReadPtr_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXARGBReadPtr_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXARGBReadPtr_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXARGBReadPtr_GetSurface(This,riid,ppSurface) \ + (This)->lpVtbl -> GetSurface(This,riid,ppSurface) + +#define IDXARGBReadPtr_GetNativeType(This,pInfo) \ + (This)->lpVtbl -> GetNativeType(This,pInfo) + +#define IDXARGBReadPtr_Move(This,cSamples) \ + (This)->lpVtbl -> Move(This,cSamples) + +#define IDXARGBReadPtr_MoveToRow(This,y) \ + (This)->lpVtbl -> MoveToRow(This,y) + +#define IDXARGBReadPtr_MoveToXY(This,x,y) \ + (This)->lpVtbl -> MoveToXY(This,x,y) + +#define IDXARGBReadPtr_MoveAndGetRunInfo(This,Row,ppInfo) \ + (This)->lpVtbl -> MoveAndGetRunInfo(This,Row,ppInfo) + +#define IDXARGBReadPtr_Unpack(This,pSamples,cSamples,bMove) \ + (This)->lpVtbl -> Unpack(This,pSamples,cSamples,bMove) + +#define IDXARGBReadPtr_UnpackPremult(This,pSamples,cSamples,bMove) \ + (This)->lpVtbl -> UnpackPremult(This,pSamples,cSamples,bMove) + +#define IDXARGBReadPtr_UnpackRect(This,pRectDesc) \ + (This)->lpVtbl -> UnpackRect(This,pRectDesc) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXARGBReadPtr_GetSurface_Proxy( + IDXARGBReadPtr * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppSurface); + + +void __RPC_STUB IDXARGBReadPtr_GetSurface_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +DXSAMPLEFORMATENUM STDMETHODCALLTYPE IDXARGBReadPtr_GetNativeType_Proxy( + IDXARGBReadPtr * This, + /* [out] */ DXNATIVETYPEINFO *pInfo); + + +void __RPC_STUB IDXARGBReadPtr_GetNativeType_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +void STDMETHODCALLTYPE IDXARGBReadPtr_Move_Proxy( + IDXARGBReadPtr * This, + /* [in] */ long cSamples); + + +void __RPC_STUB IDXARGBReadPtr_Move_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +void STDMETHODCALLTYPE IDXARGBReadPtr_MoveToRow_Proxy( + IDXARGBReadPtr * This, + /* [in] */ ULONG y); + + +void __RPC_STUB IDXARGBReadPtr_MoveToRow_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +void STDMETHODCALLTYPE IDXARGBReadPtr_MoveToXY_Proxy( + IDXARGBReadPtr * This, + /* [in] */ ULONG x, + /* [in] */ ULONG y); + + +void __RPC_STUB IDXARGBReadPtr_MoveToXY_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +ULONG STDMETHODCALLTYPE IDXARGBReadPtr_MoveAndGetRunInfo_Proxy( + IDXARGBReadPtr * This, + /* [in] */ ULONG Row, + /* [out] */ const DXRUNINFO **ppInfo); + + +void __RPC_STUB IDXARGBReadPtr_MoveAndGetRunInfo_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +DXSAMPLE *STDMETHODCALLTYPE IDXARGBReadPtr_Unpack_Proxy( + IDXARGBReadPtr * This, + /* [in] */ DXSAMPLE *pSamples, + /* [in] */ ULONG cSamples, + /* [in] */ BOOL bMove); + + +void __RPC_STUB IDXARGBReadPtr_Unpack_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +DXPMSAMPLE *STDMETHODCALLTYPE IDXARGBReadPtr_UnpackPremult_Proxy( + IDXARGBReadPtr * This, + /* [in] */ DXPMSAMPLE *pSamples, + /* [in] */ ULONG cSamples, + /* [in] */ BOOL bMove); + + +void __RPC_STUB IDXARGBReadPtr_UnpackPremult_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +void STDMETHODCALLTYPE IDXARGBReadPtr_UnpackRect_Proxy( + IDXARGBReadPtr * This, + /* [in] */ const DXPACKEDRECTDESC *pRectDesc); + + +void __RPC_STUB IDXARGBReadPtr_UnpackRect_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXARGBReadPtr_INTERFACE_DEFINED__ */ + + +#ifndef __IDXARGBReadWritePtr_INTERFACE_DEFINED__ +#define __IDXARGBReadWritePtr_INTERFACE_DEFINED__ + +/* interface IDXARGBReadWritePtr */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXARGBReadWritePtr; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("EAAAC2D7-C290-11d1-905D-00C04FD9189D") + IDXARGBReadWritePtr : public IDXARGBReadPtr + { + public: + virtual void STDMETHODCALLTYPE PackAndMove( + /* [in] */ const DXSAMPLE *pSamples, + /* [in] */ ULONG cSamples) = 0; + + virtual void STDMETHODCALLTYPE PackPremultAndMove( + /* [in] */ const DXPMSAMPLE *pSamples, + /* [in] */ ULONG cSamples) = 0; + + virtual void STDMETHODCALLTYPE PackRect( + /* [in] */ const DXPACKEDRECTDESC *pRectDesc) = 0; + + virtual void STDMETHODCALLTYPE CopyAndMoveBoth( + /* [in] */ DXBASESAMPLE *pScratchBuffer, + /* [in] */ IDXARGBReadPtr *pSrc, + /* [in] */ ULONG cSamples, + /* [in] */ BOOL bIsOpaque) = 0; + + virtual void STDMETHODCALLTYPE CopyRect( + /* [in] */ DXBASESAMPLE *pScratchBuffer, + /* [in] */ const RECT *pDestRect, + /* [in] */ IDXARGBReadPtr *pSrc, + /* [in] */ const POINT *pSrcOrigin, + /* [in] */ BOOL bIsOpaque) = 0; + + virtual void STDMETHODCALLTYPE FillAndMove( + /* [in] */ DXBASESAMPLE *pScratchBuffer, + /* [in] */ DXPMSAMPLE SampVal, + /* [in] */ ULONG cSamples, + /* [in] */ BOOL bDoOver) = 0; + + virtual void STDMETHODCALLTYPE FillRect( + /* [in] */ const RECT *pRect, + /* [in] */ DXPMSAMPLE SampVal, + /* [in] */ BOOL bDoOver) = 0; + + virtual void STDMETHODCALLTYPE OverSample( + /* [in] */ const DXOVERSAMPLEDESC *pOverDesc) = 0; + + virtual void STDMETHODCALLTYPE OverArrayAndMove( + /* [in] */ DXBASESAMPLE *pScratchBuffer, + /* [in] */ const DXPMSAMPLE *pSrc, + /* [in] */ ULONG cSamples) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXARGBReadWritePtrVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXARGBReadWritePtr * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXARGBReadWritePtr * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXARGBReadWritePtr * This); + + HRESULT ( STDMETHODCALLTYPE *GetSurface )( + IDXARGBReadWritePtr * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppSurface); + + DXSAMPLEFORMATENUM ( STDMETHODCALLTYPE *GetNativeType )( + IDXARGBReadWritePtr * This, + /* [out] */ DXNATIVETYPEINFO *pInfo); + + void ( STDMETHODCALLTYPE *Move )( + IDXARGBReadWritePtr * This, + /* [in] */ long cSamples); + + void ( STDMETHODCALLTYPE *MoveToRow )( + IDXARGBReadWritePtr * This, + /* [in] */ ULONG y); + + void ( STDMETHODCALLTYPE *MoveToXY )( + IDXARGBReadWritePtr * This, + /* [in] */ ULONG x, + /* [in] */ ULONG y); + + ULONG ( STDMETHODCALLTYPE *MoveAndGetRunInfo )( + IDXARGBReadWritePtr * This, + /* [in] */ ULONG Row, + /* [out] */ const DXRUNINFO **ppInfo); + + DXSAMPLE *( STDMETHODCALLTYPE *Unpack )( + IDXARGBReadWritePtr * This, + /* [in] */ DXSAMPLE *pSamples, + /* [in] */ ULONG cSamples, + /* [in] */ BOOL bMove); + + DXPMSAMPLE *( STDMETHODCALLTYPE *UnpackPremult )( + IDXARGBReadWritePtr * This, + /* [in] */ DXPMSAMPLE *pSamples, + /* [in] */ ULONG cSamples, + /* [in] */ BOOL bMove); + + void ( STDMETHODCALLTYPE *UnpackRect )( + IDXARGBReadWritePtr * This, + /* [in] */ const DXPACKEDRECTDESC *pRectDesc); + + void ( STDMETHODCALLTYPE *PackAndMove )( + IDXARGBReadWritePtr * This, + /* [in] */ const DXSAMPLE *pSamples, + /* [in] */ ULONG cSamples); + + void ( STDMETHODCALLTYPE *PackPremultAndMove )( + IDXARGBReadWritePtr * This, + /* [in] */ const DXPMSAMPLE *pSamples, + /* [in] */ ULONG cSamples); + + void ( STDMETHODCALLTYPE *PackRect )( + IDXARGBReadWritePtr * This, + /* [in] */ const DXPACKEDRECTDESC *pRectDesc); + + void ( STDMETHODCALLTYPE *CopyAndMoveBoth )( + IDXARGBReadWritePtr * This, + /* [in] */ DXBASESAMPLE *pScratchBuffer, + /* [in] */ IDXARGBReadPtr *pSrc, + /* [in] */ ULONG cSamples, + /* [in] */ BOOL bIsOpaque); + + void ( STDMETHODCALLTYPE *CopyRect )( + IDXARGBReadWritePtr * This, + /* [in] */ DXBASESAMPLE *pScratchBuffer, + /* [in] */ const RECT *pDestRect, + /* [in] */ IDXARGBReadPtr *pSrc, + /* [in] */ const POINT *pSrcOrigin, + /* [in] */ BOOL bIsOpaque); + + void ( STDMETHODCALLTYPE *FillAndMove )( + IDXARGBReadWritePtr * This, + /* [in] */ DXBASESAMPLE *pScratchBuffer, + /* [in] */ DXPMSAMPLE SampVal, + /* [in] */ ULONG cSamples, + /* [in] */ BOOL bDoOver); + + void ( STDMETHODCALLTYPE *FillRect )( + IDXARGBReadWritePtr * This, + /* [in] */ const RECT *pRect, + /* [in] */ DXPMSAMPLE SampVal, + /* [in] */ BOOL bDoOver); + + void ( STDMETHODCALLTYPE *OverSample )( + IDXARGBReadWritePtr * This, + /* [in] */ const DXOVERSAMPLEDESC *pOverDesc); + + void ( STDMETHODCALLTYPE *OverArrayAndMove )( + IDXARGBReadWritePtr * This, + /* [in] */ DXBASESAMPLE *pScratchBuffer, + /* [in] */ const DXPMSAMPLE *pSrc, + /* [in] */ ULONG cSamples); + + END_INTERFACE + } IDXARGBReadWritePtrVtbl; + + interface IDXARGBReadWritePtr + { + CONST_VTBL struct IDXARGBReadWritePtrVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXARGBReadWritePtr_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXARGBReadWritePtr_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXARGBReadWritePtr_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXARGBReadWritePtr_GetSurface(This,riid,ppSurface) \ + (This)->lpVtbl -> GetSurface(This,riid,ppSurface) + +#define IDXARGBReadWritePtr_GetNativeType(This,pInfo) \ + (This)->lpVtbl -> GetNativeType(This,pInfo) + +#define IDXARGBReadWritePtr_Move(This,cSamples) \ + (This)->lpVtbl -> Move(This,cSamples) + +#define IDXARGBReadWritePtr_MoveToRow(This,y) \ + (This)->lpVtbl -> MoveToRow(This,y) + +#define IDXARGBReadWritePtr_MoveToXY(This,x,y) \ + (This)->lpVtbl -> MoveToXY(This,x,y) + +#define IDXARGBReadWritePtr_MoveAndGetRunInfo(This,Row,ppInfo) \ + (This)->lpVtbl -> MoveAndGetRunInfo(This,Row,ppInfo) + +#define IDXARGBReadWritePtr_Unpack(This,pSamples,cSamples,bMove) \ + (This)->lpVtbl -> Unpack(This,pSamples,cSamples,bMove) + +#define IDXARGBReadWritePtr_UnpackPremult(This,pSamples,cSamples,bMove) \ + (This)->lpVtbl -> UnpackPremult(This,pSamples,cSamples,bMove) + +#define IDXARGBReadWritePtr_UnpackRect(This,pRectDesc) \ + (This)->lpVtbl -> UnpackRect(This,pRectDesc) + + +#define IDXARGBReadWritePtr_PackAndMove(This,pSamples,cSamples) \ + (This)->lpVtbl -> PackAndMove(This,pSamples,cSamples) + +#define IDXARGBReadWritePtr_PackPremultAndMove(This,pSamples,cSamples) \ + (This)->lpVtbl -> PackPremultAndMove(This,pSamples,cSamples) + +#define IDXARGBReadWritePtr_PackRect(This,pRectDesc) \ + (This)->lpVtbl -> PackRect(This,pRectDesc) + +#define IDXARGBReadWritePtr_CopyAndMoveBoth(This,pScratchBuffer,pSrc,cSamples,bIsOpaque) \ + (This)->lpVtbl -> CopyAndMoveBoth(This,pScratchBuffer,pSrc,cSamples,bIsOpaque) + +#define IDXARGBReadWritePtr_CopyRect(This,pScratchBuffer,pDestRect,pSrc,pSrcOrigin,bIsOpaque) \ + (This)->lpVtbl -> CopyRect(This,pScratchBuffer,pDestRect,pSrc,pSrcOrigin,bIsOpaque) + +#define IDXARGBReadWritePtr_FillAndMove(This,pScratchBuffer,SampVal,cSamples,bDoOver) \ + (This)->lpVtbl -> FillAndMove(This,pScratchBuffer,SampVal,cSamples,bDoOver) + +#define IDXARGBReadWritePtr_FillRect(This,pRect,SampVal,bDoOver) \ + (This)->lpVtbl -> FillRect(This,pRect,SampVal,bDoOver) + +#define IDXARGBReadWritePtr_OverSample(This,pOverDesc) \ + (This)->lpVtbl -> OverSample(This,pOverDesc) + +#define IDXARGBReadWritePtr_OverArrayAndMove(This,pScratchBuffer,pSrc,cSamples) \ + (This)->lpVtbl -> OverArrayAndMove(This,pScratchBuffer,pSrc,cSamples) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +void STDMETHODCALLTYPE IDXARGBReadWritePtr_PackAndMove_Proxy( + IDXARGBReadWritePtr * This, + /* [in] */ const DXSAMPLE *pSamples, + /* [in] */ ULONG cSamples); + + +void __RPC_STUB IDXARGBReadWritePtr_PackAndMove_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +void STDMETHODCALLTYPE IDXARGBReadWritePtr_PackPremultAndMove_Proxy( + IDXARGBReadWritePtr * This, + /* [in] */ const DXPMSAMPLE *pSamples, + /* [in] */ ULONG cSamples); + + +void __RPC_STUB IDXARGBReadWritePtr_PackPremultAndMove_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +void STDMETHODCALLTYPE IDXARGBReadWritePtr_PackRect_Proxy( + IDXARGBReadWritePtr * This, + /* [in] */ const DXPACKEDRECTDESC *pRectDesc); + + +void __RPC_STUB IDXARGBReadWritePtr_PackRect_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +void STDMETHODCALLTYPE IDXARGBReadWritePtr_CopyAndMoveBoth_Proxy( + IDXARGBReadWritePtr * This, + /* [in] */ DXBASESAMPLE *pScratchBuffer, + /* [in] */ IDXARGBReadPtr *pSrc, + /* [in] */ ULONG cSamples, + /* [in] */ BOOL bIsOpaque); + + +void __RPC_STUB IDXARGBReadWritePtr_CopyAndMoveBoth_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +void STDMETHODCALLTYPE IDXARGBReadWritePtr_CopyRect_Proxy( + IDXARGBReadWritePtr * This, + /* [in] */ DXBASESAMPLE *pScratchBuffer, + /* [in] */ const RECT *pDestRect, + /* [in] */ IDXARGBReadPtr *pSrc, + /* [in] */ const POINT *pSrcOrigin, + /* [in] */ BOOL bIsOpaque); + + +void __RPC_STUB IDXARGBReadWritePtr_CopyRect_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +void STDMETHODCALLTYPE IDXARGBReadWritePtr_FillAndMove_Proxy( + IDXARGBReadWritePtr * This, + /* [in] */ DXBASESAMPLE *pScratchBuffer, + /* [in] */ DXPMSAMPLE SampVal, + /* [in] */ ULONG cSamples, + /* [in] */ BOOL bDoOver); + + +void __RPC_STUB IDXARGBReadWritePtr_FillAndMove_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +void STDMETHODCALLTYPE IDXARGBReadWritePtr_FillRect_Proxy( + IDXARGBReadWritePtr * This, + /* [in] */ const RECT *pRect, + /* [in] */ DXPMSAMPLE SampVal, + /* [in] */ BOOL bDoOver); + + +void __RPC_STUB IDXARGBReadWritePtr_FillRect_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +void STDMETHODCALLTYPE IDXARGBReadWritePtr_OverSample_Proxy( + IDXARGBReadWritePtr * This, + /* [in] */ const DXOVERSAMPLEDESC *pOverDesc); + + +void __RPC_STUB IDXARGBReadWritePtr_OverSample_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +void STDMETHODCALLTYPE IDXARGBReadWritePtr_OverArrayAndMove_Proxy( + IDXARGBReadWritePtr * This, + /* [in] */ DXBASESAMPLE *pScratchBuffer, + /* [in] */ const DXPMSAMPLE *pSrc, + /* [in] */ ULONG cSamples); + + +void __RPC_STUB IDXARGBReadWritePtr_OverArrayAndMove_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXARGBReadWritePtr_INTERFACE_DEFINED__ */ + + +#ifndef __IDXDCLock_INTERFACE_DEFINED__ +#define __IDXDCLock_INTERFACE_DEFINED__ + +/* interface IDXDCLock */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXDCLock; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("0F619456-CF39-11d1-905E-00C04FD9189D") + IDXDCLock : public IUnknown + { + public: + virtual HDC STDMETHODCALLTYPE GetDC( void) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXDCLockVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXDCLock * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXDCLock * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXDCLock * This); + + HDC ( STDMETHODCALLTYPE *GetDC )( + IDXDCLock * This); + + END_INTERFACE + } IDXDCLockVtbl; + + interface IDXDCLock + { + CONST_VTBL struct IDXDCLockVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXDCLock_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXDCLock_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXDCLock_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXDCLock_GetDC(This) \ + (This)->lpVtbl -> GetDC(This) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HDC STDMETHODCALLTYPE IDXDCLock_GetDC_Proxy( + IDXDCLock * This); + + +void __RPC_STUB IDXDCLock_GetDC_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXDCLock_INTERFACE_DEFINED__ */ + + +#ifndef __IDXTScaleOutput_INTERFACE_DEFINED__ +#define __IDXTScaleOutput_INTERFACE_DEFINED__ + +/* interface IDXTScaleOutput */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXTScaleOutput; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("B2024B50-EE77-11d1-9066-00C04FD9189D") + IDXTScaleOutput : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE SetOutputSize( + /* [in] */ const SIZE OutSize, + /* [in] */ BOOL bMaintainAspect) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXTScaleOutputVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXTScaleOutput * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXTScaleOutput * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXTScaleOutput * This); + + HRESULT ( STDMETHODCALLTYPE *SetOutputSize )( + IDXTScaleOutput * This, + /* [in] */ const SIZE OutSize, + /* [in] */ BOOL bMaintainAspect); + + END_INTERFACE + } IDXTScaleOutputVtbl; + + interface IDXTScaleOutput + { + CONST_VTBL struct IDXTScaleOutputVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXTScaleOutput_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXTScaleOutput_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXTScaleOutput_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXTScaleOutput_SetOutputSize(This,OutSize,bMaintainAspect) \ + (This)->lpVtbl -> SetOutputSize(This,OutSize,bMaintainAspect) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXTScaleOutput_SetOutputSize_Proxy( + IDXTScaleOutput * This, + /* [in] */ const SIZE OutSize, + /* [in] */ BOOL bMaintainAspect); + + +void __RPC_STUB IDXTScaleOutput_SetOutputSize_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXTScaleOutput_INTERFACE_DEFINED__ */ + + +#ifndef __IDXGradient_INTERFACE_DEFINED__ +#define __IDXGradient_INTERFACE_DEFINED__ + +/* interface IDXGradient */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXGradient; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("B2024B51-EE77-11d1-9066-00C04FD9189D") + IDXGradient : public IDXTScaleOutput + { + public: + virtual HRESULT STDMETHODCALLTYPE SetGradient( + DXSAMPLE StartColor, + DXSAMPLE EndColor, + BOOL bHorizontal) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetOutputSize( + /* [out] */ SIZE *pOutSize) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXGradientVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXGradient * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXGradient * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXGradient * This); + + HRESULT ( STDMETHODCALLTYPE *SetOutputSize )( + IDXGradient * This, + /* [in] */ const SIZE OutSize, + /* [in] */ BOOL bMaintainAspect); + + HRESULT ( STDMETHODCALLTYPE *SetGradient )( + IDXGradient * This, + DXSAMPLE StartColor, + DXSAMPLE EndColor, + BOOL bHorizontal); + + HRESULT ( STDMETHODCALLTYPE *GetOutputSize )( + IDXGradient * This, + /* [out] */ SIZE *pOutSize); + + END_INTERFACE + } IDXGradientVtbl; + + interface IDXGradient + { + CONST_VTBL struct IDXGradientVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXGradient_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXGradient_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXGradient_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXGradient_SetOutputSize(This,OutSize,bMaintainAspect) \ + (This)->lpVtbl -> SetOutputSize(This,OutSize,bMaintainAspect) + + +#define IDXGradient_SetGradient(This,StartColor,EndColor,bHorizontal) \ + (This)->lpVtbl -> SetGradient(This,StartColor,EndColor,bHorizontal) + +#define IDXGradient_GetOutputSize(This,pOutSize) \ + (This)->lpVtbl -> GetOutputSize(This,pOutSize) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXGradient_SetGradient_Proxy( + IDXGradient * This, + DXSAMPLE StartColor, + DXSAMPLE EndColor, + BOOL bHorizontal); + + +void __RPC_STUB IDXGradient_SetGradient_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXGradient_GetOutputSize_Proxy( + IDXGradient * This, + /* [out] */ SIZE *pOutSize); + + +void __RPC_STUB IDXGradient_GetOutputSize_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXGradient_INTERFACE_DEFINED__ */ + + +#ifndef __IDXTScale_INTERFACE_DEFINED__ +#define __IDXTScale_INTERFACE_DEFINED__ + +/* interface IDXTScale */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXTScale; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("B39FD742-E139-11d1-9065-00C04FD9189D") + IDXTScale : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE SetScales( + /* [in] */ float Scales[ 2 ]) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetScales( + /* [out] */ float Scales[ 2 ]) = 0; + + virtual HRESULT STDMETHODCALLTYPE ScaleFitToSize( + /* [out][in] */ DXBNDS *pClipBounds, + /* [in] */ SIZE FitToSize, + /* [in] */ BOOL bMaintainAspect) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXTScaleVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXTScale * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXTScale * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXTScale * This); + + HRESULT ( STDMETHODCALLTYPE *SetScales )( + IDXTScale * This, + /* [in] */ float Scales[ 2 ]); + + HRESULT ( STDMETHODCALLTYPE *GetScales )( + IDXTScale * This, + /* [out] */ float Scales[ 2 ]); + + HRESULT ( STDMETHODCALLTYPE *ScaleFitToSize )( + IDXTScale * This, + /* [out][in] */ DXBNDS *pClipBounds, + /* [in] */ SIZE FitToSize, + /* [in] */ BOOL bMaintainAspect); + + END_INTERFACE + } IDXTScaleVtbl; + + interface IDXTScale + { + CONST_VTBL struct IDXTScaleVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXTScale_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXTScale_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXTScale_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXTScale_SetScales(This,Scales) \ + (This)->lpVtbl -> SetScales(This,Scales) + +#define IDXTScale_GetScales(This,Scales) \ + (This)->lpVtbl -> GetScales(This,Scales) + +#define IDXTScale_ScaleFitToSize(This,pClipBounds,FitToSize,bMaintainAspect) \ + (This)->lpVtbl -> ScaleFitToSize(This,pClipBounds,FitToSize,bMaintainAspect) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXTScale_SetScales_Proxy( + IDXTScale * This, + /* [in] */ float Scales[ 2 ]); + + +void __RPC_STUB IDXTScale_SetScales_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTScale_GetScales_Proxy( + IDXTScale * This, + /* [out] */ float Scales[ 2 ]); + + +void __RPC_STUB IDXTScale_GetScales_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXTScale_ScaleFitToSize_Proxy( + IDXTScale * This, + /* [out][in] */ DXBNDS *pClipBounds, + /* [in] */ SIZE FitToSize, + /* [in] */ BOOL bMaintainAspect); + + +void __RPC_STUB IDXTScale_ScaleFitToSize_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXTScale_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxtrans_0276 */ +/* [local] */ + +typedef +enum DISPIDDXEFFECT + { DISPID_DXECAPABILITIES = 10000, + DISPID_DXEPROGRESS = DISPID_DXECAPABILITIES + 1, + DISPID_DXESTEP = DISPID_DXEPROGRESS + 1, + DISPID_DXEDURATION = DISPID_DXESTEP + 1, + DISPID_DXE_NEXT_ID = DISPID_DXEDURATION + 1 + } DISPIDDXBOUNDEDEFFECT; + +typedef +enum DXEFFECTTYPE + { DXTET_PERIODIC = 1 << 0, + DXTET_MORPH = 1 << 1 + } DXEFFECTTYPE; + + + +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0276_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0276_v0_0_s_ifspec; + +#ifndef __IDXEffect_INTERFACE_DEFINED__ +#define __IDXEffect_INTERFACE_DEFINED__ + +/* interface IDXEffect */ +/* [dual][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXEffect; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("E31FB81B-1335-11d1-8189-0000F87557DB") + IDXEffect : public IDispatch + { + public: + virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Capabilities( + /* [retval][out] */ long *pVal) = 0; + + virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Progress( + /* [retval][out] */ float *pVal) = 0; + + virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Progress( + /* [in] */ float newVal) = 0; + + virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_StepResolution( + /* [retval][out] */ float *pVal) = 0; + + virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Duration( + /* [retval][out] */ float *pVal) = 0; + + virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Duration( + /* [in] */ float newVal) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXEffectVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXEffect * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXEffect * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXEffect * This); + + HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( + IDXEffect * This, + /* [out] */ UINT *pctinfo); + + HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( + IDXEffect * This, + /* [in] */ UINT iTInfo, + /* [in] */ LCID lcid, + /* [out] */ ITypeInfo **ppTInfo); + + HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( + IDXEffect * This, + /* [in] */ REFIID riid, + /* [size_is][in] */ LPOLESTR *rgszNames, + /* [in] */ UINT cNames, + /* [in] */ LCID lcid, + /* [size_is][out] */ DISPID *rgDispId); + + /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( + IDXEffect * This, + /* [in] */ DISPID dispIdMember, + /* [in] */ REFIID riid, + /* [in] */ LCID lcid, + /* [in] */ WORD wFlags, + /* [out][in] */ DISPPARAMS *pDispParams, + /* [out] */ VARIANT *pVarResult, + /* [out] */ EXCEPINFO *pExcepInfo, + /* [out] */ UINT *puArgErr); + + /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Capabilities )( + IDXEffect * This, + /* [retval][out] */ long *pVal); + + /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Progress )( + IDXEffect * This, + /* [retval][out] */ float *pVal); + + /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Progress )( + IDXEffect * This, + /* [in] */ float newVal); + + /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_StepResolution )( + IDXEffect * This, + /* [retval][out] */ float *pVal); + + /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Duration )( + IDXEffect * This, + /* [retval][out] */ float *pVal); + + /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Duration )( + IDXEffect * This, + /* [in] */ float newVal); + + END_INTERFACE + } IDXEffectVtbl; + + interface IDXEffect + { + CONST_VTBL struct IDXEffectVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXEffect_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXEffect_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXEffect_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXEffect_GetTypeInfoCount(This,pctinfo) \ + (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) + +#define IDXEffect_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ + (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) + +#define IDXEffect_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ + (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) + +#define IDXEffect_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ + (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) + + +#define IDXEffect_get_Capabilities(This,pVal) \ + (This)->lpVtbl -> get_Capabilities(This,pVal) + +#define IDXEffect_get_Progress(This,pVal) \ + (This)->lpVtbl -> get_Progress(This,pVal) + +#define IDXEffect_put_Progress(This,newVal) \ + (This)->lpVtbl -> put_Progress(This,newVal) + +#define IDXEffect_get_StepResolution(This,pVal) \ + (This)->lpVtbl -> get_StepResolution(This,pVal) + +#define IDXEffect_get_Duration(This,pVal) \ + (This)->lpVtbl -> get_Duration(This,pVal) + +#define IDXEffect_put_Duration(This,newVal) \ + (This)->lpVtbl -> put_Duration(This,newVal) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +/* [id][propget] */ HRESULT STDMETHODCALLTYPE IDXEffect_get_Capabilities_Proxy( + IDXEffect * This, + /* [retval][out] */ long *pVal); + + +void __RPC_STUB IDXEffect_get_Capabilities_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [id][propget] */ HRESULT STDMETHODCALLTYPE IDXEffect_get_Progress_Proxy( + IDXEffect * This, + /* [retval][out] */ float *pVal); + + +void __RPC_STUB IDXEffect_get_Progress_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [id][propput] */ HRESULT STDMETHODCALLTYPE IDXEffect_put_Progress_Proxy( + IDXEffect * This, + /* [in] */ float newVal); + + +void __RPC_STUB IDXEffect_put_Progress_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [id][propget] */ HRESULT STDMETHODCALLTYPE IDXEffect_get_StepResolution_Proxy( + IDXEffect * This, + /* [retval][out] */ float *pVal); + + +void __RPC_STUB IDXEffect_get_StepResolution_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [id][propget] */ HRESULT STDMETHODCALLTYPE IDXEffect_get_Duration_Proxy( + IDXEffect * This, + /* [retval][out] */ float *pVal); + + +void __RPC_STUB IDXEffect_get_Duration_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [id][propput] */ HRESULT STDMETHODCALLTYPE IDXEffect_put_Duration_Proxy( + IDXEffect * This, + /* [in] */ float newVal); + + +void __RPC_STUB IDXEffect_put_Duration_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXEffect_INTERFACE_DEFINED__ */ + + +#ifndef __IDXLookupTable_INTERFACE_DEFINED__ +#define __IDXLookupTable_INTERFACE_DEFINED__ + +/* interface IDXLookupTable */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXLookupTable; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("01BAFC7F-9E63-11d1-9053-00C04FD9189D") + IDXLookupTable : public IDXBaseObject + { + public: + virtual HRESULT STDMETHODCALLTYPE GetTables( + /* [out] */ BYTE RedLUT[ 256 ], + /* [out] */ BYTE GreenLUT[ 256 ], + /* [out] */ BYTE BlueLUT[ 256 ], + /* [out] */ BYTE AlphaLUT[ 256 ]) = 0; + + virtual HRESULT STDMETHODCALLTYPE IsChannelIdentity( + /* [out] */ DXBASESAMPLE *pSampleBools) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetIndexValues( + /* [in] */ ULONG Index, + /* [out] */ DXBASESAMPLE *pSample) = 0; + + virtual HRESULT STDMETHODCALLTYPE ApplyTables( + /* [out][in] */ DXSAMPLE *pSamples, + /* [in] */ ULONG cSamples) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXLookupTableVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXLookupTable * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXLookupTable * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXLookupTable * This); + + HRESULT ( STDMETHODCALLTYPE *GetGenerationId )( + IDXLookupTable * This, + /* [out] */ ULONG *pID); + + HRESULT ( STDMETHODCALLTYPE *IncrementGenerationId )( + IDXLookupTable * This, + /* [in] */ BOOL bRefresh); + + HRESULT ( STDMETHODCALLTYPE *GetObjectSize )( + IDXLookupTable * This, + /* [out] */ ULONG *pcbSize); + + HRESULT ( STDMETHODCALLTYPE *GetTables )( + IDXLookupTable * This, + /* [out] */ BYTE RedLUT[ 256 ], + /* [out] */ BYTE GreenLUT[ 256 ], + /* [out] */ BYTE BlueLUT[ 256 ], + /* [out] */ BYTE AlphaLUT[ 256 ]); + + HRESULT ( STDMETHODCALLTYPE *IsChannelIdentity )( + IDXLookupTable * This, + /* [out] */ DXBASESAMPLE *pSampleBools); + + HRESULT ( STDMETHODCALLTYPE *GetIndexValues )( + IDXLookupTable * This, + /* [in] */ ULONG Index, + /* [out] */ DXBASESAMPLE *pSample); + + HRESULT ( STDMETHODCALLTYPE *ApplyTables )( + IDXLookupTable * This, + /* [out][in] */ DXSAMPLE *pSamples, + /* [in] */ ULONG cSamples); + + END_INTERFACE + } IDXLookupTableVtbl; + + interface IDXLookupTable + { + CONST_VTBL struct IDXLookupTableVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXLookupTable_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXLookupTable_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXLookupTable_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXLookupTable_GetGenerationId(This,pID) \ + (This)->lpVtbl -> GetGenerationId(This,pID) + +#define IDXLookupTable_IncrementGenerationId(This,bRefresh) \ + (This)->lpVtbl -> IncrementGenerationId(This,bRefresh) + +#define IDXLookupTable_GetObjectSize(This,pcbSize) \ + (This)->lpVtbl -> GetObjectSize(This,pcbSize) + + +#define IDXLookupTable_GetTables(This,RedLUT,GreenLUT,BlueLUT,AlphaLUT) \ + (This)->lpVtbl -> GetTables(This,RedLUT,GreenLUT,BlueLUT,AlphaLUT) + +#define IDXLookupTable_IsChannelIdentity(This,pSampleBools) \ + (This)->lpVtbl -> IsChannelIdentity(This,pSampleBools) + +#define IDXLookupTable_GetIndexValues(This,Index,pSample) \ + (This)->lpVtbl -> GetIndexValues(This,Index,pSample) + +#define IDXLookupTable_ApplyTables(This,pSamples,cSamples) \ + (This)->lpVtbl -> ApplyTables(This,pSamples,cSamples) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXLookupTable_GetTables_Proxy( + IDXLookupTable * This, + /* [out] */ BYTE RedLUT[ 256 ], + /* [out] */ BYTE GreenLUT[ 256 ], + /* [out] */ BYTE BlueLUT[ 256 ], + /* [out] */ BYTE AlphaLUT[ 256 ]); + + +void __RPC_STUB IDXLookupTable_GetTables_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXLookupTable_IsChannelIdentity_Proxy( + IDXLookupTable * This, + /* [out] */ DXBASESAMPLE *pSampleBools); + + +void __RPC_STUB IDXLookupTable_IsChannelIdentity_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXLookupTable_GetIndexValues_Proxy( + IDXLookupTable * This, + /* [in] */ ULONG Index, + /* [out] */ DXBASESAMPLE *pSample); + + +void __RPC_STUB IDXLookupTable_GetIndexValues_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +HRESULT STDMETHODCALLTYPE IDXLookupTable_ApplyTables_Proxy( + IDXLookupTable * This, + /* [out][in] */ DXSAMPLE *pSamples, + /* [in] */ ULONG cSamples); + + +void __RPC_STUB IDXLookupTable_ApplyTables_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXLookupTable_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxtrans_0278 */ +/* [local] */ + +typedef struct DXRAWSURFACEINFO + { + BYTE *pFirstByte; + long lPitch; + ULONG Width; + ULONG Height; + const GUID *pPixelFormat; + HDC hdc; + DWORD dwColorKey; + DXBASESAMPLE *pPalette; + } DXRAWSURFACEINFO; + + + +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0278_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0278_v0_0_s_ifspec; + +#ifndef __IDXRawSurface_INTERFACE_DEFINED__ +#define __IDXRawSurface_INTERFACE_DEFINED__ + +/* interface IDXRawSurface */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IDXRawSurface; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("09756C8A-D96A-11d1-9062-00C04FD9189D") + IDXRawSurface : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE GetSurfaceInfo( + DXRAWSURFACEINFO *pSurfaceInfo) = 0; + + }; + +#else /* C style interface */ + + typedef struct IDXRawSurfaceVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDXRawSurface * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDXRawSurface * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IDXRawSurface * This); + + HRESULT ( STDMETHODCALLTYPE *GetSurfaceInfo )( + IDXRawSurface * This, + DXRAWSURFACEINFO *pSurfaceInfo); + + END_INTERFACE + } IDXRawSurfaceVtbl; + + interface IDXRawSurface + { + CONST_VTBL struct IDXRawSurfaceVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IDXRawSurface_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IDXRawSurface_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IDXRawSurface_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IDXRawSurface_GetSurfaceInfo(This,pSurfaceInfo) \ + (This)->lpVtbl -> GetSurfaceInfo(This,pSurfaceInfo) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IDXRawSurface_GetSurfaceInfo_Proxy( + IDXRawSurface * This, + DXRAWSURFACEINFO *pSurfaceInfo); + + +void __RPC_STUB IDXRawSurface_GetSurfaceInfo_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IDXRawSurface_INTERFACE_DEFINED__ */ + + +#ifndef __IHTMLDXTransform_INTERFACE_DEFINED__ +#define __IHTMLDXTransform_INTERFACE_DEFINED__ + +/* interface IHTMLDXTransform */ +/* [local][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IHTMLDXTransform; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("30E2AB7D-4FDD-4159-B7EA-DC722BF4ADE5") + IHTMLDXTransform : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE SetHostUrl( + BSTR bstrHostUrl) = 0; + + }; + +#else /* C style interface */ + + typedef struct IHTMLDXTransformVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IHTMLDXTransform * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IHTMLDXTransform * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IHTMLDXTransform * This); + + HRESULT ( STDMETHODCALLTYPE *SetHostUrl )( + IHTMLDXTransform * This, + BSTR bstrHostUrl); + + END_INTERFACE + } IHTMLDXTransformVtbl; + + interface IHTMLDXTransform + { + CONST_VTBL struct IHTMLDXTransformVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IHTMLDXTransform_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IHTMLDXTransform_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IHTMLDXTransform_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IHTMLDXTransform_SetHostUrl(This,bstrHostUrl) \ + (This)->lpVtbl -> SetHostUrl(This,bstrHostUrl) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +HRESULT STDMETHODCALLTYPE IHTMLDXTransform_SetHostUrl_Proxy( + IHTMLDXTransform * This, + BSTR bstrHostUrl); + + +void __RPC_STUB IHTMLDXTransform_SetHostUrl_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IHTMLDXTransform_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_dxtrans_0280 */ +/* [local] */ + +typedef +enum DXTFILTER_STATUS + { DXTFILTER_STATUS_Stopped = 0, + DXTFILTER_STATUS_Applied = DXTFILTER_STATUS_Stopped + 1, + DXTFILTER_STATUS_Playing = DXTFILTER_STATUS_Applied + 1, + DXTFILTER_STATUS_MAX = DXTFILTER_STATUS_Playing + 1 + } DXTFILTER_STATUS; + +typedef +enum DXTFILTER_DISPID + { DISPID_DXTFilter_Percent = 1, + DISPID_DXTFilter_Duration = DISPID_DXTFilter_Percent + 1, + DISPID_DXTFilter_Enabled = DISPID_DXTFilter_Duration + 1, + DISPID_DXTFilter_Status = DISPID_DXTFilter_Enabled + 1, + DISPID_DXTFilter_Apply = DISPID_DXTFilter_Status + 1, + DISPID_DXTFilter_Play = DISPID_DXTFilter_Apply + 1, + DISPID_DXTFilter_Stop = DISPID_DXTFilter_Play + 1, + DISPID_DXTFilter_MAX = DISPID_DXTFilter_Stop + 1 + } DXTFILTER_DISPID; + + + +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0280_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_dxtrans_0280_v0_0_s_ifspec; + +#ifndef __ICSSFilterDispatch_INTERFACE_DEFINED__ +#define __ICSSFilterDispatch_INTERFACE_DEFINED__ + +/* interface ICSSFilterDispatch */ +/* [dual][unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_ICSSFilterDispatch; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9519152B-9484-4A6C-B6A7-4F25E92D6C6B") + ICSSFilterDispatch : public IDispatch + { + public: + virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Percent( + /* [retval][out] */ float *pVal) = 0; + + virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Percent( + /* [in] */ float newVal) = 0; + + virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Duration( + /* [retval][out] */ float *pVal) = 0; + + virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Duration( + /* [in] */ float newVal) = 0; + + virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Enabled( + /* [retval][out] */ VARIANT_BOOL *pfVal) = 0; + + virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Enabled( + /* [in] */ VARIANT_BOOL fVal) = 0; + + virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Status( + /* [retval][out] */ DXTFILTER_STATUS *peVal) = 0; + + virtual /* [id] */ HRESULT STDMETHODCALLTYPE Apply( void) = 0; + + virtual /* [id] */ HRESULT STDMETHODCALLTYPE Play( + /* [optional][in] */ VARIANT varDuration) = 0; + + virtual /* [id] */ HRESULT STDMETHODCALLTYPE Stop( void) = 0; + + }; + +#else /* C style interface */ + + typedef struct ICSSFilterDispatchVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ICSSFilterDispatch * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ICSSFilterDispatch * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ICSSFilterDispatch * This); + + HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( + ICSSFilterDispatch * This, + /* [out] */ UINT *pctinfo); + + HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( + ICSSFilterDispatch * This, + /* [in] */ UINT iTInfo, + /* [in] */ LCID lcid, + /* [out] */ ITypeInfo **ppTInfo); + + HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( + ICSSFilterDispatch * This, + /* [in] */ REFIID riid, + /* [size_is][in] */ LPOLESTR *rgszNames, + /* [in] */ UINT cNames, + /* [in] */ LCID lcid, + /* [size_is][out] */ DISPID *rgDispId); + + /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( + ICSSFilterDispatch * This, + /* [in] */ DISPID dispIdMember, + /* [in] */ REFIID riid, + /* [in] */ LCID lcid, + /* [in] */ WORD wFlags, + /* [out][in] */ DISPPARAMS *pDispParams, + /* [out] */ VARIANT *pVarResult, + /* [out] */ EXCEPINFO *pExcepInfo, + /* [out] */ UINT *puArgErr); + + /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Percent )( + ICSSFilterDispatch * This, + /* [retval][out] */ float *pVal); + + /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Percent )( + ICSSFilterDispatch * This, + /* [in] */ float newVal); + + /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Duration )( + ICSSFilterDispatch * This, + /* [retval][out] */ float *pVal); + + /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Duration )( + ICSSFilterDispatch * This, + /* [in] */ float newVal); + + /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Enabled )( + ICSSFilterDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pfVal); + + /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Enabled )( + ICSSFilterDispatch * This, + /* [in] */ VARIANT_BOOL fVal); + + /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Status )( + ICSSFilterDispatch * This, + /* [retval][out] */ DXTFILTER_STATUS *peVal); + + /* [id] */ HRESULT ( STDMETHODCALLTYPE *Apply )( + ICSSFilterDispatch * This); + + /* [id] */ HRESULT ( STDMETHODCALLTYPE *Play )( + ICSSFilterDispatch * This, + /* [optional][in] */ VARIANT varDuration); + + /* [id] */ HRESULT ( STDMETHODCALLTYPE *Stop )( + ICSSFilterDispatch * This); + + END_INTERFACE + } ICSSFilterDispatchVtbl; + + interface ICSSFilterDispatch + { + CONST_VTBL struct ICSSFilterDispatchVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ICSSFilterDispatch_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define ICSSFilterDispatch_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define ICSSFilterDispatch_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define ICSSFilterDispatch_GetTypeInfoCount(This,pctinfo) \ + (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) + +#define ICSSFilterDispatch_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ + (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) + +#define ICSSFilterDispatch_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ + (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) + +#define ICSSFilterDispatch_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ + (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) + + +#define ICSSFilterDispatch_get_Percent(This,pVal) \ + (This)->lpVtbl -> get_Percent(This,pVal) + +#define ICSSFilterDispatch_put_Percent(This,newVal) \ + (This)->lpVtbl -> put_Percent(This,newVal) + +#define ICSSFilterDispatch_get_Duration(This,pVal) \ + (This)->lpVtbl -> get_Duration(This,pVal) + +#define ICSSFilterDispatch_put_Duration(This,newVal) \ + (This)->lpVtbl -> put_Duration(This,newVal) + +#define ICSSFilterDispatch_get_Enabled(This,pfVal) \ + (This)->lpVtbl -> get_Enabled(This,pfVal) + +#define ICSSFilterDispatch_put_Enabled(This,fVal) \ + (This)->lpVtbl -> put_Enabled(This,fVal) + +#define ICSSFilterDispatch_get_Status(This,peVal) \ + (This)->lpVtbl -> get_Status(This,peVal) + +#define ICSSFilterDispatch_Apply(This) \ + (This)->lpVtbl -> Apply(This) + +#define ICSSFilterDispatch_Play(This,varDuration) \ + (This)->lpVtbl -> Play(This,varDuration) + +#define ICSSFilterDispatch_Stop(This) \ + (This)->lpVtbl -> Stop(This) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +/* [id][propget] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_get_Percent_Proxy( + ICSSFilterDispatch * This, + /* [retval][out] */ float *pVal); + + +void __RPC_STUB ICSSFilterDispatch_get_Percent_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [id][propput] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_put_Percent_Proxy( + ICSSFilterDispatch * This, + /* [in] */ float newVal); + + +void __RPC_STUB ICSSFilterDispatch_put_Percent_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [id][propget] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_get_Duration_Proxy( + ICSSFilterDispatch * This, + /* [retval][out] */ float *pVal); + + +void __RPC_STUB ICSSFilterDispatch_get_Duration_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [id][propput] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_put_Duration_Proxy( + ICSSFilterDispatch * This, + /* [in] */ float newVal); + + +void __RPC_STUB ICSSFilterDispatch_put_Duration_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [id][propget] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_get_Enabled_Proxy( + ICSSFilterDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pfVal); + + +void __RPC_STUB ICSSFilterDispatch_get_Enabled_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [id][propput] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_put_Enabled_Proxy( + ICSSFilterDispatch * This, + /* [in] */ VARIANT_BOOL fVal); + + +void __RPC_STUB ICSSFilterDispatch_put_Enabled_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [id][propget] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_get_Status_Proxy( + ICSSFilterDispatch * This, + /* [retval][out] */ DXTFILTER_STATUS *peVal); + + +void __RPC_STUB ICSSFilterDispatch_get_Status_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [id] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_Apply_Proxy( + ICSSFilterDispatch * This); + + +void __RPC_STUB ICSSFilterDispatch_Apply_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [id] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_Play_Proxy( + ICSSFilterDispatch * This, + /* [optional][in] */ VARIANT varDuration); + + +void __RPC_STUB ICSSFilterDispatch_Play_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [id] */ HRESULT STDMETHODCALLTYPE ICSSFilterDispatch_Stop_Proxy( + ICSSFilterDispatch * This); + + +void __RPC_STUB ICSSFilterDispatch_Stop_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __ICSSFilterDispatch_INTERFACE_DEFINED__ */ + + + +#ifndef __DXTRANSLib_LIBRARY_DEFINED__ +#define __DXTRANSLib_LIBRARY_DEFINED__ + +/* library DXTRANSLib */ +/* [helpstring][version][uuid] */ + + +EXTERN_C const IID LIBID_DXTRANSLib; + +EXTERN_C const CLSID CLSID_DXTransformFactory; + +#ifdef __cplusplus + +class DECLSPEC_UUID("D1FE6762-FC48-11D0-883A-3C8B00C10000") +DXTransformFactory; +#endif + +EXTERN_C const CLSID CLSID_DXTaskManager; + +#ifdef __cplusplus + +class DECLSPEC_UUID("4CB26C03-FF93-11d0-817E-0000F87557DB") +DXTaskManager; +#endif + +EXTERN_C const CLSID CLSID_DXTScale; + +#ifdef __cplusplus + +class DECLSPEC_UUID("555278E2-05DB-11D1-883A-3C8B00C10000") +DXTScale; +#endif + +EXTERN_C const CLSID CLSID_DXSurface; + +#ifdef __cplusplus + +class DECLSPEC_UUID("0E890F83-5F79-11D1-9043-00C04FD9189D") +DXSurface; +#endif + +EXTERN_C const CLSID CLSID_DXSurfaceModifier; + +#ifdef __cplusplus + +class DECLSPEC_UUID("3E669F1D-9C23-11d1-9053-00C04FD9189D") +DXSurfaceModifier; +#endif + +EXTERN_C const CLSID CLSID_DXGradient; + +#ifdef __cplusplus + +class DECLSPEC_UUID("C6365470-F667-11d1-9067-00C04FD9189D") +DXGradient; +#endif + +EXTERN_C const CLSID CLSID_DXTFilter; + +#ifdef __cplusplus + +class DECLSPEC_UUID("385A91BC-1E8A-4e4a-A7A6-F4FC1E6CA1BD") +DXTFilter; +#endif +#endif /* __DXTRANSLib_LIBRARY_DEFINED__ */ + +/* Additional Prototypes for ALL interfaces */ + +unsigned long __RPC_USER VARIANT_UserSize( unsigned long *, unsigned long , VARIANT * ); +unsigned char * __RPC_USER VARIANT_UserMarshal( unsigned long *, unsigned char *, VARIANT * ); +unsigned char * __RPC_USER VARIANT_UserUnmarshal(unsigned long *, unsigned char *, VARIANT * ); +void __RPC_USER VARIANT_UserFree( unsigned long *, VARIANT * ); + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/dep/include/DXSDK/include/gameux.h b/src/dep/include/DXSDK/include/gameux.h index fa5b20a..2e28a5f 100644 --- a/src/dep/include/DXSDK/include/gameux.h +++ b/src/dep/include/DXSDK/include/gameux.h @@ -1,250 +1,250 @@ - - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 7.00.0486 */ -/* Compiler settings for gameux.idl: - Oicf, W1, Zp8, env=Win32 (32b run) - protocol : dce , ms_ext, c_ext, robust - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() -*/ -//@@MIDL_FILE_HEADING( ) - -#pragma warning( disable: 4049 ) /* more than 64k source lines */ - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 475 -#endif - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCSAL_H_VERSION__ -#define __REQUIRED_RPCSAL_H_VERSION__ 100 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ - -#ifndef COM_NO_WINDOWS_H -#include "windows.h" -#include "ole2.h" -#endif /*COM_NO_WINDOWS_H*/ - -#ifndef __gameux_h__ -#define __gameux_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -/* Forward Declarations */ - -#ifndef __IGameExplorer_FWD_DEFINED__ -#define __IGameExplorer_FWD_DEFINED__ -typedef interface IGameExplorer IGameExplorer; -#endif /* __IGameExplorer_FWD_DEFINED__ */ - - -#ifndef __GameExplorer_FWD_DEFINED__ -#define __GameExplorer_FWD_DEFINED__ - -#ifdef __cplusplus -typedef class GameExplorer GameExplorer; -#else -typedef struct GameExplorer GameExplorer; -#endif /* __cplusplus */ - -#endif /* __GameExplorer_FWD_DEFINED__ */ - - -/* header files for imported files */ -#include "oaidl.h" -#include "ocidl.h" -#include "shobjidl.h" - -#ifdef __cplusplus -extern "C"{ -#endif - - -/* interface __MIDL_itf_gameux_0000_0000 */ -/* [local] */ - -#define ID_GDF_XML __GDF_XML -#define ID_GDF_THUMBNAIL __GDF_THUMBNAIL -#define ID_ICON_ICO __ICON_ICO -#define ID_GDF_XML_STR L"__GDF_XML" -#define ID_GDF_THUMBNAIL_STR L"__GDF_THUMBNAIL" -typedef /* [v1_enum] */ -enum GAME_INSTALL_SCOPE - { GIS_NOT_INSTALLED = 1, - GIS_CURRENT_USER = 2, - GIS_ALL_USERS = 3 - } GAME_INSTALL_SCOPE; - - - -extern RPC_IF_HANDLE __MIDL_itf_gameux_0000_0000_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_gameux_0000_0000_v0_0_s_ifspec; - -#ifndef __IGameExplorer_INTERFACE_DEFINED__ -#define __IGameExplorer_INTERFACE_DEFINED__ - -/* interface IGameExplorer */ -/* [unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IGameExplorer; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("E7B2FB72-D728-49B3-A5F2-18EBF5F1349E") - IGameExplorer : public IUnknown - { - public: - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE AddGame( - /* [in] */ __RPC__in BSTR bstrGDFBinaryPath, - /* [in] */ __RPC__in BSTR bstrGameInstallDirectory, - /* [in] */ GAME_INSTALL_SCOPE installScope, - /* [out][in] */ __RPC__inout GUID *pguidInstanceID) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE RemoveGame( - /* [in] */ GUID guidInstanceID) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE UpdateGame( - /* [in] */ GUID guidInstanceID) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE VerifyAccess( - /* [in] */ __RPC__in BSTR bstrGDFBinaryPath, - /* [out] */ __RPC__out BOOL *pfHasAccess) = 0; - - }; - -#else /* C style interface */ - - typedef struct IGameExplorerVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IGameExplorer * This, - /* [in] */ __RPC__in REFIID riid, - /* [iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IGameExplorer * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IGameExplorer * This); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *AddGame )( - IGameExplorer * This, - /* [in] */ __RPC__in BSTR bstrGDFBinaryPath, - /* [in] */ __RPC__in BSTR bstrGameInstallDirectory, - /* [in] */ GAME_INSTALL_SCOPE installScope, - /* [out][in] */ __RPC__inout GUID *pguidInstanceID); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *RemoveGame )( - IGameExplorer * This, - /* [in] */ GUID guidInstanceID); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *UpdateGame )( - IGameExplorer * This, - /* [in] */ GUID guidInstanceID); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *VerifyAccess )( - IGameExplorer * This, - /* [in] */ __RPC__in BSTR bstrGDFBinaryPath, - /* [out] */ __RPC__out BOOL *pfHasAccess); - - END_INTERFACE - } IGameExplorerVtbl; - - interface IGameExplorer - { - CONST_VTBL struct IGameExplorerVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IGameExplorer_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IGameExplorer_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IGameExplorer_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IGameExplorer_AddGame(This,bstrGDFBinaryPath,bstrGameInstallDirectory,installScope,pguidInstanceID) \ - ( (This)->lpVtbl -> AddGame(This,bstrGDFBinaryPath,bstrGameInstallDirectory,installScope,pguidInstanceID) ) - -#define IGameExplorer_RemoveGame(This,guidInstanceID) \ - ( (This)->lpVtbl -> RemoveGame(This,guidInstanceID) ) - -#define IGameExplorer_UpdateGame(This,guidInstanceID) \ - ( (This)->lpVtbl -> UpdateGame(This,guidInstanceID) ) - -#define IGameExplorer_VerifyAccess(This,bstrGDFBinaryPath,pfHasAccess) \ - ( (This)->lpVtbl -> VerifyAccess(This,bstrGDFBinaryPath,pfHasAccess) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IGameExplorer_INTERFACE_DEFINED__ */ - - - -#ifndef __gameuxLib_LIBRARY_DEFINED__ -#define __gameuxLib_LIBRARY_DEFINED__ - -/* library gameuxLib */ -/* [helpstring][version][uuid] */ - - -EXTERN_C const IID LIBID_gameuxLib; - -EXTERN_C const CLSID CLSID_GameExplorer; - -#ifdef __cplusplus - -class DECLSPEC_UUID("9A5EA990-3034-4D6F-9128-01F3C61022BC") -GameExplorer; -#endif -#endif /* __gameuxLib_LIBRARY_DEFINED__ */ - -/* Additional Prototypes for ALL interfaces */ - -unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * ); -unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * ); -unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * ); -void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * ); - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 7.00.0486 */ +/* Compiler settings for gameux.idl: + Oicf, W1, Zp8, env=Win32 (32b run) + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +//@@MIDL_FILE_HEADING( ) + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCSAL_H_VERSION__ +#define __REQUIRED_RPCSAL_H_VERSION__ 100 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif // __RPCNDR_H_VERSION__ + +#ifndef COM_NO_WINDOWS_H +#include "windows.h" +#include "ole2.h" +#endif /*COM_NO_WINDOWS_H*/ + +#ifndef __gameux_h__ +#define __gameux_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +#ifndef __IGameExplorer_FWD_DEFINED__ +#define __IGameExplorer_FWD_DEFINED__ +typedef interface IGameExplorer IGameExplorer; +#endif /* __IGameExplorer_FWD_DEFINED__ */ + + +#ifndef __GameExplorer_FWD_DEFINED__ +#define __GameExplorer_FWD_DEFINED__ + +#ifdef __cplusplus +typedef class GameExplorer GameExplorer; +#else +typedef struct GameExplorer GameExplorer; +#endif /* __cplusplus */ + +#endif /* __GameExplorer_FWD_DEFINED__ */ + + +/* header files for imported files */ +#include "oaidl.h" +#include "ocidl.h" +#include "shobjidl.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +/* interface __MIDL_itf_gameux_0000_0000 */ +/* [local] */ + +#define ID_GDF_XML __GDF_XML +#define ID_GDF_THUMBNAIL __GDF_THUMBNAIL +#define ID_ICON_ICO __ICON_ICO +#define ID_GDF_XML_STR L"__GDF_XML" +#define ID_GDF_THUMBNAIL_STR L"__GDF_THUMBNAIL" +typedef /* [v1_enum] */ +enum GAME_INSTALL_SCOPE + { GIS_NOT_INSTALLED = 1, + GIS_CURRENT_USER = 2, + GIS_ALL_USERS = 3 + } GAME_INSTALL_SCOPE; + + + +extern RPC_IF_HANDLE __MIDL_itf_gameux_0000_0000_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_gameux_0000_0000_v0_0_s_ifspec; + +#ifndef __IGameExplorer_INTERFACE_DEFINED__ +#define __IGameExplorer_INTERFACE_DEFINED__ + +/* interface IGameExplorer */ +/* [unique][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IGameExplorer; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("E7B2FB72-D728-49B3-A5F2-18EBF5F1349E") + IGameExplorer : public IUnknown + { + public: + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE AddGame( + /* [in] */ __RPC__in BSTR bstrGDFBinaryPath, + /* [in] */ __RPC__in BSTR bstrGameInstallDirectory, + /* [in] */ GAME_INSTALL_SCOPE installScope, + /* [out][in] */ __RPC__inout GUID *pguidInstanceID) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE RemoveGame( + /* [in] */ GUID guidInstanceID) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE UpdateGame( + /* [in] */ GUID guidInstanceID) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE VerifyAccess( + /* [in] */ __RPC__in BSTR bstrGDFBinaryPath, + /* [out] */ __RPC__out BOOL *pfHasAccess) = 0; + + }; + +#else /* C style interface */ + + typedef struct IGameExplorerVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IGameExplorer * This, + /* [in] */ __RPC__in REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IGameExplorer * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IGameExplorer * This); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *AddGame )( + IGameExplorer * This, + /* [in] */ __RPC__in BSTR bstrGDFBinaryPath, + /* [in] */ __RPC__in BSTR bstrGameInstallDirectory, + /* [in] */ GAME_INSTALL_SCOPE installScope, + /* [out][in] */ __RPC__inout GUID *pguidInstanceID); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *RemoveGame )( + IGameExplorer * This, + /* [in] */ GUID guidInstanceID); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *UpdateGame )( + IGameExplorer * This, + /* [in] */ GUID guidInstanceID); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *VerifyAccess )( + IGameExplorer * This, + /* [in] */ __RPC__in BSTR bstrGDFBinaryPath, + /* [out] */ __RPC__out BOOL *pfHasAccess); + + END_INTERFACE + } IGameExplorerVtbl; + + interface IGameExplorer + { + CONST_VTBL struct IGameExplorerVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IGameExplorer_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IGameExplorer_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IGameExplorer_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IGameExplorer_AddGame(This,bstrGDFBinaryPath,bstrGameInstallDirectory,installScope,pguidInstanceID) \ + ( (This)->lpVtbl -> AddGame(This,bstrGDFBinaryPath,bstrGameInstallDirectory,installScope,pguidInstanceID) ) + +#define IGameExplorer_RemoveGame(This,guidInstanceID) \ + ( (This)->lpVtbl -> RemoveGame(This,guidInstanceID) ) + +#define IGameExplorer_UpdateGame(This,guidInstanceID) \ + ( (This)->lpVtbl -> UpdateGame(This,guidInstanceID) ) + +#define IGameExplorer_VerifyAccess(This,bstrGDFBinaryPath,pfHasAccess) \ + ( (This)->lpVtbl -> VerifyAccess(This,bstrGDFBinaryPath,pfHasAccess) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IGameExplorer_INTERFACE_DEFINED__ */ + + + +#ifndef __gameuxLib_LIBRARY_DEFINED__ +#define __gameuxLib_LIBRARY_DEFINED__ + +/* library gameuxLib */ +/* [helpstring][version][uuid] */ + + +EXTERN_C const IID LIBID_gameuxLib; + +EXTERN_C const CLSID CLSID_GameExplorer; + +#ifdef __cplusplus + +class DECLSPEC_UUID("9A5EA990-3034-4D6F-9128-01F3C61022BC") +GameExplorer; +#endif +#endif /* __gameuxLib_LIBRARY_DEFINED__ */ + +/* Additional Prototypes for ALL interfaces */ + +unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * ); +unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * ); +unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * ); +void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * ); + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/dep/include/DXSDK/include/multimon.h b/src/dep/include/DXSDK/include/multimon.h index 83fa9dd..88e2862 100644 --- a/src/dep/include/DXSDK/include/multimon.h +++ b/src/dep/include/DXSDK/include/multimon.h @@ -1,484 +1,484 @@ -//============================================================================= -// -// multimon.h -- Stub module that fakes multiple monitor apis on Win32 OSes -// without them. -// -// By using this header your code will get back default values from -// GetSystemMetrics() for new metrics, and the new multimonitor APIs -// will act like only one display is present on a Win32 OS without -// multimonitor APIs. -// -// Exactly one source must include this with COMPILE_MULTIMON_STUBS defined. -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -//============================================================================= - -#ifdef __cplusplus -extern "C" { // Assume C declarations for C++ -#endif // __cplusplus - -// -// If we are building with Win95/NT4 headers, we need to declare -// the multimonitor-related metrics and APIs ourselves. -// -#ifndef SM_CMONITORS - -#define SM_XVIRTUALSCREEN 76 -#define SM_YVIRTUALSCREEN 77 -#define SM_CXVIRTUALSCREEN 78 -#define SM_CYVIRTUALSCREEN 79 -#define SM_CMONITORS 80 -#define SM_SAMEDISPLAYFORMAT 81 - -// HMONITOR is already declared if WINVER >= 0x0500 in windef.h -// This is for components built with an older version number. -// -#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) -DECLARE_HANDLE(HMONITOR); -#define HMONITOR_DECLARED -#endif - -#define MONITOR_DEFAULTTONULL 0x00000000 -#define MONITOR_DEFAULTTOPRIMARY 0x00000001 -#define MONITOR_DEFAULTTONEAREST 0x00000002 - -#define MONITORINFOF_PRIMARY 0x00000001 - -typedef struct tagMONITORINFO -{ - DWORD cbSize; - RECT rcMonitor; - RECT rcWork; - DWORD dwFlags; -} MONITORINFO, *LPMONITORINFO; - -#ifndef CCHDEVICENAME -#define CCHDEVICENAME 32 -#endif - -#ifdef __cplusplus -typedef struct tagMONITORINFOEXA : public tagMONITORINFO -{ - CHAR szDevice[CCHDEVICENAME]; -} MONITORINFOEXA, *LPMONITORINFOEXA; -typedef struct tagMONITORINFOEXW : public tagMONITORINFO -{ - WCHAR szDevice[CCHDEVICENAME]; -} MONITORINFOEXW, *LPMONITORINFOEXW; -#ifdef UNICODE -typedef MONITORINFOEXW MONITORINFOEX; -typedef LPMONITORINFOEXW LPMONITORINFOEX; -#else -typedef MONITORINFOEXA MONITORINFOEX; -typedef LPMONITORINFOEXA LPMONITORINFOEX; -#endif // UNICODE -#else // ndef __cplusplus -typedef struct tagMONITORINFOEXA -{ - MONITORINFO; - CHAR szDevice[CCHDEVICENAME]; -} MONITORINFOEXA, *LPMONITORINFOEXA; -typedef struct tagMONITORINFOEXW -{ - MONITORINFO; - WCHAR szDevice[CCHDEVICENAME]; -} MONITORINFOEXW, *LPMONITORINFOEXW; -#ifdef UNICODE -typedef MONITORINFOEXW MONITORINFOEX; -typedef LPMONITORINFOEXW LPMONITORINFOEX; -#else -typedef MONITORINFOEXA MONITORINFOEX; -typedef LPMONITORINFOEXA LPMONITORINFOEX; -#endif // UNICODE -#endif - -typedef BOOL (CALLBACK* MONITORENUMPROC)(HMONITOR, HDC, LPRECT, LPARAM); - -#ifndef DISPLAY_DEVICE_ATTACHED_TO_DESKTOP -typedef struct _DISPLAY_DEVICEA { - DWORD cb; - CHAR DeviceName[32]; - CHAR DeviceString[128]; - DWORD StateFlags; - CHAR DeviceID[128]; - CHAR DeviceKey[128]; -} DISPLAY_DEVICEA, *PDISPLAY_DEVICEA, *LPDISPLAY_DEVICEA; -typedef struct _DISPLAY_DEVICEW { - DWORD cb; - WCHAR DeviceName[32]; - WCHAR DeviceString[128]; - DWORD StateFlags; - WCHAR DeviceID[128]; - WCHAR DeviceKey[128]; -} DISPLAY_DEVICEW, *PDISPLAY_DEVICEW, *LPDISPLAY_DEVICEW; -#ifdef UNICODE -typedef DISPLAY_DEVICEW DISPLAY_DEVICE; -typedef PDISPLAY_DEVICEW PDISPLAY_DEVICE; -typedef LPDISPLAY_DEVICEW LPDISPLAY_DEVICE; -#else -typedef DISPLAY_DEVICEA DISPLAY_DEVICE; -typedef PDISPLAY_DEVICEA PDISPLAY_DEVICE; -typedef LPDISPLAY_DEVICEA LPDISPLAY_DEVICE; -#endif // UNICODE - -#define DISPLAY_DEVICE_ATTACHED_TO_DESKTOP 0x00000001 -#define DISPLAY_DEVICE_MULTI_DRIVER 0x00000002 -#define DISPLAY_DEVICE_PRIMARY_DEVICE 0x00000004 -#define DISPLAY_DEVICE_MIRRORING_DRIVER 0x00000008 -#define DISPLAY_DEVICE_VGA_COMPATIBLE 0x00000010 -#endif - -#endif // SM_CMONITORS - -#undef GetMonitorInfo -#undef GetSystemMetrics -#undef MonitorFromWindow -#undef MonitorFromRect -#undef MonitorFromPoint -#undef EnumDisplayMonitors -#undef EnumDisplayDevices - -// -// Define COMPILE_MULTIMON_STUBS to compile the stubs; -// otherwise, you get the declarations. -// -#ifdef COMPILE_MULTIMON_STUBS - -//----------------------------------------------------------------------------- -// -// Implement the API stubs. -// -//----------------------------------------------------------------------------- - -#ifndef MULTIMON_FNS_DEFINED - -int (WINAPI* g_pfnGetSystemMetrics)(int) = NULL; -HMONITOR (WINAPI* g_pfnMonitorFromWindow)(HWND, DWORD) = NULL; -HMONITOR (WINAPI* g_pfnMonitorFromRect)(LPCRECT, DWORD) = NULL; -HMONITOR (WINAPI* g_pfnMonitorFromPoint)(POINT, DWORD) = NULL; -BOOL (WINAPI* g_pfnGetMonitorInfo)(HMONITOR, LPMONITORINFO) = NULL; -BOOL (WINAPI* g_pfnEnumDisplayMonitors)(HDC, LPCRECT, MONITORENUMPROC, LPARAM) = NULL; -BOOL (WINAPI* g_pfnEnumDisplayDevices)(PVOID, DWORD, PDISPLAY_DEVICE,DWORD) = NULL; -BOOL g_fMultiMonInitDone = FALSE; -BOOL g_fMultimonPlatformNT = FALSE; - -#endif - -BOOL IsPlatformNT() -{ - OSVERSIONINFOA osvi = {0}; - osvi.dwOSVersionInfoSize = sizeof(osvi); - GetVersionExA((OSVERSIONINFOA*)&osvi); - return (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId); -} - -BOOL InitMultipleMonitorStubs(void) -{ - HMODULE hUser32; - if (g_fMultiMonInitDone) - { - return g_pfnGetMonitorInfo != NULL; - } - - g_fMultimonPlatformNT = IsPlatformNT(); - hUser32 = GetModuleHandle(TEXT("USER32")); - if (hUser32 && - (*(FARPROC*)&g_pfnGetSystemMetrics = GetProcAddress(hUser32,"GetSystemMetrics")) != NULL && - (*(FARPROC*)&g_pfnMonitorFromWindow = GetProcAddress(hUser32,"MonitorFromWindow")) != NULL && - (*(FARPROC*)&g_pfnMonitorFromRect = GetProcAddress(hUser32,"MonitorFromRect")) != NULL && - (*(FARPROC*)&g_pfnMonitorFromPoint = GetProcAddress(hUser32,"MonitorFromPoint")) != NULL && - (*(FARPROC*)&g_pfnEnumDisplayMonitors = GetProcAddress(hUser32,"EnumDisplayMonitors")) != NULL && -#ifdef UNICODE - (*(FARPROC*)&g_pfnEnumDisplayDevices = GetProcAddress(hUser32,"EnumDisplayDevicesW")) != NULL && - (*(FARPROC*)&g_pfnGetMonitorInfo = g_fMultimonPlatformNT ? GetProcAddress(hUser32,"GetMonitorInfoW") : - GetProcAddress(hUser32,"GetMonitorInfoA")) != NULL -#else - (*(FARPROC*)&g_pfnGetMonitorInfo = GetProcAddress(hUser32,"GetMonitorInfoA")) != NULL && - (*(FARPROC*)&g_pfnEnumDisplayDevices = GetProcAddress(hUser32,"EnumDisplayDevicesA")) != NULL -#endif - ) { - g_fMultiMonInitDone = TRUE; - return TRUE; - } - else - { - g_pfnGetSystemMetrics = NULL; - g_pfnMonitorFromWindow = NULL; - g_pfnMonitorFromRect = NULL; - g_pfnMonitorFromPoint = NULL; - g_pfnGetMonitorInfo = NULL; - g_pfnEnumDisplayMonitors = NULL; - g_pfnEnumDisplayDevices = NULL; - - g_fMultiMonInitDone = TRUE; - return FALSE; - } -} - -//----------------------------------------------------------------------------- -// -// fake implementations of Monitor APIs that work with the primary display -// no special parameter validation is made since these run in client code -// -//----------------------------------------------------------------------------- - -int WINAPI -xGetSystemMetrics(int nIndex) -{ - if (InitMultipleMonitorStubs()) - return g_pfnGetSystemMetrics(nIndex); - - switch (nIndex) - { - case SM_CMONITORS: - case SM_SAMEDISPLAYFORMAT: - return 1; - - case SM_XVIRTUALSCREEN: - case SM_YVIRTUALSCREEN: - return 0; - - case SM_CXVIRTUALSCREEN: - nIndex = SM_CXSCREEN; - break; - - case SM_CYVIRTUALSCREEN: - nIndex = SM_CYSCREEN; - break; - } - - return GetSystemMetrics(nIndex); -} - -#define xPRIMARY_MONITOR ((HMONITOR)0x12340042) - -HMONITOR WINAPI -xMonitorFromPoint(POINT ptScreenCoords, DWORD dwFlags) -{ - if (InitMultipleMonitorStubs()) - return g_pfnMonitorFromPoint(ptScreenCoords, dwFlags); - - if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) || - ((ptScreenCoords.x >= 0) && - (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) && - (ptScreenCoords.y >= 0) && - (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN)))) - { - return xPRIMARY_MONITOR; - } - - return NULL; -} - -HMONITOR WINAPI -xMonitorFromRect(LPCRECT lprcScreenCoords, DWORD dwFlags) -{ - if (InitMultipleMonitorStubs()) - return g_pfnMonitorFromRect(lprcScreenCoords, dwFlags); - - if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) || - ((lprcScreenCoords->right > 0) && - (lprcScreenCoords->bottom > 0) && - (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) && - (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN)))) - { - return xPRIMARY_MONITOR; - } - - return NULL; -} - -HMONITOR WINAPI -xMonitorFromWindow(HWND hWnd, DWORD dwFlags) -{ - WINDOWPLACEMENT wp; - - if (InitMultipleMonitorStubs()) - return g_pfnMonitorFromWindow(hWnd, dwFlags); - - if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) - return xPRIMARY_MONITOR; - - if (IsIconic(hWnd) ? - GetWindowPlacement(hWnd, &wp) : - GetWindowRect(hWnd, &wp.rcNormalPosition)) { - - return xMonitorFromRect(&wp.rcNormalPosition, dwFlags); - } - - return NULL; -} - -BOOL WINAPI -xGetMonitorInfo(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo) -{ - RECT rcWork; - - if (InitMultipleMonitorStubs()) - { - BOOL f = g_pfnGetMonitorInfo(hMonitor, lpMonitorInfo); -#ifdef UNICODE - if (f && !g_fMultimonPlatformNT && (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEX))) - { - MultiByteToWideChar(CP_ACP, 0, - (LPSTR)((MONITORINFOEX*)lpMonitorInfo)->szDevice, -1, - ((MONITORINFOEX*)lpMonitorInfo)->szDevice, (sizeof(((MONITORINFOEX*)lpMonitorInfo)->szDevice)/sizeof(TCHAR))); - } -#endif - return f; - } - - if ((hMonitor == xPRIMARY_MONITOR) && - lpMonitorInfo && - (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) && - SystemParametersInfoA(SPI_GETWORKAREA, 0, &rcWork, 0)) - { - lpMonitorInfo->rcMonitor.left = 0; - lpMonitorInfo->rcMonitor.top = 0; - lpMonitorInfo->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN); - lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN); - lpMonitorInfo->rcWork = rcWork; - lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY; - - if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEX)) - { -#ifdef UNICODE - MultiByteToWideChar(CP_ACP, 0, "DISPLAY", -1, ((MONITORINFOEX*)lpMonitorInfo)->szDevice, (sizeof(((MONITORINFOEX*)lpMonitorInfo)->szDevice)/sizeof(TCHAR))); -#else // UNICODE - lstrcpy(((MONITORINFOEX*)lpMonitorInfo)->szDevice, TEXT("DISPLAY")); -#endif // UNICODE - } - - return TRUE; - } - - return FALSE; -} - -BOOL WINAPI -xEnumDisplayMonitors( - HDC hdcOptionalForPainting, - LPCRECT lprcEnumMonitorsThatIntersect, - MONITORENUMPROC lpfnEnumProc, - LPARAM dwData) -{ - RECT rcLimit; - - if (InitMultipleMonitorStubs()) { - return g_pfnEnumDisplayMonitors( - hdcOptionalForPainting, - lprcEnumMonitorsThatIntersect, - lpfnEnumProc, - dwData); - } - - if (!lpfnEnumProc) - return FALSE; - - rcLimit.left = 0; - rcLimit.top = 0; - rcLimit.right = GetSystemMetrics(SM_CXSCREEN); - rcLimit.bottom = GetSystemMetrics(SM_CYSCREEN); - - if (hdcOptionalForPainting) - { - RECT rcClip; - POINT ptOrg; - - switch (GetClipBox(hdcOptionalForPainting, &rcClip)) - { - default: - if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg)) - return FALSE; - - OffsetRect(&rcLimit, -ptOrg.x, -ptOrg.y); - if (IntersectRect(&rcLimit, &rcLimit, &rcClip) && - (!lprcEnumMonitorsThatIntersect || - IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) { - - break; - } - //fall thru - case NULLREGION: - return TRUE; - case ERROR: - return FALSE; - } - } else { - if ( lprcEnumMonitorsThatIntersect && - !IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) { - - return TRUE; - } - } - - return lpfnEnumProc( - xPRIMARY_MONITOR, - hdcOptionalForPainting, - &rcLimit, - dwData); -} - -BOOL WINAPI -xEnumDisplayDevices( - PVOID Unused, - DWORD iDevNum, - PDISPLAY_DEVICE lpDisplayDevice, - DWORD dwFlags) -{ - if (InitMultipleMonitorStubs()) - return g_pfnEnumDisplayDevices(Unused, iDevNum, lpDisplayDevice, dwFlags); - - if (Unused != NULL) - return FALSE; - - if (iDevNum != 0) - return FALSE; - - if (lpDisplayDevice == NULL || lpDisplayDevice->cb < sizeof(DISPLAY_DEVICE)) - return FALSE; - -#ifdef UNICODE - MultiByteToWideChar(CP_ACP, 0, "DISPLAY", -1, lpDisplayDevice->DeviceName, (sizeof(lpDisplayDevice->DeviceName)/sizeof(TCHAR))); - MultiByteToWideChar(CP_ACP, 0, "DISPLAY", -1, lpDisplayDevice->DeviceString, (sizeof(lpDisplayDevice->DeviceName)/sizeof(TCHAR))); -#else // UNICODE - lstrcpy((LPTSTR)lpDisplayDevice->DeviceName, TEXT("DISPLAY")); - lstrcpy((LPTSTR)lpDisplayDevice->DeviceString, TEXT("DISPLAY")); -#endif // UNICODE - - lpDisplayDevice->StateFlags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE; - - return TRUE; -} - -#undef xPRIMARY_MONITOR -#undef COMPILE_MULTIMON_STUBS - -#else // COMPILE_MULTIMON_STUBS - -extern int WINAPI xGetSystemMetrics(int); -extern HMONITOR WINAPI xMonitorFromWindow(HWND, DWORD); -extern HMONITOR WINAPI xMonitorFromRect(LPCRECT, DWORD); -extern HMONITOR WINAPI xMonitorFromPoint(POINT, DWORD); -extern BOOL WINAPI xGetMonitorInfo(HMONITOR, LPMONITORINFO); -extern BOOL WINAPI xEnumDisplayMonitors(HDC, LPCRECT, MONITORENUMPROC, LPARAM); -extern BOOL WINAPI xEnumDisplayDevices(PVOID, DWORD, PDISPLAY_DEVICE, DWORD); - -#endif // COMPILE_MULTIMON_STUBS - -// -// build defines that replace the regular APIs with our versions -// -#define GetSystemMetrics xGetSystemMetrics -#define MonitorFromWindow xMonitorFromWindow -#define MonitorFromRect xMonitorFromRect -#define MonitorFromPoint xMonitorFromPoint -#define GetMonitorInfo xGetMonitorInfo -#define EnumDisplayMonitors xEnumDisplayMonitors -#define EnumDisplayDevices xEnumDisplayDevices - -#ifdef __cplusplus -} -#endif // __cplusplus - +//============================================================================= +// +// multimon.h -- Stub module that fakes multiple monitor apis on Win32 OSes +// without them. +// +// By using this header your code will get back default values from +// GetSystemMetrics() for new metrics, and the new multimonitor APIs +// will act like only one display is present on a Win32 OS without +// multimonitor APIs. +// +// Exactly one source must include this with COMPILE_MULTIMON_STUBS defined. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +//============================================================================= + +#ifdef __cplusplus +extern "C" { // Assume C declarations for C++ +#endif // __cplusplus + +// +// If we are building with Win95/NT4 headers, we need to declare +// the multimonitor-related metrics and APIs ourselves. +// +#ifndef SM_CMONITORS + +#define SM_XVIRTUALSCREEN 76 +#define SM_YVIRTUALSCREEN 77 +#define SM_CXVIRTUALSCREEN 78 +#define SM_CYVIRTUALSCREEN 79 +#define SM_CMONITORS 80 +#define SM_SAMEDISPLAYFORMAT 81 + +// HMONITOR is already declared if WINVER >= 0x0500 in windef.h +// This is for components built with an older version number. +// +#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) +DECLARE_HANDLE(HMONITOR); +#define HMONITOR_DECLARED +#endif + +#define MONITOR_DEFAULTTONULL 0x00000000 +#define MONITOR_DEFAULTTOPRIMARY 0x00000001 +#define MONITOR_DEFAULTTONEAREST 0x00000002 + +#define MONITORINFOF_PRIMARY 0x00000001 + +typedef struct tagMONITORINFO +{ + DWORD cbSize; + RECT rcMonitor; + RECT rcWork; + DWORD dwFlags; +} MONITORINFO, *LPMONITORINFO; + +#ifndef CCHDEVICENAME +#define CCHDEVICENAME 32 +#endif + +#ifdef __cplusplus +typedef struct tagMONITORINFOEXA : public tagMONITORINFO +{ + CHAR szDevice[CCHDEVICENAME]; +} MONITORINFOEXA, *LPMONITORINFOEXA; +typedef struct tagMONITORINFOEXW : public tagMONITORINFO +{ + WCHAR szDevice[CCHDEVICENAME]; +} MONITORINFOEXW, *LPMONITORINFOEXW; +#ifdef UNICODE +typedef MONITORINFOEXW MONITORINFOEX; +typedef LPMONITORINFOEXW LPMONITORINFOEX; +#else +typedef MONITORINFOEXA MONITORINFOEX; +typedef LPMONITORINFOEXA LPMONITORINFOEX; +#endif // UNICODE +#else // ndef __cplusplus +typedef struct tagMONITORINFOEXA +{ + MONITORINFO; + CHAR szDevice[CCHDEVICENAME]; +} MONITORINFOEXA, *LPMONITORINFOEXA; +typedef struct tagMONITORINFOEXW +{ + MONITORINFO; + WCHAR szDevice[CCHDEVICENAME]; +} MONITORINFOEXW, *LPMONITORINFOEXW; +#ifdef UNICODE +typedef MONITORINFOEXW MONITORINFOEX; +typedef LPMONITORINFOEXW LPMONITORINFOEX; +#else +typedef MONITORINFOEXA MONITORINFOEX; +typedef LPMONITORINFOEXA LPMONITORINFOEX; +#endif // UNICODE +#endif + +typedef BOOL (CALLBACK* MONITORENUMPROC)(HMONITOR, HDC, LPRECT, LPARAM); + +#ifndef DISPLAY_DEVICE_ATTACHED_TO_DESKTOP +typedef struct _DISPLAY_DEVICEA { + DWORD cb; + CHAR DeviceName[32]; + CHAR DeviceString[128]; + DWORD StateFlags; + CHAR DeviceID[128]; + CHAR DeviceKey[128]; +} DISPLAY_DEVICEA, *PDISPLAY_DEVICEA, *LPDISPLAY_DEVICEA; +typedef struct _DISPLAY_DEVICEW { + DWORD cb; + WCHAR DeviceName[32]; + WCHAR DeviceString[128]; + DWORD StateFlags; + WCHAR DeviceID[128]; + WCHAR DeviceKey[128]; +} DISPLAY_DEVICEW, *PDISPLAY_DEVICEW, *LPDISPLAY_DEVICEW; +#ifdef UNICODE +typedef DISPLAY_DEVICEW DISPLAY_DEVICE; +typedef PDISPLAY_DEVICEW PDISPLAY_DEVICE; +typedef LPDISPLAY_DEVICEW LPDISPLAY_DEVICE; +#else +typedef DISPLAY_DEVICEA DISPLAY_DEVICE; +typedef PDISPLAY_DEVICEA PDISPLAY_DEVICE; +typedef LPDISPLAY_DEVICEA LPDISPLAY_DEVICE; +#endif // UNICODE + +#define DISPLAY_DEVICE_ATTACHED_TO_DESKTOP 0x00000001 +#define DISPLAY_DEVICE_MULTI_DRIVER 0x00000002 +#define DISPLAY_DEVICE_PRIMARY_DEVICE 0x00000004 +#define DISPLAY_DEVICE_MIRRORING_DRIVER 0x00000008 +#define DISPLAY_DEVICE_VGA_COMPATIBLE 0x00000010 +#endif + +#endif // SM_CMONITORS + +#undef GetMonitorInfo +#undef GetSystemMetrics +#undef MonitorFromWindow +#undef MonitorFromRect +#undef MonitorFromPoint +#undef EnumDisplayMonitors +#undef EnumDisplayDevices + +// +// Define COMPILE_MULTIMON_STUBS to compile the stubs; +// otherwise, you get the declarations. +// +#ifdef COMPILE_MULTIMON_STUBS + +//----------------------------------------------------------------------------- +// +// Implement the API stubs. +// +//----------------------------------------------------------------------------- + +#ifndef MULTIMON_FNS_DEFINED + +int (WINAPI* g_pfnGetSystemMetrics)(int) = NULL; +HMONITOR (WINAPI* g_pfnMonitorFromWindow)(HWND, DWORD) = NULL; +HMONITOR (WINAPI* g_pfnMonitorFromRect)(LPCRECT, DWORD) = NULL; +HMONITOR (WINAPI* g_pfnMonitorFromPoint)(POINT, DWORD) = NULL; +BOOL (WINAPI* g_pfnGetMonitorInfo)(HMONITOR, LPMONITORINFO) = NULL; +BOOL (WINAPI* g_pfnEnumDisplayMonitors)(HDC, LPCRECT, MONITORENUMPROC, LPARAM) = NULL; +BOOL (WINAPI* g_pfnEnumDisplayDevices)(PVOID, DWORD, PDISPLAY_DEVICE,DWORD) = NULL; +BOOL g_fMultiMonInitDone = FALSE; +BOOL g_fMultimonPlatformNT = FALSE; + +#endif + +BOOL IsPlatformNT() +{ + OSVERSIONINFOA osvi = {0}; + osvi.dwOSVersionInfoSize = sizeof(osvi); + GetVersionExA((OSVERSIONINFOA*)&osvi); + return (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId); +} + +BOOL InitMultipleMonitorStubs(void) +{ + HMODULE hUser32; + if (g_fMultiMonInitDone) + { + return g_pfnGetMonitorInfo != NULL; + } + + g_fMultimonPlatformNT = IsPlatformNT(); + hUser32 = GetModuleHandle(TEXT("USER32")); + if (hUser32 && + (*(FARPROC*)&g_pfnGetSystemMetrics = GetProcAddress(hUser32,"GetSystemMetrics")) != NULL && + (*(FARPROC*)&g_pfnMonitorFromWindow = GetProcAddress(hUser32,"MonitorFromWindow")) != NULL && + (*(FARPROC*)&g_pfnMonitorFromRect = GetProcAddress(hUser32,"MonitorFromRect")) != NULL && + (*(FARPROC*)&g_pfnMonitorFromPoint = GetProcAddress(hUser32,"MonitorFromPoint")) != NULL && + (*(FARPROC*)&g_pfnEnumDisplayMonitors = GetProcAddress(hUser32,"EnumDisplayMonitors")) != NULL && +#ifdef UNICODE + (*(FARPROC*)&g_pfnEnumDisplayDevices = GetProcAddress(hUser32,"EnumDisplayDevicesW")) != NULL && + (*(FARPROC*)&g_pfnGetMonitorInfo = g_fMultimonPlatformNT ? GetProcAddress(hUser32,"GetMonitorInfoW") : + GetProcAddress(hUser32,"GetMonitorInfoA")) != NULL +#else + (*(FARPROC*)&g_pfnGetMonitorInfo = GetProcAddress(hUser32,"GetMonitorInfoA")) != NULL && + (*(FARPROC*)&g_pfnEnumDisplayDevices = GetProcAddress(hUser32,"EnumDisplayDevicesA")) != NULL +#endif + ) { + g_fMultiMonInitDone = TRUE; + return TRUE; + } + else + { + g_pfnGetSystemMetrics = NULL; + g_pfnMonitorFromWindow = NULL; + g_pfnMonitorFromRect = NULL; + g_pfnMonitorFromPoint = NULL; + g_pfnGetMonitorInfo = NULL; + g_pfnEnumDisplayMonitors = NULL; + g_pfnEnumDisplayDevices = NULL; + + g_fMultiMonInitDone = TRUE; + return FALSE; + } +} + +//----------------------------------------------------------------------------- +// +// fake implementations of Monitor APIs that work with the primary display +// no special parameter validation is made since these run in client code +// +//----------------------------------------------------------------------------- + +int WINAPI +xGetSystemMetrics(int nIndex) +{ + if (InitMultipleMonitorStubs()) + return g_pfnGetSystemMetrics(nIndex); + + switch (nIndex) + { + case SM_CMONITORS: + case SM_SAMEDISPLAYFORMAT: + return 1; + + case SM_XVIRTUALSCREEN: + case SM_YVIRTUALSCREEN: + return 0; + + case SM_CXVIRTUALSCREEN: + nIndex = SM_CXSCREEN; + break; + + case SM_CYVIRTUALSCREEN: + nIndex = SM_CYSCREEN; + break; + } + + return GetSystemMetrics(nIndex); +} + +#define xPRIMARY_MONITOR ((HMONITOR)0x12340042) + +HMONITOR WINAPI +xMonitorFromPoint(POINT ptScreenCoords, DWORD dwFlags) +{ + if (InitMultipleMonitorStubs()) + return g_pfnMonitorFromPoint(ptScreenCoords, dwFlags); + + if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) || + ((ptScreenCoords.x >= 0) && + (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) && + (ptScreenCoords.y >= 0) && + (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN)))) + { + return xPRIMARY_MONITOR; + } + + return NULL; +} + +HMONITOR WINAPI +xMonitorFromRect(LPCRECT lprcScreenCoords, DWORD dwFlags) +{ + if (InitMultipleMonitorStubs()) + return g_pfnMonitorFromRect(lprcScreenCoords, dwFlags); + + if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) || + ((lprcScreenCoords->right > 0) && + (lprcScreenCoords->bottom > 0) && + (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) && + (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN)))) + { + return xPRIMARY_MONITOR; + } + + return NULL; +} + +HMONITOR WINAPI +xMonitorFromWindow(HWND hWnd, DWORD dwFlags) +{ + WINDOWPLACEMENT wp; + + if (InitMultipleMonitorStubs()) + return g_pfnMonitorFromWindow(hWnd, dwFlags); + + if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) + return xPRIMARY_MONITOR; + + if (IsIconic(hWnd) ? + GetWindowPlacement(hWnd, &wp) : + GetWindowRect(hWnd, &wp.rcNormalPosition)) { + + return xMonitorFromRect(&wp.rcNormalPosition, dwFlags); + } + + return NULL; +} + +BOOL WINAPI +xGetMonitorInfo(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo) +{ + RECT rcWork; + + if (InitMultipleMonitorStubs()) + { + BOOL f = g_pfnGetMonitorInfo(hMonitor, lpMonitorInfo); +#ifdef UNICODE + if (f && !g_fMultimonPlatformNT && (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEX))) + { + MultiByteToWideChar(CP_ACP, 0, + (LPSTR)((MONITORINFOEX*)lpMonitorInfo)->szDevice, -1, + ((MONITORINFOEX*)lpMonitorInfo)->szDevice, (sizeof(((MONITORINFOEX*)lpMonitorInfo)->szDevice)/sizeof(TCHAR))); + } +#endif + return f; + } + + if ((hMonitor == xPRIMARY_MONITOR) && + lpMonitorInfo && + (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) && + SystemParametersInfoA(SPI_GETWORKAREA, 0, &rcWork, 0)) + { + lpMonitorInfo->rcMonitor.left = 0; + lpMonitorInfo->rcMonitor.top = 0; + lpMonitorInfo->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN); + lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN); + lpMonitorInfo->rcWork = rcWork; + lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY; + + if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEX)) + { +#ifdef UNICODE + MultiByteToWideChar(CP_ACP, 0, "DISPLAY", -1, ((MONITORINFOEX*)lpMonitorInfo)->szDevice, (sizeof(((MONITORINFOEX*)lpMonitorInfo)->szDevice)/sizeof(TCHAR))); +#else // UNICODE + lstrcpy(((MONITORINFOEX*)lpMonitorInfo)->szDevice, TEXT("DISPLAY")); +#endif // UNICODE + } + + return TRUE; + } + + return FALSE; +} + +BOOL WINAPI +xEnumDisplayMonitors( + HDC hdcOptionalForPainting, + LPCRECT lprcEnumMonitorsThatIntersect, + MONITORENUMPROC lpfnEnumProc, + LPARAM dwData) +{ + RECT rcLimit; + + if (InitMultipleMonitorStubs()) { + return g_pfnEnumDisplayMonitors( + hdcOptionalForPainting, + lprcEnumMonitorsThatIntersect, + lpfnEnumProc, + dwData); + } + + if (!lpfnEnumProc) + return FALSE; + + rcLimit.left = 0; + rcLimit.top = 0; + rcLimit.right = GetSystemMetrics(SM_CXSCREEN); + rcLimit.bottom = GetSystemMetrics(SM_CYSCREEN); + + if (hdcOptionalForPainting) + { + RECT rcClip; + POINT ptOrg; + + switch (GetClipBox(hdcOptionalForPainting, &rcClip)) + { + default: + if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg)) + return FALSE; + + OffsetRect(&rcLimit, -ptOrg.x, -ptOrg.y); + if (IntersectRect(&rcLimit, &rcLimit, &rcClip) && + (!lprcEnumMonitorsThatIntersect || + IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) { + + break; + } + //fall thru + case NULLREGION: + return TRUE; + case ERROR: + return FALSE; + } + } else { + if ( lprcEnumMonitorsThatIntersect && + !IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) { + + return TRUE; + } + } + + return lpfnEnumProc( + xPRIMARY_MONITOR, + hdcOptionalForPainting, + &rcLimit, + dwData); +} + +BOOL WINAPI +xEnumDisplayDevices( + PVOID Unused, + DWORD iDevNum, + PDISPLAY_DEVICE lpDisplayDevice, + DWORD dwFlags) +{ + if (InitMultipleMonitorStubs()) + return g_pfnEnumDisplayDevices(Unused, iDevNum, lpDisplayDevice, dwFlags); + + if (Unused != NULL) + return FALSE; + + if (iDevNum != 0) + return FALSE; + + if (lpDisplayDevice == NULL || lpDisplayDevice->cb < sizeof(DISPLAY_DEVICE)) + return FALSE; + +#ifdef UNICODE + MultiByteToWideChar(CP_ACP, 0, "DISPLAY", -1, lpDisplayDevice->DeviceName, (sizeof(lpDisplayDevice->DeviceName)/sizeof(TCHAR))); + MultiByteToWideChar(CP_ACP, 0, "DISPLAY", -1, lpDisplayDevice->DeviceString, (sizeof(lpDisplayDevice->DeviceName)/sizeof(TCHAR))); +#else // UNICODE + lstrcpy((LPTSTR)lpDisplayDevice->DeviceName, TEXT("DISPLAY")); + lstrcpy((LPTSTR)lpDisplayDevice->DeviceString, TEXT("DISPLAY")); +#endif // UNICODE + + lpDisplayDevice->StateFlags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE; + + return TRUE; +} + +#undef xPRIMARY_MONITOR +#undef COMPILE_MULTIMON_STUBS + +#else // COMPILE_MULTIMON_STUBS + +extern int WINAPI xGetSystemMetrics(int); +extern HMONITOR WINAPI xMonitorFromWindow(HWND, DWORD); +extern HMONITOR WINAPI xMonitorFromRect(LPCRECT, DWORD); +extern HMONITOR WINAPI xMonitorFromPoint(POINT, DWORD); +extern BOOL WINAPI xGetMonitorInfo(HMONITOR, LPMONITORINFO); +extern BOOL WINAPI xEnumDisplayMonitors(HDC, LPCRECT, MONITORENUMPROC, LPARAM); +extern BOOL WINAPI xEnumDisplayDevices(PVOID, DWORD, PDISPLAY_DEVICE, DWORD); + +#endif // COMPILE_MULTIMON_STUBS + +// +// build defines that replace the regular APIs with our versions +// +#define GetSystemMetrics xGetSystemMetrics +#define MonitorFromWindow xMonitorFromWindow +#define MonitorFromRect xMonitorFromRect +#define MonitorFromPoint xMonitorFromPoint +#define GetMonitorInfo xGetMonitorInfo +#define EnumDisplayMonitors xEnumDisplayMonitors +#define EnumDisplayDevices xEnumDisplayDevices + +#ifdef __cplusplus +} +#endif // __cplusplus + diff --git a/src/dep/include/DXSDK/include/rmxfguid.h b/src/dep/include/DXSDK/include/rmxfguid.h index 31e71e6..d3326cc 100644 --- a/src/dep/include/DXSDK/include/rmxfguid.h +++ b/src/dep/include/DXSDK/include/rmxfguid.h @@ -1,223 +1,223 @@ -/*************************************************************************** - * - * Copyright (C) 1998-1999 Microsoft Corporation. All Rights Reserved. - * - * File: rmxfguid.h - * - * Content: Defines GUIDs of D3DRM's templates. - * - ***************************************************************************/ - -#ifndef __RMXFGUID_H_ -#define __RMXFGUID_H_ - -/* {2B957100-9E9A-11cf-AB39-0020AF71E433} */ -DEFINE_GUID(TID_D3DRMInfo, -0x2b957100, 0x9e9a, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); - -/* {3D82AB44-62DA-11cf-AB39-0020AF71E433} */ -DEFINE_GUID(TID_D3DRMMesh, -0x3d82ab44, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); - -/* {3D82AB5E-62DA-11cf-AB39-0020AF71E433} */ -DEFINE_GUID(TID_D3DRMVector, -0x3d82ab5e, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); - -/* {3D82AB5F-62DA-11cf-AB39-0020AF71E433} */ -DEFINE_GUID(TID_D3DRMMeshFace, -0x3d82ab5f, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); - -/* {3D82AB4D-62DA-11cf-AB39-0020AF71E433} */ -DEFINE_GUID(TID_D3DRMMaterial, -0x3d82ab4d, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); - -/* {35FF44E1-6C7C-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMMaterialArray, -0x35ff44e1, 0x6c7c, 0x11cf, 0x8F, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {3D82AB46-62DA-11cf-AB39-0020AF71E433} */ -DEFINE_GUID(TID_D3DRMFrame, -0x3d82ab46, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); - -/* {F6F23F41-7686-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMFrameTransformMatrix, -0xf6f23f41, 0x7686, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {F6F23F42-7686-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMMeshMaterialList, -0xf6f23f42, 0x7686, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {F6F23F40-7686-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMMeshTextureCoords, -0xf6f23f40, 0x7686, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {F6F23F43-7686-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMMeshNormals, -0xf6f23f43, 0x7686, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {F6F23F44-7686-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMCoords2d, -0xf6f23f44, 0x7686, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {F6F23F45-7686-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMMatrix4x4, -0xf6f23f45, 0x7686, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {3D82AB4F-62DA-11cf-AB39-0020AF71E433} */ -DEFINE_GUID(TID_D3DRMAnimation, -0x3d82ab4f, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); - -/* {3D82AB50-62DA-11cf-AB39-0020AF71E433} */ -DEFINE_GUID(TID_D3DRMAnimationSet, -0x3d82ab50, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); - -/* {10DD46A8-775B-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMAnimationKey, -0x10dd46a8, 0x775b, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xA3); - -/* {10DD46A9-775B-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMFloatKeys, -0x10dd46a9, 0x775b, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xA3); - -/* {01411840-7786-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMMaterialAmbientColor, -0x01411840, 0x7786, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xA3); - -/* {01411841-7786-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMMaterialDiffuseColor, -0x01411841, 0x7786, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xA3); - -/* {01411842-7786-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMMaterialSpecularColor, -0x01411842, 0x7786, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xA3); - -/* {D3E16E80-7835-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMMaterialEmissiveColor, -0xd3e16e80, 0x7835, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {01411843-7786-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMMaterialPower, -0x01411843, 0x7786, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xA3); - -/* {35FF44E0-6C7C-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMColorRGBA, -0x35ff44e0, 0x6c7c, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xA3); - -/* {D3E16E81-7835-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMColorRGB, -0xd3e16e81, 0x7835, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {A42790E0-7810-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMGuid, -0xa42790e0, 0x7810, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {A42790E1-7810-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMTextureFilename, -0xa42790e1, 0x7810, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {A42790E2-7810-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMTextureReference, -0xa42790e2, 0x7810, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {1630B820-7842-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMIndexedColor, -0x1630b820, 0x7842, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {1630B821-7842-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMMeshVertexColors, -0x1630b821, 0x7842, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {4885AE60-78E8-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMMaterialWrap, -0x4885ae60, 0x78e8, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {537DA6A0-CA37-11d0-941C-0080C80CFA7B} */ -DEFINE_GUID(TID_D3DRMBoolean, -0x537da6a0, 0xca37, 0x11d0, 0x94, 0x1c, 0x0, 0x80, 0xc8, 0xc, 0xfa, 0x7b); - -/* {ED1EC5C0-C0A8-11d0-941C-0080C80CFA7B} */ -DEFINE_GUID(TID_D3DRMMeshFaceWraps, -0xed1ec5c0, 0xc0a8, 0x11d0, 0x94, 0x1c, 0x0, 0x80, 0xc8, 0xc, 0xfa, 0x7b); - -/* {4885AE63-78E8-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMBoolean2d, -0x4885ae63, 0x78e8, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {F406B180-7B3B-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMTimedFloatKeys, -0xf406b180, 0x7b3b, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {E2BF56C0-840F-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMAnimationOptions, -0xe2bf56c0, 0x840f, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {E2BF56C1-840F-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMFramePosition, -0xe2bf56c1, 0x840f, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {E2BF56C2-840F-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMFrameVelocity, -0xe2bf56c2, 0x840f, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {E2BF56C3-840F-11cf-8F52-0040333594A3} */ -DEFINE_GUID(TID_D3DRMFrameRotation, -0xe2bf56c3, 0x840f, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); - -/* {3D82AB4A-62DA-11cf-AB39-0020AF71E433} */ -DEFINE_GUID(TID_D3DRMLight, -0x3d82ab4a, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); - -/* {3D82AB51-62DA-11cf-AB39-0020AF71E433} */ -DEFINE_GUID(TID_D3DRMCamera, -0x3d82ab51, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); - -/* {E5745280-B24F-11cf-9DD5-00AA00A71A2F} */ -DEFINE_GUID(TID_D3DRMAppData, -0xe5745280, 0xb24f, 0x11cf, 0x9d, 0xd5, 0x0, 0xaa, 0x0, 0xa7, 0x1a, 0x2f); - -/* {AED22740-B31F-11cf-9DD5-00AA00A71A2F} */ -DEFINE_GUID(TID_D3DRMLightUmbra, -0xaed22740, 0xb31f, 0x11cf, 0x9d, 0xd5, 0x0, 0xaa, 0x0, 0xa7, 0x1a, 0x2f); - -/* {AED22742-B31F-11cf-9DD5-00AA00A71A2F} */ -DEFINE_GUID(TID_D3DRMLightRange, -0xaed22742, 0xb31f, 0x11cf, 0x9d, 0xd5, 0x0, 0xaa, 0x0, 0xa7, 0x1a, 0x2f); - -/* {AED22741-B31F-11cf-9DD5-00AA00A71A2F} */ -DEFINE_GUID(TID_D3DRMLightPenumbra, -0xaed22741, 0xb31f, 0x11cf, 0x9d, 0xd5, 0x0, 0xaa, 0x0, 0xa7, 0x1a, 0x2f); - -/* {A8A98BA0-C5E5-11cf-B941-0080C80CFA7B} */ -DEFINE_GUID(TID_D3DRMLightAttenuation, -0xa8a98ba0, 0xc5e5, 0x11cf, 0xb9, 0x41, 0x0, 0x80, 0xc8, 0xc, 0xfa, 0x7b); - -/* {3A23EEA0-94B1-11d0-AB39-0020AF71E433} */ -DEFINE_GUID(TID_D3DRMInlineData, -0x3a23eea0, 0x94b1, 0x11d0, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); - -/* {3A23EEA1-94B1-11d0-AB39-0020AF71E433} */ -DEFINE_GUID(TID_D3DRMUrl, -0x3a23eea1, 0x94b1, 0x11d0, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); - -/* {8A63C360-997D-11d0-941C-0080C80CFA7B} */ -DEFINE_GUID(TID_D3DRMProgressiveMesh, -0x8A63C360, 0x997D, 0x11d0, 0x94, 0x1C, 0x0, 0x80, 0xC8, 0x0C, 0xFA, 0x7B); - -/* {98116AA0-BDBA-11d1-82C0-00A0C9697271} */ -DEFINE_GUID(TID_D3DRMExternalVisual, -0x98116AA0, 0xBDBA, 0x11d1, 0x82, 0xC0, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x71); - -/* {7F0F21E0-BFE1-11d1-82C0-00A0C9697271} */ -DEFINE_GUID(TID_D3DRMStringProperty, -0x7f0f21e0, 0xbfe1, 0x11d1, 0x82, 0xc0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x71); - -/* {7F0F21E1-BFE1-11d1-82C0-00A0C9697271} */ -DEFINE_GUID(TID_D3DRMPropertyBag, -0x7f0f21e1, 0xbfe1, 0x11d1, 0x82, 0xc0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x71); - -// {7F5D5EA0-D53A-11d1-82C0-00A0C9697271} -DEFINE_GUID(TID_D3DRMRightHanded, -0x7f5d5ea0, 0xd53a, 0x11d1, 0x82, 0xc0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x71); - -#endif /* __RMXFGUID_H_ */ - +/*************************************************************************** + * + * Copyright (C) 1998-1999 Microsoft Corporation. All Rights Reserved. + * + * File: rmxfguid.h + * + * Content: Defines GUIDs of D3DRM's templates. + * + ***************************************************************************/ + +#ifndef __RMXFGUID_H_ +#define __RMXFGUID_H_ + +/* {2B957100-9E9A-11cf-AB39-0020AF71E433} */ +DEFINE_GUID(TID_D3DRMInfo, +0x2b957100, 0x9e9a, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + +/* {3D82AB44-62DA-11cf-AB39-0020AF71E433} */ +DEFINE_GUID(TID_D3DRMMesh, +0x3d82ab44, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + +/* {3D82AB5E-62DA-11cf-AB39-0020AF71E433} */ +DEFINE_GUID(TID_D3DRMVector, +0x3d82ab5e, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + +/* {3D82AB5F-62DA-11cf-AB39-0020AF71E433} */ +DEFINE_GUID(TID_D3DRMMeshFace, +0x3d82ab5f, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + +/* {3D82AB4D-62DA-11cf-AB39-0020AF71E433} */ +DEFINE_GUID(TID_D3DRMMaterial, +0x3d82ab4d, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + +/* {35FF44E1-6C7C-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMMaterialArray, +0x35ff44e1, 0x6c7c, 0x11cf, 0x8F, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {3D82AB46-62DA-11cf-AB39-0020AF71E433} */ +DEFINE_GUID(TID_D3DRMFrame, +0x3d82ab46, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + +/* {F6F23F41-7686-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMFrameTransformMatrix, +0xf6f23f41, 0x7686, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {F6F23F42-7686-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMMeshMaterialList, +0xf6f23f42, 0x7686, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {F6F23F40-7686-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMMeshTextureCoords, +0xf6f23f40, 0x7686, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {F6F23F43-7686-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMMeshNormals, +0xf6f23f43, 0x7686, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {F6F23F44-7686-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMCoords2d, +0xf6f23f44, 0x7686, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {F6F23F45-7686-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMMatrix4x4, +0xf6f23f45, 0x7686, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {3D82AB4F-62DA-11cf-AB39-0020AF71E433} */ +DEFINE_GUID(TID_D3DRMAnimation, +0x3d82ab4f, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + +/* {3D82AB50-62DA-11cf-AB39-0020AF71E433} */ +DEFINE_GUID(TID_D3DRMAnimationSet, +0x3d82ab50, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + +/* {10DD46A8-775B-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMAnimationKey, +0x10dd46a8, 0x775b, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xA3); + +/* {10DD46A9-775B-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMFloatKeys, +0x10dd46a9, 0x775b, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xA3); + +/* {01411840-7786-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMMaterialAmbientColor, +0x01411840, 0x7786, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xA3); + +/* {01411841-7786-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMMaterialDiffuseColor, +0x01411841, 0x7786, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xA3); + +/* {01411842-7786-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMMaterialSpecularColor, +0x01411842, 0x7786, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xA3); + +/* {D3E16E80-7835-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMMaterialEmissiveColor, +0xd3e16e80, 0x7835, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {01411843-7786-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMMaterialPower, +0x01411843, 0x7786, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xA3); + +/* {35FF44E0-6C7C-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMColorRGBA, +0x35ff44e0, 0x6c7c, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xA3); + +/* {D3E16E81-7835-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMColorRGB, +0xd3e16e81, 0x7835, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {A42790E0-7810-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMGuid, +0xa42790e0, 0x7810, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {A42790E1-7810-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMTextureFilename, +0xa42790e1, 0x7810, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {A42790E2-7810-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMTextureReference, +0xa42790e2, 0x7810, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {1630B820-7842-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMIndexedColor, +0x1630b820, 0x7842, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {1630B821-7842-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMMeshVertexColors, +0x1630b821, 0x7842, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {4885AE60-78E8-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMMaterialWrap, +0x4885ae60, 0x78e8, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {537DA6A0-CA37-11d0-941C-0080C80CFA7B} */ +DEFINE_GUID(TID_D3DRMBoolean, +0x537da6a0, 0xca37, 0x11d0, 0x94, 0x1c, 0x0, 0x80, 0xc8, 0xc, 0xfa, 0x7b); + +/* {ED1EC5C0-C0A8-11d0-941C-0080C80CFA7B} */ +DEFINE_GUID(TID_D3DRMMeshFaceWraps, +0xed1ec5c0, 0xc0a8, 0x11d0, 0x94, 0x1c, 0x0, 0x80, 0xc8, 0xc, 0xfa, 0x7b); + +/* {4885AE63-78E8-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMBoolean2d, +0x4885ae63, 0x78e8, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {F406B180-7B3B-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMTimedFloatKeys, +0xf406b180, 0x7b3b, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {E2BF56C0-840F-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMAnimationOptions, +0xe2bf56c0, 0x840f, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {E2BF56C1-840F-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMFramePosition, +0xe2bf56c1, 0x840f, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {E2BF56C2-840F-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMFrameVelocity, +0xe2bf56c2, 0x840f, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {E2BF56C3-840F-11cf-8F52-0040333594A3} */ +DEFINE_GUID(TID_D3DRMFrameRotation, +0xe2bf56c3, 0x840f, 0x11cf, 0x8f, 0x52, 0x0, 0x40, 0x33, 0x35, 0x94, 0xa3); + +/* {3D82AB4A-62DA-11cf-AB39-0020AF71E433} */ +DEFINE_GUID(TID_D3DRMLight, +0x3d82ab4a, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + +/* {3D82AB51-62DA-11cf-AB39-0020AF71E433} */ +DEFINE_GUID(TID_D3DRMCamera, +0x3d82ab51, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + +/* {E5745280-B24F-11cf-9DD5-00AA00A71A2F} */ +DEFINE_GUID(TID_D3DRMAppData, +0xe5745280, 0xb24f, 0x11cf, 0x9d, 0xd5, 0x0, 0xaa, 0x0, 0xa7, 0x1a, 0x2f); + +/* {AED22740-B31F-11cf-9DD5-00AA00A71A2F} */ +DEFINE_GUID(TID_D3DRMLightUmbra, +0xaed22740, 0xb31f, 0x11cf, 0x9d, 0xd5, 0x0, 0xaa, 0x0, 0xa7, 0x1a, 0x2f); + +/* {AED22742-B31F-11cf-9DD5-00AA00A71A2F} */ +DEFINE_GUID(TID_D3DRMLightRange, +0xaed22742, 0xb31f, 0x11cf, 0x9d, 0xd5, 0x0, 0xaa, 0x0, 0xa7, 0x1a, 0x2f); + +/* {AED22741-B31F-11cf-9DD5-00AA00A71A2F} */ +DEFINE_GUID(TID_D3DRMLightPenumbra, +0xaed22741, 0xb31f, 0x11cf, 0x9d, 0xd5, 0x0, 0xaa, 0x0, 0xa7, 0x1a, 0x2f); + +/* {A8A98BA0-C5E5-11cf-B941-0080C80CFA7B} */ +DEFINE_GUID(TID_D3DRMLightAttenuation, +0xa8a98ba0, 0xc5e5, 0x11cf, 0xb9, 0x41, 0x0, 0x80, 0xc8, 0xc, 0xfa, 0x7b); + +/* {3A23EEA0-94B1-11d0-AB39-0020AF71E433} */ +DEFINE_GUID(TID_D3DRMInlineData, +0x3a23eea0, 0x94b1, 0x11d0, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + +/* {3A23EEA1-94B1-11d0-AB39-0020AF71E433} */ +DEFINE_GUID(TID_D3DRMUrl, +0x3a23eea1, 0x94b1, 0x11d0, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + +/* {8A63C360-997D-11d0-941C-0080C80CFA7B} */ +DEFINE_GUID(TID_D3DRMProgressiveMesh, +0x8A63C360, 0x997D, 0x11d0, 0x94, 0x1C, 0x0, 0x80, 0xC8, 0x0C, 0xFA, 0x7B); + +/* {98116AA0-BDBA-11d1-82C0-00A0C9697271} */ +DEFINE_GUID(TID_D3DRMExternalVisual, +0x98116AA0, 0xBDBA, 0x11d1, 0x82, 0xC0, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x71); + +/* {7F0F21E0-BFE1-11d1-82C0-00A0C9697271} */ +DEFINE_GUID(TID_D3DRMStringProperty, +0x7f0f21e0, 0xbfe1, 0x11d1, 0x82, 0xc0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x71); + +/* {7F0F21E1-BFE1-11d1-82C0-00A0C9697271} */ +DEFINE_GUID(TID_D3DRMPropertyBag, +0x7f0f21e1, 0xbfe1, 0x11d1, 0x82, 0xc0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x71); + +// {7F5D5EA0-D53A-11d1-82C0-00A0C9697271} +DEFINE_GUID(TID_D3DRMRightHanded, +0x7f5d5ea0, 0xd53a, 0x11d1, 0x82, 0xc0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x71); + +#endif /* __RMXFGUID_H_ */ + diff --git a/src/dep/include/DXSDK/include/rmxftmpl.h b/src/dep/include/DXSDK/include/rmxftmpl.h index 8de19ef..e0018d0 100644 --- a/src/dep/include/DXSDK/include/rmxftmpl.h +++ b/src/dep/include/DXSDK/include/rmxftmpl.h @@ -1,339 +1,339 @@ -/* D3DRM XFile templates in binary form */ - -#ifndef _RMXFTMPL_H_ -#define _RMXFTMPL_H_ - -unsigned char D3DRM_XTEMPLATES[] = { - 0x78, 0x6f, 0x66, 0x20, 0x30, 0x33, 0x30, 0x32, 0x62, - 0x69, 0x6e, 0x20, 0x30, 0x30, 0x36, 0x34, 0x1f, 0, 0x1, - 0, 0x6, 0, 0, 0, 0x48, 0x65, 0x61, 0x64, 0x65, - 0x72, 0xa, 0, 0x5, 0, 0x43, 0xab, 0x82, 0x3d, 0xda, - 0x62, 0xcf, 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, - 0x33, 0x28, 0, 0x1, 0, 0x5, 0, 0, 0, 0x6d, - 0x61, 0x6a, 0x6f, 0x72, 0x14, 0, 0x28, 0, 0x1, 0, - 0x5, 0, 0, 0, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x14, - 0, 0x29, 0, 0x1, 0, 0x5, 0, 0, 0, 0x66, - 0x6c, 0x61, 0x67, 0x73, 0x14, 0, 0xb, 0, 0x1f, 0, - 0x1, 0, 0x6, 0, 0, 0, 0x56, 0x65, 0x63, 0x74, - 0x6f, 0x72, 0xa, 0, 0x5, 0, 0x5e, 0xab, 0x82, 0x3d, - 0xda, 0x62, 0xcf, 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, - 0xe4, 0x33, 0x2a, 0, 0x1, 0, 0x1, 0, 0, 0, - 0x78, 0x14, 0, 0x2a, 0, 0x1, 0, 0x1, 0, 0, - 0, 0x79, 0x14, 0, 0x2a, 0, 0x1, 0, 0x1, 0, - 0, 0, 0x7a, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, - 0, 0x8, 0, 0, 0, 0x43, 0x6f, 0x6f, 0x72, 0x64, - 0x73, 0x32, 0x64, 0xa, 0, 0x5, 0, 0x44, 0x3f, 0xf2, - 0xf6, 0x86, 0x76, 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, - 0x35, 0x94, 0xa3, 0x2a, 0, 0x1, 0, 0x1, 0, 0, - 0, 0x75, 0x14, 0, 0x2a, 0, 0x1, 0, 0x1, 0, - 0, 0, 0x76, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, - 0, 0x9, 0, 0, 0, 0x4d, 0x61, 0x74, 0x72, 0x69, - 0x78, 0x34, 0x78, 0x34, 0xa, 0, 0x5, 0, 0x45, 0x3f, - 0xf2, 0xf6, 0x86, 0x76, 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, - 0x33, 0x35, 0x94, 0xa3, 0x34, 0, 0x2a, 0, 0x1, 0, - 0x6, 0, 0, 0, 0x6d, 0x61, 0x74, 0x72, 0x69, 0x78, - 0xe, 0, 0x3, 0, 0x10, 0, 0, 0, 0xf, 0, - 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, 0, 0x9, 0, - 0, 0, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x47, 0x42, - 0x41, 0xa, 0, 0x5, 0, 0xe0, 0x44, 0xff, 0x35, 0x7c, - 0x6c, 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, - 0xa3, 0x2a, 0, 0x1, 0, 0x3, 0, 0, 0, 0x72, - 0x65, 0x64, 0x14, 0, 0x2a, 0, 0x1, 0, 0x5, 0, - 0, 0, 0x67, 0x72, 0x65, 0x65, 0x6e, 0x14, 0, 0x2a, - 0, 0x1, 0, 0x4, 0, 0, 0, 0x62, 0x6c, 0x75, - 0x65, 0x14, 0, 0x2a, 0, 0x1, 0, 0x5, 0, 0, - 0, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x14, 0, 0xb, 0, - 0x1f, 0, 0x1, 0, 0x8, 0, 0, 0, 0x43, 0x6f, - 0x6c, 0x6f, 0x72, 0x52, 0x47, 0x42, 0xa, 0, 0x5, 0, - 0x81, 0x6e, 0xe1, 0xd3, 0x35, 0x78, 0xcf, 0x11, 0x8f, 0x52, - 0, 0x40, 0x33, 0x35, 0x94, 0xa3, 0x2a, 0, 0x1, 0, - 0x3, 0, 0, 0, 0x72, 0x65, 0x64, 0x14, 0, 0x2a, - 0, 0x1, 0, 0x5, 0, 0, 0, 0x67, 0x72, 0x65, - 0x65, 0x6e, 0x14, 0, 0x2a, 0, 0x1, 0, 0x4, 0, - 0, 0, 0x62, 0x6c, 0x75, 0x65, 0x14, 0, 0xb, 0, - 0x1f, 0, 0x1, 0, 0xc, 0, 0, 0, 0x49, 0x6e, - 0x64, 0x65, 0x78, 0x65, 0x64, 0x43, 0x6f, 0x6c, 0x6f, 0x72, - 0xa, 0, 0x5, 0, 0x20, 0xb8, 0x30, 0x16, 0x42, 0x78, - 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, - 0x29, 0, 0x1, 0, 0x5, 0, 0, 0, 0x69, 0x6e, - 0x64, 0x65, 0x78, 0x14, 0, 0x1, 0, 0x9, 0, 0, - 0, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x47, 0x42, 0x41, - 0x1, 0, 0xa, 0, 0, 0, 0x69, 0x6e, 0x64, 0x65, - 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x14, 0, 0xb, 0, - 0x1f, 0, 0x1, 0, 0x7, 0, 0, 0, 0x42, 0x6f, - 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0xa, 0, 0x5, 0, 0xa0, - 0xa6, 0x7d, 0x53, 0x37, 0xca, 0xd0, 0x11, 0x94, 0x1c, 0, - 0x80, 0xc8, 0xc, 0xfa, 0x7b, 0x29, 0, 0x1, 0, 0x9, - 0, 0, 0, 0x74, 0x72, 0x75, 0x65, 0x66, 0x61, 0x6c, - 0x73, 0x65, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, 0, - 0x9, 0, 0, 0, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, - 0x6e, 0x32, 0x64, 0xa, 0, 0x5, 0, 0x63, 0xae, 0x85, - 0x48, 0xe8, 0x78, 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, - 0x35, 0x94, 0xa3, 0x1, 0, 0x7, 0, 0, 0, 0x42, - 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x1, 0, 0x1, 0, - 0, 0, 0x75, 0x14, 0, 0x1, 0, 0x7, 0, 0, - 0, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x1, 0, - 0x1, 0, 0, 0, 0x76, 0x14, 0, 0xb, 0, 0x1f, - 0, 0x1, 0, 0xc, 0, 0, 0, 0x4d, 0x61, 0x74, - 0x65, 0x72, 0x69, 0x61, 0x6c, 0x57, 0x72, 0x61, 0x70, 0xa, - 0, 0x5, 0, 0x60, 0xae, 0x85, 0x48, 0xe8, 0x78, 0xcf, - 0x11, 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, 0x1, - 0, 0x7, 0, 0, 0, 0x42, 0x6f, 0x6f, 0x6c, 0x65, - 0x61, 0x6e, 0x1, 0, 0x1, 0, 0, 0, 0x75, 0x14, - 0, 0x1, 0, 0x7, 0, 0, 0, 0x42, 0x6f, 0x6f, - 0x6c, 0x65, 0x61, 0x6e, 0x1, 0, 0x1, 0, 0, 0, - 0x76, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, 0, 0xf, - 0, 0, 0, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, - 0x46, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0xa, 0, - 0x5, 0, 0xe1, 0x90, 0x27, 0xa4, 0x10, 0x78, 0xcf, 0x11, - 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, 0x31, 0, - 0x1, 0, 0x8, 0, 0, 0, 0x66, 0x69, 0x6c, 0x65, - 0x6e, 0x61, 0x6d, 0x65, 0x14, 0, 0xb, 0, 0x1f, 0, - 0x1, 0, 0x8, 0, 0, 0, 0x4d, 0x61, 0x74, 0x65, - 0x72, 0x69, 0x61, 0x6c, 0xa, 0, 0x5, 0, 0x4d, 0xab, - 0x82, 0x3d, 0xda, 0x62, 0xcf, 0x11, 0xab, 0x39, 0, 0x20, - 0xaf, 0x71, 0xe4, 0x33, 0x1, 0, 0x9, 0, 0, 0, - 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x47, 0x42, 0x41, 0x1, - 0, 0x9, 0, 0, 0, 0x66, 0x61, 0x63, 0x65, 0x43, - 0x6f, 0x6c, 0x6f, 0x72, 0x14, 0, 0x2a, 0, 0x1, 0, - 0x5, 0, 0, 0, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x14, - 0, 0x1, 0, 0x8, 0, 0, 0, 0x43, 0x6f, 0x6c, - 0x6f, 0x72, 0x52, 0x47, 0x42, 0x1, 0, 0xd, 0, 0, - 0, 0x73, 0x70, 0x65, 0x63, 0x75, 0x6c, 0x61, 0x72, 0x43, - 0x6f, 0x6c, 0x6f, 0x72, 0x14, 0, 0x1, 0, 0x8, 0, - 0, 0, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x47, 0x42, - 0x1, 0, 0xd, 0, 0, 0, 0x65, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x76, 0x65, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x14, - 0, 0xe, 0, 0x12, 0, 0x12, 0, 0x12, 0, 0xf, - 0, 0xb, 0, 0x1f, 0, 0x1, 0, 0x8, 0, 0, - 0, 0x4d, 0x65, 0x73, 0x68, 0x46, 0x61, 0x63, 0x65, 0xa, - 0, 0x5, 0, 0x5f, 0xab, 0x82, 0x3d, 0xda, 0x62, 0xcf, - 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, 0x33, 0x29, - 0, 0x1, 0, 0x12, 0, 0, 0, 0x6e, 0x46, 0x61, - 0x63, 0x65, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x49, 0x6e, - 0x64, 0x69, 0x63, 0x65, 0x73, 0x14, 0, 0x34, 0, 0x29, - 0, 0x1, 0, 0x11, 0, 0, 0, 0x66, 0x61, 0x63, - 0x65, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x49, 0x6e, 0x64, - 0x69, 0x63, 0x65, 0x73, 0xe, 0, 0x1, 0, 0x12, 0, - 0, 0, 0x6e, 0x46, 0x61, 0x63, 0x65, 0x56, 0x65, 0x72, - 0x74, 0x65, 0x78, 0x49, 0x6e, 0x64, 0x69, 0x63, 0x65, 0x73, - 0xf, 0, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, 0, - 0xd, 0, 0, 0, 0x4d, 0x65, 0x73, 0x68, 0x46, 0x61, - 0x63, 0x65, 0x57, 0x72, 0x61, 0x70, 0x73, 0xa, 0, 0x5, - 0, 0xc0, 0xc5, 0x1e, 0xed, 0xa8, 0xc0, 0xd0, 0x11, 0x94, - 0x1c, 0, 0x80, 0xc8, 0xc, 0xfa, 0x7b, 0x29, 0, 0x1, - 0, 0xf, 0, 0, 0, 0x6e, 0x46, 0x61, 0x63, 0x65, - 0x57, 0x72, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, - 0x14, 0, 0x34, 0, 0x1, 0, 0x9, 0, 0, 0, - 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x32, 0x64, 0x1, - 0, 0xe, 0, 0, 0, 0x66, 0x61, 0x63, 0x65, 0x57, - 0x72, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0xe, - 0, 0x1, 0, 0xf, 0, 0, 0, 0x6e, 0x46, 0x61, - 0x63, 0x65, 0x57, 0x72, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x73, 0xf, 0, 0x14, 0, 0xb, 0, 0x1f, 0, - 0x1, 0, 0x11, 0, 0, 0, 0x4d, 0x65, 0x73, 0x68, - 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, 0x6f, - 0x72, 0x64, 0x73, 0xa, 0, 0x5, 0, 0x40, 0x3f, 0xf2, - 0xf6, 0x86, 0x76, 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, - 0x35, 0x94, 0xa3, 0x29, 0, 0x1, 0, 0xe, 0, 0, - 0, 0x6e, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x43, - 0x6f, 0x6f, 0x72, 0x64, 0x73, 0x14, 0, 0x34, 0, 0x1, - 0, 0x8, 0, 0, 0, 0x43, 0x6f, 0x6f, 0x72, 0x64, - 0x73, 0x32, 0x64, 0x1, 0, 0xd, 0, 0, 0, 0x74, - 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, 0x6f, 0x72, - 0x64, 0x73, 0xe, 0, 0x1, 0, 0xe, 0, 0, 0, - 0x6e, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, - 0x6f, 0x72, 0x64, 0x73, 0xf, 0, 0x14, 0, 0xb, 0, - 0x1f, 0, 0x1, 0, 0x10, 0, 0, 0, 0x4d, 0x65, - 0x73, 0x68, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, - 0x4c, 0x69, 0x73, 0x74, 0xa, 0, 0x5, 0, 0x42, 0x3f, - 0xf2, 0xf6, 0x86, 0x76, 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, - 0x33, 0x35, 0x94, 0xa3, 0x29, 0, 0x1, 0, 0xa, 0, - 0, 0, 0x6e, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, - 0x6c, 0x73, 0x14, 0, 0x29, 0, 0x1, 0, 0xc, 0, - 0, 0, 0x6e, 0x46, 0x61, 0x63, 0x65, 0x49, 0x6e, 0x64, - 0x65, 0x78, 0x65, 0x73, 0x14, 0, 0x34, 0, 0x29, 0, - 0x1, 0, 0xb, 0, 0, 0, 0x66, 0x61, 0x63, 0x65, - 0x49, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0xe, 0, 0x1, - 0, 0xc, 0, 0, 0, 0x6e, 0x46, 0x61, 0x63, 0x65, - 0x49, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0xf, 0, 0x14, - 0, 0xe, 0, 0x1, 0, 0x8, 0, 0, 0, 0x4d, - 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0xf, 0, 0xb, - 0, 0x1f, 0, 0x1, 0, 0xb, 0, 0, 0, 0x4d, - 0x65, 0x73, 0x68, 0x4e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x73, - 0xa, 0, 0x5, 0, 0x43, 0x3f, 0xf2, 0xf6, 0x86, 0x76, - 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, - 0x29, 0, 0x1, 0, 0x8, 0, 0, 0, 0x6e, 0x4e, - 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x73, 0x14, 0, 0x34, 0, - 0x1, 0, 0x6, 0, 0, 0, 0x56, 0x65, 0x63, 0x74, - 0x6f, 0x72, 0x1, 0, 0x7, 0, 0, 0, 0x6e, 0x6f, - 0x72, 0x6d, 0x61, 0x6c, 0x73, 0xe, 0, 0x1, 0, 0x8, - 0, 0, 0, 0x6e, 0x4e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, - 0x73, 0xf, 0, 0x14, 0, 0x29, 0, 0x1, 0, 0xc, - 0, 0, 0, 0x6e, 0x46, 0x61, 0x63, 0x65, 0x4e, 0x6f, - 0x72, 0x6d, 0x61, 0x6c, 0x73, 0x14, 0, 0x34, 0, 0x1, - 0, 0x8, 0, 0, 0, 0x4d, 0x65, 0x73, 0x68, 0x46, - 0x61, 0x63, 0x65, 0x1, 0, 0xb, 0, 0, 0, 0x66, - 0x61, 0x63, 0x65, 0x4e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x73, - 0xe, 0, 0x1, 0, 0xc, 0, 0, 0, 0x6e, 0x46, - 0x61, 0x63, 0x65, 0x4e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x73, - 0xf, 0, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, 0, - 0x10, 0, 0, 0, 0x4d, 0x65, 0x73, 0x68, 0x56, 0x65, - 0x72, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x73, - 0xa, 0, 0x5, 0, 0x21, 0xb8, 0x30, 0x16, 0x42, 0x78, - 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, - 0x29, 0, 0x1, 0, 0xd, 0, 0, 0, 0x6e, 0x56, - 0x65, 0x72, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, - 0x73, 0x14, 0, 0x34, 0, 0x1, 0, 0xc, 0, 0, - 0, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x64, 0x43, 0x6f, - 0x6c, 0x6f, 0x72, 0x1, 0, 0xc, 0, 0, 0, 0x76, - 0x65, 0x72, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, - 0x73, 0xe, 0, 0x1, 0, 0xd, 0, 0, 0, 0x6e, - 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, - 0x72, 0x73, 0xf, 0, 0x14, 0, 0xb, 0, 0x1f, 0, - 0x1, 0, 0x4, 0, 0, 0, 0x4d, 0x65, 0x73, 0x68, - 0xa, 0, 0x5, 0, 0x44, 0xab, 0x82, 0x3d, 0xda, 0x62, - 0xcf, 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, 0x33, - 0x29, 0, 0x1, 0, 0x9, 0, 0, 0, 0x6e, 0x56, - 0x65, 0x72, 0x74, 0x69, 0x63, 0x65, 0x73, 0x14, 0, 0x34, - 0, 0x1, 0, 0x6, 0, 0, 0, 0x56, 0x65, 0x63, - 0x74, 0x6f, 0x72, 0x1, 0, 0x8, 0, 0, 0, 0x76, - 0x65, 0x72, 0x74, 0x69, 0x63, 0x65, 0x73, 0xe, 0, 0x1, - 0, 0x9, 0, 0, 0, 0x6e, 0x56, 0x65, 0x72, 0x74, - 0x69, 0x63, 0x65, 0x73, 0xf, 0, 0x14, 0, 0x29, 0, - 0x1, 0, 0x6, 0, 0, 0, 0x6e, 0x46, 0x61, 0x63, - 0x65, 0x73, 0x14, 0, 0x34, 0, 0x1, 0, 0x8, 0, - 0, 0, 0x4d, 0x65, 0x73, 0x68, 0x46, 0x61, 0x63, 0x65, - 0x1, 0, 0x5, 0, 0, 0, 0x66, 0x61, 0x63, 0x65, - 0x73, 0xe, 0, 0x1, 0, 0x6, 0, 0, 0, 0x6e, - 0x46, 0x61, 0x63, 0x65, 0x73, 0xf, 0, 0x14, 0, 0xe, - 0, 0x12, 0, 0x12, 0, 0x12, 0, 0xf, 0, 0xb, - 0, 0x1f, 0, 0x1, 0, 0x14, 0, 0, 0, 0x46, - 0x72, 0x61, 0x6d, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, - 0x6f, 0x72, 0x6d, 0x4d, 0x61, 0x74, 0x72, 0x69, 0x78, 0xa, - 0, 0x5, 0, 0x41, 0x3f, 0xf2, 0xf6, 0x86, 0x76, 0xcf, - 0x11, 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, 0x1, - 0, 0x9, 0, 0, 0, 0x4d, 0x61, 0x74, 0x72, 0x69, - 0x78, 0x34, 0x78, 0x34, 0x1, 0, 0xb, 0, 0, 0, - 0x66, 0x72, 0x61, 0x6d, 0x65, 0x4d, 0x61, 0x74, 0x72, 0x69, - 0x78, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, 0, 0x5, - 0, 0, 0, 0x46, 0x72, 0x61, 0x6d, 0x65, 0xa, 0, - 0x5, 0, 0x46, 0xab, 0x82, 0x3d, 0xda, 0x62, 0xcf, 0x11, - 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, 0x33, 0xe, 0, - 0x12, 0, 0x12, 0, 0x12, 0, 0xf, 0, 0xb, 0, - 0x1f, 0, 0x1, 0, 0x9, 0, 0, 0, 0x46, 0x6c, - 0x6f, 0x61, 0x74, 0x4b, 0x65, 0x79, 0x73, 0xa, 0, 0x5, - 0, 0xa9, 0x46, 0xdd, 0x10, 0x5b, 0x77, 0xcf, 0x11, 0x8f, - 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, 0x29, 0, 0x1, - 0, 0x7, 0, 0, 0, 0x6e, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x73, 0x14, 0, 0x34, 0, 0x2a, 0, 0x1, 0, - 0x6, 0, 0, 0, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, - 0xe, 0, 0x1, 0, 0x7, 0, 0, 0, 0x6e, 0x56, - 0x61, 0x6c, 0x75, 0x65, 0x73, 0xf, 0, 0x14, 0, 0xb, - 0, 0x1f, 0, 0x1, 0, 0xe, 0, 0, 0, 0x54, - 0x69, 0x6d, 0x65, 0x64, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x4b, - 0x65, 0x79, 0x73, 0xa, 0, 0x5, 0, 0x80, 0xb1, 0x6, - 0xf4, 0x3b, 0x7b, 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, - 0x35, 0x94, 0xa3, 0x29, 0, 0x1, 0, 0x4, 0, 0, - 0, 0x74, 0x69, 0x6d, 0x65, 0x14, 0, 0x1, 0, 0x9, - 0, 0, 0, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x4b, 0x65, - 0x79, 0x73, 0x1, 0, 0x6, 0, 0, 0, 0x74, 0x66, - 0x6b, 0x65, 0x79, 0x73, 0x14, 0, 0xb, 0, 0x1f, 0, - 0x1, 0, 0xc, 0, 0, 0, 0x41, 0x6e, 0x69, 0x6d, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0xa, 0, - 0x5, 0, 0xa8, 0x46, 0xdd, 0x10, 0x5b, 0x77, 0xcf, 0x11, - 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, 0x29, 0, - 0x1, 0, 0x7, 0, 0, 0, 0x6b, 0x65, 0x79, 0x54, - 0x79, 0x70, 0x65, 0x14, 0, 0x29, 0, 0x1, 0, 0x5, - 0, 0, 0, 0x6e, 0x4b, 0x65, 0x79, 0x73, 0x14, 0, - 0x34, 0, 0x1, 0, 0xe, 0, 0, 0, 0x54, 0x69, - 0x6d, 0x65, 0x64, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x4b, 0x65, - 0x79, 0x73, 0x1, 0, 0x4, 0, 0, 0, 0x6b, 0x65, - 0x79, 0x73, 0xe, 0, 0x1, 0, 0x5, 0, 0, 0, - 0x6e, 0x4b, 0x65, 0x79, 0x73, 0xf, 0, 0x14, 0, 0xb, - 0, 0x1f, 0, 0x1, 0, 0x10, 0, 0, 0, 0x41, - 0x6e, 0x69, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xa, 0, 0x5, 0, 0xc0, - 0x56, 0xbf, 0xe2, 0xf, 0x84, 0xcf, 0x11, 0x8f, 0x52, 0, - 0x40, 0x33, 0x35, 0x94, 0xa3, 0x29, 0, 0x1, 0, 0xa, - 0, 0, 0, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6c, 0x6f, - 0x73, 0x65, 0x64, 0x14, 0, 0x29, 0, 0x1, 0, 0xf, - 0, 0, 0, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x71, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x14, 0, - 0xb, 0, 0x1f, 0, 0x1, 0, 0x9, 0, 0, 0, - 0x41, 0x6e, 0x69, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xa, - 0, 0x5, 0, 0x4f, 0xab, 0x82, 0x3d, 0xda, 0x62, 0xcf, - 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, 0x33, 0xe, - 0, 0x12, 0, 0x12, 0, 0x12, 0, 0xf, 0, 0xb, - 0, 0x1f, 0, 0x1, 0, 0xc, 0, 0, 0, 0x41, - 0x6e, 0x69, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, - 0x74, 0xa, 0, 0x5, 0, 0x50, 0xab, 0x82, 0x3d, 0xda, - 0x62, 0xcf, 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, - 0x33, 0xe, 0, 0x1, 0, 0x9, 0, 0, 0, 0x41, - 0x6e, 0x69, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xf, 0, - 0xb, 0, 0x1f, 0, 0x1, 0, 0xa, 0, 0, 0, - 0x49, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x44, 0x61, 0x74, 0x61, - 0xa, 0, 0x5, 0, 0xa0, 0xee, 0x23, 0x3a, 0xb1, 0x94, - 0xd0, 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, 0x33, - 0xe, 0, 0x1, 0, 0x6, 0, 0, 0, 0x42, 0x49, - 0x4e, 0x41, 0x52, 0x59, 0xf, 0, 0xb, 0, 0x1f, 0, - 0x1, 0, 0x3, 0, 0, 0, 0x55, 0x72, 0x6c, 0xa, - 0, 0x5, 0, 0xa1, 0xee, 0x23, 0x3a, 0xb1, 0x94, 0xd0, - 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, 0x33, 0x29, - 0, 0x1, 0, 0x5, 0, 0, 0, 0x6e, 0x55, 0x72, - 0x6c, 0x73, 0x14, 0, 0x34, 0, 0x31, 0, 0x1, 0, - 0x4, 0, 0, 0, 0x75, 0x72, 0x6c, 0x73, 0xe, 0, - 0x1, 0, 0x5, 0, 0, 0, 0x6e, 0x55, 0x72, 0x6c, - 0x73, 0xf, 0, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, - 0, 0xf, 0, 0, 0, 0x50, 0x72, 0x6f, 0x67, 0x72, - 0x65, 0x73, 0x73, 0x69, 0x76, 0x65, 0x4d, 0x65, 0x73, 0x68, - 0xa, 0, 0x5, 0, 0x60, 0xc3, 0x63, 0x8a, 0x7d, 0x99, - 0xd0, 0x11, 0x94, 0x1c, 0, 0x80, 0xc8, 0xc, 0xfa, 0x7b, - 0xe, 0, 0x1, 0, 0x3, 0, 0, 0, 0x55, 0x72, - 0x6c, 0x13, 0, 0x1, 0, 0xa, 0, 0, 0, 0x49, - 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x44, 0x61, 0x74, 0x61, 0xf, - 0, 0xb, 0, 0x1f, 0, 0x1, 0, 0x4, 0, 0, - 0, 0x47, 0x75, 0x69, 0x64, 0xa, 0, 0x5, 0, 0xe0, - 0x90, 0x27, 0xa4, 0x10, 0x78, 0xcf, 0x11, 0x8f, 0x52, 0, - 0x40, 0x33, 0x35, 0x94, 0xa3, 0x29, 0, 0x1, 0, 0x5, - 0, 0, 0, 0x64, 0x61, 0x74, 0x61, 0x31, 0x14, 0, - 0x28, 0, 0x1, 0, 0x5, 0, 0, 0, 0x64, 0x61, - 0x74, 0x61, 0x32, 0x14, 0, 0x28, 0, 0x1, 0, 0x5, - 0, 0, 0, 0x64, 0x61, 0x74, 0x61, 0x33, 0x14, 0, - 0x34, 0, 0x2d, 0, 0x1, 0, 0x5, 0, 0, 0, - 0x64, 0x61, 0x74, 0x61, 0x34, 0xe, 0, 0x3, 0, 0x8, - 0, 0, 0, 0xf, 0, 0x14, 0, 0xb, 0, 0x1f, - 0, 0x1, 0, 0xe, 0, 0, 0, 0x53, 0x74, 0x72, - 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, - 0x79, 0xa, 0, 0x5, 0, 0xe0, 0x21, 0xf, 0x7f, 0xe1, - 0xbf, 0xd1, 0x11, 0x82, 0xc0, 0, 0xa0, 0xc9, 0x69, 0x72, - 0x71, 0x31, 0, 0x1, 0, 0x3, 0, 0, 0, 0x6b, - 0x65, 0x79, 0x14, 0, 0x31, 0, 0x1, 0, 0x5, 0, - 0, 0, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x14, 0, 0xb, - 0, 0x1f, 0, 0x1, 0, 0xb, 0, 0, 0, 0x50, - 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x42, 0x61, 0x67, - 0xa, 0, 0x5, 0, 0xe1, 0x21, 0xf, 0x7f, 0xe1, 0xbf, - 0xd1, 0x11, 0x82, 0xc0, 0, 0xa0, 0xc9, 0x69, 0x72, 0x71, - 0xe, 0, 0x1, 0, 0xe, 0, 0, 0, 0x53, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, - 0x74, 0x79, 0xf, 0, 0xb, 0, 0x1f, 0, 0x1, 0, - 0xe, 0, 0, 0, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, - 0x61, 0x6c, 0x56, 0x69, 0x73, 0x75, 0x61, 0x6c, 0xa, 0, - 0x5, 0, 0xa0, 0x6a, 0x11, 0x98, 0xba, 0xbd, 0xd1, 0x11, - 0x82, 0xc0, 0, 0xa0, 0xc9, 0x69, 0x72, 0x71, 0x1, 0, - 0x4, 0, 0, 0, 0x47, 0x75, 0x69, 0x64, 0x1, 0, - 0x12, 0, 0, 0, 0x67, 0x75, 0x69, 0x64, 0x45, 0x78, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x56, 0x69, 0x73, 0x75, - 0x61, 0x6c, 0x14, 0, 0xe, 0, 0x12, 0, 0x12, 0, - 0x12, 0, 0xf, 0, 0xb, 0, 0x1f, 0, 0x1, 0, - 0xb, 0, 0, 0, 0x52, 0x69, 0x67, 0x68, 0x74, 0x48, - 0x61, 0x6e, 0x64, 0x65, 0x64, 0xa, 0, 0x5, 0, 0xa0, - 0x5e, 0x5d, 0x7f, 0x3a, 0xd5, 0xd1, 0x11, 0x82, 0xc0, 0, - 0xa0, 0xc9, 0x69, 0x72, 0x71, 0x29, 0, 0x1, 0, 0xc, - 0, 0, 0, 0x62, 0x52, 0x69, 0x67, 0x68, 0x74, 0x48, - 0x61, 0x6e, 0x64, 0x65, 0x64, 0x14, 0, 0xb, 0 -}; - -#define D3DRM_XTEMPLATE_BYTES 3278 - -#endif /* _RMXFTMPL_H_ */ +/* D3DRM XFile templates in binary form */ + +#ifndef _RMXFTMPL_H_ +#define _RMXFTMPL_H_ + +unsigned char D3DRM_XTEMPLATES[] = { + 0x78, 0x6f, 0x66, 0x20, 0x30, 0x33, 0x30, 0x32, 0x62, + 0x69, 0x6e, 0x20, 0x30, 0x30, 0x36, 0x34, 0x1f, 0, 0x1, + 0, 0x6, 0, 0, 0, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0xa, 0, 0x5, 0, 0x43, 0xab, 0x82, 0x3d, 0xda, + 0x62, 0xcf, 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, + 0x33, 0x28, 0, 0x1, 0, 0x5, 0, 0, 0, 0x6d, + 0x61, 0x6a, 0x6f, 0x72, 0x14, 0, 0x28, 0, 0x1, 0, + 0x5, 0, 0, 0, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x14, + 0, 0x29, 0, 0x1, 0, 0x5, 0, 0, 0, 0x66, + 0x6c, 0x61, 0x67, 0x73, 0x14, 0, 0xb, 0, 0x1f, 0, + 0x1, 0, 0x6, 0, 0, 0, 0x56, 0x65, 0x63, 0x74, + 0x6f, 0x72, 0xa, 0, 0x5, 0, 0x5e, 0xab, 0x82, 0x3d, + 0xda, 0x62, 0xcf, 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, + 0xe4, 0x33, 0x2a, 0, 0x1, 0, 0x1, 0, 0, 0, + 0x78, 0x14, 0, 0x2a, 0, 0x1, 0, 0x1, 0, 0, + 0, 0x79, 0x14, 0, 0x2a, 0, 0x1, 0, 0x1, 0, + 0, 0, 0x7a, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, + 0, 0x8, 0, 0, 0, 0x43, 0x6f, 0x6f, 0x72, 0x64, + 0x73, 0x32, 0x64, 0xa, 0, 0x5, 0, 0x44, 0x3f, 0xf2, + 0xf6, 0x86, 0x76, 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, + 0x35, 0x94, 0xa3, 0x2a, 0, 0x1, 0, 0x1, 0, 0, + 0, 0x75, 0x14, 0, 0x2a, 0, 0x1, 0, 0x1, 0, + 0, 0, 0x76, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, + 0, 0x9, 0, 0, 0, 0x4d, 0x61, 0x74, 0x72, 0x69, + 0x78, 0x34, 0x78, 0x34, 0xa, 0, 0x5, 0, 0x45, 0x3f, + 0xf2, 0xf6, 0x86, 0x76, 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, + 0x33, 0x35, 0x94, 0xa3, 0x34, 0, 0x2a, 0, 0x1, 0, + 0x6, 0, 0, 0, 0x6d, 0x61, 0x74, 0x72, 0x69, 0x78, + 0xe, 0, 0x3, 0, 0x10, 0, 0, 0, 0xf, 0, + 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, 0, 0x9, 0, + 0, 0, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x47, 0x42, + 0x41, 0xa, 0, 0x5, 0, 0xe0, 0x44, 0xff, 0x35, 0x7c, + 0x6c, 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, + 0xa3, 0x2a, 0, 0x1, 0, 0x3, 0, 0, 0, 0x72, + 0x65, 0x64, 0x14, 0, 0x2a, 0, 0x1, 0, 0x5, 0, + 0, 0, 0x67, 0x72, 0x65, 0x65, 0x6e, 0x14, 0, 0x2a, + 0, 0x1, 0, 0x4, 0, 0, 0, 0x62, 0x6c, 0x75, + 0x65, 0x14, 0, 0x2a, 0, 0x1, 0, 0x5, 0, 0, + 0, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x14, 0, 0xb, 0, + 0x1f, 0, 0x1, 0, 0x8, 0, 0, 0, 0x43, 0x6f, + 0x6c, 0x6f, 0x72, 0x52, 0x47, 0x42, 0xa, 0, 0x5, 0, + 0x81, 0x6e, 0xe1, 0xd3, 0x35, 0x78, 0xcf, 0x11, 0x8f, 0x52, + 0, 0x40, 0x33, 0x35, 0x94, 0xa3, 0x2a, 0, 0x1, 0, + 0x3, 0, 0, 0, 0x72, 0x65, 0x64, 0x14, 0, 0x2a, + 0, 0x1, 0, 0x5, 0, 0, 0, 0x67, 0x72, 0x65, + 0x65, 0x6e, 0x14, 0, 0x2a, 0, 0x1, 0, 0x4, 0, + 0, 0, 0x62, 0x6c, 0x75, 0x65, 0x14, 0, 0xb, 0, + 0x1f, 0, 0x1, 0, 0xc, 0, 0, 0, 0x49, 0x6e, + 0x64, 0x65, 0x78, 0x65, 0x64, 0x43, 0x6f, 0x6c, 0x6f, 0x72, + 0xa, 0, 0x5, 0, 0x20, 0xb8, 0x30, 0x16, 0x42, 0x78, + 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, + 0x29, 0, 0x1, 0, 0x5, 0, 0, 0, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x14, 0, 0x1, 0, 0x9, 0, 0, + 0, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x47, 0x42, 0x41, + 0x1, 0, 0xa, 0, 0, 0, 0x69, 0x6e, 0x64, 0x65, + 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x14, 0, 0xb, 0, + 0x1f, 0, 0x1, 0, 0x7, 0, 0, 0, 0x42, 0x6f, + 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0xa, 0, 0x5, 0, 0xa0, + 0xa6, 0x7d, 0x53, 0x37, 0xca, 0xd0, 0x11, 0x94, 0x1c, 0, + 0x80, 0xc8, 0xc, 0xfa, 0x7b, 0x29, 0, 0x1, 0, 0x9, + 0, 0, 0, 0x74, 0x72, 0x75, 0x65, 0x66, 0x61, 0x6c, + 0x73, 0x65, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, 0, + 0x9, 0, 0, 0, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, + 0x6e, 0x32, 0x64, 0xa, 0, 0x5, 0, 0x63, 0xae, 0x85, + 0x48, 0xe8, 0x78, 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, + 0x35, 0x94, 0xa3, 0x1, 0, 0x7, 0, 0, 0, 0x42, + 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x1, 0, 0x1, 0, + 0, 0, 0x75, 0x14, 0, 0x1, 0, 0x7, 0, 0, + 0, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x1, 0, + 0x1, 0, 0, 0, 0x76, 0x14, 0, 0xb, 0, 0x1f, + 0, 0x1, 0, 0xc, 0, 0, 0, 0x4d, 0x61, 0x74, + 0x65, 0x72, 0x69, 0x61, 0x6c, 0x57, 0x72, 0x61, 0x70, 0xa, + 0, 0x5, 0, 0x60, 0xae, 0x85, 0x48, 0xe8, 0x78, 0xcf, + 0x11, 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, 0x1, + 0, 0x7, 0, 0, 0, 0x42, 0x6f, 0x6f, 0x6c, 0x65, + 0x61, 0x6e, 0x1, 0, 0x1, 0, 0, 0, 0x75, 0x14, + 0, 0x1, 0, 0x7, 0, 0, 0, 0x42, 0x6f, 0x6f, + 0x6c, 0x65, 0x61, 0x6e, 0x1, 0, 0x1, 0, 0, 0, + 0x76, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, 0, 0xf, + 0, 0, 0, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, + 0x46, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0xa, 0, + 0x5, 0, 0xe1, 0x90, 0x27, 0xa4, 0x10, 0x78, 0xcf, 0x11, + 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, 0x31, 0, + 0x1, 0, 0x8, 0, 0, 0, 0x66, 0x69, 0x6c, 0x65, + 0x6e, 0x61, 0x6d, 0x65, 0x14, 0, 0xb, 0, 0x1f, 0, + 0x1, 0, 0x8, 0, 0, 0, 0x4d, 0x61, 0x74, 0x65, + 0x72, 0x69, 0x61, 0x6c, 0xa, 0, 0x5, 0, 0x4d, 0xab, + 0x82, 0x3d, 0xda, 0x62, 0xcf, 0x11, 0xab, 0x39, 0, 0x20, + 0xaf, 0x71, 0xe4, 0x33, 0x1, 0, 0x9, 0, 0, 0, + 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x47, 0x42, 0x41, 0x1, + 0, 0x9, 0, 0, 0, 0x66, 0x61, 0x63, 0x65, 0x43, + 0x6f, 0x6c, 0x6f, 0x72, 0x14, 0, 0x2a, 0, 0x1, 0, + 0x5, 0, 0, 0, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x14, + 0, 0x1, 0, 0x8, 0, 0, 0, 0x43, 0x6f, 0x6c, + 0x6f, 0x72, 0x52, 0x47, 0x42, 0x1, 0, 0xd, 0, 0, + 0, 0x73, 0x70, 0x65, 0x63, 0x75, 0x6c, 0x61, 0x72, 0x43, + 0x6f, 0x6c, 0x6f, 0x72, 0x14, 0, 0x1, 0, 0x8, 0, + 0, 0, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x47, 0x42, + 0x1, 0, 0xd, 0, 0, 0, 0x65, 0x6d, 0x69, 0x73, + 0x73, 0x69, 0x76, 0x65, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x14, + 0, 0xe, 0, 0x12, 0, 0x12, 0, 0x12, 0, 0xf, + 0, 0xb, 0, 0x1f, 0, 0x1, 0, 0x8, 0, 0, + 0, 0x4d, 0x65, 0x73, 0x68, 0x46, 0x61, 0x63, 0x65, 0xa, + 0, 0x5, 0, 0x5f, 0xab, 0x82, 0x3d, 0xda, 0x62, 0xcf, + 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, 0x33, 0x29, + 0, 0x1, 0, 0x12, 0, 0, 0, 0x6e, 0x46, 0x61, + 0x63, 0x65, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x49, 0x6e, + 0x64, 0x69, 0x63, 0x65, 0x73, 0x14, 0, 0x34, 0, 0x29, + 0, 0x1, 0, 0x11, 0, 0, 0, 0x66, 0x61, 0x63, + 0x65, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x49, 0x6e, 0x64, + 0x69, 0x63, 0x65, 0x73, 0xe, 0, 0x1, 0, 0x12, 0, + 0, 0, 0x6e, 0x46, 0x61, 0x63, 0x65, 0x56, 0x65, 0x72, + 0x74, 0x65, 0x78, 0x49, 0x6e, 0x64, 0x69, 0x63, 0x65, 0x73, + 0xf, 0, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, 0, + 0xd, 0, 0, 0, 0x4d, 0x65, 0x73, 0x68, 0x46, 0x61, + 0x63, 0x65, 0x57, 0x72, 0x61, 0x70, 0x73, 0xa, 0, 0x5, + 0, 0xc0, 0xc5, 0x1e, 0xed, 0xa8, 0xc0, 0xd0, 0x11, 0x94, + 0x1c, 0, 0x80, 0xc8, 0xc, 0xfa, 0x7b, 0x29, 0, 0x1, + 0, 0xf, 0, 0, 0, 0x6e, 0x46, 0x61, 0x63, 0x65, + 0x57, 0x72, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, + 0x14, 0, 0x34, 0, 0x1, 0, 0x9, 0, 0, 0, + 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x32, 0x64, 0x1, + 0, 0xe, 0, 0, 0, 0x66, 0x61, 0x63, 0x65, 0x57, + 0x72, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0xe, + 0, 0x1, 0, 0xf, 0, 0, 0, 0x6e, 0x46, 0x61, + 0x63, 0x65, 0x57, 0x72, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x73, 0xf, 0, 0x14, 0, 0xb, 0, 0x1f, 0, + 0x1, 0, 0x11, 0, 0, 0, 0x4d, 0x65, 0x73, 0x68, + 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, 0x6f, + 0x72, 0x64, 0x73, 0xa, 0, 0x5, 0, 0x40, 0x3f, 0xf2, + 0xf6, 0x86, 0x76, 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, + 0x35, 0x94, 0xa3, 0x29, 0, 0x1, 0, 0xe, 0, 0, + 0, 0x6e, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x43, + 0x6f, 0x6f, 0x72, 0x64, 0x73, 0x14, 0, 0x34, 0, 0x1, + 0, 0x8, 0, 0, 0, 0x43, 0x6f, 0x6f, 0x72, 0x64, + 0x73, 0x32, 0x64, 0x1, 0, 0xd, 0, 0, 0, 0x74, + 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, 0x6f, 0x72, + 0x64, 0x73, 0xe, 0, 0x1, 0, 0xe, 0, 0, 0, + 0x6e, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, + 0x6f, 0x72, 0x64, 0x73, 0xf, 0, 0x14, 0, 0xb, 0, + 0x1f, 0, 0x1, 0, 0x10, 0, 0, 0, 0x4d, 0x65, + 0x73, 0x68, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, + 0x4c, 0x69, 0x73, 0x74, 0xa, 0, 0x5, 0, 0x42, 0x3f, + 0xf2, 0xf6, 0x86, 0x76, 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, + 0x33, 0x35, 0x94, 0xa3, 0x29, 0, 0x1, 0, 0xa, 0, + 0, 0, 0x6e, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, + 0x6c, 0x73, 0x14, 0, 0x29, 0, 0x1, 0, 0xc, 0, + 0, 0, 0x6e, 0x46, 0x61, 0x63, 0x65, 0x49, 0x6e, 0x64, + 0x65, 0x78, 0x65, 0x73, 0x14, 0, 0x34, 0, 0x29, 0, + 0x1, 0, 0xb, 0, 0, 0, 0x66, 0x61, 0x63, 0x65, + 0x49, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0xe, 0, 0x1, + 0, 0xc, 0, 0, 0, 0x6e, 0x46, 0x61, 0x63, 0x65, + 0x49, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0xf, 0, 0x14, + 0, 0xe, 0, 0x1, 0, 0x8, 0, 0, 0, 0x4d, + 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0xf, 0, 0xb, + 0, 0x1f, 0, 0x1, 0, 0xb, 0, 0, 0, 0x4d, + 0x65, 0x73, 0x68, 0x4e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x73, + 0xa, 0, 0x5, 0, 0x43, 0x3f, 0xf2, 0xf6, 0x86, 0x76, + 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, + 0x29, 0, 0x1, 0, 0x8, 0, 0, 0, 0x6e, 0x4e, + 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x73, 0x14, 0, 0x34, 0, + 0x1, 0, 0x6, 0, 0, 0, 0x56, 0x65, 0x63, 0x74, + 0x6f, 0x72, 0x1, 0, 0x7, 0, 0, 0, 0x6e, 0x6f, + 0x72, 0x6d, 0x61, 0x6c, 0x73, 0xe, 0, 0x1, 0, 0x8, + 0, 0, 0, 0x6e, 0x4e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, + 0x73, 0xf, 0, 0x14, 0, 0x29, 0, 0x1, 0, 0xc, + 0, 0, 0, 0x6e, 0x46, 0x61, 0x63, 0x65, 0x4e, 0x6f, + 0x72, 0x6d, 0x61, 0x6c, 0x73, 0x14, 0, 0x34, 0, 0x1, + 0, 0x8, 0, 0, 0, 0x4d, 0x65, 0x73, 0x68, 0x46, + 0x61, 0x63, 0x65, 0x1, 0, 0xb, 0, 0, 0, 0x66, + 0x61, 0x63, 0x65, 0x4e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x73, + 0xe, 0, 0x1, 0, 0xc, 0, 0, 0, 0x6e, 0x46, + 0x61, 0x63, 0x65, 0x4e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x73, + 0xf, 0, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, 0, + 0x10, 0, 0, 0, 0x4d, 0x65, 0x73, 0x68, 0x56, 0x65, + 0x72, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x73, + 0xa, 0, 0x5, 0, 0x21, 0xb8, 0x30, 0x16, 0x42, 0x78, + 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, + 0x29, 0, 0x1, 0, 0xd, 0, 0, 0, 0x6e, 0x56, + 0x65, 0x72, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, + 0x73, 0x14, 0, 0x34, 0, 0x1, 0, 0xc, 0, 0, + 0, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x64, 0x43, 0x6f, + 0x6c, 0x6f, 0x72, 0x1, 0, 0xc, 0, 0, 0, 0x76, + 0x65, 0x72, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, + 0x73, 0xe, 0, 0x1, 0, 0xd, 0, 0, 0, 0x6e, + 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, + 0x72, 0x73, 0xf, 0, 0x14, 0, 0xb, 0, 0x1f, 0, + 0x1, 0, 0x4, 0, 0, 0, 0x4d, 0x65, 0x73, 0x68, + 0xa, 0, 0x5, 0, 0x44, 0xab, 0x82, 0x3d, 0xda, 0x62, + 0xcf, 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, 0x33, + 0x29, 0, 0x1, 0, 0x9, 0, 0, 0, 0x6e, 0x56, + 0x65, 0x72, 0x74, 0x69, 0x63, 0x65, 0x73, 0x14, 0, 0x34, + 0, 0x1, 0, 0x6, 0, 0, 0, 0x56, 0x65, 0x63, + 0x74, 0x6f, 0x72, 0x1, 0, 0x8, 0, 0, 0, 0x76, + 0x65, 0x72, 0x74, 0x69, 0x63, 0x65, 0x73, 0xe, 0, 0x1, + 0, 0x9, 0, 0, 0, 0x6e, 0x56, 0x65, 0x72, 0x74, + 0x69, 0x63, 0x65, 0x73, 0xf, 0, 0x14, 0, 0x29, 0, + 0x1, 0, 0x6, 0, 0, 0, 0x6e, 0x46, 0x61, 0x63, + 0x65, 0x73, 0x14, 0, 0x34, 0, 0x1, 0, 0x8, 0, + 0, 0, 0x4d, 0x65, 0x73, 0x68, 0x46, 0x61, 0x63, 0x65, + 0x1, 0, 0x5, 0, 0, 0, 0x66, 0x61, 0x63, 0x65, + 0x73, 0xe, 0, 0x1, 0, 0x6, 0, 0, 0, 0x6e, + 0x46, 0x61, 0x63, 0x65, 0x73, 0xf, 0, 0x14, 0, 0xe, + 0, 0x12, 0, 0x12, 0, 0x12, 0, 0xf, 0, 0xb, + 0, 0x1f, 0, 0x1, 0, 0x14, 0, 0, 0, 0x46, + 0x72, 0x61, 0x6d, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, + 0x6f, 0x72, 0x6d, 0x4d, 0x61, 0x74, 0x72, 0x69, 0x78, 0xa, + 0, 0x5, 0, 0x41, 0x3f, 0xf2, 0xf6, 0x86, 0x76, 0xcf, + 0x11, 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, 0x1, + 0, 0x9, 0, 0, 0, 0x4d, 0x61, 0x74, 0x72, 0x69, + 0x78, 0x34, 0x78, 0x34, 0x1, 0, 0xb, 0, 0, 0, + 0x66, 0x72, 0x61, 0x6d, 0x65, 0x4d, 0x61, 0x74, 0x72, 0x69, + 0x78, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, 0, 0x5, + 0, 0, 0, 0x46, 0x72, 0x61, 0x6d, 0x65, 0xa, 0, + 0x5, 0, 0x46, 0xab, 0x82, 0x3d, 0xda, 0x62, 0xcf, 0x11, + 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, 0x33, 0xe, 0, + 0x12, 0, 0x12, 0, 0x12, 0, 0xf, 0, 0xb, 0, + 0x1f, 0, 0x1, 0, 0x9, 0, 0, 0, 0x46, 0x6c, + 0x6f, 0x61, 0x74, 0x4b, 0x65, 0x79, 0x73, 0xa, 0, 0x5, + 0, 0xa9, 0x46, 0xdd, 0x10, 0x5b, 0x77, 0xcf, 0x11, 0x8f, + 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, 0x29, 0, 0x1, + 0, 0x7, 0, 0, 0, 0x6e, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x73, 0x14, 0, 0x34, 0, 0x2a, 0, 0x1, 0, + 0x6, 0, 0, 0, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, + 0xe, 0, 0x1, 0, 0x7, 0, 0, 0, 0x6e, 0x56, + 0x61, 0x6c, 0x75, 0x65, 0x73, 0xf, 0, 0x14, 0, 0xb, + 0, 0x1f, 0, 0x1, 0, 0xe, 0, 0, 0, 0x54, + 0x69, 0x6d, 0x65, 0x64, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x4b, + 0x65, 0x79, 0x73, 0xa, 0, 0x5, 0, 0x80, 0xb1, 0x6, + 0xf4, 0x3b, 0x7b, 0xcf, 0x11, 0x8f, 0x52, 0, 0x40, 0x33, + 0x35, 0x94, 0xa3, 0x29, 0, 0x1, 0, 0x4, 0, 0, + 0, 0x74, 0x69, 0x6d, 0x65, 0x14, 0, 0x1, 0, 0x9, + 0, 0, 0, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x4b, 0x65, + 0x79, 0x73, 0x1, 0, 0x6, 0, 0, 0, 0x74, 0x66, + 0x6b, 0x65, 0x79, 0x73, 0x14, 0, 0xb, 0, 0x1f, 0, + 0x1, 0, 0xc, 0, 0, 0, 0x41, 0x6e, 0x69, 0x6d, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0xa, 0, + 0x5, 0, 0xa8, 0x46, 0xdd, 0x10, 0x5b, 0x77, 0xcf, 0x11, + 0x8f, 0x52, 0, 0x40, 0x33, 0x35, 0x94, 0xa3, 0x29, 0, + 0x1, 0, 0x7, 0, 0, 0, 0x6b, 0x65, 0x79, 0x54, + 0x79, 0x70, 0x65, 0x14, 0, 0x29, 0, 0x1, 0, 0x5, + 0, 0, 0, 0x6e, 0x4b, 0x65, 0x79, 0x73, 0x14, 0, + 0x34, 0, 0x1, 0, 0xe, 0, 0, 0, 0x54, 0x69, + 0x6d, 0x65, 0x64, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x4b, 0x65, + 0x79, 0x73, 0x1, 0, 0x4, 0, 0, 0, 0x6b, 0x65, + 0x79, 0x73, 0xe, 0, 0x1, 0, 0x5, 0, 0, 0, + 0x6e, 0x4b, 0x65, 0x79, 0x73, 0xf, 0, 0x14, 0, 0xb, + 0, 0x1f, 0, 0x1, 0, 0x10, 0, 0, 0, 0x41, + 0x6e, 0x69, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xa, 0, 0x5, 0, 0xc0, + 0x56, 0xbf, 0xe2, 0xf, 0x84, 0xcf, 0x11, 0x8f, 0x52, 0, + 0x40, 0x33, 0x35, 0x94, 0xa3, 0x29, 0, 0x1, 0, 0xa, + 0, 0, 0, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6c, 0x6f, + 0x73, 0x65, 0x64, 0x14, 0, 0x29, 0, 0x1, 0, 0xf, + 0, 0, 0, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x71, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x14, 0, + 0xb, 0, 0x1f, 0, 0x1, 0, 0x9, 0, 0, 0, + 0x41, 0x6e, 0x69, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xa, + 0, 0x5, 0, 0x4f, 0xab, 0x82, 0x3d, 0xda, 0x62, 0xcf, + 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, 0x33, 0xe, + 0, 0x12, 0, 0x12, 0, 0x12, 0, 0xf, 0, 0xb, + 0, 0x1f, 0, 0x1, 0, 0xc, 0, 0, 0, 0x41, + 0x6e, 0x69, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, + 0x74, 0xa, 0, 0x5, 0, 0x50, 0xab, 0x82, 0x3d, 0xda, + 0x62, 0xcf, 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, + 0x33, 0xe, 0, 0x1, 0, 0x9, 0, 0, 0, 0x41, + 0x6e, 0x69, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xf, 0, + 0xb, 0, 0x1f, 0, 0x1, 0, 0xa, 0, 0, 0, + 0x49, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x44, 0x61, 0x74, 0x61, + 0xa, 0, 0x5, 0, 0xa0, 0xee, 0x23, 0x3a, 0xb1, 0x94, + 0xd0, 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, 0x33, + 0xe, 0, 0x1, 0, 0x6, 0, 0, 0, 0x42, 0x49, + 0x4e, 0x41, 0x52, 0x59, 0xf, 0, 0xb, 0, 0x1f, 0, + 0x1, 0, 0x3, 0, 0, 0, 0x55, 0x72, 0x6c, 0xa, + 0, 0x5, 0, 0xa1, 0xee, 0x23, 0x3a, 0xb1, 0x94, 0xd0, + 0x11, 0xab, 0x39, 0, 0x20, 0xaf, 0x71, 0xe4, 0x33, 0x29, + 0, 0x1, 0, 0x5, 0, 0, 0, 0x6e, 0x55, 0x72, + 0x6c, 0x73, 0x14, 0, 0x34, 0, 0x31, 0, 0x1, 0, + 0x4, 0, 0, 0, 0x75, 0x72, 0x6c, 0x73, 0xe, 0, + 0x1, 0, 0x5, 0, 0, 0, 0x6e, 0x55, 0x72, 0x6c, + 0x73, 0xf, 0, 0x14, 0, 0xb, 0, 0x1f, 0, 0x1, + 0, 0xf, 0, 0, 0, 0x50, 0x72, 0x6f, 0x67, 0x72, + 0x65, 0x73, 0x73, 0x69, 0x76, 0x65, 0x4d, 0x65, 0x73, 0x68, + 0xa, 0, 0x5, 0, 0x60, 0xc3, 0x63, 0x8a, 0x7d, 0x99, + 0xd0, 0x11, 0x94, 0x1c, 0, 0x80, 0xc8, 0xc, 0xfa, 0x7b, + 0xe, 0, 0x1, 0, 0x3, 0, 0, 0, 0x55, 0x72, + 0x6c, 0x13, 0, 0x1, 0, 0xa, 0, 0, 0, 0x49, + 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x44, 0x61, 0x74, 0x61, 0xf, + 0, 0xb, 0, 0x1f, 0, 0x1, 0, 0x4, 0, 0, + 0, 0x47, 0x75, 0x69, 0x64, 0xa, 0, 0x5, 0, 0xe0, + 0x90, 0x27, 0xa4, 0x10, 0x78, 0xcf, 0x11, 0x8f, 0x52, 0, + 0x40, 0x33, 0x35, 0x94, 0xa3, 0x29, 0, 0x1, 0, 0x5, + 0, 0, 0, 0x64, 0x61, 0x74, 0x61, 0x31, 0x14, 0, + 0x28, 0, 0x1, 0, 0x5, 0, 0, 0, 0x64, 0x61, + 0x74, 0x61, 0x32, 0x14, 0, 0x28, 0, 0x1, 0, 0x5, + 0, 0, 0, 0x64, 0x61, 0x74, 0x61, 0x33, 0x14, 0, + 0x34, 0, 0x2d, 0, 0x1, 0, 0x5, 0, 0, 0, + 0x64, 0x61, 0x74, 0x61, 0x34, 0xe, 0, 0x3, 0, 0x8, + 0, 0, 0, 0xf, 0, 0x14, 0, 0xb, 0, 0x1f, + 0, 0x1, 0, 0xe, 0, 0, 0, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, + 0x79, 0xa, 0, 0x5, 0, 0xe0, 0x21, 0xf, 0x7f, 0xe1, + 0xbf, 0xd1, 0x11, 0x82, 0xc0, 0, 0xa0, 0xc9, 0x69, 0x72, + 0x71, 0x31, 0, 0x1, 0, 0x3, 0, 0, 0, 0x6b, + 0x65, 0x79, 0x14, 0, 0x31, 0, 0x1, 0, 0x5, 0, + 0, 0, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x14, 0, 0xb, + 0, 0x1f, 0, 0x1, 0, 0xb, 0, 0, 0, 0x50, + 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x42, 0x61, 0x67, + 0xa, 0, 0x5, 0, 0xe1, 0x21, 0xf, 0x7f, 0xe1, 0xbf, + 0xd1, 0x11, 0x82, 0xc0, 0, 0xa0, 0xc9, 0x69, 0x72, 0x71, + 0xe, 0, 0x1, 0, 0xe, 0, 0, 0, 0x53, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, + 0x74, 0x79, 0xf, 0, 0xb, 0, 0x1f, 0, 0x1, 0, + 0xe, 0, 0, 0, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x56, 0x69, 0x73, 0x75, 0x61, 0x6c, 0xa, 0, + 0x5, 0, 0xa0, 0x6a, 0x11, 0x98, 0xba, 0xbd, 0xd1, 0x11, + 0x82, 0xc0, 0, 0xa0, 0xc9, 0x69, 0x72, 0x71, 0x1, 0, + 0x4, 0, 0, 0, 0x47, 0x75, 0x69, 0x64, 0x1, 0, + 0x12, 0, 0, 0, 0x67, 0x75, 0x69, 0x64, 0x45, 0x78, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x56, 0x69, 0x73, 0x75, + 0x61, 0x6c, 0x14, 0, 0xe, 0, 0x12, 0, 0x12, 0, + 0x12, 0, 0xf, 0, 0xb, 0, 0x1f, 0, 0x1, 0, + 0xb, 0, 0, 0, 0x52, 0x69, 0x67, 0x68, 0x74, 0x48, + 0x61, 0x6e, 0x64, 0x65, 0x64, 0xa, 0, 0x5, 0, 0xa0, + 0x5e, 0x5d, 0x7f, 0x3a, 0xd5, 0xd1, 0x11, 0x82, 0xc0, 0, + 0xa0, 0xc9, 0x69, 0x72, 0x71, 0x29, 0, 0x1, 0, 0xc, + 0, 0, 0, 0x62, 0x52, 0x69, 0x67, 0x68, 0x74, 0x48, + 0x61, 0x6e, 0x64, 0x65, 0x64, 0x14, 0, 0xb, 0 +}; + +#define D3DRM_XTEMPLATE_BYTES 3278 + +#endif /* _RMXFTMPL_H_ */ diff --git a/src/dep/include/DXSDK/include/rpcsal.h b/src/dep/include/DXSDK/include/rpcsal.h index 62b1ec4..996bd33 100644 --- a/src/dep/include/DXSDK/include/rpcsal.h +++ b/src/dep/include/DXSDK/include/rpcsal.h @@ -1,386 +1,386 @@ -/****************************************************************\ -* * -* rpcsal.h - markers for documenting the semantics of RPC APIs * -* * -* Version 1.0 * -* * -* Copyright (c) 2004 Microsoft Corporation. All rights reserved. * -* * -\****************************************************************/ - -// ------------------------------------------------------------------------------- -// Introduction -// -// rpcsal.h provides a set of annotations to describe how RPC functions use their -// parameters - the assumptions it makes about them, adn the guarantees it makes -// upon finishing. These annotations are similar to those found in specstrings.h, -// but are designed to be used by the MIDL compiler when it generates annotations -// enabled header files. -// -// IDL authors do not need to annotate their functions declarations. The MIDL compiler -// will interpret the IDL directives and use one of the annotations contained -// in this header. This documentation is intended to help those trying to understand -// the MIDL-generated header files or those who maintain their own copies of these files. -// -// ------------------------------------------------------------------------------- -// Differences between rpcsal.h and specstrings.h -// -// There are a few important differences between the annotations found in rpcsal.h and -// those in specstrings.h: -// -// 1. [in] parameters are not marked as read-only. They may be used for scratch space -// at the server and changes will not affect the client. -// 2. String versions of each macro alleviates the need for a special type definition -// -// ------------------------------------------------------------------------------- -// Interpreting RPC Annotations -// -// These annotations are interpreted precisely in the same way as those in specstrings.h. -// Please refer to that header for information related to general usage in annotations. -// -// To construct an RPC annotation, concatenate the appropriate value from each category -// along with a leading __RPC_. A typical annotation looks like "__RPC__in_string". -// -// |----------------------------------------------------------------------------------| -// | RPC Annotations | -// |------------|------------|---------|--------|----------|----------|---------------| -// | Level | Usage | Size | Output | Optional | String | Parameters | -// |------------|------------|---------|--------|----------|----------|---------------| -// | <> | <> | <> | <> | <> | <> | <> | -// | _deref | _in | _ecount | _full | _opt | _string | (size) | -// | _deref_opt | _out | _bcount | _part | | | (size,length) | -// | | _inout | | | | | | -// | | | | | | | | -// |------------|------------|---------|--------|----------|----------|---------------| -// -// Level: Describes the buffer pointer's level of indirection from the parameter or -// return value 'p'. -// -// <> : p is the buffer pointer. -// _deref : *p is the buffer pointer. p must not be NULL. -// _deref_opt : *p may be the buffer pointer. p may be NULL, in which case the rest of -// the annotation is ignored. -// -// Usage: Describes how the function uses the buffer. -// -// <> : The buffer is not accessed. If used on the return value or with _deref, the -// function will provide the buffer, and it will be uninitialized at exit. -// Otherwise, the caller must provide the buffer. This should only be used -// for alloc and free functions. -// _in : The function will only read from the buffer. The caller must provide the -// buffer and initialize it. Cannot be used with _deref. -// _out : The function will only write to the buffer. If used on the return value or -// with _deref, the function will provide the buffer and initialize it. -// Otherwise, the caller must provide the buffer, and the function will -// initialize it. -// _inout : The function may freely read from and write to the buffer. The caller must -// provide the buffer and initialize it. If used with _deref, the buffer may -// be reallocated by the function. -// -// Size: Describes the total size of the buffer. This may be less than the space actually -// allocated for the buffer, in which case it describes the accessible amount. -// -// <> : No buffer size is given. If the type specifies the buffer size (such as -// with LPSTR and LPWSTR), that amount is used. Otherwise, the buffer is one -// element long. Must be used with _in, _out, or _inout. -// _ecount : The buffer size is an explicit element count. -// _bcount : The buffer size is an explicit byte count. -// -// Output: Describes how much of the buffer will be initialized by the function. For -// _inout buffers, this also describes how much is initialized at entry. Omit this -// category for _in buffers; they must be fully initialized by the caller. -// -// <> : The type specifies how much is initialized. For instance, a function initializing -// an LPWSTR must NULL-terminate the string. -// _full : The function initializes the entire buffer. -// _part : The function initializes part of the buffer, and explicitly indicates how much. -// -// Optional: Describes if the buffer itself is optional. -// -// <> : The pointer to the buffer must not be NULL. -// _opt : The pointer to the buffer might be NULL. It will be checked before being dereferenced. -// -// String: Describes if the buffer is NULL terminated -// -// <> : The buffer is not assumed to be NULL terminated -// _string : The buffer is assumed to be NULL terminated once it has been initialized -// -// Parameters: Gives explicit counts for the size and length of the buffer. -// -// <> : There is no explicit count. Use when neither _ecount nor _bcount is used. -// (size) : Only the buffer's total size is given. Use with _ecount or _bcount but not _part. -// (size,length) : The buffer's total size and initialized length are given. Use with _ecount_part -// and _bcount_part. -// -// Notes: -// -// 1. Specifying two buffer annotations on a single parameter results in unspecified behavior -// (e.g. __RPC__in_bcount(5) __RPC__out_bcount(6) -// -// 2. The size of the buffer and the amount that has been initialized are separate concepts. -// Specify the size using _ecount or _bcount. Specify the amount that is initialized using -// _full, _part, or _string. As a special case, a single element buffer does not need -// _ecount, _bcount, _full, or _part -// -// 3. The count may be less than the total size of the buffer in which case it describes the -// accessible portion. -// -// 4. "__RPC__opt" and "__RPC_deref" are not valid annotations. -// -// 5. The placement of _opt when using _deref is important: -// __RPC__deref_opt_... : Input may be NULL -// __RPC__deref_..._opt : Output may be NULL -// __RPC__deref_opt_..._opt : Both input and output may be NULL -// - -#pragma once - -#include - -#ifndef __RPCSAL_H_VERSION__ -#define __RPCSAL_H_VERSION__ ( 100 ) -#endif // __RPCSAL_H_VERSION__ - -#ifdef __REQUIRED_RPCSAL_H_VERSION__ - #if ( __RPCSAL_H_VERSION__ < __REQUIRED_RPCSAL_H_VERSION__ ) - #error incorrect version. Use the header that matches with the MIDL compiler. - #endif -#endif - - -#ifdef __cplusplus -extern "C" { -#endif // #ifdef __cplusplus - -#if (_MSC_VER >= 1000) && !defined(__midl) && defined(_PREFAST_) - - -// [in] -#define __RPC__in __pre __valid -#define __RPC__in_string __RPC__in __pre __nullterminated -#define __RPC__in_ecount(size) __RPC__in __pre __elem_readableTo(size) -#define __RPC__in_ecount_full(size) __RPC__in_ecount(size) -#define __RPC__in_ecount_full_string(size) __RPC__in_ecount_full(size) __pre __nullterminated -#define __RPC__in_ecount_part(size, length) __RPC__in_ecount(length) __pre __elem_writableTo(size) -#define __RPC__in_ecount_full_opt(size) __RPC__in_ecount_full(size) __pre __exceptthat __maybenull -#define __RPC__in_ecount_full_opt_string(size) __RPC__in_ecount_full_opt(size) __pre __nullterminated -#define __RPC__in_ecount_part_opt(size, length) __RPC__in_ecount_part(size, length) __pre __exceptthat __maybenull - - -#define __RPC__deref_in __RPC__in __deref __notnull -#define __RPC__deref_in_string __RPC__in __pre __deref __nullterminated -#define __RPC__deref_in_opt __RPC__deref_in __deref __exceptthat __maybenull -#define __RPC__deref_opt_in __RPC__in __exceptthat __maybenull -#define __RPC__deref_opt_in_opt __RPC__deref_opt_in __pre __deref __exceptthat __maybenull -#define __RPC__deref_in_ecount(size) __RPC__in __pre __deref __elem_readableTo(size) -#define __RPC__deref_in_ecount_part(size, length) __RPC__deref_in_ecount(size) __pre __deref __elem_readableTo(length) -#define __RPC__deref_in_ecount_full(size) __RPC__deref_in_ecount_part(size, size) -#define __RPC__deref_in_ecount_full_opt(size) __RPC__deref_in_ecount_full(size) __pre __deref __exceptthat __maybenull -#define __RPC__deref_in_ecount_full_opt_string(size) __RPC__deref_in_ecount_full_opt(size) __pre __deref __nullterminated -#define __RPC__deref_in_ecount_full_string(size) __RPC__deref_in_ecount_full(size) __pre __deref __nullterminated -#define __RPC__deref_in_ecount_opt(size) __RPC__deref_in_ecount(size) __pre __deref __exceptthat __maybenull -#define __RPC__deref_in_ecount_opt_string(size) __RPC__deref_in_ecount_opt(size) __pre __deref __nullterminated -#define __RPC__deref_in_ecount_part_opt(size, length) __RPC__deref_in_ecount_opt(size) __pre __deref __elem_readableTo(length) - - -// [out] -#define __RPC__out __out -#define __RPC__out_ecount(size) __out_ecount(size) __post __elem_writableTo(size) -#define __RPC__out_ecount_string(size) __RPC__out_ecount(size) __post __nullterminated -#define __RPC__out_ecount_part(size, length) __RPC__out_ecount(size) __post __elem_readableTo(length) -#define __RPC__out_ecount_full(size) __RPC__out_ecount_part(size, size) -#define __RPC__out_ecount_full_string(size) __RPC__out_ecount_full(size) __post __nullterminated - -// [in,out] -#define __RPC__inout __inout -#define __RPC__inout_string __RPC__inout __pre __nullterminated __post __nullterminated -#define __RPC__inout_ecount(size) __inout_ecount(size) -#define __RPC__inout_ecount_part(size, length) __inout_ecount_part(size, length) -#define __RPC__inout_ecount_full(size) __RPC__inout_ecount_part(size, size) -#define __RPC__inout_ecount_full_string(size) __RPC__inout_ecount_full(size) __pre __nullterminated __post __nullterminated - -// [in,unique] -#define __RPC__in_opt __RPC__in __pre __exceptthat __maybenull -#define __RPC__in_opt_string __RPC__in_opt __pre __nullterminated -#define __RPC__in_ecount_opt(size) __RPC__in_ecount(size) __pre __exceptthat __maybenull -#define __RPC__in_ecount_opt_string(size) __RPC__in_ecount_opt(size) __pre __nullterminated - -// [in,out,unique] -#define __RPC__inout_opt __inout_opt -#define __RPC__inout_ecount_opt(size) __inout_ecount_opt(size) -#define __RPC__inout_ecount_part_opt(size, length) __inout_ecount_part_opt(size, length) -#define __RPC__inout_ecount_full_opt(size) __RPC__inout_ecount_part_opt(size, size) -#define __RPC__inout_ecount_full_opt_string(size) __RPC__inout_ecount_full_opt(size) __pre __nullterminated __post __nullterminated - -// [out] ** -#define __RPC__deref_out __deref_out -#define __RPC__deref_out_string __RPC__deref_out __post __deref __nullterminated -// Removed "__post __deref __exceptthat __maybenull" so return values from QueryInterface and the like can be trusted without an explicit NULL check. -// This is a temporary fix until midl.exe can be rev'd to produce more accurate annotations. -#define __RPC__deref_out_opt __RPC__deref_out -#define __RPC__deref_out_opt_string __RPC__deref_out_opt __post __deref __nullterminated __pre __deref __null -#define __RPC__deref_out_ecount(size) __deref_out_ecount(size) __post __deref __elem_writableTo(size) -#define __RPC__deref_out_ecount_part(size, length) __RPC__deref_out_ecount(size) __post __deref __elem_readableTo(length) -#define __RPC__deref_out_ecount_full(size) __RPC__deref_out_ecount_part(size,size) -#define __RPC__deref_out_ecount_full_string(size) __RPC__deref_out_ecount_full(size) __post __deref __nullterminated - -// [in,out] **, second pointer decoration. -#define __RPC__deref_inout __deref_inout -#define __RPC__deref_inout_string __RPC__deref_inout __pre __deref __nullterminated __post __deref __nullterminated -#define __RPC__deref_inout_opt __deref_inout_opt -#define __RPC__deref_inout_opt_string __RPC__deref_inout_opt __deref __nullterminated -#define __RPC__deref_inout_ecount_opt(size) __deref_inout_ecount_opt(size) -#define __RPC__deref_inout_ecount_part_opt(size, length) __deref_inout_ecount_part_opt(size , length) -#define __RPC__deref_inout_ecount_full_opt(size) __RPC__deref_inout_ecount_part_opt(size, size) -#define __RPC__deref_inout_ecount_full(size) __deref_inout_ecount_full(size) -#define __RPC__deref_inout_ecount_full_string(size) __RPC__deref_inout_ecount_full(size) __post __deref __nullterminated -#define __RPC__deref_inout_ecount_full_opt_string(size) __RPC__deref_inout_ecount_full_opt(size) __pre __deref __nullterminated __post __deref __nullterminated - - -// #define __RPC_out_opt out_opt is not allowed in rpc - -// [in,out,unique] -#define __RPC__deref_opt_inout __deref_opt_inout -#define __RPC__deref_opt_inout_ecount(size) __deref_opt_inout_ecount(size) -#define __RPC__deref_opt_inout_string __RPC__deref_opt_inout __pre __deref __nullterminated __post __deref __nullterminated -#define __RPC__deref_opt_inout_ecount_part(size, length) __deref_opt_inout_ecount_part(size, length) -#define __RPC__deref_opt_inout_ecount_full(size) __deref_opt_inout_ecount_full(size) -#define __RPC__deref_opt_inout_ecount_full_string(size) __RPC__deref_opt_inout_ecount_full(size) __pre __deref __nullterminated __post __deref __nullterminated - - -// We don't need to specify __pre __deref __exceptthat __maybenull : this is default behavior. While this might not hold in SAL 1.1 syntax, SAL team -// believes it's OK. We can revisit if SAL 1.1 can survive. -#define __RPC__deref_out_ecount_opt(size) __RPC__out_ecount(size) __post __deref __exceptthat __maybenull __pre __deref __null -#define __RPC__deref_out_ecount_part_opt(size, length) __RPC__deref_out_ecount_part(size, length) __post __deref __exceptthat __maybenull __pre __deref __null -#define __RPC__deref_out_ecount_full_opt(size) __RPC__deref_out_ecount_part_opt(size, size) __pre __deref __null -#define __RPC__deref_out_ecount_full_opt_string(size) __RPC__deref_out_ecount_part_opt(size, size) __post __deref __nullterminated __pre __deref __null - -#define __RPC__deref_opt_inout_opt __deref_opt_inout_opt -#define __RPC__deref_opt_inout_opt_string __RPC__deref_opt_inout_opt __pre __deref __nullterminated __post __deref __nullterminated -#define __RPC__deref_opt_inout_ecount_opt(size) __deref_opt_inout_ecount_opt(size) -#define __RPC__deref_opt_inout_ecount_part_opt(size, length) __deref_opt_inout_ecount_part_opt(size, length) -#define __RPC__deref_opt_inout_ecount_full_opt(size) __RPC__deref_opt_inout_ecount_part_opt(size, size) -#define __RPC__deref_opt_inout_ecount_full_opt_string(size) __RPC__deref_opt_inout_ecount_full_opt(size) __pre __deref __nullterminated __post __deref __nullterminated - -#define __RPC_full_pointer __maybenull -#define __RPC_unique_pointer __maybenull -#define __RPC_ref_pointer __notnull -#define __RPC_string __nullterminated - -#else // not prefast - -#define RPC_range(min,max) - -#define __RPC__in -#define __RPC__in_string -#define __RPC__in_opt_string -#define __RPC__deref_opt_in_opt -#define __RPC__opt_in_opt_string -#define __RPC__in_ecount(size) -#define __RPC__in_ecount_full(size) -#define __RPC__in_ecount_full_string(size) -#define __RPC__in_ecount_part(size, length) -#define __RPC__in_ecount_full_opt(size) -#define __RPC__in_ecount_full_opt_string(size) -#define __RPC__inout_ecount_full_opt_string(size) -#define __RPC__in_ecount_part_opt(size, length) - -#define __RPC__deref_in -#define __RPC__deref_in_string -#define __RPC__deref_opt_in -#define __RPC__deref_in_opt -#define __RPC__deref_in_ecount(size) -#define __RPC__deref_in_ecount_part(size, length) -#define __RPC__deref_in_ecount_full(size) -#define __RPC__deref_in_ecount_full_opt(size) -#define __RPC__deref_in_ecount_full_string(size) -#define __RPC__deref_in_ecount_full_opt_string(size) -#define __RPC__deref_in_ecount_opt(size) -#define __RPC__deref_in_ecount_opt_string(size) -#define __RPC__deref_in_ecount_part_opt(size, length) - -// [out] -#define __RPC__out -#define __RPC__out_ecount(size) -#define __RPC__out_ecount_part(size, length) -#define __RPC__out_ecount_full(size) -#define __RPC__out_ecount_full_string(size) - -// [in,out] -#define __RPC__inout -#define __RPC__inout_string -#define __RPC__opt_inout -#define __RPC__inout_ecount(size) -#define __RPC__inout_ecount_part(size, length) -#define __RPC__inout_ecount_full(size) -#define __RPC__inout_ecount_full_string(size) - -// [in,unique] -#define __RPC__in_opt -#define __RPC__in_ecount_opt(size) - - -// [in,out,unique] -#define __RPC__inout_opt -#define __RPC__inout_ecount_opt(size) -#define __RPC__inout_ecount_part_opt(size, length) -#define __RPC__inout_ecount_full_opt(size) -#define __RPC__inout_ecount_full_string(size) - -// [out] ** -#define __RPC__deref_out -#define __RPC__deref_out_string -#define __RPC__deref_out_opt -#define __RPC__deref_out_opt_string -#define __RPC__deref_out_ecount(size) -#define __RPC__deref_out_ecount_part(size, length) -#define __RPC__deref_out_ecount_full(size) -#define __RPC__deref_out_ecount_full_string(size) - - -// [in,out] **, second pointer decoration. -#define __RPC__deref_inout -#define __RPC__deref_inout_string -#define __RPC__deref_inout_opt -#define __RPC__deref_inout_opt_string -#define __RPC__deref_inout_ecount_full(size) -#define __RPC__deref_inout_ecount_full_string(size) -#define __RPC__deref_inout_ecount_opt(size) -#define __RPC__deref_inout_ecount_part_opt(size, length) -#define __RPC__deref_inout_ecount_full_opt(size) -#define __RPC__deref_inout_ecount_full_opt_string(size) - -// #define __RPC_out_opt out_opt is not allowed in rpc - -// [in,out,unique] -#define __RPC__deref_opt_inout -#define __RPC__deref_opt_inout_string -#define __RPC__deref_opt_inout_ecount(size) -#define __RPC__deref_opt_inout_ecount_part(size, length) -#define __RPC__deref_opt_inout_ecount_full(size) -#define __RPC__deref_opt_inout_ecount_full_string(size) - -#define __RPC__deref_out_ecount_opt(size) -#define __RPC__deref_out_ecount_part_opt(size, length) -#define __RPC__deref_out_ecount_full_opt(size) -#define __RPC__deref_out_ecount_full_opt_string(size) - -#define __RPC__deref_opt_inout_opt -#define __RPC__deref_opt_inout_opt_string -#define __RPC__deref_opt_inout_ecount_opt(size) -#define __RPC__deref_opt_inout_ecount_part_opt(size, length) -#define __RPC__deref_opt_inout_ecount_full_opt(size) -#define __RPC__deref_opt_inout_ecount_full_opt_string(size) - -#define __RPC_full_pointer -#define __RPC_unique_pointer -#define __RPC_ref_pointer -#define __RPC_string - - -#endif - -#ifdef __cplusplus -} -#endif - +/****************************************************************\ +* * +* rpcsal.h - markers for documenting the semantics of RPC APIs * +* * +* Version 1.0 * +* * +* Copyright (c) 2004 Microsoft Corporation. All rights reserved. * +* * +\****************************************************************/ + +// ------------------------------------------------------------------------------- +// Introduction +// +// rpcsal.h provides a set of annotations to describe how RPC functions use their +// parameters - the assumptions it makes about them, adn the guarantees it makes +// upon finishing. These annotations are similar to those found in specstrings.h, +// but are designed to be used by the MIDL compiler when it generates annotations +// enabled header files. +// +// IDL authors do not need to annotate their functions declarations. The MIDL compiler +// will interpret the IDL directives and use one of the annotations contained +// in this header. This documentation is intended to help those trying to understand +// the MIDL-generated header files or those who maintain their own copies of these files. +// +// ------------------------------------------------------------------------------- +// Differences between rpcsal.h and specstrings.h +// +// There are a few important differences between the annotations found in rpcsal.h and +// those in specstrings.h: +// +// 1. [in] parameters are not marked as read-only. They may be used for scratch space +// at the server and changes will not affect the client. +// 2. String versions of each macro alleviates the need for a special type definition +// +// ------------------------------------------------------------------------------- +// Interpreting RPC Annotations +// +// These annotations are interpreted precisely in the same way as those in specstrings.h. +// Please refer to that header for information related to general usage in annotations. +// +// To construct an RPC annotation, concatenate the appropriate value from each category +// along with a leading __RPC_. A typical annotation looks like "__RPC__in_string". +// +// |----------------------------------------------------------------------------------| +// | RPC Annotations | +// |------------|------------|---------|--------|----------|----------|---------------| +// | Level | Usage | Size | Output | Optional | String | Parameters | +// |------------|------------|---------|--------|----------|----------|---------------| +// | <> | <> | <> | <> | <> | <> | <> | +// | _deref | _in | _ecount | _full | _opt | _string | (size) | +// | _deref_opt | _out | _bcount | _part | | | (size,length) | +// | | _inout | | | | | | +// | | | | | | | | +// |------------|------------|---------|--------|----------|----------|---------------| +// +// Level: Describes the buffer pointer's level of indirection from the parameter or +// return value 'p'. +// +// <> : p is the buffer pointer. +// _deref : *p is the buffer pointer. p must not be NULL. +// _deref_opt : *p may be the buffer pointer. p may be NULL, in which case the rest of +// the annotation is ignored. +// +// Usage: Describes how the function uses the buffer. +// +// <> : The buffer is not accessed. If used on the return value or with _deref, the +// function will provide the buffer, and it will be uninitialized at exit. +// Otherwise, the caller must provide the buffer. This should only be used +// for alloc and free functions. +// _in : The function will only read from the buffer. The caller must provide the +// buffer and initialize it. Cannot be used with _deref. +// _out : The function will only write to the buffer. If used on the return value or +// with _deref, the function will provide the buffer and initialize it. +// Otherwise, the caller must provide the buffer, and the function will +// initialize it. +// _inout : The function may freely read from and write to the buffer. The caller must +// provide the buffer and initialize it. If used with _deref, the buffer may +// be reallocated by the function. +// +// Size: Describes the total size of the buffer. This may be less than the space actually +// allocated for the buffer, in which case it describes the accessible amount. +// +// <> : No buffer size is given. If the type specifies the buffer size (such as +// with LPSTR and LPWSTR), that amount is used. Otherwise, the buffer is one +// element long. Must be used with _in, _out, or _inout. +// _ecount : The buffer size is an explicit element count. +// _bcount : The buffer size is an explicit byte count. +// +// Output: Describes how much of the buffer will be initialized by the function. For +// _inout buffers, this also describes how much is initialized at entry. Omit this +// category for _in buffers; they must be fully initialized by the caller. +// +// <> : The type specifies how much is initialized. For instance, a function initializing +// an LPWSTR must NULL-terminate the string. +// _full : The function initializes the entire buffer. +// _part : The function initializes part of the buffer, and explicitly indicates how much. +// +// Optional: Describes if the buffer itself is optional. +// +// <> : The pointer to the buffer must not be NULL. +// _opt : The pointer to the buffer might be NULL. It will be checked before being dereferenced. +// +// String: Describes if the buffer is NULL terminated +// +// <> : The buffer is not assumed to be NULL terminated +// _string : The buffer is assumed to be NULL terminated once it has been initialized +// +// Parameters: Gives explicit counts for the size and length of the buffer. +// +// <> : There is no explicit count. Use when neither _ecount nor _bcount is used. +// (size) : Only the buffer's total size is given. Use with _ecount or _bcount but not _part. +// (size,length) : The buffer's total size and initialized length are given. Use with _ecount_part +// and _bcount_part. +// +// Notes: +// +// 1. Specifying two buffer annotations on a single parameter results in unspecified behavior +// (e.g. __RPC__in_bcount(5) __RPC__out_bcount(6) +// +// 2. The size of the buffer and the amount that has been initialized are separate concepts. +// Specify the size using _ecount or _bcount. Specify the amount that is initialized using +// _full, _part, or _string. As a special case, a single element buffer does not need +// _ecount, _bcount, _full, or _part +// +// 3. The count may be less than the total size of the buffer in which case it describes the +// accessible portion. +// +// 4. "__RPC__opt" and "__RPC_deref" are not valid annotations. +// +// 5. The placement of _opt when using _deref is important: +// __RPC__deref_opt_... : Input may be NULL +// __RPC__deref_..._opt : Output may be NULL +// __RPC__deref_opt_..._opt : Both input and output may be NULL +// + +#pragma once + +#include + +#ifndef __RPCSAL_H_VERSION__ +#define __RPCSAL_H_VERSION__ ( 100 ) +#endif // __RPCSAL_H_VERSION__ + +#ifdef __REQUIRED_RPCSAL_H_VERSION__ + #if ( __RPCSAL_H_VERSION__ < __REQUIRED_RPCSAL_H_VERSION__ ) + #error incorrect version. Use the header that matches with the MIDL compiler. + #endif +#endif + + +#ifdef __cplusplus +extern "C" { +#endif // #ifdef __cplusplus + +#if (_MSC_VER >= 1000) && !defined(__midl) && defined(_PREFAST_) + + +// [in] +#define __RPC__in __pre __valid +#define __RPC__in_string __RPC__in __pre __nullterminated +#define __RPC__in_ecount(size) __RPC__in __pre __elem_readableTo(size) +#define __RPC__in_ecount_full(size) __RPC__in_ecount(size) +#define __RPC__in_ecount_full_string(size) __RPC__in_ecount_full(size) __pre __nullterminated +#define __RPC__in_ecount_part(size, length) __RPC__in_ecount(length) __pre __elem_writableTo(size) +#define __RPC__in_ecount_full_opt(size) __RPC__in_ecount_full(size) __pre __exceptthat __maybenull +#define __RPC__in_ecount_full_opt_string(size) __RPC__in_ecount_full_opt(size) __pre __nullterminated +#define __RPC__in_ecount_part_opt(size, length) __RPC__in_ecount_part(size, length) __pre __exceptthat __maybenull + + +#define __RPC__deref_in __RPC__in __deref __notnull +#define __RPC__deref_in_string __RPC__in __pre __deref __nullterminated +#define __RPC__deref_in_opt __RPC__deref_in __deref __exceptthat __maybenull +#define __RPC__deref_opt_in __RPC__in __exceptthat __maybenull +#define __RPC__deref_opt_in_opt __RPC__deref_opt_in __pre __deref __exceptthat __maybenull +#define __RPC__deref_in_ecount(size) __RPC__in __pre __deref __elem_readableTo(size) +#define __RPC__deref_in_ecount_part(size, length) __RPC__deref_in_ecount(size) __pre __deref __elem_readableTo(length) +#define __RPC__deref_in_ecount_full(size) __RPC__deref_in_ecount_part(size, size) +#define __RPC__deref_in_ecount_full_opt(size) __RPC__deref_in_ecount_full(size) __pre __deref __exceptthat __maybenull +#define __RPC__deref_in_ecount_full_opt_string(size) __RPC__deref_in_ecount_full_opt(size) __pre __deref __nullterminated +#define __RPC__deref_in_ecount_full_string(size) __RPC__deref_in_ecount_full(size) __pre __deref __nullterminated +#define __RPC__deref_in_ecount_opt(size) __RPC__deref_in_ecount(size) __pre __deref __exceptthat __maybenull +#define __RPC__deref_in_ecount_opt_string(size) __RPC__deref_in_ecount_opt(size) __pre __deref __nullterminated +#define __RPC__deref_in_ecount_part_opt(size, length) __RPC__deref_in_ecount_opt(size) __pre __deref __elem_readableTo(length) + + +// [out] +#define __RPC__out __out +#define __RPC__out_ecount(size) __out_ecount(size) __post __elem_writableTo(size) +#define __RPC__out_ecount_string(size) __RPC__out_ecount(size) __post __nullterminated +#define __RPC__out_ecount_part(size, length) __RPC__out_ecount(size) __post __elem_readableTo(length) +#define __RPC__out_ecount_full(size) __RPC__out_ecount_part(size, size) +#define __RPC__out_ecount_full_string(size) __RPC__out_ecount_full(size) __post __nullterminated + +// [in,out] +#define __RPC__inout __inout +#define __RPC__inout_string __RPC__inout __pre __nullterminated __post __nullterminated +#define __RPC__inout_ecount(size) __inout_ecount(size) +#define __RPC__inout_ecount_part(size, length) __inout_ecount_part(size, length) +#define __RPC__inout_ecount_full(size) __RPC__inout_ecount_part(size, size) +#define __RPC__inout_ecount_full_string(size) __RPC__inout_ecount_full(size) __pre __nullterminated __post __nullterminated + +// [in,unique] +#define __RPC__in_opt __RPC__in __pre __exceptthat __maybenull +#define __RPC__in_opt_string __RPC__in_opt __pre __nullterminated +#define __RPC__in_ecount_opt(size) __RPC__in_ecount(size) __pre __exceptthat __maybenull +#define __RPC__in_ecount_opt_string(size) __RPC__in_ecount_opt(size) __pre __nullterminated + +// [in,out,unique] +#define __RPC__inout_opt __inout_opt +#define __RPC__inout_ecount_opt(size) __inout_ecount_opt(size) +#define __RPC__inout_ecount_part_opt(size, length) __inout_ecount_part_opt(size, length) +#define __RPC__inout_ecount_full_opt(size) __RPC__inout_ecount_part_opt(size, size) +#define __RPC__inout_ecount_full_opt_string(size) __RPC__inout_ecount_full_opt(size) __pre __nullterminated __post __nullterminated + +// [out] ** +#define __RPC__deref_out __deref_out +#define __RPC__deref_out_string __RPC__deref_out __post __deref __nullterminated +// Removed "__post __deref __exceptthat __maybenull" so return values from QueryInterface and the like can be trusted without an explicit NULL check. +// This is a temporary fix until midl.exe can be rev'd to produce more accurate annotations. +#define __RPC__deref_out_opt __RPC__deref_out +#define __RPC__deref_out_opt_string __RPC__deref_out_opt __post __deref __nullterminated __pre __deref __null +#define __RPC__deref_out_ecount(size) __deref_out_ecount(size) __post __deref __elem_writableTo(size) +#define __RPC__deref_out_ecount_part(size, length) __RPC__deref_out_ecount(size) __post __deref __elem_readableTo(length) +#define __RPC__deref_out_ecount_full(size) __RPC__deref_out_ecount_part(size,size) +#define __RPC__deref_out_ecount_full_string(size) __RPC__deref_out_ecount_full(size) __post __deref __nullterminated + +// [in,out] **, second pointer decoration. +#define __RPC__deref_inout __deref_inout +#define __RPC__deref_inout_string __RPC__deref_inout __pre __deref __nullterminated __post __deref __nullterminated +#define __RPC__deref_inout_opt __deref_inout_opt +#define __RPC__deref_inout_opt_string __RPC__deref_inout_opt __deref __nullterminated +#define __RPC__deref_inout_ecount_opt(size) __deref_inout_ecount_opt(size) +#define __RPC__deref_inout_ecount_part_opt(size, length) __deref_inout_ecount_part_opt(size , length) +#define __RPC__deref_inout_ecount_full_opt(size) __RPC__deref_inout_ecount_part_opt(size, size) +#define __RPC__deref_inout_ecount_full(size) __deref_inout_ecount_full(size) +#define __RPC__deref_inout_ecount_full_string(size) __RPC__deref_inout_ecount_full(size) __post __deref __nullterminated +#define __RPC__deref_inout_ecount_full_opt_string(size) __RPC__deref_inout_ecount_full_opt(size) __pre __deref __nullterminated __post __deref __nullterminated + + +// #define __RPC_out_opt out_opt is not allowed in rpc + +// [in,out,unique] +#define __RPC__deref_opt_inout __deref_opt_inout +#define __RPC__deref_opt_inout_ecount(size) __deref_opt_inout_ecount(size) +#define __RPC__deref_opt_inout_string __RPC__deref_opt_inout __pre __deref __nullterminated __post __deref __nullterminated +#define __RPC__deref_opt_inout_ecount_part(size, length) __deref_opt_inout_ecount_part(size, length) +#define __RPC__deref_opt_inout_ecount_full(size) __deref_opt_inout_ecount_full(size) +#define __RPC__deref_opt_inout_ecount_full_string(size) __RPC__deref_opt_inout_ecount_full(size) __pre __deref __nullterminated __post __deref __nullterminated + + +// We don't need to specify __pre __deref __exceptthat __maybenull : this is default behavior. While this might not hold in SAL 1.1 syntax, SAL team +// believes it's OK. We can revisit if SAL 1.1 can survive. +#define __RPC__deref_out_ecount_opt(size) __RPC__out_ecount(size) __post __deref __exceptthat __maybenull __pre __deref __null +#define __RPC__deref_out_ecount_part_opt(size, length) __RPC__deref_out_ecount_part(size, length) __post __deref __exceptthat __maybenull __pre __deref __null +#define __RPC__deref_out_ecount_full_opt(size) __RPC__deref_out_ecount_part_opt(size, size) __pre __deref __null +#define __RPC__deref_out_ecount_full_opt_string(size) __RPC__deref_out_ecount_part_opt(size, size) __post __deref __nullterminated __pre __deref __null + +#define __RPC__deref_opt_inout_opt __deref_opt_inout_opt +#define __RPC__deref_opt_inout_opt_string __RPC__deref_opt_inout_opt __pre __deref __nullterminated __post __deref __nullterminated +#define __RPC__deref_opt_inout_ecount_opt(size) __deref_opt_inout_ecount_opt(size) +#define __RPC__deref_opt_inout_ecount_part_opt(size, length) __deref_opt_inout_ecount_part_opt(size, length) +#define __RPC__deref_opt_inout_ecount_full_opt(size) __RPC__deref_opt_inout_ecount_part_opt(size, size) +#define __RPC__deref_opt_inout_ecount_full_opt_string(size) __RPC__deref_opt_inout_ecount_full_opt(size) __pre __deref __nullterminated __post __deref __nullterminated + +#define __RPC_full_pointer __maybenull +#define __RPC_unique_pointer __maybenull +#define __RPC_ref_pointer __notnull +#define __RPC_string __nullterminated + +#else // not prefast + +#define RPC_range(min,max) + +#define __RPC__in +#define __RPC__in_string +#define __RPC__in_opt_string +#define __RPC__deref_opt_in_opt +#define __RPC__opt_in_opt_string +#define __RPC__in_ecount(size) +#define __RPC__in_ecount_full(size) +#define __RPC__in_ecount_full_string(size) +#define __RPC__in_ecount_part(size, length) +#define __RPC__in_ecount_full_opt(size) +#define __RPC__in_ecount_full_opt_string(size) +#define __RPC__inout_ecount_full_opt_string(size) +#define __RPC__in_ecount_part_opt(size, length) + +#define __RPC__deref_in +#define __RPC__deref_in_string +#define __RPC__deref_opt_in +#define __RPC__deref_in_opt +#define __RPC__deref_in_ecount(size) +#define __RPC__deref_in_ecount_part(size, length) +#define __RPC__deref_in_ecount_full(size) +#define __RPC__deref_in_ecount_full_opt(size) +#define __RPC__deref_in_ecount_full_string(size) +#define __RPC__deref_in_ecount_full_opt_string(size) +#define __RPC__deref_in_ecount_opt(size) +#define __RPC__deref_in_ecount_opt_string(size) +#define __RPC__deref_in_ecount_part_opt(size, length) + +// [out] +#define __RPC__out +#define __RPC__out_ecount(size) +#define __RPC__out_ecount_part(size, length) +#define __RPC__out_ecount_full(size) +#define __RPC__out_ecount_full_string(size) + +// [in,out] +#define __RPC__inout +#define __RPC__inout_string +#define __RPC__opt_inout +#define __RPC__inout_ecount(size) +#define __RPC__inout_ecount_part(size, length) +#define __RPC__inout_ecount_full(size) +#define __RPC__inout_ecount_full_string(size) + +// [in,unique] +#define __RPC__in_opt +#define __RPC__in_ecount_opt(size) + + +// [in,out,unique] +#define __RPC__inout_opt +#define __RPC__inout_ecount_opt(size) +#define __RPC__inout_ecount_part_opt(size, length) +#define __RPC__inout_ecount_full_opt(size) +#define __RPC__inout_ecount_full_string(size) + +// [out] ** +#define __RPC__deref_out +#define __RPC__deref_out_string +#define __RPC__deref_out_opt +#define __RPC__deref_out_opt_string +#define __RPC__deref_out_ecount(size) +#define __RPC__deref_out_ecount_part(size, length) +#define __RPC__deref_out_ecount_full(size) +#define __RPC__deref_out_ecount_full_string(size) + + +// [in,out] **, second pointer decoration. +#define __RPC__deref_inout +#define __RPC__deref_inout_string +#define __RPC__deref_inout_opt +#define __RPC__deref_inout_opt_string +#define __RPC__deref_inout_ecount_full(size) +#define __RPC__deref_inout_ecount_full_string(size) +#define __RPC__deref_inout_ecount_opt(size) +#define __RPC__deref_inout_ecount_part_opt(size, length) +#define __RPC__deref_inout_ecount_full_opt(size) +#define __RPC__deref_inout_ecount_full_opt_string(size) + +// #define __RPC_out_opt out_opt is not allowed in rpc + +// [in,out,unique] +#define __RPC__deref_opt_inout +#define __RPC__deref_opt_inout_string +#define __RPC__deref_opt_inout_ecount(size) +#define __RPC__deref_opt_inout_ecount_part(size, length) +#define __RPC__deref_opt_inout_ecount_full(size) +#define __RPC__deref_opt_inout_ecount_full_string(size) + +#define __RPC__deref_out_ecount_opt(size) +#define __RPC__deref_out_ecount_part_opt(size, length) +#define __RPC__deref_out_ecount_full_opt(size) +#define __RPC__deref_out_ecount_full_opt_string(size) + +#define __RPC__deref_opt_inout_opt +#define __RPC__deref_opt_inout_opt_string +#define __RPC__deref_opt_inout_ecount_opt(size) +#define __RPC__deref_opt_inout_ecount_part_opt(size, length) +#define __RPC__deref_opt_inout_ecount_full_opt(size) +#define __RPC__deref_opt_inout_ecount_full_opt_string(size) + +#define __RPC_full_pointer +#define __RPC_unique_pointer +#define __RPC_ref_pointer +#define __RPC_string + + +#endif + +#ifdef __cplusplus +} +#endif + diff --git a/src/dep/include/DXSDK/include/strsafe.h b/src/dep/include/DXSDK/include/strsafe.h index cc573b4..061b3c4 100644 --- a/src/dep/include/DXSDK/include/strsafe.h +++ b/src/dep/include/DXSDK/include/strsafe.h @@ -1,6611 +1,6611 @@ -/****************************************************************** -* * -* strsafe.h -- This module defines safer C library string * -* routine replacements. These are meant to make C * -* a bit more safe in reference to security and * -* robustness * -* * -* Copyright (c) Microsoft Corp. All rights reserved. * -* * -******************************************************************/ -#ifndef _STRSAFE_H_INCLUDED_ -#define _STRSAFE_H_INCLUDED_ -#pragma once - -#include // for _vsnprintf, _vsnwprintf, getc, getwc -#include // for memset -#include // for va_start, etc. - - -#ifndef _SIZE_T_DEFINED -#ifdef _WIN64 -typedef unsigned __int64 size_t; -#else -typedef __w64 unsigned int size_t; -#endif // !_WIN64 -#define _SIZE_T_DEFINED -#endif // !_SIZE_T_DEFINED - -#if !defined(_WCHAR_T_DEFINED) && !defined(_NATIVE_WCHAR_T_DEFINED) -typedef unsigned short wchar_t; -#define _WCHAR_T_DEFINED -#endif - -#ifndef _HRESULT_DEFINED -#define _HRESULT_DEFINED -typedef long HRESULT; -#endif // !_HRESULT_DEFINED - -#ifndef SUCCEEDED -#define SUCCEEDED(hr) ((HRESULT)(hr) >= 0) -#endif - -#ifndef FAILED -#define FAILED(hr) ((HRESULT)(hr) < 0) -#endif - -#ifndef S_OK -#define S_OK ((HRESULT)0x00000000L) -#endif - -#ifdef __cplusplus -#define _STRSAFE_EXTERN_C extern "C" -#else -#define _STRSAFE_EXTERN_C extern -#endif - -// If you do not want to use these functions inline (and instead want to link w/ strsafe.lib), then -// #define STRSAFE_LIB before including this header file. -#if defined(STRSAFE_LIB) -#define STRSAFEAPI _STRSAFE_EXTERN_C HRESULT __stdcall -#pragma comment(lib, "strsafe.lib") -#elif defined(STRSAFE_LIB_IMPL) -#define STRSAFEAPI _STRSAFE_EXTERN_C HRESULT __stdcall -#else -#define STRSAFEAPI __inline HRESULT __stdcall -#define STRSAFE_INLINE -#endif - -// Some functions always run inline because they use stdin and we want to avoid building multiple -// versions of strsafe lib depending on if you use msvcrt, libcmt, etc. -#define STRSAFE_INLINE_API __inline HRESULT __stdcall - -// The user can request no "Cb" or no "Cch" fuctions, but not both! -#if defined(STRSAFE_NO_CB_FUNCTIONS) && defined(STRSAFE_NO_CCH_FUNCTIONS) -#error cannot specify both STRSAFE_NO_CB_FUNCTIONS and STRSAFE_NO_CCH_FUNCTIONS !! -#endif - -// This should only be defined when we are building strsafe.lib -#ifdef STRSAFE_LIB_IMPL -#define STRSAFE_INLINE -#endif - - -// If both strsafe.h and ntstrsafe.h are included, only use definitions from one. -#ifndef _NTSTRSAFE_H_INCLUDED_ - -#define STRSAFE_MAX_CCH 2147483647 // max # of characters we support (same as INT_MAX) - -// Flags for controling the Ex functions -// -// STRSAFE_FILL_BYTE(0xFF) 0x000000FF // bottom byte specifies fill pattern -#define STRSAFE_IGNORE_NULLS 0x00000100 // treat null as TEXT("") -- don't fault on NULL buffers -#define STRSAFE_FILL_BEHIND_NULL 0x00000200 // fill in extra space behind the null terminator -#define STRSAFE_FILL_ON_FAILURE 0x00000400 // on failure, overwrite pszDest with fill pattern and null terminate it -#define STRSAFE_NULL_ON_FAILURE 0x00000800 // on failure, set *pszDest = TEXT('\0') -#define STRSAFE_NO_TRUNCATION 0x00001000 // instead of returning a truncated result, copy/append nothing to pszDest and null terminate it - -#define STRSAFE_VALID_FLAGS (0x000000FF | STRSAFE_IGNORE_NULLS | STRSAFE_FILL_BEHIND_NULL | STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION) - -// helper macro to set the fill character and specify buffer filling -#define STRSAFE_FILL_BYTE(x) ((unsigned long)((x & 0x000000FF) | STRSAFE_FILL_BEHIND_NULL)) -#define STRSAFE_FAILURE_BYTE(x) ((unsigned long)((x & 0x000000FF) | STRSAFE_FILL_ON_FAILURE)) - -#define STRSAFE_GET_FILL_PATTERN(dwFlags) ((int)(dwFlags & 0x000000FF)) - -#endif // _NTSTRSAFE_H_INCLUDED_ - -// STRSAFE error return codes -// -#define STRSAFE_E_INSUFFICIENT_BUFFER ((HRESULT)0x8007007AL) // 0x7A = 122L = ERROR_INSUFFICIENT_BUFFER -#define STRSAFE_E_INVALID_PARAMETER ((HRESULT)0x80070057L) // 0x57 = 87L = ERROR_INVALID_PARAMETER -#define STRSAFE_E_END_OF_FILE ((HRESULT)0x80070026L) // 0x26 = 38L = ERROR_HANDLE_EOF - -// prototypes for the worker functions -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCopyWorkerA(char* pszDest, size_t cchDest, const char* pszSrc); -STRSAFEAPI StringCopyWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc); -STRSAFEAPI StringCopyExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -STRSAFEAPI StringCopyExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -STRSAFEAPI StringCopyNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc); -STRSAFEAPI StringCopyNWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchSrc); -STRSAFEAPI StringCopyNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -STRSAFEAPI StringCopyNExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, size_t cchSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -STRSAFEAPI StringCatWorkerA(char* pszDest, size_t cchDest, const char* pszSrc); -STRSAFEAPI StringCatWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc); -STRSAFEAPI StringCatExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -STRSAFEAPI StringCatExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -STRSAFEAPI StringCatNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend); -STRSAFEAPI StringCatNWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchMaxAppend); -STRSAFEAPI StringCatNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchMaxAppend, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -STRSAFEAPI StringCatNExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, size_t cchMaxAppend, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -STRSAFEAPI StringVPrintfWorkerA(char* pszDest, size_t cchDest, const char* pszFormat, va_list argList); -STRSAFEAPI StringVPrintfWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszFormat, va_list argList); -STRSAFEAPI StringVPrintfExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList); -STRSAFEAPI StringVPrintfExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const wchar_t* pszFormat, va_list argList); -STRSAFEAPI StringLengthWorkerA(const char* psz, size_t cchMax, size_t* pcch); -STRSAFEAPI StringLengthWorkerW(const wchar_t* psz, size_t cchMax, size_t* pcch); -#endif // STRSAFE_INLINE - -#ifndef STRSAFE_LIB_IMPL -// these functions are always inline -STRSAFE_INLINE_API StringGetsExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -STRSAFE_INLINE_API StringGetsExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -#endif - -#ifdef _NTSTRSAFE_H_INCLUDED_ -#pragma warning(push) -#pragma warning(disable : 4995) -#endif // _NTSTRSAFE_H_INCLUDED_ - - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchCopy( - OUT LPTSTR pszDest, - IN size_t cchDest, - IN LPCTSTR pszSrc - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strcpy'. - The size of the destination buffer (in characters) is a parameter and - this function will not write past the end of this buffer and it will - ALWAYS null terminate the destination buffer (unless it is zero length). - - This routine is not a replacement for strncpy. That function will pad the - destination string with extra null termination characters if the count is - greater than the length of the source string, and it will fail to null - terminate the destination string if the source string length is greater - than or equal to the count. You can not blindly use this instead of strncpy: - it is common for code to use it to "patch" strings and you would introduce - errors if the code started null terminating in the middle of the string. - - This function returns a hresult, and not a pointer. It returns - S_OK if the string was copied without truncation and null terminated, - otherwise it will return a failure code. In failure cases as much of - pszSrc will be copied to pszDest as possible, and pszDest will be null - terminated. - -Arguments: - - pszDest - destination string - - cchDest - size of destination buffer in characters. - length must be = (_tcslen(src) + 1) to hold all of the - source including the null terminator - - pszSrc - source string which must be null terminated - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL. See StringCchCopyEx if you require - the handling of NULL values. - -Return Value: - - S_OK - if there was source data and it was all copied and the - resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the copy - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function. - ---*/ - -STRSAFEAPI StringCchCopyA(char* pszDest, size_t cchDest, const char* pszSrc); -STRSAFEAPI StringCchCopyW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc); -#ifdef UNICODE -#define StringCchCopy StringCchCopyW -#else -#define StringCchCopy StringCchCopyA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCchCopyA(char* pszDest, size_t cchDest, const char* pszSrc) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCopyWorkerA(pszDest, cchDest, pszSrc); - } - - return hr; -} - -STRSAFEAPI StringCchCopyW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCopyWorkerW(pszDest, cchDest, pszSrc); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CCH_FUNCTIONS - - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbCopy( - OUT LPTSTR pszDest, - IN size_t cbDest, - IN LPCTSTR pszSrc - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strcpy'. - The size of the destination buffer (in bytes) is a parameter and this - function will not write past the end of this buffer and it will ALWAYS - null terminate the destination buffer (unless it is zero length). - - This routine is not a replacement for strncpy. That function will pad the - destination string with extra null termination characters if the count is - greater than the length of the source string, and it will fail to null - terminate the destination string if the source string length is greater - than or equal to the count. You can not blindly use this instead of strncpy: - it is common for code to use it to "patch" strings and you would introduce - errors if the code started null terminating in the middle of the string. - - This function returns a hresult, and not a pointer. It returns - S_OK if the string was copied without truncation and null terminated, - otherwise it will return a failure code. In failure cases as much of pszSrc - will be copied to pszDest as possible, and pszDest will be null terminated. - -Arguments: - - pszDest - destination string - - cbDest - size of destination buffer in bytes. - length must be = ((_tcslen(src) + 1) * sizeof(TCHAR)) to - hold all of the source including the null terminator - - pszSrc - source string which must be null terminated - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL. See StringCbCopyEx if you require - the handling of NULL values. - -Return Value: - - S_OK - if there was source data and it was all copied and the - resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the copy - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function. - ---*/ - -STRSAFEAPI StringCbCopyA(char* pszDest, size_t cbDest, const char* pszSrc); -STRSAFEAPI StringCbCopyW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc); -#ifdef UNICODE -#define StringCbCopy StringCbCopyW -#else -#define StringCbCopy StringCbCopyA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCbCopyA(char* pszDest, size_t cbDest, const char* pszSrc) -{ - HRESULT hr; - size_t cchDest; - - // convert to count of characters - cchDest = cbDest / sizeof(char); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCopyWorkerA(pszDest, cchDest, pszSrc); - } - - return hr; -} - -STRSAFEAPI StringCbCopyW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc) -{ - HRESULT hr; - size_t cchDest; - - // convert to count of characters - cchDest = cbDest / sizeof(wchar_t); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCopyWorkerW(pszDest, cchDest, pszSrc); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CB_FUNCTIONS - - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchCopyEx( - OUT LPTSTR pszDest OPTIONAL, - IN size_t cchDest, - IN LPCTSTR pszSrc OPTIONAL, - OUT LPTSTR* ppszDestEnd OPTIONAL, - OUT size_t* pcchRemaining OPTIONAL, - IN DWORD dwFlags - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strcpy' with - some additional parameters. In addition to functionality provided by - StringCchCopy, this routine also returns a pointer to the end of the - destination string and the number of characters left in the destination string - including the null terminator. The flags parameter allows additional controls. - -Arguments: - - pszDest - destination string - - cchDest - size of destination buffer in characters. - length must be = (_tcslen(pszSrc) + 1) to hold all of - the source including the null terminator - - pszSrc - source string which must be null terminated - - ppszDestEnd - if ppszDestEnd is non-null, the function will return a - pointer to the end of the destination string. If the - function copied any data, the result will point to the - null termination character - - pcchRemaining - if pcchRemaining is non-null, the function will return the - number of characters left in the destination string, - including the null terminator - - dwFlags - controls some details of the string copy: - - STRSAFE_FILL_BEHIND_NULL - if the function succeeds, the low byte of dwFlags will be - used to fill the uninitialize part of destination buffer - behind the null terminator - - STRSAFE_IGNORE_NULLS - treat NULL string pointers like empty strings (TEXT("")). - this flag is useful for emulating functions like lstrcpy - - STRSAFE_FILL_ON_FAILURE - if the function fails, the low byte of dwFlags will be - used to fill all of the destination buffer, and it will - be null terminated. This will overwrite any truncated - string returned when the failure is - STRSAFE_E_INSUFFICIENT_BUFFER - - STRSAFE_NO_TRUNCATION / - STRSAFE_NULL_ON_FAILURE - if the function fails, the destination buffer will be set - to the empty string. This will overwrite any truncated string - returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag - is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc - may be NULL. An error may still be returned even though NULLS are ignored - due to insufficient space. - -Return Value: - - S_OK - if there was source data and it was all copied and the - resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the copy - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCchCopyExA(char* pszDest, size_t cchDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -STRSAFEAPI StringCchCopyExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -#ifdef UNICODE -#define StringCchCopyEx StringCchCopyExW -#else -#define StringCchCopyEx StringCchCopyExA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCchCopyExA(char* pszDest, size_t cchDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - - // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 - cbDest = cchDest * sizeof(char); - - hr = StringCopyExWorkerA(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, pcchRemaining, dwFlags); - } - - return hr; -} - -STRSAFEAPI StringCchCopyExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - - // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - cbDest = cchDest * sizeof(wchar_t); - - hr = StringCopyExWorkerW(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, pcchRemaining, dwFlags); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CCH_FUNCTIONS - - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbCopyEx( - OUT LPTSTR pszDest OPTIONAL, - IN size_t cbDest, - IN LPCTSTR pszSrc OPTIONAL, - OUT LPTSTR* ppszDestEnd OPTIONAL, - OUT size_t* pcbRemaining OPTIONAL, - IN DWORD dwFlags - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strcpy' with - some additional parameters. In addition to functionality provided by - StringCbCopy, this routine also returns a pointer to the end of the - destination string and the number of bytes left in the destination string - including the null terminator. The flags parameter allows additional controls. - -Arguments: - - pszDest - destination string - - cbDest - size of destination buffer in bytes. - length must be ((_tcslen(pszSrc) + 1) * sizeof(TCHAR)) to - hold all of the source including the null terminator - - pszSrc - source string which must be null terminated - - ppszDestEnd - if ppszDestEnd is non-null, the function will return a - pointer to the end of the destination string. If the - function copied any data, the result will point to the - null termination character - - pcbRemaining - pcbRemaining is non-null,the function will return the - number of bytes left in the destination string, - including the null terminator - - dwFlags - controls some details of the string copy: - - STRSAFE_FILL_BEHIND_NULL - if the function succeeds, the low byte of dwFlags will be - used to fill the uninitialize part of destination buffer - behind the null terminator - - STRSAFE_IGNORE_NULLS - treat NULL string pointers like empty strings (TEXT("")). - this flag is useful for emulating functions like lstrcpy - - STRSAFE_FILL_ON_FAILURE - if the function fails, the low byte of dwFlags will be - used to fill all of the destination buffer, and it will - be null terminated. This will overwrite any truncated - string returned when the failure is - STRSAFE_E_INSUFFICIENT_BUFFER - - STRSAFE_NO_TRUNCATION / - STRSAFE_NULL_ON_FAILURE - if the function fails, the destination buffer will be set - to the empty string. This will overwrite any truncated string - returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag - is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc - may be NULL. An error may still be returned even though NULLS are ignored - due to insufficient space. - -Return Value: - - S_OK - if there was source data and it was all copied and the - resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the copy - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCbCopyExA(char* pszDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); -STRSAFEAPI StringCbCopyExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); -#ifdef UNICODE -#define StringCbCopyEx StringCbCopyExW -#else -#define StringCbCopyEx StringCbCopyExA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCbCopyExA(char* pszDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) -{ - HRESULT hr; - size_t cchDest; - size_t cchRemaining = 0; - - cchDest = cbDest / sizeof(char); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCopyExWorkerA(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, &cchRemaining, dwFlags); - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (pcbRemaining) - { - // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1 - *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)); - } - } - - return hr; -} - -STRSAFEAPI StringCbCopyExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) -{ - HRESULT hr; - size_t cchDest; - size_t cchRemaining = 0; - - cchDest = cbDest / sizeof(wchar_t); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCopyExWorkerW(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, &cchRemaining, dwFlags); - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (pcbRemaining) - { - // safe to multiply cchRemaining * sizeof(wchar_t) since cchRemaining < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - *pcbRemaining = (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)); - } - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CB_FUNCTIONS - - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchCopyN( - OUT LPTSTR pszDest, - IN size_t cchDest, - IN LPCTSTR pszSrc, - IN size_t cchSrc - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strncpy'. - The size of the destination buffer (in characters) is a parameter and - this function will not write past the end of this buffer and it will - ALWAYS null terminate the destination buffer (unless it is zero length). - - This routine is meant as a replacement for strncpy, but it does behave - differently. This function will not pad the destination buffer with extra - null termination characters if cchSrc is greater than the length of pszSrc. - - This function returns a hresult, and not a pointer. It returns - S_OK if the entire string or the first cchSrc characters were copied - without truncation and the resultant destination string was null terminated, - otherwise it will return a failure code. In failure cases as much of pszSrc - will be copied to pszDest as possible, and pszDest will be null terminated. - -Arguments: - - pszDest - destination string - - cchDest - size of destination buffer in characters. - length must be = (_tcslen(src) + 1) to hold all of the - source including the null terminator - - pszSrc - source string - - cchSrc - maximum number of characters to copy from source string, - not including the null terminator. - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL. See StringCchCopyNEx if you require - the handling of NULL values. - -Return Value: - - S_OK - if there was source data and it was all copied and the - resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the copy - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function. - ---*/ - -STRSAFEAPI StringCchCopyNA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc); -STRSAFEAPI StringCchCopyNW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchSrc); -#ifdef UNICODE -#define StringCchCopyN StringCchCopyNW -#else -#define StringCchCopyN StringCchCopyNA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCchCopyNA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc) -{ - HRESULT hr; - - if ((cchDest > STRSAFE_MAX_CCH) || - (cchSrc > STRSAFE_MAX_CCH)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCopyNWorkerA(pszDest, cchDest, pszSrc, cchSrc); - } - - return hr; -} - -STRSAFEAPI StringCchCopyNW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchSrc) -{ - HRESULT hr; - - if ((cchDest > STRSAFE_MAX_CCH) || - (cchSrc > STRSAFE_MAX_CCH)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCopyNWorkerW(pszDest, cchDest, pszSrc, cchSrc); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CCH_FUNCTIONS - - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbCopyN( - OUT LPTSTR pszDest, - IN size_t cbDest, - IN LPCTSTR pszSrc, - IN size_t cbSrc - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strncpy'. - The size of the destination buffer (in bytes) is a parameter and this - function will not write past the end of this buffer and it will ALWAYS - null terminate the destination buffer (unless it is zero length). - - This routine is meant as a replacement for strncpy, but it does behave - differently. This function will not pad the destination buffer with extra - null termination characters if cbSrc is greater than the size of pszSrc. - - This function returns a hresult, and not a pointer. It returns - S_OK if the entire string or the first cbSrc characters were - copied without truncation and the resultant destination string was null - terminated, otherwise it will return a failure code. In failure cases as - much of pszSrc will be copied to pszDest as possible, and pszDest will be - null terminated. - -Arguments: - - pszDest - destination string - - cbDest - size of destination buffer in bytes. - length must be = ((_tcslen(src) + 1) * sizeof(TCHAR)) to - hold all of the source including the null terminator - - pszSrc - source string - - cbSrc - maximum number of bytes to copy from source string, - not including the null terminator. - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL. See StringCbCopyEx if you require - the handling of NULL values. - -Return Value: - - S_OK - if there was source data and it was all copied and the - resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the copy - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function. - ---*/ - -STRSAFEAPI StringCbCopyNA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbSrc); -STRSAFEAPI StringCbCopyNW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbSrc); -#ifdef UNICODE -#define StringCbCopyN StringCbCopyNW -#else -#define StringCbCopyN StringCbCopyNA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCbCopyNA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbSrc) -{ - HRESULT hr; - size_t cchDest; - size_t cchSrc; - - // convert to count of characters - cchDest = cbDest / sizeof(char); - cchSrc = cbSrc / sizeof(char); - - if ((cchDest > STRSAFE_MAX_CCH) || - (cchSrc > STRSAFE_MAX_CCH)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCopyNWorkerA(pszDest, cchDest, pszSrc, cchSrc); - } - - return hr; -} - -STRSAFEAPI StringCbCopyNW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbSrc) -{ - HRESULT hr; - size_t cchDest; - size_t cchSrc; - - // convert to count of characters - cchDest = cbDest / sizeof(wchar_t); - cchSrc = cbSrc / sizeof(wchar_t); - - if ((cchDest > STRSAFE_MAX_CCH) || - (cchSrc > STRSAFE_MAX_CCH)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCopyNWorkerW(pszDest, cchDest, pszSrc, cchSrc); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CB_FUNCTIONS - - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchCopyNEx( - OUT LPTSTR pszDest OPTIONAL, - IN size_t cchDest, - IN LPCTSTR pszSrc OPTIONAL, - IN size_t cchSrc, - OUT LPTSTR* ppszDestEnd OPTIONAL, - OUT size_t* pcchRemaining OPTIONAL, - IN DWORD dwFlags - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strncpy' with - some additional parameters. In addition to functionality provided by - StringCchCopyN, this routine also returns a pointer to the end of the - destination string and the number of characters left in the destination - string including the null terminator. The flags parameter allows - additional controls. - - This routine is meant as a replacement for strncpy, but it does behave - differently. This function will not pad the destination buffer with extra - null termination characters if cchSrc is greater than the length of pszSrc. - -Arguments: - - pszDest - destination string - - cchDest - size of destination buffer in characters. - length must be = (_tcslen(pszSrc) + 1) to hold all of - the source including the null terminator - - pszSrc - source string - - cchSrc - maximum number of characters to copy from the source - string - - ppszDestEnd - if ppszDestEnd is non-null, the function will return a - pointer to the end of the destination string. If the - function copied any data, the result will point to the - null termination character - - pcchRemaining - if pcchRemaining is non-null, the function will return the - number of characters left in the destination string, - including the null terminator - - dwFlags - controls some details of the string copy: - - STRSAFE_FILL_BEHIND_NULL - if the function succeeds, the low byte of dwFlags will be - used to fill the uninitialize part of destination buffer - behind the null terminator - - STRSAFE_IGNORE_NULLS - treat NULL string pointers like empty strings (TEXT("")). - this flag is useful for emulating functions like lstrcpy - - STRSAFE_FILL_ON_FAILURE - if the function fails, the low byte of dwFlags will be - used to fill all of the destination buffer, and it will - be null terminated. This will overwrite any truncated - string returned when the failure is - STRSAFE_E_INSUFFICIENT_BUFFER - - STRSAFE_NO_TRUNCATION / - STRSAFE_NULL_ON_FAILURE - if the function fails, the destination buffer will be set - to the empty string. This will overwrite any truncated string - returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag - is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc - may be NULL. An error may still be returned even though NULLS are ignored - due to insufficient space. - -Return Value: - - S_OK - if there was source data and it was all copied and the - resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the copy - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCchCopyNExA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -STRSAFEAPI StringCchCopyNExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -#ifdef UNICODE -#define StringCchCopyNEx StringCchCopyNExW -#else -#define StringCchCopyNEx StringCchCopyNExA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCchCopyNExA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr; - - if ((cchDest > STRSAFE_MAX_CCH) || - (cchSrc > STRSAFE_MAX_CCH)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - - // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 - cbDest = cchDest * sizeof(char); - - hr = StringCopyNExWorkerA(pszDest, cchDest, cbDest, pszSrc, cchSrc, ppszDestEnd, pcchRemaining, dwFlags); - } - - return hr; -} - -STRSAFEAPI StringCchCopyNExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr; - - if ((cchDest > STRSAFE_MAX_CCH) || - (cchSrc > STRSAFE_MAX_CCH)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - - // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - cbDest = cchDest * sizeof(wchar_t); - - hr = StringCopyNExWorkerW(pszDest, cchDest, cbDest, pszSrc, cchSrc, ppszDestEnd, pcchRemaining, dwFlags); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CCH_FUNCTIONS - - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbCopyNEx( - OUT LPTSTR pszDest OPTIONAL, - IN size_t cbDest, - IN LPCTSTR pszSrc OPTIONAL, - IN size_t cbSrc, - OUT LPTSTR* ppszDestEnd OPTIONAL, - OUT size_t* pcbRemaining OPTIONAL, - IN DWORD dwFlags - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strncpy' with - some additional parameters. In addition to functionality provided by - StringCbCopyN, this routine also returns a pointer to the end of the - destination string and the number of bytes left in the destination string - including the null terminator. The flags parameter allows additional controls. - - This routine is meant as a replacement for strncpy, but it does behave - differently. This function will not pad the destination buffer with extra - null termination characters if cbSrc is greater than the size of pszSrc. - -Arguments: - - pszDest - destination string - - cbDest - size of destination buffer in bytes. - length must be ((_tcslen(pszSrc) + 1) * sizeof(TCHAR)) to - hold all of the source including the null terminator - - pszSrc - source string - - cbSrc - maximum number of bytes to copy from source string - - ppszDestEnd - if ppszDestEnd is non-null, the function will return a - pointer to the end of the destination string. If the - function copied any data, the result will point to the - null termination character - - pcbRemaining - pcbRemaining is non-null,the function will return the - number of bytes left in the destination string, - including the null terminator - - dwFlags - controls some details of the string copy: - - STRSAFE_FILL_BEHIND_NULL - if the function succeeds, the low byte of dwFlags will be - used to fill the uninitialize part of destination buffer - behind the null terminator - - STRSAFE_IGNORE_NULLS - treat NULL string pointers like empty strings (TEXT("")). - this flag is useful for emulating functions like lstrcpy - - STRSAFE_FILL_ON_FAILURE - if the function fails, the low byte of dwFlags will be - used to fill all of the destination buffer, and it will - be null terminated. This will overwrite any truncated - string returned when the failure is - STRSAFE_E_INSUFFICIENT_BUFFER - - STRSAFE_NO_TRUNCATION / - STRSAFE_NULL_ON_FAILURE - if the function fails, the destination buffer will be set - to the empty string. This will overwrite any truncated string - returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag - is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc - may be NULL. An error may still be returned even though NULLS are ignored - due to insufficient space. - -Return Value: - - S_OK - if there was source data and it was all copied and the - resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the copy - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCbCopyNExA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); -STRSAFEAPI StringCbCopyNExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbSrc, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); -#ifdef UNICODE -#define StringCbCopyNEx StringCbCopyNExW -#else -#define StringCbCopyNEx StringCbCopyNExA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCbCopyNExA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) -{ - HRESULT hr; - size_t cchDest; - size_t cchSrc; - size_t cchRemaining = 0; - - cchDest = cbDest / sizeof(char); - cchSrc = cbSrc / sizeof(char); - - if ((cchDest > STRSAFE_MAX_CCH) || - (cchSrc > STRSAFE_MAX_CCH)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCopyNExWorkerA(pszDest, cchDest, cbDest, pszSrc, cchSrc, ppszDestEnd, &cchRemaining, dwFlags); - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (pcbRemaining) - { - // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1 - *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)); - } - } - - return hr; -} - -STRSAFEAPI StringCbCopyNExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbSrc, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) -{ - HRESULT hr; - size_t cchDest; - size_t cchSrc; - size_t cchRemaining = 0; - - cchDest = cbDest / sizeof(wchar_t); - cchSrc = cbSrc / sizeof(wchar_t); - - if ((cchDest > STRSAFE_MAX_CCH) || - (cchSrc > STRSAFE_MAX_CCH)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCopyNExWorkerW(pszDest, cchDest, cbDest, pszSrc, cchSrc, ppszDestEnd, &cchRemaining, dwFlags); - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (pcbRemaining) - { - // safe to multiply cchRemaining * sizeof(wchar_t) since cchRemaining < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - *pcbRemaining = (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)); - } - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CB_FUNCTIONS - - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchCat( - IN OUT LPTSTR pszDest, - IN size_t cchDest, - IN LPCTSTR pszSrc - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strcat'. - The size of the destination buffer (in characters) is a parameter and this - function will not write past the end of this buffer and it will ALWAYS - null terminate the destination buffer (unless it is zero length). - - This function returns a hresult, and not a pointer. It returns - S_OK if the string was concatenated without truncation and null terminated, - otherwise it will return a failure code. In failure cases as much of pszSrc - will be appended to pszDest as possible, and pszDest will be null - terminated. - -Arguments: - - pszDest - destination string which must be null terminated - - cchDest - size of destination buffer in characters. - length must be = (_tcslen(pszDest) + _tcslen(pszSrc) + 1) - to hold all of the combine string plus the null - terminator - - pszSrc - source string which must be null terminated - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL. See StringCchCatEx if you require - the handling of NULL values. - -Return Value: - - S_OK - if there was source data and it was all concatenated and - the resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the operation - failed due to insufficient space. When this error occurs, - the destination buffer is modified to contain a truncated - version of the ideal result and is null terminated. This - is useful for situations where truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCchCatA(char* pszDest, size_t cchDest, const char* pszSrc); -STRSAFEAPI StringCchCatW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc); -#ifdef UNICODE -#define StringCchCat StringCchCatW -#else -#define StringCchCat StringCchCatA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCchCatA(char* pszDest, size_t cchDest, const char* pszSrc) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCatWorkerA(pszDest, cchDest, pszSrc); - } - - return hr; -} - -STRSAFEAPI StringCchCatW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCatWorkerW(pszDest, cchDest, pszSrc); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CCH_FUNCTIONS - - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbCat( - IN OUT LPTSTR pszDest, - IN size_t cbDest, - IN LPCTSTR pszSrc - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strcat'. - The size of the destination buffer (in bytes) is a parameter and this - function will not write past the end of this buffer and it will ALWAYS - null terminate the destination buffer (unless it is zero length). - - This function returns a hresult, and not a pointer. It returns - S_OK if the string was concatenated without truncation and null terminated, - otherwise it will return a failure code. In failure cases as much of pszSrc - will be appended to pszDest as possible, and pszDest will be null - terminated. - -Arguments: - - pszDest - destination string which must be null terminated - - cbDest - size of destination buffer in bytes. - length must be = ((_tcslen(pszDest) + _tcslen(pszSrc) + 1) * sizeof(TCHAR) - to hold all of the combine string plus the null - terminator - - pszSrc - source string which must be null terminated - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL. See StringCbCatEx if you require - the handling of NULL values. - -Return Value: - - S_OK - if there was source data and it was all concatenated and - the resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the operation - failed due to insufficient space. When this error occurs, - the destination buffer is modified to contain a truncated - version of the ideal result and is null terminated. This - is useful for situations where truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCbCatA(char* pszDest, size_t cbDest, const char* pszSrc); -STRSAFEAPI StringCbCatW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc); -#ifdef UNICODE -#define StringCbCat StringCbCatW -#else -#define StringCbCat StringCbCatA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCbCatA(char* pszDest, size_t cbDest, const char* pszSrc) -{ - HRESULT hr; - size_t cchDest; - - cchDest = cbDest / sizeof(char); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCatWorkerA(pszDest, cchDest, pszSrc); - } - - return hr; -} - -STRSAFEAPI StringCbCatW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc) -{ - HRESULT hr; - size_t cchDest; - - cchDest = cbDest / sizeof(wchar_t); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCatWorkerW(pszDest, cchDest, pszSrc); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CB_FUNCTIONS - - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchCatEx( - IN OUT LPTSTR pszDest OPTIONAL, - IN size_t cchDest, - IN LPCTSTR pszSrc OPTIONAL, - OUT LPTSTR* ppszDestEnd OPTIONAL, - OUT size_t* pcchRemaining OPTIONAL, - IN DWORD dwFlags - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strcat' with - some additional parameters. In addition to functionality provided by - StringCchCat, this routine also returns a pointer to the end of the - destination string and the number of characters left in the destination string - including the null terminator. The flags parameter allows additional controls. - -Arguments: - - pszDest - destination string which must be null terminated - - cchDest - size of destination buffer in characters - length must be (_tcslen(pszDest) + _tcslen(pszSrc) + 1) - to hold all of the combine string plus the null - terminator. - - pszSrc - source string which must be null terminated - - ppszDestEnd - if ppszDestEnd is non-null, the function will return a - pointer to the end of the destination string. If the - function appended any data, the result will point to the - null termination character - - pcchRemaining - if pcchRemaining is non-null, the function will return the - number of characters left in the destination string, - including the null terminator - - dwFlags - controls some details of the string copy: - - STRSAFE_FILL_BEHIND_NULL - if the function succeeds, the low byte of dwFlags will be - used to fill the uninitialize part of destination buffer - behind the null terminator - - STRSAFE_IGNORE_NULLS - treat NULL string pointers like empty strings (TEXT("")). - this flag is useful for emulating functions like lstrcat - - STRSAFE_FILL_ON_FAILURE - if the function fails, the low byte of dwFlags will be - used to fill all of the destination buffer, and it will - be null terminated. This will overwrite any pre-existing - or truncated string - - STRSAFE_NULL_ON_FAILURE - if the function fails, the destination buffer will be set - to the empty string. This will overwrite any pre-existing or - truncated string - - STRSAFE_NO_TRUNCATION - if the function returns STRSAFE_E_INSUFFICIENT_BUFFER, pszDest - will not contain a truncated string, it will remain unchanged. - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag - is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc - may be NULL. An error may still be returned even though NULLS are ignored - due to insufficient space. - -Return Value: - - S_OK - if there was source data and it was all concatenated and - the resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the operation - failed due to insufficient space. When this error - occurs, the destination buffer is modified to contain - a truncated version of the ideal result and is null - terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCchCatExA(char* pszDest, size_t cchDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -STRSAFEAPI StringCchCatExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -#ifdef UNICODE -#define StringCchCatEx StringCchCatExW -#else -#define StringCchCatEx StringCchCatExA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCchCatExA(char* pszDest, size_t cchDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - - // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 - cbDest = cchDest * sizeof(char); - - hr = StringCatExWorkerA(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, pcchRemaining, dwFlags); - } - - return hr; -} - -STRSAFEAPI StringCchCatExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - - // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - cbDest = cchDest * sizeof(wchar_t); - - hr = StringCatExWorkerW(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, pcchRemaining, dwFlags); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CCH_FUNCTIONS - - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbCatEx( - IN OUT LPTSTR pszDest OPTIONAL, - IN size_t cbDest, - IN LPCTSTR pszSrc OPTIONAL, - OUT LPTSTR* ppszDestEnd OPTIONAL, - OUT size_t* pcbRemaining OPTIONAL, - IN DWORD dwFlags - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strcat' with - some additional parameters. In addition to functionality provided by - StringCbCat, this routine also returns a pointer to the end of the - destination string and the number of bytes left in the destination string - including the null terminator. The flags parameter allows additional controls. - -Arguments: - - pszDest - destination string which must be null terminated - - cbDest - size of destination buffer in bytes. - length must be ((_tcslen(pszDest) + _tcslen(pszSrc) + 1) * sizeof(TCHAR) - to hold all of the combine string plus the null - terminator. - - pszSrc - source string which must be null terminated - - ppszDestEnd - if ppszDestEnd is non-null, the function will return a - pointer to the end of the destination string. If the - function appended any data, the result will point to the - null termination character - - pcbRemaining - if pcbRemaining is non-null, the function will return - the number of bytes left in the destination string, - including the null terminator - - dwFlags - controls some details of the string copy: - - STRSAFE_FILL_BEHIND_NULL - if the function succeeds, the low byte of dwFlags will be - used to fill the uninitialize part of destination buffer - behind the null terminator - - STRSAFE_IGNORE_NULLS - treat NULL string pointers like empty strings (TEXT("")). - this flag is useful for emulating functions like lstrcat - - STRSAFE_FILL_ON_FAILURE - if the function fails, the low byte of dwFlags will be - used to fill all of the destination buffer, and it will - be null terminated. This will overwrite any pre-existing - or truncated string - - STRSAFE_NULL_ON_FAILURE - if the function fails, the destination buffer will be set - to the empty string. This will overwrite any pre-existing or - truncated string - - STRSAFE_NO_TRUNCATION - if the function returns STRSAFE_E_INSUFFICIENT_BUFFER, pszDest - will not contain a truncated string, it will remain unchanged. - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag - is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc - may be NULL. An error may still be returned even though NULLS are ignored - due to insufficient space. - -Return Value: - - S_OK - if there was source data and it was all concatenated - and the resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the operation - failed due to insufficient space. When this error - occurs, the destination buffer is modified to contain - a truncated version of the ideal result and is null - terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCbCatExA(char* pszDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); -STRSAFEAPI StringCbCatExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); -#ifdef UNICODE -#define StringCbCatEx StringCbCatExW -#else -#define StringCbCatEx StringCbCatExA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCbCatExA(char* pszDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) -{ - HRESULT hr; - size_t cchDest; - size_t cchRemaining = 0; - - cchDest = cbDest / sizeof(char); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCatExWorkerA(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, &cchRemaining, dwFlags); - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (pcbRemaining) - { - // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1 - *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)); - } - } - - return hr; -} - -STRSAFEAPI StringCbCatExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) -{ - HRESULT hr; - size_t cchDest; - size_t cchRemaining = 0; - - cchDest = cbDest / sizeof(wchar_t); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCatExWorkerW(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, &cchRemaining, dwFlags); - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (pcbRemaining) - { - // safe to multiply cchRemaining * sizeof(wchar_t) since cchRemaining < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - *pcbRemaining = (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)); - } - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CB_FUNCTIONS - - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchCatN( - IN OUT LPTSTR pszDest, - IN size_t cchDest, - IN LPCTSTR pszSrc, - IN size_t cchMaxAppend - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strncat'. - The size of the destination buffer (in characters) is a parameter as well as - the maximum number of characters to append, excluding the null terminator. - This function will not write past the end of the destination buffer and it will - ALWAYS null terminate pszDest (unless it is zero length). - - This function returns a hresult, and not a pointer. It returns - S_OK if all of pszSrc or the first cchMaxAppend characters were appended - to the destination string and it was null terminated, otherwise it will - return a failure code. In failure cases as much of pszSrc will be appended - to pszDest as possible, and pszDest will be null terminated. - -Arguments: - - pszDest - destination string which must be null terminated - - cchDest - size of destination buffer in characters. - length must be (_tcslen(pszDest) + min(cchMaxAppend, _tcslen(pszSrc)) + 1) - to hold all of the combine string plus the null - terminator. - - pszSrc - source string - - cchMaxAppend - maximum number of characters to append - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL. See StringCchCatNEx if you require - the handling of NULL values. - -Return Value: - - S_OK - if all of pszSrc or the first cchMaxAppend characters - were concatenated to pszDest and the resultant dest - string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the operation - failed due to insufficient space. When this error - occurs, the destination buffer is modified to contain - a truncated version of the ideal result and is null - terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCchCatNA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend); -STRSAFEAPI StringCchCatNW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchMaxAppend); -#ifdef UNICODE -#define StringCchCatN StringCchCatNW -#else -#define StringCchCatN StringCchCatNA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCchCatNA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCatNWorkerA(pszDest, cchDest, pszSrc, cchMaxAppend); - } - - return hr; -} - -STRSAFEAPI StringCchCatNW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchMaxAppend) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringCatNWorkerW(pszDest, cchDest, pszSrc, cchMaxAppend); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CCH_FUNCTIONS - - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbCatN( - IN OUT LPTSTR pszDest, - IN size_t cbDest, - IN LPCTSTR pszSrc, - IN size_t cbMaxAppend - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strncat'. - The size of the destination buffer (in bytes) is a parameter as well as - the maximum number of bytes to append, excluding the null terminator. - This function will not write past the end of the destination buffer and it will - ALWAYS null terminate pszDest (unless it is zero length). - - This function returns a hresult, and not a pointer. It returns - S_OK if all of pszSrc or the first cbMaxAppend bytes were appended - to the destination string and it was null terminated, otherwise it will - return a failure code. In failure cases as much of pszSrc will be appended - to pszDest as possible, and pszDest will be null terminated. - -Arguments: - - pszDest - destination string which must be null terminated - - cbDest - size of destination buffer in bytes. - length must be ((_tcslen(pszDest) + min(cbMaxAppend / sizeof(TCHAR), _tcslen(pszSrc)) + 1) * sizeof(TCHAR) - to hold all of the combine string plus the null - terminator. - - pszSrc - source string - - cbMaxAppend - maximum number of bytes to append - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL. See StringCbCatNEx if you require - the handling of NULL values. - -Return Value: - - S_OK - if all of pszSrc or the first cbMaxAppend bytes were - concatenated to pszDest and the resultant dest string - was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the operation - failed due to insufficient space. When this error - occurs, the destination buffer is modified to contain - a truncated version of the ideal result and is null - terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCbCatNA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbMaxAppend); -STRSAFEAPI StringCbCatNW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbMaxAppend); -#ifdef UNICODE -#define StringCbCatN StringCbCatNW -#else -#define StringCbCatN StringCbCatNA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCbCatNA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbMaxAppend) -{ - HRESULT hr; - size_t cchDest; - - cchDest = cbDest / sizeof(char); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cchMaxAppend; - - cchMaxAppend = cbMaxAppend / sizeof(char); - - hr = StringCatNWorkerA(pszDest, cchDest, pszSrc, cchMaxAppend); - } - - return hr; -} - -STRSAFEAPI StringCbCatNW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbMaxAppend) -{ - HRESULT hr; - size_t cchDest; - - cchDest = cbDest / sizeof(wchar_t); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cchMaxAppend; - - cchMaxAppend = cbMaxAppend / sizeof(wchar_t); - - hr = StringCatNWorkerW(pszDest, cchDest, pszSrc, cchMaxAppend); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CB_FUNCTIONS - - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchCatNEx( - IN OUT LPTSTR pszDest OPTIONAL, - IN size_t cchDest, - IN LPCTSTR pszSrc OPTIONAL, - IN size_t cchMaxAppend, - OUT LPTSTR* ppszDestEnd OPTIONAL, - OUT size_t* pcchRemaining OPTIONAL, - IN DWORD dwFlags - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strncat', with - some additional parameters. In addition to functionality provided by - StringCchCatN, this routine also returns a pointer to the end of the - destination string and the number of characters left in the destination string - including the null terminator. The flags parameter allows additional controls. - -Arguments: - - pszDest - destination string which must be null terminated - - cchDest - size of destination buffer in characters. - length must be (_tcslen(pszDest) + min(cchMaxAppend, _tcslen(pszSrc)) + 1) - to hold all of the combine string plus the null - terminator. - - pszSrc - source string - - cchMaxAppend - maximum number of characters to append - - ppszDestEnd - if ppszDestEnd is non-null, the function will return a - pointer to the end of the destination string. If the - function appended any data, the result will point to the - null termination character - - pcchRemaining - if pcchRemaining is non-null, the function will return the - number of characters left in the destination string, - including the null terminator - - dwFlags - controls some details of the string copy: - - STRSAFE_FILL_BEHIND_NULL - if the function succeeds, the low byte of dwFlags will be - used to fill the uninitialize part of destination buffer - behind the null terminator - - STRSAFE_IGNORE_NULLS - treat NULL string pointers like empty strings (TEXT("")) - - STRSAFE_FILL_ON_FAILURE - if the function fails, the low byte of dwFlags will be - used to fill all of the destination buffer, and it will - be null terminated. This will overwrite any pre-existing - or truncated string - - STRSAFE_NULL_ON_FAILURE - if the function fails, the destination buffer will be set - to the empty string. This will overwrite any pre-existing or - truncated string - - STRSAFE_NO_TRUNCATION - if the function returns STRSAFE_E_INSUFFICIENT_BUFFER, pszDest - will not contain a truncated string, it will remain unchanged. - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag - is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc - may be NULL. An error may still be returned even though NULLS are ignored - due to insufficient space. - -Return Value: - - S_OK - if all of pszSrc or the first cchMaxAppend characters - were concatenated to pszDest and the resultant dest - string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the operation - failed due to insufficient space. When this error - occurs, the destination buffer is modified to contain - a truncated version of the ideal result and is null - terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCchCatNExA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -STRSAFEAPI StringCchCatNExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchMaxAppend, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -#ifdef UNICODE -#define StringCchCatNEx StringCchCatNExW -#else -#define StringCchCatNEx StringCchCatNExA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCchCatNExA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - - // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 - cbDest = cchDest * sizeof(char); - - hr = StringCatNExWorkerA(pszDest, cchDest, cbDest, pszSrc, cchMaxAppend, ppszDestEnd, pcchRemaining, dwFlags); - } - - return hr; -} - -STRSAFEAPI StringCchCatNExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchMaxAppend, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - - // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - cbDest = cchDest * sizeof(wchar_t); - - hr = StringCatNExWorkerW(pszDest, cchDest, cbDest, pszSrc, cchMaxAppend, ppszDestEnd, pcchRemaining, dwFlags); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CCH_FUNCTIONS - - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbCatNEx( - IN OUT LPTSTR pszDest OPTIONAL, - IN size_t cbDest, - IN LPCTSTR pszSrc OPTIONAL, - IN size_t cbMaxAppend, - OUT LPTSTR* ppszDestEnd OPTIONAL, - OUT size_t* pcchRemaining OPTIONAL, - IN DWORD dwFlags - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strncat', with - some additional parameters. In addition to functionality provided by - StringCbCatN, this routine also returns a pointer to the end of the - destination string and the number of bytes left in the destination string - including the null terminator. The flags parameter allows additional controls. - -Arguments: - - pszDest - destination string which must be null terminated - - cbDest - size of destination buffer in bytes. - length must be ((_tcslen(pszDest) + min(cbMaxAppend / sizeof(TCHAR), _tcslen(pszSrc)) + 1) * sizeof(TCHAR) - to hold all of the combine string plus the null - terminator. - - pszSrc - source string - - cbMaxAppend - maximum number of bytes to append - - ppszDestEnd - if ppszDestEnd is non-null, the function will return a - pointer to the end of the destination string. If the - function appended any data, the result will point to the - null termination character - - pcbRemaining - if pcbRemaining is non-null, the function will return the - number of bytes left in the destination string, - including the null terminator - - dwFlags - controls some details of the string copy: - - STRSAFE_FILL_BEHIND_NULL - if the function succeeds, the low byte of dwFlags will be - used to fill the uninitialize part of destination buffer - behind the null terminator - - STRSAFE_IGNORE_NULLS - treat NULL string pointers like empty strings (TEXT("")) - - STRSAFE_FILL_ON_FAILURE - if the function fails, the low byte of dwFlags will be - used to fill all of the destination buffer, and it will - be null terminated. This will overwrite any pre-existing - or truncated string - - STRSAFE_NULL_ON_FAILURE - if the function fails, the destination buffer will be set - to the empty string. This will overwrite any pre-existing or - truncated string - - STRSAFE_NO_TRUNCATION - if the function returns STRSAFE_E_INSUFFICIENT_BUFFER, pszDest - will not contain a truncated string, it will remain unchanged. - -Notes: - Behavior is undefined if source and destination strings overlap. - - pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag - is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc - may be NULL. An error may still be returned even though NULLS are ignored - due to insufficient space. - -Return Value: - - S_OK - if all of pszSrc or the first cbMaxAppend bytes were - concatenated to pszDest and the resultant dest string - was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the operation - failed due to insufficient space. When this error - occurs, the destination buffer is modified to contain - a truncated version of the ideal result and is null - terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCbCatNExA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbMaxAppend, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); -STRSAFEAPI StringCbCatNExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbMaxAppend, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); -#ifdef UNICODE -#define StringCbCatNEx StringCbCatNExW -#else -#define StringCbCatNEx StringCbCatNExA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCbCatNExA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbMaxAppend, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) -{ - HRESULT hr; - size_t cchDest; - size_t cchRemaining = 0; - - cchDest = cbDest / sizeof(char); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cchMaxAppend; - - cchMaxAppend = cbMaxAppend / sizeof(char); - - hr = StringCatNExWorkerA(pszDest, cchDest, cbDest, pszSrc, cchMaxAppend, ppszDestEnd, &cchRemaining, dwFlags); - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (pcbRemaining) - { - // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1 - *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)); - } - } - - return hr; -} - -STRSAFEAPI StringCbCatNExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbMaxAppend, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) -{ - HRESULT hr; - size_t cchDest; - size_t cchRemaining = 0; - - cchDest = cbDest / sizeof(wchar_t); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cchMaxAppend; - - cchMaxAppend = cbMaxAppend / sizeof(wchar_t); - - hr = StringCatNExWorkerW(pszDest, cchDest, cbDest, pszSrc, cchMaxAppend, ppszDestEnd, &cchRemaining, dwFlags); - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (pcbRemaining) - { - // safe to multiply cchRemaining * sizeof(wchar_t) since cchRemaining < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - *pcbRemaining = (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)); - } - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CB_FUNCTIONS - - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchVPrintf( - OUT LPTSTR pszDest, - IN size_t cchDest, - IN LPCTSTR pszFormat, - IN va_list argList - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'vsprintf'. - The size of the destination buffer (in characters) is a parameter and - this function will not write past the end of this buffer and it will - ALWAYS null terminate the destination buffer (unless it is zero length). - - This function returns a hresult, and not a pointer. It returns - S_OK if the string was printed without truncation and null terminated, - otherwise it will return a failure code. In failure cases it will return - a truncated version of the ideal result. - -Arguments: - - pszDest - destination string - - cchDest - size of destination buffer in characters - length must be sufficient to hold the resulting formatted - string, including the null terminator. - - pszFormat - format string which must be null terminated - - argList - va_list from the variable arguments according to the - stdarg.h convention - -Notes: - Behavior is undefined if destination, format strings or any arguments - strings overlap. - - pszDest and pszFormat should not be NULL. See StringCchVPrintfEx if you - require the handling of NULL values. - -Return Value: - - S_OK - if there was sufficient space in the dest buffer for - the resultant string and it was null terminated. - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the print - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCchVPrintfA(char* pszDest, size_t cchDest, const char* pszFormat, va_list argList); -STRSAFEAPI StringCchVPrintfW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszFormat, va_list argList); -#ifdef UNICODE -#define StringCchVPrintf StringCchVPrintfW -#else -#define StringCchVPrintf StringCchVPrintfA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCchVPrintfA(char* pszDest, size_t cchDest, const char* pszFormat, va_list argList) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringVPrintfWorkerA(pszDest, cchDest, pszFormat, argList); - } - - return hr; -} - -STRSAFEAPI StringCchVPrintfW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszFormat, va_list argList) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringVPrintfWorkerW(pszDest, cchDest, pszFormat, argList); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CCH_FUNCTIONS - - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbVPrintf( - OUT LPTSTR pszDest, - IN size_t cbDest, - IN LPCTSTR pszFormat, - IN va_list argList - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'vsprintf'. - The size of the destination buffer (in bytes) is a parameter and - this function will not write past the end of this buffer and it will - ALWAYS null terminate the destination buffer (unless it is zero length). - - This function returns a hresult, and not a pointer. It returns - S_OK if the string was printed without truncation and null terminated, - otherwise it will return a failure code. In failure cases it will return - a truncated version of the ideal result. - -Arguments: - - pszDest - destination string - - cbDest - size of destination buffer in bytes - length must be sufficient to hold the resulting formatted - string, including the null terminator. - - pszFormat - format string which must be null terminated - - argList - va_list from the variable arguments according to the - stdarg.h convention - -Notes: - Behavior is undefined if destination, format strings or any arguments - strings overlap. - - pszDest and pszFormat should not be NULL. See StringCbVPrintfEx if you - require the handling of NULL values. - - -Return Value: - - S_OK - if there was sufficient space in the dest buffer for - the resultant string and it was null terminated. - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the print - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCbVPrintfA(char* pszDest, size_t cbDest, const char* pszFormat, va_list argList); -STRSAFEAPI StringCbVPrintfW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszFormat, va_list argList); -#ifdef UNICODE -#define StringCbVPrintf StringCbVPrintfW -#else -#define StringCbVPrintf StringCbVPrintfA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCbVPrintfA(char* pszDest, size_t cbDest, const char* pszFormat, va_list argList) -{ - HRESULT hr; - size_t cchDest; - - cchDest = cbDest / sizeof(char); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringVPrintfWorkerA(pszDest, cchDest, pszFormat, argList); - } - - return hr; -} - -STRSAFEAPI StringCbVPrintfW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszFormat, va_list argList) -{ - HRESULT hr; - size_t cchDest; - - cchDest = cbDest / sizeof(wchar_t); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringVPrintfWorkerW(pszDest, cchDest, pszFormat, argList); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CB_FUNCTIONS - - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchPrintf( - OUT LPTSTR pszDest, - IN size_t cchDest, - IN LPCTSTR pszFormat, - ... - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'sprintf'. - The size of the destination buffer (in characters) is a parameter and - this function will not write past the end of this buffer and it will - ALWAYS null terminate the destination buffer (unless it is zero length). - - This function returns a hresult, and not a pointer. It returns - S_OK if the string was printed without truncation and null terminated, - otherwise it will return a failure code. In failure cases it will return - a truncated version of the ideal result. - -Arguments: - - pszDest - destination string - - cchDest - size of destination buffer in characters - length must be sufficient to hold the resulting formatted - string, including the null terminator. - - pszFormat - format string which must be null terminated - - ... - additional parameters to be formatted according to - the format string - -Notes: - Behavior is undefined if destination, format strings or any arguments - strings overlap. - - pszDest and pszFormat should not be NULL. See StringCchPrintfEx if you - require the handling of NULL values. - -Return Value: - - S_OK - if there was sufficient space in the dest buffer for - the resultant string and it was null terminated. - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the print - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCchPrintfA(char* pszDest, size_t cchDest, const char* pszFormat, ...); -STRSAFEAPI StringCchPrintfW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszFormat, ...); -#ifdef UNICODE -#define StringCchPrintf StringCchPrintfW -#else -#define StringCchPrintf StringCchPrintfA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCchPrintfA(char* pszDest, size_t cchDest, const char* pszFormat, ...) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - va_list argList; - - va_start(argList, pszFormat); - - hr = StringVPrintfWorkerA(pszDest, cchDest, pszFormat, argList); - - va_end(argList); - } - - return hr; -} - -STRSAFEAPI StringCchPrintfW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszFormat, ...) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - va_list argList; - - va_start(argList, pszFormat); - - hr = StringVPrintfWorkerW(pszDest, cchDest, pszFormat, argList); - - va_end(argList); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CCH_FUNCTIONS - - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbPrintf( - OUT LPTSTR pszDest, - IN size_t cbDest, - IN LPCTSTR pszFormat, - ... - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'sprintf'. - The size of the destination buffer (in bytes) is a parameter and - this function will not write past the end of this buffer and it will - ALWAYS null terminate the destination buffer (unless it is zero length). - - This function returns a hresult, and not a pointer. It returns - S_OK if the string was printed without truncation and null terminated, - otherwise it will return a failure code. In failure cases it will return - a truncated version of the ideal result. - -Arguments: - - pszDest - destination string - - cbDest - size of destination buffer in bytes - length must be sufficient to hold the resulting formatted - string, including the null terminator. - - pszFormat - format string which must be null terminated - - ... - additional parameters to be formatted according to - the format string - -Notes: - Behavior is undefined if destination, format strings or any arguments - strings overlap. - - pszDest and pszFormat should not be NULL. See StringCbPrintfEx if you - require the handling of NULL values. - - -Return Value: - - S_OK - if there was sufficient space in the dest buffer for - the resultant string and it was null terminated. - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the print - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCbPrintfA(char* pszDest, size_t cbDest, const char* pszFormat, ...); -STRSAFEAPI StringCbPrintfW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszFormat, ...); -#ifdef UNICODE -#define StringCbPrintf StringCbPrintfW -#else -#define StringCbPrintf StringCbPrintfA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCbPrintfA(char* pszDest, size_t cbDest, const char* pszFormat, ...) -{ - HRESULT hr; - size_t cchDest; - - cchDest = cbDest / sizeof(char); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - va_list argList; - - va_start(argList, pszFormat); - - hr = StringVPrintfWorkerA(pszDest, cchDest, pszFormat, argList); - - va_end(argList); - } - - return hr; -} - -STRSAFEAPI StringCbPrintfW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszFormat, ...) -{ - HRESULT hr; - size_t cchDest; - - cchDest = cbDest / sizeof(wchar_t); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - va_list argList; - - va_start(argList, pszFormat); - - hr = StringVPrintfWorkerW(pszDest, cchDest, pszFormat, argList); - - va_end(argList); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CB_FUNCTIONS - - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchPrintfEx( - OUT LPTSTR pszDest OPTIONAL, - IN size_t cchDest, - OUT LPTSTR* ppszDestEnd OPTIONAL, - OUT size_t* pcchRemaining OPTIONAL, - IN DWORD dwFlags, - IN LPCTSTR pszFormat OPTIONAL, - ... - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'sprintf' with - some additional parameters. In addition to functionality provided by - StringCchPrintf, this routine also returns a pointer to the end of the - destination string and the number of characters left in the destination string - including the null terminator. The flags parameter allows additional controls. - -Arguments: - - pszDest - destination string - - cchDest - size of destination buffer in characters. - length must be sufficient to contain the resulting - formatted string plus the null terminator. - - ppszDestEnd - if ppszDestEnd is non-null, the function will return a - pointer to the end of the destination string. If the - function printed any data, the result will point to the - null termination character - - pcchRemaining - if pcchRemaining is non-null, the function will return - the number of characters left in the destination string, - including the null terminator - - dwFlags - controls some details of the string copy: - - STRSAFE_FILL_BEHIND_NULL - if the function succeeds, the low byte of dwFlags will be - used to fill the uninitialize part of destination buffer - behind the null terminator - - STRSAFE_IGNORE_NULLS - treat NULL string pointers like empty strings (TEXT("")) - - STRSAFE_FILL_ON_FAILURE - if the function fails, the low byte of dwFlags will be - used to fill all of the destination buffer, and it will - be null terminated. This will overwrite any truncated - string returned when the failure is - STRSAFE_E_INSUFFICIENT_BUFFER - - STRSAFE_NO_TRUNCATION / - STRSAFE_NULL_ON_FAILURE - if the function fails, the destination buffer will be set - to the empty string. This will overwrite any truncated string - returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. - - pszFormat - format string which must be null terminated - - ... - additional parameters to be formatted according to - the format string - -Notes: - Behavior is undefined if destination, format strings or any arguments - strings overlap. - - pszDest and pszFormat should not be NULL unless the STRSAFE_IGNORE_NULLS - flag is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and - pszFormat may be NULL. An error may still be returned even though NULLS - are ignored due to insufficient space. - -Return Value: - - S_OK - if there was source data and it was all concatenated and - the resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the print - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCchPrintfExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, ...); -STRSAFEAPI StringCchPrintfExW(wchar_t* pszDest, size_t cchDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const wchar_t* pszFormat, ...); -#ifdef UNICODE -#define StringCchPrintfEx StringCchPrintfExW -#else -#define StringCchPrintfEx StringCchPrintfExA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCchPrintfExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, ...) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - va_list argList; - - // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 - cbDest = cchDest * sizeof(char); - va_start(argList, pszFormat); - - hr = StringVPrintfExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags, pszFormat, argList); - - va_end(argList); - } - - return hr; -} - -STRSAFEAPI StringCchPrintfExW(wchar_t* pszDest, size_t cchDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const wchar_t* pszFormat, ...) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - va_list argList; - - // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - cbDest = cchDest * sizeof(wchar_t); - va_start(argList, pszFormat); - - hr = StringVPrintfExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags, pszFormat, argList); - - va_end(argList); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CCH_FUNCTIONS - - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbPrintfEx( - OUT LPTSTR pszDest OPTIONAL, - IN size_t cbDest, - OUT LPTSTR* ppszDestEnd OPTIONAL, - OUT size_t* pcbRemaining OPTIONAL, - IN DWORD dwFlags, - IN LPCTSTR pszFormat OPTIONAL, - ... - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'sprintf' with - some additional parameters. In addition to functionality provided by - StringCbPrintf, this routine also returns a pointer to the end of the - destination string and the number of bytes left in the destination string - including the null terminator. The flags parameter allows additional controls. - -Arguments: - - pszDest - destination string - - cbDest - size of destination buffer in bytes. - length must be sufficient to contain the resulting - formatted string plus the null terminator. - - ppszDestEnd - if ppszDestEnd is non-null, the function will return a - pointer to the end of the destination string. If the - function printed any data, the result will point to the - null termination character - - pcbRemaining - if pcbRemaining is non-null, the function will return - the number of bytes left in the destination string, - including the null terminator - - dwFlags - controls some details of the string copy: - - STRSAFE_FILL_BEHIND_NULL - if the function succeeds, the low byte of dwFlags will be - used to fill the uninitialize part of destination buffer - behind the null terminator - - STRSAFE_IGNORE_NULLS - treat NULL string pointers like empty strings (TEXT("")) - - STRSAFE_FILL_ON_FAILURE - if the function fails, the low byte of dwFlags will be - used to fill all of the destination buffer, and it will - be null terminated. This will overwrite any truncated - string returned when the failure is - STRSAFE_E_INSUFFICIENT_BUFFER - - STRSAFE_NO_TRUNCATION / - STRSAFE_NULL_ON_FAILURE - if the function fails, the destination buffer will be set - to the empty string. This will overwrite any truncated string - returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. - - pszFormat - format string which must be null terminated - - ... - additional parameters to be formatted according to - the format string - -Notes: - Behavior is undefined if destination, format strings or any arguments - strings overlap. - - pszDest and pszFormat should not be NULL unless the STRSAFE_IGNORE_NULLS - flag is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and - pszFormat may be NULL. An error may still be returned even though NULLS - are ignored due to insufficient space. - -Return Value: - - S_OK - if there was source data and it was all concatenated and - the resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the print - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCbPrintfExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const char* pszFormat, ...); -STRSAFEAPI StringCbPrintfExW(wchar_t* pszDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const wchar_t* pszFormat, ...); -#ifdef UNICODE -#define StringCbPrintfEx StringCbPrintfExW -#else -#define StringCbPrintfEx StringCbPrintfExA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCbPrintfExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const char* pszFormat, ...) -{ - HRESULT hr; - size_t cchDest; - size_t cchRemaining = 0; - - cchDest = cbDest / sizeof(char); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - va_list argList; - - va_start(argList, pszFormat); - - hr = StringVPrintfExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags, pszFormat, argList); - - va_end(argList); - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (pcbRemaining) - { - // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1 - *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)); - } - } - - return hr; -} - -STRSAFEAPI StringCbPrintfExW(wchar_t* pszDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const wchar_t* pszFormat, ...) -{ - HRESULT hr; - size_t cchDest; - size_t cchRemaining = 0; - - cchDest = cbDest / sizeof(wchar_t); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - va_list argList; - - va_start(argList, pszFormat); - - hr = StringVPrintfExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags, pszFormat, argList); - - va_end(argList); - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (pcbRemaining) - { - // safe to multiply cchRemaining * sizeof(wchar_t) since cchRemaining < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - *pcbRemaining = (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)); - } - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CB_FUNCTIONS - - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchVPrintfEx( - OUT LPTSTR pszDest OPTIONAL, - IN size_t cchDest, - OUT LPTSTR* ppszDestEnd OPTIONAL, - OUT size_t* pcchRemaining OPTIONAL, - IN DWORD dwFlags, - IN LPCTSTR pszFormat OPTIONAL, - IN va_list argList - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'vsprintf' with - some additional parameters. In addition to functionality provided by - StringCchVPrintf, this routine also returns a pointer to the end of the - destination string and the number of characters left in the destination string - including the null terminator. The flags parameter allows additional controls. - -Arguments: - - pszDest - destination string - - cchDest - size of destination buffer in characters. - length must be sufficient to contain the resulting - formatted string plus the null terminator. - - ppszDestEnd - if ppszDestEnd is non-null, the function will return a - pointer to the end of the destination string. If the - function printed any data, the result will point to the - null termination character - - pcchRemaining - if pcchRemaining is non-null, the function will return - the number of characters left in the destination string, - including the null terminator - - dwFlags - controls some details of the string copy: - - STRSAFE_FILL_BEHIND_NULL - if the function succeeds, the low byte of dwFlags will be - used to fill the uninitialize part of destination buffer - behind the null terminator - - STRSAFE_IGNORE_NULLS - treat NULL string pointers like empty strings (TEXT("")) - - STRSAFE_FILL_ON_FAILURE - if the function fails, the low byte of dwFlags will be - used to fill all of the destination buffer, and it will - be null terminated. This will overwrite any truncated - string returned when the failure is - STRSAFE_E_INSUFFICIENT_BUFFER - - STRSAFE_NO_TRUNCATION / - STRSAFE_NULL_ON_FAILURE - if the function fails, the destination buffer will be set - to the empty string. This will overwrite any truncated string - returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. - - pszFormat - format string which must be null terminated - - argList - va_list from the variable arguments according to the - stdarg.h convention - -Notes: - Behavior is undefined if destination, format strings or any arguments - strings overlap. - - pszDest and pszFormat should not be NULL unless the STRSAFE_IGNORE_NULLS - flag is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and - pszFormat may be NULL. An error may still be returned even though NULLS - are ignored due to insufficient space. - -Return Value: - - S_OK - if there was source data and it was all concatenated and - the resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the print - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCchVPrintfExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList); -STRSAFEAPI StringCchVPrintfExW(wchar_t* pszDest, size_t cchDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const wchar_t* pszFormat, va_list argList); -#ifdef UNICODE -#define StringCchVPrintfEx StringCchVPrintfExW -#else -#define StringCchVPrintfEx StringCchVPrintfExA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCchVPrintfExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - - // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 - cbDest = cchDest * sizeof(char); - - hr = StringVPrintfExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags, pszFormat, argList); - } - - return hr; -} - -STRSAFEAPI StringCchVPrintfExW(wchar_t* pszDest, size_t cchDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const wchar_t* pszFormat, va_list argList) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - - // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - cbDest = cchDest * sizeof(wchar_t); - - hr = StringVPrintfExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags, pszFormat, argList); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CCH_FUNCTIONS - - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbVPrintfEx( - OUT LPTSTR pszDest OPTIONAL, - IN size_t cbDest, - OUT LPTSTR* ppszDestEnd OPTIONAL, - OUT size_t* pcbRemaining OPTIONAL, - IN DWORD dwFlags, - IN LPCTSTR pszFormat OPTIONAL, - IN va_list argList - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'vsprintf' with - some additional parameters. In addition to functionality provided by - StringCbVPrintf, this routine also returns a pointer to the end of the - destination string and the number of characters left in the destination string - including the null terminator. The flags parameter allows additional controls. - -Arguments: - - pszDest - destination string - - cbDest - size of destination buffer in bytes. - length must be sufficient to contain the resulting - formatted string plus the null terminator. - - ppszDestEnd - if ppszDestEnd is non-null, the function will return - a pointer to the end of the destination string. If the - function printed any data, the result will point to the - null termination character - - pcbRemaining - if pcbRemaining is non-null, the function will return - the number of bytes left in the destination string, - including the null terminator - - dwFlags - controls some details of the string copy: - - STRSAFE_FILL_BEHIND_NULL - if the function succeeds, the low byte of dwFlags will be - used to fill the uninitialize part of destination buffer - behind the null terminator - - STRSAFE_IGNORE_NULLS - treat NULL string pointers like empty strings (TEXT("")) - - STRSAFE_FILL_ON_FAILURE - if the function fails, the low byte of dwFlags will be - used to fill all of the destination buffer, and it will - be null terminated. This will overwrite any truncated - string returned when the failure is - STRSAFE_E_INSUFFICIENT_BUFFER - - STRSAFE_NO_TRUNCATION / - STRSAFE_NULL_ON_FAILURE - if the function fails, the destination buffer will be set - to the empty string. This will overwrite any truncated string - returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. - - pszFormat - format string which must be null terminated - - argList - va_list from the variable arguments according to the - stdarg.h convention - -Notes: - Behavior is undefined if destination, format strings or any arguments - strings overlap. - - pszDest and pszFormat should not be NULL unless the STRSAFE_IGNORE_NULLS - flag is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and - pszFormat may be NULL. An error may still be returned even though NULLS - are ignored due to insufficient space. - -Return Value: - - S_OK - if there was source data and it was all concatenated and - the resultant dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that the print - operation failed due to insufficient space. When this - error occurs, the destination buffer is modified to - contain a truncated version of the ideal result and is - null terminated. This is useful for situations where - truncation is ok. - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function - ---*/ - -STRSAFEAPI StringCbVPrintfExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList); -STRSAFEAPI StringCbVPrintfExW(wchar_t* pszDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const wchar_t* pszFormat, va_list argList); -#ifdef UNICODE -#define StringCbVPrintfEx StringCbVPrintfExW -#else -#define StringCbVPrintfEx StringCbVPrintfExA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCbVPrintfExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList) -{ - HRESULT hr; - size_t cchDest; - size_t cchRemaining = 0; - - cchDest = cbDest / sizeof(char); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringVPrintfExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags, pszFormat, argList); - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (pcbRemaining) - { - // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1 - *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)); - } - } - - return hr; -} - -STRSAFEAPI StringCbVPrintfExW(wchar_t* pszDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const wchar_t* pszFormat, va_list argList) -{ - HRESULT hr; - size_t cchDest; - size_t cchRemaining = 0; - - cchDest = cbDest / sizeof(wchar_t); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringVPrintfExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags, pszFormat, argList); - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (pcbRemaining) - { - // safe to multiply cchRemaining * sizeof(wchar_t) since cchRemaining < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - *pcbRemaining = (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)); - } - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CB_FUNCTIONS - - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchGets( - OUT LPTSTR pszDest, - IN size_t cchDest - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'gets'. - The size of the destination buffer (in characters) is a parameter and - this function will not write past the end of this buffer and it will - ALWAYS null terminate the destination buffer (unless it is zero length). - - This routine is not a replacement for fgets. That function does not replace - newline characters with a null terminator. - - This function returns a hresult, and not a pointer. It returns - S_OK if any characters were read from stdin and copied to pszDest and - pszDest was null terminated, otherwise it will return a failure code. - -Arguments: - - pszDest - destination string - - cchDest - size of destination buffer in characters. - -Notes: - pszDest should not be NULL. See StringCchGetsEx if you require the handling - of NULL values. - - cchDest must be > 1 for this function to succeed. - -Return Value: - - S_OK - data was read from stdin and copied, and the resultant - dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_END_OF_FILE / - HRESULT_CODE(hr) == ERROR_HANDLE_EOF - - this return value indicates an error or end-of-file - condition, use feof or ferror to determine which one has - occured. - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that there was - insufficient space in the destination buffer to copy any - data - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function. - ---*/ - -#ifndef STRSAFE_LIB_IMPL -STRSAFE_INLINE_API StringCchGetsA(char* pszDest, size_t cchDest); -STRSAFE_INLINE_API StringCchGetsW(wchar_t* pszDest, size_t cchDest); -#ifdef UNICODE -#define StringCchGets StringCchGetsW -#else -#define StringCchGets StringCchGetsA -#endif // !UNICODE - -STRSAFE_INLINE_API StringCchGetsA(char* pszDest, size_t cchDest) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - - // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 - cbDest = cchDest * sizeof(char); - - hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, NULL, NULL, 0); - } - - return hr; -} - -STRSAFE_INLINE_API StringCchGetsW(wchar_t* pszDest, size_t cchDest) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - - // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - cbDest = cchDest * sizeof(wchar_t); - - hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, NULL, NULL, 0); - } - - return hr; -} -#endif // !STRSAFE_NO_CCH_FUNCTIONS -#endif // !STRSAFE_LIB_IMPL - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbGets( - OUT LPTSTR pszDest, - IN size_t cbDest - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'gets'. - The size of the destination buffer (in bytes) is a parameter and - this function will not write past the end of this buffer and it will - ALWAYS null terminate the destination buffer (unless it is zero length). - - This routine is not a replacement for fgets. That function does not replace - newline characters with a null terminator. - - This function returns a hresult, and not a pointer. It returns - S_OK if any characters were read from stdin and copied to pszDest - and pszDest was null terminated, otherwise it will return a failure code. - -Arguments: - - pszDest - destination string - - cbDest - size of destination buffer in bytes. - -Notes: - pszDest should not be NULL. See StringCbGetsEx if you require the handling - of NULL values. - - cbDest must be > sizeof(TCHAR) for this function to succeed. - -Return Value: - - S_OK - data was read from stdin and copied, and the resultant - dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_END_OF_FILE / - HRESULT_CODE(hr) == ERROR_HANDLE_EOF - - this return value indicates an error or end-of-file - condition, use feof or ferror to determine which one has - occured. - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that there was - insufficient space in the destination buffer to copy any - data - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function. - ---*/ - -#ifndef STRSAFE_LIB_IMPL -STRSAFE_INLINE_API StringCbGetsA(char* pszDest, size_t cbDest); -STRSAFE_INLINE_API StringCbGetsW(wchar_t* pszDest, size_t cbDest); -#ifdef UNICODE -#define StringCbGets StringCbGetsW -#else -#define StringCbGets StringCbGetsA -#endif // !UNICODE - -STRSAFE_INLINE_API StringCbGetsA(char* pszDest, size_t cbDest) -{ - HRESULT hr; - size_t cchDest; - - // convert to count of characters - cchDest = cbDest / sizeof(char); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, NULL, NULL, 0); - } - - return hr; -} - -STRSAFE_INLINE_API StringCbGetsW(wchar_t* pszDest, size_t cbDest) -{ - HRESULT hr; - size_t cchDest; - - // convert to count of characters - cchDest = cbDest / sizeof(wchar_t); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, NULL, NULL, 0); - } - - return hr; -} -#endif // !STRSAFE_NO_CB_FUNCTIONS -#endif // !STRSAFE_LIB_IMPL - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchGetsEx( - OUT LPTSTR pszDest OPTIONAL, - IN size_t cchDest, - OUT LPTSTR* ppszDestEnd OPTIONAL, - OUT size_t* pcchRemaining OPTIONAL, - IN DWORD dwFlags - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'gets' with - some additional parameters. In addition to functionality provided by - StringCchGets, this routine also returns a pointer to the end of the - destination string and the number of characters left in the destination string - including the null terminator. The flags parameter allows additional controls. - -Arguments: - - pszDest - destination string - - cchDest - size of destination buffer in characters. - - ppszDestEnd - if ppszDestEnd is non-null, the function will return a - pointer to the end of the destination string. If the - function copied any data, the result will point to the - null termination character - - pcchRemaining - if pcchRemaining is non-null, the function will return the - number of characters left in the destination string, - including the null terminator - - dwFlags - controls some details of the string copy: - - STRSAFE_FILL_BEHIND_NULL - if the function succeeds, the low byte of dwFlags will be - used to fill the uninitialize part of destination buffer - behind the null terminator - - STRSAFE_IGNORE_NULLS - treat NULL string pointers like empty strings (TEXT("")). - - STRSAFE_FILL_ON_FAILURE - if the function fails, the low byte of dwFlags will be - used to fill all of the destination buffer, and it will - be null terminated. - - STRSAFE_NO_TRUNCATION / - STRSAFE_NULL_ON_FAILURE - if the function fails, the destination buffer will be set - to the empty string. - -Notes: - pszDest should not be NULL unless the STRSAFE_IGNORE_NULLS flag is specified. - If STRSAFE_IGNORE_NULLS is passed and pszDest is NULL, an error may still be - returned even though NULLS are ignored - - cchDest must be > 1 for this function to succeed. - -Return Value: - - S_OK - data was read from stdin and copied, and the resultant - dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_END_OF_FILE / - HRESULT_CODE(hr) == ERROR_HANDLE_EOF - - this return value indicates an error or end-of-file - condition, use feof or ferror to determine which one has - occured. - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that there was - insufficient space in the destination buffer to copy any - data - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function. - ---*/ - -#ifndef STRSAFE_LIB_IMPL -STRSAFE_INLINE_API StringCchGetsExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -STRSAFE_INLINE_API StringCchGetsExW(wchar_t* pszDest, size_t cchDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); -#ifdef UNICODE -#define StringCchGetsEx StringCchGetsExW -#else -#define StringCchGetsEx StringCchGetsExA -#endif // !UNICODE - -STRSAFE_INLINE_API StringCchGetsExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - - // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 - cbDest = cchDest * sizeof(char); - - hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags); - } - - return hr; -} - -STRSAFE_INLINE_API StringCchGetsExW(wchar_t* pszDest, size_t cchDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr; - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cbDest; - - // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - cbDest = cchDest * sizeof(wchar_t); - - hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags); - } - - return hr; -} -#endif // !STRSAFE_NO_CCH_FUNCTIONS -#endif // !STRSAFE_LIB_IMPL - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbGetsEx( - OUT LPTSTR pszDest OPTIONAL, - IN size_t cbDest, - OUT LPTSTR* ppszDestEnd OPTIONAL, - OUT size_t* pcbRemaining OPTIONAL, - IN DWORD dwFlags - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'gets' with - some additional parameters. In addition to functionality provided by - StringCbGets, this routine also returns a pointer to the end of the - destination string and the number of characters left in the destination string - including the null terminator. The flags parameter allows additional controls. - -Arguments: - - pszDest - destination string - - cbDest - size of destination buffer in bytes. - - ppszDestEnd - if ppszDestEnd is non-null, the function will return a - pointer to the end of the destination string. If the - function copied any data, the result will point to the - null termination character - - pcbRemaining - if pbRemaining is non-null, the function will return the - number of bytes left in the destination string, - including the null terminator - - dwFlags - controls some details of the string copy: - - STRSAFE_FILL_BEHIND_NULL - if the function succeeds, the low byte of dwFlags will be - used to fill the uninitialize part of destination buffer - behind the null terminator - - STRSAFE_IGNORE_NULLS - treat NULL string pointers like empty strings (TEXT("")). - - STRSAFE_FILL_ON_FAILURE - if the function fails, the low byte of dwFlags will be - used to fill all of the destination buffer, and it will - be null terminated. - - STRSAFE_NO_TRUNCATION / - STRSAFE_NULL_ON_FAILURE - if the function fails, the destination buffer will be set - to the empty string. - -Notes: - pszDest should not be NULL unless the STRSAFE_IGNORE_NULLS flag is specified. - If STRSAFE_IGNORE_NULLS is passed and pszDest is NULL, an error may still be - returned even though NULLS are ignored - - cbDest must be > sizeof(TCHAR) for this function to succeed - -Return Value: - - S_OK - data was read from stdin and copied, and the resultant - dest string was null terminated - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - STRSAFE_E_END_OF_FILE / - HRESULT_CODE(hr) == ERROR_HANDLE_EOF - - this return value indicates an error or end-of-file - condition, use feof or ferror to determine which one has - occured. - - STRSAFE_E_INSUFFICIENT_BUFFER / - HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER - - this return value is an indication that there was - insufficient space in the destination buffer to copy any - data - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function. - ---*/ - -#ifndef STRSAFE_LIB_IMPL -STRSAFE_INLINE_API StringCbGetsExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pbRemaining, unsigned long dwFlags); -STRSAFE_INLINE_API StringCbGetsExW(wchar_t* pszDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); -#ifdef UNICODE -#define StringCbGetsEx StringCbGetsExW -#else -#define StringCbGetsEx StringCbGetsExA -#endif // !UNICODE - -STRSAFE_INLINE_API StringCbGetsExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) -{ - HRESULT hr; - size_t cchDest; - size_t cchRemaining = 0; - - cchDest = cbDest / sizeof(char); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags); - } - - if (SUCCEEDED(hr) || - (hr == STRSAFE_E_INSUFFICIENT_BUFFER) || - (hr == STRSAFE_E_END_OF_FILE)) - { - if (pcbRemaining) - { - // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1 - *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)); - } - } - - return hr; -} - -STRSAFE_INLINE_API StringCbGetsExW(wchar_t* pszDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) -{ - HRESULT hr; - size_t cchDest; - size_t cchRemaining = 0; - - cchDest = cbDest / sizeof(wchar_t); - - if (cchDest > STRSAFE_MAX_CCH) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags); - } - - if (SUCCEEDED(hr) || - (hr == STRSAFE_E_INSUFFICIENT_BUFFER) || - (hr == STRSAFE_E_END_OF_FILE)) - { - if (pcbRemaining) - { - // safe to multiply cchRemaining * sizeof(wchar_t) since cchRemaining < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - *pcbRemaining = (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)); - } - } - - return hr; -} -#endif // !STRSAFE_NO_CB_FUNCTIONS -#endif // !STRSAFE_LIB_IMPL - -#ifndef STRSAFE_NO_CCH_FUNCTIONS -/*++ - -STDAPI -StringCchLength( - IN LPCTSTR psz, - IN size_t cchMax, - OUT size_t* pcch OPTIONAL - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strlen'. - It is used to make sure a string is not larger than a given length, and - it optionally returns the current length in characters not including - the null terminator. - - This function returns a hresult, and not a pointer. It returns - S_OK if the string is non-null and the length including the null - terminator is less than or equal to cchMax characters. - -Arguments: - - psz - string to check the length of - - cchMax - maximum number of characters including the null terminator - that psz is allowed to contain - - pcch - if the function succeeds and pcch is non-null, the current length - in characters of psz excluding the null terminator will be returned. - This out parameter is equivalent to the return value of strlen(psz) - -Notes: - psz can be null but the function will fail - - cchMax should be greater than zero or the function will fail - -Return Value: - - S_OK - psz is non-null and the length including the null - terminator is less than or equal to cchMax characters - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function. - ---*/ - -STRSAFEAPI StringCchLengthA(const char* psz, size_t cchMax, size_t* pcch); -STRSAFEAPI StringCchLengthW(const wchar_t* psz, size_t cchMax, size_t* pcch); -#ifdef UNICODE -#define StringCchLength StringCchLengthW -#else -#define StringCchLength StringCchLengthA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCchLengthA(const char* psz, size_t cchMax, size_t* pcch) -{ - HRESULT hr; - - if ((psz == NULL) || (cchMax > STRSAFE_MAX_CCH)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringLengthWorkerA(psz, cchMax, pcch); - } - - return hr; -} - -STRSAFEAPI StringCchLengthW(const wchar_t* psz, size_t cchMax, size_t* pcch) -{ - HRESULT hr; - - if ((psz == NULL) || (cchMax > STRSAFE_MAX_CCH)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringLengthWorkerW(psz, cchMax, pcch); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CCH_FUNCTIONS - - -#ifndef STRSAFE_NO_CB_FUNCTIONS -/*++ - -STDAPI -StringCbLength( - IN LPCTSTR psz, - IN size_t cbMax, - OUT size_t* pcb OPTIONAL - ); - -Routine Description: - - This routine is a safer version of the C built-in function 'strlen'. - It is used to make sure a string is not larger than a given length, and - it optionally returns the current length in bytes not including - the null terminator. - - This function returns a hresult, and not a pointer. It returns - S_OK if the string is non-null and the length including the null - terminator is less than or equal to cbMax bytes. - -Arguments: - - psz - string to check the length of - - cbMax - maximum number of bytes including the null terminator - that psz is allowed to contain - - pcb - if the function succeeds and pcb is non-null, the current length - in bytes of psz excluding the null terminator will be returned. - This out parameter is equivalent to the return value of strlen(psz) * sizeof(TCHAR) - -Notes: - psz can be null but the function will fail - - cbMax should be greater than or equal to sizeof(TCHAR) or the function will fail - -Return Value: - - S_OK - psz is non-null and the length including the null - terminator is less than or equal to cbMax bytes - - failure - you can use the macro HRESULT_CODE() to get a win32 - error code for all hresult failure cases - - It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the - return value of this function. - ---*/ - -STRSAFEAPI StringCbLengthA(const char* psz, size_t cchMax, size_t* pcch); -STRSAFEAPI StringCbLengthW(const wchar_t* psz, size_t cchMax, size_t* pcch); -#ifdef UNICODE -#define StringCbLength StringCbLengthW -#else -#define StringCbLength StringCbLengthA -#endif // !UNICODE - -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCbLengthA(const char* psz, size_t cbMax, size_t* pcb) -{ - HRESULT hr; - size_t cchMax; - size_t cch = 0; - - cchMax = cbMax / sizeof(char); - - if ((psz == NULL) || (cchMax > STRSAFE_MAX_CCH)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringLengthWorkerA(psz, cchMax, &cch); - } - - if (SUCCEEDED(hr) && pcb) - { - // safe to multiply cch * sizeof(char) since cch < STRSAFE_MAX_CCH and sizeof(char) is 1 - *pcb = cch * sizeof(char); - } - - return hr; -} - -STRSAFEAPI StringCbLengthW(const wchar_t* psz, size_t cbMax, size_t* pcb) -{ - HRESULT hr; - size_t cchMax; - size_t cch = 0; - - cchMax = cbMax / sizeof(wchar_t); - - if ((psz == NULL) || (cchMax > STRSAFE_MAX_CCH)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = StringLengthWorkerW(psz, cchMax, &cch); - } - - if (SUCCEEDED(hr) && pcb) - { - // safe to multiply cch * sizeof(wchar_t) since cch < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 - *pcb = cch * sizeof(wchar_t); - } - - return hr; -} -#endif // STRSAFE_INLINE -#endif // !STRSAFE_NO_CB_FUNCTIONS - - -// these are the worker functions that actually do the work -#ifdef STRSAFE_INLINE -STRSAFEAPI StringCopyWorkerA(char* pszDest, size_t cchDest, const char* pszSrc) -{ - HRESULT hr = S_OK; - - if (cchDest == 0) - { - // can not null terminate a zero-byte dest buffer - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - while (cchDest && (*pszSrc != '\0')) - { - *pszDest++ = *pszSrc++; - cchDest--; - } - - if (cchDest == 0) - { - // we are going to truncate pszDest - pszDest--; - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - - *pszDest= '\0'; - } - - return hr; -} - -STRSAFEAPI StringCopyWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc) -{ - HRESULT hr = S_OK; - - if (cchDest == 0) - { - // can not null terminate a zero-byte dest buffer - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - while (cchDest && (*pszSrc != L'\0')) - { - *pszDest++ = *pszSrc++; - cchDest--; - } - - if (cchDest == 0) - { - // we are going to truncate pszDest - pszDest--; - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - - *pszDest= L'\0'; - } - - return hr; -} - -STRSAFEAPI StringCopyExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr = S_OK; - char* pszDestEnd = pszDest; - size_t cchRemaining = 0; - - // ASSERT(cbDest == (cchDest * sizeof(char)) || - // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char))); - - // only accept valid flags - if (dwFlags & (~STRSAFE_VALID_FLAGS)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - if (dwFlags & STRSAFE_IGNORE_NULLS) - { - if (pszDest == NULL) - { - if ((cchDest != 0) || (cbDest != 0)) - { - // NULL pszDest and non-zero cchDest/cbDest is invalid - hr = STRSAFE_E_INVALID_PARAMETER; - } - } - - if (pszSrc == NULL) - { - pszSrc = ""; - } - } - - if (SUCCEEDED(hr)) - { - if (cchDest == 0) - { - pszDestEnd = pszDest; - cchRemaining = 0; - - // only fail if there was actually src data to copy - if (*pszSrc != '\0') - { - if (pszDest == NULL) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - } - } - else - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - while (cchRemaining && (*pszSrc != '\0')) - { - *pszDestEnd++= *pszSrc++; - cchRemaining--; - } - - if (cchRemaining > 0) - { - if (dwFlags & STRSAFE_FILL_BEHIND_NULL) - { - memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(char)) + (cbDest % sizeof(char))); - } - } - else - { - // we are going to truncate pszDest - pszDestEnd--; - cchRemaining++; - - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - - *pszDestEnd = '\0'; - } - } - } - - if (FAILED(hr)) - { - if (pszDest) - { - if (dwFlags & STRSAFE_FILL_ON_FAILURE) - { - memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); - - if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - } - else if (cchDest > 0) - { - pszDestEnd = pszDest + cchDest - 1; - cchRemaining = 1; - - // null terminate the end of the string - *pszDestEnd = '\0'; - } - } - - if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) - { - if (cchDest > 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - // null terminate the beginning of the string - *pszDestEnd = '\0'; - } - } - } - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (ppszDestEnd) - { - *ppszDestEnd = pszDestEnd; - } - - if (pcchRemaining) - { - *pcchRemaining = cchRemaining; - } - } - - return hr; -} - -STRSAFEAPI StringCopyExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr = S_OK; - wchar_t* pszDestEnd = pszDest; - size_t cchRemaining = 0; - - // ASSERT(cbDest == (cchDest * sizeof(wchar_t)) || - // cbDest == (cchDest * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); - - // only accept valid flags - if (dwFlags & (~STRSAFE_VALID_FLAGS)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - if (dwFlags & STRSAFE_IGNORE_NULLS) - { - if (pszDest == NULL) - { - if ((cchDest != 0) || (cbDest != 0)) - { - // NULL pszDest and non-zero cchDest/cbDest is invalid - hr = STRSAFE_E_INVALID_PARAMETER; - } - } - - if (pszSrc == NULL) - { - pszSrc = L""; - } - } - - if (SUCCEEDED(hr)) - { - if (cchDest == 0) - { - pszDestEnd = pszDest; - cchRemaining = 0; - - // only fail if there was actually src data to copy - if (*pszSrc != L'\0') - { - if (pszDest == NULL) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - } - } - else - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - while (cchRemaining && (*pszSrc != L'\0')) - { - *pszDestEnd++= *pszSrc++; - cchRemaining--; - } - - if (cchRemaining > 0) - { - if (dwFlags & STRSAFE_FILL_BEHIND_NULL) - { - memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); - } - } - else - { - // we are going to truncate pszDest - pszDestEnd--; - cchRemaining++; - - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - - *pszDestEnd = L'\0'; - } - } - } - - if (FAILED(hr)) - { - if (pszDest) - { - if (dwFlags & STRSAFE_FILL_ON_FAILURE) - { - memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); - - if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - } - else if (cchDest > 0) - { - pszDestEnd = pszDest + cchDest - 1; - cchRemaining = 1; - - // null terminate the end of the string - *pszDestEnd = L'\0'; - } - } - - if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) - { - if (cchDest > 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - // null terminate the beginning of the string - *pszDestEnd = L'\0'; - } - } - } - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (ppszDestEnd) - { - *ppszDestEnd = pszDestEnd; - } - - if (pcchRemaining) - { - *pcchRemaining = cchRemaining; - } - } - - return hr; -} - -STRSAFEAPI StringCopyNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc) -{ - HRESULT hr = S_OK; - - if (cchDest == 0) - { - // can not null terminate a zero-byte dest buffer - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - while (cchDest && cchSrc && (*pszSrc != '\0')) - { - *pszDest++= *pszSrc++; - cchDest--; - cchSrc--; - } - - if (cchDest == 0) - { - // we are going to truncate pszDest - pszDest--; - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - - *pszDest= '\0'; - } - - return hr; -} - -STRSAFEAPI StringCopyNWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchSrc) -{ - HRESULT hr = S_OK; - - if (cchDest == 0) - { - // can not null terminate a zero-byte dest buffer - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - while (cchDest && cchSrc && (*pszSrc != L'\0')) - { - *pszDest++= *pszSrc++; - cchDest--; - cchSrc--; - } - - if (cchDest == 0) - { - // we are going to truncate pszDest - pszDest--; - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - - *pszDest= L'\0'; - } - - return hr; -} - -STRSAFEAPI StringCopyNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr = S_OK; - char* pszDestEnd = pszDest; - size_t cchRemaining = 0; - - // ASSERT(cbDest == (cchDest * sizeof(char)) || - // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char))); - - // only accept valid flags - if (dwFlags & (~STRSAFE_VALID_FLAGS)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - if (dwFlags & STRSAFE_IGNORE_NULLS) - { - if (pszDest == NULL) - { - if ((cchDest != 0) || (cbDest != 0)) - { - // NULL pszDest and non-zero cchDest/cbDest is invalid - hr = STRSAFE_E_INVALID_PARAMETER; - } - } - - if (pszSrc == NULL) - { - pszSrc = ""; - } - } - - if (SUCCEEDED(hr)) - { - if (cchDest == 0) - { - pszDestEnd = pszDest; - cchRemaining = 0; - - // only fail if there was actually src data to copy - if (*pszSrc != '\0') - { - if (pszDest == NULL) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - } - } - else - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - while (cchRemaining && cchSrc && (*pszSrc != '\0')) - { - *pszDestEnd++= *pszSrc++; - cchRemaining--; - cchSrc--; - } - - if (cchRemaining > 0) - { - if (dwFlags & STRSAFE_FILL_BEHIND_NULL) - { - memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(char)) + (cbDest % sizeof(char))); - } - } - else - { - // we are going to truncate pszDest - pszDestEnd--; - cchRemaining++; - - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - - *pszDestEnd = '\0'; - } - } - } - - if (FAILED(hr)) - { - if (pszDest) - { - if (dwFlags & STRSAFE_FILL_ON_FAILURE) - { - memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); - - if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - } - else if (cchDest > 0) - { - pszDestEnd = pszDest + cchDest - 1; - cchRemaining = 1; - - // null terminate the end of the string - *pszDestEnd = '\0'; - } - } - - if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) - { - if (cchDest > 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - // null terminate the beginning of the string - *pszDestEnd = '\0'; - } - } - } - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (ppszDestEnd) - { - *ppszDestEnd = pszDestEnd; - } - - if (pcchRemaining) - { - *pcchRemaining = cchRemaining; - } - } - - return hr; -} - -STRSAFEAPI StringCopyNExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, size_t cchSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr = S_OK; - wchar_t* pszDestEnd = pszDest; - size_t cchRemaining = 0; - - // ASSERT(cbDest == (cchDest * sizeof(wchar_t)) || - // cbDest == (cchDest * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); - - // only accept valid flags - if (dwFlags & (~STRSAFE_VALID_FLAGS)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - if (dwFlags & STRSAFE_IGNORE_NULLS) - { - if (pszDest == NULL) - { - if ((cchDest != 0) || (cbDest != 0)) - { - // NULL pszDest and non-zero cchDest/cbDest is invalid - hr = STRSAFE_E_INVALID_PARAMETER; - } - } - - if (pszSrc == NULL) - { - pszSrc = L""; - } - } - - if (SUCCEEDED(hr)) - { - if (cchDest == 0) - { - pszDestEnd = pszDest; - cchRemaining = 0; - - // only fail if there was actually src data to copy - if (*pszSrc != L'\0') - { - if (pszDest == NULL) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - } - } - else - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - while (cchRemaining && cchSrc && (*pszSrc != L'\0')) - { - *pszDestEnd++= *pszSrc++; - cchRemaining--; - cchSrc--; - } - - if (cchRemaining > 0) - { - if (dwFlags & STRSAFE_FILL_BEHIND_NULL) - { - memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); - } - } - else - { - // we are going to truncate pszDest - pszDestEnd--; - cchRemaining++; - - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - - *pszDestEnd = L'\0'; - } - } - } - - if (FAILED(hr)) - { - if (pszDest) - { - if (dwFlags & STRSAFE_FILL_ON_FAILURE) - { - memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); - - if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - } - else if (cchDest > 0) - { - pszDestEnd = pszDest + cchDest - 1; - cchRemaining = 1; - - // null terminate the end of the string - *pszDestEnd = L'\0'; - } - } - - if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) - { - if (cchDest > 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - // null terminate the beginning of the string - *pszDestEnd = L'\0'; - } - } - } - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (ppszDestEnd) - { - *ppszDestEnd = pszDestEnd; - } - - if (pcchRemaining) - { - *pcchRemaining = cchRemaining; - } - } - - return hr; -} - -STRSAFEAPI StringCatWorkerA(char* pszDest, size_t cchDest, const char* pszSrc) -{ - HRESULT hr; - size_t cchDestCurrent; - - hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent); - - if (SUCCEEDED(hr)) - { - hr = StringCopyWorkerA(pszDest + cchDestCurrent, - cchDest - cchDestCurrent, - pszSrc); - } - - return hr; -} - -STRSAFEAPI StringCatWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc) -{ - HRESULT hr; - size_t cchDestCurrent; - - hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent); - - if (SUCCEEDED(hr)) - { - hr = StringCopyWorkerW(pszDest + cchDestCurrent, - cchDest - cchDestCurrent, - pszSrc); - } - - return hr; -} - -STRSAFEAPI StringCatExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr = S_OK; - char* pszDestEnd = pszDest; - size_t cchRemaining = 0; - - // ASSERT(cbDest == (cchDest * sizeof(char)) || - // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char))); - - // only accept valid flags - if (dwFlags & (~STRSAFE_VALID_FLAGS)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cchDestCurrent; - - if (dwFlags & STRSAFE_IGNORE_NULLS) - { - if (pszDest == NULL) - { - if ((cchDest == 0) && (cbDest == 0)) - { - cchDestCurrent = 0; - } - else - { - // NULL pszDest and non-zero cchDest/cbDest is invalid - hr = STRSAFE_E_INVALID_PARAMETER; - } - } - else - { - hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent); - - if (SUCCEEDED(hr)) - { - pszDestEnd = pszDest + cchDestCurrent; - cchRemaining = cchDest - cchDestCurrent; - } - } - - if (pszSrc == NULL) - { - pszSrc = ""; - } - } - else - { - hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent); - - if (SUCCEEDED(hr)) - { - pszDestEnd = pszDest + cchDestCurrent; - cchRemaining = cchDest - cchDestCurrent; - } - } - - if (SUCCEEDED(hr)) - { - if (cchDest == 0) - { - // only fail if there was actually src data to append - if (*pszSrc != '\0') - { - if (pszDest == NULL) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - } - } - else - { - // we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass - // those flags through - hr = StringCopyExWorkerA(pszDestEnd, - cchRemaining, - (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)), - pszSrc, - &pszDestEnd, - &cchRemaining, - dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE))); - } - } - } - - if (FAILED(hr)) - { - if (pszDest) - { - // STRSAFE_NO_TRUNCATION is taken care of by StringCopyExWorkerA() - - if (dwFlags & STRSAFE_FILL_ON_FAILURE) - { - memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); - - if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - } - else - if (cchDest > 0) - { - pszDestEnd = pszDest + cchDest - 1; - cchRemaining = 1; - - // null terminate the end of the string - *pszDestEnd = '\0'; - } - } - - if (dwFlags & STRSAFE_NULL_ON_FAILURE) - { - if (cchDest > 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - // null terminate the beginning of the string - *pszDestEnd = '\0'; - } - } - } - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (ppszDestEnd) - { - *ppszDestEnd = pszDestEnd; - } - - if (pcchRemaining) - { - *pcchRemaining = cchRemaining; - } - } - - return hr; -} - -STRSAFEAPI StringCatExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr = S_OK; - wchar_t* pszDestEnd = pszDest; - size_t cchRemaining = 0; - - // ASSERT(cbDest == (cchDest * sizeof(wchar_t)) || - // cbDest == (cchDest * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); - - // only accept valid flags - if (dwFlags & (~STRSAFE_VALID_FLAGS)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - size_t cchDestCurrent; - - if (dwFlags & STRSAFE_IGNORE_NULLS) - { - if (pszDest == NULL) - { - if ((cchDest == 0) && (cbDest == 0)) - { - cchDestCurrent = 0; - } - else - { - // NULL pszDest and non-zero cchDest/cbDest is invalid - hr = STRSAFE_E_INVALID_PARAMETER; - } - } - else - { - hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent); - - if (SUCCEEDED(hr)) - { - pszDestEnd = pszDest + cchDestCurrent; - cchRemaining = cchDest - cchDestCurrent; - } - } - - if (pszSrc == NULL) - { - pszSrc = L""; - } - } - else - { - hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent); - - if (SUCCEEDED(hr)) - { - pszDestEnd = pszDest + cchDestCurrent; - cchRemaining = cchDest - cchDestCurrent; - } - } - - if (SUCCEEDED(hr)) - { - if (cchDest == 0) - { - // only fail if there was actually src data to append - if (*pszSrc != L'\0') - { - if (pszDest == NULL) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - } - } - else - { - // we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass - // those flags through - hr = StringCopyExWorkerW(pszDestEnd, - cchRemaining, - (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)), - pszSrc, - &pszDestEnd, - &cchRemaining, - dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE))); - } - } - } - - if (FAILED(hr)) - { - if (pszDest) - { - // STRSAFE_NO_TRUNCATION is taken care of by StringCopyExWorkerW() - - if (dwFlags & STRSAFE_FILL_ON_FAILURE) - { - memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); - - if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - } - else if (cchDest > 0) - { - pszDestEnd = pszDest + cchDest - 1; - cchRemaining = 1; - - // null terminate the end of the string - *pszDestEnd = L'\0'; - } - } - - if (dwFlags & STRSAFE_NULL_ON_FAILURE) - { - if (cchDest > 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - // null terminate the beginning of the string - *pszDestEnd = L'\0'; - } - } - } - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (ppszDestEnd) - { - *ppszDestEnd = pszDestEnd; - } - - if (pcchRemaining) - { - *pcchRemaining = cchRemaining; - } - } - - return hr; -} - -STRSAFEAPI StringCatNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend) -{ - HRESULT hr; - size_t cchDestCurrent; - - hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent); - - if (SUCCEEDED(hr)) - { - hr = StringCopyNWorkerA(pszDest + cchDestCurrent, - cchDest - cchDestCurrent, - pszSrc, - cchMaxAppend); - } - - return hr; -} - -STRSAFEAPI StringCatNWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchMaxAppend) -{ - HRESULT hr; - size_t cchDestCurrent; - - hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent); - - if (SUCCEEDED(hr)) - { - hr = StringCopyNWorkerW(pszDest + cchDestCurrent, - cchDest - cchDestCurrent, - pszSrc, - cchMaxAppend); - } - - return hr; -} - -STRSAFEAPI StringCatNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchMaxAppend, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr = S_OK; - char* pszDestEnd = pszDest; - size_t cchRemaining = 0; - size_t cchDestCurrent = 0; - - // ASSERT(cbDest == (cchDest * sizeof(char)) || - // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char))); - - // only accept valid flags - if (dwFlags & (~STRSAFE_VALID_FLAGS)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - if (dwFlags & STRSAFE_IGNORE_NULLS) - { - if (pszDest == NULL) - { - if ((cchDest == 0) && (cbDest == 0)) - { - cchDestCurrent = 0; - } - else - { - // NULL pszDest and non-zero cchDest/cbDest is invalid - hr = STRSAFE_E_INVALID_PARAMETER; - } - } - else - { - hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent); - - if (SUCCEEDED(hr)) - { - pszDestEnd = pszDest + cchDestCurrent; - cchRemaining = cchDest - cchDestCurrent; - } - } - - if (pszSrc == NULL) - { - pszSrc = ""; - } - } - else - { - hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent); - - if (SUCCEEDED(hr)) - { - pszDestEnd = pszDest + cchDestCurrent; - cchRemaining = cchDest - cchDestCurrent; - } - } - - if (SUCCEEDED(hr)) - { - if (cchDest == 0) - { - // only fail if there was actually src data to append - if (*pszSrc != '\0') - { - if (pszDest == NULL) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - } - } - else - { - // we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass - // those flags through - hr = StringCopyNExWorkerA(pszDestEnd, - cchRemaining, - (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)), - pszSrc, - cchMaxAppend, - &pszDestEnd, - &cchRemaining, - dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE))); - } - } - } - - if (FAILED(hr)) - { - if (pszDest) - { - // STRSAFE_NO_TRUNCATION is taken care of by StringCopyNExWorkerA() - - if (dwFlags & STRSAFE_FILL_ON_FAILURE) - { - memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); - - if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - } - else if (cchDest > 0) - { - pszDestEnd = pszDest + cchDest - 1; - cchRemaining = 1; - - // null terminate the end of the string - *pszDestEnd = '\0'; - } - } - - if (dwFlags & (STRSAFE_NULL_ON_FAILURE)) - { - if (cchDest > 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - // null terminate the beginning of the string - *pszDestEnd = '\0'; - } - } - } - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (ppszDestEnd) - { - *ppszDestEnd = pszDestEnd; - } - - if (pcchRemaining) - { - *pcchRemaining = cchRemaining; - } - } - - return hr; -} - -STRSAFEAPI StringCatNExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, size_t cchMaxAppend, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr = S_OK; - wchar_t* pszDestEnd = pszDest; - size_t cchRemaining = 0; - size_t cchDestCurrent = 0; - - - // ASSERT(cbDest == (cchDest * sizeof(wchar_t)) || - // cbDest == (cchDest * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); - - // only accept valid flags - if (dwFlags & (~STRSAFE_VALID_FLAGS)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - if (dwFlags & STRSAFE_IGNORE_NULLS) - { - if (pszDest == NULL) - { - if ((cchDest == 0) && (cbDest == 0)) - { - cchDestCurrent = 0; - } - else - { - // NULL pszDest and non-zero cchDest/cbDest is invalid - hr = STRSAFE_E_INVALID_PARAMETER; - } - } - else - { - hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent); - - if (SUCCEEDED(hr)) - { - pszDestEnd = pszDest + cchDestCurrent; - cchRemaining = cchDest - cchDestCurrent; - } - } - - if (pszSrc == NULL) - { - pszSrc = L""; - } - } - else - { - hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent); - - if (SUCCEEDED(hr)) - { - pszDestEnd = pszDest + cchDestCurrent; - cchRemaining = cchDest - cchDestCurrent; - } - } - - if (SUCCEEDED(hr)) - { - if (cchDest == 0) - { - // only fail if there was actually src data to append - if (*pszSrc != L'\0') - { - if (pszDest == NULL) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - } - } - else - { - // we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass - // those flags through - hr = StringCopyNExWorkerW(pszDestEnd, - cchRemaining, - (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)), - pszSrc, - cchMaxAppend, - &pszDestEnd, - &cchRemaining, - dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE))); - } - } - } - - if (FAILED(hr)) - { - if (pszDest) - { - // STRSAFE_NO_TRUNCATION is taken care of by StringCopyNExWorkerW() - - if (dwFlags & STRSAFE_FILL_ON_FAILURE) - { - memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); - - if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - } - else if (cchDest > 0) - { - pszDestEnd = pszDest + cchDest - 1; - cchRemaining = 1; - - // null terminate the end of the string - *pszDestEnd = L'\0'; - } - } - - if (dwFlags & (STRSAFE_NULL_ON_FAILURE)) - { - if (cchDest > 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - // null terminate the beginning of the string - *pszDestEnd = L'\0'; - } - } - } - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (ppszDestEnd) - { - *ppszDestEnd = pszDestEnd; - } - - if (pcchRemaining) - { - *pcchRemaining = cchRemaining; - } - } - - return hr; -} - -STRSAFEAPI StringVPrintfWorkerA(char* pszDest, size_t cchDest, const char* pszFormat, va_list argList) -{ - HRESULT hr = S_OK; - - if (cchDest == 0) - { - // can not null terminate a zero-byte dest buffer - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - int iRet; - size_t cchMax; - - // leave the last space for the null terminator - cchMax = cchDest - 1; - - iRet = _vsnprintf(pszDest, cchMax, pszFormat, argList); - // ASSERT((iRet < 0) || (((size_t)iRet) <= cchMax)); - - if ((iRet < 0) || (((size_t)iRet) > cchMax)) - { - // need to null terminate the string - pszDest += cchMax; - *pszDest = '\0'; - - // we have truncated pszDest - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - else if (((size_t)iRet) == cchMax) - { - // need to null terminate the string - pszDest += cchMax; - *pszDest = '\0'; - } - } - - return hr; -} - -STRSAFEAPI StringVPrintfWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszFormat, va_list argList) -{ - HRESULT hr = S_OK; - - if (cchDest == 0) - { - // can not null terminate a zero-byte dest buffer - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - int iRet; - size_t cchMax; - - // leave the last space for the null terminator - cchMax = cchDest - 1; - - iRet = _vsnwprintf(pszDest, cchMax, pszFormat, argList); - // ASSERT((iRet < 0) || (((size_t)iRet) <= cchMax)); - - if ((iRet < 0) || (((size_t)iRet) > cchMax)) - { - // need to null terminate the string - pszDest += cchMax; - *pszDest = L'\0'; - - // we have truncated pszDest - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - else if (((size_t)iRet) == cchMax) - { - // need to null terminate the string - pszDest += cchMax; - *pszDest = L'\0'; - } - } - - return hr; -} - -STRSAFEAPI StringVPrintfExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList) -{ - HRESULT hr = S_OK; - char* pszDestEnd = pszDest; - size_t cchRemaining = 0; - - // ASSERT(cbDest == (cchDest * sizeof(char)) || - // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char))); - - // only accept valid flags - if (dwFlags & (~STRSAFE_VALID_FLAGS)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - if (dwFlags & STRSAFE_IGNORE_NULLS) - { - if (pszDest == NULL) - { - if ((cchDest != 0) || (cbDest != 0)) - { - // NULL pszDest and non-zero cchDest/cbDest is invalid - hr = STRSAFE_E_INVALID_PARAMETER; - } - } - - if (pszFormat == NULL) - { - pszFormat = ""; - } - } - - if (SUCCEEDED(hr)) - { - if (cchDest == 0) - { - pszDestEnd = pszDest; - cchRemaining = 0; - - // only fail if there was actually a non-empty format string - if (*pszFormat != '\0') - { - if (pszDest == NULL) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - } - } - else - { - int iRet; - size_t cchMax; - - // leave the last space for the null terminator - cchMax = cchDest - 1; - - iRet = _vsnprintf(pszDest, cchMax, pszFormat, argList); - // ASSERT((iRet < 0) || (((size_t)iRet) <= cchMax)); - - if ((iRet < 0) || (((size_t)iRet) > cchMax)) - { - // we have truncated pszDest - pszDestEnd = pszDest + cchMax; - cchRemaining = 1; - - // need to null terminate the string - *pszDestEnd = '\0'; - - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - else if (((size_t)iRet) == cchMax) - { - // string fit perfectly - pszDestEnd = pszDest + cchMax; - cchRemaining = 1; - - // need to null terminate the string - *pszDestEnd = '\0'; - } - else if (((size_t)iRet) < cchMax) - { - // there is extra room - pszDestEnd = pszDest + iRet; - cchRemaining = cchDest - iRet; - - if (dwFlags & STRSAFE_FILL_BEHIND_NULL) - { - memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(char)) + (cbDest % sizeof(char))); - } - } - } - } - } - - if (FAILED(hr)) - { - if (pszDest) - { - if (dwFlags & STRSAFE_FILL_ON_FAILURE) - { - memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); - - if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - } - else if (cchDest > 0) - { - pszDestEnd = pszDest + cchDest - 1; - cchRemaining = 1; - - // null terminate the end of the string - *pszDestEnd = '\0'; - } - } - - if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) - { - if (cchDest > 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - // null terminate the beginning of the string - *pszDestEnd = '\0'; - } - } - } - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (ppszDestEnd) - { - *ppszDestEnd = pszDestEnd; - } - - if (pcchRemaining) - { - *pcchRemaining = cchRemaining; - } - } - - return hr; -} - -STRSAFEAPI StringVPrintfExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const wchar_t* pszFormat, va_list argList) -{ - HRESULT hr = S_OK; - wchar_t* pszDestEnd = pszDest; - size_t cchRemaining = 0; - - // ASSERT(cbDest == (cchDest * sizeof(wchar_t)) || - // cbDest == (cchDest * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); - - // only accept valid flags - if (dwFlags & (~STRSAFE_VALID_FLAGS)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - if (dwFlags & STRSAFE_IGNORE_NULLS) - { - if (pszDest == NULL) - { - if ((cchDest != 0) || (cbDest != 0)) - { - // NULL pszDest and non-zero cchDest/cbDest is invalid - hr = STRSAFE_E_INVALID_PARAMETER; - } - } - - if (pszFormat == NULL) - { - pszFormat = L""; - } - } - - if (SUCCEEDED(hr)) - { - if (cchDest == 0) - { - pszDestEnd = pszDest; - cchRemaining = 0; - - // only fail if there was actually a non-empty format string - if (*pszFormat != L'\0') - { - if (pszDest == NULL) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - } - } - else - { - int iRet; - size_t cchMax; - - // leave the last space for the null terminator - cchMax = cchDest - 1; - - iRet = _vsnwprintf(pszDest, cchMax, pszFormat, argList); - // ASSERT((iRet < 0) || (((size_t)iRet) <= cchMax)); - - if ((iRet < 0) || (((size_t)iRet) > cchMax)) - { - // we have truncated pszDest - pszDestEnd = pszDest + cchMax; - cchRemaining = 1; - - // need to null terminate the string - *pszDestEnd = L'\0'; - - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - else if (((size_t)iRet) == cchMax) - { - // string fit perfectly - pszDestEnd = pszDest + cchMax; - cchRemaining = 1; - - // need to null terminate the string - *pszDestEnd = L'\0'; - } - else if (((size_t)iRet) < cchMax) - { - // there is extra room - pszDestEnd = pszDest + iRet; - cchRemaining = cchDest - iRet; - - if (dwFlags & STRSAFE_FILL_BEHIND_NULL) - { - memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); - } - } - } - } - } - - if (FAILED(hr)) - { - if (pszDest) - { - if (dwFlags & STRSAFE_FILL_ON_FAILURE) - { - memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); - - if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - } - else if (cchDest > 0) - { - pszDestEnd = pszDest + cchDest - 1; - cchRemaining = 1; - - // null terminate the end of the string - *pszDestEnd = L'\0'; - } - } - - if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) - { - if (cchDest > 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - // null terminate the beginning of the string - *pszDestEnd = L'\0'; - } - } - } - } - - if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) - { - if (ppszDestEnd) - { - *ppszDestEnd = pszDestEnd; - } - - if (pcchRemaining) - { - *pcchRemaining = cchRemaining; - } - } - - return hr; -} - -STRSAFEAPI StringLengthWorkerA(const char* psz, size_t cchMax, size_t* pcch) -{ - HRESULT hr = S_OK; - size_t cchMaxPrev = cchMax; - - while (cchMax && (*psz != '\0')) - { - psz++; - cchMax--; - } - - if (cchMax == 0) - { - // the string is longer than cchMax - hr = STRSAFE_E_INVALID_PARAMETER; - } - - if (SUCCEEDED(hr) && pcch) - { - *pcch = cchMaxPrev - cchMax; - } - - return hr; -} - -STRSAFEAPI StringLengthWorkerW(const wchar_t* psz, size_t cchMax, size_t* pcch) -{ - HRESULT hr = S_OK; - size_t cchMaxPrev = cchMax; - - while (cchMax && (*psz != L'\0')) - { - psz++; - cchMax--; - } - - if (cchMax == 0) - { - // the string is longer than cchMax - hr = STRSAFE_E_INVALID_PARAMETER; - } - - if (SUCCEEDED(hr) && pcch) - { - *pcch = cchMaxPrev - cchMax; - } - - return hr; -} -#endif // STRSAFE_INLINE - -#ifndef STRSAFE_LIB_IMPL -STRSAFE_INLINE_API StringGetsExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr = S_OK; - char* pszDestEnd = pszDest; - size_t cchRemaining = 0; - - // ASSERT(cbDest == (cchDest * sizeof(char)) || - // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char))); - - // only accept valid flags - if (dwFlags & (~STRSAFE_VALID_FLAGS)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - if (dwFlags & STRSAFE_IGNORE_NULLS) - { - if (pszDest == NULL) - { - if ((cchDest != 0) || (cbDest != 0)) - { - // NULL pszDest and non-zero cchDest/cbDest is invalid - hr = STRSAFE_E_INVALID_PARAMETER; - } - } - } - - if (SUCCEEDED(hr)) - { - if (cchDest <= 1) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - if (cchDest == 1) - { - *pszDestEnd = '\0'; - } - - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - else - { - char ch; - - pszDestEnd = pszDest; - cchRemaining = cchDest; - - while ((cchRemaining > 1) && (ch = (char)getc(stdin)) != '\n') - { - if (ch == EOF) - { - if (pszDestEnd == pszDest) - { - // we failed to read anything from stdin - hr = STRSAFE_E_END_OF_FILE; - } - break; - } - - *pszDestEnd = ch; - - pszDestEnd++; - cchRemaining--; - } - - if (cchRemaining > 0) - { - // there is extra room - if (dwFlags & STRSAFE_FILL_BEHIND_NULL) - { - memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(char)) + (cbDest % sizeof(char))); - } - } - - *pszDestEnd = '\0'; - } - } - } - - if (FAILED(hr)) - { - if (pszDest) - { - if (dwFlags & STRSAFE_FILL_ON_FAILURE) - { - memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); - - if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - } - else if (cchDest > 0) - { - pszDestEnd = pszDest + cchDest - 1; - cchRemaining = 1; - - // null terminate the end of the string - *pszDestEnd = '\0'; - } - } - - if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) - { - if (cchDest > 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - // null terminate the beginning of the string - *pszDestEnd = '\0'; - } - } - } - } - - if (SUCCEEDED(hr) || - (hr == STRSAFE_E_INSUFFICIENT_BUFFER) || - (hr == STRSAFE_E_END_OF_FILE)) - { - if (ppszDestEnd) - { - *ppszDestEnd = pszDestEnd; - } - - if (pcchRemaining) - { - *pcchRemaining = cchRemaining; - } - } - - return hr; -} - -STRSAFE_INLINE_API StringGetsExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) -{ - HRESULT hr = S_OK; - wchar_t* pszDestEnd = pszDest; - size_t cchRemaining = 0; - - // ASSERT(cbDest == (cchDest * sizeof(char)) || - // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char))); - - // only accept valid flags - if (dwFlags & (~STRSAFE_VALID_FLAGS)) - { - hr = STRSAFE_E_INVALID_PARAMETER; - } - else - { - if (dwFlags & STRSAFE_IGNORE_NULLS) - { - if (pszDest == NULL) - { - if ((cchDest != 0) || (cbDest != 0)) - { - // NULL pszDest and non-zero cchDest/cbDest is invalid - hr = STRSAFE_E_INVALID_PARAMETER; - } - } - } - - if (SUCCEEDED(hr)) - { - if (cchDest <= 1) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - if (cchDest == 1) - { - *pszDestEnd = L'\0'; - } - - hr = STRSAFE_E_INSUFFICIENT_BUFFER; - } - else - { - wchar_t ch; - - pszDestEnd = pszDest; - cchRemaining = cchDest; - - while ((cchRemaining > 1) && (ch = (wchar_t)getwc(stdin)) != L'\n') - { - if (ch == EOF) - { - if (pszDestEnd == pszDest) - { - // we failed to read anything from stdin - hr = STRSAFE_E_END_OF_FILE; - } - break; - } - - *pszDestEnd = ch; - - pszDestEnd++; - cchRemaining--; - } - - if (cchRemaining > 0) - { - // there is extra room - if (dwFlags & STRSAFE_FILL_BEHIND_NULL) - { - memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); - } - } - - *pszDestEnd = L'\0'; - } - } - } - - if (FAILED(hr)) - { - if (pszDest) - { - if (dwFlags & STRSAFE_FILL_ON_FAILURE) - { - memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); - - if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - } - else if (cchDest > 0) - { - pszDestEnd = pszDest + cchDest - 1; - cchRemaining = 1; - - // null terminate the end of the string - *pszDestEnd = L'\0'; - } - } - - if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) - { - if (cchDest > 0) - { - pszDestEnd = pszDest; - cchRemaining = cchDest; - - // null terminate the beginning of the string - *pszDestEnd = L'\0'; - } - } - } - } - - if (SUCCEEDED(hr) || - (hr == STRSAFE_E_INSUFFICIENT_BUFFER) || - (hr == STRSAFE_E_END_OF_FILE)) - { - if (ppszDestEnd) - { - *ppszDestEnd = pszDestEnd; - } - - if (pcchRemaining) - { - *pcchRemaining = cchRemaining; - } - } - - return hr; -} -#endif // !STRSAFE_LIB_IMPL - - -// Do not call these functions, they are worker functions for internal use within this file -#ifdef DEPRECATE_SUPPORTED -#pragma deprecated(StringCopyWorkerA) -#pragma deprecated(StringCopyWorkerW) -#pragma deprecated(StringCopyExWorkerA) -#pragma deprecated(StringCopyExWorkerW) -#pragma deprecated(StringCatWorkerA) -#pragma deprecated(StringCatWorkerW) -#pragma deprecated(StringCatExWorkerA) -#pragma deprecated(StringCatExWorkerW) -#pragma deprecated(StringCatNWorkerA) -#pragma deprecated(StringCatNWorkerW) -#pragma deprecated(StringCatNExWorkerA) -#pragma deprecated(StringCatNExWorkerW) -#pragma deprecated(StringVPrintfWorkerA) -#pragma deprecated(StringVPrintfWorkerW) -#pragma deprecated(StringVPrintfExWorkerA) -#pragma deprecated(StringVPrintfExWorkerW) -#pragma deprecated(StringLengthWorkerA) -#pragma deprecated(StringLengthWorkerW) -#else -#define StringCopyWorkerA StringCopyWorkerA_instead_use_StringCchCopyA_or_StringCchCopyExA; -#define StringCopyWorkerW StringCopyWorkerW_instead_use_StringCchCopyW_or_StringCchCopyExW; -#define StringCopyExWorkerA StringCopyExWorkerA_instead_use_StringCchCopyA_or_StringCchCopyExA; -#define StringCopyExWorkerW StringCopyExWorkerW_instead_use_StringCchCopyW_or_StringCchCopyExW; -#define StringCatWorkerA StringCatWorkerA_instead_use_StringCchCatA_or_StringCchCatExA; -#define StringCatWorkerW StringCatWorkerW_instead_use_StringCchCatW_or_StringCchCatExW; -#define StringCatExWorkerA StringCatExWorkerA_instead_use_StringCchCatA_or_StringCchCatExA; -#define StringCatExWorkerW StringCatExWorkerW_instead_use_StringCchCatW_or_StringCchCatExW; -#define StringCatNWorkerA StringCatNWorkerA_instead_use_StringCchCatNA_or_StrincCbCatNA; -#define StringCatNWorkerW StringCatNWorkerW_instead_use_StringCchCatNW_or_StringCbCatNW; -#define StringCatNExWorkerA StringCatNExWorkerA_instead_use_StringCchCatNExA_or_StringCbCatNExA; -#define StringCatNExWorkerW StringCatNExWorkerW_instead_use_StringCchCatNExW_or_StringCbCatNExW; -#define StringVPrintfWorkerA StringVPrintfWorkerA_instead_use_StringCchVPrintfA_or_StringCchVPrintfExA; -#define StringVPrintfWorkerW StringVPrintfWorkerW_instead_use_StringCchVPrintfW_or_StringCchVPrintfExW; -#define StringVPrintfExWorkerA StringVPrintfExWorkerA_instead_use_StringCchVPrintfA_or_StringCchVPrintfExA; -#define StringVPrintfExWorkerW StringVPrintfExWorkerW_instead_use_StringCchVPrintfW_or_StringCchVPrintfExW; -#define StringLengthWorkerA StringLengthWorkerA_instead_use_StringCchLengthA_or_StringCbLengthA; -#define StringLengthWorkerW StringLengthWorkerW_instead_use_StringCchLengthW_or_StringCbLengthW; -#endif // !DEPRECATE_SUPPORTED - - -#ifndef STRSAFE_NO_DEPRECATE -// Deprecate all of the unsafe functions to generate compiletime errors. If you do not want -// this then you can #define STRSAFE_NO_DEPRECATE before including this file. -#ifdef DEPRECATE_SUPPORTED - -// First all the names that are a/w variants (or shouldn't be #defined by now anyway). -#pragma deprecated(lstrcpyA) -#pragma deprecated(lstrcpyW) -#pragma deprecated(lstrcatA) -#pragma deprecated(lstrcatW) -#pragma deprecated(wsprintfA) -#pragma deprecated(wsprintfW) - -#pragma deprecated(StrCpyW) -#pragma deprecated(StrCatW) -#pragma deprecated(StrNCatA) -#pragma deprecated(StrNCatW) -#pragma deprecated(StrCatNA) -#pragma deprecated(StrCatNW) -#pragma deprecated(wvsprintfA) -#pragma deprecated(wvsprintfW) - -#pragma deprecated(strcpy) -#pragma deprecated(wcscpy) -#pragma deprecated(strcat) -#pragma deprecated(wcscat) -#pragma deprecated(sprintf) -#pragma deprecated(swprintf) -#pragma deprecated(vsprintf) -#pragma deprecated(vswprintf) -#pragma deprecated(_snprintf) -#pragma deprecated(_snwprintf) -#pragma deprecated(_vsnprintf) -#pragma deprecated(_vsnwprintf) -#pragma deprecated(gets) -#pragma deprecated(_getws) - -// Then all the windows.h names - we need to undef and redef based on UNICODE setting -#undef lstrcpy -#undef lstrcat -#undef wsprintf -#undef wvsprintf -#pragma deprecated(lstrcpy) -#pragma deprecated(lstrcat) -#pragma deprecated(wsprintf) -#pragma deprecated(wvsprintf) -#ifdef UNICODE -#define lstrcpy lstrcpyW -#define lstrcat lstrcatW -#define wsprintf wsprintfW -#define wvsprintf wvsprintfW -#else -#define lstrcpy lstrcpyA -#define lstrcat lstrcatA -#define wsprintf wsprintfA -#define wvsprintf wvsprintfA -#endif - -// Then the shlwapi names - they key off UNICODE also. -#undef StrCpyA -#undef StrCpy -#undef StrCatA -#undef StrCat -#undef StrNCat -#undef StrCatN -#pragma deprecated(StrCpyA) -#pragma deprecated(StrCatA) -#pragma deprecated(StrCatN) -#pragma deprecated(StrCpy) -#pragma deprecated(StrCat) -#pragma deprecated(StrNCat) -#define StrCpyA lstrcpyA -#define StrCatA lstrcatA -#define StrCatN StrNCat -#ifdef UNICODE -#define StrCpy StrCpyW -#define StrCat StrCatW -#define StrNCat StrNCatW -#else -#define StrCpy lstrcpyA -#define StrCat lstrcatA -#define StrNCat StrNCatA -#endif - -// Then all the CRT names - we need to undef/redef based on _UNICODE value. -#undef _tcscpy -#undef _ftcscpy -#undef _tcscat -#undef _ftcscat -#undef _stprintf -#undef _sntprintf -#undef _vstprintf -#undef _vsntprintf -#undef _getts -#pragma deprecated(_tcscpy) -#pragma deprecated(_ftcscpy) -#pragma deprecated(_tcscat) -#pragma deprecated(_ftcscat) -#pragma deprecated(_stprintf) -#pragma deprecated(_sntprintf) -#pragma deprecated(_vstprintf) -#pragma deprecated(_vsntprintf) -#pragma deprecated(_getts) -#ifdef _UNICODE -#define _tcscpy wcscpy -#define _ftcscpy wcscpy -#define _tcscat wcscat -#define _ftcscat wcscat -#define _stprintf swprintf -#define _sntprintf _snwprintf -#define _vstprintf vswprintf -#define _vsntprintf _vsnwprintf -#define _getts _getws -#else -#define _tcscpy strcpy -#define _ftcscpy strcpy -#define _tcscat strcat -#define _ftcscat strcat -#define _stprintf sprintf -#define _sntprintf _snprintf -#define _vstprintf vsprintf -#define _vsntprintf _vsnprintf -#define _getts gets -#endif - -#else // DEPRECATE_SUPPORTED - -#undef strcpy -#define strcpy strcpy_instead_use_StringCbCopyA_or_StringCchCopyA; - -#undef wcscpy -#define wcscpy wcscpy_instead_use_StringCbCopyW_or_StringCchCopyW; - -#undef strcat -#define strcat strcat_instead_use_StringCbCatA_or_StringCchCatA; - -#undef wcscat -#define wcscat wcscat_instead_use_StringCbCatW_or_StringCchCatW; - -#undef sprintf -#define sprintf sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA; - -#undef swprintf -#define swprintf swprintf_instead_use_StringCbPrintfW_or_StringCchPrintfW; - -#undef vsprintf -#define vsprintf vsprintf_instead_use_StringCbVPrintfA_or_StringCchVPrintfA; - -#undef vswprintf -#define vswprintf vswprintf_instead_use_StringCbVPrintfW_or_StringCchVPrintfW; - -#undef _snprintf -#define _snprintf _snprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA; - -#undef _snwprintf -#define _snwprintf _snwprintf_instead_use_StringCbPrintfW_or_StringCchPrintfW; - -#undef _vsnprintf -#define _vsnprintf _vsnprintf_instead_use_StringCbVPrintfA_or_StringCchVPrintfA; - -#undef _vsnwprintf -#define _vsnwprintf _vsnwprintf_instead_use_StringCbVPrintfW_or_StringCchVPrintfW; - -#undef strcpyA -#define strcpyA strcpyA_instead_use_StringCbCopyA_or_StringCchCopyA; - -#undef strcpyW -#define strcpyW strcpyW_instead_use_StringCbCopyW_or_StringCchCopyW; - -#undef lstrcpy -#define lstrcpy lstrcpy_instead_use_StringCbCopy_or_StringCchCopy; - -#undef lstrcpyA -#define lstrcpyA lstrcpyA_instead_use_StringCbCopyA_or_StringCchCopyA; - -#undef lstrcpyW -#define lstrcpyW lstrcpyW_instead_use_StringCbCopyW_or_StringCchCopyW; - -#undef StrCpy -#define StrCpy StrCpy_instead_use_StringCbCopy_or_StringCchCopy; - -#undef StrCpyA -#define StrCpyA StrCpyA_instead_use_StringCbCopyA_or_StringCchCopyA; - -#undef StrCpyW -#define StrCpyW StrCpyW_instead_use_StringCbCopyW_or_StringCchCopyW; - -#undef _tcscpy -#define _tcscpy _tcscpy_instead_use_StringCbCopy_or_StringCchCopy; - -#undef _ftcscpy -#define _ftcscpy _ftcscpy_instead_use_StringCbCopy_or_StringCchCopy; - -#undef lstrcat -#define lstrcat lstrcat_instead_use_StringCbCat_or_StringCchCat; - -#undef lstrcatA -#define lstrcatA lstrcatA_instead_use_StringCbCatA_or_StringCchCatA; - -#undef lstrcatW -#define lstrcatW lstrcatW_instead_use_StringCbCatW_or_StringCchCatW; - -#undef StrCat -#define StrCat StrCat_instead_use_StringCbCat_or_StringCchCat; - -#undef StrCatA -#define StrCatA StrCatA_instead_use_StringCbCatA_or_StringCchCatA; - -#undef StrCatW -#define StrCatW StrCatW_instead_use_StringCbCatW_or_StringCchCatW; - -#undef StrNCat -#define StrNCat StrNCat_instead_use_StringCbCatN_or_StringCchCatN; - -#undef StrNCatA -#define StrNCatA StrNCatA_instead_use_StringCbCatNA_or_StringCchCatNA; - -#undef StrNCatW -#define StrNCatW StrNCatW_instead_use_StringCbCatNW_or_StringCchCatNW; - -#undef StrCatN -#define StrCatN StrCatN_instead_use_StringCbCatN_or_StringCchCatN; - -#undef StrCatNA -#define StrCatNA StrCatNA_instead_use_StringCbCatNA_or_StringCchCatNA; - -#undef StrCatNW -#define StrCatNW StrCatNW_instead_use_StringCbCatNW_or_StringCchCatNW; - -#undef _tcscat -#define _tcscat _tcscat_instead_use_StringCbCat_or_StringCchCat; - -#undef _ftcscat -#define _ftcscat _ftcscat_instead_use_StringCbCat_or_StringCchCat; - -#undef wsprintf -#define wsprintf wsprintf_instead_use_StringCbPrintf_or_StringCchPrintf; - -#undef wsprintfA -#define wsprintfA wsprintfA_instead_use_StringCbPrintfA_or_StringCchPrintfA; - -#undef wsprintfW -#define wsprintfW wsprintfW_instead_use_StringCbPrintfW_or_StringCchPrintfW; - -#undef wvsprintf -#define wvsprintf wvsprintf_instead_use_StringCbVPrintf_or_StringCchVPrintf; - -#undef wvsprintfA -#define wvsprintfA wvsprintfA_instead_use_StringCbVPrintfA_or_StringCchVPrintfA; - -#undef wvsprintfW -#define wvsprintfW wvsprintfW_instead_use_StringCbVPrintfW_or_StringCchVPrintfW; - -#undef _vstprintf -#define _vstprintf _vstprintf_instead_use_StringCbVPrintf_or_StringCchVPrintf; - -#undef _vsntprintf -#define _vsntprintf _vsntprintf_instead_use_StringCbVPrintf_or_StringCchVPrintf; - -#undef _stprintf -#define _stprintf _stprintf_instead_use_StringCbPrintf_or_StringCchPrintf; - -#undef _sntprintf -#define _sntprintf _sntprintf_instead_use_StringCbPrintf_or_StringCchPrintf; - -#undef _getts -#define _getts _getts_instead_use_StringCbGets_or_StringCchGets; - -#undef gets -#define gets _gets_instead_use_StringCbGetsA_or_StringCchGetsA; - -#undef _getws -#define _getws _getws_instead_use_StringCbGetsW_or_StringCchGetsW; - -#endif // !DEPRECATE_SUPPORTED -#endif // !STRSAFE_NO_DEPRECATE - -#ifdef _NTSTRSAFE_H_INCLUDED_ -#pragma warning(pop) -#endif // _NTSTRSAFE_H_INCLUDED_ - -#endif // _STRSAFE_H_INCLUDED_ +/****************************************************************** +* * +* strsafe.h -- This module defines safer C library string * +* routine replacements. These are meant to make C * +* a bit more safe in reference to security and * +* robustness * +* * +* Copyright (c) Microsoft Corp. All rights reserved. * +* * +******************************************************************/ +#ifndef _STRSAFE_H_INCLUDED_ +#define _STRSAFE_H_INCLUDED_ +#pragma once + +#include // for _vsnprintf, _vsnwprintf, getc, getwc +#include // for memset +#include // for va_start, etc. + + +#ifndef _SIZE_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 size_t; +#else +typedef __w64 unsigned int size_t; +#endif // !_WIN64 +#define _SIZE_T_DEFINED +#endif // !_SIZE_T_DEFINED + +#if !defined(_WCHAR_T_DEFINED) && !defined(_NATIVE_WCHAR_T_DEFINED) +typedef unsigned short wchar_t; +#define _WCHAR_T_DEFINED +#endif + +#ifndef _HRESULT_DEFINED +#define _HRESULT_DEFINED +typedef long HRESULT; +#endif // !_HRESULT_DEFINED + +#ifndef SUCCEEDED +#define SUCCEEDED(hr) ((HRESULT)(hr) >= 0) +#endif + +#ifndef FAILED +#define FAILED(hr) ((HRESULT)(hr) < 0) +#endif + +#ifndef S_OK +#define S_OK ((HRESULT)0x00000000L) +#endif + +#ifdef __cplusplus +#define _STRSAFE_EXTERN_C extern "C" +#else +#define _STRSAFE_EXTERN_C extern +#endif + +// If you do not want to use these functions inline (and instead want to link w/ strsafe.lib), then +// #define STRSAFE_LIB before including this header file. +#if defined(STRSAFE_LIB) +#define STRSAFEAPI _STRSAFE_EXTERN_C HRESULT __stdcall +#pragma comment(lib, "strsafe.lib") +#elif defined(STRSAFE_LIB_IMPL) +#define STRSAFEAPI _STRSAFE_EXTERN_C HRESULT __stdcall +#else +#define STRSAFEAPI __inline HRESULT __stdcall +#define STRSAFE_INLINE +#endif + +// Some functions always run inline because they use stdin and we want to avoid building multiple +// versions of strsafe lib depending on if you use msvcrt, libcmt, etc. +#define STRSAFE_INLINE_API __inline HRESULT __stdcall + +// The user can request no "Cb" or no "Cch" fuctions, but not both! +#if defined(STRSAFE_NO_CB_FUNCTIONS) && defined(STRSAFE_NO_CCH_FUNCTIONS) +#error cannot specify both STRSAFE_NO_CB_FUNCTIONS and STRSAFE_NO_CCH_FUNCTIONS !! +#endif + +// This should only be defined when we are building strsafe.lib +#ifdef STRSAFE_LIB_IMPL +#define STRSAFE_INLINE +#endif + + +// If both strsafe.h and ntstrsafe.h are included, only use definitions from one. +#ifndef _NTSTRSAFE_H_INCLUDED_ + +#define STRSAFE_MAX_CCH 2147483647 // max # of characters we support (same as INT_MAX) + +// Flags for controling the Ex functions +// +// STRSAFE_FILL_BYTE(0xFF) 0x000000FF // bottom byte specifies fill pattern +#define STRSAFE_IGNORE_NULLS 0x00000100 // treat null as TEXT("") -- don't fault on NULL buffers +#define STRSAFE_FILL_BEHIND_NULL 0x00000200 // fill in extra space behind the null terminator +#define STRSAFE_FILL_ON_FAILURE 0x00000400 // on failure, overwrite pszDest with fill pattern and null terminate it +#define STRSAFE_NULL_ON_FAILURE 0x00000800 // on failure, set *pszDest = TEXT('\0') +#define STRSAFE_NO_TRUNCATION 0x00001000 // instead of returning a truncated result, copy/append nothing to pszDest and null terminate it + +#define STRSAFE_VALID_FLAGS (0x000000FF | STRSAFE_IGNORE_NULLS | STRSAFE_FILL_BEHIND_NULL | STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION) + +// helper macro to set the fill character and specify buffer filling +#define STRSAFE_FILL_BYTE(x) ((unsigned long)((x & 0x000000FF) | STRSAFE_FILL_BEHIND_NULL)) +#define STRSAFE_FAILURE_BYTE(x) ((unsigned long)((x & 0x000000FF) | STRSAFE_FILL_ON_FAILURE)) + +#define STRSAFE_GET_FILL_PATTERN(dwFlags) ((int)(dwFlags & 0x000000FF)) + +#endif // _NTSTRSAFE_H_INCLUDED_ + +// STRSAFE error return codes +// +#define STRSAFE_E_INSUFFICIENT_BUFFER ((HRESULT)0x8007007AL) // 0x7A = 122L = ERROR_INSUFFICIENT_BUFFER +#define STRSAFE_E_INVALID_PARAMETER ((HRESULT)0x80070057L) // 0x57 = 87L = ERROR_INVALID_PARAMETER +#define STRSAFE_E_END_OF_FILE ((HRESULT)0x80070026L) // 0x26 = 38L = ERROR_HANDLE_EOF + +// prototypes for the worker functions +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCopyWorkerA(char* pszDest, size_t cchDest, const char* pszSrc); +STRSAFEAPI StringCopyWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc); +STRSAFEAPI StringCopyExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +STRSAFEAPI StringCopyExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +STRSAFEAPI StringCopyNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc); +STRSAFEAPI StringCopyNWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchSrc); +STRSAFEAPI StringCopyNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +STRSAFEAPI StringCopyNExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, size_t cchSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +STRSAFEAPI StringCatWorkerA(char* pszDest, size_t cchDest, const char* pszSrc); +STRSAFEAPI StringCatWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc); +STRSAFEAPI StringCatExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +STRSAFEAPI StringCatExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +STRSAFEAPI StringCatNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend); +STRSAFEAPI StringCatNWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchMaxAppend); +STRSAFEAPI StringCatNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchMaxAppend, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +STRSAFEAPI StringCatNExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, size_t cchMaxAppend, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +STRSAFEAPI StringVPrintfWorkerA(char* pszDest, size_t cchDest, const char* pszFormat, va_list argList); +STRSAFEAPI StringVPrintfWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszFormat, va_list argList); +STRSAFEAPI StringVPrintfExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList); +STRSAFEAPI StringVPrintfExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const wchar_t* pszFormat, va_list argList); +STRSAFEAPI StringLengthWorkerA(const char* psz, size_t cchMax, size_t* pcch); +STRSAFEAPI StringLengthWorkerW(const wchar_t* psz, size_t cchMax, size_t* pcch); +#endif // STRSAFE_INLINE + +#ifndef STRSAFE_LIB_IMPL +// these functions are always inline +STRSAFE_INLINE_API StringGetsExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +STRSAFE_INLINE_API StringGetsExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +#endif + +#ifdef _NTSTRSAFE_H_INCLUDED_ +#pragma warning(push) +#pragma warning(disable : 4995) +#endif // _NTSTRSAFE_H_INCLUDED_ + + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchCopy( + OUT LPTSTR pszDest, + IN size_t cchDest, + IN LPCTSTR pszSrc + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strcpy'. + The size of the destination buffer (in characters) is a parameter and + this function will not write past the end of this buffer and it will + ALWAYS null terminate the destination buffer (unless it is zero length). + + This routine is not a replacement for strncpy. That function will pad the + destination string with extra null termination characters if the count is + greater than the length of the source string, and it will fail to null + terminate the destination string if the source string length is greater + than or equal to the count. You can not blindly use this instead of strncpy: + it is common for code to use it to "patch" strings and you would introduce + errors if the code started null terminating in the middle of the string. + + This function returns a hresult, and not a pointer. It returns + S_OK if the string was copied without truncation and null terminated, + otherwise it will return a failure code. In failure cases as much of + pszSrc will be copied to pszDest as possible, and pszDest will be null + terminated. + +Arguments: + + pszDest - destination string + + cchDest - size of destination buffer in characters. + length must be = (_tcslen(src) + 1) to hold all of the + source including the null terminator + + pszSrc - source string which must be null terminated + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL. See StringCchCopyEx if you require + the handling of NULL values. + +Return Value: + + S_OK - if there was source data and it was all copied and the + resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the copy + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function. + +--*/ + +STRSAFEAPI StringCchCopyA(char* pszDest, size_t cchDest, const char* pszSrc); +STRSAFEAPI StringCchCopyW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc); +#ifdef UNICODE +#define StringCchCopy StringCchCopyW +#else +#define StringCchCopy StringCchCopyA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCchCopyA(char* pszDest, size_t cchDest, const char* pszSrc) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCopyWorkerA(pszDest, cchDest, pszSrc); + } + + return hr; +} + +STRSAFEAPI StringCchCopyW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCopyWorkerW(pszDest, cchDest, pszSrc); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CCH_FUNCTIONS + + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbCopy( + OUT LPTSTR pszDest, + IN size_t cbDest, + IN LPCTSTR pszSrc + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strcpy'. + The size of the destination buffer (in bytes) is a parameter and this + function will not write past the end of this buffer and it will ALWAYS + null terminate the destination buffer (unless it is zero length). + + This routine is not a replacement for strncpy. That function will pad the + destination string with extra null termination characters if the count is + greater than the length of the source string, and it will fail to null + terminate the destination string if the source string length is greater + than or equal to the count. You can not blindly use this instead of strncpy: + it is common for code to use it to "patch" strings and you would introduce + errors if the code started null terminating in the middle of the string. + + This function returns a hresult, and not a pointer. It returns + S_OK if the string was copied without truncation and null terminated, + otherwise it will return a failure code. In failure cases as much of pszSrc + will be copied to pszDest as possible, and pszDest will be null terminated. + +Arguments: + + pszDest - destination string + + cbDest - size of destination buffer in bytes. + length must be = ((_tcslen(src) + 1) * sizeof(TCHAR)) to + hold all of the source including the null terminator + + pszSrc - source string which must be null terminated + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL. See StringCbCopyEx if you require + the handling of NULL values. + +Return Value: + + S_OK - if there was source data and it was all copied and the + resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the copy + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function. + +--*/ + +STRSAFEAPI StringCbCopyA(char* pszDest, size_t cbDest, const char* pszSrc); +STRSAFEAPI StringCbCopyW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc); +#ifdef UNICODE +#define StringCbCopy StringCbCopyW +#else +#define StringCbCopy StringCbCopyA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCbCopyA(char* pszDest, size_t cbDest, const char* pszSrc) +{ + HRESULT hr; + size_t cchDest; + + // convert to count of characters + cchDest = cbDest / sizeof(char); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCopyWorkerA(pszDest, cchDest, pszSrc); + } + + return hr; +} + +STRSAFEAPI StringCbCopyW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc) +{ + HRESULT hr; + size_t cchDest; + + // convert to count of characters + cchDest = cbDest / sizeof(wchar_t); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCopyWorkerW(pszDest, cchDest, pszSrc); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CB_FUNCTIONS + + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchCopyEx( + OUT LPTSTR pszDest OPTIONAL, + IN size_t cchDest, + IN LPCTSTR pszSrc OPTIONAL, + OUT LPTSTR* ppszDestEnd OPTIONAL, + OUT size_t* pcchRemaining OPTIONAL, + IN DWORD dwFlags + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strcpy' with + some additional parameters. In addition to functionality provided by + StringCchCopy, this routine also returns a pointer to the end of the + destination string and the number of characters left in the destination string + including the null terminator. The flags parameter allows additional controls. + +Arguments: + + pszDest - destination string + + cchDest - size of destination buffer in characters. + length must be = (_tcslen(pszSrc) + 1) to hold all of + the source including the null terminator + + pszSrc - source string which must be null terminated + + ppszDestEnd - if ppszDestEnd is non-null, the function will return a + pointer to the end of the destination string. If the + function copied any data, the result will point to the + null termination character + + pcchRemaining - if pcchRemaining is non-null, the function will return the + number of characters left in the destination string, + including the null terminator + + dwFlags - controls some details of the string copy: + + STRSAFE_FILL_BEHIND_NULL + if the function succeeds, the low byte of dwFlags will be + used to fill the uninitialize part of destination buffer + behind the null terminator + + STRSAFE_IGNORE_NULLS + treat NULL string pointers like empty strings (TEXT("")). + this flag is useful for emulating functions like lstrcpy + + STRSAFE_FILL_ON_FAILURE + if the function fails, the low byte of dwFlags will be + used to fill all of the destination buffer, and it will + be null terminated. This will overwrite any truncated + string returned when the failure is + STRSAFE_E_INSUFFICIENT_BUFFER + + STRSAFE_NO_TRUNCATION / + STRSAFE_NULL_ON_FAILURE + if the function fails, the destination buffer will be set + to the empty string. This will overwrite any truncated string + returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag + is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc + may be NULL. An error may still be returned even though NULLS are ignored + due to insufficient space. + +Return Value: + + S_OK - if there was source data and it was all copied and the + resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the copy + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCchCopyExA(char* pszDest, size_t cchDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +STRSAFEAPI StringCchCopyExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +#ifdef UNICODE +#define StringCchCopyEx StringCchCopyExW +#else +#define StringCchCopyEx StringCchCopyExA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCchCopyExA(char* pszDest, size_t cchDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + + // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 + cbDest = cchDest * sizeof(char); + + hr = StringCopyExWorkerA(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, pcchRemaining, dwFlags); + } + + return hr; +} + +STRSAFEAPI StringCchCopyExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + + // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + cbDest = cchDest * sizeof(wchar_t); + + hr = StringCopyExWorkerW(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, pcchRemaining, dwFlags); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CCH_FUNCTIONS + + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbCopyEx( + OUT LPTSTR pszDest OPTIONAL, + IN size_t cbDest, + IN LPCTSTR pszSrc OPTIONAL, + OUT LPTSTR* ppszDestEnd OPTIONAL, + OUT size_t* pcbRemaining OPTIONAL, + IN DWORD dwFlags + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strcpy' with + some additional parameters. In addition to functionality provided by + StringCbCopy, this routine also returns a pointer to the end of the + destination string and the number of bytes left in the destination string + including the null terminator. The flags parameter allows additional controls. + +Arguments: + + pszDest - destination string + + cbDest - size of destination buffer in bytes. + length must be ((_tcslen(pszSrc) + 1) * sizeof(TCHAR)) to + hold all of the source including the null terminator + + pszSrc - source string which must be null terminated + + ppszDestEnd - if ppszDestEnd is non-null, the function will return a + pointer to the end of the destination string. If the + function copied any data, the result will point to the + null termination character + + pcbRemaining - pcbRemaining is non-null,the function will return the + number of bytes left in the destination string, + including the null terminator + + dwFlags - controls some details of the string copy: + + STRSAFE_FILL_BEHIND_NULL + if the function succeeds, the low byte of dwFlags will be + used to fill the uninitialize part of destination buffer + behind the null terminator + + STRSAFE_IGNORE_NULLS + treat NULL string pointers like empty strings (TEXT("")). + this flag is useful for emulating functions like lstrcpy + + STRSAFE_FILL_ON_FAILURE + if the function fails, the low byte of dwFlags will be + used to fill all of the destination buffer, and it will + be null terminated. This will overwrite any truncated + string returned when the failure is + STRSAFE_E_INSUFFICIENT_BUFFER + + STRSAFE_NO_TRUNCATION / + STRSAFE_NULL_ON_FAILURE + if the function fails, the destination buffer will be set + to the empty string. This will overwrite any truncated string + returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag + is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc + may be NULL. An error may still be returned even though NULLS are ignored + due to insufficient space. + +Return Value: + + S_OK - if there was source data and it was all copied and the + resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the copy + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCbCopyExA(char* pszDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); +STRSAFEAPI StringCbCopyExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); +#ifdef UNICODE +#define StringCbCopyEx StringCbCopyExW +#else +#define StringCbCopyEx StringCbCopyExA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCbCopyExA(char* pszDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) +{ + HRESULT hr; + size_t cchDest; + size_t cchRemaining = 0; + + cchDest = cbDest / sizeof(char); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCopyExWorkerA(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, &cchRemaining, dwFlags); + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (pcbRemaining) + { + // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1 + *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)); + } + } + + return hr; +} + +STRSAFEAPI StringCbCopyExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) +{ + HRESULT hr; + size_t cchDest; + size_t cchRemaining = 0; + + cchDest = cbDest / sizeof(wchar_t); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCopyExWorkerW(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, &cchRemaining, dwFlags); + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (pcbRemaining) + { + // safe to multiply cchRemaining * sizeof(wchar_t) since cchRemaining < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + *pcbRemaining = (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)); + } + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CB_FUNCTIONS + + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchCopyN( + OUT LPTSTR pszDest, + IN size_t cchDest, + IN LPCTSTR pszSrc, + IN size_t cchSrc + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strncpy'. + The size of the destination buffer (in characters) is a parameter and + this function will not write past the end of this buffer and it will + ALWAYS null terminate the destination buffer (unless it is zero length). + + This routine is meant as a replacement for strncpy, but it does behave + differently. This function will not pad the destination buffer with extra + null termination characters if cchSrc is greater than the length of pszSrc. + + This function returns a hresult, and not a pointer. It returns + S_OK if the entire string or the first cchSrc characters were copied + without truncation and the resultant destination string was null terminated, + otherwise it will return a failure code. In failure cases as much of pszSrc + will be copied to pszDest as possible, and pszDest will be null terminated. + +Arguments: + + pszDest - destination string + + cchDest - size of destination buffer in characters. + length must be = (_tcslen(src) + 1) to hold all of the + source including the null terminator + + pszSrc - source string + + cchSrc - maximum number of characters to copy from source string, + not including the null terminator. + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL. See StringCchCopyNEx if you require + the handling of NULL values. + +Return Value: + + S_OK - if there was source data and it was all copied and the + resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the copy + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function. + +--*/ + +STRSAFEAPI StringCchCopyNA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc); +STRSAFEAPI StringCchCopyNW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchSrc); +#ifdef UNICODE +#define StringCchCopyN StringCchCopyNW +#else +#define StringCchCopyN StringCchCopyNA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCchCopyNA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc) +{ + HRESULT hr; + + if ((cchDest > STRSAFE_MAX_CCH) || + (cchSrc > STRSAFE_MAX_CCH)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCopyNWorkerA(pszDest, cchDest, pszSrc, cchSrc); + } + + return hr; +} + +STRSAFEAPI StringCchCopyNW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchSrc) +{ + HRESULT hr; + + if ((cchDest > STRSAFE_MAX_CCH) || + (cchSrc > STRSAFE_MAX_CCH)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCopyNWorkerW(pszDest, cchDest, pszSrc, cchSrc); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CCH_FUNCTIONS + + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbCopyN( + OUT LPTSTR pszDest, + IN size_t cbDest, + IN LPCTSTR pszSrc, + IN size_t cbSrc + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strncpy'. + The size of the destination buffer (in bytes) is a parameter and this + function will not write past the end of this buffer and it will ALWAYS + null terminate the destination buffer (unless it is zero length). + + This routine is meant as a replacement for strncpy, but it does behave + differently. This function will not pad the destination buffer with extra + null termination characters if cbSrc is greater than the size of pszSrc. + + This function returns a hresult, and not a pointer. It returns + S_OK if the entire string or the first cbSrc characters were + copied without truncation and the resultant destination string was null + terminated, otherwise it will return a failure code. In failure cases as + much of pszSrc will be copied to pszDest as possible, and pszDest will be + null terminated. + +Arguments: + + pszDest - destination string + + cbDest - size of destination buffer in bytes. + length must be = ((_tcslen(src) + 1) * sizeof(TCHAR)) to + hold all of the source including the null terminator + + pszSrc - source string + + cbSrc - maximum number of bytes to copy from source string, + not including the null terminator. + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL. See StringCbCopyEx if you require + the handling of NULL values. + +Return Value: + + S_OK - if there was source data and it was all copied and the + resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the copy + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function. + +--*/ + +STRSAFEAPI StringCbCopyNA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbSrc); +STRSAFEAPI StringCbCopyNW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbSrc); +#ifdef UNICODE +#define StringCbCopyN StringCbCopyNW +#else +#define StringCbCopyN StringCbCopyNA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCbCopyNA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbSrc) +{ + HRESULT hr; + size_t cchDest; + size_t cchSrc; + + // convert to count of characters + cchDest = cbDest / sizeof(char); + cchSrc = cbSrc / sizeof(char); + + if ((cchDest > STRSAFE_MAX_CCH) || + (cchSrc > STRSAFE_MAX_CCH)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCopyNWorkerA(pszDest, cchDest, pszSrc, cchSrc); + } + + return hr; +} + +STRSAFEAPI StringCbCopyNW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbSrc) +{ + HRESULT hr; + size_t cchDest; + size_t cchSrc; + + // convert to count of characters + cchDest = cbDest / sizeof(wchar_t); + cchSrc = cbSrc / sizeof(wchar_t); + + if ((cchDest > STRSAFE_MAX_CCH) || + (cchSrc > STRSAFE_MAX_CCH)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCopyNWorkerW(pszDest, cchDest, pszSrc, cchSrc); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CB_FUNCTIONS + + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchCopyNEx( + OUT LPTSTR pszDest OPTIONAL, + IN size_t cchDest, + IN LPCTSTR pszSrc OPTIONAL, + IN size_t cchSrc, + OUT LPTSTR* ppszDestEnd OPTIONAL, + OUT size_t* pcchRemaining OPTIONAL, + IN DWORD dwFlags + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strncpy' with + some additional parameters. In addition to functionality provided by + StringCchCopyN, this routine also returns a pointer to the end of the + destination string and the number of characters left in the destination + string including the null terminator. The flags parameter allows + additional controls. + + This routine is meant as a replacement for strncpy, but it does behave + differently. This function will not pad the destination buffer with extra + null termination characters if cchSrc is greater than the length of pszSrc. + +Arguments: + + pszDest - destination string + + cchDest - size of destination buffer in characters. + length must be = (_tcslen(pszSrc) + 1) to hold all of + the source including the null terminator + + pszSrc - source string + + cchSrc - maximum number of characters to copy from the source + string + + ppszDestEnd - if ppszDestEnd is non-null, the function will return a + pointer to the end of the destination string. If the + function copied any data, the result will point to the + null termination character + + pcchRemaining - if pcchRemaining is non-null, the function will return the + number of characters left in the destination string, + including the null terminator + + dwFlags - controls some details of the string copy: + + STRSAFE_FILL_BEHIND_NULL + if the function succeeds, the low byte of dwFlags will be + used to fill the uninitialize part of destination buffer + behind the null terminator + + STRSAFE_IGNORE_NULLS + treat NULL string pointers like empty strings (TEXT("")). + this flag is useful for emulating functions like lstrcpy + + STRSAFE_FILL_ON_FAILURE + if the function fails, the low byte of dwFlags will be + used to fill all of the destination buffer, and it will + be null terminated. This will overwrite any truncated + string returned when the failure is + STRSAFE_E_INSUFFICIENT_BUFFER + + STRSAFE_NO_TRUNCATION / + STRSAFE_NULL_ON_FAILURE + if the function fails, the destination buffer will be set + to the empty string. This will overwrite any truncated string + returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag + is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc + may be NULL. An error may still be returned even though NULLS are ignored + due to insufficient space. + +Return Value: + + S_OK - if there was source data and it was all copied and the + resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the copy + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCchCopyNExA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +STRSAFEAPI StringCchCopyNExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +#ifdef UNICODE +#define StringCchCopyNEx StringCchCopyNExW +#else +#define StringCchCopyNEx StringCchCopyNExA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCchCopyNExA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr; + + if ((cchDest > STRSAFE_MAX_CCH) || + (cchSrc > STRSAFE_MAX_CCH)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + + // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 + cbDest = cchDest * sizeof(char); + + hr = StringCopyNExWorkerA(pszDest, cchDest, cbDest, pszSrc, cchSrc, ppszDestEnd, pcchRemaining, dwFlags); + } + + return hr; +} + +STRSAFEAPI StringCchCopyNExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr; + + if ((cchDest > STRSAFE_MAX_CCH) || + (cchSrc > STRSAFE_MAX_CCH)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + + // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + cbDest = cchDest * sizeof(wchar_t); + + hr = StringCopyNExWorkerW(pszDest, cchDest, cbDest, pszSrc, cchSrc, ppszDestEnd, pcchRemaining, dwFlags); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CCH_FUNCTIONS + + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbCopyNEx( + OUT LPTSTR pszDest OPTIONAL, + IN size_t cbDest, + IN LPCTSTR pszSrc OPTIONAL, + IN size_t cbSrc, + OUT LPTSTR* ppszDestEnd OPTIONAL, + OUT size_t* pcbRemaining OPTIONAL, + IN DWORD dwFlags + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strncpy' with + some additional parameters. In addition to functionality provided by + StringCbCopyN, this routine also returns a pointer to the end of the + destination string and the number of bytes left in the destination string + including the null terminator. The flags parameter allows additional controls. + + This routine is meant as a replacement for strncpy, but it does behave + differently. This function will not pad the destination buffer with extra + null termination characters if cbSrc is greater than the size of pszSrc. + +Arguments: + + pszDest - destination string + + cbDest - size of destination buffer in bytes. + length must be ((_tcslen(pszSrc) + 1) * sizeof(TCHAR)) to + hold all of the source including the null terminator + + pszSrc - source string + + cbSrc - maximum number of bytes to copy from source string + + ppszDestEnd - if ppszDestEnd is non-null, the function will return a + pointer to the end of the destination string. If the + function copied any data, the result will point to the + null termination character + + pcbRemaining - pcbRemaining is non-null,the function will return the + number of bytes left in the destination string, + including the null terminator + + dwFlags - controls some details of the string copy: + + STRSAFE_FILL_BEHIND_NULL + if the function succeeds, the low byte of dwFlags will be + used to fill the uninitialize part of destination buffer + behind the null terminator + + STRSAFE_IGNORE_NULLS + treat NULL string pointers like empty strings (TEXT("")). + this flag is useful for emulating functions like lstrcpy + + STRSAFE_FILL_ON_FAILURE + if the function fails, the low byte of dwFlags will be + used to fill all of the destination buffer, and it will + be null terminated. This will overwrite any truncated + string returned when the failure is + STRSAFE_E_INSUFFICIENT_BUFFER + + STRSAFE_NO_TRUNCATION / + STRSAFE_NULL_ON_FAILURE + if the function fails, the destination buffer will be set + to the empty string. This will overwrite any truncated string + returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag + is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc + may be NULL. An error may still be returned even though NULLS are ignored + due to insufficient space. + +Return Value: + + S_OK - if there was source data and it was all copied and the + resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the copy + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCbCopyNExA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); +STRSAFEAPI StringCbCopyNExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbSrc, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); +#ifdef UNICODE +#define StringCbCopyNEx StringCbCopyNExW +#else +#define StringCbCopyNEx StringCbCopyNExA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCbCopyNExA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) +{ + HRESULT hr; + size_t cchDest; + size_t cchSrc; + size_t cchRemaining = 0; + + cchDest = cbDest / sizeof(char); + cchSrc = cbSrc / sizeof(char); + + if ((cchDest > STRSAFE_MAX_CCH) || + (cchSrc > STRSAFE_MAX_CCH)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCopyNExWorkerA(pszDest, cchDest, cbDest, pszSrc, cchSrc, ppszDestEnd, &cchRemaining, dwFlags); + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (pcbRemaining) + { + // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1 + *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)); + } + } + + return hr; +} + +STRSAFEAPI StringCbCopyNExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbSrc, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) +{ + HRESULT hr; + size_t cchDest; + size_t cchSrc; + size_t cchRemaining = 0; + + cchDest = cbDest / sizeof(wchar_t); + cchSrc = cbSrc / sizeof(wchar_t); + + if ((cchDest > STRSAFE_MAX_CCH) || + (cchSrc > STRSAFE_MAX_CCH)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCopyNExWorkerW(pszDest, cchDest, cbDest, pszSrc, cchSrc, ppszDestEnd, &cchRemaining, dwFlags); + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (pcbRemaining) + { + // safe to multiply cchRemaining * sizeof(wchar_t) since cchRemaining < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + *pcbRemaining = (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)); + } + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CB_FUNCTIONS + + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchCat( + IN OUT LPTSTR pszDest, + IN size_t cchDest, + IN LPCTSTR pszSrc + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strcat'. + The size of the destination buffer (in characters) is a parameter and this + function will not write past the end of this buffer and it will ALWAYS + null terminate the destination buffer (unless it is zero length). + + This function returns a hresult, and not a pointer. It returns + S_OK if the string was concatenated without truncation and null terminated, + otherwise it will return a failure code. In failure cases as much of pszSrc + will be appended to pszDest as possible, and pszDest will be null + terminated. + +Arguments: + + pszDest - destination string which must be null terminated + + cchDest - size of destination buffer in characters. + length must be = (_tcslen(pszDest) + _tcslen(pszSrc) + 1) + to hold all of the combine string plus the null + terminator + + pszSrc - source string which must be null terminated + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL. See StringCchCatEx if you require + the handling of NULL values. + +Return Value: + + S_OK - if there was source data and it was all concatenated and + the resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the operation + failed due to insufficient space. When this error occurs, + the destination buffer is modified to contain a truncated + version of the ideal result and is null terminated. This + is useful for situations where truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCchCatA(char* pszDest, size_t cchDest, const char* pszSrc); +STRSAFEAPI StringCchCatW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc); +#ifdef UNICODE +#define StringCchCat StringCchCatW +#else +#define StringCchCat StringCchCatA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCchCatA(char* pszDest, size_t cchDest, const char* pszSrc) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCatWorkerA(pszDest, cchDest, pszSrc); + } + + return hr; +} + +STRSAFEAPI StringCchCatW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCatWorkerW(pszDest, cchDest, pszSrc); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CCH_FUNCTIONS + + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbCat( + IN OUT LPTSTR pszDest, + IN size_t cbDest, + IN LPCTSTR pszSrc + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strcat'. + The size of the destination buffer (in bytes) is a parameter and this + function will not write past the end of this buffer and it will ALWAYS + null terminate the destination buffer (unless it is zero length). + + This function returns a hresult, and not a pointer. It returns + S_OK if the string was concatenated without truncation and null terminated, + otherwise it will return a failure code. In failure cases as much of pszSrc + will be appended to pszDest as possible, and pszDest will be null + terminated. + +Arguments: + + pszDest - destination string which must be null terminated + + cbDest - size of destination buffer in bytes. + length must be = ((_tcslen(pszDest) + _tcslen(pszSrc) + 1) * sizeof(TCHAR) + to hold all of the combine string plus the null + terminator + + pszSrc - source string which must be null terminated + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL. See StringCbCatEx if you require + the handling of NULL values. + +Return Value: + + S_OK - if there was source data and it was all concatenated and + the resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the operation + failed due to insufficient space. When this error occurs, + the destination buffer is modified to contain a truncated + version of the ideal result and is null terminated. This + is useful for situations where truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCbCatA(char* pszDest, size_t cbDest, const char* pszSrc); +STRSAFEAPI StringCbCatW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc); +#ifdef UNICODE +#define StringCbCat StringCbCatW +#else +#define StringCbCat StringCbCatA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCbCatA(char* pszDest, size_t cbDest, const char* pszSrc) +{ + HRESULT hr; + size_t cchDest; + + cchDest = cbDest / sizeof(char); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCatWorkerA(pszDest, cchDest, pszSrc); + } + + return hr; +} + +STRSAFEAPI StringCbCatW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc) +{ + HRESULT hr; + size_t cchDest; + + cchDest = cbDest / sizeof(wchar_t); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCatWorkerW(pszDest, cchDest, pszSrc); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CB_FUNCTIONS + + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchCatEx( + IN OUT LPTSTR pszDest OPTIONAL, + IN size_t cchDest, + IN LPCTSTR pszSrc OPTIONAL, + OUT LPTSTR* ppszDestEnd OPTIONAL, + OUT size_t* pcchRemaining OPTIONAL, + IN DWORD dwFlags + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strcat' with + some additional parameters. In addition to functionality provided by + StringCchCat, this routine also returns a pointer to the end of the + destination string and the number of characters left in the destination string + including the null terminator. The flags parameter allows additional controls. + +Arguments: + + pszDest - destination string which must be null terminated + + cchDest - size of destination buffer in characters + length must be (_tcslen(pszDest) + _tcslen(pszSrc) + 1) + to hold all of the combine string plus the null + terminator. + + pszSrc - source string which must be null terminated + + ppszDestEnd - if ppszDestEnd is non-null, the function will return a + pointer to the end of the destination string. If the + function appended any data, the result will point to the + null termination character + + pcchRemaining - if pcchRemaining is non-null, the function will return the + number of characters left in the destination string, + including the null terminator + + dwFlags - controls some details of the string copy: + + STRSAFE_FILL_BEHIND_NULL + if the function succeeds, the low byte of dwFlags will be + used to fill the uninitialize part of destination buffer + behind the null terminator + + STRSAFE_IGNORE_NULLS + treat NULL string pointers like empty strings (TEXT("")). + this flag is useful for emulating functions like lstrcat + + STRSAFE_FILL_ON_FAILURE + if the function fails, the low byte of dwFlags will be + used to fill all of the destination buffer, and it will + be null terminated. This will overwrite any pre-existing + or truncated string + + STRSAFE_NULL_ON_FAILURE + if the function fails, the destination buffer will be set + to the empty string. This will overwrite any pre-existing or + truncated string + + STRSAFE_NO_TRUNCATION + if the function returns STRSAFE_E_INSUFFICIENT_BUFFER, pszDest + will not contain a truncated string, it will remain unchanged. + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag + is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc + may be NULL. An error may still be returned even though NULLS are ignored + due to insufficient space. + +Return Value: + + S_OK - if there was source data and it was all concatenated and + the resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the operation + failed due to insufficient space. When this error + occurs, the destination buffer is modified to contain + a truncated version of the ideal result and is null + terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCchCatExA(char* pszDest, size_t cchDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +STRSAFEAPI StringCchCatExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +#ifdef UNICODE +#define StringCchCatEx StringCchCatExW +#else +#define StringCchCatEx StringCchCatExA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCchCatExA(char* pszDest, size_t cchDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + + // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 + cbDest = cchDest * sizeof(char); + + hr = StringCatExWorkerA(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, pcchRemaining, dwFlags); + } + + return hr; +} + +STRSAFEAPI StringCchCatExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + + // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + cbDest = cchDest * sizeof(wchar_t); + + hr = StringCatExWorkerW(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, pcchRemaining, dwFlags); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CCH_FUNCTIONS + + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbCatEx( + IN OUT LPTSTR pszDest OPTIONAL, + IN size_t cbDest, + IN LPCTSTR pszSrc OPTIONAL, + OUT LPTSTR* ppszDestEnd OPTIONAL, + OUT size_t* pcbRemaining OPTIONAL, + IN DWORD dwFlags + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strcat' with + some additional parameters. In addition to functionality provided by + StringCbCat, this routine also returns a pointer to the end of the + destination string and the number of bytes left in the destination string + including the null terminator. The flags parameter allows additional controls. + +Arguments: + + pszDest - destination string which must be null terminated + + cbDest - size of destination buffer in bytes. + length must be ((_tcslen(pszDest) + _tcslen(pszSrc) + 1) * sizeof(TCHAR) + to hold all of the combine string plus the null + terminator. + + pszSrc - source string which must be null terminated + + ppszDestEnd - if ppszDestEnd is non-null, the function will return a + pointer to the end of the destination string. If the + function appended any data, the result will point to the + null termination character + + pcbRemaining - if pcbRemaining is non-null, the function will return + the number of bytes left in the destination string, + including the null terminator + + dwFlags - controls some details of the string copy: + + STRSAFE_FILL_BEHIND_NULL + if the function succeeds, the low byte of dwFlags will be + used to fill the uninitialize part of destination buffer + behind the null terminator + + STRSAFE_IGNORE_NULLS + treat NULL string pointers like empty strings (TEXT("")). + this flag is useful for emulating functions like lstrcat + + STRSAFE_FILL_ON_FAILURE + if the function fails, the low byte of dwFlags will be + used to fill all of the destination buffer, and it will + be null terminated. This will overwrite any pre-existing + or truncated string + + STRSAFE_NULL_ON_FAILURE + if the function fails, the destination buffer will be set + to the empty string. This will overwrite any pre-existing or + truncated string + + STRSAFE_NO_TRUNCATION + if the function returns STRSAFE_E_INSUFFICIENT_BUFFER, pszDest + will not contain a truncated string, it will remain unchanged. + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag + is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc + may be NULL. An error may still be returned even though NULLS are ignored + due to insufficient space. + +Return Value: + + S_OK - if there was source data and it was all concatenated + and the resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the operation + failed due to insufficient space. When this error + occurs, the destination buffer is modified to contain + a truncated version of the ideal result and is null + terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCbCatExA(char* pszDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); +STRSAFEAPI StringCbCatExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); +#ifdef UNICODE +#define StringCbCatEx StringCbCatExW +#else +#define StringCbCatEx StringCbCatExA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCbCatExA(char* pszDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) +{ + HRESULT hr; + size_t cchDest; + size_t cchRemaining = 0; + + cchDest = cbDest / sizeof(char); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCatExWorkerA(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, &cchRemaining, dwFlags); + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (pcbRemaining) + { + // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1 + *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)); + } + } + + return hr; +} + +STRSAFEAPI StringCbCatExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) +{ + HRESULT hr; + size_t cchDest; + size_t cchRemaining = 0; + + cchDest = cbDest / sizeof(wchar_t); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCatExWorkerW(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, &cchRemaining, dwFlags); + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (pcbRemaining) + { + // safe to multiply cchRemaining * sizeof(wchar_t) since cchRemaining < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + *pcbRemaining = (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)); + } + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CB_FUNCTIONS + + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchCatN( + IN OUT LPTSTR pszDest, + IN size_t cchDest, + IN LPCTSTR pszSrc, + IN size_t cchMaxAppend + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strncat'. + The size of the destination buffer (in characters) is a parameter as well as + the maximum number of characters to append, excluding the null terminator. + This function will not write past the end of the destination buffer and it will + ALWAYS null terminate pszDest (unless it is zero length). + + This function returns a hresult, and not a pointer. It returns + S_OK if all of pszSrc or the first cchMaxAppend characters were appended + to the destination string and it was null terminated, otherwise it will + return a failure code. In failure cases as much of pszSrc will be appended + to pszDest as possible, and pszDest will be null terminated. + +Arguments: + + pszDest - destination string which must be null terminated + + cchDest - size of destination buffer in characters. + length must be (_tcslen(pszDest) + min(cchMaxAppend, _tcslen(pszSrc)) + 1) + to hold all of the combine string plus the null + terminator. + + pszSrc - source string + + cchMaxAppend - maximum number of characters to append + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL. See StringCchCatNEx if you require + the handling of NULL values. + +Return Value: + + S_OK - if all of pszSrc or the first cchMaxAppend characters + were concatenated to pszDest and the resultant dest + string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the operation + failed due to insufficient space. When this error + occurs, the destination buffer is modified to contain + a truncated version of the ideal result and is null + terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCchCatNA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend); +STRSAFEAPI StringCchCatNW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchMaxAppend); +#ifdef UNICODE +#define StringCchCatN StringCchCatNW +#else +#define StringCchCatN StringCchCatNA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCchCatNA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCatNWorkerA(pszDest, cchDest, pszSrc, cchMaxAppend); + } + + return hr; +} + +STRSAFEAPI StringCchCatNW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchMaxAppend) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringCatNWorkerW(pszDest, cchDest, pszSrc, cchMaxAppend); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CCH_FUNCTIONS + + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbCatN( + IN OUT LPTSTR pszDest, + IN size_t cbDest, + IN LPCTSTR pszSrc, + IN size_t cbMaxAppend + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strncat'. + The size of the destination buffer (in bytes) is a parameter as well as + the maximum number of bytes to append, excluding the null terminator. + This function will not write past the end of the destination buffer and it will + ALWAYS null terminate pszDest (unless it is zero length). + + This function returns a hresult, and not a pointer. It returns + S_OK if all of pszSrc or the first cbMaxAppend bytes were appended + to the destination string and it was null terminated, otherwise it will + return a failure code. In failure cases as much of pszSrc will be appended + to pszDest as possible, and pszDest will be null terminated. + +Arguments: + + pszDest - destination string which must be null terminated + + cbDest - size of destination buffer in bytes. + length must be ((_tcslen(pszDest) + min(cbMaxAppend / sizeof(TCHAR), _tcslen(pszSrc)) + 1) * sizeof(TCHAR) + to hold all of the combine string plus the null + terminator. + + pszSrc - source string + + cbMaxAppend - maximum number of bytes to append + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL. See StringCbCatNEx if you require + the handling of NULL values. + +Return Value: + + S_OK - if all of pszSrc or the first cbMaxAppend bytes were + concatenated to pszDest and the resultant dest string + was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the operation + failed due to insufficient space. When this error + occurs, the destination buffer is modified to contain + a truncated version of the ideal result and is null + terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCbCatNA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbMaxAppend); +STRSAFEAPI StringCbCatNW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbMaxAppend); +#ifdef UNICODE +#define StringCbCatN StringCbCatNW +#else +#define StringCbCatN StringCbCatNA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCbCatNA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbMaxAppend) +{ + HRESULT hr; + size_t cchDest; + + cchDest = cbDest / sizeof(char); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cchMaxAppend; + + cchMaxAppend = cbMaxAppend / sizeof(char); + + hr = StringCatNWorkerA(pszDest, cchDest, pszSrc, cchMaxAppend); + } + + return hr; +} + +STRSAFEAPI StringCbCatNW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbMaxAppend) +{ + HRESULT hr; + size_t cchDest; + + cchDest = cbDest / sizeof(wchar_t); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cchMaxAppend; + + cchMaxAppend = cbMaxAppend / sizeof(wchar_t); + + hr = StringCatNWorkerW(pszDest, cchDest, pszSrc, cchMaxAppend); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CB_FUNCTIONS + + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchCatNEx( + IN OUT LPTSTR pszDest OPTIONAL, + IN size_t cchDest, + IN LPCTSTR pszSrc OPTIONAL, + IN size_t cchMaxAppend, + OUT LPTSTR* ppszDestEnd OPTIONAL, + OUT size_t* pcchRemaining OPTIONAL, + IN DWORD dwFlags + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strncat', with + some additional parameters. In addition to functionality provided by + StringCchCatN, this routine also returns a pointer to the end of the + destination string and the number of characters left in the destination string + including the null terminator. The flags parameter allows additional controls. + +Arguments: + + pszDest - destination string which must be null terminated + + cchDest - size of destination buffer in characters. + length must be (_tcslen(pszDest) + min(cchMaxAppend, _tcslen(pszSrc)) + 1) + to hold all of the combine string plus the null + terminator. + + pszSrc - source string + + cchMaxAppend - maximum number of characters to append + + ppszDestEnd - if ppszDestEnd is non-null, the function will return a + pointer to the end of the destination string. If the + function appended any data, the result will point to the + null termination character + + pcchRemaining - if pcchRemaining is non-null, the function will return the + number of characters left in the destination string, + including the null terminator + + dwFlags - controls some details of the string copy: + + STRSAFE_FILL_BEHIND_NULL + if the function succeeds, the low byte of dwFlags will be + used to fill the uninitialize part of destination buffer + behind the null terminator + + STRSAFE_IGNORE_NULLS + treat NULL string pointers like empty strings (TEXT("")) + + STRSAFE_FILL_ON_FAILURE + if the function fails, the low byte of dwFlags will be + used to fill all of the destination buffer, and it will + be null terminated. This will overwrite any pre-existing + or truncated string + + STRSAFE_NULL_ON_FAILURE + if the function fails, the destination buffer will be set + to the empty string. This will overwrite any pre-existing or + truncated string + + STRSAFE_NO_TRUNCATION + if the function returns STRSAFE_E_INSUFFICIENT_BUFFER, pszDest + will not contain a truncated string, it will remain unchanged. + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag + is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc + may be NULL. An error may still be returned even though NULLS are ignored + due to insufficient space. + +Return Value: + + S_OK - if all of pszSrc or the first cchMaxAppend characters + were concatenated to pszDest and the resultant dest + string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the operation + failed due to insufficient space. When this error + occurs, the destination buffer is modified to contain + a truncated version of the ideal result and is null + terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCchCatNExA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +STRSAFEAPI StringCchCatNExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchMaxAppend, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +#ifdef UNICODE +#define StringCchCatNEx StringCchCatNExW +#else +#define StringCchCatNEx StringCchCatNExA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCchCatNExA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + + // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 + cbDest = cchDest * sizeof(char); + + hr = StringCatNExWorkerA(pszDest, cchDest, cbDest, pszSrc, cchMaxAppend, ppszDestEnd, pcchRemaining, dwFlags); + } + + return hr; +} + +STRSAFEAPI StringCchCatNExW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchMaxAppend, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + + // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + cbDest = cchDest * sizeof(wchar_t); + + hr = StringCatNExWorkerW(pszDest, cchDest, cbDest, pszSrc, cchMaxAppend, ppszDestEnd, pcchRemaining, dwFlags); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CCH_FUNCTIONS + + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbCatNEx( + IN OUT LPTSTR pszDest OPTIONAL, + IN size_t cbDest, + IN LPCTSTR pszSrc OPTIONAL, + IN size_t cbMaxAppend, + OUT LPTSTR* ppszDestEnd OPTIONAL, + OUT size_t* pcchRemaining OPTIONAL, + IN DWORD dwFlags + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strncat', with + some additional parameters. In addition to functionality provided by + StringCbCatN, this routine also returns a pointer to the end of the + destination string and the number of bytes left in the destination string + including the null terminator. The flags parameter allows additional controls. + +Arguments: + + pszDest - destination string which must be null terminated + + cbDest - size of destination buffer in bytes. + length must be ((_tcslen(pszDest) + min(cbMaxAppend / sizeof(TCHAR), _tcslen(pszSrc)) + 1) * sizeof(TCHAR) + to hold all of the combine string plus the null + terminator. + + pszSrc - source string + + cbMaxAppend - maximum number of bytes to append + + ppszDestEnd - if ppszDestEnd is non-null, the function will return a + pointer to the end of the destination string. If the + function appended any data, the result will point to the + null termination character + + pcbRemaining - if pcbRemaining is non-null, the function will return the + number of bytes left in the destination string, + including the null terminator + + dwFlags - controls some details of the string copy: + + STRSAFE_FILL_BEHIND_NULL + if the function succeeds, the low byte of dwFlags will be + used to fill the uninitialize part of destination buffer + behind the null terminator + + STRSAFE_IGNORE_NULLS + treat NULL string pointers like empty strings (TEXT("")) + + STRSAFE_FILL_ON_FAILURE + if the function fails, the low byte of dwFlags will be + used to fill all of the destination buffer, and it will + be null terminated. This will overwrite any pre-existing + or truncated string + + STRSAFE_NULL_ON_FAILURE + if the function fails, the destination buffer will be set + to the empty string. This will overwrite any pre-existing or + truncated string + + STRSAFE_NO_TRUNCATION + if the function returns STRSAFE_E_INSUFFICIENT_BUFFER, pszDest + will not contain a truncated string, it will remain unchanged. + +Notes: + Behavior is undefined if source and destination strings overlap. + + pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag + is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc + may be NULL. An error may still be returned even though NULLS are ignored + due to insufficient space. + +Return Value: + + S_OK - if all of pszSrc or the first cbMaxAppend bytes were + concatenated to pszDest and the resultant dest string + was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the operation + failed due to insufficient space. When this error + occurs, the destination buffer is modified to contain + a truncated version of the ideal result and is null + terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCbCatNExA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbMaxAppend, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); +STRSAFEAPI StringCbCatNExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbMaxAppend, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); +#ifdef UNICODE +#define StringCbCatNEx StringCbCatNExW +#else +#define StringCbCatNEx StringCbCatNExA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCbCatNExA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbMaxAppend, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) +{ + HRESULT hr; + size_t cchDest; + size_t cchRemaining = 0; + + cchDest = cbDest / sizeof(char); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cchMaxAppend; + + cchMaxAppend = cbMaxAppend / sizeof(char); + + hr = StringCatNExWorkerA(pszDest, cchDest, cbDest, pszSrc, cchMaxAppend, ppszDestEnd, &cchRemaining, dwFlags); + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (pcbRemaining) + { + // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1 + *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)); + } + } + + return hr; +} + +STRSAFEAPI StringCbCatNExW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszSrc, size_t cbMaxAppend, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) +{ + HRESULT hr; + size_t cchDest; + size_t cchRemaining = 0; + + cchDest = cbDest / sizeof(wchar_t); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cchMaxAppend; + + cchMaxAppend = cbMaxAppend / sizeof(wchar_t); + + hr = StringCatNExWorkerW(pszDest, cchDest, cbDest, pszSrc, cchMaxAppend, ppszDestEnd, &cchRemaining, dwFlags); + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (pcbRemaining) + { + // safe to multiply cchRemaining * sizeof(wchar_t) since cchRemaining < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + *pcbRemaining = (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)); + } + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CB_FUNCTIONS + + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchVPrintf( + OUT LPTSTR pszDest, + IN size_t cchDest, + IN LPCTSTR pszFormat, + IN va_list argList + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'vsprintf'. + The size of the destination buffer (in characters) is a parameter and + this function will not write past the end of this buffer and it will + ALWAYS null terminate the destination buffer (unless it is zero length). + + This function returns a hresult, and not a pointer. It returns + S_OK if the string was printed without truncation and null terminated, + otherwise it will return a failure code. In failure cases it will return + a truncated version of the ideal result. + +Arguments: + + pszDest - destination string + + cchDest - size of destination buffer in characters + length must be sufficient to hold the resulting formatted + string, including the null terminator. + + pszFormat - format string which must be null terminated + + argList - va_list from the variable arguments according to the + stdarg.h convention + +Notes: + Behavior is undefined if destination, format strings or any arguments + strings overlap. + + pszDest and pszFormat should not be NULL. See StringCchVPrintfEx if you + require the handling of NULL values. + +Return Value: + + S_OK - if there was sufficient space in the dest buffer for + the resultant string and it was null terminated. + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the print + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCchVPrintfA(char* pszDest, size_t cchDest, const char* pszFormat, va_list argList); +STRSAFEAPI StringCchVPrintfW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszFormat, va_list argList); +#ifdef UNICODE +#define StringCchVPrintf StringCchVPrintfW +#else +#define StringCchVPrintf StringCchVPrintfA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCchVPrintfA(char* pszDest, size_t cchDest, const char* pszFormat, va_list argList) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringVPrintfWorkerA(pszDest, cchDest, pszFormat, argList); + } + + return hr; +} + +STRSAFEAPI StringCchVPrintfW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszFormat, va_list argList) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringVPrintfWorkerW(pszDest, cchDest, pszFormat, argList); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CCH_FUNCTIONS + + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbVPrintf( + OUT LPTSTR pszDest, + IN size_t cbDest, + IN LPCTSTR pszFormat, + IN va_list argList + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'vsprintf'. + The size of the destination buffer (in bytes) is a parameter and + this function will not write past the end of this buffer and it will + ALWAYS null terminate the destination buffer (unless it is zero length). + + This function returns a hresult, and not a pointer. It returns + S_OK if the string was printed without truncation and null terminated, + otherwise it will return a failure code. In failure cases it will return + a truncated version of the ideal result. + +Arguments: + + pszDest - destination string + + cbDest - size of destination buffer in bytes + length must be sufficient to hold the resulting formatted + string, including the null terminator. + + pszFormat - format string which must be null terminated + + argList - va_list from the variable arguments according to the + stdarg.h convention + +Notes: + Behavior is undefined if destination, format strings or any arguments + strings overlap. + + pszDest and pszFormat should not be NULL. See StringCbVPrintfEx if you + require the handling of NULL values. + + +Return Value: + + S_OK - if there was sufficient space in the dest buffer for + the resultant string and it was null terminated. + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the print + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCbVPrintfA(char* pszDest, size_t cbDest, const char* pszFormat, va_list argList); +STRSAFEAPI StringCbVPrintfW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszFormat, va_list argList); +#ifdef UNICODE +#define StringCbVPrintf StringCbVPrintfW +#else +#define StringCbVPrintf StringCbVPrintfA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCbVPrintfA(char* pszDest, size_t cbDest, const char* pszFormat, va_list argList) +{ + HRESULT hr; + size_t cchDest; + + cchDest = cbDest / sizeof(char); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringVPrintfWorkerA(pszDest, cchDest, pszFormat, argList); + } + + return hr; +} + +STRSAFEAPI StringCbVPrintfW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszFormat, va_list argList) +{ + HRESULT hr; + size_t cchDest; + + cchDest = cbDest / sizeof(wchar_t); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringVPrintfWorkerW(pszDest, cchDest, pszFormat, argList); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CB_FUNCTIONS + + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchPrintf( + OUT LPTSTR pszDest, + IN size_t cchDest, + IN LPCTSTR pszFormat, + ... + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'sprintf'. + The size of the destination buffer (in characters) is a parameter and + this function will not write past the end of this buffer and it will + ALWAYS null terminate the destination buffer (unless it is zero length). + + This function returns a hresult, and not a pointer. It returns + S_OK if the string was printed without truncation and null terminated, + otherwise it will return a failure code. In failure cases it will return + a truncated version of the ideal result. + +Arguments: + + pszDest - destination string + + cchDest - size of destination buffer in characters + length must be sufficient to hold the resulting formatted + string, including the null terminator. + + pszFormat - format string which must be null terminated + + ... - additional parameters to be formatted according to + the format string + +Notes: + Behavior is undefined if destination, format strings or any arguments + strings overlap. + + pszDest and pszFormat should not be NULL. See StringCchPrintfEx if you + require the handling of NULL values. + +Return Value: + + S_OK - if there was sufficient space in the dest buffer for + the resultant string and it was null terminated. + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the print + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCchPrintfA(char* pszDest, size_t cchDest, const char* pszFormat, ...); +STRSAFEAPI StringCchPrintfW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszFormat, ...); +#ifdef UNICODE +#define StringCchPrintf StringCchPrintfW +#else +#define StringCchPrintf StringCchPrintfA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCchPrintfA(char* pszDest, size_t cchDest, const char* pszFormat, ...) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + va_list argList; + + va_start(argList, pszFormat); + + hr = StringVPrintfWorkerA(pszDest, cchDest, pszFormat, argList); + + va_end(argList); + } + + return hr; +} + +STRSAFEAPI StringCchPrintfW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszFormat, ...) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + va_list argList; + + va_start(argList, pszFormat); + + hr = StringVPrintfWorkerW(pszDest, cchDest, pszFormat, argList); + + va_end(argList); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CCH_FUNCTIONS + + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbPrintf( + OUT LPTSTR pszDest, + IN size_t cbDest, + IN LPCTSTR pszFormat, + ... + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'sprintf'. + The size of the destination buffer (in bytes) is a parameter and + this function will not write past the end of this buffer and it will + ALWAYS null terminate the destination buffer (unless it is zero length). + + This function returns a hresult, and not a pointer. It returns + S_OK if the string was printed without truncation and null terminated, + otherwise it will return a failure code. In failure cases it will return + a truncated version of the ideal result. + +Arguments: + + pszDest - destination string + + cbDest - size of destination buffer in bytes + length must be sufficient to hold the resulting formatted + string, including the null terminator. + + pszFormat - format string which must be null terminated + + ... - additional parameters to be formatted according to + the format string + +Notes: + Behavior is undefined if destination, format strings or any arguments + strings overlap. + + pszDest and pszFormat should not be NULL. See StringCbPrintfEx if you + require the handling of NULL values. + + +Return Value: + + S_OK - if there was sufficient space in the dest buffer for + the resultant string and it was null terminated. + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the print + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCbPrintfA(char* pszDest, size_t cbDest, const char* pszFormat, ...); +STRSAFEAPI StringCbPrintfW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszFormat, ...); +#ifdef UNICODE +#define StringCbPrintf StringCbPrintfW +#else +#define StringCbPrintf StringCbPrintfA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCbPrintfA(char* pszDest, size_t cbDest, const char* pszFormat, ...) +{ + HRESULT hr; + size_t cchDest; + + cchDest = cbDest / sizeof(char); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + va_list argList; + + va_start(argList, pszFormat); + + hr = StringVPrintfWorkerA(pszDest, cchDest, pszFormat, argList); + + va_end(argList); + } + + return hr; +} + +STRSAFEAPI StringCbPrintfW(wchar_t* pszDest, size_t cbDest, const wchar_t* pszFormat, ...) +{ + HRESULT hr; + size_t cchDest; + + cchDest = cbDest / sizeof(wchar_t); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + va_list argList; + + va_start(argList, pszFormat); + + hr = StringVPrintfWorkerW(pszDest, cchDest, pszFormat, argList); + + va_end(argList); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CB_FUNCTIONS + + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchPrintfEx( + OUT LPTSTR pszDest OPTIONAL, + IN size_t cchDest, + OUT LPTSTR* ppszDestEnd OPTIONAL, + OUT size_t* pcchRemaining OPTIONAL, + IN DWORD dwFlags, + IN LPCTSTR pszFormat OPTIONAL, + ... + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'sprintf' with + some additional parameters. In addition to functionality provided by + StringCchPrintf, this routine also returns a pointer to the end of the + destination string and the number of characters left in the destination string + including the null terminator. The flags parameter allows additional controls. + +Arguments: + + pszDest - destination string + + cchDest - size of destination buffer in characters. + length must be sufficient to contain the resulting + formatted string plus the null terminator. + + ppszDestEnd - if ppszDestEnd is non-null, the function will return a + pointer to the end of the destination string. If the + function printed any data, the result will point to the + null termination character + + pcchRemaining - if pcchRemaining is non-null, the function will return + the number of characters left in the destination string, + including the null terminator + + dwFlags - controls some details of the string copy: + + STRSAFE_FILL_BEHIND_NULL + if the function succeeds, the low byte of dwFlags will be + used to fill the uninitialize part of destination buffer + behind the null terminator + + STRSAFE_IGNORE_NULLS + treat NULL string pointers like empty strings (TEXT("")) + + STRSAFE_FILL_ON_FAILURE + if the function fails, the low byte of dwFlags will be + used to fill all of the destination buffer, and it will + be null terminated. This will overwrite any truncated + string returned when the failure is + STRSAFE_E_INSUFFICIENT_BUFFER + + STRSAFE_NO_TRUNCATION / + STRSAFE_NULL_ON_FAILURE + if the function fails, the destination buffer will be set + to the empty string. This will overwrite any truncated string + returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. + + pszFormat - format string which must be null terminated + + ... - additional parameters to be formatted according to + the format string + +Notes: + Behavior is undefined if destination, format strings or any arguments + strings overlap. + + pszDest and pszFormat should not be NULL unless the STRSAFE_IGNORE_NULLS + flag is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and + pszFormat may be NULL. An error may still be returned even though NULLS + are ignored due to insufficient space. + +Return Value: + + S_OK - if there was source data and it was all concatenated and + the resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the print + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCchPrintfExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, ...); +STRSAFEAPI StringCchPrintfExW(wchar_t* pszDest, size_t cchDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const wchar_t* pszFormat, ...); +#ifdef UNICODE +#define StringCchPrintfEx StringCchPrintfExW +#else +#define StringCchPrintfEx StringCchPrintfExA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCchPrintfExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, ...) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + va_list argList; + + // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 + cbDest = cchDest * sizeof(char); + va_start(argList, pszFormat); + + hr = StringVPrintfExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags, pszFormat, argList); + + va_end(argList); + } + + return hr; +} + +STRSAFEAPI StringCchPrintfExW(wchar_t* pszDest, size_t cchDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const wchar_t* pszFormat, ...) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + va_list argList; + + // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + cbDest = cchDest * sizeof(wchar_t); + va_start(argList, pszFormat); + + hr = StringVPrintfExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags, pszFormat, argList); + + va_end(argList); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CCH_FUNCTIONS + + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbPrintfEx( + OUT LPTSTR pszDest OPTIONAL, + IN size_t cbDest, + OUT LPTSTR* ppszDestEnd OPTIONAL, + OUT size_t* pcbRemaining OPTIONAL, + IN DWORD dwFlags, + IN LPCTSTR pszFormat OPTIONAL, + ... + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'sprintf' with + some additional parameters. In addition to functionality provided by + StringCbPrintf, this routine also returns a pointer to the end of the + destination string and the number of bytes left in the destination string + including the null terminator. The flags parameter allows additional controls. + +Arguments: + + pszDest - destination string + + cbDest - size of destination buffer in bytes. + length must be sufficient to contain the resulting + formatted string plus the null terminator. + + ppszDestEnd - if ppszDestEnd is non-null, the function will return a + pointer to the end of the destination string. If the + function printed any data, the result will point to the + null termination character + + pcbRemaining - if pcbRemaining is non-null, the function will return + the number of bytes left in the destination string, + including the null terminator + + dwFlags - controls some details of the string copy: + + STRSAFE_FILL_BEHIND_NULL + if the function succeeds, the low byte of dwFlags will be + used to fill the uninitialize part of destination buffer + behind the null terminator + + STRSAFE_IGNORE_NULLS + treat NULL string pointers like empty strings (TEXT("")) + + STRSAFE_FILL_ON_FAILURE + if the function fails, the low byte of dwFlags will be + used to fill all of the destination buffer, and it will + be null terminated. This will overwrite any truncated + string returned when the failure is + STRSAFE_E_INSUFFICIENT_BUFFER + + STRSAFE_NO_TRUNCATION / + STRSAFE_NULL_ON_FAILURE + if the function fails, the destination buffer will be set + to the empty string. This will overwrite any truncated string + returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. + + pszFormat - format string which must be null terminated + + ... - additional parameters to be formatted according to + the format string + +Notes: + Behavior is undefined if destination, format strings or any arguments + strings overlap. + + pszDest and pszFormat should not be NULL unless the STRSAFE_IGNORE_NULLS + flag is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and + pszFormat may be NULL. An error may still be returned even though NULLS + are ignored due to insufficient space. + +Return Value: + + S_OK - if there was source data and it was all concatenated and + the resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the print + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCbPrintfExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const char* pszFormat, ...); +STRSAFEAPI StringCbPrintfExW(wchar_t* pszDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const wchar_t* pszFormat, ...); +#ifdef UNICODE +#define StringCbPrintfEx StringCbPrintfExW +#else +#define StringCbPrintfEx StringCbPrintfExA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCbPrintfExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const char* pszFormat, ...) +{ + HRESULT hr; + size_t cchDest; + size_t cchRemaining = 0; + + cchDest = cbDest / sizeof(char); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + va_list argList; + + va_start(argList, pszFormat); + + hr = StringVPrintfExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags, pszFormat, argList); + + va_end(argList); + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (pcbRemaining) + { + // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1 + *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)); + } + } + + return hr; +} + +STRSAFEAPI StringCbPrintfExW(wchar_t* pszDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const wchar_t* pszFormat, ...) +{ + HRESULT hr; + size_t cchDest; + size_t cchRemaining = 0; + + cchDest = cbDest / sizeof(wchar_t); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + va_list argList; + + va_start(argList, pszFormat); + + hr = StringVPrintfExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags, pszFormat, argList); + + va_end(argList); + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (pcbRemaining) + { + // safe to multiply cchRemaining * sizeof(wchar_t) since cchRemaining < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + *pcbRemaining = (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)); + } + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CB_FUNCTIONS + + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchVPrintfEx( + OUT LPTSTR pszDest OPTIONAL, + IN size_t cchDest, + OUT LPTSTR* ppszDestEnd OPTIONAL, + OUT size_t* pcchRemaining OPTIONAL, + IN DWORD dwFlags, + IN LPCTSTR pszFormat OPTIONAL, + IN va_list argList + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'vsprintf' with + some additional parameters. In addition to functionality provided by + StringCchVPrintf, this routine also returns a pointer to the end of the + destination string and the number of characters left in the destination string + including the null terminator. The flags parameter allows additional controls. + +Arguments: + + pszDest - destination string + + cchDest - size of destination buffer in characters. + length must be sufficient to contain the resulting + formatted string plus the null terminator. + + ppszDestEnd - if ppszDestEnd is non-null, the function will return a + pointer to the end of the destination string. If the + function printed any data, the result will point to the + null termination character + + pcchRemaining - if pcchRemaining is non-null, the function will return + the number of characters left in the destination string, + including the null terminator + + dwFlags - controls some details of the string copy: + + STRSAFE_FILL_BEHIND_NULL + if the function succeeds, the low byte of dwFlags will be + used to fill the uninitialize part of destination buffer + behind the null terminator + + STRSAFE_IGNORE_NULLS + treat NULL string pointers like empty strings (TEXT("")) + + STRSAFE_FILL_ON_FAILURE + if the function fails, the low byte of dwFlags will be + used to fill all of the destination buffer, and it will + be null terminated. This will overwrite any truncated + string returned when the failure is + STRSAFE_E_INSUFFICIENT_BUFFER + + STRSAFE_NO_TRUNCATION / + STRSAFE_NULL_ON_FAILURE + if the function fails, the destination buffer will be set + to the empty string. This will overwrite any truncated string + returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. + + pszFormat - format string which must be null terminated + + argList - va_list from the variable arguments according to the + stdarg.h convention + +Notes: + Behavior is undefined if destination, format strings or any arguments + strings overlap. + + pszDest and pszFormat should not be NULL unless the STRSAFE_IGNORE_NULLS + flag is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and + pszFormat may be NULL. An error may still be returned even though NULLS + are ignored due to insufficient space. + +Return Value: + + S_OK - if there was source data and it was all concatenated and + the resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the print + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCchVPrintfExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList); +STRSAFEAPI StringCchVPrintfExW(wchar_t* pszDest, size_t cchDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const wchar_t* pszFormat, va_list argList); +#ifdef UNICODE +#define StringCchVPrintfEx StringCchVPrintfExW +#else +#define StringCchVPrintfEx StringCchVPrintfExA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCchVPrintfExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + + // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 + cbDest = cchDest * sizeof(char); + + hr = StringVPrintfExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags, pszFormat, argList); + } + + return hr; +} + +STRSAFEAPI StringCchVPrintfExW(wchar_t* pszDest, size_t cchDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const wchar_t* pszFormat, va_list argList) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + + // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + cbDest = cchDest * sizeof(wchar_t); + + hr = StringVPrintfExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags, pszFormat, argList); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CCH_FUNCTIONS + + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbVPrintfEx( + OUT LPTSTR pszDest OPTIONAL, + IN size_t cbDest, + OUT LPTSTR* ppszDestEnd OPTIONAL, + OUT size_t* pcbRemaining OPTIONAL, + IN DWORD dwFlags, + IN LPCTSTR pszFormat OPTIONAL, + IN va_list argList + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'vsprintf' with + some additional parameters. In addition to functionality provided by + StringCbVPrintf, this routine also returns a pointer to the end of the + destination string and the number of characters left in the destination string + including the null terminator. The flags parameter allows additional controls. + +Arguments: + + pszDest - destination string + + cbDest - size of destination buffer in bytes. + length must be sufficient to contain the resulting + formatted string plus the null terminator. + + ppszDestEnd - if ppszDestEnd is non-null, the function will return + a pointer to the end of the destination string. If the + function printed any data, the result will point to the + null termination character + + pcbRemaining - if pcbRemaining is non-null, the function will return + the number of bytes left in the destination string, + including the null terminator + + dwFlags - controls some details of the string copy: + + STRSAFE_FILL_BEHIND_NULL + if the function succeeds, the low byte of dwFlags will be + used to fill the uninitialize part of destination buffer + behind the null terminator + + STRSAFE_IGNORE_NULLS + treat NULL string pointers like empty strings (TEXT("")) + + STRSAFE_FILL_ON_FAILURE + if the function fails, the low byte of dwFlags will be + used to fill all of the destination buffer, and it will + be null terminated. This will overwrite any truncated + string returned when the failure is + STRSAFE_E_INSUFFICIENT_BUFFER + + STRSAFE_NO_TRUNCATION / + STRSAFE_NULL_ON_FAILURE + if the function fails, the destination buffer will be set + to the empty string. This will overwrite any truncated string + returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER. + + pszFormat - format string which must be null terminated + + argList - va_list from the variable arguments according to the + stdarg.h convention + +Notes: + Behavior is undefined if destination, format strings or any arguments + strings overlap. + + pszDest and pszFormat should not be NULL unless the STRSAFE_IGNORE_NULLS + flag is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and + pszFormat may be NULL. An error may still be returned even though NULLS + are ignored due to insufficient space. + +Return Value: + + S_OK - if there was source data and it was all concatenated and + the resultant dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that the print + operation failed due to insufficient space. When this + error occurs, the destination buffer is modified to + contain a truncated version of the ideal result and is + null terminated. This is useful for situations where + truncation is ok. + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function + +--*/ + +STRSAFEAPI StringCbVPrintfExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList); +STRSAFEAPI StringCbVPrintfExW(wchar_t* pszDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const wchar_t* pszFormat, va_list argList); +#ifdef UNICODE +#define StringCbVPrintfEx StringCbVPrintfExW +#else +#define StringCbVPrintfEx StringCbVPrintfExA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCbVPrintfExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList) +{ + HRESULT hr; + size_t cchDest; + size_t cchRemaining = 0; + + cchDest = cbDest / sizeof(char); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringVPrintfExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags, pszFormat, argList); + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (pcbRemaining) + { + // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1 + *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)); + } + } + + return hr; +} + +STRSAFEAPI StringCbVPrintfExW(wchar_t* pszDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const wchar_t* pszFormat, va_list argList) +{ + HRESULT hr; + size_t cchDest; + size_t cchRemaining = 0; + + cchDest = cbDest / sizeof(wchar_t); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringVPrintfExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags, pszFormat, argList); + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (pcbRemaining) + { + // safe to multiply cchRemaining * sizeof(wchar_t) since cchRemaining < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + *pcbRemaining = (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)); + } + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CB_FUNCTIONS + + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchGets( + OUT LPTSTR pszDest, + IN size_t cchDest + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'gets'. + The size of the destination buffer (in characters) is a parameter and + this function will not write past the end of this buffer and it will + ALWAYS null terminate the destination buffer (unless it is zero length). + + This routine is not a replacement for fgets. That function does not replace + newline characters with a null terminator. + + This function returns a hresult, and not a pointer. It returns + S_OK if any characters were read from stdin and copied to pszDest and + pszDest was null terminated, otherwise it will return a failure code. + +Arguments: + + pszDest - destination string + + cchDest - size of destination buffer in characters. + +Notes: + pszDest should not be NULL. See StringCchGetsEx if you require the handling + of NULL values. + + cchDest must be > 1 for this function to succeed. + +Return Value: + + S_OK - data was read from stdin and copied, and the resultant + dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_END_OF_FILE / + HRESULT_CODE(hr) == ERROR_HANDLE_EOF + - this return value indicates an error or end-of-file + condition, use feof or ferror to determine which one has + occured. + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that there was + insufficient space in the destination buffer to copy any + data + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function. + +--*/ + +#ifndef STRSAFE_LIB_IMPL +STRSAFE_INLINE_API StringCchGetsA(char* pszDest, size_t cchDest); +STRSAFE_INLINE_API StringCchGetsW(wchar_t* pszDest, size_t cchDest); +#ifdef UNICODE +#define StringCchGets StringCchGetsW +#else +#define StringCchGets StringCchGetsA +#endif // !UNICODE + +STRSAFE_INLINE_API StringCchGetsA(char* pszDest, size_t cchDest) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + + // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 + cbDest = cchDest * sizeof(char); + + hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, NULL, NULL, 0); + } + + return hr; +} + +STRSAFE_INLINE_API StringCchGetsW(wchar_t* pszDest, size_t cchDest) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + + // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + cbDest = cchDest * sizeof(wchar_t); + + hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, NULL, NULL, 0); + } + + return hr; +} +#endif // !STRSAFE_NO_CCH_FUNCTIONS +#endif // !STRSAFE_LIB_IMPL + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbGets( + OUT LPTSTR pszDest, + IN size_t cbDest + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'gets'. + The size of the destination buffer (in bytes) is a parameter and + this function will not write past the end of this buffer and it will + ALWAYS null terminate the destination buffer (unless it is zero length). + + This routine is not a replacement for fgets. That function does not replace + newline characters with a null terminator. + + This function returns a hresult, and not a pointer. It returns + S_OK if any characters were read from stdin and copied to pszDest + and pszDest was null terminated, otherwise it will return a failure code. + +Arguments: + + pszDest - destination string + + cbDest - size of destination buffer in bytes. + +Notes: + pszDest should not be NULL. See StringCbGetsEx if you require the handling + of NULL values. + + cbDest must be > sizeof(TCHAR) for this function to succeed. + +Return Value: + + S_OK - data was read from stdin and copied, and the resultant + dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_END_OF_FILE / + HRESULT_CODE(hr) == ERROR_HANDLE_EOF + - this return value indicates an error or end-of-file + condition, use feof or ferror to determine which one has + occured. + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that there was + insufficient space in the destination buffer to copy any + data + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function. + +--*/ + +#ifndef STRSAFE_LIB_IMPL +STRSAFE_INLINE_API StringCbGetsA(char* pszDest, size_t cbDest); +STRSAFE_INLINE_API StringCbGetsW(wchar_t* pszDest, size_t cbDest); +#ifdef UNICODE +#define StringCbGets StringCbGetsW +#else +#define StringCbGets StringCbGetsA +#endif // !UNICODE + +STRSAFE_INLINE_API StringCbGetsA(char* pszDest, size_t cbDest) +{ + HRESULT hr; + size_t cchDest; + + // convert to count of characters + cchDest = cbDest / sizeof(char); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, NULL, NULL, 0); + } + + return hr; +} + +STRSAFE_INLINE_API StringCbGetsW(wchar_t* pszDest, size_t cbDest) +{ + HRESULT hr; + size_t cchDest; + + // convert to count of characters + cchDest = cbDest / sizeof(wchar_t); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, NULL, NULL, 0); + } + + return hr; +} +#endif // !STRSAFE_NO_CB_FUNCTIONS +#endif // !STRSAFE_LIB_IMPL + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchGetsEx( + OUT LPTSTR pszDest OPTIONAL, + IN size_t cchDest, + OUT LPTSTR* ppszDestEnd OPTIONAL, + OUT size_t* pcchRemaining OPTIONAL, + IN DWORD dwFlags + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'gets' with + some additional parameters. In addition to functionality provided by + StringCchGets, this routine also returns a pointer to the end of the + destination string and the number of characters left in the destination string + including the null terminator. The flags parameter allows additional controls. + +Arguments: + + pszDest - destination string + + cchDest - size of destination buffer in characters. + + ppszDestEnd - if ppszDestEnd is non-null, the function will return a + pointer to the end of the destination string. If the + function copied any data, the result will point to the + null termination character + + pcchRemaining - if pcchRemaining is non-null, the function will return the + number of characters left in the destination string, + including the null terminator + + dwFlags - controls some details of the string copy: + + STRSAFE_FILL_BEHIND_NULL + if the function succeeds, the low byte of dwFlags will be + used to fill the uninitialize part of destination buffer + behind the null terminator + + STRSAFE_IGNORE_NULLS + treat NULL string pointers like empty strings (TEXT("")). + + STRSAFE_FILL_ON_FAILURE + if the function fails, the low byte of dwFlags will be + used to fill all of the destination buffer, and it will + be null terminated. + + STRSAFE_NO_TRUNCATION / + STRSAFE_NULL_ON_FAILURE + if the function fails, the destination buffer will be set + to the empty string. + +Notes: + pszDest should not be NULL unless the STRSAFE_IGNORE_NULLS flag is specified. + If STRSAFE_IGNORE_NULLS is passed and pszDest is NULL, an error may still be + returned even though NULLS are ignored + + cchDest must be > 1 for this function to succeed. + +Return Value: + + S_OK - data was read from stdin and copied, and the resultant + dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_END_OF_FILE / + HRESULT_CODE(hr) == ERROR_HANDLE_EOF + - this return value indicates an error or end-of-file + condition, use feof or ferror to determine which one has + occured. + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that there was + insufficient space in the destination buffer to copy any + data + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function. + +--*/ + +#ifndef STRSAFE_LIB_IMPL +STRSAFE_INLINE_API StringCchGetsExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +STRSAFE_INLINE_API StringCchGetsExW(wchar_t* pszDest, size_t cchDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags); +#ifdef UNICODE +#define StringCchGetsEx StringCchGetsExW +#else +#define StringCchGetsEx StringCchGetsExA +#endif // !UNICODE + +STRSAFE_INLINE_API StringCchGetsExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + + // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1 + cbDest = cchDest * sizeof(char); + + hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags); + } + + return hr; +} + +STRSAFE_INLINE_API StringCchGetsExW(wchar_t* pszDest, size_t cchDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr; + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cbDest; + + // safe to multiply cchDest * sizeof(wchar_t) since cchDest < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + cbDest = cchDest * sizeof(wchar_t); + + hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags); + } + + return hr; +} +#endif // !STRSAFE_NO_CCH_FUNCTIONS +#endif // !STRSAFE_LIB_IMPL + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbGetsEx( + OUT LPTSTR pszDest OPTIONAL, + IN size_t cbDest, + OUT LPTSTR* ppszDestEnd OPTIONAL, + OUT size_t* pcbRemaining OPTIONAL, + IN DWORD dwFlags + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'gets' with + some additional parameters. In addition to functionality provided by + StringCbGets, this routine also returns a pointer to the end of the + destination string and the number of characters left in the destination string + including the null terminator. The flags parameter allows additional controls. + +Arguments: + + pszDest - destination string + + cbDest - size of destination buffer in bytes. + + ppszDestEnd - if ppszDestEnd is non-null, the function will return a + pointer to the end of the destination string. If the + function copied any data, the result will point to the + null termination character + + pcbRemaining - if pbRemaining is non-null, the function will return the + number of bytes left in the destination string, + including the null terminator + + dwFlags - controls some details of the string copy: + + STRSAFE_FILL_BEHIND_NULL + if the function succeeds, the low byte of dwFlags will be + used to fill the uninitialize part of destination buffer + behind the null terminator + + STRSAFE_IGNORE_NULLS + treat NULL string pointers like empty strings (TEXT("")). + + STRSAFE_FILL_ON_FAILURE + if the function fails, the low byte of dwFlags will be + used to fill all of the destination buffer, and it will + be null terminated. + + STRSAFE_NO_TRUNCATION / + STRSAFE_NULL_ON_FAILURE + if the function fails, the destination buffer will be set + to the empty string. + +Notes: + pszDest should not be NULL unless the STRSAFE_IGNORE_NULLS flag is specified. + If STRSAFE_IGNORE_NULLS is passed and pszDest is NULL, an error may still be + returned even though NULLS are ignored + + cbDest must be > sizeof(TCHAR) for this function to succeed + +Return Value: + + S_OK - data was read from stdin and copied, and the resultant + dest string was null terminated + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + STRSAFE_E_END_OF_FILE / + HRESULT_CODE(hr) == ERROR_HANDLE_EOF + - this return value indicates an error or end-of-file + condition, use feof or ferror to determine which one has + occured. + + STRSAFE_E_INSUFFICIENT_BUFFER / + HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER + - this return value is an indication that there was + insufficient space in the destination buffer to copy any + data + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function. + +--*/ + +#ifndef STRSAFE_LIB_IMPL +STRSAFE_INLINE_API StringCbGetsExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pbRemaining, unsigned long dwFlags); +STRSAFE_INLINE_API StringCbGetsExW(wchar_t* pszDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags); +#ifdef UNICODE +#define StringCbGetsEx StringCbGetsExW +#else +#define StringCbGetsEx StringCbGetsExA +#endif // !UNICODE + +STRSAFE_INLINE_API StringCbGetsExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) +{ + HRESULT hr; + size_t cchDest; + size_t cchRemaining = 0; + + cchDest = cbDest / sizeof(char); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags); + } + + if (SUCCEEDED(hr) || + (hr == STRSAFE_E_INSUFFICIENT_BUFFER) || + (hr == STRSAFE_E_END_OF_FILE)) + { + if (pcbRemaining) + { + // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1 + *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)); + } + } + + return hr; +} + +STRSAFE_INLINE_API StringCbGetsExW(wchar_t* pszDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags) +{ + HRESULT hr; + size_t cchDest; + size_t cchRemaining = 0; + + cchDest = cbDest / sizeof(wchar_t); + + if (cchDest > STRSAFE_MAX_CCH) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags); + } + + if (SUCCEEDED(hr) || + (hr == STRSAFE_E_INSUFFICIENT_BUFFER) || + (hr == STRSAFE_E_END_OF_FILE)) + { + if (pcbRemaining) + { + // safe to multiply cchRemaining * sizeof(wchar_t) since cchRemaining < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + *pcbRemaining = (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)); + } + } + + return hr; +} +#endif // !STRSAFE_NO_CB_FUNCTIONS +#endif // !STRSAFE_LIB_IMPL + +#ifndef STRSAFE_NO_CCH_FUNCTIONS +/*++ + +STDAPI +StringCchLength( + IN LPCTSTR psz, + IN size_t cchMax, + OUT size_t* pcch OPTIONAL + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strlen'. + It is used to make sure a string is not larger than a given length, and + it optionally returns the current length in characters not including + the null terminator. + + This function returns a hresult, and not a pointer. It returns + S_OK if the string is non-null and the length including the null + terminator is less than or equal to cchMax characters. + +Arguments: + + psz - string to check the length of + + cchMax - maximum number of characters including the null terminator + that psz is allowed to contain + + pcch - if the function succeeds and pcch is non-null, the current length + in characters of psz excluding the null terminator will be returned. + This out parameter is equivalent to the return value of strlen(psz) + +Notes: + psz can be null but the function will fail + + cchMax should be greater than zero or the function will fail + +Return Value: + + S_OK - psz is non-null and the length including the null + terminator is less than or equal to cchMax characters + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function. + +--*/ + +STRSAFEAPI StringCchLengthA(const char* psz, size_t cchMax, size_t* pcch); +STRSAFEAPI StringCchLengthW(const wchar_t* psz, size_t cchMax, size_t* pcch); +#ifdef UNICODE +#define StringCchLength StringCchLengthW +#else +#define StringCchLength StringCchLengthA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCchLengthA(const char* psz, size_t cchMax, size_t* pcch) +{ + HRESULT hr; + + if ((psz == NULL) || (cchMax > STRSAFE_MAX_CCH)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringLengthWorkerA(psz, cchMax, pcch); + } + + return hr; +} + +STRSAFEAPI StringCchLengthW(const wchar_t* psz, size_t cchMax, size_t* pcch) +{ + HRESULT hr; + + if ((psz == NULL) || (cchMax > STRSAFE_MAX_CCH)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringLengthWorkerW(psz, cchMax, pcch); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CCH_FUNCTIONS + + +#ifndef STRSAFE_NO_CB_FUNCTIONS +/*++ + +STDAPI +StringCbLength( + IN LPCTSTR psz, + IN size_t cbMax, + OUT size_t* pcb OPTIONAL + ); + +Routine Description: + + This routine is a safer version of the C built-in function 'strlen'. + It is used to make sure a string is not larger than a given length, and + it optionally returns the current length in bytes not including + the null terminator. + + This function returns a hresult, and not a pointer. It returns + S_OK if the string is non-null and the length including the null + terminator is less than or equal to cbMax bytes. + +Arguments: + + psz - string to check the length of + + cbMax - maximum number of bytes including the null terminator + that psz is allowed to contain + + pcb - if the function succeeds and pcb is non-null, the current length + in bytes of psz excluding the null terminator will be returned. + This out parameter is equivalent to the return value of strlen(psz) * sizeof(TCHAR) + +Notes: + psz can be null but the function will fail + + cbMax should be greater than or equal to sizeof(TCHAR) or the function will fail + +Return Value: + + S_OK - psz is non-null and the length including the null + terminator is less than or equal to cbMax bytes + + failure - you can use the macro HRESULT_CODE() to get a win32 + error code for all hresult failure cases + + It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the + return value of this function. + +--*/ + +STRSAFEAPI StringCbLengthA(const char* psz, size_t cchMax, size_t* pcch); +STRSAFEAPI StringCbLengthW(const wchar_t* psz, size_t cchMax, size_t* pcch); +#ifdef UNICODE +#define StringCbLength StringCbLengthW +#else +#define StringCbLength StringCbLengthA +#endif // !UNICODE + +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCbLengthA(const char* psz, size_t cbMax, size_t* pcb) +{ + HRESULT hr; + size_t cchMax; + size_t cch = 0; + + cchMax = cbMax / sizeof(char); + + if ((psz == NULL) || (cchMax > STRSAFE_MAX_CCH)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringLengthWorkerA(psz, cchMax, &cch); + } + + if (SUCCEEDED(hr) && pcb) + { + // safe to multiply cch * sizeof(char) since cch < STRSAFE_MAX_CCH and sizeof(char) is 1 + *pcb = cch * sizeof(char); + } + + return hr; +} + +STRSAFEAPI StringCbLengthW(const wchar_t* psz, size_t cbMax, size_t* pcb) +{ + HRESULT hr; + size_t cchMax; + size_t cch = 0; + + cchMax = cbMax / sizeof(wchar_t); + + if ((psz == NULL) || (cchMax > STRSAFE_MAX_CCH)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = StringLengthWorkerW(psz, cchMax, &cch); + } + + if (SUCCEEDED(hr) && pcb) + { + // safe to multiply cch * sizeof(wchar_t) since cch < STRSAFE_MAX_CCH and sizeof(wchar_t) is 2 + *pcb = cch * sizeof(wchar_t); + } + + return hr; +} +#endif // STRSAFE_INLINE +#endif // !STRSAFE_NO_CB_FUNCTIONS + + +// these are the worker functions that actually do the work +#ifdef STRSAFE_INLINE +STRSAFEAPI StringCopyWorkerA(char* pszDest, size_t cchDest, const char* pszSrc) +{ + HRESULT hr = S_OK; + + if (cchDest == 0) + { + // can not null terminate a zero-byte dest buffer + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + while (cchDest && (*pszSrc != '\0')) + { + *pszDest++ = *pszSrc++; + cchDest--; + } + + if (cchDest == 0) + { + // we are going to truncate pszDest + pszDest--; + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + + *pszDest= '\0'; + } + + return hr; +} + +STRSAFEAPI StringCopyWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc) +{ + HRESULT hr = S_OK; + + if (cchDest == 0) + { + // can not null terminate a zero-byte dest buffer + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + while (cchDest && (*pszSrc != L'\0')) + { + *pszDest++ = *pszSrc++; + cchDest--; + } + + if (cchDest == 0) + { + // we are going to truncate pszDest + pszDest--; + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + + *pszDest= L'\0'; + } + + return hr; +} + +STRSAFEAPI StringCopyExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr = S_OK; + char* pszDestEnd = pszDest; + size_t cchRemaining = 0; + + // ASSERT(cbDest == (cchDest * sizeof(char)) || + // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char))); + + // only accept valid flags + if (dwFlags & (~STRSAFE_VALID_FLAGS)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + if (dwFlags & STRSAFE_IGNORE_NULLS) + { + if (pszDest == NULL) + { + if ((cchDest != 0) || (cbDest != 0)) + { + // NULL pszDest and non-zero cchDest/cbDest is invalid + hr = STRSAFE_E_INVALID_PARAMETER; + } + } + + if (pszSrc == NULL) + { + pszSrc = ""; + } + } + + if (SUCCEEDED(hr)) + { + if (cchDest == 0) + { + pszDestEnd = pszDest; + cchRemaining = 0; + + // only fail if there was actually src data to copy + if (*pszSrc != '\0') + { + if (pszDest == NULL) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + } + } + else + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + while (cchRemaining && (*pszSrc != '\0')) + { + *pszDestEnd++= *pszSrc++; + cchRemaining--; + } + + if (cchRemaining > 0) + { + if (dwFlags & STRSAFE_FILL_BEHIND_NULL) + { + memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(char)) + (cbDest % sizeof(char))); + } + } + else + { + // we are going to truncate pszDest + pszDestEnd--; + cchRemaining++; + + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + + *pszDestEnd = '\0'; + } + } + } + + if (FAILED(hr)) + { + if (pszDest) + { + if (dwFlags & STRSAFE_FILL_ON_FAILURE) + { + memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); + + if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + } + else if (cchDest > 0) + { + pszDestEnd = pszDest + cchDest - 1; + cchRemaining = 1; + + // null terminate the end of the string + *pszDestEnd = '\0'; + } + } + + if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) + { + if (cchDest > 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + // null terminate the beginning of the string + *pszDestEnd = '\0'; + } + } + } + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (ppszDestEnd) + { + *ppszDestEnd = pszDestEnd; + } + + if (pcchRemaining) + { + *pcchRemaining = cchRemaining; + } + } + + return hr; +} + +STRSAFEAPI StringCopyExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr = S_OK; + wchar_t* pszDestEnd = pszDest; + size_t cchRemaining = 0; + + // ASSERT(cbDest == (cchDest * sizeof(wchar_t)) || + // cbDest == (cchDest * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); + + // only accept valid flags + if (dwFlags & (~STRSAFE_VALID_FLAGS)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + if (dwFlags & STRSAFE_IGNORE_NULLS) + { + if (pszDest == NULL) + { + if ((cchDest != 0) || (cbDest != 0)) + { + // NULL pszDest and non-zero cchDest/cbDest is invalid + hr = STRSAFE_E_INVALID_PARAMETER; + } + } + + if (pszSrc == NULL) + { + pszSrc = L""; + } + } + + if (SUCCEEDED(hr)) + { + if (cchDest == 0) + { + pszDestEnd = pszDest; + cchRemaining = 0; + + // only fail if there was actually src data to copy + if (*pszSrc != L'\0') + { + if (pszDest == NULL) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + } + } + else + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + while (cchRemaining && (*pszSrc != L'\0')) + { + *pszDestEnd++= *pszSrc++; + cchRemaining--; + } + + if (cchRemaining > 0) + { + if (dwFlags & STRSAFE_FILL_BEHIND_NULL) + { + memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); + } + } + else + { + // we are going to truncate pszDest + pszDestEnd--; + cchRemaining++; + + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + + *pszDestEnd = L'\0'; + } + } + } + + if (FAILED(hr)) + { + if (pszDest) + { + if (dwFlags & STRSAFE_FILL_ON_FAILURE) + { + memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); + + if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + } + else if (cchDest > 0) + { + pszDestEnd = pszDest + cchDest - 1; + cchRemaining = 1; + + // null terminate the end of the string + *pszDestEnd = L'\0'; + } + } + + if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) + { + if (cchDest > 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + // null terminate the beginning of the string + *pszDestEnd = L'\0'; + } + } + } + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (ppszDestEnd) + { + *ppszDestEnd = pszDestEnd; + } + + if (pcchRemaining) + { + *pcchRemaining = cchRemaining; + } + } + + return hr; +} + +STRSAFEAPI StringCopyNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc) +{ + HRESULT hr = S_OK; + + if (cchDest == 0) + { + // can not null terminate a zero-byte dest buffer + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + while (cchDest && cchSrc && (*pszSrc != '\0')) + { + *pszDest++= *pszSrc++; + cchDest--; + cchSrc--; + } + + if (cchDest == 0) + { + // we are going to truncate pszDest + pszDest--; + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + + *pszDest= '\0'; + } + + return hr; +} + +STRSAFEAPI StringCopyNWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchSrc) +{ + HRESULT hr = S_OK; + + if (cchDest == 0) + { + // can not null terminate a zero-byte dest buffer + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + while (cchDest && cchSrc && (*pszSrc != L'\0')) + { + *pszDest++= *pszSrc++; + cchDest--; + cchSrc--; + } + + if (cchDest == 0) + { + // we are going to truncate pszDest + pszDest--; + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + + *pszDest= L'\0'; + } + + return hr; +} + +STRSAFEAPI StringCopyNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr = S_OK; + char* pszDestEnd = pszDest; + size_t cchRemaining = 0; + + // ASSERT(cbDest == (cchDest * sizeof(char)) || + // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char))); + + // only accept valid flags + if (dwFlags & (~STRSAFE_VALID_FLAGS)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + if (dwFlags & STRSAFE_IGNORE_NULLS) + { + if (pszDest == NULL) + { + if ((cchDest != 0) || (cbDest != 0)) + { + // NULL pszDest and non-zero cchDest/cbDest is invalid + hr = STRSAFE_E_INVALID_PARAMETER; + } + } + + if (pszSrc == NULL) + { + pszSrc = ""; + } + } + + if (SUCCEEDED(hr)) + { + if (cchDest == 0) + { + pszDestEnd = pszDest; + cchRemaining = 0; + + // only fail if there was actually src data to copy + if (*pszSrc != '\0') + { + if (pszDest == NULL) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + } + } + else + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + while (cchRemaining && cchSrc && (*pszSrc != '\0')) + { + *pszDestEnd++= *pszSrc++; + cchRemaining--; + cchSrc--; + } + + if (cchRemaining > 0) + { + if (dwFlags & STRSAFE_FILL_BEHIND_NULL) + { + memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(char)) + (cbDest % sizeof(char))); + } + } + else + { + // we are going to truncate pszDest + pszDestEnd--; + cchRemaining++; + + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + + *pszDestEnd = '\0'; + } + } + } + + if (FAILED(hr)) + { + if (pszDest) + { + if (dwFlags & STRSAFE_FILL_ON_FAILURE) + { + memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); + + if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + } + else if (cchDest > 0) + { + pszDestEnd = pszDest + cchDest - 1; + cchRemaining = 1; + + // null terminate the end of the string + *pszDestEnd = '\0'; + } + } + + if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) + { + if (cchDest > 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + // null terminate the beginning of the string + *pszDestEnd = '\0'; + } + } + } + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (ppszDestEnd) + { + *ppszDestEnd = pszDestEnd; + } + + if (pcchRemaining) + { + *pcchRemaining = cchRemaining; + } + } + + return hr; +} + +STRSAFEAPI StringCopyNExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, size_t cchSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr = S_OK; + wchar_t* pszDestEnd = pszDest; + size_t cchRemaining = 0; + + // ASSERT(cbDest == (cchDest * sizeof(wchar_t)) || + // cbDest == (cchDest * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); + + // only accept valid flags + if (dwFlags & (~STRSAFE_VALID_FLAGS)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + if (dwFlags & STRSAFE_IGNORE_NULLS) + { + if (pszDest == NULL) + { + if ((cchDest != 0) || (cbDest != 0)) + { + // NULL pszDest and non-zero cchDest/cbDest is invalid + hr = STRSAFE_E_INVALID_PARAMETER; + } + } + + if (pszSrc == NULL) + { + pszSrc = L""; + } + } + + if (SUCCEEDED(hr)) + { + if (cchDest == 0) + { + pszDestEnd = pszDest; + cchRemaining = 0; + + // only fail if there was actually src data to copy + if (*pszSrc != L'\0') + { + if (pszDest == NULL) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + } + } + else + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + while (cchRemaining && cchSrc && (*pszSrc != L'\0')) + { + *pszDestEnd++= *pszSrc++; + cchRemaining--; + cchSrc--; + } + + if (cchRemaining > 0) + { + if (dwFlags & STRSAFE_FILL_BEHIND_NULL) + { + memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); + } + } + else + { + // we are going to truncate pszDest + pszDestEnd--; + cchRemaining++; + + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + + *pszDestEnd = L'\0'; + } + } + } + + if (FAILED(hr)) + { + if (pszDest) + { + if (dwFlags & STRSAFE_FILL_ON_FAILURE) + { + memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); + + if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + } + else if (cchDest > 0) + { + pszDestEnd = pszDest + cchDest - 1; + cchRemaining = 1; + + // null terminate the end of the string + *pszDestEnd = L'\0'; + } + } + + if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) + { + if (cchDest > 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + // null terminate the beginning of the string + *pszDestEnd = L'\0'; + } + } + } + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (ppszDestEnd) + { + *ppszDestEnd = pszDestEnd; + } + + if (pcchRemaining) + { + *pcchRemaining = cchRemaining; + } + } + + return hr; +} + +STRSAFEAPI StringCatWorkerA(char* pszDest, size_t cchDest, const char* pszSrc) +{ + HRESULT hr; + size_t cchDestCurrent; + + hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent); + + if (SUCCEEDED(hr)) + { + hr = StringCopyWorkerA(pszDest + cchDestCurrent, + cchDest - cchDestCurrent, + pszSrc); + } + + return hr; +} + +STRSAFEAPI StringCatWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc) +{ + HRESULT hr; + size_t cchDestCurrent; + + hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent); + + if (SUCCEEDED(hr)) + { + hr = StringCopyWorkerW(pszDest + cchDestCurrent, + cchDest - cchDestCurrent, + pszSrc); + } + + return hr; +} + +STRSAFEAPI StringCatExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr = S_OK; + char* pszDestEnd = pszDest; + size_t cchRemaining = 0; + + // ASSERT(cbDest == (cchDest * sizeof(char)) || + // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char))); + + // only accept valid flags + if (dwFlags & (~STRSAFE_VALID_FLAGS)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cchDestCurrent; + + if (dwFlags & STRSAFE_IGNORE_NULLS) + { + if (pszDest == NULL) + { + if ((cchDest == 0) && (cbDest == 0)) + { + cchDestCurrent = 0; + } + else + { + // NULL pszDest and non-zero cchDest/cbDest is invalid + hr = STRSAFE_E_INVALID_PARAMETER; + } + } + else + { + hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent); + + if (SUCCEEDED(hr)) + { + pszDestEnd = pszDest + cchDestCurrent; + cchRemaining = cchDest - cchDestCurrent; + } + } + + if (pszSrc == NULL) + { + pszSrc = ""; + } + } + else + { + hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent); + + if (SUCCEEDED(hr)) + { + pszDestEnd = pszDest + cchDestCurrent; + cchRemaining = cchDest - cchDestCurrent; + } + } + + if (SUCCEEDED(hr)) + { + if (cchDest == 0) + { + // only fail if there was actually src data to append + if (*pszSrc != '\0') + { + if (pszDest == NULL) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + } + } + else + { + // we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass + // those flags through + hr = StringCopyExWorkerA(pszDestEnd, + cchRemaining, + (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)), + pszSrc, + &pszDestEnd, + &cchRemaining, + dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE))); + } + } + } + + if (FAILED(hr)) + { + if (pszDest) + { + // STRSAFE_NO_TRUNCATION is taken care of by StringCopyExWorkerA() + + if (dwFlags & STRSAFE_FILL_ON_FAILURE) + { + memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); + + if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + } + else + if (cchDest > 0) + { + pszDestEnd = pszDest + cchDest - 1; + cchRemaining = 1; + + // null terminate the end of the string + *pszDestEnd = '\0'; + } + } + + if (dwFlags & STRSAFE_NULL_ON_FAILURE) + { + if (cchDest > 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + // null terminate the beginning of the string + *pszDestEnd = '\0'; + } + } + } + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (ppszDestEnd) + { + *ppszDestEnd = pszDestEnd; + } + + if (pcchRemaining) + { + *pcchRemaining = cchRemaining; + } + } + + return hr; +} + +STRSAFEAPI StringCatExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr = S_OK; + wchar_t* pszDestEnd = pszDest; + size_t cchRemaining = 0; + + // ASSERT(cbDest == (cchDest * sizeof(wchar_t)) || + // cbDest == (cchDest * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); + + // only accept valid flags + if (dwFlags & (~STRSAFE_VALID_FLAGS)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + size_t cchDestCurrent; + + if (dwFlags & STRSAFE_IGNORE_NULLS) + { + if (pszDest == NULL) + { + if ((cchDest == 0) && (cbDest == 0)) + { + cchDestCurrent = 0; + } + else + { + // NULL pszDest and non-zero cchDest/cbDest is invalid + hr = STRSAFE_E_INVALID_PARAMETER; + } + } + else + { + hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent); + + if (SUCCEEDED(hr)) + { + pszDestEnd = pszDest + cchDestCurrent; + cchRemaining = cchDest - cchDestCurrent; + } + } + + if (pszSrc == NULL) + { + pszSrc = L""; + } + } + else + { + hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent); + + if (SUCCEEDED(hr)) + { + pszDestEnd = pszDest + cchDestCurrent; + cchRemaining = cchDest - cchDestCurrent; + } + } + + if (SUCCEEDED(hr)) + { + if (cchDest == 0) + { + // only fail if there was actually src data to append + if (*pszSrc != L'\0') + { + if (pszDest == NULL) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + } + } + else + { + // we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass + // those flags through + hr = StringCopyExWorkerW(pszDestEnd, + cchRemaining, + (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)), + pszSrc, + &pszDestEnd, + &cchRemaining, + dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE))); + } + } + } + + if (FAILED(hr)) + { + if (pszDest) + { + // STRSAFE_NO_TRUNCATION is taken care of by StringCopyExWorkerW() + + if (dwFlags & STRSAFE_FILL_ON_FAILURE) + { + memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); + + if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + } + else if (cchDest > 0) + { + pszDestEnd = pszDest + cchDest - 1; + cchRemaining = 1; + + // null terminate the end of the string + *pszDestEnd = L'\0'; + } + } + + if (dwFlags & STRSAFE_NULL_ON_FAILURE) + { + if (cchDest > 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + // null terminate the beginning of the string + *pszDestEnd = L'\0'; + } + } + } + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (ppszDestEnd) + { + *ppszDestEnd = pszDestEnd; + } + + if (pcchRemaining) + { + *pcchRemaining = cchRemaining; + } + } + + return hr; +} + +STRSAFEAPI StringCatNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend) +{ + HRESULT hr; + size_t cchDestCurrent; + + hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent); + + if (SUCCEEDED(hr)) + { + hr = StringCopyNWorkerA(pszDest + cchDestCurrent, + cchDest - cchDestCurrent, + pszSrc, + cchMaxAppend); + } + + return hr; +} + +STRSAFEAPI StringCatNWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc, size_t cchMaxAppend) +{ + HRESULT hr; + size_t cchDestCurrent; + + hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent); + + if (SUCCEEDED(hr)) + { + hr = StringCopyNWorkerW(pszDest + cchDestCurrent, + cchDest - cchDestCurrent, + pszSrc, + cchMaxAppend); + } + + return hr; +} + +STRSAFEAPI StringCatNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchMaxAppend, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr = S_OK; + char* pszDestEnd = pszDest; + size_t cchRemaining = 0; + size_t cchDestCurrent = 0; + + // ASSERT(cbDest == (cchDest * sizeof(char)) || + // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char))); + + // only accept valid flags + if (dwFlags & (~STRSAFE_VALID_FLAGS)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + if (dwFlags & STRSAFE_IGNORE_NULLS) + { + if (pszDest == NULL) + { + if ((cchDest == 0) && (cbDest == 0)) + { + cchDestCurrent = 0; + } + else + { + // NULL pszDest and non-zero cchDest/cbDest is invalid + hr = STRSAFE_E_INVALID_PARAMETER; + } + } + else + { + hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent); + + if (SUCCEEDED(hr)) + { + pszDestEnd = pszDest + cchDestCurrent; + cchRemaining = cchDest - cchDestCurrent; + } + } + + if (pszSrc == NULL) + { + pszSrc = ""; + } + } + else + { + hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent); + + if (SUCCEEDED(hr)) + { + pszDestEnd = pszDest + cchDestCurrent; + cchRemaining = cchDest - cchDestCurrent; + } + } + + if (SUCCEEDED(hr)) + { + if (cchDest == 0) + { + // only fail if there was actually src data to append + if (*pszSrc != '\0') + { + if (pszDest == NULL) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + } + } + else + { + // we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass + // those flags through + hr = StringCopyNExWorkerA(pszDestEnd, + cchRemaining, + (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)), + pszSrc, + cchMaxAppend, + &pszDestEnd, + &cchRemaining, + dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE))); + } + } + } + + if (FAILED(hr)) + { + if (pszDest) + { + // STRSAFE_NO_TRUNCATION is taken care of by StringCopyNExWorkerA() + + if (dwFlags & STRSAFE_FILL_ON_FAILURE) + { + memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); + + if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + } + else if (cchDest > 0) + { + pszDestEnd = pszDest + cchDest - 1; + cchRemaining = 1; + + // null terminate the end of the string + *pszDestEnd = '\0'; + } + } + + if (dwFlags & (STRSAFE_NULL_ON_FAILURE)) + { + if (cchDest > 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + // null terminate the beginning of the string + *pszDestEnd = '\0'; + } + } + } + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (ppszDestEnd) + { + *ppszDestEnd = pszDestEnd; + } + + if (pcchRemaining) + { + *pcchRemaining = cchRemaining; + } + } + + return hr; +} + +STRSAFEAPI StringCatNExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, const wchar_t* pszSrc, size_t cchMaxAppend, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr = S_OK; + wchar_t* pszDestEnd = pszDest; + size_t cchRemaining = 0; + size_t cchDestCurrent = 0; + + + // ASSERT(cbDest == (cchDest * sizeof(wchar_t)) || + // cbDest == (cchDest * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); + + // only accept valid flags + if (dwFlags & (~STRSAFE_VALID_FLAGS)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + if (dwFlags & STRSAFE_IGNORE_NULLS) + { + if (pszDest == NULL) + { + if ((cchDest == 0) && (cbDest == 0)) + { + cchDestCurrent = 0; + } + else + { + // NULL pszDest and non-zero cchDest/cbDest is invalid + hr = STRSAFE_E_INVALID_PARAMETER; + } + } + else + { + hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent); + + if (SUCCEEDED(hr)) + { + pszDestEnd = pszDest + cchDestCurrent; + cchRemaining = cchDest - cchDestCurrent; + } + } + + if (pszSrc == NULL) + { + pszSrc = L""; + } + } + else + { + hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent); + + if (SUCCEEDED(hr)) + { + pszDestEnd = pszDest + cchDestCurrent; + cchRemaining = cchDest - cchDestCurrent; + } + } + + if (SUCCEEDED(hr)) + { + if (cchDest == 0) + { + // only fail if there was actually src data to append + if (*pszSrc != L'\0') + { + if (pszDest == NULL) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + } + } + else + { + // we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass + // those flags through + hr = StringCopyNExWorkerW(pszDestEnd, + cchRemaining, + (cchRemaining * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)), + pszSrc, + cchMaxAppend, + &pszDestEnd, + &cchRemaining, + dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE))); + } + } + } + + if (FAILED(hr)) + { + if (pszDest) + { + // STRSAFE_NO_TRUNCATION is taken care of by StringCopyNExWorkerW() + + if (dwFlags & STRSAFE_FILL_ON_FAILURE) + { + memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); + + if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + } + else if (cchDest > 0) + { + pszDestEnd = pszDest + cchDest - 1; + cchRemaining = 1; + + // null terminate the end of the string + *pszDestEnd = L'\0'; + } + } + + if (dwFlags & (STRSAFE_NULL_ON_FAILURE)) + { + if (cchDest > 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + // null terminate the beginning of the string + *pszDestEnd = L'\0'; + } + } + } + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (ppszDestEnd) + { + *ppszDestEnd = pszDestEnd; + } + + if (pcchRemaining) + { + *pcchRemaining = cchRemaining; + } + } + + return hr; +} + +STRSAFEAPI StringVPrintfWorkerA(char* pszDest, size_t cchDest, const char* pszFormat, va_list argList) +{ + HRESULT hr = S_OK; + + if (cchDest == 0) + { + // can not null terminate a zero-byte dest buffer + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + int iRet; + size_t cchMax; + + // leave the last space for the null terminator + cchMax = cchDest - 1; + + iRet = _vsnprintf(pszDest, cchMax, pszFormat, argList); + // ASSERT((iRet < 0) || (((size_t)iRet) <= cchMax)); + + if ((iRet < 0) || (((size_t)iRet) > cchMax)) + { + // need to null terminate the string + pszDest += cchMax; + *pszDest = '\0'; + + // we have truncated pszDest + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + else if (((size_t)iRet) == cchMax) + { + // need to null terminate the string + pszDest += cchMax; + *pszDest = '\0'; + } + } + + return hr; +} + +STRSAFEAPI StringVPrintfWorkerW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszFormat, va_list argList) +{ + HRESULT hr = S_OK; + + if (cchDest == 0) + { + // can not null terminate a zero-byte dest buffer + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + int iRet; + size_t cchMax; + + // leave the last space for the null terminator + cchMax = cchDest - 1; + + iRet = _vsnwprintf(pszDest, cchMax, pszFormat, argList); + // ASSERT((iRet < 0) || (((size_t)iRet) <= cchMax)); + + if ((iRet < 0) || (((size_t)iRet) > cchMax)) + { + // need to null terminate the string + pszDest += cchMax; + *pszDest = L'\0'; + + // we have truncated pszDest + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + else if (((size_t)iRet) == cchMax) + { + // need to null terminate the string + pszDest += cchMax; + *pszDest = L'\0'; + } + } + + return hr; +} + +STRSAFEAPI StringVPrintfExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList) +{ + HRESULT hr = S_OK; + char* pszDestEnd = pszDest; + size_t cchRemaining = 0; + + // ASSERT(cbDest == (cchDest * sizeof(char)) || + // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char))); + + // only accept valid flags + if (dwFlags & (~STRSAFE_VALID_FLAGS)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + if (dwFlags & STRSAFE_IGNORE_NULLS) + { + if (pszDest == NULL) + { + if ((cchDest != 0) || (cbDest != 0)) + { + // NULL pszDest and non-zero cchDest/cbDest is invalid + hr = STRSAFE_E_INVALID_PARAMETER; + } + } + + if (pszFormat == NULL) + { + pszFormat = ""; + } + } + + if (SUCCEEDED(hr)) + { + if (cchDest == 0) + { + pszDestEnd = pszDest; + cchRemaining = 0; + + // only fail if there was actually a non-empty format string + if (*pszFormat != '\0') + { + if (pszDest == NULL) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + } + } + else + { + int iRet; + size_t cchMax; + + // leave the last space for the null terminator + cchMax = cchDest - 1; + + iRet = _vsnprintf(pszDest, cchMax, pszFormat, argList); + // ASSERT((iRet < 0) || (((size_t)iRet) <= cchMax)); + + if ((iRet < 0) || (((size_t)iRet) > cchMax)) + { + // we have truncated pszDest + pszDestEnd = pszDest + cchMax; + cchRemaining = 1; + + // need to null terminate the string + *pszDestEnd = '\0'; + + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + else if (((size_t)iRet) == cchMax) + { + // string fit perfectly + pszDestEnd = pszDest + cchMax; + cchRemaining = 1; + + // need to null terminate the string + *pszDestEnd = '\0'; + } + else if (((size_t)iRet) < cchMax) + { + // there is extra room + pszDestEnd = pszDest + iRet; + cchRemaining = cchDest - iRet; + + if (dwFlags & STRSAFE_FILL_BEHIND_NULL) + { + memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(char)) + (cbDest % sizeof(char))); + } + } + } + } + } + + if (FAILED(hr)) + { + if (pszDest) + { + if (dwFlags & STRSAFE_FILL_ON_FAILURE) + { + memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); + + if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + } + else if (cchDest > 0) + { + pszDestEnd = pszDest + cchDest - 1; + cchRemaining = 1; + + // null terminate the end of the string + *pszDestEnd = '\0'; + } + } + + if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) + { + if (cchDest > 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + // null terminate the beginning of the string + *pszDestEnd = '\0'; + } + } + } + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (ppszDestEnd) + { + *ppszDestEnd = pszDestEnd; + } + + if (pcchRemaining) + { + *pcchRemaining = cchRemaining; + } + } + + return hr; +} + +STRSAFEAPI StringVPrintfExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const wchar_t* pszFormat, va_list argList) +{ + HRESULT hr = S_OK; + wchar_t* pszDestEnd = pszDest; + size_t cchRemaining = 0; + + // ASSERT(cbDest == (cchDest * sizeof(wchar_t)) || + // cbDest == (cchDest * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); + + // only accept valid flags + if (dwFlags & (~STRSAFE_VALID_FLAGS)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + if (dwFlags & STRSAFE_IGNORE_NULLS) + { + if (pszDest == NULL) + { + if ((cchDest != 0) || (cbDest != 0)) + { + // NULL pszDest and non-zero cchDest/cbDest is invalid + hr = STRSAFE_E_INVALID_PARAMETER; + } + } + + if (pszFormat == NULL) + { + pszFormat = L""; + } + } + + if (SUCCEEDED(hr)) + { + if (cchDest == 0) + { + pszDestEnd = pszDest; + cchRemaining = 0; + + // only fail if there was actually a non-empty format string + if (*pszFormat != L'\0') + { + if (pszDest == NULL) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + } + } + else + { + int iRet; + size_t cchMax; + + // leave the last space for the null terminator + cchMax = cchDest - 1; + + iRet = _vsnwprintf(pszDest, cchMax, pszFormat, argList); + // ASSERT((iRet < 0) || (((size_t)iRet) <= cchMax)); + + if ((iRet < 0) || (((size_t)iRet) > cchMax)) + { + // we have truncated pszDest + pszDestEnd = pszDest + cchMax; + cchRemaining = 1; + + // need to null terminate the string + *pszDestEnd = L'\0'; + + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + else if (((size_t)iRet) == cchMax) + { + // string fit perfectly + pszDestEnd = pszDest + cchMax; + cchRemaining = 1; + + // need to null terminate the string + *pszDestEnd = L'\0'; + } + else if (((size_t)iRet) < cchMax) + { + // there is extra room + pszDestEnd = pszDest + iRet; + cchRemaining = cchDest - iRet; + + if (dwFlags & STRSAFE_FILL_BEHIND_NULL) + { + memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); + } + } + } + } + } + + if (FAILED(hr)) + { + if (pszDest) + { + if (dwFlags & STRSAFE_FILL_ON_FAILURE) + { + memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); + + if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + } + else if (cchDest > 0) + { + pszDestEnd = pszDest + cchDest - 1; + cchRemaining = 1; + + // null terminate the end of the string + *pszDestEnd = L'\0'; + } + } + + if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) + { + if (cchDest > 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + // null terminate the beginning of the string + *pszDestEnd = L'\0'; + } + } + } + } + + if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER)) + { + if (ppszDestEnd) + { + *ppszDestEnd = pszDestEnd; + } + + if (pcchRemaining) + { + *pcchRemaining = cchRemaining; + } + } + + return hr; +} + +STRSAFEAPI StringLengthWorkerA(const char* psz, size_t cchMax, size_t* pcch) +{ + HRESULT hr = S_OK; + size_t cchMaxPrev = cchMax; + + while (cchMax && (*psz != '\0')) + { + psz++; + cchMax--; + } + + if (cchMax == 0) + { + // the string is longer than cchMax + hr = STRSAFE_E_INVALID_PARAMETER; + } + + if (SUCCEEDED(hr) && pcch) + { + *pcch = cchMaxPrev - cchMax; + } + + return hr; +} + +STRSAFEAPI StringLengthWorkerW(const wchar_t* psz, size_t cchMax, size_t* pcch) +{ + HRESULT hr = S_OK; + size_t cchMaxPrev = cchMax; + + while (cchMax && (*psz != L'\0')) + { + psz++; + cchMax--; + } + + if (cchMax == 0) + { + // the string is longer than cchMax + hr = STRSAFE_E_INVALID_PARAMETER; + } + + if (SUCCEEDED(hr) && pcch) + { + *pcch = cchMaxPrev - cchMax; + } + + return hr; +} +#endif // STRSAFE_INLINE + +#ifndef STRSAFE_LIB_IMPL +STRSAFE_INLINE_API StringGetsExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr = S_OK; + char* pszDestEnd = pszDest; + size_t cchRemaining = 0; + + // ASSERT(cbDest == (cchDest * sizeof(char)) || + // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char))); + + // only accept valid flags + if (dwFlags & (~STRSAFE_VALID_FLAGS)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + if (dwFlags & STRSAFE_IGNORE_NULLS) + { + if (pszDest == NULL) + { + if ((cchDest != 0) || (cbDest != 0)) + { + // NULL pszDest and non-zero cchDest/cbDest is invalid + hr = STRSAFE_E_INVALID_PARAMETER; + } + } + } + + if (SUCCEEDED(hr)) + { + if (cchDest <= 1) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + if (cchDest == 1) + { + *pszDestEnd = '\0'; + } + + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + else + { + char ch; + + pszDestEnd = pszDest; + cchRemaining = cchDest; + + while ((cchRemaining > 1) && (ch = (char)getc(stdin)) != '\n') + { + if (ch == EOF) + { + if (pszDestEnd == pszDest) + { + // we failed to read anything from stdin + hr = STRSAFE_E_END_OF_FILE; + } + break; + } + + *pszDestEnd = ch; + + pszDestEnd++; + cchRemaining--; + } + + if (cchRemaining > 0) + { + // there is extra room + if (dwFlags & STRSAFE_FILL_BEHIND_NULL) + { + memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(char)) + (cbDest % sizeof(char))); + } + } + + *pszDestEnd = '\0'; + } + } + } + + if (FAILED(hr)) + { + if (pszDest) + { + if (dwFlags & STRSAFE_FILL_ON_FAILURE) + { + memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); + + if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + } + else if (cchDest > 0) + { + pszDestEnd = pszDest + cchDest - 1; + cchRemaining = 1; + + // null terminate the end of the string + *pszDestEnd = '\0'; + } + } + + if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) + { + if (cchDest > 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + // null terminate the beginning of the string + *pszDestEnd = '\0'; + } + } + } + } + + if (SUCCEEDED(hr) || + (hr == STRSAFE_E_INSUFFICIENT_BUFFER) || + (hr == STRSAFE_E_END_OF_FILE)) + { + if (ppszDestEnd) + { + *ppszDestEnd = pszDestEnd; + } + + if (pcchRemaining) + { + *pcchRemaining = cchRemaining; + } + } + + return hr; +} + +STRSAFE_INLINE_API StringGetsExWorkerW(wchar_t* pszDest, size_t cchDest, size_t cbDest, wchar_t** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags) +{ + HRESULT hr = S_OK; + wchar_t* pszDestEnd = pszDest; + size_t cchRemaining = 0; + + // ASSERT(cbDest == (cchDest * sizeof(char)) || + // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char))); + + // only accept valid flags + if (dwFlags & (~STRSAFE_VALID_FLAGS)) + { + hr = STRSAFE_E_INVALID_PARAMETER; + } + else + { + if (dwFlags & STRSAFE_IGNORE_NULLS) + { + if (pszDest == NULL) + { + if ((cchDest != 0) || (cbDest != 0)) + { + // NULL pszDest and non-zero cchDest/cbDest is invalid + hr = STRSAFE_E_INVALID_PARAMETER; + } + } + } + + if (SUCCEEDED(hr)) + { + if (cchDest <= 1) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + if (cchDest == 1) + { + *pszDestEnd = L'\0'; + } + + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + else + { + wchar_t ch; + + pszDestEnd = pszDest; + cchRemaining = cchDest; + + while ((cchRemaining > 1) && (ch = (wchar_t)getwc(stdin)) != L'\n') + { + if (ch == EOF) + { + if (pszDestEnd == pszDest) + { + // we failed to read anything from stdin + hr = STRSAFE_E_END_OF_FILE; + } + break; + } + + *pszDestEnd = ch; + + pszDestEnd++; + cchRemaining--; + } + + if (cchRemaining > 0) + { + // there is extra room + if (dwFlags & STRSAFE_FILL_BEHIND_NULL) + { + memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(wchar_t)) + (cbDest % sizeof(wchar_t))); + } + } + + *pszDestEnd = L'\0'; + } + } + } + + if (FAILED(hr)) + { + if (pszDest) + { + if (dwFlags & STRSAFE_FILL_ON_FAILURE) + { + memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest); + + if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + } + else if (cchDest > 0) + { + pszDestEnd = pszDest + cchDest - 1; + cchRemaining = 1; + + // null terminate the end of the string + *pszDestEnd = L'\0'; + } + } + + if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) + { + if (cchDest > 0) + { + pszDestEnd = pszDest; + cchRemaining = cchDest; + + // null terminate the beginning of the string + *pszDestEnd = L'\0'; + } + } + } + } + + if (SUCCEEDED(hr) || + (hr == STRSAFE_E_INSUFFICIENT_BUFFER) || + (hr == STRSAFE_E_END_OF_FILE)) + { + if (ppszDestEnd) + { + *ppszDestEnd = pszDestEnd; + } + + if (pcchRemaining) + { + *pcchRemaining = cchRemaining; + } + } + + return hr; +} +#endif // !STRSAFE_LIB_IMPL + + +// Do not call these functions, they are worker functions for internal use within this file +#ifdef DEPRECATE_SUPPORTED +#pragma deprecated(StringCopyWorkerA) +#pragma deprecated(StringCopyWorkerW) +#pragma deprecated(StringCopyExWorkerA) +#pragma deprecated(StringCopyExWorkerW) +#pragma deprecated(StringCatWorkerA) +#pragma deprecated(StringCatWorkerW) +#pragma deprecated(StringCatExWorkerA) +#pragma deprecated(StringCatExWorkerW) +#pragma deprecated(StringCatNWorkerA) +#pragma deprecated(StringCatNWorkerW) +#pragma deprecated(StringCatNExWorkerA) +#pragma deprecated(StringCatNExWorkerW) +#pragma deprecated(StringVPrintfWorkerA) +#pragma deprecated(StringVPrintfWorkerW) +#pragma deprecated(StringVPrintfExWorkerA) +#pragma deprecated(StringVPrintfExWorkerW) +#pragma deprecated(StringLengthWorkerA) +#pragma deprecated(StringLengthWorkerW) +#else +#define StringCopyWorkerA StringCopyWorkerA_instead_use_StringCchCopyA_or_StringCchCopyExA; +#define StringCopyWorkerW StringCopyWorkerW_instead_use_StringCchCopyW_or_StringCchCopyExW; +#define StringCopyExWorkerA StringCopyExWorkerA_instead_use_StringCchCopyA_or_StringCchCopyExA; +#define StringCopyExWorkerW StringCopyExWorkerW_instead_use_StringCchCopyW_or_StringCchCopyExW; +#define StringCatWorkerA StringCatWorkerA_instead_use_StringCchCatA_or_StringCchCatExA; +#define StringCatWorkerW StringCatWorkerW_instead_use_StringCchCatW_or_StringCchCatExW; +#define StringCatExWorkerA StringCatExWorkerA_instead_use_StringCchCatA_or_StringCchCatExA; +#define StringCatExWorkerW StringCatExWorkerW_instead_use_StringCchCatW_or_StringCchCatExW; +#define StringCatNWorkerA StringCatNWorkerA_instead_use_StringCchCatNA_or_StrincCbCatNA; +#define StringCatNWorkerW StringCatNWorkerW_instead_use_StringCchCatNW_or_StringCbCatNW; +#define StringCatNExWorkerA StringCatNExWorkerA_instead_use_StringCchCatNExA_or_StringCbCatNExA; +#define StringCatNExWorkerW StringCatNExWorkerW_instead_use_StringCchCatNExW_or_StringCbCatNExW; +#define StringVPrintfWorkerA StringVPrintfWorkerA_instead_use_StringCchVPrintfA_or_StringCchVPrintfExA; +#define StringVPrintfWorkerW StringVPrintfWorkerW_instead_use_StringCchVPrintfW_or_StringCchVPrintfExW; +#define StringVPrintfExWorkerA StringVPrintfExWorkerA_instead_use_StringCchVPrintfA_or_StringCchVPrintfExA; +#define StringVPrintfExWorkerW StringVPrintfExWorkerW_instead_use_StringCchVPrintfW_or_StringCchVPrintfExW; +#define StringLengthWorkerA StringLengthWorkerA_instead_use_StringCchLengthA_or_StringCbLengthA; +#define StringLengthWorkerW StringLengthWorkerW_instead_use_StringCchLengthW_or_StringCbLengthW; +#endif // !DEPRECATE_SUPPORTED + + +#ifndef STRSAFE_NO_DEPRECATE +// Deprecate all of the unsafe functions to generate compiletime errors. If you do not want +// this then you can #define STRSAFE_NO_DEPRECATE before including this file. +#ifdef DEPRECATE_SUPPORTED + +// First all the names that are a/w variants (or shouldn't be #defined by now anyway). +#pragma deprecated(lstrcpyA) +#pragma deprecated(lstrcpyW) +#pragma deprecated(lstrcatA) +#pragma deprecated(lstrcatW) +#pragma deprecated(wsprintfA) +#pragma deprecated(wsprintfW) + +#pragma deprecated(StrCpyW) +#pragma deprecated(StrCatW) +#pragma deprecated(StrNCatA) +#pragma deprecated(StrNCatW) +#pragma deprecated(StrCatNA) +#pragma deprecated(StrCatNW) +#pragma deprecated(wvsprintfA) +#pragma deprecated(wvsprintfW) + +#pragma deprecated(strcpy) +#pragma deprecated(wcscpy) +#pragma deprecated(strcat) +#pragma deprecated(wcscat) +#pragma deprecated(sprintf) +#pragma deprecated(swprintf) +#pragma deprecated(vsprintf) +#pragma deprecated(vswprintf) +#pragma deprecated(_snprintf) +#pragma deprecated(_snwprintf) +#pragma deprecated(_vsnprintf) +#pragma deprecated(_vsnwprintf) +#pragma deprecated(gets) +#pragma deprecated(_getws) + +// Then all the windows.h names - we need to undef and redef based on UNICODE setting +#undef lstrcpy +#undef lstrcat +#undef wsprintf +#undef wvsprintf +#pragma deprecated(lstrcpy) +#pragma deprecated(lstrcat) +#pragma deprecated(wsprintf) +#pragma deprecated(wvsprintf) +#ifdef UNICODE +#define lstrcpy lstrcpyW +#define lstrcat lstrcatW +#define wsprintf wsprintfW +#define wvsprintf wvsprintfW +#else +#define lstrcpy lstrcpyA +#define lstrcat lstrcatA +#define wsprintf wsprintfA +#define wvsprintf wvsprintfA +#endif + +// Then the shlwapi names - they key off UNICODE also. +#undef StrCpyA +#undef StrCpy +#undef StrCatA +#undef StrCat +#undef StrNCat +#undef StrCatN +#pragma deprecated(StrCpyA) +#pragma deprecated(StrCatA) +#pragma deprecated(StrCatN) +#pragma deprecated(StrCpy) +#pragma deprecated(StrCat) +#pragma deprecated(StrNCat) +#define StrCpyA lstrcpyA +#define StrCatA lstrcatA +#define StrCatN StrNCat +#ifdef UNICODE +#define StrCpy StrCpyW +#define StrCat StrCatW +#define StrNCat StrNCatW +#else +#define StrCpy lstrcpyA +#define StrCat lstrcatA +#define StrNCat StrNCatA +#endif + +// Then all the CRT names - we need to undef/redef based on _UNICODE value. +#undef _tcscpy +#undef _ftcscpy +#undef _tcscat +#undef _ftcscat +#undef _stprintf +#undef _sntprintf +#undef _vstprintf +#undef _vsntprintf +#undef _getts +#pragma deprecated(_tcscpy) +#pragma deprecated(_ftcscpy) +#pragma deprecated(_tcscat) +#pragma deprecated(_ftcscat) +#pragma deprecated(_stprintf) +#pragma deprecated(_sntprintf) +#pragma deprecated(_vstprintf) +#pragma deprecated(_vsntprintf) +#pragma deprecated(_getts) +#ifdef _UNICODE +#define _tcscpy wcscpy +#define _ftcscpy wcscpy +#define _tcscat wcscat +#define _ftcscat wcscat +#define _stprintf swprintf +#define _sntprintf _snwprintf +#define _vstprintf vswprintf +#define _vsntprintf _vsnwprintf +#define _getts _getws +#else +#define _tcscpy strcpy +#define _ftcscpy strcpy +#define _tcscat strcat +#define _ftcscat strcat +#define _stprintf sprintf +#define _sntprintf _snprintf +#define _vstprintf vsprintf +#define _vsntprintf _vsnprintf +#define _getts gets +#endif + +#else // DEPRECATE_SUPPORTED + +#undef strcpy +#define strcpy strcpy_instead_use_StringCbCopyA_or_StringCchCopyA; + +#undef wcscpy +#define wcscpy wcscpy_instead_use_StringCbCopyW_or_StringCchCopyW; + +#undef strcat +#define strcat strcat_instead_use_StringCbCatA_or_StringCchCatA; + +#undef wcscat +#define wcscat wcscat_instead_use_StringCbCatW_or_StringCchCatW; + +#undef sprintf +#define sprintf sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA; + +#undef swprintf +#define swprintf swprintf_instead_use_StringCbPrintfW_or_StringCchPrintfW; + +#undef vsprintf +#define vsprintf vsprintf_instead_use_StringCbVPrintfA_or_StringCchVPrintfA; + +#undef vswprintf +#define vswprintf vswprintf_instead_use_StringCbVPrintfW_or_StringCchVPrintfW; + +#undef _snprintf +#define _snprintf _snprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA; + +#undef _snwprintf +#define _snwprintf _snwprintf_instead_use_StringCbPrintfW_or_StringCchPrintfW; + +#undef _vsnprintf +#define _vsnprintf _vsnprintf_instead_use_StringCbVPrintfA_or_StringCchVPrintfA; + +#undef _vsnwprintf +#define _vsnwprintf _vsnwprintf_instead_use_StringCbVPrintfW_or_StringCchVPrintfW; + +#undef strcpyA +#define strcpyA strcpyA_instead_use_StringCbCopyA_or_StringCchCopyA; + +#undef strcpyW +#define strcpyW strcpyW_instead_use_StringCbCopyW_or_StringCchCopyW; + +#undef lstrcpy +#define lstrcpy lstrcpy_instead_use_StringCbCopy_or_StringCchCopy; + +#undef lstrcpyA +#define lstrcpyA lstrcpyA_instead_use_StringCbCopyA_or_StringCchCopyA; + +#undef lstrcpyW +#define lstrcpyW lstrcpyW_instead_use_StringCbCopyW_or_StringCchCopyW; + +#undef StrCpy +#define StrCpy StrCpy_instead_use_StringCbCopy_or_StringCchCopy; + +#undef StrCpyA +#define StrCpyA StrCpyA_instead_use_StringCbCopyA_or_StringCchCopyA; + +#undef StrCpyW +#define StrCpyW StrCpyW_instead_use_StringCbCopyW_or_StringCchCopyW; + +#undef _tcscpy +#define _tcscpy _tcscpy_instead_use_StringCbCopy_or_StringCchCopy; + +#undef _ftcscpy +#define _ftcscpy _ftcscpy_instead_use_StringCbCopy_or_StringCchCopy; + +#undef lstrcat +#define lstrcat lstrcat_instead_use_StringCbCat_or_StringCchCat; + +#undef lstrcatA +#define lstrcatA lstrcatA_instead_use_StringCbCatA_or_StringCchCatA; + +#undef lstrcatW +#define lstrcatW lstrcatW_instead_use_StringCbCatW_or_StringCchCatW; + +#undef StrCat +#define StrCat StrCat_instead_use_StringCbCat_or_StringCchCat; + +#undef StrCatA +#define StrCatA StrCatA_instead_use_StringCbCatA_or_StringCchCatA; + +#undef StrCatW +#define StrCatW StrCatW_instead_use_StringCbCatW_or_StringCchCatW; + +#undef StrNCat +#define StrNCat StrNCat_instead_use_StringCbCatN_or_StringCchCatN; + +#undef StrNCatA +#define StrNCatA StrNCatA_instead_use_StringCbCatNA_or_StringCchCatNA; + +#undef StrNCatW +#define StrNCatW StrNCatW_instead_use_StringCbCatNW_or_StringCchCatNW; + +#undef StrCatN +#define StrCatN StrCatN_instead_use_StringCbCatN_or_StringCchCatN; + +#undef StrCatNA +#define StrCatNA StrCatNA_instead_use_StringCbCatNA_or_StringCchCatNA; + +#undef StrCatNW +#define StrCatNW StrCatNW_instead_use_StringCbCatNW_or_StringCchCatNW; + +#undef _tcscat +#define _tcscat _tcscat_instead_use_StringCbCat_or_StringCchCat; + +#undef _ftcscat +#define _ftcscat _ftcscat_instead_use_StringCbCat_or_StringCchCat; + +#undef wsprintf +#define wsprintf wsprintf_instead_use_StringCbPrintf_or_StringCchPrintf; + +#undef wsprintfA +#define wsprintfA wsprintfA_instead_use_StringCbPrintfA_or_StringCchPrintfA; + +#undef wsprintfW +#define wsprintfW wsprintfW_instead_use_StringCbPrintfW_or_StringCchPrintfW; + +#undef wvsprintf +#define wvsprintf wvsprintf_instead_use_StringCbVPrintf_or_StringCchVPrintf; + +#undef wvsprintfA +#define wvsprintfA wvsprintfA_instead_use_StringCbVPrintfA_or_StringCchVPrintfA; + +#undef wvsprintfW +#define wvsprintfW wvsprintfW_instead_use_StringCbVPrintfW_or_StringCchVPrintfW; + +#undef _vstprintf +#define _vstprintf _vstprintf_instead_use_StringCbVPrintf_or_StringCchVPrintf; + +#undef _vsntprintf +#define _vsntprintf _vsntprintf_instead_use_StringCbVPrintf_or_StringCchVPrintf; + +#undef _stprintf +#define _stprintf _stprintf_instead_use_StringCbPrintf_or_StringCchPrintf; + +#undef _sntprintf +#define _sntprintf _sntprintf_instead_use_StringCbPrintf_or_StringCchPrintf; + +#undef _getts +#define _getts _getts_instead_use_StringCbGets_or_StringCchGets; + +#undef gets +#define gets _gets_instead_use_StringCbGetsA_or_StringCchGetsA; + +#undef _getws +#define _getws _getws_instead_use_StringCbGetsW_or_StringCchGetsW; + +#endif // !DEPRECATE_SUPPORTED +#endif // !STRSAFE_NO_DEPRECATE + +#ifdef _NTSTRSAFE_H_INCLUDED_ +#pragma warning(pop) +#endif // _NTSTRSAFE_H_INCLUDED_ + +#endif // _STRSAFE_H_INCLUDED_ diff --git a/src/dep/include/DXSDK/include/xact.h b/src/dep/include/DXSDK/include/xact.h index b275263..abd09fa 100644 --- a/src/dep/include/DXSDK/include/xact.h +++ b/src/dep/include/DXSDK/include/xact.h @@ -1,1156 +1,1156 @@ -/*++ - -Copyright (C) Microsoft Corporation. All rights reserved. - -Module Name: - - xact.h - -Abstract: - - XACT public interfaces, functions and data types - ---*/ - -#pragma once - -#ifndef _XACT_H_ -#define _XACT_H_ - -//------------------------------------------------------------------------------ -// XACT class and interface IDs -//------------------------------------------------------------------------------ -#ifndef _XBOX // XACT COM support only exists on Windows - #include // For DEFINE_CLSID, DEFINE_IID and DECLARE_INTERFACE - DEFINE_CLSID(XACTEngine, 1f1b577e, 5e5a, 4e8a, ba, 73, c6, 57, ea, 8e, 85, 98); - DEFINE_CLSID(XACTAuditionEngine, fcecc8be, b09a, 48cb, 92, 08, 95, a7, ed, 45, 82, a6); - DEFINE_CLSID(XACTDebugEngine, 2b4a46bb, ae7a, 4072, ae, 18, 11, 28, 15, 4f, ba, 97); - DEFINE_IID(IXACTEngine, 7cdd1894, 643b, 4168, 83, 6f, d1, 9d, 59, d0, ce, 53); -#endif - -// Ignore the rest of this header if only the GUID definitions were requested: -#ifndef GUID_DEFS_ONLY - -//------------------------------------------------------------------------------ -// Includes -//------------------------------------------------------------------------------ - -#ifndef _XBOX - #include - #include - #include -#else - #include -#endif - -//------------------------------------------------------------------------------ -// Forward Declarations -//------------------------------------------------------------------------------ - -typedef struct IXACTSoundBank IXACTSoundBank; -typedef struct IXACTWaveBank IXACTWaveBank; -typedef struct IXACTCue IXACTCue; -typedef struct IXACTEngine IXACTEngine; -typedef struct XACT_NOTIFICATION XACT_NOTIFICATION; - - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -typedef WORD XACTINDEX; // All normal indices -typedef BYTE XACTNOTIFICATIONTYPE; // Notification type -typedef FLOAT XACTVARIABLEVALUE; // Variable value -typedef WORD XACTVARIABLEINDEX; // Variable index -typedef WORD XACTCATEGORY; // Sound category -typedef BYTE XACTCHANNEL; // Audio channel -typedef FLOAT XACTVOLUME; // Volume value -typedef LONG XACTTIME; // Time (in ms) - -//------------------------------------------------------------------------------ -// Constants -//------------------------------------------------------------------------------ - -static const XACTINDEX XACTINDEX_MIN = 0x0; -static const XACTINDEX XACTINDEX_MAX = 0xfffe; -static const XACTINDEX XACTINDEX_INVALID = 0xffff; - -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_MIN = 0x00; -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_MAX = 0xff; - -static const XACTVARIABLEVALUE XACTVARIABLEVALUE_MIN = -FLT_MAX; -static const XACTVARIABLEVALUE XACTVARIABLEVALUE_MAX = FLT_MAX; - -static const XACTVARIABLEINDEX XACTVARIABLEINDEX_MIN = 0x0000; -static const XACTVARIABLEINDEX XACTVARIABLEINDEX_MAX = 0xfffe; -static const XACTVARIABLEINDEX XACTVARIABLEINDEX_INVALID = 0xffff; - -static const XACTCATEGORY XACTCATEGORY_MIN = 0x0; -static const XACTCATEGORY XACTCATEGORY_MAX = 0xfffe; -static const XACTCATEGORY XACTCATEGORY_INVALID = 0xffff; - -static const XACTCHANNEL XACTCHANNEL_MIN = 0; -static const XACTCHANNEL XACTCHANNEL_MAX = 0xFF; - -static const XACTVOLUME XACTVOLUME_MIN = 0.0f; -static const XACTVOLUME XACTVOLUME_MAX = FLT_MAX; - -static const XACTVARIABLEVALUE XACTPARAMETERVALUE_MIN = -FLT_MAX; -static const XACTVARIABLEVALUE XACTPARAMETERVALUE_MAX = FLT_MAX; - -#ifdef _XBOX -static const XAUDIOVOICEINDEX XACTMAXOUTPUTVOICECOUNT = 3; -#endif // _XBOX - -#define XACT_CONTENT_VERSION 38 - -//------------------------------------------------------------------------------ -// XACT Parameters -//------------------------------------------------------------------------------ - -static const DWORD XACT_FLAG_GLOBAL_SETTINGS_MANAGEDATA = 0x00000001; - -typedef BOOL (__stdcall * XACT_READFILE_CALLBACK)(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped); -typedef BOOL (__stdcall * XACT_GETOVERLAPPEDRESULT_CALLBACK)(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait); - -typedef struct XACT_FILEIO_CALLBACKS -{ - XACT_READFILE_CALLBACK readFileCallback; - XACT_GETOVERLAPPEDRESULT_CALLBACK getOverlappedResultCallback; -} XACT_FILEIO_CALLBACKS, *PXACT_FILEIO_CALLBACKS; -typedef const XACT_FILEIO_CALLBACKS *PCXACT_FILEIO_CALLBACKS; - -// The callback that receives the notifications. -typedef void (__stdcall * XACT_NOTIFICATION_CALLBACK)(const XACT_NOTIFICATION* pNotification); - -#ifndef _XBOX - -#define XACT_RENDERER_ID_LENGTH 0xff // Maximum number of characters allowed in the renderer ID -#define XACT_RENDERER_NAME_LENGTH 0xff // Maximum number of characters allowed in the renderer display name. - -// Renderer details -typedef struct XACT_RENDERER_DETAILS -{ - WCHAR rendererID[XACT_RENDERER_ID_LENGTH]; // The string ID for the rendering device. - WCHAR displayName[XACT_RENDERER_NAME_LENGTH]; // A friendly name suitable for display to a human. - BOOL defaultDevice; // Set to TRUE if this device is the primary audio device on the system. -} XACT_RENDERER_DETAILS, *LPXACT_RENDERER_DETAILS; -#endif - -// Runtime (engine) parameters -typedef struct XACT_RUNTIME_PARAMETERS -{ - DWORD lookAheadTime; // Time in ms - void* pGlobalSettingsBuffer; // Buffer containing the global settings file - DWORD globalSettingsBufferSize; // Size of global settings buffer - DWORD globalSettingsFlags; // Flags for global settings - DWORD globalSettingsAllocAttributes; // Global settings buffer allocation attributes (see XMemAlloc) - XACT_FILEIO_CALLBACKS fileIOCallbacks; // File I/O callbacks - XACT_NOTIFICATION_CALLBACK fnNotificationCallback; // Callback that receives notifications. -#ifndef _XBOX - PWSTR pRendererID; // Ptr to the ID for the audio renderer the engine should connect to. -#endif -} XACT_RUNTIME_PARAMETERS, *LPXACT_RUNTIME_PARAMETERS; -typedef const XACT_RUNTIME_PARAMETERS *LPCXACT_RUNTIME_PARAMETERS; - -//------------------------------------------------------------------------------ -// Streaming Parameters -//------------------------------------------------------------------------------ - -typedef struct XACT_WAVEBANK_STREAMING_PARAMETERS -{ - HANDLE file; // File handle associated with wavebank data - DWORD offset; // Offset within file of wavebank header (must be sector aligned) - DWORD flags; // Flags (none currently) - WORD packetSize; // Stream packet size (in sectors) to use for each stream (min = 2) - // number of sectors (DVD = 2048 bytes: 2 = 4096, 3 = 6144, 4 = 8192 etc.) - // optimal DVD size is a multiple of 16 (DVD block = 16 DVD sectors) -} XACT_WAVEBANK_STREAMING_PARAMETERS, *LPXACT_WAVEBANK_STREAMING_PARAMETERS; -typedef const XACT_WAVEBANK_STREAMING_PARAMETERS *LPCXACT_WAVEBANK_STREAMING_PARAMETERS; - -//------------------------------------------------------------------------------ -// Cue Properties (Xbox Only) -//------------------------------------------------------------------------------ -#ifdef _XBOX -typedef struct XACTCUEPROPERTIES -{ - XACTCATEGORY ActiveSoundCategory; // Category of the active sound - BYTE ActiveSoundTrackCount; // The number of tracks in the active sound - BYTE ActiveSoundPriority; // The priority of the active sound - XACTINDEX FirstTrackWaveIndex; // Index of the currently selected wave variation in the first track - DWORD FirstTrackWaveDuration; // Estimated duration (ms) of the selected wave in the first track (does not account for pitch changes) - XACTCHANNEL MaxTrackChannelCount; // The highest number of channels in any track - BYTE MaxTrackLoopCount; // The highest loop count of any track (255 is infinite) -} XACTCUEPROPERTIES, *LPXACTCUEPROPERTIES; -#endif // _XBOX - -//------------------------------------------------------------------------------ -// Channel Mapping / Speaker Panning -//------------------------------------------------------------------------------ - -typedef struct XACTCHANNELMAPENTRY -{ - XACTCHANNEL InputChannel; - XACTCHANNEL OutputChannel; - XACTVOLUME Volume; -} XACTCHANNELMAPENTRY, *LPXACTCHANNELMAPENTRY; -typedef const XACTCHANNELMAPENTRY *LPCXACTCHANNELMAPENTRY; - -typedef struct XACTCHANNELMAP -{ - XACTCHANNEL EntryCount; - XACTCHANNELMAPENTRY* paEntries; -} XACTCHANNELMAP, *LPXACTCHANNELMAP; -typedef const XACTCHANNELMAP *LPCXACTCHANNELMAP; - -typedef struct XACTCHANNELVOLUMEENTRY -{ - XACTCHANNEL EntryIndex; - XACTVOLUME Volume; -} XACTCHANNELVOLUMEENTRY, *LPXACTCHANNELVOLUMEENTRY; -typedef const XACTCHANNELVOLUMEENTRY *LPCXACTCHANNELVOLUMEENTRY; - -typedef struct XACTCHANNELVOLUME -{ - XACTCHANNEL EntryCount; - XACTCHANNELVOLUMEENTRY* paEntries; -} XACTCHANNELVOLUME, *LPXACTCHANNELVOLUME; -typedef const XACTCHANNELVOLUME *LPCXACTCHANNELVOLUME; - -//------------------------------------------------------------------------------ -// Notifications -//------------------------------------------------------------------------------ - -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_CUEPREPARED = 1; // None, SoundBank, SoundBank & cue index, cue instance -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_CUEPLAY = 2; // None, SoundBank, SoundBank & cue index, cue instance -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_CUESTOP = 3; // None, SoundBank, SoundBank & cue index, cue instance -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_CUEDESTROYED = 4; // None, SoundBank, SoundBank & cue index, cue instance -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_MARKER = 5; // None, SoundBank, SoundBank & cue index, cue instance -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_SOUNDBANKDESTROYED = 6; // None, SoundBank -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_WAVEBANKDESTROYED = 7; // None, WaveBank -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_LOCALVARIABLECHANGED = 8; // None, SoundBank, SoundBank & cue index, cue instance -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_GLOBALVARIABLECHANGED = 9; // None -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_GUICONNECTED = 10; // None -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_GUIDISCONNECTED = 11; // None -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_WAVEPLAY = 12; // None, SoundBank, SoundBank & cue index, cue instance, WaveBank -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_WAVESTOP = 13; // None, SoundBank, SoundBank & cue index, cue instance, WaveBank -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_WAVEBANKPREPARED = 14; // None, WaveBank -static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_WAVEBANKSTREAMING_INVALIDCONTENT = 15; // None, WaveBank - -static const BYTE XACT_FLAG_NOTIFICATION_PERSIST = 0x01; - -// Pack the notification structures -#pragma pack(push, 1) - -// Notification description used for registering, un-registering and flushing notifications -typedef struct XACT_NOTIFICATION_DESCRIPTION -{ - XACTNOTIFICATIONTYPE type; // Notification type - BYTE flags; // Flags - IXACTSoundBank* pSoundBank; // SoundBank instance - IXACTWaveBank* pWaveBank; // WaveBank instance - IXACTCue* pCue; // Cue instance - XACTINDEX cueIndex; // Cue index - PVOID pvContext; // User context (optional) - -} XACT_NOTIFICATION_DESCRIPTION, *LPXACT_NOTIFICATION_DESCRIPTION; -typedef const XACT_NOTIFICATION_DESCRIPTION *LPCXACT_NOTIFICATION_DESCRIPTION; - -// Notification structure for all XACTNOTIFICATIONTYPE_CUE* notifications -typedef struct XACT_NOTIFICATION_CUE -{ - XACTINDEX cueIndex; // Cue index - IXACTSoundBank* pSoundBank; // SoundBank instance - IXACTCue* pCue; // Cue instance - -} XACT_NOTIFICATION_CUE, *LPXACT_NOTIFICATION_CUE; -typedef const XACT_NOTIFICATION_CUE *LPCXACT_NOTIFICATION_CUE; - -// Notification structure for all XACTNOTIFICATIONTYPE_MARKER* notifications -typedef struct XACT_NOTIFICATION_MARKER -{ - XACTINDEX cueIndex; // Cue index - IXACTSoundBank* pSoundBank; // SoundBank instance - IXACTCue* pCue; // Cue instance - DWORD marker; // Marker value - -} XACT_NOTIFICATION_MARKER, *LPXACT_NOTIFICATION_MARKER; -typedef const XACT_NOTIFICATION_MARKER *LPCXACT_NOTIFICATION_MARKER; - -// Notification structure for all XACTNOTIFICATIONTYPE_SOUNDBANK* notifications -typedef struct XACT_NOTIFICATION_SOUNDBANK -{ - IXACTSoundBank* pSoundBank; // SoundBank instance - -} XACT_NOTIFICATION_SOUNDBANK, *LPXACT_NOTIFICATION_SOUNDBANK; -typedef const XACT_NOTIFICATION_SOUNDBANK *LPCXACT_NOTIFICATION_SOUNDBANK; - -// Notification structure for all XACTNOTIFICATIONTYPE_WAVEBANK* notifications -typedef struct XACT_NOTIFICATION_WAVEBANK -{ - IXACTWaveBank* pWaveBank; // WaveBank instance - -} XACT_NOTIFICATION_WAVEBANK, *LPXACT_NOTIFICATION_WAVEBANK; -typedef const XACT_NOTIFICATION_WAVEBANK *LPCXACT_NOTIFICATION_WAVEBANK; - -// Notification structure for all XACTNOTIFICATIONTYPE_*VARIABLE* notifications -typedef struct XACT_NOTIFICATION_VARIABLE -{ - XACTINDEX cueIndex; // Cue index - IXACTSoundBank* pSoundBank; // SoundBank instance - IXACTCue* pCue; // Cue instance - XACTVARIABLEINDEX variableIndex; // Variable index - XACTVARIABLEVALUE variableValue; // Variable value - BOOL local; // TRUE if a local variable - -} XACT_NOTIFICATION_VARIABLE, *LPXACT_NOTIFICATION_VARIABLE; -typedef const XACT_NOTIFICATION_VARIABLE *LPCXACT_NOTIFICATION_VARIABLE; - -// Notification structure for all XACTNOTIFICATIONTYPE_GUI* notifications -typedef struct XACT_NOTIFICATION_GUI -{ - DWORD reserved; // Reserved -} XACT_NOTIFICATION_GUI, *LPXACT_NOTIFICATION_GUI; -typedef const XACT_NOTIFICATION_GUI *LPCXACT_NOTIFICATION_GUI; - -// Notification structure for all XACTNOTIFICATIONTYPE_WAVE* notifications -typedef struct XACT_NOTIFICATION_WAVE -{ - IXACTWaveBank* pWaveBank; // WaveBank - XACTINDEX waveIndex; // Wave index - XACTINDEX cueIndex; // Cue index - IXACTSoundBank* pSoundBank; // SoundBank instance - IXACTCue* pCue; // Cue instance - -} XACT_NOTIFICATION_WAVE, *LPXACT_NOTIFICATION_WAVE; -typedef const XACT_NOTIFICATION_WAVE *LPCXACT_NOTIFICATION_WAVE; - -// General notification structure -typedef struct XACT_NOTIFICATION -{ - XACTNOTIFICATIONTYPE type; // Notification type - LONG timeStamp; // Timestamp of notification (milliseconds) - PVOID pvContext; // User context (optional) - union - { - XACT_NOTIFICATION_CUE cue; // XACTNOTIFICATIONTYPE_CUE* - XACT_NOTIFICATION_MARKER marker; // XACTNOTIFICATIONTYPE_MARKER* - XACT_NOTIFICATION_SOUNDBANK soundBank; // XACTNOTIFICATIONTYPE_SOUNDBANK* - XACT_NOTIFICATION_WAVEBANK waveBank; // XACTNOTIFICATIONTYPE_WAVEBANK* - XACT_NOTIFICATION_VARIABLE variable; // XACTNOTIFICATIONTYPE_VARIABLE* - XACT_NOTIFICATION_GUI gui; // XACTNOTIFICATIONTYPE_GUI* - XACT_NOTIFICATION_WAVE wave; // XACTNOTIFICATIONTYPE_WAVE* - }; - -} XACT_NOTIFICATION, *LPXACT_NOTIFICATION; -typedef const XACT_NOTIFICATION *LPCXACT_NOTIFICATION; -#pragma pack(pop) - -//------------------------------------------------------------------------------ -// IXACTSoundBank -//------------------------------------------------------------------------------ - -static const DWORD XACT_FLAG_SOUNDBANK_STOP_IMMEDIATE = 0x00000001; - -static const DWORD XACT_SOUNDBANKSTATE_INUSE = 0x00000001; // Currently in-use - -STDAPI IXACTSoundBank_Destroy(IXACTSoundBank* pSoundBank); -STDAPI_(XACTINDEX) IXACTSoundBank_GetCueIndex(IXACTSoundBank* pSoundBank, PCSTR szFriendlyName); -STDAPI IXACTSoundBank_Prepare(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue); -STDAPI IXACTSoundBank_Play(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue); -STDAPI IXACTSoundBank_Stop(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags); -STDAPI IXACTSoundBank_GetState(IXACTSoundBank* pSoundBank, DWORD* pdwState); - -#undef INTERFACE -#define INTERFACE IXACTSoundBank - -DECLARE_INTERFACE(IXACTSoundBank) -{ - STDMETHOD_(XACTINDEX, GetCueIndex)(THIS_ PCSTR szFriendlyName) PURE; - STDMETHOD(Prepare)(THIS_ XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue) PURE; - STDMETHOD(Play)(THIS_ XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue) PURE; - STDMETHOD(Stop)(THIS_ XACTINDEX nCueIndex, DWORD dwFlags) PURE; - STDMETHOD(Destroy)(THIS) PURE; - STDMETHOD(GetState)(THIS_ DWORD* pdwState) PURE; -}; - -#ifdef __cplusplus - -__inline HRESULT __stdcall IXACTSoundBank_Destroy(IXACTSoundBank* pSoundBank) -{ - return pSoundBank->Destroy(); -} - -__inline XACTINDEX __stdcall IXACTSoundBank_GetCueIndex(IXACTSoundBank* pSoundBank, PCSTR szFriendlyName) -{ - return pSoundBank->GetCueIndex(szFriendlyName); -} - -__inline HRESULT __stdcall IXACTSoundBank_Prepare(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue) -{ - return pSoundBank->Prepare(nCueIndex, dwFlags, timeOffset, ppCue); -} - -__inline HRESULT __stdcall IXACTSoundBank_Play(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue) -{ - return pSoundBank->Play(nCueIndex, dwFlags, timeOffset, ppCue); -} - -__inline HRESULT __stdcall IXACTSoundBank_Stop(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags) -{ - return pSoundBank->Stop(nCueIndex, dwFlags); -} - -__inline HRESULT __stdcall IXACTSoundBank_GetState(IXACTSoundBank* pSoundBank, DWORD* pdwState) -{ - return pSoundBank->GetState(pdwState); -} - -#else // __cplusplus - -__inline HRESULT __stdcall IXACTSoundBank_Destroy(IXACTSoundBank* pSoundBank) -{ - return pSoundBank->lpVtbl->Destroy(pSoundBank); -} - -__inline XACTINDEX __stdcall IXACTSoundBank_GetCueIndex(IXACTSoundBank* pSoundBank, PCSTR szFriendlyName) -{ - return pSoundBank->lpVtbl->GetCueIndex(pSoundBank, szFriendlyName); -} - -__inline HRESULT __stdcall IXACTSoundBank_Prepare(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue) -{ - return pSoundBank->lpVtbl->Prepare(pSoundBank, nCueIndex, dwFlags, timeOffset, ppCue); -} - -__inline HRESULT __stdcall IXACTSoundBank_Play(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue) -{ - return pSoundBank->lpVtbl->Play(pSoundBank, nCueIndex, dwFlags, timeOffset, ppCue); -} - -__inline HRESULT __stdcall IXACTSoundBank_Stop(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags) -{ - return pSoundBank->lpVtbl->Stop(pSoundBank, nCueIndex, dwFlags); -} - -__inline HRESULT __stdcall IXACTSoundBank_GetState(IXACTSoundBank* pSoundBank, DWORD* pdwState) -{ - return pSoundBank->lpVtbl->GetState(pSoundBank, pdwState); -} - -#endif // __cplusplus - -//------------------------------------------------------------------------------ -// IXACTWaveBank -//------------------------------------------------------------------------------ - -static const DWORD XACT_WAVEBANKSTATE_INUSE = 0x00000001; // Currently in-use -static const DWORD XACT_WAVEBANKSTATE_PREPARED = 0x00000002; // Prepared -static const DWORD XACT_WAVEBANKSTATE_PREPAREFAILED = 0x00000004; // Prepare failed. - -STDAPI IXACTWaveBank_Destroy(IXACTWaveBank* pWaveBank); -STDAPI IXACTWaveBank_GetState(IXACTWaveBank* pWaveBank, DWORD* pdwState); - -#undef INTERFACE -#define INTERFACE IXACTWaveBank - -DECLARE_INTERFACE(IXACTWaveBank) -{ - STDMETHOD(Destroy)(THIS) PURE; - STDMETHOD(GetState)(THIS_ DWORD* pdwState) PURE; -}; - -#ifdef __cplusplus - -__inline HRESULT __stdcall IXACTWaveBank_Destroy(IXACTWaveBank* pWaveBank) -{ - return pWaveBank->Destroy(); -} - -__inline HRESULT __stdcall IXACTWaveBank_GetState(IXACTWaveBank* pWaveBank, DWORD* pdwState) -{ - return pWaveBank->GetState(pdwState); -} - -#else // __cplusplus - -__inline HRESULT __stdcall IXACTWaveBank_Destroy(IXACTWaveBank* pWaveBank) -{ - return pWaveBank->lpVtbl->Destroy(pWaveBank); -} - -__inline HRESULT __stdcall IXACTWaveBank_GetState(IXACTWaveBank* pWaveBank, DWORD* pdwState) -{ - return pWaveBank->lpVtbl->GetState(pWaveBank, pdwState); -} - -#endif // __cplusplus - -//------------------------------------------------------------------------------ -// IXACTCue -//------------------------------------------------------------------------------ - -// Cue Flags -static const DWORD XACT_FLAG_CUE_STOP_RELEASE = 0x00000000; -static const DWORD XACT_FLAG_CUE_STOP_IMMEDIATE = 0x00000001; - -// Mutually exclusive states -static const DWORD XACT_CUESTATE_CREATED = 0x00000001; // Created, but nothing else -static const DWORD XACT_CUESTATE_PREPARING = 0x00000002; // In the middle of preparing -static const DWORD XACT_CUESTATE_PREPARED = 0x00000004; // Prepared, but not yet played -static const DWORD XACT_CUESTATE_PLAYING = 0x00000008; // Playing (though could be paused) -static const DWORD XACT_CUESTATE_STOPPING = 0x00000010; // Stopping -static const DWORD XACT_CUESTATE_STOPPED = 0x00000020; // Stopped - -// Inclusive states -static const DWORD XACT_CUESTATE_PAUSED = 0x00000040; // Paused (can be combinded with other states) - -STDAPI IXACTCue_Destroy(IXACTCue* pCue); -STDAPI IXACTCue_Play(IXACTCue* pCue); -STDAPI IXACTCue_Stop(IXACTCue* pCue, DWORD dwFlags); -STDAPI IXACTCue_GetState(IXACTCue* pCue, DWORD* pdwState); -STDAPI IXACTCue_GetChannelMap(IXACTCue*, LPXACTCHANNELMAP pChannelMap, DWORD BufferSize, LPDWORD pRequiredSize); -STDAPI IXACTCue_SetChannelMap(IXACTCue*, LPCXACTCHANNELMAP pChannelMap); -STDAPI IXACTCue_GetChannelVolume(IXACTCue*, LPXACTCHANNELVOLUME pVolume); -STDAPI IXACTCue_SetChannelVolume(IXACTCue*, LPCXACTCHANNELVOLUME pVolume); -STDAPI IXACTCue_SetMatrixCoefficients(IXACTCue*, UINT32 uSrcChannelCount, UINT32 uDstChannelCount, float* pMatrixCoefficients); -STDAPI_(XACTVARIABLEINDEX) IXACTCue_GetVariableIndex(IXACTCue* pCue, PCSTR szFriendlyName); -STDAPI IXACTCue_SetVariable(IXACTCue* pCue, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue); -STDAPI IXACTCue_GetVariable(IXACTCue* pCue, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* nValue); -STDAPI IXACTCue_Pause(IXACTCue* pCue, BOOL fPause); -#ifdef _XBOX -STDAPI IXACTCue_SetVoiceOutput(IXACTCue*, LPCXAUDIOVOICEOUTPUT pVoiceOutput); -STDAPI IXACTCue_SetVoiceOutputVolume(IXACTCue*, LPCXAUDIOVOICEOUTPUTVOLUME pVolume); -STDAPI IXACTCue_GetProperties(IXACTCue*, LPXACTCUEPROPERTIES pProperties); -#endif // _XBOX - -#undef INTERFACE -#define INTERFACE IXACTCue - -DECLARE_INTERFACE(IXACTCue) -{ - STDMETHOD(Play)(THIS) PURE; - STDMETHOD(Stop)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(GetState)(THIS_ DWORD* pdwState) PURE; - STDMETHOD(Destroy)(THIS) PURE; - STDMETHOD(GetChannelMap)(THIS_ LPXACTCHANNELMAP pChannelMap, DWORD BufferSize, LPDWORD pRequiredSize) PURE; - STDMETHOD(SetChannelMap)(THIS_ LPCXACTCHANNELMAP pChannelMap) PURE; - STDMETHOD(GetChannelVolume)(THIS_ LPXACTCHANNELVOLUME pVolume) PURE; - STDMETHOD(SetChannelVolume)(THIS_ LPCXACTCHANNELVOLUME pVolume) PURE; - STDMETHOD(SetMatrixCoefficients)(THIS_ UINT32 uSrcChannelCount, UINT32 uDstChannelCount, float* pMatrixCoefficients) PURE; - STDMETHOD_(XACTVARIABLEINDEX, GetVariableIndex)(THIS_ PCSTR szFriendlyName) PURE; - STDMETHOD(SetVariable)(THIS_ XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue) PURE; - STDMETHOD(GetVariable)(THIS_ XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* nValue) PURE; - STDMETHOD(Pause)(THIS_ BOOL fPause) PURE; -#ifdef _XBOX - STDMETHOD(SetVoiceOutput)(THIS_ LPCXAUDIOVOICEOUTPUT pVoiceOutput) PURE; - STDMETHOD(SetVoiceOutputVolume)(THIS_ LPCXAUDIOVOICEOUTPUTVOLUME pVolume) PURE; - STDMETHOD(GetProperties)(THIS_ LPXACTCUEPROPERTIES pProperties) PURE; -#endif // _XBOX -}; - -#ifdef __cplusplus - -__inline HRESULT __stdcall IXACTCue_Play(IXACTCue* pCue) -{ - return pCue->Play(); -} - -__inline HRESULT __stdcall IXACTCue_Stop(IXACTCue* pCue, DWORD dwFlags) -{ - return pCue->Stop(dwFlags); -} - -__inline HRESULT __stdcall IXACTCue_GetState(IXACTCue* pCue, DWORD* pdwState) -{ - return pCue->GetState(pdwState); -} - -__inline HRESULT __stdcall IXACTCue_Destroy(IXACTCue* pCue) -{ - return pCue->Destroy(); -} - -__inline HRESULT __stdcall IXACTCue_GetChannelMap(IXACTCue* pCue, LPXACTCHANNELMAP pChannelMap, DWORD BufferSize, LPDWORD pRequiredSize) -{ - return pCue->GetChannelMap(pChannelMap, BufferSize, pRequiredSize); -} - -__inline HRESULT __stdcall IXACTCue_SetChannelMap(IXACTCue* pCue, LPCXACTCHANNELMAP pChannelMap) -{ - return pCue->SetChannelMap(pChannelMap); -} - -__inline HRESULT __stdcall IXACTCue_GetChannelVolume(IXACTCue* pCue, LPXACTCHANNELVOLUME pVolume) -{ - return pCue->GetChannelVolume(pVolume); -} - -__inline HRESULT __stdcall IXACTCue_SetChannelVolume(IXACTCue* pCue, LPCXACTCHANNELVOLUME pVolume) -{ - return pCue->SetChannelVolume(pVolume); -} - -__inline HRESULT __stdcall IXACTCue_SetMatrixCoefficients(IXACTCue* pCue, UINT32 uSrcChannelCount, UINT32 uDstChannelCount, float* pMatrixCoefficients) -{ - return pCue->SetMatrixCoefficients(uSrcChannelCount, uDstChannelCount, pMatrixCoefficients); -} - -__inline XACTVARIABLEINDEX __stdcall IXACTCue_GetVariableIndex(IXACTCue* pCue, PCSTR szFriendlyName) -{ - return pCue->GetVariableIndex(szFriendlyName); -} - -__inline HRESULT __stdcall IXACTCue_SetVariable(IXACTCue* pCue, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue) -{ - return pCue->SetVariable(nIndex, nValue); -} - -__inline HRESULT __stdcall IXACTCue_GetVariable(IXACTCue* pCue, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* pnValue) -{ - return pCue->GetVariable(nIndex, pnValue); -} - -__inline HRESULT __stdcall IXACTCue_Pause(IXACTCue* pCue, BOOL fPause) -{ - return pCue->Pause(fPause); -} - -#ifdef _XBOX -__inline HRESULT __stdcall IXACTCue_SetVoiceOutput(IXACTCue* pCue, LPCXAUDIOVOICEOUTPUT pVoiceOutput) -{ - return pCue->SetVoiceOutput(pVoiceOutput); -} - -__inline HRESULT __stdcall IXACTCue_SetVoiceOutputVolume(IXACTCue* pCue, LPCXAUDIOVOICEOUTPUTVOLUME pVolume) -{ - return pCue->SetVoiceOutputVolume(pVolume); -} - -__inline HRESULT __stdcall IXACTCue_GetProperties(IXACTCue* pCue, LPXACTCUEPROPERTIES pProperties) -{ - return pCue->GetProperties(pProperties); -} -#endif // _XBOX - -#else // __cplusplus - -__inline HRESULT __stdcall IXACTCue_Play(IXACTCue* pCue) -{ - return pCue->lpVtbl->Play(pCue); -} - -__inline HRESULT __stdcall IXACTCue_Stop(IXACTCue* pCue, DWORD dwFlags) -{ - return pCue->lpVtbl->Stop(pCue, dwFlags); -} - -__inline HRESULT __stdcall IXACTCue_GetState(IXACTCue* pCue, DWORD* pdwState) -{ - return pCue->lpVtbl->GetState(pCue, pdwState); -} - -__inline HRESULT __stdcall IXACTCue_Destroy(IXACTCue* pCue) -{ - return pCue->lpVtbl->Destroy(pCue); -} - -__inline HRESULT __stdcall IXACTCue_GetChannelMap(IXACTCue* pCue, LPXACTCHANNELMAP pChannelMap, DWORD BufferSize, LPDWORD pRequiredSize) -{ - return pCue->lpVtbl->GetChannelMap(pCue, pChannelMap, BufferSize, pRequiredSize); -} - -__inline HRESULT __stdcall IXACTCue_SetChannelMap(IXACTCue* pCue, LPCXACTCHANNELMAP pChannelMap) -{ - return pCue->lpVtbl->SetChannelMap(pCue, pChannelMap); -} - -__inline HRESULT __stdcall IXACTCue_GetChannelVolume(IXACTCue* pCue, LPXACTCHANNELVOLUME pVolume) -{ - return pCue->lpVtbl->GetChannelVolume(pCue, pVolume); -} - -__inline HRESULT __stdcall IXACTCue_SetChannelVolume(IXACTCue* pCue, LPCXACTCHANNELVOLUME pVolume) -{ - return pCue->lpVtbl->SetChannelVolume(pCue, pVolume); -} - -__inline HRESULT __stdcall IXACTCue_SetMatrixCoefficients(IXACTCue* pCue, UINT32 uSrcChannelCount, UINT32 uDstChannelCount, float* pMatrixCoefficients) -{ - return pCue->lpVtbl->SetMatrixCoefficients(pCue, uSrcChannelCount, uDstChannelCount, pMatrixCoefficients); -} - -__inline XACTVARIABLEINDEX __stdcall IXACTCue_GetVariableIndex(IXACTCue* pCue, PCSTR szFriendlyName) -{ - return pCue->lpVtbl->GetVariableIndex(pCue, szFriendlyName); -} - -__inline HRESULT __stdcall IXACTCue_SetVariable(IXACTCue* pCue, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue) -{ - return pCue->lpVtbl->SetVariable(pCue, nIndex, nValue); -} - -__inline HRESULT __stdcall IXACTCue_GetVariable(IXACTCue* pCue, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* pnValue) -{ - return pCue->lpVtbl->GetVariable(pCue, nIndex, pnValue); -} - -__inline HRESULT __stdcall IXACTCue_Pause(IXACTCue* pCue, BOOL fPause) -{ - return pCue->lpVtbl->Pause(pCue, fPause); -} - -#ifdef _XBOX -__inline HRESULT __stdcall IXACTCue_SetVoiceOutput(IXACTCue* pCue, LPCXAUDIOVOICEOUTPUT pVoiceOutput) -{ - return pCue->lpVtbl->SetVoiceOutput(pCue, pVoiceOutput); -} - -__inline HRESULT __stdcall IXACTCue_SetVoiceOutputVolume(IXACTCue* pCue, LPCXAUDIOVOICEOUTPUTVOLUME pVolume) -{ - return pCue->lpVtbl->SetVoiceOutputVolume(pCue, pVolume); -} - -__inline HRESULT __stdcall IXACTCue_GetProperties(IXACTCue* pCue, LPXACTCUEPROPERTIES pProperties) -{ - return pCue->lpVtbl->GetProperties(pCue, pProperties); -} -#endif // _XBOX - -#endif // __cplusplus - -//------------------------------------------------------------------------------ -// IXACTEngine -//------------------------------------------------------------------------------ - -// Engine flags -static const DWORD XACT_FLAG_ENGINE_CREATE_MANAGEDATA = 0x00000001; -static const DWORD XACT_FLAG_ENGINE_STOP_IMMEDIATE = 0x00000002; - -STDAPI_(ULONG) IXACTEngine_AddRef(IXACTEngine* pEngine); -STDAPI_(ULONG) IXACTEngine_Release(IXACTEngine* pEngine); -#ifndef _XBOX -STDAPI IXACTEngine_GetRendererCount(IXACTEngine* pEngine, XACTINDEX* pnRendererCount); -STDAPI IXACTEngine_GetRendererDetails(IXACTEngine* pEngine, XACTINDEX nRendererIndex, LPXACT_RENDERER_DETAILS pRendererDetails); -#endif -STDAPI IXACTEngine_Initialize(IXACTEngine* pEngine, const XACT_RUNTIME_PARAMETERS* pParams); -STDAPI IXACTEngine_ShutDown(IXACTEngine* pEngine); -STDAPI IXACTEngine_DoWork(IXACTEngine* pEngine); -STDAPI IXACTEngine_CreateSoundBank(IXACTEngine* pEngine, const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTSoundBank** ppSoundBank); -STDAPI IXACTEngine_CreateInMemoryWaveBank(IXACTEngine* pEngine, const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTWaveBank** ppWaveBank); -STDAPI IXACTEngine_CreateStreamingWaveBank(IXACTEngine* pEngine, const XACT_WAVEBANK_STREAMING_PARAMETERS* pParms, IXACTWaveBank** ppWaveBank); -STDAPI IXACTEngine_RegisterNotification(IXACTEngine* pEngine, const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc); -STDAPI IXACTEngine_UnRegisterNotification(IXACTEngine* pEngine, const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc); -STDAPI_(XACTCATEGORY) IXACTEngine_GetCategory(IXACTEngine* pEngine, PCSTR szFriendlyName); -STDAPI IXACTEngine_Stop(IXACTEngine* pEngine, XACTCATEGORY nCategory, DWORD dwFlags); -STDAPI IXACTEngine_SetVolume(IXACTEngine* pEngine, XACTCATEGORY nCategory, XACTVOLUME nVolume); -STDAPI IXACTEngine_Pause(IXACTEngine* pEngine, XACTCATEGORY nCategory, BOOL fPause); -STDAPI_(XACTVARIABLEINDEX) IXACTEngine_GetGlobalVariableIndex(IXACTEngine* pEngine, PCSTR szFriendlyName); -STDAPI IXACTEngine_SetGlobalVariable(IXACTEngine* pEngine, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue); -STDAPI IXACTEngine_GetGlobalVariable(IXACTEngine* pEngine, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* pnValue); - -#undef INTERFACE -#define INTERFACE IXACTEngine - -#ifdef _XBOX -DECLARE_INTERFACE(IXACTEngine) -{ -#else -DECLARE_INTERFACE_(IXACTEngine, IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, OUT void** ppvObj) PURE; -#endif - - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - -#ifndef _XBOX - STDMETHOD(GetRendererCount)(THIS_ XACTINDEX* pnRendererCount) PURE; - STDMETHOD(GetRendererDetails)(THIS_ XACTINDEX nRendererIndex, LPXACT_RENDERER_DETAILS pRendererDetails) PURE; -#endif - - STDMETHOD(Initialize)(THIS_ const XACT_RUNTIME_PARAMETERS* pParams) PURE; - STDMETHOD(ShutDown)(THIS) PURE; - - STDMETHOD(DoWork)(THIS) PURE; - - STDMETHOD(CreateSoundBank)(THIS_ const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTSoundBank** ppSoundBank) PURE; - STDMETHOD(CreateInMemoryWaveBank)(THIS_ const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTWaveBank** ppWaveBank) PURE; - STDMETHOD(CreateStreamingWaveBank)(THIS_ const XACT_WAVEBANK_STREAMING_PARAMETERS* pParms, IXACTWaveBank** ppWaveBank) PURE; - - STDMETHOD(RegisterNotification)(THIS_ const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc) PURE; - STDMETHOD(UnRegisterNotification)(THIS_ const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc) PURE; - - STDMETHOD_(XACTCATEGORY, GetCategory)(THIS_ PCSTR szFriendlyName) PURE; - STDMETHOD(Stop)(THIS_ XACTCATEGORY nCategory, DWORD dwFlags) PURE; - STDMETHOD(SetVolume)(THIS_ XACTCATEGORY nCategory, XACTVOLUME nVolume) PURE; - STDMETHOD(Pause)(THIS_ XACTCATEGORY nCategory, BOOL fPause) PURE; - - STDMETHOD_(XACTVARIABLEINDEX, GetGlobalVariableIndex)(THIS_ PCSTR szFriendlyName) PURE; - STDMETHOD(SetGlobalVariable)(THIS_ XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue) PURE; - STDMETHOD(GetGlobalVariable)(THIS_ XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* nValue) PURE; -}; - -#ifdef __cplusplus - -__inline ULONG __stdcall IXACTEngine_AddRef(IXACTEngine* pEngine) -{ - return pEngine->AddRef(); -} - -__inline ULONG __stdcall IXACTEngine_Release(IXACTEngine* pEngine) -{ - return pEngine->Release(); -} - -#ifndef _XBOX -__inline HRESULT __stdcall IXACTEngine_GetRendererCount(IXACTEngine* pEngine, XACTINDEX* pnRendererCount) -{ - return pEngine->GetRendererCount(pnRendererCount); -} - -__inline HRESULT __stdcall IXACTEngine_GetRendererDetails(IXACTEngine* pEngine, XACTINDEX nRendererIndex, LPXACT_RENDERER_DETAILS pRendererDetails) -{ - return pEngine->GetRendererDetails(nRendererIndex, pRendererDetails); -} -#endif - -__inline HRESULT __stdcall IXACTEngine_Initialize(IXACTEngine* pEngine, const XACT_RUNTIME_PARAMETERS* pParams) -{ - return pEngine->Initialize(pParams); -} - -__inline HRESULT __stdcall IXACTEngine_ShutDown(IXACTEngine* pEngine) -{ - return pEngine->ShutDown(); -} - -__inline HRESULT __stdcall IXACTEngine_DoWork(IXACTEngine* pEngine) -{ - return pEngine->DoWork(); -} - -__inline HRESULT __stdcall IXACTEngine_CreateSoundBank(IXACTEngine* pEngine, const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTSoundBank** ppSoundBank) -{ - return pEngine->CreateSoundBank(pvBuffer, dwSize, dwFlags, dwAllocAttributes, ppSoundBank); -} - -__inline HRESULT __stdcall IXACTEngine_CreateInMemoryWaveBank(IXACTEngine* pEngine, const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTWaveBank** ppWaveBank) -{ - return pEngine->CreateInMemoryWaveBank(pvBuffer, dwSize, dwFlags, dwAllocAttributes, ppWaveBank); -} - -__inline HRESULT __stdcall IXACTEngine_CreateStreamingWaveBank(IXACTEngine* pEngine, const XACT_WAVEBANK_STREAMING_PARAMETERS* pParms, IXACTWaveBank** ppWaveBank) -{ - return pEngine->CreateStreamingWaveBank(pParms, ppWaveBank); -} - -__inline HRESULT __stdcall IXACTEngine_RegisterNotification(IXACTEngine* pEngine, const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc) -{ - return pEngine->RegisterNotification(pNotificationDesc); -} - -__inline HRESULT __stdcall IXACTEngine_UnRegisterNotification(IXACTEngine* pEngine, const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc) -{ - return pEngine->UnRegisterNotification(pNotificationDesc); -} - -__inline XACTCATEGORY __stdcall IXACTEngine_GetCategory(IXACTEngine* pEngine, PCSTR szFriendlyName) -{ - return pEngine->GetCategory(szFriendlyName); -} - -__inline HRESULT __stdcall IXACTEngine_Stop(IXACTEngine* pEngine, XACTCATEGORY nCategory, DWORD dwFlags) -{ - return pEngine->Stop(nCategory, dwFlags); -} - -__inline HRESULT __stdcall IXACTEngine_SetVolume(IXACTEngine* pEngine, XACTCATEGORY nCategory, XACTVOLUME nVolume) -{ - return pEngine->SetVolume(nCategory, nVolume); -} - -__inline HRESULT __stdcall IXACTEngine_Pause(IXACTEngine* pEngine, XACTCATEGORY nCategory, BOOL fPause) -{ - return pEngine->Pause(nCategory, fPause); -} - -__inline XACTVARIABLEINDEX __stdcall IXACTEngine_GetGlobalVariableIndex(IXACTEngine* pEngine, PCSTR szFriendlyName) -{ - return pEngine->GetGlobalVariableIndex(szFriendlyName); -} - -__inline HRESULT __stdcall IXACTEngine_SetGlobalVariable(IXACTEngine* pEngine, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue) -{ - return pEngine->SetGlobalVariable(nIndex, nValue); -} - -__inline HRESULT __stdcall IXACTEngine_GetGlobalVariable(IXACTEngine* pEngine, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* nValue) -{ - return pEngine->GetGlobalVariable(nIndex, nValue); -} - -#else // __cplusplus - -__inline ULONG __stdcall IXACTEngine_AddRef(IXACTEngine* pEngine) -{ - return pEngine->lpVtbl->AddRef(pEngine); -} - -__inline ULONG __stdcall IXACTEngine_Release(IXACTEngine* pEngine) -{ - return pEngine->lpVtbl->Release(pEngine); -} - -#ifndef _XBOX -__inline HRESULT __stdcall IXACTEngine_GetRendererCount(IXACTEngine* pEngine, XACTINDEX* pnRendererCount) -{ - return pEngine->lpVtbl->GetRendererCount(pEngine, pnRendererCount); -} - -__inline HRESULT __stdcall IXACTEngine_GetRendererDetails(IXACTEngine* pEngine, XACTINDEX nRendererIndex, LPXACT_RENDERER_DETAILS pRendererDetails) -{ - return pEngine->lpVtbl->GetRendererDetails(pEngine, nRendererIndex, pRendererDetails); -} -#endif - -__inline HRESULT __stdcall IXACTEngine_Initialize(IXACTEngine* pEngine, const XACT_RUNTIME_PARAMETERS* pParams) -{ - return pEngine->lpVtbl->Initialize(pEngine, pParams); -} - -__inline HRESULT __stdcall IXACTEngine_ShutDown(IXACTEngine* pEngine) -{ - return pEngine->lpVtbl->ShutDown(pEngine); -} - -__inline HRESULT __stdcall IXACTEngine_DoWork(IXACTEngine* pEngine) -{ - return pEngine->lpVtbl->DoWork(pEngine); -} - -__inline HRESULT __stdcall IXACTEngine_CreateSoundBank(IXACTEngine* pEngine, const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTSoundBank** ppSoundBank) -{ - return pEngine->lpVtbl->CreateSoundBank(pEngine, pvBuffer, dwSize, dwFlags, dwAllocAttributes, ppSoundBank); -} - -__inline HRESULT __stdcall IXACTEngine_CreateInMemoryWaveBank(IXACTEngine* pEngine, const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTWaveBank** ppWaveBank) -{ - return pEngine->lpVtbl->CreateInMemoryWaveBank(pEngine, pvBuffer, dwSize, dwFlags, dwAllocAttributes, ppWaveBank); -} - -__inline HRESULT __stdcall IXACTEngine_CreateStreamingWaveBank(IXACTEngine* pEngine, const XACT_WAVEBANK_STREAMING_PARAMETERS* pParms, IXACTWaveBank** ppWaveBank) -{ - return pEngine->lpVtbl->CreateStreamingWaveBank(pEngine, pParms, ppWaveBank); -} - -__inline HRESULT __stdcall IXACTEngine_RegisterNotification(IXACTEngine* pEngine, const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc) -{ - return pEngine->lpVtbl->RegisterNotification(pEngine, pNotificationDesc); -} - -__inline HRESULT __stdcall IXACTEngine_UnRegisterNotification(IXACTEngine* pEngine, const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc) -{ - return pEngine->lpVtbl->UnRegisterNotification(pEngine, pNotificationDesc); -} - -__inline XACTCATEGORY __stdcall IXACTEngine_GetCategory(IXACTEngine* pEngine, PCSTR szFriendlyName) -{ - return pEngine->lpVtbl->GetCategory(pEngine, szFriendlyName); -} - -__inline HRESULT __stdcall IXACTEngine_Stop(IXACTEngine* pEngine, XACTCATEGORY nCategory, DWORD dwFlags) -{ - return pEngine->lpVtbl->Stop(pEngine, nCategory, dwFlags); -} - -__inline HRESULT __stdcall IXACTEngine_SetVolume(IXACTEngine* pEngine, XACTCATEGORY nCategory, XACTVOLUME nVolume) -{ - return pEngine->lpVtbl->SetVolume(pEngine, nCategory, nVolume); -} - -__inline HRESULT __stdcall IXACTEngine_Pause(IXACTEngine* pEngine, XACTCATEGORY nCategory, BOOL fPause) -{ - return pEngine->lpVtbl->Pause(pEngine, nCategory, fPause); -} - -__inline XACTVARIABLEINDEX __stdcall IXACTEngine_GetGlobalVariableIndex(IXACTEngine* pEngine, PCSTR szFriendlyName) -{ - return pEngine->lpVtbl->GetGlobalVariableIndex(pEngine, szFriendlyName); -} - -__inline HRESULT __stdcall IXACTEngine_SetGlobalVariable(IXACTEngine* pEngine, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue) -{ - return pEngine->lpVtbl->SetGlobalVariable(pEngine, nIndex, nValue); -} - -__inline HRESULT __stdcall IXACTEngine_GetGlobalVariable(IXACTEngine* pEngine, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* nValue) -{ - return pEngine->lpVtbl->GetGlobalVariable(pEngine, nIndex, nValue); -} - -#endif // __cplusplus - -//------------------------------------------------------------------------------ -// XACT API's (these are deprecated and will be removed in a future release) -//------------------------------------------------------------------------------ - -#ifdef _XBOX - -static const DWORD XACT_FLAG_API_CREATE_MANAGEDATA = 0x00000001; -static const DWORD XACT_FLAG_API_STOP_IMMEDIATE = 0x00000002; - -STDAPI XACTInitialize(const XACT_RUNTIME_PARAMETERS* pParams); -STDAPI XACTShutDown(void); -STDAPI XACTDoWork(void); - -STDAPI XACTCreateSoundBank(const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTSoundBank** ppSoundBank); -STDAPI XACTCreateInMemoryWaveBank(const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTWaveBank** ppWaveBank); -STDAPI XACTCreateStreamingWaveBank(const XACT_WAVEBANK_STREAMING_PARAMETERS* pParms, IXACTWaveBank** ppWaveBank); - -STDAPI XACTRegisterNotification(const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc); -STDAPI XACTUnRegisterNotification(const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc); - -STDAPI_(XACTCATEGORY) XACTGetCategory(PCSTR szFriendlyName); -STDAPI XACTStop(XACTCATEGORY nCategory, DWORD dwFlags); -STDAPI XACTSetVolume(XACTCATEGORY nCategory, XACTVOLUME nVolume); -STDAPI XACTPause(XACTCATEGORY nCategory, BOOL fPause); - -STDAPI_(XACTVARIABLEINDEX) XACTGetGlobalVariableIndex(PCSTR szFriendlyName); -STDAPI XACTSetGlobalVariable(XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue); -STDAPI XACTGetGlobalVariable(XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* pnValue); - -#endif // #ifdef _XBOX - -//------------------------------------------------------------------------------ -// Create Engine -//------------------------------------------------------------------------------ - -// Flags used only in XACTCreateEngine below. These flags are valid but ignored -// when building for Xbox 360; to enable auditioning on that platform you must -// link explicitly to an auditioning version of the XACT static library. -static const DWORD XACT_FLAG_API_AUDITION_MODE = 0x00000001; -static const DWORD XACT_FLAG_API_DEBUG_MODE = 0x00000002; - -STDAPI XACTCreateEngine(DWORD dwCreationFlags, IXACTEngine** ppEngine); - -#ifndef _XBOX - -#if defined (UNICODE) -# define XACT_DEBUGENGINE_REGISTRY_KEY L"Software\\Microsoft\\XACT" -# define XACT_DEBUGENGINE_REGISTRY_VALUE L"DebugEngine" -#else -# define XACT_DEBUGENGINE_REGISTRY_KEY "Software\\Microsoft\\XACT" -# define XACT_DEBUGENGINE_REGISTRY_VALUE "DebugEngine" -#endif - -#ifdef __cplusplus - -__inline HRESULT __stdcall XACTCreateEngine(DWORD dwCreationFlags, IXACTEngine** ppEngine) -{ - HKEY key; - DWORD data; - DWORD type = REG_DWORD; - DWORD dataSize = sizeof(DWORD); - BOOL debug = (dwCreationFlags & XACT_FLAG_API_DEBUG_MODE) ? TRUE : FALSE; - BOOL audition = (dwCreationFlags & XACT_FLAG_API_AUDITION_MODE) ? TRUE : FALSE; - - // If neither the debug nor audition flags are set, see if the debug registry key is set - if(!debug && !audition && - (RegOpenKeyEx(HKEY_LOCAL_MACHINE, XACT_DEBUGENGINE_REGISTRY_KEY, 0, KEY_READ, &key) == ERROR_SUCCESS)) - { - if(RegQueryValueEx(key, XACT_DEBUGENGINE_REGISTRY_VALUE, NULL, &type, (LPBYTE)&data, &dataSize) == ERROR_SUCCESS) - { - if(data) - { - debug = TRUE; - } - } - RegCloseKey(key); - } - - return CoCreateInstance(audition ? __uuidof(XACTAuditionEngine) - : (debug ? __uuidof(XACTDebugEngine) : __uuidof(XACTEngine)), - NULL, CLSCTX_INPROC_SERVER, __uuidof(IXACTEngine), (void**)ppEngine); -} - -#else - -__inline HRESULT __stdcall XACTCreateEngine(DWORD dwCreationFlags, IXACTEngine** ppEngine) -{ - HKEY key; - DWORD data; - DWORD type = REG_DWORD; - DWORD dataSize = sizeof(DWORD); - BOOL debug = (dwCreationFlags & XACT_FLAG_API_DEBUG_MODE) ? TRUE : FALSE; - BOOL audition = (dwCreationFlags & XACT_FLAG_API_AUDITION_MODE) ? TRUE : FALSE; - - // If neither the debug nor audition flags are set, see if the debug registry key is set - if(!debug && !audition && - (RegOpenKeyEx(HKEY_LOCAL_MACHINE, XACT_DEBUGENGINE_REGISTRY_KEY, 0, KEY_READ, &key) == ERROR_SUCCESS)) - { - if(RegQueryValueEx(key, XACT_DEBUGENGINE_REGISTRY_VALUE, NULL, &type, (LPBYTE)&data, &dataSize) == ERROR_SUCCESS) - { - if(data) - { - debug = TRUE; - } - } - RegCloseKey(key); - } - - return CoCreateInstance(audition ? &CLSID_XACTAuditionEngine - : (debug ? &CLSID_XACTDebugEngine : &CLSID_XACTEngine), - NULL, CLSCTX_INPROC_SERVER, &IID_IXACTEngine, (void**)ppEngine); -} - -#endif // #ifdef __cplusplus -#endif // #ifndef _XBOX - -//------------------------------------------------------------------------------ -// XACT specific error codes -//------------------------------------------------------------------------------ - -#define FACILITY_XACTENGINE 0xAC7 -#define XACTENGINEERROR(n) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_XACTENGINE, n) - -#define XACTENGINE_E_OUTOFMEMORY E_OUTOFMEMORY // Out of memory -#define XACTENGINE_E_INVALIDARG E_INVALIDARG // Invalid arg -#define XACTENGINE_E_NOTIMPL E_NOTIMPL // Not implemented -#define XACTENGINE_E_FAIL E_FAIL // Unknown error - -#define XACTENGINE_E_ALREADYINITIALIZED XACTENGINEERROR(0x001) // The engine is already initialized -#define XACTENGINE_E_NOTINITIALIZED XACTENGINEERROR(0x002) // The engine has not been initialized -#define XACTENGINE_E_EXPIRED XACTENGINEERROR(0x003) // The engine has expired (demo or pre-release version) -#define XACTENGINE_E_NONOTIFICATIONCALLBACK XACTENGINEERROR(0x004) // No notification callback -#define XACTENGINE_E_NOTIFICATIONREGISTERED XACTENGINEERROR(0x005) // Notification already registered -#define XACTENGINE_E_INVALIDUSAGE XACTENGINEERROR(0x006) // Invalid usage -#define XACTENGINE_E_INVALIDDATA XACTENGINEERROR(0x007) // Invalid data -#define XACTENGINE_E_INSTANCELIMITFAILTOPLAY XACTENGINEERROR(0x008) // Fail to play due to instance limit -#define XACTENGINE_E_NOGLOBALSETTINGS XACTENGINEERROR(0x009) // Global Settings not loaded -#define XACTENGINE_E_INVALIDVARIABLEINDEX XACTENGINEERROR(0x00a) // Invalid variable index -#define XACTENGINE_E_INVALIDCATEGORY XACTENGINEERROR(0x00b) // Invalid category -#define XACTENGINE_E_INVALIDCUEINDEX XACTENGINEERROR(0x00c) // Invalid cue index -#define XACTENGINE_E_INVALIDWAVEINDEX XACTENGINEERROR(0x00d) // Invalid wave index -#define XACTENGINE_E_INVALIDTRACKINDEX XACTENGINEERROR(0x00e) // Invalid track index -#define XACTENGINE_E_INVALIDSOUNDOFFSETORINDEX XACTENGINEERROR(0x00f) // Invalid sound offset or index -#define XACTENGINE_E_READFILE XACTENGINEERROR(0x010) // Error reading a file -#define XACTENGINE_E_UNKNOWNEVENT XACTENGINEERROR(0x011) // Unknown event type -#define XACTENGINE_E_INCALLBACK XACTENGINEERROR(0x012) // Invalid call of method of function from callback -#define XACTENGINE_E_NOWAVEBANK XACTENGINEERROR(0x013) // No wavebank exists for desired operation -#define XACTENGINE_E_SELECTVARIATION XACTENGINEERROR(0x014) // Unable to select a variation -#define XACTENGINE_E_MULTIPLEAUDITIONENGINES XACTENGINEERROR(0x015) // There can be only one audition engine -#define XACTENGINE_E_WAVEBANKNOTPREPARED XACTENGINEERROR(0x016) // The wavebank is not prepared -#define XACTENGINE_E_NORENDERER XACTENGINEERROR(0x017) // No audio device found on. -#define XACTENGINE_E_INVALIDENTRYCOUNT XACTENGINEERROR(0x018) // Invalid entry count for channel maps -#define XACTENGINE_E_SEEKTIMEBEYONDCUEEND XACTENGINEERROR(0x19) // Time offset for seeking is beyond the cue end. - -#define XACTENGINE_E_AUDITION_WRITEFILE XACTENGINEERROR(0x101) // Error writing a file during auditioning -#define XACTENGINE_E_AUDITION_NOSOUNDBANK XACTENGINEERROR(0x102) // Missing a soundbank -#define XACTENGINE_E_AUDITION_INVALIDRPCINDEX XACTENGINEERROR(0x103) // Missing an RPC curve -#define XACTENGINE_E_AUDITION_MISSINGDATA XACTENGINEERROR(0x104) // Missing data for an audition command -#define XACTENGINE_E_AUDITION_UNKNOWNCOMMAND XACTENGINEERROR(0x105) // Unknown command -#define XACTENGINE_E_AUDITION_INVALIDDSPINDEX XACTENGINEERROR(0x106) // Missing a DSP parameter - -#endif // #ifndef GUID_DEFS_ONLY -#endif // #ifndef _XACT_H_ +/*++ + +Copyright (C) Microsoft Corporation. All rights reserved. + +Module Name: + + xact.h + +Abstract: + + XACT public interfaces, functions and data types + +--*/ + +#pragma once + +#ifndef _XACT_H_ +#define _XACT_H_ + +//------------------------------------------------------------------------------ +// XACT class and interface IDs +//------------------------------------------------------------------------------ +#ifndef _XBOX // XACT COM support only exists on Windows + #include // For DEFINE_CLSID, DEFINE_IID and DECLARE_INTERFACE + DEFINE_CLSID(XACTEngine, 1f1b577e, 5e5a, 4e8a, ba, 73, c6, 57, ea, 8e, 85, 98); + DEFINE_CLSID(XACTAuditionEngine, fcecc8be, b09a, 48cb, 92, 08, 95, a7, ed, 45, 82, a6); + DEFINE_CLSID(XACTDebugEngine, 2b4a46bb, ae7a, 4072, ae, 18, 11, 28, 15, 4f, ba, 97); + DEFINE_IID(IXACTEngine, 7cdd1894, 643b, 4168, 83, 6f, d1, 9d, 59, d0, ce, 53); +#endif + +// Ignore the rest of this header if only the GUID definitions were requested: +#ifndef GUID_DEFS_ONLY + +//------------------------------------------------------------------------------ +// Includes +//------------------------------------------------------------------------------ + +#ifndef _XBOX + #include + #include + #include +#else + #include +#endif + +//------------------------------------------------------------------------------ +// Forward Declarations +//------------------------------------------------------------------------------ + +typedef struct IXACTSoundBank IXACTSoundBank; +typedef struct IXACTWaveBank IXACTWaveBank; +typedef struct IXACTCue IXACTCue; +typedef struct IXACTEngine IXACTEngine; +typedef struct XACT_NOTIFICATION XACT_NOTIFICATION; + + +//------------------------------------------------------------------------------ +// Typedefs +//------------------------------------------------------------------------------ + +typedef WORD XACTINDEX; // All normal indices +typedef BYTE XACTNOTIFICATIONTYPE; // Notification type +typedef FLOAT XACTVARIABLEVALUE; // Variable value +typedef WORD XACTVARIABLEINDEX; // Variable index +typedef WORD XACTCATEGORY; // Sound category +typedef BYTE XACTCHANNEL; // Audio channel +typedef FLOAT XACTVOLUME; // Volume value +typedef LONG XACTTIME; // Time (in ms) + +//------------------------------------------------------------------------------ +// Constants +//------------------------------------------------------------------------------ + +static const XACTINDEX XACTINDEX_MIN = 0x0; +static const XACTINDEX XACTINDEX_MAX = 0xfffe; +static const XACTINDEX XACTINDEX_INVALID = 0xffff; + +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_MIN = 0x00; +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_MAX = 0xff; + +static const XACTVARIABLEVALUE XACTVARIABLEVALUE_MIN = -FLT_MAX; +static const XACTVARIABLEVALUE XACTVARIABLEVALUE_MAX = FLT_MAX; + +static const XACTVARIABLEINDEX XACTVARIABLEINDEX_MIN = 0x0000; +static const XACTVARIABLEINDEX XACTVARIABLEINDEX_MAX = 0xfffe; +static const XACTVARIABLEINDEX XACTVARIABLEINDEX_INVALID = 0xffff; + +static const XACTCATEGORY XACTCATEGORY_MIN = 0x0; +static const XACTCATEGORY XACTCATEGORY_MAX = 0xfffe; +static const XACTCATEGORY XACTCATEGORY_INVALID = 0xffff; + +static const XACTCHANNEL XACTCHANNEL_MIN = 0; +static const XACTCHANNEL XACTCHANNEL_MAX = 0xFF; + +static const XACTVOLUME XACTVOLUME_MIN = 0.0f; +static const XACTVOLUME XACTVOLUME_MAX = FLT_MAX; + +static const XACTVARIABLEVALUE XACTPARAMETERVALUE_MIN = -FLT_MAX; +static const XACTVARIABLEVALUE XACTPARAMETERVALUE_MAX = FLT_MAX; + +#ifdef _XBOX +static const XAUDIOVOICEINDEX XACTMAXOUTPUTVOICECOUNT = 3; +#endif // _XBOX + +#define XACT_CONTENT_VERSION 38 + +//------------------------------------------------------------------------------ +// XACT Parameters +//------------------------------------------------------------------------------ + +static const DWORD XACT_FLAG_GLOBAL_SETTINGS_MANAGEDATA = 0x00000001; + +typedef BOOL (__stdcall * XACT_READFILE_CALLBACK)(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped); +typedef BOOL (__stdcall * XACT_GETOVERLAPPEDRESULT_CALLBACK)(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait); + +typedef struct XACT_FILEIO_CALLBACKS +{ + XACT_READFILE_CALLBACK readFileCallback; + XACT_GETOVERLAPPEDRESULT_CALLBACK getOverlappedResultCallback; +} XACT_FILEIO_CALLBACKS, *PXACT_FILEIO_CALLBACKS; +typedef const XACT_FILEIO_CALLBACKS *PCXACT_FILEIO_CALLBACKS; + +// The callback that receives the notifications. +typedef void (__stdcall * XACT_NOTIFICATION_CALLBACK)(const XACT_NOTIFICATION* pNotification); + +#ifndef _XBOX + +#define XACT_RENDERER_ID_LENGTH 0xff // Maximum number of characters allowed in the renderer ID +#define XACT_RENDERER_NAME_LENGTH 0xff // Maximum number of characters allowed in the renderer display name. + +// Renderer details +typedef struct XACT_RENDERER_DETAILS +{ + WCHAR rendererID[XACT_RENDERER_ID_LENGTH]; // The string ID for the rendering device. + WCHAR displayName[XACT_RENDERER_NAME_LENGTH]; // A friendly name suitable for display to a human. + BOOL defaultDevice; // Set to TRUE if this device is the primary audio device on the system. +} XACT_RENDERER_DETAILS, *LPXACT_RENDERER_DETAILS; +#endif + +// Runtime (engine) parameters +typedef struct XACT_RUNTIME_PARAMETERS +{ + DWORD lookAheadTime; // Time in ms + void* pGlobalSettingsBuffer; // Buffer containing the global settings file + DWORD globalSettingsBufferSize; // Size of global settings buffer + DWORD globalSettingsFlags; // Flags for global settings + DWORD globalSettingsAllocAttributes; // Global settings buffer allocation attributes (see XMemAlloc) + XACT_FILEIO_CALLBACKS fileIOCallbacks; // File I/O callbacks + XACT_NOTIFICATION_CALLBACK fnNotificationCallback; // Callback that receives notifications. +#ifndef _XBOX + PWSTR pRendererID; // Ptr to the ID for the audio renderer the engine should connect to. +#endif +} XACT_RUNTIME_PARAMETERS, *LPXACT_RUNTIME_PARAMETERS; +typedef const XACT_RUNTIME_PARAMETERS *LPCXACT_RUNTIME_PARAMETERS; + +//------------------------------------------------------------------------------ +// Streaming Parameters +//------------------------------------------------------------------------------ + +typedef struct XACT_WAVEBANK_STREAMING_PARAMETERS +{ + HANDLE file; // File handle associated with wavebank data + DWORD offset; // Offset within file of wavebank header (must be sector aligned) + DWORD flags; // Flags (none currently) + WORD packetSize; // Stream packet size (in sectors) to use for each stream (min = 2) + // number of sectors (DVD = 2048 bytes: 2 = 4096, 3 = 6144, 4 = 8192 etc.) + // optimal DVD size is a multiple of 16 (DVD block = 16 DVD sectors) +} XACT_WAVEBANK_STREAMING_PARAMETERS, *LPXACT_WAVEBANK_STREAMING_PARAMETERS; +typedef const XACT_WAVEBANK_STREAMING_PARAMETERS *LPCXACT_WAVEBANK_STREAMING_PARAMETERS; + +//------------------------------------------------------------------------------ +// Cue Properties (Xbox Only) +//------------------------------------------------------------------------------ +#ifdef _XBOX +typedef struct XACTCUEPROPERTIES +{ + XACTCATEGORY ActiveSoundCategory; // Category of the active sound + BYTE ActiveSoundTrackCount; // The number of tracks in the active sound + BYTE ActiveSoundPriority; // The priority of the active sound + XACTINDEX FirstTrackWaveIndex; // Index of the currently selected wave variation in the first track + DWORD FirstTrackWaveDuration; // Estimated duration (ms) of the selected wave in the first track (does not account for pitch changes) + XACTCHANNEL MaxTrackChannelCount; // The highest number of channels in any track + BYTE MaxTrackLoopCount; // The highest loop count of any track (255 is infinite) +} XACTCUEPROPERTIES, *LPXACTCUEPROPERTIES; +#endif // _XBOX + +//------------------------------------------------------------------------------ +// Channel Mapping / Speaker Panning +//------------------------------------------------------------------------------ + +typedef struct XACTCHANNELMAPENTRY +{ + XACTCHANNEL InputChannel; + XACTCHANNEL OutputChannel; + XACTVOLUME Volume; +} XACTCHANNELMAPENTRY, *LPXACTCHANNELMAPENTRY; +typedef const XACTCHANNELMAPENTRY *LPCXACTCHANNELMAPENTRY; + +typedef struct XACTCHANNELMAP +{ + XACTCHANNEL EntryCount; + XACTCHANNELMAPENTRY* paEntries; +} XACTCHANNELMAP, *LPXACTCHANNELMAP; +typedef const XACTCHANNELMAP *LPCXACTCHANNELMAP; + +typedef struct XACTCHANNELVOLUMEENTRY +{ + XACTCHANNEL EntryIndex; + XACTVOLUME Volume; +} XACTCHANNELVOLUMEENTRY, *LPXACTCHANNELVOLUMEENTRY; +typedef const XACTCHANNELVOLUMEENTRY *LPCXACTCHANNELVOLUMEENTRY; + +typedef struct XACTCHANNELVOLUME +{ + XACTCHANNEL EntryCount; + XACTCHANNELVOLUMEENTRY* paEntries; +} XACTCHANNELVOLUME, *LPXACTCHANNELVOLUME; +typedef const XACTCHANNELVOLUME *LPCXACTCHANNELVOLUME; + +//------------------------------------------------------------------------------ +// Notifications +//------------------------------------------------------------------------------ + +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_CUEPREPARED = 1; // None, SoundBank, SoundBank & cue index, cue instance +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_CUEPLAY = 2; // None, SoundBank, SoundBank & cue index, cue instance +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_CUESTOP = 3; // None, SoundBank, SoundBank & cue index, cue instance +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_CUEDESTROYED = 4; // None, SoundBank, SoundBank & cue index, cue instance +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_MARKER = 5; // None, SoundBank, SoundBank & cue index, cue instance +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_SOUNDBANKDESTROYED = 6; // None, SoundBank +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_WAVEBANKDESTROYED = 7; // None, WaveBank +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_LOCALVARIABLECHANGED = 8; // None, SoundBank, SoundBank & cue index, cue instance +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_GLOBALVARIABLECHANGED = 9; // None +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_GUICONNECTED = 10; // None +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_GUIDISCONNECTED = 11; // None +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_WAVEPLAY = 12; // None, SoundBank, SoundBank & cue index, cue instance, WaveBank +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_WAVESTOP = 13; // None, SoundBank, SoundBank & cue index, cue instance, WaveBank +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_WAVEBANKPREPARED = 14; // None, WaveBank +static const XACTNOTIFICATIONTYPE XACTNOTIFICATIONTYPE_WAVEBANKSTREAMING_INVALIDCONTENT = 15; // None, WaveBank + +static const BYTE XACT_FLAG_NOTIFICATION_PERSIST = 0x01; + +// Pack the notification structures +#pragma pack(push, 1) + +// Notification description used for registering, un-registering and flushing notifications +typedef struct XACT_NOTIFICATION_DESCRIPTION +{ + XACTNOTIFICATIONTYPE type; // Notification type + BYTE flags; // Flags + IXACTSoundBank* pSoundBank; // SoundBank instance + IXACTWaveBank* pWaveBank; // WaveBank instance + IXACTCue* pCue; // Cue instance + XACTINDEX cueIndex; // Cue index + PVOID pvContext; // User context (optional) + +} XACT_NOTIFICATION_DESCRIPTION, *LPXACT_NOTIFICATION_DESCRIPTION; +typedef const XACT_NOTIFICATION_DESCRIPTION *LPCXACT_NOTIFICATION_DESCRIPTION; + +// Notification structure for all XACTNOTIFICATIONTYPE_CUE* notifications +typedef struct XACT_NOTIFICATION_CUE +{ + XACTINDEX cueIndex; // Cue index + IXACTSoundBank* pSoundBank; // SoundBank instance + IXACTCue* pCue; // Cue instance + +} XACT_NOTIFICATION_CUE, *LPXACT_NOTIFICATION_CUE; +typedef const XACT_NOTIFICATION_CUE *LPCXACT_NOTIFICATION_CUE; + +// Notification structure for all XACTNOTIFICATIONTYPE_MARKER* notifications +typedef struct XACT_NOTIFICATION_MARKER +{ + XACTINDEX cueIndex; // Cue index + IXACTSoundBank* pSoundBank; // SoundBank instance + IXACTCue* pCue; // Cue instance + DWORD marker; // Marker value + +} XACT_NOTIFICATION_MARKER, *LPXACT_NOTIFICATION_MARKER; +typedef const XACT_NOTIFICATION_MARKER *LPCXACT_NOTIFICATION_MARKER; + +// Notification structure for all XACTNOTIFICATIONTYPE_SOUNDBANK* notifications +typedef struct XACT_NOTIFICATION_SOUNDBANK +{ + IXACTSoundBank* pSoundBank; // SoundBank instance + +} XACT_NOTIFICATION_SOUNDBANK, *LPXACT_NOTIFICATION_SOUNDBANK; +typedef const XACT_NOTIFICATION_SOUNDBANK *LPCXACT_NOTIFICATION_SOUNDBANK; + +// Notification structure for all XACTNOTIFICATIONTYPE_WAVEBANK* notifications +typedef struct XACT_NOTIFICATION_WAVEBANK +{ + IXACTWaveBank* pWaveBank; // WaveBank instance + +} XACT_NOTIFICATION_WAVEBANK, *LPXACT_NOTIFICATION_WAVEBANK; +typedef const XACT_NOTIFICATION_WAVEBANK *LPCXACT_NOTIFICATION_WAVEBANK; + +// Notification structure for all XACTNOTIFICATIONTYPE_*VARIABLE* notifications +typedef struct XACT_NOTIFICATION_VARIABLE +{ + XACTINDEX cueIndex; // Cue index + IXACTSoundBank* pSoundBank; // SoundBank instance + IXACTCue* pCue; // Cue instance + XACTVARIABLEINDEX variableIndex; // Variable index + XACTVARIABLEVALUE variableValue; // Variable value + BOOL local; // TRUE if a local variable + +} XACT_NOTIFICATION_VARIABLE, *LPXACT_NOTIFICATION_VARIABLE; +typedef const XACT_NOTIFICATION_VARIABLE *LPCXACT_NOTIFICATION_VARIABLE; + +// Notification structure for all XACTNOTIFICATIONTYPE_GUI* notifications +typedef struct XACT_NOTIFICATION_GUI +{ + DWORD reserved; // Reserved +} XACT_NOTIFICATION_GUI, *LPXACT_NOTIFICATION_GUI; +typedef const XACT_NOTIFICATION_GUI *LPCXACT_NOTIFICATION_GUI; + +// Notification structure for all XACTNOTIFICATIONTYPE_WAVE* notifications +typedef struct XACT_NOTIFICATION_WAVE +{ + IXACTWaveBank* pWaveBank; // WaveBank + XACTINDEX waveIndex; // Wave index + XACTINDEX cueIndex; // Cue index + IXACTSoundBank* pSoundBank; // SoundBank instance + IXACTCue* pCue; // Cue instance + +} XACT_NOTIFICATION_WAVE, *LPXACT_NOTIFICATION_WAVE; +typedef const XACT_NOTIFICATION_WAVE *LPCXACT_NOTIFICATION_WAVE; + +// General notification structure +typedef struct XACT_NOTIFICATION +{ + XACTNOTIFICATIONTYPE type; // Notification type + LONG timeStamp; // Timestamp of notification (milliseconds) + PVOID pvContext; // User context (optional) + union + { + XACT_NOTIFICATION_CUE cue; // XACTNOTIFICATIONTYPE_CUE* + XACT_NOTIFICATION_MARKER marker; // XACTNOTIFICATIONTYPE_MARKER* + XACT_NOTIFICATION_SOUNDBANK soundBank; // XACTNOTIFICATIONTYPE_SOUNDBANK* + XACT_NOTIFICATION_WAVEBANK waveBank; // XACTNOTIFICATIONTYPE_WAVEBANK* + XACT_NOTIFICATION_VARIABLE variable; // XACTNOTIFICATIONTYPE_VARIABLE* + XACT_NOTIFICATION_GUI gui; // XACTNOTIFICATIONTYPE_GUI* + XACT_NOTIFICATION_WAVE wave; // XACTNOTIFICATIONTYPE_WAVE* + }; + +} XACT_NOTIFICATION, *LPXACT_NOTIFICATION; +typedef const XACT_NOTIFICATION *LPCXACT_NOTIFICATION; +#pragma pack(pop) + +//------------------------------------------------------------------------------ +// IXACTSoundBank +//------------------------------------------------------------------------------ + +static const DWORD XACT_FLAG_SOUNDBANK_STOP_IMMEDIATE = 0x00000001; + +static const DWORD XACT_SOUNDBANKSTATE_INUSE = 0x00000001; // Currently in-use + +STDAPI IXACTSoundBank_Destroy(IXACTSoundBank* pSoundBank); +STDAPI_(XACTINDEX) IXACTSoundBank_GetCueIndex(IXACTSoundBank* pSoundBank, PCSTR szFriendlyName); +STDAPI IXACTSoundBank_Prepare(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue); +STDAPI IXACTSoundBank_Play(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue); +STDAPI IXACTSoundBank_Stop(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags); +STDAPI IXACTSoundBank_GetState(IXACTSoundBank* pSoundBank, DWORD* pdwState); + +#undef INTERFACE +#define INTERFACE IXACTSoundBank + +DECLARE_INTERFACE(IXACTSoundBank) +{ + STDMETHOD_(XACTINDEX, GetCueIndex)(THIS_ PCSTR szFriendlyName) PURE; + STDMETHOD(Prepare)(THIS_ XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue) PURE; + STDMETHOD(Play)(THIS_ XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue) PURE; + STDMETHOD(Stop)(THIS_ XACTINDEX nCueIndex, DWORD dwFlags) PURE; + STDMETHOD(Destroy)(THIS) PURE; + STDMETHOD(GetState)(THIS_ DWORD* pdwState) PURE; +}; + +#ifdef __cplusplus + +__inline HRESULT __stdcall IXACTSoundBank_Destroy(IXACTSoundBank* pSoundBank) +{ + return pSoundBank->Destroy(); +} + +__inline XACTINDEX __stdcall IXACTSoundBank_GetCueIndex(IXACTSoundBank* pSoundBank, PCSTR szFriendlyName) +{ + return pSoundBank->GetCueIndex(szFriendlyName); +} + +__inline HRESULT __stdcall IXACTSoundBank_Prepare(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue) +{ + return pSoundBank->Prepare(nCueIndex, dwFlags, timeOffset, ppCue); +} + +__inline HRESULT __stdcall IXACTSoundBank_Play(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue) +{ + return pSoundBank->Play(nCueIndex, dwFlags, timeOffset, ppCue); +} + +__inline HRESULT __stdcall IXACTSoundBank_Stop(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags) +{ + return pSoundBank->Stop(nCueIndex, dwFlags); +} + +__inline HRESULT __stdcall IXACTSoundBank_GetState(IXACTSoundBank* pSoundBank, DWORD* pdwState) +{ + return pSoundBank->GetState(pdwState); +} + +#else // __cplusplus + +__inline HRESULT __stdcall IXACTSoundBank_Destroy(IXACTSoundBank* pSoundBank) +{ + return pSoundBank->lpVtbl->Destroy(pSoundBank); +} + +__inline XACTINDEX __stdcall IXACTSoundBank_GetCueIndex(IXACTSoundBank* pSoundBank, PCSTR szFriendlyName) +{ + return pSoundBank->lpVtbl->GetCueIndex(pSoundBank, szFriendlyName); +} + +__inline HRESULT __stdcall IXACTSoundBank_Prepare(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue) +{ + return pSoundBank->lpVtbl->Prepare(pSoundBank, nCueIndex, dwFlags, timeOffset, ppCue); +} + +__inline HRESULT __stdcall IXACTSoundBank_Play(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACTCue** ppCue) +{ + return pSoundBank->lpVtbl->Play(pSoundBank, nCueIndex, dwFlags, timeOffset, ppCue); +} + +__inline HRESULT __stdcall IXACTSoundBank_Stop(IXACTSoundBank* pSoundBank, XACTINDEX nCueIndex, DWORD dwFlags) +{ + return pSoundBank->lpVtbl->Stop(pSoundBank, nCueIndex, dwFlags); +} + +__inline HRESULT __stdcall IXACTSoundBank_GetState(IXACTSoundBank* pSoundBank, DWORD* pdwState) +{ + return pSoundBank->lpVtbl->GetState(pSoundBank, pdwState); +} + +#endif // __cplusplus + +//------------------------------------------------------------------------------ +// IXACTWaveBank +//------------------------------------------------------------------------------ + +static const DWORD XACT_WAVEBANKSTATE_INUSE = 0x00000001; // Currently in-use +static const DWORD XACT_WAVEBANKSTATE_PREPARED = 0x00000002; // Prepared +static const DWORD XACT_WAVEBANKSTATE_PREPAREFAILED = 0x00000004; // Prepare failed. + +STDAPI IXACTWaveBank_Destroy(IXACTWaveBank* pWaveBank); +STDAPI IXACTWaveBank_GetState(IXACTWaveBank* pWaveBank, DWORD* pdwState); + +#undef INTERFACE +#define INTERFACE IXACTWaveBank + +DECLARE_INTERFACE(IXACTWaveBank) +{ + STDMETHOD(Destroy)(THIS) PURE; + STDMETHOD(GetState)(THIS_ DWORD* pdwState) PURE; +}; + +#ifdef __cplusplus + +__inline HRESULT __stdcall IXACTWaveBank_Destroy(IXACTWaveBank* pWaveBank) +{ + return pWaveBank->Destroy(); +} + +__inline HRESULT __stdcall IXACTWaveBank_GetState(IXACTWaveBank* pWaveBank, DWORD* pdwState) +{ + return pWaveBank->GetState(pdwState); +} + +#else // __cplusplus + +__inline HRESULT __stdcall IXACTWaveBank_Destroy(IXACTWaveBank* pWaveBank) +{ + return pWaveBank->lpVtbl->Destroy(pWaveBank); +} + +__inline HRESULT __stdcall IXACTWaveBank_GetState(IXACTWaveBank* pWaveBank, DWORD* pdwState) +{ + return pWaveBank->lpVtbl->GetState(pWaveBank, pdwState); +} + +#endif // __cplusplus + +//------------------------------------------------------------------------------ +// IXACTCue +//------------------------------------------------------------------------------ + +// Cue Flags +static const DWORD XACT_FLAG_CUE_STOP_RELEASE = 0x00000000; +static const DWORD XACT_FLAG_CUE_STOP_IMMEDIATE = 0x00000001; + +// Mutually exclusive states +static const DWORD XACT_CUESTATE_CREATED = 0x00000001; // Created, but nothing else +static const DWORD XACT_CUESTATE_PREPARING = 0x00000002; // In the middle of preparing +static const DWORD XACT_CUESTATE_PREPARED = 0x00000004; // Prepared, but not yet played +static const DWORD XACT_CUESTATE_PLAYING = 0x00000008; // Playing (though could be paused) +static const DWORD XACT_CUESTATE_STOPPING = 0x00000010; // Stopping +static const DWORD XACT_CUESTATE_STOPPED = 0x00000020; // Stopped + +// Inclusive states +static const DWORD XACT_CUESTATE_PAUSED = 0x00000040; // Paused (can be combinded with other states) + +STDAPI IXACTCue_Destroy(IXACTCue* pCue); +STDAPI IXACTCue_Play(IXACTCue* pCue); +STDAPI IXACTCue_Stop(IXACTCue* pCue, DWORD dwFlags); +STDAPI IXACTCue_GetState(IXACTCue* pCue, DWORD* pdwState); +STDAPI IXACTCue_GetChannelMap(IXACTCue*, LPXACTCHANNELMAP pChannelMap, DWORD BufferSize, LPDWORD pRequiredSize); +STDAPI IXACTCue_SetChannelMap(IXACTCue*, LPCXACTCHANNELMAP pChannelMap); +STDAPI IXACTCue_GetChannelVolume(IXACTCue*, LPXACTCHANNELVOLUME pVolume); +STDAPI IXACTCue_SetChannelVolume(IXACTCue*, LPCXACTCHANNELVOLUME pVolume); +STDAPI IXACTCue_SetMatrixCoefficients(IXACTCue*, UINT32 uSrcChannelCount, UINT32 uDstChannelCount, float* pMatrixCoefficients); +STDAPI_(XACTVARIABLEINDEX) IXACTCue_GetVariableIndex(IXACTCue* pCue, PCSTR szFriendlyName); +STDAPI IXACTCue_SetVariable(IXACTCue* pCue, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue); +STDAPI IXACTCue_GetVariable(IXACTCue* pCue, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* nValue); +STDAPI IXACTCue_Pause(IXACTCue* pCue, BOOL fPause); +#ifdef _XBOX +STDAPI IXACTCue_SetVoiceOutput(IXACTCue*, LPCXAUDIOVOICEOUTPUT pVoiceOutput); +STDAPI IXACTCue_SetVoiceOutputVolume(IXACTCue*, LPCXAUDIOVOICEOUTPUTVOLUME pVolume); +STDAPI IXACTCue_GetProperties(IXACTCue*, LPXACTCUEPROPERTIES pProperties); +#endif // _XBOX + +#undef INTERFACE +#define INTERFACE IXACTCue + +DECLARE_INTERFACE(IXACTCue) +{ + STDMETHOD(Play)(THIS) PURE; + STDMETHOD(Stop)(THIS_ DWORD dwFlags) PURE; + STDMETHOD(GetState)(THIS_ DWORD* pdwState) PURE; + STDMETHOD(Destroy)(THIS) PURE; + STDMETHOD(GetChannelMap)(THIS_ LPXACTCHANNELMAP pChannelMap, DWORD BufferSize, LPDWORD pRequiredSize) PURE; + STDMETHOD(SetChannelMap)(THIS_ LPCXACTCHANNELMAP pChannelMap) PURE; + STDMETHOD(GetChannelVolume)(THIS_ LPXACTCHANNELVOLUME pVolume) PURE; + STDMETHOD(SetChannelVolume)(THIS_ LPCXACTCHANNELVOLUME pVolume) PURE; + STDMETHOD(SetMatrixCoefficients)(THIS_ UINT32 uSrcChannelCount, UINT32 uDstChannelCount, float* pMatrixCoefficients) PURE; + STDMETHOD_(XACTVARIABLEINDEX, GetVariableIndex)(THIS_ PCSTR szFriendlyName) PURE; + STDMETHOD(SetVariable)(THIS_ XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue) PURE; + STDMETHOD(GetVariable)(THIS_ XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* nValue) PURE; + STDMETHOD(Pause)(THIS_ BOOL fPause) PURE; +#ifdef _XBOX + STDMETHOD(SetVoiceOutput)(THIS_ LPCXAUDIOVOICEOUTPUT pVoiceOutput) PURE; + STDMETHOD(SetVoiceOutputVolume)(THIS_ LPCXAUDIOVOICEOUTPUTVOLUME pVolume) PURE; + STDMETHOD(GetProperties)(THIS_ LPXACTCUEPROPERTIES pProperties) PURE; +#endif // _XBOX +}; + +#ifdef __cplusplus + +__inline HRESULT __stdcall IXACTCue_Play(IXACTCue* pCue) +{ + return pCue->Play(); +} + +__inline HRESULT __stdcall IXACTCue_Stop(IXACTCue* pCue, DWORD dwFlags) +{ + return pCue->Stop(dwFlags); +} + +__inline HRESULT __stdcall IXACTCue_GetState(IXACTCue* pCue, DWORD* pdwState) +{ + return pCue->GetState(pdwState); +} + +__inline HRESULT __stdcall IXACTCue_Destroy(IXACTCue* pCue) +{ + return pCue->Destroy(); +} + +__inline HRESULT __stdcall IXACTCue_GetChannelMap(IXACTCue* pCue, LPXACTCHANNELMAP pChannelMap, DWORD BufferSize, LPDWORD pRequiredSize) +{ + return pCue->GetChannelMap(pChannelMap, BufferSize, pRequiredSize); +} + +__inline HRESULT __stdcall IXACTCue_SetChannelMap(IXACTCue* pCue, LPCXACTCHANNELMAP pChannelMap) +{ + return pCue->SetChannelMap(pChannelMap); +} + +__inline HRESULT __stdcall IXACTCue_GetChannelVolume(IXACTCue* pCue, LPXACTCHANNELVOLUME pVolume) +{ + return pCue->GetChannelVolume(pVolume); +} + +__inline HRESULT __stdcall IXACTCue_SetChannelVolume(IXACTCue* pCue, LPCXACTCHANNELVOLUME pVolume) +{ + return pCue->SetChannelVolume(pVolume); +} + +__inline HRESULT __stdcall IXACTCue_SetMatrixCoefficients(IXACTCue* pCue, UINT32 uSrcChannelCount, UINT32 uDstChannelCount, float* pMatrixCoefficients) +{ + return pCue->SetMatrixCoefficients(uSrcChannelCount, uDstChannelCount, pMatrixCoefficients); +} + +__inline XACTVARIABLEINDEX __stdcall IXACTCue_GetVariableIndex(IXACTCue* pCue, PCSTR szFriendlyName) +{ + return pCue->GetVariableIndex(szFriendlyName); +} + +__inline HRESULT __stdcall IXACTCue_SetVariable(IXACTCue* pCue, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue) +{ + return pCue->SetVariable(nIndex, nValue); +} + +__inline HRESULT __stdcall IXACTCue_GetVariable(IXACTCue* pCue, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* pnValue) +{ + return pCue->GetVariable(nIndex, pnValue); +} + +__inline HRESULT __stdcall IXACTCue_Pause(IXACTCue* pCue, BOOL fPause) +{ + return pCue->Pause(fPause); +} + +#ifdef _XBOX +__inline HRESULT __stdcall IXACTCue_SetVoiceOutput(IXACTCue* pCue, LPCXAUDIOVOICEOUTPUT pVoiceOutput) +{ + return pCue->SetVoiceOutput(pVoiceOutput); +} + +__inline HRESULT __stdcall IXACTCue_SetVoiceOutputVolume(IXACTCue* pCue, LPCXAUDIOVOICEOUTPUTVOLUME pVolume) +{ + return pCue->SetVoiceOutputVolume(pVolume); +} + +__inline HRESULT __stdcall IXACTCue_GetProperties(IXACTCue* pCue, LPXACTCUEPROPERTIES pProperties) +{ + return pCue->GetProperties(pProperties); +} +#endif // _XBOX + +#else // __cplusplus + +__inline HRESULT __stdcall IXACTCue_Play(IXACTCue* pCue) +{ + return pCue->lpVtbl->Play(pCue); +} + +__inline HRESULT __stdcall IXACTCue_Stop(IXACTCue* pCue, DWORD dwFlags) +{ + return pCue->lpVtbl->Stop(pCue, dwFlags); +} + +__inline HRESULT __stdcall IXACTCue_GetState(IXACTCue* pCue, DWORD* pdwState) +{ + return pCue->lpVtbl->GetState(pCue, pdwState); +} + +__inline HRESULT __stdcall IXACTCue_Destroy(IXACTCue* pCue) +{ + return pCue->lpVtbl->Destroy(pCue); +} + +__inline HRESULT __stdcall IXACTCue_GetChannelMap(IXACTCue* pCue, LPXACTCHANNELMAP pChannelMap, DWORD BufferSize, LPDWORD pRequiredSize) +{ + return pCue->lpVtbl->GetChannelMap(pCue, pChannelMap, BufferSize, pRequiredSize); +} + +__inline HRESULT __stdcall IXACTCue_SetChannelMap(IXACTCue* pCue, LPCXACTCHANNELMAP pChannelMap) +{ + return pCue->lpVtbl->SetChannelMap(pCue, pChannelMap); +} + +__inline HRESULT __stdcall IXACTCue_GetChannelVolume(IXACTCue* pCue, LPXACTCHANNELVOLUME pVolume) +{ + return pCue->lpVtbl->GetChannelVolume(pCue, pVolume); +} + +__inline HRESULT __stdcall IXACTCue_SetChannelVolume(IXACTCue* pCue, LPCXACTCHANNELVOLUME pVolume) +{ + return pCue->lpVtbl->SetChannelVolume(pCue, pVolume); +} + +__inline HRESULT __stdcall IXACTCue_SetMatrixCoefficients(IXACTCue* pCue, UINT32 uSrcChannelCount, UINT32 uDstChannelCount, float* pMatrixCoefficients) +{ + return pCue->lpVtbl->SetMatrixCoefficients(pCue, uSrcChannelCount, uDstChannelCount, pMatrixCoefficients); +} + +__inline XACTVARIABLEINDEX __stdcall IXACTCue_GetVariableIndex(IXACTCue* pCue, PCSTR szFriendlyName) +{ + return pCue->lpVtbl->GetVariableIndex(pCue, szFriendlyName); +} + +__inline HRESULT __stdcall IXACTCue_SetVariable(IXACTCue* pCue, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue) +{ + return pCue->lpVtbl->SetVariable(pCue, nIndex, nValue); +} + +__inline HRESULT __stdcall IXACTCue_GetVariable(IXACTCue* pCue, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* pnValue) +{ + return pCue->lpVtbl->GetVariable(pCue, nIndex, pnValue); +} + +__inline HRESULT __stdcall IXACTCue_Pause(IXACTCue* pCue, BOOL fPause) +{ + return pCue->lpVtbl->Pause(pCue, fPause); +} + +#ifdef _XBOX +__inline HRESULT __stdcall IXACTCue_SetVoiceOutput(IXACTCue* pCue, LPCXAUDIOVOICEOUTPUT pVoiceOutput) +{ + return pCue->lpVtbl->SetVoiceOutput(pCue, pVoiceOutput); +} + +__inline HRESULT __stdcall IXACTCue_SetVoiceOutputVolume(IXACTCue* pCue, LPCXAUDIOVOICEOUTPUTVOLUME pVolume) +{ + return pCue->lpVtbl->SetVoiceOutputVolume(pCue, pVolume); +} + +__inline HRESULT __stdcall IXACTCue_GetProperties(IXACTCue* pCue, LPXACTCUEPROPERTIES pProperties) +{ + return pCue->lpVtbl->GetProperties(pCue, pProperties); +} +#endif // _XBOX + +#endif // __cplusplus + +//------------------------------------------------------------------------------ +// IXACTEngine +//------------------------------------------------------------------------------ + +// Engine flags +static const DWORD XACT_FLAG_ENGINE_CREATE_MANAGEDATA = 0x00000001; +static const DWORD XACT_FLAG_ENGINE_STOP_IMMEDIATE = 0x00000002; + +STDAPI_(ULONG) IXACTEngine_AddRef(IXACTEngine* pEngine); +STDAPI_(ULONG) IXACTEngine_Release(IXACTEngine* pEngine); +#ifndef _XBOX +STDAPI IXACTEngine_GetRendererCount(IXACTEngine* pEngine, XACTINDEX* pnRendererCount); +STDAPI IXACTEngine_GetRendererDetails(IXACTEngine* pEngine, XACTINDEX nRendererIndex, LPXACT_RENDERER_DETAILS pRendererDetails); +#endif +STDAPI IXACTEngine_Initialize(IXACTEngine* pEngine, const XACT_RUNTIME_PARAMETERS* pParams); +STDAPI IXACTEngine_ShutDown(IXACTEngine* pEngine); +STDAPI IXACTEngine_DoWork(IXACTEngine* pEngine); +STDAPI IXACTEngine_CreateSoundBank(IXACTEngine* pEngine, const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTSoundBank** ppSoundBank); +STDAPI IXACTEngine_CreateInMemoryWaveBank(IXACTEngine* pEngine, const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTWaveBank** ppWaveBank); +STDAPI IXACTEngine_CreateStreamingWaveBank(IXACTEngine* pEngine, const XACT_WAVEBANK_STREAMING_PARAMETERS* pParms, IXACTWaveBank** ppWaveBank); +STDAPI IXACTEngine_RegisterNotification(IXACTEngine* pEngine, const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc); +STDAPI IXACTEngine_UnRegisterNotification(IXACTEngine* pEngine, const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc); +STDAPI_(XACTCATEGORY) IXACTEngine_GetCategory(IXACTEngine* pEngine, PCSTR szFriendlyName); +STDAPI IXACTEngine_Stop(IXACTEngine* pEngine, XACTCATEGORY nCategory, DWORD dwFlags); +STDAPI IXACTEngine_SetVolume(IXACTEngine* pEngine, XACTCATEGORY nCategory, XACTVOLUME nVolume); +STDAPI IXACTEngine_Pause(IXACTEngine* pEngine, XACTCATEGORY nCategory, BOOL fPause); +STDAPI_(XACTVARIABLEINDEX) IXACTEngine_GetGlobalVariableIndex(IXACTEngine* pEngine, PCSTR szFriendlyName); +STDAPI IXACTEngine_SetGlobalVariable(IXACTEngine* pEngine, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue); +STDAPI IXACTEngine_GetGlobalVariable(IXACTEngine* pEngine, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* pnValue); + +#undef INTERFACE +#define INTERFACE IXACTEngine + +#ifdef _XBOX +DECLARE_INTERFACE(IXACTEngine) +{ +#else +DECLARE_INTERFACE_(IXACTEngine, IUnknown) +{ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, OUT void** ppvObj) PURE; +#endif + + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + +#ifndef _XBOX + STDMETHOD(GetRendererCount)(THIS_ XACTINDEX* pnRendererCount) PURE; + STDMETHOD(GetRendererDetails)(THIS_ XACTINDEX nRendererIndex, LPXACT_RENDERER_DETAILS pRendererDetails) PURE; +#endif + + STDMETHOD(Initialize)(THIS_ const XACT_RUNTIME_PARAMETERS* pParams) PURE; + STDMETHOD(ShutDown)(THIS) PURE; + + STDMETHOD(DoWork)(THIS) PURE; + + STDMETHOD(CreateSoundBank)(THIS_ const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTSoundBank** ppSoundBank) PURE; + STDMETHOD(CreateInMemoryWaveBank)(THIS_ const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTWaveBank** ppWaveBank) PURE; + STDMETHOD(CreateStreamingWaveBank)(THIS_ const XACT_WAVEBANK_STREAMING_PARAMETERS* pParms, IXACTWaveBank** ppWaveBank) PURE; + + STDMETHOD(RegisterNotification)(THIS_ const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc) PURE; + STDMETHOD(UnRegisterNotification)(THIS_ const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc) PURE; + + STDMETHOD_(XACTCATEGORY, GetCategory)(THIS_ PCSTR szFriendlyName) PURE; + STDMETHOD(Stop)(THIS_ XACTCATEGORY nCategory, DWORD dwFlags) PURE; + STDMETHOD(SetVolume)(THIS_ XACTCATEGORY nCategory, XACTVOLUME nVolume) PURE; + STDMETHOD(Pause)(THIS_ XACTCATEGORY nCategory, BOOL fPause) PURE; + + STDMETHOD_(XACTVARIABLEINDEX, GetGlobalVariableIndex)(THIS_ PCSTR szFriendlyName) PURE; + STDMETHOD(SetGlobalVariable)(THIS_ XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue) PURE; + STDMETHOD(GetGlobalVariable)(THIS_ XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* nValue) PURE; +}; + +#ifdef __cplusplus + +__inline ULONG __stdcall IXACTEngine_AddRef(IXACTEngine* pEngine) +{ + return pEngine->AddRef(); +} + +__inline ULONG __stdcall IXACTEngine_Release(IXACTEngine* pEngine) +{ + return pEngine->Release(); +} + +#ifndef _XBOX +__inline HRESULT __stdcall IXACTEngine_GetRendererCount(IXACTEngine* pEngine, XACTINDEX* pnRendererCount) +{ + return pEngine->GetRendererCount(pnRendererCount); +} + +__inline HRESULT __stdcall IXACTEngine_GetRendererDetails(IXACTEngine* pEngine, XACTINDEX nRendererIndex, LPXACT_RENDERER_DETAILS pRendererDetails) +{ + return pEngine->GetRendererDetails(nRendererIndex, pRendererDetails); +} +#endif + +__inline HRESULT __stdcall IXACTEngine_Initialize(IXACTEngine* pEngine, const XACT_RUNTIME_PARAMETERS* pParams) +{ + return pEngine->Initialize(pParams); +} + +__inline HRESULT __stdcall IXACTEngine_ShutDown(IXACTEngine* pEngine) +{ + return pEngine->ShutDown(); +} + +__inline HRESULT __stdcall IXACTEngine_DoWork(IXACTEngine* pEngine) +{ + return pEngine->DoWork(); +} + +__inline HRESULT __stdcall IXACTEngine_CreateSoundBank(IXACTEngine* pEngine, const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTSoundBank** ppSoundBank) +{ + return pEngine->CreateSoundBank(pvBuffer, dwSize, dwFlags, dwAllocAttributes, ppSoundBank); +} + +__inline HRESULT __stdcall IXACTEngine_CreateInMemoryWaveBank(IXACTEngine* pEngine, const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTWaveBank** ppWaveBank) +{ + return pEngine->CreateInMemoryWaveBank(pvBuffer, dwSize, dwFlags, dwAllocAttributes, ppWaveBank); +} + +__inline HRESULT __stdcall IXACTEngine_CreateStreamingWaveBank(IXACTEngine* pEngine, const XACT_WAVEBANK_STREAMING_PARAMETERS* pParms, IXACTWaveBank** ppWaveBank) +{ + return pEngine->CreateStreamingWaveBank(pParms, ppWaveBank); +} + +__inline HRESULT __stdcall IXACTEngine_RegisterNotification(IXACTEngine* pEngine, const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc) +{ + return pEngine->RegisterNotification(pNotificationDesc); +} + +__inline HRESULT __stdcall IXACTEngine_UnRegisterNotification(IXACTEngine* pEngine, const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc) +{ + return pEngine->UnRegisterNotification(pNotificationDesc); +} + +__inline XACTCATEGORY __stdcall IXACTEngine_GetCategory(IXACTEngine* pEngine, PCSTR szFriendlyName) +{ + return pEngine->GetCategory(szFriendlyName); +} + +__inline HRESULT __stdcall IXACTEngine_Stop(IXACTEngine* pEngine, XACTCATEGORY nCategory, DWORD dwFlags) +{ + return pEngine->Stop(nCategory, dwFlags); +} + +__inline HRESULT __stdcall IXACTEngine_SetVolume(IXACTEngine* pEngine, XACTCATEGORY nCategory, XACTVOLUME nVolume) +{ + return pEngine->SetVolume(nCategory, nVolume); +} + +__inline HRESULT __stdcall IXACTEngine_Pause(IXACTEngine* pEngine, XACTCATEGORY nCategory, BOOL fPause) +{ + return pEngine->Pause(nCategory, fPause); +} + +__inline XACTVARIABLEINDEX __stdcall IXACTEngine_GetGlobalVariableIndex(IXACTEngine* pEngine, PCSTR szFriendlyName) +{ + return pEngine->GetGlobalVariableIndex(szFriendlyName); +} + +__inline HRESULT __stdcall IXACTEngine_SetGlobalVariable(IXACTEngine* pEngine, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue) +{ + return pEngine->SetGlobalVariable(nIndex, nValue); +} + +__inline HRESULT __stdcall IXACTEngine_GetGlobalVariable(IXACTEngine* pEngine, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* nValue) +{ + return pEngine->GetGlobalVariable(nIndex, nValue); +} + +#else // __cplusplus + +__inline ULONG __stdcall IXACTEngine_AddRef(IXACTEngine* pEngine) +{ + return pEngine->lpVtbl->AddRef(pEngine); +} + +__inline ULONG __stdcall IXACTEngine_Release(IXACTEngine* pEngine) +{ + return pEngine->lpVtbl->Release(pEngine); +} + +#ifndef _XBOX +__inline HRESULT __stdcall IXACTEngine_GetRendererCount(IXACTEngine* pEngine, XACTINDEX* pnRendererCount) +{ + return pEngine->lpVtbl->GetRendererCount(pEngine, pnRendererCount); +} + +__inline HRESULT __stdcall IXACTEngine_GetRendererDetails(IXACTEngine* pEngine, XACTINDEX nRendererIndex, LPXACT_RENDERER_DETAILS pRendererDetails) +{ + return pEngine->lpVtbl->GetRendererDetails(pEngine, nRendererIndex, pRendererDetails); +} +#endif + +__inline HRESULT __stdcall IXACTEngine_Initialize(IXACTEngine* pEngine, const XACT_RUNTIME_PARAMETERS* pParams) +{ + return pEngine->lpVtbl->Initialize(pEngine, pParams); +} + +__inline HRESULT __stdcall IXACTEngine_ShutDown(IXACTEngine* pEngine) +{ + return pEngine->lpVtbl->ShutDown(pEngine); +} + +__inline HRESULT __stdcall IXACTEngine_DoWork(IXACTEngine* pEngine) +{ + return pEngine->lpVtbl->DoWork(pEngine); +} + +__inline HRESULT __stdcall IXACTEngine_CreateSoundBank(IXACTEngine* pEngine, const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTSoundBank** ppSoundBank) +{ + return pEngine->lpVtbl->CreateSoundBank(pEngine, pvBuffer, dwSize, dwFlags, dwAllocAttributes, ppSoundBank); +} + +__inline HRESULT __stdcall IXACTEngine_CreateInMemoryWaveBank(IXACTEngine* pEngine, const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTWaveBank** ppWaveBank) +{ + return pEngine->lpVtbl->CreateInMemoryWaveBank(pEngine, pvBuffer, dwSize, dwFlags, dwAllocAttributes, ppWaveBank); +} + +__inline HRESULT __stdcall IXACTEngine_CreateStreamingWaveBank(IXACTEngine* pEngine, const XACT_WAVEBANK_STREAMING_PARAMETERS* pParms, IXACTWaveBank** ppWaveBank) +{ + return pEngine->lpVtbl->CreateStreamingWaveBank(pEngine, pParms, ppWaveBank); +} + +__inline HRESULT __stdcall IXACTEngine_RegisterNotification(IXACTEngine* pEngine, const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc) +{ + return pEngine->lpVtbl->RegisterNotification(pEngine, pNotificationDesc); +} + +__inline HRESULT __stdcall IXACTEngine_UnRegisterNotification(IXACTEngine* pEngine, const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc) +{ + return pEngine->lpVtbl->UnRegisterNotification(pEngine, pNotificationDesc); +} + +__inline XACTCATEGORY __stdcall IXACTEngine_GetCategory(IXACTEngine* pEngine, PCSTR szFriendlyName) +{ + return pEngine->lpVtbl->GetCategory(pEngine, szFriendlyName); +} + +__inline HRESULT __stdcall IXACTEngine_Stop(IXACTEngine* pEngine, XACTCATEGORY nCategory, DWORD dwFlags) +{ + return pEngine->lpVtbl->Stop(pEngine, nCategory, dwFlags); +} + +__inline HRESULT __stdcall IXACTEngine_SetVolume(IXACTEngine* pEngine, XACTCATEGORY nCategory, XACTVOLUME nVolume) +{ + return pEngine->lpVtbl->SetVolume(pEngine, nCategory, nVolume); +} + +__inline HRESULT __stdcall IXACTEngine_Pause(IXACTEngine* pEngine, XACTCATEGORY nCategory, BOOL fPause) +{ + return pEngine->lpVtbl->Pause(pEngine, nCategory, fPause); +} + +__inline XACTVARIABLEINDEX __stdcall IXACTEngine_GetGlobalVariableIndex(IXACTEngine* pEngine, PCSTR szFriendlyName) +{ + return pEngine->lpVtbl->GetGlobalVariableIndex(pEngine, szFriendlyName); +} + +__inline HRESULT __stdcall IXACTEngine_SetGlobalVariable(IXACTEngine* pEngine, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue) +{ + return pEngine->lpVtbl->SetGlobalVariable(pEngine, nIndex, nValue); +} + +__inline HRESULT __stdcall IXACTEngine_GetGlobalVariable(IXACTEngine* pEngine, XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* nValue) +{ + return pEngine->lpVtbl->GetGlobalVariable(pEngine, nIndex, nValue); +} + +#endif // __cplusplus + +//------------------------------------------------------------------------------ +// XACT API's (these are deprecated and will be removed in a future release) +//------------------------------------------------------------------------------ + +#ifdef _XBOX + +static const DWORD XACT_FLAG_API_CREATE_MANAGEDATA = 0x00000001; +static const DWORD XACT_FLAG_API_STOP_IMMEDIATE = 0x00000002; + +STDAPI XACTInitialize(const XACT_RUNTIME_PARAMETERS* pParams); +STDAPI XACTShutDown(void); +STDAPI XACTDoWork(void); + +STDAPI XACTCreateSoundBank(const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTSoundBank** ppSoundBank); +STDAPI XACTCreateInMemoryWaveBank(const void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACTWaveBank** ppWaveBank); +STDAPI XACTCreateStreamingWaveBank(const XACT_WAVEBANK_STREAMING_PARAMETERS* pParms, IXACTWaveBank** ppWaveBank); + +STDAPI XACTRegisterNotification(const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc); +STDAPI XACTUnRegisterNotification(const XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc); + +STDAPI_(XACTCATEGORY) XACTGetCategory(PCSTR szFriendlyName); +STDAPI XACTStop(XACTCATEGORY nCategory, DWORD dwFlags); +STDAPI XACTSetVolume(XACTCATEGORY nCategory, XACTVOLUME nVolume); +STDAPI XACTPause(XACTCATEGORY nCategory, BOOL fPause); + +STDAPI_(XACTVARIABLEINDEX) XACTGetGlobalVariableIndex(PCSTR szFriendlyName); +STDAPI XACTSetGlobalVariable(XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue); +STDAPI XACTGetGlobalVariable(XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* pnValue); + +#endif // #ifdef _XBOX + +//------------------------------------------------------------------------------ +// Create Engine +//------------------------------------------------------------------------------ + +// Flags used only in XACTCreateEngine below. These flags are valid but ignored +// when building for Xbox 360; to enable auditioning on that platform you must +// link explicitly to an auditioning version of the XACT static library. +static const DWORD XACT_FLAG_API_AUDITION_MODE = 0x00000001; +static const DWORD XACT_FLAG_API_DEBUG_MODE = 0x00000002; + +STDAPI XACTCreateEngine(DWORD dwCreationFlags, IXACTEngine** ppEngine); + +#ifndef _XBOX + +#if defined (UNICODE) +# define XACT_DEBUGENGINE_REGISTRY_KEY L"Software\\Microsoft\\XACT" +# define XACT_DEBUGENGINE_REGISTRY_VALUE L"DebugEngine" +#else +# define XACT_DEBUGENGINE_REGISTRY_KEY "Software\\Microsoft\\XACT" +# define XACT_DEBUGENGINE_REGISTRY_VALUE "DebugEngine" +#endif + +#ifdef __cplusplus + +__inline HRESULT __stdcall XACTCreateEngine(DWORD dwCreationFlags, IXACTEngine** ppEngine) +{ + HKEY key; + DWORD data; + DWORD type = REG_DWORD; + DWORD dataSize = sizeof(DWORD); + BOOL debug = (dwCreationFlags & XACT_FLAG_API_DEBUG_MODE) ? TRUE : FALSE; + BOOL audition = (dwCreationFlags & XACT_FLAG_API_AUDITION_MODE) ? TRUE : FALSE; + + // If neither the debug nor audition flags are set, see if the debug registry key is set + if(!debug && !audition && + (RegOpenKeyEx(HKEY_LOCAL_MACHINE, XACT_DEBUGENGINE_REGISTRY_KEY, 0, KEY_READ, &key) == ERROR_SUCCESS)) + { + if(RegQueryValueEx(key, XACT_DEBUGENGINE_REGISTRY_VALUE, NULL, &type, (LPBYTE)&data, &dataSize) == ERROR_SUCCESS) + { + if(data) + { + debug = TRUE; + } + } + RegCloseKey(key); + } + + return CoCreateInstance(audition ? __uuidof(XACTAuditionEngine) + : (debug ? __uuidof(XACTDebugEngine) : __uuidof(XACTEngine)), + NULL, CLSCTX_INPROC_SERVER, __uuidof(IXACTEngine), (void**)ppEngine); +} + +#else + +__inline HRESULT __stdcall XACTCreateEngine(DWORD dwCreationFlags, IXACTEngine** ppEngine) +{ + HKEY key; + DWORD data; + DWORD type = REG_DWORD; + DWORD dataSize = sizeof(DWORD); + BOOL debug = (dwCreationFlags & XACT_FLAG_API_DEBUG_MODE) ? TRUE : FALSE; + BOOL audition = (dwCreationFlags & XACT_FLAG_API_AUDITION_MODE) ? TRUE : FALSE; + + // If neither the debug nor audition flags are set, see if the debug registry key is set + if(!debug && !audition && + (RegOpenKeyEx(HKEY_LOCAL_MACHINE, XACT_DEBUGENGINE_REGISTRY_KEY, 0, KEY_READ, &key) == ERROR_SUCCESS)) + { + if(RegQueryValueEx(key, XACT_DEBUGENGINE_REGISTRY_VALUE, NULL, &type, (LPBYTE)&data, &dataSize) == ERROR_SUCCESS) + { + if(data) + { + debug = TRUE; + } + } + RegCloseKey(key); + } + + return CoCreateInstance(audition ? &CLSID_XACTAuditionEngine + : (debug ? &CLSID_XACTDebugEngine : &CLSID_XACTEngine), + NULL, CLSCTX_INPROC_SERVER, &IID_IXACTEngine, (void**)ppEngine); +} + +#endif // #ifdef __cplusplus +#endif // #ifndef _XBOX + +//------------------------------------------------------------------------------ +// XACT specific error codes +//------------------------------------------------------------------------------ + +#define FACILITY_XACTENGINE 0xAC7 +#define XACTENGINEERROR(n) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_XACTENGINE, n) + +#define XACTENGINE_E_OUTOFMEMORY E_OUTOFMEMORY // Out of memory +#define XACTENGINE_E_INVALIDARG E_INVALIDARG // Invalid arg +#define XACTENGINE_E_NOTIMPL E_NOTIMPL // Not implemented +#define XACTENGINE_E_FAIL E_FAIL // Unknown error + +#define XACTENGINE_E_ALREADYINITIALIZED XACTENGINEERROR(0x001) // The engine is already initialized +#define XACTENGINE_E_NOTINITIALIZED XACTENGINEERROR(0x002) // The engine has not been initialized +#define XACTENGINE_E_EXPIRED XACTENGINEERROR(0x003) // The engine has expired (demo or pre-release version) +#define XACTENGINE_E_NONOTIFICATIONCALLBACK XACTENGINEERROR(0x004) // No notification callback +#define XACTENGINE_E_NOTIFICATIONREGISTERED XACTENGINEERROR(0x005) // Notification already registered +#define XACTENGINE_E_INVALIDUSAGE XACTENGINEERROR(0x006) // Invalid usage +#define XACTENGINE_E_INVALIDDATA XACTENGINEERROR(0x007) // Invalid data +#define XACTENGINE_E_INSTANCELIMITFAILTOPLAY XACTENGINEERROR(0x008) // Fail to play due to instance limit +#define XACTENGINE_E_NOGLOBALSETTINGS XACTENGINEERROR(0x009) // Global Settings not loaded +#define XACTENGINE_E_INVALIDVARIABLEINDEX XACTENGINEERROR(0x00a) // Invalid variable index +#define XACTENGINE_E_INVALIDCATEGORY XACTENGINEERROR(0x00b) // Invalid category +#define XACTENGINE_E_INVALIDCUEINDEX XACTENGINEERROR(0x00c) // Invalid cue index +#define XACTENGINE_E_INVALIDWAVEINDEX XACTENGINEERROR(0x00d) // Invalid wave index +#define XACTENGINE_E_INVALIDTRACKINDEX XACTENGINEERROR(0x00e) // Invalid track index +#define XACTENGINE_E_INVALIDSOUNDOFFSETORINDEX XACTENGINEERROR(0x00f) // Invalid sound offset or index +#define XACTENGINE_E_READFILE XACTENGINEERROR(0x010) // Error reading a file +#define XACTENGINE_E_UNKNOWNEVENT XACTENGINEERROR(0x011) // Unknown event type +#define XACTENGINE_E_INCALLBACK XACTENGINEERROR(0x012) // Invalid call of method of function from callback +#define XACTENGINE_E_NOWAVEBANK XACTENGINEERROR(0x013) // No wavebank exists for desired operation +#define XACTENGINE_E_SELECTVARIATION XACTENGINEERROR(0x014) // Unable to select a variation +#define XACTENGINE_E_MULTIPLEAUDITIONENGINES XACTENGINEERROR(0x015) // There can be only one audition engine +#define XACTENGINE_E_WAVEBANKNOTPREPARED XACTENGINEERROR(0x016) // The wavebank is not prepared +#define XACTENGINE_E_NORENDERER XACTENGINEERROR(0x017) // No audio device found on. +#define XACTENGINE_E_INVALIDENTRYCOUNT XACTENGINEERROR(0x018) // Invalid entry count for channel maps +#define XACTENGINE_E_SEEKTIMEBEYONDCUEEND XACTENGINEERROR(0x19) // Time offset for seeking is beyond the cue end. + +#define XACTENGINE_E_AUDITION_WRITEFILE XACTENGINEERROR(0x101) // Error writing a file during auditioning +#define XACTENGINE_E_AUDITION_NOSOUNDBANK XACTENGINEERROR(0x102) // Missing a soundbank +#define XACTENGINE_E_AUDITION_INVALIDRPCINDEX XACTENGINEERROR(0x103) // Missing an RPC curve +#define XACTENGINE_E_AUDITION_MISSINGDATA XACTENGINEERROR(0x104) // Missing data for an audition command +#define XACTENGINE_E_AUDITION_UNKNOWNCOMMAND XACTENGINEERROR(0x105) // Unknown command +#define XACTENGINE_E_AUDITION_INVALIDDSPINDEX XACTENGINEERROR(0x106) // Missing a DSP parameter + +#endif // #ifndef GUID_DEFS_ONLY +#endif // #ifndef _XACT_H_ diff --git a/src/dep/include/DXSDK/include/xact2wb.h b/src/dep/include/DXSDK/include/xact2wb.h index 21ab08a..06af8b8 100644 --- a/src/dep/include/DXSDK/include/xact2wb.h +++ b/src/dep/include/DXSDK/include/xact2wb.h @@ -1,398 +1,398 @@ -/*************************************************************************** - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: xact2wb.h - * Content: XACT 2 wave bank definitions. - * - ****************************************************************************/ - -#ifndef __XACTWB_H__ -#define __XACTWB_H__ - -#ifdef _XBOX -# include -#else -# include -#endif - -#include - -#pragma warning(push) -#pragma warning(disable:4201) -#pragma warning(disable:4214) // nonstandard extension used : bit field types other than int - -#pragma pack(push, 1) - -#ifdef _M_PPCBE -#pragma bitfield_order(push, lsb_to_msb) -#endif - -#define WAVEBANK_HEADER_SIGNATURE 'DNBW' - -#define WAVEBANK_HEADER_VERSION XACT_CONTENT_VERSION // Current tool version - -#define WAVEBANK_BANKNAME_LENGTH 64 // Wave bank friendly name length, in characters -#define WAVEBANK_ENTRYNAME_LENGTH 64 // Wave bank entry friendly name length, in characters - -#define WAVEBANK_MAX_DATA_SEGMENT_SIZE 0xFFFFFFFF // Maximum wave bank data segment size, in bytes -#define WAVEBANK_MAX_COMPACT_DATA_SEGMENT_SIZE 0x001FFFFF // Maximum compact wave bank data segment size, in bytes - -typedef DWORD WAVEBANKOFFSET; - -// -// Bank flags -// - -#define WAVEBANK_TYPE_BUFFER 0x00000000 // In-memory buffer -#define WAVEBANK_TYPE_STREAMING 0x00000001 // Streaming -#define WAVEBANK_TYPE_MASK 0x00000001 - -#define WAVEBANK_FLAGS_ENTRYNAMES 0x00010000 // Bank includes entry names -#define WAVEBANK_FLAGS_COMPACT 0x00020000 // Bank uses compact format -#define WAVEBANK_FLAGS_SYNC_DISABLED 0x00040000 // Bank is disabled for audition sync -#define WAVEBANK_FLAGS_MASK 0x00070000 - -// -// Entry flags -// - -#define WAVEBANKENTRY_FLAGS_READAHEAD 0x00000001 // Enable stream read-ahead -#define WAVEBANKENTRY_FLAGS_LOOPCACHE 0x00000002 // One or more looping sounds use this wave -#define WAVEBANKENTRY_FLAGS_REMOVELOOPTAIL 0x00000004 // Remove data after the end of the loop region -#define WAVEBANKENTRY_FLAGS_IGNORELOOP 0x00000008 // Used internally when the loop region can't be used -#define WAVEBANKENTRY_FLAGS_MASK 0x00000008 - -// -// Entry wave format identifiers -// - -#define WAVEBANKMINIFORMAT_TAG_PCM 0x0 // PCM data -#define WAVEBANKMINIFORMAT_TAG_XMA 0x1 // XMA data -#define WAVEBANKMINIFORMAT_TAG_ADPCM 0x2 // ADPCM data - -#define WAVEBANKMINIFORMAT_BITDEPTH_8 0x0 // 8-bit data (PCM only) -#define WAVEBANKMINIFORMAT_BITDEPTH_16 0x1 // 16-bit data (PCM only) - -// -// Arbitrary fixed sizes -// -#define WAVEBANKENTRY_XMASTREAMS_MAX 3 // enough for 5.1 channel audio -#define WAVEBANKENTRY_XMACHANNELS_MAX 6 // enough for 5.1 channel audio (cf. XAUDIOCHANNEL_SOURCEMAX) - -// -// DVD data sizes -// - -#define WAVEBANK_DVD_SECTOR_SIZE 2048 -#define WAVEBANK_DVD_BLOCK_SIZE (WAVEBANK_DVD_SECTOR_SIZE * 16) - -// -// Bank alignment presets -// - -#define WAVEBANK_ALIGNMENT_MIN 4 // Minimum alignment -#define WAVEBANK_ALIGNMENT_DVD WAVEBANK_DVD_SECTOR_SIZE // DVD-optimized alignment - -// -// Wave bank segment identifiers -// - -typedef enum WAVEBANKSEGIDX -{ - WAVEBANK_SEGIDX_BANKDATA = 0, // Bank data - WAVEBANK_SEGIDX_ENTRYMETADATA, // Entry meta-data - WAVEBANK_SEGIDX_ENTRYNAMES, // Entry friendly names - WAVEBANK_SEGIDX_EXTRA, // Storage for extra metadata defined by the wave entry - WAVEBANK_SEGIDX_ENTRYWAVEDATA, // Entry wave data - WAVEBANK_SEGIDX_COUNT -} WAVEBANKSEGIDX, *LPWAVEBANKSEGIDX; - -typedef const WAVEBANKSEGIDX *LPCWAVEBANKSEGIDX; - -// -// Endianness -// - -#ifdef __cplusplus - -namespace XACTWaveBank -{ - __inline void SwapBytes(DWORD &dw) - { - -#ifdef _X86_ - - __asm - { - mov edi, dw - mov eax, [edi] - bswap eax - mov [edi], eax - } - -#else // _X86_ - - dw = _byteswap_ulong(dw); - -#endif // _X86_ - - } - - __inline void SwapBytes(WORD &w) - { - -#ifdef _X86_ - - __asm - { - mov edi, w - mov ax, [edi] - xchg ah, al - mov [edi], ax - } - -#else // _X86_ - - w = _byteswap_ushort(w); - -#endif // _X86_ - - } - -} - -#endif // __cplusplus - -// -// Wave bank region -// - -typedef struct WAVEBANKREGION -{ - DWORD dwOffset; // Region offset, in bytes - DWORD dwLength; // Region length, in bytes - -#ifdef __cplusplus - - void SwapBytes(void) - { - XACTWaveBank::SwapBytes(dwOffset); - XACTWaveBank::SwapBytes(dwLength); - } - -#endif // __cplusplus - -} WAVEBANKREGION, *LPWAVEBANKREGION; - -typedef const WAVEBANKREGION *LPCWAVEBANKREGION; - -// -// Wave bank file header -// - -typedef struct WAVEBANKHEADER -{ - DWORD dwSignature; // File signature - DWORD dwVersion; // Version of the tool that created the file - WAVEBANKREGION Segments[WAVEBANK_SEGIDX_COUNT]; // Segment lookup table - -#ifdef __cplusplus - - void SwapBytes(void) - { - XACTWaveBank::SwapBytes(dwSignature); - XACTWaveBank::SwapBytes(dwVersion); - - for(int i = 0; i < WAVEBANK_SEGIDX_COUNT; i++) - { - Segments[i].SwapBytes(); - } - } - -#endif // __cplusplus - -} WAVEBANKHEADER, *LPWAVEBANKHEADER; - -typedef const WAVEBANKHEADER *LPCWAVEBANKHEADER; - -// -// Entry compressed data format -// - -typedef union WAVEBANKMINIWAVEFORMAT -{ - struct - { - DWORD wFormatTag : 2; // Format tag - DWORD nChannels : 3; // Channel count (1 - 6) - DWORD nSamplesPerSec : 18; // Sampling rate - DWORD wBlockAlign : 8; // Block alignment - DWORD wBitsPerSample : 1; // Bits per sample (8 vs. 16, PCM only) - }; - - DWORD dwValue; - -#ifdef __cplusplus - - void SwapBytes(void) - { - XACTWaveBank::SwapBytes(dwValue); - } - - WORD BitsPerSample() const - { - return wBitsPerSample == WAVEBANKMINIFORMAT_BITDEPTH_16 ? 16 : 8; - } - - #define ADPCM_MINIWAVEFORMAT_BLOCKALIGN_CONVERSION_OFFSET 22 - DWORD BlockAlign() const - { - return wFormatTag != WAVEBANKMINIFORMAT_TAG_ADPCM ? wBlockAlign : - (wBlockAlign + ADPCM_MINIWAVEFORMAT_BLOCKALIGN_CONVERSION_OFFSET) * nChannels; - } - -#endif // __cplusplus - -} WAVEBANKMINIWAVEFORMAT, *LPWAVEBANKMINIWAVEFORMAT; - -typedef const WAVEBANKMINIWAVEFORMAT *LPCWAVEBANKMINIWAVEFORMAT; - -// -// Entry meta-data -// - -typedef struct WAVEBANKENTRY -{ - union - { - struct - { - // Entry flags - DWORD dwFlags : 4; - - // Duration of the wave, in units of one sample. - // For instance, a ten second long wave sampled - // at 48KHz would have a duration of 480,000. - // This value is not affected by the number of - // channels, the number of bits per sample, or the - // compression format of the wave. - DWORD Duration : 28; - }; - DWORD dwFlagsAndDuration; - }; - - WAVEBANKMINIWAVEFORMAT Format; // Entry format - WAVEBANKREGION PlayRegion; // Region within the wave data segment that contains this entry - - union - { - WAVEBANKREGION LoopRegion; // Region within the wave data that should loop - - // XMA loop region - // Note: this is not the same memory layout as the XMA loop region - // passed to the XMA driver--it is more compact. The named values - // map correctly and there are enough bits to store the entire - // range of values that XMA considers valid, with one exception: - // valid values for nSubframeSkip are 1, 2, 3, or 4. In order to - // store this in two bits, XACT subtracts 1 from the value, then adds - - struct - { - DWORD dwStartOffset; // loop start offset (in bits) - - DWORD nSubframeSkip : 2; // needed by XMA decoder. Valid values for XMA are 1-4; XACT converts to 0-3 for storage. Add 1 to this value before passing to driver. - DWORD nSubframeEnd : 2; // needed by XMA decoder - DWORD dwEndOffset : 28; // loop end offset (in bits) - } XMALoopRegion[ WAVEBANKENTRY_XMASTREAMS_MAX ]; - - // The last element in the union is an array that aliases the - // entire union so we can byte-reverse the whole thing. - WAVEBANKREGION LoopRegionAlias[ WAVEBANKENTRY_XMASTREAMS_MAX ]; - }; - -#ifdef __cplusplus - - void SwapBytes(void) - { - XACTWaveBank::SwapBytes(dwFlagsAndDuration); - Format.SwapBytes(); - PlayRegion.SwapBytes(); - for( int i = 0; i < WAVEBANKENTRY_XMASTREAMS_MAX; ++i ) - { - LoopRegionAlias[i].SwapBytes(); - } - } - -#endif // __cplusplus - -} WAVEBANKENTRY, *LPWAVEBANKENTRY; - -typedef const WAVEBANKENTRY *LPCWAVEBANKENTRY; - -// -// Compact entry meta-data -// - -typedef struct WAVEBANKENTRYCOMPACT -{ - DWORD dwOffset : 21; // Data offset, in sectors - DWORD dwLengthDeviation : 11; // Data length deviation, in bytes - -#ifdef __cplusplus - - void SwapBytes(void) - { - XACTWaveBank::SwapBytes(*(LPDWORD)this); - } - -#endif // __cplusplus - -} WAVEBANKENTRYCOMPACT, *LPWAVEBANKENTRYCOMPACT; - -typedef const WAVEBANKENTRYCOMPACT *LPCWAVEBANKENTRYCOMPACT; - -// -// Bank data segment -// - -typedef struct WAVEBANKDATA -{ - DWORD dwFlags; // Bank flags - DWORD dwEntryCount; // Number of entries in the bank - CHAR szBankName[WAVEBANK_BANKNAME_LENGTH]; // Bank friendly name - DWORD dwEntryMetaDataElementSize; // Size of each entry meta-data element, in bytes - DWORD dwEntryNameElementSize; // Size of each entry name element, in bytes - DWORD dwAlignment; // Entry alignment, in bytes - WAVEBANKMINIWAVEFORMAT CompactFormat; // Format data for compact bank - FILETIME BuildTime; // Build timestamp - -#ifdef __cplusplus - - void SwapBytes(void) - { - XACTWaveBank::SwapBytes(dwFlags); - XACTWaveBank::SwapBytes(dwEntryCount); - XACTWaveBank::SwapBytes(dwEntryMetaDataElementSize); - XACTWaveBank::SwapBytes(dwEntryNameElementSize); - XACTWaveBank::SwapBytes(dwAlignment); - CompactFormat.SwapBytes(); - XACTWaveBank::SwapBytes(BuildTime.dwLowDateTime); - XACTWaveBank::SwapBytes(BuildTime.dwHighDateTime); - } - -#endif // __cplusplus - -} WAVEBANKDATA, *LPWAVEBANKDATA; - -typedef const WAVEBANKDATA *LPCWAVEBANKDATA; - -#ifdef _M_PPCBE -#pragma bitfield_order(pop) -#endif - -#pragma warning(pop) -#pragma pack(pop) - -#endif // __XACTWB_H__ - +/*************************************************************************** + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: xact2wb.h + * Content: XACT 2 wave bank definitions. + * + ****************************************************************************/ + +#ifndef __XACTWB_H__ +#define __XACTWB_H__ + +#ifdef _XBOX +# include +#else +# include +#endif + +#include + +#pragma warning(push) +#pragma warning(disable:4201) +#pragma warning(disable:4214) // nonstandard extension used : bit field types other than int + +#pragma pack(push, 1) + +#ifdef _M_PPCBE +#pragma bitfield_order(push, lsb_to_msb) +#endif + +#define WAVEBANK_HEADER_SIGNATURE 'DNBW' + +#define WAVEBANK_HEADER_VERSION XACT_CONTENT_VERSION // Current tool version + +#define WAVEBANK_BANKNAME_LENGTH 64 // Wave bank friendly name length, in characters +#define WAVEBANK_ENTRYNAME_LENGTH 64 // Wave bank entry friendly name length, in characters + +#define WAVEBANK_MAX_DATA_SEGMENT_SIZE 0xFFFFFFFF // Maximum wave bank data segment size, in bytes +#define WAVEBANK_MAX_COMPACT_DATA_SEGMENT_SIZE 0x001FFFFF // Maximum compact wave bank data segment size, in bytes + +typedef DWORD WAVEBANKOFFSET; + +// +// Bank flags +// + +#define WAVEBANK_TYPE_BUFFER 0x00000000 // In-memory buffer +#define WAVEBANK_TYPE_STREAMING 0x00000001 // Streaming +#define WAVEBANK_TYPE_MASK 0x00000001 + +#define WAVEBANK_FLAGS_ENTRYNAMES 0x00010000 // Bank includes entry names +#define WAVEBANK_FLAGS_COMPACT 0x00020000 // Bank uses compact format +#define WAVEBANK_FLAGS_SYNC_DISABLED 0x00040000 // Bank is disabled for audition sync +#define WAVEBANK_FLAGS_MASK 0x00070000 + +// +// Entry flags +// + +#define WAVEBANKENTRY_FLAGS_READAHEAD 0x00000001 // Enable stream read-ahead +#define WAVEBANKENTRY_FLAGS_LOOPCACHE 0x00000002 // One or more looping sounds use this wave +#define WAVEBANKENTRY_FLAGS_REMOVELOOPTAIL 0x00000004 // Remove data after the end of the loop region +#define WAVEBANKENTRY_FLAGS_IGNORELOOP 0x00000008 // Used internally when the loop region can't be used +#define WAVEBANKENTRY_FLAGS_MASK 0x00000008 + +// +// Entry wave format identifiers +// + +#define WAVEBANKMINIFORMAT_TAG_PCM 0x0 // PCM data +#define WAVEBANKMINIFORMAT_TAG_XMA 0x1 // XMA data +#define WAVEBANKMINIFORMAT_TAG_ADPCM 0x2 // ADPCM data + +#define WAVEBANKMINIFORMAT_BITDEPTH_8 0x0 // 8-bit data (PCM only) +#define WAVEBANKMINIFORMAT_BITDEPTH_16 0x1 // 16-bit data (PCM only) + +// +// Arbitrary fixed sizes +// +#define WAVEBANKENTRY_XMASTREAMS_MAX 3 // enough for 5.1 channel audio +#define WAVEBANKENTRY_XMACHANNELS_MAX 6 // enough for 5.1 channel audio (cf. XAUDIOCHANNEL_SOURCEMAX) + +// +// DVD data sizes +// + +#define WAVEBANK_DVD_SECTOR_SIZE 2048 +#define WAVEBANK_DVD_BLOCK_SIZE (WAVEBANK_DVD_SECTOR_SIZE * 16) + +// +// Bank alignment presets +// + +#define WAVEBANK_ALIGNMENT_MIN 4 // Minimum alignment +#define WAVEBANK_ALIGNMENT_DVD WAVEBANK_DVD_SECTOR_SIZE // DVD-optimized alignment + +// +// Wave bank segment identifiers +// + +typedef enum WAVEBANKSEGIDX +{ + WAVEBANK_SEGIDX_BANKDATA = 0, // Bank data + WAVEBANK_SEGIDX_ENTRYMETADATA, // Entry meta-data + WAVEBANK_SEGIDX_ENTRYNAMES, // Entry friendly names + WAVEBANK_SEGIDX_EXTRA, // Storage for extra metadata defined by the wave entry + WAVEBANK_SEGIDX_ENTRYWAVEDATA, // Entry wave data + WAVEBANK_SEGIDX_COUNT +} WAVEBANKSEGIDX, *LPWAVEBANKSEGIDX; + +typedef const WAVEBANKSEGIDX *LPCWAVEBANKSEGIDX; + +// +// Endianness +// + +#ifdef __cplusplus + +namespace XACTWaveBank +{ + __inline void SwapBytes(DWORD &dw) + { + +#ifdef _X86_ + + __asm + { + mov edi, dw + mov eax, [edi] + bswap eax + mov [edi], eax + } + +#else // _X86_ + + dw = _byteswap_ulong(dw); + +#endif // _X86_ + + } + + __inline void SwapBytes(WORD &w) + { + +#ifdef _X86_ + + __asm + { + mov edi, w + mov ax, [edi] + xchg ah, al + mov [edi], ax + } + +#else // _X86_ + + w = _byteswap_ushort(w); + +#endif // _X86_ + + } + +} + +#endif // __cplusplus + +// +// Wave bank region +// + +typedef struct WAVEBANKREGION +{ + DWORD dwOffset; // Region offset, in bytes + DWORD dwLength; // Region length, in bytes + +#ifdef __cplusplus + + void SwapBytes(void) + { + XACTWaveBank::SwapBytes(dwOffset); + XACTWaveBank::SwapBytes(dwLength); + } + +#endif // __cplusplus + +} WAVEBANKREGION, *LPWAVEBANKREGION; + +typedef const WAVEBANKREGION *LPCWAVEBANKREGION; + +// +// Wave bank file header +// + +typedef struct WAVEBANKHEADER +{ + DWORD dwSignature; // File signature + DWORD dwVersion; // Version of the tool that created the file + WAVEBANKREGION Segments[WAVEBANK_SEGIDX_COUNT]; // Segment lookup table + +#ifdef __cplusplus + + void SwapBytes(void) + { + XACTWaveBank::SwapBytes(dwSignature); + XACTWaveBank::SwapBytes(dwVersion); + + for(int i = 0; i < WAVEBANK_SEGIDX_COUNT; i++) + { + Segments[i].SwapBytes(); + } + } + +#endif // __cplusplus + +} WAVEBANKHEADER, *LPWAVEBANKHEADER; + +typedef const WAVEBANKHEADER *LPCWAVEBANKHEADER; + +// +// Entry compressed data format +// + +typedef union WAVEBANKMINIWAVEFORMAT +{ + struct + { + DWORD wFormatTag : 2; // Format tag + DWORD nChannels : 3; // Channel count (1 - 6) + DWORD nSamplesPerSec : 18; // Sampling rate + DWORD wBlockAlign : 8; // Block alignment + DWORD wBitsPerSample : 1; // Bits per sample (8 vs. 16, PCM only) + }; + + DWORD dwValue; + +#ifdef __cplusplus + + void SwapBytes(void) + { + XACTWaveBank::SwapBytes(dwValue); + } + + WORD BitsPerSample() const + { + return wBitsPerSample == WAVEBANKMINIFORMAT_BITDEPTH_16 ? 16 : 8; + } + + #define ADPCM_MINIWAVEFORMAT_BLOCKALIGN_CONVERSION_OFFSET 22 + DWORD BlockAlign() const + { + return wFormatTag != WAVEBANKMINIFORMAT_TAG_ADPCM ? wBlockAlign : + (wBlockAlign + ADPCM_MINIWAVEFORMAT_BLOCKALIGN_CONVERSION_OFFSET) * nChannels; + } + +#endif // __cplusplus + +} WAVEBANKMINIWAVEFORMAT, *LPWAVEBANKMINIWAVEFORMAT; + +typedef const WAVEBANKMINIWAVEFORMAT *LPCWAVEBANKMINIWAVEFORMAT; + +// +// Entry meta-data +// + +typedef struct WAVEBANKENTRY +{ + union + { + struct + { + // Entry flags + DWORD dwFlags : 4; + + // Duration of the wave, in units of one sample. + // For instance, a ten second long wave sampled + // at 48KHz would have a duration of 480,000. + // This value is not affected by the number of + // channels, the number of bits per sample, or the + // compression format of the wave. + DWORD Duration : 28; + }; + DWORD dwFlagsAndDuration; + }; + + WAVEBANKMINIWAVEFORMAT Format; // Entry format + WAVEBANKREGION PlayRegion; // Region within the wave data segment that contains this entry + + union + { + WAVEBANKREGION LoopRegion; // Region within the wave data that should loop + + // XMA loop region + // Note: this is not the same memory layout as the XMA loop region + // passed to the XMA driver--it is more compact. The named values + // map correctly and there are enough bits to store the entire + // range of values that XMA considers valid, with one exception: + // valid values for nSubframeSkip are 1, 2, 3, or 4. In order to + // store this in two bits, XACT subtracts 1 from the value, then adds + + struct + { + DWORD dwStartOffset; // loop start offset (in bits) + + DWORD nSubframeSkip : 2; // needed by XMA decoder. Valid values for XMA are 1-4; XACT converts to 0-3 for storage. Add 1 to this value before passing to driver. + DWORD nSubframeEnd : 2; // needed by XMA decoder + DWORD dwEndOffset : 28; // loop end offset (in bits) + } XMALoopRegion[ WAVEBANKENTRY_XMASTREAMS_MAX ]; + + // The last element in the union is an array that aliases the + // entire union so we can byte-reverse the whole thing. + WAVEBANKREGION LoopRegionAlias[ WAVEBANKENTRY_XMASTREAMS_MAX ]; + }; + +#ifdef __cplusplus + + void SwapBytes(void) + { + XACTWaveBank::SwapBytes(dwFlagsAndDuration); + Format.SwapBytes(); + PlayRegion.SwapBytes(); + for( int i = 0; i < WAVEBANKENTRY_XMASTREAMS_MAX; ++i ) + { + LoopRegionAlias[i].SwapBytes(); + } + } + +#endif // __cplusplus + +} WAVEBANKENTRY, *LPWAVEBANKENTRY; + +typedef const WAVEBANKENTRY *LPCWAVEBANKENTRY; + +// +// Compact entry meta-data +// + +typedef struct WAVEBANKENTRYCOMPACT +{ + DWORD dwOffset : 21; // Data offset, in sectors + DWORD dwLengthDeviation : 11; // Data length deviation, in bytes + +#ifdef __cplusplus + + void SwapBytes(void) + { + XACTWaveBank::SwapBytes(*(LPDWORD)this); + } + +#endif // __cplusplus + +} WAVEBANKENTRYCOMPACT, *LPWAVEBANKENTRYCOMPACT; + +typedef const WAVEBANKENTRYCOMPACT *LPCWAVEBANKENTRYCOMPACT; + +// +// Bank data segment +// + +typedef struct WAVEBANKDATA +{ + DWORD dwFlags; // Bank flags + DWORD dwEntryCount; // Number of entries in the bank + CHAR szBankName[WAVEBANK_BANKNAME_LENGTH]; // Bank friendly name + DWORD dwEntryMetaDataElementSize; // Size of each entry meta-data element, in bytes + DWORD dwEntryNameElementSize; // Size of each entry name element, in bytes + DWORD dwAlignment; // Entry alignment, in bytes + WAVEBANKMINIWAVEFORMAT CompactFormat; // Format data for compact bank + FILETIME BuildTime; // Build timestamp + +#ifdef __cplusplus + + void SwapBytes(void) + { + XACTWaveBank::SwapBytes(dwFlags); + XACTWaveBank::SwapBytes(dwEntryCount); + XACTWaveBank::SwapBytes(dwEntryMetaDataElementSize); + XACTWaveBank::SwapBytes(dwEntryNameElementSize); + XACTWaveBank::SwapBytes(dwAlignment); + CompactFormat.SwapBytes(); + XACTWaveBank::SwapBytes(BuildTime.dwLowDateTime); + XACTWaveBank::SwapBytes(BuildTime.dwHighDateTime); + } + +#endif // __cplusplus + +} WAVEBANKDATA, *LPWAVEBANKDATA; + +typedef const WAVEBANKDATA *LPCWAVEBANKDATA; + +#ifdef _M_PPCBE +#pragma bitfield_order(pop) +#endif + +#pragma warning(pop) +#pragma pack(pop) + +#endif // __XACTWB_H__ + diff --git a/src/dep/include/DXSDK/include/xact3d.h b/src/dep/include/DXSDK/include/xact3d.h index 39c1ad7..bfd2142 100644 --- a/src/dep/include/DXSDK/include/xact3d.h +++ b/src/dep/include/DXSDK/include/xact3d.h @@ -1,210 +1,210 @@ -/*-========================================================================-_ - | - XACT3D - | - | Copyright (c) Microsoft Corporation. All rights reserved. | - |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| - |VERSION: 0.1 MODEL: Unmanaged User-mode | - |CONTRACT: N / A EXCEPT: No Exceptions | - |PARENT: N / A MINREQ: Win2000, Xbox360 | - |PROJECT: XACT3D DIALECT: MS Visual C++ 7.0 | - |>------------------------------------------------------------------------<| - | DUTY: XACT 3D support | - ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ - NOTES: - 1. See X3DAudio.h for information regarding X3DAudio types. */ - - -#ifndef __XACT3D_H__ -#define __XACT3D_H__ -//---------------------------------------------------// - #include - #include - - // Supported speaker positions, represented as azimuth angles. - // - // Here's a picture of the azimuth angles for the 8 cardinal points, - // seen from above. The emitter's base position is at the origin 0. - // - // FRONT - // | 0 <-- azimuth - // | - // 7pi/4 \ | / pi/4 - // \ | / - // LEFT \|/ RIGHT - // 3pi/2-------0-------pi/2 - // /|\ - // / | \ - // 5pi/4 / | \ 3pi/4 - // | - // | pi - // BACK - // - #define LEFT_AZIMUTH (3*X3DAUDIO_PI/2) - #define RIGHT_AZIMUTH (X3DAUDIO_PI/2) - #define FRONT_LEFT_AZIMUTH (7*X3DAUDIO_PI/4) - #define FRONT_RIGHT_AZIMUTH (X3DAUDIO_PI/4) - #define FRONT_CENTER_AZIMUTH 0.0f - #define LOW_FREQUENCY_AZIMUTH X3DAUDIO_2PI - #define BACK_LEFT_AZIMUTH (5*X3DAUDIO_PI/4) - #define BACK_RIGHT_AZIMUTH (3*X3DAUDIO_PI/4) - #define BACK_CENTER_AZIMUTH X3DAUDIO_PI - #define FRONT_LEFT_OF_CENTER_AZIMUTH (15*X3DAUDIO_PI/8) - #define FRONT_RIGHT_OF_CENTER_AZIMUTH (X3DAUDIO_PI/8) - - -//-----------------------------------------------------// - // Supported emitter channel layouts: - static const float aStereoLayout[] = - { - LEFT_AZIMUTH, - RIGHT_AZIMUTH - }; - static const float a2Point1Layout[] = - { - LEFT_AZIMUTH, - RIGHT_AZIMUTH, - LOW_FREQUENCY_AZIMUTH - }; - static const float aQuadLayout[] = - { - FRONT_LEFT_AZIMUTH, - FRONT_RIGHT_AZIMUTH, - BACK_LEFT_AZIMUTH, - BACK_RIGHT_AZIMUTH - }; - static const float a5Point1Layout[] = - { - FRONT_LEFT_AZIMUTH, - FRONT_RIGHT_AZIMUTH, - FRONT_CENTER_AZIMUTH, - LOW_FREQUENCY_AZIMUTH, - BACK_LEFT_AZIMUTH, - BACK_RIGHT_AZIMUTH - }; - static const float a7Point1Layout[] = - { - FRONT_LEFT_AZIMUTH, - FRONT_RIGHT_AZIMUTH, - FRONT_CENTER_AZIMUTH, - LOW_FREQUENCY_AZIMUTH, - BACK_LEFT_AZIMUTH, - BACK_RIGHT_AZIMUTH, - LEFT_AZIMUTH, - RIGHT_AZIMUTH - }; - - -//-------------------------------------------------------// - //// - // DESCRIPTION: - // Initializes the 3D API's: - // - // REMARKS: - // This method only needs to be called once - // - // PARAMETERS: - // SpeakerChannelMask - [in] speaker geometry configuration on the final mix, specifies assignment of channels to speaker positions, defined as per WAVEFORMATEXTENSIBLE.dwChannelMask, must be != 0 - // Currently only SPEAKER_STEREO and SPEAKER_5POINT1 is supported by X3DAudio. - // pEngine - [in] pointer to the XACT engine - // X3DInstance - [out] Handle to the X3DAudio instance - // - // RETURN VALUE: - // HResult error code - //// - EXTERN_C HRESULT inline XACT3DInitialize (UINT32 SpeakerChannelMask, IXACTEngine* pEngine, X3DAUDIO_HANDLE X3DInstance) - { - XACTVARIABLEINDEX xactSpeedOfSoundID = pEngine->GetGlobalVariableIndex("SpeedOfSound"); - XACTVARIABLEVALUE nSpeedOfSound; - HRESULT hr = pEngine->GetGlobalVariable(xactSpeedOfSoundID, &nSpeedOfSound); - - if (SUCCEEDED(hr)) { - X3DAudioInitialize(SpeakerChannelMask, nSpeedOfSound, X3DInstance); - } - - return hr; - } - - //// - // DESCRIPTION: - // Calculates DSP settings with respect to 3D parameters: - // - // REMARKS: - // The number of bits set in SpeakerChannelMask should equal the number of - // channels expected on the final mix. - // - // PARAMETERS: - // X3DInstance - [in] X3DAudio instance (returned from XACT3DInitialize) - // pListener - [in] point of 3D audio reception - // pEmitter - [in] 3D audio source - // pDSPSettings - [out] receives calculation results, applied to an XACT cue via XACT3DApply - // - // RETURN VALUE: - // HResult error code - //// - EXTERN_C HRESULT inline XACT3DCalculate (X3DAUDIO_HANDLE X3DInstance, const X3DAUDIO_LISTENER* pListener, X3DAUDIO_EMITTER* pEmitter, X3DAUDIO_DSP_SETTINGS* pDSPSettings) - { - HRESULT hr = S_OK; - if (pEmitter->ChannelCount > 1 && pEmitter->pChannelAzimuths == NULL) { - pEmitter->ChannelRadius = 1.0f; - - switch (pEmitter->ChannelCount) { - case 2: pEmitter->pChannelAzimuths = (float*)&aStereoLayout[0]; break; - case 3: pEmitter->pChannelAzimuths = (float*)&a2Point1Layout[0]; break; - case 4: pEmitter->pChannelAzimuths = (float*)&aQuadLayout[0]; break; - case 6: pEmitter->pChannelAzimuths = (float*)&a5Point1Layout[0]; break; - case 8: pEmitter->pChannelAzimuths = (float*)&a7Point1Layout[0]; break; - default: hr = E_FAIL; break; - } - } - - if(SUCCEEDED(hr)) - { - static X3DAUDIO_DISTANCE_CURVE_POINT DefaultCurvePoints[2] = { 0.0f, 1.0f, 1.0f, 1.0f }; - static X3DAUDIO_DISTANCE_CURVE DefaultCurve = { (X3DAUDIO_DISTANCE_CURVE_POINT*)&DefaultCurvePoints[0], 2 }; - if (pEmitter->pVolumeCurve == NULL) { - pEmitter->pVolumeCurve = &DefaultCurve; - } - if (pEmitter->pLFECurve == NULL) { - pEmitter->pLFECurve = &DefaultCurve; - } - - X3DAudioCalculate(X3DInstance, pListener, pEmitter, X3DAUDIO_CALCULATE_MATRIX | X3DAUDIO_CALCULATE_DOPPLER | X3DAUDIO_CALCULATE_EMITTER_ANGLE, pDSPSettings); - } - - return hr; - } - - - //// - // DESCRIPTION: - // Applies a 3D calculation returned by XACT3DCalculate to a cue: - // - // PARAMETERS: - // pDSPSettings - [in] calculation results generated by XACT3DCalculate - // pCue - [in] cue to which to apply pDSPSettings - // - // RETURN VALUE: - // HResult error code - //// - EXTERN_C HRESULT inline XACT3DApply (X3DAUDIO_DSP_SETTINGS* pDSPSettings, IXACTCue* pCue) - { - HRESULT hr = pCue->SetMatrixCoefficients(pDSPSettings->SrcChannelCount, pDSPSettings->DstChannelCount, pDSPSettings->pMatrixCoefficients); - - if (SUCCEEDED(hr)) { - XACTVARIABLEINDEX xactDistanceID = pCue->GetVariableIndex("Distance"); - hr = pCue->SetVariable(xactDistanceID, pDSPSettings->EmitterToListenerDistance); - } - if (SUCCEEDED(hr)) { - XACTVARIABLEINDEX xactDopplerID = pCue->GetVariableIndex("DopplerPitchScalar"); - hr = pCue->SetVariable(xactDopplerID, pDSPSettings->DopplerFactor); - } - if (SUCCEEDED(hr)) { - XACTVARIABLEINDEX xactOrientationID = pCue->GetVariableIndex("OrientationAngle"); - hr = pCue->SetVariable(xactOrientationID, pDSPSettings->EmitterToListenerAngle * (180.0f / X3DAUDIO_PI)); - } - - return hr; - } - - -#endif // __XACT3D_H__ -//---------------------------------<-EOF->----------------------------------// +/*-========================================================================-_ + | - XACT3D - | + | Copyright (c) Microsoft Corporation. All rights reserved. | + |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| + |VERSION: 0.1 MODEL: Unmanaged User-mode | + |CONTRACT: N / A EXCEPT: No Exceptions | + |PARENT: N / A MINREQ: Win2000, Xbox360 | + |PROJECT: XACT3D DIALECT: MS Visual C++ 7.0 | + |>------------------------------------------------------------------------<| + | DUTY: XACT 3D support | + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ + NOTES: + 1. See X3DAudio.h for information regarding X3DAudio types. */ + + +#ifndef __XACT3D_H__ +#define __XACT3D_H__ +//---------------------------------------------------// + #include + #include + + // Supported speaker positions, represented as azimuth angles. + // + // Here's a picture of the azimuth angles for the 8 cardinal points, + // seen from above. The emitter's base position is at the origin 0. + // + // FRONT + // | 0 <-- azimuth + // | + // 7pi/4 \ | / pi/4 + // \ | / + // LEFT \|/ RIGHT + // 3pi/2-------0-------pi/2 + // /|\ + // / | \ + // 5pi/4 / | \ 3pi/4 + // | + // | pi + // BACK + // + #define LEFT_AZIMUTH (3*X3DAUDIO_PI/2) + #define RIGHT_AZIMUTH (X3DAUDIO_PI/2) + #define FRONT_LEFT_AZIMUTH (7*X3DAUDIO_PI/4) + #define FRONT_RIGHT_AZIMUTH (X3DAUDIO_PI/4) + #define FRONT_CENTER_AZIMUTH 0.0f + #define LOW_FREQUENCY_AZIMUTH X3DAUDIO_2PI + #define BACK_LEFT_AZIMUTH (5*X3DAUDIO_PI/4) + #define BACK_RIGHT_AZIMUTH (3*X3DAUDIO_PI/4) + #define BACK_CENTER_AZIMUTH X3DAUDIO_PI + #define FRONT_LEFT_OF_CENTER_AZIMUTH (15*X3DAUDIO_PI/8) + #define FRONT_RIGHT_OF_CENTER_AZIMUTH (X3DAUDIO_PI/8) + + +//-----------------------------------------------------// + // Supported emitter channel layouts: + static const float aStereoLayout[] = + { + LEFT_AZIMUTH, + RIGHT_AZIMUTH + }; + static const float a2Point1Layout[] = + { + LEFT_AZIMUTH, + RIGHT_AZIMUTH, + LOW_FREQUENCY_AZIMUTH + }; + static const float aQuadLayout[] = + { + FRONT_LEFT_AZIMUTH, + FRONT_RIGHT_AZIMUTH, + BACK_LEFT_AZIMUTH, + BACK_RIGHT_AZIMUTH + }; + static const float a5Point1Layout[] = + { + FRONT_LEFT_AZIMUTH, + FRONT_RIGHT_AZIMUTH, + FRONT_CENTER_AZIMUTH, + LOW_FREQUENCY_AZIMUTH, + BACK_LEFT_AZIMUTH, + BACK_RIGHT_AZIMUTH + }; + static const float a7Point1Layout[] = + { + FRONT_LEFT_AZIMUTH, + FRONT_RIGHT_AZIMUTH, + FRONT_CENTER_AZIMUTH, + LOW_FREQUENCY_AZIMUTH, + BACK_LEFT_AZIMUTH, + BACK_RIGHT_AZIMUTH, + LEFT_AZIMUTH, + RIGHT_AZIMUTH + }; + + +//-------------------------------------------------------// + //// + // DESCRIPTION: + // Initializes the 3D API's: + // + // REMARKS: + // This method only needs to be called once + // + // PARAMETERS: + // SpeakerChannelMask - [in] speaker geometry configuration on the final mix, specifies assignment of channels to speaker positions, defined as per WAVEFORMATEXTENSIBLE.dwChannelMask, must be != 0 + // Currently only SPEAKER_STEREO and SPEAKER_5POINT1 is supported by X3DAudio. + // pEngine - [in] pointer to the XACT engine + // X3DInstance - [out] Handle to the X3DAudio instance + // + // RETURN VALUE: + // HResult error code + //// + EXTERN_C HRESULT inline XACT3DInitialize (UINT32 SpeakerChannelMask, IXACTEngine* pEngine, X3DAUDIO_HANDLE X3DInstance) + { + XACTVARIABLEINDEX xactSpeedOfSoundID = pEngine->GetGlobalVariableIndex("SpeedOfSound"); + XACTVARIABLEVALUE nSpeedOfSound; + HRESULT hr = pEngine->GetGlobalVariable(xactSpeedOfSoundID, &nSpeedOfSound); + + if (SUCCEEDED(hr)) { + X3DAudioInitialize(SpeakerChannelMask, nSpeedOfSound, X3DInstance); + } + + return hr; + } + + //// + // DESCRIPTION: + // Calculates DSP settings with respect to 3D parameters: + // + // REMARKS: + // The number of bits set in SpeakerChannelMask should equal the number of + // channels expected on the final mix. + // + // PARAMETERS: + // X3DInstance - [in] X3DAudio instance (returned from XACT3DInitialize) + // pListener - [in] point of 3D audio reception + // pEmitter - [in] 3D audio source + // pDSPSettings - [out] receives calculation results, applied to an XACT cue via XACT3DApply + // + // RETURN VALUE: + // HResult error code + //// + EXTERN_C HRESULT inline XACT3DCalculate (X3DAUDIO_HANDLE X3DInstance, const X3DAUDIO_LISTENER* pListener, X3DAUDIO_EMITTER* pEmitter, X3DAUDIO_DSP_SETTINGS* pDSPSettings) + { + HRESULT hr = S_OK; + if (pEmitter->ChannelCount > 1 && pEmitter->pChannelAzimuths == NULL) { + pEmitter->ChannelRadius = 1.0f; + + switch (pEmitter->ChannelCount) { + case 2: pEmitter->pChannelAzimuths = (float*)&aStereoLayout[0]; break; + case 3: pEmitter->pChannelAzimuths = (float*)&a2Point1Layout[0]; break; + case 4: pEmitter->pChannelAzimuths = (float*)&aQuadLayout[0]; break; + case 6: pEmitter->pChannelAzimuths = (float*)&a5Point1Layout[0]; break; + case 8: pEmitter->pChannelAzimuths = (float*)&a7Point1Layout[0]; break; + default: hr = E_FAIL; break; + } + } + + if(SUCCEEDED(hr)) + { + static X3DAUDIO_DISTANCE_CURVE_POINT DefaultCurvePoints[2] = { 0.0f, 1.0f, 1.0f, 1.0f }; + static X3DAUDIO_DISTANCE_CURVE DefaultCurve = { (X3DAUDIO_DISTANCE_CURVE_POINT*)&DefaultCurvePoints[0], 2 }; + if (pEmitter->pVolumeCurve == NULL) { + pEmitter->pVolumeCurve = &DefaultCurve; + } + if (pEmitter->pLFECurve == NULL) { + pEmitter->pLFECurve = &DefaultCurve; + } + + X3DAudioCalculate(X3DInstance, pListener, pEmitter, X3DAUDIO_CALCULATE_MATRIX | X3DAUDIO_CALCULATE_DOPPLER | X3DAUDIO_CALCULATE_EMITTER_ANGLE, pDSPSettings); + } + + return hr; + } + + + //// + // DESCRIPTION: + // Applies a 3D calculation returned by XACT3DCalculate to a cue: + // + // PARAMETERS: + // pDSPSettings - [in] calculation results generated by XACT3DCalculate + // pCue - [in] cue to which to apply pDSPSettings + // + // RETURN VALUE: + // HResult error code + //// + EXTERN_C HRESULT inline XACT3DApply (X3DAUDIO_DSP_SETTINGS* pDSPSettings, IXACTCue* pCue) + { + HRESULT hr = pCue->SetMatrixCoefficients(pDSPSettings->SrcChannelCount, pDSPSettings->DstChannelCount, pDSPSettings->pMatrixCoefficients); + + if (SUCCEEDED(hr)) { + XACTVARIABLEINDEX xactDistanceID = pCue->GetVariableIndex("Distance"); + hr = pCue->SetVariable(xactDistanceID, pDSPSettings->EmitterToListenerDistance); + } + if (SUCCEEDED(hr)) { + XACTVARIABLEINDEX xactDopplerID = pCue->GetVariableIndex("DopplerPitchScalar"); + hr = pCue->SetVariable(xactDopplerID, pDSPSettings->DopplerFactor); + } + if (SUCCEEDED(hr)) { + XACTVARIABLEINDEX xactOrientationID = pCue->GetVariableIndex("OrientationAngle"); + hr = pCue->SetVariable(xactOrientationID, pDSPSettings->EmitterToListenerAngle * (180.0f / X3DAUDIO_PI)); + } + + return hr; + } + + +#endif // __XACT3D_H__ +//---------------------------------<-EOF->----------------------------------// diff --git a/src/dep/include/irrlicht/EDriverTypes.h b/src/dep/include/irrlicht/EDriverTypes.h index 17f429a..8413919 100644 --- a/src/dep/include/irrlicht/EDriverTypes.h +++ b/src/dep/include/irrlicht/EDriverTypes.h @@ -1,55 +1,55 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_DRIVER_TYPES_H_INCLUDED__ -#define __E_DRIVER_TYPES_H_INCLUDED__ - -namespace irr -{ -namespace video -{ - //! An enum for all types of drivers the Irrlicht Engine supports. - enum E_DRIVER_TYPE - { - //! Null device, useful for applications to run the engine without visualisation. - //! The null device is able to load textures, but does not render and display - //! any graphics. - EDT_NULL, - - //! The Irrlicht Engine Software renderer, runs on all platforms, - //! with every hardware. It should only be used for 2d graphics, - //! but it can also perform some primitive 3d functions. These 3d drawing - //! functions are quite fast, but very inaccurate, and don't even support - //! clipping in 3D mode. - EDT_SOFTWARE, - - //! The Burning's Software Renderer, an alternative software renderer for Irrlicht. - //! Basically it can be described as the Irrlicht Software renderer on steroids. It rasterizes - //! 3D geometry perfectly: It is able to perform correct 3d clipping, perspective - //! correct texture mapping, perspective correct color mapping, and renders - //! sub pixel correct, sub texel correct primitives. In addition, it does - //! bilinear texel filtering and supports more materials than the EDT_SOFTWARE driver. - //! This renderer has been written entirely by Thomas Alten, thanks a lot for this huge - //! contribution. - EDT_BURNINGSVIDEO, - - //! Direct3D 8 device, only available on Win32 platforms including Win95, Win98, WinNT, - //! Win2K, WinXP. Performs hardware accelerated rendering of 3D and 2D primitives. - EDT_DIRECT3D8, - - //! Direct3D 9 device, only available on Win32 platforms including Win95, Win98, WinNT, - //! Win2K, WinXP. Performs hardware accelerated rendering of 3D and 2D primitives. - EDT_DIRECT3D9, - - //! OpenGL device, available on all Win32 platforms and on Linux. - //! Performs hardware accelerated rendering of 3D and 2D primitives. - EDT_OPENGL - }; - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __E_DRIVER_TYPES_H_INCLUDED__ +#define __E_DRIVER_TYPES_H_INCLUDED__ + +namespace irr +{ +namespace video +{ + //! An enum for all types of drivers the Irrlicht Engine supports. + enum E_DRIVER_TYPE + { + //! Null device, useful for applications to run the engine without visualisation. + //! The null device is able to load textures, but does not render and display + //! any graphics. + EDT_NULL, + + //! The Irrlicht Engine Software renderer, runs on all platforms, + //! with every hardware. It should only be used for 2d graphics, + //! but it can also perform some primitive 3d functions. These 3d drawing + //! functions are quite fast, but very inaccurate, and don't even support + //! clipping in 3D mode. + EDT_SOFTWARE, + + //! The Burning's Software Renderer, an alternative software renderer for Irrlicht. + //! Basically it can be described as the Irrlicht Software renderer on steroids. It rasterizes + //! 3D geometry perfectly: It is able to perform correct 3d clipping, perspective + //! correct texture mapping, perspective correct color mapping, and renders + //! sub pixel correct, sub texel correct primitives. In addition, it does + //! bilinear texel filtering and supports more materials than the EDT_SOFTWARE driver. + //! This renderer has been written entirely by Thomas Alten, thanks a lot for this huge + //! contribution. + EDT_BURNINGSVIDEO, + + //! Direct3D 8 device, only available on Win32 platforms including Win95, Win98, WinNT, + //! Win2K, WinXP. Performs hardware accelerated rendering of 3D and 2D primitives. + EDT_DIRECT3D8, + + //! Direct3D 9 device, only available on Win32 platforms including Win95, Win98, WinNT, + //! Win2K, WinXP. Performs hardware accelerated rendering of 3D and 2D primitives. + EDT_DIRECT3D9, + + //! OpenGL device, available on all Win32 platforms and on Linux. + //! Performs hardware accelerated rendering of 3D and 2D primitives. + EDT_OPENGL + }; + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/EGUIElementTypes.h b/src/dep/include/irrlicht/EGUIElementTypes.h index 7e8e895..28c2bef 100644 --- a/src/dep/include/irrlicht/EGUIElementTypes.h +++ b/src/dep/include/irrlicht/EGUIElementTypes.h @@ -1,119 +1,119 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_GUI_ELEMENT_TYPES_H_INCLUDED__ -#define __E_GUI_ELEMENT_TYPES_H_INCLUDED__ - -namespace irr -{ -namespace gui -{ - -//! List of all basic Irrlicht GUI elements. -/** An IGUIElement returns this when calling IGUIElement::getType(); */ -enum EGUI_ELEMENT_TYPE -{ - //! A button (IGUIButton) - EGUIET_BUTTON = 0, - - //! A check box (IGUICheckBox) - EGUIET_CHECK_BOX, - - //! A combo box (IGUIComboBox) - EGUIET_COMBO_BOX, - - //! A context menu (IGUIContextMenu) - EGUIET_CONTEXT_MENU, - - //! A menu (IGUIMenu) - EGUIET_MENU, - - //! An edit box (IGUIEditBox) - EGUIET_EDIT_BOX, - - //! A file open dialog (IGUIFileOpenDialog) - EGUIET_FILE_OPEN_DIALOG, - - //! A color select open dialog (IGUIColorSelectDialog) - EGUIET_COLOR_SELECT_DIALOG, - - //! A in/out fader (IGUIInOutFader) - EGUIET_IN_OUT_FADER, - - //! An image (IGUIImage) - EGUIET_IMAGE, - - //! A list box (IGUIListBox) - EGUIET_LIST_BOX, - - //! A mesh viewer (IGUIMeshViewer) - EGUIET_MESH_VIEWER, - - //! A message box (IGUIWindow) - EGUIET_MESSAGE_BOX, - - //! A modal screen - EGUIET_MODAL_SCREEN, - - //! A scroll bar (IGUIScrollBar) - EGUIET_SCROLL_BAR, - - //! A static text (IGUIStaticText) - EGUIET_STATIC_TEXT, - - //! A tab (IGUITab) - EGUIET_TAB, - - //! A tab control - EGUIET_TAB_CONTROL, - - //! A tool bar (IGUIToolBar) - EGUIET_TOOL_BAR, - - //! A window - EGUIET_WINDOW, - - //! Not an element, amount of elements in there - EGUIET_COUNT, - - //! Unknown type. - EGUIET_ELEMENT, - - //! This enum is never used, it only forces the compiler to - //! compile these enumeration values to 32 bit. - EGUIET_FORCE_32_BIT = 0x7fffffff - -}; - -//! Names for built-in element types -const c8* const GUIElementTypeNames[] = -{ - "button", - "checkBox", - "comboBox", - "contextMenu", - "menu", - "editBox", - "fileOpenDialog", - "colorSelectDialog", - "inOutFader", - "image", - "listBox", - "meshViewer", - "messageBox", - "modalScreen", - "scrollBar", - "staticText", - "tab", - "tabControl", - "toolBar", - "window", - 0 -}; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __E_GUI_ELEMENT_TYPES_H_INCLUDED__ +#define __E_GUI_ELEMENT_TYPES_H_INCLUDED__ + +namespace irr +{ +namespace gui +{ + +//! List of all basic Irrlicht GUI elements. +/** An IGUIElement returns this when calling IGUIElement::getType(); */ +enum EGUI_ELEMENT_TYPE +{ + //! A button (IGUIButton) + EGUIET_BUTTON = 0, + + //! A check box (IGUICheckBox) + EGUIET_CHECK_BOX, + + //! A combo box (IGUIComboBox) + EGUIET_COMBO_BOX, + + //! A context menu (IGUIContextMenu) + EGUIET_CONTEXT_MENU, + + //! A menu (IGUIMenu) + EGUIET_MENU, + + //! An edit box (IGUIEditBox) + EGUIET_EDIT_BOX, + + //! A file open dialog (IGUIFileOpenDialog) + EGUIET_FILE_OPEN_DIALOG, + + //! A color select open dialog (IGUIColorSelectDialog) + EGUIET_COLOR_SELECT_DIALOG, + + //! A in/out fader (IGUIInOutFader) + EGUIET_IN_OUT_FADER, + + //! An image (IGUIImage) + EGUIET_IMAGE, + + //! A list box (IGUIListBox) + EGUIET_LIST_BOX, + + //! A mesh viewer (IGUIMeshViewer) + EGUIET_MESH_VIEWER, + + //! A message box (IGUIWindow) + EGUIET_MESSAGE_BOX, + + //! A modal screen + EGUIET_MODAL_SCREEN, + + //! A scroll bar (IGUIScrollBar) + EGUIET_SCROLL_BAR, + + //! A static text (IGUIStaticText) + EGUIET_STATIC_TEXT, + + //! A tab (IGUITab) + EGUIET_TAB, + + //! A tab control + EGUIET_TAB_CONTROL, + + //! A tool bar (IGUIToolBar) + EGUIET_TOOL_BAR, + + //! A window + EGUIET_WINDOW, + + //! Not an element, amount of elements in there + EGUIET_COUNT, + + //! Unknown type. + EGUIET_ELEMENT, + + //! This enum is never used, it only forces the compiler to + //! compile these enumeration values to 32 bit. + EGUIET_FORCE_32_BIT = 0x7fffffff + +}; + +//! Names for built-in element types +const c8* const GUIElementTypeNames[] = +{ + "button", + "checkBox", + "comboBox", + "contextMenu", + "menu", + "editBox", + "fileOpenDialog", + "colorSelectDialog", + "inOutFader", + "image", + "listBox", + "meshViewer", + "messageBox", + "modalScreen", + "scrollBar", + "staticText", + "tab", + "tabControl", + "toolBar", + "window", + 0 +}; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/ESceneNodeAnimatorTypes.h b/src/dep/include/irrlicht/ESceneNodeAnimatorTypes.h index d5b44b7..72f9023 100644 --- a/src/dep/include/irrlicht/ESceneNodeAnimatorTypes.h +++ b/src/dep/include/irrlicht/ESceneNodeAnimatorTypes.h @@ -1,52 +1,52 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_SCENE_NODE_ANIMATOR_TYPES_H_INCLUDED__ -#define __E_SCENE_NODE_ANIMATOR_TYPES_H_INCLUDED__ - -namespace irr -{ -namespace scene -{ - //! An enumeration for all types of built-in scene node animators - enum ESCENE_NODE_ANIMATOR_TYPE - { - //! Fly circle scene node animator - ESNAT_FLY_CIRCLE = 0, - - //! Fly straight scene node animator - ESNAT_FLY_STRAIGHT, - - //! Follow spline scene node animator - ESNAT_FOLLOW_SPLINE, - - //! Rotation scene node animator - ESNAT_ROTATION, - - //! Texture scene node animator - ESNAT_TEXTURE, - - //! Deletion scene node animator - ESNAT_DELETION, - - //! Collision respose scene node animator - ESNAT_COLLISION_RESPONSE, - - //! Amount of build in scene node animators - ESNAT_COUNT, - - //! Unknown scene node animator - ESNAT_UNKNOWN, - - //! This enum is never used, it only forces the compiler to - //! compile these enumeration values to 32 bit. - ESNAT_FORCE_32_BIT = 0x7fffffff - }; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __E_SCENE_NODE_ANIMATOR_TYPES_H_INCLUDED__ +#define __E_SCENE_NODE_ANIMATOR_TYPES_H_INCLUDED__ + +namespace irr +{ +namespace scene +{ + //! An enumeration for all types of built-in scene node animators + enum ESCENE_NODE_ANIMATOR_TYPE + { + //! Fly circle scene node animator + ESNAT_FLY_CIRCLE = 0, + + //! Fly straight scene node animator + ESNAT_FLY_STRAIGHT, + + //! Follow spline scene node animator + ESNAT_FOLLOW_SPLINE, + + //! Rotation scene node animator + ESNAT_ROTATION, + + //! Texture scene node animator + ESNAT_TEXTURE, + + //! Deletion scene node animator + ESNAT_DELETION, + + //! Collision respose scene node animator + ESNAT_COLLISION_RESPONSE, + + //! Amount of build in scene node animators + ESNAT_COUNT, + + //! Unknown scene node animator + ESNAT_UNKNOWN, + + //! This enum is never used, it only forces the compiler to + //! compile these enumeration values to 32 bit. + ESNAT_FORCE_32_BIT = 0x7fffffff + }; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/ESceneNodeTypes.h b/src/dep/include/irrlicht/ESceneNodeTypes.h index 998b539..0e555a8 100644 --- a/src/dep/include/irrlicht/ESceneNodeTypes.h +++ b/src/dep/include/irrlicht/ESceneNodeTypes.h @@ -1,130 +1,130 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_SCENE_NODE_TYPES_H_INCLUDED__ -#define __E_SCENE_NODE_TYPES_H_INCLUDED__ - -namespace irr -{ -namespace scene -{ - //! An enumeration for all types of built-in scene nodes - enum ESCENE_NODE_TYPE - { - //! simple cube scene node - ESNT_CUBE = 0, - - //! Sphere scene node - ESNT_SPHERE, - - //! Text Scene Node - ESNT_TEXT, - - //! Water Surface Scene Node - ESNT_WATER_SURFACE, - - //! Terrain Scene Node - ESNT_TERRAIN, - - //! Sky Box Scene Node - ESNT_SKY_BOX, - - //! Shadow Volume Scene Node - ESNT_SHADOW_VOLUME, - - //! OctTree Scene Node - ESNT_OCT_TREE, - - //! Mesh Scene Node - ESNT_MESH, - - //! Light Scene Node - ESNT_LIGHT, - - //! Empty Scene Node - ESNT_EMPTY, - - //! Dummy Transformation Scene Node - ESNT_DUMMY_TRANSFORMATION, - - //! Camera Scene Node - ESNT_CAMERA, - - //! Maya Camera Scene Node - ESNT_CAMERA_MAYA, - - //! First Person Shooter style Camera - ESNT_CAMERA_FPS, - - //! Billboard Scene Node - ESNT_BILLBOARD, - - //! Animated Mesh Scene Node - ESNT_ANIMATED_MESH, - - //! Particle System Scene Node - ESNT_PARTICLE_SYSTEM, - - //! Quake3 Model Scene Node ( has tag to link to ) - ESNT_MD3_SCENE_NODE, - - //! Amount of build in Scene Nodes - ESNT_COUNT, - - //! Unknown scene node - ESNT_UNKNOWN, - - //! This enum is never used, it only forces the compiler to - //! compile these enumeration values to 32 bit. - ESNT_FORCE_32_BIT = 0x7fffffff - }; - - - //! An enumeration for all types of automatic culling for built-in scene nodes - enum E_CULLING_TYPE - { - EAC_OFF = 0, - EAC_BOX, - EAC_FRUSTUM_BOX, - EAC_FRUSTUM_SPHERE - }; - - //! Names for culling type - const c8* const AutomaticCullingNames[] = - { - "false", - "box", // camera box against node box - "frustum_box", // camera frustum against node box - "frustum_sphere", // camera frustum against node sphere - 0 - }; - - //! An enumeration for all types of debug data for built-in scene nodes (flags) - enum E_DEBUG_SCENE_TYPE - { - //! No Debug Data ( Default ) - EDS_OFF = 0, - //! Show Bounding Boxes of SceneNode - EDS_BBOX = 1, - //! Show Vertex Normals - EDS_NORMALS = 2, - //! Shows Skeleton/Tags - EDS_SKELETON = 4, - //! Overlays Mesh Wireframe - EDS_MESH_WIRE_OVERLAY = 8, - //! Temporary use transparency Material Type - EDS_HALF_TRANSPARENCY = 16, - //! Show Bounding Boxes of all MeshBuffers - EDS_BBOX_BUFFERS = 32, - EDS_FULL = EDS_BBOX | EDS_NORMALS | EDS_SKELETON | EDS_MESH_WIRE_OVERLAY - }; - - - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __E_SCENE_NODE_TYPES_H_INCLUDED__ +#define __E_SCENE_NODE_TYPES_H_INCLUDED__ + +namespace irr +{ +namespace scene +{ + //! An enumeration for all types of built-in scene nodes + enum ESCENE_NODE_TYPE + { + //! simple cube scene node + ESNT_CUBE = 0, + + //! Sphere scene node + ESNT_SPHERE, + + //! Text Scene Node + ESNT_TEXT, + + //! Water Surface Scene Node + ESNT_WATER_SURFACE, + + //! Terrain Scene Node + ESNT_TERRAIN, + + //! Sky Box Scene Node + ESNT_SKY_BOX, + + //! Shadow Volume Scene Node + ESNT_SHADOW_VOLUME, + + //! OctTree Scene Node + ESNT_OCT_TREE, + + //! Mesh Scene Node + ESNT_MESH, + + //! Light Scene Node + ESNT_LIGHT, + + //! Empty Scene Node + ESNT_EMPTY, + + //! Dummy Transformation Scene Node + ESNT_DUMMY_TRANSFORMATION, + + //! Camera Scene Node + ESNT_CAMERA, + + //! Maya Camera Scene Node + ESNT_CAMERA_MAYA, + + //! First Person Shooter style Camera + ESNT_CAMERA_FPS, + + //! Billboard Scene Node + ESNT_BILLBOARD, + + //! Animated Mesh Scene Node + ESNT_ANIMATED_MESH, + + //! Particle System Scene Node + ESNT_PARTICLE_SYSTEM, + + //! Quake3 Model Scene Node ( has tag to link to ) + ESNT_MD3_SCENE_NODE, + + //! Amount of build in Scene Nodes + ESNT_COUNT, + + //! Unknown scene node + ESNT_UNKNOWN, + + //! This enum is never used, it only forces the compiler to + //! compile these enumeration values to 32 bit. + ESNT_FORCE_32_BIT = 0x7fffffff + }; + + + //! An enumeration for all types of automatic culling for built-in scene nodes + enum E_CULLING_TYPE + { + EAC_OFF = 0, + EAC_BOX, + EAC_FRUSTUM_BOX, + EAC_FRUSTUM_SPHERE + }; + + //! Names for culling type + const c8* const AutomaticCullingNames[] = + { + "false", + "box", // camera box against node box + "frustum_box", // camera frustum against node box + "frustum_sphere", // camera frustum against node sphere + 0 + }; + + //! An enumeration for all types of debug data for built-in scene nodes (flags) + enum E_DEBUG_SCENE_TYPE + { + //! No Debug Data ( Default ) + EDS_OFF = 0, + //! Show Bounding Boxes of SceneNode + EDS_BBOX = 1, + //! Show Vertex Normals + EDS_NORMALS = 2, + //! Shows Skeleton/Tags + EDS_SKELETON = 4, + //! Overlays Mesh Wireframe + EDS_MESH_WIRE_OVERLAY = 8, + //! Temporary use transparency Material Type + EDS_HALF_TRANSPARENCY = 16, + //! Show Bounding Boxes of all MeshBuffers + EDS_BBOX_BUFFERS = 32, + EDS_FULL = EDS_BBOX | EDS_NORMALS | EDS_SKELETON | EDS_MESH_WIRE_OVERLAY + }; + + + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/IAnimatedMesh.h b/src/dep/include/irrlicht/IAnimatedMesh.h index 4c8cc12..306d729 100644 --- a/src/dep/include/irrlicht/IAnimatedMesh.h +++ b/src/dep/include/irrlicht/IAnimatedMesh.h @@ -1,115 +1,115 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ANIMATED_MESH_H_INCLUDED__ -#define __I_ANIMATED_MESH_H_INCLUDED__ - -#include "IUnknown.h" -#include "IMesh.h" -#include "matrix4.h" - -namespace irr -{ -namespace scene -{ - enum E_ANIMATED_MESH_TYPE - { - //! Unknown animated mesh type. - EAMT_UNKNOWN = 0, - - //! Quake 2 MD2 model file - EAMT_MD2, - - //! Quake 3 MD3 model file - EAMT_MD3, - - //! Milkshape 3d skeletal animation file - EAMT_MS3D, - - //! Maya .obj not animated model - EAMT_OBJ, - - //! Quake 3 .bsp Map, not animated - EAMT_BSP, - - //! 3D Studio .3ds file - EAMT_3DS, - - //! Microsoft Direct3D .x-file. Can contain static and skeletal animated - //! skinned meshes. This is the standard and best supported - //! format of the Irrlicht Engine. - EAMT_X, - - //! My3D Mesh, the file format by Zhuck Dimitry - EAMT_MY3D, - - //! Pulsar LMTools (.lmts) file. The Irrlicht loader for this was written by - //! Jonas Petersen - EAMT_LMTS, - - //! Cartography Shop .csm file. The loader for this was created by Saurav Mohapatra. - EAMT_CSM, - - //! .oct file for Paul Nette's FSRad or from Murphy McCauley's Blender .oct exporter. - //! The oct file format contains 3D geometry and lightmaps and can - //! be loaded directly by Irrlicht - EAMT_OCT, - - //! Blitz Basic .b3d file, the file format by Mark Sibly - EAMT_B3D - - }; - - //! Interface for an animated mesh. - /** There are already simple implementations of this interface available so - you don't have to implement this interface on your own if you need to: - You might want to use irr::scene::SAnimatedMesh, irr::scene::SMesh, - irr::scene::SMeshBuffer etc. */ - class IAnimatedMesh : public virtual IUnknown - { - public: - - //! destructor - virtual ~IAnimatedMesh() {}; - - //! Gets the frame count of the animated mesh. - /** \return Returns the amount of frames. If the amount is 1, it is a - static, non animated mesh. */ - virtual s32 getFrameCount() = 0; - - //! Returns the IMesh interface for a frame. - /** \param frame: Frame number as zero based index. The maximum frame number is - getFrameCount() - 1; - \param detailLevel: Level of detail. 0 is the lowest, - 255 the highest level of detail. Most meshes will ignore the detail level. - \param startFrameLoop: Because some animated meshes (.MD2) are blended between 2 - static frames, and maybe animated in a loop, the startFrameLoop and the endFrameLoop - have to be defined, to prevent the animation to be blended between frames which are - outside of this loop. - If startFrameLoop and endFrameLoop are both -1, they are ignored. - \param endFrameLoop: see startFrameLoop. - \return Returns the animated mesh based on a detail level. */ - virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1) = 0; - - //! Returns an axis aligned bounding box of the mesh. - /** \return A bounding box of this mesh is returned. */ - virtual const core::aabbox3d& getBoundingBox() const = 0; - - //! Returns the type of the animated mesh. - /** In most cases it is not neccessary to use this method. - This is useful for making a save downcast, for example - if getMeshType() returns EAMT_MD2, its save to cast the - IAnimatedMesh to IAnimatedMeshMD2. - \returns Type of the mesh. */ - virtual E_ANIMATED_MESH_TYPE getMeshType() const - { - return EAMT_UNKNOWN; - } - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_ANIMATED_MESH_H_INCLUDED__ +#define __I_ANIMATED_MESH_H_INCLUDED__ + +#include "IUnknown.h" +#include "IMesh.h" +#include "matrix4.h" + +namespace irr +{ +namespace scene +{ + enum E_ANIMATED_MESH_TYPE + { + //! Unknown animated mesh type. + EAMT_UNKNOWN = 0, + + //! Quake 2 MD2 model file + EAMT_MD2, + + //! Quake 3 MD3 model file + EAMT_MD3, + + //! Milkshape 3d skeletal animation file + EAMT_MS3D, + + //! Maya .obj not animated model + EAMT_OBJ, + + //! Quake 3 .bsp Map, not animated + EAMT_BSP, + + //! 3D Studio .3ds file + EAMT_3DS, + + //! Microsoft Direct3D .x-file. Can contain static and skeletal animated + //! skinned meshes. This is the standard and best supported + //! format of the Irrlicht Engine. + EAMT_X, + + //! My3D Mesh, the file format by Zhuck Dimitry + EAMT_MY3D, + + //! Pulsar LMTools (.lmts) file. The Irrlicht loader for this was written by + //! Jonas Petersen + EAMT_LMTS, + + //! Cartography Shop .csm file. The loader for this was created by Saurav Mohapatra. + EAMT_CSM, + + //! .oct file for Paul Nette's FSRad or from Murphy McCauley's Blender .oct exporter. + //! The oct file format contains 3D geometry and lightmaps and can + //! be loaded directly by Irrlicht + EAMT_OCT, + + //! Blitz Basic .b3d file, the file format by Mark Sibly + EAMT_B3D + + }; + + //! Interface for an animated mesh. + /** There are already simple implementations of this interface available so + you don't have to implement this interface on your own if you need to: + You might want to use irr::scene::SAnimatedMesh, irr::scene::SMesh, + irr::scene::SMeshBuffer etc. */ + class IAnimatedMesh : public virtual IUnknown + { + public: + + //! destructor + virtual ~IAnimatedMesh() {}; + + //! Gets the frame count of the animated mesh. + /** \return Returns the amount of frames. If the amount is 1, it is a + static, non animated mesh. */ + virtual s32 getFrameCount() = 0; + + //! Returns the IMesh interface for a frame. + /** \param frame: Frame number as zero based index. The maximum frame number is + getFrameCount() - 1; + \param detailLevel: Level of detail. 0 is the lowest, + 255 the highest level of detail. Most meshes will ignore the detail level. + \param startFrameLoop: Because some animated meshes (.MD2) are blended between 2 + static frames, and maybe animated in a loop, the startFrameLoop and the endFrameLoop + have to be defined, to prevent the animation to be blended between frames which are + outside of this loop. + If startFrameLoop and endFrameLoop are both -1, they are ignored. + \param endFrameLoop: see startFrameLoop. + \return Returns the animated mesh based on a detail level. */ + virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1) = 0; + + //! Returns an axis aligned bounding box of the mesh. + /** \return A bounding box of this mesh is returned. */ + virtual const core::aabbox3d& getBoundingBox() const = 0; + + //! Returns the type of the animated mesh. + /** In most cases it is not neccessary to use this method. + This is useful for making a save downcast, for example + if getMeshType() returns EAMT_MD2, its save to cast the + IAnimatedMesh to IAnimatedMeshMD2. + \returns Type of the mesh. */ + virtual E_ANIMATED_MESH_TYPE getMeshType() const + { + return EAMT_UNKNOWN; + } + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IAnimatedMeshB3d.h b/src/dep/include/irrlicht/IAnimatedMeshB3d.h index 2ec2ae1..e35ad41 100644 --- a/src/dep/include/irrlicht/IAnimatedMeshB3d.h +++ b/src/dep/include/irrlicht/IAnimatedMeshB3d.h @@ -1,96 +1,96 @@ -// Copyright (C) 2002-2006 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ANIMATED_MESH_B3D_H_INCLUDED__ -#define __I_ANIMATED_MESH_B3D_H_INCLUDED__ - -#include "ISceneNode.h" -#include "IAnimatedMesh.h" - -namespace irr -{ -namespace scene -{ - //! Interface for using some special functions of B3d meshes - /** Please note that the B3d Mesh's frame numbers are scaled by 100 */ - class IAnimatedMeshB3d : public IAnimatedMesh - { - public: - - //! Returns a pointer to a transformation matrix of a part of the - //! mesh based on a frame time. This is used for being able to attach - //! objects to parts of animated meshes. For example a weapon to an animated - //! hand. - //! \param jointNumber: Zero based index of joint. The last joint has the number - //! IAnimatedMeshB3d::getJointCount()-1; - //! \param frame: Frame of the animation. - //! \return Returns a pointer to the matrix of the mesh part or - //! null if an error occured. - virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame) = 0; - - - //! Returns a pointer to a local matrix of a Joint, can be used to control the animation - virtual core::matrix4* getLocalMatrixOfJoint(s32 jointNumber) = 0; - - //! Returns a pointer to a matrix of a part of the mesh unanimated - virtual core::matrix4* getMatrixOfJointUnanimated(s32 jointNumber) = 0; - - - //! Move this Joint's local matrix when animating - //! \param jointNumber: Zero based index of joint. The last joint has the number - //! IAnimatedMeshB3d::getJointCount()-1; - //! \param On: False= Leave joint's local matrix, True= Animate - //! (not used yet) - virtual void setJointAnimation(s32 jointNumber, bool On) = 0; - - - //! Gets joint count. - //! \return Returns amount of joints in the skeletal animated mesh. - virtual s32 getJointCount() const = 0; - - //! Gets the name of a joint. - //! \param number: Zero based index of joint. The last joint has the number - //! IAnimatedMeshB3d::getJointCount()-1; - //! \return Returns name of joint and null if an error happened. - virtual const c8* getJointName(s32 number) const = 0; - - //! Gets a joint number from its name - //! \param name: Name of the joint. - //! \return Returns the number of the joint or -1 if not found. - virtual s32 getJointNumber(const c8* name) const = 0; - - //!Update Normals when Animating - //!False= Don't (default) - //!True= Update normals, slower - virtual void updateNormalsWhenAnimating(bool on) = 0; - - - //!Sets Interpolation Mode - //!0- Constant - //!1- Linear (default) - virtual void setInterpolationMode(s32 mode) = 0; - - //!Want should happen on when animating - //!0-Nothing - //!1-Update nodes only - //!2-Update skin only - //!3-Update both nodes and skin (default) - virtual void setAnimateMode(s32 mode) = 0; - - //!Convert all mesh buffers to use tangent vertices - virtual void convertToTangents() =0; - - - virtual void recoverJointsFromMesh(core::array &JointChildSceneNodes)=0; - virtual void tranferJointsToMesh(core::array &JointChildSceneNodes)=0; - virtual void createJoints(core::array &JointChildSceneNodes, ISceneNode* AnimatedMeshSceneNode, ISceneManager* SceneManager)=0; - - }; - -} // end namespace scene -} // end namespace irr - -#endif - - +// Copyright (C) 2002-2006 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_ANIMATED_MESH_B3D_H_INCLUDED__ +#define __I_ANIMATED_MESH_B3D_H_INCLUDED__ + +#include "ISceneNode.h" +#include "IAnimatedMesh.h" + +namespace irr +{ +namespace scene +{ + //! Interface for using some special functions of B3d meshes + /** Please note that the B3d Mesh's frame numbers are scaled by 100 */ + class IAnimatedMeshB3d : public IAnimatedMesh + { + public: + + //! Returns a pointer to a transformation matrix of a part of the + //! mesh based on a frame time. This is used for being able to attach + //! objects to parts of animated meshes. For example a weapon to an animated + //! hand. + //! \param jointNumber: Zero based index of joint. The last joint has the number + //! IAnimatedMeshB3d::getJointCount()-1; + //! \param frame: Frame of the animation. + //! \return Returns a pointer to the matrix of the mesh part or + //! null if an error occured. + virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame) = 0; + + + //! Returns a pointer to a local matrix of a Joint, can be used to control the animation + virtual core::matrix4* getLocalMatrixOfJoint(s32 jointNumber) = 0; + + //! Returns a pointer to a matrix of a part of the mesh unanimated + virtual core::matrix4* getMatrixOfJointUnanimated(s32 jointNumber) = 0; + + + //! Move this Joint's local matrix when animating + //! \param jointNumber: Zero based index of joint. The last joint has the number + //! IAnimatedMeshB3d::getJointCount()-1; + //! \param On: False= Leave joint's local matrix, True= Animate + //! (not used yet) + virtual void setJointAnimation(s32 jointNumber, bool On) = 0; + + + //! Gets joint count. + //! \return Returns amount of joints in the skeletal animated mesh. + virtual s32 getJointCount() const = 0; + + //! Gets the name of a joint. + //! \param number: Zero based index of joint. The last joint has the number + //! IAnimatedMeshB3d::getJointCount()-1; + //! \return Returns name of joint and null if an error happened. + virtual const c8* getJointName(s32 number) const = 0; + + //! Gets a joint number from its name + //! \param name: Name of the joint. + //! \return Returns the number of the joint or -1 if not found. + virtual s32 getJointNumber(const c8* name) const = 0; + + //!Update Normals when Animating + //!False= Don't (default) + //!True= Update normals, slower + virtual void updateNormalsWhenAnimating(bool on) = 0; + + + //!Sets Interpolation Mode + //!0- Constant + //!1- Linear (default) + virtual void setInterpolationMode(s32 mode) = 0; + + //!Want should happen on when animating + //!0-Nothing + //!1-Update nodes only + //!2-Update skin only + //!3-Update both nodes and skin (default) + virtual void setAnimateMode(s32 mode) = 0; + + //!Convert all mesh buffers to use tangent vertices + virtual void convertToTangents() =0; + + + virtual void recoverJointsFromMesh(core::array &JointChildSceneNodes)=0; + virtual void tranferJointsToMesh(core::array &JointChildSceneNodes)=0; + virtual void createJoints(core::array &JointChildSceneNodes, ISceneNode* AnimatedMeshSceneNode, ISceneManager* SceneManager)=0; + + }; + +} // end namespace scene +} // end namespace irr + +#endif + + diff --git a/src/dep/include/irrlicht/IAnimatedMeshMD2.h b/src/dep/include/irrlicht/IAnimatedMeshMD2.h index 4c2bd05..9f9aa8a 100644 --- a/src/dep/include/irrlicht/IAnimatedMeshMD2.h +++ b/src/dep/include/irrlicht/IAnimatedMeshMD2.h @@ -1,78 +1,78 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ANIMATED_MESH_MD2_H_INCLUDED__ -#define __I_ANIMATED_MESH_MD2_H_INCLUDED__ - -#include "IAnimatedMesh.h" - -namespace irr -{ -namespace scene -{ - - //! Types of standard md2 animations - enum EMD2_ANIMATION_TYPE - { - EMAT_STAND = 0, - EMAT_RUN, - EMAT_ATTACK, - EMAT_PAIN_A, - EMAT_PAIN_B, - EMAT_PAIN_C, - EMAT_JUMP, - EMAT_FLIP, - EMAT_SALUTE, - EMAT_FALLBACK, - EMAT_WAVE, - EMAT_POINT, - EMAT_CROUCH_STAND, - EMAT_CROUCH_WALK, - EMAT_CROUCH_ATTACK, - EMAT_CROUCH_PAIN, - EMAT_CROUCH_DEATH, - EMAT_DEATH_FALLBACK, - EMAT_DEATH_FALLFORWARD, - EMAT_DEATH_FALLBACKSLOW, - EMAT_BOOM, - - //! Not an animation, but amount of animation types. - EMAT_COUNT - }; - - //! Interface for using some special functions of MD2 meshes - class IAnimatedMeshMD2 : public IAnimatedMesh - { - public: - - //! Returns the beginframe, endframe and frames per second for a default MD2 animation type. - //! \param l: The EMD2_ANIMATION_TYPE to get the frames for. - //! \param outBegin: The returned beginning frame for animation type specified. - //! \param outEnd: The returned ending frame for the animation type specified. - //! \param outFPS: The number of frames per second, this animation should be played at. - virtual void getFrameLoop(EMD2_ANIMATION_TYPE l, s32& outBegin, - s32& outEnd, s32& outFPS) const = 0; - - //! Returns the beginframe, endframe and frames per second for a special MD2 animation type. - //! \param name: Name of the animation. - //! \param outBegin: The returned beginning frame for animation type specified. - //! \param outEnd: The returned ending frame for the animation type specified. - //! \param outFPS: The number of frames per second, this animation should be played at. - virtual bool getFrameLoop(const c8* name, - s32& outBegin, s32& outEnd, s32& outFPS) const = 0; - - //! Returns amount of md2 animations in this file. - virtual s32 getAnimationCount() const = 0; - - //! Returns name of md2 animation. - //! \param nr: Zero based index of animation. - virtual const c8* getAnimationName(s32 nr) const = 0; - - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_ANIMATED_MESH_MD2_H_INCLUDED__ +#define __I_ANIMATED_MESH_MD2_H_INCLUDED__ + +#include "IAnimatedMesh.h" + +namespace irr +{ +namespace scene +{ + + //! Types of standard md2 animations + enum EMD2_ANIMATION_TYPE + { + EMAT_STAND = 0, + EMAT_RUN, + EMAT_ATTACK, + EMAT_PAIN_A, + EMAT_PAIN_B, + EMAT_PAIN_C, + EMAT_JUMP, + EMAT_FLIP, + EMAT_SALUTE, + EMAT_FALLBACK, + EMAT_WAVE, + EMAT_POINT, + EMAT_CROUCH_STAND, + EMAT_CROUCH_WALK, + EMAT_CROUCH_ATTACK, + EMAT_CROUCH_PAIN, + EMAT_CROUCH_DEATH, + EMAT_DEATH_FALLBACK, + EMAT_DEATH_FALLFORWARD, + EMAT_DEATH_FALLBACKSLOW, + EMAT_BOOM, + + //! Not an animation, but amount of animation types. + EMAT_COUNT + }; + + //! Interface for using some special functions of MD2 meshes + class IAnimatedMeshMD2 : public IAnimatedMesh + { + public: + + //! Returns the beginframe, endframe and frames per second for a default MD2 animation type. + //! \param l: The EMD2_ANIMATION_TYPE to get the frames for. + //! \param outBegin: The returned beginning frame for animation type specified. + //! \param outEnd: The returned ending frame for the animation type specified. + //! \param outFPS: The number of frames per second, this animation should be played at. + virtual void getFrameLoop(EMD2_ANIMATION_TYPE l, s32& outBegin, + s32& outEnd, s32& outFPS) const = 0; + + //! Returns the beginframe, endframe and frames per second for a special MD2 animation type. + //! \param name: Name of the animation. + //! \param outBegin: The returned beginning frame for animation type specified. + //! \param outEnd: The returned ending frame for the animation type specified. + //! \param outFPS: The number of frames per second, this animation should be played at. + virtual bool getFrameLoop(const c8* name, + s32& outBegin, s32& outEnd, s32& outFPS) const = 0; + + //! Returns amount of md2 animations in this file. + virtual s32 getAnimationCount() const = 0; + + //! Returns name of md2 animation. + //! \param nr: Zero based index of animation. + virtual const c8* getAnimationName(s32 nr) const = 0; + + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IAnimatedMeshMD3.h b/src/dep/include/irrlicht/IAnimatedMeshMD3.h index d0f2f31..bdfb8cb 100644 --- a/src/dep/include/irrlicht/IAnimatedMeshMD3.h +++ b/src/dep/include/irrlicht/IAnimatedMeshMD3.h @@ -1,269 +1,269 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ANIMATED_MESH_MD3_H_INCLUDED__ -#define __I_ANIMATED_MESH_MD3_H_INCLUDED__ - -#include "IAnimatedMesh.h" -#include "IQ3Shader.h" -#include "quaternion.h" - -namespace irr -{ -namespace scene -{ - - enum eMD3Models - { - EMD3_HEAD = 0, - EMD3_UPPER, - EMD3_LOWER, - EMD3_WEAPON, - EMD3_NUMMODELS - }; - - - // Animation list - enum EMD3_ANIMATION_TYPE - { - // Animations for both lower and upper parts of the player - EMD3_BOTH_DEATH_1 = 0, - EMD3_BOTH_DEAD_1, - EMD3_BOTH_DEATH_2, - EMD3_BOTH_DEAD_2, - EMD3_BOTH_DEATH_3, - EMD3_BOTH_DEAD_3, - - // Animations for the upper part - EMD3_TORSO_GESTURE, - EMD3_TORSO_ATTACK_1, - EMD3_TORSO_ATTACK_2, - EMD3_TORSO_DROP, - EMD3_TORSO_RAISE, - EMD3_TORSO_STAND_1, - EMD3_TORSO_STAND_2, - - // Animations for the lower part - EMD3_LEGS_WALK_CROUCH, - EMD3_LEGS_WALK, - EMD3_LEGS_RUN, - EMD3_LEGS_BACK, - EMD3_LEGS_SWIM, - EMD3_LEGS_JUMP_1, - EMD3_LEGS_LAND_1, - EMD3_LEGS_JUMP_2, - EMD3_LEGS_LAND_2, - EMD3_LEGS_IDLE, - EMD3_LEGS_IDLE_CROUCH, - EMD3_LEGS_TURN, - - //! Not an animation, but amount of animation types. - EMD3_ANIMATION_COUNT - }; - - struct SMD3AnimationInfo - { - s32 first; // First frame - s32 num; // Last frame - s32 looping; // Looping frames - s32 fps; // Frames per second - }; - - -// byte-align structures -#ifdef _MSC_VER -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - // this holds the header info of the MD3 file - struct SMD3Header - { - c8 headerID[4]; //id of file, always "IDP3" - s32 Version; //this is a version number, always 15 - s8 fileName[68]; //sometimes left Blank... 65 chars, 32bit aligned == 68 chars - s32 numFrames; //number of KeyFrames - s32 numTags; //number of 'tags' per frame - s32 numMeshes; //number of meshes/skins - s32 numMaxSkins; //maximum number of unique skins used in md3 file - s32 headerSize; //always equal to the length of this header - s32 tagStart; //starting position of tag-structures - s32 tagEnd; //ending position of tag-structures/starting position of mesh-structures - s32 fileSize; - }; - - struct SMD3MeshHeader - { - c8 meshID[4]; //id, must be IDP3 - c8 meshName[68]; //name of mesh 65 chars, 32 bit aligned == 68 chars - - s32 numFrames; //number of meshframes in mesh - s32 numShader; //number of skins in mesh - s32 numVertices; //number of vertices - s32 numTriangles; //number of Triangles - - s32 offset_triangles; //starting position of Triangle data, relative to start of Mesh_Header - s32 offset_shaders; //size of header - s32 offset_st; //starting position of texvector data, relative to start of Mesh_Header - s32 vertexStart; //starting position of vertex data,relative to start of Mesh_Header - s32 offset_end; - }; - - - //! Compressed Vertex Data - struct SMD3Vertex - { - s16 position[3]; - u8 normal[2]; - }; - - //! Texure Coordinate - struct SMD3TexCoord - { - f32 u; - f32 v; - }; - - //! Triangle Index - struct SMD3Face - { - s32 Index[3]; - }; - - -// Default alignment -#ifdef _MSC_VER -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - - //! Holding Frame Data for a Mesh - struct SMD3MeshBuffer : public IUnknown - { - virtual ~ SMD3MeshBuffer () {} - - SMD3MeshHeader MeshHeader; - - core::array < core::stringc > Shader; - core::array < s32 > Indices; - core::array < SMD3Vertex > Vertices; - core::array < SMD3TexCoord > Tex; - }; - - //! hold a tag info for connecting meshes - //! basically its an alternate way to describe a transformation - struct SMD3QuaterionTag - { - SMD3QuaterionTag() {} - - SMD3QuaterionTag( const core::stringc& name ) - : Name ( name ) {} - - // construct from a matrix - SMD3QuaterionTag ( const core::stringc& name, const core::matrix4 &m ) - { - Name = name; - position = m.getTranslation (); - rotation = m; - } - - // set to matrix - void setto ( core::matrix4 &m ) - { - rotation.getMatrix ( m ); - m.setTranslation ( position ); - } - - // construct from a position and euler angles in degrees - SMD3QuaterionTag ( const core::vector3df&pos, const core::vector3df &angle ) - { - position = pos; - rotation.set ( angle.X * core::DEGTORAD, angle.Y * core::DEGTORAD, angle.Z * core::DEGTORAD ); - } - - virtual ~SMD3QuaterionTag() {} - - core::stringc Name; - core::vector3df position; - core::quaternion rotation; - - bool operator < ( const SMD3QuaterionTag &other ) const - { - return Name < other.Name; - } - }; - - // holds a assoziative list of named quaternions - struct SMD3QuaterionTagList : public virtual IUnknown - { - SMD3QuaterionTagList () {} - virtual ~SMD3QuaterionTagList () {} - - SMD3QuaterionTag* get ( const core::stringc& name ) - { - SMD3QuaterionTag search ( name ); - s32 index = Container.linear_search ( search ); - if ( index >= 0 ) - return &Container[index]; - return 0; - } - - u32 size () const - { - return Container.size(); - } - - SMD3QuaterionTag& operator[] (u32 index ) - { - return Container[index]; - } - - - core::array < SMD3QuaterionTag > Container; - }; - - - - //! Holding Frames Buffers and Tag Infos - struct SMD3Mesh: public IUnknown - { - virtual ~SMD3Mesh() - { - for (u32 i=0; idrop(); - }; - - SMD3Header MD3Header; - core::stringc Name; - core::array < SMD3MeshBuffer * > Buffer; - SMD3QuaterionTagList TagList; - }; - - - - //! Interface for using some special functions of MD3 meshes - class IAnimatedMeshMD3 : public IAnimatedMesh - { - public: - - //! tune how many frames you want to render inbetween - virtual void setInterpolationShift ( u32 shift, u32 loopMode ) = 0; - - virtual SMD3QuaterionTagList *getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) = 0; - - virtual SMD3Mesh * getOriginalMesh () = 0; - - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_ANIMATED_MESH_MD3_H_INCLUDED__ +#define __I_ANIMATED_MESH_MD3_H_INCLUDED__ + +#include "IAnimatedMesh.h" +#include "IQ3Shader.h" +#include "quaternion.h" + +namespace irr +{ +namespace scene +{ + + enum eMD3Models + { + EMD3_HEAD = 0, + EMD3_UPPER, + EMD3_LOWER, + EMD3_WEAPON, + EMD3_NUMMODELS + }; + + + // Animation list + enum EMD3_ANIMATION_TYPE + { + // Animations for both lower and upper parts of the player + EMD3_BOTH_DEATH_1 = 0, + EMD3_BOTH_DEAD_1, + EMD3_BOTH_DEATH_2, + EMD3_BOTH_DEAD_2, + EMD3_BOTH_DEATH_3, + EMD3_BOTH_DEAD_3, + + // Animations for the upper part + EMD3_TORSO_GESTURE, + EMD3_TORSO_ATTACK_1, + EMD3_TORSO_ATTACK_2, + EMD3_TORSO_DROP, + EMD3_TORSO_RAISE, + EMD3_TORSO_STAND_1, + EMD3_TORSO_STAND_2, + + // Animations for the lower part + EMD3_LEGS_WALK_CROUCH, + EMD3_LEGS_WALK, + EMD3_LEGS_RUN, + EMD3_LEGS_BACK, + EMD3_LEGS_SWIM, + EMD3_LEGS_JUMP_1, + EMD3_LEGS_LAND_1, + EMD3_LEGS_JUMP_2, + EMD3_LEGS_LAND_2, + EMD3_LEGS_IDLE, + EMD3_LEGS_IDLE_CROUCH, + EMD3_LEGS_TURN, + + //! Not an animation, but amount of animation types. + EMD3_ANIMATION_COUNT + }; + + struct SMD3AnimationInfo + { + s32 first; // First frame + s32 num; // Last frame + s32 looping; // Looping frames + s32 fps; // Frames per second + }; + + +// byte-align structures +#ifdef _MSC_VER +# pragma pack( push, packing ) +# pragma pack( 1 ) +# define PACK_STRUCT +#elif defined( __GNUC__ ) +# define PACK_STRUCT __attribute__((packed)) +#else +# error compiler not supported +#endif + + // this holds the header info of the MD3 file + struct SMD3Header + { + c8 headerID[4]; //id of file, always "IDP3" + s32 Version; //this is a version number, always 15 + s8 fileName[68]; //sometimes left Blank... 65 chars, 32bit aligned == 68 chars + s32 numFrames; //number of KeyFrames + s32 numTags; //number of 'tags' per frame + s32 numMeshes; //number of meshes/skins + s32 numMaxSkins; //maximum number of unique skins used in md3 file + s32 headerSize; //always equal to the length of this header + s32 tagStart; //starting position of tag-structures + s32 tagEnd; //ending position of tag-structures/starting position of mesh-structures + s32 fileSize; + }; + + struct SMD3MeshHeader + { + c8 meshID[4]; //id, must be IDP3 + c8 meshName[68]; //name of mesh 65 chars, 32 bit aligned == 68 chars + + s32 numFrames; //number of meshframes in mesh + s32 numShader; //number of skins in mesh + s32 numVertices; //number of vertices + s32 numTriangles; //number of Triangles + + s32 offset_triangles; //starting position of Triangle data, relative to start of Mesh_Header + s32 offset_shaders; //size of header + s32 offset_st; //starting position of texvector data, relative to start of Mesh_Header + s32 vertexStart; //starting position of vertex data,relative to start of Mesh_Header + s32 offset_end; + }; + + + //! Compressed Vertex Data + struct SMD3Vertex + { + s16 position[3]; + u8 normal[2]; + }; + + //! Texure Coordinate + struct SMD3TexCoord + { + f32 u; + f32 v; + }; + + //! Triangle Index + struct SMD3Face + { + s32 Index[3]; + }; + + +// Default alignment +#ifdef _MSC_VER +# pragma pack( pop, packing ) +#endif + +#undef PACK_STRUCT + + //! Holding Frame Data for a Mesh + struct SMD3MeshBuffer : public IUnknown + { + virtual ~ SMD3MeshBuffer () {} + + SMD3MeshHeader MeshHeader; + + core::array < core::stringc > Shader; + core::array < s32 > Indices; + core::array < SMD3Vertex > Vertices; + core::array < SMD3TexCoord > Tex; + }; + + //! hold a tag info for connecting meshes + //! basically its an alternate way to describe a transformation + struct SMD3QuaterionTag + { + SMD3QuaterionTag() {} + + SMD3QuaterionTag( const core::stringc& name ) + : Name ( name ) {} + + // construct from a matrix + SMD3QuaterionTag ( const core::stringc& name, const core::matrix4 &m ) + { + Name = name; + position = m.getTranslation (); + rotation = m; + } + + // set to matrix + void setto ( core::matrix4 &m ) + { + rotation.getMatrix ( m ); + m.setTranslation ( position ); + } + + // construct from a position and euler angles in degrees + SMD3QuaterionTag ( const core::vector3df&pos, const core::vector3df &angle ) + { + position = pos; + rotation.set ( angle.X * core::DEGTORAD, angle.Y * core::DEGTORAD, angle.Z * core::DEGTORAD ); + } + + virtual ~SMD3QuaterionTag() {} + + core::stringc Name; + core::vector3df position; + core::quaternion rotation; + + bool operator < ( const SMD3QuaterionTag &other ) const + { + return Name < other.Name; + } + }; + + // holds a assoziative list of named quaternions + struct SMD3QuaterionTagList : public virtual IUnknown + { + SMD3QuaterionTagList () {} + virtual ~SMD3QuaterionTagList () {} + + SMD3QuaterionTag* get ( const core::stringc& name ) + { + SMD3QuaterionTag search ( name ); + s32 index = Container.linear_search ( search ); + if ( index >= 0 ) + return &Container[index]; + return 0; + } + + u32 size () const + { + return Container.size(); + } + + SMD3QuaterionTag& operator[] (u32 index ) + { + return Container[index]; + } + + + core::array < SMD3QuaterionTag > Container; + }; + + + + //! Holding Frames Buffers and Tag Infos + struct SMD3Mesh: public IUnknown + { + virtual ~SMD3Mesh() + { + for (u32 i=0; idrop(); + }; + + SMD3Header MD3Header; + core::stringc Name; + core::array < SMD3MeshBuffer * > Buffer; + SMD3QuaterionTagList TagList; + }; + + + + //! Interface for using some special functions of MD3 meshes + class IAnimatedMeshMD3 : public IAnimatedMesh + { + public: + + //! tune how many frames you want to render inbetween + virtual void setInterpolationShift ( u32 shift, u32 loopMode ) = 0; + + virtual SMD3QuaterionTagList *getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) = 0; + + virtual SMD3Mesh * getOriginalMesh () = 0; + + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IAnimatedMeshMS3D.h b/src/dep/include/irrlicht/IAnimatedMeshMS3D.h index ee5ca67..43c4533 100644 --- a/src/dep/include/irrlicht/IAnimatedMeshMS3D.h +++ b/src/dep/include/irrlicht/IAnimatedMeshMS3D.h @@ -1,51 +1,51 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Fabio Concas / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ANIMATED_MESH_MS3D_H_INCLUDED__ -#define __I_ANIMATED_MESH_MS3D_H_INCLUDED__ - -#include "IAnimatedMesh.h" - -namespace irr -{ -namespace scene -{ - //! Interface for using some special functions of MS3D meshes - class IAnimatedMeshMS3D : public IAnimatedMesh - { - public: - - //! Returns a pointer to a transformation matrix of a part of the - //! mesh based on a frame time. This is used for being able to attach - //! objects to parts of animated meshes. For example a weapon to an animated - //! hand. - //! \param jointNumber: Zero based index of joint. The last joint has the number - //! IAnimatedMeshMS3D::getJointCount()-1; - //! \param frame: Frame of the animation. - //! \return Returns a pointer to the matrix of the mesh part or - //! null if an error occured. - virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame) = 0; - - //! Gets joint count. - //! \return Returns amount of joints in the skeletal animated mesh. - virtual s32 getJointCount() const = 0; - - //! Gets the name of a joint. - //! \param number: Zero based index of joint. The last joint has the number - //! IAnimatedMeshMS3D::getJointCount()-1; - //! \return Returns name of joint and null if an error happened. - virtual const c8* getJointName(s32 number) const = 0; - - //! Gets a joint number from its name - //! \param name: Name of the joint. - //! \return Returns the number of the joint or -1 if not found. - virtual s32 getJointNumber(const c8* name) const = 0; - - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Fabio Concas / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_ANIMATED_MESH_MS3D_H_INCLUDED__ +#define __I_ANIMATED_MESH_MS3D_H_INCLUDED__ + +#include "IAnimatedMesh.h" + +namespace irr +{ +namespace scene +{ + //! Interface for using some special functions of MS3D meshes + class IAnimatedMeshMS3D : public IAnimatedMesh + { + public: + + //! Returns a pointer to a transformation matrix of a part of the + //! mesh based on a frame time. This is used for being able to attach + //! objects to parts of animated meshes. For example a weapon to an animated + //! hand. + //! \param jointNumber: Zero based index of joint. The last joint has the number + //! IAnimatedMeshMS3D::getJointCount()-1; + //! \param frame: Frame of the animation. + //! \return Returns a pointer to the matrix of the mesh part or + //! null if an error occured. + virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame) = 0; + + //! Gets joint count. + //! \return Returns amount of joints in the skeletal animated mesh. + virtual s32 getJointCount() const = 0; + + //! Gets the name of a joint. + //! \param number: Zero based index of joint. The last joint has the number + //! IAnimatedMeshMS3D::getJointCount()-1; + //! \return Returns name of joint and null if an error happened. + virtual const c8* getJointName(s32 number) const = 0; + + //! Gets a joint number from its name + //! \param name: Name of the joint. + //! \return Returns the number of the joint or -1 if not found. + virtual s32 getJointNumber(const c8* name) const = 0; + + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IAnimatedMeshSceneNode.h b/src/dep/include/irrlicht/IAnimatedMeshSceneNode.h index 0c8d90a..5509d7c 100644 --- a/src/dep/include/irrlicht/IAnimatedMeshSceneNode.h +++ b/src/dep/include/irrlicht/IAnimatedMeshSceneNode.h @@ -1,208 +1,208 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ -#define __I_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "IAnimatedMeshMD2.h" -#include "IAnimatedMeshMD3.h" -#include "IShadowVolumeSceneNode.h" - -namespace irr -{ -namespace scene -{ - class IAnimatedMeshSceneNode; - - //! Callback interface for catching events of ended animations. - /** Implement this interface and use - IAnimatedMeshSceneNode::setAnimationEndCallback to be able to - be notified if an animation playback has ended. - **/ - class IAnimationEndCallBack : public virtual IUnknown - { - public: - - //! Will be called when the animation playback has ended. - //! See IAnimatedMeshSceneNode::setAnimationEndCallback for - //! more informations. - //! \param node: Node of which the animation has ended. - virtual void OnAnimationEnd(IAnimatedMeshSceneNode* node) = 0; - }; - - //! Scene node capable of displaying an animated mesh and its shadow. - /** The shadow is optional: If a shadow should be displayed too, just invoke - the IAnimatedMeshSceneNode::createShadowVolumeSceneNode().*/ - class IAnimatedMeshSceneNode : public ISceneNode - { - public: - - //! Constructor - IAnimatedMeshSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) - : ISceneNode(parent, mgr, id, position, rotation, scale) {} - - //! Destructor - virtual ~IAnimatedMeshSceneNode() {}; - - //! Sets the current frame number. - //! From now on the animation is played from this frame. - //! \param frame: Number of the frame to let the animation be started from. - //! The frame number must be a valid frame number of the IMesh used by this - //! scene node. Set IAnimatedMesh::getMesh() for details. - virtual void setCurrentFrame(s32 frame) = 0; - - //! Sets the frame numbers between the animation is looped. - //! The default is 0 - MaximalFrameCount of the mesh. - //! \param begin: Start frame number of the loop. - //! \param end: End frame number of the loop. - //! \return Returns true if successful, false if not. - virtual bool setFrameLoop(s32 begin, s32 end) = 0; - - //! Sets the speed with witch the animation is played. - //! \param framesPerSecond: Frames per second played. - virtual void setAnimationSpeed(f32 framesPerSecond) = 0; - - //! Creates shadow volume scene node as child of this node - //! and returns a pointer to it. The shadow can be rendered using the ZPass - //! or the zfail method. ZPass is a little bit faster because the shadow volume - //! creation is easier, but with this method there occur ugly looking artifacs - //! when the camera is inside the shadow volume. These error do not occur - //! with the ZFail method. - //! \param id: Id of the shadow scene node. This id can be used to identify - //! the node later. - //! \param zfailmethod: If set to true, the shadow will use the zfail method, - //! if not, zpass is used. - //! \param infinity: Value used by the shadow volume algorithm to scale the - //! shadow volume. - //! \return Returns pointer to the created shadow scene node. - //! This pointer should not be dropped. See IUnknown::drop() for more information. - virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(s32 id=-1, - bool zfailmethod=true, f32 infinity=10000.0f) = 0; - - //! Returns a pointer to a child node, wich has the same transformation as - //! the corresponding joint, if the mesh in this scene node is a ms3d mesh. - //! Otherwise 0 is returned. With this method it is possible to - //! attach scene nodes to joints more easily. In this way, it is - //! for example possible to attach a weapon to the left hand of an - //! animated model. This example shows how: - //! \code - //! ISceneNode* hand = - //! yourMS3DAnimatedMeshSceneNode->getMS3DJointNode("LeftHand"); - //! hand->addChild(weaponSceneNode); - //! \endcode - //! Please note that the SceneNode returned by this method may not exist - //! before this call and is created by it. - //! \param jointName: Name of the joint. - //! \return Returns a pointer to the scene node which represents the joint - //! with the specified name. Returns 0 if the contained mesh is not an - //! ms3d mesh or the name of the joint could not be found. - virtual ISceneNode* getMS3DJointNode(const c8* jointName) = 0; - - //! Returns a pointer to a child node, which has the same transformation as - //! the corresponding joint, if the mesh in this scene node is a x mesh. - //! Otherwise 0 is returned. With this method it is possible to - //! attach scene nodes to joints more easily. In this way, it is - //! for example possible to attach a weapon to the left hand of an - //! animated model. This example shows how: - //! \code - //! ISceneNode* hand = - //! yourMS3DAnimatedMeshSceneNode->getXJointNode("LeftHand"); - //! hand->addChild(weaponSceneNode); - //! \endcode - //! Please note that the SceneNode returned by this method may not exist - //! before this call and is created by it. - //! \param jointName: Name of the joint. - //! \return Returns a pointer to the scene node which represents the joint - //! with the specified name. Returns 0 if the contained mesh is not an - //! ms3d mesh or the name of the joint could not be found. - virtual ISceneNode* getXJointNode(const c8* jointName) = 0; - - //! Returns a pointer to a child node, wich has the same transformation as - //! the corresponding joint, if the mesh in this scene node is a b3d mesh. - //! Otherwise 0 is returned. With this method it is possible to - //! attach scene nodes to joints more easily. In this way, it is - //! for example possible to attach a weapon to the left hand of an - //! animated model. This example shows how: - //! \code - //! ISceneNode* hand = - //! yourB3DAnimatedMeshSceneNode->getB3DJointNode("LeftHand"); - //! hand->addChild(weaponSceneNode); - //! \endcode - //! Please note that the SceneNode returned by this method may not exist - //! before this call and is created by it. - //! \param jointName: Name of the joint. - //! \return Returns a pointer to the scene node which represents the joint - //! with the specified name. Returns 0 if the contained mesh is not an - //! ms3d mesh or the name of the joint could not be found. - virtual ISceneNode* getB3DJointNode(const c8* jointName) = 0; - - //! Starts a default MD2 animation. - //! With this method it is easily possible to start a Run, Attack, - //! Die or whatever animation, if the mesh contained in this scene - //! node is an md2 mesh. Otherwise, nothing happens. - //! \param anim: An MD2 animation type, which should be played, for - //! example EMAT_STAND for the standing animation. - //! \return Returns true if successful, and false if not, for example - //! if the mesh in the scene node is not a md2 mesh. - virtual bool setMD2Animation(EMD2_ANIMATION_TYPE anim) = 0; - - //! Starts a special MD2 animation. - //! With this method it is easily possible to start a Run, Attack, - //! Die or whatever animation, if the mesh contained in this scene - //! node is an md2 mesh. Otherwise, nothing happens. This method uses - //! a character string to identify the animation. If the animation is a - //! standard md2 animation, you might want to start this animation - //! with the EMD2_ANIMATION_TYPE enumeration instead. - //! \param animationName: Name of the animation which should be played. - //! \return Returns true if successful, and false if not, for example - //! if the mesh in the scene node is not an md2 mesh, or no animation - //! with this name could be found. - virtual bool setMD2Animation(const c8* animationName) = 0; - - //! Returns the current displayed frame number. - virtual s32 getFrameNr() = 0; - //! Returns the current start frame number. - virtual s32 getStartFrame() = 0; - //! Returns the current end frame number. - virtual s32 getEndFrame() = 0; - - //! Sets looping mode which is on by default. If set to false, - //! animations will not be played looped. - virtual void setLoopMode(bool playAnimationLooped) = 0; - - //! Sets a callback interface which will be called if an animation - //! playback has ended. Set this to 0 to disable the callback again. - //! Please note that this will only be called when in non looped mode, - //! see IAnimatedMeshSceneNode::setLoopMode(). - virtual void setAnimationEndCallback(IAnimationEndCallBack* callback=0) = 0; - - //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. - /* In this way it is possible to change the materials a mesh causing all mesh scene nodes - referencing this mesh to change too. */ - virtual void setReadOnlyMaterials(bool readonly) = 0; - - //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style - virtual bool isReadOnlyMaterials() = 0; - - //! Sets a new mesh - virtual void setMesh(IAnimatedMesh* mesh) = 0; - - //! Returns the current mesh - virtual IAnimatedMesh* getMesh(void) = 0; - - // returns the absolute transformation for a special MD3 Tag if the mesh is a md3 mesh, - // or the absolutetransformation if it's a normal scenenode - virtual const SMD3QuaterionTag& getAbsoluteTransformation( const core::stringc & tagname) = 0; - - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ +#define __I_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" +#include "IAnimatedMeshMD2.h" +#include "IAnimatedMeshMD3.h" +#include "IShadowVolumeSceneNode.h" + +namespace irr +{ +namespace scene +{ + class IAnimatedMeshSceneNode; + + //! Callback interface for catching events of ended animations. + /** Implement this interface and use + IAnimatedMeshSceneNode::setAnimationEndCallback to be able to + be notified if an animation playback has ended. + **/ + class IAnimationEndCallBack : public virtual IUnknown + { + public: + + //! Will be called when the animation playback has ended. + //! See IAnimatedMeshSceneNode::setAnimationEndCallback for + //! more informations. + //! \param node: Node of which the animation has ended. + virtual void OnAnimationEnd(IAnimatedMeshSceneNode* node) = 0; + }; + + //! Scene node capable of displaying an animated mesh and its shadow. + /** The shadow is optional: If a shadow should be displayed too, just invoke + the IAnimatedMeshSceneNode::createShadowVolumeSceneNode().*/ + class IAnimatedMeshSceneNode : public ISceneNode + { + public: + + //! Constructor + IAnimatedMeshSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) + : ISceneNode(parent, mgr, id, position, rotation, scale) {} + + //! Destructor + virtual ~IAnimatedMeshSceneNode() {}; + + //! Sets the current frame number. + //! From now on the animation is played from this frame. + //! \param frame: Number of the frame to let the animation be started from. + //! The frame number must be a valid frame number of the IMesh used by this + //! scene node. Set IAnimatedMesh::getMesh() for details. + virtual void setCurrentFrame(s32 frame) = 0; + + //! Sets the frame numbers between the animation is looped. + //! The default is 0 - MaximalFrameCount of the mesh. + //! \param begin: Start frame number of the loop. + //! \param end: End frame number of the loop. + //! \return Returns true if successful, false if not. + virtual bool setFrameLoop(s32 begin, s32 end) = 0; + + //! Sets the speed with witch the animation is played. + //! \param framesPerSecond: Frames per second played. + virtual void setAnimationSpeed(f32 framesPerSecond) = 0; + + //! Creates shadow volume scene node as child of this node + //! and returns a pointer to it. The shadow can be rendered using the ZPass + //! or the zfail method. ZPass is a little bit faster because the shadow volume + //! creation is easier, but with this method there occur ugly looking artifacs + //! when the camera is inside the shadow volume. These error do not occur + //! with the ZFail method. + //! \param id: Id of the shadow scene node. This id can be used to identify + //! the node later. + //! \param zfailmethod: If set to true, the shadow will use the zfail method, + //! if not, zpass is used. + //! \param infinity: Value used by the shadow volume algorithm to scale the + //! shadow volume. + //! \return Returns pointer to the created shadow scene node. + //! This pointer should not be dropped. See IUnknown::drop() for more information. + virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(s32 id=-1, + bool zfailmethod=true, f32 infinity=10000.0f) = 0; + + //! Returns a pointer to a child node, wich has the same transformation as + //! the corresponding joint, if the mesh in this scene node is a ms3d mesh. + //! Otherwise 0 is returned. With this method it is possible to + //! attach scene nodes to joints more easily. In this way, it is + //! for example possible to attach a weapon to the left hand of an + //! animated model. This example shows how: + //! \code + //! ISceneNode* hand = + //! yourMS3DAnimatedMeshSceneNode->getMS3DJointNode("LeftHand"); + //! hand->addChild(weaponSceneNode); + //! \endcode + //! Please note that the SceneNode returned by this method may not exist + //! before this call and is created by it. + //! \param jointName: Name of the joint. + //! \return Returns a pointer to the scene node which represents the joint + //! with the specified name. Returns 0 if the contained mesh is not an + //! ms3d mesh or the name of the joint could not be found. + virtual ISceneNode* getMS3DJointNode(const c8* jointName) = 0; + + //! Returns a pointer to a child node, which has the same transformation as + //! the corresponding joint, if the mesh in this scene node is a x mesh. + //! Otherwise 0 is returned. With this method it is possible to + //! attach scene nodes to joints more easily. In this way, it is + //! for example possible to attach a weapon to the left hand of an + //! animated model. This example shows how: + //! \code + //! ISceneNode* hand = + //! yourMS3DAnimatedMeshSceneNode->getXJointNode("LeftHand"); + //! hand->addChild(weaponSceneNode); + //! \endcode + //! Please note that the SceneNode returned by this method may not exist + //! before this call and is created by it. + //! \param jointName: Name of the joint. + //! \return Returns a pointer to the scene node which represents the joint + //! with the specified name. Returns 0 if the contained mesh is not an + //! ms3d mesh or the name of the joint could not be found. + virtual ISceneNode* getXJointNode(const c8* jointName) = 0; + + //! Returns a pointer to a child node, wich has the same transformation as + //! the corresponding joint, if the mesh in this scene node is a b3d mesh. + //! Otherwise 0 is returned. With this method it is possible to + //! attach scene nodes to joints more easily. In this way, it is + //! for example possible to attach a weapon to the left hand of an + //! animated model. This example shows how: + //! \code + //! ISceneNode* hand = + //! yourB3DAnimatedMeshSceneNode->getB3DJointNode("LeftHand"); + //! hand->addChild(weaponSceneNode); + //! \endcode + //! Please note that the SceneNode returned by this method may not exist + //! before this call and is created by it. + //! \param jointName: Name of the joint. + //! \return Returns a pointer to the scene node which represents the joint + //! with the specified name. Returns 0 if the contained mesh is not an + //! ms3d mesh or the name of the joint could not be found. + virtual ISceneNode* getB3DJointNode(const c8* jointName) = 0; + + //! Starts a default MD2 animation. + //! With this method it is easily possible to start a Run, Attack, + //! Die or whatever animation, if the mesh contained in this scene + //! node is an md2 mesh. Otherwise, nothing happens. + //! \param anim: An MD2 animation type, which should be played, for + //! example EMAT_STAND for the standing animation. + //! \return Returns true if successful, and false if not, for example + //! if the mesh in the scene node is not a md2 mesh. + virtual bool setMD2Animation(EMD2_ANIMATION_TYPE anim) = 0; + + //! Starts a special MD2 animation. + //! With this method it is easily possible to start a Run, Attack, + //! Die or whatever animation, if the mesh contained in this scene + //! node is an md2 mesh. Otherwise, nothing happens. This method uses + //! a character string to identify the animation. If the animation is a + //! standard md2 animation, you might want to start this animation + //! with the EMD2_ANIMATION_TYPE enumeration instead. + //! \param animationName: Name of the animation which should be played. + //! \return Returns true if successful, and false if not, for example + //! if the mesh in the scene node is not an md2 mesh, or no animation + //! with this name could be found. + virtual bool setMD2Animation(const c8* animationName) = 0; + + //! Returns the current displayed frame number. + virtual s32 getFrameNr() = 0; + //! Returns the current start frame number. + virtual s32 getStartFrame() = 0; + //! Returns the current end frame number. + virtual s32 getEndFrame() = 0; + + //! Sets looping mode which is on by default. If set to false, + //! animations will not be played looped. + virtual void setLoopMode(bool playAnimationLooped) = 0; + + //! Sets a callback interface which will be called if an animation + //! playback has ended. Set this to 0 to disable the callback again. + //! Please note that this will only be called when in non looped mode, + //! see IAnimatedMeshSceneNode::setLoopMode(). + virtual void setAnimationEndCallback(IAnimationEndCallBack* callback=0) = 0; + + //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. + /* In this way it is possible to change the materials a mesh causing all mesh scene nodes + referencing this mesh to change too. */ + virtual void setReadOnlyMaterials(bool readonly) = 0; + + //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style + virtual bool isReadOnlyMaterials() = 0; + + //! Sets a new mesh + virtual void setMesh(IAnimatedMesh* mesh) = 0; + + //! Returns the current mesh + virtual IAnimatedMesh* getMesh(void) = 0; + + // returns the absolute transformation for a special MD3 Tag if the mesh is a md3 mesh, + // or the absolutetransformation if it's a normal scenenode + virtual const SMD3QuaterionTag& getAbsoluteTransformation( const core::stringc & tagname) = 0; + + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IAnimatedMeshX.h b/src/dep/include/irrlicht/IAnimatedMeshX.h index 2a2b5a5..f8b058d 100644 --- a/src/dep/include/irrlicht/IAnimatedMeshX.h +++ b/src/dep/include/irrlicht/IAnimatedMeshX.h @@ -1,80 +1,80 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ANIMATED_MESH_X_H_INCLUDED__ -#define __I_ANIMATED_MESH_X_H_INCLUDED__ - -#include "IAnimatedMesh.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - //! Interface for using some special functions of X meshes - class IAnimatedMeshX : public IAnimatedMesh - { - public: - - //! Returns a pointer to a transformation matrix of a part of the - //! mesh based on a frame time. This is used for being able to attach - //! objects to parts of animated meshes. For example a weapon to an animated - //! hand. - //! \param jointNumber: Zero based index of joint. The last joint has the number - //! IAnimatedMeshX::getJointCount()-1; - //! \param frame: Frame of the animation. - //! \return Returns a pointer to the matrix of the mesh part or - //! null if an error occured. - virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame) = 0; - - //! Gets joint count. - //! \return Returns amount of joints in the skeletal animated mesh. - virtual s32 getJointCount() const = 0; - - //! Gets the name of a joint. - //! \param number: Zero based index of joint. The last joint has the number - //! IAnimatedMeshX::getJointCount()-1; - //! \return Returns name of joint and null if an error happened. - virtual const c8* getJointName(s32 number) const = 0; - - //! Gets a joint number from its name - //! \param name: Name of the joint. - //! \return Returns the number of the joint or -1 if not found. - virtual s32 getJointNumber(const c8* name) const = 0; - - //! Returns a pointer to list of points containing the skeleton. - //! Draw a line between point 1 and 2, and 3 and 4 and 5 and 6 - //! and so on to visualize this. Only for debug purposes. If you - //! use an .x-File with the IAnimatedMeshSceneNode and turn DebugDataVisible - //! to true, the Scene node will visualize the skeleton using this - //! method. - virtual const core::array* getDrawableSkeleton(s32 frame) = 0; - - //! Returns amount of animations in .X-file. - virtual s32 getAnimationCount() const = 0; - - //! Returns the name of an animation. - //! \param idx: Zero based Index of the animation. Must be a value between - //! 0 and getAnimationCount()-1; - //! \return Returns pointer to the string of the name of the animation. - //! Returns 0 if an animation with this index does not exist. - virtual const c8* getAnimationName(s32 idx) const = 0; - - //! Sets an animation as animation to play back. - //! \param idx: Zero based Index of the animation. Must be a value between - //! 0 and getAnimationCount()-1; - virtual void setCurrentAnimation(s32 idx) = 0; - - //! Sets an animation as animation to play back. - //! \param name: Name of the animtion. - //! \return Returns true if successful, and false if the specified animation - //! does not exist. - virtual bool setCurrentAnimation(const c8* name) = 0; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_ANIMATED_MESH_X_H_INCLUDED__ +#define __I_ANIMATED_MESH_X_H_INCLUDED__ + +#include "IAnimatedMesh.h" +#include "irrArray.h" + +namespace irr +{ +namespace scene +{ + //! Interface for using some special functions of X meshes + class IAnimatedMeshX : public IAnimatedMesh + { + public: + + //! Returns a pointer to a transformation matrix of a part of the + //! mesh based on a frame time. This is used for being able to attach + //! objects to parts of animated meshes. For example a weapon to an animated + //! hand. + //! \param jointNumber: Zero based index of joint. The last joint has the number + //! IAnimatedMeshX::getJointCount()-1; + //! \param frame: Frame of the animation. + //! \return Returns a pointer to the matrix of the mesh part or + //! null if an error occured. + virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame) = 0; + + //! Gets joint count. + //! \return Returns amount of joints in the skeletal animated mesh. + virtual s32 getJointCount() const = 0; + + //! Gets the name of a joint. + //! \param number: Zero based index of joint. The last joint has the number + //! IAnimatedMeshX::getJointCount()-1; + //! \return Returns name of joint and null if an error happened. + virtual const c8* getJointName(s32 number) const = 0; + + //! Gets a joint number from its name + //! \param name: Name of the joint. + //! \return Returns the number of the joint or -1 if not found. + virtual s32 getJointNumber(const c8* name) const = 0; + + //! Returns a pointer to list of points containing the skeleton. + //! Draw a line between point 1 and 2, and 3 and 4 and 5 and 6 + //! and so on to visualize this. Only for debug purposes. If you + //! use an .x-File with the IAnimatedMeshSceneNode and turn DebugDataVisible + //! to true, the Scene node will visualize the skeleton using this + //! method. + virtual const core::array* getDrawableSkeleton(s32 frame) = 0; + + //! Returns amount of animations in .X-file. + virtual s32 getAnimationCount() const = 0; + + //! Returns the name of an animation. + //! \param idx: Zero based Index of the animation. Must be a value between + //! 0 and getAnimationCount()-1; + //! \return Returns pointer to the string of the name of the animation. + //! Returns 0 if an animation with this index does not exist. + virtual const c8* getAnimationName(s32 idx) const = 0; + + //! Sets an animation as animation to play back. + //! \param idx: Zero based Index of the animation. Must be a value between + //! 0 and getAnimationCount()-1; + virtual void setCurrentAnimation(s32 idx) = 0; + + //! Sets an animation as animation to play back. + //! \param name: Name of the animtion. + //! \return Returns true if successful, and false if the specified animation + //! does not exist. + virtual bool setCurrentAnimation(const c8* name) = 0; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IAttributeExchangingObject.h b/src/dep/include/irrlicht/IAttributeExchangingObject.h index 8fc8025..d433c1c 100644 --- a/src/dep/include/irrlicht/IAttributeExchangingObject.h +++ b/src/dep/include/irrlicht/IAttributeExchangingObject.h @@ -1,71 +1,71 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ATTRIBUTE_EXCHANGING_OBJECT_H_INCLUDED__ -#define __I_ATTRIBUTE_EXCHANGING_OBJECT_H_INCLUDED__ - -#include "IUnknown.h" - - -namespace irr -{ - -namespace io -{ - -class IAttributes; - -//! Enumation flags passed through SAttributeReadWriteOptions to the IAttributeExchangingObject object -enum E_ATTRIBUTE_READ_WRITE_FLAGS -{ - //! Serialization/Deserializion is done for an xml file - EARWF_FOR_FILE = 0x00000001, - - //! Serialization/Deserializion is done for an editor property box - EARWF_FOR_EDITOR = 0x00000002, - - //! When writing filenames, relative paths should be used - EARWF_USE_RELATIVE_PATHS = 0x00000004 -}; - - -//! struct holding data describing options -struct SAttributeReadWriteOptions -{ - //! constructor - SAttributeReadWriteOptions() - : Flags(0), Filename(0) - { - } - - //! Combination of E_ATTRIBUTE_READ_WRITE_FLAGS or other, custom ones - s32 Flags; - - //! optional filename - const c8* Filename; -}; - - -//! An object which is able to serialize and deserialize its attributes into an attributes object -class IAttributeExchangingObject : public virtual IUnknown -{ -public: - - //! Writes attributes of the object. - //! Implement this to expose the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) {} - - //! Reads attributes of the object. - //! Implement this to set the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml deserialization purposes. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) {} - -}; - -} // end namespace io -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_ATTRIBUTE_EXCHANGING_OBJECT_H_INCLUDED__ +#define __I_ATTRIBUTE_EXCHANGING_OBJECT_H_INCLUDED__ + +#include "IUnknown.h" + + +namespace irr +{ + +namespace io +{ + +class IAttributes; + +//! Enumation flags passed through SAttributeReadWriteOptions to the IAttributeExchangingObject object +enum E_ATTRIBUTE_READ_WRITE_FLAGS +{ + //! Serialization/Deserializion is done for an xml file + EARWF_FOR_FILE = 0x00000001, + + //! Serialization/Deserializion is done for an editor property box + EARWF_FOR_EDITOR = 0x00000002, + + //! When writing filenames, relative paths should be used + EARWF_USE_RELATIVE_PATHS = 0x00000004 +}; + + +//! struct holding data describing options +struct SAttributeReadWriteOptions +{ + //! constructor + SAttributeReadWriteOptions() + : Flags(0), Filename(0) + { + } + + //! Combination of E_ATTRIBUTE_READ_WRITE_FLAGS or other, custom ones + s32 Flags; + + //! optional filename + const c8* Filename; +}; + + +//! An object which is able to serialize and deserialize its attributes into an attributes object +class IAttributeExchangingObject : public virtual IUnknown +{ +public: + + //! Writes attributes of the object. + //! Implement this to expose the attributes of your scene node animator for + //! scripting languages, editors, debuggers or xml serialization purposes. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) {} + + //! Reads attributes of the object. + //! Implement this to set the attributes of your scene node animator for + //! scripting languages, editors, debuggers or xml deserialization purposes. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) {} + +}; + +} // end namespace io +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IAttributes.h b/src/dep/include/irrlicht/IAttributes.h index 0380c4e..976967f 100644 --- a/src/dep/include/irrlicht/IAttributes.h +++ b/src/dep/include/irrlicht/IAttributes.h @@ -1,725 +1,725 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ATTRIBUTES_H_INCLUDED__ -#define __I_ATTRIBUTES_H_INCLUDED__ - -#include "IUnknown.h" -#include "SColor.h" -#include "vector3d.h" -#include "vector2d.h" -#include "line2d.h" -#include "line3d.h" -#include "triangle3d.h" -#include "quaternion.h" -#include "position2d.h" -#include "rect.h" -#include "matrix4.h" -#include "quaternion.h" -#include "plane3d.h" -#include "triangle3d.h" -#include "line2d.h" -#include "line3d.h" -#include "irrString.h" -#include "irrArray.h" -#include "IXMLReader.h" - -namespace irr -{ -namespace video -{ - class ITexture; -} // end namespace video -namespace io -{ - class IXMLWriter; - -//! Types of attributes available for IAttributes -enum E_ATTRIBUTE_TYPE -{ - // integer attribute - EAT_INT = 0, - - // float attribute - EAT_FLOAT, - - // string attribute - EAT_STRING, - - // boolean attribute - EAT_BOOL, - - // enumeration attribute - EAT_ENUM, - - // color attribute - EAT_COLOR, - - // floating point color attribute - EAT_COLORF, - - // 3d vector attribute - EAT_VECTOR3D, - - // 2d position attribute - EAT_POSITION2D, - - // vector 2d - EAT_VECTOR2D, - - // rectangle attribute - EAT_RECT, - - // matrix attribute - EAT_MATRIX, - - // quaternion attribute - EAT_QUATERNION, - - // 3d bounding box - EAT_BBOX, - - // plane - EAT_PLANE, - - // 3d triangle - EAT_TRIANGLE3D, - - // line 2d - EAT_LINE2D, - - // line 3d - EAT_LINE3D, - - // array of stringws attribute - EAT_STRINGWARRAY, - - // array of float - EAT_FLOATARRAY, - - // array of int - EAT_INTARRAY, - - // binary data attribute - EAT_BINARY, - - // texture reference attribute - EAT_TEXTURE, - - // known attribute type count - EAT_COUNT, - - // unknown attribute - EAT_UNKNOWN -}; - -//! Provides a generic interface for attributes and their values and the possiblity to serialize them -class IAttributes : public virtual IUnknown -{ -public: - - //! Returns amount of attributes in this collection of attributes. - virtual s32 getAttributeCount() = 0; - - //! Returns attribute name by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual const c8* getAttributeName(s32 index) = 0; - - //! Returns the type of an attribute - //! \param attributeName: Name for the attribute - virtual E_ATTRIBUTE_TYPE getAttributeType(const c8* attributeName) = 0; - - //! Returns attribute type by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual E_ATTRIBUTE_TYPE getAttributeType(s32 index) = 0; - - //! Returns the type string of the attribute - //! \param attributeName: String for the attribute type - virtual const wchar_t* getAttributeTypeString(const c8* attributeName) = 0; - - //! Returns the type string of the attribute by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual const wchar_t* getAttributeTypeString(s32 index) = 0; - - //! Returns if an attribute with a name exists - virtual bool existsAttribute(const c8* attributeName) = 0; - - //! Returns attribute index from name, -1 if not found - virtual s32 findAttribute(const c8* attributeName) = 0; - - //! Removes all attributes - virtual void clear() = 0; - - //! Reads attributes from a xml file. - //! \param readCurrentElementOnly: If set to true, reading only works if current element has the name 'attributes'. - //! If set to false, the first appearing list attributes are read. - virtual bool read(irr::io::IXMLReader* reader, bool readCurrentElementOnly=false) = 0; - - //! Write these attributes into a xml file - //! \param writer: The XML writer to write to - //! \param writeXMLHeader: Writes a header to the XML file, required if at the beginning of the file - //! and you haven't already written one with writer->writeXMLHeader() - virtual bool write(io::IXMLWriter* writer, bool writeXMLHeader=false) = 0; - - - /* - - Integer Attribute - - */ - - //! Adds an attribute as integer - virtual void addInt(const c8* attributeName, s32 value) = 0; - - //! Sets an attribute as integer value - virtual void setAttribute(const c8* attributeName, s32 value) = 0; - - //! Gets an attribute as integer value - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual s32 getAttributeAsInt(const c8* attributeName) = 0; - - //! Gets an attribute as integer value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual s32 getAttributeAsInt(s32 index) = 0; - - //! Sets an attribute as integer value - virtual void setAttribute(s32 index, s32 value) = 0; - - /* - - Float Attribute - - */ - - //! Adds an attribute as float - virtual void addFloat(const c8* attributeName, f32 value) = 0; - - //! Sets a attribute as float value - virtual void setAttribute(const c8* attributeName, f32 value) = 0; - - //! Gets an attribute as float value - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual f32 getAttributeAsFloat(const c8* attributeName) = 0; - - //! Gets an attribute as float value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual f32 getAttributeAsFloat(s32 index) = 0; - - //! Sets an attribute as float value - virtual void setAttribute(s32 index, f32 value) = 0; - - /* - - String Attribute - - */ - - //! Adds an attribute as string - virtual void addString(const c8* attributeName, const c8* value) = 0; - - //! Sets an attribute value as string. - //! \param attributeName: Name for the attribute - //! \param value: Value for the attribute. Set this to 0 to delete the attribute - virtual void setAttribute(const c8* attributeName, const c8* value) = 0; - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - //! or 0 if attribute is not set. - virtual core::stringc getAttributeAsString(const c8* attributeName) = 0; - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \param target: Buffer where the string is copied to. - virtual void getAttributeAsString(const c8* attributeName, c8* target) = 0; - - //! Returns attribute value as string by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::stringc getAttributeAsString(s32 index) = 0; - - //! Sets an attribute value as string. - //! \param attributeName: Name for the attribute - virtual void setAttribute(s32 index, const c8* value) = 0; - - // wide strings - - //! Adds an attribute as string - virtual void addString(const c8* attributeName, const wchar_t* value) = 0; - - //! Sets an attribute value as string. - //! \param attributeName: Name for the attribute - //! \param value: Value for the attribute. Set this to 0 to delete the attribute - virtual void setAttribute(const c8* attributeName, const wchar_t* value) = 0; - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - //! or 0 if attribute is not set. - virtual core::stringw getAttributeAsStringW(const c8* attributeName) = 0; - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \param target: Buffer where the string is copied to. - virtual void getAttributeAsStringW(const c8* attributeName, wchar_t* target) = 0; - - //! Returns attribute value as string by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::stringw getAttributeAsStringW(s32 index) = 0; - - //! Sets an attribute value as string. - //! \param attributeName: Name for the attribute - virtual void setAttribute(s32 index, const wchar_t* value) = 0; - - /* - - Binary Data Attribute - - */ - - //! Adds an attribute as binary data - virtual void addBinary(const c8* attributeName, void* data, s32 dataSizeInBytes) = 0; - - //! Sets an attribute as binary data - virtual void setAttribute(const c8* attributeName, void* data, s32 dataSizeInBytes ) = 0; - - //! Gets an attribute as binary data - //! \param attributeName: Name of the attribute to get. - virtual void getAttributeAsBinaryData(const c8* attributeName, void* outData, s32 maxSizeInBytes) = 0; - - //! Gets an attribute as binary data - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual void getAttributeAsBinaryData(s32 index, void* outData, s32 maxSizeInBytes) = 0; - - //! Sets an attribute as binary data - virtual void setAttribute(s32 index, void* data, s32 dataSizeInBytes ) = 0; - - - /* - - Array Attribute - - */ - - //! Adds an attribute as wide string array - virtual void addArray(const c8* attributeName, core::array value) = 0; - - //! Sets an attribute value as a wide string array. - //! \param attributeName: Name for the attribute - //! \param value: Value for the attribute. Set this to 0 to delete the attribute - virtual void setAttribute(const c8* attributeName, const core::array value) = 0; - - //! Gets an attribute as an array of wide strings. - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - //! or 0 if attribute is not set. - virtual core::array getAttributeAsArray(const c8* attributeName) = 0; - - //! Returns attribute value as an array of wide strings by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::array getAttributeAsArray(s32 index) = 0; - - //! Sets an attribute as an array of wide strings - virtual void setAttribute(s32 index, core::array value) = 0; - - - /* - - Bool Attribute - - */ - - //! Adds an attribute as bool - virtual void addBool(const c8* attributeName, bool value) = 0; - - //! Sets an attribute as boolean value - virtual void setAttribute(const c8* attributeName, bool value) = 0; - - //! Gets an attribute as boolean value - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual bool getAttributeAsBool(const c8* attributeName) = 0; - - //! Gets an attribute as boolean value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual bool getAttributeAsBool(s32 index) = 0; - - //! Sets an attribute as boolean value - virtual void setAttribute(s32 index, bool value) = 0; - - /* - - Enumeration Attribute - - */ - - //! Adds an attribute as enum - virtual void addEnum(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals) = 0; - - //! Adds an attribute as enum - virtual void addEnum(const c8* attributeName, s32 enumValue, const c8* const* enumerationLiterals) = 0; - - //! Sets an attribute as enumeration - virtual void setAttribute(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals) = 0; - - //! Gets an attribute as enumeration - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual const c8* getAttributeAsEnumeration(const c8* attributeName) = 0; - - //! Gets an attribute as enumeration - //! \param attributeName: Name of the attribute to get. - //! \param enumerationLiteralsToUse: Use these enumeration literals to get the index value instead of the set ones. - //! This is useful when the attribute list maybe was read from an xml file, and only contains the enumeration string, but - //! no information about its index. - //! \return Returns value of the attribute previously set by setAttribute() - virtual s32 getAttributeAsEnumeration(const c8* attributeName, const c8* const* enumerationLiteralsToUse) = 0; - - //! Gets an attribute as enumeration - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual s32 getAttributeAsEnumeration(s32 index, const c8* const* enumerationLiteralsToUse) = 0; - - //! Gets an attribute as enumeration - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual const c8* getAttributeAsEnumeration(s32 index) = 0; - - //! Gets the list of enumeration literals of an enumeration attribute - //! \param attributeName: Name of the attribute to get. - virtual void getAttributeEnumerationLiteralsOfEnumeration(const c8* attributeName, core::array& outLiterals) = 0; - - //! Gets the list of enumeration literals of an enumeration attribute - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual void getAttributeEnumerationLiteralsOfEnumeration(s32 index, core::array& outLiterals) = 0; - - //! Sets an attribute as enumeration - virtual void setAttribute(s32 index, const c8* enumValue, const c8* const* enumerationLiterals) = 0; - - - /* - - SColor Attribute - - */ - - //! Adds an attribute as color - virtual void addColor(const c8* attributeName, video::SColor value) = 0; - - - //! Sets a attribute as color - virtual void setAttribute(const c8* attributeName, video::SColor color) = 0; - - //! Gets an attribute as color - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual video::SColor getAttributeAsColor(const c8* attributeName) = 0; - - //! Gets an attribute as color - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual video::SColor getAttributeAsColor(s32 index) = 0; - - //! Sets an attribute as color - virtual void setAttribute(s32 index, video::SColor color) = 0; - - /* - - SColorf Attribute - - */ - - //! Adds an attribute as floating point color - virtual void addColorf(const c8* attributeName, video::SColorf value) = 0; - - //! Sets a attribute as floating point color - virtual void setAttribute(const c8* attributeName, video::SColorf color) = 0; - - //! Gets an attribute as floating point color - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual video::SColorf getAttributeAsColorf(const c8* attributeName) = 0; - - //! Gets an attribute as floating point color - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual video::SColorf getAttributeAsColorf(s32 index) = 0; - - //! Sets an attribute as floating point color - virtual void setAttribute(s32 index, video::SColorf color) = 0; - - - /* - - Vector3d Attribute - - */ - - //! Adds an attribute as 3d vector - virtual void addVector3d(const c8* attributeName, core::vector3df value) = 0; - - //! Sets a attribute as 3d vector - virtual void setAttribute(const c8* attributeName, core::vector3df v) = 0; - - //! Gets an attribute as 3d vector - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::vector3df getAttributeAsVector3d(const c8* attributeName) = 0; - - //! Gets an attribute as 3d vector - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::vector3df getAttributeAsVector3d(s32 index) = 0; - - //! Sets an attribute as vector - virtual void setAttribute(s32 index, core::vector3df v) = 0; - - /* - - Position2d Attribute - - */ - - //! Adds an attribute as 2d position - virtual void addPosition2d(const c8* attributeName, core::position2di value) = 0; - - //! Sets a attribute as 2d position - virtual void setAttribute(const c8* attributeName, core::position2di v) = 0; - - //! Gets an attribute as position - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::position2di getAttributeAsPosition2d(const c8* attributeName) = 0; - - //! Gets an attribute as position - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::position2di getAttributeAsPosition2d(s32 index) = 0; - - //! Sets an attribute as 2d position - virtual void setAttribute(s32 index, core::position2di v) = 0; - - /* - - Rectangle Attribute - - */ - - //! Adds an attribute as rectangle - virtual void addRect(const c8* attributeName, core::rect value) = 0; - - //! Sets an attribute as rectangle - virtual void setAttribute(const c8* attributeName, core::rect v) = 0; - - //! Gets an attribute as rectangle - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::rect getAttributeAsRect(const c8* attributeName) = 0; - - //! Gets an attribute as rectangle - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::rect getAttributeAsRect(s32 index) = 0; - - //! Sets an attribute as rectangle - virtual void setAttribute(s32 index, core::rect v) = 0; - - - /* - - matrix attribute - - */ - - //! Adds an attribute as matrix - virtual void addMatrix(const c8* attributeName, core::matrix4 v) = 0; - - //! Sets an attribute as matrix - virtual void setAttribute(const c8* attributeName, core::matrix4 v) = 0; - - //! Gets an attribute as a matrix4 - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::matrix4 getAttributeAsMatrix(const c8* attributeName) = 0; - - //! Gets an attribute as matrix - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::matrix4 getAttributeAsMatrix(s32 index) = 0; - - //! Sets an attribute as matrix - virtual void setAttribute(s32 index, core::matrix4 v) = 0; - - /* - quaternion attribute - - */ - - //! Adds an attribute as quaternion - virtual void addQuaternion(const c8* attributeName, core::quaternion v) = 0; - - //! Sets an attribute as quaternion - virtual void setAttribute(const c8* attributeName, core::quaternion v) = 0; - - //! Gets an attribute as a quaternion - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::quaternion getAttributeAsQuaternion(const c8* attributeName) = 0; - - //! Gets an attribute as quaternion - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::quaternion getAttributeAsQuaternion(s32 index) = 0; - - //! Sets an attribute as quaternion - virtual void setAttribute(s32 index, core::quaternion v) = 0; - - /* - - 3d bounding box - - */ - - //! Adds an attribute as axis aligned bounding box - virtual void addBox3d(const c8* attributeName, core::aabbox3df v) = 0; - - //! Sets an attribute as axis aligned bounding box - virtual void setAttribute(const c8* attributeName, core::aabbox3df v) = 0; - - //! Gets an attribute as a axis aligned bounding box - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::aabbox3df getAttributeAsBox3d(const c8* attributeName) = 0; - - //! Gets an attribute as axis aligned bounding box - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::aabbox3df getAttributeAsBox3d(s32 index) = 0; - - //! Sets an attribute as axis aligned bounding box - virtual void setAttribute(s32 index, core::aabbox3df v) = 0; - - /* - - plane - - */ - - //! Adds an attribute as 3d plane - virtual void addPlane3d(const c8* attributeName, core::plane3df v) = 0; - - //! Sets an attribute as 3d plane - virtual void setAttribute(const c8* attributeName, core::plane3df v) = 0; - - //! Gets an attribute as a 3d plane - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::plane3df getAttributeAsPlane3d(const c8* attributeName) = 0; - - //! Gets an attribute as 3d plane - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::plane3df getAttributeAsPlane3d(s32 index) = 0; - - //! Sets an attribute as 3d plane - virtual void setAttribute(s32 index, core::plane3df v) = 0; - - - /* - - 3d triangle - - */ - - //! Adds an attribute as 3d triangle - virtual void addTriangle3d(const c8* attributeName, core::triangle3df v) = 0; - - //! Sets an attribute as 3d trianle - virtual void setAttribute(const c8* attributeName, core::triangle3df v) = 0; - - //! Gets an attribute as a 3d triangle - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::triangle3df getAttributeAsTriangle3d(const c8* attributeName) = 0; - - //! Gets an attribute as 3d triangle - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::triangle3df getAttributeAsTriangle3d(s32 index) = 0; - - //! Sets an attribute as 3d triangle - virtual void setAttribute(s32 index, core::triangle3df v) = 0; - - - /* - - line 2d - - */ - - //! Adds an attribute as a 2d line - virtual void addLine2d(const c8* attributeName, core::line2df v) = 0; - - //! Sets an attribute as a 2d line - virtual void setAttribute(const c8* attributeName, core::line2df v) = 0; - - //! Gets an attribute as a 2d line - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::line2df getAttributeAsLine2d(const c8* attributeName) = 0; - - //! Gets an attribute as a 2d line - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::line2df getAttributeAsLine2d(s32 index) = 0; - - //! Sets an attribute as a 2d line - virtual void setAttribute(s32 index, core::line2df v) = 0; - - - /* - - line 3d - - */ - - //! Adds an attribute as a 3d line - virtual void addLine3d(const c8* attributeName, core::line3df v) = 0; - - //! Sets an attribute as a 3d line - virtual void setAttribute(const c8* attributeName, core::line3df v) = 0; - - //! Gets an attribute as a 3d line - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::line3df getAttributeAsLine3d(const c8* attributeName) = 0; - - //! Gets an attribute as a 3d line - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::line3df getAttributeAsLine3d(s32 index) = 0; - - //! Sets an attribute as a 3d line - virtual void setAttribute(s32 index, core::line3df v) = 0; - - - /* - - Texture Attribute - - */ - - //! Adds an attribute as texture reference - virtual void addTexture(const c8* attributeName, video::ITexture* texture) = 0; - - //! Sets an attribute as texture reference - virtual void setAttribute(const c8* attributeName, video::ITexture* texture ) = 0; - - //! Gets an attribute as texture reference - //! \param attributeName: Name of the attribute to get. - virtual video::ITexture* getAttributeAsTexture(const c8* attributeName) = 0; - - //! Gets an attribute as texture reference - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual video::ITexture* getAttributeAsTexture(s32 index) = 0; - - //! Sets an attribute as texture reference - virtual void setAttribute(s32 index, video::ITexture* texture) = 0; - -}; - -} // end namespace io -} // end namespace irr - -#endif - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_ATTRIBUTES_H_INCLUDED__ +#define __I_ATTRIBUTES_H_INCLUDED__ + +#include "IUnknown.h" +#include "SColor.h" +#include "vector3d.h" +#include "vector2d.h" +#include "line2d.h" +#include "line3d.h" +#include "triangle3d.h" +#include "quaternion.h" +#include "position2d.h" +#include "rect.h" +#include "matrix4.h" +#include "quaternion.h" +#include "plane3d.h" +#include "triangle3d.h" +#include "line2d.h" +#include "line3d.h" +#include "irrString.h" +#include "irrArray.h" +#include "IXMLReader.h" + +namespace irr +{ +namespace video +{ + class ITexture; +} // end namespace video +namespace io +{ + class IXMLWriter; + +//! Types of attributes available for IAttributes +enum E_ATTRIBUTE_TYPE +{ + // integer attribute + EAT_INT = 0, + + // float attribute + EAT_FLOAT, + + // string attribute + EAT_STRING, + + // boolean attribute + EAT_BOOL, + + // enumeration attribute + EAT_ENUM, + + // color attribute + EAT_COLOR, + + // floating point color attribute + EAT_COLORF, + + // 3d vector attribute + EAT_VECTOR3D, + + // 2d position attribute + EAT_POSITION2D, + + // vector 2d + EAT_VECTOR2D, + + // rectangle attribute + EAT_RECT, + + // matrix attribute + EAT_MATRIX, + + // quaternion attribute + EAT_QUATERNION, + + // 3d bounding box + EAT_BBOX, + + // plane + EAT_PLANE, + + // 3d triangle + EAT_TRIANGLE3D, + + // line 2d + EAT_LINE2D, + + // line 3d + EAT_LINE3D, + + // array of stringws attribute + EAT_STRINGWARRAY, + + // array of float + EAT_FLOATARRAY, + + // array of int + EAT_INTARRAY, + + // binary data attribute + EAT_BINARY, + + // texture reference attribute + EAT_TEXTURE, + + // known attribute type count + EAT_COUNT, + + // unknown attribute + EAT_UNKNOWN +}; + +//! Provides a generic interface for attributes and their values and the possiblity to serialize them +class IAttributes : public virtual IUnknown +{ +public: + + //! Returns amount of attributes in this collection of attributes. + virtual s32 getAttributeCount() = 0; + + //! Returns attribute name by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual const c8* getAttributeName(s32 index) = 0; + + //! Returns the type of an attribute + //! \param attributeName: Name for the attribute + virtual E_ATTRIBUTE_TYPE getAttributeType(const c8* attributeName) = 0; + + //! Returns attribute type by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual E_ATTRIBUTE_TYPE getAttributeType(s32 index) = 0; + + //! Returns the type string of the attribute + //! \param attributeName: String for the attribute type + virtual const wchar_t* getAttributeTypeString(const c8* attributeName) = 0; + + //! Returns the type string of the attribute by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual const wchar_t* getAttributeTypeString(s32 index) = 0; + + //! Returns if an attribute with a name exists + virtual bool existsAttribute(const c8* attributeName) = 0; + + //! Returns attribute index from name, -1 if not found + virtual s32 findAttribute(const c8* attributeName) = 0; + + //! Removes all attributes + virtual void clear() = 0; + + //! Reads attributes from a xml file. + //! \param readCurrentElementOnly: If set to true, reading only works if current element has the name 'attributes'. + //! If set to false, the first appearing list attributes are read. + virtual bool read(irr::io::IXMLReader* reader, bool readCurrentElementOnly=false) = 0; + + //! Write these attributes into a xml file + //! \param writer: The XML writer to write to + //! \param writeXMLHeader: Writes a header to the XML file, required if at the beginning of the file + //! and you haven't already written one with writer->writeXMLHeader() + virtual bool write(io::IXMLWriter* writer, bool writeXMLHeader=false) = 0; + + + /* + + Integer Attribute + + */ + + //! Adds an attribute as integer + virtual void addInt(const c8* attributeName, s32 value) = 0; + + //! Sets an attribute as integer value + virtual void setAttribute(const c8* attributeName, s32 value) = 0; + + //! Gets an attribute as integer value + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual s32 getAttributeAsInt(const c8* attributeName) = 0; + + //! Gets an attribute as integer value + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual s32 getAttributeAsInt(s32 index) = 0; + + //! Sets an attribute as integer value + virtual void setAttribute(s32 index, s32 value) = 0; + + /* + + Float Attribute + + */ + + //! Adds an attribute as float + virtual void addFloat(const c8* attributeName, f32 value) = 0; + + //! Sets a attribute as float value + virtual void setAttribute(const c8* attributeName, f32 value) = 0; + + //! Gets an attribute as float value + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual f32 getAttributeAsFloat(const c8* attributeName) = 0; + + //! Gets an attribute as float value + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual f32 getAttributeAsFloat(s32 index) = 0; + + //! Sets an attribute as float value + virtual void setAttribute(s32 index, f32 value) = 0; + + /* + + String Attribute + + */ + + //! Adds an attribute as string + virtual void addString(const c8* attributeName, const c8* value) = 0; + + //! Sets an attribute value as string. + //! \param attributeName: Name for the attribute + //! \param value: Value for the attribute. Set this to 0 to delete the attribute + virtual void setAttribute(const c8* attributeName, const c8* value) = 0; + + //! Gets an attribute as string. + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + //! or 0 if attribute is not set. + virtual core::stringc getAttributeAsString(const c8* attributeName) = 0; + + //! Gets an attribute as string. + //! \param attributeName: Name of the attribute to get. + //! \param target: Buffer where the string is copied to. + virtual void getAttributeAsString(const c8* attributeName, c8* target) = 0; + + //! Returns attribute value as string by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::stringc getAttributeAsString(s32 index) = 0; + + //! Sets an attribute value as string. + //! \param attributeName: Name for the attribute + virtual void setAttribute(s32 index, const c8* value) = 0; + + // wide strings + + //! Adds an attribute as string + virtual void addString(const c8* attributeName, const wchar_t* value) = 0; + + //! Sets an attribute value as string. + //! \param attributeName: Name for the attribute + //! \param value: Value for the attribute. Set this to 0 to delete the attribute + virtual void setAttribute(const c8* attributeName, const wchar_t* value) = 0; + + //! Gets an attribute as string. + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + //! or 0 if attribute is not set. + virtual core::stringw getAttributeAsStringW(const c8* attributeName) = 0; + + //! Gets an attribute as string. + //! \param attributeName: Name of the attribute to get. + //! \param target: Buffer where the string is copied to. + virtual void getAttributeAsStringW(const c8* attributeName, wchar_t* target) = 0; + + //! Returns attribute value as string by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::stringw getAttributeAsStringW(s32 index) = 0; + + //! Sets an attribute value as string. + //! \param attributeName: Name for the attribute + virtual void setAttribute(s32 index, const wchar_t* value) = 0; + + /* + + Binary Data Attribute + + */ + + //! Adds an attribute as binary data + virtual void addBinary(const c8* attributeName, void* data, s32 dataSizeInBytes) = 0; + + //! Sets an attribute as binary data + virtual void setAttribute(const c8* attributeName, void* data, s32 dataSizeInBytes ) = 0; + + //! Gets an attribute as binary data + //! \param attributeName: Name of the attribute to get. + virtual void getAttributeAsBinaryData(const c8* attributeName, void* outData, s32 maxSizeInBytes) = 0; + + //! Gets an attribute as binary data + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual void getAttributeAsBinaryData(s32 index, void* outData, s32 maxSizeInBytes) = 0; + + //! Sets an attribute as binary data + virtual void setAttribute(s32 index, void* data, s32 dataSizeInBytes ) = 0; + + + /* + + Array Attribute + + */ + + //! Adds an attribute as wide string array + virtual void addArray(const c8* attributeName, core::array value) = 0; + + //! Sets an attribute value as a wide string array. + //! \param attributeName: Name for the attribute + //! \param value: Value for the attribute. Set this to 0 to delete the attribute + virtual void setAttribute(const c8* attributeName, const core::array value) = 0; + + //! Gets an attribute as an array of wide strings. + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + //! or 0 if attribute is not set. + virtual core::array getAttributeAsArray(const c8* attributeName) = 0; + + //! Returns attribute value as an array of wide strings by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::array getAttributeAsArray(s32 index) = 0; + + //! Sets an attribute as an array of wide strings + virtual void setAttribute(s32 index, core::array value) = 0; + + + /* + + Bool Attribute + + */ + + //! Adds an attribute as bool + virtual void addBool(const c8* attributeName, bool value) = 0; + + //! Sets an attribute as boolean value + virtual void setAttribute(const c8* attributeName, bool value) = 0; + + //! Gets an attribute as boolean value + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual bool getAttributeAsBool(const c8* attributeName) = 0; + + //! Gets an attribute as boolean value + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual bool getAttributeAsBool(s32 index) = 0; + + //! Sets an attribute as boolean value + virtual void setAttribute(s32 index, bool value) = 0; + + /* + + Enumeration Attribute + + */ + + //! Adds an attribute as enum + virtual void addEnum(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals) = 0; + + //! Adds an attribute as enum + virtual void addEnum(const c8* attributeName, s32 enumValue, const c8* const* enumerationLiterals) = 0; + + //! Sets an attribute as enumeration + virtual void setAttribute(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals) = 0; + + //! Gets an attribute as enumeration + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual const c8* getAttributeAsEnumeration(const c8* attributeName) = 0; + + //! Gets an attribute as enumeration + //! \param attributeName: Name of the attribute to get. + //! \param enumerationLiteralsToUse: Use these enumeration literals to get the index value instead of the set ones. + //! This is useful when the attribute list maybe was read from an xml file, and only contains the enumeration string, but + //! no information about its index. + //! \return Returns value of the attribute previously set by setAttribute() + virtual s32 getAttributeAsEnumeration(const c8* attributeName, const c8* const* enumerationLiteralsToUse) = 0; + + //! Gets an attribute as enumeration + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual s32 getAttributeAsEnumeration(s32 index, const c8* const* enumerationLiteralsToUse) = 0; + + //! Gets an attribute as enumeration + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual const c8* getAttributeAsEnumeration(s32 index) = 0; + + //! Gets the list of enumeration literals of an enumeration attribute + //! \param attributeName: Name of the attribute to get. + virtual void getAttributeEnumerationLiteralsOfEnumeration(const c8* attributeName, core::array& outLiterals) = 0; + + //! Gets the list of enumeration literals of an enumeration attribute + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual void getAttributeEnumerationLiteralsOfEnumeration(s32 index, core::array& outLiterals) = 0; + + //! Sets an attribute as enumeration + virtual void setAttribute(s32 index, const c8* enumValue, const c8* const* enumerationLiterals) = 0; + + + /* + + SColor Attribute + + */ + + //! Adds an attribute as color + virtual void addColor(const c8* attributeName, video::SColor value) = 0; + + + //! Sets a attribute as color + virtual void setAttribute(const c8* attributeName, video::SColor color) = 0; + + //! Gets an attribute as color + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual video::SColor getAttributeAsColor(const c8* attributeName) = 0; + + //! Gets an attribute as color + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual video::SColor getAttributeAsColor(s32 index) = 0; + + //! Sets an attribute as color + virtual void setAttribute(s32 index, video::SColor color) = 0; + + /* + + SColorf Attribute + + */ + + //! Adds an attribute as floating point color + virtual void addColorf(const c8* attributeName, video::SColorf value) = 0; + + //! Sets a attribute as floating point color + virtual void setAttribute(const c8* attributeName, video::SColorf color) = 0; + + //! Gets an attribute as floating point color + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual video::SColorf getAttributeAsColorf(const c8* attributeName) = 0; + + //! Gets an attribute as floating point color + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual video::SColorf getAttributeAsColorf(s32 index) = 0; + + //! Sets an attribute as floating point color + virtual void setAttribute(s32 index, video::SColorf color) = 0; + + + /* + + Vector3d Attribute + + */ + + //! Adds an attribute as 3d vector + virtual void addVector3d(const c8* attributeName, core::vector3df value) = 0; + + //! Sets a attribute as 3d vector + virtual void setAttribute(const c8* attributeName, core::vector3df v) = 0; + + //! Gets an attribute as 3d vector + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::vector3df getAttributeAsVector3d(const c8* attributeName) = 0; + + //! Gets an attribute as 3d vector + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::vector3df getAttributeAsVector3d(s32 index) = 0; + + //! Sets an attribute as vector + virtual void setAttribute(s32 index, core::vector3df v) = 0; + + /* + + Position2d Attribute + + */ + + //! Adds an attribute as 2d position + virtual void addPosition2d(const c8* attributeName, core::position2di value) = 0; + + //! Sets a attribute as 2d position + virtual void setAttribute(const c8* attributeName, core::position2di v) = 0; + + //! Gets an attribute as position + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::position2di getAttributeAsPosition2d(const c8* attributeName) = 0; + + //! Gets an attribute as position + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::position2di getAttributeAsPosition2d(s32 index) = 0; + + //! Sets an attribute as 2d position + virtual void setAttribute(s32 index, core::position2di v) = 0; + + /* + + Rectangle Attribute + + */ + + //! Adds an attribute as rectangle + virtual void addRect(const c8* attributeName, core::rect value) = 0; + + //! Sets an attribute as rectangle + virtual void setAttribute(const c8* attributeName, core::rect v) = 0; + + //! Gets an attribute as rectangle + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::rect getAttributeAsRect(const c8* attributeName) = 0; + + //! Gets an attribute as rectangle + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::rect getAttributeAsRect(s32 index) = 0; + + //! Sets an attribute as rectangle + virtual void setAttribute(s32 index, core::rect v) = 0; + + + /* + + matrix attribute + + */ + + //! Adds an attribute as matrix + virtual void addMatrix(const c8* attributeName, core::matrix4 v) = 0; + + //! Sets an attribute as matrix + virtual void setAttribute(const c8* attributeName, core::matrix4 v) = 0; + + //! Gets an attribute as a matrix4 + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::matrix4 getAttributeAsMatrix(const c8* attributeName) = 0; + + //! Gets an attribute as matrix + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::matrix4 getAttributeAsMatrix(s32 index) = 0; + + //! Sets an attribute as matrix + virtual void setAttribute(s32 index, core::matrix4 v) = 0; + + /* + quaternion attribute + + */ + + //! Adds an attribute as quaternion + virtual void addQuaternion(const c8* attributeName, core::quaternion v) = 0; + + //! Sets an attribute as quaternion + virtual void setAttribute(const c8* attributeName, core::quaternion v) = 0; + + //! Gets an attribute as a quaternion + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::quaternion getAttributeAsQuaternion(const c8* attributeName) = 0; + + //! Gets an attribute as quaternion + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::quaternion getAttributeAsQuaternion(s32 index) = 0; + + //! Sets an attribute as quaternion + virtual void setAttribute(s32 index, core::quaternion v) = 0; + + /* + + 3d bounding box + + */ + + //! Adds an attribute as axis aligned bounding box + virtual void addBox3d(const c8* attributeName, core::aabbox3df v) = 0; + + //! Sets an attribute as axis aligned bounding box + virtual void setAttribute(const c8* attributeName, core::aabbox3df v) = 0; + + //! Gets an attribute as a axis aligned bounding box + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::aabbox3df getAttributeAsBox3d(const c8* attributeName) = 0; + + //! Gets an attribute as axis aligned bounding box + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::aabbox3df getAttributeAsBox3d(s32 index) = 0; + + //! Sets an attribute as axis aligned bounding box + virtual void setAttribute(s32 index, core::aabbox3df v) = 0; + + /* + + plane + + */ + + //! Adds an attribute as 3d plane + virtual void addPlane3d(const c8* attributeName, core::plane3df v) = 0; + + //! Sets an attribute as 3d plane + virtual void setAttribute(const c8* attributeName, core::plane3df v) = 0; + + //! Gets an attribute as a 3d plane + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::plane3df getAttributeAsPlane3d(const c8* attributeName) = 0; + + //! Gets an attribute as 3d plane + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::plane3df getAttributeAsPlane3d(s32 index) = 0; + + //! Sets an attribute as 3d plane + virtual void setAttribute(s32 index, core::plane3df v) = 0; + + + /* + + 3d triangle + + */ + + //! Adds an attribute as 3d triangle + virtual void addTriangle3d(const c8* attributeName, core::triangle3df v) = 0; + + //! Sets an attribute as 3d trianle + virtual void setAttribute(const c8* attributeName, core::triangle3df v) = 0; + + //! Gets an attribute as a 3d triangle + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::triangle3df getAttributeAsTriangle3d(const c8* attributeName) = 0; + + //! Gets an attribute as 3d triangle + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::triangle3df getAttributeAsTriangle3d(s32 index) = 0; + + //! Sets an attribute as 3d triangle + virtual void setAttribute(s32 index, core::triangle3df v) = 0; + + + /* + + line 2d + + */ + + //! Adds an attribute as a 2d line + virtual void addLine2d(const c8* attributeName, core::line2df v) = 0; + + //! Sets an attribute as a 2d line + virtual void setAttribute(const c8* attributeName, core::line2df v) = 0; + + //! Gets an attribute as a 2d line + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::line2df getAttributeAsLine2d(const c8* attributeName) = 0; + + //! Gets an attribute as a 2d line + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::line2df getAttributeAsLine2d(s32 index) = 0; + + //! Sets an attribute as a 2d line + virtual void setAttribute(s32 index, core::line2df v) = 0; + + + /* + + line 3d + + */ + + //! Adds an attribute as a 3d line + virtual void addLine3d(const c8* attributeName, core::line3df v) = 0; + + //! Sets an attribute as a 3d line + virtual void setAttribute(const c8* attributeName, core::line3df v) = 0; + + //! Gets an attribute as a 3d line + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::line3df getAttributeAsLine3d(const c8* attributeName) = 0; + + //! Gets an attribute as a 3d line + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::line3df getAttributeAsLine3d(s32 index) = 0; + + //! Sets an attribute as a 3d line + virtual void setAttribute(s32 index, core::line3df v) = 0; + + + /* + + Texture Attribute + + */ + + //! Adds an attribute as texture reference + virtual void addTexture(const c8* attributeName, video::ITexture* texture) = 0; + + //! Sets an attribute as texture reference + virtual void setAttribute(const c8* attributeName, video::ITexture* texture ) = 0; + + //! Gets an attribute as texture reference + //! \param attributeName: Name of the attribute to get. + virtual video::ITexture* getAttributeAsTexture(const c8* attributeName) = 0; + + //! Gets an attribute as texture reference + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual video::ITexture* getAttributeAsTexture(s32 index) = 0; + + //! Sets an attribute as texture reference + virtual void setAttribute(s32 index, video::ITexture* texture) = 0; + +}; + +} // end namespace io +} // end namespace irr + +#endif + + + diff --git a/src/dep/include/irrlicht/IBillboardSceneNode.h b/src/dep/include/irrlicht/IBillboardSceneNode.h index acf4e42..7a6eba2 100644 --- a/src/dep/include/irrlicht/IBillboardSceneNode.h +++ b/src/dep/include/irrlicht/IBillboardSceneNode.h @@ -1,56 +1,56 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_BILLBOARD_SCENE_NODE_H_INCLUDED__ -#define __I_BILLBOARD_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! A billboard scene node. -/** A billboard is like a 3d sprite: A 2d element, -which always looks to the camera. It is usually used for explosions, fire, -lensflares, particles and things like that. -*/ -class IBillboardSceneNode : public ISceneNode -{ -public: - - //! constructor - IBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0)) - : ISceneNode(parent, mgr, id, position) {} - - //! Sets the size of the billboard. - virtual void setSize(const core::dimension2d& size) = 0; - - //! Returns the size of the billboard. - virtual const core::dimension2d& getSize() = 0; - - //! Set the color of all vertices of the billboard - //! \param overallColor: the color to set - virtual void setColor(const video::SColor & overallColor) = 0; - - //! Set the color of the top and bottom vertices of the billboard - //! \param topColor: the color to set the top vertices - //! \param bottomColor: the color to set the bottom vertices - virtual void setColor(const video::SColor & topColor, const video::SColor & bottomColor) = 0; - - //! Gets the color of the top and bottom vertices of the billboard - //! \param[out] topColor: stores the color of the top vertices - //! \param[out] bottomColor: stores the color of the bottom vertices - virtual void getColor(video::SColor & topColor, video::SColor & bottomColor) = 0; - -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_BILLBOARD_SCENE_NODE_H_INCLUDED__ +#define __I_BILLBOARD_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + +//! A billboard scene node. +/** A billboard is like a 3d sprite: A 2d element, +which always looks to the camera. It is usually used for explosions, fire, +lensflares, particles and things like that. +*/ +class IBillboardSceneNode : public ISceneNode +{ +public: + + //! constructor + IBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position = core::vector3df(0,0,0)) + : ISceneNode(parent, mgr, id, position) {} + + //! Sets the size of the billboard. + virtual void setSize(const core::dimension2d& size) = 0; + + //! Returns the size of the billboard. + virtual const core::dimension2d& getSize() = 0; + + //! Set the color of all vertices of the billboard + //! \param overallColor: the color to set + virtual void setColor(const video::SColor & overallColor) = 0; + + //! Set the color of the top and bottom vertices of the billboard + //! \param topColor: the color to set the top vertices + //! \param bottomColor: the color to set the bottom vertices + virtual void setColor(const video::SColor & topColor, const video::SColor & bottomColor) = 0; + + //! Gets the color of the top and bottom vertices of the billboard + //! \param[out] topColor: stores the color of the top vertices + //! \param[out] bottomColor: stores the color of the bottom vertices + virtual void getColor(video::SColor & topColor, video::SColor & bottomColor) = 0; + +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/ICameraSceneNode.h b/src/dep/include/irrlicht/ICameraSceneNode.h index d18da3c..7d21879 100644 --- a/src/dep/include/irrlicht/ICameraSceneNode.h +++ b/src/dep/include/irrlicht/ICameraSceneNode.h @@ -1,149 +1,149 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_CAMERA_SCENE_NODE_H_INCLUDED__ -#define __I_CAMERA_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "IEventReceiver.h" -#include "SViewFrustum.h" - -namespace irr -{ -namespace scene -{ - - //! Scene Node which is a (controlable) camera. - /** The whole scene will be - rendered from the cameras point of view. Because the ICameraScenNode - is a SceneNode, it can be attached to any other scene node, and will - follow its parents movement, rotation and so on. - */ - class ICameraSceneNode : public ISceneNode, public IEventReceiver - { - public: - - //! Constructor - ICameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f)) - : ISceneNode(parent, mgr, id, position, rotation, scale), IsOrthogonal(false) {} - - //! Destructor - virtual ~ICameraSceneNode() {}; - - //! Sets the projection matrix of the camera. - /** The core::matrix4 class has some methods - to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH. - Note that the matrix will only stay as set by this method until one of - the following Methods are called: setNearValue, setFarValue, setAspectRatio, setFOV. - \param projection: The new projection matrix of the camera. */ - virtual void setProjectionMatrix(const core::matrix4& projection) = 0; - - //! Gets the current projection matrix of the camera. - /** \return Returns the current projection matrix of the camera. */ - virtual const core::matrix4& getProjectionMatrix() = 0; - - //! Gets the current view matrix of the camera. - /** \return Returns the current view matrix of the camera. */ - virtual const core::matrix4& getViewMatrix() = 0; - - //! It is possible to send mouse and key events to the camera. - /** Most cameras - may ignore this input, but camera scene nodes which are created for - example with ISceneManager::addMayaCameraSceneNode or - ISceneManager::addMeshViewerCameraSceneNode, may want to get this input - for changing their position, look at target or whatever. */ - virtual bool OnEvent(SEvent event) = 0; - - //! Sets the look at target of the camera - /** \param pos: Look at target of the camera. */ - virtual void setTarget(const core::vector3df& pos) = 0; - - //! Gets the current look at target of the camera - /** \return Returns the current look at target of the camera */ - virtual core::vector3df getTarget() const = 0; - - //! Sets the up vector of the camera. - /** \param pos: New upvector of the camera. */ - virtual void setUpVector(const core::vector3df& pos) = 0; - - //! Gets the up vector of the camera. - /** \return Returns the up vector of the camera. */ - virtual core::vector3df getUpVector() const = 0; - - //! Gets the value of the near plane of the camera. - /** \return Returns the value of the near plane of the camera. */ - virtual f32 getNearValue() = 0; - - //! Gets the value of the far plane of the camera. - /** \return Returns the value of the far plane of the camera. */ - virtual f32 getFarValue() = 0; - - //! Gets the aspect ratio of the camera. - /** \return Returns the aspect ratio of the camera. */ - virtual f32 getAspectRatio() = 0; - - //! Gets the field of view of the camera. - /** \return Returns the field of view of the camera in radiants. */ - virtual f32 getFOV() = 0; - - //! Sets the value of the near clipping plane. (default: 1.0f) - /** \param zn: New z near value. */ - virtual void setNearValue(f32 zn) = 0; - - //! Sets the value of the far clipping plane (default: 2000.0f) - /** \param zf: New z far value. */ - virtual void setFarValue(f32 zf) = 0; - - //! Sets the aspect ratio (default: 4.0f / 3.0f) - /** \param aspect: New aspect ratio. */ - virtual void setAspectRatio(f32 aspect) = 0; - - //! Sets the field of view (Default: PI / 2.5f) - /** \param fovy: New field of view in radiants. */ - virtual void setFOV(f32 fovy) = 0; - - //! Returns the view frustum. - /** Needed sometimes by bspTree or LOD render nodes. - \return Returns the current view frustum. */ - virtual const SViewFrustum* getViewFrustum() const = 0; - - //! Disables or enables the camera to get key or mouse inputs. - /** If this is set to true, the camera will respond to key inputs - otherwise not. */ - virtual void setInputReceiverEnabled(bool enabled) = 0; - - //! Returns if the input receiver of the camera is currently enabled. - virtual bool isInputReceiverEnabled() = 0; - - //! Returns if a camera is orthogonal. - /** This setting does not change anything of the view or projection matrix. However - it influences how collision detection and picking is done with this camera. */ - virtual bool isOrthogonal() - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsOrthogonal; - } - - //! Sets if this camera should return if it is orthogonal. - /** This setting does not change anything of the view or projection matrix. However - it influences how collision detection and picking is done with this camera. */ - void setIsOrthogonal( bool orthogonal ) - { - IsOrthogonal = orthogonal; - } - - - private: - - bool IsOrthogonal; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_CAMERA_SCENE_NODE_H_INCLUDED__ +#define __I_CAMERA_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" +#include "IEventReceiver.h" +#include "SViewFrustum.h" + +namespace irr +{ +namespace scene +{ + + //! Scene Node which is a (controlable) camera. + /** The whole scene will be + rendered from the cameras point of view. Because the ICameraScenNode + is a SceneNode, it can be attached to any other scene node, and will + follow its parents movement, rotation and so on. + */ + class ICameraSceneNode : public ISceneNode, public IEventReceiver + { + public: + + //! Constructor + ICameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f)) + : ISceneNode(parent, mgr, id, position, rotation, scale), IsOrthogonal(false) {} + + //! Destructor + virtual ~ICameraSceneNode() {}; + + //! Sets the projection matrix of the camera. + /** The core::matrix4 class has some methods + to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH. + Note that the matrix will only stay as set by this method until one of + the following Methods are called: setNearValue, setFarValue, setAspectRatio, setFOV. + \param projection: The new projection matrix of the camera. */ + virtual void setProjectionMatrix(const core::matrix4& projection) = 0; + + //! Gets the current projection matrix of the camera. + /** \return Returns the current projection matrix of the camera. */ + virtual const core::matrix4& getProjectionMatrix() = 0; + + //! Gets the current view matrix of the camera. + /** \return Returns the current view matrix of the camera. */ + virtual const core::matrix4& getViewMatrix() = 0; + + //! It is possible to send mouse and key events to the camera. + /** Most cameras + may ignore this input, but camera scene nodes which are created for + example with ISceneManager::addMayaCameraSceneNode or + ISceneManager::addMeshViewerCameraSceneNode, may want to get this input + for changing their position, look at target or whatever. */ + virtual bool OnEvent(SEvent event) = 0; + + //! Sets the look at target of the camera + /** \param pos: Look at target of the camera. */ + virtual void setTarget(const core::vector3df& pos) = 0; + + //! Gets the current look at target of the camera + /** \return Returns the current look at target of the camera */ + virtual core::vector3df getTarget() const = 0; + + //! Sets the up vector of the camera. + /** \param pos: New upvector of the camera. */ + virtual void setUpVector(const core::vector3df& pos) = 0; + + //! Gets the up vector of the camera. + /** \return Returns the up vector of the camera. */ + virtual core::vector3df getUpVector() const = 0; + + //! Gets the value of the near plane of the camera. + /** \return Returns the value of the near plane of the camera. */ + virtual f32 getNearValue() = 0; + + //! Gets the value of the far plane of the camera. + /** \return Returns the value of the far plane of the camera. */ + virtual f32 getFarValue() = 0; + + //! Gets the aspect ratio of the camera. + /** \return Returns the aspect ratio of the camera. */ + virtual f32 getAspectRatio() = 0; + + //! Gets the field of view of the camera. + /** \return Returns the field of view of the camera in radiants. */ + virtual f32 getFOV() = 0; + + //! Sets the value of the near clipping plane. (default: 1.0f) + /** \param zn: New z near value. */ + virtual void setNearValue(f32 zn) = 0; + + //! Sets the value of the far clipping plane (default: 2000.0f) + /** \param zf: New z far value. */ + virtual void setFarValue(f32 zf) = 0; + + //! Sets the aspect ratio (default: 4.0f / 3.0f) + /** \param aspect: New aspect ratio. */ + virtual void setAspectRatio(f32 aspect) = 0; + + //! Sets the field of view (Default: PI / 2.5f) + /** \param fovy: New field of view in radiants. */ + virtual void setFOV(f32 fovy) = 0; + + //! Returns the view frustum. + /** Needed sometimes by bspTree or LOD render nodes. + \return Returns the current view frustum. */ + virtual const SViewFrustum* getViewFrustum() const = 0; + + //! Disables or enables the camera to get key or mouse inputs. + /** If this is set to true, the camera will respond to key inputs + otherwise not. */ + virtual void setInputReceiverEnabled(bool enabled) = 0; + + //! Returns if the input receiver of the camera is currently enabled. + virtual bool isInputReceiverEnabled() = 0; + + //! Returns if a camera is orthogonal. + /** This setting does not change anything of the view or projection matrix. However + it influences how collision detection and picking is done with this camera. */ + virtual bool isOrthogonal() + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return IsOrthogonal; + } + + //! Sets if this camera should return if it is orthogonal. + /** This setting does not change anything of the view or projection matrix. However + it influences how collision detection and picking is done with this camera. */ + void setIsOrthogonal( bool orthogonal ) + { + IsOrthogonal = orthogonal; + } + + + private: + + bool IsOrthogonal; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/ICursorControl.h b/src/dep/include/irrlicht/ICursorControl.h index 3af30b0..43e142a 100644 --- a/src/dep/include/irrlicht/ICursorControl.h +++ b/src/dep/include/irrlicht/ICursorControl.h @@ -1,71 +1,71 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_CURSOR_CONTROL_H_INCLUDED__ -#define __I_CURSOR_CONTROL_H_INCLUDED__ - -#include "position2d.h" -#include "IUnknown.h" -#include "irrTypes.h" - -namespace irr -{ -namespace gui -{ - - //! Interface to manipulate the mouse cursor. - class ICursorControl : public virtual IUnknown - { - public: - - //! Changes the visible state of the mouse cursor. - /** \param visible: The new visible state. If true, the cursor will be visible, - if false, it will be invisible. */ - virtual void setVisible(bool visible) = 0; - - //! Returns if the cursor is currently visible. - /** \return Returns true if the cursor is visible, false if not. */ - virtual bool isVisible() = 0; - - //! Sets the new position of the cursor. - /** \param pos: New position of the cursor. The position must be between - (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is - the top left corner and (1.0f, 1.0f) is the bottom right corner of the - render window. */ - virtual void setPosition(const core::position2d &pos) = 0; - - //! Sets the new position of the cursor. - /** \param pos: New position of the cursor. The position must be between - (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is - the top left corner and (1.0f, 1.0f) is the bottom right corner of the - render window. */ - virtual void setPosition(f32 x, f32 y) = 0; - - //! Sets the new position of the cursor. - /** \param pos: New position of the cursor. The coordinates are pixel units. */ - virtual void setPosition(const core::position2d &pos) = 0; - - //! Sets the new position of the cursor. - /** \param pos: New position of the cursor. The coordinates are pixel units. */ - virtual void setPosition(s32 x, s32 y) = 0; - - //! Returns the current position of the mouse cursor. - /** \return Returns the current position of the cursor. The returned position - is the position of the mouse cursor in pixel units. */ - virtual core::position2d getPosition() = 0; - - //! Returns the current position of the mouse cursor. - /** \return Returns the current position of the cursor. The returned position - is a value between (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is - the top left corner and (1.0f, 1.0f) is the bottom right corner of the - render window. */ - virtual core::position2d getRelativePosition() = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_CURSOR_CONTROL_H_INCLUDED__ +#define __I_CURSOR_CONTROL_H_INCLUDED__ + +#include "position2d.h" +#include "IUnknown.h" +#include "irrTypes.h" + +namespace irr +{ +namespace gui +{ + + //! Interface to manipulate the mouse cursor. + class ICursorControl : public virtual IUnknown + { + public: + + //! Changes the visible state of the mouse cursor. + /** \param visible: The new visible state. If true, the cursor will be visible, + if false, it will be invisible. */ + virtual void setVisible(bool visible) = 0; + + //! Returns if the cursor is currently visible. + /** \return Returns true if the cursor is visible, false if not. */ + virtual bool isVisible() = 0; + + //! Sets the new position of the cursor. + /** \param pos: New position of the cursor. The position must be between + (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is + the top left corner and (1.0f, 1.0f) is the bottom right corner of the + render window. */ + virtual void setPosition(const core::position2d &pos) = 0; + + //! Sets the new position of the cursor. + /** \param pos: New position of the cursor. The position must be between + (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is + the top left corner and (1.0f, 1.0f) is the bottom right corner of the + render window. */ + virtual void setPosition(f32 x, f32 y) = 0; + + //! Sets the new position of the cursor. + /** \param pos: New position of the cursor. The coordinates are pixel units. */ + virtual void setPosition(const core::position2d &pos) = 0; + + //! Sets the new position of the cursor. + /** \param pos: New position of the cursor. The coordinates are pixel units. */ + virtual void setPosition(s32 x, s32 y) = 0; + + //! Returns the current position of the mouse cursor. + /** \return Returns the current position of the cursor. The returned position + is the position of the mouse cursor in pixel units. */ + virtual core::position2d getPosition() = 0; + + //! Returns the current position of the mouse cursor. + /** \return Returns the current position of the cursor. The returned position + is a value between (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is + the top left corner and (1.0f, 1.0f) is the bottom right corner of the + render window. */ + virtual core::position2d getRelativePosition() = 0; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IDummyTransformationSceneNode.h b/src/dep/include/irrlicht/IDummyTransformationSceneNode.h index 3a140c5..38898ae 100644 --- a/src/dep/include/irrlicht/IDummyTransformationSceneNode.h +++ b/src/dep/include/irrlicht/IDummyTransformationSceneNode.h @@ -1,42 +1,42 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_DUMMY_TRANSFORMATION_SCENE_NODE_H_INCLUDED__ -#define __I_DUMMY_TRANSFORMATION_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! Dummy scene node for adding additional transformations to the scene graph. -/** This scene node does not render itself, and does not respond to set/getPosition, -set/getRotation and set/getScale. Its just a simple scene node that takes a -matrix as relative transformation, making it possible to insert any transformation -anywhere into the scene graph. -This scene node is for example used by the IAnimatedMeshSceneNode for emulating -joint scene nodes when playing skeletal animations. -*/ -class IDummyTransformationSceneNode : public ISceneNode -{ -public: - - //! constructor - IDummyTransformationSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id) - : ISceneNode(parent, mgr, id) {} - - //! Returns a reference to the current relative transformation matrix. - //! This is the matrix, this scene node uses instead of scale, translation - //! and rotation. - virtual core::matrix4& getRelativeTransformationMatrix() = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_DUMMY_TRANSFORMATION_SCENE_NODE_H_INCLUDED__ +#define __I_DUMMY_TRANSFORMATION_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + +//! Dummy scene node for adding additional transformations to the scene graph. +/** This scene node does not render itself, and does not respond to set/getPosition, +set/getRotation and set/getScale. Its just a simple scene node that takes a +matrix as relative transformation, making it possible to insert any transformation +anywhere into the scene graph. +This scene node is for example used by the IAnimatedMeshSceneNode for emulating +joint scene nodes when playing skeletal animations. +*/ +class IDummyTransformationSceneNode : public ISceneNode +{ +public: + + //! constructor + IDummyTransformationSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id) + : ISceneNode(parent, mgr, id) {} + + //! Returns a reference to the current relative transformation matrix. + //! This is the matrix, this scene node uses instead of scale, translation + //! and rotation. + virtual core::matrix4& getRelativeTransformationMatrix() = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/IEventReceiver.h b/src/dep/include/irrlicht/IEventReceiver.h index 576465a..c439ed6 100644 --- a/src/dep/include/irrlicht/IEventReceiver.h +++ b/src/dep/include/irrlicht/IEventReceiver.h @@ -1,225 +1,225 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_EVENT_RECEIVER_H_INCLUDED__ -#define __I_EVENT_RECEIVER_H_INCLUDED__ - -#include "ILogger.h" -#include "position2d.h" -#include "Keycodes.h" - -namespace irr -{ - //! Enumeration for all event types there are. - enum EEVENT_TYPE - { - //! An event of the graphical user interface. - EET_GUI_EVENT = 0, - - //! A mouse input event. - EET_MOUSE_INPUT_EVENT, - - //! A key input evant. - EET_KEY_INPUT_EVENT, - - //! A log event - EET_LOG_TEXT_EVENT, - - //! A user event with user data. This is not used by Irrlicht and can be used - //! to send user specific data though the system. - EET_USER_EVENT - }; - - //! Enumeration for all mouse input events - enum EMOUSE_INPUT_EVENT - { - //! Left mouse button was pressed down. - EMIE_LMOUSE_PRESSED_DOWN = 0, - - //! Right mouse button was pressed down. - EMIE_RMOUSE_PRESSED_DOWN, - - //! Middle mouse button was pressed down. - EMIE_MMOUSE_PRESSED_DOWN, - - //! Left mouse button was left up. - EMIE_LMOUSE_LEFT_UP, - - //! Right mouse button was left up. - EMIE_RMOUSE_LEFT_UP, - - //! Middle mouse button was left up. - EMIE_MMOUSE_LEFT_UP, - - //! The mouse cursor changed its position. - EMIE_MOUSE_MOVED, - - //! The mouse wheel was moved. Use Wheel value in event data to find out - //! in what direction and how fast. - EMIE_MOUSE_WHEEL, - - //! No real event. Just for convenience to get number of events - EMIE_COUNT - }; - - namespace gui - { - - class IGUIElement; - - //! Enumeration for all events which are sendable by the gui system - enum EGUI_EVENT_TYPE - { - //! A gui element has lost its focus. - EGET_ELEMENT_FOCUS_LOST = 0, - - //! A gui element has got the focus. - EGET_ELEMENT_FOCUSED, - - //! A gui element was hovered. - EGET_ELEMENT_HOVERED, - - //! A hovered gui element was left - EGET_ELEMENT_LEFT, - - //! A button was clicked. - EGET_BUTTON_CLICKED, - - //! A scrollbar has changed its position. - EGET_SCROLL_BAR_CHANGED, - - //! A checkbox has changed its check state. - EGET_CHECKBOX_CHANGED, - - //! A new item in a listbox was seleted. - EGET_LISTBOX_CHANGED, - - //! An item in the listbox was selected, which was already selected. - EGET_LISTBOX_SELECTED_AGAIN, - - //! A file has been selected in the file dialog - EGET_FILE_SELECTED, - - //! A file open dialog has been closed without choosing a file - EGET_FILE_CHOOSE_DIALOG_CANCELLED, - - //! 'Yes' was clicked on a messagebox - EGET_MESSAGEBOX_YES, - - //! 'No' was clicked on a messagebox - EGET_MESSAGEBOX_NO, - - //! 'OK' was clicked on a messagebox - EGET_MESSAGEBOX_OK, - - //! 'Cancel' was clicked on a messagebox - EGET_MESSAGEBOX_CANCEL, - - //! In an editbox was pressed 'ENTER' - EGET_EDITBOX_ENTER, - - //! The tab was changed in an tab control - EGET_TAB_CHANGED, - - //! A menu item was selected in a (context) menu - EGET_MENU_ITEM_SELECTED, - - //! The selection in a combo box has been changed - EGET_COMBO_BOX_CHANGED - }; - } // end namespace gui - - -//! Struct for holding event data. An event can be a gui, mouse or keyboard event. -struct SEvent -{ - EEVENT_TYPE EventType; - - union - { - struct - { - //! IGUIElement who called the event - gui::IGUIElement* Caller; - - //! Type of GUI Event - gui::EGUI_EVENT_TYPE EventType; - - } GUIEvent; - - struct - { - //! X position of mouse cursor - s32 X; - - //! Y position of mouse cursor - s32 Y; - - //! mouse wheel delta, usually 1.0 or -1.0. - /** Only valid if event was EMIE_MOUSE_WHEEL */ - f32 Wheel; - - //! type of mouse event - EMOUSE_INPUT_EVENT Event; - } MouseInput; - - struct - { - //! Character corresponding to the key (0, if not a character) - wchar_t Char; - - //! Key which has been pressed or released - EKEY_CODE Key; - - //! if not pressed, then the key was left up - bool PressedDown; - - //! true if shift was also pressed - bool Shift; - - //! true if ctrl was also pressed - bool Control; - } KeyInput; - - struct - { - //! pointer to text which has been logged - const c8* Text; - - //! log level in which the text has been logged - ELOG_LEVEL Level; - } LogEvent; - - struct - { - //! Some user specified data as int - s32 UserData1; - - //! Another user specified data as int - s32 UserData2; - - //! Some user specified data as float - f32 UserData3; - } UserEvent; - - }; - -}; - -//! Interface of an object wich can receive events. -class IEventReceiver -{ -public: - - virtual ~IEventReceiver() {}; - - //! called if an event happened. returns true if event was processed - virtual bool OnEvent(SEvent event) = 0; -}; - - -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_EVENT_RECEIVER_H_INCLUDED__ +#define __I_EVENT_RECEIVER_H_INCLUDED__ + +#include "ILogger.h" +#include "position2d.h" +#include "Keycodes.h" + +namespace irr +{ + //! Enumeration for all event types there are. + enum EEVENT_TYPE + { + //! An event of the graphical user interface. + EET_GUI_EVENT = 0, + + //! A mouse input event. + EET_MOUSE_INPUT_EVENT, + + //! A key input evant. + EET_KEY_INPUT_EVENT, + + //! A log event + EET_LOG_TEXT_EVENT, + + //! A user event with user data. This is not used by Irrlicht and can be used + //! to send user specific data though the system. + EET_USER_EVENT + }; + + //! Enumeration for all mouse input events + enum EMOUSE_INPUT_EVENT + { + //! Left mouse button was pressed down. + EMIE_LMOUSE_PRESSED_DOWN = 0, + + //! Right mouse button was pressed down. + EMIE_RMOUSE_PRESSED_DOWN, + + //! Middle mouse button was pressed down. + EMIE_MMOUSE_PRESSED_DOWN, + + //! Left mouse button was left up. + EMIE_LMOUSE_LEFT_UP, + + //! Right mouse button was left up. + EMIE_RMOUSE_LEFT_UP, + + //! Middle mouse button was left up. + EMIE_MMOUSE_LEFT_UP, + + //! The mouse cursor changed its position. + EMIE_MOUSE_MOVED, + + //! The mouse wheel was moved. Use Wheel value in event data to find out + //! in what direction and how fast. + EMIE_MOUSE_WHEEL, + + //! No real event. Just for convenience to get number of events + EMIE_COUNT + }; + + namespace gui + { + + class IGUIElement; + + //! Enumeration for all events which are sendable by the gui system + enum EGUI_EVENT_TYPE + { + //! A gui element has lost its focus. + EGET_ELEMENT_FOCUS_LOST = 0, + + //! A gui element has got the focus. + EGET_ELEMENT_FOCUSED, + + //! A gui element was hovered. + EGET_ELEMENT_HOVERED, + + //! A hovered gui element was left + EGET_ELEMENT_LEFT, + + //! A button was clicked. + EGET_BUTTON_CLICKED, + + //! A scrollbar has changed its position. + EGET_SCROLL_BAR_CHANGED, + + //! A checkbox has changed its check state. + EGET_CHECKBOX_CHANGED, + + //! A new item in a listbox was seleted. + EGET_LISTBOX_CHANGED, + + //! An item in the listbox was selected, which was already selected. + EGET_LISTBOX_SELECTED_AGAIN, + + //! A file has been selected in the file dialog + EGET_FILE_SELECTED, + + //! A file open dialog has been closed without choosing a file + EGET_FILE_CHOOSE_DIALOG_CANCELLED, + + //! 'Yes' was clicked on a messagebox + EGET_MESSAGEBOX_YES, + + //! 'No' was clicked on a messagebox + EGET_MESSAGEBOX_NO, + + //! 'OK' was clicked on a messagebox + EGET_MESSAGEBOX_OK, + + //! 'Cancel' was clicked on a messagebox + EGET_MESSAGEBOX_CANCEL, + + //! In an editbox was pressed 'ENTER' + EGET_EDITBOX_ENTER, + + //! The tab was changed in an tab control + EGET_TAB_CHANGED, + + //! A menu item was selected in a (context) menu + EGET_MENU_ITEM_SELECTED, + + //! The selection in a combo box has been changed + EGET_COMBO_BOX_CHANGED + }; + } // end namespace gui + + +//! Struct for holding event data. An event can be a gui, mouse or keyboard event. +struct SEvent +{ + EEVENT_TYPE EventType; + + union + { + struct + { + //! IGUIElement who called the event + gui::IGUIElement* Caller; + + //! Type of GUI Event + gui::EGUI_EVENT_TYPE EventType; + + } GUIEvent; + + struct + { + //! X position of mouse cursor + s32 X; + + //! Y position of mouse cursor + s32 Y; + + //! mouse wheel delta, usually 1.0 or -1.0. + /** Only valid if event was EMIE_MOUSE_WHEEL */ + f32 Wheel; + + //! type of mouse event + EMOUSE_INPUT_EVENT Event; + } MouseInput; + + struct + { + //! Character corresponding to the key (0, if not a character) + wchar_t Char; + + //! Key which has been pressed or released + EKEY_CODE Key; + + //! if not pressed, then the key was left up + bool PressedDown; + + //! true if shift was also pressed + bool Shift; + + //! true if ctrl was also pressed + bool Control; + } KeyInput; + + struct + { + //! pointer to text which has been logged + const c8* Text; + + //! log level in which the text has been logged + ELOG_LEVEL Level; + } LogEvent; + + struct + { + //! Some user specified data as int + s32 UserData1; + + //! Another user specified data as int + s32 UserData2; + + //! Some user specified data as float + f32 UserData3; + } UserEvent; + + }; + +}; + +//! Interface of an object wich can receive events. +class IEventReceiver +{ +public: + + virtual ~IEventReceiver() {}; + + //! called if an event happened. returns true if event was processed + virtual bool OnEvent(SEvent event) = 0; +}; + + +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IFileList.h b/src/dep/include/irrlicht/IFileList.h index e8a5487..f162c23 100644 --- a/src/dep/include/irrlicht/IFileList.h +++ b/src/dep/include/irrlicht/IFileList.h @@ -1,58 +1,58 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_FILE_LIST_H_INCLUDED__ -#define __I_FILE_LIST_H_INCLUDED__ - -#include "IUnknown.h" - -namespace irr -{ -namespace io -{ - -//! The Filelist lists all files in a directory. -class IFileList : public virtual IUnknown -{ -public: - - //! destructor - virtual ~IFileList() {}; - - //! Returns the amount of files in the filelist. - //! \return - //! Returns the amount of files and directories in the file list. - virtual s32 getFileCount() = 0; - - //! Gets the name of a file in the list, based on an index. - //! The path is not included in this name. Use getFullFileName for this. - //! \param index is the zero based index of the file which name should - //! be returned. The index has to be smaller than the amount getFileCount() returns. - //! \return - //! Returns the file name of the file. Returns 0, if an error occured. - virtual const c8* getFileName(s32 index) = 0; - - //! Gets the full name of a file in the list, path included, based on an index. - //! \param index is the zero based index of the file which name should - //! be returned. The index has to be smaller than the amount getFileCount() returns. - //! \return - //! Returns the file name of the file. Returns 0, if an error occured. - virtual const c8* getFullFileName(s32 index) = 0; - - //! Returns of the file is a directory - //! \param - //! index is the zero based index of the file which name should - //! be returned. The index has to be smaller than the amount getFileCount() returns. - //! \return - //! Returns true, if the file is a directory, and false, if it is not. - //! If an error occurs, the result is undefined. - virtual bool isDirectory(s32 index) = 0; -}; - -} // end namespace irr -} // end namespace io - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_FILE_LIST_H_INCLUDED__ +#define __I_FILE_LIST_H_INCLUDED__ + +#include "IUnknown.h" + +namespace irr +{ +namespace io +{ + +//! The Filelist lists all files in a directory. +class IFileList : public virtual IUnknown +{ +public: + + //! destructor + virtual ~IFileList() {}; + + //! Returns the amount of files in the filelist. + //! \return + //! Returns the amount of files and directories in the file list. + virtual s32 getFileCount() = 0; + + //! Gets the name of a file in the list, based on an index. + //! The path is not included in this name. Use getFullFileName for this. + //! \param index is the zero based index of the file which name should + //! be returned. The index has to be smaller than the amount getFileCount() returns. + //! \return + //! Returns the file name of the file. Returns 0, if an error occured. + virtual const c8* getFileName(s32 index) = 0; + + //! Gets the full name of a file in the list, path included, based on an index. + //! \param index is the zero based index of the file which name should + //! be returned. The index has to be smaller than the amount getFileCount() returns. + //! \return + //! Returns the file name of the file. Returns 0, if an error occured. + virtual const c8* getFullFileName(s32 index) = 0; + + //! Returns of the file is a directory + //! \param + //! index is the zero based index of the file which name should + //! be returned. The index has to be smaller than the amount getFileCount() returns. + //! \return + //! Returns true, if the file is a directory, and false, if it is not. + //! If an error occurs, the result is undefined. + virtual bool isDirectory(s32 index) = 0; +}; + +} // end namespace irr +} // end namespace io + + +#endif + diff --git a/src/dep/include/irrlicht/IFileSystem.h b/src/dep/include/irrlicht/IFileSystem.h index 9973641..5c08e3a 100644 --- a/src/dep/include/irrlicht/IFileSystem.h +++ b/src/dep/include/irrlicht/IFileSystem.h @@ -1,193 +1,193 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_FILE_SYSTEM_H_INCLUDED__ -#define __I_FILE_SYSTEM_H_INCLUDED__ - -#include "IUnknown.h" -#include "IXMLReader.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - class IVideoDriver; -} // end namespace video -namespace io -{ - -class IReadFile; -class IWriteFile; -class IFileList; -class IXMLWriter; -class IAttributes; - -//! The FileSystem manages files and archives and provides access to them. -/** - It manages where files are, so that modules which - use the the IO do not need to know where every file is located. A file - could be in a .zip-Archive or as file on disk, using the IFileSystem - makes no difference to this. -*/ -class IFileSystem : public virtual IUnknown -{ -public: - - //! destructor - virtual ~IFileSystem() {}; - - //! Opens a file for read access. - /** \param filename: Name of file to open. - \return Returns a pointer to the created file interface. - The returned pointer should be dropped when no longer needed. - See IUnknown::drop() for more information. */ - virtual IReadFile* createAndOpenFile(const c8* filename) = 0; - - //! Creates an IReadFile interface for accessing memory like a file. - /** This allows you to use a pointer to memory where an IReadFile is requested. - \param memory: A pointer to the start of the file in memory - \param len: The length of the memory in bytes - \param fileName: The name given to this file - \param deleteMemoryWhenDropped: True if the memory should be deleted - along with the IReadFile when it is dropped. - \return Returns a pointer to the created file interface. - The returned pointer should be dropped when no longer needed. - See IUnknown::drop() for more information. - */ - virtual IReadFile* createMemoryReadFile(void* memory, s32 len, const c8* fileName, bool deleteMemoryWhenDropped=false) = 0; - - //! Opens a file for write access. - /** \param filename: Name of file to open. - \param append: If the file already exist, all write operations are - appended to the file. - \return Returns a pointer to the created file interface. 0 is returned, if the - file could not created or opened for writing. - The returned pointer should be dropped when no longer needed. - See IUnknown::drop() for more information. */ - virtual IWriteFile* createAndWriteFile(const c8* filename, bool append=false) = 0; - - //! Adds an zip archive to the file system. - /** After calling this, the Irrlicht Engine will search and open files directly from this archive too. - This is useful for hiding data from the end user, speeding up file access and making it possible to - access for example Quake3 .pk3 files, which are nothing different than .zip files. - \param filename: Filename of the zip archive to add to the file system. - \param ignoreCase: If set to true, files in the archive can be accessed without - writing all letters in the right case. - \param ignorePaths: If set to true, files in the added archive can be accessed - without its complete path. - \return Returns true if the archive was added successful, false if not. */ - virtual bool addZipFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true) = 0; - - //! Adds an unzipped archive ( or basedirectory with subdirectories..) to the file system. - /** Useful for handling data which will be in a zip file - \param filename: Filename of the unzipped zip archive base directory to add to the file system. - \param ignoreCase: If set to true, files in the archive can be accessed without - writing all letters in the right case. - \param ignorePaths: If set to true, files in the added archive can be accessed - without its complete path. - \return Returns true if the archive was added successful, false if not. */ - virtual bool addFolderFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true) = 0; - - //! Adds an pak archive to the file system. - /** After calling this, the Irrlicht Engine will search and open files directly from this archive too. - This is useful for hiding data from the end user, speeding up file access and making it possible to - access for example Quake2/KingPin/Hexen2 .pak files - \param filename: Filename of the pak archive to add to the file system. - \param ignoreCase: If set to true, files in the archive can be accessed without - writing all letters in the right case. - \param ignorePaths: If set to true, files in the added archive can be accessed - without its complete path.(should not use with Quake2 paks - \return Returns true if the archive was added successful, false if not. */ - virtual bool addPakFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true) = 0; - - //! Returns the string of the current working directory. - virtual const c8* getWorkingDirectory() = 0; - - //! Changes the current Working Directory to the overgiven string. - /** \param ewDirectory is a string specifiing the new working directory. - The string is operating system dependent. Under Windows it has - the form ":\\\<..>". An example would be: "C:\Windows\" - \return Returns true if successful, otherwise false. */ - virtual bool changeWorkingDirectoryTo(const c8* newDirectory) = 0; - - //! Converts a relative path to an absolute (unique) path, resolving symbolic links if required - virtual irr::core::stringc getAbsolutePath(irr::core::stringc &filename) = 0; - - //! Creates a list of files and directories in the current working directory and returns it. - /** \return a Pointer to the created IFileList is returned. After the list has been used - it has to be deleted using its IFileList::drop() method. - See IUnknown::drop() for more information. */ - virtual IFileList* createFileList() = 0; - - //! Determinates if a file exists and would be able to be opened. - /** \param filename is the string identifying the file which should be tested for existance. - \return Returns true if file exsits, and false if it does not exist or an error occured. */ - virtual bool existFile(const c8* filename) = 0; - - //! Creates a XML Reader from a file which returns all parsed strings as wide characters (wchar_t*). - /** Use createXMLReaderUTF8() if you prefer char* instead of wchar_t*. See IIrrXMLReader for - more information on how to use the parser. - \return 0, if file could not be opened, otherwise a pointer to the created - IXMLReader is returned. After use, the reader - has to be deleted using its IXMLReader::drop() method. - See IUnknown::drop() for more information. */ - virtual IXMLReader* createXMLReader(const c8* filename) = 0; - - //! Creates a XML Reader from a file which returns all parsed strings as wide characters (wchar_t*). - /** Use createXMLReaderUTF8() if you prefer char* instead of wchar_t*. See IIrrXMLReader for - more information on how to use the parser. - \return 0, if file could not be opened, otherwise a pointer to the created - IXMLReader is returned. After use, the reader - has to be deleted using its IXMLReader::drop() method. - See IUnknown::drop() for more information. */ - virtual IXMLReader* createXMLReader(IReadFile* file) = 0; - - //! Creates a XML Reader from a file which returns all parsed strings as ASCII/UTF-8 characters (char*). - /** Use createXMLReader() if you prefer wchar_t* instead of char*. See IIrrXMLReader for - more information on how to use the parser. - \return 0, if file could not be opened, otherwise a pointer to the created - IXMLReader is returned. After use, the reader - has to be deleted using its IXMLReaderUTF8::drop() method. - See IUnknown::drop() for more information. */ - virtual IXMLReaderUTF8* createXMLReaderUTF8(const c8* filename) = 0; - - //! Creates a XML Reader from a file which returns all parsed strings as ASCII/UTF-8 characters (char*). - /** Use createXMLReader() if you prefer wchar_t* instead of char*. See IIrrXMLReader for - more information on how to use the parser. - \return 0, if file could not be opened, otherwise a pointer to the created - IXMLReader is returned. After use, the reader - has to be deleted using its IXMLReaderUTF8::drop() method. - See IUnknown::drop() for more information. */ - virtual IXMLReaderUTF8* createXMLReaderUTF8(IReadFile* file) = 0; - - //! Creates a XML Writer from a file. - /** \return 0, if file could not be opened, otherwise a pointer to the created - IXMLWriter is returned. After use, the reader - has to be deleted using its IXMLWriter::drop() method. - See IUnknown::drop() for more information. */ - virtual IXMLWriter* createXMLWriter(const c8* filename) = 0; - - //! Creates a XML Writer from a file. - /** \return 0, if file could not be opened, otherwise a pointer to the created - IXMLWriter is returned. After use, the reader - has to be deleted using its IXMLWriter::drop() method. - See IUnknown::drop() for more information. */ - virtual IXMLWriter* createXMLWriter(IWriteFile* file) = 0; - - //! Creates a new empty collection of attributes, usable for serialization and more. - /** \param: driver: Video driver to be used to load textures when specified as attribute values. - Can be null to prevent automatic texture loading by attributes. - \return Returns a pointer to the created object. - If you no longer need the object, you should call IAttributes::drop(). - See IUnknown::drop() for more information. */ - virtual IAttributes* createEmptyAttributes(video::IVideoDriver* driver=0) = 0; -}; - -} // end namespace io -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_FILE_SYSTEM_H_INCLUDED__ +#define __I_FILE_SYSTEM_H_INCLUDED__ + +#include "IUnknown.h" +#include "IXMLReader.h" +#include "irrString.h" + +namespace irr +{ +namespace video +{ + class IVideoDriver; +} // end namespace video +namespace io +{ + +class IReadFile; +class IWriteFile; +class IFileList; +class IXMLWriter; +class IAttributes; + +//! The FileSystem manages files and archives and provides access to them. +/** + It manages where files are, so that modules which + use the the IO do not need to know where every file is located. A file + could be in a .zip-Archive or as file on disk, using the IFileSystem + makes no difference to this. +*/ +class IFileSystem : public virtual IUnknown +{ +public: + + //! destructor + virtual ~IFileSystem() {}; + + //! Opens a file for read access. + /** \param filename: Name of file to open. + \return Returns a pointer to the created file interface. + The returned pointer should be dropped when no longer needed. + See IUnknown::drop() for more information. */ + virtual IReadFile* createAndOpenFile(const c8* filename) = 0; + + //! Creates an IReadFile interface for accessing memory like a file. + /** This allows you to use a pointer to memory where an IReadFile is requested. + \param memory: A pointer to the start of the file in memory + \param len: The length of the memory in bytes + \param fileName: The name given to this file + \param deleteMemoryWhenDropped: True if the memory should be deleted + along with the IReadFile when it is dropped. + \return Returns a pointer to the created file interface. + The returned pointer should be dropped when no longer needed. + See IUnknown::drop() for more information. + */ + virtual IReadFile* createMemoryReadFile(void* memory, s32 len, const c8* fileName, bool deleteMemoryWhenDropped=false) = 0; + + //! Opens a file for write access. + /** \param filename: Name of file to open. + \param append: If the file already exist, all write operations are + appended to the file. + \return Returns a pointer to the created file interface. 0 is returned, if the + file could not created or opened for writing. + The returned pointer should be dropped when no longer needed. + See IUnknown::drop() for more information. */ + virtual IWriteFile* createAndWriteFile(const c8* filename, bool append=false) = 0; + + //! Adds an zip archive to the file system. + /** After calling this, the Irrlicht Engine will search and open files directly from this archive too. + This is useful for hiding data from the end user, speeding up file access and making it possible to + access for example Quake3 .pk3 files, which are nothing different than .zip files. + \param filename: Filename of the zip archive to add to the file system. + \param ignoreCase: If set to true, files in the archive can be accessed without + writing all letters in the right case. + \param ignorePaths: If set to true, files in the added archive can be accessed + without its complete path. + \return Returns true if the archive was added successful, false if not. */ + virtual bool addZipFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true) = 0; + + //! Adds an unzipped archive ( or basedirectory with subdirectories..) to the file system. + /** Useful for handling data which will be in a zip file + \param filename: Filename of the unzipped zip archive base directory to add to the file system. + \param ignoreCase: If set to true, files in the archive can be accessed without + writing all letters in the right case. + \param ignorePaths: If set to true, files in the added archive can be accessed + without its complete path. + \return Returns true if the archive was added successful, false if not. */ + virtual bool addFolderFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true) = 0; + + //! Adds an pak archive to the file system. + /** After calling this, the Irrlicht Engine will search and open files directly from this archive too. + This is useful for hiding data from the end user, speeding up file access and making it possible to + access for example Quake2/KingPin/Hexen2 .pak files + \param filename: Filename of the pak archive to add to the file system. + \param ignoreCase: If set to true, files in the archive can be accessed without + writing all letters in the right case. + \param ignorePaths: If set to true, files in the added archive can be accessed + without its complete path.(should not use with Quake2 paks + \return Returns true if the archive was added successful, false if not. */ + virtual bool addPakFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true) = 0; + + //! Returns the string of the current working directory. + virtual const c8* getWorkingDirectory() = 0; + + //! Changes the current Working Directory to the overgiven string. + /** \param ewDirectory is a string specifiing the new working directory. + The string is operating system dependent. Under Windows it has + the form ":\\\<..>". An example would be: "C:\Windows\" + \return Returns true if successful, otherwise false. */ + virtual bool changeWorkingDirectoryTo(const c8* newDirectory) = 0; + + //! Converts a relative path to an absolute (unique) path, resolving symbolic links if required + virtual irr::core::stringc getAbsolutePath(irr::core::stringc &filename) = 0; + + //! Creates a list of files and directories in the current working directory and returns it. + /** \return a Pointer to the created IFileList is returned. After the list has been used + it has to be deleted using its IFileList::drop() method. + See IUnknown::drop() for more information. */ + virtual IFileList* createFileList() = 0; + + //! Determinates if a file exists and would be able to be opened. + /** \param filename is the string identifying the file which should be tested for existance. + \return Returns true if file exsits, and false if it does not exist or an error occured. */ + virtual bool existFile(const c8* filename) = 0; + + //! Creates a XML Reader from a file which returns all parsed strings as wide characters (wchar_t*). + /** Use createXMLReaderUTF8() if you prefer char* instead of wchar_t*. See IIrrXMLReader for + more information on how to use the parser. + \return 0, if file could not be opened, otherwise a pointer to the created + IXMLReader is returned. After use, the reader + has to be deleted using its IXMLReader::drop() method. + See IUnknown::drop() for more information. */ + virtual IXMLReader* createXMLReader(const c8* filename) = 0; + + //! Creates a XML Reader from a file which returns all parsed strings as wide characters (wchar_t*). + /** Use createXMLReaderUTF8() if you prefer char* instead of wchar_t*. See IIrrXMLReader for + more information on how to use the parser. + \return 0, if file could not be opened, otherwise a pointer to the created + IXMLReader is returned. After use, the reader + has to be deleted using its IXMLReader::drop() method. + See IUnknown::drop() for more information. */ + virtual IXMLReader* createXMLReader(IReadFile* file) = 0; + + //! Creates a XML Reader from a file which returns all parsed strings as ASCII/UTF-8 characters (char*). + /** Use createXMLReader() if you prefer wchar_t* instead of char*. See IIrrXMLReader for + more information on how to use the parser. + \return 0, if file could not be opened, otherwise a pointer to the created + IXMLReader is returned. After use, the reader + has to be deleted using its IXMLReaderUTF8::drop() method. + See IUnknown::drop() for more information. */ + virtual IXMLReaderUTF8* createXMLReaderUTF8(const c8* filename) = 0; + + //! Creates a XML Reader from a file which returns all parsed strings as ASCII/UTF-8 characters (char*). + /** Use createXMLReader() if you prefer wchar_t* instead of char*. See IIrrXMLReader for + more information on how to use the parser. + \return 0, if file could not be opened, otherwise a pointer to the created + IXMLReader is returned. After use, the reader + has to be deleted using its IXMLReaderUTF8::drop() method. + See IUnknown::drop() for more information. */ + virtual IXMLReaderUTF8* createXMLReaderUTF8(IReadFile* file) = 0; + + //! Creates a XML Writer from a file. + /** \return 0, if file could not be opened, otherwise a pointer to the created + IXMLWriter is returned. After use, the reader + has to be deleted using its IXMLWriter::drop() method. + See IUnknown::drop() for more information. */ + virtual IXMLWriter* createXMLWriter(const c8* filename) = 0; + + //! Creates a XML Writer from a file. + /** \return 0, if file could not be opened, otherwise a pointer to the created + IXMLWriter is returned. After use, the reader + has to be deleted using its IXMLWriter::drop() method. + See IUnknown::drop() for more information. */ + virtual IXMLWriter* createXMLWriter(IWriteFile* file) = 0; + + //! Creates a new empty collection of attributes, usable for serialization and more. + /** \param: driver: Video driver to be used to load textures when specified as attribute values. + Can be null to prevent automatic texture loading by attributes. + \return Returns a pointer to the created object. + If you no longer need the object, you should call IAttributes::drop(). + See IUnknown::drop() for more information. */ + virtual IAttributes* createEmptyAttributes(video::IVideoDriver* driver=0) = 0; +}; + +} // end namespace io +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/IGPUProgrammingServices.h b/src/dep/include/irrlicht/IGPUProgrammingServices.h index 243ee7b..9e41905 100644 --- a/src/dep/include/irrlicht/IGPUProgrammingServices.h +++ b/src/dep/include/irrlicht/IGPUProgrammingServices.h @@ -1,219 +1,219 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GPU_PROGRAMMING_SERVICES_H_INCLUDED__ -#define __I_GPU_PROGRAMMING_SERVICES_H_INCLUDED__ - -#include "IUnknown.h" -#include "SMaterial.h" - -namespace irr -{ - -namespace io -{ - class IReadFile; -} // end namespace io - -namespace video -{ - -class IVideoDriver; -class IShaderConstantSetCallBack; - -//! Compile target enumeration for the addHighLevelShaderMaterial() method. -enum E_VERTEX_SHADER_TYPE -{ - EVST_VS_1_1 = 0, - EVST_VS_2_0, - EVST_VS_2_a, - EVST_VS_3_0, - - //! This is not a type, but a value indicating how much types there are. - EVST_COUNT -}; - -//! Names for all vertex shader types, each entry corresponds to a E_VERTEX_SHADER_TYPE entry. -const c8* const VERTEX_SHADER_TYPE_NAMES[] = { - "vs_1_1", - "vs_2_0", - "vs_2_a", - "vs_3_0", - 0 }; - -//! Compile target enumeration for the addHighLevelShaderMaterial() method. -enum E_PIXEL_SHADER_TYPE -{ - EPST_PS_1_1 = 0, - EPST_PS_1_2, - EPST_PS_1_3, - EPST_PS_1_4, - EPST_PS_2_0, - EPST_PS_2_a, - EPST_PS_2_b, - EPST_PS_3_0, - - //! This is not a type, but a value indicating how much types there are. - EPST_COUNT -}; - -//! Names for all pixel shader types, each entry corresponds to a E_PIXEL_SHADER_TYPE entry. -const c8* const PIXEL_SHADER_TYPE_NAMES[] = { - "ps_1_1", - "ps_1_2", - "ps_1_3", - "ps_1_4", - "ps_2_0", - "ps_2_a", - "ps_2_b", - "ps_3_0", - 0 }; - -//! Interface making it possible to create and use programs running on the GPU. -class IGPUProgrammingServices -{ -public: - - //! destructor - virtual ~IGPUProgrammingServices() {} - - //! Adds a new material renderer to the VideoDriver, based on a high level shading - //! language. Currently only HLSL/D3D9 and GLSL/OpenGL is supported. - //! \param vertexShaderProgram: String containing the source of the vertex shader program. - //! This can be 0 if no vertex program should be used. - //! \param Entry name of the function of the vertexShaderProgram - //! \param vsCompileTarget: Vertex shader version where the high level shader should be compiled to. - //! \param pixelShaderProgram: String containing the source of the pixel shader program. - //! This can be 0 if no pixel shader should be used. - //! \param pixelShaderEntryPointName: Entry name of the function of the pixelShaderEntryPointName - //! \param psCompileTarget: Pixel shader version where the high level shader should be compiled to. - //! \param callback: Pointer to an implementation of IShaderConstantSetCallBack in which you - //! can set the needed vertex and pixel shader program constants. Set this to 0 if you don't need this. - //! \param baseMaterial: Base material which renderstates will be used to shade the - //! material. - //! \param userData: a user data int. This int can be set to any value and will be set as parameter - //! in the callback method when calling OnSetConstants(). In this way it is easily possible to - //! use the same callback method for multiple materials and distinguish between them during the call. - //! \return Returns the number of the - //! material type which can be set in SMaterial::MaterialType to use the renderer. - //! -1 is returned if an error occured. -1 is returned for example if a vertex or pixel shader - //! program could not be compiled or a compile target is not reachable. - //! The error strings are then printed out into the error log, and - //! can be catched with a custom event receiver. - virtual s32 addHighLevelShaderMaterial( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName = "main", - E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, - const c8* pixelShaderProgram = 0, - const c8* pixelShaderEntryPointName = "main", - E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData = 0 ) = 0; - - //! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), - //! but tries to load the programs from files. - //! \param vertexShaderProgram: Text file containing the source of the vertex shader program. - //! Set to null if no shader should be created. - //! \param pixelShaderProgram: Text file containing the source of the pixel shader program. Set to - //! 0 if no shader should be created. - virtual s32 addHighLevelShaderMaterialFromFiles( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName = "main", - E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, - const c8* pixelShaderProgram = 0, - const c8* pixelShaderEntryPointName = "main", - E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData = 0) = 0; - - - //! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), - //! but tries to load the programs from files. - //! \param vertexShaderProgram: Text file containing the source of the vertex shader program. - //! Set to null if no shader should be created. - //! \param pixelShaderProgram: Text file containing the source of the pixel shader program. Set to - //! 0 if no shader should be created. - virtual s32 addHighLevelShaderMaterialFromFiles( - io::IReadFile* vertexShaderProgram, - const c8* vertexShaderEntryPointName = "main", - E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, - io::IReadFile* pixelShaderProgram = 0, - const c8* pixelShaderEntryPointName = "main", - E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData = 0) = 0; - - //! Adds a new material renderer to the VideoDriver, using pixel and/or - //! vertex shaders to render geometry. - //! Note that it is a good idea to call IVideoDriver::queryFeature() before to check - //! if the IVideoDriver supports the vertex and/or pixel shader version your are using. - //! The material is added to the VideoDriver like with IVideoDriver::addMaterialRenderer() - //! and can be used like it had been added with that method. - //! \param vertexShaderProgram: String containing the source of the vertex shader program. This can be - //! 0 if no vertex program should be used. - //! For DX8 programs, the will always input registers look like this: - //! v0: position, v1: normal, - //! v2: color, v3: texture cooridnates, v4: texture coordinates 2 if available. - //! For DX9 programs, you can manually set the registers using the dcl_ statements. - //! \param pixelShaderProgram: String containing the source of the pixel shader program. - //! This can be 0 if you don't want to use a pixel shader. - //! \param callback: Pointer to an implementation of IShaderConstantSetCallBack in which you - //! can set the needed vertex and pixel shader program constants. Set this to 0 if you don't need this. - //! \param baseMaterial: Base material which renderstates will be used to shade the - //! material. - //! \param userData: a user data int. This int can be set to any value and will be set as parameter - //! in the callback method when calling OnSetConstants(). In this way it is easily possible to - //! use the same callback method for multiple materials and distinguish between them during the call. - //! \return Returns the number of the - //! material type which can be set in SMaterial::MaterialType to use the renderer. - //! -1 is returned if an error occured. -1 is returned for example if a vertex or pixel shader - //! program could not be compiled, the error strings are then printed out into the error log, and - //! can be catched with a custom event receiver. - virtual s32 addShaderMaterial(const c8* vertexShaderProgram = 0, - const c8* pixelShaderProgram = 0, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData = 0) = 0; - - //! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the - //! programs from files. - //! \param vertexShaderProgram: Text file containing the source of the vertex shader program. - //! Set to null if no shader should be created. - //! \param pixelShaderProgram: Text file containing the source of the pixel shader program. Set to - //! 0 if no shader should be created. - //! \param callback: Pointer to an IShaderConstantSetCallback object to which the - //! OnSetConstants function is called. - //! \param baseMaterial: baseMaterial - virtual s32 addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram, - io::IReadFile* pixelShaderProgram, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData = 0) = 0; - - //! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the - //! programs from files. - //! \param vertexShaderProgramFileName: Text file name containing the source of the - //! vertex shader program. - //! Set to null if no shader should be created. - //! \param pixelShaderProgramFileName: Text file name containing the source of the - //! pixel shader program. Set to 0 if no shader should be created. - //! \param callback: Pointer to an IShaderConstantSetCallback object to which the - //! OnSetConstants function is called. - //! \param baseMaterial: baseMaterial - virtual s32 addShaderMaterialFromFiles(const c8* vertexShaderProgramFileName, - const c8* pixelShaderProgramFileName, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData = 0) = 0; -}; - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GPU_PROGRAMMING_SERVICES_H_INCLUDED__ +#define __I_GPU_PROGRAMMING_SERVICES_H_INCLUDED__ + +#include "IUnknown.h" +#include "SMaterial.h" + +namespace irr +{ + +namespace io +{ + class IReadFile; +} // end namespace io + +namespace video +{ + +class IVideoDriver; +class IShaderConstantSetCallBack; + +//! Compile target enumeration for the addHighLevelShaderMaterial() method. +enum E_VERTEX_SHADER_TYPE +{ + EVST_VS_1_1 = 0, + EVST_VS_2_0, + EVST_VS_2_a, + EVST_VS_3_0, + + //! This is not a type, but a value indicating how much types there are. + EVST_COUNT +}; + +//! Names for all vertex shader types, each entry corresponds to a E_VERTEX_SHADER_TYPE entry. +const c8* const VERTEX_SHADER_TYPE_NAMES[] = { + "vs_1_1", + "vs_2_0", + "vs_2_a", + "vs_3_0", + 0 }; + +//! Compile target enumeration for the addHighLevelShaderMaterial() method. +enum E_PIXEL_SHADER_TYPE +{ + EPST_PS_1_1 = 0, + EPST_PS_1_2, + EPST_PS_1_3, + EPST_PS_1_4, + EPST_PS_2_0, + EPST_PS_2_a, + EPST_PS_2_b, + EPST_PS_3_0, + + //! This is not a type, but a value indicating how much types there are. + EPST_COUNT +}; + +//! Names for all pixel shader types, each entry corresponds to a E_PIXEL_SHADER_TYPE entry. +const c8* const PIXEL_SHADER_TYPE_NAMES[] = { + "ps_1_1", + "ps_1_2", + "ps_1_3", + "ps_1_4", + "ps_2_0", + "ps_2_a", + "ps_2_b", + "ps_3_0", + 0 }; + +//! Interface making it possible to create and use programs running on the GPU. +class IGPUProgrammingServices +{ +public: + + //! destructor + virtual ~IGPUProgrammingServices() {} + + //! Adds a new material renderer to the VideoDriver, based on a high level shading + //! language. Currently only HLSL/D3D9 and GLSL/OpenGL is supported. + //! \param vertexShaderProgram: String containing the source of the vertex shader program. + //! This can be 0 if no vertex program should be used. + //! \param Entry name of the function of the vertexShaderProgram + //! \param vsCompileTarget: Vertex shader version where the high level shader should be compiled to. + //! \param pixelShaderProgram: String containing the source of the pixel shader program. + //! This can be 0 if no pixel shader should be used. + //! \param pixelShaderEntryPointName: Entry name of the function of the pixelShaderEntryPointName + //! \param psCompileTarget: Pixel shader version where the high level shader should be compiled to. + //! \param callback: Pointer to an implementation of IShaderConstantSetCallBack in which you + //! can set the needed vertex and pixel shader program constants. Set this to 0 if you don't need this. + //! \param baseMaterial: Base material which renderstates will be used to shade the + //! material. + //! \param userData: a user data int. This int can be set to any value and will be set as parameter + //! in the callback method when calling OnSetConstants(). In this way it is easily possible to + //! use the same callback method for multiple materials and distinguish between them during the call. + //! \return Returns the number of the + //! material type which can be set in SMaterial::MaterialType to use the renderer. + //! -1 is returned if an error occured. -1 is returned for example if a vertex or pixel shader + //! program could not be compiled or a compile target is not reachable. + //! The error strings are then printed out into the error log, and + //! can be catched with a custom event receiver. + virtual s32 addHighLevelShaderMaterial( + const c8* vertexShaderProgram, + const c8* vertexShaderEntryPointName = "main", + E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, + const c8* pixelShaderProgram = 0, + const c8* pixelShaderEntryPointName = "main", + E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, + IShaderConstantSetCallBack* callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0 ) = 0; + + //! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), + //! but tries to load the programs from files. + //! \param vertexShaderProgram: Text file containing the source of the vertex shader program. + //! Set to null if no shader should be created. + //! \param pixelShaderProgram: Text file containing the source of the pixel shader program. Set to + //! 0 if no shader should be created. + virtual s32 addHighLevelShaderMaterialFromFiles( + const c8* vertexShaderProgram, + const c8* vertexShaderEntryPointName = "main", + E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, + const c8* pixelShaderProgram = 0, + const c8* pixelShaderEntryPointName = "main", + E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, + IShaderConstantSetCallBack* callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) = 0; + + + //! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), + //! but tries to load the programs from files. + //! \param vertexShaderProgram: Text file containing the source of the vertex shader program. + //! Set to null if no shader should be created. + //! \param pixelShaderProgram: Text file containing the source of the pixel shader program. Set to + //! 0 if no shader should be created. + virtual s32 addHighLevelShaderMaterialFromFiles( + io::IReadFile* vertexShaderProgram, + const c8* vertexShaderEntryPointName = "main", + E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, + io::IReadFile* pixelShaderProgram = 0, + const c8* pixelShaderEntryPointName = "main", + E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, + IShaderConstantSetCallBack* callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) = 0; + + //! Adds a new material renderer to the VideoDriver, using pixel and/or + //! vertex shaders to render geometry. + //! Note that it is a good idea to call IVideoDriver::queryFeature() before to check + //! if the IVideoDriver supports the vertex and/or pixel shader version your are using. + //! The material is added to the VideoDriver like with IVideoDriver::addMaterialRenderer() + //! and can be used like it had been added with that method. + //! \param vertexShaderProgram: String containing the source of the vertex shader program. This can be + //! 0 if no vertex program should be used. + //! For DX8 programs, the will always input registers look like this: + //! v0: position, v1: normal, + //! v2: color, v3: texture cooridnates, v4: texture coordinates 2 if available. + //! For DX9 programs, you can manually set the registers using the dcl_ statements. + //! \param pixelShaderProgram: String containing the source of the pixel shader program. + //! This can be 0 if you don't want to use a pixel shader. + //! \param callback: Pointer to an implementation of IShaderConstantSetCallBack in which you + //! can set the needed vertex and pixel shader program constants. Set this to 0 if you don't need this. + //! \param baseMaterial: Base material which renderstates will be used to shade the + //! material. + //! \param userData: a user data int. This int can be set to any value and will be set as parameter + //! in the callback method when calling OnSetConstants(). In this way it is easily possible to + //! use the same callback method for multiple materials and distinguish between them during the call. + //! \return Returns the number of the + //! material type which can be set in SMaterial::MaterialType to use the renderer. + //! -1 is returned if an error occured. -1 is returned for example if a vertex or pixel shader + //! program could not be compiled, the error strings are then printed out into the error log, and + //! can be catched with a custom event receiver. + virtual s32 addShaderMaterial(const c8* vertexShaderProgram = 0, + const c8* pixelShaderProgram = 0, + IShaderConstantSetCallBack* callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) = 0; + + //! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the + //! programs from files. + //! \param vertexShaderProgram: Text file containing the source of the vertex shader program. + //! Set to null if no shader should be created. + //! \param pixelShaderProgram: Text file containing the source of the pixel shader program. Set to + //! 0 if no shader should be created. + //! \param callback: Pointer to an IShaderConstantSetCallback object to which the + //! OnSetConstants function is called. + //! \param baseMaterial: baseMaterial + virtual s32 addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram, + io::IReadFile* pixelShaderProgram, + IShaderConstantSetCallBack* callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) = 0; + + //! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the + //! programs from files. + //! \param vertexShaderProgramFileName: Text file name containing the source of the + //! vertex shader program. + //! Set to null if no shader should be created. + //! \param pixelShaderProgramFileName: Text file name containing the source of the + //! pixel shader program. Set to 0 if no shader should be created. + //! \param callback: Pointer to an IShaderConstantSetCallback object to which the + //! OnSetConstants function is called. + //! \param baseMaterial: baseMaterial + virtual s32 addShaderMaterialFromFiles(const c8* vertexShaderProgramFileName, + const c8* pixelShaderProgramFileName, + IShaderConstantSetCallBack* callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) = 0; +}; + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIButton.h b/src/dep/include/irrlicht/IGUIButton.h index abb782d..87188e9 100644 --- a/src/dep/include/irrlicht/IGUIButton.h +++ b/src/dep/include/irrlicht/IGUIButton.h @@ -1,130 +1,130 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_BUTTON_H_INCLUDED__ -#define __I_GUI_BUTTON_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ - -namespace video -{ - class ITexture; -} // end namespace video - -namespace gui -{ - class IGUIFont; - class IGUISpriteBank; - - enum EGUI_BUTTON_STATE - { - //! The button is not pressed - EGBS_BUTTON_UP=0, - //! The button is currently pressed down - EGBS_BUTTON_DOWN, - //! The mouse cursor is over the button - EGBS_BUTTON_MOUSE_OVER, - //! The mouse cursor is not over the button - EGBS_BUTTON_MOUSE_OFF, - //! The button has the focus - EGBS_BUTTON_FOCUSED, - //! The button doesn't have the focus - EGBS_BUTTON_NOT_FOCUSED, - //! not used, counts the number of enumerated items - EGBS_COUNT - }; - - //! Names for gui button state icons - const c8* const GUIButtonStateNames[] = - { - "buttonUp", - "buttonDown", - "buttonMouseOver", - "buttonMouseOff", - "buttonFocused", - "buttonNotFocused", - 0, - 0, - }; - - //! GUI Button interface. - class IGUIButton : public IGUIElement - { - public: - - //! constructor - IGUIButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_BUTTON, environment, parent, id, rectangle) {} - - //! destructor - ~IGUIButton() {}; - - //! Sets another skin independent font. - /** If this is set to zero, the button uses the font of the skin. - \param font: New font to set. */ - virtual void setOverrideFont(IGUIFont* font=0) = 0; - - //! Sets an image which should be displayed on the button when it is in normal state. - /** \param image: Image to be displayed */ - virtual void setImage(video::ITexture* image) = 0; - - //! Sets a background image for the button when it is in normal state. - /** \param image: Texture containing the image to be displayed - \param pos: Position in the texture, where the image is located */ - virtual void setImage(video::ITexture* image, const core::rect& pos) = 0; - - //! Sets a background image for the button when it is in pressed state. - /** If no images is specified for the pressed state via - setPressedImage(), this image is also drawn in pressed state. - \param image: Image to be displayed */ - virtual void setPressedImage(video::ITexture* image) = 0; - - //! Sets an image which should be displayed on the button when it is in pressed state. - /** \param image: Texture containing the image to be displayed - \param pos: Position in the texture, where the image is located */ - virtual void setPressedImage(video::ITexture* image, const core::rect& pos) = 0; - - //! Sets the sprite bank used by the button - virtual void setSpriteBank(IGUISpriteBank* bank) = 0; - - //! Sets the animated sprite for a specific button state - /** \param index: Number of the sprite within the sprite bank, use -1 for no sprite - \param state: State of the button to set the sprite for - \param index: The sprite number from the current sprite bank - \param color: The color of the sprite - \param loop: True if the animation should loop, false if not - */ - virtual void setSprite(EGUI_BUTTON_STATE state, s32 index, - video::SColor color=video::SColor(255,255,255,255), bool loop=false) = 0; - - //! Sets if the button should behave like a push button. - /** Which means it can be in two states: Normal or Pressed. With a click on the button, - the user can change the state of the button. */ - virtual void setIsPushButton(bool isPushButton) = 0; - - //! Sets the pressed state of the button if this is a pushbutton - virtual void setPressed(bool pressed) = 0; - - //! Returns if the button is currently pressed - virtual bool isPressed() = 0; - - //! Sets if the alpha channel should be used for drawing background images on the button (default is false) - virtual void setUseAlphaChannel(bool useAlphaChannel) = 0; - - //! Returns if the alpha channel should be used for drawing background images on the button - virtual bool getUseAlphaChannel() = 0; - - //! Sets if the button should use the skin to draw its border (default is true) - virtual void setDrawBorder(bool border) = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_BUTTON_H_INCLUDED__ +#define __I_GUI_BUTTON_H_INCLUDED__ + +#include "IGUIElement.h" + +namespace irr +{ + +namespace video +{ + class ITexture; +} // end namespace video + +namespace gui +{ + class IGUIFont; + class IGUISpriteBank; + + enum EGUI_BUTTON_STATE + { + //! The button is not pressed + EGBS_BUTTON_UP=0, + //! The button is currently pressed down + EGBS_BUTTON_DOWN, + //! The mouse cursor is over the button + EGBS_BUTTON_MOUSE_OVER, + //! The mouse cursor is not over the button + EGBS_BUTTON_MOUSE_OFF, + //! The button has the focus + EGBS_BUTTON_FOCUSED, + //! The button doesn't have the focus + EGBS_BUTTON_NOT_FOCUSED, + //! not used, counts the number of enumerated items + EGBS_COUNT + }; + + //! Names for gui button state icons + const c8* const GUIButtonStateNames[] = + { + "buttonUp", + "buttonDown", + "buttonMouseOver", + "buttonMouseOff", + "buttonFocused", + "buttonNotFocused", + 0, + 0, + }; + + //! GUI Button interface. + class IGUIButton : public IGUIElement + { + public: + + //! constructor + IGUIButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_BUTTON, environment, parent, id, rectangle) {} + + //! destructor + ~IGUIButton() {}; + + //! Sets another skin independent font. + /** If this is set to zero, the button uses the font of the skin. + \param font: New font to set. */ + virtual void setOverrideFont(IGUIFont* font=0) = 0; + + //! Sets an image which should be displayed on the button when it is in normal state. + /** \param image: Image to be displayed */ + virtual void setImage(video::ITexture* image) = 0; + + //! Sets a background image for the button when it is in normal state. + /** \param image: Texture containing the image to be displayed + \param pos: Position in the texture, where the image is located */ + virtual void setImage(video::ITexture* image, const core::rect& pos) = 0; + + //! Sets a background image for the button when it is in pressed state. + /** If no images is specified for the pressed state via + setPressedImage(), this image is also drawn in pressed state. + \param image: Image to be displayed */ + virtual void setPressedImage(video::ITexture* image) = 0; + + //! Sets an image which should be displayed on the button when it is in pressed state. + /** \param image: Texture containing the image to be displayed + \param pos: Position in the texture, where the image is located */ + virtual void setPressedImage(video::ITexture* image, const core::rect& pos) = 0; + + //! Sets the sprite bank used by the button + virtual void setSpriteBank(IGUISpriteBank* bank) = 0; + + //! Sets the animated sprite for a specific button state + /** \param index: Number of the sprite within the sprite bank, use -1 for no sprite + \param state: State of the button to set the sprite for + \param index: The sprite number from the current sprite bank + \param color: The color of the sprite + \param loop: True if the animation should loop, false if not + */ + virtual void setSprite(EGUI_BUTTON_STATE state, s32 index, + video::SColor color=video::SColor(255,255,255,255), bool loop=false) = 0; + + //! Sets if the button should behave like a push button. + /** Which means it can be in two states: Normal or Pressed. With a click on the button, + the user can change the state of the button. */ + virtual void setIsPushButton(bool isPushButton) = 0; + + //! Sets the pressed state of the button if this is a pushbutton + virtual void setPressed(bool pressed) = 0; + + //! Returns if the button is currently pressed + virtual bool isPressed() = 0; + + //! Sets if the alpha channel should be used for drawing background images on the button (default is false) + virtual void setUseAlphaChannel(bool useAlphaChannel) = 0; + + //! Returns if the alpha channel should be used for drawing background images on the button + virtual bool getUseAlphaChannel() = 0; + + //! Sets if the button should use the skin to draw its border (default is true) + virtual void setDrawBorder(bool border) = 0; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUICheckBox.h b/src/dep/include/irrlicht/IGUICheckBox.h index 1f0a456..abffff8 100644 --- a/src/dep/include/irrlicht/IGUICheckBox.h +++ b/src/dep/include/irrlicht/IGUICheckBox.h @@ -1,38 +1,38 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_CHECKBOX_H_INCLUDED__ -#define __I_GUI_CHECKBOX_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace gui -{ - - //! GUI Check box interface. - class IGUICheckBox : public IGUIElement - { - public: - - //! constructor - IGUICheckBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_CHECK_BOX, environment, parent, id, rectangle) {} - - //! destructor - ~IGUICheckBox() {}; - - //! Set if box is checked. - virtual void setChecked(bool checked) = 0; - - //! Returns true if box is checked. - virtual bool isChecked() = 0; - }; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_CHECKBOX_H_INCLUDED__ +#define __I_GUI_CHECKBOX_H_INCLUDED__ + +#include "IGUIElement.h" + +namespace irr +{ +namespace gui +{ + + //! GUI Check box interface. + class IGUICheckBox : public IGUIElement + { + public: + + //! constructor + IGUICheckBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_CHECK_BOX, environment, parent, id, rectangle) {} + + //! destructor + ~IGUICheckBox() {}; + + //! Set if box is checked. + virtual void setChecked(bool checked) = 0; + + //! Returns true if box is checked. + virtual bool isChecked() = 0; + }; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIColorSelectDialog.h b/src/dep/include/irrlicht/IGUIColorSelectDialog.h index c0b480a..b9f30b6 100644 --- a/src/dep/include/irrlicht/IGUIColorSelectDialog.h +++ b/src/dep/include/irrlicht/IGUIColorSelectDialog.h @@ -1,35 +1,35 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ -#define __I_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace gui -{ - - //! Standard file chooser dialog. - class IGUIColorSelectDialog : public IGUIElement - { - public: - - //! constructor - IGUIColorSelectDialog(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_COLOR_SELECT_DIALOG, environment, parent, id, rectangle) {} - - //! destructor - virtual ~IGUIColorSelectDialog() {}; - - - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ +#define __I_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ + +#include "IGUIElement.h" + +namespace irr +{ +namespace gui +{ + + //! Standard file chooser dialog. + class IGUIColorSelectDialog : public IGUIElement + { + public: + + //! constructor + IGUIColorSelectDialog(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_COLOR_SELECT_DIALOG, environment, parent, id, rectangle) {} + + //! destructor + virtual ~IGUIColorSelectDialog() {}; + + + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIComboBox.h b/src/dep/include/irrlicht/IGUIComboBox.h index 9680e91..eaf2fd2 100644 --- a/src/dep/include/irrlicht/IGUIComboBox.h +++ b/src/dep/include/irrlicht/IGUIComboBox.h @@ -1,51 +1,51 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_COMBO_BOX_H_INCLUDED__ -#define __I_GUI_COMBO_BOX_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace gui -{ - //! Combobox widget - class IGUIComboBox : public IGUIElement - { - public: - - //! constructor - IGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_COMBO_BOX, environment, parent, id, rectangle) {} - - //! destructor - ~IGUIComboBox() {}; - - //! Returns amount of items in box - virtual s32 getItemCount() = 0; - - //! returns string of an item. the idx may be a value from 0 to itemCount-1 - virtual const wchar_t* getItem(s32 idx) = 0; - - //! adds an item and returns the index of it - virtual s32 addItem(const wchar_t* text) = 0; - - //! deletes all items in the combo box - virtual void clear() = 0; - - //! returns id of selected item. returns -1 if no item is selected. - virtual s32 getSelected() = 0; - - //! sets the selected item. Set this to -1 if no item should be selected - virtual void setSelected(s32 id) = 0; - - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_COMBO_BOX_H_INCLUDED__ +#define __I_GUI_COMBO_BOX_H_INCLUDED__ + +#include "IGUIElement.h" + +namespace irr +{ +namespace gui +{ + //! Combobox widget + class IGUIComboBox : public IGUIElement + { + public: + + //! constructor + IGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_COMBO_BOX, environment, parent, id, rectangle) {} + + //! destructor + ~IGUIComboBox() {}; + + //! Returns amount of items in box + virtual s32 getItemCount() = 0; + + //! returns string of an item. the idx may be a value from 0 to itemCount-1 + virtual const wchar_t* getItem(s32 idx) = 0; + + //! adds an item and returns the index of it + virtual s32 addItem(const wchar_t* text) = 0; + + //! deletes all items in the combo box + virtual void clear() = 0; + + //! returns id of selected item. returns -1 if no item is selected. + virtual s32 getSelected() = 0; + + //! sets the selected item. Set this to -1 if no item should be selected + virtual void setSelected(s32 id) = 0; + + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIContextMenu.h b/src/dep/include/irrlicht/IGUIContextMenu.h index e835bb4..2cfb049 100644 --- a/src/dep/include/irrlicht/IGUIContextMenu.h +++ b/src/dep/include/irrlicht/IGUIContextMenu.h @@ -1,103 +1,103 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_CONTEXT_MENU_H_INCLUDED__ -#define __I_GUI_CONTEXT_MENU_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace gui -{ - - //! GUI Context menu interface. - class IGUIContextMenu : public IGUIElement - { - public: - - //! constructor - IGUIContextMenu(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_CONTEXT_MENU, environment, parent, id, rectangle) {} - - //! destructor - ~IGUIContextMenu() {}; - - //! Returns amount of menu items - virtual s32 getItemCount() const = 0; - - //! Adds a menu item. - /** \param text: Text of menu item. Set this to 0 to create - an separator instead of a real item, which is the same like - calling addSeparator(); - \param commandId: Command id of menu item, a simple id you may - set to whatever you want. - \param enabled: Specifies if the menu item should be enabled. - \param hasSubMenu: Set this to true if there should be a submenu - at this item. You can acess this submenu via getSubMenu(). - \return Returns the index of the new item */ - virtual s32 addItem(const wchar_t* text, s32 commandId=-1, bool enabled=true, - bool hasSubMenu=false, - bool checked=false - ) = 0; - - //! Adds a separator item to the menu - virtual void addSeparator() = 0; - - //! Returns text of the menu item. - /** \param idx: Zero based index of the menu item */ - virtual const wchar_t* getItemText(s32 idx) = 0; - - //! Sets text of the menu item. - /** \param idx: Zero based index of the menu item - \param text: New text of the item. */ - virtual void setItemText(s32 idx, const wchar_t* text) = 0; - - //! Returns if a menu item is enabled - /** \param idx: Zero based index of the menu item */ - virtual bool isItemEnabled(s32 idx) = 0; - - //! Sets if the menu item should be enabled. - /** \param idx: Zero based index of the menu item - \param enabled: True if it is enabled, otherwise false. */ - virtual void setItemEnabled(s32 idx, bool enabled) = 0; - - //! Sets if the menu item should be checked. - /** \param idx: Zero based index of the menu item - \param enabled: True if it is enabled, otherwise false. */ - virtual void setItemChecked(s32 idx, bool enabled) = 0; - - - //! Removes a menu item - /** \param idx: Zero based index of the menu item */ - virtual void removeItem(s32 idx) = 0; - - //! Removes all menu items - virtual void removeAllItems() = 0; - - //! Returns the selected item in the menu - /** \return Index of the selected item, -1 if none selected. */ - virtual s32 getSelectedItem() = 0; - - //! Returns command id of a menu item - /** \param idx: Zero based index of the menu item */ - virtual s32 getItemCommandId(s32 idx) = 0; - - //! Sets the command id of a menu item - /** \param idx: Zero based index of the menu item - \param id: Command id of menu item, a simple id you may - set to whatever you want. */ - virtual void setItemCommandId(s32 idx, s32 id) = 0; - - //! \return Returns a pointer to the submenu of an item. - /** 0 is returned if there is no submenu - \param idx: Zero based index of the menu item */ - virtual IGUIContextMenu* getSubMenu(s32 idx) = 0; - }; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_CONTEXT_MENU_H_INCLUDED__ +#define __I_GUI_CONTEXT_MENU_H_INCLUDED__ + +#include "IGUIElement.h" + +namespace irr +{ +namespace gui +{ + + //! GUI Context menu interface. + class IGUIContextMenu : public IGUIElement + { + public: + + //! constructor + IGUIContextMenu(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_CONTEXT_MENU, environment, parent, id, rectangle) {} + + //! destructor + ~IGUIContextMenu() {}; + + //! Returns amount of menu items + virtual s32 getItemCount() const = 0; + + //! Adds a menu item. + /** \param text: Text of menu item. Set this to 0 to create + an separator instead of a real item, which is the same like + calling addSeparator(); + \param commandId: Command id of menu item, a simple id you may + set to whatever you want. + \param enabled: Specifies if the menu item should be enabled. + \param hasSubMenu: Set this to true if there should be a submenu + at this item. You can acess this submenu via getSubMenu(). + \return Returns the index of the new item */ + virtual s32 addItem(const wchar_t* text, s32 commandId=-1, bool enabled=true, + bool hasSubMenu=false, + bool checked=false + ) = 0; + + //! Adds a separator item to the menu + virtual void addSeparator() = 0; + + //! Returns text of the menu item. + /** \param idx: Zero based index of the menu item */ + virtual const wchar_t* getItemText(s32 idx) = 0; + + //! Sets text of the menu item. + /** \param idx: Zero based index of the menu item + \param text: New text of the item. */ + virtual void setItemText(s32 idx, const wchar_t* text) = 0; + + //! Returns if a menu item is enabled + /** \param idx: Zero based index of the menu item */ + virtual bool isItemEnabled(s32 idx) = 0; + + //! Sets if the menu item should be enabled. + /** \param idx: Zero based index of the menu item + \param enabled: True if it is enabled, otherwise false. */ + virtual void setItemEnabled(s32 idx, bool enabled) = 0; + + //! Sets if the menu item should be checked. + /** \param idx: Zero based index of the menu item + \param enabled: True if it is enabled, otherwise false. */ + virtual void setItemChecked(s32 idx, bool enabled) = 0; + + + //! Removes a menu item + /** \param idx: Zero based index of the menu item */ + virtual void removeItem(s32 idx) = 0; + + //! Removes all menu items + virtual void removeAllItems() = 0; + + //! Returns the selected item in the menu + /** \return Index of the selected item, -1 if none selected. */ + virtual s32 getSelectedItem() = 0; + + //! Returns command id of a menu item + /** \param idx: Zero based index of the menu item */ + virtual s32 getItemCommandId(s32 idx) = 0; + + //! Sets the command id of a menu item + /** \param idx: Zero based index of the menu item + \param id: Command id of menu item, a simple id you may + set to whatever you want. */ + virtual void setItemCommandId(s32 idx, s32 id) = 0; + + //! \return Returns a pointer to the submenu of an item. + /** 0 is returned if there is no submenu + \param idx: Zero based index of the menu item */ + virtual IGUIContextMenu* getSubMenu(s32 idx) = 0; + }; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIEditBox.h b/src/dep/include/irrlicht/IGUIEditBox.h index a205639..a8d028b 100644 --- a/src/dep/include/irrlicht/IGUIEditBox.h +++ b/src/dep/include/irrlicht/IGUIEditBox.h @@ -1,64 +1,64 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_EDIT_BOX_H_INCLUDED__ -#define __I_GUI_EDIT_BOX_H_INCLUDED__ - -#include "IGUIElement.h" -#include "SColor.h" - -namespace irr -{ -namespace gui -{ - class IGUIFont; - - //! Single line edit box for editing simple text. - class IGUIEditBox : public IGUIElement - { - public: - - //! constructor - IGUIEditBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_EDIT_BOX, environment, parent, id, rectangle) {} - - //! destructor - ~IGUIEditBox() {}; - - //! Sets another skin independent font. - /** If this is set to zero, the button uses the font of the skin. - \param font: New font to set. */ - virtual void setOverrideFont(IGUIFont* font=0) = 0; - - //! Sets another color for the text. - /** If set, the edit box does not use the EGDC_BUTTON_TEXT color defined - in the skin, but the set color instead. You don't need to call - IGUIEditBox::enableOverrrideColor(true) after this, this is done - by this function. - If you set a color, and you want the text displayed with the color - of the skin again, call IGUIEditBox::enableOverrideColor(false); - \param color: New color of the text. */ - virtual void setOverrideColor(video::SColor color) = 0; - - //! Sets if the text should use the overide color or the color in the gui skin. - /** \param enable: If set to true, the override color, which can be set - with IGUIEditBox::setOverrideColor is used, otherwise the - EGDC_BUTTON_TEXT color of the skin. */ - virtual void enableOverrideColor(bool enable) = 0; - - //! Sets the maximum amount of characters which may be entered in the box. - /** \param max: Maximum amount of characters. If 0, the character amount is - infinity. */ - virtual void setMax(s32 max) = 0; - - //! Returns maximum amount of characters, previously set by setMax(); - virtual s32 getMax() = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_EDIT_BOX_H_INCLUDED__ +#define __I_GUI_EDIT_BOX_H_INCLUDED__ + +#include "IGUIElement.h" +#include "SColor.h" + +namespace irr +{ +namespace gui +{ + class IGUIFont; + + //! Single line edit box for editing simple text. + class IGUIEditBox : public IGUIElement + { + public: + + //! constructor + IGUIEditBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_EDIT_BOX, environment, parent, id, rectangle) {} + + //! destructor + ~IGUIEditBox() {}; + + //! Sets another skin independent font. + /** If this is set to zero, the button uses the font of the skin. + \param font: New font to set. */ + virtual void setOverrideFont(IGUIFont* font=0) = 0; + + //! Sets another color for the text. + /** If set, the edit box does not use the EGDC_BUTTON_TEXT color defined + in the skin, but the set color instead. You don't need to call + IGUIEditBox::enableOverrrideColor(true) after this, this is done + by this function. + If you set a color, and you want the text displayed with the color + of the skin again, call IGUIEditBox::enableOverrideColor(false); + \param color: New color of the text. */ + virtual void setOverrideColor(video::SColor color) = 0; + + //! Sets if the text should use the overide color or the color in the gui skin. + /** \param enable: If set to true, the override color, which can be set + with IGUIEditBox::setOverrideColor is used, otherwise the + EGDC_BUTTON_TEXT color of the skin. */ + virtual void enableOverrideColor(bool enable) = 0; + + //! Sets the maximum amount of characters which may be entered in the box. + /** \param max: Maximum amount of characters. If 0, the character amount is + infinity. */ + virtual void setMax(s32 max) = 0; + + //! Returns maximum amount of characters, previously set by setMax(); + virtual s32 getMax() = 0; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIElement.h b/src/dep/include/irrlicht/IGUIElement.h index fd81e66..ea371b5 100644 --- a/src/dep/include/irrlicht/IGUIElement.h +++ b/src/dep/include/irrlicht/IGUIElement.h @@ -1,706 +1,706 @@ - // Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_ELEMENT_H_INCLUDED__ -#define __I_GUI_ELEMENT_H_INCLUDED__ - -#include "IUnknown.h" -#include "irrList.h" -#include "rect.h" -#include "irrString.h" -#include "IEventReceiver.h" -#include "EGUIElementTypes.h" -#include "IAttributes.h" -#include "IAttributeExchangingObject.h" - -namespace irr -{ -namespace gui -{ -class IGUIEnvironment; - -enum EGUI_ALIGNMENT -{ - //! Aligned to parent's top or left side (default) - EGUIA_UPPERLEFT=0, - //! Aligned to parent's bottom or right side - EGUIA_LOWERRIGHT, - //! Aligned to the center of parent - EGUIA_CENTER, - //! Scaled within its parent - EGUIA_SCALE -}; - -//! Names for alignments -const c8* const GUIAlignmentNames[] = -{ - "upperLeft", - "lowerRight", - "center", - "scale", - 0 -}; - -//! Base class of all GUI elements. -class IGUIElement : public virtual io::IAttributeExchangingObject, public IEventReceiver -{ -public: - - //! Constructor - IGUIElement(EGUI_ELEMENT_TYPE type, IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect rectangle) - : Parent(0), RelativeRect(rectangle), AbsoluteRect(rectangle), - AbsoluteClippingRect(rectangle), DesiredRect(rectangle), - MaxSize(0,0), MinSize(1,1), IsVisible(true), IsEnabled(true), - IsSubElement(false), NoClip(false), ID(id), - AlignLeft(EGUIA_UPPERLEFT), AlignRight(EGUIA_UPPERLEFT), AlignTop(EGUIA_UPPERLEFT), AlignBottom(EGUIA_UPPERLEFT), - Environment(environment), Type(type) - { - // if we were given a parent to attach to - if (parent) - parent->addChild(this); - - // if we succeeded in becoming a child - if (Parent) - { - LastParentRect = Parent->getAbsolutePosition(); - AbsoluteRect += LastParentRect.UpperLeftCorner; - AbsoluteClippingRect = AbsoluteRect; - AbsoluteClippingRect.clipAgainst(Parent->AbsoluteClippingRect); - } - } - - - //! Destructor - virtual ~IGUIElement() - { - // delete all children - core::list::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - { - (*it)->Parent = 0; - (*it)->drop(); - } - }; - - - //! Returns parent of this element. - IGUIElement* getParent() const - { - return Parent; - } - - - //! Returns the relative rectangle of this element. - core::rect getRelativePosition() const - { - return RelativeRect; - } - - - //! Sets the relative rectangle of this element. - void setRelativePosition(const core::rect& r) - { - if (Parent) - { - core::rect r2(Parent->getAbsolutePosition()); - - core::dimension2df d((f32)r2.getSize().Width, (f32)r2.getSize().Height); - - if (AlignLeft == EGUIA_SCALE) - ScaleRect.UpperLeftCorner.X = (f32)r.UpperLeftCorner.X / d.Width; - if (AlignRight == EGUIA_SCALE) - ScaleRect.LowerRightCorner.X = (f32)r.LowerRightCorner.X / d.Width; - if (AlignTop == EGUIA_SCALE) - ScaleRect.UpperLeftCorner.Y = (f32)r.UpperLeftCorner.Y / d.Height; - if (AlignBottom == EGUIA_SCALE) - ScaleRect.LowerRightCorner.Y = (f32)r.LowerRightCorner.Y / d.Height; - } - - DesiredRect = r; - updateAbsolutePosition(); - } - - //! Sets the relative rectangle of this element. - void setRelativePosition(const core::rect& r) - { - if (!Parent) - return; - - core::rect r2(Parent->getAbsolutePosition()); - - core::dimension2di d(r2.getSize()); - - DesiredRect = core::rect( - (s32)((f32)d.Width * r.UpperLeftCorner.X), - (s32)((f32)d.Height * r.UpperLeftCorner.Y), - (s32)((f32)d.Width * r.LowerRightCorner.X), - (s32)((f32)d.Height * r.LowerRightCorner.Y)); - - ScaleRect = r; - - updateAbsolutePosition(); - } - - - //! Returns the absolute rectangle of element. - core::rect getAbsolutePosition() const - { - return AbsoluteRect; - } - - //! Sets whether the element will ignore its parent's clipping rectangle - void setNotClipped(bool noClip) - { - NoClip = noClip; - } - - //! Gets whether the element will ignore its parent's clipping rectangle - bool isNotClipped() - { - return NoClip; - } - - //! Sets the maximum size allowed for this element - /** If set to 0,0, there is no maximum size */ - void setMaxSize(core::dimension2di size) - { - MaxSize = size; - updateAbsolutePosition(); - } - - //! Sets the minimum size allowed for this element - void setMinSize(core::dimension2di size) - { - MinSize = size; - if (MinSize.Width < 1) - MinSize.Width = 1; - if (MinSize.Height < 1) - MinSize.Height = 1; - updateAbsolutePosition(); - } - - void setAlignment(EGUI_ALIGNMENT left, EGUI_ALIGNMENT right, EGUI_ALIGNMENT top, EGUI_ALIGNMENT bottom) - { - AlignLeft = left; - AlignRight = right; - AlignTop = top; - AlignBottom = bottom; - - if (Parent) - { - core::rect r(Parent->getAbsolutePosition()); - - core::dimension2df d((f32)r.getSize().Width, (f32)r.getSize().Height); - - if (AlignLeft == EGUIA_SCALE) - ScaleRect.UpperLeftCorner.X = (f32)DesiredRect.UpperLeftCorner.X / d.Width; - if (AlignRight == EGUIA_SCALE) - ScaleRect.LowerRightCorner.X = (f32)DesiredRect.LowerRightCorner.X / d.Width; - if (AlignTop == EGUIA_SCALE) - ScaleRect.UpperLeftCorner.Y = (f32)DesiredRect.UpperLeftCorner.Y / d.Height; - if (AlignBottom == EGUIA_SCALE) - ScaleRect.LowerRightCorner.Y = (f32)DesiredRect.LowerRightCorner.Y / d.Height; - } - } - - //! Updates the absolute position. - virtual void updateAbsolutePosition() - { - core::rect parentAbsolute(0,0,0,0); - core::rect parentAbsoluteClip; - s32 diffx, diffy; - f32 fw=0.f, fh=0.f; - - if (Parent) - { - parentAbsolute = Parent->AbsoluteRect; - - if (NoClip) - { - IGUIElement* p=this; - while (p && p->NoClip && p->Parent) - p = p->Parent; - if (p->Parent) - parentAbsoluteClip = p->Parent->AbsoluteClippingRect; - else - parentAbsoluteClip = p->AbsoluteClippingRect; - } - else - parentAbsoluteClip = Parent->AbsoluteClippingRect; - } - - - diffx = parentAbsolute.getWidth() - LastParentRect.getWidth(); - diffy = parentAbsolute.getHeight() - LastParentRect.getHeight(); - - if (AlignLeft == EGUIA_SCALE || AlignRight == EGUIA_SCALE) - fw = (f32)parentAbsolute.getWidth(); - - if (AlignTop == EGUIA_SCALE || AlignBottom == EGUIA_SCALE) - fh = (f32)parentAbsolute.getHeight(); - - - switch (AlignLeft) - { - case EGUIA_UPPERLEFT: - break; - case EGUIA_LOWERRIGHT: - DesiredRect.UpperLeftCorner.X += diffx; - break; - case EGUIA_CENTER: - DesiredRect.UpperLeftCorner.X += diffx/2; - break; - case EGUIA_SCALE: - DesiredRect.UpperLeftCorner.X = (s32)(ScaleRect.UpperLeftCorner.X * fw); - break; - } - - switch (AlignRight) - { - case EGUIA_UPPERLEFT: - break; - case EGUIA_LOWERRIGHT: - DesiredRect.LowerRightCorner.X += diffx; - break; - case EGUIA_CENTER: - DesiredRect.LowerRightCorner.X += diffx/2; - break; - case EGUIA_SCALE: - DesiredRect.LowerRightCorner.X = (s32)(ScaleRect.LowerRightCorner.X * fw); - break; - } - - switch (AlignTop) - { - case EGUIA_UPPERLEFT: - break; - case EGUIA_LOWERRIGHT: - DesiredRect.UpperLeftCorner.Y += diffy; - break; - case EGUIA_CENTER: - DesiredRect.UpperLeftCorner.Y += diffy/2; - break; - case EGUIA_SCALE: - DesiredRect.UpperLeftCorner.Y = (s32)(ScaleRect.UpperLeftCorner.Y * fh); - break; - } - - switch (AlignBottom) - { - case EGUIA_UPPERLEFT: - break; - case EGUIA_LOWERRIGHT: - DesiredRect.LowerRightCorner.Y += diffy; - break; - case EGUIA_CENTER: - DesiredRect.LowerRightCorner.Y += diffy/2; - break; - case EGUIA_SCALE: - DesiredRect.LowerRightCorner.Y = (s32)(ScaleRect.LowerRightCorner.Y * fh); - break; - } - - RelativeRect = DesiredRect; - - s32 w = RelativeRect.getWidth(); - s32 h = RelativeRect.getHeight(); - - // make sure the desired rectangle is allowed - if (w < MinSize.Width) - RelativeRect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + MinSize.Width; - if (h < MinSize.Height) - RelativeRect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + MinSize.Height; - if (MaxSize.Width && w > MaxSize.Width) - RelativeRect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + MaxSize.Width; - if (MaxSize.Height && h > MaxSize.Height) - RelativeRect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + MaxSize.Height; - - RelativeRect.repair(); - - AbsoluteRect = RelativeRect + parentAbsolute.UpperLeftCorner; - - if (!Parent) - parentAbsoluteClip = AbsoluteRect; - - AbsoluteClippingRect = AbsoluteRect; - AbsoluteClippingRect.clipAgainst(parentAbsoluteClip); - - LastParentRect = parentAbsolute; - - // update all children - core::list::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - { - (*it)->updateAbsolutePosition(); - } - } - - - //! Returns the child element, which is at the position of the point. - IGUIElement* getElementFromPoint(const core::position2d& point) - { - IGUIElement* target = 0; - - // we have to search from back to front. - - core::list::Iterator it = Children.getLast(); - - if (IsVisible) - while(it != Children.end()) - { - target = (*it)->getElementFromPoint(point); - if (target) - return target; - - --it; - } - - if (AbsoluteClippingRect.isPointInside(point) && IsVisible) - target = this; - - return target; - } - - - //! Adds a GUI element as new child of this element. - virtual void addChild(IGUIElement* child) - { - if (child) - { - child->grab(); - child->remove(); // remove from old parent - child->Parent = this; - Children.push_back(child); - } - } - - - //! Removes a child. - virtual void removeChild(IGUIElement* child) - { - core::list::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - if ((*it) == child) - { - (*it)->Parent = 0; - (*it)->drop(); - Children.erase(it); - return; - } - } - - - //! Removes this element from its parent. - virtual void remove() - { - if (Parent) - Parent->removeChild(this); - } - - - //! Draws the element and its children. - virtual void draw() - { - if (!IsVisible) - return; - - core::list::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - (*it)->draw(); - } - - //! animate the element and its children. - virtual void OnPostRender(u32 timeMs) - { - if (!IsVisible) - return; - - core::list::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - (*it)->OnPostRender( timeMs ); - } - - - //! Moves this element. - virtual void move(core::position2d absoluteMovement) - { - setRelativePosition(DesiredRect + absoluteMovement); - } - - - //! Returns true if element is visible. - virtual bool isVisible() - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsVisible; - } - - - //! Sets the visible state of this element. - virtual void setVisible(bool visible) - { - IsVisible = visible; - } - - - //! Returns true if this element was created as part of its parent control - virtual bool isSubElement() - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsSubElement; - } - - //! Sets whether this control was created as part of its parent, - //! for example when a scrollbar is part of a listbox. - //! SubElements are not saved to disk when calling guiEnvironment->saveGUI() - virtual void setSubElement(bool subElement) - { - IsSubElement = subElement; - } - - //! Returns true if element is enabled. - virtual bool isEnabled() - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsEnabled; - } - - - //! Sets the enabled state of this element. - virtual void setEnabled(bool enabled) - { - IsEnabled = enabled; - } - - - //! Sets the new caption of this element. - virtual void setText(const wchar_t* text) - { - Text = text; - } - - - //! Returns caption of this element. - virtual const wchar_t* getText() - { - return Text.c_str(); - } - - //! Sets the new caption of this element. - virtual void setToolTipText(const wchar_t* text) - { - ToolTipText = text; - } - - - //! Returns caption of this element. - virtual core::stringw &getToolTipText() - { - return ToolTipText; - } - - - //! Returns id. Can be used to identify the element. - virtual s32 getID() - { - return ID; - } - - //! Sets the id of this element - virtual void setID(s32 id) - { - ID = id; - } - - - //! Called if an event happened. - virtual bool OnEvent(SEvent event) - { - if (Parent) - Parent->OnEvent(event); - - return true; - } - - - //! Brings a child to front - /** \return Returns true if successful, false if not. */ - virtual bool bringToFront(IGUIElement* element) - { - core::list::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - { - if (element == (*it)) - { - Children.erase(it); - Children.push_back(element); - return true; - } - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - //! Returns list with children of this element - virtual const core::list& getChildren() const - { - return Children; - } - - //! Finds the first element with the given id. - /** \param id: Id to search for. - \param searchchildren: Set this to true, if also children of this - element may contain the element with the searched id and they - should be searched too. - \return Returns the first element with the given id. If no element - with this id was found, 0 is returned. */ - virtual IGUIElement* getElementFromId(s32 id, bool searchchildren=false) const - { - IGUIElement* e = 0; - - core::list::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - { - if ((*it)->getID() == id) - return (*it); - - if (searchchildren) - e = (*it)->getElementFromId(id, true); - - if (e) - return e; - } - - return e; - } - - //! Returns the type of the gui element. - /** This is needed for the .NET wrapper but will be used - later for serializing and deserializing. - If you wrote your own GUIElements, you need to set the type for your element as first parameter - in the constructor of IGUIElement. For own (=unknown) elements, simply use EGUIET_ELEMENT as type */ - EGUI_ELEMENT_TYPE getType() - { - return Type; - } - - //! Returns the type name of the gui element. - /** This is needed serializing elements. For serializing your own elements, override this function - and return your own type name which is created by your IGUIElementFactory */ - virtual const c8* getTypeName() - { - return GUIElementTypeNames[Type]; - } - - //! Writes attributes of the scene node. - //! Implement this to expose the attributes of your scene node for - //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) - { - out->addInt("Id", ID ); - out->addString("Caption", Text.c_str()); - out->addRect("Rect", DesiredRect); - out->addPosition2d("MinSize", core::position2di(MinSize.Width, MinSize.Height)); - out->addPosition2d("MaxSize", core::position2di(MaxSize.Width, MaxSize.Height)); - out->addBool("NoClip", NoClip); - out->addEnum("LeftAlign", AlignLeft, GUIAlignmentNames); - out->addEnum("RightAlign", AlignRight, GUIAlignmentNames); - out->addEnum("TopAlign", AlignTop, GUIAlignmentNames); - out->addEnum("BottomAlign", AlignBottom, GUIAlignmentNames); - out->addBool("Visible", IsVisible ); - out->addBool("Enabled", IsEnabled ); - } - - //! Reads attributes of the scene node. - //! Implement this to set the attributes of your scene node for - //! scripting languages, editors, debuggers or xml deserialization purposes. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) - { - //! relative rect of element - ID = in->getAttributeAsInt("Id"); - Text = in->getAttributeAsStringW("Caption").c_str(); - IsVisible = in->getAttributeAsBool("Visible"); - IsEnabled = in->getAttributeAsBool("Enabled"); - core::position2di p = in->getAttributeAsPosition2d("MaxSize"); - MaxSize = core::dimension2di(p.X,p.Y); - p = in->getAttributeAsPosition2d("MinSize"); - MinSize = core::dimension2di(p.X,p.Y); - NoClip = in->getAttributeAsBool("NoClip"); - AlignLeft = (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("LeftAlign", GUIAlignmentNames); - AlignRight = (EGUI_ALIGNMENT)in->getAttributeAsEnumeration("RightAlign", GUIAlignmentNames); - AlignTop = (EGUI_ALIGNMENT)in->getAttributeAsEnumeration("TopAlign", GUIAlignmentNames); - AlignBottom = (EGUI_ALIGNMENT)in->getAttributeAsEnumeration("BottomAlign", GUIAlignmentNames); - - setRelativePosition(in->getAttributeAsRect("Rect")); - } - -protected: - - //! List of all children of this element - core::list Children; - - //! Pointer to the parent - IGUIElement* Parent; - - //! relative rect of element - core::rect RelativeRect; - - //! absolute rect of element - core::rect AbsoluteRect; - - //! absolute clipping rect of element - core::rect AbsoluteClippingRect; - - //! the rectangle the element would prefer to be, - //! if it was not constrained by parent or max/min size - core::rect DesiredRect; - - //! for calculating the difference when resizing parent - core::rect LastParentRect; - - //! relative scale of the element inside its parent - core::rect ScaleRect; - - //! maximum and minimum size of the element - core::dimension2di MaxSize, MinSize; - - //! is visible? - bool IsVisible; - - //! is enabled? - bool IsEnabled; - - //! is a part of a larger whole and should not be serialized? - bool IsSubElement; - - //! does this element ignore its parent's clipping rectangle? - bool NoClip; - - //! caption - core::stringw Text; - - //! tooltip - core::stringw ToolTipText; - - //! id - s32 ID; - - //! tells the element how to act when its parent is resized - EGUI_ALIGNMENT AlignLeft, AlignRight, AlignTop, AlignBottom; - - //! GUI Environment - IGUIEnvironment* Environment; - - //! type of element - EGUI_ELEMENT_TYPE Type; -}; - - -} // end namespace gui -} // end namespace irr - -#endif - + // Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_ELEMENT_H_INCLUDED__ +#define __I_GUI_ELEMENT_H_INCLUDED__ + +#include "IUnknown.h" +#include "irrList.h" +#include "rect.h" +#include "irrString.h" +#include "IEventReceiver.h" +#include "EGUIElementTypes.h" +#include "IAttributes.h" +#include "IAttributeExchangingObject.h" + +namespace irr +{ +namespace gui +{ +class IGUIEnvironment; + +enum EGUI_ALIGNMENT +{ + //! Aligned to parent's top or left side (default) + EGUIA_UPPERLEFT=0, + //! Aligned to parent's bottom or right side + EGUIA_LOWERRIGHT, + //! Aligned to the center of parent + EGUIA_CENTER, + //! Scaled within its parent + EGUIA_SCALE +}; + +//! Names for alignments +const c8* const GUIAlignmentNames[] = +{ + "upperLeft", + "lowerRight", + "center", + "scale", + 0 +}; + +//! Base class of all GUI elements. +class IGUIElement : public virtual io::IAttributeExchangingObject, public IEventReceiver +{ +public: + + //! Constructor + IGUIElement(EGUI_ELEMENT_TYPE type, IGUIEnvironment* environment, IGUIElement* parent, + s32 id, core::rect rectangle) + : Parent(0), RelativeRect(rectangle), AbsoluteRect(rectangle), + AbsoluteClippingRect(rectangle), DesiredRect(rectangle), + MaxSize(0,0), MinSize(1,1), IsVisible(true), IsEnabled(true), + IsSubElement(false), NoClip(false), ID(id), + AlignLeft(EGUIA_UPPERLEFT), AlignRight(EGUIA_UPPERLEFT), AlignTop(EGUIA_UPPERLEFT), AlignBottom(EGUIA_UPPERLEFT), + Environment(environment), Type(type) + { + // if we were given a parent to attach to + if (parent) + parent->addChild(this); + + // if we succeeded in becoming a child + if (Parent) + { + LastParentRect = Parent->getAbsolutePosition(); + AbsoluteRect += LastParentRect.UpperLeftCorner; + AbsoluteClippingRect = AbsoluteRect; + AbsoluteClippingRect.clipAgainst(Parent->AbsoluteClippingRect); + } + } + + + //! Destructor + virtual ~IGUIElement() + { + // delete all children + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + { + (*it)->Parent = 0; + (*it)->drop(); + } + }; + + + //! Returns parent of this element. + IGUIElement* getParent() const + { + return Parent; + } + + + //! Returns the relative rectangle of this element. + core::rect getRelativePosition() const + { + return RelativeRect; + } + + + //! Sets the relative rectangle of this element. + void setRelativePosition(const core::rect& r) + { + if (Parent) + { + core::rect r2(Parent->getAbsolutePosition()); + + core::dimension2df d((f32)r2.getSize().Width, (f32)r2.getSize().Height); + + if (AlignLeft == EGUIA_SCALE) + ScaleRect.UpperLeftCorner.X = (f32)r.UpperLeftCorner.X / d.Width; + if (AlignRight == EGUIA_SCALE) + ScaleRect.LowerRightCorner.X = (f32)r.LowerRightCorner.X / d.Width; + if (AlignTop == EGUIA_SCALE) + ScaleRect.UpperLeftCorner.Y = (f32)r.UpperLeftCorner.Y / d.Height; + if (AlignBottom == EGUIA_SCALE) + ScaleRect.LowerRightCorner.Y = (f32)r.LowerRightCorner.Y / d.Height; + } + + DesiredRect = r; + updateAbsolutePosition(); + } + + //! Sets the relative rectangle of this element. + void setRelativePosition(const core::rect& r) + { + if (!Parent) + return; + + core::rect r2(Parent->getAbsolutePosition()); + + core::dimension2di d(r2.getSize()); + + DesiredRect = core::rect( + (s32)((f32)d.Width * r.UpperLeftCorner.X), + (s32)((f32)d.Height * r.UpperLeftCorner.Y), + (s32)((f32)d.Width * r.LowerRightCorner.X), + (s32)((f32)d.Height * r.LowerRightCorner.Y)); + + ScaleRect = r; + + updateAbsolutePosition(); + } + + + //! Returns the absolute rectangle of element. + core::rect getAbsolutePosition() const + { + return AbsoluteRect; + } + + //! Sets whether the element will ignore its parent's clipping rectangle + void setNotClipped(bool noClip) + { + NoClip = noClip; + } + + //! Gets whether the element will ignore its parent's clipping rectangle + bool isNotClipped() + { + return NoClip; + } + + //! Sets the maximum size allowed for this element + /** If set to 0,0, there is no maximum size */ + void setMaxSize(core::dimension2di size) + { + MaxSize = size; + updateAbsolutePosition(); + } + + //! Sets the minimum size allowed for this element + void setMinSize(core::dimension2di size) + { + MinSize = size; + if (MinSize.Width < 1) + MinSize.Width = 1; + if (MinSize.Height < 1) + MinSize.Height = 1; + updateAbsolutePosition(); + } + + void setAlignment(EGUI_ALIGNMENT left, EGUI_ALIGNMENT right, EGUI_ALIGNMENT top, EGUI_ALIGNMENT bottom) + { + AlignLeft = left; + AlignRight = right; + AlignTop = top; + AlignBottom = bottom; + + if (Parent) + { + core::rect r(Parent->getAbsolutePosition()); + + core::dimension2df d((f32)r.getSize().Width, (f32)r.getSize().Height); + + if (AlignLeft == EGUIA_SCALE) + ScaleRect.UpperLeftCorner.X = (f32)DesiredRect.UpperLeftCorner.X / d.Width; + if (AlignRight == EGUIA_SCALE) + ScaleRect.LowerRightCorner.X = (f32)DesiredRect.LowerRightCorner.X / d.Width; + if (AlignTop == EGUIA_SCALE) + ScaleRect.UpperLeftCorner.Y = (f32)DesiredRect.UpperLeftCorner.Y / d.Height; + if (AlignBottom == EGUIA_SCALE) + ScaleRect.LowerRightCorner.Y = (f32)DesiredRect.LowerRightCorner.Y / d.Height; + } + } + + //! Updates the absolute position. + virtual void updateAbsolutePosition() + { + core::rect parentAbsolute(0,0,0,0); + core::rect parentAbsoluteClip; + s32 diffx, diffy; + f32 fw=0.f, fh=0.f; + + if (Parent) + { + parentAbsolute = Parent->AbsoluteRect; + + if (NoClip) + { + IGUIElement* p=this; + while (p && p->NoClip && p->Parent) + p = p->Parent; + if (p->Parent) + parentAbsoluteClip = p->Parent->AbsoluteClippingRect; + else + parentAbsoluteClip = p->AbsoluteClippingRect; + } + else + parentAbsoluteClip = Parent->AbsoluteClippingRect; + } + + + diffx = parentAbsolute.getWidth() - LastParentRect.getWidth(); + diffy = parentAbsolute.getHeight() - LastParentRect.getHeight(); + + if (AlignLeft == EGUIA_SCALE || AlignRight == EGUIA_SCALE) + fw = (f32)parentAbsolute.getWidth(); + + if (AlignTop == EGUIA_SCALE || AlignBottom == EGUIA_SCALE) + fh = (f32)parentAbsolute.getHeight(); + + + switch (AlignLeft) + { + case EGUIA_UPPERLEFT: + break; + case EGUIA_LOWERRIGHT: + DesiredRect.UpperLeftCorner.X += diffx; + break; + case EGUIA_CENTER: + DesiredRect.UpperLeftCorner.X += diffx/2; + break; + case EGUIA_SCALE: + DesiredRect.UpperLeftCorner.X = (s32)(ScaleRect.UpperLeftCorner.X * fw); + break; + } + + switch (AlignRight) + { + case EGUIA_UPPERLEFT: + break; + case EGUIA_LOWERRIGHT: + DesiredRect.LowerRightCorner.X += diffx; + break; + case EGUIA_CENTER: + DesiredRect.LowerRightCorner.X += diffx/2; + break; + case EGUIA_SCALE: + DesiredRect.LowerRightCorner.X = (s32)(ScaleRect.LowerRightCorner.X * fw); + break; + } + + switch (AlignTop) + { + case EGUIA_UPPERLEFT: + break; + case EGUIA_LOWERRIGHT: + DesiredRect.UpperLeftCorner.Y += diffy; + break; + case EGUIA_CENTER: + DesiredRect.UpperLeftCorner.Y += diffy/2; + break; + case EGUIA_SCALE: + DesiredRect.UpperLeftCorner.Y = (s32)(ScaleRect.UpperLeftCorner.Y * fh); + break; + } + + switch (AlignBottom) + { + case EGUIA_UPPERLEFT: + break; + case EGUIA_LOWERRIGHT: + DesiredRect.LowerRightCorner.Y += diffy; + break; + case EGUIA_CENTER: + DesiredRect.LowerRightCorner.Y += diffy/2; + break; + case EGUIA_SCALE: + DesiredRect.LowerRightCorner.Y = (s32)(ScaleRect.LowerRightCorner.Y * fh); + break; + } + + RelativeRect = DesiredRect; + + s32 w = RelativeRect.getWidth(); + s32 h = RelativeRect.getHeight(); + + // make sure the desired rectangle is allowed + if (w < MinSize.Width) + RelativeRect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + MinSize.Width; + if (h < MinSize.Height) + RelativeRect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + MinSize.Height; + if (MaxSize.Width && w > MaxSize.Width) + RelativeRect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + MaxSize.Width; + if (MaxSize.Height && h > MaxSize.Height) + RelativeRect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + MaxSize.Height; + + RelativeRect.repair(); + + AbsoluteRect = RelativeRect + parentAbsolute.UpperLeftCorner; + + if (!Parent) + parentAbsoluteClip = AbsoluteRect; + + AbsoluteClippingRect = AbsoluteRect; + AbsoluteClippingRect.clipAgainst(parentAbsoluteClip); + + LastParentRect = parentAbsolute; + + // update all children + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + { + (*it)->updateAbsolutePosition(); + } + } + + + //! Returns the child element, which is at the position of the point. + IGUIElement* getElementFromPoint(const core::position2d& point) + { + IGUIElement* target = 0; + + // we have to search from back to front. + + core::list::Iterator it = Children.getLast(); + + if (IsVisible) + while(it != Children.end()) + { + target = (*it)->getElementFromPoint(point); + if (target) + return target; + + --it; + } + + if (AbsoluteClippingRect.isPointInside(point) && IsVisible) + target = this; + + return target; + } + + + //! Adds a GUI element as new child of this element. + virtual void addChild(IGUIElement* child) + { + if (child) + { + child->grab(); + child->remove(); // remove from old parent + child->Parent = this; + Children.push_back(child); + } + } + + + //! Removes a child. + virtual void removeChild(IGUIElement* child) + { + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + if ((*it) == child) + { + (*it)->Parent = 0; + (*it)->drop(); + Children.erase(it); + return; + } + } + + + //! Removes this element from its parent. + virtual void remove() + { + if (Parent) + Parent->removeChild(this); + } + + + //! Draws the element and its children. + virtual void draw() + { + if (!IsVisible) + return; + + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + (*it)->draw(); + } + + //! animate the element and its children. + virtual void OnPostRender(u32 timeMs) + { + if (!IsVisible) + return; + + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + (*it)->OnPostRender( timeMs ); + } + + + //! Moves this element. + virtual void move(core::position2d absoluteMovement) + { + setRelativePosition(DesiredRect + absoluteMovement); + } + + + //! Returns true if element is visible. + virtual bool isVisible() + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return IsVisible; + } + + + //! Sets the visible state of this element. + virtual void setVisible(bool visible) + { + IsVisible = visible; + } + + + //! Returns true if this element was created as part of its parent control + virtual bool isSubElement() + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return IsSubElement; + } + + //! Sets whether this control was created as part of its parent, + //! for example when a scrollbar is part of a listbox. + //! SubElements are not saved to disk when calling guiEnvironment->saveGUI() + virtual void setSubElement(bool subElement) + { + IsSubElement = subElement; + } + + //! Returns true if element is enabled. + virtual bool isEnabled() + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return IsEnabled; + } + + + //! Sets the enabled state of this element. + virtual void setEnabled(bool enabled) + { + IsEnabled = enabled; + } + + + //! Sets the new caption of this element. + virtual void setText(const wchar_t* text) + { + Text = text; + } + + + //! Returns caption of this element. + virtual const wchar_t* getText() + { + return Text.c_str(); + } + + //! Sets the new caption of this element. + virtual void setToolTipText(const wchar_t* text) + { + ToolTipText = text; + } + + + //! Returns caption of this element. + virtual core::stringw &getToolTipText() + { + return ToolTipText; + } + + + //! Returns id. Can be used to identify the element. + virtual s32 getID() + { + return ID; + } + + //! Sets the id of this element + virtual void setID(s32 id) + { + ID = id; + } + + + //! Called if an event happened. + virtual bool OnEvent(SEvent event) + { + if (Parent) + Parent->OnEvent(event); + + return true; + } + + + //! Brings a child to front + /** \return Returns true if successful, false if not. */ + virtual bool bringToFront(IGUIElement* element) + { + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + { + if (element == (*it)) + { + Children.erase(it); + Children.push_back(element); + return true; + } + } + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return false; + } + + //! Returns list with children of this element + virtual const core::list& getChildren() const + { + return Children; + } + + //! Finds the first element with the given id. + /** \param id: Id to search for. + \param searchchildren: Set this to true, if also children of this + element may contain the element with the searched id and they + should be searched too. + \return Returns the first element with the given id. If no element + with this id was found, 0 is returned. */ + virtual IGUIElement* getElementFromId(s32 id, bool searchchildren=false) const + { + IGUIElement* e = 0; + + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + { + if ((*it)->getID() == id) + return (*it); + + if (searchchildren) + e = (*it)->getElementFromId(id, true); + + if (e) + return e; + } + + return e; + } + + //! Returns the type of the gui element. + /** This is needed for the .NET wrapper but will be used + later for serializing and deserializing. + If you wrote your own GUIElements, you need to set the type for your element as first parameter + in the constructor of IGUIElement. For own (=unknown) elements, simply use EGUIET_ELEMENT as type */ + EGUI_ELEMENT_TYPE getType() + { + return Type; + } + + //! Returns the type name of the gui element. + /** This is needed serializing elements. For serializing your own elements, override this function + and return your own type name which is created by your IGUIElementFactory */ + virtual const c8* getTypeName() + { + return GUIElementTypeNames[Type]; + } + + //! Writes attributes of the scene node. + //! Implement this to expose the attributes of your scene node for + //! scripting languages, editors, debuggers or xml serialization purposes. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) + { + out->addInt("Id", ID ); + out->addString("Caption", Text.c_str()); + out->addRect("Rect", DesiredRect); + out->addPosition2d("MinSize", core::position2di(MinSize.Width, MinSize.Height)); + out->addPosition2d("MaxSize", core::position2di(MaxSize.Width, MaxSize.Height)); + out->addBool("NoClip", NoClip); + out->addEnum("LeftAlign", AlignLeft, GUIAlignmentNames); + out->addEnum("RightAlign", AlignRight, GUIAlignmentNames); + out->addEnum("TopAlign", AlignTop, GUIAlignmentNames); + out->addEnum("BottomAlign", AlignBottom, GUIAlignmentNames); + out->addBool("Visible", IsVisible ); + out->addBool("Enabled", IsEnabled ); + } + + //! Reads attributes of the scene node. + //! Implement this to set the attributes of your scene node for + //! scripting languages, editors, debuggers or xml deserialization purposes. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) + { + //! relative rect of element + ID = in->getAttributeAsInt("Id"); + Text = in->getAttributeAsStringW("Caption").c_str(); + IsVisible = in->getAttributeAsBool("Visible"); + IsEnabled = in->getAttributeAsBool("Enabled"); + core::position2di p = in->getAttributeAsPosition2d("MaxSize"); + MaxSize = core::dimension2di(p.X,p.Y); + p = in->getAttributeAsPosition2d("MinSize"); + MinSize = core::dimension2di(p.X,p.Y); + NoClip = in->getAttributeAsBool("NoClip"); + AlignLeft = (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("LeftAlign", GUIAlignmentNames); + AlignRight = (EGUI_ALIGNMENT)in->getAttributeAsEnumeration("RightAlign", GUIAlignmentNames); + AlignTop = (EGUI_ALIGNMENT)in->getAttributeAsEnumeration("TopAlign", GUIAlignmentNames); + AlignBottom = (EGUI_ALIGNMENT)in->getAttributeAsEnumeration("BottomAlign", GUIAlignmentNames); + + setRelativePosition(in->getAttributeAsRect("Rect")); + } + +protected: + + //! List of all children of this element + core::list Children; + + //! Pointer to the parent + IGUIElement* Parent; + + //! relative rect of element + core::rect RelativeRect; + + //! absolute rect of element + core::rect AbsoluteRect; + + //! absolute clipping rect of element + core::rect AbsoluteClippingRect; + + //! the rectangle the element would prefer to be, + //! if it was not constrained by parent or max/min size + core::rect DesiredRect; + + //! for calculating the difference when resizing parent + core::rect LastParentRect; + + //! relative scale of the element inside its parent + core::rect ScaleRect; + + //! maximum and minimum size of the element + core::dimension2di MaxSize, MinSize; + + //! is visible? + bool IsVisible; + + //! is enabled? + bool IsEnabled; + + //! is a part of a larger whole and should not be serialized? + bool IsSubElement; + + //! does this element ignore its parent's clipping rectangle? + bool NoClip; + + //! caption + core::stringw Text; + + //! tooltip + core::stringw ToolTipText; + + //! id + s32 ID; + + //! tells the element how to act when its parent is resized + EGUI_ALIGNMENT AlignLeft, AlignRight, AlignTop, AlignBottom; + + //! GUI Environment + IGUIEnvironment* Environment; + + //! type of element + EGUI_ELEMENT_TYPE Type; +}; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIElementFactory.h b/src/dep/include/irrlicht/IGUIElementFactory.h index 4ad9b6c..fbcb696 100644 --- a/src/dep/include/irrlicht/IGUIElementFactory.h +++ b/src/dep/include/irrlicht/IGUIElementFactory.h @@ -1,66 +1,66 @@ -// Copyright (C) 2002-2006 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_ELEMENT_FACTORY_H_INCLUDED__ -#define __I_GUI_ELEMENT_FACTORY_H_INCLUDED__ - -#include "IUnknown.h" -#include "EGUIElementTypes.h" - -namespace irr -{ - - -namespace gui -{ - class IGUIElement; - - //! Interface making it possible to dynamicly create GUI elements - /** To be able to add custom elements to Irrlicht and to make it possible for the - scene manager to save and load them, simply implement this interface and register it - in your gui environment via IGUIEnvironment::registerGUIElementFactory. - Note: When implementing your own element factory, don't call IGUIEnvironment::grab() to - increase the reference counter of the environment. This is not necessary because the - it will grab() the factory anyway, and otherwise cyclic references will be created. - */ - class IGUIElementFactory : public virtual IUnknown - { - public: - - //! adds an element to the gui environment based on its type id - /** \param type: Type of the element to add. - \param parent: Parent scene node of the new element, can be null to add to the root. - \return Returns pointer to the new element or null if not successful. */ - virtual IGUIElement* addGUIElement(EGUI_ELEMENT_TYPE type, IGUIElement* parent=0) = 0; - - //! adds a GUI element to the GUI Environment based on its type name - /** \param typeName: Type name of the element to add. - \param parent: Parent scene node of the new element, can be null to add it to the root. - \return Returns pointer to the new element or null if not successful. */ - virtual IGUIElement* addGUIElement(const c8* typeName, IGUIElement* parent=0) = 0; - - //! returns amount of GUI element types this factory is able to create - virtual s32 getCreatableGUIElementTypeCount() = 0; - - //! returns type of a createable element type - /** \param idx: Index of the element type in this factory. Must be a value between 0 and - getCreatableGUIElementTypeCount() */ - virtual EGUI_ELEMENT_TYPE getCreateableGUIElementType(s32 idx) = 0; - - //! returns type name of a createable GUI element type by index - /** \param idx: Index of the type in this factory. Must be a value between 0 and - getCreatableGUIElementTypeCount() */ - virtual const c8* getCreateableGUIElementTypeName(s32 idx) = 0; - - //! returns type name of a createable GUI element - /** \param type: Type of GUI element. - \return: Returns name of the type if this factory can create the type, otherwise 0. */ - virtual const c8* getCreateableGUIElementTypeName(EGUI_ELEMENT_TYPE type) = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif // __I_GUI_ELEMENT_FACTORY_H_INCLUDED__ +// Copyright (C) 2002-2006 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_ELEMENT_FACTORY_H_INCLUDED__ +#define __I_GUI_ELEMENT_FACTORY_H_INCLUDED__ + +#include "IUnknown.h" +#include "EGUIElementTypes.h" + +namespace irr +{ + + +namespace gui +{ + class IGUIElement; + + //! Interface making it possible to dynamicly create GUI elements + /** To be able to add custom elements to Irrlicht and to make it possible for the + scene manager to save and load them, simply implement this interface and register it + in your gui environment via IGUIEnvironment::registerGUIElementFactory. + Note: When implementing your own element factory, don't call IGUIEnvironment::grab() to + increase the reference counter of the environment. This is not necessary because the + it will grab() the factory anyway, and otherwise cyclic references will be created. + */ + class IGUIElementFactory : public virtual IUnknown + { + public: + + //! adds an element to the gui environment based on its type id + /** \param type: Type of the element to add. + \param parent: Parent scene node of the new element, can be null to add to the root. + \return Returns pointer to the new element or null if not successful. */ + virtual IGUIElement* addGUIElement(EGUI_ELEMENT_TYPE type, IGUIElement* parent=0) = 0; + + //! adds a GUI element to the GUI Environment based on its type name + /** \param typeName: Type name of the element to add. + \param parent: Parent scene node of the new element, can be null to add it to the root. + \return Returns pointer to the new element or null if not successful. */ + virtual IGUIElement* addGUIElement(const c8* typeName, IGUIElement* parent=0) = 0; + + //! returns amount of GUI element types this factory is able to create + virtual s32 getCreatableGUIElementTypeCount() = 0; + + //! returns type of a createable element type + /** \param idx: Index of the element type in this factory. Must be a value between 0 and + getCreatableGUIElementTypeCount() */ + virtual EGUI_ELEMENT_TYPE getCreateableGUIElementType(s32 idx) = 0; + + //! returns type name of a createable GUI element type by index + /** \param idx: Index of the type in this factory. Must be a value between 0 and + getCreatableGUIElementTypeCount() */ + virtual const c8* getCreateableGUIElementTypeName(s32 idx) = 0; + + //! returns type name of a createable GUI element + /** \param type: Type of GUI element. + \return: Returns name of the type if this factory can create the type, otherwise 0. */ + virtual const c8* getCreateableGUIElementTypeName(EGUI_ELEMENT_TYPE type) = 0; + }; + + +} // end namespace gui +} // end namespace irr + +#endif // __I_GUI_ELEMENT_FACTORY_H_INCLUDED__ diff --git a/src/dep/include/irrlicht/IGUIEnvironment.h b/src/dep/include/irrlicht/IGUIEnvironment.h index 323044b..7d3d6bb 100644 --- a/src/dep/include/irrlicht/IGUIEnvironment.h +++ b/src/dep/include/irrlicht/IGUIEnvironment.h @@ -1,395 +1,395 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_ENVIRNMENT_H_INCLUDED__ -#define __I_GUI_ENVIRNMENT_H_INCLUDED__ - -#include "rect.h" -#include "IUnknown.h" -#include "IEventReceiver.h" -#include "irrTypes.h" -#include "IGUIWindow.h" -#include "IGUISkin.h" -#include "IFileSystem.h" - -namespace irr -{ - namespace io - { - class IXMLWriter; - class IReadFile; - class IWriteFile; - } // end namespace io - namespace video - { - class IVideoDriver; - class ITexture; - } // end namespace video - -namespace gui -{ - -class IGUIElement; -class IGUIFont; -class IGUISpriteBank; -class IGUIScrollBar; -class IGUIImage; -class IGUIMeshViewer; -class IGUICheckBox; -class IGUIListBox; -class IGUIFileOpenDialog; -class IGUIColorSelectDialog; -class IGUIInOutFader; -class IGUIStaticText; -class IGUIEditBox; -class IGUITabControl; -class IGUITab; -class IGUIContextMenu; -class IGUIComboBox; -class IGUIToolBar; -class IGUIElementFactory; - -//! GUI Environment. Used as factory and manager of all other GUI elements. -class IGUIEnvironment : public virtual IUnknown -{ -public: - - //! destructor - virtual ~IGUIEnvironment() {}; - - //! Draws all gui elements. - virtual void drawAll() = 0; - - //! Sets the focus to an element. - virtual void setFocus(IGUIElement* element) = 0; - - //! Returns the element with the focus - virtual IGUIElement* getFocus() = 0; - - //! Removes the focus from an element. - virtual void removeFocus(IGUIElement* element) = 0; - - //! Returns if the element has focus - virtual bool hasFocus(IGUIElement* element) = 0; - - //! Returns the current video driver. - virtual video::IVideoDriver* getVideoDriver() = 0; - - //! Returns the file system. - virtual io::IFileSystem* getFileSystem() = 0; - - //! removes all elements from the environment. - virtual void clear() = 0; - - //! Posts an input event to the environment. - /** Usually you do not have to - use this method, it is used by the internal engine. */ - virtual bool postEventFromUser(SEvent event) = 0; - - //! This sets a new event receiver for gui events. - /** Usually you do not have to - use this method, it is used by the internal engine. */ - virtual void setUserEventReceiver(IEventReceiver* evr) = 0; - - //! Returns pointer to the current gui skin. - virtual IGUISkin* getSkin() = 0; - - //! Sets a new GUI Skin - /** You can used this to change the appearance of the whole GUI Environment. You - can set one ot the built-in skins or implement your own class derived from - IGUISkin and set this useing this method. - To set for example the built-in Windows classic skin, use the following code: - \code - gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC); - environment->setSkin(newskin); - newskin->drop(); - \endcode - */ - virtual void setSkin(IGUISkin* skin) = 0; - - //! Creates a new GUI Skin based on a template. - /** Use setSkin() to set the created skin. - \return Returns a pointer to the created skin. - If you no longer need the image, you should call IGUISkin::drop(). - See IUnknown::drop() for more information. */ - virtual IGUISkin* createSkin(EGUI_SKIN_TYPE type) = 0; - - //! Returns pointer to the font with the specified file name. - /** Loads the font if it was not loaded before. Returns 0 if the font could not be loaded. - \return - returns a pointer to the font. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIFont* getFont(const c8* filename) = 0; - - //! Returns the default built-in font. - virtual IGUIFont* getBuiltInFont() = 0; - - //! Returns pointer to the sprite bank with the specified file name. - /** Loads the bank if it was not loaded before. Returns 0 if it could not be loaded. - \return - returns a pointer to the sprite bank. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUISpriteBank* getSpriteBank(const c8* filename) = 0; - - //! adds an empty sprite bank to the manager - virtual IGUISpriteBank* addEmptySpriteBank(const c8 *name) = 0; - - //! Returns the root gui element. - /** This is the first gui element, parent of all other - gui elements. You'll never need to use this method, unless you are not creating - your own gui elements, trying to add them to the gui elements without a parent. - The returned pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIElement* getRootGUIElement() = 0; - - //! Adds an button element. - /** \return - Returns a pointer to the created button. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIButton* addButton(const core::rect& rectangle, - IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0, const wchar_t* tooltiptext = 0) = 0; - - //! Adds an empty window element. - /** \param modal: Defines if the dialog is modal. This means, that all other - gui elements which were created before the message box cannot be used - until this messagebox is removed. - \return - Returns a pointer to the created window. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIWindow* addWindow(const core::rect& rectangle, bool modal = false, - const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a modal screen. This control stops its parent's members from being - //! able to recieve input until its last child is removed, it then deletes its self. - /** \return - Returns a pointer to the created window. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIElement* addModalScreen(IGUIElement* parent) = 0; - - //! Adds a message box. - /** \param caption: Text to be displayed the title of the message box. - \param text: Text to be displayed in the body of the message box. - \param modal: Defines if the dialog is modal. This means, that all other - gui elements which were created before the message box cannot be used - until this messagebox is removed. - \param flags: Flags specifying the layout of the message box. For example - to create a message box with an OK and a CANCEL button on it, set this - to (EMBF_OK | EMBF_CANCEL). - \param parent: Parent gui element of the message box. - \param id: Id with which the gui element can be identified. - \return - Returns a pointer to the created message box. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0, - bool modal = true, s32 flags = EMBF_OK, IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a scrollbar. - /** \return - Returns a pointer to the created scrollbar. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect& rectangle, - IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds an image element. - /** \param image: Image to be displayed. - \param pos: Position of the image. The width and height of the image is taken - from the image. - \param useAlphaChannel: Sets if the image should use the alpha channel of the texture - to draw itself. - \return - Returns a pointer to the created image element. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIImage* addImage(video::ITexture* image, core::position2d pos, - bool useAlphaChannel=true, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0; - - //! Adds an image element. - /** Use IGUIImage::setImage later to set the image to be displayed. - \return - Returns a pointer to the created image element. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIImage* addImage(const core::rect& rectangle, - IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0; - - //! Adds a checkbox element. - /** \return - Returns a pointer to the created check box. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUICheckBox* addCheckBox(bool checked, const core::rect& rectangle, - IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0; - - //! Adds a list box element. - /** \return - Returns a pointer to the created list box. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIListBox* addListBox(const core::rect& rectangle, - IGUIElement* parent=0, s32 id=-1, bool drawBackground=false) = 0; - - //! Adds an mesh viewer. Not 100% implemented yet. - /** \return - Returns a pointer to the created mesh viewer. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIMeshViewer* addMeshViewer(const core::rect& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0; - - //! Adds a file open dialog. - /** \param modal: Defines if the dialog is modal. This means, that all other - gui elements which were created before the message box cannot be used - until this messagebox is removed. - \return - Returns a pointer to the created file open dialog. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIFileOpenDialog* addFileOpenDialog(const wchar_t* title = 0, - bool modal=true, IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a color select dialog. - /** \param modal: Defines if the dialog is modal. This means, that all other - gui elements which were created before the message box cannot be used - until this messagebox is removed. - \return - Returns a pointer to the created file open dialog. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIColorSelectDialog* addColorSelectDialog(const wchar_t* title = 0, - bool modal=true, IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a static text. - /** The returned pointer must not be dropped. - \param text is the text to be displayed. Can be altered after creation with SetText(). - \param rectangle is the position of the static text. - \param border has to be set to true if the static text should have a 3d border. - \param wordWrap specifies, if the text should be wrapped into multiple lines. - \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the fader directly in the environment. - \param id is a s32 to identify the static text element. - \param fillBackground specifies if the background will be filled. Default: false. - \return - Returns a pointer to the created static text. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIStaticText* addStaticText(const wchar_t* text, const core::rect& rectangle, - bool border=false, bool wordWrap=true, IGUIElement* parent=0, s32 id=-1, - bool fillBackground = false) = 0; - - //! Adds an edit box. - /** Supports unicode input from every keyboard around the world, - scrolling, copying and pasting (exchanging data with the clipboard directly), maximum - character amount, marking and all shortcuts like ctrl+X, ctrl+V, ctrg+C, - shift+Left, shift+Right, Home, End, and so on. - \param text is the text to be displayed. Can be altered after creation with SetText(). - \param rectangle is the position of the edit box. - \param border has to be set to true if the edit box should have a 3d border. - \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the edit box directly in the environment. - \param id is a s32 to identify the edit box. - \return - Returns a pointer to the created static text. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIEditBox* addEditBox(const wchar_t* text, const core::rect& rectangle, - bool border=true, IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds an element for fading in or out. - /* \param rectangle: Pointer to rectangle specifing the borders of the element. - If the pointer is NULL, the whole screen is used. - \param parent: Parent item of the element. E.g. a window. Set it to 0 to place the static text directly in the environment. - \param id: A s32 to identify the text. - \return - Returns a pointer to the created in-out-fader. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUIInOutFader* addInOutFader(const core::rect* rectangle=0, IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a tab control to the environment. - /** \param rectangle is the position of the tab control. - \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the tab control directly in the environment. - \param fillbackground specifies if the background of the tab control should be drawn to. - \param border specifiys if a flat 3d border should be drawn. - This is usually not necesarry unless you don't place the control directly into the environment without a window as parent. - \param id is a s32 to identify the tab control. - \return - Returns a pointer to the created tab control element. Returns 0 if an error occured. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IGUITabControl* addTabControl(const core::rect& rectangle, - IGUIElement* parent=0, bool fillbackground=false, - bool border=true, s32 id=-1) = 0; - - //! Adds tab to the environment. - /** You can use this element to group other elements. This is not used for creating tabs on tab controls, - please use IGUITabControl::addTab() for this instead. - \param rectangle is the position of the tab. - \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the tab directly in the environment. - \param id is a s32 to identify the tab. */ - virtual IGUITab* addTab(const core::rect& rectangle, - IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a context menu to the environment. - /** \param rectangle is the position of the menu. Note that the menu is - resizing itself based on what items you add. - \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the menu directly in the environment. - \param id is a s32 to identify the menu. */ - virtual IGUIContextMenu* addContextMenu(const core::rect& rectangle, - IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a menu to the environment. - /* This is like the menu you can find on top of most windows in modern graphical user interfaces. - \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the menu directly in the environment. - \param id is a s32 to identify the menu. */ - virtual IGUIContextMenu* addMenu(IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a toolbar to the environment. - /** It is like a menu is always placed on top - in its parent, and contains buttons. - \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the tool bar directly in the environment. - \param id is a s32 to identify the tool bar. */ - virtual IGUIToolBar* addToolBar(IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a combo box to the environment. - /** \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the combo box directly in the environment. - \param id is a s32 to identify the combo box. */ - virtual IGUIComboBox* addComboBox(const core::rect& rectangle, - IGUIElement* parent=0, s32 id=-1) = 0; - - //! Returns the default element factory which can create all built in elements - virtual IGUIElementFactory* getDefaultGUIElementFactory() = 0; - - //! Adds an element factory to the gui environment. - /** Use this to extend the gui environment with new element types which it should be - able to create automaticly, for example when loading data from xml files. */ - virtual void registerGUIElementFactory(IGUIElementFactory* factoryToAdd) = 0; - - //! Returns amount of registered scene node factories. - virtual s32 getRegisteredGUIElementFactoryCount() = 0; - - //! Returns a scene node factory by index - virtual IGUIElementFactory* getGUIElementFactory(s32 index) = 0; - - //! Adds a GUI Element by its name - virtual IGUIElement* addGUIElement(const c8* elementName, IGUIElement* parent=0) = 0; - - //! Saves the current gui into a file. - //! \param filename: Name of the file. - virtual bool saveGUI(const c8* filename)=0; - - //! Saves the current gui into a file. - virtual bool saveGUI(io::IWriteFile* file)=0; - - //! Loads the gui. Note that the current gui is not cleared before. - //! \param filename: Name of the file . - virtual bool loadGUI(const c8* filename)=0; - - //! Loads the gui. Note that the current gui is not cleared before. - virtual bool loadGUI(io::IReadFile* file)=0; - - //! Writes attributes of the gui environment - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0)=0; - - //! Reads attributes of the gui environment - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)=0; - - //! writes an element - virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node) =0; - - //! reads an element - virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* parent) =0; - -}; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_ENVIRNMENT_H_INCLUDED__ +#define __I_GUI_ENVIRNMENT_H_INCLUDED__ + +#include "rect.h" +#include "IUnknown.h" +#include "IEventReceiver.h" +#include "irrTypes.h" +#include "IGUIWindow.h" +#include "IGUISkin.h" +#include "IFileSystem.h" + +namespace irr +{ + namespace io + { + class IXMLWriter; + class IReadFile; + class IWriteFile; + } // end namespace io + namespace video + { + class IVideoDriver; + class ITexture; + } // end namespace video + +namespace gui +{ + +class IGUIElement; +class IGUIFont; +class IGUISpriteBank; +class IGUIScrollBar; +class IGUIImage; +class IGUIMeshViewer; +class IGUICheckBox; +class IGUIListBox; +class IGUIFileOpenDialog; +class IGUIColorSelectDialog; +class IGUIInOutFader; +class IGUIStaticText; +class IGUIEditBox; +class IGUITabControl; +class IGUITab; +class IGUIContextMenu; +class IGUIComboBox; +class IGUIToolBar; +class IGUIElementFactory; + +//! GUI Environment. Used as factory and manager of all other GUI elements. +class IGUIEnvironment : public virtual IUnknown +{ +public: + + //! destructor + virtual ~IGUIEnvironment() {}; + + //! Draws all gui elements. + virtual void drawAll() = 0; + + //! Sets the focus to an element. + virtual void setFocus(IGUIElement* element) = 0; + + //! Returns the element with the focus + virtual IGUIElement* getFocus() = 0; + + //! Removes the focus from an element. + virtual void removeFocus(IGUIElement* element) = 0; + + //! Returns if the element has focus + virtual bool hasFocus(IGUIElement* element) = 0; + + //! Returns the current video driver. + virtual video::IVideoDriver* getVideoDriver() = 0; + + //! Returns the file system. + virtual io::IFileSystem* getFileSystem() = 0; + + //! removes all elements from the environment. + virtual void clear() = 0; + + //! Posts an input event to the environment. + /** Usually you do not have to + use this method, it is used by the internal engine. */ + virtual bool postEventFromUser(SEvent event) = 0; + + //! This sets a new event receiver for gui events. + /** Usually you do not have to + use this method, it is used by the internal engine. */ + virtual void setUserEventReceiver(IEventReceiver* evr) = 0; + + //! Returns pointer to the current gui skin. + virtual IGUISkin* getSkin() = 0; + + //! Sets a new GUI Skin + /** You can used this to change the appearance of the whole GUI Environment. You + can set one ot the built-in skins or implement your own class derived from + IGUISkin and set this useing this method. + To set for example the built-in Windows classic skin, use the following code: + \code + gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC); + environment->setSkin(newskin); + newskin->drop(); + \endcode + */ + virtual void setSkin(IGUISkin* skin) = 0; + + //! Creates a new GUI Skin based on a template. + /** Use setSkin() to set the created skin. + \return Returns a pointer to the created skin. + If you no longer need the image, you should call IGUISkin::drop(). + See IUnknown::drop() for more information. */ + virtual IGUISkin* createSkin(EGUI_SKIN_TYPE type) = 0; + + //! Returns pointer to the font with the specified file name. + /** Loads the font if it was not loaded before. Returns 0 if the font could not be loaded. + \return + returns a pointer to the font. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIFont* getFont(const c8* filename) = 0; + + //! Returns the default built-in font. + virtual IGUIFont* getBuiltInFont() = 0; + + //! Returns pointer to the sprite bank with the specified file name. + /** Loads the bank if it was not loaded before. Returns 0 if it could not be loaded. + \return + returns a pointer to the sprite bank. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUISpriteBank* getSpriteBank(const c8* filename) = 0; + + //! adds an empty sprite bank to the manager + virtual IGUISpriteBank* addEmptySpriteBank(const c8 *name) = 0; + + //! Returns the root gui element. + /** This is the first gui element, parent of all other + gui elements. You'll never need to use this method, unless you are not creating + your own gui elements, trying to add them to the gui elements without a parent. + The returned pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIElement* getRootGUIElement() = 0; + + //! Adds an button element. + /** \return + Returns a pointer to the created button. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIButton* addButton(const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0, const wchar_t* tooltiptext = 0) = 0; + + //! Adds an empty window element. + /** \param modal: Defines if the dialog is modal. This means, that all other + gui elements which were created before the message box cannot be used + until this messagebox is removed. + \return + Returns a pointer to the created window. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIWindow* addWindow(const core::rect& rectangle, bool modal = false, + const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1) = 0; + + //! Adds a modal screen. This control stops its parent's members from being + //! able to recieve input until its last child is removed, it then deletes its self. + /** \return + Returns a pointer to the created window. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIElement* addModalScreen(IGUIElement* parent) = 0; + + //! Adds a message box. + /** \param caption: Text to be displayed the title of the message box. + \param text: Text to be displayed in the body of the message box. + \param modal: Defines if the dialog is modal. This means, that all other + gui elements which were created before the message box cannot be used + until this messagebox is removed. + \param flags: Flags specifying the layout of the message box. For example + to create a message box with an OK and a CANCEL button on it, set this + to (EMBF_OK | EMBF_CANCEL). + \param parent: Parent gui element of the message box. + \param id: Id with which the gui element can be identified. + \return + Returns a pointer to the created message box. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0, + bool modal = true, s32 flags = EMBF_OK, IGUIElement* parent=0, s32 id=-1) = 0; + + //! Adds a scrollbar. + /** \return + Returns a pointer to the created scrollbar. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1) = 0; + + //! Adds an image element. + /** \param image: Image to be displayed. + \param pos: Position of the image. The width and height of the image is taken + from the image. + \param useAlphaChannel: Sets if the image should use the alpha channel of the texture + to draw itself. + \return + Returns a pointer to the created image element. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIImage* addImage(video::ITexture* image, core::position2d pos, + bool useAlphaChannel=true, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0; + + //! Adds an image element. + /** Use IGUIImage::setImage later to set the image to be displayed. + \return + Returns a pointer to the created image element. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIImage* addImage(const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0; + + //! Adds a checkbox element. + /** \return + Returns a pointer to the created check box. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUICheckBox* addCheckBox(bool checked, const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0; + + //! Adds a list box element. + /** \return + Returns a pointer to the created list box. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIListBox* addListBox(const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1, bool drawBackground=false) = 0; + + //! Adds an mesh viewer. Not 100% implemented yet. + /** \return + Returns a pointer to the created mesh viewer. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIMeshViewer* addMeshViewer(const core::rect& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0; + + //! Adds a file open dialog. + /** \param modal: Defines if the dialog is modal. This means, that all other + gui elements which were created before the message box cannot be used + until this messagebox is removed. + \return + Returns a pointer to the created file open dialog. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIFileOpenDialog* addFileOpenDialog(const wchar_t* title = 0, + bool modal=true, IGUIElement* parent=0, s32 id=-1) = 0; + + //! Adds a color select dialog. + /** \param modal: Defines if the dialog is modal. This means, that all other + gui elements which were created before the message box cannot be used + until this messagebox is removed. + \return + Returns a pointer to the created file open dialog. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIColorSelectDialog* addColorSelectDialog(const wchar_t* title = 0, + bool modal=true, IGUIElement* parent=0, s32 id=-1) = 0; + + //! Adds a static text. + /** The returned pointer must not be dropped. + \param text is the text to be displayed. Can be altered after creation with SetText(). + \param rectangle is the position of the static text. + \param border has to be set to true if the static text should have a 3d border. + \param wordWrap specifies, if the text should be wrapped into multiple lines. + \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the fader directly in the environment. + \param id is a s32 to identify the static text element. + \param fillBackground specifies if the background will be filled. Default: false. + \return + Returns a pointer to the created static text. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIStaticText* addStaticText(const wchar_t* text, const core::rect& rectangle, + bool border=false, bool wordWrap=true, IGUIElement* parent=0, s32 id=-1, + bool fillBackground = false) = 0; + + //! Adds an edit box. + /** Supports unicode input from every keyboard around the world, + scrolling, copying and pasting (exchanging data with the clipboard directly), maximum + character amount, marking and all shortcuts like ctrl+X, ctrl+V, ctrg+C, + shift+Left, shift+Right, Home, End, and so on. + \param text is the text to be displayed. Can be altered after creation with SetText(). + \param rectangle is the position of the edit box. + \param border has to be set to true if the edit box should have a 3d border. + \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the edit box directly in the environment. + \param id is a s32 to identify the edit box. + \return + Returns a pointer to the created static text. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIEditBox* addEditBox(const wchar_t* text, const core::rect& rectangle, + bool border=true, IGUIElement* parent=0, s32 id=-1) = 0; + + //! Adds an element for fading in or out. + /* \param rectangle: Pointer to rectangle specifing the borders of the element. + If the pointer is NULL, the whole screen is used. + \param parent: Parent item of the element. E.g. a window. Set it to 0 to place the static text directly in the environment. + \param id: A s32 to identify the text. + \return + Returns a pointer to the created in-out-fader. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUIInOutFader* addInOutFader(const core::rect* rectangle=0, IGUIElement* parent=0, s32 id=-1) = 0; + + //! Adds a tab control to the environment. + /** \param rectangle is the position of the tab control. + \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the tab control directly in the environment. + \param fillbackground specifies if the background of the tab control should be drawn to. + \param border specifiys if a flat 3d border should be drawn. + This is usually not necesarry unless you don't place the control directly into the environment without a window as parent. + \param id is a s32 to identify the tab control. + \return + Returns a pointer to the created tab control element. Returns 0 if an error occured. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IGUITabControl* addTabControl(const core::rect& rectangle, + IGUIElement* parent=0, bool fillbackground=false, + bool border=true, s32 id=-1) = 0; + + //! Adds tab to the environment. + /** You can use this element to group other elements. This is not used for creating tabs on tab controls, + please use IGUITabControl::addTab() for this instead. + \param rectangle is the position of the tab. + \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the tab directly in the environment. + \param id is a s32 to identify the tab. */ + virtual IGUITab* addTab(const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1) = 0; + + //! Adds a context menu to the environment. + /** \param rectangle is the position of the menu. Note that the menu is + resizing itself based on what items you add. + \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the menu directly in the environment. + \param id is a s32 to identify the menu. */ + virtual IGUIContextMenu* addContextMenu(const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1) = 0; + + //! Adds a menu to the environment. + /* This is like the menu you can find on top of most windows in modern graphical user interfaces. + \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the menu directly in the environment. + \param id is a s32 to identify the menu. */ + virtual IGUIContextMenu* addMenu(IGUIElement* parent=0, s32 id=-1) = 0; + + //! Adds a toolbar to the environment. + /** It is like a menu is always placed on top + in its parent, and contains buttons. + \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the tool bar directly in the environment. + \param id is a s32 to identify the tool bar. */ + virtual IGUIToolBar* addToolBar(IGUIElement* parent=0, s32 id=-1) = 0; + + //! Adds a combo box to the environment. + /** \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the combo box directly in the environment. + \param id is a s32 to identify the combo box. */ + virtual IGUIComboBox* addComboBox(const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1) = 0; + + //! Returns the default element factory which can create all built in elements + virtual IGUIElementFactory* getDefaultGUIElementFactory() = 0; + + //! Adds an element factory to the gui environment. + /** Use this to extend the gui environment with new element types which it should be + able to create automaticly, for example when loading data from xml files. */ + virtual void registerGUIElementFactory(IGUIElementFactory* factoryToAdd) = 0; + + //! Returns amount of registered scene node factories. + virtual s32 getRegisteredGUIElementFactoryCount() = 0; + + //! Returns a scene node factory by index + virtual IGUIElementFactory* getGUIElementFactory(s32 index) = 0; + + //! Adds a GUI Element by its name + virtual IGUIElement* addGUIElement(const c8* elementName, IGUIElement* parent=0) = 0; + + //! Saves the current gui into a file. + //! \param filename: Name of the file. + virtual bool saveGUI(const c8* filename)=0; + + //! Saves the current gui into a file. + virtual bool saveGUI(io::IWriteFile* file)=0; + + //! Loads the gui. Note that the current gui is not cleared before. + //! \param filename: Name of the file . + virtual bool loadGUI(const c8* filename)=0; + + //! Loads the gui. Note that the current gui is not cleared before. + virtual bool loadGUI(io::IReadFile* file)=0; + + //! Writes attributes of the gui environment + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0)=0; + + //! Reads attributes of the gui environment + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)=0; + + //! writes an element + virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node) =0; + + //! reads an element + virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* parent) =0; + +}; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIFileOpenDialog.h b/src/dep/include/irrlicht/IGUIFileOpenDialog.h index 7338ef3..88f6c8d 100644 --- a/src/dep/include/irrlicht/IGUIFileOpenDialog.h +++ b/src/dep/include/irrlicht/IGUIFileOpenDialog.h @@ -1,37 +1,37 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ -#define __I_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace gui -{ - - //! Standard file chooser dialog. - class IGUIFileOpenDialog : public IGUIElement - { - public: - - //! constructor - IGUIFileOpenDialog(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_FILE_OPEN_DIALOG, environment, parent, id, rectangle) {} - - //! destructor - virtual ~IGUIFileOpenDialog() {}; - - //! Returns the filename of the selected file. Returns NULL, if no file was selected. - virtual const wchar_t* getFilename() = 0; - - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ +#define __I_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ + +#include "IGUIElement.h" + +namespace irr +{ +namespace gui +{ + + //! Standard file chooser dialog. + class IGUIFileOpenDialog : public IGUIElement + { + public: + + //! constructor + IGUIFileOpenDialog(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_FILE_OPEN_DIALOG, environment, parent, id, rectangle) {} + + //! destructor + virtual ~IGUIFileOpenDialog() {}; + + //! Returns the filename of the selected file. Returns NULL, if no file was selected. + virtual const wchar_t* getFilename() = 0; + + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIFont.h b/src/dep/include/irrlicht/IGUIFont.h index e015a42..c1b9f1e 100644 --- a/src/dep/include/irrlicht/IGUIFont.h +++ b/src/dep/include/irrlicht/IGUIFont.h @@ -1,99 +1,99 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_FONT_H_INCLUDED__ -#define __I_GUI_FONT_H_INCLUDED__ - -#include "IUnknown.h" -#include "rect.h" -#include "irrTypes.h" -#include "SColor.h" -#include "irrArray.h" -#include "ITexture.h" - -namespace irr -{ -namespace gui -{ - -//! An enum for the different types of GUI font. -enum EGUI_FONT_TYPE -{ - //! Bitmap fonts loaded from an XML file or a texture. - EGFT_BITMAP = 0, - - //! Scalable vector fonts loaded from an XML file. - //! These fonts reside in system memory and use no video memory - //! until they are displayed. These are slower than bitmap fonts - //! but can be easily scaled and rotated. - EGFT_VECTOR, - - //! A font which uses a the native API provided by the operating system. - //! Currently not used. - EGFT_OS, - - //! An external font type provided by the user. - EGFT_CUSTOM -}; - -//! Font interface. -class IGUIFont : public virtual IUnknown -{ -public: - - //! Destructor - virtual ~IGUIFont() {}; - - //! Draws an text and clips it to the specified rectangle if wanted. - /** \param text: Text to draw - \param position: Rectangle specifying position where to draw the text. - \param color: Color of the text - \param hcenter: Specifiies if the text should be centered horizontally into the rectangle. - \param vcenter: Specifiies if the text should be centered vertically into the rectangle. - \param clip: Optional pointer to a rectangle against which the text will be clipped. - If the pointer is null, no clipping will be done. */ - virtual void draw(const wchar_t* text, const core::rect& position, - video::SColor color, bool hcenter=false, bool vcenter=false, - const core::rect* clip=0) = 0; - - //! Calculates the dimension of a text. - /** \return Returns width and height of the area covered by the text if it would be - drawn. */ - virtual core::dimension2d getDimension(const wchar_t* text) = 0; - - //! Calculates the index of the character in the text which is on a specific position. - /** \param text: Text string. - \param pixel_x: X pixel position of which the index of the character will be returned. - \return Returns zero based index of the character in the text, and -1 if no no character - is on this position. (=the text is too short). */ - virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) = 0; - - //! Returns the type of this font - virtual EGUI_FONT_TYPE getType() { return EGFT_CUSTOM; } - - //! Sets global kerning for the font. - virtual void setKerningWidth (s32 kerning) = 0; - virtual void setKerningHeight (s32 kerning) = 0; - - //! Gets kerning values (distance between letters) for the font. If no parameters are provided, - /** the global kerning distance is returned. - \param thisLetter: If this parameter is provided, the left side kerning for this letter is added - to the global kerning value. For example, a space might only be one pixel wide, but it may - be displayed as several pixels. - \param previousLetter: If provided, kerning is calculated for both letters and added to the global - kerning value. For example, in a font which supports kerning pairs a string such as 'Wo' may have - the 'o' tucked neatly under the 'W'. - */ - virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) = 0; - - //! Returns the distance between letters - virtual s32 getKerningHeight() = 0; - -}; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_FONT_H_INCLUDED__ +#define __I_GUI_FONT_H_INCLUDED__ + +#include "IUnknown.h" +#include "rect.h" +#include "irrTypes.h" +#include "SColor.h" +#include "irrArray.h" +#include "ITexture.h" + +namespace irr +{ +namespace gui +{ + +//! An enum for the different types of GUI font. +enum EGUI_FONT_TYPE +{ + //! Bitmap fonts loaded from an XML file or a texture. + EGFT_BITMAP = 0, + + //! Scalable vector fonts loaded from an XML file. + //! These fonts reside in system memory and use no video memory + //! until they are displayed. These are slower than bitmap fonts + //! but can be easily scaled and rotated. + EGFT_VECTOR, + + //! A font which uses a the native API provided by the operating system. + //! Currently not used. + EGFT_OS, + + //! An external font type provided by the user. + EGFT_CUSTOM +}; + +//! Font interface. +class IGUIFont : public virtual IUnknown +{ +public: + + //! Destructor + virtual ~IGUIFont() {}; + + //! Draws an text and clips it to the specified rectangle if wanted. + /** \param text: Text to draw + \param position: Rectangle specifying position where to draw the text. + \param color: Color of the text + \param hcenter: Specifiies if the text should be centered horizontally into the rectangle. + \param vcenter: Specifiies if the text should be centered vertically into the rectangle. + \param clip: Optional pointer to a rectangle against which the text will be clipped. + If the pointer is null, no clipping will be done. */ + virtual void draw(const wchar_t* text, const core::rect& position, + video::SColor color, bool hcenter=false, bool vcenter=false, + const core::rect* clip=0) = 0; + + //! Calculates the dimension of a text. + /** \return Returns width and height of the area covered by the text if it would be + drawn. */ + virtual core::dimension2d getDimension(const wchar_t* text) = 0; + + //! Calculates the index of the character in the text which is on a specific position. + /** \param text: Text string. + \param pixel_x: X pixel position of which the index of the character will be returned. + \return Returns zero based index of the character in the text, and -1 if no no character + is on this position. (=the text is too short). */ + virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) = 0; + + //! Returns the type of this font + virtual EGUI_FONT_TYPE getType() { return EGFT_CUSTOM; } + + //! Sets global kerning for the font. + virtual void setKerningWidth (s32 kerning) = 0; + virtual void setKerningHeight (s32 kerning) = 0; + + //! Gets kerning values (distance between letters) for the font. If no parameters are provided, + /** the global kerning distance is returned. + \param thisLetter: If this parameter is provided, the left side kerning for this letter is added + to the global kerning value. For example, a space might only be one pixel wide, but it may + be displayed as several pixels. + \param previousLetter: If provided, kerning is calculated for both letters and added to the global + kerning value. For example, in a font which supports kerning pairs a string such as 'Wo' may have + the 'o' tucked neatly under the 'W'. + */ + virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) = 0; + + //! Returns the distance between letters + virtual s32 getKerningHeight() = 0; + +}; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIFontBitmap.h b/src/dep/include/irrlicht/IGUIFontBitmap.h index 06bda41..587436f 100644 --- a/src/dep/include/irrlicht/IGUIFontBitmap.h +++ b/src/dep/include/irrlicht/IGUIFontBitmap.h @@ -1,50 +1,50 @@ -// Copyright (C) 2002-2006 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_FONT_BITMAP_H_INCLUDED__ -#define __I_GUI_FONT_BITMAP_H_INCLUDED__ - -#include "IGUIFont.h" -#include "IGUISpriteBank.h" - -namespace irr -{ -namespace gui -{ - -//! Font interface. -class IGUIFontBitmap : public IGUIFont -{ -public: - - //! Destructor - virtual ~IGUIFontBitmap() {}; - - //! Returns the type of this font - virtual EGUI_FONT_TYPE getType() { return EGFT_BITMAP; } - - //! returns the parsed Symbol Information - virtual IGUISpriteBank* getSpriteBank() = 0; - - //! returns the sprite number from a given character - virtual u32 getSpriteNoFromChar(const wchar_t *c) = 0; - - //! Gets kerning values (distance between letters) for the font. If no parameters are provided, - /** the global kerning distance is returned. - \param thisLetter: If this parameter is provided, the left side kerning for this letter is added - to the global kerning value. For example, a space might only be one pixel wide, but it may - be displayed as several pixels. - \param previousLetter: If provided, kerning is calculated for both letters and added to the global - kerning value. For example, EGFT_BITMAP will add the right kerning value of previousLetter to the - left side kerning value of thisLetter, then add the global value. - */ - virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) = 0; - -}; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2006 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_FONT_BITMAP_H_INCLUDED__ +#define __I_GUI_FONT_BITMAP_H_INCLUDED__ + +#include "IGUIFont.h" +#include "IGUISpriteBank.h" + +namespace irr +{ +namespace gui +{ + +//! Font interface. +class IGUIFontBitmap : public IGUIFont +{ +public: + + //! Destructor + virtual ~IGUIFontBitmap() {}; + + //! Returns the type of this font + virtual EGUI_FONT_TYPE getType() { return EGFT_BITMAP; } + + //! returns the parsed Symbol Information + virtual IGUISpriteBank* getSpriteBank() = 0; + + //! returns the sprite number from a given character + virtual u32 getSpriteNoFromChar(const wchar_t *c) = 0; + + //! Gets kerning values (distance between letters) for the font. If no parameters are provided, + /** the global kerning distance is returned. + \param thisLetter: If this parameter is provided, the left side kerning for this letter is added + to the global kerning value. For example, a space might only be one pixel wide, but it may + be displayed as several pixels. + \param previousLetter: If provided, kerning is calculated for both letters and added to the global + kerning value. For example, EGFT_BITMAP will add the right kerning value of previousLetter to the + left side kerning value of thisLetter, then add the global value. + */ + virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) = 0; + +}; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIImage.h b/src/dep/include/irrlicht/IGUIImage.h index c9a6227..d952629 100644 --- a/src/dep/include/irrlicht/IGUIImage.h +++ b/src/dep/include/irrlicht/IGUIImage.h @@ -1,40 +1,40 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_IMAGE_H_INCLUDED__ -#define __I_GUI_IMAGE_H_INCLUDED__ - -#include "IGUIElement.h" -#include "ITexture.h" - -namespace irr -{ -namespace gui -{ - - //! GUI element displaying an image. - class IGUIImage : public IGUIElement - { - public: - - //! constructor - IGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_IMAGE, environment, parent, id, rectangle) {} - - //! destructor - ~IGUIImage() {}; - - //! sets an image - virtual void setImage(video::ITexture* image) = 0; - - //! sets if the image should use its alpha channel to draw itself - virtual void setUseAlphaChannel(bool use) = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_IMAGE_H_INCLUDED__ +#define __I_GUI_IMAGE_H_INCLUDED__ + +#include "IGUIElement.h" +#include "ITexture.h" + +namespace irr +{ +namespace gui +{ + + //! GUI element displaying an image. + class IGUIImage : public IGUIElement + { + public: + + //! constructor + IGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_IMAGE, environment, parent, id, rectangle) {} + + //! destructor + ~IGUIImage() {}; + + //! sets an image + virtual void setImage(video::ITexture* image) = 0; + + //! sets if the image should use its alpha channel to draw itself + virtual void setUseAlphaChannel(bool use) = 0; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIInOutFader.h b/src/dep/include/irrlicht/IGUIInOutFader.h index 6f8299f..1020f08 100644 --- a/src/dep/include/irrlicht/IGUIInOutFader.h +++ b/src/dep/include/irrlicht/IGUIInOutFader.h @@ -1,69 +1,69 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_IN_OUT_FADER_H_INCLUDED__ -#define __I_GUI_IN_OUT_FADER_H_INCLUDED__ - -#include "IGUIElement.h" -#include "SColor.h" - -namespace irr -{ -namespace gui -{ - - //! Element for fading out or in - /** Here is a small example on how the class is used. In this example we fade - in from a total red screen in the beginning. As you can see, the fader is not - only useful for dramatic in and out fading, but also to show that the player - is hit in a first person shooter game for example. - \code - gui::IGUIInOutFader* fader = device->getGUIEnvironment()->addInOutFader(); - fader->setColor(video::SColor(0,255,0,0)); - fader->fadeIn(4000); - \endcode - */ - class IGUIInOutFader : public IGUIElement - { - public: - - //! constructor - IGUIInOutFader(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_IN_OUT_FADER, environment, parent, id, rectangle) {} - - //! destructor - ~IGUIInOutFader() {}; - - //! Gets the color to fade out to or to fade in from. - virtual video::SColor getColor() const = 0; - - //! Sets the color to fade out to or to fade in from. - //! \param color: Color to where it is faded out od from it is faded in. - virtual void setColor(video::SColor color) = 0; - virtual void setColor(video::SColor source, video::SColor dest) = 0; - - //! Starts the fade in process. In the beginning the whole rect is drawn by - //! the set color (black by default) and at the end of the overgiven - //! time the color has faded out. - //! \param time: Time specifing how long it should need to fade in, - //! in milliseconds. - virtual void fadeIn(u32 time) = 0; - - //! Starts the fade out process. In the beginning everything is visible, - //! and at the end of the time only the set color (black by the fault) - //! will be drawn. - //! \param time: Time specifing how long it should need to fade out, - //! in milliseconds. - virtual void fadeOut(u32 time) = 0; - - //! Returns if the fade in or out process is done. - virtual bool isReady() const = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_IN_OUT_FADER_H_INCLUDED__ +#define __I_GUI_IN_OUT_FADER_H_INCLUDED__ + +#include "IGUIElement.h" +#include "SColor.h" + +namespace irr +{ +namespace gui +{ + + //! Element for fading out or in + /** Here is a small example on how the class is used. In this example we fade + in from a total red screen in the beginning. As you can see, the fader is not + only useful for dramatic in and out fading, but also to show that the player + is hit in a first person shooter game for example. + \code + gui::IGUIInOutFader* fader = device->getGUIEnvironment()->addInOutFader(); + fader->setColor(video::SColor(0,255,0,0)); + fader->fadeIn(4000); + \endcode + */ + class IGUIInOutFader : public IGUIElement + { + public: + + //! constructor + IGUIInOutFader(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_IN_OUT_FADER, environment, parent, id, rectangle) {} + + //! destructor + ~IGUIInOutFader() {}; + + //! Gets the color to fade out to or to fade in from. + virtual video::SColor getColor() const = 0; + + //! Sets the color to fade out to or to fade in from. + //! \param color: Color to where it is faded out od from it is faded in. + virtual void setColor(video::SColor color) = 0; + virtual void setColor(video::SColor source, video::SColor dest) = 0; + + //! Starts the fade in process. In the beginning the whole rect is drawn by + //! the set color (black by default) and at the end of the overgiven + //! time the color has faded out. + //! \param time: Time specifing how long it should need to fade in, + //! in milliseconds. + virtual void fadeIn(u32 time) = 0; + + //! Starts the fade out process. In the beginning everything is visible, + //! and at the end of the time only the set color (black by the fault) + //! will be drawn. + //! \param time: Time specifing how long it should need to fade out, + //! in milliseconds. + virtual void fadeOut(u32 time) = 0; + + //! Returns if the fade in or out process is done. + virtual bool isReady() const = 0; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIListBox.h b/src/dep/include/irrlicht/IGUIListBox.h index 7b38d00..2b1e08e 100644 --- a/src/dep/include/irrlicht/IGUIListBox.h +++ b/src/dep/include/irrlicht/IGUIListBox.h @@ -1,70 +1,70 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_LIST_BOX_BAR_H_INCLUDED__ -#define __I_GUI_LIST_BOX_BAR_H_INCLUDED__ - -#include "IGUIElement.h" -#include "irrTypes.h" - -namespace irr -{ -namespace gui -{ - class IGUIFont; - class IGUISpriteBank; - - //! Default list box GUI element. - class IGUIListBox : public IGUIElement - { - public: - - //! constructor - IGUIListBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_LIST_BOX, environment, parent, id, rectangle) {} - - //! destructor - ~IGUIListBox() {}; - - //! returns amount of list items - virtual s32 getItemCount() = 0; - - //! returns string of a list item. the may id be a value from 0 to itemCount-1 - virtual const wchar_t* getListItem(s32 id) = 0; - - //! adds an list item, returns id of item - virtual s32 addItem(const wchar_t* text) = 0; - - //! adds an list item with an icon - //! \param text Text of list entry - //! \param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon - //! \return - //! returns the id of the new created item - virtual s32 addItem(const wchar_t* text, s32 icon) = 0; - - //! Removes an item from the list - virtual void removeItem(s32 index) = 0; - - //! Sets the sprite bank which should be used to draw list icons. This font is set to the sprite bank of - //! the built-in-font by default. A sprite can be displayed in front of every list item. - //! An icon is an index within the icon sprite bank. Several default icons are available in the - //! skin through getIcon - virtual void setSpriteBank(IGUISpriteBank* bank) = 0; - - //! clears the list, deletes all items in the listbox - virtual void clear() = 0; - - //! returns id of selected item. returns -1 if no item is selected. - virtual s32 getSelected() = 0; - - //! sets the selected item. Set this to -1 if no item should be selected - virtual void setSelected(s32 id) = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_LIST_BOX_BAR_H_INCLUDED__ +#define __I_GUI_LIST_BOX_BAR_H_INCLUDED__ + +#include "IGUIElement.h" +#include "irrTypes.h" + +namespace irr +{ +namespace gui +{ + class IGUIFont; + class IGUISpriteBank; + + //! Default list box GUI element. + class IGUIListBox : public IGUIElement + { + public: + + //! constructor + IGUIListBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_LIST_BOX, environment, parent, id, rectangle) {} + + //! destructor + ~IGUIListBox() {}; + + //! returns amount of list items + virtual s32 getItemCount() = 0; + + //! returns string of a list item. the may id be a value from 0 to itemCount-1 + virtual const wchar_t* getListItem(s32 id) = 0; + + //! adds an list item, returns id of item + virtual s32 addItem(const wchar_t* text) = 0; + + //! adds an list item with an icon + //! \param text Text of list entry + //! \param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon + //! \return + //! returns the id of the new created item + virtual s32 addItem(const wchar_t* text, s32 icon) = 0; + + //! Removes an item from the list + virtual void removeItem(s32 index) = 0; + + //! Sets the sprite bank which should be used to draw list icons. This font is set to the sprite bank of + //! the built-in-font by default. A sprite can be displayed in front of every list item. + //! An icon is an index within the icon sprite bank. Several default icons are available in the + //! skin through getIcon + virtual void setSpriteBank(IGUISpriteBank* bank) = 0; + + //! clears the list, deletes all items in the listbox + virtual void clear() = 0; + + //! returns id of selected item. returns -1 if no item is selected. + virtual s32 getSelected() = 0; + + //! sets the selected item. Set this to -1 if no item should be selected + virtual void setSelected(s32 id) = 0; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIMeshViewer.h b/src/dep/include/irrlicht/IGUIMeshViewer.h index ea84911..2927f61 100644 --- a/src/dep/include/irrlicht/IGUIMeshViewer.h +++ b/src/dep/include/irrlicht/IGUIMeshViewer.h @@ -1,54 +1,54 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_MESH_VIEWER_H_INCLUDED__ -#define __I_GUI_MESH_VIEWER_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ - -namespace video -{ - class SMaterial; -} // end namespace video - -namespace scene -{ - class IAnimatedMesh; -} // end namespace scene - -namespace gui -{ - - //! 3d mesh viewing GUI element. - class IGUIMeshViewer : public IGUIElement - { - public: - - //! constructor - IGUIMeshViewer(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_MESH_VIEWER, environment, parent, id, rectangle) {} - - //! destructor - ~IGUIMeshViewer() {}; - - //! sets the mesh to be shown - virtual void setMesh(scene::IAnimatedMesh* mesh) = 0; - - //! sets the material - virtual void setMaterial(const video::SMaterial& material) = 0; - - //! gets the material - virtual const video::SMaterial& getMaterial() = 0; - - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_MESH_VIEWER_H_INCLUDED__ +#define __I_GUI_MESH_VIEWER_H_INCLUDED__ + +#include "IGUIElement.h" + +namespace irr +{ + +namespace video +{ + class SMaterial; +} // end namespace video + +namespace scene +{ + class IAnimatedMesh; +} // end namespace scene + +namespace gui +{ + + //! 3d mesh viewing GUI element. + class IGUIMeshViewer : public IGUIElement + { + public: + + //! constructor + IGUIMeshViewer(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_MESH_VIEWER, environment, parent, id, rectangle) {} + + //! destructor + ~IGUIMeshViewer() {}; + + //! sets the mesh to be shown + virtual void setMesh(scene::IAnimatedMesh* mesh) = 0; + + //! sets the material + virtual void setMaterial(const video::SMaterial& material) = 0; + + //! gets the material + virtual const video::SMaterial& getMaterial() = 0; + + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIScrollBar.h b/src/dep/include/irrlicht/IGUIScrollBar.h index 8593c6a..c13930a 100644 --- a/src/dep/include/irrlicht/IGUIScrollBar.h +++ b/src/dep/include/irrlicht/IGUIScrollBar.h @@ -1,45 +1,45 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_SCROLL_BAR_H_INCLUDED__ -#define __I_GUI_SCROLL_BAR_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace gui -{ - - //! Default scroll bar GUI element. - class IGUIScrollBar : public IGUIElement - { - public: - - //! constructor - IGUIScrollBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_SCROLL_BAR, environment, parent, id, rectangle) {} - - //! destructor - ~IGUIScrollBar() {}; - - //! sets the maximum value of the scrollbar. must be > 0 - virtual void setMax(s32 max) = 0; - - //! sets the small step value - virtual void setSmallStep(s32 step) = 0; - - //! gets the current position of the scrollbar - virtual s32 getPos() = 0; - - //! sets the current position of the scrollbar - virtual void setPos(s32 pos) = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_SCROLL_BAR_H_INCLUDED__ +#define __I_GUI_SCROLL_BAR_H_INCLUDED__ + +#include "IGUIElement.h" + +namespace irr +{ +namespace gui +{ + + //! Default scroll bar GUI element. + class IGUIScrollBar : public IGUIElement + { + public: + + //! constructor + IGUIScrollBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_SCROLL_BAR, environment, parent, id, rectangle) {} + + //! destructor + ~IGUIScrollBar() {}; + + //! sets the maximum value of the scrollbar. must be > 0 + virtual void setMax(s32 max) = 0; + + //! sets the small step value + virtual void setSmallStep(s32 step) = 0; + + //! gets the current position of the scrollbar + virtual s32 getPos() = 0; + + //! sets the current position of the scrollbar + virtual void setPos(s32 pos) = 0; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUISkin.h b/src/dep/include/irrlicht/IGUISkin.h index 7ef38eb..1e083d1 100644 --- a/src/dep/include/irrlicht/IGUISkin.h +++ b/src/dep/include/irrlicht/IGUISkin.h @@ -1,453 +1,453 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_SKIN_H_INCLUDED__ -#define __I_GUI_SKIN_H_INCLUDED__ - -#include "IAttributeExchangingObject.h" -#include "SColor.h" -#include "IGUISkin.h" -#include "rect.h" - -namespace irr -{ -namespace gui -{ - class IGUIFont; - class IGUISpriteBank; - class IGUIElement; - - //! Enumeration of available default skins. - /** To set one of the skins, use the following code, for example to set - the Windows classic skin: - \code - gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC); - environment->setSkin(newskin); - newskin->drop(); - \endcode - */ - enum EGUI_SKIN_TYPE - { - //! Default windows look and feel - EGST_WINDOWS_CLASSIC=0, - //! Like EGST_WINDOWS_CLASSIC, but with metallic shaded windows and buttons - EGST_WINDOWS_METALLIC, - //! Burning's skin - EGST_BURNING_SKIN, - - //! An unknown skin, not serializable at present - EGST_UNKNOWN - }; - - //! Names for gui element types - const c8* const GUISkinTypeNames[] = - { - "windowsClassic", - "windowsMetallic", - "burning", - "unknown", - 0, - }; - - - //! Enumeration for skin colors - enum EGUI_DEFAULT_COLOR - { - //! Dark shadow for three-dimensional display elements. - EGDC_3D_DARK_SHADOW = 0, - //! Shadow color for three-dimensional display elements (for edges facing away from the light source). - EGDC_3D_SHADOW, - //! Face color for three-dimensional display elements and for dialog box backgrounds. - EGDC_3D_FACE, - //! Highlight color for three-dimensional display elements (for edges facing the light source.) - EGDC_3D_HIGH_LIGHT, - //! Light color for three-dimensional display elements (for edges facing the light source.) - EGDC_3D_LIGHT, - //! Active window border. - EGDC_ACTIVE_BORDER, - //! Active window title bar text. - EGDC_ACTIVE_CAPTION, - //! Background color of multiple document interface (MDI) applications. - EGDC_APP_WORKSPACE, - //! Text on a button - EGDC_BUTTON_TEXT, - //! Grayed (disabled) text. - EGDC_GRAY_TEXT, - //! Item(s) selected in a control. - EGDC_HIGH_LIGHT, - //! Text of item(s) selected in a control. - EGDC_HIGH_LIGHT_TEXT, - //! Inactive window border. - EGDC_INACTIVE_BORDER, - //! Inactive window caption. - EGDC_INACTIVE_CAPTION, - //! Tool tip color - EGDC_TOOLTIP, - //! Scrollbar gray area - EGDC_SCROLLBAR, - //! Window background - EGDC_WINDOW, - //! Window symbols like on close buttons, scroll bars and check boxes - EGDC_WINDOW_SYMBOL, - //! Icons in a list or tree - EGDC_ICON, - //! Selected icons in a list or tree - EGDC_ICON_HIGH_LIGHT, - //! this value is not used, it only specifies the amount of default colors - //! available. - EGDC_COUNT - }; - - //! Names for default skin colors - const c8* const GUISkinColorNames[] = - { - "3DDarkShadow", - "3DShadow", - "3DFace", - "3DHighlight", - "3DLight", - "ActiveBorder", - "ActiveCaption", - "AppWorkspace", - "ButtonText", - "GrayText", - "Highlight", - "HighlightText", - "InactiveBorder", - "InactiveCaption", - "ToolTip", - "ScrollBar", - "Window", - "WindowSymbol", - "Icon", - "IconHighlight", - 0, - }; - - //! Enumeration for default sizes. - enum EGUI_DEFAULT_SIZE - { - //! default with / height of scrollbar - EGDS_SCROLLBAR_SIZE = 0, - //! height of menu - EGDS_MENU_HEIGHT, - //! width of a window button - EGDS_WINDOW_BUTTON_WIDTH, - //! width of a checkbox check - EGDS_CHECK_BOX_WIDTH, - //! width of a messagebox - EGDS_MESSAGE_BOX_WIDTH, - //! height of a messagebox - EGDS_MESSAGE_BOX_HEIGHT, - //! width of a default button - EGDS_BUTTON_WIDTH, - //! height of a default button - EGDS_BUTTON_HEIGHT, - //! distance for text from background - EGDS_TEXT_DISTANCE_X, - //! distance for text from background - EGDS_TEXT_DISTANCE_Y, - //! this value is not used, it only specifies the amount of default sizes - //! available. - EGDS_COUNT - }; - - - //! Names for default skin sizes - const c8* const GUISkinSizeNames[] = - { - "ScrollBarSize", - "MenuHeight", - "WindowButtonWidth", - "CheckBoxWidth", - "MessageBoxWidth", - "MessageBoxHeight", - "ButtonWidth", - "ButtonHeight", - "TextDistanceX", - "TextDistanceY", - 0, - }; - - - enum EGUI_DEFAULT_TEXT - { - //! Text for the OK button on a message box - EGDT_MSG_BOX_OK = 0, - //! Text for the Cancel button on a message box - EGDT_MSG_BOX_CANCEL, - //! Text for the Yes button on a message box - EGDT_MSG_BOX_YES, - //! Text for the No button on a message box - EGDT_MSG_BOX_NO, - //! Tooltip text for window close button - EGDT_WINDOW_CLOSE, - //! Tooltip text for window maximize button - EGDT_WINDOW_MAXIMIZE, - //! Tooltip text for window minimize button - EGDT_WINDOW_MINIMIZE, - //! Tooltip text for window restore button - EGDT_WINDOW_RESTORE, - - //! this value is not used, it only specifies the number of default texts - EGDT_COUNT - }; - - //! Names for default skin sizes - const c8* const GUISkinTextNames[] = - { - "MessageBoxOkay", - "MessageBoxCancel", - "MessageBoxYes", - "MessageBoxNo", - "WindowButtonClose", - "WindowButtonMaximize", - "WindowButtonMinimize", - "WindowButtonRestore", - 0, - }; - - //! Customizable symbols for GUI - enum EGUI_DEFAULT_ICON - { - //! maximize window button - EGDI_WINDOW_MAXIMIZE = 0, - //! restore window button - EGDI_WINDOW_RESTORE, - //! close window button - EGDI_WINDOW_CLOSE, - //! minimize window button - EGDI_WINDOW_MINIMIZE, - //! scroll bar up button - EGDI_CURSOR_UP, - //! scroll bar down button - EGDI_CURSOR_DOWN, - //! scroll bar left button - EGDI_CURSOR_LEFT, - //! scroll bar right button - EGDI_CURSOR_RIGHT, - //! icon for menu children - EGDI_MENU_MORE, - //! tick for checkbox - EGDI_CHECK_BOX_CHECKED, - //! down arrow for dropdown menus - EGDI_DROP_DOWN, - //! smaller up arrow - EGDI_SMALL_CURSOR_UP, - //! smaller down arrow - EGDI_SMALL_CURSOR_DOWN, - //! selection dot in a radio button - EGDI_RADIO_BUTTON_CHECKED, - //! file icon for file selection - EGDI_FILE, - //! folder icon for file selection - EGDI_DIRECTORY, - - //! value not used, it only specifies the number of icons - EGDI_COUNT - }; - - const c8* const GUISkinIconNames[] = - { - "windowMaximize", - "windowRestore", - "windowClose", - "windowMinimize", - "cursorUp", - "cursorDown", - "cursorLeft", - "cursorRight", - "menuMore", - "checkBoxChecked", - "dropDown", - "smallCursorUp", - "smallCursorDown", - "radioButtonChecked", - "file", - "directory", - 0 - }; - - //! A skin modifies the look of the GUI elements. - class IGUISkin : public virtual io::IAttributeExchangingObject - { - public: - - //! destructor - ~IGUISkin() {}; - - //! returns default color - virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) = 0; - - //! sets a default color - virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) = 0; - - //! returns default color - virtual s32 getSize(EGUI_DEFAULT_SIZE size) = 0; - - //! Returns a default text. - /** For example for Message box button captions: - "OK", "Cancel", "Yes", "No" and so on. */ - virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text) = 0; - - //! Sets a default text. - /** For example for Message box button captions: - "OK", "Cancel", "Yes", "No" and so on. */ - virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText) = 0; - - //! sets a default size - virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size) = 0; - - //! returns the default font - virtual IGUIFont* getFont() = 0; - - //! sets a default font - virtual void setFont(IGUIFont* font) = 0; - - //! returns the sprite bank - virtual IGUISpriteBank* getSpriteBank() = 0; - - //! sets the sprite bank - virtual void setSpriteBank(IGUISpriteBank* bank) = 0; - - //! Returns a default icon - /** Returns the sprite index within the sprite bank */ - virtual u32 getIcon(EGUI_DEFAULT_ICON icon) = 0; - - //! Sets a default icon - /** Sets the sprite index used for drawing icons like arrows, - close buttons and ticks in checkboxes - \param icon: Enum specifying which icon to change - \param index: The sprite index used to draw this icon */ - virtual void setIcon(EGUI_DEFAULT_ICON icon, u32 index) = 0; - - //! draws a standard 3d button pane - /** Used for drawing for example buttons in normal state. - It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and - EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DButtonPaneStandard(IGUIElement* element, - const core::rect& rect, - const core::rect* clip=0) = 0; - - //! draws a pressed 3d button pane - /** Used for drawing for example buttons in pressed state. - It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and - EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DButtonPanePressed(IGUIElement* element, - const core::rect& rect, - const core::rect* clip=0) = 0; - - //! draws a sunken 3d pane - /** Used for drawing the background of edit, combo or check boxes. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param bgcolor: Background color. - \param flat: Specifies if the sunken pane should be flat or displayed as sunken - deep into the ground. - \param fillBackGround: Specifies if the background should be filled with the background - color or not be drawn at all. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DSunkenPane(IGUIElement* element, - video::SColor bgcolor, bool flat, bool fillBackGround, - const core::rect& rect, - const core::rect* clip=0) = 0; - - //! draws a window background - /** Used for drawing the background of dialogs and windows. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param titleBarColor: Title color. - \param drawTitleBar: True to enable title drawing. - \param rect: Defining area where to draw. - \param clip: Clip area. - \return Returns rect where it would be good to draw title bar text. */ - virtual core::rect draw3DWindowBackground(IGUIElement* element, - bool drawTitleBar, video::SColor titleBarColor, - const core::rect& rect, - const core::rect* clip=0) = 0; - - //! draws a standard 3d menu pane - /** Used for drawing for menus and context menus. - It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and - EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DMenuPane(IGUIElement* element, - const core::rect& rect, - const core::rect* clip=0) = 0; - - //! draws a standard 3d tool bar - /** Used for drawing for toolbars and menus. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DToolBar(IGUIElement* element, - const core::rect& rect, - const core::rect* clip=0) = 0; - - //! draws a tab button - /** Used for drawing for tab buttons on top of tabs. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param active: Specifies if the tab is currently active. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DTabButton(IGUIElement* element, bool active, - const core::rect& rect, const core::rect* clip=0) = 0; - - //! draws a tab control body - /** \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param border: Specifies if the border should be drawn. - \param background: Specifies if the background should be drawn. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DTabBody(IGUIElement* element, bool border, bool background, - const core::rect& rect, const core::rect* clip=0) = 0; - - //! draws an icon, usually from the skin's sprite bank - /** \param parent: Pointer to the element which wishes to draw this icon. - This parameter is usually not used by IGUISkin, but can be used for example - by more complex implementations to find out how to draw the part exactly. - \param icon: Specifies the icon to be drawn. - \param position: The position to draw the icon - \param starttime: The time at the start of the animation - \param currenttime: The present time, used to calculate the frame number - \param loop: Whether the animation should loop or not - \param clip: Clip area. */ - virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon, - const core::position2di position, u32 starttime=0, u32 currenttime=0, - bool loop=false, const core::rect* clip=0) = 0; - - //! get the type of this skin - virtual EGUI_SKIN_TYPE getType() { return EGST_UNKNOWN; }; - - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_SKIN_H_INCLUDED__ +#define __I_GUI_SKIN_H_INCLUDED__ + +#include "IAttributeExchangingObject.h" +#include "SColor.h" +#include "IGUISkin.h" +#include "rect.h" + +namespace irr +{ +namespace gui +{ + class IGUIFont; + class IGUISpriteBank; + class IGUIElement; + + //! Enumeration of available default skins. + /** To set one of the skins, use the following code, for example to set + the Windows classic skin: + \code + gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC); + environment->setSkin(newskin); + newskin->drop(); + \endcode + */ + enum EGUI_SKIN_TYPE + { + //! Default windows look and feel + EGST_WINDOWS_CLASSIC=0, + //! Like EGST_WINDOWS_CLASSIC, but with metallic shaded windows and buttons + EGST_WINDOWS_METALLIC, + //! Burning's skin + EGST_BURNING_SKIN, + + //! An unknown skin, not serializable at present + EGST_UNKNOWN + }; + + //! Names for gui element types + const c8* const GUISkinTypeNames[] = + { + "windowsClassic", + "windowsMetallic", + "burning", + "unknown", + 0, + }; + + + //! Enumeration for skin colors + enum EGUI_DEFAULT_COLOR + { + //! Dark shadow for three-dimensional display elements. + EGDC_3D_DARK_SHADOW = 0, + //! Shadow color for three-dimensional display elements (for edges facing away from the light source). + EGDC_3D_SHADOW, + //! Face color for three-dimensional display elements and for dialog box backgrounds. + EGDC_3D_FACE, + //! Highlight color for three-dimensional display elements (for edges facing the light source.) + EGDC_3D_HIGH_LIGHT, + //! Light color for three-dimensional display elements (for edges facing the light source.) + EGDC_3D_LIGHT, + //! Active window border. + EGDC_ACTIVE_BORDER, + //! Active window title bar text. + EGDC_ACTIVE_CAPTION, + //! Background color of multiple document interface (MDI) applications. + EGDC_APP_WORKSPACE, + //! Text on a button + EGDC_BUTTON_TEXT, + //! Grayed (disabled) text. + EGDC_GRAY_TEXT, + //! Item(s) selected in a control. + EGDC_HIGH_LIGHT, + //! Text of item(s) selected in a control. + EGDC_HIGH_LIGHT_TEXT, + //! Inactive window border. + EGDC_INACTIVE_BORDER, + //! Inactive window caption. + EGDC_INACTIVE_CAPTION, + //! Tool tip color + EGDC_TOOLTIP, + //! Scrollbar gray area + EGDC_SCROLLBAR, + //! Window background + EGDC_WINDOW, + //! Window symbols like on close buttons, scroll bars and check boxes + EGDC_WINDOW_SYMBOL, + //! Icons in a list or tree + EGDC_ICON, + //! Selected icons in a list or tree + EGDC_ICON_HIGH_LIGHT, + //! this value is not used, it only specifies the amount of default colors + //! available. + EGDC_COUNT + }; + + //! Names for default skin colors + const c8* const GUISkinColorNames[] = + { + "3DDarkShadow", + "3DShadow", + "3DFace", + "3DHighlight", + "3DLight", + "ActiveBorder", + "ActiveCaption", + "AppWorkspace", + "ButtonText", + "GrayText", + "Highlight", + "HighlightText", + "InactiveBorder", + "InactiveCaption", + "ToolTip", + "ScrollBar", + "Window", + "WindowSymbol", + "Icon", + "IconHighlight", + 0, + }; + + //! Enumeration for default sizes. + enum EGUI_DEFAULT_SIZE + { + //! default with / height of scrollbar + EGDS_SCROLLBAR_SIZE = 0, + //! height of menu + EGDS_MENU_HEIGHT, + //! width of a window button + EGDS_WINDOW_BUTTON_WIDTH, + //! width of a checkbox check + EGDS_CHECK_BOX_WIDTH, + //! width of a messagebox + EGDS_MESSAGE_BOX_WIDTH, + //! height of a messagebox + EGDS_MESSAGE_BOX_HEIGHT, + //! width of a default button + EGDS_BUTTON_WIDTH, + //! height of a default button + EGDS_BUTTON_HEIGHT, + //! distance for text from background + EGDS_TEXT_DISTANCE_X, + //! distance for text from background + EGDS_TEXT_DISTANCE_Y, + //! this value is not used, it only specifies the amount of default sizes + //! available. + EGDS_COUNT + }; + + + //! Names for default skin sizes + const c8* const GUISkinSizeNames[] = + { + "ScrollBarSize", + "MenuHeight", + "WindowButtonWidth", + "CheckBoxWidth", + "MessageBoxWidth", + "MessageBoxHeight", + "ButtonWidth", + "ButtonHeight", + "TextDistanceX", + "TextDistanceY", + 0, + }; + + + enum EGUI_DEFAULT_TEXT + { + //! Text for the OK button on a message box + EGDT_MSG_BOX_OK = 0, + //! Text for the Cancel button on a message box + EGDT_MSG_BOX_CANCEL, + //! Text for the Yes button on a message box + EGDT_MSG_BOX_YES, + //! Text for the No button on a message box + EGDT_MSG_BOX_NO, + //! Tooltip text for window close button + EGDT_WINDOW_CLOSE, + //! Tooltip text for window maximize button + EGDT_WINDOW_MAXIMIZE, + //! Tooltip text for window minimize button + EGDT_WINDOW_MINIMIZE, + //! Tooltip text for window restore button + EGDT_WINDOW_RESTORE, + + //! this value is not used, it only specifies the number of default texts + EGDT_COUNT + }; + + //! Names for default skin sizes + const c8* const GUISkinTextNames[] = + { + "MessageBoxOkay", + "MessageBoxCancel", + "MessageBoxYes", + "MessageBoxNo", + "WindowButtonClose", + "WindowButtonMaximize", + "WindowButtonMinimize", + "WindowButtonRestore", + 0, + }; + + //! Customizable symbols for GUI + enum EGUI_DEFAULT_ICON + { + //! maximize window button + EGDI_WINDOW_MAXIMIZE = 0, + //! restore window button + EGDI_WINDOW_RESTORE, + //! close window button + EGDI_WINDOW_CLOSE, + //! minimize window button + EGDI_WINDOW_MINIMIZE, + //! scroll bar up button + EGDI_CURSOR_UP, + //! scroll bar down button + EGDI_CURSOR_DOWN, + //! scroll bar left button + EGDI_CURSOR_LEFT, + //! scroll bar right button + EGDI_CURSOR_RIGHT, + //! icon for menu children + EGDI_MENU_MORE, + //! tick for checkbox + EGDI_CHECK_BOX_CHECKED, + //! down arrow for dropdown menus + EGDI_DROP_DOWN, + //! smaller up arrow + EGDI_SMALL_CURSOR_UP, + //! smaller down arrow + EGDI_SMALL_CURSOR_DOWN, + //! selection dot in a radio button + EGDI_RADIO_BUTTON_CHECKED, + //! file icon for file selection + EGDI_FILE, + //! folder icon for file selection + EGDI_DIRECTORY, + + //! value not used, it only specifies the number of icons + EGDI_COUNT + }; + + const c8* const GUISkinIconNames[] = + { + "windowMaximize", + "windowRestore", + "windowClose", + "windowMinimize", + "cursorUp", + "cursorDown", + "cursorLeft", + "cursorRight", + "menuMore", + "checkBoxChecked", + "dropDown", + "smallCursorUp", + "smallCursorDown", + "radioButtonChecked", + "file", + "directory", + 0 + }; + + //! A skin modifies the look of the GUI elements. + class IGUISkin : public virtual io::IAttributeExchangingObject + { + public: + + //! destructor + ~IGUISkin() {}; + + //! returns default color + virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) = 0; + + //! sets a default color + virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) = 0; + + //! returns default color + virtual s32 getSize(EGUI_DEFAULT_SIZE size) = 0; + + //! Returns a default text. + /** For example for Message box button captions: + "OK", "Cancel", "Yes", "No" and so on. */ + virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text) = 0; + + //! Sets a default text. + /** For example for Message box button captions: + "OK", "Cancel", "Yes", "No" and so on. */ + virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText) = 0; + + //! sets a default size + virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size) = 0; + + //! returns the default font + virtual IGUIFont* getFont() = 0; + + //! sets a default font + virtual void setFont(IGUIFont* font) = 0; + + //! returns the sprite bank + virtual IGUISpriteBank* getSpriteBank() = 0; + + //! sets the sprite bank + virtual void setSpriteBank(IGUISpriteBank* bank) = 0; + + //! Returns a default icon + /** Returns the sprite index within the sprite bank */ + virtual u32 getIcon(EGUI_DEFAULT_ICON icon) = 0; + + //! Sets a default icon + /** Sets the sprite index used for drawing icons like arrows, + close buttons and ticks in checkboxes + \param icon: Enum specifying which icon to change + \param index: The sprite index used to draw this icon */ + virtual void setIcon(EGUI_DEFAULT_ICON icon, u32 index) = 0; + + //! draws a standard 3d button pane + /** Used for drawing for example buttons in normal state. + It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and + EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DButtonPaneStandard(IGUIElement* element, + const core::rect& rect, + const core::rect* clip=0) = 0; + + //! draws a pressed 3d button pane + /** Used for drawing for example buttons in pressed state. + It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and + EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DButtonPanePressed(IGUIElement* element, + const core::rect& rect, + const core::rect* clip=0) = 0; + + //! draws a sunken 3d pane + /** Used for drawing the background of edit, combo or check boxes. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param bgcolor: Background color. + \param flat: Specifies if the sunken pane should be flat or displayed as sunken + deep into the ground. + \param fillBackGround: Specifies if the background should be filled with the background + color or not be drawn at all. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DSunkenPane(IGUIElement* element, + video::SColor bgcolor, bool flat, bool fillBackGround, + const core::rect& rect, + const core::rect* clip=0) = 0; + + //! draws a window background + /** Used for drawing the background of dialogs and windows. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param titleBarColor: Title color. + \param drawTitleBar: True to enable title drawing. + \param rect: Defining area where to draw. + \param clip: Clip area. + \return Returns rect where it would be good to draw title bar text. */ + virtual core::rect draw3DWindowBackground(IGUIElement* element, + bool drawTitleBar, video::SColor titleBarColor, + const core::rect& rect, + const core::rect* clip=0) = 0; + + //! draws a standard 3d menu pane + /** Used for drawing for menus and context menus. + It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and + EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DMenuPane(IGUIElement* element, + const core::rect& rect, + const core::rect* clip=0) = 0; + + //! draws a standard 3d tool bar + /** Used for drawing for toolbars and menus. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DToolBar(IGUIElement* element, + const core::rect& rect, + const core::rect* clip=0) = 0; + + //! draws a tab button + /** Used for drawing for tab buttons on top of tabs. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param active: Specifies if the tab is currently active. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DTabButton(IGUIElement* element, bool active, + const core::rect& rect, const core::rect* clip=0) = 0; + + //! draws a tab control body + /** \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param border: Specifies if the border should be drawn. + \param background: Specifies if the background should be drawn. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DTabBody(IGUIElement* element, bool border, bool background, + const core::rect& rect, const core::rect* clip=0) = 0; + + //! draws an icon, usually from the skin's sprite bank + /** \param parent: Pointer to the element which wishes to draw this icon. + This parameter is usually not used by IGUISkin, but can be used for example + by more complex implementations to find out how to draw the part exactly. + \param icon: Specifies the icon to be drawn. + \param position: The position to draw the icon + \param starttime: The time at the start of the animation + \param currenttime: The present time, used to calculate the frame number + \param loop: Whether the animation should loop or not + \param clip: Clip area. */ + virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon, + const core::position2di position, u32 starttime=0, u32 currenttime=0, + bool loop=false, const core::rect* clip=0) = 0; + + //! get the type of this skin + virtual EGUI_SKIN_TYPE getType() { return EGST_UNKNOWN; }; + + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUISpriteBank.h b/src/dep/include/irrlicht/IGUISpriteBank.h index 0b74174..ed85ab1 100644 --- a/src/dep/include/irrlicht/IGUISpriteBank.h +++ b/src/dep/include/irrlicht/IGUISpriteBank.h @@ -1,73 +1,73 @@ - -#ifndef __I_GUI_SPRITE_BANK_H_INCLUDED__ -#define __I_GUI_SPRITE_BANK_H_INCLUDED__ - -#include "IUnknown.h" -#include "irrArray.h" -#include "SColor.h" -#include "rect.h" - -namespace irr -{ - -namespace video -{ - class ITexture; -} // end namespace video - -namespace gui -{ - -struct SGUISpriteFrame -{ - u32 textureNumber; - u32 rectNumber; -}; - -struct SGUISprite -{ - SGUISprite() : Frames(), frameTime(0) { }; - core::array Frames; - u32 frameTime; -}; - - -//! Sprite bank interface. -class IGUISpriteBank : public virtual IUnknown -{ -public: - - //! Destructor - virtual ~IGUISpriteBank() {}; - - //! Returns the list of rectangles held by the sprite bank - virtual core::array< core::rect >& getPositions() = 0; - - //! Returns the array of animated sprites within the sprite bank - virtual core::array< SGUISprite >& getSprites() = 0; - - //! Returns the number of textures held by the sprite bank - virtual u32 getTextureCount() = 0; - - //! Gets the texture with the specified index - virtual video::ITexture* getTexture(u32 index) = 0; - - //! Adds a texture to the sprite bank - virtual void addTexture(video::ITexture* texture) = 0; - - //! Changes one of the textures in the sprite bank - virtual void setTexture(u32 index, video::ITexture* texture) = 0; - - //! Draws a sprite in 2d with position and color - virtual void draw2DSprite(u32 index, const core::position2di& pos, const core::rect* clip=0, - const video::SColor& color= video::SColor(255,255,255,255), - u32 starttime=0, u32 currenttime=0, bool loop=true, bool center=false) = 0; - -}; - -} // end namespace gui -} // end namespace irr - -#endif // __I_GUI_SPRITE_BANK_H_INCLUDED__ - - + +#ifndef __I_GUI_SPRITE_BANK_H_INCLUDED__ +#define __I_GUI_SPRITE_BANK_H_INCLUDED__ + +#include "IUnknown.h" +#include "irrArray.h" +#include "SColor.h" +#include "rect.h" + +namespace irr +{ + +namespace video +{ + class ITexture; +} // end namespace video + +namespace gui +{ + +struct SGUISpriteFrame +{ + u32 textureNumber; + u32 rectNumber; +}; + +struct SGUISprite +{ + SGUISprite() : Frames(), frameTime(0) { }; + core::array Frames; + u32 frameTime; +}; + + +//! Sprite bank interface. +class IGUISpriteBank : public virtual IUnknown +{ +public: + + //! Destructor + virtual ~IGUISpriteBank() {}; + + //! Returns the list of rectangles held by the sprite bank + virtual core::array< core::rect >& getPositions() = 0; + + //! Returns the array of animated sprites within the sprite bank + virtual core::array< SGUISprite >& getSprites() = 0; + + //! Returns the number of textures held by the sprite bank + virtual u32 getTextureCount() = 0; + + //! Gets the texture with the specified index + virtual video::ITexture* getTexture(u32 index) = 0; + + //! Adds a texture to the sprite bank + virtual void addTexture(video::ITexture* texture) = 0; + + //! Changes one of the textures in the sprite bank + virtual void setTexture(u32 index, video::ITexture* texture) = 0; + + //! Draws a sprite in 2d with position and color + virtual void draw2DSprite(u32 index, const core::position2di& pos, const core::rect* clip=0, + const video::SColor& color= video::SColor(255,255,255,255), + u32 starttime=0, u32 currenttime=0, bool loop=true, bool center=false) = 0; + +}; + +} // end namespace gui +} // end namespace irr + +#endif // __I_GUI_SPRITE_BANK_H_INCLUDED__ + + diff --git a/src/dep/include/irrlicht/IGUIStaticText.h b/src/dep/include/irrlicht/IGUIStaticText.h index 372f71b..c987316 100644 --- a/src/dep/include/irrlicht/IGUIStaticText.h +++ b/src/dep/include/irrlicht/IGUIStaticText.h @@ -1,90 +1,90 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_STATIC_TEXT_H_INCLUDED__ -#define __I_GUI_STATIC_TEXT_H_INCLUDED__ - -#include "IGUIElement.h" -#include "SColor.h" - -namespace irr -{ -namespace gui -{ - class IGUIFont; - - //! Multi or single line text label. - class IGUIStaticText : public IGUIElement - { - public: - - //! constructor - IGUIStaticText(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_STATIC_TEXT, environment, parent, id, rectangle) {} - - //! destructor - ~IGUIStaticText() {}; - - //! Sets another skin independent font. - /** If this is set to zero, the button uses the font of the skin. - \param font: New font to set. */ - virtual void setOverrideFont(IGUIFont* font=0) = 0; - - //! Gets the override font (if any) - //! \return The override font (may be 0) - virtual IGUIFont * getOverrideFont(void) = 0; - - //! Sets another color for the text. - /** If set, the static text does not use the EGDC_BUTTON_TEXT color defined - in the skin, but the set color instead. You don't need to call - IGUIStaticText::enableOverrrideColor(true) after this, this is done - by this function. - If you set a color, and you want the text displayed with the color - of the skin again, call IGUIStaticText::enableOverrideColor(false); - \param color: New color of the text. */ - virtual void setOverrideColor(video::SColor color) = 0; - - //! Gets the override color - //! \return: The override color - virtual video::SColor const & getOverrideColor(void) = 0; - - //! Sets if the static text should use the overide color or the color in the gui skin. - /** \param enable: If set to true, the override color, which can be set - with IGUIStaticText::setOverrideColor is used, otherwise the - EGDC_BUTTON_TEXT color of the skin. */ - virtual void enableOverrideColor(bool enable) = 0; - - //! Checks if an override color is enabled - //! \return true if the override color is enabled, false otherwise - virtual bool isOverrideColorEnabled(void) = 0; - - //! Enables or disables word wrap for using the static text as multiline text control. - /** \param enable: If set to true, words going over one line are - breaked to the next line. */ - virtual void setWordWrap(bool enable) = 0; - - //! Checks if word wrap is enabled - //! \return true if word wrap is enabled, false otherwise - virtual bool isWordWrapEnabled(void) = 0; - - //! Returns the height of the text in pixels when it is drawn. - /** This is useful for adjusting the layout of gui elements based on the height - of the multiline text in this element. - \return Returns height of text in pixels. */ - virtual s32 getTextHeight() = 0; - - //! Returns the width of the current text, in the current font - /** If the text is broken, this returns the width of the widest line - \return The width of the text, or the widest broken line. */ - virtual s32 getTextWidth(void) = 0; - - }; - - -} // end namespace gui -} // end namespace irr - -#endif - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_STATIC_TEXT_H_INCLUDED__ +#define __I_GUI_STATIC_TEXT_H_INCLUDED__ + +#include "IGUIElement.h" +#include "SColor.h" + +namespace irr +{ +namespace gui +{ + class IGUIFont; + + //! Multi or single line text label. + class IGUIStaticText : public IGUIElement + { + public: + + //! constructor + IGUIStaticText(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_STATIC_TEXT, environment, parent, id, rectangle) {} + + //! destructor + ~IGUIStaticText() {}; + + //! Sets another skin independent font. + /** If this is set to zero, the button uses the font of the skin. + \param font: New font to set. */ + virtual void setOverrideFont(IGUIFont* font=0) = 0; + + //! Gets the override font (if any) + //! \return The override font (may be 0) + virtual IGUIFont * getOverrideFont(void) = 0; + + //! Sets another color for the text. + /** If set, the static text does not use the EGDC_BUTTON_TEXT color defined + in the skin, but the set color instead. You don't need to call + IGUIStaticText::enableOverrrideColor(true) after this, this is done + by this function. + If you set a color, and you want the text displayed with the color + of the skin again, call IGUIStaticText::enableOverrideColor(false); + \param color: New color of the text. */ + virtual void setOverrideColor(video::SColor color) = 0; + + //! Gets the override color + //! \return: The override color + virtual video::SColor const & getOverrideColor(void) = 0; + + //! Sets if the static text should use the overide color or the color in the gui skin. + /** \param enable: If set to true, the override color, which can be set + with IGUIStaticText::setOverrideColor is used, otherwise the + EGDC_BUTTON_TEXT color of the skin. */ + virtual void enableOverrideColor(bool enable) = 0; + + //! Checks if an override color is enabled + //! \return true if the override color is enabled, false otherwise + virtual bool isOverrideColorEnabled(void) = 0; + + //! Enables or disables word wrap for using the static text as multiline text control. + /** \param enable: If set to true, words going over one line are + breaked to the next line. */ + virtual void setWordWrap(bool enable) = 0; + + //! Checks if word wrap is enabled + //! \return true if word wrap is enabled, false otherwise + virtual bool isWordWrapEnabled(void) = 0; + + //! Returns the height of the text in pixels when it is drawn. + /** This is useful for adjusting the layout of gui elements based on the height + of the multiline text in this element. + \return Returns height of text in pixels. */ + virtual s32 getTextHeight() = 0; + + //! Returns the width of the current text, in the current font + /** If the text is broken, this returns the width of the widest line + \return The width of the text, or the widest broken line. */ + virtual s32 getTextWidth(void) = 0; + + }; + + +} // end namespace gui +} // end namespace irr + +#endif + + diff --git a/src/dep/include/irrlicht/IGUITabControl.h b/src/dep/include/irrlicht/IGUITabControl.h index 1940c4c..29d1a96 100644 --- a/src/dep/include/irrlicht/IGUITabControl.h +++ b/src/dep/include/irrlicht/IGUITabControl.h @@ -1,81 +1,81 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_TAB_CONTROL_H_INCLUDED__ -#define __I_GUI_TAB_CONTROL_H_INCLUDED__ - -#include "IGUIElement.h" -#include "SColor.h" - -namespace irr -{ -namespace gui -{ - //! A tab, onto which other gui elements could be added. - class IGUITab : public IGUIElement - { - public: - - //! constructor - IGUITab(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_TAB, environment, parent, id, rectangle) {} - - //! destructor - virtual ~IGUITab() {}; - - //! Returns number of tab if in tabcontrol. - /** Can be accessed later IGUITabControl::getTab() by this number. */ - virtual s32 getNumber() = 0; - - //! sets if the tab should draw its background - virtual void setDrawBackground(bool draw=true) = 0; - - //! sets the color of the background, if it should be drawn. - virtual void setBackgroundColor(video::SColor c) = 0; - }; - - //! A standard tab control - class IGUITabControl : public IGUIElement - { - public: - - //! constructor - IGUITabControl(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_TAB_CONTROL, environment, parent, id, rectangle) {} - - //! destructor - virtual ~IGUITabControl() {}; - - //! Adds a tab - virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1) = 0; - - //! Returns amount of tabs in the tabcontrol - virtual s32 getTabcount() = 0; - - //! Returns a tab based on zero based index - /** \param idx: zero based index of tab. Is a value betwenn 0 and getTabcount()-1; - \return Returns pointer to the Tab. Returns 0 if no tab - is corresponding to this tab. */ - virtual IGUITab* getTab(s32 idx) = 0; - - //! Brings a tab to front. - /** \param idx: number of the tab. - \return Returns true if successful. */ - virtual bool setActiveTab(s32 idx) = 0; - - //! Brings a tab to front. - /** \param idx: pointer to the tab. - \return Returns true if successful. */ - virtual bool setActiveTab(IGUIElement *tab) = 0; - - //! Returns which tab is currently active - virtual s32 getActiveTab() = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_TAB_CONTROL_H_INCLUDED__ +#define __I_GUI_TAB_CONTROL_H_INCLUDED__ + +#include "IGUIElement.h" +#include "SColor.h" + +namespace irr +{ +namespace gui +{ + //! A tab, onto which other gui elements could be added. + class IGUITab : public IGUIElement + { + public: + + //! constructor + IGUITab(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_TAB, environment, parent, id, rectangle) {} + + //! destructor + virtual ~IGUITab() {}; + + //! Returns number of tab if in tabcontrol. + /** Can be accessed later IGUITabControl::getTab() by this number. */ + virtual s32 getNumber() = 0; + + //! sets if the tab should draw its background + virtual void setDrawBackground(bool draw=true) = 0; + + //! sets the color of the background, if it should be drawn. + virtual void setBackgroundColor(video::SColor c) = 0; + }; + + //! A standard tab control + class IGUITabControl : public IGUIElement + { + public: + + //! constructor + IGUITabControl(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_TAB_CONTROL, environment, parent, id, rectangle) {} + + //! destructor + virtual ~IGUITabControl() {}; + + //! Adds a tab + virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1) = 0; + + //! Returns amount of tabs in the tabcontrol + virtual s32 getTabcount() = 0; + + //! Returns a tab based on zero based index + /** \param idx: zero based index of tab. Is a value betwenn 0 and getTabcount()-1; + \return Returns pointer to the Tab. Returns 0 if no tab + is corresponding to this tab. */ + virtual IGUITab* getTab(s32 idx) = 0; + + //! Brings a tab to front. + /** \param idx: number of the tab. + \return Returns true if successful. */ + virtual bool setActiveTab(s32 idx) = 0; + + //! Brings a tab to front. + /** \param idx: pointer to the tab. + \return Returns true if successful. */ + virtual bool setActiveTab(IGUIElement *tab) = 0; + + //! Returns which tab is currently active + virtual s32 getActiveTab() = 0; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIToolbar.h b/src/dep/include/irrlicht/IGUIToolbar.h index 016669a..a8eb955 100644 --- a/src/dep/include/irrlicht/IGUIToolbar.h +++ b/src/dep/include/irrlicht/IGUIToolbar.h @@ -1,43 +1,43 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_TOOL_BAR_H_INCLUDED__ -#define __I_GUI_TOOL_BAR_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace video -{ - class ITexture; -} // end namespace video -namespace gui -{ - class IGUIButton; - - //! Stays at the top of its parent like the menu bar and contains tool buttons - class IGUIToolBar : public IGUIElement - { - public: - - //! constructor - IGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_TOOL_BAR, environment, parent, id, rectangle) {} - - //! destructor - ~IGUIToolBar() {}; - - //! Adds a button to the tool bar - virtual IGUIButton* addButton(s32 id=-1, const wchar_t* text=0,const wchar_t* tooltiptext=0, - video::ITexture* img=0, video::ITexture* pressedimg=0, - bool isPushButton=false, bool useAlphaChannel=false) = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_TOOL_BAR_H_INCLUDED__ +#define __I_GUI_TOOL_BAR_H_INCLUDED__ + +#include "IGUIElement.h" + +namespace irr +{ +namespace video +{ + class ITexture; +} // end namespace video +namespace gui +{ + class IGUIButton; + + //! Stays at the top of its parent like the menu bar and contains tool buttons + class IGUIToolBar : public IGUIElement + { + public: + + //! constructor + IGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_TOOL_BAR, environment, parent, id, rectangle) {} + + //! destructor + ~IGUIToolBar() {}; + + //! Adds a button to the tool bar + virtual IGUIButton* addButton(s32 id=-1, const wchar_t* text=0,const wchar_t* tooltiptext=0, + video::ITexture* img=0, video::ITexture* pressedimg=0, + bool isPushButton=false, bool useAlphaChannel=false) = 0; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IGUIWindow.h b/src/dep/include/irrlicht/IGUIWindow.h index 326a66b..5fd0b11 100644 --- a/src/dep/include/irrlicht/IGUIWindow.h +++ b/src/dep/include/irrlicht/IGUIWindow.h @@ -1,60 +1,60 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_WINDOW_H_INCLUDED__ -#define __I_GUI_WINDOW_H_INCLUDED__ - -#include "IGUIButton.h" - -namespace irr -{ -namespace gui -{ - //! enumeration for message box layout flags - enum EMESSAGE_BOX_FLAG - { - //! Flag for the ok button - EMBF_OK = 0x1, - - //! Flag for the cancel button - EMBF_CANCEL = 0x2, - - //! Flag for the yes button - EMBF_YES = 0x4, - - //! Flag for the no button - EMBF_NO = 0x8, - - //! This value is not used. It only forces this enumeration to compile in 32 bit. - EMBF_FORCE_32BIT = 0x7fffffff - }; - - //! Default moveable window GUI element with border, caption and close icons. - class IGUIWindow : public IGUIElement - { - public: - - //! constructor - IGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) - : IGUIElement(EGUIET_WINDOW, environment, parent, id, rectangle) {} - - //! destructor - virtual ~IGUIWindow() {}; - - //! Returns pointer to the close button - virtual IGUIButton* getCloseButton() = 0; - - //! Returns pointer to the minimize button - virtual IGUIButton* getMinimizeButton() = 0; - - //! Returns pointer to the maximize button - virtual IGUIButton* getMaximizeButton() = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_GUI_WINDOW_H_INCLUDED__ +#define __I_GUI_WINDOW_H_INCLUDED__ + +#include "IGUIButton.h" + +namespace irr +{ +namespace gui +{ + //! enumeration for message box layout flags + enum EMESSAGE_BOX_FLAG + { + //! Flag for the ok button + EMBF_OK = 0x1, + + //! Flag for the cancel button + EMBF_CANCEL = 0x2, + + //! Flag for the yes button + EMBF_YES = 0x4, + + //! Flag for the no button + EMBF_NO = 0x8, + + //! This value is not used. It only forces this enumeration to compile in 32 bit. + EMBF_FORCE_32BIT = 0x7fffffff + }; + + //! Default moveable window GUI element with border, caption and close icons. + class IGUIWindow : public IGUIElement + { + public: + + //! constructor + IGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_WINDOW, environment, parent, id, rectangle) {} + + //! destructor + virtual ~IGUIWindow() {}; + + //! Returns pointer to the close button + virtual IGUIButton* getCloseButton() = 0; + + //! Returns pointer to the minimize button + virtual IGUIButton* getMinimizeButton() = 0; + + //! Returns pointer to the maximize button + virtual IGUIButton* getMaximizeButton() = 0; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IImage.h b/src/dep/include/irrlicht/IImage.h index 639f67f..68bfc64 100644 --- a/src/dep/include/irrlicht/IImage.h +++ b/src/dep/include/irrlicht/IImage.h @@ -1,104 +1,104 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_IMAGE_H_INCLUDED__ -#define __I_IMAGE_H_INCLUDED__ - -#include "IUnknown.h" -#include "position2d.h" -#include "SColor.h" - -namespace irr -{ -namespace video -{ - -//! An enum for the color format of textures used by the Irrlicht Engine. -/** A color format specifies how color information is stored. */ -enum ECOLOR_FORMAT -{ - //! 16 bit color format used by the software driver, and thus preferred - //! by all other irrlicht engine video drivers. There are 5 bits for every - //! color component, and a single bit is left for alpha information. - ECF_A1R5G5B5 = 0, - - //! Standard 16 bit color format. - ECF_R5G6B5, - - //! 24 bit color, no alpha channel, but 8 bit for red, green and blue. - ECF_R8G8B8, - - //! Default 32 bit color format. 8 bits are used for every component: - //! red, green, blue and alpha. - ECF_A8R8G8B8 -}; - - -//! Interface for software image data. -/** Image loaders create these images from files. IVideoDrivers convert -these images into their (hardware) textures. -*/ -class IImage : public virtual IUnknown -{ -public: - - //! destructor - virtual ~IImage() {}; - - //! Lock function. Use this to get a pointer to the image data. After you - //! don't need the pointer anymore, you must call unlock(). - //! \return Returns pointer to the image data. What type of data - //! is pointed to depends on the color format of the image. For example - //! if the color format is ECF_A8R8G8B8, it is of s32. - //! Be sure to call unlock() after you don't need the pointer any more. - virtual void* lock() = 0; - - //! Unlock function. - //! Should be called after the pointer received by lock() is not - //! needed anymore. - virtual void unlock() = 0; - - //! Returns width and height of image data. - virtual const core::dimension2d& getDimension() = 0; - - //! Returns bits per pixel. - virtual s32 getBitsPerPixel() = 0; - - //! Returns bytes per pixel - virtual s32 getBytesPerPixel() = 0; - - //! Returns image data size in bytes - virtual s32 getImageDataSizeInBytes() = 0; - - //! Returns image data size in pixels - virtual s32 getImageDataSizeInPixels() = 0; - - //! returns a pixel - virtual SColor getPixel(s32 x, s32 y) = 0; - - //! returns the color format - virtual ECOLOR_FORMAT getColorFormat() const = 0; - - //! returns mask for red value of a pixel - virtual u32 getRedMask() = 0; - - //! returns mask for green value of a pixel - virtual u32 getGreenMask() = 0; - - //! returns mask for blue value of a pixel - virtual u32 getBlueMask() = 0; - - //! returns mask for alpha value of a pixel - virtual u32 getAlphaMask() = 0; - - //! returns pitch of image - virtual u32 getPitch() const = 0; - -}; - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_IMAGE_H_INCLUDED__ +#define __I_IMAGE_H_INCLUDED__ + +#include "IUnknown.h" +#include "position2d.h" +#include "SColor.h" + +namespace irr +{ +namespace video +{ + +//! An enum for the color format of textures used by the Irrlicht Engine. +/** A color format specifies how color information is stored. */ +enum ECOLOR_FORMAT +{ + //! 16 bit color format used by the software driver, and thus preferred + //! by all other irrlicht engine video drivers. There are 5 bits for every + //! color component, and a single bit is left for alpha information. + ECF_A1R5G5B5 = 0, + + //! Standard 16 bit color format. + ECF_R5G6B5, + + //! 24 bit color, no alpha channel, but 8 bit for red, green and blue. + ECF_R8G8B8, + + //! Default 32 bit color format. 8 bits are used for every component: + //! red, green, blue and alpha. + ECF_A8R8G8B8 +}; + + +//! Interface for software image data. +/** Image loaders create these images from files. IVideoDrivers convert +these images into their (hardware) textures. +*/ +class IImage : public virtual IUnknown +{ +public: + + //! destructor + virtual ~IImage() {}; + + //! Lock function. Use this to get a pointer to the image data. After you + //! don't need the pointer anymore, you must call unlock(). + //! \return Returns pointer to the image data. What type of data + //! is pointed to depends on the color format of the image. For example + //! if the color format is ECF_A8R8G8B8, it is of s32. + //! Be sure to call unlock() after you don't need the pointer any more. + virtual void* lock() = 0; + + //! Unlock function. + //! Should be called after the pointer received by lock() is not + //! needed anymore. + virtual void unlock() = 0; + + //! Returns width and height of image data. + virtual const core::dimension2d& getDimension() = 0; + + //! Returns bits per pixel. + virtual s32 getBitsPerPixel() = 0; + + //! Returns bytes per pixel + virtual s32 getBytesPerPixel() = 0; + + //! Returns image data size in bytes + virtual s32 getImageDataSizeInBytes() = 0; + + //! Returns image data size in pixels + virtual s32 getImageDataSizeInPixels() = 0; + + //! returns a pixel + virtual SColor getPixel(s32 x, s32 y) = 0; + + //! returns the color format + virtual ECOLOR_FORMAT getColorFormat() const = 0; + + //! returns mask for red value of a pixel + virtual u32 getRedMask() = 0; + + //! returns mask for green value of a pixel + virtual u32 getGreenMask() = 0; + + //! returns mask for blue value of a pixel + virtual u32 getBlueMask() = 0; + + //! returns mask for alpha value of a pixel + virtual u32 getAlphaMask() = 0; + + //! returns pitch of image + virtual u32 getPitch() const = 0; + +}; + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IImageLoader.h b/src/dep/include/irrlicht/IImageLoader.h index 0916c60..0f74498 100644 --- a/src/dep/include/irrlicht/IImageLoader.h +++ b/src/dep/include/irrlicht/IImageLoader.h @@ -1,45 +1,45 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SURFACE_LOADER_H_INCLUDED__ -#define __I_SURFACE_LOADER_H_INCLUDED__ - -#include "IUnknown.h" -#include "IReadFile.h" -#include "IImage.h" - -namespace irr -{ -namespace video -{ - -//! Class which is able to create a image from a file. -/** If you want the Irrlicht Engine be able to load textures of -currently unsupported file formats (e.g .gif), then implement -this and add your new Surface loader with -IVideoDriver::addExternalImageLoader() to the engine. */ -class IImageLoader : public virtual IUnknown -{ -public: - - //! destructor - virtual ~IImageLoader() {}; - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".tga") - virtual bool isALoadableFileExtension(const c8* fileName) = 0; - - //! returns true if the file maybe is able to be loaded by this class - virtual bool isALoadableFileFormat(irr::io::IReadFile* file) = 0; - - //! creates a surface from the file - virtual IImage* loadImage(irr::io::IReadFile* file) = 0; -}; - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_SURFACE_LOADER_H_INCLUDED__ +#define __I_SURFACE_LOADER_H_INCLUDED__ + +#include "IUnknown.h" +#include "IReadFile.h" +#include "IImage.h" + +namespace irr +{ +namespace video +{ + +//! Class which is able to create a image from a file. +/** If you want the Irrlicht Engine be able to load textures of +currently unsupported file formats (e.g .gif), then implement +this and add your new Surface loader with +IVideoDriver::addExternalImageLoader() to the engine. */ +class IImageLoader : public virtual IUnknown +{ +public: + + //! destructor + virtual ~IImageLoader() {}; + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".tga") + virtual bool isALoadableFileExtension(const c8* fileName) = 0; + + //! returns true if the file maybe is able to be loaded by this class + virtual bool isALoadableFileFormat(irr::io::IReadFile* file) = 0; + + //! creates a surface from the file + virtual IImage* loadImage(irr::io::IReadFile* file) = 0; +}; + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IImageWriter.h b/src/dep/include/irrlicht/IImageWriter.h index 35b325d..e986437 100644 --- a/src/dep/include/irrlicht/IImageWriter.h +++ b/src/dep/include/irrlicht/IImageWriter.h @@ -1,43 +1,43 @@ -#ifndef _I_IMAGE_WRITER_H_INCLUDED__ -#define _I_IMAGE_WRITER_H_INCLUDED__ - -#include "irrTypes.h" -#include "IUnknown.h" - -namespace irr -{ -namespace io -{ - class IWriteFile; -} // end namespace io - -namespace video -{ - class IImage; - - -//! Interface for writing software image data. -class IImageWriter : public IUnknown -{ -public: - //! constructor - IImageWriter() - { - } - - //! destructor - virtual ~IImageWriter() - { - }; - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const c8* fileName) = 0; - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param = 0) = 0; -}; - -} // namespace video -} // namespace irr - -#endif // _I_IMAGE_WRITER_H_INCLUDED__ +#ifndef _I_IMAGE_WRITER_H_INCLUDED__ +#define _I_IMAGE_WRITER_H_INCLUDED__ + +#include "irrTypes.h" +#include "IUnknown.h" + +namespace irr +{ +namespace io +{ + class IWriteFile; +} // end namespace io + +namespace video +{ + class IImage; + + +//! Interface for writing software image data. +class IImageWriter : public IUnknown +{ +public: + //! constructor + IImageWriter() + { + } + + //! destructor + virtual ~IImageWriter() + { + }; + + //! return true if this writer can write a file with the given extension + virtual bool isAWriteableFileExtension(const c8* fileName) = 0; + + //! write image to file + virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param = 0) = 0; +}; + +} // namespace video +} // namespace irr + +#endif // _I_IMAGE_WRITER_H_INCLUDED__ diff --git a/src/dep/include/irrlicht/ILightSceneNode.h b/src/dep/include/irrlicht/ILightSceneNode.h index fb2297e..fde5a5c 100644 --- a/src/dep/include/irrlicht/ILightSceneNode.h +++ b/src/dep/include/irrlicht/ILightSceneNode.h @@ -1,46 +1,46 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_LIGHT_SCENE_NODE_H_INCLUDED__ -#define __I_LIGHT_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "SLight.h" - -namespace irr -{ -namespace scene -{ - -//! Scene node which is a dynamic light. -/** You can switch the light on and off by -making it visible or not, and let it be animated by ordinary scene node animators. -If you set the light type to be directional, you will need to set the direction of the -light source manually in the SLight structure, the position of the scene node will have no -effect on this direction. -*/ -class ILightSceneNode : public ISceneNode -{ -public: - - //! constructor - ILightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0)) - : ISceneNode(parent, mgr, id, position) {} - - //! Sets the light data associated with this ILightSceneNode - virtual void setLightData(const video::SLight& light) = 0; - - //! Gets the light data associated with this ILightSceneNode - //! \return Returns the light data. - virtual video::SLight& getLightData() = 0; - -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_LIGHT_SCENE_NODE_H_INCLUDED__ +#define __I_LIGHT_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" +#include "SLight.h" + +namespace irr +{ +namespace scene +{ + +//! Scene node which is a dynamic light. +/** You can switch the light on and off by +making it visible or not, and let it be animated by ordinary scene node animators. +If you set the light type to be directional, you will need to set the direction of the +light source manually in the SLight structure, the position of the scene node will have no +effect on this direction. +*/ +class ILightSceneNode : public ISceneNode +{ +public: + + //! constructor + ILightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position = core::vector3df(0,0,0)) + : ISceneNode(parent, mgr, id, position) {} + + //! Sets the light data associated with this ILightSceneNode + virtual void setLightData(const video::SLight& light) = 0; + + //! Gets the light data associated with this ILightSceneNode + //! \return Returns the light data. + virtual video::SLight& getLightData() = 0; + +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/ILogger.h b/src/dep/include/irrlicht/ILogger.h index 8a160be..dec9140 100644 --- a/src/dep/include/irrlicht/ILogger.h +++ b/src/dep/include/irrlicht/ILogger.h @@ -1,95 +1,95 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_LOGGER_H_INCLUDED__ -#define __I_LOGGER_H_INCLUDED__ - -#include "IUnknown.h" - -namespace irr -{ - -enum ELOG_LEVEL -{ - //! High log level, warnings, errors and important information - //! texts are printed out. - ELL_INFORMATION = 0, - - //! Default log level, warnings and errors are printed out - ELL_WARNING, - - //! Low log level, only errors are printed into the log - ELL_ERROR, - - //! Nothing is printed out to the log - ELL_NONE -}; - - -//! Interface for logging messages, warnings and errors -class ILogger : public virtual IUnknown -{ -public: - - //! destructor - virtual ~ILogger() {} - - //! Returns the current set log level. - virtual ELOG_LEVEL getLogLevel() = 0; - - //! Sets a new log level. With this value, texts which are sent to - //! the logger are filtered out. For example setting this value to - //! ELL_WARNING, only warnings and - //! errors are printed out. Setting it to ELL_INFORMATION, which is - //! the default setting, warnings, - //! errors and informational texts are printed out. - //! \param ll: new log level filter value. - virtual void setLogLevel(ELOG_LEVEL ll) = 0; - - //! Prints out a text into the log - //! \param text: Text to print out. - //! \param ll: Log level of the text. If the text is an error, set - //! it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it - //! is just an informational text, set it to ELL_INFORMATION. Texts are - //! filtered with these levels. If you want to be a text displayed, - //! independent on what level filter is set, use ELL_NONE. - virtual void log(const c8* text, ELOG_LEVEL ll=ELL_INFORMATION) = 0; - - //! Prints out a text into the log - //! \param text: Text to print out. - //! \param hint: Additional info. This string is added after a " :" to the - //! string. - //! \param ll: Log level of the text. If the text is an error, set - //! it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it - //! is just an informational text, set it to ELL_INFORMATION. Texts are - //! filtered with these levels. If you want to be a text displayed, - //! independent on what level filter is set, use ELL_NONE. - virtual void log(const c8* text, const c8* hint, ELOG_LEVEL ll=ELL_INFORMATION) = 0; - - //! Prints out a text into the log - //! \param text: Text to print out. - //! \param hint: Additional info. This string is added after a " :" to the - //! string. - //! \param ll: Log level of the text. If the text is an error, set - //! it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it - //! is just an informational text, set it to ELL_INFORMATION. Texts are - //! filtered with these levels. If you want to be a text displayed, - //! independent on what level filter is set, use ELL_NONE. - virtual void log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION) = 0; - - - //! Prints out a text into the log - //! \param text: Text to print out. - //! \param ll: Log level of the text. If the text is an error, set - //! it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it - //! is just an informational text, set it to ELL_INFORMATION. Texts are - //! filtered with these levels. If you want to be a text displayed, - //! independent on what level filter is set, use ELL_NONE. - virtual void log(const wchar_t* text, ELOG_LEVEL ll=ELL_INFORMATION) = 0; -}; - -} // end namespace - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_LOGGER_H_INCLUDED__ +#define __I_LOGGER_H_INCLUDED__ + +#include "IUnknown.h" + +namespace irr +{ + +enum ELOG_LEVEL +{ + //! High log level, warnings, errors and important information + //! texts are printed out. + ELL_INFORMATION = 0, + + //! Default log level, warnings and errors are printed out + ELL_WARNING, + + //! Low log level, only errors are printed into the log + ELL_ERROR, + + //! Nothing is printed out to the log + ELL_NONE +}; + + +//! Interface for logging messages, warnings and errors +class ILogger : public virtual IUnknown +{ +public: + + //! destructor + virtual ~ILogger() {} + + //! Returns the current set log level. + virtual ELOG_LEVEL getLogLevel() = 0; + + //! Sets a new log level. With this value, texts which are sent to + //! the logger are filtered out. For example setting this value to + //! ELL_WARNING, only warnings and + //! errors are printed out. Setting it to ELL_INFORMATION, which is + //! the default setting, warnings, + //! errors and informational texts are printed out. + //! \param ll: new log level filter value. + virtual void setLogLevel(ELOG_LEVEL ll) = 0; + + //! Prints out a text into the log + //! \param text: Text to print out. + //! \param ll: Log level of the text. If the text is an error, set + //! it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it + //! is just an informational text, set it to ELL_INFORMATION. Texts are + //! filtered with these levels. If you want to be a text displayed, + //! independent on what level filter is set, use ELL_NONE. + virtual void log(const c8* text, ELOG_LEVEL ll=ELL_INFORMATION) = 0; + + //! Prints out a text into the log + //! \param text: Text to print out. + //! \param hint: Additional info. This string is added after a " :" to the + //! string. + //! \param ll: Log level of the text. If the text is an error, set + //! it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it + //! is just an informational text, set it to ELL_INFORMATION. Texts are + //! filtered with these levels. If you want to be a text displayed, + //! independent on what level filter is set, use ELL_NONE. + virtual void log(const c8* text, const c8* hint, ELOG_LEVEL ll=ELL_INFORMATION) = 0; + + //! Prints out a text into the log + //! \param text: Text to print out. + //! \param hint: Additional info. This string is added after a " :" to the + //! string. + //! \param ll: Log level of the text. If the text is an error, set + //! it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it + //! is just an informational text, set it to ELL_INFORMATION. Texts are + //! filtered with these levels. If you want to be a text displayed, + //! independent on what level filter is set, use ELL_NONE. + virtual void log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION) = 0; + + + //! Prints out a text into the log + //! \param text: Text to print out. + //! \param ll: Log level of the text. If the text is an error, set + //! it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it + //! is just an informational text, set it to ELL_INFORMATION. Texts are + //! filtered with these levels. If you want to be a text displayed, + //! independent on what level filter is set, use ELL_NONE. + virtual void log(const wchar_t* text, ELOG_LEVEL ll=ELL_INFORMATION) = 0; +}; + +} // end namespace + +#endif + diff --git a/src/dep/include/irrlicht/IMaterialRenderer.h b/src/dep/include/irrlicht/IMaterialRenderer.h index 089bde1..7e9c82a 100644 --- a/src/dep/include/irrlicht/IMaterialRenderer.h +++ b/src/dep/include/irrlicht/IMaterialRenderer.h @@ -1,97 +1,97 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MATERIAL_RENDERER_H_INCLUDED__ -#define __I_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IUnknown.h" -#include "SMaterial.h" -#include "S3DVertex.h" - -namespace irr -{ -namespace video -{ - -class IVideoDriver; -class IMaterialRendererServices; - -//! Interface for material rendering. Can be used to extend the engine with new materials. -/** Refer to IVideoDriver::addMaterialRenderer() for more informations on how to extend the engine - with new materials. -*/ -class IMaterialRenderer : public virtual IUnknown -{ -public: - - //! destructor - virtual ~IMaterialRenderer() {}; - - //! Called by the IVideoDriver implementation the let the renderer set its needed render states. - /** This is called during the IVideoDriver::setMaterial() call. - When overriding this, you can set some renderstates or for example a vertex or pixel shader - if you like. - \param material: The new material parameters to be set. The renderer may change the material - flags in this material. For example if this material does not accept the zbuffer = true, it - can set it to false. This is useful, because in the next lastMaterial will be just the material - in this call. - \param lastMaterial: The material parameters which have been set before this material. - \param resetAllRenderstates: True if all renderstates should really be reset. This is usually - true if the last rendering mode was not a usual 3d rendering mode, but for example - a 2d rendering mode. - You should reset really all renderstates if this is true, no matter if the lastMaterial had - some similar settings. This is used because in most cases, some common renderstates are not - changed if they are already there, for example bilinear filtering, wireframe, gouraudshading, - lighting, zbuffer, zwriteenable, backfaceculling and fogenable. - \param services: Interface providing some methods for changing advanced, internal - states of a IVideoDriver. */ - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) {}; - - //! Called every time before a new bunch of geometry is being drawn using this material with - //! for example drawIndexedTriangleList() call. - /** OnSetMaterial should normally only be called if the renderer decides that the renderstates should be changed, it won't be called if for - example two drawIndexedTriangleList() will be called with the same material set. This - method will be called every time. This is useful for example for materials with shaders, - which don't only set new renderstates but also shader constants. - \param service: Pointer to interface providing methos for setting constants and other things. - \param vtxtype: Vertex type with which the next rendering will be done. This can be used - by the material renderer to set some specific optimized shaders or if this is an incompatible - vertex type for this renderer, to refuse rendering for example. - \return Returns true if everything is ok, and false if nothing should be rendered. - The material renderer can choose to return false for example if he doesn't support the - specified vertex type. This is actually done in D3D8 and D3D9 when using a - normal mapped material with a vertex type other than EVT_TANGENTS. */ - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) { return true; }; - - //! Called by the IVideoDriver to unset this material. - /** Called during the - IVideoDriver::setMaterial() call before the new material will get the OnSetMaterial() - call. */ - virtual void OnUnsetMaterial() {}; - - //! Returns if the material is transparent. - /** The scene managment needs to know this - for being able to sort the materials by opaque and transparent. */ - virtual bool isTransparent() { return false; } - - //! Returns the render capability of the material. - /** Because some more complex materials - are implemented in multiple ways and need special hardware capabilities, it is possible - to query how the current material renderer is performing on the current hardware with this - function. - \return Returns 0 if everything is running fine. Any other value is material renderer - specific and means for example that the renderer switched back to a fall back material because - it cannot use the latest shaders. More specific examples: - Fixed function pipeline materials should return 0 in most cases, parallax mapped - material will only return 0 when at least pixel shader 1.4 is available on that machine. */ - virtual s32 getRenderCapability() { return 0; } -}; - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_MATERIAL_RENDERER_H_INCLUDED__ +#define __I_MATERIAL_RENDERER_H_INCLUDED__ + +#include "IUnknown.h" +#include "SMaterial.h" +#include "S3DVertex.h" + +namespace irr +{ +namespace video +{ + +class IVideoDriver; +class IMaterialRendererServices; + +//! Interface for material rendering. Can be used to extend the engine with new materials. +/** Refer to IVideoDriver::addMaterialRenderer() for more informations on how to extend the engine + with new materials. +*/ +class IMaterialRenderer : public virtual IUnknown +{ +public: + + //! destructor + virtual ~IMaterialRenderer() {}; + + //! Called by the IVideoDriver implementation the let the renderer set its needed render states. + /** This is called during the IVideoDriver::setMaterial() call. + When overriding this, you can set some renderstates or for example a vertex or pixel shader + if you like. + \param material: The new material parameters to be set. The renderer may change the material + flags in this material. For example if this material does not accept the zbuffer = true, it + can set it to false. This is useful, because in the next lastMaterial will be just the material + in this call. + \param lastMaterial: The material parameters which have been set before this material. + \param resetAllRenderstates: True if all renderstates should really be reset. This is usually + true if the last rendering mode was not a usual 3d rendering mode, but for example + a 2d rendering mode. + You should reset really all renderstates if this is true, no matter if the lastMaterial had + some similar settings. This is used because in most cases, some common renderstates are not + changed if they are already there, for example bilinear filtering, wireframe, gouraudshading, + lighting, zbuffer, zwriteenable, backfaceculling and fogenable. + \param services: Interface providing some methods for changing advanced, internal + states of a IVideoDriver. */ + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) {}; + + //! Called every time before a new bunch of geometry is being drawn using this material with + //! for example drawIndexedTriangleList() call. + /** OnSetMaterial should normally only be called if the renderer decides that the renderstates should be changed, it won't be called if for + example two drawIndexedTriangleList() will be called with the same material set. This + method will be called every time. This is useful for example for materials with shaders, + which don't only set new renderstates but also shader constants. + \param service: Pointer to interface providing methos for setting constants and other things. + \param vtxtype: Vertex type with which the next rendering will be done. This can be used + by the material renderer to set some specific optimized shaders or if this is an incompatible + vertex type for this renderer, to refuse rendering for example. + \return Returns true if everything is ok, and false if nothing should be rendered. + The material renderer can choose to return false for example if he doesn't support the + specified vertex type. This is actually done in D3D8 and D3D9 when using a + normal mapped material with a vertex type other than EVT_TANGENTS. */ + virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) { return true; }; + + //! Called by the IVideoDriver to unset this material. + /** Called during the + IVideoDriver::setMaterial() call before the new material will get the OnSetMaterial() + call. */ + virtual void OnUnsetMaterial() {}; + + //! Returns if the material is transparent. + /** The scene managment needs to know this + for being able to sort the materials by opaque and transparent. */ + virtual bool isTransparent() { return false; } + + //! Returns the render capability of the material. + /** Because some more complex materials + are implemented in multiple ways and need special hardware capabilities, it is possible + to query how the current material renderer is performing on the current hardware with this + function. + \return Returns 0 if everything is running fine. Any other value is material renderer + specific and means for example that the renderer switched back to a fall back material because + it cannot use the latest shaders. More specific examples: + Fixed function pipeline materials should return 0 in most cases, parallax mapped + material will only return 0 when at least pixel shader 1.4 is available on that machine. */ + virtual s32 getRenderCapability() { return 0; } +}; + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IMaterialRendererServices.h b/src/dep/include/irrlicht/IMaterialRendererServices.h index c9f8162..d49b8c7 100644 --- a/src/dep/include/irrlicht/IMaterialRendererServices.h +++ b/src/dep/include/irrlicht/IMaterialRendererServices.h @@ -1,93 +1,93 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MATERIAL_RENDERER_SERVICES_H_INCLUDED__ -#define __I_MATERIAL_RENDERER_SERVICES_H_INCLUDED__ - -#include "IUnknown.h" -#include "SMaterial.h" -#include "S3DVertex.h" - -namespace irr -{ -namespace video -{ - -class IVideoDriver; - - -//! Interface providing some methods for changing advanced, internal states of a IVideoDriver. -class IMaterialRendererServices -{ -public: - - //! destructor - virtual ~IMaterialRendererServices() {} - - //! Can be called by an IMaterialRenderer to make its work easier. - //! Sets all basic renderstates if needed. - //! Basic render states are diffuse, ambient, specular, and emissive color, specular power, - //! bilinear and trilinear filtering, wireframe mode, - //! grouraudshading, lighting, zbuffer, zwriteenable, backfaceculling and fog enabling. - virtual void setBasicRenderStates(const SMaterial& material, - const SMaterial& lastMaterial, - bool resetAllRenderstates) = 0; - - //! Sets a constant for the vertex shader based on a name. This can be used if you used - //! a high level shader language like GLSL or HLSL to create a shader. Example: If you - //! created a shader which has variables named 'mWorldViewProj' (containing the - //! WorldViewProjection matrix) and another one named 'fTime' containing one float, - //! you can set them in your IShaderConstantSetCallBack derived class like this: - //! \code - //! virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData) - //! { - //! video::IVideoDriver* driver = services->getVideoDriver(); - //! - //! f32 time = (f32)os::Timer::getTime()/100000.0f; - //! services->setVertexShaderConstant("fTime", &time, 1); - //! - //! core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); - //! worldViewProj *= driver->getTransform(video::ETS_VIEW); - //! worldViewProj *= driver->getTransform(video::ETS_WORLD); - //! services->setVertexShaderConstant("mWorldViewProj", worldViewProj.M, 16); - //! } - //! \endcode - //! \param name: Name of the variable - //! \param floats: Pointer to array of floats - //! \param count: Amount of floats in array. - //! \return: Returns true if successful. - virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count) = 0; - - //! Sets a vertex shader constant. Can be used if you created a shader using - //! pixel/vertex shader assembler or ARB_fragment_program or ARB_vertex_program. - //! \param data: Data to be set in the constants - //! \param startRegister: First register to be set - //! \param constantAmount: Amount of registers to be set. One register consists of 4 floats. - virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) = 0; - - //! Sets a constant for the pixel shader based on a name. This can be used if you used - //! a high level shader language like GLSL or HLSL to create a shader. See - //! setVertexShaderConstant() for an example on how to use this. - //! \param name: Name of the variable - //! \param floats: Pointer to array of floats - //! \param count: Amount of floats in array. - //! \return: Returns true if successful. - virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count) = 0; - - //! Sets a pixel shader constant. Can be used if you created a shader using - //! pixel/vertex shader assembler or ARB_fragment_program or ARB_vertex_program. - //! \param data: Data to be set in the constants - //! \param startRegister: First register to be set. - //! \param constantAmount: Amount of registers to be set. One register consists of 4 floats. - virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) = 0; - - //! Returns a pointer to the IVideoDriver interface - virtual IVideoDriver* getVideoDriver() = 0; -}; - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_MATERIAL_RENDERER_SERVICES_H_INCLUDED__ +#define __I_MATERIAL_RENDERER_SERVICES_H_INCLUDED__ + +#include "IUnknown.h" +#include "SMaterial.h" +#include "S3DVertex.h" + +namespace irr +{ +namespace video +{ + +class IVideoDriver; + + +//! Interface providing some methods for changing advanced, internal states of a IVideoDriver. +class IMaterialRendererServices +{ +public: + + //! destructor + virtual ~IMaterialRendererServices() {} + + //! Can be called by an IMaterialRenderer to make its work easier. + //! Sets all basic renderstates if needed. + //! Basic render states are diffuse, ambient, specular, and emissive color, specular power, + //! bilinear and trilinear filtering, wireframe mode, + //! grouraudshading, lighting, zbuffer, zwriteenable, backfaceculling and fog enabling. + virtual void setBasicRenderStates(const SMaterial& material, + const SMaterial& lastMaterial, + bool resetAllRenderstates) = 0; + + //! Sets a constant for the vertex shader based on a name. This can be used if you used + //! a high level shader language like GLSL or HLSL to create a shader. Example: If you + //! created a shader which has variables named 'mWorldViewProj' (containing the + //! WorldViewProjection matrix) and another one named 'fTime' containing one float, + //! you can set them in your IShaderConstantSetCallBack derived class like this: + //! \code + //! virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData) + //! { + //! video::IVideoDriver* driver = services->getVideoDriver(); + //! + //! f32 time = (f32)os::Timer::getTime()/100000.0f; + //! services->setVertexShaderConstant("fTime", &time, 1); + //! + //! core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); + //! worldViewProj *= driver->getTransform(video::ETS_VIEW); + //! worldViewProj *= driver->getTransform(video::ETS_WORLD); + //! services->setVertexShaderConstant("mWorldViewProj", worldViewProj.M, 16); + //! } + //! \endcode + //! \param name: Name of the variable + //! \param floats: Pointer to array of floats + //! \param count: Amount of floats in array. + //! \return: Returns true if successful. + virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count) = 0; + + //! Sets a vertex shader constant. Can be used if you created a shader using + //! pixel/vertex shader assembler or ARB_fragment_program or ARB_vertex_program. + //! \param data: Data to be set in the constants + //! \param startRegister: First register to be set + //! \param constantAmount: Amount of registers to be set. One register consists of 4 floats. + virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) = 0; + + //! Sets a constant for the pixel shader based on a name. This can be used if you used + //! a high level shader language like GLSL or HLSL to create a shader. See + //! setVertexShaderConstant() for an example on how to use this. + //! \param name: Name of the variable + //! \param floats: Pointer to array of floats + //! \param count: Amount of floats in array. + //! \return: Returns true if successful. + virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count) = 0; + + //! Sets a pixel shader constant. Can be used if you created a shader using + //! pixel/vertex shader assembler or ARB_fragment_program or ARB_vertex_program. + //! \param data: Data to be set in the constants + //! \param startRegister: First register to be set. + //! \param constantAmount: Amount of registers to be set. One register consists of 4 floats. + virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) = 0; + + //! Returns a pointer to the IVideoDriver interface + virtual IVideoDriver* getVideoDriver() = 0; +}; + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IMesh.h b/src/dep/include/irrlicht/IMesh.h index 60aeb38..c29ef43 100644 --- a/src/dep/include/irrlicht/IMesh.h +++ b/src/dep/include/irrlicht/IMesh.h @@ -1,61 +1,61 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MESH_H_INCLUDED__ -#define __I_MESH_H_INCLUDED__ - -#include "IUnknown.h" -#include "IMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - //! Class for accessing a mesh with multiple mesh buffers. - /** An IMesh is nothing more than a collection of some mesh buffers (IMeshBuffer). - SMesh is a simple implementation of an IMesh. - */ - class IMesh : public virtual IUnknown - { - public: - - //! destructor - virtual ~IMesh(){}; - - //! Returns the amount of mesh buffers. - /** \return Returns the amount of mesh buffers (IMeshBuffer) in this mesh. */ - virtual u32 getMeshBufferCount() const = 0; - - //! Returns pointer to a mesh buffer. - /** \param nr: Zero based index of the mesh buffer. The maximum value is - getMeshBufferCount() - 1; - \return Returns the pointer to the mesh buffer or - NULL if there is no such mesh buffer. */ - virtual IMeshBuffer* getMeshBuffer(u32 nr) const = 0; - - //! Returns pointer to a mesh buffer which fits a material - /** \param material: material to search for - \return Returns the pointer to the mesh buffer or - NULL if there is no such mesh buffer. */ - virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const { return 0; } - - //! Returns an axis aligned bounding box of the mesh. - /** \return A bounding box of this mesh is returned. */ - virtual const core::aabbox3d& getBoundingBox() const = 0; - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box) = 0; - - //! Sets a flag of all contained materials to a new value. - /** \param flag: Flag to set in all materials. - \param newvalue: New value to set in all materials. */ - virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) = 0; - - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_MESH_H_INCLUDED__ +#define __I_MESH_H_INCLUDED__ + +#include "IUnknown.h" +#include "IMeshBuffer.h" + +namespace irr +{ +namespace scene +{ + //! Class for accessing a mesh with multiple mesh buffers. + /** An IMesh is nothing more than a collection of some mesh buffers (IMeshBuffer). + SMesh is a simple implementation of an IMesh. + */ + class IMesh : public virtual IUnknown + { + public: + + //! destructor + virtual ~IMesh(){}; + + //! Returns the amount of mesh buffers. + /** \return Returns the amount of mesh buffers (IMeshBuffer) in this mesh. */ + virtual u32 getMeshBufferCount() const = 0; + + //! Returns pointer to a mesh buffer. + /** \param nr: Zero based index of the mesh buffer. The maximum value is + getMeshBufferCount() - 1; + \return Returns the pointer to the mesh buffer or + NULL if there is no such mesh buffer. */ + virtual IMeshBuffer* getMeshBuffer(u32 nr) const = 0; + + //! Returns pointer to a mesh buffer which fits a material + /** \param material: material to search for + \return Returns the pointer to the mesh buffer or + NULL if there is no such mesh buffer. */ + virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const { return 0; } + + //! Returns an axis aligned bounding box of the mesh. + /** \return A bounding box of this mesh is returned. */ + virtual const core::aabbox3d& getBoundingBox() const = 0; + + //! set user axis aligned bounding box + virtual void setBoundingBox( const core::aabbox3df& box) = 0; + + //! Sets a flag of all contained materials to a new value. + /** \param flag: Flag to set in all materials. + \param newvalue: New value to set in all materials. */ + virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) = 0; + + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IMeshBuffer.h b/src/dep/include/irrlicht/IMeshBuffer.h index 329f92b..febe0b5 100644 --- a/src/dep/include/irrlicht/IMeshBuffer.h +++ b/src/dep/include/irrlicht/IMeshBuffer.h @@ -1,106 +1,106 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MESH_BUFFER_H_INCLUDED__ -#define __I_MESH_BUFFER_H_INCLUDED__ - -#include "IUnknown.h" -#include "SMaterial.h" -#include "aabbox3d.h" -#include "S3DVertex.h" - -namespace irr -{ -namespace scene -{ -//! Enumeration for all vertex types there are. -enum E_PRIMITIVE_TYPE -{ - //! All vertices are non-connected points. - EPT_POINTS=0, - - //! All vertices form a single connected line. - EPT_LINE_STRIP, - - //! Just as LINE_STRIP, but the last and the first vertex is also connected. - EPT_LINE_LOOP, - - //! Every two vertices are connected creating n/2 lines. - EPT_LINES, - - //! After the first two vertices each vertex defines a new triangle. - //! Always the two last and the new one form a new triangle. - EPT_TRIANGLE_STRIP, - - //! After the first two vertices each vertex defines a new triangle. - //! All around the common first vertex. - EPT_TRIANGLE_FAN, - - //! Explicitly set all vertices for each triangle. - EPT_TRIANGLES, - - //! After the first two vertices each further tw vetices create a quad with the preceding two. - EPT_QUAD_STRIP, - - //! Every four vertices create a quad. - EPT_QUADS, - - //! Just as LINE_LOOP, but filled. - EPT_POLYGON -}; - - //! Struct for holding a mesh with a single material - /** SMeshBuffer is a simple implementation of a MeshBuffer. */ - class IMeshBuffer : public virtual IUnknown - { - public: - - //! destructor - virtual ~IMeshBuffer() {}; - - //! returns the material of this meshbuffer - virtual video::SMaterial& getMaterial() = 0; - - //! returns the material of this meshbuffer - virtual const video::SMaterial& getMaterial() const = 0; - - //! returns which type of vertex data is stored. - virtual video::E_VERTEX_TYPE getVertexType() const = 0; - - //! returns the byte size (stride, pitch) of the vertex - virtual u32 getVertexPitch() const = 0; - - //! returns pointer to vertex data. The data is an array of vertices. Which vertex - //! type is used can be determined with getVertexType(). - virtual const void* getVertices() const = 0; - - //! returns pointer to vertex data. The data is an array of vertices. Which vertex - //! type is used can be determined with getVertexType(). - virtual void* getVertices() = 0; - - //! returns amount of vertices - virtual u32 getVertexCount() const = 0; - - //! returns pointer to Indices - virtual const u16* getIndices() const = 0; - - //! returns pointer to Indices - virtual u16* getIndices() = 0; - - //! returns amount of indices - virtual u32 getIndexCount() const = 0; - - //! returns an axis aligned bounding box - virtual const core::aabbox3df& getBoundingBox() const = 0; - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box) = 0; - - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_MESH_BUFFER_H_INCLUDED__ +#define __I_MESH_BUFFER_H_INCLUDED__ + +#include "IUnknown.h" +#include "SMaterial.h" +#include "aabbox3d.h" +#include "S3DVertex.h" + +namespace irr +{ +namespace scene +{ +//! Enumeration for all vertex types there are. +enum E_PRIMITIVE_TYPE +{ + //! All vertices are non-connected points. + EPT_POINTS=0, + + //! All vertices form a single connected line. + EPT_LINE_STRIP, + + //! Just as LINE_STRIP, but the last and the first vertex is also connected. + EPT_LINE_LOOP, + + //! Every two vertices are connected creating n/2 lines. + EPT_LINES, + + //! After the first two vertices each vertex defines a new triangle. + //! Always the two last and the new one form a new triangle. + EPT_TRIANGLE_STRIP, + + //! After the first two vertices each vertex defines a new triangle. + //! All around the common first vertex. + EPT_TRIANGLE_FAN, + + //! Explicitly set all vertices for each triangle. + EPT_TRIANGLES, + + //! After the first two vertices each further tw vetices create a quad with the preceding two. + EPT_QUAD_STRIP, + + //! Every four vertices create a quad. + EPT_QUADS, + + //! Just as LINE_LOOP, but filled. + EPT_POLYGON +}; + + //! Struct for holding a mesh with a single material + /** SMeshBuffer is a simple implementation of a MeshBuffer. */ + class IMeshBuffer : public virtual IUnknown + { + public: + + //! destructor + virtual ~IMeshBuffer() {}; + + //! returns the material of this meshbuffer + virtual video::SMaterial& getMaterial() = 0; + + //! returns the material of this meshbuffer + virtual const video::SMaterial& getMaterial() const = 0; + + //! returns which type of vertex data is stored. + virtual video::E_VERTEX_TYPE getVertexType() const = 0; + + //! returns the byte size (stride, pitch) of the vertex + virtual u32 getVertexPitch() const = 0; + + //! returns pointer to vertex data. The data is an array of vertices. Which vertex + //! type is used can be determined with getVertexType(). + virtual const void* getVertices() const = 0; + + //! returns pointer to vertex data. The data is an array of vertices. Which vertex + //! type is used can be determined with getVertexType(). + virtual void* getVertices() = 0; + + //! returns amount of vertices + virtual u32 getVertexCount() const = 0; + + //! returns pointer to Indices + virtual const u16* getIndices() const = 0; + + //! returns pointer to Indices + virtual u16* getIndices() = 0; + + //! returns amount of indices + virtual u32 getIndexCount() const = 0; + + //! returns an axis aligned bounding box + virtual const core::aabbox3df& getBoundingBox() const = 0; + + //! set user axis aligned bounding box + virtual void setBoundingBox( const core::aabbox3df& box) = 0; + + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IMeshCache.h b/src/dep/include/irrlicht/IMeshCache.h index bf554a9..4131db0 100644 --- a/src/dep/include/irrlicht/IMeshCache.h +++ b/src/dep/include/irrlicht/IMeshCache.h @@ -1,86 +1,86 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MESH_CACHE_H_INCLUDED__ -#define __I_MESH_CACHE_H_INCLUDED__ - -#include "irrTypes.h" -#include "IUnknown.h" - -namespace irr -{ - -namespace scene -{ - class IMesh; - class IAnimatedMesh; - class IAnimatedMeshSceneNode; - class IMeshLoader; - - //! The mesh cache stores already loaded meshes and provides an interface to them. - /** You can access it using ISceneManager::getMeshCache(). All existing scene managers - will return a pointer to the same mesh cache, because it is shared between them. With - this interface, it is possible to manually add new loaded meshes (if - ISceneManager::getMesh() is not sufficient), to remove them and to iterate through - already loaded meshes. */ - class IMeshCache : public virtual IUnknown - { - public: - - //! destructor - virtual ~IMeshCache() {}; - - //! Adds a mesh to the internal list of loaded meshes. - /** Usually, ISceneManager::getMesh() is called to load a mesh from a file. - That method searches the list of loaded meshes if a mesh has already been loaded and - returns a pointer to if it is in that list and already in memory. Otherwise it loads - the mesh. With IMeshCache::addMesh(), it is possible to pretend that a mesh already - has been loaded. This method can be used for example by mesh loaders who need to - load more than one mesh with one call. They can add additional meshes with this - method to the scene manager. The COLLADA loader for example uses this method. - \param filename: Filename of the mesh. When called ISceneManager::getMesh() with this - parameter, the method will return the mesh parameter given with this method. - \param mesh: Pointer to a mesh which will now be referenced by this name. */ - virtual void addMesh(const c8* filename, IAnimatedMesh* mesh) = 0; - - //! Removes a mesh from the cache. - /** After loading a mesh with getMesh(), the mesh can be removed from the cache - using this method, freeing a lot of memory. */ - virtual void removeMesh(IAnimatedMesh* mesh) = 0; - - //! Returns amount of loaded meshes in the cache. - /** You can load new meshes into the cache using getMesh() and addMesh(). - If you ever need to access the internal mesh cache, you can do this using - removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename() */ - virtual s32 getMeshCount() = 0; - - //! Returns current index number of the mesh, and -1 if it is not in the cache. - virtual s32 getMeshIndex(IAnimatedMesh* mesh) = 0; - - //! Returns a mesh based on its index number. - /** \param index: Index of the mesh, number between 0 and getMeshCount()-1. - Note that this number is only valid until a new mesh is loaded or removed * - \return Returns pointer to the mesh or 0 if there is none with this number. */ - virtual IAnimatedMesh* getMeshByIndex(s32 index) = 0; - - //! Returns name of a mesh based on its index number. - /** \param index: Index of the mesh, number between 0 and getMeshCount()-1. - Note that this is only valid until a new mesh is loaded */ - virtual const c8* getMeshFilename(s32 index) = 0; - - //! Returns the filename of a loaded mesh, if there is any. - /** Returns 0 if there is none. */ - virtual const c8* getMeshFilename(IAnimatedMesh* mesh) = 0; - - //! Returns the filename of a loaded mesh, if there is any. - /* Returns 0 if there is none.*/ - virtual const c8* getMeshFilename(IMesh* mesh) = 0; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_MESH_CACHE_H_INCLUDED__ +#define __I_MESH_CACHE_H_INCLUDED__ + +#include "irrTypes.h" +#include "IUnknown.h" + +namespace irr +{ + +namespace scene +{ + class IMesh; + class IAnimatedMesh; + class IAnimatedMeshSceneNode; + class IMeshLoader; + + //! The mesh cache stores already loaded meshes and provides an interface to them. + /** You can access it using ISceneManager::getMeshCache(). All existing scene managers + will return a pointer to the same mesh cache, because it is shared between them. With + this interface, it is possible to manually add new loaded meshes (if + ISceneManager::getMesh() is not sufficient), to remove them and to iterate through + already loaded meshes. */ + class IMeshCache : public virtual IUnknown + { + public: + + //! destructor + virtual ~IMeshCache() {}; + + //! Adds a mesh to the internal list of loaded meshes. + /** Usually, ISceneManager::getMesh() is called to load a mesh from a file. + That method searches the list of loaded meshes if a mesh has already been loaded and + returns a pointer to if it is in that list and already in memory. Otherwise it loads + the mesh. With IMeshCache::addMesh(), it is possible to pretend that a mesh already + has been loaded. This method can be used for example by mesh loaders who need to + load more than one mesh with one call. They can add additional meshes with this + method to the scene manager. The COLLADA loader for example uses this method. + \param filename: Filename of the mesh. When called ISceneManager::getMesh() with this + parameter, the method will return the mesh parameter given with this method. + \param mesh: Pointer to a mesh which will now be referenced by this name. */ + virtual void addMesh(const c8* filename, IAnimatedMesh* mesh) = 0; + + //! Removes a mesh from the cache. + /** After loading a mesh with getMesh(), the mesh can be removed from the cache + using this method, freeing a lot of memory. */ + virtual void removeMesh(IAnimatedMesh* mesh) = 0; + + //! Returns amount of loaded meshes in the cache. + /** You can load new meshes into the cache using getMesh() and addMesh(). + If you ever need to access the internal mesh cache, you can do this using + removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename() */ + virtual s32 getMeshCount() = 0; + + //! Returns current index number of the mesh, and -1 if it is not in the cache. + virtual s32 getMeshIndex(IAnimatedMesh* mesh) = 0; + + //! Returns a mesh based on its index number. + /** \param index: Index of the mesh, number between 0 and getMeshCount()-1. + Note that this number is only valid until a new mesh is loaded or removed * + \return Returns pointer to the mesh or 0 if there is none with this number. */ + virtual IAnimatedMesh* getMeshByIndex(s32 index) = 0; + + //! Returns name of a mesh based on its index number. + /** \param index: Index of the mesh, number between 0 and getMeshCount()-1. + Note that this is only valid until a new mesh is loaded */ + virtual const c8* getMeshFilename(s32 index) = 0; + + //! Returns the filename of a loaded mesh, if there is any. + /** Returns 0 if there is none. */ + virtual const c8* getMeshFilename(IAnimatedMesh* mesh) = 0; + + //! Returns the filename of a loaded mesh, if there is any. + /* Returns 0 if there is none.*/ + virtual const c8* getMeshFilename(IMesh* mesh) = 0; + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IMeshLoader.h b/src/dep/include/irrlicht/IMeshLoader.h index fd86a00..baf84b6 100644 --- a/src/dep/include/irrlicht/IMeshLoader.h +++ b/src/dep/include/irrlicht/IMeshLoader.h @@ -1,45 +1,45 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MESH_LOADER_H_INCLUDED__ -#define __I_MESH_LOADER_H_INCLUDED__ - -#include "IUnknown.h" -#include "IReadFile.h" -#include "IAnimatedMesh.h" - -namespace irr -{ -namespace scene -{ - -//! Class which is able to load an animated mesh from a file. -/** If you want the Irrlicht Engine be able to load meshes of -currently unsupported file formats (e.g .cob), then implement -this and add your new Surface loader with -ISceneManager::addExternalMeshLoader() to the engine. */ -class IMeshLoader : public virtual IUnknown -{ -public: - - //! destructor - virtual ~IMeshLoader() {}; - - //! Returns true if the file maybe is able to be loaded by this class. - /** This decision should be based only on the file extension (e.g. ".cob") */ - virtual bool isALoadableFileExtension(const c8* fileName) = 0; - - //! Creates/loads an animated mesh from the file. - /** \return Pointer to the created mesh. Returns 0 if loading failed. - If you no longer need the mesh, you should call IAnimatedMesh::drop(). - See IUnknown::drop() for more information. */ - virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file) = 0; -}; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_MESH_LOADER_H_INCLUDED__ +#define __I_MESH_LOADER_H_INCLUDED__ + +#include "IUnknown.h" +#include "IReadFile.h" +#include "IAnimatedMesh.h" + +namespace irr +{ +namespace scene +{ + +//! Class which is able to load an animated mesh from a file. +/** If you want the Irrlicht Engine be able to load meshes of +currently unsupported file formats (e.g .cob), then implement +this and add your new Surface loader with +ISceneManager::addExternalMeshLoader() to the engine. */ +class IMeshLoader : public virtual IUnknown +{ +public: + + //! destructor + virtual ~IMeshLoader() {}; + + //! Returns true if the file maybe is able to be loaded by this class. + /** This decision should be based only on the file extension (e.g. ".cob") */ + virtual bool isALoadableFileExtension(const c8* fileName) = 0; + + //! Creates/loads an animated mesh from the file. + /** \return Pointer to the created mesh. Returns 0 if loading failed. + If you no longer need the mesh, you should call IAnimatedMesh::drop(). + See IUnknown::drop() for more information. */ + virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file) = 0; +}; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IMeshManipulator.h b/src/dep/include/irrlicht/IMeshManipulator.h index ecbac77..11da3ed 100644 --- a/src/dep/include/irrlicht/IMeshManipulator.h +++ b/src/dep/include/irrlicht/IMeshManipulator.h @@ -1,116 +1,116 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MESH_MANIPULATOR_H_INCLUDED__ -#define __I_MESH_MANIPULATOR_H_INCLUDED__ - -#include "IUnknown.h" -#include "vector3d.h" -#include "IMeshBuffer.h" -#include "aabbox3d.h" -#include "IAnimatedMesh.h" - -namespace irr -{ -namespace scene -{ - - class IMesh; - class IAnimatedMesh; - struct SMesh; - - //! An interface for easily manipulate meshes. - /** Scale, set alpha value, flip surfaces, and so on. This exists for fixing problems - with wrong imported or exported meshes quickly after loading. It is not intended for doing mesh - modifications and/or animations during runtime. - */ - class IMeshManipulator : public virtual IUnknown - { - public: - - //! destructor - virtual ~IMeshManipulator() {}; - - //! Flips the direction of surfaces. - /** Changes backfacing triangles to frontfacing - triangles and vice versa. - \param mesh: Mesh on which the operation is performed. */ - virtual void flipSurfaces(IMesh* mesh) const = 0; - - //! Sets the alpha vertex color value of the whole mesh to a new value. - /** \param mesh: Mesh on which the operation is performed. - \param alpha: New alpha value. Must be a value between 0 and 255. */ - virtual void setVertexColorAlpha(IMesh* mesh, s32 alpha) const = 0; - - //! Sets the colors of all vertices to one color - virtual void setVertexColors(IMesh* mesh, video::SColor color) const = 0; - - //! Recalculates all normals of the mesh. - /** \param mesh: Mesh on which the operation is performed. */ - virtual void recalculateNormals(IMesh* mesh, bool smooth = false) const = 0; - - //! Recalculates all normals of the mesh buffer. - /** \param buffer: Mesh buffer on which the operation is performed. */ - virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false) const = 0; - - //! Scales the whole mesh. - /** \param mesh: Mesh on which the operation is performed. - \param scale: Scale factor. */ - virtual void scaleMesh(IMesh* mesh, const core::vector3df& scale) const = 0; - - //! Applies a transformation - /** \param mesh: Mesh on which the operation is performed. - \param m: transformation matrix. */ - virtual void transformMesh(IMesh* mesh, const core::matrix4& m) const = 0; - - //! Clones a static IMesh into a modifyable SMesh. - /** All meshbuffers in the returned SMesh - are of type SMeshBuffer or SMeshBufferLightMap. - \param mesh: Mesh to copy. - \return Returns the cloned mesh. - If you no longer need the cloned mesh, you should call SMesh::drop(). - See IUnknown::drop() for more information. */ - virtual SMesh* createMeshCopy(IMesh* mesh) const = 0; - - - //! Creates a planar texture mapping on the mesh - /** \param mesh: Mesh on which the operation is performed. - \param resolution: resolution of the planar mapping. This is the value - specifying which is the relation between world space and - texture coordinate space. */ - virtual void makePlanarTextureMapping(IMesh* mesh, f32 resolution=0.001f) const = 0; - - //! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices. - /** This is useful if you want to draw tangent space normal mapped geometry because - it calculates the tangent and binormal data which is needed there. - \param mesh: Input mesh - \return Mesh consiting only of S3DVertexTangents vertices. - If you no longer need the cloned mesh, you should call IMesh::drop(). - See IUnknown::drop() for more information. */ - virtual IMesh* createMeshWithTangents(IMesh* mesh) const = 0; - - //! Unweld vertices - virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const = 0; - - //! Recalculates the bounding box for a meshbuffer - virtual void recalculateBoundingBox(scene::IMeshBuffer* buffer) const = 0; - - //! Returns amount of polygons in mesh. - virtual s32 getPolyCount(scene::IMesh* mesh) const = 0; - - //! Returns amount of polygons in mesh. - virtual s32 getPolyCount(scene::IAnimatedMesh* mesh) const = 0; - - //! create a new AnimatedMesh and adds the mesh to it - virtual IAnimatedMesh * createAnimatedMesh(scene::IMesh* mesh, - scene::E_ANIMATED_MESH_TYPE type = scene::EAMT_UNKNOWN) const = 0; - - }; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_MESH_MANIPULATOR_H_INCLUDED__ +#define __I_MESH_MANIPULATOR_H_INCLUDED__ + +#include "IUnknown.h" +#include "vector3d.h" +#include "IMeshBuffer.h" +#include "aabbox3d.h" +#include "IAnimatedMesh.h" + +namespace irr +{ +namespace scene +{ + + class IMesh; + class IAnimatedMesh; + struct SMesh; + + //! An interface for easily manipulate meshes. + /** Scale, set alpha value, flip surfaces, and so on. This exists for fixing problems + with wrong imported or exported meshes quickly after loading. It is not intended for doing mesh + modifications and/or animations during runtime. + */ + class IMeshManipulator : public virtual IUnknown + { + public: + + //! destructor + virtual ~IMeshManipulator() {}; + + //! Flips the direction of surfaces. + /** Changes backfacing triangles to frontfacing + triangles and vice versa. + \param mesh: Mesh on which the operation is performed. */ + virtual void flipSurfaces(IMesh* mesh) const = 0; + + //! Sets the alpha vertex color value of the whole mesh to a new value. + /** \param mesh: Mesh on which the operation is performed. + \param alpha: New alpha value. Must be a value between 0 and 255. */ + virtual void setVertexColorAlpha(IMesh* mesh, s32 alpha) const = 0; + + //! Sets the colors of all vertices to one color + virtual void setVertexColors(IMesh* mesh, video::SColor color) const = 0; + + //! Recalculates all normals of the mesh. + /** \param mesh: Mesh on which the operation is performed. */ + virtual void recalculateNormals(IMesh* mesh, bool smooth = false) const = 0; + + //! Recalculates all normals of the mesh buffer. + /** \param buffer: Mesh buffer on which the operation is performed. */ + virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false) const = 0; + + //! Scales the whole mesh. + /** \param mesh: Mesh on which the operation is performed. + \param scale: Scale factor. */ + virtual void scaleMesh(IMesh* mesh, const core::vector3df& scale) const = 0; + + //! Applies a transformation + /** \param mesh: Mesh on which the operation is performed. + \param m: transformation matrix. */ + virtual void transformMesh(IMesh* mesh, const core::matrix4& m) const = 0; + + //! Clones a static IMesh into a modifyable SMesh. + /** All meshbuffers in the returned SMesh + are of type SMeshBuffer or SMeshBufferLightMap. + \param mesh: Mesh to copy. + \return Returns the cloned mesh. + If you no longer need the cloned mesh, you should call SMesh::drop(). + See IUnknown::drop() for more information. */ + virtual SMesh* createMeshCopy(IMesh* mesh) const = 0; + + + //! Creates a planar texture mapping on the mesh + /** \param mesh: Mesh on which the operation is performed. + \param resolution: resolution of the planar mapping. This is the value + specifying which is the relation between world space and + texture coordinate space. */ + virtual void makePlanarTextureMapping(IMesh* mesh, f32 resolution=0.001f) const = 0; + + //! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices. + /** This is useful if you want to draw tangent space normal mapped geometry because + it calculates the tangent and binormal data which is needed there. + \param mesh: Input mesh + \return Mesh consiting only of S3DVertexTangents vertices. + If you no longer need the cloned mesh, you should call IMesh::drop(). + See IUnknown::drop() for more information. */ + virtual IMesh* createMeshWithTangents(IMesh* mesh) const = 0; + + //! Unweld vertices + virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const = 0; + + //! Recalculates the bounding box for a meshbuffer + virtual void recalculateBoundingBox(scene::IMeshBuffer* buffer) const = 0; + + //! Returns amount of polygons in mesh. + virtual s32 getPolyCount(scene::IMesh* mesh) const = 0; + + //! Returns amount of polygons in mesh. + virtual s32 getPolyCount(scene::IAnimatedMesh* mesh) const = 0; + + //! create a new AnimatedMesh and adds the mesh to it + virtual IAnimatedMesh * createAnimatedMesh(scene::IMesh* mesh, + scene::E_ANIMATED_MESH_TYPE type = scene::EAMT_UNKNOWN) const = 0; + + }; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/IMeshSceneNode.h b/src/dep/include/irrlicht/IMeshSceneNode.h index d0717e6..3189a38 100644 --- a/src/dep/include/irrlicht/IMeshSceneNode.h +++ b/src/dep/include/irrlicht/IMeshSceneNode.h @@ -1,49 +1,49 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MESH_SCENE_NODE_H_INCLUDED__ -#define __I_MESH_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - -class IMesh; - - -//! A scene node displaying a static mesh -class IMeshSceneNode : public ISceneNode -{ -public: - - //! constructor - IMeshSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::vector3df& rotation, - const core::vector3df& scale) - : ISceneNode(parent, mgr, id, position, rotation, scale) {} - - //! Sets a new mesh to display - virtual void setMesh(IMesh* mesh) = 0; - - //! Returns the current mesh - virtual IMesh* getMesh(void) = 0; - - //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. - /* In this way it is possible to change the materials a mesh causing all mesh scene nodes - referencing this mesh to change too. */ - virtual void setReadOnlyMaterials(bool readonly) = 0; - - //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style - virtual bool isReadOnlyMaterials() = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_MESH_SCENE_NODE_H_INCLUDED__ +#define __I_MESH_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + +class IMesh; + + +//! A scene node displaying a static mesh +class IMeshSceneNode : public ISceneNode +{ +public: + + //! constructor + IMeshSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position, const core::vector3df& rotation, + const core::vector3df& scale) + : ISceneNode(parent, mgr, id, position, rotation, scale) {} + + //! Sets a new mesh to display + virtual void setMesh(IMesh* mesh) = 0; + + //! Returns the current mesh + virtual IMesh* getMesh(void) = 0; + + //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. + /* In this way it is possible to change the materials a mesh causing all mesh scene nodes + referencing this mesh to change too. */ + virtual void setReadOnlyMaterials(bool readonly) = 0; + + //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style + virtual bool isReadOnlyMaterials() = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/IMetaTriangleSelector.h b/src/dep/include/irrlicht/IMetaTriangleSelector.h index d3afaba..d799665 100644 --- a/src/dep/include/irrlicht/IMetaTriangleSelector.h +++ b/src/dep/include/irrlicht/IMetaTriangleSelector.h @@ -1,44 +1,44 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_META_TRIANGLE_SELECTOR_H_INCLUDED__ -#define __I_META_TRIANGLE_SELECTOR_H_INCLUDED__ - -#include "ITriangleSelector.h" - -namespace irr -{ -namespace scene -{ - -//! Interface for making multiple triangle selectors work as one big selector. -/** This is nothing more than a collection of one or more triangle selectors -providing together the interface of one triangle selector. In this way, -collision tests can be done with different triangle soups in one pass. -*/ -class IMetaTriangleSelector : public ITriangleSelector -{ -public: - - //! Adds a triangle selector to the collection of triangle selectors - //! in this metaTriangleSelector. - //! \param toAdd: Pointer to an triangle selector to add to the list. - virtual void addTriangleSelector(ITriangleSelector* toAdd) = 0; - - //! Removes a specific triangle selector which was added before from the collection. - //! \param toRemove: Pointer to an triangle selector which is in the list - //! but will be removed. - //! \return Returns true if successful, false if not. - virtual bool removeTriangleSelector(ITriangleSelector* toRemove) = 0; - - //! Removes all triangle selectors from the collection. - virtual void removeAllTriangleSelectors() = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_META_TRIANGLE_SELECTOR_H_INCLUDED__ +#define __I_META_TRIANGLE_SELECTOR_H_INCLUDED__ + +#include "ITriangleSelector.h" + +namespace irr +{ +namespace scene +{ + +//! Interface for making multiple triangle selectors work as one big selector. +/** This is nothing more than a collection of one or more triangle selectors +providing together the interface of one triangle selector. In this way, +collision tests can be done with different triangle soups in one pass. +*/ +class IMetaTriangleSelector : public ITriangleSelector +{ +public: + + //! Adds a triangle selector to the collection of triangle selectors + //! in this metaTriangleSelector. + //! \param toAdd: Pointer to an triangle selector to add to the list. + virtual void addTriangleSelector(ITriangleSelector* toAdd) = 0; + + //! Removes a specific triangle selector which was added before from the collection. + //! \param toRemove: Pointer to an triangle selector which is in the list + //! but will be removed. + //! \return Returns true if successful, false if not. + virtual bool removeTriangleSelector(ITriangleSelector* toRemove) = 0; + + //! Removes all triangle selectors from the collection. + virtual void removeAllTriangleSelectors() = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/IOSOperator.h b/src/dep/include/irrlicht/IOSOperator.h index a8ec377..62239d9 100644 --- a/src/dep/include/irrlicht/IOSOperator.h +++ b/src/dep/include/irrlicht/IOSOperator.h @@ -1,49 +1,49 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_OS_OPERATOR_H_INCLUDED__ -#define __I_OS_OPERATOR_H_INCLUDED__ - -#include "IUnknown.h" - -namespace irr -{ - -//! The Operating system operator provides operation system specific methods and informations. -/** Currently only 3 methods are supported. But it will be extended with more functionality -soon. */ -class IOSOperator : public virtual IUnknown -{ -public: - - //! destructor - virtual ~IOSOperator() {} - - //! returns the current operation system version as string. - virtual const wchar_t* getOperationSystemVersion() = 0; - - //! copies text to the clipboard - virtual void copyToClipboard(const c8* text) = 0; - - //! gets text from the clipboard - //! \return Returns 0 if no string is in there. - virtual c8* getTextFromClipboard() = 0; - - //! gets the processor speed in megahertz - //! \param Mhz: - //! \return Returns true if successful, false if not - virtual bool getProcessorSpeedMHz(irr::u32* MHz) = 0; - - //! gets the total and available system RAM - //! \param Total: will contain the total system memory - //! \param Avail: will contain the available memory - //! \return Returns true if successful, false if not - virtual bool getSystemMemory(irr::u32* Total, irr::u32* Avail) = 0; - -}; - -} // end namespace - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_OS_OPERATOR_H_INCLUDED__ +#define __I_OS_OPERATOR_H_INCLUDED__ + +#include "IUnknown.h" + +namespace irr +{ + +//! The Operating system operator provides operation system specific methods and informations. +/** Currently only 3 methods are supported. But it will be extended with more functionality +soon. */ +class IOSOperator : public virtual IUnknown +{ +public: + + //! destructor + virtual ~IOSOperator() {} + + //! returns the current operation system version as string. + virtual const wchar_t* getOperationSystemVersion() = 0; + + //! copies text to the clipboard + virtual void copyToClipboard(const c8* text) = 0; + + //! gets text from the clipboard + //! \return Returns 0 if no string is in there. + virtual c8* getTextFromClipboard() = 0; + + //! gets the processor speed in megahertz + //! \param Mhz: + //! \return Returns true if successful, false if not + virtual bool getProcessorSpeedMHz(irr::u32* MHz) = 0; + + //! gets the total and available system RAM + //! \param Total: will contain the total system memory + //! \param Avail: will contain the available memory + //! \return Returns true if successful, false if not + virtual bool getSystemMemory(irr::u32* Total, irr::u32* Avail) = 0; + +}; + +} // end namespace + +#endif + diff --git a/src/dep/include/irrlicht/IParticleAffector.h b/src/dep/include/irrlicht/IParticleAffector.h index ea71ab1..849ca00 100644 --- a/src/dep/include/irrlicht/IParticleAffector.h +++ b/src/dep/include/irrlicht/IParticleAffector.h @@ -1,78 +1,78 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_AFFECTOR_H_INCLUDED__ -#define __I_PARTICLE_AFFECTOR_H_INCLUDED__ - -#include "IAttributeExchangingObject.h" -#include "SParticle.h" - -namespace irr -{ -namespace scene -{ - -//! Types of built in particle affectors -enum E_PARTICLE_AFFECTOR_TYPE -{ - EPAT_NONE = 0, - EPAT_FADE_OUT, - EPAT_GRAVITY, - EPAT_COUNT -}; - -//! Names for built in particle affectors -const c8* const ParticleAffectorTypeNames[] = -{ - "None", - "FadeOut", - "Gravity", - 0 -}; - -//! A particle affector modifies particles. -class IParticleAffector : public virtual io::IAttributeExchangingObject -{ -public: - - //! constructor - IParticleAffector() : Enabled(true) {} - - //! Affects an array of particles. - //! \param now: Current time. (Same as ITimer::getTime() would return) - //! \param particlearray: Array of particles. - //! \param count: Amount of particles in array. - virtual void affect(u32 now, SParticle* particlearray, u32 count) = 0; - - //! Sets whether or not the affector is currently enabled. - virtual void setEnabled(bool enabled) {Enabled = enabled;} - - //! Gets whether or not the affector is currently enabled. - virtual bool getEnabled() const { return Enabled;} - - //! Writes attributes of the object. - //! Implement this to expose the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) {} - - //! Reads attributes of the object. - //! Implement this to set the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml deserialization purposes. - //! \param startIndex: start index where to start reading attributes. - //! \return: returns last index of an attribute read by this affector - virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { return 0; } - - //! Get emitter type - virtual E_PARTICLE_AFFECTOR_TYPE getType() = 0; - -protected: - bool Enabled; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_PARTICLE_AFFECTOR_H_INCLUDED__ +#define __I_PARTICLE_AFFECTOR_H_INCLUDED__ + +#include "IAttributeExchangingObject.h" +#include "SParticle.h" + +namespace irr +{ +namespace scene +{ + +//! Types of built in particle affectors +enum E_PARTICLE_AFFECTOR_TYPE +{ + EPAT_NONE = 0, + EPAT_FADE_OUT, + EPAT_GRAVITY, + EPAT_COUNT +}; + +//! Names for built in particle affectors +const c8* const ParticleAffectorTypeNames[] = +{ + "None", + "FadeOut", + "Gravity", + 0 +}; + +//! A particle affector modifies particles. +class IParticleAffector : public virtual io::IAttributeExchangingObject +{ +public: + + //! constructor + IParticleAffector() : Enabled(true) {} + + //! Affects an array of particles. + //! \param now: Current time. (Same as ITimer::getTime() would return) + //! \param particlearray: Array of particles. + //! \param count: Amount of particles in array. + virtual void affect(u32 now, SParticle* particlearray, u32 count) = 0; + + //! Sets whether or not the affector is currently enabled. + virtual void setEnabled(bool enabled) {Enabled = enabled;} + + //! Gets whether or not the affector is currently enabled. + virtual bool getEnabled() const { return Enabled;} + + //! Writes attributes of the object. + //! Implement this to expose the attributes of your scene node animator for + //! scripting languages, editors, debuggers or xml serialization purposes. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) {} + + //! Reads attributes of the object. + //! Implement this to set the attributes of your scene node animator for + //! scripting languages, editors, debuggers or xml deserialization purposes. + //! \param startIndex: start index where to start reading attributes. + //! \return: returns last index of an attribute read by this affector + virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { return 0; } + + //! Get emitter type + virtual E_PARTICLE_AFFECTOR_TYPE getType() = 0; + +protected: + bool Enabled; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/IParticleEmitter.h b/src/dep/include/irrlicht/IParticleEmitter.h index fcc7a88..af0ac3f 100644 --- a/src/dep/include/irrlicht/IParticleEmitter.h +++ b/src/dep/include/irrlicht/IParticleEmitter.h @@ -1,72 +1,72 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_EMITTER_H_INCLUDED__ -#define __I_PARTICLE_EMITTER_H_INCLUDED__ - -#include "IAttributeExchangingObject.h" -#include "SParticle.h" - -namespace irr -{ -namespace scene -{ - -//! Types of built in particle emitters -enum E_PARTICLE_EMITTER_TYPE -{ - EPET_POINT = 0, - EPET_BOX, - EPET_COUNT -}; - -//! Names for built in particle emitters -const c8* const ParticleEmitterTypeNames[] = -{ - "Point", - "Box", - 0 -}; - -//! A particle emitter for using with particle systems. -/** A Particle emitter emitts new particles into a particle system. -*/ -class IParticleEmitter : public virtual io::IAttributeExchangingObject -{ -public: - - //! destructor - virtual ~IParticleEmitter() {}; - - //! Prepares an array with new particles to emitt into the system - //! and returns how much new particles there are. - //! \param now: Current time. - //! \param timeSinceLastCall: Time elapsed since last call, in milliseconds. - //! \param outArray: Pointer which will point to the array with the new - //! particles to add into the system. - //! \return Returns amount of new particles in the array. Can be 0. - virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) = 0; - - //! Writes attributes of the object. - //! Implement this to expose the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) {} - - //! Reads attributes of the object. - //! Implement this to set the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml deserialization purposes. - //! \param startIndex: start index where to start reading attributes. - //! \return: returns last index of an attribute read by this affector - virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { return 0; } - - //! Get emitter type - virtual E_PARTICLE_EMITTER_TYPE getType() = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_PARTICLE_EMITTER_H_INCLUDED__ +#define __I_PARTICLE_EMITTER_H_INCLUDED__ + +#include "IAttributeExchangingObject.h" +#include "SParticle.h" + +namespace irr +{ +namespace scene +{ + +//! Types of built in particle emitters +enum E_PARTICLE_EMITTER_TYPE +{ + EPET_POINT = 0, + EPET_BOX, + EPET_COUNT +}; + +//! Names for built in particle emitters +const c8* const ParticleEmitterTypeNames[] = +{ + "Point", + "Box", + 0 +}; + +//! A particle emitter for using with particle systems. +/** A Particle emitter emitts new particles into a particle system. +*/ +class IParticleEmitter : public virtual io::IAttributeExchangingObject +{ +public: + + //! destructor + virtual ~IParticleEmitter() {}; + + //! Prepares an array with new particles to emitt into the system + //! and returns how much new particles there are. + //! \param now: Current time. + //! \param timeSinceLastCall: Time elapsed since last call, in milliseconds. + //! \param outArray: Pointer which will point to the array with the new + //! particles to add into the system. + //! \return Returns amount of new particles in the array. Can be 0. + virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) = 0; + + //! Writes attributes of the object. + //! Implement this to expose the attributes of your scene node animator for + //! scripting languages, editors, debuggers or xml serialization purposes. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) {} + + //! Reads attributes of the object. + //! Implement this to set the attributes of your scene node animator for + //! scripting languages, editors, debuggers or xml deserialization purposes. + //! \param startIndex: start index where to start reading attributes. + //! \return: returns last index of an attribute read by this affector + virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { return 0; } + + //! Get emitter type + virtual E_PARTICLE_EMITTER_TYPE getType() = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/IParticleSystemSceneNode.h b/src/dep/include/irrlicht/IParticleSystemSceneNode.h index c0c5345..13f1ce4 100644 --- a/src/dep/include/irrlicht/IParticleSystemSceneNode.h +++ b/src/dep/include/irrlicht/IParticleSystemSceneNode.h @@ -1,184 +1,184 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ -#define __I_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "IParticleEmitter.h" -#include "IParticleAffector.h" -#include "dimension2d.h" - -namespace irr -{ -namespace scene -{ - -//! A particle system scene node for creating snow, fire, exlosions, smoke... -/** A scene node controlling a particle System. The behavior of the particles -can be controlling by setting the right particle emitters and effectors. -You can for example easily a campfire by doing this: - -\code - scene::IParticleSystemSceneNode* p = scenemgr->addParticleSystemSceneNode(); - p->setParticleSize(core::dimension2d(20.0f, 10.0f)); - scene::IParticleEmitter* em = p->createBoxEmitter( - core::aabbox3d(-5,0,-5,5,1,5), - core::vector3df(0.0f,0.03f,0.0f), - 40,80, video::SColor(0,255,255,255),video::SColor(0,255,255,255), 1100,2000); - p->setEmitter(em); - em->drop(); - scene::IParticleAffector* paf = p->createFadeOutParticleAffector(); - p->addAffector(paf); - paf->drop(); -\endcode - -*/ -class IParticleSystemSceneNode : public ISceneNode -{ -public: - - //! constructor - IParticleSystemSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) - : ISceneNode(parent, mgr, id, position, rotation, scale) {} - - //! Sets the size of all particles. - virtual void setParticleSize( - const core::dimension2d &size = core::dimension2d(5.0f, 5.0f)) = 0; - - //! Sets if the particles should be global. If it is, the particles are affected by - //! the movement of the particle system scene node too, otherwise they completely - //! ignore it. Default is true. - virtual void setParticlesAreGlobal(bool global) = 0; - - //! Sets the particle emitter, which creates the particles. - //! A particle emitter can be created using one of the - //! methods. For example to create and use a simple PointEmitter, - //! call IParticleEmitter* p = createPointEmitter(); setEmitter(p); p->drop(); - //! \param emitter: Sets the particle emitter. You can set this to 0 - //! for removing the current emitter and stopping the particle system - //! emitting new particles. - virtual void setEmitter(IParticleEmitter* emitter) = 0; - - //! Adds new particle effector to the particle system. A particle - //! affector modifies the particles. For example, the FadeOut - //! affector lets all particles fade out after some time. It is created - //! and used in this way: IParticleAffector* p = createFadeOutParticleAffector(); - //! addAffector(p); p->drop(); - //! Please note that a affector is not necessary for the particle - //! system to work. - //! \param affector: New affector. - virtual void addAffector(IParticleAffector* affector) = 0; - - //! Removes all particle affectors in the particle system. - virtual void removeAllAffectors() = 0; - - //! Creates a point particle emitter. - //! \param direction: Direction and speed of particle emission. - //! \param minParticlesPerSecond: Minimal amount of particles emitted - //! per second. - //! \param maxParticlesPerSecond: Maximal amount of particles emitted - //! per second. - //! \param minStartColor: Minimal initial start color of a particle. - //! The real color of every particle is calculated as random interpolation - //! between minStartColor and maxStartColor. - //! \param maxStartColor: Maximal initial start color of a particle. - //! The real color of every particle is calculated as random interpolation - //! between minStartColor and maxStartColor. - //! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds. - //! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. - //! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction - //! of the particle will differ from the orignial direction. - //! \return Returns a pointer to the created particle emitter. - //! To set this emitter as new emitter of this particle system, - //! just call setEmitter(). Note that you'll have to drop() the - //! returned pointer, after you don't need it any more, see - //! IUnknown::drop() for more informations. - virtual IParticleEmitter* createPointEmitter( - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - video::SColor minStartColor = video::SColor(255,0,0,0), - video::SColor maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0) = 0; - - //! Creates a box particle emitter. - //! \param box: The box for the emitter. - //! \param direction: Direction and speed of particle emission. - //! \param minParticlesPerSecond: Minimal amount of particles emitted - //! per second. - //! \param maxParticlesPerSecond: Maximal amount of particles emitted - //! per second. - //! \param minStartColor: Minimal initial start color of a particle. - //! The real color of every particle is calculated as random interpolation - //! between minStartColor and maxStartColor. - //! \param maxStartColor: Maximal initial start color of a particle. - //! The real color of every particle is calculated as random interpolation - //! between minStartColor and maxStartColor. - //! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds. - //! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. - //! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction - //! of the particle will differ from the orignial direction. - //! \return Returns a pointer to the created particle emitter. - //! To set this emitter as new emitter of this particle system, - //! just call setEmitter(). Note that you'll have to drop() the - //! returned pointer, after you don't need it any more, see - //! IUnknown::drop() for more informations. - virtual IParticleEmitter* createBoxEmitter( - const core::aabbox3df& box = core::aabbox3df(-10,28,-10,10,30,10), - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - video::SColor minStartColor = video::SColor(255,0,0,0), - video::SColor maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0) = 0; - - //! Creates a fade out particle affector. This affector modifies - //! the color of every particle and and reaches the final color - //! when the particle dies. - //! This affector looks really good, if the EMT_TRANSPARENT_VERTEX_ALPHA - //! material is used and the targetColor is video::SColor(0,0,0,0): - //! Particles are fading out into void with this setting. - //! \param targetColor: Color whereto the color of the particle is changed. - //! \param timeNeededToFadeOut: How much time in milli seconds - //! should the affector need to change the color to the targetColor. - //! \return Returns a pointer to the created particle affector. - //! To add this affector as new affector of this particle system, - //! just call addAffector(). Note that you'll have to drop() the - //! returned pointer, after you don't need it any more, see - //! IUnknown::drop() for more informations. - virtual IParticleAffector* createFadeOutParticleAffector( - video::SColor targetColor = video::SColor(0,0,0,0), - u32 timeNeededToFadeOut = 1000) = 0; - - //! Creates a gravity affector. This affector modifies the direction - //! of the particle. It assumes that the particle is fired out of the - //! emitter with huge force, but is loosing this after some time - //! and is catched by the gravity then. This affector is ideal for - //! creating things like fountains. - //! \param gravity: Direction and force of gravity. - //! \param timeForceLost: Time in milli seconds when the force - //! of the emitter is totally lost and the particle does not move any more. - //! This is the time where gravity fully affects the particle. - //! \return Returns a pointer to the created particle affector. - //! To add this affector as new affector of this particle system, - //! just call addAffector(). Note that you'll have to drop() the - //! returned pointer, after you don't need it any more, see - //! IUnknown::drop() for more informations. - virtual IParticleAffector* createGravityAffector( - const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), - u32 timeForceLost = 1000) = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ +#define __I_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" +#include "IParticleEmitter.h" +#include "IParticleAffector.h" +#include "dimension2d.h" + +namespace irr +{ +namespace scene +{ + +//! A particle system scene node for creating snow, fire, exlosions, smoke... +/** A scene node controlling a particle System. The behavior of the particles +can be controlling by setting the right particle emitters and effectors. +You can for example easily a campfire by doing this: + +\code + scene::IParticleSystemSceneNode* p = scenemgr->addParticleSystemSceneNode(); + p->setParticleSize(core::dimension2d(20.0f, 10.0f)); + scene::IParticleEmitter* em = p->createBoxEmitter( + core::aabbox3d(-5,0,-5,5,1,5), + core::vector3df(0.0f,0.03f,0.0f), + 40,80, video::SColor(0,255,255,255),video::SColor(0,255,255,255), 1100,2000); + p->setEmitter(em); + em->drop(); + scene::IParticleAffector* paf = p->createFadeOutParticleAffector(); + p->addAffector(paf); + paf->drop(); +\endcode + +*/ +class IParticleSystemSceneNode : public ISceneNode +{ +public: + + //! constructor + IParticleSystemSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) + : ISceneNode(parent, mgr, id, position, rotation, scale) {} + + //! Sets the size of all particles. + virtual void setParticleSize( + const core::dimension2d &size = core::dimension2d(5.0f, 5.0f)) = 0; + + //! Sets if the particles should be global. If it is, the particles are affected by + //! the movement of the particle system scene node too, otherwise they completely + //! ignore it. Default is true. + virtual void setParticlesAreGlobal(bool global) = 0; + + //! Sets the particle emitter, which creates the particles. + //! A particle emitter can be created using one of the + //! methods. For example to create and use a simple PointEmitter, + //! call IParticleEmitter* p = createPointEmitter(); setEmitter(p); p->drop(); + //! \param emitter: Sets the particle emitter. You can set this to 0 + //! for removing the current emitter and stopping the particle system + //! emitting new particles. + virtual void setEmitter(IParticleEmitter* emitter) = 0; + + //! Adds new particle effector to the particle system. A particle + //! affector modifies the particles. For example, the FadeOut + //! affector lets all particles fade out after some time. It is created + //! and used in this way: IParticleAffector* p = createFadeOutParticleAffector(); + //! addAffector(p); p->drop(); + //! Please note that a affector is not necessary for the particle + //! system to work. + //! \param affector: New affector. + virtual void addAffector(IParticleAffector* affector) = 0; + + //! Removes all particle affectors in the particle system. + virtual void removeAllAffectors() = 0; + + //! Creates a point particle emitter. + //! \param direction: Direction and speed of particle emission. + //! \param minParticlesPerSecond: Minimal amount of particles emitted + //! per second. + //! \param maxParticlesPerSecond: Maximal amount of particles emitted + //! per second. + //! \param minStartColor: Minimal initial start color of a particle. + //! The real color of every particle is calculated as random interpolation + //! between minStartColor and maxStartColor. + //! \param maxStartColor: Maximal initial start color of a particle. + //! The real color of every particle is calculated as random interpolation + //! between minStartColor and maxStartColor. + //! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds. + //! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. + //! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction + //! of the particle will differ from the orignial direction. + //! \return Returns a pointer to the created particle emitter. + //! To set this emitter as new emitter of this particle system, + //! just call setEmitter(). Note that you'll have to drop() the + //! returned pointer, after you don't need it any more, see + //! IUnknown::drop() for more informations. + virtual IParticleEmitter* createPointEmitter( + const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), + u32 minParticlesPerSecond = 5, + u32 maxParticlesPerSecond = 10, + video::SColor minStartColor = video::SColor(255,0,0,0), + video::SColor maxStartColor = video::SColor(255,255,255,255), + u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, + s32 maxAngleDegrees=0) = 0; + + //! Creates a box particle emitter. + //! \param box: The box for the emitter. + //! \param direction: Direction and speed of particle emission. + //! \param minParticlesPerSecond: Minimal amount of particles emitted + //! per second. + //! \param maxParticlesPerSecond: Maximal amount of particles emitted + //! per second. + //! \param minStartColor: Minimal initial start color of a particle. + //! The real color of every particle is calculated as random interpolation + //! between minStartColor and maxStartColor. + //! \param maxStartColor: Maximal initial start color of a particle. + //! The real color of every particle is calculated as random interpolation + //! between minStartColor and maxStartColor. + //! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds. + //! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. + //! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction + //! of the particle will differ from the orignial direction. + //! \return Returns a pointer to the created particle emitter. + //! To set this emitter as new emitter of this particle system, + //! just call setEmitter(). Note that you'll have to drop() the + //! returned pointer, after you don't need it any more, see + //! IUnknown::drop() for more informations. + virtual IParticleEmitter* createBoxEmitter( + const core::aabbox3df& box = core::aabbox3df(-10,28,-10,10,30,10), + const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), + u32 minParticlesPerSecond = 5, + u32 maxParticlesPerSecond = 10, + video::SColor minStartColor = video::SColor(255,0,0,0), + video::SColor maxStartColor = video::SColor(255,255,255,255), + u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, + s32 maxAngleDegrees=0) = 0; + + //! Creates a fade out particle affector. This affector modifies + //! the color of every particle and and reaches the final color + //! when the particle dies. + //! This affector looks really good, if the EMT_TRANSPARENT_VERTEX_ALPHA + //! material is used and the targetColor is video::SColor(0,0,0,0): + //! Particles are fading out into void with this setting. + //! \param targetColor: Color whereto the color of the particle is changed. + //! \param timeNeededToFadeOut: How much time in milli seconds + //! should the affector need to change the color to the targetColor. + //! \return Returns a pointer to the created particle affector. + //! To add this affector as new affector of this particle system, + //! just call addAffector(). Note that you'll have to drop() the + //! returned pointer, after you don't need it any more, see + //! IUnknown::drop() for more informations. + virtual IParticleAffector* createFadeOutParticleAffector( + video::SColor targetColor = video::SColor(0,0,0,0), + u32 timeNeededToFadeOut = 1000) = 0; + + //! Creates a gravity affector. This affector modifies the direction + //! of the particle. It assumes that the particle is fired out of the + //! emitter with huge force, but is loosing this after some time + //! and is catched by the gravity then. This affector is ideal for + //! creating things like fountains. + //! \param gravity: Direction and force of gravity. + //! \param timeForceLost: Time in milli seconds when the force + //! of the emitter is totally lost and the particle does not move any more. + //! This is the time where gravity fully affects the particle. + //! \return Returns a pointer to the created particle affector. + //! To add this affector as new affector of this particle system, + //! just call addAffector(). Note that you'll have to drop() the + //! returned pointer, after you don't need it any more, see + //! IUnknown::drop() for more informations. + virtual IParticleAffector* createGravityAffector( + const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), + u32 timeForceLost = 1000) = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/IQ3LevelMesh.h b/src/dep/include/irrlicht/IQ3LevelMesh.h index 4906387..0bbc510 100644 --- a/src/dep/include/irrlicht/IQ3LevelMesh.h +++ b/src/dep/include/irrlicht/IQ3LevelMesh.h @@ -1,45 +1,45 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_Q3_LEVEL_MESH_H_INCLUDED__ -#define __I_Q3_LEVEL_MESH_H_INCLUDED__ - -#include "IAnimatedMesh.h" -#include "IQ3Shader.h" - -namespace irr -{ -namespace scene -{ - //! Interface for a Mesh wich can be loaded directly from a Quake3 .bsp-file. - /** The Mesh tries to load all textures of the map. There are currently - no additional methods in this class, but maybe there will be some in later - releases if there are feature requests. */ - class IQ3LevelMesh : public IAnimatedMesh - { - public: - - //! destructor - virtual ~IQ3LevelMesh() {}; - - //! releases a Mesh from the Q3 Loader - virtual void releaseMesh ( s32 index ) = 0; - - //! loads the shader definition - // either from file ( we assume /scripts on fileNameIsValid == 0 ) - virtual const quake3::SShader * getShader ( const c8 * filename, s32 fileNameIsValid ) = 0; - - //! returns a already loaded Shader - virtual const quake3::SShader * getShader ( u32 index ) const = 0; - - //! get's an interface to the entities - virtual const quake3::tQ3EntityList & getEntityList () = 0; - - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_Q3_LEVEL_MESH_H_INCLUDED__ +#define __I_Q3_LEVEL_MESH_H_INCLUDED__ + +#include "IAnimatedMesh.h" +#include "IQ3Shader.h" + +namespace irr +{ +namespace scene +{ + //! Interface for a Mesh wich can be loaded directly from a Quake3 .bsp-file. + /** The Mesh tries to load all textures of the map. There are currently + no additional methods in this class, but maybe there will be some in later + releases if there are feature requests. */ + class IQ3LevelMesh : public IAnimatedMesh + { + public: + + //! destructor + virtual ~IQ3LevelMesh() {}; + + //! releases a Mesh from the Q3 Loader + virtual void releaseMesh ( s32 index ) = 0; + + //! loads the shader definition + // either from file ( we assume /scripts on fileNameIsValid == 0 ) + virtual const quake3::SShader * getShader ( const c8 * filename, s32 fileNameIsValid ) = 0; + + //! returns a already loaded Shader + virtual const quake3::SShader * getShader ( u32 index ) const = 0; + + //! get's an interface to the entities + virtual const quake3::tQ3EntityList & getEntityList () = 0; + + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IQ3Shader.h b/src/dep/include/irrlicht/IQ3Shader.h index a34f708..7db03fa 100644 --- a/src/dep/include/irrlicht/IQ3Shader.h +++ b/src/dep/include/irrlicht/IQ3Shader.h @@ -1,602 +1,602 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_Q3_LEVEL_SHADER_H_INCLUDED__ -#define __I_Q3_LEVEL_SHADER_H_INCLUDED__ - -#include "irrArray.h" -#include "fast_atof.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "coreutil.h" - -namespace irr -{ -namespace scene -{ -namespace quake3 -{ - - //! Hold the different Mesh Types used for getMesh - enum eQ3MeshIndex - { - E_Q3_MESH_GEOMETRY = 0, - E_Q3_MESH_ITEMS, - E_Q3_MESH_BILLBOARD, - E_Q3_MESH_SIZE - }; - - // we are not using gamma, so quake3 is very dark. - // define the standard multiplication for lightmaps and vertex colors - const video::E_MATERIAL_TYPE defaultLightMap = video::EMT_LIGHTMAP_M2; - const video::E_MODULATE_FUNC defaultModulate = video::EMFN_MODULATE_2X; - - // some useful typedefs - typedef core::array< core::stringc > tStringList; - typedef core::array< video::ITexture* > tTexArray; - - // name = "a b c .." - struct SVariable - { - core::stringc name; - core::stringc content; - - void clear () - { - name = core::irrEmtpyStringc; - content = core::irrEmtpyStringc; - } - - s32 isValid () const - { - return name.size(); - } - - bool operator < ( const SVariable &other ) const - { - return name < other.name; - } - }; - - // string helper.. TODO: move to generic files - inline s32 isEqual ( const core::stringc &string, u32 &pos, const c8 *list[], u32 listSize ) - { - const char * in = string.c_str () + pos; - - for ( u32 i = 0; i != listSize; ++i ) - { - if (string.size() < pos) - return -2; - u32 len = (u32) strlen ( list[i] ); - if (string.size() < pos+len) - continue; - if ( in [len] != 0 && in [len] != ' ' ) - continue; - if ( strncmp ( in, list[i], len ) ) - continue; - - pos += len + 1; - return (s32) i; - } - return -2; - } - - inline f32 getAsFloat ( const core::stringc &string, u32 &pos ) - { - const char * in = string.c_str () + pos; - - f32 value = 0.f; - pos += (u32) ( core::fast_atof_move ( in, value ) - in ) + 1; - return value; - } - - inline core::vector3df getAsVector3df ( const core::stringc &string, u32 &pos ) - { - core::vector3df v; - - v.X = getAsFloat ( string, pos ); - v.Z = getAsFloat ( string, pos ); - v.Y = getAsFloat ( string, pos ); - - return v; - } - - /* - extract substrings - */ - inline void getAsStringList ( tStringList &list, s32 max, const core::stringc &string, u32 &startPos ) - { - list.clear (); - - s32 finish = 0; - s32 endPos; - do - { - endPos = string.findNext ( ' ', startPos ); - if ( endPos == -1 ) - { - finish = 1; - endPos = string.size(); - } - - list.push_back ( string.subString ( startPos, endPos - startPos ) ); - startPos = endPos + 1; - - if ( list.size() >= (u32) max ) - finish = 1; - - } while ( !finish ); - - } - - struct SBlendFunc - { - SBlendFunc () : type ( video::EMT_SOLID ), param ( 0.f ) {} - - video::E_MATERIAL_TYPE type; - f32 param; - }; - - // parses the content of Variable cull - inline bool getBackfaceCulling ( const core::stringc &string ) - { - if ( string.size() == 0 ) - return true; - - bool ret = true; - static const c8 * funclist[] = { "none", "disable" }; - - u32 pos = 0; - switch ( isEqual ( string, pos, funclist, 2 ) ) - { - case 0: - case 1: - ret = false; - break; - } - return ret; - } - - // parses the content of Variable depthfunc - // return a z-test - inline u32 getDepthFunction ( const core::stringc &string ) - { - if ( string.size() == 0 ) - return 1; - - u32 ret = 1; - static const c8 * funclist[] = { "lequal","equal" }; - - u32 pos = 0; - switch ( isEqual ( string, pos, funclist, 2 ) ) - { - case 0: - ret = 1; - case 1: - ret = 2; - break; - } - return ret; - } - - - - // parses the content of Variable blendfunc,alphafunc - inline static void getBlendFunc ( const core::stringc &string, SBlendFunc &blendfunc ) - { - if ( string.size() == 0 ) - return; - - // maps to E_BLEND_FACTOR - static const c8 * funclist[] = - { - "gl_zero", - "gl_one", - "gl_dst_color", - "gl_one_minus_dst_color", - "gl_src_color", - "gl_one_minus_src_color", - "gl_src_alpha", - "gl_one_minus_src_alpha", - "gl_dst_alpha", - "gl_one_minus_dst_alpha", - "gl_src_alpha_sat", - - "add", - "filter", - "blend", - - "ge128", - "gt0" - }; - - - u32 pos = 0; - s32 srcFact = isEqual ( string, pos, funclist, 16 ); - - if ( srcFact < 0 ) - return; - - u32 resolved = 0; - s32 dstFact = isEqual ( string, pos, funclist, 16 ); - - switch ( srcFact ) - { - case video::EBF_ONE: - switch ( dstFact ) - { - // gl_one gl_zero - case video::EBF_ZERO: - blendfunc.type = video::EMT_SOLID; - resolved = 1; - break; - - // gl_one gl_one - case video::EBF_ONE: - blendfunc.type = video::EMT_TRANSPARENT_ADD_COLOR; - resolved = 1; - break; - } break; - - case video::EBF_SRC_ALPHA: - switch ( dstFact ) - { - // gl_src_alpha gl_one_minus_src_alpha - case video::EBF_ONE_MINUS_SRC_ALPHA: - blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - blendfunc.param = 1.f / 255.f; - resolved = 1; - break; - } break; - - case 11: - // add - blendfunc.type = video::EMT_TRANSPARENT_ADD_COLOR; - resolved = 1; - break; - case 12: - // filter = gl_dst_color gl_zero - blendfunc.type = video::EMT_ONETEXTURE_BLEND; - blendfunc.param = video::pack_texureBlendFunc ( video::EBF_DST_COLOR, video::EBF_ZERO, defaultModulate ); - resolved = 1; - break; - case 13: - // blend - blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - blendfunc.param = 1.f / 255.f; - resolved = 1; - break; - case 14: - // alphafunc ge128 - blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; - blendfunc.param = 0.5f; - resolved = 1; - break; - case 15: - // alphafunc gt0 - blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; - blendfunc.param = 1.f / 255.f; - resolved = 1; - break; - } - - // use the generic blender - if ( 0 == resolved ) - { - blendfunc.type = video::EMT_ONETEXTURE_BLEND; - blendfunc.param = video::pack_texureBlendFunc ( - (video::E_BLEND_FACTOR) srcFact, - (video::E_BLEND_FACTOR) dstFact, - defaultModulate); - } - } - - struct SModifierFunction - { - SModifierFunction () - : masterfunc0 ( 0 ), masterfunc1(0), func ( 0 ), - tcgen( 8 ), base ( 0 ), amp ( 1 ), phase ( 0 ), freq ( 1 ), wave(1) {} - - // "tcmod","deformvertexes","rgbgen", "tcgen" - s32 masterfunc0; - // depends - s32 masterfunc1; - // depends - s32 func; - - s32 tcgen; - - union - { - f32 base; - f32 bulgewidth; - }; - - union - { - f32 amp; - f32 bulgeheight; - }; - - f32 phase; - - union - { - f32 freq; - f32 bulgespeed; - }; - - f32 wave; - - f32 evaluate ( f32 dt ) const - { - // phase in 0 and 1.. - f32 x = core::fract( (dt + phase ) * freq ); - f32 y = 0.f; - - switch ( func ) - { - // sin - case 0: - y = (f32) sin ( x * core::PI64 * 2.0 ); - break; - // cos - case 1: - y = (f32) cos ( x * core::PI64 * 2.0 ); - break; - // square - case 2: - y = x < 0.5f ? 1.f : -1.f; - break; - // triangle - case 3: - y = x < 0.5f ? ( 2.f * x ) - 1.f : ( -2.f * x ) + 2.f; - break; - // sawtooth: - case 4: - y = x; - break; - // inverse sawtooth: - case 5: - y = 1.f - x; - break; - } - - return base + ( y * amp ); - } - - - }; - - // - inline void getModifierFunc ( SModifierFunction& fill, const core::stringc &string, u32 &pos ) - { - if ( string.size() == 0 ) - return; - - static const c8 * funclist[] = - { - "sin","cos","square", "triangle", "sawtooth","inversesawtooth" - }; - - fill.func = quake3::isEqual ( string,pos, funclist,6 ); - if ( fill.func == -2 ) - fill.func = 0; - - fill.base = quake3::getAsFloat ( string, pos ); - fill.amp = quake3::getAsFloat ( string, pos ); - fill.phase = quake3::getAsFloat ( string, pos ); - fill.freq = quake3::getAsFloat ( string, pos ); - } - - - - struct SVarGroup - { - // simple assoziative array - s32 getIndex( const c8 * name ) const - { - SVariable search; - search.name = name; - - return Variable.linear_search ( search ); - } - - // searches for Variable name and returns is content - // if Variable is not found a reference to an Empty String is returned - const core::stringc &get( const c8 * name ) const - { - s32 index = getIndex ( name ); - if ( index < 0 ) - return core::irrEmtpyStringc; - - return Variable [ index ].content; - } - - bool isDefined ( const c8 * name, const c8 * content = 0 ) const - { - for ( u32 i = 0; i != Variable.size (); ++i ) - { - if ( 0 == strcmp ( Variable[i].name.c_str(), name ) ) - { - if ( 0 == content ) - return true; - if ( 0 == strcmp ( Variable[i].content.c_str(), content ) ) - return true; - } - } - return false; - } - - core::array < SVariable > Variable; - }; - - struct SVarGroupList: public IUnknown - { - SVarGroupList () {} - virtual ~SVarGroupList () {} - - core::array < SVarGroup > VariableGroup; - }; - - //! A Parsed Shader Holding Variables ordered in Groups - class SShader - { - public: - bool operator < (const SShader &other ) const - { - return name < other.name; - } - - const SVarGroup * getGroup ( u32 stage ) const - { - if ( 0 == VarGroup || stage >= VarGroup->VariableGroup.size () ) - return 0; - - return &VarGroup->VariableGroup [ stage ]; - } - - // id - s32 id; - - // Shader: shader name ( also first variable in first Vargroup ) - // Entity: classname ( variable in Group(1) ) - core::stringc name; - SVarGroupList *VarGroup; // reference - }; - - typedef SShader SEntity; - - typedef core::array < SEntity > tQ3EntityList; - - /* - dump shader like original layout, regardless of internal data holding - no recursive folding.. - */ - inline void dumpVarGroup ( core::stringc &dest, const SVarGroup * group, s32 stack ) - { - core::stringc buf; - s32 i; - - - if ( stack > 0 ) - { - buf = ""; - for ( i = 0; i < stack - 1; ++i ) - buf += '\t'; - - buf += "{\n"; - dest.append ( buf ); - } - - for ( u32 g = 0; g != group->Variable.size(); ++g ) - { - buf = ""; - for ( i = 0; i < stack; ++i ) - buf += '\t'; - - buf += group->Variable[g].name; - buf += " "; - buf += group->Variable[g].content; - buf += "\n"; - dest.append ( buf ); - } - - if ( stack > 1 ) - { - buf = ""; - for ( i = 0; i < stack - 1; ++i ) - buf += '\t'; - - buf += "}\n"; - dest.append ( buf ); - } - - } - - inline core::stringc & dumpShader ( core::stringc &dest, const SShader * shader ) - { - dest = ""; - if ( 0 == shader ) - return dest; - - const SVarGroup * group; - - const u32 size = shader->VarGroup->VariableGroup.size (); - - for ( u32 i = 0; i != size; ++i ) - { - group = &shader->VarGroup->VariableGroup[ i ]; - dumpVarGroup ( dest, group, core::clamp ( (s32) i, 0, 2 ) ); - } - - if ( size <= 1 ) - { - dest.append ( "{\n" ); - } - - dest.append ( "}\n" ); - return dest; - } - - - - /* - quake3 doesn't care much about tga & jpg - load one or multiple files stored in name started at startPos to the texture array textures - if texture is not loaded 0 will be added ( to find missing textures easier) - */ - inline void getTextures ( tTexArray &textures , - const core::stringc &name, u32 &startPos, - io::IFileSystem *fileSystem, - video::IVideoDriver* driver - ) - { - static const char * extension[2] = - { - ".jpg", - ".tga" - }; - - tStringList stringList; - getAsStringList ( stringList, -1, name, startPos ); - - textures.clear(); - - core::stringc loadFile; - for ( u32 i = 0; i!= stringList.size (); ++i ) - { - video::ITexture* texture = 0; - for ( u32 g = 0; g != 2 ; ++g ) - { - irr::core::cutFilenameExtension ( loadFile, stringList[i] ).append ( extension[g] ); - - if ( fileSystem->existFile ( loadFile.c_str() ) ) - { - texture = driver->getTexture( loadFile.c_str () ); - if ( texture ) - { - break; - } - } - } - // take 0 Texture - textures.push_back(texture); - } - } - - - /*! - Manages various Quake3 Shader Styles - */ - class IShaderManager : public irr::IUnknown - { - }; - -} // end namespace quake3 -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_Q3_LEVEL_SHADER_H_INCLUDED__ +#define __I_Q3_LEVEL_SHADER_H_INCLUDED__ + +#include "irrArray.h" +#include "fast_atof.h" +#include "IFileSystem.h" +#include "IVideoDriver.h" +#include "coreutil.h" + +namespace irr +{ +namespace scene +{ +namespace quake3 +{ + + //! Hold the different Mesh Types used for getMesh + enum eQ3MeshIndex + { + E_Q3_MESH_GEOMETRY = 0, + E_Q3_MESH_ITEMS, + E_Q3_MESH_BILLBOARD, + E_Q3_MESH_SIZE + }; + + // we are not using gamma, so quake3 is very dark. + // define the standard multiplication for lightmaps and vertex colors + const video::E_MATERIAL_TYPE defaultLightMap = video::EMT_LIGHTMAP_M2; + const video::E_MODULATE_FUNC defaultModulate = video::EMFN_MODULATE_2X; + + // some useful typedefs + typedef core::array< core::stringc > tStringList; + typedef core::array< video::ITexture* > tTexArray; + + // name = "a b c .." + struct SVariable + { + core::stringc name; + core::stringc content; + + void clear () + { + name = core::irrEmtpyStringc; + content = core::irrEmtpyStringc; + } + + s32 isValid () const + { + return name.size(); + } + + bool operator < ( const SVariable &other ) const + { + return name < other.name; + } + }; + + // string helper.. TODO: move to generic files + inline s32 isEqual ( const core::stringc &string, u32 &pos, const c8 *list[], u32 listSize ) + { + const char * in = string.c_str () + pos; + + for ( u32 i = 0; i != listSize; ++i ) + { + if (string.size() < pos) + return -2; + u32 len = (u32) strlen ( list[i] ); + if (string.size() < pos+len) + continue; + if ( in [len] != 0 && in [len] != ' ' ) + continue; + if ( strncmp ( in, list[i], len ) ) + continue; + + pos += len + 1; + return (s32) i; + } + return -2; + } + + inline f32 getAsFloat ( const core::stringc &string, u32 &pos ) + { + const char * in = string.c_str () + pos; + + f32 value = 0.f; + pos += (u32) ( core::fast_atof_move ( in, value ) - in ) + 1; + return value; + } + + inline core::vector3df getAsVector3df ( const core::stringc &string, u32 &pos ) + { + core::vector3df v; + + v.X = getAsFloat ( string, pos ); + v.Z = getAsFloat ( string, pos ); + v.Y = getAsFloat ( string, pos ); + + return v; + } + + /* + extract substrings + */ + inline void getAsStringList ( tStringList &list, s32 max, const core::stringc &string, u32 &startPos ) + { + list.clear (); + + s32 finish = 0; + s32 endPos; + do + { + endPos = string.findNext ( ' ', startPos ); + if ( endPos == -1 ) + { + finish = 1; + endPos = string.size(); + } + + list.push_back ( string.subString ( startPos, endPos - startPos ) ); + startPos = endPos + 1; + + if ( list.size() >= (u32) max ) + finish = 1; + + } while ( !finish ); + + } + + struct SBlendFunc + { + SBlendFunc () : type ( video::EMT_SOLID ), param ( 0.f ) {} + + video::E_MATERIAL_TYPE type; + f32 param; + }; + + // parses the content of Variable cull + inline bool getBackfaceCulling ( const core::stringc &string ) + { + if ( string.size() == 0 ) + return true; + + bool ret = true; + static const c8 * funclist[] = { "none", "disable" }; + + u32 pos = 0; + switch ( isEqual ( string, pos, funclist, 2 ) ) + { + case 0: + case 1: + ret = false; + break; + } + return ret; + } + + // parses the content of Variable depthfunc + // return a z-test + inline u32 getDepthFunction ( const core::stringc &string ) + { + if ( string.size() == 0 ) + return 1; + + u32 ret = 1; + static const c8 * funclist[] = { "lequal","equal" }; + + u32 pos = 0; + switch ( isEqual ( string, pos, funclist, 2 ) ) + { + case 0: + ret = 1; + case 1: + ret = 2; + break; + } + return ret; + } + + + + // parses the content of Variable blendfunc,alphafunc + inline static void getBlendFunc ( const core::stringc &string, SBlendFunc &blendfunc ) + { + if ( string.size() == 0 ) + return; + + // maps to E_BLEND_FACTOR + static const c8 * funclist[] = + { + "gl_zero", + "gl_one", + "gl_dst_color", + "gl_one_minus_dst_color", + "gl_src_color", + "gl_one_minus_src_color", + "gl_src_alpha", + "gl_one_minus_src_alpha", + "gl_dst_alpha", + "gl_one_minus_dst_alpha", + "gl_src_alpha_sat", + + "add", + "filter", + "blend", + + "ge128", + "gt0" + }; + + + u32 pos = 0; + s32 srcFact = isEqual ( string, pos, funclist, 16 ); + + if ( srcFact < 0 ) + return; + + u32 resolved = 0; + s32 dstFact = isEqual ( string, pos, funclist, 16 ); + + switch ( srcFact ) + { + case video::EBF_ONE: + switch ( dstFact ) + { + // gl_one gl_zero + case video::EBF_ZERO: + blendfunc.type = video::EMT_SOLID; + resolved = 1; + break; + + // gl_one gl_one + case video::EBF_ONE: + blendfunc.type = video::EMT_TRANSPARENT_ADD_COLOR; + resolved = 1; + break; + } break; + + case video::EBF_SRC_ALPHA: + switch ( dstFact ) + { + // gl_src_alpha gl_one_minus_src_alpha + case video::EBF_ONE_MINUS_SRC_ALPHA: + blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL; + blendfunc.param = 1.f / 255.f; + resolved = 1; + break; + } break; + + case 11: + // add + blendfunc.type = video::EMT_TRANSPARENT_ADD_COLOR; + resolved = 1; + break; + case 12: + // filter = gl_dst_color gl_zero + blendfunc.type = video::EMT_ONETEXTURE_BLEND; + blendfunc.param = video::pack_texureBlendFunc ( video::EBF_DST_COLOR, video::EBF_ZERO, defaultModulate ); + resolved = 1; + break; + case 13: + // blend + blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL; + blendfunc.param = 1.f / 255.f; + resolved = 1; + break; + case 14: + // alphafunc ge128 + blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + blendfunc.param = 0.5f; + resolved = 1; + break; + case 15: + // alphafunc gt0 + blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + blendfunc.param = 1.f / 255.f; + resolved = 1; + break; + } + + // use the generic blender + if ( 0 == resolved ) + { + blendfunc.type = video::EMT_ONETEXTURE_BLEND; + blendfunc.param = video::pack_texureBlendFunc ( + (video::E_BLEND_FACTOR) srcFact, + (video::E_BLEND_FACTOR) dstFact, + defaultModulate); + } + } + + struct SModifierFunction + { + SModifierFunction () + : masterfunc0 ( 0 ), masterfunc1(0), func ( 0 ), + tcgen( 8 ), base ( 0 ), amp ( 1 ), phase ( 0 ), freq ( 1 ), wave(1) {} + + // "tcmod","deformvertexes","rgbgen", "tcgen" + s32 masterfunc0; + // depends + s32 masterfunc1; + // depends + s32 func; + + s32 tcgen; + + union + { + f32 base; + f32 bulgewidth; + }; + + union + { + f32 amp; + f32 bulgeheight; + }; + + f32 phase; + + union + { + f32 freq; + f32 bulgespeed; + }; + + f32 wave; + + f32 evaluate ( f32 dt ) const + { + // phase in 0 and 1.. + f32 x = core::fract( (dt + phase ) * freq ); + f32 y = 0.f; + + switch ( func ) + { + // sin + case 0: + y = (f32) sin ( x * core::PI64 * 2.0 ); + break; + // cos + case 1: + y = (f32) cos ( x * core::PI64 * 2.0 ); + break; + // square + case 2: + y = x < 0.5f ? 1.f : -1.f; + break; + // triangle + case 3: + y = x < 0.5f ? ( 2.f * x ) - 1.f : ( -2.f * x ) + 2.f; + break; + // sawtooth: + case 4: + y = x; + break; + // inverse sawtooth: + case 5: + y = 1.f - x; + break; + } + + return base + ( y * amp ); + } + + + }; + + // + inline void getModifierFunc ( SModifierFunction& fill, const core::stringc &string, u32 &pos ) + { + if ( string.size() == 0 ) + return; + + static const c8 * funclist[] = + { + "sin","cos","square", "triangle", "sawtooth","inversesawtooth" + }; + + fill.func = quake3::isEqual ( string,pos, funclist,6 ); + if ( fill.func == -2 ) + fill.func = 0; + + fill.base = quake3::getAsFloat ( string, pos ); + fill.amp = quake3::getAsFloat ( string, pos ); + fill.phase = quake3::getAsFloat ( string, pos ); + fill.freq = quake3::getAsFloat ( string, pos ); + } + + + + struct SVarGroup + { + // simple assoziative array + s32 getIndex( const c8 * name ) const + { + SVariable search; + search.name = name; + + return Variable.linear_search ( search ); + } + + // searches for Variable name and returns is content + // if Variable is not found a reference to an Empty String is returned + const core::stringc &get( const c8 * name ) const + { + s32 index = getIndex ( name ); + if ( index < 0 ) + return core::irrEmtpyStringc; + + return Variable [ index ].content; + } + + bool isDefined ( const c8 * name, const c8 * content = 0 ) const + { + for ( u32 i = 0; i != Variable.size (); ++i ) + { + if ( 0 == strcmp ( Variable[i].name.c_str(), name ) ) + { + if ( 0 == content ) + return true; + if ( 0 == strcmp ( Variable[i].content.c_str(), content ) ) + return true; + } + } + return false; + } + + core::array < SVariable > Variable; + }; + + struct SVarGroupList: public IUnknown + { + SVarGroupList () {} + virtual ~SVarGroupList () {} + + core::array < SVarGroup > VariableGroup; + }; + + //! A Parsed Shader Holding Variables ordered in Groups + class SShader + { + public: + bool operator < (const SShader &other ) const + { + return name < other.name; + } + + const SVarGroup * getGroup ( u32 stage ) const + { + if ( 0 == VarGroup || stage >= VarGroup->VariableGroup.size () ) + return 0; + + return &VarGroup->VariableGroup [ stage ]; + } + + // id + s32 id; + + // Shader: shader name ( also first variable in first Vargroup ) + // Entity: classname ( variable in Group(1) ) + core::stringc name; + SVarGroupList *VarGroup; // reference + }; + + typedef SShader SEntity; + + typedef core::array < SEntity > tQ3EntityList; + + /* + dump shader like original layout, regardless of internal data holding + no recursive folding.. + */ + inline void dumpVarGroup ( core::stringc &dest, const SVarGroup * group, s32 stack ) + { + core::stringc buf; + s32 i; + + + if ( stack > 0 ) + { + buf = ""; + for ( i = 0; i < stack - 1; ++i ) + buf += '\t'; + + buf += "{\n"; + dest.append ( buf ); + } + + for ( u32 g = 0; g != group->Variable.size(); ++g ) + { + buf = ""; + for ( i = 0; i < stack; ++i ) + buf += '\t'; + + buf += group->Variable[g].name; + buf += " "; + buf += group->Variable[g].content; + buf += "\n"; + dest.append ( buf ); + } + + if ( stack > 1 ) + { + buf = ""; + for ( i = 0; i < stack - 1; ++i ) + buf += '\t'; + + buf += "}\n"; + dest.append ( buf ); + } + + } + + inline core::stringc & dumpShader ( core::stringc &dest, const SShader * shader ) + { + dest = ""; + if ( 0 == shader ) + return dest; + + const SVarGroup * group; + + const u32 size = shader->VarGroup->VariableGroup.size (); + + for ( u32 i = 0; i != size; ++i ) + { + group = &shader->VarGroup->VariableGroup[ i ]; + dumpVarGroup ( dest, group, core::clamp ( (s32) i, 0, 2 ) ); + } + + if ( size <= 1 ) + { + dest.append ( "{\n" ); + } + + dest.append ( "}\n" ); + return dest; + } + + + + /* + quake3 doesn't care much about tga & jpg + load one or multiple files stored in name started at startPos to the texture array textures + if texture is not loaded 0 will be added ( to find missing textures easier) + */ + inline void getTextures ( tTexArray &textures , + const core::stringc &name, u32 &startPos, + io::IFileSystem *fileSystem, + video::IVideoDriver* driver + ) + { + static const char * extension[2] = + { + ".jpg", + ".tga" + }; + + tStringList stringList; + getAsStringList ( stringList, -1, name, startPos ); + + textures.clear(); + + core::stringc loadFile; + for ( u32 i = 0; i!= stringList.size (); ++i ) + { + video::ITexture* texture = 0; + for ( u32 g = 0; g != 2 ; ++g ) + { + irr::core::cutFilenameExtension ( loadFile, stringList[i] ).append ( extension[g] ); + + if ( fileSystem->existFile ( loadFile.c_str() ) ) + { + texture = driver->getTexture( loadFile.c_str () ); + if ( texture ) + { + break; + } + } + } + // take 0 Texture + textures.push_back(texture); + } + } + + + /*! + Manages various Quake3 Shader Styles + */ + class IShaderManager : public irr::IUnknown + { + }; + +} // end namespace quake3 +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IReadFile.h b/src/dep/include/irrlicht/IReadFile.h index e79c805..c110e53 100644 --- a/src/dep/include/irrlicht/IReadFile.h +++ b/src/dep/include/irrlicht/IReadFile.h @@ -1,60 +1,60 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_READ_FILE_H_INCLUDED__ -#define __I_READ_FILE_H_INCLUDED__ - -#include "IUnknown.h" - -namespace irr -{ -namespace io -{ - - //! Interface providing read acess to a file. - class IReadFile : public virtual IUnknown - { - public: - - virtual ~IReadFile() {}; - - //! Reads an amount of bytes from the file. - //! \param buffer: Pointer to buffer where to read bytes will be written to. - //! \param sizeToRead: Amount of bytes to read from the file. - //! \return Returns how much bytes were read. - virtual s32 read(void* buffer, u32 sizeToRead) = 0; - - //! Changes position in file, returns true if successful. - //! \param finalPos: Destination position in the file. - //! \param relativeMovement: If set to true, the position in the file is - //! changed relative to current position. Otherwise the position is changed - //! from beginning of file. - //! \return Returns true if successful, otherwise false. - virtual bool seek(s32 finalPos, bool relativeMovement = false) = 0; - - //! Returns size of file. - //! \return Returns the size of the file in bytes. - virtual s32 getSize() = 0; - - //! Returns the current position in the file. - //! \return Returns the current position in the file in bytes. - virtual s32 getPos() = 0; - - //! Returns name of file. - //! \return Returns the file name as zero terminated character string. - virtual const c8* getFileName() = 0; - }; - - //! Internal function, please do not use. - IReadFile* createReadFile(const c8* fileName); - //! Internal function, please do not use. - IReadFile* createLimitReadFile(const c8* fileName, IReadFile* alreadyOpenedFile, s32 areaSize); - //! Internal function, please do not use. - IReadFile* createMemoryReadFile(void* memory, s32 size, const c8* fileName, bool deleteMemoryWhenDropped); - -} // end namespace io -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_READ_FILE_H_INCLUDED__ +#define __I_READ_FILE_H_INCLUDED__ + +#include "IUnknown.h" + +namespace irr +{ +namespace io +{ + + //! Interface providing read acess to a file. + class IReadFile : public virtual IUnknown + { + public: + + virtual ~IReadFile() {}; + + //! Reads an amount of bytes from the file. + //! \param buffer: Pointer to buffer where to read bytes will be written to. + //! \param sizeToRead: Amount of bytes to read from the file. + //! \return Returns how much bytes were read. + virtual s32 read(void* buffer, u32 sizeToRead) = 0; + + //! Changes position in file, returns true if successful. + //! \param finalPos: Destination position in the file. + //! \param relativeMovement: If set to true, the position in the file is + //! changed relative to current position. Otherwise the position is changed + //! from beginning of file. + //! \return Returns true if successful, otherwise false. + virtual bool seek(s32 finalPos, bool relativeMovement = false) = 0; + + //! Returns size of file. + //! \return Returns the size of the file in bytes. + virtual s32 getSize() = 0; + + //! Returns the current position in the file. + //! \return Returns the current position in the file in bytes. + virtual s32 getPos() = 0; + + //! Returns name of file. + //! \return Returns the file name as zero terminated character string. + virtual const c8* getFileName() = 0; + }; + + //! Internal function, please do not use. + IReadFile* createReadFile(const c8* fileName); + //! Internal function, please do not use. + IReadFile* createLimitReadFile(const c8* fileName, IReadFile* alreadyOpenedFile, s32 areaSize); + //! Internal function, please do not use. + IReadFile* createMemoryReadFile(void* memory, s32 size, const c8* fileName, bool deleteMemoryWhenDropped); + +} // end namespace io +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/ISceneCollisionManager.h b/src/dep/include/irrlicht/ISceneCollisionManager.h index 7e7c0d4..249f0d9 100644 --- a/src/dep/include/irrlicht/ISceneCollisionManager.h +++ b/src/dep/include/irrlicht/ISceneCollisionManager.h @@ -1,151 +1,151 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_COLLISION_MANAGER_H_INCLUDED__ -#define __I_SCENE_COLLISION_MANAGER_H_INCLUDED__ - -#include "IUnknown.h" -#include "vector3d.h" -#include "triangle3d.h" -#include "position2d.h" -#include "line3d.h" - -namespace irr -{ - - -namespace scene -{ - class ISceneNode; - class ICameraSceneNode; - class ITriangleSelector; - - //! The Scene Collision Manager provides methods for performing collision tests and picking on scene nodes. - class ISceneCollisionManager : public virtual IUnknown - { - public: - - //! destructor - virtual ~ISceneCollisionManager() {}; - - //! Finds the collision point of a line and lots of triangles, if there is one. - //! \param ray: Line with witch collisions are tested. - //! \param selector: TriangleSelector containing the triangles. It can - //! be created for example using ISceneManager::createTriangleSelector() or - //! ISceneManager::createTriangleOctTreeSelector(). - //! \param outCollisionPoint: If a collision is detected, this will contain the - //! position of the nearest collision. - //! \param outTriangle: If a collision is detected, this will contain the triangle - //! with which the ray collided. - //! \return Returns true if a collision was detected and false if not. - virtual bool getCollisionPoint(const core::line3d& ray, - ITriangleSelector* selector, core::vector3df& outCollisionPoint, - core::triangle3df& outTriangle) = 0; - - //! Collides a moving ellipsoid with a 3d world with gravity and returns - //! the resulting new position of the ellipsoid. This can be used for moving - //! a character in a 3d world: The character will slide at walls and is able - //! to walk up stairs. The method used how to calculate the collision result - //! position is based on the paper "Improved Collision detection and Response" - //! by Kasper Fauerby. - //! \param selector: TriangleSelector containing the triangles of the world. - //! It can be created for example using ISceneManager::createTriangleSelector() or - //! ISceneManager::createTriangleOctTreeSelector(). - //! \param ellipsoidPosition: Position of the ellipsoid. - //! \param ellipsoidRadius: Radius of the ellipsoid. - //! \param ellipsoidDirectionAndSpeed: Direction and speed of - //! the movement of the ellipsoid. - //! \param triout: Optional parameter where the last triangle causing a - //! collision is stored, if there is a collision. - //! \param outFalling: Is set to true if the ellipsoid is falling down, caused - //! by gravity. - //! \param slidingSpeed: DOCUMENTATION NEEDED. - //! \param gravityDirectionAndSpeed: Direction and force of gravity. - //! \return Returns the new position of the ellipsoid. - virtual core::vector3df getCollisionResultPosition( - ITriangleSelector* selector, - const core::vector3df &ellipsoidPosition, - const core::vector3df& ellipsoidRadius, - const core::vector3df& ellipsoidDirectionAndSpeed, - core::triangle3df& triout, - bool& outFalling, - f32 slidingSpeed = 0.0005f, - const core::vector3df& gravityDirectionAndSpeed - = core::vector3df(0.0f, 0.0f, 0.0f)) = 0; - - //! Returns a 3d ray which would go through the 2d screen coodinates. - //! \param pos: Screen coordinates in pixels. - //! \param camera: Camera from which the ray starts. If null, the - //! active camera is used. - //! \return Returns a ray starting from the position of the camera - //! and ending at a length of the far value of the camera at a position - //! which would be behind the 2d screen coodinates. - virtual core::line3d getRayFromScreenCoordinates( - core::position2d pos, ICameraSceneNode* camera = 0) = 0; - - //! Calculates 2d screen position from a 3d position. - //! \param pos: 3D position in world space to be transformed into - //! 2d. - //! \param camera: Camera to be used. If null, the currently active - //! camera is used. - //! \return Returns the 2d screen coordinates which a object in the - //! 3d world would have if it would be rendered to the screen. If the - //! 3d position is behind the camera, it is set to (-10000,-10000). In - //! most cases you can ignore this fact, because if you use this method - //! for drawing a decorator over a 3d object, it will be clipped by the - //! screen borders. - virtual core::position2d getScreenCoordinatesFrom3DPosition( - core::vector3df pos, ICameraSceneNode* camera=0) = 0; - - //! Returns the scene node, which is currently visible under the overgiven - //! screencoordinates, viewed from the currently active camera. The collision - //! tests are done using a bounding box for each scene node. - //! \param pos: Position in pixel screen coordinates, under which the returned - //! scene node will be. - //! \param idBitMask: Only scene nodes with an id with bits set like in this mask - //! will be tested. If the BitMask is 0, this feature is disabled. - //! \param bNoDebugObjects: Doesn't take debug objects into account when true. These - // are scene nodes with IsDebugObject() = true. - //! \return Returns the visible scene node under screen coordinates with matching - //! bits in its id. If there is no scene node under this position, 0 is returned. - virtual ISceneNode* getSceneNodeFromScreenCoordinatesBB(core::position2d pos, - s32 idBitMask=0, bool bNoDebugObjects = false) = 0; - - //! Returns the nearest scene node which collides with a 3d ray and - //! which id matches a bitmask. The collision tests are done using a bounding - //! box for each scene node. - //! \param ray: Line with witch collisions are tested. - //! \param idBitMask: Only scene nodes with an id with bits set like in this mask - //! will be tested. If the BitMask is 0, this feature is disabled. - //! \param bNoDebugObjects: Doesn't take debug objects into account when true. These - // are scene nodes with IsDebugObject() = true. - //! \return Returns the scene node nearest to ray.start, which collides with the - //! ray and matches the idBitMask, if the mask is not null. If no scene - //! node is found, 0 is returned. - virtual ISceneNode* getSceneNodeFromRayBB(core::line3d ray, - s32 idBitMask=0, bool bNoDebugObjects = false) = 0; - - //! Returns the scene node, at which the overgiven camera is looking at and - //! which id matches the bitmask. A ray is simply casted from the position - //! of the camera to the view target position, and all scene nodes are tested - //! against this ray. The collision tests are done using a bounding - //! box for each scene node. - //! \param camera: Camera from which the ray is casted. - //! \param idBitMask: Only scene nodes with an id with bits set like in this mask - //! will be tested. If the BitMask is 0, this feature is disabled. - //! \param bNoDebugObjects: Doesn't take debug objects into account when true. These - // are scene nodes with IsDebugObject() = true. - //! \return Returns the scene node nearest to the camera, which collides with the - //! ray and matches the idBitMask, if the mask is not null. If no scene - //! node is found, 0 is returned. - virtual ISceneNode* getSceneNodeFromCameraBB(ICameraSceneNode* camera, - s32 idBitMask=0, bool bNoDebugObjects = false) = 0; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_SCENE_COLLISION_MANAGER_H_INCLUDED__ +#define __I_SCENE_COLLISION_MANAGER_H_INCLUDED__ + +#include "IUnknown.h" +#include "vector3d.h" +#include "triangle3d.h" +#include "position2d.h" +#include "line3d.h" + +namespace irr +{ + + +namespace scene +{ + class ISceneNode; + class ICameraSceneNode; + class ITriangleSelector; + + //! The Scene Collision Manager provides methods for performing collision tests and picking on scene nodes. + class ISceneCollisionManager : public virtual IUnknown + { + public: + + //! destructor + virtual ~ISceneCollisionManager() {}; + + //! Finds the collision point of a line and lots of triangles, if there is one. + //! \param ray: Line with witch collisions are tested. + //! \param selector: TriangleSelector containing the triangles. It can + //! be created for example using ISceneManager::createTriangleSelector() or + //! ISceneManager::createTriangleOctTreeSelector(). + //! \param outCollisionPoint: If a collision is detected, this will contain the + //! position of the nearest collision. + //! \param outTriangle: If a collision is detected, this will contain the triangle + //! with which the ray collided. + //! \return Returns true if a collision was detected and false if not. + virtual bool getCollisionPoint(const core::line3d& ray, + ITriangleSelector* selector, core::vector3df& outCollisionPoint, + core::triangle3df& outTriangle) = 0; + + //! Collides a moving ellipsoid with a 3d world with gravity and returns + //! the resulting new position of the ellipsoid. This can be used for moving + //! a character in a 3d world: The character will slide at walls and is able + //! to walk up stairs. The method used how to calculate the collision result + //! position is based on the paper "Improved Collision detection and Response" + //! by Kasper Fauerby. + //! \param selector: TriangleSelector containing the triangles of the world. + //! It can be created for example using ISceneManager::createTriangleSelector() or + //! ISceneManager::createTriangleOctTreeSelector(). + //! \param ellipsoidPosition: Position of the ellipsoid. + //! \param ellipsoidRadius: Radius of the ellipsoid. + //! \param ellipsoidDirectionAndSpeed: Direction and speed of + //! the movement of the ellipsoid. + //! \param triout: Optional parameter where the last triangle causing a + //! collision is stored, if there is a collision. + //! \param outFalling: Is set to true if the ellipsoid is falling down, caused + //! by gravity. + //! \param slidingSpeed: DOCUMENTATION NEEDED. + //! \param gravityDirectionAndSpeed: Direction and force of gravity. + //! \return Returns the new position of the ellipsoid. + virtual core::vector3df getCollisionResultPosition( + ITriangleSelector* selector, + const core::vector3df &ellipsoidPosition, + const core::vector3df& ellipsoidRadius, + const core::vector3df& ellipsoidDirectionAndSpeed, + core::triangle3df& triout, + bool& outFalling, + f32 slidingSpeed = 0.0005f, + const core::vector3df& gravityDirectionAndSpeed + = core::vector3df(0.0f, 0.0f, 0.0f)) = 0; + + //! Returns a 3d ray which would go through the 2d screen coodinates. + //! \param pos: Screen coordinates in pixels. + //! \param camera: Camera from which the ray starts. If null, the + //! active camera is used. + //! \return Returns a ray starting from the position of the camera + //! and ending at a length of the far value of the camera at a position + //! which would be behind the 2d screen coodinates. + virtual core::line3d getRayFromScreenCoordinates( + core::position2d pos, ICameraSceneNode* camera = 0) = 0; + + //! Calculates 2d screen position from a 3d position. + //! \param pos: 3D position in world space to be transformed into + //! 2d. + //! \param camera: Camera to be used. If null, the currently active + //! camera is used. + //! \return Returns the 2d screen coordinates which a object in the + //! 3d world would have if it would be rendered to the screen. If the + //! 3d position is behind the camera, it is set to (-10000,-10000). In + //! most cases you can ignore this fact, because if you use this method + //! for drawing a decorator over a 3d object, it will be clipped by the + //! screen borders. + virtual core::position2d getScreenCoordinatesFrom3DPosition( + core::vector3df pos, ICameraSceneNode* camera=0) = 0; + + //! Returns the scene node, which is currently visible under the overgiven + //! screencoordinates, viewed from the currently active camera. The collision + //! tests are done using a bounding box for each scene node. + //! \param pos: Position in pixel screen coordinates, under which the returned + //! scene node will be. + //! \param idBitMask: Only scene nodes with an id with bits set like in this mask + //! will be tested. If the BitMask is 0, this feature is disabled. + //! \param bNoDebugObjects: Doesn't take debug objects into account when true. These + // are scene nodes with IsDebugObject() = true. + //! \return Returns the visible scene node under screen coordinates with matching + //! bits in its id. If there is no scene node under this position, 0 is returned. + virtual ISceneNode* getSceneNodeFromScreenCoordinatesBB(core::position2d pos, + s32 idBitMask=0, bool bNoDebugObjects = false) = 0; + + //! Returns the nearest scene node which collides with a 3d ray and + //! which id matches a bitmask. The collision tests are done using a bounding + //! box for each scene node. + //! \param ray: Line with witch collisions are tested. + //! \param idBitMask: Only scene nodes with an id with bits set like in this mask + //! will be tested. If the BitMask is 0, this feature is disabled. + //! \param bNoDebugObjects: Doesn't take debug objects into account when true. These + // are scene nodes with IsDebugObject() = true. + //! \return Returns the scene node nearest to ray.start, which collides with the + //! ray and matches the idBitMask, if the mask is not null. If no scene + //! node is found, 0 is returned. + virtual ISceneNode* getSceneNodeFromRayBB(core::line3d ray, + s32 idBitMask=0, bool bNoDebugObjects = false) = 0; + + //! Returns the scene node, at which the overgiven camera is looking at and + //! which id matches the bitmask. A ray is simply casted from the position + //! of the camera to the view target position, and all scene nodes are tested + //! against this ray. The collision tests are done using a bounding + //! box for each scene node. + //! \param camera: Camera from which the ray is casted. + //! \param idBitMask: Only scene nodes with an id with bits set like in this mask + //! will be tested. If the BitMask is 0, this feature is disabled. + //! \param bNoDebugObjects: Doesn't take debug objects into account when true. These + // are scene nodes with IsDebugObject() = true. + //! \return Returns the scene node nearest to the camera, which collides with the + //! ray and matches the idBitMask, if the mask is not null. If no scene + //! node is found, 0 is returned. + virtual ISceneNode* getSceneNodeFromCameraBB(ICameraSceneNode* camera, + s32 idBitMask=0, bool bNoDebugObjects = false) = 0; + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/ISceneManager.h b/src/dep/include/irrlicht/ISceneManager.h index b106cb5..418e2c6 100644 --- a/src/dep/include/irrlicht/ISceneManager.h +++ b/src/dep/include/irrlicht/ISceneManager.h @@ -1,1168 +1,1168 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_MANAGER_H_INCLUDED__ -#define __I_SCENE_MANAGER_H_INCLUDED__ - -#include "irrArray.h" -#include "IUnknown.h" -#include "vector3d.h" -#include "dimension2d.h" -#include "SColor.h" -#include "SMaterial.h" -#include "IEventReceiver.h" -#include "ETerrainElements.h" -#include "ESceneNodeTypes.h" -#include "SceneParameters.h" -#include "IGUIEnvironment.h" - -namespace irr -{ - struct SKeyMap; - -namespace io -{ - class IFileSystem; - class IReadFile; - class IAttributes; - class IWriteFile; -} // end namespace io - -namespace gui -{ - class IGUIFont; - class IGUIFontBitmap; -} // end namespace gui - -namespace video -{ - class IVideoDriver; -} // end namespace video - -namespace scene -{ - //! Enumeration for render passes. - /** A parameter passed to the registerNodeForRendering() method of the ISceneManager, - specifying when the mode wants to be drawn in relation to the other nodes. */ - enum E_SCENE_NODE_RENDER_PASS - { - //! Camera pass. The active view is set up here. - //! The very first pass. - ESNRP_CAMERA, - - //! In this pass, lights are transformed into camera space and added to the driver - ESNRP_LIGHT, - - //! This is used for sky boxes. - ESNRP_SKY_BOX, - - //! All normal objects can use this for registering themselves. - //! This value will never be returned by ISceneManager::getSceneNodeRenderPass(). - //! The scene manager will determine by itself if an object is - //! transparent or solid and register the object as SNRT_TRANSPARENT or - //! SNRT_SOLD automaticly if you call registerNodeForRendering with this - //! value (which is default). Note that it will register the node only as ONE type. - //! If your scene node has both solid and transparent material types register - //! it twice (one time as SNRT_SOLID, the other time as SNRT_TRANSPARENT) and - //! in the render() method call getSceneNodeRenderPass() to find out the current - //! render pass and render only the corresponding parts of the node. - ESNRP_AUTOMATIC, - - //! Solid scene nodes or special scene nodes without materials. - ESNRP_SOLID, - - //! Drawn after the transparent nodes, the time for drawing shadow volumes - ESNRP_SHADOW, - - //! Transparent scene nodes, drawn after shadow nodes. They are sorted from back - //! to front and drawn in that order. - ESNRP_TRANSPARENT, - - //! Scene Nodes with special support - ESNRP_SHADER_0, - ESNRP_SHADER_1, - ESNRP_SHADER_2, - ESNRP_SHADER_3, - ESNRP_SHADER_4, - ESNRP_SHADER_5, - ESNRP_SHADER_6, - ESNRP_SHADER_7, - ESNRP_SHADER_8, - ESNRP_SHADER_9, - ESNRP_SHADER_10, - - //! Never used, value specifing how much parameters there are. - ESNRP_COUNT - }; - - class IMesh; - class IMeshBuffer; - class IAnimatedMesh; - class IMeshCache; - class ISceneNode; - class ICameraSceneNode; - class IAnimatedMeshSceneNode; - class ISceneNodeAnimator; - class ISceneNodeAnimatorCollisionResponse; - class ILightSceneNode; - class IBillboardSceneNode; - class ITerrainSceneNode; - class IMeshSceneNode; - class IMeshLoader; - class ISceneCollisionManager; - class IParticleSystemSceneNode; - class IDummyTransformationSceneNode; - class ITriangleSelector; - class IMetaTriangleSelector; - class IMeshManipulator; - class ITextSceneNode; - class ISceneNodeFactory; - class ISceneNodeAnimatorFactory; - class ISceneUserDataSerializer; - - namespace quake3 - { - class SShader; - } // end namespace quake3 - - //! The Scene Manager manages scene nodes, mesh recources, cameras and all the other stuff. - /** All Scene nodes can be created only here. There is a always growing list of scene - nodes for lots of purposes: Indoor rendering scene nodes like the Octree - (addOctTreeSceneNode()) or the terrain renderer (addTerrainSceneNode()), - different Camera scene nodes (addCameraSceneNode(), addCameraSceneNodeMaya()), - scene nodes for Light (addLightSceneNode()), Billboards (addBillboardSceneNode()) - and so on. - A scene node is a node in the hierachical scene graph. Every scene node may have children, - which are other scene nodes. Children move relative the their parents position. If the parent of a node is not - visible, its children won't be visible, too. In this way, it is for example easily possible - to attach a light to a moving car or to place a walking character on a moving platform - on a moving ship. - The SceneManager is also able to load 3d mesh files of different formats. Take a look - at getMesh() to find out what formats are supported. And if these formats are not enough - use addExternalMeshLoader() to add new formats to the engine. - */ - class ISceneManager : public virtual IUnknown - { - public: - - //! destructor - virtual ~ISceneManager() {}; - - //! Returns pointer to an animateable mesh. Loads the file if not loaded already. - /** - * If you want to remove a loaded mesh from the cache again, use removeMesh(). - * Currently there are the following mesh formats supported: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
FormatDescription
3D Studio (.3ds)Loader for 3D-Studio files which lots of 3D packages are able to export. - * Only static meshes are currently supported by this importer.
Bliz Basic B3D (.b3d)Loader for blitz basic files, developed by Mark Sibly, also supports animations.
Cartography shop 4 (.csm)Cartography Shop is a modeling program for creating architecture and calculating - * lighting. Irrlicht can directly import .csm files thanks to the IrrCSM library - * created by Saurav Mohapatra which is now integrated directly in Irrlicht. - * If you are using this loader, please note that you'll have to set the path - * of the textures before loading .csm files. You can do this using SceneManager->getParameters()->setParameter(scene::CSM_TEXTURE_PATH, - * "path/to/your/textures");
COLLADA (.dae, .xml)COLLADA is an open Digital Asset Exchange Schema for the interactive 3D industry. There are - * exporters and importers for this format available for most of the big 3d packages - * at http://collada.org. Irrlicht can import COLLADA files by using the - * ISceneManager::getMesh() method. COLLADA files need not contain only one single mesh - * but multiple meshes and a whole scene setup with lights, cameras and mesh instances, - * this loader can set up a scene as described by the COLLADA file instead of loading - * and returning one single mesh. By default, this loader behaves like the other loaders - * and does not create instances, but it can be switched into this mode by using - * SceneManager->getParameters()->setParameter(COLLADA_CREATE_SCENE_INSTANCES, true); - * Created scene nodes will be named as the names of the nodes in the - * COLLADA file. The returned mesh is just a dummy object in this mode. Meshes included in - * the scene will be added into the scene manager with the following naming scheme: - * path/to/file/file.dea#meshname. The loading of such meshes is logged. - * Currently, this loader is able to create meshes (made of only polygons), lights, - * and cameras. Materials and animations are currently not supported but this will - * change with future releases. - *
Delgine DeleD (.dmf)DeleD (delgine.com) is a 3D editor and level-editor combined into one and is specifically - * designed for 3D game-development. With this loader, it is possible to directly load - * all geometry is as well as textures and lightmaps from .dmf files. To set texture and - * material paths, see scene::DMF_USE_MATERIALS_DIRS and scene::DMF_TEXTURE_PATH. It is also - * possible to flip the alpha texture by setting scene::DMF_FLIP_ALPHA_TEXTURES to true and - * to set the material transparent reference value by setting scene::DMF_ALPHA_CHANNEL_REF to - * a float between 0 and 1. The loader is - * based on Salvatore Russo's .dmf loader, I just changed some parts of it. Thanks to - * Salvatore for his work and for allowing me to use his code in Irrlicht and put it under Irrlicht's - * license. For newer and more enchanced versions of the loader, take a look at delgine.com. - *
DirectX (.x)Platform independent importer (so not D3D-only) for .x files. Most 3D - * packages can export these natively and there are several tools for them - * available. (e.g. the Maya exporter included in the DX SDK) .x files can - * include skeletal animations and Irrlicht is able to play and display them. - * Currently, Irrlicht only supports uncompressed .x files.
Maya (.obj)Most 3D software can create .obj files which contain static geometry without - * material data. The material files .mtl are also supported. This importer - * for Irrlicht can load them directly.
Milkshape (.ms3d).MS3D files contain models and sometimes skeletal animations from the - * Milkshape 3D modeling and animation software. This importer for Irrlicht - * can display and/or animate these files.
My3D (.my3d).my3D is a flexible 3D file format. The My3DTools contains plug-ins to - * export .my3D files from several 3D packages. With this built-in importer, - * Irrlicht can read and display those files directly. This loader was written - * by Zhuck Dimitry who also created the whole My3DTools package. If you are using this loader, please - * note that you can set the path of the textures before loading .my3d files. - * You can do this using SceneManager->getParameters()->setParameter(scene::MY3D_TEXTURE_PATH, - * "path/to/your/textures");
OCT (.oct)The oct file format contains 3D geometry and lightmaps and can be loaded - * directly by Irrlicht. OCT files
- * can be created by FSRad, Paul Nette's radiosity processor or exported from - * Blender using OCTTools which can be found in the exporters/OCTTools directory - * of the SDK. Thanks to Murphy McCauley for creating all this.
OGRE Meshes (.mesh)Ogre .mesh files contain 3D data for the OGRE 3D engine. Irrlicht can read and - * display them directly with this importer. To define materials for the mesh, - * copy a .material file named like the corresponding .mesh file where the .mesh - * file is. (For example ogrehead.material for ogrehead.mesh). Thanks to Christian Stehno - * who wrote and contributed this loader.
Pulsar LMTools (.lmts)LMTools is a set of tools (Windows & Linux) for creating lightmaps. - * Irrlicht can directly read .lmts files thanks to
- * the importer created by Jonas Petersen. If you are using this loader, please - * note that you can set the path of the textures before loading .lmts files. - * You can do this using SceneManager->getParameters()->setParameter(scene::LMTS_TEXTURE_PATH, - * "path/to/your/textures"); Notes for
- * this version of the loader:
- * - It does not recognice/support user data in the *.lmts files.
- * - The TGAs generated by LMTools don't work in Irrlicht for some reason (the - * textures are upside down). Opening and resaving them in a graphics app will - * solve the problem.
Quake 3 levels (.bsp)Quake 3 is a popular game by IDSoftware, and .pk3 files contain .bsp files - * and textures/lightmaps describing huge
- * prelighted levels. Irrlicht can read .pk3 and .bsp files directly and thus - * render Quake 3 levels directly. Written by Nikolaus Gebhardt enhanced by - * Dean P. Macri with the curved surfaces feature.
Quake 2 models (.md2)Quake 2 models are characters with morph target animation. Irrlicht can - * read, display and animate them directly with this importer.
- * - * To load and display a mesh quickly, just do this: - * \code - * SceneManager->addAnimatedMeshSceneNode( - * SceneManager->getMesh("yourmesh.3ds")); - * \endcode - * If you would like to implement and add your own file format loader to Irrlicht, - * see addExternalMeshLoader(). - * \param filename: Filename of the mesh to load. - * \return Returns NULL if failed and the pointer to the mesh if - * successful. - * This pointer should not be dropped. See IUnknown::drop() for more information. - **/ - virtual IAnimatedMesh* getMesh(const c8* filename) = 0; - - //! Returns an interface to the mesh cache which is shared beween all existing scene managers. - /** With this interface, it is possible to manually add new loaded - meshes (if ISceneManager::getMesh() is not sufficient), to remove them and to iterate - through already loaded meshes. */ - virtual IMeshCache* getMeshCache() = 0; - - //! Returns the video driver. - /** \return Returns pointer to the video Driver. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual video::IVideoDriver* getVideoDriver() = 0; - - //! Returns the active GUIEnvironment - /** \return Returns pointer to the GUIEnvironment - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual gui::IGUIEnvironment* getGUIEnvironment() = 0; - - //! Adds a test scene node for test purposes to the scene. - /** It is a simple cube of (1,1,1) size. - \param size: Size of the cube. - \param parent: Parent of the scene node. Can be NULL if no parent. - \param id: Id of the node. This id can be used to identify the scene node. - \param position: Position of the space relative to its parent where the - scene node will be placed. - \param rotation: Initital rotation of the scene node. - \param scale: Initial scale of the scene node. - \return Returns pointer to the created test scene node. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual ISceneNode* addCubeSceneNode(f32 size=10.0f, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; - - //! Adds a sphere scene node for test purposes to the scene. - /** It is a simple sphere. - \param radius: Radius of the sphere. - \param polyCount: Polycount of the sphere. - \param parent: Parent of the scene node. Can be NULL if no parent. - \param id: Id of the node. This id can be used to identify the scene node. - \param position: Position of the space relative to its parent where the - scene node will be placed. - \param rotation: Initital rotation of the scene node. - \param scale: Initial scale of the scene node. - \return Returns pointer to the created test scene node. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual ISceneNode* addSphereSceneNode(f32 radius=5.0f, s32 polyCount=16, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; - - //! Adds a scene node for rendering an animated mesh model. - /** \param mesh: Pointer to the loaded animated mesh to be displayed. - \param parent: Parent of the scene node. Can be NULL if no parent. - \param id: Id of the node. This id can be used to identify the scene node. - \param position: Position of the space relative to its parent where the - scene node will be placed. - \param rotation: Initital rotation of the scene node. - \param scale: Initial scale of the scene node. - \return Returns pointer to the created scene node. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IAnimatedMeshSceneNode* addAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), - bool alsoAddIfMeshPointerZero=false) = 0; - - //! Adds a scene node for rendering a static mesh. - /** \param mesh: Pointer to the loaded static mesh to be displayed. - \param parent: Parent of the scene node. Can be NULL if no parent. - \param id: Id of the node. This id can be used to identify the scene node. - \param position: Position of the space relative to its parent where the - scene node will be placed. - \param rotation: Initital rotation of the scene node. - \param scale: Initial scale of the scene node. - \return Returns pointer to the created scene node. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IMeshSceneNode* addMeshSceneNode(IMesh* mesh, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), - bool alsoAddIfMeshPointerZero=false) = 0; - - //! Adds a scene node for rendering a animated water surface mesh. - /** Looks really good when the Material type EMT_TRANSPARENT_REFLECTION - is used. - \param waveHeight: Height of the water waves. - \param waveSpeed: Speed of the water waves. - \param waveLength: Lenght of a water wave. - \param mesh: Pointer to the loaded static mesh to be displayed with water waves on it. - \param parent: Parent of the scene node. Can be NULL if no parent. - \param id: Id of the node. This id can be used to identify the scene node. - \param position: Position of the space relative to its parent where the - scene node will be placed. - \param rotation: Initital rotation of the scene node. - \param scale: Initial scale of the scene node. - \return Returns pointer to the created scene node. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual ISceneNode* addWaterSurfaceSceneNode(IMesh* mesh, - f32 waveHeight=2.0f, f32 waveSpeed=300.0f, f32 waveLength=10.0f, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; - - - //! Adds a scene node for rendering using a octtree to the scene graph. - /** This a good method for rendering - scenes with lots of geometry. The Octree is built on the fly from the mesh. - \param mesh: The mesh containing all geometry from which the octtree will be build. - If this animated mesh has more than one frames in it, the first frame is taken. - \param parent: Parent node of the octtree node. - \param id: id of the node. This id can be used to identify the node. - \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node. - If a node gets less polys the this value, it will not be splitted into - smaller nodes. - \return Returns the pointer to the octtree if successful, otherwise 0. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual ISceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, - s32 id=-1, s32 minimalPolysPerNode=256, bool alsoAddIfMeshPointerZero=false) = 0; - - //! Adds a scene node for rendering using a octtree to the scene graph. - /** This a good method for rendering - scenes with lots of geometry. The Octree is built on the fly from the mesh, much - faster then a bsp tree. - \param mesh: The mesh containing all geometry from which the octtree will be build. - \param parent: Parent node of the octtree node. - \param id: id of the node. This id can be used to identify the node. - \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node. - If a node gets less polys the this value, it will not be splitted into - smaller nodes. - \return Returns the pointer to the octtree if successful, otherwise 0. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual ISceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0, - s32 id=-1, s32 minimalPolysPerNode=256, bool alsoAddIfMeshPointerZero=false) = 0; - - //! Adds a camera scene node to the scene graph and sets it as active camera. - /** This camera does not react on user input like for example the one created with - addCameraSceneNodeFPS(). If you want to move or animate it, use animators or the - ISceneNode::setPosition(), ICameraSceneNode::setTarget() etc methods. - \param position: Position of the space relative to its parent where the camera will be placed. - \param lookat: Position where the camera will look at. Also known as target. - \param parent: Parent scene node of the camera. Can be null. If the parent moves, - the camera will move too. - \param id: id of the camera. This id can be used to identify the camera. - \return Returns pointer to interface to camera if successful, otherwise 0. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& lookat = core::vector3df(0,0,100), s32 id=-1) = 0; - - //! Adds a maya style user controlled camera scene node to the scene graph. - /** The maya camera is able to be controlled with the mouse similar - like in the 3D Software Maya by Alias Wavefront. - \param parent: Parent scene node of the camera. Can be null. - \param rotateSpeed: Rotation speed of the camera. - \param zoomSpeed: Zoom speed of the camera. - \param tranlationSpeed: TranslationSpeed of the camera. - \param id: id of the camera. This id can be used to identify the camera. - \return Returns a pointer to the interface of the camera if successful, otherwise 0. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent = 0, - f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 translationSpeed = 1500.0f, s32 id=-1) = 0; - - //! Adds a camera scene node which is able to be controlled with the mouse and keys like in most first person shooters (FPS). - /** Look with the mouse, move with cursor keys. If you do not like the default - key layout, you may want to specify your own. For example to make the camera - be controlled by the cursor keys AND the keys W,A,S, and D, do something - like this: - \code - SKeyMap keyMap[8]; - keyMap[0].Action = EKA_MOVE_FORWARD; - keyMap[0].KeyCode = KEY_UP; - keyMap[1].Action = EKA_MOVE_FORWARD; - keyMap[1].KeyCode = KEY_KEY_W; - - keyMap[2].Action = EKA_MOVE_BACKWARD; - keyMap[2].KeyCode = KEY_DOWN; - keyMap[3].Action = EKA_MOVE_BACKWARD; - keyMap[3].KeyCode = KEY_KEY_S; - - keyMap[4].Action = EKA_STRAFE_LEFT; - keyMap[4].KeyCode = KEY_LEFT; - keyMap[5].Action = EKA_STRAFE_LEFT; - keyMap[5].KeyCode = KEY_KEY_A; - - keyMap[6].Action = EKA_STRAFE_RIGHT; - keyMap[6].KeyCode = KEY_RIGHT; - keyMap[7].Action = EKA_STRAFE_RIGHT; - keyMap[7].KeyCode = KEY_KEY_D; - - camera = sceneManager->addCameraSceneNodeFPS(0, 100, 500, -1, keyMap, 8); - \endcode - \param parent: Parent scene node of the camera. Can be null. - \param rotateSpeed: Speed with wich the camera is rotated. This can be done - only with the mouse. - \param movespeed: Speed with which the camera is moved. Movement is done with - the cursor keys. - \param id: id of the camera. This id can be used to identify the camera. - \param keyMapArray: Optional pointer to an array of a keymap, specifying what - keys should be used to move the camera. If this is null, the default keymap - is used. You can define actions more then one time in the array, to bind - multiple keys to the same action. - \param keyMapSize: Amount of items in the keymap array. - \param noVerticalMovement: Setting this to true makes the camera only move within a - horizontal plane, and disables vertical movement as known from most ego shooters. Default - is 'false', with which it is possible to fly around in space, if no gravity is there. - \return Returns a pointer to the interface of the camera if successful, otherwise 0. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, - f32 rotateSpeed = 100.0f, f32 moveSpeed = 500.0f, s32 id=-1, - SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false, - f32 jumpSpeed = 0.f) = 0; - - //! Adds a dynamic light scene node to the scene graph. - /** The light will cast dynamic light on all - other scene nodes in the scene, which have the material flag video::MTF_LIGHTING - turned on. (This is the default setting in most scene nodes). - \param parent: Parent scene node of the light. Can be null. If the parent moves, - the light will move too. - \param position: Position of the space relative to its parent where the light will be placed. - \param color: Diffuse color of the light. Ambient or Specular colors can be set manually with - the ILightSceneNode::getLightData() method. - \param radius: Radius of the light. - \param id: id of the node. This id can be used to identify the node. - \return Returns pointer to the interface of the light if successful, otherwise NULL. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual ILightSceneNode* addLightSceneNode(ISceneNode* parent = 0, - const core::vector3df& position = core::vector3df(0,0,0), - video::SColorf color = video::SColorf(1.0f, 1.0f, 1.0f), - f32 radius=100.0f, s32 id=-1) = 0; - - //! Adds a billboard scene node to the scene graph. - /** A billboard is like a 3d sprite: A 2d element, - which always looks to the camera. It is usually used for things like explosions, fire, - lensflares and things like that. - \param parent: Parent scene node of the billboard. Can be null. If the parent moves, - the billboard will move too. - \param position: Position of the space relative to its parent where the billboard will be placed. - \param size: Size of the billboard. This size is 2 dimensional because a billboard only has - width and height. - \param id: An id of the node. This id can be used to identify the node. - \param shade_top: vertex color top - \param shade_down: vertex color down - \return Returns pointer to the billboard if successful, otherwise NULL. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IBillboardSceneNode* addBillboardSceneNode(ISceneNode* parent = 0, - const core::dimension2d& size = core::dimension2d(10.0f, 10.0f), - const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, - video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF) = 0; - - //! Adds a skybox scene node to the scene graph. - /** A skybox is a big cube with 6 textures on it and - is drawn around the camera position. - \param top: Texture for the top plane of the box. - \param bottom: Texture for the bottom plane of the box. - \param left: Texture for the left plane of the box. - \param right: Texture for the right plane of the box. - \param front: Texture for the front plane of the box. - \param back: Texture for the back plane of the box. - \param parent: Parent scene node of the skybox. A skybox usually has no parent, - so this should be null. Note: If a parent is set to the skybox, the box will not - change how it is drawn. - \param id: An id of the node. This id can be used to identify the node. - \return Returns a pointer to the sky box if successful, otherwise NULL. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual ISceneNode* addSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, - video::ITexture* left, video::ITexture* right, video::ITexture* front, - video::ITexture* back, ISceneNode* parent = 0, s32 id=-1) = 0; - - //! Adds a skydome scene node to the scene graph. - /** A skydome is a large (half-) sphere with a panoramic texture - on the inside and is drawn around the camera position. - \param texture: Texture for the dome. - \param horiRes: Number of vertices of a horizontal layer of the sphere. - \param vertRes: Number of vertices of a vertical layer of the sphere. - \param texturePercentage: How much of the height of the texture is used. Should be between 0 and 1. - \param spherePercentage: How much of the sphere is drawn. Value should be between 0 and 2, where 1 is an exact half-sphere and 2 is a full sphere. - \param parent: Parent scene node of the dome. A dome usually has no parent, - so this should be null. Note: If a parent is set, the dome will not - change how it is drawn. - \param id: An id of the node. This id can be used to identify the node. - \return Returns a pointer to the sky dome if successful, otherwise NULL. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual ISceneNode* addSkyDomeSceneNode(video::ITexture* texture, - u32 horiRes, u32 vertRes, f64 texturePercentage, f64 spherePercentage, - ISceneNode* parent = 0, s32 id=-1) = 0; - - //! Adds a particle system scene node to the scene graph. - /** \param withDefaultEmitter: Creates a default working point emitter - which emitts some particles. Set this to true to see a particle system - in action. If set to false, you'll have to set the emitter you want by - calling IParticleSystemSceneNode::setEmitter(). - \param parent: Parent of the scene node. Can be NULL if no parent. - \param id: Id of the node. This id can be used to identify the scene node. - \param position: Position of the space relative to its parent where the - scene node will be placed. - \param rotation: Initital rotation of the scene node. - \param scale: Initial scale of the scene node. - \return Returns pointer to the created scene node. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IParticleSystemSceneNode* addParticleSystemSceneNode( - bool withDefaultEmitter=true, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; - - //! Adds a terrain scene node to the scene graph. - /** This node - implements is a simple terrain renderer which uses - a technique known as geo mip mapping - for reducing the detail of triangle blocks which are far away. - The code for the TerrainSceneNode is based on the terrain renderer by Soconne and - the GeoMipMapSceneNode developed by Spintz. They made their code available for Irrlicht - and allowed it to be distributed under this licence. I only modified some parts. - A lot of thanks go to them. - - This scene node is capable of very quickly loading - terrains and updating the indices at runtime to enable viewing very large terrains. It uses a - CLOD (Continuous Level of Detail) algorithm which updates the indices for each patch based on - a LOD (Level of Detail) which is determined based on a patch's distance from the camera. - - The patch size of the terrain must always be a size of ( 2^N+1, i.e. 8+1(9), 16+1(17), etc. ). - The MaxLOD available is directly dependent on the patch size of the terrain. LOD 0 contains all - of the indices to draw all the triangles at the max detail for a patch. As each LOD goes up by 1 - the step taken, in generating indices increases by - 2^LOD, so for LOD 1, the step taken is 2, for - LOD 2, the step taken is 4, LOD 3 - 8, etc. The step can be no larger than the size of the patch, - so having a LOD of 8, with a patch size of 17, is asking the algoritm to generate indices every - 2^8 ( 256 ) vertices, which is not possible with a patch size of 17. The maximum LOD for a patch - size of 17 is 2^4 ( 16 ). So, with a MaxLOD of 5, you'll have LOD 0 ( full detail ), LOD 1 ( every - 2 vertices ), LOD 2 ( every 4 vertices ), LOD 3 ( every 8 vertices ) and LOD 4 ( every 16 vertices ). - \param heightMapFile: The location of the file on disk, to read vertex data from. This should - be a gray scale bitmap. - \param position: The absolute position of this node. - \param rotation: The absolute rotation of this node. ( NOT YET IMPLEMENTED ) - \param scale: The scale factor for the terrain. If you're using a heightmap of size 128x128 and would like - your terrain to be 12800x12800 in game units, then use a scale factor of ( core::vector ( 100.0f, 100.0f, 100.0f ). - If you use a Y scaling factor of 0.0f, then your terrain will be flat. - \param vertexColor: The default color of all the vertices. If no texture is associated - with the scene node, then all vertices will be this color. Defaults to white. - \param maxLOD: The maximum LOD (level of detail) for the node. Only change if you - know what you are doing, this might lead to strange behaviour. - \param patchSize: patch size of the terrain. Only change if you - know what you are doing, this might lead to strange behaviour. - \return Returns pointer to the created scene node. Can be null if the - terrain could not be created, for example because the heightmap could not be loaded. - The returned pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual ITerrainSceneNode* addTerrainSceneNode( - const c8* heightMapFileName, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), - video::SColor vertexColor = video::SColor(255,255,255,255), - s32 maxLOD=5, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17, s32 smoothFactor=0) = 0; - - //! Adds a terrain scene node to the scene graph. - /** Just like the other addTerrainSceneNode() method, but takes an IReadFile - pointer as parameter for the heightmap. For more informations take a look - add the other overload. */ - virtual ITerrainSceneNode* addTerrainSceneNode( - io::IReadFile* heightMapFile, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), - video::SColor vertexColor = video::SColor(255,255,255,255), - s32 maxLOD=5, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17, s32 smoothFactor=0) = 0; - - //! Adds a quake3 scene node to the scene graph. - /** A Quake3 Scene renders multiple meshes for a specific HighLanguage Shader (Quake3 Style ) - \return Returns a pointer to the quake3 scene node if successful, otherwise NULL. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual ISceneNode* addQuake3SceneNode(IMeshBuffer* meshBuffer, const quake3::SShader * shader, - ISceneNode* parent=0, s32 id=-1 - ) = 0; - - - //! Adds an empty scene node to the scene graph. - /** Can be used for doing advanced transformations - or structuring the scene graph. - \return Returns pointer to the created scene node. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual ISceneNode* addEmptySceneNode(ISceneNode* parent=0, s32 id=-1) = 0; - - //! Adds a dummy transformation scene node to the scene graph. - /** This scene node does not render itself, and does not respond to set/getPosition, - set/getRotation and set/getScale. Its just a simple scene node that takes a - matrix as relative transformation, making it possible to insert any transformation - anywhere into the scene graph. - \return Returns pointer to the created scene node. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IDummyTransformationSceneNode* addDummyTransformationSceneNode( - ISceneNode* parent=0, s32 id=-1) = 0; - - //! Adds a text scene node, which is able to display 2d text at a position in three dimensional space - virtual ITextSceneNode* addTextSceneNode(gui::IGUIFont* font, const wchar_t* text, - video::SColor color=video::SColor(100,255,255,255), - ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0), - s32 id=-1) = 0; - - //! Adds a text scene node, which uses billboards - virtual ITextSceneNode* addBillboardTextSceneNode( gui::IGUIFont* font, const wchar_t* text, - ISceneNode* parent = 0, - const core::dimension2d& size = core::dimension2d(10.0f, 10.0f), - const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, - video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF) = 0; - - //! Adds a Hill Plane mesh to the mesh pool. - /** The mesh is generated on the fly - and looks like a plane with some hills on it. It is uses mostly for quick - tests of the engine only. You can specify how many hills there should be - on the plane and how high they should be. Also you must specify a name for - the mesh, because the mesh is added to the mesh pool, and can be retieved - again using ISceneManager::getMesh() with the name as parameter. - \param name: The name of this mesh which must be specified in order - to be able to retrieve the mesh later with ISceneManager::getMesh(). - \param tileSize: Size of a tile of the mesh. (10.0f, 10.0f) would be a - good value to start, for example. - \param tileCount: Specifies how much tiles there will be. If you specifiy - for example that a tile has the size (10.0f, 10.0f) and the tileCount is - (10,10), than you get a field of 100 tiles wich has the dimension 100.0fx100.0f. - \param material: Material of the hill mesh. - \param hillHeight: Height of the hills. If you specify a negative value - you will get holes instead of hills. If the height is 0, no hills will be - created. - \param countHills: Amount of hills on the plane. There will be countHills.X - hills along the X axis and countHills.Y along the Y axis. So in total there - will be countHills.X * countHills.Y hills. - \param textureRepeatCount: Defines how often the texture will be repeated in - x and y direction. - \return Returns null if the creation failed. The reason could be that you - specified some invalid parameters or that a mesh with that name already - exists. If successful, a pointer to the mesh is returned. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IAnimatedMesh* addHillPlaneMesh(const c8* name, - const core::dimension2d& tileSize, const core::dimension2d& tileCount, - video::SMaterial* material = 0, f32 hillHeight = 0.0f, - const core::dimension2d& countHills = core::dimension2d(0.0f, 0.0f), - const core::dimension2d& textureRepeatCount = core::dimension2d(1.0f, 1.0f)) = 0; - - //! Adds a static terrain mesh to the mesh pool. - /** The mesh is generated on the fly - from a texture file and a height map file. Both files may be huge - (8000x8000 pixels would be no problem) because the generator splits the - files into smaller textures if necessary. - You must specify a name for the mesh, because the mesh is added to the mesh pool, - and can be retieved again using ISceneManager::getMesh() with the name as parameter. - \param meshname: The name of this mesh which must be specified in order - to be able to retrieve the mesh later with ISceneManager::getMesh(). - \param texture: Texture for the terrain. Please note that this is not a - hardware texture as usual (ITexture), but an IImage software texture. - You can load this texture with IVideoDriver::createImageFromFile(). - \param heightmap: A grayscaled heightmap image. Like the texture, - it can be created with IVideoDriver::createImageFromFile(). The amount - of triangles created depends on the size of this texture, so use a small - heightmap to increase rendering speed. - \param stretchSize: Parameter defining how big a is pixel on the heightmap. - \param maxHeight: Defines how height a white pixel on the heighmap is. - \return Returns null if the creation failed. The reason could be that you - specified some invalid parameters, that a mesh with that name already - exists, or that a texture could not be found. If successful, a pointer to the mesh is returned. - This pointer should not be dropped. See IUnknown::drop() for more information. */ - virtual IAnimatedMesh* addTerrainMesh(const c8* meshname, - video::IImage* texture, video::IImage* heightmap, - const core::dimension2d& stretchSize = core::dimension2d(10.0f,10.0f), - f32 maxHeight=200.0f, - const core::dimension2d& defaultVertexBlockSize = core::dimension2d(64,64)) = 0; - - //! add a static arrow mesh to the meshpool - /** it quite usefull for debuggin purposes. ( showing directions eq ) - */ - virtual IAnimatedMesh* addArrowMesh(const c8* name, u32 tesselationCylinder, u32 tesselationCone, f32 height, - f32 cylinderHeight, f32 width0,f32 width1, - video::SColor vtxColor0, video::SColor vtxColor1) = 0; - - //! Returns the root scene node. - /** This is the scene node wich is parent - of all scene nodes. The root scene node is a special scene node which - only exists to manage all scene nodes. It will not be rendered and cannot - be removed from the scene. - \return Returns a pointer to the root scene node. */ - virtual ISceneNode* getRootSceneNode() = 0; - - //! Returns the first scene node with the specified id. - /** \param id: The id to search for - \param start: Scene node to start from. All children of this scene - node are searched. If null is specified, the root scene node is - taken. - \return Returns pointer to the first scene node with this id, - and null if no scene node could be found. */ - virtual ISceneNode* getSceneNodeFromId(s32 id, ISceneNode* start=0) = 0; - - //! Returns the first scene node with the specified name. - /**\param start: Scene node to start from. All children of this scene - node are searched. If null is specified, the root scene node is - taken. - \return Returns pointer to the first scene node with this id, - and null if no scene node could be found. */ - virtual ISceneNode* getSceneNodeFromName(const c8* name, ISceneNode* start=0) = 0; - - //! Returns the current active camera. - /** \return The active camera is returned. Note that this can be NULL, if there - was no camera created yet. */ - virtual ICameraSceneNode* getActiveCamera() = 0; - - //! Sets the currently active camera. - /** The previous active camera will be deactivated. - \param camera: The new camera which should be active. */ - virtual void setActiveCamera(ICameraSceneNode* camera) = 0; - - //! Sets the color of stencil buffers shadows drawn by the scene manager. - virtual void setShadowColor(video::SColor color = video::SColor(150,0,0,0)) = 0; - - //! Returns the current color of shadows. - virtual video::SColor getShadowColor() const = 0; - - //! Registers a node for rendering it at a specific time. - /** This method should only be used by SceneNodes when they get a - ISceneNode::OnRegisterSceneNode() call. - \param node: Node to register for drawing. Usually scene nodes would set 'this' - as parameter here because they want to be drawn. - \param pass: Specifies when the mode wants to be drawn in relation to the other nodes. - For example, if the node is a shadow, it usually wants to be drawn after all other nodes - and will use ESNRP_SHADOW for this. See E_SCENE_NODE_RENDER_PASS for details. - \return scene will be rendered ( passed culling ) */ - virtual u32 registerNodeForRendering(ISceneNode* node, - E_SCENE_NODE_RENDER_PASS pass = ESNRP_AUTOMATIC) = 0; - - //! Draws all the scene nodes. - /** This can only be invoked between - IVideoDriver::beginScene() and IVideoDriver::endScene(). Please note that - the scene is not only drawn when calling this, but also animated - by existing scene node animators, culling of scene nodes is done, etc. */ - virtual void drawAll() = 0; - - //! Creates a rotation animator, which rotates the attached scene node around itself. - /** \param rotationPerSecond: Specifies the speed of the animation - \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() - and the animator will animate it. - If you no longer need the animator, you should call ISceneNodeAnimator::drop(). - See IUnknown::drop() for more information. */ - virtual ISceneNodeAnimator* createRotationAnimator(const core::vector3df& rotationPerSecond) = 0; - - //! Creates a fly circle animator, which lets the attached scene node fly around a center. - /** \param center: Center of the circle. - \param radius: Radius of the circle. - \param speed: Specifies the speed of the flight. - \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() - and the animator will animate it. - If you no longer need the animator, you should call ISceneNodeAnimator::drop(). - See IUnknown::drop() for more information. */ - virtual ISceneNodeAnimator* createFlyCircleAnimator(const core::vector3df& center, - f32 radius, f32 speed=0.001f, const core::vector3df& direction= core::vector3df ( 0.f, 1.f, 0.f ) ) = 0; - - //! Creates a fly straight animator, which lets the attached scene node fly or move along a line between two points. - /** \param startPoint: Start point of the line. - \param endPoint: End point of the line. - \param timeForWay: Time in milli seconds how long the node should need to - move from the start point to the end point. - \param loop: If set to false, the node stops when the end point is reached. - If loop is true, the node begins again at the start. - \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() - and the animator will animate it. - If you no longer need the animator, you should call ISceneNodeAnimator::drop(). - See IUnknown::drop() for more information. */ - virtual ISceneNodeAnimator* createFlyStraightAnimator(const core::vector3df& startPoint, - const core::vector3df& endPoint, u32 timeForWay, bool loop=false) = 0; - - //! Creates a texture animator, which switches the textures of the target scene node based on a list of textures. - /** \param textures: List of textures to use. - \param timePerFrame: Time in milliseconds, how long any texture in the list - should be visible. - \param loop: If set to to false, the last texture remains set, and the animation - stops. If set to true, the animation restarts with the first texture. - \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() - and the animator will animate it. - If you no longer need the animator, you should call ISceneNodeAnimator::drop(). - See IUnknown::drop() for more information. */ - virtual ISceneNodeAnimator* createTextureAnimator(const core::array& textures, - s32 timePerFrame, bool loop=true) = 0; - - //! Creates a scene node animator, which deletes the scene node after some time automatically. - /** \param timeMs: Time in milliseconds, after when the node will be deleted. - \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() - and the animator will animate it. - If you no longer need the animator, you should call ISceneNodeAnimator::drop(). - See IUnknown::drop() for more information. */ - virtual ISceneNodeAnimator* createDeleteAnimator(u32 timeMs) = 0; - - //! Creates a special scene node animator for doing automatic collision detection and response. - /** See ISceneNodeAnimatorCollisionResponse for details. - \param world: Triangle selector holding all triangles of the world with which - the scene node may collide. You can create a triangle selector with - ISceneManager::createTriangleSelector(); - \param sceneNode: SceneNode which should be manipulated. After you added this animator - to the scene node, the scene node will not be able to move through walls and is - affected by gravity. - \param ellipsoidRadius: Radius of the ellipsoid with which collision detection and - response is done. If you have got a scene node, and you are unsure about - how big the radius should be, you could use the following code to determine - it: - \code - core::aabbox box = yourSceneNode->getBoundingBox(); - core::vector3df radius = box.MaxEdge - box.getCenter(); - \endcode - \param gravityPerSecond: Sets the gravity of the environment. A good example value would be - core::vector3df(0,-100.0f,0) for letting gravity affect all object to - fall down. For bigger gravity, make increase the length of the vector. - You can disable gravity by setting it to core::vector3df(0,0,0). - \param ellipsoidTranslation: By default, the ellipsoid for collision detection is created around - the center of the scene node, which means that the ellipsoid surrounds - it completely. If this is not what you want, you may specify a translation - for the ellipsoid. - \param slidingValue: DOCUMENTATION NEEDED. - \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() - and the animator will cause it to do collision detection and response. - If you no longer need the animator, you should call ISceneNodeAnimator::drop(). - See IUnknown::drop() for more information. */ - virtual ISceneNodeAnimatorCollisionResponse* createCollisionResponseAnimator( - ITriangleSelector* world, ISceneNode* sceneNode, - const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30), - const core::vector3df& gravityPerSecond = core::vector3df(0,-100.0f,0), - const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0), - f32 slidingValue = 0.0005f) = 0; - - //! Creates a follow spline animator. - /** The animator modifies the position of - the attached scene node to make it follow a hermite spline. - The code of the is based on a scene node - Matthias Gall sent in. Thanks! I adapted the code just a little bit. Matthias - wrote: - Uses a subset of hermite splines: either cardinal splines (tightness != 0.5) or catmull-rom-splines (tightness == 0.5) - but this is just my understanding of this stuff, I'm not a mathematician, so this might be wrong ;) */ - virtual ISceneNodeAnimator* createFollowSplineAnimator(s32 startTime, - const core::array< core::vector3df >& points, - f32 speed = 1.0f, f32 tightness = 0.5f) = 0; - - //! Creates a simple ITriangleSelector, based on a mesh. - /** Triangle selectors - can be used for doing collision detection. Don't use this selector - for a huge amount of triangles like in Quake3 maps. - Instead, use for example ISceneManager::createOctTreeTriangleSelector(). - Please note that the created triangle selector is not automaticly attached - to the scene node. You will have to call ISceneNode::setTriangleSelector() - for this. To create and attach a triangle selector is done like this: - \code - ITriangleSelector* s = sceneManager->createTriangleSelector(yourMesh, - yourSceneNode); - yourSceneNode->setTriangleSelector(s); - s->drop(); - \endcode - \param mesh: Mesh of which the triangles are taken. - \param node: Scene node of which visibility and transformation is used. - \return Returns the selector, or null if not successful. - If you no longer need the selector, you should call ITriangleSelector::drop(). - See IUnknown::drop() for more information. */ - virtual ITriangleSelector* createTriangleSelector(IMesh* mesh, ISceneNode* node) = 0; - - //! Creates a simple dynamic ITriangleSelector, based on a axis aligned bounding box. - /** Triangle selectors - can be used for doing collision detection. Every time when triangles are - queried, the triangle selector gets the bounding box of the scene node, - an creates new triangles. In this way, it works good with animated scene nodes. - \param node: Scene node of which the bounding box, visibility and transformation is used. - \return Returns the selector, or null if not successful. - If you no longer need the selector, you should call ITriangleSelector::drop(). - See IUnknown::drop() for more information. */ - virtual ITriangleSelector* createTriangleSelectorFromBoundingBox(ISceneNode* node) = 0; - - //! Creates a Triangle Selector, optimized by an octtree. - /** Triangle selectors - can be used for doing collision detection. This triangle selector is - optimized for huge amounts of triangle, it organizes them in an octtree. - Please note that the created triangle selector is not automaticly attached - to the scene node. You will have to call ISceneNode::setTriangleSelector() - for this. To create and attach a triangle selector is done like this: - \code - ITriangleSelector* s = sceneManager->createOctTreeTriangleSelector(yourMesh, - yourSceneNode); - yourSceneNode->setTriangleSelector(s); - s->drop(); - \endcode - For more informations and examples on this, take a look at the collision - tutorial in the SDK. - \param mesh: Mesh of which the triangles are taken. - \param node: Scene node of which visibility and transformation is used. - \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node. - If a node gets less polys the this value, it will not be splitted into - smaller nodes. - \return Returns the selector, or null if not successful. - If you no longer need the selector, you should call ITriangleSelector::drop(). - See IUnknown::drop() for more information. */ - virtual ITriangleSelector* createOctTreeTriangleSelector(IMesh* mesh, - ISceneNode* node, s32 minimalPolysPerNode=32) = 0; - - //! Creates a meta triangle selector. - /** A meta triangle selector is nothing more than a - collection of one or more triangle selectors providing together - the interface of one triangle selector. In this way, - collision tests can be done with different triangle soups in one pass. - \return Returns the selector, or null if not successful. - If you no longer need the selector, you should call ITriangleSelector::drop(). - See IUnknown::drop() for more information. */ - virtual IMetaTriangleSelector* createMetaTriangleSelector() = 0; - - //! Creates a triangle selector which can select triangles from a terrain scene node. - /** \param: Pointer to the created terrain scene node - \param: Level of detail, 0 for highest detail. */ - virtual ITriangleSelector* createTerrainTriangleSelector( - ITerrainSceneNode* node, s32 LOD=0) = 0; - - //! Adds an external mesh loader for extending the engine with new file formats. - /** If you want the engine to be extended with - file formats it currently is not able to load (e.g. .cob), just implement - the IMeshLoader interface in your loading class and add it with this method. - Using this method it is also possible to override built-in mesh loaders with - newer or updated versions without the need of recompiling the engine. - \param externalLoader: Implementation of a new mesh loader. */ - virtual void addExternalMeshLoader(IMeshLoader* externalLoader) = 0; - - //! Returns a pointer to the scene collision manager. - virtual ISceneCollisionManager* getSceneCollisionManager() = 0; - - //! Returns a pointer to the mesh manipulator. - virtual IMeshManipulator* getMeshManipulator() = 0; - - //! Adds a scene node to the deletion queue. - /** The scene node is immediatly - deleted when it's secure. Which means when the scene node does not - execute animators and things like that. This method is for example - used for deleting scene nodes by their scene node animators. In - most other cases, a ISceneNode::remove() call is enough, using this - deletion queue is not necessary. - See ISceneManager::createDeleteAnimator() for details. - \param node: Node to detete. */ - virtual void addToDeletionQueue(ISceneNode* node) = 0; - - //! Posts an input event to the environment. - /** Usually you do not have to - use this method, it is used by the internal engine. */ - virtual bool postEventFromUser(SEvent event) = 0; - - //! Clears the whole scene. - /** All scene nodes are removed. */ - virtual void clear() = 0; - - //! Returns interface to the parameters set in this scene. - /** String parameters can be used by plugins and mesh loaders. - For example the CMS and LMTS loader want a parameter named 'CSM_TexturePath' - and 'LMTS_TexturePath' set to the path were attached textures can be found. See - CSM_TEXTURE_PATH, LMTS_TEXTURE_PATH, MY3D_TEXTURE_PATH, - COLLADA_CREATE_SCENE_INSTANCES, DMF_TEXTURE_PATH and DMF_USE_MATERIALS_DIRS*/ - virtual io::IAttributes* getParameters() = 0; - - //! Returns current render pass. - /** All scene nodes are being rendered in a specific order. - First lights, cameras, sky boxes, solid geometry, and then transparent - stuff. During the rendering process, scene nodes may want to know what the scene - manager is rendering currently, because for example they registered for rendering - twice, once for transparent geometry and once for solid. When knowing what rendering - pass currently is active they can render the correct part of their geometry. */ - virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() = 0; - - //! Returns the default scene node factory which can create all built in scene nodes - virtual ISceneNodeFactory* getDefaultSceneNodeFactory() = 0; - - //! Adds a scene node factory to the scene manager. - /** Use this to extend the scene manager with new scene node types which it should be - able to create automaticly, for example when loading data from xml files. */ - virtual void registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd) = 0; - - //! Returns amount of registered scene node factories. - virtual s32 getRegisteredSceneNodeFactoryCount() = 0; - - //! Returns a scene node factory by index - virtual ISceneNodeFactory* getSceneNodeFactory(s32 index) = 0; - - //! Returns the default scene node animator factory which can create all built-in scene node animators - virtual ISceneNodeAnimatorFactory* getDefaultSceneNodeAnimatorFactory() = 0; - - //! Adds a scene node animator factory to the scene manager. - /** Use this to extend the scene manager with new scene node animator types which it should be - able to create automaticly, for example when loading data from xml files. */ - virtual void registerSceneNodeAnimatorFactory(ISceneNodeAnimatorFactory* factoryToAdd) = 0; - - //! Returns amount of registered scene node animator factories. - virtual s32 getRegisteredSceneNodeAnimatorFactoryCount() = 0; - - //! Returns a scene node animator factory by index - virtual ISceneNodeAnimatorFactory* getSceneNodeAnimatorFactory(s32 index) = 0; - - //! Returns a typename from a scene node type or null if not found - virtual const c8* getSceneNodeTypeName(ESCENE_NODE_TYPE type) = 0; - - //! Creates a new scene manager. - /** This can be used to easily draw and/or store two independent scenes at the same time. - The mesh cache will be shared between all existing scene managers, which means if you load - a mesh in the original scene manager using for example getMesh(), the mesh will be available - in all other scene managers too, without loading. - The original/main scene manager will still be there and accessible via IrrlichtDevice::getSceneManager(). - If you need input event in this new scene manager, for example for FPS cameras, you'll need - to forward input to this manually: Just implement an IEventReceiver and call - yourNewSceneManager->postEventFromUser(), and return true so that the original scene manager - doesn't get the event. Otherwise, all input will go automaticly to the main scene manager. - If you no longer need the new scene manager, you should call ISceneManager::drop(). - See IUnknown::drop() for more information. */ - virtual ISceneManager* createNewSceneManager() = 0; - - //! Saves the current scene into a file. - /** Scene nodes with the option isDebugObject set to true are not being saved. - The scene is usually written to an .irr file, an xml based format. .irr files can - Be edited with the Irrlicht Engine Editor, irrEdit (http://irredit.irrlicht3d.org). - To load .irr files again, see ISceneManager::loadScene(). - \param filename: Name of the file. - \param userDataSerializer: If you want to save some user data for every scene node into the - file, implement the ISceneUserDataSerializer interface and provide it as parameter here. - Otherwise, simply specify 0 as this parameter. - \return Returns true if successful. */ - virtual bool saveScene(const c8* filename, ISceneUserDataSerializer* userDataSerializer=0) = 0; - - //! Saves the current scene into a file. - /** Scene nodes with the option isDebugObject set to true are not being saved. - The scene is usually written to an .irr file, an xml based format. .irr files can - Be edited with the Irrlicht Engine Editor, irrEdit (http://irredit.irrlicht3d.org). - To load .irr files again, see ISceneManager::loadScene(). - \param file: File where the scene is saved into. - \param userDataSerializer: If you want to save some user data for every scene node into the - file, implement the ISceneUserDataSerializer interface and provide it as parameter here. - Otherwise, simply specify 0 as this parameter. - \return Returns true if successful. */ - virtual bool saveScene(io::IWriteFile* file, ISceneUserDataSerializer* userDataSerializer=0) = 0; - - //! Loads a scene. Note that the current scene is not cleared before. - /** The scene is usually load from an .irr file, an xml based format. .irr files can - Be edited with the Irrlicht Engine Editor, irrEdit (http://irredit.irrlicht3d.org) or - saved directly by the engine using ISceneManager::saveScene(). - \param filename: Name of the file. - \param userDataSerializer: If you want to load user data possibily saved in that file for - some scene nodes in the file, implement the ISceneUserDataSerializer interface and provide it as parameter here. - Otherwise, simply specify 0 as this parameter. - \return Returns true if successful. */ - virtual bool loadScene(const c8* filename, ISceneUserDataSerializer* userDataSerializer=0) = 0; - - //! Loads a scene. Note that the current scene is not cleared before. - /** The scene is usually load from an .irr file, an xml based format. .irr files can - Be edited with the Irrlicht Engine Editor, irrEdit (http://irredit.irrlicht3d.org) or - saved directly by the engine using ISceneManager::saveScene(). - \param file: File where the scene is going to be saved into. - \param userDataSerializer: If you want to load user data possibily saved in that file for - some scene nodes in the file, implement the ISceneUserDataSerializer interface and provide it as parameter here. - Otherwise, simply specify 0 as this parameter. - \return Returns true if successful. */ - virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0) = 0; - - //! Sets ambient color of the scene - virtual void setAmbientLight(const video::SColorf &ambientColor) = 0; - - //! Returns ambient color of the scene - virtual video::SColorf getAmbientLight() = 0; - - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_SCENE_MANAGER_H_INCLUDED__ +#define __I_SCENE_MANAGER_H_INCLUDED__ + +#include "irrArray.h" +#include "IUnknown.h" +#include "vector3d.h" +#include "dimension2d.h" +#include "SColor.h" +#include "SMaterial.h" +#include "IEventReceiver.h" +#include "ETerrainElements.h" +#include "ESceneNodeTypes.h" +#include "SceneParameters.h" +#include "IGUIEnvironment.h" + +namespace irr +{ + struct SKeyMap; + +namespace io +{ + class IFileSystem; + class IReadFile; + class IAttributes; + class IWriteFile; +} // end namespace io + +namespace gui +{ + class IGUIFont; + class IGUIFontBitmap; +} // end namespace gui + +namespace video +{ + class IVideoDriver; +} // end namespace video + +namespace scene +{ + //! Enumeration for render passes. + /** A parameter passed to the registerNodeForRendering() method of the ISceneManager, + specifying when the mode wants to be drawn in relation to the other nodes. */ + enum E_SCENE_NODE_RENDER_PASS + { + //! Camera pass. The active view is set up here. + //! The very first pass. + ESNRP_CAMERA, + + //! In this pass, lights are transformed into camera space and added to the driver + ESNRP_LIGHT, + + //! This is used for sky boxes. + ESNRP_SKY_BOX, + + //! All normal objects can use this for registering themselves. + //! This value will never be returned by ISceneManager::getSceneNodeRenderPass(). + //! The scene manager will determine by itself if an object is + //! transparent or solid and register the object as SNRT_TRANSPARENT or + //! SNRT_SOLD automaticly if you call registerNodeForRendering with this + //! value (which is default). Note that it will register the node only as ONE type. + //! If your scene node has both solid and transparent material types register + //! it twice (one time as SNRT_SOLID, the other time as SNRT_TRANSPARENT) and + //! in the render() method call getSceneNodeRenderPass() to find out the current + //! render pass and render only the corresponding parts of the node. + ESNRP_AUTOMATIC, + + //! Solid scene nodes or special scene nodes without materials. + ESNRP_SOLID, + + //! Drawn after the transparent nodes, the time for drawing shadow volumes + ESNRP_SHADOW, + + //! Transparent scene nodes, drawn after shadow nodes. They are sorted from back + //! to front and drawn in that order. + ESNRP_TRANSPARENT, + + //! Scene Nodes with special support + ESNRP_SHADER_0, + ESNRP_SHADER_1, + ESNRP_SHADER_2, + ESNRP_SHADER_3, + ESNRP_SHADER_4, + ESNRP_SHADER_5, + ESNRP_SHADER_6, + ESNRP_SHADER_7, + ESNRP_SHADER_8, + ESNRP_SHADER_9, + ESNRP_SHADER_10, + + //! Never used, value specifing how much parameters there are. + ESNRP_COUNT + }; + + class IMesh; + class IMeshBuffer; + class IAnimatedMesh; + class IMeshCache; + class ISceneNode; + class ICameraSceneNode; + class IAnimatedMeshSceneNode; + class ISceneNodeAnimator; + class ISceneNodeAnimatorCollisionResponse; + class ILightSceneNode; + class IBillboardSceneNode; + class ITerrainSceneNode; + class IMeshSceneNode; + class IMeshLoader; + class ISceneCollisionManager; + class IParticleSystemSceneNode; + class IDummyTransformationSceneNode; + class ITriangleSelector; + class IMetaTriangleSelector; + class IMeshManipulator; + class ITextSceneNode; + class ISceneNodeFactory; + class ISceneNodeAnimatorFactory; + class ISceneUserDataSerializer; + + namespace quake3 + { + class SShader; + } // end namespace quake3 + + //! The Scene Manager manages scene nodes, mesh recources, cameras and all the other stuff. + /** All Scene nodes can be created only here. There is a always growing list of scene + nodes for lots of purposes: Indoor rendering scene nodes like the Octree + (addOctTreeSceneNode()) or the terrain renderer (addTerrainSceneNode()), + different Camera scene nodes (addCameraSceneNode(), addCameraSceneNodeMaya()), + scene nodes for Light (addLightSceneNode()), Billboards (addBillboardSceneNode()) + and so on. + A scene node is a node in the hierachical scene graph. Every scene node may have children, + which are other scene nodes. Children move relative the their parents position. If the parent of a node is not + visible, its children won't be visible, too. In this way, it is for example easily possible + to attach a light to a moving car or to place a walking character on a moving platform + on a moving ship. + The SceneManager is also able to load 3d mesh files of different formats. Take a look + at getMesh() to find out what formats are supported. And if these formats are not enough + use addExternalMeshLoader() to add new formats to the engine. + */ + class ISceneManager : public virtual IUnknown + { + public: + + //! destructor + virtual ~ISceneManager() {}; + + //! Returns pointer to an animateable mesh. Loads the file if not loaded already. + /** + * If you want to remove a loaded mesh from the cache again, use removeMesh(). + * Currently there are the following mesh formats supported: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
FormatDescription
3D Studio (.3ds)Loader for 3D-Studio files which lots of 3D packages are able to export. + * Only static meshes are currently supported by this importer.
Bliz Basic B3D (.b3d)Loader for blitz basic files, developed by Mark Sibly, also supports animations.
Cartography shop 4 (.csm)Cartography Shop is a modeling program for creating architecture and calculating + * lighting. Irrlicht can directly import .csm files thanks to the IrrCSM library + * created by Saurav Mohapatra which is now integrated directly in Irrlicht. + * If you are using this loader, please note that you'll have to set the path + * of the textures before loading .csm files. You can do this using SceneManager->getParameters()->setParameter(scene::CSM_TEXTURE_PATH, + * "path/to/your/textures");
COLLADA (.dae, .xml)COLLADA is an open Digital Asset Exchange Schema for the interactive 3D industry. There are + * exporters and importers for this format available for most of the big 3d packages + * at http://collada.org. Irrlicht can import COLLADA files by using the + * ISceneManager::getMesh() method. COLLADA files need not contain only one single mesh + * but multiple meshes and a whole scene setup with lights, cameras and mesh instances, + * this loader can set up a scene as described by the COLLADA file instead of loading + * and returning one single mesh. By default, this loader behaves like the other loaders + * and does not create instances, but it can be switched into this mode by using + * SceneManager->getParameters()->setParameter(COLLADA_CREATE_SCENE_INSTANCES, true); + * Created scene nodes will be named as the names of the nodes in the + * COLLADA file. The returned mesh is just a dummy object in this mode. Meshes included in + * the scene will be added into the scene manager with the following naming scheme: + * path/to/file/file.dea#meshname. The loading of such meshes is logged. + * Currently, this loader is able to create meshes (made of only polygons), lights, + * and cameras. Materials and animations are currently not supported but this will + * change with future releases. + *
Delgine DeleD (.dmf)DeleD (delgine.com) is a 3D editor and level-editor combined into one and is specifically + * designed for 3D game-development. With this loader, it is possible to directly load + * all geometry is as well as textures and lightmaps from .dmf files. To set texture and + * material paths, see scene::DMF_USE_MATERIALS_DIRS and scene::DMF_TEXTURE_PATH. It is also + * possible to flip the alpha texture by setting scene::DMF_FLIP_ALPHA_TEXTURES to true and + * to set the material transparent reference value by setting scene::DMF_ALPHA_CHANNEL_REF to + * a float between 0 and 1. The loader is + * based on Salvatore Russo's .dmf loader, I just changed some parts of it. Thanks to + * Salvatore for his work and for allowing me to use his code in Irrlicht and put it under Irrlicht's + * license. For newer and more enchanced versions of the loader, take a look at delgine.com. + *
DirectX (.x)Platform independent importer (so not D3D-only) for .x files. Most 3D + * packages can export these natively and there are several tools for them + * available. (e.g. the Maya exporter included in the DX SDK) .x files can + * include skeletal animations and Irrlicht is able to play and display them. + * Currently, Irrlicht only supports uncompressed .x files.
Maya (.obj)Most 3D software can create .obj files which contain static geometry without + * material data. The material files .mtl are also supported. This importer + * for Irrlicht can load them directly.
Milkshape (.ms3d).MS3D files contain models and sometimes skeletal animations from the + * Milkshape 3D modeling and animation software. This importer for Irrlicht + * can display and/or animate these files.
My3D (.my3d).my3D is a flexible 3D file format. The My3DTools contains plug-ins to + * export .my3D files from several 3D packages. With this built-in importer, + * Irrlicht can read and display those files directly. This loader was written + * by Zhuck Dimitry who also created the whole My3DTools package. If you are using this loader, please + * note that you can set the path of the textures before loading .my3d files. + * You can do this using SceneManager->getParameters()->setParameter(scene::MY3D_TEXTURE_PATH, + * "path/to/your/textures");
OCT (.oct)The oct file format contains 3D geometry and lightmaps and can be loaded + * directly by Irrlicht. OCT files
+ * can be created by FSRad, Paul Nette's radiosity processor or exported from + * Blender using OCTTools which can be found in the exporters/OCTTools directory + * of the SDK. Thanks to Murphy McCauley for creating all this.
OGRE Meshes (.mesh)Ogre .mesh files contain 3D data for the OGRE 3D engine. Irrlicht can read and + * display them directly with this importer. To define materials for the mesh, + * copy a .material file named like the corresponding .mesh file where the .mesh + * file is. (For example ogrehead.material for ogrehead.mesh). Thanks to Christian Stehno + * who wrote and contributed this loader.
Pulsar LMTools (.lmts)LMTools is a set of tools (Windows & Linux) for creating lightmaps. + * Irrlicht can directly read .lmts files thanks to
+ * the importer created by Jonas Petersen. If you are using this loader, please + * note that you can set the path of the textures before loading .lmts files. + * You can do this using SceneManager->getParameters()->setParameter(scene::LMTS_TEXTURE_PATH, + * "path/to/your/textures"); Notes for
+ * this version of the loader:
+ * - It does not recognice/support user data in the *.lmts files.
+ * - The TGAs generated by LMTools don't work in Irrlicht for some reason (the + * textures are upside down). Opening and resaving them in a graphics app will + * solve the problem.
Quake 3 levels (.bsp)Quake 3 is a popular game by IDSoftware, and .pk3 files contain .bsp files + * and textures/lightmaps describing huge
+ * prelighted levels. Irrlicht can read .pk3 and .bsp files directly and thus + * render Quake 3 levels directly. Written by Nikolaus Gebhardt enhanced by + * Dean P. Macri with the curved surfaces feature.
Quake 2 models (.md2)Quake 2 models are characters with morph target animation. Irrlicht can + * read, display and animate them directly with this importer.
+ * + * To load and display a mesh quickly, just do this: + * \code + * SceneManager->addAnimatedMeshSceneNode( + * SceneManager->getMesh("yourmesh.3ds")); + * \endcode + * If you would like to implement and add your own file format loader to Irrlicht, + * see addExternalMeshLoader(). + * \param filename: Filename of the mesh to load. + * \return Returns NULL if failed and the pointer to the mesh if + * successful. + * This pointer should not be dropped. See IUnknown::drop() for more information. + **/ + virtual IAnimatedMesh* getMesh(const c8* filename) = 0; + + //! Returns an interface to the mesh cache which is shared beween all existing scene managers. + /** With this interface, it is possible to manually add new loaded + meshes (if ISceneManager::getMesh() is not sufficient), to remove them and to iterate + through already loaded meshes. */ + virtual IMeshCache* getMeshCache() = 0; + + //! Returns the video driver. + /** \return Returns pointer to the video Driver. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual video::IVideoDriver* getVideoDriver() = 0; + + //! Returns the active GUIEnvironment + /** \return Returns pointer to the GUIEnvironment + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual gui::IGUIEnvironment* getGUIEnvironment() = 0; + + //! Adds a test scene node for test purposes to the scene. + /** It is a simple cube of (1,1,1) size. + \param size: Size of the cube. + \param parent: Parent of the scene node. Can be NULL if no parent. + \param id: Id of the node. This id can be used to identify the scene node. + \param position: Position of the space relative to its parent where the + scene node will be placed. + \param rotation: Initital rotation of the scene node. + \param scale: Initial scale of the scene node. + \return Returns pointer to the created test scene node. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual ISceneNode* addCubeSceneNode(f32 size=10.0f, ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; + + //! Adds a sphere scene node for test purposes to the scene. + /** It is a simple sphere. + \param radius: Radius of the sphere. + \param polyCount: Polycount of the sphere. + \param parent: Parent of the scene node. Can be NULL if no parent. + \param id: Id of the node. This id can be used to identify the scene node. + \param position: Position of the space relative to its parent where the + scene node will be placed. + \param rotation: Initital rotation of the scene node. + \param scale: Initial scale of the scene node. + \return Returns pointer to the created test scene node. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual ISceneNode* addSphereSceneNode(f32 radius=5.0f, s32 polyCount=16, ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; + + //! Adds a scene node for rendering an animated mesh model. + /** \param mesh: Pointer to the loaded animated mesh to be displayed. + \param parent: Parent of the scene node. Can be NULL if no parent. + \param id: Id of the node. This id can be used to identify the scene node. + \param position: Position of the space relative to its parent where the + scene node will be placed. + \param rotation: Initital rotation of the scene node. + \param scale: Initial scale of the scene node. + \return Returns pointer to the created scene node. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IAnimatedMeshSceneNode* addAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), + bool alsoAddIfMeshPointerZero=false) = 0; + + //! Adds a scene node for rendering a static mesh. + /** \param mesh: Pointer to the loaded static mesh to be displayed. + \param parent: Parent of the scene node. Can be NULL if no parent. + \param id: Id of the node. This id can be used to identify the scene node. + \param position: Position of the space relative to its parent where the + scene node will be placed. + \param rotation: Initital rotation of the scene node. + \param scale: Initial scale of the scene node. + \return Returns pointer to the created scene node. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IMeshSceneNode* addMeshSceneNode(IMesh* mesh, ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), + bool alsoAddIfMeshPointerZero=false) = 0; + + //! Adds a scene node for rendering a animated water surface mesh. + /** Looks really good when the Material type EMT_TRANSPARENT_REFLECTION + is used. + \param waveHeight: Height of the water waves. + \param waveSpeed: Speed of the water waves. + \param waveLength: Lenght of a water wave. + \param mesh: Pointer to the loaded static mesh to be displayed with water waves on it. + \param parent: Parent of the scene node. Can be NULL if no parent. + \param id: Id of the node. This id can be used to identify the scene node. + \param position: Position of the space relative to its parent where the + scene node will be placed. + \param rotation: Initital rotation of the scene node. + \param scale: Initial scale of the scene node. + \return Returns pointer to the created scene node. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual ISceneNode* addWaterSurfaceSceneNode(IMesh* mesh, + f32 waveHeight=2.0f, f32 waveSpeed=300.0f, f32 waveLength=10.0f, + ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; + + + //! Adds a scene node for rendering using a octtree to the scene graph. + /** This a good method for rendering + scenes with lots of geometry. The Octree is built on the fly from the mesh. + \param mesh: The mesh containing all geometry from which the octtree will be build. + If this animated mesh has more than one frames in it, the first frame is taken. + \param parent: Parent node of the octtree node. + \param id: id of the node. This id can be used to identify the node. + \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node. + If a node gets less polys the this value, it will not be splitted into + smaller nodes. + \return Returns the pointer to the octtree if successful, otherwise 0. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual ISceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, + s32 id=-1, s32 minimalPolysPerNode=256, bool alsoAddIfMeshPointerZero=false) = 0; + + //! Adds a scene node for rendering using a octtree to the scene graph. + /** This a good method for rendering + scenes with lots of geometry. The Octree is built on the fly from the mesh, much + faster then a bsp tree. + \param mesh: The mesh containing all geometry from which the octtree will be build. + \param parent: Parent node of the octtree node. + \param id: id of the node. This id can be used to identify the node. + \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node. + If a node gets less polys the this value, it will not be splitted into + smaller nodes. + \return Returns the pointer to the octtree if successful, otherwise 0. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual ISceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0, + s32 id=-1, s32 minimalPolysPerNode=256, bool alsoAddIfMeshPointerZero=false) = 0; + + //! Adds a camera scene node to the scene graph and sets it as active camera. + /** This camera does not react on user input like for example the one created with + addCameraSceneNodeFPS(). If you want to move or animate it, use animators or the + ISceneNode::setPosition(), ICameraSceneNode::setTarget() etc methods. + \param position: Position of the space relative to its parent where the camera will be placed. + \param lookat: Position where the camera will look at. Also known as target. + \param parent: Parent scene node of the camera. Can be null. If the parent moves, + the camera will move too. + \param id: id of the camera. This id can be used to identify the camera. + \return Returns pointer to interface to camera if successful, otherwise 0. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& lookat = core::vector3df(0,0,100), s32 id=-1) = 0; + + //! Adds a maya style user controlled camera scene node to the scene graph. + /** The maya camera is able to be controlled with the mouse similar + like in the 3D Software Maya by Alias Wavefront. + \param parent: Parent scene node of the camera. Can be null. + \param rotateSpeed: Rotation speed of the camera. + \param zoomSpeed: Zoom speed of the camera. + \param tranlationSpeed: TranslationSpeed of the camera. + \param id: id of the camera. This id can be used to identify the camera. + \return Returns a pointer to the interface of the camera if successful, otherwise 0. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent = 0, + f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 translationSpeed = 1500.0f, s32 id=-1) = 0; + + //! Adds a camera scene node which is able to be controlled with the mouse and keys like in most first person shooters (FPS). + /** Look with the mouse, move with cursor keys. If you do not like the default + key layout, you may want to specify your own. For example to make the camera + be controlled by the cursor keys AND the keys W,A,S, and D, do something + like this: + \code + SKeyMap keyMap[8]; + keyMap[0].Action = EKA_MOVE_FORWARD; + keyMap[0].KeyCode = KEY_UP; + keyMap[1].Action = EKA_MOVE_FORWARD; + keyMap[1].KeyCode = KEY_KEY_W; + + keyMap[2].Action = EKA_MOVE_BACKWARD; + keyMap[2].KeyCode = KEY_DOWN; + keyMap[3].Action = EKA_MOVE_BACKWARD; + keyMap[3].KeyCode = KEY_KEY_S; + + keyMap[4].Action = EKA_STRAFE_LEFT; + keyMap[4].KeyCode = KEY_LEFT; + keyMap[5].Action = EKA_STRAFE_LEFT; + keyMap[5].KeyCode = KEY_KEY_A; + + keyMap[6].Action = EKA_STRAFE_RIGHT; + keyMap[6].KeyCode = KEY_RIGHT; + keyMap[7].Action = EKA_STRAFE_RIGHT; + keyMap[7].KeyCode = KEY_KEY_D; + + camera = sceneManager->addCameraSceneNodeFPS(0, 100, 500, -1, keyMap, 8); + \endcode + \param parent: Parent scene node of the camera. Can be null. + \param rotateSpeed: Speed with wich the camera is rotated. This can be done + only with the mouse. + \param movespeed: Speed with which the camera is moved. Movement is done with + the cursor keys. + \param id: id of the camera. This id can be used to identify the camera. + \param keyMapArray: Optional pointer to an array of a keymap, specifying what + keys should be used to move the camera. If this is null, the default keymap + is used. You can define actions more then one time in the array, to bind + multiple keys to the same action. + \param keyMapSize: Amount of items in the keymap array. + \param noVerticalMovement: Setting this to true makes the camera only move within a + horizontal plane, and disables vertical movement as known from most ego shooters. Default + is 'false', with which it is possible to fly around in space, if no gravity is there. + \return Returns a pointer to the interface of the camera if successful, otherwise 0. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, + f32 rotateSpeed = 100.0f, f32 moveSpeed = 500.0f, s32 id=-1, + SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false, + f32 jumpSpeed = 0.f) = 0; + + //! Adds a dynamic light scene node to the scene graph. + /** The light will cast dynamic light on all + other scene nodes in the scene, which have the material flag video::MTF_LIGHTING + turned on. (This is the default setting in most scene nodes). + \param parent: Parent scene node of the light. Can be null. If the parent moves, + the light will move too. + \param position: Position of the space relative to its parent where the light will be placed. + \param color: Diffuse color of the light. Ambient or Specular colors can be set manually with + the ILightSceneNode::getLightData() method. + \param radius: Radius of the light. + \param id: id of the node. This id can be used to identify the node. + \return Returns pointer to the interface of the light if successful, otherwise NULL. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual ILightSceneNode* addLightSceneNode(ISceneNode* parent = 0, + const core::vector3df& position = core::vector3df(0,0,0), + video::SColorf color = video::SColorf(1.0f, 1.0f, 1.0f), + f32 radius=100.0f, s32 id=-1) = 0; + + //! Adds a billboard scene node to the scene graph. + /** A billboard is like a 3d sprite: A 2d element, + which always looks to the camera. It is usually used for things like explosions, fire, + lensflares and things like that. + \param parent: Parent scene node of the billboard. Can be null. If the parent moves, + the billboard will move too. + \param position: Position of the space relative to its parent where the billboard will be placed. + \param size: Size of the billboard. This size is 2 dimensional because a billboard only has + width and height. + \param id: An id of the node. This id can be used to identify the node. + \param shade_top: vertex color top + \param shade_down: vertex color down + \return Returns pointer to the billboard if successful, otherwise NULL. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IBillboardSceneNode* addBillboardSceneNode(ISceneNode* parent = 0, + const core::dimension2d& size = core::dimension2d(10.0f, 10.0f), + const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, + video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF) = 0; + + //! Adds a skybox scene node to the scene graph. + /** A skybox is a big cube with 6 textures on it and + is drawn around the camera position. + \param top: Texture for the top plane of the box. + \param bottom: Texture for the bottom plane of the box. + \param left: Texture for the left plane of the box. + \param right: Texture for the right plane of the box. + \param front: Texture for the front plane of the box. + \param back: Texture for the back plane of the box. + \param parent: Parent scene node of the skybox. A skybox usually has no parent, + so this should be null. Note: If a parent is set to the skybox, the box will not + change how it is drawn. + \param id: An id of the node. This id can be used to identify the node. + \return Returns a pointer to the sky box if successful, otherwise NULL. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual ISceneNode* addSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, + video::ITexture* left, video::ITexture* right, video::ITexture* front, + video::ITexture* back, ISceneNode* parent = 0, s32 id=-1) = 0; + + //! Adds a skydome scene node to the scene graph. + /** A skydome is a large (half-) sphere with a panoramic texture + on the inside and is drawn around the camera position. + \param texture: Texture for the dome. + \param horiRes: Number of vertices of a horizontal layer of the sphere. + \param vertRes: Number of vertices of a vertical layer of the sphere. + \param texturePercentage: How much of the height of the texture is used. Should be between 0 and 1. + \param spherePercentage: How much of the sphere is drawn. Value should be between 0 and 2, where 1 is an exact half-sphere and 2 is a full sphere. + \param parent: Parent scene node of the dome. A dome usually has no parent, + so this should be null. Note: If a parent is set, the dome will not + change how it is drawn. + \param id: An id of the node. This id can be used to identify the node. + \return Returns a pointer to the sky dome if successful, otherwise NULL. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual ISceneNode* addSkyDomeSceneNode(video::ITexture* texture, + u32 horiRes, u32 vertRes, f64 texturePercentage, f64 spherePercentage, + ISceneNode* parent = 0, s32 id=-1) = 0; + + //! Adds a particle system scene node to the scene graph. + /** \param withDefaultEmitter: Creates a default working point emitter + which emitts some particles. Set this to true to see a particle system + in action. If set to false, you'll have to set the emitter you want by + calling IParticleSystemSceneNode::setEmitter(). + \param parent: Parent of the scene node. Can be NULL if no parent. + \param id: Id of the node. This id can be used to identify the scene node. + \param position: Position of the space relative to its parent where the + scene node will be placed. + \param rotation: Initital rotation of the scene node. + \param scale: Initial scale of the scene node. + \return Returns pointer to the created scene node. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IParticleSystemSceneNode* addParticleSystemSceneNode( + bool withDefaultEmitter=true, ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; + + //! Adds a terrain scene node to the scene graph. + /** This node + implements is a simple terrain renderer which uses + a technique known as geo mip mapping + for reducing the detail of triangle blocks which are far away. + The code for the TerrainSceneNode is based on the terrain renderer by Soconne and + the GeoMipMapSceneNode developed by Spintz. They made their code available for Irrlicht + and allowed it to be distributed under this licence. I only modified some parts. + A lot of thanks go to them. + + This scene node is capable of very quickly loading + terrains and updating the indices at runtime to enable viewing very large terrains. It uses a + CLOD (Continuous Level of Detail) algorithm which updates the indices for each patch based on + a LOD (Level of Detail) which is determined based on a patch's distance from the camera. + + The patch size of the terrain must always be a size of ( 2^N+1, i.e. 8+1(9), 16+1(17), etc. ). + The MaxLOD available is directly dependent on the patch size of the terrain. LOD 0 contains all + of the indices to draw all the triangles at the max detail for a patch. As each LOD goes up by 1 + the step taken, in generating indices increases by - 2^LOD, so for LOD 1, the step taken is 2, for + LOD 2, the step taken is 4, LOD 3 - 8, etc. The step can be no larger than the size of the patch, + so having a LOD of 8, with a patch size of 17, is asking the algoritm to generate indices every + 2^8 ( 256 ) vertices, which is not possible with a patch size of 17. The maximum LOD for a patch + size of 17 is 2^4 ( 16 ). So, with a MaxLOD of 5, you'll have LOD 0 ( full detail ), LOD 1 ( every + 2 vertices ), LOD 2 ( every 4 vertices ), LOD 3 ( every 8 vertices ) and LOD 4 ( every 16 vertices ). + \param heightMapFile: The location of the file on disk, to read vertex data from. This should + be a gray scale bitmap. + \param position: The absolute position of this node. + \param rotation: The absolute rotation of this node. ( NOT YET IMPLEMENTED ) + \param scale: The scale factor for the terrain. If you're using a heightmap of size 128x128 and would like + your terrain to be 12800x12800 in game units, then use a scale factor of ( core::vector ( 100.0f, 100.0f, 100.0f ). + If you use a Y scaling factor of 0.0f, then your terrain will be flat. + \param vertexColor: The default color of all the vertices. If no texture is associated + with the scene node, then all vertices will be this color. Defaults to white. + \param maxLOD: The maximum LOD (level of detail) for the node. Only change if you + know what you are doing, this might lead to strange behaviour. + \param patchSize: patch size of the terrain. Only change if you + know what you are doing, this might lead to strange behaviour. + \return Returns pointer to the created scene node. Can be null if the + terrain could not be created, for example because the heightmap could not be loaded. + The returned pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual ITerrainSceneNode* addTerrainSceneNode( + const c8* heightMapFileName, + ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), + const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), + const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), + video::SColor vertexColor = video::SColor(255,255,255,255), + s32 maxLOD=5, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17, s32 smoothFactor=0) = 0; + + //! Adds a terrain scene node to the scene graph. + /** Just like the other addTerrainSceneNode() method, but takes an IReadFile + pointer as parameter for the heightmap. For more informations take a look + add the other overload. */ + virtual ITerrainSceneNode* addTerrainSceneNode( + io::IReadFile* heightMapFile, + ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), + const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), + const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), + video::SColor vertexColor = video::SColor(255,255,255,255), + s32 maxLOD=5, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17, s32 smoothFactor=0) = 0; + + //! Adds a quake3 scene node to the scene graph. + /** A Quake3 Scene renders multiple meshes for a specific HighLanguage Shader (Quake3 Style ) + \return Returns a pointer to the quake3 scene node if successful, otherwise NULL. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual ISceneNode* addQuake3SceneNode(IMeshBuffer* meshBuffer, const quake3::SShader * shader, + ISceneNode* parent=0, s32 id=-1 + ) = 0; + + + //! Adds an empty scene node to the scene graph. + /** Can be used for doing advanced transformations + or structuring the scene graph. + \return Returns pointer to the created scene node. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual ISceneNode* addEmptySceneNode(ISceneNode* parent=0, s32 id=-1) = 0; + + //! Adds a dummy transformation scene node to the scene graph. + /** This scene node does not render itself, and does not respond to set/getPosition, + set/getRotation and set/getScale. Its just a simple scene node that takes a + matrix as relative transformation, making it possible to insert any transformation + anywhere into the scene graph. + \return Returns pointer to the created scene node. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IDummyTransformationSceneNode* addDummyTransformationSceneNode( + ISceneNode* parent=0, s32 id=-1) = 0; + + //! Adds a text scene node, which is able to display 2d text at a position in three dimensional space + virtual ITextSceneNode* addTextSceneNode(gui::IGUIFont* font, const wchar_t* text, + video::SColor color=video::SColor(100,255,255,255), + ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0), + s32 id=-1) = 0; + + //! Adds a text scene node, which uses billboards + virtual ITextSceneNode* addBillboardTextSceneNode( gui::IGUIFont* font, const wchar_t* text, + ISceneNode* parent = 0, + const core::dimension2d& size = core::dimension2d(10.0f, 10.0f), + const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, + video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF) = 0; + + //! Adds a Hill Plane mesh to the mesh pool. + /** The mesh is generated on the fly + and looks like a plane with some hills on it. It is uses mostly for quick + tests of the engine only. You can specify how many hills there should be + on the plane and how high they should be. Also you must specify a name for + the mesh, because the mesh is added to the mesh pool, and can be retieved + again using ISceneManager::getMesh() with the name as parameter. + \param name: The name of this mesh which must be specified in order + to be able to retrieve the mesh later with ISceneManager::getMesh(). + \param tileSize: Size of a tile of the mesh. (10.0f, 10.0f) would be a + good value to start, for example. + \param tileCount: Specifies how much tiles there will be. If you specifiy + for example that a tile has the size (10.0f, 10.0f) and the tileCount is + (10,10), than you get a field of 100 tiles wich has the dimension 100.0fx100.0f. + \param material: Material of the hill mesh. + \param hillHeight: Height of the hills. If you specify a negative value + you will get holes instead of hills. If the height is 0, no hills will be + created. + \param countHills: Amount of hills on the plane. There will be countHills.X + hills along the X axis and countHills.Y along the Y axis. So in total there + will be countHills.X * countHills.Y hills. + \param textureRepeatCount: Defines how often the texture will be repeated in + x and y direction. + \return Returns null if the creation failed. The reason could be that you + specified some invalid parameters or that a mesh with that name already + exists. If successful, a pointer to the mesh is returned. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IAnimatedMesh* addHillPlaneMesh(const c8* name, + const core::dimension2d& tileSize, const core::dimension2d& tileCount, + video::SMaterial* material = 0, f32 hillHeight = 0.0f, + const core::dimension2d& countHills = core::dimension2d(0.0f, 0.0f), + const core::dimension2d& textureRepeatCount = core::dimension2d(1.0f, 1.0f)) = 0; + + //! Adds a static terrain mesh to the mesh pool. + /** The mesh is generated on the fly + from a texture file and a height map file. Both files may be huge + (8000x8000 pixels would be no problem) because the generator splits the + files into smaller textures if necessary. + You must specify a name for the mesh, because the mesh is added to the mesh pool, + and can be retieved again using ISceneManager::getMesh() with the name as parameter. + \param meshname: The name of this mesh which must be specified in order + to be able to retrieve the mesh later with ISceneManager::getMesh(). + \param texture: Texture for the terrain. Please note that this is not a + hardware texture as usual (ITexture), but an IImage software texture. + You can load this texture with IVideoDriver::createImageFromFile(). + \param heightmap: A grayscaled heightmap image. Like the texture, + it can be created with IVideoDriver::createImageFromFile(). The amount + of triangles created depends on the size of this texture, so use a small + heightmap to increase rendering speed. + \param stretchSize: Parameter defining how big a is pixel on the heightmap. + \param maxHeight: Defines how height a white pixel on the heighmap is. + \return Returns null if the creation failed. The reason could be that you + specified some invalid parameters, that a mesh with that name already + exists, or that a texture could not be found. If successful, a pointer to the mesh is returned. + This pointer should not be dropped. See IUnknown::drop() for more information. */ + virtual IAnimatedMesh* addTerrainMesh(const c8* meshname, + video::IImage* texture, video::IImage* heightmap, + const core::dimension2d& stretchSize = core::dimension2d(10.0f,10.0f), + f32 maxHeight=200.0f, + const core::dimension2d& defaultVertexBlockSize = core::dimension2d(64,64)) = 0; + + //! add a static arrow mesh to the meshpool + /** it quite usefull for debuggin purposes. ( showing directions eq ) + */ + virtual IAnimatedMesh* addArrowMesh(const c8* name, u32 tesselationCylinder, u32 tesselationCone, f32 height, + f32 cylinderHeight, f32 width0,f32 width1, + video::SColor vtxColor0, video::SColor vtxColor1) = 0; + + //! Returns the root scene node. + /** This is the scene node wich is parent + of all scene nodes. The root scene node is a special scene node which + only exists to manage all scene nodes. It will not be rendered and cannot + be removed from the scene. + \return Returns a pointer to the root scene node. */ + virtual ISceneNode* getRootSceneNode() = 0; + + //! Returns the first scene node with the specified id. + /** \param id: The id to search for + \param start: Scene node to start from. All children of this scene + node are searched. If null is specified, the root scene node is + taken. + \return Returns pointer to the first scene node with this id, + and null if no scene node could be found. */ + virtual ISceneNode* getSceneNodeFromId(s32 id, ISceneNode* start=0) = 0; + + //! Returns the first scene node with the specified name. + /**\param start: Scene node to start from. All children of this scene + node are searched. If null is specified, the root scene node is + taken. + \return Returns pointer to the first scene node with this id, + and null if no scene node could be found. */ + virtual ISceneNode* getSceneNodeFromName(const c8* name, ISceneNode* start=0) = 0; + + //! Returns the current active camera. + /** \return The active camera is returned. Note that this can be NULL, if there + was no camera created yet. */ + virtual ICameraSceneNode* getActiveCamera() = 0; + + //! Sets the currently active camera. + /** The previous active camera will be deactivated. + \param camera: The new camera which should be active. */ + virtual void setActiveCamera(ICameraSceneNode* camera) = 0; + + //! Sets the color of stencil buffers shadows drawn by the scene manager. + virtual void setShadowColor(video::SColor color = video::SColor(150,0,0,0)) = 0; + + //! Returns the current color of shadows. + virtual video::SColor getShadowColor() const = 0; + + //! Registers a node for rendering it at a specific time. + /** This method should only be used by SceneNodes when they get a + ISceneNode::OnRegisterSceneNode() call. + \param node: Node to register for drawing. Usually scene nodes would set 'this' + as parameter here because they want to be drawn. + \param pass: Specifies when the mode wants to be drawn in relation to the other nodes. + For example, if the node is a shadow, it usually wants to be drawn after all other nodes + and will use ESNRP_SHADOW for this. See E_SCENE_NODE_RENDER_PASS for details. + \return scene will be rendered ( passed culling ) */ + virtual u32 registerNodeForRendering(ISceneNode* node, + E_SCENE_NODE_RENDER_PASS pass = ESNRP_AUTOMATIC) = 0; + + //! Draws all the scene nodes. + /** This can only be invoked between + IVideoDriver::beginScene() and IVideoDriver::endScene(). Please note that + the scene is not only drawn when calling this, but also animated + by existing scene node animators, culling of scene nodes is done, etc. */ + virtual void drawAll() = 0; + + //! Creates a rotation animator, which rotates the attached scene node around itself. + /** \param rotationPerSecond: Specifies the speed of the animation + \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() + and the animator will animate it. + If you no longer need the animator, you should call ISceneNodeAnimator::drop(). + See IUnknown::drop() for more information. */ + virtual ISceneNodeAnimator* createRotationAnimator(const core::vector3df& rotationPerSecond) = 0; + + //! Creates a fly circle animator, which lets the attached scene node fly around a center. + /** \param center: Center of the circle. + \param radius: Radius of the circle. + \param speed: Specifies the speed of the flight. + \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() + and the animator will animate it. + If you no longer need the animator, you should call ISceneNodeAnimator::drop(). + See IUnknown::drop() for more information. */ + virtual ISceneNodeAnimator* createFlyCircleAnimator(const core::vector3df& center, + f32 radius, f32 speed=0.001f, const core::vector3df& direction= core::vector3df ( 0.f, 1.f, 0.f ) ) = 0; + + //! Creates a fly straight animator, which lets the attached scene node fly or move along a line between two points. + /** \param startPoint: Start point of the line. + \param endPoint: End point of the line. + \param timeForWay: Time in milli seconds how long the node should need to + move from the start point to the end point. + \param loop: If set to false, the node stops when the end point is reached. + If loop is true, the node begins again at the start. + \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() + and the animator will animate it. + If you no longer need the animator, you should call ISceneNodeAnimator::drop(). + See IUnknown::drop() for more information. */ + virtual ISceneNodeAnimator* createFlyStraightAnimator(const core::vector3df& startPoint, + const core::vector3df& endPoint, u32 timeForWay, bool loop=false) = 0; + + //! Creates a texture animator, which switches the textures of the target scene node based on a list of textures. + /** \param textures: List of textures to use. + \param timePerFrame: Time in milliseconds, how long any texture in the list + should be visible. + \param loop: If set to to false, the last texture remains set, and the animation + stops. If set to true, the animation restarts with the first texture. + \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() + and the animator will animate it. + If you no longer need the animator, you should call ISceneNodeAnimator::drop(). + See IUnknown::drop() for more information. */ + virtual ISceneNodeAnimator* createTextureAnimator(const core::array& textures, + s32 timePerFrame, bool loop=true) = 0; + + //! Creates a scene node animator, which deletes the scene node after some time automatically. + /** \param timeMs: Time in milliseconds, after when the node will be deleted. + \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() + and the animator will animate it. + If you no longer need the animator, you should call ISceneNodeAnimator::drop(). + See IUnknown::drop() for more information. */ + virtual ISceneNodeAnimator* createDeleteAnimator(u32 timeMs) = 0; + + //! Creates a special scene node animator for doing automatic collision detection and response. + /** See ISceneNodeAnimatorCollisionResponse for details. + \param world: Triangle selector holding all triangles of the world with which + the scene node may collide. You can create a triangle selector with + ISceneManager::createTriangleSelector(); + \param sceneNode: SceneNode which should be manipulated. After you added this animator + to the scene node, the scene node will not be able to move through walls and is + affected by gravity. + \param ellipsoidRadius: Radius of the ellipsoid with which collision detection and + response is done. If you have got a scene node, and you are unsure about + how big the radius should be, you could use the following code to determine + it: + \code + core::aabbox box = yourSceneNode->getBoundingBox(); + core::vector3df radius = box.MaxEdge - box.getCenter(); + \endcode + \param gravityPerSecond: Sets the gravity of the environment. A good example value would be + core::vector3df(0,-100.0f,0) for letting gravity affect all object to + fall down. For bigger gravity, make increase the length of the vector. + You can disable gravity by setting it to core::vector3df(0,0,0). + \param ellipsoidTranslation: By default, the ellipsoid for collision detection is created around + the center of the scene node, which means that the ellipsoid surrounds + it completely. If this is not what you want, you may specify a translation + for the ellipsoid. + \param slidingValue: DOCUMENTATION NEEDED. + \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() + and the animator will cause it to do collision detection and response. + If you no longer need the animator, you should call ISceneNodeAnimator::drop(). + See IUnknown::drop() for more information. */ + virtual ISceneNodeAnimatorCollisionResponse* createCollisionResponseAnimator( + ITriangleSelector* world, ISceneNode* sceneNode, + const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30), + const core::vector3df& gravityPerSecond = core::vector3df(0,-100.0f,0), + const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0), + f32 slidingValue = 0.0005f) = 0; + + //! Creates a follow spline animator. + /** The animator modifies the position of + the attached scene node to make it follow a hermite spline. + The code of the is based on a scene node + Matthias Gall sent in. Thanks! I adapted the code just a little bit. Matthias + wrote: + Uses a subset of hermite splines: either cardinal splines (tightness != 0.5) or catmull-rom-splines (tightness == 0.5) + but this is just my understanding of this stuff, I'm not a mathematician, so this might be wrong ;) */ + virtual ISceneNodeAnimator* createFollowSplineAnimator(s32 startTime, + const core::array< core::vector3df >& points, + f32 speed = 1.0f, f32 tightness = 0.5f) = 0; + + //! Creates a simple ITriangleSelector, based on a mesh. + /** Triangle selectors + can be used for doing collision detection. Don't use this selector + for a huge amount of triangles like in Quake3 maps. + Instead, use for example ISceneManager::createOctTreeTriangleSelector(). + Please note that the created triangle selector is not automaticly attached + to the scene node. You will have to call ISceneNode::setTriangleSelector() + for this. To create and attach a triangle selector is done like this: + \code + ITriangleSelector* s = sceneManager->createTriangleSelector(yourMesh, + yourSceneNode); + yourSceneNode->setTriangleSelector(s); + s->drop(); + \endcode + \param mesh: Mesh of which the triangles are taken. + \param node: Scene node of which visibility and transformation is used. + \return Returns the selector, or null if not successful. + If you no longer need the selector, you should call ITriangleSelector::drop(). + See IUnknown::drop() for more information. */ + virtual ITriangleSelector* createTriangleSelector(IMesh* mesh, ISceneNode* node) = 0; + + //! Creates a simple dynamic ITriangleSelector, based on a axis aligned bounding box. + /** Triangle selectors + can be used for doing collision detection. Every time when triangles are + queried, the triangle selector gets the bounding box of the scene node, + an creates new triangles. In this way, it works good with animated scene nodes. + \param node: Scene node of which the bounding box, visibility and transformation is used. + \return Returns the selector, or null if not successful. + If you no longer need the selector, you should call ITriangleSelector::drop(). + See IUnknown::drop() for more information. */ + virtual ITriangleSelector* createTriangleSelectorFromBoundingBox(ISceneNode* node) = 0; + + //! Creates a Triangle Selector, optimized by an octtree. + /** Triangle selectors + can be used for doing collision detection. This triangle selector is + optimized for huge amounts of triangle, it organizes them in an octtree. + Please note that the created triangle selector is not automaticly attached + to the scene node. You will have to call ISceneNode::setTriangleSelector() + for this. To create and attach a triangle selector is done like this: + \code + ITriangleSelector* s = sceneManager->createOctTreeTriangleSelector(yourMesh, + yourSceneNode); + yourSceneNode->setTriangleSelector(s); + s->drop(); + \endcode + For more informations and examples on this, take a look at the collision + tutorial in the SDK. + \param mesh: Mesh of which the triangles are taken. + \param node: Scene node of which visibility and transformation is used. + \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node. + If a node gets less polys the this value, it will not be splitted into + smaller nodes. + \return Returns the selector, or null if not successful. + If you no longer need the selector, you should call ITriangleSelector::drop(). + See IUnknown::drop() for more information. */ + virtual ITriangleSelector* createOctTreeTriangleSelector(IMesh* mesh, + ISceneNode* node, s32 minimalPolysPerNode=32) = 0; + + //! Creates a meta triangle selector. + /** A meta triangle selector is nothing more than a + collection of one or more triangle selectors providing together + the interface of one triangle selector. In this way, + collision tests can be done with different triangle soups in one pass. + \return Returns the selector, or null if not successful. + If you no longer need the selector, you should call ITriangleSelector::drop(). + See IUnknown::drop() for more information. */ + virtual IMetaTriangleSelector* createMetaTriangleSelector() = 0; + + //! Creates a triangle selector which can select triangles from a terrain scene node. + /** \param: Pointer to the created terrain scene node + \param: Level of detail, 0 for highest detail. */ + virtual ITriangleSelector* createTerrainTriangleSelector( + ITerrainSceneNode* node, s32 LOD=0) = 0; + + //! Adds an external mesh loader for extending the engine with new file formats. + /** If you want the engine to be extended with + file formats it currently is not able to load (e.g. .cob), just implement + the IMeshLoader interface in your loading class and add it with this method. + Using this method it is also possible to override built-in mesh loaders with + newer or updated versions without the need of recompiling the engine. + \param externalLoader: Implementation of a new mesh loader. */ + virtual void addExternalMeshLoader(IMeshLoader* externalLoader) = 0; + + //! Returns a pointer to the scene collision manager. + virtual ISceneCollisionManager* getSceneCollisionManager() = 0; + + //! Returns a pointer to the mesh manipulator. + virtual IMeshManipulator* getMeshManipulator() = 0; + + //! Adds a scene node to the deletion queue. + /** The scene node is immediatly + deleted when it's secure. Which means when the scene node does not + execute animators and things like that. This method is for example + used for deleting scene nodes by their scene node animators. In + most other cases, a ISceneNode::remove() call is enough, using this + deletion queue is not necessary. + See ISceneManager::createDeleteAnimator() for details. + \param node: Node to detete. */ + virtual void addToDeletionQueue(ISceneNode* node) = 0; + + //! Posts an input event to the environment. + /** Usually you do not have to + use this method, it is used by the internal engine. */ + virtual bool postEventFromUser(SEvent event) = 0; + + //! Clears the whole scene. + /** All scene nodes are removed. */ + virtual void clear() = 0; + + //! Returns interface to the parameters set in this scene. + /** String parameters can be used by plugins and mesh loaders. + For example the CMS and LMTS loader want a parameter named 'CSM_TexturePath' + and 'LMTS_TexturePath' set to the path were attached textures can be found. See + CSM_TEXTURE_PATH, LMTS_TEXTURE_PATH, MY3D_TEXTURE_PATH, + COLLADA_CREATE_SCENE_INSTANCES, DMF_TEXTURE_PATH and DMF_USE_MATERIALS_DIRS*/ + virtual io::IAttributes* getParameters() = 0; + + //! Returns current render pass. + /** All scene nodes are being rendered in a specific order. + First lights, cameras, sky boxes, solid geometry, and then transparent + stuff. During the rendering process, scene nodes may want to know what the scene + manager is rendering currently, because for example they registered for rendering + twice, once for transparent geometry and once for solid. When knowing what rendering + pass currently is active they can render the correct part of their geometry. */ + virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() = 0; + + //! Returns the default scene node factory which can create all built in scene nodes + virtual ISceneNodeFactory* getDefaultSceneNodeFactory() = 0; + + //! Adds a scene node factory to the scene manager. + /** Use this to extend the scene manager with new scene node types which it should be + able to create automaticly, for example when loading data from xml files. */ + virtual void registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd) = 0; + + //! Returns amount of registered scene node factories. + virtual s32 getRegisteredSceneNodeFactoryCount() = 0; + + //! Returns a scene node factory by index + virtual ISceneNodeFactory* getSceneNodeFactory(s32 index) = 0; + + //! Returns the default scene node animator factory which can create all built-in scene node animators + virtual ISceneNodeAnimatorFactory* getDefaultSceneNodeAnimatorFactory() = 0; + + //! Adds a scene node animator factory to the scene manager. + /** Use this to extend the scene manager with new scene node animator types which it should be + able to create automaticly, for example when loading data from xml files. */ + virtual void registerSceneNodeAnimatorFactory(ISceneNodeAnimatorFactory* factoryToAdd) = 0; + + //! Returns amount of registered scene node animator factories. + virtual s32 getRegisteredSceneNodeAnimatorFactoryCount() = 0; + + //! Returns a scene node animator factory by index + virtual ISceneNodeAnimatorFactory* getSceneNodeAnimatorFactory(s32 index) = 0; + + //! Returns a typename from a scene node type or null if not found + virtual const c8* getSceneNodeTypeName(ESCENE_NODE_TYPE type) = 0; + + //! Creates a new scene manager. + /** This can be used to easily draw and/or store two independent scenes at the same time. + The mesh cache will be shared between all existing scene managers, which means if you load + a mesh in the original scene manager using for example getMesh(), the mesh will be available + in all other scene managers too, without loading. + The original/main scene manager will still be there and accessible via IrrlichtDevice::getSceneManager(). + If you need input event in this new scene manager, for example for FPS cameras, you'll need + to forward input to this manually: Just implement an IEventReceiver and call + yourNewSceneManager->postEventFromUser(), and return true so that the original scene manager + doesn't get the event. Otherwise, all input will go automaticly to the main scene manager. + If you no longer need the new scene manager, you should call ISceneManager::drop(). + See IUnknown::drop() for more information. */ + virtual ISceneManager* createNewSceneManager() = 0; + + //! Saves the current scene into a file. + /** Scene nodes with the option isDebugObject set to true are not being saved. + The scene is usually written to an .irr file, an xml based format. .irr files can + Be edited with the Irrlicht Engine Editor, irrEdit (http://irredit.irrlicht3d.org). + To load .irr files again, see ISceneManager::loadScene(). + \param filename: Name of the file. + \param userDataSerializer: If you want to save some user data for every scene node into the + file, implement the ISceneUserDataSerializer interface and provide it as parameter here. + Otherwise, simply specify 0 as this parameter. + \return Returns true if successful. */ + virtual bool saveScene(const c8* filename, ISceneUserDataSerializer* userDataSerializer=0) = 0; + + //! Saves the current scene into a file. + /** Scene nodes with the option isDebugObject set to true are not being saved. + The scene is usually written to an .irr file, an xml based format. .irr files can + Be edited with the Irrlicht Engine Editor, irrEdit (http://irredit.irrlicht3d.org). + To load .irr files again, see ISceneManager::loadScene(). + \param file: File where the scene is saved into. + \param userDataSerializer: If you want to save some user data for every scene node into the + file, implement the ISceneUserDataSerializer interface and provide it as parameter here. + Otherwise, simply specify 0 as this parameter. + \return Returns true if successful. */ + virtual bool saveScene(io::IWriteFile* file, ISceneUserDataSerializer* userDataSerializer=0) = 0; + + //! Loads a scene. Note that the current scene is not cleared before. + /** The scene is usually load from an .irr file, an xml based format. .irr files can + Be edited with the Irrlicht Engine Editor, irrEdit (http://irredit.irrlicht3d.org) or + saved directly by the engine using ISceneManager::saveScene(). + \param filename: Name of the file. + \param userDataSerializer: If you want to load user data possibily saved in that file for + some scene nodes in the file, implement the ISceneUserDataSerializer interface and provide it as parameter here. + Otherwise, simply specify 0 as this parameter. + \return Returns true if successful. */ + virtual bool loadScene(const c8* filename, ISceneUserDataSerializer* userDataSerializer=0) = 0; + + //! Loads a scene. Note that the current scene is not cleared before. + /** The scene is usually load from an .irr file, an xml based format. .irr files can + Be edited with the Irrlicht Engine Editor, irrEdit (http://irredit.irrlicht3d.org) or + saved directly by the engine using ISceneManager::saveScene(). + \param file: File where the scene is going to be saved into. + \param userDataSerializer: If you want to load user data possibily saved in that file for + some scene nodes in the file, implement the ISceneUserDataSerializer interface and provide it as parameter here. + Otherwise, simply specify 0 as this parameter. + \return Returns true if successful. */ + virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0) = 0; + + //! Sets ambient color of the scene + virtual void setAmbientLight(const video::SColorf &ambientColor) = 0; + + //! Returns ambient color of the scene + virtual video::SColorf getAmbientLight() = 0; + + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/ISceneNode.h b/src/dep/include/irrlicht/ISceneNode.h index 6b7ee61..78b6e72 100644 --- a/src/dep/include/irrlicht/ISceneNode.h +++ b/src/dep/include/irrlicht/ISceneNode.h @@ -1,659 +1,659 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_NODE_H_INCLUDED__ -#define __I_SCENE_NODE_H_INCLUDED__ - -#include "IUnknown.h" -#include "ESceneNodeTypes.h" -#include "ISceneManager.h" -#include "ISceneNodeAnimator.h" -#include "ITriangleSelector.h" -#include "SMaterial.h" -#include "irrString.h" -#include "aabbox3d.h" -#include "matrix4.h" -#include "irrList.h" -#include "IAttributes.h" -#include "IAttributeExchangingObject.h" - -namespace irr -{ -namespace scene -{ - //! Scene node interface. - /** A scene node is a node in the hirachical scene graph. Every scene node may have children, - which are other scene nodes. Children move relative the their parents position. If the parent of a node is not - visible, its children won't be visible too. In this way, it is for example easily possible - to attach a light to a moving car, or to place a walking character on a moving platform - on a moving ship. */ - class ISceneNode : public io::IAttributeExchangingObject - { - public: - - //! Constructor - ISceneNode( ISceneNode* parent, ISceneManager* mgr, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) - : RelativeTranslation(position), RelativeRotation(rotation), RelativeScale(scale), - Parent(parent), ID(id), SceneManager(mgr), TriangleSelector(0), - AutomaticCullingState(EAC_BOX), IsVisible(true), - DebugDataVisible(EDS_OFF), IsDebugObject(false) - { - if (Parent) - Parent->addChild(this); - - updateAbsolutePosition(); - } - - - - //! Destructor - virtual ~ISceneNode() - { - // delete all children - removeAll(); - - // delete all animators - core::list::Iterator ait = Animators.begin(); - for (; ait != Animators.end(); ++ait) - (*ait)->drop(); - - if (TriangleSelector) - TriangleSelector->drop(); - } - - - //! This method is called just before the rendering process of the whole scene. - /** Nodes may register themselves in the render pipeline during this call, - precalculate the geometry which should be renderered, and prevent their - children from being able to register them selfes if they are clipped by simply - not calling their OnRegisterSceneNode-Method. - If you are implementing your own scene node, you should overwrite this method - with an implementtion code looking like this: - \code - if (IsVisible) - SceneManager->registerNodeForRendering(this); - - ISceneNode::OnRegisterSceneNode(); - \endcode - */ - virtual void OnRegisterSceneNode() - { - if (IsVisible) - { - core::list::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - (*it)->OnRegisterSceneNode(); - } - } - - - //! OnAnimate() is called just before rendering the whole scene. - //! Nodes may calculate or store animations here, and may do other useful things, - //! dependent on what they are. Also, OnAnimate() should be called for all - //! child scene nodes here. This method will called once per frame, independent - //! of if the scene node is visible or not. - //! \param timeMs: Current time in milli seconds. - virtual void OnAnimate(u32 timeMs) - { - if (IsVisible) - { - // animate this node with all animators - - core::list::Iterator ait = Animators.begin(); - for (; ait != Animators.end(); ++ait) - (*ait)->animateNode(this, timeMs); - - // update absolute position - updateAbsolutePosition(); - - // perform the post render process on all children - - core::list::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - (*it)->OnAnimate(timeMs); - } - } - - - //! Renders the node. - virtual void render() = 0; - - - //! Returns the name of the node. - //! \return Returns name as wide character string. - virtual const c8* getName() const - { - return Name.c_str(); - } - - - //! Sets the name of the node. - //! \param name: New name of the scene node. - virtual void setName(const c8* name) - { - Name = name; - } - - - //! Returns the axis aligned, not transformed bounding box of this node. - //! This means that if this node is a animated 3d character, moving in a room, - //! the bounding box will always be around the origin. To get the box in - //! real world coordinates, just transform it with the matrix you receive with - //! getAbsoluteTransformation() or simply use getTransformedBoundingBox(), - //! which does the same. - virtual const core::aabbox3d& getBoundingBox() const = 0; - - - //! Returns the axis aligned, transformed and animated absolute bounding box - //! of this node. - virtual const core::aabbox3d getTransformedBoundingBox() const - { - core::aabbox3d box = getBoundingBox(); - AbsoluteTransformation.transformBox(box); - return box; - } - - - //! returns the absolute transformation of the node. Is recalculated every OnAnimate()-call. - const core::matrix4& getAbsoluteTransformation() const - { - return AbsoluteTransformation; - } - - - //! Returns the relative transformation of the scene node. - //! The relative transformation is stored internally as 3 vectors: - //! translation, rotation and scale. To get the relative transformation - //! matrix, it is calculated from these values. - //! \return Returns the relative transformation matrix. - virtual core::matrix4 getRelativeTransformation() const - { - core::matrix4 mat; - mat.setRotationDegrees(RelativeRotation); - mat.setTranslation(RelativeTranslation); - - if (RelativeScale != core::vector3df(1,1,1)) - { - core::matrix4 smat; - smat.setScale(RelativeScale); - mat *= smat; - } - - return mat; - } - - - //! Returns true if the node is visible. This is only an option, set by the user and has - //! nothing to do with geometry culling - virtual bool isVisible() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsVisible; - } - - - //! Sets if the node should be visible or not. All children of this node won't be visible too. - virtual void setVisible(bool isVisible) - { - IsVisible = isVisible; - } - - - //! Returns the id of the scene node. This id can be used to identify the node. - virtual s32 getID() const - { - return ID; - } - - - //! sets the id of the scene node. This id can be used to identify the node. - virtual void setID(s32 id) - { - ID = id; - } - - - //! Adds a child to this scene node. If the scene node already - //! has got a parent, it is removed from there as child. - virtual void addChild(ISceneNode* child) - { - if (child) - { - child->grab(); - child->remove(); // remove from old parent - Children.push_back(child); - child->Parent = this; - } - } - - - //! Removes a child from this scene node. - //! \return Returns true if the child could be removed, and false if not. - virtual bool removeChild(ISceneNode* child) - { - core::list::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - if ((*it) == child) - { - (*it)->Parent = 0; - (*it)->drop(); - Children.erase(it); - return true; - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - - //! Removes all children of this scene node - virtual void removeAll() - { - core::list::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - { - (*it)->Parent = 0; - (*it)->drop(); - } - - Children.clear(); - } - - - //! Removes this scene node from the scene, deleting it. - virtual void remove() - { - if (Parent) - Parent->removeChild(this); - } - - - //! Adds an animator which should animate this node. - virtual void addAnimator(ISceneNodeAnimator* animator) - { - if (animator) - { - Animators.push_back(animator); - animator->grab(); - } - } - - - //! Returns a const reference to the list of all scene node animators. - const core::list& getAnimators() const - { - return Animators; - } - - - //! Removes an animator from this scene node. - virtual void removeAnimator(ISceneNodeAnimator* animator) - { - core::list::Iterator it = Animators.begin(); - for (; it != Animators.end(); ++it) - if ((*it) == animator) - { - (*it)->drop(); - Animators.erase(it); - return; - } - } - - - //! Removes all animators from this scene node. - virtual void removeAnimators() - { - core::list::Iterator it = Animators.begin(); - for (; it != Animators.end(); ++it) - (*it)->drop(); - - Animators.clear(); - } - - - //! Returns the material based on the zero based index i. To get the amount - //! of materials used by this scene node, use getMaterialCount(). - //! This function is needed for inserting the node into the scene hirachy on a - //! optimal position for minimizing renderstate changes, but can also be used - //! to directly modify the material of a scene node. - //! \param num: Zero based index. The maximal value is getMaterialCount() - 1. - //! \return Returns the material of that index. - virtual video::SMaterial& getMaterial(u32 num) - { - return *((video::SMaterial*)0); - } - - - //! Returns amount of materials used by this scene node. - //! \return Returns current count of materials used by this scene node. - virtual u32 getMaterialCount() - { - return 0; - } - - - //! Sets all material flags at once to a new value. Helpful for - //! example, if you want to be the the whole mesh to be lighted by - //! \param flag: Which flag of all materials to be set. - //! \param newvalue: New value of the flag. - void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) - { - for (u32 i=0; i= video::MATERIAL_MAX_TEXTURES) - return; - - for (u32 i=0; i& getChildren() const - { - return Children; - } - - - //! Changes the parent of the scene node. - virtual void setParent(ISceneNode* newParent) - { - grab(); - remove(); - - Parent = newParent; - - if (Parent) - Parent->addChild(this); - - drop(); - } - - - //! Returns the triangle selector attached to this scene node. - //! The Selector can be used by the engine for doing collision - //! detection. You can create a TriangleSelector with - //! ISceneManager::createTriangleSelector() or - //! ISceneManager::createOctTreeTriangleSelector and set it with - //! ISceneNode::setTriangleSelector(). If a scene node got no triangle - //! selector, but collision tests should be done with it, a triangle - //! selector is created using the bounding box of the scene node. - //! \return Returns a pointer to the TriangleSelector or NULL, if there - //! is none. - virtual ITriangleSelector* getTriangleSelector() const - { - return TriangleSelector; - } - - - //! Sets the triangle selector of the scene node. The Selector can be - //! used by the engine for doing collision detection. You can create a - //! TriangleSelector with ISceneManager::createTriangleSelector() or - //! ISceneManager::createOctTreeTriangleSelector(). Some nodes may - //! create their own selector by default, so it would be good to - //! check if there is already a selector in this node by calling - //! ISceneNode::getTriangleSelector(). - //! \param selector: New triangle selector for this scene node. - virtual void setTriangleSelector(ITriangleSelector* selector) - { - if (TriangleSelector) - TriangleSelector->drop(); - - TriangleSelector = selector; - if (TriangleSelector) - TriangleSelector->grab(); - } - - //! updates the absolute position based on the relative and the parents position - virtual void updateAbsolutePosition() - { - if (Parent ) - { - AbsoluteTransformation = - Parent->getAbsoluteTransformation() * getRelativeTransformation(); - } - else - AbsoluteTransformation = getRelativeTransformation(); - } - - //! Returns the parent of this scene node - scene::ISceneNode* getParent() const - { - return Parent; - } - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const - { - return ESNT_UNKNOWN; - } - - //! Writes attributes of the scene node. - //! Implement this to expose the attributes of your scene node for - //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) - { - out->addString ("Name", Name.c_str()); - out->addInt ("Id", ID ); - out->addVector3d("Position", RelativeTranslation ); - out->addVector3d("Rotation", RelativeRotation ); - out->addVector3d("Scale", RelativeScale ); - out->addBool ("Visible", IsVisible ); - out->addEnum ("AutomaticCulling", AutomaticCullingState, AutomaticCullingNames); - out->addInt ("DebugDataVisible", DebugDataVisible ); - out->addBool ("IsDebugObject", IsDebugObject ); - } - - //! Reads attributes of the scene node. - //! Implement this to set the attributes of your scene node for - //! scripting languages, editors, debuggers or xml deserialization purposes. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) - { - Name = in->getAttributeAsString("Name"); - ID = in->getAttributeAsInt("Id"); - RelativeTranslation = in->getAttributeAsVector3d("Position"); - RelativeRotation = in->getAttributeAsVector3d("Rotation"); - RelativeScale = in->getAttributeAsVector3d("Scale"); - IsVisible = in->getAttributeAsBool("Visible"); - AutomaticCullingState = (scene::E_CULLING_TYPE ) in->getAttributeAsEnumeration("AutomaticCulling", scene::AutomaticCullingNames); - - DebugDataVisible = (scene::E_DEBUG_SCENE_TYPE ) in->getAttributeAsInt("DebugDataVisible"); - IsDebugObject = in->getAttributeAsBool("IsDebugObject"); - - updateAbsolutePosition(); - } - - protected: - - //! name of the scene node. - core::stringc Name; - - //! absolute transformation of the node. - core::matrix4 AbsoluteTransformation; - - //! relative translation of the scene node. - core::vector3df RelativeTranslation; - - //! relative rotation of the scene node. - core::vector3df RelativeRotation; - - //! relative scale of the scene node. - core::vector3df RelativeScale; - - //! Pointer to the parent - ISceneNode* Parent; - - //! List of all children of this node - core::list Children; - - //! List of all animator nodes - core::list Animators; - - //! id of the node. - s32 ID; - - //! pointer to the scene manager - ISceneManager* SceneManager; - - //! pointer to the triangle selector - ITriangleSelector* TriangleSelector; - - //! automatic culling - E_CULLING_TYPE AutomaticCullingState; - - //! is the node visible? - bool IsVisible; - - //! flag if debug data should be drawn, such as Bounding Boxes. - E_DEBUG_SCENE_TYPE DebugDataVisible; - - //! is debug object? - bool IsDebugObject; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_SCENE_NODE_H_INCLUDED__ +#define __I_SCENE_NODE_H_INCLUDED__ + +#include "IUnknown.h" +#include "ESceneNodeTypes.h" +#include "ISceneManager.h" +#include "ISceneNodeAnimator.h" +#include "ITriangleSelector.h" +#include "SMaterial.h" +#include "irrString.h" +#include "aabbox3d.h" +#include "matrix4.h" +#include "irrList.h" +#include "IAttributes.h" +#include "IAttributeExchangingObject.h" + +namespace irr +{ +namespace scene +{ + //! Scene node interface. + /** A scene node is a node in the hirachical scene graph. Every scene node may have children, + which are other scene nodes. Children move relative the their parents position. If the parent of a node is not + visible, its children won't be visible too. In this way, it is for example easily possible + to attach a light to a moving car, or to place a walking character on a moving platform + on a moving ship. */ + class ISceneNode : public io::IAttributeExchangingObject + { + public: + + //! Constructor + ISceneNode( ISceneNode* parent, ISceneManager* mgr, s32 id=-1, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) + : RelativeTranslation(position), RelativeRotation(rotation), RelativeScale(scale), + Parent(parent), ID(id), SceneManager(mgr), TriangleSelector(0), + AutomaticCullingState(EAC_BOX), IsVisible(true), + DebugDataVisible(EDS_OFF), IsDebugObject(false) + { + if (Parent) + Parent->addChild(this); + + updateAbsolutePosition(); + } + + + + //! Destructor + virtual ~ISceneNode() + { + // delete all children + removeAll(); + + // delete all animators + core::list::Iterator ait = Animators.begin(); + for (; ait != Animators.end(); ++ait) + (*ait)->drop(); + + if (TriangleSelector) + TriangleSelector->drop(); + } + + + //! This method is called just before the rendering process of the whole scene. + /** Nodes may register themselves in the render pipeline during this call, + precalculate the geometry which should be renderered, and prevent their + children from being able to register them selfes if they are clipped by simply + not calling their OnRegisterSceneNode-Method. + If you are implementing your own scene node, you should overwrite this method + with an implementtion code looking like this: + \code + if (IsVisible) + SceneManager->registerNodeForRendering(this); + + ISceneNode::OnRegisterSceneNode(); + \endcode + */ + virtual void OnRegisterSceneNode() + { + if (IsVisible) + { + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + (*it)->OnRegisterSceneNode(); + } + } + + + //! OnAnimate() is called just before rendering the whole scene. + //! Nodes may calculate or store animations here, and may do other useful things, + //! dependent on what they are. Also, OnAnimate() should be called for all + //! child scene nodes here. This method will called once per frame, independent + //! of if the scene node is visible or not. + //! \param timeMs: Current time in milli seconds. + virtual void OnAnimate(u32 timeMs) + { + if (IsVisible) + { + // animate this node with all animators + + core::list::Iterator ait = Animators.begin(); + for (; ait != Animators.end(); ++ait) + (*ait)->animateNode(this, timeMs); + + // update absolute position + updateAbsolutePosition(); + + // perform the post render process on all children + + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + (*it)->OnAnimate(timeMs); + } + } + + + //! Renders the node. + virtual void render() = 0; + + + //! Returns the name of the node. + //! \return Returns name as wide character string. + virtual const c8* getName() const + { + return Name.c_str(); + } + + + //! Sets the name of the node. + //! \param name: New name of the scene node. + virtual void setName(const c8* name) + { + Name = name; + } + + + //! Returns the axis aligned, not transformed bounding box of this node. + //! This means that if this node is a animated 3d character, moving in a room, + //! the bounding box will always be around the origin. To get the box in + //! real world coordinates, just transform it with the matrix you receive with + //! getAbsoluteTransformation() or simply use getTransformedBoundingBox(), + //! which does the same. + virtual const core::aabbox3d& getBoundingBox() const = 0; + + + //! Returns the axis aligned, transformed and animated absolute bounding box + //! of this node. + virtual const core::aabbox3d getTransformedBoundingBox() const + { + core::aabbox3d box = getBoundingBox(); + AbsoluteTransformation.transformBox(box); + return box; + } + + + //! returns the absolute transformation of the node. Is recalculated every OnAnimate()-call. + const core::matrix4& getAbsoluteTransformation() const + { + return AbsoluteTransformation; + } + + + //! Returns the relative transformation of the scene node. + //! The relative transformation is stored internally as 3 vectors: + //! translation, rotation and scale. To get the relative transformation + //! matrix, it is calculated from these values. + //! \return Returns the relative transformation matrix. + virtual core::matrix4 getRelativeTransformation() const + { + core::matrix4 mat; + mat.setRotationDegrees(RelativeRotation); + mat.setTranslation(RelativeTranslation); + + if (RelativeScale != core::vector3df(1,1,1)) + { + core::matrix4 smat; + smat.setScale(RelativeScale); + mat *= smat; + } + + return mat; + } + + + //! Returns true if the node is visible. This is only an option, set by the user and has + //! nothing to do with geometry culling + virtual bool isVisible() const + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return IsVisible; + } + + + //! Sets if the node should be visible or not. All children of this node won't be visible too. + virtual void setVisible(bool isVisible) + { + IsVisible = isVisible; + } + + + //! Returns the id of the scene node. This id can be used to identify the node. + virtual s32 getID() const + { + return ID; + } + + + //! sets the id of the scene node. This id can be used to identify the node. + virtual void setID(s32 id) + { + ID = id; + } + + + //! Adds a child to this scene node. If the scene node already + //! has got a parent, it is removed from there as child. + virtual void addChild(ISceneNode* child) + { + if (child) + { + child->grab(); + child->remove(); // remove from old parent + Children.push_back(child); + child->Parent = this; + } + } + + + //! Removes a child from this scene node. + //! \return Returns true if the child could be removed, and false if not. + virtual bool removeChild(ISceneNode* child) + { + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + if ((*it) == child) + { + (*it)->Parent = 0; + (*it)->drop(); + Children.erase(it); + return true; + } + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return false; + } + + + //! Removes all children of this scene node + virtual void removeAll() + { + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + { + (*it)->Parent = 0; + (*it)->drop(); + } + + Children.clear(); + } + + + //! Removes this scene node from the scene, deleting it. + virtual void remove() + { + if (Parent) + Parent->removeChild(this); + } + + + //! Adds an animator which should animate this node. + virtual void addAnimator(ISceneNodeAnimator* animator) + { + if (animator) + { + Animators.push_back(animator); + animator->grab(); + } + } + + + //! Returns a const reference to the list of all scene node animators. + const core::list& getAnimators() const + { + return Animators; + } + + + //! Removes an animator from this scene node. + virtual void removeAnimator(ISceneNodeAnimator* animator) + { + core::list::Iterator it = Animators.begin(); + for (; it != Animators.end(); ++it) + if ((*it) == animator) + { + (*it)->drop(); + Animators.erase(it); + return; + } + } + + + //! Removes all animators from this scene node. + virtual void removeAnimators() + { + core::list::Iterator it = Animators.begin(); + for (; it != Animators.end(); ++it) + (*it)->drop(); + + Animators.clear(); + } + + + //! Returns the material based on the zero based index i. To get the amount + //! of materials used by this scene node, use getMaterialCount(). + //! This function is needed for inserting the node into the scene hirachy on a + //! optimal position for minimizing renderstate changes, but can also be used + //! to directly modify the material of a scene node. + //! \param num: Zero based index. The maximal value is getMaterialCount() - 1. + //! \return Returns the material of that index. + virtual video::SMaterial& getMaterial(u32 num) + { + return *((video::SMaterial*)0); + } + + + //! Returns amount of materials used by this scene node. + //! \return Returns current count of materials used by this scene node. + virtual u32 getMaterialCount() + { + return 0; + } + + + //! Sets all material flags at once to a new value. Helpful for + //! example, if you want to be the the whole mesh to be lighted by + //! \param flag: Which flag of all materials to be set. + //! \param newvalue: New value of the flag. + void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) + { + for (u32 i=0; i= video::MATERIAL_MAX_TEXTURES) + return; + + for (u32 i=0; i& getChildren() const + { + return Children; + } + + + //! Changes the parent of the scene node. + virtual void setParent(ISceneNode* newParent) + { + grab(); + remove(); + + Parent = newParent; + + if (Parent) + Parent->addChild(this); + + drop(); + } + + + //! Returns the triangle selector attached to this scene node. + //! The Selector can be used by the engine for doing collision + //! detection. You can create a TriangleSelector with + //! ISceneManager::createTriangleSelector() or + //! ISceneManager::createOctTreeTriangleSelector and set it with + //! ISceneNode::setTriangleSelector(). If a scene node got no triangle + //! selector, but collision tests should be done with it, a triangle + //! selector is created using the bounding box of the scene node. + //! \return Returns a pointer to the TriangleSelector or NULL, if there + //! is none. + virtual ITriangleSelector* getTriangleSelector() const + { + return TriangleSelector; + } + + + //! Sets the triangle selector of the scene node. The Selector can be + //! used by the engine for doing collision detection. You can create a + //! TriangleSelector with ISceneManager::createTriangleSelector() or + //! ISceneManager::createOctTreeTriangleSelector(). Some nodes may + //! create their own selector by default, so it would be good to + //! check if there is already a selector in this node by calling + //! ISceneNode::getTriangleSelector(). + //! \param selector: New triangle selector for this scene node. + virtual void setTriangleSelector(ITriangleSelector* selector) + { + if (TriangleSelector) + TriangleSelector->drop(); + + TriangleSelector = selector; + if (TriangleSelector) + TriangleSelector->grab(); + } + + //! updates the absolute position based on the relative and the parents position + virtual void updateAbsolutePosition() + { + if (Parent ) + { + AbsoluteTransformation = + Parent->getAbsoluteTransformation() * getRelativeTransformation(); + } + else + AbsoluteTransformation = getRelativeTransformation(); + } + + //! Returns the parent of this scene node + scene::ISceneNode* getParent() const + { + return Parent; + } + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() const + { + return ESNT_UNKNOWN; + } + + //! Writes attributes of the scene node. + //! Implement this to expose the attributes of your scene node for + //! scripting languages, editors, debuggers or xml serialization purposes. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) + { + out->addString ("Name", Name.c_str()); + out->addInt ("Id", ID ); + out->addVector3d("Position", RelativeTranslation ); + out->addVector3d("Rotation", RelativeRotation ); + out->addVector3d("Scale", RelativeScale ); + out->addBool ("Visible", IsVisible ); + out->addEnum ("AutomaticCulling", AutomaticCullingState, AutomaticCullingNames); + out->addInt ("DebugDataVisible", DebugDataVisible ); + out->addBool ("IsDebugObject", IsDebugObject ); + } + + //! Reads attributes of the scene node. + //! Implement this to set the attributes of your scene node for + //! scripting languages, editors, debuggers or xml deserialization purposes. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) + { + Name = in->getAttributeAsString("Name"); + ID = in->getAttributeAsInt("Id"); + RelativeTranslation = in->getAttributeAsVector3d("Position"); + RelativeRotation = in->getAttributeAsVector3d("Rotation"); + RelativeScale = in->getAttributeAsVector3d("Scale"); + IsVisible = in->getAttributeAsBool("Visible"); + AutomaticCullingState = (scene::E_CULLING_TYPE ) in->getAttributeAsEnumeration("AutomaticCulling", scene::AutomaticCullingNames); + + DebugDataVisible = (scene::E_DEBUG_SCENE_TYPE ) in->getAttributeAsInt("DebugDataVisible"); + IsDebugObject = in->getAttributeAsBool("IsDebugObject"); + + updateAbsolutePosition(); + } + + protected: + + //! name of the scene node. + core::stringc Name; + + //! absolute transformation of the node. + core::matrix4 AbsoluteTransformation; + + //! relative translation of the scene node. + core::vector3df RelativeTranslation; + + //! relative rotation of the scene node. + core::vector3df RelativeRotation; + + //! relative scale of the scene node. + core::vector3df RelativeScale; + + //! Pointer to the parent + ISceneNode* Parent; + + //! List of all children of this node + core::list Children; + + //! List of all animator nodes + core::list Animators; + + //! id of the node. + s32 ID; + + //! pointer to the scene manager + ISceneManager* SceneManager; + + //! pointer to the triangle selector + ITriangleSelector* TriangleSelector; + + //! automatic culling + E_CULLING_TYPE AutomaticCullingState; + + //! is the node visible? + bool IsVisible; + + //! flag if debug data should be drawn, such as Bounding Boxes. + E_DEBUG_SCENE_TYPE DebugDataVisible; + + //! is debug object? + bool IsDebugObject; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/ISceneNodeAnimator.h b/src/dep/include/irrlicht/ISceneNodeAnimator.h index 06ba17e..2e84973 100644 --- a/src/dep/include/irrlicht/ISceneNodeAnimator.h +++ b/src/dep/include/irrlicht/ISceneNodeAnimator.h @@ -1,52 +1,52 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_NODE_ANIMATOR_H_INCLUDED__ -#define __I_SCENE_NODE_ANIMATOR_H_INCLUDED__ - -#include "IUnknown.h" -#include "vector3d.h" -#include "ESceneNodeAnimatorTypes.h" -#include "IAttributeExchangingObject.h" - -namespace irr -{ -namespace io -{ - class IAttributes; -} // end namespace io -namespace scene -{ - class ISceneNode; - - //! Animates a scene node. Can animate position, rotation, material, and so on. - /** A scene node animator is able to animate a scene node in a very simple way. It may - change its position, rotation, scale and/or material. There are lots of animators - to choose from. You can create scene node animators with the ISceneManager interface. - */ - class ISceneNodeAnimator : public io::IAttributeExchangingObject - { - public: - - //! destructor - virtual ~ISceneNodeAnimator() {} - - /// - /// Animates a scene node. - /// - /// \param node: Node to animate. - /// \param timeMs: Current time in milli seconds. - virtual void animateNode(ISceneNode* node, u32 timeMs) = 0; - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() - { - return ESNAT_UNKNOWN; - } - }; -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_SCENE_NODE_ANIMATOR_H_INCLUDED__ +#define __I_SCENE_NODE_ANIMATOR_H_INCLUDED__ + +#include "IUnknown.h" +#include "vector3d.h" +#include "ESceneNodeAnimatorTypes.h" +#include "IAttributeExchangingObject.h" + +namespace irr +{ +namespace io +{ + class IAttributes; +} // end namespace io +namespace scene +{ + class ISceneNode; + + //! Animates a scene node. Can animate position, rotation, material, and so on. + /** A scene node animator is able to animate a scene node in a very simple way. It may + change its position, rotation, scale and/or material. There are lots of animators + to choose from. You can create scene node animators with the ISceneManager interface. + */ + class ISceneNodeAnimator : public io::IAttributeExchangingObject + { + public: + + //! destructor + virtual ~ISceneNodeAnimator() {} + + /// + /// Animates a scene node. + /// + /// \param node: Node to animate. + /// \param timeMs: Current time in milli seconds. + virtual void animateNode(ISceneNode* node, u32 timeMs) = 0; + + //! Returns type of the scene node animator + virtual ESCENE_NODE_ANIMATOR_TYPE getType() + { + return ESNAT_UNKNOWN; + } + }; +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/ISceneNodeAnimatorCollisionResponse.h b/src/dep/include/irrlicht/ISceneNodeAnimatorCollisionResponse.h index 34fc7dd..e38991a 100644 --- a/src/dep/include/irrlicht/ISceneNodeAnimatorCollisionResponse.h +++ b/src/dep/include/irrlicht/ISceneNodeAnimatorCollisionResponse.h @@ -1,93 +1,93 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ -#define __I_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - - //! Special scene node animator for doing automatic collision detection and response. - /** This scene node animator can be attached to any scene node modifying it in that - way, that it cannot move through walls of the world, is influenced by gravity and - acceleration. This animator is useful for example for first person shooter - games. Attach it for example to a first person shooter camera, and the camera will - behave as the player control in a first person shooter game: The camera stops and - slides at walls, walks up stairs, falls down if there is no floor under it, and so on. - */ - class ISceneNodeAnimatorCollisionResponse : public ISceneNodeAnimator - { - public: - - //! destructor - virtual ~ISceneNodeAnimatorCollisionResponse() {} - - //! Returns if the attached scene node is falling, which means that - //! there is no blocking wall from the scene node in the direction of - //! the gravity. The implementation of this method is very fast, - //! no collision detection is done when invoking it. - //! \return Returns true if the scene node is falling, false if not. - virtual bool isFalling() = 0; - - //! Sets the radius of the ellipsoid with which collision detection and - //! response is done. If you have got a scene node, and you are unsure about - //! how big the radius should be, you could use the following code to determine - //! it: - //! \code - //! core::aabbox box = yourSceneNode->getBoundingBox(); - //! core::vector3df radius = box.MaxEdge - box.getCenter(); - //! \endcode - //! \param radius: New radius of the ellipsoid. - virtual void setEllipsoidRadius(const core::vector3df& radius) = 0; - - //! Returns the radius of the ellipsoid with wich the collision detection and - //! response is done. - //! \return Radius of the ellipsoid. - virtual core::vector3df getEllipsoidRadius() const = 0; - - //! Sets the gravity of the environment. A good example value would be - //! core::vector3df(0,-100.0f,0) for letting gravity affect all object to - //! fall down. For bigger gravity, make increase the length of the vector. - //! You can disable gravity by setting it to core::vector3df(0,0,0); - //! \param gravity: New gravity vector. - virtual void setGravity(const core::vector3df& gravity) = 0; - - //! Returns current vector of gravity. - //! \return Returns the gravity vector. - virtual core::vector3df getGravity() const = 0; - - //! By default, the ellipsoid for collision detection is created around - //! the center of the scene node, which means that the ellipsoid surrounds - //! it completely. If this is not what you want, you may specify a translation - //! for the ellipsoid. - //! \param translation: Translation of the ellipsoid relative - //! to the position of the scene node. - virtual void setEllipsoidTranslation(const core::vector3df &translation) = 0; - - //! Returns the translation of the ellipsoid for collision detection. See - //! ISceneNodeAnimatorCollisionResponse::setEllipsoidTranslation() for - //! more details. - //! \return Returns the tranlation of the ellipsoid relative to the position - //! of the scene node. - virtual core::vector3df getEllipsoidTranslation() const = 0; - - //! Sets a triangle selector holding all triangles of the world with which - //! the scene node may collide. - //! \param newWorld: New triangle selector containing triangles to let the - //! scene node collide with. - virtual void setWorld(ITriangleSelector* newWorld) = 0; - - //! Returns the current triangle selector containing all triangles for - //! collision detection. - virtual ITriangleSelector* getWorld() const = 0; - }; -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ +#define __I_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + + //! Special scene node animator for doing automatic collision detection and response. + /** This scene node animator can be attached to any scene node modifying it in that + way, that it cannot move through walls of the world, is influenced by gravity and + acceleration. This animator is useful for example for first person shooter + games. Attach it for example to a first person shooter camera, and the camera will + behave as the player control in a first person shooter game: The camera stops and + slides at walls, walks up stairs, falls down if there is no floor under it, and so on. + */ + class ISceneNodeAnimatorCollisionResponse : public ISceneNodeAnimator + { + public: + + //! destructor + virtual ~ISceneNodeAnimatorCollisionResponse() {} + + //! Returns if the attached scene node is falling, which means that + //! there is no blocking wall from the scene node in the direction of + //! the gravity. The implementation of this method is very fast, + //! no collision detection is done when invoking it. + //! \return Returns true if the scene node is falling, false if not. + virtual bool isFalling() = 0; + + //! Sets the radius of the ellipsoid with which collision detection and + //! response is done. If you have got a scene node, and you are unsure about + //! how big the radius should be, you could use the following code to determine + //! it: + //! \code + //! core::aabbox box = yourSceneNode->getBoundingBox(); + //! core::vector3df radius = box.MaxEdge - box.getCenter(); + //! \endcode + //! \param radius: New radius of the ellipsoid. + virtual void setEllipsoidRadius(const core::vector3df& radius) = 0; + + //! Returns the radius of the ellipsoid with wich the collision detection and + //! response is done. + //! \return Radius of the ellipsoid. + virtual core::vector3df getEllipsoidRadius() const = 0; + + //! Sets the gravity of the environment. A good example value would be + //! core::vector3df(0,-100.0f,0) for letting gravity affect all object to + //! fall down. For bigger gravity, make increase the length of the vector. + //! You can disable gravity by setting it to core::vector3df(0,0,0); + //! \param gravity: New gravity vector. + virtual void setGravity(const core::vector3df& gravity) = 0; + + //! Returns current vector of gravity. + //! \return Returns the gravity vector. + virtual core::vector3df getGravity() const = 0; + + //! By default, the ellipsoid for collision detection is created around + //! the center of the scene node, which means that the ellipsoid surrounds + //! it completely. If this is not what you want, you may specify a translation + //! for the ellipsoid. + //! \param translation: Translation of the ellipsoid relative + //! to the position of the scene node. + virtual void setEllipsoidTranslation(const core::vector3df &translation) = 0; + + //! Returns the translation of the ellipsoid for collision detection. See + //! ISceneNodeAnimatorCollisionResponse::setEllipsoidTranslation() for + //! more details. + //! \return Returns the tranlation of the ellipsoid relative to the position + //! of the scene node. + virtual core::vector3df getEllipsoidTranslation() const = 0; + + //! Sets a triangle selector holding all triangles of the world with which + //! the scene node may collide. + //! \param newWorld: New triangle selector containing triangles to let the + //! scene node collide with. + virtual void setWorld(ITriangleSelector* newWorld) = 0; + + //! Returns the current triangle selector containing all triangles for + //! collision detection. + virtual ITriangleSelector* getWorld() const = 0; + }; +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/ISceneNodeAnimatorFactory.h b/src/dep/include/irrlicht/ISceneNodeAnimatorFactory.h index 5a89858..6f7fce0 100644 --- a/src/dep/include/irrlicht/ISceneNodeAnimatorFactory.h +++ b/src/dep/include/irrlicht/ISceneNodeAnimatorFactory.h @@ -1,69 +1,69 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_NODE_ANIMATOR_FACTORY_H_INCLUDED__ -#define __I_SCENE_NODE_ANIMATOR_FACTORY_H_INCLUDED__ - -#include "IUnknown.h" -#include "ESceneNodeAnimatorTypes.h" - -namespace irr -{ -namespace scene -{ - class ISceneNode; - class ISceneNodeAnimator; - - //! Interface making it possible to dynamicly create scene nodes animators - /** To be able to add custom scene node animators to Irrlicht and to make it possible for the - scene manager to save and load those external animators, simply implement this - interface and register it in you scene manager via ISceneManager::registerSceneNodeAnimatorFactory. - Note: When implementing your own scene node factory, don't call ISceneNodeManager::grab() to - increase the reference counter of the scene node manager. This is not necessary because the - scene node manager will grab() the factory anyway, and otherwise cyclic references will - be created and the scene manager and all its nodes won't get deallocated. - */ - class ISceneNodeAnimatorFactory : public virtual IUnknown - { - public: - - //! creates a scene node animator based on its type id - /** \param type: Type of the scene node animator to add. - \param target: Target scene node of the new animator. - \return Returns pointer to the new scene node animator or null if not successful. You need to - drop this pointer after calling this, see IUnknown::drop() for details. */ - virtual ISceneNodeAnimator* createSceneNodeAnimator(ESCENE_NODE_ANIMATOR_TYPE type, ISceneNode* target) = 0; - - //! creates a scene node animator based on its type name - /** \param typeName: Type of the scene node animator to add. - \param target: Target scene node of the new animator. - \return Returns pointer to the new scene node animator or null if not successful. You need to - drop this pointer after calling this, see IUnknown::drop() for details. */ - virtual ISceneNodeAnimator* createSceneNodeAnimator(const c8* typeName, ISceneNode* target) = 0; - - //! returns amount of scene node animator types this factory is able to create - virtual s32 getCreatableSceneNodeAnimatorTypeCount() = 0; - - //! returns type of a createable scene node animator type - /** \param idx: Index of scene node animator type in this factory. Must be a value between 0 and - getCreatableSceneNodeTypeCount() */ - virtual ESCENE_NODE_ANIMATOR_TYPE getCreateableSceneNodeAnimatorType(s32 idx) = 0; - - //! returns type name of a createable scene node animator type - /** \param idx: Index of scene node animator type in this factory. Must be a value between 0 and - getCreatableSceneNodeAnimatorTypeCount() */ - virtual const c8* getCreateableSceneNodeAnimatorTypeName(s32 idx) = 0; - - //! returns type name of a createable scene node animator type - /** \param type: Type of scene node animator. - \return: Returns name of scene node animator type if this factory can create the type, otherwise 0. */ - virtual const c8* getCreateableSceneNodeAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type) = 0; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_SCENE_NODE_ANIMATOR_FACTORY_H_INCLUDED__ +#define __I_SCENE_NODE_ANIMATOR_FACTORY_H_INCLUDED__ + +#include "IUnknown.h" +#include "ESceneNodeAnimatorTypes.h" + +namespace irr +{ +namespace scene +{ + class ISceneNode; + class ISceneNodeAnimator; + + //! Interface making it possible to dynamicly create scene nodes animators + /** To be able to add custom scene node animators to Irrlicht and to make it possible for the + scene manager to save and load those external animators, simply implement this + interface and register it in you scene manager via ISceneManager::registerSceneNodeAnimatorFactory. + Note: When implementing your own scene node factory, don't call ISceneNodeManager::grab() to + increase the reference counter of the scene node manager. This is not necessary because the + scene node manager will grab() the factory anyway, and otherwise cyclic references will + be created and the scene manager and all its nodes won't get deallocated. + */ + class ISceneNodeAnimatorFactory : public virtual IUnknown + { + public: + + //! creates a scene node animator based on its type id + /** \param type: Type of the scene node animator to add. + \param target: Target scene node of the new animator. + \return Returns pointer to the new scene node animator or null if not successful. You need to + drop this pointer after calling this, see IUnknown::drop() for details. */ + virtual ISceneNodeAnimator* createSceneNodeAnimator(ESCENE_NODE_ANIMATOR_TYPE type, ISceneNode* target) = 0; + + //! creates a scene node animator based on its type name + /** \param typeName: Type of the scene node animator to add. + \param target: Target scene node of the new animator. + \return Returns pointer to the new scene node animator or null if not successful. You need to + drop this pointer after calling this, see IUnknown::drop() for details. */ + virtual ISceneNodeAnimator* createSceneNodeAnimator(const c8* typeName, ISceneNode* target) = 0; + + //! returns amount of scene node animator types this factory is able to create + virtual s32 getCreatableSceneNodeAnimatorTypeCount() = 0; + + //! returns type of a createable scene node animator type + /** \param idx: Index of scene node animator type in this factory. Must be a value between 0 and + getCreatableSceneNodeTypeCount() */ + virtual ESCENE_NODE_ANIMATOR_TYPE getCreateableSceneNodeAnimatorType(s32 idx) = 0; + + //! returns type name of a createable scene node animator type + /** \param idx: Index of scene node animator type in this factory. Must be a value between 0 and + getCreatableSceneNodeAnimatorTypeCount() */ + virtual const c8* getCreateableSceneNodeAnimatorTypeName(s32 idx) = 0; + + //! returns type name of a createable scene node animator type + /** \param type: Type of scene node animator. + \return: Returns name of scene node animator type if this factory can create the type, otherwise 0. */ + virtual const c8* getCreateableSceneNodeAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type) = 0; + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/ISceneNodeFactory.h b/src/dep/include/irrlicht/ISceneNodeFactory.h index faeee84..c6ebd2e 100644 --- a/src/dep/include/irrlicht/ISceneNodeFactory.h +++ b/src/dep/include/irrlicht/ISceneNodeFactory.h @@ -1,68 +1,68 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_NODE_FACTORY_H_INCLUDED__ -#define __I_SCENE_NODE_FACTORY_H_INCLUDED__ - -#include "IUnknown.h" -#include "ESceneNodeTypes.h" - -namespace irr -{ - - -namespace scene -{ - class ISceneNode; - - //! Interface making it possible to dynamicly create scene nodes - /** To be able to add custom scene nodes to Irrlicht and to make it possible for the - scene manager to save and load those external scene nodes, simply implement this - interface and register it in you scene manager via ISceneManager::registerSceneNodeFactory. - Note: When implementing your own scene node factory, don't call ISceneNodeManager::grab() to - increase the reference counter of the scene node manager. This is not necessary because the - scene node manager will grab() the factory anyway, and otherwise cyclic references will - be created and the scene manager and all its nodes won't get deallocated. - */ - class ISceneNodeFactory : public virtual IUnknown - { - public: - - //! adds a scene node to the scene graph based on its type id - /** \param type: Type of the scene node to add. - \param parent: Parent scene node of the new node, can be null to add the scene node to the root. - \return Returns pointer to the new scene node or null if not successful. */ - virtual ISceneNode* addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent=0) = 0; - - //! adds a scene node to the scene graph based on its type name - /** \param typeName: Type name of the scene node to add. - \param parent: Parent scene node of the new node, can be null to add the scene node to the root. - \return Returns pointer to the new scene node or null if not successful. */ - virtual ISceneNode* addSceneNode(const c8* typeName, ISceneNode* parent=0) = 0; - - //! returns amount of scene node types this factory is able to create - virtual s32 getCreatableSceneNodeTypeCount() = 0; - - //! returns type of a createable scene node type - /** \param idx: Index of scene node type in this factory. Must be a value between 0 and - getCreatableSceneNodeTypeCount() */ - virtual ESCENE_NODE_TYPE getCreateableSceneNodeType(s32 idx) = 0; - - //! returns type name of a createable scene node type by index - /** \param idx: Index of scene node type in this factory. Must be a value between 0 and - getCreatableSceneNodeTypeCount() */ - virtual const c8* getCreateableSceneNodeTypeName(s32 idx) = 0; - - //! returns type name of a createable scene node type - /** \param type: Type of scene node. - \return: Returns name of scene node type if this factory can create the type, otherwise 0. */ - virtual const c8* getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) = 0; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_SCENE_NODE_FACTORY_H_INCLUDED__ +#define __I_SCENE_NODE_FACTORY_H_INCLUDED__ + +#include "IUnknown.h" +#include "ESceneNodeTypes.h" + +namespace irr +{ + + +namespace scene +{ + class ISceneNode; + + //! Interface making it possible to dynamicly create scene nodes + /** To be able to add custom scene nodes to Irrlicht and to make it possible for the + scene manager to save and load those external scene nodes, simply implement this + interface and register it in you scene manager via ISceneManager::registerSceneNodeFactory. + Note: When implementing your own scene node factory, don't call ISceneNodeManager::grab() to + increase the reference counter of the scene node manager. This is not necessary because the + scene node manager will grab() the factory anyway, and otherwise cyclic references will + be created and the scene manager and all its nodes won't get deallocated. + */ + class ISceneNodeFactory : public virtual IUnknown + { + public: + + //! adds a scene node to the scene graph based on its type id + /** \param type: Type of the scene node to add. + \param parent: Parent scene node of the new node, can be null to add the scene node to the root. + \return Returns pointer to the new scene node or null if not successful. */ + virtual ISceneNode* addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent=0) = 0; + + //! adds a scene node to the scene graph based on its type name + /** \param typeName: Type name of the scene node to add. + \param parent: Parent scene node of the new node, can be null to add the scene node to the root. + \return Returns pointer to the new scene node or null if not successful. */ + virtual ISceneNode* addSceneNode(const c8* typeName, ISceneNode* parent=0) = 0; + + //! returns amount of scene node types this factory is able to create + virtual s32 getCreatableSceneNodeTypeCount() = 0; + + //! returns type of a createable scene node type + /** \param idx: Index of scene node type in this factory. Must be a value between 0 and + getCreatableSceneNodeTypeCount() */ + virtual ESCENE_NODE_TYPE getCreateableSceneNodeType(s32 idx) = 0; + + //! returns type name of a createable scene node type by index + /** \param idx: Index of scene node type in this factory. Must be a value between 0 and + getCreatableSceneNodeTypeCount() */ + virtual const c8* getCreateableSceneNodeTypeName(s32 idx) = 0; + + //! returns type name of a createable scene node type + /** \param type: Type of scene node. + \return: Returns name of scene node type if this factory can create the type, otherwise 0. */ + virtual const c8* getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) = 0; + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/ISceneUserDataSerializer.h b/src/dep/include/irrlicht/ISceneUserDataSerializer.h index b058c65..2885251 100644 --- a/src/dep/include/irrlicht/ISceneUserDataSerializer.h +++ b/src/dep/include/irrlicht/ISceneUserDataSerializer.h @@ -1,48 +1,48 @@ -// Copyright (C) 2002-2006 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_USER_DATA_SERIALIZER_H_INCLUDED__ -#define __I_SCENE_USER_DATA_SERIALIZER_H_INCLUDED__ - -#include "IUnknown.h" - -namespace irr -{ -namespace io -{ - class IAttributes; -} // end namespace io -namespace scene -{ - class ISceneNode; - -//! Interface to read and write user data to and from .irr files. -/** This interface is to be imlpemented by the user, to make it possible to read -and write user data when reading or writing .irr files via ISceneManager. -To be used with ISceneManager::loadScene() and ISceneManager::saveScene() */ -class ISceneUserDataSerializer -{ -public: - - virtual ~ISceneUserDataSerializer() {} - - //! Called when the scene manager read a scene node while loading a file. - /** The userData pointer contains a list of attributes with userData which - were attached to the scene node in the read scene file.*/ - virtual void OnReadUserData(ISceneNode* forSceneNode, io::IAttributes* userData) = 0; - - //! Called when the scene manager is writing a scene node to an xml file for example. - /** Implement this method and return a list of attributes containing the user data - you want to be saved together with the scene node. Return 0 if no user data should - be added. Please note that the scene manager will call drop() to the returned pointer - after it no longer needs it, so if you didn't create a new object for the return value - and returning a longer existing IAttributes object, simply call grab() before returning it. */ - virtual io::IAttributes* createUserData(ISceneNode* forSceneNode) = 0; -}; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2006 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_SCENE_USER_DATA_SERIALIZER_H_INCLUDED__ +#define __I_SCENE_USER_DATA_SERIALIZER_H_INCLUDED__ + +#include "IUnknown.h" + +namespace irr +{ +namespace io +{ + class IAttributes; +} // end namespace io +namespace scene +{ + class ISceneNode; + +//! Interface to read and write user data to and from .irr files. +/** This interface is to be imlpemented by the user, to make it possible to read +and write user data when reading or writing .irr files via ISceneManager. +To be used with ISceneManager::loadScene() and ISceneManager::saveScene() */ +class ISceneUserDataSerializer +{ +public: + + virtual ~ISceneUserDataSerializer() {} + + //! Called when the scene manager read a scene node while loading a file. + /** The userData pointer contains a list of attributes with userData which + were attached to the scene node in the read scene file.*/ + virtual void OnReadUserData(ISceneNode* forSceneNode, io::IAttributes* userData) = 0; + + //! Called when the scene manager is writing a scene node to an xml file for example. + /** Implement this method and return a list of attributes containing the user data + you want to be saved together with the scene node. Return 0 if no user data should + be added. Please note that the scene manager will call drop() to the returned pointer + after it no longer needs it, so if you didn't create a new object for the return value + and returning a longer existing IAttributes object, simply call grab() before returning it. */ + virtual io::IAttributes* createUserData(ISceneNode* forSceneNode) = 0; +}; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IShaderConstantSetCallBack.h b/src/dep/include/irrlicht/IShaderConstantSetCallBack.h index e11068f..03e215c 100644 --- a/src/dep/include/irrlicht/IShaderConstantSetCallBack.h +++ b/src/dep/include/irrlicht/IShaderConstantSetCallBack.h @@ -1,67 +1,67 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SHADER_CONSTANT_SET_CALLBACT_H_INCLUDED__ -#define __I_SHADER_CONSTANT_SET_CALLBACT_H_INCLUDED__ - -#include "IUnknown.h" - -namespace irr -{ -namespace video -{ - class IMaterialRendererServices; - -//! Interface making it possible to set constants for gpu programs every frame. -/** Implement this interface in an own class and pass a pointer to it to one of the methods in - IGPUProgrammingServices when creating a shader. The OnSetConstants method will be called - every frame now. */ -class IShaderConstantSetCallBack : public virtual IUnknown -{ -public: - - //! Destructor. - virtual ~IShaderConstantSetCallBack() {} - - //! Called by the engine when the vertex and/or pixel shader constants for an material renderer should be set. - /** - Implement the IShaderConstantSetCallBack in an own class and implement your own - OnSetConstants method using the given IMaterialRendererServices interface. - Pass a pointer to this class to one of the methods in IGPUProgrammingServices - when creating a shader. The OnSetConstants method will now be called every time - before geometry is being drawn using your shader material. A sample implementation - would look like this: - \code - virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData) - { - video::IVideoDriver* driver = services->getVideoDriver(); - - // set clip matrix at register 4 - core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - services->setVertexShaderConstant(&worldViewProj.M[0], 4, 4); - // for high level shading languages, this would be another solution: - //services->setVertexShaderConstant("mWorldViewProj", worldViewProj.M, 16); - - // set some light color at register 9 - video::SColorf col(0.0f,1.0f,1.0f,0.0f); - services->setVertexShaderConstant(reinterpret_cast(&col), 9, 1); - // for high level shading languages, this would be another solution: - //services->setVertexShaderConstant("myColor", reinterpret_cast(&col), 4); - } - \endcode - \param services: Pointer to an interface providing methods to set the constants for the shader. - \param userData: Userdata int which can be specified when creating the shader. - */ - virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData) = 0; -}; - - -} // end namespace video -} // end namespace irr - -#endif - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_SHADER_CONSTANT_SET_CALLBACT_H_INCLUDED__ +#define __I_SHADER_CONSTANT_SET_CALLBACT_H_INCLUDED__ + +#include "IUnknown.h" + +namespace irr +{ +namespace video +{ + class IMaterialRendererServices; + +//! Interface making it possible to set constants for gpu programs every frame. +/** Implement this interface in an own class and pass a pointer to it to one of the methods in + IGPUProgrammingServices when creating a shader. The OnSetConstants method will be called + every frame now. */ +class IShaderConstantSetCallBack : public virtual IUnknown +{ +public: + + //! Destructor. + virtual ~IShaderConstantSetCallBack() {} + + //! Called by the engine when the vertex and/or pixel shader constants for an material renderer should be set. + /** + Implement the IShaderConstantSetCallBack in an own class and implement your own + OnSetConstants method using the given IMaterialRendererServices interface. + Pass a pointer to this class to one of the methods in IGPUProgrammingServices + when creating a shader. The OnSetConstants method will now be called every time + before geometry is being drawn using your shader material. A sample implementation + would look like this: + \code + virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData) + { + video::IVideoDriver* driver = services->getVideoDriver(); + + // set clip matrix at register 4 + core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); + worldViewProj *= driver->getTransform(video::ETS_VIEW); + worldViewProj *= driver->getTransform(video::ETS_WORLD); + services->setVertexShaderConstant(&worldViewProj.M[0], 4, 4); + // for high level shading languages, this would be another solution: + //services->setVertexShaderConstant("mWorldViewProj", worldViewProj.M, 16); + + // set some light color at register 9 + video::SColorf col(0.0f,1.0f,1.0f,0.0f); + services->setVertexShaderConstant(reinterpret_cast(&col), 9, 1); + // for high level shading languages, this would be another solution: + //services->setVertexShaderConstant("myColor", reinterpret_cast(&col), 4); + } + \endcode + \param services: Pointer to an interface providing methods to set the constants for the shader. + \param userData: Userdata int which can be specified when creating the shader. + */ + virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData) = 0; +}; + + +} // end namespace video +} // end namespace irr + +#endif + + diff --git a/src/dep/include/irrlicht/IShadowVolumeSceneNode.h b/src/dep/include/irrlicht/IShadowVolumeSceneNode.h index f8cb31b..dd60036 100644 --- a/src/dep/include/irrlicht/IShadowVolumeSceneNode.h +++ b/src/dep/include/irrlicht/IShadowVolumeSceneNode.h @@ -1,33 +1,33 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__ -#define __I_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "IMesh.h" - -namespace irr -{ -namespace scene -{ - - //! Scene node for rendering a shadow volume into a stencil buffer. - class IShadowVolumeSceneNode : public ISceneNode - { - public: - - //! constructor - IShadowVolumeSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id) - : ISceneNode(parent, mgr, id) {} - - //! sets the mesh from which the shadow volume should be generated. - virtual void setMeshToRenderFrom(IMesh* mesh) = 0; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__ +#define __I_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" +#include "IMesh.h" + +namespace irr +{ +namespace scene +{ + + //! Scene node for rendering a shadow volume into a stencil buffer. + class IShadowVolumeSceneNode : public ISceneNode + { + public: + + //! constructor + IShadowVolumeSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id) + : ISceneNode(parent, mgr, id) {} + + //! sets the mesh from which the shadow volume should be generated. + virtual void setMeshToRenderFrom(IMesh* mesh) = 0; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/ITerrainSceneNode.h b/src/dep/include/irrlicht/ITerrainSceneNode.h index f016e00..da32005 100644 --- a/src/dep/include/irrlicht/ITerrainSceneNode.h +++ b/src/dep/include/irrlicht/ITerrainSceneNode.h @@ -1,140 +1,140 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// The code for the TerrainSceneNode is based on the terrain renderer by Soconne and -// the GeoMipMapSceneNode developed by Spintz. They made their code available for Irrlicht -// and allowed it to be distributed under this licence. I only modified some parts. -// A lot of thanks go to them. - -#ifndef __I_TERRAIN_SCENE_NODE_H__ -#define __I_TERRAIN_SCENE_NODE_H__ - -#include "ETerrainElements.h" -#include "ISceneNode.h" -#include "SMeshBufferLightMap.h" -#include "IMesh.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - //! A scene node for displaying terrain using the geo mip map algorithm. - /** The code for the TerrainSceneNode is based on the Terrain renderer by Soconne and - * the GeoMipMapSceneNode developed by Spintz. They made their code available for Irrlicht - * and allowed it to be distributed under this licence. I only modified some parts. - * A lot of thanks go to them. - * - * This scene node is capable of very quickly loading - * terrains and updating the indices at runtime to enable viewing very large terrains. It uses a - * CLOD ( Continuous Level of Detail ) algorithm which updates the indices for each patch based on - * a LOD ( Level of Detail ) which is determined based on a patch's distance from the camera. - * - * The Patch Size of the terrain must always be a size of ( 2^N+1, i.e. 8+1(9), 16+1(17), etc. ). - * The MaxLOD available is directly dependent on the patch size of the terrain. LOD 0 contains all - * of the indices to draw all the triangles at the max detail for a patch. As each LOD goes up by 1 - * the step taken, in generating indices increases by - 2^LOD, so for LOD 1, the step taken is 2, for - * LOD 2, the step taken is 4, LOD 3 - 8, etc. The step can be no larger than the size of the patch, - * so having a LOD of 8, with a patch size of 17, is asking the algoritm to generate indices every - * 2^8 ( 256 ) vertices, which is not possible with a patch size of 17. The maximum LOD for a patch - * size of 17 is 2^4 ( 16 ). So, with a MaxLOD of 5, you'll have LOD 0 ( full detail ), LOD 1 ( every - * 2 vertices ), LOD 2 ( every 4 vertices ), LOD 3 ( every 8 vertices ) and LOD 4 ( every 16 vertices ). - **/ - class ITerrainSceneNode : public ISceneNode - { - public: - - //! constructor - ITerrainSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0.0f, 0.0f, 0.0f), - const core::vector3df& rotation = core::vector3df(0.0f, 0.0f, 0.0f), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f) ) - : ISceneNode (parent, mgr, id, position, rotation, scale) {} - - //! destructor - virtual ~ITerrainSceneNode() {}; - - //! \return: Returns the bounding box of the entire terrain. - virtual const core::aabbox3d& getBoundingBox ( ) const = 0; - - //! Returns the bounding box of a patch - virtual const core::aabbox3d& getBoundingBox (s32 patchX, s32 patchZ) const = 0; - - //! Returns the number of indices currently in the meshbuffer for this scene node. - virtual u32 getIndexCount() = 0; - - //! Returns pointer to the mesh - virtual IMesh* getMesh() = 0; - - //! Gets the meshbuffer data based on a specified level of detail. - /** \param mb: A reference to an SMeshBuffer object - \param LOD: the level of detail you want the indices from. */ - virtual void getMeshBufferForLOD(SMeshBufferLightMap& mb, s32 LOD) = 0; - - //! Gets the indices for a specified patch at a specified Level of Detail. - /** \param indices: A reference to an array of u32 indices. - \param patchX: Patch x coordinate. - \param patchZ: Patch z coordinate. - \param LOD: The level of detail to get for that patch. If -1, then get - the CurrentLOD. If the CurrentLOD is set to -1, meaning it's not shown, - then it will retrieve the triangles at the highest LOD ( 0 ). - \return: Number if indices put into the buffer. */ - virtual s32 getIndicesForPatch(core::array& indices, - s32 patchX, s32 patchZ, s32 LOD = 0 ) = 0; - - //! Populates an array with the CurrentLOD of each patch. - /** \param LODs: A reference to a core::array to hold the values - \return: Returns the number of elements in the array */ - virtual s32 getCurrentLODOfPatches(core::array& LODs) = 0; - - //! Manually sets the LOD of a patch - /** \param patchX: Patch x coordinate. - \param patchZ: Patch z coordinate. - \param LOD: The level of detail to set the patch to. */ - virtual void setLODOfPatch( s32 patchX, s32 patchZ, s32 LOD ) = 0; - - //! Returns center of terrain. - virtual core::vector3df getTerrainCenter() = 0; - - //! Returns height of a point of the terrain. - virtual f32 getHeight( f32 x, f32 y ) = 0; - - //! Sets the movement camera threshold. - /** It is used to determine when to recalculate - indices for the scene node. The default value is 10.0f. */ - virtual void setCameraMovementDelta(f32 delta) = 0; - - //! Sets the rotation camera threshold. - /** It is used to determine when to recalculate - indices for the scene node. The default value is 1.0f. */ - virtual void setCameraRotationDelta(f32 delta) = 0; - - //! Sets whether or not the node should dynamically update its associated selector when the geomipmap data changes. - /** \param bVal: Boolean value representing whether or not to update selector dynamically. */ - virtual void setDynamicSelectorUpdate(bool bVal) = 0; - - //! Override the default generation of distance thresholds. - /** For determining the LOD a patch - is rendered at. If any LOD is overridden, then the scene node will no longer apply - scaling factors to these values. If you override these distances, and then apply - a scale to the scene node, it is your responsibility to update the new distances to - work best with your new terrain size. */ - virtual bool overrideLODDistance(s32 LOD, f64 newDistance) = 0; - - //! Scales the base texture, similar to makePlanarTextureMapping. - /** \param scale: The scaling amount. Values above 1.0 increase the number of time the - texture is drawn on the terrain. Values below 0 will decrease the number of times the - texture is drawn on the terrain. Using negative values will flip the texture, as - well as still scaling it. - \param scale2: If set to 0 (default value), this will set the second texture coordinate set - to the same values as in the first set. If this is another value than zero, it will scale - the second texture coordinate set by this value. */ - virtual void scaleTexture(f32 scale = 1.0f, f32 scale2 = 0.0f) = 0; - }; - -} // end namespace scene -} // end namespace irr - - -#endif // __IGEOMIPMAPSCENENODE_H__ +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// The code for the TerrainSceneNode is based on the terrain renderer by Soconne and +// the GeoMipMapSceneNode developed by Spintz. They made their code available for Irrlicht +// and allowed it to be distributed under this licence. I only modified some parts. +// A lot of thanks go to them. + +#ifndef __I_TERRAIN_SCENE_NODE_H__ +#define __I_TERRAIN_SCENE_NODE_H__ + +#include "ETerrainElements.h" +#include "ISceneNode.h" +#include "SMeshBufferLightMap.h" +#include "IMesh.h" +#include "irrArray.h" + +namespace irr +{ +namespace scene +{ + //! A scene node for displaying terrain using the geo mip map algorithm. + /** The code for the TerrainSceneNode is based on the Terrain renderer by Soconne and + * the GeoMipMapSceneNode developed by Spintz. They made their code available for Irrlicht + * and allowed it to be distributed under this licence. I only modified some parts. + * A lot of thanks go to them. + * + * This scene node is capable of very quickly loading + * terrains and updating the indices at runtime to enable viewing very large terrains. It uses a + * CLOD ( Continuous Level of Detail ) algorithm which updates the indices for each patch based on + * a LOD ( Level of Detail ) which is determined based on a patch's distance from the camera. + * + * The Patch Size of the terrain must always be a size of ( 2^N+1, i.e. 8+1(9), 16+1(17), etc. ). + * The MaxLOD available is directly dependent on the patch size of the terrain. LOD 0 contains all + * of the indices to draw all the triangles at the max detail for a patch. As each LOD goes up by 1 + * the step taken, in generating indices increases by - 2^LOD, so for LOD 1, the step taken is 2, for + * LOD 2, the step taken is 4, LOD 3 - 8, etc. The step can be no larger than the size of the patch, + * so having a LOD of 8, with a patch size of 17, is asking the algoritm to generate indices every + * 2^8 ( 256 ) vertices, which is not possible with a patch size of 17. The maximum LOD for a patch + * size of 17 is 2^4 ( 16 ). So, with a MaxLOD of 5, you'll have LOD 0 ( full detail ), LOD 1 ( every + * 2 vertices ), LOD 2 ( every 4 vertices ), LOD 3 ( every 8 vertices ) and LOD 4 ( every 16 vertices ). + **/ + class ITerrainSceneNode : public ISceneNode + { + public: + + //! constructor + ITerrainSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position = core::vector3df(0.0f, 0.0f, 0.0f), + const core::vector3df& rotation = core::vector3df(0.0f, 0.0f, 0.0f), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f) ) + : ISceneNode (parent, mgr, id, position, rotation, scale) {} + + //! destructor + virtual ~ITerrainSceneNode() {}; + + //! \return: Returns the bounding box of the entire terrain. + virtual const core::aabbox3d& getBoundingBox ( ) const = 0; + + //! Returns the bounding box of a patch + virtual const core::aabbox3d& getBoundingBox (s32 patchX, s32 patchZ) const = 0; + + //! Returns the number of indices currently in the meshbuffer for this scene node. + virtual u32 getIndexCount() = 0; + + //! Returns pointer to the mesh + virtual IMesh* getMesh() = 0; + + //! Gets the meshbuffer data based on a specified level of detail. + /** \param mb: A reference to an SMeshBuffer object + \param LOD: the level of detail you want the indices from. */ + virtual void getMeshBufferForLOD(SMeshBufferLightMap& mb, s32 LOD) = 0; + + //! Gets the indices for a specified patch at a specified Level of Detail. + /** \param indices: A reference to an array of u32 indices. + \param patchX: Patch x coordinate. + \param patchZ: Patch z coordinate. + \param LOD: The level of detail to get for that patch. If -1, then get + the CurrentLOD. If the CurrentLOD is set to -1, meaning it's not shown, + then it will retrieve the triangles at the highest LOD ( 0 ). + \return: Number if indices put into the buffer. */ + virtual s32 getIndicesForPatch(core::array& indices, + s32 patchX, s32 patchZ, s32 LOD = 0 ) = 0; + + //! Populates an array with the CurrentLOD of each patch. + /** \param LODs: A reference to a core::array to hold the values + \return: Returns the number of elements in the array */ + virtual s32 getCurrentLODOfPatches(core::array& LODs) = 0; + + //! Manually sets the LOD of a patch + /** \param patchX: Patch x coordinate. + \param patchZ: Patch z coordinate. + \param LOD: The level of detail to set the patch to. */ + virtual void setLODOfPatch( s32 patchX, s32 patchZ, s32 LOD ) = 0; + + //! Returns center of terrain. + virtual core::vector3df getTerrainCenter() = 0; + + //! Returns height of a point of the terrain. + virtual f32 getHeight( f32 x, f32 y ) = 0; + + //! Sets the movement camera threshold. + /** It is used to determine when to recalculate + indices for the scene node. The default value is 10.0f. */ + virtual void setCameraMovementDelta(f32 delta) = 0; + + //! Sets the rotation camera threshold. + /** It is used to determine when to recalculate + indices for the scene node. The default value is 1.0f. */ + virtual void setCameraRotationDelta(f32 delta) = 0; + + //! Sets whether or not the node should dynamically update its associated selector when the geomipmap data changes. + /** \param bVal: Boolean value representing whether or not to update selector dynamically. */ + virtual void setDynamicSelectorUpdate(bool bVal) = 0; + + //! Override the default generation of distance thresholds. + /** For determining the LOD a patch + is rendered at. If any LOD is overridden, then the scene node will no longer apply + scaling factors to these values. If you override these distances, and then apply + a scale to the scene node, it is your responsibility to update the new distances to + work best with your new terrain size. */ + virtual bool overrideLODDistance(s32 LOD, f64 newDistance) = 0; + + //! Scales the base texture, similar to makePlanarTextureMapping. + /** \param scale: The scaling amount. Values above 1.0 increase the number of time the + texture is drawn on the terrain. Values below 0 will decrease the number of times the + texture is drawn on the terrain. Using negative values will flip the texture, as + well as still scaling it. + \param scale2: If set to 0 (default value), this will set the second texture coordinate set + to the same values as in the first set. If this is another value than zero, it will scale + the second texture coordinate set by this value. */ + virtual void scaleTexture(f32 scale = 1.0f, f32 scale2 = 0.0f) = 0; + }; + +} // end namespace scene +} // end namespace irr + + +#endif // __IGEOMIPMAPSCENENODE_H__ diff --git a/src/dep/include/irrlicht/ITextSceneNode.h b/src/dep/include/irrlicht/ITextSceneNode.h index 30c86df..1cc4ec5 100644 --- a/src/dep/include/irrlicht/ITextSceneNode.h +++ b/src/dep/include/irrlicht/ITextSceneNode.h @@ -1,37 +1,37 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_TEXT_SCENE_NODE_H_INCLUDED__ -#define __I_TEXT_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! A scene node for displaying 2d text at a position in three dimensional space -class ITextSceneNode : public ISceneNode -{ -public: - - //! constructor - ITextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0)) - : ISceneNode(parent, mgr, id, position) {} - - //! sets the text string - virtual void setText(const wchar_t* text) = 0; - - //! sets the color of the text - virtual void setTextColor(video::SColor color) = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_TEXT_SCENE_NODE_H_INCLUDED__ +#define __I_TEXT_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + +//! A scene node for displaying 2d text at a position in three dimensional space +class ITextSceneNode : public ISceneNode +{ +public: + + //! constructor + ITextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position = core::vector3df(0,0,0)) + : ISceneNode(parent, mgr, id, position) {} + + //! sets the text string + virtual void setText(const wchar_t* text) = 0; + + //! sets the color of the text + virtual void setTextColor(video::SColor color) = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/ITexture.h b/src/dep/include/irrlicht/ITexture.h index 816d0f9..b06d2f1 100644 --- a/src/dep/include/irrlicht/ITexture.h +++ b/src/dep/include/irrlicht/ITexture.h @@ -1,173 +1,173 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_TEXTURE_H_INCLUDED__ -#define __I_TEXTURE_H_INCLUDED__ - -#include "IUnknown.h" -#include "IImage.h" -#include "dimension2d.h" -#include "EDriverTypes.h" -#include "irrString.h" -#include "matrix4.h" - -namespace irr -{ -namespace video -{ - - -//! Enumeration flags telling the video driver in which format textures -//! should be created. -enum E_TEXTURE_CREATION_FLAG -{ - //! Forces the driver to create 16 bit textures always, independent of - //! which format the file on disk has. When choosing this you may loose - //! some color detail, but gain much speed and memory. 16 bit textures - //! can be transferred twice as fast as 32 bit textures and only use - //! half of the space in memory. - //! When using this flag, it does not make sense to use the flags - //! ETCF_ALWAYS_32_BIT, ETCF_OPTIMIZED_FOR_QUALITY, - //! or ETCF_OPTIMIZED_FOR_SPEED at the same time. - ETCF_ALWAYS_16_BIT = 0x00000001, - - //! Forces the driver to create 32 bit textures always, independent of - //! which format the file on disk has. Please note that some drivers - //! (like the software device) will ignore this, because they are only - //! able to create and use 16 bit textures. - //! When using this flag, it does not make sense to use the flags - //! ETCF_ALWAYS_16_BIT, ETCF_OPTIMIZED_FOR_QUALITY, - //! or ETCF_OPTIMIZED_FOR_SPEED at the same time. - ETCF_ALWAYS_32_BIT = 0x00000002, - - //! Lets the driver decide in which format the textures are created and - //! tries to make the textures look as good as possible. - //! Usually it simply chooses the format in which the texture was stored on disk. - //! When using this flag, it does not make sense to use the flags - //! ETCF_ALWAYS_16_BIT, ETCF_ALWAYS_32_BIT, - //! or ETCF_OPTIMIZED_FOR_SPEED at the same time. - ETCF_OPTIMIZED_FOR_QUALITY = 0x00000004, - - //! Lets the driver decide in which format the textures are created and - //! tries to create them maximizing render speed. - //! When using this flag, it does not make sense to use the flags - //! ETCF_ALWAYS_16_BIT, ETCF_ALWAYS_32_BIT, or ETCF_OPTIMIZED_FOR_QUALITY, - //! at the same time. - ETCF_OPTIMIZED_FOR_SPEED = 0x00000008, - - //! Automatically creates mip map levels for the textures. - ETCF_CREATE_MIP_MAPS = 0x00000010, - - //! This flag is never used, it only forces the compiler to - //! compile these enumeration values to 32 bit. - ETCF_FORCE_32_BIT_DO_NOT_USE = 0x7fffffff -}; - - -//! Helper function, helps to get the desired texture creation format from the flags. -//! Returns either ETCF_ALWAYS_32_BIT, ETCF_ALWAYS_16_BIT, ETCF_OPTIMIZED_FOR_QUALITY, -//! or ETCF_OPTIMIZED_FOR_SPEED. -inline E_TEXTURE_CREATION_FLAG getTextureFormatFromFlags(u32 flags) -{ - if (flags & ETCF_OPTIMIZED_FOR_SPEED) - return ETCF_OPTIMIZED_FOR_SPEED; - if (flags & ETCF_ALWAYS_16_BIT) - return ETCF_ALWAYS_16_BIT; - if (flags & ETCF_ALWAYS_32_BIT) - return ETCF_ALWAYS_32_BIT; - if (flags & ETCF_OPTIMIZED_FOR_QUALITY) - return ETCF_OPTIMIZED_FOR_QUALITY; - return ETCF_OPTIMIZED_FOR_SPEED; -} - - -//! Interface of a Video Driver dependent Texture. -/** - An ITexture is created by an IVideoDriver by using IVideoDriver::addTexture or - IVideoDriver::getTexture. After that, the texture may only be used by this VideoDriver. - As you can imagine, textures of the DirectX and the OpenGL device will, e.g., not be compatible. - An exception is the Software device and the NULL device, their textures are compatible. - If you try to use a texture created by one device with an other device, the device - will refuse to do that and write a warning or an error message to the output buffer. -*/ -class ITexture : public virtual IUnknown -{ -public: - - //! constructor - ITexture(const c8* name) : Name(name) - { - Name.make_lower(); - } - - //! destructor - virtual ~ITexture() {}; - - //! Lock function. - /** Locks the Texture and returns a pointer to access the - pixels. After lock() has been called and all operations on the pixels - are done, you must call unlock(). - \return Returns a pointer to the pixel data. The format of the pixel can - be determinated by using getColorFormat(). NULL is returned, if - the texture cannot be locked. */ - virtual void* lock() = 0; - - //! Unlock function. Must be called after a lock() to the texture. - virtual void unlock() = 0; - - //! Returns original size of the texture. - /** The texture is usually - scaled, if it was created with an unoptimal size. For example if the size - of the texture file it was loaded from was not a power of two. This returns - the size of the texture, it had before it was scaled. Can be useful - when drawing 2d images on the screen, which should have the exact size - of the original texture. Use ITexture::getSize() if you want to know - the real size it has now stored in the system. - \return Returns the original size of the texture. */ - virtual const core::dimension2d& getOriginalSize() = 0; - - //! Returns dimension (=size) of the texture. - /** \return Returns the size of the texture. */ - virtual const core::dimension2d& getSize() = 0; - - //! Returns driver type of texture. - /** This is the driver, which created the texture. - This method is used internally by the video devices, to check, if they may - use a texture because textures may be incompatible between different - devices. - \return Returns driver type of texture. */ - virtual E_DRIVER_TYPE getDriverType() = 0; - - //! Returns the color format of texture. - /** \return Returns the color format of texture. */ - virtual ECOLOR_FORMAT getColorFormat() const = 0; - - //! Returns pitch of texture (in bytes). - /** The pitch is the amount of bytes - used for a row of pixels in a texture. - \return Returns pitch of texture in bytes. */ - virtual u32 getPitch() const = 0; - - //! Returns whether the texture has MipMaps - /** \return Returns true if texture has MipMaps, else false. */ - virtual bool hasMipMaps() { return false; } - - //! Regenerates the mip map levels of the texture. - /** Useful after locking and modifying the texture */ - virtual void regenerateMipMapLevels() = 0; - - //! Returns name of texture (in most cases this is the filename) - const core::stringc& getName() { return Name; } - -protected: - - core::stringc Name; -}; - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_TEXTURE_H_INCLUDED__ +#define __I_TEXTURE_H_INCLUDED__ + +#include "IUnknown.h" +#include "IImage.h" +#include "dimension2d.h" +#include "EDriverTypes.h" +#include "irrString.h" +#include "matrix4.h" + +namespace irr +{ +namespace video +{ + + +//! Enumeration flags telling the video driver in which format textures +//! should be created. +enum E_TEXTURE_CREATION_FLAG +{ + //! Forces the driver to create 16 bit textures always, independent of + //! which format the file on disk has. When choosing this you may loose + //! some color detail, but gain much speed and memory. 16 bit textures + //! can be transferred twice as fast as 32 bit textures and only use + //! half of the space in memory. + //! When using this flag, it does not make sense to use the flags + //! ETCF_ALWAYS_32_BIT, ETCF_OPTIMIZED_FOR_QUALITY, + //! or ETCF_OPTIMIZED_FOR_SPEED at the same time. + ETCF_ALWAYS_16_BIT = 0x00000001, + + //! Forces the driver to create 32 bit textures always, independent of + //! which format the file on disk has. Please note that some drivers + //! (like the software device) will ignore this, because they are only + //! able to create and use 16 bit textures. + //! When using this flag, it does not make sense to use the flags + //! ETCF_ALWAYS_16_BIT, ETCF_OPTIMIZED_FOR_QUALITY, + //! or ETCF_OPTIMIZED_FOR_SPEED at the same time. + ETCF_ALWAYS_32_BIT = 0x00000002, + + //! Lets the driver decide in which format the textures are created and + //! tries to make the textures look as good as possible. + //! Usually it simply chooses the format in which the texture was stored on disk. + //! When using this flag, it does not make sense to use the flags + //! ETCF_ALWAYS_16_BIT, ETCF_ALWAYS_32_BIT, + //! or ETCF_OPTIMIZED_FOR_SPEED at the same time. + ETCF_OPTIMIZED_FOR_QUALITY = 0x00000004, + + //! Lets the driver decide in which format the textures are created and + //! tries to create them maximizing render speed. + //! When using this flag, it does not make sense to use the flags + //! ETCF_ALWAYS_16_BIT, ETCF_ALWAYS_32_BIT, or ETCF_OPTIMIZED_FOR_QUALITY, + //! at the same time. + ETCF_OPTIMIZED_FOR_SPEED = 0x00000008, + + //! Automatically creates mip map levels for the textures. + ETCF_CREATE_MIP_MAPS = 0x00000010, + + //! This flag is never used, it only forces the compiler to + //! compile these enumeration values to 32 bit. + ETCF_FORCE_32_BIT_DO_NOT_USE = 0x7fffffff +}; + + +//! Helper function, helps to get the desired texture creation format from the flags. +//! Returns either ETCF_ALWAYS_32_BIT, ETCF_ALWAYS_16_BIT, ETCF_OPTIMIZED_FOR_QUALITY, +//! or ETCF_OPTIMIZED_FOR_SPEED. +inline E_TEXTURE_CREATION_FLAG getTextureFormatFromFlags(u32 flags) +{ + if (flags & ETCF_OPTIMIZED_FOR_SPEED) + return ETCF_OPTIMIZED_FOR_SPEED; + if (flags & ETCF_ALWAYS_16_BIT) + return ETCF_ALWAYS_16_BIT; + if (flags & ETCF_ALWAYS_32_BIT) + return ETCF_ALWAYS_32_BIT; + if (flags & ETCF_OPTIMIZED_FOR_QUALITY) + return ETCF_OPTIMIZED_FOR_QUALITY; + return ETCF_OPTIMIZED_FOR_SPEED; +} + + +//! Interface of a Video Driver dependent Texture. +/** + An ITexture is created by an IVideoDriver by using IVideoDriver::addTexture or + IVideoDriver::getTexture. After that, the texture may only be used by this VideoDriver. + As you can imagine, textures of the DirectX and the OpenGL device will, e.g., not be compatible. + An exception is the Software device and the NULL device, their textures are compatible. + If you try to use a texture created by one device with an other device, the device + will refuse to do that and write a warning or an error message to the output buffer. +*/ +class ITexture : public virtual IUnknown +{ +public: + + //! constructor + ITexture(const c8* name) : Name(name) + { + Name.make_lower(); + } + + //! destructor + virtual ~ITexture() {}; + + //! Lock function. + /** Locks the Texture and returns a pointer to access the + pixels. After lock() has been called and all operations on the pixels + are done, you must call unlock(). + \return Returns a pointer to the pixel data. The format of the pixel can + be determinated by using getColorFormat(). NULL is returned, if + the texture cannot be locked. */ + virtual void* lock() = 0; + + //! Unlock function. Must be called after a lock() to the texture. + virtual void unlock() = 0; + + //! Returns original size of the texture. + /** The texture is usually + scaled, if it was created with an unoptimal size. For example if the size + of the texture file it was loaded from was not a power of two. This returns + the size of the texture, it had before it was scaled. Can be useful + when drawing 2d images on the screen, which should have the exact size + of the original texture. Use ITexture::getSize() if you want to know + the real size it has now stored in the system. + \return Returns the original size of the texture. */ + virtual const core::dimension2d& getOriginalSize() = 0; + + //! Returns dimension (=size) of the texture. + /** \return Returns the size of the texture. */ + virtual const core::dimension2d& getSize() = 0; + + //! Returns driver type of texture. + /** This is the driver, which created the texture. + This method is used internally by the video devices, to check, if they may + use a texture because textures may be incompatible between different + devices. + \return Returns driver type of texture. */ + virtual E_DRIVER_TYPE getDriverType() = 0; + + //! Returns the color format of texture. + /** \return Returns the color format of texture. */ + virtual ECOLOR_FORMAT getColorFormat() const = 0; + + //! Returns pitch of texture (in bytes). + /** The pitch is the amount of bytes + used for a row of pixels in a texture. + \return Returns pitch of texture in bytes. */ + virtual u32 getPitch() const = 0; + + //! Returns whether the texture has MipMaps + /** \return Returns true if texture has MipMaps, else false. */ + virtual bool hasMipMaps() { return false; } + + //! Regenerates the mip map levels of the texture. + /** Useful after locking and modifying the texture */ + virtual void regenerateMipMapLevels() = 0; + + //! Returns name of texture (in most cases this is the filename) + const core::stringc& getName() { return Name; } + +protected: + + core::stringc Name; +}; + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/ITimer.h b/src/dep/include/irrlicht/ITimer.h index 98cc269..eae3481 100644 --- a/src/dep/include/irrlicht/ITimer.h +++ b/src/dep/include/irrlicht/ITimer.h @@ -1,71 +1,71 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_TIMER_H_INCLUDED__ -#define __I_TIMER_H_INCLUDED__ - -#include "IUnknown.h" - -namespace irr -{ - -//! Interface for getting and manipulating the virtual time -class ITimer : public virtual IUnknown -{ -public: - - //! destructor - virtual ~ITimer() {} - - //! Returns current real time in milliseconds of the system. - /** This value does not start with 0 when the application starts. - For example in one implementation the value returned could be the - amount of milliseconds which have elapsed since the system was started. */ - virtual u32 getRealTime() = 0; - - //! Returns current virtual time in milliseconds. - /** This value starts with 0 and can be manipulated using setTime(), stopTimer(), - startTimer(), etc. This value depends on the set speed of the timer if the timer - is stopped, etc. If you need the system time, use getRealTime() */ - virtual u32 getTime() = 0; - - //! sets current virtual time - virtual void setTime(u32 time) = 0; - - //! Stops the virtual timer. - /** The timer is reference counted, which means everything which calls - stop() will also have to call start(), otherwise the timer may not start/stop - corretly again. */ - virtual void stop() = 0; - - //! Starts the virtual timer. - /** The timer is reference counted, which means everything which calls - stop() will also have to call start(), otherwise the timer may not start/stop - corretly again. */ - virtual void start() = 0; - - //! Sets the speed of the timer - /** The speed is the factor with which the time is running faster or slower then the - real system time. */ - virtual void setSpeed(f32 speed = 1.0f) = 0; - - //! Returns current speed of the timer - /** The speed is the factor with which the time is running faster or slower then the - real system time. */ - virtual f32 getSpeed() = 0; - - //! Returns if the virtual timer is currently stopped - virtual bool isStopped() = 0; - - //! Advances the virtual time - /** Makes the virtual timer update the time value based on the real - time. This is called automatically when calling IrrlichtDevice::run(), - but you can call it manually if you don't use this method. */ - virtual void tick() = 0; -}; - -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_TIMER_H_INCLUDED__ +#define __I_TIMER_H_INCLUDED__ + +#include "IUnknown.h" + +namespace irr +{ + +//! Interface for getting and manipulating the virtual time +class ITimer : public virtual IUnknown +{ +public: + + //! destructor + virtual ~ITimer() {} + + //! Returns current real time in milliseconds of the system. + /** This value does not start with 0 when the application starts. + For example in one implementation the value returned could be the + amount of milliseconds which have elapsed since the system was started. */ + virtual u32 getRealTime() = 0; + + //! Returns current virtual time in milliseconds. + /** This value starts with 0 and can be manipulated using setTime(), stopTimer(), + startTimer(), etc. This value depends on the set speed of the timer if the timer + is stopped, etc. If you need the system time, use getRealTime() */ + virtual u32 getTime() = 0; + + //! sets current virtual time + virtual void setTime(u32 time) = 0; + + //! Stops the virtual timer. + /** The timer is reference counted, which means everything which calls + stop() will also have to call start(), otherwise the timer may not start/stop + corretly again. */ + virtual void stop() = 0; + + //! Starts the virtual timer. + /** The timer is reference counted, which means everything which calls + stop() will also have to call start(), otherwise the timer may not start/stop + corretly again. */ + virtual void start() = 0; + + //! Sets the speed of the timer + /** The speed is the factor with which the time is running faster or slower then the + real system time. */ + virtual void setSpeed(f32 speed = 1.0f) = 0; + + //! Returns current speed of the timer + /** The speed is the factor with which the time is running faster or slower then the + real system time. */ + virtual f32 getSpeed() = 0; + + //! Returns if the virtual timer is currently stopped + virtual bool isStopped() = 0; + + //! Advances the virtual time + /** Makes the virtual timer update the time value based on the real + time. This is called automatically when calling IrrlichtDevice::run(), + but you can call it manually if you don't use this method. */ + virtual void tick() = 0; +}; + +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/ITriangleSelector.h b/src/dep/include/irrlicht/ITriangleSelector.h index 63730f7..92daed9 100644 --- a/src/dep/include/irrlicht/ITriangleSelector.h +++ b/src/dep/include/irrlicht/ITriangleSelector.h @@ -1,85 +1,85 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_TRIANGLE_SELECTOR_H_INCLUDED__ -#define __I_TRIANGLE_SELECTOR_H_INCLUDED__ - -#include "IUnknown.h" -#include "triangle3d.h" -#include "aabbox3d.h" -#include "matrix4.h" -#include "line3d.h" - -namespace irr -{ -namespace scene -{ - -//! Interface to return triangles with specific properties. -/** Every ISceneNode may have a triangle selector, available with - ISceneNode::getTriangleScelector() or ISceneManager::createTriangleSelector. - This is used for doing collision detection: For example if you know, that a collision may happened in the - area between (1,1,1) and (10,10,10), you can get all triangles of the - scene node in this area with the ITriangleSelector easily and check every triangle - if it collided. */ -class ITriangleSelector : public virtual IUnknown -{ -public: - - //! destructor - virtual ~ITriangleSelector() {}; - - //! Returns amount of all available triangles in this selector - virtual s32 getTriangleCount() const = 0; - - //! Gets all triangles. - //! \param triangles: Array where the resulting triangles will be written to. - //! \param arraySize: Size of the target array. - //! \param outTriangleCount: Amount of triangles which have been written into the - //! array. - //! \param transform: Pointer to matrix for transforming the triangles before. - //! they are returned. Useful for example to scale all triangles down into an - //! ellipsoid space. If this pointer is null, no transformation will be done. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::matrix4* transform=0) = 0; - - //! Gets all triangles which lie within a specific bounding box. - //! Please note that unoptimized triangle selectors also may return triangles, - //! which are not in the specific box at all. - //! \param triangles: Array where the resulting triangles will be written to. - //! \param arraySize: Size of the target array. - //! \param outTriangleCount: Amount of triangles which have been written into the - //! array. - //! \param box: Only triangles which are in this axis aligned bounding box - //! will be written into the array. - //! \param transform: Pointer to matrix for transforming the triangles before. - //! they are returned. Useful for example to scale all triangles down into an - //! ellipsoid space. If this pointer is null, no transformation will be done. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::aabbox3d& box, - const core::matrix4* transform=0) = 0; - - //! Gets all triangles which have or may have contact with a 3d line. - //! Please note that unoptimized triangle selectors also may return triangles, - //! which are not in contact at all with the 3d line. - //! \param triangles: Array where the resulting triangles will be written to. - //! \param arraySize: Size of the target array. - //! \param outTriangleCount: Amount of triangles which have been written into the - //! array. - //! \param line: Only triangles which may be in contact with this 3d line will - //! be written into the array. - //! \param transform: Pointer to matrix for transforming the triangles before. - //! they are returned. Useful for example to scale all triangles down into an - //! ellipsoid space. If this pointer is null, no transformation will be done. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d& line, - const core::matrix4* transform=0) = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_TRIANGLE_SELECTOR_H_INCLUDED__ +#define __I_TRIANGLE_SELECTOR_H_INCLUDED__ + +#include "IUnknown.h" +#include "triangle3d.h" +#include "aabbox3d.h" +#include "matrix4.h" +#include "line3d.h" + +namespace irr +{ +namespace scene +{ + +//! Interface to return triangles with specific properties. +/** Every ISceneNode may have a triangle selector, available with + ISceneNode::getTriangleScelector() or ISceneManager::createTriangleSelector. + This is used for doing collision detection: For example if you know, that a collision may happened in the + area between (1,1,1) and (10,10,10), you can get all triangles of the + scene node in this area with the ITriangleSelector easily and check every triangle + if it collided. */ +class ITriangleSelector : public virtual IUnknown +{ +public: + + //! destructor + virtual ~ITriangleSelector() {}; + + //! Returns amount of all available triangles in this selector + virtual s32 getTriangleCount() const = 0; + + //! Gets all triangles. + //! \param triangles: Array where the resulting triangles will be written to. + //! \param arraySize: Size of the target array. + //! \param outTriangleCount: Amount of triangles which have been written into the + //! array. + //! \param transform: Pointer to matrix for transforming the triangles before. + //! they are returned. Useful for example to scale all triangles down into an + //! ellipsoid space. If this pointer is null, no transformation will be done. + virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::matrix4* transform=0) = 0; + + //! Gets all triangles which lie within a specific bounding box. + //! Please note that unoptimized triangle selectors also may return triangles, + //! which are not in the specific box at all. + //! \param triangles: Array where the resulting triangles will be written to. + //! \param arraySize: Size of the target array. + //! \param outTriangleCount: Amount of triangles which have been written into the + //! array. + //! \param box: Only triangles which are in this axis aligned bounding box + //! will be written into the array. + //! \param transform: Pointer to matrix for transforming the triangles before. + //! they are returned. Useful for example to scale all triangles down into an + //! ellipsoid space. If this pointer is null, no transformation will be done. + virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::aabbox3d& box, + const core::matrix4* transform=0) = 0; + + //! Gets all triangles which have or may have contact with a 3d line. + //! Please note that unoptimized triangle selectors also may return triangles, + //! which are not in contact at all with the 3d line. + //! \param triangles: Array where the resulting triangles will be written to. + //! \param arraySize: Size of the target array. + //! \param outTriangleCount: Amount of triangles which have been written into the + //! array. + //! \param line: Only triangles which may be in contact with this 3d line will + //! be written into the array. + //! \param transform: Pointer to matrix for transforming the triangles before. + //! they are returned. Useful for example to scale all triangles down into an + //! ellipsoid space. If this pointer is null, no transformation will be done. + virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::line3d& line, + const core::matrix4* transform=0) = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/IUnknown.h b/src/dep/include/irrlicht/IUnknown.h index 24f4d2d..01a6418 100644 --- a/src/dep/include/irrlicht/IUnknown.h +++ b/src/dep/include/irrlicht/IUnknown.h @@ -1,153 +1,153 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_UNKNOWN_H_INCLUDED__ -#define __I_UNKNOWN_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr -{ - - //! Base class of most objects of the Irrlicht Engine. - /** This class provides reference counting through the methods grab() and drop(). - It also is able to store a debug string for every instance of an object. - Most objects of the Irrlicht - Engine are derived from IUnknown, and so they are reference counted. - - When you create an object in the Irrlicht engine, calling a method - which starts with 'create', an object is created, and you get a pointer - to the new object. If you no longer need the object, you have - to call drop(). This will destroy the object, if grab() was not called - in another part of you program, because this part still needs the object. - Note, that you only need to call drop() to the object, if you created it, - and the method had a 'create' in it. - - A simple example: - - If you want to create a texture, you may want to call an imaginable method - IDriver::createTexture. You call - ITexture* texture = driver->createTexture(dimension2d(128, 128)); - If you no longer need the texture, call texture->drop(). - - If you want to load a texture, you may want to call imaginable method - IDriver::loadTexture. You do this like - ITexture* texture = driver->loadTexture("example.jpg"); - You will not have to drop the pointer to the loaded texture, because - the name of the method does not start with 'create'. The texture - is stored somewhere by the driver. - */ - class IUnknown - { - public: - - //! Constructor. - IUnknown() - : ReferenceCounter(1), DebugName(0) - { - } - - //! Destructor. - virtual ~IUnknown() - { - } - - //! Grabs the object. Increments the reference counter by one. - //! Someone who calls grab() to an object, should later also call - //! drop() to it. If an object never gets as much drop() as grab() - //! calls, it will never be destroyed. - //! The IUnknown class provides a basic reference counting mechanism - //! with its methods grab() and drop(). Most objects of the Irrlicht - //! Engine are derived from IUnknown, and so they are reference counted. - //! - //! When you create an object in the Irrlicht engine, calling a method - //! which starts with 'create', an object is created, and you get a pointer - //! to the new object. If you no longer need the object, you have - //! to call drop(). This will destroy the object, if grab() was not called - //! in another part of you program, because this part still needs the object. - //! Note, that you only need to call drop() to the object, if you created it, - //! and the method had a 'create' in it. - //! - //! A simple example: - //! - //! If you want to create a texture, you may want to call an imaginable method - //! IDriver::createTexture. You call - //! ITexture* texture = driver->createTexture(dimension2d(128, 128)); - //! If you no longer need the texture, call texture->drop(). - //! If you want to load a texture, you may want to call imaginable method - //! IDriver::loadTexture. You do this like - //! ITexture* texture = driver->loadTexture("example.jpg"); - //! You will not have to drop the pointer to the loaded texture, because - //! the name of the method does not start with 'create'. The texture - //! is stored somewhere by the driver. - void grab() { ++ReferenceCounter; } - - //! Drops the object. Decrements the reference counter by one. - //! Returns true, if the object was deleted. - //! The IUnknown class provides a basic reference counting mechanism - //! with its methods grab() and drop(). Most objects of the Irrlicht - //! Engine are derived from IUnknown, and so they are reference counted. - //! - //! When you create an object in the Irrlicht engine, calling a method - //! which starts with 'create', an object is created, and you get a pointer - //! to the new object. If you no longer need the object, you have - //! to call drop(). This will destroy the object, if grab() was not called - //! in another part of you program, because this part still needs the object. - //! Note, that you only need to call drop() to the object, if you created it, - //! and the method had a 'create' in it. - //! - //! A simple example: - //! - //! If you want to create a texture, you may want to call an imaginable method - //! IDriver::createTexture. You call - //! ITexture* texture = driver->createTexture(dimension2d(128, 128)); - //! If you no longer need the texture, call texture->drop(). - //! If you want to load a texture, you may want to call imaginable method - //! IDriver::loadTexture. You do this like - //! ITexture* texture = driver->loadTexture("example.jpg"); - //! You will not have to drop the pointer to the loaded texture, because - //! the name of the method does not start with 'create'. The texture - //! is stored somewhere by the driver. - bool drop() - { - _IRR_DEBUG_BREAK_IF(ReferenceCounter <= 0) // someone is doing bad reference counting. - - --ReferenceCounter; - if (!ReferenceCounter) - { - delete this; - return true; - } - - return false; - } - - //! Returns the debug name of the object. The Debugname may only be set and - //! changed by the object itself. This method should only be used in Debug mode. - //! \return Returns a string, previously set by setDebugName(); - const c8* getDebugName() const - { - return DebugName; - } - - protected: - - //! Sets the debug name of the object. The Debugname may only be set and - //! changed by the object itself. This method should only be used in Debug mode. - //! \param newName: New debug name to set. - void setDebugName(const c8* newName) - { - DebugName = newName; - } - - private: - - s32 ReferenceCounter; - const c8* DebugName; - }; - -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_UNKNOWN_H_INCLUDED__ +#define __I_UNKNOWN_H_INCLUDED__ + +#include "irrTypes.h" + +namespace irr +{ + + //! Base class of most objects of the Irrlicht Engine. + /** This class provides reference counting through the methods grab() and drop(). + It also is able to store a debug string for every instance of an object. + Most objects of the Irrlicht + Engine are derived from IUnknown, and so they are reference counted. + + When you create an object in the Irrlicht engine, calling a method + which starts with 'create', an object is created, and you get a pointer + to the new object. If you no longer need the object, you have + to call drop(). This will destroy the object, if grab() was not called + in another part of you program, because this part still needs the object. + Note, that you only need to call drop() to the object, if you created it, + and the method had a 'create' in it. + + A simple example: + + If you want to create a texture, you may want to call an imaginable method + IDriver::createTexture. You call + ITexture* texture = driver->createTexture(dimension2d(128, 128)); + If you no longer need the texture, call texture->drop(). + + If you want to load a texture, you may want to call imaginable method + IDriver::loadTexture. You do this like + ITexture* texture = driver->loadTexture("example.jpg"); + You will not have to drop the pointer to the loaded texture, because + the name of the method does not start with 'create'. The texture + is stored somewhere by the driver. + */ + class IUnknown + { + public: + + //! Constructor. + IUnknown() + : ReferenceCounter(1), DebugName(0) + { + } + + //! Destructor. + virtual ~IUnknown() + { + } + + //! Grabs the object. Increments the reference counter by one. + //! Someone who calls grab() to an object, should later also call + //! drop() to it. If an object never gets as much drop() as grab() + //! calls, it will never be destroyed. + //! The IUnknown class provides a basic reference counting mechanism + //! with its methods grab() and drop(). Most objects of the Irrlicht + //! Engine are derived from IUnknown, and so they are reference counted. + //! + //! When you create an object in the Irrlicht engine, calling a method + //! which starts with 'create', an object is created, and you get a pointer + //! to the new object. If you no longer need the object, you have + //! to call drop(). This will destroy the object, if grab() was not called + //! in another part of you program, because this part still needs the object. + //! Note, that you only need to call drop() to the object, if you created it, + //! and the method had a 'create' in it. + //! + //! A simple example: + //! + //! If you want to create a texture, you may want to call an imaginable method + //! IDriver::createTexture. You call + //! ITexture* texture = driver->createTexture(dimension2d(128, 128)); + //! If you no longer need the texture, call texture->drop(). + //! If you want to load a texture, you may want to call imaginable method + //! IDriver::loadTexture. You do this like + //! ITexture* texture = driver->loadTexture("example.jpg"); + //! You will not have to drop the pointer to the loaded texture, because + //! the name of the method does not start with 'create'. The texture + //! is stored somewhere by the driver. + void grab() { ++ReferenceCounter; } + + //! Drops the object. Decrements the reference counter by one. + //! Returns true, if the object was deleted. + //! The IUnknown class provides a basic reference counting mechanism + //! with its methods grab() and drop(). Most objects of the Irrlicht + //! Engine are derived from IUnknown, and so they are reference counted. + //! + //! When you create an object in the Irrlicht engine, calling a method + //! which starts with 'create', an object is created, and you get a pointer + //! to the new object. If you no longer need the object, you have + //! to call drop(). This will destroy the object, if grab() was not called + //! in another part of you program, because this part still needs the object. + //! Note, that you only need to call drop() to the object, if you created it, + //! and the method had a 'create' in it. + //! + //! A simple example: + //! + //! If you want to create a texture, you may want to call an imaginable method + //! IDriver::createTexture. You call + //! ITexture* texture = driver->createTexture(dimension2d(128, 128)); + //! If you no longer need the texture, call texture->drop(). + //! If you want to load a texture, you may want to call imaginable method + //! IDriver::loadTexture. You do this like + //! ITexture* texture = driver->loadTexture("example.jpg"); + //! You will not have to drop the pointer to the loaded texture, because + //! the name of the method does not start with 'create'. The texture + //! is stored somewhere by the driver. + bool drop() + { + _IRR_DEBUG_BREAK_IF(ReferenceCounter <= 0) // someone is doing bad reference counting. + + --ReferenceCounter; + if (!ReferenceCounter) + { + delete this; + return true; + } + + return false; + } + + //! Returns the debug name of the object. The Debugname may only be set and + //! changed by the object itself. This method should only be used in Debug mode. + //! \return Returns a string, previously set by setDebugName(); + const c8* getDebugName() const + { + return DebugName; + } + + protected: + + //! Sets the debug name of the object. The Debugname may only be set and + //! changed by the object itself. This method should only be used in Debug mode. + //! \param newName: New debug name to set. + void setDebugName(const c8* newName) + { + DebugName = newName; + } + + private: + + s32 ReferenceCounter; + const c8* DebugName; + }; + +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IVideoDriver.h b/src/dep/include/irrlicht/IVideoDriver.h index bb8cb63..ca5abdf 100644 --- a/src/dep/include/irrlicht/IVideoDriver.h +++ b/src/dep/include/irrlicht/IVideoDriver.h @@ -1,863 +1,863 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_I_VIDEO_DRIVER_H_INCLUDED__ -#define __IRR_I_VIDEO_DRIVER_H_INCLUDED__ - -#include "rect.h" -#include "SColor.h" -#include "ITexture.h" -#include "irrArray.h" -#include "matrix4.h" -#include "dimension2d.h" -#include "position2d.h" -#include "IReadFile.h" -#include "SMaterial.h" -#include "IImageLoader.h" -#include "IImageWriter.h" -#include "IMeshBuffer.h" -#include "triangle3d.h" -#include "SExposedVideoData.h" -#include "IMaterialRenderer.h" -#include "EDriverTypes.h" -#include "IGPUProgrammingServices.h" - -namespace irr -{ -namespace io -{ - class IAttributes; -} // end namespace io -namespace scene -{ - class IMeshBuffer; -} // end namespace scene - -namespace video -{ - struct S3DVertex; - struct S3DVertex2TCoords; - struct S3DVertexTangents; - struct SLight; - - //! enumeration for querying features of the video driver. - enum E_VIDEO_DRIVER_FEATURE - { - //! Is driver able to render to a surface? - EVDF_RENDER_TO_TARGET = 0, - - //! Is hardeware transform and lighting supported? - EVDF_HARDWARE_TL, - - //! Are multiple textures per material possible? - EVDF_MULTITEXTURE, - - //! Is driver able to render with a bilinear filter applied? - EVDF_BILINEAR_FILTER, - - //! Can the driver handle mip maps? - EVDF_MIP_MAP, - - //! Can the driver update mip maps automatically? - EVDF_MIP_MAP_AUTO_UPDATE, - - //! Are stencilbuffers switched on and does the device support stencil buffers? - EVDF_STENCIL_BUFFER, - - //! Is Vertex Shader 1.1 supported? - EVDF_VERTEX_SHADER_1_1, - - //! Is Vertex Shader 2.0 supported? - EVDF_VERTEX_SHADER_2_0, - - //! Is Vertex Shader 3.0 supported? - EVDF_VERTEX_SHADER_3_0, - - //! Is Pixel Shader 1.1 supported? - EVDF_PIXEL_SHADER_1_1, - - //! Is Pixel Shader 1.2 supported? - EVDF_PIXEL_SHADER_1_2, - - //! Is Pixel Shader 1.3 supported? - EVDF_PIXEL_SHADER_1_3, - - //! Is Pixel Shader 1.4 supported? - EVDF_PIXEL_SHADER_1_4, - - //! Is Pixel Shader 2.0 supported? - EVDF_PIXEL_SHADER_2_0, - - //! Is Pixel Shader 3.0 supported? - EVDF_PIXEL_SHADER_3_0, - - //! Are ARB vertex programs v1.0 supported? - EVDF_ARB_VERTEX_PROGRAM_1, - - //! Are ARB fragment programs v1.0 supported? - EVDF_ARB_FRAGMENT_PROGRAM_1, - - //! Is GLSL supported? - EVDF_ARB_GLSL, - - //! Is HLSL supported? - EVDF_HLSL, - - //! Are non-power-of-two textures supported? - EVDF_TEXTURE_NPOT, - - //! Are framebuffer objects supported? - EVDF_FRAMEBUFFER_OBJECT - }; - - //! enumeration for geometry transformation states - enum E_TRANSFORMATION_STATE - { - //! View transformation - ETS_VIEW = 0, - //! World transformation - ETS_WORLD, - //! Projection transformation - ETS_PROJECTION, - //! Texture transformation - ETS_TEXTURE_0, - //! Texture transformation - ETS_TEXTURE_1, - //! Texture transformation - ETS_TEXTURE_2, - //! Texture transformation - ETS_TEXTURE_3, - //! Not used - ETS_COUNT - }; - - - //! Interface to driver which is able to perform 2d and 3d gfx functions. - /** The IVideoDriver interface is one of the most important interfaces of - the Irrlicht Engine: All rendering and texture manipulating is done with - this interface. You are able to use the Irrlicht Engine by only invoking methods - of this interface if you would like to, although the irr::scene::ISceneManager interface - provides a lot of powerful classes and methods to make the programmers life - easier. - */ - class IVideoDriver : public virtual IUnknown - { - public: - - //! destructor - virtual ~IVideoDriver() {} - - //! Applications must call this method before performing any rendering. - /** \param backBuffer: Specifies if the back buffer should be cleared, which - means that the screen is filled with a color specified with the parameter color. - If this parameter is false, the back buffer will not be cleared and the color - parameter is ignored. - \param zBuffer: Specifies if the depth or z buffer should be cleared. It is - not nesesarry to do so, if only 2d drawing is used. - \return Returns false if failed. Begin Scene can clear the back- and the z-buffer. */ - virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color) = 0; - - //! Presents the rendered image on the screen. - /** Applications must call this method after performing any rendering. - \param windowId: Handle of another window, if you want the bitmap to be displayed - on another window. If this is null, everything will be displayed in the default window. - Note: This does not work in fullscreen mode and is not implemented for all devices (only for - D3D8, D3D9, Software1 and Software2, and only for Windows). - \param sourceRect: Pointer to a rectangle defining the source rectangle of the area - to be presented. Set to null to present everything. Note: not implemented in all devices. - \return Returns false if failed and true if succeeded. */ - virtual bool endScene( s32 windowId = 0, core::rect* sourceRect=0 ) = 0; - - //! Queries the features of the driver. - /** Returns true if a feature is available - \param feature: A feature to query. - \return Returns true if the feature is available, false if not. */ - virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) = 0; - - //! Sets the view, world or projection transformation. - /* \param state: Transformation type to be set. Can be view, world or projection. - \param mat: Matrix describing the transformation. */ - virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) = 0; - - //! Returns the transformation set by setTransform - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) = 0; - - //! Sets a material. - /** All 3d drawing functions draw geometry now - using this material. - \param material: Material to be used from now on. */ - virtual void setMaterial(const SMaterial& material) = 0; - - //! Returns a pointer to a texture. - /** Loads the texture if it is not - already loaded, and generates mipmap levels if wished. - You can influence how the texture is loaded using the setTextureCreationFlag() - method. - The texture can be in BMP, JPG, TGA, PCX, PNG and PSD format. - For loading BMP, TGA, PCX, and PSD files, the engine uses its own methods. - PCX loading is based on some code by Dean P. Macri, who sent - it in for free use by the engine, PGN loading is done using a loader - by rt who allowed it to be used by Irrlicht. - For loading JPG-Files the JPEG LIB 6b, written by - The Independent JPEG Group is used by the engine. For PNG loading, - libPNG is used. Thanx for such great libraries! - \param filename: Filename of the texture to be loaded. - \return Returns a pointer to the texture and NULL if the texture - could not be loaded. - This pointer should not be dropped. See IUnknown::drop() for more information.*/ - virtual ITexture* getTexture(const c8* filename) = 0; - - //! Returns a pointer to a texture. - /** Loads the texture if it is not - already loaded, and generates mipmap levels if wished. - You can influence how the texture is loaded using the setTextureCreationFlag() - method. - The texture can be in BMP, JPG, TGA, PCX, PNG and PSD format. - For loading BMP, TGA, PCX, and PSD files, the engine uses its own methods. - PCX loading is based on some code by Dean P. Macri, who sent - it in for free use by the engine, PGN loading is done using a loader - by rt who allowed it to be used by Irrlicht. - For loading JPG-Files the JPEG LIB 6b, written by - The Independent JPEG Group is used by the engine. For PNG loading, - libPNG is used. Thanx for such great libraries! - \param file: Pointer to an already opened file. - \return Returns a pointer to the texture and NULL if the texture - could not be loaded. - This pointer should not be dropped. See IUnknown::drop() for more information.*/ - virtual ITexture* getTexture(io::IReadFile* file) = 0; - - //! Returns a texture by index - /** \param index: Index of the texture, must be smaller than getTextureCount() - Please note that this index would change when adding or removing textures - */ - virtual ITexture* getTextureByIndex(u32 index) = 0; - - //! Returns amount of textures currently loaded - virtual s32 getTextureCount() = 0; - - //! Creates an empty Texture of specified size. - /** \param size: Size of the texture. - \param name: A name for the texture. Later calls of getTexture() with this name - will return this texture - \param format: Desired color format of the texture. Please note that - the driver may choose to create the texture in another color format. - \return Returns a pointer to the new created Texture. - This pointer should not be dropped. See IUnknown::drop() for more information. - The format of the new texture will be chosen by the driver. */ - virtual ITexture* addTexture(const core::dimension2d& size, - const c8* name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0; - - //! Creates a texture from a loaded IImage. - /** \param name: A name for the texture. Later calls of getTexture() with this name - will return this texture - \param image: Image from which the texture is created from. - \return Returns a pointer to the new created Texture. - This pointer should not be dropped. See IUnknown::drop() for more information. - The format of the new texture will be chosen by the driver. */ - virtual ITexture* addTexture(const c8* name, IImage* image) = 0; - - //! Creates a render target texture. - /** \param size: Size of the texture, in pixels. Width and height should - be a power of two (for example 64, 128, 256, 512, ...) and it should not - be bigger than the backbuffer, because it shares the zbuffer with the - screen buffer. - \return Returns a pointer to the created texture or 0 if the texture could not - be created. If you no longer need the image, you should call ITexture::drop(). - See IUnknown::drop() for more information. */ - virtual ITexture* createRenderTargetTexture(const core::dimension2d& size) = 0; - - //! Removes a texture from the texture cache and deletes it, freeing lot of memory. - /** Please note that after calling this, the pointer to the ITexture - may not be longer valid, if it was not grabbed before by other parts of - the engine for storing it longer. So it would be a good idea to set all - materials which are using this texture to null or another texture first. - \param texture: Texture to delete from the engines cache. */ - virtual void removeTexture(ITexture* texture) = 0; - - //! Removes all texture from the texture cache and deletes them, freeing lot of memory. - /** Please note that after calling this, the pointer to all ITextures - may not be longer valid, if they were not grabbed before by other parts of - the engine for storing them longer. So it would be a good idea to set all - materials which are using textures to null first. */ - virtual void removeAllTextures() = 0; - - //! Creates an 1bit alpha channel of the texture based of an color key. - /** This makes the texture transparent at the regions where this color - key can be found when using for example draw2DImage with useAlphachannel - = true. - \param texture: Texture of which its alpha channel is modified. - \param color: Color key color. Every pixel with this color will get transparent - like described above. Please note that the colors of a texture may get - converted when loading it, so the color values may not be exactly the same - in the engine and for example in picture edit programs. To avoid this - problem, you could use the makeColorKeyTexture method, which takes the position - of a pixel instead a color value. */ - virtual void makeColorKeyTexture(video::ITexture* texture, video::SColor color) = 0; - - //! Creates an 1bit alpha channel of the texture based of an color key position. - /** This makes the texture transparent at the regions where this color - key can be found when using for example draw2DImage with useAlphachannel - = true. - \param texture: Texture of which its alpha channel is modified. - \param colorKeyPixelPos: Position of a pixel with the color key color. - Every pixel with this color will get transparent - like described above. */ - virtual void makeColorKeyTexture(video::ITexture* texture, - core::position2d colorKeyPixelPos) = 0; - - //! Creates a normal map from a height map texture. - /** If the target texture - has 32 bit, the height value is stored in the alpha component of the texture as - addition. This value will be used by the video::EMT_PARALLAX_MAP_SOLID - material and similar materials. - \param texture: Texture of which its alpha channel is modified. - \param amplitude: Constant value by which the height information is multiplied.*/ - virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f) = 0; - - //! Sets a new render target. - /** This will only work if the driver - supports the EVDF_RENDER_TO_TARGET feature, which can be - queried with queryFeature(). Usually, rendering to textures is done in this - way: - \code - // create render target - ITexture* target = driver->createRenderTargetTexture(core::dimension2d(128,128)); - - // ... - - driver->setRenderTarget(target); // set render target - // .. draw stuff here - driver->setRenderTarget(0); // set previous render target - Please note that you cannot render 3D or 2D geometry with a render target as texture - on it when you are rendering the scene into this render target at the same time. It is - usually only possible to render into a texture between the IVideoDriver::beginScene() and endScene() - method calls. And please also note that the scene will be rendered upside down into the texture - in some devices (e.g. OpenGL vs. D3D). A simple workaround for this is to flip the - texture coordinates of the geometry where the render target texture is displayed on. - \endcode - \param texture: New render target. Must be a texture created with - IVideoDriver::createRenderTargetTexture(). If set to 0, it sets the previous render - target which was set before the last setRenderTarget() call. - \param clearBackBuffer: Clears the backbuffer of the render target with the color parameter - \param clearZBuffer: Clears the zBuffer of the rendertarget. Note that, because the frame - buffer shares the zbuffer with the rendertarget, its zbuffer will be partially cleared - too with this. - \return Returns true if sucessful and false if not. */ - virtual bool setRenderTarget(video::ITexture* texture, - bool clearBackBuffer=true, bool clearZBuffer=true, - SColor color=video::SColor(0,0,0,0)) = 0; - - //! Sets a new viewport. - /** Every rendering operation is done into this new area. - \param Rectangle defining the new area of rendering operations. */ - virtual void setViewPort(const core::rect& area) = 0; - - //! Gets the area of the current viewport. - /** \return Returns rectangle of the current vieport. */ - virtual const core::rect& getViewPort() const = 0; - - //! draws a vertex primitive list - /** Note that there may be at maximum 65536 vertices, because the - index list is an array of 16 bit values each with a maximum value - of 65536. If there are more than 65536 vertices in the list, - results of this operation are not defined. - \param vertices: Pointer to array of vertices. - \param vertexCount: Amount of vertices in the array. - \param indexList: Pointer to array of indizes. - \param triangleCount: amount of Triangles. - \param vType: Vertex type, e.g. EVT_STANDARD for S3DVertex. - \param pType: Primitive type, e.g. EPT_TRIANGLE_FAN for a triangle fan. */ - virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) = 0; - - //! Draws an indexed triangle list. - /** Note that there may be at maximum 65536 vertices, because the - index list is a array of 16 bit values each with a maximum value - of 65536. If there are more than 65536 vertices in the list, - results of this operation are not defined. - \param vertices: Pointer to array of vertices. - \param vertexCount: Amount of vertices in the array. - \param indexList: Pointer to array of indizes. - \param triangleCount: amount of Triangles. Usually amount of indizes / 3. */ - virtual void drawIndexedTriangleList(const S3DVertex* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; - - //! Draws an indexed triangle list. - /** Note that there may be at maximum 65536 vertices, because the - index list is a array of 16 bit values each with a maximum value - of 65536. If there are more than 65536 vertices in the list, - results of this operation are not defined. - \param vertices: Pointer to array of vertices. - \param vertexCount: Amount of vertices in the array. - \param indexList: Pointer to array of indizes. - \param triangleCount: amount of Triangles. Usually amount of indizes / 3.*/ - virtual void drawIndexedTriangleList(const S3DVertex2TCoords* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; - - //! Draws an indexed triangle list. - /** Note that there may be at maximum 65536 vertices, because the - index list is a array of 16 bit values each with a maximum value - of 65536. If there are more than 65536 vertices in the list, - results of this operation are not defined. - \param vertices: Pointer to array of vertices. - \param vertexCount: Amount of vertices in the array. - \param indexList: Pointer to array of indizes. - \param triangleCount: amount of Triangles. Usually amount of indizes / 3. */ - virtual void drawIndexedTriangleList(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; - - //! Draws an indexed triangle fan. - /** Note that there may be at maximum 65536 vertices, because the - index list is a array of 16 bit values each with a maximum value - of 65536. If there are more than 65536 vertices in the list, - results of this operation are not defined. - Please note that some of the implementation code for this method is based on - free code sent in by Mario Gruber, lots of thanks go to him! - \param vertices: Pointer to array of vertices. - \param vertexCount: Amount of vertices in the array. - \param indexList: Pointer to array of indizes. - \param triangleCount: amount of Triangles. Usually amount of indizes - 2. */ - virtual void drawIndexedTriangleFan(const S3DVertex* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; - - //! Draws an indexed triangle fan. - /** Note that there may be at maximum 65536 vertices, because the - index list is a array of 16 bit values each with a maximum value - of 65536. If there are more than 65536 vertices in the list, - results of this operation are not defined. - Please note that some of the implementation code for this method is based on - free code sent in by Mario Gruber, lots of thanks go to him! - \param vertices: Pointer to array of vertices. - \param vertexCount: Amount of vertices in the array. - \param indexList: Pointer to array of indizes. - \param triangleCount: amount of Triangles. Usually amount of indizes - 2. */ - virtual void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; - - //! Draws a 3d line. - /** For some implementations, this method simply calls drawIndexedTriangles with some - triangles. Note that the line is drawn using the current transformation - matrix and material. So if you need to draw the 3D line independently of the - current transformation, use - \code - driver->setTransform(video::ETS_WORLD, core::matrix4()); - \endcode - before drawing the line. - This method was created for making culling debugging easier. - \param start: Start of the 3d line. - \param end: End of the 3d line. - \param color: Color of the line. */ - virtual void draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color = SColor(255,255,255,255)) = 0; - - //! Draws a 3d triangle. - /** This method usually simply calls drawIndexedTriangles with some - triangles. Note that the line is drawn using the current transformation - matrix and material. - This method was created for making collision debugging easier. It works with - all drivers because it does simply a call to drawIndexedTriangleList and - hence is not very fast but it might be useful for further development. - \param triangle: The triangle to draw. - \param color: Color of the line. */ - virtual void draw3DTriangle(const core::triangle3df& triangle, - SColor color = SColor(255,255,255,255)) = 0; - - //! Draws a 3d axis aligned box. - /** This method usually simply calls drawIndexedTriangles with some - triangles. Note that the line is drawn using the current transformation - matrix and material. - This method was created for making culling debugging easier. It works with - all drivers because it does simply a call to drawIndexedTriangleList and - hence is not very fast but it might be useful for further development. - \param box: The axis aligned box to draw - \param color: Color to use while drawing the box. */ - virtual void draw3DBox(const core::aabbox3d box, - SColor color = SColor(255,255,255,255)) = 0; - - //! Simply draws a 2d image without any special effects - /** \param texture: Pointer to texture to use. - \param destPos: upper left 2d destination position where the image will be drawn. */ - virtual void draw2DImage(video::ITexture* texture, - const core::position2d& destPos) = 0; - - //! Draws a 2d image using a color - /** (if color is other than - Color(255,255,255,255)) and the alpha channel of the texture if wanted. - \param texture: Texture to be drawn. - \param destPos: Upper left 2d destination position where the image will be drawn. - \param sourceRect: Source rectangle in the image. - \param clipRect: Pointer to rectangle on the screen where the image is clipped to. - This pointer can be NULL. Then the image is not clipped. - \param color: Color with which the image is colored. If the color equals - Color(255,255,255,255), the color is ignored. Note that the alpha component - is used: If alpha is other than 255, the image will be transparent. - \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is - used to draw the image.*/ - virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos, - const core::rect& sourceRect, const core::rect* clipRect = 0, - SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) = 0; - - //! draws a set of 2d images, using a color and the alpha - /** channel of the texture if desired. The images are drawn - beginning at pos and concatenated in one line. All drawings - are clipped against clipRect (if != 0). - The subtextures are defined by the array of sourceRects - and are chosen by the indices given. - \param texture: Texture to be drawn. - \param pos: Upper left 2d destination position where the image will be drawn. - \param sourceRects: Source rectangles of the image. - \param indices: List of indices which choose the actual rectangle used each time. - \param kerningWidth: Offset to Position on X - \param clipRect: Pointer to rectangle on the screen where the image is clipped to. - This pointer can be 0. Then the image is not clipped. - \param color: Color with which the image is colored. - Note that the alpha component is used: If alpha is other than 255, the image will be transparent. - \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is - used to draw the image. */ - virtual void draw2DImage(video::ITexture* texture, - const core::position2d& pos, - const core::array >& sourceRects, - const core::array& indices, - s32 kerningWidth, - const core::rect* clipRect, SColor color, - bool useAlphaChannelOfTexture) = 0; - - //! Draws a part of the texture into the rectangle. - /** Suggested and first implemented by zola. - \param texture: the texture to draw from - \param destRect: the rectangle to draw into - \param sourceRect: the rectangle denoting a part of the texture - \param clipRect: clips the destination rectangle (may be 0) - \param colors: array of 4 colors denoting the color values of the corners of the destRect - \param useAlphaChannelOfTexture: true if alpha channel will be blended. */ - virtual void draw2DImage(video::ITexture* texture, const core::rect& destRect, - const core::rect& sourceRect, const core::rect* clipRect = 0, - video::SColor* colors=0, bool useAlphaChannelOfTexture=false) = 0; - - //!Draws an 2d rectangle. - /** \param color: Color of the rectangle to draw. The alpha component will not - be ignored and specifies how transparent the rectangle will be. - \param pos: Position of the rectangle. - \param clip: Pointer to rectangle against which the rectangle will be clipped. - If the pointer is null, no clipping will be performed. */ - virtual void draw2DRectangle(SColor color, const core::rect& pos, - const core::rect* clip = 0) = 0; - - //!Draws an 2d rectangle with a gradient. - /** \param colorLeftUp: Color of the left upper corner to draw. - The alpha component will not be ignored and specifies how transparent the rectangle will be. - \param colorRightUp: Color of the right upper corner to draw. - The alpha component will not be ignored and specifies how transparent the rectangle will be. - \param colorLeftDown: Color of the left lower corner to draw. - The alpha component will not be ignored and specifies how transparent the rectangle will be. - \param colorRightDown: Color of the right lower corner to draw. - The alpha component will not be ignored and specifies how transparent the rectangle will be. - \param pos: Position of the rectangle. - \param clip: Pointer to rectangle against which the rectangle will be clipped. - If the pointer is null, no clipping will be performed. */ - virtual void draw2DRectangle(const core::rect& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect* clip = 0) = 0; - - //! Draws a 2d line. - /** \param start: Screen coordinates of the start of the line in pixels. - \param end: Screen coordinates of the start of the line in pixels. - \param color: Color of the line to draw. */ - virtual void draw2DLine(const core::position2d& start, - const core::position2d& end, - SColor color=SColor(255,255,255,255)) = 0; - - //! Draws a non filled concyclic regular 2d polyon. - /** This method can be used to draw - circles, but also triangles, tetragons, pentagons, hexagons, heptagons, octagons, - enneagons, decagons, hendecagons, dodecagon, triskaidecagons, etc. I think you'll - got it now. And all this by simply specifying the vertex count. Welcome to the - wonders of geometry. - \param center: Position of center of circle (pixels). - \param radius: Radius of circle in pixels. - \param color: Color of the circle. - \param vertexCount: Amount of vertices of the polygon. Specify 2 to draw a line, - 3 to draw a triangle, 4 for a tetragons and a lot (>10) for nearly a circle. */ - virtual void draw2DPolygon(core::position2d center, - f32 radius, video::SColor color=SColor(100,255,255,255), s32 vertexCount=10) = 0; - - //! Draws a shadow volume into the stencil buffer. - /** To draw a stencil shadow, do - this: Frist, draw all geometry. Then use this method, to draw the shadow - volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. - Please note that the code for the opengl version of the method is based on - free code sent in by Philipp Dortmann, lots of thanks go to him! - \param triangles: Pointer to array of 3d vectors, specifing the shadow volume. - \param count: Amount of triangles in the array. - \param zfail: If set to true, zfail method is used, otherwise zpass. */ - virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail=true) = 0; - - //! Fills the stencil shadow with color. - /** After the shadow volume has been drawn - into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this - to draw the color of the shadow. - Please note that the code for the opengl version of the method is based on - free code sent in by Philipp Dortmann, lots of thanks go to him! - \param clearStencilBuffer: Set this to false, if you want to draw every shadow - with the same color, and only want to call drawStencilShadow() once after all - shadow volumes have been drawn. Set this to true, if you want to paint every - shadow with its own color. - \param leftUpEdge: Color of the shadow in the upper left corner of screen. - \param rightUpEdge: Color of the shadow in the upper right corner of screen. - \param leftDownEdge: Color of the shadow in the lower left corner of screen. - \param rightDownEdge: Color of the shadow in the lower right corner of screen. */ - virtual void drawStencilShadow(bool clearStencilBuffer=false, - video::SColor leftUpEdge = video::SColor(255,0,0,0), - video::SColor rightUpEdge = video::SColor(255,0,0,0), - video::SColor leftDownEdge = video::SColor(255,0,0,0), - video::SColor rightDownEdge = video::SColor(255,0,0,0)) = 0; - - //! Draws a mesh buffer - /** \param mb: Buffer to draw; */ - virtual void drawMeshBuffer( const scene::IMeshBuffer* mb) = 0; - - //! Sets the fog mode. - /** These are global values attached to each 3d object - rendered, which has the fog flag enabled in its material. - \param color: Color of the fog - \param linearFog: Set this to true for linear fog, otherwise exponential fog is applied. - \param start: Only used in linear fog mode (linearFog=true). Specifies where fog starts. - \param end: Only used in linear fog mode (linearFog=true). Specifies where fog ends. - \param density: Only used in expotential fog mode (linearFog=false). Must be a value between 0 and 1. - \param pixelFog: Set this to false for vertex fog, and true if you want pixel fog. - \param rangeFog: Set this to true to enable range-based vertex fog. The distance - from the viewer is used to compute the fog, not the z-coordinate. This is - better, but slower. This is only available with D3D and vertex fog. */ - virtual void setFog(SColor color=SColor(0,255,255,255), bool linearFog=true, f32 start=50.0f, f32 end=100.0f, - f32 density=0.01f, bool pixelFog=false, bool rangeFog=false) = 0; - - //! Returns the size of the screen or render window. - /** \return Size of screen or render window. */ - virtual core::dimension2d getScreenSize() = 0; - - //! Returns the size of the current render target, or the screen size if the driver - //! doesnt support render to texture - /** \return Size of render target or screen/window */ - virtual core::dimension2d getCurrentRenderTargetSize() = 0; - - - //! Returns current frames per second value. - /** \return Returns amount of frames per second drawn. **/ - virtual s32 getFPS() = 0; - - //! Returns amount of primitives (mostly triangles) which were drawn in the last frame. - /** Together with getFPS() very useful method for statistics. - \return Amount of primitives drawn in the last frame. */ - virtual u32 getPrimitiveCountDrawn( u32 param = 0 ) = 0; - - //! Deletes all dynamic lights which were previously added with addDynamicLight(). - virtual void deleteAllDynamicLights() = 0; - - //! Adds a dynamic light. - /** \param light: Data specifing the dynamic light. */ - virtual void addDynamicLight(const SLight& light) = 0; - - //! Sets the dynamic ambient light color. - /** The default color is - (0,0,0,0) which means it is dark. - \param color: New color of the ambient light. */ - virtual void setAmbientLight(const SColorf& color) = 0; - - //! Returns the maximal amount of dynamic lights the device can handle - /** \return Maximal amount of dynamic lights. */ - virtual u32 getMaximalDynamicLightAmount() = 0; - - //! Returns current amount of dynamic lights set - /** \return Current amount of dynamic lights set */ - virtual u32 getDynamicLightCount() = 0; - - //! Returns light data which was previously set with IVideDriver::addDynamicLight(). - /** \param idx: Zero based index of the light. Must be greater than 0 and smaller - than IVideoDriver()::getDynamicLightCount. - \return Light data. */ - virtual const SLight& getDynamicLight(u32 idx) = 0; - - //! Gets name of this video driver. - /** \return Returns the name of the video driver. Example: In case of the Direct3D8 - driver, it would return "Direct3D 8.1". */ - virtual const wchar_t* getName() = 0; - - //! Adds an external image loader to the engine. - /** This is useful if - the Irrlicht Engine should be able to load textures of currently - unsupported file formats (e.g .gif). The IImageLoader only needs - to be implemented for loading this file format. A pointer to - the implementation can be passed to the engine using this method. - \param loader: Pointer to the external loader created. */ - virtual void addExternalImageLoader(IImageLoader* loader) = 0; - - //! Adds an external image writer to the engine. - /** This is useful if - the Irrlicht Engine should be able to write textures of currently - unsupported file formats (e.g .gif). The IImageWriter only needs - to be implemented for writing this file format. A pointer to - the implementation can be passed to the engine using this method. - \param writer: Pointer to the external writer created. */ - virtual void addExternalImageWriter(IImageWriter* writer) = 0; - - //! Returns the maximum amount of primitives - /** (mostly vertices) which - the device is able to render with one drawIndexedTriangleList - call. */ - virtual u32 getMaximalPrimitiveCount() = 0; - - //! Enables or disables a texture creation flag. - /** This flag defines how - textures should be created. By changing this value, you can influence for example - the speed of rendering a lot. But please note that the video drivers - take this value only as recommendation. It could happen that you - enable the ETCM_ALWAYS_16_BIT mode, but the driver creates 32 bit - textures. - \param flag: Texture creation flag. - \param enbabled: Specifies if the given flag should be enabled or disabled.*/ - virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) = 0; - - //! Returns if a texture creation flag is enabled or disabled. - /** You can change this value using setTextureCreationMode(). - \param flag: Texture creation flag. - \return Returns the current texture creation mode. */ - virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) = 0; - - //! Creates a software image from a file. - /** No hardware texture will - be created for this image. This method is useful for example if - you want to read a heightmap for a terrain renderer. - \param filename: Name of the file from which the image is created. - \return Returns the created image. - If you no longer need the image, you should call IImage::drop(). - See IUnknown::drop() for more information. */ - virtual IImage* createImageFromFile(const c8* filename) = 0; - - //! Creates a software image from a file. - /** No hardware texture will - be created for this image. This method is useful for example if - you want to read a heightmap for a terrain renderer. - \param file: File from which the image is created. - \return Returns the created image. - If you no longer need the image, you should call IImage::drop(). - See IUnknown::drop() for more information. */ - virtual IImage* createImageFromFile(io::IReadFile* file) = 0; - - //! Writes the provided image to disk file - /** Requires that there is a suitable image writer - registered for writing the image to disk - \param image: Image to write to disk - \param filename: name of the file to write - \param param: control parameter for the backend ( eq. compression level ) - \return Returns true on success */ - virtual bool writeImageToFile(IImage* image, const c8* filename, u32 param = 0) = 0; - - //! Creates a software image from a byte array. - /** No hardware texture will - be created for this image. This method is useful for example if - you want to read a heightmap for a terrain renderer. - \param format: Desired color format of the texture - \param size: Desired the size of the image - \param data: a byte array with pixelcolor information - \param useForeignMemory: If true, the image will use the data pointer - directly and own it from now on, which means it will also try to delete [] the - data when the image will be destructed. - If false, the memory will by copied internally. - \return Returns the created image. - If you no longer need the image, you should call IImage::drop(). - See IUnknown::drop() for more information. */ - virtual IImage* createImageFromData(ECOLOR_FORMAT format, - const core::dimension2d& size, void *data, - bool ownForeignMemory=false, - bool deleteMemory = true) = 0; - - //! Only used by the internal engine. - /** Used to notify the driver that - the window was resized. Usually, there is no need to call this method. */ - virtual void OnResize(const core::dimension2d& size) = 0; - - //! Adds a new material renderer to the video device. - /** Use this method to extend the VideoDriver with new MaterialTypes. To extend the - engine using this method do the following: - Derive a class from IMaterialRenderer and override the methods you need. For - setting the right renderstates, you can try to get a pointer to the real rendering device - using IVideoDriver::getExposedVideoData(). Add your class with - IVideoDriver::addMaterialRenderer() and if you want an object in the engine to be displayed - with your new material, set the MaterialType member of the SMaterial struct to the - value returned by this method. - If you simply want to create a new material using vertex and/or pixel shaders, it would - be easier to use the video::IGPUProgrammingServices interface which you can get using - the getGPUProgrammingServices() method. - \param name: name for this registered material renderer entry. - \return Returns the number of the - material type which can be set in SMaterial::MaterialType to use the renderer. - -1 is returned if an error occured. (For example if you tried to add - an material renderer to the software renderer or the null device, which do not accept - material renderers.) */ - virtual s32 addMaterialRenderer(IMaterialRenderer* renderer, const c8* name = 0) = 0; - - //! Returns pointer to material renderer or null if not existing. - /** \param idx: Id of the material renderer. Can be a value of the E_MATERIAL_TYPE enum or a - value which was returned by addMaterialRenderer(). */ - virtual IMaterialRenderer* getMaterialRenderer(u32 idx) = 0; - - //! Returns amount of currently available material renderers. - virtual u32 getMaterialRendererCount() = 0; - - //! Returns name of the material renderer - /** This string can for example be used to test if a specific renderer already has - been registered/created, or use this string to store data about materials: This - returned name will be also used when serializing Materials. - \param idx: Id of the material renderer. Can be a value of the E_MATERIAL_TYPE enum or a - value which was returned by addMaterialRenderer(). */ - virtual const c8* getMaterialRendererName(u32 idx) = 0; - - //! Sets the name of a material renderer. - /** Will have no effect on built-in material renderers. - \param idx: Id of the material renderer. Can be a value of the E_MATERIAL_TYPE enum or a - value which was returned by addMaterialRenderer(). */ - virtual void setMaterialRendererName(s32 idx, const c8* name) = 0; - - //! Creates material attributes list from a material, usable for serialization and more. - /** Please note that the videodriver will use the material renderer names from - getMaterialRendererName() to write out the material type name, so they should be set before. */ - virtual io::IAttributes* createAttributesFromMaterial(const video::SMaterial& material) = 0; - - //! Fills an SMaterial structure from attributes. - /** Please note that for setting material types of the material, the video driver - will need to query the material renderers for their names, so all non built-in materials must have been created before - calling this method. */ - virtual void fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attributes) = 0; - - //! Returns driver and operating system specific data about the IVideoDriver. - /** This method should only be used if the engine should be extended without having - to modify the source of the engine. */ - virtual SExposedVideoData getExposedVideoData() = 0; - - //! Returns type of video driver - virtual E_DRIVER_TYPE getDriverType() = 0; - - //! Returns pointer to the IGPUProgrammingServices interface. - /** Returns 0 if the - videodriver does not support this. (For example the Software and the NULL device - will always return 0) */ - virtual IGPUProgrammingServices* getGPUProgrammingServices() = 0; - - //! Clears the ZBuffer. - /** Note that you usually need not to call this method, - This is done automaticly during IVideoDriver::beginScene() or - IVideoDriver::setRenderTarget() if you specify zBuffer=true. - But if you have to render some special things, you can clear the zbuffer - during the rendering process with this method another time. */ - virtual void clearZBuffer() = 0; - - //! Returns an image created from the last rendered frame. - virtual IImage* createScreenShot() = 0; - }; - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_I_VIDEO_DRIVER_H_INCLUDED__ +#define __IRR_I_VIDEO_DRIVER_H_INCLUDED__ + +#include "rect.h" +#include "SColor.h" +#include "ITexture.h" +#include "irrArray.h" +#include "matrix4.h" +#include "dimension2d.h" +#include "position2d.h" +#include "IReadFile.h" +#include "SMaterial.h" +#include "IImageLoader.h" +#include "IImageWriter.h" +#include "IMeshBuffer.h" +#include "triangle3d.h" +#include "SExposedVideoData.h" +#include "IMaterialRenderer.h" +#include "EDriverTypes.h" +#include "IGPUProgrammingServices.h" + +namespace irr +{ +namespace io +{ + class IAttributes; +} // end namespace io +namespace scene +{ + class IMeshBuffer; +} // end namespace scene + +namespace video +{ + struct S3DVertex; + struct S3DVertex2TCoords; + struct S3DVertexTangents; + struct SLight; + + //! enumeration for querying features of the video driver. + enum E_VIDEO_DRIVER_FEATURE + { + //! Is driver able to render to a surface? + EVDF_RENDER_TO_TARGET = 0, + + //! Is hardeware transform and lighting supported? + EVDF_HARDWARE_TL, + + //! Are multiple textures per material possible? + EVDF_MULTITEXTURE, + + //! Is driver able to render with a bilinear filter applied? + EVDF_BILINEAR_FILTER, + + //! Can the driver handle mip maps? + EVDF_MIP_MAP, + + //! Can the driver update mip maps automatically? + EVDF_MIP_MAP_AUTO_UPDATE, + + //! Are stencilbuffers switched on and does the device support stencil buffers? + EVDF_STENCIL_BUFFER, + + //! Is Vertex Shader 1.1 supported? + EVDF_VERTEX_SHADER_1_1, + + //! Is Vertex Shader 2.0 supported? + EVDF_VERTEX_SHADER_2_0, + + //! Is Vertex Shader 3.0 supported? + EVDF_VERTEX_SHADER_3_0, + + //! Is Pixel Shader 1.1 supported? + EVDF_PIXEL_SHADER_1_1, + + //! Is Pixel Shader 1.2 supported? + EVDF_PIXEL_SHADER_1_2, + + //! Is Pixel Shader 1.3 supported? + EVDF_PIXEL_SHADER_1_3, + + //! Is Pixel Shader 1.4 supported? + EVDF_PIXEL_SHADER_1_4, + + //! Is Pixel Shader 2.0 supported? + EVDF_PIXEL_SHADER_2_0, + + //! Is Pixel Shader 3.0 supported? + EVDF_PIXEL_SHADER_3_0, + + //! Are ARB vertex programs v1.0 supported? + EVDF_ARB_VERTEX_PROGRAM_1, + + //! Are ARB fragment programs v1.0 supported? + EVDF_ARB_FRAGMENT_PROGRAM_1, + + //! Is GLSL supported? + EVDF_ARB_GLSL, + + //! Is HLSL supported? + EVDF_HLSL, + + //! Are non-power-of-two textures supported? + EVDF_TEXTURE_NPOT, + + //! Are framebuffer objects supported? + EVDF_FRAMEBUFFER_OBJECT + }; + + //! enumeration for geometry transformation states + enum E_TRANSFORMATION_STATE + { + //! View transformation + ETS_VIEW = 0, + //! World transformation + ETS_WORLD, + //! Projection transformation + ETS_PROJECTION, + //! Texture transformation + ETS_TEXTURE_0, + //! Texture transformation + ETS_TEXTURE_1, + //! Texture transformation + ETS_TEXTURE_2, + //! Texture transformation + ETS_TEXTURE_3, + //! Not used + ETS_COUNT + }; + + + //! Interface to driver which is able to perform 2d and 3d gfx functions. + /** The IVideoDriver interface is one of the most important interfaces of + the Irrlicht Engine: All rendering and texture manipulating is done with + this interface. You are able to use the Irrlicht Engine by only invoking methods + of this interface if you would like to, although the irr::scene::ISceneManager interface + provides a lot of powerful classes and methods to make the programmers life + easier. + */ + class IVideoDriver : public virtual IUnknown + { + public: + + //! destructor + virtual ~IVideoDriver() {} + + //! Applications must call this method before performing any rendering. + /** \param backBuffer: Specifies if the back buffer should be cleared, which + means that the screen is filled with a color specified with the parameter color. + If this parameter is false, the back buffer will not be cleared and the color + parameter is ignored. + \param zBuffer: Specifies if the depth or z buffer should be cleared. It is + not nesesarry to do so, if only 2d drawing is used. + \return Returns false if failed. Begin Scene can clear the back- and the z-buffer. */ + virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color) = 0; + + //! Presents the rendered image on the screen. + /** Applications must call this method after performing any rendering. + \param windowId: Handle of another window, if you want the bitmap to be displayed + on another window. If this is null, everything will be displayed in the default window. + Note: This does not work in fullscreen mode and is not implemented for all devices (only for + D3D8, D3D9, Software1 and Software2, and only for Windows). + \param sourceRect: Pointer to a rectangle defining the source rectangle of the area + to be presented. Set to null to present everything. Note: not implemented in all devices. + \return Returns false if failed and true if succeeded. */ + virtual bool endScene( s32 windowId = 0, core::rect* sourceRect=0 ) = 0; + + //! Queries the features of the driver. + /** Returns true if a feature is available + \param feature: A feature to query. + \return Returns true if the feature is available, false if not. */ + virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) = 0; + + //! Sets the view, world or projection transformation. + /* \param state: Transformation type to be set. Can be view, world or projection. + \param mat: Matrix describing the transformation. */ + virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) = 0; + + //! Returns the transformation set by setTransform + virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) = 0; + + //! Sets a material. + /** All 3d drawing functions draw geometry now + using this material. + \param material: Material to be used from now on. */ + virtual void setMaterial(const SMaterial& material) = 0; + + //! Returns a pointer to a texture. + /** Loads the texture if it is not + already loaded, and generates mipmap levels if wished. + You can influence how the texture is loaded using the setTextureCreationFlag() + method. + The texture can be in BMP, JPG, TGA, PCX, PNG and PSD format. + For loading BMP, TGA, PCX, and PSD files, the engine uses its own methods. + PCX loading is based on some code by Dean P. Macri, who sent + it in for free use by the engine, PGN loading is done using a loader + by rt who allowed it to be used by Irrlicht. + For loading JPG-Files the JPEG LIB 6b, written by + The Independent JPEG Group is used by the engine. For PNG loading, + libPNG is used. Thanx for such great libraries! + \param filename: Filename of the texture to be loaded. + \return Returns a pointer to the texture and NULL if the texture + could not be loaded. + This pointer should not be dropped. See IUnknown::drop() for more information.*/ + virtual ITexture* getTexture(const c8* filename) = 0; + + //! Returns a pointer to a texture. + /** Loads the texture if it is not + already loaded, and generates mipmap levels if wished. + You can influence how the texture is loaded using the setTextureCreationFlag() + method. + The texture can be in BMP, JPG, TGA, PCX, PNG and PSD format. + For loading BMP, TGA, PCX, and PSD files, the engine uses its own methods. + PCX loading is based on some code by Dean P. Macri, who sent + it in for free use by the engine, PGN loading is done using a loader + by rt who allowed it to be used by Irrlicht. + For loading JPG-Files the JPEG LIB 6b, written by + The Independent JPEG Group is used by the engine. For PNG loading, + libPNG is used. Thanx for such great libraries! + \param file: Pointer to an already opened file. + \return Returns a pointer to the texture and NULL if the texture + could not be loaded. + This pointer should not be dropped. See IUnknown::drop() for more information.*/ + virtual ITexture* getTexture(io::IReadFile* file) = 0; + + //! Returns a texture by index + /** \param index: Index of the texture, must be smaller than getTextureCount() + Please note that this index would change when adding or removing textures + */ + virtual ITexture* getTextureByIndex(u32 index) = 0; + + //! Returns amount of textures currently loaded + virtual s32 getTextureCount() = 0; + + //! Creates an empty Texture of specified size. + /** \param size: Size of the texture. + \param name: A name for the texture. Later calls of getTexture() with this name + will return this texture + \param format: Desired color format of the texture. Please note that + the driver may choose to create the texture in another color format. + \return Returns a pointer to the new created Texture. + This pointer should not be dropped. See IUnknown::drop() for more information. + The format of the new texture will be chosen by the driver. */ + virtual ITexture* addTexture(const core::dimension2d& size, + const c8* name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0; + + //! Creates a texture from a loaded IImage. + /** \param name: A name for the texture. Later calls of getTexture() with this name + will return this texture + \param image: Image from which the texture is created from. + \return Returns a pointer to the new created Texture. + This pointer should not be dropped. See IUnknown::drop() for more information. + The format of the new texture will be chosen by the driver. */ + virtual ITexture* addTexture(const c8* name, IImage* image) = 0; + + //! Creates a render target texture. + /** \param size: Size of the texture, in pixels. Width and height should + be a power of two (for example 64, 128, 256, 512, ...) and it should not + be bigger than the backbuffer, because it shares the zbuffer with the + screen buffer. + \return Returns a pointer to the created texture or 0 if the texture could not + be created. If you no longer need the image, you should call ITexture::drop(). + See IUnknown::drop() for more information. */ + virtual ITexture* createRenderTargetTexture(const core::dimension2d& size) = 0; + + //! Removes a texture from the texture cache and deletes it, freeing lot of memory. + /** Please note that after calling this, the pointer to the ITexture + may not be longer valid, if it was not grabbed before by other parts of + the engine for storing it longer. So it would be a good idea to set all + materials which are using this texture to null or another texture first. + \param texture: Texture to delete from the engines cache. */ + virtual void removeTexture(ITexture* texture) = 0; + + //! Removes all texture from the texture cache and deletes them, freeing lot of memory. + /** Please note that after calling this, the pointer to all ITextures + may not be longer valid, if they were not grabbed before by other parts of + the engine for storing them longer. So it would be a good idea to set all + materials which are using textures to null first. */ + virtual void removeAllTextures() = 0; + + //! Creates an 1bit alpha channel of the texture based of an color key. + /** This makes the texture transparent at the regions where this color + key can be found when using for example draw2DImage with useAlphachannel + = true. + \param texture: Texture of which its alpha channel is modified. + \param color: Color key color. Every pixel with this color will get transparent + like described above. Please note that the colors of a texture may get + converted when loading it, so the color values may not be exactly the same + in the engine and for example in picture edit programs. To avoid this + problem, you could use the makeColorKeyTexture method, which takes the position + of a pixel instead a color value. */ + virtual void makeColorKeyTexture(video::ITexture* texture, video::SColor color) = 0; + + //! Creates an 1bit alpha channel of the texture based of an color key position. + /** This makes the texture transparent at the regions where this color + key can be found when using for example draw2DImage with useAlphachannel + = true. + \param texture: Texture of which its alpha channel is modified. + \param colorKeyPixelPos: Position of a pixel with the color key color. + Every pixel with this color will get transparent + like described above. */ + virtual void makeColorKeyTexture(video::ITexture* texture, + core::position2d colorKeyPixelPos) = 0; + + //! Creates a normal map from a height map texture. + /** If the target texture + has 32 bit, the height value is stored in the alpha component of the texture as + addition. This value will be used by the video::EMT_PARALLAX_MAP_SOLID + material and similar materials. + \param texture: Texture of which its alpha channel is modified. + \param amplitude: Constant value by which the height information is multiplied.*/ + virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f) = 0; + + //! Sets a new render target. + /** This will only work if the driver + supports the EVDF_RENDER_TO_TARGET feature, which can be + queried with queryFeature(). Usually, rendering to textures is done in this + way: + \code + // create render target + ITexture* target = driver->createRenderTargetTexture(core::dimension2d(128,128)); + + // ... + + driver->setRenderTarget(target); // set render target + // .. draw stuff here + driver->setRenderTarget(0); // set previous render target + Please note that you cannot render 3D or 2D geometry with a render target as texture + on it when you are rendering the scene into this render target at the same time. It is + usually only possible to render into a texture between the IVideoDriver::beginScene() and endScene() + method calls. And please also note that the scene will be rendered upside down into the texture + in some devices (e.g. OpenGL vs. D3D). A simple workaround for this is to flip the + texture coordinates of the geometry where the render target texture is displayed on. + \endcode + \param texture: New render target. Must be a texture created with + IVideoDriver::createRenderTargetTexture(). If set to 0, it sets the previous render + target which was set before the last setRenderTarget() call. + \param clearBackBuffer: Clears the backbuffer of the render target with the color parameter + \param clearZBuffer: Clears the zBuffer of the rendertarget. Note that, because the frame + buffer shares the zbuffer with the rendertarget, its zbuffer will be partially cleared + too with this. + \return Returns true if sucessful and false if not. */ + virtual bool setRenderTarget(video::ITexture* texture, + bool clearBackBuffer=true, bool clearZBuffer=true, + SColor color=video::SColor(0,0,0,0)) = 0; + + //! Sets a new viewport. + /** Every rendering operation is done into this new area. + \param Rectangle defining the new area of rendering operations. */ + virtual void setViewPort(const core::rect& area) = 0; + + //! Gets the area of the current viewport. + /** \return Returns rectangle of the current vieport. */ + virtual const core::rect& getViewPort() const = 0; + + //! draws a vertex primitive list + /** Note that there may be at maximum 65536 vertices, because the + index list is an array of 16 bit values each with a maximum value + of 65536. If there are more than 65536 vertices in the list, + results of this operation are not defined. + \param vertices: Pointer to array of vertices. + \param vertexCount: Amount of vertices in the array. + \param indexList: Pointer to array of indizes. + \param triangleCount: amount of Triangles. + \param vType: Vertex type, e.g. EVT_STANDARD for S3DVertex. + \param pType: Primitive type, e.g. EPT_TRIANGLE_FAN for a triangle fan. */ + virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) = 0; + + //! Draws an indexed triangle list. + /** Note that there may be at maximum 65536 vertices, because the + index list is a array of 16 bit values each with a maximum value + of 65536. If there are more than 65536 vertices in the list, + results of this operation are not defined. + \param vertices: Pointer to array of vertices. + \param vertexCount: Amount of vertices in the array. + \param indexList: Pointer to array of indizes. + \param triangleCount: amount of Triangles. Usually amount of indizes / 3. */ + virtual void drawIndexedTriangleList(const S3DVertex* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; + + //! Draws an indexed triangle list. + /** Note that there may be at maximum 65536 vertices, because the + index list is a array of 16 bit values each with a maximum value + of 65536. If there are more than 65536 vertices in the list, + results of this operation are not defined. + \param vertices: Pointer to array of vertices. + \param vertexCount: Amount of vertices in the array. + \param indexList: Pointer to array of indizes. + \param triangleCount: amount of Triangles. Usually amount of indizes / 3.*/ + virtual void drawIndexedTriangleList(const S3DVertex2TCoords* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; + + //! Draws an indexed triangle list. + /** Note that there may be at maximum 65536 vertices, because the + index list is a array of 16 bit values each with a maximum value + of 65536. If there are more than 65536 vertices in the list, + results of this operation are not defined. + \param vertices: Pointer to array of vertices. + \param vertexCount: Amount of vertices in the array. + \param indexList: Pointer to array of indizes. + \param triangleCount: amount of Triangles. Usually amount of indizes / 3. */ + virtual void drawIndexedTriangleList(const S3DVertexTangents* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; + + //! Draws an indexed triangle fan. + /** Note that there may be at maximum 65536 vertices, because the + index list is a array of 16 bit values each with a maximum value + of 65536. If there are more than 65536 vertices in the list, + results of this operation are not defined. + Please note that some of the implementation code for this method is based on + free code sent in by Mario Gruber, lots of thanks go to him! + \param vertices: Pointer to array of vertices. + \param vertexCount: Amount of vertices in the array. + \param indexList: Pointer to array of indizes. + \param triangleCount: amount of Triangles. Usually amount of indizes - 2. */ + virtual void drawIndexedTriangleFan(const S3DVertex* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; + + //! Draws an indexed triangle fan. + /** Note that there may be at maximum 65536 vertices, because the + index list is a array of 16 bit values each with a maximum value + of 65536. If there are more than 65536 vertices in the list, + results of this operation are not defined. + Please note that some of the implementation code for this method is based on + free code sent in by Mario Gruber, lots of thanks go to him! + \param vertices: Pointer to array of vertices. + \param vertexCount: Amount of vertices in the array. + \param indexList: Pointer to array of indizes. + \param triangleCount: amount of Triangles. Usually amount of indizes - 2. */ + virtual void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; + + //! Draws a 3d line. + /** For some implementations, this method simply calls drawIndexedTriangles with some + triangles. Note that the line is drawn using the current transformation + matrix and material. So if you need to draw the 3D line independently of the + current transformation, use + \code + driver->setTransform(video::ETS_WORLD, core::matrix4()); + \endcode + before drawing the line. + This method was created for making culling debugging easier. + \param start: Start of the 3d line. + \param end: End of the 3d line. + \param color: Color of the line. */ + virtual void draw3DLine(const core::vector3df& start, + const core::vector3df& end, SColor color = SColor(255,255,255,255)) = 0; + + //! Draws a 3d triangle. + /** This method usually simply calls drawIndexedTriangles with some + triangles. Note that the line is drawn using the current transformation + matrix and material. + This method was created for making collision debugging easier. It works with + all drivers because it does simply a call to drawIndexedTriangleList and + hence is not very fast but it might be useful for further development. + \param triangle: The triangle to draw. + \param color: Color of the line. */ + virtual void draw3DTriangle(const core::triangle3df& triangle, + SColor color = SColor(255,255,255,255)) = 0; + + //! Draws a 3d axis aligned box. + /** This method usually simply calls drawIndexedTriangles with some + triangles. Note that the line is drawn using the current transformation + matrix and material. + This method was created for making culling debugging easier. It works with + all drivers because it does simply a call to drawIndexedTriangleList and + hence is not very fast but it might be useful for further development. + \param box: The axis aligned box to draw + \param color: Color to use while drawing the box. */ + virtual void draw3DBox(const core::aabbox3d box, + SColor color = SColor(255,255,255,255)) = 0; + + //! Simply draws a 2d image without any special effects + /** \param texture: Pointer to texture to use. + \param destPos: upper left 2d destination position where the image will be drawn. */ + virtual void draw2DImage(video::ITexture* texture, + const core::position2d& destPos) = 0; + + //! Draws a 2d image using a color + /** (if color is other than + Color(255,255,255,255)) and the alpha channel of the texture if wanted. + \param texture: Texture to be drawn. + \param destPos: Upper left 2d destination position where the image will be drawn. + \param sourceRect: Source rectangle in the image. + \param clipRect: Pointer to rectangle on the screen where the image is clipped to. + This pointer can be NULL. Then the image is not clipped. + \param color: Color with which the image is colored. If the color equals + Color(255,255,255,255), the color is ignored. Note that the alpha component + is used: If alpha is other than 255, the image will be transparent. + \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is + used to draw the image.*/ + virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos, + const core::rect& sourceRect, const core::rect* clipRect = 0, + SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) = 0; + + //! draws a set of 2d images, using a color and the alpha + /** channel of the texture if desired. The images are drawn + beginning at pos and concatenated in one line. All drawings + are clipped against clipRect (if != 0). + The subtextures are defined by the array of sourceRects + and are chosen by the indices given. + \param texture: Texture to be drawn. + \param pos: Upper left 2d destination position where the image will be drawn. + \param sourceRects: Source rectangles of the image. + \param indices: List of indices which choose the actual rectangle used each time. + \param kerningWidth: Offset to Position on X + \param clipRect: Pointer to rectangle on the screen where the image is clipped to. + This pointer can be 0. Then the image is not clipped. + \param color: Color with which the image is colored. + Note that the alpha component is used: If alpha is other than 255, the image will be transparent. + \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is + used to draw the image. */ + virtual void draw2DImage(video::ITexture* texture, + const core::position2d& pos, + const core::array >& sourceRects, + const core::array& indices, + s32 kerningWidth, + const core::rect* clipRect, SColor color, + bool useAlphaChannelOfTexture) = 0; + + //! Draws a part of the texture into the rectangle. + /** Suggested and first implemented by zola. + \param texture: the texture to draw from + \param destRect: the rectangle to draw into + \param sourceRect: the rectangle denoting a part of the texture + \param clipRect: clips the destination rectangle (may be 0) + \param colors: array of 4 colors denoting the color values of the corners of the destRect + \param useAlphaChannelOfTexture: true if alpha channel will be blended. */ + virtual void draw2DImage(video::ITexture* texture, const core::rect& destRect, + const core::rect& sourceRect, const core::rect* clipRect = 0, + video::SColor* colors=0, bool useAlphaChannelOfTexture=false) = 0; + + //!Draws an 2d rectangle. + /** \param color: Color of the rectangle to draw. The alpha component will not + be ignored and specifies how transparent the rectangle will be. + \param pos: Position of the rectangle. + \param clip: Pointer to rectangle against which the rectangle will be clipped. + If the pointer is null, no clipping will be performed. */ + virtual void draw2DRectangle(SColor color, const core::rect& pos, + const core::rect* clip = 0) = 0; + + //!Draws an 2d rectangle with a gradient. + /** \param colorLeftUp: Color of the left upper corner to draw. + The alpha component will not be ignored and specifies how transparent the rectangle will be. + \param colorRightUp: Color of the right upper corner to draw. + The alpha component will not be ignored and specifies how transparent the rectangle will be. + \param colorLeftDown: Color of the left lower corner to draw. + The alpha component will not be ignored and specifies how transparent the rectangle will be. + \param colorRightDown: Color of the right lower corner to draw. + The alpha component will not be ignored and specifies how transparent the rectangle will be. + \param pos: Position of the rectangle. + \param clip: Pointer to rectangle against which the rectangle will be clipped. + If the pointer is null, no clipping will be performed. */ + virtual void draw2DRectangle(const core::rect& pos, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect* clip = 0) = 0; + + //! Draws a 2d line. + /** \param start: Screen coordinates of the start of the line in pixels. + \param end: Screen coordinates of the start of the line in pixels. + \param color: Color of the line to draw. */ + virtual void draw2DLine(const core::position2d& start, + const core::position2d& end, + SColor color=SColor(255,255,255,255)) = 0; + + //! Draws a non filled concyclic regular 2d polyon. + /** This method can be used to draw + circles, but also triangles, tetragons, pentagons, hexagons, heptagons, octagons, + enneagons, decagons, hendecagons, dodecagon, triskaidecagons, etc. I think you'll + got it now. And all this by simply specifying the vertex count. Welcome to the + wonders of geometry. + \param center: Position of center of circle (pixels). + \param radius: Radius of circle in pixels. + \param color: Color of the circle. + \param vertexCount: Amount of vertices of the polygon. Specify 2 to draw a line, + 3 to draw a triangle, 4 for a tetragons and a lot (>10) for nearly a circle. */ + virtual void draw2DPolygon(core::position2d center, + f32 radius, video::SColor color=SColor(100,255,255,255), s32 vertexCount=10) = 0; + + //! Draws a shadow volume into the stencil buffer. + /** To draw a stencil shadow, do + this: Frist, draw all geometry. Then use this method, to draw the shadow + volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. + Please note that the code for the opengl version of the method is based on + free code sent in by Philipp Dortmann, lots of thanks go to him! + \param triangles: Pointer to array of 3d vectors, specifing the shadow volume. + \param count: Amount of triangles in the array. + \param zfail: If set to true, zfail method is used, otherwise zpass. */ + virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail=true) = 0; + + //! Fills the stencil shadow with color. + /** After the shadow volume has been drawn + into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this + to draw the color of the shadow. + Please note that the code for the opengl version of the method is based on + free code sent in by Philipp Dortmann, lots of thanks go to him! + \param clearStencilBuffer: Set this to false, if you want to draw every shadow + with the same color, and only want to call drawStencilShadow() once after all + shadow volumes have been drawn. Set this to true, if you want to paint every + shadow with its own color. + \param leftUpEdge: Color of the shadow in the upper left corner of screen. + \param rightUpEdge: Color of the shadow in the upper right corner of screen. + \param leftDownEdge: Color of the shadow in the lower left corner of screen. + \param rightDownEdge: Color of the shadow in the lower right corner of screen. */ + virtual void drawStencilShadow(bool clearStencilBuffer=false, + video::SColor leftUpEdge = video::SColor(255,0,0,0), + video::SColor rightUpEdge = video::SColor(255,0,0,0), + video::SColor leftDownEdge = video::SColor(255,0,0,0), + video::SColor rightDownEdge = video::SColor(255,0,0,0)) = 0; + + //! Draws a mesh buffer + /** \param mb: Buffer to draw; */ + virtual void drawMeshBuffer( const scene::IMeshBuffer* mb) = 0; + + //! Sets the fog mode. + /** These are global values attached to each 3d object + rendered, which has the fog flag enabled in its material. + \param color: Color of the fog + \param linearFog: Set this to true for linear fog, otherwise exponential fog is applied. + \param start: Only used in linear fog mode (linearFog=true). Specifies where fog starts. + \param end: Only used in linear fog mode (linearFog=true). Specifies where fog ends. + \param density: Only used in expotential fog mode (linearFog=false). Must be a value between 0 and 1. + \param pixelFog: Set this to false for vertex fog, and true if you want pixel fog. + \param rangeFog: Set this to true to enable range-based vertex fog. The distance + from the viewer is used to compute the fog, not the z-coordinate. This is + better, but slower. This is only available with D3D and vertex fog. */ + virtual void setFog(SColor color=SColor(0,255,255,255), bool linearFog=true, f32 start=50.0f, f32 end=100.0f, + f32 density=0.01f, bool pixelFog=false, bool rangeFog=false) = 0; + + //! Returns the size of the screen or render window. + /** \return Size of screen or render window. */ + virtual core::dimension2d getScreenSize() = 0; + + //! Returns the size of the current render target, or the screen size if the driver + //! doesnt support render to texture + /** \return Size of render target or screen/window */ + virtual core::dimension2d getCurrentRenderTargetSize() = 0; + + + //! Returns current frames per second value. + /** \return Returns amount of frames per second drawn. **/ + virtual s32 getFPS() = 0; + + //! Returns amount of primitives (mostly triangles) which were drawn in the last frame. + /** Together with getFPS() very useful method for statistics. + \return Amount of primitives drawn in the last frame. */ + virtual u32 getPrimitiveCountDrawn( u32 param = 0 ) = 0; + + //! Deletes all dynamic lights which were previously added with addDynamicLight(). + virtual void deleteAllDynamicLights() = 0; + + //! Adds a dynamic light. + /** \param light: Data specifing the dynamic light. */ + virtual void addDynamicLight(const SLight& light) = 0; + + //! Sets the dynamic ambient light color. + /** The default color is + (0,0,0,0) which means it is dark. + \param color: New color of the ambient light. */ + virtual void setAmbientLight(const SColorf& color) = 0; + + //! Returns the maximal amount of dynamic lights the device can handle + /** \return Maximal amount of dynamic lights. */ + virtual u32 getMaximalDynamicLightAmount() = 0; + + //! Returns current amount of dynamic lights set + /** \return Current amount of dynamic lights set */ + virtual u32 getDynamicLightCount() = 0; + + //! Returns light data which was previously set with IVideDriver::addDynamicLight(). + /** \param idx: Zero based index of the light. Must be greater than 0 and smaller + than IVideoDriver()::getDynamicLightCount. + \return Light data. */ + virtual const SLight& getDynamicLight(u32 idx) = 0; + + //! Gets name of this video driver. + /** \return Returns the name of the video driver. Example: In case of the Direct3D8 + driver, it would return "Direct3D 8.1". */ + virtual const wchar_t* getName() = 0; + + //! Adds an external image loader to the engine. + /** This is useful if + the Irrlicht Engine should be able to load textures of currently + unsupported file formats (e.g .gif). The IImageLoader only needs + to be implemented for loading this file format. A pointer to + the implementation can be passed to the engine using this method. + \param loader: Pointer to the external loader created. */ + virtual void addExternalImageLoader(IImageLoader* loader) = 0; + + //! Adds an external image writer to the engine. + /** This is useful if + the Irrlicht Engine should be able to write textures of currently + unsupported file formats (e.g .gif). The IImageWriter only needs + to be implemented for writing this file format. A pointer to + the implementation can be passed to the engine using this method. + \param writer: Pointer to the external writer created. */ + virtual void addExternalImageWriter(IImageWriter* writer) = 0; + + //! Returns the maximum amount of primitives + /** (mostly vertices) which + the device is able to render with one drawIndexedTriangleList + call. */ + virtual u32 getMaximalPrimitiveCount() = 0; + + //! Enables or disables a texture creation flag. + /** This flag defines how + textures should be created. By changing this value, you can influence for example + the speed of rendering a lot. But please note that the video drivers + take this value only as recommendation. It could happen that you + enable the ETCM_ALWAYS_16_BIT mode, but the driver creates 32 bit + textures. + \param flag: Texture creation flag. + \param enbabled: Specifies if the given flag should be enabled or disabled.*/ + virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) = 0; + + //! Returns if a texture creation flag is enabled or disabled. + /** You can change this value using setTextureCreationMode(). + \param flag: Texture creation flag. + \return Returns the current texture creation mode. */ + virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) = 0; + + //! Creates a software image from a file. + /** No hardware texture will + be created for this image. This method is useful for example if + you want to read a heightmap for a terrain renderer. + \param filename: Name of the file from which the image is created. + \return Returns the created image. + If you no longer need the image, you should call IImage::drop(). + See IUnknown::drop() for more information. */ + virtual IImage* createImageFromFile(const c8* filename) = 0; + + //! Creates a software image from a file. + /** No hardware texture will + be created for this image. This method is useful for example if + you want to read a heightmap for a terrain renderer. + \param file: File from which the image is created. + \return Returns the created image. + If you no longer need the image, you should call IImage::drop(). + See IUnknown::drop() for more information. */ + virtual IImage* createImageFromFile(io::IReadFile* file) = 0; + + //! Writes the provided image to disk file + /** Requires that there is a suitable image writer + registered for writing the image to disk + \param image: Image to write to disk + \param filename: name of the file to write + \param param: control parameter for the backend ( eq. compression level ) + \return Returns true on success */ + virtual bool writeImageToFile(IImage* image, const c8* filename, u32 param = 0) = 0; + + //! Creates a software image from a byte array. + /** No hardware texture will + be created for this image. This method is useful for example if + you want to read a heightmap for a terrain renderer. + \param format: Desired color format of the texture + \param size: Desired the size of the image + \param data: a byte array with pixelcolor information + \param useForeignMemory: If true, the image will use the data pointer + directly and own it from now on, which means it will also try to delete [] the + data when the image will be destructed. + If false, the memory will by copied internally. + \return Returns the created image. + If you no longer need the image, you should call IImage::drop(). + See IUnknown::drop() for more information. */ + virtual IImage* createImageFromData(ECOLOR_FORMAT format, + const core::dimension2d& size, void *data, + bool ownForeignMemory=false, + bool deleteMemory = true) = 0; + + //! Only used by the internal engine. + /** Used to notify the driver that + the window was resized. Usually, there is no need to call this method. */ + virtual void OnResize(const core::dimension2d& size) = 0; + + //! Adds a new material renderer to the video device. + /** Use this method to extend the VideoDriver with new MaterialTypes. To extend the + engine using this method do the following: + Derive a class from IMaterialRenderer and override the methods you need. For + setting the right renderstates, you can try to get a pointer to the real rendering device + using IVideoDriver::getExposedVideoData(). Add your class with + IVideoDriver::addMaterialRenderer() and if you want an object in the engine to be displayed + with your new material, set the MaterialType member of the SMaterial struct to the + value returned by this method. + If you simply want to create a new material using vertex and/or pixel shaders, it would + be easier to use the video::IGPUProgrammingServices interface which you can get using + the getGPUProgrammingServices() method. + \param name: name for this registered material renderer entry. + \return Returns the number of the + material type which can be set in SMaterial::MaterialType to use the renderer. + -1 is returned if an error occured. (For example if you tried to add + an material renderer to the software renderer or the null device, which do not accept + material renderers.) */ + virtual s32 addMaterialRenderer(IMaterialRenderer* renderer, const c8* name = 0) = 0; + + //! Returns pointer to material renderer or null if not existing. + /** \param idx: Id of the material renderer. Can be a value of the E_MATERIAL_TYPE enum or a + value which was returned by addMaterialRenderer(). */ + virtual IMaterialRenderer* getMaterialRenderer(u32 idx) = 0; + + //! Returns amount of currently available material renderers. + virtual u32 getMaterialRendererCount() = 0; + + //! Returns name of the material renderer + /** This string can for example be used to test if a specific renderer already has + been registered/created, or use this string to store data about materials: This + returned name will be also used when serializing Materials. + \param idx: Id of the material renderer. Can be a value of the E_MATERIAL_TYPE enum or a + value which was returned by addMaterialRenderer(). */ + virtual const c8* getMaterialRendererName(u32 idx) = 0; + + //! Sets the name of a material renderer. + /** Will have no effect on built-in material renderers. + \param idx: Id of the material renderer. Can be a value of the E_MATERIAL_TYPE enum or a + value which was returned by addMaterialRenderer(). */ + virtual void setMaterialRendererName(s32 idx, const c8* name) = 0; + + //! Creates material attributes list from a material, usable for serialization and more. + /** Please note that the videodriver will use the material renderer names from + getMaterialRendererName() to write out the material type name, so they should be set before. */ + virtual io::IAttributes* createAttributesFromMaterial(const video::SMaterial& material) = 0; + + //! Fills an SMaterial structure from attributes. + /** Please note that for setting material types of the material, the video driver + will need to query the material renderers for their names, so all non built-in materials must have been created before + calling this method. */ + virtual void fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attributes) = 0; + + //! Returns driver and operating system specific data about the IVideoDriver. + /** This method should only be used if the engine should be extended without having + to modify the source of the engine. */ + virtual SExposedVideoData getExposedVideoData() = 0; + + //! Returns type of video driver + virtual E_DRIVER_TYPE getDriverType() = 0; + + //! Returns pointer to the IGPUProgrammingServices interface. + /** Returns 0 if the + videodriver does not support this. (For example the Software and the NULL device + will always return 0) */ + virtual IGPUProgrammingServices* getGPUProgrammingServices() = 0; + + //! Clears the ZBuffer. + /** Note that you usually need not to call this method, + This is done automaticly during IVideoDriver::beginScene() or + IVideoDriver::setRenderTarget() if you specify zBuffer=true. + But if you have to render some special things, you can clear the zbuffer + during the rendering process with this method another time. */ + virtual void clearZBuffer() = 0; + + //! Returns an image created from the last rendered frame. + virtual IImage* createScreenShot() = 0; + }; + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/IVideoModeList.h b/src/dep/include/irrlicht/IVideoModeList.h index da6a1dd..7c7058d 100644 --- a/src/dep/include/irrlicht/IVideoModeList.h +++ b/src/dep/include/irrlicht/IVideoModeList.h @@ -1,58 +1,58 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_I_VIDEO_MODE_LIST_H_INCLUDED__ -#define __IRR_I_VIDEO_MODE_LIST_H_INCLUDED__ - -#include "IUnknown.h" -#include "dimension2d.h" - -namespace irr -{ -namespace video -{ - - //! A list of all available video modes. - /** You can get a list via IrrlichtDevice::getVideoModeList(). If you are confused - now, because you think you have to create an Irrlicht Device with a video - mode before being able to get the video mode list, let me tell you that - there is no need to start up an Irrlicht Device with EDT_DIRECT3D8, EDT_OPENGL or - EDT_SOFTWARE: For this (and for lots of other reasons) the null device, - EDT_NULL exists.*/ - class IVideoModeList : public virtual IUnknown - { - public: - - //! destructor - virtual ~IVideoModeList() {} - - //! Gets amount of video modes in the list. - //! \return Returns amount of video modes. - virtual s32 getVideoModeCount() const = 0; - - //! Returns the screen size of a video mode in pixels. - //! \param modeNumber: zero based index of the video mode. - //! \return Returns size of screen in pixels of the specified video mode. - virtual core::dimension2d getVideoModeResolution(s32 modeNumber) const = 0; - - //! Returns the pixel depth of a video mode in bits. - //! \param modeNumber: zero based index of the video mode. - //! \return Returns the size of each pixel of the specified video mode in bits. - virtual s32 getVideoModeDepth(s32 modeNumber) const = 0; - - //! Returns current desktop screen resolution. - //! \return Returns size of screen in pixels of the current desktop video mode. - virtual core::dimension2d getDesktopResolution() const = 0; - - //! Returns the pixel depth of a video mode in bits. - //! \return Returns the size of each pixel of the current desktop video mode in bits. - virtual s32 getDesktopDepth() const = 0; - }; - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_I_VIDEO_MODE_LIST_H_INCLUDED__ +#define __IRR_I_VIDEO_MODE_LIST_H_INCLUDED__ + +#include "IUnknown.h" +#include "dimension2d.h" + +namespace irr +{ +namespace video +{ + + //! A list of all available video modes. + /** You can get a list via IrrlichtDevice::getVideoModeList(). If you are confused + now, because you think you have to create an Irrlicht Device with a video + mode before being able to get the video mode list, let me tell you that + there is no need to start up an Irrlicht Device with EDT_DIRECT3D8, EDT_OPENGL or + EDT_SOFTWARE: For this (and for lots of other reasons) the null device, + EDT_NULL exists.*/ + class IVideoModeList : public virtual IUnknown + { + public: + + //! destructor + virtual ~IVideoModeList() {} + + //! Gets amount of video modes in the list. + //! \return Returns amount of video modes. + virtual s32 getVideoModeCount() const = 0; + + //! Returns the screen size of a video mode in pixels. + //! \param modeNumber: zero based index of the video mode. + //! \return Returns size of screen in pixels of the specified video mode. + virtual core::dimension2d getVideoModeResolution(s32 modeNumber) const = 0; + + //! Returns the pixel depth of a video mode in bits. + //! \param modeNumber: zero based index of the video mode. + //! \return Returns the size of each pixel of the specified video mode in bits. + virtual s32 getVideoModeDepth(s32 modeNumber) const = 0; + + //! Returns current desktop screen resolution. + //! \return Returns size of screen in pixels of the current desktop video mode. + virtual core::dimension2d getDesktopResolution() const = 0; + + //! Returns the pixel depth of a video mode in bits. + //! \return Returns the size of each pixel of the current desktop video mode in bits. + virtual s32 getDesktopDepth() const = 0; + }; + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/IWriteFile.h b/src/dep/include/irrlicht/IWriteFile.h index 465f0fd..6072e53 100644 --- a/src/dep/include/irrlicht/IWriteFile.h +++ b/src/dep/include/irrlicht/IWriteFile.h @@ -1,52 +1,52 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_WRITE_FILE_H_INCLUDED__ -#define __I_WRITE_FILE_H_INCLUDED__ - -#include "IUnknown.h" - -namespace irr -{ -namespace io -{ - - //! Interface providing write acess to a file. - class IWriteFile : public virtual IUnknown - { - public: - - virtual ~IWriteFile() {}; - - //! Reads an amount of bytes from the file. - //! \param buffer: Pointer to buffer of bytes to write. - //! \param sizeToWrite: Amount of bytes to wrtie to the file. - //! \return Returns how much bytes were written. - virtual s32 write(const void* buffer, s32 sizeToWrite) = 0; - - //! Changes position in file, returns true if successful. - //! \param finalPos: Destination position in the file. - //! \param relativeMovement: If set to true, the position in the file is - //! changed relative to current position. Otherwise the position is changed - //! from begin of file. - //! \return Returns true if successful, otherwise false. - virtual bool seek(s32 finalPos, bool relativeMovement = false) = 0; - - //! Returns the current position in the file. - //! \return Returns the current position in the file in bytes. - virtual s32 getPos() = 0; - - //! Returns name of file. - //! \return Returns the file name as zero terminated character string. - virtual const c8* getFileName() = 0; - }; - - //! Internal function, please do not use. - IWriteFile* createWriteFile(const c8* fileName, bool append); - -} // end namespace io -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_WRITE_FILE_H_INCLUDED__ +#define __I_WRITE_FILE_H_INCLUDED__ + +#include "IUnknown.h" + +namespace irr +{ +namespace io +{ + + //! Interface providing write acess to a file. + class IWriteFile : public virtual IUnknown + { + public: + + virtual ~IWriteFile() {}; + + //! Reads an amount of bytes from the file. + //! \param buffer: Pointer to buffer of bytes to write. + //! \param sizeToWrite: Amount of bytes to wrtie to the file. + //! \return Returns how much bytes were written. + virtual s32 write(const void* buffer, s32 sizeToWrite) = 0; + + //! Changes position in file, returns true if successful. + //! \param finalPos: Destination position in the file. + //! \param relativeMovement: If set to true, the position in the file is + //! changed relative to current position. Otherwise the position is changed + //! from begin of file. + //! \return Returns true if successful, otherwise false. + virtual bool seek(s32 finalPos, bool relativeMovement = false) = 0; + + //! Returns the current position in the file. + //! \return Returns the current position in the file in bytes. + virtual s32 getPos() = 0; + + //! Returns name of file. + //! \return Returns the file name as zero terminated character string. + virtual const c8* getFileName() = 0; + }; + + //! Internal function, please do not use. + IWriteFile* createWriteFile(const c8* fileName, bool append); + +} // end namespace io +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IXMLReader.h b/src/dep/include/irrlicht/IXMLReader.h index 3d1edf9..8e8acfb 100644 --- a/src/dep/include/irrlicht/IXMLReader.h +++ b/src/dep/include/irrlicht/IXMLReader.h @@ -1,31 +1,31 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_XML_READER_H_INCLUDED__ -#define __I_XML_READER_H_INCLUDED__ - -#include "IUnknown.h" -#include "irrXML.h" - -namespace irr -{ -namespace io -{ - //! A xml reader for wide characters, derived from IUnknown. - //! This XML Parser can read any type of text files from any source where irrlicht - //! can read. Just call IFileSystem::createXMLReader(). - //! For more informations on how to use the parser, see IIrrXMLReader - typedef IIrrXMLReader IXMLReader; - - //! A xml reader for ASCII or UTF-8 characters, derived from IUnknown. - //! This XML Parser can read any type of text files from any source where irrlicht - //! can read. Just call IFileSystem::createXMLReaderUTF8(). - //! For more informations on how to use the parser, see IIrrXMLReader - typedef IIrrXMLReader IXMLReaderUTF8; - -} // end namespace io -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_XML_READER_H_INCLUDED__ +#define __I_XML_READER_H_INCLUDED__ + +#include "IUnknown.h" +#include "irrXML.h" + +namespace irr +{ +namespace io +{ + //! A xml reader for wide characters, derived from IUnknown. + //! This XML Parser can read any type of text files from any source where irrlicht + //! can read. Just call IFileSystem::createXMLReader(). + //! For more informations on how to use the parser, see IIrrXMLReader + typedef IIrrXMLReader IXMLReader; + + //! A xml reader for ASCII or UTF-8 characters, derived from IUnknown. + //! This XML Parser can read any type of text files from any source where irrlicht + //! can read. Just call IFileSystem::createXMLReaderUTF8(). + //! For more informations on how to use the parser, see IIrrXMLReader + typedef IIrrXMLReader IXMLReaderUTF8; + +} // end namespace io +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IXMLWriter.h b/src/dep/include/irrlicht/IXMLWriter.h index 790bf2c..badee99 100644 --- a/src/dep/include/irrlicht/IXMLWriter.h +++ b/src/dep/include/irrlicht/IXMLWriter.h @@ -1,77 +1,77 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_XML_WRITER_H_INCLUDED__ -#define __I_XML_WRITER_H_INCLUDED__ - -#include "IUnknown.h" -#include "irrArray.h" -#include "irrString.h" - -namespace irr -{ -namespace io -{ - - //! Interface providing methods for making it easier to write XML files. - /** This XML Writer only writes UTF-16 xml files, because these are parsed - faster than all other formats by IXMLReader. - */ - class IXMLWriter : public virtual IUnknown - { - public: - - //! Destructor - virtual ~IXMLWriter() {}; - - //! Writes a xml 1.0 header like <?xml version="1.0"?>. This should - //! always be called before writing anything other, because also the - //! text file header for unicode texts is written out with this method. - virtual void writeXMLHeader() = 0; - - //! Writes an xml element with maximal 5 attributes like "" or - //! <foo optAttr="value" />. The element can be empty or not. - //! \param name: Name of the element - //! \param empty: Specifies if the element should be empty. Like "". If - //! You set this to false, something like this is written instead: "". - //! \param attr1Name: 1st attributes name - //! \param attr1Value: 1st attributes value - //! \param attr2Name: 2nd attributes name - //! \param attr2Value: 2nd attributes value - //! \param attr3Name: 3rd attributes name - //! \param attr3Value: 3rd attributes value - //! \param attr4Name: 4th attributes name - //! \param attr4Value: 4th attributes value - //! \param attr5Name: 5th attributes name - //! \param attr5Value: 5th attributes value - virtual void writeElement(const wchar_t* name, bool empty=false, - const wchar_t* attr1Name = 0, const wchar_t* attr1Value = 0, - const wchar_t* attr2Name = 0, const wchar_t* attr2Value = 0, - const wchar_t* attr3Name = 0, const wchar_t* attr3Value = 0, - const wchar_t* attr4Name = 0, const wchar_t* attr4Value = 0, - const wchar_t* attr5Name = 0, const wchar_t* attr5Value = 0) = 0; - - //! Writes an xml element with any number of attributes - virtual void writeElement(const wchar_t* name, bool empty, - core::array &names, core::array &values) = 0; - - //! Writes a comment into the xml file - virtual void writeComment(const wchar_t* comment) = 0; - - //! Writes the closing tag for an element. Like "" - virtual void writeClosingTag(const wchar_t* name) = 0; - - //! Writes a text into the file. All occurrences of special characters like - //! & (&), < (<), > (>), and " (") are automaticly replaced. - virtual void writeText(const wchar_t* text) = 0; - - //! Writes a line break - virtual void writeLineBreak() = 0; - }; - -} // end namespace io -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_XML_WRITER_H_INCLUDED__ +#define __I_XML_WRITER_H_INCLUDED__ + +#include "IUnknown.h" +#include "irrArray.h" +#include "irrString.h" + +namespace irr +{ +namespace io +{ + + //! Interface providing methods for making it easier to write XML files. + /** This XML Writer only writes UTF-16 xml files, because these are parsed + faster than all other formats by IXMLReader. + */ + class IXMLWriter : public virtual IUnknown + { + public: + + //! Destructor + virtual ~IXMLWriter() {}; + + //! Writes a xml 1.0 header like <?xml version="1.0"?>. This should + //! always be called before writing anything other, because also the + //! text file header for unicode texts is written out with this method. + virtual void writeXMLHeader() = 0; + + //! Writes an xml element with maximal 5 attributes like "" or + //! <foo optAttr="value" />. The element can be empty or not. + //! \param name: Name of the element + //! \param empty: Specifies if the element should be empty. Like "". If + //! You set this to false, something like this is written instead: "". + //! \param attr1Name: 1st attributes name + //! \param attr1Value: 1st attributes value + //! \param attr2Name: 2nd attributes name + //! \param attr2Value: 2nd attributes value + //! \param attr3Name: 3rd attributes name + //! \param attr3Value: 3rd attributes value + //! \param attr4Name: 4th attributes name + //! \param attr4Value: 4th attributes value + //! \param attr5Name: 5th attributes name + //! \param attr5Value: 5th attributes value + virtual void writeElement(const wchar_t* name, bool empty=false, + const wchar_t* attr1Name = 0, const wchar_t* attr1Value = 0, + const wchar_t* attr2Name = 0, const wchar_t* attr2Value = 0, + const wchar_t* attr3Name = 0, const wchar_t* attr3Value = 0, + const wchar_t* attr4Name = 0, const wchar_t* attr4Value = 0, + const wchar_t* attr5Name = 0, const wchar_t* attr5Value = 0) = 0; + + //! Writes an xml element with any number of attributes + virtual void writeElement(const wchar_t* name, bool empty, + core::array &names, core::array &values) = 0; + + //! Writes a comment into the xml file + virtual void writeComment(const wchar_t* comment) = 0; + + //! Writes the closing tag for an element. Like "" + virtual void writeClosingTag(const wchar_t* name) = 0; + + //! Writes a text into the file. All occurrences of special characters like + //! & (&), < (<), > (>), and " (") are automaticly replaced. + virtual void writeText(const wchar_t* text) = 0; + + //! Writes a line break + virtual void writeLineBreak() = 0; + }; + +} // end namespace io +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/IrrCompileConfig.h b/src/dep/include/irrlicht/IrrCompileConfig.h index 510faef..d65ff39 100644 --- a/src/dep/include/irrlicht/IrrCompileConfig.h +++ b/src/dep/include/irrlicht/IrrCompileConfig.h @@ -1,207 +1,207 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_COMPILE_CONFIG_H_INCLUDED__ -#define __IRR_COMPILE_CONFIG_H_INCLUDED__ - -//! Irrlicht SDK Version -#define IRRLICHT_SDK_VERSION "1.3" - -//! The defines for different operating system are: -//! _XBOX for XBox -//! WIN32 for Windows32 -//! WIN64 for Windows64 -//! _IRR_WINDOWS_ for all irrlicht supported windows versions -//! OS2 for OS/2 -//! MACOSX for Mac OS X -//! LINUX for linux and unix (it is defined here if no other os is defined) - -#if defined(WIN32) || defined(WIN64) -#define _IRR_WINDOWS_ -#endif - -#if !defined(_IRR_WINDOWS_) && !defined(_XBOX) && !defined(OS2) && !defined(MACOSX) -#define LINUX -#endif - -#if defined(__sparc__) || defined(__sun__) -#define __BIG_ENDIAN__ -#endif - -#include // TODO: Although included elsewhere this is required at least for mingw -//! Define _IRR_COMPILE_WITH_DIRECT3D_8_ and _IRR_COMPILE_WITH_DIRECT3D_9_ to compile -//! the Irrlicht engine with Direct3D8 and/or DIRECT3D9. -/** If you only want to use the software device or opengl this can be useful. -This switch is mostly disabled because people do not get the g++ compiler compile -directX header files, and directX is only available on windows platforms. If you -are using Dev-Cpp, and want to compile this using a DX dev pack, you can define -_IRR_COMPILE_WITH_DX9_DEV_PACK_. So you simply need to add something like this -to the compiler settings: -DIRR_COMPILE_WITH_DX9_DEV_PACK -and this to the linker settings: -ld3dx9 -ld3dx8 **/ -#if (defined(_IRR_WINDOWS_) || defined(_XBOX)) && \ - (!defined(__GNUC__) || defined(IRR_COMPILE_WITH_DX9_DEV_PACK)) - -#define _IRR_COMPILE_WITH_DIRECT3D_8_ -#define _IRR_COMPILE_WITH_DIRECT3D_9_ - -#endif - -//! Define _IRR_COMPILE_WITH_OPENGL_ to compile the Irrlicht engine with OpenGL. -/** If you do not wish the engine to be compiled with OpengGL, comment this -define out. */ -#if !defined(_XBOX) - -#define _IRR_COMPILE_WITH_OPENGL_ - -#endif // ! _XBOX - -//! Define _IRR_COMPILE_WITH_SOFTWARE_ to compile the Irrlicht engine with software driver -/** If you do not need the software driver, or want to use Burning's Video instead, -comment this define out */ -#define _IRR_COMPILE_WITH_SOFTWARE_ - -//! Define _IRR_COMPILE_WITH_BURNINGSVIDEO_ to compile the Irrlicht engine with Burning's video driver -/** If you do not need this software driver, you can comment this define out. */ -#define _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -//! Define _IRR_COMPILE_WITH_X11_ to compile the Irrlicht engine with X11 support. -/** If you do not wish the engine to be compiled with X11, comment this -define out. */ -#if defined(LINUX) - -#define _IRR_COMPILE_WITH_X11_ - -#endif - - -//! Define _IRR_OPENGL_USE_EXTPOINTER_ if the OpenGL renderer should use OpenGL extensions via function pointers. -/** On some systems there is no support for the dynamic extension of OpenGL - via function pointers such that this has to be undef'ed. */ -#if !defined(MACOSX) && !defined(__sun__) -#define _IRR_OPENGL_USE_EXTPOINTER_ -#endif - -//! On some Linux systems the XF86 vidmode extension or X11 RandR are missing. Use these flags -//! to remove the dependencies such that Irrlicht will compile on those systems, too. -#if defined(LINUX) && !defined(__sun__) -#define _IRR_LINUX_X11_VIDMODE_ -//#define _IRR_LINUX_X11_RANDR_ -#endif - - -//! Define _IRR_COMPILE_WITH_ZLIB_ to enable compiling the engine using zlib. -/** This enables the engine to read from compressed .zip archives. If you -disable this feature, the engine can still read archives, but only uncompressed -ones. */ -#define _IRR_COMPILE_WITH_ZLIB_ - -//! Define _IRR_USE_NON_SYSTEM_ZLIB_ to let irrlicht use the zlib which comes with irrlicht. -/** If this is commented out, Irrlicht will try to compile using the zlib installed in the system. - This is only used when _IRR_COMPILE_WITH_ZLIB_ is defined. */ -//#define _IRR_USE_NON_SYSTEM_ZLIB_ - - -//! Define _IRR_COMPILE_WITH_JPEGLIB_ to enable compiling the engine using libjpeg. -/** This enables the engine to read jpeg images. If you comment this out, -the engine will no longer read .jpeg images. */ -#define _IRR_COMPILE_WITH_LIBJPEG_ - -//! Define _IRR_USE_NON_SYSTEM_JPEG_LIB_ to let irrlicht use the jpeglib which comes with irrlicht. -/** If this is commented out, Irrlicht will try to compile using the jpeg lib installed in the system. - This is only used when _IRR_COMPILE_WITH_LIBJPEG_ is defined. */ -#define _IRR_USE_NON_SYSTEM_JPEG_LIB_ - - -//! Define _IRR_COMPILE_WITH_LIBPNG_ to enable compiling the engine using libpng. -/** This enables the engine to read png images. If you comment this out, -the engine will no longer read .png images. */ -#define _IRR_COMPILE_WITH_LIBPNG_ - -//! Define _IRR_USE_NON_SYSTEM_LIBPNG_ to let irrlicht use the libpng which comes with irrlicht. -/** If this is commented out, Irrlicht will try to compile using the libpng installed in the system. - This is only used when _IRR_COMPILE_WITH_LIBPNG_ is defined. */ -#define _IRR_USE_NON_SYSTEM_LIB_PNG_ - - -//! Define _IRR_D3D_NO_SHADER_DEBUGGING to disable shader debugging in D3D9 -/** If _IRR_D3D_NO_SHADER_DEBUGGING is undefined in IrrCompileConfig.h, -it is possible to debug all D3D9 shaders in VisualStudio. All shaders -(which have been generated in memory or read from archives for example) will be emitted -into a temporary file at runtime for this purpose. To debug your shaders, choose -Debug->Direct3D->StartWithDirect3DDebugging in Visual Studio, and for every shader a -file named 'irr_dbg_shader_%%.vsh' or 'irr_dbg_shader_%%.psh' will be created. Drag'n'drop -the file you want to debug into visual studio. That's it. You can now set breakpoints and -watch registers, variables etc. This works with ASM, HLSL, and both with pixel and vertex shaders. -Note that the engine will run in D3D REF for this, which is a lot slower than HAL. */ -#define _IRR_D3D_NO_SHADER_DEBUGGING - -#define _IRR_STATIC_LIB_ - -#ifdef _IRR_WINDOWS_ - -#ifndef _IRR_STATIC_LIB_ -#ifdef IRRLICHT_EXPORTS -#define IRRLICHT_API __declspec(dllexport) -#else -#define IRRLICHT_API __declspec(dllimport) -#endif // IRRLICHT_EXPORT -#else -#define IRRLICHT_API -#endif // _IRR_STATIC_LIB_ - -// Declare the calling convention. -#if defined(_STDCALL_SUPPORTED) -#define IRRCALLCONV __stdcall -#else -#define IRRCALLCONV __cdecl -#endif // STDCALL_SUPPORTED - -#else -#define IRRLICHT_API -#define IRRCALLCONV -#endif // _IRR_WINDOWS_ - -// We need to disable DIRECT3D9 support for Visual Studio 6.0 because -// those $%&$!! disabled support for it since Dec. 2004 and users are complaining -// about linker errors. Comment this out only if you are knowing what you are -// doing. (Which means you have an old DX9 SDK and VisualStudio6). -#ifdef _MSC_VER -#if (_MSC_VER < 1300 && !defined(__GNUC__)) -#undef _IRR_COMPILE_WITH_DIRECT3D_9_ -#pragma message("Compiling Irrlicht with Visual Studio 6.0, support for DX9 is disabled.") -#endif -#endif - -//! Define one of the three setting for Burning's Video Software Rasterizer -/** So if we were marketing guys we could says Irrlicht has 4 Software-Rasterizers. - In a Nutshell: - All Burnings Rasterizers use 32 Bit Backbuffer, 32Bit Texture & 32 Bit Z or WBuffer, - 16 Bit/32 Bit can be adjusted on a global flag. - - BURNINGVIDEO_RENDERER_BEAUTIFUL - 32 Bit + Vertexcolor + Lighting + Per Pixel Perspective Correct + SubPixel/SubTexel Correct + - Bilinear Texturefiltering + WBuffer - - BURNINGVIDEO_RENDERER_FAST - 32 Bit + Per Pixel Perspective Correct + SubPixel/SubTexel Correct + WBuffer + - Bilinear Dithering TextureFilterung + WBuffer - - BURNINGVIDEO_RENDERER_ULTRA_FAST - 16Bit + SubPixel/SubTexel Correct + ZBuffer -*/ - -#define BURNINGVIDEO_RENDERER_BEAUTIFUL -//#define BURNINGVIDEO_RENDERER_FAST -//#define BURNINGVIDEO_RENDERER_ULTRA_FAST - - -//! Set FPU settings -/** Irrlicht should use approximate float and integer fpu techniques -precision will be lower but speed higher. currently X86 only -*/ -#if !defined(MACOSX) && !defined(__sun__) - //#define IRRLICHT_FAST_MATH -#endif - -#endif // __IRR_COMPILE_CONFIG_H_INCLUDED__ +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_COMPILE_CONFIG_H_INCLUDED__ +#define __IRR_COMPILE_CONFIG_H_INCLUDED__ + +//! Irrlicht SDK Version +#define IRRLICHT_SDK_VERSION "1.3" + +//! The defines for different operating system are: +//! _XBOX for XBox +//! WIN32 for Windows32 +//! WIN64 for Windows64 +//! _IRR_WINDOWS_ for all irrlicht supported windows versions +//! OS2 for OS/2 +//! MACOSX for Mac OS X +//! LINUX for linux and unix (it is defined here if no other os is defined) + +#if defined(WIN32) || defined(WIN64) +#define _IRR_WINDOWS_ +#endif + +#if !defined(_IRR_WINDOWS_) && !defined(_XBOX) && !defined(OS2) && !defined(MACOSX) +#define LINUX +#endif + +#if defined(__sparc__) || defined(__sun__) +#define __BIG_ENDIAN__ +#endif + +#include // TODO: Although included elsewhere this is required at least for mingw +//! Define _IRR_COMPILE_WITH_DIRECT3D_8_ and _IRR_COMPILE_WITH_DIRECT3D_9_ to compile +//! the Irrlicht engine with Direct3D8 and/or DIRECT3D9. +/** If you only want to use the software device or opengl this can be useful. +This switch is mostly disabled because people do not get the g++ compiler compile +directX header files, and directX is only available on windows platforms. If you +are using Dev-Cpp, and want to compile this using a DX dev pack, you can define +_IRR_COMPILE_WITH_DX9_DEV_PACK_. So you simply need to add something like this +to the compiler settings: -DIRR_COMPILE_WITH_DX9_DEV_PACK +and this to the linker settings: -ld3dx9 -ld3dx8 **/ +#if (defined(_IRR_WINDOWS_) || defined(_XBOX)) && \ + (!defined(__GNUC__) || defined(IRR_COMPILE_WITH_DX9_DEV_PACK)) + +#define _IRR_COMPILE_WITH_DIRECT3D_8_ +#define _IRR_COMPILE_WITH_DIRECT3D_9_ + +#endif + +//! Define _IRR_COMPILE_WITH_OPENGL_ to compile the Irrlicht engine with OpenGL. +/** If you do not wish the engine to be compiled with OpengGL, comment this +define out. */ +#if !defined(_XBOX) + +#define _IRR_COMPILE_WITH_OPENGL_ + +#endif // ! _XBOX + +//! Define _IRR_COMPILE_WITH_SOFTWARE_ to compile the Irrlicht engine with software driver +/** If you do not need the software driver, or want to use Burning's Video instead, +comment this define out */ +#define _IRR_COMPILE_WITH_SOFTWARE_ + +//! Define _IRR_COMPILE_WITH_BURNINGSVIDEO_ to compile the Irrlicht engine with Burning's video driver +/** If you do not need this software driver, you can comment this define out. */ +#define _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +//! Define _IRR_COMPILE_WITH_X11_ to compile the Irrlicht engine with X11 support. +/** If you do not wish the engine to be compiled with X11, comment this +define out. */ +#if defined(LINUX) + +#define _IRR_COMPILE_WITH_X11_ + +#endif + + +//! Define _IRR_OPENGL_USE_EXTPOINTER_ if the OpenGL renderer should use OpenGL extensions via function pointers. +/** On some systems there is no support for the dynamic extension of OpenGL + via function pointers such that this has to be undef'ed. */ +#if !defined(MACOSX) && !defined(__sun__) +#define _IRR_OPENGL_USE_EXTPOINTER_ +#endif + +//! On some Linux systems the XF86 vidmode extension or X11 RandR are missing. Use these flags +//! to remove the dependencies such that Irrlicht will compile on those systems, too. +#if defined(LINUX) && !defined(__sun__) +#define _IRR_LINUX_X11_VIDMODE_ +//#define _IRR_LINUX_X11_RANDR_ +#endif + + +//! Define _IRR_COMPILE_WITH_ZLIB_ to enable compiling the engine using zlib. +/** This enables the engine to read from compressed .zip archives. If you +disable this feature, the engine can still read archives, but only uncompressed +ones. */ +#define _IRR_COMPILE_WITH_ZLIB_ + +//! Define _IRR_USE_NON_SYSTEM_ZLIB_ to let irrlicht use the zlib which comes with irrlicht. +/** If this is commented out, Irrlicht will try to compile using the zlib installed in the system. + This is only used when _IRR_COMPILE_WITH_ZLIB_ is defined. */ +//#define _IRR_USE_NON_SYSTEM_ZLIB_ + + +//! Define _IRR_COMPILE_WITH_JPEGLIB_ to enable compiling the engine using libjpeg. +/** This enables the engine to read jpeg images. If you comment this out, +the engine will no longer read .jpeg images. */ +#define _IRR_COMPILE_WITH_LIBJPEG_ + +//! Define _IRR_USE_NON_SYSTEM_JPEG_LIB_ to let irrlicht use the jpeglib which comes with irrlicht. +/** If this is commented out, Irrlicht will try to compile using the jpeg lib installed in the system. + This is only used when _IRR_COMPILE_WITH_LIBJPEG_ is defined. */ +#define _IRR_USE_NON_SYSTEM_JPEG_LIB_ + + +//! Define _IRR_COMPILE_WITH_LIBPNG_ to enable compiling the engine using libpng. +/** This enables the engine to read png images. If you comment this out, +the engine will no longer read .png images. */ +#define _IRR_COMPILE_WITH_LIBPNG_ + +//! Define _IRR_USE_NON_SYSTEM_LIBPNG_ to let irrlicht use the libpng which comes with irrlicht. +/** If this is commented out, Irrlicht will try to compile using the libpng installed in the system. + This is only used when _IRR_COMPILE_WITH_LIBPNG_ is defined. */ +#define _IRR_USE_NON_SYSTEM_LIB_PNG_ + + +//! Define _IRR_D3D_NO_SHADER_DEBUGGING to disable shader debugging in D3D9 +/** If _IRR_D3D_NO_SHADER_DEBUGGING is undefined in IrrCompileConfig.h, +it is possible to debug all D3D9 shaders in VisualStudio. All shaders +(which have been generated in memory or read from archives for example) will be emitted +into a temporary file at runtime for this purpose. To debug your shaders, choose +Debug->Direct3D->StartWithDirect3DDebugging in Visual Studio, and for every shader a +file named 'irr_dbg_shader_%%.vsh' or 'irr_dbg_shader_%%.psh' will be created. Drag'n'drop +the file you want to debug into visual studio. That's it. You can now set breakpoints and +watch registers, variables etc. This works with ASM, HLSL, and both with pixel and vertex shaders. +Note that the engine will run in D3D REF for this, which is a lot slower than HAL. */ +#define _IRR_D3D_NO_SHADER_DEBUGGING + +#define _IRR_STATIC_LIB_ + +#ifdef _IRR_WINDOWS_ + +#ifndef _IRR_STATIC_LIB_ +#ifdef IRRLICHT_EXPORTS +#define IRRLICHT_API __declspec(dllexport) +#else +#define IRRLICHT_API __declspec(dllimport) +#endif // IRRLICHT_EXPORT +#else +#define IRRLICHT_API +#endif // _IRR_STATIC_LIB_ + +// Declare the calling convention. +#if defined(_STDCALL_SUPPORTED) +#define IRRCALLCONV __stdcall +#else +#define IRRCALLCONV __cdecl +#endif // STDCALL_SUPPORTED + +#else +#define IRRLICHT_API +#define IRRCALLCONV +#endif // _IRR_WINDOWS_ + +// We need to disable DIRECT3D9 support for Visual Studio 6.0 because +// those $%&$!! disabled support for it since Dec. 2004 and users are complaining +// about linker errors. Comment this out only if you are knowing what you are +// doing. (Which means you have an old DX9 SDK and VisualStudio6). +#ifdef _MSC_VER +#if (_MSC_VER < 1300 && !defined(__GNUC__)) +#undef _IRR_COMPILE_WITH_DIRECT3D_9_ +#pragma message("Compiling Irrlicht with Visual Studio 6.0, support for DX9 is disabled.") +#endif +#endif + +//! Define one of the three setting for Burning's Video Software Rasterizer +/** So if we were marketing guys we could says Irrlicht has 4 Software-Rasterizers. + In a Nutshell: + All Burnings Rasterizers use 32 Bit Backbuffer, 32Bit Texture & 32 Bit Z or WBuffer, + 16 Bit/32 Bit can be adjusted on a global flag. + + BURNINGVIDEO_RENDERER_BEAUTIFUL + 32 Bit + Vertexcolor + Lighting + Per Pixel Perspective Correct + SubPixel/SubTexel Correct + + Bilinear Texturefiltering + WBuffer + + BURNINGVIDEO_RENDERER_FAST + 32 Bit + Per Pixel Perspective Correct + SubPixel/SubTexel Correct + WBuffer + + Bilinear Dithering TextureFilterung + WBuffer + + BURNINGVIDEO_RENDERER_ULTRA_FAST + 16Bit + SubPixel/SubTexel Correct + ZBuffer +*/ + +#define BURNINGVIDEO_RENDERER_BEAUTIFUL +//#define BURNINGVIDEO_RENDERER_FAST +//#define BURNINGVIDEO_RENDERER_ULTRA_FAST + + +//! Set FPU settings +/** Irrlicht should use approximate float and integer fpu techniques +precision will be lower but speed higher. currently X86 only +*/ +#if !defined(MACOSX) && !defined(__sun__) + //#define IRRLICHT_FAST_MATH +#endif + +#endif // __IRR_COMPILE_CONFIG_H_INCLUDED__ diff --git a/src/dep/include/irrlicht/IrrlichtDevice.h b/src/dep/include/irrlicht/IrrlichtDevice.h index 4f737fe..742c4c3 100644 --- a/src/dep/include/irrlicht/IrrlichtDevice.h +++ b/src/dep/include/irrlicht/IrrlichtDevice.h @@ -1,169 +1,169 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_IRRLICHT_DEVICE_H_INCLUDED__ -#define __I_IRRLICHT_DEVICE_H_INCLUDED__ - -#include "irrTypes.h" -#include "IUnknown.h" -#include "dimension2d.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "EDriverTypes.h" -#include "IGUIEnvironment.h" -#include "IEventReceiver.h" -#include "ISceneManager.h" -#include "ICursorControl.h" -#include "IVideoModeList.h" -#include "ITimer.h" -#include "ILogger.h" -#include "IOSOperator.h" - -namespace irr -{ - //! The Irrlicht device. You can create it with createDevice() or createDeviceEx(). - /** This is the most important class of the Irrlicht Engine. You can access everything - in the engine if you have a pointer to an instance of this class. - */ - class IrrlichtDevice : public virtual IUnknown - { - public: - - //! destructor - virtual ~IrrlichtDevice() {}; - - //! Runs the device. - /** Also increments the virtual timer by calling ITimer::tick();. You can prevent this - by calling ITimer::stop(); before and ITimer::start() after calling IrrlichtDevice::run(). - Returns false if device wants to be deleted. Use it in this way: - \code -while(device->run()) -{ - // draw everything here -} - \endcode - If you want the device to do nothing if the window is inactive (recommended), - use this slightly enhanced code instead: - \code -while(device->run()) - if (device->isWindowActive()) - { - // draw everything here - } - \endcode - Note if you are running Irrlicht inside an external, custom created window: - Calling Device->run() will cause Irrlicht to dispatch windows messages internally. - If you are running Irrlicht in your own, custom window, you - you can also simply use your own message loop - using GetMessage, DispatchMessage and whatever and simply don't use this method. - But note that Irrlicht will not be able to fetch user input then. See - irr::SIrrlichtCreationParameters::WindowId for more informations and example code. - */ - virtual bool run() = 0; - - //! Cause the device to temporarily pause execution and let other processes to run - // This should bring down processor usage without major performance loss for Irrlicht - virtual void yield() = 0; - - //! Pause execution and let other processes to run for a specified amount of time. - /** It may not wait the full given time, as sleep may be interrupted - \param timeMs: Time to sleep for in milisecs. - \param pauseTimer: If true, pauses the device timer while sleeping - */ - virtual void sleep(u32 timeMs, bool pauseTimer=false) = 0; - - //! Provides access to the video driver for drawing 3d and 2d geometry. - /** \return Returns a pointer the video driver. */ - virtual video::IVideoDriver* getVideoDriver() = 0; - - //! Provides access to the virtual file system. - /** \return Returns a pointer to the file system. */ - virtual io::IFileSystem* getFileSystem() = 0; - - //! Provides access to the 2d user interface environment. - /** \return Returns a pointer to the gui environment. */ - virtual gui::IGUIEnvironment* getGUIEnvironment() = 0; - - //! \return Returns a pointer to the scene manager. - virtual scene::ISceneManager* getSceneManager() = 0; - - //! Provides access to the cursor control. - /** \return Returns a pointer to the mouse cursor control interface. */ - virtual gui::ICursorControl* getCursorControl() = 0; - - //! Provides access to the logger. - /** \return Returns a pointer to the logger. */ - virtual ILogger* getLogger() = 0; - - //! Gets a list with all video modes available. - /** If you are confused - now, because you think you have to create an Irrlicht Device with a video - mode before being able to get the video mode list, let me tell you that - there is no need to start up an Irrlicht Device with EDT_DIRECT3D8, EDT_OPENGL or - EDT_SOFTWARE: For this (and for lots of other reasons) the null device, - EDT_NULL exists. - \return Returns a pointer to a list with all video modes supported - by the gfx adapter. */ - virtual video::IVideoModeList* getVideoModeList() = 0; - - //! Returns the operation system opertator object. - /** It provides methods for - getting operation system specific informations and doing operation system - specific operations. Like for example exchanging data with the clipboard - or reading the operation system version. */ - virtual IOSOperator* getOSOperator() = 0; - - //! Returns pointer to the timer. - /** \return Returns a pointer to the ITimer object. The system time can be retrieved by it as - well as the virtual time, which also can be manipulated. */ - virtual ITimer* getTimer() = 0; - - //! Sets the caption of the window. - /** \param text: New text of the window caption. */ - virtual void setWindowCaption(const wchar_t* text) = 0; - - //! Returns if the window is active. - /** \return Returns true if window is active. If the window is inactive, - nothing need to be drawn. So if you don't want to draw anything when - the window is inactive, create your drawing loop this way: - \code -while(device->run()) - if (device->isWindowActive()) - { - // draw everything here - } - \endcode */ - virtual bool isWindowActive() = 0; - - //! Notifies the device that it should close itself. - /** IrrlichtDevice::run() will always return false after closeDevice() was called. */ - virtual void closeDevice() = 0; - - //! Returns the version of the engine. - /** The returned string - will look like this: "1.2.3" or this: "1.2". */ - virtual const c8* getVersion() = 0; - - //! Sets a new event receiver to receive events. - virtual void setEventReceiver(IEventReceiver* receiver) = 0; - - //! Returns poinhter to the current event receiver. Returns 0 if there is none. - virtual IEventReceiver* getEventReceiver() = 0; - - //! Sends a user created event to the engine. - /** Is is usually not necessary to use this. However, if you are using an own - input library for example for doing joystick input, you can use this to post key or mouse input - events to the engine. Internally, this method only delegates the events further to the - scene manager and the GUI environment. */ - virtual void postEventFromUser(SEvent event) = 0; - - //! Sets if the window should be resizeable in windowed mode. - /** The default is false. This method only works in windowed mode. */ - virtual void setResizeAble(bool resize=false) = 0; - }; - -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_IRRLICHT_DEVICE_H_INCLUDED__ +#define __I_IRRLICHT_DEVICE_H_INCLUDED__ + +#include "irrTypes.h" +#include "IUnknown.h" +#include "dimension2d.h" +#include "IFileSystem.h" +#include "IVideoDriver.h" +#include "EDriverTypes.h" +#include "IGUIEnvironment.h" +#include "IEventReceiver.h" +#include "ISceneManager.h" +#include "ICursorControl.h" +#include "IVideoModeList.h" +#include "ITimer.h" +#include "ILogger.h" +#include "IOSOperator.h" + +namespace irr +{ + //! The Irrlicht device. You can create it with createDevice() or createDeviceEx(). + /** This is the most important class of the Irrlicht Engine. You can access everything + in the engine if you have a pointer to an instance of this class. + */ + class IrrlichtDevice : public virtual IUnknown + { + public: + + //! destructor + virtual ~IrrlichtDevice() {}; + + //! Runs the device. + /** Also increments the virtual timer by calling ITimer::tick();. You can prevent this + by calling ITimer::stop(); before and ITimer::start() after calling IrrlichtDevice::run(). + Returns false if device wants to be deleted. Use it in this way: + \code +while(device->run()) +{ + // draw everything here +} + \endcode + If you want the device to do nothing if the window is inactive (recommended), + use this slightly enhanced code instead: + \code +while(device->run()) + if (device->isWindowActive()) + { + // draw everything here + } + \endcode + Note if you are running Irrlicht inside an external, custom created window: + Calling Device->run() will cause Irrlicht to dispatch windows messages internally. + If you are running Irrlicht in your own, custom window, you + you can also simply use your own message loop + using GetMessage, DispatchMessage and whatever and simply don't use this method. + But note that Irrlicht will not be able to fetch user input then. See + irr::SIrrlichtCreationParameters::WindowId for more informations and example code. + */ + virtual bool run() = 0; + + //! Cause the device to temporarily pause execution and let other processes to run + // This should bring down processor usage without major performance loss for Irrlicht + virtual void yield() = 0; + + //! Pause execution and let other processes to run for a specified amount of time. + /** It may not wait the full given time, as sleep may be interrupted + \param timeMs: Time to sleep for in milisecs. + \param pauseTimer: If true, pauses the device timer while sleeping + */ + virtual void sleep(u32 timeMs, bool pauseTimer=false) = 0; + + //! Provides access to the video driver for drawing 3d and 2d geometry. + /** \return Returns a pointer the video driver. */ + virtual video::IVideoDriver* getVideoDriver() = 0; + + //! Provides access to the virtual file system. + /** \return Returns a pointer to the file system. */ + virtual io::IFileSystem* getFileSystem() = 0; + + //! Provides access to the 2d user interface environment. + /** \return Returns a pointer to the gui environment. */ + virtual gui::IGUIEnvironment* getGUIEnvironment() = 0; + + //! \return Returns a pointer to the scene manager. + virtual scene::ISceneManager* getSceneManager() = 0; + + //! Provides access to the cursor control. + /** \return Returns a pointer to the mouse cursor control interface. */ + virtual gui::ICursorControl* getCursorControl() = 0; + + //! Provides access to the logger. + /** \return Returns a pointer to the logger. */ + virtual ILogger* getLogger() = 0; + + //! Gets a list with all video modes available. + /** If you are confused + now, because you think you have to create an Irrlicht Device with a video + mode before being able to get the video mode list, let me tell you that + there is no need to start up an Irrlicht Device with EDT_DIRECT3D8, EDT_OPENGL or + EDT_SOFTWARE: For this (and for lots of other reasons) the null device, + EDT_NULL exists. + \return Returns a pointer to a list with all video modes supported + by the gfx adapter. */ + virtual video::IVideoModeList* getVideoModeList() = 0; + + //! Returns the operation system opertator object. + /** It provides methods for + getting operation system specific informations and doing operation system + specific operations. Like for example exchanging data with the clipboard + or reading the operation system version. */ + virtual IOSOperator* getOSOperator() = 0; + + //! Returns pointer to the timer. + /** \return Returns a pointer to the ITimer object. The system time can be retrieved by it as + well as the virtual time, which also can be manipulated. */ + virtual ITimer* getTimer() = 0; + + //! Sets the caption of the window. + /** \param text: New text of the window caption. */ + virtual void setWindowCaption(const wchar_t* text) = 0; + + //! Returns if the window is active. + /** \return Returns true if window is active. If the window is inactive, + nothing need to be drawn. So if you don't want to draw anything when + the window is inactive, create your drawing loop this way: + \code +while(device->run()) + if (device->isWindowActive()) + { + // draw everything here + } + \endcode */ + virtual bool isWindowActive() = 0; + + //! Notifies the device that it should close itself. + /** IrrlichtDevice::run() will always return false after closeDevice() was called. */ + virtual void closeDevice() = 0; + + //! Returns the version of the engine. + /** The returned string + will look like this: "1.2.3" or this: "1.2". */ + virtual const c8* getVersion() = 0; + + //! Sets a new event receiver to receive events. + virtual void setEventReceiver(IEventReceiver* receiver) = 0; + + //! Returns poinhter to the current event receiver. Returns 0 if there is none. + virtual IEventReceiver* getEventReceiver() = 0; + + //! Sends a user created event to the engine. + /** Is is usually not necessary to use this. However, if you are using an own + input library for example for doing joystick input, you can use this to post key or mouse input + events to the engine. Internally, this method only delegates the events further to the + scene manager and the GUI environment. */ + virtual void postEventFromUser(SEvent event) = 0; + + //! Sets if the window should be resizeable in windowed mode. + /** The default is false. This method only works in windowed mode. */ + virtual void setResizeAble(bool resize=false) = 0; + }; + +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/Keycodes.h b/src/dep/include/irrlicht/Keycodes.h index c35124c..74f862d 100644 --- a/src/dep/include/irrlicht/Keycodes.h +++ b/src/dep/include/irrlicht/Keycodes.h @@ -1,163 +1,163 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_KEY_CODES_H_INCLUDED__ -#define __IRR_KEY_CODES_H_INCLUDED__ - -namespace irr -{ - - enum EKEY_CODE - { - KEY_LBUTTON = 0x01, // Left mouse button - KEY_RBUTTON = 0x02, // Right mouse button - KEY_CANCEL = 0x03, // Control-break processing - KEY_MBUTTON = 0x04, // Middle mouse button (three-button mouse) - KEY_XBUTTON1 = 0x05, // Windows 2000/XP: X1 mouse button - KEY_XBUTTON2 = 0x06, // Windows 2000/XP: X2 mouse button - KEY_BACK = 0x08, // BACKSPACE key - KEY_TAB = 0x09, // TAB key - KEY_CLEAR = 0x0C, // CLEAR key - KEY_RETURN = 0x0D, // ENTER key - KEY_SHIFT = 0x10, // SHIFT key - KEY_CONTROL = 0x11, // CTRL key - KEY_MENU = 0x12, // ALT key - KEY_PAUSE = 0x13, // PAUSE key - KEY_CAPITAL = 0x14, // CAPS LOCK key - KEY_KANA = 0x15, // IME Kana mode - KEY_HANGUEL = 0x15, // IME Hanguel mode (maintained for compatibility use KEY_HANGUL) - KEY_HANGUL = 0x15, // IME Hangul mode - KEY_JUNJA = 0x17, // IME Junja mode - KEY_FINAL = 0x18, // IME final mode - KEY_HANJA = 0x19, // IME Hanja mode - KEY_KANJI = 0x19, // IME Kanji mode - KEY_ESCAPE = 0x1B, // ESC key - KEY_CONVERT = 0x1C, // IME convert - KEY_NONCONVERT = 0x1D, // IME nonconvert - KEY_ACCEPT = 0x1E, // IME accept - KEY_MODECHANGE = 0x1F, // IME mode change request - KEY_SPACE = 0x20, // SPACEBAR - KEY_PRIOR = 0x21, // PAGE UP key - KEY_NEXT = 0x22, // PAGE DOWN key - KEY_END = 0x23, // END key - KEY_HOME = 0x24, // HOME key - KEY_LEFT = 0x25, // LEFT ARROW key - KEY_UP = 0x26, // UP ARROW key - KEY_RIGHT = 0x27, // RIGHT ARROW key - KEY_DOWN = 0x28, // DOWN ARROW key - KEY_SELECT = 0x29, // SELECT key - KEY_PRINT = 0x2A, // PRINT key - KEY_EXECUT = 0x2B, // EXECUTE key - KEY_SNAPSHOT = 0x2C, // PRINT SCREEN key - KEY_INSERT = 0x2D, // INS key - KEY_DELETE = 0x2E, // DEL key - KEY_HELP = 0x2F, // HELP key - KEY_KEY_0 = 0x30, // 0 key - KEY_KEY_1 = 0x31, // 1 key - KEY_KEY_2 = 0x32, // 2 key - KEY_KEY_3 = 0x33, // 3 key - KEY_KEY_4 = 0x34, // 4 key - KEY_KEY_5 = 0x35, // 5 key - KEY_KEY_6 = 0x36, // 6 key - KEY_KEY_7 = 0x37, // 7 key - KEY_KEY_8 = 0x38, // 8 key - KEY_KEY_9 = 0x39, // 9 key - KEY_KEY_A = 0x41, // A key - KEY_KEY_B = 0x42, // B key - KEY_KEY_C = 0x43, // C key - KEY_KEY_D = 0x44, // D key - KEY_KEY_E = 0x45, // E key - KEY_KEY_F = 0x46, // F key - KEY_KEY_G = 0x47, // G key - KEY_KEY_H = 0x48, // H key - KEY_KEY_I = 0x49, // I key - KEY_KEY_J = 0x4A, // J key - KEY_KEY_K = 0x4B, // K key - KEY_KEY_L = 0x4C, // L key - KEY_KEY_M = 0x4D, // M key - KEY_KEY_N = 0x4E, // N key - KEY_KEY_O = 0x4F, // O key - KEY_KEY_P = 0x50, // P key - KEY_KEY_Q = 0x51, // Q key - KEY_KEY_R = 0x52, // R key - KEY_KEY_S = 0x53, // S key - KEY_KEY_T = 0x54, // T key - KEY_KEY_U = 0x55, // U key - KEY_KEY_V = 0x56, // V key - KEY_KEY_W = 0x57, // W key - KEY_KEY_X = 0x58, // X key - KEY_KEY_Y = 0x59, // Y key - KEY_KEY_Z = 0x5A, // Z key - KEY_LWIN = 0x5B, // Left Windows key (Microsoft® Natural® keyboard) - KEY_RWIN = 0x5C, // Right Windows key (Natural keyboard) - KEY_APPS = 0x5D, //Applications key (Natural keyboard) - KEY_SLEEP = 0x5F, // Computer Sleep key - KEY_NUMPAD0 = 0x60, // Numeric keypad 0 key - KEY_NUMPAD1 = 0x61, // Numeric keypad 1 key - KEY_NUMPAD2 = 0x62, // Numeric keypad 2 key - KEY_NUMPAD3 = 0x63, // Numeric keypad 3 key - KEY_NUMPAD4 = 0x64, // Numeric keypad 4 key - KEY_NUMPAD5 = 0x65, // Numeric keypad 5 key - KEY_NUMPAD6 = 0x66, // Numeric keypad 6 key - KEY_NUMPAD7 = 0x67, // Numeric keypad 7 key - KEY_NUMPAD8 = 0x68, // Numeric keypad 8 key - KEY_NUMPAD9 = 0x69, // Numeric keypad 9 key - KEY_MULTIPLY = 0x6A, // Multiply key - KEY_ADD = 0x6B, // Add key - KEY_SEPARATOR = 0x6C, // Separator key - KEY_SUBTRACT = 0x6D, // Subtract key - KEY_DECIMAL = 0x6E, // Decimal key - KEY_DIVIDE = 0x6F, // Divide key - KEY_F1 = 0x70, // F1 key - KEY_F2 = 0x71, // F2 key - KEY_F3 = 0x72, // F3 key - KEY_F4 = 0x73, // F4 key - KEY_F5 = 0x74, // F5 key - KEY_F6 = 0x75, // F6 key - KEY_F7 = 0x76, // F7 key - KEY_F8 = 0x77, // F8 key - KEY_F9 = 0x78, // F9 key - KEY_F10 = 0x79, // F10 key - KEY_F11 = 0x7A, // F11 key - KEY_F12 = 0x7B, // F12 key - KEY_F13 = 0x7C, // F13 key - KEY_F14 = 0x7D, // F14 key - KEY_F15 = 0x7E, // F15 key - KEY_F16 = 0x7F, // F16 key - KEY_F17 = 0x80, // F17 key - KEY_F18 = 0x81, // F18 key - KEY_F19 = 0x82, // F19 key - KEY_F20 = 0x83, // F20 key - KEY_F21 = 0x84, // F21 key - KEY_F22 = 0x85, // F22 key - KEY_F23 = 0x86, // F23 key - KEY_F24 = 0x87, // F24 key - KEY_NUMLOCK = 0x90, // NUM LOCK key - KEY_SCROLL = 0x91, // SCROLL LOCK key - KEY_LSHIFT = 0xA0, // Left SHIFT key - KEY_RSHIFT = 0xA1, // Right SHIFT key - KEY_LCONTROL = 0xA2, // Left CONTROL key - KEY_RCONTROL = 0xA3, // Right CONTROL key - KEY_LMENU = 0xA4, // Left MENU key - KEY_RMENU = 0xA5, // Right MENU key - KEY_PLUS = 0xBB, // Plus Key (+) - KEY_COMMA = 0xBC, // Comma Key (,) - KEY_MINUS = 0xBD, // Minus Key (-) - KEY_PERIOD = 0xBE, // Period Key (.) - KEY_ATTN = 0xF6, // Attn key - KEY_CRSEL = 0xF7, // CrSel key - KEY_EXSEL = 0xF8, // ExSel key - KEY_EREOF = 0xF9, // Erase EOF key - KEY_PLAY = 0xFA, // Play key - KEY_ZOOM = 0xFB, // Zoom key - KEY_PA1 = 0xFD, // PA1 key - KEY_OEM_CLEAR = 0xFE, // Clear key - - KEY_KEY_CODES_COUNT = 0xFF // this is not a key, but the amount of keycodes there are. - }; - -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_KEY_CODES_H_INCLUDED__ +#define __IRR_KEY_CODES_H_INCLUDED__ + +namespace irr +{ + + enum EKEY_CODE + { + KEY_LBUTTON = 0x01, // Left mouse button + KEY_RBUTTON = 0x02, // Right mouse button + KEY_CANCEL = 0x03, // Control-break processing + KEY_MBUTTON = 0x04, // Middle mouse button (three-button mouse) + KEY_XBUTTON1 = 0x05, // Windows 2000/XP: X1 mouse button + KEY_XBUTTON2 = 0x06, // Windows 2000/XP: X2 mouse button + KEY_BACK = 0x08, // BACKSPACE key + KEY_TAB = 0x09, // TAB key + KEY_CLEAR = 0x0C, // CLEAR key + KEY_RETURN = 0x0D, // ENTER key + KEY_SHIFT = 0x10, // SHIFT key + KEY_CONTROL = 0x11, // CTRL key + KEY_MENU = 0x12, // ALT key + KEY_PAUSE = 0x13, // PAUSE key + KEY_CAPITAL = 0x14, // CAPS LOCK key + KEY_KANA = 0x15, // IME Kana mode + KEY_HANGUEL = 0x15, // IME Hanguel mode (maintained for compatibility use KEY_HANGUL) + KEY_HANGUL = 0x15, // IME Hangul mode + KEY_JUNJA = 0x17, // IME Junja mode + KEY_FINAL = 0x18, // IME final mode + KEY_HANJA = 0x19, // IME Hanja mode + KEY_KANJI = 0x19, // IME Kanji mode + KEY_ESCAPE = 0x1B, // ESC key + KEY_CONVERT = 0x1C, // IME convert + KEY_NONCONVERT = 0x1D, // IME nonconvert + KEY_ACCEPT = 0x1E, // IME accept + KEY_MODECHANGE = 0x1F, // IME mode change request + KEY_SPACE = 0x20, // SPACEBAR + KEY_PRIOR = 0x21, // PAGE UP key + KEY_NEXT = 0x22, // PAGE DOWN key + KEY_END = 0x23, // END key + KEY_HOME = 0x24, // HOME key + KEY_LEFT = 0x25, // LEFT ARROW key + KEY_UP = 0x26, // UP ARROW key + KEY_RIGHT = 0x27, // RIGHT ARROW key + KEY_DOWN = 0x28, // DOWN ARROW key + KEY_SELECT = 0x29, // SELECT key + KEY_PRINT = 0x2A, // PRINT key + KEY_EXECUT = 0x2B, // EXECUTE key + KEY_SNAPSHOT = 0x2C, // PRINT SCREEN key + KEY_INSERT = 0x2D, // INS key + KEY_DELETE = 0x2E, // DEL key + KEY_HELP = 0x2F, // HELP key + KEY_KEY_0 = 0x30, // 0 key + KEY_KEY_1 = 0x31, // 1 key + KEY_KEY_2 = 0x32, // 2 key + KEY_KEY_3 = 0x33, // 3 key + KEY_KEY_4 = 0x34, // 4 key + KEY_KEY_5 = 0x35, // 5 key + KEY_KEY_6 = 0x36, // 6 key + KEY_KEY_7 = 0x37, // 7 key + KEY_KEY_8 = 0x38, // 8 key + KEY_KEY_9 = 0x39, // 9 key + KEY_KEY_A = 0x41, // A key + KEY_KEY_B = 0x42, // B key + KEY_KEY_C = 0x43, // C key + KEY_KEY_D = 0x44, // D key + KEY_KEY_E = 0x45, // E key + KEY_KEY_F = 0x46, // F key + KEY_KEY_G = 0x47, // G key + KEY_KEY_H = 0x48, // H key + KEY_KEY_I = 0x49, // I key + KEY_KEY_J = 0x4A, // J key + KEY_KEY_K = 0x4B, // K key + KEY_KEY_L = 0x4C, // L key + KEY_KEY_M = 0x4D, // M key + KEY_KEY_N = 0x4E, // N key + KEY_KEY_O = 0x4F, // O key + KEY_KEY_P = 0x50, // P key + KEY_KEY_Q = 0x51, // Q key + KEY_KEY_R = 0x52, // R key + KEY_KEY_S = 0x53, // S key + KEY_KEY_T = 0x54, // T key + KEY_KEY_U = 0x55, // U key + KEY_KEY_V = 0x56, // V key + KEY_KEY_W = 0x57, // W key + KEY_KEY_X = 0x58, // X key + KEY_KEY_Y = 0x59, // Y key + KEY_KEY_Z = 0x5A, // Z key + KEY_LWIN = 0x5B, // Left Windows key (Microsoft® Natural® keyboard) + KEY_RWIN = 0x5C, // Right Windows key (Natural keyboard) + KEY_APPS = 0x5D, //Applications key (Natural keyboard) + KEY_SLEEP = 0x5F, // Computer Sleep key + KEY_NUMPAD0 = 0x60, // Numeric keypad 0 key + KEY_NUMPAD1 = 0x61, // Numeric keypad 1 key + KEY_NUMPAD2 = 0x62, // Numeric keypad 2 key + KEY_NUMPAD3 = 0x63, // Numeric keypad 3 key + KEY_NUMPAD4 = 0x64, // Numeric keypad 4 key + KEY_NUMPAD5 = 0x65, // Numeric keypad 5 key + KEY_NUMPAD6 = 0x66, // Numeric keypad 6 key + KEY_NUMPAD7 = 0x67, // Numeric keypad 7 key + KEY_NUMPAD8 = 0x68, // Numeric keypad 8 key + KEY_NUMPAD9 = 0x69, // Numeric keypad 9 key + KEY_MULTIPLY = 0x6A, // Multiply key + KEY_ADD = 0x6B, // Add key + KEY_SEPARATOR = 0x6C, // Separator key + KEY_SUBTRACT = 0x6D, // Subtract key + KEY_DECIMAL = 0x6E, // Decimal key + KEY_DIVIDE = 0x6F, // Divide key + KEY_F1 = 0x70, // F1 key + KEY_F2 = 0x71, // F2 key + KEY_F3 = 0x72, // F3 key + KEY_F4 = 0x73, // F4 key + KEY_F5 = 0x74, // F5 key + KEY_F6 = 0x75, // F6 key + KEY_F7 = 0x76, // F7 key + KEY_F8 = 0x77, // F8 key + KEY_F9 = 0x78, // F9 key + KEY_F10 = 0x79, // F10 key + KEY_F11 = 0x7A, // F11 key + KEY_F12 = 0x7B, // F12 key + KEY_F13 = 0x7C, // F13 key + KEY_F14 = 0x7D, // F14 key + KEY_F15 = 0x7E, // F15 key + KEY_F16 = 0x7F, // F16 key + KEY_F17 = 0x80, // F17 key + KEY_F18 = 0x81, // F18 key + KEY_F19 = 0x82, // F19 key + KEY_F20 = 0x83, // F20 key + KEY_F21 = 0x84, // F21 key + KEY_F22 = 0x85, // F22 key + KEY_F23 = 0x86, // F23 key + KEY_F24 = 0x87, // F24 key + KEY_NUMLOCK = 0x90, // NUM LOCK key + KEY_SCROLL = 0x91, // SCROLL LOCK key + KEY_LSHIFT = 0xA0, // Left SHIFT key + KEY_RSHIFT = 0xA1, // Right SHIFT key + KEY_LCONTROL = 0xA2, // Left CONTROL key + KEY_RCONTROL = 0xA3, // Right CONTROL key + KEY_LMENU = 0xA4, // Left MENU key + KEY_RMENU = 0xA5, // Right MENU key + KEY_PLUS = 0xBB, // Plus Key (+) + KEY_COMMA = 0xBC, // Comma Key (,) + KEY_MINUS = 0xBD, // Minus Key (-) + KEY_PERIOD = 0xBE, // Period Key (.) + KEY_ATTN = 0xF6, // Attn key + KEY_CRSEL = 0xF7, // CrSel key + KEY_EXSEL = 0xF8, // ExSel key + KEY_EREOF = 0xF9, // Erase EOF key + KEY_PLAY = 0xFA, // Play key + KEY_ZOOM = 0xFB, // Zoom key + KEY_PA1 = 0xFD, // PA1 key + KEY_OEM_CLEAR = 0xFE, // Clear key + + KEY_KEY_CODES_COUNT = 0xFF // this is not a key, but the amount of keycodes there are. + }; + +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/S3DVertex.h b/src/dep/include/irrlicht/S3DVertex.h index d9623a8..ccee43a 100644 --- a/src/dep/include/irrlicht/S3DVertex.h +++ b/src/dep/include/irrlicht/S3DVertex.h @@ -1,193 +1,193 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_3D_VERTEX_H_INCLUDED__ -#define __S_3D_VERTEX_H_INCLUDED__ - -#include "vector3d.h" -#include "vector2d.h" -#include "SColor.h" - -namespace irr -{ -namespace video -{ - -//! Enumeration for all vertex types there are. -enum E_VERTEX_TYPE -{ - //! Standard vertex type used by the Irrlicht engine, video::S3DVertex. - EVT_STANDARD = 0, - - //! Vertex with two texture coordinates, video::S3DVertex2TCoords. Usually used - //! for geometry with lightmaps or other special materials. - EVT_2TCOORDS, - - //! Vertex with a tangent and binormal vector, video::S3DVertexTangents. Usually - //! used for tangent space normal mapping. - EVT_TANGENTS -}; - -//! standard vertex used by the Irrlicht engine. -struct S3DVertex -{ - //! default constructor - S3DVertex() {}; - - //! constructor - S3DVertex(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv) - : Pos(x,y,z), Normal(nx,ny,nz), Color(c), TCoords(tu,tv) {} - - //! constructor - S3DVertex(const core::vector3df& pos, const core::vector3df& normal, - SColor color, const core::vector2d& tcoords) - : Pos(pos), Normal(normal), Color(color), TCoords(tcoords) {} - - //! Position - core::vector3df Pos; - - //! Normal vector - core::vector3df Normal; - - //! Color - SColor Color; - - //! Texture coordinates - core::vector2d TCoords; - - bool operator == (const S3DVertex& other) const - { - return (Pos == other.Pos && Normal == other.Normal && - Color == other.Color && TCoords == other.TCoords); - } - - bool operator != (const S3DVertex& other) const - { - return (Pos != other.Pos || Normal != other.Normal || - Color != other.Color || TCoords != other.TCoords); - } -}; - - -//! Vertex with two texture coordinates. -/** Usually used for geometry with lightmaps -or other special materials. -*/ -struct S3DVertex2TCoords -{ - //! default constructor - S3DVertex2TCoords() {}; - - //! constructor with two different texture coords - S3DVertex2TCoords(f32 x, f32 y, f32 z, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2) - : Pos(x,y,z), Color(c), TCoords(tu,tv), TCoords2(tu2,tv2) {} - - //! constructor with two different texture coords - S3DVertex2TCoords(const core::vector3df& pos, SColor color, - const core::vector2d& tcoords, const core::vector2d& tcoords2) - : Pos(pos), Color(color), TCoords(tcoords), TCoords2(tcoords2) {} - - //! constructor - S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal, const SColor& color, - const core::vector2d& tcoords, const core::vector2d& tcoords2) - : Pos(pos), Normal(normal), Color(color), TCoords(tcoords), TCoords2(tcoords2) {} - - //! constructor with the same texture coords and normal - S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv) - : Pos(x,y,z), Normal(nx,ny,nz), Color(c), TCoords(tu,tv), TCoords2(tu,tv) {} - - //! constructor with the same texture coords and normal - S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal, - SColor color, const core::vector2d& tcoords) - : Pos(pos), Normal(normal), Color(color), TCoords(tcoords), TCoords2(tcoords) {} - - //! Position - core::vector3df Pos; - - //! Normal - core::vector3df Normal; - - //! Color - SColor Color; - - //! First set of texture coordinates - core::vector2d TCoords; - - //! Second set of texture coordinates - core::vector2d TCoords2; - - bool operator == (const S3DVertex2TCoords& other) const - { - return (Pos == other.Pos && Normal == other.Normal && - Color == other.Color && TCoords == other.TCoords && - TCoords2 == other.TCoords2); - } - - bool operator != (const S3DVertex2TCoords& other) const - { - return (Pos != other.Pos || Normal != other.Normal || - Color != other.Color || TCoords != other.TCoords || - TCoords2 != other.TCoords2); - } - -}; - - -//! Vertex with a tangent and binormal vector. -/** Usually used for tangent space normal mapping. -*/ -struct S3DVertexTangents -{ - //! default constructor - S3DVertexTangents() { }; - - //! constructor - S3DVertexTangents(f32 x, f32 y, f32 z) - : Pos(x,y,z) { } - - //! constructor - S3DVertexTangents(const core::vector3df& pos, - const core::vector2df& tcoords, SColor c) - : Pos(pos), Color(c), TCoords(tcoords) { } - - //! Position - core::vector3df Pos; - - //! Normal vector - core::vector3df Normal; - - //! Color - SColor Color; - - //! Texture coordinates - core::vector2d TCoords; - - //! Tangent vector along the x-axis of the texture - core::vector3df Tangent; - - //! Binormal vector (tangent x normal) - core::vector3df Binormal; - - bool operator == (const S3DVertexTangents& other) const - { - return (Pos == other.Pos && Normal == other.Normal && - Color == other.Color && TCoords == other.TCoords && - Tangent == other.Tangent && Binormal == other.Binormal); - } - - bool operator != (const S3DVertexTangents& other) const - { - return (Pos != other.Pos || Normal != other.Normal || - Color != other.Color || TCoords != other.TCoords || - Tangent != other.Tangent || Binormal != other.Binormal); - } -}; - - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __S_3D_VERTEX_H_INCLUDED__ +#define __S_3D_VERTEX_H_INCLUDED__ + +#include "vector3d.h" +#include "vector2d.h" +#include "SColor.h" + +namespace irr +{ +namespace video +{ + +//! Enumeration for all vertex types there are. +enum E_VERTEX_TYPE +{ + //! Standard vertex type used by the Irrlicht engine, video::S3DVertex. + EVT_STANDARD = 0, + + //! Vertex with two texture coordinates, video::S3DVertex2TCoords. Usually used + //! for geometry with lightmaps or other special materials. + EVT_2TCOORDS, + + //! Vertex with a tangent and binormal vector, video::S3DVertexTangents. Usually + //! used for tangent space normal mapping. + EVT_TANGENTS +}; + +//! standard vertex used by the Irrlicht engine. +struct S3DVertex +{ + //! default constructor + S3DVertex() {}; + + //! constructor + S3DVertex(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv) + : Pos(x,y,z), Normal(nx,ny,nz), Color(c), TCoords(tu,tv) {} + + //! constructor + S3DVertex(const core::vector3df& pos, const core::vector3df& normal, + SColor color, const core::vector2d& tcoords) + : Pos(pos), Normal(normal), Color(color), TCoords(tcoords) {} + + //! Position + core::vector3df Pos; + + //! Normal vector + core::vector3df Normal; + + //! Color + SColor Color; + + //! Texture coordinates + core::vector2d TCoords; + + bool operator == (const S3DVertex& other) const + { + return (Pos == other.Pos && Normal == other.Normal && + Color == other.Color && TCoords == other.TCoords); + } + + bool operator != (const S3DVertex& other) const + { + return (Pos != other.Pos || Normal != other.Normal || + Color != other.Color || TCoords != other.TCoords); + } +}; + + +//! Vertex with two texture coordinates. +/** Usually used for geometry with lightmaps +or other special materials. +*/ +struct S3DVertex2TCoords +{ + //! default constructor + S3DVertex2TCoords() {}; + + //! constructor with two different texture coords + S3DVertex2TCoords(f32 x, f32 y, f32 z, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2) + : Pos(x,y,z), Color(c), TCoords(tu,tv), TCoords2(tu2,tv2) {} + + //! constructor with two different texture coords + S3DVertex2TCoords(const core::vector3df& pos, SColor color, + const core::vector2d& tcoords, const core::vector2d& tcoords2) + : Pos(pos), Color(color), TCoords(tcoords), TCoords2(tcoords2) {} + + //! constructor + S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal, const SColor& color, + const core::vector2d& tcoords, const core::vector2d& tcoords2) + : Pos(pos), Normal(normal), Color(color), TCoords(tcoords), TCoords2(tcoords2) {} + + //! constructor with the same texture coords and normal + S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv) + : Pos(x,y,z), Normal(nx,ny,nz), Color(c), TCoords(tu,tv), TCoords2(tu,tv) {} + + //! constructor with the same texture coords and normal + S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal, + SColor color, const core::vector2d& tcoords) + : Pos(pos), Normal(normal), Color(color), TCoords(tcoords), TCoords2(tcoords) {} + + //! Position + core::vector3df Pos; + + //! Normal + core::vector3df Normal; + + //! Color + SColor Color; + + //! First set of texture coordinates + core::vector2d TCoords; + + //! Second set of texture coordinates + core::vector2d TCoords2; + + bool operator == (const S3DVertex2TCoords& other) const + { + return (Pos == other.Pos && Normal == other.Normal && + Color == other.Color && TCoords == other.TCoords && + TCoords2 == other.TCoords2); + } + + bool operator != (const S3DVertex2TCoords& other) const + { + return (Pos != other.Pos || Normal != other.Normal || + Color != other.Color || TCoords != other.TCoords || + TCoords2 != other.TCoords2); + } + +}; + + +//! Vertex with a tangent and binormal vector. +/** Usually used for tangent space normal mapping. +*/ +struct S3DVertexTangents +{ + //! default constructor + S3DVertexTangents() { }; + + //! constructor + S3DVertexTangents(f32 x, f32 y, f32 z) + : Pos(x,y,z) { } + + //! constructor + S3DVertexTangents(const core::vector3df& pos, + const core::vector2df& tcoords, SColor c) + : Pos(pos), Color(c), TCoords(tcoords) { } + + //! Position + core::vector3df Pos; + + //! Normal vector + core::vector3df Normal; + + //! Color + SColor Color; + + //! Texture coordinates + core::vector2d TCoords; + + //! Tangent vector along the x-axis of the texture + core::vector3df Tangent; + + //! Binormal vector (tangent x normal) + core::vector3df Binormal; + + bool operator == (const S3DVertexTangents& other) const + { + return (Pos == other.Pos && Normal == other.Normal && + Color == other.Color && TCoords == other.TCoords && + Tangent == other.Tangent && Binormal == other.Binormal); + } + + bool operator != (const S3DVertexTangents& other) const + { + return (Pos != other.Pos || Normal != other.Normal || + Color != other.Color || TCoords != other.TCoords || + Tangent != other.Tangent || Binormal != other.Binormal); + } +}; + + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/SAnimatedMesh.h b/src/dep/include/irrlicht/SAnimatedMesh.h index 502e29d..7e89dad 100644 --- a/src/dep/include/irrlicht/SAnimatedMesh.h +++ b/src/dep/include/irrlicht/SAnimatedMesh.h @@ -1,121 +1,121 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_ANIMATED_MESH_H_INCLUDED__ -#define __S_ANIMATED_MESH_H_INCLUDED__ - -#include "IAnimatedMesh.h" -#include "IMesh.h" -#include "aabbox3d.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - - //! Simple implementation of the IAnimatedMesh interface. - struct SAnimatedMesh : public IAnimatedMesh - { - //! constructor - SAnimatedMesh() - { - #ifdef _DEBUG - setDebugName("SAnimatedMesh"); - #endif - - Type = EAMT_UNKNOWN; - } - - - //! destructor - ~SAnimatedMesh() - { - // drop meshes - for (u32 i=0; idrop(); - }; - - - //! Gets the frame count of the animated mesh. - //! \return Returns the amount of frames. If the amount is 1, it is a static, non animated mesh. - virtual s32 getFrameCount() - { - return Meshes.size(); - } - - - - //! Returns the IMesh interface for a frame. - //! \param frame: Frame number as zero based index. The maximum frame number is - //! getFrameCount() - 1; - //! \param detailLevel: Level of detail. 0 is the lowest, - //! 255 the highest level of detail. Most meshes will ignore the detail level. - //! \param startFrameLoop: start frame - //! \param endFrameLoop: end frame - //! \return Returns the animated mesh based on a detail level. - virtual IMesh* getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop=-1, s32 endFrameLoop=-1) - { - if (Meshes.empty()) - return 0; - - return Meshes[frame]; - } - - - //! adds a Mesh - void addMesh(IMesh* mesh) - { - if (mesh) - { - mesh->grab(); - Meshes.push_back(mesh); - } - } - - - //! Returns an axis aligned bounding box of the mesh. - //! \return A bounding box of this mesh is returned. - virtual const core::aabbox3d& getBoundingBox() const - { - return Box; - } - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box) - { - Box = box; - } - - void recalculateBoundingBox() - { - Box.reset(0,0,0); - - if (Meshes.empty()) - return; - - Box = Meshes[0]->getBoundingBox(); - - for (u32 i=1; igetBoundingBox()); - } - - - //! Returns the type of the animated mesh. - virtual E_ANIMATED_MESH_TYPE getMeshType() const - { - return Type; - } - - core::aabbox3d Box; - core::array Meshes; - E_ANIMATED_MESH_TYPE Type; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __S_ANIMATED_MESH_H_INCLUDED__ +#define __S_ANIMATED_MESH_H_INCLUDED__ + +#include "IAnimatedMesh.h" +#include "IMesh.h" +#include "aabbox3d.h" +#include "irrArray.h" + +namespace irr +{ +namespace scene +{ + + //! Simple implementation of the IAnimatedMesh interface. + struct SAnimatedMesh : public IAnimatedMesh + { + //! constructor + SAnimatedMesh() + { + #ifdef _DEBUG + setDebugName("SAnimatedMesh"); + #endif + + Type = EAMT_UNKNOWN; + } + + + //! destructor + ~SAnimatedMesh() + { + // drop meshes + for (u32 i=0; idrop(); + }; + + + //! Gets the frame count of the animated mesh. + //! \return Returns the amount of frames. If the amount is 1, it is a static, non animated mesh. + virtual s32 getFrameCount() + { + return Meshes.size(); + } + + + + //! Returns the IMesh interface for a frame. + //! \param frame: Frame number as zero based index. The maximum frame number is + //! getFrameCount() - 1; + //! \param detailLevel: Level of detail. 0 is the lowest, + //! 255 the highest level of detail. Most meshes will ignore the detail level. + //! \param startFrameLoop: start frame + //! \param endFrameLoop: end frame + //! \return Returns the animated mesh based on a detail level. + virtual IMesh* getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop=-1, s32 endFrameLoop=-1) + { + if (Meshes.empty()) + return 0; + + return Meshes[frame]; + } + + + //! adds a Mesh + void addMesh(IMesh* mesh) + { + if (mesh) + { + mesh->grab(); + Meshes.push_back(mesh); + } + } + + + //! Returns an axis aligned bounding box of the mesh. + //! \return A bounding box of this mesh is returned. + virtual const core::aabbox3d& getBoundingBox() const + { + return Box; + } + + //! set user axis aligned bounding box + virtual void setBoundingBox( const core::aabbox3df& box) + { + Box = box; + } + + void recalculateBoundingBox() + { + Box.reset(0,0,0); + + if (Meshes.empty()) + return; + + Box = Meshes[0]->getBoundingBox(); + + for (u32 i=1; igetBoundingBox()); + } + + + //! Returns the type of the animated mesh. + virtual E_ANIMATED_MESH_TYPE getMeshType() const + { + return Type; + } + + core::aabbox3d Box; + core::array Meshes; + E_ANIMATED_MESH_TYPE Type; + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/SColor.h b/src/dep/include/irrlicht/SColor.h index 5d66845..bd5f20d 100644 --- a/src/dep/include/irrlicht/SColor.h +++ b/src/dep/include/irrlicht/SColor.h @@ -1,513 +1,513 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __COLOR_H_INCLUDED__ -#define __COLOR_H_INCLUDED__ - -#include "irrTypes.h" -#include "irrMath.h" - -namespace irr -{ -namespace video -{ - //! Creates a 16 bit A1R5G5B5 color - inline u16 RGBA16(u32 r, u32 g, u32 b, u32 a) - { - return ((a & 0x80) << 8 | - (r & 0xF8) << 7 | - (g & 0xF8) << 2 | - (b & 0xF8) >> 3); - } - - - //! Creates a 16 bit A1R5G5B5 color - inline u16 RGB16(u32 r, u32 g, u32 b) - { - return RGBA16(r,g,b,0xFF); - } - - - //! Creates a 16 bit A1R5G5B5 color, based on 16 bit input values - inline u16 RGB16from16(u16 r, u16 g, u16 b) - { - return (r & 0x1F) << 10 | - (g & 0x1F) << 5 | - (b & 0x1F); - } - - - //! Converts a 32 bit (X8R8G8B8) color to a 16 A1R5G5B5 color - inline u16 X8R8G8B8toA1R5G5B5(u32 color) - { - return ( 0x8000 | - ( color & 0x00F80000) >> 9 | - ( color & 0x0000F800) >> 6 | - ( color & 0x000000F8) >> 3); - } - - - //! Converts a 32 bit (A8R8G8B8) color to a 16 A1R5G5B5 color - inline u16 A8R8G8B8toA1R5G5B5(u32 color) - { - return (( color & 0x80000000) >> 16| - ( color & 0x00F80000) >> 9 | - ( color & 0x0000F800) >> 6 | - ( color & 0x000000F8) >> 3); - } - - - //! Returns A8R8G8B8 Color from A1R5G5B5 color - //! build a nicer 32 Bit Color by extending dest lower bits with source high bits - inline u32 A1R5G5B5toA8R8G8B8(u32 color) - { - return ( (( -( (s32) color & 0x00008000 ) >> (s32) 31 ) & 0xFF000000 ) | - (( color & 0x00007C00 ) << 9) | (( color & 0x00007000 ) << 4) | - (( color & 0x000003E0 ) << 6) | (( color & 0x00000380 ) << 1) | - (( color & 0x0000001F ) << 3) | (( color & 0x0000001C ) >> 2) - ); - } - - - //! Returns A8R8G8B8 Color from R5G6B5 color - inline u32 R5G6B5toA8R8G8B8(u16 color) - { - return 0xFF000000 | - ((color & 0xF800) << 8)| - ((color & 0x07E0) << 5)| - ((color & 0x001F) << 3); - } - - - //! Returns A1R5G5B5 Color from R5G6B5 color - inline u16 R5G6B5toA1R5G5B5(u16 color) - { - return 0x8000 | (((color & 0xFFC0) >> 1) | (color & 0x1F)); - } - - - //! Returns R5G6B5 Color from A1R5G5B5 color - inline u16 A1R5G5B5toR5G6B5(u16 color) - { - return (((color & 0x7FE0) << 1) | (color & 0x1F)); - } - - - - //! Returns the alpha component from A1R5G5B5 color - inline u32 getAlpha(u16 color) - { - return ((color >> 15)&0x1); - } - - - //! Returns the red component from A1R5G5B5 color. - //! Shift left by 3 to get 8 bit value. - inline u32 getRed(u16 color) - { - return ((color >> 10)&0x1F); - } - - - //! Returns the green component from A1R5G5B5 color - //! Shift left by 3 to get 8 bit value. - inline u32 getGreen(u16 color) - { - return ((color >> 5)&0x1F); - } - - - //! Returns the blue component from A1R5G5B5 color - //! Shift left by 3 to get 8 bit value. - inline u32 getBlue(u16 color) - { - return (color & 0x1F); - } - - //! Returns the red component from A1R5G5B5 color. - //! Shift left by 3 to get 8 bit value. - inline s32 getRedSigned(u16 color) - { - return ((color >> 10)&0x1F); - } - - - //! Returns the green component from A1R5G5B5 color - //! Shift left by 3 to get 8 bit value. - inline s32 getGreenSigned(u16 color) - { - return ((color >> 5)&0x1F); - } - - - //! Returns the blue component from A1R5G5B5 color - //! Shift left by 3 to get 8 bit value. - inline s32 getBlueSigned(u16 color) - { - return (color & 0x1F); - } - - //! Returns the average from a 16 bit A1R5G5B5 color - inline s32 getAverage(s16 color) - { - return ((getRed(color)<<3) + (getGreen(color)<<3) + (getBlue(color)<<3)) / 3; - } - - - - //! Class representing a 32 bit ARGB color. - /** The color values for alpha, red, green, and blue are - stored in a single s32. So all four values may be between 0 and 255. - This class is used by most parts of the Irrlicht Engine - to specify a color. Another way is using the class Colorf, which - stores the color values in 4 floats. - */ - class SColor - { - public: - - //! Constructor of the Color. Does nothing. The color value - //! is not initialized to save time. - inline SColor() {} - - //! Constructs the color from 4 values representing the alpha, red, green and - //! blue components of the color. Must be values between 0 and 255. - inline SColor (u32 a, u32 r, u32 g, u32 b) - : color(((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff)) {} - - //! Constructs the color from a 32 bit value. Could be another color. - inline SColor(u32 clr) - : color(clr) {} - - //! Returns the alpha component of the color. The alpha component - //! defines how transparent a color should be. - //! 0 means not transparent (opaque), 255 means fully transparent. - inline u32 getAlpha() const { return color>>24; } - - //! Returns the red component of the color. - //! \return Returns a value between 0 and 255, specifying how red the color is. - //! 0 means no red, 255 means full red. - inline u32 getRed() const { return (color>>16) & 0xff; } - - //! Returns the green component of the color. - //! \return Returns a value between 0 and 255, specifying how green the color is. - //! 0 means no green, 255 means full green. - inline u32 getGreen() const { return (color>>8) & 0xff; } - - //! Returns the blue component of the color. - //! \return Returns a value between 0 and 255, specifying how blue the color is. - //! 0 means no blue, 255 means full blue. - inline u32 getBlue() const { return color & 0xff; } - - //! Returns the luminance of the color. - inline f32 getLuminance() const - { - return 0.3f*getRed() + 0.59f*getGreen() + 0.11f*getBlue(); - } - - //! Returns the average intensity of the color. - inline u32 getAverage() const - { - return ( getRed() + getGreen() + getBlue() ) / 3; - } - - //! Sets the alpha component of the Color. The alpha component - //! defines how transparent a color should be. - //! \param a: Has to be a value between 0 and 255. - //! 0 means not transparent (opaque), 255 means fully transparent. - inline void setAlpha(u32 a) { color = ((a & 0xff)<<24) | (color & 0x00ffffff); } - - //! Sets the red component of the Color. - //! \param r: Has to be a value between 0 and 255. - //! 0 means no red (=black), 255 means full red. - inline void setRed(u32 r) { color = ((r & 0xff)<<16) | (color & 0xff00ffff); } - - //! Sets the green component of the Color. - //! \param g: Has to be a value between 0 and 255. - //! 0 means no green (=black), 255 means full green. - inline void setGreen(u32 g) { color = ((g & 0xff)<<8) | (color & 0xffff00ff); } - - //! Sets the blue component of the Color. - //! \param b: Has to be a value between 0 and 255. - //! 0 means no blue (=black), 255 means full blue. - inline void setBlue(u32 b) { color = (b & 0xff) | (color & 0xffffff00); } - - //! Calculates a 16 bit A1R5G5B5 value of this color. - //! \return Returns the 16 bit A1R5G5B5 value of this color. - inline u16 toA1R5G5B5() const { return A8R8G8B8toA1R5G5B5(color); }; - - //! Converts color to OpenGL color format, - //! from ARGB to RGBA in 4 byte components for endian aware - //! passing to OpenGL - //! \param dest: address where the 4x8 bit OpenGL color is stored. - inline void toOpenGLColor(u8* dest) const - { - *dest = getRed(); - *++dest = getGreen(); - *++dest = getBlue(); - *++dest = getAlpha(); - }; - - //! Sets all four components of the color at once. - //! Constructs the color from 4 values representing the alpha, red, green and - //! blue components of the color. Must be values between 0 and 255. - //! \param a: Alpha component of the color. - //! The alpha component defines how transparent a color should be. - //! Has to be a value between 0 and 255. - //! 0 means not transparent (opaque), 255 means fully transparent. - //! \param r: Sets the red component of the Color. - //! Has to be a value between 0 and 255. - //! 0 means no red (=black), 255 means full red. - //! \param g: Sets the green component of the Color. - //! Has to be a value between 0 and 255. - //! 0 means no green (=black), 255 means full green. - //! \param b: Sets the blue component of the Color. - //! Has to be a value between 0 and 255. - //! 0 means no blue (=black), 255 means full blue. - inline void set(u32 a, u32 r, u32 g, u32 b) { color = (((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff)); } - inline void set(u32 col) { color = col; } - - //! Compares the color to another color. - //! \return Returns true if the colors are the same, and false if not. - inline bool operator==(const SColor& other) const { return other.color == color; } - - //! Compares the color to another color. - //! \return Returns true if the colors are different, and false if they are the same. - inline bool operator!=(const SColor& other) const { return other.color != color; } - - //! Interpolates the color with a f32 value to another color - //! \param other: Other color - //! \param d: value between 0.0f and 1.0f - //! \return Returns interpolated color. - inline SColor getInterpolated(const SColor &other, f32 d) const - { - const f32 inv = 1.0f - d; - return SColor((u32)(other.getAlpha()*inv + getAlpha()*d), - (u32)(other.getRed()*inv + getRed()*d), - (u32)(other.getGreen()*inv + getGreen()*d), - (u32)(other.getBlue()*inv + getBlue()*d)); - } - - //! Returns interpolated color. ( quadratic ) - /** \param other0: other vector to interpolate between - \param other1: other vector to interpolate between - \param factor: value between 0.0f and 1.0f. */ - inline SColor getInterpolated_quadratic(const SColor& v2, const SColor& v3, const f32 d) const - { - // this*(1-d)*(1-d) + 2 * v2 * (1-d) + v3 * d * d; - const f32 inv = 1.f - d; - const f32 mul0 = inv * inv; - const f32 mul1 = 2.f * d * inv; - const f32 mul2 = d * d; - - return SColor ( core::clamp ( core::floor32 ( getAlpha() * mul0 + v2.getAlpha() * mul1 + v3.getAlpha() * mul2 ), 0, 255 ), - core::clamp ( core::floor32 ( getRed() * mul0 + v2.getRed() * mul1 + v3.getRed() * mul2 ), 0, 255 ), - core::clamp ( core::floor32 ( getGreen() * mul0 + v2.getGreen() * mul1 + v3.getGreen() * mul2 ), 0, 255 ), - core::clamp ( core::floor32 ( getBlue() * mul0 + v2.getBlue() * mul1 + v3.getBlue() * mul2 ), 0, 255 ) - ); - } - - - //! color in A8R8G8B8 Format - u32 color; - }; - - - //! Class representing a color with four floats. - /** The color values for red, green, blue - and alpha are each stored in a 32 bit floating point variable. - So all four values may be between 0.0f and 1.0f. - This class is rarely used by the Irrlicht Engine - to specify a color. Another, faster way is using the class Color, which - stores the color values in a single 32 bit integer. - */ - class SColorf - { - public: - - //! Constructs a color. All values are initialised with 0.0f, resulting - //! in a black color. - SColorf() : r(0.0f), g(0.0f), b(0.0f), a(0.0f) {}; - - //! Constructs a color from three color values: red, green and blue. - //! \param r: Red color component. Should be a value between 0.0f meaning - //! no red (=black) and 1.0f, meaning full red. - //! \param g: Green color component. Should be a value between 0.0f meaning - //! no green (=black) and 1.0f, meaning full green. - //! \param b: Blue color component. Should be a value between 0.0f meaning - //! no blue (=black) and 1.0f, meaning full blue. - SColorf(f32 r, f32 g, f32 b) : r(r), g(g), b(b), a(1.0f) {}; - - //! Constructs a color from four color values: alpha, red, green and blue. - //! \param a: Alpha color component of the color. - //! The alpha component defines how transparent a color should be. - //! Has to be a value between 0.0f and 1.0f, - //! 0.0f means not transparent (opaque), 1.0f means fully transparent. - //! \param r: Red color component. Should be a value between 0.0f meaning - //! no red (=black) and 1.0f, meaning full red. - //! \param g: Green color component. Should be a value between 0.0f meaning - //! no green (=black) and 1.0f, meaning full green. - //! \param b: Blue color component. Should be a value between 0.0f meaning - //! no blue (=black) and 1.0f, meaning full blue. - SColorf(f32 r, f32 g, f32 b, f32 a) : r(r), g(g), b(b), a(a) {}; - - //! Constructs a color from 32 bit Color. - //! \param c: 32 bit color value from which this Colorf class is - //! constructed from. - SColorf(SColor c) { const f32 inv = 1.0f / 255.0f; r = c.getRed() * inv; g = c.getGreen() * inv; b = c.getBlue() * inv; a = c.getAlpha() * inv; }; - - //! Converts this color to a SColor without floats. - SColor toSColor() const - { - return SColor((s32)(a*255.0f), (s32)(r*255.0f), (s32)(g*255.0f), (s32)(b*255.0f)); - } - - //! red color component - f32 r; - - //! green color component - f32 g; - - //! blue component - f32 b; - - //! alpha color component - f32 a; - - //! Sets three color components to new values at once. - //! \param rr: Red color component. Should be a value between 0.0f meaning - //! no red (=black) and 1.0f, meaning full red. - //! \param gg: Green color component. Should be a value between 0.0f meaning - //! no green (=black) and 1.0f, meaning full green. - //! \param bb: Blue color component. Should be a value between 0.0f meaning - //! no blue (=black) and 1.0f, meaning full blue. - void set(f32 rr, f32 gg, f32 bb) {r = rr; g =gg; b = bb; }; - - //! Sets all four color components to new values at once. - //! \param a: Alpha component. - //! \param rr: Red color component. Should be a value between 0.0f meaning - //! no red (=black) and 1.0f, meaning full red. - //! \param gg: Green color component. Should be a value between 0.0f meaning - //! no green (=black) and 1.0f, meaning full green. - //! \param bb: Blue color component. Should be a value between 0.0f meaning - //! no blue (=black) and 1.0f, meaning full blue. - void set(f32 aa, f32 rr, f32 gg, f32 bb) {a = aa; r = rr; g =gg; b = bb; }; - - //! Interpolates the color with a f32 value to another color - //! \param other: Other color - //! \param d: value between 0.0f and 1.0f - //! \return Returns interpolated color. - inline SColorf getInterpolated(const SColorf &other, f32 d) const - { - const f32 inv = 1.0f - d; - return SColorf(other.r*inv + r*d, - other.g*inv + g*d, other.b*inv + b*d, other.a*inv + a*d); - } - - //! Returns interpolated color. ( quadratic ) - /** \param other0: other vector to interpolate between - \param other1: other vector to interpolate between - \param factor: value between 0.0f and 1.0f. */ - inline SColorf getInterpolated_quadratic(const SColorf& v2, const SColorf& v3, const f32 d) const - { - // this*(1-d)*(1-d) + 2 * v2 * (1-d) + v3 * d * d; - const f32 inv = 1.f - d; - const f32 mul0 = inv * inv; - const f32 mul1 = 2.f * d * inv; - const f32 mul2 = d * d; - - return SColorf ( r * mul0 + v2.r * mul1 + v3.r * mul2, - g * mul0 + v2.g * mul1 + v3.g * mul2, - g * mul0 + v2.b * mul1 + v3.b * mul2, - a * mul0 + v2.a * mul1 + v3.a * mul2 - ); - } - - - - //! Sets a color component by index. R=0, G=1, B=2, A=3 - inline void setColorComponentValue(s32 index, f32 value) - { - switch(index) - { - case 0: r = value; break; - case 1: g = value; break; - case 2: b = value; break; - case 3: a = value; break; - } - } - }; - - //! Class representing a color in HSV format - /** The color values for hue, saturation, value - are stored in a 32 bit floating point variable. - */ - class SColorHSL - { - public: - SColorHSL ( f32 h = 0.f, f32 s = 0.f, f32 l = 0.f ) - : Hue ( h ), Saturation ( s ), Luminance ( l ) {} - - void setfromRGB ( const SColor &color ); - void settoRGB ( SColor &color ) const; - - f32 Hue; - f32 Saturation; - f32 Luminance; - - private: - inline u32 toRGB1(f32 rm1, f32 rm2, f32 rh) const; - - }; - - inline void SColorHSL::settoRGB ( SColor &color ) const - { - if ( Saturation == 0.0f) // grey - { - u8 c = (u8) ( Luminance * 255.0 ); - color.setRed ( c ); - color.setGreen ( c ); - color.setBlue ( c ); - return; - } - - f32 rm1, rm2; - - if ( Luminance <= 0.5f ) - { - rm2 = Luminance + Luminance * Saturation; - } - else - { - rm2 = Luminance + Saturation - Luminance * Saturation; - } - - rm1 = 2.0f * Luminance - rm2; - - color.setRed ( toRGB1(rm1, rm2, Hue + (120.0f * core::DEGTORAD )) ); - color.setGreen ( toRGB1(rm1, rm2, Hue) ); - color.setBlue ( toRGB1(rm1, rm2, Hue - (120.0f * core::DEGTORAD) ) ); - } - - - inline u32 SColorHSL::toRGB1(f32 rm1, f32 rm2, f32 rh) const - { - while ( rh > 2.f * core::PI ) - rh -= 2.f * core::PI; - - while ( rh < 0.f ) - rh += 2.f * core::PI; - - if (rh < 60.0f * core::DEGTORAD ) rm1 = rm1 + (rm2 - rm1) * rh / (60.0f * core::DEGTORAD); - else if (rh < 180.0f * core::DEGTORAD ) rm1 = rm2; - else if (rh < 240.0f * core::DEGTORAD ) rm1 = rm1 + (rm2 - rm1) * ( ( 240.0f * core::DEGTORAD ) - rh) / (60.0f * core::DEGTORAD); - - return (u32) (rm1 * 255.f); - } - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __COLOR_H_INCLUDED__ +#define __COLOR_H_INCLUDED__ + +#include "irrTypes.h" +#include "irrMath.h" + +namespace irr +{ +namespace video +{ + //! Creates a 16 bit A1R5G5B5 color + inline u16 RGBA16(u32 r, u32 g, u32 b, u32 a) + { + return ((a & 0x80) << 8 | + (r & 0xF8) << 7 | + (g & 0xF8) << 2 | + (b & 0xF8) >> 3); + } + + + //! Creates a 16 bit A1R5G5B5 color + inline u16 RGB16(u32 r, u32 g, u32 b) + { + return RGBA16(r,g,b,0xFF); + } + + + //! Creates a 16 bit A1R5G5B5 color, based on 16 bit input values + inline u16 RGB16from16(u16 r, u16 g, u16 b) + { + return (r & 0x1F) << 10 | + (g & 0x1F) << 5 | + (b & 0x1F); + } + + + //! Converts a 32 bit (X8R8G8B8) color to a 16 A1R5G5B5 color + inline u16 X8R8G8B8toA1R5G5B5(u32 color) + { + return ( 0x8000 | + ( color & 0x00F80000) >> 9 | + ( color & 0x0000F800) >> 6 | + ( color & 0x000000F8) >> 3); + } + + + //! Converts a 32 bit (A8R8G8B8) color to a 16 A1R5G5B5 color + inline u16 A8R8G8B8toA1R5G5B5(u32 color) + { + return (( color & 0x80000000) >> 16| + ( color & 0x00F80000) >> 9 | + ( color & 0x0000F800) >> 6 | + ( color & 0x000000F8) >> 3); + } + + + //! Returns A8R8G8B8 Color from A1R5G5B5 color + //! build a nicer 32 Bit Color by extending dest lower bits with source high bits + inline u32 A1R5G5B5toA8R8G8B8(u32 color) + { + return ( (( -( (s32) color & 0x00008000 ) >> (s32) 31 ) & 0xFF000000 ) | + (( color & 0x00007C00 ) << 9) | (( color & 0x00007000 ) << 4) | + (( color & 0x000003E0 ) << 6) | (( color & 0x00000380 ) << 1) | + (( color & 0x0000001F ) << 3) | (( color & 0x0000001C ) >> 2) + ); + } + + + //! Returns A8R8G8B8 Color from R5G6B5 color + inline u32 R5G6B5toA8R8G8B8(u16 color) + { + return 0xFF000000 | + ((color & 0xF800) << 8)| + ((color & 0x07E0) << 5)| + ((color & 0x001F) << 3); + } + + + //! Returns A1R5G5B5 Color from R5G6B5 color + inline u16 R5G6B5toA1R5G5B5(u16 color) + { + return 0x8000 | (((color & 0xFFC0) >> 1) | (color & 0x1F)); + } + + + //! Returns R5G6B5 Color from A1R5G5B5 color + inline u16 A1R5G5B5toR5G6B5(u16 color) + { + return (((color & 0x7FE0) << 1) | (color & 0x1F)); + } + + + + //! Returns the alpha component from A1R5G5B5 color + inline u32 getAlpha(u16 color) + { + return ((color >> 15)&0x1); + } + + + //! Returns the red component from A1R5G5B5 color. + //! Shift left by 3 to get 8 bit value. + inline u32 getRed(u16 color) + { + return ((color >> 10)&0x1F); + } + + + //! Returns the green component from A1R5G5B5 color + //! Shift left by 3 to get 8 bit value. + inline u32 getGreen(u16 color) + { + return ((color >> 5)&0x1F); + } + + + //! Returns the blue component from A1R5G5B5 color + //! Shift left by 3 to get 8 bit value. + inline u32 getBlue(u16 color) + { + return (color & 0x1F); + } + + //! Returns the red component from A1R5G5B5 color. + //! Shift left by 3 to get 8 bit value. + inline s32 getRedSigned(u16 color) + { + return ((color >> 10)&0x1F); + } + + + //! Returns the green component from A1R5G5B5 color + //! Shift left by 3 to get 8 bit value. + inline s32 getGreenSigned(u16 color) + { + return ((color >> 5)&0x1F); + } + + + //! Returns the blue component from A1R5G5B5 color + //! Shift left by 3 to get 8 bit value. + inline s32 getBlueSigned(u16 color) + { + return (color & 0x1F); + } + + //! Returns the average from a 16 bit A1R5G5B5 color + inline s32 getAverage(s16 color) + { + return ((getRed(color)<<3) + (getGreen(color)<<3) + (getBlue(color)<<3)) / 3; + } + + + + //! Class representing a 32 bit ARGB color. + /** The color values for alpha, red, green, and blue are + stored in a single s32. So all four values may be between 0 and 255. + This class is used by most parts of the Irrlicht Engine + to specify a color. Another way is using the class Colorf, which + stores the color values in 4 floats. + */ + class SColor + { + public: + + //! Constructor of the Color. Does nothing. The color value + //! is not initialized to save time. + inline SColor() {} + + //! Constructs the color from 4 values representing the alpha, red, green and + //! blue components of the color. Must be values between 0 and 255. + inline SColor (u32 a, u32 r, u32 g, u32 b) + : color(((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff)) {} + + //! Constructs the color from a 32 bit value. Could be another color. + inline SColor(u32 clr) + : color(clr) {} + + //! Returns the alpha component of the color. The alpha component + //! defines how transparent a color should be. + //! 0 means not transparent (opaque), 255 means fully transparent. + inline u32 getAlpha() const { return color>>24; } + + //! Returns the red component of the color. + //! \return Returns a value between 0 and 255, specifying how red the color is. + //! 0 means no red, 255 means full red. + inline u32 getRed() const { return (color>>16) & 0xff; } + + //! Returns the green component of the color. + //! \return Returns a value between 0 and 255, specifying how green the color is. + //! 0 means no green, 255 means full green. + inline u32 getGreen() const { return (color>>8) & 0xff; } + + //! Returns the blue component of the color. + //! \return Returns a value between 0 and 255, specifying how blue the color is. + //! 0 means no blue, 255 means full blue. + inline u32 getBlue() const { return color & 0xff; } + + //! Returns the luminance of the color. + inline f32 getLuminance() const + { + return 0.3f*getRed() + 0.59f*getGreen() + 0.11f*getBlue(); + } + + //! Returns the average intensity of the color. + inline u32 getAverage() const + { + return ( getRed() + getGreen() + getBlue() ) / 3; + } + + //! Sets the alpha component of the Color. The alpha component + //! defines how transparent a color should be. + //! \param a: Has to be a value between 0 and 255. + //! 0 means not transparent (opaque), 255 means fully transparent. + inline void setAlpha(u32 a) { color = ((a & 0xff)<<24) | (color & 0x00ffffff); } + + //! Sets the red component of the Color. + //! \param r: Has to be a value between 0 and 255. + //! 0 means no red (=black), 255 means full red. + inline void setRed(u32 r) { color = ((r & 0xff)<<16) | (color & 0xff00ffff); } + + //! Sets the green component of the Color. + //! \param g: Has to be a value between 0 and 255. + //! 0 means no green (=black), 255 means full green. + inline void setGreen(u32 g) { color = ((g & 0xff)<<8) | (color & 0xffff00ff); } + + //! Sets the blue component of the Color. + //! \param b: Has to be a value between 0 and 255. + //! 0 means no blue (=black), 255 means full blue. + inline void setBlue(u32 b) { color = (b & 0xff) | (color & 0xffffff00); } + + //! Calculates a 16 bit A1R5G5B5 value of this color. + //! \return Returns the 16 bit A1R5G5B5 value of this color. + inline u16 toA1R5G5B5() const { return A8R8G8B8toA1R5G5B5(color); }; + + //! Converts color to OpenGL color format, + //! from ARGB to RGBA in 4 byte components for endian aware + //! passing to OpenGL + //! \param dest: address where the 4x8 bit OpenGL color is stored. + inline void toOpenGLColor(u8* dest) const + { + *dest = getRed(); + *++dest = getGreen(); + *++dest = getBlue(); + *++dest = getAlpha(); + }; + + //! Sets all four components of the color at once. + //! Constructs the color from 4 values representing the alpha, red, green and + //! blue components of the color. Must be values between 0 and 255. + //! \param a: Alpha component of the color. + //! The alpha component defines how transparent a color should be. + //! Has to be a value between 0 and 255. + //! 0 means not transparent (opaque), 255 means fully transparent. + //! \param r: Sets the red component of the Color. + //! Has to be a value between 0 and 255. + //! 0 means no red (=black), 255 means full red. + //! \param g: Sets the green component of the Color. + //! Has to be a value between 0 and 255. + //! 0 means no green (=black), 255 means full green. + //! \param b: Sets the blue component of the Color. + //! Has to be a value between 0 and 255. + //! 0 means no blue (=black), 255 means full blue. + inline void set(u32 a, u32 r, u32 g, u32 b) { color = (((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff)); } + inline void set(u32 col) { color = col; } + + //! Compares the color to another color. + //! \return Returns true if the colors are the same, and false if not. + inline bool operator==(const SColor& other) const { return other.color == color; } + + //! Compares the color to another color. + //! \return Returns true if the colors are different, and false if they are the same. + inline bool operator!=(const SColor& other) const { return other.color != color; } + + //! Interpolates the color with a f32 value to another color + //! \param other: Other color + //! \param d: value between 0.0f and 1.0f + //! \return Returns interpolated color. + inline SColor getInterpolated(const SColor &other, f32 d) const + { + const f32 inv = 1.0f - d; + return SColor((u32)(other.getAlpha()*inv + getAlpha()*d), + (u32)(other.getRed()*inv + getRed()*d), + (u32)(other.getGreen()*inv + getGreen()*d), + (u32)(other.getBlue()*inv + getBlue()*d)); + } + + //! Returns interpolated color. ( quadratic ) + /** \param other0: other vector to interpolate between + \param other1: other vector to interpolate between + \param factor: value between 0.0f and 1.0f. */ + inline SColor getInterpolated_quadratic(const SColor& v2, const SColor& v3, const f32 d) const + { + // this*(1-d)*(1-d) + 2 * v2 * (1-d) + v3 * d * d; + const f32 inv = 1.f - d; + const f32 mul0 = inv * inv; + const f32 mul1 = 2.f * d * inv; + const f32 mul2 = d * d; + + return SColor ( core::clamp ( core::floor32 ( getAlpha() * mul0 + v2.getAlpha() * mul1 + v3.getAlpha() * mul2 ), 0, 255 ), + core::clamp ( core::floor32 ( getRed() * mul0 + v2.getRed() * mul1 + v3.getRed() * mul2 ), 0, 255 ), + core::clamp ( core::floor32 ( getGreen() * mul0 + v2.getGreen() * mul1 + v3.getGreen() * mul2 ), 0, 255 ), + core::clamp ( core::floor32 ( getBlue() * mul0 + v2.getBlue() * mul1 + v3.getBlue() * mul2 ), 0, 255 ) + ); + } + + + //! color in A8R8G8B8 Format + u32 color; + }; + + + //! Class representing a color with four floats. + /** The color values for red, green, blue + and alpha are each stored in a 32 bit floating point variable. + So all four values may be between 0.0f and 1.0f. + This class is rarely used by the Irrlicht Engine + to specify a color. Another, faster way is using the class Color, which + stores the color values in a single 32 bit integer. + */ + class SColorf + { + public: + + //! Constructs a color. All values are initialised with 0.0f, resulting + //! in a black color. + SColorf() : r(0.0f), g(0.0f), b(0.0f), a(0.0f) {}; + + //! Constructs a color from three color values: red, green and blue. + //! \param r: Red color component. Should be a value between 0.0f meaning + //! no red (=black) and 1.0f, meaning full red. + //! \param g: Green color component. Should be a value between 0.0f meaning + //! no green (=black) and 1.0f, meaning full green. + //! \param b: Blue color component. Should be a value between 0.0f meaning + //! no blue (=black) and 1.0f, meaning full blue. + SColorf(f32 r, f32 g, f32 b) : r(r), g(g), b(b), a(1.0f) {}; + + //! Constructs a color from four color values: alpha, red, green and blue. + //! \param a: Alpha color component of the color. + //! The alpha component defines how transparent a color should be. + //! Has to be a value between 0.0f and 1.0f, + //! 0.0f means not transparent (opaque), 1.0f means fully transparent. + //! \param r: Red color component. Should be a value between 0.0f meaning + //! no red (=black) and 1.0f, meaning full red. + //! \param g: Green color component. Should be a value between 0.0f meaning + //! no green (=black) and 1.0f, meaning full green. + //! \param b: Blue color component. Should be a value between 0.0f meaning + //! no blue (=black) and 1.0f, meaning full blue. + SColorf(f32 r, f32 g, f32 b, f32 a) : r(r), g(g), b(b), a(a) {}; + + //! Constructs a color from 32 bit Color. + //! \param c: 32 bit color value from which this Colorf class is + //! constructed from. + SColorf(SColor c) { const f32 inv = 1.0f / 255.0f; r = c.getRed() * inv; g = c.getGreen() * inv; b = c.getBlue() * inv; a = c.getAlpha() * inv; }; + + //! Converts this color to a SColor without floats. + SColor toSColor() const + { + return SColor((s32)(a*255.0f), (s32)(r*255.0f), (s32)(g*255.0f), (s32)(b*255.0f)); + } + + //! red color component + f32 r; + + //! green color component + f32 g; + + //! blue component + f32 b; + + //! alpha color component + f32 a; + + //! Sets three color components to new values at once. + //! \param rr: Red color component. Should be a value between 0.0f meaning + //! no red (=black) and 1.0f, meaning full red. + //! \param gg: Green color component. Should be a value between 0.0f meaning + //! no green (=black) and 1.0f, meaning full green. + //! \param bb: Blue color component. Should be a value between 0.0f meaning + //! no blue (=black) and 1.0f, meaning full blue. + void set(f32 rr, f32 gg, f32 bb) {r = rr; g =gg; b = bb; }; + + //! Sets all four color components to new values at once. + //! \param a: Alpha component. + //! \param rr: Red color component. Should be a value between 0.0f meaning + //! no red (=black) and 1.0f, meaning full red. + //! \param gg: Green color component. Should be a value between 0.0f meaning + //! no green (=black) and 1.0f, meaning full green. + //! \param bb: Blue color component. Should be a value between 0.0f meaning + //! no blue (=black) and 1.0f, meaning full blue. + void set(f32 aa, f32 rr, f32 gg, f32 bb) {a = aa; r = rr; g =gg; b = bb; }; + + //! Interpolates the color with a f32 value to another color + //! \param other: Other color + //! \param d: value between 0.0f and 1.0f + //! \return Returns interpolated color. + inline SColorf getInterpolated(const SColorf &other, f32 d) const + { + const f32 inv = 1.0f - d; + return SColorf(other.r*inv + r*d, + other.g*inv + g*d, other.b*inv + b*d, other.a*inv + a*d); + } + + //! Returns interpolated color. ( quadratic ) + /** \param other0: other vector to interpolate between + \param other1: other vector to interpolate between + \param factor: value between 0.0f and 1.0f. */ + inline SColorf getInterpolated_quadratic(const SColorf& v2, const SColorf& v3, const f32 d) const + { + // this*(1-d)*(1-d) + 2 * v2 * (1-d) + v3 * d * d; + const f32 inv = 1.f - d; + const f32 mul0 = inv * inv; + const f32 mul1 = 2.f * d * inv; + const f32 mul2 = d * d; + + return SColorf ( r * mul0 + v2.r * mul1 + v3.r * mul2, + g * mul0 + v2.g * mul1 + v3.g * mul2, + g * mul0 + v2.b * mul1 + v3.b * mul2, + a * mul0 + v2.a * mul1 + v3.a * mul2 + ); + } + + + + //! Sets a color component by index. R=0, G=1, B=2, A=3 + inline void setColorComponentValue(s32 index, f32 value) + { + switch(index) + { + case 0: r = value; break; + case 1: g = value; break; + case 2: b = value; break; + case 3: a = value; break; + } + } + }; + + //! Class representing a color in HSV format + /** The color values for hue, saturation, value + are stored in a 32 bit floating point variable. + */ + class SColorHSL + { + public: + SColorHSL ( f32 h = 0.f, f32 s = 0.f, f32 l = 0.f ) + : Hue ( h ), Saturation ( s ), Luminance ( l ) {} + + void setfromRGB ( const SColor &color ); + void settoRGB ( SColor &color ) const; + + f32 Hue; + f32 Saturation; + f32 Luminance; + + private: + inline u32 toRGB1(f32 rm1, f32 rm2, f32 rh) const; + + }; + + inline void SColorHSL::settoRGB ( SColor &color ) const + { + if ( Saturation == 0.0f) // grey + { + u8 c = (u8) ( Luminance * 255.0 ); + color.setRed ( c ); + color.setGreen ( c ); + color.setBlue ( c ); + return; + } + + f32 rm1, rm2; + + if ( Luminance <= 0.5f ) + { + rm2 = Luminance + Luminance * Saturation; + } + else + { + rm2 = Luminance + Saturation - Luminance * Saturation; + } + + rm1 = 2.0f * Luminance - rm2; + + color.setRed ( toRGB1(rm1, rm2, Hue + (120.0f * core::DEGTORAD )) ); + color.setGreen ( toRGB1(rm1, rm2, Hue) ); + color.setBlue ( toRGB1(rm1, rm2, Hue - (120.0f * core::DEGTORAD) ) ); + } + + + inline u32 SColorHSL::toRGB1(f32 rm1, f32 rm2, f32 rh) const + { + while ( rh > 2.f * core::PI ) + rh -= 2.f * core::PI; + + while ( rh < 0.f ) + rh += 2.f * core::PI; + + if (rh < 60.0f * core::DEGTORAD ) rm1 = rm1 + (rm2 - rm1) * rh / (60.0f * core::DEGTORAD); + else if (rh < 180.0f * core::DEGTORAD ) rm1 = rm2; + else if (rh < 240.0f * core::DEGTORAD ) rm1 = rm1 + (rm2 - rm1) * ( ( 240.0f * core::DEGTORAD ) - rh) / (60.0f * core::DEGTORAD); + + return (u32) (rm1 * 255.f); + } + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/SExposedVideoData.h b/src/dep/include/irrlicht/SExposedVideoData.h index a0ebd81..c526150 100644 --- a/src/dep/include/irrlicht/SExposedVideoData.h +++ b/src/dep/include/irrlicht/SExposedVideoData.h @@ -1,86 +1,86 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_EXPOSED_VIDEO_DATA_H_INCLUDED__ -#define __S_EXPOSED_VIDEO_DATA_H_INCLUDED__ - -// forward declarations for internal pointers -struct IDirect3D9; -struct IDirect3DDevice9; -struct IDirect3D8; -struct IDirect3DDevice8; - -namespace irr -{ -namespace video -{ - -//! structure for holding data describing a driver and operating system specific data. -/** This data can be retrived by IVideoDriver::getExposedVideoData(). Use this with caution. - This only should be used to make it possible to extend the engine easily without - modification of its source. Note that this structure does not contain any valid data, if - you are using the software or the null device. -*/ -struct SExposedVideoData -{ - union - { - struct - { - //! Pointer to the IDirect3D9 interface - IDirect3D9* D3D9; - - //! Pointer to the IDirect3D9 interface - IDirect3DDevice9* D3DDev9; - - //! Window handle. Get with for example - //! HWND h = reinterpret_cast(exposedData.D3D9.HWnd) - s32 HWnd; - - } D3D9; - - struct - { - //! Pointer to the IDirect3D8 interface - IDirect3D8* D3D8; - - //! Pointer to the IDirect3D8 interface - IDirect3DDevice8* D3DDev8; - - //! Window handle. Get with for example with: - //! HWND h = reinterpret_cast(exposedData.D3D8.HWnd) - s32 HWnd; - - } D3D8; - - struct - { - //! Private GDI Device Context. Get if for example with: - //! HDC h = reinterpret_cast(exposedData.OpenGLWin32.HDc) - s32 HDc; - - //! Permanent Rendering Context. Get if for example with: - //! HGLRC h = reinterpret_cast(exposedData.OpenGLWin32.HRc) - s32 HRc; - - //! Window handle. Get with for example with: - //! HWND h = reinterpret_cast(exposedData.OpenGLWin32.HWnd) - s32 HWnd; - - } OpenGLWin32; - - struct - { - // XWindow handle - u32 Window; - } OpenGLLinux; - }; -}; - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __S_EXPOSED_VIDEO_DATA_H_INCLUDED__ +#define __S_EXPOSED_VIDEO_DATA_H_INCLUDED__ + +// forward declarations for internal pointers +struct IDirect3D9; +struct IDirect3DDevice9; +struct IDirect3D8; +struct IDirect3DDevice8; + +namespace irr +{ +namespace video +{ + +//! structure for holding data describing a driver and operating system specific data. +/** This data can be retrived by IVideoDriver::getExposedVideoData(). Use this with caution. + This only should be used to make it possible to extend the engine easily without + modification of its source. Note that this structure does not contain any valid data, if + you are using the software or the null device. +*/ +struct SExposedVideoData +{ + union + { + struct + { + //! Pointer to the IDirect3D9 interface + IDirect3D9* D3D9; + + //! Pointer to the IDirect3D9 interface + IDirect3DDevice9* D3DDev9; + + //! Window handle. Get with for example + //! HWND h = reinterpret_cast(exposedData.D3D9.HWnd) + s32 HWnd; + + } D3D9; + + struct + { + //! Pointer to the IDirect3D8 interface + IDirect3D8* D3D8; + + //! Pointer to the IDirect3D8 interface + IDirect3DDevice8* D3DDev8; + + //! Window handle. Get with for example with: + //! HWND h = reinterpret_cast(exposedData.D3D8.HWnd) + s32 HWnd; + + } D3D8; + + struct + { + //! Private GDI Device Context. Get if for example with: + //! HDC h = reinterpret_cast(exposedData.OpenGLWin32.HDc) + s32 HDc; + + //! Permanent Rendering Context. Get if for example with: + //! HGLRC h = reinterpret_cast(exposedData.OpenGLWin32.HRc) + s32 HRc; + + //! Window handle. Get with for example with: + //! HWND h = reinterpret_cast(exposedData.OpenGLWin32.HWnd) + s32 HWnd; + + } OpenGLWin32; + + struct + { + // XWindow handle + u32 Window; + } OpenGLLinux; + }; +}; + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/SIrrCreationParameters.h b/src/dep/include/irrlicht/SIrrCreationParameters.h index bfdb3f7..fbef6d3 100644 --- a/src/dep/include/irrlicht/SIrrCreationParameters.h +++ b/src/dep/include/irrlicht/SIrrCreationParameters.h @@ -1,140 +1,140 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED__ -#define __I_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED__ - -namespace irr -{ - //! Structure for holding advanced Irrlicht Device creation parameters. - /** This structure is only used in the createDeviceEx() function. */ - struct SIrrlichtCreationParameters - { - //! Constructs a SIrrlichtCreationParameters structure with default values. - SIrrlichtCreationParameters() - { - DriverType = video::EDT_BURNINGSVIDEO; - WindowSize = core::dimension2d(800, 600); - Bits = 16; - Fullscreen = false; - Stencilbuffer = false; - Vsync = false; - AntiAlias = false; - HighPrecisionFPU = false; - EventReceiver = 0; - WindowId = 0; - SDK_version_do_not_use = IRRLICHT_SDK_VERSION; - } - - //! Type of the device. - /** This can currently be video::EDT_NULL, - video::EDT_SOFTWARE, video::EDT_DIRECT3D8, video::EDT_DIRECT3D9 and video::EDT_OPENGL. - Default: Software. */ - video::E_DRIVER_TYPE DriverType; - - //! Size of the window or the video mode in fullscreen mode. Default: 800x600 - core::dimension2d WindowSize; - - //! Bits per pixel in fullscreen mode. Ignored if windowed mode. Default: 16. - u32 Bits; - - //! Should be set to true if the device should run in fullscreen. - /** Otherwise the device runs in windowed mode. Default: false. */ - bool Fullscreen; - - //! Specifies if the stencil buffer should be enabled. - /** Set this to true, - if you want the engine be able to draw stencil buffer shadows. Note that not all - devices are able to use the stencil buffer. If they don't no shadows will be drawn. - Default: false. */ - bool Stencilbuffer; - - //! Specifies vertical syncronisation. - /** If set to true, the driver will wait for the vertical retrace period, otherwise not. - Default: false */ - bool Vsync; - - //! Specifies if the device should use fullscreen anti aliasing - /** Makes sharp/pixelated edges softer, but requires more performance. Also, 2D - elements might look blurred with this switched on. The resulting rendering quality - also depends on the hardware and driver you are using, your program might look - different on different hardware with this. So if you are writing a - game/application with antiAlias switched on, it would be a good idea to make it - possible to switch this option off again by the user. - This is only supported in D3D9 and D3D8. In D3D9, both sample types are supported, - D3DMULTISAMPLE_X_SAMPLES and D3DMULTISAMPLE_NONMASKABLE. Default value: false */ - bool AntiAlias; - - //! Specifies if the device should use high precision FPU setting - /** This is only relevant for DirectX Devices, which switch to low FPU precision - by default for performance reasons. However, this may lead to problems with the - other computations of the application. In this case setting this flag to true - should help - on the expense of performance loss, though. - Default value: false */ - bool HighPrecisionFPU; - - //! A user created event receiver. - IEventReceiver* EventReceiver; - - //! Window Id. - /** If this is set to a value other than 0, the Irrlicht Engine will be created in - an already existing window. For windows, set this to the HWND of the window you want. - The windowSize and FullScreen options will be ignored when using the WindowId parameter. - Default this is set to 0. - To make Irrlicht run inside the custom window, you still will have to draw Irrlicht - on your own. You can use this loop, as usual: - \code - while (device->run()) - { - driver->beginScene(true, true, 0); - smgr->drawAll(); - driver->endScene(); - } - \endcode - Instead of this, you can also simply use your own message loop - using GetMessage, DispatchMessage and whatever. Calling - IrrlichtDevice::run() will cause Irrlicht to dispatch messages internally too. - You need not call Device->run() if you want to do your own message - dispatching loop, but Irrlicht will not be able to fetch - user input then and you have to do it on your own using the window - messages, DirectInput, or whatever. Also, you'll have to increment the Irrlicht timer. - An alternative, own message dispatching loop without device->run() would - look like this: - \code - MSG msg; - while (true) - { - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - - if (msg.message == WM_QUIT) - break; - } - - // increase virtual timer time - device->getTimer()->tick(); - - // draw engine picture - driver->beginScene(true, true, 0); - smgr->drawAll(); - driver->endScene(); - } - \endcode - However, there is no need to draw the picture this often. Just do it how you like. - */ - s32 WindowId; - - //! Don't use or change this parameter. - /** Always set it to IRRLICHT_SDK_VERSION, which is done by default. - This is needed for sdk version checks. */ - const c8* SDK_version_do_not_use; - }; - - -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED__ +#define __I_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED__ + +namespace irr +{ + //! Structure for holding advanced Irrlicht Device creation parameters. + /** This structure is only used in the createDeviceEx() function. */ + struct SIrrlichtCreationParameters + { + //! Constructs a SIrrlichtCreationParameters structure with default values. + SIrrlichtCreationParameters() + { + DriverType = video::EDT_BURNINGSVIDEO; + WindowSize = core::dimension2d(800, 600); + Bits = 16; + Fullscreen = false; + Stencilbuffer = false; + Vsync = false; + AntiAlias = false; + HighPrecisionFPU = false; + EventReceiver = 0; + WindowId = 0; + SDK_version_do_not_use = IRRLICHT_SDK_VERSION; + } + + //! Type of the device. + /** This can currently be video::EDT_NULL, + video::EDT_SOFTWARE, video::EDT_DIRECT3D8, video::EDT_DIRECT3D9 and video::EDT_OPENGL. + Default: Software. */ + video::E_DRIVER_TYPE DriverType; + + //! Size of the window or the video mode in fullscreen mode. Default: 800x600 + core::dimension2d WindowSize; + + //! Bits per pixel in fullscreen mode. Ignored if windowed mode. Default: 16. + u32 Bits; + + //! Should be set to true if the device should run in fullscreen. + /** Otherwise the device runs in windowed mode. Default: false. */ + bool Fullscreen; + + //! Specifies if the stencil buffer should be enabled. + /** Set this to true, + if you want the engine be able to draw stencil buffer shadows. Note that not all + devices are able to use the stencil buffer. If they don't no shadows will be drawn. + Default: false. */ + bool Stencilbuffer; + + //! Specifies vertical syncronisation. + /** If set to true, the driver will wait for the vertical retrace period, otherwise not. + Default: false */ + bool Vsync; + + //! Specifies if the device should use fullscreen anti aliasing + /** Makes sharp/pixelated edges softer, but requires more performance. Also, 2D + elements might look blurred with this switched on. The resulting rendering quality + also depends on the hardware and driver you are using, your program might look + different on different hardware with this. So if you are writing a + game/application with antiAlias switched on, it would be a good idea to make it + possible to switch this option off again by the user. + This is only supported in D3D9 and D3D8. In D3D9, both sample types are supported, + D3DMULTISAMPLE_X_SAMPLES and D3DMULTISAMPLE_NONMASKABLE. Default value: false */ + bool AntiAlias; + + //! Specifies if the device should use high precision FPU setting + /** This is only relevant for DirectX Devices, which switch to low FPU precision + by default for performance reasons. However, this may lead to problems with the + other computations of the application. In this case setting this flag to true + should help - on the expense of performance loss, though. + Default value: false */ + bool HighPrecisionFPU; + + //! A user created event receiver. + IEventReceiver* EventReceiver; + + //! Window Id. + /** If this is set to a value other than 0, the Irrlicht Engine will be created in + an already existing window. For windows, set this to the HWND of the window you want. + The windowSize and FullScreen options will be ignored when using the WindowId parameter. + Default this is set to 0. + To make Irrlicht run inside the custom window, you still will have to draw Irrlicht + on your own. You can use this loop, as usual: + \code + while (device->run()) + { + driver->beginScene(true, true, 0); + smgr->drawAll(); + driver->endScene(); + } + \endcode + Instead of this, you can also simply use your own message loop + using GetMessage, DispatchMessage and whatever. Calling + IrrlichtDevice::run() will cause Irrlicht to dispatch messages internally too. + You need not call Device->run() if you want to do your own message + dispatching loop, but Irrlicht will not be able to fetch + user input then and you have to do it on your own using the window + messages, DirectInput, or whatever. Also, you'll have to increment the Irrlicht timer. + An alternative, own message dispatching loop without device->run() would + look like this: + \code + MSG msg; + while (true) + { + if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + + if (msg.message == WM_QUIT) + break; + } + + // increase virtual timer time + device->getTimer()->tick(); + + // draw engine picture + driver->beginScene(true, true, 0); + smgr->drawAll(); + driver->endScene(); + } + \endcode + However, there is no need to draw the picture this often. Just do it how you like. + */ + s32 WindowId; + + //! Don't use or change this parameter. + /** Always set it to IRRLICHT_SDK_VERSION, which is done by default. + This is needed for sdk version checks. */ + const c8* SDK_version_do_not_use; + }; + + +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/SKeyMap.h b/src/dep/include/irrlicht/SKeyMap.h index b9ab43f..b5282b4 100644 --- a/src/dep/include/irrlicht/SKeyMap.h +++ b/src/dep/include/irrlicht/SKeyMap.h @@ -1,37 +1,37 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_KEY_MAP_H_INCLUDED__ -#define __S_KEY_MAP_H_INCLUDED__ - -#include "Keycodes.h" - -namespace irr -{ - - //! enumeration for key actions. Used for example in the FPS Camera. - enum EKEY_ACTION - { - EKA_MOVE_FORWARD = 0, - EKA_MOVE_BACKWARD, - EKA_STRAFE_LEFT, - EKA_STRAFE_RIGHT, - EKA_JUMP_UP, - EKA_COUNT, - - //! This value is not used. It only forces this enumeration to compile in 32 bit. - EKA_FORCE_32BIT = 0x7fffffff - }; - - //! Struct storing which key belongs to which action. - struct SKeyMap - { - EKEY_ACTION Action; - EKEY_CODE KeyCode; - }; - -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __S_KEY_MAP_H_INCLUDED__ +#define __S_KEY_MAP_H_INCLUDED__ + +#include "Keycodes.h" + +namespace irr +{ + + //! enumeration for key actions. Used for example in the FPS Camera. + enum EKEY_ACTION + { + EKA_MOVE_FORWARD = 0, + EKA_MOVE_BACKWARD, + EKA_STRAFE_LEFT, + EKA_STRAFE_RIGHT, + EKA_JUMP_UP, + EKA_COUNT, + + //! This value is not used. It only forces this enumeration to compile in 32 bit. + EKA_FORCE_32BIT = 0x7fffffff + }; + + //! Struct storing which key belongs to which action. + struct SKeyMap + { + EKEY_ACTION Action; + EKEY_CODE KeyCode; + }; + +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/SLight.h b/src/dep/include/irrlicht/SLight.h index 6ba059b..dfde9ef 100644 --- a/src/dep/include/irrlicht/SLight.h +++ b/src/dep/include/irrlicht/SLight.h @@ -1,72 +1,72 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_LIGHT_H_INCLUDED__ -#define __S_LIGHT_H_INCLUDED__ - -#include "SColor.h" - -namespace irr -{ -namespace video -{ - -//! Enumeration for different types of lights -enum E_LIGHT_TYPE -{ - //! point light, it has a position in space and radiates light in all directions - ELT_POINT, - - //! directional light, coming from a direction from an infinite distance - ELT_DIRECTIONAL -}; - -//! Names for light types -const c8* const LightTypeNames[] = -{ - "Point", - "Directional", - 0 -}; - -//! structure for holding data describing a dynamic point light. -/** ambient light and point lights are the only light supported -by the irrlicht engine. -*/ -struct SLight -{ - SLight() : AmbientColor(0.0f,0.0f,0.0f), DiffuseColor(1.0f, 1.0f, 1.0f), - SpecularColor(1.0f,1.0f,1.0f), Position(0.0f, 0.0f, 0.0f), Radius(100.0f), - CastShadows(true), Type(ELT_POINT) - {}; - - //! Ambient color emitted by the light - SColorf AmbientColor; - - //! Diffuse color emitted by the light. - /** This is the primary color you might want to set. */ - SColorf DiffuseColor; - - //! Specular color emitted by the light. - /** For details how to use specular highlights, see SMaterial::Shininess */ - SColorf SpecularColor; - - //! Position of the light. If Type is ELT_DIRECTIONAL, this is the direction vector the light is coming from. - core::vector3df Position; - - //! Radius of light. Everything within this radius be be lighted. - f32 Radius; - - //! Does the light cast shadows? - bool CastShadows; - - //! Type of the light. Default: ELT_POINT - E_LIGHT_TYPE Type; -}; - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __S_LIGHT_H_INCLUDED__ +#define __S_LIGHT_H_INCLUDED__ + +#include "SColor.h" + +namespace irr +{ +namespace video +{ + +//! Enumeration for different types of lights +enum E_LIGHT_TYPE +{ + //! point light, it has a position in space and radiates light in all directions + ELT_POINT, + + //! directional light, coming from a direction from an infinite distance + ELT_DIRECTIONAL +}; + +//! Names for light types +const c8* const LightTypeNames[] = +{ + "Point", + "Directional", + 0 +}; + +//! structure for holding data describing a dynamic point light. +/** ambient light and point lights are the only light supported +by the irrlicht engine. +*/ +struct SLight +{ + SLight() : AmbientColor(0.0f,0.0f,0.0f), DiffuseColor(1.0f, 1.0f, 1.0f), + SpecularColor(1.0f,1.0f,1.0f), Position(0.0f, 0.0f, 0.0f), Radius(100.0f), + CastShadows(true), Type(ELT_POINT) + {}; + + //! Ambient color emitted by the light + SColorf AmbientColor; + + //! Diffuse color emitted by the light. + /** This is the primary color you might want to set. */ + SColorf DiffuseColor; + + //! Specular color emitted by the light. + /** For details how to use specular highlights, see SMaterial::Shininess */ + SColorf SpecularColor; + + //! Position of the light. If Type is ELT_DIRECTIONAL, this is the direction vector the light is coming from. + core::vector3df Position; + + //! Radius of light. Everything within this radius be be lighted. + f32 Radius; + + //! Does the light cast shadows? + bool CastShadows; + + //! Type of the light. Default: ELT_POINT + E_LIGHT_TYPE Type; +}; + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/SMaterial.h b/src/dep/include/irrlicht/SMaterial.h index d3c9ca3..e4302ed 100644 --- a/src/dep/include/irrlicht/SMaterial.h +++ b/src/dep/include/irrlicht/SMaterial.h @@ -1,670 +1,670 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_MATERIAL_H_INCLUDED__ -#define __S_MATERIAL_H_INCLUDED__ - -#include "SColor.h" -#include "ITexture.h" -#include "matrix4.h" -#include "irrArray.h" - -namespace irr -{ -namespace video -{ - //! Abstracted and easy to use fixed function/programmable pipeline material modes. - enum E_MATERIAL_TYPE - { - //! Standard solid material. Only first texture is used, which is - //! supposed to be the diffuse material. - EMT_SOLID = 0, - - //! Solid material with 2 texture layers. The second is blended onto the - //! first using the alpha value of the vertex colors. - //! This material is currently not implemented in OpenGL, but it - //! works with DirectX. - EMT_SOLID_2_LAYER, - - //! Material type with standard lightmap technique: - //! There should be 2 textures: The first texture layer is a diffuse map, - //! the second is a light map. Vertex light is ignored. - EMT_LIGHTMAP, - - //! Material type with lightmap technique like EMT_LIGHTMAP, but - //! lightmap and diffuse texture are not modulated, but added instead. - EMT_LIGHTMAP_ADD, - - //! Material type with standard lightmap technique: - //! There should be 2 textures: The first texture layer is a diffuse map, - //! the second is a light map. Vertex light is ignored. - //! The texture colors are effectively multiplyied by 2 for brightening. - //! like known in DirectX as D3DTOP_MODULATE2X. - EMT_LIGHTMAP_M2, - - //! Material type with standard lightmap technique: - //! There should be 2 textures: The first texture layer is a diffuse map, - //! the second is a light map. Vertex light is ignored. - //! The texture colors are effectively multiplyied by 4 for brightening. - //! like known in DirectX as D3DTOP_MODULATE4X. - EMT_LIGHTMAP_M4, - - //! Like EMT_LIGHTMAP, but also supports dynamic lighting. - EMT_LIGHTMAP_LIGHTING, - - //! Like EMT_LIGHTMAP_M2, but also supports dynamic lighting. - EMT_LIGHTMAP_LIGHTING_M2, - - //! Like EMT_LIGHTMAP_4, but also supports dynamic lighting. - EMT_LIGHTMAP_LIGHTING_M4, - - //! Detail mapped material. The first texture is diffuse color map, the - //! second is added to this and usually displayed with a bigger scale value - //! so that it adds more detail. The detail map is added to the diffuse map using - //! ADD_SIGNED, so that it is possible to add and substract color from the diffuse - //! map. For example a value of (127,127,127) will not change the appearance of - //! the diffuse map at all. - //! Often used for terrain rendering. - EMT_DETAIL_MAP, - - //! Makes the material look like it was reflection the environment - //! around it. To make this possible, a texture called 'sphere map' - //! is used, which must be set as Textures[0]. - EMT_SPHERE_MAP, - - //! A reflecting material with an - //! optional additional non reflecting texture layer. The reflection - //! map should be set as Texture 1. - EMT_REFLECTION_2_LAYER, - - //! A transparent material. Only the first texture is used. - //! The new color is calculated by simply adding the source color and - //! the dest color. This means if for example a billboard using a texture with - //! black background and a red circle on it is drawn with this material, the - //! result is that only the red circle will be drawn a little bit transparent, - //! and everything which was black is 100% transparent and not visible. - //! This material type is useful for e.g. particle effects. - EMT_TRANSPARENT_ADD_COLOR, - - //! Makes the material transparent based on the texture alpha channel. - //! The final color is blended together from the destination color and the - //! texture color, using the alpha channel value as blend factor. - //! Only first texture is used. If you are using this material with small - //! textures, it is a good idea to load the texture in 32 bit - //! mode (video::IVideoDriver::setTextureCreationFlag()). - //! Also, an alpha ref is used, which can be manipulated using SMaterial::MaterialTypeParam. - //! If set to 0, the alpha ref gets its default value which is 0.5f and which means - //! that pixels with an alpha value >127 will be written, others not. In other, simple - //! words: this value controls how sharp the edges become when going from a - //! transparent to a solid spot on the texture. - EMT_TRANSPARENT_ALPHA_CHANNEL, - - //! Makes the material transparent based on the texture alpha channel. - //! If the alpha channel value is greater than 127, a pixel is written to the - //! target, otherwise not. This material does not use alpha blending - //! and is a lot faster than EMT_TRANSPARENT_ALPHA_CHANNEL. It - //! is ideal for drawing stuff like leafes of plants, because the borders - //! are not blurry but sharp. - //! Only first texture is used. If you are using this material with small - //! textures and 3d object, it is a good idea to load the texture in 32 bit - //! mode (video::IVideoDriver::setTextureCreationFlag()). - EMT_TRANSPARENT_ALPHA_CHANNEL_REF, - - //! Makes the material transparent based on the vertex alpha value. - EMT_TRANSPARENT_VERTEX_ALPHA, - - //! A transparent reflecting material with an - //! optional additional non reflecting texture layer. The reflection - //! map should be set as Texture 1. The transparency depends on the - //! alpha value in the vertex colors. A texture which will not reflect - //! can be set als Texture 2. - //! Please note that this material type is currently not 100% implemented - //! in OpenGL. It works in Direct3D. - EMT_TRANSPARENT_REFLECTION_2_LAYER, - - //! A solid normal map renderer. First texture is the color map, the - //! second should be the normal map. Note that you should use this material - //! only when drawing geometry consisting of vertices of type S3DVertexTangents - //! (EVT_TANGENTS). You can convert any mesh into this format using - //! IMeshManipulator::createMeshWithTangents() (See SpecialFX2 Tutorial). - //! This shader runs on vertex shader 1.1 and pixel shader 1.1 capable hardware and - //! falls back on a fixed function lighted material if this hardware is not available. - //! Only two lights are supported by this shader, if there are more, the nearest two - //! are chosen. Currently, this shader is only implemented for the D3D8 and D3D9 renderers. - EMT_NORMAL_MAP_SOLID, - - //! A transparent normal map renderer. First texture is the color map, the - //! second should be the normal map. Note that you should use this material - //! only when drawing geometry consisting of vertices of type S3DVertexTangents - //! (EVT_TANGENTS). You can convert any mesh into this format using - //! IMeshManipulator::createMeshWithTangents() (See SpecialFX2 Tutorial). - //! This shader runs on vertex shader 1.1 and pixel shader 1.1 capable hardware and - //! falls back on a fixed function lighted material if this hardware is not available. - //! Only two lights are supported by this shader, if there are more, the nearest two - //! are chosen. Currently, this shader is only implemented for the D3D8 and D3D9 renderers. - EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR, - - //! A transparent (based on the vertex alpha value) normal map renderer. - //! First texture is the color map, the - //! second should be the normal map. Note that you should use this material - //! only when drawing geometry consisting of vertices of type S3DVertexTangents - //! (EVT_TANGENTS). You can convert any mesh into this format using - //! IMeshManipulator::createMeshWithTangents() (See SpecialFX2 Tutorial). - //! This shader runs on vertex shader 1.1 and pixel shader 1.1 capable hardware and - //! falls back on a fixed function lighted material if this hardware is not available. - //! Only two lights are supported by this shader, if there are more, the nearest two - //! are chosen. Currently, this shader is only implemented for the D3D8 and D3D9 renderers. - EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA, - - //! Just like EMT_NORMAL_MAP_SOLID, but uses parallax mapping too, which - //! looks a lot more realistic. This only works when the hardware supports at - //! least vertex shader 1.1 and pixel shader 1.4. - //! First texture is the color map, the second should be the normal map. - //! The normal map texture should contain the height value in the - //! alpha component. The IVideoDriver::makeNormalMapTexture() method writes - //! this value automaticly when creating normal maps from a heightmap when using a 32 bit - //! texture. - //! The height scale of the material (affecting the bumpiness) is being controlled - //! by the SMaterial::MaterialTypeParam member. - //! If set to zero, the default value (0.02f) will be applied. Otherwise - //! the value set in SMaterial::MaterialTypeParam is taken. This value depends on with which - //! scale the texture is mapped on the material. Too high or low values of MaterialTypeParam - //! can result in strange artifacts. - EMT_PARALLAX_MAP_SOLID, - - //! A material just like EMT_PARALLAX_MAP_SOLID, but it is transparent, using - //! EMT_TRANSPARENT_ADD_COLOR as base material. - EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR, - - //! A material just like EMT_PARALLAX_MAP_SOLID, but it is transparent, using - //! EMT_TRANSPARENT_VERTEX_ALPHA as base material. - EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA, - - //! BlendFunc = source * sourceFactor + dest * destFactor ( E_BLEND_FUNC ) - //! Using only Textures[0]. generic Blender - EMT_ONETEXTURE_BLEND, - - //! This value is not used. It only forces this enumeration to compile in 32 bit. - EMT_FORCE_32BIT = 0x7fffffff - }; - - //! Flag for EMT_ONETEXTURE_BLEND, ( BlendFactor ) - //! BlendFunc = source * sourceFactor + dest * destFactor - enum E_BLEND_FACTOR - { - EBF_ZERO = 0, // src & dest (0, 0, 0, 0) - EBF_ONE, // src & dest (1, 1, 1, 1) - EBF_DST_COLOR, // src (destR, destG, destB, destA) - EBF_ONE_MINUS_DST_COLOR, // src (1-destR, 1-destG, 1-destB, 1-destA) - EBF_SRC_COLOR, // dest (srcR, srcG, srcB, srcA) - EBF_ONE_MINUS_SRC_COLOR, // dest (1-srcR, 1-srcG, 1-srcB, 1-srcA) - EBF_SRC_ALPHA, // src & dest (srcA, srcA, srcA, srcA) - EBF_ONE_MINUS_SRC_ALPHA, // src & dest (1-srcA, 1-srcA, 1-srcA, 1-srcA) - EBF_DST_ALPHA, // src & dest (destA, destA, destA, destA) - EBF_ONE_MINUS_DST_ALPHA, // src & dest (1-destA, 1-destA, 1-destA, 1-destA) - EBF_SRC_ALPHA_SATURATE // src (min(srcA, 1-destA), idem, ...) - }; - - //! Texture coord clamp mode - enum E_TEXTURE_CLAMP - { - ETC_REPEAT = 0, - ETC_CLAMP, - ETC_CLAMP_TO_EDGE, - ETC_CLAMP_TO_BORDER, - ETC_MIRROR - }; - static const char* const aTextureClampNames[] = { - "texture_clamp_repeat", - "texture_clamp_clamp", - "texture_clamp_clamp_to_edge", - "texture_clamp_clamp_to_border", - "texture_clamp_mirror", 0}; - - //! MaterialTypeParam: eg. DirectX: D3DTOP_MODULATE, D3DTOP_MODULATE2X, D3DTOP_MODULATE4X - enum E_MODULATE_FUNC - { - EMFN_MODULATE_1X = 1, - EMFN_MODULATE_2X = 2, - EMFN_MODULATE_4X = 4 - }; - - //! EMT_ONETEXTURE_BLEND: pack srcFact & dstFact and Modulo to MaterialTypeParam - inline f32 pack_texureBlendFunc ( const E_BLEND_FACTOR srcFact, const E_BLEND_FACTOR dstFact, const E_MODULATE_FUNC modulate ) - { - u32 state = modulate << 16 | srcFact << 8 | dstFact; - return (f32&) state; - } - - //! EMT_ONETEXTURE_BLEND: unpack srcFact & dstFact and Modulo to MaterialTypeParam - inline void unpack_texureBlendFunc ( E_BLEND_FACTOR &srcFact, E_BLEND_FACTOR &dstFact, E_MODULATE_FUNC &modulo, const f32 param ) - { - u32 state = (u32&)(param); - modulo = E_MODULATE_FUNC ( ( state & 0x00FF0000 ) >> 16 ); - srcFact = E_BLEND_FACTOR ( ( state & 0x0000FF00 ) >> 8 ); - dstFact = E_BLEND_FACTOR ( ( state & 0x000000FF ) ); - } - - //! Material flags - enum E_MATERIAL_FLAG - { - //! Draw as wireframe or filled triangles? Default: false - EMF_WIREFRAME = 0, - - //! Draw as point cloud or filled triangles? Default: false - EMF_POINTCLOUD, - - //! Flat or Gouraud shading? Default: true - EMF_GOURAUD_SHADING, - - //! Will this material be lighted? Default: true - EMF_LIGHTING, - - //! Is the ZBuffer enabled? Default: true - EMF_ZBUFFER, - - //! May be written to the zbuffer or is it readonly. Default: true - //! This flag is ignored, if the material type is a transparent type. - EMF_ZWRITE_ENABLE, - - //! Is backfaceculling enabled? Default: true - EMF_BACK_FACE_CULLING, - - //! Is bilinear filtering enabled? Default: true - EMF_BILINEAR_FILTER, - - //! Is trilinear filtering enabled? Default: false - //! If the trilinear filter flag is enabled, - //! the bilinear filtering flag is ignored. - EMF_TRILINEAR_FILTER, - - //! Is anisotropic filtering? Default: false - //! In Irrlicht you can use anisotropic texture filtering in - //! conjunction with bilinear or trilinear texture filtering - //! to improve rendering results. Primitives will look less - //! blurry with this flag switched on. - EMF_ANISOTROPIC_FILTER, - - //! Is fog enabled? Default: false - EMF_FOG_ENABLE, - - //! Normalizes normals.You can enable this if you need - //! to scale a dynamic lighted model. Usually, its normals will get scaled - //! too then and it will get darker. If you enable the EMF_NORMALIZE_NORMALS flag, - //! the normals will be normalized again, and the model will look as bright as it should. - EMF_NORMALIZE_NORMALS, - - //! Access to all layers texture wrap settings. Overwrites separate layer settings. - EMF_TEXTURE_WRAP, - - //! This is not a flag, but a value indicating how much flags there are. - EMF_MATERIAL_FLAG_COUNT - }; - - //! Maximum number of texture an SMaterial can have. - const u32 MATERIAL_MAX_TEXTURES = 4; - - - //! struct for holding parameters for a material renderer - class SMaterial - { - public: - //! default constructor, creates a solid material with standard colors - SMaterial() - : MaterialType(EMT_SOLID), AmbientColor(255,255,255,255), DiffuseColor(255,255,255,255), - EmissiveColor(0,0,0,0), SpecularColor(255,255,255,255), - Shininess(0.0f), MaterialTypeParam(0.0f), MaterialTypeParam2(0.0f), Thickness(1.0f), - Wireframe(false), PointCloud(false), GouraudShading(true), Lighting(true), - ZBuffer(true), ZWriteEnable(true), BackfaceCulling(true), - BilinearFilter(true), TrilinearFilter(false), AnisotropicFilter(false), - FogEnable(false), NormalizeNormals(false) - { - for (u32 i=0; igetMaterial(0).Shininess = 20.0f; - \endcode - - You can also change the color of the highlights using - \code - sceneNode->getMaterial(0).SpecularColor.set(255,255,255,255); - \endcode - - The specular color of the dynamic lights (SLight::SpecularColor) will influence - the the highlight color too, but they are set to a useful value by default when - creating the light scene node. Here is a simple example on how - to use specular highlights: - \code - // load and display mesh - scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( - smgr->getMesh("data/faerie.md2")); - node->setMaterialTexture(0, driver->getTexture("data/Faerie2.pcx")); // set diffuse texture - node->setMaterialFlag(video::EMF_LIGHTING, true); // enable dynamic lighting - node->getMaterial(0).Shininess = 20.0f; // set size of specular highlights - - // add white light - scene::ILightSceneNode* light = smgr->addLightSceneNode(0, - core::vector3df(5,5,5), video::SColorf(1.0f, 1.0f, 1.0f)); - \endcode */ - f32 Shininess; - - //! Free parameter dependend on the material type. - /** Mostly ignored, used for example in EMT_PARALLAX_MAP_SOLID - and EMT_TRANSPARENT_ALPHA_CHANNEL. */ - f32 MaterialTypeParam; - - //! Second free parameter dependend on the material type. - /** Mostly ignored. */ - f32 MaterialTypeParam2; - - //! Thickness of non-3dimensional elements such as lines and points. - f32 Thickness; - - //! Texture layer array. - ITexture* Textures[MATERIAL_MAX_TEXTURES]; - - //! Texture Matrix array - //! Do not acces the elements directly as the internal - //! ressource management has to cope with Null pointers etc. - core::matrix4* TextureMatrix[MATERIAL_MAX_TEXTURES]; - - //! Texture Address Mode - E_TEXTURE_CLAMP TextureWrap[MATERIAL_MAX_TEXTURES]; - - //! material flag union. - /** This enables the user to access the - material flag using e.g: material.Wireframe = true or - material.setFlag(EMF_WIREFRAME, true); */ - struct - { - //! Draw as wireframe or filled triangles? Default: false - bool Wireframe; - - //! Draw as point cloud or filled triangles? Default: false - bool PointCloud; - - //! Flat or Gouraud shading? Default: true - bool GouraudShading; - - //! Will this material be lighted? Default: true - bool Lighting; - - //! Is the ZBuffer enabled? Default: true - //! Changed from Bool to Integer - // ( 0 == ZBuffer Off, 1 == ZBuffer LessEqual, 2 == ZBuffer Equal ) - u32 ZBuffer; - - //! May be written to the zbuffer or is it readonly. - /** Default: 1 This flag is ignored, if the MaterialType - is a transparent type. */ - bool ZWriteEnable; - - //! Is backfaceculling enabled? Default: true - bool BackfaceCulling; - - //! Is bilinear filtering enabled? Default: true - bool BilinearFilter; - - //! Is trilinear filtering enabled? Default: false - /** If the trilinear filter flag is enabled, - the bilinear filtering flag is ignored. */ - bool TrilinearFilter; - - //! Is anisotropic filtering enabled? Default: false - /** In Irrlicht you can use anisotropic texture filtering - in conjunction with bilinear or trilinear texture - filtering to improve rendering results. Primitives - will look less blurry with this flag switched on. */ - bool AnisotropicFilter; - - //! Is fog enabled? Default: false - bool FogEnable; - - //! Should normals be normalized? Default: false - bool NormalizeNormals; - }; - - core::matrix4& getTextureMatrix(u32 i) - { - if (i=MATERIAL_MAX_TEXTURES) - return; - if (!TextureMatrix[i]) - TextureMatrix[i] = new core::matrix4(mat); - else - *TextureMatrix[i] = mat; - } - - void setFlag(E_MATERIAL_FLAG flag, bool value) - { - switch (flag) - { - case EMF_WIREFRAME: - Wireframe = value; break; - case EMF_POINTCLOUD: - PointCloud = value; break; - case EMF_GOURAUD_SHADING: - GouraudShading = value; break; - case EMF_LIGHTING: - Lighting = value; break; - case EMF_ZBUFFER: - ZBuffer = value; break; - case EMF_ZWRITE_ENABLE: - ZWriteEnable = value; break; - case EMF_BACK_FACE_CULLING: - BackfaceCulling = value; break; - case EMF_BILINEAR_FILTER: - BilinearFilter = value; break; - case EMF_TRILINEAR_FILTER: - TrilinearFilter = value; break; - case EMF_ANISOTROPIC_FILTER: - AnisotropicFilter = value; break; - case EMF_FOG_ENABLE: - FogEnable = value; break; - case EMF_NORMALIZE_NORMALS: - NormalizeNormals = value; break; - case EMF_TEXTURE_WRAP: - TextureWrap[0] = TextureWrap[1] = TextureWrap[2] = TextureWrap[3] = (E_TEXTURE_CLAMP)value; - break; - default: - break; - } - } - - bool getFlag(E_MATERIAL_FLAG flag) const - { - switch (flag) - { - case EMF_WIREFRAME: - return Wireframe; break; - case EMF_POINTCLOUD: - return PointCloud; break; - case EMF_GOURAUD_SHADING: - return GouraudShading; break; - case EMF_LIGHTING: - return Lighting; break; - case EMF_ZBUFFER: - return ZBuffer!=0; break; - case EMF_ZWRITE_ENABLE: - return ZWriteEnable; break; - case EMF_BACK_FACE_CULLING: - return BackfaceCulling; break; - case EMF_BILINEAR_FILTER: - return BilinearFilter; break; - case EMF_TRILINEAR_FILTER: - return TrilinearFilter; break; - case EMF_ANISOTROPIC_FILTER: - return AnisotropicFilter; break; - case EMF_FOG_ENABLE: - return FogEnable; break; - case EMF_NORMALIZE_NORMALS: - return NormalizeNormals; break; - case EMF_TEXTURE_WRAP: - return !(TextureWrap[0] || TextureWrap[1] || TextureWrap[2] || TextureWrap[3]); - case EMF_MATERIAL_FLAG_COUNT: - break; - } - - return false; - } - - //! Compare operator - inline bool operator!=(const SMaterial& b) const - { - return - Textures[0] != b.Textures[0] || - Textures[1] != b.Textures[1] || - Textures[2] != b.Textures[2] || - Textures[3] != b.Textures[3] || - MaterialType != b.MaterialType || - AmbientColor != b.AmbientColor || - DiffuseColor != b.DiffuseColor || - EmissiveColor != b.EmissiveColor || - SpecularColor != b.SpecularColor || - Shininess != b.Shininess || - MaterialTypeParam != b.MaterialTypeParam || - MaterialTypeParam2 != b.MaterialTypeParam2 || - Thickness != b.Thickness || - Wireframe != b.Wireframe || - PointCloud != b.PointCloud || - GouraudShading != b.GouraudShading || - Lighting != b.Lighting || - ZBuffer != b.ZBuffer || - ZWriteEnable != b.ZWriteEnable || - BackfaceCulling != b.BackfaceCulling || - BilinearFilter != b.BilinearFilter || - TrilinearFilter != b.TrilinearFilter || - AnisotropicFilter != b.AnisotropicFilter || - FogEnable != b.FogEnable || - NormalizeNormals != b.NormalizeNormals || - TextureWrap[0] != b.TextureWrap[0] || - TextureWrap[1] != b.TextureWrap[1] || - TextureWrap[2] != b.TextureWrap[2] || - TextureWrap[3] != b.TextureWrap[3] || - TextureMatrix[0] != b.TextureMatrix[0] || - TextureMatrix[1] != b.TextureMatrix[1] || - TextureMatrix[2] != b.TextureMatrix[2] || - TextureMatrix[3] != b.TextureMatrix[3]; - } - inline bool operator==(const SMaterial& b) const - { return !(b!=*this); } - }; - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __S_MATERIAL_H_INCLUDED__ +#define __S_MATERIAL_H_INCLUDED__ + +#include "SColor.h" +#include "ITexture.h" +#include "matrix4.h" +#include "irrArray.h" + +namespace irr +{ +namespace video +{ + //! Abstracted and easy to use fixed function/programmable pipeline material modes. + enum E_MATERIAL_TYPE + { + //! Standard solid material. Only first texture is used, which is + //! supposed to be the diffuse material. + EMT_SOLID = 0, + + //! Solid material with 2 texture layers. The second is blended onto the + //! first using the alpha value of the vertex colors. + //! This material is currently not implemented in OpenGL, but it + //! works with DirectX. + EMT_SOLID_2_LAYER, + + //! Material type with standard lightmap technique: + //! There should be 2 textures: The first texture layer is a diffuse map, + //! the second is a light map. Vertex light is ignored. + EMT_LIGHTMAP, + + //! Material type with lightmap technique like EMT_LIGHTMAP, but + //! lightmap and diffuse texture are not modulated, but added instead. + EMT_LIGHTMAP_ADD, + + //! Material type with standard lightmap technique: + //! There should be 2 textures: The first texture layer is a diffuse map, + //! the second is a light map. Vertex light is ignored. + //! The texture colors are effectively multiplyied by 2 for brightening. + //! like known in DirectX as D3DTOP_MODULATE2X. + EMT_LIGHTMAP_M2, + + //! Material type with standard lightmap technique: + //! There should be 2 textures: The first texture layer is a diffuse map, + //! the second is a light map. Vertex light is ignored. + //! The texture colors are effectively multiplyied by 4 for brightening. + //! like known in DirectX as D3DTOP_MODULATE4X. + EMT_LIGHTMAP_M4, + + //! Like EMT_LIGHTMAP, but also supports dynamic lighting. + EMT_LIGHTMAP_LIGHTING, + + //! Like EMT_LIGHTMAP_M2, but also supports dynamic lighting. + EMT_LIGHTMAP_LIGHTING_M2, + + //! Like EMT_LIGHTMAP_4, but also supports dynamic lighting. + EMT_LIGHTMAP_LIGHTING_M4, + + //! Detail mapped material. The first texture is diffuse color map, the + //! second is added to this and usually displayed with a bigger scale value + //! so that it adds more detail. The detail map is added to the diffuse map using + //! ADD_SIGNED, so that it is possible to add and substract color from the diffuse + //! map. For example a value of (127,127,127) will not change the appearance of + //! the diffuse map at all. + //! Often used for terrain rendering. + EMT_DETAIL_MAP, + + //! Makes the material look like it was reflection the environment + //! around it. To make this possible, a texture called 'sphere map' + //! is used, which must be set as Textures[0]. + EMT_SPHERE_MAP, + + //! A reflecting material with an + //! optional additional non reflecting texture layer. The reflection + //! map should be set as Texture 1. + EMT_REFLECTION_2_LAYER, + + //! A transparent material. Only the first texture is used. + //! The new color is calculated by simply adding the source color and + //! the dest color. This means if for example a billboard using a texture with + //! black background and a red circle on it is drawn with this material, the + //! result is that only the red circle will be drawn a little bit transparent, + //! and everything which was black is 100% transparent and not visible. + //! This material type is useful for e.g. particle effects. + EMT_TRANSPARENT_ADD_COLOR, + + //! Makes the material transparent based on the texture alpha channel. + //! The final color is blended together from the destination color and the + //! texture color, using the alpha channel value as blend factor. + //! Only first texture is used. If you are using this material with small + //! textures, it is a good idea to load the texture in 32 bit + //! mode (video::IVideoDriver::setTextureCreationFlag()). + //! Also, an alpha ref is used, which can be manipulated using SMaterial::MaterialTypeParam. + //! If set to 0, the alpha ref gets its default value which is 0.5f and which means + //! that pixels with an alpha value >127 will be written, others not. In other, simple + //! words: this value controls how sharp the edges become when going from a + //! transparent to a solid spot on the texture. + EMT_TRANSPARENT_ALPHA_CHANNEL, + + //! Makes the material transparent based on the texture alpha channel. + //! If the alpha channel value is greater than 127, a pixel is written to the + //! target, otherwise not. This material does not use alpha blending + //! and is a lot faster than EMT_TRANSPARENT_ALPHA_CHANNEL. It + //! is ideal for drawing stuff like leafes of plants, because the borders + //! are not blurry but sharp. + //! Only first texture is used. If you are using this material with small + //! textures and 3d object, it is a good idea to load the texture in 32 bit + //! mode (video::IVideoDriver::setTextureCreationFlag()). + EMT_TRANSPARENT_ALPHA_CHANNEL_REF, + + //! Makes the material transparent based on the vertex alpha value. + EMT_TRANSPARENT_VERTEX_ALPHA, + + //! A transparent reflecting material with an + //! optional additional non reflecting texture layer. The reflection + //! map should be set as Texture 1. The transparency depends on the + //! alpha value in the vertex colors. A texture which will not reflect + //! can be set als Texture 2. + //! Please note that this material type is currently not 100% implemented + //! in OpenGL. It works in Direct3D. + EMT_TRANSPARENT_REFLECTION_2_LAYER, + + //! A solid normal map renderer. First texture is the color map, the + //! second should be the normal map. Note that you should use this material + //! only when drawing geometry consisting of vertices of type S3DVertexTangents + //! (EVT_TANGENTS). You can convert any mesh into this format using + //! IMeshManipulator::createMeshWithTangents() (See SpecialFX2 Tutorial). + //! This shader runs on vertex shader 1.1 and pixel shader 1.1 capable hardware and + //! falls back on a fixed function lighted material if this hardware is not available. + //! Only two lights are supported by this shader, if there are more, the nearest two + //! are chosen. Currently, this shader is only implemented for the D3D8 and D3D9 renderers. + EMT_NORMAL_MAP_SOLID, + + //! A transparent normal map renderer. First texture is the color map, the + //! second should be the normal map. Note that you should use this material + //! only when drawing geometry consisting of vertices of type S3DVertexTangents + //! (EVT_TANGENTS). You can convert any mesh into this format using + //! IMeshManipulator::createMeshWithTangents() (See SpecialFX2 Tutorial). + //! This shader runs on vertex shader 1.1 and pixel shader 1.1 capable hardware and + //! falls back on a fixed function lighted material if this hardware is not available. + //! Only two lights are supported by this shader, if there are more, the nearest two + //! are chosen. Currently, this shader is only implemented for the D3D8 and D3D9 renderers. + EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR, + + //! A transparent (based on the vertex alpha value) normal map renderer. + //! First texture is the color map, the + //! second should be the normal map. Note that you should use this material + //! only when drawing geometry consisting of vertices of type S3DVertexTangents + //! (EVT_TANGENTS). You can convert any mesh into this format using + //! IMeshManipulator::createMeshWithTangents() (See SpecialFX2 Tutorial). + //! This shader runs on vertex shader 1.1 and pixel shader 1.1 capable hardware and + //! falls back on a fixed function lighted material if this hardware is not available. + //! Only two lights are supported by this shader, if there are more, the nearest two + //! are chosen. Currently, this shader is only implemented for the D3D8 and D3D9 renderers. + EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA, + + //! Just like EMT_NORMAL_MAP_SOLID, but uses parallax mapping too, which + //! looks a lot more realistic. This only works when the hardware supports at + //! least vertex shader 1.1 and pixel shader 1.4. + //! First texture is the color map, the second should be the normal map. + //! The normal map texture should contain the height value in the + //! alpha component. The IVideoDriver::makeNormalMapTexture() method writes + //! this value automaticly when creating normal maps from a heightmap when using a 32 bit + //! texture. + //! The height scale of the material (affecting the bumpiness) is being controlled + //! by the SMaterial::MaterialTypeParam member. + //! If set to zero, the default value (0.02f) will be applied. Otherwise + //! the value set in SMaterial::MaterialTypeParam is taken. This value depends on with which + //! scale the texture is mapped on the material. Too high or low values of MaterialTypeParam + //! can result in strange artifacts. + EMT_PARALLAX_MAP_SOLID, + + //! A material just like EMT_PARALLAX_MAP_SOLID, but it is transparent, using + //! EMT_TRANSPARENT_ADD_COLOR as base material. + EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR, + + //! A material just like EMT_PARALLAX_MAP_SOLID, but it is transparent, using + //! EMT_TRANSPARENT_VERTEX_ALPHA as base material. + EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA, + + //! BlendFunc = source * sourceFactor + dest * destFactor ( E_BLEND_FUNC ) + //! Using only Textures[0]. generic Blender + EMT_ONETEXTURE_BLEND, + + //! This value is not used. It only forces this enumeration to compile in 32 bit. + EMT_FORCE_32BIT = 0x7fffffff + }; + + //! Flag for EMT_ONETEXTURE_BLEND, ( BlendFactor ) + //! BlendFunc = source * sourceFactor + dest * destFactor + enum E_BLEND_FACTOR + { + EBF_ZERO = 0, // src & dest (0, 0, 0, 0) + EBF_ONE, // src & dest (1, 1, 1, 1) + EBF_DST_COLOR, // src (destR, destG, destB, destA) + EBF_ONE_MINUS_DST_COLOR, // src (1-destR, 1-destG, 1-destB, 1-destA) + EBF_SRC_COLOR, // dest (srcR, srcG, srcB, srcA) + EBF_ONE_MINUS_SRC_COLOR, // dest (1-srcR, 1-srcG, 1-srcB, 1-srcA) + EBF_SRC_ALPHA, // src & dest (srcA, srcA, srcA, srcA) + EBF_ONE_MINUS_SRC_ALPHA, // src & dest (1-srcA, 1-srcA, 1-srcA, 1-srcA) + EBF_DST_ALPHA, // src & dest (destA, destA, destA, destA) + EBF_ONE_MINUS_DST_ALPHA, // src & dest (1-destA, 1-destA, 1-destA, 1-destA) + EBF_SRC_ALPHA_SATURATE // src (min(srcA, 1-destA), idem, ...) + }; + + //! Texture coord clamp mode + enum E_TEXTURE_CLAMP + { + ETC_REPEAT = 0, + ETC_CLAMP, + ETC_CLAMP_TO_EDGE, + ETC_CLAMP_TO_BORDER, + ETC_MIRROR + }; + static const char* const aTextureClampNames[] = { + "texture_clamp_repeat", + "texture_clamp_clamp", + "texture_clamp_clamp_to_edge", + "texture_clamp_clamp_to_border", + "texture_clamp_mirror", 0}; + + //! MaterialTypeParam: eg. DirectX: D3DTOP_MODULATE, D3DTOP_MODULATE2X, D3DTOP_MODULATE4X + enum E_MODULATE_FUNC + { + EMFN_MODULATE_1X = 1, + EMFN_MODULATE_2X = 2, + EMFN_MODULATE_4X = 4 + }; + + //! EMT_ONETEXTURE_BLEND: pack srcFact & dstFact and Modulo to MaterialTypeParam + inline f32 pack_texureBlendFunc ( const E_BLEND_FACTOR srcFact, const E_BLEND_FACTOR dstFact, const E_MODULATE_FUNC modulate ) + { + u32 state = modulate << 16 | srcFact << 8 | dstFact; + return (f32&) state; + } + + //! EMT_ONETEXTURE_BLEND: unpack srcFact & dstFact and Modulo to MaterialTypeParam + inline void unpack_texureBlendFunc ( E_BLEND_FACTOR &srcFact, E_BLEND_FACTOR &dstFact, E_MODULATE_FUNC &modulo, const f32 param ) + { + u32 state = (u32&)(param); + modulo = E_MODULATE_FUNC ( ( state & 0x00FF0000 ) >> 16 ); + srcFact = E_BLEND_FACTOR ( ( state & 0x0000FF00 ) >> 8 ); + dstFact = E_BLEND_FACTOR ( ( state & 0x000000FF ) ); + } + + //! Material flags + enum E_MATERIAL_FLAG + { + //! Draw as wireframe or filled triangles? Default: false + EMF_WIREFRAME = 0, + + //! Draw as point cloud or filled triangles? Default: false + EMF_POINTCLOUD, + + //! Flat or Gouraud shading? Default: true + EMF_GOURAUD_SHADING, + + //! Will this material be lighted? Default: true + EMF_LIGHTING, + + //! Is the ZBuffer enabled? Default: true + EMF_ZBUFFER, + + //! May be written to the zbuffer or is it readonly. Default: true + //! This flag is ignored, if the material type is a transparent type. + EMF_ZWRITE_ENABLE, + + //! Is backfaceculling enabled? Default: true + EMF_BACK_FACE_CULLING, + + //! Is bilinear filtering enabled? Default: true + EMF_BILINEAR_FILTER, + + //! Is trilinear filtering enabled? Default: false + //! If the trilinear filter flag is enabled, + //! the bilinear filtering flag is ignored. + EMF_TRILINEAR_FILTER, + + //! Is anisotropic filtering? Default: false + //! In Irrlicht you can use anisotropic texture filtering in + //! conjunction with bilinear or trilinear texture filtering + //! to improve rendering results. Primitives will look less + //! blurry with this flag switched on. + EMF_ANISOTROPIC_FILTER, + + //! Is fog enabled? Default: false + EMF_FOG_ENABLE, + + //! Normalizes normals.You can enable this if you need + //! to scale a dynamic lighted model. Usually, its normals will get scaled + //! too then and it will get darker. If you enable the EMF_NORMALIZE_NORMALS flag, + //! the normals will be normalized again, and the model will look as bright as it should. + EMF_NORMALIZE_NORMALS, + + //! Access to all layers texture wrap settings. Overwrites separate layer settings. + EMF_TEXTURE_WRAP, + + //! This is not a flag, but a value indicating how much flags there are. + EMF_MATERIAL_FLAG_COUNT + }; + + //! Maximum number of texture an SMaterial can have. + const u32 MATERIAL_MAX_TEXTURES = 4; + + + //! struct for holding parameters for a material renderer + class SMaterial + { + public: + //! default constructor, creates a solid material with standard colors + SMaterial() + : MaterialType(EMT_SOLID), AmbientColor(255,255,255,255), DiffuseColor(255,255,255,255), + EmissiveColor(0,0,0,0), SpecularColor(255,255,255,255), + Shininess(0.0f), MaterialTypeParam(0.0f), MaterialTypeParam2(0.0f), Thickness(1.0f), + Wireframe(false), PointCloud(false), GouraudShading(true), Lighting(true), + ZBuffer(true), ZWriteEnable(true), BackfaceCulling(true), + BilinearFilter(true), TrilinearFilter(false), AnisotropicFilter(false), + FogEnable(false), NormalizeNormals(false) + { + for (u32 i=0; igetMaterial(0).Shininess = 20.0f; + \endcode + + You can also change the color of the highlights using + \code + sceneNode->getMaterial(0).SpecularColor.set(255,255,255,255); + \endcode + + The specular color of the dynamic lights (SLight::SpecularColor) will influence + the the highlight color too, but they are set to a useful value by default when + creating the light scene node. Here is a simple example on how + to use specular highlights: + \code + // load and display mesh + scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( + smgr->getMesh("data/faerie.md2")); + node->setMaterialTexture(0, driver->getTexture("data/Faerie2.pcx")); // set diffuse texture + node->setMaterialFlag(video::EMF_LIGHTING, true); // enable dynamic lighting + node->getMaterial(0).Shininess = 20.0f; // set size of specular highlights + + // add white light + scene::ILightSceneNode* light = smgr->addLightSceneNode(0, + core::vector3df(5,5,5), video::SColorf(1.0f, 1.0f, 1.0f)); + \endcode */ + f32 Shininess; + + //! Free parameter dependend on the material type. + /** Mostly ignored, used for example in EMT_PARALLAX_MAP_SOLID + and EMT_TRANSPARENT_ALPHA_CHANNEL. */ + f32 MaterialTypeParam; + + //! Second free parameter dependend on the material type. + /** Mostly ignored. */ + f32 MaterialTypeParam2; + + //! Thickness of non-3dimensional elements such as lines and points. + f32 Thickness; + + //! Texture layer array. + ITexture* Textures[MATERIAL_MAX_TEXTURES]; + + //! Texture Matrix array + //! Do not acces the elements directly as the internal + //! ressource management has to cope with Null pointers etc. + core::matrix4* TextureMatrix[MATERIAL_MAX_TEXTURES]; + + //! Texture Address Mode + E_TEXTURE_CLAMP TextureWrap[MATERIAL_MAX_TEXTURES]; + + //! material flag union. + /** This enables the user to access the + material flag using e.g: material.Wireframe = true or + material.setFlag(EMF_WIREFRAME, true); */ + struct + { + //! Draw as wireframe or filled triangles? Default: false + bool Wireframe; + + //! Draw as point cloud or filled triangles? Default: false + bool PointCloud; + + //! Flat or Gouraud shading? Default: true + bool GouraudShading; + + //! Will this material be lighted? Default: true + bool Lighting; + + //! Is the ZBuffer enabled? Default: true + //! Changed from Bool to Integer + // ( 0 == ZBuffer Off, 1 == ZBuffer LessEqual, 2 == ZBuffer Equal ) + u32 ZBuffer; + + //! May be written to the zbuffer or is it readonly. + /** Default: 1 This flag is ignored, if the MaterialType + is a transparent type. */ + bool ZWriteEnable; + + //! Is backfaceculling enabled? Default: true + bool BackfaceCulling; + + //! Is bilinear filtering enabled? Default: true + bool BilinearFilter; + + //! Is trilinear filtering enabled? Default: false + /** If the trilinear filter flag is enabled, + the bilinear filtering flag is ignored. */ + bool TrilinearFilter; + + //! Is anisotropic filtering enabled? Default: false + /** In Irrlicht you can use anisotropic texture filtering + in conjunction with bilinear or trilinear texture + filtering to improve rendering results. Primitives + will look less blurry with this flag switched on. */ + bool AnisotropicFilter; + + //! Is fog enabled? Default: false + bool FogEnable; + + //! Should normals be normalized? Default: false + bool NormalizeNormals; + }; + + core::matrix4& getTextureMatrix(u32 i) + { + if (i=MATERIAL_MAX_TEXTURES) + return; + if (!TextureMatrix[i]) + TextureMatrix[i] = new core::matrix4(mat); + else + *TextureMatrix[i] = mat; + } + + void setFlag(E_MATERIAL_FLAG flag, bool value) + { + switch (flag) + { + case EMF_WIREFRAME: + Wireframe = value; break; + case EMF_POINTCLOUD: + PointCloud = value; break; + case EMF_GOURAUD_SHADING: + GouraudShading = value; break; + case EMF_LIGHTING: + Lighting = value; break; + case EMF_ZBUFFER: + ZBuffer = value; break; + case EMF_ZWRITE_ENABLE: + ZWriteEnable = value; break; + case EMF_BACK_FACE_CULLING: + BackfaceCulling = value; break; + case EMF_BILINEAR_FILTER: + BilinearFilter = value; break; + case EMF_TRILINEAR_FILTER: + TrilinearFilter = value; break; + case EMF_ANISOTROPIC_FILTER: + AnisotropicFilter = value; break; + case EMF_FOG_ENABLE: + FogEnable = value; break; + case EMF_NORMALIZE_NORMALS: + NormalizeNormals = value; break; + case EMF_TEXTURE_WRAP: + TextureWrap[0] = TextureWrap[1] = TextureWrap[2] = TextureWrap[3] = (E_TEXTURE_CLAMP)value; + break; + default: + break; + } + } + + bool getFlag(E_MATERIAL_FLAG flag) const + { + switch (flag) + { + case EMF_WIREFRAME: + return Wireframe; break; + case EMF_POINTCLOUD: + return PointCloud; break; + case EMF_GOURAUD_SHADING: + return GouraudShading; break; + case EMF_LIGHTING: + return Lighting; break; + case EMF_ZBUFFER: + return ZBuffer!=0; break; + case EMF_ZWRITE_ENABLE: + return ZWriteEnable; break; + case EMF_BACK_FACE_CULLING: + return BackfaceCulling; break; + case EMF_BILINEAR_FILTER: + return BilinearFilter; break; + case EMF_TRILINEAR_FILTER: + return TrilinearFilter; break; + case EMF_ANISOTROPIC_FILTER: + return AnisotropicFilter; break; + case EMF_FOG_ENABLE: + return FogEnable; break; + case EMF_NORMALIZE_NORMALS: + return NormalizeNormals; break; + case EMF_TEXTURE_WRAP: + return !(TextureWrap[0] || TextureWrap[1] || TextureWrap[2] || TextureWrap[3]); + case EMF_MATERIAL_FLAG_COUNT: + break; + } + + return false; + } + + //! Compare operator + inline bool operator!=(const SMaterial& b) const + { + return + Textures[0] != b.Textures[0] || + Textures[1] != b.Textures[1] || + Textures[2] != b.Textures[2] || + Textures[3] != b.Textures[3] || + MaterialType != b.MaterialType || + AmbientColor != b.AmbientColor || + DiffuseColor != b.DiffuseColor || + EmissiveColor != b.EmissiveColor || + SpecularColor != b.SpecularColor || + Shininess != b.Shininess || + MaterialTypeParam != b.MaterialTypeParam || + MaterialTypeParam2 != b.MaterialTypeParam2 || + Thickness != b.Thickness || + Wireframe != b.Wireframe || + PointCloud != b.PointCloud || + GouraudShading != b.GouraudShading || + Lighting != b.Lighting || + ZBuffer != b.ZBuffer || + ZWriteEnable != b.ZWriteEnable || + BackfaceCulling != b.BackfaceCulling || + BilinearFilter != b.BilinearFilter || + TrilinearFilter != b.TrilinearFilter || + AnisotropicFilter != b.AnisotropicFilter || + FogEnable != b.FogEnable || + NormalizeNormals != b.NormalizeNormals || + TextureWrap[0] != b.TextureWrap[0] || + TextureWrap[1] != b.TextureWrap[1] || + TextureWrap[2] != b.TextureWrap[2] || + TextureWrap[3] != b.TextureWrap[3] || + TextureMatrix[0] != b.TextureMatrix[0] || + TextureMatrix[1] != b.TextureMatrix[1] || + TextureMatrix[2] != b.TextureMatrix[2] || + TextureMatrix[3] != b.TextureMatrix[3]; + } + inline bool operator==(const SMaterial& b) const + { return !(b!=*this); } + }; + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/SMesh.h b/src/dep/include/irrlicht/SMesh.h index f04b1da..71a199b 100644 --- a/src/dep/include/irrlicht/SMesh.h +++ b/src/dep/include/irrlicht/SMesh.h @@ -1,114 +1,114 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_MESH_H_INCLUDED__ -#define __S_MESH_H_INCLUDED__ - -#include "IMesh.h" -#include "IMeshBuffer.h" -#include "aabbox3d.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - //! Simple implementation of the IMesh interface. - struct SMesh : public IMesh - { - //! constructor - SMesh() - { - #ifdef _DEBUG - setDebugName("SMesh"); - #endif - } - - //! destructor - ~SMesh() - { - // drop buffers - for (u32 i=0; idrop(); - } - }; - - //! returns amount of mesh buffers. - virtual u32 getMeshBufferCount() const - { - return MeshBuffers.size(); - } - - //! returns pointer to a mesh buffer - virtual IMeshBuffer* getMeshBuffer(u32 nr) const - { - return MeshBuffers[nr]; - } - - //! returns a meshbuffer which fits a material - // reverse search - virtual IMeshBuffer* getMeshBuffer( const video::SMaterial & material) const - { - for (s32 i = (s32) MeshBuffers.size(); --i >= 0; ) - { - if ( !(material != MeshBuffers[i]->getMaterial()) ) - return MeshBuffers[i]; - } - - return 0; - } - - //! returns an axis aligned bounding box - virtual const core::aabbox3d& getBoundingBox() const - { - return BoundingBox; - } - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box) - { - BoundingBox = box; - } - - //! recalculates the bounding box - void recalculateBoundingBox() - { - if (MeshBuffers.size()) - { - BoundingBox = MeshBuffers[0]->getBoundingBox(); - for (u32 i=1; igetBoundingBox()); - } - else - BoundingBox.reset(0.0f, 0.0f, 0.0f); - } - - //! adds a MeshBuffer - void addMeshBuffer(IMeshBuffer* buf) - { - if (buf) - { - buf->grab(); - MeshBuffers.push_back(buf); - } - } - - //! sets a flag of all contained materials to a new value - virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) - { - for (u32 i=0; igetMaterial().setFlag(flag, newvalue); - } - - core::array MeshBuffers; - core::aabbox3d BoundingBox; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __S_MESH_H_INCLUDED__ +#define __S_MESH_H_INCLUDED__ + +#include "IMesh.h" +#include "IMeshBuffer.h" +#include "aabbox3d.h" +#include "irrArray.h" + +namespace irr +{ +namespace scene +{ + //! Simple implementation of the IMesh interface. + struct SMesh : public IMesh + { + //! constructor + SMesh() + { + #ifdef _DEBUG + setDebugName("SMesh"); + #endif + } + + //! destructor + ~SMesh() + { + // drop buffers + for (u32 i=0; idrop(); + } + }; + + //! returns amount of mesh buffers. + virtual u32 getMeshBufferCount() const + { + return MeshBuffers.size(); + } + + //! returns pointer to a mesh buffer + virtual IMeshBuffer* getMeshBuffer(u32 nr) const + { + return MeshBuffers[nr]; + } + + //! returns a meshbuffer which fits a material + // reverse search + virtual IMeshBuffer* getMeshBuffer( const video::SMaterial & material) const + { + for (s32 i = (s32) MeshBuffers.size(); --i >= 0; ) + { + if ( !(material != MeshBuffers[i]->getMaterial()) ) + return MeshBuffers[i]; + } + + return 0; + } + + //! returns an axis aligned bounding box + virtual const core::aabbox3d& getBoundingBox() const + { + return BoundingBox; + } + + //! set user axis aligned bounding box + virtual void setBoundingBox( const core::aabbox3df& box) + { + BoundingBox = box; + } + + //! recalculates the bounding box + void recalculateBoundingBox() + { + if (MeshBuffers.size()) + { + BoundingBox = MeshBuffers[0]->getBoundingBox(); + for (u32 i=1; igetBoundingBox()); + } + else + BoundingBox.reset(0.0f, 0.0f, 0.0f); + } + + //! adds a MeshBuffer + void addMeshBuffer(IMeshBuffer* buf) + { + if (buf) + { + buf->grab(); + MeshBuffers.push_back(buf); + } + } + + //! sets a flag of all contained materials to a new value + virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) + { + for (u32 i=0; igetMaterial().setFlag(flag, newvalue); + } + + core::array MeshBuffers; + core::aabbox3d BoundingBox; + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/SMeshBuffer.h b/src/dep/include/irrlicht/SMeshBuffer.h index 1df91d4..4645a36 100644 --- a/src/dep/include/irrlicht/SMeshBuffer.h +++ b/src/dep/include/irrlicht/SMeshBuffer.h @@ -1,126 +1,126 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_MESH_BUFFER_H_INCLUDED__ -#define __S_MESH_BUFFER_H_INCLUDED__ - -#include "irrArray.h" -#include "IMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - //! Simple implementation of the IMeshBuffer interface with S3DVertex vertices. - struct SMeshBuffer : public IMeshBuffer - { - //! constructor - SMeshBuffer() - { - #ifdef _DEBUG - setDebugName("SMeshBuffer"); - #endif - } - - //! destructor - ~SMeshBuffer() {}; - - //! returns the material of this meshbuffer - virtual const video::SMaterial& getMaterial() const - { - return Material; - } - - //! returns the material of this meshbuffer - virtual video::SMaterial& getMaterial() - { - return Material; - } - - //! returns pointer to vertices - virtual const void* getVertices() const - { - return Vertices.const_pointer(); - } - - //! returns pointer to vertices - virtual void* getVertices() - { - return Vertices.pointer(); - } - - //! returns amount of vertices - virtual u32 getVertexCount() const - { - return Vertices.size(); - } - - //! returns pointer to Indices - virtual const u16* getIndices() const - { - return Indices.const_pointer(); - } - - //! returns pointer to Indices - virtual u16* getIndices() - { - return Indices.pointer(); - } - - //! returns amount of indices - virtual u32 getIndexCount() const - { - return Indices.size(); - } - - //! returns an axis aligned bounding box - virtual const core::aabbox3d& getBoundingBox() const - { - return BoundingBox; - } - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box) - { - BoundingBox = box; - } - - - //! recalculates the bounding box. should be called if the mesh changed. - void recalculateBoundingBox() - { - if (Vertices.empty()) - BoundingBox.reset(0,0,0); - else - { - BoundingBox.reset(Vertices[0].Pos); - for (u32 i=1; i Vertices; //! Array of vertices - core::array Indices; //! Array of the Indices. - core::aabbox3d BoundingBox; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __S_MESH_BUFFER_H_INCLUDED__ +#define __S_MESH_BUFFER_H_INCLUDED__ + +#include "irrArray.h" +#include "IMeshBuffer.h" + +namespace irr +{ +namespace scene +{ + //! Simple implementation of the IMeshBuffer interface with S3DVertex vertices. + struct SMeshBuffer : public IMeshBuffer + { + //! constructor + SMeshBuffer() + { + #ifdef _DEBUG + setDebugName("SMeshBuffer"); + #endif + } + + //! destructor + ~SMeshBuffer() {}; + + //! returns the material of this meshbuffer + virtual const video::SMaterial& getMaterial() const + { + return Material; + } + + //! returns the material of this meshbuffer + virtual video::SMaterial& getMaterial() + { + return Material; + } + + //! returns pointer to vertices + virtual const void* getVertices() const + { + return Vertices.const_pointer(); + } + + //! returns pointer to vertices + virtual void* getVertices() + { + return Vertices.pointer(); + } + + //! returns amount of vertices + virtual u32 getVertexCount() const + { + return Vertices.size(); + } + + //! returns pointer to Indices + virtual const u16* getIndices() const + { + return Indices.const_pointer(); + } + + //! returns pointer to Indices + virtual u16* getIndices() + { + return Indices.pointer(); + } + + //! returns amount of indices + virtual u32 getIndexCount() const + { + return Indices.size(); + } + + //! returns an axis aligned bounding box + virtual const core::aabbox3d& getBoundingBox() const + { + return BoundingBox; + } + + //! set user axis aligned bounding box + virtual void setBoundingBox( const core::aabbox3df& box) + { + BoundingBox = box; + } + + + //! recalculates the bounding box. should be called if the mesh changed. + void recalculateBoundingBox() + { + if (Vertices.empty()) + BoundingBox.reset(0,0,0); + else + { + BoundingBox.reset(Vertices[0].Pos); + for (u32 i=1; i Vertices; //! Array of vertices + core::array Indices; //! Array of the Indices. + core::aabbox3d BoundingBox; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/SMeshBufferLightMap.h b/src/dep/include/irrlicht/SMeshBufferLightMap.h index 027ea6a..7fe211b 100644 --- a/src/dep/include/irrlicht/SMeshBufferLightMap.h +++ b/src/dep/include/irrlicht/SMeshBufferLightMap.h @@ -1,127 +1,127 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_MESH_BUFFER_LIGHT_MAP_H_INCLUDED__ -#define __S_MESH_BUFFER_LIGHT_MAP_H_INCLUDED__ - -#include "irrArray.h" -#include "IMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - //! Simple implementation of the IMeshBuffer interface with S3DVertex2TCoords vertices. - struct SMeshBufferLightMap : public IMeshBuffer - { - //! constructor - SMeshBufferLightMap() - { - #ifdef _DEBUG - setDebugName("SMeshBufferLightMap"); - #endif - } - - //! destructor - ~SMeshBufferLightMap() {}; - - //! returns the material of this meshbuffer - virtual const video::SMaterial& getMaterial() const - { - return Material; - } - - - //! returns the material of this meshbuffer - video::SMaterial& getMaterial() - { - return Material; - } - - //! returns pointer to vertices - virtual const void* getVertices() const - { - return Vertices.const_pointer(); - } - - //! returns pointer to vertices - virtual void* getVertices() - { - return Vertices.pointer(); - } - - //! returns amount of vertices - virtual u32 getVertexCount() const - { - return Vertices.size(); - } - - //! returns pointer to Indices - virtual const u16* getIndices() const - { - return Indices.const_pointer(); - } - - //! returns pointer to Indices - virtual u16* getIndices() - { - return Indices.pointer(); - } - - //! returns amount of indices - virtual u32 getIndexCount() const - { - return Indices.size(); - } - - //! returns an axis aligned bounding box - virtual const core::aabbox3d& getBoundingBox() const - { - return BoundingBox; - } - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box) - { - BoundingBox = box; - } - - - //! recalculates the bounding box. should be called if the mesh changed. - void recalculateBoundingBox() - { - if (Vertices.empty()) - BoundingBox.reset(0,0,0); - else - { - BoundingBox.reset(Vertices[0].Pos); - for (u32 i=1; i Vertices; //! Array of vertices - core::array Indices; //! Array of the Indices. - core::aabbox3d BoundingBox; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __S_MESH_BUFFER_LIGHT_MAP_H_INCLUDED__ +#define __S_MESH_BUFFER_LIGHT_MAP_H_INCLUDED__ + +#include "irrArray.h" +#include "IMeshBuffer.h" + +namespace irr +{ +namespace scene +{ + //! Simple implementation of the IMeshBuffer interface with S3DVertex2TCoords vertices. + struct SMeshBufferLightMap : public IMeshBuffer + { + //! constructor + SMeshBufferLightMap() + { + #ifdef _DEBUG + setDebugName("SMeshBufferLightMap"); + #endif + } + + //! destructor + ~SMeshBufferLightMap() {}; + + //! returns the material of this meshbuffer + virtual const video::SMaterial& getMaterial() const + { + return Material; + } + + + //! returns the material of this meshbuffer + video::SMaterial& getMaterial() + { + return Material; + } + + //! returns pointer to vertices + virtual const void* getVertices() const + { + return Vertices.const_pointer(); + } + + //! returns pointer to vertices + virtual void* getVertices() + { + return Vertices.pointer(); + } + + //! returns amount of vertices + virtual u32 getVertexCount() const + { + return Vertices.size(); + } + + //! returns pointer to Indices + virtual const u16* getIndices() const + { + return Indices.const_pointer(); + } + + //! returns pointer to Indices + virtual u16* getIndices() + { + return Indices.pointer(); + } + + //! returns amount of indices + virtual u32 getIndexCount() const + { + return Indices.size(); + } + + //! returns an axis aligned bounding box + virtual const core::aabbox3d& getBoundingBox() const + { + return BoundingBox; + } + + //! set user axis aligned bounding box + virtual void setBoundingBox( const core::aabbox3df& box) + { + BoundingBox = box; + } + + + //! recalculates the bounding box. should be called if the mesh changed. + void recalculateBoundingBox() + { + if (Vertices.empty()) + BoundingBox.reset(0,0,0); + else + { + BoundingBox.reset(Vertices[0].Pos); + for (u32 i=1; i Vertices; //! Array of vertices + core::array Indices; //! Array of the Indices. + core::aabbox3d BoundingBox; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/SMeshBufferTangents.h b/src/dep/include/irrlicht/SMeshBufferTangents.h index a905857..6f4b2e3 100644 --- a/src/dep/include/irrlicht/SMeshBufferTangents.h +++ b/src/dep/include/irrlicht/SMeshBufferTangents.h @@ -1,126 +1,126 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_MESH_BUFFER_TANGENTS_H_INCLUDED__ -#define __S_MESH_BUFFER_TANGENTS_H_INCLUDED__ - -#include "irrArray.h" -#include "IMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - //! Simple implementation of the IMeshBuffer interface with S3DVertexTangents vertices. - struct SMeshBufferTangents : public IMeshBuffer - { - //! constructor - SMeshBufferTangents() - { - #ifdef _DEBUG - setDebugName("SMeshBufferTangents"); - #endif - } - - //! destructor - ~SMeshBufferTangents() {}; - - //! returns the material of this meshbuffer - virtual const video::SMaterial& getMaterial() const - { - return Material; - } - - //! returns the material of this meshbuffer - virtual video::SMaterial& getMaterial() - { - return Material; - } - - //! returns pointer to vertices - virtual const void* getVertices() const - { - return Vertices.const_pointer(); - } - - //! returns pointer to vertices - virtual void* getVertices() - { - return Vertices.pointer(); - } - - //! returns amount of vertices - virtual u32 getVertexCount() const - { - return Vertices.size(); - } - - //! returns pointer to Indices - virtual const u16* getIndices() const - { - return Indices.const_pointer(); - } - - //! returns pointer to Indices - virtual u16* getIndices() - { - return Indices.pointer(); - } - - //! returns amount of indices - virtual u32 getIndexCount() const - { - return Indices.size(); - } - - //! returns an axis aligned bounding box - virtual const core::aabbox3d& getBoundingBox() const - { - return BoundingBox; - } - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box) - { - BoundingBox = box; - } - - - //! recalculates the bounding box. should be called if the mesh changed. - void recalculateBoundingBox() - { - if (Vertices.empty()) - BoundingBox.reset(0,0,0); - else - { - BoundingBox.reset(Vertices[0].Pos); - for (u32 i=1; i Vertices; //! Array of vertices - core::array Indices; //! Array of the Indices. - core::aabbox3d BoundingBox; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __S_MESH_BUFFER_TANGENTS_H_INCLUDED__ +#define __S_MESH_BUFFER_TANGENTS_H_INCLUDED__ + +#include "irrArray.h" +#include "IMeshBuffer.h" + +namespace irr +{ +namespace scene +{ + //! Simple implementation of the IMeshBuffer interface with S3DVertexTangents vertices. + struct SMeshBufferTangents : public IMeshBuffer + { + //! constructor + SMeshBufferTangents() + { + #ifdef _DEBUG + setDebugName("SMeshBufferTangents"); + #endif + } + + //! destructor + ~SMeshBufferTangents() {}; + + //! returns the material of this meshbuffer + virtual const video::SMaterial& getMaterial() const + { + return Material; + } + + //! returns the material of this meshbuffer + virtual video::SMaterial& getMaterial() + { + return Material; + } + + //! returns pointer to vertices + virtual const void* getVertices() const + { + return Vertices.const_pointer(); + } + + //! returns pointer to vertices + virtual void* getVertices() + { + return Vertices.pointer(); + } + + //! returns amount of vertices + virtual u32 getVertexCount() const + { + return Vertices.size(); + } + + //! returns pointer to Indices + virtual const u16* getIndices() const + { + return Indices.const_pointer(); + } + + //! returns pointer to Indices + virtual u16* getIndices() + { + return Indices.pointer(); + } + + //! returns amount of indices + virtual u32 getIndexCount() const + { + return Indices.size(); + } + + //! returns an axis aligned bounding box + virtual const core::aabbox3d& getBoundingBox() const + { + return BoundingBox; + } + + //! set user axis aligned bounding box + virtual void setBoundingBox( const core::aabbox3df& box) + { + BoundingBox = box; + } + + + //! recalculates the bounding box. should be called if the mesh changed. + void recalculateBoundingBox() + { + if (Vertices.empty()) + BoundingBox.reset(0,0,0); + else + { + BoundingBox.reset(Vertices[0].Pos); + for (u32 i=1; i Vertices; //! Array of vertices + core::array Indices; //! Array of the Indices. + core::aabbox3d BoundingBox; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/SParticle.h b/src/dep/include/irrlicht/SParticle.h index 92bd97a..166ff8a 100644 --- a/src/dep/include/irrlicht/SParticle.h +++ b/src/dep/include/irrlicht/SParticle.h @@ -1,48 +1,48 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_PARTICLE_H_INCLUDED__ -#define __S_PARTICLE_H_INCLUDED__ - -#include "vector3d.h" -#include "SColor.h" - -namespace irr -{ -namespace scene -{ - //! Struct for holding particle data - struct SParticle - { - //! Position of the particle - core::vector3df pos; - - //! Direction and speed of the particle - core::vector3df vector; - - //! Start life time of the particle - u32 startTime; - - //! End life time of the particle - u32 endTime; - - //! Current color of the particle - video::SColor color; - - //! Original color of the particle. That's the color - //! of the particle it had when it was emitted. - video::SColor startColor; - - //! Original direction and speed of the particle, - //! the direction and speed the particle had when - //! it was emitted. - core::vector3df startVector; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __S_PARTICLE_H_INCLUDED__ +#define __S_PARTICLE_H_INCLUDED__ + +#include "vector3d.h" +#include "SColor.h" + +namespace irr +{ +namespace scene +{ + //! Struct for holding particle data + struct SParticle + { + //! Position of the particle + core::vector3df pos; + + //! Direction and speed of the particle + core::vector3df vector; + + //! Start life time of the particle + u32 startTime; + + //! End life time of the particle + u32 endTime; + + //! Current color of the particle + video::SColor color; + + //! Original color of the particle. That's the color + //! of the particle it had when it was emitted. + video::SColor startColor; + + //! Original direction and speed of the particle, + //! the direction and speed the particle had when + //! it was emitted. + core::vector3df startVector; + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/SViewFrustum.h b/src/dep/include/irrlicht/SViewFrustum.h index 98f92ac..6d23d29 100644 --- a/src/dep/include/irrlicht/SViewFrustum.h +++ b/src/dep/include/irrlicht/SViewFrustum.h @@ -1,324 +1,324 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_VIEW_FRUSTUM_H_INCLUDED__ -#define __S_VIEW_FRUSTUM_H_INCLUDED__ - -#include "plane3d.h" -#include "vector3d.h" -#include "aabbox3d.h" -#include "matrix4.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace scene -{ - - //! Defines the view frustum. Thats the space viewed by the camera. - /** The view frustum is enclosed by 6 planes. These six planes share - four points. A bounding box around these four points is also stored in - this structure. - */ - struct SViewFrustum - { - enum VFPLANES - { - //! Far plane of the frustum. Thats the plane farest away from the eye. - VF_FAR_PLANE = 0, - //! Near plane of the frustum. Thats the plane nearest to the eye. - VF_NEAR_PLANE, - //! Left plane of the frustum. - VF_LEFT_PLANE, - //! Right plane of the frustum. - VF_RIGHT_PLANE, - //! Bottom plane of the frustum. - VF_BOTTOM_PLANE, - //! Top plane of the frustum. - VF_TOP_PLANE, - - //! Amount of planes enclosing the view frustum. Should be 6. - VF_PLANE_COUNT - }; - - //! Default Constructor - SViewFrustum() {}; - - //! This constructor creates a view frustum based on a projection and/or - //! view matrix. - SViewFrustum(const core::matrix4& mat); - - //! This constructor creates a view frustum based on a projection - //! and/or view matrix. - void setFrom(const core::matrix4& mat); - - //! the position of the camera - core::vector3df cameraPosition; - - //! all planes enclosing the view frustum. - core::plane3d planes[VF_PLANE_COUNT]; - - - //! transforms the frustum by the matrix - //! \param mat: Matrix by which the view frustum is transformed. - void transform(const core::matrix4 &mat); - - //! returns the point which is on the far left upper corner inside the - //! the view frustum. - core::vector3df getFarLeftUp() const; - - //! returns the point which is on the far left bottom corner inside the - //! the view frustum. - core::vector3df getFarLeftDown() const; - - //! returns the point which is on the far right top corner inside the - //! the view frustum. - core::vector3df getFarRightUp() const; - - //! returns the point which is on the far right bottom corner inside the - //! the view frustum. - core::vector3df getFarRightDown() const; - - //! returns a bounding box enclosing the whole view frustum - const core::aabbox3d &getBoundingBox() const; - - //! recalculates the bounding box member based on the planes - inline void recalculateBoundingBox(); - - //! bouding box around the view frustum - core::aabbox3d boundingBox; - - //! Hold a copy of important transform matrices - enum E_TRANSFORMATION_STATE_3 - { - ETS_VIEW_PROJECTION_3 = video::ETS_PROJECTION + 1, - ETS_VIEW_MODEL_INVERSE_3, - ETS_CURRENT_3, - ETS_COUNT_3 - }; - - core::matrix4 Matrices[ETS_COUNT_3]; - void setTransformState( video::E_TRANSFORMATION_STATE state); - }; - - - //! transforms the frustum by the matrix - //! \param Matrix by which the view frustum is transformed. - inline void SViewFrustum::transform(const core::matrix4 &mat) - { - for (int i=0; i &SViewFrustum::getBoundingBox() const - { - return boundingBox; - } - - //! recalculates the bounding box member based on the planes - inline void SViewFrustum::recalculateBoundingBox() - { - boundingBox.reset ( cameraPosition ); - - boundingBox.addInternalPoint(getFarLeftUp()); - boundingBox.addInternalPoint(getFarRightUp()); - boundingBox.addInternalPoint(getFarLeftDown()); - boundingBox.addInternalPoint(getFarRightDown()); - } - - //! This constructor creates a view frustum based on a projection - //! and/or view matrix. - inline SViewFrustum::SViewFrustum(const core::matrix4& mat) - { - setFrom ( mat ); - } - -/* - //! This constructor creates a view frustum based on a projection - //! and/or view matrix. - inline void SViewFrustum::setFrom(const core::matrix4& mat) - { - // left clipping plane - planes[SViewFrustum::VF_LEFT_PLANE].Normal.X = -(mat(0,3) + mat(0,0)); - planes[SViewFrustum::VF_LEFT_PLANE].Normal.Y = -(mat(1,3) + mat(1,0)); - planes[SViewFrustum::VF_LEFT_PLANE].Normal.Z = -(mat(2,3) + mat(2,0)); - planes[SViewFrustum::VF_LEFT_PLANE].D = -(mat(3,3) + mat(3,0)); - - // right clipping plane - planes[SViewFrustum::VF_RIGHT_PLANE].Normal.X = -(mat(0,3) - mat(0,0)); - planes[SViewFrustum::VF_RIGHT_PLANE].Normal.Y = -(mat(1,3) - mat(1,0)); - planes[SViewFrustum::VF_RIGHT_PLANE].Normal.Z = -(mat(2,3) - mat(2,0)); - planes[SViewFrustum::VF_RIGHT_PLANE].D = -(mat(3,3) - mat(3,0)); - - // top clipping plane - planes[SViewFrustum::VF_TOP_PLANE].Normal.X = -(mat(0,3) - mat(0,1)); - planes[SViewFrustum::VF_TOP_PLANE].Normal.Y = -(mat(1,3) - mat(1,1)); - planes[SViewFrustum::VF_TOP_PLANE].Normal.Z = -(mat(2,3) - mat(2,1)); - planes[SViewFrustum::VF_TOP_PLANE].D = -(mat(3,3) - mat(3,1)); - - // bottom clipping plane - planes[SViewFrustum::VF_BOTTOM_PLANE].Normal.X = -(mat(0,3) + mat(0,1)); - planes[SViewFrustum::VF_BOTTOM_PLANE].Normal.Y = -(mat(1,3) + mat(1,1)); - planes[SViewFrustum::VF_BOTTOM_PLANE].Normal.Z = -(mat(2,3) + mat(2,1)); - planes[SViewFrustum::VF_BOTTOM_PLANE].D = -(mat(3,3) + mat(3,1)); - - // near clipping plane - planes[SViewFrustum::VF_NEAR_PLANE].Normal.X = -mat(0,2); - planes[SViewFrustum::VF_NEAR_PLANE].Normal.Y = -mat(1,2); - planes[SViewFrustum::VF_NEAR_PLANE].Normal.Z = -mat(2,2); - planes[SViewFrustum::VF_NEAR_PLANE].D = -mat(3,2); - - // far clipping plane - planes[SViewFrustum::VF_FAR_PLANE].Normal.X = -(mat(0,3) - mat(0,2)); - planes[SViewFrustum::VF_FAR_PLANE].Normal.Y = -(mat(1,3) - mat(1,2)); - planes[SViewFrustum::VF_FAR_PLANE].Normal.Z = -(mat(2,3) - mat(2,2)); - planes[SViewFrustum::VF_FAR_PLANE].D = -(mat(3,3) - mat(3,2)); - // normalize normals - - for (s32 i=0; i<6; ++i) - { - const f32 len = core::reciprocal_squareroot ( planes[i].Normal.getLengthSQ() ); - planes[i].Normal *= len; - planes[i].D *= len; - } - - // make bounding box - recalculateBoundingBox(); - } -*/ - - //! This constructor creates a view frustum based on a projection - //! and/or view matrix. - inline void SViewFrustum::setFrom(const core::matrix4& mat) - { - // left clipping plane - planes[VF_LEFT_PLANE].Normal.X = mat[3 ] + mat[0]; - planes[VF_LEFT_PLANE].Normal.Y = mat[7 ] + mat[4]; - planes[VF_LEFT_PLANE].Normal.Z = mat[11] + mat[8]; - planes[VF_LEFT_PLANE].D = mat[15] + mat[12]; - - // right clipping plane - planes[VF_RIGHT_PLANE].Normal.X = mat[3 ] - mat[0]; - planes[VF_RIGHT_PLANE].Normal.Y = mat[7 ] - mat[4]; - planes[VF_RIGHT_PLANE].Normal.Z = mat[11] - mat[8]; - planes[VF_RIGHT_PLANE].D = mat[15] - mat[12]; - - // top clipping plane - planes[VF_TOP_PLANE].Normal.X = mat[3 ] - mat[1]; - planes[VF_TOP_PLANE].Normal.Y = mat[7 ] - mat[5]; - planes[VF_TOP_PLANE].Normal.Z = mat[11] - mat[9]; - planes[VF_TOP_PLANE].D = mat[15] - mat[13]; - - // bottom clipping plane - planes[VF_BOTTOM_PLANE].Normal.X = mat[3 ] + mat[1]; - planes[VF_BOTTOM_PLANE].Normal.Y = mat[7 ] + mat[5]; - planes[VF_BOTTOM_PLANE].Normal.Z = mat[11] + mat[9]; - planes[VF_BOTTOM_PLANE].D = mat[15] + mat[13]; - - // far clipping plane - planes[VF_FAR_PLANE].Normal.X = mat[3 ] - mat[2]; - planes[VF_FAR_PLANE].Normal.Y = mat[7 ] - mat[6]; - planes[VF_FAR_PLANE].Normal.Z = mat[11] - mat[10]; - planes[VF_FAR_PLANE].D = mat[15] - mat[14]; - - // near clipping plane - planes[VF_NEAR_PLANE].Normal.X = mat[2]; - planes[VF_NEAR_PLANE].Normal.Y = mat[6]; - planes[VF_NEAR_PLANE].Normal.Z = mat[10]; - planes[VF_NEAR_PLANE].D = mat[14]; - - - // normalize normals - u32 i; - for ( i=0; i != 6; ++i) - { - const f32 len = - core::reciprocal_squareroot ( planes[i].Normal.getLengthSQ() ); - planes[i].Normal *= len; - planes[i].D *= len; - } - - // make bounding box - recalculateBoundingBox(); - } - - inline void SViewFrustum::setTransformState( video::E_TRANSFORMATION_STATE state) - { - switch ( state ) - { - case video::ETS_VIEW: - Matrices[ETS_VIEW_PROJECTION_3].setbyproduct_nocheck ( Matrices[ video::ETS_PROJECTION], - Matrices[ video::ETS_VIEW] - ); - Matrices[ETS_VIEW_MODEL_INVERSE_3] = Matrices[ video::ETS_VIEW]; - Matrices[ETS_VIEW_MODEL_INVERSE_3].makeInverse(); - break; - - case video::ETS_WORLD: - Matrices[ETS_CURRENT_3].setbyproduct ( Matrices[ ETS_VIEW_PROJECTION_3 ], - Matrices[ video::ETS_WORLD] ); - break; - default: - break; - } - } - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __S_VIEW_FRUSTUM_H_INCLUDED__ +#define __S_VIEW_FRUSTUM_H_INCLUDED__ + +#include "plane3d.h" +#include "vector3d.h" +#include "aabbox3d.h" +#include "matrix4.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace scene +{ + + //! Defines the view frustum. Thats the space viewed by the camera. + /** The view frustum is enclosed by 6 planes. These six planes share + four points. A bounding box around these four points is also stored in + this structure. + */ + struct SViewFrustum + { + enum VFPLANES + { + //! Far plane of the frustum. Thats the plane farest away from the eye. + VF_FAR_PLANE = 0, + //! Near plane of the frustum. Thats the plane nearest to the eye. + VF_NEAR_PLANE, + //! Left plane of the frustum. + VF_LEFT_PLANE, + //! Right plane of the frustum. + VF_RIGHT_PLANE, + //! Bottom plane of the frustum. + VF_BOTTOM_PLANE, + //! Top plane of the frustum. + VF_TOP_PLANE, + + //! Amount of planes enclosing the view frustum. Should be 6. + VF_PLANE_COUNT + }; + + //! Default Constructor + SViewFrustum() {}; + + //! This constructor creates a view frustum based on a projection and/or + //! view matrix. + SViewFrustum(const core::matrix4& mat); + + //! This constructor creates a view frustum based on a projection + //! and/or view matrix. + void setFrom(const core::matrix4& mat); + + //! the position of the camera + core::vector3df cameraPosition; + + //! all planes enclosing the view frustum. + core::plane3d planes[VF_PLANE_COUNT]; + + + //! transforms the frustum by the matrix + //! \param mat: Matrix by which the view frustum is transformed. + void transform(const core::matrix4 &mat); + + //! returns the point which is on the far left upper corner inside the + //! the view frustum. + core::vector3df getFarLeftUp() const; + + //! returns the point which is on the far left bottom corner inside the + //! the view frustum. + core::vector3df getFarLeftDown() const; + + //! returns the point which is on the far right top corner inside the + //! the view frustum. + core::vector3df getFarRightUp() const; + + //! returns the point which is on the far right bottom corner inside the + //! the view frustum. + core::vector3df getFarRightDown() const; + + //! returns a bounding box enclosing the whole view frustum + const core::aabbox3d &getBoundingBox() const; + + //! recalculates the bounding box member based on the planes + inline void recalculateBoundingBox(); + + //! bouding box around the view frustum + core::aabbox3d boundingBox; + + //! Hold a copy of important transform matrices + enum E_TRANSFORMATION_STATE_3 + { + ETS_VIEW_PROJECTION_3 = video::ETS_PROJECTION + 1, + ETS_VIEW_MODEL_INVERSE_3, + ETS_CURRENT_3, + ETS_COUNT_3 + }; + + core::matrix4 Matrices[ETS_COUNT_3]; + void setTransformState( video::E_TRANSFORMATION_STATE state); + }; + + + //! transforms the frustum by the matrix + //! \param Matrix by which the view frustum is transformed. + inline void SViewFrustum::transform(const core::matrix4 &mat) + { + for (int i=0; i &SViewFrustum::getBoundingBox() const + { + return boundingBox; + } + + //! recalculates the bounding box member based on the planes + inline void SViewFrustum::recalculateBoundingBox() + { + boundingBox.reset ( cameraPosition ); + + boundingBox.addInternalPoint(getFarLeftUp()); + boundingBox.addInternalPoint(getFarRightUp()); + boundingBox.addInternalPoint(getFarLeftDown()); + boundingBox.addInternalPoint(getFarRightDown()); + } + + //! This constructor creates a view frustum based on a projection + //! and/or view matrix. + inline SViewFrustum::SViewFrustum(const core::matrix4& mat) + { + setFrom ( mat ); + } + +/* + //! This constructor creates a view frustum based on a projection + //! and/or view matrix. + inline void SViewFrustum::setFrom(const core::matrix4& mat) + { + // left clipping plane + planes[SViewFrustum::VF_LEFT_PLANE].Normal.X = -(mat(0,3) + mat(0,0)); + planes[SViewFrustum::VF_LEFT_PLANE].Normal.Y = -(mat(1,3) + mat(1,0)); + planes[SViewFrustum::VF_LEFT_PLANE].Normal.Z = -(mat(2,3) + mat(2,0)); + planes[SViewFrustum::VF_LEFT_PLANE].D = -(mat(3,3) + mat(3,0)); + + // right clipping plane + planes[SViewFrustum::VF_RIGHT_PLANE].Normal.X = -(mat(0,3) - mat(0,0)); + planes[SViewFrustum::VF_RIGHT_PLANE].Normal.Y = -(mat(1,3) - mat(1,0)); + planes[SViewFrustum::VF_RIGHT_PLANE].Normal.Z = -(mat(2,3) - mat(2,0)); + planes[SViewFrustum::VF_RIGHT_PLANE].D = -(mat(3,3) - mat(3,0)); + + // top clipping plane + planes[SViewFrustum::VF_TOP_PLANE].Normal.X = -(mat(0,3) - mat(0,1)); + planes[SViewFrustum::VF_TOP_PLANE].Normal.Y = -(mat(1,3) - mat(1,1)); + planes[SViewFrustum::VF_TOP_PLANE].Normal.Z = -(mat(2,3) - mat(2,1)); + planes[SViewFrustum::VF_TOP_PLANE].D = -(mat(3,3) - mat(3,1)); + + // bottom clipping plane + planes[SViewFrustum::VF_BOTTOM_PLANE].Normal.X = -(mat(0,3) + mat(0,1)); + planes[SViewFrustum::VF_BOTTOM_PLANE].Normal.Y = -(mat(1,3) + mat(1,1)); + planes[SViewFrustum::VF_BOTTOM_PLANE].Normal.Z = -(mat(2,3) + mat(2,1)); + planes[SViewFrustum::VF_BOTTOM_PLANE].D = -(mat(3,3) + mat(3,1)); + + // near clipping plane + planes[SViewFrustum::VF_NEAR_PLANE].Normal.X = -mat(0,2); + planes[SViewFrustum::VF_NEAR_PLANE].Normal.Y = -mat(1,2); + planes[SViewFrustum::VF_NEAR_PLANE].Normal.Z = -mat(2,2); + planes[SViewFrustum::VF_NEAR_PLANE].D = -mat(3,2); + + // far clipping plane + planes[SViewFrustum::VF_FAR_PLANE].Normal.X = -(mat(0,3) - mat(0,2)); + planes[SViewFrustum::VF_FAR_PLANE].Normal.Y = -(mat(1,3) - mat(1,2)); + planes[SViewFrustum::VF_FAR_PLANE].Normal.Z = -(mat(2,3) - mat(2,2)); + planes[SViewFrustum::VF_FAR_PLANE].D = -(mat(3,3) - mat(3,2)); + // normalize normals + + for (s32 i=0; i<6; ++i) + { + const f32 len = core::reciprocal_squareroot ( planes[i].Normal.getLengthSQ() ); + planes[i].Normal *= len; + planes[i].D *= len; + } + + // make bounding box + recalculateBoundingBox(); + } +*/ + + //! This constructor creates a view frustum based on a projection + //! and/or view matrix. + inline void SViewFrustum::setFrom(const core::matrix4& mat) + { + // left clipping plane + planes[VF_LEFT_PLANE].Normal.X = mat[3 ] + mat[0]; + planes[VF_LEFT_PLANE].Normal.Y = mat[7 ] + mat[4]; + planes[VF_LEFT_PLANE].Normal.Z = mat[11] + mat[8]; + planes[VF_LEFT_PLANE].D = mat[15] + mat[12]; + + // right clipping plane + planes[VF_RIGHT_PLANE].Normal.X = mat[3 ] - mat[0]; + planes[VF_RIGHT_PLANE].Normal.Y = mat[7 ] - mat[4]; + planes[VF_RIGHT_PLANE].Normal.Z = mat[11] - mat[8]; + planes[VF_RIGHT_PLANE].D = mat[15] - mat[12]; + + // top clipping plane + planes[VF_TOP_PLANE].Normal.X = mat[3 ] - mat[1]; + planes[VF_TOP_PLANE].Normal.Y = mat[7 ] - mat[5]; + planes[VF_TOP_PLANE].Normal.Z = mat[11] - mat[9]; + planes[VF_TOP_PLANE].D = mat[15] - mat[13]; + + // bottom clipping plane + planes[VF_BOTTOM_PLANE].Normal.X = mat[3 ] + mat[1]; + planes[VF_BOTTOM_PLANE].Normal.Y = mat[7 ] + mat[5]; + planes[VF_BOTTOM_PLANE].Normal.Z = mat[11] + mat[9]; + planes[VF_BOTTOM_PLANE].D = mat[15] + mat[13]; + + // far clipping plane + planes[VF_FAR_PLANE].Normal.X = mat[3 ] - mat[2]; + planes[VF_FAR_PLANE].Normal.Y = mat[7 ] - mat[6]; + planes[VF_FAR_PLANE].Normal.Z = mat[11] - mat[10]; + planes[VF_FAR_PLANE].D = mat[15] - mat[14]; + + // near clipping plane + planes[VF_NEAR_PLANE].Normal.X = mat[2]; + planes[VF_NEAR_PLANE].Normal.Y = mat[6]; + planes[VF_NEAR_PLANE].Normal.Z = mat[10]; + planes[VF_NEAR_PLANE].D = mat[14]; + + + // normalize normals + u32 i; + for ( i=0; i != 6; ++i) + { + const f32 len = - core::reciprocal_squareroot ( planes[i].Normal.getLengthSQ() ); + planes[i].Normal *= len; + planes[i].D *= len; + } + + // make bounding box + recalculateBoundingBox(); + } + + inline void SViewFrustum::setTransformState( video::E_TRANSFORMATION_STATE state) + { + switch ( state ) + { + case video::ETS_VIEW: + Matrices[ETS_VIEW_PROJECTION_3].setbyproduct_nocheck ( Matrices[ video::ETS_PROJECTION], + Matrices[ video::ETS_VIEW] + ); + Matrices[ETS_VIEW_MODEL_INVERSE_3] = Matrices[ video::ETS_VIEW]; + Matrices[ETS_VIEW_MODEL_INVERSE_3].makeInverse(); + break; + + case video::ETS_WORLD: + Matrices[ETS_CURRENT_3].setbyproduct ( Matrices[ ETS_VIEW_PROJECTION_3 ], + Matrices[ video::ETS_WORLD] ); + break; + default: + break; + } + } + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/SceneParameters.h b/src/dep/include/irrlicht/SceneParameters.h index 34b7b61..18129f2 100644 --- a/src/dep/include/irrlicht/SceneParameters.h +++ b/src/dep/include/irrlicht/SceneParameters.h @@ -1,114 +1,114 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_PARAMETERS_H_INCLUDED__ -#define __I_SCENE_PARAMETERS_H_INCLUDED__ - -/*! \file SceneParameters.h - \brief Header file containing all scene parameters for modifying mesh loading etc. - - This file includes all parameter names which can be set using ISceneManager::getParameters() - to modify the behaviour of plugins and mesh loaders. -*/ - -namespace irr -{ -namespace scene -{ - //! Name of the parameter for changing the texture path of the built-in csm loader. - /** Use it like this: - \code - SceneManager->getParameters()->setAttribute( - scene::CSM_TEXTURE_PATH, "path/to/your/textures"); - \endcode - **/ - const c8* const CSM_TEXTURE_PATH = "CSM_TexturePath"; - - //! Name of the parameter for changing the texture path of the built-in lmts loader. - /** Use it like this: - \code - SceneManager->getParameters()->setAttribute( - scene::LMTS_TEXTURE_PATH, "path/to/your/textures"); - \endcode - **/ - const c8* const LMTS_TEXTURE_PATH = "LMTS_TexturePath"; - - //! Name of the parameter for changing the texture path of the built-in my3d loader. - /** Use it like this: - \code - SceneManager->getParameters()->setAttribute( - scene::MY3D_TEXTURE_PATH, "path/to/your/textures"); - \endcode - **/ - const c8* const MY3D_TEXTURE_PATH = "MY3D_TexturePath"; - - //! Name of the parameter specifying the COLLADA mesh loading mode - /** - Specifies if the COLLADA loader should create instances of the models, lights and - cameras when loading COLLADA meshes. By default, this is set to false. If this is - set to true, the ISceneManager::getMesh() method will only return a pointer to a - dummy mesh and create instances of all meshes and lights and cameras in the collada - file by itself. Example: - \code - SceneManager->getParameters()->setAttribute( - scene::COLLADA_CREATE_SCENE_INSTANCES, true); - \endcode - */ - const c8* const COLLADA_CREATE_SCENE_INSTANCES = "COLLADA_CreateSceneInstances"; - - //! Name of the parameter for changing the texture path of the built-in DMF loader. - /** Use it like this: - \code - SceneManager->getStringParameters()->setAttribute( - scene::DMF_TEXTURE_PATH, "path/to/your/textures"); - \endcode - **/ - const c8* const DMF_TEXTURE_PATH = "DMF_TexturePath"; - - //! Name of the parameter for preserving DMF textures dir structure with built-in DMF loader. - /** Use it like this: - \code - //this way you won't use this setting - SceneManager->getParameters()->setAttribute( - scene::DMF_USE_MATERIALS_DIRS, false); - \endcode - \code - //this way you'll use this setting - SceneManager->getParameters()->setAttribute( - scene::DMF_USE_MATERIALS_DIRS, true); - \endcode - **/ - const c8* const DMF_USE_MATERIALS_DIRS = "DMF_MaterialsDir"; - - //! Name of the parameter for setting reference value of alpha in transparent materials. - /** Use it like this: - \code - //this way you'll set alpha ref to 0.1 - SceneManager->getParameters()->setAttribute( - scene::DMF_ALPHA_CHANNEL_REF, 0.1); - \endcode - **/ - const c8* const DMF_ALPHA_CHANNEL_REF = "DMF_AlphaRef"; - - //! Name of the parameter for choose to flip or not tga files. - /** Use it like this: - \code - //this way you'll choose to flip alpha textures - SceneManager->()->setAttribute( - scene::DMF_FLIP_ALPHA_TEXTURES, true); - \endcode - **/ - const c8* const DMF_FLIP_ALPHA_TEXTURES = "DMF_FlipAlpha"; - - - //! Flag set as parameter when the scene manager is used as editor - /** In this way special animators like deletion animators can be stopped from - deleting scene nodes for example */ - const c8* const IRR_SCENE_MANAGER_IS_EDITOR = "IRR_Editor"; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_SCENE_PARAMETERS_H_INCLUDED__ +#define __I_SCENE_PARAMETERS_H_INCLUDED__ + +/*! \file SceneParameters.h + \brief Header file containing all scene parameters for modifying mesh loading etc. + + This file includes all parameter names which can be set using ISceneManager::getParameters() + to modify the behaviour of plugins and mesh loaders. +*/ + +namespace irr +{ +namespace scene +{ + //! Name of the parameter for changing the texture path of the built-in csm loader. + /** Use it like this: + \code + SceneManager->getParameters()->setAttribute( + scene::CSM_TEXTURE_PATH, "path/to/your/textures"); + \endcode + **/ + const c8* const CSM_TEXTURE_PATH = "CSM_TexturePath"; + + //! Name of the parameter for changing the texture path of the built-in lmts loader. + /** Use it like this: + \code + SceneManager->getParameters()->setAttribute( + scene::LMTS_TEXTURE_PATH, "path/to/your/textures"); + \endcode + **/ + const c8* const LMTS_TEXTURE_PATH = "LMTS_TexturePath"; + + //! Name of the parameter for changing the texture path of the built-in my3d loader. + /** Use it like this: + \code + SceneManager->getParameters()->setAttribute( + scene::MY3D_TEXTURE_PATH, "path/to/your/textures"); + \endcode + **/ + const c8* const MY3D_TEXTURE_PATH = "MY3D_TexturePath"; + + //! Name of the parameter specifying the COLLADA mesh loading mode + /** + Specifies if the COLLADA loader should create instances of the models, lights and + cameras when loading COLLADA meshes. By default, this is set to false. If this is + set to true, the ISceneManager::getMesh() method will only return a pointer to a + dummy mesh and create instances of all meshes and lights and cameras in the collada + file by itself. Example: + \code + SceneManager->getParameters()->setAttribute( + scene::COLLADA_CREATE_SCENE_INSTANCES, true); + \endcode + */ + const c8* const COLLADA_CREATE_SCENE_INSTANCES = "COLLADA_CreateSceneInstances"; + + //! Name of the parameter for changing the texture path of the built-in DMF loader. + /** Use it like this: + \code + SceneManager->getStringParameters()->setAttribute( + scene::DMF_TEXTURE_PATH, "path/to/your/textures"); + \endcode + **/ + const c8* const DMF_TEXTURE_PATH = "DMF_TexturePath"; + + //! Name of the parameter for preserving DMF textures dir structure with built-in DMF loader. + /** Use it like this: + \code + //this way you won't use this setting + SceneManager->getParameters()->setAttribute( + scene::DMF_USE_MATERIALS_DIRS, false); + \endcode + \code + //this way you'll use this setting + SceneManager->getParameters()->setAttribute( + scene::DMF_USE_MATERIALS_DIRS, true); + \endcode + **/ + const c8* const DMF_USE_MATERIALS_DIRS = "DMF_MaterialsDir"; + + //! Name of the parameter for setting reference value of alpha in transparent materials. + /** Use it like this: + \code + //this way you'll set alpha ref to 0.1 + SceneManager->getParameters()->setAttribute( + scene::DMF_ALPHA_CHANNEL_REF, 0.1); + \endcode + **/ + const c8* const DMF_ALPHA_CHANNEL_REF = "DMF_AlphaRef"; + + //! Name of the parameter for choose to flip or not tga files. + /** Use it like this: + \code + //this way you'll choose to flip alpha textures + SceneManager->()->setAttribute( + scene::DMF_FLIP_ALPHA_TEXTURES, true); + \endcode + **/ + const c8* const DMF_FLIP_ALPHA_TEXTURES = "DMF_FlipAlpha"; + + + //! Flag set as parameter when the scene manager is used as editor + /** In this way special animators like deletion animators can be stopped from + deleting scene nodes for example */ + const c8* const IRR_SCENE_MANAGER_IS_EDITOR = "IRR_Editor"; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/aabbox3d.h b/src/dep/include/irrlicht/aabbox3d.h index b6e2df0..f8070fb 100644 --- a/src/dep/include/irrlicht/aabbox3d.h +++ b/src/dep/include/irrlicht/aabbox3d.h @@ -1,294 +1,294 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_AABBOX_3D_H_INCLUDED__ -#define __IRR_AABBOX_3D_H_INCLUDED__ - -#include "irrMath.h" -#include "plane3d.h" -#include "line3d.h" - -namespace irr -{ -namespace core -{ - -//! Axis aligned bounding box in 3d dimensional space. -/** Has some useful methods used with occlusion culling or clipping. -*/ -template -class aabbox3d -{ - public: - - // Constructors - - aabbox3d(): MinEdge(-1,-1,-1), MaxEdge(1,1,1) {}; - aabbox3d(const aabbox3d& other): MinEdge(other.MinEdge), MaxEdge(other.MaxEdge) {}; - aabbox3d(const vector3d& min, const vector3d& max): MinEdge(min), MaxEdge(max) {}; - aabbox3d(const vector3d& init): MinEdge(init), MaxEdge(init) {}; - aabbox3d(T minx, T miny, T minz, T maxx, T maxy, T maxz): MinEdge(minx, miny, minz), MaxEdge(maxx, maxy, maxz) {}; - - // operators - - inline bool operator==(const aabbox3d& other) const { return (MinEdge == other.MinEdge && other.MaxEdge == MaxEdge);}; - inline bool operator!=(const aabbox3d& other) const { return !(MinEdge == other.MinEdge && other.MaxEdge == MaxEdge);}; - - // functions - - //! Adds a point to the bounding box, causing it to grow bigger, - //! if point is outside of the box - //! \param p: Point to add into the box. - void addInternalPoint(const vector3d& p) - { - addInternalPoint(p.X, p.Y, p.Z); - } - - //! Adds an other bounding box to the bounding box, causing it to grow bigger, - //! if the box is outside of the box - //! \param b: Other bounding box to add into this box. - void addInternalBox(const aabbox3d& b) - { - addInternalPoint(b.MaxEdge); - addInternalPoint(b.MinEdge); - } - - //! Resets the bounding box. - void reset(T x, T y, T z) - { - MaxEdge.set(x,y,z); - MinEdge = MaxEdge; - } - - //! Resets the bounding box. - void reset(const aabbox3d& initValue) - { - *this = initValue; - } - - //! Resets the bounding box. - void reset(const vector3d& initValue) - { - MaxEdge = initValue; - MinEdge = initValue; - } - - //! Adds a point to the bounding box, causing it to grow bigger, - //! if point is outside of the box. - //! \param x: X Coordinate of the point to add to this box. - //! \param y: Y Coordinate of the point to add to this box. - //! \param z: Z Coordinate of the point to add to this box. - void addInternalPoint(T x, T y, T z) - { - if (x>MaxEdge.X) MaxEdge.X = x; - if (y>MaxEdge.Y) MaxEdge.Y = y; - if (z>MaxEdge.Z) MaxEdge.Z = z; - - if (x& p) const - { - return (p.X >= MinEdge.X && p.X <= MaxEdge.X && - p.Y >= MinEdge.Y && p.Y <= MaxEdge.Y && - p.Z >= MinEdge.Z && p.Z <= MaxEdge.Z); - }; - - //! Determinates if a point is within this box and its borders. - //! \param p: Point to check. - //! \return Returns true if the point is withing the box, and false if it is not. - bool isPointTotalInside(const vector3d& p) const - { - return (p.X > MinEdge.X && p.X < MaxEdge.X && - p.Y > MinEdge.Y && p.Y < MaxEdge.Y && - p.Z > MinEdge.Z && p.Z < MaxEdge.Z); - }; - - //! Determinates if the box intersects with an other box. - //! \param other: Other box to check a intersection with. - //! \return Returns true if there is a intersection with the other box, - //! otherwise false. - bool intersectsWithBox(const aabbox3d& other) const - { - return (MinEdge <= other.MaxEdge && MaxEdge >= other.MinEdge); - } - - bool isFullInside(const aabbox3d& other) const - { - return MinEdge >= other.MinEdge && MaxEdge <= other.MaxEdge; - } - - //! Tests if the box intersects with a line - //! \param line: Line to test intersection with. - //! \return Returns true if there is an intersection and false if not. - bool intersectsWithLine(const line3d& line) const - { - return intersectsWithLine(line.getMiddle(), line.getVector().normalize(), - (T)(line.getLength() * 0.5)); - } - - //! Tests if the box intersects with a line - //! \return Returns true if there is an intersection and false if not. - bool intersectsWithLine(const vector3d& linemiddle, - const vector3d& linevect, - T halflength) const - { - const vector3d e = getExtent() * (T)0.5; - const vector3d t = getCenter() - linemiddle; - T r; - - if ((fabs(t.X) > e.X + halflength * fabs(linevect.X)) || - (fabs(t.Y) > e.Y + halflength * fabs(linevect.Y)) || - (fabs(t.Z) > e.Z + halflength * fabs(linevect.Z)) ) - return false; - - r = e.Y * (T)fabs(linevect.Z) + e.Z * (T)fabs(linevect.Y); - if (fabs(t.Y*linevect.Z - t.Z*linevect.Y) > r ) - return false; - - r = e.X * (T)fabs(linevect.Z) + e.Z * (T)fabs(linevect.X); - if (fabs(t.Z*linevect.X - t.X*linevect.Z) > r ) - return false; - - r = e.X * (T)fabs(linevect.Y) + e.Y * (T)fabs(linevect.X); - if (fabs(t.X*linevect.Y - t.Y*linevect.X) > r) - return false; - - return true; - } - - //! Classifies a relation with a plane. - //! \param plane: Plane to classify relation to. - //! \return Returns ISREL3D_FRONT if the box is in front of the plane, - //! ISREL3D_BACK if the box is back of the plane, and - //! ISREL3D_CLIPPED if is on both sides of the plane. - EIntersectionRelation3D classifyPlaneRelation(const plane3d& plane) const - { - vector3d nearPoint(MaxEdge); - vector3d farPoint(MinEdge); - - if (plane.Normal.X > (T)0) - { - nearPoint.X = MinEdge.X; - farPoint.X = MaxEdge.X; - } - - if (plane.Normal.Y > (T)0) - { - nearPoint.Y = MinEdge.Y; - farPoint.Y = MaxEdge.Y; - } - - if (plane.Normal.Z > (T)0) - { - nearPoint.Z = MinEdge.Z; - farPoint.Z = MaxEdge.Z; - } - - if (plane.Normal.dotProduct(nearPoint) + plane.D > (T)0) - return ISREL3D_FRONT; - - if (plane.Normal.dotProduct(farPoint) + plane.D > (T)0) - return ISREL3D_CLIPPED; - - return ISREL3D_BACK; - } - - - //! returns center of the bounding box - vector3d getCenter() const - { - return (MinEdge + MaxEdge) / 2; - } - - //! returns extend of the box - vector3d getExtent() const - { - return MaxEdge - MinEdge; - } - - - //! stores all 8 edges of the box into a array - //! \param edges: Pointer to array of 8 edges - void getEdges(vector3d *edges) const - { - const core::vector3d middle = getCenter(); - const core::vector3d diag = middle - MaxEdge; - - /* - Edges are stored in this way: - Hey, am I an ascii artist, or what? :) niko. - /4--------/0 - / | / | - / | / | - 6---------2 | - | 5- - -| -1 - | / | / - |/ | / - 7---------3/ - */ - - edges[0].set(middle.X + diag.X, middle.Y + diag.Y, middle.Z + diag.Z); - edges[1].set(middle.X + diag.X, middle.Y - diag.Y, middle.Z + diag.Z); - edges[2].set(middle.X + diag.X, middle.Y + diag.Y, middle.Z - diag.Z); - edges[3].set(middle.X + diag.X, middle.Y - diag.Y, middle.Z - diag.Z); - edges[4].set(middle.X - diag.X, middle.Y + diag.Y, middle.Z + diag.Z); - edges[5].set(middle.X - diag.X, middle.Y - diag.Y, middle.Z + diag.Z); - edges[6].set(middle.X - diag.X, middle.Y + diag.Y, middle.Z - diag.Z); - edges[7].set(middle.X - diag.X, middle.Y - diag.Y, middle.Z - diag.Z); - } - - - //! returns if the box is empty, which means that there is - //! no space within the min and the max edge. - bool isEmpty() const - { - return MinEdge.equals ( MaxEdge ); - } - - //! repairs the box, if for example MinEdge and MaxEdge are swapped. - void repair() - { - T t; - - if (MinEdge.X > MaxEdge.X) - { t=MinEdge.X; MinEdge.X = MaxEdge.X; MaxEdge.X=t; } - if (MinEdge.Y > MaxEdge.Y) - { t=MinEdge.Y; MinEdge.Y = MaxEdge.Y; MaxEdge.Y=t; } - if (MinEdge.Z > MaxEdge.Z) - { t=MinEdge.Z; MinEdge.Z = MaxEdge.Z; MaxEdge.Z=t; } - } - - //! Calculates a new interpolated bounding box. - //! \param other: other box to interpolate between - //! \param d: value between 0.0f and 1.0f. - aabbox3d getInterpolated(const aabbox3d& other, f32 d) const - { - f32 inv = 1.0f - d; - return aabbox3d((other.MinEdge*inv) + (MinEdge*d), - (other.MaxEdge*inv) + (MaxEdge*d)); - } - - // member variables - - vector3d MinEdge; - vector3d MaxEdge; -}; - - //! Typedef for a f32 3d bounding box. - typedef aabbox3d aabbox3df; - //! Typedef for an integer 3d bounding box. - typedef aabbox3d aabbox3di; - - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_AABBOX_3D_H_INCLUDED__ +#define __IRR_AABBOX_3D_H_INCLUDED__ + +#include "irrMath.h" +#include "plane3d.h" +#include "line3d.h" + +namespace irr +{ +namespace core +{ + +//! Axis aligned bounding box in 3d dimensional space. +/** Has some useful methods used with occlusion culling or clipping. +*/ +template +class aabbox3d +{ + public: + + // Constructors + + aabbox3d(): MinEdge(-1,-1,-1), MaxEdge(1,1,1) {}; + aabbox3d(const aabbox3d& other): MinEdge(other.MinEdge), MaxEdge(other.MaxEdge) {}; + aabbox3d(const vector3d& min, const vector3d& max): MinEdge(min), MaxEdge(max) {}; + aabbox3d(const vector3d& init): MinEdge(init), MaxEdge(init) {}; + aabbox3d(T minx, T miny, T minz, T maxx, T maxy, T maxz): MinEdge(minx, miny, minz), MaxEdge(maxx, maxy, maxz) {}; + + // operators + + inline bool operator==(const aabbox3d& other) const { return (MinEdge == other.MinEdge && other.MaxEdge == MaxEdge);}; + inline bool operator!=(const aabbox3d& other) const { return !(MinEdge == other.MinEdge && other.MaxEdge == MaxEdge);}; + + // functions + + //! Adds a point to the bounding box, causing it to grow bigger, + //! if point is outside of the box + //! \param p: Point to add into the box. + void addInternalPoint(const vector3d& p) + { + addInternalPoint(p.X, p.Y, p.Z); + } + + //! Adds an other bounding box to the bounding box, causing it to grow bigger, + //! if the box is outside of the box + //! \param b: Other bounding box to add into this box. + void addInternalBox(const aabbox3d& b) + { + addInternalPoint(b.MaxEdge); + addInternalPoint(b.MinEdge); + } + + //! Resets the bounding box. + void reset(T x, T y, T z) + { + MaxEdge.set(x,y,z); + MinEdge = MaxEdge; + } + + //! Resets the bounding box. + void reset(const aabbox3d& initValue) + { + *this = initValue; + } + + //! Resets the bounding box. + void reset(const vector3d& initValue) + { + MaxEdge = initValue; + MinEdge = initValue; + } + + //! Adds a point to the bounding box, causing it to grow bigger, + //! if point is outside of the box. + //! \param x: X Coordinate of the point to add to this box. + //! \param y: Y Coordinate of the point to add to this box. + //! \param z: Z Coordinate of the point to add to this box. + void addInternalPoint(T x, T y, T z) + { + if (x>MaxEdge.X) MaxEdge.X = x; + if (y>MaxEdge.Y) MaxEdge.Y = y; + if (z>MaxEdge.Z) MaxEdge.Z = z; + + if (x& p) const + { + return (p.X >= MinEdge.X && p.X <= MaxEdge.X && + p.Y >= MinEdge.Y && p.Y <= MaxEdge.Y && + p.Z >= MinEdge.Z && p.Z <= MaxEdge.Z); + }; + + //! Determinates if a point is within this box and its borders. + //! \param p: Point to check. + //! \return Returns true if the point is withing the box, and false if it is not. + bool isPointTotalInside(const vector3d& p) const + { + return (p.X > MinEdge.X && p.X < MaxEdge.X && + p.Y > MinEdge.Y && p.Y < MaxEdge.Y && + p.Z > MinEdge.Z && p.Z < MaxEdge.Z); + }; + + //! Determinates if the box intersects with an other box. + //! \param other: Other box to check a intersection with. + //! \return Returns true if there is a intersection with the other box, + //! otherwise false. + bool intersectsWithBox(const aabbox3d& other) const + { + return (MinEdge <= other.MaxEdge && MaxEdge >= other.MinEdge); + } + + bool isFullInside(const aabbox3d& other) const + { + return MinEdge >= other.MinEdge && MaxEdge <= other.MaxEdge; + } + + //! Tests if the box intersects with a line + //! \param line: Line to test intersection with. + //! \return Returns true if there is an intersection and false if not. + bool intersectsWithLine(const line3d& line) const + { + return intersectsWithLine(line.getMiddle(), line.getVector().normalize(), + (T)(line.getLength() * 0.5)); + } + + //! Tests if the box intersects with a line + //! \return Returns true if there is an intersection and false if not. + bool intersectsWithLine(const vector3d& linemiddle, + const vector3d& linevect, + T halflength) const + { + const vector3d e = getExtent() * (T)0.5; + const vector3d t = getCenter() - linemiddle; + T r; + + if ((fabs(t.X) > e.X + halflength * fabs(linevect.X)) || + (fabs(t.Y) > e.Y + halflength * fabs(linevect.Y)) || + (fabs(t.Z) > e.Z + halflength * fabs(linevect.Z)) ) + return false; + + r = e.Y * (T)fabs(linevect.Z) + e.Z * (T)fabs(linevect.Y); + if (fabs(t.Y*linevect.Z - t.Z*linevect.Y) > r ) + return false; + + r = e.X * (T)fabs(linevect.Z) + e.Z * (T)fabs(linevect.X); + if (fabs(t.Z*linevect.X - t.X*linevect.Z) > r ) + return false; + + r = e.X * (T)fabs(linevect.Y) + e.Y * (T)fabs(linevect.X); + if (fabs(t.X*linevect.Y - t.Y*linevect.X) > r) + return false; + + return true; + } + + //! Classifies a relation with a plane. + //! \param plane: Plane to classify relation to. + //! \return Returns ISREL3D_FRONT if the box is in front of the plane, + //! ISREL3D_BACK if the box is back of the plane, and + //! ISREL3D_CLIPPED if is on both sides of the plane. + EIntersectionRelation3D classifyPlaneRelation(const plane3d& plane) const + { + vector3d nearPoint(MaxEdge); + vector3d farPoint(MinEdge); + + if (plane.Normal.X > (T)0) + { + nearPoint.X = MinEdge.X; + farPoint.X = MaxEdge.X; + } + + if (plane.Normal.Y > (T)0) + { + nearPoint.Y = MinEdge.Y; + farPoint.Y = MaxEdge.Y; + } + + if (plane.Normal.Z > (T)0) + { + nearPoint.Z = MinEdge.Z; + farPoint.Z = MaxEdge.Z; + } + + if (plane.Normal.dotProduct(nearPoint) + plane.D > (T)0) + return ISREL3D_FRONT; + + if (plane.Normal.dotProduct(farPoint) + plane.D > (T)0) + return ISREL3D_CLIPPED; + + return ISREL3D_BACK; + } + + + //! returns center of the bounding box + vector3d getCenter() const + { + return (MinEdge + MaxEdge) / 2; + } + + //! returns extend of the box + vector3d getExtent() const + { + return MaxEdge - MinEdge; + } + + + //! stores all 8 edges of the box into a array + //! \param edges: Pointer to array of 8 edges + void getEdges(vector3d *edges) const + { + const core::vector3d middle = getCenter(); + const core::vector3d diag = middle - MaxEdge; + + /* + Edges are stored in this way: + Hey, am I an ascii artist, or what? :) niko. + /4--------/0 + / | / | + / | / | + 6---------2 | + | 5- - -| -1 + | / | / + |/ | / + 7---------3/ + */ + + edges[0].set(middle.X + diag.X, middle.Y + diag.Y, middle.Z + diag.Z); + edges[1].set(middle.X + diag.X, middle.Y - diag.Y, middle.Z + diag.Z); + edges[2].set(middle.X + diag.X, middle.Y + diag.Y, middle.Z - diag.Z); + edges[3].set(middle.X + diag.X, middle.Y - diag.Y, middle.Z - diag.Z); + edges[4].set(middle.X - diag.X, middle.Y + diag.Y, middle.Z + diag.Z); + edges[5].set(middle.X - diag.X, middle.Y - diag.Y, middle.Z + diag.Z); + edges[6].set(middle.X - diag.X, middle.Y + diag.Y, middle.Z - diag.Z); + edges[7].set(middle.X - diag.X, middle.Y - diag.Y, middle.Z - diag.Z); + } + + + //! returns if the box is empty, which means that there is + //! no space within the min and the max edge. + bool isEmpty() const + { + return MinEdge.equals ( MaxEdge ); + } + + //! repairs the box, if for example MinEdge and MaxEdge are swapped. + void repair() + { + T t; + + if (MinEdge.X > MaxEdge.X) + { t=MinEdge.X; MinEdge.X = MaxEdge.X; MaxEdge.X=t; } + if (MinEdge.Y > MaxEdge.Y) + { t=MinEdge.Y; MinEdge.Y = MaxEdge.Y; MaxEdge.Y=t; } + if (MinEdge.Z > MaxEdge.Z) + { t=MinEdge.Z; MinEdge.Z = MaxEdge.Z; MaxEdge.Z=t; } + } + + //! Calculates a new interpolated bounding box. + //! \param other: other box to interpolate between + //! \param d: value between 0.0f and 1.0f. + aabbox3d getInterpolated(const aabbox3d& other, f32 d) const + { + f32 inv = 1.0f - d; + return aabbox3d((other.MinEdge*inv) + (MinEdge*d), + (other.MaxEdge*inv) + (MaxEdge*d)); + } + + // member variables + + vector3d MinEdge; + vector3d MaxEdge; +}; + + //! Typedef for a f32 3d bounding box. + typedef aabbox3d aabbox3df; + //! Typedef for an integer 3d bounding box. + typedef aabbox3d aabbox3di; + + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/coreutil.h b/src/dep/include/irrlicht/coreutil.h index 14aefb7..6b030d7 100644 --- a/src/dep/include/irrlicht/coreutil.h +++ b/src/dep/include/irrlicht/coreutil.h @@ -1,55 +1,55 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_CORE_UTIL_H_INCLUDED__ -#define __IRR_CORE_UTIL_H_INCLUDED__ - -#include "irrString.h" - -namespace irr -{ -namespace core -{ - -/*! \file irrxml.h - \brief File containing useful basic utility functions -*/ - -// ----------------------------- some basic quite often used string functions -------------------------- - -static const stringc irrEmtpyStringc = ""; - -//! cut the filename extension from a string -inline stringc& cutFilenameExtension ( stringc &dest, const stringc &source ) -{ - s32 endPos = source.findLast ( '.' ); - dest = source.subString ( 0, endPos < 0 ? source.size () : endPos ); - return dest; -} - -//! get the filename extension from a string -inline stringc& getFileNameExtension ( stringc &dest, const stringc &source ) -{ - s32 endPos = source.findLast ( '.' ); - if ( endPos < 0 ) - dest = ""; - else - dest = source.subString ( endPos, source.size () ); - return dest; -} - -//! some standard function ( to remove dependencies ) -#undef isdigit -#undef isspace -#undef isupper -inline s32 isdigit(s32 c) { return c >= '0' && c <= '9'; } -inline s32 isspace(s32 c) { return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v'; } -inline s32 isupper(s32 c) { return c >= 'A' && c <= 'Z'; } - - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_CORE_UTIL_H_INCLUDED__ +#define __IRR_CORE_UTIL_H_INCLUDED__ + +#include "irrString.h" + +namespace irr +{ +namespace core +{ + +/*! \file irrxml.h + \brief File containing useful basic utility functions +*/ + +// ----------------------------- some basic quite often used string functions -------------------------- + +static const stringc irrEmtpyStringc = ""; + +//! cut the filename extension from a string +inline stringc& cutFilenameExtension ( stringc &dest, const stringc &source ) +{ + s32 endPos = source.findLast ( '.' ); + dest = source.subString ( 0, endPos < 0 ? source.size () : endPos ); + return dest; +} + +//! get the filename extension from a string +inline stringc& getFileNameExtension ( stringc &dest, const stringc &source ) +{ + s32 endPos = source.findLast ( '.' ); + if ( endPos < 0 ) + dest = ""; + else + dest = source.subString ( endPos, source.size () ); + return dest; +} + +//! some standard function ( to remove dependencies ) +#undef isdigit +#undef isspace +#undef isupper +inline s32 isdigit(s32 c) { return c >= '0' && c <= '9'; } +inline s32 isspace(s32 c) { return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v'; } +inline s32 isupper(s32 c) { return c >= 'A' && c <= 'Z'; } + + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/dimension2d.h b/src/dep/include/irrlicht/dimension2d.h index f124f2a..fa7a769 100644 --- a/src/dep/include/irrlicht/dimension2d.h +++ b/src/dep/include/irrlicht/dimension2d.h @@ -1,71 +1,71 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_DIMENSION2D_H_INCLUDED__ -#define __IRR_DIMENSION2D_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr -{ -namespace core -{ - - //! Specifies a 2 dimensional size. - template - class dimension2d - { - public: - - dimension2d() - : Width(0), Height(0) {}; - - dimension2d(T width, T height) - : Width(width), Height(height) {}; - - dimension2d(const dimension2d& other) - : Width(other.Width), Height(other.Height) {}; - - - bool operator == (const dimension2d& other) const - { - return Width == other.Width && Height == other.Height; - } - - - bool operator != (const dimension2d& other) const - { - return Width != other.Width || Height != other.Height; - } - - const dimension2d& operator=(const dimension2d& other) - { - Width = other.Width; - Height = other.Height; - return *this; - } - - dimension2d operator/(T scale) - { - return dimension2d(Width/scale, Height/scale); - } - - dimension2d operator*(T scale) - { - return dimension2d(Width*scale, Height*scale); - } - - T Width, Height; - }; - - //! Typedef for a f32 dimension. - typedef dimension2d dimension2df; - //! Typedef for an integer dimension. - typedef dimension2d dimension2di; - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_DIMENSION2D_H_INCLUDED__ +#define __IRR_DIMENSION2D_H_INCLUDED__ + +#include "irrTypes.h" + +namespace irr +{ +namespace core +{ + + //! Specifies a 2 dimensional size. + template + class dimension2d + { + public: + + dimension2d() + : Width(0), Height(0) {}; + + dimension2d(T width, T height) + : Width(width), Height(height) {}; + + dimension2d(const dimension2d& other) + : Width(other.Width), Height(other.Height) {}; + + + bool operator == (const dimension2d& other) const + { + return Width == other.Width && Height == other.Height; + } + + + bool operator != (const dimension2d& other) const + { + return Width != other.Width || Height != other.Height; + } + + const dimension2d& operator=(const dimension2d& other) + { + Width = other.Width; + Height = other.Height; + return *this; + } + + dimension2d operator/(T scale) + { + return dimension2d(Width/scale, Height/scale); + } + + dimension2d operator*(T scale) + { + return dimension2d(Width*scale, Height*scale); + } + + T Width, Height; + }; + + //! Typedef for a f32 dimension. + typedef dimension2d dimension2df; + //! Typedef for an integer dimension. + typedef dimension2d dimension2di; + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/fast_atof.h b/src/dep/include/irrlicht/fast_atof.h index 14a3035..b0f3306 100644 --- a/src/dep/include/irrlicht/fast_atof.h +++ b/src/dep/include/irrlicht/fast_atof.h @@ -1,114 +1,114 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h - -#ifndef __FAST_A_TO_F_H_INCLUDED__ -#define __FAST_A_TO_F_H_INCLUDED__ - -#include -#include "irrMath.h" - -namespace irr -{ -namespace core -{ - -const float fast_atof_table[] = { - 0.f, - 0.1f, - 0.01f, - 0.001f, - 0.0001f, - 0.00001f, - 0.000001f, - 0.0000001f, - 0.00000001f, - 0.000000001f, - 0.0000000001f, - 0.00000000001f, - 0.000000000001f, - 0.0000000000001f, - 0.00000000000001f, - 0.000000000000001f - }; - -inline u32 strtol10( const char* in, const char* &out) -{ - u32 value = 0; - c8 symbol; - - while ( 1 ) - { - symbol = *in; - if ( symbol < '0' || symbol > '9' ) - break; - - value = ( value * 10 ) + ( symbol - '0' ); - in += 1; - } - out = in; - return value; -} - -//! Provides a fast function for converting a string into a float, -//! about 6 times faster than atof in win32. -// If you find any bugs, please send them to me, niko (at) irrlicht3d.org. -inline const char* fast_atof_move( const char* c, float& out) -{ - bool inv = false; - const char *t; - float f; - - if (*c=='-') - { - c++; - inv = true; - } - - //f = (float)strtol(c, &t, 10); - f = (float) strtol10 ( c, t ); - - c = t; - - if (*c == '.') - { - c++; - - //float pl = (float)strtol(c, &t, 10); - float pl = (float) strtol10 ( c, t ); - pl *= fast_atof_table[t-c]; - - f += pl; - - c = t; - - if (*c == 'e') - { - ++c; - //float exp = (float)strtol(c, &t, 10); - float exp = (float)strtol10(c, t); - - f *= (float)pow(10.0f, exp); - c = t; - } - } - - if (inv) - f *= -1.0f; - - out = f; - return c; -} - -inline float fast_atof(const char* c) -{ - float ret; - fast_atof_move(c, ret); - return ret; -} - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine" and the "irrXML" project. +// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h + +#ifndef __FAST_A_TO_F_H_INCLUDED__ +#define __FAST_A_TO_F_H_INCLUDED__ + +#include +#include "irrMath.h" + +namespace irr +{ +namespace core +{ + +const float fast_atof_table[] = { + 0.f, + 0.1f, + 0.01f, + 0.001f, + 0.0001f, + 0.00001f, + 0.000001f, + 0.0000001f, + 0.00000001f, + 0.000000001f, + 0.0000000001f, + 0.00000000001f, + 0.000000000001f, + 0.0000000000001f, + 0.00000000000001f, + 0.000000000000001f + }; + +inline u32 strtol10( const char* in, const char* &out) +{ + u32 value = 0; + c8 symbol; + + while ( 1 ) + { + symbol = *in; + if ( symbol < '0' || symbol > '9' ) + break; + + value = ( value * 10 ) + ( symbol - '0' ); + in += 1; + } + out = in; + return value; +} + +//! Provides a fast function for converting a string into a float, +//! about 6 times faster than atof in win32. +// If you find any bugs, please send them to me, niko (at) irrlicht3d.org. +inline const char* fast_atof_move( const char* c, float& out) +{ + bool inv = false; + const char *t; + float f; + + if (*c=='-') + { + c++; + inv = true; + } + + //f = (float)strtol(c, &t, 10); + f = (float) strtol10 ( c, t ); + + c = t; + + if (*c == '.') + { + c++; + + //float pl = (float)strtol(c, &t, 10); + float pl = (float) strtol10 ( c, t ); + pl *= fast_atof_table[t-c]; + + f += pl; + + c = t; + + if (*c == 'e') + { + ++c; + //float exp = (float)strtol(c, &t, 10); + float exp = (float)strtol10(c, t); + + f *= (float)pow(10.0f, exp); + c = t; + } + } + + if (inv) + f *= -1.0f; + + out = f; + return c; +} + +inline float fast_atof(const char* c) +{ + float ret; + fast_atof_move(c, ret); + return ret; +} + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/heapsort.h b/src/dep/include/irrlicht/heapsort.h index 507ebce..fec708a 100644 --- a/src/dep/include/irrlicht/heapsort.h +++ b/src/dep/include/irrlicht/heapsort.h @@ -1,73 +1,73 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_HEAPSORT_H_INCLUDED__ -#define __IRR_HEAPSORT_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr -{ -namespace core -{ - -//! Sinks an element into the heap. -template -inline void heapsink(T*array, s32 element, s32 max) -{ - while ((element<<1) < max) // there is a left child - { - s32 j = (element<<1); - - if (j+1 < max && array[j] < array[j+1]) - j = j+1; // take right child - - if (array[element] < array[j]) - { - T t = array[j]; // swap elements - array[j] = array[element]; - array[element] = t; - element = j; - } - else - return; - } -} - - -//! Sorts an array with size 'size' using heapsort. -template -inline void heapsort(T* array_, s32 size) -{ - // for heapsink we pretent this is not c++, where - // arrays start with index 0. So we decrease the array pointer, - // the maximum always +2 and the element always +1 - - T* virtualArray = array_ - 1; - s32 virtualSize = size + 2; - s32 i; - - // build heap - - for (i=((size-1)/2); i>=0; --i) - heapsink(virtualArray, i+1, virtualSize-1); - - // sort array - - for (i=size-1; i>=0; --i) - { - T t = array_[0]; - array_[0] = array_[i]; - array_[i] = t; - heapsink(virtualArray, 1, i + 1); - } -} - -} // end namespace core -} // end namespace irr - - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_HEAPSORT_H_INCLUDED__ +#define __IRR_HEAPSORT_H_INCLUDED__ + +#include "irrTypes.h" + +namespace irr +{ +namespace core +{ + +//! Sinks an element into the heap. +template +inline void heapsink(T*array, s32 element, s32 max) +{ + while ((element<<1) < max) // there is a left child + { + s32 j = (element<<1); + + if (j+1 < max && array[j] < array[j+1]) + j = j+1; // take right child + + if (array[element] < array[j]) + { + T t = array[j]; // swap elements + array[j] = array[element]; + array[element] = t; + element = j; + } + else + return; + } +} + + +//! Sorts an array with size 'size' using heapsort. +template +inline void heapsort(T* array_, s32 size) +{ + // for heapsink we pretent this is not c++, where + // arrays start with index 0. So we decrease the array pointer, + // the maximum always +2 and the element always +1 + + T* virtualArray = array_ - 1; + s32 virtualSize = size + 2; + s32 i; + + // build heap + + for (i=((size-1)/2); i>=0; --i) + heapsink(virtualArray, i+1, virtualSize-1); + + // sort array + + for (i=size-1; i>=0; --i) + { + T t = array_[0]; + array_[0] = array_[i]; + array_[i] = t; + heapsink(virtualArray, 1, i + 1); + } +} + +} // end namespace core +} // end namespace irr + + + +#endif + diff --git a/src/dep/include/irrlicht/irrAllocator.h b/src/dep/include/irrlicht/irrAllocator.h index 9c12f6c..efdde1c 100644 --- a/src/dep/include/irrlicht/irrAllocator.h +++ b/src/dep/include/irrlicht/irrAllocator.h @@ -1,116 +1,116 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h - -#ifndef __IRR_ALLOCATOR_H_INCLUDED__ -#define __IRR_ALLOCATOR_H_INCLUDED__ - -#include "irrTypes.h" -#include -#include - -namespace irr -{ -namespace core -{ - -#ifdef DEBUG_CLIENTBLOCK -#undef DEBUG_CLIENTBLOCK -#define DEBUG_CLIENTBLOCK new -#endif - -//! Very simple allocator implementation, containers using it are able to -//! be used it across dll boundaries -template -class irrAllocator -{ -public: - - //! destructor - virtual ~irrAllocator() {} - - //! allocate memory for an array of objects - T* allocate(size_t cnt) - { - return (T*)internal_new(cnt* sizeof(T)); - } - - //! deallocate memory for an array of objects - void deallocate(T* ptr) - { - internal_delete(ptr); - } - - //! construct an element - void construct(T* ptr, const T&e) - { - new ((void*)ptr) T(e); - } - - //! destruct an element - void destruct(T* ptr) - { - ptr->~T(); - } - -protected: - - virtual void* internal_new(size_t cnt) - { - return operator new(cnt); - } - - virtual void internal_delete(void* ptr) - { - operator delete(ptr); - } - -}; - - -//! fast allocator, only to be used in containers inside the same memory heap. -/** Containers using it are NOT able to be used it across dll boundaries. Use this -when using in an internal class or function or when compiled into a static lib */ -template -class irrAllocatorFast -{ -public: - - //! allocate memory for an array of objects - T* allocate(size_t cnt) - { - return (T*)operator new(cnt* sizeof(T)); - } - - //! deallocate memory for an array of objects - void deallocate(T* ptr) - { - operator delete(ptr); - } - - //! construct an element - void construct(T* ptr, const T&e) - { - new ((void*)ptr) T(e); - } - - //! destruct an element - void destruct(T* ptr) - { - ptr->~T(); - } -}; - - - -#ifdef DEBUG_CLIENTBLOCK -#undef DEBUG_CLIENTBLOCK -#define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) -#endif - - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine" and the "irrXML" project. +// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h + +#ifndef __IRR_ALLOCATOR_H_INCLUDED__ +#define __IRR_ALLOCATOR_H_INCLUDED__ + +#include "irrTypes.h" +#include +#include + +namespace irr +{ +namespace core +{ + +#ifdef DEBUG_CLIENTBLOCK +#undef DEBUG_CLIENTBLOCK +#define DEBUG_CLIENTBLOCK new +#endif + +//! Very simple allocator implementation, containers using it are able to +//! be used it across dll boundaries +template +class irrAllocator +{ +public: + + //! destructor + virtual ~irrAllocator() {} + + //! allocate memory for an array of objects + T* allocate(size_t cnt) + { + return (T*)internal_new(cnt* sizeof(T)); + } + + //! deallocate memory for an array of objects + void deallocate(T* ptr) + { + internal_delete(ptr); + } + + //! construct an element + void construct(T* ptr, const T&e) + { + new ((void*)ptr) T(e); + } + + //! destruct an element + void destruct(T* ptr) + { + ptr->~T(); + } + +protected: + + virtual void* internal_new(size_t cnt) + { + return operator new(cnt); + } + + virtual void internal_delete(void* ptr) + { + operator delete(ptr); + } + +}; + + +//! fast allocator, only to be used in containers inside the same memory heap. +/** Containers using it are NOT able to be used it across dll boundaries. Use this +when using in an internal class or function or when compiled into a static lib */ +template +class irrAllocatorFast +{ +public: + + //! allocate memory for an array of objects + T* allocate(size_t cnt) + { + return (T*)operator new(cnt* sizeof(T)); + } + + //! deallocate memory for an array of objects + void deallocate(T* ptr) + { + operator delete(ptr); + } + + //! construct an element + void construct(T* ptr, const T&e) + { + new ((void*)ptr) T(e); + } + + //! destruct an element + void destruct(T* ptr) + { + ptr->~T(); + } +}; + + + +#ifdef DEBUG_CLIENTBLOCK +#undef DEBUG_CLIENTBLOCK +#define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) +#endif + + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/irrArray.h b/src/dep/include/irrlicht/irrArray.h index 82b1f83..1b80daa 100644 --- a/src/dep/include/irrlicht/irrArray.h +++ b/src/dep/include/irrlicht/irrArray.h @@ -1,521 +1,521 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h - -#ifndef __IRR_ARRAY_H_INCLUDED__ -#define __IRR_ARRAY_H_INCLUDED__ - -#include "irrTypes.h" -#include "heapsort.h" -#include "irrAllocator.h" - -namespace irr -{ -namespace core -{ - -//! Self reallocating template array (like stl vector) with additional features. -/** Some features are: Heap sorting, binary search methods, easier debugging. -*/ -template > -class array -{ - -public: - - array() - : data(0), allocated(0), used(0), - free_when_destroyed(true), is_sorted(true) - { - } - - //! Constructs a array and allocates an initial chunk of memory. - //! \param start_count: Amount of elements to allocate. - array(u32 start_count) - : data(0), allocated(0), used(0), - free_when_destroyed(true), is_sorted(true) - { - reallocate(start_count); - } - - - //! Copy constructor - array(const array& other) - : data(0) - { - *this = other; - } - - - - //! Destructor. Frees allocated memory, if set_free_when_destroyed - //! was not set to false by the user before. - ~array() - { - if (free_when_destroyed) - { - for (u32 i=0; i allocated) - { - // reallocate(used * 2 +1); - // this doesn't work if the element is in the same array. So - // we'll copy the element first to be sure we'll get no data - // corruption - - T e(element); - reallocate(used * 2 +1); // increase data block - - allocator.construct(&data[used++], e); // data[used++] = e; // push_back - } - else - { - //data[used++] = element; - // instead of using this here, we copy it the safe way: - allocator.construct(&data[used++], element); - } - - is_sorted = false; - } - - - //! Adds an element at the front of the array. If the array is to small to - //! add this new element, the array is made bigger. Please note that this - //! is slow, because the whole array needs to be copied for this. - //! \param element: Element to add at the back of the array. - void push_front(const T& element) - { - if (used + 1 > allocated) - reallocate(used +1); - - for (u32 i=used; i>0; --i) - { - //data[i] = data[i-1]; - allocator.construct(&data[i], data[i-1]); - } - - // data[0] = element; - allocator.construct(&data[0], element); - - is_sorted = false; - ++used; - } - - - //! Insert item into array at specified position. Please use this - //! only if you know what you are doing (possible performance loss). - //! The preferred method of adding elements should be push_back(). - //! \param element: Element to be inserted - //! \param index: Where position to insert the new element. - void insert(const T& element, u32 index=0) - { - _IRR_DEBUG_BREAK_IF(index>used) // access violation - - if (used + 1 > allocated) - reallocate(used +1); - - for (u32 i=used++; i>index; --i) - allocator.construct(&data[i], data[i-1]); // data[i] = data[i-1]; - - allocator.construct(&data[index], element); // data[index] = element; - is_sorted = false; - } - - - - - //! Clears the array and deletes all allocated memory. - void clear() - { - for (u32 i=0; i& other) - { - if (data) - { - for (u32 i=0; i& other) const - { - if (used != other.used) - return false; - - for (u32 i=0; i& other) const - { - return !(*this==other); - } - - //! Direct access operator - T& operator [](u32 index) - { - _IRR_DEBUG_BREAK_IF(index>=used) // access violation - - return data[index]; - } - - - - //! Direct access operator - const T& operator [](u32 index) const - { - _IRR_DEBUG_BREAK_IF(index>=used) // access violation - - return data[index]; - } - - //! Gets last frame - T& getLast() - { - _IRR_DEBUG_BREAK_IF(!used) // access violation - - return data[used-1]; - } - - - //! Gets last frame - const T& getLast() const - { - _IRR_DEBUG_BREAK_IF(!used) // access violation - - return data[used-1]; - } - - //! Returns a pointer to the array. - //! \return Pointer to the array. - T* pointer() - { - return data; - } - - - - //! Returns a const pointer to the array. - //! \return Pointer to the array. - const T* const_pointer() const - { - return data; - } - - - - //! Returns size of used array. - //! \return Size of elements in the array. - u32 size() const - { - return used; - } - - - - //! Returns amount memory allocated. - //! \return Returns amount of memory allocated. The amount of bytes - //! allocated would be allocated_size() * sizeof(ElementsUsed); - u32 allocated_size() const - { - return allocated; - } - - - - //! Returns true if array is empty - //! \return True if the array is empty, false if not. - bool empty() const - { - return used == 0; - } - - - - //! Sorts the array using heapsort. There is no additional memory waste and - //! the algorithm performs O(n*log n) in worst case. - void sort() - { - if (is_sorted || used<2) - return; - - heapsort(data, used); - is_sorted = true; - } - - - - //! Performs a binary search for an element, returns -1 if not found. - //! The array will be sorted before the binary search if it is not - //! already sorted. - //! \param element: Element to search for. - //! \return Returns position of the searched element if it was found, - //! otherwise -1 is returned. - s32 binary_search(const T& element) - { - sort(); - return binary_search(element, 0, used-1); - } - - //! Performs a binary search for an element, returns -1 if not found. - //! The array must be sorted prior - //! \param element: Element to search for. - //! \return Returns position of the searched element if it was found, - //! otherwise -1 is returned. - s32 binary_search_const(const T& element) const - { - return binary_search(element, 0, used-1); - } - - - - //! Performs a binary search for an element, returns -1 if not found. - //! \param element: Element to search for. - //! \param left: First left index - //! \param right: Last right index. - //! \return Returns position of the searched element if it was found, - //! otherwise -1 is returned. - s32 binary_search(const T& element, s32 left, s32 right) const - { - if (!used) - return -1; - - s32 m; - - do - { - m = (left+right)>>1; - - if (element < data[m]) - right = m - 1; - else - left = m + 1; - - } while((element < data[m] || data[m] < element) && left<=right); - - // this last line equals to: - // " while((element != array[m]) && left<=right);" - // but we only want to use the '<' operator. - // the same in next line, it is "(element == array[m])" - - if (!(element < data[m]) && !(data[m] < element)) - return m; - - return -1; - } - - - //! Finds an element in linear time, which is very slow. Use - //! binary_search for faster finding. Only works if =operator is implemented. - //! \param element: Element to search for. - //! \return Returns position of the searched element if it was found, - //! otherwise -1 is returned. - s32 linear_search(const T& element) const - { - for (u32 i=0; i=0; --i) - if (data[i] == element) - return i; - - return -1; - } - - - - //! Erases an element from the array. May be slow, because all elements - //! following after the erased element have to be copied. - //! \param index: Index of element to be erased. - void erase(u32 index) - { - _IRR_DEBUG_BREAK_IF(index>=used) // access violation - - for (u32 i=index+1; i=used || count<1 || index+count>used) // access violation - - u32 i; - for (i=index; i index+count) - allocator.destruct(&data[i-count]); - - allocator.construct(&data[i-count], data[i]); // data[i-count] = data[i]; - - if (i >= used-count) - allocator.destruct(&data[i]); - } - - used-= count; - } - - - //! Sets if the array is sorted - void set_sorted(bool _is_sorted) - { - is_sorted = _is_sorted; - } - - - private: - - T* data; - u32 allocated; - u32 used; - bool free_when_destroyed; - bool is_sorted; - TAlloc allocator; -}; - - -} // end namespace core -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine" and the "irrXML" project. +// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h + +#ifndef __IRR_ARRAY_H_INCLUDED__ +#define __IRR_ARRAY_H_INCLUDED__ + +#include "irrTypes.h" +#include "heapsort.h" +#include "irrAllocator.h" + +namespace irr +{ +namespace core +{ + +//! Self reallocating template array (like stl vector) with additional features. +/** Some features are: Heap sorting, binary search methods, easier debugging. +*/ +template > +class array +{ + +public: + + array() + : data(0), allocated(0), used(0), + free_when_destroyed(true), is_sorted(true) + { + } + + //! Constructs a array and allocates an initial chunk of memory. + //! \param start_count: Amount of elements to allocate. + array(u32 start_count) + : data(0), allocated(0), used(0), + free_when_destroyed(true), is_sorted(true) + { + reallocate(start_count); + } + + + //! Copy constructor + array(const array& other) + : data(0) + { + *this = other; + } + + + + //! Destructor. Frees allocated memory, if set_free_when_destroyed + //! was not set to false by the user before. + ~array() + { + if (free_when_destroyed) + { + for (u32 i=0; i allocated) + { + // reallocate(used * 2 +1); + // this doesn't work if the element is in the same array. So + // we'll copy the element first to be sure we'll get no data + // corruption + + T e(element); + reallocate(used * 2 +1); // increase data block + + allocator.construct(&data[used++], e); // data[used++] = e; // push_back + } + else + { + //data[used++] = element; + // instead of using this here, we copy it the safe way: + allocator.construct(&data[used++], element); + } + + is_sorted = false; + } + + + //! Adds an element at the front of the array. If the array is to small to + //! add this new element, the array is made bigger. Please note that this + //! is slow, because the whole array needs to be copied for this. + //! \param element: Element to add at the back of the array. + void push_front(const T& element) + { + if (used + 1 > allocated) + reallocate(used +1); + + for (u32 i=used; i>0; --i) + { + //data[i] = data[i-1]; + allocator.construct(&data[i], data[i-1]); + } + + // data[0] = element; + allocator.construct(&data[0], element); + + is_sorted = false; + ++used; + } + + + //! Insert item into array at specified position. Please use this + //! only if you know what you are doing (possible performance loss). + //! The preferred method of adding elements should be push_back(). + //! \param element: Element to be inserted + //! \param index: Where position to insert the new element. + void insert(const T& element, u32 index=0) + { + _IRR_DEBUG_BREAK_IF(index>used) // access violation + + if (used + 1 > allocated) + reallocate(used +1); + + for (u32 i=used++; i>index; --i) + allocator.construct(&data[i], data[i-1]); // data[i] = data[i-1]; + + allocator.construct(&data[index], element); // data[index] = element; + is_sorted = false; + } + + + + + //! Clears the array and deletes all allocated memory. + void clear() + { + for (u32 i=0; i& other) + { + if (data) + { + for (u32 i=0; i& other) const + { + if (used != other.used) + return false; + + for (u32 i=0; i& other) const + { + return !(*this==other); + } + + //! Direct access operator + T& operator [](u32 index) + { + _IRR_DEBUG_BREAK_IF(index>=used) // access violation + + return data[index]; + } + + + + //! Direct access operator + const T& operator [](u32 index) const + { + _IRR_DEBUG_BREAK_IF(index>=used) // access violation + + return data[index]; + } + + //! Gets last frame + T& getLast() + { + _IRR_DEBUG_BREAK_IF(!used) // access violation + + return data[used-1]; + } + + + //! Gets last frame + const T& getLast() const + { + _IRR_DEBUG_BREAK_IF(!used) // access violation + + return data[used-1]; + } + + //! Returns a pointer to the array. + //! \return Pointer to the array. + T* pointer() + { + return data; + } + + + + //! Returns a const pointer to the array. + //! \return Pointer to the array. + const T* const_pointer() const + { + return data; + } + + + + //! Returns size of used array. + //! \return Size of elements in the array. + u32 size() const + { + return used; + } + + + + //! Returns amount memory allocated. + //! \return Returns amount of memory allocated. The amount of bytes + //! allocated would be allocated_size() * sizeof(ElementsUsed); + u32 allocated_size() const + { + return allocated; + } + + + + //! Returns true if array is empty + //! \return True if the array is empty, false if not. + bool empty() const + { + return used == 0; + } + + + + //! Sorts the array using heapsort. There is no additional memory waste and + //! the algorithm performs O(n*log n) in worst case. + void sort() + { + if (is_sorted || used<2) + return; + + heapsort(data, used); + is_sorted = true; + } + + + + //! Performs a binary search for an element, returns -1 if not found. + //! The array will be sorted before the binary search if it is not + //! already sorted. + //! \param element: Element to search for. + //! \return Returns position of the searched element if it was found, + //! otherwise -1 is returned. + s32 binary_search(const T& element) + { + sort(); + return binary_search(element, 0, used-1); + } + + //! Performs a binary search for an element, returns -1 if not found. + //! The array must be sorted prior + //! \param element: Element to search for. + //! \return Returns position of the searched element if it was found, + //! otherwise -1 is returned. + s32 binary_search_const(const T& element) const + { + return binary_search(element, 0, used-1); + } + + + + //! Performs a binary search for an element, returns -1 if not found. + //! \param element: Element to search for. + //! \param left: First left index + //! \param right: Last right index. + //! \return Returns position of the searched element if it was found, + //! otherwise -1 is returned. + s32 binary_search(const T& element, s32 left, s32 right) const + { + if (!used) + return -1; + + s32 m; + + do + { + m = (left+right)>>1; + + if (element < data[m]) + right = m - 1; + else + left = m + 1; + + } while((element < data[m] || data[m] < element) && left<=right); + + // this last line equals to: + // " while((element != array[m]) && left<=right);" + // but we only want to use the '<' operator. + // the same in next line, it is "(element == array[m])" + + if (!(element < data[m]) && !(data[m] < element)) + return m; + + return -1; + } + + + //! Finds an element in linear time, which is very slow. Use + //! binary_search for faster finding. Only works if =operator is implemented. + //! \param element: Element to search for. + //! \return Returns position of the searched element if it was found, + //! otherwise -1 is returned. + s32 linear_search(const T& element) const + { + for (u32 i=0; i=0; --i) + if (data[i] == element) + return i; + + return -1; + } + + + + //! Erases an element from the array. May be slow, because all elements + //! following after the erased element have to be copied. + //! \param index: Index of element to be erased. + void erase(u32 index) + { + _IRR_DEBUG_BREAK_IF(index>=used) // access violation + + for (u32 i=index+1; i=used || count<1 || index+count>used) // access violation + + u32 i; + for (i=index; i index+count) + allocator.destruct(&data[i-count]); + + allocator.construct(&data[i-count], data[i]); // data[i-count] = data[i]; + + if (i >= used-count) + allocator.destruct(&data[i]); + } + + used-= count; + } + + + //! Sets if the array is sorted + void set_sorted(bool _is_sorted) + { + is_sorted = _is_sorted; + } + + + private: + + T* data; + u32 allocated; + u32 used; + bool free_when_destroyed; + bool is_sorted; + TAlloc allocator; +}; + + +} // end namespace core +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/irrList.h b/src/dep/include/irrlicht/irrList.h index e4a927f..b2ca544 100644 --- a/src/dep/include/irrlicht/irrList.h +++ b/src/dep/include/irrlicht/irrList.h @@ -1,311 +1,311 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_LIST_H_INCLUDED__ -#define __IRR_LIST_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr -{ -namespace core -{ - -//! Double linked list template. -template -class list -{ -private: - - //! List element node with pointer to previous and next element in the list. - struct SKListNode - { - SKListNode() : next(0), prev(0) {}; - - SKListNode* next; - SKListNode* prev; - T element; - }; - -public: - - //! List iterator. - class Iterator - { - public: - - Iterator() : current(0) {}; - - Iterator& operator ++() { current = current->next; return *this; }; - Iterator& operator --() { current = current->prev; return *this; }; - Iterator operator ++(s32) { Iterator tmp = *this; current = current->next; return tmp; }; - Iterator operator --(s32) { Iterator tmp = *this; current = current->prev; return tmp; }; - - Iterator operator+(s32 num) const - { - Iterator tmp = *this; - - if (num >= 0) - while (num-- && tmp.current != 0) ++tmp; - else - while (num++ && tmp.current != 0) --tmp; - - return tmp; - } - - Iterator& operator+=(s32 num) - { - if (num >= 0) - while (num-- && this->current != 0) ++(*this); - else - while (num++ && this->current != 0) --(*this); - - return *this; - } - - Iterator operator-(s32 num) const { return (*this)+(-num); } - Iterator operator-=(s32 num) const { (*this)+=(-num); return *this; } - - bool operator ==(const Iterator& other) const { return current == other.current; }; - bool operator !=(const Iterator& other) const { return current != other.current; }; - - T& operator *() { return current->element; }; - - private: - - Iterator(SKListNode* begin) : current(begin) {}; - - friend class list; - - SKListNode* current; - }; - - - //! constructor - list() - : root(0), last(0), size(0) {} - - - //! copy constructor - list(const list& other) : root(0), last(0), size(0) - { - *this = other; - } - - - //! destructor - ~list() - { - clear(); - } - - - - //! Assignment operator - void operator=(const list& other) - { - clear(); - - SKListNode* node = other.root; - while(node) - { - push_back(node->element); - node = node->next; - } - } - - - - //! Returns amount of elements in list. - //! \return Returns amount of elements in the list. - u32 getSize() const - { - return size; - } - - - - //! Clears the list, deletes all elements in the list. All existing - //! iterators of this list will be invalid. - void clear() - { - SKListNode* node = root; - while(node) - { - SKListNode* next = node->next; - delete node; - node = next; - } - - root = 0; - last = 0; - size = 0; - } - - - - //! Returns ture if the list is empty. - //! \return Returns true if the list is empty and false if not. - bool empty() const - { - return root == 0; - } - - - - //! Adds an element at the end of the list. - //! \param element: Element to add to the list. - void push_back(const T& element) - { - SKListNode* node = new SKListNode; - node->element = element; - - ++size; - - if (root == 0) - root = node; - - node->prev = last; - - if (last != 0) - last->next = node; - - last = node; - } - - - //! Adds an element at the begin of the list. - //! \param element: Element to add to the list. - void push_front(const T& element) - { - SKListNode* node = new SKListNode; - node->element = element; - - ++size; - - if (root == 0) - { - last = node; - root = node; - } - else - { - node->next = root; - root->prev = node; - root = node; - } - } - - - //! Gets begin node. - //! \return Returns a list iterator pointing to the begin of the list. - Iterator begin() const - { - return Iterator(root); - } - - - //! Gets end node. - //! \return Returns a list iterator pointing to null. - Iterator end() const - { - return Iterator(0); - } - - - //! Gets last element. - //! \return Returns a list iterator pointing to the end of the list. - Iterator getLast() const - { - return Iterator(last); - } - - - //! Inserts an element after an element. - //! \param it: Iterator pointing to element after which the new element - //! should be inserted. - //! \param element: The new element to be insterted into the list. - void insert_after(Iterator& it, const T& element) - { - SKListNode* node = new SKListNode; - node->element = element; - - node->next = it.current->next; - - if (it.current->next) - it.current->next->prev = node; - - node->prev = it.current; - it.current->next = node; - ++size; - - if (it.current == last) - last = node; - } - - - //! Inserts an element before an element. - //! \param it: Iterator pointing to element before which the new element - //! should be inserted. - //! \param element: The new element to be insterted into the list. - void insert_before(Iterator& it, const T& element) - { - SKListNode* node = new SKListNode; - node->element = element; - - node->prev = it.current->prev; - - if (it.current->prev) - it.current->prev->next = node; - - node->next = it.current; - it.current->prev = node; - ++size; - - if (it.current == root) - root = node; - } - - - //! Erases an element - //! \param it: Iterator pointing to the element which should be erased. - //! \return Returns iterator pointing to next element. - Iterator erase(Iterator& it) - { - Iterator returnIterator(it); - ++returnIterator; - - if (it.current == root) - root = it.current->next; - - if (it.current == last) - last = it.current->prev; - - if (it.current->next) - it.current->next->prev = it.current->prev; - - if (it.current->prev) - it.current->prev->next = it.current->next; - - delete it.current; - it.current = 0; - --size; - - return returnIterator; - } - -private: - - SKListNode* root; - SKListNode* last; - u32 size; - -}; - - -} // end namespace core -}// end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_LIST_H_INCLUDED__ +#define __IRR_LIST_H_INCLUDED__ + +#include "irrTypes.h" + +namespace irr +{ +namespace core +{ + +//! Double linked list template. +template +class list +{ +private: + + //! List element node with pointer to previous and next element in the list. + struct SKListNode + { + SKListNode() : next(0), prev(0) {}; + + SKListNode* next; + SKListNode* prev; + T element; + }; + +public: + + //! List iterator. + class Iterator + { + public: + + Iterator() : current(0) {}; + + Iterator& operator ++() { current = current->next; return *this; }; + Iterator& operator --() { current = current->prev; return *this; }; + Iterator operator ++(s32) { Iterator tmp = *this; current = current->next; return tmp; }; + Iterator operator --(s32) { Iterator tmp = *this; current = current->prev; return tmp; }; + + Iterator operator+(s32 num) const + { + Iterator tmp = *this; + + if (num >= 0) + while (num-- && tmp.current != 0) ++tmp; + else + while (num++ && tmp.current != 0) --tmp; + + return tmp; + } + + Iterator& operator+=(s32 num) + { + if (num >= 0) + while (num-- && this->current != 0) ++(*this); + else + while (num++ && this->current != 0) --(*this); + + return *this; + } + + Iterator operator-(s32 num) const { return (*this)+(-num); } + Iterator operator-=(s32 num) const { (*this)+=(-num); return *this; } + + bool operator ==(const Iterator& other) const { return current == other.current; }; + bool operator !=(const Iterator& other) const { return current != other.current; }; + + T& operator *() { return current->element; }; + + private: + + Iterator(SKListNode* begin) : current(begin) {}; + + friend class list; + + SKListNode* current; + }; + + + //! constructor + list() + : root(0), last(0), size(0) {} + + + //! copy constructor + list(const list& other) : root(0), last(0), size(0) + { + *this = other; + } + + + //! destructor + ~list() + { + clear(); + } + + + + //! Assignment operator + void operator=(const list& other) + { + clear(); + + SKListNode* node = other.root; + while(node) + { + push_back(node->element); + node = node->next; + } + } + + + + //! Returns amount of elements in list. + //! \return Returns amount of elements in the list. + u32 getSize() const + { + return size; + } + + + + //! Clears the list, deletes all elements in the list. All existing + //! iterators of this list will be invalid. + void clear() + { + SKListNode* node = root; + while(node) + { + SKListNode* next = node->next; + delete node; + node = next; + } + + root = 0; + last = 0; + size = 0; + } + + + + //! Returns ture if the list is empty. + //! \return Returns true if the list is empty and false if not. + bool empty() const + { + return root == 0; + } + + + + //! Adds an element at the end of the list. + //! \param element: Element to add to the list. + void push_back(const T& element) + { + SKListNode* node = new SKListNode; + node->element = element; + + ++size; + + if (root == 0) + root = node; + + node->prev = last; + + if (last != 0) + last->next = node; + + last = node; + } + + + //! Adds an element at the begin of the list. + //! \param element: Element to add to the list. + void push_front(const T& element) + { + SKListNode* node = new SKListNode; + node->element = element; + + ++size; + + if (root == 0) + { + last = node; + root = node; + } + else + { + node->next = root; + root->prev = node; + root = node; + } + } + + + //! Gets begin node. + //! \return Returns a list iterator pointing to the begin of the list. + Iterator begin() const + { + return Iterator(root); + } + + + //! Gets end node. + //! \return Returns a list iterator pointing to null. + Iterator end() const + { + return Iterator(0); + } + + + //! Gets last element. + //! \return Returns a list iterator pointing to the end of the list. + Iterator getLast() const + { + return Iterator(last); + } + + + //! Inserts an element after an element. + //! \param it: Iterator pointing to element after which the new element + //! should be inserted. + //! \param element: The new element to be insterted into the list. + void insert_after(Iterator& it, const T& element) + { + SKListNode* node = new SKListNode; + node->element = element; + + node->next = it.current->next; + + if (it.current->next) + it.current->next->prev = node; + + node->prev = it.current; + it.current->next = node; + ++size; + + if (it.current == last) + last = node; + } + + + //! Inserts an element before an element. + //! \param it: Iterator pointing to element before which the new element + //! should be inserted. + //! \param element: The new element to be insterted into the list. + void insert_before(Iterator& it, const T& element) + { + SKListNode* node = new SKListNode; + node->element = element; + + node->prev = it.current->prev; + + if (it.current->prev) + it.current->prev->next = node; + + node->next = it.current; + it.current->prev = node; + ++size; + + if (it.current == root) + root = node; + } + + + //! Erases an element + //! \param it: Iterator pointing to the element which should be erased. + //! \return Returns iterator pointing to next element. + Iterator erase(Iterator& it) + { + Iterator returnIterator(it); + ++returnIterator; + + if (it.current == root) + root = it.current->next; + + if (it.current == last) + last = it.current->prev; + + if (it.current->next) + it.current->next->prev = it.current->prev; + + if (it.current->prev) + it.current->prev->next = it.current->next; + + delete it.current; + it.current = 0; + --size; + + return returnIterator; + } + +private: + + SKListNode* root; + SKListNode* last; + u32 size; + +}; + + +} // end namespace core +}// end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/irrMap.h b/src/dep/include/irrlicht/irrMap.h index 43c942a..efe0d9f 100644 --- a/src/dep/include/irrlicht/irrMap.h +++ b/src/dep/include/irrlicht/irrMap.h @@ -1,936 +1,936 @@ -// Copyright 2006-2007 by Kat'Oun -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_MAP_H_INCLUDED__ -#define __IRR_MAP_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr -{ -namespace core -{ - -//! map template for associative arrays using a red-black tree -template -class map -{ - //! red/black tree for map - template - class RBTree - { - public: - - RBTree(const KeyTypeRB& k, const ValueTypeRB& v) - : mLeftChild(0), mRightChild(0), mParent(0), mKey(k), - mValue(v), mIsRed(true) {} - - virtual ~RBTree(){} - - void setLeftChild(RBTree* p) { mLeftChild=p; if (p) p->setParent(this); } - void setRightChild(RBTree* p) { mRightChild=p;if (p) p->setParent(this); } - void setParent(RBTree* p) { mParent=p; } - - void setValue(const ValueTypeRB& v) { mValue = v; } - - void setRed() { mIsRed = true; } - void setBlack() { mIsRed = false; } - - RBTree* getLeftChild() const { return mLeftChild; } - RBTree* getRightChild() const { return mRightChild; } - RBTree* getParent() const { return mParent; } - - ValueTypeRB getValue() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return mValue; - } - - KeyTypeRB getKey() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return mKey; - } - - - bool isRoot() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return mParent==0; - } - - bool isLeftChild() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return mParent!=0 && mParent->getLeftChild()==this; - } - - bool isRightChild() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return mParent!=0 && mParent->getRightChild()==this; - } - - bool isLeaf() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return mLeftChild==0 && mRightChild==0; - } - - unsigned int getLevel() const - { - if (isRoot()) - return 1; - else - return getParent()->getLevel() + 1; - } - - - bool isRed() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return mIsRed; - } - - bool isBlack() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return !mIsRed; - } - - private: - RBTree(); - - RBTree* mLeftChild; - RBTree* mRightChild; - - RBTree* mParent; - - KeyTypeRB mKey; - ValueTypeRB mValue; - - bool mIsRed; - }; - - public: - - typedef RBTree Node; - - //! Normal Iterator - class Iterator - { - public: - - Iterator() : mRoot(0), mCur(0) {} - - // Constructor(Node*) - Iterator(Node* root):mRoot(root) - { - reset(); - } - - // Copy constructor - Iterator(const Iterator& src) : mRoot(src.mRoot), mCur(src.mCur){} - - void reset(bool atLowest=true) - { - if (atLowest) - mCur = getMin(mRoot); - else - mCur = getMax(mRoot); - } - - bool atEnd() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return mCur==0; - } - - Node* getNode() - { - return mCur; - } - - Iterator& operator=(const Iterator& src) - { - mRoot = src.mRoot; - mCur = src.mCur; - return (*this); - } - - void operator++(int) - { - inc(); - } - - void operator--(int) - { - dec(); - } - - - Node* operator -> () - { - return getNode(); - } - - Node& operator* () - { - if (atEnd()) - throw "Iterator at end"; - - return *mCur; - } - - private: - - Node* getMin(Node* n) - { - while(n && n->getLeftChild()) - n = n->getLeftChild(); - return n; - } - - Node* getMax(Node* n) - { - while(n && n->getRightChild()) - n = n->getRightChild(); - return n; - } - - void inc() - { - // Already at end? - if (mCur==0) - return; - - if (mCur->getRightChild()) - { - // If current node has a right child, the next higher node is the - // node with lowest key beneath the right child. - mCur = getMin(mCur->getRightChild()); - } - else if (mCur->isLeftChild()) - { - // No right child? Well if current node is a left child then - // the next higher node is the parent - mCur = mCur->getParent(); - } - else - { - // Current node neither is left child nor has a right child. - // Ie it is either right child or root - // The next higher node is the parent of the first non-right - // child (ie either a left child or the root) up in the - // hierarchy. Root's parent is 0. - while(mCur->isRightChild()) - mCur = mCur->getParent(); - mCur = mCur->getParent(); - } - } - - void dec() - { - // Already at end? - if (mCur==0) - return; - - if (mCur->getLeftChild()) - { - // If current node has a left child, the next lower node is the - // node with highest key beneath the left child. - mCur = getMax(mCur->getLeftChild()); - } - else if (mCur->isRightChild()) - { - // No left child? Well if current node is a right child then - // the next lower node is the parent - mCur = mCur->getParent(); - } - else - { - // Current node neither is right child nor has a left child. - // Ie it is either left child or root - // The next higher node is the parent of the first non-left - // child (ie either a right child or the root) up in the - // hierarchy. Root's parent is 0. - - while(mCur->isLeftChild()) - mCur = mCur->getParent(); - mCur = mCur->getParent(); - } - } - - Node* mRoot; - Node* mCur; - }; // Iterator - - - - //! Parent First Iterator. - //! Traverses the tree from top to bottom. Typical usage is - //! when storing the tree structure, because when reading it - //! later (and inserting elements) the tree structure will - //! be the same. - class ParentFirstIterator - { - public: - - - ParentFirstIterator():mRoot(0),mCur(0) - { - } - - - explicit ParentFirstIterator(Node* root):mRoot(root),mCur(0) - { - reset(); - } - - void reset() - { - mCur = mRoot; - } - - - bool atEnd() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return mCur==0; - } - - Node* getNode() - { - return mCur; - } - - - ParentFirstIterator& operator=(const ParentFirstIterator& src) - { - mRoot = src.mRoot; - mCur = src.mCur; - return (*this); - } - - - void operator++(int) - { - inc(); - } - - - Node* operator -> () - { - return getNode(); - } - - Node& operator* () - { - if (atEnd()) - throw "ParentFirstIterator at end"; - return *getNode(); - } - - private: - - void inc() - { - // Already at end? - if (mCur==0) - return; - - // First we try down to the left - if (mCur->getLeftChild()) - { - mCur = mCur->getLeftChild(); - } - else if (mCur->getRightChild()) - { - // No left child? The we go down to the right. - mCur = mCur->getRightChild(); - } - else - { - // No children? Move up in the hierarcy until - // we either reach 0 (and are finished) or - // find a right uncle. - while (mCur!=0) - { - // But if parent is left child and has a right "uncle" the parent - // has already been processed but the uncle hasn't. Move to - // the uncle. - if (mCur->isLeftChild() && mCur->getParent()->getRightChild()) - { - mCur = mCur->getParent()->getRightChild(); - return; - } - mCur = mCur->getParent(); - } - } - } - - Node* mRoot; - Node* mCur; - - }; // ParentFirstIterator - - - //! Parent Last Iterator - //! Traverse the tree from bottom to top. - //! Typical usage is when deleting all elements in the tree - //! because you must delete the children before you delete - //! their parent. - class ParentLastIterator - { - public: - - ParentLastIterator():mRoot(0),mCur(0){} - - explicit ParentLastIterator(Node* root) : mRoot(root), mCur(0) - { - reset(); - } - - void reset() - { - mCur = getMin(mRoot); - } - - bool atEnd() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return mCur==0; - } - - Node* getNode() - { - return mCur; - } - - ParentLastIterator& operator=(const ParentLastIterator& src) - { - mRoot = src.mRoot; - mCur = src.mCur; - return (*this); - } - - void operator++(int) - { - inc(); - } - - Node* operator -> () - { - return getNode(); - } - - Node& operator* () - { - if (atEnd()) - throw "ParentLastIterator at end"; - return *getNode(); - } - private: - - Node* getMin(Node* n) - { - while(n!=0 && (n->getLeftChild()!=0 || n->getRightChild()!=0)) - { - if (n->getLeftChild()) - n = n->getLeftChild(); - else - n = n->getRightChild(); - } - return n; - } - - void inc() - { - // Already at end? - if (mCur==0) - return; - - // Note: Starting point is the node as far down to the left as possible. - - // If current node has an uncle to the right, go to the - // node as far down to the left from the uncle as possible - // else just go up a level to the parent. - if (mCur->isLeftChild() && mCur->getParent()->getRightChild()) - { - mCur = getMin(mCur->getParent()->getRightChild()); - } - else - mCur = mCur->getParent(); - } - - - Node* mRoot; - Node* mCur; - }; // ParentLastIterator - - - // AccessClass is a temporary class used with the [] operator. - // It makes it possible to have different behavior in situations like: - // myTree["Foo"] = 32; - // If "Foo" already exists, just update its value else insert a new - // element. - // int i = myTree["Foo"] - // If "Foo" exists return its value, else throw an exception. - class AccessClass - { - // Let map be the only one who can instantiate this class. - friend class map; - - public: - - // Assignment operator. Handles the myTree["Foo"] = 32; situation - void operator=(const ValueType& value) - { - // Just use the Set method, it handles already exist/not exist situation - mTree.set(mKey,value); - } - - // ValueType operator - operator ValueType() - { - Node* node = mTree.find(mKey); - - // Not found - if (node==0) - throw "Item not found"; - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return node->getValue(); - } - - private: - - AccessClass(map& tree, const KeyType& key):mTree(tree),mKey(key){} - - AccessClass(); - - map& mTree; - const KeyType& mKey; - }; // AccessClass - - - // Constructor. - map() : mRoot(0),mSize(0) {} - - // Destructor - ~map() - { - clear(); - } - - //------------------------------ - // Public Commands - //------------------------------ - - //! Inserts a new node into the tree - //! \param keyNew: the index for this value - //! \param v: the value to insert - //! \return Returns true if successful, - //! false if it fails (already exists) - bool insert(const KeyType& keyNew, const ValueType& v) - { - // First insert node the "usual" way (no fancy balance logic yet) - Node* newNode = new Node(keyNew,v); - if (!insert(newNode)) - { - delete newNode; - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - // Then attend a balancing party - while (!newNode->isRoot() && (newNode->getParent()->isRed())) - { - if (newNode->getParent()->isLeftChild()) - { - // If newNode is a left child, get its right 'uncle' - Node* newNodesUncle = newNode->getParent()->getParent()->getRightChild(); - if ( newNodesUncle!=0 && newNodesUncle->isRed()) - { - // case 1 - change the colours - newNode->getParent()->setBlack(); - newNodesUncle->setBlack(); - newNode->getParent()->getParent()->setRed(); - // Move newNode up the tree - newNode = newNode->getParent()->getParent(); - } - else - { - // newNodesUncle is a black node - if ( newNode->isRightChild()) - { - // and newNode is to the right - // case 2 - move newNode up and rotate - newNode = newNode->getParent(); - rotateLeft(newNode); - } - // case 3 - newNode->getParent()->setBlack(); - newNode->getParent()->getParent()->setRed(); - rotateRight(newNode->getParent()->getParent()); - } - } - else - { - // If newNode is a right child, get its left 'uncle' - Node* newNodesUncle = newNode->getParent()->getParent()->getLeftChild(); - if ( newNodesUncle!=0 && newNodesUncle->isRed()) - { - // case 1 - change the colours - newNode->getParent()->setBlack(); - newNodesUncle->setBlack(); - newNode->getParent()->getParent()->setRed(); - // Move newNode up the tree - newNode = newNode->getParent()->getParent(); - } - else - { - // newNodesUncle is a black node - if (newNode->isLeftChild()) - { - // and newNode is to the left - // case 2 - move newNode up and rotate - newNode = newNode->getParent(); - rotateRight(newNode); - } - // case 3 - newNode->getParent()->setBlack(); - newNode->getParent()->getParent()->setRed(); - rotateLeft(newNode->getParent()->getParent()); - } - - } - } - // Color the root black - mRoot->setBlack(); - return true; - } - - //! Replaces the value if the key already exists, - //! otherwise inserts a new element. - //! \param key: the index for this value - //! \param v: the new value of - void set(const KeyType& k, const ValueType& v) - { - Node* p = find(k); - if (p) - p->setValue(v); - else - insert(k,v); - } - - //! Removes a node from the tree and returns it. - //! The returned node must be deleted by the user - //! \param k: the key to remove - //! \return: A pointer to the node, or 0 if not found - Node* delink(const KeyType& k) - { - Node* p = Find(k); - if (p == 0) - return 0; - - // Rotate p down to the left until it has no right child, will get there - // sooner or later. - while(p->getRightChild()) - { - // "Pull up my right child and let it knock me down to the left" - rotateLeft(p); - } - // p now has no right child but might have a left child - Node* left = p->getLeftChild(); - - // Let p's parent point to p's child instead of point to p - if (p->isLeftChild()) - p->getParent()->setLeftChild(left); - - else if (p->isRightChild()) - p->getParent()->setRightChild(left); - - else - { - // p has no parent => p is the root. - // Let the left child be the new root. - setRoot(left); - } - - // p is now gone from the tree in the sense that - // no one is pointing at it, so return it. - - mSize--; - return p; - } - - //! Removes a node from the tree and deletes it. - //! \return True if the node was found and deleted - bool remove(const KeyType& k) - { - Node* p = find(k); - if (p == 0) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - // Rotate p down to the left until it has no right child, will get there - // sooner or later. - while(p->getRightChild()) - { - // "Pull up my right child and let it knock me down to the left" - rotateLeft(p); - } - // p now has no right child but might have a left child - Node* left = p->getLeftChild(); - - // Let p's parent point to p's child instead of point to p - if (p->isLeftChild()) - p->getParent()->setLeftChild(left); - - else if (p->isRightChild()) - p->getParent()->setRightChild(left); - - else - { - // p has no parent => p is the root. - // Let the left child be the new root. - setRoot(left); - } - - // p is now gone from the tree in the sense that - // no one is pointing at it. Let's get rid of it. - delete p; - - mSize--; - return true; - } - - //! Clear the entire tree - void clear() - { - ParentLastIterator i(getParentLastIterator()); - - while(!i.atEnd()) - { - Node* p = i.getNode(); - i++; // Increment it before it is deleted - // else iterator will get quite confused. - delete p; - } - mRoot = 0; - mSize= 0; - } - - //! Is the tree empty? - //! \return Returns true if empty, false if not - bool isEmpty() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return mRoot == 0; - } - - //! Search for a node with the specified key. - //! \param keyToFind: The key to find - //! \return Returns 0 if node couldn't be found. - Node* find(const KeyType& keyToFind) const - { - Node* pNode = mRoot; - - while(pNode!=0) - { - KeyType key(pNode->getKey()); - - if (keyToFind == key) - return pNode; - else if (keyToFind < key) - pNode = pNode->getLeftChild(); - else //keyToFind > key - pNode = pNode->getRightChild(); - } - - return 0; - } - - //! Gets the root element. - //! \return Returns a pointer to the root node, or - //! 0 if the tree is empty. - Node* getRoot() const - { - return mRoot; - } - - //! Returns the number of nodes in the tree. - u32 size() const - { - return mSize; - } - - //------------------------------ - // Public Iterators - //------------------------------ - - //! Returns an iterator - Iterator getIterator() - { - Iterator it(getRoot()); - return it; - } - //! Returns a ParentFirstIterator. - //! Traverses the tree from top to bottom. Typical usage is - //! when storing the tree structure, because when reading it - //! later (and inserting elements) the tree structure will - //! be the same. - ParentFirstIterator getParentFirstIterator() - { - ParentFirstIterator it(getRoot()); - return it; - } - //! Returns a ParentLastIterator to traverse the tree from - //! bottom to top. - //! Typical usage is when deleting all elements in the tree - //! because you must delete the children before you delete - //! their parent. - ParentLastIterator getParentLastIterator() - { - ParentLastIterator it(getRoot()); - return it; - } - - //------------------------------ - // Public Operators - //------------------------------ - - //! operator [] for accesss to elements - //! for example myMap["key"] - AccessClass operator[](const KeyType& k) - { - return AccessClass(*this, k); - } - private: - - //------------------------------ - // Disabled methods - //------------------------------ - //! Copy constructor and assignment operator deliberately - //! defined but not implemented. The tree should never be - //! copied, pass along references to it instead (or use auto_ptr to it). - explicit map(const map& src); - map& operator = (const map& src); - - void setRoot(Node* newRoot) - { - mRoot = newRoot; - if (mRoot!=0) - mRoot->setParent(0); - } - - //! Insert a node into the tree without using any fancy balancing logic. - //! Returns false if that key already exist in the tree. - bool insert(Node* newNode) - { - bool result=true; // Assume success - - if (mRoot==0) - { - setRoot(newNode); - mSize = 1; - } - else - { - Node* pNode = mRoot; - KeyType keyNew = newNode->getKey(); - while (pNode) - { - KeyType key(pNode->getKey()); - - if (keyNew == key) - { - result = false; - pNode = 0; - } - else if (keyNew < key) - { - if (pNode->getLeftChild() == 0) - { - pNode->setLeftChild(newNode); - pNode = 0; - } - else - pNode = pNode->getLeftChild(); - } - else // keyNew > key - { - if (pNode->getRightChild()==0) - { - pNode->setRightChild(newNode); - pNode = 0; - } - else - { - pNode = pNode->getRightChild(); - } - } - } - - if (result) - mSize++; - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return result; - } - - //! Rotate left. - //! Pull up node's right child and let it knock node down to the left - void rotateLeft(Node* p) - { - Node* right = p->getRightChild(); - - p->setRightChild(right->getLeftChild()); - - if (p->isLeftChild()) - p->getParent()->setLeftChild(right); - else if (p->isRightChild()) - p->getParent()->setRightChild(right); - else - setRoot(right); - - right->setLeftChild(p); - } - - //! Rotate right. - //! Pull up node's left child and let it knock node down to the right - void rotateRight(Node* p) - { - - Node* left = p->getLeftChild(); - - p->setLeftChild(left->getRightChild()); - - if (p->isLeftChild()) - p->getParent()->setLeftChild(left); - else if (p->isRightChild()) - p->getParent()->setRightChild(left); - else - setRoot(left); - - left->setRightChild(p); - } - - //------------------------------ - // Private Members - //------------------------------ - Node* mRoot; // The top node. 0 if empty. - u32 mSize; // Number of nodes in the tree - -}; - -} // end namespace core -} // end namespace irr - -#endif // __IRR_MAP_H_INCLUDED__ - +// Copyright 2006-2007 by Kat'Oun +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_MAP_H_INCLUDED__ +#define __IRR_MAP_H_INCLUDED__ + +#include "irrTypes.h" + +namespace irr +{ +namespace core +{ + +//! map template for associative arrays using a red-black tree +template +class map +{ + //! red/black tree for map + template + class RBTree + { + public: + + RBTree(const KeyTypeRB& k, const ValueTypeRB& v) + : mLeftChild(0), mRightChild(0), mParent(0), mKey(k), + mValue(v), mIsRed(true) {} + + virtual ~RBTree(){} + + void setLeftChild(RBTree* p) { mLeftChild=p; if (p) p->setParent(this); } + void setRightChild(RBTree* p) { mRightChild=p;if (p) p->setParent(this); } + void setParent(RBTree* p) { mParent=p; } + + void setValue(const ValueTypeRB& v) { mValue = v; } + + void setRed() { mIsRed = true; } + void setBlack() { mIsRed = false; } + + RBTree* getLeftChild() const { return mLeftChild; } + RBTree* getRightChild() const { return mRightChild; } + RBTree* getParent() const { return mParent; } + + ValueTypeRB getValue() const + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return mValue; + } + + KeyTypeRB getKey() const + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return mKey; + } + + + bool isRoot() const + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return mParent==0; + } + + bool isLeftChild() const + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return mParent!=0 && mParent->getLeftChild()==this; + } + + bool isRightChild() const + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return mParent!=0 && mParent->getRightChild()==this; + } + + bool isLeaf() const + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return mLeftChild==0 && mRightChild==0; + } + + unsigned int getLevel() const + { + if (isRoot()) + return 1; + else + return getParent()->getLevel() + 1; + } + + + bool isRed() const + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return mIsRed; + } + + bool isBlack() const + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return !mIsRed; + } + + private: + RBTree(); + + RBTree* mLeftChild; + RBTree* mRightChild; + + RBTree* mParent; + + KeyTypeRB mKey; + ValueTypeRB mValue; + + bool mIsRed; + }; + + public: + + typedef RBTree Node; + + //! Normal Iterator + class Iterator + { + public: + + Iterator() : mRoot(0), mCur(0) {} + + // Constructor(Node*) + Iterator(Node* root):mRoot(root) + { + reset(); + } + + // Copy constructor + Iterator(const Iterator& src) : mRoot(src.mRoot), mCur(src.mCur){} + + void reset(bool atLowest=true) + { + if (atLowest) + mCur = getMin(mRoot); + else + mCur = getMax(mRoot); + } + + bool atEnd() const + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return mCur==0; + } + + Node* getNode() + { + return mCur; + } + + Iterator& operator=(const Iterator& src) + { + mRoot = src.mRoot; + mCur = src.mCur; + return (*this); + } + + void operator++(int) + { + inc(); + } + + void operator--(int) + { + dec(); + } + + + Node* operator -> () + { + return getNode(); + } + + Node& operator* () + { + if (atEnd()) + throw "Iterator at end"; + + return *mCur; + } + + private: + + Node* getMin(Node* n) + { + while(n && n->getLeftChild()) + n = n->getLeftChild(); + return n; + } + + Node* getMax(Node* n) + { + while(n && n->getRightChild()) + n = n->getRightChild(); + return n; + } + + void inc() + { + // Already at end? + if (mCur==0) + return; + + if (mCur->getRightChild()) + { + // If current node has a right child, the next higher node is the + // node with lowest key beneath the right child. + mCur = getMin(mCur->getRightChild()); + } + else if (mCur->isLeftChild()) + { + // No right child? Well if current node is a left child then + // the next higher node is the parent + mCur = mCur->getParent(); + } + else + { + // Current node neither is left child nor has a right child. + // Ie it is either right child or root + // The next higher node is the parent of the first non-right + // child (ie either a left child or the root) up in the + // hierarchy. Root's parent is 0. + while(mCur->isRightChild()) + mCur = mCur->getParent(); + mCur = mCur->getParent(); + } + } + + void dec() + { + // Already at end? + if (mCur==0) + return; + + if (mCur->getLeftChild()) + { + // If current node has a left child, the next lower node is the + // node with highest key beneath the left child. + mCur = getMax(mCur->getLeftChild()); + } + else if (mCur->isRightChild()) + { + // No left child? Well if current node is a right child then + // the next lower node is the parent + mCur = mCur->getParent(); + } + else + { + // Current node neither is right child nor has a left child. + // Ie it is either left child or root + // The next higher node is the parent of the first non-left + // child (ie either a right child or the root) up in the + // hierarchy. Root's parent is 0. + + while(mCur->isLeftChild()) + mCur = mCur->getParent(); + mCur = mCur->getParent(); + } + } + + Node* mRoot; + Node* mCur; + }; // Iterator + + + + //! Parent First Iterator. + //! Traverses the tree from top to bottom. Typical usage is + //! when storing the tree structure, because when reading it + //! later (and inserting elements) the tree structure will + //! be the same. + class ParentFirstIterator + { + public: + + + ParentFirstIterator():mRoot(0),mCur(0) + { + } + + + explicit ParentFirstIterator(Node* root):mRoot(root),mCur(0) + { + reset(); + } + + void reset() + { + mCur = mRoot; + } + + + bool atEnd() const + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return mCur==0; + } + + Node* getNode() + { + return mCur; + } + + + ParentFirstIterator& operator=(const ParentFirstIterator& src) + { + mRoot = src.mRoot; + mCur = src.mCur; + return (*this); + } + + + void operator++(int) + { + inc(); + } + + + Node* operator -> () + { + return getNode(); + } + + Node& operator* () + { + if (atEnd()) + throw "ParentFirstIterator at end"; + return *getNode(); + } + + private: + + void inc() + { + // Already at end? + if (mCur==0) + return; + + // First we try down to the left + if (mCur->getLeftChild()) + { + mCur = mCur->getLeftChild(); + } + else if (mCur->getRightChild()) + { + // No left child? The we go down to the right. + mCur = mCur->getRightChild(); + } + else + { + // No children? Move up in the hierarcy until + // we either reach 0 (and are finished) or + // find a right uncle. + while (mCur!=0) + { + // But if parent is left child and has a right "uncle" the parent + // has already been processed but the uncle hasn't. Move to + // the uncle. + if (mCur->isLeftChild() && mCur->getParent()->getRightChild()) + { + mCur = mCur->getParent()->getRightChild(); + return; + } + mCur = mCur->getParent(); + } + } + } + + Node* mRoot; + Node* mCur; + + }; // ParentFirstIterator + + + //! Parent Last Iterator + //! Traverse the tree from bottom to top. + //! Typical usage is when deleting all elements in the tree + //! because you must delete the children before you delete + //! their parent. + class ParentLastIterator + { + public: + + ParentLastIterator():mRoot(0),mCur(0){} + + explicit ParentLastIterator(Node* root) : mRoot(root), mCur(0) + { + reset(); + } + + void reset() + { + mCur = getMin(mRoot); + } + + bool atEnd() const + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return mCur==0; + } + + Node* getNode() + { + return mCur; + } + + ParentLastIterator& operator=(const ParentLastIterator& src) + { + mRoot = src.mRoot; + mCur = src.mCur; + return (*this); + } + + void operator++(int) + { + inc(); + } + + Node* operator -> () + { + return getNode(); + } + + Node& operator* () + { + if (atEnd()) + throw "ParentLastIterator at end"; + return *getNode(); + } + private: + + Node* getMin(Node* n) + { + while(n!=0 && (n->getLeftChild()!=0 || n->getRightChild()!=0)) + { + if (n->getLeftChild()) + n = n->getLeftChild(); + else + n = n->getRightChild(); + } + return n; + } + + void inc() + { + // Already at end? + if (mCur==0) + return; + + // Note: Starting point is the node as far down to the left as possible. + + // If current node has an uncle to the right, go to the + // node as far down to the left from the uncle as possible + // else just go up a level to the parent. + if (mCur->isLeftChild() && mCur->getParent()->getRightChild()) + { + mCur = getMin(mCur->getParent()->getRightChild()); + } + else + mCur = mCur->getParent(); + } + + + Node* mRoot; + Node* mCur; + }; // ParentLastIterator + + + // AccessClass is a temporary class used with the [] operator. + // It makes it possible to have different behavior in situations like: + // myTree["Foo"] = 32; + // If "Foo" already exists, just update its value else insert a new + // element. + // int i = myTree["Foo"] + // If "Foo" exists return its value, else throw an exception. + class AccessClass + { + // Let map be the only one who can instantiate this class. + friend class map; + + public: + + // Assignment operator. Handles the myTree["Foo"] = 32; situation + void operator=(const ValueType& value) + { + // Just use the Set method, it handles already exist/not exist situation + mTree.set(mKey,value); + } + + // ValueType operator + operator ValueType() + { + Node* node = mTree.find(mKey); + + // Not found + if (node==0) + throw "Item not found"; + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return node->getValue(); + } + + private: + + AccessClass(map& tree, const KeyType& key):mTree(tree),mKey(key){} + + AccessClass(); + + map& mTree; + const KeyType& mKey; + }; // AccessClass + + + // Constructor. + map() : mRoot(0),mSize(0) {} + + // Destructor + ~map() + { + clear(); + } + + //------------------------------ + // Public Commands + //------------------------------ + + //! Inserts a new node into the tree + //! \param keyNew: the index for this value + //! \param v: the value to insert + //! \return Returns true if successful, + //! false if it fails (already exists) + bool insert(const KeyType& keyNew, const ValueType& v) + { + // First insert node the "usual" way (no fancy balance logic yet) + Node* newNode = new Node(keyNew,v); + if (!insert(newNode)) + { + delete newNode; + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return false; + } + + // Then attend a balancing party + while (!newNode->isRoot() && (newNode->getParent()->isRed())) + { + if (newNode->getParent()->isLeftChild()) + { + // If newNode is a left child, get its right 'uncle' + Node* newNodesUncle = newNode->getParent()->getParent()->getRightChild(); + if ( newNodesUncle!=0 && newNodesUncle->isRed()) + { + // case 1 - change the colours + newNode->getParent()->setBlack(); + newNodesUncle->setBlack(); + newNode->getParent()->getParent()->setRed(); + // Move newNode up the tree + newNode = newNode->getParent()->getParent(); + } + else + { + // newNodesUncle is a black node + if ( newNode->isRightChild()) + { + // and newNode is to the right + // case 2 - move newNode up and rotate + newNode = newNode->getParent(); + rotateLeft(newNode); + } + // case 3 + newNode->getParent()->setBlack(); + newNode->getParent()->getParent()->setRed(); + rotateRight(newNode->getParent()->getParent()); + } + } + else + { + // If newNode is a right child, get its left 'uncle' + Node* newNodesUncle = newNode->getParent()->getParent()->getLeftChild(); + if ( newNodesUncle!=0 && newNodesUncle->isRed()) + { + // case 1 - change the colours + newNode->getParent()->setBlack(); + newNodesUncle->setBlack(); + newNode->getParent()->getParent()->setRed(); + // Move newNode up the tree + newNode = newNode->getParent()->getParent(); + } + else + { + // newNodesUncle is a black node + if (newNode->isLeftChild()) + { + // and newNode is to the left + // case 2 - move newNode up and rotate + newNode = newNode->getParent(); + rotateRight(newNode); + } + // case 3 + newNode->getParent()->setBlack(); + newNode->getParent()->getParent()->setRed(); + rotateLeft(newNode->getParent()->getParent()); + } + + } + } + // Color the root black + mRoot->setBlack(); + return true; + } + + //! Replaces the value if the key already exists, + //! otherwise inserts a new element. + //! \param key: the index for this value + //! \param v: the new value of + void set(const KeyType& k, const ValueType& v) + { + Node* p = find(k); + if (p) + p->setValue(v); + else + insert(k,v); + } + + //! Removes a node from the tree and returns it. + //! The returned node must be deleted by the user + //! \param k: the key to remove + //! \return: A pointer to the node, or 0 if not found + Node* delink(const KeyType& k) + { + Node* p = Find(k); + if (p == 0) + return 0; + + // Rotate p down to the left until it has no right child, will get there + // sooner or later. + while(p->getRightChild()) + { + // "Pull up my right child and let it knock me down to the left" + rotateLeft(p); + } + // p now has no right child but might have a left child + Node* left = p->getLeftChild(); + + // Let p's parent point to p's child instead of point to p + if (p->isLeftChild()) + p->getParent()->setLeftChild(left); + + else if (p->isRightChild()) + p->getParent()->setRightChild(left); + + else + { + // p has no parent => p is the root. + // Let the left child be the new root. + setRoot(left); + } + + // p is now gone from the tree in the sense that + // no one is pointing at it, so return it. + + mSize--; + return p; + } + + //! Removes a node from the tree and deletes it. + //! \return True if the node was found and deleted + bool remove(const KeyType& k) + { + Node* p = find(k); + if (p == 0) + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return false; + } + + // Rotate p down to the left until it has no right child, will get there + // sooner or later. + while(p->getRightChild()) + { + // "Pull up my right child and let it knock me down to the left" + rotateLeft(p); + } + // p now has no right child but might have a left child + Node* left = p->getLeftChild(); + + // Let p's parent point to p's child instead of point to p + if (p->isLeftChild()) + p->getParent()->setLeftChild(left); + + else if (p->isRightChild()) + p->getParent()->setRightChild(left); + + else + { + // p has no parent => p is the root. + // Let the left child be the new root. + setRoot(left); + } + + // p is now gone from the tree in the sense that + // no one is pointing at it. Let's get rid of it. + delete p; + + mSize--; + return true; + } + + //! Clear the entire tree + void clear() + { + ParentLastIterator i(getParentLastIterator()); + + while(!i.atEnd()) + { + Node* p = i.getNode(); + i++; // Increment it before it is deleted + // else iterator will get quite confused. + delete p; + } + mRoot = 0; + mSize= 0; + } + + //! Is the tree empty? + //! \return Returns true if empty, false if not + bool isEmpty() const + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return mRoot == 0; + } + + //! Search for a node with the specified key. + //! \param keyToFind: The key to find + //! \return Returns 0 if node couldn't be found. + Node* find(const KeyType& keyToFind) const + { + Node* pNode = mRoot; + + while(pNode!=0) + { + KeyType key(pNode->getKey()); + + if (keyToFind == key) + return pNode; + else if (keyToFind < key) + pNode = pNode->getLeftChild(); + else //keyToFind > key + pNode = pNode->getRightChild(); + } + + return 0; + } + + //! Gets the root element. + //! \return Returns a pointer to the root node, or + //! 0 if the tree is empty. + Node* getRoot() const + { + return mRoot; + } + + //! Returns the number of nodes in the tree. + u32 size() const + { + return mSize; + } + + //------------------------------ + // Public Iterators + //------------------------------ + + //! Returns an iterator + Iterator getIterator() + { + Iterator it(getRoot()); + return it; + } + //! Returns a ParentFirstIterator. + //! Traverses the tree from top to bottom. Typical usage is + //! when storing the tree structure, because when reading it + //! later (and inserting elements) the tree structure will + //! be the same. + ParentFirstIterator getParentFirstIterator() + { + ParentFirstIterator it(getRoot()); + return it; + } + //! Returns a ParentLastIterator to traverse the tree from + //! bottom to top. + //! Typical usage is when deleting all elements in the tree + //! because you must delete the children before you delete + //! their parent. + ParentLastIterator getParentLastIterator() + { + ParentLastIterator it(getRoot()); + return it; + } + + //------------------------------ + // Public Operators + //------------------------------ + + //! operator [] for accesss to elements + //! for example myMap["key"] + AccessClass operator[](const KeyType& k) + { + return AccessClass(*this, k); + } + private: + + //------------------------------ + // Disabled methods + //------------------------------ + //! Copy constructor and assignment operator deliberately + //! defined but not implemented. The tree should never be + //! copied, pass along references to it instead (or use auto_ptr to it). + explicit map(const map& src); + map& operator = (const map& src); + + void setRoot(Node* newRoot) + { + mRoot = newRoot; + if (mRoot!=0) + mRoot->setParent(0); + } + + //! Insert a node into the tree without using any fancy balancing logic. + //! Returns false if that key already exist in the tree. + bool insert(Node* newNode) + { + bool result=true; // Assume success + + if (mRoot==0) + { + setRoot(newNode); + mSize = 1; + } + else + { + Node* pNode = mRoot; + KeyType keyNew = newNode->getKey(); + while (pNode) + { + KeyType key(pNode->getKey()); + + if (keyNew == key) + { + result = false; + pNode = 0; + } + else if (keyNew < key) + { + if (pNode->getLeftChild() == 0) + { + pNode->setLeftChild(newNode); + pNode = 0; + } + else + pNode = pNode->getLeftChild(); + } + else // keyNew > key + { + if (pNode->getRightChild()==0) + { + pNode->setRightChild(newNode); + pNode = 0; + } + else + { + pNode = pNode->getRightChild(); + } + } + } + + if (result) + mSize++; + } + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return result; + } + + //! Rotate left. + //! Pull up node's right child and let it knock node down to the left + void rotateLeft(Node* p) + { + Node* right = p->getRightChild(); + + p->setRightChild(right->getLeftChild()); + + if (p->isLeftChild()) + p->getParent()->setLeftChild(right); + else if (p->isRightChild()) + p->getParent()->setRightChild(right); + else + setRoot(right); + + right->setLeftChild(p); + } + + //! Rotate right. + //! Pull up node's left child and let it knock node down to the right + void rotateRight(Node* p) + { + + Node* left = p->getLeftChild(); + + p->setLeftChild(left->getRightChild()); + + if (p->isLeftChild()) + p->getParent()->setLeftChild(left); + else if (p->isRightChild()) + p->getParent()->setRightChild(left); + else + setRoot(left); + + left->setRightChild(p); + } + + //------------------------------ + // Private Members + //------------------------------ + Node* mRoot; // The top node. 0 if empty. + u32 mSize; // Number of nodes in the tree + +}; + +} // end namespace core +} // end namespace irr + +#endif // __IRR_MAP_H_INCLUDED__ + diff --git a/src/dep/include/irrlicht/irrMath.h b/src/dep/include/irrlicht/irrMath.h index 68e74ad..c52ed19 100644 --- a/src/dep/include/irrlicht/irrMath.h +++ b/src/dep/include/irrlicht/irrMath.h @@ -1,369 +1,369 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_MATH_H_INCLUDED__ -#define __IRR_MATH_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#include "irrTypes.h" -#include - -#ifdef __sun__ - #define sqrtf(X) sqrt(X) - #define sinf(X) sin(X) - #define cosf(X) cos(X) - #define ceilf(X) ceil(X) - #define floorf(X) floor(X) - #define powf(X,Y) pow(X,Y) - #define fmodf(X,Y) fmod(X,Y) -#endif - -namespace irr -{ -namespace core -{ - - - //! Rounding error constant often used when comparing f32 values. - -#ifdef IRRLICHT_FAST_MATH - const f32 ROUNDING_ERROR_32 = 0.00005f; - const f64 ROUNDING_ERROR_64 = 0.000005f; -#else - const f32 ROUNDING_ERROR_32 = 0.000001f; - const f64 ROUNDING_ERROR_64 = 0.00000001f; -#endif - - //! Constant for PI. - const f32 PI = 3.14159265359f; - - //! Constant for 64bit PI. - const f64 PI64 = 3.1415926535897932384626433832795028841971693993751; - - //! 32bit Constant for converting from degrees to radians - const f32 DEGTORAD = PI / 180.0f; - - //! 32bit constant for converting from radians to degrees - const f32 RADTODEG = 180.0f / PI; - - //! 64bit constant for converting from degrees to radians - const f64 DEGTORAD64 = PI64 / 180.0; - - //! 64bit constant for converting from radians to degrees - const f64 RADTODEG64 = 180.0 / PI64; - - //! returns minimum of two values. Own implementation to get rid of the STL (VS6 problems) - template - inline const T min_(const T a, const T b) - { - return a < b ? a : b; - } - - //! returns maximum of two values. Own implementation to get rid of the STL (VS6 problems) - template - inline T max_(const T a, const T b) - { - return a < b ? b : a; - } - - //! returns abs of two values. Own implementation to get rid of STL (VS6 problems) - template - inline T abs_(const T a) - { - return a < 0 ? -a : a; - } - - //! returns linear interpolation of a and b with ratio t - //! \return: a if t==0, b if t==1, and the linear interpolation else - template - inline T lerp(const T a, const T b, const T t) - { - return (a*(1-t)) + (b*t); - } - - //! clamps a value between low and high - template - inline const T clamp (const T value, const T low, const T high) - { - return min_ (max_(value,low), high); - } - - //! returns if a float equals the other one, taking floating - //! point rounding errors into account - inline bool equals(const f32 a, const f32 b, const f32 tolerance = ROUNDING_ERROR_32) - { - return (a + tolerance > b) && (a - tolerance < b); - } - - //! returns if a float equals zero, taking floating - //! point rounding errors into account - inline bool iszero(const f32 a, const f32 tolerance = ROUNDING_ERROR_32) - { - return fabs ( a ) < tolerance; - } - - inline s32 s32_min ( s32 a, s32 b) - { - s32 mask = (a - b) >> 31; - return (a & mask) | (b & ~mask); - } - - inline s32 s32_max ( s32 a, s32 b) - { - s32 mask = (a - b) >> 31; - return (b & mask) | (a & ~mask); - } - - inline s32 s32_clamp (s32 value, s32 low, s32 high) - { - return s32_min (s32_max(value,low), high); - } - - /* - - float IEEE-754 bit represenation - - 0 0x00000000 - 1.0 0x3f800000 - 0.5 0x3f000000 - 3 0x40400000 - +inf 0x7f800000 - -inf 0xff800000 - +NaN 0x7fc00000 or 0x7ff00000 - in general: number = (sign ? -1:1) * 2^(exponent) * 1.(mantissa bits) - */ - - #define F32_AS_S32(f) (*((s32 *) &(f))) - #define F32_AS_U32(f) (*((u32 *) &(f))) - #define F32_AS_U32_POINTER(f) ( ((u32 *) &(f))) - - #define F32_VALUE_0 0x00000000 - #define F32_VALUE_1 0x3f800000 - #define F32_SIGN_BIT 0x80000000U - #define F32_EXPON_MANTISSA 0x7FFFFFFFU - - //! code is taken from IceFPU - //! Integer representation of a floating-point value. - #define IR(x) ((u32&)(x)) - - //! Absolute integer representation of a floating-point value - #define AIR(x) (IR(x)&0x7fffffff) - - //! Floating-point representation of an integer value. - #define FR(x) ((f32&)(x)) - - #define IEEE_1_0 0x3f800000 //!< integer representation of 1.0 - #define IEEE_255_0 0x437f0000 //!< integer representation of 255.0 - - - #define F32_LOWER_0(f) (F32_AS_U32(f) > F32_SIGN_BIT) - #define F32_LOWER_EQUAL_0(f) (F32_AS_S32(f) <= F32_VALUE_0) - #define F32_GREATER_0(f) (F32_AS_S32(f) > F32_VALUE_0) - #define F32_GREATER_EQUAL_0(f) (F32_AS_U32(f) <= F32_SIGN_BIT) - #define F32_EQUAL_1(f) (F32_AS_U32(f) == F32_VALUE_1) - #define F32_EQUAL_0(f) ( (F32_AS_U32(f) & F32_EXPON_MANTISSA ) == F32_VALUE_0) - - // only same sign - #define F32_A_GREATER_B(a,b) (F32_AS_S32((a)) > F32_AS_S32((b))) - - -#ifndef REALINLINE - #ifdef _MSC_VER - #define REALINLINE __forceinline - #else - #define REALINLINE inline - #endif -#endif - - - //! conditional set based on mask and arithmetic shift - REALINLINE u32 if_c_a_else_b ( const s32 condition, const u32 a, const u32 b ) - { - return ( ( -condition >> 31 ) & ( a ^ b ) ) ^ b; - } - - //! conditional set based on mask and arithmetic shift - REALINLINE u32 if_c_a_else_0 ( const s32 condition, const u32 a ) - { - return ( -condition >> 31 ) & a; - } - - /* - if (condition) state |= m; else state &= ~m; - */ - REALINLINE void setbit ( u32 &state, s32 condition, u32 mask ) - { - // 0, or any postive to mask - //s32 conmask = -condition >> 31; - state ^= ( ( -condition >> 31 ) ^ state ) & mask; - } - - -#ifdef IRRLICHT_FAST_MATH - - REALINLINE void clearFPUException () - { - __asm fnclex; - } - -// comes from Nvidia -#if 1 - REALINLINE f32 reciprocal_squareroot(const f32 x) - { - u32 tmp = (u32(IEEE_1_0 << 1) + IEEE_1_0 - *(u32*)&x) >> 1; - f32 y = *(f32*)&tmp; - return y * (1.47f - 0.47f * x * y * y); - } -#endif - -// an sse2 version -#if 0 - REALINLINE f32 reciprocal_squareroot(const f32 x) - { - __asm - { - movss xmm0, x - rsqrtss xmm0, xmm0 - movss x, xmm0 - } - return x; - } -#endif - - - //! i do not divide through 0.. (fpu expection) - // instead set f to a high value to get a return value near zero.. - // -1000000000000.f.. is use minus to stay negative.. - // must test's here (plane.normal dot anything ) checks on <= 0.f - REALINLINE f32 reciprocal ( const f32 f ) - { - return 1.f / f; - //u32 x = (-(AIR(f) != 0 ) >> 31 ) & ( IR(f) ^ 0xd368d4a5 ) ^ 0xd368d4a5; - //return 1.f / FR ( x ); - } - - REALINLINE f32 reciprocal_approxim ( const f32 p ) - { - register u32 x = 0x7F000000 - IR ( p ); - const f32 r = FR ( x ); - return r * (2.0f - p * r); - } - - - REALINLINE s32 floor32(f32 x) - { - const f32 h = 0.5f; - - s32 t; - - __asm - { - fld x - fsub h - fistp t - } - - return t; - } - - REALINLINE s32 ceil32 ( f32 x ) - { - const f32 h = 0.5f; - - s32 t; - - __asm - { - fld x - fadd h - fistp t - } - - return t; - - } - - - REALINLINE s32 round32(f32 x) - { - s32 t; - - __asm - { - fld x - fistp t - } - - return t; - } - - -#else - - REALINLINE void clearFPUException () - { - } - - - inline f32 reciprocal_squareroot(const f32 x) - { - return 1.f / sqrtf ( x ); - } - - - inline f32 reciprocal ( const f32 x ) - { - return 1.f / x; - } - - inline f32 reciprocal_approxim ( const f32 x ) - { - return 1.f / x; - } - - - inline s32 floor32 ( f32 x ) - { - return (s32) floorf ( x ); - } - - inline s32 ceil32 ( f32 x ) - { - return (s32) ceilf ( x ); - } - - inline s32 round32 ( f32 x ) - { - return (s32) ( x + 0.5f ); - } - - - inline f32 f32_max3(const f32 a, const f32 b, const f32 c) - { - return a > b ? (a > c ? a : c) : (b > c ? b : c); - } - - inline f32 f32_min3(const f32 a, const f32 b, const f32 c) - { - return a < b ? (a < c ? a : c) : (b < c ? b : c); - } - -#endif - - inline f32 fract ( f32 x ) - { - return x - floorf ( x ); - } - - inline f32 round ( f32 x ) - { - return floorf ( x + 0.5f ); - } - - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_MATH_H_INCLUDED__ +#define __IRR_MATH_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#include "irrTypes.h" +#include + +#ifdef __sun__ + #define sqrtf(X) sqrt(X) + #define sinf(X) sin(X) + #define cosf(X) cos(X) + #define ceilf(X) ceil(X) + #define floorf(X) floor(X) + #define powf(X,Y) pow(X,Y) + #define fmodf(X,Y) fmod(X,Y) +#endif + +namespace irr +{ +namespace core +{ + + + //! Rounding error constant often used when comparing f32 values. + +#ifdef IRRLICHT_FAST_MATH + const f32 ROUNDING_ERROR_32 = 0.00005f; + const f64 ROUNDING_ERROR_64 = 0.000005f; +#else + const f32 ROUNDING_ERROR_32 = 0.000001f; + const f64 ROUNDING_ERROR_64 = 0.00000001f; +#endif + + //! Constant for PI. + const f32 PI = 3.14159265359f; + + //! Constant for 64bit PI. + const f64 PI64 = 3.1415926535897932384626433832795028841971693993751; + + //! 32bit Constant for converting from degrees to radians + const f32 DEGTORAD = PI / 180.0f; + + //! 32bit constant for converting from radians to degrees + const f32 RADTODEG = 180.0f / PI; + + //! 64bit constant for converting from degrees to radians + const f64 DEGTORAD64 = PI64 / 180.0; + + //! 64bit constant for converting from radians to degrees + const f64 RADTODEG64 = 180.0 / PI64; + + //! returns minimum of two values. Own implementation to get rid of the STL (VS6 problems) + template + inline const T min_(const T a, const T b) + { + return a < b ? a : b; + } + + //! returns maximum of two values. Own implementation to get rid of the STL (VS6 problems) + template + inline T max_(const T a, const T b) + { + return a < b ? b : a; + } + + //! returns abs of two values. Own implementation to get rid of STL (VS6 problems) + template + inline T abs_(const T a) + { + return a < 0 ? -a : a; + } + + //! returns linear interpolation of a and b with ratio t + //! \return: a if t==0, b if t==1, and the linear interpolation else + template + inline T lerp(const T a, const T b, const T t) + { + return (a*(1-t)) + (b*t); + } + + //! clamps a value between low and high + template + inline const T clamp (const T value, const T low, const T high) + { + return min_ (max_(value,low), high); + } + + //! returns if a float equals the other one, taking floating + //! point rounding errors into account + inline bool equals(const f32 a, const f32 b, const f32 tolerance = ROUNDING_ERROR_32) + { + return (a + tolerance > b) && (a - tolerance < b); + } + + //! returns if a float equals zero, taking floating + //! point rounding errors into account + inline bool iszero(const f32 a, const f32 tolerance = ROUNDING_ERROR_32) + { + return fabs ( a ) < tolerance; + } + + inline s32 s32_min ( s32 a, s32 b) + { + s32 mask = (a - b) >> 31; + return (a & mask) | (b & ~mask); + } + + inline s32 s32_max ( s32 a, s32 b) + { + s32 mask = (a - b) >> 31; + return (b & mask) | (a & ~mask); + } + + inline s32 s32_clamp (s32 value, s32 low, s32 high) + { + return s32_min (s32_max(value,low), high); + } + + /* + + float IEEE-754 bit represenation + + 0 0x00000000 + 1.0 0x3f800000 + 0.5 0x3f000000 + 3 0x40400000 + +inf 0x7f800000 + -inf 0xff800000 + +NaN 0x7fc00000 or 0x7ff00000 + in general: number = (sign ? -1:1) * 2^(exponent) * 1.(mantissa bits) + */ + + #define F32_AS_S32(f) (*((s32 *) &(f))) + #define F32_AS_U32(f) (*((u32 *) &(f))) + #define F32_AS_U32_POINTER(f) ( ((u32 *) &(f))) + + #define F32_VALUE_0 0x00000000 + #define F32_VALUE_1 0x3f800000 + #define F32_SIGN_BIT 0x80000000U + #define F32_EXPON_MANTISSA 0x7FFFFFFFU + + //! code is taken from IceFPU + //! Integer representation of a floating-point value. + #define IR(x) ((u32&)(x)) + + //! Absolute integer representation of a floating-point value + #define AIR(x) (IR(x)&0x7fffffff) + + //! Floating-point representation of an integer value. + #define FR(x) ((f32&)(x)) + + #define IEEE_1_0 0x3f800000 //!< integer representation of 1.0 + #define IEEE_255_0 0x437f0000 //!< integer representation of 255.0 + + + #define F32_LOWER_0(f) (F32_AS_U32(f) > F32_SIGN_BIT) + #define F32_LOWER_EQUAL_0(f) (F32_AS_S32(f) <= F32_VALUE_0) + #define F32_GREATER_0(f) (F32_AS_S32(f) > F32_VALUE_0) + #define F32_GREATER_EQUAL_0(f) (F32_AS_U32(f) <= F32_SIGN_BIT) + #define F32_EQUAL_1(f) (F32_AS_U32(f) == F32_VALUE_1) + #define F32_EQUAL_0(f) ( (F32_AS_U32(f) & F32_EXPON_MANTISSA ) == F32_VALUE_0) + + // only same sign + #define F32_A_GREATER_B(a,b) (F32_AS_S32((a)) > F32_AS_S32((b))) + + +#ifndef REALINLINE + #ifdef _MSC_VER + #define REALINLINE __forceinline + #else + #define REALINLINE inline + #endif +#endif + + + //! conditional set based on mask and arithmetic shift + REALINLINE u32 if_c_a_else_b ( const s32 condition, const u32 a, const u32 b ) + { + return ( ( -condition >> 31 ) & ( a ^ b ) ) ^ b; + } + + //! conditional set based on mask and arithmetic shift + REALINLINE u32 if_c_a_else_0 ( const s32 condition, const u32 a ) + { + return ( -condition >> 31 ) & a; + } + + /* + if (condition) state |= m; else state &= ~m; + */ + REALINLINE void setbit ( u32 &state, s32 condition, u32 mask ) + { + // 0, or any postive to mask + //s32 conmask = -condition >> 31; + state ^= ( ( -condition >> 31 ) ^ state ) & mask; + } + + +#ifdef IRRLICHT_FAST_MATH + + REALINLINE void clearFPUException () + { + __asm fnclex; + } + +// comes from Nvidia +#if 1 + REALINLINE f32 reciprocal_squareroot(const f32 x) + { + u32 tmp = (u32(IEEE_1_0 << 1) + IEEE_1_0 - *(u32*)&x) >> 1; + f32 y = *(f32*)&tmp; + return y * (1.47f - 0.47f * x * y * y); + } +#endif + +// an sse2 version +#if 0 + REALINLINE f32 reciprocal_squareroot(const f32 x) + { + __asm + { + movss xmm0, x + rsqrtss xmm0, xmm0 + movss x, xmm0 + } + return x; + } +#endif + + + //! i do not divide through 0.. (fpu expection) + // instead set f to a high value to get a return value near zero.. + // -1000000000000.f.. is use minus to stay negative.. + // must test's here (plane.normal dot anything ) checks on <= 0.f + REALINLINE f32 reciprocal ( const f32 f ) + { + return 1.f / f; + //u32 x = (-(AIR(f) != 0 ) >> 31 ) & ( IR(f) ^ 0xd368d4a5 ) ^ 0xd368d4a5; + //return 1.f / FR ( x ); + } + + REALINLINE f32 reciprocal_approxim ( const f32 p ) + { + register u32 x = 0x7F000000 - IR ( p ); + const f32 r = FR ( x ); + return r * (2.0f - p * r); + } + + + REALINLINE s32 floor32(f32 x) + { + const f32 h = 0.5f; + + s32 t; + + __asm + { + fld x + fsub h + fistp t + } + + return t; + } + + REALINLINE s32 ceil32 ( f32 x ) + { + const f32 h = 0.5f; + + s32 t; + + __asm + { + fld x + fadd h + fistp t + } + + return t; + + } + + + REALINLINE s32 round32(f32 x) + { + s32 t; + + __asm + { + fld x + fistp t + } + + return t; + } + + +#else + + REALINLINE void clearFPUException () + { + } + + + inline f32 reciprocal_squareroot(const f32 x) + { + return 1.f / sqrtf ( x ); + } + + + inline f32 reciprocal ( const f32 x ) + { + return 1.f / x; + } + + inline f32 reciprocal_approxim ( const f32 x ) + { + return 1.f / x; + } + + + inline s32 floor32 ( f32 x ) + { + return (s32) floorf ( x ); + } + + inline s32 ceil32 ( f32 x ) + { + return (s32) ceilf ( x ); + } + + inline s32 round32 ( f32 x ) + { + return (s32) ( x + 0.5f ); + } + + + inline f32 f32_max3(const f32 a, const f32 b, const f32 c) + { + return a > b ? (a > c ? a : c) : (b > c ? b : c); + } + + inline f32 f32_min3(const f32 a, const f32 b, const f32 c) + { + return a < b ? (a < c ? a : c) : (b < c ? b : c); + } + +#endif + + inline f32 fract ( f32 x ) + { + return x - floorf ( x ); + } + + inline f32 round ( f32 x ) + { + return floorf ( x + 0.5f ); + } + + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/irrString.h b/src/dep/include/irrlicht/irrString.h index f7b4339..6ee9d81 100644 --- a/src/dep/include/irrlicht/irrString.h +++ b/src/dep/include/irrlicht/irrString.h @@ -1,830 +1,830 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h - -#ifndef __IRR_STRING_H_INCLUDED__ -#define __IRR_STRING_H_INCLUDED__ - -#include "irrTypes.h" -#include "irrAllocator.h" -#include "irrMath.h" -#include -#include -#include - -namespace irr -{ -namespace core -{ - -//! Very simple string class with some useful features. -/** string and string work both with unicode AND ascii, -so you can assign unicode to string and ascii to string -(and the other way round) if your ever would want to. -Note that the conversation between both is not done using an encoding. - -Known bugs: -Special characters like 'Ä', 'Ü' and 'Ö' are ignored in the -methods make_upper, make_lower and equals_ignore_case. -*/ -template > -class string -{ -public: - - //! Default constructor - string() - : array(0), allocated(1), used(1) - { - array = allocator.allocate(1); // new T[1]; - array[0] = 0x0; - } - - - - //! Constructor - string(const string& other) - : array(0), allocated(0), used(0) - { - *this = other; - } - - - //! Constructs a string from a float - string(double number) - : array(0), allocated(0), used(0) - { - c8 tmpbuf[255]; - sprintf(tmpbuf,"%0.6f",number); - *this = tmpbuf; - } - - - - //! Constructs a string from an int - string(int number) - : array(0), allocated(0), used(0) - { - // store if negative and make positive - - bool negative = false; - if (number < 0) - { - number *= -1; - negative = true; - } - - // temporary buffer for 16 numbers - - c8 tmpbuf[16]; - tmpbuf[15] = 0; - u32 idx = 15; - - // special case '0' - - if (!number) - { - tmpbuf[14] = '0'; - *this = &tmpbuf[14]; - return; - } - - // add numbers - - while(number && idx) - { - --idx; - tmpbuf[idx] = (c8)('0' + (number % 10)); - number /= 10; - } - - // add sign - - if (negative) - { - --idx; - tmpbuf[idx] = '-'; - } - - *this = &tmpbuf[idx]; - } - - - - //! Constructs a string from an unsigned int - string(unsigned int number) - : array(0), allocated(0), used(0) - { - // temporary buffer for 16 numbers - - c8 tmpbuf[16]; - tmpbuf[15] = 0; - u32 idx = 15; - - // special case '0' - - if (!number) - { - tmpbuf[14] = '0'; - *this = &tmpbuf[14]; - return; - } - - // add numbers - - while(number && idx) - { - --idx; - tmpbuf[idx] = (c8)('0' + (number % 10)); - number /= 10; - } - - *this = &tmpbuf[idx]; - } - - - - //! Constructor for copying a string from a pointer with a given length - template - string(const B* const c, u32 length) - : array(0), allocated(0), used(0) - { - if (!c) - { - // correctly init the string to an empty one - *this=""; - return; - } - - allocated = used = length+1; - array = allocator.allocate(used); // new T[used]; - - for (u32 l = 0; l - string(const B* const c) - : array(0), allocated(0), used(0) - { - *this = c; - } - - - - //! destructor - ~string() - { - allocator.deallocate(array); // delete [] array; - } - - - - //! Assignment operator - string& operator=(const string& other) - { - if (this == &other) - return *this; - - allocator.deallocate(array); // delete [] array; - allocated = used = other.size()+1; - array = allocator.allocate(used); //new T[used]; - - const T* p = other.c_str(); - for (u32 i=0; i - string& operator=(const B* const c) - { - if (!c) - { - if (!array) - { - array = allocator.allocate(1); //new T[1]; - allocated = 1; - } - used = 1; - array[0] = 0x0; - return *this; - } - - if ((void*)c == (void*)array) - return *this; - - u32 len = 0; - const B* p = c; - while(*p) - { - ++len; - ++p; - } - - // we'll take the old string for a while, because the new - // string could be a part of the current string. - T* oldArray = array; - - ++len; - allocated = used = len; - array = allocator.allocate(used); //new T[used]; - - for (u32 l = 0; l operator+(const string& other) const - { - string str(*this); - str.append(other); - - return str; - } - - //! Add operator for strings, ascii and unicode - template - string operator+(const B* const c) const - { - string str(*this); - str.append(c); - - return str; - } - - - - //! Direct access operator - T& operator [](const u32 index) const - { - _IRR_DEBUG_BREAK_IF(index>=used) // bad index - - return array[index]; - } - - - //! Comparison operator - bool operator ==(const T* const str) const - { - if (!str) - return false; - - u32 i; - for(i=0; array[i] && str[i]; ++i) - if (array[i] != str[i]) - return false; - - return !array[i] && !str[i]; - } - - - - //! Comparison operator - bool operator ==(const string& other) const - { - for(u32 i=0; array[i] && other.array[i]; ++i) - if (array[i] != other.array[i]) - return false; - - return used == other.used; - } - - - //! Is smaller operator - bool operator <(const string& other) const - { - for(u32 i=0; array[i] && other.array[i]; ++i) - { - s32 diff = array[i] - other.array[i]; - if ( diff ) - return diff < 0; -/* - if (array[i] != other.array[i]) - return (array[i] < other.array[i]); -*/ - } - - return used < other.used; - } - - - - //! Equals not operator - bool operator !=(const T* const str) const - { - return !(*this == str); - } - - - - //! Equals not operator - bool operator !=(const string& other) const - { - return !(*this == other); - } - - - - //! Returns length of string - /** \return Returns length of the string in characters. */ - u32 size() const - { - return used-1; - } - - - - //! Returns character string - /** \return Returns pointer to C-style zero terminated string. */ - const T* c_str() const - { - return array; - } - - - - //! Makes the string lower case. - void make_lower() - { - for (u32 i=0; i=a && array[i]<=z) - array[i] += diff; - } - } - - - - //! Compares the string ignoring case. - /** \param other: Other string to compare. - \return Returns true if the string are equal ignoring case. */ - bool equals_ignore_case(const string& other) const - { - for(u32 i=0; array[i] && other[i]; ++i) - if (ansi_lower(array[i]) != ansi_lower(other[i])) - return false; - - return used == other.used; - } - - //! Compares the string ignoring case. - /** \param other: Other string to compare. - \return Returns true if the string is smaller ignoring case. */ - bool lower_ignore_case(const string& other) const - { - for(u32 i=0; array[i] && other.array[i]; ++i) - { - s32 diff = (s32) ansi_lower ( array[i] ) - (s32) ansi_lower ( other.array[i] ); - if ( diff ) - return diff < 0; - } - - return used < other.used; - } - - - - //! compares the first n characters of the strings - bool equalsn(const string& other, int len) const - { - u32 i; - for(i=0; array[i] && other[i] && i < len; ++i) - if (array[i] != other[i]) - return false; - - // if one (or both) of the strings was smaller then they - // are only equal if they have the same length - return (i == len) || (used == other.used); - } - - - //! compares the first n characters of the strings - bool equalsn(const T* const str, int len) const - { - if (!str) - return false; - u32 i; - for(i=0; array[i] && str[i] && i < len; ++i) - if (array[i] != str[i]) - return false; - - // if one (or both) of the strings was smaller then they - // are only equal if they have the same length - return (i == len) || (array[i] == 0 && str[i] == 0); - } - - - //! Appends a character to this string - /** \param character: Character to append. */ - void append(T character) - { - if (used + 1 > allocated) - reallocate(used + 1); - - ++used; - - array[used-2] = character; - array[used-1] = 0; - } - - //! Appends a char string to this string - /** \param other: Char string to append. */ - void append(const T* const other) - { - if (!other) - return; - - u32 len = 0; - const T* p = other; - while(*p) - { - ++len; - ++p; - } - - if (used + len > allocated) - reallocate(used + len); - - --used; - ++len; - - for (u32 l=0; l& other) - { - --used; - u32 len = other.size()+1; - - if (used + len > allocated) - reallocate(used + len); - - for (u32 l=0; l& other, u32 length) - { - if (other.size() < length) - { - append(other); - return; - } - - if (used + length > allocated) - reallocate(used + length); - - --used; - - for (u32 l=0; l - s32 findFirstCharNotInList(const B* const c, u32 count) const - { - for (u32 i=0; i - s32 findLastCharNotInList(const B* const c, u32 count) const - { - for (s32 i=(s32)(used-2); i>=0; --i) - { - u32 j; - for (j=0; j=0; --i) - if (array[i] == c) - return i; - - return -1; - } - - //! finds another string in this string - //! \param str: Another string - //! \return Returns positions where the string has been found, - //! or -1 if not found. - template - s32 find(const B* const str) const - { - if (str && *str) - { - u32 len = 0; - - while (str[len]) - ++len; - - if (len > used-1) - return -1; - - for (u32 i=0; i subString(u32 begin, s32 length) const - { - if ((length+begin) > size()) - length = size()-begin; - if (length <= 0) - return string(""); - - string o; - o.reserve(length+1); - - for (s32 i=0; i& other) - { - append(other); - } - - void operator += (int i) - { - append(string(i)); - } - - void operator += (double i) - { - append(string(i)); - } - - //! replaces all characters of a special type with another one - void replace(T toReplace, T replaceWith) - { - for (u32 i=0; i=used) // access violation - - for (u32 i=index+1; i=(T)'A' && t<=(T)'Z') - return t + ((T)'a' - (T)'A'); - else - return t; - } -*/ - //! Returns a character converted to lower case - inline T ansi_lower ( u32 x ) const - { - return x >= 'A' && x <= 'Z' ? (T) x + 0x20 : (T) x; - } - - - //! Reallocate the array, make it bigger or smaller - void reallocate(u32 new_size) - { - T* old_array = array; - - array = allocator.allocate(new_size); //new T[new_size]; - allocated = new_size; - - u32 amount = used < new_size ? used : new_size; - for (u32 i=0; i stringc; - -//! Typedef for wide character strings -typedef string stringw; - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine" and the "irrXML" project. +// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h + +#ifndef __IRR_STRING_H_INCLUDED__ +#define __IRR_STRING_H_INCLUDED__ + +#include "irrTypes.h" +#include "irrAllocator.h" +#include "irrMath.h" +#include +#include +#include + +namespace irr +{ +namespace core +{ + +//! Very simple string class with some useful features. +/** string and string work both with unicode AND ascii, +so you can assign unicode to string and ascii to string +(and the other way round) if your ever would want to. +Note that the conversation between both is not done using an encoding. + +Known bugs: +Special characters like 'Ä', 'Ü' and 'Ö' are ignored in the +methods make_upper, make_lower and equals_ignore_case. +*/ +template > +class string +{ +public: + + //! Default constructor + string() + : array(0), allocated(1), used(1) + { + array = allocator.allocate(1); // new T[1]; + array[0] = 0x0; + } + + + + //! Constructor + string(const string& other) + : array(0), allocated(0), used(0) + { + *this = other; + } + + + //! Constructs a string from a float + string(double number) + : array(0), allocated(0), used(0) + { + c8 tmpbuf[255]; + sprintf(tmpbuf,"%0.6f",number); + *this = tmpbuf; + } + + + + //! Constructs a string from an int + string(int number) + : array(0), allocated(0), used(0) + { + // store if negative and make positive + + bool negative = false; + if (number < 0) + { + number *= -1; + negative = true; + } + + // temporary buffer for 16 numbers + + c8 tmpbuf[16]; + tmpbuf[15] = 0; + u32 idx = 15; + + // special case '0' + + if (!number) + { + tmpbuf[14] = '0'; + *this = &tmpbuf[14]; + return; + } + + // add numbers + + while(number && idx) + { + --idx; + tmpbuf[idx] = (c8)('0' + (number % 10)); + number /= 10; + } + + // add sign + + if (negative) + { + --idx; + tmpbuf[idx] = '-'; + } + + *this = &tmpbuf[idx]; + } + + + + //! Constructs a string from an unsigned int + string(unsigned int number) + : array(0), allocated(0), used(0) + { + // temporary buffer for 16 numbers + + c8 tmpbuf[16]; + tmpbuf[15] = 0; + u32 idx = 15; + + // special case '0' + + if (!number) + { + tmpbuf[14] = '0'; + *this = &tmpbuf[14]; + return; + } + + // add numbers + + while(number && idx) + { + --idx; + tmpbuf[idx] = (c8)('0' + (number % 10)); + number /= 10; + } + + *this = &tmpbuf[idx]; + } + + + + //! Constructor for copying a string from a pointer with a given length + template + string(const B* const c, u32 length) + : array(0), allocated(0), used(0) + { + if (!c) + { + // correctly init the string to an empty one + *this=""; + return; + } + + allocated = used = length+1; + array = allocator.allocate(used); // new T[used]; + + for (u32 l = 0; l + string(const B* const c) + : array(0), allocated(0), used(0) + { + *this = c; + } + + + + //! destructor + ~string() + { + allocator.deallocate(array); // delete [] array; + } + + + + //! Assignment operator + string& operator=(const string& other) + { + if (this == &other) + return *this; + + allocator.deallocate(array); // delete [] array; + allocated = used = other.size()+1; + array = allocator.allocate(used); //new T[used]; + + const T* p = other.c_str(); + for (u32 i=0; i + string& operator=(const B* const c) + { + if (!c) + { + if (!array) + { + array = allocator.allocate(1); //new T[1]; + allocated = 1; + } + used = 1; + array[0] = 0x0; + return *this; + } + + if ((void*)c == (void*)array) + return *this; + + u32 len = 0; + const B* p = c; + while(*p) + { + ++len; + ++p; + } + + // we'll take the old string for a while, because the new + // string could be a part of the current string. + T* oldArray = array; + + ++len; + allocated = used = len; + array = allocator.allocate(used); //new T[used]; + + for (u32 l = 0; l operator+(const string& other) const + { + string str(*this); + str.append(other); + + return str; + } + + //! Add operator for strings, ascii and unicode + template + string operator+(const B* const c) const + { + string str(*this); + str.append(c); + + return str; + } + + + + //! Direct access operator + T& operator [](const u32 index) const + { + _IRR_DEBUG_BREAK_IF(index>=used) // bad index + + return array[index]; + } + + + //! Comparison operator + bool operator ==(const T* const str) const + { + if (!str) + return false; + + u32 i; + for(i=0; array[i] && str[i]; ++i) + if (array[i] != str[i]) + return false; + + return !array[i] && !str[i]; + } + + + + //! Comparison operator + bool operator ==(const string& other) const + { + for(u32 i=0; array[i] && other.array[i]; ++i) + if (array[i] != other.array[i]) + return false; + + return used == other.used; + } + + + //! Is smaller operator + bool operator <(const string& other) const + { + for(u32 i=0; array[i] && other.array[i]; ++i) + { + s32 diff = array[i] - other.array[i]; + if ( diff ) + return diff < 0; +/* + if (array[i] != other.array[i]) + return (array[i] < other.array[i]); +*/ + } + + return used < other.used; + } + + + + //! Equals not operator + bool operator !=(const T* const str) const + { + return !(*this == str); + } + + + + //! Equals not operator + bool operator !=(const string& other) const + { + return !(*this == other); + } + + + + //! Returns length of string + /** \return Returns length of the string in characters. */ + u32 size() const + { + return used-1; + } + + + + //! Returns character string + /** \return Returns pointer to C-style zero terminated string. */ + const T* c_str() const + { + return array; + } + + + + //! Makes the string lower case. + void make_lower() + { + for (u32 i=0; i=a && array[i]<=z) + array[i] += diff; + } + } + + + + //! Compares the string ignoring case. + /** \param other: Other string to compare. + \return Returns true if the string are equal ignoring case. */ + bool equals_ignore_case(const string& other) const + { + for(u32 i=0; array[i] && other[i]; ++i) + if (ansi_lower(array[i]) != ansi_lower(other[i])) + return false; + + return used == other.used; + } + + //! Compares the string ignoring case. + /** \param other: Other string to compare. + \return Returns true if the string is smaller ignoring case. */ + bool lower_ignore_case(const string& other) const + { + for(u32 i=0; array[i] && other.array[i]; ++i) + { + s32 diff = (s32) ansi_lower ( array[i] ) - (s32) ansi_lower ( other.array[i] ); + if ( diff ) + return diff < 0; + } + + return used < other.used; + } + + + + //! compares the first n characters of the strings + bool equalsn(const string& other, int len) const + { + u32 i; + for(i=0; array[i] && other[i] && i < len; ++i) + if (array[i] != other[i]) + return false; + + // if one (or both) of the strings was smaller then they + // are only equal if they have the same length + return (i == len) || (used == other.used); + } + + + //! compares the first n characters of the strings + bool equalsn(const T* const str, int len) const + { + if (!str) + return false; + u32 i; + for(i=0; array[i] && str[i] && i < len; ++i) + if (array[i] != str[i]) + return false; + + // if one (or both) of the strings was smaller then they + // are only equal if they have the same length + return (i == len) || (array[i] == 0 && str[i] == 0); + } + + + //! Appends a character to this string + /** \param character: Character to append. */ + void append(T character) + { + if (used + 1 > allocated) + reallocate(used + 1); + + ++used; + + array[used-2] = character; + array[used-1] = 0; + } + + //! Appends a char string to this string + /** \param other: Char string to append. */ + void append(const T* const other) + { + if (!other) + return; + + u32 len = 0; + const T* p = other; + while(*p) + { + ++len; + ++p; + } + + if (used + len > allocated) + reallocate(used + len); + + --used; + ++len; + + for (u32 l=0; l& other) + { + --used; + u32 len = other.size()+1; + + if (used + len > allocated) + reallocate(used + len); + + for (u32 l=0; l& other, u32 length) + { + if (other.size() < length) + { + append(other); + return; + } + + if (used + length > allocated) + reallocate(used + length); + + --used; + + for (u32 l=0; l + s32 findFirstCharNotInList(const B* const c, u32 count) const + { + for (u32 i=0; i + s32 findLastCharNotInList(const B* const c, u32 count) const + { + for (s32 i=(s32)(used-2); i>=0; --i) + { + u32 j; + for (j=0; j=0; --i) + if (array[i] == c) + return i; + + return -1; + } + + //! finds another string in this string + //! \param str: Another string + //! \return Returns positions where the string has been found, + //! or -1 if not found. + template + s32 find(const B* const str) const + { + if (str && *str) + { + u32 len = 0; + + while (str[len]) + ++len; + + if (len > used-1) + return -1; + + for (u32 i=0; i subString(u32 begin, s32 length) const + { + if ((length+begin) > size()) + length = size()-begin; + if (length <= 0) + return string(""); + + string o; + o.reserve(length+1); + + for (s32 i=0; i& other) + { + append(other); + } + + void operator += (int i) + { + append(string(i)); + } + + void operator += (double i) + { + append(string(i)); + } + + //! replaces all characters of a special type with another one + void replace(T toReplace, T replaceWith) + { + for (u32 i=0; i=used) // access violation + + for (u32 i=index+1; i=(T)'A' && t<=(T)'Z') + return t + ((T)'a' - (T)'A'); + else + return t; + } +*/ + //! Returns a character converted to lower case + inline T ansi_lower ( u32 x ) const + { + return x >= 'A' && x <= 'Z' ? (T) x + 0x20 : (T) x; + } + + + //! Reallocate the array, make it bigger or smaller + void reallocate(u32 new_size) + { + T* old_array = array; + + array = allocator.allocate(new_size); //new T[new_size]; + allocated = new_size; + + u32 amount = used < new_size ? used : new_size; + for (u32 i=0; i stringc; + +//! Typedef for wide character strings +typedef string stringw; + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/irrTypes.h b/src/dep/include/irrlicht/irrTypes.h index f34af23..c090e7b 100644 --- a/src/dep/include/irrlicht/irrTypes.h +++ b/src/dep/include/irrlicht/irrTypes.h @@ -1,142 +1,142 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_TYPES_H_INCLUDED__ -#define __IRR_TYPES_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -namespace irr -{ - -//! 8 bit unsigned variable. -/** This is a typedef for unsigned char, it ensures portability of the engine. */ -typedef unsigned char u8; - -//! 8 bit signed variable. -/** This is a typedef for signed char, it ensures portability of the engine. */ -typedef signed char s8; - -//! 8 bit character variable. -/** This is a typedef for char, it ensures portability of the engine. */ -typedef char c8; - - - -//! 16 bit unsigned variable. -/** This is a typedef for unsigned short, it ensures portability of the engine. */ -typedef unsigned short u16; - -//! 16 bit signed variable. -/** This is a typedef for signed short, it ensures portability of the engine. */ -typedef signed short s16; - - - -//! 32 bit unsigned variable. -/** This is a typedef for unsigned int, it ensures portability of the engine. */ -typedef unsigned int u32; - -//! 32 bit signed variable. -/** This is a typedef for signed int, it ensures portability of the engine. */ -typedef signed int s32; - - - -// 64 bit signed variable. -// This is a typedef for __int64, it ensures portability of the engine. -// This type is currently not used by the engine and not supported by compilers -// other than Microsoft Compilers, so it is outcommented. -//typedef __int64 s64; - - - -//! 32 bit floating point variable. -/** This is a typedef for float, it ensures portability of the engine. */ -typedef float f32; - -//! 64 bit floating point variable. -/** This is a typedef for double, it ensures portability of the engine. */ -typedef double f64; - - -} // end namespace irr - - -#include -#ifdef _IRR_WINDOWS_ -//! Defines for s{w,n}printf because these methods do not match the ISO C -//! standard on Windows platforms, but it does on all others. -#define swprintf _snwprintf -#define snprintf _snprintf - -// define the wchar_t type if not already built in. -#ifdef _MSC_VER -#ifndef _WCHAR_T_DEFINED -//! A 16 bit wide character type. -/** - Defines the wchar_t-type. - In VS6, its not possible to tell - the standard compiler to treat wchar_t as a built-in type, and - sometimes we just don't want to include the huge stdlib.h or wchar.h, - so we'll use this. -*/ -typedef unsigned short wchar_t; -#define _WCHAR_T_DEFINED -#endif // wchar is not defined -#endif // microsoft compiler -#endif // _IRR_WINDOWS_ - -//! define a break macro for debugging. -#if defined(_DEBUG) -#if defined(_IRR_WINDOWS_) && defined(_MSC_VER) -#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_asm int 3} -#else -#include "assert.h" -#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) assert( !(_CONDITION_) ); -#endif -#else -#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) -#endif - -//! Defines a small statement to work around a microsoft compiler bug. -/** The microsft compiler 7.0 - 7.1 has a bug: -When you call unmanaged code that returns a bool type value of false from managed code, -the return value may appear as true. See -http://support.microsoft.com/default.aspx?kbid=823071 for details. -Compiler version defines: VC6.0 : 1200, VC7.0 : 1300, VC7.1 : 1310, VC8.0 : 1400*/ -#if defined(_IRR_WINDOWS_) && defined(_MSC_VER) && (_MSC_VER > 1299) && (_MSC_VER < 1400) -#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX __asm mov eax,100 -#else -#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX -#endif // _IRR_MANAGED_MARSHALLING_BUGFIX - - -#if defined(_DEBUG) && defined(IRRLICHT_EXPORTS) && defined(_MSC_VER) && \ - (_MSC_VER > 1299) && !defined(_IRR_DONT_DO_MEMORY_DEBUGGING_HERE) - - #define CRTDBG_MAP_ALLOC - #define _CRTDBG_MAP_ALLOC - #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) - #include - #include - #define new DEBUG_CLIENTBLOCK -#endif - -// disable truncated debug information warning in visual studio 6 by default -#if defined(_MSC_VER) && (_MSC_VER < 1300 ) -#pragma warning( disable: 4786) -#endif // _MSC - -//! ignore VC8 warning deprecated -/** The microsoft compiler */ -#if defined(_IRR_WINDOWS_) && defined(_MSC_VER) && (_MSC_VER >= 1400) - //#pragma warning( disable: 4996) - //#define _CRT_SECURE_NO_DEPRECATE 1 - //#define _CRT_NONSTDC_NO_DEPRECATE 1 -#endif - - -#endif // __IRR_TYPES_H_INCLUDED__ - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_TYPES_H_INCLUDED__ +#define __IRR_TYPES_H_INCLUDED__ + +#include "IrrCompileConfig.h" + +namespace irr +{ + +//! 8 bit unsigned variable. +/** This is a typedef for unsigned char, it ensures portability of the engine. */ +typedef unsigned char u8; + +//! 8 bit signed variable. +/** This is a typedef for signed char, it ensures portability of the engine. */ +typedef signed char s8; + +//! 8 bit character variable. +/** This is a typedef for char, it ensures portability of the engine. */ +typedef char c8; + + + +//! 16 bit unsigned variable. +/** This is a typedef for unsigned short, it ensures portability of the engine. */ +typedef unsigned short u16; + +//! 16 bit signed variable. +/** This is a typedef for signed short, it ensures portability of the engine. */ +typedef signed short s16; + + + +//! 32 bit unsigned variable. +/** This is a typedef for unsigned int, it ensures portability of the engine. */ +typedef unsigned int u32; + +//! 32 bit signed variable. +/** This is a typedef for signed int, it ensures portability of the engine. */ +typedef signed int s32; + + + +// 64 bit signed variable. +// This is a typedef for __int64, it ensures portability of the engine. +// This type is currently not used by the engine and not supported by compilers +// other than Microsoft Compilers, so it is outcommented. +//typedef __int64 s64; + + + +//! 32 bit floating point variable. +/** This is a typedef for float, it ensures portability of the engine. */ +typedef float f32; + +//! 64 bit floating point variable. +/** This is a typedef for double, it ensures portability of the engine. */ +typedef double f64; + + +} // end namespace irr + + +#include +#ifdef _IRR_WINDOWS_ +//! Defines for s{w,n}printf because these methods do not match the ISO C +//! standard on Windows platforms, but it does on all others. +#define swprintf _snwprintf +#define snprintf _snprintf + +// define the wchar_t type if not already built in. +#ifdef _MSC_VER +#ifndef _WCHAR_T_DEFINED +//! A 16 bit wide character type. +/** + Defines the wchar_t-type. + In VS6, its not possible to tell + the standard compiler to treat wchar_t as a built-in type, and + sometimes we just don't want to include the huge stdlib.h or wchar.h, + so we'll use this. +*/ +typedef unsigned short wchar_t; +#define _WCHAR_T_DEFINED +#endif // wchar is not defined +#endif // microsoft compiler +#endif // _IRR_WINDOWS_ + +//! define a break macro for debugging. +#if defined(_DEBUG) +#if defined(_IRR_WINDOWS_) && defined(_MSC_VER) +#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_asm int 3} +#else +#include "assert.h" +#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) assert( !(_CONDITION_) ); +#endif +#else +#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) +#endif + +//! Defines a small statement to work around a microsoft compiler bug. +/** The microsft compiler 7.0 - 7.1 has a bug: +When you call unmanaged code that returns a bool type value of false from managed code, +the return value may appear as true. See +http://support.microsoft.com/default.aspx?kbid=823071 for details. +Compiler version defines: VC6.0 : 1200, VC7.0 : 1300, VC7.1 : 1310, VC8.0 : 1400*/ +#if defined(_IRR_WINDOWS_) && defined(_MSC_VER) && (_MSC_VER > 1299) && (_MSC_VER < 1400) +#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX __asm mov eax,100 +#else +#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX +#endif // _IRR_MANAGED_MARSHALLING_BUGFIX + + +#if defined(_DEBUG) && defined(IRRLICHT_EXPORTS) && defined(_MSC_VER) && \ + (_MSC_VER > 1299) && !defined(_IRR_DONT_DO_MEMORY_DEBUGGING_HERE) + + #define CRTDBG_MAP_ALLOC + #define _CRTDBG_MAP_ALLOC + #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) + #include + #include + #define new DEBUG_CLIENTBLOCK +#endif + +// disable truncated debug information warning in visual studio 6 by default +#if defined(_MSC_VER) && (_MSC_VER < 1300 ) +#pragma warning( disable: 4786) +#endif // _MSC + +//! ignore VC8 warning deprecated +/** The microsoft compiler */ +#if defined(_IRR_WINDOWS_) && defined(_MSC_VER) && (_MSC_VER >= 1400) + //#pragma warning( disable: 4996) + //#define _CRT_SECURE_NO_DEPRECATE 1 + //#define _CRT_NONSTDC_NO_DEPRECATE 1 +#endif + + +#endif // __IRR_TYPES_H_INCLUDED__ + diff --git a/src/dep/include/irrlicht/irrXML.h b/src/dep/include/irrlicht/irrXML.h index 74d632b..931ec82 100644 --- a/src/dep/include/irrlicht/irrXML.h +++ b/src/dep/include/irrlicht/irrXML.h @@ -1,540 +1,540 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h - -#ifndef __IRR_XML_H_INCLUDED__ -#define __IRR_XML_H_INCLUDED__ - -#include - -/** \mainpage irrXML 1.2 API documentation -
- - \section intro Introduction - - Welcome to the irrXML API documentation. - Here you'll find any information you'll need to develop applications with - irrXML. If you look for a tutorial on how to start, take a look at the \ref irrxmlexample, - at the homepage of irrXML at xml.irrlicht3d.org - or into the SDK in the directory \example. - - irrXML is intended to be a high speed and easy-to-use XML Parser for C++, and - this documentation is an important part of it. If you have any questions or - suggestions, just send a email to the author of the engine, Nikolaus Gebhardt - (niko (at) irrlicht3d.org). For more informations about this parser, see \ref history. - - \section features Features - - irrXML provides forward-only, read-only - access to a stream of non validated XML data. It was fully implemented by - Nikolaus Gebhardt. Its current features are: - - - It it fast as lighting and has very low memory usage. It was - developed with the intention of being used in 3D games, as it already has been. - - irrXML is very small: It only consists of 60 KB of code and can be added easily - to your existing project. - - Of course, it is platform independent and works with lots of compilers. - - It is able to parse ASCII, UTF-8, UTF-16 and UTF-32 text files, both in - little and big endian format. - - Independent of the input file format, the parser can return all strings in ASCII, UTF-8, - UTF-16 and UTF-32 format. - - With its optional file access abstraction it has the advantage that it can read not - only from files but from any type of data (memory, network, ...). For example when - used with the Irrlicht Engine, it directly reads from compressed .zip files. - - Just like the Irrlicht Engine for which it was originally created, it is extremely easy - to use. - - It has no external dependencies, it does not even need the STL. - - Although irrXML has some strenghts, it currently also has the following limitations: - - - The input xml file is not validated and assumed to be correct. - - \section irrxmlexample Example - - The following code demonstrates the basic usage of irrXML. A simple xml - file like this is parsed: - \code - - - - - - Welcome to the Mesh Viewer of the "Irrlicht Engine". - - - \endcode - - The code for parsing this file would look like this: - \code - #include - using namespace irr; // irrXML is located in the namespace irr::io - using namespace io; - - #include // we use STL strings to store data in this example - - void main() - { - // create the reader using one of the factory functions - - IrrXMLReader* xml = createIrrXMLReader("config.xml"); - - // strings for storing the data we want to get out of the file - std::string modelFile; - std::string messageText; - std::string caption; - - // parse the file until end reached - - while(xml && xml->read()) - { - switch(xml->getNodeType()) - { - case EXN_TEXT: - // in this xml file, the only text which occurs is the messageText - messageText = xml->getNodeData(); - break; - case EXN_ELEMENT: - { - if (!strcmp("model", xml->getNodeName())) - modelFile = xml->getAttributeValue("file"); - else - if (!strcmp("messageText", xml->getNodeName())) - caption = xml->getAttributeValue("caption"); - } - break; - } - } - - // delete the xml parser after usage - delete xml; - } - \endcode - - \section howto How to use - - Simply add the source files in the /src directory of irrXML to your project. Done. - - \section license License - - The irrXML license is based on the zlib license. Basicly, this means you can do with - irrXML whatever you want: - - Copyright (C) 2002-2007 Nikolaus Gebhardt - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source distribution. - - \section history History - - As lots of references in this documentation and the source show, this xml - parser has originally been a part of the - Irrlicht Engine. But because - the parser has become very useful with the latest release, people asked for a - separate version of it, to be able to use it in non Irrlicht projects. With - irrXML 1.0, this has now been done. -*/ - -namespace irr -{ -namespace io -{ - //! Enumeration of all supported source text file formats - enum ETEXT_FORMAT - { - //! ASCII, file without byte order mark, or not a text file - ETF_ASCII, - - //! UTF-8 format - ETF_UTF8, - - //! UTF-16 format, big endian - ETF_UTF16_BE, - - //! UTF-16 format, little endian - ETF_UTF16_LE, - - //! UTF-32 format, big endian - ETF_UTF32_BE, - - //! UTF-32 format, little endian - ETF_UTF32_LE - }; - - - //! Enumeration for all xml nodes which are parsed by IrrXMLReader - enum EXML_NODE - { - //! No xml node. This is usually the node if you did not read anything yet. - EXN_NONE, - - //! An xml element such as <foo> - EXN_ELEMENT, - - //! End of an xml element such as </foo> - EXN_ELEMENT_END, - - //! Text within an xml element: <foo> this is the text. <foo> - EXN_TEXT, - - //! An xml comment like <!-- I am a comment --> or a DTD definition. - EXN_COMMENT, - - //! An xml cdata section like <![CDATA[ this is some CDATA ]]> - EXN_CDATA, - - //! Unknown element. - EXN_UNKNOWN - }; - - //! Callback class for file read abstraction. - /** With this, it is possible to make the xml parser read in other things - than just files. The Irrlicht engine is using this for example to - read xml from compressed .zip files. To make the parser read in - any other data, derive a class from this interface, implement the - two methods to read your data and give a pointer to an instance of - your implementation when calling createIrrXMLReader(), - createIrrXMLReaderUTF16() or createIrrXMLReaderUTF32() */ - class IFileReadCallBack - { - public: - - //! virtual destructor - virtual ~IFileReadCallBack() {}; - - //! Reads an amount of bytes from the file. - /** \param buffer: Pointer to buffer where to read bytes will be written to. - \param sizeToRead: Amount of bytes to read from the file. - \return Returns how much bytes were read. */ - virtual int read(void* buffer, int sizeToRead) = 0; - - //! Returns size of file in bytes - virtual int getSize() = 0; - }; - - //! Empty class to be used as parent class for IrrXMLReader. - /** If you need another class as base class for the xml reader, you can do this by creating - the reader using for example new CXMLReaderImpl(yourcallback); - The Irrlicht Engine for example needs IUnknown as base class for every object to - let it automaticly reference countend, hence it replaces IXMLBase with IUnknown. - See irrXML.cpp on how this can be done in detail. */ - class IXMLBase - { - }; - - //! Interface providing easy read access to a XML file. - /** You can create an instance of this reader using one of the factory functions - createIrrXMLReader(), createIrrXMLReaderUTF16() and createIrrXMLReaderUTF32(). - If using the parser from the Irrlicht Engine, please use IFileSystem::createXMLReader() - instead. - For a detailed intro how to use the parser, see \ref irrxmlexample and \ref features. - - The typical usage of this parser looks like this: - \code - #include - using namespace irr; // irrXML is located in the namespace irr::io - using namespace io; - - void main() - { - // create the reader using one of the factory functions - IrrXMLReader* xml = createIrrXMLReader("config.xml"); - - if (xml == 0) - return; // file could not be opened - - // parse the file until end reached - while(xml->read()) - { - // based on xml->getNodeType(), do something. - } - - // delete the xml parser after usage - delete xml; - } - \endcode - See \ref irrxmlexample for a more detailed example. - */ - template - class IIrrXMLReader : public super_class - { - public: - - //! Destructor - virtual ~IIrrXMLReader() {}; - - //! Reads forward to the next xml node. - /** \return Returns false, if there was no further node. */ - virtual bool read() = 0; - - //! Returns the type of the current XML node. - virtual EXML_NODE getNodeType() const = 0; - - //! Returns attribute count of the current XML node. - /** This is usually - non null if the current node is EXN_ELEMENT, and the element has attributes. - \return Returns amount of attributes of this xml node. */ - virtual int getAttributeCount() const = 0; - - //! Returns name of an attribute. - /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. - \return Name of the attribute, 0 if an attribute with this index does not exist. */ - virtual const char_type* getAttributeName(int idx) const = 0; - - //! Returns the value of an attribute. - /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. - \return Value of the attribute, 0 if an attribute with this index does not exist. */ - virtual const char_type* getAttributeValue(int idx) const = 0; - - //! Returns the value of an attribute. - /** \param name: Name of the attribute. - \return Value of the attribute, 0 if an attribute with this name does not exist. */ - virtual const char_type* getAttributeValue(const char_type* name) const = 0; - - //! Returns the value of an attribute in a safe way. - /** Like getAttributeValue(), but does not - return 0 if the attribute does not exist. An empty string ("") is returned then. - \param name: Name of the attribute. - \return Value of the attribute, and "" if an attribute with this name does not exist */ - virtual const char_type* getAttributeValueSafe(const char_type* name) const = 0; - - //! Returns the value of an attribute as integer. - /** \param name Name of the attribute. - \return Value of the attribute as integer, and 0 if an attribute with this name does not exist or - the value could not be interpreted as integer. */ - virtual int getAttributeValueAsInt(const char_type* name) const = 0; - - //! Returns the value of an attribute as integer. - /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. - \return Value of the attribute as integer, and 0 if an attribute with this index does not exist or - the value could not be interpreted as integer. */ - virtual int getAttributeValueAsInt(int idx) const = 0; - - //! Returns the value of an attribute as float. - /** \param name: Name of the attribute. - \return Value of the attribute as float, and 0 if an attribute with this name does not exist or - the value could not be interpreted as float. */ - virtual float getAttributeValueAsFloat(const char_type* name) const = 0; - - //! Returns the value of an attribute as float. - /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. - \return Value of the attribute as float, and 0 if an attribute with this index does not exist or - the value could not be interpreted as float. */ - virtual float getAttributeValueAsFloat(int idx) const = 0; - - //! Returns the name of the current node. - /** Only non null, if the node type is EXN_ELEMENT. - \return Name of the current node or 0 if the node has no name. */ - virtual const char_type* getNodeName() const = 0; - - //! Returns data of the current node. - /** Only non null if the node has some - data and it is of type EXN_TEXT or EXN_UNKNOWN. */ - virtual const char_type* getNodeData() const = 0; - - //! Returns if an element is an empty element, like - virtual bool isEmptyElement() const = 0; - - //! Returns format of the source xml file. - /** It is not necessary to use - this method because the parser will convert the input file format - to the format wanted by the user when creating the parser. This - method is useful to get/display additional informations. */ - virtual ETEXT_FORMAT getSourceFormat() const = 0; - - //! Returns format of the strings returned by the parser. - /** This will be UTF8 for example when you created a parser with - IrrXMLReaderUTF8() and UTF32 when it has been created using - IrrXMLReaderUTF32. It should not be necessary to call this - method and only exists for informational purposes. */ - virtual ETEXT_FORMAT getParserFormat() const = 0; - }; - - - //! defines the utf-16 type. - /** Not using wchar_t for this because - wchar_t has 16 bit on windows and 32 bit on other operating systems. */ - typedef unsigned short char16; - - //! defines the utf-32 type. - /** Not using wchar_t for this because - wchar_t has 16 bit on windows and 32 bit on other operating systems. */ - typedef unsigned long char32; - - //! A UTF-8 or ASCII character xml parser. - /** This means that all character data will be returned in 8 bit ASCII or UTF-8 by this parser. - The file to read can be in any format, it will be converted to UTF-8 if it is not - in this format. - Create an instance of this with createIrrXMLReader(); - See IIrrXMLReader for description on how to use it. */ - typedef IIrrXMLReader IrrXMLReader; - - //! A UTF-16 xml parser. - /** This means that all character data will be returned in UTF-16 by this parser. - The file to read can be in any format, it will be converted to UTF-16 if it is not - in this format. - Create an instance of this with createIrrXMLReaderUTF16(); - See IIrrXMLReader for description on how to use it. */ - typedef IIrrXMLReader IrrXMLReaderUTF16; - - //! A UTF-32 xml parser. - /** This means that all character data will be returned in UTF-32 by this parser. - The file to read can be in any format, it will be converted to UTF-32 if it is not - in this format. - Create an instance of this with createIrrXMLReaderUTF32(); - See IIrrXMLReader for description on how to use it. */ - typedef IIrrXMLReader IrrXMLReaderUTF32; - - - //! Creates an instance of an UFT-8 or ASCII character xml parser. - /** This means that all character data will be returned in 8 bit ASCII or UTF-8. - The file to read can be in any format, it will be converted to UTF-8 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReaderUTF8() instead. - \param filename: Name of file to be opened. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IrrXMLReader* createIrrXMLReader(const char* filename); - - //! Creates an instance of an UFT-8 or ASCII character xml parser. - /** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can - be in any format, it will be converted to UTF-8 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReaderUTF8() instead. - \param file: Pointer to opened file, must have been opened in binary mode, e.g. - using fopen("foo.bar", "wb"); The file will not be closed after it has been read. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IrrXMLReader* createIrrXMLReader(FILE* file); - - //! Creates an instance of an UFT-8 or ASCII character xml parser. - /** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can - be in any format, it will be converted to UTF-8 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReaderUTF8() instead. - \param callback: Callback for file read abstraction. Implement your own - callback to make the xml parser read in other things than just files. See - IFileReadCallBack for more information about this. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IrrXMLReader* createIrrXMLReader(IFileReadCallBack* callback); - - //! Creates an instance of an UFT-16 xml parser. - /** This means that - all character data will be returned in UTF-16. The file to read can - be in any format, it will be converted to UTF-16 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReader() instead. - \param filename: Name of file to be opened. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IrrXMLReaderUTF16* createIrrXMLReaderUTF16(const char* filename); - - //! Creates an instance of an UFT-16 xml parser. - /** This means that all character data will be returned in UTF-16. The file to read can - be in any format, it will be converted to UTF-16 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReader() instead. - \param file: Pointer to opened file, must have been opened in binary mode, e.g. - using fopen("foo.bar", "wb"); The file will not be closed after it has been read. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IrrXMLReaderUTF16* createIrrXMLReaderUTF16(FILE* file); - - //! Creates an instance of an UFT-16 xml parser. - /** This means that all character data will be returned in UTF-16. The file to read can - be in any format, it will be converted to UTF-16 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReader() instead. - \param callback: Callback for file read abstraction. Implement your own - callback to make the xml parser read in other things than just files. See - IFileReadCallBack for more information about this. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IrrXMLReaderUTF16* createIrrXMLReaderUTF16(IFileReadCallBack* callback); - - - //! Creates an instance of an UFT-32 xml parser. - /** This means that all character data will be returned in UTF-32. The file to read can - be in any format, it will be converted to UTF-32 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReader() instead. - \param filename: Name of file to be opened. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IrrXMLReaderUTF32* createIrrXMLReaderUTF32(const char* filename); - - //! Creates an instance of an UFT-32 xml parser. - /** This means that all character data will be returned in UTF-32. The file to read can - be in any format, it will be converted to UTF-32 if it is not in this format. - if you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReader() instead. - \param file: Pointer to opened file, must have been opened in binary mode, e.g. - using fopen("foo.bar", "wb"); The file will not be closed after it has been read. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IrrXMLReaderUTF32* createIrrXMLReaderUTF32(FILE* file); - - //! Creates an instance of an UFT-32 xml parser. - /** This means that - all character data will be returned in UTF-32. The file to read can - be in any format, it will be converted to UTF-32 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReader() instead. - \param callback: Callback for file read abstraction. Implement your own - callback to make the xml parser read in other things than just files. See - IFileReadCallBack for more information about this. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IrrXMLReaderUTF32* createIrrXMLReaderUTF32(IFileReadCallBack* callback); - - - /*! \file irrxml.h - \brief Header file of the irrXML, the Irrlicht XML parser. - - This file includes everything needed for using irrXML, - the XML parser of the Irrlicht Engine. To use irrXML, - you only need to include this file in your project: - - \code - #include - \endcode - - It is also common to use the two namespaces in which irrXML is included, - directly after #including irrXML.h: - - \code - #include - using namespace irr; - using namespace io; - \endcode - */ - -} // end namespace io -} // end namespace irr - -#endif // __IRR_XML_H_INCLUDED__ - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine" and the "irrXML" project. +// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h + +#ifndef __IRR_XML_H_INCLUDED__ +#define __IRR_XML_H_INCLUDED__ + +#include + +/** \mainpage irrXML 1.2 API documentation +
+ + \section intro Introduction + + Welcome to the irrXML API documentation. + Here you'll find any information you'll need to develop applications with + irrXML. If you look for a tutorial on how to start, take a look at the \ref irrxmlexample, + at the homepage of irrXML at xml.irrlicht3d.org + or into the SDK in the directory \example. + + irrXML is intended to be a high speed and easy-to-use XML Parser for C++, and + this documentation is an important part of it. If you have any questions or + suggestions, just send a email to the author of the engine, Nikolaus Gebhardt + (niko (at) irrlicht3d.org). For more informations about this parser, see \ref history. + + \section features Features + + irrXML provides forward-only, read-only + access to a stream of non validated XML data. It was fully implemented by + Nikolaus Gebhardt. Its current features are: + + - It it fast as lighting and has very low memory usage. It was + developed with the intention of being used in 3D games, as it already has been. + - irrXML is very small: It only consists of 60 KB of code and can be added easily + to your existing project. + - Of course, it is platform independent and works with lots of compilers. + - It is able to parse ASCII, UTF-8, UTF-16 and UTF-32 text files, both in + little and big endian format. + - Independent of the input file format, the parser can return all strings in ASCII, UTF-8, + UTF-16 and UTF-32 format. + - With its optional file access abstraction it has the advantage that it can read not + only from files but from any type of data (memory, network, ...). For example when + used with the Irrlicht Engine, it directly reads from compressed .zip files. + - Just like the Irrlicht Engine for which it was originally created, it is extremely easy + to use. + - It has no external dependencies, it does not even need the STL. + + Although irrXML has some strenghts, it currently also has the following limitations: + + - The input xml file is not validated and assumed to be correct. + + \section irrxmlexample Example + + The following code demonstrates the basic usage of irrXML. A simple xml + file like this is parsed: + \code + + + + + + Welcome to the Mesh Viewer of the "Irrlicht Engine". + + + \endcode + + The code for parsing this file would look like this: + \code + #include + using namespace irr; // irrXML is located in the namespace irr::io + using namespace io; + + #include // we use STL strings to store data in this example + + void main() + { + // create the reader using one of the factory functions + + IrrXMLReader* xml = createIrrXMLReader("config.xml"); + + // strings for storing the data we want to get out of the file + std::string modelFile; + std::string messageText; + std::string caption; + + // parse the file until end reached + + while(xml && xml->read()) + { + switch(xml->getNodeType()) + { + case EXN_TEXT: + // in this xml file, the only text which occurs is the messageText + messageText = xml->getNodeData(); + break; + case EXN_ELEMENT: + { + if (!strcmp("model", xml->getNodeName())) + modelFile = xml->getAttributeValue("file"); + else + if (!strcmp("messageText", xml->getNodeName())) + caption = xml->getAttributeValue("caption"); + } + break; + } + } + + // delete the xml parser after usage + delete xml; + } + \endcode + + \section howto How to use + + Simply add the source files in the /src directory of irrXML to your project. Done. + + \section license License + + The irrXML license is based on the zlib license. Basicly, this means you can do with + irrXML whatever you want: + + Copyright (C) 2002-2007 Nikolaus Gebhardt + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. + + \section history History + + As lots of references in this documentation and the source show, this xml + parser has originally been a part of the + Irrlicht Engine. But because + the parser has become very useful with the latest release, people asked for a + separate version of it, to be able to use it in non Irrlicht projects. With + irrXML 1.0, this has now been done. +*/ + +namespace irr +{ +namespace io +{ + //! Enumeration of all supported source text file formats + enum ETEXT_FORMAT + { + //! ASCII, file without byte order mark, or not a text file + ETF_ASCII, + + //! UTF-8 format + ETF_UTF8, + + //! UTF-16 format, big endian + ETF_UTF16_BE, + + //! UTF-16 format, little endian + ETF_UTF16_LE, + + //! UTF-32 format, big endian + ETF_UTF32_BE, + + //! UTF-32 format, little endian + ETF_UTF32_LE + }; + + + //! Enumeration for all xml nodes which are parsed by IrrXMLReader + enum EXML_NODE + { + //! No xml node. This is usually the node if you did not read anything yet. + EXN_NONE, + + //! An xml element such as <foo> + EXN_ELEMENT, + + //! End of an xml element such as </foo> + EXN_ELEMENT_END, + + //! Text within an xml element: <foo> this is the text. <foo> + EXN_TEXT, + + //! An xml comment like <!-- I am a comment --> or a DTD definition. + EXN_COMMENT, + + //! An xml cdata section like <![CDATA[ this is some CDATA ]]> + EXN_CDATA, + + //! Unknown element. + EXN_UNKNOWN + }; + + //! Callback class for file read abstraction. + /** With this, it is possible to make the xml parser read in other things + than just files. The Irrlicht engine is using this for example to + read xml from compressed .zip files. To make the parser read in + any other data, derive a class from this interface, implement the + two methods to read your data and give a pointer to an instance of + your implementation when calling createIrrXMLReader(), + createIrrXMLReaderUTF16() or createIrrXMLReaderUTF32() */ + class IFileReadCallBack + { + public: + + //! virtual destructor + virtual ~IFileReadCallBack() {}; + + //! Reads an amount of bytes from the file. + /** \param buffer: Pointer to buffer where to read bytes will be written to. + \param sizeToRead: Amount of bytes to read from the file. + \return Returns how much bytes were read. */ + virtual int read(void* buffer, int sizeToRead) = 0; + + //! Returns size of file in bytes + virtual int getSize() = 0; + }; + + //! Empty class to be used as parent class for IrrXMLReader. + /** If you need another class as base class for the xml reader, you can do this by creating + the reader using for example new CXMLReaderImpl(yourcallback); + The Irrlicht Engine for example needs IUnknown as base class for every object to + let it automaticly reference countend, hence it replaces IXMLBase with IUnknown. + See irrXML.cpp on how this can be done in detail. */ + class IXMLBase + { + }; + + //! Interface providing easy read access to a XML file. + /** You can create an instance of this reader using one of the factory functions + createIrrXMLReader(), createIrrXMLReaderUTF16() and createIrrXMLReaderUTF32(). + If using the parser from the Irrlicht Engine, please use IFileSystem::createXMLReader() + instead. + For a detailed intro how to use the parser, see \ref irrxmlexample and \ref features. + + The typical usage of this parser looks like this: + \code + #include + using namespace irr; // irrXML is located in the namespace irr::io + using namespace io; + + void main() + { + // create the reader using one of the factory functions + IrrXMLReader* xml = createIrrXMLReader("config.xml"); + + if (xml == 0) + return; // file could not be opened + + // parse the file until end reached + while(xml->read()) + { + // based on xml->getNodeType(), do something. + } + + // delete the xml parser after usage + delete xml; + } + \endcode + See \ref irrxmlexample for a more detailed example. + */ + template + class IIrrXMLReader : public super_class + { + public: + + //! Destructor + virtual ~IIrrXMLReader() {}; + + //! Reads forward to the next xml node. + /** \return Returns false, if there was no further node. */ + virtual bool read() = 0; + + //! Returns the type of the current XML node. + virtual EXML_NODE getNodeType() const = 0; + + //! Returns attribute count of the current XML node. + /** This is usually + non null if the current node is EXN_ELEMENT, and the element has attributes. + \return Returns amount of attributes of this xml node. */ + virtual int getAttributeCount() const = 0; + + //! Returns name of an attribute. + /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. + \return Name of the attribute, 0 if an attribute with this index does not exist. */ + virtual const char_type* getAttributeName(int idx) const = 0; + + //! Returns the value of an attribute. + /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. + \return Value of the attribute, 0 if an attribute with this index does not exist. */ + virtual const char_type* getAttributeValue(int idx) const = 0; + + //! Returns the value of an attribute. + /** \param name: Name of the attribute. + \return Value of the attribute, 0 if an attribute with this name does not exist. */ + virtual const char_type* getAttributeValue(const char_type* name) const = 0; + + //! Returns the value of an attribute in a safe way. + /** Like getAttributeValue(), but does not + return 0 if the attribute does not exist. An empty string ("") is returned then. + \param name: Name of the attribute. + \return Value of the attribute, and "" if an attribute with this name does not exist */ + virtual const char_type* getAttributeValueSafe(const char_type* name) const = 0; + + //! Returns the value of an attribute as integer. + /** \param name Name of the attribute. + \return Value of the attribute as integer, and 0 if an attribute with this name does not exist or + the value could not be interpreted as integer. */ + virtual int getAttributeValueAsInt(const char_type* name) const = 0; + + //! Returns the value of an attribute as integer. + /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. + \return Value of the attribute as integer, and 0 if an attribute with this index does not exist or + the value could not be interpreted as integer. */ + virtual int getAttributeValueAsInt(int idx) const = 0; + + //! Returns the value of an attribute as float. + /** \param name: Name of the attribute. + \return Value of the attribute as float, and 0 if an attribute with this name does not exist or + the value could not be interpreted as float. */ + virtual float getAttributeValueAsFloat(const char_type* name) const = 0; + + //! Returns the value of an attribute as float. + /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. + \return Value of the attribute as float, and 0 if an attribute with this index does not exist or + the value could not be interpreted as float. */ + virtual float getAttributeValueAsFloat(int idx) const = 0; + + //! Returns the name of the current node. + /** Only non null, if the node type is EXN_ELEMENT. + \return Name of the current node or 0 if the node has no name. */ + virtual const char_type* getNodeName() const = 0; + + //! Returns data of the current node. + /** Only non null if the node has some + data and it is of type EXN_TEXT or EXN_UNKNOWN. */ + virtual const char_type* getNodeData() const = 0; + + //! Returns if an element is an empty element, like + virtual bool isEmptyElement() const = 0; + + //! Returns format of the source xml file. + /** It is not necessary to use + this method because the parser will convert the input file format + to the format wanted by the user when creating the parser. This + method is useful to get/display additional informations. */ + virtual ETEXT_FORMAT getSourceFormat() const = 0; + + //! Returns format of the strings returned by the parser. + /** This will be UTF8 for example when you created a parser with + IrrXMLReaderUTF8() and UTF32 when it has been created using + IrrXMLReaderUTF32. It should not be necessary to call this + method and only exists for informational purposes. */ + virtual ETEXT_FORMAT getParserFormat() const = 0; + }; + + + //! defines the utf-16 type. + /** Not using wchar_t for this because + wchar_t has 16 bit on windows and 32 bit on other operating systems. */ + typedef unsigned short char16; + + //! defines the utf-32 type. + /** Not using wchar_t for this because + wchar_t has 16 bit on windows and 32 bit on other operating systems. */ + typedef unsigned long char32; + + //! A UTF-8 or ASCII character xml parser. + /** This means that all character data will be returned in 8 bit ASCII or UTF-8 by this parser. + The file to read can be in any format, it will be converted to UTF-8 if it is not + in this format. + Create an instance of this with createIrrXMLReader(); + See IIrrXMLReader for description on how to use it. */ + typedef IIrrXMLReader IrrXMLReader; + + //! A UTF-16 xml parser. + /** This means that all character data will be returned in UTF-16 by this parser. + The file to read can be in any format, it will be converted to UTF-16 if it is not + in this format. + Create an instance of this with createIrrXMLReaderUTF16(); + See IIrrXMLReader for description on how to use it. */ + typedef IIrrXMLReader IrrXMLReaderUTF16; + + //! A UTF-32 xml parser. + /** This means that all character data will be returned in UTF-32 by this parser. + The file to read can be in any format, it will be converted to UTF-32 if it is not + in this format. + Create an instance of this with createIrrXMLReaderUTF32(); + See IIrrXMLReader for description on how to use it. */ + typedef IIrrXMLReader IrrXMLReaderUTF32; + + + //! Creates an instance of an UFT-8 or ASCII character xml parser. + /** This means that all character data will be returned in 8 bit ASCII or UTF-8. + The file to read can be in any format, it will be converted to UTF-8 if it is not in this format. + If you are using the Irrlicht Engine, it is better not to use this function but + IFileSystem::createXMLReaderUTF8() instead. + \param filename: Name of file to be opened. + \return Returns a pointer to the created xml parser. This pointer should be + deleted using 'delete' after no longer needed. Returns 0 if an error occured + and the file could not be opened. */ + IrrXMLReader* createIrrXMLReader(const char* filename); + + //! Creates an instance of an UFT-8 or ASCII character xml parser. + /** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can + be in any format, it will be converted to UTF-8 if it is not in this format. + If you are using the Irrlicht Engine, it is better not to use this function but + IFileSystem::createXMLReaderUTF8() instead. + \param file: Pointer to opened file, must have been opened in binary mode, e.g. + using fopen("foo.bar", "wb"); The file will not be closed after it has been read. + \return Returns a pointer to the created xml parser. This pointer should be + deleted using 'delete' after no longer needed. Returns 0 if an error occured + and the file could not be opened. */ + IrrXMLReader* createIrrXMLReader(FILE* file); + + //! Creates an instance of an UFT-8 or ASCII character xml parser. + /** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can + be in any format, it will be converted to UTF-8 if it is not in this format. + If you are using the Irrlicht Engine, it is better not to use this function but + IFileSystem::createXMLReaderUTF8() instead. + \param callback: Callback for file read abstraction. Implement your own + callback to make the xml parser read in other things than just files. See + IFileReadCallBack for more information about this. + \return Returns a pointer to the created xml parser. This pointer should be + deleted using 'delete' after no longer needed. Returns 0 if an error occured + and the file could not be opened. */ + IrrXMLReader* createIrrXMLReader(IFileReadCallBack* callback); + + //! Creates an instance of an UFT-16 xml parser. + /** This means that + all character data will be returned in UTF-16. The file to read can + be in any format, it will be converted to UTF-16 if it is not in this format. + If you are using the Irrlicht Engine, it is better not to use this function but + IFileSystem::createXMLReader() instead. + \param filename: Name of file to be opened. + \return Returns a pointer to the created xml parser. This pointer should be + deleted using 'delete' after no longer needed. Returns 0 if an error occured + and the file could not be opened. */ + IrrXMLReaderUTF16* createIrrXMLReaderUTF16(const char* filename); + + //! Creates an instance of an UFT-16 xml parser. + /** This means that all character data will be returned in UTF-16. The file to read can + be in any format, it will be converted to UTF-16 if it is not in this format. + If you are using the Irrlicht Engine, it is better not to use this function but + IFileSystem::createXMLReader() instead. + \param file: Pointer to opened file, must have been opened in binary mode, e.g. + using fopen("foo.bar", "wb"); The file will not be closed after it has been read. + \return Returns a pointer to the created xml parser. This pointer should be + deleted using 'delete' after no longer needed. Returns 0 if an error occured + and the file could not be opened. */ + IrrXMLReaderUTF16* createIrrXMLReaderUTF16(FILE* file); + + //! Creates an instance of an UFT-16 xml parser. + /** This means that all character data will be returned in UTF-16. The file to read can + be in any format, it will be converted to UTF-16 if it is not in this format. + If you are using the Irrlicht Engine, it is better not to use this function but + IFileSystem::createXMLReader() instead. + \param callback: Callback for file read abstraction. Implement your own + callback to make the xml parser read in other things than just files. See + IFileReadCallBack for more information about this. + \return Returns a pointer to the created xml parser. This pointer should be + deleted using 'delete' after no longer needed. Returns 0 if an error occured + and the file could not be opened. */ + IrrXMLReaderUTF16* createIrrXMLReaderUTF16(IFileReadCallBack* callback); + + + //! Creates an instance of an UFT-32 xml parser. + /** This means that all character data will be returned in UTF-32. The file to read can + be in any format, it will be converted to UTF-32 if it is not in this format. + If you are using the Irrlicht Engine, it is better not to use this function but + IFileSystem::createXMLReader() instead. + \param filename: Name of file to be opened. + \return Returns a pointer to the created xml parser. This pointer should be + deleted using 'delete' after no longer needed. Returns 0 if an error occured + and the file could not be opened. */ + IrrXMLReaderUTF32* createIrrXMLReaderUTF32(const char* filename); + + //! Creates an instance of an UFT-32 xml parser. + /** This means that all character data will be returned in UTF-32. The file to read can + be in any format, it will be converted to UTF-32 if it is not in this format. + if you are using the Irrlicht Engine, it is better not to use this function but + IFileSystem::createXMLReader() instead. + \param file: Pointer to opened file, must have been opened in binary mode, e.g. + using fopen("foo.bar", "wb"); The file will not be closed after it has been read. + \return Returns a pointer to the created xml parser. This pointer should be + deleted using 'delete' after no longer needed. Returns 0 if an error occured + and the file could not be opened. */ + IrrXMLReaderUTF32* createIrrXMLReaderUTF32(FILE* file); + + //! Creates an instance of an UFT-32 xml parser. + /** This means that + all character data will be returned in UTF-32. The file to read can + be in any format, it will be converted to UTF-32 if it is not in this format. + If you are using the Irrlicht Engine, it is better not to use this function but + IFileSystem::createXMLReader() instead. + \param callback: Callback for file read abstraction. Implement your own + callback to make the xml parser read in other things than just files. See + IFileReadCallBack for more information about this. + \return Returns a pointer to the created xml parser. This pointer should be + deleted using 'delete' after no longer needed. Returns 0 if an error occured + and the file could not be opened. */ + IrrXMLReaderUTF32* createIrrXMLReaderUTF32(IFileReadCallBack* callback); + + + /*! \file irrxml.h + \brief Header file of the irrXML, the Irrlicht XML parser. + + This file includes everything needed for using irrXML, + the XML parser of the Irrlicht Engine. To use irrXML, + you only need to include this file in your project: + + \code + #include + \endcode + + It is also common to use the two namespaces in which irrXML is included, + directly after #including irrXML.h: + + \code + #include + using namespace irr; + using namespace io; + \endcode + */ + +} // end namespace io +} // end namespace irr + +#endif // __IRR_XML_H_INCLUDED__ + diff --git a/src/dep/include/irrlicht/irrlicht.h b/src/dep/include/irrlicht/irrlicht.h index f81923e..f46e51c 100644 --- a/src/dep/include/irrlicht/irrlicht.h +++ b/src/dep/include/irrlicht/irrlicht.h @@ -1,333 +1,333 @@ -/* irrlicht.h -- interface of the 'Irrlicht Engine' - - Copyright (C) 2002-2007 Nikolaus Gebhardt - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Please note that the Irrlicht Engine is based in part on the work of the - Independent JPEG Group, the zlib and the libPng. This means that if you use - the Irrlicht Engine in your product, you must acknowledge somewhere in your - documentation that you've used the IJG code. It would also be nice to mention - that you use the Irrlicht Engine, the zlib and libPng. See the README files - in the jpeglib, the zlib and libPng for further informations. -*/ - -#ifndef __IRRLICHT_H_INCLUDED__ -#define __IRRLICHT_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#include "aabbox3d.h" -#include "irrArray.h" -#include "irrMap.h" -#include "SColor.h" -#include "SLight.h" -#include "dimension2d.h" -#include "EDriverTypes.h" -#include "heapsort.h" -#include "IAttributes.h" -#include "IAttributeExchangingObject.h" -#include "IAnimatedMesh.h" -#include "IAnimatedMeshMD2.h" -#include "IAnimatedMeshMD3.h" -#include "IAnimatedMeshMS3D.h" -#include "IAnimatedMeshMS3D.h" -#include "IQ3LevelMesh.h" -#include "IAnimatedMeshX.h" -#include "IAnimatedMeshB3d.h" -#include "IAnimatedMeshSceneNode.h" -#include "ICameraSceneNode.h" -#include "IDummyTransformationSceneNode.h" -#include "IEventReceiver.h" -#include "IFileList.h" -#include "IFileSystem.h" -#include "IGUIButton.h" -#include "IGUICheckBox.h" -#include "IGUIContextMenu.h" -#include "IGUIComboBox.h" -#include "IGUIElement.h" -#include "IGUIEditBox.h" -#include "IGUIEnvironment.h" -#include "IGUIFileOpenDialog.h" -#include "IGUIColorSelectDialog.h" -#include "IGUIFont.h" -#include "IGUIFontBitmap.h" -#include "IGUIImage.h" -#include "IGUIInOutFader.h" -#include "IGUIListBox.h" -#include "IGUIMeshViewer.h" -#include "IGUIScrollBar.h" -#include "IGUISkin.h" -#include "IGUIStaticText.h" -#include "IGUITabControl.h" -#include "IGUIWindow.h" -#include "IGUIToolbar.h" -#include "IImage.h" -#include "ILightSceneNode.h" -#include "ILogger.h" -#include "IMesh.h" -#include "IMeshBuffer.h" -#include "IMeshCache.h" -#include "IMeshSceneNode.h" -#include "IMeshManipulator.h" -#include "IMetaTriangleSelector.h" -#include "IReadFile.h" -#include "IrrlichtDevice.h" -#include "irrMath.h" -#include "irrString.h" -#include "ISceneManager.h" -#include "ISceneNode.h" -#include "IAttributes.h" -#include "ISceneUserDataSerializer.h" -#include "ITriangleSelector.h" -#include "ISceneNodeAnimator.h" -#include "ISceneCollisionManager.h" -#include "IMaterialRenderer.h" -#include "IMaterialRendererServices.h" -#include "ISceneNodeFactory.h" -#include "ISceneNodeAnimatorFactory.h" -#include "ISceneNodeAnimatorCollisionResponse.h" -#include "IShaderConstantSetCallBack.h" -#include "IParticleSystemSceneNode.h" -#include "ITerrainSceneNode.h" -#include "ITextSceneNode.h" -#include "IParticleEmitter.h" -#include "IParticleAffector.h" -#include "IBillboardSceneNode.h" -#include "ITexture.h" -#include "IUnknown.h" -#include "IVideoDriver.h" -#include "IVideoModeList.h" -#include "IWriteFile.h" -#include "IXMLReader.h" -#include "IXMLWriter.h" -#include "Keycodes.h" -#include "line2d.h" -#include "line3d.h" -#include "irrList.h" -#include "matrix4.h" -#include "plane3d.h" -#include "vector2d.h" -#include "vector3d.h" -#include "triangle3d.h" -#include "position2d.h" -#include "quaternion.h" -#include "rect.h" -#include "S3DVertex.h" -#include "SAnimatedMesh.h" -#include "SKeyMap.h" -#include "SMaterial.h" -#include "SMesh.h" -#include "SMeshBuffer.h" -#include "SMeshBufferLightMap.h" -#include "SMeshBufferTangents.h" -#include "SViewFrustum.h" -#include "irrTypes.h" -#include "coreutil.h" - -/*! \mainpage Irrlicht Engine 1.3 API documentation - * - *
- * - * \section intro Introduction - * - * Welcome to the Irrlicht Engine API documentation. - * Here you'll find any information you'll need to develop applications with - * the Irrlicht Engine. If you are looking for a tutorial on how to start, you'll - * find some on the homepage of the Irrlicht Engine at - * irrlicht.sourceforge.net - * or inside the SDK in the directory \examples. - * - * The Irrlicht Engine is intended to be an easy-to-use 3d engine, so - * this documentation is an important part of it. If you have any questions or - * suggestions, just send a email to the author of the engine, Nikolaus Gebhardt - * (niko (at) irrlicht3d.org). - * - * - * \section links Links - * - * Namespaces: A very good place to start reading - * the documentation.
- * Class list: List of all classes with descriptions.
- * Class members: Good place to find forgotten features.
- * - * \section irrexample Short example - * - * A simple application, starting up the engine, loading a Quake 2 animated - * model file and the corresponding texture, animating and displaying it - * in front of a blue background and placing a user controlable 3d camera - * would look like the following code. I think this example shows the usage - * of the engine quite well: - * - * \code - * #include - * using namespace irr; - * - * int main() - * { - * // start up the engine - * IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D8, - * core::dimension2d(640,480)); - * - * video::IVideoDriver* driver = device->getVideoDriver(); - * scene::ISceneManager* scenemgr = device->getSceneManager(); - * - * device->setWindowCaption(L"Hello World!"); - * - * // load and show quake2 .md2 model - * scene::ISceneNode* node = scenemgr->addAnimatedMeshSceneNode( - * scenemgr->getMesh("quake2model.md2")); - * - * // if everything worked, add a texture and disable lighting - * if (node) - * { - * node->setMaterialTexture(0, driver->getTexture("texture.bmp")); - * node->setMaterialFlag(video::EMF_LIGHTING, false); - * } - * - * // add a first person shooter style user controlled camera - * scenemgr->addCameraSceneNodeFPS(); - * - * // draw everything - * while(device->run() && driver) - * { - * driver->beginScene(true, true, video::SColor(255,0,0,255)); - * scenemgr->drawAll(); - * driver->endScene(); - * } - * - * // delete device - * device->drop(); - * return 0; - * } - * \endcode - * - * Irrlicht can load a lot of file formats automaticly, see irr::scene::ISceneManager::getMesh() - * for a detailed list. So if you would like to replace the simple blue screen background by - * a cool Quake 3 Map, optimized by an octtree, just insert this code - * somewhere before the while loop: - * - * \code - * // add .pk3 archive to the file system - * device->getFileSystem()->addZipFileArchive("quake3map.pk3"); - * - * // load .bsp file and show it using an octtree - * scenemgr->addOctTreeSceneNode( - * scenemgr->getMesh("quake3map.bsp")); - * \endcode - * - * As you can see, the engine uses namespaces. Everything in the engine is - * placed into the namespace 'irr', but there are also 5 sub namespaces. - * You can find a list of all namespaces with descriptions at the - * namespaces page. - * This is also a good place to start reading the documentation. If you - * don't want to write the namespace names all the time, just use all namespaces like - * this: - * \code - * using namespace core; - * using namespace scene; - * using namespace video; - * using namespace io; - * using namespace gui; - * \endcode - * - * There is a lot more the engine can do, but I hope this gave a short - * overview over the basic features of the engine. For more examples, please take - * a look into the examples directory of the SDK. - */ - -#include "SIrrCreationParameters.h" - -//! Everything in the Irrlicht Engine can be found in this namespace. -namespace irr -{ - //! Creates an Irrlicht device. The Irrlicht device is the root object for using the engine. - /** If you need more parameters to be passed to the creation of the Irrlicht Engine device, - use the createDeviceEx() function. - \param deviceType: Type of the device. This can currently be video::EDT_NULL, - video::EDT_SOFTWARE, video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D8, video::EDT_DIRECT3D9 and video::EDT_OPENGL. - \param windowSize: Size of the window or the video mode in fullscreen mode. - \param bits: Bits per pixel in fullscreen mode. Ignored if windowed mode. - \param fullscreen: Should be set to true if the device should run in fullscreen. Otherwise - the device runs in windowed mode. - \param stencilbuffer: Specifies if the stencil buffer should be enabled. Set this to true, - if you want the engine be able to draw stencil buffer shadows. Note that not all - devices are able to use the stencil buffer. If they don't no shadows will be drawn. - \param vsync: Specifies vertical syncronisation: If set to true, the driver will wait - for the vertical retrace period, otherwise not. - \param receiver: A user created event receiver. - \param sdk_version_do_not_use: Don't use or change this parameter. Always set it to - IRRLICHT_SDK_VERSION, which is done by default. This is needed for sdk version checks. - \return Returns pointer to the created IrrlichtDevice or null if the - device could not be created. - */ - IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice( - video::E_DRIVER_TYPE deviceType = video::EDT_SOFTWARE, - const core::dimension2d& windowSize = core::dimension2d(640,480), - u32 bits = 16, - bool fullscreen = false, - bool stencilbuffer=false, - bool vsync=false, - IEventReceiver* receiver = 0, - const c8* sdk_version_do_not_use = IRRLICHT_SDK_VERSION); - - //! Creates an Irrlicht device with the option to specify advanced parameters. - /** Usually you should used createDevice() for creating an Irrlicht Engine device. - Use this function only if you wish to specify advanced parameters like a window - handle in which the device should be created. - \param parameters: Structure containing advanced parameters for the creation of the device. - See irr::SIrrlichtCreationParameters for details. - \return Returns pointer to the created IrrlichtDevice or null if the - device could not be created. */ - IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx( - const SIrrlichtCreationParameters& parameters); - - - // THE FOLLOWING IS AN EMPTY LIST OF ALL SUB NAMESPACES - // EXISTING ONLY FOR THE DOCUMENTATION SOFTWARE DOXYGEN. - - //! In this namespace can be found basic classes like vectors, planes, arrays, lists and so on. - namespace core - { - } - - //! The gui namespace contains useful classes for easy creation of a graphical user interface. - namespace gui - { - } - - //! This namespace provides interfaces for input/output: Reading and writing files, accessing zip archives, xml files, ... - namespace io - { - } - - //! All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees and billboards, ... - namespace scene - { - } - - //! The video namespace contains classes for accessing the video driver. All 2d and 3d rendering is done here. - namespace video - { - } -} - -/*! \file irrlicht.h - \brief Main header file of the irrlicht, the only file needed to include. -*/ - -#endif - +/* irrlicht.h -- interface of the 'Irrlicht Engine' + + Copyright (C) 2002-2007 Nikolaus Gebhardt + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Please note that the Irrlicht Engine is based in part on the work of the + Independent JPEG Group, the zlib and the libPng. This means that if you use + the Irrlicht Engine in your product, you must acknowledge somewhere in your + documentation that you've used the IJG code. It would also be nice to mention + that you use the Irrlicht Engine, the zlib and libPng. See the README files + in the jpeglib, the zlib and libPng for further informations. +*/ + +#ifndef __IRRLICHT_H_INCLUDED__ +#define __IRRLICHT_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#include "aabbox3d.h" +#include "irrArray.h" +#include "irrMap.h" +#include "SColor.h" +#include "SLight.h" +#include "dimension2d.h" +#include "EDriverTypes.h" +#include "heapsort.h" +#include "IAttributes.h" +#include "IAttributeExchangingObject.h" +#include "IAnimatedMesh.h" +#include "IAnimatedMeshMD2.h" +#include "IAnimatedMeshMD3.h" +#include "IAnimatedMeshMS3D.h" +#include "IAnimatedMeshMS3D.h" +#include "IQ3LevelMesh.h" +#include "IAnimatedMeshX.h" +#include "IAnimatedMeshB3d.h" +#include "IAnimatedMeshSceneNode.h" +#include "ICameraSceneNode.h" +#include "IDummyTransformationSceneNode.h" +#include "IEventReceiver.h" +#include "IFileList.h" +#include "IFileSystem.h" +#include "IGUIButton.h" +#include "IGUICheckBox.h" +#include "IGUIContextMenu.h" +#include "IGUIComboBox.h" +#include "IGUIElement.h" +#include "IGUIEditBox.h" +#include "IGUIEnvironment.h" +#include "IGUIFileOpenDialog.h" +#include "IGUIColorSelectDialog.h" +#include "IGUIFont.h" +#include "IGUIFontBitmap.h" +#include "IGUIImage.h" +#include "IGUIInOutFader.h" +#include "IGUIListBox.h" +#include "IGUIMeshViewer.h" +#include "IGUIScrollBar.h" +#include "IGUISkin.h" +#include "IGUIStaticText.h" +#include "IGUITabControl.h" +#include "IGUIWindow.h" +#include "IGUIToolbar.h" +#include "IImage.h" +#include "ILightSceneNode.h" +#include "ILogger.h" +#include "IMesh.h" +#include "IMeshBuffer.h" +#include "IMeshCache.h" +#include "IMeshSceneNode.h" +#include "IMeshManipulator.h" +#include "IMetaTriangleSelector.h" +#include "IReadFile.h" +#include "IrrlichtDevice.h" +#include "irrMath.h" +#include "irrString.h" +#include "ISceneManager.h" +#include "ISceneNode.h" +#include "IAttributes.h" +#include "ISceneUserDataSerializer.h" +#include "ITriangleSelector.h" +#include "ISceneNodeAnimator.h" +#include "ISceneCollisionManager.h" +#include "IMaterialRenderer.h" +#include "IMaterialRendererServices.h" +#include "ISceneNodeFactory.h" +#include "ISceneNodeAnimatorFactory.h" +#include "ISceneNodeAnimatorCollisionResponse.h" +#include "IShaderConstantSetCallBack.h" +#include "IParticleSystemSceneNode.h" +#include "ITerrainSceneNode.h" +#include "ITextSceneNode.h" +#include "IParticleEmitter.h" +#include "IParticleAffector.h" +#include "IBillboardSceneNode.h" +#include "ITexture.h" +#include "IUnknown.h" +#include "IVideoDriver.h" +#include "IVideoModeList.h" +#include "IWriteFile.h" +#include "IXMLReader.h" +#include "IXMLWriter.h" +#include "Keycodes.h" +#include "line2d.h" +#include "line3d.h" +#include "irrList.h" +#include "matrix4.h" +#include "plane3d.h" +#include "vector2d.h" +#include "vector3d.h" +#include "triangle3d.h" +#include "position2d.h" +#include "quaternion.h" +#include "rect.h" +#include "S3DVertex.h" +#include "SAnimatedMesh.h" +#include "SKeyMap.h" +#include "SMaterial.h" +#include "SMesh.h" +#include "SMeshBuffer.h" +#include "SMeshBufferLightMap.h" +#include "SMeshBufferTangents.h" +#include "SViewFrustum.h" +#include "irrTypes.h" +#include "coreutil.h" + +/*! \mainpage Irrlicht Engine 1.3 API documentation + * + *
+ * + * \section intro Introduction + * + * Welcome to the Irrlicht Engine API documentation. + * Here you'll find any information you'll need to develop applications with + * the Irrlicht Engine. If you are looking for a tutorial on how to start, you'll + * find some on the homepage of the Irrlicht Engine at + * irrlicht.sourceforge.net + * or inside the SDK in the directory \examples. + * + * The Irrlicht Engine is intended to be an easy-to-use 3d engine, so + * this documentation is an important part of it. If you have any questions or + * suggestions, just send a email to the author of the engine, Nikolaus Gebhardt + * (niko (at) irrlicht3d.org). + * + * + * \section links Links + * + * Namespaces: A very good place to start reading + * the documentation.
+ * Class list: List of all classes with descriptions.
+ * Class members: Good place to find forgotten features.
+ * + * \section irrexample Short example + * + * A simple application, starting up the engine, loading a Quake 2 animated + * model file and the corresponding texture, animating and displaying it + * in front of a blue background and placing a user controlable 3d camera + * would look like the following code. I think this example shows the usage + * of the engine quite well: + * + * \code + * #include + * using namespace irr; + * + * int main() + * { + * // start up the engine + * IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D8, + * core::dimension2d(640,480)); + * + * video::IVideoDriver* driver = device->getVideoDriver(); + * scene::ISceneManager* scenemgr = device->getSceneManager(); + * + * device->setWindowCaption(L"Hello World!"); + * + * // load and show quake2 .md2 model + * scene::ISceneNode* node = scenemgr->addAnimatedMeshSceneNode( + * scenemgr->getMesh("quake2model.md2")); + * + * // if everything worked, add a texture and disable lighting + * if (node) + * { + * node->setMaterialTexture(0, driver->getTexture("texture.bmp")); + * node->setMaterialFlag(video::EMF_LIGHTING, false); + * } + * + * // add a first person shooter style user controlled camera + * scenemgr->addCameraSceneNodeFPS(); + * + * // draw everything + * while(device->run() && driver) + * { + * driver->beginScene(true, true, video::SColor(255,0,0,255)); + * scenemgr->drawAll(); + * driver->endScene(); + * } + * + * // delete device + * device->drop(); + * return 0; + * } + * \endcode + * + * Irrlicht can load a lot of file formats automaticly, see irr::scene::ISceneManager::getMesh() + * for a detailed list. So if you would like to replace the simple blue screen background by + * a cool Quake 3 Map, optimized by an octtree, just insert this code + * somewhere before the while loop: + * + * \code + * // add .pk3 archive to the file system + * device->getFileSystem()->addZipFileArchive("quake3map.pk3"); + * + * // load .bsp file and show it using an octtree + * scenemgr->addOctTreeSceneNode( + * scenemgr->getMesh("quake3map.bsp")); + * \endcode + * + * As you can see, the engine uses namespaces. Everything in the engine is + * placed into the namespace 'irr', but there are also 5 sub namespaces. + * You can find a list of all namespaces with descriptions at the + * namespaces page. + * This is also a good place to start reading the documentation. If you + * don't want to write the namespace names all the time, just use all namespaces like + * this: + * \code + * using namespace core; + * using namespace scene; + * using namespace video; + * using namespace io; + * using namespace gui; + * \endcode + * + * There is a lot more the engine can do, but I hope this gave a short + * overview over the basic features of the engine. For more examples, please take + * a look into the examples directory of the SDK. + */ + +#include "SIrrCreationParameters.h" + +//! Everything in the Irrlicht Engine can be found in this namespace. +namespace irr +{ + //! Creates an Irrlicht device. The Irrlicht device is the root object for using the engine. + /** If you need more parameters to be passed to the creation of the Irrlicht Engine device, + use the createDeviceEx() function. + \param deviceType: Type of the device. This can currently be video::EDT_NULL, + video::EDT_SOFTWARE, video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D8, video::EDT_DIRECT3D9 and video::EDT_OPENGL. + \param windowSize: Size of the window or the video mode in fullscreen mode. + \param bits: Bits per pixel in fullscreen mode. Ignored if windowed mode. + \param fullscreen: Should be set to true if the device should run in fullscreen. Otherwise + the device runs in windowed mode. + \param stencilbuffer: Specifies if the stencil buffer should be enabled. Set this to true, + if you want the engine be able to draw stencil buffer shadows. Note that not all + devices are able to use the stencil buffer. If they don't no shadows will be drawn. + \param vsync: Specifies vertical syncronisation: If set to true, the driver will wait + for the vertical retrace period, otherwise not. + \param receiver: A user created event receiver. + \param sdk_version_do_not_use: Don't use or change this parameter. Always set it to + IRRLICHT_SDK_VERSION, which is done by default. This is needed for sdk version checks. + \return Returns pointer to the created IrrlichtDevice or null if the + device could not be created. + */ + IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice( + video::E_DRIVER_TYPE deviceType = video::EDT_SOFTWARE, + const core::dimension2d& windowSize = core::dimension2d(640,480), + u32 bits = 16, + bool fullscreen = false, + bool stencilbuffer=false, + bool vsync=false, + IEventReceiver* receiver = 0, + const c8* sdk_version_do_not_use = IRRLICHT_SDK_VERSION); + + //! Creates an Irrlicht device with the option to specify advanced parameters. + /** Usually you should used createDevice() for creating an Irrlicht Engine device. + Use this function only if you wish to specify advanced parameters like a window + handle in which the device should be created. + \param parameters: Structure containing advanced parameters for the creation of the device. + See irr::SIrrlichtCreationParameters for details. + \return Returns pointer to the created IrrlichtDevice or null if the + device could not be created. */ + IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx( + const SIrrlichtCreationParameters& parameters); + + + // THE FOLLOWING IS AN EMPTY LIST OF ALL SUB NAMESPACES + // EXISTING ONLY FOR THE DOCUMENTATION SOFTWARE DOXYGEN. + + //! In this namespace can be found basic classes like vectors, planes, arrays, lists and so on. + namespace core + { + } + + //! The gui namespace contains useful classes for easy creation of a graphical user interface. + namespace gui + { + } + + //! This namespace provides interfaces for input/output: Reading and writing files, accessing zip archives, xml files, ... + namespace io + { + } + + //! All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees and billboards, ... + namespace scene + { + } + + //! The video namespace contains classes for accessing the video driver. All 2d and 3d rendering is done here. + namespace video + { + } +} + +/*! \file irrlicht.h + \brief Main header file of the irrlicht, the only file needed to include. +*/ + +#endif + diff --git a/src/dep/include/irrlicht/line2d.h b/src/dep/include/irrlicht/line2d.h index 38e11b6..ba39b40 100644 --- a/src/dep/include/irrlicht/line2d.h +++ b/src/dep/include/irrlicht/line2d.h @@ -1,171 +1,171 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_LINE_2D_H_INCLUDED__ -#define __IRR_LINE_2D_H_INCLUDED__ - -#include "irrTypes.h" -#include "vector2d.h" - -namespace irr -{ -namespace core -{ - -//! 2D line between two points with intersection methods. -template -class line2d -{ - public: - - line2d() : start(0,0), end(1,1) {}; - line2d(T xa, T ya, T xb, T yb) : start(xa, ya), end(xb, yb) {}; - line2d(const vector2d& start, const vector2d& end) : start(start), end(end) {}; - line2d(const line2d& other) : start(other.start), end(other.end) {}; - - // operators - - line2d operator+(const vector2d& point) const { return line2d(start + point, end + point); }; - line2d& operator+=(const vector2d& point) { start += point; end += point; return *this; }; - - line2d operator-(const vector2d& point) const { return line2d(start - point, end - point); }; - line2d& operator-=(const vector2d& point) { start -= point; end -= point; return *this; }; - - bool operator==(const line2d& other) const { return (start==other.start && end==other.end) || (end==other.start && start==other.end);}; - bool operator!=(const line2d& other) const { return !(start==other.start && end==other.end) || (end==other.start && start==other.end);}; - - // functions - - void setLine(const T& xa, const T& ya, const T& xb, const T& yb){start.set(xa, ya); end.set(xb, yb);} - void setLine(const vector2d& nstart, const vector2d& nend){start.set(nstart); end.set(nend);} - void setLine(const line2d& line){start.set(line.start); end.set(line.end);} - - //! Returns length of line - //! \return Returns length of the line. - f64 getLength() const { return start.getDistanceFrom(end); }; - - //! Returns squared length of the line - //! \return Returns squared length of line. - T getLengthSQ() const { return start.getDistanceFromSQ(end); }; - - //! Returns middle of the line - vector2d getMiddle() const - { - return (start + end) * (T)0.5; - } - - //! Returns the vector of the line. - //! \return Returns the vector of the line. - vector2d getVector() const { return vector2d(start.X - end.X, start.Y - end.Y); }; - - //! Tests if this line intersects with another line. - //! \param l: Other line to test intersection with. - //! \param out: If there is an intersection, the location of the intersection will - //! be stored in this vector. - //! \return Returns true if there is an intersection, false if not. - bool intersectWith(const line2d& l, vector2d& out) const - { - bool found=false; - - f32 a1,a2,b1,b2; - - // calculate slopes, deal with infinity - if (end.X-start.X == 0) - b1 = (f32)1e+10; - else - b1 = (end.Y-start.Y)/(end.X-start.X); - if (l.end.X-l.start.X == 0) - b2 = (f32)1e+10; - else - b2 = (l.end.Y-l.start.Y)/(l.end.X-l.start.X); - - // calculate position - a1 = start.Y - b1 * start.X; - a2 = l.start.Y - b2 * l.start.X; - out.X = - (a1-a2)/(b1-b2); - out.Y = a1 + b1*out.X; - - // did the lines cross? - if ( (start.X-out.X) *(out.X-end.X) >= -ROUNDING_ERROR_32 && - (l.start.X-out.X)*(out.X-l.end.X)>= -ROUNDING_ERROR_32 && - (start.Y-out.Y) *(out.Y-end.Y) >= -ROUNDING_ERROR_32 && - (l.start.Y-out.Y)*(out.Y-l.end.Y)>= -ROUNDING_ERROR_32 ) - { - found = true; - } - return found; - } - - //! Returns unit vector of the line. - //! \return Returns unit vector of this line. - vector2d getUnitVector() - { - T len = (T)(1.0 / getLength()); - return vector2d((end.X - start.X) * len, (end.Y - start.Y) * len); - } - - f64 getAngleWith(const line2d& l) - { - vector2d vect = getVector(); - vector2d vect2 = l.getVector(); - return vect.getAngleWith(vect2); - } - - //! Tells us if the given point lies to the left, - //! right, or on the direction of the line - //! \return Returns 0 if the point is on the line - //! <0 if to the left, or >0 if to the right. - T getPointOrientation(const vector2d& point) - { - return ( (end.X - start.X) * (point.Y - start.Y) - - (point.X - start.X) * (end.Y - start.Y) ); - } - - //! Returns if the given point is a member of the line - //! \return Returns true if - bool isPointOnLine(const vector2d& point) - { - T d = getPointOrientation(point); - return (d == 0 && point.isBetweenPoints(start, end)); - } - - //! Returns if the given point is between start and end of the - //! line. Assumes that the point is already somewhere on the line. - bool isPointBetweenStartAndEnd(const vector2d& point) const - { - return point.isBetweenPoints(start, end); - } - - //! Returns the closest point on this line to a point - vector2d getClosestPoint(const vector2d& point) const - { - vector2d c = point - start; - vector2d v = end - start; - T d = (T)v.getLength(); - v /= d; - T t = v.dotProduct(c); - - if (t < (T)0.0) return start; - if (t > d) return end; - - v *= t; - return start + v; - } - - // member variables - - vector2d start; - vector2d end; -}; - - //! Typedef for a f32 line. - typedef line2d line2df; - //! Typedef for an integer line. - typedef line2d line2di; - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_LINE_2D_H_INCLUDED__ +#define __IRR_LINE_2D_H_INCLUDED__ + +#include "irrTypes.h" +#include "vector2d.h" + +namespace irr +{ +namespace core +{ + +//! 2D line between two points with intersection methods. +template +class line2d +{ + public: + + line2d() : start(0,0), end(1,1) {}; + line2d(T xa, T ya, T xb, T yb) : start(xa, ya), end(xb, yb) {}; + line2d(const vector2d& start, const vector2d& end) : start(start), end(end) {}; + line2d(const line2d& other) : start(other.start), end(other.end) {}; + + // operators + + line2d operator+(const vector2d& point) const { return line2d(start + point, end + point); }; + line2d& operator+=(const vector2d& point) { start += point; end += point; return *this; }; + + line2d operator-(const vector2d& point) const { return line2d(start - point, end - point); }; + line2d& operator-=(const vector2d& point) { start -= point; end -= point; return *this; }; + + bool operator==(const line2d& other) const { return (start==other.start && end==other.end) || (end==other.start && start==other.end);}; + bool operator!=(const line2d& other) const { return !(start==other.start && end==other.end) || (end==other.start && start==other.end);}; + + // functions + + void setLine(const T& xa, const T& ya, const T& xb, const T& yb){start.set(xa, ya); end.set(xb, yb);} + void setLine(const vector2d& nstart, const vector2d& nend){start.set(nstart); end.set(nend);} + void setLine(const line2d& line){start.set(line.start); end.set(line.end);} + + //! Returns length of line + //! \return Returns length of the line. + f64 getLength() const { return start.getDistanceFrom(end); }; + + //! Returns squared length of the line + //! \return Returns squared length of line. + T getLengthSQ() const { return start.getDistanceFromSQ(end); }; + + //! Returns middle of the line + vector2d getMiddle() const + { + return (start + end) * (T)0.5; + } + + //! Returns the vector of the line. + //! \return Returns the vector of the line. + vector2d getVector() const { return vector2d(start.X - end.X, start.Y - end.Y); }; + + //! Tests if this line intersects with another line. + //! \param l: Other line to test intersection with. + //! \param out: If there is an intersection, the location of the intersection will + //! be stored in this vector. + //! \return Returns true if there is an intersection, false if not. + bool intersectWith(const line2d& l, vector2d& out) const + { + bool found=false; + + f32 a1,a2,b1,b2; + + // calculate slopes, deal with infinity + if (end.X-start.X == 0) + b1 = (f32)1e+10; + else + b1 = (end.Y-start.Y)/(end.X-start.X); + if (l.end.X-l.start.X == 0) + b2 = (f32)1e+10; + else + b2 = (l.end.Y-l.start.Y)/(l.end.X-l.start.X); + + // calculate position + a1 = start.Y - b1 * start.X; + a2 = l.start.Y - b2 * l.start.X; + out.X = - (a1-a2)/(b1-b2); + out.Y = a1 + b1*out.X; + + // did the lines cross? + if ( (start.X-out.X) *(out.X-end.X) >= -ROUNDING_ERROR_32 && + (l.start.X-out.X)*(out.X-l.end.X)>= -ROUNDING_ERROR_32 && + (start.Y-out.Y) *(out.Y-end.Y) >= -ROUNDING_ERROR_32 && + (l.start.Y-out.Y)*(out.Y-l.end.Y)>= -ROUNDING_ERROR_32 ) + { + found = true; + } + return found; + } + + //! Returns unit vector of the line. + //! \return Returns unit vector of this line. + vector2d getUnitVector() + { + T len = (T)(1.0 / getLength()); + return vector2d((end.X - start.X) * len, (end.Y - start.Y) * len); + } + + f64 getAngleWith(const line2d& l) + { + vector2d vect = getVector(); + vector2d vect2 = l.getVector(); + return vect.getAngleWith(vect2); + } + + //! Tells us if the given point lies to the left, + //! right, or on the direction of the line + //! \return Returns 0 if the point is on the line + //! <0 if to the left, or >0 if to the right. + T getPointOrientation(const vector2d& point) + { + return ( (end.X - start.X) * (point.Y - start.Y) - + (point.X - start.X) * (end.Y - start.Y) ); + } + + //! Returns if the given point is a member of the line + //! \return Returns true if + bool isPointOnLine(const vector2d& point) + { + T d = getPointOrientation(point); + return (d == 0 && point.isBetweenPoints(start, end)); + } + + //! Returns if the given point is between start and end of the + //! line. Assumes that the point is already somewhere on the line. + bool isPointBetweenStartAndEnd(const vector2d& point) const + { + return point.isBetweenPoints(start, end); + } + + //! Returns the closest point on this line to a point + vector2d getClosestPoint(const vector2d& point) const + { + vector2d c = point - start; + vector2d v = end - start; + T d = (T)v.getLength(); + v /= d; + T t = v.dotProduct(c); + + if (t < (T)0.0) return start; + if (t > d) return end; + + v *= t; + return start + v; + } + + // member variables + + vector2d start; + vector2d end; +}; + + //! Typedef for a f32 line. + typedef line2d line2df; + //! Typedef for an integer line. + typedef line2d line2di; + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/line3d.h b/src/dep/include/irrlicht/line3d.h index 74759a3..514c194 100644 --- a/src/dep/include/irrlicht/line3d.h +++ b/src/dep/include/irrlicht/line3d.h @@ -1,125 +1,125 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_LINE_3D_H_INCLUDED__ -#define __IRR_LINE_3D_H_INCLUDED__ - -#include "irrTypes.h" -#include "vector3d.h" - -namespace irr -{ -namespace core -{ - -//! 3D line between two points with intersection methods. -template -class line3d -{ - public: - - // Constructors - - line3d() : start(0,0,0), end(1,1,1) {}; - line3d(T xa, T ya, T za, T xb, T yb, T zb) : start(xa, ya, za), end(xb, yb, zb) {}; - line3d(const vector3d& start, const vector3d& end) : start(start), end(end) {}; - line3d(const line3d& other) : start(other.start), end(other.end) {}; - - // operators - - line3d operator+(const vector3d& point) const { return line3d(start + point, end + point); }; - line3d& operator+=(const vector3d& point) { start += point; end += point; return *this; }; - - line3d operator-(const vector3d& point) const { return line3d(start - point, end - point); }; - line3d& operator-=(const vector3d& point) { start -= point; end -= point; return *this; }; - - bool operator==(const line3d& other) const { return (start==other.start && end==other.end) || (end==other.start && start==other.end);}; - bool operator!=(const line3d& other) const { return !(start==other.start && end==other.end) || (end==other.start && start==other.end);}; - - // functions - - void setLine(const T& xa, const T& ya, const T& za, const T& xb, const T& yb, const T& zb){start.set(xa, ya, za); end.set(xb, yb, zb);} - void setLine(const vector3d& nstart, const vector3d& nend){start.set(nstart); end.set(nend);} - void setLine(const line3d& line){start.set(line.start); end.set(line.end);} - - //! Returns length of line - //! \return Returns length of line. - f64 getLength() const { return start.getDistanceFrom(end); }; - - //! Returns sqared length of line - //! \return Returns sqared length of line. - T getLengthSQ() const { return start.getDistanceFromSQ(end); }; - - //! Returns middle of line - vector3d getMiddle() const - { - return (start + end) * (T)0.5; - } - - //! Returns vector of line - vector3d getVector() const - { - return end - start; - } - - //! Returns if the given point is between start and end of the - //! line. Assumes that the point is already somewhere on the line. - bool isPointBetweenStartAndEnd(const vector3d& point) const - { - return point.isBetweenPoints(start, end); - } - - //! Returns the closest point on this line to a point - vector3d getClosestPoint(const vector3d& point) const - { - vector3d c = point - start; - vector3d v = end - start; - T d = (T)v.getLength(); - v /= d; - T t = v.dotProduct(c); - - if (t < (T)0.0) return start; - if (t > d) return end; - - v *= t; - return start + v; - } - - //! Returns if the line intersects with a shpere - //! \param sorigin: Origin of the shpere. - //! \param sradius: Radius if the sphere. - //! \param outdistance: The distance to the first intersection point. - //! \return Returns true if there is an intersection. - //! If there is one, the distance to the first intersection point - //! is stored in outdistance. - bool getIntersectionWithSphere(vector3d sorigin, T sradius, f64& outdistance) const - { - vector3d q = sorigin - start; - f64 c = q.getLength(); - f64 v = q.dotProduct(getVector().normalize()); - f64 d = sradius * sradius - (c*c - v*v); - - if (d < 0.0) - return false; - - outdistance = v - sqrt(d); - return true; - } - - // member variables - - vector3d start; - vector3d end; -}; - - //! Typedef for a f32 line. - typedef line3d line3df; - //! Typedef for an integer line. - typedef line3d line3di; - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_LINE_3D_H_INCLUDED__ +#define __IRR_LINE_3D_H_INCLUDED__ + +#include "irrTypes.h" +#include "vector3d.h" + +namespace irr +{ +namespace core +{ + +//! 3D line between two points with intersection methods. +template +class line3d +{ + public: + + // Constructors + + line3d() : start(0,0,0), end(1,1,1) {}; + line3d(T xa, T ya, T za, T xb, T yb, T zb) : start(xa, ya, za), end(xb, yb, zb) {}; + line3d(const vector3d& start, const vector3d& end) : start(start), end(end) {}; + line3d(const line3d& other) : start(other.start), end(other.end) {}; + + // operators + + line3d operator+(const vector3d& point) const { return line3d(start + point, end + point); }; + line3d& operator+=(const vector3d& point) { start += point; end += point; return *this; }; + + line3d operator-(const vector3d& point) const { return line3d(start - point, end - point); }; + line3d& operator-=(const vector3d& point) { start -= point; end -= point; return *this; }; + + bool operator==(const line3d& other) const { return (start==other.start && end==other.end) || (end==other.start && start==other.end);}; + bool operator!=(const line3d& other) const { return !(start==other.start && end==other.end) || (end==other.start && start==other.end);}; + + // functions + + void setLine(const T& xa, const T& ya, const T& za, const T& xb, const T& yb, const T& zb){start.set(xa, ya, za); end.set(xb, yb, zb);} + void setLine(const vector3d& nstart, const vector3d& nend){start.set(nstart); end.set(nend);} + void setLine(const line3d& line){start.set(line.start); end.set(line.end);} + + //! Returns length of line + //! \return Returns length of line. + f64 getLength() const { return start.getDistanceFrom(end); }; + + //! Returns sqared length of line + //! \return Returns sqared length of line. + T getLengthSQ() const { return start.getDistanceFromSQ(end); }; + + //! Returns middle of line + vector3d getMiddle() const + { + return (start + end) * (T)0.5; + } + + //! Returns vector of line + vector3d getVector() const + { + return end - start; + } + + //! Returns if the given point is between start and end of the + //! line. Assumes that the point is already somewhere on the line. + bool isPointBetweenStartAndEnd(const vector3d& point) const + { + return point.isBetweenPoints(start, end); + } + + //! Returns the closest point on this line to a point + vector3d getClosestPoint(const vector3d& point) const + { + vector3d c = point - start; + vector3d v = end - start; + T d = (T)v.getLength(); + v /= d; + T t = v.dotProduct(c); + + if (t < (T)0.0) return start; + if (t > d) return end; + + v *= t; + return start + v; + } + + //! Returns if the line intersects with a shpere + //! \param sorigin: Origin of the shpere. + //! \param sradius: Radius if the sphere. + //! \param outdistance: The distance to the first intersection point. + //! \return Returns true if there is an intersection. + //! If there is one, the distance to the first intersection point + //! is stored in outdistance. + bool getIntersectionWithSphere(vector3d sorigin, T sradius, f64& outdistance) const + { + vector3d q = sorigin - start; + f64 c = q.getLength(); + f64 v = q.dotProduct(getVector().normalize()); + f64 d = sradius * sradius - (c*c - v*v); + + if (d < 0.0) + return false; + + outdistance = v - sqrt(d); + return true; + } + + // member variables + + vector3d start; + vector3d end; +}; + + //! Typedef for a f32 line. + typedef line3d line3df; + //! Typedef for an integer line. + typedef line3d line3di; + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/matrix4.h b/src/dep/include/irrlicht/matrix4.h index a4a2b60..bb4208c 100644 --- a/src/dep/include/irrlicht/matrix4.h +++ b/src/dep/include/irrlicht/matrix4.h @@ -1,1500 +1,1500 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_MATRIX_H_INCLUDED__ -#define __IRR_MATRIX_H_INCLUDED__ - -#include "irrTypes.h" -#include "vector3d.h" -#include "vector2d.h" -#include "plane3d.h" -#include "aabbox3d.h" -#include "rect.h" -#include "irrString.h" - -namespace irr -{ -namespace core -{ - - //! 4x4 matrix. Mostly used as transformation matrix for 3d calculations. - /* Matrix4 is mainly used by the Irrlicht engine for doing transformations. - The matrix is a D3D style matrix, row major with translations in the 4th row. - */ - class matrix4 - { - public: - - //! Constructor Flags - enum eConstructor - { - EM4CONST_NOTHING = 0, - EM4CONST_COPY, - EM4CONST_IDENTITY, - EM4CONST_TRANSPOSED, - EM4CONST_INVERSE, - EM4CONST_INVERSE_TRANSPOSED - }; - - matrix4( eConstructor constructor = EM4CONST_IDENTITY ); - matrix4( const matrix4& other,eConstructor constructor = EM4CONST_COPY); - - //! Simple operator for directly accessing every element of the matrix. - f32& operator()(const s32 row, const s32 col) { definitelyIdentityMatrix=false; return M[ row * 4 + col ]; } - - //! Simple operator for directly accessing every element of the matrix. - const f32& operator()(const s32 row, const s32 col) const { return M[row * 4 + col]; } - - //! Simple operator for linearly accessing every element of the matrix. - f32& operator[](u32 index) { definitelyIdentityMatrix=false; return M[index]; } - - //! Simple operator for linearly accessing every element of the matrix. - const f32& operator[](u32 index) const { return M[index]; } - - //! Sets this matrix equal to the other matrix. - inline matrix4& operator=(const matrix4 &other); - - //! Sets all elements of this matrix to the value. - inline matrix4& operator=(const f32 scalar); - - //! Returns pointer to internal array - const f32* pointer() const { return M; } - f32* pointer() { definitelyIdentityMatrix=false; return M; } - - //! Returns true if other matrix is equal to this matrix. - bool operator==(const matrix4 &other) const; - - //! Returns true if other matrix is not equal to this matrix. - bool operator!=(const matrix4 &other) const; - - //! Add another matrix. - matrix4 operator+(const matrix4& other) const; - - //! Add another matrix. - matrix4& operator+=(const matrix4& other); - - //! Subtract another matrix. - matrix4 operator-(const matrix4& other) const; - - //! Subtract another matrix. - matrix4& operator-=(const matrix4& other); - - //! set this matrix to the product of two matrices - inline void setbyproduct(const matrix4& other_a,const matrix4& other_b ); - - //! set this matrix to the product of two matrices, no logical optimation - //! use it if you know you never have a identity matrix - void setbyproduct_nocheck(const matrix4& other_a,const matrix4& other_b ); - - //! Multiply by another matrix. - matrix4 operator*(const matrix4& other) const; - - //! Multiply by another matrix. - matrix4& operator*=(const matrix4& other); - - //! Multiply by scalar. - matrix4 operator*(const f32 scalar) const; - - //! Multiply by scalar. - matrix4& operator*=(const f32 scalar); - - //! Set matrix to identity. - inline void makeIdentity(); - - //! Returns true if the matrix is the identity matrix - inline bool isIdentity() const; - - //! Returns true if the matrix is the identity matrix - bool isIdentity_integer_base () const; - - //! Set the translation of the current matrix. Will erase any previous values. - void setTranslation( const vector3df& translation ); - - //! Gets the current translation - vector3df getTranslation() const; - - //! Set the inverse translation of the current matrix. Will erase any previous values. - void setInverseTranslation( const vector3df& translation ); - - //! Make a rotation matrix from Euler angles. The 4th row and column are unmodified. - inline void setRotationRadians( const vector3df& rotation ); - - //! Make a rotation matrix from Euler angles. The 4th row and column are unmodified. - void setRotationDegrees( const vector3df& rotation ); - - //! Returns the rotation, as set by setRotation(). This code was orginally written by by Chev. - core::vector3df getRotationDegrees() const; - - //! Make an inverted rotation matrix from Euler angles. The 4th row and column are unmodified. - inline void setInverseRotationRadians( const vector3df& rotation ); - - //! Make an inverted rotation matrix from Euler angles. The 4th row and column are unmodified. - void setInverseRotationDegrees( const vector3df& rotation ); - - //! Set Scale - void setScale( const vector3df& scale ); - - //! Get Scale - core::vector3df getScale() const; - - //! Translate a vector by the inverse of the translation part of this matrix. - void inverseTranslateVect( vector3df& vect ) const; - - //! Rotate a vector by the inverse of the rotation part of this matrix. - void inverseRotateVect( vector3df& vect ) const; - - //! Rotate a vector by the rotation part of this matrix. - void rotateVect( vector3df& vect ) const; - - //! Transforms the vector by this matrix - void transformVect( vector3df& vect) const; - - //! Transforms input vector by this matrix and stores result in output vector - void transformVect( vector3df& out, const vector3df& in ) const; - - //! An alternate transform vector method, writing into an array of 4 floats - void transformVect(f32 *out,const core::vector3df &in) const; - - //! An alternate transform vector method, writing into an array of 3 floats - void rotateVect(f32 *out,const core::vector3df &in) const; - - //! Translate a vector by the translation part of this matrix. - void translateVect( vector3df& vect ) const; - - //! Transforms a plane by this matrix - void transformPlane( core::plane3d &plane) const; - - //! Transforms a plane by this matrix ( some problems to solve..) - void transformPlane_new( core::plane3d &plane) const; - - //! Transforms a plane by this matrix - void transformPlane( const core::plane3d &in, core::plane3d &out) const; - - //! Transforms a axis aligned bounding box - /** The result box of this operation may not be very accurate. For - accurate results, use transformBoxEx() */ - void transformBox(core::aabbox3d& box) const; - - //! Transforms a axis aligned bounding box more accurately than transformBox() - /** The result box of this operation should by quite accurate, but this operation - is slower than transformBox(). */ - void transformBoxEx(core::aabbox3d& box) const; - - //! Multiplies this matrix by a 1x4 matrix - void multiplyWith1x4Matrix(f32* matrix) const; - - //! Calculates inverse of matrix. Slow. - //! \return Returns false if there is no inverse matrix. - bool makeInverse(); - - - //! Inverts a primitive matrix which only contains a translation and a rotation - //! \param out: where result matrix is written to. - bool getInversePrimitive ( matrix4& out ) const; - - //! returns the inversed matrix of this one - //! \param out: where result matrix is written to. - //! \return Returns false if there is no inverse matrix. - bool getInverse(matrix4& out) const; - - //! Builds a right-handed perspective projection matrix based on a field of view - void buildProjectionMatrixPerspectiveFovRH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar); - - //! Builds a left-handed perspective projection matrix based on a field of view - void buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar); - - //! Builds a right-handed perspective projection matrix. - void buildProjectionMatrixPerspectiveRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); - - //! Builds a left-handed perspective projection matrix. - void buildProjectionMatrixPerspectiveLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); - - //! Builds a left-handed orthogonal projection matrix. - void buildProjectionMatrixOrthoLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); - - //! Builds a right-handed orthogonal projection matrix. - void buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); - - //! Builds a left-handed look-at matrix. - void buildCameraLookAtMatrixLH(const vector3df& position, const vector3df& target, const vector3df& upVector); - - //! Builds a right-handed look-at matrix. - void buildCameraLookAtMatrixRH(const vector3df& position, const vector3df& target, const vector3df& upVector); - - //! Builds a matrix that flattens geometry into a plane. - //! \param light: light source - //! \param plane: plane into which the geometry if flattened into - //! \param point: value between 0 and 1, describing the light source. - //! If this is 1, it is a point light, if it is 0, it is a directional light. - void buildShadowMatrix(const core::vector3df& light, core::plane3df plane, f32 point=1.0f); - - //! Builds a matrix which transforms a normalized Device Coordinate to Device Coordinates. - /** Used to scale <-1,-1><1,1> to viewport, for example from von <-1,-1> <1,1> to the viewport <0,0><0,640> */ - void buildNDCToDCMatrix( const core::rect& area, f32 zScale); - - //! creates a new matrix as interpolated matrix from two other ones. - //! \param b: other matrix to interpolate with - //! \param time: Must be a value between 0 and 1. - matrix4 interpolate(const core::matrix4& b, f32 time) const; - - //! returns transposed matrix - matrix4 getTransposed() const; - - //! returns transposed matrix to a plain 4x4 float matrix - inline void getTransposed( matrix4& dest ) const; - - /*! - construct 2D Texture transformations - rotate about center, scale, and transform. - */ - void setTextureScale ( f32 sx, f32 sy ); - - void setTextureRotationCenter( f32 radAngle ); - void setTextureScaleCenter( f32 sx, f32 sy ); - - void setTextureTranslate ( f32 x, f32 y ); - - void buildTextureTransform( f32 rotateRad, - const core::vector2df &rotatecenter, - const core::vector2df &translate, - const core::vector2df &scale); - - private: - //! Matrix data, stored in row-major order - f32 M[16]; - bool definitelyIdentityMatrix; - }; - - inline matrix4::matrix4( matrix4::eConstructor constructor ) : definitelyIdentityMatrix(false) - { - switch ( constructor ) - { - case EM4CONST_NOTHING: - case EM4CONST_COPY: - break; - case EM4CONST_IDENTITY: - case EM4CONST_INVERSE: - default: - makeIdentity(); - break; - } - } - - inline matrix4::matrix4( const matrix4& other,matrix4::eConstructor constructor) : definitelyIdentityMatrix(false) - { - switch ( constructor ) - { - case EM4CONST_IDENTITY: - makeIdentity(); - break; - case EM4CONST_NOTHING: - break; - case EM4CONST_COPY: - *this = other; - break; - case EM4CONST_TRANSPOSED: - other.getTransposed(*this); - break; - case EM4CONST_INVERSE: - if (!other.getInverse(*this)) - memset(M, 0, 16*sizeof(f32)); - break; - case EM4CONST_INVERSE_TRANSPOSED: - if (!other.getInverse(*this)) - memset(M, 0, 16*sizeof(f32)); - else - *this=getTransposed(); - break; - } - } - - //! Add another matrix. - inline matrix4 matrix4::operator+(const matrix4& other) const - { - matrix4 temp ( EM4CONST_NOTHING ); - - temp[0] = M[0]+other[0]; - temp[1] = M[1]+other[1]; - temp[2] = M[2]+other[2]; - temp[3] = M[3]+other[3]; - temp[4] = M[4]+other[4]; - temp[5] = M[5]+other[5]; - temp[6] = M[6]+other[6]; - temp[7] = M[7]+other[7]; - temp[8] = M[8]+other[8]; - temp[9] = M[9]+other[9]; - temp[10] = M[10]+other[10]; - temp[11] = M[11]+other[11]; - temp[12] = M[12]+other[12]; - temp[13] = M[13]+other[13]; - temp[14] = M[14]+other[14]; - temp[15] = M[15]+other[15]; - - return temp; - } - - //! Add another matrix. - inline matrix4& matrix4::operator+=(const matrix4& other) - { - M[0]+=other[0]; - M[1]+=other[1]; - M[2]+=other[2]; - M[3]+=other[3]; - M[4]+=other[4]; - M[5]+=other[5]; - M[6]+=other[6]; - M[7]+=other[7]; - M[8]+=other[8]; - M[9]+=other[9]; - M[10]+=other[10]; - M[11]+=other[11]; - M[12]+=other[12]; - M[13]+=other[13]; - M[14]+=other[14]; - M[15]+=other[15]; - - return *this; - matrix4 temp ( *this ); - setbyproduct ( temp, other ); - return *this; - } - - //! Subtract another matrix. - inline matrix4 matrix4::operator-(const matrix4& other) const - { - matrix4 temp ( EM4CONST_NOTHING ); - - temp[0] = M[0]-other[0]; - temp[1] = M[1]-other[1]; - temp[2] = M[2]-other[2]; - temp[3] = M[3]-other[3]; - temp[4] = M[4]-other[4]; - temp[5] = M[5]-other[5]; - temp[6] = M[6]-other[6]; - temp[7] = M[7]-other[7]; - temp[8] = M[8]-other[8]; - temp[9] = M[9]-other[9]; - temp[10] = M[10]-other[10]; - temp[11] = M[11]-other[11]; - temp[12] = M[12]-other[12]; - temp[13] = M[13]-other[13]; - temp[14] = M[14]-other[14]; - temp[15] = M[15]-other[15]; - - return temp; - } - - //! Subtract another matrix. - inline matrix4& matrix4::operator-=(const matrix4& other) - { - M[0]-=other[0]; - M[1]-=other[1]; - M[2]-=other[2]; - M[3]-=other[3]; - M[4]-=other[4]; - M[5]-=other[5]; - M[6]-=other[6]; - M[7]-=other[7]; - M[8]-=other[8]; - M[9]-=other[9]; - M[10]-=other[10]; - M[11]-=other[11]; - M[12]-=other[12]; - M[13]-=other[13]; - M[14]-=other[14]; - M[15]-=other[15]; - - return *this; - } - - //! Multiply by scalar. - inline matrix4 matrix4::operator*(const f32 scalar) const - { - matrix4 temp ( EM4CONST_NOTHING ); - - temp[0] = M[0]*scalar; - temp[1] = M[1]*scalar; - temp[2] = M[2]*scalar; - temp[3] = M[3]*scalar; - temp[4] = M[4]*scalar; - temp[5] = M[5]*scalar; - temp[6] = M[6]*scalar; - temp[7] = M[7]*scalar; - temp[8] = M[8]*scalar; - temp[9] = M[9]*scalar; - temp[10] = M[10]*scalar; - temp[11] = M[11]*scalar; - temp[12] = M[12]*scalar; - temp[13] = M[13]*scalar; - temp[14] = M[14]*scalar; - temp[15] = M[15]*scalar; - - return temp; - } - - //! Multiply by scalar. - inline matrix4& matrix4::operator*=(const f32 scalar) - { - M[0]*=scalar; - M[1]*=scalar; - M[2]*=scalar; - M[3]*=scalar; - M[4]*=scalar; - M[5]*=scalar; - M[6]*=scalar; - M[7]*=scalar; - M[8]*=scalar; - M[9]*=scalar; - M[10]*=scalar; - M[11]*=scalar; - M[12]*=scalar; - M[13]*=scalar; - M[14]*=scalar; - M[15]*=scalar; - - return *this; - } - - //! Multiply by another matrix. - inline matrix4& matrix4::operator*=(const matrix4& other) - { - matrix4 temp ( *this ); - setbyproduct ( temp, other ); - return *this; - } - - //! multiply by another matrix - // set this matrix to the product of two other matrices - // goal is to reduce stack use and copy - inline void matrix4::setbyproduct_nocheck(const matrix4& other_a,const matrix4& other_b ) - { - const f32 *m1 = other_a.M; - const f32 *m2 = other_b.M; - - M[0] = m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2] + m1[12]*m2[3]; - M[1] = m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2] + m1[13]*m2[3]; - M[2] = m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2] + m1[14]*m2[3]; - M[3] = m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2] + m1[15]*m2[3]; - - M[4] = m1[0]*m2[4] + m1[4]*m2[5] + m1[8]*m2[6] + m1[12]*m2[7]; - M[5] = m1[1]*m2[4] + m1[5]*m2[5] + m1[9]*m2[6] + m1[13]*m2[7]; - M[6] = m1[2]*m2[4] + m1[6]*m2[5] + m1[10]*m2[6] + m1[14]*m2[7]; - M[7] = m1[3]*m2[4] + m1[7]*m2[5] + m1[11]*m2[6] + m1[15]*m2[7]; - - M[8] = m1[0]*m2[8] + m1[4]*m2[9] + m1[8]*m2[10] + m1[12]*m2[11]; - M[9] = m1[1]*m2[8] + m1[5]*m2[9] + m1[9]*m2[10] + m1[13]*m2[11]; - M[10] = m1[2]*m2[8] + m1[6]*m2[9] + m1[10]*m2[10] + m1[14]*m2[11]; - M[11] = m1[3]*m2[8] + m1[7]*m2[9] + m1[11]*m2[10] + m1[15]*m2[11]; - - M[12] = m1[0]*m2[12] + m1[4]*m2[13] + m1[8]*m2[14] + m1[12]*m2[15]; - M[13] = m1[1]*m2[12] + m1[5]*m2[13] + m1[9]*m2[14] + m1[13]*m2[15]; - M[14] = m1[2]*m2[12] + m1[6]*m2[13] + m1[10]*m2[14] + m1[14]*m2[15]; - M[15] = m1[3]*m2[12] + m1[7]*m2[13] + m1[11]*m2[14] + m1[15]*m2[15]; - definitelyIdentityMatrix=false; - } - - - //! multiply by another matrix - // set this matrix to the product of two other matrices - // goal is to reduce stack use and copy - inline void matrix4::setbyproduct(const matrix4& other_a,const matrix4& other_b ) - { - if ( other_a.isIdentity () ) - { - *this = other_b; - return; - } - else - if ( other_b.isIdentity () ) - { - *this = other_a; - return; - } - setbyproduct_nocheck(other_a,other_b); - } - - //! multiply by another matrix - inline matrix4 matrix4::operator*(const matrix4& m2) const - { - // Testing purpose.. - if ( this->isIdentity() ) - return m2; - if ( m2.isIdentity() ) - return *this; - - matrix4 m3 ( EM4CONST_NOTHING ); - - const f32 *m1 = M; - - m3[0] = m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2] + m1[12]*m2[3]; - m3[1] = m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2] + m1[13]*m2[3]; - m3[2] = m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2] + m1[14]*m2[3]; - m3[3] = m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2] + m1[15]*m2[3]; - - m3[4] = m1[0]*m2[4] + m1[4]*m2[5] + m1[8]*m2[6] + m1[12]*m2[7]; - m3[5] = m1[1]*m2[4] + m1[5]*m2[5] + m1[9]*m2[6] + m1[13]*m2[7]; - m3[6] = m1[2]*m2[4] + m1[6]*m2[5] + m1[10]*m2[6] + m1[14]*m2[7]; - m3[7] = m1[3]*m2[4] + m1[7]*m2[5] + m1[11]*m2[6] + m1[15]*m2[7]; - - m3[8] = m1[0]*m2[8] + m1[4]*m2[9] + m1[8]*m2[10] + m1[12]*m2[11]; - m3[9] = m1[1]*m2[8] + m1[5]*m2[9] + m1[9]*m2[10] + m1[13]*m2[11]; - m3[10] = m1[2]*m2[8] + m1[6]*m2[9] + m1[10]*m2[10] + m1[14]*m2[11]; - m3[11] = m1[3]*m2[8] + m1[7]*m2[9] + m1[11]*m2[10] + m1[15]*m2[11]; - - m3[12] = m1[0]*m2[12] + m1[4]*m2[13] + m1[8]*m2[14] + m1[12]*m2[15]; - m3[13] = m1[1]*m2[12] + m1[5]*m2[13] + m1[9]*m2[14] + m1[13]*m2[15]; - m3[14] = m1[2]*m2[12] + m1[6]*m2[13] + m1[10]*m2[14] + m1[14]*m2[15]; - m3[15] = m1[3]*m2[12] + m1[7]*m2[13] + m1[11]*m2[14] + m1[15]*m2[15]; - return m3; - } - - - - inline vector3df matrix4::getTranslation() const - { - return vector3df(M[12], M[13], M[14]); - } - - - inline void matrix4::setTranslation( const vector3df& translation ) - { - M[12] = translation.X; - M[13] = translation.Y; - M[14] = translation.Z; - definitelyIdentityMatrix=false; - } - - inline void matrix4::setInverseTranslation( const vector3df& translation ) - { - M[12] = -translation.X; - M[13] = -translation.Y; - M[14] = -translation.Z; - definitelyIdentityMatrix=false; - } - - inline void matrix4::setScale( const vector3df& scale ) - { - M[0] = scale.X; - M[5] = scale.Y; - M[10] = scale.Z; - definitelyIdentityMatrix=false; - } - - inline vector3df matrix4::getScale() const - { - return vector3df(M[0],M[5],M[10]); - } - - inline void matrix4::setRotationDegrees( const vector3df& rotation ) - { - setRotationRadians( rotation * core::DEGTORAD ); - } - - inline void matrix4::setInverseRotationDegrees( const vector3df& rotation ) - { - setInverseRotationRadians( rotation * core::DEGTORAD ); - } - - inline void matrix4::setRotationRadians( const vector3df& rotation ) - { - f64 cr = cos( rotation.X ); - f64 sr = sin( rotation.X ); - f64 cp = cos( rotation.Y ); - f64 sp = sin( rotation.Y ); - f64 cy = cos( rotation.Z ); - f64 sy = sin( rotation.Z ); - - M[0] = (f32)( cp*cy ); - M[1] = (f32)( cp*sy ); - M[2] = (f32)( -sp ); - - f64 srsp = sr*sp; - f64 crsp = cr*sp; - - M[4] = (f32)( srsp*cy-cr*sy ); - M[5] = (f32)( srsp*sy+cr*cy ); - M[6] = (f32)( sr*cp ); - - M[8] = (f32)( crsp*cy+sr*sy ); - M[9] = (f32)( crsp*sy-sr*cy ); - M[10] = (f32)( cr*cp ); - definitelyIdentityMatrix=false; - } - - - - //! Returns the rotation, as set by setRotation(). This code was sent - //! in by Chev. - inline core::vector3df matrix4::getRotationDegrees() const - { - const matrix4 &mat = *this; - - f64 Y = -asin(mat(0,2)); - f64 C = cos(Y); - Y *= RADTODEG64; - - f64 rotx, roty, X, Z; - - if (fabs(C)>0.0005f) - { - rotx = mat(2,2) / C; - roty = mat(1,2) / C; - X = atan2( roty, rotx ) * RADTODEG64; - rotx = mat(0,0) / C; - roty = mat(0,1) / C; - Z = atan2( roty, rotx ) * RADTODEG64; - } - else - { - X = 0.0f; - rotx = mat(1,1); - roty = -mat(1,0); - Z = atan2( roty, rotx ) * RADTODEG64; - } - - // fix values that get below zero - // before it would set (!) values to 360 - // that where above 360: - if (X < 0.0) X += 360.0; - if (Y < 0.0) Y += 360.0; - if (Z < 0.0) Z += 360.0; - - return vector3df((f32)X,(f32)Y,(f32)Z); - } - - inline void matrix4::setInverseRotationRadians( const vector3df& rotation ) - { - f64 cr = cos( rotation.X ); - f64 sr = sin( rotation.X ); - f64 cp = cos( rotation.Y ); - f64 sp = sin( rotation.Y ); - f64 cy = cos( rotation.Z ); - f64 sy = sin( rotation.Z ); - - M[0] = (f32)( cp*cy ); - M[4] = (f32)( cp*sy ); - M[8] = (f32)( -sp ); - - f64 srsp = sr*sp; - f64 crsp = cr*sp; - - M[1] = (f32)( srsp*cy-cr*sy ); - M[5] = (f32)( srsp*sy+cr*cy ); - M[9] = (f32)( sr*cp ); - - M[2] = (f32)( crsp*cy+sr*sy ); - M[6] = (f32)( crsp*sy-sr*cy ); - M[10] = (f32)( cr*cp ); - definitelyIdentityMatrix=false; - } - - - /*! - */ - inline void matrix4::makeIdentity() - { - memset(M, 0, 16*sizeof(f32)); - M[0] = M[5] = M[10] = M[15] = 1.0f; - definitelyIdentityMatrix=true; - } - - - /* - check identity with epsilon - solve floating range problems.. - */ - inline bool matrix4::isIdentity() const - { - if (definitelyIdentityMatrix) - return true; - if ( !equals ( M[ 0], 1.f ) || - !equals ( M[ 5], 1.f ) || - !equals ( M[10], 1.f ) || - !equals ( M[15], 1.f ) - ) - return false; - - for (s32 i=0; i<4; ++i) - for (s32 j=0; j<4; ++j) - if (j != i) - { - if ((*this)(i,j) < -ROUNDING_ERROR_32|| - (*this)(i,j) > ROUNDING_ERROR_32) - return false; - } - return true; - } - - /* - doesn't solve floating range problems.. - but takes care on +/- 0 on translation because we are changing it.. - reducing floating point branches - but it need's the floats in memory.. - */ - inline bool matrix4::isIdentity_integer_base() const - { - if (definitelyIdentityMatrix) - return true; - if(IR(M[0])!=F32_VALUE_1) return false; - if(IR(M[1])!=0) return false; - if(IR(M[2])!=0) return false; - if(IR(M[3])!=0) return false; - - if(IR(M[4])!=0) return false; - if(IR(M[5])!=F32_VALUE_1) return false; - if(IR(M[6])!=0) return false; - if(IR(M[7])!=0) return false; - - if(IR(M[8])!=0) return false; - if(IR(M[9])!=0) return false; - if(IR(M[10])!=F32_VALUE_1) return false; - if(IR(M[11])!=0) return false; - - if(IR(M[12])!=0) return false; - if(IR(M[13])!=0) return false; - if(IR(M[13])!=0) return false; - if(IR(M[15])!=F32_VALUE_1) return false; - return true; - } - - - - inline void matrix4::rotateVect( vector3df& vect ) const - { - vector3df tmp = vect; - vect.X = tmp.X*M[0] + tmp.Y*M[4] + tmp.Z*M[8]; - vect.Y = tmp.X*M[1] + tmp.Y*M[5] + tmp.Z*M[9]; - vect.Z = tmp.X*M[2] + tmp.Y*M[6] + tmp.Z*M[10]; - } - - //! An alternate transform vector method, writing into an array of 3 floats - inline void matrix4::rotateVect(f32 *out,const core::vector3df &in) const - { - out[0] = in.X*M[0] + in.Y*M[4] + in.Z*M[8]; - out[1] = in.X*M[1] + in.Y*M[5] + in.Z*M[9]; - out[2] = in.X*M[2] + in.Y*M[6] + in.Z*M[10]; - } - - inline void matrix4::inverseRotateVect( vector3df& vect ) const - { - vector3df tmp = vect; - vect.X = tmp.X*M[0] + tmp.Y*M[1] + tmp.Z*M[2]; - vect.Y = tmp.X*M[4] + tmp.Y*M[5] + tmp.Z*M[6]; - vect.Z = tmp.X*M[8] + tmp.Y*M[9] + tmp.Z*M[10]; - } - - inline void matrix4::transformVect( vector3df& vect) const - { - f32 vector[3]; - - vector[0] = vect.X*M[0] + vect.Y*M[4] + vect.Z*M[8] + M[12]; - vector[1] = vect.X*M[1] + vect.Y*M[5] + vect.Z*M[9] + M[13]; - vector[2] = vect.X*M[2] + vect.Y*M[6] + vect.Z*M[10] + M[14]; - - vect.X = vector[0]; - vect.Y = vector[1]; - vect.Z = vector[2]; - } - - inline void matrix4::transformVect( vector3df& out, const vector3df& in) const - { - out.X = in.X*M[0] + in.Y*M[4] + in.Z*M[8] + M[12]; - out.Y = in.X*M[1] + in.Y*M[5] + in.Z*M[9] + M[13]; - out.Z = in.X*M[2] + in.Y*M[6] + in.Z*M[10] + M[14]; - } - - - // transform (x,y,z,1) - inline void matrix4::transformVect(f32 *out,const vector3df &in) const - { - out[0] = in.X*M[0] + in.Y*M[4] + in.Z*M[8] + M[12]; - out[1] = in.X*M[1] + in.Y*M[5] + in.Z*M[9] + M[13]; - out[2] = in.X*M[2] + in.Y*M[6] + in.Z*M[10] + M[14]; - out[3] = in.X*M[3] + in.Y*M[7] + in.Z*M[11] + M[15]; - } - - - //! Transforms a plane by this matrix - inline void matrix4::transformPlane( core::plane3d &plane) const - { - vector3df member; - transformVect(member, plane.getMemberPoint()); - - vector3df origin(0,0,0); - transformVect(plane.Normal); - transformVect(origin); - - plane.Normal -= origin; - plane.D = - member.dotProduct(plane.Normal); - } - - //! Transforms a plane by this matrix - inline void matrix4::transformPlane_new( core::plane3d &plane) const - { - // rotate normal -> rotateVect ( plane.n ); - vector3df n; - n.X = plane.Normal.X*M[0] + plane.Normal.Y*M[4] + plane.Normal.Z*M[8]; - n.Y = plane.Normal.X*M[1] + plane.Normal.Y*M[5] + plane.Normal.Z*M[9]; - n.Z = plane.Normal.X*M[2] + plane.Normal.Y*M[6] + plane.Normal.Z*M[10]; - - // compute new d. -> getTranslation(). dotproduct ( plane.n ) - plane.D -= M[12] * n.X + M[13] * n.Y + M[14] * n.Z; - plane.Normal.X = n.X; - plane.Normal.Y = n.Y; - plane.Normal.Z = n.Z; - } - - //! Transforms a plane by this matrix - inline void matrix4::transformPlane( const core::plane3d &in, core::plane3d &out) const - { - out = in; - transformPlane( out ); - } - - //! Transforms a axis aligned bounding box - inline void matrix4::transformBox(core::aabbox3d& box) const - { - if (isIdentity() ) - return; - - transformVect(box.MinEdge); - transformVect(box.MaxEdge); - box.repair(); - } - - //! Transforms a axis aligned bounding box more accurately than transformBox() - inline void matrix4::transformBoxEx(core::aabbox3d& box) const - { - f32 Amin[3]; - f32 Amax[3]; - f32 Bmin[3]; - f32 Bmax[3]; - - Amin[0] = box.MinEdge.X; - Amin[1] = box.MinEdge.Y; - Amin[2] = box.MinEdge.Z; - - Amax[0] = box.MaxEdge.X; - Amax[1] = box.MaxEdge.Y; - Amax[2] = box.MaxEdge.Z; - - Bmin[0] = Bmax[0] = M[12]; - Bmin[1] = Bmax[1] = M[13]; - Bmin[2] = Bmax[2] = M[14]; - - u32 i, j; - const matrix4 &m = *this; - - for (i = 0; i < 3; ++i) - { - for (j = 0; j < 3; ++j) - { - f32 a = m(j,i) * Amin[j]; - f32 b = m(j,i) * Amax[j]; - - if (a < b) - { - Bmin[i] += a; - Bmax[i] += b; - } - else - { - Bmin[i] += b; - Bmax[i] += a; - } - } - } - - box.MinEdge.X = Bmin[0]; - box.MinEdge.Y = Bmin[1]; - box.MinEdge.Z = Bmin[2]; - - box.MaxEdge.X = Bmax[0]; - box.MaxEdge.Y = Bmax[1]; - box.MaxEdge.Z = Bmax[2]; - } - - - //! Multiplies this matrix by a 1x4 matrix - inline void matrix4::multiplyWith1x4Matrix(f32* matrix) const - { - /* - 0 1 2 3 - 4 5 6 7 - 8 9 10 11 - 12 13 14 15 - */ - - f32 mat[4]; - mat[0] = matrix[0]; - mat[1] = matrix[1]; - mat[2] = matrix[2]; - mat[3] = matrix[3]; - - matrix[0] = M[0]*mat[0] + M[4]*mat[1] + M[8]*mat[2] + M[12]*mat[3]; - matrix[1] = M[1]*mat[0] + M[5]*mat[1] + M[9]*mat[2] + M[13]*mat[3]; - matrix[2] = M[2]*mat[0] + M[6]*mat[1] + M[10]*mat[2] + M[14]*mat[3]; - matrix[3] = M[3]*mat[0] + M[7]*mat[1] + M[11]*mat[2] + M[15]*mat[3]; - } - - inline void matrix4::inverseTranslateVect( vector3df& vect ) const - { - vect.X = vect.X-M[12]; - vect.Y = vect.Y-M[13]; - vect.Z = vect.Z-M[14]; - } - - inline void matrix4::translateVect( vector3df& vect ) const - { - vect.X = vect.X+M[12]; - vect.Y = vect.Y+M[13]; - vect.Z = vect.Z+M[14]; - } - - - inline bool matrix4::getInverse(matrix4& out) const - { - /// Calculates the inverse of this Matrix - /// The inverse is calculated using Cramers rule. - /// If no inverse exists then 'false' is returned. - - const matrix4 &m = *this; - - f32 d = (m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0)) * (m(2, 2) * m(3, 3) - m(2, 3) * m(3, 2)) - - (m(0, 0) * m(1, 2) - m(0, 2) * m(1, 0)) * (m(2, 1) * m(3, 3) - m(2, 3) * m(3, 1)) + - (m(0, 0) * m(1, 3) - m(0, 3) * m(1, 0)) * (m(2, 1) * m(3, 2) - m(2, 2) * m(3, 1)) + - (m(0, 1) * m(1, 2) - m(0, 2) * m(1, 1)) * (m(2, 0) * m(3, 3) - m(2, 3) * m(3, 0)) - - (m(0, 1) * m(1, 3) - m(0, 3) * m(1, 1)) * (m(2, 0) * m(3, 2) - m(2, 2) * m(3, 0)) + - (m(0, 2) * m(1, 3) - m(0, 3) * m(1, 2)) * (m(2, 0) * m(3, 1) - m(2, 1) * m(3, 0)); - - if( core::iszero ( d ) ) - return false; - - d = core::reciprocal ( d ); - - out(0, 0) = d * (m(1, 1) * (m(2, 2) * m(3, 3) - m(2, 3) * m(3, 2)) + m(1, 2) * (m(2, 3) * m(3, 1) - m(2, 1) * m(3, 3)) + m(1, 3) * (m(2, 1) * m(3, 2) - m(2, 2) * m(3, 1))); - out(0, 1) = d * (m(2, 1) * (m(0, 2) * m(3, 3) - m(0, 3) * m(3, 2)) + m(2, 2) * (m(0, 3) * m(3, 1) - m(0, 1) * m(3, 3)) + m(2, 3) * (m(0, 1) * m(3, 2) - m(0, 2) * m(3, 1))); - out(0, 2) = d * (m(3, 1) * (m(0, 2) * m(1, 3) - m(0, 3) * m(1, 2)) + m(3, 2) * (m(0, 3) * m(1, 1) - m(0, 1) * m(1, 3)) + m(3, 3) * (m(0, 1) * m(1, 2) - m(0, 2) * m(1, 1))); - out(0, 3) = d * (m(0, 1) * (m(1, 3) * m(2, 2) - m(1, 2) * m(2, 3)) + m(0, 2) * (m(1, 1) * m(2, 3) - m(1, 3) * m(2, 1)) + m(0, 3) * (m(1, 2) * m(2, 1) - m(1, 1) * m(2, 2))); - out(1, 0) = d * (m(1, 2) * (m(2, 0) * m(3, 3) - m(2, 3) * m(3, 0)) + m(1, 3) * (m(2, 2) * m(3, 0) - m(2, 0) * m(3, 2)) + m(1, 0) * (m(2, 3) * m(3, 2) - m(2, 2) * m(3, 3))); - out(1, 1) = d * (m(2, 2) * (m(0, 0) * m(3, 3) - m(0, 3) * m(3, 0)) + m(2, 3) * (m(0, 2) * m(3, 0) - m(0, 0) * m(3, 2)) + m(2, 0) * (m(0, 3) * m(3, 2) - m(0, 2) * m(3, 3))); - out(1, 2) = d * (m(3, 2) * (m(0, 0) * m(1, 3) - m(0, 3) * m(1, 0)) + m(3, 3) * (m(0, 2) * m(1, 0) - m(0, 0) * m(1, 2)) + m(3, 0) * (m(0, 3) * m(1, 2) - m(0, 2) * m(1, 3))); - out(1, 3) = d * (m(0, 2) * (m(1, 3) * m(2, 0) - m(1, 0) * m(2, 3)) + m(0, 3) * (m(1, 0) * m(2, 2) - m(1, 2) * m(2, 0)) + m(0, 0) * (m(1, 2) * m(2, 3) - m(1, 3) * m(2, 2))); - out(2, 0) = d * (m(1, 3) * (m(2, 0) * m(3, 1) - m(2, 1) * m(3, 0)) + m(1, 0) * (m(2, 1) * m(3, 3) - m(2, 3) * m(3, 1)) + m(1, 1) * (m(2, 3) * m(3, 0) - m(2, 0) * m(3, 3))); - out(2, 1) = d * (m(2, 3) * (m(0, 0) * m(3, 1) - m(0, 1) * m(3, 0)) + m(2, 0) * (m(0, 1) * m(3, 3) - m(0, 3) * m(3, 1)) + m(2, 1) * (m(0, 3) * m(3, 0) - m(0, 0) * m(3, 3))); - out(2, 2) = d * (m(3, 3) * (m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0)) + m(3, 0) * (m(0, 1) * m(1, 3) - m(0, 3) * m(1, 1)) + m(3, 1) * (m(0, 3) * m(1, 0) - m(0, 0) * m(1, 3))); - out(2, 3) = d * (m(0, 3) * (m(1, 1) * m(2, 0) - m(1, 0) * m(2, 1)) + m(0, 0) * (m(1, 3) * m(2, 1) - m(1, 1) * m(2, 3)) + m(0, 1) * (m(1, 0) * m(2, 3) - m(1, 3) * m(2, 0))); - out(3, 0) = d * (m(1, 0) * (m(2, 2) * m(3, 1) - m(2, 1) * m(3, 2)) + m(1, 1) * (m(2, 0) * m(3, 2) - m(2, 2) * m(3, 0)) + m(1, 2) * (m(2, 1) * m(3, 0) - m(2, 0) * m(3, 1))); - out(3, 1) = d * (m(2, 0) * (m(0, 2) * m(3, 1) - m(0, 1) * m(3, 2)) + m(2, 1) * (m(0, 0) * m(3, 2) - m(0, 2) * m(3, 0)) + m(2, 2) * (m(0, 1) * m(3, 0) - m(0, 0) * m(3, 1))); - out(3, 2) = d * (m(3, 0) * (m(0, 2) * m(1, 1) - m(0, 1) * m(1, 2)) + m(3, 1) * (m(0, 0) * m(1, 2) - m(0, 2) * m(1, 0)) + m(3, 2) * (m(0, 1) * m(1, 0) - m(0, 0) * m(1, 1))); - out(3, 3) = d * (m(0, 0) * (m(1, 1) * m(2, 2) - m(1, 2) * m(2, 1)) + m(0, 1) * (m(1, 2) * m(2, 0) - m(1, 0) * m(2, 2)) + m(0, 2) * (m(1, 0) * m(2, 1) - m(1, 1) * m(2, 0))); - out.definitelyIdentityMatrix = definitelyIdentityMatrix; - return true; - } - - - //! Inverts a primitive matrix which only contains a translation and a rotation - //! \param out: where result matrix is written to. - inline bool matrix4::getInversePrimitive ( matrix4& out ) const - { - out.M[0 ] = M[0]; - out.M[1 ] = M[4]; - out.M[2 ] = M[8]; - out.M[3 ] = 0.0f; - - out.M[4 ] = M[1]; - out.M[5 ] = M[5]; - out.M[6 ] = M[9]; - out.M[7 ] = 0.0f; - - out.M[8 ] = M[2]; - out.M[9 ] = M[6]; - out.M[10] = M[10]; - out.M[11] = 0.0f; - - out.M[12] = -(M[12]*M[0] + M[13]*M[1] + M[14]*M[2]); - out.M[13] = -(M[12]*M[4] + M[13]*M[5] + M[14]*M[6]); - out.M[14] = -(M[12]*M[8] + M[13]*M[9] + M[14]*M[10]); - out.M[15] = 1.0f; - out.definitelyIdentityMatrix = definitelyIdentityMatrix; - return true; - } - - /*! - */ - inline bool matrix4::makeInverse() - { - matrix4 temp ( EM4CONST_NOTHING ); - - if (getInverse(temp)) - { - *this = temp; - return true; - } - - return false; - } - - - - inline matrix4& matrix4::operator=(const matrix4 &other) - { - if (this==&other) - return *this; - memcpy(M, other.M, 16*sizeof(f32)); - definitelyIdentityMatrix=other.definitelyIdentityMatrix; - return *this; - } - - - - inline bool matrix4::operator==(const matrix4 &other) const - { - if (definitelyIdentityMatrix && other.definitelyIdentityMatrix) - return true; - for (s32 i = 0; i < 16; ++i) - if (M[i] != other.M[i]) - return false; - - return true; - } - - - - inline bool matrix4::operator!=(const matrix4 &other) const - { - return !(*this == other); - } - - - - //! Builds a right-handed perspective projection matrix based on a field of view - inline void matrix4::buildProjectionMatrixPerspectiveFovRH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar) - { - f32 h = (f32)(1.0/tan(fieldOfViewRadians/2.0)); - f32 w = h / aspectRatio; - - M[0] = w; - M[1] = 0.0f; - M[2] = 0.0f; - M[3] = 0.0f; - - M[4] = 0.0f; - M[5] = h; - M[6] = 0.0f; - M[7] = 0.0f; - - M[8] = 0.0f; - M[9] = 0.0f; - M[10] = zFar/(zNear-zFar); // DirectX version -// M[10] = zFar+zNear/(zNear-zFar); // OpenGL version - M[11] = -1.0f; - - M[12] = 0.0f; - M[13] = 0.0f; - M[14] = zNear*zFar/(zNear-zFar); // DirectX version -// M[14] = 2.0f*zNear*zFar/(zNear-zFar); // OpenGL version - M[15] = 0.0f; - definitelyIdentityMatrix=false; - } - - - - //! Builds a left-handed perspective projection matrix based on a field of view - inline void matrix4::buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar) - { - f32 h = (f32)(1.0/tan(fieldOfViewRadians/2.0)); - f32 w = h / aspectRatio; - - M[0] = w; - M[1] = 0.0f; - M[2] = 0.0f; - M[3] = 0.0f; - - M[4] = 0.0f; - M[5] = h; - M[6] = 0.0f; - M[7] = 0.0f; - - M[8] = 0.0f; - M[9] = 0.0f; - M[10] = zFar/(zFar-zNear); - M[11] = 1.0f; - - M[12] = 0.0f; - M[13] = 0.0f; - M[14] = -zNear*zFar/(zFar-zNear); - M[15] = 0.0f; - definitelyIdentityMatrix=false; - } - - - - //! Builds a left-handed orthogonal projection matrix. - inline void matrix4::buildProjectionMatrixOrthoLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) - { - M[0] = 2/widthOfViewVolume; - M[1] = 0; - M[2] = 0; - M[3] = 0; - - M[4] = 0; - M[5] = 2/heightOfViewVolume; - M[6] = 0; - M[7] = 0; - - M[8] = 0; - M[9] = 0; - M[10] = 1/(zFar-zNear); - M[11] = 0; - - M[12] = 0; - M[13] = 0; - M[14] = zNear/(zNear-zFar); - M[15] = 1; - definitelyIdentityMatrix=false; - } - - - - //! Builds a right-handed orthogonal projection matrix. - inline void matrix4::buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) - { - M[0] = 2/widthOfViewVolume; - M[1] = 0; - M[2] = 0; - M[3] = 0; - - M[4] = 0; - M[5] = 2/heightOfViewVolume; - M[6] = 0; - M[7] = 0; - - M[8] = 0; - M[9] = 0; - M[10] = 1/(zNear-zFar); - M[11] = 0; - - M[12] = 0; - M[13] = 0; - M[14] = zNear/(zNear-zFar); - M[15] = -1; - definitelyIdentityMatrix=false; - } - - - //! Builds a right-handed perspective projection matrix. - inline void matrix4::buildProjectionMatrixPerspectiveRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) - { - M[0] = 2*zNear/widthOfViewVolume; - M[1] = 0; - M[2] = 0; - M[3] = 0; - - M[4] = 0; - M[5] = 2*zNear/heightOfViewVolume; - M[6] = 0; - M[7] = 0; - - M[8] = 0; - M[9] = 0; - M[10] = zFar/(zNear-zFar); - M[11] = -1; - - M[12] = 0; - M[13] = 0; - M[14] = zNear*zFar/(zNear-zFar); - M[15] = 0; - definitelyIdentityMatrix=false; - } - - - //! Builds a left-handed perspective projection matrix. - inline void matrix4::buildProjectionMatrixPerspectiveLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) - { - M[0] = 2*zNear/widthOfViewVolume; - M[1] = 0; - M[2] = 0; - M[3] = 0; - - M[4] = 0; - M[5] = 2*zNear/heightOfViewVolume; - M[6] = 0; - M[7] = 0; - - M[8] = 0; - M[9] = 0; - M[10] = zFar/(zFar-zNear); - M[11] = 1; - - M[12] = 0; - M[13] = 0; - M[14] = zNear*zFar/(zNear-zFar); - M[15] = 0; - definitelyIdentityMatrix=false; - } - - - //! Builds a matrix that flattens geometry into a plane. - inline void matrix4::buildShadowMatrix(const core::vector3df& light, core::plane3df plane, f32 point) - { - plane.Normal.normalize(); - f32 d = plane.Normal.dotProduct(light); - - M[ 0] = -plane.Normal.X * light.X + d; - M[ 1] = -plane.Normal.X * light.Y; - M[ 2] = -plane.Normal.X * light.Z; - M[ 3] = -plane.Normal.X * point; - - M[ 4] = -plane.Normal.Y * light.X; - M[ 5] = -plane.Normal.Y * light.Y + d; - M[ 6] = -plane.Normal.Y * light.Z; - M[ 7] = -plane.Normal.Y * point; - - M[ 8] = -plane.Normal.Z * light.X; - M[ 9] = -plane.Normal.Z * light.Y; - M[10] = -plane.Normal.Z * light.Z + d; - M[11] = -plane.Normal.Z * point; - - M[12] = -plane.D * light.X; - M[13] = -plane.D * light.Y; - M[14] = -plane.D * light.Z; - M[15] = -plane.D * point + d; - definitelyIdentityMatrix=false; - } - - //! Builds a left-handed look-at matrix. - inline void matrix4::buildCameraLookAtMatrixLH( - const vector3df& position, - const vector3df& target, - const vector3df& upVector) - { - vector3df zaxis = target - position; - zaxis.normalize(); - - vector3df xaxis = upVector.crossProduct(zaxis); - xaxis.normalize(); - - vector3df yaxis = zaxis.crossProduct(xaxis); - - M[0] = xaxis.X; - M[1] = yaxis.X; - M[2] = zaxis.X; - M[3] = 0; - - M[4] = xaxis.Y; - M[5] = yaxis.Y; - M[6] = zaxis.Y; - M[7] = 0; - - M[8] = xaxis.Z; - M[9] = yaxis.Z; - M[10] = zaxis.Z; - M[11] = 0; - - M[12] = -xaxis.dotProduct(position); - M[13] = -yaxis.dotProduct(position); - M[14] = -zaxis.dotProduct(position); - M[15] = 1.0f; - definitelyIdentityMatrix=false; - } - - - - //! Builds a right-handed look-at matrix. - inline void matrix4::buildCameraLookAtMatrixRH( - const vector3df& position, - const vector3df& target, - const vector3df& upVector) - { - vector3df zaxis = position - target; - zaxis.normalize(); - - vector3df xaxis = upVector.crossProduct(zaxis); - xaxis.normalize(); - - vector3df yaxis = zaxis.crossProduct(xaxis); - - M[0] = xaxis.X; - M[1] = yaxis.X; - M[2] = zaxis.X; - M[3] = 0; - - M[4] = xaxis.Y; - M[5] = yaxis.Y; - M[6] = zaxis.Y; - M[7] = 0; - - M[8] = xaxis.Z; - M[9] = yaxis.Z; - M[10] = zaxis.Z; - M[11] = 0; - - M[12] = -xaxis.dotProduct(position); - M[13] = -yaxis.dotProduct(position); - M[14] = -zaxis.dotProduct(position); - M[15] = 1.0f; - definitelyIdentityMatrix=false; - } - - - //! creates a new matrix as interpolated matrix from to other ones. - //! \param time: Must be a value between 0 and 1. - inline matrix4 matrix4::interpolate(const core::matrix4& b, f32 time) const - { - matrix4 mat ( EM4CONST_NOTHING ); - - for (s32 i=0; i < 16; i += 4) - { - mat.M[i+0] = M[i+0] + ( b.M[i+0] - M[i+0] ) * time; - mat.M[i+1] = M[i+1] + ( b.M[i+1] - M[i+1] ) * time; - mat.M[i+2] = M[i+2] + ( b.M[i+2] - M[i+2] ) * time; - mat.M[i+3] = M[i+3] + ( b.M[i+3] - M[i+3] ) * time; - } - return mat; - } - - //! returns transposed matrix - inline matrix4 matrix4::getTransposed() const - { - matrix4 t ( EM4CONST_NOTHING ); - getTransposed ( t ); - return t; - } - - //! returns transposed matrix - inline void matrix4::getTransposed( matrix4& o ) const - { - o[ 0] = M[ 0]; - o[ 1] = M[ 4]; - o[ 2] = M[ 8]; - o[ 3] = M[12]; - - o[ 4] = M[ 1]; - o[ 5] = M[ 5]; - o[ 6] = M[ 9]; - o[ 7] = M[13]; - - o[ 8] = M[ 2]; - o[ 9] = M[ 6]; - o[10] = M[10]; - o[11] = M[14]; - - o[12] = M[ 3]; - o[13] = M[ 7]; - o[14] = M[11]; - o[15] = M[15]; - o.definitelyIdentityMatrix=definitelyIdentityMatrix; - } - - - // used to scale <-1,-1><1,1> to viewport - inline void matrix4::buildNDCToDCMatrix( const core::rect& viewport, f32 zScale) - { - f32 scaleX = (viewport.getWidth() - 0.75f ) / 2.f; - f32 scaleY = -(viewport.getHeight() - 0.75f ) / 2.f; - - f32 dx = -0.5f + ( (viewport.UpperLeftCorner.X + viewport.LowerRightCorner.X ) / 2.f ); - f32 dy = -0.5f + ( (viewport.UpperLeftCorner.Y + viewport.LowerRightCorner.Y ) / 2.f ); - - makeIdentity(); - M[0] = scaleX; - M[5] = scaleY; - M[10] = zScale; - M[12] = dx; - M[13] = dy; - definitelyIdentityMatrix=false; - } - - /*! - Generate texture coordinates as linear functions so that: - u = Ux*x + Uy*y + Uz*z + Uw - v = Vx*x + Vy*y + Vz*z + Vw - The matrix M for this case is: - Ux Vx 0 0 - Uy Vy 0 0 - Uz Vz 0 0 - Uw Vw 0 0 - */ - - inline void matrix4::buildTextureTransform( f32 rotateRad, - const core::vector2df &rotatecenter, - const core::vector2df &translate, - const core::vector2df &scale) - { - f32 c = cosf(rotateRad); - f32 s = sinf(rotateRad); - - M[0] = c * scale.X; - M[1] = s * scale.Y; - M[2] = 0.f; - M[3] = 0.f; - - M[4] = -s * scale.X; - M[5] = c * scale.Y; - M[6] = 0.f; - M[7] = 0.f; - - M[8] = c * scale.X * rotatecenter.X + -s * rotatecenter.Y + translate.X; - M[9] = s * scale.Y * rotatecenter.X + c * rotatecenter.Y + translate.Y; - M[10] = 1.f; - M[11] = 0.f; - - M[12] = 0.f; - M[13] = 0.f; - M[14] = 0.f; - M[15] = 1.f; - definitelyIdentityMatrix=false; - } - - //! rotate about z axis, center ( 0.5, 0.5 ) - inline void matrix4::setTextureRotationCenter( f32 rotateRad ) - { - f32 c = cosf(rotateRad); - f32 s = sinf(rotateRad); - M[0] = c; - M[1] = s; - M[2] = -0.5f * ( c + s) + 0.5f; - - M[4] = -s; - M[5] = c; - M[6] = -0.5f * (-s + c) + 0.5f; - definitelyIdentityMatrix=false; - } - - inline void matrix4::setTextureTranslate ( f32 x, f32 y ) - { - M[2] = x; - M[6] = y; - definitelyIdentityMatrix=false; - } - - inline void matrix4::setTextureScale ( f32 sx, f32 sy ) - { - M[0] = sx; - M[5] = sy; - definitelyIdentityMatrix=false; - } - - inline void matrix4::setTextureScaleCenter( f32 sx, f32 sy ) - { - M[0] = sx; - M[2] = -0.5f * sx + 0.5f; - M[5] = sy; - M[6] = -0.5f * sy + 0.5f; - definitelyIdentityMatrix=false; - } - - //! Multiply by scalar. - inline matrix4 operator*(const f32 scalar, const matrix4& mat) - { - return mat*scalar; - } - - const matrix4 IdentityMatrix(matrix4::EM4CONST_IDENTITY); -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_MATRIX_H_INCLUDED__ +#define __IRR_MATRIX_H_INCLUDED__ + +#include "irrTypes.h" +#include "vector3d.h" +#include "vector2d.h" +#include "plane3d.h" +#include "aabbox3d.h" +#include "rect.h" +#include "irrString.h" + +namespace irr +{ +namespace core +{ + + //! 4x4 matrix. Mostly used as transformation matrix for 3d calculations. + /* Matrix4 is mainly used by the Irrlicht engine for doing transformations. + The matrix is a D3D style matrix, row major with translations in the 4th row. + */ + class matrix4 + { + public: + + //! Constructor Flags + enum eConstructor + { + EM4CONST_NOTHING = 0, + EM4CONST_COPY, + EM4CONST_IDENTITY, + EM4CONST_TRANSPOSED, + EM4CONST_INVERSE, + EM4CONST_INVERSE_TRANSPOSED + }; + + matrix4( eConstructor constructor = EM4CONST_IDENTITY ); + matrix4( const matrix4& other,eConstructor constructor = EM4CONST_COPY); + + //! Simple operator for directly accessing every element of the matrix. + f32& operator()(const s32 row, const s32 col) { definitelyIdentityMatrix=false; return M[ row * 4 + col ]; } + + //! Simple operator for directly accessing every element of the matrix. + const f32& operator()(const s32 row, const s32 col) const { return M[row * 4 + col]; } + + //! Simple operator for linearly accessing every element of the matrix. + f32& operator[](u32 index) { definitelyIdentityMatrix=false; return M[index]; } + + //! Simple operator for linearly accessing every element of the matrix. + const f32& operator[](u32 index) const { return M[index]; } + + //! Sets this matrix equal to the other matrix. + inline matrix4& operator=(const matrix4 &other); + + //! Sets all elements of this matrix to the value. + inline matrix4& operator=(const f32 scalar); + + //! Returns pointer to internal array + const f32* pointer() const { return M; } + f32* pointer() { definitelyIdentityMatrix=false; return M; } + + //! Returns true if other matrix is equal to this matrix. + bool operator==(const matrix4 &other) const; + + //! Returns true if other matrix is not equal to this matrix. + bool operator!=(const matrix4 &other) const; + + //! Add another matrix. + matrix4 operator+(const matrix4& other) const; + + //! Add another matrix. + matrix4& operator+=(const matrix4& other); + + //! Subtract another matrix. + matrix4 operator-(const matrix4& other) const; + + //! Subtract another matrix. + matrix4& operator-=(const matrix4& other); + + //! set this matrix to the product of two matrices + inline void setbyproduct(const matrix4& other_a,const matrix4& other_b ); + + //! set this matrix to the product of two matrices, no logical optimation + //! use it if you know you never have a identity matrix + void setbyproduct_nocheck(const matrix4& other_a,const matrix4& other_b ); + + //! Multiply by another matrix. + matrix4 operator*(const matrix4& other) const; + + //! Multiply by another matrix. + matrix4& operator*=(const matrix4& other); + + //! Multiply by scalar. + matrix4 operator*(const f32 scalar) const; + + //! Multiply by scalar. + matrix4& operator*=(const f32 scalar); + + //! Set matrix to identity. + inline void makeIdentity(); + + //! Returns true if the matrix is the identity matrix + inline bool isIdentity() const; + + //! Returns true if the matrix is the identity matrix + bool isIdentity_integer_base () const; + + //! Set the translation of the current matrix. Will erase any previous values. + void setTranslation( const vector3df& translation ); + + //! Gets the current translation + vector3df getTranslation() const; + + //! Set the inverse translation of the current matrix. Will erase any previous values. + void setInverseTranslation( const vector3df& translation ); + + //! Make a rotation matrix from Euler angles. The 4th row and column are unmodified. + inline void setRotationRadians( const vector3df& rotation ); + + //! Make a rotation matrix from Euler angles. The 4th row and column are unmodified. + void setRotationDegrees( const vector3df& rotation ); + + //! Returns the rotation, as set by setRotation(). This code was orginally written by by Chev. + core::vector3df getRotationDegrees() const; + + //! Make an inverted rotation matrix from Euler angles. The 4th row and column are unmodified. + inline void setInverseRotationRadians( const vector3df& rotation ); + + //! Make an inverted rotation matrix from Euler angles. The 4th row and column are unmodified. + void setInverseRotationDegrees( const vector3df& rotation ); + + //! Set Scale + void setScale( const vector3df& scale ); + + //! Get Scale + core::vector3df getScale() const; + + //! Translate a vector by the inverse of the translation part of this matrix. + void inverseTranslateVect( vector3df& vect ) const; + + //! Rotate a vector by the inverse of the rotation part of this matrix. + void inverseRotateVect( vector3df& vect ) const; + + //! Rotate a vector by the rotation part of this matrix. + void rotateVect( vector3df& vect ) const; + + //! Transforms the vector by this matrix + void transformVect( vector3df& vect) const; + + //! Transforms input vector by this matrix and stores result in output vector + void transformVect( vector3df& out, const vector3df& in ) const; + + //! An alternate transform vector method, writing into an array of 4 floats + void transformVect(f32 *out,const core::vector3df &in) const; + + //! An alternate transform vector method, writing into an array of 3 floats + void rotateVect(f32 *out,const core::vector3df &in) const; + + //! Translate a vector by the translation part of this matrix. + void translateVect( vector3df& vect ) const; + + //! Transforms a plane by this matrix + void transformPlane( core::plane3d &plane) const; + + //! Transforms a plane by this matrix ( some problems to solve..) + void transformPlane_new( core::plane3d &plane) const; + + //! Transforms a plane by this matrix + void transformPlane( const core::plane3d &in, core::plane3d &out) const; + + //! Transforms a axis aligned bounding box + /** The result box of this operation may not be very accurate. For + accurate results, use transformBoxEx() */ + void transformBox(core::aabbox3d& box) const; + + //! Transforms a axis aligned bounding box more accurately than transformBox() + /** The result box of this operation should by quite accurate, but this operation + is slower than transformBox(). */ + void transformBoxEx(core::aabbox3d& box) const; + + //! Multiplies this matrix by a 1x4 matrix + void multiplyWith1x4Matrix(f32* matrix) const; + + //! Calculates inverse of matrix. Slow. + //! \return Returns false if there is no inverse matrix. + bool makeInverse(); + + + //! Inverts a primitive matrix which only contains a translation and a rotation + //! \param out: where result matrix is written to. + bool getInversePrimitive ( matrix4& out ) const; + + //! returns the inversed matrix of this one + //! \param out: where result matrix is written to. + //! \return Returns false if there is no inverse matrix. + bool getInverse(matrix4& out) const; + + //! Builds a right-handed perspective projection matrix based on a field of view + void buildProjectionMatrixPerspectiveFovRH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar); + + //! Builds a left-handed perspective projection matrix based on a field of view + void buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar); + + //! Builds a right-handed perspective projection matrix. + void buildProjectionMatrixPerspectiveRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); + + //! Builds a left-handed perspective projection matrix. + void buildProjectionMatrixPerspectiveLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); + + //! Builds a left-handed orthogonal projection matrix. + void buildProjectionMatrixOrthoLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); + + //! Builds a right-handed orthogonal projection matrix. + void buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); + + //! Builds a left-handed look-at matrix. + void buildCameraLookAtMatrixLH(const vector3df& position, const vector3df& target, const vector3df& upVector); + + //! Builds a right-handed look-at matrix. + void buildCameraLookAtMatrixRH(const vector3df& position, const vector3df& target, const vector3df& upVector); + + //! Builds a matrix that flattens geometry into a plane. + //! \param light: light source + //! \param plane: plane into which the geometry if flattened into + //! \param point: value between 0 and 1, describing the light source. + //! If this is 1, it is a point light, if it is 0, it is a directional light. + void buildShadowMatrix(const core::vector3df& light, core::plane3df plane, f32 point=1.0f); + + //! Builds a matrix which transforms a normalized Device Coordinate to Device Coordinates. + /** Used to scale <-1,-1><1,1> to viewport, for example from von <-1,-1> <1,1> to the viewport <0,0><0,640> */ + void buildNDCToDCMatrix( const core::rect& area, f32 zScale); + + //! creates a new matrix as interpolated matrix from two other ones. + //! \param b: other matrix to interpolate with + //! \param time: Must be a value between 0 and 1. + matrix4 interpolate(const core::matrix4& b, f32 time) const; + + //! returns transposed matrix + matrix4 getTransposed() const; + + //! returns transposed matrix to a plain 4x4 float matrix + inline void getTransposed( matrix4& dest ) const; + + /*! + construct 2D Texture transformations + rotate about center, scale, and transform. + */ + void setTextureScale ( f32 sx, f32 sy ); + + void setTextureRotationCenter( f32 radAngle ); + void setTextureScaleCenter( f32 sx, f32 sy ); + + void setTextureTranslate ( f32 x, f32 y ); + + void buildTextureTransform( f32 rotateRad, + const core::vector2df &rotatecenter, + const core::vector2df &translate, + const core::vector2df &scale); + + private: + //! Matrix data, stored in row-major order + f32 M[16]; + bool definitelyIdentityMatrix; + }; + + inline matrix4::matrix4( matrix4::eConstructor constructor ) : definitelyIdentityMatrix(false) + { + switch ( constructor ) + { + case EM4CONST_NOTHING: + case EM4CONST_COPY: + break; + case EM4CONST_IDENTITY: + case EM4CONST_INVERSE: + default: + makeIdentity(); + break; + } + } + + inline matrix4::matrix4( const matrix4& other,matrix4::eConstructor constructor) : definitelyIdentityMatrix(false) + { + switch ( constructor ) + { + case EM4CONST_IDENTITY: + makeIdentity(); + break; + case EM4CONST_NOTHING: + break; + case EM4CONST_COPY: + *this = other; + break; + case EM4CONST_TRANSPOSED: + other.getTransposed(*this); + break; + case EM4CONST_INVERSE: + if (!other.getInverse(*this)) + memset(M, 0, 16*sizeof(f32)); + break; + case EM4CONST_INVERSE_TRANSPOSED: + if (!other.getInverse(*this)) + memset(M, 0, 16*sizeof(f32)); + else + *this=getTransposed(); + break; + } + } + + //! Add another matrix. + inline matrix4 matrix4::operator+(const matrix4& other) const + { + matrix4 temp ( EM4CONST_NOTHING ); + + temp[0] = M[0]+other[0]; + temp[1] = M[1]+other[1]; + temp[2] = M[2]+other[2]; + temp[3] = M[3]+other[3]; + temp[4] = M[4]+other[4]; + temp[5] = M[5]+other[5]; + temp[6] = M[6]+other[6]; + temp[7] = M[7]+other[7]; + temp[8] = M[8]+other[8]; + temp[9] = M[9]+other[9]; + temp[10] = M[10]+other[10]; + temp[11] = M[11]+other[11]; + temp[12] = M[12]+other[12]; + temp[13] = M[13]+other[13]; + temp[14] = M[14]+other[14]; + temp[15] = M[15]+other[15]; + + return temp; + } + + //! Add another matrix. + inline matrix4& matrix4::operator+=(const matrix4& other) + { + M[0]+=other[0]; + M[1]+=other[1]; + M[2]+=other[2]; + M[3]+=other[3]; + M[4]+=other[4]; + M[5]+=other[5]; + M[6]+=other[6]; + M[7]+=other[7]; + M[8]+=other[8]; + M[9]+=other[9]; + M[10]+=other[10]; + M[11]+=other[11]; + M[12]+=other[12]; + M[13]+=other[13]; + M[14]+=other[14]; + M[15]+=other[15]; + + return *this; + matrix4 temp ( *this ); + setbyproduct ( temp, other ); + return *this; + } + + //! Subtract another matrix. + inline matrix4 matrix4::operator-(const matrix4& other) const + { + matrix4 temp ( EM4CONST_NOTHING ); + + temp[0] = M[0]-other[0]; + temp[1] = M[1]-other[1]; + temp[2] = M[2]-other[2]; + temp[3] = M[3]-other[3]; + temp[4] = M[4]-other[4]; + temp[5] = M[5]-other[5]; + temp[6] = M[6]-other[6]; + temp[7] = M[7]-other[7]; + temp[8] = M[8]-other[8]; + temp[9] = M[9]-other[9]; + temp[10] = M[10]-other[10]; + temp[11] = M[11]-other[11]; + temp[12] = M[12]-other[12]; + temp[13] = M[13]-other[13]; + temp[14] = M[14]-other[14]; + temp[15] = M[15]-other[15]; + + return temp; + } + + //! Subtract another matrix. + inline matrix4& matrix4::operator-=(const matrix4& other) + { + M[0]-=other[0]; + M[1]-=other[1]; + M[2]-=other[2]; + M[3]-=other[3]; + M[4]-=other[4]; + M[5]-=other[5]; + M[6]-=other[6]; + M[7]-=other[7]; + M[8]-=other[8]; + M[9]-=other[9]; + M[10]-=other[10]; + M[11]-=other[11]; + M[12]-=other[12]; + M[13]-=other[13]; + M[14]-=other[14]; + M[15]-=other[15]; + + return *this; + } + + //! Multiply by scalar. + inline matrix4 matrix4::operator*(const f32 scalar) const + { + matrix4 temp ( EM4CONST_NOTHING ); + + temp[0] = M[0]*scalar; + temp[1] = M[1]*scalar; + temp[2] = M[2]*scalar; + temp[3] = M[3]*scalar; + temp[4] = M[4]*scalar; + temp[5] = M[5]*scalar; + temp[6] = M[6]*scalar; + temp[7] = M[7]*scalar; + temp[8] = M[8]*scalar; + temp[9] = M[9]*scalar; + temp[10] = M[10]*scalar; + temp[11] = M[11]*scalar; + temp[12] = M[12]*scalar; + temp[13] = M[13]*scalar; + temp[14] = M[14]*scalar; + temp[15] = M[15]*scalar; + + return temp; + } + + //! Multiply by scalar. + inline matrix4& matrix4::operator*=(const f32 scalar) + { + M[0]*=scalar; + M[1]*=scalar; + M[2]*=scalar; + M[3]*=scalar; + M[4]*=scalar; + M[5]*=scalar; + M[6]*=scalar; + M[7]*=scalar; + M[8]*=scalar; + M[9]*=scalar; + M[10]*=scalar; + M[11]*=scalar; + M[12]*=scalar; + M[13]*=scalar; + M[14]*=scalar; + M[15]*=scalar; + + return *this; + } + + //! Multiply by another matrix. + inline matrix4& matrix4::operator*=(const matrix4& other) + { + matrix4 temp ( *this ); + setbyproduct ( temp, other ); + return *this; + } + + //! multiply by another matrix + // set this matrix to the product of two other matrices + // goal is to reduce stack use and copy + inline void matrix4::setbyproduct_nocheck(const matrix4& other_a,const matrix4& other_b ) + { + const f32 *m1 = other_a.M; + const f32 *m2 = other_b.M; + + M[0] = m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2] + m1[12]*m2[3]; + M[1] = m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2] + m1[13]*m2[3]; + M[2] = m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2] + m1[14]*m2[3]; + M[3] = m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2] + m1[15]*m2[3]; + + M[4] = m1[0]*m2[4] + m1[4]*m2[5] + m1[8]*m2[6] + m1[12]*m2[7]; + M[5] = m1[1]*m2[4] + m1[5]*m2[5] + m1[9]*m2[6] + m1[13]*m2[7]; + M[6] = m1[2]*m2[4] + m1[6]*m2[5] + m1[10]*m2[6] + m1[14]*m2[7]; + M[7] = m1[3]*m2[4] + m1[7]*m2[5] + m1[11]*m2[6] + m1[15]*m2[7]; + + M[8] = m1[0]*m2[8] + m1[4]*m2[9] + m1[8]*m2[10] + m1[12]*m2[11]; + M[9] = m1[1]*m2[8] + m1[5]*m2[9] + m1[9]*m2[10] + m1[13]*m2[11]; + M[10] = m1[2]*m2[8] + m1[6]*m2[9] + m1[10]*m2[10] + m1[14]*m2[11]; + M[11] = m1[3]*m2[8] + m1[7]*m2[9] + m1[11]*m2[10] + m1[15]*m2[11]; + + M[12] = m1[0]*m2[12] + m1[4]*m2[13] + m1[8]*m2[14] + m1[12]*m2[15]; + M[13] = m1[1]*m2[12] + m1[5]*m2[13] + m1[9]*m2[14] + m1[13]*m2[15]; + M[14] = m1[2]*m2[12] + m1[6]*m2[13] + m1[10]*m2[14] + m1[14]*m2[15]; + M[15] = m1[3]*m2[12] + m1[7]*m2[13] + m1[11]*m2[14] + m1[15]*m2[15]; + definitelyIdentityMatrix=false; + } + + + //! multiply by another matrix + // set this matrix to the product of two other matrices + // goal is to reduce stack use and copy + inline void matrix4::setbyproduct(const matrix4& other_a,const matrix4& other_b ) + { + if ( other_a.isIdentity () ) + { + *this = other_b; + return; + } + else + if ( other_b.isIdentity () ) + { + *this = other_a; + return; + } + setbyproduct_nocheck(other_a,other_b); + } + + //! multiply by another matrix + inline matrix4 matrix4::operator*(const matrix4& m2) const + { + // Testing purpose.. + if ( this->isIdentity() ) + return m2; + if ( m2.isIdentity() ) + return *this; + + matrix4 m3 ( EM4CONST_NOTHING ); + + const f32 *m1 = M; + + m3[0] = m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2] + m1[12]*m2[3]; + m3[1] = m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2] + m1[13]*m2[3]; + m3[2] = m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2] + m1[14]*m2[3]; + m3[3] = m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2] + m1[15]*m2[3]; + + m3[4] = m1[0]*m2[4] + m1[4]*m2[5] + m1[8]*m2[6] + m1[12]*m2[7]; + m3[5] = m1[1]*m2[4] + m1[5]*m2[5] + m1[9]*m2[6] + m1[13]*m2[7]; + m3[6] = m1[2]*m2[4] + m1[6]*m2[5] + m1[10]*m2[6] + m1[14]*m2[7]; + m3[7] = m1[3]*m2[4] + m1[7]*m2[5] + m1[11]*m2[6] + m1[15]*m2[7]; + + m3[8] = m1[0]*m2[8] + m1[4]*m2[9] + m1[8]*m2[10] + m1[12]*m2[11]; + m3[9] = m1[1]*m2[8] + m1[5]*m2[9] + m1[9]*m2[10] + m1[13]*m2[11]; + m3[10] = m1[2]*m2[8] + m1[6]*m2[9] + m1[10]*m2[10] + m1[14]*m2[11]; + m3[11] = m1[3]*m2[8] + m1[7]*m2[9] + m1[11]*m2[10] + m1[15]*m2[11]; + + m3[12] = m1[0]*m2[12] + m1[4]*m2[13] + m1[8]*m2[14] + m1[12]*m2[15]; + m3[13] = m1[1]*m2[12] + m1[5]*m2[13] + m1[9]*m2[14] + m1[13]*m2[15]; + m3[14] = m1[2]*m2[12] + m1[6]*m2[13] + m1[10]*m2[14] + m1[14]*m2[15]; + m3[15] = m1[3]*m2[12] + m1[7]*m2[13] + m1[11]*m2[14] + m1[15]*m2[15]; + return m3; + } + + + + inline vector3df matrix4::getTranslation() const + { + return vector3df(M[12], M[13], M[14]); + } + + + inline void matrix4::setTranslation( const vector3df& translation ) + { + M[12] = translation.X; + M[13] = translation.Y; + M[14] = translation.Z; + definitelyIdentityMatrix=false; + } + + inline void matrix4::setInverseTranslation( const vector3df& translation ) + { + M[12] = -translation.X; + M[13] = -translation.Y; + M[14] = -translation.Z; + definitelyIdentityMatrix=false; + } + + inline void matrix4::setScale( const vector3df& scale ) + { + M[0] = scale.X; + M[5] = scale.Y; + M[10] = scale.Z; + definitelyIdentityMatrix=false; + } + + inline vector3df matrix4::getScale() const + { + return vector3df(M[0],M[5],M[10]); + } + + inline void matrix4::setRotationDegrees( const vector3df& rotation ) + { + setRotationRadians( rotation * core::DEGTORAD ); + } + + inline void matrix4::setInverseRotationDegrees( const vector3df& rotation ) + { + setInverseRotationRadians( rotation * core::DEGTORAD ); + } + + inline void matrix4::setRotationRadians( const vector3df& rotation ) + { + f64 cr = cos( rotation.X ); + f64 sr = sin( rotation.X ); + f64 cp = cos( rotation.Y ); + f64 sp = sin( rotation.Y ); + f64 cy = cos( rotation.Z ); + f64 sy = sin( rotation.Z ); + + M[0] = (f32)( cp*cy ); + M[1] = (f32)( cp*sy ); + M[2] = (f32)( -sp ); + + f64 srsp = sr*sp; + f64 crsp = cr*sp; + + M[4] = (f32)( srsp*cy-cr*sy ); + M[5] = (f32)( srsp*sy+cr*cy ); + M[6] = (f32)( sr*cp ); + + M[8] = (f32)( crsp*cy+sr*sy ); + M[9] = (f32)( crsp*sy-sr*cy ); + M[10] = (f32)( cr*cp ); + definitelyIdentityMatrix=false; + } + + + + //! Returns the rotation, as set by setRotation(). This code was sent + //! in by Chev. + inline core::vector3df matrix4::getRotationDegrees() const + { + const matrix4 &mat = *this; + + f64 Y = -asin(mat(0,2)); + f64 C = cos(Y); + Y *= RADTODEG64; + + f64 rotx, roty, X, Z; + + if (fabs(C)>0.0005f) + { + rotx = mat(2,2) / C; + roty = mat(1,2) / C; + X = atan2( roty, rotx ) * RADTODEG64; + rotx = mat(0,0) / C; + roty = mat(0,1) / C; + Z = atan2( roty, rotx ) * RADTODEG64; + } + else + { + X = 0.0f; + rotx = mat(1,1); + roty = -mat(1,0); + Z = atan2( roty, rotx ) * RADTODEG64; + } + + // fix values that get below zero + // before it would set (!) values to 360 + // that where above 360: + if (X < 0.0) X += 360.0; + if (Y < 0.0) Y += 360.0; + if (Z < 0.0) Z += 360.0; + + return vector3df((f32)X,(f32)Y,(f32)Z); + } + + inline void matrix4::setInverseRotationRadians( const vector3df& rotation ) + { + f64 cr = cos( rotation.X ); + f64 sr = sin( rotation.X ); + f64 cp = cos( rotation.Y ); + f64 sp = sin( rotation.Y ); + f64 cy = cos( rotation.Z ); + f64 sy = sin( rotation.Z ); + + M[0] = (f32)( cp*cy ); + M[4] = (f32)( cp*sy ); + M[8] = (f32)( -sp ); + + f64 srsp = sr*sp; + f64 crsp = cr*sp; + + M[1] = (f32)( srsp*cy-cr*sy ); + M[5] = (f32)( srsp*sy+cr*cy ); + M[9] = (f32)( sr*cp ); + + M[2] = (f32)( crsp*cy+sr*sy ); + M[6] = (f32)( crsp*sy-sr*cy ); + M[10] = (f32)( cr*cp ); + definitelyIdentityMatrix=false; + } + + + /*! + */ + inline void matrix4::makeIdentity() + { + memset(M, 0, 16*sizeof(f32)); + M[0] = M[5] = M[10] = M[15] = 1.0f; + definitelyIdentityMatrix=true; + } + + + /* + check identity with epsilon + solve floating range problems.. + */ + inline bool matrix4::isIdentity() const + { + if (definitelyIdentityMatrix) + return true; + if ( !equals ( M[ 0], 1.f ) || + !equals ( M[ 5], 1.f ) || + !equals ( M[10], 1.f ) || + !equals ( M[15], 1.f ) + ) + return false; + + for (s32 i=0; i<4; ++i) + for (s32 j=0; j<4; ++j) + if (j != i) + { + if ((*this)(i,j) < -ROUNDING_ERROR_32|| + (*this)(i,j) > ROUNDING_ERROR_32) + return false; + } + return true; + } + + /* + doesn't solve floating range problems.. + but takes care on +/- 0 on translation because we are changing it.. + reducing floating point branches + but it need's the floats in memory.. + */ + inline bool matrix4::isIdentity_integer_base() const + { + if (definitelyIdentityMatrix) + return true; + if(IR(M[0])!=F32_VALUE_1) return false; + if(IR(M[1])!=0) return false; + if(IR(M[2])!=0) return false; + if(IR(M[3])!=0) return false; + + if(IR(M[4])!=0) return false; + if(IR(M[5])!=F32_VALUE_1) return false; + if(IR(M[6])!=0) return false; + if(IR(M[7])!=0) return false; + + if(IR(M[8])!=0) return false; + if(IR(M[9])!=0) return false; + if(IR(M[10])!=F32_VALUE_1) return false; + if(IR(M[11])!=0) return false; + + if(IR(M[12])!=0) return false; + if(IR(M[13])!=0) return false; + if(IR(M[13])!=0) return false; + if(IR(M[15])!=F32_VALUE_1) return false; + return true; + } + + + + inline void matrix4::rotateVect( vector3df& vect ) const + { + vector3df tmp = vect; + vect.X = tmp.X*M[0] + tmp.Y*M[4] + tmp.Z*M[8]; + vect.Y = tmp.X*M[1] + tmp.Y*M[5] + tmp.Z*M[9]; + vect.Z = tmp.X*M[2] + tmp.Y*M[6] + tmp.Z*M[10]; + } + + //! An alternate transform vector method, writing into an array of 3 floats + inline void matrix4::rotateVect(f32 *out,const core::vector3df &in) const + { + out[0] = in.X*M[0] + in.Y*M[4] + in.Z*M[8]; + out[1] = in.X*M[1] + in.Y*M[5] + in.Z*M[9]; + out[2] = in.X*M[2] + in.Y*M[6] + in.Z*M[10]; + } + + inline void matrix4::inverseRotateVect( vector3df& vect ) const + { + vector3df tmp = vect; + vect.X = tmp.X*M[0] + tmp.Y*M[1] + tmp.Z*M[2]; + vect.Y = tmp.X*M[4] + tmp.Y*M[5] + tmp.Z*M[6]; + vect.Z = tmp.X*M[8] + tmp.Y*M[9] + tmp.Z*M[10]; + } + + inline void matrix4::transformVect( vector3df& vect) const + { + f32 vector[3]; + + vector[0] = vect.X*M[0] + vect.Y*M[4] + vect.Z*M[8] + M[12]; + vector[1] = vect.X*M[1] + vect.Y*M[5] + vect.Z*M[9] + M[13]; + vector[2] = vect.X*M[2] + vect.Y*M[6] + vect.Z*M[10] + M[14]; + + vect.X = vector[0]; + vect.Y = vector[1]; + vect.Z = vector[2]; + } + + inline void matrix4::transformVect( vector3df& out, const vector3df& in) const + { + out.X = in.X*M[0] + in.Y*M[4] + in.Z*M[8] + M[12]; + out.Y = in.X*M[1] + in.Y*M[5] + in.Z*M[9] + M[13]; + out.Z = in.X*M[2] + in.Y*M[6] + in.Z*M[10] + M[14]; + } + + + // transform (x,y,z,1) + inline void matrix4::transformVect(f32 *out,const vector3df &in) const + { + out[0] = in.X*M[0] + in.Y*M[4] + in.Z*M[8] + M[12]; + out[1] = in.X*M[1] + in.Y*M[5] + in.Z*M[9] + M[13]; + out[2] = in.X*M[2] + in.Y*M[6] + in.Z*M[10] + M[14]; + out[3] = in.X*M[3] + in.Y*M[7] + in.Z*M[11] + M[15]; + } + + + //! Transforms a plane by this matrix + inline void matrix4::transformPlane( core::plane3d &plane) const + { + vector3df member; + transformVect(member, plane.getMemberPoint()); + + vector3df origin(0,0,0); + transformVect(plane.Normal); + transformVect(origin); + + plane.Normal -= origin; + plane.D = - member.dotProduct(plane.Normal); + } + + //! Transforms a plane by this matrix + inline void matrix4::transformPlane_new( core::plane3d &plane) const + { + // rotate normal -> rotateVect ( plane.n ); + vector3df n; + n.X = plane.Normal.X*M[0] + plane.Normal.Y*M[4] + plane.Normal.Z*M[8]; + n.Y = plane.Normal.X*M[1] + plane.Normal.Y*M[5] + plane.Normal.Z*M[9]; + n.Z = plane.Normal.X*M[2] + plane.Normal.Y*M[6] + plane.Normal.Z*M[10]; + + // compute new d. -> getTranslation(). dotproduct ( plane.n ) + plane.D -= M[12] * n.X + M[13] * n.Y + M[14] * n.Z; + plane.Normal.X = n.X; + plane.Normal.Y = n.Y; + plane.Normal.Z = n.Z; + } + + //! Transforms a plane by this matrix + inline void matrix4::transformPlane( const core::plane3d &in, core::plane3d &out) const + { + out = in; + transformPlane( out ); + } + + //! Transforms a axis aligned bounding box + inline void matrix4::transformBox(core::aabbox3d& box) const + { + if (isIdentity() ) + return; + + transformVect(box.MinEdge); + transformVect(box.MaxEdge); + box.repair(); + } + + //! Transforms a axis aligned bounding box more accurately than transformBox() + inline void matrix4::transformBoxEx(core::aabbox3d& box) const + { + f32 Amin[3]; + f32 Amax[3]; + f32 Bmin[3]; + f32 Bmax[3]; + + Amin[0] = box.MinEdge.X; + Amin[1] = box.MinEdge.Y; + Amin[2] = box.MinEdge.Z; + + Amax[0] = box.MaxEdge.X; + Amax[1] = box.MaxEdge.Y; + Amax[2] = box.MaxEdge.Z; + + Bmin[0] = Bmax[0] = M[12]; + Bmin[1] = Bmax[1] = M[13]; + Bmin[2] = Bmax[2] = M[14]; + + u32 i, j; + const matrix4 &m = *this; + + for (i = 0; i < 3; ++i) + { + for (j = 0; j < 3; ++j) + { + f32 a = m(j,i) * Amin[j]; + f32 b = m(j,i) * Amax[j]; + + if (a < b) + { + Bmin[i] += a; + Bmax[i] += b; + } + else + { + Bmin[i] += b; + Bmax[i] += a; + } + } + } + + box.MinEdge.X = Bmin[0]; + box.MinEdge.Y = Bmin[1]; + box.MinEdge.Z = Bmin[2]; + + box.MaxEdge.X = Bmax[0]; + box.MaxEdge.Y = Bmax[1]; + box.MaxEdge.Z = Bmax[2]; + } + + + //! Multiplies this matrix by a 1x4 matrix + inline void matrix4::multiplyWith1x4Matrix(f32* matrix) const + { + /* + 0 1 2 3 + 4 5 6 7 + 8 9 10 11 + 12 13 14 15 + */ + + f32 mat[4]; + mat[0] = matrix[0]; + mat[1] = matrix[1]; + mat[2] = matrix[2]; + mat[3] = matrix[3]; + + matrix[0] = M[0]*mat[0] + M[4]*mat[1] + M[8]*mat[2] + M[12]*mat[3]; + matrix[1] = M[1]*mat[0] + M[5]*mat[1] + M[9]*mat[2] + M[13]*mat[3]; + matrix[2] = M[2]*mat[0] + M[6]*mat[1] + M[10]*mat[2] + M[14]*mat[3]; + matrix[3] = M[3]*mat[0] + M[7]*mat[1] + M[11]*mat[2] + M[15]*mat[3]; + } + + inline void matrix4::inverseTranslateVect( vector3df& vect ) const + { + vect.X = vect.X-M[12]; + vect.Y = vect.Y-M[13]; + vect.Z = vect.Z-M[14]; + } + + inline void matrix4::translateVect( vector3df& vect ) const + { + vect.X = vect.X+M[12]; + vect.Y = vect.Y+M[13]; + vect.Z = vect.Z+M[14]; + } + + + inline bool matrix4::getInverse(matrix4& out) const + { + /// Calculates the inverse of this Matrix + /// The inverse is calculated using Cramers rule. + /// If no inverse exists then 'false' is returned. + + const matrix4 &m = *this; + + f32 d = (m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0)) * (m(2, 2) * m(3, 3) - m(2, 3) * m(3, 2)) - + (m(0, 0) * m(1, 2) - m(0, 2) * m(1, 0)) * (m(2, 1) * m(3, 3) - m(2, 3) * m(3, 1)) + + (m(0, 0) * m(1, 3) - m(0, 3) * m(1, 0)) * (m(2, 1) * m(3, 2) - m(2, 2) * m(3, 1)) + + (m(0, 1) * m(1, 2) - m(0, 2) * m(1, 1)) * (m(2, 0) * m(3, 3) - m(2, 3) * m(3, 0)) - + (m(0, 1) * m(1, 3) - m(0, 3) * m(1, 1)) * (m(2, 0) * m(3, 2) - m(2, 2) * m(3, 0)) + + (m(0, 2) * m(1, 3) - m(0, 3) * m(1, 2)) * (m(2, 0) * m(3, 1) - m(2, 1) * m(3, 0)); + + if( core::iszero ( d ) ) + return false; + + d = core::reciprocal ( d ); + + out(0, 0) = d * (m(1, 1) * (m(2, 2) * m(3, 3) - m(2, 3) * m(3, 2)) + m(1, 2) * (m(2, 3) * m(3, 1) - m(2, 1) * m(3, 3)) + m(1, 3) * (m(2, 1) * m(3, 2) - m(2, 2) * m(3, 1))); + out(0, 1) = d * (m(2, 1) * (m(0, 2) * m(3, 3) - m(0, 3) * m(3, 2)) + m(2, 2) * (m(0, 3) * m(3, 1) - m(0, 1) * m(3, 3)) + m(2, 3) * (m(0, 1) * m(3, 2) - m(0, 2) * m(3, 1))); + out(0, 2) = d * (m(3, 1) * (m(0, 2) * m(1, 3) - m(0, 3) * m(1, 2)) + m(3, 2) * (m(0, 3) * m(1, 1) - m(0, 1) * m(1, 3)) + m(3, 3) * (m(0, 1) * m(1, 2) - m(0, 2) * m(1, 1))); + out(0, 3) = d * (m(0, 1) * (m(1, 3) * m(2, 2) - m(1, 2) * m(2, 3)) + m(0, 2) * (m(1, 1) * m(2, 3) - m(1, 3) * m(2, 1)) + m(0, 3) * (m(1, 2) * m(2, 1) - m(1, 1) * m(2, 2))); + out(1, 0) = d * (m(1, 2) * (m(2, 0) * m(3, 3) - m(2, 3) * m(3, 0)) + m(1, 3) * (m(2, 2) * m(3, 0) - m(2, 0) * m(3, 2)) + m(1, 0) * (m(2, 3) * m(3, 2) - m(2, 2) * m(3, 3))); + out(1, 1) = d * (m(2, 2) * (m(0, 0) * m(3, 3) - m(0, 3) * m(3, 0)) + m(2, 3) * (m(0, 2) * m(3, 0) - m(0, 0) * m(3, 2)) + m(2, 0) * (m(0, 3) * m(3, 2) - m(0, 2) * m(3, 3))); + out(1, 2) = d * (m(3, 2) * (m(0, 0) * m(1, 3) - m(0, 3) * m(1, 0)) + m(3, 3) * (m(0, 2) * m(1, 0) - m(0, 0) * m(1, 2)) + m(3, 0) * (m(0, 3) * m(1, 2) - m(0, 2) * m(1, 3))); + out(1, 3) = d * (m(0, 2) * (m(1, 3) * m(2, 0) - m(1, 0) * m(2, 3)) + m(0, 3) * (m(1, 0) * m(2, 2) - m(1, 2) * m(2, 0)) + m(0, 0) * (m(1, 2) * m(2, 3) - m(1, 3) * m(2, 2))); + out(2, 0) = d * (m(1, 3) * (m(2, 0) * m(3, 1) - m(2, 1) * m(3, 0)) + m(1, 0) * (m(2, 1) * m(3, 3) - m(2, 3) * m(3, 1)) + m(1, 1) * (m(2, 3) * m(3, 0) - m(2, 0) * m(3, 3))); + out(2, 1) = d * (m(2, 3) * (m(0, 0) * m(3, 1) - m(0, 1) * m(3, 0)) + m(2, 0) * (m(0, 1) * m(3, 3) - m(0, 3) * m(3, 1)) + m(2, 1) * (m(0, 3) * m(3, 0) - m(0, 0) * m(3, 3))); + out(2, 2) = d * (m(3, 3) * (m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0)) + m(3, 0) * (m(0, 1) * m(1, 3) - m(0, 3) * m(1, 1)) + m(3, 1) * (m(0, 3) * m(1, 0) - m(0, 0) * m(1, 3))); + out(2, 3) = d * (m(0, 3) * (m(1, 1) * m(2, 0) - m(1, 0) * m(2, 1)) + m(0, 0) * (m(1, 3) * m(2, 1) - m(1, 1) * m(2, 3)) + m(0, 1) * (m(1, 0) * m(2, 3) - m(1, 3) * m(2, 0))); + out(3, 0) = d * (m(1, 0) * (m(2, 2) * m(3, 1) - m(2, 1) * m(3, 2)) + m(1, 1) * (m(2, 0) * m(3, 2) - m(2, 2) * m(3, 0)) + m(1, 2) * (m(2, 1) * m(3, 0) - m(2, 0) * m(3, 1))); + out(3, 1) = d * (m(2, 0) * (m(0, 2) * m(3, 1) - m(0, 1) * m(3, 2)) + m(2, 1) * (m(0, 0) * m(3, 2) - m(0, 2) * m(3, 0)) + m(2, 2) * (m(0, 1) * m(3, 0) - m(0, 0) * m(3, 1))); + out(3, 2) = d * (m(3, 0) * (m(0, 2) * m(1, 1) - m(0, 1) * m(1, 2)) + m(3, 1) * (m(0, 0) * m(1, 2) - m(0, 2) * m(1, 0)) + m(3, 2) * (m(0, 1) * m(1, 0) - m(0, 0) * m(1, 1))); + out(3, 3) = d * (m(0, 0) * (m(1, 1) * m(2, 2) - m(1, 2) * m(2, 1)) + m(0, 1) * (m(1, 2) * m(2, 0) - m(1, 0) * m(2, 2)) + m(0, 2) * (m(1, 0) * m(2, 1) - m(1, 1) * m(2, 0))); + out.definitelyIdentityMatrix = definitelyIdentityMatrix; + return true; + } + + + //! Inverts a primitive matrix which only contains a translation and a rotation + //! \param out: where result matrix is written to. + inline bool matrix4::getInversePrimitive ( matrix4& out ) const + { + out.M[0 ] = M[0]; + out.M[1 ] = M[4]; + out.M[2 ] = M[8]; + out.M[3 ] = 0.0f; + + out.M[4 ] = M[1]; + out.M[5 ] = M[5]; + out.M[6 ] = M[9]; + out.M[7 ] = 0.0f; + + out.M[8 ] = M[2]; + out.M[9 ] = M[6]; + out.M[10] = M[10]; + out.M[11] = 0.0f; + + out.M[12] = -(M[12]*M[0] + M[13]*M[1] + M[14]*M[2]); + out.M[13] = -(M[12]*M[4] + M[13]*M[5] + M[14]*M[6]); + out.M[14] = -(M[12]*M[8] + M[13]*M[9] + M[14]*M[10]); + out.M[15] = 1.0f; + out.definitelyIdentityMatrix = definitelyIdentityMatrix; + return true; + } + + /*! + */ + inline bool matrix4::makeInverse() + { + matrix4 temp ( EM4CONST_NOTHING ); + + if (getInverse(temp)) + { + *this = temp; + return true; + } + + return false; + } + + + + inline matrix4& matrix4::operator=(const matrix4 &other) + { + if (this==&other) + return *this; + memcpy(M, other.M, 16*sizeof(f32)); + definitelyIdentityMatrix=other.definitelyIdentityMatrix; + return *this; + } + + + + inline bool matrix4::operator==(const matrix4 &other) const + { + if (definitelyIdentityMatrix && other.definitelyIdentityMatrix) + return true; + for (s32 i = 0; i < 16; ++i) + if (M[i] != other.M[i]) + return false; + + return true; + } + + + + inline bool matrix4::operator!=(const matrix4 &other) const + { + return !(*this == other); + } + + + + //! Builds a right-handed perspective projection matrix based on a field of view + inline void matrix4::buildProjectionMatrixPerspectiveFovRH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar) + { + f32 h = (f32)(1.0/tan(fieldOfViewRadians/2.0)); + f32 w = h / aspectRatio; + + M[0] = w; + M[1] = 0.0f; + M[2] = 0.0f; + M[3] = 0.0f; + + M[4] = 0.0f; + M[5] = h; + M[6] = 0.0f; + M[7] = 0.0f; + + M[8] = 0.0f; + M[9] = 0.0f; + M[10] = zFar/(zNear-zFar); // DirectX version +// M[10] = zFar+zNear/(zNear-zFar); // OpenGL version + M[11] = -1.0f; + + M[12] = 0.0f; + M[13] = 0.0f; + M[14] = zNear*zFar/(zNear-zFar); // DirectX version +// M[14] = 2.0f*zNear*zFar/(zNear-zFar); // OpenGL version + M[15] = 0.0f; + definitelyIdentityMatrix=false; + } + + + + //! Builds a left-handed perspective projection matrix based on a field of view + inline void matrix4::buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar) + { + f32 h = (f32)(1.0/tan(fieldOfViewRadians/2.0)); + f32 w = h / aspectRatio; + + M[0] = w; + M[1] = 0.0f; + M[2] = 0.0f; + M[3] = 0.0f; + + M[4] = 0.0f; + M[5] = h; + M[6] = 0.0f; + M[7] = 0.0f; + + M[8] = 0.0f; + M[9] = 0.0f; + M[10] = zFar/(zFar-zNear); + M[11] = 1.0f; + + M[12] = 0.0f; + M[13] = 0.0f; + M[14] = -zNear*zFar/(zFar-zNear); + M[15] = 0.0f; + definitelyIdentityMatrix=false; + } + + + + //! Builds a left-handed orthogonal projection matrix. + inline void matrix4::buildProjectionMatrixOrthoLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) + { + M[0] = 2/widthOfViewVolume; + M[1] = 0; + M[2] = 0; + M[3] = 0; + + M[4] = 0; + M[5] = 2/heightOfViewVolume; + M[6] = 0; + M[7] = 0; + + M[8] = 0; + M[9] = 0; + M[10] = 1/(zFar-zNear); + M[11] = 0; + + M[12] = 0; + M[13] = 0; + M[14] = zNear/(zNear-zFar); + M[15] = 1; + definitelyIdentityMatrix=false; + } + + + + //! Builds a right-handed orthogonal projection matrix. + inline void matrix4::buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) + { + M[0] = 2/widthOfViewVolume; + M[1] = 0; + M[2] = 0; + M[3] = 0; + + M[4] = 0; + M[5] = 2/heightOfViewVolume; + M[6] = 0; + M[7] = 0; + + M[8] = 0; + M[9] = 0; + M[10] = 1/(zNear-zFar); + M[11] = 0; + + M[12] = 0; + M[13] = 0; + M[14] = zNear/(zNear-zFar); + M[15] = -1; + definitelyIdentityMatrix=false; + } + + + //! Builds a right-handed perspective projection matrix. + inline void matrix4::buildProjectionMatrixPerspectiveRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) + { + M[0] = 2*zNear/widthOfViewVolume; + M[1] = 0; + M[2] = 0; + M[3] = 0; + + M[4] = 0; + M[5] = 2*zNear/heightOfViewVolume; + M[6] = 0; + M[7] = 0; + + M[8] = 0; + M[9] = 0; + M[10] = zFar/(zNear-zFar); + M[11] = -1; + + M[12] = 0; + M[13] = 0; + M[14] = zNear*zFar/(zNear-zFar); + M[15] = 0; + definitelyIdentityMatrix=false; + } + + + //! Builds a left-handed perspective projection matrix. + inline void matrix4::buildProjectionMatrixPerspectiveLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) + { + M[0] = 2*zNear/widthOfViewVolume; + M[1] = 0; + M[2] = 0; + M[3] = 0; + + M[4] = 0; + M[5] = 2*zNear/heightOfViewVolume; + M[6] = 0; + M[7] = 0; + + M[8] = 0; + M[9] = 0; + M[10] = zFar/(zFar-zNear); + M[11] = 1; + + M[12] = 0; + M[13] = 0; + M[14] = zNear*zFar/(zNear-zFar); + M[15] = 0; + definitelyIdentityMatrix=false; + } + + + //! Builds a matrix that flattens geometry into a plane. + inline void matrix4::buildShadowMatrix(const core::vector3df& light, core::plane3df plane, f32 point) + { + plane.Normal.normalize(); + f32 d = plane.Normal.dotProduct(light); + + M[ 0] = -plane.Normal.X * light.X + d; + M[ 1] = -plane.Normal.X * light.Y; + M[ 2] = -plane.Normal.X * light.Z; + M[ 3] = -plane.Normal.X * point; + + M[ 4] = -plane.Normal.Y * light.X; + M[ 5] = -plane.Normal.Y * light.Y + d; + M[ 6] = -plane.Normal.Y * light.Z; + M[ 7] = -plane.Normal.Y * point; + + M[ 8] = -plane.Normal.Z * light.X; + M[ 9] = -plane.Normal.Z * light.Y; + M[10] = -plane.Normal.Z * light.Z + d; + M[11] = -plane.Normal.Z * point; + + M[12] = -plane.D * light.X; + M[13] = -plane.D * light.Y; + M[14] = -plane.D * light.Z; + M[15] = -plane.D * point + d; + definitelyIdentityMatrix=false; + } + + //! Builds a left-handed look-at matrix. + inline void matrix4::buildCameraLookAtMatrixLH( + const vector3df& position, + const vector3df& target, + const vector3df& upVector) + { + vector3df zaxis = target - position; + zaxis.normalize(); + + vector3df xaxis = upVector.crossProduct(zaxis); + xaxis.normalize(); + + vector3df yaxis = zaxis.crossProduct(xaxis); + + M[0] = xaxis.X; + M[1] = yaxis.X; + M[2] = zaxis.X; + M[3] = 0; + + M[4] = xaxis.Y; + M[5] = yaxis.Y; + M[6] = zaxis.Y; + M[7] = 0; + + M[8] = xaxis.Z; + M[9] = yaxis.Z; + M[10] = zaxis.Z; + M[11] = 0; + + M[12] = -xaxis.dotProduct(position); + M[13] = -yaxis.dotProduct(position); + M[14] = -zaxis.dotProduct(position); + M[15] = 1.0f; + definitelyIdentityMatrix=false; + } + + + + //! Builds a right-handed look-at matrix. + inline void matrix4::buildCameraLookAtMatrixRH( + const vector3df& position, + const vector3df& target, + const vector3df& upVector) + { + vector3df zaxis = position - target; + zaxis.normalize(); + + vector3df xaxis = upVector.crossProduct(zaxis); + xaxis.normalize(); + + vector3df yaxis = zaxis.crossProduct(xaxis); + + M[0] = xaxis.X; + M[1] = yaxis.X; + M[2] = zaxis.X; + M[3] = 0; + + M[4] = xaxis.Y; + M[5] = yaxis.Y; + M[6] = zaxis.Y; + M[7] = 0; + + M[8] = xaxis.Z; + M[9] = yaxis.Z; + M[10] = zaxis.Z; + M[11] = 0; + + M[12] = -xaxis.dotProduct(position); + M[13] = -yaxis.dotProduct(position); + M[14] = -zaxis.dotProduct(position); + M[15] = 1.0f; + definitelyIdentityMatrix=false; + } + + + //! creates a new matrix as interpolated matrix from to other ones. + //! \param time: Must be a value between 0 and 1. + inline matrix4 matrix4::interpolate(const core::matrix4& b, f32 time) const + { + matrix4 mat ( EM4CONST_NOTHING ); + + for (s32 i=0; i < 16; i += 4) + { + mat.M[i+0] = M[i+0] + ( b.M[i+0] - M[i+0] ) * time; + mat.M[i+1] = M[i+1] + ( b.M[i+1] - M[i+1] ) * time; + mat.M[i+2] = M[i+2] + ( b.M[i+2] - M[i+2] ) * time; + mat.M[i+3] = M[i+3] + ( b.M[i+3] - M[i+3] ) * time; + } + return mat; + } + + //! returns transposed matrix + inline matrix4 matrix4::getTransposed() const + { + matrix4 t ( EM4CONST_NOTHING ); + getTransposed ( t ); + return t; + } + + //! returns transposed matrix + inline void matrix4::getTransposed( matrix4& o ) const + { + o[ 0] = M[ 0]; + o[ 1] = M[ 4]; + o[ 2] = M[ 8]; + o[ 3] = M[12]; + + o[ 4] = M[ 1]; + o[ 5] = M[ 5]; + o[ 6] = M[ 9]; + o[ 7] = M[13]; + + o[ 8] = M[ 2]; + o[ 9] = M[ 6]; + o[10] = M[10]; + o[11] = M[14]; + + o[12] = M[ 3]; + o[13] = M[ 7]; + o[14] = M[11]; + o[15] = M[15]; + o.definitelyIdentityMatrix=definitelyIdentityMatrix; + } + + + // used to scale <-1,-1><1,1> to viewport + inline void matrix4::buildNDCToDCMatrix( const core::rect& viewport, f32 zScale) + { + f32 scaleX = (viewport.getWidth() - 0.75f ) / 2.f; + f32 scaleY = -(viewport.getHeight() - 0.75f ) / 2.f; + + f32 dx = -0.5f + ( (viewport.UpperLeftCorner.X + viewport.LowerRightCorner.X ) / 2.f ); + f32 dy = -0.5f + ( (viewport.UpperLeftCorner.Y + viewport.LowerRightCorner.Y ) / 2.f ); + + makeIdentity(); + M[0] = scaleX; + M[5] = scaleY; + M[10] = zScale; + M[12] = dx; + M[13] = dy; + definitelyIdentityMatrix=false; + } + + /*! + Generate texture coordinates as linear functions so that: + u = Ux*x + Uy*y + Uz*z + Uw + v = Vx*x + Vy*y + Vz*z + Vw + The matrix M for this case is: + Ux Vx 0 0 + Uy Vy 0 0 + Uz Vz 0 0 + Uw Vw 0 0 + */ + + inline void matrix4::buildTextureTransform( f32 rotateRad, + const core::vector2df &rotatecenter, + const core::vector2df &translate, + const core::vector2df &scale) + { + f32 c = cosf(rotateRad); + f32 s = sinf(rotateRad); + + M[0] = c * scale.X; + M[1] = s * scale.Y; + M[2] = 0.f; + M[3] = 0.f; + + M[4] = -s * scale.X; + M[5] = c * scale.Y; + M[6] = 0.f; + M[7] = 0.f; + + M[8] = c * scale.X * rotatecenter.X + -s * rotatecenter.Y + translate.X; + M[9] = s * scale.Y * rotatecenter.X + c * rotatecenter.Y + translate.Y; + M[10] = 1.f; + M[11] = 0.f; + + M[12] = 0.f; + M[13] = 0.f; + M[14] = 0.f; + M[15] = 1.f; + definitelyIdentityMatrix=false; + } + + //! rotate about z axis, center ( 0.5, 0.5 ) + inline void matrix4::setTextureRotationCenter( f32 rotateRad ) + { + f32 c = cosf(rotateRad); + f32 s = sinf(rotateRad); + M[0] = c; + M[1] = s; + M[2] = -0.5f * ( c + s) + 0.5f; + + M[4] = -s; + M[5] = c; + M[6] = -0.5f * (-s + c) + 0.5f; + definitelyIdentityMatrix=false; + } + + inline void matrix4::setTextureTranslate ( f32 x, f32 y ) + { + M[2] = x; + M[6] = y; + definitelyIdentityMatrix=false; + } + + inline void matrix4::setTextureScale ( f32 sx, f32 sy ) + { + M[0] = sx; + M[5] = sy; + definitelyIdentityMatrix=false; + } + + inline void matrix4::setTextureScaleCenter( f32 sx, f32 sy ) + { + M[0] = sx; + M[2] = -0.5f * sx + 0.5f; + M[5] = sy; + M[6] = -0.5f * sy + 0.5f; + definitelyIdentityMatrix=false; + } + + //! Multiply by scalar. + inline matrix4 operator*(const f32 scalar, const matrix4& mat) + { + return mat*scalar; + } + + const matrix4 IdentityMatrix(matrix4::EM4CONST_IDENTITY); +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/plane3d.h b/src/dep/include/irrlicht/plane3d.h index 2f6c94a..12d6a41 100644 --- a/src/dep/include/irrlicht/plane3d.h +++ b/src/dep/include/irrlicht/plane3d.h @@ -1,220 +1,220 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_PLANE_3D_H_INCLUDED__ -#define __IRR_PLANE_3D_H_INCLUDED__ - -#include "irrMath.h" -#include "vector3d.h" - -namespace irr -{ -namespace core -{ - -//! Enumeration for intersection relations of 3d objects -enum EIntersectionRelation3D -{ - ISREL3D_FRONT = 0, - ISREL3D_BACK, - ISREL3D_PLANAR, - ISREL3D_SPANNING, - ISREL3D_CLIPPED -}; - -//! Template plane class with some intersection testing methods. -template -class plane3d -{ - public: - - // Constructors - - plane3d(): Normal(0,1,0) { recalculateD(vector3d(0,0,0)); }; - plane3d(const vector3d& MPoint, const vector3d& Normal) : Normal(Normal) { recalculateD(MPoint); }; - plane3d(T px, T py, T pz, T nx, T ny, T nz) : Normal(nx, ny, nz) { recalculateD(vector3d(px, py, pz)); }; - plane3d(const plane3d& other) : Normal(other.Normal), D(other.D) {}; - plane3d(const vector3d& point1, const vector3d& point2, const vector3d& point3) { setPlane(point1, point2, point3); }; - - // operators - - inline bool operator==(const plane3d& other) const { return (D==other.D && Normal==other.Normal);}; - inline bool operator!=(const plane3d& other) const { return !(D==other.D && Normal==other.Normal);}; - - // functions - - void setPlane(const vector3d& point, const vector3d& nvector) - { - Normal = nvector; - Normal.normalize(); - recalculateD(point); - } - - void setPlane(const vector3d& nvect, T d) - { - Normal = nvect; - D = d; - } - - void setPlane(const vector3d& point1, const vector3d& point2, const vector3d& point3) - { - // creates the plane from 3 memberpoints - Normal = (point2 - point1).crossProduct(point3 - point1); - Normal.normalize(); - - recalculateD(point1); - } - - - //! Returns an intersection with a 3d line. - //! \param lineVect: Vector of the line to intersect with. - //! \param linePoint: Point of the line to intersect with. - //! \param outIntersection: Place to store the intersection point, if there is one. - //! \return Returns true if there was an intersection, false if there was not. - bool getIntersectionWithLine(const vector3d& linePoint, const vector3d& lineVect, - vector3d& outIntersection) const - { - T t2 = Normal.dotProduct(lineVect); - - if (t2 == 0) - return false; - - T t =- (Normal.dotProduct(linePoint) + D) / t2; - outIntersection = linePoint + (lineVect * t); - return true; - } - - //! Returns where on a line between two points an intersection with this plane happened. - //! Only useful if known that there is an intersection. - //! \param linePoint1: Point1 of the line to intersect with. - //! \param linePoint2: Point2 of the line to intersect with. - //! \return Returns where on a line between two points an intersection with this plane happened. - //! For example, 0.5 is returned if the intersection happened exectly in the middle of the two points. - f32 getKnownIntersectionWithLine(const vector3d& linePoint1, - const vector3d& linePoint2) const - { - vector3d vect = linePoint2 - linePoint1; - T t2 = (f32)Normal.dotProduct(vect); - return (f32)-((Normal.dotProduct(linePoint1) + D) / t2); - } - - //! Returns an intersection with a 3d line, limited between two 3d points. - //! \param linePoint1: Point 1 of the line. - //! \param linePoint2: Point 2 of the line. - //! \param outIntersection: Place to store the intersection point, if there is one. - //! \return Returns true if there was an intersection, false if there was not. - bool getIntersectionWithLimitedLine(const vector3d& linePoint1, - const vector3d& linePoint2, vector3d& outIntersection) const - { - return ( getIntersectionWithLine(linePoint1, linePoint2 - linePoint1, outIntersection) && - outIntersection.isBetweenPoints(linePoint1, linePoint2)); - } - - //! Classifies the relation of a point to this plane. - //! \param point: Point to classify its relation. - //! \return Returns ISREL3D_FRONT if the point is in front of the plane, - //! ISREL3D_BACK if the point is behind of the plane, and - //! ISREL3D_PLANAR if the point is within the plane. - EIntersectionRelation3D classifyPointRelation(const vector3d& point) const - { - const T d = Normal.dotProduct(point) + D; - - if (d < -ROUNDING_ERROR_32) - return ISREL3D_FRONT; - - if (d > ROUNDING_ERROR_32) - return ISREL3D_BACK; - - return ISREL3D_PLANAR; - } - - //! Recalculates the distance from origin by applying - //! a new member point to the plane. - void recalculateD(const vector3d& MPoint) - { - D = - MPoint.dotProduct(Normal); - } - - //! Returns a member point of the plane. - vector3d getMemberPoint() const - { - return Normal * -D; - } - - //! Tests if there is a intersection between this plane and another - //! \return Returns true if there is a intersection. - bool existsInterSection(const plane3d& other) const - { - vector3d cross = other.Normal.crossProduct(Normal); - return cross.getLength() > core::ROUNDING_ERROR_32; - } - - //! Intersects this plane with another. - //! \return Returns true if there is a intersection, false if not. - bool getIntersectionWithPlane(const plane3d& other, vector3d& outLinePoint, - vector3d& outLineVect) const - { - f64 fn00 = Normal.getLength(); - f64 fn01 = Normal.dotProduct(other.Normal); - f64 fn11 = other.Normal.getLength(); - f64 det = fn00*fn11 - fn01*fn01; - - if (fabs(det) < ROUNDING_ERROR_64 ) - return false; - - det = 1.0 / det; - f64 fc0 = (fn11*-D + fn01*other.D) * det; - f64 fc1 = (fn00*-other.D + fn01*D) * det; - - outLineVect = Normal.crossProduct(other.Normal); - outLinePoint = Normal*(T)fc0 + other.Normal*(T)fc1; - return true; - } - - //! Returns the intersection point with two other planes if there is one. - bool getIntersectionWithPlanes(const plane3d& o1, - const plane3d& o2, vector3d& outPoint) const - { - vector3d linePoint, lineVect; - if (getIntersectionWithPlane(o1, linePoint, lineVect)) - return o2.getIntersectionWithLine(linePoint, lineVect, outPoint); - - return false; - } - - //! Returns if the plane is front of backfacing. Note that this only - //! works if the normal is Normalized. - //! \param lookDirection: Look direction. - //! \return Returns true if the plane is front facing, which mean it would - //! be visible, and false if it is backfacing. - bool isFrontFacing(const vector3d& lookDirection) const - { - const f32 d = Normal.dotProduct(lookDirection); - return F32_LOWER_EQUAL_0 ( d ); - } - - //! Returns the distance to a point. Note that this only - //! works if the normal is Normalized. - T getDistanceTo(const vector3d& point) const - { - return point.dotProduct(Normal) + D; - } - - // member variables - - vector3d Normal; // normal vector - T D; // distance from origin -}; - - -//! Typedef for a f32 3d plane. -typedef plane3d plane3df; -//! Typedef for an integer 3d plane. -typedef plane3d plane3di; - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_PLANE_3D_H_INCLUDED__ +#define __IRR_PLANE_3D_H_INCLUDED__ + +#include "irrMath.h" +#include "vector3d.h" + +namespace irr +{ +namespace core +{ + +//! Enumeration for intersection relations of 3d objects +enum EIntersectionRelation3D +{ + ISREL3D_FRONT = 0, + ISREL3D_BACK, + ISREL3D_PLANAR, + ISREL3D_SPANNING, + ISREL3D_CLIPPED +}; + +//! Template plane class with some intersection testing methods. +template +class plane3d +{ + public: + + // Constructors + + plane3d(): Normal(0,1,0) { recalculateD(vector3d(0,0,0)); }; + plane3d(const vector3d& MPoint, const vector3d& Normal) : Normal(Normal) { recalculateD(MPoint); }; + plane3d(T px, T py, T pz, T nx, T ny, T nz) : Normal(nx, ny, nz) { recalculateD(vector3d(px, py, pz)); }; + plane3d(const plane3d& other) : Normal(other.Normal), D(other.D) {}; + plane3d(const vector3d& point1, const vector3d& point2, const vector3d& point3) { setPlane(point1, point2, point3); }; + + // operators + + inline bool operator==(const plane3d& other) const { return (D==other.D && Normal==other.Normal);}; + inline bool operator!=(const plane3d& other) const { return !(D==other.D && Normal==other.Normal);}; + + // functions + + void setPlane(const vector3d& point, const vector3d& nvector) + { + Normal = nvector; + Normal.normalize(); + recalculateD(point); + } + + void setPlane(const vector3d& nvect, T d) + { + Normal = nvect; + D = d; + } + + void setPlane(const vector3d& point1, const vector3d& point2, const vector3d& point3) + { + // creates the plane from 3 memberpoints + Normal = (point2 - point1).crossProduct(point3 - point1); + Normal.normalize(); + + recalculateD(point1); + } + + + //! Returns an intersection with a 3d line. + //! \param lineVect: Vector of the line to intersect with. + //! \param linePoint: Point of the line to intersect with. + //! \param outIntersection: Place to store the intersection point, if there is one. + //! \return Returns true if there was an intersection, false if there was not. + bool getIntersectionWithLine(const vector3d& linePoint, const vector3d& lineVect, + vector3d& outIntersection) const + { + T t2 = Normal.dotProduct(lineVect); + + if (t2 == 0) + return false; + + T t =- (Normal.dotProduct(linePoint) + D) / t2; + outIntersection = linePoint + (lineVect * t); + return true; + } + + //! Returns where on a line between two points an intersection with this plane happened. + //! Only useful if known that there is an intersection. + //! \param linePoint1: Point1 of the line to intersect with. + //! \param linePoint2: Point2 of the line to intersect with. + //! \return Returns where on a line between two points an intersection with this plane happened. + //! For example, 0.5 is returned if the intersection happened exectly in the middle of the two points. + f32 getKnownIntersectionWithLine(const vector3d& linePoint1, + const vector3d& linePoint2) const + { + vector3d vect = linePoint2 - linePoint1; + T t2 = (f32)Normal.dotProduct(vect); + return (f32)-((Normal.dotProduct(linePoint1) + D) / t2); + } + + //! Returns an intersection with a 3d line, limited between two 3d points. + //! \param linePoint1: Point 1 of the line. + //! \param linePoint2: Point 2 of the line. + //! \param outIntersection: Place to store the intersection point, if there is one. + //! \return Returns true if there was an intersection, false if there was not. + bool getIntersectionWithLimitedLine(const vector3d& linePoint1, + const vector3d& linePoint2, vector3d& outIntersection) const + { + return ( getIntersectionWithLine(linePoint1, linePoint2 - linePoint1, outIntersection) && + outIntersection.isBetweenPoints(linePoint1, linePoint2)); + } + + //! Classifies the relation of a point to this plane. + //! \param point: Point to classify its relation. + //! \return Returns ISREL3D_FRONT if the point is in front of the plane, + //! ISREL3D_BACK if the point is behind of the plane, and + //! ISREL3D_PLANAR if the point is within the plane. + EIntersectionRelation3D classifyPointRelation(const vector3d& point) const + { + const T d = Normal.dotProduct(point) + D; + + if (d < -ROUNDING_ERROR_32) + return ISREL3D_FRONT; + + if (d > ROUNDING_ERROR_32) + return ISREL3D_BACK; + + return ISREL3D_PLANAR; + } + + //! Recalculates the distance from origin by applying + //! a new member point to the plane. + void recalculateD(const vector3d& MPoint) + { + D = - MPoint.dotProduct(Normal); + } + + //! Returns a member point of the plane. + vector3d getMemberPoint() const + { + return Normal * -D; + } + + //! Tests if there is a intersection between this plane and another + //! \return Returns true if there is a intersection. + bool existsInterSection(const plane3d& other) const + { + vector3d cross = other.Normal.crossProduct(Normal); + return cross.getLength() > core::ROUNDING_ERROR_32; + } + + //! Intersects this plane with another. + //! \return Returns true if there is a intersection, false if not. + bool getIntersectionWithPlane(const plane3d& other, vector3d& outLinePoint, + vector3d& outLineVect) const + { + f64 fn00 = Normal.getLength(); + f64 fn01 = Normal.dotProduct(other.Normal); + f64 fn11 = other.Normal.getLength(); + f64 det = fn00*fn11 - fn01*fn01; + + if (fabs(det) < ROUNDING_ERROR_64 ) + return false; + + det = 1.0 / det; + f64 fc0 = (fn11*-D + fn01*other.D) * det; + f64 fc1 = (fn00*-other.D + fn01*D) * det; + + outLineVect = Normal.crossProduct(other.Normal); + outLinePoint = Normal*(T)fc0 + other.Normal*(T)fc1; + return true; + } + + //! Returns the intersection point with two other planes if there is one. + bool getIntersectionWithPlanes(const plane3d& o1, + const plane3d& o2, vector3d& outPoint) const + { + vector3d linePoint, lineVect; + if (getIntersectionWithPlane(o1, linePoint, lineVect)) + return o2.getIntersectionWithLine(linePoint, lineVect, outPoint); + + return false; + } + + //! Returns if the plane is front of backfacing. Note that this only + //! works if the normal is Normalized. + //! \param lookDirection: Look direction. + //! \return Returns true if the plane is front facing, which mean it would + //! be visible, and false if it is backfacing. + bool isFrontFacing(const vector3d& lookDirection) const + { + const f32 d = Normal.dotProduct(lookDirection); + return F32_LOWER_EQUAL_0 ( d ); + } + + //! Returns the distance to a point. Note that this only + //! works if the normal is Normalized. + T getDistanceTo(const vector3d& point) const + { + return point.dotProduct(Normal) + D; + } + + // member variables + + vector3d Normal; // normal vector + T D; // distance from origin +}; + + +//! Typedef for a f32 3d plane. +typedef plane3d plane3df; +//! Typedef for an integer 3d plane. +typedef plane3d plane3di; + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/position2d.h b/src/dep/include/irrlicht/position2d.h index ac673bb..206ef06 100644 --- a/src/dep/include/irrlicht/position2d.h +++ b/src/dep/include/irrlicht/position2d.h @@ -1,124 +1,124 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_POSITION_H_INCLUDED__ -#define __IRR_POSITION_H_INCLUDED__ - -#include "irrTypes.h" -#include "dimension2d.h" - -namespace irr -{ -namespace core -{ - - //! Simple class for holding 2d coordinates. - /** Not supposed for doing geometric calculations. - use vector2d instead for things like that. - */ - template - class position2d - { - public: - position2d(T x, T y) - : X(x), Y(y) {}; - - - position2d() - : X(0), Y(0) {}; - - - position2d(const position2d& other) - : X(other.X), Y(other.Y) {}; - - - bool operator == (const position2d& other) const - { - return X == other.X && Y == other.Y; - } - - - bool operator != (const position2d& other) const - { - return X != other.X || Y != other.Y; - } - - const position2d& operator+=(const position2d& other) - { - X += other.X; - Y += other.Y; - return *this; - } - - const position2d& operator-=(const position2d& other) - { - X -= other.X; - Y -= other.Y; - return *this; - } - - const position2d& operator+=(const dimension2d& other) - { - X += other.Width; - Y += other.Height; - return *this; - } - - const position2d& operator-=(const dimension2d& other) - { - X -= other.Width; - Y -= other.Height; - return *this; - } - - position2d operator-(const position2d& other) const - { - return position2d(X-other.X, Y-other.Y); - } - - position2d operator+(const position2d& other) const - { - return position2d(X+other.X, Y+other.Y); - } - - position2d operator*(const position2d& other) const - { - return position2d(X*other.X, Y*other.Y); - } - - position2d operator*(const T& scalar) const - { - return position2d(X*scalar, Y*scalar); - } - - position2d operator+(const dimension2d& other) const - { - return position2d(X+other.Width, Y+other.Height); - } - - position2d operator-(const dimension2d& other) const - { - return position2d(X-other.Width, Y-other.Height); - } - - const position2d& operator=(const position2d& other) - { - X = other.X; - Y = other.Y; - return *this; - } - - T X, Y; - }; - - //! Typedef for a f32 position. - typedef position2d position2df; - //! Typedef for an integer position. - typedef position2d position2di; - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_POSITION_H_INCLUDED__ +#define __IRR_POSITION_H_INCLUDED__ + +#include "irrTypes.h" +#include "dimension2d.h" + +namespace irr +{ +namespace core +{ + + //! Simple class for holding 2d coordinates. + /** Not supposed for doing geometric calculations. + use vector2d instead for things like that. + */ + template + class position2d + { + public: + position2d(T x, T y) + : X(x), Y(y) {}; + + + position2d() + : X(0), Y(0) {}; + + + position2d(const position2d& other) + : X(other.X), Y(other.Y) {}; + + + bool operator == (const position2d& other) const + { + return X == other.X && Y == other.Y; + } + + + bool operator != (const position2d& other) const + { + return X != other.X || Y != other.Y; + } + + const position2d& operator+=(const position2d& other) + { + X += other.X; + Y += other.Y; + return *this; + } + + const position2d& operator-=(const position2d& other) + { + X -= other.X; + Y -= other.Y; + return *this; + } + + const position2d& operator+=(const dimension2d& other) + { + X += other.Width; + Y += other.Height; + return *this; + } + + const position2d& operator-=(const dimension2d& other) + { + X -= other.Width; + Y -= other.Height; + return *this; + } + + position2d operator-(const position2d& other) const + { + return position2d(X-other.X, Y-other.Y); + } + + position2d operator+(const position2d& other) const + { + return position2d(X+other.X, Y+other.Y); + } + + position2d operator*(const position2d& other) const + { + return position2d(X*other.X, Y*other.Y); + } + + position2d operator*(const T& scalar) const + { + return position2d(X*scalar, Y*scalar); + } + + position2d operator+(const dimension2d& other) const + { + return position2d(X+other.Width, Y+other.Height); + } + + position2d operator-(const dimension2d& other) const + { + return position2d(X-other.Width, Y-other.Height); + } + + const position2d& operator=(const position2d& other) + { + X = other.X; + Y = other.Y; + return *this; + } + + T X, Y; + }; + + //! Typedef for a f32 position. + typedef position2d position2df; + //! Typedef for an integer position. + typedef position2d position2di; + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/quaternion.h b/src/dep/include/irrlicht/quaternion.h index ae901e5..ab9e2c6 100644 --- a/src/dep/include/irrlicht/quaternion.h +++ b/src/dep/include/irrlicht/quaternion.h @@ -1,503 +1,503 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_QUATERNION_H_INCLUDED__ -#define __IRR_QUATERNION_H_INCLUDED__ - -#include "irrTypes.h" -#include "matrix4.h" -#include "vector3d.h" - -namespace irr -{ -namespace core -{ - -//! Quaternion class. -class quaternion -{ - public: - - //! Default Constructor - quaternion(); - - //! Constructor - quaternion(f32 X, f32 Y, f32 Z, f32 W); - - //! Constructor which converts euler angles to a quaternion - quaternion(f32 x, f32 y, f32 z); - - //! Constructor which converts a matrix to a quaternion - quaternion(const matrix4& mat); - - //! equal operator - bool operator==(const quaternion& other) const; - - //! assignment operator - inline quaternion& operator=(const quaternion& other); - - //! matrix assignment operator - inline quaternion& operator=(const matrix4& other); - - //! add operator - quaternion operator+(const quaternion& other) const; - - //! multiplication operator - quaternion operator*(const quaternion& other) const; - - //! multiplication operator - quaternion operator*(f32 s) const; - - //! multiplication operator - quaternion& operator*=(f32 s); - - //! multiplication operator - vector3df operator* (const vector3df& v) const; - - //! multiplication operator - quaternion& operator*=(const quaternion& other); - - //! calculates the dot product - inline f32 getDotProduct(const quaternion& other) const; - - //! sets new quaternion - inline void set(f32 x, f32 y, f32 z, f32 w); - - //! sets new quaternion based on euler angles - inline void set(f32 x, f32 y, f32 z); - - //! normalizes the quaternion - inline quaternion& normalize(); - - //! Creates a matrix from this quaternion - matrix4 getMatrix() const; - - //! Creates a matrix from this quaternion - void getMatrix( matrix4 &dest ) const; - - //! Creates a matrix from this quaternion - void getMatrix_transposed( matrix4 &dest ) const; - - //! Inverts this quaternion - void makeInverse(); - - //! set this quaternion to the result of the inpolation between two quaternions based - void slerp( quaternion q1, const quaternion q2, f32 interpolate ); - - //! axis must be unit length - //! The quaternion representing the rotation is - //! q = cos(A/2)+sin(A/2)*(x*i+y*j+z*k) - void fromAngleAxis (f32 angle, const vector3df& axis); - - void toEuler(vector3df& euler) const; - - //! set quaternion to identity - void makeIdentity(); - - f32 X, Y, Z, W; -}; - - -//! Default Constructor -inline quaternion::quaternion() -: X(0.0f), Y(0.0f), Z(0.0f), W(1.0f) -{ -} - -//! Constructor -inline quaternion::quaternion(f32 x, f32 y, f32 z, f32 w) -: X(x), Y(y), Z(z), W(w) -{ -} - -//! Constructor which converts euler angles to a quaternion -inline quaternion::quaternion(f32 x, f32 y, f32 z) -{ - set(x,y,z); -} - - -//! Constructor which converts a matrix to a quaternion -inline quaternion::quaternion(const matrix4& mat) -{ - (*this) = mat; -} - - -//! equal operator -inline bool quaternion::operator==(const quaternion& other) const -{ - if(X != other.X) - return false; - if(Y != other.Y) - return false; - if(Z != other.Z) - return false; - if(W != other.W) - return false; - - return true; -} - - -//! assignment operator -inline quaternion& quaternion::operator=(const quaternion& other) -{ - X = other.X; - Y = other.Y; - Z = other.Z; - W = other.W; - return *this; -} - - -//! matrix assignment operator -inline quaternion& quaternion::operator=(const matrix4& m) -{ - f32 diag = m(0,0) + m(1,1) + m(2,2) + 1; - f32 scale = 0.0f; - - if( diag > 0.0f ) - { - scale = sqrtf(diag) * 2.0f; // get scale from diagonal - - // TODO: speed this up - X = ( m(2,1) - m(1,2)) / scale; - Y = ( m(0,2) - m(2,0)) / scale; - Z = ( m(1,0) - m(0,1)) / scale; - W = 0.25f * scale; - } - else - { - if ( m(0,0) > m(1,1) && m(0,0) > m(2,2)) - { - // 1st element of diag is greatest value - // find scale according to 1st element, and double it - scale = sqrtf( 1.0f + m(0,0) - m(1,1) - m(2,2)) * 2.0f; - - // TODO: speed this up - X = 0.25f * scale; - Y = (m(0,1) + m(1,0)) / scale; - Z = (m(2,0) + m(0,2)) / scale; - W = (m(2,1) - m(1,2)) / scale; - } - else if ( m(1,1) > m(2,2)) - { - // 2nd element of diag is greatest value - // find scale according to 2nd element, and double it - scale = sqrtf( 1.0f + m(1,1) - m(0,0) - m(2,2)) * 2.0f; - - // TODO: speed this up - X = (m(0,1) + m(1,0) ) / scale; - Y = 0.25f * scale; - Z = (m(1,2) + m(2,1) ) / scale; - W = (m(0,2) - m(2,0) ) / scale; - } - else - { - // 3rd element of diag is greatest value - // find scale according to 3rd element, and double it - scale = sqrtf( 1.0f + m(2,2) - m(0,0) - m(1,1)) * 2.0f; - - // TODO: speed this up - X = (m(0,2) + m(2,0)) / scale; - Y = (m(1,2) + m(2,1)) / scale; - Z = 0.25f * scale; - W = (m(1,0) - m(0,1)) / scale; - } - } - - normalize(); - return *this; -} - - -//! multiplication operator -inline quaternion quaternion::operator*(const quaternion& other) const -{ - quaternion tmp; - - tmp.W = (other.W * W) - (other.X * X) - (other.Y * Y) - (other.Z * Z); - tmp.X = (other.W * X) + (other.X * W) + (other.Y * Z) - (other.Z * Y); - tmp.Y = (other.W * Y) + (other.Y * W) + (other.Z * X) - (other.X * Z); - tmp.Z = (other.W * Z) + (other.Z * W) + (other.X * Y) - (other.Y * X); - - return tmp; -} - - -//! multiplication operator -inline quaternion quaternion::operator*(f32 s) const -{ - return quaternion(s*X, s*Y, s*Z, s*W); -} - -//! multiplication operator -inline quaternion& quaternion::operator*=(f32 s) -{ - X *= s; Y*=s; Z*=s; W*=s; - return *this; -} - -//! multiplication operator -inline quaternion& quaternion::operator*=(const quaternion& other) -{ - *this = other * (*this); - return *this; -} - -//! add operator -inline quaternion quaternion::operator+(const quaternion& b) const -{ - return quaternion(X+b.X, Y+b.Y, Z+b.Z, W+b.W); -} - - -//! Creates a matrix from this quaternion -inline matrix4 quaternion::getMatrix() const -{ - core::matrix4 m; - - m(0,0) = 1.0f - 2.0f*Y*Y - 2.0f*Z*Z; - m(1,0) = 2.0f*X*Y + 2.0f*Z*W; - m(2,0) = 2.0f*X*Z - 2.0f*Y*W; - m(3,0) = 0.0f; - - m(0,1) = 2.0f*X*Y - 2.0f*Z*W; - m(1,1) = 1.0f - 2.0f*X*X - 2.0f*Z*Z; - m(2,1) = 2.0f*Z*Y + 2.0f*X*W; - m(3,1) = 0.0f; - - m(0,2) = 2.0f*X*Z + 2.0f*Y*W; - m(1,2) = 2.0f*Z*Y - 2.0f*X*W; - m(2,2) = 1.0f - 2.0f*X*X - 2.0f*Y*Y; - m(3,2) = 0.0f; - - m(0,3) = 0.0f; - m(1,3) = 0.0f; - m(2,3) = 0.0f; - m(3,3) = 1.0f; - - return m; -} - - -//! Creates a matrix from this quaternion -inline void quaternion::getMatrix( matrix4 &dest ) const -{ - dest[0] = 1.0f - 2.0f*Y*Y - 2.0f*Z*Z; - dest[1] = 2.0f*X*Y + 2.0f*Z*W; - dest[2] = 2.0f*X*Z - 2.0f*Y*W; - dest[3] = 0.0f; - - dest[4] = 2.0f*X*Y - 2.0f*Z*W; - dest[5] = 1.0f - 2.0f*X*X - 2.0f*Z*Z; - dest[6] = 2.0f*Z*Y + 2.0f*X*W; - dest[7] = 0.0f; - - dest[8] = 2.0f*X*Z + 2.0f*Y*W; - dest[9] = 2.0f*Z*Y - 2.0f*X*W; - dest[10] = 1.0f - 2.0f*X*X - 2.0f*Y*Y; - dest[11] = 0.0f; - - dest[12] = 0.f; - dest[13] = 0.f; - dest[14] = 0.f; - dest[15] = 1.f; -} - -//! Creates a matrix from this quaternion -inline void quaternion::getMatrix_transposed( matrix4 &dest ) const -{ - dest[0] = 1.0f - 2.0f*Y*Y - 2.0f*Z*Z; - dest[4] = 2.0f*X*Y + 2.0f*Z*W; - dest[8] = 2.0f*X*Z - 2.0f*Y*W; - dest[12] = 0.0f; - - dest[1] = 2.0f*X*Y - 2.0f*Z*W; - dest[5] = 1.0f - 2.0f*X*X - 2.0f*Z*Z; - dest[9] = 2.0f*Z*Y + 2.0f*X*W; - dest[13] = 0.0f; - - dest[2] = 2.0f*X*Z + 2.0f*Y*W; - dest[6] = 2.0f*Z*Y - 2.0f*X*W; - dest[10] = 1.0f - 2.0f*X*X - 2.0f*Y*Y; - dest[14] = 0.0f; - - dest[3] = 0.f; - dest[7] = 0.f; - dest[11] = 0.f; - dest[15] = 1.f; -} - - - -//! Inverts this quaternion -inline void quaternion::makeInverse() -{ - X = -X; Y = -Y; Z = -Z; -} - -//! sets new quaternion -inline void quaternion::set(f32 x, f32 y, f32 z, f32 w) -{ - X = x; - Y = y; - Z = z; - W = w; -} - - -//! sets new quaternion based on euler angles -inline void quaternion::set(f32 x, f32 y, f32 z) -{ - f64 angle; - - angle = x * 0.5; - f64 sr = (f32)sin(angle); - f64 cr = (f32)cos(angle); - - angle = y * 0.5; - f64 sp = (f32)sin(angle); - f64 cp = (f32)cos(angle); - - angle = z * 0.5; - f64 sy = (f32)sin(angle); - f64 cy = (f32)cos(angle); - - f64 cpcy = cp * cy; - f64 spcy = sp * cy; - f64 cpsy = cp * sy; - f64 spsy = sp * sy; - - X = (f32)(sr * cpcy - cr * spsy); - Y = (f32)(cr * spcy + sr * cpsy); - Z = (f32)(cr * cpsy - sr * spcy); - W = (f32)(cr * cpcy + sr * spsy); - - normalize(); -} - -//! normalizes the quaternion -inline quaternion& quaternion::normalize() -{ - f32 n = X*X + Y*Y + Z*Z + W*W; - - if (n == 1) - return *this; - - //n = 1.0f / sqrtf(n); - n = reciprocal_squareroot ( n ); - X *= n; - Y *= n; - Z *= n; - W *= n; - - return *this; -} - - -// set this quaternion to the result of the inpolation between two quaternions based -inline void quaternion::slerp( quaternion q1, quaternion q2, f32 time) -{ - f32 angle = q1.getDotProduct(q2); - - if (angle < 0.0f) - { - q1 *= -1.0f; - angle *= -1.0f; - } - - f32 scale; - f32 invscale; - - if ((angle + 1.0f) > 0.05f) - { - if ((1.0f - angle) >= 0.05f) // spherical interpolation - { - f32 theta = (f32)acos(angle); - f32 invsintheta = 1.0f / (f32)sin(theta); - scale = (f32)sin(theta * (1.0f-time)) * invsintheta; - invscale = (f32)sin(theta * time) * invsintheta; - } - else // linear interploation - { - scale = 1.0f - time; - invscale = time; - } - } - else - { - q2 = quaternion(-q1.Y, q1.X, -q1.W, q1.Z); - scale = (f32)sin(PI * (0.5f - time)); - invscale = (f32)sin(PI * time); - } - - *this = (q1*scale) + (q2*invscale); -} - - -//! calculates the dot product -inline f32 quaternion::getDotProduct(const quaternion& q2) const -{ - return (X * q2.X) + (Y * q2.Y) + (Z * q2.Z) + (W * q2.W); -} - - -inline void quaternion::fromAngleAxis(f32 angle, const vector3df& axis) -{ - f32 fHalfAngle = 0.5f*angle; - f32 fSin = (f32)sin(fHalfAngle); - W = (f32)cos(fHalfAngle); - X = fSin*axis.X; - Y = fSin*axis.Y; - Z = fSin*axis.Z; -} - -inline void quaternion::toEuler(vector3df& euler) const -{ - double sqw = W*W; - double sqx = X*X; - double sqy = Y*Y; - double sqz = Z*Z; - - // heading = rotation about z-axis - euler.Z = (f32) (atan2(2.0 * (X*Y +Z*W),(sqx - sqy - sqz + sqw))); - - // bank = rotation about x-axis - euler.X = (f32) (atan2(2.0 * (Y*Z +X*W),(-sqx - sqy + sqz + sqw))); - - // attitude = rotation about y-axis - euler.Y = (f32) (asin(-2.0 * (X*Z - Y*W))); -} - -inline vector3df quaternion::operator* (const vector3df& v) const -{ - // nVidia SDK implementation - - vector3df uv, uuv; - vector3df qvec(X, Y, Z); - uv = qvec.crossProduct(v); - uuv = qvec.crossProduct(uv); - uv *= (2.0f * W); - uuv *= 2.0f; - - return v + uv + uuv; -} - -//! set quaterion to identity -inline void quaternion::makeIdentity() -{ - W = 1.f; - X = 0.f; - Y = 0.f; - Z = 0.f; -} - - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_QUATERNION_H_INCLUDED__ +#define __IRR_QUATERNION_H_INCLUDED__ + +#include "irrTypes.h" +#include "matrix4.h" +#include "vector3d.h" + +namespace irr +{ +namespace core +{ + +//! Quaternion class. +class quaternion +{ + public: + + //! Default Constructor + quaternion(); + + //! Constructor + quaternion(f32 X, f32 Y, f32 Z, f32 W); + + //! Constructor which converts euler angles to a quaternion + quaternion(f32 x, f32 y, f32 z); + + //! Constructor which converts a matrix to a quaternion + quaternion(const matrix4& mat); + + //! equal operator + bool operator==(const quaternion& other) const; + + //! assignment operator + inline quaternion& operator=(const quaternion& other); + + //! matrix assignment operator + inline quaternion& operator=(const matrix4& other); + + //! add operator + quaternion operator+(const quaternion& other) const; + + //! multiplication operator + quaternion operator*(const quaternion& other) const; + + //! multiplication operator + quaternion operator*(f32 s) const; + + //! multiplication operator + quaternion& operator*=(f32 s); + + //! multiplication operator + vector3df operator* (const vector3df& v) const; + + //! multiplication operator + quaternion& operator*=(const quaternion& other); + + //! calculates the dot product + inline f32 getDotProduct(const quaternion& other) const; + + //! sets new quaternion + inline void set(f32 x, f32 y, f32 z, f32 w); + + //! sets new quaternion based on euler angles + inline void set(f32 x, f32 y, f32 z); + + //! normalizes the quaternion + inline quaternion& normalize(); + + //! Creates a matrix from this quaternion + matrix4 getMatrix() const; + + //! Creates a matrix from this quaternion + void getMatrix( matrix4 &dest ) const; + + //! Creates a matrix from this quaternion + void getMatrix_transposed( matrix4 &dest ) const; + + //! Inverts this quaternion + void makeInverse(); + + //! set this quaternion to the result of the inpolation between two quaternions based + void slerp( quaternion q1, const quaternion q2, f32 interpolate ); + + //! axis must be unit length + //! The quaternion representing the rotation is + //! q = cos(A/2)+sin(A/2)*(x*i+y*j+z*k) + void fromAngleAxis (f32 angle, const vector3df& axis); + + void toEuler(vector3df& euler) const; + + //! set quaternion to identity + void makeIdentity(); + + f32 X, Y, Z, W; +}; + + +//! Default Constructor +inline quaternion::quaternion() +: X(0.0f), Y(0.0f), Z(0.0f), W(1.0f) +{ +} + +//! Constructor +inline quaternion::quaternion(f32 x, f32 y, f32 z, f32 w) +: X(x), Y(y), Z(z), W(w) +{ +} + +//! Constructor which converts euler angles to a quaternion +inline quaternion::quaternion(f32 x, f32 y, f32 z) +{ + set(x,y,z); +} + + +//! Constructor which converts a matrix to a quaternion +inline quaternion::quaternion(const matrix4& mat) +{ + (*this) = mat; +} + + +//! equal operator +inline bool quaternion::operator==(const quaternion& other) const +{ + if(X != other.X) + return false; + if(Y != other.Y) + return false; + if(Z != other.Z) + return false; + if(W != other.W) + return false; + + return true; +} + + +//! assignment operator +inline quaternion& quaternion::operator=(const quaternion& other) +{ + X = other.X; + Y = other.Y; + Z = other.Z; + W = other.W; + return *this; +} + + +//! matrix assignment operator +inline quaternion& quaternion::operator=(const matrix4& m) +{ + f32 diag = m(0,0) + m(1,1) + m(2,2) + 1; + f32 scale = 0.0f; + + if( diag > 0.0f ) + { + scale = sqrtf(diag) * 2.0f; // get scale from diagonal + + // TODO: speed this up + X = ( m(2,1) - m(1,2)) / scale; + Y = ( m(0,2) - m(2,0)) / scale; + Z = ( m(1,0) - m(0,1)) / scale; + W = 0.25f * scale; + } + else + { + if ( m(0,0) > m(1,1) && m(0,0) > m(2,2)) + { + // 1st element of diag is greatest value + // find scale according to 1st element, and double it + scale = sqrtf( 1.0f + m(0,0) - m(1,1) - m(2,2)) * 2.0f; + + // TODO: speed this up + X = 0.25f * scale; + Y = (m(0,1) + m(1,0)) / scale; + Z = (m(2,0) + m(0,2)) / scale; + W = (m(2,1) - m(1,2)) / scale; + } + else if ( m(1,1) > m(2,2)) + { + // 2nd element of diag is greatest value + // find scale according to 2nd element, and double it + scale = sqrtf( 1.0f + m(1,1) - m(0,0) - m(2,2)) * 2.0f; + + // TODO: speed this up + X = (m(0,1) + m(1,0) ) / scale; + Y = 0.25f * scale; + Z = (m(1,2) + m(2,1) ) / scale; + W = (m(0,2) - m(2,0) ) / scale; + } + else + { + // 3rd element of diag is greatest value + // find scale according to 3rd element, and double it + scale = sqrtf( 1.0f + m(2,2) - m(0,0) - m(1,1)) * 2.0f; + + // TODO: speed this up + X = (m(0,2) + m(2,0)) / scale; + Y = (m(1,2) + m(2,1)) / scale; + Z = 0.25f * scale; + W = (m(1,0) - m(0,1)) / scale; + } + } + + normalize(); + return *this; +} + + +//! multiplication operator +inline quaternion quaternion::operator*(const quaternion& other) const +{ + quaternion tmp; + + tmp.W = (other.W * W) - (other.X * X) - (other.Y * Y) - (other.Z * Z); + tmp.X = (other.W * X) + (other.X * W) + (other.Y * Z) - (other.Z * Y); + tmp.Y = (other.W * Y) + (other.Y * W) + (other.Z * X) - (other.X * Z); + tmp.Z = (other.W * Z) + (other.Z * W) + (other.X * Y) - (other.Y * X); + + return tmp; +} + + +//! multiplication operator +inline quaternion quaternion::operator*(f32 s) const +{ + return quaternion(s*X, s*Y, s*Z, s*W); +} + +//! multiplication operator +inline quaternion& quaternion::operator*=(f32 s) +{ + X *= s; Y*=s; Z*=s; W*=s; + return *this; +} + +//! multiplication operator +inline quaternion& quaternion::operator*=(const quaternion& other) +{ + *this = other * (*this); + return *this; +} + +//! add operator +inline quaternion quaternion::operator+(const quaternion& b) const +{ + return quaternion(X+b.X, Y+b.Y, Z+b.Z, W+b.W); +} + + +//! Creates a matrix from this quaternion +inline matrix4 quaternion::getMatrix() const +{ + core::matrix4 m; + + m(0,0) = 1.0f - 2.0f*Y*Y - 2.0f*Z*Z; + m(1,0) = 2.0f*X*Y + 2.0f*Z*W; + m(2,0) = 2.0f*X*Z - 2.0f*Y*W; + m(3,0) = 0.0f; + + m(0,1) = 2.0f*X*Y - 2.0f*Z*W; + m(1,1) = 1.0f - 2.0f*X*X - 2.0f*Z*Z; + m(2,1) = 2.0f*Z*Y + 2.0f*X*W; + m(3,1) = 0.0f; + + m(0,2) = 2.0f*X*Z + 2.0f*Y*W; + m(1,2) = 2.0f*Z*Y - 2.0f*X*W; + m(2,2) = 1.0f - 2.0f*X*X - 2.0f*Y*Y; + m(3,2) = 0.0f; + + m(0,3) = 0.0f; + m(1,3) = 0.0f; + m(2,3) = 0.0f; + m(3,3) = 1.0f; + + return m; +} + + +//! Creates a matrix from this quaternion +inline void quaternion::getMatrix( matrix4 &dest ) const +{ + dest[0] = 1.0f - 2.0f*Y*Y - 2.0f*Z*Z; + dest[1] = 2.0f*X*Y + 2.0f*Z*W; + dest[2] = 2.0f*X*Z - 2.0f*Y*W; + dest[3] = 0.0f; + + dest[4] = 2.0f*X*Y - 2.0f*Z*W; + dest[5] = 1.0f - 2.0f*X*X - 2.0f*Z*Z; + dest[6] = 2.0f*Z*Y + 2.0f*X*W; + dest[7] = 0.0f; + + dest[8] = 2.0f*X*Z + 2.0f*Y*W; + dest[9] = 2.0f*Z*Y - 2.0f*X*W; + dest[10] = 1.0f - 2.0f*X*X - 2.0f*Y*Y; + dest[11] = 0.0f; + + dest[12] = 0.f; + dest[13] = 0.f; + dest[14] = 0.f; + dest[15] = 1.f; +} + +//! Creates a matrix from this quaternion +inline void quaternion::getMatrix_transposed( matrix4 &dest ) const +{ + dest[0] = 1.0f - 2.0f*Y*Y - 2.0f*Z*Z; + dest[4] = 2.0f*X*Y + 2.0f*Z*W; + dest[8] = 2.0f*X*Z - 2.0f*Y*W; + dest[12] = 0.0f; + + dest[1] = 2.0f*X*Y - 2.0f*Z*W; + dest[5] = 1.0f - 2.0f*X*X - 2.0f*Z*Z; + dest[9] = 2.0f*Z*Y + 2.0f*X*W; + dest[13] = 0.0f; + + dest[2] = 2.0f*X*Z + 2.0f*Y*W; + dest[6] = 2.0f*Z*Y - 2.0f*X*W; + dest[10] = 1.0f - 2.0f*X*X - 2.0f*Y*Y; + dest[14] = 0.0f; + + dest[3] = 0.f; + dest[7] = 0.f; + dest[11] = 0.f; + dest[15] = 1.f; +} + + + +//! Inverts this quaternion +inline void quaternion::makeInverse() +{ + X = -X; Y = -Y; Z = -Z; +} + +//! sets new quaternion +inline void quaternion::set(f32 x, f32 y, f32 z, f32 w) +{ + X = x; + Y = y; + Z = z; + W = w; +} + + +//! sets new quaternion based on euler angles +inline void quaternion::set(f32 x, f32 y, f32 z) +{ + f64 angle; + + angle = x * 0.5; + f64 sr = (f32)sin(angle); + f64 cr = (f32)cos(angle); + + angle = y * 0.5; + f64 sp = (f32)sin(angle); + f64 cp = (f32)cos(angle); + + angle = z * 0.5; + f64 sy = (f32)sin(angle); + f64 cy = (f32)cos(angle); + + f64 cpcy = cp * cy; + f64 spcy = sp * cy; + f64 cpsy = cp * sy; + f64 spsy = sp * sy; + + X = (f32)(sr * cpcy - cr * spsy); + Y = (f32)(cr * spcy + sr * cpsy); + Z = (f32)(cr * cpsy - sr * spcy); + W = (f32)(cr * cpcy + sr * spsy); + + normalize(); +} + +//! normalizes the quaternion +inline quaternion& quaternion::normalize() +{ + f32 n = X*X + Y*Y + Z*Z + W*W; + + if (n == 1) + return *this; + + //n = 1.0f / sqrtf(n); + n = reciprocal_squareroot ( n ); + X *= n; + Y *= n; + Z *= n; + W *= n; + + return *this; +} + + +// set this quaternion to the result of the inpolation between two quaternions based +inline void quaternion::slerp( quaternion q1, quaternion q2, f32 time) +{ + f32 angle = q1.getDotProduct(q2); + + if (angle < 0.0f) + { + q1 *= -1.0f; + angle *= -1.0f; + } + + f32 scale; + f32 invscale; + + if ((angle + 1.0f) > 0.05f) + { + if ((1.0f - angle) >= 0.05f) // spherical interpolation + { + f32 theta = (f32)acos(angle); + f32 invsintheta = 1.0f / (f32)sin(theta); + scale = (f32)sin(theta * (1.0f-time)) * invsintheta; + invscale = (f32)sin(theta * time) * invsintheta; + } + else // linear interploation + { + scale = 1.0f - time; + invscale = time; + } + } + else + { + q2 = quaternion(-q1.Y, q1.X, -q1.W, q1.Z); + scale = (f32)sin(PI * (0.5f - time)); + invscale = (f32)sin(PI * time); + } + + *this = (q1*scale) + (q2*invscale); +} + + +//! calculates the dot product +inline f32 quaternion::getDotProduct(const quaternion& q2) const +{ + return (X * q2.X) + (Y * q2.Y) + (Z * q2.Z) + (W * q2.W); +} + + +inline void quaternion::fromAngleAxis(f32 angle, const vector3df& axis) +{ + f32 fHalfAngle = 0.5f*angle; + f32 fSin = (f32)sin(fHalfAngle); + W = (f32)cos(fHalfAngle); + X = fSin*axis.X; + Y = fSin*axis.Y; + Z = fSin*axis.Z; +} + +inline void quaternion::toEuler(vector3df& euler) const +{ + double sqw = W*W; + double sqx = X*X; + double sqy = Y*Y; + double sqz = Z*Z; + + // heading = rotation about z-axis + euler.Z = (f32) (atan2(2.0 * (X*Y +Z*W),(sqx - sqy - sqz + sqw))); + + // bank = rotation about x-axis + euler.X = (f32) (atan2(2.0 * (Y*Z +X*W),(-sqx - sqy + sqz + sqw))); + + // attitude = rotation about y-axis + euler.Y = (f32) (asin(-2.0 * (X*Z - Y*W))); +} + +inline vector3df quaternion::operator* (const vector3df& v) const +{ + // nVidia SDK implementation + + vector3df uv, uuv; + vector3df qvec(X, Y, Z); + uv = qvec.crossProduct(v); + uuv = qvec.crossProduct(uv); + uv *= (2.0f * W); + uuv *= 2.0f; + + return v + uv + uuv; +} + +//! set quaterion to identity +inline void quaternion::makeIdentity() +{ + W = 1.f; + X = 0.f; + Y = 0.f; + Z = 0.f; +} + + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/rect.h b/src/dep/include/irrlicht/rect.h index 4bb3bac..3094b96 100644 --- a/src/dep/include/irrlicht/rect.h +++ b/src/dep/include/irrlicht/rect.h @@ -1,226 +1,226 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_RECT_H_INCLUDED__ -#define __IRR_RECT_H_INCLUDED__ - -#include "irrTypes.h" -#include "dimension2d.h" -#include "position2d.h" - -namespace irr -{ -namespace core -{ - - //! Rectangle template. - /** Mostly used by 2D GUI elements and for 2D drawing methods. - It has 2 positions instead of position and dimension - and a fast method for collision detection with other rectangles and points. - */ - template - class rect - { - public: - - rect() - : UpperLeftCorner(0,0), LowerRightCorner(0,0) {}; - - - rect(T x, T y, T x2, T y2) - : UpperLeftCorner(x,y), LowerRightCorner(x2,y2) {}; - - - rect(const position2d& upperLeft, const position2d& lowerRight) - : UpperLeftCorner(upperLeft), LowerRightCorner(lowerRight) {}; - - rect(const rect& other) - : UpperLeftCorner(other.UpperLeftCorner), LowerRightCorner(other.LowerRightCorner) {}; - - rect(const position2d& pos, const dimension2d& size) - : UpperLeftCorner(pos), LowerRightCorner(pos.X + size.Width, pos.Y + size.Height) {}; - - - rect operator+(const position2d& pos) const - { - rect ret(*this); - ret.UpperLeftCorner += pos; - ret.LowerRightCorner += pos; - return ret; - } - - const rect& operator+=(const position2d& pos) - { - UpperLeftCorner += pos; - LowerRightCorner += pos; - return *this; - } - - rect operator-(const position2d& pos) const - { - rect ret(*this); - ret.UpperLeftCorner -= pos; - ret.LowerRightCorner -= pos; - return ret; - } - - const rect& operator-=(const position2d& pos) - { - UpperLeftCorner -= pos; - LowerRightCorner -= pos; - return *this; - } - - bool operator == (const rect& other) const - { - return (UpperLeftCorner == other.UpperLeftCorner && - LowerRightCorner == other.LowerRightCorner); - } - - - bool operator != (const rect& other) const - { - return (UpperLeftCorner != other.UpperLeftCorner || - LowerRightCorner != other.LowerRightCorner); - } - - const rect& operator = (const rect& other) - { - UpperLeftCorner = other.UpperLeftCorner; - LowerRightCorner = other.LowerRightCorner; - return *this; - } - - //! Returns if a 2d point is within this rectangle. - //! \param pos: Position to test if it lies within this rectangle. - //! \return Returns true if the position is within the rectangle, false if not. - bool isPointInside(const position2d& pos) const - { - return (UpperLeftCorner.X <= pos.X && - UpperLeftCorner.Y <= pos.Y && - LowerRightCorner.X >= pos.X && - LowerRightCorner.Y >= pos.Y); - } - - //! Returns if the rectangle collides with another rectangle. - bool isRectCollided(const rect& other) const - { - return (LowerRightCorner.Y > other.UpperLeftCorner.Y && - UpperLeftCorner.Y < other.LowerRightCorner.Y && - LowerRightCorner.X > other.UpperLeftCorner.X && - UpperLeftCorner.X < other.LowerRightCorner.X); - } - - //! Clips this rectangle with another one. - void clipAgainst(const rect& other) - { - if (other.LowerRightCorner.X < LowerRightCorner.X) - LowerRightCorner.X = other.LowerRightCorner.X; - if (other.LowerRightCorner.Y < LowerRightCorner.Y) - LowerRightCorner.Y = other.LowerRightCorner.Y; - - if (other.UpperLeftCorner.X > UpperLeftCorner.X) - UpperLeftCorner.X = other.UpperLeftCorner.X; - if (other.UpperLeftCorner.Y > UpperLeftCorner.Y) - UpperLeftCorner.Y = other.UpperLeftCorner.Y; - - // correct possible invalid rect resulting from clipping - if (UpperLeftCorner.Y > LowerRightCorner.Y) - UpperLeftCorner.Y = LowerRightCorner.Y; - if (UpperLeftCorner.X > LowerRightCorner.X) - UpperLeftCorner.X = LowerRightCorner.X; - } - - //! Returns width of rectangle. - T getWidth() const - { - return LowerRightCorner.X - UpperLeftCorner.X; - } - - //! Returns height of rectangle. - T getHeight() const - { - return LowerRightCorner.Y - UpperLeftCorner.Y; - } - - //! If the lower right corner of the rect is smaller then the - //! upper left, the points are swapped. - void repair() - { - if (LowerRightCorner.X < UpperLeftCorner.X) - { - T t = LowerRightCorner.X; - LowerRightCorner.X = UpperLeftCorner.X; - UpperLeftCorner.X = t; - } - - if (LowerRightCorner.Y < UpperLeftCorner.Y) - { - T t = LowerRightCorner.Y; - LowerRightCorner.Y = UpperLeftCorner.Y; - UpperLeftCorner.Y = t; - } - } - - //! Returns if the rect is valid to draw. It could be invalid - //! if the UpperLeftCorner is lower or more right than the - //! LowerRightCorner, or if the area described by the rect is 0. - bool isValid() const - { - // thx to jox for a correction to this method - - T xd = LowerRightCorner.X - UpperLeftCorner.X; - T yd = LowerRightCorner.Y - UpperLeftCorner.Y; - - return !(xd < 0 || yd < 0 || (xd == 0 && yd == 0)); - } - - //! Returns the center of the rectangle - position2d getCenter() const - { - return position2d((UpperLeftCorner.X + LowerRightCorner.X) / 2, - (UpperLeftCorner.Y + LowerRightCorner.Y) / 2); - } - - //! Returns the dimensions of the rectangle - dimension2d getSize() const - { - return dimension2d(getWidth(), getHeight()); - } - - - //! Adds a point to the rectangle, causing it to grow bigger, - //! if point is outside of the box - //! \param p: Point to add into the box. - void addInternalPoint(const position2d& p) - { - addInternalPoint(p.X, p.Y); - } - - //! Adds a point to the bounding rectangle, causing it to grow bigger, - //! if point is outside of the box. - //! \param x: X Coordinate of the point to add to this box. - //! \param y: Y Coordinate of the point to add to this box. - void addInternalPoint(T x, T y) - { - if (x>LowerRightCorner.X) LowerRightCorner.X = x; - if (y>LowerRightCorner.Y) LowerRightCorner.Y = y; - - if (x UpperLeftCorner; - position2d LowerRightCorner; - }; - -} // end namespace core -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_RECT_H_INCLUDED__ +#define __IRR_RECT_H_INCLUDED__ + +#include "irrTypes.h" +#include "dimension2d.h" +#include "position2d.h" + +namespace irr +{ +namespace core +{ + + //! Rectangle template. + /** Mostly used by 2D GUI elements and for 2D drawing methods. + It has 2 positions instead of position and dimension + and a fast method for collision detection with other rectangles and points. + */ + template + class rect + { + public: + + rect() + : UpperLeftCorner(0,0), LowerRightCorner(0,0) {}; + + + rect(T x, T y, T x2, T y2) + : UpperLeftCorner(x,y), LowerRightCorner(x2,y2) {}; + + + rect(const position2d& upperLeft, const position2d& lowerRight) + : UpperLeftCorner(upperLeft), LowerRightCorner(lowerRight) {}; + + rect(const rect& other) + : UpperLeftCorner(other.UpperLeftCorner), LowerRightCorner(other.LowerRightCorner) {}; + + rect(const position2d& pos, const dimension2d& size) + : UpperLeftCorner(pos), LowerRightCorner(pos.X + size.Width, pos.Y + size.Height) {}; + + + rect operator+(const position2d& pos) const + { + rect ret(*this); + ret.UpperLeftCorner += pos; + ret.LowerRightCorner += pos; + return ret; + } + + const rect& operator+=(const position2d& pos) + { + UpperLeftCorner += pos; + LowerRightCorner += pos; + return *this; + } + + rect operator-(const position2d& pos) const + { + rect ret(*this); + ret.UpperLeftCorner -= pos; + ret.LowerRightCorner -= pos; + return ret; + } + + const rect& operator-=(const position2d& pos) + { + UpperLeftCorner -= pos; + LowerRightCorner -= pos; + return *this; + } + + bool operator == (const rect& other) const + { + return (UpperLeftCorner == other.UpperLeftCorner && + LowerRightCorner == other.LowerRightCorner); + } + + + bool operator != (const rect& other) const + { + return (UpperLeftCorner != other.UpperLeftCorner || + LowerRightCorner != other.LowerRightCorner); + } + + const rect& operator = (const rect& other) + { + UpperLeftCorner = other.UpperLeftCorner; + LowerRightCorner = other.LowerRightCorner; + return *this; + } + + //! Returns if a 2d point is within this rectangle. + //! \param pos: Position to test if it lies within this rectangle. + //! \return Returns true if the position is within the rectangle, false if not. + bool isPointInside(const position2d& pos) const + { + return (UpperLeftCorner.X <= pos.X && + UpperLeftCorner.Y <= pos.Y && + LowerRightCorner.X >= pos.X && + LowerRightCorner.Y >= pos.Y); + } + + //! Returns if the rectangle collides with another rectangle. + bool isRectCollided(const rect& other) const + { + return (LowerRightCorner.Y > other.UpperLeftCorner.Y && + UpperLeftCorner.Y < other.LowerRightCorner.Y && + LowerRightCorner.X > other.UpperLeftCorner.X && + UpperLeftCorner.X < other.LowerRightCorner.X); + } + + //! Clips this rectangle with another one. + void clipAgainst(const rect& other) + { + if (other.LowerRightCorner.X < LowerRightCorner.X) + LowerRightCorner.X = other.LowerRightCorner.X; + if (other.LowerRightCorner.Y < LowerRightCorner.Y) + LowerRightCorner.Y = other.LowerRightCorner.Y; + + if (other.UpperLeftCorner.X > UpperLeftCorner.X) + UpperLeftCorner.X = other.UpperLeftCorner.X; + if (other.UpperLeftCorner.Y > UpperLeftCorner.Y) + UpperLeftCorner.Y = other.UpperLeftCorner.Y; + + // correct possible invalid rect resulting from clipping + if (UpperLeftCorner.Y > LowerRightCorner.Y) + UpperLeftCorner.Y = LowerRightCorner.Y; + if (UpperLeftCorner.X > LowerRightCorner.X) + UpperLeftCorner.X = LowerRightCorner.X; + } + + //! Returns width of rectangle. + T getWidth() const + { + return LowerRightCorner.X - UpperLeftCorner.X; + } + + //! Returns height of rectangle. + T getHeight() const + { + return LowerRightCorner.Y - UpperLeftCorner.Y; + } + + //! If the lower right corner of the rect is smaller then the + //! upper left, the points are swapped. + void repair() + { + if (LowerRightCorner.X < UpperLeftCorner.X) + { + T t = LowerRightCorner.X; + LowerRightCorner.X = UpperLeftCorner.X; + UpperLeftCorner.X = t; + } + + if (LowerRightCorner.Y < UpperLeftCorner.Y) + { + T t = LowerRightCorner.Y; + LowerRightCorner.Y = UpperLeftCorner.Y; + UpperLeftCorner.Y = t; + } + } + + //! Returns if the rect is valid to draw. It could be invalid + //! if the UpperLeftCorner is lower or more right than the + //! LowerRightCorner, or if the area described by the rect is 0. + bool isValid() const + { + // thx to jox for a correction to this method + + T xd = LowerRightCorner.X - UpperLeftCorner.X; + T yd = LowerRightCorner.Y - UpperLeftCorner.Y; + + return !(xd < 0 || yd < 0 || (xd == 0 && yd == 0)); + } + + //! Returns the center of the rectangle + position2d getCenter() const + { + return position2d((UpperLeftCorner.X + LowerRightCorner.X) / 2, + (UpperLeftCorner.Y + LowerRightCorner.Y) / 2); + } + + //! Returns the dimensions of the rectangle + dimension2d getSize() const + { + return dimension2d(getWidth(), getHeight()); + } + + + //! Adds a point to the rectangle, causing it to grow bigger, + //! if point is outside of the box + //! \param p: Point to add into the box. + void addInternalPoint(const position2d& p) + { + addInternalPoint(p.X, p.Y); + } + + //! Adds a point to the bounding rectangle, causing it to grow bigger, + //! if point is outside of the box. + //! \param x: X Coordinate of the point to add to this box. + //! \param y: Y Coordinate of the point to add to this box. + void addInternalPoint(T x, T y) + { + if (x>LowerRightCorner.X) LowerRightCorner.X = x; + if (y>LowerRightCorner.Y) LowerRightCorner.Y = y; + + if (x UpperLeftCorner; + position2d LowerRightCorner; + }; + +} // end namespace core +} // end namespace irr + + +#endif + diff --git a/src/dep/include/irrlicht/triangle3d.h b/src/dep/include/irrlicht/triangle3d.h index fa479e1..4c06bdb 100644 --- a/src/dep/include/irrlicht/triangle3d.h +++ b/src/dep/include/irrlicht/triangle3d.h @@ -1,215 +1,215 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_TRIANGLE_3D_H_INCLUDED__ -#define __IRR_TRIANGLE_3D_H_INCLUDED__ - -#include "vector3d.h" -#include "line3d.h" -#include "plane3d.h" -#include "aabbox3d.h" - -namespace irr -{ -namespace core -{ - - //! 3d triangle template class for doing collision detection and other things. - template - class triangle3d - { - public: - - //! Determines if the triangle is totally inside a bounding box. - //! \param box: Box to check. - //! \return Returns true if the triangle is withing the box, - //! and false otherwise. - bool isTotalInsideBox(const aabbox3d& box) const - { - return (box.isPointInside(pointA) && - box.isPointInside(pointB) && - box.isPointInside(pointC)); - } - - bool operator==(const triangle3d& other) const { return other.pointA==pointA && other.pointB==pointB && other.pointC==pointC; } - bool operator!=(const triangle3d& other) const { return other.pointA!=pointA || other.pointB!=pointB || other.pointC!=pointC; } - - //! Returns the closest point on a triangle to a point on the same plane. - //! \param p: Point which must be on the same plane as the triangle. - core::vector3d closestPointOnTriangle(const core::vector3d& p) const - { - core::vector3d rab = line3d(pointA, pointB).getClosestPoint(p); - core::vector3d rbc = line3d(pointB, pointC).getClosestPoint(p); - core::vector3d rca = line3d(pointC, pointA).getClosestPoint(p); - - T d1 = rab.getDistanceFrom(p); - T d2 = rbc.getDistanceFrom(p); - T d3 = rca.getDistanceFrom(p); - - if (d1 < d2) - return d1 < d3 ? rab : rca; - - return d2 < d3 ? rbc : rca; - } - - //! Returns if a point is inside the triangle - //! \param p: Point to test. Assumes that this point is already on the plane - //! of the triangle. - //! \return Returns true if the point is inside the triangle, otherwise false. - bool isPointInside(const vector3d& p) const - { - return (isOnSameSide(p, pointA, pointB, pointC) && - isOnSameSide(p, pointB, pointA, pointC) && - isOnSameSide(p, pointC, pointA, pointB)); - } - - //! Returns if a point is inside the triangle. This method is an implementation - //! of the example used in a paper by Kasper Fauerby original written - //! by Keidy from Mr-Gamemaker. - //! \param p: Point to test. Assumes that this point is already on the plane - //! of the triangle. - //! \return Returns true if the point is inside the triangle, otherwise false. - bool isPointInsideFast(const vector3d& p) const - { - vector3d f = pointB - pointA; - vector3d g = pointC - pointA; - - f32 a = f.dotProduct(f); - f32 b = f.dotProduct(g); - f32 c = g.dotProduct(g); - - f32 ac_bb = (a*c)-(b*b); - vector3d vp = p - pointA; - - f32 d = vp.dotProduct(f); - f32 e = vp.dotProduct(g); - f32 x = (d*c)-(e*b); - f32 y = (e*a)-(d*b); - f32 z = x+y-ac_bb; - - return (( ((u32&)z)& ~(((u32&)x)|((u32&)y))) & 0x80000000)!=0; - } - - - bool isOnSameSide(const vector3d& p1, const vector3d& p2, - const vector3d& a, const vector3d& b) const - { - vector3d bminusa = b - a; - vector3d cp1 = bminusa.crossProduct(p1 - a); - vector3d cp2 = bminusa.crossProduct(p2 - a); - return (cp1.dotProduct(cp2) >= core::ROUNDING_ERROR_32); - } - - - //! Returns an intersection with a 3d line. - //! \param line: Line to intersect with. - //! \param outIntersection: Place to store the intersection point, if there is one. - //! \return Returns true if there was an intersection, false if there was not. - bool getIntersectionWithLimitedLine(const line3d& line, - vector3d& outIntersection) const - { - return getIntersectionWithLine(line.start, - line.getVector(), outIntersection) && - outIntersection.isBetweenPoints(line.start, line.end); - } - - - //! Returns an intersection with a 3d line. - //! Please note that also points are returned as intersection, which - //! are on the line, but not between the start and end point of the line. - //! If you want the returned point be between start and end, please - //! use getIntersectionWithLimitedLine(). - //! \param lineVect: Vector of the line to intersect with. - //! \param linePoint: Point of the line to intersect with. - //! \param outIntersection: Place to store the intersection point, if there is one. - //! \return Returns true if there was an intersection, false if there was not. - bool getIntersectionWithLine(const vector3d& linePoint, - const vector3d& lineVect, vector3d& outIntersection) const - { - if (getIntersectionOfPlaneWithLine(linePoint, lineVect, outIntersection)) - return isPointInside(outIntersection); - - return false; - } - - - //! Calculates the intersection between a 3d line and - //! the plane the triangle is on. - //! \param lineVect: Vector of the line to intersect with. - //! \param linePoint: Point of the line to intersect with. - //! \param outIntersection: Place to store the intersection point, if there is one. - //! \return Returns true if there was an intersection, false if there was not. - bool getIntersectionOfPlaneWithLine(const vector3d& linePoint, - const vector3d& lineVect, vector3d& outIntersection) const - { - const vector3d normal = getNormal().normalize(); - T t2; - - if ( core::iszero ( t2 = normal.dotProduct(lineVect) ) ) - return false; - - T d = pointA.dotProduct(normal); - T t = -(normal.dotProduct(linePoint) - d) / t2; - outIntersection = linePoint + (lineVect * t); - return true; - } - - - //! Returns the normal of the triangle. - //! Please note: The normal is not normalized. - vector3d getNormal() const - { - return (pointB - pointA).crossProduct(pointC - pointA); - } - - //! Returns if the triangle is front of backfacing. - //! \param lookDirection: Look direction. - //! \return Returns true if the plane is front facing, which mean it would - //! be visible, and false if it is backfacing. - bool isFrontFacing(const vector3d& lookDirection) const - { - vector3d n = getNormal(); - n.normalize(); - return n.dotProduct(lookDirection) <= 0.0f; - } - - //! Returns the plane of this triangle. - plane3d getPlane() const - { - return plane3d(pointA, pointB, pointC); - } - - //! Returns the area of the triangle - T getArea() const - { - return (pointB - pointA).crossProduct(pointC - pointA).getLength() * 0.5; - - } - - //! sets the triangle's points - void set(const core::vector3d& a, const core::vector3d& b, const core::vector3d& c) - { - pointA = a; - pointB = b; - pointC = c; - } - - //! the three points of the triangle - vector3d pointA; - vector3d pointB; - vector3d pointC; - }; - - - //! Typedef for a f32 3d triangle. - typedef triangle3d triangle3df; - - //! Typedef for an integer 3d triangle. - typedef triangle3d triangle3di; - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_TRIANGLE_3D_H_INCLUDED__ +#define __IRR_TRIANGLE_3D_H_INCLUDED__ + +#include "vector3d.h" +#include "line3d.h" +#include "plane3d.h" +#include "aabbox3d.h" + +namespace irr +{ +namespace core +{ + + //! 3d triangle template class for doing collision detection and other things. + template + class triangle3d + { + public: + + //! Determines if the triangle is totally inside a bounding box. + //! \param box: Box to check. + //! \return Returns true if the triangle is withing the box, + //! and false otherwise. + bool isTotalInsideBox(const aabbox3d& box) const + { + return (box.isPointInside(pointA) && + box.isPointInside(pointB) && + box.isPointInside(pointC)); + } + + bool operator==(const triangle3d& other) const { return other.pointA==pointA && other.pointB==pointB && other.pointC==pointC; } + bool operator!=(const triangle3d& other) const { return other.pointA!=pointA || other.pointB!=pointB || other.pointC!=pointC; } + + //! Returns the closest point on a triangle to a point on the same plane. + //! \param p: Point which must be on the same plane as the triangle. + core::vector3d closestPointOnTriangle(const core::vector3d& p) const + { + core::vector3d rab = line3d(pointA, pointB).getClosestPoint(p); + core::vector3d rbc = line3d(pointB, pointC).getClosestPoint(p); + core::vector3d rca = line3d(pointC, pointA).getClosestPoint(p); + + T d1 = rab.getDistanceFrom(p); + T d2 = rbc.getDistanceFrom(p); + T d3 = rca.getDistanceFrom(p); + + if (d1 < d2) + return d1 < d3 ? rab : rca; + + return d2 < d3 ? rbc : rca; + } + + //! Returns if a point is inside the triangle + //! \param p: Point to test. Assumes that this point is already on the plane + //! of the triangle. + //! \return Returns true if the point is inside the triangle, otherwise false. + bool isPointInside(const vector3d& p) const + { + return (isOnSameSide(p, pointA, pointB, pointC) && + isOnSameSide(p, pointB, pointA, pointC) && + isOnSameSide(p, pointC, pointA, pointB)); + } + + //! Returns if a point is inside the triangle. This method is an implementation + //! of the example used in a paper by Kasper Fauerby original written + //! by Keidy from Mr-Gamemaker. + //! \param p: Point to test. Assumes that this point is already on the plane + //! of the triangle. + //! \return Returns true if the point is inside the triangle, otherwise false. + bool isPointInsideFast(const vector3d& p) const + { + vector3d f = pointB - pointA; + vector3d g = pointC - pointA; + + f32 a = f.dotProduct(f); + f32 b = f.dotProduct(g); + f32 c = g.dotProduct(g); + + f32 ac_bb = (a*c)-(b*b); + vector3d vp = p - pointA; + + f32 d = vp.dotProduct(f); + f32 e = vp.dotProduct(g); + f32 x = (d*c)-(e*b); + f32 y = (e*a)-(d*b); + f32 z = x+y-ac_bb; + + return (( ((u32&)z)& ~(((u32&)x)|((u32&)y))) & 0x80000000)!=0; + } + + + bool isOnSameSide(const vector3d& p1, const vector3d& p2, + const vector3d& a, const vector3d& b) const + { + vector3d bminusa = b - a; + vector3d cp1 = bminusa.crossProduct(p1 - a); + vector3d cp2 = bminusa.crossProduct(p2 - a); + return (cp1.dotProduct(cp2) >= core::ROUNDING_ERROR_32); + } + + + //! Returns an intersection with a 3d line. + //! \param line: Line to intersect with. + //! \param outIntersection: Place to store the intersection point, if there is one. + //! \return Returns true if there was an intersection, false if there was not. + bool getIntersectionWithLimitedLine(const line3d& line, + vector3d& outIntersection) const + { + return getIntersectionWithLine(line.start, + line.getVector(), outIntersection) && + outIntersection.isBetweenPoints(line.start, line.end); + } + + + //! Returns an intersection with a 3d line. + //! Please note that also points are returned as intersection, which + //! are on the line, but not between the start and end point of the line. + //! If you want the returned point be between start and end, please + //! use getIntersectionWithLimitedLine(). + //! \param lineVect: Vector of the line to intersect with. + //! \param linePoint: Point of the line to intersect with. + //! \param outIntersection: Place to store the intersection point, if there is one. + //! \return Returns true if there was an intersection, false if there was not. + bool getIntersectionWithLine(const vector3d& linePoint, + const vector3d& lineVect, vector3d& outIntersection) const + { + if (getIntersectionOfPlaneWithLine(linePoint, lineVect, outIntersection)) + return isPointInside(outIntersection); + + return false; + } + + + //! Calculates the intersection between a 3d line and + //! the plane the triangle is on. + //! \param lineVect: Vector of the line to intersect with. + //! \param linePoint: Point of the line to intersect with. + //! \param outIntersection: Place to store the intersection point, if there is one. + //! \return Returns true if there was an intersection, false if there was not. + bool getIntersectionOfPlaneWithLine(const vector3d& linePoint, + const vector3d& lineVect, vector3d& outIntersection) const + { + const vector3d normal = getNormal().normalize(); + T t2; + + if ( core::iszero ( t2 = normal.dotProduct(lineVect) ) ) + return false; + + T d = pointA.dotProduct(normal); + T t = -(normal.dotProduct(linePoint) - d) / t2; + outIntersection = linePoint + (lineVect * t); + return true; + } + + + //! Returns the normal of the triangle. + //! Please note: The normal is not normalized. + vector3d getNormal() const + { + return (pointB - pointA).crossProduct(pointC - pointA); + } + + //! Returns if the triangle is front of backfacing. + //! \param lookDirection: Look direction. + //! \return Returns true if the plane is front facing, which mean it would + //! be visible, and false if it is backfacing. + bool isFrontFacing(const vector3d& lookDirection) const + { + vector3d n = getNormal(); + n.normalize(); + return n.dotProduct(lookDirection) <= 0.0f; + } + + //! Returns the plane of this triangle. + plane3d getPlane() const + { + return plane3d(pointA, pointB, pointC); + } + + //! Returns the area of the triangle + T getArea() const + { + return (pointB - pointA).crossProduct(pointC - pointA).getLength() * 0.5; + + } + + //! sets the triangle's points + void set(const core::vector3d& a, const core::vector3d& b, const core::vector3d& c) + { + pointA = a; + pointB = b; + pointC = c; + } + + //! the three points of the triangle + vector3d pointA; + vector3d pointB; + vector3d pointC; + }; + + + //! Typedef for a f32 3d triangle. + typedef triangle3d triangle3df; + + //! Typedef for an integer 3d triangle. + typedef triangle3d triangle3di; + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/vector2d.h b/src/dep/include/irrlicht/vector2d.h index f0b5493..fc90f41 100644 --- a/src/dep/include/irrlicht/vector2d.h +++ b/src/dep/include/irrlicht/vector2d.h @@ -1,254 +1,254 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_POINT_2D_H_INCLUDED__ -#define __IRR_POINT_2D_H_INCLUDED__ - -#include "irrMath.h" - -namespace irr -{ -namespace core -{ - - -//! 2d vector template class with lots of operators and methods. -template -class vector2d -{ -public: - - vector2d() : X(0), Y(0) {}; - vector2d(T nx, T ny) : X(nx), Y(ny) {}; - vector2d(const vector2d& other) : X(other.X), Y(other.Y) {}; - - // operators - - vector2d operator-() const { return vector2d(-X, -Y); } - - vector2d& operator=(const vector2d& other) { X = other.X; Y = other.Y; return *this; } - - vector2d operator+(const vector2d& other) const { return vector2d(X + other.X, Y + other.Y); } - vector2d& operator+=(const vector2d& other) { X+=other.X; Y+=other.Y; return *this; } - - vector2d operator-(const vector2d& other) const { return vector2d(X - other.X, Y - other.Y); } - vector2d& operator-=(const vector2d& other) { X-=other.X; Y-=other.Y; return *this; } - - vector2d operator*(const vector2d& other) const { return vector2d(X * other.X, Y * other.Y); } - vector2d& operator*=(const vector2d& other) { X*=other.X; Y*=other.Y; return *this; } - vector2d operator*(const T v) const { return vector2d(X * v, Y * v); } - vector2d& operator*=(const T v) { X*=v; Y*=v; return *this; } - - vector2d operator/(const vector2d& other) const { return vector2d(X / other.X, Y / other.Y); } - vector2d& operator/=(const vector2d& other) { X/=other.X; Y/=other.Y; return *this; } - vector2d operator/(const T v) const { return vector2d(X / v, Y / v); } - vector2d& operator/=(const T v) { X/=v; Y/=v; return *this; } - - bool operator<=(const vector2d&other) const { return X<=other.X && Y<=other.Y; } - bool operator>=(const vector2d&other) const { return X>=other.X && Y>=other.Y; } - - bool operator<(const vector2d&other) const { return X(const vector2d&other) const { return X>other.X && Y>other.Y; } - - bool operator==(const vector2d& other) const { return other.X==X && other.Y==Y; } - bool operator!=(const vector2d& other) const { return other.X!=X || other.Y!=Y; } - - // functions - - //! returns if this vector equals the other one, taking floating point rounding errors into account - bool equals(const vector2d& other) const - { - return core::equals(X, other.X) && - core::equals(Y, other.Y); - } - - void set(T nx, T ny) {X=nx; Y=ny; } - void set(const vector2d& p) { X=p.X; Y=p.Y;} - - //! Returns the length of the vector - //! \return Returns the length of the vector. - f64 getLength() const { return sqrt(X*X + Y*Y); } - - //! Returns the squared lenth of this vector - /** This is useful because it is much faster than getLength(). */ - T getLengthSQ() const { return X*X + Y*Y; } - - //! Returns the dot product of this vector with another. - T dotProduct(const vector2d& other) const - { - return X*other.X + Y*other.Y; - } - - //! Returns distance from another point. Here, the vector is interpreted as - //! point in 2 dimensional space. - f64 getDistanceFrom(const vector2d& other) const - { - return vector2d(X - other.X, Y - other.Y).getLength(); - } - - //! Returns squared distance from another point. Here, the vector is interpreted as - //! point in 2 dimensional space. - T getDistanceFromSQ(const vector2d& other) const - { - return vector2d(X - other.X, Y - other.Y).getLengthSQ(); - } - - //! rotates the point around a center by an amount of degrees. - void rotateBy(f64 degrees, const vector2d& center) - { - degrees *= DEGTORAD64; - T cs = (T)cos(degrees); - T sn = (T)sin(degrees); - - X -= center.X; - Y -= center.Y; - - set(X*cs - Y*sn, X*sn + Y*cs); - - X += center.X; - Y += center.Y; - } - - //! normalizes the vector. - vector2d& normalize() - { - T l = core::reciprocal_squareroot ( X*X + Y*Y ); -/* - T l = (T)getLength(); - if (l == 0) - return *this; - - l = (T)1.0 / l; -*/ - X *= l; - Y *= l; - return *this; - } - - //! Calculates the angle of this vector in grad in the trigonometric sense. - //! This method has been suggested by Pr3t3nd3r. - //! \return Returns a value between 0 and 360. - f64 getAngleTrig() const - { - if (X == 0.0) - return Y < 0.0 ? 270.0 : 90.0; - else - if (Y == 0) - return X < 0.0 ? 180.0 : 0.0; - - if ( Y > 0.0) - if (X > 0.0) - return atan(Y/X) * RADTODEG64; - else - return 180.0-atan(Y/-X) * RADTODEG64; - else - if (X > 0.0) - return 360.0-atan(-Y/X) * RADTODEG64; - else - return 180.0+atan(-Y/-X) * RADTODEG64; - } - - //! Calculates the angle of this vector in grad in the counter trigonometric sense. - //! \return Returns a value between 0 and 360. - inline f64 getAngle() const - { - if (Y == 0.0) // corrected thanks to a suggestion by Jox - return X < 0.0 ? 180.0 : 0.0; - else if (X == 0.0) - return Y < 0.0 ? 90.0 : 270.0; - - f64 tmp = Y / getLength(); - tmp = atan(sqrt(1 - tmp*tmp) / tmp) * RADTODEG64; - - if (X>0.0 && Y>0.0) - return tmp + 270; - else - if (X>0.0 && Y<0.0) - return tmp + 90; - else - if (X<0.0 && Y<0.0) - return 90 - tmp; - else - if (X<0.0 && Y>0.0) - return 270 - tmp; - - return tmp; - } - - //! Calculates the angle between this vector and another one in grad. - //! \return Returns a value between 0 and 90. - inline f64 getAngleWith(const vector2d& b) const - { - f64 tmp = X*b.X + Y*b.Y; - - if (tmp == 0.0) - return 90.0; - - tmp = tmp / sqrt((X*X + Y*Y) * (b.X*b.X + b.Y*b.Y)); - if (tmp < 0.0) tmp = -tmp; - - return atan(sqrt(1 - tmp*tmp) / tmp) * RADTODEG64; - } - - //! Returns if this vector interpreted as a point is on a line between two other points. - /** It is assumed that the point is on the line. */ - //! \param begin: Beginning vector to compare between. - //! \param end: Ending vector to compare between. - //! \return True if this vector is between begin and end. False if not. - bool isBetweenPoints(const vector2d& begin, const vector2d& end) const - { - T f = (end - begin).getLengthSQ(); - return getDistanceFromSQ(begin) < f && - getDistanceFromSQ(end) < f; - } - - //! returns interpolated vector - //! \param other: other vector to interpolate between - //! \param d: value between 0.0f and 1.0f. - vector2d getInterpolated(const vector2d& other, f32 d) const - { - T inv = (T) 1.0 - d; - return vector2d(other.X*inv + X*d, other.Y*inv + Y*d); - } - - //! Returns interpolated vector. ( quadratic ) - /** \param other0: other vector to interpolate between - \param other1: other vector to interpolate between - \param factor: value between 0.0f and 1.0f. */ - vector2d getInterpolated_quadratic(const vector2d& v2, const vector2d& v3, const T d) const - { - // this*(1-d)*(1-d) + 2 * v2 * (1-d) + v3 * d * d; - const T inv = (T) 1.0 - d; - const T mul0 = inv * inv; - const T mul1 = (T) 2.0 * d * inv; - const T mul2 = d * d; - - return vector2d ( X * mul0 + v2.X * mul1 + v3.X * mul2, - Y * mul0 + v2.Y * mul1 + v3.Y * mul2 - ); - } - - //! sets this vector to the interpolated vector between a and b. - void interpolate(const vector2d& a, const vector2d& b, const f32 t) - { - X = b.X + ( ( a.X - b.X ) * t ); - Y = b.Y + ( ( a.Y - b.Y ) * t ); - } - - // member variables - T X, Y; -}; - - //! Typedef for f32 2d vector. - typedef vector2d vector2df; - //! Typedef for integer 2d vector. - typedef vector2d vector2di; - - template vector2d operator*(const S scalar, const vector2d& vector) { return vector*scalar; } - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_POINT_2D_H_INCLUDED__ +#define __IRR_POINT_2D_H_INCLUDED__ + +#include "irrMath.h" + +namespace irr +{ +namespace core +{ + + +//! 2d vector template class with lots of operators and methods. +template +class vector2d +{ +public: + + vector2d() : X(0), Y(0) {}; + vector2d(T nx, T ny) : X(nx), Y(ny) {}; + vector2d(const vector2d& other) : X(other.X), Y(other.Y) {}; + + // operators + + vector2d operator-() const { return vector2d(-X, -Y); } + + vector2d& operator=(const vector2d& other) { X = other.X; Y = other.Y; return *this; } + + vector2d operator+(const vector2d& other) const { return vector2d(X + other.X, Y + other.Y); } + vector2d& operator+=(const vector2d& other) { X+=other.X; Y+=other.Y; return *this; } + + vector2d operator-(const vector2d& other) const { return vector2d(X - other.X, Y - other.Y); } + vector2d& operator-=(const vector2d& other) { X-=other.X; Y-=other.Y; return *this; } + + vector2d operator*(const vector2d& other) const { return vector2d(X * other.X, Y * other.Y); } + vector2d& operator*=(const vector2d& other) { X*=other.X; Y*=other.Y; return *this; } + vector2d operator*(const T v) const { return vector2d(X * v, Y * v); } + vector2d& operator*=(const T v) { X*=v; Y*=v; return *this; } + + vector2d operator/(const vector2d& other) const { return vector2d(X / other.X, Y / other.Y); } + vector2d& operator/=(const vector2d& other) { X/=other.X; Y/=other.Y; return *this; } + vector2d operator/(const T v) const { return vector2d(X / v, Y / v); } + vector2d& operator/=(const T v) { X/=v; Y/=v; return *this; } + + bool operator<=(const vector2d&other) const { return X<=other.X && Y<=other.Y; } + bool operator>=(const vector2d&other) const { return X>=other.X && Y>=other.Y; } + + bool operator<(const vector2d&other) const { return X(const vector2d&other) const { return X>other.X && Y>other.Y; } + + bool operator==(const vector2d& other) const { return other.X==X && other.Y==Y; } + bool operator!=(const vector2d& other) const { return other.X!=X || other.Y!=Y; } + + // functions + + //! returns if this vector equals the other one, taking floating point rounding errors into account + bool equals(const vector2d& other) const + { + return core::equals(X, other.X) && + core::equals(Y, other.Y); + } + + void set(T nx, T ny) {X=nx; Y=ny; } + void set(const vector2d& p) { X=p.X; Y=p.Y;} + + //! Returns the length of the vector + //! \return Returns the length of the vector. + f64 getLength() const { return sqrt(X*X + Y*Y); } + + //! Returns the squared lenth of this vector + /** This is useful because it is much faster than getLength(). */ + T getLengthSQ() const { return X*X + Y*Y; } + + //! Returns the dot product of this vector with another. + T dotProduct(const vector2d& other) const + { + return X*other.X + Y*other.Y; + } + + //! Returns distance from another point. Here, the vector is interpreted as + //! point in 2 dimensional space. + f64 getDistanceFrom(const vector2d& other) const + { + return vector2d(X - other.X, Y - other.Y).getLength(); + } + + //! Returns squared distance from another point. Here, the vector is interpreted as + //! point in 2 dimensional space. + T getDistanceFromSQ(const vector2d& other) const + { + return vector2d(X - other.X, Y - other.Y).getLengthSQ(); + } + + //! rotates the point around a center by an amount of degrees. + void rotateBy(f64 degrees, const vector2d& center) + { + degrees *= DEGTORAD64; + T cs = (T)cos(degrees); + T sn = (T)sin(degrees); + + X -= center.X; + Y -= center.Y; + + set(X*cs - Y*sn, X*sn + Y*cs); + + X += center.X; + Y += center.Y; + } + + //! normalizes the vector. + vector2d& normalize() + { + T l = core::reciprocal_squareroot ( X*X + Y*Y ); +/* + T l = (T)getLength(); + if (l == 0) + return *this; + + l = (T)1.0 / l; +*/ + X *= l; + Y *= l; + return *this; + } + + //! Calculates the angle of this vector in grad in the trigonometric sense. + //! This method has been suggested by Pr3t3nd3r. + //! \return Returns a value between 0 and 360. + f64 getAngleTrig() const + { + if (X == 0.0) + return Y < 0.0 ? 270.0 : 90.0; + else + if (Y == 0) + return X < 0.0 ? 180.0 : 0.0; + + if ( Y > 0.0) + if (X > 0.0) + return atan(Y/X) * RADTODEG64; + else + return 180.0-atan(Y/-X) * RADTODEG64; + else + if (X > 0.0) + return 360.0-atan(-Y/X) * RADTODEG64; + else + return 180.0+atan(-Y/-X) * RADTODEG64; + } + + //! Calculates the angle of this vector in grad in the counter trigonometric sense. + //! \return Returns a value between 0 and 360. + inline f64 getAngle() const + { + if (Y == 0.0) // corrected thanks to a suggestion by Jox + return X < 0.0 ? 180.0 : 0.0; + else if (X == 0.0) + return Y < 0.0 ? 90.0 : 270.0; + + f64 tmp = Y / getLength(); + tmp = atan(sqrt(1 - tmp*tmp) / tmp) * RADTODEG64; + + if (X>0.0 && Y>0.0) + return tmp + 270; + else + if (X>0.0 && Y<0.0) + return tmp + 90; + else + if (X<0.0 && Y<0.0) + return 90 - tmp; + else + if (X<0.0 && Y>0.0) + return 270 - tmp; + + return tmp; + } + + //! Calculates the angle between this vector and another one in grad. + //! \return Returns a value between 0 and 90. + inline f64 getAngleWith(const vector2d& b) const + { + f64 tmp = X*b.X + Y*b.Y; + + if (tmp == 0.0) + return 90.0; + + tmp = tmp / sqrt((X*X + Y*Y) * (b.X*b.X + b.Y*b.Y)); + if (tmp < 0.0) tmp = -tmp; + + return atan(sqrt(1 - tmp*tmp) / tmp) * RADTODEG64; + } + + //! Returns if this vector interpreted as a point is on a line between two other points. + /** It is assumed that the point is on the line. */ + //! \param begin: Beginning vector to compare between. + //! \param end: Ending vector to compare between. + //! \return True if this vector is between begin and end. False if not. + bool isBetweenPoints(const vector2d& begin, const vector2d& end) const + { + T f = (end - begin).getLengthSQ(); + return getDistanceFromSQ(begin) < f && + getDistanceFromSQ(end) < f; + } + + //! returns interpolated vector + //! \param other: other vector to interpolate between + //! \param d: value between 0.0f and 1.0f. + vector2d getInterpolated(const vector2d& other, f32 d) const + { + T inv = (T) 1.0 - d; + return vector2d(other.X*inv + X*d, other.Y*inv + Y*d); + } + + //! Returns interpolated vector. ( quadratic ) + /** \param other0: other vector to interpolate between + \param other1: other vector to interpolate between + \param factor: value between 0.0f and 1.0f. */ + vector2d getInterpolated_quadratic(const vector2d& v2, const vector2d& v3, const T d) const + { + // this*(1-d)*(1-d) + 2 * v2 * (1-d) + v3 * d * d; + const T inv = (T) 1.0 - d; + const T mul0 = inv * inv; + const T mul1 = (T) 2.0 * d * inv; + const T mul2 = d * d; + + return vector2d ( X * mul0 + v2.X * mul1 + v3.X * mul2, + Y * mul0 + v2.Y * mul1 + v3.Y * mul2 + ); + } + + //! sets this vector to the interpolated vector between a and b. + void interpolate(const vector2d& a, const vector2d& b, const f32 t) + { + X = b.X + ( ( a.X - b.X ) * t ); + Y = b.Y + ( ( a.Y - b.Y ) * t ); + } + + // member variables + T X, Y; +}; + + //! Typedef for f32 2d vector. + typedef vector2d vector2df; + //! Typedef for integer 2d vector. + typedef vector2d vector2di; + + template vector2d operator*(const S scalar, const vector2d& vector) { return vector*scalar; } + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/irrlicht/vector3d.h b/src/dep/include/irrlicht/vector3d.h index 168ac5b..9f8f627 100644 --- a/src/dep/include/irrlicht/vector3d.h +++ b/src/dep/include/irrlicht/vector3d.h @@ -1,305 +1,305 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_POINT_3D_H_INCLUDED__ -#define __IRR_POINT_3D_H_INCLUDED__ - -#include "irrMath.h" - -namespace irr -{ -namespace core -{ - - //! 3d vector template class with lots of operators and methods. - template - class vector3d - { - public: - -#ifdef IRRLICHT_FAST_MATH - vector3d() {}; -#else - vector3d() : X(0), Y(0), Z(0) {}; -#endif - - vector3d(T nx, T ny, T nz) : X(nx), Y(ny), Z(nz) {}; - vector3d(const vector3d& other) : X(other.X), Y(other.Y), Z(other.Z) {}; - - // operators - - vector3d operator-() const { return vector3d(-X, -Y, -Z); } - - vector3d& operator=(const vector3d& other) { X = other.X; Y = other.Y; Z = other.Z; return *this; } - - vector3d operator+(const vector3d& other) const { return vector3d(X + other.X, Y + other.Y, Z + other.Z); } - vector3d& operator+=(const vector3d& other) { X+=other.X; Y+=other.Y; Z+=other.Z; return *this; } - - vector3d operator-(const vector3d& other) const { return vector3d(X - other.X, Y - other.Y, Z - other.Z); } - vector3d& operator-=(const vector3d& other) { X-=other.X; Y-=other.Y; Z-=other.Z; return *this; } - - vector3d operator*(const vector3d& other) const { return vector3d(X * other.X, Y * other.Y, Z * other.Z); } - vector3d& operator*=(const vector3d& other) { X*=other.X; Y*=other.Y; Z*=other.Z; return *this; } - vector3d operator*(const T v) const { return vector3d(X * v, Y * v, Z * v); } - vector3d& operator*=(const T v) { X*=v; Y*=v; Z*=v; return *this; } - - vector3d operator/(const vector3d& other) const { return vector3d(X / other.X, Y / other.Y, Z / other.Z); } - vector3d& operator/=(const vector3d& other) { X/=other.X; Y/=other.Y; Z/=other.Z; return *this; } - vector3d operator/(const T v) const { T i=(T)1.0/v; return vector3d(X * i, Y * i, Z * i); } - vector3d& operator/=(const T v) { T i=(T)1.0/v; X*=i; Y*=i; Z*=i; return *this; } - - bool operator<=(const vector3d&other) const { return X<=other.X && Y<=other.Y && Z<=other.Z;}; - bool operator>=(const vector3d&other) const { return X>=other.X && Y>=other.Y && Z>=other.Z;}; - bool operator<(const vector3d&other) const { return X(const vector3d&other) const { return X>other.X && Y>other.Y && Z>other.Z;}; - - //! use week float compare - //bool operator==(const vector3d& other) const { return other.X==X && other.Y==Y && other.Z==Z; } - //bool operator!=(const vector3d& other) const { return other.X!=X || other.Y!=Y || other.Z!=Z; } - - bool operator==(const vector3d& other) const - { - return core::equals(X, other.X) && - core::equals(Y, other.Y) && - core::equals(Z, other.Z); - } - - bool operator!=(const vector3d& other) const - { - return !core::equals(X, other.X) || - !core::equals(Y, other.Y) || - !core::equals(Z, other.Z); - } - - // functions - - //! returns if this vector equals the other one, taking floating point rounding errors into account - bool equals(const vector3d& other, const f32 tolerance = ROUNDING_ERROR_32 ) const - { - return core::equals(X, other.X, tolerance) && - core::equals(Y, other.Y, tolerance) && - core::equals(Z, other.Z, tolerance); - } - - void set(const T nx, const T ny, const T nz) {X=nx; Y=ny; Z=nz; } - void set(const vector3d& p) { X=p.X; Y=p.Y; Z=p.Z;} - - //! Returns length of the vector. - T getLength() const { return (T) sqrt(X*X + Y*Y + Z*Z); } - - //! Returns squared length of the vector. - /** This is useful because it is much faster than - getLength(). */ - T getLengthSQ() const { return X*X + Y*Y + Z*Z; } - - //! Returns the dot product with another vector. - T dotProduct(const vector3d& other) const - { - return X*other.X + Y*other.Y + Z*other.Z; - } - - //! Returns distance from another point. - /** Here, the vector is interpreted as point in 3 dimensional space. */ - f64 getDistanceFrom(const vector3d& other) const - { - return vector3d(X - other.X, Y - other.Y, Z - other.Z).getLength(); - } - - //! Returns squared distance from another point. - /** Here, the vector is interpreted as point in 3 dimensional space. */ - T getDistanceFromSQ(const vector3d& other) const - { - return vector3d(X - other.X, Y - other.Y, Z - other.Z).getLengthSQ(); - } - - //! Calculates the cross product with another vector - //! \param p: vector to multiply with. - //! \return Crossproduct of this vector with p. - vector3d crossProduct(const vector3d& p) const - { - return vector3d(Y * p.Z - Z * p.Y, Z * p.X - X * p.Z, X * p.Y - Y * p.X); - } - - //! Returns if this vector interpreted as a point is on a line between two other points. - /** It is assumed that the point is on the line. */ - //! \param begin: Beginning vector to compare between. - //! \param end: Ending vector to compare between. - //! \return True if this vector is between begin and end. False if not. - bool isBetweenPoints(const vector3d& begin, const vector3d& end) const - { - T f = (end - begin).getLengthSQ(); - return getDistanceFromSQ(begin) < f && - getDistanceFromSQ(end) < f; - } - - //! Normalizes the vector. - //! Todo: 64 Bit template doesnt work.. need specialized template - vector3d& normalize() - { - T l = (T) reciprocal_squareroot ( f32(X*X + Y*Y + Z*Z) ); - - X *= l; - Y *= l; - Z *= l; - return *this; - -/* - T l = (T)getLength(); - if (l == 0) - return *this; - - l = (T)1.0 / l; - X *= l; - Y *= l; - Z *= l; - return *this; -*/ - } - - //! Sets the length of the vector to a new value - void setLength(T newlength) - { - normalize(); - *this *= newlength; - } - - //! Inverts the vector. - void invert() - { - X *= -1.0f; - Y *= -1.0f; - Z *= -1.0f; - } - - //! Rotates the vector by a specified number of degrees around the Y - //! axis and the specified center. - //! \param degrees: Number of degrees to rotate around the Y axis. - //! \param center: The center of the rotation. - void rotateXZBy(f64 degrees, const vector3d& center) - { - degrees *= DEGTORAD64; - T cs = (T)cos(degrees); - T sn = (T)sin(degrees); - X -= center.X; - Z -= center.Z; - set(X*cs - Z*sn, Y, X*sn + Z*cs); - X += center.X; - Z += center.Z; - } - - //! Rotates the vector by a specified number of degrees around the Z - //! axis and the specified center. - //! \param degrees: Number of degrees to rotate around the Z axis. - //! \param center: The center of the rotation. - void rotateXYBy(f64 degrees, const vector3d& center) - { - degrees *= DEGTORAD64; - T cs = (T)cos(degrees); - T sn = (T)sin(degrees); - X -= center.X; - Y -= center.Y; - set(X*cs - Y*sn, X*sn + Y*cs, Z); - X += center.X; - Y += center.Y; - } - - //! Rotates the vector by a specified number of degrees around the X - //! axis and the specified center. - //! \param degrees: Number of degrees to rotate around the X axis. - //! \param center: The center of the rotation. - void rotateYZBy(f64 degrees, const vector3d& center) - { - degrees *= DEGTORAD64; - T cs = (T)cos(degrees); - T sn = (T)sin(degrees); - Z -= center.Z; - Y -= center.Y; - set(X, Y*cs - Z*sn, Y*sn + Z*cs); - Z += center.Z; - Y += center.Y; - } - - //! Returns interpolated vector. - /** \param other: other vector to interpolate between - \param d: value between 0.0f and 1.0f. */ - vector3d getInterpolated(const vector3d& other, const T d) const - { - const T inv = (T) 1.0 - d; - return vector3d(other.X*inv + X*d, other.Y*inv + Y*d, other.Z*inv + Z*d); - } - - //! Returns interpolated vector. ( quadratic ) - /** \param other0: other vector to interpolate between - \param other1: other vector to interpolate between - \param factor: value between 0.0f and 1.0f. */ - vector3d getInterpolated_quadratic(const vector3d& v2, const vector3d& v3, const T d) const - { - // this*(1-d)*(1-d) + 2 * v2 * (1-d) + v3 * d * d; - const T inv = (T) 1.0 - d; - const T mul0 = inv * inv; - const T mul1 = (T) 2.0 * d * inv; - const T mul2 = d * d; - - return vector3d ( X * mul0 + v2.X * mul1 + v3.X * mul2, - Y * mul0 + v2.Y * mul1 + v3.Y * mul2, - Z * mul0 + v2.Z * mul1 + v3.Z * mul2 - ); - } - - //! Gets the Y and Z rotations of a vector. - /** Thanks to Arras on the Irrlicht forums to add this method. - \return A vector representing the rotation in degrees of - this vector. The Z component of the vector will always be 0. */ - vector3d getHorizontalAngle() - { - vector3d angle; - - angle.Y = (T)atan2(X, Z); - angle.Y *= (f32)RADTODEG64; - - if (angle.Y < 0.0f) angle.Y += 360.0f; - if (angle.Y >= 360.0f) angle.Y -= 360.0f; - - f32 z1 = (f32)sqrt(X*X + Z*Z); - - angle.X = (T)atan2(z1, Y); - angle.X *= (f32)RADTODEG64; - angle.X -= 90.0f; - - if (angle.X < 0.0f) angle.X += 360.0f; - if (angle.X >= 360.0f) angle.X -= 360.0f; - - return angle; - } - - //! Fills an array of 4 values with the vector data (usually floats). - /** Useful for setting in shader constants for example. The fourth value - will always be 0. */ - void getAs4Values(T* array) const - { - array[0] = X; - array[1] = Y; - array[2] = Z; - array[3] = 0; - } - - - // member variables - - T X, Y, Z; - }; - - - //! Typedef for a f32 3d vector. - typedef vector3d vector3df; - //! Typedef for an integer 3d vector. - typedef vector3d vector3di; - - template vector3d operator*(const S scalar, const vector3d& vector) { return vector*scalar; } - -} // end namespace core -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_POINT_3D_H_INCLUDED__ +#define __IRR_POINT_3D_H_INCLUDED__ + +#include "irrMath.h" + +namespace irr +{ +namespace core +{ + + //! 3d vector template class with lots of operators and methods. + template + class vector3d + { + public: + +#ifdef IRRLICHT_FAST_MATH + vector3d() {}; +#else + vector3d() : X(0), Y(0), Z(0) {}; +#endif + + vector3d(T nx, T ny, T nz) : X(nx), Y(ny), Z(nz) {}; + vector3d(const vector3d& other) : X(other.X), Y(other.Y), Z(other.Z) {}; + + // operators + + vector3d operator-() const { return vector3d(-X, -Y, -Z); } + + vector3d& operator=(const vector3d& other) { X = other.X; Y = other.Y; Z = other.Z; return *this; } + + vector3d operator+(const vector3d& other) const { return vector3d(X + other.X, Y + other.Y, Z + other.Z); } + vector3d& operator+=(const vector3d& other) { X+=other.X; Y+=other.Y; Z+=other.Z; return *this; } + + vector3d operator-(const vector3d& other) const { return vector3d(X - other.X, Y - other.Y, Z - other.Z); } + vector3d& operator-=(const vector3d& other) { X-=other.X; Y-=other.Y; Z-=other.Z; return *this; } + + vector3d operator*(const vector3d& other) const { return vector3d(X * other.X, Y * other.Y, Z * other.Z); } + vector3d& operator*=(const vector3d& other) { X*=other.X; Y*=other.Y; Z*=other.Z; return *this; } + vector3d operator*(const T v) const { return vector3d(X * v, Y * v, Z * v); } + vector3d& operator*=(const T v) { X*=v; Y*=v; Z*=v; return *this; } + + vector3d operator/(const vector3d& other) const { return vector3d(X / other.X, Y / other.Y, Z / other.Z); } + vector3d& operator/=(const vector3d& other) { X/=other.X; Y/=other.Y; Z/=other.Z; return *this; } + vector3d operator/(const T v) const { T i=(T)1.0/v; return vector3d(X * i, Y * i, Z * i); } + vector3d& operator/=(const T v) { T i=(T)1.0/v; X*=i; Y*=i; Z*=i; return *this; } + + bool operator<=(const vector3d&other) const { return X<=other.X && Y<=other.Y && Z<=other.Z;}; + bool operator>=(const vector3d&other) const { return X>=other.X && Y>=other.Y && Z>=other.Z;}; + bool operator<(const vector3d&other) const { return X(const vector3d&other) const { return X>other.X && Y>other.Y && Z>other.Z;}; + + //! use week float compare + //bool operator==(const vector3d& other) const { return other.X==X && other.Y==Y && other.Z==Z; } + //bool operator!=(const vector3d& other) const { return other.X!=X || other.Y!=Y || other.Z!=Z; } + + bool operator==(const vector3d& other) const + { + return core::equals(X, other.X) && + core::equals(Y, other.Y) && + core::equals(Z, other.Z); + } + + bool operator!=(const vector3d& other) const + { + return !core::equals(X, other.X) || + !core::equals(Y, other.Y) || + !core::equals(Z, other.Z); + } + + // functions + + //! returns if this vector equals the other one, taking floating point rounding errors into account + bool equals(const vector3d& other, const f32 tolerance = ROUNDING_ERROR_32 ) const + { + return core::equals(X, other.X, tolerance) && + core::equals(Y, other.Y, tolerance) && + core::equals(Z, other.Z, tolerance); + } + + void set(const T nx, const T ny, const T nz) {X=nx; Y=ny; Z=nz; } + void set(const vector3d& p) { X=p.X; Y=p.Y; Z=p.Z;} + + //! Returns length of the vector. + T getLength() const { return (T) sqrt(X*X + Y*Y + Z*Z); } + + //! Returns squared length of the vector. + /** This is useful because it is much faster than + getLength(). */ + T getLengthSQ() const { return X*X + Y*Y + Z*Z; } + + //! Returns the dot product with another vector. + T dotProduct(const vector3d& other) const + { + return X*other.X + Y*other.Y + Z*other.Z; + } + + //! Returns distance from another point. + /** Here, the vector is interpreted as point in 3 dimensional space. */ + f64 getDistanceFrom(const vector3d& other) const + { + return vector3d(X - other.X, Y - other.Y, Z - other.Z).getLength(); + } + + //! Returns squared distance from another point. + /** Here, the vector is interpreted as point in 3 dimensional space. */ + T getDistanceFromSQ(const vector3d& other) const + { + return vector3d(X - other.X, Y - other.Y, Z - other.Z).getLengthSQ(); + } + + //! Calculates the cross product with another vector + //! \param p: vector to multiply with. + //! \return Crossproduct of this vector with p. + vector3d crossProduct(const vector3d& p) const + { + return vector3d(Y * p.Z - Z * p.Y, Z * p.X - X * p.Z, X * p.Y - Y * p.X); + } + + //! Returns if this vector interpreted as a point is on a line between two other points. + /** It is assumed that the point is on the line. */ + //! \param begin: Beginning vector to compare between. + //! \param end: Ending vector to compare between. + //! \return True if this vector is between begin and end. False if not. + bool isBetweenPoints(const vector3d& begin, const vector3d& end) const + { + T f = (end - begin).getLengthSQ(); + return getDistanceFromSQ(begin) < f && + getDistanceFromSQ(end) < f; + } + + //! Normalizes the vector. + //! Todo: 64 Bit template doesnt work.. need specialized template + vector3d& normalize() + { + T l = (T) reciprocal_squareroot ( f32(X*X + Y*Y + Z*Z) ); + + X *= l; + Y *= l; + Z *= l; + return *this; + +/* + T l = (T)getLength(); + if (l == 0) + return *this; + + l = (T)1.0 / l; + X *= l; + Y *= l; + Z *= l; + return *this; +*/ + } + + //! Sets the length of the vector to a new value + void setLength(T newlength) + { + normalize(); + *this *= newlength; + } + + //! Inverts the vector. + void invert() + { + X *= -1.0f; + Y *= -1.0f; + Z *= -1.0f; + } + + //! Rotates the vector by a specified number of degrees around the Y + //! axis and the specified center. + //! \param degrees: Number of degrees to rotate around the Y axis. + //! \param center: The center of the rotation. + void rotateXZBy(f64 degrees, const vector3d& center) + { + degrees *= DEGTORAD64; + T cs = (T)cos(degrees); + T sn = (T)sin(degrees); + X -= center.X; + Z -= center.Z; + set(X*cs - Z*sn, Y, X*sn + Z*cs); + X += center.X; + Z += center.Z; + } + + //! Rotates the vector by a specified number of degrees around the Z + //! axis and the specified center. + //! \param degrees: Number of degrees to rotate around the Z axis. + //! \param center: The center of the rotation. + void rotateXYBy(f64 degrees, const vector3d& center) + { + degrees *= DEGTORAD64; + T cs = (T)cos(degrees); + T sn = (T)sin(degrees); + X -= center.X; + Y -= center.Y; + set(X*cs - Y*sn, X*sn + Y*cs, Z); + X += center.X; + Y += center.Y; + } + + //! Rotates the vector by a specified number of degrees around the X + //! axis and the specified center. + //! \param degrees: Number of degrees to rotate around the X axis. + //! \param center: The center of the rotation. + void rotateYZBy(f64 degrees, const vector3d& center) + { + degrees *= DEGTORAD64; + T cs = (T)cos(degrees); + T sn = (T)sin(degrees); + Z -= center.Z; + Y -= center.Y; + set(X, Y*cs - Z*sn, Y*sn + Z*cs); + Z += center.Z; + Y += center.Y; + } + + //! Returns interpolated vector. + /** \param other: other vector to interpolate between + \param d: value between 0.0f and 1.0f. */ + vector3d getInterpolated(const vector3d& other, const T d) const + { + const T inv = (T) 1.0 - d; + return vector3d(other.X*inv + X*d, other.Y*inv + Y*d, other.Z*inv + Z*d); + } + + //! Returns interpolated vector. ( quadratic ) + /** \param other0: other vector to interpolate between + \param other1: other vector to interpolate between + \param factor: value between 0.0f and 1.0f. */ + vector3d getInterpolated_quadratic(const vector3d& v2, const vector3d& v3, const T d) const + { + // this*(1-d)*(1-d) + 2 * v2 * (1-d) + v3 * d * d; + const T inv = (T) 1.0 - d; + const T mul0 = inv * inv; + const T mul1 = (T) 2.0 * d * inv; + const T mul2 = d * d; + + return vector3d ( X * mul0 + v2.X * mul1 + v3.X * mul2, + Y * mul0 + v2.Y * mul1 + v3.Y * mul2, + Z * mul0 + v2.Z * mul1 + v3.Z * mul2 + ); + } + + //! Gets the Y and Z rotations of a vector. + /** Thanks to Arras on the Irrlicht forums to add this method. + \return A vector representing the rotation in degrees of + this vector. The Z component of the vector will always be 0. */ + vector3d getHorizontalAngle() + { + vector3d angle; + + angle.Y = (T)atan2(X, Z); + angle.Y *= (f32)RADTODEG64; + + if (angle.Y < 0.0f) angle.Y += 360.0f; + if (angle.Y >= 360.0f) angle.Y -= 360.0f; + + f32 z1 = (f32)sqrt(X*X + Z*Z); + + angle.X = (T)atan2(z1, Y); + angle.X *= (f32)RADTODEG64; + angle.X -= 90.0f; + + if (angle.X < 0.0f) angle.X += 360.0f; + if (angle.X >= 360.0f) angle.X -= 360.0f; + + return angle; + } + + //! Fills an array of 4 values with the vector data (usually floats). + /** Useful for setting in shader constants for example. The fourth value + will always be 0. */ + void getAs4Values(T* array) const + { + array[0] = X; + array[1] = Y; + array[2] = Z; + array[3] = 0; + } + + + // member variables + + T X, Y, Z; + }; + + + //! Typedef for a f32 3d vector. + typedef vector3d vector3df; + //! Typedef for an integer 3d vector. + typedef vector3d vector3di; + + template vector3d operator*(const S scalar, const vector3d& vector) { return vector*scalar; } + +} // end namespace core +} // end namespace irr + +#endif + diff --git a/src/dep/include/openssl/aes.h b/src/dep/include/openssl/aes.h index 3644129..7303262 100644 --- a/src/dep/include/openssl/aes.h +++ b/src/dep/include/openssl/aes.h @@ -1,127 +1,127 @@ -/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */ -/* ==================================================================== - * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - */ - -#ifndef HEADER_AES_H -#define HEADER_AES_H - -#include - -#ifdef OPENSSL_NO_AES -#error AES is disabled. -#endif - -#define AES_ENCRYPT 1 -#define AES_DECRYPT 0 - -/* Because array size can't be a const in C, the following two are macros. - Both sizes are in bytes. */ -#define AES_MAXNR 14 -#define AES_BLOCK_SIZE 16 - -#ifdef __cplusplus -extern "C" { -#endif - -/* This should be a hidden type, but EVP requires that the size be known */ -struct aes_key_st { -#ifdef AES_LONG - unsigned long rd_key[4 *(AES_MAXNR + 1)]; -#else - unsigned int rd_key[4 *(AES_MAXNR + 1)]; -#endif - int rounds; -}; -typedef struct aes_key_st AES_KEY; - -const char *AES_options(void); - -int AES_set_encrypt_key(const unsigned char *userKey, const int bits, - AES_KEY *key); -int AES_set_decrypt_key(const unsigned char *userKey, const int bits, - AES_KEY *key); - -void AES_encrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key); -void AES_decrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key); - -void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key, const int enc); -void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, - const unsigned long length, const AES_KEY *key, - unsigned char *ivec, const int enc); -void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, - const unsigned long length, const AES_KEY *key, - unsigned char *ivec, int *num, const int enc); -void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, - const unsigned long length, const AES_KEY *key, - unsigned char *ivec, int *num, const int enc); -void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, - const unsigned long length, const AES_KEY *key, - unsigned char *ivec, int *num, const int enc); -void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out, - const int nbits,const AES_KEY *key, - unsigned char *ivec,const int enc); -void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, - const unsigned long length, const AES_KEY *key, - unsigned char *ivec, int *num); -void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, - const unsigned long length, const AES_KEY *key, - unsigned char ivec[AES_BLOCK_SIZE], - unsigned char ecount_buf[AES_BLOCK_SIZE], - unsigned int *num); - - -#ifdef __cplusplus -} -#endif - -#endif /* !HEADER_AES_H */ +/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + */ + +#ifndef HEADER_AES_H +#define HEADER_AES_H + +#include + +#ifdef OPENSSL_NO_AES +#error AES is disabled. +#endif + +#define AES_ENCRYPT 1 +#define AES_DECRYPT 0 + +/* Because array size can't be a const in C, the following two are macros. + Both sizes are in bytes. */ +#define AES_MAXNR 14 +#define AES_BLOCK_SIZE 16 + +#ifdef __cplusplus +extern "C" { +#endif + +/* This should be a hidden type, but EVP requires that the size be known */ +struct aes_key_st { +#ifdef AES_LONG + unsigned long rd_key[4 *(AES_MAXNR + 1)]; +#else + unsigned int rd_key[4 *(AES_MAXNR + 1)]; +#endif + int rounds; +}; +typedef struct aes_key_st AES_KEY; + +const char *AES_options(void); + +int AES_set_encrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); +int AES_set_decrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); + +void AES_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); +void AES_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); + +void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key, const int enc); +void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, const int enc); +void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out, + const int nbits,const AES_KEY *key, + unsigned char *ivec,const int enc); +void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num); +void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char ivec[AES_BLOCK_SIZE], + unsigned char ecount_buf[AES_BLOCK_SIZE], + unsigned int *num); + + +#ifdef __cplusplus +} +#endif + +#endif /* !HEADER_AES_H */ diff --git a/src/dep/include/openssl/applink.c b/src/dep/include/openssl/applink.c index 7789bd9..54a0a64 100644 --- a/src/dep/include/openssl/applink.c +++ b/src/dep/include/openssl/applink.c @@ -1,94 +1,94 @@ -#define APPLINK_STDIN 1 -#define APPLINK_STDOUT 2 -#define APPLINK_STDERR 3 -#define APPLINK_FPRINTF 4 -#define APPLINK_FGETS 5 -#define APPLINK_FREAD 6 -#define APPLINK_FWRITE 7 -#define APPLINK_FSETMOD 8 -#define APPLINK_FEOF 9 -#define APPLINK_FCLOSE 10 /* should not be used */ - -#define APPLINK_FOPEN 11 /* solely for completeness */ -#define APPLINK_FSEEK 12 -#define APPLINK_FTELL 13 -#define APPLINK_FFLUSH 14 -#define APPLINK_FERROR 15 -#define APPLINK_CLEARERR 16 -#define APPLINK_FILENO 17 /* to be used with below */ - -#define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */ -#define APPLINK_READ 19 -#define APPLINK_WRITE 20 -#define APPLINK_LSEEK 21 -#define APPLINK_CLOSE 22 -#define APPLINK_MAX 22 /* always same as last macro */ - -#ifndef APPMACROS_ONLY -#include -#include -#include - -static void *app_stdin(void) { return stdin; } -static void *app_stdout(void) { return stdout; } -static void *app_stderr(void) { return stderr; } -static int app_feof(FILE *fp) { return feof(fp); } -static int app_ferror(FILE *fp) { return ferror(fp); } -static void app_clearerr(FILE *fp) { clearerr(fp); } -static int app_fileno(FILE *fp) { return _fileno(fp); } -static int app_fsetmod(FILE *fp,char mod) -{ return _setmode (_fileno(fp),mod=='b'?_O_BINARY:_O_TEXT); } - -#ifdef __cplusplus -extern "C" { -#endif - -__declspec(dllexport) -void ** -#if defined(__BORLANDC__) -__stdcall /* __stdcall appears to be the only way to get the name - * decoration right with Borland C. Otherwise it works - * purely incidentally, as we pass no parameters. */ -#else -__cdecl -#endif -OPENSSL_Applink(void) -{ static int once=1; - static void *OPENSSL_ApplinkTable[APPLINK_MAX+1]={(void *)APPLINK_MAX}; - - if (once) - { OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin; - OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout; - OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr; - OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf; - OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets; - OPENSSL_ApplinkTable[APPLINK_FREAD] = fread; - OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite; - OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod; - OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof; - OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose; - - OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen; - OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek; - OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell; - OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush; - OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror; - OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr; - OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno; - - OPENSSL_ApplinkTable[APPLINK_OPEN] = _open; - OPENSSL_ApplinkTable[APPLINK_READ] = _read; - OPENSSL_ApplinkTable[APPLINK_WRITE] = _write; - OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek; - OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close; - - once = 0; - } - - return OPENSSL_ApplinkTable; -} - -#ifdef __cplusplus -} -#endif -#endif +#define APPLINK_STDIN 1 +#define APPLINK_STDOUT 2 +#define APPLINK_STDERR 3 +#define APPLINK_FPRINTF 4 +#define APPLINK_FGETS 5 +#define APPLINK_FREAD 6 +#define APPLINK_FWRITE 7 +#define APPLINK_FSETMOD 8 +#define APPLINK_FEOF 9 +#define APPLINK_FCLOSE 10 /* should not be used */ + +#define APPLINK_FOPEN 11 /* solely for completeness */ +#define APPLINK_FSEEK 12 +#define APPLINK_FTELL 13 +#define APPLINK_FFLUSH 14 +#define APPLINK_FERROR 15 +#define APPLINK_CLEARERR 16 +#define APPLINK_FILENO 17 /* to be used with below */ + +#define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */ +#define APPLINK_READ 19 +#define APPLINK_WRITE 20 +#define APPLINK_LSEEK 21 +#define APPLINK_CLOSE 22 +#define APPLINK_MAX 22 /* always same as last macro */ + +#ifndef APPMACROS_ONLY +#include +#include +#include + +static void *app_stdin(void) { return stdin; } +static void *app_stdout(void) { return stdout; } +static void *app_stderr(void) { return stderr; } +static int app_feof(FILE *fp) { return feof(fp); } +static int app_ferror(FILE *fp) { return ferror(fp); } +static void app_clearerr(FILE *fp) { clearerr(fp); } +static int app_fileno(FILE *fp) { return _fileno(fp); } +static int app_fsetmod(FILE *fp,char mod) +{ return _setmode (_fileno(fp),mod=='b'?_O_BINARY:_O_TEXT); } + +#ifdef __cplusplus +extern "C" { +#endif + +__declspec(dllexport) +void ** +#if defined(__BORLANDC__) +__stdcall /* __stdcall appears to be the only way to get the name + * decoration right with Borland C. Otherwise it works + * purely incidentally, as we pass no parameters. */ +#else +__cdecl +#endif +OPENSSL_Applink(void) +{ static int once=1; + static void *OPENSSL_ApplinkTable[APPLINK_MAX+1]={(void *)APPLINK_MAX}; + + if (once) + { OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin; + OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout; + OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr; + OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf; + OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets; + OPENSSL_ApplinkTable[APPLINK_FREAD] = fread; + OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite; + OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod; + OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof; + OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose; + + OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen; + OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek; + OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell; + OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush; + OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror; + OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr; + OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno; + + OPENSSL_ApplinkTable[APPLINK_OPEN] = _open; + OPENSSL_ApplinkTable[APPLINK_READ] = _read; + OPENSSL_ApplinkTable[APPLINK_WRITE] = _write; + OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek; + OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close; + + once = 0; + } + + return OPENSSL_ApplinkTable; +} + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/asn1.h b/src/dep/include/openssl/asn1.h index 42d2252..6d03220 100644 --- a/src/dep/include/openssl/asn1.h +++ b/src/dep/include/openssl/asn1.h @@ -1,1233 +1,1233 @@ -/* crypto/asn1/asn1.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_ASN1_H -#define HEADER_ASN1_H - -#include -#include -#ifndef OPENSSL_NO_BIO -#include -#endif -#include -#include - -#include - -#include -#ifndef OPENSSL_NO_DEPRECATED -#include -#endif - -#ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define V_ASN1_UNIVERSAL 0x00 -#define V_ASN1_APPLICATION 0x40 -#define V_ASN1_CONTEXT_SPECIFIC 0x80 -#define V_ASN1_PRIVATE 0xc0 - -#define V_ASN1_CONSTRUCTED 0x20 -#define V_ASN1_PRIMITIVE_TAG 0x1f -#define V_ASN1_PRIMATIVE_TAG 0x1f - -#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */ -#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */ -#define V_ASN1_ANY -4 /* used in ASN1 template code */ - -#define V_ASN1_NEG 0x100 /* negative flag */ - -#define V_ASN1_UNDEF -1 -#define V_ASN1_EOC 0 -#define V_ASN1_BOOLEAN 1 /**/ -#define V_ASN1_INTEGER 2 -#define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG) -#define V_ASN1_BIT_STRING 3 -#define V_ASN1_OCTET_STRING 4 -#define V_ASN1_NULL 5 -#define V_ASN1_OBJECT 6 -#define V_ASN1_OBJECT_DESCRIPTOR 7 -#define V_ASN1_EXTERNAL 8 -#define V_ASN1_REAL 9 -#define V_ASN1_ENUMERATED 10 -#define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG) -#define V_ASN1_UTF8STRING 12 -#define V_ASN1_SEQUENCE 16 -#define V_ASN1_SET 17 -#define V_ASN1_NUMERICSTRING 18 /**/ -#define V_ASN1_PRINTABLESTRING 19 -#define V_ASN1_T61STRING 20 -#define V_ASN1_TELETEXSTRING 20 /* alias */ -#define V_ASN1_VIDEOTEXSTRING 21 /**/ -#define V_ASN1_IA5STRING 22 -#define V_ASN1_UTCTIME 23 -#define V_ASN1_GENERALIZEDTIME 24 /**/ -#define V_ASN1_GRAPHICSTRING 25 /**/ -#define V_ASN1_ISO64STRING 26 /**/ -#define V_ASN1_VISIBLESTRING 26 /* alias */ -#define V_ASN1_GENERALSTRING 27 /**/ -#define V_ASN1_UNIVERSALSTRING 28 /**/ -#define V_ASN1_BMPSTRING 30 - -/* For use with d2i_ASN1_type_bytes() */ -#define B_ASN1_NUMERICSTRING 0x0001 -#define B_ASN1_PRINTABLESTRING 0x0002 -#define B_ASN1_T61STRING 0x0004 -#define B_ASN1_TELETEXSTRING 0x0004 -#define B_ASN1_VIDEOTEXSTRING 0x0008 -#define B_ASN1_IA5STRING 0x0010 -#define B_ASN1_GRAPHICSTRING 0x0020 -#define B_ASN1_ISO64STRING 0x0040 -#define B_ASN1_VISIBLESTRING 0x0040 -#define B_ASN1_GENERALSTRING 0x0080 -#define B_ASN1_UNIVERSALSTRING 0x0100 -#define B_ASN1_OCTET_STRING 0x0200 -#define B_ASN1_BIT_STRING 0x0400 -#define B_ASN1_BMPSTRING 0x0800 -#define B_ASN1_UNKNOWN 0x1000 -#define B_ASN1_UTF8STRING 0x2000 -#define B_ASN1_UTCTIME 0x4000 -#define B_ASN1_GENERALIZEDTIME 0x8000 -#define B_ASN1_SEQUENCE 0x10000 - -/* For use with ASN1_mbstring_copy() */ -#define MBSTRING_FLAG 0x1000 -#define MBSTRING_UTF8 (MBSTRING_FLAG) -#define MBSTRING_ASC (MBSTRING_FLAG|1) -#define MBSTRING_BMP (MBSTRING_FLAG|2) -#define MBSTRING_UNIV (MBSTRING_FLAG|4) - -struct X509_algor_st; - -#define DECLARE_ASN1_SET_OF(type) /* filled in by mkstack.pl */ -#define IMPLEMENT_ASN1_SET_OF(type) /* nothing, no longer needed */ - -/* We MUST make sure that, except for constness, asn1_ctx_st and - asn1_const_ctx are exactly the same. Fortunately, as soon as - the old ASN1 parsing macros are gone, we can throw this away - as well... */ -typedef struct asn1_ctx_st - { - unsigned char *p;/* work char pointer */ - int eos; /* end of sequence read for indefinite encoding */ - int error; /* error code to use when returning an error */ - int inf; /* constructed if 0x20, indefinite is 0x21 */ - int tag; /* tag from last 'get object' */ - int xclass; /* class from last 'get object' */ - long slen; /* length of last 'get object' */ - unsigned char *max; /* largest value of p allowed */ - unsigned char *q;/* temporary variable */ - unsigned char **pp;/* variable */ - int line; /* used in error processing */ - } ASN1_CTX; - -typedef struct asn1_const_ctx_st - { - const unsigned char *p;/* work char pointer */ - int eos; /* end of sequence read for indefinite encoding */ - int error; /* error code to use when returning an error */ - int inf; /* constructed if 0x20, indefinite is 0x21 */ - int tag; /* tag from last 'get object' */ - int xclass; /* class from last 'get object' */ - long slen; /* length of last 'get object' */ - const unsigned char *max; /* largest value of p allowed */ - const unsigned char *q;/* temporary variable */ - const unsigned char **pp;/* variable */ - int line; /* used in error processing */ - } ASN1_const_CTX; - -/* These are used internally in the ASN1_OBJECT to keep track of - * whether the names and data need to be free()ed */ -#define ASN1_OBJECT_FLAG_DYNAMIC 0x01 /* internal use */ -#define ASN1_OBJECT_FLAG_CRITICAL 0x02 /* critical x509v3 object id */ -#define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04 /* internal use */ -#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */ -typedef struct asn1_object_st - { - const char *sn,*ln; - int nid; - int length; - unsigned char *data; - int flags; /* Should we free this one */ - } ASN1_OBJECT; - -#define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */ -/* This indicates that the ASN1_STRING is not a real value but just a place - * holder for the location where indefinite length constructed data should - * be inserted in the memory buffer - */ -#define ASN1_STRING_FLAG_NDEF 0x010 -/* This is the base type that holds just about everything :-) */ -typedef struct asn1_string_st - { - int length; - int type; - unsigned char *data; - /* The value of the following field depends on the type being - * held. It is mostly being used for BIT_STRING so if the - * input data has a non-zero 'unused bits' value, it will be - * handled correctly */ - long flags; - } ASN1_STRING; - -/* ASN1_ENCODING structure: this is used to save the received - * encoding of an ASN1 type. This is useful to get round - * problems with invalid encodings which can break signatures. - */ - -typedef struct ASN1_ENCODING_st - { - unsigned char *enc; /* DER encoding */ - long len; /* Length of encoding */ - int modified; /* set to 1 if 'enc' is invalid */ - } ASN1_ENCODING; - -/* Used with ASN1 LONG type: if a long is set to this it is omitted */ -#define ASN1_LONG_UNDEF 0x7fffffffL - -#define STABLE_FLAGS_MALLOC 0x01 -#define STABLE_NO_MASK 0x02 -#define DIRSTRING_TYPE \ - (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING) -#define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING) - -typedef struct asn1_string_table_st { - int nid; - long minsize; - long maxsize; - unsigned long mask; - unsigned long flags; -} ASN1_STRING_TABLE; - -DECLARE_STACK_OF(ASN1_STRING_TABLE) - -/* size limits: this stuff is taken straight from RFC2459 */ - -#define ub_name 32768 -#define ub_common_name 64 -#define ub_locality_name 128 -#define ub_state_name 128 -#define ub_organization_name 64 -#define ub_organization_unit_name 64 -#define ub_title 64 -#define ub_email_address 128 - -/* Declarations for template structures: for full definitions - * see asn1t.h - */ -typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE; -typedef struct ASN1_ITEM_st ASN1_ITEM; -typedef struct ASN1_TLC_st ASN1_TLC; -/* This is just an opaque pointer */ -typedef struct ASN1_VALUE_st ASN1_VALUE; - -/* Declare ASN1 functions: the implement macro in in asn1t.h */ - -#define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type) - -#define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type) - -#define DECLARE_ASN1_FUNCTIONS_name(type, name) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) - -#define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) - -#define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ - type *d2i_##name(type **a, const unsigned char **in, long len); \ - int i2d_##name(type *a, unsigned char **out); \ - DECLARE_ASN1_ITEM(itname) - -#define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ - type *d2i_##name(type **a, const unsigned char **in, long len); \ - int i2d_##name(const type *a, unsigned char **out); \ - DECLARE_ASN1_ITEM(name) - -#define DECLARE_ASN1_NDEF_FUNCTION(name) \ - int i2d_##name##_NDEF(name *a, unsigned char **out); - -#define DECLARE_ASN1_FUNCTIONS_const(name) \ - name *name##_new(void); \ - void name##_free(name *a); - -#define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ - type *name##_new(void); \ - void name##_free(type *a); - -#define D2I_OF(type) type *(*)(type **,const unsigned char **,long) -#define I2D_OF(type) int (*)(type *,unsigned char **) -#define I2D_OF_const(type) int (*)(const type *,unsigned char **) - -#define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long) -#define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **) -#define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type) - -TYPEDEF_D2I2D_OF(void); - -/* The following macros and typedefs allow an ASN1_ITEM - * to be embedded in a structure and referenced. Since - * the ASN1_ITEM pointers need to be globally accessible - * (possibly from shared libraries) they may exist in - * different forms. On platforms that support it the - * ASN1_ITEM structure itself will be globally exported. - * Other platforms will export a function that returns - * an ASN1_ITEM pointer. - * - * To handle both cases transparently the macros below - * should be used instead of hard coding an ASN1_ITEM - * pointer in a structure. - * - * The structure will look like this: - * - * typedef struct SOMETHING_st { - * ... - * ASN1_ITEM_EXP *iptr; - * ... - * } SOMETHING; - * - * It would be initialised as e.g.: - * - * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...}; - * - * and the actual pointer extracted with: - * - * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr); - * - * Finally an ASN1_ITEM pointer can be extracted from an - * appropriate reference with: ASN1_ITEM_rptr(X509). This - * would be used when a function takes an ASN1_ITEM * argument. - * - */ - -#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION - -/* ASN1_ITEM pointer exported type */ -typedef const ASN1_ITEM ASN1_ITEM_EXP; - -/* Macro to obtain ASN1_ITEM pointer from exported type */ -#define ASN1_ITEM_ptr(iptr) (iptr) - -/* Macro to include ASN1_ITEM pointer from base type */ -#define ASN1_ITEM_ref(iptr) (&(iptr##_it)) - -#define ASN1_ITEM_rptr(ref) (&(ref##_it)) - -#define DECLARE_ASN1_ITEM(name) \ - OPENSSL_EXTERN const ASN1_ITEM name##_it; - -#else - -/* Platforms that can't easily handle shared global variables are declared - * as functions returning ASN1_ITEM pointers. - */ - -/* ASN1_ITEM pointer exported type */ -typedef const ASN1_ITEM * ASN1_ITEM_EXP(void); - -/* Macro to obtain ASN1_ITEM pointer from exported type */ -#define ASN1_ITEM_ptr(iptr) (iptr()) - -/* Macro to include ASN1_ITEM pointer from base type */ -#define ASN1_ITEM_ref(iptr) (iptr##_it) - -#define ASN1_ITEM_rptr(ref) (ref##_it()) - -#define DECLARE_ASN1_ITEM(name) \ - const ASN1_ITEM * name##_it(void); - -#endif - -/* Parameters used by ASN1_STRING_print_ex() */ - -/* These determine which characters to escape: - * RFC2253 special characters, control characters and - * MSB set characters - */ - -#define ASN1_STRFLGS_ESC_2253 1 -#define ASN1_STRFLGS_ESC_CTRL 2 -#define ASN1_STRFLGS_ESC_MSB 4 - - -/* This flag determines how we do escaping: normally - * RC2253 backslash only, set this to use backslash and - * quote. - */ - -#define ASN1_STRFLGS_ESC_QUOTE 8 - - -/* These three flags are internal use only. */ - -/* Character is a valid PrintableString character */ -#define CHARTYPE_PRINTABLESTRING 0x10 -/* Character needs escaping if it is the first character */ -#define CHARTYPE_FIRST_ESC_2253 0x20 -/* Character needs escaping if it is the last character */ -#define CHARTYPE_LAST_ESC_2253 0x40 - -/* NB the internal flags are safely reused below by flags - * handled at the top level. - */ - -/* If this is set we convert all character strings - * to UTF8 first - */ - -#define ASN1_STRFLGS_UTF8_CONVERT 0x10 - -/* If this is set we don't attempt to interpret content: - * just assume all strings are 1 byte per character. This - * will produce some pretty odd looking output! - */ - -#define ASN1_STRFLGS_IGNORE_TYPE 0x20 - -/* If this is set we include the string type in the output */ -#define ASN1_STRFLGS_SHOW_TYPE 0x40 - -/* This determines which strings to display and which to - * 'dump' (hex dump of content octets or DER encoding). We can - * only dump non character strings or everything. If we - * don't dump 'unknown' they are interpreted as character - * strings with 1 octet per character and are subject to - * the usual escaping options. - */ - -#define ASN1_STRFLGS_DUMP_ALL 0x80 -#define ASN1_STRFLGS_DUMP_UNKNOWN 0x100 - -/* These determine what 'dumping' does, we can dump the - * content octets or the DER encoding: both use the - * RFC2253 #XXXXX notation. - */ - -#define ASN1_STRFLGS_DUMP_DER 0x200 - -/* All the string flags consistent with RFC2253, - * escaping control characters isn't essential in - * RFC2253 but it is advisable anyway. - */ - -#define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \ - ASN1_STRFLGS_ESC_CTRL | \ - ASN1_STRFLGS_ESC_MSB | \ - ASN1_STRFLGS_UTF8_CONVERT | \ - ASN1_STRFLGS_DUMP_UNKNOWN | \ - ASN1_STRFLGS_DUMP_DER) - -DECLARE_STACK_OF(ASN1_INTEGER) -DECLARE_ASN1_SET_OF(ASN1_INTEGER) - -DECLARE_STACK_OF(ASN1_GENERALSTRING) - -typedef struct asn1_type_st - { - int type; - union { - char *ptr; - ASN1_BOOLEAN boolean; - ASN1_STRING * asn1_string; - ASN1_OBJECT * object; - ASN1_INTEGER * integer; - ASN1_ENUMERATED * enumerated; - ASN1_BIT_STRING * bit_string; - ASN1_OCTET_STRING * octet_string; - ASN1_PRINTABLESTRING * printablestring; - ASN1_T61STRING * t61string; - ASN1_IA5STRING * ia5string; - ASN1_GENERALSTRING * generalstring; - ASN1_BMPSTRING * bmpstring; - ASN1_UNIVERSALSTRING * universalstring; - ASN1_UTCTIME * utctime; - ASN1_GENERALIZEDTIME * generalizedtime; - ASN1_VISIBLESTRING * visiblestring; - ASN1_UTF8STRING * utf8string; - /* set and sequence are left complete and still - * contain the set or sequence bytes */ - ASN1_STRING * set; - ASN1_STRING * sequence; - } value; - } ASN1_TYPE; - -DECLARE_STACK_OF(ASN1_TYPE) -DECLARE_ASN1_SET_OF(ASN1_TYPE) - -typedef struct asn1_method_st - { - i2d_of_void *i2d; - d2i_of_void *d2i; - void *(*create)(void); - void (*destroy)(void *); - } ASN1_METHOD; - -/* This is used when parsing some Netscape objects */ -typedef struct asn1_header_st - { - ASN1_OCTET_STRING *header; - void *data; - ASN1_METHOD *meth; - } ASN1_HEADER; - -/* This is used to contain a list of bit names */ -typedef struct BIT_STRING_BITNAME_st { - int bitnum; - const char *lname; - const char *sname; -} BIT_STRING_BITNAME; - - -#define M_ASN1_STRING_length(x) ((x)->length) -#define M_ASN1_STRING_length_set(x, n) ((x)->length = (n)) -#define M_ASN1_STRING_type(x) ((x)->type) -#define M_ASN1_STRING_data(x) ((x)->data) - -/* Macros for string operations */ -#define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\ - ASN1_STRING_type_new(V_ASN1_BIT_STRING) -#define M_ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\ - ASN1_STRING_dup((ASN1_STRING *)a) -#define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\ - (ASN1_STRING *)a,(ASN1_STRING *)b) -#define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) - -#define M_ASN1_INTEGER_new() (ASN1_INTEGER *)\ - ASN1_STRING_type_new(V_ASN1_INTEGER) -#define M_ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a) -#define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\ - (ASN1_STRING *)a,(ASN1_STRING *)b) - -#define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\ - ASN1_STRING_type_new(V_ASN1_ENUMERATED) -#define M_ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a) -#define M_ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\ - (ASN1_STRING *)a,(ASN1_STRING *)b) - -#define M_ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\ - ASN1_STRING_type_new(V_ASN1_OCTET_STRING) -#define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\ - ASN1_STRING_dup((ASN1_STRING *)a) -#define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\ - (ASN1_STRING *)a,(ASN1_STRING *)b) -#define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) -#define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b) -#define M_i2d_ASN1_OCTET_STRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\ - V_ASN1_UNIVERSAL) - -#define B_ASN1_TIME \ - B_ASN1_UTCTIME | \ - B_ASN1_GENERALIZEDTIME - -#define B_ASN1_PRINTABLE \ - B_ASN1_PRINTABLESTRING| \ - B_ASN1_T61STRING| \ - B_ASN1_IA5STRING| \ - B_ASN1_BIT_STRING| \ - B_ASN1_UNIVERSALSTRING|\ - B_ASN1_BMPSTRING|\ - B_ASN1_UTF8STRING|\ - B_ASN1_SEQUENCE|\ - B_ASN1_UNKNOWN - -#define B_ASN1_DIRECTORYSTRING \ - B_ASN1_PRINTABLESTRING| \ - B_ASN1_TELETEXSTRING|\ - B_ASN1_BMPSTRING|\ - B_ASN1_UNIVERSALSTRING|\ - B_ASN1_UTF8STRING - -#define B_ASN1_DISPLAYTEXT \ - B_ASN1_IA5STRING| \ - B_ASN1_VISIBLESTRING| \ - B_ASN1_BMPSTRING|\ - B_ASN1_UTF8STRING - -#define M_ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING) -#define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ - pp,a->type,V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_PRINTABLE(a,pp,l) \ - d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ - B_ASN1_PRINTABLE) - -#define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) -#define M_DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ - pp,a->type,V_ASN1_UNIVERSAL) -#define M_d2i_DIRECTORYSTRING(a,pp,l) \ - d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ - B_ASN1_DIRECTORYSTRING) - -#define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) -#define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ - pp,a->type,V_ASN1_UNIVERSAL) -#define M_d2i_DISPLAYTEXT(a,pp,l) \ - d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ - B_ASN1_DISPLAYTEXT) - -#define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\ - ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) -#define M_ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_PRINTABLESTRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \ - (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\ - ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING) - -#define M_ASN1_T61STRING_new() (ASN1_T61STRING *)\ - ASN1_STRING_type_new(V_ASN1_T61STRING) -#define M_ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_T61STRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_T61STRING(a,pp,l) \ - (ASN1_T61STRING *)d2i_ASN1_type_bytes\ - ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING) - -#define M_ASN1_IA5STRING_new() (ASN1_IA5STRING *)\ - ASN1_STRING_type_new(V_ASN1_IA5STRING) -#define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_IA5STRING_dup(a) \ - (ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a) -#define M_i2d_ASN1_IA5STRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_IA5STRING(a,pp,l) \ - (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\ - B_ASN1_IA5STRING) - -#define M_ASN1_UTCTIME_new() (ASN1_UTCTIME *)\ - ASN1_STRING_type_new(V_ASN1_UTCTIME) -#define M_ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a) - -#define M_ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\ - ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME) -#define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\ - (ASN1_STRING *)a) - -#define M_ASN1_TIME_new() (ASN1_TIME *)\ - ASN1_STRING_type_new(V_ASN1_UTCTIME) -#define M_ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a) - -#define M_ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\ - ASN1_STRING_type_new(V_ASN1_GENERALSTRING) -#define M_ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_GENERALSTRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_GENERALSTRING(a,pp,l) \ - (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\ - ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING) - -#define M_ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\ - ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING) -#define M_ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \ - (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\ - ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING) - -#define M_ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\ - ASN1_STRING_type_new(V_ASN1_BMPSTRING) -#define M_ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_BMPSTRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_BMPSTRING(a,pp,l) \ - (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\ - ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING) - -#define M_ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\ - ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) -#define M_ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_VISIBLESTRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \ - (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\ - ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING) - -#define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\ - ASN1_STRING_type_new(V_ASN1_UTF8STRING) -#define M_ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_UTF8STRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_UTF8STRING(a,pp,l) \ - (ASN1_UTF8STRING *)d2i_ASN1_type_bytes\ - ((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING) - - /* for the is_set parameter to i2d_ASN1_SET */ -#define IS_SEQUENCE 0 -#define IS_SET 1 - -DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) - -int ASN1_TYPE_get(ASN1_TYPE *a); -void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); - -ASN1_OBJECT * ASN1_OBJECT_new(void ); -void ASN1_OBJECT_free(ASN1_OBJECT *a); -int i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp); -ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp, - long length); -ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp, - long length); - -DECLARE_ASN1_ITEM(ASN1_OBJECT) - -DECLARE_STACK_OF(ASN1_OBJECT) -DECLARE_ASN1_SET_OF(ASN1_OBJECT) - -ASN1_STRING * ASN1_STRING_new(void); -void ASN1_STRING_free(ASN1_STRING *a); -ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a); -ASN1_STRING * ASN1_STRING_type_new(int type ); -int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b); - /* Since this is used to store all sorts of things, via macros, for now, make - its data void * */ -int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); -int ASN1_STRING_length(ASN1_STRING *x); -void ASN1_STRING_length_set(ASN1_STRING *x, int n); -int ASN1_STRING_type(ASN1_STRING *x); -unsigned char * ASN1_STRING_data(ASN1_STRING *x); - -DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) -int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp); -ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,const unsigned char **pp, - long length); -int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, - int length ); -int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); -int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); - -#ifndef OPENSSL_NO_BIO -int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, - BIT_STRING_BITNAME *tbl, int indent); -#endif -int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl); -int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, - BIT_STRING_BITNAME *tbl); - -int i2d_ASN1_BOOLEAN(int a,unsigned char **pp); -int d2i_ASN1_BOOLEAN(int *a,const unsigned char **pp,long length); - -DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER) -int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp); -ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const unsigned char **pp, - long length); -ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp, - long length); -ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x); -int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y); - -DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) - -int ASN1_UTCTIME_check(ASN1_UTCTIME *a); -ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t); -int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); -int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); -#if 0 -time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s); -#endif - -int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a); -ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t); -int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); - -DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) -ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *a); -int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b); -int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len); - -DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING) -DECLARE_ASN1_FUNCTIONS(ASN1_NULL) -DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING) - -int UTF8_getc(const unsigned char *str, int len, unsigned long *val); -int UTF8_putc(unsigned char *str, int len, unsigned long value); - -DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE) - -DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING) -DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT) -DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING) -DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING) -DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME) -DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME) -DECLARE_ASN1_FUNCTIONS(ASN1_TIME) - -DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) - -ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t); -int ASN1_TIME_check(ASN1_TIME *t); -ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out); - -int i2d_ASN1_SET(STACK *a, unsigned char **pp, - i2d_of_void *i2d, int ex_tag, int ex_class, int is_set); -STACK * d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length, - d2i_of_void *d2i, void (*free_func)(void *), - int ex_tag, int ex_class); - -#ifndef OPENSSL_NO_BIO -int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a); -int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size); -int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a); -int a2i_ASN1_ENUMERATED(BIO *bp,ASN1_ENUMERATED *bs,char *buf,int size); -int i2a_ASN1_OBJECT(BIO *bp,ASN1_OBJECT *a); -int a2i_ASN1_STRING(BIO *bp,ASN1_STRING *bs,char *buf,int size); -int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type); -#endif -int i2t_ASN1_OBJECT(char *buf,int buf_len,ASN1_OBJECT *a); - -int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num); -ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len, - const char *sn, const char *ln); - -int ASN1_INTEGER_set(ASN1_INTEGER *a, long v); -long ASN1_INTEGER_get(ASN1_INTEGER *a); -ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai); -BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai,BIGNUM *bn); - -int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); -long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a); -ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai); -BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai,BIGNUM *bn); - -/* General */ -/* given a string, return the correct type, max is the maximum length */ -int ASN1_PRINTABLE_type(const unsigned char *s, int max); - -int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass); -ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, - long length, int Ptag, int Pclass); -unsigned long ASN1_tag2bit(int tag); -/* type is one or more of the B_ASN1_ values. */ -ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp, - long length,int type); - -/* PARSING */ -int asn1_Finish(ASN1_CTX *c); -int asn1_const_Finish(ASN1_const_CTX *c); - -/* SPECIALS */ -int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, - int *pclass, long omax); -int ASN1_check_infinite_end(unsigned char **p,long len); -int ASN1_const_check_infinite_end(const unsigned char **p,long len); -void ASN1_put_object(unsigned char **pp, int constructed, int length, - int tag, int xclass); -int ASN1_put_eoc(unsigned char **pp); -int ASN1_object_size(int constructed, int length, int tag); - -/* Used to implement other functions */ -void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x); -#define ASN1_dup_of(type,i2d,d2i,x) \ - ((type *(*)(I2D_OF(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x) -#define ASN1_dup_of_const(type,i2d,d2i,x) \ - ((type *(*)(I2D_OF_const(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x) - -void *ASN1_item_dup(const ASN1_ITEM *it, void *x); - -#ifndef OPENSSL_NO_FP_API -void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x); -#define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \ - ((type *(*)(type *(*)(void),D2I_OF(type),FILE *,type **))openssl_fcast(ASN1_d2i_fp))(xnew,d2i,in,x) -void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x); -int ASN1_i2d_fp(i2d_of_void *i2d,FILE *out,void *x); -#define ASN1_i2d_fp_of(type,i2d,out,x) \ - ((int (*)(I2D_OF(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x) -#define ASN1_i2d_fp_of_const(type,i2d,out,x) \ - ((int (*)(I2D_OF_const(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x) -int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x); -int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags); -#endif - -int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in); - -#ifndef OPENSSL_NO_BIO -void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x); -#define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \ - ((type *(*)(type *(*)(void),D2I_OF(type),BIO *,type **))openssl_fcast(ASN1_d2i_bio))(xnew,d2i,in,x) -void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x); -int ASN1_i2d_bio(i2d_of_void *i2d,BIO *out, unsigned char *x); -#define ASN1_i2d_bio_of(type,i2d,out,x) \ - ((int (*)(I2D_OF(type),BIO *,type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x) -#define ASN1_i2d_bio_of_const(type,i2d,out,x) \ - ((int (*)(I2D_OF_const(type),BIO *,const type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x) -int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x); -int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a); -int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a); -int ASN1_TIME_print(BIO *fp,ASN1_TIME *a); -int ASN1_STRING_print(BIO *bp,ASN1_STRING *v); -int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags); -int ASN1_parse(BIO *bp,const unsigned char *pp,long len,int indent); -int ASN1_parse_dump(BIO *bp,const unsigned char *pp,long len,int indent,int dump); -#endif -const char *ASN1_tag2str(int tag); - -/* Used to load and write netscape format cert/key */ -int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp); -ASN1_HEADER *d2i_ASN1_HEADER(ASN1_HEADER **a,const unsigned char **pp, long length); -ASN1_HEADER *ASN1_HEADER_new(void ); -void ASN1_HEADER_free(ASN1_HEADER *a); - -int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); - -/* Not used that much at this point, except for the first two */ -ASN1_METHOD *X509_asn1_meth(void); -ASN1_METHOD *RSAPrivateKey_asn1_meth(void); -ASN1_METHOD *ASN1_IA5STRING_asn1_meth(void); -ASN1_METHOD *ASN1_BIT_STRING_asn1_meth(void); - -int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, - unsigned char *data, int len); -int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, - unsigned char *data, int max_len); -int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, - unsigned char *data, int len); -int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num, - unsigned char *data, int max_len); - -STACK *ASN1_seq_unpack(const unsigned char *buf, int len, - d2i_of_void *d2i, void (*free_func)(void *)); -unsigned char *ASN1_seq_pack(STACK *safes, i2d_of_void *i2d, - unsigned char **buf, int *len ); -void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i); -void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it); -ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, - ASN1_OCTET_STRING **oct); -#define ASN1_pack_string_of(type,obj,i2d,oct) \ - ((ASN1_STRING *(*)(type *,I2D_OF(type),ASN1_OCTET_STRING **))openssl_fcast(ASN1_pack_string))(obj,i2d,oct) -ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct); - -void ASN1_STRING_set_default_mask(unsigned long mask); -int ASN1_STRING_set_default_mask_asc(char *p); -unsigned long ASN1_STRING_get_default_mask(void); -int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, - int inform, unsigned long mask); -int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, - int inform, unsigned long mask, - long minsize, long maxsize); - -ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, - const unsigned char *in, int inlen, int inform, int nid); -ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid); -int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); -void ASN1_STRING_TABLE_cleanup(void); - -/* ASN1 template functions */ - -/* Old API compatible functions */ -ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); -void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it); -ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it); -int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); -int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); - -void ASN1_add_oid_module(void); - -ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf); -ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_ASN1_strings(void); - -/* Error codes for the ASN1 functions. */ - -/* Function codes. */ -#define ASN1_F_A2D_ASN1_OBJECT 100 -#define ASN1_F_A2I_ASN1_ENUMERATED 101 -#define ASN1_F_A2I_ASN1_INTEGER 102 -#define ASN1_F_A2I_ASN1_STRING 103 -#define ASN1_F_APPEND_EXP 176 -#define ASN1_F_ASN1_BIT_STRING_SET_BIT 183 -#define ASN1_F_ASN1_CB 177 -#define ASN1_F_ASN1_CHECK_TLEN 104 -#define ASN1_F_ASN1_COLLATE_PRIMITIVE 105 -#define ASN1_F_ASN1_COLLECT 106 -#define ASN1_F_ASN1_D2I_EX_PRIMITIVE 108 -#define ASN1_F_ASN1_D2I_FP 109 -#define ASN1_F_ASN1_D2I_READ_BIO 107 -#define ASN1_F_ASN1_DIGEST 184 -#define ASN1_F_ASN1_DO_ADB 110 -#define ASN1_F_ASN1_DUP 111 -#define ASN1_F_ASN1_ENUMERATED_SET 112 -#define ASN1_F_ASN1_ENUMERATED_TO_BN 113 -#define ASN1_F_ASN1_EX_C2I 204 -#define ASN1_F_ASN1_FIND_END 190 -#define ASN1_F_ASN1_GENERALIZEDTIME_SET 185 -#define ASN1_F_ASN1_GENERATE_V3 178 -#define ASN1_F_ASN1_GET_OBJECT 114 -#define ASN1_F_ASN1_HEADER_NEW 115 -#define ASN1_F_ASN1_I2D_BIO 116 -#define ASN1_F_ASN1_I2D_FP 117 -#define ASN1_F_ASN1_INTEGER_SET 118 -#define ASN1_F_ASN1_INTEGER_TO_BN 119 -#define ASN1_F_ASN1_ITEM_D2I_FP 206 -#define ASN1_F_ASN1_ITEM_DUP 191 -#define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW 121 -#define ASN1_F_ASN1_ITEM_EX_D2I 120 -#define ASN1_F_ASN1_ITEM_I2D_BIO 192 -#define ASN1_F_ASN1_ITEM_I2D_FP 193 -#define ASN1_F_ASN1_ITEM_PACK 198 -#define ASN1_F_ASN1_ITEM_SIGN 195 -#define ASN1_F_ASN1_ITEM_UNPACK 199 -#define ASN1_F_ASN1_ITEM_VERIFY 197 -#define ASN1_F_ASN1_MBSTRING_NCOPY 122 -#define ASN1_F_ASN1_OBJECT_NEW 123 -#define ASN1_F_ASN1_PACK_STRING 124 -#define ASN1_F_ASN1_PCTX_NEW 205 -#define ASN1_F_ASN1_PKCS5_PBE_SET 125 -#define ASN1_F_ASN1_SEQ_PACK 126 -#define ASN1_F_ASN1_SEQ_UNPACK 127 -#define ASN1_F_ASN1_SIGN 128 -#define ASN1_F_ASN1_STR2TYPE 179 -#define ASN1_F_ASN1_STRING_SET 186 -#define ASN1_F_ASN1_STRING_TABLE_ADD 129 -#define ASN1_F_ASN1_STRING_TYPE_NEW 130 -#define ASN1_F_ASN1_TEMPLATE_EX_D2I 132 -#define ASN1_F_ASN1_TEMPLATE_NEW 133 -#define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 131 -#define ASN1_F_ASN1_TIME_SET 175 -#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134 -#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135 -#define ASN1_F_ASN1_UNPACK_STRING 136 -#define ASN1_F_ASN1_UTCTIME_SET 187 -#define ASN1_F_ASN1_VERIFY 137 -#define ASN1_F_BITSTR_CB 180 -#define ASN1_F_BN_TO_ASN1_ENUMERATED 138 -#define ASN1_F_BN_TO_ASN1_INTEGER 139 -#define ASN1_F_C2I_ASN1_BIT_STRING 189 -#define ASN1_F_C2I_ASN1_INTEGER 194 -#define ASN1_F_C2I_ASN1_OBJECT 196 -#define ASN1_F_COLLECT_DATA 140 -#define ASN1_F_D2I_ASN1_BIT_STRING 141 -#define ASN1_F_D2I_ASN1_BOOLEAN 142 -#define ASN1_F_D2I_ASN1_BYTES 143 -#define ASN1_F_D2I_ASN1_GENERALIZEDTIME 144 -#define ASN1_F_D2I_ASN1_HEADER 145 -#define ASN1_F_D2I_ASN1_INTEGER 146 -#define ASN1_F_D2I_ASN1_OBJECT 147 -#define ASN1_F_D2I_ASN1_SET 148 -#define ASN1_F_D2I_ASN1_TYPE_BYTES 149 -#define ASN1_F_D2I_ASN1_UINTEGER 150 -#define ASN1_F_D2I_ASN1_UTCTIME 151 -#define ASN1_F_D2I_NETSCAPE_RSA 152 -#define ASN1_F_D2I_NETSCAPE_RSA_2 153 -#define ASN1_F_D2I_PRIVATEKEY 154 -#define ASN1_F_D2I_PUBLICKEY 155 -#define ASN1_F_D2I_RSA_NET 200 -#define ASN1_F_D2I_RSA_NET_2 201 -#define ASN1_F_D2I_X509 156 -#define ASN1_F_D2I_X509_CINF 157 -#define ASN1_F_D2I_X509_PKEY 159 -#define ASN1_F_I2D_ASN1_SET 188 -#define ASN1_F_I2D_ASN1_TIME 160 -#define ASN1_F_I2D_DSA_PUBKEY 161 -#define ASN1_F_I2D_EC_PUBKEY 181 -#define ASN1_F_I2D_PRIVATEKEY 163 -#define ASN1_F_I2D_PUBLICKEY 164 -#define ASN1_F_I2D_RSA_NET 162 -#define ASN1_F_I2D_RSA_PUBKEY 165 -#define ASN1_F_LONG_C2I 166 -#define ASN1_F_OID_MODULE_INIT 174 -#define ASN1_F_PARSE_TAGGING 182 -#define ASN1_F_PKCS5_PBE2_SET 167 -#define ASN1_F_PKCS5_PBE_SET 202 -#define ASN1_F_X509_CINF_NEW 168 -#define ASN1_F_X509_CRL_ADD0_REVOKED 169 -#define ASN1_F_X509_INFO_NEW 170 -#define ASN1_F_X509_NAME_ENCODE 203 -#define ASN1_F_X509_NAME_EX_D2I 158 -#define ASN1_F_X509_NAME_EX_NEW 171 -#define ASN1_F_X509_NEW 172 -#define ASN1_F_X509_PKEY_NEW 173 - -/* Reason codes. */ -#define ASN1_R_ADDING_OBJECT 171 -#define ASN1_R_AUX_ERROR 100 -#define ASN1_R_BAD_CLASS 101 -#define ASN1_R_BAD_OBJECT_HEADER 102 -#define ASN1_R_BAD_PASSWORD_READ 103 -#define ASN1_R_BAD_TAG 104 -#define ASN1_R_BN_LIB 105 -#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106 -#define ASN1_R_BUFFER_TOO_SMALL 107 -#define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108 -#define ASN1_R_DATA_IS_WRONG 109 -#define ASN1_R_DECODE_ERROR 110 -#define ASN1_R_DECODING_ERROR 111 -#define ASN1_R_DEPTH_EXCEEDED 174 -#define ASN1_R_ENCODE_ERROR 112 -#define ASN1_R_ERROR_GETTING_TIME 173 -#define ASN1_R_ERROR_LOADING_SECTION 172 -#define ASN1_R_ERROR_PARSING_SET_ELEMENT 113 -#define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114 -#define ASN1_R_EXPECTING_AN_INTEGER 115 -#define ASN1_R_EXPECTING_AN_OBJECT 116 -#define ASN1_R_EXPECTING_A_BOOLEAN 117 -#define ASN1_R_EXPECTING_A_TIME 118 -#define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119 -#define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120 -#define ASN1_R_FIELD_MISSING 121 -#define ASN1_R_FIRST_NUM_TOO_LARGE 122 -#define ASN1_R_HEADER_TOO_LONG 123 -#define ASN1_R_ILLEGAL_BITSTRING_FORMAT 175 -#define ASN1_R_ILLEGAL_BOOLEAN 176 -#define ASN1_R_ILLEGAL_CHARACTERS 124 -#define ASN1_R_ILLEGAL_FORMAT 177 -#define ASN1_R_ILLEGAL_HEX 178 -#define ASN1_R_ILLEGAL_IMPLICIT_TAG 179 -#define ASN1_R_ILLEGAL_INTEGER 180 -#define ASN1_R_ILLEGAL_NESTED_TAGGING 181 -#define ASN1_R_ILLEGAL_NULL 125 -#define ASN1_R_ILLEGAL_NULL_VALUE 182 -#define ASN1_R_ILLEGAL_OBJECT 183 -#define ASN1_R_ILLEGAL_OPTIONAL_ANY 126 -#define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170 -#define ASN1_R_ILLEGAL_TAGGED_ANY 127 -#define ASN1_R_ILLEGAL_TIME_VALUE 184 -#define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185 -#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128 -#define ASN1_R_INVALID_BMPSTRING_LENGTH 129 -#define ASN1_R_INVALID_DIGIT 130 -#define ASN1_R_INVALID_MODIFIER 186 -#define ASN1_R_INVALID_NUMBER 187 -#define ASN1_R_INVALID_SEPARATOR 131 -#define ASN1_R_INVALID_TIME_FORMAT 132 -#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133 -#define ASN1_R_INVALID_UTF8STRING 134 -#define ASN1_R_IV_TOO_LARGE 135 -#define ASN1_R_LENGTH_ERROR 136 -#define ASN1_R_LIST_ERROR 188 -#define ASN1_R_MISSING_EOC 137 -#define ASN1_R_MISSING_SECOND_NUMBER 138 -#define ASN1_R_MISSING_VALUE 189 -#define ASN1_R_MSTRING_NOT_UNIVERSAL 139 -#define ASN1_R_MSTRING_WRONG_TAG 140 -#define ASN1_R_NESTED_ASN1_STRING 197 -#define ASN1_R_NON_HEX_CHARACTERS 141 -#define ASN1_R_NOT_ASCII_FORMAT 190 -#define ASN1_R_NOT_ENOUGH_DATA 142 -#define ASN1_R_NO_MATCHING_CHOICE_TYPE 143 -#define ASN1_R_NULL_IS_WRONG_LENGTH 144 -#define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191 -#define ASN1_R_ODD_NUMBER_OF_CHARS 145 -#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 146 -#define ASN1_R_SECOND_NUMBER_TOO_LARGE 147 -#define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148 -#define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149 -#define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192 -#define ASN1_R_SHORT_LINE 150 -#define ASN1_R_STRING_TOO_LONG 151 -#define ASN1_R_STRING_TOO_SHORT 152 -#define ASN1_R_TAG_VALUE_TOO_HIGH 153 -#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154 -#define ASN1_R_TIME_NOT_ASCII_FORMAT 193 -#define ASN1_R_TOO_LONG 155 -#define ASN1_R_TYPE_NOT_CONSTRUCTED 156 -#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 157 -#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 158 -#define ASN1_R_UNEXPECTED_EOC 159 -#define ASN1_R_UNKNOWN_FORMAT 160 -#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161 -#define ASN1_R_UNKNOWN_OBJECT_TYPE 162 -#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163 -#define ASN1_R_UNKNOWN_TAG 194 -#define ASN1_R_UNKOWN_FORMAT 195 -#define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164 -#define ASN1_R_UNSUPPORTED_CIPHER 165 -#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 166 -#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167 -#define ASN1_R_UNSUPPORTED_TYPE 196 -#define ASN1_R_WRONG_TAG 168 -#define ASN1_R_WRONG_TYPE 169 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/asn1/asn1.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ASN1_H +#define HEADER_ASN1_H + +#include +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include + +#include + +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define V_ASN1_UNIVERSAL 0x00 +#define V_ASN1_APPLICATION 0x40 +#define V_ASN1_CONTEXT_SPECIFIC 0x80 +#define V_ASN1_PRIVATE 0xc0 + +#define V_ASN1_CONSTRUCTED 0x20 +#define V_ASN1_PRIMITIVE_TAG 0x1f +#define V_ASN1_PRIMATIVE_TAG 0x1f + +#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */ +#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */ +#define V_ASN1_ANY -4 /* used in ASN1 template code */ + +#define V_ASN1_NEG 0x100 /* negative flag */ + +#define V_ASN1_UNDEF -1 +#define V_ASN1_EOC 0 +#define V_ASN1_BOOLEAN 1 /**/ +#define V_ASN1_INTEGER 2 +#define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG) +#define V_ASN1_BIT_STRING 3 +#define V_ASN1_OCTET_STRING 4 +#define V_ASN1_NULL 5 +#define V_ASN1_OBJECT 6 +#define V_ASN1_OBJECT_DESCRIPTOR 7 +#define V_ASN1_EXTERNAL 8 +#define V_ASN1_REAL 9 +#define V_ASN1_ENUMERATED 10 +#define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG) +#define V_ASN1_UTF8STRING 12 +#define V_ASN1_SEQUENCE 16 +#define V_ASN1_SET 17 +#define V_ASN1_NUMERICSTRING 18 /**/ +#define V_ASN1_PRINTABLESTRING 19 +#define V_ASN1_T61STRING 20 +#define V_ASN1_TELETEXSTRING 20 /* alias */ +#define V_ASN1_VIDEOTEXSTRING 21 /**/ +#define V_ASN1_IA5STRING 22 +#define V_ASN1_UTCTIME 23 +#define V_ASN1_GENERALIZEDTIME 24 /**/ +#define V_ASN1_GRAPHICSTRING 25 /**/ +#define V_ASN1_ISO64STRING 26 /**/ +#define V_ASN1_VISIBLESTRING 26 /* alias */ +#define V_ASN1_GENERALSTRING 27 /**/ +#define V_ASN1_UNIVERSALSTRING 28 /**/ +#define V_ASN1_BMPSTRING 30 + +/* For use with d2i_ASN1_type_bytes() */ +#define B_ASN1_NUMERICSTRING 0x0001 +#define B_ASN1_PRINTABLESTRING 0x0002 +#define B_ASN1_T61STRING 0x0004 +#define B_ASN1_TELETEXSTRING 0x0004 +#define B_ASN1_VIDEOTEXSTRING 0x0008 +#define B_ASN1_IA5STRING 0x0010 +#define B_ASN1_GRAPHICSTRING 0x0020 +#define B_ASN1_ISO64STRING 0x0040 +#define B_ASN1_VISIBLESTRING 0x0040 +#define B_ASN1_GENERALSTRING 0x0080 +#define B_ASN1_UNIVERSALSTRING 0x0100 +#define B_ASN1_OCTET_STRING 0x0200 +#define B_ASN1_BIT_STRING 0x0400 +#define B_ASN1_BMPSTRING 0x0800 +#define B_ASN1_UNKNOWN 0x1000 +#define B_ASN1_UTF8STRING 0x2000 +#define B_ASN1_UTCTIME 0x4000 +#define B_ASN1_GENERALIZEDTIME 0x8000 +#define B_ASN1_SEQUENCE 0x10000 + +/* For use with ASN1_mbstring_copy() */ +#define MBSTRING_FLAG 0x1000 +#define MBSTRING_UTF8 (MBSTRING_FLAG) +#define MBSTRING_ASC (MBSTRING_FLAG|1) +#define MBSTRING_BMP (MBSTRING_FLAG|2) +#define MBSTRING_UNIV (MBSTRING_FLAG|4) + +struct X509_algor_st; + +#define DECLARE_ASN1_SET_OF(type) /* filled in by mkstack.pl */ +#define IMPLEMENT_ASN1_SET_OF(type) /* nothing, no longer needed */ + +/* We MUST make sure that, except for constness, asn1_ctx_st and + asn1_const_ctx are exactly the same. Fortunately, as soon as + the old ASN1 parsing macros are gone, we can throw this away + as well... */ +typedef struct asn1_ctx_st + { + unsigned char *p;/* work char pointer */ + int eos; /* end of sequence read for indefinite encoding */ + int error; /* error code to use when returning an error */ + int inf; /* constructed if 0x20, indefinite is 0x21 */ + int tag; /* tag from last 'get object' */ + int xclass; /* class from last 'get object' */ + long slen; /* length of last 'get object' */ + unsigned char *max; /* largest value of p allowed */ + unsigned char *q;/* temporary variable */ + unsigned char **pp;/* variable */ + int line; /* used in error processing */ + } ASN1_CTX; + +typedef struct asn1_const_ctx_st + { + const unsigned char *p;/* work char pointer */ + int eos; /* end of sequence read for indefinite encoding */ + int error; /* error code to use when returning an error */ + int inf; /* constructed if 0x20, indefinite is 0x21 */ + int tag; /* tag from last 'get object' */ + int xclass; /* class from last 'get object' */ + long slen; /* length of last 'get object' */ + const unsigned char *max; /* largest value of p allowed */ + const unsigned char *q;/* temporary variable */ + const unsigned char **pp;/* variable */ + int line; /* used in error processing */ + } ASN1_const_CTX; + +/* These are used internally in the ASN1_OBJECT to keep track of + * whether the names and data need to be free()ed */ +#define ASN1_OBJECT_FLAG_DYNAMIC 0x01 /* internal use */ +#define ASN1_OBJECT_FLAG_CRITICAL 0x02 /* critical x509v3 object id */ +#define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04 /* internal use */ +#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */ +typedef struct asn1_object_st + { + const char *sn,*ln; + int nid; + int length; + unsigned char *data; + int flags; /* Should we free this one */ + } ASN1_OBJECT; + +#define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */ +/* This indicates that the ASN1_STRING is not a real value but just a place + * holder for the location where indefinite length constructed data should + * be inserted in the memory buffer + */ +#define ASN1_STRING_FLAG_NDEF 0x010 +/* This is the base type that holds just about everything :-) */ +typedef struct asn1_string_st + { + int length; + int type; + unsigned char *data; + /* The value of the following field depends on the type being + * held. It is mostly being used for BIT_STRING so if the + * input data has a non-zero 'unused bits' value, it will be + * handled correctly */ + long flags; + } ASN1_STRING; + +/* ASN1_ENCODING structure: this is used to save the received + * encoding of an ASN1 type. This is useful to get round + * problems with invalid encodings which can break signatures. + */ + +typedef struct ASN1_ENCODING_st + { + unsigned char *enc; /* DER encoding */ + long len; /* Length of encoding */ + int modified; /* set to 1 if 'enc' is invalid */ + } ASN1_ENCODING; + +/* Used with ASN1 LONG type: if a long is set to this it is omitted */ +#define ASN1_LONG_UNDEF 0x7fffffffL + +#define STABLE_FLAGS_MALLOC 0x01 +#define STABLE_NO_MASK 0x02 +#define DIRSTRING_TYPE \ + (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING) +#define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING) + +typedef struct asn1_string_table_st { + int nid; + long minsize; + long maxsize; + unsigned long mask; + unsigned long flags; +} ASN1_STRING_TABLE; + +DECLARE_STACK_OF(ASN1_STRING_TABLE) + +/* size limits: this stuff is taken straight from RFC2459 */ + +#define ub_name 32768 +#define ub_common_name 64 +#define ub_locality_name 128 +#define ub_state_name 128 +#define ub_organization_name 64 +#define ub_organization_unit_name 64 +#define ub_title 64 +#define ub_email_address 128 + +/* Declarations for template structures: for full definitions + * see asn1t.h + */ +typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE; +typedef struct ASN1_ITEM_st ASN1_ITEM; +typedef struct ASN1_TLC_st ASN1_TLC; +/* This is just an opaque pointer */ +typedef struct ASN1_VALUE_st ASN1_VALUE; + +/* Declare ASN1 functions: the implement macro in in asn1t.h */ + +#define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type) + +#define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type) + +#define DECLARE_ASN1_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) + +#define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) + +#define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ + type *d2i_##name(type **a, const unsigned char **in, long len); \ + int i2d_##name(type *a, unsigned char **out); \ + DECLARE_ASN1_ITEM(itname) + +#define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ + type *d2i_##name(type **a, const unsigned char **in, long len); \ + int i2d_##name(const type *a, unsigned char **out); \ + DECLARE_ASN1_ITEM(name) + +#define DECLARE_ASN1_NDEF_FUNCTION(name) \ + int i2d_##name##_NDEF(name *a, unsigned char **out); + +#define DECLARE_ASN1_FUNCTIONS_const(name) \ + name *name##_new(void); \ + void name##_free(name *a); + +#define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + type *name##_new(void); \ + void name##_free(type *a); + +#define D2I_OF(type) type *(*)(type **,const unsigned char **,long) +#define I2D_OF(type) int (*)(type *,unsigned char **) +#define I2D_OF_const(type) int (*)(const type *,unsigned char **) + +#define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long) +#define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **) +#define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type) + +TYPEDEF_D2I2D_OF(void); + +/* The following macros and typedefs allow an ASN1_ITEM + * to be embedded in a structure and referenced. Since + * the ASN1_ITEM pointers need to be globally accessible + * (possibly from shared libraries) they may exist in + * different forms. On platforms that support it the + * ASN1_ITEM structure itself will be globally exported. + * Other platforms will export a function that returns + * an ASN1_ITEM pointer. + * + * To handle both cases transparently the macros below + * should be used instead of hard coding an ASN1_ITEM + * pointer in a structure. + * + * The structure will look like this: + * + * typedef struct SOMETHING_st { + * ... + * ASN1_ITEM_EXP *iptr; + * ... + * } SOMETHING; + * + * It would be initialised as e.g.: + * + * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...}; + * + * and the actual pointer extracted with: + * + * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr); + * + * Finally an ASN1_ITEM pointer can be extracted from an + * appropriate reference with: ASN1_ITEM_rptr(X509). This + * would be used when a function takes an ASN1_ITEM * argument. + * + */ + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION + +/* ASN1_ITEM pointer exported type */ +typedef const ASN1_ITEM ASN1_ITEM_EXP; + +/* Macro to obtain ASN1_ITEM pointer from exported type */ +#define ASN1_ITEM_ptr(iptr) (iptr) + +/* Macro to include ASN1_ITEM pointer from base type */ +#define ASN1_ITEM_ref(iptr) (&(iptr##_it)) + +#define ASN1_ITEM_rptr(ref) (&(ref##_it)) + +#define DECLARE_ASN1_ITEM(name) \ + OPENSSL_EXTERN const ASN1_ITEM name##_it; + +#else + +/* Platforms that can't easily handle shared global variables are declared + * as functions returning ASN1_ITEM pointers. + */ + +/* ASN1_ITEM pointer exported type */ +typedef const ASN1_ITEM * ASN1_ITEM_EXP(void); + +/* Macro to obtain ASN1_ITEM pointer from exported type */ +#define ASN1_ITEM_ptr(iptr) (iptr()) + +/* Macro to include ASN1_ITEM pointer from base type */ +#define ASN1_ITEM_ref(iptr) (iptr##_it) + +#define ASN1_ITEM_rptr(ref) (ref##_it()) + +#define DECLARE_ASN1_ITEM(name) \ + const ASN1_ITEM * name##_it(void); + +#endif + +/* Parameters used by ASN1_STRING_print_ex() */ + +/* These determine which characters to escape: + * RFC2253 special characters, control characters and + * MSB set characters + */ + +#define ASN1_STRFLGS_ESC_2253 1 +#define ASN1_STRFLGS_ESC_CTRL 2 +#define ASN1_STRFLGS_ESC_MSB 4 + + +/* This flag determines how we do escaping: normally + * RC2253 backslash only, set this to use backslash and + * quote. + */ + +#define ASN1_STRFLGS_ESC_QUOTE 8 + + +/* These three flags are internal use only. */ + +/* Character is a valid PrintableString character */ +#define CHARTYPE_PRINTABLESTRING 0x10 +/* Character needs escaping if it is the first character */ +#define CHARTYPE_FIRST_ESC_2253 0x20 +/* Character needs escaping if it is the last character */ +#define CHARTYPE_LAST_ESC_2253 0x40 + +/* NB the internal flags are safely reused below by flags + * handled at the top level. + */ + +/* If this is set we convert all character strings + * to UTF8 first + */ + +#define ASN1_STRFLGS_UTF8_CONVERT 0x10 + +/* If this is set we don't attempt to interpret content: + * just assume all strings are 1 byte per character. This + * will produce some pretty odd looking output! + */ + +#define ASN1_STRFLGS_IGNORE_TYPE 0x20 + +/* If this is set we include the string type in the output */ +#define ASN1_STRFLGS_SHOW_TYPE 0x40 + +/* This determines which strings to display and which to + * 'dump' (hex dump of content octets or DER encoding). We can + * only dump non character strings or everything. If we + * don't dump 'unknown' they are interpreted as character + * strings with 1 octet per character and are subject to + * the usual escaping options. + */ + +#define ASN1_STRFLGS_DUMP_ALL 0x80 +#define ASN1_STRFLGS_DUMP_UNKNOWN 0x100 + +/* These determine what 'dumping' does, we can dump the + * content octets or the DER encoding: both use the + * RFC2253 #XXXXX notation. + */ + +#define ASN1_STRFLGS_DUMP_DER 0x200 + +/* All the string flags consistent with RFC2253, + * escaping control characters isn't essential in + * RFC2253 but it is advisable anyway. + */ + +#define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \ + ASN1_STRFLGS_ESC_CTRL | \ + ASN1_STRFLGS_ESC_MSB | \ + ASN1_STRFLGS_UTF8_CONVERT | \ + ASN1_STRFLGS_DUMP_UNKNOWN | \ + ASN1_STRFLGS_DUMP_DER) + +DECLARE_STACK_OF(ASN1_INTEGER) +DECLARE_ASN1_SET_OF(ASN1_INTEGER) + +DECLARE_STACK_OF(ASN1_GENERALSTRING) + +typedef struct asn1_type_st + { + int type; + union { + char *ptr; + ASN1_BOOLEAN boolean; + ASN1_STRING * asn1_string; + ASN1_OBJECT * object; + ASN1_INTEGER * integer; + ASN1_ENUMERATED * enumerated; + ASN1_BIT_STRING * bit_string; + ASN1_OCTET_STRING * octet_string; + ASN1_PRINTABLESTRING * printablestring; + ASN1_T61STRING * t61string; + ASN1_IA5STRING * ia5string; + ASN1_GENERALSTRING * generalstring; + ASN1_BMPSTRING * bmpstring; + ASN1_UNIVERSALSTRING * universalstring; + ASN1_UTCTIME * utctime; + ASN1_GENERALIZEDTIME * generalizedtime; + ASN1_VISIBLESTRING * visiblestring; + ASN1_UTF8STRING * utf8string; + /* set and sequence are left complete and still + * contain the set or sequence bytes */ + ASN1_STRING * set; + ASN1_STRING * sequence; + } value; + } ASN1_TYPE; + +DECLARE_STACK_OF(ASN1_TYPE) +DECLARE_ASN1_SET_OF(ASN1_TYPE) + +typedef struct asn1_method_st + { + i2d_of_void *i2d; + d2i_of_void *d2i; + void *(*create)(void); + void (*destroy)(void *); + } ASN1_METHOD; + +/* This is used when parsing some Netscape objects */ +typedef struct asn1_header_st + { + ASN1_OCTET_STRING *header; + void *data; + ASN1_METHOD *meth; + } ASN1_HEADER; + +/* This is used to contain a list of bit names */ +typedef struct BIT_STRING_BITNAME_st { + int bitnum; + const char *lname; + const char *sname; +} BIT_STRING_BITNAME; + + +#define M_ASN1_STRING_length(x) ((x)->length) +#define M_ASN1_STRING_length_set(x, n) ((x)->length = (n)) +#define M_ASN1_STRING_type(x) ((x)->type) +#define M_ASN1_STRING_data(x) ((x)->data) + +/* Macros for string operations */ +#define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\ + ASN1_STRING_type_new(V_ASN1_BIT_STRING) +#define M_ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\ + ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) +#define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) + +#define M_ASN1_INTEGER_new() (ASN1_INTEGER *)\ + ASN1_STRING_type_new(V_ASN1_INTEGER) +#define M_ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) + +#define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\ + ASN1_STRING_type_new(V_ASN1_ENUMERATED) +#define M_ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) + +#define M_ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\ + ASN1_STRING_type_new(V_ASN1_OCTET_STRING) +#define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\ + ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) +#define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) +#define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b) +#define M_i2d_ASN1_OCTET_STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\ + V_ASN1_UNIVERSAL) + +#define B_ASN1_TIME \ + B_ASN1_UTCTIME | \ + B_ASN1_GENERALIZEDTIME + +#define B_ASN1_PRINTABLE \ + B_ASN1_PRINTABLESTRING| \ + B_ASN1_T61STRING| \ + B_ASN1_IA5STRING| \ + B_ASN1_BIT_STRING| \ + B_ASN1_UNIVERSALSTRING|\ + B_ASN1_BMPSTRING|\ + B_ASN1_UTF8STRING|\ + B_ASN1_SEQUENCE|\ + B_ASN1_UNKNOWN + +#define B_ASN1_DIRECTORYSTRING \ + B_ASN1_PRINTABLESTRING| \ + B_ASN1_TELETEXSTRING|\ + B_ASN1_BMPSTRING|\ + B_ASN1_UNIVERSALSTRING|\ + B_ASN1_UTF8STRING + +#define B_ASN1_DISPLAYTEXT \ + B_ASN1_IA5STRING| \ + B_ASN1_VISIBLESTRING| \ + B_ASN1_BMPSTRING|\ + B_ASN1_UTF8STRING + +#define M_ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING) +#define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ + pp,a->type,V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_PRINTABLE(a,pp,l) \ + d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ + B_ASN1_PRINTABLE) + +#define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) +#define M_DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ + pp,a->type,V_ASN1_UNIVERSAL) +#define M_d2i_DIRECTORYSTRING(a,pp,l) \ + d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ + B_ASN1_DIRECTORYSTRING) + +#define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) +#define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ + pp,a->type,V_ASN1_UNIVERSAL) +#define M_d2i_DISPLAYTEXT(a,pp,l) \ + d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ + B_ASN1_DISPLAYTEXT) + +#define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\ + ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) +#define M_ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_PRINTABLESTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \ + (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING) + +#define M_ASN1_T61STRING_new() (ASN1_T61STRING *)\ + ASN1_STRING_type_new(V_ASN1_T61STRING) +#define M_ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_T61STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_T61STRING(a,pp,l) \ + (ASN1_T61STRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING) + +#define M_ASN1_IA5STRING_new() (ASN1_IA5STRING *)\ + ASN1_STRING_type_new(V_ASN1_IA5STRING) +#define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_IA5STRING_dup(a) \ + (ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a) +#define M_i2d_ASN1_IA5STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_IA5STRING(a,pp,l) \ + (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\ + B_ASN1_IA5STRING) + +#define M_ASN1_UTCTIME_new() (ASN1_UTCTIME *)\ + ASN1_STRING_type_new(V_ASN1_UTCTIME) +#define M_ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a) + +#define M_ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\ + ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME) +#define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\ + (ASN1_STRING *)a) + +#define M_ASN1_TIME_new() (ASN1_TIME *)\ + ASN1_STRING_type_new(V_ASN1_UTCTIME) +#define M_ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a) + +#define M_ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\ + ASN1_STRING_type_new(V_ASN1_GENERALSTRING) +#define M_ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_GENERALSTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_GENERALSTRING(a,pp,l) \ + (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING) + +#define M_ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\ + ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING) +#define M_ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \ + (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING) + +#define M_ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\ + ASN1_STRING_type_new(V_ASN1_BMPSTRING) +#define M_ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_BMPSTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_BMPSTRING(a,pp,l) \ + (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING) + +#define M_ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\ + ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) +#define M_ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_VISIBLESTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \ + (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING) + +#define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\ + ASN1_STRING_type_new(V_ASN1_UTF8STRING) +#define M_ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_UTF8STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_UTF8STRING(a,pp,l) \ + (ASN1_UTF8STRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING) + + /* for the is_set parameter to i2d_ASN1_SET */ +#define IS_SEQUENCE 0 +#define IS_SET 1 + +DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) + +int ASN1_TYPE_get(ASN1_TYPE *a); +void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); + +ASN1_OBJECT * ASN1_OBJECT_new(void ); +void ASN1_OBJECT_free(ASN1_OBJECT *a); +int i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp); +ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp, + long length); +ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp, + long length); + +DECLARE_ASN1_ITEM(ASN1_OBJECT) + +DECLARE_STACK_OF(ASN1_OBJECT) +DECLARE_ASN1_SET_OF(ASN1_OBJECT) + +ASN1_STRING * ASN1_STRING_new(void); +void ASN1_STRING_free(ASN1_STRING *a); +ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a); +ASN1_STRING * ASN1_STRING_type_new(int type ); +int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b); + /* Since this is used to store all sorts of things, via macros, for now, make + its data void * */ +int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); +int ASN1_STRING_length(ASN1_STRING *x); +void ASN1_STRING_length_set(ASN1_STRING *x, int n); +int ASN1_STRING_type(ASN1_STRING *x); +unsigned char * ASN1_STRING_data(ASN1_STRING *x); + +DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) +int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp); +ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,const unsigned char **pp, + long length); +int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, + int length ); +int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); +int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); + +#ifndef OPENSSL_NO_BIO +int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, + BIT_STRING_BITNAME *tbl, int indent); +#endif +int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl); +int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, + BIT_STRING_BITNAME *tbl); + +int i2d_ASN1_BOOLEAN(int a,unsigned char **pp); +int d2i_ASN1_BOOLEAN(int *a,const unsigned char **pp,long length); + +DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER) +int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp); +ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const unsigned char **pp, + long length); +ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp, + long length); +ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x); +int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y); + +DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) + +int ASN1_UTCTIME_check(ASN1_UTCTIME *a); +ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t); +int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); +int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); +#if 0 +time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s); +#endif + +int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a); +ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t); +int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); + +DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) +ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *a); +int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b); +int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len); + +DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_NULL) +DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING) + +int UTF8_getc(const unsigned char *str, int len, unsigned long *val); +int UTF8_putc(unsigned char *str, int len, unsigned long value); + +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE) + +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING) +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT) +DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME) +DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME) +DECLARE_ASN1_FUNCTIONS(ASN1_TIME) + +DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) + +ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t); +int ASN1_TIME_check(ASN1_TIME *t); +ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out); + +int i2d_ASN1_SET(STACK *a, unsigned char **pp, + i2d_of_void *i2d, int ex_tag, int ex_class, int is_set); +STACK * d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length, + d2i_of_void *d2i, void (*free_func)(void *), + int ex_tag, int ex_class); + +#ifndef OPENSSL_NO_BIO +int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a); +int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size); +int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a); +int a2i_ASN1_ENUMERATED(BIO *bp,ASN1_ENUMERATED *bs,char *buf,int size); +int i2a_ASN1_OBJECT(BIO *bp,ASN1_OBJECT *a); +int a2i_ASN1_STRING(BIO *bp,ASN1_STRING *bs,char *buf,int size); +int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type); +#endif +int i2t_ASN1_OBJECT(char *buf,int buf_len,ASN1_OBJECT *a); + +int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num); +ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len, + const char *sn, const char *ln); + +int ASN1_INTEGER_set(ASN1_INTEGER *a, long v); +long ASN1_INTEGER_get(ASN1_INTEGER *a); +ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai); +BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai,BIGNUM *bn); + +int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); +long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a); +ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai); +BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai,BIGNUM *bn); + +/* General */ +/* given a string, return the correct type, max is the maximum length */ +int ASN1_PRINTABLE_type(const unsigned char *s, int max); + +int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass); +ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, + long length, int Ptag, int Pclass); +unsigned long ASN1_tag2bit(int tag); +/* type is one or more of the B_ASN1_ values. */ +ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp, + long length,int type); + +/* PARSING */ +int asn1_Finish(ASN1_CTX *c); +int asn1_const_Finish(ASN1_const_CTX *c); + +/* SPECIALS */ +int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, + int *pclass, long omax); +int ASN1_check_infinite_end(unsigned char **p,long len); +int ASN1_const_check_infinite_end(const unsigned char **p,long len); +void ASN1_put_object(unsigned char **pp, int constructed, int length, + int tag, int xclass); +int ASN1_put_eoc(unsigned char **pp); +int ASN1_object_size(int constructed, int length, int tag); + +/* Used to implement other functions */ +void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x); +#define ASN1_dup_of(type,i2d,d2i,x) \ + ((type *(*)(I2D_OF(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x) +#define ASN1_dup_of_const(type,i2d,d2i,x) \ + ((type *(*)(I2D_OF_const(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x) + +void *ASN1_item_dup(const ASN1_ITEM *it, void *x); + +#ifndef OPENSSL_NO_FP_API +void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x); +#define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \ + ((type *(*)(type *(*)(void),D2I_OF(type),FILE *,type **))openssl_fcast(ASN1_d2i_fp))(xnew,d2i,in,x) +void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x); +int ASN1_i2d_fp(i2d_of_void *i2d,FILE *out,void *x); +#define ASN1_i2d_fp_of(type,i2d,out,x) \ + ((int (*)(I2D_OF(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x) +#define ASN1_i2d_fp_of_const(type,i2d,out,x) \ + ((int (*)(I2D_OF_const(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x) +int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x); +int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags); +#endif + +int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in); + +#ifndef OPENSSL_NO_BIO +void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x); +#define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \ + ((type *(*)(type *(*)(void),D2I_OF(type),BIO *,type **))openssl_fcast(ASN1_d2i_bio))(xnew,d2i,in,x) +void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x); +int ASN1_i2d_bio(i2d_of_void *i2d,BIO *out, unsigned char *x); +#define ASN1_i2d_bio_of(type,i2d,out,x) \ + ((int (*)(I2D_OF(type),BIO *,type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x) +#define ASN1_i2d_bio_of_const(type,i2d,out,x) \ + ((int (*)(I2D_OF_const(type),BIO *,const type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x) +int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x); +int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a); +int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a); +int ASN1_TIME_print(BIO *fp,ASN1_TIME *a); +int ASN1_STRING_print(BIO *bp,ASN1_STRING *v); +int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags); +int ASN1_parse(BIO *bp,const unsigned char *pp,long len,int indent); +int ASN1_parse_dump(BIO *bp,const unsigned char *pp,long len,int indent,int dump); +#endif +const char *ASN1_tag2str(int tag); + +/* Used to load and write netscape format cert/key */ +int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp); +ASN1_HEADER *d2i_ASN1_HEADER(ASN1_HEADER **a,const unsigned char **pp, long length); +ASN1_HEADER *ASN1_HEADER_new(void ); +void ASN1_HEADER_free(ASN1_HEADER *a); + +int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); + +/* Not used that much at this point, except for the first two */ +ASN1_METHOD *X509_asn1_meth(void); +ASN1_METHOD *RSAPrivateKey_asn1_meth(void); +ASN1_METHOD *ASN1_IA5STRING_asn1_meth(void); +ASN1_METHOD *ASN1_BIT_STRING_asn1_meth(void); + +int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, + unsigned char *data, int len); +int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, + unsigned char *data, int max_len); +int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, + unsigned char *data, int len); +int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num, + unsigned char *data, int max_len); + +STACK *ASN1_seq_unpack(const unsigned char *buf, int len, + d2i_of_void *d2i, void (*free_func)(void *)); +unsigned char *ASN1_seq_pack(STACK *safes, i2d_of_void *i2d, + unsigned char **buf, int *len ); +void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i); +void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it); +ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, + ASN1_OCTET_STRING **oct); +#define ASN1_pack_string_of(type,obj,i2d,oct) \ + ((ASN1_STRING *(*)(type *,I2D_OF(type),ASN1_OCTET_STRING **))openssl_fcast(ASN1_pack_string))(obj,i2d,oct) +ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct); + +void ASN1_STRING_set_default_mask(unsigned long mask); +int ASN1_STRING_set_default_mask_asc(char *p); +unsigned long ASN1_STRING_get_default_mask(void); +int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, + int inform, unsigned long mask); +int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, + int inform, unsigned long mask, + long minsize, long maxsize); + +ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, + const unsigned char *in, int inlen, int inform, int nid); +ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid); +int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); +void ASN1_STRING_TABLE_cleanup(void); + +/* ASN1 template functions */ + +/* Old API compatible functions */ +ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); +void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it); +ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it); +int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); +int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); + +void ASN1_add_oid_module(void); + +ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf); +ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ASN1_strings(void); + +/* Error codes for the ASN1 functions. */ + +/* Function codes. */ +#define ASN1_F_A2D_ASN1_OBJECT 100 +#define ASN1_F_A2I_ASN1_ENUMERATED 101 +#define ASN1_F_A2I_ASN1_INTEGER 102 +#define ASN1_F_A2I_ASN1_STRING 103 +#define ASN1_F_APPEND_EXP 176 +#define ASN1_F_ASN1_BIT_STRING_SET_BIT 183 +#define ASN1_F_ASN1_CB 177 +#define ASN1_F_ASN1_CHECK_TLEN 104 +#define ASN1_F_ASN1_COLLATE_PRIMITIVE 105 +#define ASN1_F_ASN1_COLLECT 106 +#define ASN1_F_ASN1_D2I_EX_PRIMITIVE 108 +#define ASN1_F_ASN1_D2I_FP 109 +#define ASN1_F_ASN1_D2I_READ_BIO 107 +#define ASN1_F_ASN1_DIGEST 184 +#define ASN1_F_ASN1_DO_ADB 110 +#define ASN1_F_ASN1_DUP 111 +#define ASN1_F_ASN1_ENUMERATED_SET 112 +#define ASN1_F_ASN1_ENUMERATED_TO_BN 113 +#define ASN1_F_ASN1_EX_C2I 204 +#define ASN1_F_ASN1_FIND_END 190 +#define ASN1_F_ASN1_GENERALIZEDTIME_SET 185 +#define ASN1_F_ASN1_GENERATE_V3 178 +#define ASN1_F_ASN1_GET_OBJECT 114 +#define ASN1_F_ASN1_HEADER_NEW 115 +#define ASN1_F_ASN1_I2D_BIO 116 +#define ASN1_F_ASN1_I2D_FP 117 +#define ASN1_F_ASN1_INTEGER_SET 118 +#define ASN1_F_ASN1_INTEGER_TO_BN 119 +#define ASN1_F_ASN1_ITEM_D2I_FP 206 +#define ASN1_F_ASN1_ITEM_DUP 191 +#define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW 121 +#define ASN1_F_ASN1_ITEM_EX_D2I 120 +#define ASN1_F_ASN1_ITEM_I2D_BIO 192 +#define ASN1_F_ASN1_ITEM_I2D_FP 193 +#define ASN1_F_ASN1_ITEM_PACK 198 +#define ASN1_F_ASN1_ITEM_SIGN 195 +#define ASN1_F_ASN1_ITEM_UNPACK 199 +#define ASN1_F_ASN1_ITEM_VERIFY 197 +#define ASN1_F_ASN1_MBSTRING_NCOPY 122 +#define ASN1_F_ASN1_OBJECT_NEW 123 +#define ASN1_F_ASN1_PACK_STRING 124 +#define ASN1_F_ASN1_PCTX_NEW 205 +#define ASN1_F_ASN1_PKCS5_PBE_SET 125 +#define ASN1_F_ASN1_SEQ_PACK 126 +#define ASN1_F_ASN1_SEQ_UNPACK 127 +#define ASN1_F_ASN1_SIGN 128 +#define ASN1_F_ASN1_STR2TYPE 179 +#define ASN1_F_ASN1_STRING_SET 186 +#define ASN1_F_ASN1_STRING_TABLE_ADD 129 +#define ASN1_F_ASN1_STRING_TYPE_NEW 130 +#define ASN1_F_ASN1_TEMPLATE_EX_D2I 132 +#define ASN1_F_ASN1_TEMPLATE_NEW 133 +#define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 131 +#define ASN1_F_ASN1_TIME_SET 175 +#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134 +#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135 +#define ASN1_F_ASN1_UNPACK_STRING 136 +#define ASN1_F_ASN1_UTCTIME_SET 187 +#define ASN1_F_ASN1_VERIFY 137 +#define ASN1_F_BITSTR_CB 180 +#define ASN1_F_BN_TO_ASN1_ENUMERATED 138 +#define ASN1_F_BN_TO_ASN1_INTEGER 139 +#define ASN1_F_C2I_ASN1_BIT_STRING 189 +#define ASN1_F_C2I_ASN1_INTEGER 194 +#define ASN1_F_C2I_ASN1_OBJECT 196 +#define ASN1_F_COLLECT_DATA 140 +#define ASN1_F_D2I_ASN1_BIT_STRING 141 +#define ASN1_F_D2I_ASN1_BOOLEAN 142 +#define ASN1_F_D2I_ASN1_BYTES 143 +#define ASN1_F_D2I_ASN1_GENERALIZEDTIME 144 +#define ASN1_F_D2I_ASN1_HEADER 145 +#define ASN1_F_D2I_ASN1_INTEGER 146 +#define ASN1_F_D2I_ASN1_OBJECT 147 +#define ASN1_F_D2I_ASN1_SET 148 +#define ASN1_F_D2I_ASN1_TYPE_BYTES 149 +#define ASN1_F_D2I_ASN1_UINTEGER 150 +#define ASN1_F_D2I_ASN1_UTCTIME 151 +#define ASN1_F_D2I_NETSCAPE_RSA 152 +#define ASN1_F_D2I_NETSCAPE_RSA_2 153 +#define ASN1_F_D2I_PRIVATEKEY 154 +#define ASN1_F_D2I_PUBLICKEY 155 +#define ASN1_F_D2I_RSA_NET 200 +#define ASN1_F_D2I_RSA_NET_2 201 +#define ASN1_F_D2I_X509 156 +#define ASN1_F_D2I_X509_CINF 157 +#define ASN1_F_D2I_X509_PKEY 159 +#define ASN1_F_I2D_ASN1_SET 188 +#define ASN1_F_I2D_ASN1_TIME 160 +#define ASN1_F_I2D_DSA_PUBKEY 161 +#define ASN1_F_I2D_EC_PUBKEY 181 +#define ASN1_F_I2D_PRIVATEKEY 163 +#define ASN1_F_I2D_PUBLICKEY 164 +#define ASN1_F_I2D_RSA_NET 162 +#define ASN1_F_I2D_RSA_PUBKEY 165 +#define ASN1_F_LONG_C2I 166 +#define ASN1_F_OID_MODULE_INIT 174 +#define ASN1_F_PARSE_TAGGING 182 +#define ASN1_F_PKCS5_PBE2_SET 167 +#define ASN1_F_PKCS5_PBE_SET 202 +#define ASN1_F_X509_CINF_NEW 168 +#define ASN1_F_X509_CRL_ADD0_REVOKED 169 +#define ASN1_F_X509_INFO_NEW 170 +#define ASN1_F_X509_NAME_ENCODE 203 +#define ASN1_F_X509_NAME_EX_D2I 158 +#define ASN1_F_X509_NAME_EX_NEW 171 +#define ASN1_F_X509_NEW 172 +#define ASN1_F_X509_PKEY_NEW 173 + +/* Reason codes. */ +#define ASN1_R_ADDING_OBJECT 171 +#define ASN1_R_AUX_ERROR 100 +#define ASN1_R_BAD_CLASS 101 +#define ASN1_R_BAD_OBJECT_HEADER 102 +#define ASN1_R_BAD_PASSWORD_READ 103 +#define ASN1_R_BAD_TAG 104 +#define ASN1_R_BN_LIB 105 +#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106 +#define ASN1_R_BUFFER_TOO_SMALL 107 +#define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108 +#define ASN1_R_DATA_IS_WRONG 109 +#define ASN1_R_DECODE_ERROR 110 +#define ASN1_R_DECODING_ERROR 111 +#define ASN1_R_DEPTH_EXCEEDED 174 +#define ASN1_R_ENCODE_ERROR 112 +#define ASN1_R_ERROR_GETTING_TIME 173 +#define ASN1_R_ERROR_LOADING_SECTION 172 +#define ASN1_R_ERROR_PARSING_SET_ELEMENT 113 +#define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114 +#define ASN1_R_EXPECTING_AN_INTEGER 115 +#define ASN1_R_EXPECTING_AN_OBJECT 116 +#define ASN1_R_EXPECTING_A_BOOLEAN 117 +#define ASN1_R_EXPECTING_A_TIME 118 +#define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119 +#define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120 +#define ASN1_R_FIELD_MISSING 121 +#define ASN1_R_FIRST_NUM_TOO_LARGE 122 +#define ASN1_R_HEADER_TOO_LONG 123 +#define ASN1_R_ILLEGAL_BITSTRING_FORMAT 175 +#define ASN1_R_ILLEGAL_BOOLEAN 176 +#define ASN1_R_ILLEGAL_CHARACTERS 124 +#define ASN1_R_ILLEGAL_FORMAT 177 +#define ASN1_R_ILLEGAL_HEX 178 +#define ASN1_R_ILLEGAL_IMPLICIT_TAG 179 +#define ASN1_R_ILLEGAL_INTEGER 180 +#define ASN1_R_ILLEGAL_NESTED_TAGGING 181 +#define ASN1_R_ILLEGAL_NULL 125 +#define ASN1_R_ILLEGAL_NULL_VALUE 182 +#define ASN1_R_ILLEGAL_OBJECT 183 +#define ASN1_R_ILLEGAL_OPTIONAL_ANY 126 +#define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170 +#define ASN1_R_ILLEGAL_TAGGED_ANY 127 +#define ASN1_R_ILLEGAL_TIME_VALUE 184 +#define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185 +#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128 +#define ASN1_R_INVALID_BMPSTRING_LENGTH 129 +#define ASN1_R_INVALID_DIGIT 130 +#define ASN1_R_INVALID_MODIFIER 186 +#define ASN1_R_INVALID_NUMBER 187 +#define ASN1_R_INVALID_SEPARATOR 131 +#define ASN1_R_INVALID_TIME_FORMAT 132 +#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133 +#define ASN1_R_INVALID_UTF8STRING 134 +#define ASN1_R_IV_TOO_LARGE 135 +#define ASN1_R_LENGTH_ERROR 136 +#define ASN1_R_LIST_ERROR 188 +#define ASN1_R_MISSING_EOC 137 +#define ASN1_R_MISSING_SECOND_NUMBER 138 +#define ASN1_R_MISSING_VALUE 189 +#define ASN1_R_MSTRING_NOT_UNIVERSAL 139 +#define ASN1_R_MSTRING_WRONG_TAG 140 +#define ASN1_R_NESTED_ASN1_STRING 197 +#define ASN1_R_NON_HEX_CHARACTERS 141 +#define ASN1_R_NOT_ASCII_FORMAT 190 +#define ASN1_R_NOT_ENOUGH_DATA 142 +#define ASN1_R_NO_MATCHING_CHOICE_TYPE 143 +#define ASN1_R_NULL_IS_WRONG_LENGTH 144 +#define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191 +#define ASN1_R_ODD_NUMBER_OF_CHARS 145 +#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 146 +#define ASN1_R_SECOND_NUMBER_TOO_LARGE 147 +#define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148 +#define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149 +#define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192 +#define ASN1_R_SHORT_LINE 150 +#define ASN1_R_STRING_TOO_LONG 151 +#define ASN1_R_STRING_TOO_SHORT 152 +#define ASN1_R_TAG_VALUE_TOO_HIGH 153 +#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154 +#define ASN1_R_TIME_NOT_ASCII_FORMAT 193 +#define ASN1_R_TOO_LONG 155 +#define ASN1_R_TYPE_NOT_CONSTRUCTED 156 +#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 157 +#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 158 +#define ASN1_R_UNEXPECTED_EOC 159 +#define ASN1_R_UNKNOWN_FORMAT 160 +#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161 +#define ASN1_R_UNKNOWN_OBJECT_TYPE 162 +#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163 +#define ASN1_R_UNKNOWN_TAG 194 +#define ASN1_R_UNKOWN_FORMAT 195 +#define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164 +#define ASN1_R_UNSUPPORTED_CIPHER 165 +#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 166 +#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167 +#define ASN1_R_UNSUPPORTED_TYPE 196 +#define ASN1_R_WRONG_TAG 168 +#define ASN1_R_WRONG_TYPE 169 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/asn1_mac.h b/src/dep/include/openssl/asn1_mac.h index a2b85ba..dbba292 100644 --- a/src/dep/include/openssl/asn1_mac.h +++ b/src/dep/include/openssl/asn1_mac.h @@ -1,571 +1,571 @@ -/* crypto/asn1/asn1_mac.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_ASN1_MAC_H -#define HEADER_ASN1_MAC_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef ASN1_MAC_ERR_LIB -#define ASN1_MAC_ERR_LIB ERR_LIB_ASN1 -#endif - -#define ASN1_MAC_H_err(f,r,line) \ - ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line)) - -#define M_ASN1_D2I_vars(a,type,func) \ - ASN1_const_CTX c; \ - type ret=NULL; \ - \ - c.pp=(const unsigned char **)pp; \ - c.q= *(const unsigned char **)pp; \ - c.error=ERR_R_NESTED_ASN1_ERROR; \ - if ((a == NULL) || ((*a) == NULL)) \ - { if ((ret=(type)func()) == NULL) \ - { c.line=__LINE__; goto err; } } \ - else ret=(*a); - -#define M_ASN1_D2I_Init() \ - c.p= *(const unsigned char **)pp; \ - c.max=(length == 0)?0:(c.p+length); - -#define M_ASN1_D2I_Finish_2(a) \ - if (!asn1_const_Finish(&c)) \ - { c.line=__LINE__; goto err; } \ - *(const unsigned char **)pp=c.p; \ - if (a != NULL) (*a)=ret; \ - return(ret); - -#define M_ASN1_D2I_Finish(a,func,e) \ - M_ASN1_D2I_Finish_2(a); \ -err:\ - ASN1_MAC_H_err((e),c.error,c.line); \ - asn1_add_error(*(const unsigned char **)pp,(int)(c.q- *pp)); \ - if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \ - return(NULL) - -#define M_ASN1_D2I_start_sequence() \ - if (!asn1_GetSequence(&c,&length)) \ - { c.line=__LINE__; goto err; } -/* Begin reading ASN1 without a surrounding sequence */ -#define M_ASN1_D2I_begin() \ - c.slen = length; - -/* End reading ASN1 with no check on length */ -#define M_ASN1_D2I_Finish_nolen(a, func, e) \ - *pp=c.p; \ - if (a != NULL) (*a)=ret; \ - return(ret); \ -err:\ - ASN1_MAC_H_err((e),c.error,c.line); \ - asn1_add_error(*pp,(int)(c.q- *pp)); \ - if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \ - return(NULL) - -#define M_ASN1_D2I_end_sequence() \ - (((c.inf&1) == 0)?(c.slen <= 0): \ - (c.eos=ASN1_const_check_infinite_end(&c.p,c.slen))) - -/* Don't use this with d2i_ASN1_BOOLEAN() */ -#define M_ASN1_D2I_get(b, func) \ - c.q=c.p; \ - if (func(&(b),&c.p,c.slen) == NULL) \ - {c.line=__LINE__; goto err; } \ - c.slen-=(c.p-c.q); - -/* Don't use this with d2i_ASN1_BOOLEAN() */ -#define M_ASN1_D2I_get_x(type,b,func) \ - c.q=c.p; \ - if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \ - {c.line=__LINE__; goto err; } \ - c.slen-=(c.p-c.q); - -/* use this instead () */ -#define M_ASN1_D2I_get_int(b,func) \ - c.q=c.p; \ - if (func(&(b),&c.p,c.slen) < 0) \ - {c.line=__LINE__; goto err; } \ - c.slen-=(c.p-c.q); - -#define M_ASN1_D2I_get_opt(b,func,type) \ - if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \ - == (V_ASN1_UNIVERSAL|(type)))) \ - { \ - M_ASN1_D2I_get(b,func); \ - } - -#define M_ASN1_D2I_get_imp(b,func, type) \ - M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \ - c.q=c.p; \ - if (func(&(b),&c.p,c.slen) == NULL) \ - {c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \ - c.slen-=(c.p-c.q);\ - M_ASN1_next_prev=_tmp; - -#define M_ASN1_D2I_get_IMP_opt(b,func,tag,type) \ - if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) == \ - (V_ASN1_CONTEXT_SPECIFIC|(tag)))) \ - { \ - unsigned char _tmp = M_ASN1_next; \ - M_ASN1_D2I_get_imp(b,func, type);\ - } - -#define M_ASN1_D2I_get_set(r,func,free_func) \ - M_ASN1_D2I_get_imp_set(r,func,free_func, \ - V_ASN1_SET,V_ASN1_UNIVERSAL); - -#define M_ASN1_D2I_get_set_type(type,r,func,free_func) \ - M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \ - V_ASN1_SET,V_ASN1_UNIVERSAL); - -#define M_ASN1_D2I_get_set_opt(r,func,free_func) \ - if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ - V_ASN1_CONSTRUCTED|V_ASN1_SET)))\ - { M_ASN1_D2I_get_set(r,func,free_func); } - -#define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \ - if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ - V_ASN1_CONSTRUCTED|V_ASN1_SET)))\ - { M_ASN1_D2I_get_set_type(type,r,func,free_func); } - -#define M_ASN1_I2D_len_SET_opt(a,f) \ - if ((a != NULL) && (sk_num(a) != 0)) \ - M_ASN1_I2D_len_SET(a,f); - -#define M_ASN1_I2D_put_SET_opt(a,f) \ - if ((a != NULL) && (sk_num(a) != 0)) \ - M_ASN1_I2D_put_SET(a,f); - -#define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \ - if ((a != NULL) && (sk_num(a) != 0)) \ - M_ASN1_I2D_put_SEQUENCE(a,f); - -#define M_ASN1_I2D_put_SEQUENCE_opt_type(type,a,f) \ - if ((a != NULL) && (sk_##type##_num(a) != 0)) \ - M_ASN1_I2D_put_SEQUENCE_type(type,a,f); - -#define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \ - if ((c.slen != 0) && \ - (M_ASN1_next == \ - (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\ - { \ - M_ASN1_D2I_get_imp_set(b,func,free_func,\ - tag,V_ASN1_CONTEXT_SPECIFIC); \ - } - -#define M_ASN1_D2I_get_IMP_set_opt_type(type,b,func,free_func,tag) \ - if ((c.slen != 0) && \ - (M_ASN1_next == \ - (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\ - { \ - M_ASN1_D2I_get_imp_set_type(type,b,func,free_func,\ - tag,V_ASN1_CONTEXT_SPECIFIC); \ - } - -#define M_ASN1_D2I_get_seq(r,func,free_func) \ - M_ASN1_D2I_get_imp_set(r,func,free_func,\ - V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); - -#define M_ASN1_D2I_get_seq_type(type,r,func,free_func) \ - M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\ - V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL) - -#define M_ASN1_D2I_get_seq_opt(r,func,free_func) \ - if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ - V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\ - { M_ASN1_D2I_get_seq(r,func,free_func); } - -#define M_ASN1_D2I_get_seq_opt_type(type,r,func,free_func) \ - if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ - V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\ - { M_ASN1_D2I_get_seq_type(type,r,func,free_func); } - -#define M_ASN1_D2I_get_IMP_set(r,func,free_func,x) \ - M_ASN1_D2I_get_imp_set(r,func,free_func,\ - x,V_ASN1_CONTEXT_SPECIFIC); - -#define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \ - M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\ - x,V_ASN1_CONTEXT_SPECIFIC); - -#define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \ - c.q=c.p; \ - if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\ - (void (*)())free_func,a,b) == NULL) \ - { c.line=__LINE__; goto err; } \ - c.slen-=(c.p-c.q); - -#define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \ - c.q=c.p; \ - if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\ - free_func,a,b) == NULL) \ - { c.line=__LINE__; goto err; } \ - c.slen-=(c.p-c.q); - -#define M_ASN1_D2I_get_set_strings(r,func,a,b) \ - c.q=c.p; \ - if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \ - { c.line=__LINE__; goto err; } \ - c.slen-=(c.p-c.q); - -#define M_ASN1_D2I_get_EXP_opt(r,func,tag) \ - if ((c.slen != 0L) && (M_ASN1_next == \ - (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ - { \ - int Tinf,Ttag,Tclass; \ - long Tlen; \ - \ - c.q=c.p; \ - Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ - if (Tinf & 0x80) \ - { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ - c.line=__LINE__; goto err; } \ - if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ - Tlen = c.slen - (c.p - c.q) - 2; \ - if (func(&(r),&c.p,Tlen) == NULL) \ - { c.line=__LINE__; goto err; } \ - if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ - Tlen = c.slen - (c.p - c.q); \ - if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \ - { c.error=ERR_R_MISSING_ASN1_EOS; \ - c.line=__LINE__; goto err; } \ - }\ - c.slen-=(c.p-c.q); \ - } - -#define M_ASN1_D2I_get_EXP_set_opt(r,func,free_func,tag,b) \ - if ((c.slen != 0) && (M_ASN1_next == \ - (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ - { \ - int Tinf,Ttag,Tclass; \ - long Tlen; \ - \ - c.q=c.p; \ - Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ - if (Tinf & 0x80) \ - { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ - c.line=__LINE__; goto err; } \ - if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ - Tlen = c.slen - (c.p - c.q) - 2; \ - if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \ - (void (*)())free_func, \ - b,V_ASN1_UNIVERSAL) == NULL) \ - { c.line=__LINE__; goto err; } \ - if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ - Tlen = c.slen - (c.p - c.q); \ - if(!ASN1_check_infinite_end(&c.p, Tlen)) \ - { c.error=ERR_R_MISSING_ASN1_EOS; \ - c.line=__LINE__; goto err; } \ - }\ - c.slen-=(c.p-c.q); \ - } - -#define M_ASN1_D2I_get_EXP_set_opt_type(type,r,func,free_func,tag,b) \ - if ((c.slen != 0) && (M_ASN1_next == \ - (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ - { \ - int Tinf,Ttag,Tclass; \ - long Tlen; \ - \ - c.q=c.p; \ - Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ - if (Tinf & 0x80) \ - { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ - c.line=__LINE__; goto err; } \ - if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ - Tlen = c.slen - (c.p - c.q) - 2; \ - if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \ - free_func,b,V_ASN1_UNIVERSAL) == NULL) \ - { c.line=__LINE__; goto err; } \ - if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ - Tlen = c.slen - (c.p - c.q); \ - if(!ASN1_check_infinite_end(&c.p, Tlen)) \ - { c.error=ERR_R_MISSING_ASN1_EOS; \ - c.line=__LINE__; goto err; } \ - }\ - c.slen-=(c.p-c.q); \ - } - -/* New macros */ -#define M_ASN1_New_Malloc(ret,type) \ - if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \ - { c.line=__LINE__; goto err2; } - -#define M_ASN1_New(arg,func) \ - if (((arg)=func()) == NULL) return(NULL) - -#define M_ASN1_New_Error(a) \ -/* err: ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \ - return(NULL);*/ \ - err2: ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \ - return(NULL) - - -/* BIG UGLY WARNING! This is so damn ugly I wanna puke. Unfortunately, - some macros that use ASN1_const_CTX still insist on writing in the input - stream. ARGH! ARGH! ARGH! Let's get rid of this macro package. - Please? -- Richard Levitte */ -#define M_ASN1_next (*((unsigned char *)(c.p))) -#define M_ASN1_next_prev (*((unsigned char *)(c.q))) - -/*************************************************/ - -#define M_ASN1_I2D_vars(a) int r=0,ret=0; \ - unsigned char *p; \ - if (a == NULL) return(0) - -/* Length Macros */ -#define M_ASN1_I2D_len(a,f) ret+=f(a,NULL) -#define M_ASN1_I2D_len_IMP_opt(a,f) if (a != NULL) M_ASN1_I2D_len(a,f) - -#define M_ASN1_I2D_len_SET(a,f) \ - ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET); - -#define M_ASN1_I2D_len_SET_type(type,a,f) \ - ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \ - V_ASN1_UNIVERSAL,IS_SET); - -#define M_ASN1_I2D_len_SEQUENCE(a,f) \ - ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \ - IS_SEQUENCE); - -#define M_ASN1_I2D_len_SEQUENCE_type(type,a,f) \ - ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SEQUENCE, \ - V_ASN1_UNIVERSAL,IS_SEQUENCE) - -#define M_ASN1_I2D_len_SEQUENCE_opt(a,f) \ - if ((a != NULL) && (sk_num(a) != 0)) \ - M_ASN1_I2D_len_SEQUENCE(a,f); - -#define M_ASN1_I2D_len_SEQUENCE_opt_type(type,a,f) \ - if ((a != NULL) && (sk_##type##_num(a) != 0)) \ - M_ASN1_I2D_len_SEQUENCE_type(type,a,f); - -#define M_ASN1_I2D_len_IMP_SET(a,f,x) \ - ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET); - -#define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \ - ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ - V_ASN1_CONTEXT_SPECIFIC,IS_SET); - -#define M_ASN1_I2D_len_IMP_SET_opt(a,f,x) \ - if ((a != NULL) && (sk_num(a) != 0)) \ - ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ - IS_SET); - -#define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \ - if ((a != NULL) && (sk_##type##_num(a) != 0)) \ - ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ - V_ASN1_CONTEXT_SPECIFIC,IS_SET); - -#define M_ASN1_I2D_len_IMP_SEQUENCE(a,f,x) \ - ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ - IS_SEQUENCE); - -#define M_ASN1_I2D_len_IMP_SEQUENCE_opt(a,f,x) \ - if ((a != NULL) && (sk_num(a) != 0)) \ - ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ - IS_SEQUENCE); - -#define M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(type,a,f,x) \ - if ((a != NULL) && (sk_##type##_num(a) != 0)) \ - ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ - V_ASN1_CONTEXT_SPECIFIC, \ - IS_SEQUENCE); - -#define M_ASN1_I2D_len_EXP_opt(a,f,mtag,v) \ - if (a != NULL)\ - { \ - v=f(a,NULL); \ - ret+=ASN1_object_size(1,v,mtag); \ - } - -#define M_ASN1_I2D_len_EXP_SET_opt(a,f,mtag,tag,v) \ - if ((a != NULL) && (sk_num(a) != 0))\ - { \ - v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL,IS_SET); \ - ret+=ASN1_object_size(1,v,mtag); \ - } - -#define M_ASN1_I2D_len_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \ - if ((a != NULL) && (sk_num(a) != 0))\ - { \ - v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL, \ - IS_SEQUENCE); \ - ret+=ASN1_object_size(1,v,mtag); \ - } - -#define M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \ - if ((a != NULL) && (sk_##type##_num(a) != 0))\ - { \ - v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \ - V_ASN1_UNIVERSAL, \ - IS_SEQUENCE); \ - ret+=ASN1_object_size(1,v,mtag); \ - } - -/* Put Macros */ -#define M_ASN1_I2D_put(a,f) f(a,&p) - -#define M_ASN1_I2D_put_IMP_opt(a,f,t) \ - if (a != NULL) \ - { \ - unsigned char *q=p; \ - f(a,&p); \ - *q=(V_ASN1_CONTEXT_SPECIFIC|t|(*q&V_ASN1_CONSTRUCTED));\ - } - -#define M_ASN1_I2D_put_SET(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SET,\ - V_ASN1_UNIVERSAL,IS_SET) -#define M_ASN1_I2D_put_SET_type(type,a,f) \ - i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET) -#define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\ - V_ASN1_CONTEXT_SPECIFIC,IS_SET) -#define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \ - i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET) -#define M_ASN1_I2D_put_IMP_SEQUENCE(a,f,x) i2d_ASN1_SET(a,&p,f,x,\ - V_ASN1_CONTEXT_SPECIFIC,IS_SEQUENCE) - -#define M_ASN1_I2D_put_SEQUENCE(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SEQUENCE,\ - V_ASN1_UNIVERSAL,IS_SEQUENCE) - -#define M_ASN1_I2D_put_SEQUENCE_type(type,a,f) \ - i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \ - IS_SEQUENCE) - -#define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \ - if ((a != NULL) && (sk_num(a) != 0)) \ - M_ASN1_I2D_put_SEQUENCE(a,f); - -#define M_ASN1_I2D_put_IMP_SET_opt(a,f,x) \ - if ((a != NULL) && (sk_num(a) != 0)) \ - { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \ - IS_SET); } - -#define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \ - if ((a != NULL) && (sk_##type##_num(a) != 0)) \ - { i2d_ASN1_SET_OF_##type(a,&p,f,x, \ - V_ASN1_CONTEXT_SPECIFIC, \ - IS_SET); } - -#define M_ASN1_I2D_put_IMP_SEQUENCE_opt(a,f,x) \ - if ((a != NULL) && (sk_num(a) != 0)) \ - { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \ - IS_SEQUENCE); } - -#define M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(type,a,f,x) \ - if ((a != NULL) && (sk_##type##_num(a) != 0)) \ - { i2d_ASN1_SET_OF_##type(a,&p,f,x, \ - V_ASN1_CONTEXT_SPECIFIC, \ - IS_SEQUENCE); } - -#define M_ASN1_I2D_put_EXP_opt(a,f,tag,v) \ - if (a != NULL) \ - { \ - ASN1_put_object(&p,1,v,tag,V_ASN1_CONTEXT_SPECIFIC); \ - f(a,&p); \ - } - -#define M_ASN1_I2D_put_EXP_SET_opt(a,f,mtag,tag,v) \ - if ((a != NULL) && (sk_num(a) != 0)) \ - { \ - ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ - i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SET); \ - } - -#define M_ASN1_I2D_put_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \ - if ((a != NULL) && (sk_num(a) != 0)) \ - { \ - ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ - i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SEQUENCE); \ - } - -#define M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \ - if ((a != NULL) && (sk_##type##_num(a) != 0)) \ - { \ - ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ - i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \ - IS_SEQUENCE); \ - } - -#define M_ASN1_I2D_seq_total() \ - r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \ - if (pp == NULL) return(r); \ - p= *pp; \ - ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL) - -#define M_ASN1_I2D_INF_seq_start(tag,ctx) \ - *(p++)=(V_ASN1_CONSTRUCTED|(tag)|(ctx)); \ - *(p++)=0x80 - -#define M_ASN1_I2D_INF_seq_end() *(p++)=0x00; *(p++)=0x00 - -#define M_ASN1_I2D_finish() *pp=p; \ - return(r); - -int asn1_GetSequence(ASN1_const_CTX *c, long *length); -void asn1_add_error(const unsigned char *address,int offset); -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/asn1/asn1_mac.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ASN1_MAC_H +#define HEADER_ASN1_MAC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ASN1_MAC_ERR_LIB +#define ASN1_MAC_ERR_LIB ERR_LIB_ASN1 +#endif + +#define ASN1_MAC_H_err(f,r,line) \ + ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line)) + +#define M_ASN1_D2I_vars(a,type,func) \ + ASN1_const_CTX c; \ + type ret=NULL; \ + \ + c.pp=(const unsigned char **)pp; \ + c.q= *(const unsigned char **)pp; \ + c.error=ERR_R_NESTED_ASN1_ERROR; \ + if ((a == NULL) || ((*a) == NULL)) \ + { if ((ret=(type)func()) == NULL) \ + { c.line=__LINE__; goto err; } } \ + else ret=(*a); + +#define M_ASN1_D2I_Init() \ + c.p= *(const unsigned char **)pp; \ + c.max=(length == 0)?0:(c.p+length); + +#define M_ASN1_D2I_Finish_2(a) \ + if (!asn1_const_Finish(&c)) \ + { c.line=__LINE__; goto err; } \ + *(const unsigned char **)pp=c.p; \ + if (a != NULL) (*a)=ret; \ + return(ret); + +#define M_ASN1_D2I_Finish(a,func,e) \ + M_ASN1_D2I_Finish_2(a); \ +err:\ + ASN1_MAC_H_err((e),c.error,c.line); \ + asn1_add_error(*(const unsigned char **)pp,(int)(c.q- *pp)); \ + if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \ + return(NULL) + +#define M_ASN1_D2I_start_sequence() \ + if (!asn1_GetSequence(&c,&length)) \ + { c.line=__LINE__; goto err; } +/* Begin reading ASN1 without a surrounding sequence */ +#define M_ASN1_D2I_begin() \ + c.slen = length; + +/* End reading ASN1 with no check on length */ +#define M_ASN1_D2I_Finish_nolen(a, func, e) \ + *pp=c.p; \ + if (a != NULL) (*a)=ret; \ + return(ret); \ +err:\ + ASN1_MAC_H_err((e),c.error,c.line); \ + asn1_add_error(*pp,(int)(c.q- *pp)); \ + if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \ + return(NULL) + +#define M_ASN1_D2I_end_sequence() \ + (((c.inf&1) == 0)?(c.slen <= 0): \ + (c.eos=ASN1_const_check_infinite_end(&c.p,c.slen))) + +/* Don't use this with d2i_ASN1_BOOLEAN() */ +#define M_ASN1_D2I_get(b, func) \ + c.q=c.p; \ + if (func(&(b),&c.p,c.slen) == NULL) \ + {c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +/* Don't use this with d2i_ASN1_BOOLEAN() */ +#define M_ASN1_D2I_get_x(type,b,func) \ + c.q=c.p; \ + if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \ + {c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +/* use this instead () */ +#define M_ASN1_D2I_get_int(b,func) \ + c.q=c.p; \ + if (func(&(b),&c.p,c.slen) < 0) \ + {c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_opt(b,func,type) \ + if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \ + == (V_ASN1_UNIVERSAL|(type)))) \ + { \ + M_ASN1_D2I_get(b,func); \ + } + +#define M_ASN1_D2I_get_imp(b,func, type) \ + M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \ + c.q=c.p; \ + if (func(&(b),&c.p,c.slen) == NULL) \ + {c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \ + c.slen-=(c.p-c.q);\ + M_ASN1_next_prev=_tmp; + +#define M_ASN1_D2I_get_IMP_opt(b,func,tag,type) \ + if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) == \ + (V_ASN1_CONTEXT_SPECIFIC|(tag)))) \ + { \ + unsigned char _tmp = M_ASN1_next; \ + M_ASN1_D2I_get_imp(b,func, type);\ + } + +#define M_ASN1_D2I_get_set(r,func,free_func) \ + M_ASN1_D2I_get_imp_set(r,func,free_func, \ + V_ASN1_SET,V_ASN1_UNIVERSAL); + +#define M_ASN1_D2I_get_set_type(type,r,func,free_func) \ + M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \ + V_ASN1_SET,V_ASN1_UNIVERSAL); + +#define M_ASN1_D2I_get_set_opt(r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SET)))\ + { M_ASN1_D2I_get_set(r,func,free_func); } + +#define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SET)))\ + { M_ASN1_D2I_get_set_type(type,r,func,free_func); } + +#define M_ASN1_I2D_len_SET_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_len_SET(a,f); + +#define M_ASN1_I2D_put_SET_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_put_SET(a,f); + +#define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_put_SEQUENCE(a,f); + +#define M_ASN1_I2D_put_SEQUENCE_opt_type(type,a,f) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + M_ASN1_I2D_put_SEQUENCE_type(type,a,f); + +#define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \ + if ((c.slen != 0) && \ + (M_ASN1_next == \ + (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\ + { \ + M_ASN1_D2I_get_imp_set(b,func,free_func,\ + tag,V_ASN1_CONTEXT_SPECIFIC); \ + } + +#define M_ASN1_D2I_get_IMP_set_opt_type(type,b,func,free_func,tag) \ + if ((c.slen != 0) && \ + (M_ASN1_next == \ + (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\ + { \ + M_ASN1_D2I_get_imp_set_type(type,b,func,free_func,\ + tag,V_ASN1_CONTEXT_SPECIFIC); \ + } + +#define M_ASN1_D2I_get_seq(r,func,free_func) \ + M_ASN1_D2I_get_imp_set(r,func,free_func,\ + V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + +#define M_ASN1_D2I_get_seq_type(type,r,func,free_func) \ + M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\ + V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL) + +#define M_ASN1_D2I_get_seq_opt(r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\ + { M_ASN1_D2I_get_seq(r,func,free_func); } + +#define M_ASN1_D2I_get_seq_opt_type(type,r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\ + { M_ASN1_D2I_get_seq_type(type,r,func,free_func); } + +#define M_ASN1_D2I_get_IMP_set(r,func,free_func,x) \ + M_ASN1_D2I_get_imp_set(r,func,free_func,\ + x,V_ASN1_CONTEXT_SPECIFIC); + +#define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \ + M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\ + x,V_ASN1_CONTEXT_SPECIFIC); + +#define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \ + c.q=c.p; \ + if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\ + (void (*)())free_func,a,b) == NULL) \ + { c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \ + c.q=c.p; \ + if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\ + free_func,a,b) == NULL) \ + { c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_set_strings(r,func,a,b) \ + c.q=c.p; \ + if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \ + { c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_EXP_opt(r,func,tag) \ + if ((c.slen != 0L) && (M_ASN1_next == \ + (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ + { \ + int Tinf,Ttag,Tclass; \ + long Tlen; \ + \ + c.q=c.p; \ + Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ + if (Tinf & 0x80) \ + { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ + c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ + Tlen = c.slen - (c.p - c.q) - 2; \ + if (func(&(r),&c.p,Tlen) == NULL) \ + { c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ + Tlen = c.slen - (c.p - c.q); \ + if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \ + { c.error=ERR_R_MISSING_ASN1_EOS; \ + c.line=__LINE__; goto err; } \ + }\ + c.slen-=(c.p-c.q); \ + } + +#define M_ASN1_D2I_get_EXP_set_opt(r,func,free_func,tag,b) \ + if ((c.slen != 0) && (M_ASN1_next == \ + (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ + { \ + int Tinf,Ttag,Tclass; \ + long Tlen; \ + \ + c.q=c.p; \ + Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ + if (Tinf & 0x80) \ + { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ + c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ + Tlen = c.slen - (c.p - c.q) - 2; \ + if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \ + (void (*)())free_func, \ + b,V_ASN1_UNIVERSAL) == NULL) \ + { c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ + Tlen = c.slen - (c.p - c.q); \ + if(!ASN1_check_infinite_end(&c.p, Tlen)) \ + { c.error=ERR_R_MISSING_ASN1_EOS; \ + c.line=__LINE__; goto err; } \ + }\ + c.slen-=(c.p-c.q); \ + } + +#define M_ASN1_D2I_get_EXP_set_opt_type(type,r,func,free_func,tag,b) \ + if ((c.slen != 0) && (M_ASN1_next == \ + (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ + { \ + int Tinf,Ttag,Tclass; \ + long Tlen; \ + \ + c.q=c.p; \ + Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ + if (Tinf & 0x80) \ + { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ + c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ + Tlen = c.slen - (c.p - c.q) - 2; \ + if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \ + free_func,b,V_ASN1_UNIVERSAL) == NULL) \ + { c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ + Tlen = c.slen - (c.p - c.q); \ + if(!ASN1_check_infinite_end(&c.p, Tlen)) \ + { c.error=ERR_R_MISSING_ASN1_EOS; \ + c.line=__LINE__; goto err; } \ + }\ + c.slen-=(c.p-c.q); \ + } + +/* New macros */ +#define M_ASN1_New_Malloc(ret,type) \ + if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \ + { c.line=__LINE__; goto err2; } + +#define M_ASN1_New(arg,func) \ + if (((arg)=func()) == NULL) return(NULL) + +#define M_ASN1_New_Error(a) \ +/* err: ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \ + return(NULL);*/ \ + err2: ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \ + return(NULL) + + +/* BIG UGLY WARNING! This is so damn ugly I wanna puke. Unfortunately, + some macros that use ASN1_const_CTX still insist on writing in the input + stream. ARGH! ARGH! ARGH! Let's get rid of this macro package. + Please? -- Richard Levitte */ +#define M_ASN1_next (*((unsigned char *)(c.p))) +#define M_ASN1_next_prev (*((unsigned char *)(c.q))) + +/*************************************************/ + +#define M_ASN1_I2D_vars(a) int r=0,ret=0; \ + unsigned char *p; \ + if (a == NULL) return(0) + +/* Length Macros */ +#define M_ASN1_I2D_len(a,f) ret+=f(a,NULL) +#define M_ASN1_I2D_len_IMP_opt(a,f) if (a != NULL) M_ASN1_I2D_len(a,f) + +#define M_ASN1_I2D_len_SET(a,f) \ + ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET); + +#define M_ASN1_I2D_len_SET_type(type,a,f) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \ + V_ASN1_UNIVERSAL,IS_SET); + +#define M_ASN1_I2D_len_SEQUENCE(a,f) \ + ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_SEQUENCE_type(type,a,f) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SEQUENCE, \ + V_ASN1_UNIVERSAL,IS_SEQUENCE) + +#define M_ASN1_I2D_len_SEQUENCE_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_len_SEQUENCE(a,f); + +#define M_ASN1_I2D_len_SEQUENCE_opt_type(type,a,f) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + M_ASN1_I2D_len_SEQUENCE_type(type,a,f); + +#define M_ASN1_I2D_len_IMP_SET(a,f,x) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET); + +#define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ + V_ASN1_CONTEXT_SPECIFIC,IS_SET); + +#define M_ASN1_I2D_len_IMP_SET_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SET); + +#define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ + V_ASN1_CONTEXT_SPECIFIC,IS_SET); + +#define M_ASN1_I2D_len_IMP_SEQUENCE(a,f,x) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_IMP_SEQUENCE_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ + V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_EXP_opt(a,f,mtag,v) \ + if (a != NULL)\ + { \ + v=f(a,NULL); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +#define M_ASN1_I2D_len_EXP_SET_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0))\ + { \ + v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL,IS_SET); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +#define M_ASN1_I2D_len_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0))\ + { \ + v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +#define M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_##type##_num(a) != 0))\ + { \ + v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \ + V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +/* Put Macros */ +#define M_ASN1_I2D_put(a,f) f(a,&p) + +#define M_ASN1_I2D_put_IMP_opt(a,f,t) \ + if (a != NULL) \ + { \ + unsigned char *q=p; \ + f(a,&p); \ + *q=(V_ASN1_CONTEXT_SPECIFIC|t|(*q&V_ASN1_CONSTRUCTED));\ + } + +#define M_ASN1_I2D_put_SET(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SET,\ + V_ASN1_UNIVERSAL,IS_SET) +#define M_ASN1_I2D_put_SET_type(type,a,f) \ + i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET) +#define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\ + V_ASN1_CONTEXT_SPECIFIC,IS_SET) +#define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \ + i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET) +#define M_ASN1_I2D_put_IMP_SEQUENCE(a,f,x) i2d_ASN1_SET(a,&p,f,x,\ + V_ASN1_CONTEXT_SPECIFIC,IS_SEQUENCE) + +#define M_ASN1_I2D_put_SEQUENCE(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SEQUENCE,\ + V_ASN1_UNIVERSAL,IS_SEQUENCE) + +#define M_ASN1_I2D_put_SEQUENCE_type(type,a,f) \ + i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE) + +#define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_put_SEQUENCE(a,f); + +#define M_ASN1_I2D_put_IMP_SET_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SET); } + +#define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + { i2d_ASN1_SET_OF_##type(a,&p,f,x, \ + V_ASN1_CONTEXT_SPECIFIC, \ + IS_SET); } + +#define M_ASN1_I2D_put_IMP_SEQUENCE_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); } + +#define M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + { i2d_ASN1_SET_OF_##type(a,&p,f,x, \ + V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); } + +#define M_ASN1_I2D_put_EXP_opt(a,f,tag,v) \ + if (a != NULL) \ + { \ + ASN1_put_object(&p,1,v,tag,V_ASN1_CONTEXT_SPECIFIC); \ + f(a,&p); \ + } + +#define M_ASN1_I2D_put_EXP_SET_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { \ + ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ + i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SET); \ + } + +#define M_ASN1_I2D_put_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { \ + ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ + i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SEQUENCE); \ + } + +#define M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + { \ + ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ + i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); \ + } + +#define M_ASN1_I2D_seq_total() \ + r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \ + if (pp == NULL) return(r); \ + p= *pp; \ + ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL) + +#define M_ASN1_I2D_INF_seq_start(tag,ctx) \ + *(p++)=(V_ASN1_CONSTRUCTED|(tag)|(ctx)); \ + *(p++)=0x80 + +#define M_ASN1_I2D_INF_seq_end() *(p++)=0x00; *(p++)=0x00 + +#define M_ASN1_I2D_finish() *pp=p; \ + return(r); + +int asn1_GetSequence(ASN1_const_CTX *c, long *length); +void asn1_add_error(const unsigned char *address,int offset); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/asn1t.h b/src/dep/include/openssl/asn1t.h index e2ac426..eedbfc5 100644 --- a/src/dep/include/openssl/asn1t.h +++ b/src/dep/include/openssl/asn1t.h @@ -1,886 +1,886 @@ -/* asn1t.h */ -/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL - * project 2000. - */ -/* ==================================================================== - * Copyright (c) 2000 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -#ifndef HEADER_ASN1T_H -#define HEADER_ASN1T_H - -#include -#include -#include - -#ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT -#endif - -/* ASN1 template defines, structures and functions */ - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION - -/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ -#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr)) - - -/* Macros for start and end of ASN1_ITEM definition */ - -#define ASN1_ITEM_start(itname) \ - OPENSSL_GLOBAL const ASN1_ITEM itname##_it = { - -#define ASN1_ITEM_end(itname) \ - }; - -#else - -/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ -#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr())) - - -/* Macros for start and end of ASN1_ITEM definition */ - -#define ASN1_ITEM_start(itname) \ - const ASN1_ITEM * itname##_it(void) \ - { \ - static const ASN1_ITEM local_it = { \ - -#define ASN1_ITEM_end(itname) \ - }; \ - return &local_it; \ - } - -#endif - - -/* Macros to aid ASN1 template writing */ - -#define ASN1_ITEM_TEMPLATE(tname) \ - static const ASN1_TEMPLATE tname##_item_tt - -#define ASN1_ITEM_TEMPLATE_END(tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_PRIMITIVE,\ - -1,\ - &tname##_item_tt,\ - 0,\ - NULL,\ - 0,\ - #tname \ - ASN1_ITEM_end(tname) - - -/* This is a ASN1 type which just embeds a template */ - -/* This pair helps declare a SEQUENCE. We can do: - * - * ASN1_SEQUENCE(stname) = { - * ... SEQUENCE components ... - * } ASN1_SEQUENCE_END(stname) - * - * This will produce an ASN1_ITEM called stname_it - * for a structure called stname. - * - * If you want the same structure but a different - * name then use: - * - * ASN1_SEQUENCE(itname) = { - * ... SEQUENCE components ... - * } ASN1_SEQUENCE_END_name(stname, itname) - * - * This will create an item called itname_it using - * a structure called stname. - */ - -#define ASN1_SEQUENCE(tname) \ - static const ASN1_TEMPLATE tname##_seq_tt[] - -#define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) - -#define ASN1_SEQUENCE_END_name(stname, tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -#define ASN1_NDEF_SEQUENCE(tname) \ - ASN1_SEQUENCE(tname) - -#define ASN1_SEQUENCE_cb(tname, cb) \ - static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ - ASN1_SEQUENCE(tname) - -#define ASN1_BROKEN_SEQUENCE(tname) \ - static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \ - ASN1_SEQUENCE(tname) - -#define ASN1_SEQUENCE_ref(tname, cb, lck) \ - static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \ - ASN1_SEQUENCE(tname) - -#define ASN1_SEQUENCE_enc(tname, enc, cb) \ - static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \ - ASN1_SEQUENCE(tname) - -#define ASN1_NDEF_SEQUENCE_END(tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_NDEF_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(tname),\ - #tname \ - ASN1_ITEM_end(tname) - -#define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname) - -#define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) - -#define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) - -#define ASN1_SEQUENCE_END_ref(stname, tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - &tname##_aux,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - - -/* This pair helps declare a CHOICE type. We can do: - * - * ASN1_CHOICE(chname) = { - * ... CHOICE options ... - * ASN1_CHOICE_END(chname) - * - * This will produce an ASN1_ITEM called chname_it - * for a structure called chname. The structure - * definition must look like this: - * typedef struct { - * int type; - * union { - * ASN1_SOMETHING *opt1; - * ASN1_SOMEOTHER *opt2; - * } value; - * } chname; - * - * the name of the selector must be 'type'. - * to use an alternative selector name use the - * ASN1_CHOICE_END_selector() version. - */ - -#define ASN1_CHOICE(tname) \ - static const ASN1_TEMPLATE tname##_ch_tt[] - -#define ASN1_CHOICE_cb(tname, cb) \ - static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ - ASN1_CHOICE(tname) - -#define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname) - -#define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type) - -#define ASN1_CHOICE_END_selector(stname, tname, selname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_CHOICE,\ - offsetof(stname,selname) ,\ - tname##_ch_tt,\ - sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -#define ASN1_CHOICE_END_cb(stname, tname, selname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_CHOICE,\ - offsetof(stname,selname) ,\ - tname##_ch_tt,\ - sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ - &tname##_aux,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -/* This helps with the template wrapper form of ASN1_ITEM */ - -#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \ - (flags), (tag), 0,\ - #name, ASN1_ITEM_ref(type) } - -/* These help with SEQUENCE or CHOICE components */ - -/* used to declare other types */ - -#define ASN1_EX_TYPE(flags, tag, stname, field, type) { \ - (flags), (tag), offsetof(stname, field),\ - #field, ASN1_ITEM_ref(type) } - -/* used when the structure is combined with the parent */ - -#define ASN1_EX_COMBINE(flags, tag, type) { \ - (flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) } - -/* implicit and explicit helper macros */ - -#define ASN1_IMP_EX(stname, field, type, tag, ex) \ - ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type) - -#define ASN1_EXP_EX(stname, field, type, tag, ex) \ - ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type) - -/* Any defined by macros: the field used is in the table itself */ - -#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION -#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } -#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } -#else -#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb } -#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb } -#endif -/* Plain simple type */ -#define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type) - -/* OPTIONAL simple type */ -#define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type) - -/* IMPLICIT tagged simple type */ -#define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0) - -/* IMPLICIT tagged OPTIONAL simple type */ -#define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) - -/* Same as above but EXPLICIT */ - -#define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0) -#define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) - -/* SEQUENCE OF type */ -#define ASN1_SEQUENCE_OF(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) - -/* OPTIONAL SEQUENCE OF */ -#define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) - -/* Same as above but for SET OF */ - -#define ASN1_SET_OF(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) - -#define ASN1_SET_OF_OPT(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) - -/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ - -#define ASN1_IMP_SET_OF(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) - -#define ASN1_EXP_SET_OF(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) - -#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) - -#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) - -#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) - -#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) - -#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) - -#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) - -/* EXPLICIT OPTIONAL using indefinite length constructed form */ -#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF) - -/* Macros for the ASN1_ADB structure */ - -#define ASN1_ADB(name) \ - static const ASN1_ADB_TABLE name##_adbtbl[] - -#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION - -#define ASN1_ADB_END(name, flags, field, app_table, def, none) \ - ;\ - static const ASN1_ADB name##_adb = {\ - flags,\ - offsetof(name, field),\ - app_table,\ - name##_adbtbl,\ - sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ - def,\ - none\ - } - -#else - -#define ASN1_ADB_END(name, flags, field, app_table, def, none) \ - ;\ - static const ASN1_ITEM *name##_adb(void) \ - { \ - static const ASN1_ADB internal_adb = \ - {\ - flags,\ - offsetof(name, field),\ - app_table,\ - name##_adbtbl,\ - sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ - def,\ - none\ - }; \ - return (const ASN1_ITEM *) &internal_adb; \ - } \ - void dummy_function(void) - -#endif - -#define ADB_ENTRY(val, template) {val, template} - -#define ASN1_ADB_TEMPLATE(name) \ - static const ASN1_TEMPLATE name##_tt - -/* This is the ASN1 template structure that defines - * a wrapper round the actual type. It determines the - * actual position of the field in the value structure, - * various flags such as OPTIONAL and the field name. - */ - -struct ASN1_TEMPLATE_st { -unsigned long flags; /* Various flags */ -long tag; /* tag, not used if no tagging */ -unsigned long offset; /* Offset of this field in structure */ -#ifndef NO_ASN1_FIELD_NAMES -const char *field_name; /* Field name */ -#endif -ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */ -}; - -/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */ - -#define ASN1_TEMPLATE_item(t) (t->item_ptr) -#define ASN1_TEMPLATE_adb(t) (t->item_ptr) - -typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE; -typedef struct ASN1_ADB_st ASN1_ADB; - -struct ASN1_ADB_st { - unsigned long flags; /* Various flags */ - unsigned long offset; /* Offset of selector field */ - STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */ - const ASN1_ADB_TABLE *tbl; /* Table of possible types */ - long tblcount; /* Number of entries in tbl */ - const ASN1_TEMPLATE *default_tt; /* Type to use if no match */ - const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */ -}; - -struct ASN1_ADB_TABLE_st { - long value; /* NID for an object or value for an int */ - const ASN1_TEMPLATE tt; /* item for this value */ -}; - -/* template flags */ - -/* Field is optional */ -#define ASN1_TFLG_OPTIONAL (0x1) - -/* Field is a SET OF */ -#define ASN1_TFLG_SET_OF (0x1 << 1) - -/* Field is a SEQUENCE OF */ -#define ASN1_TFLG_SEQUENCE_OF (0x2 << 1) - -/* Special case: this refers to a SET OF that - * will be sorted into DER order when encoded *and* - * the corresponding STACK will be modified to match - * the new order. - */ -#define ASN1_TFLG_SET_ORDER (0x3 << 1) - -/* Mask for SET OF or SEQUENCE OF */ -#define ASN1_TFLG_SK_MASK (0x3 << 1) - -/* These flags mean the tag should be taken from the - * tag field. If EXPLICIT then the underlying type - * is used for the inner tag. - */ - -/* IMPLICIT tagging */ -#define ASN1_TFLG_IMPTAG (0x1 << 3) - - -/* EXPLICIT tagging, inner tag from underlying type */ -#define ASN1_TFLG_EXPTAG (0x2 << 3) - -#define ASN1_TFLG_TAG_MASK (0x3 << 3) - -/* context specific IMPLICIT */ -#define ASN1_TFLG_IMPLICIT ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT - -/* context specific EXPLICIT */ -#define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT - -/* If tagging is in force these determine the - * type of tag to use. Otherwise the tag is - * determined by the underlying type. These - * values reflect the actual octet format. - */ - -/* Universal tag */ -#define ASN1_TFLG_UNIVERSAL (0x0<<6) -/* Application tag */ -#define ASN1_TFLG_APPLICATION (0x1<<6) -/* Context specific tag */ -#define ASN1_TFLG_CONTEXT (0x2<<6) -/* Private tag */ -#define ASN1_TFLG_PRIVATE (0x3<<6) - -#define ASN1_TFLG_TAG_CLASS (0x3<<6) - -/* These are for ANY DEFINED BY type. In this case - * the 'item' field points to an ASN1_ADB structure - * which contains a table of values to decode the - * relevant type - */ - -#define ASN1_TFLG_ADB_MASK (0x3<<8) - -#define ASN1_TFLG_ADB_OID (0x1<<8) - -#define ASN1_TFLG_ADB_INT (0x1<<9) - -/* This flag means a parent structure is passed - * instead of the field: this is useful is a - * SEQUENCE is being combined with a CHOICE for - * example. Since this means the structure and - * item name will differ we need to use the - * ASN1_CHOICE_END_name() macro for example. - */ - -#define ASN1_TFLG_COMBINE (0x1<<10) - -/* This flag when present in a SEQUENCE OF, SET OF - * or EXPLICIT causes indefinite length constructed - * encoding to be used if required. - */ - -#define ASN1_TFLG_NDEF (0x1<<11) - -/* This is the actual ASN1 item itself */ - -struct ASN1_ITEM_st { -char itype; /* The item type, primitive, SEQUENCE, CHOICE or extern */ -long utype; /* underlying type */ -const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains the contents */ -long tcount; /* Number of templates if SEQUENCE or CHOICE */ -const void *funcs; /* functions that handle this type */ -long size; /* Structure size (usually)*/ -#ifndef NO_ASN1_FIELD_NAMES -const char *sname; /* Structure name */ -#endif -}; - -/* These are values for the itype field and - * determine how the type is interpreted. - * - * For PRIMITIVE types the underlying type - * determines the behaviour if items is NULL. - * - * Otherwise templates must contain a single - * template and the type is treated in the - * same way as the type specified in the template. - * - * For SEQUENCE types the templates field points - * to the members, the size field is the - * structure size. - * - * For CHOICE types the templates field points - * to each possible member (typically a union) - * and the 'size' field is the offset of the - * selector. - * - * The 'funcs' field is used for application - * specific functions. - * - * For COMPAT types the funcs field gives a - * set of functions that handle this type, this - * supports the old d2i, i2d convention. - * - * The EXTERN type uses a new style d2i/i2d. - * The new style should be used where possible - * because it avoids things like the d2i IMPLICIT - * hack. - * - * MSTRING is a multiple string type, it is used - * for a CHOICE of character strings where the - * actual strings all occupy an ASN1_STRING - * structure. In this case the 'utype' field - * has a special meaning, it is used as a mask - * of acceptable types using the B_ASN1 constants. - * - * NDEF_SEQUENCE is the same as SEQUENCE except - * that it will use indefinite length constructed - * encoding if requested. - * - */ - -#define ASN1_ITYPE_PRIMITIVE 0x0 - -#define ASN1_ITYPE_SEQUENCE 0x1 - -#define ASN1_ITYPE_CHOICE 0x2 - -#define ASN1_ITYPE_COMPAT 0x3 - -#define ASN1_ITYPE_EXTERN 0x4 - -#define ASN1_ITYPE_MSTRING 0x5 - -#define ASN1_ITYPE_NDEF_SEQUENCE 0x6 - -/* Cache for ASN1 tag and length, so we - * don't keep re-reading it for things - * like CHOICE - */ - -struct ASN1_TLC_st{ - char valid; /* Values below are valid */ - int ret; /* return value */ - long plen; /* length */ - int ptag; /* class value */ - int pclass; /* class value */ - int hdrlen; /* header length */ -}; - -/* Typedefs for ASN1 function pointers */ - -typedef ASN1_VALUE * ASN1_new_func(void); -typedef void ASN1_free_func(ASN1_VALUE *a); -typedef ASN1_VALUE * ASN1_d2i_func(ASN1_VALUE **a, const unsigned char ** in, long length); -typedef int ASN1_i2d_func(ASN1_VALUE * a, unsigned char **in); - -typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, - int tag, int aclass, char opt, ASN1_TLC *ctx); - -typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); -typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); -typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); - -typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); -typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); - -typedef struct ASN1_COMPAT_FUNCS_st { - ASN1_new_func *asn1_new; - ASN1_free_func *asn1_free; - ASN1_d2i_func *asn1_d2i; - ASN1_i2d_func *asn1_i2d; -} ASN1_COMPAT_FUNCS; - -typedef struct ASN1_EXTERN_FUNCS_st { - void *app_data; - ASN1_ex_new_func *asn1_ex_new; - ASN1_ex_free_func *asn1_ex_free; - ASN1_ex_free_func *asn1_ex_clear; - ASN1_ex_d2i *asn1_ex_d2i; - ASN1_ex_i2d *asn1_ex_i2d; -} ASN1_EXTERN_FUNCS; - -typedef struct ASN1_PRIMITIVE_FUNCS_st { - void *app_data; - unsigned long flags; - ASN1_ex_new_func *prim_new; - ASN1_ex_free_func *prim_free; - ASN1_ex_free_func *prim_clear; - ASN1_primitive_c2i *prim_c2i; - ASN1_primitive_i2c *prim_i2c; -} ASN1_PRIMITIVE_FUNCS; - -/* This is the ASN1_AUX structure: it handles various - * miscellaneous requirements. For example the use of - * reference counts and an informational callback. - * - * The "informational callback" is called at various - * points during the ASN1 encoding and decoding. It can - * be used to provide minor customisation of the structures - * used. This is most useful where the supplied routines - * *almost* do the right thing but need some extra help - * at a few points. If the callback returns zero then - * it is assumed a fatal error has occurred and the - * main operation should be abandoned. - * - * If major changes in the default behaviour are required - * then an external type is more appropriate. - */ - -typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it); - -typedef struct ASN1_AUX_st { - void *app_data; - int flags; - int ref_offset; /* Offset of reference value */ - int ref_lock; /* Lock type to use */ - ASN1_aux_cb *asn1_cb; - int enc_offset; /* Offset of ASN1_ENCODING structure */ -} ASN1_AUX; - -/* Flags in ASN1_AUX */ - -/* Use a reference count */ -#define ASN1_AFLG_REFCOUNT 1 -/* Save the encoding of structure (useful for signatures) */ -#define ASN1_AFLG_ENCODING 2 -/* The Sequence length is invalid */ -#define ASN1_AFLG_BROKEN 4 - -/* operation values for asn1_cb */ - -#define ASN1_OP_NEW_PRE 0 -#define ASN1_OP_NEW_POST 1 -#define ASN1_OP_FREE_PRE 2 -#define ASN1_OP_FREE_POST 3 -#define ASN1_OP_D2I_PRE 4 -#define ASN1_OP_D2I_POST 5 -#define ASN1_OP_I2D_PRE 6 -#define ASN1_OP_I2D_POST 7 - -/* Macro to implement a primitive type */ -#define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) -#define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \ - ASN1_ITEM_start(itname) \ - ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \ - ASN1_ITEM_end(itname) - -/* Macro to implement a multi string type */ -#define IMPLEMENT_ASN1_MSTRING(itname, mask) \ - ASN1_ITEM_start(itname) \ - ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \ - ASN1_ITEM_end(itname) - -/* Macro to implement an ASN1_ITEM in terms of old style funcs */ - -#define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE) - -#define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \ - static const ASN1_COMPAT_FUNCS sname##_ff = { \ - (ASN1_new_func *)sname##_new, \ - (ASN1_free_func *)sname##_free, \ - (ASN1_d2i_func *)d2i_##sname, \ - (ASN1_i2d_func *)i2d_##sname, \ - }; \ - ASN1_ITEM_start(sname) \ - ASN1_ITYPE_COMPAT, \ - tag, \ - NULL, \ - 0, \ - &sname##_ff, \ - 0, \ - #sname \ - ASN1_ITEM_end(sname) - -#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ - ASN1_ITEM_start(sname) \ - ASN1_ITYPE_EXTERN, \ - tag, \ - NULL, \ - 0, \ - &fptrs, \ - 0, \ - #sname \ - ASN1_ITEM_end(sname) - -/* Macro to implement standard functions in terms of ASN1_ITEM structures */ - -#define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) - -#define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) - -#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ - IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) - -#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) - -#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ - stname *fname##_new(void) \ - { \ - return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ - } \ - void fname##_free(stname *a) \ - { \ - ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ - } - -#define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) - -#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ - stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ - { \ - return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ - } \ - int i2d_##fname(stname *a, unsigned char **out) \ - { \ - return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ - } - -#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ - int i2d_##stname##_NDEF(stname *a, unsigned char **out) \ - { \ - return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\ - } - -/* This includes evil casts to remove const: they will go away when full - * ASN1 constification is done. - */ -#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ - stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ - { \ - return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ - } \ - int i2d_##fname(const stname *a, unsigned char **out) \ - { \ - return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ - } - -#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ - stname * stname##_dup(stname *x) \ - { \ - return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ - } - -#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \ - IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name) - -#define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) - -/* external definitions for primitive types */ - -DECLARE_ASN1_ITEM(ASN1_BOOLEAN) -DECLARE_ASN1_ITEM(ASN1_TBOOLEAN) -DECLARE_ASN1_ITEM(ASN1_FBOOLEAN) -DECLARE_ASN1_ITEM(ASN1_SEQUENCE) -DECLARE_ASN1_ITEM(CBIGNUM) -DECLARE_ASN1_ITEM(BIGNUM) -DECLARE_ASN1_ITEM(LONG) -DECLARE_ASN1_ITEM(ZLONG) - -DECLARE_STACK_OF(ASN1_VALUE) - -/* Functions used internally by the ASN1 code */ - -int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); -void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it); -int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); -int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it); - -void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); -int ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_TEMPLATE *tt); -int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, - int tag, int aclass, char opt, ASN1_TLC *ctx); - -int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); -int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt); -void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it); - -int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); -int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); - -int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); -int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it); - -ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); - -const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, int nullerr); - -int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it); - -void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it); -void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it); -int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, const ASN1_ITEM *it); -int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, const ASN1_ITEM *it); - -#ifdef __cplusplus -} -#endif -#endif +/* asn1t.h */ +/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_ASN1T_H +#define HEADER_ASN1T_H + +#include +#include +#include + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +/* ASN1 template defines, structures and functions */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION + +/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ +#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr)) + + +/* Macros for start and end of ASN1_ITEM definition */ + +#define ASN1_ITEM_start(itname) \ + OPENSSL_GLOBAL const ASN1_ITEM itname##_it = { + +#define ASN1_ITEM_end(itname) \ + }; + +#else + +/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ +#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr())) + + +/* Macros for start and end of ASN1_ITEM definition */ + +#define ASN1_ITEM_start(itname) \ + const ASN1_ITEM * itname##_it(void) \ + { \ + static const ASN1_ITEM local_it = { \ + +#define ASN1_ITEM_end(itname) \ + }; \ + return &local_it; \ + } + +#endif + + +/* Macros to aid ASN1 template writing */ + +#define ASN1_ITEM_TEMPLATE(tname) \ + static const ASN1_TEMPLATE tname##_item_tt + +#define ASN1_ITEM_TEMPLATE_END(tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_PRIMITIVE,\ + -1,\ + &tname##_item_tt,\ + 0,\ + NULL,\ + 0,\ + #tname \ + ASN1_ITEM_end(tname) + + +/* This is a ASN1 type which just embeds a template */ + +/* This pair helps declare a SEQUENCE. We can do: + * + * ASN1_SEQUENCE(stname) = { + * ... SEQUENCE components ... + * } ASN1_SEQUENCE_END(stname) + * + * This will produce an ASN1_ITEM called stname_it + * for a structure called stname. + * + * If you want the same structure but a different + * name then use: + * + * ASN1_SEQUENCE(itname) = { + * ... SEQUENCE components ... + * } ASN1_SEQUENCE_END_name(stname, itname) + * + * This will create an item called itname_it using + * a structure called stname. + */ + +#define ASN1_SEQUENCE(tname) \ + static const ASN1_TEMPLATE tname##_seq_tt[] + +#define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) + +#define ASN1_SEQUENCE_END_name(stname, tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +#define ASN1_NDEF_SEQUENCE(tname) \ + ASN1_SEQUENCE(tname) + +#define ASN1_SEQUENCE_cb(tname, cb) \ + static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_BROKEN_SEQUENCE(tname) \ + static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_SEQUENCE_ref(tname, cb, lck) \ + static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_SEQUENCE_enc(tname, enc, cb) \ + static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_NDEF_SEQUENCE_END(tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_NDEF_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(tname),\ + #tname \ + ASN1_ITEM_end(tname) + +#define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname) + +#define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) + +#define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) + +#define ASN1_SEQUENCE_END_ref(stname, tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + &tname##_aux,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + + +/* This pair helps declare a CHOICE type. We can do: + * + * ASN1_CHOICE(chname) = { + * ... CHOICE options ... + * ASN1_CHOICE_END(chname) + * + * This will produce an ASN1_ITEM called chname_it + * for a structure called chname. The structure + * definition must look like this: + * typedef struct { + * int type; + * union { + * ASN1_SOMETHING *opt1; + * ASN1_SOMEOTHER *opt2; + * } value; + * } chname; + * + * the name of the selector must be 'type'. + * to use an alternative selector name use the + * ASN1_CHOICE_END_selector() version. + */ + +#define ASN1_CHOICE(tname) \ + static const ASN1_TEMPLATE tname##_ch_tt[] + +#define ASN1_CHOICE_cb(tname, cb) \ + static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ + ASN1_CHOICE(tname) + +#define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname) + +#define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type) + +#define ASN1_CHOICE_END_selector(stname, tname, selname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_CHOICE,\ + offsetof(stname,selname) ,\ + tname##_ch_tt,\ + sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +#define ASN1_CHOICE_END_cb(stname, tname, selname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_CHOICE,\ + offsetof(stname,selname) ,\ + tname##_ch_tt,\ + sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ + &tname##_aux,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +/* This helps with the template wrapper form of ASN1_ITEM */ + +#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \ + (flags), (tag), 0,\ + #name, ASN1_ITEM_ref(type) } + +/* These help with SEQUENCE or CHOICE components */ + +/* used to declare other types */ + +#define ASN1_EX_TYPE(flags, tag, stname, field, type) { \ + (flags), (tag), offsetof(stname, field),\ + #field, ASN1_ITEM_ref(type) } + +/* used when the structure is combined with the parent */ + +#define ASN1_EX_COMBINE(flags, tag, type) { \ + (flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) } + +/* implicit and explicit helper macros */ + +#define ASN1_IMP_EX(stname, field, type, tag, ex) \ + ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type) + +#define ASN1_EXP_EX(stname, field, type, tag, ex) \ + ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type) + +/* Any defined by macros: the field used is in the table itself */ + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION +#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } +#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } +#else +#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb } +#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb } +#endif +/* Plain simple type */ +#define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type) + +/* OPTIONAL simple type */ +#define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type) + +/* IMPLICIT tagged simple type */ +#define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0) + +/* IMPLICIT tagged OPTIONAL simple type */ +#define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) + +/* Same as above but EXPLICIT */ + +#define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0) +#define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) + +/* SEQUENCE OF type */ +#define ASN1_SEQUENCE_OF(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) + +/* OPTIONAL SEQUENCE OF */ +#define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) + +/* Same as above but for SET OF */ + +#define ASN1_SET_OF(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) + +#define ASN1_SET_OF_OPT(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) + +/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ + +#define ASN1_IMP_SET_OF(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) + +#define ASN1_EXP_SET_OF(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) + +#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) + +#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) + +#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) + +#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) + +#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) + +#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) + +/* EXPLICIT OPTIONAL using indefinite length constructed form */ +#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF) + +/* Macros for the ASN1_ADB structure */ + +#define ASN1_ADB(name) \ + static const ASN1_ADB_TABLE name##_adbtbl[] + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#define ASN1_ADB_END(name, flags, field, app_table, def, none) \ + ;\ + static const ASN1_ADB name##_adb = {\ + flags,\ + offsetof(name, field),\ + app_table,\ + name##_adbtbl,\ + sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ + def,\ + none\ + } + +#else + +#define ASN1_ADB_END(name, flags, field, app_table, def, none) \ + ;\ + static const ASN1_ITEM *name##_adb(void) \ + { \ + static const ASN1_ADB internal_adb = \ + {\ + flags,\ + offsetof(name, field),\ + app_table,\ + name##_adbtbl,\ + sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ + def,\ + none\ + }; \ + return (const ASN1_ITEM *) &internal_adb; \ + } \ + void dummy_function(void) + +#endif + +#define ADB_ENTRY(val, template) {val, template} + +#define ASN1_ADB_TEMPLATE(name) \ + static const ASN1_TEMPLATE name##_tt + +/* This is the ASN1 template structure that defines + * a wrapper round the actual type. It determines the + * actual position of the field in the value structure, + * various flags such as OPTIONAL and the field name. + */ + +struct ASN1_TEMPLATE_st { +unsigned long flags; /* Various flags */ +long tag; /* tag, not used if no tagging */ +unsigned long offset; /* Offset of this field in structure */ +#ifndef NO_ASN1_FIELD_NAMES +const char *field_name; /* Field name */ +#endif +ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */ +}; + +/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */ + +#define ASN1_TEMPLATE_item(t) (t->item_ptr) +#define ASN1_TEMPLATE_adb(t) (t->item_ptr) + +typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE; +typedef struct ASN1_ADB_st ASN1_ADB; + +struct ASN1_ADB_st { + unsigned long flags; /* Various flags */ + unsigned long offset; /* Offset of selector field */ + STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */ + const ASN1_ADB_TABLE *tbl; /* Table of possible types */ + long tblcount; /* Number of entries in tbl */ + const ASN1_TEMPLATE *default_tt; /* Type to use if no match */ + const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */ +}; + +struct ASN1_ADB_TABLE_st { + long value; /* NID for an object or value for an int */ + const ASN1_TEMPLATE tt; /* item for this value */ +}; + +/* template flags */ + +/* Field is optional */ +#define ASN1_TFLG_OPTIONAL (0x1) + +/* Field is a SET OF */ +#define ASN1_TFLG_SET_OF (0x1 << 1) + +/* Field is a SEQUENCE OF */ +#define ASN1_TFLG_SEQUENCE_OF (0x2 << 1) + +/* Special case: this refers to a SET OF that + * will be sorted into DER order when encoded *and* + * the corresponding STACK will be modified to match + * the new order. + */ +#define ASN1_TFLG_SET_ORDER (0x3 << 1) + +/* Mask for SET OF or SEQUENCE OF */ +#define ASN1_TFLG_SK_MASK (0x3 << 1) + +/* These flags mean the tag should be taken from the + * tag field. If EXPLICIT then the underlying type + * is used for the inner tag. + */ + +/* IMPLICIT tagging */ +#define ASN1_TFLG_IMPTAG (0x1 << 3) + + +/* EXPLICIT tagging, inner tag from underlying type */ +#define ASN1_TFLG_EXPTAG (0x2 << 3) + +#define ASN1_TFLG_TAG_MASK (0x3 << 3) + +/* context specific IMPLICIT */ +#define ASN1_TFLG_IMPLICIT ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT + +/* context specific EXPLICIT */ +#define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT + +/* If tagging is in force these determine the + * type of tag to use. Otherwise the tag is + * determined by the underlying type. These + * values reflect the actual octet format. + */ + +/* Universal tag */ +#define ASN1_TFLG_UNIVERSAL (0x0<<6) +/* Application tag */ +#define ASN1_TFLG_APPLICATION (0x1<<6) +/* Context specific tag */ +#define ASN1_TFLG_CONTEXT (0x2<<6) +/* Private tag */ +#define ASN1_TFLG_PRIVATE (0x3<<6) + +#define ASN1_TFLG_TAG_CLASS (0x3<<6) + +/* These are for ANY DEFINED BY type. In this case + * the 'item' field points to an ASN1_ADB structure + * which contains a table of values to decode the + * relevant type + */ + +#define ASN1_TFLG_ADB_MASK (0x3<<8) + +#define ASN1_TFLG_ADB_OID (0x1<<8) + +#define ASN1_TFLG_ADB_INT (0x1<<9) + +/* This flag means a parent structure is passed + * instead of the field: this is useful is a + * SEQUENCE is being combined with a CHOICE for + * example. Since this means the structure and + * item name will differ we need to use the + * ASN1_CHOICE_END_name() macro for example. + */ + +#define ASN1_TFLG_COMBINE (0x1<<10) + +/* This flag when present in a SEQUENCE OF, SET OF + * or EXPLICIT causes indefinite length constructed + * encoding to be used if required. + */ + +#define ASN1_TFLG_NDEF (0x1<<11) + +/* This is the actual ASN1 item itself */ + +struct ASN1_ITEM_st { +char itype; /* The item type, primitive, SEQUENCE, CHOICE or extern */ +long utype; /* underlying type */ +const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains the contents */ +long tcount; /* Number of templates if SEQUENCE or CHOICE */ +const void *funcs; /* functions that handle this type */ +long size; /* Structure size (usually)*/ +#ifndef NO_ASN1_FIELD_NAMES +const char *sname; /* Structure name */ +#endif +}; + +/* These are values for the itype field and + * determine how the type is interpreted. + * + * For PRIMITIVE types the underlying type + * determines the behaviour if items is NULL. + * + * Otherwise templates must contain a single + * template and the type is treated in the + * same way as the type specified in the template. + * + * For SEQUENCE types the templates field points + * to the members, the size field is the + * structure size. + * + * For CHOICE types the templates field points + * to each possible member (typically a union) + * and the 'size' field is the offset of the + * selector. + * + * The 'funcs' field is used for application + * specific functions. + * + * For COMPAT types the funcs field gives a + * set of functions that handle this type, this + * supports the old d2i, i2d convention. + * + * The EXTERN type uses a new style d2i/i2d. + * The new style should be used where possible + * because it avoids things like the d2i IMPLICIT + * hack. + * + * MSTRING is a multiple string type, it is used + * for a CHOICE of character strings where the + * actual strings all occupy an ASN1_STRING + * structure. In this case the 'utype' field + * has a special meaning, it is used as a mask + * of acceptable types using the B_ASN1 constants. + * + * NDEF_SEQUENCE is the same as SEQUENCE except + * that it will use indefinite length constructed + * encoding if requested. + * + */ + +#define ASN1_ITYPE_PRIMITIVE 0x0 + +#define ASN1_ITYPE_SEQUENCE 0x1 + +#define ASN1_ITYPE_CHOICE 0x2 + +#define ASN1_ITYPE_COMPAT 0x3 + +#define ASN1_ITYPE_EXTERN 0x4 + +#define ASN1_ITYPE_MSTRING 0x5 + +#define ASN1_ITYPE_NDEF_SEQUENCE 0x6 + +/* Cache for ASN1 tag and length, so we + * don't keep re-reading it for things + * like CHOICE + */ + +struct ASN1_TLC_st{ + char valid; /* Values below are valid */ + int ret; /* return value */ + long plen; /* length */ + int ptag; /* class value */ + int pclass; /* class value */ + int hdrlen; /* header length */ +}; + +/* Typedefs for ASN1 function pointers */ + +typedef ASN1_VALUE * ASN1_new_func(void); +typedef void ASN1_free_func(ASN1_VALUE *a); +typedef ASN1_VALUE * ASN1_d2i_func(ASN1_VALUE **a, const unsigned char ** in, long length); +typedef int ASN1_i2d_func(ASN1_VALUE * a, unsigned char **in); + +typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, + int tag, int aclass, char opt, ASN1_TLC *ctx); + +typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); +typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); +typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); + +typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); +typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); + +typedef struct ASN1_COMPAT_FUNCS_st { + ASN1_new_func *asn1_new; + ASN1_free_func *asn1_free; + ASN1_d2i_func *asn1_d2i; + ASN1_i2d_func *asn1_i2d; +} ASN1_COMPAT_FUNCS; + +typedef struct ASN1_EXTERN_FUNCS_st { + void *app_data; + ASN1_ex_new_func *asn1_ex_new; + ASN1_ex_free_func *asn1_ex_free; + ASN1_ex_free_func *asn1_ex_clear; + ASN1_ex_d2i *asn1_ex_d2i; + ASN1_ex_i2d *asn1_ex_i2d; +} ASN1_EXTERN_FUNCS; + +typedef struct ASN1_PRIMITIVE_FUNCS_st { + void *app_data; + unsigned long flags; + ASN1_ex_new_func *prim_new; + ASN1_ex_free_func *prim_free; + ASN1_ex_free_func *prim_clear; + ASN1_primitive_c2i *prim_c2i; + ASN1_primitive_i2c *prim_i2c; +} ASN1_PRIMITIVE_FUNCS; + +/* This is the ASN1_AUX structure: it handles various + * miscellaneous requirements. For example the use of + * reference counts and an informational callback. + * + * The "informational callback" is called at various + * points during the ASN1 encoding and decoding. It can + * be used to provide minor customisation of the structures + * used. This is most useful where the supplied routines + * *almost* do the right thing but need some extra help + * at a few points. If the callback returns zero then + * it is assumed a fatal error has occurred and the + * main operation should be abandoned. + * + * If major changes in the default behaviour are required + * then an external type is more appropriate. + */ + +typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it); + +typedef struct ASN1_AUX_st { + void *app_data; + int flags; + int ref_offset; /* Offset of reference value */ + int ref_lock; /* Lock type to use */ + ASN1_aux_cb *asn1_cb; + int enc_offset; /* Offset of ASN1_ENCODING structure */ +} ASN1_AUX; + +/* Flags in ASN1_AUX */ + +/* Use a reference count */ +#define ASN1_AFLG_REFCOUNT 1 +/* Save the encoding of structure (useful for signatures) */ +#define ASN1_AFLG_ENCODING 2 +/* The Sequence length is invalid */ +#define ASN1_AFLG_BROKEN 4 + +/* operation values for asn1_cb */ + +#define ASN1_OP_NEW_PRE 0 +#define ASN1_OP_NEW_POST 1 +#define ASN1_OP_FREE_PRE 2 +#define ASN1_OP_FREE_POST 3 +#define ASN1_OP_D2I_PRE 4 +#define ASN1_OP_D2I_POST 5 +#define ASN1_OP_I2D_PRE 6 +#define ASN1_OP_I2D_POST 7 + +/* Macro to implement a primitive type */ +#define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) +#define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \ + ASN1_ITEM_start(itname) \ + ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \ + ASN1_ITEM_end(itname) + +/* Macro to implement a multi string type */ +#define IMPLEMENT_ASN1_MSTRING(itname, mask) \ + ASN1_ITEM_start(itname) \ + ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \ + ASN1_ITEM_end(itname) + +/* Macro to implement an ASN1_ITEM in terms of old style funcs */ + +#define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE) + +#define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \ + static const ASN1_COMPAT_FUNCS sname##_ff = { \ + (ASN1_new_func *)sname##_new, \ + (ASN1_free_func *)sname##_free, \ + (ASN1_d2i_func *)d2i_##sname, \ + (ASN1_i2d_func *)i2d_##sname, \ + }; \ + ASN1_ITEM_start(sname) \ + ASN1_ITYPE_COMPAT, \ + tag, \ + NULL, \ + 0, \ + &sname##_ff, \ + 0, \ + #sname \ + ASN1_ITEM_end(sname) + +#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ + ASN1_ITEM_start(sname) \ + ASN1_ITYPE_EXTERN, \ + tag, \ + NULL, \ + 0, \ + &fptrs, \ + 0, \ + #sname \ + ASN1_ITEM_end(sname) + +/* Macro to implement standard functions in terms of ASN1_ITEM structures */ + +#define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) + +#define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) + +#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ + IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) + +#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) + +#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ + stname *fname##_new(void) \ + { \ + return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ + } \ + void fname##_free(stname *a) \ + { \ + ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ + } + +#define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) + +#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ + stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ + { \ + return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ + } \ + int i2d_##fname(stname *a, unsigned char **out) \ + { \ + return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ + } + +#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ + int i2d_##stname##_NDEF(stname *a, unsigned char **out) \ + { \ + return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\ + } + +/* This includes evil casts to remove const: they will go away when full + * ASN1 constification is done. + */ +#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ + stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ + { \ + return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ + } \ + int i2d_##fname(const stname *a, unsigned char **out) \ + { \ + return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ + } + +#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ + stname * stname##_dup(stname *x) \ + { \ + return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ + } + +#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \ + IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name) + +#define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) + +/* external definitions for primitive types */ + +DECLARE_ASN1_ITEM(ASN1_BOOLEAN) +DECLARE_ASN1_ITEM(ASN1_TBOOLEAN) +DECLARE_ASN1_ITEM(ASN1_FBOOLEAN) +DECLARE_ASN1_ITEM(ASN1_SEQUENCE) +DECLARE_ASN1_ITEM(CBIGNUM) +DECLARE_ASN1_ITEM(BIGNUM) +DECLARE_ASN1_ITEM(LONG) +DECLARE_ASN1_ITEM(ZLONG) + +DECLARE_STACK_OF(ASN1_VALUE) + +/* Functions used internally by the ASN1 code */ + +int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); +void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it); +int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); +int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it); + +void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); +int ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_TEMPLATE *tt); +int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, + int tag, int aclass, char opt, ASN1_TLC *ctx); + +int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); +int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt); +void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it); + +int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); +int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); + +int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); +int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it); + +ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); + +const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, int nullerr); + +int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it); + +void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it); +void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it); +int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, const ASN1_ITEM *it); +int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, const ASN1_ITEM *it); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/bio.h b/src/dep/include/openssl/bio.h index 894c5ba..82b86e4 100644 --- a/src/dep/include/openssl/bio.h +++ b/src/dep/include/openssl/bio.h @@ -1,770 +1,770 @@ -/* crypto/bio/bio.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_BIO_H -#define HEADER_BIO_H - -#include - -#ifndef OPENSSL_NO_FP_API -# include -#endif -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* These are the 'types' of BIOs */ -#define BIO_TYPE_NONE 0 -#define BIO_TYPE_MEM (1|0x0400) -#define BIO_TYPE_FILE (2|0x0400) - -#define BIO_TYPE_FD (4|0x0400|0x0100) -#define BIO_TYPE_SOCKET (5|0x0400|0x0100) -#define BIO_TYPE_NULL (6|0x0400) -#define BIO_TYPE_SSL (7|0x0200) -#define BIO_TYPE_MD (8|0x0200) /* passive filter */ -#define BIO_TYPE_BUFFER (9|0x0200) /* filter */ -#define BIO_TYPE_CIPHER (10|0x0200) /* filter */ -#define BIO_TYPE_BASE64 (11|0x0200) /* filter */ -#define BIO_TYPE_CONNECT (12|0x0400|0x0100) /* socket - connect */ -#define BIO_TYPE_ACCEPT (13|0x0400|0x0100) /* socket for accept */ -#define BIO_TYPE_PROXY_CLIENT (14|0x0200) /* client proxy BIO */ -#define BIO_TYPE_PROXY_SERVER (15|0x0200) /* server proxy BIO */ -#define BIO_TYPE_NBIO_TEST (16|0x0200) /* server proxy BIO */ -#define BIO_TYPE_NULL_FILTER (17|0x0200) -#define BIO_TYPE_BER (18|0x0200) /* BER -> bin filter */ -#define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */ -#define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */ -#define BIO_TYPE_DGRAM (21|0x0400|0x0100) - -#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ -#define BIO_TYPE_FILTER 0x0200 -#define BIO_TYPE_SOURCE_SINK 0x0400 - -/* BIO_FILENAME_READ|BIO_CLOSE to open or close on free. - * BIO_set_fp(in,stdin,BIO_NOCLOSE); */ -#define BIO_NOCLOSE 0x00 -#define BIO_CLOSE 0x01 - -/* These are used in the following macros and are passed to - * BIO_ctrl() */ -#define BIO_CTRL_RESET 1 /* opt - rewind/zero etc */ -#define BIO_CTRL_EOF 2 /* opt - are we at the eof */ -#define BIO_CTRL_INFO 3 /* opt - extra tit-bits */ -#define BIO_CTRL_SET 4 /* man - set the 'IO' type */ -#define BIO_CTRL_GET 5 /* man - get the 'IO' type */ -#define BIO_CTRL_PUSH 6 /* opt - internal, used to signify change */ -#define BIO_CTRL_POP 7 /* opt - internal, used to signify change */ -#define BIO_CTRL_GET_CLOSE 8 /* man - set the 'close' on free */ -#define BIO_CTRL_SET_CLOSE 9 /* man - set the 'close' on free */ -#define BIO_CTRL_PENDING 10 /* opt - is their more data buffered */ -#define BIO_CTRL_FLUSH 11 /* opt - 'flush' buffered output */ -#define BIO_CTRL_DUP 12 /* man - extra stuff for 'duped' BIO */ -#define BIO_CTRL_WPENDING 13 /* opt - number of bytes still to write */ -/* callback is int cb(BIO *bio,state,ret); */ -#define BIO_CTRL_SET_CALLBACK 14 /* opt - set callback function */ -#define BIO_CTRL_GET_CALLBACK 15 /* opt - set callback function */ - -#define BIO_CTRL_SET_FILENAME 30 /* BIO_s_file special */ - -/* dgram BIO stuff */ -#define BIO_CTRL_DGRAM_CONNECT 31 /* BIO dgram special */ -#define BIO_CTRL_DGRAM_SET_CONNECTED 32 /* allow for an externally - * connected socket to be - * passed in */ -#define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */ -#define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */ -#define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */ -#define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36 /* getsockopt, essentially */ - -#define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37 /* flag whether the last */ -#define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38 /* I/O operation tiemd out */ - -/* #ifdef IP_MTU_DISCOVER */ -#define BIO_CTRL_DGRAM_MTU_DISCOVER 39 /* set DF bit on egress packets */ -/* #endif */ - -#define BIO_CTRL_DGRAM_QUERY_MTU 40 /* as kernel for current MTU */ -#define BIO_CTRL_DGRAM_GET_MTU 41 /* get cached value for MTU */ -#define BIO_CTRL_DGRAM_SET_MTU 42 /* set cached value for - * MTU. want to use this - * if asking the kernel - * fails */ - -#define BIO_CTRL_DGRAM_MTU_EXCEEDED 43 /* check whether the MTU - * was exceed in the - * previous write - * operation */ - -#define BIO_CTRL_DGRAM_SET_PEER 44 /* Destination for the data */ - - -/* modifiers */ -#define BIO_FP_READ 0x02 -#define BIO_FP_WRITE 0x04 -#define BIO_FP_APPEND 0x08 -#define BIO_FP_TEXT 0x10 - -#define BIO_FLAGS_READ 0x01 -#define BIO_FLAGS_WRITE 0x02 -#define BIO_FLAGS_IO_SPECIAL 0x04 -#define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) -#define BIO_FLAGS_SHOULD_RETRY 0x08 -#ifndef BIO_FLAGS_UPLINK -/* "UPLINK" flag denotes file descriptors provided by application. - It defaults to 0, as most platforms don't require UPLINK interface. */ -#define BIO_FLAGS_UPLINK 0 -#endif - -/* Used in BIO_gethostbyname() */ -#define BIO_GHBN_CTRL_HITS 1 -#define BIO_GHBN_CTRL_MISSES 2 -#define BIO_GHBN_CTRL_CACHE_SIZE 3 -#define BIO_GHBN_CTRL_GET_ENTRY 4 -#define BIO_GHBN_CTRL_FLUSH 5 - -/* Mostly used in the SSL BIO */ -/* Not used anymore - * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10 - * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20 - * #define BIO_FLAGS_PROTOCOL_STARTUP 0x40 - */ - -#define BIO_FLAGS_BASE64_NO_NL 0x100 - -/* This is used with memory BIOs: it means we shouldn't free up or change the - * data in any way. - */ -#define BIO_FLAGS_MEM_RDONLY 0x200 - -#define BIO_set_flags(b,f) ((b)->flags|=(f)) -#define BIO_get_flags(b) ((b)->flags) -#define BIO_set_retry_special(b) \ - ((b)->flags|=(BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY)) -#define BIO_set_retry_read(b) \ - ((b)->flags|=(BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)) -#define BIO_set_retry_write(b) \ - ((b)->flags|=(BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY)) - -/* These are normally used internally in BIOs */ -#define BIO_clear_flags(b,f) ((b)->flags&= ~(f)) -#define BIO_clear_retry_flags(b) \ - ((b)->flags&= ~(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) -#define BIO_get_retry_flags(b) \ - ((b)->flags&(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) - -/* These should be used by the application to tell why we should retry */ -#define BIO_should_read(a) ((a)->flags & BIO_FLAGS_READ) -#define BIO_should_write(a) ((a)->flags & BIO_FLAGS_WRITE) -#define BIO_should_io_special(a) ((a)->flags & BIO_FLAGS_IO_SPECIAL) -#define BIO_retry_type(a) ((a)->flags & BIO_FLAGS_RWS) -#define BIO_should_retry(a) ((a)->flags & BIO_FLAGS_SHOULD_RETRY) - -/* The next three are used in conjunction with the - * BIO_should_io_special() condition. After this returns true, - * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO - * stack and return the 'reason' for the special and the offending BIO. - * Given a BIO, BIO_get_retry_reason(bio) will return the code. */ -/* Returned from the SSL bio when the certificate retrieval code had an error */ -#define BIO_RR_SSL_X509_LOOKUP 0x01 -/* Returned from the connect BIO when a connect would have blocked */ -#define BIO_RR_CONNECT 0x02 -/* Returned from the accept BIO when an accept would have blocked */ -#define BIO_RR_ACCEPT 0x03 - -/* These are passed by the BIO callback */ -#define BIO_CB_FREE 0x01 -#define BIO_CB_READ 0x02 -#define BIO_CB_WRITE 0x03 -#define BIO_CB_PUTS 0x04 -#define BIO_CB_GETS 0x05 -#define BIO_CB_CTRL 0x06 - -/* The callback is called before and after the underling operation, - * The BIO_CB_RETURN flag indicates if it is after the call */ -#define BIO_CB_RETURN 0x80 -#define BIO_CB_return(a) ((a)|BIO_CB_RETURN)) -#define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) -#define BIO_cb_post(a) ((a)&BIO_CB_RETURN) - -#define BIO_set_callback(b,cb) ((b)->callback=(cb)) -#define BIO_set_callback_arg(b,arg) ((b)->cb_arg=(char *)(arg)) -#define BIO_get_callback_arg(b) ((b)->cb_arg) -#define BIO_get_callback(b) ((b)->callback) -#define BIO_method_name(b) ((b)->method->name) -#define BIO_method_type(b) ((b)->method->type) - -typedef struct bio_st BIO; - -typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long); - -#ifndef OPENSSL_SYS_WIN16 -typedef struct bio_method_st - { - int type; - const char *name; - int (*bwrite)(BIO *, const char *, int); - int (*bread)(BIO *, char *, int); - int (*bputs)(BIO *, const char *); - int (*bgets)(BIO *, char *, int); - long (*ctrl)(BIO *, int, long, void *); - int (*create)(BIO *); - int (*destroy)(BIO *); - long (*callback_ctrl)(BIO *, int, bio_info_cb *); - } BIO_METHOD; -#else -typedef struct bio_method_st - { - int type; - const char *name; - int (_far *bwrite)(); - int (_far *bread)(); - int (_far *bputs)(); - int (_far *bgets)(); - long (_far *ctrl)(); - int (_far *create)(); - int (_far *destroy)(); - long (_far *callback_ctrl)(); - } BIO_METHOD; -#endif - -struct bio_st - { - BIO_METHOD *method; - /* bio, mode, argp, argi, argl, ret */ - long (*callback)(struct bio_st *,int,const char *,int, long,long); - char *cb_arg; /* first argument for the callback */ - - int init; - int shutdown; - int flags; /* extra storage */ - int retry_reason; - int num; - void *ptr; - struct bio_st *next_bio; /* used by filter BIOs */ - struct bio_st *prev_bio; /* used by filter BIOs */ - int references; - unsigned long num_read; - unsigned long num_write; - - CRYPTO_EX_DATA ex_data; - }; - -DECLARE_STACK_OF(BIO) - -typedef struct bio_f_buffer_ctx_struct - { - /* BIO *bio; */ /* this is now in the BIO struct */ - int ibuf_size; /* how big is the input buffer */ - int obuf_size; /* how big is the output buffer */ - - char *ibuf; /* the char array */ - int ibuf_len; /* how many bytes are in it */ - int ibuf_off; /* write/read offset */ - - char *obuf; /* the char array */ - int obuf_len; /* how many bytes are in it */ - int obuf_off; /* write/read offset */ - } BIO_F_BUFFER_CTX; - -/* connect BIO stuff */ -#define BIO_CONN_S_BEFORE 1 -#define BIO_CONN_S_GET_IP 2 -#define BIO_CONN_S_GET_PORT 3 -#define BIO_CONN_S_CREATE_SOCKET 4 -#define BIO_CONN_S_CONNECT 5 -#define BIO_CONN_S_OK 6 -#define BIO_CONN_S_BLOCKED_CONNECT 7 -#define BIO_CONN_S_NBIO 8 -/*#define BIO_CONN_get_param_hostname BIO_ctrl */ - -#define BIO_C_SET_CONNECT 100 -#define BIO_C_DO_STATE_MACHINE 101 -#define BIO_C_SET_NBIO 102 -#define BIO_C_SET_PROXY_PARAM 103 -#define BIO_C_SET_FD 104 -#define BIO_C_GET_FD 105 -#define BIO_C_SET_FILE_PTR 106 -#define BIO_C_GET_FILE_PTR 107 -#define BIO_C_SET_FILENAME 108 -#define BIO_C_SET_SSL 109 -#define BIO_C_GET_SSL 110 -#define BIO_C_SET_MD 111 -#define BIO_C_GET_MD 112 -#define BIO_C_GET_CIPHER_STATUS 113 -#define BIO_C_SET_BUF_MEM 114 -#define BIO_C_GET_BUF_MEM_PTR 115 -#define BIO_C_GET_BUFF_NUM_LINES 116 -#define BIO_C_SET_BUFF_SIZE 117 -#define BIO_C_SET_ACCEPT 118 -#define BIO_C_SSL_MODE 119 -#define BIO_C_GET_MD_CTX 120 -#define BIO_C_GET_PROXY_PARAM 121 -#define BIO_C_SET_BUFF_READ_DATA 122 /* data to read first */ -#define BIO_C_GET_CONNECT 123 -#define BIO_C_GET_ACCEPT 124 -#define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 -#define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 -#define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 -#define BIO_C_FILE_SEEK 128 -#define BIO_C_GET_CIPHER_CTX 129 -#define BIO_C_SET_BUF_MEM_EOF_RETURN 130/*return end of input value*/ -#define BIO_C_SET_BIND_MODE 131 -#define BIO_C_GET_BIND_MODE 132 -#define BIO_C_FILE_TELL 133 -#define BIO_C_GET_SOCKS 134 -#define BIO_C_SET_SOCKS 135 - -#define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */ -#define BIO_C_GET_WRITE_BUF_SIZE 137 -#define BIO_C_MAKE_BIO_PAIR 138 -#define BIO_C_DESTROY_BIO_PAIR 139 -#define BIO_C_GET_WRITE_GUARANTEE 140 -#define BIO_C_GET_READ_REQUEST 141 -#define BIO_C_SHUTDOWN_WR 142 -#define BIO_C_NREAD0 143 -#define BIO_C_NREAD 144 -#define BIO_C_NWRITE0 145 -#define BIO_C_NWRITE 146 -#define BIO_C_RESET_READ_REQUEST 147 - - -#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg) -#define BIO_get_app_data(s) BIO_get_ex_data(s,0) - -/* BIO_s_connect() and BIO_s_socks4a_connect() */ -#define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name) -#define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port) -#define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip) -#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port) -#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) -#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) -#define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2) -#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3) - - -#define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) - -/* BIO_s_accept_socket() */ -#define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name) -#define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0) -/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */ -#define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL) -#define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio) - -#define BIO_BIND_NORMAL 0 -#define BIO_BIND_REUSEADDR_IF_UNUSED 1 -#define BIO_BIND_REUSEADDR 2 -#define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) -#define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) - -#define BIO_do_connect(b) BIO_do_handshake(b) -#define BIO_do_accept(b) BIO_do_handshake(b) -#define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) - -/* BIO_s_proxy_client() */ -#define BIO_set_url(b,url) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url)) -#define BIO_set_proxies(b,p) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p)) -/* BIO_set_nbio(b,n) */ -#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s)) -/* BIO *BIO_get_filter_bio(BIO *bio); */ -#define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)())) -#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk) -#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool) - -#define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp) -#define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p)) -#define BIO_get_url(b,url) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url)) -#define BIO_get_no_connect_return(b) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL) - -#define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) -#define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c) - -#define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp) -#define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp) - -#define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL) -#define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL) - -/* name is cast to lose const, but might be better to route through a function - so we can do it safely */ -#ifdef CONST_STRICT -/* If you are wondering why this isn't defined, its because CONST_STRICT is - * purely a compile-time kludge to allow const to be checked. - */ -int BIO_read_filename(BIO *b,const char *name); -#else -#define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ - BIO_CLOSE|BIO_FP_READ,(char *)name) -#endif -#define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ - BIO_CLOSE|BIO_FP_WRITE,name) -#define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ - BIO_CLOSE|BIO_FP_APPEND,name) -#define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ - BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name) - -/* WARNING WARNING, this ups the reference count on the read bio of the - * SSL structure. This is because the ssl read BIO is now pointed to by - * the next_bio field in the bio. So when you free the BIO, make sure - * you are doing a BIO_free_all() to catch the underlying BIO. */ -#define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl) -#define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp) -#define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL) -#define BIO_set_ssl_renegotiate_bytes(b,num) \ - BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL); -#define BIO_get_num_renegotiates(b) \ - BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL); -#define BIO_set_ssl_renegotiate_timeout(b,seconds) \ - BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL); - -/* defined in evp.h */ -/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */ - -#define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp) -#define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm) -#define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp) -#define BIO_set_mem_eof_return(b,v) \ - BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL) - -/* For the BIO_f_buffer() type */ -#define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) -#define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL) -#define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0) -#define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1) -#define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf) - -/* Don't use the next one unless you know what you are doing :-) */ -#define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret)) - -#define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL) -#define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL) -#define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL) -#define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL) -#define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) -#define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL) -/* ...pending macros have inappropriate return type */ -size_t BIO_ctrl_pending(BIO *b); -size_t BIO_ctrl_wpending(BIO *b); -#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) -#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \ - cbp) -#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb) - -/* For the BIO_f_buffer() type */ -#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) - -/* For BIO_s_bio() */ -#define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL) -#define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL) -#define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2) -#define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL) -#define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL) -/* macros with inappropriate type -- but ...pending macros use int too: */ -#define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL) -#define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) -size_t BIO_ctrl_get_write_guarantee(BIO *b); -size_t BIO_ctrl_get_read_request(BIO *b); -int BIO_ctrl_reset_read_request(BIO *b); - -/* ctrl macros for dgram */ -#define BIO_ctrl_dgram_connect(b,peer) \ - (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer) -#define BIO_ctrl_set_connected(b, state, peer) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer) -#define BIO_dgram_recv_timedout(b) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) -#define BIO_dgram_send_timedout(b) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) -#define BIO_dgram_set_peer(b,peer) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer) - -/* These two aren't currently implemented */ -/* int BIO_get_ex_num(BIO *bio); */ -/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */ -int BIO_set_ex_data(BIO *bio,int idx,void *data); -void *BIO_get_ex_data(BIO *bio,int idx); -int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); -unsigned long BIO_number_read(BIO *bio); -unsigned long BIO_number_written(BIO *bio); - -# ifndef OPENSSL_NO_FP_API -# if defined(OPENSSL_SYS_WIN16) && defined(_WINDLL) -BIO_METHOD *BIO_s_file_internal(void); -BIO *BIO_new_file_internal(char *filename, char *mode); -BIO *BIO_new_fp_internal(FILE *stream, int close_flag); -# define BIO_s_file BIO_s_file_internal -# define BIO_new_file BIO_new_file_internal -# define BIO_new_fp BIO_new_fp_internal -# else /* FP_API */ -BIO_METHOD *BIO_s_file(void ); -BIO *BIO_new_file(const char *filename, const char *mode); -BIO *BIO_new_fp(FILE *stream, int close_flag); -# define BIO_s_file_internal BIO_s_file -# define BIO_new_file_internal BIO_new_file -# define BIO_new_fp_internal BIO_s_file -# endif /* FP_API */ -# endif -BIO * BIO_new(BIO_METHOD *type); -int BIO_set(BIO *a,BIO_METHOD *type); -int BIO_free(BIO *a); -void BIO_vfree(BIO *a); -int BIO_read(BIO *b, void *data, int len); -int BIO_gets(BIO *bp,char *buf, int size); -int BIO_write(BIO *b, const void *data, int len); -int BIO_puts(BIO *bp,const char *buf); -int BIO_indent(BIO *b,int indent,int max); -long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); -long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long)); -char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); -long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg); -BIO * BIO_push(BIO *b,BIO *append); -BIO * BIO_pop(BIO *b); -void BIO_free_all(BIO *a); -BIO * BIO_find_type(BIO *b,int bio_type); -BIO * BIO_next(BIO *b); -BIO * BIO_get_retry_BIO(BIO *bio, int *reason); -int BIO_get_retry_reason(BIO *bio); -BIO * BIO_dup_chain(BIO *in); - -int BIO_nread0(BIO *bio, char **buf); -int BIO_nread(BIO *bio, char **buf, int num); -int BIO_nwrite0(BIO *bio, char **buf); -int BIO_nwrite(BIO *bio, char **buf, int num); - -#ifndef OPENSSL_SYS_WIN16 -long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, - long argl,long ret); -#else -long _far _loadds BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, - long argl,long ret); -#endif - -BIO_METHOD *BIO_s_mem(void); -BIO *BIO_new_mem_buf(void *buf, int len); -BIO_METHOD *BIO_s_socket(void); -BIO_METHOD *BIO_s_connect(void); -BIO_METHOD *BIO_s_accept(void); -BIO_METHOD *BIO_s_fd(void); -#ifndef OPENSSL_SYS_OS2 -BIO_METHOD *BIO_s_log(void); -#endif -BIO_METHOD *BIO_s_bio(void); -BIO_METHOD *BIO_s_null(void); -BIO_METHOD *BIO_f_null(void); -BIO_METHOD *BIO_f_buffer(void); -#ifdef OPENSSL_SYS_VMS -BIO_METHOD *BIO_f_linebuffer(void); -#endif -BIO_METHOD *BIO_f_nbio_test(void); -#ifndef OPENSSL_NO_DGRAM -BIO_METHOD *BIO_s_datagram(void); -#endif - -/* BIO_METHOD *BIO_f_ber(void); */ - -int BIO_sock_should_retry(int i); -int BIO_sock_non_fatal_error(int error); -int BIO_dgram_non_fatal_error(int error); - -int BIO_fd_should_retry(int i); -int BIO_fd_non_fatal_error(int error); -int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u), - void *u, const char *s, int len); -int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), - void *u, const char *s, int len, int indent); -int BIO_dump(BIO *b,const char *bytes,int len); -int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent); -#ifndef OPENSSL_NO_FP_API -int BIO_dump_fp(FILE *fp, const char *s, int len); -int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent); -#endif -struct hostent *BIO_gethostbyname(const char *name); -/* We might want a thread-safe interface too: - * struct hostent *BIO_gethostbyname_r(const char *name, - * struct hostent *result, void *buffer, size_t buflen); - * or something similar (caller allocates a struct hostent, - * pointed to by "result", and additional buffer space for the various - * substructures; if the buffer does not suffice, NULL is returned - * and an appropriate error code is set). - */ -int BIO_sock_error(int sock); -int BIO_socket_ioctl(int fd, long type, void *arg); -int BIO_socket_nbio(int fd,int mode); -int BIO_get_port(const char *str, unsigned short *port_ptr); -int BIO_get_host_ip(const char *str, unsigned char *ip); -int BIO_get_accept_socket(char *host_port,int mode); -int BIO_accept(int sock,char **ip_port); -int BIO_sock_init(void ); -void BIO_sock_cleanup(void); -int BIO_set_tcp_ndelay(int sock,int turn_on); - -BIO *BIO_new_socket(int sock, int close_flag); -BIO *BIO_new_dgram(int fd, int close_flag); -BIO *BIO_new_fd(int fd, int close_flag); -BIO *BIO_new_connect(char *host_port); -BIO *BIO_new_accept(char *host_port); - -int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, - BIO **bio2, size_t writebuf2); -/* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints. - * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. - * Size 0 uses default value. - */ - -void BIO_copy_next_retry(BIO *b); - -/*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/ - -#ifdef __GNUC__ -# define __bio_h__attr__ __attribute__ -#else -# define __bio_h__attr__(x) -#endif -int BIO_printf(BIO *bio, const char *format, ...) - __bio_h__attr__((__format__(__printf__,2,3))); -int BIO_vprintf(BIO *bio, const char *format, va_list args) - __bio_h__attr__((__format__(__printf__,2,0))); -int BIO_snprintf(char *buf, size_t n, const char *format, ...) - __bio_h__attr__((__format__(__printf__,3,4))); -int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) - __bio_h__attr__((__format__(__printf__,3,0))); -#undef __bio_h__attr__ - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_BIO_strings(void); - -/* Error codes for the BIO functions. */ - -/* Function codes. */ -#define BIO_F_ACPT_STATE 100 -#define BIO_F_BIO_ACCEPT 101 -#define BIO_F_BIO_BER_GET_HEADER 102 -#define BIO_F_BIO_CALLBACK_CTRL 131 -#define BIO_F_BIO_CTRL 103 -#define BIO_F_BIO_GETHOSTBYNAME 120 -#define BIO_F_BIO_GETS 104 -#define BIO_F_BIO_GET_ACCEPT_SOCKET 105 -#define BIO_F_BIO_GET_HOST_IP 106 -#define BIO_F_BIO_GET_PORT 107 -#define BIO_F_BIO_MAKE_PAIR 121 -#define BIO_F_BIO_NEW 108 -#define BIO_F_BIO_NEW_FILE 109 -#define BIO_F_BIO_NEW_MEM_BUF 126 -#define BIO_F_BIO_NREAD 123 -#define BIO_F_BIO_NREAD0 124 -#define BIO_F_BIO_NWRITE 125 -#define BIO_F_BIO_NWRITE0 122 -#define BIO_F_BIO_PUTS 110 -#define BIO_F_BIO_READ 111 -#define BIO_F_BIO_SOCK_INIT 112 -#define BIO_F_BIO_WRITE 113 -#define BIO_F_BUFFER_CTRL 114 -#define BIO_F_CONN_CTRL 127 -#define BIO_F_CONN_STATE 115 -#define BIO_F_FILE_CTRL 116 -#define BIO_F_FILE_READ 130 -#define BIO_F_LINEBUFFER_CTRL 129 -#define BIO_F_MEM_READ 128 -#define BIO_F_MEM_WRITE 117 -#define BIO_F_SSL_NEW 118 -#define BIO_F_WSASTARTUP 119 - -/* Reason codes. */ -#define BIO_R_ACCEPT_ERROR 100 -#define BIO_R_BAD_FOPEN_MODE 101 -#define BIO_R_BAD_HOSTNAME_LOOKUP 102 -#define BIO_R_BROKEN_PIPE 124 -#define BIO_R_CONNECT_ERROR 103 -#define BIO_R_EOF_ON_MEMORY_BIO 127 -#define BIO_R_ERROR_SETTING_NBIO 104 -#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105 -#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106 -#define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 -#define BIO_R_INVALID_ARGUMENT 125 -#define BIO_R_INVALID_IP_ADDRESS 108 -#define BIO_R_IN_USE 123 -#define BIO_R_KEEPALIVE 109 -#define BIO_R_NBIO_CONNECT_ERROR 110 -#define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 -#define BIO_R_NO_HOSTNAME_SPECIFIED 112 -#define BIO_R_NO_PORT_DEFINED 113 -#define BIO_R_NO_PORT_SPECIFIED 114 -#define BIO_R_NO_SUCH_FILE 128 -#define BIO_R_NULL_PARAMETER 115 -#define BIO_R_TAG_MISMATCH 116 -#define BIO_R_UNABLE_TO_BIND_SOCKET 117 -#define BIO_R_UNABLE_TO_CREATE_SOCKET 118 -#define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 -#define BIO_R_UNINITIALIZED 120 -#define BIO_R_UNSUPPORTED_METHOD 121 -#define BIO_R_WRITE_TO_READ_ONLY_BIO 126 -#define BIO_R_WSASTARTUP 122 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/bio/bio.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BIO_H +#define HEADER_BIO_H + +#include + +#ifndef OPENSSL_NO_FP_API +# include +#endif +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These are the 'types' of BIOs */ +#define BIO_TYPE_NONE 0 +#define BIO_TYPE_MEM (1|0x0400) +#define BIO_TYPE_FILE (2|0x0400) + +#define BIO_TYPE_FD (4|0x0400|0x0100) +#define BIO_TYPE_SOCKET (5|0x0400|0x0100) +#define BIO_TYPE_NULL (6|0x0400) +#define BIO_TYPE_SSL (7|0x0200) +#define BIO_TYPE_MD (8|0x0200) /* passive filter */ +#define BIO_TYPE_BUFFER (9|0x0200) /* filter */ +#define BIO_TYPE_CIPHER (10|0x0200) /* filter */ +#define BIO_TYPE_BASE64 (11|0x0200) /* filter */ +#define BIO_TYPE_CONNECT (12|0x0400|0x0100) /* socket - connect */ +#define BIO_TYPE_ACCEPT (13|0x0400|0x0100) /* socket for accept */ +#define BIO_TYPE_PROXY_CLIENT (14|0x0200) /* client proxy BIO */ +#define BIO_TYPE_PROXY_SERVER (15|0x0200) /* server proxy BIO */ +#define BIO_TYPE_NBIO_TEST (16|0x0200) /* server proxy BIO */ +#define BIO_TYPE_NULL_FILTER (17|0x0200) +#define BIO_TYPE_BER (18|0x0200) /* BER -> bin filter */ +#define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */ +#define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */ +#define BIO_TYPE_DGRAM (21|0x0400|0x0100) + +#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ +#define BIO_TYPE_FILTER 0x0200 +#define BIO_TYPE_SOURCE_SINK 0x0400 + +/* BIO_FILENAME_READ|BIO_CLOSE to open or close on free. + * BIO_set_fp(in,stdin,BIO_NOCLOSE); */ +#define BIO_NOCLOSE 0x00 +#define BIO_CLOSE 0x01 + +/* These are used in the following macros and are passed to + * BIO_ctrl() */ +#define BIO_CTRL_RESET 1 /* opt - rewind/zero etc */ +#define BIO_CTRL_EOF 2 /* opt - are we at the eof */ +#define BIO_CTRL_INFO 3 /* opt - extra tit-bits */ +#define BIO_CTRL_SET 4 /* man - set the 'IO' type */ +#define BIO_CTRL_GET 5 /* man - get the 'IO' type */ +#define BIO_CTRL_PUSH 6 /* opt - internal, used to signify change */ +#define BIO_CTRL_POP 7 /* opt - internal, used to signify change */ +#define BIO_CTRL_GET_CLOSE 8 /* man - set the 'close' on free */ +#define BIO_CTRL_SET_CLOSE 9 /* man - set the 'close' on free */ +#define BIO_CTRL_PENDING 10 /* opt - is their more data buffered */ +#define BIO_CTRL_FLUSH 11 /* opt - 'flush' buffered output */ +#define BIO_CTRL_DUP 12 /* man - extra stuff for 'duped' BIO */ +#define BIO_CTRL_WPENDING 13 /* opt - number of bytes still to write */ +/* callback is int cb(BIO *bio,state,ret); */ +#define BIO_CTRL_SET_CALLBACK 14 /* opt - set callback function */ +#define BIO_CTRL_GET_CALLBACK 15 /* opt - set callback function */ + +#define BIO_CTRL_SET_FILENAME 30 /* BIO_s_file special */ + +/* dgram BIO stuff */ +#define BIO_CTRL_DGRAM_CONNECT 31 /* BIO dgram special */ +#define BIO_CTRL_DGRAM_SET_CONNECTED 32 /* allow for an externally + * connected socket to be + * passed in */ +#define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */ +#define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */ +#define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */ +#define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36 /* getsockopt, essentially */ + +#define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37 /* flag whether the last */ +#define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38 /* I/O operation tiemd out */ + +/* #ifdef IP_MTU_DISCOVER */ +#define BIO_CTRL_DGRAM_MTU_DISCOVER 39 /* set DF bit on egress packets */ +/* #endif */ + +#define BIO_CTRL_DGRAM_QUERY_MTU 40 /* as kernel for current MTU */ +#define BIO_CTRL_DGRAM_GET_MTU 41 /* get cached value for MTU */ +#define BIO_CTRL_DGRAM_SET_MTU 42 /* set cached value for + * MTU. want to use this + * if asking the kernel + * fails */ + +#define BIO_CTRL_DGRAM_MTU_EXCEEDED 43 /* check whether the MTU + * was exceed in the + * previous write + * operation */ + +#define BIO_CTRL_DGRAM_SET_PEER 44 /* Destination for the data */ + + +/* modifiers */ +#define BIO_FP_READ 0x02 +#define BIO_FP_WRITE 0x04 +#define BIO_FP_APPEND 0x08 +#define BIO_FP_TEXT 0x10 + +#define BIO_FLAGS_READ 0x01 +#define BIO_FLAGS_WRITE 0x02 +#define BIO_FLAGS_IO_SPECIAL 0x04 +#define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) +#define BIO_FLAGS_SHOULD_RETRY 0x08 +#ifndef BIO_FLAGS_UPLINK +/* "UPLINK" flag denotes file descriptors provided by application. + It defaults to 0, as most platforms don't require UPLINK interface. */ +#define BIO_FLAGS_UPLINK 0 +#endif + +/* Used in BIO_gethostbyname() */ +#define BIO_GHBN_CTRL_HITS 1 +#define BIO_GHBN_CTRL_MISSES 2 +#define BIO_GHBN_CTRL_CACHE_SIZE 3 +#define BIO_GHBN_CTRL_GET_ENTRY 4 +#define BIO_GHBN_CTRL_FLUSH 5 + +/* Mostly used in the SSL BIO */ +/* Not used anymore + * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10 + * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20 + * #define BIO_FLAGS_PROTOCOL_STARTUP 0x40 + */ + +#define BIO_FLAGS_BASE64_NO_NL 0x100 + +/* This is used with memory BIOs: it means we shouldn't free up or change the + * data in any way. + */ +#define BIO_FLAGS_MEM_RDONLY 0x200 + +#define BIO_set_flags(b,f) ((b)->flags|=(f)) +#define BIO_get_flags(b) ((b)->flags) +#define BIO_set_retry_special(b) \ + ((b)->flags|=(BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY)) +#define BIO_set_retry_read(b) \ + ((b)->flags|=(BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)) +#define BIO_set_retry_write(b) \ + ((b)->flags|=(BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY)) + +/* These are normally used internally in BIOs */ +#define BIO_clear_flags(b,f) ((b)->flags&= ~(f)) +#define BIO_clear_retry_flags(b) \ + ((b)->flags&= ~(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) +#define BIO_get_retry_flags(b) \ + ((b)->flags&(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) + +/* These should be used by the application to tell why we should retry */ +#define BIO_should_read(a) ((a)->flags & BIO_FLAGS_READ) +#define BIO_should_write(a) ((a)->flags & BIO_FLAGS_WRITE) +#define BIO_should_io_special(a) ((a)->flags & BIO_FLAGS_IO_SPECIAL) +#define BIO_retry_type(a) ((a)->flags & BIO_FLAGS_RWS) +#define BIO_should_retry(a) ((a)->flags & BIO_FLAGS_SHOULD_RETRY) + +/* The next three are used in conjunction with the + * BIO_should_io_special() condition. After this returns true, + * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO + * stack and return the 'reason' for the special and the offending BIO. + * Given a BIO, BIO_get_retry_reason(bio) will return the code. */ +/* Returned from the SSL bio when the certificate retrieval code had an error */ +#define BIO_RR_SSL_X509_LOOKUP 0x01 +/* Returned from the connect BIO when a connect would have blocked */ +#define BIO_RR_CONNECT 0x02 +/* Returned from the accept BIO when an accept would have blocked */ +#define BIO_RR_ACCEPT 0x03 + +/* These are passed by the BIO callback */ +#define BIO_CB_FREE 0x01 +#define BIO_CB_READ 0x02 +#define BIO_CB_WRITE 0x03 +#define BIO_CB_PUTS 0x04 +#define BIO_CB_GETS 0x05 +#define BIO_CB_CTRL 0x06 + +/* The callback is called before and after the underling operation, + * The BIO_CB_RETURN flag indicates if it is after the call */ +#define BIO_CB_RETURN 0x80 +#define BIO_CB_return(a) ((a)|BIO_CB_RETURN)) +#define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) +#define BIO_cb_post(a) ((a)&BIO_CB_RETURN) + +#define BIO_set_callback(b,cb) ((b)->callback=(cb)) +#define BIO_set_callback_arg(b,arg) ((b)->cb_arg=(char *)(arg)) +#define BIO_get_callback_arg(b) ((b)->cb_arg) +#define BIO_get_callback(b) ((b)->callback) +#define BIO_method_name(b) ((b)->method->name) +#define BIO_method_type(b) ((b)->method->type) + +typedef struct bio_st BIO; + +typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long); + +#ifndef OPENSSL_SYS_WIN16 +typedef struct bio_method_st + { + int type; + const char *name; + int (*bwrite)(BIO *, const char *, int); + int (*bread)(BIO *, char *, int); + int (*bputs)(BIO *, const char *); + int (*bgets)(BIO *, char *, int); + long (*ctrl)(BIO *, int, long, void *); + int (*create)(BIO *); + int (*destroy)(BIO *); + long (*callback_ctrl)(BIO *, int, bio_info_cb *); + } BIO_METHOD; +#else +typedef struct bio_method_st + { + int type; + const char *name; + int (_far *bwrite)(); + int (_far *bread)(); + int (_far *bputs)(); + int (_far *bgets)(); + long (_far *ctrl)(); + int (_far *create)(); + int (_far *destroy)(); + long (_far *callback_ctrl)(); + } BIO_METHOD; +#endif + +struct bio_st + { + BIO_METHOD *method; + /* bio, mode, argp, argi, argl, ret */ + long (*callback)(struct bio_st *,int,const char *,int, long,long); + char *cb_arg; /* first argument for the callback */ + + int init; + int shutdown; + int flags; /* extra storage */ + int retry_reason; + int num; + void *ptr; + struct bio_st *next_bio; /* used by filter BIOs */ + struct bio_st *prev_bio; /* used by filter BIOs */ + int references; + unsigned long num_read; + unsigned long num_write; + + CRYPTO_EX_DATA ex_data; + }; + +DECLARE_STACK_OF(BIO) + +typedef struct bio_f_buffer_ctx_struct + { + /* BIO *bio; */ /* this is now in the BIO struct */ + int ibuf_size; /* how big is the input buffer */ + int obuf_size; /* how big is the output buffer */ + + char *ibuf; /* the char array */ + int ibuf_len; /* how many bytes are in it */ + int ibuf_off; /* write/read offset */ + + char *obuf; /* the char array */ + int obuf_len; /* how many bytes are in it */ + int obuf_off; /* write/read offset */ + } BIO_F_BUFFER_CTX; + +/* connect BIO stuff */ +#define BIO_CONN_S_BEFORE 1 +#define BIO_CONN_S_GET_IP 2 +#define BIO_CONN_S_GET_PORT 3 +#define BIO_CONN_S_CREATE_SOCKET 4 +#define BIO_CONN_S_CONNECT 5 +#define BIO_CONN_S_OK 6 +#define BIO_CONN_S_BLOCKED_CONNECT 7 +#define BIO_CONN_S_NBIO 8 +/*#define BIO_CONN_get_param_hostname BIO_ctrl */ + +#define BIO_C_SET_CONNECT 100 +#define BIO_C_DO_STATE_MACHINE 101 +#define BIO_C_SET_NBIO 102 +#define BIO_C_SET_PROXY_PARAM 103 +#define BIO_C_SET_FD 104 +#define BIO_C_GET_FD 105 +#define BIO_C_SET_FILE_PTR 106 +#define BIO_C_GET_FILE_PTR 107 +#define BIO_C_SET_FILENAME 108 +#define BIO_C_SET_SSL 109 +#define BIO_C_GET_SSL 110 +#define BIO_C_SET_MD 111 +#define BIO_C_GET_MD 112 +#define BIO_C_GET_CIPHER_STATUS 113 +#define BIO_C_SET_BUF_MEM 114 +#define BIO_C_GET_BUF_MEM_PTR 115 +#define BIO_C_GET_BUFF_NUM_LINES 116 +#define BIO_C_SET_BUFF_SIZE 117 +#define BIO_C_SET_ACCEPT 118 +#define BIO_C_SSL_MODE 119 +#define BIO_C_GET_MD_CTX 120 +#define BIO_C_GET_PROXY_PARAM 121 +#define BIO_C_SET_BUFF_READ_DATA 122 /* data to read first */ +#define BIO_C_GET_CONNECT 123 +#define BIO_C_GET_ACCEPT 124 +#define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 +#define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 +#define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 +#define BIO_C_FILE_SEEK 128 +#define BIO_C_GET_CIPHER_CTX 129 +#define BIO_C_SET_BUF_MEM_EOF_RETURN 130/*return end of input value*/ +#define BIO_C_SET_BIND_MODE 131 +#define BIO_C_GET_BIND_MODE 132 +#define BIO_C_FILE_TELL 133 +#define BIO_C_GET_SOCKS 134 +#define BIO_C_SET_SOCKS 135 + +#define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */ +#define BIO_C_GET_WRITE_BUF_SIZE 137 +#define BIO_C_MAKE_BIO_PAIR 138 +#define BIO_C_DESTROY_BIO_PAIR 139 +#define BIO_C_GET_WRITE_GUARANTEE 140 +#define BIO_C_GET_READ_REQUEST 141 +#define BIO_C_SHUTDOWN_WR 142 +#define BIO_C_NREAD0 143 +#define BIO_C_NREAD 144 +#define BIO_C_NWRITE0 145 +#define BIO_C_NWRITE 146 +#define BIO_C_RESET_READ_REQUEST 147 + + +#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg) +#define BIO_get_app_data(s) BIO_get_ex_data(s,0) + +/* BIO_s_connect() and BIO_s_socks4a_connect() */ +#define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name) +#define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port) +#define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip) +#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port) +#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) +#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) +#define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2) +#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3) + + +#define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) + +/* BIO_s_accept_socket() */ +#define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name) +#define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0) +/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */ +#define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL) +#define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio) + +#define BIO_BIND_NORMAL 0 +#define BIO_BIND_REUSEADDR_IF_UNUSED 1 +#define BIO_BIND_REUSEADDR 2 +#define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) +#define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) + +#define BIO_do_connect(b) BIO_do_handshake(b) +#define BIO_do_accept(b) BIO_do_handshake(b) +#define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) + +/* BIO_s_proxy_client() */ +#define BIO_set_url(b,url) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url)) +#define BIO_set_proxies(b,p) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p)) +/* BIO_set_nbio(b,n) */ +#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s)) +/* BIO *BIO_get_filter_bio(BIO *bio); */ +#define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)())) +#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk) +#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool) + +#define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp) +#define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p)) +#define BIO_get_url(b,url) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url)) +#define BIO_get_no_connect_return(b) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL) + +#define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) +#define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c) + +#define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp) +#define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp) + +#define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL) +#define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL) + +/* name is cast to lose const, but might be better to route through a function + so we can do it safely */ +#ifdef CONST_STRICT +/* If you are wondering why this isn't defined, its because CONST_STRICT is + * purely a compile-time kludge to allow const to be checked. + */ +int BIO_read_filename(BIO *b,const char *name); +#else +#define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_READ,(char *)name) +#endif +#define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_WRITE,name) +#define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_APPEND,name) +#define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name) + +/* WARNING WARNING, this ups the reference count on the read bio of the + * SSL structure. This is because the ssl read BIO is now pointed to by + * the next_bio field in the bio. So when you free the BIO, make sure + * you are doing a BIO_free_all() to catch the underlying BIO. */ +#define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl) +#define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp) +#define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL) +#define BIO_set_ssl_renegotiate_bytes(b,num) \ + BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL); +#define BIO_get_num_renegotiates(b) \ + BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL); +#define BIO_set_ssl_renegotiate_timeout(b,seconds) \ + BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL); + +/* defined in evp.h */ +/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */ + +#define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp) +#define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm) +#define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp) +#define BIO_set_mem_eof_return(b,v) \ + BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL) + +/* For the BIO_f_buffer() type */ +#define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) +#define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL) +#define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0) +#define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1) +#define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf) + +/* Don't use the next one unless you know what you are doing :-) */ +#define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret)) + +#define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL) +#define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL) +#define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL) +#define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL) +#define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) +#define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL) +/* ...pending macros have inappropriate return type */ +size_t BIO_ctrl_pending(BIO *b); +size_t BIO_ctrl_wpending(BIO *b); +#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) +#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \ + cbp) +#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb) + +/* For the BIO_f_buffer() type */ +#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) + +/* For BIO_s_bio() */ +#define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL) +#define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL) +#define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2) +#define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL) +#define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL) +/* macros with inappropriate type -- but ...pending macros use int too: */ +#define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL) +#define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) +size_t BIO_ctrl_get_write_guarantee(BIO *b); +size_t BIO_ctrl_get_read_request(BIO *b); +int BIO_ctrl_reset_read_request(BIO *b); + +/* ctrl macros for dgram */ +#define BIO_ctrl_dgram_connect(b,peer) \ + (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer) +#define BIO_ctrl_set_connected(b, state, peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer) +#define BIO_dgram_recv_timedout(b) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) +#define BIO_dgram_send_timedout(b) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) +#define BIO_dgram_set_peer(b,peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer) + +/* These two aren't currently implemented */ +/* int BIO_get_ex_num(BIO *bio); */ +/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */ +int BIO_set_ex_data(BIO *bio,int idx,void *data); +void *BIO_get_ex_data(BIO *bio,int idx); +int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +unsigned long BIO_number_read(BIO *bio); +unsigned long BIO_number_written(BIO *bio); + +# ifndef OPENSSL_NO_FP_API +# if defined(OPENSSL_SYS_WIN16) && defined(_WINDLL) +BIO_METHOD *BIO_s_file_internal(void); +BIO *BIO_new_file_internal(char *filename, char *mode); +BIO *BIO_new_fp_internal(FILE *stream, int close_flag); +# define BIO_s_file BIO_s_file_internal +# define BIO_new_file BIO_new_file_internal +# define BIO_new_fp BIO_new_fp_internal +# else /* FP_API */ +BIO_METHOD *BIO_s_file(void ); +BIO *BIO_new_file(const char *filename, const char *mode); +BIO *BIO_new_fp(FILE *stream, int close_flag); +# define BIO_s_file_internal BIO_s_file +# define BIO_new_file_internal BIO_new_file +# define BIO_new_fp_internal BIO_s_file +# endif /* FP_API */ +# endif +BIO * BIO_new(BIO_METHOD *type); +int BIO_set(BIO *a,BIO_METHOD *type); +int BIO_free(BIO *a); +void BIO_vfree(BIO *a); +int BIO_read(BIO *b, void *data, int len); +int BIO_gets(BIO *bp,char *buf, int size); +int BIO_write(BIO *b, const void *data, int len); +int BIO_puts(BIO *bp,const char *buf); +int BIO_indent(BIO *b,int indent,int max); +long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); +long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long)); +char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); +long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg); +BIO * BIO_push(BIO *b,BIO *append); +BIO * BIO_pop(BIO *b); +void BIO_free_all(BIO *a); +BIO * BIO_find_type(BIO *b,int bio_type); +BIO * BIO_next(BIO *b); +BIO * BIO_get_retry_BIO(BIO *bio, int *reason); +int BIO_get_retry_reason(BIO *bio); +BIO * BIO_dup_chain(BIO *in); + +int BIO_nread0(BIO *bio, char **buf); +int BIO_nread(BIO *bio, char **buf, int num); +int BIO_nwrite0(BIO *bio, char **buf); +int BIO_nwrite(BIO *bio, char **buf, int num); + +#ifndef OPENSSL_SYS_WIN16 +long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, + long argl,long ret); +#else +long _far _loadds BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, + long argl,long ret); +#endif + +BIO_METHOD *BIO_s_mem(void); +BIO *BIO_new_mem_buf(void *buf, int len); +BIO_METHOD *BIO_s_socket(void); +BIO_METHOD *BIO_s_connect(void); +BIO_METHOD *BIO_s_accept(void); +BIO_METHOD *BIO_s_fd(void); +#ifndef OPENSSL_SYS_OS2 +BIO_METHOD *BIO_s_log(void); +#endif +BIO_METHOD *BIO_s_bio(void); +BIO_METHOD *BIO_s_null(void); +BIO_METHOD *BIO_f_null(void); +BIO_METHOD *BIO_f_buffer(void); +#ifdef OPENSSL_SYS_VMS +BIO_METHOD *BIO_f_linebuffer(void); +#endif +BIO_METHOD *BIO_f_nbio_test(void); +#ifndef OPENSSL_NO_DGRAM +BIO_METHOD *BIO_s_datagram(void); +#endif + +/* BIO_METHOD *BIO_f_ber(void); */ + +int BIO_sock_should_retry(int i); +int BIO_sock_non_fatal_error(int error); +int BIO_dgram_non_fatal_error(int error); + +int BIO_fd_should_retry(int i); +int BIO_fd_non_fatal_error(int error); +int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u), + void *u, const char *s, int len); +int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), + void *u, const char *s, int len, int indent); +int BIO_dump(BIO *b,const char *bytes,int len); +int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent); +#ifndef OPENSSL_NO_FP_API +int BIO_dump_fp(FILE *fp, const char *s, int len); +int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent); +#endif +struct hostent *BIO_gethostbyname(const char *name); +/* We might want a thread-safe interface too: + * struct hostent *BIO_gethostbyname_r(const char *name, + * struct hostent *result, void *buffer, size_t buflen); + * or something similar (caller allocates a struct hostent, + * pointed to by "result", and additional buffer space for the various + * substructures; if the buffer does not suffice, NULL is returned + * and an appropriate error code is set). + */ +int BIO_sock_error(int sock); +int BIO_socket_ioctl(int fd, long type, void *arg); +int BIO_socket_nbio(int fd,int mode); +int BIO_get_port(const char *str, unsigned short *port_ptr); +int BIO_get_host_ip(const char *str, unsigned char *ip); +int BIO_get_accept_socket(char *host_port,int mode); +int BIO_accept(int sock,char **ip_port); +int BIO_sock_init(void ); +void BIO_sock_cleanup(void); +int BIO_set_tcp_ndelay(int sock,int turn_on); + +BIO *BIO_new_socket(int sock, int close_flag); +BIO *BIO_new_dgram(int fd, int close_flag); +BIO *BIO_new_fd(int fd, int close_flag); +BIO *BIO_new_connect(char *host_port); +BIO *BIO_new_accept(char *host_port); + +int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, + BIO **bio2, size_t writebuf2); +/* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints. + * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. + * Size 0 uses default value. + */ + +void BIO_copy_next_retry(BIO *b); + +/*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/ + +#ifdef __GNUC__ +# define __bio_h__attr__ __attribute__ +#else +# define __bio_h__attr__(x) +#endif +int BIO_printf(BIO *bio, const char *format, ...) + __bio_h__attr__((__format__(__printf__,2,3))); +int BIO_vprintf(BIO *bio, const char *format, va_list args) + __bio_h__attr__((__format__(__printf__,2,0))); +int BIO_snprintf(char *buf, size_t n, const char *format, ...) + __bio_h__attr__((__format__(__printf__,3,4))); +int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) + __bio_h__attr__((__format__(__printf__,3,0))); +#undef __bio_h__attr__ + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_BIO_strings(void); + +/* Error codes for the BIO functions. */ + +/* Function codes. */ +#define BIO_F_ACPT_STATE 100 +#define BIO_F_BIO_ACCEPT 101 +#define BIO_F_BIO_BER_GET_HEADER 102 +#define BIO_F_BIO_CALLBACK_CTRL 131 +#define BIO_F_BIO_CTRL 103 +#define BIO_F_BIO_GETHOSTBYNAME 120 +#define BIO_F_BIO_GETS 104 +#define BIO_F_BIO_GET_ACCEPT_SOCKET 105 +#define BIO_F_BIO_GET_HOST_IP 106 +#define BIO_F_BIO_GET_PORT 107 +#define BIO_F_BIO_MAKE_PAIR 121 +#define BIO_F_BIO_NEW 108 +#define BIO_F_BIO_NEW_FILE 109 +#define BIO_F_BIO_NEW_MEM_BUF 126 +#define BIO_F_BIO_NREAD 123 +#define BIO_F_BIO_NREAD0 124 +#define BIO_F_BIO_NWRITE 125 +#define BIO_F_BIO_NWRITE0 122 +#define BIO_F_BIO_PUTS 110 +#define BIO_F_BIO_READ 111 +#define BIO_F_BIO_SOCK_INIT 112 +#define BIO_F_BIO_WRITE 113 +#define BIO_F_BUFFER_CTRL 114 +#define BIO_F_CONN_CTRL 127 +#define BIO_F_CONN_STATE 115 +#define BIO_F_FILE_CTRL 116 +#define BIO_F_FILE_READ 130 +#define BIO_F_LINEBUFFER_CTRL 129 +#define BIO_F_MEM_READ 128 +#define BIO_F_MEM_WRITE 117 +#define BIO_F_SSL_NEW 118 +#define BIO_F_WSASTARTUP 119 + +/* Reason codes. */ +#define BIO_R_ACCEPT_ERROR 100 +#define BIO_R_BAD_FOPEN_MODE 101 +#define BIO_R_BAD_HOSTNAME_LOOKUP 102 +#define BIO_R_BROKEN_PIPE 124 +#define BIO_R_CONNECT_ERROR 103 +#define BIO_R_EOF_ON_MEMORY_BIO 127 +#define BIO_R_ERROR_SETTING_NBIO 104 +#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105 +#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106 +#define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 +#define BIO_R_INVALID_ARGUMENT 125 +#define BIO_R_INVALID_IP_ADDRESS 108 +#define BIO_R_IN_USE 123 +#define BIO_R_KEEPALIVE 109 +#define BIO_R_NBIO_CONNECT_ERROR 110 +#define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 +#define BIO_R_NO_HOSTNAME_SPECIFIED 112 +#define BIO_R_NO_PORT_DEFINED 113 +#define BIO_R_NO_PORT_SPECIFIED 114 +#define BIO_R_NO_SUCH_FILE 128 +#define BIO_R_NULL_PARAMETER 115 +#define BIO_R_TAG_MISMATCH 116 +#define BIO_R_UNABLE_TO_BIND_SOCKET 117 +#define BIO_R_UNABLE_TO_CREATE_SOCKET 118 +#define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 +#define BIO_R_UNINITIALIZED 120 +#define BIO_R_UNSUPPORTED_METHOD 121 +#define BIO_R_WRITE_TO_READ_ONLY_BIO 126 +#define BIO_R_WSASTARTUP 122 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/blowfish.h b/src/dep/include/openssl/blowfish.h index 714264d..c5f6500 100644 --- a/src/dep/include/openssl/blowfish.h +++ b/src/dep/include/openssl/blowfish.h @@ -1,127 +1,127 @@ -/* crypto/bf/blowfish.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_BLOWFISH_H -#define HEADER_BLOWFISH_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef OPENSSL_NO_BF -#error BF is disabled. -#endif - -#define BF_ENCRYPT 1 -#define BF_DECRYPT 0 - -/* - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * ! BF_LONG has to be at least 32 bits wide. If it's wider, then ! - * ! BF_LONG_LOG2 has to be defined along. ! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - */ - -#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) -#define BF_LONG unsigned long -#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) -#define BF_LONG unsigned long -#define BF_LONG_LOG2 3 -/* - * _CRAY note. I could declare short, but I have no idea what impact - * does it have on performance on none-T3E machines. I could declare - * int, but at least on C90 sizeof(int) can be chosen at compile time. - * So I've chosen long... - * - */ -#else -#define BF_LONG unsigned int -#endif - -#define BF_ROUNDS 16 -#define BF_BLOCK 8 - -typedef struct bf_key_st - { - BF_LONG P[BF_ROUNDS+2]; - BF_LONG S[4*256]; - } BF_KEY; - - -void BF_set_key(BF_KEY *key, int len, const unsigned char *data); - -void BF_encrypt(BF_LONG *data,const BF_KEY *key); -void BF_decrypt(BF_LONG *data,const BF_KEY *key); - -void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, - const BF_KEY *key, int enc); -void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, - const BF_KEY *schedule, unsigned char *ivec, int enc); -void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, - const BF_KEY *schedule, unsigned char *ivec, int *num, int enc); -void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, - const BF_KEY *schedule, unsigned char *ivec, int *num); -const char *BF_options(void); - -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/bf/blowfish.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BLOWFISH_H +#define HEADER_BLOWFISH_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_BF +#error BF is disabled. +#endif + +#define BF_ENCRYPT 1 +#define BF_DECRYPT 0 + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! BF_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! BF_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define BF_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define BF_LONG unsigned long +#define BF_LONG_LOG2 3 +/* + * _CRAY note. I could declare short, but I have no idea what impact + * does it have on performance on none-T3E machines. I could declare + * int, but at least on C90 sizeof(int) can be chosen at compile time. + * So I've chosen long... + * + */ +#else +#define BF_LONG unsigned int +#endif + +#define BF_ROUNDS 16 +#define BF_BLOCK 8 + +typedef struct bf_key_st + { + BF_LONG P[BF_ROUNDS+2]; + BF_LONG S[4*256]; + } BF_KEY; + + +void BF_set_key(BF_KEY *key, int len, const unsigned char *data); + +void BF_encrypt(BF_LONG *data,const BF_KEY *key); +void BF_decrypt(BF_LONG *data,const BF_KEY *key); + +void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, + const BF_KEY *key, int enc); +void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int enc); +void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int *num, int enc); +void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int *num); +const char *BF_options(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/bn.h b/src/dep/include/openssl/bn.h index f67bf60..5d7afc3 100644 --- a/src/dep/include/openssl/bn.h +++ b/src/dep/include/openssl/bn.h @@ -1,827 +1,827 @@ -/* crypto/bn/bn.h */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * - * Portions of the attached software ("Contribution") are developed by - * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. - * - * The Contribution is licensed pursuant to the Eric Young open source - * license provided above. - * - * The binary polynomial arithmetic software is originally written by - * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. - * - */ - -#ifndef HEADER_BN_H -#define HEADER_BN_H - -#include -#ifndef OPENSSL_NO_FP_API -#include /* FILE */ -#endif -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* These preprocessor symbols control various aspects of the bignum headers and - * library code. They're not defined by any "normal" configuration, as they are - * intended for development and testing purposes. NB: defining all three can be - * useful for debugging application code as well as openssl itself. - * - * BN_DEBUG - turn on various debugging alterations to the bignum code - * BN_DEBUG_RAND - uses random poisoning of unused words to trip up - * mismanagement of bignum internals. You must also define BN_DEBUG. - */ -/* #define BN_DEBUG */ -/* #define BN_DEBUG_RAND */ - -#define BN_MUL_COMBA -#define BN_SQR_COMBA -#define BN_RECURSION - -/* This next option uses the C libraries (2 word)/(1 word) function. - * If it is not defined, I use my C version (which is slower). - * The reason for this flag is that when the particular C compiler - * library routine is used, and the library is linked with a different - * compiler, the library is missing. This mostly happens when the - * library is built with gcc and then linked using normal cc. This would - * be a common occurrence because gcc normally produces code that is - * 2 times faster than system compilers for the big number stuff. - * For machines with only one compiler (or shared libraries), this should - * be on. Again this in only really a problem on machines - * using "long long's", are 32bit, and are not using my assembler code. */ -#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \ - defined(OPENSSL_SYS_WIN32) || defined(linux) -# ifndef BN_DIV2W -# define BN_DIV2W -# endif -#endif - -/* assuming long is 64bit - this is the DEC Alpha - * unsigned long long is only 64 bits :-(, don't define - * BN_LLONG for the DEC Alpha */ -#ifdef SIXTY_FOUR_BIT_LONG -#define BN_ULLONG unsigned long long -#define BN_ULONG unsigned long -#define BN_LONG long -#define BN_BITS 128 -#define BN_BYTES 8 -#define BN_BITS2 64 -#define BN_BITS4 32 -#define BN_MASK (0xffffffffffffffffffffffffffffffffLL) -#define BN_MASK2 (0xffffffffffffffffL) -#define BN_MASK2l (0xffffffffL) -#define BN_MASK2h (0xffffffff00000000L) -#define BN_MASK2h1 (0xffffffff80000000L) -#define BN_TBIT (0x8000000000000000L) -#define BN_DEC_CONV (10000000000000000000UL) -#define BN_DEC_FMT1 "%lu" -#define BN_DEC_FMT2 "%019lu" -#define BN_DEC_NUM 19 -#endif - -/* This is where the long long data type is 64 bits, but long is 32. - * For machines where there are 64bit registers, this is the mode to use. - * IRIX, on R4000 and above should use this mode, along with the relevant - * assembler code :-). Do NOT define BN_LLONG. - */ -#ifdef SIXTY_FOUR_BIT -#undef BN_LLONG -#undef BN_ULLONG -#define BN_ULONG unsigned long long -#define BN_LONG long long -#define BN_BITS 128 -#define BN_BYTES 8 -#define BN_BITS2 64 -#define BN_BITS4 32 -#define BN_MASK2 (0xffffffffffffffffLL) -#define BN_MASK2l (0xffffffffL) -#define BN_MASK2h (0xffffffff00000000LL) -#define BN_MASK2h1 (0xffffffff80000000LL) -#define BN_TBIT (0x8000000000000000LL) -#define BN_DEC_CONV (10000000000000000000ULL) -#define BN_DEC_FMT1 "%llu" -#define BN_DEC_FMT2 "%019llu" -#define BN_DEC_NUM 19 -#endif - -#ifdef THIRTY_TWO_BIT -#ifdef BN_LLONG -# if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) -# define BN_ULLONG unsigned __int64 -# else -# define BN_ULLONG unsigned long long -# endif -#endif -#define BN_ULONG unsigned long -#define BN_LONG long -#define BN_BITS 64 -#define BN_BYTES 4 -#define BN_BITS2 32 -#define BN_BITS4 16 -#ifdef OPENSSL_SYS_WIN32 -/* VC++ doesn't like the LL suffix */ -#define BN_MASK (0xffffffffffffffffL) -#else -#define BN_MASK (0xffffffffffffffffLL) -#endif -#define BN_MASK2 (0xffffffffL) -#define BN_MASK2l (0xffff) -#define BN_MASK2h1 (0xffff8000L) -#define BN_MASK2h (0xffff0000L) -#define BN_TBIT (0x80000000L) -#define BN_DEC_CONV (1000000000L) -#define BN_DEC_FMT1 "%lu" -#define BN_DEC_FMT2 "%09lu" -#define BN_DEC_NUM 9 -#endif - -#ifdef SIXTEEN_BIT -#ifndef BN_DIV2W -#define BN_DIV2W -#endif -#define BN_ULLONG unsigned long -#define BN_ULONG unsigned short -#define BN_LONG short -#define BN_BITS 32 -#define BN_BYTES 2 -#define BN_BITS2 16 -#define BN_BITS4 8 -#define BN_MASK (0xffffffff) -#define BN_MASK2 (0xffff) -#define BN_MASK2l (0xff) -#define BN_MASK2h1 (0xff80) -#define BN_MASK2h (0xff00) -#define BN_TBIT (0x8000) -#define BN_DEC_CONV (100000) -#define BN_DEC_FMT1 "%u" -#define BN_DEC_FMT2 "%05u" -#define BN_DEC_NUM 5 -#endif - -#ifdef EIGHT_BIT -#ifndef BN_DIV2W -#define BN_DIV2W -#endif -#define BN_ULLONG unsigned short -#define BN_ULONG unsigned char -#define BN_LONG char -#define BN_BITS 16 -#define BN_BYTES 1 -#define BN_BITS2 8 -#define BN_BITS4 4 -#define BN_MASK (0xffff) -#define BN_MASK2 (0xff) -#define BN_MASK2l (0xf) -#define BN_MASK2h1 (0xf8) -#define BN_MASK2h (0xf0) -#define BN_TBIT (0x80) -#define BN_DEC_CONV (100) -#define BN_DEC_FMT1 "%u" -#define BN_DEC_FMT2 "%02u" -#define BN_DEC_NUM 2 -#endif - -#define BN_DEFAULT_BITS 1280 - -#define BN_FLG_MALLOCED 0x01 -#define BN_FLG_STATIC_DATA 0x02 -#define BN_FLG_EXP_CONSTTIME 0x04 /* avoid leaking exponent information through timings - * (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime) */ -#ifndef OPENSSL_NO_DEPRECATED -#define BN_FLG_FREE 0x8000 /* used for debuging */ -#endif -#define BN_set_flags(b,n) ((b)->flags|=(n)) -#define BN_get_flags(b,n) ((b)->flags&(n)) - -/* get a clone of a BIGNUM with changed flags, for *temporary* use only - * (the two BIGNUMs cannot not be used in parallel!) */ -#define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \ - (dest)->top=(b)->top, \ - (dest)->dmax=(b)->dmax, \ - (dest)->neg=(b)->neg, \ - (dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \ - | ((b)->flags & ~BN_FLG_MALLOCED) \ - | BN_FLG_STATIC_DATA \ - | (n))) - -/* Already declared in ossl_typ.h */ -#if 0 -typedef struct bignum_st BIGNUM; -/* Used for temp variables (declaration hidden in bn_lcl.h) */ -typedef struct bignum_ctx BN_CTX; -typedef struct bn_blinding_st BN_BLINDING; -typedef struct bn_mont_ctx_st BN_MONT_CTX; -typedef struct bn_recp_ctx_st BN_RECP_CTX; -typedef struct bn_gencb_st BN_GENCB; -#endif - -struct bignum_st - { - BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ - int top; /* Index of last used d +1. */ - /* The next are internal book keeping for bn_expand. */ - int dmax; /* Size of the d array. */ - int neg; /* one if the number is negative */ - int flags; - }; - -/* Used for montgomery multiplication */ -struct bn_mont_ctx_st - { - int ri; /* number of bits in R */ - BIGNUM RR; /* used to convert to montgomery form */ - BIGNUM N; /* The modulus */ - BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 - * (Ni is only stored for bignum algorithm) */ - BN_ULONG n0; /* least significant word of Ni */ - int flags; - }; - -/* Used for reciprocal division/mod functions - * It cannot be shared between threads - */ -struct bn_recp_ctx_st - { - BIGNUM N; /* the divisor */ - BIGNUM Nr; /* the reciprocal */ - int num_bits; - int shift; - int flags; - }; - -/* Used for slow "generation" functions. */ -struct bn_gencb_st - { - unsigned int ver; /* To handle binary (in)compatibility */ - void *arg; /* callback-specific data */ - union - { - /* if(ver==1) - handles old style callbacks */ - void (*cb_1)(int, int, void *); - /* if(ver==2) - new callback style */ - int (*cb_2)(int, int, BN_GENCB *); - } cb; - }; -/* Wrapper function to make using BN_GENCB easier, */ -int BN_GENCB_call(BN_GENCB *cb, int a, int b); -/* Macro to populate a BN_GENCB structure with an "old"-style callback */ -#define BN_GENCB_set_old(gencb, callback, cb_arg) { \ - BN_GENCB *tmp_gencb = (gencb); \ - tmp_gencb->ver = 1; \ - tmp_gencb->arg = (cb_arg); \ - tmp_gencb->cb.cb_1 = (callback); } -/* Macro to populate a BN_GENCB structure with a "new"-style callback */ -#define BN_GENCB_set(gencb, callback, cb_arg) { \ - BN_GENCB *tmp_gencb = (gencb); \ - tmp_gencb->ver = 2; \ - tmp_gencb->arg = (cb_arg); \ - tmp_gencb->cb.cb_2 = (callback); } - -#define BN_prime_checks 0 /* default: select number of iterations - based on the size of the number */ - -/* number of Miller-Rabin iterations for an error rate of less than 2^-80 - * for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook - * of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996]; - * original paper: Damgaard, Landrock, Pomerance: Average case error estimates - * for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */ -#define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \ - (b) >= 850 ? 3 : \ - (b) >= 650 ? 4 : \ - (b) >= 550 ? 5 : \ - (b) >= 450 ? 6 : \ - (b) >= 400 ? 7 : \ - (b) >= 350 ? 8 : \ - (b) >= 300 ? 9 : \ - (b) >= 250 ? 12 : \ - (b) >= 200 ? 15 : \ - (b) >= 150 ? 18 : \ - /* b >= 100 */ 27) - -#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) - -/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */ -#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \ - (((w) == 0) && ((a)->top == 0))) -#define BN_is_zero(a) ((a)->top == 0) -#define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg) -#define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg)) -#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1)) - -#define BN_one(a) (BN_set_word((a),1)) -#define BN_zero_ex(a) \ - do { \ - BIGNUM *_tmp_bn = (a); \ - _tmp_bn->top = 0; \ - _tmp_bn->neg = 0; \ - } while(0) -#ifdef OPENSSL_NO_DEPRECATED -#define BN_zero(a) BN_zero_ex(a) -#else -#define BN_zero(a) (BN_set_word((a),0)) -#endif - -const BIGNUM *BN_value_one(void); -char * BN_options(void); -BN_CTX *BN_CTX_new(void); -#ifndef OPENSSL_NO_DEPRECATED -void BN_CTX_init(BN_CTX *c); -#endif -void BN_CTX_free(BN_CTX *c); -void BN_CTX_start(BN_CTX *ctx); -BIGNUM *BN_CTX_get(BN_CTX *ctx); -void BN_CTX_end(BN_CTX *ctx); -int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); -int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom); -int BN_rand_range(BIGNUM *rnd, BIGNUM *range); -int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range); -int BN_num_bits(const BIGNUM *a); -int BN_num_bits_word(BN_ULONG); -BIGNUM *BN_new(void); -void BN_init(BIGNUM *); -void BN_clear_free(BIGNUM *a); -BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); -void BN_swap(BIGNUM *a, BIGNUM *b); -BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret); -int BN_bn2bin(const BIGNUM *a, unsigned char *to); -BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret); -int BN_bn2mpi(const BIGNUM *a, unsigned char *to); -int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); -int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx); -/** BN_set_negative sets sign of a BIGNUM - * \param b pointer to the BIGNUM object - * \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise - */ -void BN_set_negative(BIGNUM *b, int n); -/** BN_is_negative returns 1 if the BIGNUM is negative - * \param a pointer to the BIGNUM object - * \return 1 if a < 0 and 0 otherwise - */ -#define BN_is_negative(a) ((a)->neg != 0) - -int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, - BN_CTX *ctx); -#define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx)) -int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); -int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); -int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); -int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); -int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); -int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *m, BN_CTX *ctx); -int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); -int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); -int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); -int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx); -int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m); - -BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); -BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); -int BN_mul_word(BIGNUM *a, BN_ULONG w); -int BN_add_word(BIGNUM *a, BN_ULONG w); -int BN_sub_word(BIGNUM *a, BN_ULONG w); -int BN_set_word(BIGNUM *a, BN_ULONG w); -BN_ULONG BN_get_word(const BIGNUM *a); - -int BN_cmp(const BIGNUM *a, const BIGNUM *b); -void BN_free(BIGNUM *a); -int BN_is_bit_set(const BIGNUM *a, int n); -int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); -int BN_lshift1(BIGNUM *r, const BIGNUM *a); -int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx); - -int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m,BN_CTX *ctx); -int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont); -int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, - const BIGNUM *a2, const BIGNUM *p2,const BIGNUM *m, - BN_CTX *ctx,BN_MONT_CTX *m_ctx); -int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m,BN_CTX *ctx); - -int BN_mask_bits(BIGNUM *a,int n); -#ifndef OPENSSL_NO_FP_API -int BN_print_fp(FILE *fp, const BIGNUM *a); -#endif -#ifdef HEADER_BIO_H -int BN_print(BIO *fp, const BIGNUM *a); -#else -int BN_print(void *fp, const BIGNUM *a); -#endif -int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx); -int BN_rshift(BIGNUM *r, const BIGNUM *a, int n); -int BN_rshift1(BIGNUM *r, const BIGNUM *a); -void BN_clear(BIGNUM *a); -BIGNUM *BN_dup(const BIGNUM *a); -int BN_ucmp(const BIGNUM *a, const BIGNUM *b); -int BN_set_bit(BIGNUM *a, int n); -int BN_clear_bit(BIGNUM *a, int n); -char * BN_bn2hex(const BIGNUM *a); -char * BN_bn2dec(const BIGNUM *a); -int BN_hex2bn(BIGNUM **a, const char *str); -int BN_dec2bn(BIGNUM **a, const char *str); -int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); -int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */ -BIGNUM *BN_mod_inverse(BIGNUM *ret, - const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); -BIGNUM *BN_mod_sqrt(BIGNUM *ret, - const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); - -/* Deprecated versions */ -#ifndef OPENSSL_NO_DEPRECATED -BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe, - const BIGNUM *add, const BIGNUM *rem, - void (*callback)(int,int,void *),void *cb_arg); -int BN_is_prime(const BIGNUM *p,int nchecks, - void (*callback)(int,int,void *), - BN_CTX *ctx,void *cb_arg); -int BN_is_prime_fasttest(const BIGNUM *p,int nchecks, - void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg, - int do_trial_division); -#endif /* !defined(OPENSSL_NO_DEPRECATED) */ - -/* Newer versions */ -int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add, - const BIGNUM *rem, BN_GENCB *cb); -int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb); -int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, - int do_trial_division, BN_GENCB *cb); - -BN_MONT_CTX *BN_MONT_CTX_new(void ); -void BN_MONT_CTX_init(BN_MONT_CTX *ctx); -int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b, - BN_MONT_CTX *mont, BN_CTX *ctx); -#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ - (r),(a),&((mont)->RR),(mont),(ctx)) -int BN_from_montgomery(BIGNUM *r,const BIGNUM *a, - BN_MONT_CTX *mont, BN_CTX *ctx); -void BN_MONT_CTX_free(BN_MONT_CTX *mont); -int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *mod,BN_CTX *ctx); -BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from); -BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock, - const BIGNUM *mod, BN_CTX *ctx); - -/* BN_BLINDING flags */ -#define BN_BLINDING_NO_UPDATE 0x00000001 -#define BN_BLINDING_NO_RECREATE 0x00000002 - -BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod); -void BN_BLINDING_free(BN_BLINDING *b); -int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); -int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); -int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); -int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); -int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); -unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *); -void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long); -unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); -void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); -BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, - const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, - int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), - BN_MONT_CTX *m_ctx); - -#ifndef OPENSSL_NO_DEPRECATED -void BN_set_params(int mul,int high,int low,int mont); -int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */ -#endif - -void BN_RECP_CTX_init(BN_RECP_CTX *recp); -BN_RECP_CTX *BN_RECP_CTX_new(void); -void BN_RECP_CTX_free(BN_RECP_CTX *recp); -int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx); -int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, - BN_RECP_CTX *recp,BN_CTX *ctx); -int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); -int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, - BN_RECP_CTX *recp, BN_CTX *ctx); - -/* Functions for arithmetic over binary polynomials represented by BIGNUMs. - * - * The BIGNUM::neg property of BIGNUMs representing binary polynomials is - * ignored. - * - * Note that input arguments are not const so that their bit arrays can - * be expanded to the appropriate size if needed. - */ - -int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); /*r = a + b*/ -#define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b) -int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); /*r=a mod p*/ -int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *p, BN_CTX *ctx); /* r = (a * b) mod p */ -int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - BN_CTX *ctx); /* r = (a * a) mod p */ -int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, - BN_CTX *ctx); /* r = (1 / b) mod p */ -int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *p, BN_CTX *ctx); /* r = (a / b) mod p */ -int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *p, BN_CTX *ctx); /* r = (a ^ b) mod p */ -int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - BN_CTX *ctx); /* r = sqrt(a) mod p */ -int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - BN_CTX *ctx); /* r^2 + r = a mod p */ -#define BN_GF2m_cmp(a, b) BN_ucmp((a), (b)) -/* Some functions allow for representation of the irreducible polynomials - * as an unsigned int[], say p. The irreducible f(t) is then of the form: - * t^p[0] + t^p[1] + ... + t^p[k] - * where m = p[0] > p[1] > ... > p[k] = 0. - */ -int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[]); - /* r = a mod p */ -int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const unsigned int p[], BN_CTX *ctx); /* r = (a * b) mod p */ -int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[], - BN_CTX *ctx); /* r = (a * a) mod p */ -int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const unsigned int p[], - BN_CTX *ctx); /* r = (1 / b) mod p */ -int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const unsigned int p[], BN_CTX *ctx); /* r = (a / b) mod p */ -int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const unsigned int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */ -int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, - const unsigned int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */ -int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, - const unsigned int p[], BN_CTX *ctx); /* r^2 + r = a mod p */ -int BN_GF2m_poly2arr(const BIGNUM *a, unsigned int p[], int max); -int BN_GF2m_arr2poly(const unsigned int p[], BIGNUM *a); - -/* faster mod functions for the 'NIST primes' - * 0 <= a < p^2 */ -int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); - -const BIGNUM *BN_get0_nist_prime_192(void); -const BIGNUM *BN_get0_nist_prime_224(void); -const BIGNUM *BN_get0_nist_prime_256(void); -const BIGNUM *BN_get0_nist_prime_384(void); -const BIGNUM *BN_get0_nist_prime_521(void); - -/* library internal functions */ - -#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\ - (a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2)) -#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) -BIGNUM *bn_expand2(BIGNUM *a, int words); -#ifndef OPENSSL_NO_DEPRECATED -BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */ -#endif - -/* Bignum consistency macros - * There is one "API" macro, bn_fix_top(), for stripping leading zeroes from - * bignum data after direct manipulations on the data. There is also an - * "internal" macro, bn_check_top(), for verifying that there are no leading - * zeroes. Unfortunately, some auditing is required due to the fact that - * bn_fix_top() has become an overabused duct-tape because bignum data is - * occasionally passed around in an inconsistent state. So the following - * changes have been made to sort this out; - * - bn_fix_top()s implementation has been moved to bn_correct_top() - * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and - * bn_check_top() is as before. - * - if BN_DEBUG *is* defined; - * - bn_check_top() tries to pollute unused words even if the bignum 'top' is - * consistent. (ed: only if BN_DEBUG_RAND is defined) - * - bn_fix_top() maps to bn_check_top() rather than "fixing" anything. - * The idea is to have debug builds flag up inconsistent bignums when they - * occur. If that occurs in a bn_fix_top(), we examine the code in question; if - * the use of bn_fix_top() was appropriate (ie. it follows directly after code - * that manipulates the bignum) it is converted to bn_correct_top(), and if it - * was not appropriate, we convert it permanently to bn_check_top() and track - * down the cause of the bug. Eventually, no internal code should be using the - * bn_fix_top() macro. External applications and libraries should try this with - * their own code too, both in terms of building against the openssl headers - * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it - * defined. This not only improves external code, it provides more test - * coverage for openssl's own code. - */ - -#ifdef BN_DEBUG - -/* We only need assert() when debugging */ -#include - -#ifdef BN_DEBUG_RAND -/* To avoid "make update" cvs wars due to BN_DEBUG, use some tricks */ -#ifndef RAND_pseudo_bytes -int RAND_pseudo_bytes(unsigned char *buf,int num); -#define BN_DEBUG_TRIX -#endif -#define bn_pollute(a) \ - do { \ - const BIGNUM *_bnum1 = (a); \ - if(_bnum1->top < _bnum1->dmax) { \ - unsigned char _tmp_char; \ - /* We cast away const without the compiler knowing, any \ - * *genuinely* constant variables that aren't mutable \ - * wouldn't be constructed with top!=dmax. */ \ - BN_ULONG *_not_const; \ - memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \ - RAND_pseudo_bytes(&_tmp_char, 1); \ - memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \ - (_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \ - } \ - } while(0) -#ifdef BN_DEBUG_TRIX -#undef RAND_pseudo_bytes -#endif -#else -#define bn_pollute(a) -#endif -#define bn_check_top(a) \ - do { \ - const BIGNUM *_bnum2 = (a); \ - if (_bnum2 != NULL) { \ - assert((_bnum2->top == 0) || \ - (_bnum2->d[_bnum2->top - 1] != 0)); \ - bn_pollute(_bnum2); \ - } \ - } while(0) - -#define bn_fix_top(a) bn_check_top(a) - -#else /* !BN_DEBUG */ - -#define bn_pollute(a) -#define bn_check_top(a) -#define bn_fix_top(a) bn_correct_top(a) - -#endif - -#define bn_correct_top(a) \ - { \ - BN_ULONG *ftl; \ - if ((a)->top > 0) \ - { \ - for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \ - if (*(ftl--)) break; \ - } \ - bn_pollute(a); \ - } - -BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); -BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); -void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num); -BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d); -BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); -BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); - -/* Primes from RFC 2409 */ -BIGNUM *get_rfc2409_prime_768(BIGNUM *bn); -BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn); - -/* Primes from RFC 3526 */ -BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn); -BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn); -BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn); -BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn); -BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn); -BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn); - -int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_BN_strings(void); - -/* Error codes for the BN functions. */ - -/* Function codes. */ -#define BN_F_BNRAND 127 -#define BN_F_BN_BLINDING_CONVERT_EX 100 -#define BN_F_BN_BLINDING_CREATE_PARAM 128 -#define BN_F_BN_BLINDING_INVERT_EX 101 -#define BN_F_BN_BLINDING_NEW 102 -#define BN_F_BN_BLINDING_UPDATE 103 -#define BN_F_BN_BN2DEC 104 -#define BN_F_BN_BN2HEX 105 -#define BN_F_BN_CTX_GET 116 -#define BN_F_BN_CTX_NEW 106 -#define BN_F_BN_CTX_START 129 -#define BN_F_BN_DIV 107 -#define BN_F_BN_DIV_RECP 130 -#define BN_F_BN_EXP 123 -#define BN_F_BN_EXPAND2 108 -#define BN_F_BN_EXPAND_INTERNAL 120 -#define BN_F_BN_GF2M_MOD 131 -#define BN_F_BN_GF2M_MOD_EXP 132 -#define BN_F_BN_GF2M_MOD_MUL 133 -#define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134 -#define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135 -#define BN_F_BN_GF2M_MOD_SQR 136 -#define BN_F_BN_GF2M_MOD_SQRT 137 -#define BN_F_BN_MOD_EXP2_MONT 118 -#define BN_F_BN_MOD_EXP_MONT 109 -#define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124 -#define BN_F_BN_MOD_EXP_MONT_WORD 117 -#define BN_F_BN_MOD_EXP_RECP 125 -#define BN_F_BN_MOD_EXP_SIMPLE 126 -#define BN_F_BN_MOD_INVERSE 110 -#define BN_F_BN_MOD_LSHIFT_QUICK 119 -#define BN_F_BN_MOD_MUL_RECIPROCAL 111 -#define BN_F_BN_MOD_SQRT 121 -#define BN_F_BN_MPI2BN 112 -#define BN_F_BN_NEW 113 -#define BN_F_BN_RAND 114 -#define BN_F_BN_RAND_RANGE 122 -#define BN_F_BN_USUB 115 - -/* Reason codes. */ -#define BN_R_ARG2_LT_ARG3 100 -#define BN_R_BAD_RECIPROCAL 101 -#define BN_R_BIGNUM_TOO_LONG 114 -#define BN_R_CALLED_WITH_EVEN_MODULUS 102 -#define BN_R_DIV_BY_ZERO 103 -#define BN_R_ENCODING_ERROR 104 -#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 -#define BN_R_INPUT_NOT_REDUCED 110 -#define BN_R_INVALID_LENGTH 106 -#define BN_R_INVALID_RANGE 115 -#define BN_R_NOT_A_SQUARE 111 -#define BN_R_NOT_INITIALIZED 107 -#define BN_R_NO_INVERSE 108 -#define BN_R_NO_SOLUTION 116 -#define BN_R_P_IS_NOT_PRIME 112 -#define BN_R_TOO_MANY_ITERATIONS 113 -#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/bn/bn.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the Eric Young open source + * license provided above. + * + * The binary polynomial arithmetic software is originally written by + * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. + * + */ + +#ifndef HEADER_BN_H +#define HEADER_BN_H + +#include +#ifndef OPENSSL_NO_FP_API +#include /* FILE */ +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These preprocessor symbols control various aspects of the bignum headers and + * library code. They're not defined by any "normal" configuration, as they are + * intended for development and testing purposes. NB: defining all three can be + * useful for debugging application code as well as openssl itself. + * + * BN_DEBUG - turn on various debugging alterations to the bignum code + * BN_DEBUG_RAND - uses random poisoning of unused words to trip up + * mismanagement of bignum internals. You must also define BN_DEBUG. + */ +/* #define BN_DEBUG */ +/* #define BN_DEBUG_RAND */ + +#define BN_MUL_COMBA +#define BN_SQR_COMBA +#define BN_RECURSION + +/* This next option uses the C libraries (2 word)/(1 word) function. + * If it is not defined, I use my C version (which is slower). + * The reason for this flag is that when the particular C compiler + * library routine is used, and the library is linked with a different + * compiler, the library is missing. This mostly happens when the + * library is built with gcc and then linked using normal cc. This would + * be a common occurrence because gcc normally produces code that is + * 2 times faster than system compilers for the big number stuff. + * For machines with only one compiler (or shared libraries), this should + * be on. Again this in only really a problem on machines + * using "long long's", are 32bit, and are not using my assembler code. */ +#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \ + defined(OPENSSL_SYS_WIN32) || defined(linux) +# ifndef BN_DIV2W +# define BN_DIV2W +# endif +#endif + +/* assuming long is 64bit - this is the DEC Alpha + * unsigned long long is only 64 bits :-(, don't define + * BN_LLONG for the DEC Alpha */ +#ifdef SIXTY_FOUR_BIT_LONG +#define BN_ULLONG unsigned long long +#define BN_ULONG unsigned long +#define BN_LONG long +#define BN_BITS 128 +#define BN_BYTES 8 +#define BN_BITS2 64 +#define BN_BITS4 32 +#define BN_MASK (0xffffffffffffffffffffffffffffffffLL) +#define BN_MASK2 (0xffffffffffffffffL) +#define BN_MASK2l (0xffffffffL) +#define BN_MASK2h (0xffffffff00000000L) +#define BN_MASK2h1 (0xffffffff80000000L) +#define BN_TBIT (0x8000000000000000L) +#define BN_DEC_CONV (10000000000000000000UL) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%019lu" +#define BN_DEC_NUM 19 +#endif + +/* This is where the long long data type is 64 bits, but long is 32. + * For machines where there are 64bit registers, this is the mode to use. + * IRIX, on R4000 and above should use this mode, along with the relevant + * assembler code :-). Do NOT define BN_LLONG. + */ +#ifdef SIXTY_FOUR_BIT +#undef BN_LLONG +#undef BN_ULLONG +#define BN_ULONG unsigned long long +#define BN_LONG long long +#define BN_BITS 128 +#define BN_BYTES 8 +#define BN_BITS2 64 +#define BN_BITS4 32 +#define BN_MASK2 (0xffffffffffffffffLL) +#define BN_MASK2l (0xffffffffL) +#define BN_MASK2h (0xffffffff00000000LL) +#define BN_MASK2h1 (0xffffffff80000000LL) +#define BN_TBIT (0x8000000000000000LL) +#define BN_DEC_CONV (10000000000000000000ULL) +#define BN_DEC_FMT1 "%llu" +#define BN_DEC_FMT2 "%019llu" +#define BN_DEC_NUM 19 +#endif + +#ifdef THIRTY_TWO_BIT +#ifdef BN_LLONG +# if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) +# define BN_ULLONG unsigned __int64 +# else +# define BN_ULLONG unsigned long long +# endif +#endif +#define BN_ULONG unsigned long +#define BN_LONG long +#define BN_BITS 64 +#define BN_BYTES 4 +#define BN_BITS2 32 +#define BN_BITS4 16 +#ifdef OPENSSL_SYS_WIN32 +/* VC++ doesn't like the LL suffix */ +#define BN_MASK (0xffffffffffffffffL) +#else +#define BN_MASK (0xffffffffffffffffLL) +#endif +#define BN_MASK2 (0xffffffffL) +#define BN_MASK2l (0xffff) +#define BN_MASK2h1 (0xffff8000L) +#define BN_MASK2h (0xffff0000L) +#define BN_TBIT (0x80000000L) +#define BN_DEC_CONV (1000000000L) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%09lu" +#define BN_DEC_NUM 9 +#endif + +#ifdef SIXTEEN_BIT +#ifndef BN_DIV2W +#define BN_DIV2W +#endif +#define BN_ULLONG unsigned long +#define BN_ULONG unsigned short +#define BN_LONG short +#define BN_BITS 32 +#define BN_BYTES 2 +#define BN_BITS2 16 +#define BN_BITS4 8 +#define BN_MASK (0xffffffff) +#define BN_MASK2 (0xffff) +#define BN_MASK2l (0xff) +#define BN_MASK2h1 (0xff80) +#define BN_MASK2h (0xff00) +#define BN_TBIT (0x8000) +#define BN_DEC_CONV (100000) +#define BN_DEC_FMT1 "%u" +#define BN_DEC_FMT2 "%05u" +#define BN_DEC_NUM 5 +#endif + +#ifdef EIGHT_BIT +#ifndef BN_DIV2W +#define BN_DIV2W +#endif +#define BN_ULLONG unsigned short +#define BN_ULONG unsigned char +#define BN_LONG char +#define BN_BITS 16 +#define BN_BYTES 1 +#define BN_BITS2 8 +#define BN_BITS4 4 +#define BN_MASK (0xffff) +#define BN_MASK2 (0xff) +#define BN_MASK2l (0xf) +#define BN_MASK2h1 (0xf8) +#define BN_MASK2h (0xf0) +#define BN_TBIT (0x80) +#define BN_DEC_CONV (100) +#define BN_DEC_FMT1 "%u" +#define BN_DEC_FMT2 "%02u" +#define BN_DEC_NUM 2 +#endif + +#define BN_DEFAULT_BITS 1280 + +#define BN_FLG_MALLOCED 0x01 +#define BN_FLG_STATIC_DATA 0x02 +#define BN_FLG_EXP_CONSTTIME 0x04 /* avoid leaking exponent information through timings + * (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime) */ +#ifndef OPENSSL_NO_DEPRECATED +#define BN_FLG_FREE 0x8000 /* used for debuging */ +#endif +#define BN_set_flags(b,n) ((b)->flags|=(n)) +#define BN_get_flags(b,n) ((b)->flags&(n)) + +/* get a clone of a BIGNUM with changed flags, for *temporary* use only + * (the two BIGNUMs cannot not be used in parallel!) */ +#define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \ + (dest)->top=(b)->top, \ + (dest)->dmax=(b)->dmax, \ + (dest)->neg=(b)->neg, \ + (dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \ + | ((b)->flags & ~BN_FLG_MALLOCED) \ + | BN_FLG_STATIC_DATA \ + | (n))) + +/* Already declared in ossl_typ.h */ +#if 0 +typedef struct bignum_st BIGNUM; +/* Used for temp variables (declaration hidden in bn_lcl.h) */ +typedef struct bignum_ctx BN_CTX; +typedef struct bn_blinding_st BN_BLINDING; +typedef struct bn_mont_ctx_st BN_MONT_CTX; +typedef struct bn_recp_ctx_st BN_RECP_CTX; +typedef struct bn_gencb_st BN_GENCB; +#endif + +struct bignum_st + { + BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ + int top; /* Index of last used d +1. */ + /* The next are internal book keeping for bn_expand. */ + int dmax; /* Size of the d array. */ + int neg; /* one if the number is negative */ + int flags; + }; + +/* Used for montgomery multiplication */ +struct bn_mont_ctx_st + { + int ri; /* number of bits in R */ + BIGNUM RR; /* used to convert to montgomery form */ + BIGNUM N; /* The modulus */ + BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 + * (Ni is only stored for bignum algorithm) */ + BN_ULONG n0; /* least significant word of Ni */ + int flags; + }; + +/* Used for reciprocal division/mod functions + * It cannot be shared between threads + */ +struct bn_recp_ctx_st + { + BIGNUM N; /* the divisor */ + BIGNUM Nr; /* the reciprocal */ + int num_bits; + int shift; + int flags; + }; + +/* Used for slow "generation" functions. */ +struct bn_gencb_st + { + unsigned int ver; /* To handle binary (in)compatibility */ + void *arg; /* callback-specific data */ + union + { + /* if(ver==1) - handles old style callbacks */ + void (*cb_1)(int, int, void *); + /* if(ver==2) - new callback style */ + int (*cb_2)(int, int, BN_GENCB *); + } cb; + }; +/* Wrapper function to make using BN_GENCB easier, */ +int BN_GENCB_call(BN_GENCB *cb, int a, int b); +/* Macro to populate a BN_GENCB structure with an "old"-style callback */ +#define BN_GENCB_set_old(gencb, callback, cb_arg) { \ + BN_GENCB *tmp_gencb = (gencb); \ + tmp_gencb->ver = 1; \ + tmp_gencb->arg = (cb_arg); \ + tmp_gencb->cb.cb_1 = (callback); } +/* Macro to populate a BN_GENCB structure with a "new"-style callback */ +#define BN_GENCB_set(gencb, callback, cb_arg) { \ + BN_GENCB *tmp_gencb = (gencb); \ + tmp_gencb->ver = 2; \ + tmp_gencb->arg = (cb_arg); \ + tmp_gencb->cb.cb_2 = (callback); } + +#define BN_prime_checks 0 /* default: select number of iterations + based on the size of the number */ + +/* number of Miller-Rabin iterations for an error rate of less than 2^-80 + * for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook + * of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996]; + * original paper: Damgaard, Landrock, Pomerance: Average case error estimates + * for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */ +#define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \ + (b) >= 850 ? 3 : \ + (b) >= 650 ? 4 : \ + (b) >= 550 ? 5 : \ + (b) >= 450 ? 6 : \ + (b) >= 400 ? 7 : \ + (b) >= 350 ? 8 : \ + (b) >= 300 ? 9 : \ + (b) >= 250 ? 12 : \ + (b) >= 200 ? 15 : \ + (b) >= 150 ? 18 : \ + /* b >= 100 */ 27) + +#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) + +/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */ +#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \ + (((w) == 0) && ((a)->top == 0))) +#define BN_is_zero(a) ((a)->top == 0) +#define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg) +#define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg)) +#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1)) + +#define BN_one(a) (BN_set_word((a),1)) +#define BN_zero_ex(a) \ + do { \ + BIGNUM *_tmp_bn = (a); \ + _tmp_bn->top = 0; \ + _tmp_bn->neg = 0; \ + } while(0) +#ifdef OPENSSL_NO_DEPRECATED +#define BN_zero(a) BN_zero_ex(a) +#else +#define BN_zero(a) (BN_set_word((a),0)) +#endif + +const BIGNUM *BN_value_one(void); +char * BN_options(void); +BN_CTX *BN_CTX_new(void); +#ifndef OPENSSL_NO_DEPRECATED +void BN_CTX_init(BN_CTX *c); +#endif +void BN_CTX_free(BN_CTX *c); +void BN_CTX_start(BN_CTX *ctx); +BIGNUM *BN_CTX_get(BN_CTX *ctx); +void BN_CTX_end(BN_CTX *ctx); +int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); +int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom); +int BN_rand_range(BIGNUM *rnd, BIGNUM *range); +int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range); +int BN_num_bits(const BIGNUM *a); +int BN_num_bits_word(BN_ULONG); +BIGNUM *BN_new(void); +void BN_init(BIGNUM *); +void BN_clear_free(BIGNUM *a); +BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); +void BN_swap(BIGNUM *a, BIGNUM *b); +BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret); +int BN_bn2bin(const BIGNUM *a, unsigned char *to); +BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret); +int BN_bn2mpi(const BIGNUM *a, unsigned char *to); +int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); +int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx); +/** BN_set_negative sets sign of a BIGNUM + * \param b pointer to the BIGNUM object + * \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise + */ +void BN_set_negative(BIGNUM *b, int n); +/** BN_is_negative returns 1 if the BIGNUM is negative + * \param a pointer to the BIGNUM object + * \return 1 if a < 0 and 0 otherwise + */ +#define BN_is_negative(a) ((a)->neg != 0) + +int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, + BN_CTX *ctx); +#define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx)) +int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); +int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); +int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); +int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *m, BN_CTX *ctx); +int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); +int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m); + +BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); +BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); +int BN_mul_word(BIGNUM *a, BN_ULONG w); +int BN_add_word(BIGNUM *a, BN_ULONG w); +int BN_sub_word(BIGNUM *a, BN_ULONG w); +int BN_set_word(BIGNUM *a, BN_ULONG w); +BN_ULONG BN_get_word(const BIGNUM *a); + +int BN_cmp(const BIGNUM *a, const BIGNUM *b); +void BN_free(BIGNUM *a); +int BN_is_bit_set(const BIGNUM *a, int n); +int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); +int BN_lshift1(BIGNUM *r, const BIGNUM *a); +int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx); + +int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m,BN_CTX *ctx); +int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont); +int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, + const BIGNUM *a2, const BIGNUM *p2,const BIGNUM *m, + BN_CTX *ctx,BN_MONT_CTX *m_ctx); +int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m,BN_CTX *ctx); + +int BN_mask_bits(BIGNUM *a,int n); +#ifndef OPENSSL_NO_FP_API +int BN_print_fp(FILE *fp, const BIGNUM *a); +#endif +#ifdef HEADER_BIO_H +int BN_print(BIO *fp, const BIGNUM *a); +#else +int BN_print(void *fp, const BIGNUM *a); +#endif +int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx); +int BN_rshift(BIGNUM *r, const BIGNUM *a, int n); +int BN_rshift1(BIGNUM *r, const BIGNUM *a); +void BN_clear(BIGNUM *a); +BIGNUM *BN_dup(const BIGNUM *a); +int BN_ucmp(const BIGNUM *a, const BIGNUM *b); +int BN_set_bit(BIGNUM *a, int n); +int BN_clear_bit(BIGNUM *a, int n); +char * BN_bn2hex(const BIGNUM *a); +char * BN_bn2dec(const BIGNUM *a); +int BN_hex2bn(BIGNUM **a, const char *str); +int BN_dec2bn(BIGNUM **a, const char *str); +int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); +int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */ +BIGNUM *BN_mod_inverse(BIGNUM *ret, + const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); +BIGNUM *BN_mod_sqrt(BIGNUM *ret, + const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); + +/* Deprecated versions */ +#ifndef OPENSSL_NO_DEPRECATED +BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe, + const BIGNUM *add, const BIGNUM *rem, + void (*callback)(int,int,void *),void *cb_arg); +int BN_is_prime(const BIGNUM *p,int nchecks, + void (*callback)(int,int,void *), + BN_CTX *ctx,void *cb_arg); +int BN_is_prime_fasttest(const BIGNUM *p,int nchecks, + void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg, + int do_trial_division); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* Newer versions */ +int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add, + const BIGNUM *rem, BN_GENCB *cb); +int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb); +int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, + int do_trial_division, BN_GENCB *cb); + +BN_MONT_CTX *BN_MONT_CTX_new(void ); +void BN_MONT_CTX_init(BN_MONT_CTX *ctx); +int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b, + BN_MONT_CTX *mont, BN_CTX *ctx); +#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ + (r),(a),&((mont)->RR),(mont),(ctx)) +int BN_from_montgomery(BIGNUM *r,const BIGNUM *a, + BN_MONT_CTX *mont, BN_CTX *ctx); +void BN_MONT_CTX_free(BN_MONT_CTX *mont); +int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *mod,BN_CTX *ctx); +BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from); +BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock, + const BIGNUM *mod, BN_CTX *ctx); + +/* BN_BLINDING flags */ +#define BN_BLINDING_NO_UPDATE 0x00000001 +#define BN_BLINDING_NO_RECREATE 0x00000002 + +BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod); +void BN_BLINDING_free(BN_BLINDING *b); +int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); +int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); +int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); +int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); +int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); +unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *); +void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long); +unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); +void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); +BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, + const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, + int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), + BN_MONT_CTX *m_ctx); + +#ifndef OPENSSL_NO_DEPRECATED +void BN_set_params(int mul,int high,int low,int mont); +int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */ +#endif + +void BN_RECP_CTX_init(BN_RECP_CTX *recp); +BN_RECP_CTX *BN_RECP_CTX_new(void); +void BN_RECP_CTX_free(BN_RECP_CTX *recp); +int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx); +int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, + BN_RECP_CTX *recp,BN_CTX *ctx); +int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx); +int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, + BN_RECP_CTX *recp, BN_CTX *ctx); + +/* Functions for arithmetic over binary polynomials represented by BIGNUMs. + * + * The BIGNUM::neg property of BIGNUMs representing binary polynomials is + * ignored. + * + * Note that input arguments are not const so that their bit arrays can + * be expanded to the appropriate size if needed. + */ + +int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); /*r = a + b*/ +#define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b) +int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); /*r=a mod p*/ +int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = (a * b) mod p */ +int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); /* r = (a * a) mod p */ +int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, + BN_CTX *ctx); /* r = (1 / b) mod p */ +int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = (a / b) mod p */ +int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = (a ^ b) mod p */ +int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); /* r = sqrt(a) mod p */ +int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); /* r^2 + r = a mod p */ +#define BN_GF2m_cmp(a, b) BN_ucmp((a), (b)) +/* Some functions allow for representation of the irreducible polynomials + * as an unsigned int[], say p. The irreducible f(t) is then of the form: + * t^p[0] + t^p[1] + ... + t^p[k] + * where m = p[0] > p[1] > ... > p[k] = 0. + */ +int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[]); + /* r = a mod p */ +int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const unsigned int p[], BN_CTX *ctx); /* r = (a * b) mod p */ +int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[], + BN_CTX *ctx); /* r = (a * a) mod p */ +int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const unsigned int p[], + BN_CTX *ctx); /* r = (1 / b) mod p */ +int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const unsigned int p[], BN_CTX *ctx); /* r = (a / b) mod p */ +int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const unsigned int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */ +int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, + const unsigned int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */ +int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, + const unsigned int p[], BN_CTX *ctx); /* r^2 + r = a mod p */ +int BN_GF2m_poly2arr(const BIGNUM *a, unsigned int p[], int max); +int BN_GF2m_arr2poly(const unsigned int p[], BIGNUM *a); + +/* faster mod functions for the 'NIST primes' + * 0 <= a < p^2 */ +int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); + +const BIGNUM *BN_get0_nist_prime_192(void); +const BIGNUM *BN_get0_nist_prime_224(void); +const BIGNUM *BN_get0_nist_prime_256(void); +const BIGNUM *BN_get0_nist_prime_384(void); +const BIGNUM *BN_get0_nist_prime_521(void); + +/* library internal functions */ + +#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\ + (a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2)) +#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) +BIGNUM *bn_expand2(BIGNUM *a, int words); +#ifndef OPENSSL_NO_DEPRECATED +BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */ +#endif + +/* Bignum consistency macros + * There is one "API" macro, bn_fix_top(), for stripping leading zeroes from + * bignum data after direct manipulations on the data. There is also an + * "internal" macro, bn_check_top(), for verifying that there are no leading + * zeroes. Unfortunately, some auditing is required due to the fact that + * bn_fix_top() has become an overabused duct-tape because bignum data is + * occasionally passed around in an inconsistent state. So the following + * changes have been made to sort this out; + * - bn_fix_top()s implementation has been moved to bn_correct_top() + * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and + * bn_check_top() is as before. + * - if BN_DEBUG *is* defined; + * - bn_check_top() tries to pollute unused words even if the bignum 'top' is + * consistent. (ed: only if BN_DEBUG_RAND is defined) + * - bn_fix_top() maps to bn_check_top() rather than "fixing" anything. + * The idea is to have debug builds flag up inconsistent bignums when they + * occur. If that occurs in a bn_fix_top(), we examine the code in question; if + * the use of bn_fix_top() was appropriate (ie. it follows directly after code + * that manipulates the bignum) it is converted to bn_correct_top(), and if it + * was not appropriate, we convert it permanently to bn_check_top() and track + * down the cause of the bug. Eventually, no internal code should be using the + * bn_fix_top() macro. External applications and libraries should try this with + * their own code too, both in terms of building against the openssl headers + * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it + * defined. This not only improves external code, it provides more test + * coverage for openssl's own code. + */ + +#ifdef BN_DEBUG + +/* We only need assert() when debugging */ +#include + +#ifdef BN_DEBUG_RAND +/* To avoid "make update" cvs wars due to BN_DEBUG, use some tricks */ +#ifndef RAND_pseudo_bytes +int RAND_pseudo_bytes(unsigned char *buf,int num); +#define BN_DEBUG_TRIX +#endif +#define bn_pollute(a) \ + do { \ + const BIGNUM *_bnum1 = (a); \ + if(_bnum1->top < _bnum1->dmax) { \ + unsigned char _tmp_char; \ + /* We cast away const without the compiler knowing, any \ + * *genuinely* constant variables that aren't mutable \ + * wouldn't be constructed with top!=dmax. */ \ + BN_ULONG *_not_const; \ + memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \ + RAND_pseudo_bytes(&_tmp_char, 1); \ + memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \ + (_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \ + } \ + } while(0) +#ifdef BN_DEBUG_TRIX +#undef RAND_pseudo_bytes +#endif +#else +#define bn_pollute(a) +#endif +#define bn_check_top(a) \ + do { \ + const BIGNUM *_bnum2 = (a); \ + if (_bnum2 != NULL) { \ + assert((_bnum2->top == 0) || \ + (_bnum2->d[_bnum2->top - 1] != 0)); \ + bn_pollute(_bnum2); \ + } \ + } while(0) + +#define bn_fix_top(a) bn_check_top(a) + +#else /* !BN_DEBUG */ + +#define bn_pollute(a) +#define bn_check_top(a) +#define bn_fix_top(a) bn_correct_top(a) + +#endif + +#define bn_correct_top(a) \ + { \ + BN_ULONG *ftl; \ + if ((a)->top > 0) \ + { \ + for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \ + if (*(ftl--)) break; \ + } \ + bn_pollute(a); \ + } + +BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); +BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); +void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num); +BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d); +BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); +BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); + +/* Primes from RFC 2409 */ +BIGNUM *get_rfc2409_prime_768(BIGNUM *bn); +BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn); + +/* Primes from RFC 3526 */ +BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn); + +int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_BN_strings(void); + +/* Error codes for the BN functions. */ + +/* Function codes. */ +#define BN_F_BNRAND 127 +#define BN_F_BN_BLINDING_CONVERT_EX 100 +#define BN_F_BN_BLINDING_CREATE_PARAM 128 +#define BN_F_BN_BLINDING_INVERT_EX 101 +#define BN_F_BN_BLINDING_NEW 102 +#define BN_F_BN_BLINDING_UPDATE 103 +#define BN_F_BN_BN2DEC 104 +#define BN_F_BN_BN2HEX 105 +#define BN_F_BN_CTX_GET 116 +#define BN_F_BN_CTX_NEW 106 +#define BN_F_BN_CTX_START 129 +#define BN_F_BN_DIV 107 +#define BN_F_BN_DIV_RECP 130 +#define BN_F_BN_EXP 123 +#define BN_F_BN_EXPAND2 108 +#define BN_F_BN_EXPAND_INTERNAL 120 +#define BN_F_BN_GF2M_MOD 131 +#define BN_F_BN_GF2M_MOD_EXP 132 +#define BN_F_BN_GF2M_MOD_MUL 133 +#define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134 +#define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135 +#define BN_F_BN_GF2M_MOD_SQR 136 +#define BN_F_BN_GF2M_MOD_SQRT 137 +#define BN_F_BN_MOD_EXP2_MONT 118 +#define BN_F_BN_MOD_EXP_MONT 109 +#define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124 +#define BN_F_BN_MOD_EXP_MONT_WORD 117 +#define BN_F_BN_MOD_EXP_RECP 125 +#define BN_F_BN_MOD_EXP_SIMPLE 126 +#define BN_F_BN_MOD_INVERSE 110 +#define BN_F_BN_MOD_LSHIFT_QUICK 119 +#define BN_F_BN_MOD_MUL_RECIPROCAL 111 +#define BN_F_BN_MOD_SQRT 121 +#define BN_F_BN_MPI2BN 112 +#define BN_F_BN_NEW 113 +#define BN_F_BN_RAND 114 +#define BN_F_BN_RAND_RANGE 122 +#define BN_F_BN_USUB 115 + +/* Reason codes. */ +#define BN_R_ARG2_LT_ARG3 100 +#define BN_R_BAD_RECIPROCAL 101 +#define BN_R_BIGNUM_TOO_LONG 114 +#define BN_R_CALLED_WITH_EVEN_MODULUS 102 +#define BN_R_DIV_BY_ZERO 103 +#define BN_R_ENCODING_ERROR 104 +#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 +#define BN_R_INPUT_NOT_REDUCED 110 +#define BN_R_INVALID_LENGTH 106 +#define BN_R_INVALID_RANGE 115 +#define BN_R_NOT_A_SQUARE 111 +#define BN_R_NOT_INITIALIZED 107 +#define BN_R_NO_INVERSE 108 +#define BN_R_NO_SOLUTION 116 +#define BN_R_P_IS_NOT_PRIME 112 +#define BN_R_TOO_MANY_ITERATIONS 113 +#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/buffer.h b/src/dep/include/openssl/buffer.h index 261db14..a91e5b8 100644 --- a/src/dep/include/openssl/buffer.h +++ b/src/dep/include/openssl/buffer.h @@ -1,118 +1,118 @@ -/* crypto/buffer/buffer.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_BUFFER_H -#define HEADER_BUFFER_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#if !defined(NO_SYS_TYPES_H) -#include -#endif - -/* Already declared in ossl_typ.h */ -/* typedef struct buf_mem_st BUF_MEM; */ - -struct buf_mem_st - { - int length; /* current number of bytes */ - char *data; - int max; /* size of buffer */ - }; - -BUF_MEM *BUF_MEM_new(void); -void BUF_MEM_free(BUF_MEM *a); -int BUF_MEM_grow(BUF_MEM *str, int len); -int BUF_MEM_grow_clean(BUF_MEM *str, int len); -char * BUF_strdup(const char *str); -char * BUF_strndup(const char *str, size_t siz); -void * BUF_memdup(const void *data, size_t siz); - -/* safe string functions */ -size_t BUF_strlcpy(char *dst,const char *src,size_t siz); -size_t BUF_strlcat(char *dst,const char *src,size_t siz); - - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_BUF_strings(void); - -/* Error codes for the BUF functions. */ - -/* Function codes. */ -#define BUF_F_BUF_MEMDUP 103 -#define BUF_F_BUF_MEM_GROW 100 -#define BUF_F_BUF_MEM_GROW_CLEAN 105 -#define BUF_F_BUF_MEM_NEW 101 -#define BUF_F_BUF_STRDUP 102 -#define BUF_F_BUF_STRNDUP 104 - -/* Reason codes. */ - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/buffer/buffer.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BUFFER_H +#define HEADER_BUFFER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#if !defined(NO_SYS_TYPES_H) +#include +#endif + +/* Already declared in ossl_typ.h */ +/* typedef struct buf_mem_st BUF_MEM; */ + +struct buf_mem_st + { + int length; /* current number of bytes */ + char *data; + int max; /* size of buffer */ + }; + +BUF_MEM *BUF_MEM_new(void); +void BUF_MEM_free(BUF_MEM *a); +int BUF_MEM_grow(BUF_MEM *str, int len); +int BUF_MEM_grow_clean(BUF_MEM *str, int len); +char * BUF_strdup(const char *str); +char * BUF_strndup(const char *str, size_t siz); +void * BUF_memdup(const void *data, size_t siz); + +/* safe string functions */ +size_t BUF_strlcpy(char *dst,const char *src,size_t siz); +size_t BUF_strlcat(char *dst,const char *src,size_t siz); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_BUF_strings(void); + +/* Error codes for the BUF functions. */ + +/* Function codes. */ +#define BUF_F_BUF_MEMDUP 103 +#define BUF_F_BUF_MEM_GROW 100 +#define BUF_F_BUF_MEM_GROW_CLEAN 105 +#define BUF_F_BUF_MEM_NEW 101 +#define BUF_F_BUF_STRDUP 102 +#define BUF_F_BUF_STRNDUP 104 + +/* Reason codes. */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/cast.h b/src/dep/include/openssl/cast.h index 30ce6cc..c5daf8f 100644 --- a/src/dep/include/openssl/cast.h +++ b/src/dep/include/openssl/cast.h @@ -1,105 +1,105 @@ -/* crypto/cast/cast.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_CAST_H -#define HEADER_CAST_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#ifdef OPENSSL_NO_CAST -#error CAST is disabled. -#endif - -#define CAST_ENCRYPT 1 -#define CAST_DECRYPT 0 - -#define CAST_LONG unsigned long - -#define CAST_BLOCK 8 -#define CAST_KEY_LENGTH 16 - -typedef struct cast_key_st - { - CAST_LONG data[32]; - int short_key; /* Use reduced rounds for short key */ - } CAST_KEY; - - -void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); -void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out,CAST_KEY *key, - int enc); -void CAST_encrypt(CAST_LONG *data,CAST_KEY *key); -void CAST_decrypt(CAST_LONG *data,CAST_KEY *key); -void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, - CAST_KEY *ks, unsigned char *iv, int enc); -void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, CAST_KEY *schedule, unsigned char *ivec, - int *num, int enc); -void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, CAST_KEY *schedule, unsigned char *ivec, - int *num); - -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/cast/cast.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CAST_H +#define HEADER_CAST_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef OPENSSL_NO_CAST +#error CAST is disabled. +#endif + +#define CAST_ENCRYPT 1 +#define CAST_DECRYPT 0 + +#define CAST_LONG unsigned long + +#define CAST_BLOCK 8 +#define CAST_KEY_LENGTH 16 + +typedef struct cast_key_st + { + CAST_LONG data[32]; + int short_key; /* Use reduced rounds for short key */ + } CAST_KEY; + + +void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); +void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out,CAST_KEY *key, + int enc); +void CAST_encrypt(CAST_LONG *data,CAST_KEY *key); +void CAST_decrypt(CAST_LONG *data,CAST_KEY *key); +void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + CAST_KEY *ks, unsigned char *iv, int enc); +void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, CAST_KEY *schedule, unsigned char *ivec, + int *num, int enc); +void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, CAST_KEY *schedule, unsigned char *ivec, + int *num); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/comp.h b/src/dep/include/openssl/comp.h index 9e77ebc..5d59354 100644 --- a/src/dep/include/openssl/comp.h +++ b/src/dep/include/openssl/comp.h @@ -1,66 +1,66 @@ - -#ifndef HEADER_COMP_H -#define HEADER_COMP_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct comp_ctx_st COMP_CTX; - -typedef struct comp_method_st - { - int type; /* NID for compression library */ - const char *name; /* A text string to identify the library */ - int (*init)(COMP_CTX *ctx); - void (*finish)(COMP_CTX *ctx); - int (*compress)(COMP_CTX *ctx, - unsigned char *out, unsigned int olen, - unsigned char *in, unsigned int ilen); - int (*expand)(COMP_CTX *ctx, - unsigned char *out, unsigned int olen, - unsigned char *in, unsigned int ilen); - /* The following two do NOTHING, but are kept for backward compatibility */ - long (*ctrl)(void); - long (*callback_ctrl)(void); - } COMP_METHOD; - -struct comp_ctx_st - { - COMP_METHOD *meth; - unsigned long compress_in; - unsigned long compress_out; - unsigned long expand_in; - unsigned long expand_out; - - CRYPTO_EX_DATA ex_data; - }; - - -COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); -void COMP_CTX_free(COMP_CTX *ctx); -int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, - unsigned char *in, int ilen); -int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, - unsigned char *in, int ilen); -COMP_METHOD *COMP_rle(void ); -COMP_METHOD *COMP_zlib(void ); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_COMP_strings(void); - -/* Error codes for the COMP functions. */ - -/* Function codes. */ - -/* Reason codes. */ - -#ifdef __cplusplus -} -#endif -#endif + +#ifndef HEADER_COMP_H +#define HEADER_COMP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct comp_ctx_st COMP_CTX; + +typedef struct comp_method_st + { + int type; /* NID for compression library */ + const char *name; /* A text string to identify the library */ + int (*init)(COMP_CTX *ctx); + void (*finish)(COMP_CTX *ctx); + int (*compress)(COMP_CTX *ctx, + unsigned char *out, unsigned int olen, + unsigned char *in, unsigned int ilen); + int (*expand)(COMP_CTX *ctx, + unsigned char *out, unsigned int olen, + unsigned char *in, unsigned int ilen); + /* The following two do NOTHING, but are kept for backward compatibility */ + long (*ctrl)(void); + long (*callback_ctrl)(void); + } COMP_METHOD; + +struct comp_ctx_st + { + COMP_METHOD *meth; + unsigned long compress_in; + unsigned long compress_out; + unsigned long expand_in; + unsigned long expand_out; + + CRYPTO_EX_DATA ex_data; + }; + + +COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); +void COMP_CTX_free(COMP_CTX *ctx); +int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, + unsigned char *in, int ilen); +int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, + unsigned char *in, int ilen); +COMP_METHOD *COMP_rle(void ); +COMP_METHOD *COMP_zlib(void ); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_COMP_strings(void); + +/* Error codes for the COMP functions. */ + +/* Function codes. */ + +/* Reason codes. */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/conf.h b/src/dep/include/openssl/conf.h index 0452c6a..c1235e5 100644 --- a/src/dep/include/openssl/conf.h +++ b/src/dep/include/openssl/conf.h @@ -1,253 +1,253 @@ -/* crypto/conf/conf.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_CONF_H -#define HEADER_CONF_H - -#include -#include -#include -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct - { - char *section; - char *name; - char *value; - } CONF_VALUE; - -DECLARE_STACK_OF(CONF_VALUE) -DECLARE_STACK_OF(CONF_MODULE) -DECLARE_STACK_OF(CONF_IMODULE) - -struct conf_st; -struct conf_method_st; -typedef struct conf_method_st CONF_METHOD; - -struct conf_method_st - { - const char *name; - CONF *(*create)(CONF_METHOD *meth); - int (*init)(CONF *conf); - int (*destroy)(CONF *conf); - int (*destroy_data)(CONF *conf); - int (*load_bio)(CONF *conf, BIO *bp, long *eline); - int (*dump)(const CONF *conf, BIO *bp); - int (*is_number)(const CONF *conf, char c); - int (*to_int)(const CONF *conf, char c); - int (*load)(CONF *conf, const char *name, long *eline); - }; - -/* Module definitions */ - -typedef struct conf_imodule_st CONF_IMODULE; -typedef struct conf_module_st CONF_MODULE; - -/* DSO module function typedefs */ -typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf); -typedef void conf_finish_func(CONF_IMODULE *md); - -#define CONF_MFLAGS_IGNORE_ERRORS 0x1 -#define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 -#define CONF_MFLAGS_SILENT 0x4 -#define CONF_MFLAGS_NO_DSO 0x8 -#define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 - -int CONF_set_default_method(CONF_METHOD *meth); -void CONF_set_nconf(CONF *conf,LHASH *hash); -LHASH *CONF_load(LHASH *conf,const char *file,long *eline); -#ifndef OPENSSL_NO_FP_API -LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline); -#endif -LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline); -STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section); -char *CONF_get_string(LHASH *conf,const char *group,const char *name); -long CONF_get_number(LHASH *conf,const char *group,const char *name); -void CONF_free(LHASH *conf); -int CONF_dump_fp(LHASH *conf, FILE *out); -int CONF_dump_bio(LHASH *conf, BIO *out); - -void OPENSSL_config(const char *config_name); -void OPENSSL_no_config(void); - -/* New conf code. The semantics are different from the functions above. - If that wasn't the case, the above functions would have been replaced */ - -struct conf_st - { - CONF_METHOD *meth; - void *meth_data; - LHASH *data; - }; - -CONF *NCONF_new(CONF_METHOD *meth); -CONF_METHOD *NCONF_default(void); -CONF_METHOD *NCONF_WIN32(void); -#if 0 /* Just to give you an idea of what I have in mind */ -CONF_METHOD *NCONF_XML(void); -#endif -void NCONF_free(CONF *conf); -void NCONF_free_data(CONF *conf); - -int NCONF_load(CONF *conf,const char *file,long *eline); -#ifndef OPENSSL_NO_FP_API -int NCONF_load_fp(CONF *conf, FILE *fp,long *eline); -#endif -int NCONF_load_bio(CONF *conf, BIO *bp,long *eline); -STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section); -char *NCONF_get_string(const CONF *conf,const char *group,const char *name); -int NCONF_get_number_e(const CONF *conf,const char *group,const char *name, - long *result); -int NCONF_dump_fp(const CONF *conf, FILE *out); -int NCONF_dump_bio(const CONF *conf, BIO *out); - -#if 0 /* The following function has no error checking, - and should therefore be avoided */ -long NCONF_get_number(CONF *conf,char *group,char *name); -#else -#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) -#endif - -/* Module functions */ - -int CONF_modules_load(const CONF *cnf, const char *appname, - unsigned long flags); -int CONF_modules_load_file(const char *filename, const char *appname, - unsigned long flags); -void CONF_modules_unload(int all); -void CONF_modules_finish(void); -void CONF_modules_free(void); -int CONF_module_add(const char *name, conf_init_func *ifunc, - conf_finish_func *ffunc); - -const char *CONF_imodule_get_name(const CONF_IMODULE *md); -const char *CONF_imodule_get_value(const CONF_IMODULE *md); -void *CONF_imodule_get_usr_data(const CONF_IMODULE *md); -void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); -CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); -unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); -void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); -void *CONF_module_get_usr_data(CONF_MODULE *pmod); -void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); - -char *CONF_get1_default_config_file(void); - -int CONF_parse_list(const char *list, int sep, int nospc, - int (*list_cb)(const char *elem, int len, void *usr), void *arg); - -void OPENSSL_load_builtin_modules(void); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_CONF_strings(void); - -/* Error codes for the CONF functions. */ - -/* Function codes. */ -#define CONF_F_CONF_DUMP_FP 104 -#define CONF_F_CONF_LOAD 100 -#define CONF_F_CONF_LOAD_BIO 102 -#define CONF_F_CONF_LOAD_FP 103 -#define CONF_F_CONF_MODULES_LOAD 116 -#define CONF_F_DEF_LOAD 120 -#define CONF_F_DEF_LOAD_BIO 121 -#define CONF_F_MODULE_INIT 115 -#define CONF_F_MODULE_LOAD_DSO 117 -#define CONF_F_MODULE_RUN 118 -#define CONF_F_NCONF_DUMP_BIO 105 -#define CONF_F_NCONF_DUMP_FP 106 -#define CONF_F_NCONF_GET_NUMBER 107 -#define CONF_F_NCONF_GET_NUMBER_E 112 -#define CONF_F_NCONF_GET_SECTION 108 -#define CONF_F_NCONF_GET_STRING 109 -#define CONF_F_NCONF_LOAD 113 -#define CONF_F_NCONF_LOAD_BIO 110 -#define CONF_F_NCONF_LOAD_FP 114 -#define CONF_F_NCONF_NEW 111 -#define CONF_F_STR_COPY 101 - -/* Reason codes. */ -#define CONF_R_ERROR_LOADING_DSO 110 -#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 -#define CONF_R_MISSING_EQUAL_SIGN 101 -#define CONF_R_MISSING_FINISH_FUNCTION 111 -#define CONF_R_MISSING_INIT_FUNCTION 112 -#define CONF_R_MODULE_INITIALIZATION_ERROR 109 -#define CONF_R_NO_CLOSE_BRACE 102 -#define CONF_R_NO_CONF 105 -#define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 -#define CONF_R_NO_SECTION 107 -#define CONF_R_NO_SUCH_FILE 114 -#define CONF_R_NO_VALUE 108 -#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 -#define CONF_R_UNKNOWN_MODULE_NAME 113 -#define CONF_R_VARIABLE_HAS_NO_VALUE 104 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/conf/conf.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CONF_H +#define HEADER_CONF_H + +#include +#include +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct + { + char *section; + char *name; + char *value; + } CONF_VALUE; + +DECLARE_STACK_OF(CONF_VALUE) +DECLARE_STACK_OF(CONF_MODULE) +DECLARE_STACK_OF(CONF_IMODULE) + +struct conf_st; +struct conf_method_st; +typedef struct conf_method_st CONF_METHOD; + +struct conf_method_st + { + const char *name; + CONF *(*create)(CONF_METHOD *meth); + int (*init)(CONF *conf); + int (*destroy)(CONF *conf); + int (*destroy_data)(CONF *conf); + int (*load_bio)(CONF *conf, BIO *bp, long *eline); + int (*dump)(const CONF *conf, BIO *bp); + int (*is_number)(const CONF *conf, char c); + int (*to_int)(const CONF *conf, char c); + int (*load)(CONF *conf, const char *name, long *eline); + }; + +/* Module definitions */ + +typedef struct conf_imodule_st CONF_IMODULE; +typedef struct conf_module_st CONF_MODULE; + +/* DSO module function typedefs */ +typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf); +typedef void conf_finish_func(CONF_IMODULE *md); + +#define CONF_MFLAGS_IGNORE_ERRORS 0x1 +#define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 +#define CONF_MFLAGS_SILENT 0x4 +#define CONF_MFLAGS_NO_DSO 0x8 +#define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 + +int CONF_set_default_method(CONF_METHOD *meth); +void CONF_set_nconf(CONF *conf,LHASH *hash); +LHASH *CONF_load(LHASH *conf,const char *file,long *eline); +#ifndef OPENSSL_NO_FP_API +LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline); +#endif +LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline); +STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section); +char *CONF_get_string(LHASH *conf,const char *group,const char *name); +long CONF_get_number(LHASH *conf,const char *group,const char *name); +void CONF_free(LHASH *conf); +int CONF_dump_fp(LHASH *conf, FILE *out); +int CONF_dump_bio(LHASH *conf, BIO *out); + +void OPENSSL_config(const char *config_name); +void OPENSSL_no_config(void); + +/* New conf code. The semantics are different from the functions above. + If that wasn't the case, the above functions would have been replaced */ + +struct conf_st + { + CONF_METHOD *meth; + void *meth_data; + LHASH *data; + }; + +CONF *NCONF_new(CONF_METHOD *meth); +CONF_METHOD *NCONF_default(void); +CONF_METHOD *NCONF_WIN32(void); +#if 0 /* Just to give you an idea of what I have in mind */ +CONF_METHOD *NCONF_XML(void); +#endif +void NCONF_free(CONF *conf); +void NCONF_free_data(CONF *conf); + +int NCONF_load(CONF *conf,const char *file,long *eline); +#ifndef OPENSSL_NO_FP_API +int NCONF_load_fp(CONF *conf, FILE *fp,long *eline); +#endif +int NCONF_load_bio(CONF *conf, BIO *bp,long *eline); +STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section); +char *NCONF_get_string(const CONF *conf,const char *group,const char *name); +int NCONF_get_number_e(const CONF *conf,const char *group,const char *name, + long *result); +int NCONF_dump_fp(const CONF *conf, FILE *out); +int NCONF_dump_bio(const CONF *conf, BIO *out); + +#if 0 /* The following function has no error checking, + and should therefore be avoided */ +long NCONF_get_number(CONF *conf,char *group,char *name); +#else +#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) +#endif + +/* Module functions */ + +int CONF_modules_load(const CONF *cnf, const char *appname, + unsigned long flags); +int CONF_modules_load_file(const char *filename, const char *appname, + unsigned long flags); +void CONF_modules_unload(int all); +void CONF_modules_finish(void); +void CONF_modules_free(void); +int CONF_module_add(const char *name, conf_init_func *ifunc, + conf_finish_func *ffunc); + +const char *CONF_imodule_get_name(const CONF_IMODULE *md); +const char *CONF_imodule_get_value(const CONF_IMODULE *md); +void *CONF_imodule_get_usr_data(const CONF_IMODULE *md); +void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); +CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); +unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); +void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); +void *CONF_module_get_usr_data(CONF_MODULE *pmod); +void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); + +char *CONF_get1_default_config_file(void); + +int CONF_parse_list(const char *list, int sep, int nospc, + int (*list_cb)(const char *elem, int len, void *usr), void *arg); + +void OPENSSL_load_builtin_modules(void); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_CONF_strings(void); + +/* Error codes for the CONF functions. */ + +/* Function codes. */ +#define CONF_F_CONF_DUMP_FP 104 +#define CONF_F_CONF_LOAD 100 +#define CONF_F_CONF_LOAD_BIO 102 +#define CONF_F_CONF_LOAD_FP 103 +#define CONF_F_CONF_MODULES_LOAD 116 +#define CONF_F_DEF_LOAD 120 +#define CONF_F_DEF_LOAD_BIO 121 +#define CONF_F_MODULE_INIT 115 +#define CONF_F_MODULE_LOAD_DSO 117 +#define CONF_F_MODULE_RUN 118 +#define CONF_F_NCONF_DUMP_BIO 105 +#define CONF_F_NCONF_DUMP_FP 106 +#define CONF_F_NCONF_GET_NUMBER 107 +#define CONF_F_NCONF_GET_NUMBER_E 112 +#define CONF_F_NCONF_GET_SECTION 108 +#define CONF_F_NCONF_GET_STRING 109 +#define CONF_F_NCONF_LOAD 113 +#define CONF_F_NCONF_LOAD_BIO 110 +#define CONF_F_NCONF_LOAD_FP 114 +#define CONF_F_NCONF_NEW 111 +#define CONF_F_STR_COPY 101 + +/* Reason codes. */ +#define CONF_R_ERROR_LOADING_DSO 110 +#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 +#define CONF_R_MISSING_EQUAL_SIGN 101 +#define CONF_R_MISSING_FINISH_FUNCTION 111 +#define CONF_R_MISSING_INIT_FUNCTION 112 +#define CONF_R_MODULE_INITIALIZATION_ERROR 109 +#define CONF_R_NO_CLOSE_BRACE 102 +#define CONF_R_NO_CONF 105 +#define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 +#define CONF_R_NO_SECTION 107 +#define CONF_R_NO_SUCH_FILE 114 +#define CONF_R_NO_VALUE 108 +#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 +#define CONF_R_UNKNOWN_MODULE_NAME 113 +#define CONF_R_VARIABLE_HAS_NO_VALUE 104 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/conf_api.h b/src/dep/include/openssl/conf_api.h index fd6e4a2..7cb5b8f 100644 --- a/src/dep/include/openssl/conf_api.h +++ b/src/dep/include/openssl/conf_api.h @@ -1,89 +1,89 @@ -/* conf_api.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_CONF_API_H -#define HEADER_CONF_API_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Up until OpenSSL 0.9.5a, this was new_section */ -CONF_VALUE *_CONF_new_section(CONF *conf, const char *section); -/* Up until OpenSSL 0.9.5a, this was get_section */ -CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section); -/* Up until OpenSSL 0.9.5a, this was CONF_get_section */ -STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, - const char *section); - -int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); -char *_CONF_get_string(const CONF *conf, const char *section, - const char *name); -long _CONF_get_number(const CONF *conf, const char *section, const char *name); - -int _CONF_new_data(CONF *conf); -void _CONF_free_data(CONF *conf); - -#ifdef __cplusplus -} -#endif -#endif - +/* conf_api.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CONF_API_H +#define HEADER_CONF_API_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Up until OpenSSL 0.9.5a, this was new_section */ +CONF_VALUE *_CONF_new_section(CONF *conf, const char *section); +/* Up until OpenSSL 0.9.5a, this was get_section */ +CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section); +/* Up until OpenSSL 0.9.5a, this was CONF_get_section */ +STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, + const char *section); + +int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); +char *_CONF_get_string(const CONF *conf, const char *section, + const char *name); +long _CONF_get_number(const CONF *conf, const char *section, const char *name); + +int _CONF_new_data(CONF *conf); +void _CONF_free_data(CONF *conf); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/src/dep/include/openssl/crypto.h b/src/dep/include/openssl/crypto.h index daef816..c144ade 100644 --- a/src/dep/include/openssl/crypto.h +++ b/src/dep/include/openssl/crypto.h @@ -1,550 +1,550 @@ -/* crypto/crypto.h */ -/* ==================================================================== - * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * ECDH support in OpenSSL originally developed by - * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. - */ - -#ifndef HEADER_CRYPTO_H -#define HEADER_CRYPTO_H - -#include - -#include - -#ifndef OPENSSL_NO_FP_API -#include -#endif - -#include -#include -#include -#include - -#ifdef CHARSET_EBCDIC -#include -#endif - -/* Resolve problems on some operating systems with symbol names that clash - one way or another */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Backward compatibility to SSLeay */ -/* This is more to be used to check the correct DLL is being used - * in the MS world. */ -#define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER -#define SSLEAY_VERSION 0 -/* #define SSLEAY_OPTIONS 1 no longer supported */ -#define SSLEAY_CFLAGS 2 -#define SSLEAY_BUILT_ON 3 -#define SSLEAY_PLATFORM 4 -#define SSLEAY_DIR 5 - -/* Already declared in ossl_typ.h */ -#if 0 -typedef struct crypto_ex_data_st CRYPTO_EX_DATA; -/* Called when a new object is created */ -typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, - int idx, long argl, void *argp); -/* Called when an object is free()ed */ -typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, - int idx, long argl, void *argp); -/* Called when we need to dup an object */ -typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, - int idx, long argl, void *argp); -#endif - -/* A generic structure to pass assorted data in a expandable way */ -typedef struct openssl_item_st - { - int code; - void *value; /* Not used for flag attributes */ - size_t value_size; /* Max size of value for output, length for input */ - size_t *value_length; /* Returned length of value for output */ - } OPENSSL_ITEM; - - -/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock - * names in cryptlib.c - */ - -#define CRYPTO_LOCK_ERR 1 -#define CRYPTO_LOCK_EX_DATA 2 -#define CRYPTO_LOCK_X509 3 -#define CRYPTO_LOCK_X509_INFO 4 -#define CRYPTO_LOCK_X509_PKEY 5 -#define CRYPTO_LOCK_X509_CRL 6 -#define CRYPTO_LOCK_X509_REQ 7 -#define CRYPTO_LOCK_DSA 8 -#define CRYPTO_LOCK_RSA 9 -#define CRYPTO_LOCK_EVP_PKEY 10 -#define CRYPTO_LOCK_X509_STORE 11 -#define CRYPTO_LOCK_SSL_CTX 12 -#define CRYPTO_LOCK_SSL_CERT 13 -#define CRYPTO_LOCK_SSL_SESSION 14 -#define CRYPTO_LOCK_SSL_SESS_CERT 15 -#define CRYPTO_LOCK_SSL 16 -#define CRYPTO_LOCK_SSL_METHOD 17 -#define CRYPTO_LOCK_RAND 18 -#define CRYPTO_LOCK_RAND2 19 -#define CRYPTO_LOCK_MALLOC 20 -#define CRYPTO_LOCK_BIO 21 -#define CRYPTO_LOCK_GETHOSTBYNAME 22 -#define CRYPTO_LOCK_GETSERVBYNAME 23 -#define CRYPTO_LOCK_READDIR 24 -#define CRYPTO_LOCK_RSA_BLINDING 25 -#define CRYPTO_LOCK_DH 26 -#define CRYPTO_LOCK_MALLOC2 27 -#define CRYPTO_LOCK_DSO 28 -#define CRYPTO_LOCK_DYNLOCK 29 -#define CRYPTO_LOCK_ENGINE 30 -#define CRYPTO_LOCK_UI 31 -#define CRYPTO_LOCK_ECDSA 32 -#define CRYPTO_LOCK_EC 33 -#define CRYPTO_LOCK_ECDH 34 -#define CRYPTO_LOCK_BN 35 -#define CRYPTO_LOCK_EC_PRE_COMP 36 -#define CRYPTO_LOCK_STORE 37 -#define CRYPTO_LOCK_COMP 38 -#define CRYPTO_NUM_LOCKS 39 - -#define CRYPTO_LOCK 1 -#define CRYPTO_UNLOCK 2 -#define CRYPTO_READ 4 -#define CRYPTO_WRITE 8 - -#ifndef OPENSSL_NO_LOCKING -#ifndef CRYPTO_w_lock -#define CRYPTO_w_lock(type) \ - CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) -#define CRYPTO_w_unlock(type) \ - CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) -#define CRYPTO_r_lock(type) \ - CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__) -#define CRYPTO_r_unlock(type) \ - CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__) -#define CRYPTO_add(addr,amount,type) \ - CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__) -#endif -#else -#define CRYPTO_w_lock(a) -#define CRYPTO_w_unlock(a) -#define CRYPTO_r_lock(a) -#define CRYPTO_r_unlock(a) -#define CRYPTO_add(a,b,c) ((*(a))+=(b)) -#endif - -/* Some applications as well as some parts of OpenSSL need to allocate - and deallocate locks in a dynamic fashion. The following typedef - makes this possible in a type-safe manner. */ -/* struct CRYPTO_dynlock_value has to be defined by the application. */ -typedef struct - { - int references; - struct CRYPTO_dynlock_value *data; - } CRYPTO_dynlock; - - -/* The following can be used to detect memory leaks in the SSLeay library. - * It used, it turns on malloc checking */ - -#define CRYPTO_MEM_CHECK_OFF 0x0 /* an enume */ -#define CRYPTO_MEM_CHECK_ON 0x1 /* a bit */ -#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */ -#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */ - -/* The following are bit values to turn on or off options connected to the - * malloc checking functionality */ - -/* Adds time to the memory checking information */ -#define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */ -/* Adds thread number to the memory checking information */ -#define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */ - -#define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD) - - -/* predec of the BIO type */ -typedef struct bio_st BIO_dummy; - -struct crypto_ex_data_st - { - STACK *sk; - int dummy; /* gcc is screwing up this data structure :-( */ - }; - -/* This stuff is basically class callback functions - * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */ - -typedef struct crypto_ex_data_func_st - { - long argl; /* Arbitary long */ - void *argp; /* Arbitary void * */ - CRYPTO_EX_new *new_func; - CRYPTO_EX_free *free_func; - CRYPTO_EX_dup *dup_func; - } CRYPTO_EX_DATA_FUNCS; - -DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) - -/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA - * entry. - */ - -#define CRYPTO_EX_INDEX_BIO 0 -#define CRYPTO_EX_INDEX_SSL 1 -#define CRYPTO_EX_INDEX_SSL_CTX 2 -#define CRYPTO_EX_INDEX_SSL_SESSION 3 -#define CRYPTO_EX_INDEX_X509_STORE 4 -#define CRYPTO_EX_INDEX_X509_STORE_CTX 5 -#define CRYPTO_EX_INDEX_RSA 6 -#define CRYPTO_EX_INDEX_DSA 7 -#define CRYPTO_EX_INDEX_DH 8 -#define CRYPTO_EX_INDEX_ENGINE 9 -#define CRYPTO_EX_INDEX_X509 10 -#define CRYPTO_EX_INDEX_UI 11 -#define CRYPTO_EX_INDEX_ECDSA 12 -#define CRYPTO_EX_INDEX_ECDH 13 -#define CRYPTO_EX_INDEX_COMP 14 -#define CRYPTO_EX_INDEX_STORE 15 - -/* Dynamically assigned indexes start from this value (don't use directly, use - * via CRYPTO_ex_data_new_class). */ -#define CRYPTO_EX_INDEX_USER 100 - - -/* This is the default callbacks, but we can have others as well: - * this is needed in Win32 where the application malloc and the - * library malloc may not be the same. - */ -#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\ - malloc, realloc, free) - -#if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD -# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */ -# define CRYPTO_MDEBUG -# endif -#endif - -/* Set standard debugging functions (not done by default - * unless CRYPTO_MDEBUG is defined) */ -#define CRYPTO_malloc_debug_init() do {\ - CRYPTO_set_mem_debug_functions(\ - CRYPTO_dbg_malloc,\ - CRYPTO_dbg_realloc,\ - CRYPTO_dbg_free,\ - CRYPTO_dbg_set_options,\ - CRYPTO_dbg_get_options);\ - } while(0) - -int CRYPTO_mem_ctrl(int mode); -int CRYPTO_is_mem_check_on(void); - -/* for applications */ -#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) -#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) - -/* for library-internal use */ -#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE) -#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE) -#define is_MemCheck_on() CRYPTO_is_mem_check_on() - -#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__) -#define OPENSSL_realloc(addr,num) \ - CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__) -#define OPENSSL_realloc_clean(addr,old_num,num) \ - CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__) -#define OPENSSL_remalloc(addr,num) \ - CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__) -#define OPENSSL_freeFunc CRYPTO_free -#define OPENSSL_free(addr) CRYPTO_free(addr) - -#define OPENSSL_malloc_locked(num) \ - CRYPTO_malloc_locked((int)num,__FILE__,__LINE__) -#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr) - - -const char *SSLeay_version(int type); -unsigned long SSLeay(void); - -int OPENSSL_issetugid(void); - -/* An opaque type representing an implementation of "ex_data" support */ -typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL; -/* Return an opaque pointer to the current "ex_data" implementation */ -const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void); -/* Sets the "ex_data" implementation to be used (if it's not too late) */ -int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i); -/* Get a new "ex_data" class, and return the corresponding "class_index" */ -int CRYPTO_ex_data_new_class(void); -/* Within a given class, get/register a new index */ -int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, - CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, - CRYPTO_EX_free *free_func); -/* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given - * class (invokes whatever per-class callbacks are applicable) */ -int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); -int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, - CRYPTO_EX_DATA *from); -void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); -/* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index - * (relative to the class type involved) */ -int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); -void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx); -/* This function cleans up all "ex_data" state. It mustn't be called under - * potential race-conditions. */ -void CRYPTO_cleanup_all_ex_data(void); - -int CRYPTO_get_new_lockid(char *name); - -int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */ -void CRYPTO_lock(int mode, int type,const char *file,int line); -void CRYPTO_set_locking_callback(void (*func)(int mode,int type, - const char *file,int line)); -void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file, - int line); -void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type, - const char *file, int line)); -int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type, - const char *file,int line); -void CRYPTO_set_id_callback(unsigned long (*func)(void)); -unsigned long (*CRYPTO_get_id_callback(void))(void); -unsigned long CRYPTO_thread_id(void); -const char *CRYPTO_get_lock_name(int type); -int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, - int line); - -int CRYPTO_get_new_dynlockid(void); -void CRYPTO_destroy_dynlockid(int i); -struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i); -void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line)); -void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)); -void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line)); -struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line); -void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line); -void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line); - -/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- - * call the latter last if you need different functions */ -int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *)); -int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *)); -int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int), - void *(*r)(void *,size_t,const char *,int), - void (*f)(void *)); -int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int), - void (*free_func)(void *)); -int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int), - void (*r)(void *,void *,int,const char *,int,int), - void (*f)(void *,int), - void (*so)(long), - long (*go)(void)); -void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *)); -void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)); -void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int), - void *(**r)(void *, size_t,const char *,int), - void (**f)(void *)); -void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int), - void (**f)(void *)); -void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int), - void (**r)(void *,void *,int,const char *,int,int), - void (**f)(void *,int), - void (**so)(long), - long (**go)(void)); - -void *CRYPTO_malloc_locked(int num, const char *file, int line); -void CRYPTO_free_locked(void *); -void *CRYPTO_malloc(int num, const char *file, int line); -void CRYPTO_free(void *); -void *CRYPTO_realloc(void *addr,int num, const char *file, int line); -void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file, - int line); -void *CRYPTO_remalloc(void *addr,int num, const char *file, int line); - -void OPENSSL_cleanse(void *ptr, size_t len); - -void CRYPTO_set_mem_debug_options(long bits); -long CRYPTO_get_mem_debug_options(void); - -#define CRYPTO_push_info(info) \ - CRYPTO_push_info_(info, __FILE__, __LINE__); -int CRYPTO_push_info_(const char *info, const char *file, int line); -int CRYPTO_pop_info(void); -int CRYPTO_remove_all_info(void); - - -/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro; - * used as default in CRYPTO_MDEBUG compilations): */ -/* The last argument has the following significance: - * - * 0: called before the actual memory allocation has taken place - * 1: called after the actual memory allocation has taken place - */ -void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p); -void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p); -void CRYPTO_dbg_free(void *addr,int before_p); -/* Tell the debugging code about options. By default, the following values - * apply: - * - * 0: Clear all options. - * V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option. - * V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option. - * V_CRYPTO_MDEBUG_ALL (3): 1 + 2 - */ -void CRYPTO_dbg_set_options(long bits); -long CRYPTO_dbg_get_options(void); - - -#ifndef OPENSSL_NO_FP_API -void CRYPTO_mem_leaks_fp(FILE *); -#endif -void CRYPTO_mem_leaks(struct bio_st *bio); -/* unsigned long order, char *file, int line, int num_bytes, char *addr */ -typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *); -void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); - -/* die if we have to */ -void OpenSSLDie(const char *file,int line,const char *assertion); -#define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1)) - -unsigned long *OPENSSL_ia32cap_loc(void); -#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc())) - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_CRYPTO_strings(void); - -/* Error codes for the CRYPTO functions. */ - -/* Function codes. */ -#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 -#define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103 -#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101 -#define CRYPTO_F_CRYPTO_SET_EX_DATA 102 -#define CRYPTO_F_DEF_ADD_INDEX 104 -#define CRYPTO_F_DEF_GET_CLASS 105 -#define CRYPTO_F_INT_DUP_EX_DATA 106 -#define CRYPTO_F_INT_FREE_EX_DATA 107 -#define CRYPTO_F_INT_NEW_EX_DATA 108 - -/* Reason codes. */ -#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/crypto.h */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECDH support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_CRYPTO_H +#define HEADER_CRYPTO_H + +#include + +#include + +#ifndef OPENSSL_NO_FP_API +#include +#endif + +#include +#include +#include +#include + +#ifdef CHARSET_EBCDIC +#include +#endif + +/* Resolve problems on some operating systems with symbol names that clash + one way or another */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Backward compatibility to SSLeay */ +/* This is more to be used to check the correct DLL is being used + * in the MS world. */ +#define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER +#define SSLEAY_VERSION 0 +/* #define SSLEAY_OPTIONS 1 no longer supported */ +#define SSLEAY_CFLAGS 2 +#define SSLEAY_BUILT_ON 3 +#define SSLEAY_PLATFORM 4 +#define SSLEAY_DIR 5 + +/* Already declared in ossl_typ.h */ +#if 0 +typedef struct crypto_ex_data_st CRYPTO_EX_DATA; +/* Called when a new object is created */ +typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +/* Called when an object is free()ed */ +typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +/* Called when we need to dup an object */ +typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, + int idx, long argl, void *argp); +#endif + +/* A generic structure to pass assorted data in a expandable way */ +typedef struct openssl_item_st + { + int code; + void *value; /* Not used for flag attributes */ + size_t value_size; /* Max size of value for output, length for input */ + size_t *value_length; /* Returned length of value for output */ + } OPENSSL_ITEM; + + +/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock + * names in cryptlib.c + */ + +#define CRYPTO_LOCK_ERR 1 +#define CRYPTO_LOCK_EX_DATA 2 +#define CRYPTO_LOCK_X509 3 +#define CRYPTO_LOCK_X509_INFO 4 +#define CRYPTO_LOCK_X509_PKEY 5 +#define CRYPTO_LOCK_X509_CRL 6 +#define CRYPTO_LOCK_X509_REQ 7 +#define CRYPTO_LOCK_DSA 8 +#define CRYPTO_LOCK_RSA 9 +#define CRYPTO_LOCK_EVP_PKEY 10 +#define CRYPTO_LOCK_X509_STORE 11 +#define CRYPTO_LOCK_SSL_CTX 12 +#define CRYPTO_LOCK_SSL_CERT 13 +#define CRYPTO_LOCK_SSL_SESSION 14 +#define CRYPTO_LOCK_SSL_SESS_CERT 15 +#define CRYPTO_LOCK_SSL 16 +#define CRYPTO_LOCK_SSL_METHOD 17 +#define CRYPTO_LOCK_RAND 18 +#define CRYPTO_LOCK_RAND2 19 +#define CRYPTO_LOCK_MALLOC 20 +#define CRYPTO_LOCK_BIO 21 +#define CRYPTO_LOCK_GETHOSTBYNAME 22 +#define CRYPTO_LOCK_GETSERVBYNAME 23 +#define CRYPTO_LOCK_READDIR 24 +#define CRYPTO_LOCK_RSA_BLINDING 25 +#define CRYPTO_LOCK_DH 26 +#define CRYPTO_LOCK_MALLOC2 27 +#define CRYPTO_LOCK_DSO 28 +#define CRYPTO_LOCK_DYNLOCK 29 +#define CRYPTO_LOCK_ENGINE 30 +#define CRYPTO_LOCK_UI 31 +#define CRYPTO_LOCK_ECDSA 32 +#define CRYPTO_LOCK_EC 33 +#define CRYPTO_LOCK_ECDH 34 +#define CRYPTO_LOCK_BN 35 +#define CRYPTO_LOCK_EC_PRE_COMP 36 +#define CRYPTO_LOCK_STORE 37 +#define CRYPTO_LOCK_COMP 38 +#define CRYPTO_NUM_LOCKS 39 + +#define CRYPTO_LOCK 1 +#define CRYPTO_UNLOCK 2 +#define CRYPTO_READ 4 +#define CRYPTO_WRITE 8 + +#ifndef OPENSSL_NO_LOCKING +#ifndef CRYPTO_w_lock +#define CRYPTO_w_lock(type) \ + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) +#define CRYPTO_w_unlock(type) \ + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) +#define CRYPTO_r_lock(type) \ + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__) +#define CRYPTO_r_unlock(type) \ + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__) +#define CRYPTO_add(addr,amount,type) \ + CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__) +#endif +#else +#define CRYPTO_w_lock(a) +#define CRYPTO_w_unlock(a) +#define CRYPTO_r_lock(a) +#define CRYPTO_r_unlock(a) +#define CRYPTO_add(a,b,c) ((*(a))+=(b)) +#endif + +/* Some applications as well as some parts of OpenSSL need to allocate + and deallocate locks in a dynamic fashion. The following typedef + makes this possible in a type-safe manner. */ +/* struct CRYPTO_dynlock_value has to be defined by the application. */ +typedef struct + { + int references; + struct CRYPTO_dynlock_value *data; + } CRYPTO_dynlock; + + +/* The following can be used to detect memory leaks in the SSLeay library. + * It used, it turns on malloc checking */ + +#define CRYPTO_MEM_CHECK_OFF 0x0 /* an enume */ +#define CRYPTO_MEM_CHECK_ON 0x1 /* a bit */ +#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */ +#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */ + +/* The following are bit values to turn on or off options connected to the + * malloc checking functionality */ + +/* Adds time to the memory checking information */ +#define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */ +/* Adds thread number to the memory checking information */ +#define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */ + +#define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD) + + +/* predec of the BIO type */ +typedef struct bio_st BIO_dummy; + +struct crypto_ex_data_st + { + STACK *sk; + int dummy; /* gcc is screwing up this data structure :-( */ + }; + +/* This stuff is basically class callback functions + * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */ + +typedef struct crypto_ex_data_func_st + { + long argl; /* Arbitary long */ + void *argp; /* Arbitary void * */ + CRYPTO_EX_new *new_func; + CRYPTO_EX_free *free_func; + CRYPTO_EX_dup *dup_func; + } CRYPTO_EX_DATA_FUNCS; + +DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) + +/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA + * entry. + */ + +#define CRYPTO_EX_INDEX_BIO 0 +#define CRYPTO_EX_INDEX_SSL 1 +#define CRYPTO_EX_INDEX_SSL_CTX 2 +#define CRYPTO_EX_INDEX_SSL_SESSION 3 +#define CRYPTO_EX_INDEX_X509_STORE 4 +#define CRYPTO_EX_INDEX_X509_STORE_CTX 5 +#define CRYPTO_EX_INDEX_RSA 6 +#define CRYPTO_EX_INDEX_DSA 7 +#define CRYPTO_EX_INDEX_DH 8 +#define CRYPTO_EX_INDEX_ENGINE 9 +#define CRYPTO_EX_INDEX_X509 10 +#define CRYPTO_EX_INDEX_UI 11 +#define CRYPTO_EX_INDEX_ECDSA 12 +#define CRYPTO_EX_INDEX_ECDH 13 +#define CRYPTO_EX_INDEX_COMP 14 +#define CRYPTO_EX_INDEX_STORE 15 + +/* Dynamically assigned indexes start from this value (don't use directly, use + * via CRYPTO_ex_data_new_class). */ +#define CRYPTO_EX_INDEX_USER 100 + + +/* This is the default callbacks, but we can have others as well: + * this is needed in Win32 where the application malloc and the + * library malloc may not be the same. + */ +#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\ + malloc, realloc, free) + +#if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD +# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */ +# define CRYPTO_MDEBUG +# endif +#endif + +/* Set standard debugging functions (not done by default + * unless CRYPTO_MDEBUG is defined) */ +#define CRYPTO_malloc_debug_init() do {\ + CRYPTO_set_mem_debug_functions(\ + CRYPTO_dbg_malloc,\ + CRYPTO_dbg_realloc,\ + CRYPTO_dbg_free,\ + CRYPTO_dbg_set_options,\ + CRYPTO_dbg_get_options);\ + } while(0) + +int CRYPTO_mem_ctrl(int mode); +int CRYPTO_is_mem_check_on(void); + +/* for applications */ +#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) +#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) + +/* for library-internal use */ +#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE) +#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE) +#define is_MemCheck_on() CRYPTO_is_mem_check_on() + +#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__) +#define OPENSSL_realloc(addr,num) \ + CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__) +#define OPENSSL_realloc_clean(addr,old_num,num) \ + CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__) +#define OPENSSL_remalloc(addr,num) \ + CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__) +#define OPENSSL_freeFunc CRYPTO_free +#define OPENSSL_free(addr) CRYPTO_free(addr) + +#define OPENSSL_malloc_locked(num) \ + CRYPTO_malloc_locked((int)num,__FILE__,__LINE__) +#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr) + + +const char *SSLeay_version(int type); +unsigned long SSLeay(void); + +int OPENSSL_issetugid(void); + +/* An opaque type representing an implementation of "ex_data" support */ +typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL; +/* Return an opaque pointer to the current "ex_data" implementation */ +const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void); +/* Sets the "ex_data" implementation to be used (if it's not too late) */ +int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i); +/* Get a new "ex_data" class, and return the corresponding "class_index" */ +int CRYPTO_ex_data_new_class(void); +/* Within a given class, get/register a new index */ +int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, + CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, + CRYPTO_EX_free *free_func); +/* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given + * class (invokes whatever per-class callbacks are applicable) */ +int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); +int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, + CRYPTO_EX_DATA *from); +void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); +/* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index + * (relative to the class type involved) */ +int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); +void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx); +/* This function cleans up all "ex_data" state. It mustn't be called under + * potential race-conditions. */ +void CRYPTO_cleanup_all_ex_data(void); + +int CRYPTO_get_new_lockid(char *name); + +int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */ +void CRYPTO_lock(int mode, int type,const char *file,int line); +void CRYPTO_set_locking_callback(void (*func)(int mode,int type, + const char *file,int line)); +void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file, + int line); +void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type, + const char *file, int line)); +int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type, + const char *file,int line); +void CRYPTO_set_id_callback(unsigned long (*func)(void)); +unsigned long (*CRYPTO_get_id_callback(void))(void); +unsigned long CRYPTO_thread_id(void); +const char *CRYPTO_get_lock_name(int type); +int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, + int line); + +int CRYPTO_get_new_dynlockid(void); +void CRYPTO_destroy_dynlockid(int i); +struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i); +void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line)); +void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)); +void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line)); +struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line); +void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line); +void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line); + +/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- + * call the latter last if you need different functions */ +int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *)); +int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *)); +int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int), + void *(*r)(void *,size_t,const char *,int), + void (*f)(void *)); +int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int), + void (*free_func)(void *)); +int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int), + void (*r)(void *,void *,int,const char *,int,int), + void (*f)(void *,int), + void (*so)(long), + long (*go)(void)); +void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *)); +void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)); +void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int), + void *(**r)(void *, size_t,const char *,int), + void (**f)(void *)); +void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int), + void (**f)(void *)); +void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int), + void (**r)(void *,void *,int,const char *,int,int), + void (**f)(void *,int), + void (**so)(long), + long (**go)(void)); + +void *CRYPTO_malloc_locked(int num, const char *file, int line); +void CRYPTO_free_locked(void *); +void *CRYPTO_malloc(int num, const char *file, int line); +void CRYPTO_free(void *); +void *CRYPTO_realloc(void *addr,int num, const char *file, int line); +void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file, + int line); +void *CRYPTO_remalloc(void *addr,int num, const char *file, int line); + +void OPENSSL_cleanse(void *ptr, size_t len); + +void CRYPTO_set_mem_debug_options(long bits); +long CRYPTO_get_mem_debug_options(void); + +#define CRYPTO_push_info(info) \ + CRYPTO_push_info_(info, __FILE__, __LINE__); +int CRYPTO_push_info_(const char *info, const char *file, int line); +int CRYPTO_pop_info(void); +int CRYPTO_remove_all_info(void); + + +/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro; + * used as default in CRYPTO_MDEBUG compilations): */ +/* The last argument has the following significance: + * + * 0: called before the actual memory allocation has taken place + * 1: called after the actual memory allocation has taken place + */ +void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p); +void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p); +void CRYPTO_dbg_free(void *addr,int before_p); +/* Tell the debugging code about options. By default, the following values + * apply: + * + * 0: Clear all options. + * V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option. + * V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option. + * V_CRYPTO_MDEBUG_ALL (3): 1 + 2 + */ +void CRYPTO_dbg_set_options(long bits); +long CRYPTO_dbg_get_options(void); + + +#ifndef OPENSSL_NO_FP_API +void CRYPTO_mem_leaks_fp(FILE *); +#endif +void CRYPTO_mem_leaks(struct bio_st *bio); +/* unsigned long order, char *file, int line, int num_bytes, char *addr */ +typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *); +void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); + +/* die if we have to */ +void OpenSSLDie(const char *file,int line,const char *assertion); +#define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1)) + +unsigned long *OPENSSL_ia32cap_loc(void); +#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc())) + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_CRYPTO_strings(void); + +/* Error codes for the CRYPTO functions. */ + +/* Function codes. */ +#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 +#define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103 +#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101 +#define CRYPTO_F_CRYPTO_SET_EX_DATA 102 +#define CRYPTO_F_DEF_ADD_INDEX 104 +#define CRYPTO_F_DEF_GET_CLASS 105 +#define CRYPTO_F_INT_DUP_EX_DATA 106 +#define CRYPTO_F_INT_FREE_EX_DATA 107 +#define CRYPTO_F_INT_NEW_EX_DATA 108 + +/* Reason codes. */ +#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/des.h b/src/dep/include/openssl/des.h index 4e11dad..1edfb9b 100644 --- a/src/dep/include/openssl/des.h +++ b/src/dep/include/openssl/des.h @@ -1,244 +1,244 @@ -/* crypto/des/des.h */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_NEW_DES_H -#define HEADER_NEW_DES_H - -#include /* OPENSSL_EXTERN, OPENSSL_NO_DES, - DES_LONG (via openssl/opensslconf.h */ - -#ifdef OPENSSL_NO_DES -#error DES is disabled. -#endif - -#ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef unsigned char DES_cblock[8]; -typedef /* const */ unsigned char const_DES_cblock[8]; -/* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * - * and const_DES_cblock * are incompatible pointer types. */ - -typedef struct DES_ks - { - union - { - DES_cblock cblock; - /* make sure things are correct size on machines with - * 8 byte longs */ - DES_LONG deslong[2]; - } ks[16]; - } DES_key_schedule; - -#ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT -# ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT -# define OPENSSL_ENABLE_OLD_DES_SUPPORT -# endif -#endif - -#ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT -# include -#endif - -#define DES_KEY_SZ (sizeof(DES_cblock)) -#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) - -#define DES_ENCRYPT 1 -#define DES_DECRYPT 0 - -#define DES_CBC_MODE 0 -#define DES_PCBC_MODE 1 - -#define DES_ecb2_encrypt(i,o,k1,k2,e) \ - DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) - -#define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ - DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) - -#define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ - DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) - -#define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ - DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) - -OPENSSL_DECLARE_GLOBAL(int,DES_check_key); /* defaults to false */ -#define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key) -OPENSSL_DECLARE_GLOBAL(int,DES_rw_mode); /* defaults to DES_PCBC_MODE */ -#define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode) - -const char *DES_options(void); -void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, - DES_key_schedule *ks1,DES_key_schedule *ks2, - DES_key_schedule *ks3, int enc); -DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output, - long length,DES_key_schedule *schedule, - const_DES_cblock *ivec); -/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */ -void DES_cbc_encrypt(const unsigned char *input,unsigned char *output, - long length,DES_key_schedule *schedule,DES_cblock *ivec, - int enc); -void DES_ncbc_encrypt(const unsigned char *input,unsigned char *output, - long length,DES_key_schedule *schedule,DES_cblock *ivec, - int enc); -void DES_xcbc_encrypt(const unsigned char *input,unsigned char *output, - long length,DES_key_schedule *schedule,DES_cblock *ivec, - const_DES_cblock *inw,const_DES_cblock *outw,int enc); -void DES_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits, - long length,DES_key_schedule *schedule,DES_cblock *ivec, - int enc); -void DES_ecb_encrypt(const_DES_cblock *input,DES_cblock *output, - DES_key_schedule *ks,int enc); - -/* This is the DES encryption function that gets called by just about - every other DES routine in the library. You should not use this - function except to implement 'modes' of DES. I say this because the - functions that call this routine do the conversion from 'char *' to - long, and this needs to be done to make sure 'non-aligned' memory - access do not occur. The characters are loaded 'little endian'. - Data is a pointer to 2 unsigned long's and ks is the - DES_key_schedule to use. enc, is non zero specifies encryption, - zero if decryption. */ -void DES_encrypt1(DES_LONG *data,DES_key_schedule *ks, int enc); - -/* This functions is the same as DES_encrypt1() except that the DES - initial permutation (IP) and final permutation (FP) have been left - out. As for DES_encrypt1(), you should not use this function. - It is used by the routines in the library that implement triple DES. - IP() DES_encrypt2() DES_encrypt2() DES_encrypt2() FP() is the same - as DES_encrypt1() DES_encrypt1() DES_encrypt1() except faster :-). */ -void DES_encrypt2(DES_LONG *data,DES_key_schedule *ks, int enc); - -void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, - DES_key_schedule *ks2, DES_key_schedule *ks3); -void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, - DES_key_schedule *ks2, DES_key_schedule *ks3); -void DES_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output, - long length, - DES_key_schedule *ks1,DES_key_schedule *ks2, - DES_key_schedule *ks3,DES_cblock *ivec,int enc); -void DES_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out, - long length, - DES_key_schedule *ks1,DES_key_schedule *ks2, - DES_key_schedule *ks3, - DES_cblock *ivec1,DES_cblock *ivec2, - int enc); -void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out, - long length,DES_key_schedule *ks1, - DES_key_schedule *ks2,DES_key_schedule *ks3, - DES_cblock *ivec,int *num,int enc); -void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out, - int numbits,long length,DES_key_schedule *ks1, - DES_key_schedule *ks2,DES_key_schedule *ks3, - DES_cblock *ivec,int enc); -void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out, - long length,DES_key_schedule *ks1, - DES_key_schedule *ks2,DES_key_schedule *ks3, - DES_cblock *ivec,int *num); - -void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white, - DES_cblock *out_white); - -int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched, - DES_cblock *iv); -int DES_enc_write(int fd,const void *buf,int len,DES_key_schedule *sched, - DES_cblock *iv); -char *DES_fcrypt(const char *buf,const char *salt, char *ret); -char *DES_crypt(const char *buf,const char *salt); -void DES_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits, - long length,DES_key_schedule *schedule,DES_cblock *ivec); -void DES_pcbc_encrypt(const unsigned char *input,unsigned char *output, - long length,DES_key_schedule *schedule,DES_cblock *ivec, - int enc); -DES_LONG DES_quad_cksum(const unsigned char *input,DES_cblock output[], - long length,int out_count,DES_cblock *seed); -int DES_random_key(DES_cblock *ret); -void DES_set_odd_parity(DES_cblock *key); -int DES_check_key_parity(const_DES_cblock *key); -int DES_is_weak_key(const_DES_cblock *key); -/* DES_set_key (= set_key = DES_key_sched = key_sched) calls - * DES_set_key_checked if global variable DES_check_key is set, - * DES_set_key_unchecked otherwise. */ -int DES_set_key(const_DES_cblock *key,DES_key_schedule *schedule); -int DES_key_sched(const_DES_cblock *key,DES_key_schedule *schedule); -int DES_set_key_checked(const_DES_cblock *key,DES_key_schedule *schedule); -void DES_set_key_unchecked(const_DES_cblock *key,DES_key_schedule *schedule); -void DES_string_to_key(const char *str,DES_cblock *key); -void DES_string_to_2keys(const char *str,DES_cblock *key1,DES_cblock *key2); -void DES_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length, - DES_key_schedule *schedule,DES_cblock *ivec,int *num, - int enc); -void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length, - DES_key_schedule *schedule,DES_cblock *ivec,int *num); - -int DES_read_password(DES_cblock *key, const char *prompt, int verify); -int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt, - int verify); - -#define DES_fixup_key_parity DES_set_odd_parity - -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/des/des.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_NEW_DES_H +#define HEADER_NEW_DES_H + +#include /* OPENSSL_EXTERN, OPENSSL_NO_DES, + DES_LONG (via openssl/opensslconf.h */ + +#ifdef OPENSSL_NO_DES +#error DES is disabled. +#endif + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned char DES_cblock[8]; +typedef /* const */ unsigned char const_DES_cblock[8]; +/* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * + * and const_DES_cblock * are incompatible pointer types. */ + +typedef struct DES_ks + { + union + { + DES_cblock cblock; + /* make sure things are correct size on machines with + * 8 byte longs */ + DES_LONG deslong[2]; + } ks[16]; + } DES_key_schedule; + +#ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT +# ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT +# define OPENSSL_ENABLE_OLD_DES_SUPPORT +# endif +#endif + +#ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT +# include +#endif + +#define DES_KEY_SZ (sizeof(DES_cblock)) +#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) + +#define DES_ENCRYPT 1 +#define DES_DECRYPT 0 + +#define DES_CBC_MODE 0 +#define DES_PCBC_MODE 1 + +#define DES_ecb2_encrypt(i,o,k1,k2,e) \ + DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +OPENSSL_DECLARE_GLOBAL(int,DES_check_key); /* defaults to false */ +#define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key) +OPENSSL_DECLARE_GLOBAL(int,DES_rw_mode); /* defaults to DES_PCBC_MODE */ +#define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode) + +const char *DES_options(void); +void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3, int enc); +DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output, + long length,DES_key_schedule *schedule, + const_DES_cblock *ivec); +/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */ +void DES_cbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +void DES_ncbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +void DES_xcbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + const_DES_cblock *inw,const_DES_cblock *outw,int enc); +void DES_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +void DES_ecb_encrypt(const_DES_cblock *input,DES_cblock *output, + DES_key_schedule *ks,int enc); + +/* This is the DES encryption function that gets called by just about + every other DES routine in the library. You should not use this + function except to implement 'modes' of DES. I say this because the + functions that call this routine do the conversion from 'char *' to + long, and this needs to be done to make sure 'non-aligned' memory + access do not occur. The characters are loaded 'little endian'. + Data is a pointer to 2 unsigned long's and ks is the + DES_key_schedule to use. enc, is non zero specifies encryption, + zero if decryption. */ +void DES_encrypt1(DES_LONG *data,DES_key_schedule *ks, int enc); + +/* This functions is the same as DES_encrypt1() except that the DES + initial permutation (IP) and final permutation (FP) have been left + out. As for DES_encrypt1(), you should not use this function. + It is used by the routines in the library that implement triple DES. + IP() DES_encrypt2() DES_encrypt2() DES_encrypt2() FP() is the same + as DES_encrypt1() DES_encrypt1() DES_encrypt1() except faster :-). */ +void DES_encrypt2(DES_LONG *data,DES_key_schedule *ks, int enc); + +void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3); +void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3); +void DES_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output, + long length, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3,DES_cblock *ivec,int enc); +void DES_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out, + long length, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3, + DES_cblock *ivec1,DES_cblock *ivec2, + int enc); +void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out, + long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int *num,int enc); +void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out, + int numbits,long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int enc); +void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out, + long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int *num); + +void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white, + DES_cblock *out_white); + +int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched, + DES_cblock *iv); +int DES_enc_write(int fd,const void *buf,int len,DES_key_schedule *sched, + DES_cblock *iv); +char *DES_fcrypt(const char *buf,const char *salt, char *ret); +char *DES_crypt(const char *buf,const char *salt); +void DES_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits, + long length,DES_key_schedule *schedule,DES_cblock *ivec); +void DES_pcbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +DES_LONG DES_quad_cksum(const unsigned char *input,DES_cblock output[], + long length,int out_count,DES_cblock *seed); +int DES_random_key(DES_cblock *ret); +void DES_set_odd_parity(DES_cblock *key); +int DES_check_key_parity(const_DES_cblock *key); +int DES_is_weak_key(const_DES_cblock *key); +/* DES_set_key (= set_key = DES_key_sched = key_sched) calls + * DES_set_key_checked if global variable DES_check_key is set, + * DES_set_key_unchecked otherwise. */ +int DES_set_key(const_DES_cblock *key,DES_key_schedule *schedule); +int DES_key_sched(const_DES_cblock *key,DES_key_schedule *schedule); +int DES_set_key_checked(const_DES_cblock *key,DES_key_schedule *schedule); +void DES_set_key_unchecked(const_DES_cblock *key,DES_key_schedule *schedule); +void DES_string_to_key(const char *str,DES_cblock *key); +void DES_string_to_2keys(const char *str,DES_cblock *key1,DES_cblock *key2); +void DES_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length, + DES_key_schedule *schedule,DES_cblock *ivec,int *num, + int enc); +void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length, + DES_key_schedule *schedule,DES_cblock *ivec,int *num); + +int DES_read_password(DES_cblock *key, const char *prompt, int verify); +int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt, + int verify); + +#define DES_fixup_key_parity DES_set_odd_parity + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/des_old.h b/src/dep/include/openssl/des_old.h index 51c8dfa..b49413e 100644 --- a/src/dep/include/openssl/des_old.h +++ b/src/dep/include/openssl/des_old.h @@ -1,445 +1,445 @@ -/* crypto/des/des_old.h -*- mode:C; c-file-style: "eay" -*- */ - -/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - * - * The function names in here are deprecated and are only present to - * provide an interface compatible with openssl 0.9.6 and older as - * well as libdes. OpenSSL now provides functions where "des_" has - * been replaced with "DES_" in the names, to make it possible to - * make incompatible changes that are needed for C type security and - * other stuff. - * - * This include files has two compatibility modes: - * - * - If OPENSSL_DES_LIBDES_COMPATIBILITY is defined, you get an API - * that is compatible with libdes and SSLeay. - * - If OPENSSL_DES_LIBDES_COMPATIBILITY isn't defined, you get an - * API that is compatible with OpenSSL 0.9.5x to 0.9.6x. - * - * Note that these modes break earlier snapshots of OpenSSL, where - * libdes compatibility was the only available mode or (later on) the - * prefered compatibility mode. However, after much consideration - * (and more or less violent discussions with external parties), it - * was concluded that OpenSSL should be compatible with earlier versions - * of itself before anything else. Also, in all honesty, libdes is - * an old beast that shouldn't really be used any more. - * - * Please consider starting to use the DES_ functions rather than the - * des_ ones. The des_ functions will disappear completely before - * OpenSSL 1.0! - * - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - */ - -/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL - * project 2001. - */ -/* ==================================================================== - * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_DES_H -#define HEADER_DES_H - -#include /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */ - -#ifdef OPENSSL_NO_DES -#error DES is disabled. -#endif - -#ifndef HEADER_NEW_DES_H -#error You must include des.h, not des_old.h directly. -#endif - -#ifdef _KERBEROS_DES_H -#error replaces . -#endif - -#include - -#ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _ -#undef _ -#endif - -typedef unsigned char _ossl_old_des_cblock[8]; -typedef struct _ossl_old_des_ks_struct - { - union { - _ossl_old_des_cblock _; - /* make sure things are correct size on machines with - * 8 byte longs */ - DES_LONG pad[2]; - } ks; - } _ossl_old_des_key_schedule[16]; - -#ifndef OPENSSL_DES_LIBDES_COMPATIBILITY -#define des_cblock DES_cblock -#define const_des_cblock const_DES_cblock -#define des_key_schedule DES_key_schedule -#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\ - DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e)) -#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\ - DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e)) -#define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\ - DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e)) -#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\ - DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e)) -#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\ - DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n)) -#define des_options()\ - DES_options() -#define des_cbc_cksum(i,o,l,k,iv)\ - DES_cbc_cksum((i),(o),(l),&(k),(iv)) -#define des_cbc_encrypt(i,o,l,k,iv,e)\ - DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e)) -#define des_ncbc_encrypt(i,o,l,k,iv,e)\ - DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e)) -#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\ - DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e)) -#define des_cfb_encrypt(i,o,n,l,k,iv,e)\ - DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e)) -#define des_ecb_encrypt(i,o,k,e)\ - DES_ecb_encrypt((i),(o),&(k),(e)) -#define des_encrypt1(d,k,e)\ - DES_encrypt1((d),&(k),(e)) -#define des_encrypt2(d,k,e)\ - DES_encrypt2((d),&(k),(e)) -#define des_encrypt3(d,k1,k2,k3)\ - DES_encrypt3((d),&(k1),&(k2),&(k3)) -#define des_decrypt3(d,k1,k2,k3)\ - DES_decrypt3((d),&(k1),&(k2),&(k3)) -#define des_xwhite_in2out(k,i,o)\ - DES_xwhite_in2out((k),(i),(o)) -#define des_enc_read(f,b,l,k,iv)\ - DES_enc_read((f),(b),(l),&(k),(iv)) -#define des_enc_write(f,b,l,k,iv)\ - DES_enc_write((f),(b),(l),&(k),(iv)) -#define des_fcrypt(b,s,r)\ - DES_fcrypt((b),(s),(r)) -#if 0 -#define des_crypt(b,s)\ - DES_crypt((b),(s)) -#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__) -#define crypt(b,s)\ - DES_crypt((b),(s)) -#endif -#endif -#define des_ofb_encrypt(i,o,n,l,k,iv)\ - DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv)) -#define des_pcbc_encrypt(i,o,l,k,iv,e)\ - DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e)) -#define des_quad_cksum(i,o,l,c,s)\ - DES_quad_cksum((i),(o),(l),(c),(s)) -#define des_random_seed(k)\ - _ossl_096_des_random_seed((k)) -#define des_random_key(r)\ - DES_random_key((r)) -#define des_read_password(k,p,v) \ - DES_read_password((k),(p),(v)) -#define des_read_2passwords(k1,k2,p,v) \ - DES_read_2passwords((k1),(k2),(p),(v)) -#define des_set_odd_parity(k)\ - DES_set_odd_parity((k)) -#define des_check_key_parity(k)\ - DES_check_key_parity((k)) -#define des_is_weak_key(k)\ - DES_is_weak_key((k)) -#define des_set_key(k,ks)\ - DES_set_key((k),&(ks)) -#define des_key_sched(k,ks)\ - DES_key_sched((k),&(ks)) -#define des_set_key_checked(k,ks)\ - DES_set_key_checked((k),&(ks)) -#define des_set_key_unchecked(k,ks)\ - DES_set_key_unchecked((k),&(ks)) -#define des_string_to_key(s,k)\ - DES_string_to_key((s),(k)) -#define des_string_to_2keys(s,k1,k2)\ - DES_string_to_2keys((s),(k1),(k2)) -#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\ - DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e)) -#define des_ofb64_encrypt(i,o,l,ks,iv,n)\ - DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n)) - - -#define des_ecb2_encrypt(i,o,k1,k2,e) \ - des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) - -#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ - des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) - -#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ - des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) - -#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ - des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) - -#define des_check_key DES_check_key -#define des_rw_mode DES_rw_mode -#else /* libdes compatibility */ -/* Map all symbol names to _ossl_old_des_* form, so we avoid all - clashes with libdes */ -#define des_cblock _ossl_old_des_cblock -#define des_key_schedule _ossl_old_des_key_schedule -#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\ - _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e)) -#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\ - _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e)) -#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\ - _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e)) -#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\ - _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n)) -#define des_options()\ - _ossl_old_des_options() -#define des_cbc_cksum(i,o,l,k,iv)\ - _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv)) -#define des_cbc_encrypt(i,o,l,k,iv,e)\ - _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e)) -#define des_ncbc_encrypt(i,o,l,k,iv,e)\ - _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e)) -#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\ - _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e)) -#define des_cfb_encrypt(i,o,n,l,k,iv,e)\ - _ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e)) -#define des_ecb_encrypt(i,o,k,e)\ - _ossl_old_des_ecb_encrypt((i),(o),(k),(e)) -#define des_encrypt(d,k,e)\ - _ossl_old_des_encrypt((d),(k),(e)) -#define des_encrypt2(d,k,e)\ - _ossl_old_des_encrypt2((d),(k),(e)) -#define des_encrypt3(d,k1,k2,k3)\ - _ossl_old_des_encrypt3((d),(k1),(k2),(k3)) -#define des_decrypt3(d,k1,k2,k3)\ - _ossl_old_des_decrypt3((d),(k1),(k2),(k3)) -#define des_xwhite_in2out(k,i,o)\ - _ossl_old_des_xwhite_in2out((k),(i),(o)) -#define des_enc_read(f,b,l,k,iv)\ - _ossl_old_des_enc_read((f),(b),(l),(k),(iv)) -#define des_enc_write(f,b,l,k,iv)\ - _ossl_old_des_enc_write((f),(b),(l),(k),(iv)) -#define des_fcrypt(b,s,r)\ - _ossl_old_des_fcrypt((b),(s),(r)) -#define des_crypt(b,s)\ - _ossl_old_des_crypt((b),(s)) -#if 0 -#define crypt(b,s)\ - _ossl_old_crypt((b),(s)) -#endif -#define des_ofb_encrypt(i,o,n,l,k,iv)\ - _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv)) -#define des_pcbc_encrypt(i,o,l,k,iv,e)\ - _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e)) -#define des_quad_cksum(i,o,l,c,s)\ - _ossl_old_des_quad_cksum((i),(o),(l),(c),(s)) -#define des_random_seed(k)\ - _ossl_old_des_random_seed((k)) -#define des_random_key(r)\ - _ossl_old_des_random_key((r)) -#define des_read_password(k,p,v) \ - _ossl_old_des_read_password((k),(p),(v)) -#define des_read_2passwords(k1,k2,p,v) \ - _ossl_old_des_read_2passwords((k1),(k2),(p),(v)) -#define des_set_odd_parity(k)\ - _ossl_old_des_set_odd_parity((k)) -#define des_is_weak_key(k)\ - _ossl_old_des_is_weak_key((k)) -#define des_set_key(k,ks)\ - _ossl_old_des_set_key((k),(ks)) -#define des_key_sched(k,ks)\ - _ossl_old_des_key_sched((k),(ks)) -#define des_string_to_key(s,k)\ - _ossl_old_des_string_to_key((s),(k)) -#define des_string_to_2keys(s,k1,k2)\ - _ossl_old_des_string_to_2keys((s),(k1),(k2)) -#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\ - _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e)) -#define des_ofb64_encrypt(i,o,l,ks,iv,n)\ - _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n)) - - -#define des_ecb2_encrypt(i,o,k1,k2,e) \ - des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) - -#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ - des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) - -#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ - des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) - -#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ - des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) - -#define des_check_key DES_check_key -#define des_rw_mode DES_rw_mode -#endif - -const char *_ossl_old_des_options(void); -void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, - _ossl_old_des_key_schedule ks1,_ossl_old_des_key_schedule ks2, - _ossl_old_des_key_schedule ks3, int enc); -DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, - long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec); -void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, - _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); -void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, - _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); -void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, - _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec, - _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc); -void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits, - long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); -void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, - _ossl_old_des_key_schedule ks,int enc); -void _ossl_old_des_encrypt(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc); -void _ossl_old_des_encrypt2(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc); -void _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1, - _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3); -void _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1, - _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3); -void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output, - long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, - _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc); -void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out, - long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, - _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc); -void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, - long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, - _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num); - -void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white), - _ossl_old_des_cblock (*out_white)); - -int _ossl_old_des_enc_read(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, - _ossl_old_des_cblock *iv); -int _ossl_old_des_enc_write(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, - _ossl_old_des_cblock *iv); -char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret); -char *_ossl_old_des_crypt(const char *buf,const char *salt); -#if !defined(PERL5) && !defined(NeXT) -char *_ossl_old_crypt(const char *buf,const char *salt); -#endif -void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out, - int numbits,long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec); -void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, - _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); -DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, - long length,int out_count,_ossl_old_des_cblock *seed); -void _ossl_old_des_random_seed(_ossl_old_des_cblock key); -void _ossl_old_des_random_key(_ossl_old_des_cblock ret); -int _ossl_old_des_read_password(_ossl_old_des_cblock *key,const char *prompt,int verify); -int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2, - const char *prompt,int verify); -void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key); -int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key); -int _ossl_old_des_set_key(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule); -int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule); -void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key); -void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2); -void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, - _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc); -void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, - _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num); - -void _ossl_096_des_random_seed(des_cblock *key); - -/* The following definitions provide compatibility with the MIT Kerberos - * library. The _ossl_old_des_key_schedule structure is not binary compatible. */ - -#define _KERBEROS_DES_H - -#define KRBDES_ENCRYPT DES_ENCRYPT -#define KRBDES_DECRYPT DES_DECRYPT - -#ifdef KERBEROS -# define ENCRYPT DES_ENCRYPT -# define DECRYPT DES_DECRYPT -#endif - -#ifndef NCOMPAT -# define C_Block des_cblock -# define Key_schedule des_key_schedule -# define KEY_SZ DES_KEY_SZ -# define string_to_key des_string_to_key -# define read_pw_string des_read_pw_string -# define random_key des_random_key -# define pcbc_encrypt des_pcbc_encrypt -# define set_key des_set_key -# define key_sched des_key_sched -# define ecb_encrypt des_ecb_encrypt -# define cbc_encrypt des_cbc_encrypt -# define ncbc_encrypt des_ncbc_encrypt -# define xcbc_encrypt des_xcbc_encrypt -# define cbc_cksum des_cbc_cksum -# define quad_cksum des_quad_cksum -# define check_parity des_check_key_parity -#endif - -#define des_fixup_key_parity DES_fixup_key_parity - -#ifdef __cplusplus -} -#endif - -/* for DES_read_pw_string et al */ -#include - -#endif +/* crypto/des/des_old.h -*- mode:C; c-file-style: "eay" -*- */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * The function names in here are deprecated and are only present to + * provide an interface compatible with openssl 0.9.6 and older as + * well as libdes. OpenSSL now provides functions where "des_" has + * been replaced with "DES_" in the names, to make it possible to + * make incompatible changes that are needed for C type security and + * other stuff. + * + * This include files has two compatibility modes: + * + * - If OPENSSL_DES_LIBDES_COMPATIBILITY is defined, you get an API + * that is compatible with libdes and SSLeay. + * - If OPENSSL_DES_LIBDES_COMPATIBILITY isn't defined, you get an + * API that is compatible with OpenSSL 0.9.5x to 0.9.6x. + * + * Note that these modes break earlier snapshots of OpenSSL, where + * libdes compatibility was the only available mode or (later on) the + * prefered compatibility mode. However, after much consideration + * (and more or less violent discussions with external parties), it + * was concluded that OpenSSL should be compatible with earlier versions + * of itself before anything else. Also, in all honesty, libdes is + * an old beast that shouldn't really be used any more. + * + * Please consider starting to use the DES_ functions rather than the + * des_ ones. The des_ functions will disappear completely before + * OpenSSL 1.0! + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_DES_H +#define HEADER_DES_H + +#include /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */ + +#ifdef OPENSSL_NO_DES +#error DES is disabled. +#endif + +#ifndef HEADER_NEW_DES_H +#error You must include des.h, not des_old.h directly. +#endif + +#ifdef _KERBEROS_DES_H +#error replaces . +#endif + +#include + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _ +#undef _ +#endif + +typedef unsigned char _ossl_old_des_cblock[8]; +typedef struct _ossl_old_des_ks_struct + { + union { + _ossl_old_des_cblock _; + /* make sure things are correct size on machines with + * 8 byte longs */ + DES_LONG pad[2]; + } ks; + } _ossl_old_des_key_schedule[16]; + +#ifndef OPENSSL_DES_LIBDES_COMPATIBILITY +#define des_cblock DES_cblock +#define const_des_cblock const_DES_cblock +#define des_key_schedule DES_key_schedule +#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\ + DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e)) +#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\ + DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e)) +#define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\ + DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e)) +#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\ + DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e)) +#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\ + DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n)) +#define des_options()\ + DES_options() +#define des_cbc_cksum(i,o,l,k,iv)\ + DES_cbc_cksum((i),(o),(l),&(k),(iv)) +#define des_cbc_encrypt(i,o,l,k,iv,e)\ + DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_ncbc_encrypt(i,o,l,k,iv,e)\ + DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\ + DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e)) +#define des_cfb_encrypt(i,o,n,l,k,iv,e)\ + DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e)) +#define des_ecb_encrypt(i,o,k,e)\ + DES_ecb_encrypt((i),(o),&(k),(e)) +#define des_encrypt1(d,k,e)\ + DES_encrypt1((d),&(k),(e)) +#define des_encrypt2(d,k,e)\ + DES_encrypt2((d),&(k),(e)) +#define des_encrypt3(d,k1,k2,k3)\ + DES_encrypt3((d),&(k1),&(k2),&(k3)) +#define des_decrypt3(d,k1,k2,k3)\ + DES_decrypt3((d),&(k1),&(k2),&(k3)) +#define des_xwhite_in2out(k,i,o)\ + DES_xwhite_in2out((k),(i),(o)) +#define des_enc_read(f,b,l,k,iv)\ + DES_enc_read((f),(b),(l),&(k),(iv)) +#define des_enc_write(f,b,l,k,iv)\ + DES_enc_write((f),(b),(l),&(k),(iv)) +#define des_fcrypt(b,s,r)\ + DES_fcrypt((b),(s),(r)) +#if 0 +#define des_crypt(b,s)\ + DES_crypt((b),(s)) +#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__) +#define crypt(b,s)\ + DES_crypt((b),(s)) +#endif +#endif +#define des_ofb_encrypt(i,o,n,l,k,iv)\ + DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv)) +#define des_pcbc_encrypt(i,o,l,k,iv,e)\ + DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_quad_cksum(i,o,l,c,s)\ + DES_quad_cksum((i),(o),(l),(c),(s)) +#define des_random_seed(k)\ + _ossl_096_des_random_seed((k)) +#define des_random_key(r)\ + DES_random_key((r)) +#define des_read_password(k,p,v) \ + DES_read_password((k),(p),(v)) +#define des_read_2passwords(k1,k2,p,v) \ + DES_read_2passwords((k1),(k2),(p),(v)) +#define des_set_odd_parity(k)\ + DES_set_odd_parity((k)) +#define des_check_key_parity(k)\ + DES_check_key_parity((k)) +#define des_is_weak_key(k)\ + DES_is_weak_key((k)) +#define des_set_key(k,ks)\ + DES_set_key((k),&(ks)) +#define des_key_sched(k,ks)\ + DES_key_sched((k),&(ks)) +#define des_set_key_checked(k,ks)\ + DES_set_key_checked((k),&(ks)) +#define des_set_key_unchecked(k,ks)\ + DES_set_key_unchecked((k),&(ks)) +#define des_string_to_key(s,k)\ + DES_string_to_key((s),(k)) +#define des_string_to_2keys(s,k1,k2)\ + DES_string_to_2keys((s),(k1),(k2)) +#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\ + DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e)) +#define des_ofb64_encrypt(i,o,l,ks,iv,n)\ + DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n)) + + +#define des_ecb2_encrypt(i,o,k1,k2,e) \ + des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +#define des_check_key DES_check_key +#define des_rw_mode DES_rw_mode +#else /* libdes compatibility */ +/* Map all symbol names to _ossl_old_des_* form, so we avoid all + clashes with libdes */ +#define des_cblock _ossl_old_des_cblock +#define des_key_schedule _ossl_old_des_key_schedule +#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\ + _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e)) +#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\ + _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e)) +#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\ + _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e)) +#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\ + _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n)) +#define des_options()\ + _ossl_old_des_options() +#define des_cbc_cksum(i,o,l,k,iv)\ + _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv)) +#define des_cbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_ncbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\ + _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e)) +#define des_cfb_encrypt(i,o,n,l,k,iv,e)\ + _ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e)) +#define des_ecb_encrypt(i,o,k,e)\ + _ossl_old_des_ecb_encrypt((i),(o),(k),(e)) +#define des_encrypt(d,k,e)\ + _ossl_old_des_encrypt((d),(k),(e)) +#define des_encrypt2(d,k,e)\ + _ossl_old_des_encrypt2((d),(k),(e)) +#define des_encrypt3(d,k1,k2,k3)\ + _ossl_old_des_encrypt3((d),(k1),(k2),(k3)) +#define des_decrypt3(d,k1,k2,k3)\ + _ossl_old_des_decrypt3((d),(k1),(k2),(k3)) +#define des_xwhite_in2out(k,i,o)\ + _ossl_old_des_xwhite_in2out((k),(i),(o)) +#define des_enc_read(f,b,l,k,iv)\ + _ossl_old_des_enc_read((f),(b),(l),(k),(iv)) +#define des_enc_write(f,b,l,k,iv)\ + _ossl_old_des_enc_write((f),(b),(l),(k),(iv)) +#define des_fcrypt(b,s,r)\ + _ossl_old_des_fcrypt((b),(s),(r)) +#define des_crypt(b,s)\ + _ossl_old_des_crypt((b),(s)) +#if 0 +#define crypt(b,s)\ + _ossl_old_crypt((b),(s)) +#endif +#define des_ofb_encrypt(i,o,n,l,k,iv)\ + _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv)) +#define des_pcbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_quad_cksum(i,o,l,c,s)\ + _ossl_old_des_quad_cksum((i),(o),(l),(c),(s)) +#define des_random_seed(k)\ + _ossl_old_des_random_seed((k)) +#define des_random_key(r)\ + _ossl_old_des_random_key((r)) +#define des_read_password(k,p,v) \ + _ossl_old_des_read_password((k),(p),(v)) +#define des_read_2passwords(k1,k2,p,v) \ + _ossl_old_des_read_2passwords((k1),(k2),(p),(v)) +#define des_set_odd_parity(k)\ + _ossl_old_des_set_odd_parity((k)) +#define des_is_weak_key(k)\ + _ossl_old_des_is_weak_key((k)) +#define des_set_key(k,ks)\ + _ossl_old_des_set_key((k),(ks)) +#define des_key_sched(k,ks)\ + _ossl_old_des_key_sched((k),(ks)) +#define des_string_to_key(s,k)\ + _ossl_old_des_string_to_key((s),(k)) +#define des_string_to_2keys(s,k1,k2)\ + _ossl_old_des_string_to_2keys((s),(k1),(k2)) +#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\ + _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e)) +#define des_ofb64_encrypt(i,o,l,ks,iv,n)\ + _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n)) + + +#define des_ecb2_encrypt(i,o,k1,k2,e) \ + des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +#define des_check_key DES_check_key +#define des_rw_mode DES_rw_mode +#endif + +const char *_ossl_old_des_options(void); +void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + _ossl_old_des_key_schedule ks1,_ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, int enc); +DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec); +void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec, + _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc); +void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits, + long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + _ossl_old_des_key_schedule ks,int enc); +void _ossl_old_des_encrypt(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc); +void _ossl_old_des_encrypt2(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc); +void _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1, + _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3); +void _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1, + _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3); +void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc); +void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc); +void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num); + +void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white), + _ossl_old_des_cblock (*out_white)); + +int _ossl_old_des_enc_read(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, + _ossl_old_des_cblock *iv); +int _ossl_old_des_enc_write(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, + _ossl_old_des_cblock *iv); +char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret); +char *_ossl_old_des_crypt(const char *buf,const char *salt); +#if !defined(PERL5) && !defined(NeXT) +char *_ossl_old_crypt(const char *buf,const char *salt); +#endif +void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out, + int numbits,long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec); +void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + long length,int out_count,_ossl_old_des_cblock *seed); +void _ossl_old_des_random_seed(_ossl_old_des_cblock key); +void _ossl_old_des_random_key(_ossl_old_des_cblock ret); +int _ossl_old_des_read_password(_ossl_old_des_cblock *key,const char *prompt,int verify); +int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2, + const char *prompt,int verify); +void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key); +int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key); +int _ossl_old_des_set_key(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule); +int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule); +void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key); +void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2); +void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, + _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc); +void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, + _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num); + +void _ossl_096_des_random_seed(des_cblock *key); + +/* The following definitions provide compatibility with the MIT Kerberos + * library. The _ossl_old_des_key_schedule structure is not binary compatible. */ + +#define _KERBEROS_DES_H + +#define KRBDES_ENCRYPT DES_ENCRYPT +#define KRBDES_DECRYPT DES_DECRYPT + +#ifdef KERBEROS +# define ENCRYPT DES_ENCRYPT +# define DECRYPT DES_DECRYPT +#endif + +#ifndef NCOMPAT +# define C_Block des_cblock +# define Key_schedule des_key_schedule +# define KEY_SZ DES_KEY_SZ +# define string_to_key des_string_to_key +# define read_pw_string des_read_pw_string +# define random_key des_random_key +# define pcbc_encrypt des_pcbc_encrypt +# define set_key des_set_key +# define key_sched des_key_sched +# define ecb_encrypt des_ecb_encrypt +# define cbc_encrypt des_cbc_encrypt +# define ncbc_encrypt des_ncbc_encrypt +# define xcbc_encrypt des_xcbc_encrypt +# define cbc_cksum des_cbc_cksum +# define quad_cksum des_quad_cksum +# define check_parity des_check_key_parity +#endif + +#define des_fixup_key_parity DES_fixup_key_parity + +#ifdef __cplusplus +} +#endif + +/* for DES_read_pw_string et al */ +#include + +#endif diff --git a/src/dep/include/openssl/dh.h b/src/dep/include/openssl/dh.h index f630105..d6f1281 100644 --- a/src/dep/include/openssl/dh.h +++ b/src/dep/include/openssl/dh.h @@ -1,229 +1,229 @@ -/* crypto/dh/dh.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_DH_H -#define HEADER_DH_H - -#include - -#ifdef OPENSSL_NO_DH -#error DH is disabled. -#endif - -#ifndef OPENSSL_NO_BIO -#include -#endif -#include -#ifndef OPENSSL_NO_DEPRECATED -#include -#endif - -#define DH_FLAG_CACHE_MONT_P 0x01 -#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH - * implementation now uses constant time - * modular exponentiation for secret exponents - * by default. This flag causes the - * faster variable sliding window method to - * be used for all exponents. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Already defined in ossl_typ.h */ -/* typedef struct dh_st DH; */ -/* typedef struct dh_method DH_METHOD; */ - -struct dh_method - { - const char *name; - /* Methods here */ - int (*generate_key)(DH *dh); - int (*compute_key)(unsigned char *key,const BIGNUM *pub_key,DH *dh); - int (*bn_mod_exp)(const DH *dh, BIGNUM *r, const BIGNUM *a, - const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); /* Can be null */ - - int (*init)(DH *dh); - int (*finish)(DH *dh); - int flags; - char *app_data; - /* If this is non-NULL, it will be used to generate parameters */ - int (*generate_params)(DH *dh, int prime_len, int generator, BN_GENCB *cb); - }; - -struct dh_st - { - /* This first argument is used to pick up errors when - * a DH is passed instead of a EVP_PKEY */ - int pad; - int version; - BIGNUM *p; - BIGNUM *g; - long length; /* optional */ - BIGNUM *pub_key; /* g^x */ - BIGNUM *priv_key; /* x */ - - int flags; - BN_MONT_CTX *method_mont_p; - /* Place holders if we want to do X9.42 DH */ - BIGNUM *q; - BIGNUM *j; - unsigned char *seed; - int seedlen; - BIGNUM *counter; - - int references; - CRYPTO_EX_DATA ex_data; - const DH_METHOD *meth; - ENGINE *engine; - }; - -#define DH_GENERATOR_2 2 -/* #define DH_GENERATOR_3 3 */ -#define DH_GENERATOR_5 5 - -/* DH_check error codes */ -#define DH_CHECK_P_NOT_PRIME 0x01 -#define DH_CHECK_P_NOT_SAFE_PRIME 0x02 -#define DH_UNABLE_TO_CHECK_GENERATOR 0x04 -#define DH_NOT_SUITABLE_GENERATOR 0x08 - -/* DH_check_pub_key error codes */ -#define DH_CHECK_PUBKEY_TOO_SMALL 0x01 -#define DH_CHECK_PUBKEY_TOO_LARGE 0x02 - -/* primes p where (p-1)/2 is prime too are called "safe"; we define - this for backward compatibility: */ -#define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME - -#define DHparams_dup(x) ASN1_dup_of_const(DH,i2d_DHparams,d2i_DHparams,x) -#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ - (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x)) -#define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \ - (unsigned char *)(x)) -#define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x) -#define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x) - -const DH_METHOD *DH_OpenSSL(void); - -void DH_set_default_method(const DH_METHOD *meth); -const DH_METHOD *DH_get_default_method(void); -int DH_set_method(DH *dh, const DH_METHOD *meth); -DH *DH_new_method(ENGINE *engine); - -DH * DH_new(void); -void DH_free(DH *dh); -int DH_up_ref(DH *dh); -int DH_size(const DH *dh); -int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); -int DH_set_ex_data(DH *d, int idx, void *arg); -void *DH_get_ex_data(DH *d, int idx); - -/* Deprecated version */ -#ifndef OPENSSL_NO_DEPRECATED -DH * DH_generate_parameters(int prime_len,int generator, - void (*callback)(int,int,void *),void *cb_arg); -#endif /* !defined(OPENSSL_NO_DEPRECATED) */ - -/* New version */ -int DH_generate_parameters_ex(DH *dh, int prime_len,int generator, BN_GENCB *cb); - -int DH_check(const DH *dh,int *codes); -int DH_check_pub_key(const DH *dh,const BIGNUM *pub_key, int *codes); -int DH_generate_key(DH *dh); -int DH_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh); -DH * d2i_DHparams(DH **a,const unsigned char **pp, long length); -int i2d_DHparams(const DH *a,unsigned char **pp); -#ifndef OPENSSL_NO_FP_API -int DHparams_print_fp(FILE *fp, const DH *x); -#endif -#ifndef OPENSSL_NO_BIO -int DHparams_print(BIO *bp, const DH *x); -#else -int DHparams_print(char *bp, const DH *x); -#endif - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_DH_strings(void); - -/* Error codes for the DH functions. */ - -/* Function codes. */ -#define DH_F_COMPUTE_KEY 102 -#define DH_F_DHPARAMS_PRINT 100 -#define DH_F_DHPARAMS_PRINT_FP 101 -#define DH_F_DH_BUILTIN_GENPARAMS 106 -#define DH_F_DH_NEW_METHOD 105 -#define DH_F_GENERATE_KEY 103 -#define DH_F_GENERATE_PARAMETERS 104 - -/* Reason codes. */ -#define DH_R_BAD_GENERATOR 101 -#define DH_R_INVALID_PUBKEY 102 -#define DH_R_NO_PRIVATE_VALUE 100 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/dh/dh.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_DH_H +#define HEADER_DH_H + +#include + +#ifdef OPENSSL_NO_DH +#error DH is disabled. +#endif + +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#define DH_FLAG_CACHE_MONT_P 0x01 +#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH + * implementation now uses constant time + * modular exponentiation for secret exponents + * by default. This flag causes the + * faster variable sliding window method to + * be used for all exponents. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct dh_st DH; */ +/* typedef struct dh_method DH_METHOD; */ + +struct dh_method + { + const char *name; + /* Methods here */ + int (*generate_key)(DH *dh); + int (*compute_key)(unsigned char *key,const BIGNUM *pub_key,DH *dh); + int (*bn_mod_exp)(const DH *dh, BIGNUM *r, const BIGNUM *a, + const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); /* Can be null */ + + int (*init)(DH *dh); + int (*finish)(DH *dh); + int flags; + char *app_data; + /* If this is non-NULL, it will be used to generate parameters */ + int (*generate_params)(DH *dh, int prime_len, int generator, BN_GENCB *cb); + }; + +struct dh_st + { + /* This first argument is used to pick up errors when + * a DH is passed instead of a EVP_PKEY */ + int pad; + int version; + BIGNUM *p; + BIGNUM *g; + long length; /* optional */ + BIGNUM *pub_key; /* g^x */ + BIGNUM *priv_key; /* x */ + + int flags; + BN_MONT_CTX *method_mont_p; + /* Place holders if we want to do X9.42 DH */ + BIGNUM *q; + BIGNUM *j; + unsigned char *seed; + int seedlen; + BIGNUM *counter; + + int references; + CRYPTO_EX_DATA ex_data; + const DH_METHOD *meth; + ENGINE *engine; + }; + +#define DH_GENERATOR_2 2 +/* #define DH_GENERATOR_3 3 */ +#define DH_GENERATOR_5 5 + +/* DH_check error codes */ +#define DH_CHECK_P_NOT_PRIME 0x01 +#define DH_CHECK_P_NOT_SAFE_PRIME 0x02 +#define DH_UNABLE_TO_CHECK_GENERATOR 0x04 +#define DH_NOT_SUITABLE_GENERATOR 0x08 + +/* DH_check_pub_key error codes */ +#define DH_CHECK_PUBKEY_TOO_SMALL 0x01 +#define DH_CHECK_PUBKEY_TOO_LARGE 0x02 + +/* primes p where (p-1)/2 is prime too are called "safe"; we define + this for backward compatibility: */ +#define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME + +#define DHparams_dup(x) ASN1_dup_of_const(DH,i2d_DHparams,d2i_DHparams,x) +#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ + (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x)) +#define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \ + (unsigned char *)(x)) +#define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x) +#define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x) + +const DH_METHOD *DH_OpenSSL(void); + +void DH_set_default_method(const DH_METHOD *meth); +const DH_METHOD *DH_get_default_method(void); +int DH_set_method(DH *dh, const DH_METHOD *meth); +DH *DH_new_method(ENGINE *engine); + +DH * DH_new(void); +void DH_free(DH *dh); +int DH_up_ref(DH *dh); +int DH_size(const DH *dh); +int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int DH_set_ex_data(DH *d, int idx, void *arg); +void *DH_get_ex_data(DH *d, int idx); + +/* Deprecated version */ +#ifndef OPENSSL_NO_DEPRECATED +DH * DH_generate_parameters(int prime_len,int generator, + void (*callback)(int,int,void *),void *cb_arg); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* New version */ +int DH_generate_parameters_ex(DH *dh, int prime_len,int generator, BN_GENCB *cb); + +int DH_check(const DH *dh,int *codes); +int DH_check_pub_key(const DH *dh,const BIGNUM *pub_key, int *codes); +int DH_generate_key(DH *dh); +int DH_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh); +DH * d2i_DHparams(DH **a,const unsigned char **pp, long length); +int i2d_DHparams(const DH *a,unsigned char **pp); +#ifndef OPENSSL_NO_FP_API +int DHparams_print_fp(FILE *fp, const DH *x); +#endif +#ifndef OPENSSL_NO_BIO +int DHparams_print(BIO *bp, const DH *x); +#else +int DHparams_print(char *bp, const DH *x); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_DH_strings(void); + +/* Error codes for the DH functions. */ + +/* Function codes. */ +#define DH_F_COMPUTE_KEY 102 +#define DH_F_DHPARAMS_PRINT 100 +#define DH_F_DHPARAMS_PRINT_FP 101 +#define DH_F_DH_BUILTIN_GENPARAMS 106 +#define DH_F_DH_NEW_METHOD 105 +#define DH_F_GENERATE_KEY 103 +#define DH_F_GENERATE_PARAMETERS 104 + +/* Reason codes. */ +#define DH_R_BAD_GENERATOR 101 +#define DH_R_INVALID_PUBKEY 102 +#define DH_R_NO_PRIVATE_VALUE 100 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/dsa.h b/src/dep/include/openssl/dsa.h index 7fad10c..7b78588 100644 --- a/src/dep/include/openssl/dsa.h +++ b/src/dep/include/openssl/dsa.h @@ -1,279 +1,279 @@ -/* crypto/dsa/dsa.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -/* - * The DSS routines are based on patches supplied by - * Steven Schoch . He basically did the - * work and I have just tweaked them a little to fit into my - * stylistic vision for SSLeay :-) */ - -#ifndef HEADER_DSA_H -#define HEADER_DSA_H - -#include - -#ifdef OPENSSL_NO_DSA -#error DSA is disabled. -#endif - -#ifndef OPENSSL_NO_BIO -#include -#endif -#include -#include - -#ifndef OPENSSL_NO_DEPRECATED -#include -#ifndef OPENSSL_NO_DH -# include -#endif -#endif - -#define DSA_FLAG_CACHE_MONT_P 0x01 -#define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA - * implementation now uses constant time - * modular exponentiation for secret exponents - * by default. This flag causes the - * faster variable sliding window method to - * be used for all exponents. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Already defined in ossl_typ.h */ -/* typedef struct dsa_st DSA; */ -/* typedef struct dsa_method DSA_METHOD; */ - -typedef struct DSA_SIG_st - { - BIGNUM *r; - BIGNUM *s; - } DSA_SIG; - -struct dsa_method - { - const char *name; - DSA_SIG * (*dsa_do_sign)(const unsigned char *dgst, int dlen, DSA *dsa); - int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, - BIGNUM **rp); - int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len, - DSA_SIG *sig, DSA *dsa); - int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, - BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *in_mont); - int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); /* Can be null */ - int (*init)(DSA *dsa); - int (*finish)(DSA *dsa); - int flags; - char *app_data; - /* If this is non-NULL, it is used to generate DSA parameters */ - int (*dsa_paramgen)(DSA *dsa, int bits, - unsigned char *seed, int seed_len, - int *counter_ret, unsigned long *h_ret, - BN_GENCB *cb); - /* If this is non-NULL, it is used to generate DSA keys */ - int (*dsa_keygen)(DSA *dsa); - }; - -struct dsa_st - { - /* This first variable is used to pick up errors where - * a DSA is passed instead of of a EVP_PKEY */ - int pad; - long version; - int write_params; - BIGNUM *p; - BIGNUM *q; /* == 20 */ - BIGNUM *g; - - BIGNUM *pub_key; /* y public key */ - BIGNUM *priv_key; /* x private key */ - - BIGNUM *kinv; /* Signing pre-calc */ - BIGNUM *r; /* Signing pre-calc */ - - int flags; - /* Normally used to cache montgomery values */ - BN_MONT_CTX *method_mont_p; - int references; - CRYPTO_EX_DATA ex_data; - const DSA_METHOD *meth; - /* functional reference if 'meth' is ENGINE-provided */ - ENGINE *engine; - }; - -#define DSAparams_dup(x) ASN1_dup_of_const(DSA,i2d_DSAparams,d2i_DSAparams,x) -#define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \ - (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x)) -#define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \ - (unsigned char *)(x)) -#define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x) -#define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x) - - -DSA_SIG * DSA_SIG_new(void); -void DSA_SIG_free(DSA_SIG *a); -int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); -DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length); - -DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa); -int DSA_do_verify(const unsigned char *dgst,int dgst_len, - DSA_SIG *sig,DSA *dsa); - -const DSA_METHOD *DSA_OpenSSL(void); - -void DSA_set_default_method(const DSA_METHOD *); -const DSA_METHOD *DSA_get_default_method(void); -int DSA_set_method(DSA *dsa, const DSA_METHOD *); - -DSA * DSA_new(void); -DSA * DSA_new_method(ENGINE *engine); -void DSA_free (DSA *r); -/* "up" the DSA object's reference count */ -int DSA_up_ref(DSA *r); -int DSA_size(const DSA *); - /* next 4 return -1 on error */ -int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp); -int DSA_sign(int type,const unsigned char *dgst,int dlen, - unsigned char *sig, unsigned int *siglen, DSA *dsa); -int DSA_verify(int type,const unsigned char *dgst,int dgst_len, - const unsigned char *sigbuf, int siglen, DSA *dsa); -int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); -int DSA_set_ex_data(DSA *d, int idx, void *arg); -void *DSA_get_ex_data(DSA *d, int idx); - -DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length); -DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length); -DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length); - -/* Deprecated version */ -#ifndef OPENSSL_NO_DEPRECATED -DSA * DSA_generate_parameters(int bits, - unsigned char *seed,int seed_len, - int *counter_ret, unsigned long *h_ret,void - (*callback)(int, int, void *),void *cb_arg); -#endif /* !defined(OPENSSL_NO_DEPRECATED) */ - -/* New version */ -int DSA_generate_parameters_ex(DSA *dsa, int bits, - unsigned char *seed,int seed_len, - int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); - -int DSA_generate_key(DSA *a); -int i2d_DSAPublicKey(const DSA *a, unsigned char **pp); -int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp); -int i2d_DSAparams(const DSA *a,unsigned char **pp); - -#ifndef OPENSSL_NO_BIO -int DSAparams_print(BIO *bp, const DSA *x); -int DSA_print(BIO *bp, const DSA *x, int off); -#endif -#ifndef OPENSSL_NO_FP_API -int DSAparams_print_fp(FILE *fp, const DSA *x); -int DSA_print_fp(FILE *bp, const DSA *x, int off); -#endif - -#define DSS_prime_checks 50 -/* Primality test according to FIPS PUB 186[-1], Appendix 2.1: - * 50 rounds of Rabin-Miller */ -#define DSA_is_prime(n, callback, cb_arg) \ - BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg) - -#ifndef OPENSSL_NO_DH -/* Convert DSA structure (key or just parameters) into DH structure - * (be careful to avoid small subgroup attacks when using this!) */ -DH *DSA_dup_DH(const DSA *r); -#endif - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_DSA_strings(void); - -/* Error codes for the DSA functions. */ - -/* Function codes. */ -#define DSA_F_D2I_DSA_SIG 110 -#define DSA_F_DSAPARAMS_PRINT 100 -#define DSA_F_DSAPARAMS_PRINT_FP 101 -#define DSA_F_DSA_DO_SIGN 112 -#define DSA_F_DSA_DO_VERIFY 113 -#define DSA_F_DSA_NEW_METHOD 103 -#define DSA_F_DSA_PRINT 104 -#define DSA_F_DSA_PRINT_FP 105 -#define DSA_F_DSA_SIGN 106 -#define DSA_F_DSA_SIGN_SETUP 107 -#define DSA_F_DSA_SIG_NEW 109 -#define DSA_F_DSA_VERIFY 108 -#define DSA_F_I2D_DSA_SIG 111 -#define DSA_F_SIG_CB 114 - -/* Reason codes. */ -#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 -#define DSA_R_MISSING_PARAMETERS 101 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/dsa/dsa.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* + * The DSS routines are based on patches supplied by + * Steven Schoch . He basically did the + * work and I have just tweaked them a little to fit into my + * stylistic vision for SSLeay :-) */ + +#ifndef HEADER_DSA_H +#define HEADER_DSA_H + +#include + +#ifdef OPENSSL_NO_DSA +#error DSA is disabled. +#endif + +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include + +#ifndef OPENSSL_NO_DEPRECATED +#include +#ifndef OPENSSL_NO_DH +# include +#endif +#endif + +#define DSA_FLAG_CACHE_MONT_P 0x01 +#define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA + * implementation now uses constant time + * modular exponentiation for secret exponents + * by default. This flag causes the + * faster variable sliding window method to + * be used for all exponents. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct dsa_st DSA; */ +/* typedef struct dsa_method DSA_METHOD; */ + +typedef struct DSA_SIG_st + { + BIGNUM *r; + BIGNUM *s; + } DSA_SIG; + +struct dsa_method + { + const char *name; + DSA_SIG * (*dsa_do_sign)(const unsigned char *dgst, int dlen, DSA *dsa); + int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, + BIGNUM **rp); + int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len, + DSA_SIG *sig, DSA *dsa); + int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, + BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *in_mont); + int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); /* Can be null */ + int (*init)(DSA *dsa); + int (*finish)(DSA *dsa); + int flags; + char *app_data; + /* If this is non-NULL, it is used to generate DSA parameters */ + int (*dsa_paramgen)(DSA *dsa, int bits, + unsigned char *seed, int seed_len, + int *counter_ret, unsigned long *h_ret, + BN_GENCB *cb); + /* If this is non-NULL, it is used to generate DSA keys */ + int (*dsa_keygen)(DSA *dsa); + }; + +struct dsa_st + { + /* This first variable is used to pick up errors where + * a DSA is passed instead of of a EVP_PKEY */ + int pad; + long version; + int write_params; + BIGNUM *p; + BIGNUM *q; /* == 20 */ + BIGNUM *g; + + BIGNUM *pub_key; /* y public key */ + BIGNUM *priv_key; /* x private key */ + + BIGNUM *kinv; /* Signing pre-calc */ + BIGNUM *r; /* Signing pre-calc */ + + int flags; + /* Normally used to cache montgomery values */ + BN_MONT_CTX *method_mont_p; + int references; + CRYPTO_EX_DATA ex_data; + const DSA_METHOD *meth; + /* functional reference if 'meth' is ENGINE-provided */ + ENGINE *engine; + }; + +#define DSAparams_dup(x) ASN1_dup_of_const(DSA,i2d_DSAparams,d2i_DSAparams,x) +#define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \ + (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x)) +#define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \ + (unsigned char *)(x)) +#define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x) +#define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x) + + +DSA_SIG * DSA_SIG_new(void); +void DSA_SIG_free(DSA_SIG *a); +int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); +DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length); + +DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa); +int DSA_do_verify(const unsigned char *dgst,int dgst_len, + DSA_SIG *sig,DSA *dsa); + +const DSA_METHOD *DSA_OpenSSL(void); + +void DSA_set_default_method(const DSA_METHOD *); +const DSA_METHOD *DSA_get_default_method(void); +int DSA_set_method(DSA *dsa, const DSA_METHOD *); + +DSA * DSA_new(void); +DSA * DSA_new_method(ENGINE *engine); +void DSA_free (DSA *r); +/* "up" the DSA object's reference count */ +int DSA_up_ref(DSA *r); +int DSA_size(const DSA *); + /* next 4 return -1 on error */ +int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp); +int DSA_sign(int type,const unsigned char *dgst,int dlen, + unsigned char *sig, unsigned int *siglen, DSA *dsa); +int DSA_verify(int type,const unsigned char *dgst,int dgst_len, + const unsigned char *sigbuf, int siglen, DSA *dsa); +int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int DSA_set_ex_data(DSA *d, int idx, void *arg); +void *DSA_get_ex_data(DSA *d, int idx); + +DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length); +DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length); +DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length); + +/* Deprecated version */ +#ifndef OPENSSL_NO_DEPRECATED +DSA * DSA_generate_parameters(int bits, + unsigned char *seed,int seed_len, + int *counter_ret, unsigned long *h_ret,void + (*callback)(int, int, void *),void *cb_arg); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* New version */ +int DSA_generate_parameters_ex(DSA *dsa, int bits, + unsigned char *seed,int seed_len, + int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); + +int DSA_generate_key(DSA *a); +int i2d_DSAPublicKey(const DSA *a, unsigned char **pp); +int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp); +int i2d_DSAparams(const DSA *a,unsigned char **pp); + +#ifndef OPENSSL_NO_BIO +int DSAparams_print(BIO *bp, const DSA *x); +int DSA_print(BIO *bp, const DSA *x, int off); +#endif +#ifndef OPENSSL_NO_FP_API +int DSAparams_print_fp(FILE *fp, const DSA *x); +int DSA_print_fp(FILE *bp, const DSA *x, int off); +#endif + +#define DSS_prime_checks 50 +/* Primality test according to FIPS PUB 186[-1], Appendix 2.1: + * 50 rounds of Rabin-Miller */ +#define DSA_is_prime(n, callback, cb_arg) \ + BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg) + +#ifndef OPENSSL_NO_DH +/* Convert DSA structure (key or just parameters) into DH structure + * (be careful to avoid small subgroup attacks when using this!) */ +DH *DSA_dup_DH(const DSA *r); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_DSA_strings(void); + +/* Error codes for the DSA functions. */ + +/* Function codes. */ +#define DSA_F_D2I_DSA_SIG 110 +#define DSA_F_DSAPARAMS_PRINT 100 +#define DSA_F_DSAPARAMS_PRINT_FP 101 +#define DSA_F_DSA_DO_SIGN 112 +#define DSA_F_DSA_DO_VERIFY 113 +#define DSA_F_DSA_NEW_METHOD 103 +#define DSA_F_DSA_PRINT 104 +#define DSA_F_DSA_PRINT_FP 105 +#define DSA_F_DSA_SIGN 106 +#define DSA_F_DSA_SIGN_SETUP 107 +#define DSA_F_DSA_SIG_NEW 109 +#define DSA_F_DSA_VERIFY 108 +#define DSA_F_I2D_DSA_SIG 111 +#define DSA_F_SIG_CB 114 + +/* Reason codes. */ +#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 +#define DSA_R_MISSING_PARAMETERS 101 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/dso.h b/src/dep/include/openssl/dso.h index 8909a39..a0843cb 100644 --- a/src/dep/include/openssl/dso.h +++ b/src/dep/include/openssl/dso.h @@ -1,368 +1,368 @@ -/* dso.h -*- mode:C; c-file-style: "eay" -*- */ -/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL - * project 2000. - */ -/* ==================================================================== - * Copyright (c) 2000 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_DSO_H -#define HEADER_DSO_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* These values are used as commands to DSO_ctrl() */ -#define DSO_CTRL_GET_FLAGS 1 -#define DSO_CTRL_SET_FLAGS 2 -#define DSO_CTRL_OR_FLAGS 3 - -/* By default, DSO_load() will translate the provided filename into a form - * typical for the platform (more specifically the DSO_METHOD) using the - * dso_name_converter function of the method. Eg. win32 will transform "blah" - * into "blah.dll", and dlfcn will transform it into "libblah.so". The - * behaviour can be overriden by setting the name_converter callback in the DSO - * object (using DSO_set_name_converter()). This callback could even utilise - * the DSO_METHOD's converter too if it only wants to override behaviour for - * one or two possible DSO methods. However, the following flag can be set in a - * DSO to prevent *any* native name-translation at all - eg. if the caller has - * prompted the user for a path to a driver library so the filename should be - * interpreted as-is. */ -#define DSO_FLAG_NO_NAME_TRANSLATION 0x01 -/* An extra flag to give if only the extension should be added as - * translation. This is obviously only of importance on Unix and - * other operating systems where the translation also may prefix - * the name with something, like 'lib', and ignored everywhere else. - * This flag is also ignored if DSO_FLAG_NO_NAME_TRANSLATION is used - * at the same time. */ -#define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY 0x02 - -/* The following flag controls the translation of symbol names to upper - * case. This is currently only being implemented for OpenVMS. - */ -#define DSO_FLAG_UPCASE_SYMBOL 0x10 - -/* This flag loads the library with public symbols. - * Meaning: The exported symbols of this library are public - * to all libraries loaded after this library. - * At the moment only implemented in unix. - */ -#define DSO_FLAG_GLOBAL_SYMBOLS 0x20 - - -typedef void (*DSO_FUNC_TYPE)(void); - -typedef struct dso_st DSO; - -/* The function prototype used for method functions (or caller-provided - * callbacks) that transform filenames. They are passed a DSO structure pointer - * (or NULL if they are to be used independantly of a DSO object) and a - * filename to transform. They should either return NULL (if there is an error - * condition) or a newly allocated string containing the transformed form that - * the caller will need to free with OPENSSL_free() when done. */ -typedef char* (*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *); -/* The function prototype used for method functions (or caller-provided - * callbacks) that merge two file specifications. They are passed a - * DSO structure pointer (or NULL if they are to be used independantly of - * a DSO object) and two file specifications to merge. They should - * either return NULL (if there is an error condition) or a newly allocated - * string containing the result of merging that the caller will need - * to free with OPENSSL_free() when done. - * Here, merging means that bits and pieces are taken from each of the - * file specifications and added together in whatever fashion that is - * sensible for the DSO method in question. The only rule that really - * applies is that if the two specification contain pieces of the same - * type, the copy from the first string takes priority. One could see - * it as the first specification is the one given by the user and the - * second being a bunch of defaults to add on if they're missing in the - * first. */ -typedef char* (*DSO_MERGER_FUNC)(DSO *, const char *, const char *); - -typedef struct dso_meth_st - { - const char *name; - /* Loads a shared library, NB: new DSO_METHODs must ensure that a - * successful load populates the loaded_filename field, and likewise a - * successful unload OPENSSL_frees and NULLs it out. */ - int (*dso_load)(DSO *dso); - /* Unloads a shared library */ - int (*dso_unload)(DSO *dso); - /* Binds a variable */ - void *(*dso_bind_var)(DSO *dso, const char *symname); - /* Binds a function - assumes a return type of DSO_FUNC_TYPE. - * This should be cast to the real function prototype by the - * caller. Platforms that don't have compatible representations - * for different prototypes (this is possible within ANSI C) - * are highly unlikely to have shared libraries at all, let - * alone a DSO_METHOD implemented for them. */ - DSO_FUNC_TYPE (*dso_bind_func)(DSO *dso, const char *symname); - -/* I don't think this would actually be used in any circumstances. */ -#if 0 - /* Unbinds a variable */ - int (*dso_unbind_var)(DSO *dso, char *symname, void *symptr); - /* Unbinds a function */ - int (*dso_unbind_func)(DSO *dso, char *symname, DSO_FUNC_TYPE symptr); -#endif - /* The generic (yuck) "ctrl()" function. NB: Negative return - * values (rather than zero) indicate errors. */ - long (*dso_ctrl)(DSO *dso, int cmd, long larg, void *parg); - /* The default DSO_METHOD-specific function for converting filenames to - * a canonical native form. */ - DSO_NAME_CONVERTER_FUNC dso_name_converter; - /* The default DSO_METHOD-specific function for converting filenames to - * a canonical native form. */ - DSO_MERGER_FUNC dso_merger; - - /* [De]Initialisation handlers. */ - int (*init)(DSO *dso); - int (*finish)(DSO *dso); - } DSO_METHOD; - -/**********************************************************************/ -/* The low-level handle type used to refer to a loaded shared library */ - -struct dso_st - { - DSO_METHOD *meth; - /* Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS - * doesn't use anything but will need to cache the filename - * for use in the dso_bind handler. All in all, let each - * method control its own destiny. "Handles" and such go in - * a STACK. */ - STACK *meth_data; - int references; - int flags; - /* For use by applications etc ... use this for your bits'n'pieces, - * don't touch meth_data! */ - CRYPTO_EX_DATA ex_data; - /* If this callback function pointer is set to non-NULL, then it will - * be used in DSO_load() in place of meth->dso_name_converter. NB: This - * should normally set using DSO_set_name_converter(). */ - DSO_NAME_CONVERTER_FUNC name_converter; - /* If this callback function pointer is set to non-NULL, then it will - * be used in DSO_load() in place of meth->dso_merger. NB: This - * should normally set using DSO_set_merger(). */ - DSO_MERGER_FUNC merger; - /* This is populated with (a copy of) the platform-independant - * filename used for this DSO. */ - char *filename; - /* This is populated with (a copy of) the translated filename by which - * the DSO was actually loaded. It is NULL iff the DSO is not currently - * loaded. NB: This is here because the filename translation process - * may involve a callback being invoked more than once not only to - * convert to a platform-specific form, but also to try different - * filenames in the process of trying to perform a load. As such, this - * variable can be used to indicate (a) whether this DSO structure - * corresponds to a loaded library or not, and (b) the filename with - * which it was actually loaded. */ - char *loaded_filename; - }; - - -DSO * DSO_new(void); -DSO * DSO_new_method(DSO_METHOD *method); -int DSO_free(DSO *dso); -int DSO_flags(DSO *dso); -int DSO_up_ref(DSO *dso); -long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg); - -/* This function sets the DSO's name_converter callback. If it is non-NULL, - * then it will be used instead of the associated DSO_METHOD's function. If - * oldcb is non-NULL then it is set to the function pointer value being - * replaced. Return value is non-zero for success. */ -int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb, - DSO_NAME_CONVERTER_FUNC *oldcb); -/* These functions can be used to get/set the platform-independant filename - * used for a DSO. NB: set will fail if the DSO is already loaded. */ -const char *DSO_get_filename(DSO *dso); -int DSO_set_filename(DSO *dso, const char *filename); -/* This function will invoke the DSO's name_converter callback to translate a - * filename, or if the callback isn't set it will instead use the DSO_METHOD's - * converter. If "filename" is NULL, the "filename" in the DSO itself will be - * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is - * simply duplicated. NB: This function is usually called from within a - * DSO_METHOD during the processing of a DSO_load() call, and is exposed so that - * caller-created DSO_METHODs can do the same thing. A non-NULL return value - * will need to be OPENSSL_free()'d. */ -char *DSO_convert_filename(DSO *dso, const char *filename); -/* This function will invoke the DSO's merger callback to merge two file - * specifications, or if the callback isn't set it will instead use the - * DSO_METHOD's merger. A non-NULL return value will need to be - * OPENSSL_free()'d. */ -char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2); -/* If the DSO is currently loaded, this returns the filename that it was loaded - * under, otherwise it returns NULL. So it is also useful as a test as to - * whether the DSO is currently loaded. NB: This will not necessarily return - * the same value as DSO_convert_filename(dso, dso->filename), because the - * DSO_METHOD's load function may have tried a variety of filenames (with - * and/or without the aid of the converters) before settling on the one it - * actually loaded. */ -const char *DSO_get_loaded_filename(DSO *dso); - -void DSO_set_default_method(DSO_METHOD *meth); -DSO_METHOD *DSO_get_default_method(void); -DSO_METHOD *DSO_get_method(DSO *dso); -DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth); - -/* The all-singing all-dancing load function, you normally pass NULL - * for the first and third parameters. Use DSO_up and DSO_free for - * subsequent reference count handling. Any flags passed in will be set - * in the constructed DSO after its init() function but before the - * load operation. If 'dso' is non-NULL, 'flags' is ignored. */ -DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags); - -/* This function binds to a variable inside a shared library. */ -void *DSO_bind_var(DSO *dso, const char *symname); - -/* This function binds to a function inside a shared library. */ -DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname); - -/* This method is the default, but will beg, borrow, or steal whatever - * method should be the default on any particular platform (including - * DSO_METH_null() if necessary). */ -DSO_METHOD *DSO_METHOD_openssl(void); - -/* This method is defined for all platforms - if a platform has no - * DSO support then this will be the only method! */ -DSO_METHOD *DSO_METHOD_null(void); - -/* If DSO_DLFCN is defined, the standard dlfcn.h-style functions - * (dlopen, dlclose, dlsym, etc) will be used and incorporated into - * this method. If not, this method will return NULL. */ -DSO_METHOD *DSO_METHOD_dlfcn(void); - -/* If DSO_DL is defined, the standard dl.h-style functions (shl_load, - * shl_unload, shl_findsym, etc) will be used and incorporated into - * this method. If not, this method will return NULL. */ -DSO_METHOD *DSO_METHOD_dl(void); - -/* If WIN32 is defined, use DLLs. If not, return NULL. */ -DSO_METHOD *DSO_METHOD_win32(void); - -/* If VMS is defined, use shared images. If not, return NULL. */ -DSO_METHOD *DSO_METHOD_vms(void); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_DSO_strings(void); - -/* Error codes for the DSO functions. */ - -/* Function codes. */ -#define DSO_F_DLFCN_BIND_FUNC 100 -#define DSO_F_DLFCN_BIND_VAR 101 -#define DSO_F_DLFCN_LOAD 102 -#define DSO_F_DLFCN_MERGER 130 -#define DSO_F_DLFCN_NAME_CONVERTER 123 -#define DSO_F_DLFCN_UNLOAD 103 -#define DSO_F_DL_BIND_FUNC 104 -#define DSO_F_DL_BIND_VAR 105 -#define DSO_F_DL_LOAD 106 -#define DSO_F_DL_MERGER 131 -#define DSO_F_DL_NAME_CONVERTER 124 -#define DSO_F_DL_UNLOAD 107 -#define DSO_F_DSO_BIND_FUNC 108 -#define DSO_F_DSO_BIND_VAR 109 -#define DSO_F_DSO_CONVERT_FILENAME 126 -#define DSO_F_DSO_CTRL 110 -#define DSO_F_DSO_FREE 111 -#define DSO_F_DSO_GET_FILENAME 127 -#define DSO_F_DSO_GET_LOADED_FILENAME 128 -#define DSO_F_DSO_LOAD 112 -#define DSO_F_DSO_MERGE 132 -#define DSO_F_DSO_NEW_METHOD 113 -#define DSO_F_DSO_SET_FILENAME 129 -#define DSO_F_DSO_SET_NAME_CONVERTER 122 -#define DSO_F_DSO_UP_REF 114 -#define DSO_F_VMS_BIND_SYM 115 -#define DSO_F_VMS_LOAD 116 -#define DSO_F_VMS_MERGER 133 -#define DSO_F_VMS_UNLOAD 117 -#define DSO_F_WIN32_BIND_FUNC 118 -#define DSO_F_WIN32_BIND_VAR 119 -#define DSO_F_WIN32_JOINER 135 -#define DSO_F_WIN32_LOAD 120 -#define DSO_F_WIN32_MERGER 134 -#define DSO_F_WIN32_NAME_CONVERTER 125 -#define DSO_F_WIN32_SPLITTER 136 -#define DSO_F_WIN32_UNLOAD 121 - -/* Reason codes. */ -#define DSO_R_CTRL_FAILED 100 -#define DSO_R_DSO_ALREADY_LOADED 110 -#define DSO_R_EMPTY_FILE_STRUCTURE 113 -#define DSO_R_FAILURE 114 -#define DSO_R_FILENAME_TOO_BIG 101 -#define DSO_R_FINISH_FAILED 102 -#define DSO_R_INCORRECT_FILE_SYNTAX 115 -#define DSO_R_LOAD_FAILED 103 -#define DSO_R_NAME_TRANSLATION_FAILED 109 -#define DSO_R_NO_FILENAME 111 -#define DSO_R_NO_FILE_SPECIFICATION 116 -#define DSO_R_NULL_HANDLE 104 -#define DSO_R_SET_FILENAME_FAILED 112 -#define DSO_R_STACK_ERROR 105 -#define DSO_R_SYM_FAILURE 106 -#define DSO_R_UNLOAD_FAILED 107 -#define DSO_R_UNSUPPORTED 108 - -#ifdef __cplusplus -} -#endif -#endif +/* dso.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_DSO_H +#define HEADER_DSO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These values are used as commands to DSO_ctrl() */ +#define DSO_CTRL_GET_FLAGS 1 +#define DSO_CTRL_SET_FLAGS 2 +#define DSO_CTRL_OR_FLAGS 3 + +/* By default, DSO_load() will translate the provided filename into a form + * typical for the platform (more specifically the DSO_METHOD) using the + * dso_name_converter function of the method. Eg. win32 will transform "blah" + * into "blah.dll", and dlfcn will transform it into "libblah.so". The + * behaviour can be overriden by setting the name_converter callback in the DSO + * object (using DSO_set_name_converter()). This callback could even utilise + * the DSO_METHOD's converter too if it only wants to override behaviour for + * one or two possible DSO methods. However, the following flag can be set in a + * DSO to prevent *any* native name-translation at all - eg. if the caller has + * prompted the user for a path to a driver library so the filename should be + * interpreted as-is. */ +#define DSO_FLAG_NO_NAME_TRANSLATION 0x01 +/* An extra flag to give if only the extension should be added as + * translation. This is obviously only of importance on Unix and + * other operating systems where the translation also may prefix + * the name with something, like 'lib', and ignored everywhere else. + * This flag is also ignored if DSO_FLAG_NO_NAME_TRANSLATION is used + * at the same time. */ +#define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY 0x02 + +/* The following flag controls the translation of symbol names to upper + * case. This is currently only being implemented for OpenVMS. + */ +#define DSO_FLAG_UPCASE_SYMBOL 0x10 + +/* This flag loads the library with public symbols. + * Meaning: The exported symbols of this library are public + * to all libraries loaded after this library. + * At the moment only implemented in unix. + */ +#define DSO_FLAG_GLOBAL_SYMBOLS 0x20 + + +typedef void (*DSO_FUNC_TYPE)(void); + +typedef struct dso_st DSO; + +/* The function prototype used for method functions (or caller-provided + * callbacks) that transform filenames. They are passed a DSO structure pointer + * (or NULL if they are to be used independantly of a DSO object) and a + * filename to transform. They should either return NULL (if there is an error + * condition) or a newly allocated string containing the transformed form that + * the caller will need to free with OPENSSL_free() when done. */ +typedef char* (*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *); +/* The function prototype used for method functions (or caller-provided + * callbacks) that merge two file specifications. They are passed a + * DSO structure pointer (or NULL if they are to be used independantly of + * a DSO object) and two file specifications to merge. They should + * either return NULL (if there is an error condition) or a newly allocated + * string containing the result of merging that the caller will need + * to free with OPENSSL_free() when done. + * Here, merging means that bits and pieces are taken from each of the + * file specifications and added together in whatever fashion that is + * sensible for the DSO method in question. The only rule that really + * applies is that if the two specification contain pieces of the same + * type, the copy from the first string takes priority. One could see + * it as the first specification is the one given by the user and the + * second being a bunch of defaults to add on if they're missing in the + * first. */ +typedef char* (*DSO_MERGER_FUNC)(DSO *, const char *, const char *); + +typedef struct dso_meth_st + { + const char *name; + /* Loads a shared library, NB: new DSO_METHODs must ensure that a + * successful load populates the loaded_filename field, and likewise a + * successful unload OPENSSL_frees and NULLs it out. */ + int (*dso_load)(DSO *dso); + /* Unloads a shared library */ + int (*dso_unload)(DSO *dso); + /* Binds a variable */ + void *(*dso_bind_var)(DSO *dso, const char *symname); + /* Binds a function - assumes a return type of DSO_FUNC_TYPE. + * This should be cast to the real function prototype by the + * caller. Platforms that don't have compatible representations + * for different prototypes (this is possible within ANSI C) + * are highly unlikely to have shared libraries at all, let + * alone a DSO_METHOD implemented for them. */ + DSO_FUNC_TYPE (*dso_bind_func)(DSO *dso, const char *symname); + +/* I don't think this would actually be used in any circumstances. */ +#if 0 + /* Unbinds a variable */ + int (*dso_unbind_var)(DSO *dso, char *symname, void *symptr); + /* Unbinds a function */ + int (*dso_unbind_func)(DSO *dso, char *symname, DSO_FUNC_TYPE symptr); +#endif + /* The generic (yuck) "ctrl()" function. NB: Negative return + * values (rather than zero) indicate errors. */ + long (*dso_ctrl)(DSO *dso, int cmd, long larg, void *parg); + /* The default DSO_METHOD-specific function for converting filenames to + * a canonical native form. */ + DSO_NAME_CONVERTER_FUNC dso_name_converter; + /* The default DSO_METHOD-specific function for converting filenames to + * a canonical native form. */ + DSO_MERGER_FUNC dso_merger; + + /* [De]Initialisation handlers. */ + int (*init)(DSO *dso); + int (*finish)(DSO *dso); + } DSO_METHOD; + +/**********************************************************************/ +/* The low-level handle type used to refer to a loaded shared library */ + +struct dso_st + { + DSO_METHOD *meth; + /* Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS + * doesn't use anything but will need to cache the filename + * for use in the dso_bind handler. All in all, let each + * method control its own destiny. "Handles" and such go in + * a STACK. */ + STACK *meth_data; + int references; + int flags; + /* For use by applications etc ... use this for your bits'n'pieces, + * don't touch meth_data! */ + CRYPTO_EX_DATA ex_data; + /* If this callback function pointer is set to non-NULL, then it will + * be used in DSO_load() in place of meth->dso_name_converter. NB: This + * should normally set using DSO_set_name_converter(). */ + DSO_NAME_CONVERTER_FUNC name_converter; + /* If this callback function pointer is set to non-NULL, then it will + * be used in DSO_load() in place of meth->dso_merger. NB: This + * should normally set using DSO_set_merger(). */ + DSO_MERGER_FUNC merger; + /* This is populated with (a copy of) the platform-independant + * filename used for this DSO. */ + char *filename; + /* This is populated with (a copy of) the translated filename by which + * the DSO was actually loaded. It is NULL iff the DSO is not currently + * loaded. NB: This is here because the filename translation process + * may involve a callback being invoked more than once not only to + * convert to a platform-specific form, but also to try different + * filenames in the process of trying to perform a load. As such, this + * variable can be used to indicate (a) whether this DSO structure + * corresponds to a loaded library or not, and (b) the filename with + * which it was actually loaded. */ + char *loaded_filename; + }; + + +DSO * DSO_new(void); +DSO * DSO_new_method(DSO_METHOD *method); +int DSO_free(DSO *dso); +int DSO_flags(DSO *dso); +int DSO_up_ref(DSO *dso); +long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg); + +/* This function sets the DSO's name_converter callback. If it is non-NULL, + * then it will be used instead of the associated DSO_METHOD's function. If + * oldcb is non-NULL then it is set to the function pointer value being + * replaced. Return value is non-zero for success. */ +int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb, + DSO_NAME_CONVERTER_FUNC *oldcb); +/* These functions can be used to get/set the platform-independant filename + * used for a DSO. NB: set will fail if the DSO is already loaded. */ +const char *DSO_get_filename(DSO *dso); +int DSO_set_filename(DSO *dso, const char *filename); +/* This function will invoke the DSO's name_converter callback to translate a + * filename, or if the callback isn't set it will instead use the DSO_METHOD's + * converter. If "filename" is NULL, the "filename" in the DSO itself will be + * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is + * simply duplicated. NB: This function is usually called from within a + * DSO_METHOD during the processing of a DSO_load() call, and is exposed so that + * caller-created DSO_METHODs can do the same thing. A non-NULL return value + * will need to be OPENSSL_free()'d. */ +char *DSO_convert_filename(DSO *dso, const char *filename); +/* This function will invoke the DSO's merger callback to merge two file + * specifications, or if the callback isn't set it will instead use the + * DSO_METHOD's merger. A non-NULL return value will need to be + * OPENSSL_free()'d. */ +char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2); +/* If the DSO is currently loaded, this returns the filename that it was loaded + * under, otherwise it returns NULL. So it is also useful as a test as to + * whether the DSO is currently loaded. NB: This will not necessarily return + * the same value as DSO_convert_filename(dso, dso->filename), because the + * DSO_METHOD's load function may have tried a variety of filenames (with + * and/or without the aid of the converters) before settling on the one it + * actually loaded. */ +const char *DSO_get_loaded_filename(DSO *dso); + +void DSO_set_default_method(DSO_METHOD *meth); +DSO_METHOD *DSO_get_default_method(void); +DSO_METHOD *DSO_get_method(DSO *dso); +DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth); + +/* The all-singing all-dancing load function, you normally pass NULL + * for the first and third parameters. Use DSO_up and DSO_free for + * subsequent reference count handling. Any flags passed in will be set + * in the constructed DSO after its init() function but before the + * load operation. If 'dso' is non-NULL, 'flags' is ignored. */ +DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags); + +/* This function binds to a variable inside a shared library. */ +void *DSO_bind_var(DSO *dso, const char *symname); + +/* This function binds to a function inside a shared library. */ +DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname); + +/* This method is the default, but will beg, borrow, or steal whatever + * method should be the default on any particular platform (including + * DSO_METH_null() if necessary). */ +DSO_METHOD *DSO_METHOD_openssl(void); + +/* This method is defined for all platforms - if a platform has no + * DSO support then this will be the only method! */ +DSO_METHOD *DSO_METHOD_null(void); + +/* If DSO_DLFCN is defined, the standard dlfcn.h-style functions + * (dlopen, dlclose, dlsym, etc) will be used and incorporated into + * this method. If not, this method will return NULL. */ +DSO_METHOD *DSO_METHOD_dlfcn(void); + +/* If DSO_DL is defined, the standard dl.h-style functions (shl_load, + * shl_unload, shl_findsym, etc) will be used and incorporated into + * this method. If not, this method will return NULL. */ +DSO_METHOD *DSO_METHOD_dl(void); + +/* If WIN32 is defined, use DLLs. If not, return NULL. */ +DSO_METHOD *DSO_METHOD_win32(void); + +/* If VMS is defined, use shared images. If not, return NULL. */ +DSO_METHOD *DSO_METHOD_vms(void); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_DSO_strings(void); + +/* Error codes for the DSO functions. */ + +/* Function codes. */ +#define DSO_F_DLFCN_BIND_FUNC 100 +#define DSO_F_DLFCN_BIND_VAR 101 +#define DSO_F_DLFCN_LOAD 102 +#define DSO_F_DLFCN_MERGER 130 +#define DSO_F_DLFCN_NAME_CONVERTER 123 +#define DSO_F_DLFCN_UNLOAD 103 +#define DSO_F_DL_BIND_FUNC 104 +#define DSO_F_DL_BIND_VAR 105 +#define DSO_F_DL_LOAD 106 +#define DSO_F_DL_MERGER 131 +#define DSO_F_DL_NAME_CONVERTER 124 +#define DSO_F_DL_UNLOAD 107 +#define DSO_F_DSO_BIND_FUNC 108 +#define DSO_F_DSO_BIND_VAR 109 +#define DSO_F_DSO_CONVERT_FILENAME 126 +#define DSO_F_DSO_CTRL 110 +#define DSO_F_DSO_FREE 111 +#define DSO_F_DSO_GET_FILENAME 127 +#define DSO_F_DSO_GET_LOADED_FILENAME 128 +#define DSO_F_DSO_LOAD 112 +#define DSO_F_DSO_MERGE 132 +#define DSO_F_DSO_NEW_METHOD 113 +#define DSO_F_DSO_SET_FILENAME 129 +#define DSO_F_DSO_SET_NAME_CONVERTER 122 +#define DSO_F_DSO_UP_REF 114 +#define DSO_F_VMS_BIND_SYM 115 +#define DSO_F_VMS_LOAD 116 +#define DSO_F_VMS_MERGER 133 +#define DSO_F_VMS_UNLOAD 117 +#define DSO_F_WIN32_BIND_FUNC 118 +#define DSO_F_WIN32_BIND_VAR 119 +#define DSO_F_WIN32_JOINER 135 +#define DSO_F_WIN32_LOAD 120 +#define DSO_F_WIN32_MERGER 134 +#define DSO_F_WIN32_NAME_CONVERTER 125 +#define DSO_F_WIN32_SPLITTER 136 +#define DSO_F_WIN32_UNLOAD 121 + +/* Reason codes. */ +#define DSO_R_CTRL_FAILED 100 +#define DSO_R_DSO_ALREADY_LOADED 110 +#define DSO_R_EMPTY_FILE_STRUCTURE 113 +#define DSO_R_FAILURE 114 +#define DSO_R_FILENAME_TOO_BIG 101 +#define DSO_R_FINISH_FAILED 102 +#define DSO_R_INCORRECT_FILE_SYNTAX 115 +#define DSO_R_LOAD_FAILED 103 +#define DSO_R_NAME_TRANSLATION_FAILED 109 +#define DSO_R_NO_FILENAME 111 +#define DSO_R_NO_FILE_SPECIFICATION 116 +#define DSO_R_NULL_HANDLE 104 +#define DSO_R_SET_FILENAME_FAILED 112 +#define DSO_R_STACK_ERROR 105 +#define DSO_R_SYM_FAILURE 106 +#define DSO_R_UNLOAD_FAILED 107 +#define DSO_R_UNSUPPORTED 108 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/dtls1.h b/src/dep/include/openssl/dtls1.h index 5bc0a69..12bf9b8 100644 --- a/src/dep/include/openssl/dtls1.h +++ b/src/dep/include/openssl/dtls1.h @@ -1,212 +1,212 @@ -/* ssl/dtls1.h */ -/* - * DTLS implementation written by Nagendra Modadugu - * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. - */ -/* ==================================================================== - * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_DTLS1_H -#define HEADER_DTLS1_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define DTLS1_VERSION 0x0100 -#define DTLS1_VERSION_MAJOR 0x01 -#define DTLS1_VERSION_MINOR 0x00 - -#define DTLS1_AD_MISSING_HANDSHAKE_MESSAGE 110 - -/* lengths of messages */ -#define DTLS1_COOKIE_LENGTH 32 - -#define DTLS1_RT_HEADER_LENGTH 13 - -#define DTLS1_HM_HEADER_LENGTH 12 - -#define DTLS1_HM_BAD_FRAGMENT -2 -#define DTLS1_HM_FRAGMENT_RETRY -3 - -#define DTLS1_CCS_HEADER_LENGTH 3 - -#define DTLS1_AL_HEADER_LENGTH 7 - - -typedef struct dtls1_bitmap_st - { - PQ_64BIT map; - unsigned long length; /* sizeof the bitmap in bits */ - PQ_64BIT max_seq_num; /* max record number seen so far */ - } DTLS1_BITMAP; - -struct hm_header_st - { - unsigned char type; - unsigned long msg_len; - unsigned short seq; - unsigned long frag_off; - unsigned long frag_len; - unsigned int is_ccs; - }; - -struct ccs_header_st - { - unsigned char type; - unsigned short seq; - }; - -struct dtls1_timeout_st - { - /* Number of read timeouts so far */ - unsigned int read_timeouts; - - /* Number of write timeouts so far */ - unsigned int write_timeouts; - - /* Number of alerts received so far */ - unsigned int num_alerts; - }; - -typedef struct record_pqueue_st - { - unsigned short epoch; - pqueue q; - } record_pqueue; - -typedef struct hm_fragment_st - { - struct hm_header_st msg_header; - unsigned char *fragment; - } hm_fragment; - -typedef struct dtls1_state_st - { - unsigned int send_cookie; - unsigned char cookie[DTLS1_COOKIE_LENGTH]; - unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH]; - unsigned int cookie_len; - - /* - * The current data and handshake epoch. This is initially - * undefined, and starts at zero once the initial handshake is - * completed - */ - unsigned short r_epoch; - unsigned short w_epoch; - - /* records being received in the current epoch */ - DTLS1_BITMAP bitmap; - - /* renegotiation starts a new set of sequence numbers */ - DTLS1_BITMAP next_bitmap; - - /* handshake message numbers */ - unsigned short handshake_write_seq; - unsigned short next_handshake_write_seq; - - unsigned short handshake_read_seq; - - /* Received handshake records (processed and unprocessed) */ - record_pqueue unprocessed_rcds; - record_pqueue processed_rcds; - - /* Buffered handshake messages */ - pqueue buffered_messages; - - /* Buffered (sent) handshake records */ - pqueue sent_messages; - - unsigned int mtu; /* max wire packet size */ - - struct hm_header_st w_msg_hdr; - struct hm_header_st r_msg_hdr; - - struct dtls1_timeout_st timeout; - - /* storage for Alert/Handshake protocol data received but not - * yet processed by ssl3_read_bytes: */ - unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH]; - unsigned int alert_fragment_len; - unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH]; - unsigned int handshake_fragment_len; - - unsigned int retransmitting; - - } DTLS1_STATE; - -typedef struct dtls1_record_data_st - { - unsigned char *packet; - unsigned int packet_length; - SSL3_BUFFER rbuf; - SSL3_RECORD rrec; - } DTLS1_RECORD_DATA; - - -/* Timeout multipliers (timeout slice is defined in apps/timeouts.h */ -#define DTLS1_TMO_READ_COUNT 2 -#define DTLS1_TMO_WRITE_COUNT 2 - -#define DTLS1_TMO_ALERT_COUNT 12 - -#ifdef __cplusplus -} -#endif -#endif - +/* ssl/dtls1.h */ +/* + * DTLS implementation written by Nagendra Modadugu + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. + */ +/* ==================================================================== + * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_DTLS1_H +#define HEADER_DTLS1_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DTLS1_VERSION 0x0100 +#define DTLS1_VERSION_MAJOR 0x01 +#define DTLS1_VERSION_MINOR 0x00 + +#define DTLS1_AD_MISSING_HANDSHAKE_MESSAGE 110 + +/* lengths of messages */ +#define DTLS1_COOKIE_LENGTH 32 + +#define DTLS1_RT_HEADER_LENGTH 13 + +#define DTLS1_HM_HEADER_LENGTH 12 + +#define DTLS1_HM_BAD_FRAGMENT -2 +#define DTLS1_HM_FRAGMENT_RETRY -3 + +#define DTLS1_CCS_HEADER_LENGTH 3 + +#define DTLS1_AL_HEADER_LENGTH 7 + + +typedef struct dtls1_bitmap_st + { + PQ_64BIT map; + unsigned long length; /* sizeof the bitmap in bits */ + PQ_64BIT max_seq_num; /* max record number seen so far */ + } DTLS1_BITMAP; + +struct hm_header_st + { + unsigned char type; + unsigned long msg_len; + unsigned short seq; + unsigned long frag_off; + unsigned long frag_len; + unsigned int is_ccs; + }; + +struct ccs_header_st + { + unsigned char type; + unsigned short seq; + }; + +struct dtls1_timeout_st + { + /* Number of read timeouts so far */ + unsigned int read_timeouts; + + /* Number of write timeouts so far */ + unsigned int write_timeouts; + + /* Number of alerts received so far */ + unsigned int num_alerts; + }; + +typedef struct record_pqueue_st + { + unsigned short epoch; + pqueue q; + } record_pqueue; + +typedef struct hm_fragment_st + { + struct hm_header_st msg_header; + unsigned char *fragment; + } hm_fragment; + +typedef struct dtls1_state_st + { + unsigned int send_cookie; + unsigned char cookie[DTLS1_COOKIE_LENGTH]; + unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH]; + unsigned int cookie_len; + + /* + * The current data and handshake epoch. This is initially + * undefined, and starts at zero once the initial handshake is + * completed + */ + unsigned short r_epoch; + unsigned short w_epoch; + + /* records being received in the current epoch */ + DTLS1_BITMAP bitmap; + + /* renegotiation starts a new set of sequence numbers */ + DTLS1_BITMAP next_bitmap; + + /* handshake message numbers */ + unsigned short handshake_write_seq; + unsigned short next_handshake_write_seq; + + unsigned short handshake_read_seq; + + /* Received handshake records (processed and unprocessed) */ + record_pqueue unprocessed_rcds; + record_pqueue processed_rcds; + + /* Buffered handshake messages */ + pqueue buffered_messages; + + /* Buffered (sent) handshake records */ + pqueue sent_messages; + + unsigned int mtu; /* max wire packet size */ + + struct hm_header_st w_msg_hdr; + struct hm_header_st r_msg_hdr; + + struct dtls1_timeout_st timeout; + + /* storage for Alert/Handshake protocol data received but not + * yet processed by ssl3_read_bytes: */ + unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH]; + unsigned int alert_fragment_len; + unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH]; + unsigned int handshake_fragment_len; + + unsigned int retransmitting; + + } DTLS1_STATE; + +typedef struct dtls1_record_data_st + { + unsigned char *packet; + unsigned int packet_length; + SSL3_BUFFER rbuf; + SSL3_RECORD rrec; + } DTLS1_RECORD_DATA; + + +/* Timeout multipliers (timeout slice is defined in apps/timeouts.h */ +#define DTLS1_TMO_READ_COUNT 2 +#define DTLS1_TMO_WRITE_COUNT 2 + +#define DTLS1_TMO_ALERT_COUNT 12 + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/src/dep/include/openssl/e_os2.h b/src/dep/include/openssl/e_os2.h index 4691d26..d5b6962 100644 --- a/src/dep/include/openssl/e_os2.h +++ b/src/dep/include/openssl/e_os2.h @@ -1,279 +1,279 @@ -/* e_os2.h */ -/* ==================================================================== - * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#include - -#ifndef HEADER_E_OS2_H -#define HEADER_E_OS2_H - -#ifdef __cplusplus -extern "C" { -#endif - -/****************************************************************************** - * Detect operating systems. This probably needs completing. - * The result is that at least one OPENSSL_SYS_os macro should be defined. - * However, if none is defined, Unix is assumed. - **/ - -#define OPENSSL_SYS_UNIX - -/* ----------------------- Macintosh, before MacOS X ----------------------- */ -#if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_MACINTOSH_CLASSIC -#endif - -/* ----------------------- NetWare ----------------------------------------- */ -#if defined(NETWARE) || defined(OPENSSL_SYSNAME_NETWARE) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_NETWARE -#endif - -/* ---------------------- Microsoft operating systems ---------------------- */ - -/* Note that MSDOS actually denotes 32-bit environments running on top of - MS-DOS, such as DJGPP one. */ -#if defined(OPENSSL_SYSNAME_MSDOS) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_MSDOS -#endif - -/* For 32 bit environment, there seems to be the CygWin environment and then - all the others that try to do the same thing Microsoft does... */ -#if defined(OPENSSL_SYSNAME_UWIN) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_WIN32_UWIN -#else -# if defined(__CYGWIN32__) || defined(OPENSSL_SYSNAME_CYGWIN32) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_WIN32_CYGWIN -# else -# if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_WIN32 -# endif -# if defined(OPENSSL_SYSNAME_WINNT) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_WINNT -# endif -# if defined(OPENSSL_SYSNAME_WINCE) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_WINCE -# endif -# endif -#endif - -/* Anything that tries to look like Microsoft is "Windows" */ -#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_WINDOWS -# ifndef OPENSSL_SYS_MSDOS -# define OPENSSL_SYS_MSDOS -# endif -#endif - -/* DLL settings. This part is a bit tough, because it's up to the application - implementor how he or she will link the application, so it requires some - macro to be used. */ -#ifdef OPENSSL_SYS_WINDOWS -# ifndef OPENSSL_OPT_WINDLL -# if defined(_WINDLL) /* This is used when building OpenSSL to indicate that - DLL linkage should be used */ -# define OPENSSL_OPT_WINDLL -# endif -# endif -#endif - -/* -------------------------------- OpenVMS -------------------------------- */ -#if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_VMS -# if defined(__DECC) -# define OPENSSL_SYS_VMS_DECC -# elif defined(__DECCXX) -# define OPENSSL_SYS_VMS_DECC -# define OPENSSL_SYS_VMS_DECCXX -# else -# define OPENSSL_SYS_VMS_NODECC -# endif -#endif - -/* --------------------------------- OS/2 ---------------------------------- */ -#if defined(__EMX__) || defined(__OS2__) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_OS2 -#endif - -/* --------------------------------- Unix ---------------------------------- */ -#ifdef OPENSSL_SYS_UNIX -# if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX) -# define OPENSSL_SYS_LINUX -# endif -# ifdef OPENSSL_SYSNAME_MPE -# define OPENSSL_SYS_MPE -# endif -# ifdef OPENSSL_SYSNAME_SNI -# define OPENSSL_SYS_SNI -# endif -# ifdef OPENSSL_SYSNAME_ULTRASPARC -# define OPENSSL_SYS_ULTRASPARC -# endif -# ifdef OPENSSL_SYSNAME_NEWS4 -# define OPENSSL_SYS_NEWS4 -# endif -# ifdef OPENSSL_SYSNAME_MACOSX -# define OPENSSL_SYS_MACOSX -# endif -# ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY -# define OPENSSL_SYS_MACOSX_RHAPSODY -# define OPENSSL_SYS_MACOSX -# endif -# ifdef OPENSSL_SYSNAME_SUNOS -# define OPENSSL_SYS_SUNOS -#endif -# if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY) -# define OPENSSL_SYS_CRAY -# endif -# if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX) -# define OPENSSL_SYS_AIX -# endif -#endif - -/* --------------------------------- VOS ----------------------------------- */ -#ifdef OPENSSL_SYSNAME_VOS -# define OPENSSL_SYS_VOS -#endif - -/* ------------------------------- VxWorks --------------------------------- */ -#ifdef OPENSSL_SYSNAME_VXWORKS -# define OPENSSL_SYS_VXWORKS -#endif - -/** - * That's it for OS-specific stuff - *****************************************************************************/ - - -/* Specials for I/O an exit */ -#ifdef OPENSSL_SYS_MSDOS -# define OPENSSL_UNISTD_IO -# define OPENSSL_DECLARE_EXIT extern void exit(int); -#else -# define OPENSSL_UNISTD_IO OPENSSL_UNISTD -# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ -#endif - -/* Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare - certain global symbols that, with some compilers under VMS, have to be - defined and declared explicitely with globaldef and globalref. - Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare - DLL exports and imports for compilers under Win32. These are a little - more complicated to use. Basically, for any library that exports some - global variables, the following code must be present in the header file - that declares them, before OPENSSL_EXTERN is used: - - #ifdef SOME_BUILD_FLAG_MACRO - # undef OPENSSL_EXTERN - # define OPENSSL_EXTERN OPENSSL_EXPORT - #endif - - The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL - have some generally sensible values, and for OPENSSL_EXTERN to have the - value OPENSSL_IMPORT. -*/ - -#if defined(OPENSSL_SYS_VMS_NODECC) -# define OPENSSL_EXPORT globalref -# define OPENSSL_IMPORT globalref -# define OPENSSL_GLOBAL globaldef -#elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) -# define OPENSSL_EXPORT extern __declspec(dllexport) -# define OPENSSL_IMPORT extern __declspec(dllimport) -# define OPENSSL_GLOBAL -#else -# define OPENSSL_EXPORT extern -# define OPENSSL_IMPORT extern -# define OPENSSL_GLOBAL -#endif -#define OPENSSL_EXTERN OPENSSL_IMPORT - -/* Macros to allow global variables to be reached through function calls when - required (if a shared library version requvres it, for example. - The way it's done allows definitions like this: - - // in foobar.c - OPENSSL_IMPLEMENT_GLOBAL(int,foobar) = 0; - // in foobar.h - OPENSSL_DECLARE_GLOBAL(int,foobar); - #define foobar OPENSSL_GLOBAL_REF(foobar) -*/ -#ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION -# define OPENSSL_IMPLEMENT_GLOBAL(type,name) \ - extern type _hide_##name; \ - type *_shadow_##name(void) { return &_hide_##name; } \ - static type _hide_##name -# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void) -# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name())) -#else -# define OPENSSL_IMPLEMENT_GLOBAL(type,name) OPENSSL_GLOBAL type _shadow_##name -# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name -# define OPENSSL_GLOBAL_REF(name) _shadow_##name -#endif - -#ifdef __cplusplus -} -#endif -#endif +/* e_os2.h */ +/* ==================================================================== + * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include + +#ifndef HEADER_E_OS2_H +#define HEADER_E_OS2_H + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************** + * Detect operating systems. This probably needs completing. + * The result is that at least one OPENSSL_SYS_os macro should be defined. + * However, if none is defined, Unix is assumed. + **/ + +#define OPENSSL_SYS_UNIX + +/* ----------------------- Macintosh, before MacOS X ----------------------- */ +#if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_MACINTOSH_CLASSIC +#endif + +/* ----------------------- NetWare ----------------------------------------- */ +#if defined(NETWARE) || defined(OPENSSL_SYSNAME_NETWARE) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_NETWARE +#endif + +/* ---------------------- Microsoft operating systems ---------------------- */ + +/* Note that MSDOS actually denotes 32-bit environments running on top of + MS-DOS, such as DJGPP one. */ +#if defined(OPENSSL_SYSNAME_MSDOS) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_MSDOS +#endif + +/* For 32 bit environment, there seems to be the CygWin environment and then + all the others that try to do the same thing Microsoft does... */ +#if defined(OPENSSL_SYSNAME_UWIN) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WIN32_UWIN +#else +# if defined(__CYGWIN32__) || defined(OPENSSL_SYSNAME_CYGWIN32) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WIN32_CYGWIN +# else +# if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WIN32 +# endif +# if defined(OPENSSL_SYSNAME_WINNT) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WINNT +# endif +# if defined(OPENSSL_SYSNAME_WINCE) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WINCE +# endif +# endif +#endif + +/* Anything that tries to look like Microsoft is "Windows" */ +#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WINDOWS +# ifndef OPENSSL_SYS_MSDOS +# define OPENSSL_SYS_MSDOS +# endif +#endif + +/* DLL settings. This part is a bit tough, because it's up to the application + implementor how he or she will link the application, so it requires some + macro to be used. */ +#ifdef OPENSSL_SYS_WINDOWS +# ifndef OPENSSL_OPT_WINDLL +# if defined(_WINDLL) /* This is used when building OpenSSL to indicate that + DLL linkage should be used */ +# define OPENSSL_OPT_WINDLL +# endif +# endif +#endif + +/* -------------------------------- OpenVMS -------------------------------- */ +#if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_VMS +# if defined(__DECC) +# define OPENSSL_SYS_VMS_DECC +# elif defined(__DECCXX) +# define OPENSSL_SYS_VMS_DECC +# define OPENSSL_SYS_VMS_DECCXX +# else +# define OPENSSL_SYS_VMS_NODECC +# endif +#endif + +/* --------------------------------- OS/2 ---------------------------------- */ +#if defined(__EMX__) || defined(__OS2__) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_OS2 +#endif + +/* --------------------------------- Unix ---------------------------------- */ +#ifdef OPENSSL_SYS_UNIX +# if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX) +# define OPENSSL_SYS_LINUX +# endif +# ifdef OPENSSL_SYSNAME_MPE +# define OPENSSL_SYS_MPE +# endif +# ifdef OPENSSL_SYSNAME_SNI +# define OPENSSL_SYS_SNI +# endif +# ifdef OPENSSL_SYSNAME_ULTRASPARC +# define OPENSSL_SYS_ULTRASPARC +# endif +# ifdef OPENSSL_SYSNAME_NEWS4 +# define OPENSSL_SYS_NEWS4 +# endif +# ifdef OPENSSL_SYSNAME_MACOSX +# define OPENSSL_SYS_MACOSX +# endif +# ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY +# define OPENSSL_SYS_MACOSX_RHAPSODY +# define OPENSSL_SYS_MACOSX +# endif +# ifdef OPENSSL_SYSNAME_SUNOS +# define OPENSSL_SYS_SUNOS +#endif +# if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY) +# define OPENSSL_SYS_CRAY +# endif +# if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX) +# define OPENSSL_SYS_AIX +# endif +#endif + +/* --------------------------------- VOS ----------------------------------- */ +#ifdef OPENSSL_SYSNAME_VOS +# define OPENSSL_SYS_VOS +#endif + +/* ------------------------------- VxWorks --------------------------------- */ +#ifdef OPENSSL_SYSNAME_VXWORKS +# define OPENSSL_SYS_VXWORKS +#endif + +/** + * That's it for OS-specific stuff + *****************************************************************************/ + + +/* Specials for I/O an exit */ +#ifdef OPENSSL_SYS_MSDOS +# define OPENSSL_UNISTD_IO +# define OPENSSL_DECLARE_EXIT extern void exit(int); +#else +# define OPENSSL_UNISTD_IO OPENSSL_UNISTD +# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ +#endif + +/* Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare + certain global symbols that, with some compilers under VMS, have to be + defined and declared explicitely with globaldef and globalref. + Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare + DLL exports and imports for compilers under Win32. These are a little + more complicated to use. Basically, for any library that exports some + global variables, the following code must be present in the header file + that declares them, before OPENSSL_EXTERN is used: + + #ifdef SOME_BUILD_FLAG_MACRO + # undef OPENSSL_EXTERN + # define OPENSSL_EXTERN OPENSSL_EXPORT + #endif + + The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL + have some generally sensible values, and for OPENSSL_EXTERN to have the + value OPENSSL_IMPORT. +*/ + +#if defined(OPENSSL_SYS_VMS_NODECC) +# define OPENSSL_EXPORT globalref +# define OPENSSL_IMPORT globalref +# define OPENSSL_GLOBAL globaldef +#elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) +# define OPENSSL_EXPORT extern __declspec(dllexport) +# define OPENSSL_IMPORT extern __declspec(dllimport) +# define OPENSSL_GLOBAL +#else +# define OPENSSL_EXPORT extern +# define OPENSSL_IMPORT extern +# define OPENSSL_GLOBAL +#endif +#define OPENSSL_EXTERN OPENSSL_IMPORT + +/* Macros to allow global variables to be reached through function calls when + required (if a shared library version requvres it, for example. + The way it's done allows definitions like this: + + // in foobar.c + OPENSSL_IMPLEMENT_GLOBAL(int,foobar) = 0; + // in foobar.h + OPENSSL_DECLARE_GLOBAL(int,foobar); + #define foobar OPENSSL_GLOBAL_REF(foobar) +*/ +#ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION +# define OPENSSL_IMPLEMENT_GLOBAL(type,name) \ + extern type _hide_##name; \ + type *_shadow_##name(void) { return &_hide_##name; } \ + static type _hide_##name +# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void) +# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name())) +#else +# define OPENSSL_IMPLEMENT_GLOBAL(type,name) OPENSSL_GLOBAL type _shadow_##name +# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name +# define OPENSSL_GLOBAL_REF(name) _shadow_##name +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/ebcdic.h b/src/dep/include/openssl/ebcdic.h index 0941c8b..6d65afc 100644 --- a/src/dep/include/openssl/ebcdic.h +++ b/src/dep/include/openssl/ebcdic.h @@ -1,19 +1,19 @@ -/* crypto/ebcdic.h */ - -#ifndef HEADER_EBCDIC_H -#define HEADER_EBCDIC_H - -#include - -/* Avoid name clashes with other applications */ -#define os_toascii _openssl_os_toascii -#define os_toebcdic _openssl_os_toebcdic -#define ebcdic2ascii _openssl_ebcdic2ascii -#define ascii2ebcdic _openssl_ascii2ebcdic - -extern const unsigned char os_toascii[256]; -extern const unsigned char os_toebcdic[256]; -void *ebcdic2ascii(void *dest, const void *srce, size_t count); -void *ascii2ebcdic(void *dest, const void *srce, size_t count); - -#endif +/* crypto/ebcdic.h */ + +#ifndef HEADER_EBCDIC_H +#define HEADER_EBCDIC_H + +#include + +/* Avoid name clashes with other applications */ +#define os_toascii _openssl_os_toascii +#define os_toebcdic _openssl_os_toebcdic +#define ebcdic2ascii _openssl_ebcdic2ascii +#define ascii2ebcdic _openssl_ascii2ebcdic + +extern const unsigned char os_toascii[256]; +extern const unsigned char os_toebcdic[256]; +void *ebcdic2ascii(void *dest, const void *srce, size_t count); +void *ascii2ebcdic(void *dest, const void *srce, size_t count); + +#endif diff --git a/src/dep/include/openssl/ec.h b/src/dep/include/openssl/ec.h index 4e746ca..1fe59ea 100644 --- a/src/dep/include/openssl/ec.h +++ b/src/dep/include/openssl/ec.h @@ -1,518 +1,518 @@ -/* crypto/ec/ec.h */ -/* - * Originally written by Bodo Moeller for the OpenSSL project. - */ -/* ==================================================================== - * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * - * Portions of the attached software ("Contribution") are developed by - * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. - * - * The Contribution is licensed pursuant to the OpenSSL open source - * license provided above. - * - * The elliptic curve binary polynomial software is originally written by - * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. - * - */ - -#ifndef HEADER_EC_H -#define HEADER_EC_H - -#include - -#ifdef OPENSSL_NO_EC -#error EC is disabled. -#endif - -#include -#include -#ifndef OPENSSL_NO_DEPRECATED -#include -#endif - -#ifdef __cplusplus -extern "C" { -#elif defined(__SUNPRO_C) -# if __SUNPRO_C >= 0x520 -# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) -# endif -#endif - - -typedef enum { - /* values as defined in X9.62 (ECDSA) and elsewhere */ - POINT_CONVERSION_COMPRESSED = 2, - POINT_CONVERSION_UNCOMPRESSED = 4, - POINT_CONVERSION_HYBRID = 6 -} point_conversion_form_t; - - -typedef struct ec_method_st EC_METHOD; - -typedef struct ec_group_st - /* - EC_METHOD *meth; - -- field definition - -- curve coefficients - -- optional generator with associated information (order, cofactor) - -- optional extra data (precomputed table for fast computation of multiples of generator) - -- ASN1 stuff - */ - EC_GROUP; - -typedef struct ec_point_st EC_POINT; - - -/* EC_METHODs for curves over GF(p). - * EC_GFp_simple_method provides the basis for the optimized methods. - */ -const EC_METHOD *EC_GFp_simple_method(void); -const EC_METHOD *EC_GFp_mont_method(void); -const EC_METHOD *EC_GFp_nist_method(void); - -/* EC_METHOD for curves over GF(2^m). - */ -const EC_METHOD *EC_GF2m_simple_method(void); - - -EC_GROUP *EC_GROUP_new(const EC_METHOD *); -void EC_GROUP_free(EC_GROUP *); -void EC_GROUP_clear_free(EC_GROUP *); -int EC_GROUP_copy(EC_GROUP *, const EC_GROUP *); -EC_GROUP *EC_GROUP_dup(const EC_GROUP *); - -const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *); -int EC_METHOD_get_field_type(const EC_METHOD *); - -int EC_GROUP_set_generator(EC_GROUP *, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); -const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *); -int EC_GROUP_get_order(const EC_GROUP *, BIGNUM *order, BN_CTX *); -int EC_GROUP_get_cofactor(const EC_GROUP *, BIGNUM *cofactor, BN_CTX *); - -void EC_GROUP_set_curve_name(EC_GROUP *, int nid); -int EC_GROUP_get_curve_name(const EC_GROUP *); - -void EC_GROUP_set_asn1_flag(EC_GROUP *, int flag); -int EC_GROUP_get_asn1_flag(const EC_GROUP *); - -void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t); -point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); - -unsigned char *EC_GROUP_get0_seed(const EC_GROUP *); -size_t EC_GROUP_get_seed_len(const EC_GROUP *); -size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); - -int EC_GROUP_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); -int EC_GROUP_get_curve_GFp(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); -int EC_GROUP_set_curve_GF2m(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); -int EC_GROUP_get_curve_GF2m(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); - -/* returns the number of bits needed to represent a field element */ -int EC_GROUP_get_degree(const EC_GROUP *); - -/* EC_GROUP_check() returns 1 if 'group' defines a valid group, 0 otherwise */ -int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); -/* EC_GROUP_check_discriminant() returns 1 if the discriminant of the - * elliptic curve is not zero, 0 otherwise */ -int EC_GROUP_check_discriminant(const EC_GROUP *, BN_CTX *); - -/* EC_GROUP_cmp() returns 0 if both groups are equal and 1 otherwise */ -int EC_GROUP_cmp(const EC_GROUP *, const EC_GROUP *, BN_CTX *); - -/* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() - * after choosing an appropriate EC_METHOD */ -EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); -EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); - -/* EC_GROUP_new_by_curve_name() creates a EC_GROUP structure - * specified by a curve name (in form of a NID) */ -EC_GROUP *EC_GROUP_new_by_curve_name(int nid); -/* handling of internal curves */ -typedef struct { - int nid; - const char *comment; - } EC_builtin_curve; -/* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number - * of all available curves or zero if a error occurred. - * In case r ist not zero nitems EC_builtin_curve structures - * are filled with the data of the first nitems internal groups */ -size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); - - -/* EC_POINT functions */ - -EC_POINT *EC_POINT_new(const EC_GROUP *); -void EC_POINT_free(EC_POINT *); -void EC_POINT_clear_free(EC_POINT *); -int EC_POINT_copy(EC_POINT *, const EC_POINT *); -EC_POINT *EC_POINT_dup(const EC_POINT *, const EC_GROUP *); - -const EC_METHOD *EC_POINT_method_of(const EC_POINT *); - -int EC_POINT_set_to_infinity(const EC_GROUP *, EC_POINT *); -int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *, EC_POINT *, - const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); -int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *, const EC_POINT *, - BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); -int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *, EC_POINT *, - const BIGNUM *x, const BIGNUM *y, BN_CTX *); -int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *, const EC_POINT *, - BIGNUM *x, BIGNUM *y, BN_CTX *); -int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *, EC_POINT *, - const BIGNUM *x, int y_bit, BN_CTX *); - -int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *, EC_POINT *, - const BIGNUM *x, const BIGNUM *y, BN_CTX *); -int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *, const EC_POINT *, - BIGNUM *x, BIGNUM *y, BN_CTX *); -int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *, EC_POINT *, - const BIGNUM *x, int y_bit, BN_CTX *); - -size_t EC_POINT_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, - unsigned char *buf, size_t len, BN_CTX *); -int EC_POINT_oct2point(const EC_GROUP *, EC_POINT *, - const unsigned char *buf, size_t len, BN_CTX *); - -/* other interfaces to point2oct/oct2point: */ -BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, - point_conversion_form_t form, BIGNUM *, BN_CTX *); -EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, - EC_POINT *, BN_CTX *); -char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, - point_conversion_form_t form, BN_CTX *); -EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, - EC_POINT *, BN_CTX *); - -int EC_POINT_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); -int EC_POINT_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); -int EC_POINT_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); - -int EC_POINT_is_at_infinity(const EC_GROUP *, const EC_POINT *); -int EC_POINT_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); -int EC_POINT_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); - -int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); -int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); - - -int EC_POINTs_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, size_t num, const EC_POINT *[], const BIGNUM *[], BN_CTX *); -int EC_POINT_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, const EC_POINT *, const BIGNUM *, BN_CTX *); - -/* EC_GROUP_precompute_mult() stores multiples of generator for faster point multiplication */ -int EC_GROUP_precompute_mult(EC_GROUP *, BN_CTX *); -/* EC_GROUP_have_precompute_mult() reports whether such precomputation has been done */ -int EC_GROUP_have_precompute_mult(const EC_GROUP *); - - - -/* ASN1 stuff */ - -/* EC_GROUP_get_basis_type() returns the NID of the basis type - * used to represent the field elements */ -int EC_GROUP_get_basis_type(const EC_GROUP *); -int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); -int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, - unsigned int *k2, unsigned int *k3); - -#define OPENSSL_EC_NAMED_CURVE 0x001 - -typedef struct ecpk_parameters_st ECPKPARAMETERS; - -EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); -int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); - -#define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x) -#define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x) -#define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \ - (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x)) -#define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \ - (unsigned char *)(x)) - -#ifndef OPENSSL_NO_BIO -int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); -#endif -#ifndef OPENSSL_NO_FP_API -int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); -#endif - -/* the EC_KEY stuff */ -typedef struct ec_key_st EC_KEY; - -/* some values for the encoding_flag */ -#define EC_PKEY_NO_PARAMETERS 0x001 -#define EC_PKEY_NO_PUBKEY 0x002 - -EC_KEY *EC_KEY_new(void); -EC_KEY *EC_KEY_new_by_curve_name(int nid); -void EC_KEY_free(EC_KEY *); -EC_KEY *EC_KEY_copy(EC_KEY *, const EC_KEY *); -EC_KEY *EC_KEY_dup(const EC_KEY *); - -int EC_KEY_up_ref(EC_KEY *); - -const EC_GROUP *EC_KEY_get0_group(const EC_KEY *); -int EC_KEY_set_group(EC_KEY *, const EC_GROUP *); -const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *); -int EC_KEY_set_private_key(EC_KEY *, const BIGNUM *); -const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *); -int EC_KEY_set_public_key(EC_KEY *, const EC_POINT *); -unsigned EC_KEY_get_enc_flags(const EC_KEY *); -void EC_KEY_set_enc_flags(EC_KEY *, unsigned int); -point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *); -void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t); -/* functions to set/get method specific data */ -void *EC_KEY_get_key_method_data(EC_KEY *, - void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); -void EC_KEY_insert_key_method_data(EC_KEY *, void *data, - void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); -/* wrapper functions for the underlying EC_GROUP object */ -void EC_KEY_set_asn1_flag(EC_KEY *, int); -int EC_KEY_precompute_mult(EC_KEY *, BN_CTX *ctx); - -/* EC_KEY_generate_key() creates a ec private (public) key */ -int EC_KEY_generate_key(EC_KEY *); -/* EC_KEY_check_key() */ -int EC_KEY_check_key(const EC_KEY *); - -/* de- and encoding functions for SEC1 ECPrivateKey */ -EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len); -int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out); -/* de- and encoding functions for EC parameters */ -EC_KEY *d2i_ECParameters(EC_KEY **a, const unsigned char **in, long len); -int i2d_ECParameters(EC_KEY *a, unsigned char **out); -/* de- and encoding functions for EC public key - * (octet string, not DER -- hence 'o2i' and 'i2o') */ -EC_KEY *o2i_ECPublicKey(EC_KEY **a, const unsigned char **in, long len); -int i2o_ECPublicKey(EC_KEY *a, unsigned char **out); - -#ifndef OPENSSL_NO_BIO -int ECParameters_print(BIO *bp, const EC_KEY *x); -int EC_KEY_print(BIO *bp, const EC_KEY *x, int off); -#endif -#ifndef OPENSSL_NO_FP_API -int ECParameters_print_fp(FILE *fp, const EC_KEY *x); -int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off); -#endif - -#define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) - -#ifndef __cplusplus -#if defined(__SUNPRO_C) -# if __SUNPRO_C >= 0x520 -# pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) -# endif -# endif -#endif - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_EC_strings(void); - -/* Error codes for the EC functions. */ - -/* Function codes. */ -#define EC_F_COMPUTE_WNAF 143 -#define EC_F_D2I_ECPARAMETERS 144 -#define EC_F_D2I_ECPKPARAMETERS 145 -#define EC_F_D2I_ECPRIVATEKEY 146 -#define EC_F_ECPARAMETERS_PRINT 147 -#define EC_F_ECPARAMETERS_PRINT_FP 148 -#define EC_F_ECPKPARAMETERS_PRINT 149 -#define EC_F_ECPKPARAMETERS_PRINT_FP 150 -#define EC_F_ECP_NIST_MOD_192 203 -#define EC_F_ECP_NIST_MOD_224 204 -#define EC_F_ECP_NIST_MOD_256 205 -#define EC_F_ECP_NIST_MOD_521 206 -#define EC_F_EC_ASN1_GROUP2CURVE 153 -#define EC_F_EC_ASN1_GROUP2FIELDID 154 -#define EC_F_EC_ASN1_GROUP2PARAMETERS 155 -#define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156 -#define EC_F_EC_ASN1_PARAMETERS2GROUP 157 -#define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158 -#define EC_F_EC_EX_DATA_SET_DATA 211 -#define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208 -#define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159 -#define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195 -#define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160 -#define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161 -#define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162 -#define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163 -#define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164 -#define EC_F_EC_GFP_MONT_FIELD_DECODE 133 -#define EC_F_EC_GFP_MONT_FIELD_ENCODE 134 -#define EC_F_EC_GFP_MONT_FIELD_MUL 131 -#define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209 -#define EC_F_EC_GFP_MONT_FIELD_SQR 132 -#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189 -#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135 -#define EC_F_EC_GFP_NIST_FIELD_MUL 200 -#define EC_F_EC_GFP_NIST_FIELD_SQR 201 -#define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202 -#define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165 -#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166 -#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100 -#define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101 -#define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102 -#define EC_F_EC_GFP_SIMPLE_OCT2POINT 103 -#define EC_F_EC_GFP_SIMPLE_POINT2OCT 104 -#define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137 -#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167 -#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105 -#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168 -#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128 -#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169 -#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129 -#define EC_F_EC_GROUP_CHECK 170 -#define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171 -#define EC_F_EC_GROUP_COPY 106 -#define EC_F_EC_GROUP_GET0_GENERATOR 139 -#define EC_F_EC_GROUP_GET_COFACTOR 140 -#define EC_F_EC_GROUP_GET_CURVE_GF2M 172 -#define EC_F_EC_GROUP_GET_CURVE_GFP 130 -#define EC_F_EC_GROUP_GET_DEGREE 173 -#define EC_F_EC_GROUP_GET_ORDER 141 -#define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193 -#define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194 -#define EC_F_EC_GROUP_NEW 108 -#define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174 -#define EC_F_EC_GROUP_NEW_FROM_DATA 175 -#define EC_F_EC_GROUP_PRECOMPUTE_MULT 142 -#define EC_F_EC_GROUP_SET_CURVE_GF2M 176 -#define EC_F_EC_GROUP_SET_CURVE_GFP 109 -#define EC_F_EC_GROUP_SET_EXTRA_DATA 110 -#define EC_F_EC_GROUP_SET_GENERATOR 111 -#define EC_F_EC_KEY_CHECK_KEY 177 -#define EC_F_EC_KEY_COPY 178 -#define EC_F_EC_KEY_GENERATE_KEY 179 -#define EC_F_EC_KEY_NEW 182 -#define EC_F_EC_KEY_PRINT 180 -#define EC_F_EC_KEY_PRINT_FP 181 -#define EC_F_EC_POINTS_MAKE_AFFINE 136 -#define EC_F_EC_POINTS_MUL 138 -#define EC_F_EC_POINT_ADD 112 -#define EC_F_EC_POINT_CMP 113 -#define EC_F_EC_POINT_COPY 114 -#define EC_F_EC_POINT_DBL 115 -#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183 -#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116 -#define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117 -#define EC_F_EC_POINT_INVERT 210 -#define EC_F_EC_POINT_IS_AT_INFINITY 118 -#define EC_F_EC_POINT_IS_ON_CURVE 119 -#define EC_F_EC_POINT_MAKE_AFFINE 120 -#define EC_F_EC_POINT_MUL 184 -#define EC_F_EC_POINT_NEW 121 -#define EC_F_EC_POINT_OCT2POINT 122 -#define EC_F_EC_POINT_POINT2OCT 123 -#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185 -#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124 -#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186 -#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125 -#define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126 -#define EC_F_EC_POINT_SET_TO_INFINITY 127 -#define EC_F_EC_PRE_COMP_DUP 207 -#define EC_F_EC_WNAF_MUL 187 -#define EC_F_EC_WNAF_PRECOMPUTE_MULT 188 -#define EC_F_I2D_ECPARAMETERS 190 -#define EC_F_I2D_ECPKPARAMETERS 191 -#define EC_F_I2D_ECPRIVATEKEY 192 -#define EC_F_I2O_ECPUBLICKEY 151 -#define EC_F_O2I_ECPUBLICKEY 152 - -/* Reason codes. */ -#define EC_R_ASN1_ERROR 115 -#define EC_R_ASN1_UNKNOWN_FIELD 116 -#define EC_R_BUFFER_TOO_SMALL 100 -#define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 -#define EC_R_DISCRIMINANT_IS_ZERO 118 -#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 -#define EC_R_GROUP2PKPARAMETERS_FAILURE 120 -#define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 -#define EC_R_INCOMPATIBLE_OBJECTS 101 -#define EC_R_INVALID_ARGUMENT 112 -#define EC_R_INVALID_COMPRESSED_POINT 110 -#define EC_R_INVALID_COMPRESSION_BIT 109 -#define EC_R_INVALID_ENCODING 102 -#define EC_R_INVALID_FIELD 103 -#define EC_R_INVALID_FORM 104 -#define EC_R_INVALID_GROUP_ORDER 122 -#define EC_R_INVALID_PRIVATE_KEY 123 -#define EC_R_MISSING_PARAMETERS 124 -#define EC_R_MISSING_PRIVATE_KEY 125 -#define EC_R_NOT_A_NIST_PRIME 135 -#define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136 -#define EC_R_NOT_IMPLEMENTED 126 -#define EC_R_NOT_INITIALIZED 111 -#define EC_R_NO_FIELD_MOD 133 -#define EC_R_PASSED_NULL_PARAMETER 134 -#define EC_R_PKPARAMETERS2GROUP_FAILURE 127 -#define EC_R_POINT_AT_INFINITY 106 -#define EC_R_POINT_IS_NOT_ON_CURVE 107 -#define EC_R_SLOT_FULL 108 -#define EC_R_UNDEFINED_GENERATOR 113 -#define EC_R_UNDEFINED_ORDER 128 -#define EC_R_UNKNOWN_GROUP 129 -#define EC_R_UNKNOWN_ORDER 114 -#define EC_R_UNSUPPORTED_FIELD 131 -#define EC_R_WRONG_ORDER 130 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/ec/ec.h */ +/* + * Originally written by Bodo Moeller for the OpenSSL project. + */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the OpenSSL open source + * license provided above. + * + * The elliptic curve binary polynomial software is originally written by + * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. + * + */ + +#ifndef HEADER_EC_H +#define HEADER_EC_H + +#include + +#ifdef OPENSSL_NO_EC +#error EC is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#elif defined(__SUNPRO_C) +# if __SUNPRO_C >= 0x520 +# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) +# endif +#endif + + +typedef enum { + /* values as defined in X9.62 (ECDSA) and elsewhere */ + POINT_CONVERSION_COMPRESSED = 2, + POINT_CONVERSION_UNCOMPRESSED = 4, + POINT_CONVERSION_HYBRID = 6 +} point_conversion_form_t; + + +typedef struct ec_method_st EC_METHOD; + +typedef struct ec_group_st + /* + EC_METHOD *meth; + -- field definition + -- curve coefficients + -- optional generator with associated information (order, cofactor) + -- optional extra data (precomputed table for fast computation of multiples of generator) + -- ASN1 stuff + */ + EC_GROUP; + +typedef struct ec_point_st EC_POINT; + + +/* EC_METHODs for curves over GF(p). + * EC_GFp_simple_method provides the basis for the optimized methods. + */ +const EC_METHOD *EC_GFp_simple_method(void); +const EC_METHOD *EC_GFp_mont_method(void); +const EC_METHOD *EC_GFp_nist_method(void); + +/* EC_METHOD for curves over GF(2^m). + */ +const EC_METHOD *EC_GF2m_simple_method(void); + + +EC_GROUP *EC_GROUP_new(const EC_METHOD *); +void EC_GROUP_free(EC_GROUP *); +void EC_GROUP_clear_free(EC_GROUP *); +int EC_GROUP_copy(EC_GROUP *, const EC_GROUP *); +EC_GROUP *EC_GROUP_dup(const EC_GROUP *); + +const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *); +int EC_METHOD_get_field_type(const EC_METHOD *); + +int EC_GROUP_set_generator(EC_GROUP *, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); +const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *); +int EC_GROUP_get_order(const EC_GROUP *, BIGNUM *order, BN_CTX *); +int EC_GROUP_get_cofactor(const EC_GROUP *, BIGNUM *cofactor, BN_CTX *); + +void EC_GROUP_set_curve_name(EC_GROUP *, int nid); +int EC_GROUP_get_curve_name(const EC_GROUP *); + +void EC_GROUP_set_asn1_flag(EC_GROUP *, int flag); +int EC_GROUP_get_asn1_flag(const EC_GROUP *); + +void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t); +point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); + +unsigned char *EC_GROUP_get0_seed(const EC_GROUP *); +size_t EC_GROUP_get_seed_len(const EC_GROUP *); +size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); + +int EC_GROUP_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int EC_GROUP_get_curve_GFp(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); +int EC_GROUP_set_curve_GF2m(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int EC_GROUP_get_curve_GF2m(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); + +/* returns the number of bits needed to represent a field element */ +int EC_GROUP_get_degree(const EC_GROUP *); + +/* EC_GROUP_check() returns 1 if 'group' defines a valid group, 0 otherwise */ +int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); +/* EC_GROUP_check_discriminant() returns 1 if the discriminant of the + * elliptic curve is not zero, 0 otherwise */ +int EC_GROUP_check_discriminant(const EC_GROUP *, BN_CTX *); + +/* EC_GROUP_cmp() returns 0 if both groups are equal and 1 otherwise */ +int EC_GROUP_cmp(const EC_GROUP *, const EC_GROUP *, BN_CTX *); + +/* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() + * after choosing an appropriate EC_METHOD */ +EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); + +/* EC_GROUP_new_by_curve_name() creates a EC_GROUP structure + * specified by a curve name (in form of a NID) */ +EC_GROUP *EC_GROUP_new_by_curve_name(int nid); +/* handling of internal curves */ +typedef struct { + int nid; + const char *comment; + } EC_builtin_curve; +/* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number + * of all available curves or zero if a error occurred. + * In case r ist not zero nitems EC_builtin_curve structures + * are filled with the data of the first nitems internal groups */ +size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); + + +/* EC_POINT functions */ + +EC_POINT *EC_POINT_new(const EC_GROUP *); +void EC_POINT_free(EC_POINT *); +void EC_POINT_clear_free(EC_POINT *); +int EC_POINT_copy(EC_POINT *, const EC_POINT *); +EC_POINT *EC_POINT_dup(const EC_POINT *, const EC_GROUP *); + +const EC_METHOD *EC_POINT_method_of(const EC_POINT *); + +int EC_POINT_set_to_infinity(const EC_GROUP *, EC_POINT *); +int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); +int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); +int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, BN_CTX *); +int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BN_CTX *); +int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, int y_bit, BN_CTX *); + +int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, BN_CTX *); +int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BN_CTX *); +int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, int y_bit, BN_CTX *); + +size_t EC_POINT_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, + unsigned char *buf, size_t len, BN_CTX *); +int EC_POINT_oct2point(const EC_GROUP *, EC_POINT *, + const unsigned char *buf, size_t len, BN_CTX *); + +/* other interfaces to point2oct/oct2point: */ +BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, + point_conversion_form_t form, BIGNUM *, BN_CTX *); +EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, + EC_POINT *, BN_CTX *); +char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, + point_conversion_form_t form, BN_CTX *); +EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, + EC_POINT *, BN_CTX *); + +int EC_POINT_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); +int EC_POINT_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); +int EC_POINT_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); + +int EC_POINT_is_at_infinity(const EC_GROUP *, const EC_POINT *); +int EC_POINT_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); +int EC_POINT_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); + +int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); +int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); + + +int EC_POINTs_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, size_t num, const EC_POINT *[], const BIGNUM *[], BN_CTX *); +int EC_POINT_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, const EC_POINT *, const BIGNUM *, BN_CTX *); + +/* EC_GROUP_precompute_mult() stores multiples of generator for faster point multiplication */ +int EC_GROUP_precompute_mult(EC_GROUP *, BN_CTX *); +/* EC_GROUP_have_precompute_mult() reports whether such precomputation has been done */ +int EC_GROUP_have_precompute_mult(const EC_GROUP *); + + + +/* ASN1 stuff */ + +/* EC_GROUP_get_basis_type() returns the NID of the basis type + * used to represent the field elements */ +int EC_GROUP_get_basis_type(const EC_GROUP *); +int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); +int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, + unsigned int *k2, unsigned int *k3); + +#define OPENSSL_EC_NAMED_CURVE 0x001 + +typedef struct ecpk_parameters_st ECPKPARAMETERS; + +EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); +int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); + +#define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x) +#define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x) +#define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \ + (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x)) +#define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \ + (unsigned char *)(x)) + +#ifndef OPENSSL_NO_BIO +int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); +#endif +#ifndef OPENSSL_NO_FP_API +int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); +#endif + +/* the EC_KEY stuff */ +typedef struct ec_key_st EC_KEY; + +/* some values for the encoding_flag */ +#define EC_PKEY_NO_PARAMETERS 0x001 +#define EC_PKEY_NO_PUBKEY 0x002 + +EC_KEY *EC_KEY_new(void); +EC_KEY *EC_KEY_new_by_curve_name(int nid); +void EC_KEY_free(EC_KEY *); +EC_KEY *EC_KEY_copy(EC_KEY *, const EC_KEY *); +EC_KEY *EC_KEY_dup(const EC_KEY *); + +int EC_KEY_up_ref(EC_KEY *); + +const EC_GROUP *EC_KEY_get0_group(const EC_KEY *); +int EC_KEY_set_group(EC_KEY *, const EC_GROUP *); +const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *); +int EC_KEY_set_private_key(EC_KEY *, const BIGNUM *); +const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *); +int EC_KEY_set_public_key(EC_KEY *, const EC_POINT *); +unsigned EC_KEY_get_enc_flags(const EC_KEY *); +void EC_KEY_set_enc_flags(EC_KEY *, unsigned int); +point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *); +void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t); +/* functions to set/get method specific data */ +void *EC_KEY_get_key_method_data(EC_KEY *, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); +void EC_KEY_insert_key_method_data(EC_KEY *, void *data, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); +/* wrapper functions for the underlying EC_GROUP object */ +void EC_KEY_set_asn1_flag(EC_KEY *, int); +int EC_KEY_precompute_mult(EC_KEY *, BN_CTX *ctx); + +/* EC_KEY_generate_key() creates a ec private (public) key */ +int EC_KEY_generate_key(EC_KEY *); +/* EC_KEY_check_key() */ +int EC_KEY_check_key(const EC_KEY *); + +/* de- and encoding functions for SEC1 ECPrivateKey */ +EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len); +int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out); +/* de- and encoding functions for EC parameters */ +EC_KEY *d2i_ECParameters(EC_KEY **a, const unsigned char **in, long len); +int i2d_ECParameters(EC_KEY *a, unsigned char **out); +/* de- and encoding functions for EC public key + * (octet string, not DER -- hence 'o2i' and 'i2o') */ +EC_KEY *o2i_ECPublicKey(EC_KEY **a, const unsigned char **in, long len); +int i2o_ECPublicKey(EC_KEY *a, unsigned char **out); + +#ifndef OPENSSL_NO_BIO +int ECParameters_print(BIO *bp, const EC_KEY *x); +int EC_KEY_print(BIO *bp, const EC_KEY *x, int off); +#endif +#ifndef OPENSSL_NO_FP_API +int ECParameters_print_fp(FILE *fp, const EC_KEY *x); +int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off); +#endif + +#define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) + +#ifndef __cplusplus +#if defined(__SUNPRO_C) +# if __SUNPRO_C >= 0x520 +# pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) +# endif +# endif +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_EC_strings(void); + +/* Error codes for the EC functions. */ + +/* Function codes. */ +#define EC_F_COMPUTE_WNAF 143 +#define EC_F_D2I_ECPARAMETERS 144 +#define EC_F_D2I_ECPKPARAMETERS 145 +#define EC_F_D2I_ECPRIVATEKEY 146 +#define EC_F_ECPARAMETERS_PRINT 147 +#define EC_F_ECPARAMETERS_PRINT_FP 148 +#define EC_F_ECPKPARAMETERS_PRINT 149 +#define EC_F_ECPKPARAMETERS_PRINT_FP 150 +#define EC_F_ECP_NIST_MOD_192 203 +#define EC_F_ECP_NIST_MOD_224 204 +#define EC_F_ECP_NIST_MOD_256 205 +#define EC_F_ECP_NIST_MOD_521 206 +#define EC_F_EC_ASN1_GROUP2CURVE 153 +#define EC_F_EC_ASN1_GROUP2FIELDID 154 +#define EC_F_EC_ASN1_GROUP2PARAMETERS 155 +#define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156 +#define EC_F_EC_ASN1_PARAMETERS2GROUP 157 +#define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158 +#define EC_F_EC_EX_DATA_SET_DATA 211 +#define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208 +#define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159 +#define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195 +#define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160 +#define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161 +#define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162 +#define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163 +#define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164 +#define EC_F_EC_GFP_MONT_FIELD_DECODE 133 +#define EC_F_EC_GFP_MONT_FIELD_ENCODE 134 +#define EC_F_EC_GFP_MONT_FIELD_MUL 131 +#define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209 +#define EC_F_EC_GFP_MONT_FIELD_SQR 132 +#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189 +#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135 +#define EC_F_EC_GFP_NIST_FIELD_MUL 200 +#define EC_F_EC_GFP_NIST_FIELD_SQR 201 +#define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202 +#define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101 +#define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102 +#define EC_F_EC_GFP_SIMPLE_OCT2POINT 103 +#define EC_F_EC_GFP_SIMPLE_POINT2OCT 104 +#define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137 +#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167 +#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105 +#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168 +#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128 +#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169 +#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129 +#define EC_F_EC_GROUP_CHECK 170 +#define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171 +#define EC_F_EC_GROUP_COPY 106 +#define EC_F_EC_GROUP_GET0_GENERATOR 139 +#define EC_F_EC_GROUP_GET_COFACTOR 140 +#define EC_F_EC_GROUP_GET_CURVE_GF2M 172 +#define EC_F_EC_GROUP_GET_CURVE_GFP 130 +#define EC_F_EC_GROUP_GET_DEGREE 173 +#define EC_F_EC_GROUP_GET_ORDER 141 +#define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193 +#define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194 +#define EC_F_EC_GROUP_NEW 108 +#define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174 +#define EC_F_EC_GROUP_NEW_FROM_DATA 175 +#define EC_F_EC_GROUP_PRECOMPUTE_MULT 142 +#define EC_F_EC_GROUP_SET_CURVE_GF2M 176 +#define EC_F_EC_GROUP_SET_CURVE_GFP 109 +#define EC_F_EC_GROUP_SET_EXTRA_DATA 110 +#define EC_F_EC_GROUP_SET_GENERATOR 111 +#define EC_F_EC_KEY_CHECK_KEY 177 +#define EC_F_EC_KEY_COPY 178 +#define EC_F_EC_KEY_GENERATE_KEY 179 +#define EC_F_EC_KEY_NEW 182 +#define EC_F_EC_KEY_PRINT 180 +#define EC_F_EC_KEY_PRINT_FP 181 +#define EC_F_EC_POINTS_MAKE_AFFINE 136 +#define EC_F_EC_POINTS_MUL 138 +#define EC_F_EC_POINT_ADD 112 +#define EC_F_EC_POINT_CMP 113 +#define EC_F_EC_POINT_COPY 114 +#define EC_F_EC_POINT_DBL 115 +#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183 +#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116 +#define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117 +#define EC_F_EC_POINT_INVERT 210 +#define EC_F_EC_POINT_IS_AT_INFINITY 118 +#define EC_F_EC_POINT_IS_ON_CURVE 119 +#define EC_F_EC_POINT_MAKE_AFFINE 120 +#define EC_F_EC_POINT_MUL 184 +#define EC_F_EC_POINT_NEW 121 +#define EC_F_EC_POINT_OCT2POINT 122 +#define EC_F_EC_POINT_POINT2OCT 123 +#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185 +#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124 +#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186 +#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125 +#define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126 +#define EC_F_EC_POINT_SET_TO_INFINITY 127 +#define EC_F_EC_PRE_COMP_DUP 207 +#define EC_F_EC_WNAF_MUL 187 +#define EC_F_EC_WNAF_PRECOMPUTE_MULT 188 +#define EC_F_I2D_ECPARAMETERS 190 +#define EC_F_I2D_ECPKPARAMETERS 191 +#define EC_F_I2D_ECPRIVATEKEY 192 +#define EC_F_I2O_ECPUBLICKEY 151 +#define EC_F_O2I_ECPUBLICKEY 152 + +/* Reason codes. */ +#define EC_R_ASN1_ERROR 115 +#define EC_R_ASN1_UNKNOWN_FIELD 116 +#define EC_R_BUFFER_TOO_SMALL 100 +#define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 +#define EC_R_DISCRIMINANT_IS_ZERO 118 +#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 +#define EC_R_GROUP2PKPARAMETERS_FAILURE 120 +#define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 +#define EC_R_INCOMPATIBLE_OBJECTS 101 +#define EC_R_INVALID_ARGUMENT 112 +#define EC_R_INVALID_COMPRESSED_POINT 110 +#define EC_R_INVALID_COMPRESSION_BIT 109 +#define EC_R_INVALID_ENCODING 102 +#define EC_R_INVALID_FIELD 103 +#define EC_R_INVALID_FORM 104 +#define EC_R_INVALID_GROUP_ORDER 122 +#define EC_R_INVALID_PRIVATE_KEY 123 +#define EC_R_MISSING_PARAMETERS 124 +#define EC_R_MISSING_PRIVATE_KEY 125 +#define EC_R_NOT_A_NIST_PRIME 135 +#define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136 +#define EC_R_NOT_IMPLEMENTED 126 +#define EC_R_NOT_INITIALIZED 111 +#define EC_R_NO_FIELD_MOD 133 +#define EC_R_PASSED_NULL_PARAMETER 134 +#define EC_R_PKPARAMETERS2GROUP_FAILURE 127 +#define EC_R_POINT_AT_INFINITY 106 +#define EC_R_POINT_IS_NOT_ON_CURVE 107 +#define EC_R_SLOT_FULL 108 +#define EC_R_UNDEFINED_GENERATOR 113 +#define EC_R_UNDEFINED_ORDER 128 +#define EC_R_UNKNOWN_GROUP 129 +#define EC_R_UNKNOWN_ORDER 114 +#define EC_R_UNSUPPORTED_FIELD 131 +#define EC_R_WRONG_ORDER 130 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/ecdh.h b/src/dep/include/openssl/ecdh.h index 1f0d0c6..bb48da5 100644 --- a/src/dep/include/openssl/ecdh.h +++ b/src/dep/include/openssl/ecdh.h @@ -1,123 +1,123 @@ -/* crypto/ecdh/ecdh.h */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * - * The Elliptic Curve Public-Key Crypto Library (ECC Code) included - * herein is developed by SUN MICROSYSTEMS, INC., and is contributed - * to the OpenSSL project. - * - * The ECC Code is licensed pursuant to the OpenSSL open source - * license provided below. - * - * The ECDH software is originally written by Douglas Stebila of - * Sun Microsystems Laboratories. - * - */ -/* ==================================================================== - * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -#ifndef HEADER_ECDH_H -#define HEADER_ECDH_H - -#include - -#ifdef OPENSSL_NO_ECDH -#error ECDH is disabled. -#endif - -#include -#include -#ifndef OPENSSL_NO_DEPRECATED -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -const ECDH_METHOD *ECDH_OpenSSL(void); - -void ECDH_set_default_method(const ECDH_METHOD *); -const ECDH_METHOD *ECDH_get_default_method(void); -int ECDH_set_method(EC_KEY *, const ECDH_METHOD *); - -int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh, - void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); - -int ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new - *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); -int ECDH_set_ex_data(EC_KEY *d, int idx, void *arg); -void *ECDH_get_ex_data(EC_KEY *d, int idx); - - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_ECDH_strings(void); - -/* Error codes for the ECDH functions. */ - -/* Function codes. */ -#define ECDH_F_ECDH_COMPUTE_KEY 100 -#define ECDH_F_ECDH_DATA_NEW_METHOD 101 - -/* Reason codes. */ -#define ECDH_R_KDF_FAILED 102 -#define ECDH_R_NO_PRIVATE_VALUE 100 -#define ECDH_R_POINT_ARITHMETIC_FAILURE 101 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/ecdh/ecdh.h */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * The Elliptic Curve Public-Key Crypto Library (ECC Code) included + * herein is developed by SUN MICROSYSTEMS, INC., and is contributed + * to the OpenSSL project. + * + * The ECC Code is licensed pursuant to the OpenSSL open source + * license provided below. + * + * The ECDH software is originally written by Douglas Stebila of + * Sun Microsystems Laboratories. + * + */ +/* ==================================================================== + * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_ECDH_H +#define HEADER_ECDH_H + +#include + +#ifdef OPENSSL_NO_ECDH +#error ECDH is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +const ECDH_METHOD *ECDH_OpenSSL(void); + +void ECDH_set_default_method(const ECDH_METHOD *); +const ECDH_METHOD *ECDH_get_default_method(void); +int ECDH_set_method(EC_KEY *, const ECDH_METHOD *); + +int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh, + void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); + +int ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new + *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int ECDH_set_ex_data(EC_KEY *d, int idx, void *arg); +void *ECDH_get_ex_data(EC_KEY *d, int idx); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ECDH_strings(void); + +/* Error codes for the ECDH functions. */ + +/* Function codes. */ +#define ECDH_F_ECDH_COMPUTE_KEY 100 +#define ECDH_F_ECDH_DATA_NEW_METHOD 101 + +/* Reason codes. */ +#define ECDH_R_KDF_FAILED 102 +#define ECDH_R_NO_PRIVATE_VALUE 100 +#define ECDH_R_POINT_ARITHMETIC_FAILURE 101 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/ecdsa.h b/src/dep/include/openssl/ecdsa.h index 3f7fa93..1f6eaf6 100644 --- a/src/dep/include/openssl/ecdsa.h +++ b/src/dep/include/openssl/ecdsa.h @@ -1,270 +1,270 @@ -/* crypto/ecdsa/ecdsa.h */ -/** - * \file crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions - * \author Written by Nils Larsch for the OpenSSL project - */ -/* ==================================================================== - * Copyright (c) 2000-2003 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -#ifndef HEADER_ECDSA_H -#define HEADER_ECDSA_H - -#include - -#ifdef OPENSSL_NO_ECDSA -#error ECDSA is disabled. -#endif - -#include -#include -#ifndef OPENSSL_NO_DEPRECATED -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct ECDSA_SIG_st - { - BIGNUM *r; - BIGNUM *s; - } ECDSA_SIG; - -/** ECDSA_SIG *ECDSA_SIG_new(void) - * allocates and initialize a ECDSA_SIG structure - * \return pointer to a ECDSA_SIG structure or NULL if an error occurred - */ -ECDSA_SIG *ECDSA_SIG_new(void); - -/** ECDSA_SIG_free - * frees a ECDSA_SIG structure - * \param a pointer to the ECDSA_SIG structure - */ -void ECDSA_SIG_free(ECDSA_SIG *a); - -/** i2d_ECDSA_SIG - * DER encode content of ECDSA_SIG object (note: this function modifies *pp - * (*pp += length of the DER encoded signature)). - * \param a pointer to the ECDSA_SIG object - * \param pp pointer to a unsigned char pointer for the output or NULL - * \return the length of the DER encoded ECDSA_SIG object or 0 - */ -int i2d_ECDSA_SIG(const ECDSA_SIG *a, unsigned char **pp); - -/** d2i_ECDSA_SIG - * decodes a DER encoded ECDSA signature (note: this function changes *pp - * (*pp += len)). - * \param v pointer to ECDSA_SIG pointer (may be NULL) - * \param pp buffer with the DER encoded signature - * \param len bufferlength - * \return pointer to the decoded ECDSA_SIG structure (or NULL) - */ -ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **v, const unsigned char **pp, long len); - -/** ECDSA_do_sign - * computes the ECDSA signature of the given hash value using - * the supplied private key and returns the created signature. - * \param dgst pointer to the hash value - * \param dgst_len length of the hash value - * \param eckey pointer to the EC_KEY object containing a private EC key - * \return pointer to a ECDSA_SIG structure or NULL - */ -ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey); - -/** ECDSA_do_sign_ex - * computes ECDSA signature of a given hash value using the supplied - * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). - * \param dgst pointer to the hash value to sign - * \param dgstlen length of the hash value - * \param kinv optional pointer to a pre-computed inverse k - * \param rp optional pointer to the pre-computed rp value (see - * ECDSA_sign_setup - * \param eckey pointer to the EC_KEY object containing a private EC key - * \return pointer to a ECDSA_SIG structure or NULL - */ -ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, - const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey); - -/** ECDSA_do_verify - * verifies that the supplied signature is a valid ECDSA - * signature of the supplied hash value using the supplied public key. - * \param dgst pointer to the hash value - * \param dgst_len length of the hash value - * \param sig pointer to the ECDSA_SIG structure - * \param eckey pointer to the EC_KEY object containing a public EC key - * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error - */ -int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, - const ECDSA_SIG *sig, EC_KEY* eckey); - -const ECDSA_METHOD *ECDSA_OpenSSL(void); - -/** ECDSA_set_default_method - * sets the default ECDSA method - * \param meth the new default ECDSA_METHOD - */ -void ECDSA_set_default_method(const ECDSA_METHOD *meth); - -/** ECDSA_get_default_method - * returns the default ECDSA method - * \return pointer to ECDSA_METHOD structure containing the default method - */ -const ECDSA_METHOD *ECDSA_get_default_method(void); - -/** ECDSA_set_method - * sets method to be used for the ECDSA operations - * \param eckey pointer to the EC_KEY object - * \param meth pointer to the new method - * \return 1 on success and 0 otherwise - */ -int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth); - -/** ECDSA_size - * returns the maximum length of the DER encoded signature - * \param eckey pointer to a EC_KEY object - * \return numbers of bytes required for the DER encoded signature - */ -int ECDSA_size(const EC_KEY *eckey); - -/** ECDSA_sign_setup - * precompute parts of the signing operation. - * \param eckey pointer to the EC_KEY object containing a private EC key - * \param ctx pointer to a BN_CTX object (may be NULL) - * \param kinv pointer to a BIGNUM pointer for the inverse of k - * \param rp pointer to a BIGNUM pointer for x coordinate of k * generator - * \return 1 on success and 0 otherwise - */ -int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, - BIGNUM **rp); - -/** ECDSA_sign - * computes ECDSA signature of a given hash value using the supplied - * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). - * \param type this parameter is ignored - * \param dgst pointer to the hash value to sign - * \param dgstlen length of the hash value - * \param sig buffer to hold the DER encoded signature - * \param siglen pointer to the length of the returned signature - * \param eckey pointer to the EC_KEY object containing a private EC key - * \return 1 on success and 0 otherwise - */ -int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, - unsigned char *sig, unsigned int *siglen, EC_KEY *eckey); - - -/** ECDSA_sign_ex - * computes ECDSA signature of a given hash value using the supplied - * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). - * \param type this parameter is ignored - * \param dgst pointer to the hash value to sign - * \param dgstlen length of the hash value - * \param sig buffer to hold the DER encoded signature - * \param siglen pointer to the length of the returned signature - * \param kinv optional pointer to a pre-computed inverse k - * \param rp optional pointer to the pre-computed rp value (see - * ECDSA_sign_setup - * \param eckey pointer to the EC_KEY object containing a private EC key - * \return 1 on success and 0 otherwise - */ -int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, - unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, - const BIGNUM *rp, EC_KEY *eckey); - -/** ECDSA_verify - * verifies that the given signature is valid ECDSA signature - * of the supplied hash value using the specified public key. - * \param type this parameter is ignored - * \param dgst pointer to the hash value - * \param dgstlen length of the hash value - * \param sig pointer to the DER encoded signature - * \param siglen length of the DER encoded signature - * \param eckey pointer to the EC_KEY object containing a public EC key - * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error - */ -int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, - const unsigned char *sig, int siglen, EC_KEY *eckey); - -/* the standard ex_data functions */ -int ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new - *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); -int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg); -void *ECDSA_get_ex_data(EC_KEY *d, int idx); - - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_ECDSA_strings(void); - -/* Error codes for the ECDSA functions. */ - -/* Function codes. */ -#define ECDSA_F_ECDSA_DATA_NEW_METHOD 100 -#define ECDSA_F_ECDSA_DO_SIGN 101 -#define ECDSA_F_ECDSA_DO_VERIFY 102 -#define ECDSA_F_ECDSA_SIGN_SETUP 103 - -/* Reason codes. */ -#define ECDSA_R_BAD_SIGNATURE 100 -#define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 101 -#define ECDSA_R_ERR_EC_LIB 102 -#define ECDSA_R_MISSING_PARAMETERS 103 -#define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED 104 -#define ECDSA_R_SIGNATURE_MALLOC_FAILED 105 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/ecdsa/ecdsa.h */ +/** + * \file crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions + * \author Written by Nils Larsch for the OpenSSL project + */ +/* ==================================================================== + * Copyright (c) 2000-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_ECDSA_H +#define HEADER_ECDSA_H + +#include + +#ifdef OPENSSL_NO_ECDSA +#error ECDSA is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ECDSA_SIG_st + { + BIGNUM *r; + BIGNUM *s; + } ECDSA_SIG; + +/** ECDSA_SIG *ECDSA_SIG_new(void) + * allocates and initialize a ECDSA_SIG structure + * \return pointer to a ECDSA_SIG structure or NULL if an error occurred + */ +ECDSA_SIG *ECDSA_SIG_new(void); + +/** ECDSA_SIG_free + * frees a ECDSA_SIG structure + * \param a pointer to the ECDSA_SIG structure + */ +void ECDSA_SIG_free(ECDSA_SIG *a); + +/** i2d_ECDSA_SIG + * DER encode content of ECDSA_SIG object (note: this function modifies *pp + * (*pp += length of the DER encoded signature)). + * \param a pointer to the ECDSA_SIG object + * \param pp pointer to a unsigned char pointer for the output or NULL + * \return the length of the DER encoded ECDSA_SIG object or 0 + */ +int i2d_ECDSA_SIG(const ECDSA_SIG *a, unsigned char **pp); + +/** d2i_ECDSA_SIG + * decodes a DER encoded ECDSA signature (note: this function changes *pp + * (*pp += len)). + * \param v pointer to ECDSA_SIG pointer (may be NULL) + * \param pp buffer with the DER encoded signature + * \param len bufferlength + * \return pointer to the decoded ECDSA_SIG structure (or NULL) + */ +ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **v, const unsigned char **pp, long len); + +/** ECDSA_do_sign + * computes the ECDSA signature of the given hash value using + * the supplied private key and returns the created signature. + * \param dgst pointer to the hash value + * \param dgst_len length of the hash value + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return pointer to a ECDSA_SIG structure or NULL + */ +ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey); + +/** ECDSA_do_sign_ex + * computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param kinv optional pointer to a pre-computed inverse k + * \param rp optional pointer to the pre-computed rp value (see + * ECDSA_sign_setup + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return pointer to a ECDSA_SIG structure or NULL + */ +ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, + const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey); + +/** ECDSA_do_verify + * verifies that the supplied signature is a valid ECDSA + * signature of the supplied hash value using the supplied public key. + * \param dgst pointer to the hash value + * \param dgst_len length of the hash value + * \param sig pointer to the ECDSA_SIG structure + * \param eckey pointer to the EC_KEY object containing a public EC key + * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error + */ +int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, + const ECDSA_SIG *sig, EC_KEY* eckey); + +const ECDSA_METHOD *ECDSA_OpenSSL(void); + +/** ECDSA_set_default_method + * sets the default ECDSA method + * \param meth the new default ECDSA_METHOD + */ +void ECDSA_set_default_method(const ECDSA_METHOD *meth); + +/** ECDSA_get_default_method + * returns the default ECDSA method + * \return pointer to ECDSA_METHOD structure containing the default method + */ +const ECDSA_METHOD *ECDSA_get_default_method(void); + +/** ECDSA_set_method + * sets method to be used for the ECDSA operations + * \param eckey pointer to the EC_KEY object + * \param meth pointer to the new method + * \return 1 on success and 0 otherwise + */ +int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth); + +/** ECDSA_size + * returns the maximum length of the DER encoded signature + * \param eckey pointer to a EC_KEY object + * \return numbers of bytes required for the DER encoded signature + */ +int ECDSA_size(const EC_KEY *eckey); + +/** ECDSA_sign_setup + * precompute parts of the signing operation. + * \param eckey pointer to the EC_KEY object containing a private EC key + * \param ctx pointer to a BN_CTX object (may be NULL) + * \param kinv pointer to a BIGNUM pointer for the inverse of k + * \param rp pointer to a BIGNUM pointer for x coordinate of k * generator + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, + BIGNUM **rp); + +/** ECDSA_sign + * computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param type this parameter is ignored + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param sig buffer to hold the DER encoded signature + * \param siglen pointer to the length of the returned signature + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, + unsigned char *sig, unsigned int *siglen, EC_KEY *eckey); + + +/** ECDSA_sign_ex + * computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param type this parameter is ignored + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param sig buffer to hold the DER encoded signature + * \param siglen pointer to the length of the returned signature + * \param kinv optional pointer to a pre-computed inverse k + * \param rp optional pointer to the pre-computed rp value (see + * ECDSA_sign_setup + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, + unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, + const BIGNUM *rp, EC_KEY *eckey); + +/** ECDSA_verify + * verifies that the given signature is valid ECDSA signature + * of the supplied hash value using the specified public key. + * \param type this parameter is ignored + * \param dgst pointer to the hash value + * \param dgstlen length of the hash value + * \param sig pointer to the DER encoded signature + * \param siglen length of the DER encoded signature + * \param eckey pointer to the EC_KEY object containing a public EC key + * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error + */ +int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, + const unsigned char *sig, int siglen, EC_KEY *eckey); + +/* the standard ex_data functions */ +int ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new + *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg); +void *ECDSA_get_ex_data(EC_KEY *d, int idx); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ECDSA_strings(void); + +/* Error codes for the ECDSA functions. */ + +/* Function codes. */ +#define ECDSA_F_ECDSA_DATA_NEW_METHOD 100 +#define ECDSA_F_ECDSA_DO_SIGN 101 +#define ECDSA_F_ECDSA_DO_VERIFY 102 +#define ECDSA_F_ECDSA_SIGN_SETUP 103 + +/* Reason codes. */ +#define ECDSA_R_BAD_SIGNATURE 100 +#define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 101 +#define ECDSA_R_ERR_EC_LIB 102 +#define ECDSA_R_MISSING_PARAMETERS 103 +#define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED 104 +#define ECDSA_R_SIGNATURE_MALLOC_FAILED 105 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/engine.h b/src/dep/include/openssl/engine.h index 67a027d..1d485ef 100644 --- a/src/dep/include/openssl/engine.h +++ b/src/dep/include/openssl/engine.h @@ -1,785 +1,785 @@ -/* openssl/engine.h */ -/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL - * project 2000. - */ -/* ==================================================================== - * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * ECDH support in OpenSSL originally developed by - * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. - */ - -#ifndef HEADER_ENGINE_H -#define HEADER_ENGINE_H - -#include - -#ifdef OPENSSL_NO_ENGINE -#error ENGINE is disabled. -#endif - -#ifndef OPENSSL_NO_DEPRECATED -#include -#ifndef OPENSSL_NO_RSA -#include -#endif -#ifndef OPENSSL_NO_DSA -#include -#endif -#ifndef OPENSSL_NO_DH -#include -#endif -#ifndef OPENSSL_NO_ECDH -#include -#endif -#ifndef OPENSSL_NO_ECDSA -#include -#endif -#include -#include -#include -#include -#endif - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* These flags are used to control combinations of algorithm (methods) - * by bitwise "OR"ing. */ -#define ENGINE_METHOD_RSA (unsigned int)0x0001 -#define ENGINE_METHOD_DSA (unsigned int)0x0002 -#define ENGINE_METHOD_DH (unsigned int)0x0004 -#define ENGINE_METHOD_RAND (unsigned int)0x0008 -#define ENGINE_METHOD_ECDH (unsigned int)0x0010 -#define ENGINE_METHOD_ECDSA (unsigned int)0x0020 -#define ENGINE_METHOD_CIPHERS (unsigned int)0x0040 -#define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 -#define ENGINE_METHOD_STORE (unsigned int)0x0100 -/* Obvious all-or-nothing cases. */ -#define ENGINE_METHOD_ALL (unsigned int)0xFFFF -#define ENGINE_METHOD_NONE (unsigned int)0x0000 - -/* This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used - * internally to control registration of ENGINE implementations, and can be set - * by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to - * initialise registered ENGINEs if they are not already initialised. */ -#define ENGINE_TABLE_FLAG_NOINIT (unsigned int)0x0001 - -/* ENGINE flags that can be set by ENGINE_set_flags(). */ -/* #define ENGINE_FLAGS_MALLOCED 0x0001 */ /* Not used */ - -/* This flag is for ENGINEs that wish to handle the various 'CMD'-related - * control commands on their own. Without this flag, ENGINE_ctrl() handles these - * control commands on behalf of the ENGINE using their "cmd_defns" data. */ -#define ENGINE_FLAGS_MANUAL_CMD_CTRL (int)0x0002 - -/* This flag is for ENGINEs who return new duplicate structures when found via - * "ENGINE_by_id()". When an ENGINE must store state (eg. if ENGINE_ctrl() - * commands are called in sequence as part of some stateful process like - * key-generation setup and execution), it can set this flag - then each attempt - * to obtain the ENGINE will result in it being copied into a new structure. - * Normally, ENGINEs don't declare this flag so ENGINE_by_id() just increments - * the existing ENGINE's structural reference count. */ -#define ENGINE_FLAGS_BY_ID_COPY (int)0x0004 - -/* ENGINEs can support their own command types, and these flags are used in - * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input each - * command expects. Currently only numeric and string input is supported. If a - * control command supports none of the _NUMERIC, _STRING, or _NO_INPUT options, - * then it is regarded as an "internal" control command - and not for use in - * config setting situations. As such, they're not available to the - * ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl() access. Changes to - * this list of 'command types' should be reflected carefully in - * ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string(). */ - -/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */ -#define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 -/* accepts string input (cast from 'void*' to 'const char *', 4th parameter to - * ENGINE_ctrl) */ -#define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 -/* Indicates that the control command takes *no* input. Ie. the control command - * is unparameterised. */ -#define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 -/* Indicates that the control command is internal. This control command won't - * be shown in any output, and is only usable through the ENGINE_ctrl_cmd() - * function. */ -#define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 - -/* NB: These 3 control commands are deprecated and should not be used. ENGINEs - * relying on these commands should compile conditional support for - * compatibility (eg. if these symbols are defined) but should also migrate the - * same functionality to their own ENGINE-specific control functions that can be - * "discovered" by calling applications. The fact these control commands - * wouldn't be "executable" (ie. usable by text-based config) doesn't change the - * fact that application code can find and use them without requiring per-ENGINE - * hacking. */ - -/* These flags are used to tell the ctrl function what should be done. - * All command numbers are shared between all engines, even if some don't - * make sense to some engines. In such a case, they do nothing but return - * the error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED. */ -#define ENGINE_CTRL_SET_LOGSTREAM 1 -#define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2 -#define ENGINE_CTRL_HUP 3 /* Close and reinitialise any - handles/connections etc. */ -#define ENGINE_CTRL_SET_USER_INTERFACE 4 /* Alternative to callback */ -#define ENGINE_CTRL_SET_CALLBACK_DATA 5 /* User-specific data, used - when calling the password - callback and the user - interface */ -#define ENGINE_CTRL_LOAD_CONFIGURATION 6 /* Load a configuration, given - a string that represents a - file name or so */ -#define ENGINE_CTRL_LOAD_SECTION 7 /* Load data from a given - section in the already loaded - configuration */ - -/* These control commands allow an application to deal with an arbitrary engine - * in a dynamic way. Warn: Negative return values indicate errors FOR THESE - * COMMANDS because zero is used to indicate 'end-of-list'. Other commands, - * including ENGINE-specific command types, return zero for an error. - * - * An ENGINE can choose to implement these ctrl functions, and can internally - * manage things however it chooses - it does so by setting the - * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise the - * ENGINE_ctrl() code handles this on the ENGINE's behalf using the cmd_defns - * data (set using ENGINE_set_cmd_defns()). This means an ENGINE's ctrl() - * handler need only implement its own commands - the above "meta" commands will - * be taken care of. */ - -/* Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not", then - * all the remaining control commands will return failure, so it is worth - * checking this first if the caller is trying to "discover" the engine's - * capabilities and doesn't want errors generated unnecessarily. */ -#define ENGINE_CTRL_HAS_CTRL_FUNCTION 10 -/* Returns a positive command number for the first command supported by the - * engine. Returns zero if no ctrl commands are supported. */ -#define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 -/* The 'long' argument specifies a command implemented by the engine, and the - * return value is the next command supported, or zero if there are no more. */ -#define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 -/* The 'void*' argument is a command name (cast from 'const char *'), and the - * return value is the command that corresponds to it. */ -#define ENGINE_CTRL_GET_CMD_FROM_NAME 13 -/* The next two allow a command to be converted into its corresponding string - * form. In each case, the 'long' argument supplies the command. In the NAME_LEN - * case, the return value is the length of the command name (not counting a - * trailing EOL). In the NAME case, the 'void*' argument must be a string buffer - * large enough, and it will be populated with the name of the command (WITH a - * trailing EOL). */ -#define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 -#define ENGINE_CTRL_GET_NAME_FROM_CMD 15 -/* The next two are similar but give a "short description" of a command. */ -#define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 -#define ENGINE_CTRL_GET_DESC_FROM_CMD 17 -/* With this command, the return value is the OR'd combination of - * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given - * engine-specific ctrl command expects. */ -#define ENGINE_CTRL_GET_CMD_FLAGS 18 - -/* ENGINE implementations should start the numbering of their own control - * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc). */ -#define ENGINE_CMD_BASE 200 - -/* NB: These 2 nCipher "chil" control commands are deprecated, and their - * functionality is now available through ENGINE-specific control commands - * (exposed through the above-mentioned 'CMD'-handling). Code using these 2 - * commands should be migrated to the more general command handling before these - * are removed. */ - -/* Flags specific to the nCipher "chil" engine */ -#define ENGINE_CTRL_CHIL_SET_FORKCHECK 100 - /* Depending on the value of the (long)i argument, this sets or - * unsets the SimpleForkCheck flag in the CHIL API to enable or - * disable checking and workarounds for applications that fork(). - */ -#define ENGINE_CTRL_CHIL_NO_LOCKING 101 - /* This prevents the initialisation function from providing mutex - * callbacks to the nCipher library. */ - -/* If an ENGINE supports its own specific control commands and wishes the - * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on its - * behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN entries - * to ENGINE_set_cmd_defns(). It should also implement a ctrl() handler that - * supports the stated commands (ie. the "cmd_num" entries as described by the - * array). NB: The array must be ordered in increasing order of cmd_num. - * "null-terminated" means that the last ENGINE_CMD_DEFN element has cmd_num set - * to zero and/or cmd_name set to NULL. */ -typedef struct ENGINE_CMD_DEFN_st - { - unsigned int cmd_num; /* The command number */ - const char *cmd_name; /* The command name itself */ - const char *cmd_desc; /* A short description of the command */ - unsigned int cmd_flags; /* The input the command expects */ - } ENGINE_CMD_DEFN; - -/* Generic function pointer */ -typedef int (*ENGINE_GEN_FUNC_PTR)(void); -/* Generic function pointer taking no arguments */ -typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *); -/* Specific control function pointer */ -typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, void (*f)(void)); -/* Generic load_key function pointer */ -typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, - UI_METHOD *ui_method, void *callback_data); -/* These callback types are for an ENGINE's handler for cipher and digest logic. - * These handlers have these prototypes; - * int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); - * int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid); - * Looking at how to implement these handlers in the case of cipher support, if - * the framework wants the EVP_CIPHER for 'nid', it will call; - * foo(e, &p_evp_cipher, NULL, nid); (return zero for failure) - * If the framework wants a list of supported 'nid's, it will call; - * foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error) - */ -/* Returns to a pointer to the array of supported cipher 'nid's. If the second - * parameter is non-NULL it is set to the size of the returned array. */ -typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, const int **, int); -typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int); - -/* STRUCTURE functions ... all of these functions deal with pointers to ENGINE - * structures where the pointers have a "structural reference". This means that - * their reference is to allowed access to the structure but it does not imply - * that the structure is functional. To simply increment or decrement the - * structural reference count, use ENGINE_by_id and ENGINE_free. NB: This is not - * required when iterating using ENGINE_get_next as it will automatically - * decrement the structural reference count of the "current" ENGINE and - * increment the structural reference count of the ENGINE it returns (unless it - * is NULL). */ - -/* Get the first/last "ENGINE" type available. */ -ENGINE *ENGINE_get_first(void); -ENGINE *ENGINE_get_last(void); -/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */ -ENGINE *ENGINE_get_next(ENGINE *e); -ENGINE *ENGINE_get_prev(ENGINE *e); -/* Add another "ENGINE" type into the array. */ -int ENGINE_add(ENGINE *e); -/* Remove an existing "ENGINE" type from the array. */ -int ENGINE_remove(ENGINE *e); -/* Retrieve an engine from the list by its unique "id" value. */ -ENGINE *ENGINE_by_id(const char *id); -/* Add all the built-in engines. */ -void ENGINE_load_openssl(void); -void ENGINE_load_dynamic(void); -#ifndef OPENSSL_NO_STATIC_ENGINE -void ENGINE_load_4758cca(void); -void ENGINE_load_aep(void); -void ENGINE_load_atalla(void); -void ENGINE_load_chil(void); -void ENGINE_load_cswift(void); -#ifndef OPENSSL_NO_GMP -void ENGINE_load_gmp(void); -#endif -void ENGINE_load_nuron(void); -void ENGINE_load_sureware(void); -void ENGINE_load_ubsec(void); -#endif -void ENGINE_load_cryptodev(void); -void ENGINE_load_padlock(void); -void ENGINE_load_builtin_engines(void); - -/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation - * "registry" handling. */ -unsigned int ENGINE_get_table_flags(void); -void ENGINE_set_table_flags(unsigned int flags); - -/* Manage registration of ENGINEs per "table". For each type, there are 3 - * functions; - * ENGINE_register_***(e) - registers the implementation from 'e' (if it has one) - * ENGINE_unregister_***(e) - unregister the implementation from 'e' - * ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list - * Cleanup is automatically registered from each table when required, so - * ENGINE_cleanup() will reverse any "register" operations. */ - -int ENGINE_register_RSA(ENGINE *e); -void ENGINE_unregister_RSA(ENGINE *e); -void ENGINE_register_all_RSA(void); - -int ENGINE_register_DSA(ENGINE *e); -void ENGINE_unregister_DSA(ENGINE *e); -void ENGINE_register_all_DSA(void); - -int ENGINE_register_ECDH(ENGINE *e); -void ENGINE_unregister_ECDH(ENGINE *e); -void ENGINE_register_all_ECDH(void); - -int ENGINE_register_ECDSA(ENGINE *e); -void ENGINE_unregister_ECDSA(ENGINE *e); -void ENGINE_register_all_ECDSA(void); - -int ENGINE_register_DH(ENGINE *e); -void ENGINE_unregister_DH(ENGINE *e); -void ENGINE_register_all_DH(void); - -int ENGINE_register_RAND(ENGINE *e); -void ENGINE_unregister_RAND(ENGINE *e); -void ENGINE_register_all_RAND(void); - -int ENGINE_register_STORE(ENGINE *e); -void ENGINE_unregister_STORE(ENGINE *e); -void ENGINE_register_all_STORE(void); - -int ENGINE_register_ciphers(ENGINE *e); -void ENGINE_unregister_ciphers(ENGINE *e); -void ENGINE_register_all_ciphers(void); - -int ENGINE_register_digests(ENGINE *e); -void ENGINE_unregister_digests(ENGINE *e); -void ENGINE_register_all_digests(void); - -/* These functions register all support from the above categories. Note, use of - * these functions can result in static linkage of code your application may not - * need. If you only need a subset of functionality, consider using more - * selective initialisation. */ -int ENGINE_register_complete(ENGINE *e); -int ENGINE_register_all_complete(void); - -/* Send parametrised control commands to the engine. The possibilities to send - * down an integer, a pointer to data or a function pointer are provided. Any of - * the parameters may or may not be NULL, depending on the command number. In - * actuality, this function only requires a structural (rather than functional) - * reference to an engine, but many control commands may require the engine be - * functional. The caller should be aware of trying commands that require an - * operational ENGINE, and only use functional references in such situations. */ -int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)); - -/* This function tests if an ENGINE-specific command is usable as a "setting". - * Eg. in an application's config file that gets processed through - * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to - * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl(). */ -int ENGINE_cmd_is_executable(ENGINE *e, int cmd); - -/* This function works like ENGINE_ctrl() with the exception of taking a - * command name instead of a command number, and can handle optional commands. - * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to - * use the cmd_name and cmd_optional. */ -int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, - long i, void *p, void (*f)(void), int cmd_optional); - -/* This function passes a command-name and argument to an ENGINE. The cmd_name - * is converted to a command number and the control command is called using - * 'arg' as an argument (unless the ENGINE doesn't support such a command, in - * which case no control command is called). The command is checked for input - * flags, and if necessary the argument will be converted to a numeric value. If - * cmd_optional is non-zero, then if the ENGINE doesn't support the given - * cmd_name the return value will be success anyway. This function is intended - * for applications to use so that users (or config files) can supply - * engine-specific config data to the ENGINE at run-time to control behaviour of - * specific engines. As such, it shouldn't be used for calling ENGINE_ctrl() - * functions that return data, deal with binary data, or that are otherwise - * supposed to be used directly through ENGINE_ctrl() in application code. Any - * "return" data from an ENGINE_ctrl() operation in this function will be lost - - * the return value is interpreted as failure if the return value is zero, - * success otherwise, and this function returns a boolean value as a result. In - * other words, vendors of 'ENGINE'-enabled devices should write ENGINE - * implementations with parameterisations that work in this scheme, so that - * compliant ENGINE-based applications can work consistently with the same - * configuration for the same ENGINE-enabled devices, across applications. */ -int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, - int cmd_optional); - -/* These functions are useful for manufacturing new ENGINE structures. They - * don't address reference counting at all - one uses them to populate an ENGINE - * structure with personalised implementations of things prior to using it - * directly or adding it to the builtin ENGINE list in OpenSSL. These are also - * here so that the ENGINE structure doesn't have to be exposed and break binary - * compatibility! */ -ENGINE *ENGINE_new(void); -int ENGINE_free(ENGINE *e); -int ENGINE_up_ref(ENGINE *e); -int ENGINE_set_id(ENGINE *e, const char *id); -int ENGINE_set_name(ENGINE *e, const char *name); -int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); -int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); -int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth); -int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth); -int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); -int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); -int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth); -int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f); -int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); -int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); -int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f); -int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f); -int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); -int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); -int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); -int ENGINE_set_flags(ENGINE *e, int flags); -int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); -/* These functions allow control over any per-structure ENGINE data. */ -int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); -int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); -void *ENGINE_get_ex_data(const ENGINE *e, int idx); - -/* This function cleans up anything that needs it. Eg. the ENGINE_add() function - * automatically ensures the list cleanup function is registered to be called - * from ENGINE_cleanup(). Similarly, all ENGINE_register_*** functions ensure - * ENGINE_cleanup() will clean up after them. */ -void ENGINE_cleanup(void); - -/* These return values from within the ENGINE structure. These can be useful - * with functional references as well as structural references - it depends - * which you obtained. Using the result for functional purposes if you only - * obtained a structural reference may be problematic! */ -const char *ENGINE_get_id(const ENGINE *e); -const char *ENGINE_get_name(const ENGINE *e); -const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); -const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); -const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e); -const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e); -const DH_METHOD *ENGINE_get_DH(const ENGINE *e); -const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); -const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e); -ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e); -ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e); -ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e); -ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e); -ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e); -ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e); -ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e); -ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e); -const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid); -const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); -const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); -int ENGINE_get_flags(const ENGINE *e); - -/* FUNCTIONAL functions. These functions deal with ENGINE structures - * that have (or will) be initialised for use. Broadly speaking, the - * structural functions are useful for iterating the list of available - * engine types, creating new engine types, and other "list" operations. - * These functions actually deal with ENGINEs that are to be used. As - * such these functions can fail (if applicable) when particular - * engines are unavailable - eg. if a hardware accelerator is not - * attached or not functioning correctly. Each ENGINE has 2 reference - * counts; structural and functional. Every time a functional reference - * is obtained or released, a corresponding structural reference is - * automatically obtained or released too. */ - -/* Initialise a engine type for use (or up its reference count if it's - * already in use). This will fail if the engine is not currently - * operational and cannot initialise. */ -int ENGINE_init(ENGINE *e); -/* Free a functional reference to a engine type. This does not require - * a corresponding call to ENGINE_free as it also releases a structural - * reference. */ -int ENGINE_finish(ENGINE *e); - -/* The following functions handle keys that are stored in some secondary - * location, handled by the engine. The storage may be on a card or - * whatever. */ -EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, - UI_METHOD *ui_method, void *callback_data); -EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, - UI_METHOD *ui_method, void *callback_data); - -/* This returns a pointer for the current ENGINE structure that - * is (by default) performing any RSA operations. The value returned - * is an incremented reference, so it should be free'd (ENGINE_finish) - * before it is discarded. */ -ENGINE *ENGINE_get_default_RSA(void); -/* Same for the other "methods" */ -ENGINE *ENGINE_get_default_DSA(void); -ENGINE *ENGINE_get_default_ECDH(void); -ENGINE *ENGINE_get_default_ECDSA(void); -ENGINE *ENGINE_get_default_DH(void); -ENGINE *ENGINE_get_default_RAND(void); -/* These functions can be used to get a functional reference to perform - * ciphering or digesting corresponding to "nid". */ -ENGINE *ENGINE_get_cipher_engine(int nid); -ENGINE *ENGINE_get_digest_engine(int nid); - -/* This sets a new default ENGINE structure for performing RSA - * operations. If the result is non-zero (success) then the ENGINE - * structure will have had its reference count up'd so the caller - * should still free their own reference 'e'. */ -int ENGINE_set_default_RSA(ENGINE *e); -int ENGINE_set_default_string(ENGINE *e, const char *def_list); -/* Same for the other "methods" */ -int ENGINE_set_default_DSA(ENGINE *e); -int ENGINE_set_default_ECDH(ENGINE *e); -int ENGINE_set_default_ECDSA(ENGINE *e); -int ENGINE_set_default_DH(ENGINE *e); -int ENGINE_set_default_RAND(ENGINE *e); -int ENGINE_set_default_ciphers(ENGINE *e); -int ENGINE_set_default_digests(ENGINE *e); - -/* The combination "set" - the flags are bitwise "OR"d from the - * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()" - * function, this function can result in unnecessary static linkage. If your - * application requires only specific functionality, consider using more - * selective functions. */ -int ENGINE_set_default(ENGINE *e, unsigned int flags); - -void ENGINE_add_conf_module(void); - -/* Deprecated functions ... */ -/* int ENGINE_clear_defaults(void); */ - -/**************************/ -/* DYNAMIC ENGINE SUPPORT */ -/**************************/ - -/* Binary/behaviour compatibility levels */ -#define OSSL_DYNAMIC_VERSION (unsigned long)0x00020000 -/* Binary versions older than this are too old for us (whether we're a loader or - * a loadee) */ -#define OSSL_DYNAMIC_OLDEST (unsigned long)0x00020000 - -/* When compiling an ENGINE entirely as an external shared library, loadable by - * the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' structure - * type provides the calling application's (or library's) error functionality - * and memory management function pointers to the loaded library. These should - * be used/set in the loaded library code so that the loading application's - * 'state' will be used/changed in all operations. The 'static_state' pointer - * allows the loaded library to know if it shares the same static data as the - * calling application (or library), and thus whether these callbacks need to be - * set or not. */ -typedef void *(*dyn_MEM_malloc_cb)(size_t); -typedef void *(*dyn_MEM_realloc_cb)(void *, size_t); -typedef void (*dyn_MEM_free_cb)(void *); -typedef struct st_dynamic_MEM_fns { - dyn_MEM_malloc_cb malloc_cb; - dyn_MEM_realloc_cb realloc_cb; - dyn_MEM_free_cb free_cb; - } dynamic_MEM_fns; -/* FIXME: Perhaps the memory and locking code (crypto.h) should declare and use - * these types so we (and any other dependant code) can simplify a bit?? */ -typedef void (*dyn_lock_locking_cb)(int,int,const char *,int); -typedef int (*dyn_lock_add_lock_cb)(int*,int,int,const char *,int); -typedef struct CRYPTO_dynlock_value *(*dyn_dynlock_create_cb)( - const char *,int); -typedef void (*dyn_dynlock_lock_cb)(int,struct CRYPTO_dynlock_value *, - const char *,int); -typedef void (*dyn_dynlock_destroy_cb)(struct CRYPTO_dynlock_value *, - const char *,int); -typedef struct st_dynamic_LOCK_fns { - dyn_lock_locking_cb lock_locking_cb; - dyn_lock_add_lock_cb lock_add_lock_cb; - dyn_dynlock_create_cb dynlock_create_cb; - dyn_dynlock_lock_cb dynlock_lock_cb; - dyn_dynlock_destroy_cb dynlock_destroy_cb; - } dynamic_LOCK_fns; -/* The top-level structure */ -typedef struct st_dynamic_fns { - void *static_state; - const ERR_FNS *err_fns; - const CRYPTO_EX_DATA_IMPL *ex_data_fns; - dynamic_MEM_fns mem_fns; - dynamic_LOCK_fns lock_fns; - } dynamic_fns; - -/* The version checking function should be of this prototype. NB: The - * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading code. - * If this function returns zero, it indicates a (potential) version - * incompatibility and the loaded library doesn't believe it can proceed. - * Otherwise, the returned value is the (latest) version supported by the - * loading library. The loader may still decide that the loaded code's version - * is unsatisfactory and could veto the load. The function is expected to - * be implemented with the symbol name "v_check", and a default implementation - * can be fully instantiated with IMPLEMENT_DYNAMIC_CHECK_FN(). */ -typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version); -#define IMPLEMENT_DYNAMIC_CHECK_FN() \ - OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \ - if(v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \ - return 0; } - -/* This function is passed the ENGINE structure to initialise with its own - * function and command settings. It should not adjust the structural or - * functional reference counts. If this function returns zero, (a) the load will - * be aborted, (b) the previous ENGINE state will be memcpy'd back onto the - * structure, and (c) the shared library will be unloaded. So implementations - * should do their own internal cleanup in failure circumstances otherwise they - * could leak. The 'id' parameter, if non-NULL, represents the ENGINE id that - * the loader is looking for. If this is NULL, the shared library can choose to - * return failure or to initialise a 'default' ENGINE. If non-NULL, the shared - * library must initialise only an ENGINE matching the passed 'id'. The function - * is expected to be implemented with the symbol name "bind_engine". A standard - * implementation can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where - * the parameter 'fn' is a callback function that populates the ENGINE structure - * and returns an int value (zero for failure). 'fn' should have prototype; - * [static] int fn(ENGINE *e, const char *id); */ -typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, - const dynamic_fns *fns); -#define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ - OPENSSL_EXPORT \ - int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \ - if(ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \ - if(!CRYPTO_set_mem_functions(fns->mem_fns.malloc_cb, \ - fns->mem_fns.realloc_cb, fns->mem_fns.free_cb)) \ - return 0; \ - CRYPTO_set_locking_callback(fns->lock_fns.lock_locking_cb); \ - CRYPTO_set_add_lock_callback(fns->lock_fns.lock_add_lock_cb); \ - CRYPTO_set_dynlock_create_callback(fns->lock_fns.dynlock_create_cb); \ - CRYPTO_set_dynlock_lock_callback(fns->lock_fns.dynlock_lock_cb); \ - CRYPTO_set_dynlock_destroy_callback(fns->lock_fns.dynlock_destroy_cb); \ - if(!CRYPTO_set_ex_data_implementation(fns->ex_data_fns)) \ - return 0; \ - if(!ERR_set_implementation(fns->err_fns)) return 0; \ - skip_cbs: \ - if(!fn(e,id)) return 0; \ - return 1; } - -/* If the loading application (or library) and the loaded ENGINE library share - * the same static data (eg. they're both dynamically linked to the same - * libcrypto.so) we need a way to avoid trying to set system callbacks - this - * would fail, and for the same reason that it's unnecessary to try. If the - * loaded ENGINE has (or gets from through the loader) its own copy of the - * libcrypto static data, we will need to set the callbacks. The easiest way to - * detect this is to have a function that returns a pointer to some static data - * and let the loading application and loaded ENGINE compare their respective - * values. */ -void *ENGINE_get_static_state(void); - -#if defined(__OpenBSD__) || defined(__FreeBSD__) -void ENGINE_setup_bsd_cryptodev(void); -#endif - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_ENGINE_strings(void); - -/* Error codes for the ENGINE functions. */ - -/* Function codes. */ -#define ENGINE_F_DYNAMIC_CTRL 180 -#define ENGINE_F_DYNAMIC_GET_DATA_CTX 181 -#define ENGINE_F_DYNAMIC_LOAD 182 -#define ENGINE_F_DYNAMIC_SET_DATA_CTX 183 -#define ENGINE_F_ENGINE_ADD 105 -#define ENGINE_F_ENGINE_BY_ID 106 -#define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 170 -#define ENGINE_F_ENGINE_CTRL 142 -#define ENGINE_F_ENGINE_CTRL_CMD 178 -#define ENGINE_F_ENGINE_CTRL_CMD_STRING 171 -#define ENGINE_F_ENGINE_FINISH 107 -#define ENGINE_F_ENGINE_FREE_UTIL 108 -#define ENGINE_F_ENGINE_GET_CIPHER 185 -#define ENGINE_F_ENGINE_GET_DEFAULT_TYPE 177 -#define ENGINE_F_ENGINE_GET_DIGEST 186 -#define ENGINE_F_ENGINE_GET_NEXT 115 -#define ENGINE_F_ENGINE_GET_PREV 116 -#define ENGINE_F_ENGINE_INIT 119 -#define ENGINE_F_ENGINE_LIST_ADD 120 -#define ENGINE_F_ENGINE_LIST_REMOVE 121 -#define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150 -#define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151 -#define ENGINE_F_ENGINE_NEW 122 -#define ENGINE_F_ENGINE_REMOVE 123 -#define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189 -#define ENGINE_F_ENGINE_SET_DEFAULT_TYPE 126 -#define ENGINE_F_ENGINE_SET_ID 129 -#define ENGINE_F_ENGINE_SET_NAME 130 -#define ENGINE_F_ENGINE_TABLE_REGISTER 184 -#define ENGINE_F_ENGINE_UNLOAD_KEY 152 -#define ENGINE_F_ENGINE_UNLOCKED_FINISH 191 -#define ENGINE_F_ENGINE_UP_REF 190 -#define ENGINE_F_INT_CTRL_HELPER 172 -#define ENGINE_F_INT_ENGINE_CONFIGURE 188 -#define ENGINE_F_INT_ENGINE_MODULE_INIT 187 -#define ENGINE_F_LOG_MESSAGE 141 - -/* Reason codes. */ -#define ENGINE_R_ALREADY_LOADED 100 -#define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 133 -#define ENGINE_R_CMD_NOT_EXECUTABLE 134 -#define ENGINE_R_COMMAND_TAKES_INPUT 135 -#define ENGINE_R_COMMAND_TAKES_NO_INPUT 136 -#define ENGINE_R_CONFLICTING_ENGINE_ID 103 -#define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119 -#define ENGINE_R_DH_NOT_IMPLEMENTED 139 -#define ENGINE_R_DSA_NOT_IMPLEMENTED 140 -#define ENGINE_R_DSO_FAILURE 104 -#define ENGINE_R_DSO_NOT_FOUND 132 -#define ENGINE_R_ENGINES_SECTION_ERROR 148 -#define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105 -#define ENGINE_R_ENGINE_SECTION_ERROR 149 -#define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128 -#define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129 -#define ENGINE_R_FINISH_FAILED 106 -#define ENGINE_R_GET_HANDLE_FAILED 107 -#define ENGINE_R_ID_OR_NAME_MISSING 108 -#define ENGINE_R_INIT_FAILED 109 -#define ENGINE_R_INTERNAL_LIST_ERROR 110 -#define ENGINE_R_INVALID_ARGUMENT 143 -#define ENGINE_R_INVALID_CMD_NAME 137 -#define ENGINE_R_INVALID_CMD_NUMBER 138 -#define ENGINE_R_INVALID_INIT_VALUE 151 -#define ENGINE_R_INVALID_STRING 150 -#define ENGINE_R_NOT_INITIALISED 117 -#define ENGINE_R_NOT_LOADED 112 -#define ENGINE_R_NO_CONTROL_FUNCTION 120 -#define ENGINE_R_NO_INDEX 144 -#define ENGINE_R_NO_LOAD_FUNCTION 125 -#define ENGINE_R_NO_REFERENCE 130 -#define ENGINE_R_NO_SUCH_ENGINE 116 -#define ENGINE_R_NO_UNLOAD_FUNCTION 126 -#define ENGINE_R_PROVIDE_PARAMETERS 113 -#define ENGINE_R_RSA_NOT_IMPLEMENTED 141 -#define ENGINE_R_UNIMPLEMENTED_CIPHER 146 -#define ENGINE_R_UNIMPLEMENTED_DIGEST 147 -#define ENGINE_R_VERSION_INCOMPATIBILITY 145 - -#ifdef __cplusplus -} -#endif -#endif +/* openssl/engine.h */ +/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECDH support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_ENGINE_H +#define HEADER_ENGINE_H + +#include + +#ifdef OPENSSL_NO_ENGINE +#error ENGINE is disabled. +#endif + +#ifndef OPENSSL_NO_DEPRECATED +#include +#ifndef OPENSSL_NO_RSA +#include +#endif +#ifndef OPENSSL_NO_DSA +#include +#endif +#ifndef OPENSSL_NO_DH +#include +#endif +#ifndef OPENSSL_NO_ECDH +#include +#endif +#ifndef OPENSSL_NO_ECDSA +#include +#endif +#include +#include +#include +#include +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These flags are used to control combinations of algorithm (methods) + * by bitwise "OR"ing. */ +#define ENGINE_METHOD_RSA (unsigned int)0x0001 +#define ENGINE_METHOD_DSA (unsigned int)0x0002 +#define ENGINE_METHOD_DH (unsigned int)0x0004 +#define ENGINE_METHOD_RAND (unsigned int)0x0008 +#define ENGINE_METHOD_ECDH (unsigned int)0x0010 +#define ENGINE_METHOD_ECDSA (unsigned int)0x0020 +#define ENGINE_METHOD_CIPHERS (unsigned int)0x0040 +#define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 +#define ENGINE_METHOD_STORE (unsigned int)0x0100 +/* Obvious all-or-nothing cases. */ +#define ENGINE_METHOD_ALL (unsigned int)0xFFFF +#define ENGINE_METHOD_NONE (unsigned int)0x0000 + +/* This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used + * internally to control registration of ENGINE implementations, and can be set + * by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to + * initialise registered ENGINEs if they are not already initialised. */ +#define ENGINE_TABLE_FLAG_NOINIT (unsigned int)0x0001 + +/* ENGINE flags that can be set by ENGINE_set_flags(). */ +/* #define ENGINE_FLAGS_MALLOCED 0x0001 */ /* Not used */ + +/* This flag is for ENGINEs that wish to handle the various 'CMD'-related + * control commands on their own. Without this flag, ENGINE_ctrl() handles these + * control commands on behalf of the ENGINE using their "cmd_defns" data. */ +#define ENGINE_FLAGS_MANUAL_CMD_CTRL (int)0x0002 + +/* This flag is for ENGINEs who return new duplicate structures when found via + * "ENGINE_by_id()". When an ENGINE must store state (eg. if ENGINE_ctrl() + * commands are called in sequence as part of some stateful process like + * key-generation setup and execution), it can set this flag - then each attempt + * to obtain the ENGINE will result in it being copied into a new structure. + * Normally, ENGINEs don't declare this flag so ENGINE_by_id() just increments + * the existing ENGINE's structural reference count. */ +#define ENGINE_FLAGS_BY_ID_COPY (int)0x0004 + +/* ENGINEs can support their own command types, and these flags are used in + * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input each + * command expects. Currently only numeric and string input is supported. If a + * control command supports none of the _NUMERIC, _STRING, or _NO_INPUT options, + * then it is regarded as an "internal" control command - and not for use in + * config setting situations. As such, they're not available to the + * ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl() access. Changes to + * this list of 'command types' should be reflected carefully in + * ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string(). */ + +/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */ +#define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 +/* accepts string input (cast from 'void*' to 'const char *', 4th parameter to + * ENGINE_ctrl) */ +#define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 +/* Indicates that the control command takes *no* input. Ie. the control command + * is unparameterised. */ +#define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 +/* Indicates that the control command is internal. This control command won't + * be shown in any output, and is only usable through the ENGINE_ctrl_cmd() + * function. */ +#define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 + +/* NB: These 3 control commands are deprecated and should not be used. ENGINEs + * relying on these commands should compile conditional support for + * compatibility (eg. if these symbols are defined) but should also migrate the + * same functionality to their own ENGINE-specific control functions that can be + * "discovered" by calling applications. The fact these control commands + * wouldn't be "executable" (ie. usable by text-based config) doesn't change the + * fact that application code can find and use them without requiring per-ENGINE + * hacking. */ + +/* These flags are used to tell the ctrl function what should be done. + * All command numbers are shared between all engines, even if some don't + * make sense to some engines. In such a case, they do nothing but return + * the error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED. */ +#define ENGINE_CTRL_SET_LOGSTREAM 1 +#define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2 +#define ENGINE_CTRL_HUP 3 /* Close and reinitialise any + handles/connections etc. */ +#define ENGINE_CTRL_SET_USER_INTERFACE 4 /* Alternative to callback */ +#define ENGINE_CTRL_SET_CALLBACK_DATA 5 /* User-specific data, used + when calling the password + callback and the user + interface */ +#define ENGINE_CTRL_LOAD_CONFIGURATION 6 /* Load a configuration, given + a string that represents a + file name or so */ +#define ENGINE_CTRL_LOAD_SECTION 7 /* Load data from a given + section in the already loaded + configuration */ + +/* These control commands allow an application to deal with an arbitrary engine + * in a dynamic way. Warn: Negative return values indicate errors FOR THESE + * COMMANDS because zero is used to indicate 'end-of-list'. Other commands, + * including ENGINE-specific command types, return zero for an error. + * + * An ENGINE can choose to implement these ctrl functions, and can internally + * manage things however it chooses - it does so by setting the + * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise the + * ENGINE_ctrl() code handles this on the ENGINE's behalf using the cmd_defns + * data (set using ENGINE_set_cmd_defns()). This means an ENGINE's ctrl() + * handler need only implement its own commands - the above "meta" commands will + * be taken care of. */ + +/* Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not", then + * all the remaining control commands will return failure, so it is worth + * checking this first if the caller is trying to "discover" the engine's + * capabilities and doesn't want errors generated unnecessarily. */ +#define ENGINE_CTRL_HAS_CTRL_FUNCTION 10 +/* Returns a positive command number for the first command supported by the + * engine. Returns zero if no ctrl commands are supported. */ +#define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 +/* The 'long' argument specifies a command implemented by the engine, and the + * return value is the next command supported, or zero if there are no more. */ +#define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 +/* The 'void*' argument is a command name (cast from 'const char *'), and the + * return value is the command that corresponds to it. */ +#define ENGINE_CTRL_GET_CMD_FROM_NAME 13 +/* The next two allow a command to be converted into its corresponding string + * form. In each case, the 'long' argument supplies the command. In the NAME_LEN + * case, the return value is the length of the command name (not counting a + * trailing EOL). In the NAME case, the 'void*' argument must be a string buffer + * large enough, and it will be populated with the name of the command (WITH a + * trailing EOL). */ +#define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 +#define ENGINE_CTRL_GET_NAME_FROM_CMD 15 +/* The next two are similar but give a "short description" of a command. */ +#define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 +#define ENGINE_CTRL_GET_DESC_FROM_CMD 17 +/* With this command, the return value is the OR'd combination of + * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given + * engine-specific ctrl command expects. */ +#define ENGINE_CTRL_GET_CMD_FLAGS 18 + +/* ENGINE implementations should start the numbering of their own control + * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc). */ +#define ENGINE_CMD_BASE 200 + +/* NB: These 2 nCipher "chil" control commands are deprecated, and their + * functionality is now available through ENGINE-specific control commands + * (exposed through the above-mentioned 'CMD'-handling). Code using these 2 + * commands should be migrated to the more general command handling before these + * are removed. */ + +/* Flags specific to the nCipher "chil" engine */ +#define ENGINE_CTRL_CHIL_SET_FORKCHECK 100 + /* Depending on the value of the (long)i argument, this sets or + * unsets the SimpleForkCheck flag in the CHIL API to enable or + * disable checking and workarounds for applications that fork(). + */ +#define ENGINE_CTRL_CHIL_NO_LOCKING 101 + /* This prevents the initialisation function from providing mutex + * callbacks to the nCipher library. */ + +/* If an ENGINE supports its own specific control commands and wishes the + * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on its + * behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN entries + * to ENGINE_set_cmd_defns(). It should also implement a ctrl() handler that + * supports the stated commands (ie. the "cmd_num" entries as described by the + * array). NB: The array must be ordered in increasing order of cmd_num. + * "null-terminated" means that the last ENGINE_CMD_DEFN element has cmd_num set + * to zero and/or cmd_name set to NULL. */ +typedef struct ENGINE_CMD_DEFN_st + { + unsigned int cmd_num; /* The command number */ + const char *cmd_name; /* The command name itself */ + const char *cmd_desc; /* A short description of the command */ + unsigned int cmd_flags; /* The input the command expects */ + } ENGINE_CMD_DEFN; + +/* Generic function pointer */ +typedef int (*ENGINE_GEN_FUNC_PTR)(void); +/* Generic function pointer taking no arguments */ +typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *); +/* Specific control function pointer */ +typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, void (*f)(void)); +/* Generic load_key function pointer */ +typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, + UI_METHOD *ui_method, void *callback_data); +/* These callback types are for an ENGINE's handler for cipher and digest logic. + * These handlers have these prototypes; + * int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); + * int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid); + * Looking at how to implement these handlers in the case of cipher support, if + * the framework wants the EVP_CIPHER for 'nid', it will call; + * foo(e, &p_evp_cipher, NULL, nid); (return zero for failure) + * If the framework wants a list of supported 'nid's, it will call; + * foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error) + */ +/* Returns to a pointer to the array of supported cipher 'nid's. If the second + * parameter is non-NULL it is set to the size of the returned array. */ +typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, const int **, int); +typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int); + +/* STRUCTURE functions ... all of these functions deal with pointers to ENGINE + * structures where the pointers have a "structural reference". This means that + * their reference is to allowed access to the structure but it does not imply + * that the structure is functional. To simply increment or decrement the + * structural reference count, use ENGINE_by_id and ENGINE_free. NB: This is not + * required when iterating using ENGINE_get_next as it will automatically + * decrement the structural reference count of the "current" ENGINE and + * increment the structural reference count of the ENGINE it returns (unless it + * is NULL). */ + +/* Get the first/last "ENGINE" type available. */ +ENGINE *ENGINE_get_first(void); +ENGINE *ENGINE_get_last(void); +/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */ +ENGINE *ENGINE_get_next(ENGINE *e); +ENGINE *ENGINE_get_prev(ENGINE *e); +/* Add another "ENGINE" type into the array. */ +int ENGINE_add(ENGINE *e); +/* Remove an existing "ENGINE" type from the array. */ +int ENGINE_remove(ENGINE *e); +/* Retrieve an engine from the list by its unique "id" value. */ +ENGINE *ENGINE_by_id(const char *id); +/* Add all the built-in engines. */ +void ENGINE_load_openssl(void); +void ENGINE_load_dynamic(void); +#ifndef OPENSSL_NO_STATIC_ENGINE +void ENGINE_load_4758cca(void); +void ENGINE_load_aep(void); +void ENGINE_load_atalla(void); +void ENGINE_load_chil(void); +void ENGINE_load_cswift(void); +#ifndef OPENSSL_NO_GMP +void ENGINE_load_gmp(void); +#endif +void ENGINE_load_nuron(void); +void ENGINE_load_sureware(void); +void ENGINE_load_ubsec(void); +#endif +void ENGINE_load_cryptodev(void); +void ENGINE_load_padlock(void); +void ENGINE_load_builtin_engines(void); + +/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation + * "registry" handling. */ +unsigned int ENGINE_get_table_flags(void); +void ENGINE_set_table_flags(unsigned int flags); + +/* Manage registration of ENGINEs per "table". For each type, there are 3 + * functions; + * ENGINE_register_***(e) - registers the implementation from 'e' (if it has one) + * ENGINE_unregister_***(e) - unregister the implementation from 'e' + * ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list + * Cleanup is automatically registered from each table when required, so + * ENGINE_cleanup() will reverse any "register" operations. */ + +int ENGINE_register_RSA(ENGINE *e); +void ENGINE_unregister_RSA(ENGINE *e); +void ENGINE_register_all_RSA(void); + +int ENGINE_register_DSA(ENGINE *e); +void ENGINE_unregister_DSA(ENGINE *e); +void ENGINE_register_all_DSA(void); + +int ENGINE_register_ECDH(ENGINE *e); +void ENGINE_unregister_ECDH(ENGINE *e); +void ENGINE_register_all_ECDH(void); + +int ENGINE_register_ECDSA(ENGINE *e); +void ENGINE_unregister_ECDSA(ENGINE *e); +void ENGINE_register_all_ECDSA(void); + +int ENGINE_register_DH(ENGINE *e); +void ENGINE_unregister_DH(ENGINE *e); +void ENGINE_register_all_DH(void); + +int ENGINE_register_RAND(ENGINE *e); +void ENGINE_unregister_RAND(ENGINE *e); +void ENGINE_register_all_RAND(void); + +int ENGINE_register_STORE(ENGINE *e); +void ENGINE_unregister_STORE(ENGINE *e); +void ENGINE_register_all_STORE(void); + +int ENGINE_register_ciphers(ENGINE *e); +void ENGINE_unregister_ciphers(ENGINE *e); +void ENGINE_register_all_ciphers(void); + +int ENGINE_register_digests(ENGINE *e); +void ENGINE_unregister_digests(ENGINE *e); +void ENGINE_register_all_digests(void); + +/* These functions register all support from the above categories. Note, use of + * these functions can result in static linkage of code your application may not + * need. If you only need a subset of functionality, consider using more + * selective initialisation. */ +int ENGINE_register_complete(ENGINE *e); +int ENGINE_register_all_complete(void); + +/* Send parametrised control commands to the engine. The possibilities to send + * down an integer, a pointer to data or a function pointer are provided. Any of + * the parameters may or may not be NULL, depending on the command number. In + * actuality, this function only requires a structural (rather than functional) + * reference to an engine, but many control commands may require the engine be + * functional. The caller should be aware of trying commands that require an + * operational ENGINE, and only use functional references in such situations. */ +int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)); + +/* This function tests if an ENGINE-specific command is usable as a "setting". + * Eg. in an application's config file that gets processed through + * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to + * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl(). */ +int ENGINE_cmd_is_executable(ENGINE *e, int cmd); + +/* This function works like ENGINE_ctrl() with the exception of taking a + * command name instead of a command number, and can handle optional commands. + * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to + * use the cmd_name and cmd_optional. */ +int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, + long i, void *p, void (*f)(void), int cmd_optional); + +/* This function passes a command-name and argument to an ENGINE. The cmd_name + * is converted to a command number and the control command is called using + * 'arg' as an argument (unless the ENGINE doesn't support such a command, in + * which case no control command is called). The command is checked for input + * flags, and if necessary the argument will be converted to a numeric value. If + * cmd_optional is non-zero, then if the ENGINE doesn't support the given + * cmd_name the return value will be success anyway. This function is intended + * for applications to use so that users (or config files) can supply + * engine-specific config data to the ENGINE at run-time to control behaviour of + * specific engines. As such, it shouldn't be used for calling ENGINE_ctrl() + * functions that return data, deal with binary data, or that are otherwise + * supposed to be used directly through ENGINE_ctrl() in application code. Any + * "return" data from an ENGINE_ctrl() operation in this function will be lost - + * the return value is interpreted as failure if the return value is zero, + * success otherwise, and this function returns a boolean value as a result. In + * other words, vendors of 'ENGINE'-enabled devices should write ENGINE + * implementations with parameterisations that work in this scheme, so that + * compliant ENGINE-based applications can work consistently with the same + * configuration for the same ENGINE-enabled devices, across applications. */ +int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, + int cmd_optional); + +/* These functions are useful for manufacturing new ENGINE structures. They + * don't address reference counting at all - one uses them to populate an ENGINE + * structure with personalised implementations of things prior to using it + * directly or adding it to the builtin ENGINE list in OpenSSL. These are also + * here so that the ENGINE structure doesn't have to be exposed and break binary + * compatibility! */ +ENGINE *ENGINE_new(void); +int ENGINE_free(ENGINE *e); +int ENGINE_up_ref(ENGINE *e); +int ENGINE_set_id(ENGINE *e, const char *id); +int ENGINE_set_name(ENGINE *e, const char *name); +int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); +int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); +int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth); +int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth); +int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); +int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); +int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth); +int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f); +int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); +int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); +int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f); +int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f); +int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); +int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); +int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); +int ENGINE_set_flags(ENGINE *e, int flags); +int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); +/* These functions allow control over any per-structure ENGINE data. */ +int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); +void *ENGINE_get_ex_data(const ENGINE *e, int idx); + +/* This function cleans up anything that needs it. Eg. the ENGINE_add() function + * automatically ensures the list cleanup function is registered to be called + * from ENGINE_cleanup(). Similarly, all ENGINE_register_*** functions ensure + * ENGINE_cleanup() will clean up after them. */ +void ENGINE_cleanup(void); + +/* These return values from within the ENGINE structure. These can be useful + * with functional references as well as structural references - it depends + * which you obtained. Using the result for functional purposes if you only + * obtained a structural reference may be problematic! */ +const char *ENGINE_get_id(const ENGINE *e); +const char *ENGINE_get_name(const ENGINE *e); +const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); +const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); +const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e); +const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e); +const DH_METHOD *ENGINE_get_DH(const ENGINE *e); +const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); +const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e); +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e); +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e); +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e); +ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e); +ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e); +ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e); +ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e); +ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e); +const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid); +const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); +const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); +int ENGINE_get_flags(const ENGINE *e); + +/* FUNCTIONAL functions. These functions deal with ENGINE structures + * that have (or will) be initialised for use. Broadly speaking, the + * structural functions are useful for iterating the list of available + * engine types, creating new engine types, and other "list" operations. + * These functions actually deal with ENGINEs that are to be used. As + * such these functions can fail (if applicable) when particular + * engines are unavailable - eg. if a hardware accelerator is not + * attached or not functioning correctly. Each ENGINE has 2 reference + * counts; structural and functional. Every time a functional reference + * is obtained or released, a corresponding structural reference is + * automatically obtained or released too. */ + +/* Initialise a engine type for use (or up its reference count if it's + * already in use). This will fail if the engine is not currently + * operational and cannot initialise. */ +int ENGINE_init(ENGINE *e); +/* Free a functional reference to a engine type. This does not require + * a corresponding call to ENGINE_free as it also releases a structural + * reference. */ +int ENGINE_finish(ENGINE *e); + +/* The following functions handle keys that are stored in some secondary + * location, handled by the engine. The storage may be on a card or + * whatever. */ +EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, + UI_METHOD *ui_method, void *callback_data); +EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, + UI_METHOD *ui_method, void *callback_data); + +/* This returns a pointer for the current ENGINE structure that + * is (by default) performing any RSA operations. The value returned + * is an incremented reference, so it should be free'd (ENGINE_finish) + * before it is discarded. */ +ENGINE *ENGINE_get_default_RSA(void); +/* Same for the other "methods" */ +ENGINE *ENGINE_get_default_DSA(void); +ENGINE *ENGINE_get_default_ECDH(void); +ENGINE *ENGINE_get_default_ECDSA(void); +ENGINE *ENGINE_get_default_DH(void); +ENGINE *ENGINE_get_default_RAND(void); +/* These functions can be used to get a functional reference to perform + * ciphering or digesting corresponding to "nid". */ +ENGINE *ENGINE_get_cipher_engine(int nid); +ENGINE *ENGINE_get_digest_engine(int nid); + +/* This sets a new default ENGINE structure for performing RSA + * operations. If the result is non-zero (success) then the ENGINE + * structure will have had its reference count up'd so the caller + * should still free their own reference 'e'. */ +int ENGINE_set_default_RSA(ENGINE *e); +int ENGINE_set_default_string(ENGINE *e, const char *def_list); +/* Same for the other "methods" */ +int ENGINE_set_default_DSA(ENGINE *e); +int ENGINE_set_default_ECDH(ENGINE *e); +int ENGINE_set_default_ECDSA(ENGINE *e); +int ENGINE_set_default_DH(ENGINE *e); +int ENGINE_set_default_RAND(ENGINE *e); +int ENGINE_set_default_ciphers(ENGINE *e); +int ENGINE_set_default_digests(ENGINE *e); + +/* The combination "set" - the flags are bitwise "OR"d from the + * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()" + * function, this function can result in unnecessary static linkage. If your + * application requires only specific functionality, consider using more + * selective functions. */ +int ENGINE_set_default(ENGINE *e, unsigned int flags); + +void ENGINE_add_conf_module(void); + +/* Deprecated functions ... */ +/* int ENGINE_clear_defaults(void); */ + +/**************************/ +/* DYNAMIC ENGINE SUPPORT */ +/**************************/ + +/* Binary/behaviour compatibility levels */ +#define OSSL_DYNAMIC_VERSION (unsigned long)0x00020000 +/* Binary versions older than this are too old for us (whether we're a loader or + * a loadee) */ +#define OSSL_DYNAMIC_OLDEST (unsigned long)0x00020000 + +/* When compiling an ENGINE entirely as an external shared library, loadable by + * the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' structure + * type provides the calling application's (or library's) error functionality + * and memory management function pointers to the loaded library. These should + * be used/set in the loaded library code so that the loading application's + * 'state' will be used/changed in all operations. The 'static_state' pointer + * allows the loaded library to know if it shares the same static data as the + * calling application (or library), and thus whether these callbacks need to be + * set or not. */ +typedef void *(*dyn_MEM_malloc_cb)(size_t); +typedef void *(*dyn_MEM_realloc_cb)(void *, size_t); +typedef void (*dyn_MEM_free_cb)(void *); +typedef struct st_dynamic_MEM_fns { + dyn_MEM_malloc_cb malloc_cb; + dyn_MEM_realloc_cb realloc_cb; + dyn_MEM_free_cb free_cb; + } dynamic_MEM_fns; +/* FIXME: Perhaps the memory and locking code (crypto.h) should declare and use + * these types so we (and any other dependant code) can simplify a bit?? */ +typedef void (*dyn_lock_locking_cb)(int,int,const char *,int); +typedef int (*dyn_lock_add_lock_cb)(int*,int,int,const char *,int); +typedef struct CRYPTO_dynlock_value *(*dyn_dynlock_create_cb)( + const char *,int); +typedef void (*dyn_dynlock_lock_cb)(int,struct CRYPTO_dynlock_value *, + const char *,int); +typedef void (*dyn_dynlock_destroy_cb)(struct CRYPTO_dynlock_value *, + const char *,int); +typedef struct st_dynamic_LOCK_fns { + dyn_lock_locking_cb lock_locking_cb; + dyn_lock_add_lock_cb lock_add_lock_cb; + dyn_dynlock_create_cb dynlock_create_cb; + dyn_dynlock_lock_cb dynlock_lock_cb; + dyn_dynlock_destroy_cb dynlock_destroy_cb; + } dynamic_LOCK_fns; +/* The top-level structure */ +typedef struct st_dynamic_fns { + void *static_state; + const ERR_FNS *err_fns; + const CRYPTO_EX_DATA_IMPL *ex_data_fns; + dynamic_MEM_fns mem_fns; + dynamic_LOCK_fns lock_fns; + } dynamic_fns; + +/* The version checking function should be of this prototype. NB: The + * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading code. + * If this function returns zero, it indicates a (potential) version + * incompatibility and the loaded library doesn't believe it can proceed. + * Otherwise, the returned value is the (latest) version supported by the + * loading library. The loader may still decide that the loaded code's version + * is unsatisfactory and could veto the load. The function is expected to + * be implemented with the symbol name "v_check", and a default implementation + * can be fully instantiated with IMPLEMENT_DYNAMIC_CHECK_FN(). */ +typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version); +#define IMPLEMENT_DYNAMIC_CHECK_FN() \ + OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \ + if(v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \ + return 0; } + +/* This function is passed the ENGINE structure to initialise with its own + * function and command settings. It should not adjust the structural or + * functional reference counts. If this function returns zero, (a) the load will + * be aborted, (b) the previous ENGINE state will be memcpy'd back onto the + * structure, and (c) the shared library will be unloaded. So implementations + * should do their own internal cleanup in failure circumstances otherwise they + * could leak. The 'id' parameter, if non-NULL, represents the ENGINE id that + * the loader is looking for. If this is NULL, the shared library can choose to + * return failure or to initialise a 'default' ENGINE. If non-NULL, the shared + * library must initialise only an ENGINE matching the passed 'id'. The function + * is expected to be implemented with the symbol name "bind_engine". A standard + * implementation can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where + * the parameter 'fn' is a callback function that populates the ENGINE structure + * and returns an int value (zero for failure). 'fn' should have prototype; + * [static] int fn(ENGINE *e, const char *id); */ +typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, + const dynamic_fns *fns); +#define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ + OPENSSL_EXPORT \ + int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \ + if(ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \ + if(!CRYPTO_set_mem_functions(fns->mem_fns.malloc_cb, \ + fns->mem_fns.realloc_cb, fns->mem_fns.free_cb)) \ + return 0; \ + CRYPTO_set_locking_callback(fns->lock_fns.lock_locking_cb); \ + CRYPTO_set_add_lock_callback(fns->lock_fns.lock_add_lock_cb); \ + CRYPTO_set_dynlock_create_callback(fns->lock_fns.dynlock_create_cb); \ + CRYPTO_set_dynlock_lock_callback(fns->lock_fns.dynlock_lock_cb); \ + CRYPTO_set_dynlock_destroy_callback(fns->lock_fns.dynlock_destroy_cb); \ + if(!CRYPTO_set_ex_data_implementation(fns->ex_data_fns)) \ + return 0; \ + if(!ERR_set_implementation(fns->err_fns)) return 0; \ + skip_cbs: \ + if(!fn(e,id)) return 0; \ + return 1; } + +/* If the loading application (or library) and the loaded ENGINE library share + * the same static data (eg. they're both dynamically linked to the same + * libcrypto.so) we need a way to avoid trying to set system callbacks - this + * would fail, and for the same reason that it's unnecessary to try. If the + * loaded ENGINE has (or gets from through the loader) its own copy of the + * libcrypto static data, we will need to set the callbacks. The easiest way to + * detect this is to have a function that returns a pointer to some static data + * and let the loading application and loaded ENGINE compare their respective + * values. */ +void *ENGINE_get_static_state(void); + +#if defined(__OpenBSD__) || defined(__FreeBSD__) +void ENGINE_setup_bsd_cryptodev(void); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ENGINE_strings(void); + +/* Error codes for the ENGINE functions. */ + +/* Function codes. */ +#define ENGINE_F_DYNAMIC_CTRL 180 +#define ENGINE_F_DYNAMIC_GET_DATA_CTX 181 +#define ENGINE_F_DYNAMIC_LOAD 182 +#define ENGINE_F_DYNAMIC_SET_DATA_CTX 183 +#define ENGINE_F_ENGINE_ADD 105 +#define ENGINE_F_ENGINE_BY_ID 106 +#define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 170 +#define ENGINE_F_ENGINE_CTRL 142 +#define ENGINE_F_ENGINE_CTRL_CMD 178 +#define ENGINE_F_ENGINE_CTRL_CMD_STRING 171 +#define ENGINE_F_ENGINE_FINISH 107 +#define ENGINE_F_ENGINE_FREE_UTIL 108 +#define ENGINE_F_ENGINE_GET_CIPHER 185 +#define ENGINE_F_ENGINE_GET_DEFAULT_TYPE 177 +#define ENGINE_F_ENGINE_GET_DIGEST 186 +#define ENGINE_F_ENGINE_GET_NEXT 115 +#define ENGINE_F_ENGINE_GET_PREV 116 +#define ENGINE_F_ENGINE_INIT 119 +#define ENGINE_F_ENGINE_LIST_ADD 120 +#define ENGINE_F_ENGINE_LIST_REMOVE 121 +#define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150 +#define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151 +#define ENGINE_F_ENGINE_NEW 122 +#define ENGINE_F_ENGINE_REMOVE 123 +#define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189 +#define ENGINE_F_ENGINE_SET_DEFAULT_TYPE 126 +#define ENGINE_F_ENGINE_SET_ID 129 +#define ENGINE_F_ENGINE_SET_NAME 130 +#define ENGINE_F_ENGINE_TABLE_REGISTER 184 +#define ENGINE_F_ENGINE_UNLOAD_KEY 152 +#define ENGINE_F_ENGINE_UNLOCKED_FINISH 191 +#define ENGINE_F_ENGINE_UP_REF 190 +#define ENGINE_F_INT_CTRL_HELPER 172 +#define ENGINE_F_INT_ENGINE_CONFIGURE 188 +#define ENGINE_F_INT_ENGINE_MODULE_INIT 187 +#define ENGINE_F_LOG_MESSAGE 141 + +/* Reason codes. */ +#define ENGINE_R_ALREADY_LOADED 100 +#define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 133 +#define ENGINE_R_CMD_NOT_EXECUTABLE 134 +#define ENGINE_R_COMMAND_TAKES_INPUT 135 +#define ENGINE_R_COMMAND_TAKES_NO_INPUT 136 +#define ENGINE_R_CONFLICTING_ENGINE_ID 103 +#define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119 +#define ENGINE_R_DH_NOT_IMPLEMENTED 139 +#define ENGINE_R_DSA_NOT_IMPLEMENTED 140 +#define ENGINE_R_DSO_FAILURE 104 +#define ENGINE_R_DSO_NOT_FOUND 132 +#define ENGINE_R_ENGINES_SECTION_ERROR 148 +#define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105 +#define ENGINE_R_ENGINE_SECTION_ERROR 149 +#define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128 +#define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129 +#define ENGINE_R_FINISH_FAILED 106 +#define ENGINE_R_GET_HANDLE_FAILED 107 +#define ENGINE_R_ID_OR_NAME_MISSING 108 +#define ENGINE_R_INIT_FAILED 109 +#define ENGINE_R_INTERNAL_LIST_ERROR 110 +#define ENGINE_R_INVALID_ARGUMENT 143 +#define ENGINE_R_INVALID_CMD_NAME 137 +#define ENGINE_R_INVALID_CMD_NUMBER 138 +#define ENGINE_R_INVALID_INIT_VALUE 151 +#define ENGINE_R_INVALID_STRING 150 +#define ENGINE_R_NOT_INITIALISED 117 +#define ENGINE_R_NOT_LOADED 112 +#define ENGINE_R_NO_CONTROL_FUNCTION 120 +#define ENGINE_R_NO_INDEX 144 +#define ENGINE_R_NO_LOAD_FUNCTION 125 +#define ENGINE_R_NO_REFERENCE 130 +#define ENGINE_R_NO_SUCH_ENGINE 116 +#define ENGINE_R_NO_UNLOAD_FUNCTION 126 +#define ENGINE_R_PROVIDE_PARAMETERS 113 +#define ENGINE_R_RSA_NOT_IMPLEMENTED 141 +#define ENGINE_R_UNIMPLEMENTED_CIPHER 146 +#define ENGINE_R_UNIMPLEMENTED_DIGEST 147 +#define ENGINE_R_VERSION_INCOMPATIBILITY 145 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/err.h b/src/dep/include/openssl/err.h index ede0826..7b95adf 100644 --- a/src/dep/include/openssl/err.h +++ b/src/dep/include/openssl/err.h @@ -1,318 +1,318 @@ -/* crypto/err/err.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_ERR_H -#define HEADER_ERR_H - -#include - -#ifndef OPENSSL_NO_FP_API -#include -#include -#endif - -#include -#ifndef OPENSSL_NO_BIO -#include -#endif -#ifndef OPENSSL_NO_LHASH -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef OPENSSL_NO_ERR -#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e) -#else -#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0) -#endif - -#include - -#define ERR_TXT_MALLOCED 0x01 -#define ERR_TXT_STRING 0x02 - -#define ERR_FLAG_MARK 0x01 - -#define ERR_NUM_ERRORS 16 -typedef struct err_state_st - { - unsigned long pid; - int err_flags[ERR_NUM_ERRORS]; - unsigned long err_buffer[ERR_NUM_ERRORS]; - char *err_data[ERR_NUM_ERRORS]; - int err_data_flags[ERR_NUM_ERRORS]; - const char *err_file[ERR_NUM_ERRORS]; - int err_line[ERR_NUM_ERRORS]; - int top,bottom; - } ERR_STATE; - -/* library */ -#define ERR_LIB_NONE 1 -#define ERR_LIB_SYS 2 -#define ERR_LIB_BN 3 -#define ERR_LIB_RSA 4 -#define ERR_LIB_DH 5 -#define ERR_LIB_EVP 6 -#define ERR_LIB_BUF 7 -#define ERR_LIB_OBJ 8 -#define ERR_LIB_PEM 9 -#define ERR_LIB_DSA 10 -#define ERR_LIB_X509 11 -/* #define ERR_LIB_METH 12 */ -#define ERR_LIB_ASN1 13 -#define ERR_LIB_CONF 14 -#define ERR_LIB_CRYPTO 15 -#define ERR_LIB_EC 16 -#define ERR_LIB_SSL 20 -/* #define ERR_LIB_SSL23 21 */ -/* #define ERR_LIB_SSL2 22 */ -/* #define ERR_LIB_SSL3 23 */ -/* #define ERR_LIB_RSAREF 30 */ -/* #define ERR_LIB_PROXY 31 */ -#define ERR_LIB_BIO 32 -#define ERR_LIB_PKCS7 33 -#define ERR_LIB_X509V3 34 -#define ERR_LIB_PKCS12 35 -#define ERR_LIB_RAND 36 -#define ERR_LIB_DSO 37 -#define ERR_LIB_ENGINE 38 -#define ERR_LIB_OCSP 39 -#define ERR_LIB_UI 40 -#define ERR_LIB_COMP 41 -#define ERR_LIB_ECDSA 42 -#define ERR_LIB_ECDH 43 -#define ERR_LIB_STORE 44 - -#define ERR_LIB_USER 128 - -#define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__) -#define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__) -#define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__) -#define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__) -#define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__) -#define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__) -#define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__) -#define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__) -#define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__) -#define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__) -#define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__) -#define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__) -#define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__) -#define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__) -#define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__) -#define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__) -#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__) -#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__) -#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__) -#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__) -#define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__) -#define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__) -#define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__) -#define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__) -#define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__) -#define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__) -#define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__) -#define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__) - -/* Borland C seems too stupid to be able to shift and do longs in - * the pre-processor :-( */ -#define ERR_PACK(l,f,r) (((((unsigned long)l)&0xffL)*0x1000000)| \ - ((((unsigned long)f)&0xfffL)*0x1000)| \ - ((((unsigned long)r)&0xfffL))) -#define ERR_GET_LIB(l) (int)((((unsigned long)l)>>24L)&0xffL) -#define ERR_GET_FUNC(l) (int)((((unsigned long)l)>>12L)&0xfffL) -#define ERR_GET_REASON(l) (int)((l)&0xfffL) -#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL) - - -/* OS functions */ -#define SYS_F_FOPEN 1 -#define SYS_F_CONNECT 2 -#define SYS_F_GETSERVBYNAME 3 -#define SYS_F_SOCKET 4 -#define SYS_F_IOCTLSOCKET 5 -#define SYS_F_BIND 6 -#define SYS_F_LISTEN 7 -#define SYS_F_ACCEPT 8 -#define SYS_F_WSASTARTUP 9 /* Winsock stuff */ -#define SYS_F_OPENDIR 10 -#define SYS_F_FREAD 11 - - -/* reasons */ -#define ERR_R_SYS_LIB ERR_LIB_SYS /* 2 */ -#define ERR_R_BN_LIB ERR_LIB_BN /* 3 */ -#define ERR_R_RSA_LIB ERR_LIB_RSA /* 4 */ -#define ERR_R_DH_LIB ERR_LIB_DH /* 5 */ -#define ERR_R_EVP_LIB ERR_LIB_EVP /* 6 */ -#define ERR_R_BUF_LIB ERR_LIB_BUF /* 7 */ -#define ERR_R_OBJ_LIB ERR_LIB_OBJ /* 8 */ -#define ERR_R_PEM_LIB ERR_LIB_PEM /* 9 */ -#define ERR_R_DSA_LIB ERR_LIB_DSA /* 10 */ -#define ERR_R_X509_LIB ERR_LIB_X509 /* 11 */ -#define ERR_R_ASN1_LIB ERR_LIB_ASN1 /* 13 */ -#define ERR_R_CONF_LIB ERR_LIB_CONF /* 14 */ -#define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO /* 15 */ -#define ERR_R_EC_LIB ERR_LIB_EC /* 16 */ -#define ERR_R_SSL_LIB ERR_LIB_SSL /* 20 */ -#define ERR_R_BIO_LIB ERR_LIB_BIO /* 32 */ -#define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 /* 33 */ -#define ERR_R_X509V3_LIB ERR_LIB_X509V3 /* 34 */ -#define ERR_R_PKCS12_LIB ERR_LIB_PKCS12 /* 35 */ -#define ERR_R_RAND_LIB ERR_LIB_RAND /* 36 */ -#define ERR_R_DSO_LIB ERR_LIB_DSO /* 37 */ -#define ERR_R_ENGINE_LIB ERR_LIB_ENGINE /* 38 */ -#define ERR_R_OCSP_LIB ERR_LIB_OCSP /* 39 */ -#define ERR_R_UI_LIB ERR_LIB_UI /* 40 */ -#define ERR_R_COMP_LIB ERR_LIB_COMP /* 41 */ -#define ERR_R_ECDSA_LIB ERR_LIB_ECDSA /* 42 */ -#define ERR_R_ECDH_LIB ERR_LIB_ECDH /* 43 */ -#define ERR_R_STORE_LIB ERR_LIB_STORE /* 44 */ - -#define ERR_R_NESTED_ASN1_ERROR 58 -#define ERR_R_BAD_ASN1_OBJECT_HEADER 59 -#define ERR_R_BAD_GET_ASN1_OBJECT_CALL 60 -#define ERR_R_EXPECTING_AN_ASN1_SEQUENCE 61 -#define ERR_R_ASN1_LENGTH_MISMATCH 62 -#define ERR_R_MISSING_ASN1_EOS 63 - -/* fatal error */ -#define ERR_R_FATAL 64 -#define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL) -#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL) -#define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL) -#define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL) -#define ERR_R_DISABLED (5|ERR_R_FATAL) - -/* 99 is the maximum possible ERR_R_... code, higher values - * are reserved for the individual libraries */ - - -typedef struct ERR_string_data_st - { - unsigned long error; - const char *string; - } ERR_STRING_DATA; - -void ERR_put_error(int lib, int func,int reason,const char *file,int line); -void ERR_set_error_data(char *data,int flags); - -unsigned long ERR_get_error(void); -unsigned long ERR_get_error_line(const char **file,int *line); -unsigned long ERR_get_error_line_data(const char **file,int *line, - const char **data, int *flags); -unsigned long ERR_peek_error(void); -unsigned long ERR_peek_error_line(const char **file,int *line); -unsigned long ERR_peek_error_line_data(const char **file,int *line, - const char **data,int *flags); -unsigned long ERR_peek_last_error(void); -unsigned long ERR_peek_last_error_line(const char **file,int *line); -unsigned long ERR_peek_last_error_line_data(const char **file,int *line, - const char **data,int *flags); -void ERR_clear_error(void ); -char *ERR_error_string(unsigned long e,char *buf); -void ERR_error_string_n(unsigned long e, char *buf, size_t len); -const char *ERR_lib_error_string(unsigned long e); -const char *ERR_func_error_string(unsigned long e); -const char *ERR_reason_error_string(unsigned long e); -void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), - void *u); -#ifndef OPENSSL_NO_FP_API -void ERR_print_errors_fp(FILE *fp); -#endif -#ifndef OPENSSL_NO_BIO -void ERR_print_errors(BIO *bp); -void ERR_add_error_data(int num, ...); -#endif -void ERR_load_strings(int lib,ERR_STRING_DATA str[]); -void ERR_unload_strings(int lib,ERR_STRING_DATA str[]); -void ERR_load_ERR_strings(void); -void ERR_load_crypto_strings(void); -void ERR_free_strings(void); - -void ERR_remove_state(unsigned long pid); /* if zero we look it up */ -ERR_STATE *ERR_get_state(void); - -#ifndef OPENSSL_NO_LHASH -LHASH *ERR_get_string_table(void); -LHASH *ERR_get_err_state_table(void); -void ERR_release_err_state_table(LHASH **hash); -#endif - -int ERR_get_next_error_library(void); - -int ERR_set_mark(void); -int ERR_pop_to_mark(void); - -/* Already defined in ossl_typ.h */ -/* typedef struct st_ERR_FNS ERR_FNS; */ -/* An application can use this function and provide the return value to loaded - * modules that should use the application's ERR state/functionality */ -const ERR_FNS *ERR_get_implementation(void); -/* A loaded module should call this function prior to any ERR operations using - * the application's "ERR_FNS". */ -int ERR_set_implementation(const ERR_FNS *fns); - -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/err/err.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ERR_H +#define HEADER_ERR_H + +#include + +#ifndef OPENSSL_NO_FP_API +#include +#include +#endif + +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#ifndef OPENSSL_NO_LHASH +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef OPENSSL_NO_ERR +#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e) +#else +#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0) +#endif + +#include + +#define ERR_TXT_MALLOCED 0x01 +#define ERR_TXT_STRING 0x02 + +#define ERR_FLAG_MARK 0x01 + +#define ERR_NUM_ERRORS 16 +typedef struct err_state_st + { + unsigned long pid; + int err_flags[ERR_NUM_ERRORS]; + unsigned long err_buffer[ERR_NUM_ERRORS]; + char *err_data[ERR_NUM_ERRORS]; + int err_data_flags[ERR_NUM_ERRORS]; + const char *err_file[ERR_NUM_ERRORS]; + int err_line[ERR_NUM_ERRORS]; + int top,bottom; + } ERR_STATE; + +/* library */ +#define ERR_LIB_NONE 1 +#define ERR_LIB_SYS 2 +#define ERR_LIB_BN 3 +#define ERR_LIB_RSA 4 +#define ERR_LIB_DH 5 +#define ERR_LIB_EVP 6 +#define ERR_LIB_BUF 7 +#define ERR_LIB_OBJ 8 +#define ERR_LIB_PEM 9 +#define ERR_LIB_DSA 10 +#define ERR_LIB_X509 11 +/* #define ERR_LIB_METH 12 */ +#define ERR_LIB_ASN1 13 +#define ERR_LIB_CONF 14 +#define ERR_LIB_CRYPTO 15 +#define ERR_LIB_EC 16 +#define ERR_LIB_SSL 20 +/* #define ERR_LIB_SSL23 21 */ +/* #define ERR_LIB_SSL2 22 */ +/* #define ERR_LIB_SSL3 23 */ +/* #define ERR_LIB_RSAREF 30 */ +/* #define ERR_LIB_PROXY 31 */ +#define ERR_LIB_BIO 32 +#define ERR_LIB_PKCS7 33 +#define ERR_LIB_X509V3 34 +#define ERR_LIB_PKCS12 35 +#define ERR_LIB_RAND 36 +#define ERR_LIB_DSO 37 +#define ERR_LIB_ENGINE 38 +#define ERR_LIB_OCSP 39 +#define ERR_LIB_UI 40 +#define ERR_LIB_COMP 41 +#define ERR_LIB_ECDSA 42 +#define ERR_LIB_ECDH 43 +#define ERR_LIB_STORE 44 + +#define ERR_LIB_USER 128 + +#define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__) +#define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__) +#define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__) +#define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__) +#define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__) +#define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__) +#define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__) +#define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__) +#define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__) +#define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__) +#define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__) +#define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__) +#define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__) +#define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__) +#define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__) +#define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__) +#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__) +#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__) +#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__) +#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__) +#define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__) +#define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__) +#define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__) +#define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__) +#define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__) +#define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__) +#define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__) +#define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__) + +/* Borland C seems too stupid to be able to shift and do longs in + * the pre-processor :-( */ +#define ERR_PACK(l,f,r) (((((unsigned long)l)&0xffL)*0x1000000)| \ + ((((unsigned long)f)&0xfffL)*0x1000)| \ + ((((unsigned long)r)&0xfffL))) +#define ERR_GET_LIB(l) (int)((((unsigned long)l)>>24L)&0xffL) +#define ERR_GET_FUNC(l) (int)((((unsigned long)l)>>12L)&0xfffL) +#define ERR_GET_REASON(l) (int)((l)&0xfffL) +#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL) + + +/* OS functions */ +#define SYS_F_FOPEN 1 +#define SYS_F_CONNECT 2 +#define SYS_F_GETSERVBYNAME 3 +#define SYS_F_SOCKET 4 +#define SYS_F_IOCTLSOCKET 5 +#define SYS_F_BIND 6 +#define SYS_F_LISTEN 7 +#define SYS_F_ACCEPT 8 +#define SYS_F_WSASTARTUP 9 /* Winsock stuff */ +#define SYS_F_OPENDIR 10 +#define SYS_F_FREAD 11 + + +/* reasons */ +#define ERR_R_SYS_LIB ERR_LIB_SYS /* 2 */ +#define ERR_R_BN_LIB ERR_LIB_BN /* 3 */ +#define ERR_R_RSA_LIB ERR_LIB_RSA /* 4 */ +#define ERR_R_DH_LIB ERR_LIB_DH /* 5 */ +#define ERR_R_EVP_LIB ERR_LIB_EVP /* 6 */ +#define ERR_R_BUF_LIB ERR_LIB_BUF /* 7 */ +#define ERR_R_OBJ_LIB ERR_LIB_OBJ /* 8 */ +#define ERR_R_PEM_LIB ERR_LIB_PEM /* 9 */ +#define ERR_R_DSA_LIB ERR_LIB_DSA /* 10 */ +#define ERR_R_X509_LIB ERR_LIB_X509 /* 11 */ +#define ERR_R_ASN1_LIB ERR_LIB_ASN1 /* 13 */ +#define ERR_R_CONF_LIB ERR_LIB_CONF /* 14 */ +#define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO /* 15 */ +#define ERR_R_EC_LIB ERR_LIB_EC /* 16 */ +#define ERR_R_SSL_LIB ERR_LIB_SSL /* 20 */ +#define ERR_R_BIO_LIB ERR_LIB_BIO /* 32 */ +#define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 /* 33 */ +#define ERR_R_X509V3_LIB ERR_LIB_X509V3 /* 34 */ +#define ERR_R_PKCS12_LIB ERR_LIB_PKCS12 /* 35 */ +#define ERR_R_RAND_LIB ERR_LIB_RAND /* 36 */ +#define ERR_R_DSO_LIB ERR_LIB_DSO /* 37 */ +#define ERR_R_ENGINE_LIB ERR_LIB_ENGINE /* 38 */ +#define ERR_R_OCSP_LIB ERR_LIB_OCSP /* 39 */ +#define ERR_R_UI_LIB ERR_LIB_UI /* 40 */ +#define ERR_R_COMP_LIB ERR_LIB_COMP /* 41 */ +#define ERR_R_ECDSA_LIB ERR_LIB_ECDSA /* 42 */ +#define ERR_R_ECDH_LIB ERR_LIB_ECDH /* 43 */ +#define ERR_R_STORE_LIB ERR_LIB_STORE /* 44 */ + +#define ERR_R_NESTED_ASN1_ERROR 58 +#define ERR_R_BAD_ASN1_OBJECT_HEADER 59 +#define ERR_R_BAD_GET_ASN1_OBJECT_CALL 60 +#define ERR_R_EXPECTING_AN_ASN1_SEQUENCE 61 +#define ERR_R_ASN1_LENGTH_MISMATCH 62 +#define ERR_R_MISSING_ASN1_EOS 63 + +/* fatal error */ +#define ERR_R_FATAL 64 +#define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL) +#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL) +#define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL) +#define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL) +#define ERR_R_DISABLED (5|ERR_R_FATAL) + +/* 99 is the maximum possible ERR_R_... code, higher values + * are reserved for the individual libraries */ + + +typedef struct ERR_string_data_st + { + unsigned long error; + const char *string; + } ERR_STRING_DATA; + +void ERR_put_error(int lib, int func,int reason,const char *file,int line); +void ERR_set_error_data(char *data,int flags); + +unsigned long ERR_get_error(void); +unsigned long ERR_get_error_line(const char **file,int *line); +unsigned long ERR_get_error_line_data(const char **file,int *line, + const char **data, int *flags); +unsigned long ERR_peek_error(void); +unsigned long ERR_peek_error_line(const char **file,int *line); +unsigned long ERR_peek_error_line_data(const char **file,int *line, + const char **data,int *flags); +unsigned long ERR_peek_last_error(void); +unsigned long ERR_peek_last_error_line(const char **file,int *line); +unsigned long ERR_peek_last_error_line_data(const char **file,int *line, + const char **data,int *flags); +void ERR_clear_error(void ); +char *ERR_error_string(unsigned long e,char *buf); +void ERR_error_string_n(unsigned long e, char *buf, size_t len); +const char *ERR_lib_error_string(unsigned long e); +const char *ERR_func_error_string(unsigned long e); +const char *ERR_reason_error_string(unsigned long e); +void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), + void *u); +#ifndef OPENSSL_NO_FP_API +void ERR_print_errors_fp(FILE *fp); +#endif +#ifndef OPENSSL_NO_BIO +void ERR_print_errors(BIO *bp); +void ERR_add_error_data(int num, ...); +#endif +void ERR_load_strings(int lib,ERR_STRING_DATA str[]); +void ERR_unload_strings(int lib,ERR_STRING_DATA str[]); +void ERR_load_ERR_strings(void); +void ERR_load_crypto_strings(void); +void ERR_free_strings(void); + +void ERR_remove_state(unsigned long pid); /* if zero we look it up */ +ERR_STATE *ERR_get_state(void); + +#ifndef OPENSSL_NO_LHASH +LHASH *ERR_get_string_table(void); +LHASH *ERR_get_err_state_table(void); +void ERR_release_err_state_table(LHASH **hash); +#endif + +int ERR_get_next_error_library(void); + +int ERR_set_mark(void); +int ERR_pop_to_mark(void); + +/* Already defined in ossl_typ.h */ +/* typedef struct st_ERR_FNS ERR_FNS; */ +/* An application can use this function and provide the return value to loaded + * modules that should use the application's ERR state/functionality */ +const ERR_FNS *ERR_get_implementation(void); +/* A loaded module should call this function prior to any ERR operations using + * the application's "ERR_FNS". */ +int ERR_set_implementation(const ERR_FNS *fns); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/evp.h b/src/dep/include/openssl/evp.h index d1f60ca..ea1d209 100644 --- a/src/dep/include/openssl/evp.h +++ b/src/dep/include/openssl/evp.h @@ -1,941 +1,941 @@ -/* crypto/evp/evp.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_ENVELOPE_H -#define HEADER_ENVELOPE_H - -#ifdef OPENSSL_ALGORITHM_DEFINES -# include -#else -# define OPENSSL_ALGORITHM_DEFINES -# include -# undef OPENSSL_ALGORITHM_DEFINES -#endif - -#include - -#include - -#ifndef OPENSSL_NO_BIO -#include -#endif - -/* -#define EVP_RC2_KEY_SIZE 16 -#define EVP_RC4_KEY_SIZE 16 -#define EVP_BLOWFISH_KEY_SIZE 16 -#define EVP_CAST5_KEY_SIZE 16 -#define EVP_RC5_32_12_16_KEY_SIZE 16 -*/ -#define EVP_MAX_MD_SIZE 64 /* longest known is SHA512 */ -#define EVP_MAX_KEY_LENGTH 32 -#define EVP_MAX_IV_LENGTH 16 -#define EVP_MAX_BLOCK_LENGTH 32 - -#define PKCS5_SALT_LEN 8 -/* Default PKCS#5 iteration count */ -#define PKCS5_DEFAULT_ITER 2048 - -#include - -#define EVP_PK_RSA 0x0001 -#define EVP_PK_DSA 0x0002 -#define EVP_PK_DH 0x0004 -#define EVP_PK_EC 0x0008 -#define EVP_PKT_SIGN 0x0010 -#define EVP_PKT_ENC 0x0020 -#define EVP_PKT_EXCH 0x0040 -#define EVP_PKS_RSA 0x0100 -#define EVP_PKS_DSA 0x0200 -#define EVP_PKS_EC 0x0400 -#define EVP_PKT_EXP 0x1000 /* <= 512 bit key */ - -#define EVP_PKEY_NONE NID_undef -#define EVP_PKEY_RSA NID_rsaEncryption -#define EVP_PKEY_RSA2 NID_rsa -#define EVP_PKEY_DSA NID_dsa -#define EVP_PKEY_DSA1 NID_dsa_2 -#define EVP_PKEY_DSA2 NID_dsaWithSHA -#define EVP_PKEY_DSA3 NID_dsaWithSHA1 -#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 -#define EVP_PKEY_DH NID_dhKeyAgreement -#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey - -#ifdef __cplusplus -extern "C" { -#endif - -/* Type needs to be a bit field - * Sub-type needs to be for variations on the method, as in, can it do - * arbitrary encryption.... */ -struct evp_pkey_st - { - int type; - int save_type; - int references; - union { - char *ptr; -#ifndef OPENSSL_NO_RSA - struct rsa_st *rsa; /* RSA */ -#endif -#ifndef OPENSSL_NO_DSA - struct dsa_st *dsa; /* DSA */ -#endif -#ifndef OPENSSL_NO_DH - struct dh_st *dh; /* DH */ -#endif -#ifndef OPENSSL_NO_EC - struct ec_key_st *ec; /* ECC */ -#endif - } pkey; - int save_parameters; - STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ - } /* EVP_PKEY */; - -#define EVP_PKEY_MO_SIGN 0x0001 -#define EVP_PKEY_MO_VERIFY 0x0002 -#define EVP_PKEY_MO_ENCRYPT 0x0004 -#define EVP_PKEY_MO_DECRYPT 0x0008 - -#if 0 -/* This structure is required to tie the message digest and signing together. - * The lookup can be done by md/pkey_method, oid, oid/pkey_method, or - * oid, md and pkey. - * This is required because for various smart-card perform the digest and - * signing/verification on-board. To handle this case, the specific - * EVP_MD and EVP_PKEY_METHODs need to be closely associated. - * When a PKEY is created, it will have a EVP_PKEY_METHOD associated with it. - * This can either be software or a token to provide the required low level - * routines. - */ -typedef struct evp_pkey_md_st - { - int oid; - EVP_MD *md; - EVP_PKEY_METHOD *pkey; - } EVP_PKEY_MD; - -#define EVP_rsa_md2() \ - EVP_PKEY_MD_add(NID_md2WithRSAEncryption,\ - EVP_rsa_pkcs1(),EVP_md2()) -#define EVP_rsa_md5() \ - EVP_PKEY_MD_add(NID_md5WithRSAEncryption,\ - EVP_rsa_pkcs1(),EVP_md5()) -#define EVP_rsa_sha0() \ - EVP_PKEY_MD_add(NID_shaWithRSAEncryption,\ - EVP_rsa_pkcs1(),EVP_sha()) -#define EVP_rsa_sha1() \ - EVP_PKEY_MD_add(NID_sha1WithRSAEncryption,\ - EVP_rsa_pkcs1(),EVP_sha1()) -#define EVP_rsa_ripemd160() \ - EVP_PKEY_MD_add(NID_ripemd160WithRSA,\ - EVP_rsa_pkcs1(),EVP_ripemd160()) -#define EVP_rsa_mdc2() \ - EVP_PKEY_MD_add(NID_mdc2WithRSA,\ - EVP_rsa_octet_string(),EVP_mdc2()) -#define EVP_dsa_sha() \ - EVP_PKEY_MD_add(NID_dsaWithSHA,\ - EVP_dsa(),EVP_sha()) -#define EVP_dsa_sha1() \ - EVP_PKEY_MD_add(NID_dsaWithSHA1,\ - EVP_dsa(),EVP_sha1()) - -typedef struct evp_pkey_method_st - { - char *name; - int flags; - int type; /* RSA, DSA, an SSLeay specific constant */ - int oid; /* For the pub-key type */ - int encrypt_oid; /* pub/priv key encryption */ - - int (*sign)(); - int (*verify)(); - struct { - int (*set)(); /* get and/or set the underlying type */ - int (*get)(); - int (*encrypt)(); - int (*decrypt)(); - int (*i2d)(); - int (*d2i)(); - int (*dup)(); - } pub,priv; - int (*set_asn1_parameters)(); - int (*get_asn1_parameters)(); - } EVP_PKEY_METHOD; -#endif - -#ifndef EVP_MD -struct env_md_st - { - int type; - int pkey_type; - int md_size; - unsigned long flags; - int (*init)(EVP_MD_CTX *ctx); - int (*update)(EVP_MD_CTX *ctx,const void *data,size_t count); - int (*final)(EVP_MD_CTX *ctx,unsigned char *md); - int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from); - int (*cleanup)(EVP_MD_CTX *ctx); - - /* FIXME: prototype these some day */ - int (*sign)(int type, const unsigned char *m, unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, void *key); - int (*verify)(int type, const unsigned char *m, unsigned int m_length, - const unsigned char *sigbuf, unsigned int siglen, - void *key); - int required_pkey_type[5]; /*EVP_PKEY_xxx */ - int block_size; - int ctx_size; /* how big does the ctx->md_data need to be */ - } /* EVP_MD */; - -typedef int evp_sign_method(int type,const unsigned char *m, - unsigned int m_length,unsigned char *sigret, - unsigned int *siglen, void *key); -typedef int evp_verify_method(int type,const unsigned char *m, - unsigned int m_length,const unsigned char *sigbuf, - unsigned int siglen, void *key); - -#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single - * block */ - -#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0} - -#ifndef OPENSSL_NO_DSA -#define EVP_PKEY_DSA_method (evp_sign_method *)DSA_sign, \ - (evp_verify_method *)DSA_verify, \ - {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \ - EVP_PKEY_DSA4,0} -#else -#define EVP_PKEY_DSA_method EVP_PKEY_NULL_method -#endif - -#ifndef OPENSSL_NO_ECDSA -#define EVP_PKEY_ECDSA_method (evp_sign_method *)ECDSA_sign, \ - (evp_verify_method *)ECDSA_verify, \ - {EVP_PKEY_EC,0,0,0} -#else -#define EVP_PKEY_ECDSA_method EVP_PKEY_NULL_method -#endif - -#ifndef OPENSSL_NO_RSA -#define EVP_PKEY_RSA_method (evp_sign_method *)RSA_sign, \ - (evp_verify_method *)RSA_verify, \ - {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} -#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \ - (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \ - (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \ - {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} -#else -#define EVP_PKEY_RSA_method EVP_PKEY_NULL_method -#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method -#endif - -#endif /* !EVP_MD */ - -struct env_md_ctx_st - { - const EVP_MD *digest; - ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */ - unsigned long flags; - void *md_data; - } /* EVP_MD_CTX */; - -/* values for EVP_MD_CTX flags */ - -#define EVP_MD_CTX_FLAG_ONESHOT 0x0001 /* digest update will be called - * once only */ -#define EVP_MD_CTX_FLAG_CLEANED 0x0002 /* context has already been - * cleaned */ -#define EVP_MD_CTX_FLAG_REUSE 0x0004 /* Don't free up ctx->md_data - * in EVP_MD_CTX_cleanup */ - -struct evp_cipher_st - { - int nid; - int block_size; - int key_len; /* Default value for variable length ciphers */ - int iv_len; - unsigned long flags; /* Various flags */ - int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key, - const unsigned char *iv, int enc); /* init key */ - int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl);/* encrypt/decrypt data */ - int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */ - int ctx_size; /* how big ctx->cipher_data needs to be */ - int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */ - int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */ - int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */ - void *app_data; /* Application data */ - } /* EVP_CIPHER */; - -/* Values for cipher flags */ - -/* Modes for ciphers */ - -#define EVP_CIPH_STREAM_CIPHER 0x0 -#define EVP_CIPH_ECB_MODE 0x1 -#define EVP_CIPH_CBC_MODE 0x2 -#define EVP_CIPH_CFB_MODE 0x3 -#define EVP_CIPH_OFB_MODE 0x4 -#define EVP_CIPH_MODE 0x7 -/* Set if variable length cipher */ -#define EVP_CIPH_VARIABLE_LENGTH 0x8 -/* Set if the iv handling should be done by the cipher itself */ -#define EVP_CIPH_CUSTOM_IV 0x10 -/* Set if the cipher's init() function should be called if key is NULL */ -#define EVP_CIPH_ALWAYS_CALL_INIT 0x20 -/* Call ctrl() to init cipher parameters */ -#define EVP_CIPH_CTRL_INIT 0x40 -/* Don't use standard key length function */ -#define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80 -/* Don't use standard block padding */ -#define EVP_CIPH_NO_PADDING 0x100 -/* cipher handles random key generation */ -#define EVP_CIPH_RAND_KEY 0x200 - -/* ctrl() values */ - -#define EVP_CTRL_INIT 0x0 -#define EVP_CTRL_SET_KEY_LENGTH 0x1 -#define EVP_CTRL_GET_RC2_KEY_BITS 0x2 -#define EVP_CTRL_SET_RC2_KEY_BITS 0x3 -#define EVP_CTRL_GET_RC5_ROUNDS 0x4 -#define EVP_CTRL_SET_RC5_ROUNDS 0x5 -#define EVP_CTRL_RAND_KEY 0x6 - -typedef struct evp_cipher_info_st - { - const EVP_CIPHER *cipher; - unsigned char iv[EVP_MAX_IV_LENGTH]; - } EVP_CIPHER_INFO; - -struct evp_cipher_ctx_st - { - const EVP_CIPHER *cipher; - ENGINE *engine; /* functional reference if 'cipher' is ENGINE-provided */ - int encrypt; /* encrypt or decrypt */ - int buf_len; /* number we have left */ - - unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ - unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ - unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */ - int num; /* used by cfb/ofb mode */ - - void *app_data; /* application stuff */ - int key_len; /* May change for variable length cipher */ - unsigned long flags; /* Various flags */ - void *cipher_data; /* per EVP data */ - int final_used; - int block_mask; - unsigned char final[EVP_MAX_BLOCK_LENGTH];/* possible final block */ - } /* EVP_CIPHER_CTX */; - -typedef struct evp_Encode_Ctx_st - { - int num; /* number saved in a partial encode/decode */ - int length; /* The length is either the output line length - * (in input bytes) or the shortest input line - * length that is ok. Once decoding begins, - * the length is adjusted up each time a longer - * line is decoded */ - unsigned char enc_data[80]; /* data to encode */ - int line_num; /* number read on current line */ - int expect_nl; - } EVP_ENCODE_CTX; - -/* Password based encryption function */ -typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, - ASN1_TYPE *param, const EVP_CIPHER *cipher, - const EVP_MD *md, int en_de); - -#ifndef OPENSSL_NO_RSA -#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\ - (char *)(rsa)) -#endif - -#ifndef OPENSSL_NO_DSA -#define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\ - (char *)(dsa)) -#endif - -#ifndef OPENSSL_NO_DH -#define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\ - (char *)(dh)) -#endif - -#ifndef OPENSSL_NO_EC -#define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\ - (char *)(eckey)) -#endif - -/* Add some extra combinations */ -#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) -#define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a)) -#define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) -#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) - -#define EVP_MD_type(e) ((e)->type) -#define EVP_MD_nid(e) EVP_MD_type(e) -#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e)) -#define EVP_MD_pkey_type(e) ((e)->pkey_type) -#define EVP_MD_size(e) ((e)->md_size) -#define EVP_MD_block_size(e) ((e)->block_size) - -#define EVP_MD_CTX_md(e) ((e)->digest) -#define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest) -#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest) -#define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest) - -#define EVP_CIPHER_nid(e) ((e)->nid) -#define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e)) -#define EVP_CIPHER_block_size(e) ((e)->block_size) -#define EVP_CIPHER_key_length(e) ((e)->key_len) -#define EVP_CIPHER_iv_length(e) ((e)->iv_len) -#define EVP_CIPHER_flags(e) ((e)->flags) -#define EVP_CIPHER_mode(e) (((e)->flags) & EVP_CIPH_MODE) - -#define EVP_CIPHER_CTX_cipher(e) ((e)->cipher) -#define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid) -#define EVP_CIPHER_CTX_block_size(e) ((e)->cipher->block_size) -#define EVP_CIPHER_CTX_key_length(e) ((e)->key_len) -#define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len) -#define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data) -#define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d)) -#define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c)) -#define EVP_CIPHER_CTX_flags(e) ((e)->cipher->flags) -#define EVP_CIPHER_CTX_mode(e) ((e)->cipher->flags & EVP_CIPH_MODE) - -#define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80) -#define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80) - -#define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) -#define EVP_SignInit(a,b) EVP_DigestInit(a,b) -#define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) -#define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) -#define EVP_VerifyInit(a,b) EVP_DigestInit(a,b) -#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) -#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e) -#define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e) - -#ifdef CONST_STRICT -void BIO_set_md(BIO *,const EVP_MD *md); -#else -# define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md) -#endif -#define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp) -#define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp) -#define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL) -#define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp) - -#define EVP_Cipher(c,o,i,l) (c)->cipher->do_cipher((c),(o),(i),(l)) - -#define EVP_add_cipher_alias(n,alias) \ - OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n)) -#define EVP_add_digest_alias(n,alias) \ - OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n)) -#define EVP_delete_cipher_alias(alias) \ - OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS); -#define EVP_delete_digest_alias(alias) \ - OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS); - -void EVP_MD_CTX_init(EVP_MD_CTX *ctx); -int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx); -EVP_MD_CTX *EVP_MD_CTX_create(void); -void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx); -int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in); -#define EVP_MD_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs)) -#define EVP_MD_CTX_clear_flags(ctx,flgs) ((ctx)->flags&=~(flgs)) -#define EVP_MD_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs)) -int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); -int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d, - size_t cnt); -int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); -int EVP_Digest(const void *data, size_t count, - unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl); - -int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in); -int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); -int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); - -int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify); -void EVP_set_pw_prompt(const char *prompt); -char * EVP_get_pw_prompt(void); - -int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md, - const unsigned char *salt, const unsigned char *data, - int datal, int count, unsigned char *key,unsigned char *iv); - -int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv); -int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, - const unsigned char *key, const unsigned char *iv); -int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, - int *outl, const unsigned char *in, int inl); -int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); -int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); - -int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv); -int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, - const unsigned char *key, const unsigned char *iv); -int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, - int *outl, const unsigned char *in, int inl); -int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); -int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); - -int EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, - const unsigned char *key,const unsigned char *iv, - int enc); -int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, - const unsigned char *key,const unsigned char *iv, - int enc); -int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, - int *outl, const unsigned char *in, int inl); -int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); -int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); - -int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s, - EVP_PKEY *pkey); - -int EVP_VerifyFinal(EVP_MD_CTX *ctx,const unsigned char *sigbuf, - unsigned int siglen,EVP_PKEY *pkey); - -int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type, - const unsigned char *ek, int ekl, const unsigned char *iv, - EVP_PKEY *priv); -int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); - -int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, - unsigned char **ek, int *ekl, unsigned char *iv, - EVP_PKEY **pubk, int npubk); -int EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl); - -void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); -void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, - const unsigned char *in,int inl); -void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl); -int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n); - -void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); -int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, - const unsigned char *in, int inl); -int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned - char *out, int *outl); -int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n); - -void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a); -int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); -EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void); -void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a); -int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); -int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad); -int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); -int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key); - -#ifndef OPENSSL_NO_BIO -BIO_METHOD *BIO_f_md(void); -BIO_METHOD *BIO_f_base64(void); -BIO_METHOD *BIO_f_cipher(void); -BIO_METHOD *BIO_f_reliable(void); -void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,const unsigned char *k, - const unsigned char *i, int enc); -#endif - -const EVP_MD *EVP_md_null(void); -#ifndef OPENSSL_NO_MD2 -const EVP_MD *EVP_md2(void); -#endif -#ifndef OPENSSL_NO_MD4 -const EVP_MD *EVP_md4(void); -#endif -#ifndef OPENSSL_NO_MD5 -const EVP_MD *EVP_md5(void); -#endif -#ifndef OPENSSL_NO_SHA -const EVP_MD *EVP_sha(void); -const EVP_MD *EVP_sha1(void); -const EVP_MD *EVP_dss(void); -const EVP_MD *EVP_dss1(void); -const EVP_MD *EVP_ecdsa(void); -#endif -#ifndef OPENSSL_NO_SHA256 -const EVP_MD *EVP_sha224(void); -const EVP_MD *EVP_sha256(void); -#endif -#ifndef OPENSSL_NO_SHA512 -const EVP_MD *EVP_sha384(void); -const EVP_MD *EVP_sha512(void); -#endif -#ifndef OPENSSL_NO_MDC2 -const EVP_MD *EVP_mdc2(void); -#endif -#ifndef OPENSSL_NO_RIPEMD -const EVP_MD *EVP_ripemd160(void); -#endif -const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */ -#ifndef OPENSSL_NO_DES -const EVP_CIPHER *EVP_des_ecb(void); -const EVP_CIPHER *EVP_des_ede(void); -const EVP_CIPHER *EVP_des_ede3(void); -const EVP_CIPHER *EVP_des_ede_ecb(void); -const EVP_CIPHER *EVP_des_ede3_ecb(void); -const EVP_CIPHER *EVP_des_cfb64(void); -# define EVP_des_cfb EVP_des_cfb64 -const EVP_CIPHER *EVP_des_cfb1(void); -const EVP_CIPHER *EVP_des_cfb8(void); -const EVP_CIPHER *EVP_des_ede_cfb64(void); -# define EVP_des_ede_cfb EVP_des_ede_cfb64 -#if 0 -const EVP_CIPHER *EVP_des_ede_cfb1(void); -const EVP_CIPHER *EVP_des_ede_cfb8(void); -#endif -const EVP_CIPHER *EVP_des_ede3_cfb64(void); -# define EVP_des_ede3_cfb EVP_des_ede3_cfb64 -const EVP_CIPHER *EVP_des_ede3_cfb1(void); -const EVP_CIPHER *EVP_des_ede3_cfb8(void); -const EVP_CIPHER *EVP_des_ofb(void); -const EVP_CIPHER *EVP_des_ede_ofb(void); -const EVP_CIPHER *EVP_des_ede3_ofb(void); -const EVP_CIPHER *EVP_des_cbc(void); -const EVP_CIPHER *EVP_des_ede_cbc(void); -const EVP_CIPHER *EVP_des_ede3_cbc(void); -const EVP_CIPHER *EVP_desx_cbc(void); -/* This should now be supported through the dev_crypto ENGINE. But also, why are - * rc4 and md5 declarations made here inside a "NO_DES" precompiler branch? */ -#if 0 -# ifdef OPENSSL_OPENBSD_DEV_CRYPTO -const EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void); -const EVP_CIPHER *EVP_dev_crypto_rc4(void); -const EVP_MD *EVP_dev_crypto_md5(void); -# endif -#endif -#endif -#ifndef OPENSSL_NO_RC4 -const EVP_CIPHER *EVP_rc4(void); -const EVP_CIPHER *EVP_rc4_40(void); -#endif -#ifndef OPENSSL_NO_IDEA -const EVP_CIPHER *EVP_idea_ecb(void); -const EVP_CIPHER *EVP_idea_cfb64(void); -# define EVP_idea_cfb EVP_idea_cfb64 -const EVP_CIPHER *EVP_idea_ofb(void); -const EVP_CIPHER *EVP_idea_cbc(void); -#endif -#ifndef OPENSSL_NO_RC2 -const EVP_CIPHER *EVP_rc2_ecb(void); -const EVP_CIPHER *EVP_rc2_cbc(void); -const EVP_CIPHER *EVP_rc2_40_cbc(void); -const EVP_CIPHER *EVP_rc2_64_cbc(void); -const EVP_CIPHER *EVP_rc2_cfb64(void); -# define EVP_rc2_cfb EVP_rc2_cfb64 -const EVP_CIPHER *EVP_rc2_ofb(void); -#endif -#ifndef OPENSSL_NO_BF -const EVP_CIPHER *EVP_bf_ecb(void); -const EVP_CIPHER *EVP_bf_cbc(void); -const EVP_CIPHER *EVP_bf_cfb64(void); -# define EVP_bf_cfb EVP_bf_cfb64 -const EVP_CIPHER *EVP_bf_ofb(void); -#endif -#ifndef OPENSSL_NO_CAST -const EVP_CIPHER *EVP_cast5_ecb(void); -const EVP_CIPHER *EVP_cast5_cbc(void); -const EVP_CIPHER *EVP_cast5_cfb64(void); -# define EVP_cast5_cfb EVP_cast5_cfb64 -const EVP_CIPHER *EVP_cast5_ofb(void); -#endif -#ifndef OPENSSL_NO_RC5 -const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); -const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); -const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void); -# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64 -const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); -#endif -#ifndef OPENSSL_NO_AES -const EVP_CIPHER *EVP_aes_128_ecb(void); -const EVP_CIPHER *EVP_aes_128_cbc(void); -const EVP_CIPHER *EVP_aes_128_cfb1(void); -const EVP_CIPHER *EVP_aes_128_cfb8(void); -const EVP_CIPHER *EVP_aes_128_cfb128(void); -# define EVP_aes_128_cfb EVP_aes_128_cfb128 -const EVP_CIPHER *EVP_aes_128_ofb(void); -#if 0 -const EVP_CIPHER *EVP_aes_128_ctr(void); -#endif -const EVP_CIPHER *EVP_aes_192_ecb(void); -const EVP_CIPHER *EVP_aes_192_cbc(void); -const EVP_CIPHER *EVP_aes_192_cfb1(void); -const EVP_CIPHER *EVP_aes_192_cfb8(void); -const EVP_CIPHER *EVP_aes_192_cfb128(void); -# define EVP_aes_192_cfb EVP_aes_192_cfb128 -const EVP_CIPHER *EVP_aes_192_ofb(void); -#if 0 -const EVP_CIPHER *EVP_aes_192_ctr(void); -#endif -const EVP_CIPHER *EVP_aes_256_ecb(void); -const EVP_CIPHER *EVP_aes_256_cbc(void); -const EVP_CIPHER *EVP_aes_256_cfb1(void); -const EVP_CIPHER *EVP_aes_256_cfb8(void); -const EVP_CIPHER *EVP_aes_256_cfb128(void); -# define EVP_aes_256_cfb EVP_aes_256_cfb128 -const EVP_CIPHER *EVP_aes_256_ofb(void); -#if 0 -const EVP_CIPHER *EVP_aes_256_ctr(void); -#endif -#endif - -void OPENSSL_add_all_algorithms_noconf(void); -void OPENSSL_add_all_algorithms_conf(void); - -#ifdef OPENSSL_LOAD_CONF -#define OpenSSL_add_all_algorithms() \ - OPENSSL_add_all_algorithms_conf() -#else -#define OpenSSL_add_all_algorithms() \ - OPENSSL_add_all_algorithms_noconf() -#endif - -void OpenSSL_add_all_ciphers(void); -void OpenSSL_add_all_digests(void); -#define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms() -#define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers() -#define SSLeay_add_all_digests() OpenSSL_add_all_digests() - -int EVP_add_cipher(const EVP_CIPHER *cipher); -int EVP_add_digest(const EVP_MD *digest); - -const EVP_CIPHER *EVP_get_cipherbyname(const char *name); -const EVP_MD *EVP_get_digestbyname(const char *name); -void EVP_cleanup(void); - -int EVP_PKEY_decrypt(unsigned char *dec_key, - const unsigned char *enc_key,int enc_key_len, - EVP_PKEY *private_key); -int EVP_PKEY_encrypt(unsigned char *enc_key, - const unsigned char *key,int key_len, - EVP_PKEY *pub_key); -int EVP_PKEY_type(int type); -int EVP_PKEY_bits(EVP_PKEY *pkey); -int EVP_PKEY_size(EVP_PKEY *pkey); -int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key); - -#ifndef OPENSSL_NO_RSA -struct rsa_st; -int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,struct rsa_st *key); -struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); -#endif -#ifndef OPENSSL_NO_DSA -struct dsa_st; -int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,struct dsa_st *key); -struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); -#endif -#ifndef OPENSSL_NO_DH -struct dh_st; -int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key); -struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); -#endif -#ifndef OPENSSL_NO_EC -struct ec_key_st; -int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey,struct ec_key_st *key); -struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey); -#endif - -EVP_PKEY * EVP_PKEY_new(void); -void EVP_PKEY_free(EVP_PKEY *pkey); - -EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, const unsigned char **pp, - long length); -int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp); - -EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, const unsigned char **pp, - long length); -EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, - long length); -int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp); - -int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from); -int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey); -int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode); -int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b); - -int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b); - -int EVP_CIPHER_type(const EVP_CIPHER *ctx); - -/* calls methods */ -int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); -int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); - -/* These are used by EVP_CIPHER methods */ -int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); -int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); - -/* PKCS5 password based encryption */ -int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, - ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, - int en_de); -int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, - const unsigned char *salt, int saltlen, int iter, - int keylen, unsigned char *out); -int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, - ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, - int en_de); - -void PKCS5_PBE_add(void); - -int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen, - ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de); -int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, - EVP_PBE_KEYGEN *keygen); -void EVP_PBE_cleanup(void); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_EVP_strings(void); - -/* Error codes for the EVP functions. */ - -/* Function codes. */ -#define EVP_F_AES_INIT_KEY 133 -#define EVP_F_D2I_PKEY 100 -#define EVP_F_DSAPKEY2PKCS8 134 -#define EVP_F_DSA_PKEY2PKCS8 135 -#define EVP_F_ECDSA_PKEY2PKCS8 129 -#define EVP_F_ECKEY_PKEY2PKCS8 132 -#define EVP_F_EVP_CIPHERINIT_EX 123 -#define EVP_F_EVP_CIPHER_CTX_CTRL 124 -#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122 -#define EVP_F_EVP_DECRYPTFINAL_EX 101 -#define EVP_F_EVP_DIGESTINIT_EX 128 -#define EVP_F_EVP_ENCRYPTFINAL_EX 127 -#define EVP_F_EVP_MD_CTX_COPY_EX 110 -#define EVP_F_EVP_OPENINIT 102 -#define EVP_F_EVP_PBE_ALG_ADD 115 -#define EVP_F_EVP_PBE_CIPHERINIT 116 -#define EVP_F_EVP_PKCS82PKEY 111 -#define EVP_F_EVP_PKEY2PKCS8_BROKEN 113 -#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 -#define EVP_F_EVP_PKEY_DECRYPT 104 -#define EVP_F_EVP_PKEY_ENCRYPT 105 -#define EVP_F_EVP_PKEY_GET1_DH 119 -#define EVP_F_EVP_PKEY_GET1_DSA 120 -#define EVP_F_EVP_PKEY_GET1_ECDSA 130 -#define EVP_F_EVP_PKEY_GET1_EC_KEY 131 -#define EVP_F_EVP_PKEY_GET1_RSA 121 -#define EVP_F_EVP_PKEY_NEW 106 -#define EVP_F_EVP_RIJNDAEL 126 -#define EVP_F_EVP_SIGNFINAL 107 -#define EVP_F_EVP_VERIFYFINAL 108 -#define EVP_F_PKCS5_PBE_KEYIVGEN 117 -#define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118 -#define EVP_F_PKCS8_SET_BROKEN 112 -#define EVP_F_RC2_MAGIC_TO_METH 109 -#define EVP_F_RC5_CTRL 125 - -/* Reason codes. */ -#define EVP_R_AES_KEY_SETUP_FAILED 143 -#define EVP_R_ASN1_LIB 140 -#define EVP_R_BAD_BLOCK_LENGTH 136 -#define EVP_R_BAD_DECRYPT 100 -#define EVP_R_BAD_KEY_LENGTH 137 -#define EVP_R_BN_DECODE_ERROR 112 -#define EVP_R_BN_PUBKEY_ERROR 113 -#define EVP_R_CIPHER_PARAMETER_ERROR 122 -#define EVP_R_CTRL_NOT_IMPLEMENTED 132 -#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133 -#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138 -#define EVP_R_DECODE_ERROR 114 -#define EVP_R_DIFFERENT_KEY_TYPES 101 -#define EVP_R_ENCODE_ERROR 115 -#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 -#define EVP_R_EXPECTING_AN_RSA_KEY 127 -#define EVP_R_EXPECTING_A_DH_KEY 128 -#define EVP_R_EXPECTING_A_DSA_KEY 129 -#define EVP_R_EXPECTING_A_ECDSA_KEY 141 -#define EVP_R_EXPECTING_A_EC_KEY 142 -#define EVP_R_INITIALIZATION_ERROR 134 -#define EVP_R_INPUT_NOT_INITIALIZED 111 -#define EVP_R_INVALID_KEY_LENGTH 130 -#define EVP_R_IV_TOO_LARGE 102 -#define EVP_R_KEYGEN_FAILURE 120 -#define EVP_R_MISSING_PARAMETERS 103 -#define EVP_R_NO_CIPHER_SET 131 -#define EVP_R_NO_DIGEST_SET 139 -#define EVP_R_NO_DSA_PARAMETERS 116 -#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 -#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 -#define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117 -#define EVP_R_PUBLIC_KEY_NOT_RSA 106 -#define EVP_R_UNKNOWN_PBE_ALGORITHM 121 -#define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135 -#define EVP_R_UNSUPPORTED_CIPHER 107 -#define EVP_R_UNSUPPORTED_KEYLENGTH 123 -#define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124 -#define EVP_R_UNSUPPORTED_KEY_SIZE 108 -#define EVP_R_UNSUPPORTED_PRF 125 -#define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118 -#define EVP_R_UNSUPPORTED_SALT_TYPE 126 -#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 -#define EVP_R_WRONG_PUBLIC_KEY_TYPE 110 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/evp/evp.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ENVELOPE_H +#define HEADER_ENVELOPE_H + +#ifdef OPENSSL_ALGORITHM_DEFINES +# include +#else +# define OPENSSL_ALGORITHM_DEFINES +# include +# undef OPENSSL_ALGORITHM_DEFINES +#endif + +#include + +#include + +#ifndef OPENSSL_NO_BIO +#include +#endif + +/* +#define EVP_RC2_KEY_SIZE 16 +#define EVP_RC4_KEY_SIZE 16 +#define EVP_BLOWFISH_KEY_SIZE 16 +#define EVP_CAST5_KEY_SIZE 16 +#define EVP_RC5_32_12_16_KEY_SIZE 16 +*/ +#define EVP_MAX_MD_SIZE 64 /* longest known is SHA512 */ +#define EVP_MAX_KEY_LENGTH 32 +#define EVP_MAX_IV_LENGTH 16 +#define EVP_MAX_BLOCK_LENGTH 32 + +#define PKCS5_SALT_LEN 8 +/* Default PKCS#5 iteration count */ +#define PKCS5_DEFAULT_ITER 2048 + +#include + +#define EVP_PK_RSA 0x0001 +#define EVP_PK_DSA 0x0002 +#define EVP_PK_DH 0x0004 +#define EVP_PK_EC 0x0008 +#define EVP_PKT_SIGN 0x0010 +#define EVP_PKT_ENC 0x0020 +#define EVP_PKT_EXCH 0x0040 +#define EVP_PKS_RSA 0x0100 +#define EVP_PKS_DSA 0x0200 +#define EVP_PKS_EC 0x0400 +#define EVP_PKT_EXP 0x1000 /* <= 512 bit key */ + +#define EVP_PKEY_NONE NID_undef +#define EVP_PKEY_RSA NID_rsaEncryption +#define EVP_PKEY_RSA2 NID_rsa +#define EVP_PKEY_DSA NID_dsa +#define EVP_PKEY_DSA1 NID_dsa_2 +#define EVP_PKEY_DSA2 NID_dsaWithSHA +#define EVP_PKEY_DSA3 NID_dsaWithSHA1 +#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 +#define EVP_PKEY_DH NID_dhKeyAgreement +#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey + +#ifdef __cplusplus +extern "C" { +#endif + +/* Type needs to be a bit field + * Sub-type needs to be for variations on the method, as in, can it do + * arbitrary encryption.... */ +struct evp_pkey_st + { + int type; + int save_type; + int references; + union { + char *ptr; +#ifndef OPENSSL_NO_RSA + struct rsa_st *rsa; /* RSA */ +#endif +#ifndef OPENSSL_NO_DSA + struct dsa_st *dsa; /* DSA */ +#endif +#ifndef OPENSSL_NO_DH + struct dh_st *dh; /* DH */ +#endif +#ifndef OPENSSL_NO_EC + struct ec_key_st *ec; /* ECC */ +#endif + } pkey; + int save_parameters; + STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ + } /* EVP_PKEY */; + +#define EVP_PKEY_MO_SIGN 0x0001 +#define EVP_PKEY_MO_VERIFY 0x0002 +#define EVP_PKEY_MO_ENCRYPT 0x0004 +#define EVP_PKEY_MO_DECRYPT 0x0008 + +#if 0 +/* This structure is required to tie the message digest and signing together. + * The lookup can be done by md/pkey_method, oid, oid/pkey_method, or + * oid, md and pkey. + * This is required because for various smart-card perform the digest and + * signing/verification on-board. To handle this case, the specific + * EVP_MD and EVP_PKEY_METHODs need to be closely associated. + * When a PKEY is created, it will have a EVP_PKEY_METHOD associated with it. + * This can either be software or a token to provide the required low level + * routines. + */ +typedef struct evp_pkey_md_st + { + int oid; + EVP_MD *md; + EVP_PKEY_METHOD *pkey; + } EVP_PKEY_MD; + +#define EVP_rsa_md2() \ + EVP_PKEY_MD_add(NID_md2WithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_md2()) +#define EVP_rsa_md5() \ + EVP_PKEY_MD_add(NID_md5WithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_md5()) +#define EVP_rsa_sha0() \ + EVP_PKEY_MD_add(NID_shaWithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_sha()) +#define EVP_rsa_sha1() \ + EVP_PKEY_MD_add(NID_sha1WithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_sha1()) +#define EVP_rsa_ripemd160() \ + EVP_PKEY_MD_add(NID_ripemd160WithRSA,\ + EVP_rsa_pkcs1(),EVP_ripemd160()) +#define EVP_rsa_mdc2() \ + EVP_PKEY_MD_add(NID_mdc2WithRSA,\ + EVP_rsa_octet_string(),EVP_mdc2()) +#define EVP_dsa_sha() \ + EVP_PKEY_MD_add(NID_dsaWithSHA,\ + EVP_dsa(),EVP_sha()) +#define EVP_dsa_sha1() \ + EVP_PKEY_MD_add(NID_dsaWithSHA1,\ + EVP_dsa(),EVP_sha1()) + +typedef struct evp_pkey_method_st + { + char *name; + int flags; + int type; /* RSA, DSA, an SSLeay specific constant */ + int oid; /* For the pub-key type */ + int encrypt_oid; /* pub/priv key encryption */ + + int (*sign)(); + int (*verify)(); + struct { + int (*set)(); /* get and/or set the underlying type */ + int (*get)(); + int (*encrypt)(); + int (*decrypt)(); + int (*i2d)(); + int (*d2i)(); + int (*dup)(); + } pub,priv; + int (*set_asn1_parameters)(); + int (*get_asn1_parameters)(); + } EVP_PKEY_METHOD; +#endif + +#ifndef EVP_MD +struct env_md_st + { + int type; + int pkey_type; + int md_size; + unsigned long flags; + int (*init)(EVP_MD_CTX *ctx); + int (*update)(EVP_MD_CTX *ctx,const void *data,size_t count); + int (*final)(EVP_MD_CTX *ctx,unsigned char *md); + int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from); + int (*cleanup)(EVP_MD_CTX *ctx); + + /* FIXME: prototype these some day */ + int (*sign)(int type, const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, void *key); + int (*verify)(int type, const unsigned char *m, unsigned int m_length, + const unsigned char *sigbuf, unsigned int siglen, + void *key); + int required_pkey_type[5]; /*EVP_PKEY_xxx */ + int block_size; + int ctx_size; /* how big does the ctx->md_data need to be */ + } /* EVP_MD */; + +typedef int evp_sign_method(int type,const unsigned char *m, + unsigned int m_length,unsigned char *sigret, + unsigned int *siglen, void *key); +typedef int evp_verify_method(int type,const unsigned char *m, + unsigned int m_length,const unsigned char *sigbuf, + unsigned int siglen, void *key); + +#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single + * block */ + +#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0} + +#ifndef OPENSSL_NO_DSA +#define EVP_PKEY_DSA_method (evp_sign_method *)DSA_sign, \ + (evp_verify_method *)DSA_verify, \ + {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \ + EVP_PKEY_DSA4,0} +#else +#define EVP_PKEY_DSA_method EVP_PKEY_NULL_method +#endif + +#ifndef OPENSSL_NO_ECDSA +#define EVP_PKEY_ECDSA_method (evp_sign_method *)ECDSA_sign, \ + (evp_verify_method *)ECDSA_verify, \ + {EVP_PKEY_EC,0,0,0} +#else +#define EVP_PKEY_ECDSA_method EVP_PKEY_NULL_method +#endif + +#ifndef OPENSSL_NO_RSA +#define EVP_PKEY_RSA_method (evp_sign_method *)RSA_sign, \ + (evp_verify_method *)RSA_verify, \ + {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} +#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \ + (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \ + (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \ + {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} +#else +#define EVP_PKEY_RSA_method EVP_PKEY_NULL_method +#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method +#endif + +#endif /* !EVP_MD */ + +struct env_md_ctx_st + { + const EVP_MD *digest; + ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */ + unsigned long flags; + void *md_data; + } /* EVP_MD_CTX */; + +/* values for EVP_MD_CTX flags */ + +#define EVP_MD_CTX_FLAG_ONESHOT 0x0001 /* digest update will be called + * once only */ +#define EVP_MD_CTX_FLAG_CLEANED 0x0002 /* context has already been + * cleaned */ +#define EVP_MD_CTX_FLAG_REUSE 0x0004 /* Don't free up ctx->md_data + * in EVP_MD_CTX_cleanup */ + +struct evp_cipher_st + { + int nid; + int block_size; + int key_len; /* Default value for variable length ciphers */ + int iv_len; + unsigned long flags; /* Various flags */ + int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key, + const unsigned char *iv, int enc); /* init key */ + int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, unsigned int inl);/* encrypt/decrypt data */ + int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */ + int ctx_size; /* how big ctx->cipher_data needs to be */ + int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */ + int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */ + int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */ + void *app_data; /* Application data */ + } /* EVP_CIPHER */; + +/* Values for cipher flags */ + +/* Modes for ciphers */ + +#define EVP_CIPH_STREAM_CIPHER 0x0 +#define EVP_CIPH_ECB_MODE 0x1 +#define EVP_CIPH_CBC_MODE 0x2 +#define EVP_CIPH_CFB_MODE 0x3 +#define EVP_CIPH_OFB_MODE 0x4 +#define EVP_CIPH_MODE 0x7 +/* Set if variable length cipher */ +#define EVP_CIPH_VARIABLE_LENGTH 0x8 +/* Set if the iv handling should be done by the cipher itself */ +#define EVP_CIPH_CUSTOM_IV 0x10 +/* Set if the cipher's init() function should be called if key is NULL */ +#define EVP_CIPH_ALWAYS_CALL_INIT 0x20 +/* Call ctrl() to init cipher parameters */ +#define EVP_CIPH_CTRL_INIT 0x40 +/* Don't use standard key length function */ +#define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80 +/* Don't use standard block padding */ +#define EVP_CIPH_NO_PADDING 0x100 +/* cipher handles random key generation */ +#define EVP_CIPH_RAND_KEY 0x200 + +/* ctrl() values */ + +#define EVP_CTRL_INIT 0x0 +#define EVP_CTRL_SET_KEY_LENGTH 0x1 +#define EVP_CTRL_GET_RC2_KEY_BITS 0x2 +#define EVP_CTRL_SET_RC2_KEY_BITS 0x3 +#define EVP_CTRL_GET_RC5_ROUNDS 0x4 +#define EVP_CTRL_SET_RC5_ROUNDS 0x5 +#define EVP_CTRL_RAND_KEY 0x6 + +typedef struct evp_cipher_info_st + { + const EVP_CIPHER *cipher; + unsigned char iv[EVP_MAX_IV_LENGTH]; + } EVP_CIPHER_INFO; + +struct evp_cipher_ctx_st + { + const EVP_CIPHER *cipher; + ENGINE *engine; /* functional reference if 'cipher' is ENGINE-provided */ + int encrypt; /* encrypt or decrypt */ + int buf_len; /* number we have left */ + + unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ + unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ + unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */ + int num; /* used by cfb/ofb mode */ + + void *app_data; /* application stuff */ + int key_len; /* May change for variable length cipher */ + unsigned long flags; /* Various flags */ + void *cipher_data; /* per EVP data */ + int final_used; + int block_mask; + unsigned char final[EVP_MAX_BLOCK_LENGTH];/* possible final block */ + } /* EVP_CIPHER_CTX */; + +typedef struct evp_Encode_Ctx_st + { + int num; /* number saved in a partial encode/decode */ + int length; /* The length is either the output line length + * (in input bytes) or the shortest input line + * length that is ok. Once decoding begins, + * the length is adjusted up each time a longer + * line is decoded */ + unsigned char enc_data[80]; /* data to encode */ + int line_num; /* number read on current line */ + int expect_nl; + } EVP_ENCODE_CTX; + +/* Password based encryption function */ +typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md, int en_de); + +#ifndef OPENSSL_NO_RSA +#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\ + (char *)(rsa)) +#endif + +#ifndef OPENSSL_NO_DSA +#define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\ + (char *)(dsa)) +#endif + +#ifndef OPENSSL_NO_DH +#define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\ + (char *)(dh)) +#endif + +#ifndef OPENSSL_NO_EC +#define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\ + (char *)(eckey)) +#endif + +/* Add some extra combinations */ +#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) +#define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a)) +#define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) +#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) + +#define EVP_MD_type(e) ((e)->type) +#define EVP_MD_nid(e) EVP_MD_type(e) +#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e)) +#define EVP_MD_pkey_type(e) ((e)->pkey_type) +#define EVP_MD_size(e) ((e)->md_size) +#define EVP_MD_block_size(e) ((e)->block_size) + +#define EVP_MD_CTX_md(e) ((e)->digest) +#define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest) +#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest) +#define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest) + +#define EVP_CIPHER_nid(e) ((e)->nid) +#define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e)) +#define EVP_CIPHER_block_size(e) ((e)->block_size) +#define EVP_CIPHER_key_length(e) ((e)->key_len) +#define EVP_CIPHER_iv_length(e) ((e)->iv_len) +#define EVP_CIPHER_flags(e) ((e)->flags) +#define EVP_CIPHER_mode(e) (((e)->flags) & EVP_CIPH_MODE) + +#define EVP_CIPHER_CTX_cipher(e) ((e)->cipher) +#define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid) +#define EVP_CIPHER_CTX_block_size(e) ((e)->cipher->block_size) +#define EVP_CIPHER_CTX_key_length(e) ((e)->key_len) +#define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len) +#define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data) +#define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d)) +#define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c)) +#define EVP_CIPHER_CTX_flags(e) ((e)->cipher->flags) +#define EVP_CIPHER_CTX_mode(e) ((e)->cipher->flags & EVP_CIPH_MODE) + +#define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80) +#define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80) + +#define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) +#define EVP_SignInit(a,b) EVP_DigestInit(a,b) +#define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) +#define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) +#define EVP_VerifyInit(a,b) EVP_DigestInit(a,b) +#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) +#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e) +#define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e) + +#ifdef CONST_STRICT +void BIO_set_md(BIO *,const EVP_MD *md); +#else +# define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md) +#endif +#define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp) +#define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp) +#define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL) +#define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp) + +#define EVP_Cipher(c,o,i,l) (c)->cipher->do_cipher((c),(o),(i),(l)) + +#define EVP_add_cipher_alias(n,alias) \ + OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n)) +#define EVP_add_digest_alias(n,alias) \ + OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n)) +#define EVP_delete_cipher_alias(alias) \ + OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS); +#define EVP_delete_digest_alias(alias) \ + OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS); + +void EVP_MD_CTX_init(EVP_MD_CTX *ctx); +int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx); +EVP_MD_CTX *EVP_MD_CTX_create(void); +void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx); +int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in); +#define EVP_MD_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs)) +#define EVP_MD_CTX_clear_flags(ctx,flgs) ((ctx)->flags&=~(flgs)) +#define EVP_MD_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs)) +int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); +int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d, + size_t cnt); +int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); +int EVP_Digest(const void *data, size_t count, + unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl); + +int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in); +int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); +int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); + +int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify); +void EVP_set_pw_prompt(const char *prompt); +char * EVP_get_pw_prompt(void); + +int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md, + const unsigned char *salt, const unsigned char *data, + int datal, int count, unsigned char *key,unsigned char *iv); + +int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv); +int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key, const unsigned char *iv); +int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); +int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); + +int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv); +int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key, const unsigned char *iv); +int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); +int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); + +int EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, + const unsigned char *key,const unsigned char *iv, + int enc); +int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key,const unsigned char *iv, + int enc); +int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); +int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); + +int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s, + EVP_PKEY *pkey); + +int EVP_VerifyFinal(EVP_MD_CTX *ctx,const unsigned char *sigbuf, + unsigned int siglen,EVP_PKEY *pkey); + +int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type, + const unsigned char *ek, int ekl, const unsigned char *iv, + EVP_PKEY *priv); +int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); + +int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, + unsigned char **ek, int *ekl, unsigned char *iv, + EVP_PKEY **pubk, int npubk); +int EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl); + +void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); +void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, + const unsigned char *in,int inl); +void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl); +int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n); + +void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); +int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, + const unsigned char *in, int inl); +int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned + char *out, int *outl); +int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n); + +void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a); +int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); +EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void); +void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a); +int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); +int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad); +int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); +int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key); + +#ifndef OPENSSL_NO_BIO +BIO_METHOD *BIO_f_md(void); +BIO_METHOD *BIO_f_base64(void); +BIO_METHOD *BIO_f_cipher(void); +BIO_METHOD *BIO_f_reliable(void); +void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,const unsigned char *k, + const unsigned char *i, int enc); +#endif + +const EVP_MD *EVP_md_null(void); +#ifndef OPENSSL_NO_MD2 +const EVP_MD *EVP_md2(void); +#endif +#ifndef OPENSSL_NO_MD4 +const EVP_MD *EVP_md4(void); +#endif +#ifndef OPENSSL_NO_MD5 +const EVP_MD *EVP_md5(void); +#endif +#ifndef OPENSSL_NO_SHA +const EVP_MD *EVP_sha(void); +const EVP_MD *EVP_sha1(void); +const EVP_MD *EVP_dss(void); +const EVP_MD *EVP_dss1(void); +const EVP_MD *EVP_ecdsa(void); +#endif +#ifndef OPENSSL_NO_SHA256 +const EVP_MD *EVP_sha224(void); +const EVP_MD *EVP_sha256(void); +#endif +#ifndef OPENSSL_NO_SHA512 +const EVP_MD *EVP_sha384(void); +const EVP_MD *EVP_sha512(void); +#endif +#ifndef OPENSSL_NO_MDC2 +const EVP_MD *EVP_mdc2(void); +#endif +#ifndef OPENSSL_NO_RIPEMD +const EVP_MD *EVP_ripemd160(void); +#endif +const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */ +#ifndef OPENSSL_NO_DES +const EVP_CIPHER *EVP_des_ecb(void); +const EVP_CIPHER *EVP_des_ede(void); +const EVP_CIPHER *EVP_des_ede3(void); +const EVP_CIPHER *EVP_des_ede_ecb(void); +const EVP_CIPHER *EVP_des_ede3_ecb(void); +const EVP_CIPHER *EVP_des_cfb64(void); +# define EVP_des_cfb EVP_des_cfb64 +const EVP_CIPHER *EVP_des_cfb1(void); +const EVP_CIPHER *EVP_des_cfb8(void); +const EVP_CIPHER *EVP_des_ede_cfb64(void); +# define EVP_des_ede_cfb EVP_des_ede_cfb64 +#if 0 +const EVP_CIPHER *EVP_des_ede_cfb1(void); +const EVP_CIPHER *EVP_des_ede_cfb8(void); +#endif +const EVP_CIPHER *EVP_des_ede3_cfb64(void); +# define EVP_des_ede3_cfb EVP_des_ede3_cfb64 +const EVP_CIPHER *EVP_des_ede3_cfb1(void); +const EVP_CIPHER *EVP_des_ede3_cfb8(void); +const EVP_CIPHER *EVP_des_ofb(void); +const EVP_CIPHER *EVP_des_ede_ofb(void); +const EVP_CIPHER *EVP_des_ede3_ofb(void); +const EVP_CIPHER *EVP_des_cbc(void); +const EVP_CIPHER *EVP_des_ede_cbc(void); +const EVP_CIPHER *EVP_des_ede3_cbc(void); +const EVP_CIPHER *EVP_desx_cbc(void); +/* This should now be supported through the dev_crypto ENGINE. But also, why are + * rc4 and md5 declarations made here inside a "NO_DES" precompiler branch? */ +#if 0 +# ifdef OPENSSL_OPENBSD_DEV_CRYPTO +const EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void); +const EVP_CIPHER *EVP_dev_crypto_rc4(void); +const EVP_MD *EVP_dev_crypto_md5(void); +# endif +#endif +#endif +#ifndef OPENSSL_NO_RC4 +const EVP_CIPHER *EVP_rc4(void); +const EVP_CIPHER *EVP_rc4_40(void); +#endif +#ifndef OPENSSL_NO_IDEA +const EVP_CIPHER *EVP_idea_ecb(void); +const EVP_CIPHER *EVP_idea_cfb64(void); +# define EVP_idea_cfb EVP_idea_cfb64 +const EVP_CIPHER *EVP_idea_ofb(void); +const EVP_CIPHER *EVP_idea_cbc(void); +#endif +#ifndef OPENSSL_NO_RC2 +const EVP_CIPHER *EVP_rc2_ecb(void); +const EVP_CIPHER *EVP_rc2_cbc(void); +const EVP_CIPHER *EVP_rc2_40_cbc(void); +const EVP_CIPHER *EVP_rc2_64_cbc(void); +const EVP_CIPHER *EVP_rc2_cfb64(void); +# define EVP_rc2_cfb EVP_rc2_cfb64 +const EVP_CIPHER *EVP_rc2_ofb(void); +#endif +#ifndef OPENSSL_NO_BF +const EVP_CIPHER *EVP_bf_ecb(void); +const EVP_CIPHER *EVP_bf_cbc(void); +const EVP_CIPHER *EVP_bf_cfb64(void); +# define EVP_bf_cfb EVP_bf_cfb64 +const EVP_CIPHER *EVP_bf_ofb(void); +#endif +#ifndef OPENSSL_NO_CAST +const EVP_CIPHER *EVP_cast5_ecb(void); +const EVP_CIPHER *EVP_cast5_cbc(void); +const EVP_CIPHER *EVP_cast5_cfb64(void); +# define EVP_cast5_cfb EVP_cast5_cfb64 +const EVP_CIPHER *EVP_cast5_ofb(void); +#endif +#ifndef OPENSSL_NO_RC5 +const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); +const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); +const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void); +# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64 +const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); +#endif +#ifndef OPENSSL_NO_AES +const EVP_CIPHER *EVP_aes_128_ecb(void); +const EVP_CIPHER *EVP_aes_128_cbc(void); +const EVP_CIPHER *EVP_aes_128_cfb1(void); +const EVP_CIPHER *EVP_aes_128_cfb8(void); +const EVP_CIPHER *EVP_aes_128_cfb128(void); +# define EVP_aes_128_cfb EVP_aes_128_cfb128 +const EVP_CIPHER *EVP_aes_128_ofb(void); +#if 0 +const EVP_CIPHER *EVP_aes_128_ctr(void); +#endif +const EVP_CIPHER *EVP_aes_192_ecb(void); +const EVP_CIPHER *EVP_aes_192_cbc(void); +const EVP_CIPHER *EVP_aes_192_cfb1(void); +const EVP_CIPHER *EVP_aes_192_cfb8(void); +const EVP_CIPHER *EVP_aes_192_cfb128(void); +# define EVP_aes_192_cfb EVP_aes_192_cfb128 +const EVP_CIPHER *EVP_aes_192_ofb(void); +#if 0 +const EVP_CIPHER *EVP_aes_192_ctr(void); +#endif +const EVP_CIPHER *EVP_aes_256_ecb(void); +const EVP_CIPHER *EVP_aes_256_cbc(void); +const EVP_CIPHER *EVP_aes_256_cfb1(void); +const EVP_CIPHER *EVP_aes_256_cfb8(void); +const EVP_CIPHER *EVP_aes_256_cfb128(void); +# define EVP_aes_256_cfb EVP_aes_256_cfb128 +const EVP_CIPHER *EVP_aes_256_ofb(void); +#if 0 +const EVP_CIPHER *EVP_aes_256_ctr(void); +#endif +#endif + +void OPENSSL_add_all_algorithms_noconf(void); +void OPENSSL_add_all_algorithms_conf(void); + +#ifdef OPENSSL_LOAD_CONF +#define OpenSSL_add_all_algorithms() \ + OPENSSL_add_all_algorithms_conf() +#else +#define OpenSSL_add_all_algorithms() \ + OPENSSL_add_all_algorithms_noconf() +#endif + +void OpenSSL_add_all_ciphers(void); +void OpenSSL_add_all_digests(void); +#define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms() +#define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers() +#define SSLeay_add_all_digests() OpenSSL_add_all_digests() + +int EVP_add_cipher(const EVP_CIPHER *cipher); +int EVP_add_digest(const EVP_MD *digest); + +const EVP_CIPHER *EVP_get_cipherbyname(const char *name); +const EVP_MD *EVP_get_digestbyname(const char *name); +void EVP_cleanup(void); + +int EVP_PKEY_decrypt(unsigned char *dec_key, + const unsigned char *enc_key,int enc_key_len, + EVP_PKEY *private_key); +int EVP_PKEY_encrypt(unsigned char *enc_key, + const unsigned char *key,int key_len, + EVP_PKEY *pub_key); +int EVP_PKEY_type(int type); +int EVP_PKEY_bits(EVP_PKEY *pkey); +int EVP_PKEY_size(EVP_PKEY *pkey); +int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key); + +#ifndef OPENSSL_NO_RSA +struct rsa_st; +int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,struct rsa_st *key); +struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); +#endif +#ifndef OPENSSL_NO_DSA +struct dsa_st; +int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,struct dsa_st *key); +struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); +#endif +#ifndef OPENSSL_NO_DH +struct dh_st; +int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key); +struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); +#endif +#ifndef OPENSSL_NO_EC +struct ec_key_st; +int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey,struct ec_key_st *key); +struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey); +#endif + +EVP_PKEY * EVP_PKEY_new(void); +void EVP_PKEY_free(EVP_PKEY *pkey); + +EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, const unsigned char **pp, + long length); +int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp); + +EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, const unsigned char **pp, + long length); +EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, + long length); +int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp); + +int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from); +int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey); +int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode); +int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b); + +int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b); + +int EVP_CIPHER_type(const EVP_CIPHER *ctx); + +/* calls methods */ +int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); +int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); + +/* These are used by EVP_CIPHER methods */ +int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); +int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); + +/* PKCS5 password based encryption */ +int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, + int en_de); +int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, + const unsigned char *salt, int saltlen, int iter, + int keylen, unsigned char *out); +int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, + int en_de); + +void PKCS5_PBE_add(void); + +int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen, + ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de); +int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, + EVP_PBE_KEYGEN *keygen); +void EVP_PBE_cleanup(void); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_EVP_strings(void); + +/* Error codes for the EVP functions. */ + +/* Function codes. */ +#define EVP_F_AES_INIT_KEY 133 +#define EVP_F_D2I_PKEY 100 +#define EVP_F_DSAPKEY2PKCS8 134 +#define EVP_F_DSA_PKEY2PKCS8 135 +#define EVP_F_ECDSA_PKEY2PKCS8 129 +#define EVP_F_ECKEY_PKEY2PKCS8 132 +#define EVP_F_EVP_CIPHERINIT_EX 123 +#define EVP_F_EVP_CIPHER_CTX_CTRL 124 +#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122 +#define EVP_F_EVP_DECRYPTFINAL_EX 101 +#define EVP_F_EVP_DIGESTINIT_EX 128 +#define EVP_F_EVP_ENCRYPTFINAL_EX 127 +#define EVP_F_EVP_MD_CTX_COPY_EX 110 +#define EVP_F_EVP_OPENINIT 102 +#define EVP_F_EVP_PBE_ALG_ADD 115 +#define EVP_F_EVP_PBE_CIPHERINIT 116 +#define EVP_F_EVP_PKCS82PKEY 111 +#define EVP_F_EVP_PKEY2PKCS8_BROKEN 113 +#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 +#define EVP_F_EVP_PKEY_DECRYPT 104 +#define EVP_F_EVP_PKEY_ENCRYPT 105 +#define EVP_F_EVP_PKEY_GET1_DH 119 +#define EVP_F_EVP_PKEY_GET1_DSA 120 +#define EVP_F_EVP_PKEY_GET1_ECDSA 130 +#define EVP_F_EVP_PKEY_GET1_EC_KEY 131 +#define EVP_F_EVP_PKEY_GET1_RSA 121 +#define EVP_F_EVP_PKEY_NEW 106 +#define EVP_F_EVP_RIJNDAEL 126 +#define EVP_F_EVP_SIGNFINAL 107 +#define EVP_F_EVP_VERIFYFINAL 108 +#define EVP_F_PKCS5_PBE_KEYIVGEN 117 +#define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118 +#define EVP_F_PKCS8_SET_BROKEN 112 +#define EVP_F_RC2_MAGIC_TO_METH 109 +#define EVP_F_RC5_CTRL 125 + +/* Reason codes. */ +#define EVP_R_AES_KEY_SETUP_FAILED 143 +#define EVP_R_ASN1_LIB 140 +#define EVP_R_BAD_BLOCK_LENGTH 136 +#define EVP_R_BAD_DECRYPT 100 +#define EVP_R_BAD_KEY_LENGTH 137 +#define EVP_R_BN_DECODE_ERROR 112 +#define EVP_R_BN_PUBKEY_ERROR 113 +#define EVP_R_CIPHER_PARAMETER_ERROR 122 +#define EVP_R_CTRL_NOT_IMPLEMENTED 132 +#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133 +#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138 +#define EVP_R_DECODE_ERROR 114 +#define EVP_R_DIFFERENT_KEY_TYPES 101 +#define EVP_R_ENCODE_ERROR 115 +#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 +#define EVP_R_EXPECTING_AN_RSA_KEY 127 +#define EVP_R_EXPECTING_A_DH_KEY 128 +#define EVP_R_EXPECTING_A_DSA_KEY 129 +#define EVP_R_EXPECTING_A_ECDSA_KEY 141 +#define EVP_R_EXPECTING_A_EC_KEY 142 +#define EVP_R_INITIALIZATION_ERROR 134 +#define EVP_R_INPUT_NOT_INITIALIZED 111 +#define EVP_R_INVALID_KEY_LENGTH 130 +#define EVP_R_IV_TOO_LARGE 102 +#define EVP_R_KEYGEN_FAILURE 120 +#define EVP_R_MISSING_PARAMETERS 103 +#define EVP_R_NO_CIPHER_SET 131 +#define EVP_R_NO_DIGEST_SET 139 +#define EVP_R_NO_DSA_PARAMETERS 116 +#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 +#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 +#define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117 +#define EVP_R_PUBLIC_KEY_NOT_RSA 106 +#define EVP_R_UNKNOWN_PBE_ALGORITHM 121 +#define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135 +#define EVP_R_UNSUPPORTED_CIPHER 107 +#define EVP_R_UNSUPPORTED_KEYLENGTH 123 +#define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124 +#define EVP_R_UNSUPPORTED_KEY_SIZE 108 +#define EVP_R_UNSUPPORTED_PRF 125 +#define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118 +#define EVP_R_UNSUPPORTED_SALT_TYPE 126 +#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 +#define EVP_R_WRONG_PUBLIC_KEY_TYPE 110 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/hmac.h b/src/dep/include/openssl/hmac.h index f5e3a5a..c72d9e5 100644 --- a/src/dep/include/openssl/hmac.h +++ b/src/dep/include/openssl/hmac.h @@ -1,108 +1,108 @@ -/* crypto/hmac/hmac.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -#ifndef HEADER_HMAC_H -#define HEADER_HMAC_H - -#include - -#ifdef OPENSSL_NO_HMAC -#error HMAC is disabled. -#endif - -#include - -#define HMAC_MAX_MD_CBLOCK 128 /* largest known is SHA512 */ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct hmac_ctx_st - { - const EVP_MD *md; - EVP_MD_CTX md_ctx; - EVP_MD_CTX i_ctx; - EVP_MD_CTX o_ctx; - unsigned int key_length; - unsigned char key[HMAC_MAX_MD_CBLOCK]; - } HMAC_CTX; - -#define HMAC_size(e) (EVP_MD_size((e)->md)) - - -void HMAC_CTX_init(HMAC_CTX *ctx); -void HMAC_CTX_cleanup(HMAC_CTX *ctx); - -#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */ - -void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, - const EVP_MD *md); /* deprecated */ -void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, - const EVP_MD *md, ENGINE *impl); -void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len); -void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); -unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, - const unsigned char *d, size_t n, unsigned char *md, - unsigned int *md_len); - - -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/hmac/hmac.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +#ifndef HEADER_HMAC_H +#define HEADER_HMAC_H + +#include + +#ifdef OPENSSL_NO_HMAC +#error HMAC is disabled. +#endif + +#include + +#define HMAC_MAX_MD_CBLOCK 128 /* largest known is SHA512 */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct hmac_ctx_st + { + const EVP_MD *md; + EVP_MD_CTX md_ctx; + EVP_MD_CTX i_ctx; + EVP_MD_CTX o_ctx; + unsigned int key_length; + unsigned char key[HMAC_MAX_MD_CBLOCK]; + } HMAC_CTX; + +#define HMAC_size(e) (EVP_MD_size((e)->md)) + + +void HMAC_CTX_init(HMAC_CTX *ctx); +void HMAC_CTX_cleanup(HMAC_CTX *ctx); + +#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */ + +void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, + const EVP_MD *md); /* deprecated */ +void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, + const EVP_MD *md, ENGINE *impl); +void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len); +void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); +unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, + const unsigned char *d, size_t n, unsigned char *md, + unsigned int *md_len); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/idea.h b/src/dep/include/openssl/idea.h index 5391082..c5be74f 100644 --- a/src/dep/include/openssl/idea.h +++ b/src/dep/include/openssl/idea.h @@ -1,100 +1,100 @@ -/* crypto/idea/idea.h */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_IDEA_H -#define HEADER_IDEA_H - -#include /* IDEA_INT, OPENSSL_NO_IDEA */ - -#ifdef OPENSSL_NO_IDEA -#error IDEA is disabled. -#endif - -#define IDEA_ENCRYPT 1 -#define IDEA_DECRYPT 0 - -#define IDEA_BLOCK 8 -#define IDEA_KEY_LENGTH 16 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct idea_key_st - { - IDEA_INT data[9][6]; - } IDEA_KEY_SCHEDULE; - -const char *idea_options(void); -void idea_ecb_encrypt(const unsigned char *in, unsigned char *out, - IDEA_KEY_SCHEDULE *ks); -void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks); -void idea_set_decrypt_key(const IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk); -void idea_cbc_encrypt(const unsigned char *in, unsigned char *out, - long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,int enc); -void idea_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, - int *num,int enc); -void idea_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int *num); -void idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks); -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/idea/idea.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_IDEA_H +#define HEADER_IDEA_H + +#include /* IDEA_INT, OPENSSL_NO_IDEA */ + +#ifdef OPENSSL_NO_IDEA +#error IDEA is disabled. +#endif + +#define IDEA_ENCRYPT 1 +#define IDEA_DECRYPT 0 + +#define IDEA_BLOCK 8 +#define IDEA_KEY_LENGTH 16 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct idea_key_st + { + IDEA_INT data[9][6]; + } IDEA_KEY_SCHEDULE; + +const char *idea_options(void); +void idea_ecb_encrypt(const unsigned char *in, unsigned char *out, + IDEA_KEY_SCHEDULE *ks); +void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks); +void idea_set_decrypt_key(const IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk); +void idea_cbc_encrypt(const unsigned char *in, unsigned char *out, + long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,int enc); +void idea_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, + int *num,int enc); +void idea_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int *num); +void idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/krb5_asn.h b/src/dep/include/openssl/krb5_asn.h index abf93be..198109b 100644 --- a/src/dep/include/openssl/krb5_asn.h +++ b/src/dep/include/openssl/krb5_asn.h @@ -1,256 +1,256 @@ -/* krb5_asn.h */ -/* Written by Vern Staats for the OpenSSL project, -** using ocsp/{*.h,*asn*.c} as a starting point -*/ - -/* ==================================================================== - * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_KRB5_ASN_H -#define HEADER_KRB5_ASN_H - -/* -#include -*/ -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* ASN.1 from Kerberos RFC 1510 -*/ - -/* EncryptedData ::= SEQUENCE { -** etype[0] INTEGER, -- EncryptionType -** kvno[1] INTEGER OPTIONAL, -** cipher[2] OCTET STRING -- ciphertext -** } -*/ -typedef struct krb5_encdata_st - { - ASN1_INTEGER *etype; - ASN1_INTEGER *kvno; - ASN1_OCTET_STRING *cipher; - } KRB5_ENCDATA; - -DECLARE_STACK_OF(KRB5_ENCDATA) - -/* PrincipalName ::= SEQUENCE { -** name-type[0] INTEGER, -** name-string[1] SEQUENCE OF GeneralString -** } -*/ -typedef struct krb5_princname_st - { - ASN1_INTEGER *nametype; - STACK_OF(ASN1_GENERALSTRING) *namestring; - } KRB5_PRINCNAME; - -DECLARE_STACK_OF(KRB5_PRINCNAME) - - -/* Ticket ::= [APPLICATION 1] SEQUENCE { -** tkt-vno[0] INTEGER, -** realm[1] Realm, -** sname[2] PrincipalName, -** enc-part[3] EncryptedData -** } -*/ -typedef struct krb5_tktbody_st - { - ASN1_INTEGER *tktvno; - ASN1_GENERALSTRING *realm; - KRB5_PRINCNAME *sname; - KRB5_ENCDATA *encdata; - } KRB5_TKTBODY; - -typedef STACK_OF(KRB5_TKTBODY) KRB5_TICKET; -DECLARE_STACK_OF(KRB5_TKTBODY) - - -/* AP-REQ ::= [APPLICATION 14] SEQUENCE { -** pvno[0] INTEGER, -** msg-type[1] INTEGER, -** ap-options[2] APOptions, -** ticket[3] Ticket, -** authenticator[4] EncryptedData -** } -** -** APOptions ::= BIT STRING { -** reserved(0), use-session-key(1), mutual-required(2) } -*/ -typedef struct krb5_ap_req_st - { - ASN1_INTEGER *pvno; - ASN1_INTEGER *msgtype; - ASN1_BIT_STRING *apoptions; - KRB5_TICKET *ticket; - KRB5_ENCDATA *authenticator; - } KRB5_APREQBODY; - -typedef STACK_OF(KRB5_APREQBODY) KRB5_APREQ; -DECLARE_STACK_OF(KRB5_APREQBODY) - - -/* Authenticator Stuff */ - - -/* Checksum ::= SEQUENCE { -** cksumtype[0] INTEGER, -** checksum[1] OCTET STRING -** } -*/ -typedef struct krb5_checksum_st - { - ASN1_INTEGER *ctype; - ASN1_OCTET_STRING *checksum; - } KRB5_CHECKSUM; - -DECLARE_STACK_OF(KRB5_CHECKSUM) - - -/* EncryptionKey ::= SEQUENCE { -** keytype[0] INTEGER, -** keyvalue[1] OCTET STRING -** } -*/ -typedef struct krb5_encryptionkey_st - { - ASN1_INTEGER *ktype; - ASN1_OCTET_STRING *keyvalue; - } KRB5_ENCKEY; - -DECLARE_STACK_OF(KRB5_ENCKEY) - - -/* AuthorizationData ::= SEQUENCE OF SEQUENCE { -** ad-type[0] INTEGER, -** ad-data[1] OCTET STRING -** } -*/ -typedef struct krb5_authorization_st - { - ASN1_INTEGER *adtype; - ASN1_OCTET_STRING *addata; - } KRB5_AUTHDATA; - -DECLARE_STACK_OF(KRB5_AUTHDATA) - - -/* -- Unencrypted authenticator -** Authenticator ::= [APPLICATION 2] SEQUENCE { -** authenticator-vno[0] INTEGER, -** crealm[1] Realm, -** cname[2] PrincipalName, -** cksum[3] Checksum OPTIONAL, -** cusec[4] INTEGER, -** ctime[5] KerberosTime, -** subkey[6] EncryptionKey OPTIONAL, -** seq-number[7] INTEGER OPTIONAL, -** authorization-data[8] AuthorizationData OPTIONAL -** } -*/ -typedef struct krb5_authenticator_st - { - ASN1_INTEGER *avno; - ASN1_GENERALSTRING *crealm; - KRB5_PRINCNAME *cname; - KRB5_CHECKSUM *cksum; - ASN1_INTEGER *cusec; - ASN1_GENERALIZEDTIME *ctime; - KRB5_ENCKEY *subkey; - ASN1_INTEGER *seqnum; - KRB5_AUTHDATA *authorization; - } KRB5_AUTHENTBODY; - -typedef STACK_OF(KRB5_AUTHENTBODY) KRB5_AUTHENT; -DECLARE_STACK_OF(KRB5_AUTHENTBODY) - - -/* DECLARE_ASN1_FUNCTIONS(type) = DECLARE_ASN1_FUNCTIONS_name(type, type) = -** type *name##_new(void); -** void name##_free(type *a); -** DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) = -** DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) = -** type *d2i_##name(type **a, const unsigned char **in, long len); -** int i2d_##name(type *a, unsigned char **out); -** DECLARE_ASN1_ITEM(itname) = OPENSSL_EXTERN const ASN1_ITEM itname##_it -*/ - -DECLARE_ASN1_FUNCTIONS(KRB5_ENCDATA) -DECLARE_ASN1_FUNCTIONS(KRB5_PRINCNAME) -DECLARE_ASN1_FUNCTIONS(KRB5_TKTBODY) -DECLARE_ASN1_FUNCTIONS(KRB5_APREQBODY) -DECLARE_ASN1_FUNCTIONS(KRB5_TICKET) -DECLARE_ASN1_FUNCTIONS(KRB5_APREQ) - -DECLARE_ASN1_FUNCTIONS(KRB5_CHECKSUM) -DECLARE_ASN1_FUNCTIONS(KRB5_ENCKEY) -DECLARE_ASN1_FUNCTIONS(KRB5_AUTHDATA) -DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENTBODY) -DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENT) - - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -#ifdef __cplusplus -} -#endif -#endif - +/* krb5_asn.h */ +/* Written by Vern Staats for the OpenSSL project, +** using ocsp/{*.h,*asn*.c} as a starting point +*/ + +/* ==================================================================== + * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_KRB5_ASN_H +#define HEADER_KRB5_ASN_H + +/* +#include +*/ +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ASN.1 from Kerberos RFC 1510 +*/ + +/* EncryptedData ::= SEQUENCE { +** etype[0] INTEGER, -- EncryptionType +** kvno[1] INTEGER OPTIONAL, +** cipher[2] OCTET STRING -- ciphertext +** } +*/ +typedef struct krb5_encdata_st + { + ASN1_INTEGER *etype; + ASN1_INTEGER *kvno; + ASN1_OCTET_STRING *cipher; + } KRB5_ENCDATA; + +DECLARE_STACK_OF(KRB5_ENCDATA) + +/* PrincipalName ::= SEQUENCE { +** name-type[0] INTEGER, +** name-string[1] SEQUENCE OF GeneralString +** } +*/ +typedef struct krb5_princname_st + { + ASN1_INTEGER *nametype; + STACK_OF(ASN1_GENERALSTRING) *namestring; + } KRB5_PRINCNAME; + +DECLARE_STACK_OF(KRB5_PRINCNAME) + + +/* Ticket ::= [APPLICATION 1] SEQUENCE { +** tkt-vno[0] INTEGER, +** realm[1] Realm, +** sname[2] PrincipalName, +** enc-part[3] EncryptedData +** } +*/ +typedef struct krb5_tktbody_st + { + ASN1_INTEGER *tktvno; + ASN1_GENERALSTRING *realm; + KRB5_PRINCNAME *sname; + KRB5_ENCDATA *encdata; + } KRB5_TKTBODY; + +typedef STACK_OF(KRB5_TKTBODY) KRB5_TICKET; +DECLARE_STACK_OF(KRB5_TKTBODY) + + +/* AP-REQ ::= [APPLICATION 14] SEQUENCE { +** pvno[0] INTEGER, +** msg-type[1] INTEGER, +** ap-options[2] APOptions, +** ticket[3] Ticket, +** authenticator[4] EncryptedData +** } +** +** APOptions ::= BIT STRING { +** reserved(0), use-session-key(1), mutual-required(2) } +*/ +typedef struct krb5_ap_req_st + { + ASN1_INTEGER *pvno; + ASN1_INTEGER *msgtype; + ASN1_BIT_STRING *apoptions; + KRB5_TICKET *ticket; + KRB5_ENCDATA *authenticator; + } KRB5_APREQBODY; + +typedef STACK_OF(KRB5_APREQBODY) KRB5_APREQ; +DECLARE_STACK_OF(KRB5_APREQBODY) + + +/* Authenticator Stuff */ + + +/* Checksum ::= SEQUENCE { +** cksumtype[0] INTEGER, +** checksum[1] OCTET STRING +** } +*/ +typedef struct krb5_checksum_st + { + ASN1_INTEGER *ctype; + ASN1_OCTET_STRING *checksum; + } KRB5_CHECKSUM; + +DECLARE_STACK_OF(KRB5_CHECKSUM) + + +/* EncryptionKey ::= SEQUENCE { +** keytype[0] INTEGER, +** keyvalue[1] OCTET STRING +** } +*/ +typedef struct krb5_encryptionkey_st + { + ASN1_INTEGER *ktype; + ASN1_OCTET_STRING *keyvalue; + } KRB5_ENCKEY; + +DECLARE_STACK_OF(KRB5_ENCKEY) + + +/* AuthorizationData ::= SEQUENCE OF SEQUENCE { +** ad-type[0] INTEGER, +** ad-data[1] OCTET STRING +** } +*/ +typedef struct krb5_authorization_st + { + ASN1_INTEGER *adtype; + ASN1_OCTET_STRING *addata; + } KRB5_AUTHDATA; + +DECLARE_STACK_OF(KRB5_AUTHDATA) + + +/* -- Unencrypted authenticator +** Authenticator ::= [APPLICATION 2] SEQUENCE { +** authenticator-vno[0] INTEGER, +** crealm[1] Realm, +** cname[2] PrincipalName, +** cksum[3] Checksum OPTIONAL, +** cusec[4] INTEGER, +** ctime[5] KerberosTime, +** subkey[6] EncryptionKey OPTIONAL, +** seq-number[7] INTEGER OPTIONAL, +** authorization-data[8] AuthorizationData OPTIONAL +** } +*/ +typedef struct krb5_authenticator_st + { + ASN1_INTEGER *avno; + ASN1_GENERALSTRING *crealm; + KRB5_PRINCNAME *cname; + KRB5_CHECKSUM *cksum; + ASN1_INTEGER *cusec; + ASN1_GENERALIZEDTIME *ctime; + KRB5_ENCKEY *subkey; + ASN1_INTEGER *seqnum; + KRB5_AUTHDATA *authorization; + } KRB5_AUTHENTBODY; + +typedef STACK_OF(KRB5_AUTHENTBODY) KRB5_AUTHENT; +DECLARE_STACK_OF(KRB5_AUTHENTBODY) + + +/* DECLARE_ASN1_FUNCTIONS(type) = DECLARE_ASN1_FUNCTIONS_name(type, type) = +** type *name##_new(void); +** void name##_free(type *a); +** DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) = +** DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) = +** type *d2i_##name(type **a, const unsigned char **in, long len); +** int i2d_##name(type *a, unsigned char **out); +** DECLARE_ASN1_ITEM(itname) = OPENSSL_EXTERN const ASN1_ITEM itname##_it +*/ + +DECLARE_ASN1_FUNCTIONS(KRB5_ENCDATA) +DECLARE_ASN1_FUNCTIONS(KRB5_PRINCNAME) +DECLARE_ASN1_FUNCTIONS(KRB5_TKTBODY) +DECLARE_ASN1_FUNCTIONS(KRB5_APREQBODY) +DECLARE_ASN1_FUNCTIONS(KRB5_TICKET) +DECLARE_ASN1_FUNCTIONS(KRB5_APREQ) + +DECLARE_ASN1_FUNCTIONS(KRB5_CHECKSUM) +DECLARE_ASN1_FUNCTIONS(KRB5_ENCKEY) +DECLARE_ASN1_FUNCTIONS(KRB5_AUTHDATA) +DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENTBODY) +DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENT) + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/src/dep/include/openssl/kssl.h b/src/dep/include/openssl/kssl.h index cb7feda..12ae4ab 100644 --- a/src/dep/include/openssl/kssl.h +++ b/src/dep/include/openssl/kssl.h @@ -1,179 +1,179 @@ -/* ssl/kssl.h -*- mode: C; c-file-style: "eay" -*- */ -/* Written by Vern Staats for the OpenSSL project 2000. - * project 2000. - */ -/* ==================================================================== - * Copyright (c) 2000 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -/* -** 19990701 VRS Started. -*/ - -#ifndef KSSL_H -#define KSSL_H - -#include - -#ifndef OPENSSL_NO_KRB5 - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Depending on which KRB5 implementation used, some types from -** the other may be missing. Resolve that here and now -*/ -#ifdef KRB5_HEIMDAL -typedef unsigned char krb5_octet; -#define FAR -#else - -#ifndef FAR -#define FAR -#endif - -#endif - -/* Uncomment this to debug kssl problems or -** to trace usage of the Kerberos session key -** -** #define KSSL_DEBUG -*/ - -#ifndef KRB5SVC -#define KRB5SVC "host" -#endif - -#ifndef KRB5KEYTAB -#define KRB5KEYTAB "/etc/krb5.keytab" -#endif - -#ifndef KRB5SENDAUTH -#define KRB5SENDAUTH 1 -#endif - -#ifndef KRB5CHECKAUTH -#define KRB5CHECKAUTH 1 -#endif - -#ifndef KSSL_CLOCKSKEW -#define KSSL_CLOCKSKEW 300; -#endif - -#define KSSL_ERR_MAX 255 -typedef struct kssl_err_st { - int reason; - char text[KSSL_ERR_MAX+1]; - } KSSL_ERR; - - -/* Context for passing -** (1) Kerberos session key to SSL, and -** (2) Config data between application and SSL lib -*/ -typedef struct kssl_ctx_st - { - /* used by: disposition: */ - char *service_name; /* C,S default ok (kssl) */ - char *service_host; /* C input, REQUIRED */ - char *client_princ; /* S output from krb5 ticket */ - char *keytab_file; /* S NULL (/etc/krb5.keytab) */ - char *cred_cache; /* C NULL (default) */ - krb5_enctype enctype; - int length; - krb5_octet FAR *key; - } KSSL_CTX; - -#define KSSL_CLIENT 1 -#define KSSL_SERVER 2 -#define KSSL_SERVICE 3 -#define KSSL_KEYTAB 4 - -#define KSSL_CTX_OK 0 -#define KSSL_CTX_ERR 1 -#define KSSL_NOMEM 2 - -/* Public (for use by applications that use OpenSSL with Kerberos 5 support */ -krb5_error_code kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text); -KSSL_CTX *kssl_ctx_new(void); -KSSL_CTX *kssl_ctx_free(KSSL_CTX *kssl_ctx); -void kssl_ctx_show(KSSL_CTX *kssl_ctx); -krb5_error_code kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which, - krb5_data *realm, krb5_data *entity, int nentities); -krb5_error_code kssl_cget_tkt(KSSL_CTX *kssl_ctx, krb5_data **enc_tktp, - krb5_data *authenp, KSSL_ERR *kssl_err); -krb5_error_code kssl_sget_tkt(KSSL_CTX *kssl_ctx, krb5_data *indata, - krb5_ticket_times *ttimes, KSSL_ERR *kssl_err); -krb5_error_code kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session); -void kssl_err_set(KSSL_ERR *kssl_err, int reason, char *text); -void kssl_krb5_free_data_contents(krb5_context context, krb5_data *data); -krb5_error_code kssl_build_principal_2(krb5_context context, - krb5_principal *princ, int rlen, const char *realm, - int slen, const char *svc, int hlen, const char *host); -krb5_error_code kssl_validate_times(krb5_timestamp atime, - krb5_ticket_times *ttimes); -krb5_error_code kssl_check_authent(KSSL_CTX *kssl_ctx, krb5_data *authentp, - krb5_timestamp *atimep, KSSL_ERR *kssl_err); -unsigned char *kssl_skip_confound(krb5_enctype enctype, unsigned char *authn); - -#ifdef __cplusplus -} -#endif -#endif /* OPENSSL_NO_KRB5 */ -#endif /* KSSL_H */ +/* ssl/kssl.h -*- mode: C; c-file-style: "eay" -*- */ +/* Written by Vern Staats for the OpenSSL project 2000. + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* +** 19990701 VRS Started. +*/ + +#ifndef KSSL_H +#define KSSL_H + +#include + +#ifndef OPENSSL_NO_KRB5 + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Depending on which KRB5 implementation used, some types from +** the other may be missing. Resolve that here and now +*/ +#ifdef KRB5_HEIMDAL +typedef unsigned char krb5_octet; +#define FAR +#else + +#ifndef FAR +#define FAR +#endif + +#endif + +/* Uncomment this to debug kssl problems or +** to trace usage of the Kerberos session key +** +** #define KSSL_DEBUG +*/ + +#ifndef KRB5SVC +#define KRB5SVC "host" +#endif + +#ifndef KRB5KEYTAB +#define KRB5KEYTAB "/etc/krb5.keytab" +#endif + +#ifndef KRB5SENDAUTH +#define KRB5SENDAUTH 1 +#endif + +#ifndef KRB5CHECKAUTH +#define KRB5CHECKAUTH 1 +#endif + +#ifndef KSSL_CLOCKSKEW +#define KSSL_CLOCKSKEW 300; +#endif + +#define KSSL_ERR_MAX 255 +typedef struct kssl_err_st { + int reason; + char text[KSSL_ERR_MAX+1]; + } KSSL_ERR; + + +/* Context for passing +** (1) Kerberos session key to SSL, and +** (2) Config data between application and SSL lib +*/ +typedef struct kssl_ctx_st + { + /* used by: disposition: */ + char *service_name; /* C,S default ok (kssl) */ + char *service_host; /* C input, REQUIRED */ + char *client_princ; /* S output from krb5 ticket */ + char *keytab_file; /* S NULL (/etc/krb5.keytab) */ + char *cred_cache; /* C NULL (default) */ + krb5_enctype enctype; + int length; + krb5_octet FAR *key; + } KSSL_CTX; + +#define KSSL_CLIENT 1 +#define KSSL_SERVER 2 +#define KSSL_SERVICE 3 +#define KSSL_KEYTAB 4 + +#define KSSL_CTX_OK 0 +#define KSSL_CTX_ERR 1 +#define KSSL_NOMEM 2 + +/* Public (for use by applications that use OpenSSL with Kerberos 5 support */ +krb5_error_code kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text); +KSSL_CTX *kssl_ctx_new(void); +KSSL_CTX *kssl_ctx_free(KSSL_CTX *kssl_ctx); +void kssl_ctx_show(KSSL_CTX *kssl_ctx); +krb5_error_code kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which, + krb5_data *realm, krb5_data *entity, int nentities); +krb5_error_code kssl_cget_tkt(KSSL_CTX *kssl_ctx, krb5_data **enc_tktp, + krb5_data *authenp, KSSL_ERR *kssl_err); +krb5_error_code kssl_sget_tkt(KSSL_CTX *kssl_ctx, krb5_data *indata, + krb5_ticket_times *ttimes, KSSL_ERR *kssl_err); +krb5_error_code kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session); +void kssl_err_set(KSSL_ERR *kssl_err, int reason, char *text); +void kssl_krb5_free_data_contents(krb5_context context, krb5_data *data); +krb5_error_code kssl_build_principal_2(krb5_context context, + krb5_principal *princ, int rlen, const char *realm, + int slen, const char *svc, int hlen, const char *host); +krb5_error_code kssl_validate_times(krb5_timestamp atime, + krb5_ticket_times *ttimes); +krb5_error_code kssl_check_authent(KSSL_CTX *kssl_ctx, krb5_data *authentp, + krb5_timestamp *atimep, KSSL_ERR *kssl_err); +unsigned char *kssl_skip_confound(krb5_enctype enctype, unsigned char *authn); + +#ifdef __cplusplus +} +#endif +#endif /* OPENSSL_NO_KRB5 */ +#endif /* KSSL_H */ diff --git a/src/dep/include/openssl/lhash.h b/src/dep/include/openssl/lhash.h index cc19d3f..86cee40 100644 --- a/src/dep/include/openssl/lhash.h +++ b/src/dep/include/openssl/lhash.h @@ -1,200 +1,200 @@ -/* crypto/lhash/lhash.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -/* Header for dynamic hash table routines - * Author - Eric Young - */ - -#ifndef HEADER_LHASH_H -#define HEADER_LHASH_H - -#include -#ifndef OPENSSL_NO_FP_API -#include -#endif - -#ifndef OPENSSL_NO_BIO -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct lhash_node_st - { - void *data; - struct lhash_node_st *next; -#ifndef OPENSSL_NO_HASH_COMP - unsigned long hash; -#endif - } LHASH_NODE; - -typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *); -typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *); -typedef void (*LHASH_DOALL_FN_TYPE)(void *); -typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *); - -/* Macros for declaring and implementing type-safe wrappers for LHASH callbacks. - * This way, callbacks can be provided to LHASH structures without function - * pointer casting and the macro-defined callbacks provide per-variable casting - * before deferring to the underlying type-specific callbacks. NB: It is - * possible to place a "static" in front of both the DECLARE and IMPLEMENT - * macros if the functions are strictly internal. */ - -/* First: "hash" functions */ -#define DECLARE_LHASH_HASH_FN(f_name,o_type) \ - unsigned long f_name##_LHASH_HASH(const void *); -#define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \ - unsigned long f_name##_LHASH_HASH(const void *arg) { \ - o_type a = (o_type)arg; \ - return f_name(a); } -#define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH - -/* Second: "compare" functions */ -#define DECLARE_LHASH_COMP_FN(f_name,o_type) \ - int f_name##_LHASH_COMP(const void *, const void *); -#define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \ - int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \ - o_type a = (o_type)arg1; \ - o_type b = (o_type)arg2; \ - return f_name(a,b); } -#define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP - -/* Third: "doall" functions */ -#define DECLARE_LHASH_DOALL_FN(f_name,o_type) \ - void f_name##_LHASH_DOALL(void *); -#define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \ - void f_name##_LHASH_DOALL(void *arg) { \ - o_type a = (o_type)arg; \ - f_name(a); } -#define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL - -/* Fourth: "doall_arg" functions */ -#define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ - void f_name##_LHASH_DOALL_ARG(void *, void *); -#define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ - void f_name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \ - o_type a = (o_type)arg1; \ - a_type b = (a_type)arg2; \ - f_name(a,b); } -#define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG - -typedef struct lhash_st - { - LHASH_NODE **b; - LHASH_COMP_FN_TYPE comp; - LHASH_HASH_FN_TYPE hash; - unsigned int num_nodes; - unsigned int num_alloc_nodes; - unsigned int p; - unsigned int pmax; - unsigned long up_load; /* load times 256 */ - unsigned long down_load; /* load times 256 */ - unsigned long num_items; - - unsigned long num_expands; - unsigned long num_expand_reallocs; - unsigned long num_contracts; - unsigned long num_contract_reallocs; - unsigned long num_hash_calls; - unsigned long num_comp_calls; - unsigned long num_insert; - unsigned long num_replace; - unsigned long num_delete; - unsigned long num_no_delete; - unsigned long num_retrieve; - unsigned long num_retrieve_miss; - unsigned long num_hash_comps; - - int error; - } LHASH; - -#define LH_LOAD_MULT 256 - -/* Indicates a malloc() error in the last call, this is only bad - * in lh_insert(). */ -#define lh_error(lh) ((lh)->error) - -LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c); -void lh_free(LHASH *lh); -void *lh_insert(LHASH *lh, void *data); -void *lh_delete(LHASH *lh, const void *data); -void *lh_retrieve(LHASH *lh, const void *data); -void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func); -void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg); -unsigned long lh_strhash(const char *c); -unsigned long lh_num_items(const LHASH *lh); - -#ifndef OPENSSL_NO_FP_API -void lh_stats(const LHASH *lh, FILE *out); -void lh_node_stats(const LHASH *lh, FILE *out); -void lh_node_usage_stats(const LHASH *lh, FILE *out); -#endif - -#ifndef OPENSSL_NO_BIO -void lh_stats_bio(const LHASH *lh, BIO *out); -void lh_node_stats_bio(const LHASH *lh, BIO *out); -void lh_node_usage_stats_bio(const LHASH *lh, BIO *out); -#endif -#ifdef __cplusplus -} -#endif - -#endif - +/* crypto/lhash/lhash.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* Header for dynamic hash table routines + * Author - Eric Young + */ + +#ifndef HEADER_LHASH_H +#define HEADER_LHASH_H + +#include +#ifndef OPENSSL_NO_FP_API +#include +#endif + +#ifndef OPENSSL_NO_BIO +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct lhash_node_st + { + void *data; + struct lhash_node_st *next; +#ifndef OPENSSL_NO_HASH_COMP + unsigned long hash; +#endif + } LHASH_NODE; + +typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *); +typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *); +typedef void (*LHASH_DOALL_FN_TYPE)(void *); +typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *); + +/* Macros for declaring and implementing type-safe wrappers for LHASH callbacks. + * This way, callbacks can be provided to LHASH structures without function + * pointer casting and the macro-defined callbacks provide per-variable casting + * before deferring to the underlying type-specific callbacks. NB: It is + * possible to place a "static" in front of both the DECLARE and IMPLEMENT + * macros if the functions are strictly internal. */ + +/* First: "hash" functions */ +#define DECLARE_LHASH_HASH_FN(f_name,o_type) \ + unsigned long f_name##_LHASH_HASH(const void *); +#define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \ + unsigned long f_name##_LHASH_HASH(const void *arg) { \ + o_type a = (o_type)arg; \ + return f_name(a); } +#define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH + +/* Second: "compare" functions */ +#define DECLARE_LHASH_COMP_FN(f_name,o_type) \ + int f_name##_LHASH_COMP(const void *, const void *); +#define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \ + int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \ + o_type a = (o_type)arg1; \ + o_type b = (o_type)arg2; \ + return f_name(a,b); } +#define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP + +/* Third: "doall" functions */ +#define DECLARE_LHASH_DOALL_FN(f_name,o_type) \ + void f_name##_LHASH_DOALL(void *); +#define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \ + void f_name##_LHASH_DOALL(void *arg) { \ + o_type a = (o_type)arg; \ + f_name(a); } +#define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL + +/* Fourth: "doall_arg" functions */ +#define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ + void f_name##_LHASH_DOALL_ARG(void *, void *); +#define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ + void f_name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \ + o_type a = (o_type)arg1; \ + a_type b = (a_type)arg2; \ + f_name(a,b); } +#define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG + +typedef struct lhash_st + { + LHASH_NODE **b; + LHASH_COMP_FN_TYPE comp; + LHASH_HASH_FN_TYPE hash; + unsigned int num_nodes; + unsigned int num_alloc_nodes; + unsigned int p; + unsigned int pmax; + unsigned long up_load; /* load times 256 */ + unsigned long down_load; /* load times 256 */ + unsigned long num_items; + + unsigned long num_expands; + unsigned long num_expand_reallocs; + unsigned long num_contracts; + unsigned long num_contract_reallocs; + unsigned long num_hash_calls; + unsigned long num_comp_calls; + unsigned long num_insert; + unsigned long num_replace; + unsigned long num_delete; + unsigned long num_no_delete; + unsigned long num_retrieve; + unsigned long num_retrieve_miss; + unsigned long num_hash_comps; + + int error; + } LHASH; + +#define LH_LOAD_MULT 256 + +/* Indicates a malloc() error in the last call, this is only bad + * in lh_insert(). */ +#define lh_error(lh) ((lh)->error) + +LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c); +void lh_free(LHASH *lh); +void *lh_insert(LHASH *lh, void *data); +void *lh_delete(LHASH *lh, const void *data); +void *lh_retrieve(LHASH *lh, const void *data); +void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func); +void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg); +unsigned long lh_strhash(const char *c); +unsigned long lh_num_items(const LHASH *lh); + +#ifndef OPENSSL_NO_FP_API +void lh_stats(const LHASH *lh, FILE *out); +void lh_node_stats(const LHASH *lh, FILE *out); +void lh_node_usage_stats(const LHASH *lh, FILE *out); +#endif + +#ifndef OPENSSL_NO_BIO +void lh_stats_bio(const LHASH *lh, BIO *out); +void lh_node_stats_bio(const LHASH *lh, BIO *out); +void lh_node_usage_stats_bio(const LHASH *lh, BIO *out); +#endif +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/dep/include/openssl/md2.h b/src/dep/include/openssl/md2.h index a1ed8d5..014373a 100644 --- a/src/dep/include/openssl/md2.h +++ b/src/dep/include/openssl/md2.h @@ -1,91 +1,91 @@ -/* crypto/md/md2.h */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_MD2_H -#define HEADER_MD2_H - -#include /* OPENSSL_NO_MD2, MD2_INT */ -#ifdef OPENSSL_NO_MD2 -#error MD2 is disabled. -#endif - -#define MD2_DIGEST_LENGTH 16 -#define MD2_BLOCK 16 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct MD2state_st - { - unsigned int num; - unsigned char data[MD2_BLOCK]; - MD2_INT cksm[MD2_BLOCK]; - MD2_INT state[MD2_BLOCK]; - } MD2_CTX; - -const char *MD2_options(void); -int MD2_Init(MD2_CTX *c); -int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); -int MD2_Final(unsigned char *md, MD2_CTX *c); -unsigned char *MD2(const unsigned char *d, size_t n,unsigned char *md); -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/md/md2.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_MD2_H +#define HEADER_MD2_H + +#include /* OPENSSL_NO_MD2, MD2_INT */ +#ifdef OPENSSL_NO_MD2 +#error MD2 is disabled. +#endif + +#define MD2_DIGEST_LENGTH 16 +#define MD2_BLOCK 16 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct MD2state_st + { + unsigned int num; + unsigned char data[MD2_BLOCK]; + MD2_INT cksm[MD2_BLOCK]; + MD2_INT state[MD2_BLOCK]; + } MD2_CTX; + +const char *MD2_options(void); +int MD2_Init(MD2_CTX *c); +int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); +int MD2_Final(unsigned char *md, MD2_CTX *c); +unsigned char *MD2(const unsigned char *d, size_t n,unsigned char *md); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/md4.h b/src/dep/include/openssl/md4.h index 63bf16d..d7a942d 100644 --- a/src/dep/include/openssl/md4.h +++ b/src/dep/include/openssl/md4.h @@ -1,116 +1,116 @@ -/* crypto/md4/md4.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_MD4_H -#define HEADER_MD4_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef OPENSSL_NO_MD4 -#error MD4 is disabled. -#endif - -/* - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * ! MD4_LONG has to be at least 32 bits wide. If it's wider, then ! - * ! MD4_LONG_LOG2 has to be defined along. ! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - */ - -#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) -#define MD4_LONG unsigned long -#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) -#define MD4_LONG unsigned long -#define MD4_LONG_LOG2 3 -/* - * _CRAY note. I could declare short, but I have no idea what impact - * does it have on performance on none-T3E machines. I could declare - * int, but at least on C90 sizeof(int) can be chosen at compile time. - * So I've chosen long... - * - */ -#else -#define MD4_LONG unsigned int -#endif - -#define MD4_CBLOCK 64 -#define MD4_LBLOCK (MD4_CBLOCK/4) -#define MD4_DIGEST_LENGTH 16 - -typedef struct MD4state_st - { - MD4_LONG A,B,C,D; - MD4_LONG Nl,Nh; - MD4_LONG data[MD4_LBLOCK]; - unsigned int num; - } MD4_CTX; - -int MD4_Init(MD4_CTX *c); -int MD4_Update(MD4_CTX *c, const void *data, size_t len); -int MD4_Final(unsigned char *md, MD4_CTX *c); -unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md); -void MD4_Transform(MD4_CTX *c, const unsigned char *b); -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/md4/md4.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_MD4_H +#define HEADER_MD4_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_MD4 +#error MD4 is disabled. +#endif + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! MD4_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! MD4_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define MD4_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define MD4_LONG unsigned long +#define MD4_LONG_LOG2 3 +/* + * _CRAY note. I could declare short, but I have no idea what impact + * does it have on performance on none-T3E machines. I could declare + * int, but at least on C90 sizeof(int) can be chosen at compile time. + * So I've chosen long... + * + */ +#else +#define MD4_LONG unsigned int +#endif + +#define MD4_CBLOCK 64 +#define MD4_LBLOCK (MD4_CBLOCK/4) +#define MD4_DIGEST_LENGTH 16 + +typedef struct MD4state_st + { + MD4_LONG A,B,C,D; + MD4_LONG Nl,Nh; + MD4_LONG data[MD4_LBLOCK]; + unsigned int num; + } MD4_CTX; + +int MD4_Init(MD4_CTX *c); +int MD4_Update(MD4_CTX *c, const void *data, size_t len); +int MD4_Final(unsigned char *md, MD4_CTX *c); +unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md); +void MD4_Transform(MD4_CTX *c, const unsigned char *b); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/md5.h b/src/dep/include/openssl/md5.h index eedd898..9184947 100644 --- a/src/dep/include/openssl/md5.h +++ b/src/dep/include/openssl/md5.h @@ -1,116 +1,116 @@ -/* crypto/md5/md5.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_MD5_H -#define HEADER_MD5_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef OPENSSL_NO_MD5 -#error MD5 is disabled. -#endif - -/* - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * ! MD5_LONG has to be at least 32 bits wide. If it's wider, then ! - * ! MD5_LONG_LOG2 has to be defined along. ! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - */ - -#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) -#define MD5_LONG unsigned long -#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) -#define MD5_LONG unsigned long -#define MD5_LONG_LOG2 3 -/* - * _CRAY note. I could declare short, but I have no idea what impact - * does it have on performance on none-T3E machines. I could declare - * int, but at least on C90 sizeof(int) can be chosen at compile time. - * So I've chosen long... - * - */ -#else -#define MD5_LONG unsigned int -#endif - -#define MD5_CBLOCK 64 -#define MD5_LBLOCK (MD5_CBLOCK/4) -#define MD5_DIGEST_LENGTH 16 - -typedef struct MD5state_st - { - MD5_LONG A,B,C,D; - MD5_LONG Nl,Nh; - MD5_LONG data[MD5_LBLOCK]; - unsigned int num; - } MD5_CTX; - -int MD5_Init(MD5_CTX *c); -int MD5_Update(MD5_CTX *c, const void *data, size_t len); -int MD5_Final(unsigned char *md, MD5_CTX *c); -unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md); -void MD5_Transform(MD5_CTX *c, const unsigned char *b); -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/md5/md5.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_MD5_H +#define HEADER_MD5_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_MD5 +#error MD5 is disabled. +#endif + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! MD5_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! MD5_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define MD5_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define MD5_LONG unsigned long +#define MD5_LONG_LOG2 3 +/* + * _CRAY note. I could declare short, but I have no idea what impact + * does it have on performance on none-T3E machines. I could declare + * int, but at least on C90 sizeof(int) can be chosen at compile time. + * So I've chosen long... + * + */ +#else +#define MD5_LONG unsigned int +#endif + +#define MD5_CBLOCK 64 +#define MD5_LBLOCK (MD5_CBLOCK/4) +#define MD5_DIGEST_LENGTH 16 + +typedef struct MD5state_st + { + MD5_LONG A,B,C,D; + MD5_LONG Nl,Nh; + MD5_LONG data[MD5_LBLOCK]; + unsigned int num; + } MD5_CTX; + +int MD5_Init(MD5_CTX *c); +int MD5_Update(MD5_CTX *c, const void *data, size_t len); +int MD5_Final(unsigned char *md, MD5_CTX *c); +unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md); +void MD5_Transform(MD5_CTX *c, const unsigned char *b); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/obj_mac.h b/src/dep/include/openssl/obj_mac.h index ddccdb0..e7a2240 100644 --- a/src/dep/include/openssl/obj_mac.h +++ b/src/dep/include/openssl/obj_mac.h @@ -1,3305 +1,3305 @@ -/* crypto/objects/obj_mac.h */ - -/* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the - * following command: - * perl objects.pl objects.txt obj_mac.num obj_mac.h - */ - -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#define SN_undef "UNDEF" -#define LN_undef "undefined" -#define NID_undef 0 -#define OBJ_undef 0L - -#define SN_itu_t "ITU-T" -#define LN_itu_t "itu-t" -#define NID_itu_t 645 -#define OBJ_itu_t 0L - -#define NID_ccitt 404 -#define OBJ_ccitt OBJ_itu_t - -#define SN_iso "ISO" -#define LN_iso "iso" -#define NID_iso 181 -#define OBJ_iso 1L - -#define SN_joint_iso_itu_t "JOINT-ISO-ITU-T" -#define LN_joint_iso_itu_t "joint-iso-itu-t" -#define NID_joint_iso_itu_t 646 -#define OBJ_joint_iso_itu_t 2L - -#define NID_joint_iso_ccitt 393 -#define OBJ_joint_iso_ccitt OBJ_joint_iso_itu_t - -#define SN_member_body "member-body" -#define LN_member_body "ISO Member Body" -#define NID_member_body 182 -#define OBJ_member_body OBJ_iso,2L - -#define SN_identified_organization "identified-organization" -#define NID_identified_organization 676 -#define OBJ_identified_organization OBJ_iso,3L - -#define SN_certicom_arc "certicom-arc" -#define NID_certicom_arc 677 -#define OBJ_certicom_arc OBJ_identified_organization,132L - -#define SN_international_organizations "international-organizations" -#define LN_international_organizations "International Organizations" -#define NID_international_organizations 647 -#define OBJ_international_organizations OBJ_joint_iso_itu_t,23L - -#define SN_wap "wap" -#define NID_wap 678 -#define OBJ_wap OBJ_international_organizations,43L - -#define SN_wap_wsg "wap-wsg" -#define NID_wap_wsg 679 -#define OBJ_wap_wsg OBJ_wap,13L - -#define SN_selected_attribute_types "selected-attribute-types" -#define LN_selected_attribute_types "Selected Attribute Types" -#define NID_selected_attribute_types 394 -#define OBJ_selected_attribute_types OBJ_joint_iso_itu_t,5L,1L,5L - -#define SN_clearance "clearance" -#define NID_clearance 395 -#define OBJ_clearance OBJ_selected_attribute_types,55L - -#define SN_ISO_US "ISO-US" -#define LN_ISO_US "ISO US Member Body" -#define NID_ISO_US 183 -#define OBJ_ISO_US OBJ_member_body,840L - -#define SN_X9_57 "X9-57" -#define LN_X9_57 "X9.57" -#define NID_X9_57 184 -#define OBJ_X9_57 OBJ_ISO_US,10040L - -#define SN_X9cm "X9cm" -#define LN_X9cm "X9.57 CM ?" -#define NID_X9cm 185 -#define OBJ_X9cm OBJ_X9_57,4L - -#define SN_dsa "DSA" -#define LN_dsa "dsaEncryption" -#define NID_dsa 116 -#define OBJ_dsa OBJ_X9cm,1L - -#define SN_dsaWithSHA1 "DSA-SHA1" -#define LN_dsaWithSHA1 "dsaWithSHA1" -#define NID_dsaWithSHA1 113 -#define OBJ_dsaWithSHA1 OBJ_X9cm,3L - -#define SN_ansi_X9_62 "ansi-X9-62" -#define LN_ansi_X9_62 "ANSI X9.62" -#define NID_ansi_X9_62 405 -#define OBJ_ansi_X9_62 OBJ_ISO_US,10045L - -#define OBJ_X9_62_id_fieldType OBJ_ansi_X9_62,1L - -#define SN_X9_62_prime_field "prime-field" -#define NID_X9_62_prime_field 406 -#define OBJ_X9_62_prime_field OBJ_X9_62_id_fieldType,1L - -#define SN_X9_62_characteristic_two_field "characteristic-two-field" -#define NID_X9_62_characteristic_two_field 407 -#define OBJ_X9_62_characteristic_two_field OBJ_X9_62_id_fieldType,2L - -#define SN_X9_62_id_characteristic_two_basis "id-characteristic-two-basis" -#define NID_X9_62_id_characteristic_two_basis 680 -#define OBJ_X9_62_id_characteristic_two_basis OBJ_X9_62_characteristic_two_field,3L - -#define SN_X9_62_onBasis "onBasis" -#define NID_X9_62_onBasis 681 -#define OBJ_X9_62_onBasis OBJ_X9_62_id_characteristic_two_basis,1L - -#define SN_X9_62_tpBasis "tpBasis" -#define NID_X9_62_tpBasis 682 -#define OBJ_X9_62_tpBasis OBJ_X9_62_id_characteristic_two_basis,2L - -#define SN_X9_62_ppBasis "ppBasis" -#define NID_X9_62_ppBasis 683 -#define OBJ_X9_62_ppBasis OBJ_X9_62_id_characteristic_two_basis,3L - -#define OBJ_X9_62_id_publicKeyType OBJ_ansi_X9_62,2L - -#define SN_X9_62_id_ecPublicKey "id-ecPublicKey" -#define NID_X9_62_id_ecPublicKey 408 -#define OBJ_X9_62_id_ecPublicKey OBJ_X9_62_id_publicKeyType,1L - -#define OBJ_X9_62_ellipticCurve OBJ_ansi_X9_62,3L - -#define OBJ_X9_62_c_TwoCurve OBJ_X9_62_ellipticCurve,0L - -#define SN_X9_62_c2pnb163v1 "c2pnb163v1" -#define NID_X9_62_c2pnb163v1 684 -#define OBJ_X9_62_c2pnb163v1 OBJ_X9_62_c_TwoCurve,1L - -#define SN_X9_62_c2pnb163v2 "c2pnb163v2" -#define NID_X9_62_c2pnb163v2 685 -#define OBJ_X9_62_c2pnb163v2 OBJ_X9_62_c_TwoCurve,2L - -#define SN_X9_62_c2pnb163v3 "c2pnb163v3" -#define NID_X9_62_c2pnb163v3 686 -#define OBJ_X9_62_c2pnb163v3 OBJ_X9_62_c_TwoCurve,3L - -#define SN_X9_62_c2pnb176v1 "c2pnb176v1" -#define NID_X9_62_c2pnb176v1 687 -#define OBJ_X9_62_c2pnb176v1 OBJ_X9_62_c_TwoCurve,4L - -#define SN_X9_62_c2tnb191v1 "c2tnb191v1" -#define NID_X9_62_c2tnb191v1 688 -#define OBJ_X9_62_c2tnb191v1 OBJ_X9_62_c_TwoCurve,5L - -#define SN_X9_62_c2tnb191v2 "c2tnb191v2" -#define NID_X9_62_c2tnb191v2 689 -#define OBJ_X9_62_c2tnb191v2 OBJ_X9_62_c_TwoCurve,6L - -#define SN_X9_62_c2tnb191v3 "c2tnb191v3" -#define NID_X9_62_c2tnb191v3 690 -#define OBJ_X9_62_c2tnb191v3 OBJ_X9_62_c_TwoCurve,7L - -#define SN_X9_62_c2onb191v4 "c2onb191v4" -#define NID_X9_62_c2onb191v4 691 -#define OBJ_X9_62_c2onb191v4 OBJ_X9_62_c_TwoCurve,8L - -#define SN_X9_62_c2onb191v5 "c2onb191v5" -#define NID_X9_62_c2onb191v5 692 -#define OBJ_X9_62_c2onb191v5 OBJ_X9_62_c_TwoCurve,9L - -#define SN_X9_62_c2pnb208w1 "c2pnb208w1" -#define NID_X9_62_c2pnb208w1 693 -#define OBJ_X9_62_c2pnb208w1 OBJ_X9_62_c_TwoCurve,10L - -#define SN_X9_62_c2tnb239v1 "c2tnb239v1" -#define NID_X9_62_c2tnb239v1 694 -#define OBJ_X9_62_c2tnb239v1 OBJ_X9_62_c_TwoCurve,11L - -#define SN_X9_62_c2tnb239v2 "c2tnb239v2" -#define NID_X9_62_c2tnb239v2 695 -#define OBJ_X9_62_c2tnb239v2 OBJ_X9_62_c_TwoCurve,12L - -#define SN_X9_62_c2tnb239v3 "c2tnb239v3" -#define NID_X9_62_c2tnb239v3 696 -#define OBJ_X9_62_c2tnb239v3 OBJ_X9_62_c_TwoCurve,13L - -#define SN_X9_62_c2onb239v4 "c2onb239v4" -#define NID_X9_62_c2onb239v4 697 -#define OBJ_X9_62_c2onb239v4 OBJ_X9_62_c_TwoCurve,14L - -#define SN_X9_62_c2onb239v5 "c2onb239v5" -#define NID_X9_62_c2onb239v5 698 -#define OBJ_X9_62_c2onb239v5 OBJ_X9_62_c_TwoCurve,15L - -#define SN_X9_62_c2pnb272w1 "c2pnb272w1" -#define NID_X9_62_c2pnb272w1 699 -#define OBJ_X9_62_c2pnb272w1 OBJ_X9_62_c_TwoCurve,16L - -#define SN_X9_62_c2pnb304w1 "c2pnb304w1" -#define NID_X9_62_c2pnb304w1 700 -#define OBJ_X9_62_c2pnb304w1 OBJ_X9_62_c_TwoCurve,17L - -#define SN_X9_62_c2tnb359v1 "c2tnb359v1" -#define NID_X9_62_c2tnb359v1 701 -#define OBJ_X9_62_c2tnb359v1 OBJ_X9_62_c_TwoCurve,18L - -#define SN_X9_62_c2pnb368w1 "c2pnb368w1" -#define NID_X9_62_c2pnb368w1 702 -#define OBJ_X9_62_c2pnb368w1 OBJ_X9_62_c_TwoCurve,19L - -#define SN_X9_62_c2tnb431r1 "c2tnb431r1" -#define NID_X9_62_c2tnb431r1 703 -#define OBJ_X9_62_c2tnb431r1 OBJ_X9_62_c_TwoCurve,20L - -#define OBJ_X9_62_primeCurve OBJ_X9_62_ellipticCurve,1L - -#define SN_X9_62_prime192v1 "prime192v1" -#define NID_X9_62_prime192v1 409 -#define OBJ_X9_62_prime192v1 OBJ_X9_62_primeCurve,1L - -#define SN_X9_62_prime192v2 "prime192v2" -#define NID_X9_62_prime192v2 410 -#define OBJ_X9_62_prime192v2 OBJ_X9_62_primeCurve,2L - -#define SN_X9_62_prime192v3 "prime192v3" -#define NID_X9_62_prime192v3 411 -#define OBJ_X9_62_prime192v3 OBJ_X9_62_primeCurve,3L - -#define SN_X9_62_prime239v1 "prime239v1" -#define NID_X9_62_prime239v1 412 -#define OBJ_X9_62_prime239v1 OBJ_X9_62_primeCurve,4L - -#define SN_X9_62_prime239v2 "prime239v2" -#define NID_X9_62_prime239v2 413 -#define OBJ_X9_62_prime239v2 OBJ_X9_62_primeCurve,5L - -#define SN_X9_62_prime239v3 "prime239v3" -#define NID_X9_62_prime239v3 414 -#define OBJ_X9_62_prime239v3 OBJ_X9_62_primeCurve,6L - -#define SN_X9_62_prime256v1 "prime256v1" -#define NID_X9_62_prime256v1 415 -#define OBJ_X9_62_prime256v1 OBJ_X9_62_primeCurve,7L - -#define OBJ_X9_62_id_ecSigType OBJ_ansi_X9_62,4L - -#define SN_ecdsa_with_SHA1 "ecdsa-with-SHA1" -#define NID_ecdsa_with_SHA1 416 -#define OBJ_ecdsa_with_SHA1 OBJ_X9_62_id_ecSigType,1L - -#define OBJ_secg_ellipticCurve OBJ_certicom_arc,0L - -#define SN_secp112r1 "secp112r1" -#define NID_secp112r1 704 -#define OBJ_secp112r1 OBJ_secg_ellipticCurve,6L - -#define SN_secp112r2 "secp112r2" -#define NID_secp112r2 705 -#define OBJ_secp112r2 OBJ_secg_ellipticCurve,7L - -#define SN_secp128r1 "secp128r1" -#define NID_secp128r1 706 -#define OBJ_secp128r1 OBJ_secg_ellipticCurve,28L - -#define SN_secp128r2 "secp128r2" -#define NID_secp128r2 707 -#define OBJ_secp128r2 OBJ_secg_ellipticCurve,29L - -#define SN_secp160k1 "secp160k1" -#define NID_secp160k1 708 -#define OBJ_secp160k1 OBJ_secg_ellipticCurve,9L - -#define SN_secp160r1 "secp160r1" -#define NID_secp160r1 709 -#define OBJ_secp160r1 OBJ_secg_ellipticCurve,8L - -#define SN_secp160r2 "secp160r2" -#define NID_secp160r2 710 -#define OBJ_secp160r2 OBJ_secg_ellipticCurve,30L - -#define SN_secp192k1 "secp192k1" -#define NID_secp192k1 711 -#define OBJ_secp192k1 OBJ_secg_ellipticCurve,31L - -#define SN_secp224k1 "secp224k1" -#define NID_secp224k1 712 -#define OBJ_secp224k1 OBJ_secg_ellipticCurve,32L - -#define SN_secp224r1 "secp224r1" -#define NID_secp224r1 713 -#define OBJ_secp224r1 OBJ_secg_ellipticCurve,33L - -#define SN_secp256k1 "secp256k1" -#define NID_secp256k1 714 -#define OBJ_secp256k1 OBJ_secg_ellipticCurve,10L - -#define SN_secp384r1 "secp384r1" -#define NID_secp384r1 715 -#define OBJ_secp384r1 OBJ_secg_ellipticCurve,34L - -#define SN_secp521r1 "secp521r1" -#define NID_secp521r1 716 -#define OBJ_secp521r1 OBJ_secg_ellipticCurve,35L - -#define SN_sect113r1 "sect113r1" -#define NID_sect113r1 717 -#define OBJ_sect113r1 OBJ_secg_ellipticCurve,4L - -#define SN_sect113r2 "sect113r2" -#define NID_sect113r2 718 -#define OBJ_sect113r2 OBJ_secg_ellipticCurve,5L - -#define SN_sect131r1 "sect131r1" -#define NID_sect131r1 719 -#define OBJ_sect131r1 OBJ_secg_ellipticCurve,22L - -#define SN_sect131r2 "sect131r2" -#define NID_sect131r2 720 -#define OBJ_sect131r2 OBJ_secg_ellipticCurve,23L - -#define SN_sect163k1 "sect163k1" -#define NID_sect163k1 721 -#define OBJ_sect163k1 OBJ_secg_ellipticCurve,1L - -#define SN_sect163r1 "sect163r1" -#define NID_sect163r1 722 -#define OBJ_sect163r1 OBJ_secg_ellipticCurve,2L - -#define SN_sect163r2 "sect163r2" -#define NID_sect163r2 723 -#define OBJ_sect163r2 OBJ_secg_ellipticCurve,15L - -#define SN_sect193r1 "sect193r1" -#define NID_sect193r1 724 -#define OBJ_sect193r1 OBJ_secg_ellipticCurve,24L - -#define SN_sect193r2 "sect193r2" -#define NID_sect193r2 725 -#define OBJ_sect193r2 OBJ_secg_ellipticCurve,25L - -#define SN_sect233k1 "sect233k1" -#define NID_sect233k1 726 -#define OBJ_sect233k1 OBJ_secg_ellipticCurve,26L - -#define SN_sect233r1 "sect233r1" -#define NID_sect233r1 727 -#define OBJ_sect233r1 OBJ_secg_ellipticCurve,27L - -#define SN_sect239k1 "sect239k1" -#define NID_sect239k1 728 -#define OBJ_sect239k1 OBJ_secg_ellipticCurve,3L - -#define SN_sect283k1 "sect283k1" -#define NID_sect283k1 729 -#define OBJ_sect283k1 OBJ_secg_ellipticCurve,16L - -#define SN_sect283r1 "sect283r1" -#define NID_sect283r1 730 -#define OBJ_sect283r1 OBJ_secg_ellipticCurve,17L - -#define SN_sect409k1 "sect409k1" -#define NID_sect409k1 731 -#define OBJ_sect409k1 OBJ_secg_ellipticCurve,36L - -#define SN_sect409r1 "sect409r1" -#define NID_sect409r1 732 -#define OBJ_sect409r1 OBJ_secg_ellipticCurve,37L - -#define SN_sect571k1 "sect571k1" -#define NID_sect571k1 733 -#define OBJ_sect571k1 OBJ_secg_ellipticCurve,38L - -#define SN_sect571r1 "sect571r1" -#define NID_sect571r1 734 -#define OBJ_sect571r1 OBJ_secg_ellipticCurve,39L - -#define OBJ_wap_wsg_idm_ecid OBJ_wap_wsg,4L - -#define SN_wap_wsg_idm_ecid_wtls1 "wap-wsg-idm-ecid-wtls1" -#define NID_wap_wsg_idm_ecid_wtls1 735 -#define OBJ_wap_wsg_idm_ecid_wtls1 OBJ_wap_wsg_idm_ecid,1L - -#define SN_wap_wsg_idm_ecid_wtls3 "wap-wsg-idm-ecid-wtls3" -#define NID_wap_wsg_idm_ecid_wtls3 736 -#define OBJ_wap_wsg_idm_ecid_wtls3 OBJ_wap_wsg_idm_ecid,3L - -#define SN_wap_wsg_idm_ecid_wtls4 "wap-wsg-idm-ecid-wtls4" -#define NID_wap_wsg_idm_ecid_wtls4 737 -#define OBJ_wap_wsg_idm_ecid_wtls4 OBJ_wap_wsg_idm_ecid,4L - -#define SN_wap_wsg_idm_ecid_wtls5 "wap-wsg-idm-ecid-wtls5" -#define NID_wap_wsg_idm_ecid_wtls5 738 -#define OBJ_wap_wsg_idm_ecid_wtls5 OBJ_wap_wsg_idm_ecid,5L - -#define SN_wap_wsg_idm_ecid_wtls6 "wap-wsg-idm-ecid-wtls6" -#define NID_wap_wsg_idm_ecid_wtls6 739 -#define OBJ_wap_wsg_idm_ecid_wtls6 OBJ_wap_wsg_idm_ecid,6L - -#define SN_wap_wsg_idm_ecid_wtls7 "wap-wsg-idm-ecid-wtls7" -#define NID_wap_wsg_idm_ecid_wtls7 740 -#define OBJ_wap_wsg_idm_ecid_wtls7 OBJ_wap_wsg_idm_ecid,7L - -#define SN_wap_wsg_idm_ecid_wtls8 "wap-wsg-idm-ecid-wtls8" -#define NID_wap_wsg_idm_ecid_wtls8 741 -#define OBJ_wap_wsg_idm_ecid_wtls8 OBJ_wap_wsg_idm_ecid,8L - -#define SN_wap_wsg_idm_ecid_wtls9 "wap-wsg-idm-ecid-wtls9" -#define NID_wap_wsg_idm_ecid_wtls9 742 -#define OBJ_wap_wsg_idm_ecid_wtls9 OBJ_wap_wsg_idm_ecid,9L - -#define SN_wap_wsg_idm_ecid_wtls10 "wap-wsg-idm-ecid-wtls10" -#define NID_wap_wsg_idm_ecid_wtls10 743 -#define OBJ_wap_wsg_idm_ecid_wtls10 OBJ_wap_wsg_idm_ecid,10L - -#define SN_wap_wsg_idm_ecid_wtls11 "wap-wsg-idm-ecid-wtls11" -#define NID_wap_wsg_idm_ecid_wtls11 744 -#define OBJ_wap_wsg_idm_ecid_wtls11 OBJ_wap_wsg_idm_ecid,11L - -#define SN_wap_wsg_idm_ecid_wtls12 "wap-wsg-idm-ecid-wtls12" -#define NID_wap_wsg_idm_ecid_wtls12 745 -#define OBJ_wap_wsg_idm_ecid_wtls12 OBJ_wap_wsg_idm_ecid,12L - -#define SN_cast5_cbc "CAST5-CBC" -#define LN_cast5_cbc "cast5-cbc" -#define NID_cast5_cbc 108 -#define OBJ_cast5_cbc OBJ_ISO_US,113533L,7L,66L,10L - -#define SN_cast5_ecb "CAST5-ECB" -#define LN_cast5_ecb "cast5-ecb" -#define NID_cast5_ecb 109 - -#define SN_cast5_cfb64 "CAST5-CFB" -#define LN_cast5_cfb64 "cast5-cfb" -#define NID_cast5_cfb64 110 - -#define SN_cast5_ofb64 "CAST5-OFB" -#define LN_cast5_ofb64 "cast5-ofb" -#define NID_cast5_ofb64 111 - -#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" -#define NID_pbeWithMD5AndCast5_CBC 112 -#define OBJ_pbeWithMD5AndCast5_CBC OBJ_ISO_US,113533L,7L,66L,12L - -#define SN_rsadsi "rsadsi" -#define LN_rsadsi "RSA Data Security, Inc." -#define NID_rsadsi 1 -#define OBJ_rsadsi OBJ_ISO_US,113549L - -#define SN_pkcs "pkcs" -#define LN_pkcs "RSA Data Security, Inc. PKCS" -#define NID_pkcs 2 -#define OBJ_pkcs OBJ_rsadsi,1L - -#define SN_pkcs1 "pkcs1" -#define NID_pkcs1 186 -#define OBJ_pkcs1 OBJ_pkcs,1L - -#define LN_rsaEncryption "rsaEncryption" -#define NID_rsaEncryption 6 -#define OBJ_rsaEncryption OBJ_pkcs1,1L - -#define SN_md2WithRSAEncryption "RSA-MD2" -#define LN_md2WithRSAEncryption "md2WithRSAEncryption" -#define NID_md2WithRSAEncryption 7 -#define OBJ_md2WithRSAEncryption OBJ_pkcs1,2L - -#define SN_md4WithRSAEncryption "RSA-MD4" -#define LN_md4WithRSAEncryption "md4WithRSAEncryption" -#define NID_md4WithRSAEncryption 396 -#define OBJ_md4WithRSAEncryption OBJ_pkcs1,3L - -#define SN_md5WithRSAEncryption "RSA-MD5" -#define LN_md5WithRSAEncryption "md5WithRSAEncryption" -#define NID_md5WithRSAEncryption 8 -#define OBJ_md5WithRSAEncryption OBJ_pkcs1,4L - -#define SN_sha1WithRSAEncryption "RSA-SHA1" -#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" -#define NID_sha1WithRSAEncryption 65 -#define OBJ_sha1WithRSAEncryption OBJ_pkcs1,5L - -#define SN_sha256WithRSAEncryption "RSA-SHA256" -#define LN_sha256WithRSAEncryption "sha256WithRSAEncryption" -#define NID_sha256WithRSAEncryption 668 -#define OBJ_sha256WithRSAEncryption OBJ_pkcs1,11L - -#define SN_sha384WithRSAEncryption "RSA-SHA384" -#define LN_sha384WithRSAEncryption "sha384WithRSAEncryption" -#define NID_sha384WithRSAEncryption 669 -#define OBJ_sha384WithRSAEncryption OBJ_pkcs1,12L - -#define SN_sha512WithRSAEncryption "RSA-SHA512" -#define LN_sha512WithRSAEncryption "sha512WithRSAEncryption" -#define NID_sha512WithRSAEncryption 670 -#define OBJ_sha512WithRSAEncryption OBJ_pkcs1,13L - -#define SN_sha224WithRSAEncryption "RSA-SHA224" -#define LN_sha224WithRSAEncryption "sha224WithRSAEncryption" -#define NID_sha224WithRSAEncryption 671 -#define OBJ_sha224WithRSAEncryption OBJ_pkcs1,14L - -#define SN_pkcs3 "pkcs3" -#define NID_pkcs3 27 -#define OBJ_pkcs3 OBJ_pkcs,3L - -#define LN_dhKeyAgreement "dhKeyAgreement" -#define NID_dhKeyAgreement 28 -#define OBJ_dhKeyAgreement OBJ_pkcs3,1L - -#define SN_pkcs5 "pkcs5" -#define NID_pkcs5 187 -#define OBJ_pkcs5 OBJ_pkcs,5L - -#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" -#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" -#define NID_pbeWithMD2AndDES_CBC 9 -#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs5,1L - -#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" -#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" -#define NID_pbeWithMD5AndDES_CBC 10 -#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs5,3L - -#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" -#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" -#define NID_pbeWithMD2AndRC2_CBC 168 -#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs5,4L - -#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" -#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" -#define NID_pbeWithMD5AndRC2_CBC 169 -#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs5,6L - -#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" -#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" -#define NID_pbeWithSHA1AndDES_CBC 170 -#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs5,10L - -#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" -#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" -#define NID_pbeWithSHA1AndRC2_CBC 68 -#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs5,11L - -#define LN_id_pbkdf2 "PBKDF2" -#define NID_id_pbkdf2 69 -#define OBJ_id_pbkdf2 OBJ_pkcs5,12L - -#define LN_pbes2 "PBES2" -#define NID_pbes2 161 -#define OBJ_pbes2 OBJ_pkcs5,13L - -#define LN_pbmac1 "PBMAC1" -#define NID_pbmac1 162 -#define OBJ_pbmac1 OBJ_pkcs5,14L - -#define SN_pkcs7 "pkcs7" -#define NID_pkcs7 20 -#define OBJ_pkcs7 OBJ_pkcs,7L - -#define LN_pkcs7_data "pkcs7-data" -#define NID_pkcs7_data 21 -#define OBJ_pkcs7_data OBJ_pkcs7,1L - -#define LN_pkcs7_signed "pkcs7-signedData" -#define NID_pkcs7_signed 22 -#define OBJ_pkcs7_signed OBJ_pkcs7,2L - -#define LN_pkcs7_enveloped "pkcs7-envelopedData" -#define NID_pkcs7_enveloped 23 -#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L - -#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" -#define NID_pkcs7_signedAndEnveloped 24 -#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L - -#define LN_pkcs7_digest "pkcs7-digestData" -#define NID_pkcs7_digest 25 -#define OBJ_pkcs7_digest OBJ_pkcs7,5L - -#define LN_pkcs7_encrypted "pkcs7-encryptedData" -#define NID_pkcs7_encrypted 26 -#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L - -#define SN_pkcs9 "pkcs9" -#define NID_pkcs9 47 -#define OBJ_pkcs9 OBJ_pkcs,9L - -#define LN_pkcs9_emailAddress "emailAddress" -#define NID_pkcs9_emailAddress 48 -#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L - -#define LN_pkcs9_unstructuredName "unstructuredName" -#define NID_pkcs9_unstructuredName 49 -#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L - -#define LN_pkcs9_contentType "contentType" -#define NID_pkcs9_contentType 50 -#define OBJ_pkcs9_contentType OBJ_pkcs9,3L - -#define LN_pkcs9_messageDigest "messageDigest" -#define NID_pkcs9_messageDigest 51 -#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L - -#define LN_pkcs9_signingTime "signingTime" -#define NID_pkcs9_signingTime 52 -#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L - -#define LN_pkcs9_countersignature "countersignature" -#define NID_pkcs9_countersignature 53 -#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L - -#define LN_pkcs9_challengePassword "challengePassword" -#define NID_pkcs9_challengePassword 54 -#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L - -#define LN_pkcs9_unstructuredAddress "unstructuredAddress" -#define NID_pkcs9_unstructuredAddress 55 -#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L - -#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" -#define NID_pkcs9_extCertAttributes 56 -#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L - -#define SN_ext_req "extReq" -#define LN_ext_req "Extension Request" -#define NID_ext_req 172 -#define OBJ_ext_req OBJ_pkcs9,14L - -#define SN_SMIMECapabilities "SMIME-CAPS" -#define LN_SMIMECapabilities "S/MIME Capabilities" -#define NID_SMIMECapabilities 167 -#define OBJ_SMIMECapabilities OBJ_pkcs9,15L - -#define SN_SMIME "SMIME" -#define LN_SMIME "S/MIME" -#define NID_SMIME 188 -#define OBJ_SMIME OBJ_pkcs9,16L - -#define SN_id_smime_mod "id-smime-mod" -#define NID_id_smime_mod 189 -#define OBJ_id_smime_mod OBJ_SMIME,0L - -#define SN_id_smime_ct "id-smime-ct" -#define NID_id_smime_ct 190 -#define OBJ_id_smime_ct OBJ_SMIME,1L - -#define SN_id_smime_aa "id-smime-aa" -#define NID_id_smime_aa 191 -#define OBJ_id_smime_aa OBJ_SMIME,2L - -#define SN_id_smime_alg "id-smime-alg" -#define NID_id_smime_alg 192 -#define OBJ_id_smime_alg OBJ_SMIME,3L - -#define SN_id_smime_cd "id-smime-cd" -#define NID_id_smime_cd 193 -#define OBJ_id_smime_cd OBJ_SMIME,4L - -#define SN_id_smime_spq "id-smime-spq" -#define NID_id_smime_spq 194 -#define OBJ_id_smime_spq OBJ_SMIME,5L - -#define SN_id_smime_cti "id-smime-cti" -#define NID_id_smime_cti 195 -#define OBJ_id_smime_cti OBJ_SMIME,6L - -#define SN_id_smime_mod_cms "id-smime-mod-cms" -#define NID_id_smime_mod_cms 196 -#define OBJ_id_smime_mod_cms OBJ_id_smime_mod,1L - -#define SN_id_smime_mod_ess "id-smime-mod-ess" -#define NID_id_smime_mod_ess 197 -#define OBJ_id_smime_mod_ess OBJ_id_smime_mod,2L - -#define SN_id_smime_mod_oid "id-smime-mod-oid" -#define NID_id_smime_mod_oid 198 -#define OBJ_id_smime_mod_oid OBJ_id_smime_mod,3L - -#define SN_id_smime_mod_msg_v3 "id-smime-mod-msg-v3" -#define NID_id_smime_mod_msg_v3 199 -#define OBJ_id_smime_mod_msg_v3 OBJ_id_smime_mod,4L - -#define SN_id_smime_mod_ets_eSignature_88 "id-smime-mod-ets-eSignature-88" -#define NID_id_smime_mod_ets_eSignature_88 200 -#define OBJ_id_smime_mod_ets_eSignature_88 OBJ_id_smime_mod,5L - -#define SN_id_smime_mod_ets_eSignature_97 "id-smime-mod-ets-eSignature-97" -#define NID_id_smime_mod_ets_eSignature_97 201 -#define OBJ_id_smime_mod_ets_eSignature_97 OBJ_id_smime_mod,6L - -#define SN_id_smime_mod_ets_eSigPolicy_88 "id-smime-mod-ets-eSigPolicy-88" -#define NID_id_smime_mod_ets_eSigPolicy_88 202 -#define OBJ_id_smime_mod_ets_eSigPolicy_88 OBJ_id_smime_mod,7L - -#define SN_id_smime_mod_ets_eSigPolicy_97 "id-smime-mod-ets-eSigPolicy-97" -#define NID_id_smime_mod_ets_eSigPolicy_97 203 -#define OBJ_id_smime_mod_ets_eSigPolicy_97 OBJ_id_smime_mod,8L - -#define SN_id_smime_ct_receipt "id-smime-ct-receipt" -#define NID_id_smime_ct_receipt 204 -#define OBJ_id_smime_ct_receipt OBJ_id_smime_ct,1L - -#define SN_id_smime_ct_authData "id-smime-ct-authData" -#define NID_id_smime_ct_authData 205 -#define OBJ_id_smime_ct_authData OBJ_id_smime_ct,2L - -#define SN_id_smime_ct_publishCert "id-smime-ct-publishCert" -#define NID_id_smime_ct_publishCert 206 -#define OBJ_id_smime_ct_publishCert OBJ_id_smime_ct,3L - -#define SN_id_smime_ct_TSTInfo "id-smime-ct-TSTInfo" -#define NID_id_smime_ct_TSTInfo 207 -#define OBJ_id_smime_ct_TSTInfo OBJ_id_smime_ct,4L - -#define SN_id_smime_ct_TDTInfo "id-smime-ct-TDTInfo" -#define NID_id_smime_ct_TDTInfo 208 -#define OBJ_id_smime_ct_TDTInfo OBJ_id_smime_ct,5L - -#define SN_id_smime_ct_contentInfo "id-smime-ct-contentInfo" -#define NID_id_smime_ct_contentInfo 209 -#define OBJ_id_smime_ct_contentInfo OBJ_id_smime_ct,6L - -#define SN_id_smime_ct_DVCSRequestData "id-smime-ct-DVCSRequestData" -#define NID_id_smime_ct_DVCSRequestData 210 -#define OBJ_id_smime_ct_DVCSRequestData OBJ_id_smime_ct,7L - -#define SN_id_smime_ct_DVCSResponseData "id-smime-ct-DVCSResponseData" -#define NID_id_smime_ct_DVCSResponseData 211 -#define OBJ_id_smime_ct_DVCSResponseData OBJ_id_smime_ct,8L - -#define SN_id_smime_aa_receiptRequest "id-smime-aa-receiptRequest" -#define NID_id_smime_aa_receiptRequest 212 -#define OBJ_id_smime_aa_receiptRequest OBJ_id_smime_aa,1L - -#define SN_id_smime_aa_securityLabel "id-smime-aa-securityLabel" -#define NID_id_smime_aa_securityLabel 213 -#define OBJ_id_smime_aa_securityLabel OBJ_id_smime_aa,2L - -#define SN_id_smime_aa_mlExpandHistory "id-smime-aa-mlExpandHistory" -#define NID_id_smime_aa_mlExpandHistory 214 -#define OBJ_id_smime_aa_mlExpandHistory OBJ_id_smime_aa,3L - -#define SN_id_smime_aa_contentHint "id-smime-aa-contentHint" -#define NID_id_smime_aa_contentHint 215 -#define OBJ_id_smime_aa_contentHint OBJ_id_smime_aa,4L - -#define SN_id_smime_aa_msgSigDigest "id-smime-aa-msgSigDigest" -#define NID_id_smime_aa_msgSigDigest 216 -#define OBJ_id_smime_aa_msgSigDigest OBJ_id_smime_aa,5L - -#define SN_id_smime_aa_encapContentType "id-smime-aa-encapContentType" -#define NID_id_smime_aa_encapContentType 217 -#define OBJ_id_smime_aa_encapContentType OBJ_id_smime_aa,6L - -#define SN_id_smime_aa_contentIdentifier "id-smime-aa-contentIdentifier" -#define NID_id_smime_aa_contentIdentifier 218 -#define OBJ_id_smime_aa_contentIdentifier OBJ_id_smime_aa,7L - -#define SN_id_smime_aa_macValue "id-smime-aa-macValue" -#define NID_id_smime_aa_macValue 219 -#define OBJ_id_smime_aa_macValue OBJ_id_smime_aa,8L - -#define SN_id_smime_aa_equivalentLabels "id-smime-aa-equivalentLabels" -#define NID_id_smime_aa_equivalentLabels 220 -#define OBJ_id_smime_aa_equivalentLabels OBJ_id_smime_aa,9L - -#define SN_id_smime_aa_contentReference "id-smime-aa-contentReference" -#define NID_id_smime_aa_contentReference 221 -#define OBJ_id_smime_aa_contentReference OBJ_id_smime_aa,10L - -#define SN_id_smime_aa_encrypKeyPref "id-smime-aa-encrypKeyPref" -#define NID_id_smime_aa_encrypKeyPref 222 -#define OBJ_id_smime_aa_encrypKeyPref OBJ_id_smime_aa,11L - -#define SN_id_smime_aa_signingCertificate "id-smime-aa-signingCertificate" -#define NID_id_smime_aa_signingCertificate 223 -#define OBJ_id_smime_aa_signingCertificate OBJ_id_smime_aa,12L - -#define SN_id_smime_aa_smimeEncryptCerts "id-smime-aa-smimeEncryptCerts" -#define NID_id_smime_aa_smimeEncryptCerts 224 -#define OBJ_id_smime_aa_smimeEncryptCerts OBJ_id_smime_aa,13L - -#define SN_id_smime_aa_timeStampToken "id-smime-aa-timeStampToken" -#define NID_id_smime_aa_timeStampToken 225 -#define OBJ_id_smime_aa_timeStampToken OBJ_id_smime_aa,14L - -#define SN_id_smime_aa_ets_sigPolicyId "id-smime-aa-ets-sigPolicyId" -#define NID_id_smime_aa_ets_sigPolicyId 226 -#define OBJ_id_smime_aa_ets_sigPolicyId OBJ_id_smime_aa,15L - -#define SN_id_smime_aa_ets_commitmentType "id-smime-aa-ets-commitmentType" -#define NID_id_smime_aa_ets_commitmentType 227 -#define OBJ_id_smime_aa_ets_commitmentType OBJ_id_smime_aa,16L - -#define SN_id_smime_aa_ets_signerLocation "id-smime-aa-ets-signerLocation" -#define NID_id_smime_aa_ets_signerLocation 228 -#define OBJ_id_smime_aa_ets_signerLocation OBJ_id_smime_aa,17L - -#define SN_id_smime_aa_ets_signerAttr "id-smime-aa-ets-signerAttr" -#define NID_id_smime_aa_ets_signerAttr 229 -#define OBJ_id_smime_aa_ets_signerAttr OBJ_id_smime_aa,18L - -#define SN_id_smime_aa_ets_otherSigCert "id-smime-aa-ets-otherSigCert" -#define NID_id_smime_aa_ets_otherSigCert 230 -#define OBJ_id_smime_aa_ets_otherSigCert OBJ_id_smime_aa,19L - -#define SN_id_smime_aa_ets_contentTimestamp "id-smime-aa-ets-contentTimestamp" -#define NID_id_smime_aa_ets_contentTimestamp 231 -#define OBJ_id_smime_aa_ets_contentTimestamp OBJ_id_smime_aa,20L - -#define SN_id_smime_aa_ets_CertificateRefs "id-smime-aa-ets-CertificateRefs" -#define NID_id_smime_aa_ets_CertificateRefs 232 -#define OBJ_id_smime_aa_ets_CertificateRefs OBJ_id_smime_aa,21L - -#define SN_id_smime_aa_ets_RevocationRefs "id-smime-aa-ets-RevocationRefs" -#define NID_id_smime_aa_ets_RevocationRefs 233 -#define OBJ_id_smime_aa_ets_RevocationRefs OBJ_id_smime_aa,22L - -#define SN_id_smime_aa_ets_certValues "id-smime-aa-ets-certValues" -#define NID_id_smime_aa_ets_certValues 234 -#define OBJ_id_smime_aa_ets_certValues OBJ_id_smime_aa,23L - -#define SN_id_smime_aa_ets_revocationValues "id-smime-aa-ets-revocationValues" -#define NID_id_smime_aa_ets_revocationValues 235 -#define OBJ_id_smime_aa_ets_revocationValues OBJ_id_smime_aa,24L - -#define SN_id_smime_aa_ets_escTimeStamp "id-smime-aa-ets-escTimeStamp" -#define NID_id_smime_aa_ets_escTimeStamp 236 -#define OBJ_id_smime_aa_ets_escTimeStamp OBJ_id_smime_aa,25L - -#define SN_id_smime_aa_ets_certCRLTimestamp "id-smime-aa-ets-certCRLTimestamp" -#define NID_id_smime_aa_ets_certCRLTimestamp 237 -#define OBJ_id_smime_aa_ets_certCRLTimestamp OBJ_id_smime_aa,26L - -#define SN_id_smime_aa_ets_archiveTimeStamp "id-smime-aa-ets-archiveTimeStamp" -#define NID_id_smime_aa_ets_archiveTimeStamp 238 -#define OBJ_id_smime_aa_ets_archiveTimeStamp OBJ_id_smime_aa,27L - -#define SN_id_smime_aa_signatureType "id-smime-aa-signatureType" -#define NID_id_smime_aa_signatureType 239 -#define OBJ_id_smime_aa_signatureType OBJ_id_smime_aa,28L - -#define SN_id_smime_aa_dvcs_dvc "id-smime-aa-dvcs-dvc" -#define NID_id_smime_aa_dvcs_dvc 240 -#define OBJ_id_smime_aa_dvcs_dvc OBJ_id_smime_aa,29L - -#define SN_id_smime_alg_ESDHwith3DES "id-smime-alg-ESDHwith3DES" -#define NID_id_smime_alg_ESDHwith3DES 241 -#define OBJ_id_smime_alg_ESDHwith3DES OBJ_id_smime_alg,1L - -#define SN_id_smime_alg_ESDHwithRC2 "id-smime-alg-ESDHwithRC2" -#define NID_id_smime_alg_ESDHwithRC2 242 -#define OBJ_id_smime_alg_ESDHwithRC2 OBJ_id_smime_alg,2L - -#define SN_id_smime_alg_3DESwrap "id-smime-alg-3DESwrap" -#define NID_id_smime_alg_3DESwrap 243 -#define OBJ_id_smime_alg_3DESwrap OBJ_id_smime_alg,3L - -#define SN_id_smime_alg_RC2wrap "id-smime-alg-RC2wrap" -#define NID_id_smime_alg_RC2wrap 244 -#define OBJ_id_smime_alg_RC2wrap OBJ_id_smime_alg,4L - -#define SN_id_smime_alg_ESDH "id-smime-alg-ESDH" -#define NID_id_smime_alg_ESDH 245 -#define OBJ_id_smime_alg_ESDH OBJ_id_smime_alg,5L - -#define SN_id_smime_alg_CMS3DESwrap "id-smime-alg-CMS3DESwrap" -#define NID_id_smime_alg_CMS3DESwrap 246 -#define OBJ_id_smime_alg_CMS3DESwrap OBJ_id_smime_alg,6L - -#define SN_id_smime_alg_CMSRC2wrap "id-smime-alg-CMSRC2wrap" -#define NID_id_smime_alg_CMSRC2wrap 247 -#define OBJ_id_smime_alg_CMSRC2wrap OBJ_id_smime_alg,7L - -#define SN_id_smime_cd_ldap "id-smime-cd-ldap" -#define NID_id_smime_cd_ldap 248 -#define OBJ_id_smime_cd_ldap OBJ_id_smime_cd,1L - -#define SN_id_smime_spq_ets_sqt_uri "id-smime-spq-ets-sqt-uri" -#define NID_id_smime_spq_ets_sqt_uri 249 -#define OBJ_id_smime_spq_ets_sqt_uri OBJ_id_smime_spq,1L - -#define SN_id_smime_spq_ets_sqt_unotice "id-smime-spq-ets-sqt-unotice" -#define NID_id_smime_spq_ets_sqt_unotice 250 -#define OBJ_id_smime_spq_ets_sqt_unotice OBJ_id_smime_spq,2L - -#define SN_id_smime_cti_ets_proofOfOrigin "id-smime-cti-ets-proofOfOrigin" -#define NID_id_smime_cti_ets_proofOfOrigin 251 -#define OBJ_id_smime_cti_ets_proofOfOrigin OBJ_id_smime_cti,1L - -#define SN_id_smime_cti_ets_proofOfReceipt "id-smime-cti-ets-proofOfReceipt" -#define NID_id_smime_cti_ets_proofOfReceipt 252 -#define OBJ_id_smime_cti_ets_proofOfReceipt OBJ_id_smime_cti,2L - -#define SN_id_smime_cti_ets_proofOfDelivery "id-smime-cti-ets-proofOfDelivery" -#define NID_id_smime_cti_ets_proofOfDelivery 253 -#define OBJ_id_smime_cti_ets_proofOfDelivery OBJ_id_smime_cti,3L - -#define SN_id_smime_cti_ets_proofOfSender "id-smime-cti-ets-proofOfSender" -#define NID_id_smime_cti_ets_proofOfSender 254 -#define OBJ_id_smime_cti_ets_proofOfSender OBJ_id_smime_cti,4L - -#define SN_id_smime_cti_ets_proofOfApproval "id-smime-cti-ets-proofOfApproval" -#define NID_id_smime_cti_ets_proofOfApproval 255 -#define OBJ_id_smime_cti_ets_proofOfApproval OBJ_id_smime_cti,5L - -#define SN_id_smime_cti_ets_proofOfCreation "id-smime-cti-ets-proofOfCreation" -#define NID_id_smime_cti_ets_proofOfCreation 256 -#define OBJ_id_smime_cti_ets_proofOfCreation OBJ_id_smime_cti,6L - -#define LN_friendlyName "friendlyName" -#define NID_friendlyName 156 -#define OBJ_friendlyName OBJ_pkcs9,20L - -#define LN_localKeyID "localKeyID" -#define NID_localKeyID 157 -#define OBJ_localKeyID OBJ_pkcs9,21L - -#define SN_ms_csp_name "CSPName" -#define LN_ms_csp_name "Microsoft CSP Name" -#define NID_ms_csp_name 417 -#define OBJ_ms_csp_name 1L,3L,6L,1L,4L,1L,311L,17L,1L - -#define OBJ_certTypes OBJ_pkcs9,22L - -#define LN_x509Certificate "x509Certificate" -#define NID_x509Certificate 158 -#define OBJ_x509Certificate OBJ_certTypes,1L - -#define LN_sdsiCertificate "sdsiCertificate" -#define NID_sdsiCertificate 159 -#define OBJ_sdsiCertificate OBJ_certTypes,2L - -#define OBJ_crlTypes OBJ_pkcs9,23L - -#define LN_x509Crl "x509Crl" -#define NID_x509Crl 160 -#define OBJ_x509Crl OBJ_crlTypes,1L - -#define OBJ_pkcs12 OBJ_pkcs,12L - -#define OBJ_pkcs12_pbeids OBJ_pkcs12,1L - -#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" -#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" -#define NID_pbe_WithSHA1And128BitRC4 144 -#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids,1L - -#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" -#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" -#define NID_pbe_WithSHA1And40BitRC4 145 -#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids,2L - -#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" -#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" -#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 -#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids,3L - -#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" -#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" -#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 -#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids,4L - -#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" -#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" -#define NID_pbe_WithSHA1And128BitRC2_CBC 148 -#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids,5L - -#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" -#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" -#define NID_pbe_WithSHA1And40BitRC2_CBC 149 -#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids,6L - -#define OBJ_pkcs12_Version1 OBJ_pkcs12,10L - -#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1,1L - -#define LN_keyBag "keyBag" -#define NID_keyBag 150 -#define OBJ_keyBag OBJ_pkcs12_BagIds,1L - -#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" -#define NID_pkcs8ShroudedKeyBag 151 -#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds,2L - -#define LN_certBag "certBag" -#define NID_certBag 152 -#define OBJ_certBag OBJ_pkcs12_BagIds,3L - -#define LN_crlBag "crlBag" -#define NID_crlBag 153 -#define OBJ_crlBag OBJ_pkcs12_BagIds,4L - -#define LN_secretBag "secretBag" -#define NID_secretBag 154 -#define OBJ_secretBag OBJ_pkcs12_BagIds,5L - -#define LN_safeContentsBag "safeContentsBag" -#define NID_safeContentsBag 155 -#define OBJ_safeContentsBag OBJ_pkcs12_BagIds,6L - -#define SN_md2 "MD2" -#define LN_md2 "md2" -#define NID_md2 3 -#define OBJ_md2 OBJ_rsadsi,2L,2L - -#define SN_md4 "MD4" -#define LN_md4 "md4" -#define NID_md4 257 -#define OBJ_md4 OBJ_rsadsi,2L,4L - -#define SN_md5 "MD5" -#define LN_md5 "md5" -#define NID_md5 4 -#define OBJ_md5 OBJ_rsadsi,2L,5L - -#define SN_md5_sha1 "MD5-SHA1" -#define LN_md5_sha1 "md5-sha1" -#define NID_md5_sha1 114 - -#define LN_hmacWithSHA1 "hmacWithSHA1" -#define NID_hmacWithSHA1 163 -#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L - -#define SN_rc2_cbc "RC2-CBC" -#define LN_rc2_cbc "rc2-cbc" -#define NID_rc2_cbc 37 -#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L - -#define SN_rc2_ecb "RC2-ECB" -#define LN_rc2_ecb "rc2-ecb" -#define NID_rc2_ecb 38 - -#define SN_rc2_cfb64 "RC2-CFB" -#define LN_rc2_cfb64 "rc2-cfb" -#define NID_rc2_cfb64 39 - -#define SN_rc2_ofb64 "RC2-OFB" -#define LN_rc2_ofb64 "rc2-ofb" -#define NID_rc2_ofb64 40 - -#define SN_rc2_40_cbc "RC2-40-CBC" -#define LN_rc2_40_cbc "rc2-40-cbc" -#define NID_rc2_40_cbc 98 - -#define SN_rc2_64_cbc "RC2-64-CBC" -#define LN_rc2_64_cbc "rc2-64-cbc" -#define NID_rc2_64_cbc 166 - -#define SN_rc4 "RC4" -#define LN_rc4 "rc4" -#define NID_rc4 5 -#define OBJ_rc4 OBJ_rsadsi,3L,4L - -#define SN_rc4_40 "RC4-40" -#define LN_rc4_40 "rc4-40" -#define NID_rc4_40 97 - -#define SN_des_ede3_cbc "DES-EDE3-CBC" -#define LN_des_ede3_cbc "des-ede3-cbc" -#define NID_des_ede3_cbc 44 -#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L - -#define SN_rc5_cbc "RC5-CBC" -#define LN_rc5_cbc "rc5-cbc" -#define NID_rc5_cbc 120 -#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L - -#define SN_rc5_ecb "RC5-ECB" -#define LN_rc5_ecb "rc5-ecb" -#define NID_rc5_ecb 121 - -#define SN_rc5_cfb64 "RC5-CFB" -#define LN_rc5_cfb64 "rc5-cfb" -#define NID_rc5_cfb64 122 - -#define SN_rc5_ofb64 "RC5-OFB" -#define LN_rc5_ofb64 "rc5-ofb" -#define NID_rc5_ofb64 123 - -#define SN_ms_ext_req "msExtReq" -#define LN_ms_ext_req "Microsoft Extension Request" -#define NID_ms_ext_req 171 -#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L - -#define SN_ms_code_ind "msCodeInd" -#define LN_ms_code_ind "Microsoft Individual Code Signing" -#define NID_ms_code_ind 134 -#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L - -#define SN_ms_code_com "msCodeCom" -#define LN_ms_code_com "Microsoft Commercial Code Signing" -#define NID_ms_code_com 135 -#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L - -#define SN_ms_ctl_sign "msCTLSign" -#define LN_ms_ctl_sign "Microsoft Trust List Signing" -#define NID_ms_ctl_sign 136 -#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L - -#define SN_ms_sgc "msSGC" -#define LN_ms_sgc "Microsoft Server Gated Crypto" -#define NID_ms_sgc 137 -#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L - -#define SN_ms_efs "msEFS" -#define LN_ms_efs "Microsoft Encrypted File System" -#define NID_ms_efs 138 -#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L - -#define SN_ms_smartcard_login "msSmartcardLogin" -#define LN_ms_smartcard_login "Microsoft Smartcardlogin" -#define NID_ms_smartcard_login 648 -#define OBJ_ms_smartcard_login 1L,3L,6L,1L,4L,1L,311L,20L,2L,2L - -#define SN_ms_upn "msUPN" -#define LN_ms_upn "Microsoft Universal Principal Name" -#define NID_ms_upn 649 -#define OBJ_ms_upn 1L,3L,6L,1L,4L,1L,311L,20L,2L,3L - -#define SN_idea_cbc "IDEA-CBC" -#define LN_idea_cbc "idea-cbc" -#define NID_idea_cbc 34 -#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L - -#define SN_idea_ecb "IDEA-ECB" -#define LN_idea_ecb "idea-ecb" -#define NID_idea_ecb 36 - -#define SN_idea_cfb64 "IDEA-CFB" -#define LN_idea_cfb64 "idea-cfb" -#define NID_idea_cfb64 35 - -#define SN_idea_ofb64 "IDEA-OFB" -#define LN_idea_ofb64 "idea-ofb" -#define NID_idea_ofb64 46 - -#define SN_bf_cbc "BF-CBC" -#define LN_bf_cbc "bf-cbc" -#define NID_bf_cbc 91 -#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L - -#define SN_bf_ecb "BF-ECB" -#define LN_bf_ecb "bf-ecb" -#define NID_bf_ecb 92 - -#define SN_bf_cfb64 "BF-CFB" -#define LN_bf_cfb64 "bf-cfb" -#define NID_bf_cfb64 93 - -#define SN_bf_ofb64 "BF-OFB" -#define LN_bf_ofb64 "bf-ofb" -#define NID_bf_ofb64 94 - -#define SN_id_pkix "PKIX" -#define NID_id_pkix 127 -#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L - -#define SN_id_pkix_mod "id-pkix-mod" -#define NID_id_pkix_mod 258 -#define OBJ_id_pkix_mod OBJ_id_pkix,0L - -#define SN_id_pe "id-pe" -#define NID_id_pe 175 -#define OBJ_id_pe OBJ_id_pkix,1L - -#define SN_id_qt "id-qt" -#define NID_id_qt 259 -#define OBJ_id_qt OBJ_id_pkix,2L - -#define SN_id_kp "id-kp" -#define NID_id_kp 128 -#define OBJ_id_kp OBJ_id_pkix,3L - -#define SN_id_it "id-it" -#define NID_id_it 260 -#define OBJ_id_it OBJ_id_pkix,4L - -#define SN_id_pkip "id-pkip" -#define NID_id_pkip 261 -#define OBJ_id_pkip OBJ_id_pkix,5L - -#define SN_id_alg "id-alg" -#define NID_id_alg 262 -#define OBJ_id_alg OBJ_id_pkix,6L - -#define SN_id_cmc "id-cmc" -#define NID_id_cmc 263 -#define OBJ_id_cmc OBJ_id_pkix,7L - -#define SN_id_on "id-on" -#define NID_id_on 264 -#define OBJ_id_on OBJ_id_pkix,8L - -#define SN_id_pda "id-pda" -#define NID_id_pda 265 -#define OBJ_id_pda OBJ_id_pkix,9L - -#define SN_id_aca "id-aca" -#define NID_id_aca 266 -#define OBJ_id_aca OBJ_id_pkix,10L - -#define SN_id_qcs "id-qcs" -#define NID_id_qcs 267 -#define OBJ_id_qcs OBJ_id_pkix,11L - -#define SN_id_cct "id-cct" -#define NID_id_cct 268 -#define OBJ_id_cct OBJ_id_pkix,12L - -#define SN_id_ppl "id-ppl" -#define NID_id_ppl 662 -#define OBJ_id_ppl OBJ_id_pkix,21L - -#define SN_id_ad "id-ad" -#define NID_id_ad 176 -#define OBJ_id_ad OBJ_id_pkix,48L - -#define SN_id_pkix1_explicit_88 "id-pkix1-explicit-88" -#define NID_id_pkix1_explicit_88 269 -#define OBJ_id_pkix1_explicit_88 OBJ_id_pkix_mod,1L - -#define SN_id_pkix1_implicit_88 "id-pkix1-implicit-88" -#define NID_id_pkix1_implicit_88 270 -#define OBJ_id_pkix1_implicit_88 OBJ_id_pkix_mod,2L - -#define SN_id_pkix1_explicit_93 "id-pkix1-explicit-93" -#define NID_id_pkix1_explicit_93 271 -#define OBJ_id_pkix1_explicit_93 OBJ_id_pkix_mod,3L - -#define SN_id_pkix1_implicit_93 "id-pkix1-implicit-93" -#define NID_id_pkix1_implicit_93 272 -#define OBJ_id_pkix1_implicit_93 OBJ_id_pkix_mod,4L - -#define SN_id_mod_crmf "id-mod-crmf" -#define NID_id_mod_crmf 273 -#define OBJ_id_mod_crmf OBJ_id_pkix_mod,5L - -#define SN_id_mod_cmc "id-mod-cmc" -#define NID_id_mod_cmc 274 -#define OBJ_id_mod_cmc OBJ_id_pkix_mod,6L - -#define SN_id_mod_kea_profile_88 "id-mod-kea-profile-88" -#define NID_id_mod_kea_profile_88 275 -#define OBJ_id_mod_kea_profile_88 OBJ_id_pkix_mod,7L - -#define SN_id_mod_kea_profile_93 "id-mod-kea-profile-93" -#define NID_id_mod_kea_profile_93 276 -#define OBJ_id_mod_kea_profile_93 OBJ_id_pkix_mod,8L - -#define SN_id_mod_cmp "id-mod-cmp" -#define NID_id_mod_cmp 277 -#define OBJ_id_mod_cmp OBJ_id_pkix_mod,9L - -#define SN_id_mod_qualified_cert_88 "id-mod-qualified-cert-88" -#define NID_id_mod_qualified_cert_88 278 -#define OBJ_id_mod_qualified_cert_88 OBJ_id_pkix_mod,10L - -#define SN_id_mod_qualified_cert_93 "id-mod-qualified-cert-93" -#define NID_id_mod_qualified_cert_93 279 -#define OBJ_id_mod_qualified_cert_93 OBJ_id_pkix_mod,11L - -#define SN_id_mod_attribute_cert "id-mod-attribute-cert" -#define NID_id_mod_attribute_cert 280 -#define OBJ_id_mod_attribute_cert OBJ_id_pkix_mod,12L - -#define SN_id_mod_timestamp_protocol "id-mod-timestamp-protocol" -#define NID_id_mod_timestamp_protocol 281 -#define OBJ_id_mod_timestamp_protocol OBJ_id_pkix_mod,13L - -#define SN_id_mod_ocsp "id-mod-ocsp" -#define NID_id_mod_ocsp 282 -#define OBJ_id_mod_ocsp OBJ_id_pkix_mod,14L - -#define SN_id_mod_dvcs "id-mod-dvcs" -#define NID_id_mod_dvcs 283 -#define OBJ_id_mod_dvcs OBJ_id_pkix_mod,15L - -#define SN_id_mod_cmp2000 "id-mod-cmp2000" -#define NID_id_mod_cmp2000 284 -#define OBJ_id_mod_cmp2000 OBJ_id_pkix_mod,16L - -#define SN_info_access "authorityInfoAccess" -#define LN_info_access "Authority Information Access" -#define NID_info_access 177 -#define OBJ_info_access OBJ_id_pe,1L - -#define SN_biometricInfo "biometricInfo" -#define LN_biometricInfo "Biometric Info" -#define NID_biometricInfo 285 -#define OBJ_biometricInfo OBJ_id_pe,2L - -#define SN_qcStatements "qcStatements" -#define NID_qcStatements 286 -#define OBJ_qcStatements OBJ_id_pe,3L - -#define SN_ac_auditEntity "ac-auditEntity" -#define NID_ac_auditEntity 287 -#define OBJ_ac_auditEntity OBJ_id_pe,4L - -#define SN_ac_targeting "ac-targeting" -#define NID_ac_targeting 288 -#define OBJ_ac_targeting OBJ_id_pe,5L - -#define SN_aaControls "aaControls" -#define NID_aaControls 289 -#define OBJ_aaControls OBJ_id_pe,6L - -#define SN_sbgp_ipAddrBlock "sbgp-ipAddrBlock" -#define NID_sbgp_ipAddrBlock 290 -#define OBJ_sbgp_ipAddrBlock OBJ_id_pe,7L - -#define SN_sbgp_autonomousSysNum "sbgp-autonomousSysNum" -#define NID_sbgp_autonomousSysNum 291 -#define OBJ_sbgp_autonomousSysNum OBJ_id_pe,8L - -#define SN_sbgp_routerIdentifier "sbgp-routerIdentifier" -#define NID_sbgp_routerIdentifier 292 -#define OBJ_sbgp_routerIdentifier OBJ_id_pe,9L - -#define SN_ac_proxying "ac-proxying" -#define NID_ac_proxying 397 -#define OBJ_ac_proxying OBJ_id_pe,10L - -#define SN_sinfo_access "subjectInfoAccess" -#define LN_sinfo_access "Subject Information Access" -#define NID_sinfo_access 398 -#define OBJ_sinfo_access OBJ_id_pe,11L - -#define SN_proxyCertInfo "proxyCertInfo" -#define LN_proxyCertInfo "Proxy Certificate Information" -#define NID_proxyCertInfo 663 -#define OBJ_proxyCertInfo OBJ_id_pe,14L - -#define SN_id_qt_cps "id-qt-cps" -#define LN_id_qt_cps "Policy Qualifier CPS" -#define NID_id_qt_cps 164 -#define OBJ_id_qt_cps OBJ_id_qt,1L - -#define SN_id_qt_unotice "id-qt-unotice" -#define LN_id_qt_unotice "Policy Qualifier User Notice" -#define NID_id_qt_unotice 165 -#define OBJ_id_qt_unotice OBJ_id_qt,2L - -#define SN_textNotice "textNotice" -#define NID_textNotice 293 -#define OBJ_textNotice OBJ_id_qt,3L - -#define SN_server_auth "serverAuth" -#define LN_server_auth "TLS Web Server Authentication" -#define NID_server_auth 129 -#define OBJ_server_auth OBJ_id_kp,1L - -#define SN_client_auth "clientAuth" -#define LN_client_auth "TLS Web Client Authentication" -#define NID_client_auth 130 -#define OBJ_client_auth OBJ_id_kp,2L - -#define SN_code_sign "codeSigning" -#define LN_code_sign "Code Signing" -#define NID_code_sign 131 -#define OBJ_code_sign OBJ_id_kp,3L - -#define SN_email_protect "emailProtection" -#define LN_email_protect "E-mail Protection" -#define NID_email_protect 132 -#define OBJ_email_protect OBJ_id_kp,4L - -#define SN_ipsecEndSystem "ipsecEndSystem" -#define LN_ipsecEndSystem "IPSec End System" -#define NID_ipsecEndSystem 294 -#define OBJ_ipsecEndSystem OBJ_id_kp,5L - -#define SN_ipsecTunnel "ipsecTunnel" -#define LN_ipsecTunnel "IPSec Tunnel" -#define NID_ipsecTunnel 295 -#define OBJ_ipsecTunnel OBJ_id_kp,6L - -#define SN_ipsecUser "ipsecUser" -#define LN_ipsecUser "IPSec User" -#define NID_ipsecUser 296 -#define OBJ_ipsecUser OBJ_id_kp,7L - -#define SN_time_stamp "timeStamping" -#define LN_time_stamp "Time Stamping" -#define NID_time_stamp 133 -#define OBJ_time_stamp OBJ_id_kp,8L - -#define SN_OCSP_sign "OCSPSigning" -#define LN_OCSP_sign "OCSP Signing" -#define NID_OCSP_sign 180 -#define OBJ_OCSP_sign OBJ_id_kp,9L - -#define SN_dvcs "DVCS" -#define LN_dvcs "dvcs" -#define NID_dvcs 297 -#define OBJ_dvcs OBJ_id_kp,10L - -#define SN_id_it_caProtEncCert "id-it-caProtEncCert" -#define NID_id_it_caProtEncCert 298 -#define OBJ_id_it_caProtEncCert OBJ_id_it,1L - -#define SN_id_it_signKeyPairTypes "id-it-signKeyPairTypes" -#define NID_id_it_signKeyPairTypes 299 -#define OBJ_id_it_signKeyPairTypes OBJ_id_it,2L - -#define SN_id_it_encKeyPairTypes "id-it-encKeyPairTypes" -#define NID_id_it_encKeyPairTypes 300 -#define OBJ_id_it_encKeyPairTypes OBJ_id_it,3L - -#define SN_id_it_preferredSymmAlg "id-it-preferredSymmAlg" -#define NID_id_it_preferredSymmAlg 301 -#define OBJ_id_it_preferredSymmAlg OBJ_id_it,4L - -#define SN_id_it_caKeyUpdateInfo "id-it-caKeyUpdateInfo" -#define NID_id_it_caKeyUpdateInfo 302 -#define OBJ_id_it_caKeyUpdateInfo OBJ_id_it,5L - -#define SN_id_it_currentCRL "id-it-currentCRL" -#define NID_id_it_currentCRL 303 -#define OBJ_id_it_currentCRL OBJ_id_it,6L - -#define SN_id_it_unsupportedOIDs "id-it-unsupportedOIDs" -#define NID_id_it_unsupportedOIDs 304 -#define OBJ_id_it_unsupportedOIDs OBJ_id_it,7L - -#define SN_id_it_subscriptionRequest "id-it-subscriptionRequest" -#define NID_id_it_subscriptionRequest 305 -#define OBJ_id_it_subscriptionRequest OBJ_id_it,8L - -#define SN_id_it_subscriptionResponse "id-it-subscriptionResponse" -#define NID_id_it_subscriptionResponse 306 -#define OBJ_id_it_subscriptionResponse OBJ_id_it,9L - -#define SN_id_it_keyPairParamReq "id-it-keyPairParamReq" -#define NID_id_it_keyPairParamReq 307 -#define OBJ_id_it_keyPairParamReq OBJ_id_it,10L - -#define SN_id_it_keyPairParamRep "id-it-keyPairParamRep" -#define NID_id_it_keyPairParamRep 308 -#define OBJ_id_it_keyPairParamRep OBJ_id_it,11L - -#define SN_id_it_revPassphrase "id-it-revPassphrase" -#define NID_id_it_revPassphrase 309 -#define OBJ_id_it_revPassphrase OBJ_id_it,12L - -#define SN_id_it_implicitConfirm "id-it-implicitConfirm" -#define NID_id_it_implicitConfirm 310 -#define OBJ_id_it_implicitConfirm OBJ_id_it,13L - -#define SN_id_it_confirmWaitTime "id-it-confirmWaitTime" -#define NID_id_it_confirmWaitTime 311 -#define OBJ_id_it_confirmWaitTime OBJ_id_it,14L - -#define SN_id_it_origPKIMessage "id-it-origPKIMessage" -#define NID_id_it_origPKIMessage 312 -#define OBJ_id_it_origPKIMessage OBJ_id_it,15L - -#define SN_id_regCtrl "id-regCtrl" -#define NID_id_regCtrl 313 -#define OBJ_id_regCtrl OBJ_id_pkip,1L - -#define SN_id_regInfo "id-regInfo" -#define NID_id_regInfo 314 -#define OBJ_id_regInfo OBJ_id_pkip,2L - -#define SN_id_regCtrl_regToken "id-regCtrl-regToken" -#define NID_id_regCtrl_regToken 315 -#define OBJ_id_regCtrl_regToken OBJ_id_regCtrl,1L - -#define SN_id_regCtrl_authenticator "id-regCtrl-authenticator" -#define NID_id_regCtrl_authenticator 316 -#define OBJ_id_regCtrl_authenticator OBJ_id_regCtrl,2L - -#define SN_id_regCtrl_pkiPublicationInfo "id-regCtrl-pkiPublicationInfo" -#define NID_id_regCtrl_pkiPublicationInfo 317 -#define OBJ_id_regCtrl_pkiPublicationInfo OBJ_id_regCtrl,3L - -#define SN_id_regCtrl_pkiArchiveOptions "id-regCtrl-pkiArchiveOptions" -#define NID_id_regCtrl_pkiArchiveOptions 318 -#define OBJ_id_regCtrl_pkiArchiveOptions OBJ_id_regCtrl,4L - -#define SN_id_regCtrl_oldCertID "id-regCtrl-oldCertID" -#define NID_id_regCtrl_oldCertID 319 -#define OBJ_id_regCtrl_oldCertID OBJ_id_regCtrl,5L - -#define SN_id_regCtrl_protocolEncrKey "id-regCtrl-protocolEncrKey" -#define NID_id_regCtrl_protocolEncrKey 320 -#define OBJ_id_regCtrl_protocolEncrKey OBJ_id_regCtrl,6L - -#define SN_id_regInfo_utf8Pairs "id-regInfo-utf8Pairs" -#define NID_id_regInfo_utf8Pairs 321 -#define OBJ_id_regInfo_utf8Pairs OBJ_id_regInfo,1L - -#define SN_id_regInfo_certReq "id-regInfo-certReq" -#define NID_id_regInfo_certReq 322 -#define OBJ_id_regInfo_certReq OBJ_id_regInfo,2L - -#define SN_id_alg_des40 "id-alg-des40" -#define NID_id_alg_des40 323 -#define OBJ_id_alg_des40 OBJ_id_alg,1L - -#define SN_id_alg_noSignature "id-alg-noSignature" -#define NID_id_alg_noSignature 324 -#define OBJ_id_alg_noSignature OBJ_id_alg,2L - -#define SN_id_alg_dh_sig_hmac_sha1 "id-alg-dh-sig-hmac-sha1" -#define NID_id_alg_dh_sig_hmac_sha1 325 -#define OBJ_id_alg_dh_sig_hmac_sha1 OBJ_id_alg,3L - -#define SN_id_alg_dh_pop "id-alg-dh-pop" -#define NID_id_alg_dh_pop 326 -#define OBJ_id_alg_dh_pop OBJ_id_alg,4L - -#define SN_id_cmc_statusInfo "id-cmc-statusInfo" -#define NID_id_cmc_statusInfo 327 -#define OBJ_id_cmc_statusInfo OBJ_id_cmc,1L - -#define SN_id_cmc_identification "id-cmc-identification" -#define NID_id_cmc_identification 328 -#define OBJ_id_cmc_identification OBJ_id_cmc,2L - -#define SN_id_cmc_identityProof "id-cmc-identityProof" -#define NID_id_cmc_identityProof 329 -#define OBJ_id_cmc_identityProof OBJ_id_cmc,3L - -#define SN_id_cmc_dataReturn "id-cmc-dataReturn" -#define NID_id_cmc_dataReturn 330 -#define OBJ_id_cmc_dataReturn OBJ_id_cmc,4L - -#define SN_id_cmc_transactionId "id-cmc-transactionId" -#define NID_id_cmc_transactionId 331 -#define OBJ_id_cmc_transactionId OBJ_id_cmc,5L - -#define SN_id_cmc_senderNonce "id-cmc-senderNonce" -#define NID_id_cmc_senderNonce 332 -#define OBJ_id_cmc_senderNonce OBJ_id_cmc,6L - -#define SN_id_cmc_recipientNonce "id-cmc-recipientNonce" -#define NID_id_cmc_recipientNonce 333 -#define OBJ_id_cmc_recipientNonce OBJ_id_cmc,7L - -#define SN_id_cmc_addExtensions "id-cmc-addExtensions" -#define NID_id_cmc_addExtensions 334 -#define OBJ_id_cmc_addExtensions OBJ_id_cmc,8L - -#define SN_id_cmc_encryptedPOP "id-cmc-encryptedPOP" -#define NID_id_cmc_encryptedPOP 335 -#define OBJ_id_cmc_encryptedPOP OBJ_id_cmc,9L - -#define SN_id_cmc_decryptedPOP "id-cmc-decryptedPOP" -#define NID_id_cmc_decryptedPOP 336 -#define OBJ_id_cmc_decryptedPOP OBJ_id_cmc,10L - -#define SN_id_cmc_lraPOPWitness "id-cmc-lraPOPWitness" -#define NID_id_cmc_lraPOPWitness 337 -#define OBJ_id_cmc_lraPOPWitness OBJ_id_cmc,11L - -#define SN_id_cmc_getCert "id-cmc-getCert" -#define NID_id_cmc_getCert 338 -#define OBJ_id_cmc_getCert OBJ_id_cmc,15L - -#define SN_id_cmc_getCRL "id-cmc-getCRL" -#define NID_id_cmc_getCRL 339 -#define OBJ_id_cmc_getCRL OBJ_id_cmc,16L - -#define SN_id_cmc_revokeRequest "id-cmc-revokeRequest" -#define NID_id_cmc_revokeRequest 340 -#define OBJ_id_cmc_revokeRequest OBJ_id_cmc,17L - -#define SN_id_cmc_regInfo "id-cmc-regInfo" -#define NID_id_cmc_regInfo 341 -#define OBJ_id_cmc_regInfo OBJ_id_cmc,18L - -#define SN_id_cmc_responseInfo "id-cmc-responseInfo" -#define NID_id_cmc_responseInfo 342 -#define OBJ_id_cmc_responseInfo OBJ_id_cmc,19L - -#define SN_id_cmc_queryPending "id-cmc-queryPending" -#define NID_id_cmc_queryPending 343 -#define OBJ_id_cmc_queryPending OBJ_id_cmc,21L - -#define SN_id_cmc_popLinkRandom "id-cmc-popLinkRandom" -#define NID_id_cmc_popLinkRandom 344 -#define OBJ_id_cmc_popLinkRandom OBJ_id_cmc,22L - -#define SN_id_cmc_popLinkWitness "id-cmc-popLinkWitness" -#define NID_id_cmc_popLinkWitness 345 -#define OBJ_id_cmc_popLinkWitness OBJ_id_cmc,23L - -#define SN_id_cmc_confirmCertAcceptance "id-cmc-confirmCertAcceptance" -#define NID_id_cmc_confirmCertAcceptance 346 -#define OBJ_id_cmc_confirmCertAcceptance OBJ_id_cmc,24L - -#define SN_id_on_personalData "id-on-personalData" -#define NID_id_on_personalData 347 -#define OBJ_id_on_personalData OBJ_id_on,1L - -#define SN_id_pda_dateOfBirth "id-pda-dateOfBirth" -#define NID_id_pda_dateOfBirth 348 -#define OBJ_id_pda_dateOfBirth OBJ_id_pda,1L - -#define SN_id_pda_placeOfBirth "id-pda-placeOfBirth" -#define NID_id_pda_placeOfBirth 349 -#define OBJ_id_pda_placeOfBirth OBJ_id_pda,2L - -#define SN_id_pda_gender "id-pda-gender" -#define NID_id_pda_gender 351 -#define OBJ_id_pda_gender OBJ_id_pda,3L - -#define SN_id_pda_countryOfCitizenship "id-pda-countryOfCitizenship" -#define NID_id_pda_countryOfCitizenship 352 -#define OBJ_id_pda_countryOfCitizenship OBJ_id_pda,4L - -#define SN_id_pda_countryOfResidence "id-pda-countryOfResidence" -#define NID_id_pda_countryOfResidence 353 -#define OBJ_id_pda_countryOfResidence OBJ_id_pda,5L - -#define SN_id_aca_authenticationInfo "id-aca-authenticationInfo" -#define NID_id_aca_authenticationInfo 354 -#define OBJ_id_aca_authenticationInfo OBJ_id_aca,1L - -#define SN_id_aca_accessIdentity "id-aca-accessIdentity" -#define NID_id_aca_accessIdentity 355 -#define OBJ_id_aca_accessIdentity OBJ_id_aca,2L - -#define SN_id_aca_chargingIdentity "id-aca-chargingIdentity" -#define NID_id_aca_chargingIdentity 356 -#define OBJ_id_aca_chargingIdentity OBJ_id_aca,3L - -#define SN_id_aca_group "id-aca-group" -#define NID_id_aca_group 357 -#define OBJ_id_aca_group OBJ_id_aca,4L - -#define SN_id_aca_role "id-aca-role" -#define NID_id_aca_role 358 -#define OBJ_id_aca_role OBJ_id_aca,5L - -#define SN_id_aca_encAttrs "id-aca-encAttrs" -#define NID_id_aca_encAttrs 399 -#define OBJ_id_aca_encAttrs OBJ_id_aca,6L - -#define SN_id_qcs_pkixQCSyntax_v1 "id-qcs-pkixQCSyntax-v1" -#define NID_id_qcs_pkixQCSyntax_v1 359 -#define OBJ_id_qcs_pkixQCSyntax_v1 OBJ_id_qcs,1L - -#define SN_id_cct_crs "id-cct-crs" -#define NID_id_cct_crs 360 -#define OBJ_id_cct_crs OBJ_id_cct,1L - -#define SN_id_cct_PKIData "id-cct-PKIData" -#define NID_id_cct_PKIData 361 -#define OBJ_id_cct_PKIData OBJ_id_cct,2L - -#define SN_id_cct_PKIResponse "id-cct-PKIResponse" -#define NID_id_cct_PKIResponse 362 -#define OBJ_id_cct_PKIResponse OBJ_id_cct,3L - -#define SN_id_ppl_anyLanguage "id-ppl-anyLanguage" -#define LN_id_ppl_anyLanguage "Any language" -#define NID_id_ppl_anyLanguage 664 -#define OBJ_id_ppl_anyLanguage OBJ_id_ppl,0L - -#define SN_id_ppl_inheritAll "id-ppl-inheritAll" -#define LN_id_ppl_inheritAll "Inherit all" -#define NID_id_ppl_inheritAll 665 -#define OBJ_id_ppl_inheritAll OBJ_id_ppl,1L - -#define SN_Independent "id-ppl-independent" -#define LN_Independent "Independent" -#define NID_Independent 667 -#define OBJ_Independent OBJ_id_ppl,2L - -#define SN_ad_OCSP "OCSP" -#define LN_ad_OCSP "OCSP" -#define NID_ad_OCSP 178 -#define OBJ_ad_OCSP OBJ_id_ad,1L - -#define SN_ad_ca_issuers "caIssuers" -#define LN_ad_ca_issuers "CA Issuers" -#define NID_ad_ca_issuers 179 -#define OBJ_ad_ca_issuers OBJ_id_ad,2L - -#define SN_ad_timeStamping "ad_timestamping" -#define LN_ad_timeStamping "AD Time Stamping" -#define NID_ad_timeStamping 363 -#define OBJ_ad_timeStamping OBJ_id_ad,3L - -#define SN_ad_dvcs "AD_DVCS" -#define LN_ad_dvcs "ad dvcs" -#define NID_ad_dvcs 364 -#define OBJ_ad_dvcs OBJ_id_ad,4L - -#define OBJ_id_pkix_OCSP OBJ_ad_OCSP - -#define SN_id_pkix_OCSP_basic "basicOCSPResponse" -#define LN_id_pkix_OCSP_basic "Basic OCSP Response" -#define NID_id_pkix_OCSP_basic 365 -#define OBJ_id_pkix_OCSP_basic OBJ_id_pkix_OCSP,1L - -#define SN_id_pkix_OCSP_Nonce "Nonce" -#define LN_id_pkix_OCSP_Nonce "OCSP Nonce" -#define NID_id_pkix_OCSP_Nonce 366 -#define OBJ_id_pkix_OCSP_Nonce OBJ_id_pkix_OCSP,2L - -#define SN_id_pkix_OCSP_CrlID "CrlID" -#define LN_id_pkix_OCSP_CrlID "OCSP CRL ID" -#define NID_id_pkix_OCSP_CrlID 367 -#define OBJ_id_pkix_OCSP_CrlID OBJ_id_pkix_OCSP,3L - -#define SN_id_pkix_OCSP_acceptableResponses "acceptableResponses" -#define LN_id_pkix_OCSP_acceptableResponses "Acceptable OCSP Responses" -#define NID_id_pkix_OCSP_acceptableResponses 368 -#define OBJ_id_pkix_OCSP_acceptableResponses OBJ_id_pkix_OCSP,4L - -#define SN_id_pkix_OCSP_noCheck "noCheck" -#define LN_id_pkix_OCSP_noCheck "OCSP No Check" -#define NID_id_pkix_OCSP_noCheck 369 -#define OBJ_id_pkix_OCSP_noCheck OBJ_id_pkix_OCSP,5L - -#define SN_id_pkix_OCSP_archiveCutoff "archiveCutoff" -#define LN_id_pkix_OCSP_archiveCutoff "OCSP Archive Cutoff" -#define NID_id_pkix_OCSP_archiveCutoff 370 -#define OBJ_id_pkix_OCSP_archiveCutoff OBJ_id_pkix_OCSP,6L - -#define SN_id_pkix_OCSP_serviceLocator "serviceLocator" -#define LN_id_pkix_OCSP_serviceLocator "OCSP Service Locator" -#define NID_id_pkix_OCSP_serviceLocator 371 -#define OBJ_id_pkix_OCSP_serviceLocator OBJ_id_pkix_OCSP,7L - -#define SN_id_pkix_OCSP_extendedStatus "extendedStatus" -#define LN_id_pkix_OCSP_extendedStatus "Extended OCSP Status" -#define NID_id_pkix_OCSP_extendedStatus 372 -#define OBJ_id_pkix_OCSP_extendedStatus OBJ_id_pkix_OCSP,8L - -#define SN_id_pkix_OCSP_valid "valid" -#define NID_id_pkix_OCSP_valid 373 -#define OBJ_id_pkix_OCSP_valid OBJ_id_pkix_OCSP,9L - -#define SN_id_pkix_OCSP_path "path" -#define NID_id_pkix_OCSP_path 374 -#define OBJ_id_pkix_OCSP_path OBJ_id_pkix_OCSP,10L - -#define SN_id_pkix_OCSP_trustRoot "trustRoot" -#define LN_id_pkix_OCSP_trustRoot "Trust Root" -#define NID_id_pkix_OCSP_trustRoot 375 -#define OBJ_id_pkix_OCSP_trustRoot OBJ_id_pkix_OCSP,11L - -#define SN_algorithm "algorithm" -#define LN_algorithm "algorithm" -#define NID_algorithm 376 -#define OBJ_algorithm 1L,3L,14L,3L,2L - -#define SN_md5WithRSA "RSA-NP-MD5" -#define LN_md5WithRSA "md5WithRSA" -#define NID_md5WithRSA 104 -#define OBJ_md5WithRSA OBJ_algorithm,3L - -#define SN_des_ecb "DES-ECB" -#define LN_des_ecb "des-ecb" -#define NID_des_ecb 29 -#define OBJ_des_ecb OBJ_algorithm,6L - -#define SN_des_cbc "DES-CBC" -#define LN_des_cbc "des-cbc" -#define NID_des_cbc 31 -#define OBJ_des_cbc OBJ_algorithm,7L - -#define SN_des_ofb64 "DES-OFB" -#define LN_des_ofb64 "des-ofb" -#define NID_des_ofb64 45 -#define OBJ_des_ofb64 OBJ_algorithm,8L - -#define SN_des_cfb64 "DES-CFB" -#define LN_des_cfb64 "des-cfb" -#define NID_des_cfb64 30 -#define OBJ_des_cfb64 OBJ_algorithm,9L - -#define SN_rsaSignature "rsaSignature" -#define NID_rsaSignature 377 -#define OBJ_rsaSignature OBJ_algorithm,11L - -#define SN_dsa_2 "DSA-old" -#define LN_dsa_2 "dsaEncryption-old" -#define NID_dsa_2 67 -#define OBJ_dsa_2 OBJ_algorithm,12L - -#define SN_dsaWithSHA "DSA-SHA" -#define LN_dsaWithSHA "dsaWithSHA" -#define NID_dsaWithSHA 66 -#define OBJ_dsaWithSHA OBJ_algorithm,13L - -#define SN_shaWithRSAEncryption "RSA-SHA" -#define LN_shaWithRSAEncryption "shaWithRSAEncryption" -#define NID_shaWithRSAEncryption 42 -#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L - -#define SN_des_ede_ecb "DES-EDE" -#define LN_des_ede_ecb "des-ede" -#define NID_des_ede_ecb 32 -#define OBJ_des_ede_ecb OBJ_algorithm,17L - -#define SN_des_ede3_ecb "DES-EDE3" -#define LN_des_ede3_ecb "des-ede3" -#define NID_des_ede3_ecb 33 - -#define SN_des_ede_cbc "DES-EDE-CBC" -#define LN_des_ede_cbc "des-ede-cbc" -#define NID_des_ede_cbc 43 - -#define SN_des_ede_cfb64 "DES-EDE-CFB" -#define LN_des_ede_cfb64 "des-ede-cfb" -#define NID_des_ede_cfb64 60 - -#define SN_des_ede3_cfb64 "DES-EDE3-CFB" -#define LN_des_ede3_cfb64 "des-ede3-cfb" -#define NID_des_ede3_cfb64 61 - -#define SN_des_ede_ofb64 "DES-EDE-OFB" -#define LN_des_ede_ofb64 "des-ede-ofb" -#define NID_des_ede_ofb64 62 - -#define SN_des_ede3_ofb64 "DES-EDE3-OFB" -#define LN_des_ede3_ofb64 "des-ede3-ofb" -#define NID_des_ede3_ofb64 63 - -#define SN_desx_cbc "DESX-CBC" -#define LN_desx_cbc "desx-cbc" -#define NID_desx_cbc 80 - -#define SN_sha "SHA" -#define LN_sha "sha" -#define NID_sha 41 -#define OBJ_sha OBJ_algorithm,18L - -#define SN_sha1 "SHA1" -#define LN_sha1 "sha1" -#define NID_sha1 64 -#define OBJ_sha1 OBJ_algorithm,26L - -#define SN_dsaWithSHA1_2 "DSA-SHA1-old" -#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" -#define NID_dsaWithSHA1_2 70 -#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L - -#define SN_sha1WithRSA "RSA-SHA1-2" -#define LN_sha1WithRSA "sha1WithRSA" -#define NID_sha1WithRSA 115 -#define OBJ_sha1WithRSA OBJ_algorithm,29L - -#define SN_ripemd160 "RIPEMD160" -#define LN_ripemd160 "ripemd160" -#define NID_ripemd160 117 -#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L - -#define SN_ripemd160WithRSA "RSA-RIPEMD160" -#define LN_ripemd160WithRSA "ripemd160WithRSA" -#define NID_ripemd160WithRSA 119 -#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L - -#define SN_sxnet "SXNetID" -#define LN_sxnet "Strong Extranet ID" -#define NID_sxnet 143 -#define OBJ_sxnet 1L,3L,101L,1L,4L,1L - -#define SN_X500 "X500" -#define LN_X500 "directory services (X.500)" -#define NID_X500 11 -#define OBJ_X500 2L,5L - -#define SN_X509 "X509" -#define NID_X509 12 -#define OBJ_X509 OBJ_X500,4L - -#define SN_commonName "CN" -#define LN_commonName "commonName" -#define NID_commonName 13 -#define OBJ_commonName OBJ_X509,3L - -#define SN_surname "SN" -#define LN_surname "surname" -#define NID_surname 100 -#define OBJ_surname OBJ_X509,4L - -#define LN_serialNumber "serialNumber" -#define NID_serialNumber 105 -#define OBJ_serialNumber OBJ_X509,5L - -#define SN_countryName "C" -#define LN_countryName "countryName" -#define NID_countryName 14 -#define OBJ_countryName OBJ_X509,6L - -#define SN_localityName "L" -#define LN_localityName "localityName" -#define NID_localityName 15 -#define OBJ_localityName OBJ_X509,7L - -#define SN_stateOrProvinceName "ST" -#define LN_stateOrProvinceName "stateOrProvinceName" -#define NID_stateOrProvinceName 16 -#define OBJ_stateOrProvinceName OBJ_X509,8L - -#define LN_streetAddress "streetAddress" -#define NID_streetAddress 660 -#define OBJ_streetAddress OBJ_X509,9L - -#define SN_organizationName "O" -#define LN_organizationName "organizationName" -#define NID_organizationName 17 -#define OBJ_organizationName OBJ_X509,10L - -#define SN_organizationalUnitName "OU" -#define LN_organizationalUnitName "organizationalUnitName" -#define NID_organizationalUnitName 18 -#define OBJ_organizationalUnitName OBJ_X509,11L - -#define LN_title "title" -#define NID_title 106 -#define OBJ_title OBJ_X509,12L - -#define LN_description "description" -#define NID_description 107 -#define OBJ_description OBJ_X509,13L - -#define LN_postalCode "postalCode" -#define NID_postalCode 661 -#define OBJ_postalCode OBJ_X509,17L - -#define SN_name "name" -#define LN_name "name" -#define NID_name 173 -#define OBJ_name OBJ_X509,41L - -#define SN_givenName "GN" -#define LN_givenName "givenName" -#define NID_givenName 99 -#define OBJ_givenName OBJ_X509,42L - -#define LN_initials "initials" -#define NID_initials 101 -#define OBJ_initials OBJ_X509,43L - -#define LN_generationQualifier "generationQualifier" -#define NID_generationQualifier 509 -#define OBJ_generationQualifier OBJ_X509,44L - -#define LN_x500UniqueIdentifier "x500UniqueIdentifier" -#define NID_x500UniqueIdentifier 503 -#define OBJ_x500UniqueIdentifier OBJ_X509,45L - -#define SN_dnQualifier "dnQualifier" -#define LN_dnQualifier "dnQualifier" -#define NID_dnQualifier 174 -#define OBJ_dnQualifier OBJ_X509,46L - -#define LN_pseudonym "pseudonym" -#define NID_pseudonym 510 -#define OBJ_pseudonym OBJ_X509,65L - -#define SN_role "role" -#define LN_role "role" -#define NID_role 400 -#define OBJ_role OBJ_X509,72L - -#define SN_X500algorithms "X500algorithms" -#define LN_X500algorithms "directory services - algorithms" -#define NID_X500algorithms 378 -#define OBJ_X500algorithms OBJ_X500,8L - -#define SN_rsa "RSA" -#define LN_rsa "rsa" -#define NID_rsa 19 -#define OBJ_rsa OBJ_X500algorithms,1L,1L - -#define SN_mdc2WithRSA "RSA-MDC2" -#define LN_mdc2WithRSA "mdc2WithRSA" -#define NID_mdc2WithRSA 96 -#define OBJ_mdc2WithRSA OBJ_X500algorithms,3L,100L - -#define SN_mdc2 "MDC2" -#define LN_mdc2 "mdc2" -#define NID_mdc2 95 -#define OBJ_mdc2 OBJ_X500algorithms,3L,101L - -#define SN_id_ce "id-ce" -#define NID_id_ce 81 -#define OBJ_id_ce OBJ_X500,29L - -#define SN_subject_key_identifier "subjectKeyIdentifier" -#define LN_subject_key_identifier "X509v3 Subject Key Identifier" -#define NID_subject_key_identifier 82 -#define OBJ_subject_key_identifier OBJ_id_ce,14L - -#define SN_key_usage "keyUsage" -#define LN_key_usage "X509v3 Key Usage" -#define NID_key_usage 83 -#define OBJ_key_usage OBJ_id_ce,15L - -#define SN_private_key_usage_period "privateKeyUsagePeriod" -#define LN_private_key_usage_period "X509v3 Private Key Usage Period" -#define NID_private_key_usage_period 84 -#define OBJ_private_key_usage_period OBJ_id_ce,16L - -#define SN_subject_alt_name "subjectAltName" -#define LN_subject_alt_name "X509v3 Subject Alternative Name" -#define NID_subject_alt_name 85 -#define OBJ_subject_alt_name OBJ_id_ce,17L - -#define SN_issuer_alt_name "issuerAltName" -#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" -#define NID_issuer_alt_name 86 -#define OBJ_issuer_alt_name OBJ_id_ce,18L - -#define SN_basic_constraints "basicConstraints" -#define LN_basic_constraints "X509v3 Basic Constraints" -#define NID_basic_constraints 87 -#define OBJ_basic_constraints OBJ_id_ce,19L - -#define SN_crl_number "crlNumber" -#define LN_crl_number "X509v3 CRL Number" -#define NID_crl_number 88 -#define OBJ_crl_number OBJ_id_ce,20L - -#define SN_crl_reason "CRLReason" -#define LN_crl_reason "X509v3 CRL Reason Code" -#define NID_crl_reason 141 -#define OBJ_crl_reason OBJ_id_ce,21L - -#define SN_invalidity_date "invalidityDate" -#define LN_invalidity_date "Invalidity Date" -#define NID_invalidity_date 142 -#define OBJ_invalidity_date OBJ_id_ce,24L - -#define SN_delta_crl "deltaCRL" -#define LN_delta_crl "X509v3 Delta CRL Indicator" -#define NID_delta_crl 140 -#define OBJ_delta_crl OBJ_id_ce,27L - -#define SN_name_constraints "nameConstraints" -#define LN_name_constraints "X509v3 Name Constraints" -#define NID_name_constraints 666 -#define OBJ_name_constraints OBJ_id_ce,30L - -#define SN_crl_distribution_points "crlDistributionPoints" -#define LN_crl_distribution_points "X509v3 CRL Distribution Points" -#define NID_crl_distribution_points 103 -#define OBJ_crl_distribution_points OBJ_id_ce,31L - -#define SN_certificate_policies "certificatePolicies" -#define LN_certificate_policies "X509v3 Certificate Policies" -#define NID_certificate_policies 89 -#define OBJ_certificate_policies OBJ_id_ce,32L - -#define SN_any_policy "anyPolicy" -#define LN_any_policy "X509v3 Any Policy" -#define NID_any_policy 746 -#define OBJ_any_policy OBJ_certificate_policies,0L - -#define SN_policy_mappings "policyMappings" -#define LN_policy_mappings "X509v3 Policy Mappings" -#define NID_policy_mappings 747 -#define OBJ_policy_mappings OBJ_id_ce,33L - -#define SN_authority_key_identifier "authorityKeyIdentifier" -#define LN_authority_key_identifier "X509v3 Authority Key Identifier" -#define NID_authority_key_identifier 90 -#define OBJ_authority_key_identifier OBJ_id_ce,35L - -#define SN_policy_constraints "policyConstraints" -#define LN_policy_constraints "X509v3 Policy Constraints" -#define NID_policy_constraints 401 -#define OBJ_policy_constraints OBJ_id_ce,36L - -#define SN_ext_key_usage "extendedKeyUsage" -#define LN_ext_key_usage "X509v3 Extended Key Usage" -#define NID_ext_key_usage 126 -#define OBJ_ext_key_usage OBJ_id_ce,37L - -#define SN_inhibit_any_policy "inhibitAnyPolicy" -#define LN_inhibit_any_policy "X509v3 Inhibit Any Policy" -#define NID_inhibit_any_policy 748 -#define OBJ_inhibit_any_policy OBJ_id_ce,54L - -#define SN_target_information "targetInformation" -#define LN_target_information "X509v3 AC Targeting" -#define NID_target_information 402 -#define OBJ_target_information OBJ_id_ce,55L - -#define SN_no_rev_avail "noRevAvail" -#define LN_no_rev_avail "X509v3 No Revocation Available" -#define NID_no_rev_avail 403 -#define OBJ_no_rev_avail OBJ_id_ce,56L - -#define SN_netscape "Netscape" -#define LN_netscape "Netscape Communications Corp." -#define NID_netscape 57 -#define OBJ_netscape 2L,16L,840L,1L,113730L - -#define SN_netscape_cert_extension "nsCertExt" -#define LN_netscape_cert_extension "Netscape Certificate Extension" -#define NID_netscape_cert_extension 58 -#define OBJ_netscape_cert_extension OBJ_netscape,1L - -#define SN_netscape_data_type "nsDataType" -#define LN_netscape_data_type "Netscape Data Type" -#define NID_netscape_data_type 59 -#define OBJ_netscape_data_type OBJ_netscape,2L - -#define SN_netscape_cert_type "nsCertType" -#define LN_netscape_cert_type "Netscape Cert Type" -#define NID_netscape_cert_type 71 -#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L - -#define SN_netscape_base_url "nsBaseUrl" -#define LN_netscape_base_url "Netscape Base Url" -#define NID_netscape_base_url 72 -#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L - -#define SN_netscape_revocation_url "nsRevocationUrl" -#define LN_netscape_revocation_url "Netscape Revocation Url" -#define NID_netscape_revocation_url 73 -#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L - -#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" -#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" -#define NID_netscape_ca_revocation_url 74 -#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L - -#define SN_netscape_renewal_url "nsRenewalUrl" -#define LN_netscape_renewal_url "Netscape Renewal Url" -#define NID_netscape_renewal_url 75 -#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L - -#define SN_netscape_ca_policy_url "nsCaPolicyUrl" -#define LN_netscape_ca_policy_url "Netscape CA Policy Url" -#define NID_netscape_ca_policy_url 76 -#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L - -#define SN_netscape_ssl_server_name "nsSslServerName" -#define LN_netscape_ssl_server_name "Netscape SSL Server Name" -#define NID_netscape_ssl_server_name 77 -#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L - -#define SN_netscape_comment "nsComment" -#define LN_netscape_comment "Netscape Comment" -#define NID_netscape_comment 78 -#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L - -#define SN_netscape_cert_sequence "nsCertSequence" -#define LN_netscape_cert_sequence "Netscape Certificate Sequence" -#define NID_netscape_cert_sequence 79 -#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L - -#define SN_ns_sgc "nsSGC" -#define LN_ns_sgc "Netscape Server Gated Crypto" -#define NID_ns_sgc 139 -#define OBJ_ns_sgc OBJ_netscape,4L,1L - -#define SN_org "ORG" -#define LN_org "org" -#define NID_org 379 -#define OBJ_org OBJ_iso,3L - -#define SN_dod "DOD" -#define LN_dod "dod" -#define NID_dod 380 -#define OBJ_dod OBJ_org,6L - -#define SN_iana "IANA" -#define LN_iana "iana" -#define NID_iana 381 -#define OBJ_iana OBJ_dod,1L - -#define OBJ_internet OBJ_iana - -#define SN_Directory "directory" -#define LN_Directory "Directory" -#define NID_Directory 382 -#define OBJ_Directory OBJ_internet,1L - -#define SN_Management "mgmt" -#define LN_Management "Management" -#define NID_Management 383 -#define OBJ_Management OBJ_internet,2L - -#define SN_Experimental "experimental" -#define LN_Experimental "Experimental" -#define NID_Experimental 384 -#define OBJ_Experimental OBJ_internet,3L - -#define SN_Private "private" -#define LN_Private "Private" -#define NID_Private 385 -#define OBJ_Private OBJ_internet,4L - -#define SN_Security "security" -#define LN_Security "Security" -#define NID_Security 386 -#define OBJ_Security OBJ_internet,5L - -#define SN_SNMPv2 "snmpv2" -#define LN_SNMPv2 "SNMPv2" -#define NID_SNMPv2 387 -#define OBJ_SNMPv2 OBJ_internet,6L - -#define LN_Mail "Mail" -#define NID_Mail 388 -#define OBJ_Mail OBJ_internet,7L - -#define SN_Enterprises "enterprises" -#define LN_Enterprises "Enterprises" -#define NID_Enterprises 389 -#define OBJ_Enterprises OBJ_Private,1L - -#define SN_dcObject "dcobject" -#define LN_dcObject "dcObject" -#define NID_dcObject 390 -#define OBJ_dcObject OBJ_Enterprises,1466L,344L - -#define SN_mime_mhs "mime-mhs" -#define LN_mime_mhs "MIME MHS" -#define NID_mime_mhs 504 -#define OBJ_mime_mhs OBJ_Mail,1L - -#define SN_mime_mhs_headings "mime-mhs-headings" -#define LN_mime_mhs_headings "mime-mhs-headings" -#define NID_mime_mhs_headings 505 -#define OBJ_mime_mhs_headings OBJ_mime_mhs,1L - -#define SN_mime_mhs_bodies "mime-mhs-bodies" -#define LN_mime_mhs_bodies "mime-mhs-bodies" -#define NID_mime_mhs_bodies 506 -#define OBJ_mime_mhs_bodies OBJ_mime_mhs,2L - -#define SN_id_hex_partial_message "id-hex-partial-message" -#define LN_id_hex_partial_message "id-hex-partial-message" -#define NID_id_hex_partial_message 507 -#define OBJ_id_hex_partial_message OBJ_mime_mhs_headings,1L - -#define SN_id_hex_multipart_message "id-hex-multipart-message" -#define LN_id_hex_multipart_message "id-hex-multipart-message" -#define NID_id_hex_multipart_message 508 -#define OBJ_id_hex_multipart_message OBJ_mime_mhs_headings,2L - -#define SN_rle_compression "RLE" -#define LN_rle_compression "run length compression" -#define NID_rle_compression 124 -#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L - -#define SN_zlib_compression "ZLIB" -#define LN_zlib_compression "zlib compression" -#define NID_zlib_compression 125 -#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L - -#define OBJ_csor 2L,16L,840L,1L,101L,3L - -#define OBJ_nistAlgorithms OBJ_csor,4L - -#define OBJ_aes OBJ_nistAlgorithms,1L - -#define SN_aes_128_ecb "AES-128-ECB" -#define LN_aes_128_ecb "aes-128-ecb" -#define NID_aes_128_ecb 418 -#define OBJ_aes_128_ecb OBJ_aes,1L - -#define SN_aes_128_cbc "AES-128-CBC" -#define LN_aes_128_cbc "aes-128-cbc" -#define NID_aes_128_cbc 419 -#define OBJ_aes_128_cbc OBJ_aes,2L - -#define SN_aes_128_ofb128 "AES-128-OFB" -#define LN_aes_128_ofb128 "aes-128-ofb" -#define NID_aes_128_ofb128 420 -#define OBJ_aes_128_ofb128 OBJ_aes,3L - -#define SN_aes_128_cfb128 "AES-128-CFB" -#define LN_aes_128_cfb128 "aes-128-cfb" -#define NID_aes_128_cfb128 421 -#define OBJ_aes_128_cfb128 OBJ_aes,4L - -#define SN_aes_192_ecb "AES-192-ECB" -#define LN_aes_192_ecb "aes-192-ecb" -#define NID_aes_192_ecb 422 -#define OBJ_aes_192_ecb OBJ_aes,21L - -#define SN_aes_192_cbc "AES-192-CBC" -#define LN_aes_192_cbc "aes-192-cbc" -#define NID_aes_192_cbc 423 -#define OBJ_aes_192_cbc OBJ_aes,22L - -#define SN_aes_192_ofb128 "AES-192-OFB" -#define LN_aes_192_ofb128 "aes-192-ofb" -#define NID_aes_192_ofb128 424 -#define OBJ_aes_192_ofb128 OBJ_aes,23L - -#define SN_aes_192_cfb128 "AES-192-CFB" -#define LN_aes_192_cfb128 "aes-192-cfb" -#define NID_aes_192_cfb128 425 -#define OBJ_aes_192_cfb128 OBJ_aes,24L - -#define SN_aes_256_ecb "AES-256-ECB" -#define LN_aes_256_ecb "aes-256-ecb" -#define NID_aes_256_ecb 426 -#define OBJ_aes_256_ecb OBJ_aes,41L - -#define SN_aes_256_cbc "AES-256-CBC" -#define LN_aes_256_cbc "aes-256-cbc" -#define NID_aes_256_cbc 427 -#define OBJ_aes_256_cbc OBJ_aes,42L - -#define SN_aes_256_ofb128 "AES-256-OFB" -#define LN_aes_256_ofb128 "aes-256-ofb" -#define NID_aes_256_ofb128 428 -#define OBJ_aes_256_ofb128 OBJ_aes,43L - -#define SN_aes_256_cfb128 "AES-256-CFB" -#define LN_aes_256_cfb128 "aes-256-cfb" -#define NID_aes_256_cfb128 429 -#define OBJ_aes_256_cfb128 OBJ_aes,44L - -#define SN_aes_128_cfb1 "AES-128-CFB1" -#define LN_aes_128_cfb1 "aes-128-cfb1" -#define NID_aes_128_cfb1 650 - -#define SN_aes_192_cfb1 "AES-192-CFB1" -#define LN_aes_192_cfb1 "aes-192-cfb1" -#define NID_aes_192_cfb1 651 - -#define SN_aes_256_cfb1 "AES-256-CFB1" -#define LN_aes_256_cfb1 "aes-256-cfb1" -#define NID_aes_256_cfb1 652 - -#define SN_aes_128_cfb8 "AES-128-CFB8" -#define LN_aes_128_cfb8 "aes-128-cfb8" -#define NID_aes_128_cfb8 653 - -#define SN_aes_192_cfb8 "AES-192-CFB8" -#define LN_aes_192_cfb8 "aes-192-cfb8" -#define NID_aes_192_cfb8 654 - -#define SN_aes_256_cfb8 "AES-256-CFB8" -#define LN_aes_256_cfb8 "aes-256-cfb8" -#define NID_aes_256_cfb8 655 - -#define SN_des_cfb1 "DES-CFB1" -#define LN_des_cfb1 "des-cfb1" -#define NID_des_cfb1 656 - -#define SN_des_cfb8 "DES-CFB8" -#define LN_des_cfb8 "des-cfb8" -#define NID_des_cfb8 657 - -#define SN_des_ede3_cfb1 "DES-EDE3-CFB1" -#define LN_des_ede3_cfb1 "des-ede3-cfb1" -#define NID_des_ede3_cfb1 658 - -#define SN_des_ede3_cfb8 "DES-EDE3-CFB8" -#define LN_des_ede3_cfb8 "des-ede3-cfb8" -#define NID_des_ede3_cfb8 659 - -#define OBJ_nist_hashalgs OBJ_nistAlgorithms,2L - -#define SN_sha256 "SHA256" -#define LN_sha256 "sha256" -#define NID_sha256 672 -#define OBJ_sha256 OBJ_nist_hashalgs,1L - -#define SN_sha384 "SHA384" -#define LN_sha384 "sha384" -#define NID_sha384 673 -#define OBJ_sha384 OBJ_nist_hashalgs,2L - -#define SN_sha512 "SHA512" -#define LN_sha512 "sha512" -#define NID_sha512 674 -#define OBJ_sha512 OBJ_nist_hashalgs,3L - -#define SN_sha224 "SHA224" -#define LN_sha224 "sha224" -#define NID_sha224 675 -#define OBJ_sha224 OBJ_nist_hashalgs,4L - -#define SN_hold_instruction_code "holdInstructionCode" -#define LN_hold_instruction_code "Hold Instruction Code" -#define NID_hold_instruction_code 430 -#define OBJ_hold_instruction_code OBJ_id_ce,23L - -#define OBJ_holdInstruction OBJ_X9_57,2L - -#define SN_hold_instruction_none "holdInstructionNone" -#define LN_hold_instruction_none "Hold Instruction None" -#define NID_hold_instruction_none 431 -#define OBJ_hold_instruction_none OBJ_holdInstruction,1L - -#define SN_hold_instruction_call_issuer "holdInstructionCallIssuer" -#define LN_hold_instruction_call_issuer "Hold Instruction Call Issuer" -#define NID_hold_instruction_call_issuer 432 -#define OBJ_hold_instruction_call_issuer OBJ_holdInstruction,2L - -#define SN_hold_instruction_reject "holdInstructionReject" -#define LN_hold_instruction_reject "Hold Instruction Reject" -#define NID_hold_instruction_reject 433 -#define OBJ_hold_instruction_reject OBJ_holdInstruction,3L - -#define SN_data "data" -#define NID_data 434 -#define OBJ_data OBJ_itu_t,9L - -#define SN_pss "pss" -#define NID_pss 435 -#define OBJ_pss OBJ_data,2342L - -#define SN_ucl "ucl" -#define NID_ucl 436 -#define OBJ_ucl OBJ_pss,19200300L - -#define SN_pilot "pilot" -#define NID_pilot 437 -#define OBJ_pilot OBJ_ucl,100L - -#define LN_pilotAttributeType "pilotAttributeType" -#define NID_pilotAttributeType 438 -#define OBJ_pilotAttributeType OBJ_pilot,1L - -#define LN_pilotAttributeSyntax "pilotAttributeSyntax" -#define NID_pilotAttributeSyntax 439 -#define OBJ_pilotAttributeSyntax OBJ_pilot,3L - -#define LN_pilotObjectClass "pilotObjectClass" -#define NID_pilotObjectClass 440 -#define OBJ_pilotObjectClass OBJ_pilot,4L - -#define LN_pilotGroups "pilotGroups" -#define NID_pilotGroups 441 -#define OBJ_pilotGroups OBJ_pilot,10L - -#define LN_iA5StringSyntax "iA5StringSyntax" -#define NID_iA5StringSyntax 442 -#define OBJ_iA5StringSyntax OBJ_pilotAttributeSyntax,4L - -#define LN_caseIgnoreIA5StringSyntax "caseIgnoreIA5StringSyntax" -#define NID_caseIgnoreIA5StringSyntax 443 -#define OBJ_caseIgnoreIA5StringSyntax OBJ_pilotAttributeSyntax,5L - -#define LN_pilotObject "pilotObject" -#define NID_pilotObject 444 -#define OBJ_pilotObject OBJ_pilotObjectClass,3L - -#define LN_pilotPerson "pilotPerson" -#define NID_pilotPerson 445 -#define OBJ_pilotPerson OBJ_pilotObjectClass,4L - -#define SN_account "account" -#define NID_account 446 -#define OBJ_account OBJ_pilotObjectClass,5L - -#define SN_document "document" -#define NID_document 447 -#define OBJ_document OBJ_pilotObjectClass,6L - -#define SN_room "room" -#define NID_room 448 -#define OBJ_room OBJ_pilotObjectClass,7L - -#define LN_documentSeries "documentSeries" -#define NID_documentSeries 449 -#define OBJ_documentSeries OBJ_pilotObjectClass,9L - -#define SN_Domain "domain" -#define LN_Domain "Domain" -#define NID_Domain 392 -#define OBJ_Domain OBJ_pilotObjectClass,13L - -#define LN_rFC822localPart "rFC822localPart" -#define NID_rFC822localPart 450 -#define OBJ_rFC822localPart OBJ_pilotObjectClass,14L - -#define LN_dNSDomain "dNSDomain" -#define NID_dNSDomain 451 -#define OBJ_dNSDomain OBJ_pilotObjectClass,15L - -#define LN_domainRelatedObject "domainRelatedObject" -#define NID_domainRelatedObject 452 -#define OBJ_domainRelatedObject OBJ_pilotObjectClass,17L - -#define LN_friendlyCountry "friendlyCountry" -#define NID_friendlyCountry 453 -#define OBJ_friendlyCountry OBJ_pilotObjectClass,18L - -#define LN_simpleSecurityObject "simpleSecurityObject" -#define NID_simpleSecurityObject 454 -#define OBJ_simpleSecurityObject OBJ_pilotObjectClass,19L - -#define LN_pilotOrganization "pilotOrganization" -#define NID_pilotOrganization 455 -#define OBJ_pilotOrganization OBJ_pilotObjectClass,20L - -#define LN_pilotDSA "pilotDSA" -#define NID_pilotDSA 456 -#define OBJ_pilotDSA OBJ_pilotObjectClass,21L - -#define LN_qualityLabelledData "qualityLabelledData" -#define NID_qualityLabelledData 457 -#define OBJ_qualityLabelledData OBJ_pilotObjectClass,22L - -#define SN_userId "UID" -#define LN_userId "userId" -#define NID_userId 458 -#define OBJ_userId OBJ_pilotAttributeType,1L - -#define LN_textEncodedORAddress "textEncodedORAddress" -#define NID_textEncodedORAddress 459 -#define OBJ_textEncodedORAddress OBJ_pilotAttributeType,2L - -#define SN_rfc822Mailbox "mail" -#define LN_rfc822Mailbox "rfc822Mailbox" -#define NID_rfc822Mailbox 460 -#define OBJ_rfc822Mailbox OBJ_pilotAttributeType,3L - -#define SN_info "info" -#define NID_info 461 -#define OBJ_info OBJ_pilotAttributeType,4L - -#define LN_favouriteDrink "favouriteDrink" -#define NID_favouriteDrink 462 -#define OBJ_favouriteDrink OBJ_pilotAttributeType,5L - -#define LN_roomNumber "roomNumber" -#define NID_roomNumber 463 -#define OBJ_roomNumber OBJ_pilotAttributeType,6L - -#define SN_photo "photo" -#define NID_photo 464 -#define OBJ_photo OBJ_pilotAttributeType,7L - -#define LN_userClass "userClass" -#define NID_userClass 465 -#define OBJ_userClass OBJ_pilotAttributeType,8L - -#define SN_host "host" -#define NID_host 466 -#define OBJ_host OBJ_pilotAttributeType,9L - -#define SN_manager "manager" -#define NID_manager 467 -#define OBJ_manager OBJ_pilotAttributeType,10L - -#define LN_documentIdentifier "documentIdentifier" -#define NID_documentIdentifier 468 -#define OBJ_documentIdentifier OBJ_pilotAttributeType,11L - -#define LN_documentTitle "documentTitle" -#define NID_documentTitle 469 -#define OBJ_documentTitle OBJ_pilotAttributeType,12L - -#define LN_documentVersion "documentVersion" -#define NID_documentVersion 470 -#define OBJ_documentVersion OBJ_pilotAttributeType,13L - -#define LN_documentAuthor "documentAuthor" -#define NID_documentAuthor 471 -#define OBJ_documentAuthor OBJ_pilotAttributeType,14L - -#define LN_documentLocation "documentLocation" -#define NID_documentLocation 472 -#define OBJ_documentLocation OBJ_pilotAttributeType,15L - -#define LN_homeTelephoneNumber "homeTelephoneNumber" -#define NID_homeTelephoneNumber 473 -#define OBJ_homeTelephoneNumber OBJ_pilotAttributeType,20L - -#define SN_secretary "secretary" -#define NID_secretary 474 -#define OBJ_secretary OBJ_pilotAttributeType,21L - -#define LN_otherMailbox "otherMailbox" -#define NID_otherMailbox 475 -#define OBJ_otherMailbox OBJ_pilotAttributeType,22L - -#define LN_lastModifiedTime "lastModifiedTime" -#define NID_lastModifiedTime 476 -#define OBJ_lastModifiedTime OBJ_pilotAttributeType,23L - -#define LN_lastModifiedBy "lastModifiedBy" -#define NID_lastModifiedBy 477 -#define OBJ_lastModifiedBy OBJ_pilotAttributeType,24L - -#define SN_domainComponent "DC" -#define LN_domainComponent "domainComponent" -#define NID_domainComponent 391 -#define OBJ_domainComponent OBJ_pilotAttributeType,25L - -#define LN_aRecord "aRecord" -#define NID_aRecord 478 -#define OBJ_aRecord OBJ_pilotAttributeType,26L - -#define LN_pilotAttributeType27 "pilotAttributeType27" -#define NID_pilotAttributeType27 479 -#define OBJ_pilotAttributeType27 OBJ_pilotAttributeType,27L - -#define LN_mXRecord "mXRecord" -#define NID_mXRecord 480 -#define OBJ_mXRecord OBJ_pilotAttributeType,28L - -#define LN_nSRecord "nSRecord" -#define NID_nSRecord 481 -#define OBJ_nSRecord OBJ_pilotAttributeType,29L - -#define LN_sOARecord "sOARecord" -#define NID_sOARecord 482 -#define OBJ_sOARecord OBJ_pilotAttributeType,30L - -#define LN_cNAMERecord "cNAMERecord" -#define NID_cNAMERecord 483 -#define OBJ_cNAMERecord OBJ_pilotAttributeType,31L - -#define LN_associatedDomain "associatedDomain" -#define NID_associatedDomain 484 -#define OBJ_associatedDomain OBJ_pilotAttributeType,37L - -#define LN_associatedName "associatedName" -#define NID_associatedName 485 -#define OBJ_associatedName OBJ_pilotAttributeType,38L - -#define LN_homePostalAddress "homePostalAddress" -#define NID_homePostalAddress 486 -#define OBJ_homePostalAddress OBJ_pilotAttributeType,39L - -#define LN_personalTitle "personalTitle" -#define NID_personalTitle 487 -#define OBJ_personalTitle OBJ_pilotAttributeType,40L - -#define LN_mobileTelephoneNumber "mobileTelephoneNumber" -#define NID_mobileTelephoneNumber 488 -#define OBJ_mobileTelephoneNumber OBJ_pilotAttributeType,41L - -#define LN_pagerTelephoneNumber "pagerTelephoneNumber" -#define NID_pagerTelephoneNumber 489 -#define OBJ_pagerTelephoneNumber OBJ_pilotAttributeType,42L - -#define LN_friendlyCountryName "friendlyCountryName" -#define NID_friendlyCountryName 490 -#define OBJ_friendlyCountryName OBJ_pilotAttributeType,43L - -#define LN_organizationalStatus "organizationalStatus" -#define NID_organizationalStatus 491 -#define OBJ_organizationalStatus OBJ_pilotAttributeType,45L - -#define LN_janetMailbox "janetMailbox" -#define NID_janetMailbox 492 -#define OBJ_janetMailbox OBJ_pilotAttributeType,46L - -#define LN_mailPreferenceOption "mailPreferenceOption" -#define NID_mailPreferenceOption 493 -#define OBJ_mailPreferenceOption OBJ_pilotAttributeType,47L - -#define LN_buildingName "buildingName" -#define NID_buildingName 494 -#define OBJ_buildingName OBJ_pilotAttributeType,48L - -#define LN_dSAQuality "dSAQuality" -#define NID_dSAQuality 495 -#define OBJ_dSAQuality OBJ_pilotAttributeType,49L - -#define LN_singleLevelQuality "singleLevelQuality" -#define NID_singleLevelQuality 496 -#define OBJ_singleLevelQuality OBJ_pilotAttributeType,50L - -#define LN_subtreeMinimumQuality "subtreeMinimumQuality" -#define NID_subtreeMinimumQuality 497 -#define OBJ_subtreeMinimumQuality OBJ_pilotAttributeType,51L - -#define LN_subtreeMaximumQuality "subtreeMaximumQuality" -#define NID_subtreeMaximumQuality 498 -#define OBJ_subtreeMaximumQuality OBJ_pilotAttributeType,52L - -#define LN_personalSignature "personalSignature" -#define NID_personalSignature 499 -#define OBJ_personalSignature OBJ_pilotAttributeType,53L - -#define LN_dITRedirect "dITRedirect" -#define NID_dITRedirect 500 -#define OBJ_dITRedirect OBJ_pilotAttributeType,54L - -#define SN_audio "audio" -#define NID_audio 501 -#define OBJ_audio OBJ_pilotAttributeType,55L - -#define LN_documentPublisher "documentPublisher" -#define NID_documentPublisher 502 -#define OBJ_documentPublisher OBJ_pilotAttributeType,56L - -#define SN_id_set "id-set" -#define LN_id_set "Secure Electronic Transactions" -#define NID_id_set 512 -#define OBJ_id_set OBJ_international_organizations,42L - -#define SN_set_ctype "set-ctype" -#define LN_set_ctype "content types" -#define NID_set_ctype 513 -#define OBJ_set_ctype OBJ_id_set,0L - -#define SN_set_msgExt "set-msgExt" -#define LN_set_msgExt "message extensions" -#define NID_set_msgExt 514 -#define OBJ_set_msgExt OBJ_id_set,1L - -#define SN_set_attr "set-attr" -#define NID_set_attr 515 -#define OBJ_set_attr OBJ_id_set,3L - -#define SN_set_policy "set-policy" -#define NID_set_policy 516 -#define OBJ_set_policy OBJ_id_set,5L - -#define SN_set_certExt "set-certExt" -#define LN_set_certExt "certificate extensions" -#define NID_set_certExt 517 -#define OBJ_set_certExt OBJ_id_set,7L - -#define SN_set_brand "set-brand" -#define NID_set_brand 518 -#define OBJ_set_brand OBJ_id_set,8L - -#define SN_setct_PANData "setct-PANData" -#define NID_setct_PANData 519 -#define OBJ_setct_PANData OBJ_set_ctype,0L - -#define SN_setct_PANToken "setct-PANToken" -#define NID_setct_PANToken 520 -#define OBJ_setct_PANToken OBJ_set_ctype,1L - -#define SN_setct_PANOnly "setct-PANOnly" -#define NID_setct_PANOnly 521 -#define OBJ_setct_PANOnly OBJ_set_ctype,2L - -#define SN_setct_OIData "setct-OIData" -#define NID_setct_OIData 522 -#define OBJ_setct_OIData OBJ_set_ctype,3L - -#define SN_setct_PI "setct-PI" -#define NID_setct_PI 523 -#define OBJ_setct_PI OBJ_set_ctype,4L - -#define SN_setct_PIData "setct-PIData" -#define NID_setct_PIData 524 -#define OBJ_setct_PIData OBJ_set_ctype,5L - -#define SN_setct_PIDataUnsigned "setct-PIDataUnsigned" -#define NID_setct_PIDataUnsigned 525 -#define OBJ_setct_PIDataUnsigned OBJ_set_ctype,6L - -#define SN_setct_HODInput "setct-HODInput" -#define NID_setct_HODInput 526 -#define OBJ_setct_HODInput OBJ_set_ctype,7L - -#define SN_setct_AuthResBaggage "setct-AuthResBaggage" -#define NID_setct_AuthResBaggage 527 -#define OBJ_setct_AuthResBaggage OBJ_set_ctype,8L - -#define SN_setct_AuthRevReqBaggage "setct-AuthRevReqBaggage" -#define NID_setct_AuthRevReqBaggage 528 -#define OBJ_setct_AuthRevReqBaggage OBJ_set_ctype,9L - -#define SN_setct_AuthRevResBaggage "setct-AuthRevResBaggage" -#define NID_setct_AuthRevResBaggage 529 -#define OBJ_setct_AuthRevResBaggage OBJ_set_ctype,10L - -#define SN_setct_CapTokenSeq "setct-CapTokenSeq" -#define NID_setct_CapTokenSeq 530 -#define OBJ_setct_CapTokenSeq OBJ_set_ctype,11L - -#define SN_setct_PInitResData "setct-PInitResData" -#define NID_setct_PInitResData 531 -#define OBJ_setct_PInitResData OBJ_set_ctype,12L - -#define SN_setct_PI_TBS "setct-PI-TBS" -#define NID_setct_PI_TBS 532 -#define OBJ_setct_PI_TBS OBJ_set_ctype,13L - -#define SN_setct_PResData "setct-PResData" -#define NID_setct_PResData 533 -#define OBJ_setct_PResData OBJ_set_ctype,14L - -#define SN_setct_AuthReqTBS "setct-AuthReqTBS" -#define NID_setct_AuthReqTBS 534 -#define OBJ_setct_AuthReqTBS OBJ_set_ctype,16L - -#define SN_setct_AuthResTBS "setct-AuthResTBS" -#define NID_setct_AuthResTBS 535 -#define OBJ_setct_AuthResTBS OBJ_set_ctype,17L - -#define SN_setct_AuthResTBSX "setct-AuthResTBSX" -#define NID_setct_AuthResTBSX 536 -#define OBJ_setct_AuthResTBSX OBJ_set_ctype,18L - -#define SN_setct_AuthTokenTBS "setct-AuthTokenTBS" -#define NID_setct_AuthTokenTBS 537 -#define OBJ_setct_AuthTokenTBS OBJ_set_ctype,19L - -#define SN_setct_CapTokenData "setct-CapTokenData" -#define NID_setct_CapTokenData 538 -#define OBJ_setct_CapTokenData OBJ_set_ctype,20L - -#define SN_setct_CapTokenTBS "setct-CapTokenTBS" -#define NID_setct_CapTokenTBS 539 -#define OBJ_setct_CapTokenTBS OBJ_set_ctype,21L - -#define SN_setct_AcqCardCodeMsg "setct-AcqCardCodeMsg" -#define NID_setct_AcqCardCodeMsg 540 -#define OBJ_setct_AcqCardCodeMsg OBJ_set_ctype,22L - -#define SN_setct_AuthRevReqTBS "setct-AuthRevReqTBS" -#define NID_setct_AuthRevReqTBS 541 -#define OBJ_setct_AuthRevReqTBS OBJ_set_ctype,23L - -#define SN_setct_AuthRevResData "setct-AuthRevResData" -#define NID_setct_AuthRevResData 542 -#define OBJ_setct_AuthRevResData OBJ_set_ctype,24L - -#define SN_setct_AuthRevResTBS "setct-AuthRevResTBS" -#define NID_setct_AuthRevResTBS 543 -#define OBJ_setct_AuthRevResTBS OBJ_set_ctype,25L - -#define SN_setct_CapReqTBS "setct-CapReqTBS" -#define NID_setct_CapReqTBS 544 -#define OBJ_setct_CapReqTBS OBJ_set_ctype,26L - -#define SN_setct_CapReqTBSX "setct-CapReqTBSX" -#define NID_setct_CapReqTBSX 545 -#define OBJ_setct_CapReqTBSX OBJ_set_ctype,27L - -#define SN_setct_CapResData "setct-CapResData" -#define NID_setct_CapResData 546 -#define OBJ_setct_CapResData OBJ_set_ctype,28L - -#define SN_setct_CapRevReqTBS "setct-CapRevReqTBS" -#define NID_setct_CapRevReqTBS 547 -#define OBJ_setct_CapRevReqTBS OBJ_set_ctype,29L - -#define SN_setct_CapRevReqTBSX "setct-CapRevReqTBSX" -#define NID_setct_CapRevReqTBSX 548 -#define OBJ_setct_CapRevReqTBSX OBJ_set_ctype,30L - -#define SN_setct_CapRevResData "setct-CapRevResData" -#define NID_setct_CapRevResData 549 -#define OBJ_setct_CapRevResData OBJ_set_ctype,31L - -#define SN_setct_CredReqTBS "setct-CredReqTBS" -#define NID_setct_CredReqTBS 550 -#define OBJ_setct_CredReqTBS OBJ_set_ctype,32L - -#define SN_setct_CredReqTBSX "setct-CredReqTBSX" -#define NID_setct_CredReqTBSX 551 -#define OBJ_setct_CredReqTBSX OBJ_set_ctype,33L - -#define SN_setct_CredResData "setct-CredResData" -#define NID_setct_CredResData 552 -#define OBJ_setct_CredResData OBJ_set_ctype,34L - -#define SN_setct_CredRevReqTBS "setct-CredRevReqTBS" -#define NID_setct_CredRevReqTBS 553 -#define OBJ_setct_CredRevReqTBS OBJ_set_ctype,35L - -#define SN_setct_CredRevReqTBSX "setct-CredRevReqTBSX" -#define NID_setct_CredRevReqTBSX 554 -#define OBJ_setct_CredRevReqTBSX OBJ_set_ctype,36L - -#define SN_setct_CredRevResData "setct-CredRevResData" -#define NID_setct_CredRevResData 555 -#define OBJ_setct_CredRevResData OBJ_set_ctype,37L - -#define SN_setct_PCertReqData "setct-PCertReqData" -#define NID_setct_PCertReqData 556 -#define OBJ_setct_PCertReqData OBJ_set_ctype,38L - -#define SN_setct_PCertResTBS "setct-PCertResTBS" -#define NID_setct_PCertResTBS 557 -#define OBJ_setct_PCertResTBS OBJ_set_ctype,39L - -#define SN_setct_BatchAdminReqData "setct-BatchAdminReqData" -#define NID_setct_BatchAdminReqData 558 -#define OBJ_setct_BatchAdminReqData OBJ_set_ctype,40L - -#define SN_setct_BatchAdminResData "setct-BatchAdminResData" -#define NID_setct_BatchAdminResData 559 -#define OBJ_setct_BatchAdminResData OBJ_set_ctype,41L - -#define SN_setct_CardCInitResTBS "setct-CardCInitResTBS" -#define NID_setct_CardCInitResTBS 560 -#define OBJ_setct_CardCInitResTBS OBJ_set_ctype,42L - -#define SN_setct_MeAqCInitResTBS "setct-MeAqCInitResTBS" -#define NID_setct_MeAqCInitResTBS 561 -#define OBJ_setct_MeAqCInitResTBS OBJ_set_ctype,43L - -#define SN_setct_RegFormResTBS "setct-RegFormResTBS" -#define NID_setct_RegFormResTBS 562 -#define OBJ_setct_RegFormResTBS OBJ_set_ctype,44L - -#define SN_setct_CertReqData "setct-CertReqData" -#define NID_setct_CertReqData 563 -#define OBJ_setct_CertReqData OBJ_set_ctype,45L - -#define SN_setct_CertReqTBS "setct-CertReqTBS" -#define NID_setct_CertReqTBS 564 -#define OBJ_setct_CertReqTBS OBJ_set_ctype,46L - -#define SN_setct_CertResData "setct-CertResData" -#define NID_setct_CertResData 565 -#define OBJ_setct_CertResData OBJ_set_ctype,47L - -#define SN_setct_CertInqReqTBS "setct-CertInqReqTBS" -#define NID_setct_CertInqReqTBS 566 -#define OBJ_setct_CertInqReqTBS OBJ_set_ctype,48L - -#define SN_setct_ErrorTBS "setct-ErrorTBS" -#define NID_setct_ErrorTBS 567 -#define OBJ_setct_ErrorTBS OBJ_set_ctype,49L - -#define SN_setct_PIDualSignedTBE "setct-PIDualSignedTBE" -#define NID_setct_PIDualSignedTBE 568 -#define OBJ_setct_PIDualSignedTBE OBJ_set_ctype,50L - -#define SN_setct_PIUnsignedTBE "setct-PIUnsignedTBE" -#define NID_setct_PIUnsignedTBE 569 -#define OBJ_setct_PIUnsignedTBE OBJ_set_ctype,51L - -#define SN_setct_AuthReqTBE "setct-AuthReqTBE" -#define NID_setct_AuthReqTBE 570 -#define OBJ_setct_AuthReqTBE OBJ_set_ctype,52L - -#define SN_setct_AuthResTBE "setct-AuthResTBE" -#define NID_setct_AuthResTBE 571 -#define OBJ_setct_AuthResTBE OBJ_set_ctype,53L - -#define SN_setct_AuthResTBEX "setct-AuthResTBEX" -#define NID_setct_AuthResTBEX 572 -#define OBJ_setct_AuthResTBEX OBJ_set_ctype,54L - -#define SN_setct_AuthTokenTBE "setct-AuthTokenTBE" -#define NID_setct_AuthTokenTBE 573 -#define OBJ_setct_AuthTokenTBE OBJ_set_ctype,55L - -#define SN_setct_CapTokenTBE "setct-CapTokenTBE" -#define NID_setct_CapTokenTBE 574 -#define OBJ_setct_CapTokenTBE OBJ_set_ctype,56L - -#define SN_setct_CapTokenTBEX "setct-CapTokenTBEX" -#define NID_setct_CapTokenTBEX 575 -#define OBJ_setct_CapTokenTBEX OBJ_set_ctype,57L - -#define SN_setct_AcqCardCodeMsgTBE "setct-AcqCardCodeMsgTBE" -#define NID_setct_AcqCardCodeMsgTBE 576 -#define OBJ_setct_AcqCardCodeMsgTBE OBJ_set_ctype,58L - -#define SN_setct_AuthRevReqTBE "setct-AuthRevReqTBE" -#define NID_setct_AuthRevReqTBE 577 -#define OBJ_setct_AuthRevReqTBE OBJ_set_ctype,59L - -#define SN_setct_AuthRevResTBE "setct-AuthRevResTBE" -#define NID_setct_AuthRevResTBE 578 -#define OBJ_setct_AuthRevResTBE OBJ_set_ctype,60L - -#define SN_setct_AuthRevResTBEB "setct-AuthRevResTBEB" -#define NID_setct_AuthRevResTBEB 579 -#define OBJ_setct_AuthRevResTBEB OBJ_set_ctype,61L - -#define SN_setct_CapReqTBE "setct-CapReqTBE" -#define NID_setct_CapReqTBE 580 -#define OBJ_setct_CapReqTBE OBJ_set_ctype,62L - -#define SN_setct_CapReqTBEX "setct-CapReqTBEX" -#define NID_setct_CapReqTBEX 581 -#define OBJ_setct_CapReqTBEX OBJ_set_ctype,63L - -#define SN_setct_CapResTBE "setct-CapResTBE" -#define NID_setct_CapResTBE 582 -#define OBJ_setct_CapResTBE OBJ_set_ctype,64L - -#define SN_setct_CapRevReqTBE "setct-CapRevReqTBE" -#define NID_setct_CapRevReqTBE 583 -#define OBJ_setct_CapRevReqTBE OBJ_set_ctype,65L - -#define SN_setct_CapRevReqTBEX "setct-CapRevReqTBEX" -#define NID_setct_CapRevReqTBEX 584 -#define OBJ_setct_CapRevReqTBEX OBJ_set_ctype,66L - -#define SN_setct_CapRevResTBE "setct-CapRevResTBE" -#define NID_setct_CapRevResTBE 585 -#define OBJ_setct_CapRevResTBE OBJ_set_ctype,67L - -#define SN_setct_CredReqTBE "setct-CredReqTBE" -#define NID_setct_CredReqTBE 586 -#define OBJ_setct_CredReqTBE OBJ_set_ctype,68L - -#define SN_setct_CredReqTBEX "setct-CredReqTBEX" -#define NID_setct_CredReqTBEX 587 -#define OBJ_setct_CredReqTBEX OBJ_set_ctype,69L - -#define SN_setct_CredResTBE "setct-CredResTBE" -#define NID_setct_CredResTBE 588 -#define OBJ_setct_CredResTBE OBJ_set_ctype,70L - -#define SN_setct_CredRevReqTBE "setct-CredRevReqTBE" -#define NID_setct_CredRevReqTBE 589 -#define OBJ_setct_CredRevReqTBE OBJ_set_ctype,71L - -#define SN_setct_CredRevReqTBEX "setct-CredRevReqTBEX" -#define NID_setct_CredRevReqTBEX 590 -#define OBJ_setct_CredRevReqTBEX OBJ_set_ctype,72L - -#define SN_setct_CredRevResTBE "setct-CredRevResTBE" -#define NID_setct_CredRevResTBE 591 -#define OBJ_setct_CredRevResTBE OBJ_set_ctype,73L - -#define SN_setct_BatchAdminReqTBE "setct-BatchAdminReqTBE" -#define NID_setct_BatchAdminReqTBE 592 -#define OBJ_setct_BatchAdminReqTBE OBJ_set_ctype,74L - -#define SN_setct_BatchAdminResTBE "setct-BatchAdminResTBE" -#define NID_setct_BatchAdminResTBE 593 -#define OBJ_setct_BatchAdminResTBE OBJ_set_ctype,75L - -#define SN_setct_RegFormReqTBE "setct-RegFormReqTBE" -#define NID_setct_RegFormReqTBE 594 -#define OBJ_setct_RegFormReqTBE OBJ_set_ctype,76L - -#define SN_setct_CertReqTBE "setct-CertReqTBE" -#define NID_setct_CertReqTBE 595 -#define OBJ_setct_CertReqTBE OBJ_set_ctype,77L - -#define SN_setct_CertReqTBEX "setct-CertReqTBEX" -#define NID_setct_CertReqTBEX 596 -#define OBJ_setct_CertReqTBEX OBJ_set_ctype,78L - -#define SN_setct_CertResTBE "setct-CertResTBE" -#define NID_setct_CertResTBE 597 -#define OBJ_setct_CertResTBE OBJ_set_ctype,79L - -#define SN_setct_CRLNotificationTBS "setct-CRLNotificationTBS" -#define NID_setct_CRLNotificationTBS 598 -#define OBJ_setct_CRLNotificationTBS OBJ_set_ctype,80L - -#define SN_setct_CRLNotificationResTBS "setct-CRLNotificationResTBS" -#define NID_setct_CRLNotificationResTBS 599 -#define OBJ_setct_CRLNotificationResTBS OBJ_set_ctype,81L - -#define SN_setct_BCIDistributionTBS "setct-BCIDistributionTBS" -#define NID_setct_BCIDistributionTBS 600 -#define OBJ_setct_BCIDistributionTBS OBJ_set_ctype,82L - -#define SN_setext_genCrypt "setext-genCrypt" -#define LN_setext_genCrypt "generic cryptogram" -#define NID_setext_genCrypt 601 -#define OBJ_setext_genCrypt OBJ_set_msgExt,1L - -#define SN_setext_miAuth "setext-miAuth" -#define LN_setext_miAuth "merchant initiated auth" -#define NID_setext_miAuth 602 -#define OBJ_setext_miAuth OBJ_set_msgExt,3L - -#define SN_setext_pinSecure "setext-pinSecure" -#define NID_setext_pinSecure 603 -#define OBJ_setext_pinSecure OBJ_set_msgExt,4L - -#define SN_setext_pinAny "setext-pinAny" -#define NID_setext_pinAny 604 -#define OBJ_setext_pinAny OBJ_set_msgExt,5L - -#define SN_setext_track2 "setext-track2" -#define NID_setext_track2 605 -#define OBJ_setext_track2 OBJ_set_msgExt,7L - -#define SN_setext_cv "setext-cv" -#define LN_setext_cv "additional verification" -#define NID_setext_cv 606 -#define OBJ_setext_cv OBJ_set_msgExt,8L - -#define SN_set_policy_root "set-policy-root" -#define NID_set_policy_root 607 -#define OBJ_set_policy_root OBJ_set_policy,0L - -#define SN_setCext_hashedRoot "setCext-hashedRoot" -#define NID_setCext_hashedRoot 608 -#define OBJ_setCext_hashedRoot OBJ_set_certExt,0L - -#define SN_setCext_certType "setCext-certType" -#define NID_setCext_certType 609 -#define OBJ_setCext_certType OBJ_set_certExt,1L - -#define SN_setCext_merchData "setCext-merchData" -#define NID_setCext_merchData 610 -#define OBJ_setCext_merchData OBJ_set_certExt,2L - -#define SN_setCext_cCertRequired "setCext-cCertRequired" -#define NID_setCext_cCertRequired 611 -#define OBJ_setCext_cCertRequired OBJ_set_certExt,3L - -#define SN_setCext_tunneling "setCext-tunneling" -#define NID_setCext_tunneling 612 -#define OBJ_setCext_tunneling OBJ_set_certExt,4L - -#define SN_setCext_setExt "setCext-setExt" -#define NID_setCext_setExt 613 -#define OBJ_setCext_setExt OBJ_set_certExt,5L - -#define SN_setCext_setQualf "setCext-setQualf" -#define NID_setCext_setQualf 614 -#define OBJ_setCext_setQualf OBJ_set_certExt,6L - -#define SN_setCext_PGWYcapabilities "setCext-PGWYcapabilities" -#define NID_setCext_PGWYcapabilities 615 -#define OBJ_setCext_PGWYcapabilities OBJ_set_certExt,7L - -#define SN_setCext_TokenIdentifier "setCext-TokenIdentifier" -#define NID_setCext_TokenIdentifier 616 -#define OBJ_setCext_TokenIdentifier OBJ_set_certExt,8L - -#define SN_setCext_Track2Data "setCext-Track2Data" -#define NID_setCext_Track2Data 617 -#define OBJ_setCext_Track2Data OBJ_set_certExt,9L - -#define SN_setCext_TokenType "setCext-TokenType" -#define NID_setCext_TokenType 618 -#define OBJ_setCext_TokenType OBJ_set_certExt,10L - -#define SN_setCext_IssuerCapabilities "setCext-IssuerCapabilities" -#define NID_setCext_IssuerCapabilities 619 -#define OBJ_setCext_IssuerCapabilities OBJ_set_certExt,11L - -#define SN_setAttr_Cert "setAttr-Cert" -#define NID_setAttr_Cert 620 -#define OBJ_setAttr_Cert OBJ_set_attr,0L - -#define SN_setAttr_PGWYcap "setAttr-PGWYcap" -#define LN_setAttr_PGWYcap "payment gateway capabilities" -#define NID_setAttr_PGWYcap 621 -#define OBJ_setAttr_PGWYcap OBJ_set_attr,1L - -#define SN_setAttr_TokenType "setAttr-TokenType" -#define NID_setAttr_TokenType 622 -#define OBJ_setAttr_TokenType OBJ_set_attr,2L - -#define SN_setAttr_IssCap "setAttr-IssCap" -#define LN_setAttr_IssCap "issuer capabilities" -#define NID_setAttr_IssCap 623 -#define OBJ_setAttr_IssCap OBJ_set_attr,3L - -#define SN_set_rootKeyThumb "set-rootKeyThumb" -#define NID_set_rootKeyThumb 624 -#define OBJ_set_rootKeyThumb OBJ_setAttr_Cert,0L - -#define SN_set_addPolicy "set-addPolicy" -#define NID_set_addPolicy 625 -#define OBJ_set_addPolicy OBJ_setAttr_Cert,1L - -#define SN_setAttr_Token_EMV "setAttr-Token-EMV" -#define NID_setAttr_Token_EMV 626 -#define OBJ_setAttr_Token_EMV OBJ_setAttr_TokenType,1L - -#define SN_setAttr_Token_B0Prime "setAttr-Token-B0Prime" -#define NID_setAttr_Token_B0Prime 627 -#define OBJ_setAttr_Token_B0Prime OBJ_setAttr_TokenType,2L - -#define SN_setAttr_IssCap_CVM "setAttr-IssCap-CVM" -#define NID_setAttr_IssCap_CVM 628 -#define OBJ_setAttr_IssCap_CVM OBJ_setAttr_IssCap,3L - -#define SN_setAttr_IssCap_T2 "setAttr-IssCap-T2" -#define NID_setAttr_IssCap_T2 629 -#define OBJ_setAttr_IssCap_T2 OBJ_setAttr_IssCap,4L - -#define SN_setAttr_IssCap_Sig "setAttr-IssCap-Sig" -#define NID_setAttr_IssCap_Sig 630 -#define OBJ_setAttr_IssCap_Sig OBJ_setAttr_IssCap,5L - -#define SN_setAttr_GenCryptgrm "setAttr-GenCryptgrm" -#define LN_setAttr_GenCryptgrm "generate cryptogram" -#define NID_setAttr_GenCryptgrm 631 -#define OBJ_setAttr_GenCryptgrm OBJ_setAttr_IssCap_CVM,1L - -#define SN_setAttr_T2Enc "setAttr-T2Enc" -#define LN_setAttr_T2Enc "encrypted track 2" -#define NID_setAttr_T2Enc 632 -#define OBJ_setAttr_T2Enc OBJ_setAttr_IssCap_T2,1L - -#define SN_setAttr_T2cleartxt "setAttr-T2cleartxt" -#define LN_setAttr_T2cleartxt "cleartext track 2" -#define NID_setAttr_T2cleartxt 633 -#define OBJ_setAttr_T2cleartxt OBJ_setAttr_IssCap_T2,2L - -#define SN_setAttr_TokICCsig "setAttr-TokICCsig" -#define LN_setAttr_TokICCsig "ICC or token signature" -#define NID_setAttr_TokICCsig 634 -#define OBJ_setAttr_TokICCsig OBJ_setAttr_IssCap_Sig,1L - -#define SN_setAttr_SecDevSig "setAttr-SecDevSig" -#define LN_setAttr_SecDevSig "secure device signature" -#define NID_setAttr_SecDevSig 635 -#define OBJ_setAttr_SecDevSig OBJ_setAttr_IssCap_Sig,2L - -#define SN_set_brand_IATA_ATA "set-brand-IATA-ATA" -#define NID_set_brand_IATA_ATA 636 -#define OBJ_set_brand_IATA_ATA OBJ_set_brand,1L - -#define SN_set_brand_Diners "set-brand-Diners" -#define NID_set_brand_Diners 637 -#define OBJ_set_brand_Diners OBJ_set_brand,30L - -#define SN_set_brand_AmericanExpress "set-brand-AmericanExpress" -#define NID_set_brand_AmericanExpress 638 -#define OBJ_set_brand_AmericanExpress OBJ_set_brand,34L - -#define SN_set_brand_JCB "set-brand-JCB" -#define NID_set_brand_JCB 639 -#define OBJ_set_brand_JCB OBJ_set_brand,35L - -#define SN_set_brand_Visa "set-brand-Visa" -#define NID_set_brand_Visa 640 -#define OBJ_set_brand_Visa OBJ_set_brand,4L - -#define SN_set_brand_MasterCard "set-brand-MasterCard" -#define NID_set_brand_MasterCard 641 -#define OBJ_set_brand_MasterCard OBJ_set_brand,5L - -#define SN_set_brand_Novus "set-brand-Novus" -#define NID_set_brand_Novus 642 -#define OBJ_set_brand_Novus OBJ_set_brand,6011L - -#define SN_des_cdmf "DES-CDMF" -#define LN_des_cdmf "des-cdmf" -#define NID_des_cdmf 643 -#define OBJ_des_cdmf OBJ_rsadsi,3L,10L - -#define SN_rsaOAEPEncryptionSET "rsaOAEPEncryptionSET" -#define NID_rsaOAEPEncryptionSET 644 -#define OBJ_rsaOAEPEncryptionSET OBJ_rsadsi,1L,1L,6L - -#define SN_ipsec3 "Oakley-EC2N-3" -#define LN_ipsec3 "ipsec3" -#define NID_ipsec3 749 - -#define SN_ipsec4 "Oakley-EC2N-4" -#define LN_ipsec4 "ipsec4" -#define NID_ipsec4 750 - +/* crypto/objects/obj_mac.h */ + +/* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the + * following command: + * perl objects.pl objects.txt obj_mac.num obj_mac.h + */ + +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#define SN_undef "UNDEF" +#define LN_undef "undefined" +#define NID_undef 0 +#define OBJ_undef 0L + +#define SN_itu_t "ITU-T" +#define LN_itu_t "itu-t" +#define NID_itu_t 645 +#define OBJ_itu_t 0L + +#define NID_ccitt 404 +#define OBJ_ccitt OBJ_itu_t + +#define SN_iso "ISO" +#define LN_iso "iso" +#define NID_iso 181 +#define OBJ_iso 1L + +#define SN_joint_iso_itu_t "JOINT-ISO-ITU-T" +#define LN_joint_iso_itu_t "joint-iso-itu-t" +#define NID_joint_iso_itu_t 646 +#define OBJ_joint_iso_itu_t 2L + +#define NID_joint_iso_ccitt 393 +#define OBJ_joint_iso_ccitt OBJ_joint_iso_itu_t + +#define SN_member_body "member-body" +#define LN_member_body "ISO Member Body" +#define NID_member_body 182 +#define OBJ_member_body OBJ_iso,2L + +#define SN_identified_organization "identified-organization" +#define NID_identified_organization 676 +#define OBJ_identified_organization OBJ_iso,3L + +#define SN_certicom_arc "certicom-arc" +#define NID_certicom_arc 677 +#define OBJ_certicom_arc OBJ_identified_organization,132L + +#define SN_international_organizations "international-organizations" +#define LN_international_organizations "International Organizations" +#define NID_international_organizations 647 +#define OBJ_international_organizations OBJ_joint_iso_itu_t,23L + +#define SN_wap "wap" +#define NID_wap 678 +#define OBJ_wap OBJ_international_organizations,43L + +#define SN_wap_wsg "wap-wsg" +#define NID_wap_wsg 679 +#define OBJ_wap_wsg OBJ_wap,13L + +#define SN_selected_attribute_types "selected-attribute-types" +#define LN_selected_attribute_types "Selected Attribute Types" +#define NID_selected_attribute_types 394 +#define OBJ_selected_attribute_types OBJ_joint_iso_itu_t,5L,1L,5L + +#define SN_clearance "clearance" +#define NID_clearance 395 +#define OBJ_clearance OBJ_selected_attribute_types,55L + +#define SN_ISO_US "ISO-US" +#define LN_ISO_US "ISO US Member Body" +#define NID_ISO_US 183 +#define OBJ_ISO_US OBJ_member_body,840L + +#define SN_X9_57 "X9-57" +#define LN_X9_57 "X9.57" +#define NID_X9_57 184 +#define OBJ_X9_57 OBJ_ISO_US,10040L + +#define SN_X9cm "X9cm" +#define LN_X9cm "X9.57 CM ?" +#define NID_X9cm 185 +#define OBJ_X9cm OBJ_X9_57,4L + +#define SN_dsa "DSA" +#define LN_dsa "dsaEncryption" +#define NID_dsa 116 +#define OBJ_dsa OBJ_X9cm,1L + +#define SN_dsaWithSHA1 "DSA-SHA1" +#define LN_dsaWithSHA1 "dsaWithSHA1" +#define NID_dsaWithSHA1 113 +#define OBJ_dsaWithSHA1 OBJ_X9cm,3L + +#define SN_ansi_X9_62 "ansi-X9-62" +#define LN_ansi_X9_62 "ANSI X9.62" +#define NID_ansi_X9_62 405 +#define OBJ_ansi_X9_62 OBJ_ISO_US,10045L + +#define OBJ_X9_62_id_fieldType OBJ_ansi_X9_62,1L + +#define SN_X9_62_prime_field "prime-field" +#define NID_X9_62_prime_field 406 +#define OBJ_X9_62_prime_field OBJ_X9_62_id_fieldType,1L + +#define SN_X9_62_characteristic_two_field "characteristic-two-field" +#define NID_X9_62_characteristic_two_field 407 +#define OBJ_X9_62_characteristic_two_field OBJ_X9_62_id_fieldType,2L + +#define SN_X9_62_id_characteristic_two_basis "id-characteristic-two-basis" +#define NID_X9_62_id_characteristic_two_basis 680 +#define OBJ_X9_62_id_characteristic_two_basis OBJ_X9_62_characteristic_two_field,3L + +#define SN_X9_62_onBasis "onBasis" +#define NID_X9_62_onBasis 681 +#define OBJ_X9_62_onBasis OBJ_X9_62_id_characteristic_two_basis,1L + +#define SN_X9_62_tpBasis "tpBasis" +#define NID_X9_62_tpBasis 682 +#define OBJ_X9_62_tpBasis OBJ_X9_62_id_characteristic_two_basis,2L + +#define SN_X9_62_ppBasis "ppBasis" +#define NID_X9_62_ppBasis 683 +#define OBJ_X9_62_ppBasis OBJ_X9_62_id_characteristic_two_basis,3L + +#define OBJ_X9_62_id_publicKeyType OBJ_ansi_X9_62,2L + +#define SN_X9_62_id_ecPublicKey "id-ecPublicKey" +#define NID_X9_62_id_ecPublicKey 408 +#define OBJ_X9_62_id_ecPublicKey OBJ_X9_62_id_publicKeyType,1L + +#define OBJ_X9_62_ellipticCurve OBJ_ansi_X9_62,3L + +#define OBJ_X9_62_c_TwoCurve OBJ_X9_62_ellipticCurve,0L + +#define SN_X9_62_c2pnb163v1 "c2pnb163v1" +#define NID_X9_62_c2pnb163v1 684 +#define OBJ_X9_62_c2pnb163v1 OBJ_X9_62_c_TwoCurve,1L + +#define SN_X9_62_c2pnb163v2 "c2pnb163v2" +#define NID_X9_62_c2pnb163v2 685 +#define OBJ_X9_62_c2pnb163v2 OBJ_X9_62_c_TwoCurve,2L + +#define SN_X9_62_c2pnb163v3 "c2pnb163v3" +#define NID_X9_62_c2pnb163v3 686 +#define OBJ_X9_62_c2pnb163v3 OBJ_X9_62_c_TwoCurve,3L + +#define SN_X9_62_c2pnb176v1 "c2pnb176v1" +#define NID_X9_62_c2pnb176v1 687 +#define OBJ_X9_62_c2pnb176v1 OBJ_X9_62_c_TwoCurve,4L + +#define SN_X9_62_c2tnb191v1 "c2tnb191v1" +#define NID_X9_62_c2tnb191v1 688 +#define OBJ_X9_62_c2tnb191v1 OBJ_X9_62_c_TwoCurve,5L + +#define SN_X9_62_c2tnb191v2 "c2tnb191v2" +#define NID_X9_62_c2tnb191v2 689 +#define OBJ_X9_62_c2tnb191v2 OBJ_X9_62_c_TwoCurve,6L + +#define SN_X9_62_c2tnb191v3 "c2tnb191v3" +#define NID_X9_62_c2tnb191v3 690 +#define OBJ_X9_62_c2tnb191v3 OBJ_X9_62_c_TwoCurve,7L + +#define SN_X9_62_c2onb191v4 "c2onb191v4" +#define NID_X9_62_c2onb191v4 691 +#define OBJ_X9_62_c2onb191v4 OBJ_X9_62_c_TwoCurve,8L + +#define SN_X9_62_c2onb191v5 "c2onb191v5" +#define NID_X9_62_c2onb191v5 692 +#define OBJ_X9_62_c2onb191v5 OBJ_X9_62_c_TwoCurve,9L + +#define SN_X9_62_c2pnb208w1 "c2pnb208w1" +#define NID_X9_62_c2pnb208w1 693 +#define OBJ_X9_62_c2pnb208w1 OBJ_X9_62_c_TwoCurve,10L + +#define SN_X9_62_c2tnb239v1 "c2tnb239v1" +#define NID_X9_62_c2tnb239v1 694 +#define OBJ_X9_62_c2tnb239v1 OBJ_X9_62_c_TwoCurve,11L + +#define SN_X9_62_c2tnb239v2 "c2tnb239v2" +#define NID_X9_62_c2tnb239v2 695 +#define OBJ_X9_62_c2tnb239v2 OBJ_X9_62_c_TwoCurve,12L + +#define SN_X9_62_c2tnb239v3 "c2tnb239v3" +#define NID_X9_62_c2tnb239v3 696 +#define OBJ_X9_62_c2tnb239v3 OBJ_X9_62_c_TwoCurve,13L + +#define SN_X9_62_c2onb239v4 "c2onb239v4" +#define NID_X9_62_c2onb239v4 697 +#define OBJ_X9_62_c2onb239v4 OBJ_X9_62_c_TwoCurve,14L + +#define SN_X9_62_c2onb239v5 "c2onb239v5" +#define NID_X9_62_c2onb239v5 698 +#define OBJ_X9_62_c2onb239v5 OBJ_X9_62_c_TwoCurve,15L + +#define SN_X9_62_c2pnb272w1 "c2pnb272w1" +#define NID_X9_62_c2pnb272w1 699 +#define OBJ_X9_62_c2pnb272w1 OBJ_X9_62_c_TwoCurve,16L + +#define SN_X9_62_c2pnb304w1 "c2pnb304w1" +#define NID_X9_62_c2pnb304w1 700 +#define OBJ_X9_62_c2pnb304w1 OBJ_X9_62_c_TwoCurve,17L + +#define SN_X9_62_c2tnb359v1 "c2tnb359v1" +#define NID_X9_62_c2tnb359v1 701 +#define OBJ_X9_62_c2tnb359v1 OBJ_X9_62_c_TwoCurve,18L + +#define SN_X9_62_c2pnb368w1 "c2pnb368w1" +#define NID_X9_62_c2pnb368w1 702 +#define OBJ_X9_62_c2pnb368w1 OBJ_X9_62_c_TwoCurve,19L + +#define SN_X9_62_c2tnb431r1 "c2tnb431r1" +#define NID_X9_62_c2tnb431r1 703 +#define OBJ_X9_62_c2tnb431r1 OBJ_X9_62_c_TwoCurve,20L + +#define OBJ_X9_62_primeCurve OBJ_X9_62_ellipticCurve,1L + +#define SN_X9_62_prime192v1 "prime192v1" +#define NID_X9_62_prime192v1 409 +#define OBJ_X9_62_prime192v1 OBJ_X9_62_primeCurve,1L + +#define SN_X9_62_prime192v2 "prime192v2" +#define NID_X9_62_prime192v2 410 +#define OBJ_X9_62_prime192v2 OBJ_X9_62_primeCurve,2L + +#define SN_X9_62_prime192v3 "prime192v3" +#define NID_X9_62_prime192v3 411 +#define OBJ_X9_62_prime192v3 OBJ_X9_62_primeCurve,3L + +#define SN_X9_62_prime239v1 "prime239v1" +#define NID_X9_62_prime239v1 412 +#define OBJ_X9_62_prime239v1 OBJ_X9_62_primeCurve,4L + +#define SN_X9_62_prime239v2 "prime239v2" +#define NID_X9_62_prime239v2 413 +#define OBJ_X9_62_prime239v2 OBJ_X9_62_primeCurve,5L + +#define SN_X9_62_prime239v3 "prime239v3" +#define NID_X9_62_prime239v3 414 +#define OBJ_X9_62_prime239v3 OBJ_X9_62_primeCurve,6L + +#define SN_X9_62_prime256v1 "prime256v1" +#define NID_X9_62_prime256v1 415 +#define OBJ_X9_62_prime256v1 OBJ_X9_62_primeCurve,7L + +#define OBJ_X9_62_id_ecSigType OBJ_ansi_X9_62,4L + +#define SN_ecdsa_with_SHA1 "ecdsa-with-SHA1" +#define NID_ecdsa_with_SHA1 416 +#define OBJ_ecdsa_with_SHA1 OBJ_X9_62_id_ecSigType,1L + +#define OBJ_secg_ellipticCurve OBJ_certicom_arc,0L + +#define SN_secp112r1 "secp112r1" +#define NID_secp112r1 704 +#define OBJ_secp112r1 OBJ_secg_ellipticCurve,6L + +#define SN_secp112r2 "secp112r2" +#define NID_secp112r2 705 +#define OBJ_secp112r2 OBJ_secg_ellipticCurve,7L + +#define SN_secp128r1 "secp128r1" +#define NID_secp128r1 706 +#define OBJ_secp128r1 OBJ_secg_ellipticCurve,28L + +#define SN_secp128r2 "secp128r2" +#define NID_secp128r2 707 +#define OBJ_secp128r2 OBJ_secg_ellipticCurve,29L + +#define SN_secp160k1 "secp160k1" +#define NID_secp160k1 708 +#define OBJ_secp160k1 OBJ_secg_ellipticCurve,9L + +#define SN_secp160r1 "secp160r1" +#define NID_secp160r1 709 +#define OBJ_secp160r1 OBJ_secg_ellipticCurve,8L + +#define SN_secp160r2 "secp160r2" +#define NID_secp160r2 710 +#define OBJ_secp160r2 OBJ_secg_ellipticCurve,30L + +#define SN_secp192k1 "secp192k1" +#define NID_secp192k1 711 +#define OBJ_secp192k1 OBJ_secg_ellipticCurve,31L + +#define SN_secp224k1 "secp224k1" +#define NID_secp224k1 712 +#define OBJ_secp224k1 OBJ_secg_ellipticCurve,32L + +#define SN_secp224r1 "secp224r1" +#define NID_secp224r1 713 +#define OBJ_secp224r1 OBJ_secg_ellipticCurve,33L + +#define SN_secp256k1 "secp256k1" +#define NID_secp256k1 714 +#define OBJ_secp256k1 OBJ_secg_ellipticCurve,10L + +#define SN_secp384r1 "secp384r1" +#define NID_secp384r1 715 +#define OBJ_secp384r1 OBJ_secg_ellipticCurve,34L + +#define SN_secp521r1 "secp521r1" +#define NID_secp521r1 716 +#define OBJ_secp521r1 OBJ_secg_ellipticCurve,35L + +#define SN_sect113r1 "sect113r1" +#define NID_sect113r1 717 +#define OBJ_sect113r1 OBJ_secg_ellipticCurve,4L + +#define SN_sect113r2 "sect113r2" +#define NID_sect113r2 718 +#define OBJ_sect113r2 OBJ_secg_ellipticCurve,5L + +#define SN_sect131r1 "sect131r1" +#define NID_sect131r1 719 +#define OBJ_sect131r1 OBJ_secg_ellipticCurve,22L + +#define SN_sect131r2 "sect131r2" +#define NID_sect131r2 720 +#define OBJ_sect131r2 OBJ_secg_ellipticCurve,23L + +#define SN_sect163k1 "sect163k1" +#define NID_sect163k1 721 +#define OBJ_sect163k1 OBJ_secg_ellipticCurve,1L + +#define SN_sect163r1 "sect163r1" +#define NID_sect163r1 722 +#define OBJ_sect163r1 OBJ_secg_ellipticCurve,2L + +#define SN_sect163r2 "sect163r2" +#define NID_sect163r2 723 +#define OBJ_sect163r2 OBJ_secg_ellipticCurve,15L + +#define SN_sect193r1 "sect193r1" +#define NID_sect193r1 724 +#define OBJ_sect193r1 OBJ_secg_ellipticCurve,24L + +#define SN_sect193r2 "sect193r2" +#define NID_sect193r2 725 +#define OBJ_sect193r2 OBJ_secg_ellipticCurve,25L + +#define SN_sect233k1 "sect233k1" +#define NID_sect233k1 726 +#define OBJ_sect233k1 OBJ_secg_ellipticCurve,26L + +#define SN_sect233r1 "sect233r1" +#define NID_sect233r1 727 +#define OBJ_sect233r1 OBJ_secg_ellipticCurve,27L + +#define SN_sect239k1 "sect239k1" +#define NID_sect239k1 728 +#define OBJ_sect239k1 OBJ_secg_ellipticCurve,3L + +#define SN_sect283k1 "sect283k1" +#define NID_sect283k1 729 +#define OBJ_sect283k1 OBJ_secg_ellipticCurve,16L + +#define SN_sect283r1 "sect283r1" +#define NID_sect283r1 730 +#define OBJ_sect283r1 OBJ_secg_ellipticCurve,17L + +#define SN_sect409k1 "sect409k1" +#define NID_sect409k1 731 +#define OBJ_sect409k1 OBJ_secg_ellipticCurve,36L + +#define SN_sect409r1 "sect409r1" +#define NID_sect409r1 732 +#define OBJ_sect409r1 OBJ_secg_ellipticCurve,37L + +#define SN_sect571k1 "sect571k1" +#define NID_sect571k1 733 +#define OBJ_sect571k1 OBJ_secg_ellipticCurve,38L + +#define SN_sect571r1 "sect571r1" +#define NID_sect571r1 734 +#define OBJ_sect571r1 OBJ_secg_ellipticCurve,39L + +#define OBJ_wap_wsg_idm_ecid OBJ_wap_wsg,4L + +#define SN_wap_wsg_idm_ecid_wtls1 "wap-wsg-idm-ecid-wtls1" +#define NID_wap_wsg_idm_ecid_wtls1 735 +#define OBJ_wap_wsg_idm_ecid_wtls1 OBJ_wap_wsg_idm_ecid,1L + +#define SN_wap_wsg_idm_ecid_wtls3 "wap-wsg-idm-ecid-wtls3" +#define NID_wap_wsg_idm_ecid_wtls3 736 +#define OBJ_wap_wsg_idm_ecid_wtls3 OBJ_wap_wsg_idm_ecid,3L + +#define SN_wap_wsg_idm_ecid_wtls4 "wap-wsg-idm-ecid-wtls4" +#define NID_wap_wsg_idm_ecid_wtls4 737 +#define OBJ_wap_wsg_idm_ecid_wtls4 OBJ_wap_wsg_idm_ecid,4L + +#define SN_wap_wsg_idm_ecid_wtls5 "wap-wsg-idm-ecid-wtls5" +#define NID_wap_wsg_idm_ecid_wtls5 738 +#define OBJ_wap_wsg_idm_ecid_wtls5 OBJ_wap_wsg_idm_ecid,5L + +#define SN_wap_wsg_idm_ecid_wtls6 "wap-wsg-idm-ecid-wtls6" +#define NID_wap_wsg_idm_ecid_wtls6 739 +#define OBJ_wap_wsg_idm_ecid_wtls6 OBJ_wap_wsg_idm_ecid,6L + +#define SN_wap_wsg_idm_ecid_wtls7 "wap-wsg-idm-ecid-wtls7" +#define NID_wap_wsg_idm_ecid_wtls7 740 +#define OBJ_wap_wsg_idm_ecid_wtls7 OBJ_wap_wsg_idm_ecid,7L + +#define SN_wap_wsg_idm_ecid_wtls8 "wap-wsg-idm-ecid-wtls8" +#define NID_wap_wsg_idm_ecid_wtls8 741 +#define OBJ_wap_wsg_idm_ecid_wtls8 OBJ_wap_wsg_idm_ecid,8L + +#define SN_wap_wsg_idm_ecid_wtls9 "wap-wsg-idm-ecid-wtls9" +#define NID_wap_wsg_idm_ecid_wtls9 742 +#define OBJ_wap_wsg_idm_ecid_wtls9 OBJ_wap_wsg_idm_ecid,9L + +#define SN_wap_wsg_idm_ecid_wtls10 "wap-wsg-idm-ecid-wtls10" +#define NID_wap_wsg_idm_ecid_wtls10 743 +#define OBJ_wap_wsg_idm_ecid_wtls10 OBJ_wap_wsg_idm_ecid,10L + +#define SN_wap_wsg_idm_ecid_wtls11 "wap-wsg-idm-ecid-wtls11" +#define NID_wap_wsg_idm_ecid_wtls11 744 +#define OBJ_wap_wsg_idm_ecid_wtls11 OBJ_wap_wsg_idm_ecid,11L + +#define SN_wap_wsg_idm_ecid_wtls12 "wap-wsg-idm-ecid-wtls12" +#define NID_wap_wsg_idm_ecid_wtls12 745 +#define OBJ_wap_wsg_idm_ecid_wtls12 OBJ_wap_wsg_idm_ecid,12L + +#define SN_cast5_cbc "CAST5-CBC" +#define LN_cast5_cbc "cast5-cbc" +#define NID_cast5_cbc 108 +#define OBJ_cast5_cbc OBJ_ISO_US,113533L,7L,66L,10L + +#define SN_cast5_ecb "CAST5-ECB" +#define LN_cast5_ecb "cast5-ecb" +#define NID_cast5_ecb 109 + +#define SN_cast5_cfb64 "CAST5-CFB" +#define LN_cast5_cfb64 "cast5-cfb" +#define NID_cast5_cfb64 110 + +#define SN_cast5_ofb64 "CAST5-OFB" +#define LN_cast5_ofb64 "cast5-ofb" +#define NID_cast5_ofb64 111 + +#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" +#define NID_pbeWithMD5AndCast5_CBC 112 +#define OBJ_pbeWithMD5AndCast5_CBC OBJ_ISO_US,113533L,7L,66L,12L + +#define SN_rsadsi "rsadsi" +#define LN_rsadsi "RSA Data Security, Inc." +#define NID_rsadsi 1 +#define OBJ_rsadsi OBJ_ISO_US,113549L + +#define SN_pkcs "pkcs" +#define LN_pkcs "RSA Data Security, Inc. PKCS" +#define NID_pkcs 2 +#define OBJ_pkcs OBJ_rsadsi,1L + +#define SN_pkcs1 "pkcs1" +#define NID_pkcs1 186 +#define OBJ_pkcs1 OBJ_pkcs,1L + +#define LN_rsaEncryption "rsaEncryption" +#define NID_rsaEncryption 6 +#define OBJ_rsaEncryption OBJ_pkcs1,1L + +#define SN_md2WithRSAEncryption "RSA-MD2" +#define LN_md2WithRSAEncryption "md2WithRSAEncryption" +#define NID_md2WithRSAEncryption 7 +#define OBJ_md2WithRSAEncryption OBJ_pkcs1,2L + +#define SN_md4WithRSAEncryption "RSA-MD4" +#define LN_md4WithRSAEncryption "md4WithRSAEncryption" +#define NID_md4WithRSAEncryption 396 +#define OBJ_md4WithRSAEncryption OBJ_pkcs1,3L + +#define SN_md5WithRSAEncryption "RSA-MD5" +#define LN_md5WithRSAEncryption "md5WithRSAEncryption" +#define NID_md5WithRSAEncryption 8 +#define OBJ_md5WithRSAEncryption OBJ_pkcs1,4L + +#define SN_sha1WithRSAEncryption "RSA-SHA1" +#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" +#define NID_sha1WithRSAEncryption 65 +#define OBJ_sha1WithRSAEncryption OBJ_pkcs1,5L + +#define SN_sha256WithRSAEncryption "RSA-SHA256" +#define LN_sha256WithRSAEncryption "sha256WithRSAEncryption" +#define NID_sha256WithRSAEncryption 668 +#define OBJ_sha256WithRSAEncryption OBJ_pkcs1,11L + +#define SN_sha384WithRSAEncryption "RSA-SHA384" +#define LN_sha384WithRSAEncryption "sha384WithRSAEncryption" +#define NID_sha384WithRSAEncryption 669 +#define OBJ_sha384WithRSAEncryption OBJ_pkcs1,12L + +#define SN_sha512WithRSAEncryption "RSA-SHA512" +#define LN_sha512WithRSAEncryption "sha512WithRSAEncryption" +#define NID_sha512WithRSAEncryption 670 +#define OBJ_sha512WithRSAEncryption OBJ_pkcs1,13L + +#define SN_sha224WithRSAEncryption "RSA-SHA224" +#define LN_sha224WithRSAEncryption "sha224WithRSAEncryption" +#define NID_sha224WithRSAEncryption 671 +#define OBJ_sha224WithRSAEncryption OBJ_pkcs1,14L + +#define SN_pkcs3 "pkcs3" +#define NID_pkcs3 27 +#define OBJ_pkcs3 OBJ_pkcs,3L + +#define LN_dhKeyAgreement "dhKeyAgreement" +#define NID_dhKeyAgreement 28 +#define OBJ_dhKeyAgreement OBJ_pkcs3,1L + +#define SN_pkcs5 "pkcs5" +#define NID_pkcs5 187 +#define OBJ_pkcs5 OBJ_pkcs,5L + +#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" +#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" +#define NID_pbeWithMD2AndDES_CBC 9 +#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs5,1L + +#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" +#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" +#define NID_pbeWithMD5AndDES_CBC 10 +#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs5,3L + +#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" +#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" +#define NID_pbeWithMD2AndRC2_CBC 168 +#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs5,4L + +#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" +#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" +#define NID_pbeWithMD5AndRC2_CBC 169 +#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs5,6L + +#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" +#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" +#define NID_pbeWithSHA1AndDES_CBC 170 +#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs5,10L + +#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" +#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" +#define NID_pbeWithSHA1AndRC2_CBC 68 +#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs5,11L + +#define LN_id_pbkdf2 "PBKDF2" +#define NID_id_pbkdf2 69 +#define OBJ_id_pbkdf2 OBJ_pkcs5,12L + +#define LN_pbes2 "PBES2" +#define NID_pbes2 161 +#define OBJ_pbes2 OBJ_pkcs5,13L + +#define LN_pbmac1 "PBMAC1" +#define NID_pbmac1 162 +#define OBJ_pbmac1 OBJ_pkcs5,14L + +#define SN_pkcs7 "pkcs7" +#define NID_pkcs7 20 +#define OBJ_pkcs7 OBJ_pkcs,7L + +#define LN_pkcs7_data "pkcs7-data" +#define NID_pkcs7_data 21 +#define OBJ_pkcs7_data OBJ_pkcs7,1L + +#define LN_pkcs7_signed "pkcs7-signedData" +#define NID_pkcs7_signed 22 +#define OBJ_pkcs7_signed OBJ_pkcs7,2L + +#define LN_pkcs7_enveloped "pkcs7-envelopedData" +#define NID_pkcs7_enveloped 23 +#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L + +#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" +#define NID_pkcs7_signedAndEnveloped 24 +#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L + +#define LN_pkcs7_digest "pkcs7-digestData" +#define NID_pkcs7_digest 25 +#define OBJ_pkcs7_digest OBJ_pkcs7,5L + +#define LN_pkcs7_encrypted "pkcs7-encryptedData" +#define NID_pkcs7_encrypted 26 +#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L + +#define SN_pkcs9 "pkcs9" +#define NID_pkcs9 47 +#define OBJ_pkcs9 OBJ_pkcs,9L + +#define LN_pkcs9_emailAddress "emailAddress" +#define NID_pkcs9_emailAddress 48 +#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L + +#define LN_pkcs9_unstructuredName "unstructuredName" +#define NID_pkcs9_unstructuredName 49 +#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L + +#define LN_pkcs9_contentType "contentType" +#define NID_pkcs9_contentType 50 +#define OBJ_pkcs9_contentType OBJ_pkcs9,3L + +#define LN_pkcs9_messageDigest "messageDigest" +#define NID_pkcs9_messageDigest 51 +#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L + +#define LN_pkcs9_signingTime "signingTime" +#define NID_pkcs9_signingTime 52 +#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L + +#define LN_pkcs9_countersignature "countersignature" +#define NID_pkcs9_countersignature 53 +#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L + +#define LN_pkcs9_challengePassword "challengePassword" +#define NID_pkcs9_challengePassword 54 +#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L + +#define LN_pkcs9_unstructuredAddress "unstructuredAddress" +#define NID_pkcs9_unstructuredAddress 55 +#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L + +#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" +#define NID_pkcs9_extCertAttributes 56 +#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L + +#define SN_ext_req "extReq" +#define LN_ext_req "Extension Request" +#define NID_ext_req 172 +#define OBJ_ext_req OBJ_pkcs9,14L + +#define SN_SMIMECapabilities "SMIME-CAPS" +#define LN_SMIMECapabilities "S/MIME Capabilities" +#define NID_SMIMECapabilities 167 +#define OBJ_SMIMECapabilities OBJ_pkcs9,15L + +#define SN_SMIME "SMIME" +#define LN_SMIME "S/MIME" +#define NID_SMIME 188 +#define OBJ_SMIME OBJ_pkcs9,16L + +#define SN_id_smime_mod "id-smime-mod" +#define NID_id_smime_mod 189 +#define OBJ_id_smime_mod OBJ_SMIME,0L + +#define SN_id_smime_ct "id-smime-ct" +#define NID_id_smime_ct 190 +#define OBJ_id_smime_ct OBJ_SMIME,1L + +#define SN_id_smime_aa "id-smime-aa" +#define NID_id_smime_aa 191 +#define OBJ_id_smime_aa OBJ_SMIME,2L + +#define SN_id_smime_alg "id-smime-alg" +#define NID_id_smime_alg 192 +#define OBJ_id_smime_alg OBJ_SMIME,3L + +#define SN_id_smime_cd "id-smime-cd" +#define NID_id_smime_cd 193 +#define OBJ_id_smime_cd OBJ_SMIME,4L + +#define SN_id_smime_spq "id-smime-spq" +#define NID_id_smime_spq 194 +#define OBJ_id_smime_spq OBJ_SMIME,5L + +#define SN_id_smime_cti "id-smime-cti" +#define NID_id_smime_cti 195 +#define OBJ_id_smime_cti OBJ_SMIME,6L + +#define SN_id_smime_mod_cms "id-smime-mod-cms" +#define NID_id_smime_mod_cms 196 +#define OBJ_id_smime_mod_cms OBJ_id_smime_mod,1L + +#define SN_id_smime_mod_ess "id-smime-mod-ess" +#define NID_id_smime_mod_ess 197 +#define OBJ_id_smime_mod_ess OBJ_id_smime_mod,2L + +#define SN_id_smime_mod_oid "id-smime-mod-oid" +#define NID_id_smime_mod_oid 198 +#define OBJ_id_smime_mod_oid OBJ_id_smime_mod,3L + +#define SN_id_smime_mod_msg_v3 "id-smime-mod-msg-v3" +#define NID_id_smime_mod_msg_v3 199 +#define OBJ_id_smime_mod_msg_v3 OBJ_id_smime_mod,4L + +#define SN_id_smime_mod_ets_eSignature_88 "id-smime-mod-ets-eSignature-88" +#define NID_id_smime_mod_ets_eSignature_88 200 +#define OBJ_id_smime_mod_ets_eSignature_88 OBJ_id_smime_mod,5L + +#define SN_id_smime_mod_ets_eSignature_97 "id-smime-mod-ets-eSignature-97" +#define NID_id_smime_mod_ets_eSignature_97 201 +#define OBJ_id_smime_mod_ets_eSignature_97 OBJ_id_smime_mod,6L + +#define SN_id_smime_mod_ets_eSigPolicy_88 "id-smime-mod-ets-eSigPolicy-88" +#define NID_id_smime_mod_ets_eSigPolicy_88 202 +#define OBJ_id_smime_mod_ets_eSigPolicy_88 OBJ_id_smime_mod,7L + +#define SN_id_smime_mod_ets_eSigPolicy_97 "id-smime-mod-ets-eSigPolicy-97" +#define NID_id_smime_mod_ets_eSigPolicy_97 203 +#define OBJ_id_smime_mod_ets_eSigPolicy_97 OBJ_id_smime_mod,8L + +#define SN_id_smime_ct_receipt "id-smime-ct-receipt" +#define NID_id_smime_ct_receipt 204 +#define OBJ_id_smime_ct_receipt OBJ_id_smime_ct,1L + +#define SN_id_smime_ct_authData "id-smime-ct-authData" +#define NID_id_smime_ct_authData 205 +#define OBJ_id_smime_ct_authData OBJ_id_smime_ct,2L + +#define SN_id_smime_ct_publishCert "id-smime-ct-publishCert" +#define NID_id_smime_ct_publishCert 206 +#define OBJ_id_smime_ct_publishCert OBJ_id_smime_ct,3L + +#define SN_id_smime_ct_TSTInfo "id-smime-ct-TSTInfo" +#define NID_id_smime_ct_TSTInfo 207 +#define OBJ_id_smime_ct_TSTInfo OBJ_id_smime_ct,4L + +#define SN_id_smime_ct_TDTInfo "id-smime-ct-TDTInfo" +#define NID_id_smime_ct_TDTInfo 208 +#define OBJ_id_smime_ct_TDTInfo OBJ_id_smime_ct,5L + +#define SN_id_smime_ct_contentInfo "id-smime-ct-contentInfo" +#define NID_id_smime_ct_contentInfo 209 +#define OBJ_id_smime_ct_contentInfo OBJ_id_smime_ct,6L + +#define SN_id_smime_ct_DVCSRequestData "id-smime-ct-DVCSRequestData" +#define NID_id_smime_ct_DVCSRequestData 210 +#define OBJ_id_smime_ct_DVCSRequestData OBJ_id_smime_ct,7L + +#define SN_id_smime_ct_DVCSResponseData "id-smime-ct-DVCSResponseData" +#define NID_id_smime_ct_DVCSResponseData 211 +#define OBJ_id_smime_ct_DVCSResponseData OBJ_id_smime_ct,8L + +#define SN_id_smime_aa_receiptRequest "id-smime-aa-receiptRequest" +#define NID_id_smime_aa_receiptRequest 212 +#define OBJ_id_smime_aa_receiptRequest OBJ_id_smime_aa,1L + +#define SN_id_smime_aa_securityLabel "id-smime-aa-securityLabel" +#define NID_id_smime_aa_securityLabel 213 +#define OBJ_id_smime_aa_securityLabel OBJ_id_smime_aa,2L + +#define SN_id_smime_aa_mlExpandHistory "id-smime-aa-mlExpandHistory" +#define NID_id_smime_aa_mlExpandHistory 214 +#define OBJ_id_smime_aa_mlExpandHistory OBJ_id_smime_aa,3L + +#define SN_id_smime_aa_contentHint "id-smime-aa-contentHint" +#define NID_id_smime_aa_contentHint 215 +#define OBJ_id_smime_aa_contentHint OBJ_id_smime_aa,4L + +#define SN_id_smime_aa_msgSigDigest "id-smime-aa-msgSigDigest" +#define NID_id_smime_aa_msgSigDigest 216 +#define OBJ_id_smime_aa_msgSigDigest OBJ_id_smime_aa,5L + +#define SN_id_smime_aa_encapContentType "id-smime-aa-encapContentType" +#define NID_id_smime_aa_encapContentType 217 +#define OBJ_id_smime_aa_encapContentType OBJ_id_smime_aa,6L + +#define SN_id_smime_aa_contentIdentifier "id-smime-aa-contentIdentifier" +#define NID_id_smime_aa_contentIdentifier 218 +#define OBJ_id_smime_aa_contentIdentifier OBJ_id_smime_aa,7L + +#define SN_id_smime_aa_macValue "id-smime-aa-macValue" +#define NID_id_smime_aa_macValue 219 +#define OBJ_id_smime_aa_macValue OBJ_id_smime_aa,8L + +#define SN_id_smime_aa_equivalentLabels "id-smime-aa-equivalentLabels" +#define NID_id_smime_aa_equivalentLabels 220 +#define OBJ_id_smime_aa_equivalentLabels OBJ_id_smime_aa,9L + +#define SN_id_smime_aa_contentReference "id-smime-aa-contentReference" +#define NID_id_smime_aa_contentReference 221 +#define OBJ_id_smime_aa_contentReference OBJ_id_smime_aa,10L + +#define SN_id_smime_aa_encrypKeyPref "id-smime-aa-encrypKeyPref" +#define NID_id_smime_aa_encrypKeyPref 222 +#define OBJ_id_smime_aa_encrypKeyPref OBJ_id_smime_aa,11L + +#define SN_id_smime_aa_signingCertificate "id-smime-aa-signingCertificate" +#define NID_id_smime_aa_signingCertificate 223 +#define OBJ_id_smime_aa_signingCertificate OBJ_id_smime_aa,12L + +#define SN_id_smime_aa_smimeEncryptCerts "id-smime-aa-smimeEncryptCerts" +#define NID_id_smime_aa_smimeEncryptCerts 224 +#define OBJ_id_smime_aa_smimeEncryptCerts OBJ_id_smime_aa,13L + +#define SN_id_smime_aa_timeStampToken "id-smime-aa-timeStampToken" +#define NID_id_smime_aa_timeStampToken 225 +#define OBJ_id_smime_aa_timeStampToken OBJ_id_smime_aa,14L + +#define SN_id_smime_aa_ets_sigPolicyId "id-smime-aa-ets-sigPolicyId" +#define NID_id_smime_aa_ets_sigPolicyId 226 +#define OBJ_id_smime_aa_ets_sigPolicyId OBJ_id_smime_aa,15L + +#define SN_id_smime_aa_ets_commitmentType "id-smime-aa-ets-commitmentType" +#define NID_id_smime_aa_ets_commitmentType 227 +#define OBJ_id_smime_aa_ets_commitmentType OBJ_id_smime_aa,16L + +#define SN_id_smime_aa_ets_signerLocation "id-smime-aa-ets-signerLocation" +#define NID_id_smime_aa_ets_signerLocation 228 +#define OBJ_id_smime_aa_ets_signerLocation OBJ_id_smime_aa,17L + +#define SN_id_smime_aa_ets_signerAttr "id-smime-aa-ets-signerAttr" +#define NID_id_smime_aa_ets_signerAttr 229 +#define OBJ_id_smime_aa_ets_signerAttr OBJ_id_smime_aa,18L + +#define SN_id_smime_aa_ets_otherSigCert "id-smime-aa-ets-otherSigCert" +#define NID_id_smime_aa_ets_otherSigCert 230 +#define OBJ_id_smime_aa_ets_otherSigCert OBJ_id_smime_aa,19L + +#define SN_id_smime_aa_ets_contentTimestamp "id-smime-aa-ets-contentTimestamp" +#define NID_id_smime_aa_ets_contentTimestamp 231 +#define OBJ_id_smime_aa_ets_contentTimestamp OBJ_id_smime_aa,20L + +#define SN_id_smime_aa_ets_CertificateRefs "id-smime-aa-ets-CertificateRefs" +#define NID_id_smime_aa_ets_CertificateRefs 232 +#define OBJ_id_smime_aa_ets_CertificateRefs OBJ_id_smime_aa,21L + +#define SN_id_smime_aa_ets_RevocationRefs "id-smime-aa-ets-RevocationRefs" +#define NID_id_smime_aa_ets_RevocationRefs 233 +#define OBJ_id_smime_aa_ets_RevocationRefs OBJ_id_smime_aa,22L + +#define SN_id_smime_aa_ets_certValues "id-smime-aa-ets-certValues" +#define NID_id_smime_aa_ets_certValues 234 +#define OBJ_id_smime_aa_ets_certValues OBJ_id_smime_aa,23L + +#define SN_id_smime_aa_ets_revocationValues "id-smime-aa-ets-revocationValues" +#define NID_id_smime_aa_ets_revocationValues 235 +#define OBJ_id_smime_aa_ets_revocationValues OBJ_id_smime_aa,24L + +#define SN_id_smime_aa_ets_escTimeStamp "id-smime-aa-ets-escTimeStamp" +#define NID_id_smime_aa_ets_escTimeStamp 236 +#define OBJ_id_smime_aa_ets_escTimeStamp OBJ_id_smime_aa,25L + +#define SN_id_smime_aa_ets_certCRLTimestamp "id-smime-aa-ets-certCRLTimestamp" +#define NID_id_smime_aa_ets_certCRLTimestamp 237 +#define OBJ_id_smime_aa_ets_certCRLTimestamp OBJ_id_smime_aa,26L + +#define SN_id_smime_aa_ets_archiveTimeStamp "id-smime-aa-ets-archiveTimeStamp" +#define NID_id_smime_aa_ets_archiveTimeStamp 238 +#define OBJ_id_smime_aa_ets_archiveTimeStamp OBJ_id_smime_aa,27L + +#define SN_id_smime_aa_signatureType "id-smime-aa-signatureType" +#define NID_id_smime_aa_signatureType 239 +#define OBJ_id_smime_aa_signatureType OBJ_id_smime_aa,28L + +#define SN_id_smime_aa_dvcs_dvc "id-smime-aa-dvcs-dvc" +#define NID_id_smime_aa_dvcs_dvc 240 +#define OBJ_id_smime_aa_dvcs_dvc OBJ_id_smime_aa,29L + +#define SN_id_smime_alg_ESDHwith3DES "id-smime-alg-ESDHwith3DES" +#define NID_id_smime_alg_ESDHwith3DES 241 +#define OBJ_id_smime_alg_ESDHwith3DES OBJ_id_smime_alg,1L + +#define SN_id_smime_alg_ESDHwithRC2 "id-smime-alg-ESDHwithRC2" +#define NID_id_smime_alg_ESDHwithRC2 242 +#define OBJ_id_smime_alg_ESDHwithRC2 OBJ_id_smime_alg,2L + +#define SN_id_smime_alg_3DESwrap "id-smime-alg-3DESwrap" +#define NID_id_smime_alg_3DESwrap 243 +#define OBJ_id_smime_alg_3DESwrap OBJ_id_smime_alg,3L + +#define SN_id_smime_alg_RC2wrap "id-smime-alg-RC2wrap" +#define NID_id_smime_alg_RC2wrap 244 +#define OBJ_id_smime_alg_RC2wrap OBJ_id_smime_alg,4L + +#define SN_id_smime_alg_ESDH "id-smime-alg-ESDH" +#define NID_id_smime_alg_ESDH 245 +#define OBJ_id_smime_alg_ESDH OBJ_id_smime_alg,5L + +#define SN_id_smime_alg_CMS3DESwrap "id-smime-alg-CMS3DESwrap" +#define NID_id_smime_alg_CMS3DESwrap 246 +#define OBJ_id_smime_alg_CMS3DESwrap OBJ_id_smime_alg,6L + +#define SN_id_smime_alg_CMSRC2wrap "id-smime-alg-CMSRC2wrap" +#define NID_id_smime_alg_CMSRC2wrap 247 +#define OBJ_id_smime_alg_CMSRC2wrap OBJ_id_smime_alg,7L + +#define SN_id_smime_cd_ldap "id-smime-cd-ldap" +#define NID_id_smime_cd_ldap 248 +#define OBJ_id_smime_cd_ldap OBJ_id_smime_cd,1L + +#define SN_id_smime_spq_ets_sqt_uri "id-smime-spq-ets-sqt-uri" +#define NID_id_smime_spq_ets_sqt_uri 249 +#define OBJ_id_smime_spq_ets_sqt_uri OBJ_id_smime_spq,1L + +#define SN_id_smime_spq_ets_sqt_unotice "id-smime-spq-ets-sqt-unotice" +#define NID_id_smime_spq_ets_sqt_unotice 250 +#define OBJ_id_smime_spq_ets_sqt_unotice OBJ_id_smime_spq,2L + +#define SN_id_smime_cti_ets_proofOfOrigin "id-smime-cti-ets-proofOfOrigin" +#define NID_id_smime_cti_ets_proofOfOrigin 251 +#define OBJ_id_smime_cti_ets_proofOfOrigin OBJ_id_smime_cti,1L + +#define SN_id_smime_cti_ets_proofOfReceipt "id-smime-cti-ets-proofOfReceipt" +#define NID_id_smime_cti_ets_proofOfReceipt 252 +#define OBJ_id_smime_cti_ets_proofOfReceipt OBJ_id_smime_cti,2L + +#define SN_id_smime_cti_ets_proofOfDelivery "id-smime-cti-ets-proofOfDelivery" +#define NID_id_smime_cti_ets_proofOfDelivery 253 +#define OBJ_id_smime_cti_ets_proofOfDelivery OBJ_id_smime_cti,3L + +#define SN_id_smime_cti_ets_proofOfSender "id-smime-cti-ets-proofOfSender" +#define NID_id_smime_cti_ets_proofOfSender 254 +#define OBJ_id_smime_cti_ets_proofOfSender OBJ_id_smime_cti,4L + +#define SN_id_smime_cti_ets_proofOfApproval "id-smime-cti-ets-proofOfApproval" +#define NID_id_smime_cti_ets_proofOfApproval 255 +#define OBJ_id_smime_cti_ets_proofOfApproval OBJ_id_smime_cti,5L + +#define SN_id_smime_cti_ets_proofOfCreation "id-smime-cti-ets-proofOfCreation" +#define NID_id_smime_cti_ets_proofOfCreation 256 +#define OBJ_id_smime_cti_ets_proofOfCreation OBJ_id_smime_cti,6L + +#define LN_friendlyName "friendlyName" +#define NID_friendlyName 156 +#define OBJ_friendlyName OBJ_pkcs9,20L + +#define LN_localKeyID "localKeyID" +#define NID_localKeyID 157 +#define OBJ_localKeyID OBJ_pkcs9,21L + +#define SN_ms_csp_name "CSPName" +#define LN_ms_csp_name "Microsoft CSP Name" +#define NID_ms_csp_name 417 +#define OBJ_ms_csp_name 1L,3L,6L,1L,4L,1L,311L,17L,1L + +#define OBJ_certTypes OBJ_pkcs9,22L + +#define LN_x509Certificate "x509Certificate" +#define NID_x509Certificate 158 +#define OBJ_x509Certificate OBJ_certTypes,1L + +#define LN_sdsiCertificate "sdsiCertificate" +#define NID_sdsiCertificate 159 +#define OBJ_sdsiCertificate OBJ_certTypes,2L + +#define OBJ_crlTypes OBJ_pkcs9,23L + +#define LN_x509Crl "x509Crl" +#define NID_x509Crl 160 +#define OBJ_x509Crl OBJ_crlTypes,1L + +#define OBJ_pkcs12 OBJ_pkcs,12L + +#define OBJ_pkcs12_pbeids OBJ_pkcs12,1L + +#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" +#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" +#define NID_pbe_WithSHA1And128BitRC4 144 +#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids,1L + +#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" +#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" +#define NID_pbe_WithSHA1And40BitRC4 145 +#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids,2L + +#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" +#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 +#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids,3L + +#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" +#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 +#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids,4L + +#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" +#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" +#define NID_pbe_WithSHA1And128BitRC2_CBC 148 +#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids,5L + +#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" +#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" +#define NID_pbe_WithSHA1And40BitRC2_CBC 149 +#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids,6L + +#define OBJ_pkcs12_Version1 OBJ_pkcs12,10L + +#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1,1L + +#define LN_keyBag "keyBag" +#define NID_keyBag 150 +#define OBJ_keyBag OBJ_pkcs12_BagIds,1L + +#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" +#define NID_pkcs8ShroudedKeyBag 151 +#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds,2L + +#define LN_certBag "certBag" +#define NID_certBag 152 +#define OBJ_certBag OBJ_pkcs12_BagIds,3L + +#define LN_crlBag "crlBag" +#define NID_crlBag 153 +#define OBJ_crlBag OBJ_pkcs12_BagIds,4L + +#define LN_secretBag "secretBag" +#define NID_secretBag 154 +#define OBJ_secretBag OBJ_pkcs12_BagIds,5L + +#define LN_safeContentsBag "safeContentsBag" +#define NID_safeContentsBag 155 +#define OBJ_safeContentsBag OBJ_pkcs12_BagIds,6L + +#define SN_md2 "MD2" +#define LN_md2 "md2" +#define NID_md2 3 +#define OBJ_md2 OBJ_rsadsi,2L,2L + +#define SN_md4 "MD4" +#define LN_md4 "md4" +#define NID_md4 257 +#define OBJ_md4 OBJ_rsadsi,2L,4L + +#define SN_md5 "MD5" +#define LN_md5 "md5" +#define NID_md5 4 +#define OBJ_md5 OBJ_rsadsi,2L,5L + +#define SN_md5_sha1 "MD5-SHA1" +#define LN_md5_sha1 "md5-sha1" +#define NID_md5_sha1 114 + +#define LN_hmacWithSHA1 "hmacWithSHA1" +#define NID_hmacWithSHA1 163 +#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L + +#define SN_rc2_cbc "RC2-CBC" +#define LN_rc2_cbc "rc2-cbc" +#define NID_rc2_cbc 37 +#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L + +#define SN_rc2_ecb "RC2-ECB" +#define LN_rc2_ecb "rc2-ecb" +#define NID_rc2_ecb 38 + +#define SN_rc2_cfb64 "RC2-CFB" +#define LN_rc2_cfb64 "rc2-cfb" +#define NID_rc2_cfb64 39 + +#define SN_rc2_ofb64 "RC2-OFB" +#define LN_rc2_ofb64 "rc2-ofb" +#define NID_rc2_ofb64 40 + +#define SN_rc2_40_cbc "RC2-40-CBC" +#define LN_rc2_40_cbc "rc2-40-cbc" +#define NID_rc2_40_cbc 98 + +#define SN_rc2_64_cbc "RC2-64-CBC" +#define LN_rc2_64_cbc "rc2-64-cbc" +#define NID_rc2_64_cbc 166 + +#define SN_rc4 "RC4" +#define LN_rc4 "rc4" +#define NID_rc4 5 +#define OBJ_rc4 OBJ_rsadsi,3L,4L + +#define SN_rc4_40 "RC4-40" +#define LN_rc4_40 "rc4-40" +#define NID_rc4_40 97 + +#define SN_des_ede3_cbc "DES-EDE3-CBC" +#define LN_des_ede3_cbc "des-ede3-cbc" +#define NID_des_ede3_cbc 44 +#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L + +#define SN_rc5_cbc "RC5-CBC" +#define LN_rc5_cbc "rc5-cbc" +#define NID_rc5_cbc 120 +#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L + +#define SN_rc5_ecb "RC5-ECB" +#define LN_rc5_ecb "rc5-ecb" +#define NID_rc5_ecb 121 + +#define SN_rc5_cfb64 "RC5-CFB" +#define LN_rc5_cfb64 "rc5-cfb" +#define NID_rc5_cfb64 122 + +#define SN_rc5_ofb64 "RC5-OFB" +#define LN_rc5_ofb64 "rc5-ofb" +#define NID_rc5_ofb64 123 + +#define SN_ms_ext_req "msExtReq" +#define LN_ms_ext_req "Microsoft Extension Request" +#define NID_ms_ext_req 171 +#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L + +#define SN_ms_code_ind "msCodeInd" +#define LN_ms_code_ind "Microsoft Individual Code Signing" +#define NID_ms_code_ind 134 +#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L + +#define SN_ms_code_com "msCodeCom" +#define LN_ms_code_com "Microsoft Commercial Code Signing" +#define NID_ms_code_com 135 +#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L + +#define SN_ms_ctl_sign "msCTLSign" +#define LN_ms_ctl_sign "Microsoft Trust List Signing" +#define NID_ms_ctl_sign 136 +#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L + +#define SN_ms_sgc "msSGC" +#define LN_ms_sgc "Microsoft Server Gated Crypto" +#define NID_ms_sgc 137 +#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L + +#define SN_ms_efs "msEFS" +#define LN_ms_efs "Microsoft Encrypted File System" +#define NID_ms_efs 138 +#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L + +#define SN_ms_smartcard_login "msSmartcardLogin" +#define LN_ms_smartcard_login "Microsoft Smartcardlogin" +#define NID_ms_smartcard_login 648 +#define OBJ_ms_smartcard_login 1L,3L,6L,1L,4L,1L,311L,20L,2L,2L + +#define SN_ms_upn "msUPN" +#define LN_ms_upn "Microsoft Universal Principal Name" +#define NID_ms_upn 649 +#define OBJ_ms_upn 1L,3L,6L,1L,4L,1L,311L,20L,2L,3L + +#define SN_idea_cbc "IDEA-CBC" +#define LN_idea_cbc "idea-cbc" +#define NID_idea_cbc 34 +#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L + +#define SN_idea_ecb "IDEA-ECB" +#define LN_idea_ecb "idea-ecb" +#define NID_idea_ecb 36 + +#define SN_idea_cfb64 "IDEA-CFB" +#define LN_idea_cfb64 "idea-cfb" +#define NID_idea_cfb64 35 + +#define SN_idea_ofb64 "IDEA-OFB" +#define LN_idea_ofb64 "idea-ofb" +#define NID_idea_ofb64 46 + +#define SN_bf_cbc "BF-CBC" +#define LN_bf_cbc "bf-cbc" +#define NID_bf_cbc 91 +#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L + +#define SN_bf_ecb "BF-ECB" +#define LN_bf_ecb "bf-ecb" +#define NID_bf_ecb 92 + +#define SN_bf_cfb64 "BF-CFB" +#define LN_bf_cfb64 "bf-cfb" +#define NID_bf_cfb64 93 + +#define SN_bf_ofb64 "BF-OFB" +#define LN_bf_ofb64 "bf-ofb" +#define NID_bf_ofb64 94 + +#define SN_id_pkix "PKIX" +#define NID_id_pkix 127 +#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L + +#define SN_id_pkix_mod "id-pkix-mod" +#define NID_id_pkix_mod 258 +#define OBJ_id_pkix_mod OBJ_id_pkix,0L + +#define SN_id_pe "id-pe" +#define NID_id_pe 175 +#define OBJ_id_pe OBJ_id_pkix,1L + +#define SN_id_qt "id-qt" +#define NID_id_qt 259 +#define OBJ_id_qt OBJ_id_pkix,2L + +#define SN_id_kp "id-kp" +#define NID_id_kp 128 +#define OBJ_id_kp OBJ_id_pkix,3L + +#define SN_id_it "id-it" +#define NID_id_it 260 +#define OBJ_id_it OBJ_id_pkix,4L + +#define SN_id_pkip "id-pkip" +#define NID_id_pkip 261 +#define OBJ_id_pkip OBJ_id_pkix,5L + +#define SN_id_alg "id-alg" +#define NID_id_alg 262 +#define OBJ_id_alg OBJ_id_pkix,6L + +#define SN_id_cmc "id-cmc" +#define NID_id_cmc 263 +#define OBJ_id_cmc OBJ_id_pkix,7L + +#define SN_id_on "id-on" +#define NID_id_on 264 +#define OBJ_id_on OBJ_id_pkix,8L + +#define SN_id_pda "id-pda" +#define NID_id_pda 265 +#define OBJ_id_pda OBJ_id_pkix,9L + +#define SN_id_aca "id-aca" +#define NID_id_aca 266 +#define OBJ_id_aca OBJ_id_pkix,10L + +#define SN_id_qcs "id-qcs" +#define NID_id_qcs 267 +#define OBJ_id_qcs OBJ_id_pkix,11L + +#define SN_id_cct "id-cct" +#define NID_id_cct 268 +#define OBJ_id_cct OBJ_id_pkix,12L + +#define SN_id_ppl "id-ppl" +#define NID_id_ppl 662 +#define OBJ_id_ppl OBJ_id_pkix,21L + +#define SN_id_ad "id-ad" +#define NID_id_ad 176 +#define OBJ_id_ad OBJ_id_pkix,48L + +#define SN_id_pkix1_explicit_88 "id-pkix1-explicit-88" +#define NID_id_pkix1_explicit_88 269 +#define OBJ_id_pkix1_explicit_88 OBJ_id_pkix_mod,1L + +#define SN_id_pkix1_implicit_88 "id-pkix1-implicit-88" +#define NID_id_pkix1_implicit_88 270 +#define OBJ_id_pkix1_implicit_88 OBJ_id_pkix_mod,2L + +#define SN_id_pkix1_explicit_93 "id-pkix1-explicit-93" +#define NID_id_pkix1_explicit_93 271 +#define OBJ_id_pkix1_explicit_93 OBJ_id_pkix_mod,3L + +#define SN_id_pkix1_implicit_93 "id-pkix1-implicit-93" +#define NID_id_pkix1_implicit_93 272 +#define OBJ_id_pkix1_implicit_93 OBJ_id_pkix_mod,4L + +#define SN_id_mod_crmf "id-mod-crmf" +#define NID_id_mod_crmf 273 +#define OBJ_id_mod_crmf OBJ_id_pkix_mod,5L + +#define SN_id_mod_cmc "id-mod-cmc" +#define NID_id_mod_cmc 274 +#define OBJ_id_mod_cmc OBJ_id_pkix_mod,6L + +#define SN_id_mod_kea_profile_88 "id-mod-kea-profile-88" +#define NID_id_mod_kea_profile_88 275 +#define OBJ_id_mod_kea_profile_88 OBJ_id_pkix_mod,7L + +#define SN_id_mod_kea_profile_93 "id-mod-kea-profile-93" +#define NID_id_mod_kea_profile_93 276 +#define OBJ_id_mod_kea_profile_93 OBJ_id_pkix_mod,8L + +#define SN_id_mod_cmp "id-mod-cmp" +#define NID_id_mod_cmp 277 +#define OBJ_id_mod_cmp OBJ_id_pkix_mod,9L + +#define SN_id_mod_qualified_cert_88 "id-mod-qualified-cert-88" +#define NID_id_mod_qualified_cert_88 278 +#define OBJ_id_mod_qualified_cert_88 OBJ_id_pkix_mod,10L + +#define SN_id_mod_qualified_cert_93 "id-mod-qualified-cert-93" +#define NID_id_mod_qualified_cert_93 279 +#define OBJ_id_mod_qualified_cert_93 OBJ_id_pkix_mod,11L + +#define SN_id_mod_attribute_cert "id-mod-attribute-cert" +#define NID_id_mod_attribute_cert 280 +#define OBJ_id_mod_attribute_cert OBJ_id_pkix_mod,12L + +#define SN_id_mod_timestamp_protocol "id-mod-timestamp-protocol" +#define NID_id_mod_timestamp_protocol 281 +#define OBJ_id_mod_timestamp_protocol OBJ_id_pkix_mod,13L + +#define SN_id_mod_ocsp "id-mod-ocsp" +#define NID_id_mod_ocsp 282 +#define OBJ_id_mod_ocsp OBJ_id_pkix_mod,14L + +#define SN_id_mod_dvcs "id-mod-dvcs" +#define NID_id_mod_dvcs 283 +#define OBJ_id_mod_dvcs OBJ_id_pkix_mod,15L + +#define SN_id_mod_cmp2000 "id-mod-cmp2000" +#define NID_id_mod_cmp2000 284 +#define OBJ_id_mod_cmp2000 OBJ_id_pkix_mod,16L + +#define SN_info_access "authorityInfoAccess" +#define LN_info_access "Authority Information Access" +#define NID_info_access 177 +#define OBJ_info_access OBJ_id_pe,1L + +#define SN_biometricInfo "biometricInfo" +#define LN_biometricInfo "Biometric Info" +#define NID_biometricInfo 285 +#define OBJ_biometricInfo OBJ_id_pe,2L + +#define SN_qcStatements "qcStatements" +#define NID_qcStatements 286 +#define OBJ_qcStatements OBJ_id_pe,3L + +#define SN_ac_auditEntity "ac-auditEntity" +#define NID_ac_auditEntity 287 +#define OBJ_ac_auditEntity OBJ_id_pe,4L + +#define SN_ac_targeting "ac-targeting" +#define NID_ac_targeting 288 +#define OBJ_ac_targeting OBJ_id_pe,5L + +#define SN_aaControls "aaControls" +#define NID_aaControls 289 +#define OBJ_aaControls OBJ_id_pe,6L + +#define SN_sbgp_ipAddrBlock "sbgp-ipAddrBlock" +#define NID_sbgp_ipAddrBlock 290 +#define OBJ_sbgp_ipAddrBlock OBJ_id_pe,7L + +#define SN_sbgp_autonomousSysNum "sbgp-autonomousSysNum" +#define NID_sbgp_autonomousSysNum 291 +#define OBJ_sbgp_autonomousSysNum OBJ_id_pe,8L + +#define SN_sbgp_routerIdentifier "sbgp-routerIdentifier" +#define NID_sbgp_routerIdentifier 292 +#define OBJ_sbgp_routerIdentifier OBJ_id_pe,9L + +#define SN_ac_proxying "ac-proxying" +#define NID_ac_proxying 397 +#define OBJ_ac_proxying OBJ_id_pe,10L + +#define SN_sinfo_access "subjectInfoAccess" +#define LN_sinfo_access "Subject Information Access" +#define NID_sinfo_access 398 +#define OBJ_sinfo_access OBJ_id_pe,11L + +#define SN_proxyCertInfo "proxyCertInfo" +#define LN_proxyCertInfo "Proxy Certificate Information" +#define NID_proxyCertInfo 663 +#define OBJ_proxyCertInfo OBJ_id_pe,14L + +#define SN_id_qt_cps "id-qt-cps" +#define LN_id_qt_cps "Policy Qualifier CPS" +#define NID_id_qt_cps 164 +#define OBJ_id_qt_cps OBJ_id_qt,1L + +#define SN_id_qt_unotice "id-qt-unotice" +#define LN_id_qt_unotice "Policy Qualifier User Notice" +#define NID_id_qt_unotice 165 +#define OBJ_id_qt_unotice OBJ_id_qt,2L + +#define SN_textNotice "textNotice" +#define NID_textNotice 293 +#define OBJ_textNotice OBJ_id_qt,3L + +#define SN_server_auth "serverAuth" +#define LN_server_auth "TLS Web Server Authentication" +#define NID_server_auth 129 +#define OBJ_server_auth OBJ_id_kp,1L + +#define SN_client_auth "clientAuth" +#define LN_client_auth "TLS Web Client Authentication" +#define NID_client_auth 130 +#define OBJ_client_auth OBJ_id_kp,2L + +#define SN_code_sign "codeSigning" +#define LN_code_sign "Code Signing" +#define NID_code_sign 131 +#define OBJ_code_sign OBJ_id_kp,3L + +#define SN_email_protect "emailProtection" +#define LN_email_protect "E-mail Protection" +#define NID_email_protect 132 +#define OBJ_email_protect OBJ_id_kp,4L + +#define SN_ipsecEndSystem "ipsecEndSystem" +#define LN_ipsecEndSystem "IPSec End System" +#define NID_ipsecEndSystem 294 +#define OBJ_ipsecEndSystem OBJ_id_kp,5L + +#define SN_ipsecTunnel "ipsecTunnel" +#define LN_ipsecTunnel "IPSec Tunnel" +#define NID_ipsecTunnel 295 +#define OBJ_ipsecTunnel OBJ_id_kp,6L + +#define SN_ipsecUser "ipsecUser" +#define LN_ipsecUser "IPSec User" +#define NID_ipsecUser 296 +#define OBJ_ipsecUser OBJ_id_kp,7L + +#define SN_time_stamp "timeStamping" +#define LN_time_stamp "Time Stamping" +#define NID_time_stamp 133 +#define OBJ_time_stamp OBJ_id_kp,8L + +#define SN_OCSP_sign "OCSPSigning" +#define LN_OCSP_sign "OCSP Signing" +#define NID_OCSP_sign 180 +#define OBJ_OCSP_sign OBJ_id_kp,9L + +#define SN_dvcs "DVCS" +#define LN_dvcs "dvcs" +#define NID_dvcs 297 +#define OBJ_dvcs OBJ_id_kp,10L + +#define SN_id_it_caProtEncCert "id-it-caProtEncCert" +#define NID_id_it_caProtEncCert 298 +#define OBJ_id_it_caProtEncCert OBJ_id_it,1L + +#define SN_id_it_signKeyPairTypes "id-it-signKeyPairTypes" +#define NID_id_it_signKeyPairTypes 299 +#define OBJ_id_it_signKeyPairTypes OBJ_id_it,2L + +#define SN_id_it_encKeyPairTypes "id-it-encKeyPairTypes" +#define NID_id_it_encKeyPairTypes 300 +#define OBJ_id_it_encKeyPairTypes OBJ_id_it,3L + +#define SN_id_it_preferredSymmAlg "id-it-preferredSymmAlg" +#define NID_id_it_preferredSymmAlg 301 +#define OBJ_id_it_preferredSymmAlg OBJ_id_it,4L + +#define SN_id_it_caKeyUpdateInfo "id-it-caKeyUpdateInfo" +#define NID_id_it_caKeyUpdateInfo 302 +#define OBJ_id_it_caKeyUpdateInfo OBJ_id_it,5L + +#define SN_id_it_currentCRL "id-it-currentCRL" +#define NID_id_it_currentCRL 303 +#define OBJ_id_it_currentCRL OBJ_id_it,6L + +#define SN_id_it_unsupportedOIDs "id-it-unsupportedOIDs" +#define NID_id_it_unsupportedOIDs 304 +#define OBJ_id_it_unsupportedOIDs OBJ_id_it,7L + +#define SN_id_it_subscriptionRequest "id-it-subscriptionRequest" +#define NID_id_it_subscriptionRequest 305 +#define OBJ_id_it_subscriptionRequest OBJ_id_it,8L + +#define SN_id_it_subscriptionResponse "id-it-subscriptionResponse" +#define NID_id_it_subscriptionResponse 306 +#define OBJ_id_it_subscriptionResponse OBJ_id_it,9L + +#define SN_id_it_keyPairParamReq "id-it-keyPairParamReq" +#define NID_id_it_keyPairParamReq 307 +#define OBJ_id_it_keyPairParamReq OBJ_id_it,10L + +#define SN_id_it_keyPairParamRep "id-it-keyPairParamRep" +#define NID_id_it_keyPairParamRep 308 +#define OBJ_id_it_keyPairParamRep OBJ_id_it,11L + +#define SN_id_it_revPassphrase "id-it-revPassphrase" +#define NID_id_it_revPassphrase 309 +#define OBJ_id_it_revPassphrase OBJ_id_it,12L + +#define SN_id_it_implicitConfirm "id-it-implicitConfirm" +#define NID_id_it_implicitConfirm 310 +#define OBJ_id_it_implicitConfirm OBJ_id_it,13L + +#define SN_id_it_confirmWaitTime "id-it-confirmWaitTime" +#define NID_id_it_confirmWaitTime 311 +#define OBJ_id_it_confirmWaitTime OBJ_id_it,14L + +#define SN_id_it_origPKIMessage "id-it-origPKIMessage" +#define NID_id_it_origPKIMessage 312 +#define OBJ_id_it_origPKIMessage OBJ_id_it,15L + +#define SN_id_regCtrl "id-regCtrl" +#define NID_id_regCtrl 313 +#define OBJ_id_regCtrl OBJ_id_pkip,1L + +#define SN_id_regInfo "id-regInfo" +#define NID_id_regInfo 314 +#define OBJ_id_regInfo OBJ_id_pkip,2L + +#define SN_id_regCtrl_regToken "id-regCtrl-regToken" +#define NID_id_regCtrl_regToken 315 +#define OBJ_id_regCtrl_regToken OBJ_id_regCtrl,1L + +#define SN_id_regCtrl_authenticator "id-regCtrl-authenticator" +#define NID_id_regCtrl_authenticator 316 +#define OBJ_id_regCtrl_authenticator OBJ_id_regCtrl,2L + +#define SN_id_regCtrl_pkiPublicationInfo "id-regCtrl-pkiPublicationInfo" +#define NID_id_regCtrl_pkiPublicationInfo 317 +#define OBJ_id_regCtrl_pkiPublicationInfo OBJ_id_regCtrl,3L + +#define SN_id_regCtrl_pkiArchiveOptions "id-regCtrl-pkiArchiveOptions" +#define NID_id_regCtrl_pkiArchiveOptions 318 +#define OBJ_id_regCtrl_pkiArchiveOptions OBJ_id_regCtrl,4L + +#define SN_id_regCtrl_oldCertID "id-regCtrl-oldCertID" +#define NID_id_regCtrl_oldCertID 319 +#define OBJ_id_regCtrl_oldCertID OBJ_id_regCtrl,5L + +#define SN_id_regCtrl_protocolEncrKey "id-regCtrl-protocolEncrKey" +#define NID_id_regCtrl_protocolEncrKey 320 +#define OBJ_id_regCtrl_protocolEncrKey OBJ_id_regCtrl,6L + +#define SN_id_regInfo_utf8Pairs "id-regInfo-utf8Pairs" +#define NID_id_regInfo_utf8Pairs 321 +#define OBJ_id_regInfo_utf8Pairs OBJ_id_regInfo,1L + +#define SN_id_regInfo_certReq "id-regInfo-certReq" +#define NID_id_regInfo_certReq 322 +#define OBJ_id_regInfo_certReq OBJ_id_regInfo,2L + +#define SN_id_alg_des40 "id-alg-des40" +#define NID_id_alg_des40 323 +#define OBJ_id_alg_des40 OBJ_id_alg,1L + +#define SN_id_alg_noSignature "id-alg-noSignature" +#define NID_id_alg_noSignature 324 +#define OBJ_id_alg_noSignature OBJ_id_alg,2L + +#define SN_id_alg_dh_sig_hmac_sha1 "id-alg-dh-sig-hmac-sha1" +#define NID_id_alg_dh_sig_hmac_sha1 325 +#define OBJ_id_alg_dh_sig_hmac_sha1 OBJ_id_alg,3L + +#define SN_id_alg_dh_pop "id-alg-dh-pop" +#define NID_id_alg_dh_pop 326 +#define OBJ_id_alg_dh_pop OBJ_id_alg,4L + +#define SN_id_cmc_statusInfo "id-cmc-statusInfo" +#define NID_id_cmc_statusInfo 327 +#define OBJ_id_cmc_statusInfo OBJ_id_cmc,1L + +#define SN_id_cmc_identification "id-cmc-identification" +#define NID_id_cmc_identification 328 +#define OBJ_id_cmc_identification OBJ_id_cmc,2L + +#define SN_id_cmc_identityProof "id-cmc-identityProof" +#define NID_id_cmc_identityProof 329 +#define OBJ_id_cmc_identityProof OBJ_id_cmc,3L + +#define SN_id_cmc_dataReturn "id-cmc-dataReturn" +#define NID_id_cmc_dataReturn 330 +#define OBJ_id_cmc_dataReturn OBJ_id_cmc,4L + +#define SN_id_cmc_transactionId "id-cmc-transactionId" +#define NID_id_cmc_transactionId 331 +#define OBJ_id_cmc_transactionId OBJ_id_cmc,5L + +#define SN_id_cmc_senderNonce "id-cmc-senderNonce" +#define NID_id_cmc_senderNonce 332 +#define OBJ_id_cmc_senderNonce OBJ_id_cmc,6L + +#define SN_id_cmc_recipientNonce "id-cmc-recipientNonce" +#define NID_id_cmc_recipientNonce 333 +#define OBJ_id_cmc_recipientNonce OBJ_id_cmc,7L + +#define SN_id_cmc_addExtensions "id-cmc-addExtensions" +#define NID_id_cmc_addExtensions 334 +#define OBJ_id_cmc_addExtensions OBJ_id_cmc,8L + +#define SN_id_cmc_encryptedPOP "id-cmc-encryptedPOP" +#define NID_id_cmc_encryptedPOP 335 +#define OBJ_id_cmc_encryptedPOP OBJ_id_cmc,9L + +#define SN_id_cmc_decryptedPOP "id-cmc-decryptedPOP" +#define NID_id_cmc_decryptedPOP 336 +#define OBJ_id_cmc_decryptedPOP OBJ_id_cmc,10L + +#define SN_id_cmc_lraPOPWitness "id-cmc-lraPOPWitness" +#define NID_id_cmc_lraPOPWitness 337 +#define OBJ_id_cmc_lraPOPWitness OBJ_id_cmc,11L + +#define SN_id_cmc_getCert "id-cmc-getCert" +#define NID_id_cmc_getCert 338 +#define OBJ_id_cmc_getCert OBJ_id_cmc,15L + +#define SN_id_cmc_getCRL "id-cmc-getCRL" +#define NID_id_cmc_getCRL 339 +#define OBJ_id_cmc_getCRL OBJ_id_cmc,16L + +#define SN_id_cmc_revokeRequest "id-cmc-revokeRequest" +#define NID_id_cmc_revokeRequest 340 +#define OBJ_id_cmc_revokeRequest OBJ_id_cmc,17L + +#define SN_id_cmc_regInfo "id-cmc-regInfo" +#define NID_id_cmc_regInfo 341 +#define OBJ_id_cmc_regInfo OBJ_id_cmc,18L + +#define SN_id_cmc_responseInfo "id-cmc-responseInfo" +#define NID_id_cmc_responseInfo 342 +#define OBJ_id_cmc_responseInfo OBJ_id_cmc,19L + +#define SN_id_cmc_queryPending "id-cmc-queryPending" +#define NID_id_cmc_queryPending 343 +#define OBJ_id_cmc_queryPending OBJ_id_cmc,21L + +#define SN_id_cmc_popLinkRandom "id-cmc-popLinkRandom" +#define NID_id_cmc_popLinkRandom 344 +#define OBJ_id_cmc_popLinkRandom OBJ_id_cmc,22L + +#define SN_id_cmc_popLinkWitness "id-cmc-popLinkWitness" +#define NID_id_cmc_popLinkWitness 345 +#define OBJ_id_cmc_popLinkWitness OBJ_id_cmc,23L + +#define SN_id_cmc_confirmCertAcceptance "id-cmc-confirmCertAcceptance" +#define NID_id_cmc_confirmCertAcceptance 346 +#define OBJ_id_cmc_confirmCertAcceptance OBJ_id_cmc,24L + +#define SN_id_on_personalData "id-on-personalData" +#define NID_id_on_personalData 347 +#define OBJ_id_on_personalData OBJ_id_on,1L + +#define SN_id_pda_dateOfBirth "id-pda-dateOfBirth" +#define NID_id_pda_dateOfBirth 348 +#define OBJ_id_pda_dateOfBirth OBJ_id_pda,1L + +#define SN_id_pda_placeOfBirth "id-pda-placeOfBirth" +#define NID_id_pda_placeOfBirth 349 +#define OBJ_id_pda_placeOfBirth OBJ_id_pda,2L + +#define SN_id_pda_gender "id-pda-gender" +#define NID_id_pda_gender 351 +#define OBJ_id_pda_gender OBJ_id_pda,3L + +#define SN_id_pda_countryOfCitizenship "id-pda-countryOfCitizenship" +#define NID_id_pda_countryOfCitizenship 352 +#define OBJ_id_pda_countryOfCitizenship OBJ_id_pda,4L + +#define SN_id_pda_countryOfResidence "id-pda-countryOfResidence" +#define NID_id_pda_countryOfResidence 353 +#define OBJ_id_pda_countryOfResidence OBJ_id_pda,5L + +#define SN_id_aca_authenticationInfo "id-aca-authenticationInfo" +#define NID_id_aca_authenticationInfo 354 +#define OBJ_id_aca_authenticationInfo OBJ_id_aca,1L + +#define SN_id_aca_accessIdentity "id-aca-accessIdentity" +#define NID_id_aca_accessIdentity 355 +#define OBJ_id_aca_accessIdentity OBJ_id_aca,2L + +#define SN_id_aca_chargingIdentity "id-aca-chargingIdentity" +#define NID_id_aca_chargingIdentity 356 +#define OBJ_id_aca_chargingIdentity OBJ_id_aca,3L + +#define SN_id_aca_group "id-aca-group" +#define NID_id_aca_group 357 +#define OBJ_id_aca_group OBJ_id_aca,4L + +#define SN_id_aca_role "id-aca-role" +#define NID_id_aca_role 358 +#define OBJ_id_aca_role OBJ_id_aca,5L + +#define SN_id_aca_encAttrs "id-aca-encAttrs" +#define NID_id_aca_encAttrs 399 +#define OBJ_id_aca_encAttrs OBJ_id_aca,6L + +#define SN_id_qcs_pkixQCSyntax_v1 "id-qcs-pkixQCSyntax-v1" +#define NID_id_qcs_pkixQCSyntax_v1 359 +#define OBJ_id_qcs_pkixQCSyntax_v1 OBJ_id_qcs,1L + +#define SN_id_cct_crs "id-cct-crs" +#define NID_id_cct_crs 360 +#define OBJ_id_cct_crs OBJ_id_cct,1L + +#define SN_id_cct_PKIData "id-cct-PKIData" +#define NID_id_cct_PKIData 361 +#define OBJ_id_cct_PKIData OBJ_id_cct,2L + +#define SN_id_cct_PKIResponse "id-cct-PKIResponse" +#define NID_id_cct_PKIResponse 362 +#define OBJ_id_cct_PKIResponse OBJ_id_cct,3L + +#define SN_id_ppl_anyLanguage "id-ppl-anyLanguage" +#define LN_id_ppl_anyLanguage "Any language" +#define NID_id_ppl_anyLanguage 664 +#define OBJ_id_ppl_anyLanguage OBJ_id_ppl,0L + +#define SN_id_ppl_inheritAll "id-ppl-inheritAll" +#define LN_id_ppl_inheritAll "Inherit all" +#define NID_id_ppl_inheritAll 665 +#define OBJ_id_ppl_inheritAll OBJ_id_ppl,1L + +#define SN_Independent "id-ppl-independent" +#define LN_Independent "Independent" +#define NID_Independent 667 +#define OBJ_Independent OBJ_id_ppl,2L + +#define SN_ad_OCSP "OCSP" +#define LN_ad_OCSP "OCSP" +#define NID_ad_OCSP 178 +#define OBJ_ad_OCSP OBJ_id_ad,1L + +#define SN_ad_ca_issuers "caIssuers" +#define LN_ad_ca_issuers "CA Issuers" +#define NID_ad_ca_issuers 179 +#define OBJ_ad_ca_issuers OBJ_id_ad,2L + +#define SN_ad_timeStamping "ad_timestamping" +#define LN_ad_timeStamping "AD Time Stamping" +#define NID_ad_timeStamping 363 +#define OBJ_ad_timeStamping OBJ_id_ad,3L + +#define SN_ad_dvcs "AD_DVCS" +#define LN_ad_dvcs "ad dvcs" +#define NID_ad_dvcs 364 +#define OBJ_ad_dvcs OBJ_id_ad,4L + +#define OBJ_id_pkix_OCSP OBJ_ad_OCSP + +#define SN_id_pkix_OCSP_basic "basicOCSPResponse" +#define LN_id_pkix_OCSP_basic "Basic OCSP Response" +#define NID_id_pkix_OCSP_basic 365 +#define OBJ_id_pkix_OCSP_basic OBJ_id_pkix_OCSP,1L + +#define SN_id_pkix_OCSP_Nonce "Nonce" +#define LN_id_pkix_OCSP_Nonce "OCSP Nonce" +#define NID_id_pkix_OCSP_Nonce 366 +#define OBJ_id_pkix_OCSP_Nonce OBJ_id_pkix_OCSP,2L + +#define SN_id_pkix_OCSP_CrlID "CrlID" +#define LN_id_pkix_OCSP_CrlID "OCSP CRL ID" +#define NID_id_pkix_OCSP_CrlID 367 +#define OBJ_id_pkix_OCSP_CrlID OBJ_id_pkix_OCSP,3L + +#define SN_id_pkix_OCSP_acceptableResponses "acceptableResponses" +#define LN_id_pkix_OCSP_acceptableResponses "Acceptable OCSP Responses" +#define NID_id_pkix_OCSP_acceptableResponses 368 +#define OBJ_id_pkix_OCSP_acceptableResponses OBJ_id_pkix_OCSP,4L + +#define SN_id_pkix_OCSP_noCheck "noCheck" +#define LN_id_pkix_OCSP_noCheck "OCSP No Check" +#define NID_id_pkix_OCSP_noCheck 369 +#define OBJ_id_pkix_OCSP_noCheck OBJ_id_pkix_OCSP,5L + +#define SN_id_pkix_OCSP_archiveCutoff "archiveCutoff" +#define LN_id_pkix_OCSP_archiveCutoff "OCSP Archive Cutoff" +#define NID_id_pkix_OCSP_archiveCutoff 370 +#define OBJ_id_pkix_OCSP_archiveCutoff OBJ_id_pkix_OCSP,6L + +#define SN_id_pkix_OCSP_serviceLocator "serviceLocator" +#define LN_id_pkix_OCSP_serviceLocator "OCSP Service Locator" +#define NID_id_pkix_OCSP_serviceLocator 371 +#define OBJ_id_pkix_OCSP_serviceLocator OBJ_id_pkix_OCSP,7L + +#define SN_id_pkix_OCSP_extendedStatus "extendedStatus" +#define LN_id_pkix_OCSP_extendedStatus "Extended OCSP Status" +#define NID_id_pkix_OCSP_extendedStatus 372 +#define OBJ_id_pkix_OCSP_extendedStatus OBJ_id_pkix_OCSP,8L + +#define SN_id_pkix_OCSP_valid "valid" +#define NID_id_pkix_OCSP_valid 373 +#define OBJ_id_pkix_OCSP_valid OBJ_id_pkix_OCSP,9L + +#define SN_id_pkix_OCSP_path "path" +#define NID_id_pkix_OCSP_path 374 +#define OBJ_id_pkix_OCSP_path OBJ_id_pkix_OCSP,10L + +#define SN_id_pkix_OCSP_trustRoot "trustRoot" +#define LN_id_pkix_OCSP_trustRoot "Trust Root" +#define NID_id_pkix_OCSP_trustRoot 375 +#define OBJ_id_pkix_OCSP_trustRoot OBJ_id_pkix_OCSP,11L + +#define SN_algorithm "algorithm" +#define LN_algorithm "algorithm" +#define NID_algorithm 376 +#define OBJ_algorithm 1L,3L,14L,3L,2L + +#define SN_md5WithRSA "RSA-NP-MD5" +#define LN_md5WithRSA "md5WithRSA" +#define NID_md5WithRSA 104 +#define OBJ_md5WithRSA OBJ_algorithm,3L + +#define SN_des_ecb "DES-ECB" +#define LN_des_ecb "des-ecb" +#define NID_des_ecb 29 +#define OBJ_des_ecb OBJ_algorithm,6L + +#define SN_des_cbc "DES-CBC" +#define LN_des_cbc "des-cbc" +#define NID_des_cbc 31 +#define OBJ_des_cbc OBJ_algorithm,7L + +#define SN_des_ofb64 "DES-OFB" +#define LN_des_ofb64 "des-ofb" +#define NID_des_ofb64 45 +#define OBJ_des_ofb64 OBJ_algorithm,8L + +#define SN_des_cfb64 "DES-CFB" +#define LN_des_cfb64 "des-cfb" +#define NID_des_cfb64 30 +#define OBJ_des_cfb64 OBJ_algorithm,9L + +#define SN_rsaSignature "rsaSignature" +#define NID_rsaSignature 377 +#define OBJ_rsaSignature OBJ_algorithm,11L + +#define SN_dsa_2 "DSA-old" +#define LN_dsa_2 "dsaEncryption-old" +#define NID_dsa_2 67 +#define OBJ_dsa_2 OBJ_algorithm,12L + +#define SN_dsaWithSHA "DSA-SHA" +#define LN_dsaWithSHA "dsaWithSHA" +#define NID_dsaWithSHA 66 +#define OBJ_dsaWithSHA OBJ_algorithm,13L + +#define SN_shaWithRSAEncryption "RSA-SHA" +#define LN_shaWithRSAEncryption "shaWithRSAEncryption" +#define NID_shaWithRSAEncryption 42 +#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L + +#define SN_des_ede_ecb "DES-EDE" +#define LN_des_ede_ecb "des-ede" +#define NID_des_ede_ecb 32 +#define OBJ_des_ede_ecb OBJ_algorithm,17L + +#define SN_des_ede3_ecb "DES-EDE3" +#define LN_des_ede3_ecb "des-ede3" +#define NID_des_ede3_ecb 33 + +#define SN_des_ede_cbc "DES-EDE-CBC" +#define LN_des_ede_cbc "des-ede-cbc" +#define NID_des_ede_cbc 43 + +#define SN_des_ede_cfb64 "DES-EDE-CFB" +#define LN_des_ede_cfb64 "des-ede-cfb" +#define NID_des_ede_cfb64 60 + +#define SN_des_ede3_cfb64 "DES-EDE3-CFB" +#define LN_des_ede3_cfb64 "des-ede3-cfb" +#define NID_des_ede3_cfb64 61 + +#define SN_des_ede_ofb64 "DES-EDE-OFB" +#define LN_des_ede_ofb64 "des-ede-ofb" +#define NID_des_ede_ofb64 62 + +#define SN_des_ede3_ofb64 "DES-EDE3-OFB" +#define LN_des_ede3_ofb64 "des-ede3-ofb" +#define NID_des_ede3_ofb64 63 + +#define SN_desx_cbc "DESX-CBC" +#define LN_desx_cbc "desx-cbc" +#define NID_desx_cbc 80 + +#define SN_sha "SHA" +#define LN_sha "sha" +#define NID_sha 41 +#define OBJ_sha OBJ_algorithm,18L + +#define SN_sha1 "SHA1" +#define LN_sha1 "sha1" +#define NID_sha1 64 +#define OBJ_sha1 OBJ_algorithm,26L + +#define SN_dsaWithSHA1_2 "DSA-SHA1-old" +#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" +#define NID_dsaWithSHA1_2 70 +#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L + +#define SN_sha1WithRSA "RSA-SHA1-2" +#define LN_sha1WithRSA "sha1WithRSA" +#define NID_sha1WithRSA 115 +#define OBJ_sha1WithRSA OBJ_algorithm,29L + +#define SN_ripemd160 "RIPEMD160" +#define LN_ripemd160 "ripemd160" +#define NID_ripemd160 117 +#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L + +#define SN_ripemd160WithRSA "RSA-RIPEMD160" +#define LN_ripemd160WithRSA "ripemd160WithRSA" +#define NID_ripemd160WithRSA 119 +#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L + +#define SN_sxnet "SXNetID" +#define LN_sxnet "Strong Extranet ID" +#define NID_sxnet 143 +#define OBJ_sxnet 1L,3L,101L,1L,4L,1L + +#define SN_X500 "X500" +#define LN_X500 "directory services (X.500)" +#define NID_X500 11 +#define OBJ_X500 2L,5L + +#define SN_X509 "X509" +#define NID_X509 12 +#define OBJ_X509 OBJ_X500,4L + +#define SN_commonName "CN" +#define LN_commonName "commonName" +#define NID_commonName 13 +#define OBJ_commonName OBJ_X509,3L + +#define SN_surname "SN" +#define LN_surname "surname" +#define NID_surname 100 +#define OBJ_surname OBJ_X509,4L + +#define LN_serialNumber "serialNumber" +#define NID_serialNumber 105 +#define OBJ_serialNumber OBJ_X509,5L + +#define SN_countryName "C" +#define LN_countryName "countryName" +#define NID_countryName 14 +#define OBJ_countryName OBJ_X509,6L + +#define SN_localityName "L" +#define LN_localityName "localityName" +#define NID_localityName 15 +#define OBJ_localityName OBJ_X509,7L + +#define SN_stateOrProvinceName "ST" +#define LN_stateOrProvinceName "stateOrProvinceName" +#define NID_stateOrProvinceName 16 +#define OBJ_stateOrProvinceName OBJ_X509,8L + +#define LN_streetAddress "streetAddress" +#define NID_streetAddress 660 +#define OBJ_streetAddress OBJ_X509,9L + +#define SN_organizationName "O" +#define LN_organizationName "organizationName" +#define NID_organizationName 17 +#define OBJ_organizationName OBJ_X509,10L + +#define SN_organizationalUnitName "OU" +#define LN_organizationalUnitName "organizationalUnitName" +#define NID_organizationalUnitName 18 +#define OBJ_organizationalUnitName OBJ_X509,11L + +#define LN_title "title" +#define NID_title 106 +#define OBJ_title OBJ_X509,12L + +#define LN_description "description" +#define NID_description 107 +#define OBJ_description OBJ_X509,13L + +#define LN_postalCode "postalCode" +#define NID_postalCode 661 +#define OBJ_postalCode OBJ_X509,17L + +#define SN_name "name" +#define LN_name "name" +#define NID_name 173 +#define OBJ_name OBJ_X509,41L + +#define SN_givenName "GN" +#define LN_givenName "givenName" +#define NID_givenName 99 +#define OBJ_givenName OBJ_X509,42L + +#define LN_initials "initials" +#define NID_initials 101 +#define OBJ_initials OBJ_X509,43L + +#define LN_generationQualifier "generationQualifier" +#define NID_generationQualifier 509 +#define OBJ_generationQualifier OBJ_X509,44L + +#define LN_x500UniqueIdentifier "x500UniqueIdentifier" +#define NID_x500UniqueIdentifier 503 +#define OBJ_x500UniqueIdentifier OBJ_X509,45L + +#define SN_dnQualifier "dnQualifier" +#define LN_dnQualifier "dnQualifier" +#define NID_dnQualifier 174 +#define OBJ_dnQualifier OBJ_X509,46L + +#define LN_pseudonym "pseudonym" +#define NID_pseudonym 510 +#define OBJ_pseudonym OBJ_X509,65L + +#define SN_role "role" +#define LN_role "role" +#define NID_role 400 +#define OBJ_role OBJ_X509,72L + +#define SN_X500algorithms "X500algorithms" +#define LN_X500algorithms "directory services - algorithms" +#define NID_X500algorithms 378 +#define OBJ_X500algorithms OBJ_X500,8L + +#define SN_rsa "RSA" +#define LN_rsa "rsa" +#define NID_rsa 19 +#define OBJ_rsa OBJ_X500algorithms,1L,1L + +#define SN_mdc2WithRSA "RSA-MDC2" +#define LN_mdc2WithRSA "mdc2WithRSA" +#define NID_mdc2WithRSA 96 +#define OBJ_mdc2WithRSA OBJ_X500algorithms,3L,100L + +#define SN_mdc2 "MDC2" +#define LN_mdc2 "mdc2" +#define NID_mdc2 95 +#define OBJ_mdc2 OBJ_X500algorithms,3L,101L + +#define SN_id_ce "id-ce" +#define NID_id_ce 81 +#define OBJ_id_ce OBJ_X500,29L + +#define SN_subject_key_identifier "subjectKeyIdentifier" +#define LN_subject_key_identifier "X509v3 Subject Key Identifier" +#define NID_subject_key_identifier 82 +#define OBJ_subject_key_identifier OBJ_id_ce,14L + +#define SN_key_usage "keyUsage" +#define LN_key_usage "X509v3 Key Usage" +#define NID_key_usage 83 +#define OBJ_key_usage OBJ_id_ce,15L + +#define SN_private_key_usage_period "privateKeyUsagePeriod" +#define LN_private_key_usage_period "X509v3 Private Key Usage Period" +#define NID_private_key_usage_period 84 +#define OBJ_private_key_usage_period OBJ_id_ce,16L + +#define SN_subject_alt_name "subjectAltName" +#define LN_subject_alt_name "X509v3 Subject Alternative Name" +#define NID_subject_alt_name 85 +#define OBJ_subject_alt_name OBJ_id_ce,17L + +#define SN_issuer_alt_name "issuerAltName" +#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" +#define NID_issuer_alt_name 86 +#define OBJ_issuer_alt_name OBJ_id_ce,18L + +#define SN_basic_constraints "basicConstraints" +#define LN_basic_constraints "X509v3 Basic Constraints" +#define NID_basic_constraints 87 +#define OBJ_basic_constraints OBJ_id_ce,19L + +#define SN_crl_number "crlNumber" +#define LN_crl_number "X509v3 CRL Number" +#define NID_crl_number 88 +#define OBJ_crl_number OBJ_id_ce,20L + +#define SN_crl_reason "CRLReason" +#define LN_crl_reason "X509v3 CRL Reason Code" +#define NID_crl_reason 141 +#define OBJ_crl_reason OBJ_id_ce,21L + +#define SN_invalidity_date "invalidityDate" +#define LN_invalidity_date "Invalidity Date" +#define NID_invalidity_date 142 +#define OBJ_invalidity_date OBJ_id_ce,24L + +#define SN_delta_crl "deltaCRL" +#define LN_delta_crl "X509v3 Delta CRL Indicator" +#define NID_delta_crl 140 +#define OBJ_delta_crl OBJ_id_ce,27L + +#define SN_name_constraints "nameConstraints" +#define LN_name_constraints "X509v3 Name Constraints" +#define NID_name_constraints 666 +#define OBJ_name_constraints OBJ_id_ce,30L + +#define SN_crl_distribution_points "crlDistributionPoints" +#define LN_crl_distribution_points "X509v3 CRL Distribution Points" +#define NID_crl_distribution_points 103 +#define OBJ_crl_distribution_points OBJ_id_ce,31L + +#define SN_certificate_policies "certificatePolicies" +#define LN_certificate_policies "X509v3 Certificate Policies" +#define NID_certificate_policies 89 +#define OBJ_certificate_policies OBJ_id_ce,32L + +#define SN_any_policy "anyPolicy" +#define LN_any_policy "X509v3 Any Policy" +#define NID_any_policy 746 +#define OBJ_any_policy OBJ_certificate_policies,0L + +#define SN_policy_mappings "policyMappings" +#define LN_policy_mappings "X509v3 Policy Mappings" +#define NID_policy_mappings 747 +#define OBJ_policy_mappings OBJ_id_ce,33L + +#define SN_authority_key_identifier "authorityKeyIdentifier" +#define LN_authority_key_identifier "X509v3 Authority Key Identifier" +#define NID_authority_key_identifier 90 +#define OBJ_authority_key_identifier OBJ_id_ce,35L + +#define SN_policy_constraints "policyConstraints" +#define LN_policy_constraints "X509v3 Policy Constraints" +#define NID_policy_constraints 401 +#define OBJ_policy_constraints OBJ_id_ce,36L + +#define SN_ext_key_usage "extendedKeyUsage" +#define LN_ext_key_usage "X509v3 Extended Key Usage" +#define NID_ext_key_usage 126 +#define OBJ_ext_key_usage OBJ_id_ce,37L + +#define SN_inhibit_any_policy "inhibitAnyPolicy" +#define LN_inhibit_any_policy "X509v3 Inhibit Any Policy" +#define NID_inhibit_any_policy 748 +#define OBJ_inhibit_any_policy OBJ_id_ce,54L + +#define SN_target_information "targetInformation" +#define LN_target_information "X509v3 AC Targeting" +#define NID_target_information 402 +#define OBJ_target_information OBJ_id_ce,55L + +#define SN_no_rev_avail "noRevAvail" +#define LN_no_rev_avail "X509v3 No Revocation Available" +#define NID_no_rev_avail 403 +#define OBJ_no_rev_avail OBJ_id_ce,56L + +#define SN_netscape "Netscape" +#define LN_netscape "Netscape Communications Corp." +#define NID_netscape 57 +#define OBJ_netscape 2L,16L,840L,1L,113730L + +#define SN_netscape_cert_extension "nsCertExt" +#define LN_netscape_cert_extension "Netscape Certificate Extension" +#define NID_netscape_cert_extension 58 +#define OBJ_netscape_cert_extension OBJ_netscape,1L + +#define SN_netscape_data_type "nsDataType" +#define LN_netscape_data_type "Netscape Data Type" +#define NID_netscape_data_type 59 +#define OBJ_netscape_data_type OBJ_netscape,2L + +#define SN_netscape_cert_type "nsCertType" +#define LN_netscape_cert_type "Netscape Cert Type" +#define NID_netscape_cert_type 71 +#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L + +#define SN_netscape_base_url "nsBaseUrl" +#define LN_netscape_base_url "Netscape Base Url" +#define NID_netscape_base_url 72 +#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L + +#define SN_netscape_revocation_url "nsRevocationUrl" +#define LN_netscape_revocation_url "Netscape Revocation Url" +#define NID_netscape_revocation_url 73 +#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L + +#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" +#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" +#define NID_netscape_ca_revocation_url 74 +#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L + +#define SN_netscape_renewal_url "nsRenewalUrl" +#define LN_netscape_renewal_url "Netscape Renewal Url" +#define NID_netscape_renewal_url 75 +#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L + +#define SN_netscape_ca_policy_url "nsCaPolicyUrl" +#define LN_netscape_ca_policy_url "Netscape CA Policy Url" +#define NID_netscape_ca_policy_url 76 +#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L + +#define SN_netscape_ssl_server_name "nsSslServerName" +#define LN_netscape_ssl_server_name "Netscape SSL Server Name" +#define NID_netscape_ssl_server_name 77 +#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L + +#define SN_netscape_comment "nsComment" +#define LN_netscape_comment "Netscape Comment" +#define NID_netscape_comment 78 +#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L + +#define SN_netscape_cert_sequence "nsCertSequence" +#define LN_netscape_cert_sequence "Netscape Certificate Sequence" +#define NID_netscape_cert_sequence 79 +#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L + +#define SN_ns_sgc "nsSGC" +#define LN_ns_sgc "Netscape Server Gated Crypto" +#define NID_ns_sgc 139 +#define OBJ_ns_sgc OBJ_netscape,4L,1L + +#define SN_org "ORG" +#define LN_org "org" +#define NID_org 379 +#define OBJ_org OBJ_iso,3L + +#define SN_dod "DOD" +#define LN_dod "dod" +#define NID_dod 380 +#define OBJ_dod OBJ_org,6L + +#define SN_iana "IANA" +#define LN_iana "iana" +#define NID_iana 381 +#define OBJ_iana OBJ_dod,1L + +#define OBJ_internet OBJ_iana + +#define SN_Directory "directory" +#define LN_Directory "Directory" +#define NID_Directory 382 +#define OBJ_Directory OBJ_internet,1L + +#define SN_Management "mgmt" +#define LN_Management "Management" +#define NID_Management 383 +#define OBJ_Management OBJ_internet,2L + +#define SN_Experimental "experimental" +#define LN_Experimental "Experimental" +#define NID_Experimental 384 +#define OBJ_Experimental OBJ_internet,3L + +#define SN_Private "private" +#define LN_Private "Private" +#define NID_Private 385 +#define OBJ_Private OBJ_internet,4L + +#define SN_Security "security" +#define LN_Security "Security" +#define NID_Security 386 +#define OBJ_Security OBJ_internet,5L + +#define SN_SNMPv2 "snmpv2" +#define LN_SNMPv2 "SNMPv2" +#define NID_SNMPv2 387 +#define OBJ_SNMPv2 OBJ_internet,6L + +#define LN_Mail "Mail" +#define NID_Mail 388 +#define OBJ_Mail OBJ_internet,7L + +#define SN_Enterprises "enterprises" +#define LN_Enterprises "Enterprises" +#define NID_Enterprises 389 +#define OBJ_Enterprises OBJ_Private,1L + +#define SN_dcObject "dcobject" +#define LN_dcObject "dcObject" +#define NID_dcObject 390 +#define OBJ_dcObject OBJ_Enterprises,1466L,344L + +#define SN_mime_mhs "mime-mhs" +#define LN_mime_mhs "MIME MHS" +#define NID_mime_mhs 504 +#define OBJ_mime_mhs OBJ_Mail,1L + +#define SN_mime_mhs_headings "mime-mhs-headings" +#define LN_mime_mhs_headings "mime-mhs-headings" +#define NID_mime_mhs_headings 505 +#define OBJ_mime_mhs_headings OBJ_mime_mhs,1L + +#define SN_mime_mhs_bodies "mime-mhs-bodies" +#define LN_mime_mhs_bodies "mime-mhs-bodies" +#define NID_mime_mhs_bodies 506 +#define OBJ_mime_mhs_bodies OBJ_mime_mhs,2L + +#define SN_id_hex_partial_message "id-hex-partial-message" +#define LN_id_hex_partial_message "id-hex-partial-message" +#define NID_id_hex_partial_message 507 +#define OBJ_id_hex_partial_message OBJ_mime_mhs_headings,1L + +#define SN_id_hex_multipart_message "id-hex-multipart-message" +#define LN_id_hex_multipart_message "id-hex-multipart-message" +#define NID_id_hex_multipart_message 508 +#define OBJ_id_hex_multipart_message OBJ_mime_mhs_headings,2L + +#define SN_rle_compression "RLE" +#define LN_rle_compression "run length compression" +#define NID_rle_compression 124 +#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L + +#define SN_zlib_compression "ZLIB" +#define LN_zlib_compression "zlib compression" +#define NID_zlib_compression 125 +#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L + +#define OBJ_csor 2L,16L,840L,1L,101L,3L + +#define OBJ_nistAlgorithms OBJ_csor,4L + +#define OBJ_aes OBJ_nistAlgorithms,1L + +#define SN_aes_128_ecb "AES-128-ECB" +#define LN_aes_128_ecb "aes-128-ecb" +#define NID_aes_128_ecb 418 +#define OBJ_aes_128_ecb OBJ_aes,1L + +#define SN_aes_128_cbc "AES-128-CBC" +#define LN_aes_128_cbc "aes-128-cbc" +#define NID_aes_128_cbc 419 +#define OBJ_aes_128_cbc OBJ_aes,2L + +#define SN_aes_128_ofb128 "AES-128-OFB" +#define LN_aes_128_ofb128 "aes-128-ofb" +#define NID_aes_128_ofb128 420 +#define OBJ_aes_128_ofb128 OBJ_aes,3L + +#define SN_aes_128_cfb128 "AES-128-CFB" +#define LN_aes_128_cfb128 "aes-128-cfb" +#define NID_aes_128_cfb128 421 +#define OBJ_aes_128_cfb128 OBJ_aes,4L + +#define SN_aes_192_ecb "AES-192-ECB" +#define LN_aes_192_ecb "aes-192-ecb" +#define NID_aes_192_ecb 422 +#define OBJ_aes_192_ecb OBJ_aes,21L + +#define SN_aes_192_cbc "AES-192-CBC" +#define LN_aes_192_cbc "aes-192-cbc" +#define NID_aes_192_cbc 423 +#define OBJ_aes_192_cbc OBJ_aes,22L + +#define SN_aes_192_ofb128 "AES-192-OFB" +#define LN_aes_192_ofb128 "aes-192-ofb" +#define NID_aes_192_ofb128 424 +#define OBJ_aes_192_ofb128 OBJ_aes,23L + +#define SN_aes_192_cfb128 "AES-192-CFB" +#define LN_aes_192_cfb128 "aes-192-cfb" +#define NID_aes_192_cfb128 425 +#define OBJ_aes_192_cfb128 OBJ_aes,24L + +#define SN_aes_256_ecb "AES-256-ECB" +#define LN_aes_256_ecb "aes-256-ecb" +#define NID_aes_256_ecb 426 +#define OBJ_aes_256_ecb OBJ_aes,41L + +#define SN_aes_256_cbc "AES-256-CBC" +#define LN_aes_256_cbc "aes-256-cbc" +#define NID_aes_256_cbc 427 +#define OBJ_aes_256_cbc OBJ_aes,42L + +#define SN_aes_256_ofb128 "AES-256-OFB" +#define LN_aes_256_ofb128 "aes-256-ofb" +#define NID_aes_256_ofb128 428 +#define OBJ_aes_256_ofb128 OBJ_aes,43L + +#define SN_aes_256_cfb128 "AES-256-CFB" +#define LN_aes_256_cfb128 "aes-256-cfb" +#define NID_aes_256_cfb128 429 +#define OBJ_aes_256_cfb128 OBJ_aes,44L + +#define SN_aes_128_cfb1 "AES-128-CFB1" +#define LN_aes_128_cfb1 "aes-128-cfb1" +#define NID_aes_128_cfb1 650 + +#define SN_aes_192_cfb1 "AES-192-CFB1" +#define LN_aes_192_cfb1 "aes-192-cfb1" +#define NID_aes_192_cfb1 651 + +#define SN_aes_256_cfb1 "AES-256-CFB1" +#define LN_aes_256_cfb1 "aes-256-cfb1" +#define NID_aes_256_cfb1 652 + +#define SN_aes_128_cfb8 "AES-128-CFB8" +#define LN_aes_128_cfb8 "aes-128-cfb8" +#define NID_aes_128_cfb8 653 + +#define SN_aes_192_cfb8 "AES-192-CFB8" +#define LN_aes_192_cfb8 "aes-192-cfb8" +#define NID_aes_192_cfb8 654 + +#define SN_aes_256_cfb8 "AES-256-CFB8" +#define LN_aes_256_cfb8 "aes-256-cfb8" +#define NID_aes_256_cfb8 655 + +#define SN_des_cfb1 "DES-CFB1" +#define LN_des_cfb1 "des-cfb1" +#define NID_des_cfb1 656 + +#define SN_des_cfb8 "DES-CFB8" +#define LN_des_cfb8 "des-cfb8" +#define NID_des_cfb8 657 + +#define SN_des_ede3_cfb1 "DES-EDE3-CFB1" +#define LN_des_ede3_cfb1 "des-ede3-cfb1" +#define NID_des_ede3_cfb1 658 + +#define SN_des_ede3_cfb8 "DES-EDE3-CFB8" +#define LN_des_ede3_cfb8 "des-ede3-cfb8" +#define NID_des_ede3_cfb8 659 + +#define OBJ_nist_hashalgs OBJ_nistAlgorithms,2L + +#define SN_sha256 "SHA256" +#define LN_sha256 "sha256" +#define NID_sha256 672 +#define OBJ_sha256 OBJ_nist_hashalgs,1L + +#define SN_sha384 "SHA384" +#define LN_sha384 "sha384" +#define NID_sha384 673 +#define OBJ_sha384 OBJ_nist_hashalgs,2L + +#define SN_sha512 "SHA512" +#define LN_sha512 "sha512" +#define NID_sha512 674 +#define OBJ_sha512 OBJ_nist_hashalgs,3L + +#define SN_sha224 "SHA224" +#define LN_sha224 "sha224" +#define NID_sha224 675 +#define OBJ_sha224 OBJ_nist_hashalgs,4L + +#define SN_hold_instruction_code "holdInstructionCode" +#define LN_hold_instruction_code "Hold Instruction Code" +#define NID_hold_instruction_code 430 +#define OBJ_hold_instruction_code OBJ_id_ce,23L + +#define OBJ_holdInstruction OBJ_X9_57,2L + +#define SN_hold_instruction_none "holdInstructionNone" +#define LN_hold_instruction_none "Hold Instruction None" +#define NID_hold_instruction_none 431 +#define OBJ_hold_instruction_none OBJ_holdInstruction,1L + +#define SN_hold_instruction_call_issuer "holdInstructionCallIssuer" +#define LN_hold_instruction_call_issuer "Hold Instruction Call Issuer" +#define NID_hold_instruction_call_issuer 432 +#define OBJ_hold_instruction_call_issuer OBJ_holdInstruction,2L + +#define SN_hold_instruction_reject "holdInstructionReject" +#define LN_hold_instruction_reject "Hold Instruction Reject" +#define NID_hold_instruction_reject 433 +#define OBJ_hold_instruction_reject OBJ_holdInstruction,3L + +#define SN_data "data" +#define NID_data 434 +#define OBJ_data OBJ_itu_t,9L + +#define SN_pss "pss" +#define NID_pss 435 +#define OBJ_pss OBJ_data,2342L + +#define SN_ucl "ucl" +#define NID_ucl 436 +#define OBJ_ucl OBJ_pss,19200300L + +#define SN_pilot "pilot" +#define NID_pilot 437 +#define OBJ_pilot OBJ_ucl,100L + +#define LN_pilotAttributeType "pilotAttributeType" +#define NID_pilotAttributeType 438 +#define OBJ_pilotAttributeType OBJ_pilot,1L + +#define LN_pilotAttributeSyntax "pilotAttributeSyntax" +#define NID_pilotAttributeSyntax 439 +#define OBJ_pilotAttributeSyntax OBJ_pilot,3L + +#define LN_pilotObjectClass "pilotObjectClass" +#define NID_pilotObjectClass 440 +#define OBJ_pilotObjectClass OBJ_pilot,4L + +#define LN_pilotGroups "pilotGroups" +#define NID_pilotGroups 441 +#define OBJ_pilotGroups OBJ_pilot,10L + +#define LN_iA5StringSyntax "iA5StringSyntax" +#define NID_iA5StringSyntax 442 +#define OBJ_iA5StringSyntax OBJ_pilotAttributeSyntax,4L + +#define LN_caseIgnoreIA5StringSyntax "caseIgnoreIA5StringSyntax" +#define NID_caseIgnoreIA5StringSyntax 443 +#define OBJ_caseIgnoreIA5StringSyntax OBJ_pilotAttributeSyntax,5L + +#define LN_pilotObject "pilotObject" +#define NID_pilotObject 444 +#define OBJ_pilotObject OBJ_pilotObjectClass,3L + +#define LN_pilotPerson "pilotPerson" +#define NID_pilotPerson 445 +#define OBJ_pilotPerson OBJ_pilotObjectClass,4L + +#define SN_account "account" +#define NID_account 446 +#define OBJ_account OBJ_pilotObjectClass,5L + +#define SN_document "document" +#define NID_document 447 +#define OBJ_document OBJ_pilotObjectClass,6L + +#define SN_room "room" +#define NID_room 448 +#define OBJ_room OBJ_pilotObjectClass,7L + +#define LN_documentSeries "documentSeries" +#define NID_documentSeries 449 +#define OBJ_documentSeries OBJ_pilotObjectClass,9L + +#define SN_Domain "domain" +#define LN_Domain "Domain" +#define NID_Domain 392 +#define OBJ_Domain OBJ_pilotObjectClass,13L + +#define LN_rFC822localPart "rFC822localPart" +#define NID_rFC822localPart 450 +#define OBJ_rFC822localPart OBJ_pilotObjectClass,14L + +#define LN_dNSDomain "dNSDomain" +#define NID_dNSDomain 451 +#define OBJ_dNSDomain OBJ_pilotObjectClass,15L + +#define LN_domainRelatedObject "domainRelatedObject" +#define NID_domainRelatedObject 452 +#define OBJ_domainRelatedObject OBJ_pilotObjectClass,17L + +#define LN_friendlyCountry "friendlyCountry" +#define NID_friendlyCountry 453 +#define OBJ_friendlyCountry OBJ_pilotObjectClass,18L + +#define LN_simpleSecurityObject "simpleSecurityObject" +#define NID_simpleSecurityObject 454 +#define OBJ_simpleSecurityObject OBJ_pilotObjectClass,19L + +#define LN_pilotOrganization "pilotOrganization" +#define NID_pilotOrganization 455 +#define OBJ_pilotOrganization OBJ_pilotObjectClass,20L + +#define LN_pilotDSA "pilotDSA" +#define NID_pilotDSA 456 +#define OBJ_pilotDSA OBJ_pilotObjectClass,21L + +#define LN_qualityLabelledData "qualityLabelledData" +#define NID_qualityLabelledData 457 +#define OBJ_qualityLabelledData OBJ_pilotObjectClass,22L + +#define SN_userId "UID" +#define LN_userId "userId" +#define NID_userId 458 +#define OBJ_userId OBJ_pilotAttributeType,1L + +#define LN_textEncodedORAddress "textEncodedORAddress" +#define NID_textEncodedORAddress 459 +#define OBJ_textEncodedORAddress OBJ_pilotAttributeType,2L + +#define SN_rfc822Mailbox "mail" +#define LN_rfc822Mailbox "rfc822Mailbox" +#define NID_rfc822Mailbox 460 +#define OBJ_rfc822Mailbox OBJ_pilotAttributeType,3L + +#define SN_info "info" +#define NID_info 461 +#define OBJ_info OBJ_pilotAttributeType,4L + +#define LN_favouriteDrink "favouriteDrink" +#define NID_favouriteDrink 462 +#define OBJ_favouriteDrink OBJ_pilotAttributeType,5L + +#define LN_roomNumber "roomNumber" +#define NID_roomNumber 463 +#define OBJ_roomNumber OBJ_pilotAttributeType,6L + +#define SN_photo "photo" +#define NID_photo 464 +#define OBJ_photo OBJ_pilotAttributeType,7L + +#define LN_userClass "userClass" +#define NID_userClass 465 +#define OBJ_userClass OBJ_pilotAttributeType,8L + +#define SN_host "host" +#define NID_host 466 +#define OBJ_host OBJ_pilotAttributeType,9L + +#define SN_manager "manager" +#define NID_manager 467 +#define OBJ_manager OBJ_pilotAttributeType,10L + +#define LN_documentIdentifier "documentIdentifier" +#define NID_documentIdentifier 468 +#define OBJ_documentIdentifier OBJ_pilotAttributeType,11L + +#define LN_documentTitle "documentTitle" +#define NID_documentTitle 469 +#define OBJ_documentTitle OBJ_pilotAttributeType,12L + +#define LN_documentVersion "documentVersion" +#define NID_documentVersion 470 +#define OBJ_documentVersion OBJ_pilotAttributeType,13L + +#define LN_documentAuthor "documentAuthor" +#define NID_documentAuthor 471 +#define OBJ_documentAuthor OBJ_pilotAttributeType,14L + +#define LN_documentLocation "documentLocation" +#define NID_documentLocation 472 +#define OBJ_documentLocation OBJ_pilotAttributeType,15L + +#define LN_homeTelephoneNumber "homeTelephoneNumber" +#define NID_homeTelephoneNumber 473 +#define OBJ_homeTelephoneNumber OBJ_pilotAttributeType,20L + +#define SN_secretary "secretary" +#define NID_secretary 474 +#define OBJ_secretary OBJ_pilotAttributeType,21L + +#define LN_otherMailbox "otherMailbox" +#define NID_otherMailbox 475 +#define OBJ_otherMailbox OBJ_pilotAttributeType,22L + +#define LN_lastModifiedTime "lastModifiedTime" +#define NID_lastModifiedTime 476 +#define OBJ_lastModifiedTime OBJ_pilotAttributeType,23L + +#define LN_lastModifiedBy "lastModifiedBy" +#define NID_lastModifiedBy 477 +#define OBJ_lastModifiedBy OBJ_pilotAttributeType,24L + +#define SN_domainComponent "DC" +#define LN_domainComponent "domainComponent" +#define NID_domainComponent 391 +#define OBJ_domainComponent OBJ_pilotAttributeType,25L + +#define LN_aRecord "aRecord" +#define NID_aRecord 478 +#define OBJ_aRecord OBJ_pilotAttributeType,26L + +#define LN_pilotAttributeType27 "pilotAttributeType27" +#define NID_pilotAttributeType27 479 +#define OBJ_pilotAttributeType27 OBJ_pilotAttributeType,27L + +#define LN_mXRecord "mXRecord" +#define NID_mXRecord 480 +#define OBJ_mXRecord OBJ_pilotAttributeType,28L + +#define LN_nSRecord "nSRecord" +#define NID_nSRecord 481 +#define OBJ_nSRecord OBJ_pilotAttributeType,29L + +#define LN_sOARecord "sOARecord" +#define NID_sOARecord 482 +#define OBJ_sOARecord OBJ_pilotAttributeType,30L + +#define LN_cNAMERecord "cNAMERecord" +#define NID_cNAMERecord 483 +#define OBJ_cNAMERecord OBJ_pilotAttributeType,31L + +#define LN_associatedDomain "associatedDomain" +#define NID_associatedDomain 484 +#define OBJ_associatedDomain OBJ_pilotAttributeType,37L + +#define LN_associatedName "associatedName" +#define NID_associatedName 485 +#define OBJ_associatedName OBJ_pilotAttributeType,38L + +#define LN_homePostalAddress "homePostalAddress" +#define NID_homePostalAddress 486 +#define OBJ_homePostalAddress OBJ_pilotAttributeType,39L + +#define LN_personalTitle "personalTitle" +#define NID_personalTitle 487 +#define OBJ_personalTitle OBJ_pilotAttributeType,40L + +#define LN_mobileTelephoneNumber "mobileTelephoneNumber" +#define NID_mobileTelephoneNumber 488 +#define OBJ_mobileTelephoneNumber OBJ_pilotAttributeType,41L + +#define LN_pagerTelephoneNumber "pagerTelephoneNumber" +#define NID_pagerTelephoneNumber 489 +#define OBJ_pagerTelephoneNumber OBJ_pilotAttributeType,42L + +#define LN_friendlyCountryName "friendlyCountryName" +#define NID_friendlyCountryName 490 +#define OBJ_friendlyCountryName OBJ_pilotAttributeType,43L + +#define LN_organizationalStatus "organizationalStatus" +#define NID_organizationalStatus 491 +#define OBJ_organizationalStatus OBJ_pilotAttributeType,45L + +#define LN_janetMailbox "janetMailbox" +#define NID_janetMailbox 492 +#define OBJ_janetMailbox OBJ_pilotAttributeType,46L + +#define LN_mailPreferenceOption "mailPreferenceOption" +#define NID_mailPreferenceOption 493 +#define OBJ_mailPreferenceOption OBJ_pilotAttributeType,47L + +#define LN_buildingName "buildingName" +#define NID_buildingName 494 +#define OBJ_buildingName OBJ_pilotAttributeType,48L + +#define LN_dSAQuality "dSAQuality" +#define NID_dSAQuality 495 +#define OBJ_dSAQuality OBJ_pilotAttributeType,49L + +#define LN_singleLevelQuality "singleLevelQuality" +#define NID_singleLevelQuality 496 +#define OBJ_singleLevelQuality OBJ_pilotAttributeType,50L + +#define LN_subtreeMinimumQuality "subtreeMinimumQuality" +#define NID_subtreeMinimumQuality 497 +#define OBJ_subtreeMinimumQuality OBJ_pilotAttributeType,51L + +#define LN_subtreeMaximumQuality "subtreeMaximumQuality" +#define NID_subtreeMaximumQuality 498 +#define OBJ_subtreeMaximumQuality OBJ_pilotAttributeType,52L + +#define LN_personalSignature "personalSignature" +#define NID_personalSignature 499 +#define OBJ_personalSignature OBJ_pilotAttributeType,53L + +#define LN_dITRedirect "dITRedirect" +#define NID_dITRedirect 500 +#define OBJ_dITRedirect OBJ_pilotAttributeType,54L + +#define SN_audio "audio" +#define NID_audio 501 +#define OBJ_audio OBJ_pilotAttributeType,55L + +#define LN_documentPublisher "documentPublisher" +#define NID_documentPublisher 502 +#define OBJ_documentPublisher OBJ_pilotAttributeType,56L + +#define SN_id_set "id-set" +#define LN_id_set "Secure Electronic Transactions" +#define NID_id_set 512 +#define OBJ_id_set OBJ_international_organizations,42L + +#define SN_set_ctype "set-ctype" +#define LN_set_ctype "content types" +#define NID_set_ctype 513 +#define OBJ_set_ctype OBJ_id_set,0L + +#define SN_set_msgExt "set-msgExt" +#define LN_set_msgExt "message extensions" +#define NID_set_msgExt 514 +#define OBJ_set_msgExt OBJ_id_set,1L + +#define SN_set_attr "set-attr" +#define NID_set_attr 515 +#define OBJ_set_attr OBJ_id_set,3L + +#define SN_set_policy "set-policy" +#define NID_set_policy 516 +#define OBJ_set_policy OBJ_id_set,5L + +#define SN_set_certExt "set-certExt" +#define LN_set_certExt "certificate extensions" +#define NID_set_certExt 517 +#define OBJ_set_certExt OBJ_id_set,7L + +#define SN_set_brand "set-brand" +#define NID_set_brand 518 +#define OBJ_set_brand OBJ_id_set,8L + +#define SN_setct_PANData "setct-PANData" +#define NID_setct_PANData 519 +#define OBJ_setct_PANData OBJ_set_ctype,0L + +#define SN_setct_PANToken "setct-PANToken" +#define NID_setct_PANToken 520 +#define OBJ_setct_PANToken OBJ_set_ctype,1L + +#define SN_setct_PANOnly "setct-PANOnly" +#define NID_setct_PANOnly 521 +#define OBJ_setct_PANOnly OBJ_set_ctype,2L + +#define SN_setct_OIData "setct-OIData" +#define NID_setct_OIData 522 +#define OBJ_setct_OIData OBJ_set_ctype,3L + +#define SN_setct_PI "setct-PI" +#define NID_setct_PI 523 +#define OBJ_setct_PI OBJ_set_ctype,4L + +#define SN_setct_PIData "setct-PIData" +#define NID_setct_PIData 524 +#define OBJ_setct_PIData OBJ_set_ctype,5L + +#define SN_setct_PIDataUnsigned "setct-PIDataUnsigned" +#define NID_setct_PIDataUnsigned 525 +#define OBJ_setct_PIDataUnsigned OBJ_set_ctype,6L + +#define SN_setct_HODInput "setct-HODInput" +#define NID_setct_HODInput 526 +#define OBJ_setct_HODInput OBJ_set_ctype,7L + +#define SN_setct_AuthResBaggage "setct-AuthResBaggage" +#define NID_setct_AuthResBaggage 527 +#define OBJ_setct_AuthResBaggage OBJ_set_ctype,8L + +#define SN_setct_AuthRevReqBaggage "setct-AuthRevReqBaggage" +#define NID_setct_AuthRevReqBaggage 528 +#define OBJ_setct_AuthRevReqBaggage OBJ_set_ctype,9L + +#define SN_setct_AuthRevResBaggage "setct-AuthRevResBaggage" +#define NID_setct_AuthRevResBaggage 529 +#define OBJ_setct_AuthRevResBaggage OBJ_set_ctype,10L + +#define SN_setct_CapTokenSeq "setct-CapTokenSeq" +#define NID_setct_CapTokenSeq 530 +#define OBJ_setct_CapTokenSeq OBJ_set_ctype,11L + +#define SN_setct_PInitResData "setct-PInitResData" +#define NID_setct_PInitResData 531 +#define OBJ_setct_PInitResData OBJ_set_ctype,12L + +#define SN_setct_PI_TBS "setct-PI-TBS" +#define NID_setct_PI_TBS 532 +#define OBJ_setct_PI_TBS OBJ_set_ctype,13L + +#define SN_setct_PResData "setct-PResData" +#define NID_setct_PResData 533 +#define OBJ_setct_PResData OBJ_set_ctype,14L + +#define SN_setct_AuthReqTBS "setct-AuthReqTBS" +#define NID_setct_AuthReqTBS 534 +#define OBJ_setct_AuthReqTBS OBJ_set_ctype,16L + +#define SN_setct_AuthResTBS "setct-AuthResTBS" +#define NID_setct_AuthResTBS 535 +#define OBJ_setct_AuthResTBS OBJ_set_ctype,17L + +#define SN_setct_AuthResTBSX "setct-AuthResTBSX" +#define NID_setct_AuthResTBSX 536 +#define OBJ_setct_AuthResTBSX OBJ_set_ctype,18L + +#define SN_setct_AuthTokenTBS "setct-AuthTokenTBS" +#define NID_setct_AuthTokenTBS 537 +#define OBJ_setct_AuthTokenTBS OBJ_set_ctype,19L + +#define SN_setct_CapTokenData "setct-CapTokenData" +#define NID_setct_CapTokenData 538 +#define OBJ_setct_CapTokenData OBJ_set_ctype,20L + +#define SN_setct_CapTokenTBS "setct-CapTokenTBS" +#define NID_setct_CapTokenTBS 539 +#define OBJ_setct_CapTokenTBS OBJ_set_ctype,21L + +#define SN_setct_AcqCardCodeMsg "setct-AcqCardCodeMsg" +#define NID_setct_AcqCardCodeMsg 540 +#define OBJ_setct_AcqCardCodeMsg OBJ_set_ctype,22L + +#define SN_setct_AuthRevReqTBS "setct-AuthRevReqTBS" +#define NID_setct_AuthRevReqTBS 541 +#define OBJ_setct_AuthRevReqTBS OBJ_set_ctype,23L + +#define SN_setct_AuthRevResData "setct-AuthRevResData" +#define NID_setct_AuthRevResData 542 +#define OBJ_setct_AuthRevResData OBJ_set_ctype,24L + +#define SN_setct_AuthRevResTBS "setct-AuthRevResTBS" +#define NID_setct_AuthRevResTBS 543 +#define OBJ_setct_AuthRevResTBS OBJ_set_ctype,25L + +#define SN_setct_CapReqTBS "setct-CapReqTBS" +#define NID_setct_CapReqTBS 544 +#define OBJ_setct_CapReqTBS OBJ_set_ctype,26L + +#define SN_setct_CapReqTBSX "setct-CapReqTBSX" +#define NID_setct_CapReqTBSX 545 +#define OBJ_setct_CapReqTBSX OBJ_set_ctype,27L + +#define SN_setct_CapResData "setct-CapResData" +#define NID_setct_CapResData 546 +#define OBJ_setct_CapResData OBJ_set_ctype,28L + +#define SN_setct_CapRevReqTBS "setct-CapRevReqTBS" +#define NID_setct_CapRevReqTBS 547 +#define OBJ_setct_CapRevReqTBS OBJ_set_ctype,29L + +#define SN_setct_CapRevReqTBSX "setct-CapRevReqTBSX" +#define NID_setct_CapRevReqTBSX 548 +#define OBJ_setct_CapRevReqTBSX OBJ_set_ctype,30L + +#define SN_setct_CapRevResData "setct-CapRevResData" +#define NID_setct_CapRevResData 549 +#define OBJ_setct_CapRevResData OBJ_set_ctype,31L + +#define SN_setct_CredReqTBS "setct-CredReqTBS" +#define NID_setct_CredReqTBS 550 +#define OBJ_setct_CredReqTBS OBJ_set_ctype,32L + +#define SN_setct_CredReqTBSX "setct-CredReqTBSX" +#define NID_setct_CredReqTBSX 551 +#define OBJ_setct_CredReqTBSX OBJ_set_ctype,33L + +#define SN_setct_CredResData "setct-CredResData" +#define NID_setct_CredResData 552 +#define OBJ_setct_CredResData OBJ_set_ctype,34L + +#define SN_setct_CredRevReqTBS "setct-CredRevReqTBS" +#define NID_setct_CredRevReqTBS 553 +#define OBJ_setct_CredRevReqTBS OBJ_set_ctype,35L + +#define SN_setct_CredRevReqTBSX "setct-CredRevReqTBSX" +#define NID_setct_CredRevReqTBSX 554 +#define OBJ_setct_CredRevReqTBSX OBJ_set_ctype,36L + +#define SN_setct_CredRevResData "setct-CredRevResData" +#define NID_setct_CredRevResData 555 +#define OBJ_setct_CredRevResData OBJ_set_ctype,37L + +#define SN_setct_PCertReqData "setct-PCertReqData" +#define NID_setct_PCertReqData 556 +#define OBJ_setct_PCertReqData OBJ_set_ctype,38L + +#define SN_setct_PCertResTBS "setct-PCertResTBS" +#define NID_setct_PCertResTBS 557 +#define OBJ_setct_PCertResTBS OBJ_set_ctype,39L + +#define SN_setct_BatchAdminReqData "setct-BatchAdminReqData" +#define NID_setct_BatchAdminReqData 558 +#define OBJ_setct_BatchAdminReqData OBJ_set_ctype,40L + +#define SN_setct_BatchAdminResData "setct-BatchAdminResData" +#define NID_setct_BatchAdminResData 559 +#define OBJ_setct_BatchAdminResData OBJ_set_ctype,41L + +#define SN_setct_CardCInitResTBS "setct-CardCInitResTBS" +#define NID_setct_CardCInitResTBS 560 +#define OBJ_setct_CardCInitResTBS OBJ_set_ctype,42L + +#define SN_setct_MeAqCInitResTBS "setct-MeAqCInitResTBS" +#define NID_setct_MeAqCInitResTBS 561 +#define OBJ_setct_MeAqCInitResTBS OBJ_set_ctype,43L + +#define SN_setct_RegFormResTBS "setct-RegFormResTBS" +#define NID_setct_RegFormResTBS 562 +#define OBJ_setct_RegFormResTBS OBJ_set_ctype,44L + +#define SN_setct_CertReqData "setct-CertReqData" +#define NID_setct_CertReqData 563 +#define OBJ_setct_CertReqData OBJ_set_ctype,45L + +#define SN_setct_CertReqTBS "setct-CertReqTBS" +#define NID_setct_CertReqTBS 564 +#define OBJ_setct_CertReqTBS OBJ_set_ctype,46L + +#define SN_setct_CertResData "setct-CertResData" +#define NID_setct_CertResData 565 +#define OBJ_setct_CertResData OBJ_set_ctype,47L + +#define SN_setct_CertInqReqTBS "setct-CertInqReqTBS" +#define NID_setct_CertInqReqTBS 566 +#define OBJ_setct_CertInqReqTBS OBJ_set_ctype,48L + +#define SN_setct_ErrorTBS "setct-ErrorTBS" +#define NID_setct_ErrorTBS 567 +#define OBJ_setct_ErrorTBS OBJ_set_ctype,49L + +#define SN_setct_PIDualSignedTBE "setct-PIDualSignedTBE" +#define NID_setct_PIDualSignedTBE 568 +#define OBJ_setct_PIDualSignedTBE OBJ_set_ctype,50L + +#define SN_setct_PIUnsignedTBE "setct-PIUnsignedTBE" +#define NID_setct_PIUnsignedTBE 569 +#define OBJ_setct_PIUnsignedTBE OBJ_set_ctype,51L + +#define SN_setct_AuthReqTBE "setct-AuthReqTBE" +#define NID_setct_AuthReqTBE 570 +#define OBJ_setct_AuthReqTBE OBJ_set_ctype,52L + +#define SN_setct_AuthResTBE "setct-AuthResTBE" +#define NID_setct_AuthResTBE 571 +#define OBJ_setct_AuthResTBE OBJ_set_ctype,53L + +#define SN_setct_AuthResTBEX "setct-AuthResTBEX" +#define NID_setct_AuthResTBEX 572 +#define OBJ_setct_AuthResTBEX OBJ_set_ctype,54L + +#define SN_setct_AuthTokenTBE "setct-AuthTokenTBE" +#define NID_setct_AuthTokenTBE 573 +#define OBJ_setct_AuthTokenTBE OBJ_set_ctype,55L + +#define SN_setct_CapTokenTBE "setct-CapTokenTBE" +#define NID_setct_CapTokenTBE 574 +#define OBJ_setct_CapTokenTBE OBJ_set_ctype,56L + +#define SN_setct_CapTokenTBEX "setct-CapTokenTBEX" +#define NID_setct_CapTokenTBEX 575 +#define OBJ_setct_CapTokenTBEX OBJ_set_ctype,57L + +#define SN_setct_AcqCardCodeMsgTBE "setct-AcqCardCodeMsgTBE" +#define NID_setct_AcqCardCodeMsgTBE 576 +#define OBJ_setct_AcqCardCodeMsgTBE OBJ_set_ctype,58L + +#define SN_setct_AuthRevReqTBE "setct-AuthRevReqTBE" +#define NID_setct_AuthRevReqTBE 577 +#define OBJ_setct_AuthRevReqTBE OBJ_set_ctype,59L + +#define SN_setct_AuthRevResTBE "setct-AuthRevResTBE" +#define NID_setct_AuthRevResTBE 578 +#define OBJ_setct_AuthRevResTBE OBJ_set_ctype,60L + +#define SN_setct_AuthRevResTBEB "setct-AuthRevResTBEB" +#define NID_setct_AuthRevResTBEB 579 +#define OBJ_setct_AuthRevResTBEB OBJ_set_ctype,61L + +#define SN_setct_CapReqTBE "setct-CapReqTBE" +#define NID_setct_CapReqTBE 580 +#define OBJ_setct_CapReqTBE OBJ_set_ctype,62L + +#define SN_setct_CapReqTBEX "setct-CapReqTBEX" +#define NID_setct_CapReqTBEX 581 +#define OBJ_setct_CapReqTBEX OBJ_set_ctype,63L + +#define SN_setct_CapResTBE "setct-CapResTBE" +#define NID_setct_CapResTBE 582 +#define OBJ_setct_CapResTBE OBJ_set_ctype,64L + +#define SN_setct_CapRevReqTBE "setct-CapRevReqTBE" +#define NID_setct_CapRevReqTBE 583 +#define OBJ_setct_CapRevReqTBE OBJ_set_ctype,65L + +#define SN_setct_CapRevReqTBEX "setct-CapRevReqTBEX" +#define NID_setct_CapRevReqTBEX 584 +#define OBJ_setct_CapRevReqTBEX OBJ_set_ctype,66L + +#define SN_setct_CapRevResTBE "setct-CapRevResTBE" +#define NID_setct_CapRevResTBE 585 +#define OBJ_setct_CapRevResTBE OBJ_set_ctype,67L + +#define SN_setct_CredReqTBE "setct-CredReqTBE" +#define NID_setct_CredReqTBE 586 +#define OBJ_setct_CredReqTBE OBJ_set_ctype,68L + +#define SN_setct_CredReqTBEX "setct-CredReqTBEX" +#define NID_setct_CredReqTBEX 587 +#define OBJ_setct_CredReqTBEX OBJ_set_ctype,69L + +#define SN_setct_CredResTBE "setct-CredResTBE" +#define NID_setct_CredResTBE 588 +#define OBJ_setct_CredResTBE OBJ_set_ctype,70L + +#define SN_setct_CredRevReqTBE "setct-CredRevReqTBE" +#define NID_setct_CredRevReqTBE 589 +#define OBJ_setct_CredRevReqTBE OBJ_set_ctype,71L + +#define SN_setct_CredRevReqTBEX "setct-CredRevReqTBEX" +#define NID_setct_CredRevReqTBEX 590 +#define OBJ_setct_CredRevReqTBEX OBJ_set_ctype,72L + +#define SN_setct_CredRevResTBE "setct-CredRevResTBE" +#define NID_setct_CredRevResTBE 591 +#define OBJ_setct_CredRevResTBE OBJ_set_ctype,73L + +#define SN_setct_BatchAdminReqTBE "setct-BatchAdminReqTBE" +#define NID_setct_BatchAdminReqTBE 592 +#define OBJ_setct_BatchAdminReqTBE OBJ_set_ctype,74L + +#define SN_setct_BatchAdminResTBE "setct-BatchAdminResTBE" +#define NID_setct_BatchAdminResTBE 593 +#define OBJ_setct_BatchAdminResTBE OBJ_set_ctype,75L + +#define SN_setct_RegFormReqTBE "setct-RegFormReqTBE" +#define NID_setct_RegFormReqTBE 594 +#define OBJ_setct_RegFormReqTBE OBJ_set_ctype,76L + +#define SN_setct_CertReqTBE "setct-CertReqTBE" +#define NID_setct_CertReqTBE 595 +#define OBJ_setct_CertReqTBE OBJ_set_ctype,77L + +#define SN_setct_CertReqTBEX "setct-CertReqTBEX" +#define NID_setct_CertReqTBEX 596 +#define OBJ_setct_CertReqTBEX OBJ_set_ctype,78L + +#define SN_setct_CertResTBE "setct-CertResTBE" +#define NID_setct_CertResTBE 597 +#define OBJ_setct_CertResTBE OBJ_set_ctype,79L + +#define SN_setct_CRLNotificationTBS "setct-CRLNotificationTBS" +#define NID_setct_CRLNotificationTBS 598 +#define OBJ_setct_CRLNotificationTBS OBJ_set_ctype,80L + +#define SN_setct_CRLNotificationResTBS "setct-CRLNotificationResTBS" +#define NID_setct_CRLNotificationResTBS 599 +#define OBJ_setct_CRLNotificationResTBS OBJ_set_ctype,81L + +#define SN_setct_BCIDistributionTBS "setct-BCIDistributionTBS" +#define NID_setct_BCIDistributionTBS 600 +#define OBJ_setct_BCIDistributionTBS OBJ_set_ctype,82L + +#define SN_setext_genCrypt "setext-genCrypt" +#define LN_setext_genCrypt "generic cryptogram" +#define NID_setext_genCrypt 601 +#define OBJ_setext_genCrypt OBJ_set_msgExt,1L + +#define SN_setext_miAuth "setext-miAuth" +#define LN_setext_miAuth "merchant initiated auth" +#define NID_setext_miAuth 602 +#define OBJ_setext_miAuth OBJ_set_msgExt,3L + +#define SN_setext_pinSecure "setext-pinSecure" +#define NID_setext_pinSecure 603 +#define OBJ_setext_pinSecure OBJ_set_msgExt,4L + +#define SN_setext_pinAny "setext-pinAny" +#define NID_setext_pinAny 604 +#define OBJ_setext_pinAny OBJ_set_msgExt,5L + +#define SN_setext_track2 "setext-track2" +#define NID_setext_track2 605 +#define OBJ_setext_track2 OBJ_set_msgExt,7L + +#define SN_setext_cv "setext-cv" +#define LN_setext_cv "additional verification" +#define NID_setext_cv 606 +#define OBJ_setext_cv OBJ_set_msgExt,8L + +#define SN_set_policy_root "set-policy-root" +#define NID_set_policy_root 607 +#define OBJ_set_policy_root OBJ_set_policy,0L + +#define SN_setCext_hashedRoot "setCext-hashedRoot" +#define NID_setCext_hashedRoot 608 +#define OBJ_setCext_hashedRoot OBJ_set_certExt,0L + +#define SN_setCext_certType "setCext-certType" +#define NID_setCext_certType 609 +#define OBJ_setCext_certType OBJ_set_certExt,1L + +#define SN_setCext_merchData "setCext-merchData" +#define NID_setCext_merchData 610 +#define OBJ_setCext_merchData OBJ_set_certExt,2L + +#define SN_setCext_cCertRequired "setCext-cCertRequired" +#define NID_setCext_cCertRequired 611 +#define OBJ_setCext_cCertRequired OBJ_set_certExt,3L + +#define SN_setCext_tunneling "setCext-tunneling" +#define NID_setCext_tunneling 612 +#define OBJ_setCext_tunneling OBJ_set_certExt,4L + +#define SN_setCext_setExt "setCext-setExt" +#define NID_setCext_setExt 613 +#define OBJ_setCext_setExt OBJ_set_certExt,5L + +#define SN_setCext_setQualf "setCext-setQualf" +#define NID_setCext_setQualf 614 +#define OBJ_setCext_setQualf OBJ_set_certExt,6L + +#define SN_setCext_PGWYcapabilities "setCext-PGWYcapabilities" +#define NID_setCext_PGWYcapabilities 615 +#define OBJ_setCext_PGWYcapabilities OBJ_set_certExt,7L + +#define SN_setCext_TokenIdentifier "setCext-TokenIdentifier" +#define NID_setCext_TokenIdentifier 616 +#define OBJ_setCext_TokenIdentifier OBJ_set_certExt,8L + +#define SN_setCext_Track2Data "setCext-Track2Data" +#define NID_setCext_Track2Data 617 +#define OBJ_setCext_Track2Data OBJ_set_certExt,9L + +#define SN_setCext_TokenType "setCext-TokenType" +#define NID_setCext_TokenType 618 +#define OBJ_setCext_TokenType OBJ_set_certExt,10L + +#define SN_setCext_IssuerCapabilities "setCext-IssuerCapabilities" +#define NID_setCext_IssuerCapabilities 619 +#define OBJ_setCext_IssuerCapabilities OBJ_set_certExt,11L + +#define SN_setAttr_Cert "setAttr-Cert" +#define NID_setAttr_Cert 620 +#define OBJ_setAttr_Cert OBJ_set_attr,0L + +#define SN_setAttr_PGWYcap "setAttr-PGWYcap" +#define LN_setAttr_PGWYcap "payment gateway capabilities" +#define NID_setAttr_PGWYcap 621 +#define OBJ_setAttr_PGWYcap OBJ_set_attr,1L + +#define SN_setAttr_TokenType "setAttr-TokenType" +#define NID_setAttr_TokenType 622 +#define OBJ_setAttr_TokenType OBJ_set_attr,2L + +#define SN_setAttr_IssCap "setAttr-IssCap" +#define LN_setAttr_IssCap "issuer capabilities" +#define NID_setAttr_IssCap 623 +#define OBJ_setAttr_IssCap OBJ_set_attr,3L + +#define SN_set_rootKeyThumb "set-rootKeyThumb" +#define NID_set_rootKeyThumb 624 +#define OBJ_set_rootKeyThumb OBJ_setAttr_Cert,0L + +#define SN_set_addPolicy "set-addPolicy" +#define NID_set_addPolicy 625 +#define OBJ_set_addPolicy OBJ_setAttr_Cert,1L + +#define SN_setAttr_Token_EMV "setAttr-Token-EMV" +#define NID_setAttr_Token_EMV 626 +#define OBJ_setAttr_Token_EMV OBJ_setAttr_TokenType,1L + +#define SN_setAttr_Token_B0Prime "setAttr-Token-B0Prime" +#define NID_setAttr_Token_B0Prime 627 +#define OBJ_setAttr_Token_B0Prime OBJ_setAttr_TokenType,2L + +#define SN_setAttr_IssCap_CVM "setAttr-IssCap-CVM" +#define NID_setAttr_IssCap_CVM 628 +#define OBJ_setAttr_IssCap_CVM OBJ_setAttr_IssCap,3L + +#define SN_setAttr_IssCap_T2 "setAttr-IssCap-T2" +#define NID_setAttr_IssCap_T2 629 +#define OBJ_setAttr_IssCap_T2 OBJ_setAttr_IssCap,4L + +#define SN_setAttr_IssCap_Sig "setAttr-IssCap-Sig" +#define NID_setAttr_IssCap_Sig 630 +#define OBJ_setAttr_IssCap_Sig OBJ_setAttr_IssCap,5L + +#define SN_setAttr_GenCryptgrm "setAttr-GenCryptgrm" +#define LN_setAttr_GenCryptgrm "generate cryptogram" +#define NID_setAttr_GenCryptgrm 631 +#define OBJ_setAttr_GenCryptgrm OBJ_setAttr_IssCap_CVM,1L + +#define SN_setAttr_T2Enc "setAttr-T2Enc" +#define LN_setAttr_T2Enc "encrypted track 2" +#define NID_setAttr_T2Enc 632 +#define OBJ_setAttr_T2Enc OBJ_setAttr_IssCap_T2,1L + +#define SN_setAttr_T2cleartxt "setAttr-T2cleartxt" +#define LN_setAttr_T2cleartxt "cleartext track 2" +#define NID_setAttr_T2cleartxt 633 +#define OBJ_setAttr_T2cleartxt OBJ_setAttr_IssCap_T2,2L + +#define SN_setAttr_TokICCsig "setAttr-TokICCsig" +#define LN_setAttr_TokICCsig "ICC or token signature" +#define NID_setAttr_TokICCsig 634 +#define OBJ_setAttr_TokICCsig OBJ_setAttr_IssCap_Sig,1L + +#define SN_setAttr_SecDevSig "setAttr-SecDevSig" +#define LN_setAttr_SecDevSig "secure device signature" +#define NID_setAttr_SecDevSig 635 +#define OBJ_setAttr_SecDevSig OBJ_setAttr_IssCap_Sig,2L + +#define SN_set_brand_IATA_ATA "set-brand-IATA-ATA" +#define NID_set_brand_IATA_ATA 636 +#define OBJ_set_brand_IATA_ATA OBJ_set_brand,1L + +#define SN_set_brand_Diners "set-brand-Diners" +#define NID_set_brand_Diners 637 +#define OBJ_set_brand_Diners OBJ_set_brand,30L + +#define SN_set_brand_AmericanExpress "set-brand-AmericanExpress" +#define NID_set_brand_AmericanExpress 638 +#define OBJ_set_brand_AmericanExpress OBJ_set_brand,34L + +#define SN_set_brand_JCB "set-brand-JCB" +#define NID_set_brand_JCB 639 +#define OBJ_set_brand_JCB OBJ_set_brand,35L + +#define SN_set_brand_Visa "set-brand-Visa" +#define NID_set_brand_Visa 640 +#define OBJ_set_brand_Visa OBJ_set_brand,4L + +#define SN_set_brand_MasterCard "set-brand-MasterCard" +#define NID_set_brand_MasterCard 641 +#define OBJ_set_brand_MasterCard OBJ_set_brand,5L + +#define SN_set_brand_Novus "set-brand-Novus" +#define NID_set_brand_Novus 642 +#define OBJ_set_brand_Novus OBJ_set_brand,6011L + +#define SN_des_cdmf "DES-CDMF" +#define LN_des_cdmf "des-cdmf" +#define NID_des_cdmf 643 +#define OBJ_des_cdmf OBJ_rsadsi,3L,10L + +#define SN_rsaOAEPEncryptionSET "rsaOAEPEncryptionSET" +#define NID_rsaOAEPEncryptionSET 644 +#define OBJ_rsaOAEPEncryptionSET OBJ_rsadsi,1L,1L,6L + +#define SN_ipsec3 "Oakley-EC2N-3" +#define LN_ipsec3 "ipsec3" +#define NID_ipsec3 749 + +#define SN_ipsec4 "Oakley-EC2N-4" +#define LN_ipsec4 "ipsec4" +#define NID_ipsec4 750 + diff --git a/src/dep/include/openssl/objects.h b/src/dep/include/openssl/objects.h index 9e5ccbe..0cb5768 100644 --- a/src/dep/include/openssl/objects.h +++ b/src/dep/include/openssl/objects.h @@ -1,1049 +1,1049 @@ -/* crypto/objects/objects.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_OBJECTS_H -#define HEADER_OBJECTS_H - -#define USE_OBJ_MAC - -#ifdef USE_OBJ_MAC -#include -#else -#define SN_undef "UNDEF" -#define LN_undef "undefined" -#define NID_undef 0 -#define OBJ_undef 0L - -#define SN_Algorithm "Algorithm" -#define LN_algorithm "algorithm" -#define NID_algorithm 38 -#define OBJ_algorithm 1L,3L,14L,3L,2L - -#define LN_rsadsi "rsadsi" -#define NID_rsadsi 1 -#define OBJ_rsadsi 1L,2L,840L,113549L - -#define LN_pkcs "pkcs" -#define NID_pkcs 2 -#define OBJ_pkcs OBJ_rsadsi,1L - -#define SN_md2 "MD2" -#define LN_md2 "md2" -#define NID_md2 3 -#define OBJ_md2 OBJ_rsadsi,2L,2L - -#define SN_md5 "MD5" -#define LN_md5 "md5" -#define NID_md5 4 -#define OBJ_md5 OBJ_rsadsi,2L,5L - -#define SN_rc4 "RC4" -#define LN_rc4 "rc4" -#define NID_rc4 5 -#define OBJ_rc4 OBJ_rsadsi,3L,4L - -#define LN_rsaEncryption "rsaEncryption" -#define NID_rsaEncryption 6 -#define OBJ_rsaEncryption OBJ_pkcs,1L,1L - -#define SN_md2WithRSAEncryption "RSA-MD2" -#define LN_md2WithRSAEncryption "md2WithRSAEncryption" -#define NID_md2WithRSAEncryption 7 -#define OBJ_md2WithRSAEncryption OBJ_pkcs,1L,2L - -#define SN_md5WithRSAEncryption "RSA-MD5" -#define LN_md5WithRSAEncryption "md5WithRSAEncryption" -#define NID_md5WithRSAEncryption 8 -#define OBJ_md5WithRSAEncryption OBJ_pkcs,1L,4L - -#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" -#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" -#define NID_pbeWithMD2AndDES_CBC 9 -#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs,5L,1L - -#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" -#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" -#define NID_pbeWithMD5AndDES_CBC 10 -#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs,5L,3L - -#define LN_X500 "X500" -#define NID_X500 11 -#define OBJ_X500 2L,5L - -#define LN_X509 "X509" -#define NID_X509 12 -#define OBJ_X509 OBJ_X500,4L - -#define SN_commonName "CN" -#define LN_commonName "commonName" -#define NID_commonName 13 -#define OBJ_commonName OBJ_X509,3L - -#define SN_countryName "C" -#define LN_countryName "countryName" -#define NID_countryName 14 -#define OBJ_countryName OBJ_X509,6L - -#define SN_localityName "L" -#define LN_localityName "localityName" -#define NID_localityName 15 -#define OBJ_localityName OBJ_X509,7L - -/* Postal Address? PA */ - -/* should be "ST" (rfc1327) but MS uses 'S' */ -#define SN_stateOrProvinceName "ST" -#define LN_stateOrProvinceName "stateOrProvinceName" -#define NID_stateOrProvinceName 16 -#define OBJ_stateOrProvinceName OBJ_X509,8L - -#define SN_organizationName "O" -#define LN_organizationName "organizationName" -#define NID_organizationName 17 -#define OBJ_organizationName OBJ_X509,10L - -#define SN_organizationalUnitName "OU" -#define LN_organizationalUnitName "organizationalUnitName" -#define NID_organizationalUnitName 18 -#define OBJ_organizationalUnitName OBJ_X509,11L - -#define SN_rsa "RSA" -#define LN_rsa "rsa" -#define NID_rsa 19 -#define OBJ_rsa OBJ_X500,8L,1L,1L - -#define LN_pkcs7 "pkcs7" -#define NID_pkcs7 20 -#define OBJ_pkcs7 OBJ_pkcs,7L - -#define LN_pkcs7_data "pkcs7-data" -#define NID_pkcs7_data 21 -#define OBJ_pkcs7_data OBJ_pkcs7,1L - -#define LN_pkcs7_signed "pkcs7-signedData" -#define NID_pkcs7_signed 22 -#define OBJ_pkcs7_signed OBJ_pkcs7,2L - -#define LN_pkcs7_enveloped "pkcs7-envelopedData" -#define NID_pkcs7_enveloped 23 -#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L - -#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" -#define NID_pkcs7_signedAndEnveloped 24 -#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L - -#define LN_pkcs7_digest "pkcs7-digestData" -#define NID_pkcs7_digest 25 -#define OBJ_pkcs7_digest OBJ_pkcs7,5L - -#define LN_pkcs7_encrypted "pkcs7-encryptedData" -#define NID_pkcs7_encrypted 26 -#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L - -#define LN_pkcs3 "pkcs3" -#define NID_pkcs3 27 -#define OBJ_pkcs3 OBJ_pkcs,3L - -#define LN_dhKeyAgreement "dhKeyAgreement" -#define NID_dhKeyAgreement 28 -#define OBJ_dhKeyAgreement OBJ_pkcs3,1L - -#define SN_des_ecb "DES-ECB" -#define LN_des_ecb "des-ecb" -#define NID_des_ecb 29 -#define OBJ_des_ecb OBJ_algorithm,6L - -#define SN_des_cfb64 "DES-CFB" -#define LN_des_cfb64 "des-cfb" -#define NID_des_cfb64 30 -/* IV + num */ -#define OBJ_des_cfb64 OBJ_algorithm,9L - -#define SN_des_cbc "DES-CBC" -#define LN_des_cbc "des-cbc" -#define NID_des_cbc 31 -/* IV */ -#define OBJ_des_cbc OBJ_algorithm,7L - -#define SN_des_ede "DES-EDE" -#define LN_des_ede "des-ede" -#define NID_des_ede 32 -/* ?? */ -#define OBJ_des_ede OBJ_algorithm,17L - -#define SN_des_ede3 "DES-EDE3" -#define LN_des_ede3 "des-ede3" -#define NID_des_ede3 33 - -#define SN_idea_cbc "IDEA-CBC" -#define LN_idea_cbc "idea-cbc" -#define NID_idea_cbc 34 -#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L - -#define SN_idea_cfb64 "IDEA-CFB" -#define LN_idea_cfb64 "idea-cfb" -#define NID_idea_cfb64 35 - -#define SN_idea_ecb "IDEA-ECB" -#define LN_idea_ecb "idea-ecb" -#define NID_idea_ecb 36 - -#define SN_rc2_cbc "RC2-CBC" -#define LN_rc2_cbc "rc2-cbc" -#define NID_rc2_cbc 37 -#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L - -#define SN_rc2_ecb "RC2-ECB" -#define LN_rc2_ecb "rc2-ecb" -#define NID_rc2_ecb 38 - -#define SN_rc2_cfb64 "RC2-CFB" -#define LN_rc2_cfb64 "rc2-cfb" -#define NID_rc2_cfb64 39 - -#define SN_rc2_ofb64 "RC2-OFB" -#define LN_rc2_ofb64 "rc2-ofb" -#define NID_rc2_ofb64 40 - -#define SN_sha "SHA" -#define LN_sha "sha" -#define NID_sha 41 -#define OBJ_sha OBJ_algorithm,18L - -#define SN_shaWithRSAEncryption "RSA-SHA" -#define LN_shaWithRSAEncryption "shaWithRSAEncryption" -#define NID_shaWithRSAEncryption 42 -#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L - -#define SN_des_ede_cbc "DES-EDE-CBC" -#define LN_des_ede_cbc "des-ede-cbc" -#define NID_des_ede_cbc 43 - -#define SN_des_ede3_cbc "DES-EDE3-CBC" -#define LN_des_ede3_cbc "des-ede3-cbc" -#define NID_des_ede3_cbc 44 -#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L - -#define SN_des_ofb64 "DES-OFB" -#define LN_des_ofb64 "des-ofb" -#define NID_des_ofb64 45 -#define OBJ_des_ofb64 OBJ_algorithm,8L - -#define SN_idea_ofb64 "IDEA-OFB" -#define LN_idea_ofb64 "idea-ofb" -#define NID_idea_ofb64 46 - -#define LN_pkcs9 "pkcs9" -#define NID_pkcs9 47 -#define OBJ_pkcs9 OBJ_pkcs,9L - -#define SN_pkcs9_emailAddress "Email" -#define LN_pkcs9_emailAddress "emailAddress" -#define NID_pkcs9_emailAddress 48 -#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L - -#define LN_pkcs9_unstructuredName "unstructuredName" -#define NID_pkcs9_unstructuredName 49 -#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L - -#define LN_pkcs9_contentType "contentType" -#define NID_pkcs9_contentType 50 -#define OBJ_pkcs9_contentType OBJ_pkcs9,3L - -#define LN_pkcs9_messageDigest "messageDigest" -#define NID_pkcs9_messageDigest 51 -#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L - -#define LN_pkcs9_signingTime "signingTime" -#define NID_pkcs9_signingTime 52 -#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L - -#define LN_pkcs9_countersignature "countersignature" -#define NID_pkcs9_countersignature 53 -#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L - -#define LN_pkcs9_challengePassword "challengePassword" -#define NID_pkcs9_challengePassword 54 -#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L - -#define LN_pkcs9_unstructuredAddress "unstructuredAddress" -#define NID_pkcs9_unstructuredAddress 55 -#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L - -#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" -#define NID_pkcs9_extCertAttributes 56 -#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L - -#define SN_netscape "Netscape" -#define LN_netscape "Netscape Communications Corp." -#define NID_netscape 57 -#define OBJ_netscape 2L,16L,840L,1L,113730L - -#define SN_netscape_cert_extension "nsCertExt" -#define LN_netscape_cert_extension "Netscape Certificate Extension" -#define NID_netscape_cert_extension 58 -#define OBJ_netscape_cert_extension OBJ_netscape,1L - -#define SN_netscape_data_type "nsDataType" -#define LN_netscape_data_type "Netscape Data Type" -#define NID_netscape_data_type 59 -#define OBJ_netscape_data_type OBJ_netscape,2L - -#define SN_des_ede_cfb64 "DES-EDE-CFB" -#define LN_des_ede_cfb64 "des-ede-cfb" -#define NID_des_ede_cfb64 60 - -#define SN_des_ede3_cfb64 "DES-EDE3-CFB" -#define LN_des_ede3_cfb64 "des-ede3-cfb" -#define NID_des_ede3_cfb64 61 - -#define SN_des_ede_ofb64 "DES-EDE-OFB" -#define LN_des_ede_ofb64 "des-ede-ofb" -#define NID_des_ede_ofb64 62 - -#define SN_des_ede3_ofb64 "DES-EDE3-OFB" -#define LN_des_ede3_ofb64 "des-ede3-ofb" -#define NID_des_ede3_ofb64 63 - -/* I'm not sure about the object ID */ -#define SN_sha1 "SHA1" -#define LN_sha1 "sha1" -#define NID_sha1 64 -#define OBJ_sha1 OBJ_algorithm,26L -/* 28 Jun 1996 - eay */ -/* #define OBJ_sha1 1L,3L,14L,2L,26L,05L <- wrong */ - -#define SN_sha1WithRSAEncryption "RSA-SHA1" -#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" -#define NID_sha1WithRSAEncryption 65 -#define OBJ_sha1WithRSAEncryption OBJ_pkcs,1L,5L - -#define SN_dsaWithSHA "DSA-SHA" -#define LN_dsaWithSHA "dsaWithSHA" -#define NID_dsaWithSHA 66 -#define OBJ_dsaWithSHA OBJ_algorithm,13L - -#define SN_dsa_2 "DSA-old" -#define LN_dsa_2 "dsaEncryption-old" -#define NID_dsa_2 67 -#define OBJ_dsa_2 OBJ_algorithm,12L - -/* proposed by microsoft to RSA */ -#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" -#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" -#define NID_pbeWithSHA1AndRC2_CBC 68 -#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs,5L,11L - -/* proposed by microsoft to RSA as pbeWithSHA1AndRC4: it is now - * defined explicitly in PKCS#5 v2.0 as id-PBKDF2 which is something - * completely different. - */ -#define LN_id_pbkdf2 "PBKDF2" -#define NID_id_pbkdf2 69 -#define OBJ_id_pbkdf2 OBJ_pkcs,5L,12L - -#define SN_dsaWithSHA1_2 "DSA-SHA1-old" -#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" -#define NID_dsaWithSHA1_2 70 -/* Got this one from 'sdn706r20.pdf' which is actually an NSA document :-) */ -#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L - -#define SN_netscape_cert_type "nsCertType" -#define LN_netscape_cert_type "Netscape Cert Type" -#define NID_netscape_cert_type 71 -#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L - -#define SN_netscape_base_url "nsBaseUrl" -#define LN_netscape_base_url "Netscape Base Url" -#define NID_netscape_base_url 72 -#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L - -#define SN_netscape_revocation_url "nsRevocationUrl" -#define LN_netscape_revocation_url "Netscape Revocation Url" -#define NID_netscape_revocation_url 73 -#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L - -#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" -#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" -#define NID_netscape_ca_revocation_url 74 -#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L - -#define SN_netscape_renewal_url "nsRenewalUrl" -#define LN_netscape_renewal_url "Netscape Renewal Url" -#define NID_netscape_renewal_url 75 -#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L - -#define SN_netscape_ca_policy_url "nsCaPolicyUrl" -#define LN_netscape_ca_policy_url "Netscape CA Policy Url" -#define NID_netscape_ca_policy_url 76 -#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L - -#define SN_netscape_ssl_server_name "nsSslServerName" -#define LN_netscape_ssl_server_name "Netscape SSL Server Name" -#define NID_netscape_ssl_server_name 77 -#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L - -#define SN_netscape_comment "nsComment" -#define LN_netscape_comment "Netscape Comment" -#define NID_netscape_comment 78 -#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L - -#define SN_netscape_cert_sequence "nsCertSequence" -#define LN_netscape_cert_sequence "Netscape Certificate Sequence" -#define NID_netscape_cert_sequence 79 -#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L - -#define SN_desx_cbc "DESX-CBC" -#define LN_desx_cbc "desx-cbc" -#define NID_desx_cbc 80 - -#define SN_id_ce "id-ce" -#define NID_id_ce 81 -#define OBJ_id_ce 2L,5L,29L - -#define SN_subject_key_identifier "subjectKeyIdentifier" -#define LN_subject_key_identifier "X509v3 Subject Key Identifier" -#define NID_subject_key_identifier 82 -#define OBJ_subject_key_identifier OBJ_id_ce,14L - -#define SN_key_usage "keyUsage" -#define LN_key_usage "X509v3 Key Usage" -#define NID_key_usage 83 -#define OBJ_key_usage OBJ_id_ce,15L - -#define SN_private_key_usage_period "privateKeyUsagePeriod" -#define LN_private_key_usage_period "X509v3 Private Key Usage Period" -#define NID_private_key_usage_period 84 -#define OBJ_private_key_usage_period OBJ_id_ce,16L - -#define SN_subject_alt_name "subjectAltName" -#define LN_subject_alt_name "X509v3 Subject Alternative Name" -#define NID_subject_alt_name 85 -#define OBJ_subject_alt_name OBJ_id_ce,17L - -#define SN_issuer_alt_name "issuerAltName" -#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" -#define NID_issuer_alt_name 86 -#define OBJ_issuer_alt_name OBJ_id_ce,18L - -#define SN_basic_constraints "basicConstraints" -#define LN_basic_constraints "X509v3 Basic Constraints" -#define NID_basic_constraints 87 -#define OBJ_basic_constraints OBJ_id_ce,19L - -#define SN_crl_number "crlNumber" -#define LN_crl_number "X509v3 CRL Number" -#define NID_crl_number 88 -#define OBJ_crl_number OBJ_id_ce,20L - -#define SN_certificate_policies "certificatePolicies" -#define LN_certificate_policies "X509v3 Certificate Policies" -#define NID_certificate_policies 89 -#define OBJ_certificate_policies OBJ_id_ce,32L - -#define SN_authority_key_identifier "authorityKeyIdentifier" -#define LN_authority_key_identifier "X509v3 Authority Key Identifier" -#define NID_authority_key_identifier 90 -#define OBJ_authority_key_identifier OBJ_id_ce,35L - -#define SN_bf_cbc "BF-CBC" -#define LN_bf_cbc "bf-cbc" -#define NID_bf_cbc 91 -#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L - -#define SN_bf_ecb "BF-ECB" -#define LN_bf_ecb "bf-ecb" -#define NID_bf_ecb 92 - -#define SN_bf_cfb64 "BF-CFB" -#define LN_bf_cfb64 "bf-cfb" -#define NID_bf_cfb64 93 - -#define SN_bf_ofb64 "BF-OFB" -#define LN_bf_ofb64 "bf-ofb" -#define NID_bf_ofb64 94 - -#define SN_mdc2 "MDC2" -#define LN_mdc2 "mdc2" -#define NID_mdc2 95 -#define OBJ_mdc2 2L,5L,8L,3L,101L -/* An alternative? 1L,3L,14L,3L,2L,19L */ - -#define SN_mdc2WithRSA "RSA-MDC2" -#define LN_mdc2WithRSA "mdc2withRSA" -#define NID_mdc2WithRSA 96 -#define OBJ_mdc2WithRSA 2L,5L,8L,3L,100L - -#define SN_rc4_40 "RC4-40" -#define LN_rc4_40 "rc4-40" -#define NID_rc4_40 97 - -#define SN_rc2_40_cbc "RC2-40-CBC" -#define LN_rc2_40_cbc "rc2-40-cbc" -#define NID_rc2_40_cbc 98 - -#define SN_givenName "G" -#define LN_givenName "givenName" -#define NID_givenName 99 -#define OBJ_givenName OBJ_X509,42L - -#define SN_surname "S" -#define LN_surname "surname" -#define NID_surname 100 -#define OBJ_surname OBJ_X509,4L - -#define SN_initials "I" -#define LN_initials "initials" -#define NID_initials 101 -#define OBJ_initials OBJ_X509,43L - -#define SN_uniqueIdentifier "UID" -#define LN_uniqueIdentifier "uniqueIdentifier" -#define NID_uniqueIdentifier 102 -#define OBJ_uniqueIdentifier OBJ_X509,45L - -#define SN_crl_distribution_points "crlDistributionPoints" -#define LN_crl_distribution_points "X509v3 CRL Distribution Points" -#define NID_crl_distribution_points 103 -#define OBJ_crl_distribution_points OBJ_id_ce,31L - -#define SN_md5WithRSA "RSA-NP-MD5" -#define LN_md5WithRSA "md5WithRSA" -#define NID_md5WithRSA 104 -#define OBJ_md5WithRSA OBJ_algorithm,3L - -#define SN_serialNumber "SN" -#define LN_serialNumber "serialNumber" -#define NID_serialNumber 105 -#define OBJ_serialNumber OBJ_X509,5L - -#define SN_title "T" -#define LN_title "title" -#define NID_title 106 -#define OBJ_title OBJ_X509,12L - -#define SN_description "D" -#define LN_description "description" -#define NID_description 107 -#define OBJ_description OBJ_X509,13L - -/* CAST5 is CAST-128, I'm just sticking with the documentation */ -#define SN_cast5_cbc "CAST5-CBC" -#define LN_cast5_cbc "cast5-cbc" -#define NID_cast5_cbc 108 -#define OBJ_cast5_cbc 1L,2L,840L,113533L,7L,66L,10L - -#define SN_cast5_ecb "CAST5-ECB" -#define LN_cast5_ecb "cast5-ecb" -#define NID_cast5_ecb 109 - -#define SN_cast5_cfb64 "CAST5-CFB" -#define LN_cast5_cfb64 "cast5-cfb" -#define NID_cast5_cfb64 110 - -#define SN_cast5_ofb64 "CAST5-OFB" -#define LN_cast5_ofb64 "cast5-ofb" -#define NID_cast5_ofb64 111 - -#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" -#define NID_pbeWithMD5AndCast5_CBC 112 -#define OBJ_pbeWithMD5AndCast5_CBC 1L,2L,840L,113533L,7L,66L,12L - -/* This is one sun will soon be using :-( - * id-dsa-with-sha1 ID ::= { - * iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 } - */ -#define SN_dsaWithSHA1 "DSA-SHA1" -#define LN_dsaWithSHA1 "dsaWithSHA1" -#define NID_dsaWithSHA1 113 -#define OBJ_dsaWithSHA1 1L,2L,840L,10040L,4L,3L - -#define NID_md5_sha1 114 -#define SN_md5_sha1 "MD5-SHA1" -#define LN_md5_sha1 "md5-sha1" - -#define SN_sha1WithRSA "RSA-SHA1-2" -#define LN_sha1WithRSA "sha1WithRSA" -#define NID_sha1WithRSA 115 -#define OBJ_sha1WithRSA OBJ_algorithm,29L - -#define SN_dsa "DSA" -#define LN_dsa "dsaEncryption" -#define NID_dsa 116 -#define OBJ_dsa 1L,2L,840L,10040L,4L,1L - -#define SN_ripemd160 "RIPEMD160" -#define LN_ripemd160 "ripemd160" -#define NID_ripemd160 117 -#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L - -/* The name should actually be rsaSignatureWithripemd160, but I'm going - * to continue using the convention I'm using with the other ciphers */ -#define SN_ripemd160WithRSA "RSA-RIPEMD160" -#define LN_ripemd160WithRSA "ripemd160WithRSA" -#define NID_ripemd160WithRSA 119 -#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L - -/* Taken from rfc2040 - * RC5_CBC_Parameters ::= SEQUENCE { - * version INTEGER (v1_0(16)), - * rounds INTEGER (8..127), - * blockSizeInBits INTEGER (64, 128), - * iv OCTET STRING OPTIONAL - * } - */ -#define SN_rc5_cbc "RC5-CBC" -#define LN_rc5_cbc "rc5-cbc" -#define NID_rc5_cbc 120 -#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L - -#define SN_rc5_ecb "RC5-ECB" -#define LN_rc5_ecb "rc5-ecb" -#define NID_rc5_ecb 121 - -#define SN_rc5_cfb64 "RC5-CFB" -#define LN_rc5_cfb64 "rc5-cfb" -#define NID_rc5_cfb64 122 - -#define SN_rc5_ofb64 "RC5-OFB" -#define LN_rc5_ofb64 "rc5-ofb" -#define NID_rc5_ofb64 123 - -#define SN_rle_compression "RLE" -#define LN_rle_compression "run length compression" -#define NID_rle_compression 124 -#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L - -#define SN_zlib_compression "ZLIB" -#define LN_zlib_compression "zlib compression" -#define NID_zlib_compression 125 -#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L - -#define SN_ext_key_usage "extendedKeyUsage" -#define LN_ext_key_usage "X509v3 Extended Key Usage" -#define NID_ext_key_usage 126 -#define OBJ_ext_key_usage OBJ_id_ce,37 - -#define SN_id_pkix "PKIX" -#define NID_id_pkix 127 -#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L - -#define SN_id_kp "id-kp" -#define NID_id_kp 128 -#define OBJ_id_kp OBJ_id_pkix,3L - -/* PKIX extended key usage OIDs */ - -#define SN_server_auth "serverAuth" -#define LN_server_auth "TLS Web Server Authentication" -#define NID_server_auth 129 -#define OBJ_server_auth OBJ_id_kp,1L - -#define SN_client_auth "clientAuth" -#define LN_client_auth "TLS Web Client Authentication" -#define NID_client_auth 130 -#define OBJ_client_auth OBJ_id_kp,2L - -#define SN_code_sign "codeSigning" -#define LN_code_sign "Code Signing" -#define NID_code_sign 131 -#define OBJ_code_sign OBJ_id_kp,3L - -#define SN_email_protect "emailProtection" -#define LN_email_protect "E-mail Protection" -#define NID_email_protect 132 -#define OBJ_email_protect OBJ_id_kp,4L - -#define SN_time_stamp "timeStamping" -#define LN_time_stamp "Time Stamping" -#define NID_time_stamp 133 -#define OBJ_time_stamp OBJ_id_kp,8L - -/* Additional extended key usage OIDs: Microsoft */ - -#define SN_ms_code_ind "msCodeInd" -#define LN_ms_code_ind "Microsoft Individual Code Signing" -#define NID_ms_code_ind 134 -#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L - -#define SN_ms_code_com "msCodeCom" -#define LN_ms_code_com "Microsoft Commercial Code Signing" -#define NID_ms_code_com 135 -#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L - -#define SN_ms_ctl_sign "msCTLSign" -#define LN_ms_ctl_sign "Microsoft Trust List Signing" -#define NID_ms_ctl_sign 136 -#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L - -#define SN_ms_sgc "msSGC" -#define LN_ms_sgc "Microsoft Server Gated Crypto" -#define NID_ms_sgc 137 -#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L - -#define SN_ms_efs "msEFS" -#define LN_ms_efs "Microsoft Encrypted File System" -#define NID_ms_efs 138 -#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L - -/* Additional usage: Netscape */ - -#define SN_ns_sgc "nsSGC" -#define LN_ns_sgc "Netscape Server Gated Crypto" -#define NID_ns_sgc 139 -#define OBJ_ns_sgc OBJ_netscape,4L,1L - -#define SN_delta_crl "deltaCRL" -#define LN_delta_crl "X509v3 Delta CRL Indicator" -#define NID_delta_crl 140 -#define OBJ_delta_crl OBJ_id_ce,27L - -#define SN_crl_reason "CRLReason" -#define LN_crl_reason "CRL Reason Code" -#define NID_crl_reason 141 -#define OBJ_crl_reason OBJ_id_ce,21L - -#define SN_invalidity_date "invalidityDate" -#define LN_invalidity_date "Invalidity Date" -#define NID_invalidity_date 142 -#define OBJ_invalidity_date OBJ_id_ce,24L - -#define SN_sxnet "SXNetID" -#define LN_sxnet "Strong Extranet ID" -#define NID_sxnet 143 -#define OBJ_sxnet 1L,3L,101L,1L,4L,1L - -/* PKCS12 and related OBJECT IDENTIFIERS */ - -#define OBJ_pkcs12 OBJ_pkcs,12L -#define OBJ_pkcs12_pbeids OBJ_pkcs12, 1 - -#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" -#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" -#define NID_pbe_WithSHA1And128BitRC4 144 -#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids, 1L - -#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" -#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" -#define NID_pbe_WithSHA1And40BitRC4 145 -#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids, 2L - -#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" -#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" -#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 -#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 3L - -#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" -#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" -#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 -#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 4L - -#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" -#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" -#define NID_pbe_WithSHA1And128BitRC2_CBC 148 -#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids, 5L - -#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" -#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" -#define NID_pbe_WithSHA1And40BitRC2_CBC 149 -#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L - -#define OBJ_pkcs12_Version1 OBJ_pkcs12, 10L - -#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1, 1L - -#define LN_keyBag "keyBag" -#define NID_keyBag 150 -#define OBJ_keyBag OBJ_pkcs12_BagIds, 1L - -#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" -#define NID_pkcs8ShroudedKeyBag 151 -#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds, 2L - -#define LN_certBag "certBag" -#define NID_certBag 152 -#define OBJ_certBag OBJ_pkcs12_BagIds, 3L - -#define LN_crlBag "crlBag" -#define NID_crlBag 153 -#define OBJ_crlBag OBJ_pkcs12_BagIds, 4L - -#define LN_secretBag "secretBag" -#define NID_secretBag 154 -#define OBJ_secretBag OBJ_pkcs12_BagIds, 5L - -#define LN_safeContentsBag "safeContentsBag" -#define NID_safeContentsBag 155 -#define OBJ_safeContentsBag OBJ_pkcs12_BagIds, 6L - -#define LN_friendlyName "friendlyName" -#define NID_friendlyName 156 -#define OBJ_friendlyName OBJ_pkcs9, 20L - -#define LN_localKeyID "localKeyID" -#define NID_localKeyID 157 -#define OBJ_localKeyID OBJ_pkcs9, 21L - -#define OBJ_certTypes OBJ_pkcs9, 22L - -#define LN_x509Certificate "x509Certificate" -#define NID_x509Certificate 158 -#define OBJ_x509Certificate OBJ_certTypes, 1L - -#define LN_sdsiCertificate "sdsiCertificate" -#define NID_sdsiCertificate 159 -#define OBJ_sdsiCertificate OBJ_certTypes, 2L - -#define OBJ_crlTypes OBJ_pkcs9, 23L - -#define LN_x509Crl "x509Crl" -#define NID_x509Crl 160 -#define OBJ_x509Crl OBJ_crlTypes, 1L - -/* PKCS#5 v2 OIDs */ - -#define LN_pbes2 "PBES2" -#define NID_pbes2 161 -#define OBJ_pbes2 OBJ_pkcs,5L,13L - -#define LN_pbmac1 "PBMAC1" -#define NID_pbmac1 162 -#define OBJ_pbmac1 OBJ_pkcs,5L,14L - -#define LN_hmacWithSHA1 "hmacWithSHA1" -#define NID_hmacWithSHA1 163 -#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L - -/* Policy Qualifier Ids */ - -#define LN_id_qt_cps "Policy Qualifier CPS" -#define SN_id_qt_cps "id-qt-cps" -#define NID_id_qt_cps 164 -#define OBJ_id_qt_cps OBJ_id_pkix,2L,1L - -#define LN_id_qt_unotice "Policy Qualifier User Notice" -#define SN_id_qt_unotice "id-qt-unotice" -#define NID_id_qt_unotice 165 -#define OBJ_id_qt_unotice OBJ_id_pkix,2L,2L - -#define SN_rc2_64_cbc "RC2-64-CBC" -#define LN_rc2_64_cbc "rc2-64-cbc" -#define NID_rc2_64_cbc 166 - -#define SN_SMIMECapabilities "SMIME-CAPS" -#define LN_SMIMECapabilities "S/MIME Capabilities" -#define NID_SMIMECapabilities 167 -#define OBJ_SMIMECapabilities OBJ_pkcs9,15L - -#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" -#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" -#define NID_pbeWithMD2AndRC2_CBC 168 -#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs,5L,4L - -#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" -#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" -#define NID_pbeWithMD5AndRC2_CBC 169 -#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs,5L,6L - -#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" -#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" -#define NID_pbeWithSHA1AndDES_CBC 170 -#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs,5L,10L - -/* Extension request OIDs */ - -#define LN_ms_ext_req "Microsoft Extension Request" -#define SN_ms_ext_req "msExtReq" -#define NID_ms_ext_req 171 -#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L - -#define LN_ext_req "Extension Request" -#define SN_ext_req "extReq" -#define NID_ext_req 172 -#define OBJ_ext_req OBJ_pkcs9,14L - -#define SN_name "name" -#define LN_name "name" -#define NID_name 173 -#define OBJ_name OBJ_X509,41L - -#define SN_dnQualifier "dnQualifier" -#define LN_dnQualifier "dnQualifier" -#define NID_dnQualifier 174 -#define OBJ_dnQualifier OBJ_X509,46L - -#define SN_id_pe "id-pe" -#define NID_id_pe 175 -#define OBJ_id_pe OBJ_id_pkix,1L - -#define SN_id_ad "id-ad" -#define NID_id_ad 176 -#define OBJ_id_ad OBJ_id_pkix,48L - -#define SN_info_access "authorityInfoAccess" -#define LN_info_access "Authority Information Access" -#define NID_info_access 177 -#define OBJ_info_access OBJ_id_pe,1L - -#define SN_ad_OCSP "OCSP" -#define LN_ad_OCSP "OCSP" -#define NID_ad_OCSP 178 -#define OBJ_ad_OCSP OBJ_id_ad,1L - -#define SN_ad_ca_issuers "caIssuers" -#define LN_ad_ca_issuers "CA Issuers" -#define NID_ad_ca_issuers 179 -#define OBJ_ad_ca_issuers OBJ_id_ad,2L - -#define SN_OCSP_sign "OCSPSigning" -#define LN_OCSP_sign "OCSP Signing" -#define NID_OCSP_sign 180 -#define OBJ_OCSP_sign OBJ_id_kp,9L -#endif /* USE_OBJ_MAC */ - -#include -#include - -#define OBJ_NAME_TYPE_UNDEF 0x00 -#define OBJ_NAME_TYPE_MD_METH 0x01 -#define OBJ_NAME_TYPE_CIPHER_METH 0x02 -#define OBJ_NAME_TYPE_PKEY_METH 0x03 -#define OBJ_NAME_TYPE_COMP_METH 0x04 -#define OBJ_NAME_TYPE_NUM 0x05 - -#define OBJ_NAME_ALIAS 0x8000 - -#define OBJ_BSEARCH_VALUE_ON_NOMATCH 0x01 -#define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH 0x02 - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct obj_name_st - { - int type; - int alias; - const char *name; - const char *data; - } OBJ_NAME; - -#define OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c) - - -int OBJ_NAME_init(void); -int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *), - int (*cmp_func)(const char *, const char *), - void (*free_func)(const char *, int, const char *)); -const char *OBJ_NAME_get(const char *name,int type); -int OBJ_NAME_add(const char *name,int type,const char *data); -int OBJ_NAME_remove(const char *name,int type); -void OBJ_NAME_cleanup(int type); /* -1 for everything */ -void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg), - void *arg); -void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg), - void *arg); - -ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o); -ASN1_OBJECT * OBJ_nid2obj(int n); -const char * OBJ_nid2ln(int n); -const char * OBJ_nid2sn(int n); -int OBJ_obj2nid(const ASN1_OBJECT *o); -ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name); -int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name); -int OBJ_txt2nid(const char *s); -int OBJ_ln2nid(const char *s); -int OBJ_sn2nid(const char *s); -int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b); -const char * OBJ_bsearch(const char *key,const char *base,int num,int size, - int (*cmp)(const void *, const void *)); -const char * OBJ_bsearch_ex(const char *key,const char *base,int num, - int size, int (*cmp)(const void *, const void *), int flags); - -int OBJ_new_nid(int num); -int OBJ_add_object(const ASN1_OBJECT *obj); -int OBJ_create(const char *oid,const char *sn,const char *ln); -void OBJ_cleanup(void ); -int OBJ_create_objects(BIO *in); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_OBJ_strings(void); - -/* Error codes for the OBJ functions. */ - -/* Function codes. */ -#define OBJ_F_OBJ_ADD_OBJECT 105 -#define OBJ_F_OBJ_CREATE 100 -#define OBJ_F_OBJ_DUP 101 -#define OBJ_F_OBJ_NAME_NEW_INDEX 106 -#define OBJ_F_OBJ_NID2LN 102 -#define OBJ_F_OBJ_NID2OBJ 103 -#define OBJ_F_OBJ_NID2SN 104 - -/* Reason codes. */ -#define OBJ_R_MALLOC_FAILURE 100 -#define OBJ_R_UNKNOWN_NID 101 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/objects/objects.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_OBJECTS_H +#define HEADER_OBJECTS_H + +#define USE_OBJ_MAC + +#ifdef USE_OBJ_MAC +#include +#else +#define SN_undef "UNDEF" +#define LN_undef "undefined" +#define NID_undef 0 +#define OBJ_undef 0L + +#define SN_Algorithm "Algorithm" +#define LN_algorithm "algorithm" +#define NID_algorithm 38 +#define OBJ_algorithm 1L,3L,14L,3L,2L + +#define LN_rsadsi "rsadsi" +#define NID_rsadsi 1 +#define OBJ_rsadsi 1L,2L,840L,113549L + +#define LN_pkcs "pkcs" +#define NID_pkcs 2 +#define OBJ_pkcs OBJ_rsadsi,1L + +#define SN_md2 "MD2" +#define LN_md2 "md2" +#define NID_md2 3 +#define OBJ_md2 OBJ_rsadsi,2L,2L + +#define SN_md5 "MD5" +#define LN_md5 "md5" +#define NID_md5 4 +#define OBJ_md5 OBJ_rsadsi,2L,5L + +#define SN_rc4 "RC4" +#define LN_rc4 "rc4" +#define NID_rc4 5 +#define OBJ_rc4 OBJ_rsadsi,3L,4L + +#define LN_rsaEncryption "rsaEncryption" +#define NID_rsaEncryption 6 +#define OBJ_rsaEncryption OBJ_pkcs,1L,1L + +#define SN_md2WithRSAEncryption "RSA-MD2" +#define LN_md2WithRSAEncryption "md2WithRSAEncryption" +#define NID_md2WithRSAEncryption 7 +#define OBJ_md2WithRSAEncryption OBJ_pkcs,1L,2L + +#define SN_md5WithRSAEncryption "RSA-MD5" +#define LN_md5WithRSAEncryption "md5WithRSAEncryption" +#define NID_md5WithRSAEncryption 8 +#define OBJ_md5WithRSAEncryption OBJ_pkcs,1L,4L + +#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" +#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" +#define NID_pbeWithMD2AndDES_CBC 9 +#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs,5L,1L + +#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" +#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" +#define NID_pbeWithMD5AndDES_CBC 10 +#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs,5L,3L + +#define LN_X500 "X500" +#define NID_X500 11 +#define OBJ_X500 2L,5L + +#define LN_X509 "X509" +#define NID_X509 12 +#define OBJ_X509 OBJ_X500,4L + +#define SN_commonName "CN" +#define LN_commonName "commonName" +#define NID_commonName 13 +#define OBJ_commonName OBJ_X509,3L + +#define SN_countryName "C" +#define LN_countryName "countryName" +#define NID_countryName 14 +#define OBJ_countryName OBJ_X509,6L + +#define SN_localityName "L" +#define LN_localityName "localityName" +#define NID_localityName 15 +#define OBJ_localityName OBJ_X509,7L + +/* Postal Address? PA */ + +/* should be "ST" (rfc1327) but MS uses 'S' */ +#define SN_stateOrProvinceName "ST" +#define LN_stateOrProvinceName "stateOrProvinceName" +#define NID_stateOrProvinceName 16 +#define OBJ_stateOrProvinceName OBJ_X509,8L + +#define SN_organizationName "O" +#define LN_organizationName "organizationName" +#define NID_organizationName 17 +#define OBJ_organizationName OBJ_X509,10L + +#define SN_organizationalUnitName "OU" +#define LN_organizationalUnitName "organizationalUnitName" +#define NID_organizationalUnitName 18 +#define OBJ_organizationalUnitName OBJ_X509,11L + +#define SN_rsa "RSA" +#define LN_rsa "rsa" +#define NID_rsa 19 +#define OBJ_rsa OBJ_X500,8L,1L,1L + +#define LN_pkcs7 "pkcs7" +#define NID_pkcs7 20 +#define OBJ_pkcs7 OBJ_pkcs,7L + +#define LN_pkcs7_data "pkcs7-data" +#define NID_pkcs7_data 21 +#define OBJ_pkcs7_data OBJ_pkcs7,1L + +#define LN_pkcs7_signed "pkcs7-signedData" +#define NID_pkcs7_signed 22 +#define OBJ_pkcs7_signed OBJ_pkcs7,2L + +#define LN_pkcs7_enveloped "pkcs7-envelopedData" +#define NID_pkcs7_enveloped 23 +#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L + +#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" +#define NID_pkcs7_signedAndEnveloped 24 +#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L + +#define LN_pkcs7_digest "pkcs7-digestData" +#define NID_pkcs7_digest 25 +#define OBJ_pkcs7_digest OBJ_pkcs7,5L + +#define LN_pkcs7_encrypted "pkcs7-encryptedData" +#define NID_pkcs7_encrypted 26 +#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L + +#define LN_pkcs3 "pkcs3" +#define NID_pkcs3 27 +#define OBJ_pkcs3 OBJ_pkcs,3L + +#define LN_dhKeyAgreement "dhKeyAgreement" +#define NID_dhKeyAgreement 28 +#define OBJ_dhKeyAgreement OBJ_pkcs3,1L + +#define SN_des_ecb "DES-ECB" +#define LN_des_ecb "des-ecb" +#define NID_des_ecb 29 +#define OBJ_des_ecb OBJ_algorithm,6L + +#define SN_des_cfb64 "DES-CFB" +#define LN_des_cfb64 "des-cfb" +#define NID_des_cfb64 30 +/* IV + num */ +#define OBJ_des_cfb64 OBJ_algorithm,9L + +#define SN_des_cbc "DES-CBC" +#define LN_des_cbc "des-cbc" +#define NID_des_cbc 31 +/* IV */ +#define OBJ_des_cbc OBJ_algorithm,7L + +#define SN_des_ede "DES-EDE" +#define LN_des_ede "des-ede" +#define NID_des_ede 32 +/* ?? */ +#define OBJ_des_ede OBJ_algorithm,17L + +#define SN_des_ede3 "DES-EDE3" +#define LN_des_ede3 "des-ede3" +#define NID_des_ede3 33 + +#define SN_idea_cbc "IDEA-CBC" +#define LN_idea_cbc "idea-cbc" +#define NID_idea_cbc 34 +#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L + +#define SN_idea_cfb64 "IDEA-CFB" +#define LN_idea_cfb64 "idea-cfb" +#define NID_idea_cfb64 35 + +#define SN_idea_ecb "IDEA-ECB" +#define LN_idea_ecb "idea-ecb" +#define NID_idea_ecb 36 + +#define SN_rc2_cbc "RC2-CBC" +#define LN_rc2_cbc "rc2-cbc" +#define NID_rc2_cbc 37 +#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L + +#define SN_rc2_ecb "RC2-ECB" +#define LN_rc2_ecb "rc2-ecb" +#define NID_rc2_ecb 38 + +#define SN_rc2_cfb64 "RC2-CFB" +#define LN_rc2_cfb64 "rc2-cfb" +#define NID_rc2_cfb64 39 + +#define SN_rc2_ofb64 "RC2-OFB" +#define LN_rc2_ofb64 "rc2-ofb" +#define NID_rc2_ofb64 40 + +#define SN_sha "SHA" +#define LN_sha "sha" +#define NID_sha 41 +#define OBJ_sha OBJ_algorithm,18L + +#define SN_shaWithRSAEncryption "RSA-SHA" +#define LN_shaWithRSAEncryption "shaWithRSAEncryption" +#define NID_shaWithRSAEncryption 42 +#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L + +#define SN_des_ede_cbc "DES-EDE-CBC" +#define LN_des_ede_cbc "des-ede-cbc" +#define NID_des_ede_cbc 43 + +#define SN_des_ede3_cbc "DES-EDE3-CBC" +#define LN_des_ede3_cbc "des-ede3-cbc" +#define NID_des_ede3_cbc 44 +#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L + +#define SN_des_ofb64 "DES-OFB" +#define LN_des_ofb64 "des-ofb" +#define NID_des_ofb64 45 +#define OBJ_des_ofb64 OBJ_algorithm,8L + +#define SN_idea_ofb64 "IDEA-OFB" +#define LN_idea_ofb64 "idea-ofb" +#define NID_idea_ofb64 46 + +#define LN_pkcs9 "pkcs9" +#define NID_pkcs9 47 +#define OBJ_pkcs9 OBJ_pkcs,9L + +#define SN_pkcs9_emailAddress "Email" +#define LN_pkcs9_emailAddress "emailAddress" +#define NID_pkcs9_emailAddress 48 +#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L + +#define LN_pkcs9_unstructuredName "unstructuredName" +#define NID_pkcs9_unstructuredName 49 +#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L + +#define LN_pkcs9_contentType "contentType" +#define NID_pkcs9_contentType 50 +#define OBJ_pkcs9_contentType OBJ_pkcs9,3L + +#define LN_pkcs9_messageDigest "messageDigest" +#define NID_pkcs9_messageDigest 51 +#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L + +#define LN_pkcs9_signingTime "signingTime" +#define NID_pkcs9_signingTime 52 +#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L + +#define LN_pkcs9_countersignature "countersignature" +#define NID_pkcs9_countersignature 53 +#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L + +#define LN_pkcs9_challengePassword "challengePassword" +#define NID_pkcs9_challengePassword 54 +#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L + +#define LN_pkcs9_unstructuredAddress "unstructuredAddress" +#define NID_pkcs9_unstructuredAddress 55 +#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L + +#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" +#define NID_pkcs9_extCertAttributes 56 +#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L + +#define SN_netscape "Netscape" +#define LN_netscape "Netscape Communications Corp." +#define NID_netscape 57 +#define OBJ_netscape 2L,16L,840L,1L,113730L + +#define SN_netscape_cert_extension "nsCertExt" +#define LN_netscape_cert_extension "Netscape Certificate Extension" +#define NID_netscape_cert_extension 58 +#define OBJ_netscape_cert_extension OBJ_netscape,1L + +#define SN_netscape_data_type "nsDataType" +#define LN_netscape_data_type "Netscape Data Type" +#define NID_netscape_data_type 59 +#define OBJ_netscape_data_type OBJ_netscape,2L + +#define SN_des_ede_cfb64 "DES-EDE-CFB" +#define LN_des_ede_cfb64 "des-ede-cfb" +#define NID_des_ede_cfb64 60 + +#define SN_des_ede3_cfb64 "DES-EDE3-CFB" +#define LN_des_ede3_cfb64 "des-ede3-cfb" +#define NID_des_ede3_cfb64 61 + +#define SN_des_ede_ofb64 "DES-EDE-OFB" +#define LN_des_ede_ofb64 "des-ede-ofb" +#define NID_des_ede_ofb64 62 + +#define SN_des_ede3_ofb64 "DES-EDE3-OFB" +#define LN_des_ede3_ofb64 "des-ede3-ofb" +#define NID_des_ede3_ofb64 63 + +/* I'm not sure about the object ID */ +#define SN_sha1 "SHA1" +#define LN_sha1 "sha1" +#define NID_sha1 64 +#define OBJ_sha1 OBJ_algorithm,26L +/* 28 Jun 1996 - eay */ +/* #define OBJ_sha1 1L,3L,14L,2L,26L,05L <- wrong */ + +#define SN_sha1WithRSAEncryption "RSA-SHA1" +#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" +#define NID_sha1WithRSAEncryption 65 +#define OBJ_sha1WithRSAEncryption OBJ_pkcs,1L,5L + +#define SN_dsaWithSHA "DSA-SHA" +#define LN_dsaWithSHA "dsaWithSHA" +#define NID_dsaWithSHA 66 +#define OBJ_dsaWithSHA OBJ_algorithm,13L + +#define SN_dsa_2 "DSA-old" +#define LN_dsa_2 "dsaEncryption-old" +#define NID_dsa_2 67 +#define OBJ_dsa_2 OBJ_algorithm,12L + +/* proposed by microsoft to RSA */ +#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" +#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" +#define NID_pbeWithSHA1AndRC2_CBC 68 +#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs,5L,11L + +/* proposed by microsoft to RSA as pbeWithSHA1AndRC4: it is now + * defined explicitly in PKCS#5 v2.0 as id-PBKDF2 which is something + * completely different. + */ +#define LN_id_pbkdf2 "PBKDF2" +#define NID_id_pbkdf2 69 +#define OBJ_id_pbkdf2 OBJ_pkcs,5L,12L + +#define SN_dsaWithSHA1_2 "DSA-SHA1-old" +#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" +#define NID_dsaWithSHA1_2 70 +/* Got this one from 'sdn706r20.pdf' which is actually an NSA document :-) */ +#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L + +#define SN_netscape_cert_type "nsCertType" +#define LN_netscape_cert_type "Netscape Cert Type" +#define NID_netscape_cert_type 71 +#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L + +#define SN_netscape_base_url "nsBaseUrl" +#define LN_netscape_base_url "Netscape Base Url" +#define NID_netscape_base_url 72 +#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L + +#define SN_netscape_revocation_url "nsRevocationUrl" +#define LN_netscape_revocation_url "Netscape Revocation Url" +#define NID_netscape_revocation_url 73 +#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L + +#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" +#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" +#define NID_netscape_ca_revocation_url 74 +#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L + +#define SN_netscape_renewal_url "nsRenewalUrl" +#define LN_netscape_renewal_url "Netscape Renewal Url" +#define NID_netscape_renewal_url 75 +#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L + +#define SN_netscape_ca_policy_url "nsCaPolicyUrl" +#define LN_netscape_ca_policy_url "Netscape CA Policy Url" +#define NID_netscape_ca_policy_url 76 +#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L + +#define SN_netscape_ssl_server_name "nsSslServerName" +#define LN_netscape_ssl_server_name "Netscape SSL Server Name" +#define NID_netscape_ssl_server_name 77 +#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L + +#define SN_netscape_comment "nsComment" +#define LN_netscape_comment "Netscape Comment" +#define NID_netscape_comment 78 +#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L + +#define SN_netscape_cert_sequence "nsCertSequence" +#define LN_netscape_cert_sequence "Netscape Certificate Sequence" +#define NID_netscape_cert_sequence 79 +#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L + +#define SN_desx_cbc "DESX-CBC" +#define LN_desx_cbc "desx-cbc" +#define NID_desx_cbc 80 + +#define SN_id_ce "id-ce" +#define NID_id_ce 81 +#define OBJ_id_ce 2L,5L,29L + +#define SN_subject_key_identifier "subjectKeyIdentifier" +#define LN_subject_key_identifier "X509v3 Subject Key Identifier" +#define NID_subject_key_identifier 82 +#define OBJ_subject_key_identifier OBJ_id_ce,14L + +#define SN_key_usage "keyUsage" +#define LN_key_usage "X509v3 Key Usage" +#define NID_key_usage 83 +#define OBJ_key_usage OBJ_id_ce,15L + +#define SN_private_key_usage_period "privateKeyUsagePeriod" +#define LN_private_key_usage_period "X509v3 Private Key Usage Period" +#define NID_private_key_usage_period 84 +#define OBJ_private_key_usage_period OBJ_id_ce,16L + +#define SN_subject_alt_name "subjectAltName" +#define LN_subject_alt_name "X509v3 Subject Alternative Name" +#define NID_subject_alt_name 85 +#define OBJ_subject_alt_name OBJ_id_ce,17L + +#define SN_issuer_alt_name "issuerAltName" +#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" +#define NID_issuer_alt_name 86 +#define OBJ_issuer_alt_name OBJ_id_ce,18L + +#define SN_basic_constraints "basicConstraints" +#define LN_basic_constraints "X509v3 Basic Constraints" +#define NID_basic_constraints 87 +#define OBJ_basic_constraints OBJ_id_ce,19L + +#define SN_crl_number "crlNumber" +#define LN_crl_number "X509v3 CRL Number" +#define NID_crl_number 88 +#define OBJ_crl_number OBJ_id_ce,20L + +#define SN_certificate_policies "certificatePolicies" +#define LN_certificate_policies "X509v3 Certificate Policies" +#define NID_certificate_policies 89 +#define OBJ_certificate_policies OBJ_id_ce,32L + +#define SN_authority_key_identifier "authorityKeyIdentifier" +#define LN_authority_key_identifier "X509v3 Authority Key Identifier" +#define NID_authority_key_identifier 90 +#define OBJ_authority_key_identifier OBJ_id_ce,35L + +#define SN_bf_cbc "BF-CBC" +#define LN_bf_cbc "bf-cbc" +#define NID_bf_cbc 91 +#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L + +#define SN_bf_ecb "BF-ECB" +#define LN_bf_ecb "bf-ecb" +#define NID_bf_ecb 92 + +#define SN_bf_cfb64 "BF-CFB" +#define LN_bf_cfb64 "bf-cfb" +#define NID_bf_cfb64 93 + +#define SN_bf_ofb64 "BF-OFB" +#define LN_bf_ofb64 "bf-ofb" +#define NID_bf_ofb64 94 + +#define SN_mdc2 "MDC2" +#define LN_mdc2 "mdc2" +#define NID_mdc2 95 +#define OBJ_mdc2 2L,5L,8L,3L,101L +/* An alternative? 1L,3L,14L,3L,2L,19L */ + +#define SN_mdc2WithRSA "RSA-MDC2" +#define LN_mdc2WithRSA "mdc2withRSA" +#define NID_mdc2WithRSA 96 +#define OBJ_mdc2WithRSA 2L,5L,8L,3L,100L + +#define SN_rc4_40 "RC4-40" +#define LN_rc4_40 "rc4-40" +#define NID_rc4_40 97 + +#define SN_rc2_40_cbc "RC2-40-CBC" +#define LN_rc2_40_cbc "rc2-40-cbc" +#define NID_rc2_40_cbc 98 + +#define SN_givenName "G" +#define LN_givenName "givenName" +#define NID_givenName 99 +#define OBJ_givenName OBJ_X509,42L + +#define SN_surname "S" +#define LN_surname "surname" +#define NID_surname 100 +#define OBJ_surname OBJ_X509,4L + +#define SN_initials "I" +#define LN_initials "initials" +#define NID_initials 101 +#define OBJ_initials OBJ_X509,43L + +#define SN_uniqueIdentifier "UID" +#define LN_uniqueIdentifier "uniqueIdentifier" +#define NID_uniqueIdentifier 102 +#define OBJ_uniqueIdentifier OBJ_X509,45L + +#define SN_crl_distribution_points "crlDistributionPoints" +#define LN_crl_distribution_points "X509v3 CRL Distribution Points" +#define NID_crl_distribution_points 103 +#define OBJ_crl_distribution_points OBJ_id_ce,31L + +#define SN_md5WithRSA "RSA-NP-MD5" +#define LN_md5WithRSA "md5WithRSA" +#define NID_md5WithRSA 104 +#define OBJ_md5WithRSA OBJ_algorithm,3L + +#define SN_serialNumber "SN" +#define LN_serialNumber "serialNumber" +#define NID_serialNumber 105 +#define OBJ_serialNumber OBJ_X509,5L + +#define SN_title "T" +#define LN_title "title" +#define NID_title 106 +#define OBJ_title OBJ_X509,12L + +#define SN_description "D" +#define LN_description "description" +#define NID_description 107 +#define OBJ_description OBJ_X509,13L + +/* CAST5 is CAST-128, I'm just sticking with the documentation */ +#define SN_cast5_cbc "CAST5-CBC" +#define LN_cast5_cbc "cast5-cbc" +#define NID_cast5_cbc 108 +#define OBJ_cast5_cbc 1L,2L,840L,113533L,7L,66L,10L + +#define SN_cast5_ecb "CAST5-ECB" +#define LN_cast5_ecb "cast5-ecb" +#define NID_cast5_ecb 109 + +#define SN_cast5_cfb64 "CAST5-CFB" +#define LN_cast5_cfb64 "cast5-cfb" +#define NID_cast5_cfb64 110 + +#define SN_cast5_ofb64 "CAST5-OFB" +#define LN_cast5_ofb64 "cast5-ofb" +#define NID_cast5_ofb64 111 + +#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" +#define NID_pbeWithMD5AndCast5_CBC 112 +#define OBJ_pbeWithMD5AndCast5_CBC 1L,2L,840L,113533L,7L,66L,12L + +/* This is one sun will soon be using :-( + * id-dsa-with-sha1 ID ::= { + * iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 } + */ +#define SN_dsaWithSHA1 "DSA-SHA1" +#define LN_dsaWithSHA1 "dsaWithSHA1" +#define NID_dsaWithSHA1 113 +#define OBJ_dsaWithSHA1 1L,2L,840L,10040L,4L,3L + +#define NID_md5_sha1 114 +#define SN_md5_sha1 "MD5-SHA1" +#define LN_md5_sha1 "md5-sha1" + +#define SN_sha1WithRSA "RSA-SHA1-2" +#define LN_sha1WithRSA "sha1WithRSA" +#define NID_sha1WithRSA 115 +#define OBJ_sha1WithRSA OBJ_algorithm,29L + +#define SN_dsa "DSA" +#define LN_dsa "dsaEncryption" +#define NID_dsa 116 +#define OBJ_dsa 1L,2L,840L,10040L,4L,1L + +#define SN_ripemd160 "RIPEMD160" +#define LN_ripemd160 "ripemd160" +#define NID_ripemd160 117 +#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L + +/* The name should actually be rsaSignatureWithripemd160, but I'm going + * to continue using the convention I'm using with the other ciphers */ +#define SN_ripemd160WithRSA "RSA-RIPEMD160" +#define LN_ripemd160WithRSA "ripemd160WithRSA" +#define NID_ripemd160WithRSA 119 +#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L + +/* Taken from rfc2040 + * RC5_CBC_Parameters ::= SEQUENCE { + * version INTEGER (v1_0(16)), + * rounds INTEGER (8..127), + * blockSizeInBits INTEGER (64, 128), + * iv OCTET STRING OPTIONAL + * } + */ +#define SN_rc5_cbc "RC5-CBC" +#define LN_rc5_cbc "rc5-cbc" +#define NID_rc5_cbc 120 +#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L + +#define SN_rc5_ecb "RC5-ECB" +#define LN_rc5_ecb "rc5-ecb" +#define NID_rc5_ecb 121 + +#define SN_rc5_cfb64 "RC5-CFB" +#define LN_rc5_cfb64 "rc5-cfb" +#define NID_rc5_cfb64 122 + +#define SN_rc5_ofb64 "RC5-OFB" +#define LN_rc5_ofb64 "rc5-ofb" +#define NID_rc5_ofb64 123 + +#define SN_rle_compression "RLE" +#define LN_rle_compression "run length compression" +#define NID_rle_compression 124 +#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L + +#define SN_zlib_compression "ZLIB" +#define LN_zlib_compression "zlib compression" +#define NID_zlib_compression 125 +#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L + +#define SN_ext_key_usage "extendedKeyUsage" +#define LN_ext_key_usage "X509v3 Extended Key Usage" +#define NID_ext_key_usage 126 +#define OBJ_ext_key_usage OBJ_id_ce,37 + +#define SN_id_pkix "PKIX" +#define NID_id_pkix 127 +#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L + +#define SN_id_kp "id-kp" +#define NID_id_kp 128 +#define OBJ_id_kp OBJ_id_pkix,3L + +/* PKIX extended key usage OIDs */ + +#define SN_server_auth "serverAuth" +#define LN_server_auth "TLS Web Server Authentication" +#define NID_server_auth 129 +#define OBJ_server_auth OBJ_id_kp,1L + +#define SN_client_auth "clientAuth" +#define LN_client_auth "TLS Web Client Authentication" +#define NID_client_auth 130 +#define OBJ_client_auth OBJ_id_kp,2L + +#define SN_code_sign "codeSigning" +#define LN_code_sign "Code Signing" +#define NID_code_sign 131 +#define OBJ_code_sign OBJ_id_kp,3L + +#define SN_email_protect "emailProtection" +#define LN_email_protect "E-mail Protection" +#define NID_email_protect 132 +#define OBJ_email_protect OBJ_id_kp,4L + +#define SN_time_stamp "timeStamping" +#define LN_time_stamp "Time Stamping" +#define NID_time_stamp 133 +#define OBJ_time_stamp OBJ_id_kp,8L + +/* Additional extended key usage OIDs: Microsoft */ + +#define SN_ms_code_ind "msCodeInd" +#define LN_ms_code_ind "Microsoft Individual Code Signing" +#define NID_ms_code_ind 134 +#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L + +#define SN_ms_code_com "msCodeCom" +#define LN_ms_code_com "Microsoft Commercial Code Signing" +#define NID_ms_code_com 135 +#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L + +#define SN_ms_ctl_sign "msCTLSign" +#define LN_ms_ctl_sign "Microsoft Trust List Signing" +#define NID_ms_ctl_sign 136 +#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L + +#define SN_ms_sgc "msSGC" +#define LN_ms_sgc "Microsoft Server Gated Crypto" +#define NID_ms_sgc 137 +#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L + +#define SN_ms_efs "msEFS" +#define LN_ms_efs "Microsoft Encrypted File System" +#define NID_ms_efs 138 +#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L + +/* Additional usage: Netscape */ + +#define SN_ns_sgc "nsSGC" +#define LN_ns_sgc "Netscape Server Gated Crypto" +#define NID_ns_sgc 139 +#define OBJ_ns_sgc OBJ_netscape,4L,1L + +#define SN_delta_crl "deltaCRL" +#define LN_delta_crl "X509v3 Delta CRL Indicator" +#define NID_delta_crl 140 +#define OBJ_delta_crl OBJ_id_ce,27L + +#define SN_crl_reason "CRLReason" +#define LN_crl_reason "CRL Reason Code" +#define NID_crl_reason 141 +#define OBJ_crl_reason OBJ_id_ce,21L + +#define SN_invalidity_date "invalidityDate" +#define LN_invalidity_date "Invalidity Date" +#define NID_invalidity_date 142 +#define OBJ_invalidity_date OBJ_id_ce,24L + +#define SN_sxnet "SXNetID" +#define LN_sxnet "Strong Extranet ID" +#define NID_sxnet 143 +#define OBJ_sxnet 1L,3L,101L,1L,4L,1L + +/* PKCS12 and related OBJECT IDENTIFIERS */ + +#define OBJ_pkcs12 OBJ_pkcs,12L +#define OBJ_pkcs12_pbeids OBJ_pkcs12, 1 + +#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" +#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" +#define NID_pbe_WithSHA1And128BitRC4 144 +#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids, 1L + +#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" +#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" +#define NID_pbe_WithSHA1And40BitRC4 145 +#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids, 2L + +#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" +#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 +#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 3L + +#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" +#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 +#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 4L + +#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" +#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" +#define NID_pbe_WithSHA1And128BitRC2_CBC 148 +#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids, 5L + +#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" +#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" +#define NID_pbe_WithSHA1And40BitRC2_CBC 149 +#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L + +#define OBJ_pkcs12_Version1 OBJ_pkcs12, 10L + +#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1, 1L + +#define LN_keyBag "keyBag" +#define NID_keyBag 150 +#define OBJ_keyBag OBJ_pkcs12_BagIds, 1L + +#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" +#define NID_pkcs8ShroudedKeyBag 151 +#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds, 2L + +#define LN_certBag "certBag" +#define NID_certBag 152 +#define OBJ_certBag OBJ_pkcs12_BagIds, 3L + +#define LN_crlBag "crlBag" +#define NID_crlBag 153 +#define OBJ_crlBag OBJ_pkcs12_BagIds, 4L + +#define LN_secretBag "secretBag" +#define NID_secretBag 154 +#define OBJ_secretBag OBJ_pkcs12_BagIds, 5L + +#define LN_safeContentsBag "safeContentsBag" +#define NID_safeContentsBag 155 +#define OBJ_safeContentsBag OBJ_pkcs12_BagIds, 6L + +#define LN_friendlyName "friendlyName" +#define NID_friendlyName 156 +#define OBJ_friendlyName OBJ_pkcs9, 20L + +#define LN_localKeyID "localKeyID" +#define NID_localKeyID 157 +#define OBJ_localKeyID OBJ_pkcs9, 21L + +#define OBJ_certTypes OBJ_pkcs9, 22L + +#define LN_x509Certificate "x509Certificate" +#define NID_x509Certificate 158 +#define OBJ_x509Certificate OBJ_certTypes, 1L + +#define LN_sdsiCertificate "sdsiCertificate" +#define NID_sdsiCertificate 159 +#define OBJ_sdsiCertificate OBJ_certTypes, 2L + +#define OBJ_crlTypes OBJ_pkcs9, 23L + +#define LN_x509Crl "x509Crl" +#define NID_x509Crl 160 +#define OBJ_x509Crl OBJ_crlTypes, 1L + +/* PKCS#5 v2 OIDs */ + +#define LN_pbes2 "PBES2" +#define NID_pbes2 161 +#define OBJ_pbes2 OBJ_pkcs,5L,13L + +#define LN_pbmac1 "PBMAC1" +#define NID_pbmac1 162 +#define OBJ_pbmac1 OBJ_pkcs,5L,14L + +#define LN_hmacWithSHA1 "hmacWithSHA1" +#define NID_hmacWithSHA1 163 +#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L + +/* Policy Qualifier Ids */ + +#define LN_id_qt_cps "Policy Qualifier CPS" +#define SN_id_qt_cps "id-qt-cps" +#define NID_id_qt_cps 164 +#define OBJ_id_qt_cps OBJ_id_pkix,2L,1L + +#define LN_id_qt_unotice "Policy Qualifier User Notice" +#define SN_id_qt_unotice "id-qt-unotice" +#define NID_id_qt_unotice 165 +#define OBJ_id_qt_unotice OBJ_id_pkix,2L,2L + +#define SN_rc2_64_cbc "RC2-64-CBC" +#define LN_rc2_64_cbc "rc2-64-cbc" +#define NID_rc2_64_cbc 166 + +#define SN_SMIMECapabilities "SMIME-CAPS" +#define LN_SMIMECapabilities "S/MIME Capabilities" +#define NID_SMIMECapabilities 167 +#define OBJ_SMIMECapabilities OBJ_pkcs9,15L + +#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" +#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" +#define NID_pbeWithMD2AndRC2_CBC 168 +#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs,5L,4L + +#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" +#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" +#define NID_pbeWithMD5AndRC2_CBC 169 +#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs,5L,6L + +#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" +#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" +#define NID_pbeWithSHA1AndDES_CBC 170 +#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs,5L,10L + +/* Extension request OIDs */ + +#define LN_ms_ext_req "Microsoft Extension Request" +#define SN_ms_ext_req "msExtReq" +#define NID_ms_ext_req 171 +#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L + +#define LN_ext_req "Extension Request" +#define SN_ext_req "extReq" +#define NID_ext_req 172 +#define OBJ_ext_req OBJ_pkcs9,14L + +#define SN_name "name" +#define LN_name "name" +#define NID_name 173 +#define OBJ_name OBJ_X509,41L + +#define SN_dnQualifier "dnQualifier" +#define LN_dnQualifier "dnQualifier" +#define NID_dnQualifier 174 +#define OBJ_dnQualifier OBJ_X509,46L + +#define SN_id_pe "id-pe" +#define NID_id_pe 175 +#define OBJ_id_pe OBJ_id_pkix,1L + +#define SN_id_ad "id-ad" +#define NID_id_ad 176 +#define OBJ_id_ad OBJ_id_pkix,48L + +#define SN_info_access "authorityInfoAccess" +#define LN_info_access "Authority Information Access" +#define NID_info_access 177 +#define OBJ_info_access OBJ_id_pe,1L + +#define SN_ad_OCSP "OCSP" +#define LN_ad_OCSP "OCSP" +#define NID_ad_OCSP 178 +#define OBJ_ad_OCSP OBJ_id_ad,1L + +#define SN_ad_ca_issuers "caIssuers" +#define LN_ad_ca_issuers "CA Issuers" +#define NID_ad_ca_issuers 179 +#define OBJ_ad_ca_issuers OBJ_id_ad,2L + +#define SN_OCSP_sign "OCSPSigning" +#define LN_OCSP_sign "OCSP Signing" +#define NID_OCSP_sign 180 +#define OBJ_OCSP_sign OBJ_id_kp,9L +#endif /* USE_OBJ_MAC */ + +#include +#include + +#define OBJ_NAME_TYPE_UNDEF 0x00 +#define OBJ_NAME_TYPE_MD_METH 0x01 +#define OBJ_NAME_TYPE_CIPHER_METH 0x02 +#define OBJ_NAME_TYPE_PKEY_METH 0x03 +#define OBJ_NAME_TYPE_COMP_METH 0x04 +#define OBJ_NAME_TYPE_NUM 0x05 + +#define OBJ_NAME_ALIAS 0x8000 + +#define OBJ_BSEARCH_VALUE_ON_NOMATCH 0x01 +#define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH 0x02 + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct obj_name_st + { + int type; + int alias; + const char *name; + const char *data; + } OBJ_NAME; + +#define OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c) + + +int OBJ_NAME_init(void); +int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *), + int (*cmp_func)(const char *, const char *), + void (*free_func)(const char *, int, const char *)); +const char *OBJ_NAME_get(const char *name,int type); +int OBJ_NAME_add(const char *name,int type,const char *data); +int OBJ_NAME_remove(const char *name,int type); +void OBJ_NAME_cleanup(int type); /* -1 for everything */ +void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg), + void *arg); +void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg), + void *arg); + +ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o); +ASN1_OBJECT * OBJ_nid2obj(int n); +const char * OBJ_nid2ln(int n); +const char * OBJ_nid2sn(int n); +int OBJ_obj2nid(const ASN1_OBJECT *o); +ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name); +int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name); +int OBJ_txt2nid(const char *s); +int OBJ_ln2nid(const char *s); +int OBJ_sn2nid(const char *s); +int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b); +const char * OBJ_bsearch(const char *key,const char *base,int num,int size, + int (*cmp)(const void *, const void *)); +const char * OBJ_bsearch_ex(const char *key,const char *base,int num, + int size, int (*cmp)(const void *, const void *), int flags); + +int OBJ_new_nid(int num); +int OBJ_add_object(const ASN1_OBJECT *obj); +int OBJ_create(const char *oid,const char *sn,const char *ln); +void OBJ_cleanup(void ); +int OBJ_create_objects(BIO *in); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_OBJ_strings(void); + +/* Error codes for the OBJ functions. */ + +/* Function codes. */ +#define OBJ_F_OBJ_ADD_OBJECT 105 +#define OBJ_F_OBJ_CREATE 100 +#define OBJ_F_OBJ_DUP 101 +#define OBJ_F_OBJ_NAME_NEW_INDEX 106 +#define OBJ_F_OBJ_NID2LN 102 +#define OBJ_F_OBJ_NID2OBJ 103 +#define OBJ_F_OBJ_NID2SN 104 + +/* Reason codes. */ +#define OBJ_R_MALLOC_FAILURE 100 +#define OBJ_R_UNKNOWN_NID 101 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/ocsp.h b/src/dep/include/openssl/ocsp.h index ceb35e5..2d4385d 100644 --- a/src/dep/include/openssl/ocsp.h +++ b/src/dep/include/openssl/ocsp.h @@ -1,614 +1,614 @@ -/* ocsp.h */ -/* Written by Tom Titchener for the OpenSSL - * project. */ - -/* History: - This file was transfered to Richard Levitte from CertCo by Kathy - Weinhold in mid-spring 2000 to be included in OpenSSL or released - as a patch kit. */ - -/* ==================================================================== - * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_OCSP_H -#define HEADER_OCSP_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Various flags and values */ - -#define OCSP_DEFAULT_NONCE_LENGTH 16 - -#define OCSP_NOCERTS 0x1 -#define OCSP_NOINTERN 0x2 -#define OCSP_NOSIGS 0x4 -#define OCSP_NOCHAIN 0x8 -#define OCSP_NOVERIFY 0x10 -#define OCSP_NOEXPLICIT 0x20 -#define OCSP_NOCASIGN 0x40 -#define OCSP_NODELEGATED 0x80 -#define OCSP_NOCHECKS 0x100 -#define OCSP_TRUSTOTHER 0x200 -#define OCSP_RESPID_KEY 0x400 -#define OCSP_NOTIME 0x800 - -/* CertID ::= SEQUENCE { - * hashAlgorithm AlgorithmIdentifier, - * issuerNameHash OCTET STRING, -- Hash of Issuer's DN - * issuerKeyHash OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields) - * serialNumber CertificateSerialNumber } - */ -typedef struct ocsp_cert_id_st - { - X509_ALGOR *hashAlgorithm; - ASN1_OCTET_STRING *issuerNameHash; - ASN1_OCTET_STRING *issuerKeyHash; - ASN1_INTEGER *serialNumber; - } OCSP_CERTID; - -DECLARE_STACK_OF(OCSP_CERTID) - -/* Request ::= SEQUENCE { - * reqCert CertID, - * singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL } - */ -typedef struct ocsp_one_request_st - { - OCSP_CERTID *reqCert; - STACK_OF(X509_EXTENSION) *singleRequestExtensions; - } OCSP_ONEREQ; - -DECLARE_STACK_OF(OCSP_ONEREQ) -DECLARE_ASN1_SET_OF(OCSP_ONEREQ) - - -/* TBSRequest ::= SEQUENCE { - * version [0] EXPLICIT Version DEFAULT v1, - * requestorName [1] EXPLICIT GeneralName OPTIONAL, - * requestList SEQUENCE OF Request, - * requestExtensions [2] EXPLICIT Extensions OPTIONAL } - */ -typedef struct ocsp_req_info_st - { - ASN1_INTEGER *version; - GENERAL_NAME *requestorName; - STACK_OF(OCSP_ONEREQ) *requestList; - STACK_OF(X509_EXTENSION) *requestExtensions; - } OCSP_REQINFO; - -/* Signature ::= SEQUENCE { - * signatureAlgorithm AlgorithmIdentifier, - * signature BIT STRING, - * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } - */ -typedef struct ocsp_signature_st - { - X509_ALGOR *signatureAlgorithm; - ASN1_BIT_STRING *signature; - STACK_OF(X509) *certs; - } OCSP_SIGNATURE; - -/* OCSPRequest ::= SEQUENCE { - * tbsRequest TBSRequest, - * optionalSignature [0] EXPLICIT Signature OPTIONAL } - */ -typedef struct ocsp_request_st - { - OCSP_REQINFO *tbsRequest; - OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */ - } OCSP_REQUEST; - -/* OCSPResponseStatus ::= ENUMERATED { - * successful (0), --Response has valid confirmations - * malformedRequest (1), --Illegal confirmation request - * internalError (2), --Internal error in issuer - * tryLater (3), --Try again later - * --(4) is not used - * sigRequired (5), --Must sign the request - * unauthorized (6) --Request unauthorized - * } - */ -#define OCSP_RESPONSE_STATUS_SUCCESSFUL 0 -#define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST 1 -#define OCSP_RESPONSE_STATUS_INTERNALERROR 2 -#define OCSP_RESPONSE_STATUS_TRYLATER 3 -#define OCSP_RESPONSE_STATUS_SIGREQUIRED 5 -#define OCSP_RESPONSE_STATUS_UNAUTHORIZED 6 - -/* ResponseBytes ::= SEQUENCE { - * responseType OBJECT IDENTIFIER, - * response OCTET STRING } - */ -typedef struct ocsp_resp_bytes_st - { - ASN1_OBJECT *responseType; - ASN1_OCTET_STRING *response; - } OCSP_RESPBYTES; - -/* OCSPResponse ::= SEQUENCE { - * responseStatus OCSPResponseStatus, - * responseBytes [0] EXPLICIT ResponseBytes OPTIONAL } - */ -typedef struct ocsp_response_st - { - ASN1_ENUMERATED *responseStatus; - OCSP_RESPBYTES *responseBytes; - } OCSP_RESPONSE; - -/* ResponderID ::= CHOICE { - * byName [1] Name, - * byKey [2] KeyHash } - */ -#define V_OCSP_RESPID_NAME 0 -#define V_OCSP_RESPID_KEY 1 -typedef struct ocsp_responder_id_st - { - int type; - union { - X509_NAME* byName; - ASN1_OCTET_STRING *byKey; - } value; - } OCSP_RESPID; -/* KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key - * --(excluding the tag and length fields) - */ - -/* RevokedInfo ::= SEQUENCE { - * revocationTime GeneralizedTime, - * revocationReason [0] EXPLICIT CRLReason OPTIONAL } - */ -typedef struct ocsp_revoked_info_st - { - ASN1_GENERALIZEDTIME *revocationTime; - ASN1_ENUMERATED *revocationReason; - } OCSP_REVOKEDINFO; - -/* CertStatus ::= CHOICE { - * good [0] IMPLICIT NULL, - * revoked [1] IMPLICIT RevokedInfo, - * unknown [2] IMPLICIT UnknownInfo } - */ -#define V_OCSP_CERTSTATUS_GOOD 0 -#define V_OCSP_CERTSTATUS_REVOKED 1 -#define V_OCSP_CERTSTATUS_UNKNOWN 2 -typedef struct ocsp_cert_status_st - { - int type; - union { - ASN1_NULL *good; - OCSP_REVOKEDINFO *revoked; - ASN1_NULL *unknown; - } value; - } OCSP_CERTSTATUS; - -/* SingleResponse ::= SEQUENCE { - * certID CertID, - * certStatus CertStatus, - * thisUpdate GeneralizedTime, - * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL, - * singleExtensions [1] EXPLICIT Extensions OPTIONAL } - */ -typedef struct ocsp_single_response_st - { - OCSP_CERTID *certId; - OCSP_CERTSTATUS *certStatus; - ASN1_GENERALIZEDTIME *thisUpdate; - ASN1_GENERALIZEDTIME *nextUpdate; - STACK_OF(X509_EXTENSION) *singleExtensions; - } OCSP_SINGLERESP; - -DECLARE_STACK_OF(OCSP_SINGLERESP) -DECLARE_ASN1_SET_OF(OCSP_SINGLERESP) - -/* ResponseData ::= SEQUENCE { - * version [0] EXPLICIT Version DEFAULT v1, - * responderID ResponderID, - * producedAt GeneralizedTime, - * responses SEQUENCE OF SingleResponse, - * responseExtensions [1] EXPLICIT Extensions OPTIONAL } - */ -typedef struct ocsp_response_data_st - { - ASN1_INTEGER *version; - OCSP_RESPID *responderId; - ASN1_GENERALIZEDTIME *producedAt; - STACK_OF(OCSP_SINGLERESP) *responses; - STACK_OF(X509_EXTENSION) *responseExtensions; - } OCSP_RESPDATA; - -/* BasicOCSPResponse ::= SEQUENCE { - * tbsResponseData ResponseData, - * signatureAlgorithm AlgorithmIdentifier, - * signature BIT STRING, - * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } - */ - /* Note 1: - The value for "signature" is specified in the OCSP rfc2560 as follows: - "The value for the signature SHALL be computed on the hash of the DER - encoding ResponseData." This means that you must hash the DER-encoded - tbsResponseData, and then run it through a crypto-signing function, which - will (at least w/RSA) do a hash-'n'-private-encrypt operation. This seems - a bit odd, but that's the spec. Also note that the data structures do not - leave anywhere to independently specify the algorithm used for the initial - hash. So, we look at the signature-specification algorithm, and try to do - something intelligent. -- Kathy Weinhold, CertCo */ - /* Note 2: - It seems that the mentioned passage from RFC 2560 (section 4.2.1) is open - for interpretation. I've done tests against another responder, and found - that it doesn't do the double hashing that the RFC seems to say one - should. Therefore, all relevant functions take a flag saying which - variant should be used. -- Richard Levitte, OpenSSL team and CeloCom */ -typedef struct ocsp_basic_response_st - { - OCSP_RESPDATA *tbsResponseData; - X509_ALGOR *signatureAlgorithm; - ASN1_BIT_STRING *signature; - STACK_OF(X509) *certs; - } OCSP_BASICRESP; - -/* - * CRLReason ::= ENUMERATED { - * unspecified (0), - * keyCompromise (1), - * cACompromise (2), - * affiliationChanged (3), - * superseded (4), - * cessationOfOperation (5), - * certificateHold (6), - * removeFromCRL (8) } - */ -#define OCSP_REVOKED_STATUS_NOSTATUS -1 -#define OCSP_REVOKED_STATUS_UNSPECIFIED 0 -#define OCSP_REVOKED_STATUS_KEYCOMPROMISE 1 -#define OCSP_REVOKED_STATUS_CACOMPROMISE 2 -#define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED 3 -#define OCSP_REVOKED_STATUS_SUPERSEDED 4 -#define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION 5 -#define OCSP_REVOKED_STATUS_CERTIFICATEHOLD 6 -#define OCSP_REVOKED_STATUS_REMOVEFROMCRL 8 - -/* CrlID ::= SEQUENCE { - * crlUrl [0] EXPLICIT IA5String OPTIONAL, - * crlNum [1] EXPLICIT INTEGER OPTIONAL, - * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL } - */ -typedef struct ocsp_crl_id_st - { - ASN1_IA5STRING *crlUrl; - ASN1_INTEGER *crlNum; - ASN1_GENERALIZEDTIME *crlTime; - } OCSP_CRLID; - -/* ServiceLocator ::= SEQUENCE { - * issuer Name, - * locator AuthorityInfoAccessSyntax OPTIONAL } - */ -typedef struct ocsp_service_locator_st - { - X509_NAME* issuer; - STACK_OF(ACCESS_DESCRIPTION) *locator; - } OCSP_SERVICELOC; - -#define PEM_STRING_OCSP_REQUEST "OCSP REQUEST" -#define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE" - -#define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p) - -#define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p) - -#define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \ - (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL) - -#define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\ - (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL) - -#define PEM_write_bio_OCSP_REQUEST(bp,o) \ - PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\ - bp,(char *)o, NULL,NULL,0,NULL,NULL) - -#define PEM_write_bio_OCSP_RESPONSE(bp,o) \ - PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\ - bp,(char *)o, NULL,NULL,0,NULL,NULL) - -#define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o) - -#define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o) - -#define OCSP_REQUEST_sign(o,pkey,md) \ - ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\ - o->optionalSignature->signatureAlgorithm,NULL,\ - o->optionalSignature->signature,o->tbsRequest,pkey,md) - -#define OCSP_BASICRESP_sign(o,pkey,md,d) \ - ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\ - o->signature,o->tbsResponseData,pkey,md) - -#define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\ - a->optionalSignature->signatureAlgorithm,\ - a->optionalSignature->signature,a->tbsRequest,r) - -#define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\ - a->signatureAlgorithm,a->signature,a->tbsResponseData,r) - -#define ASN1_BIT_STRING_digest(data,type,md,len) \ - ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len) - -#define OCSP_CERTID_dup(cid) ASN1_dup_of(OCSP_CERTID,i2d_OCSP_CERTID,d2i_OCSP_CERTID,cid) - -#define OCSP_CERTSTATUS_dup(cs)\ - (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\ - (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs)) - -OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req); - -OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer); - -OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, - X509_NAME *issuerName, - ASN1_BIT_STRING* issuerKey, - ASN1_INTEGER *serialNumber); - -OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid); - -int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len); -int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len); -int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs); -int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req); - -int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm); -int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert); - -int OCSP_request_sign(OCSP_REQUEST *req, - X509 *signer, - EVP_PKEY *key, - const EVP_MD *dgst, - STACK_OF(X509) *certs, - unsigned long flags); - -int OCSP_response_status(OCSP_RESPONSE *resp); -OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp); - -int OCSP_resp_count(OCSP_BASICRESP *bs); -OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx); -int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last); -int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason, - ASN1_GENERALIZEDTIME **revtime, - ASN1_GENERALIZEDTIME **thisupd, - ASN1_GENERALIZEDTIME **nextupd); -int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status, - int *reason, - ASN1_GENERALIZEDTIME **revtime, - ASN1_GENERALIZEDTIME **thisupd, - ASN1_GENERALIZEDTIME **nextupd); -int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, - ASN1_GENERALIZEDTIME *nextupd, - long sec, long maxsec); - -int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, X509_STORE *store, unsigned long flags); - -int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl); - -int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b); -int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b); - -int OCSP_request_onereq_count(OCSP_REQUEST *req); -OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i); -OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one); -int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd, - ASN1_OCTET_STRING **pikeyHash, - ASN1_INTEGER **pserial, OCSP_CERTID *cid); -int OCSP_request_is_signed(OCSP_REQUEST *req); -OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs); -OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, - OCSP_CERTID *cid, - int status, int reason, - ASN1_TIME *revtime, - ASN1_TIME *thisupd, ASN1_TIME *nextupd); -int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert); -int OCSP_basic_sign(OCSP_BASICRESP *brsp, - X509 *signer, EVP_PKEY *key, const EVP_MD *dgst, - STACK_OF(X509) *certs, unsigned long flags); - -ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d, - void *data, STACK_OF(ASN1_OBJECT) *sk); -#define ASN1_STRING_encode_of(type,s,i2d,data,sk) \ -((ASN1_STRING *(*)(ASN1_STRING *,I2D_OF(type),type *,STACK_OF(ASN1_OBJECT) *))openssl_fcast(ASN1_STRING_encode))(s,i2d,data,sk) - -X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim); - -X509_EXTENSION *OCSP_accept_responses_new(char **oids); - -X509_EXTENSION *OCSP_archive_cutoff_new(char* tim); - -X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls); - -int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x); -int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos); -int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, int lastpos); -int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos); -X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc); -X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc); -void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx); -int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit, - unsigned long flags); -int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc); - -int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x); -int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos); -int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos); -int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos); -X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc); -X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc); -void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx); -int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit, - unsigned long flags); -int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc); - -int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x); -int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos); -int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, int lastpos); -int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos); -X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc); -X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc); -void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, int *idx); -int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, int crit, - unsigned long flags); -int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc); - -int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x); -int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos); -int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj, int lastpos); -int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, int lastpos); -X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc); -X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc); -void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, int *idx); -int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, int crit, - unsigned long flags); -int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc); - -DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP) -DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS) -DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO) -DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP) -DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA) -DECLARE_ASN1_FUNCTIONS(OCSP_RESPID) -DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE) -DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES) -DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ) -DECLARE_ASN1_FUNCTIONS(OCSP_CERTID) -DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST) -DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE) -DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO) -DECLARE_ASN1_FUNCTIONS(OCSP_CRLID) -DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC) - -char *OCSP_response_status_str(long s); -char *OCSP_cert_status_str(long s); -char *OCSP_crl_reason_str(long s); - -int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags); -int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags); - -int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs, - X509_STORE *st, unsigned long flags); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_OCSP_strings(void); - -/* Error codes for the OCSP functions. */ - -/* Function codes. */ -#define OCSP_F_ASN1_STRING_ENCODE 100 -#define OCSP_F_D2I_OCSP_NONCE 102 -#define OCSP_F_OCSP_BASIC_ADD1_STATUS 103 -#define OCSP_F_OCSP_BASIC_SIGN 104 -#define OCSP_F_OCSP_BASIC_VERIFY 105 -#define OCSP_F_OCSP_CERT_ID_NEW 101 -#define OCSP_F_OCSP_CHECK_DELEGATED 106 -#define OCSP_F_OCSP_CHECK_IDS 107 -#define OCSP_F_OCSP_CHECK_ISSUER 108 -#define OCSP_F_OCSP_CHECK_VALIDITY 115 -#define OCSP_F_OCSP_MATCH_ISSUERID 109 -#define OCSP_F_OCSP_PARSE_URL 114 -#define OCSP_F_OCSP_REQUEST_SIGN 110 -#define OCSP_F_OCSP_REQUEST_VERIFY 116 -#define OCSP_F_OCSP_RESPONSE_GET1_BASIC 111 -#define OCSP_F_OCSP_SENDREQ_BIO 112 -#define OCSP_F_REQUEST_VERIFY 113 - -/* Reason codes. */ -#define OCSP_R_BAD_DATA 100 -#define OCSP_R_CERTIFICATE_VERIFY_ERROR 101 -#define OCSP_R_DIGEST_ERR 102 -#define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122 -#define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123 -#define OCSP_R_ERROR_PARSING_URL 121 -#define OCSP_R_MISSING_OCSPSIGNING_USAGE 103 -#define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124 -#define OCSP_R_NOT_BASIC_RESPONSE 104 -#define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105 -#define OCSP_R_NO_CONTENT 106 -#define OCSP_R_NO_PUBLIC_KEY 107 -#define OCSP_R_NO_RESPONSE_DATA 108 -#define OCSP_R_NO_REVOKED_TIME 109 -#define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110 -#define OCSP_R_REQUEST_NOT_SIGNED 128 -#define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111 -#define OCSP_R_ROOT_CA_NOT_TRUSTED 112 -#define OCSP_R_SERVER_READ_ERROR 113 -#define OCSP_R_SERVER_RESPONSE_ERROR 114 -#define OCSP_R_SERVER_RESPONSE_PARSE_ERROR 115 -#define OCSP_R_SERVER_WRITE_ERROR 116 -#define OCSP_R_SIGNATURE_FAILURE 117 -#define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118 -#define OCSP_R_STATUS_EXPIRED 125 -#define OCSP_R_STATUS_NOT_YET_VALID 126 -#define OCSP_R_STATUS_TOO_OLD 127 -#define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119 -#define OCSP_R_UNKNOWN_NID 120 -#define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129 - -#ifdef __cplusplus -} -#endif -#endif +/* ocsp.h */ +/* Written by Tom Titchener for the OpenSSL + * project. */ + +/* History: + This file was transfered to Richard Levitte from CertCo by Kathy + Weinhold in mid-spring 2000 to be included in OpenSSL or released + as a patch kit. */ + +/* ==================================================================== + * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_OCSP_H +#define HEADER_OCSP_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Various flags and values */ + +#define OCSP_DEFAULT_NONCE_LENGTH 16 + +#define OCSP_NOCERTS 0x1 +#define OCSP_NOINTERN 0x2 +#define OCSP_NOSIGS 0x4 +#define OCSP_NOCHAIN 0x8 +#define OCSP_NOVERIFY 0x10 +#define OCSP_NOEXPLICIT 0x20 +#define OCSP_NOCASIGN 0x40 +#define OCSP_NODELEGATED 0x80 +#define OCSP_NOCHECKS 0x100 +#define OCSP_TRUSTOTHER 0x200 +#define OCSP_RESPID_KEY 0x400 +#define OCSP_NOTIME 0x800 + +/* CertID ::= SEQUENCE { + * hashAlgorithm AlgorithmIdentifier, + * issuerNameHash OCTET STRING, -- Hash of Issuer's DN + * issuerKeyHash OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields) + * serialNumber CertificateSerialNumber } + */ +typedef struct ocsp_cert_id_st + { + X509_ALGOR *hashAlgorithm; + ASN1_OCTET_STRING *issuerNameHash; + ASN1_OCTET_STRING *issuerKeyHash; + ASN1_INTEGER *serialNumber; + } OCSP_CERTID; + +DECLARE_STACK_OF(OCSP_CERTID) + +/* Request ::= SEQUENCE { + * reqCert CertID, + * singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_one_request_st + { + OCSP_CERTID *reqCert; + STACK_OF(X509_EXTENSION) *singleRequestExtensions; + } OCSP_ONEREQ; + +DECLARE_STACK_OF(OCSP_ONEREQ) +DECLARE_ASN1_SET_OF(OCSP_ONEREQ) + + +/* TBSRequest ::= SEQUENCE { + * version [0] EXPLICIT Version DEFAULT v1, + * requestorName [1] EXPLICIT GeneralName OPTIONAL, + * requestList SEQUENCE OF Request, + * requestExtensions [2] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_req_info_st + { + ASN1_INTEGER *version; + GENERAL_NAME *requestorName; + STACK_OF(OCSP_ONEREQ) *requestList; + STACK_OF(X509_EXTENSION) *requestExtensions; + } OCSP_REQINFO; + +/* Signature ::= SEQUENCE { + * signatureAlgorithm AlgorithmIdentifier, + * signature BIT STRING, + * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } + */ +typedef struct ocsp_signature_st + { + X509_ALGOR *signatureAlgorithm; + ASN1_BIT_STRING *signature; + STACK_OF(X509) *certs; + } OCSP_SIGNATURE; + +/* OCSPRequest ::= SEQUENCE { + * tbsRequest TBSRequest, + * optionalSignature [0] EXPLICIT Signature OPTIONAL } + */ +typedef struct ocsp_request_st + { + OCSP_REQINFO *tbsRequest; + OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */ + } OCSP_REQUEST; + +/* OCSPResponseStatus ::= ENUMERATED { + * successful (0), --Response has valid confirmations + * malformedRequest (1), --Illegal confirmation request + * internalError (2), --Internal error in issuer + * tryLater (3), --Try again later + * --(4) is not used + * sigRequired (5), --Must sign the request + * unauthorized (6) --Request unauthorized + * } + */ +#define OCSP_RESPONSE_STATUS_SUCCESSFUL 0 +#define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST 1 +#define OCSP_RESPONSE_STATUS_INTERNALERROR 2 +#define OCSP_RESPONSE_STATUS_TRYLATER 3 +#define OCSP_RESPONSE_STATUS_SIGREQUIRED 5 +#define OCSP_RESPONSE_STATUS_UNAUTHORIZED 6 + +/* ResponseBytes ::= SEQUENCE { + * responseType OBJECT IDENTIFIER, + * response OCTET STRING } + */ +typedef struct ocsp_resp_bytes_st + { + ASN1_OBJECT *responseType; + ASN1_OCTET_STRING *response; + } OCSP_RESPBYTES; + +/* OCSPResponse ::= SEQUENCE { + * responseStatus OCSPResponseStatus, + * responseBytes [0] EXPLICIT ResponseBytes OPTIONAL } + */ +typedef struct ocsp_response_st + { + ASN1_ENUMERATED *responseStatus; + OCSP_RESPBYTES *responseBytes; + } OCSP_RESPONSE; + +/* ResponderID ::= CHOICE { + * byName [1] Name, + * byKey [2] KeyHash } + */ +#define V_OCSP_RESPID_NAME 0 +#define V_OCSP_RESPID_KEY 1 +typedef struct ocsp_responder_id_st + { + int type; + union { + X509_NAME* byName; + ASN1_OCTET_STRING *byKey; + } value; + } OCSP_RESPID; +/* KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key + * --(excluding the tag and length fields) + */ + +/* RevokedInfo ::= SEQUENCE { + * revocationTime GeneralizedTime, + * revocationReason [0] EXPLICIT CRLReason OPTIONAL } + */ +typedef struct ocsp_revoked_info_st + { + ASN1_GENERALIZEDTIME *revocationTime; + ASN1_ENUMERATED *revocationReason; + } OCSP_REVOKEDINFO; + +/* CertStatus ::= CHOICE { + * good [0] IMPLICIT NULL, + * revoked [1] IMPLICIT RevokedInfo, + * unknown [2] IMPLICIT UnknownInfo } + */ +#define V_OCSP_CERTSTATUS_GOOD 0 +#define V_OCSP_CERTSTATUS_REVOKED 1 +#define V_OCSP_CERTSTATUS_UNKNOWN 2 +typedef struct ocsp_cert_status_st + { + int type; + union { + ASN1_NULL *good; + OCSP_REVOKEDINFO *revoked; + ASN1_NULL *unknown; + } value; + } OCSP_CERTSTATUS; + +/* SingleResponse ::= SEQUENCE { + * certID CertID, + * certStatus CertStatus, + * thisUpdate GeneralizedTime, + * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL, + * singleExtensions [1] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_single_response_st + { + OCSP_CERTID *certId; + OCSP_CERTSTATUS *certStatus; + ASN1_GENERALIZEDTIME *thisUpdate; + ASN1_GENERALIZEDTIME *nextUpdate; + STACK_OF(X509_EXTENSION) *singleExtensions; + } OCSP_SINGLERESP; + +DECLARE_STACK_OF(OCSP_SINGLERESP) +DECLARE_ASN1_SET_OF(OCSP_SINGLERESP) + +/* ResponseData ::= SEQUENCE { + * version [0] EXPLICIT Version DEFAULT v1, + * responderID ResponderID, + * producedAt GeneralizedTime, + * responses SEQUENCE OF SingleResponse, + * responseExtensions [1] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_response_data_st + { + ASN1_INTEGER *version; + OCSP_RESPID *responderId; + ASN1_GENERALIZEDTIME *producedAt; + STACK_OF(OCSP_SINGLERESP) *responses; + STACK_OF(X509_EXTENSION) *responseExtensions; + } OCSP_RESPDATA; + +/* BasicOCSPResponse ::= SEQUENCE { + * tbsResponseData ResponseData, + * signatureAlgorithm AlgorithmIdentifier, + * signature BIT STRING, + * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } + */ + /* Note 1: + The value for "signature" is specified in the OCSP rfc2560 as follows: + "The value for the signature SHALL be computed on the hash of the DER + encoding ResponseData." This means that you must hash the DER-encoded + tbsResponseData, and then run it through a crypto-signing function, which + will (at least w/RSA) do a hash-'n'-private-encrypt operation. This seems + a bit odd, but that's the spec. Also note that the data structures do not + leave anywhere to independently specify the algorithm used for the initial + hash. So, we look at the signature-specification algorithm, and try to do + something intelligent. -- Kathy Weinhold, CertCo */ + /* Note 2: + It seems that the mentioned passage from RFC 2560 (section 4.2.1) is open + for interpretation. I've done tests against another responder, and found + that it doesn't do the double hashing that the RFC seems to say one + should. Therefore, all relevant functions take a flag saying which + variant should be used. -- Richard Levitte, OpenSSL team and CeloCom */ +typedef struct ocsp_basic_response_st + { + OCSP_RESPDATA *tbsResponseData; + X509_ALGOR *signatureAlgorithm; + ASN1_BIT_STRING *signature; + STACK_OF(X509) *certs; + } OCSP_BASICRESP; + +/* + * CRLReason ::= ENUMERATED { + * unspecified (0), + * keyCompromise (1), + * cACompromise (2), + * affiliationChanged (3), + * superseded (4), + * cessationOfOperation (5), + * certificateHold (6), + * removeFromCRL (8) } + */ +#define OCSP_REVOKED_STATUS_NOSTATUS -1 +#define OCSP_REVOKED_STATUS_UNSPECIFIED 0 +#define OCSP_REVOKED_STATUS_KEYCOMPROMISE 1 +#define OCSP_REVOKED_STATUS_CACOMPROMISE 2 +#define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED 3 +#define OCSP_REVOKED_STATUS_SUPERSEDED 4 +#define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION 5 +#define OCSP_REVOKED_STATUS_CERTIFICATEHOLD 6 +#define OCSP_REVOKED_STATUS_REMOVEFROMCRL 8 + +/* CrlID ::= SEQUENCE { + * crlUrl [0] EXPLICIT IA5String OPTIONAL, + * crlNum [1] EXPLICIT INTEGER OPTIONAL, + * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL } + */ +typedef struct ocsp_crl_id_st + { + ASN1_IA5STRING *crlUrl; + ASN1_INTEGER *crlNum; + ASN1_GENERALIZEDTIME *crlTime; + } OCSP_CRLID; + +/* ServiceLocator ::= SEQUENCE { + * issuer Name, + * locator AuthorityInfoAccessSyntax OPTIONAL } + */ +typedef struct ocsp_service_locator_st + { + X509_NAME* issuer; + STACK_OF(ACCESS_DESCRIPTION) *locator; + } OCSP_SERVICELOC; + +#define PEM_STRING_OCSP_REQUEST "OCSP REQUEST" +#define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE" + +#define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p) + +#define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p) + +#define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL) + +#define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\ + (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL) + +#define PEM_write_bio_OCSP_REQUEST(bp,o) \ + PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\ + bp,(char *)o, NULL,NULL,0,NULL,NULL) + +#define PEM_write_bio_OCSP_RESPONSE(bp,o) \ + PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\ + bp,(char *)o, NULL,NULL,0,NULL,NULL) + +#define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o) + +#define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o) + +#define OCSP_REQUEST_sign(o,pkey,md) \ + ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\ + o->optionalSignature->signatureAlgorithm,NULL,\ + o->optionalSignature->signature,o->tbsRequest,pkey,md) + +#define OCSP_BASICRESP_sign(o,pkey,md,d) \ + ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\ + o->signature,o->tbsResponseData,pkey,md) + +#define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\ + a->optionalSignature->signatureAlgorithm,\ + a->optionalSignature->signature,a->tbsRequest,r) + +#define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\ + a->signatureAlgorithm,a->signature,a->tbsResponseData,r) + +#define ASN1_BIT_STRING_digest(data,type,md,len) \ + ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len) + +#define OCSP_CERTID_dup(cid) ASN1_dup_of(OCSP_CERTID,i2d_OCSP_CERTID,d2i_OCSP_CERTID,cid) + +#define OCSP_CERTSTATUS_dup(cs)\ + (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\ + (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs)) + +OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req); + +OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer); + +OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, + X509_NAME *issuerName, + ASN1_BIT_STRING* issuerKey, + ASN1_INTEGER *serialNumber); + +OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid); + +int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len); +int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len); +int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs); +int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req); + +int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm); +int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert); + +int OCSP_request_sign(OCSP_REQUEST *req, + X509 *signer, + EVP_PKEY *key, + const EVP_MD *dgst, + STACK_OF(X509) *certs, + unsigned long flags); + +int OCSP_response_status(OCSP_RESPONSE *resp); +OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp); + +int OCSP_resp_count(OCSP_BASICRESP *bs); +OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx); +int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last); +int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason, + ASN1_GENERALIZEDTIME **revtime, + ASN1_GENERALIZEDTIME **thisupd, + ASN1_GENERALIZEDTIME **nextupd); +int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status, + int *reason, + ASN1_GENERALIZEDTIME **revtime, + ASN1_GENERALIZEDTIME **thisupd, + ASN1_GENERALIZEDTIME **nextupd); +int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, + ASN1_GENERALIZEDTIME *nextupd, + long sec, long maxsec); + +int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, X509_STORE *store, unsigned long flags); + +int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl); + +int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b); +int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b); + +int OCSP_request_onereq_count(OCSP_REQUEST *req); +OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i); +OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one); +int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd, + ASN1_OCTET_STRING **pikeyHash, + ASN1_INTEGER **pserial, OCSP_CERTID *cid); +int OCSP_request_is_signed(OCSP_REQUEST *req); +OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs); +OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, + OCSP_CERTID *cid, + int status, int reason, + ASN1_TIME *revtime, + ASN1_TIME *thisupd, ASN1_TIME *nextupd); +int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert); +int OCSP_basic_sign(OCSP_BASICRESP *brsp, + X509 *signer, EVP_PKEY *key, const EVP_MD *dgst, + STACK_OF(X509) *certs, unsigned long flags); + +ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d, + void *data, STACK_OF(ASN1_OBJECT) *sk); +#define ASN1_STRING_encode_of(type,s,i2d,data,sk) \ +((ASN1_STRING *(*)(ASN1_STRING *,I2D_OF(type),type *,STACK_OF(ASN1_OBJECT) *))openssl_fcast(ASN1_STRING_encode))(s,i2d,data,sk) + +X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim); + +X509_EXTENSION *OCSP_accept_responses_new(char **oids); + +X509_EXTENSION *OCSP_archive_cutoff_new(char* tim); + +X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls); + +int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x); +int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos); +int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos); +X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc); +X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc); +void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx); +int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc); + +int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x); +int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos); +int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos); +X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc); +X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc); +void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx); +int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc); + +int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x); +int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos); +int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos); +X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc); +X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc); +void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, int *idx); +int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc); + +int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x); +int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos); +int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, int lastpos); +X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc); +X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc); +void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, int *idx); +int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc); + +DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP) +DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS) +DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO) +DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPID) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES) +DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ) +DECLARE_ASN1_FUNCTIONS(OCSP_CERTID) +DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST) +DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE) +DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO) +DECLARE_ASN1_FUNCTIONS(OCSP_CRLID) +DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC) + +char *OCSP_response_status_str(long s); +char *OCSP_cert_status_str(long s); +char *OCSP_crl_reason_str(long s); + +int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags); +int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags); + +int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs, + X509_STORE *st, unsigned long flags); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_OCSP_strings(void); + +/* Error codes for the OCSP functions. */ + +/* Function codes. */ +#define OCSP_F_ASN1_STRING_ENCODE 100 +#define OCSP_F_D2I_OCSP_NONCE 102 +#define OCSP_F_OCSP_BASIC_ADD1_STATUS 103 +#define OCSP_F_OCSP_BASIC_SIGN 104 +#define OCSP_F_OCSP_BASIC_VERIFY 105 +#define OCSP_F_OCSP_CERT_ID_NEW 101 +#define OCSP_F_OCSP_CHECK_DELEGATED 106 +#define OCSP_F_OCSP_CHECK_IDS 107 +#define OCSP_F_OCSP_CHECK_ISSUER 108 +#define OCSP_F_OCSP_CHECK_VALIDITY 115 +#define OCSP_F_OCSP_MATCH_ISSUERID 109 +#define OCSP_F_OCSP_PARSE_URL 114 +#define OCSP_F_OCSP_REQUEST_SIGN 110 +#define OCSP_F_OCSP_REQUEST_VERIFY 116 +#define OCSP_F_OCSP_RESPONSE_GET1_BASIC 111 +#define OCSP_F_OCSP_SENDREQ_BIO 112 +#define OCSP_F_REQUEST_VERIFY 113 + +/* Reason codes. */ +#define OCSP_R_BAD_DATA 100 +#define OCSP_R_CERTIFICATE_VERIFY_ERROR 101 +#define OCSP_R_DIGEST_ERR 102 +#define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122 +#define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123 +#define OCSP_R_ERROR_PARSING_URL 121 +#define OCSP_R_MISSING_OCSPSIGNING_USAGE 103 +#define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124 +#define OCSP_R_NOT_BASIC_RESPONSE 104 +#define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105 +#define OCSP_R_NO_CONTENT 106 +#define OCSP_R_NO_PUBLIC_KEY 107 +#define OCSP_R_NO_RESPONSE_DATA 108 +#define OCSP_R_NO_REVOKED_TIME 109 +#define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110 +#define OCSP_R_REQUEST_NOT_SIGNED 128 +#define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111 +#define OCSP_R_ROOT_CA_NOT_TRUSTED 112 +#define OCSP_R_SERVER_READ_ERROR 113 +#define OCSP_R_SERVER_RESPONSE_ERROR 114 +#define OCSP_R_SERVER_RESPONSE_PARSE_ERROR 115 +#define OCSP_R_SERVER_WRITE_ERROR 116 +#define OCSP_R_SIGNATURE_FAILURE 117 +#define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118 +#define OCSP_R_STATUS_EXPIRED 125 +#define OCSP_R_STATUS_NOT_YET_VALID 126 +#define OCSP_R_STATUS_TOO_OLD 127 +#define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119 +#define OCSP_R_UNKNOWN_NID 120 +#define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/opensslconf.h b/src/dep/include/openssl/opensslconf.h index 5bb4336..d216fc5 100644 --- a/src/dep/include/openssl/opensslconf.h +++ b/src/dep/include/openssl/opensslconf.h @@ -1,206 +1,206 @@ -/* opensslconf.h */ -/* WARNING: Generated automatically from opensslconf.h.in by Configure. */ - -/* OpenSSL was configured with the following options: */ -#ifndef OPENSSL_SYSNAME_WIN32 -# define OPENSSL_SYSNAME_WIN32 -#endif -#ifndef OPENSSL_DOING_MAKEDEPEND - -#ifndef OPENSSL_NO_GMP -# define OPENSSL_NO_GMP -#endif -#ifndef OPENSSL_NO_KRB5 -# define OPENSSL_NO_KRB5 -#endif -#ifndef OPENSSL_NO_MDC2 -# define OPENSSL_NO_MDC2 -#endif -#ifndef OPENSSL_NO_RC5 -# define OPENSSL_NO_RC5 -#endif - -#endif /* OPENSSL_DOING_MAKEDEPEND */ -#ifndef OPENSSL_THREADS -# define OPENSSL_THREADS -#endif - -/* The OPENSSL_NO_* macros are also defined as NO_* if the application - asks for it. This is a transient feature that is provided for those - who haven't had the time to do the appropriate changes in their - applications. */ -#ifdef OPENSSL_ALGORITHM_DEFINES -# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP) -# define NO_GMP -# endif -# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5) -# define NO_KRB5 -# endif -# if defined(OPENSSL_NO_MDC2) && !defined(NO_MDC2) -# define NO_MDC2 -# endif -# if defined(OPENSSL_NO_RC5) && !defined(NO_RC5) -# define NO_RC5 -# endif -#endif - -/* crypto/opensslconf.h.in */ - -/* Generate 80386 code? */ -#undef I386_ONLY - -#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */ -#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) -#define ENGINESDIR "/usr/local/ssl/lib/engines" -#define OPENSSLDIR "/usr/local/ssl" -#endif -#endif - -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - -#undef OPENSSL_EXPORT_VAR_AS_FUNCTION -#define OPENSSL_EXPORT_VAR_AS_FUNCTION - -#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) -#define IDEA_INT unsigned int -#endif - -#if defined(HEADER_MD2_H) && !defined(MD2_INT) -#define MD2_INT unsigned int -#endif - -#if defined(HEADER_RC2_H) && !defined(RC2_INT) -/* I need to put in a mod for the alpha - eay */ -#define RC2_INT unsigned int -#endif - -#if defined(HEADER_RC4_H) -#if !defined(RC4_INT) -/* using int types make the structure larger but make the code faster - * on most boxes I have tested - up to %20 faster. */ -/* - * I don't know what does "most" mean, but declaring "int" is a must on: - * - Intel P6 because partial register stalls are very expensive; - * - elder Alpha because it lacks byte load/store instructions; - */ -#define RC4_INT unsigned int -#endif -#if !defined(RC4_CHUNK) -/* - * This enables code handling data aligned at natural CPU word - * boundary. See crypto/rc4/rc4_enc.c for further details. - */ -#undef RC4_CHUNK -#endif -#endif - -#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) -/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a - * %20 speed up (longs are 8 bytes, int's are 4). */ -#ifndef DES_LONG -#define DES_LONG unsigned long -#endif -#endif - -#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) -#define CONFIG_HEADER_BN_H -#define BN_LLONG - -/* Should we define BN_DIV2W here? */ - -/* Only one for the following should be defined */ -/* The prime number generation stuff may not work when - * EIGHT_BIT but I don't care since I've only used this mode - * for debuging the bignum libraries */ -#undef SIXTY_FOUR_BIT_LONG -#undef SIXTY_FOUR_BIT -#define THIRTY_TWO_BIT -#undef SIXTEEN_BIT -#undef EIGHT_BIT -#endif - -#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) -#define CONFIG_HEADER_RC4_LOCL_H -/* if this is defined data[i] is used instead of *data, this is a %20 - * speedup on x86 */ -#define RC4_INDEX -#endif - -#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) -#define CONFIG_HEADER_BF_LOCL_H -#undef BF_PTR -#endif /* HEADER_BF_LOCL_H */ - -#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) -#define CONFIG_HEADER_DES_LOCL_H -#ifndef DES_DEFAULT_OPTIONS -/* the following is tweaked from a config script, that is why it is a - * protected undef/define */ -#ifndef DES_PTR -#undef DES_PTR -#endif - -/* This helps C compiler generate the correct code for multiple functional - * units. It reduces register dependancies at the expense of 2 more - * registers */ -#ifndef DES_RISC1 -#undef DES_RISC1 -#endif - -#ifndef DES_RISC2 -#undef DES_RISC2 -#endif - -#if defined(DES_RISC1) && defined(DES_RISC2) -YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! -#endif - -/* Unroll the inner loop, this sometimes helps, sometimes hinders. - * Very mucy CPU dependant */ -#ifndef DES_UNROLL -#undef DES_UNROLL -#endif - -/* These default values were supplied by - * Peter Gutman - * They are only used if nothing else has been defined */ -#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) -/* Special defines which change the way the code is built depending on the - CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find - even newer MIPS CPU's, but at the moment one size fits all for - optimization options. Older Sparc's work better with only UNROLL, but - there's no way to tell at compile time what it is you're running on */ - -#if defined( sun ) /* Newer Sparc's */ -# define DES_PTR -# define DES_RISC1 -# define DES_UNROLL -#elif defined( __ultrix ) /* Older MIPS */ -# define DES_PTR -# define DES_RISC2 -# define DES_UNROLL -#elif defined( __osf1__ ) /* Alpha */ -# define DES_PTR -# define DES_RISC2 -#elif defined ( _AIX ) /* RS6000 */ - /* Unknown */ -#elif defined( __hpux ) /* HP-PA */ - /* Unknown */ -#elif defined( __aux ) /* 68K */ - /* Unknown */ -#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ -# define DES_UNROLL -#elif defined( __sgi ) /* Newer MIPS */ -# define DES_PTR -# define DES_RISC2 -# define DES_UNROLL -#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ -# define DES_PTR -# define DES_RISC1 -# define DES_UNROLL -#endif /* Systems-specific speed defines */ -#endif - -#endif /* DES_DEFAULT_OPTIONS */ -#endif /* HEADER_DES_LOCL_H */ +/* opensslconf.h */ +/* WARNING: Generated automatically from opensslconf.h.in by Configure. */ + +/* OpenSSL was configured with the following options: */ +#ifndef OPENSSL_SYSNAME_WIN32 +# define OPENSSL_SYSNAME_WIN32 +#endif +#ifndef OPENSSL_DOING_MAKEDEPEND + +#ifndef OPENSSL_NO_GMP +# define OPENSSL_NO_GMP +#endif +#ifndef OPENSSL_NO_KRB5 +# define OPENSSL_NO_KRB5 +#endif +#ifndef OPENSSL_NO_MDC2 +# define OPENSSL_NO_MDC2 +#endif +#ifndef OPENSSL_NO_RC5 +# define OPENSSL_NO_RC5 +#endif + +#endif /* OPENSSL_DOING_MAKEDEPEND */ +#ifndef OPENSSL_THREADS +# define OPENSSL_THREADS +#endif + +/* The OPENSSL_NO_* macros are also defined as NO_* if the application + asks for it. This is a transient feature that is provided for those + who haven't had the time to do the appropriate changes in their + applications. */ +#ifdef OPENSSL_ALGORITHM_DEFINES +# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP) +# define NO_GMP +# endif +# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5) +# define NO_KRB5 +# endif +# if defined(OPENSSL_NO_MDC2) && !defined(NO_MDC2) +# define NO_MDC2 +# endif +# if defined(OPENSSL_NO_RC5) && !defined(NO_RC5) +# define NO_RC5 +# endif +#endif + +/* crypto/opensslconf.h.in */ + +/* Generate 80386 code? */ +#undef I386_ONLY + +#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */ +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define ENGINESDIR "/usr/local/ssl/lib/engines" +#define OPENSSLDIR "/usr/local/ssl" +#endif +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION +#define OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#undef RC4_CHUNK +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned long +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#define BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debuging the bignum libraries */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#define THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#define RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependancies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very mucy CPU dependant */ +#ifndef DES_UNROLL +#undef DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/src/dep/include/openssl/opensslv.h b/src/dep/include/openssl/opensslv.h index 8f1e44a..c303b06 100644 --- a/src/dep/include/openssl/opensslv.h +++ b/src/dep/include/openssl/opensslv.h @@ -1,89 +1,89 @@ -#ifndef HEADER_OPENSSLV_H -#define HEADER_OPENSSLV_H - -/* Numeric release version identifier: - * MNNFFPPS: major minor fix patch status - * The status nibble has one of the values 0 for development, 1 to e for betas - * 1 to 14, and f for release. The patch level is exactly that. - * For example: - * 0.9.3-dev 0x00903000 - * 0.9.3-beta1 0x00903001 - * 0.9.3-beta2-dev 0x00903002 - * 0.9.3-beta2 0x00903002 (same as ...beta2-dev) - * 0.9.3 0x0090300f - * 0.9.3a 0x0090301f - * 0.9.4 0x0090400f - * 1.2.3z 0x102031af - * - * For continuity reasons (because 0.9.5 is already out, and is coded - * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level - * part is slightly different, by setting the highest bit. This means - * that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start - * with 0x0090600S... - * - * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) - * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for - * major minor fix final patch/beta) - */ -#define OPENSSL_VERSION_NUMBER 0x0090802fL -#ifdef OPENSSL_FIPS -#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8b-fips 04 May 2006" -#else -#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8b 04 May 2006" -#endif -#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT - - -/* The macros below are to be used for shared library (.so, .dll, ...) - * versioning. That kind of versioning works a bit differently between - * operating systems. The most usual scheme is to set a major and a minor - * number, and have the runtime loader check that the major number is equal - * to what it was at application link time, while the minor number has to - * be greater or equal to what it was at application link time. With this - * scheme, the version number is usually part of the file name, like this: - * - * libcrypto.so.0.9 - * - * Some unixen also make a softlink with the major verson number only: - * - * libcrypto.so.0 - * - * On Tru64 and IRIX 6.x it works a little bit differently. There, the - * shared library version is stored in the file, and is actually a series - * of versions, separated by colons. The rightmost version present in the - * library when linking an application is stored in the application to be - * matched at run time. When the application is run, a check is done to - * see if the library version stored in the application matches any of the - * versions in the version string of the library itself. - * This version string can be constructed in any way, depending on what - * kind of matching is desired. However, to implement the same scheme as - * the one used in the other unixen, all compatible versions, from lowest - * to highest, should be part of the string. Consecutive builds would - * give the following versions strings: - * - * 3.0 - * 3.0:3.1 - * 3.0:3.1:3.2 - * 4.0 - * 4.0:4.1 - * - * Notice how version 4 is completely incompatible with version, and - * therefore give the breach you can see. - * - * There may be other schemes as well that I haven't yet discovered. - * - * So, here's the way it works here: first of all, the library version - * number doesn't need at all to match the overall OpenSSL version. - * However, it's nice and more understandable if it actually does. - * The current library version is stored in the macro SHLIB_VERSION_NUMBER, - * which is just a piece of text in the format "M.m.e" (Major, minor, edit). - * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways, - * we need to keep a history of version numbers, which is done in the - * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and - * should only keep the versions that are binary compatible with the current. - */ -#define SHLIB_VERSION_HISTORY "" -#define SHLIB_VERSION_NUMBER "0.9.8" - - -#endif /* HEADER_OPENSSLV_H */ +#ifndef HEADER_OPENSSLV_H +#define HEADER_OPENSSLV_H + +/* Numeric release version identifier: + * MNNFFPPS: major minor fix patch status + * The status nibble has one of the values 0 for development, 1 to e for betas + * 1 to 14, and f for release. The patch level is exactly that. + * For example: + * 0.9.3-dev 0x00903000 + * 0.9.3-beta1 0x00903001 + * 0.9.3-beta2-dev 0x00903002 + * 0.9.3-beta2 0x00903002 (same as ...beta2-dev) + * 0.9.3 0x0090300f + * 0.9.3a 0x0090301f + * 0.9.4 0x0090400f + * 1.2.3z 0x102031af + * + * For continuity reasons (because 0.9.5 is already out, and is coded + * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level + * part is slightly different, by setting the highest bit. This means + * that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start + * with 0x0090600S... + * + * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) + * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for + * major minor fix final patch/beta) + */ +#define OPENSSL_VERSION_NUMBER 0x0090802fL +#ifdef OPENSSL_FIPS +#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8b-fips 04 May 2006" +#else +#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8b 04 May 2006" +#endif +#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT + + +/* The macros below are to be used for shared library (.so, .dll, ...) + * versioning. That kind of versioning works a bit differently between + * operating systems. The most usual scheme is to set a major and a minor + * number, and have the runtime loader check that the major number is equal + * to what it was at application link time, while the minor number has to + * be greater or equal to what it was at application link time. With this + * scheme, the version number is usually part of the file name, like this: + * + * libcrypto.so.0.9 + * + * Some unixen also make a softlink with the major verson number only: + * + * libcrypto.so.0 + * + * On Tru64 and IRIX 6.x it works a little bit differently. There, the + * shared library version is stored in the file, and is actually a series + * of versions, separated by colons. The rightmost version present in the + * library when linking an application is stored in the application to be + * matched at run time. When the application is run, a check is done to + * see if the library version stored in the application matches any of the + * versions in the version string of the library itself. + * This version string can be constructed in any way, depending on what + * kind of matching is desired. However, to implement the same scheme as + * the one used in the other unixen, all compatible versions, from lowest + * to highest, should be part of the string. Consecutive builds would + * give the following versions strings: + * + * 3.0 + * 3.0:3.1 + * 3.0:3.1:3.2 + * 4.0 + * 4.0:4.1 + * + * Notice how version 4 is completely incompatible with version, and + * therefore give the breach you can see. + * + * There may be other schemes as well that I haven't yet discovered. + * + * So, here's the way it works here: first of all, the library version + * number doesn't need at all to match the overall OpenSSL version. + * However, it's nice and more understandable if it actually does. + * The current library version is stored in the macro SHLIB_VERSION_NUMBER, + * which is just a piece of text in the format "M.m.e" (Major, minor, edit). + * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways, + * we need to keep a history of version numbers, which is done in the + * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and + * should only keep the versions that are binary compatible with the current. + */ +#define SHLIB_VERSION_HISTORY "" +#define SHLIB_VERSION_NUMBER "0.9.8" + + +#endif /* HEADER_OPENSSLV_H */ diff --git a/src/dep/include/openssl/ossl_typ.h b/src/dep/include/openssl/ossl_typ.h index 1ce4a8a..fe4b246 100644 --- a/src/dep/include/openssl/ossl_typ.h +++ b/src/dep/include/openssl/ossl_typ.h @@ -1,174 +1,174 @@ -/* ==================================================================== - * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_OPENSSL_TYPES_H -#define HEADER_OPENSSL_TYPES_H - -#include - -#ifdef NO_ASN1_TYPEDEFS -#define ASN1_INTEGER ASN1_STRING -#define ASN1_ENUMERATED ASN1_STRING -#define ASN1_BIT_STRING ASN1_STRING -#define ASN1_OCTET_STRING ASN1_STRING -#define ASN1_PRINTABLESTRING ASN1_STRING -#define ASN1_T61STRING ASN1_STRING -#define ASN1_IA5STRING ASN1_STRING -#define ASN1_UTCTIME ASN1_STRING -#define ASN1_GENERALIZEDTIME ASN1_STRING -#define ASN1_TIME ASN1_STRING -#define ASN1_GENERALSTRING ASN1_STRING -#define ASN1_UNIVERSALSTRING ASN1_STRING -#define ASN1_BMPSTRING ASN1_STRING -#define ASN1_VISIBLESTRING ASN1_STRING -#define ASN1_UTF8STRING ASN1_STRING -#define ASN1_BOOLEAN int -#define ASN1_NULL int -#else -typedef struct asn1_string_st ASN1_INTEGER; -typedef struct asn1_string_st ASN1_ENUMERATED; -typedef struct asn1_string_st ASN1_BIT_STRING; -typedef struct asn1_string_st ASN1_OCTET_STRING; -typedef struct asn1_string_st ASN1_PRINTABLESTRING; -typedef struct asn1_string_st ASN1_T61STRING; -typedef struct asn1_string_st ASN1_IA5STRING; -typedef struct asn1_string_st ASN1_GENERALSTRING; -typedef struct asn1_string_st ASN1_UNIVERSALSTRING; -typedef struct asn1_string_st ASN1_BMPSTRING; -typedef struct asn1_string_st ASN1_UTCTIME; -typedef struct asn1_string_st ASN1_TIME; -typedef struct asn1_string_st ASN1_GENERALIZEDTIME; -typedef struct asn1_string_st ASN1_VISIBLESTRING; -typedef struct asn1_string_st ASN1_UTF8STRING; -typedef int ASN1_BOOLEAN; -typedef int ASN1_NULL; -#endif - -#ifdef OPENSSL_SYS_WIN32 -#undef X509_NAME -#undef X509_CERT_PAIR -#undef PKCS7_ISSUER_AND_SERIAL -#endif - -#ifdef BIGNUM -#undef BIGNUM -#endif -typedef struct bignum_st BIGNUM; -typedef struct bignum_ctx BN_CTX; -typedef struct bn_blinding_st BN_BLINDING; -typedef struct bn_mont_ctx_st BN_MONT_CTX; -typedef struct bn_recp_ctx_st BN_RECP_CTX; -typedef struct bn_gencb_st BN_GENCB; - -typedef struct buf_mem_st BUF_MEM; - -typedef struct evp_cipher_st EVP_CIPHER; -typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; -typedef struct env_md_st EVP_MD; -typedef struct env_md_ctx_st EVP_MD_CTX; -typedef struct evp_pkey_st EVP_PKEY; - -typedef struct dh_st DH; -typedef struct dh_method DH_METHOD; - -typedef struct dsa_st DSA; -typedef struct dsa_method DSA_METHOD; - -typedef struct rsa_st RSA; -typedef struct rsa_meth_st RSA_METHOD; - -typedef struct rand_meth_st RAND_METHOD; - -typedef struct ecdh_method ECDH_METHOD; -typedef struct ecdsa_method ECDSA_METHOD; - -typedef struct x509_st X509; -typedef struct X509_algor_st X509_ALGOR; -typedef struct X509_crl_st X509_CRL; -typedef struct X509_name_st X509_NAME; -typedef struct x509_store_st X509_STORE; -typedef struct x509_store_ctx_st X509_STORE_CTX; - -typedef struct v3_ext_ctx X509V3_CTX; -typedef struct conf_st CONF; - -typedef struct store_st STORE; -typedef struct store_method_st STORE_METHOD; - -typedef struct ui_st UI; -typedef struct ui_method_st UI_METHOD; - -typedef struct st_ERR_FNS ERR_FNS; - -typedef struct engine_st ENGINE; - -typedef struct X509_POLICY_NODE_st X509_POLICY_NODE; -typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL; -typedef struct X509_POLICY_TREE_st X509_POLICY_TREE; -typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE; - - /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */ -#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */ -#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */ - -typedef struct crypto_ex_data_st CRYPTO_EX_DATA; -/* Callback types for crypto.h */ -typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, - int idx, long argl, void *argp); -typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, - int idx, long argl, void *argp); -typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, - int idx, long argl, void *argp); - -#endif /* def HEADER_OPENSSL_TYPES_H */ +/* ==================================================================== + * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_OPENSSL_TYPES_H +#define HEADER_OPENSSL_TYPES_H + +#include + +#ifdef NO_ASN1_TYPEDEFS +#define ASN1_INTEGER ASN1_STRING +#define ASN1_ENUMERATED ASN1_STRING +#define ASN1_BIT_STRING ASN1_STRING +#define ASN1_OCTET_STRING ASN1_STRING +#define ASN1_PRINTABLESTRING ASN1_STRING +#define ASN1_T61STRING ASN1_STRING +#define ASN1_IA5STRING ASN1_STRING +#define ASN1_UTCTIME ASN1_STRING +#define ASN1_GENERALIZEDTIME ASN1_STRING +#define ASN1_TIME ASN1_STRING +#define ASN1_GENERALSTRING ASN1_STRING +#define ASN1_UNIVERSALSTRING ASN1_STRING +#define ASN1_BMPSTRING ASN1_STRING +#define ASN1_VISIBLESTRING ASN1_STRING +#define ASN1_UTF8STRING ASN1_STRING +#define ASN1_BOOLEAN int +#define ASN1_NULL int +#else +typedef struct asn1_string_st ASN1_INTEGER; +typedef struct asn1_string_st ASN1_ENUMERATED; +typedef struct asn1_string_st ASN1_BIT_STRING; +typedef struct asn1_string_st ASN1_OCTET_STRING; +typedef struct asn1_string_st ASN1_PRINTABLESTRING; +typedef struct asn1_string_st ASN1_T61STRING; +typedef struct asn1_string_st ASN1_IA5STRING; +typedef struct asn1_string_st ASN1_GENERALSTRING; +typedef struct asn1_string_st ASN1_UNIVERSALSTRING; +typedef struct asn1_string_st ASN1_BMPSTRING; +typedef struct asn1_string_st ASN1_UTCTIME; +typedef struct asn1_string_st ASN1_TIME; +typedef struct asn1_string_st ASN1_GENERALIZEDTIME; +typedef struct asn1_string_st ASN1_VISIBLESTRING; +typedef struct asn1_string_st ASN1_UTF8STRING; +typedef int ASN1_BOOLEAN; +typedef int ASN1_NULL; +#endif + +#ifdef OPENSSL_SYS_WIN32 +#undef X509_NAME +#undef X509_CERT_PAIR +#undef PKCS7_ISSUER_AND_SERIAL +#endif + +#ifdef BIGNUM +#undef BIGNUM +#endif +typedef struct bignum_st BIGNUM; +typedef struct bignum_ctx BN_CTX; +typedef struct bn_blinding_st BN_BLINDING; +typedef struct bn_mont_ctx_st BN_MONT_CTX; +typedef struct bn_recp_ctx_st BN_RECP_CTX; +typedef struct bn_gencb_st BN_GENCB; + +typedef struct buf_mem_st BUF_MEM; + +typedef struct evp_cipher_st EVP_CIPHER; +typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; +typedef struct env_md_st EVP_MD; +typedef struct env_md_ctx_st EVP_MD_CTX; +typedef struct evp_pkey_st EVP_PKEY; + +typedef struct dh_st DH; +typedef struct dh_method DH_METHOD; + +typedef struct dsa_st DSA; +typedef struct dsa_method DSA_METHOD; + +typedef struct rsa_st RSA; +typedef struct rsa_meth_st RSA_METHOD; + +typedef struct rand_meth_st RAND_METHOD; + +typedef struct ecdh_method ECDH_METHOD; +typedef struct ecdsa_method ECDSA_METHOD; + +typedef struct x509_st X509; +typedef struct X509_algor_st X509_ALGOR; +typedef struct X509_crl_st X509_CRL; +typedef struct X509_name_st X509_NAME; +typedef struct x509_store_st X509_STORE; +typedef struct x509_store_ctx_st X509_STORE_CTX; + +typedef struct v3_ext_ctx X509V3_CTX; +typedef struct conf_st CONF; + +typedef struct store_st STORE; +typedef struct store_method_st STORE_METHOD; + +typedef struct ui_st UI; +typedef struct ui_method_st UI_METHOD; + +typedef struct st_ERR_FNS ERR_FNS; + +typedef struct engine_st ENGINE; + +typedef struct X509_POLICY_NODE_st X509_POLICY_NODE; +typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL; +typedef struct X509_POLICY_TREE_st X509_POLICY_TREE; +typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE; + + /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */ +#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */ +#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */ + +typedef struct crypto_ex_data_st CRYPTO_EX_DATA; +/* Callback types for crypto.h */ +typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, + int idx, long argl, void *argp); + +#endif /* def HEADER_OPENSSL_TYPES_H */ diff --git a/src/dep/include/openssl/pem.h b/src/dep/include/openssl/pem.h index df74f10..17cbe8c 100644 --- a/src/dep/include/openssl/pem.h +++ b/src/dep/include/openssl/pem.h @@ -1,737 +1,737 @@ -/* crypto/pem/pem.h */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_PEM_H -#define HEADER_PEM_H - -#include -#ifndef OPENSSL_NO_BIO -#include -#endif -#ifndef OPENSSL_NO_STACK -#include -#endif -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define PEM_BUFSIZE 1024 - -#define PEM_OBJ_UNDEF 0 -#define PEM_OBJ_X509 1 -#define PEM_OBJ_X509_REQ 2 -#define PEM_OBJ_CRL 3 -#define PEM_OBJ_SSL_SESSION 4 -#define PEM_OBJ_PRIV_KEY 10 -#define PEM_OBJ_PRIV_RSA 11 -#define PEM_OBJ_PRIV_DSA 12 -#define PEM_OBJ_PRIV_DH 13 -#define PEM_OBJ_PUB_RSA 14 -#define PEM_OBJ_PUB_DSA 15 -#define PEM_OBJ_PUB_DH 16 -#define PEM_OBJ_DHPARAMS 17 -#define PEM_OBJ_DSAPARAMS 18 -#define PEM_OBJ_PRIV_RSA_PUBLIC 19 -#define PEM_OBJ_PRIV_ECDSA 20 -#define PEM_OBJ_PUB_ECDSA 21 -#define PEM_OBJ_ECPARAMETERS 22 - -#define PEM_ERROR 30 -#define PEM_DEK_DES_CBC 40 -#define PEM_DEK_IDEA_CBC 45 -#define PEM_DEK_DES_EDE 50 -#define PEM_DEK_DES_ECB 60 -#define PEM_DEK_RSA 70 -#define PEM_DEK_RSA_MD2 80 -#define PEM_DEK_RSA_MD5 90 - -#define PEM_MD_MD2 NID_md2 -#define PEM_MD_MD5 NID_md5 -#define PEM_MD_SHA NID_sha -#define PEM_MD_MD2_RSA NID_md2WithRSAEncryption -#define PEM_MD_MD5_RSA NID_md5WithRSAEncryption -#define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption - -#define PEM_STRING_X509_OLD "X509 CERTIFICATE" -#define PEM_STRING_X509 "CERTIFICATE" -#define PEM_STRING_X509_PAIR "CERTIFICATE PAIR" -#define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE" -#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" -#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" -#define PEM_STRING_X509_CRL "X509 CRL" -#define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY" -#define PEM_STRING_PUBLIC "PUBLIC KEY" -#define PEM_STRING_RSA "RSA PRIVATE KEY" -#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" -#define PEM_STRING_DSA "DSA PRIVATE KEY" -#define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY" -#define PEM_STRING_PKCS7 "PKCS7" -#define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" -#define PEM_STRING_PKCS8INF "PRIVATE KEY" -#define PEM_STRING_DHPARAMS "DH PARAMETERS" -#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" -#define PEM_STRING_DSAPARAMS "DSA PARAMETERS" -#define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" -#define PEM_STRING_ECPARAMETERS "EC PARAMETERS" -#define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" - - /* Note that this structure is initialised by PEM_SealInit and cleaned up - by PEM_SealFinal (at least for now) */ -typedef struct PEM_Encode_Seal_st - { - EVP_ENCODE_CTX encode; - EVP_MD_CTX md; - EVP_CIPHER_CTX cipher; - } PEM_ENCODE_SEAL_CTX; - -/* enc_type is one off */ -#define PEM_TYPE_ENCRYPTED 10 -#define PEM_TYPE_MIC_ONLY 20 -#define PEM_TYPE_MIC_CLEAR 30 -#define PEM_TYPE_CLEAR 40 - -typedef struct pem_recip_st - { - char *name; - X509_NAME *dn; - - int cipher; - int key_enc; - /* char iv[8]; unused and wrong size */ - } PEM_USER; - -typedef struct pem_ctx_st - { - int type; /* what type of object */ - - struct { - int version; - int mode; - } proc_type; - - char *domain; - - struct { - int cipher; - /* unused, and wrong size - unsigned char iv[8]; */ - } DEK_info; - - PEM_USER *originator; - - int num_recipient; - PEM_USER **recipient; - -#ifndef OPENSSL_NO_STACK - STACK *x509_chain; /* certificate chain */ -#else - char *x509_chain; /* certificate chain */ -#endif - EVP_MD *md; /* signature type */ - - int md_enc; /* is the md encrypted or not? */ - int md_len; /* length of md_data */ - char *md_data; /* message digest, could be pkey encrypted */ - - EVP_CIPHER *dec; /* date encryption cipher */ - int key_len; /* key length */ - unsigned char *key; /* key */ - /* unused, and wrong size - unsigned char iv[8]; */ - - - int data_enc; /* is the data encrypted */ - int data_len; - unsigned char *data; - } PEM_CTX; - -/* These macros make the PEM_read/PEM_write functions easier to maintain and - * write. Now they are all implemented with either: - * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...) - */ - -#ifdef OPENSSL_NO_FP_API - -#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ -#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ -#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/ - -#else - -#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ -type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\ -{ \ -return(((type *(*)(D2I_OF(type),char *,FILE *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read))(d2i_##asn1, str,fp,x,cb,u)); \ -} \ - -#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ -int PEM_write_##name(FILE *fp, type *x) \ -{ \ -return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \ -} - -#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ -int PEM_write_##name(FILE *fp, const type *x) \ -{ \ -return(((int (*)(I2D_OF_const(type),const char *,FILE *, const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \ -} - -#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ -int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, \ - void *u) \ - { \ - return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \ - } - -#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ -int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, \ - void *u) \ - { \ - return(((int (*)(I2D_OF_const(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \ - } - -#endif - -#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ -type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\ -{ \ -return(((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i_##asn1, str,bp,x,cb,u)); \ -} - -#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ -int PEM_write_bio_##name(BIO *bp, type *x) \ -{ \ -return(((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \ -} - -#define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ -int PEM_write_bio_##name(BIO *bp, const type *x) \ -{ \ -return(((int (*)(I2D_OF_const(type),const char *,BIO *,const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \ -} - -#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ -int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ - { \ - return(((int (*)(I2D_OF(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \ - } - -#define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ -int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ - { \ - return(((int (*)(I2D_OF_const(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \ - } - -#define IMPLEMENT_PEM_write(name, type, str, asn1) \ - IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ - IMPLEMENT_PEM_write_fp(name, type, str, asn1) - -#define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) - -#define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) - -#define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) - -#define IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ - IMPLEMENT_PEM_read_fp(name, type, str, asn1) - -#define IMPLEMENT_PEM_rw(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_write(name, type, str, asn1) - -#define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_write_const(name, type, str, asn1) - -#define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb(name, type, str, asn1) - -/* These are the same except they are for the declarations */ - -#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_NO_FP_API) - -#define DECLARE_PEM_read_fp(name, type) /**/ -#define DECLARE_PEM_write_fp(name, type) /**/ -#define DECLARE_PEM_write_cb_fp(name, type) /**/ - -#else - -#define DECLARE_PEM_read_fp(name, type) \ - type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u); - -#define DECLARE_PEM_write_fp(name, type) \ - int PEM_write_##name(FILE *fp, type *x); - -#define DECLARE_PEM_write_fp_const(name, type) \ - int PEM_write_##name(FILE *fp, const type *x); - -#define DECLARE_PEM_write_cb_fp(name, type) \ - int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u); - -#endif - -#ifndef OPENSSL_NO_BIO -#define DECLARE_PEM_read_bio(name, type) \ - type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u); - -#define DECLARE_PEM_write_bio(name, type) \ - int PEM_write_bio_##name(BIO *bp, type *x); - -#define DECLARE_PEM_write_bio_const(name, type) \ - int PEM_write_bio_##name(BIO *bp, const type *x); - -#define DECLARE_PEM_write_cb_bio(name, type) \ - int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u); - -#else - -#define DECLARE_PEM_read_bio(name, type) /**/ -#define DECLARE_PEM_write_bio(name, type) /**/ -#define DECLARE_PEM_write_cb_bio(name, type) /**/ - -#endif - -#define DECLARE_PEM_write(name, type) \ - DECLARE_PEM_write_bio(name, type) \ - DECLARE_PEM_write_fp(name, type) - -#define DECLARE_PEM_write_const(name, type) \ - DECLARE_PEM_write_bio_const(name, type) \ - DECLARE_PEM_write_fp_const(name, type) - -#define DECLARE_PEM_write_cb(name, type) \ - DECLARE_PEM_write_cb_bio(name, type) \ - DECLARE_PEM_write_cb_fp(name, type) - -#define DECLARE_PEM_read(name, type) \ - DECLARE_PEM_read_bio(name, type) \ - DECLARE_PEM_read_fp(name, type) - -#define DECLARE_PEM_rw(name, type) \ - DECLARE_PEM_read(name, type) \ - DECLARE_PEM_write(name, type) - -#define DECLARE_PEM_rw_const(name, type) \ - DECLARE_PEM_read(name, type) \ - DECLARE_PEM_write_const(name, type) - -#define DECLARE_PEM_rw_cb(name, type) \ - DECLARE_PEM_read(name, type) \ - DECLARE_PEM_write_cb(name, type) - -#ifdef SSLEAY_MACROS - -#define PEM_write_SSL_SESSION(fp,x) \ - PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ - PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL) -#define PEM_write_X509(fp,x) \ - PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \ - (char *)x, NULL,NULL,0,NULL,NULL) -#define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \ - (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \ - NULL,NULL,0,NULL,NULL) -#define PEM_write_X509_CRL(fp,x) \ - PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \ - fp,(char *)x, NULL,NULL,0,NULL,NULL) -#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \ - PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\ - (char *)x,enc,kstr,klen,cb,u) -#define PEM_write_RSAPublicKey(fp,x) \ - PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\ - PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL,NULL) -#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \ - PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\ - (char *)x,enc,kstr,klen,cb,u) -#define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb,u) \ - PEM_ASN1_write((int (*)())i2d_PrivateKey,\ - (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ - bp,(char *)x,enc,kstr,klen,cb,u) -#define PEM_write_PKCS7(fp,x) \ - PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \ - (char *)x, NULL,NULL,0,NULL,NULL) -#define PEM_write_DHparams(fp,x) \ - PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\ - (char *)x,NULL,NULL,0,NULL,NULL) - -#define PEM_write_NETSCAPE_CERT_SEQUENCE(fp,x) \ - PEM_ASN1_write((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \ - PEM_STRING_X509,fp, \ - (char *)x, NULL,NULL,0,NULL,NULL) - -#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \ - (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u) -#define PEM_read_X509(fp,x,cb,u) (X509 *)PEM_ASN1_read( \ - (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb,u) -#define PEM_read_X509_REQ(fp,x,cb,u) (X509_REQ *)PEM_ASN1_read( \ - (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb,u) -#define PEM_read_X509_CRL(fp,x,cb,u) (X509_CRL *)PEM_ASN1_read( \ - (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb,u) -#define PEM_read_RSAPrivateKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \ - (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb,u) -#define PEM_read_RSAPublicKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \ - (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb,u) -#define PEM_read_DSAPrivateKey(fp,x,cb,u) (DSA *)PEM_ASN1_read( \ - (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb,u) -#define PEM_read_PrivateKey(fp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read( \ - (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb,u) -#define PEM_read_PKCS7(fp,x,cb,u) (PKCS7 *)PEM_ASN1_read( \ - (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb,u) -#define PEM_read_DHparams(fp,x,cb,u) (DH *)PEM_ASN1_read( \ - (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb,u) - -#define PEM_read_NETSCAPE_CERT_SEQUENCE(fp,x,cb,u) \ - (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read( \ - (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\ - (char **)x,cb,u) - -#define PEM_write_bio_X509(bp,x) \ - PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \ - (char *)x, NULL,NULL,0,NULL,NULL) -#define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \ - (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \ - NULL,NULL,0,NULL,NULL) -#define PEM_write_bio_X509_CRL(bp,x) \ - PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\ - bp,(char *)x, NULL,NULL,0,NULL,NULL) -#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \ - PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\ - bp,(char *)x,enc,kstr,klen,cb,u) -#define PEM_write_bio_RSAPublicKey(bp,x) \ - PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \ - PEM_STRING_RSA_PUBLIC,\ - bp,(char *)x,NULL,NULL,0,NULL,NULL) -#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \ - PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\ - bp,(char *)x,enc,kstr,klen,cb,u) -#define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb,u) \ - PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\ - (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ - bp,(char *)x,enc,kstr,klen,cb,u) -#define PEM_write_bio_PKCS7(bp,x) \ - PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \ - (char *)x, NULL,NULL,0,NULL,NULL) -#define PEM_write_bio_DHparams(bp,x) \ - PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\ - bp,(char *)x,NULL,NULL,0,NULL,NULL) -#define PEM_write_bio_DSAparams(bp,x) \ - PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \ - PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL,NULL) - -#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE(bp,x) \ - PEM_ASN1_write_bio((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \ - PEM_STRING_X509,bp, \ - (char *)x, NULL,NULL,0,NULL,NULL) - -#define PEM_read_bio_X509(bp,x,cb,u) (X509 *)PEM_ASN1_read_bio( \ - (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb,u) -#define PEM_read_bio_X509_REQ(bp,x,cb,u) (X509_REQ *)PEM_ASN1_read_bio( \ - (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb,u) -#define PEM_read_bio_X509_CRL(bp,x,cb,u) (X509_CRL *)PEM_ASN1_read_bio( \ - (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb,u) -#define PEM_read_bio_RSAPrivateKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \ - (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb,u) -#define PEM_read_bio_RSAPublicKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \ - (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb,u) -#define PEM_read_bio_DSAPrivateKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \ - (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb,u) -#define PEM_read_bio_PrivateKey(bp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read_bio( \ - (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb,u) - -#define PEM_read_bio_PKCS7(bp,x,cb,u) (PKCS7 *)PEM_ASN1_read_bio( \ - (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb,u) -#define PEM_read_bio_DHparams(bp,x,cb,u) (DH *)PEM_ASN1_read_bio( \ - (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb,u) -#define PEM_read_bio_DSAparams(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \ - (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb,u) - -#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE(bp,x,cb,u) \ - (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read_bio( \ - (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,bp,\ - (char **)x,cb,u) - -#endif - -#if 1 -/* "userdata": new with OpenSSL 0.9.4 */ -typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata); -#else -/* OpenSSL 0.9.3, 0.9.3a */ -typedef int pem_password_cb(char *buf, int size, int rwflag); -#endif - -int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); -int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, - pem_password_cb *callback,void *u); - -#ifndef OPENSSL_NO_BIO -int PEM_read_bio(BIO *bp, char **name, char **header, - unsigned char **data,long *len); -int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data, - long len); -int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, - pem_password_cb *cb, void *u); -void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, - void **x, pem_password_cb *cb, void *u); -#define PEM_ASN1_read_bio_of(type,d2i,name,bp,x,cb,u) \ -((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i,name,bp,x,cb,u) -int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp,char *x, - const EVP_CIPHER *enc,unsigned char *kstr,int klen, - pem_password_cb *cb, void *u); -#define PEM_ASN1_write_bio_of(type,i2d,name,bp,x,enc,kstr,klen,cb,u) \ - ((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d,name,bp,x,enc,kstr,klen,cb,u) - -STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); -int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, - unsigned char *kstr, int klen, pem_password_cb *cd, void *u); -#endif - -#ifndef OPENSSL_SYS_WIN16 -int PEM_read(FILE *fp, char **name, char **header, - unsigned char **data,long *len); -int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len); -void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, - pem_password_cb *cb, void *u); -int PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp, - char *x,const EVP_CIPHER *enc,unsigned char *kstr, - int klen,pem_password_cb *callback, void *u); -STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, - pem_password_cb *cb, void *u); -#endif - -int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, - EVP_MD *md_type, unsigned char **ek, int *ekl, - unsigned char *iv, EVP_PKEY **pubk, int npubk); -void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, - unsigned char *in, int inl); -int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl, - unsigned char *out, int *outl, EVP_PKEY *priv); - -void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); -void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt); -int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, - unsigned int *siglen, EVP_PKEY *pkey); - -int PEM_def_callback(char *buf, int num, int w, void *key); -void PEM_proc_type(char *buf, int type); -void PEM_dek_info(char *buf, const char *type, int len, char *str); - -#ifndef SSLEAY_MACROS - -#include - -DECLARE_PEM_rw(X509, X509) - -DECLARE_PEM_rw(X509_AUX, X509) - -DECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR) - -DECLARE_PEM_rw(X509_REQ, X509_REQ) -DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) - -DECLARE_PEM_rw(X509_CRL, X509_CRL) - -DECLARE_PEM_rw(PKCS7, PKCS7) - -DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE) - -DECLARE_PEM_rw(PKCS8, X509_SIG) - -DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) - -#ifndef OPENSSL_NO_RSA - -DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) - -DECLARE_PEM_rw_const(RSAPublicKey, RSA) -DECLARE_PEM_rw(RSA_PUBKEY, RSA) - -#endif - -#ifndef OPENSSL_NO_DSA - -DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) - -DECLARE_PEM_rw(DSA_PUBKEY, DSA) - -DECLARE_PEM_rw_const(DSAparams, DSA) - -#endif - -#ifndef OPENSSL_NO_EC -DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP) -DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY) -DECLARE_PEM_rw(EC_PUBKEY, EC_KEY) -#endif - -#ifndef OPENSSL_NO_DH - -DECLARE_PEM_rw_const(DHparams, DH) - -#endif - -DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY) - -DECLARE_PEM_rw(PUBKEY, EVP_PKEY) - -int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, - char *kstr, int klen, - pem_password_cb *cb, void *u); -int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, - char *, int, pem_password_cb *, void *); -int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, - char *kstr, int klen, - pem_password_cb *cb, void *u); -int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, - char *kstr, int klen, - pem_password_cb *cb, void *u); -EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u); - -int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, - char *kstr, int klen, - pem_password_cb *cb, void *u); -int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, - char *kstr, int klen, - pem_password_cb *cb, void *u); -int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, - char *kstr, int klen, - pem_password_cb *cb, void *u); - -EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u); - -int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, - char *kstr,int klen, pem_password_cb *cd, void *u); - -#endif /* SSLEAY_MACROS */ - - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_PEM_strings(void); - -/* Error codes for the PEM functions. */ - -/* Function codes. */ -#define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120 -#define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121 -#define PEM_F_DO_PK8PKEY 126 -#define PEM_F_DO_PK8PKEY_FP 125 -#define PEM_F_LOAD_IV 101 -#define PEM_F_PEM_ASN1_READ 102 -#define PEM_F_PEM_ASN1_READ_BIO 103 -#define PEM_F_PEM_ASN1_WRITE 104 -#define PEM_F_PEM_ASN1_WRITE_BIO 105 -#define PEM_F_PEM_DEF_CALLBACK 100 -#define PEM_F_PEM_DO_HEADER 106 -#define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY 118 -#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 -#define PEM_F_PEM_PK8PKEY 119 -#define PEM_F_PEM_READ 108 -#define PEM_F_PEM_READ_BIO 109 -#define PEM_F_PEM_READ_BIO_PRIVATEKEY 123 -#define PEM_F_PEM_READ_PRIVATEKEY 124 -#define PEM_F_PEM_SEALFINAL 110 -#define PEM_F_PEM_SEALINIT 111 -#define PEM_F_PEM_SIGNFINAL 112 -#define PEM_F_PEM_WRITE 113 -#define PEM_F_PEM_WRITE_BIO 114 -#define PEM_F_PEM_X509_INFO_READ 115 -#define PEM_F_PEM_X509_INFO_READ_BIO 116 -#define PEM_F_PEM_X509_INFO_WRITE_BIO 117 - -/* Reason codes. */ -#define PEM_R_BAD_BASE64_DECODE 100 -#define PEM_R_BAD_DECRYPT 101 -#define PEM_R_BAD_END_LINE 102 -#define PEM_R_BAD_IV_CHARS 103 -#define PEM_R_BAD_PASSWORD_READ 104 -#define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115 -#define PEM_R_NOT_DEK_INFO 105 -#define PEM_R_NOT_ENCRYPTED 106 -#define PEM_R_NOT_PROC_TYPE 107 -#define PEM_R_NO_START_LINE 108 -#define PEM_R_PROBLEMS_GETTING_PASSWORD 109 -#define PEM_R_PUBLIC_KEY_NO_RSA 110 -#define PEM_R_READ_KEY 111 -#define PEM_R_SHORT_HEADER 112 -#define PEM_R_UNSUPPORTED_CIPHER 113 -#define PEM_R_UNSUPPORTED_ENCRYPTION 114 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/pem/pem.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_PEM_H +#define HEADER_PEM_H + +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#ifndef OPENSSL_NO_STACK +#include +#endif +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PEM_BUFSIZE 1024 + +#define PEM_OBJ_UNDEF 0 +#define PEM_OBJ_X509 1 +#define PEM_OBJ_X509_REQ 2 +#define PEM_OBJ_CRL 3 +#define PEM_OBJ_SSL_SESSION 4 +#define PEM_OBJ_PRIV_KEY 10 +#define PEM_OBJ_PRIV_RSA 11 +#define PEM_OBJ_PRIV_DSA 12 +#define PEM_OBJ_PRIV_DH 13 +#define PEM_OBJ_PUB_RSA 14 +#define PEM_OBJ_PUB_DSA 15 +#define PEM_OBJ_PUB_DH 16 +#define PEM_OBJ_DHPARAMS 17 +#define PEM_OBJ_DSAPARAMS 18 +#define PEM_OBJ_PRIV_RSA_PUBLIC 19 +#define PEM_OBJ_PRIV_ECDSA 20 +#define PEM_OBJ_PUB_ECDSA 21 +#define PEM_OBJ_ECPARAMETERS 22 + +#define PEM_ERROR 30 +#define PEM_DEK_DES_CBC 40 +#define PEM_DEK_IDEA_CBC 45 +#define PEM_DEK_DES_EDE 50 +#define PEM_DEK_DES_ECB 60 +#define PEM_DEK_RSA 70 +#define PEM_DEK_RSA_MD2 80 +#define PEM_DEK_RSA_MD5 90 + +#define PEM_MD_MD2 NID_md2 +#define PEM_MD_MD5 NID_md5 +#define PEM_MD_SHA NID_sha +#define PEM_MD_MD2_RSA NID_md2WithRSAEncryption +#define PEM_MD_MD5_RSA NID_md5WithRSAEncryption +#define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption + +#define PEM_STRING_X509_OLD "X509 CERTIFICATE" +#define PEM_STRING_X509 "CERTIFICATE" +#define PEM_STRING_X509_PAIR "CERTIFICATE PAIR" +#define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE" +#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" +#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" +#define PEM_STRING_X509_CRL "X509 CRL" +#define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY" +#define PEM_STRING_PUBLIC "PUBLIC KEY" +#define PEM_STRING_RSA "RSA PRIVATE KEY" +#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" +#define PEM_STRING_DSA "DSA PRIVATE KEY" +#define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY" +#define PEM_STRING_PKCS7 "PKCS7" +#define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" +#define PEM_STRING_PKCS8INF "PRIVATE KEY" +#define PEM_STRING_DHPARAMS "DH PARAMETERS" +#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" +#define PEM_STRING_DSAPARAMS "DSA PARAMETERS" +#define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" +#define PEM_STRING_ECPARAMETERS "EC PARAMETERS" +#define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" + + /* Note that this structure is initialised by PEM_SealInit and cleaned up + by PEM_SealFinal (at least for now) */ +typedef struct PEM_Encode_Seal_st + { + EVP_ENCODE_CTX encode; + EVP_MD_CTX md; + EVP_CIPHER_CTX cipher; + } PEM_ENCODE_SEAL_CTX; + +/* enc_type is one off */ +#define PEM_TYPE_ENCRYPTED 10 +#define PEM_TYPE_MIC_ONLY 20 +#define PEM_TYPE_MIC_CLEAR 30 +#define PEM_TYPE_CLEAR 40 + +typedef struct pem_recip_st + { + char *name; + X509_NAME *dn; + + int cipher; + int key_enc; + /* char iv[8]; unused and wrong size */ + } PEM_USER; + +typedef struct pem_ctx_st + { + int type; /* what type of object */ + + struct { + int version; + int mode; + } proc_type; + + char *domain; + + struct { + int cipher; + /* unused, and wrong size + unsigned char iv[8]; */ + } DEK_info; + + PEM_USER *originator; + + int num_recipient; + PEM_USER **recipient; + +#ifndef OPENSSL_NO_STACK + STACK *x509_chain; /* certificate chain */ +#else + char *x509_chain; /* certificate chain */ +#endif + EVP_MD *md; /* signature type */ + + int md_enc; /* is the md encrypted or not? */ + int md_len; /* length of md_data */ + char *md_data; /* message digest, could be pkey encrypted */ + + EVP_CIPHER *dec; /* date encryption cipher */ + int key_len; /* key length */ + unsigned char *key; /* key */ + /* unused, and wrong size + unsigned char iv[8]; */ + + + int data_enc; /* is the data encrypted */ + int data_len; + unsigned char *data; + } PEM_CTX; + +/* These macros make the PEM_read/PEM_write functions easier to maintain and + * write. Now they are all implemented with either: + * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...) + */ + +#ifdef OPENSSL_NO_FP_API + +#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ +#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ +#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/ + +#else + +#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ +type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\ +{ \ +return(((type *(*)(D2I_OF(type),char *,FILE *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read))(d2i_##asn1, str,fp,x,cb,u)); \ +} \ + +#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, type *x) \ +{ \ +return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, const type *x) \ +{ \ +return(((int (*)(I2D_OF_const(type),const char *,FILE *, const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, \ + void *u) \ + { \ + return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \ + } + +#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, \ + void *u) \ + { \ + return(((int (*)(I2D_OF_const(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \ + } + +#endif + +#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ +type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\ +{ \ +return(((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i_##asn1, str,bp,x,cb,u)); \ +} + +#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, type *x) \ +{ \ +return(((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, const type *x) \ +{ \ +return(((int (*)(I2D_OF_const(type),const char *,BIO *,const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ + { \ + return(((int (*)(I2D_OF(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \ + } + +#define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ + { \ + return(((int (*)(I2D_OF_const(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \ + } + +#define IMPLEMENT_PEM_write(name, type, str, asn1) \ + IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_write_fp(name, type, str, asn1) + +#define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) + +#define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) + +#define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) + +#define IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_read_fp(name, type, str, asn1) + +#define IMPLEMENT_PEM_rw(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write(name, type, str, asn1) + +#define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write_const(name, type, str, asn1) + +#define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb(name, type, str, asn1) + +/* These are the same except they are for the declarations */ + +#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_NO_FP_API) + +#define DECLARE_PEM_read_fp(name, type) /**/ +#define DECLARE_PEM_write_fp(name, type) /**/ +#define DECLARE_PEM_write_cb_fp(name, type) /**/ + +#else + +#define DECLARE_PEM_read_fp(name, type) \ + type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u); + +#define DECLARE_PEM_write_fp(name, type) \ + int PEM_write_##name(FILE *fp, type *x); + +#define DECLARE_PEM_write_fp_const(name, type) \ + int PEM_write_##name(FILE *fp, const type *x); + +#define DECLARE_PEM_write_cb_fp(name, type) \ + int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u); + +#endif + +#ifndef OPENSSL_NO_BIO +#define DECLARE_PEM_read_bio(name, type) \ + type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u); + +#define DECLARE_PEM_write_bio(name, type) \ + int PEM_write_bio_##name(BIO *bp, type *x); + +#define DECLARE_PEM_write_bio_const(name, type) \ + int PEM_write_bio_##name(BIO *bp, const type *x); + +#define DECLARE_PEM_write_cb_bio(name, type) \ + int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u); + +#else + +#define DECLARE_PEM_read_bio(name, type) /**/ +#define DECLARE_PEM_write_bio(name, type) /**/ +#define DECLARE_PEM_write_cb_bio(name, type) /**/ + +#endif + +#define DECLARE_PEM_write(name, type) \ + DECLARE_PEM_write_bio(name, type) \ + DECLARE_PEM_write_fp(name, type) + +#define DECLARE_PEM_write_const(name, type) \ + DECLARE_PEM_write_bio_const(name, type) \ + DECLARE_PEM_write_fp_const(name, type) + +#define DECLARE_PEM_write_cb(name, type) \ + DECLARE_PEM_write_cb_bio(name, type) \ + DECLARE_PEM_write_cb_fp(name, type) + +#define DECLARE_PEM_read(name, type) \ + DECLARE_PEM_read_bio(name, type) \ + DECLARE_PEM_read_fp(name, type) + +#define DECLARE_PEM_rw(name, type) \ + DECLARE_PEM_read(name, type) \ + DECLARE_PEM_write(name, type) + +#define DECLARE_PEM_rw_const(name, type) \ + DECLARE_PEM_read(name, type) \ + DECLARE_PEM_write_const(name, type) + +#define DECLARE_PEM_rw_cb(name, type) \ + DECLARE_PEM_read(name, type) \ + DECLARE_PEM_write_cb(name, type) + +#ifdef SSLEAY_MACROS + +#define PEM_write_SSL_SESSION(fp,x) \ + PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ + PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_X509(fp,x) \ + PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \ + (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \ + NULL,NULL,0,NULL,NULL) +#define PEM_write_X509_CRL(fp,x) \ + PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \ + fp,(char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\ + (char *)x,enc,kstr,klen,cb,u) +#define PEM_write_RSAPublicKey(fp,x) \ + PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\ + PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL,NULL) +#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\ + (char *)x,enc,kstr,klen,cb,u) +#define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write((int (*)())i2d_PrivateKey,\ + (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_PKCS7(fp,x) \ + PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_DHparams(fp,x) \ + PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\ + (char *)x,NULL,NULL,0,NULL,NULL) + +#define PEM_write_NETSCAPE_CERT_SEQUENCE(fp,x) \ + PEM_ASN1_write((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \ + PEM_STRING_X509,fp, \ + (char *)x, NULL,NULL,0,NULL,NULL) + +#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \ + (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u) +#define PEM_read_X509(fp,x,cb,u) (X509 *)PEM_ASN1_read( \ + (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb,u) +#define PEM_read_X509_REQ(fp,x,cb,u) (X509_REQ *)PEM_ASN1_read( \ + (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb,u) +#define PEM_read_X509_CRL(fp,x,cb,u) (X509_CRL *)PEM_ASN1_read( \ + (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb,u) +#define PEM_read_RSAPrivateKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \ + (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb,u) +#define PEM_read_RSAPublicKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \ + (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb,u) +#define PEM_read_DSAPrivateKey(fp,x,cb,u) (DSA *)PEM_ASN1_read( \ + (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb,u) +#define PEM_read_PrivateKey(fp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read( \ + (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb,u) +#define PEM_read_PKCS7(fp,x,cb,u) (PKCS7 *)PEM_ASN1_read( \ + (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb,u) +#define PEM_read_DHparams(fp,x,cb,u) (DH *)PEM_ASN1_read( \ + (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb,u) + +#define PEM_read_NETSCAPE_CERT_SEQUENCE(fp,x,cb,u) \ + (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read( \ + (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\ + (char **)x,cb,u) + +#define PEM_write_bio_X509(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \ + (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \ + NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_X509_CRL(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\ + bp,(char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_bio_RSAPublicKey(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \ + PEM_STRING_RSA_PUBLIC,\ + bp,(char *)x,NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\ + (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_bio_PKCS7(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_DHparams(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\ + bp,(char *)x,NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_DSAparams(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \ + PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL,NULL) + +#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \ + PEM_STRING_X509,bp, \ + (char *)x, NULL,NULL,0,NULL,NULL) + +#define PEM_read_bio_X509(bp,x,cb,u) (X509 *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb,u) +#define PEM_read_bio_X509_REQ(bp,x,cb,u) (X509_REQ *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb,u) +#define PEM_read_bio_X509_CRL(bp,x,cb,u) (X509_CRL *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb,u) +#define PEM_read_bio_RSAPrivateKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb,u) +#define PEM_read_bio_RSAPublicKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb,u) +#define PEM_read_bio_DSAPrivateKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb,u) +#define PEM_read_bio_PrivateKey(bp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb,u) + +#define PEM_read_bio_PKCS7(bp,x,cb,u) (PKCS7 *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb,u) +#define PEM_read_bio_DHparams(bp,x,cb,u) (DH *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb,u) +#define PEM_read_bio_DSAparams(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb,u) + +#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE(bp,x,cb,u) \ + (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,bp,\ + (char **)x,cb,u) + +#endif + +#if 1 +/* "userdata": new with OpenSSL 0.9.4 */ +typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata); +#else +/* OpenSSL 0.9.3, 0.9.3a */ +typedef int pem_password_cb(char *buf, int size, int rwflag); +#endif + +int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); +int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, + pem_password_cb *callback,void *u); + +#ifndef OPENSSL_NO_BIO +int PEM_read_bio(BIO *bp, char **name, char **header, + unsigned char **data,long *len); +int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data, + long len); +int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, + pem_password_cb *cb, void *u); +void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, + void **x, pem_password_cb *cb, void *u); +#define PEM_ASN1_read_bio_of(type,d2i,name,bp,x,cb,u) \ +((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i,name,bp,x,cb,u) +int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp,char *x, + const EVP_CIPHER *enc,unsigned char *kstr,int klen, + pem_password_cb *cb, void *u); +#define PEM_ASN1_write_bio_of(type,i2d,name,bp,x,enc,kstr,klen,cb,u) \ + ((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d,name,bp,x,enc,kstr,klen,cb,u) + +STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); +int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, + unsigned char *kstr, int klen, pem_password_cb *cd, void *u); +#endif + +#ifndef OPENSSL_SYS_WIN16 +int PEM_read(FILE *fp, char **name, char **header, + unsigned char **data,long *len); +int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len); +void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, + pem_password_cb *cb, void *u); +int PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp, + char *x,const EVP_CIPHER *enc,unsigned char *kstr, + int klen,pem_password_cb *callback, void *u); +STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, + pem_password_cb *cb, void *u); +#endif + +int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, + EVP_MD *md_type, unsigned char **ek, int *ekl, + unsigned char *iv, EVP_PKEY **pubk, int npubk); +void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, + unsigned char *in, int inl); +int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl, + unsigned char *out, int *outl, EVP_PKEY *priv); + +void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); +void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt); +int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, + unsigned int *siglen, EVP_PKEY *pkey); + +int PEM_def_callback(char *buf, int num, int w, void *key); +void PEM_proc_type(char *buf, int type); +void PEM_dek_info(char *buf, const char *type, int len, char *str); + +#ifndef SSLEAY_MACROS + +#include + +DECLARE_PEM_rw(X509, X509) + +DECLARE_PEM_rw(X509_AUX, X509) + +DECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR) + +DECLARE_PEM_rw(X509_REQ, X509_REQ) +DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) + +DECLARE_PEM_rw(X509_CRL, X509_CRL) + +DECLARE_PEM_rw(PKCS7, PKCS7) + +DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE) + +DECLARE_PEM_rw(PKCS8, X509_SIG) + +DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) + +#ifndef OPENSSL_NO_RSA + +DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) + +DECLARE_PEM_rw_const(RSAPublicKey, RSA) +DECLARE_PEM_rw(RSA_PUBKEY, RSA) + +#endif + +#ifndef OPENSSL_NO_DSA + +DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) + +DECLARE_PEM_rw(DSA_PUBKEY, DSA) + +DECLARE_PEM_rw_const(DSAparams, DSA) + +#endif + +#ifndef OPENSSL_NO_EC +DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP) +DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY) +DECLARE_PEM_rw(EC_PUBKEY, EC_KEY) +#endif + +#ifndef OPENSSL_NO_DH + +DECLARE_PEM_rw_const(DHparams, DH) + +#endif + +DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY) + +DECLARE_PEM_rw(PUBKEY, EVP_PKEY) + +int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, + char *, int, pem_password_cb *, void *); +int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); +EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u); + +int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); + +EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u); + +int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, + char *kstr,int klen, pem_password_cb *cd, void *u); + +#endif /* SSLEAY_MACROS */ + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_PEM_strings(void); + +/* Error codes for the PEM functions. */ + +/* Function codes. */ +#define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120 +#define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121 +#define PEM_F_DO_PK8PKEY 126 +#define PEM_F_DO_PK8PKEY_FP 125 +#define PEM_F_LOAD_IV 101 +#define PEM_F_PEM_ASN1_READ 102 +#define PEM_F_PEM_ASN1_READ_BIO 103 +#define PEM_F_PEM_ASN1_WRITE 104 +#define PEM_F_PEM_ASN1_WRITE_BIO 105 +#define PEM_F_PEM_DEF_CALLBACK 100 +#define PEM_F_PEM_DO_HEADER 106 +#define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY 118 +#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 +#define PEM_F_PEM_PK8PKEY 119 +#define PEM_F_PEM_READ 108 +#define PEM_F_PEM_READ_BIO 109 +#define PEM_F_PEM_READ_BIO_PRIVATEKEY 123 +#define PEM_F_PEM_READ_PRIVATEKEY 124 +#define PEM_F_PEM_SEALFINAL 110 +#define PEM_F_PEM_SEALINIT 111 +#define PEM_F_PEM_SIGNFINAL 112 +#define PEM_F_PEM_WRITE 113 +#define PEM_F_PEM_WRITE_BIO 114 +#define PEM_F_PEM_X509_INFO_READ 115 +#define PEM_F_PEM_X509_INFO_READ_BIO 116 +#define PEM_F_PEM_X509_INFO_WRITE_BIO 117 + +/* Reason codes. */ +#define PEM_R_BAD_BASE64_DECODE 100 +#define PEM_R_BAD_DECRYPT 101 +#define PEM_R_BAD_END_LINE 102 +#define PEM_R_BAD_IV_CHARS 103 +#define PEM_R_BAD_PASSWORD_READ 104 +#define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115 +#define PEM_R_NOT_DEK_INFO 105 +#define PEM_R_NOT_ENCRYPTED 106 +#define PEM_R_NOT_PROC_TYPE 107 +#define PEM_R_NO_START_LINE 108 +#define PEM_R_PROBLEMS_GETTING_PASSWORD 109 +#define PEM_R_PUBLIC_KEY_NO_RSA 110 +#define PEM_R_READ_KEY 111 +#define PEM_R_SHORT_HEADER 112 +#define PEM_R_UNSUPPORTED_CIPHER 113 +#define PEM_R_UNSUPPORTED_ENCRYPTION 114 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/pem2.h b/src/dep/include/openssl/pem2.h index ad73e48..84897d5 100644 --- a/src/dep/include/openssl/pem2.h +++ b/src/dep/include/openssl/pem2.h @@ -1,70 +1,70 @@ -/* ==================================================================== - * Copyright (c) 1999 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -/* - * This header only exists to break a circular dependency between pem and err - * Ben 30 Jan 1999. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef HEADER_PEM_H -void ERR_load_PEM_strings(void); -#endif - -#ifdef __cplusplus -} -#endif +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* + * This header only exists to break a circular dependency between pem and err + * Ben 30 Jan 1999. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef HEADER_PEM_H +void ERR_load_PEM_strings(void); +#endif + +#ifdef __cplusplus +} +#endif diff --git a/src/dep/include/openssl/pkcs12.h b/src/dep/include/openssl/pkcs12.h index 6d05e22..1091879 100644 --- a/src/dep/include/openssl/pkcs12.h +++ b/src/dep/include/openssl/pkcs12.h @@ -1,333 +1,333 @@ -/* pkcs12.h */ -/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL - * project 1999. - */ -/* ==================================================================== - * Copyright (c) 1999 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_PKCS12_H -#define HEADER_PKCS12_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define PKCS12_KEY_ID 1 -#define PKCS12_IV_ID 2 -#define PKCS12_MAC_ID 3 - -/* Default iteration count */ -#ifndef PKCS12_DEFAULT_ITER -#define PKCS12_DEFAULT_ITER PKCS5_DEFAULT_ITER -#endif - -#define PKCS12_MAC_KEY_LENGTH 20 - -#define PKCS12_SALT_LEN 8 - -/* Uncomment out next line for unicode password and names, otherwise ASCII */ - -/*#define PBE_UNICODE*/ - -#ifdef PBE_UNICODE -#define PKCS12_key_gen PKCS12_key_gen_uni -#define PKCS12_add_friendlyname PKCS12_add_friendlyname_uni -#else -#define PKCS12_key_gen PKCS12_key_gen_asc -#define PKCS12_add_friendlyname PKCS12_add_friendlyname_asc -#endif - -/* MS key usage constants */ - -#define KEY_EX 0x10 -#define KEY_SIG 0x80 - -typedef struct { -X509_SIG *dinfo; -ASN1_OCTET_STRING *salt; -ASN1_INTEGER *iter; /* defaults to 1 */ -} PKCS12_MAC_DATA; - -typedef struct { -ASN1_INTEGER *version; -PKCS12_MAC_DATA *mac; -PKCS7 *authsafes; -} PKCS12; - -PREDECLARE_STACK_OF(PKCS12_SAFEBAG) - -typedef struct { -ASN1_OBJECT *type; -union { - struct pkcs12_bag_st *bag; /* secret, crl and certbag */ - struct pkcs8_priv_key_info_st *keybag; /* keybag */ - X509_SIG *shkeybag; /* shrouded key bag */ - STACK_OF(PKCS12_SAFEBAG) *safes; - ASN1_TYPE *other; -}value; -STACK_OF(X509_ATTRIBUTE) *attrib; -} PKCS12_SAFEBAG; - -DECLARE_STACK_OF(PKCS12_SAFEBAG) -DECLARE_ASN1_SET_OF(PKCS12_SAFEBAG) -DECLARE_PKCS12_STACK_OF(PKCS12_SAFEBAG) - -typedef struct pkcs12_bag_st { -ASN1_OBJECT *type; -union { - ASN1_OCTET_STRING *x509cert; - ASN1_OCTET_STRING *x509crl; - ASN1_OCTET_STRING *octet; - ASN1_IA5STRING *sdsicert; - ASN1_TYPE *other; /* Secret or other bag */ -}value; -} PKCS12_BAGS; - -#define PKCS12_ERROR 0 -#define PKCS12_OK 1 - -/* Compatibility macros */ - -#define M_PKCS12_x5092certbag PKCS12_x5092certbag -#define M_PKCS12_x509crl2certbag PKCS12_x509crl2certbag - -#define M_PKCS12_certbag2x509 PKCS12_certbag2x509 -#define M_PKCS12_certbag2x509crl PKCS12_certbag2x509crl - -#define M_PKCS12_unpack_p7data PKCS12_unpack_p7data -#define M_PKCS12_pack_authsafes PKCS12_pack_authsafes -#define M_PKCS12_unpack_authsafes PKCS12_unpack_authsafes -#define M_PKCS12_unpack_p7encdata PKCS12_unpack_p7encdata - -#define M_PKCS12_decrypt_skey PKCS12_decrypt_skey -#define M_PKCS8_decrypt PKCS8_decrypt - -#define M_PKCS12_bag_type(bg) OBJ_obj2nid((bg)->type) -#define M_PKCS12_cert_bag_type(bg) OBJ_obj2nid((bg)->value.bag->type) -#define M_PKCS12_crl_bag_type M_PKCS12_cert_bag_type - -#define PKCS12_get_attr(bag, attr_nid) \ - PKCS12_get_attr_gen(bag->attrib, attr_nid) - -#define PKCS8_get_attr(p8, attr_nid) \ - PKCS12_get_attr_gen(p8->attributes, attr_nid) - -#define PKCS12_mac_present(p12) ((p12)->mac ? 1 : 0) - - -PKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509); -PKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl); -X509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag); -X509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag); - -PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, int nid1, - int nid2); -PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8); -PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen); -PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass, - int passlen); -X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, - const char *pass, int passlen, - unsigned char *salt, int saltlen, int iter, - PKCS8_PRIV_KEY_INFO *p8); -PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass, - int passlen, unsigned char *salt, - int saltlen, int iter, - PKCS8_PRIV_KEY_INFO *p8); -PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk); -STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7); -PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, - unsigned char *salt, int saltlen, int iter, - STACK_OF(PKCS12_SAFEBAG) *bags); -STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen); - -int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes); -STACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12); - -int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, int namelen); -int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name, - int namelen); -int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, - int namelen); -int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name, - int namelen); -int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage); -ASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid); -char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag); -unsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, - int passlen, unsigned char *in, int inlen, - unsigned char **data, int *datalen, int en_de); -void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it, - const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf); -ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it, - const char *pass, int passlen, - void *obj, int zbuf); -PKCS12 *PKCS12_init(int mode); -int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, - int saltlen, int id, int iter, int n, - unsigned char *out, const EVP_MD *md_type); -int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, int saltlen, int id, int iter, int n, unsigned char *out, const EVP_MD *md_type); -int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, - ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md_type, - int en_de); -int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, - unsigned char *mac, unsigned int *maclen); -int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen); -int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, - unsigned char *salt, int saltlen, int iter, - const EVP_MD *md_type); -int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, - int saltlen, const EVP_MD *md_type); -unsigned char *asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen); -char *uni2asc(unsigned char *uni, int unilen); - -DECLARE_ASN1_FUNCTIONS(PKCS12) -DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA) -DECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG) -DECLARE_ASN1_FUNCTIONS(PKCS12_BAGS) - -DECLARE_ASN1_ITEM(PKCS12_SAFEBAGS) -DECLARE_ASN1_ITEM(PKCS12_AUTHSAFES) - -void PKCS12_PBE_add(void); -int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, - STACK_OF(X509) **ca); -PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, - STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter, - int mac_iter, int keytype); - -PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert); -PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key, - int key_usage, int iter, - int key_nid, char *pass); -int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, - int safe_nid, int iter, char *pass); -PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid); - -int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12); -int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12); -PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12); -PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12); -int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_PKCS12_strings(void); - -/* Error codes for the PKCS12 functions. */ - -/* Function codes. */ -#define PKCS12_F_PARSE_BAG 129 -#define PKCS12_F_PARSE_BAGS 103 -#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME 100 -#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_ASC 127 -#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI 102 -#define PKCS12_F_PKCS12_ADD_LOCALKEYID 104 -#define PKCS12_F_PKCS12_CREATE 105 -#define PKCS12_F_PKCS12_GEN_MAC 107 -#define PKCS12_F_PKCS12_INIT 109 -#define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I 106 -#define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT 108 -#define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG 117 -#define PKCS12_F_PKCS12_KEY_GEN_ASC 110 -#define PKCS12_F_PKCS12_KEY_GEN_UNI 111 -#define PKCS12_F_PKCS12_MAKE_KEYBAG 112 -#define PKCS12_F_PKCS12_MAKE_SHKEYBAG 113 -#define PKCS12_F_PKCS12_NEWPASS 128 -#define PKCS12_F_PKCS12_PACK_P7DATA 114 -#define PKCS12_F_PKCS12_PACK_P7ENCDATA 115 -#define PKCS12_F_PKCS12_PARSE 118 -#define PKCS12_F_PKCS12_PBE_CRYPT 119 -#define PKCS12_F_PKCS12_PBE_KEYIVGEN 120 -#define PKCS12_F_PKCS12_SETUP_MAC 122 -#define PKCS12_F_PKCS12_SET_MAC 123 -#define PKCS12_F_PKCS12_UNPACK_AUTHSAFES 130 -#define PKCS12_F_PKCS12_UNPACK_P7DATA 131 -#define PKCS12_F_PKCS12_VERIFY_MAC 126 -#define PKCS12_F_PKCS8_ADD_KEYUSAGE 124 -#define PKCS12_F_PKCS8_ENCRYPT 125 - -/* Reason codes. */ -#define PKCS12_R_CANT_PACK_STRUCTURE 100 -#define PKCS12_R_CONTENT_TYPE_NOT_DATA 121 -#define PKCS12_R_DECODE_ERROR 101 -#define PKCS12_R_ENCODE_ERROR 102 -#define PKCS12_R_ENCRYPT_ERROR 103 -#define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE 120 -#define PKCS12_R_INVALID_NULL_ARGUMENT 104 -#define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105 -#define PKCS12_R_IV_GEN_ERROR 106 -#define PKCS12_R_KEY_GEN_ERROR 107 -#define PKCS12_R_MAC_ABSENT 108 -#define PKCS12_R_MAC_GENERATION_ERROR 109 -#define PKCS12_R_MAC_SETUP_ERROR 110 -#define PKCS12_R_MAC_STRING_SET_ERROR 111 -#define PKCS12_R_MAC_VERIFY_ERROR 112 -#define PKCS12_R_MAC_VERIFY_FAILURE 113 -#define PKCS12_R_PARSE_ERROR 114 -#define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR 115 -#define PKCS12_R_PKCS12_CIPHERFINAL_ERROR 116 -#define PKCS12_R_PKCS12_PBE_CRYPT_ERROR 117 -#define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM 118 -#define PKCS12_R_UNSUPPORTED_PKCS12_MODE 119 - -#ifdef __cplusplus -} -#endif -#endif +/* pkcs12.h */ +/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL + * project 1999. + */ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_PKCS12_H +#define HEADER_PKCS12_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PKCS12_KEY_ID 1 +#define PKCS12_IV_ID 2 +#define PKCS12_MAC_ID 3 + +/* Default iteration count */ +#ifndef PKCS12_DEFAULT_ITER +#define PKCS12_DEFAULT_ITER PKCS5_DEFAULT_ITER +#endif + +#define PKCS12_MAC_KEY_LENGTH 20 + +#define PKCS12_SALT_LEN 8 + +/* Uncomment out next line for unicode password and names, otherwise ASCII */ + +/*#define PBE_UNICODE*/ + +#ifdef PBE_UNICODE +#define PKCS12_key_gen PKCS12_key_gen_uni +#define PKCS12_add_friendlyname PKCS12_add_friendlyname_uni +#else +#define PKCS12_key_gen PKCS12_key_gen_asc +#define PKCS12_add_friendlyname PKCS12_add_friendlyname_asc +#endif + +/* MS key usage constants */ + +#define KEY_EX 0x10 +#define KEY_SIG 0x80 + +typedef struct { +X509_SIG *dinfo; +ASN1_OCTET_STRING *salt; +ASN1_INTEGER *iter; /* defaults to 1 */ +} PKCS12_MAC_DATA; + +typedef struct { +ASN1_INTEGER *version; +PKCS12_MAC_DATA *mac; +PKCS7 *authsafes; +} PKCS12; + +PREDECLARE_STACK_OF(PKCS12_SAFEBAG) + +typedef struct { +ASN1_OBJECT *type; +union { + struct pkcs12_bag_st *bag; /* secret, crl and certbag */ + struct pkcs8_priv_key_info_st *keybag; /* keybag */ + X509_SIG *shkeybag; /* shrouded key bag */ + STACK_OF(PKCS12_SAFEBAG) *safes; + ASN1_TYPE *other; +}value; +STACK_OF(X509_ATTRIBUTE) *attrib; +} PKCS12_SAFEBAG; + +DECLARE_STACK_OF(PKCS12_SAFEBAG) +DECLARE_ASN1_SET_OF(PKCS12_SAFEBAG) +DECLARE_PKCS12_STACK_OF(PKCS12_SAFEBAG) + +typedef struct pkcs12_bag_st { +ASN1_OBJECT *type; +union { + ASN1_OCTET_STRING *x509cert; + ASN1_OCTET_STRING *x509crl; + ASN1_OCTET_STRING *octet; + ASN1_IA5STRING *sdsicert; + ASN1_TYPE *other; /* Secret or other bag */ +}value; +} PKCS12_BAGS; + +#define PKCS12_ERROR 0 +#define PKCS12_OK 1 + +/* Compatibility macros */ + +#define M_PKCS12_x5092certbag PKCS12_x5092certbag +#define M_PKCS12_x509crl2certbag PKCS12_x509crl2certbag + +#define M_PKCS12_certbag2x509 PKCS12_certbag2x509 +#define M_PKCS12_certbag2x509crl PKCS12_certbag2x509crl + +#define M_PKCS12_unpack_p7data PKCS12_unpack_p7data +#define M_PKCS12_pack_authsafes PKCS12_pack_authsafes +#define M_PKCS12_unpack_authsafes PKCS12_unpack_authsafes +#define M_PKCS12_unpack_p7encdata PKCS12_unpack_p7encdata + +#define M_PKCS12_decrypt_skey PKCS12_decrypt_skey +#define M_PKCS8_decrypt PKCS8_decrypt + +#define M_PKCS12_bag_type(bg) OBJ_obj2nid((bg)->type) +#define M_PKCS12_cert_bag_type(bg) OBJ_obj2nid((bg)->value.bag->type) +#define M_PKCS12_crl_bag_type M_PKCS12_cert_bag_type + +#define PKCS12_get_attr(bag, attr_nid) \ + PKCS12_get_attr_gen(bag->attrib, attr_nid) + +#define PKCS8_get_attr(p8, attr_nid) \ + PKCS12_get_attr_gen(p8->attributes, attr_nid) + +#define PKCS12_mac_present(p12) ((p12)->mac ? 1 : 0) + + +PKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509); +PKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl); +X509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag); +X509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag); + +PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, int nid1, + int nid2); +PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8); +PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen); +PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass, + int passlen); +X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, + const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + PKCS8_PRIV_KEY_INFO *p8); +PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass, + int passlen, unsigned char *salt, + int saltlen, int iter, + PKCS8_PRIV_KEY_INFO *p8); +PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk); +STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7); +PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + STACK_OF(PKCS12_SAFEBAG) *bags); +STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen); + +int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes); +STACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12); + +int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, int namelen); +int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name, + int namelen); +int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, + int namelen); +int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name, + int namelen); +int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage); +ASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid); +char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag); +unsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, + int passlen, unsigned char *in, int inlen, + unsigned char **data, int *datalen, int en_de); +void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf); +ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, + void *obj, int zbuf); +PKCS12 *PKCS12_init(int mode); +int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, + unsigned char *out, const EVP_MD *md_type); +int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, int saltlen, int id, int iter, int n, unsigned char *out, const EVP_MD *md_type); +int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md_type, + int en_de); +int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, + unsigned char *mac, unsigned int *maclen); +int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen); +int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + const EVP_MD *md_type); +int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, + int saltlen, const EVP_MD *md_type); +unsigned char *asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen); +char *uni2asc(unsigned char *uni, int unilen); + +DECLARE_ASN1_FUNCTIONS(PKCS12) +DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA) +DECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG) +DECLARE_ASN1_FUNCTIONS(PKCS12_BAGS) + +DECLARE_ASN1_ITEM(PKCS12_SAFEBAGS) +DECLARE_ASN1_ITEM(PKCS12_AUTHSAFES) + +void PKCS12_PBE_add(void); +int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, + STACK_OF(X509) **ca); +PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, + STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter, + int mac_iter, int keytype); + +PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert); +PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key, + int key_usage, int iter, + int key_nid, char *pass); +int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, + int safe_nid, int iter, char *pass); +PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid); + +int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12); +int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12); +PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12); +PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12); +int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_PKCS12_strings(void); + +/* Error codes for the PKCS12 functions. */ + +/* Function codes. */ +#define PKCS12_F_PARSE_BAG 129 +#define PKCS12_F_PARSE_BAGS 103 +#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME 100 +#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_ASC 127 +#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI 102 +#define PKCS12_F_PKCS12_ADD_LOCALKEYID 104 +#define PKCS12_F_PKCS12_CREATE 105 +#define PKCS12_F_PKCS12_GEN_MAC 107 +#define PKCS12_F_PKCS12_INIT 109 +#define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I 106 +#define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT 108 +#define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG 117 +#define PKCS12_F_PKCS12_KEY_GEN_ASC 110 +#define PKCS12_F_PKCS12_KEY_GEN_UNI 111 +#define PKCS12_F_PKCS12_MAKE_KEYBAG 112 +#define PKCS12_F_PKCS12_MAKE_SHKEYBAG 113 +#define PKCS12_F_PKCS12_NEWPASS 128 +#define PKCS12_F_PKCS12_PACK_P7DATA 114 +#define PKCS12_F_PKCS12_PACK_P7ENCDATA 115 +#define PKCS12_F_PKCS12_PARSE 118 +#define PKCS12_F_PKCS12_PBE_CRYPT 119 +#define PKCS12_F_PKCS12_PBE_KEYIVGEN 120 +#define PKCS12_F_PKCS12_SETUP_MAC 122 +#define PKCS12_F_PKCS12_SET_MAC 123 +#define PKCS12_F_PKCS12_UNPACK_AUTHSAFES 130 +#define PKCS12_F_PKCS12_UNPACK_P7DATA 131 +#define PKCS12_F_PKCS12_VERIFY_MAC 126 +#define PKCS12_F_PKCS8_ADD_KEYUSAGE 124 +#define PKCS12_F_PKCS8_ENCRYPT 125 + +/* Reason codes. */ +#define PKCS12_R_CANT_PACK_STRUCTURE 100 +#define PKCS12_R_CONTENT_TYPE_NOT_DATA 121 +#define PKCS12_R_DECODE_ERROR 101 +#define PKCS12_R_ENCODE_ERROR 102 +#define PKCS12_R_ENCRYPT_ERROR 103 +#define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE 120 +#define PKCS12_R_INVALID_NULL_ARGUMENT 104 +#define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105 +#define PKCS12_R_IV_GEN_ERROR 106 +#define PKCS12_R_KEY_GEN_ERROR 107 +#define PKCS12_R_MAC_ABSENT 108 +#define PKCS12_R_MAC_GENERATION_ERROR 109 +#define PKCS12_R_MAC_SETUP_ERROR 110 +#define PKCS12_R_MAC_STRING_SET_ERROR 111 +#define PKCS12_R_MAC_VERIFY_ERROR 112 +#define PKCS12_R_MAC_VERIFY_FAILURE 113 +#define PKCS12_R_PARSE_ERROR 114 +#define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR 115 +#define PKCS12_R_PKCS12_CIPHERFINAL_ERROR 116 +#define PKCS12_R_PKCS12_PBE_CRYPT_ERROR 117 +#define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM 118 +#define PKCS12_R_UNSUPPORTED_PKCS12_MODE 119 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/pkcs7.h b/src/dep/include/openssl/pkcs7.h index c73a525..47071a6 100644 --- a/src/dep/include/openssl/pkcs7.h +++ b/src/dep/include/openssl/pkcs7.h @@ -1,464 +1,464 @@ -/* crypto/pkcs7/pkcs7.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_PKCS7_H -#define HEADER_PKCS7_H - -#include -#include -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef OPENSSL_SYS_WIN32 -/* Under Win32 thes are defined in wincrypt.h */ -#undef PKCS7_ISSUER_AND_SERIAL -#undef PKCS7_SIGNER_INFO -#endif - -/* -Encryption_ID DES-CBC -Digest_ID MD5 -Digest_Encryption_ID rsaEncryption -Key_Encryption_ID rsaEncryption -*/ - -typedef struct pkcs7_issuer_and_serial_st - { - X509_NAME *issuer; - ASN1_INTEGER *serial; - } PKCS7_ISSUER_AND_SERIAL; - -typedef struct pkcs7_signer_info_st - { - ASN1_INTEGER *version; /* version 1 */ - PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; - X509_ALGOR *digest_alg; - STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */ - X509_ALGOR *digest_enc_alg; - ASN1_OCTET_STRING *enc_digest; - STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */ - - /* The private key to sign with */ - EVP_PKEY *pkey; - } PKCS7_SIGNER_INFO; - -DECLARE_STACK_OF(PKCS7_SIGNER_INFO) -DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) - -typedef struct pkcs7_recip_info_st - { - ASN1_INTEGER *version; /* version 0 */ - PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; - X509_ALGOR *key_enc_algor; - ASN1_OCTET_STRING *enc_key; - X509 *cert; /* get the pub-key from this */ - } PKCS7_RECIP_INFO; - -DECLARE_STACK_OF(PKCS7_RECIP_INFO) -DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) - -typedef struct pkcs7_signed_st - { - ASN1_INTEGER *version; /* version 1 */ - STACK_OF(X509_ALGOR) *md_algs; /* md used */ - STACK_OF(X509) *cert; /* [ 0 ] */ - STACK_OF(X509_CRL) *crl; /* [ 1 ] */ - STACK_OF(PKCS7_SIGNER_INFO) *signer_info; - - struct pkcs7_st *contents; - } PKCS7_SIGNED; -/* The above structure is very very similar to PKCS7_SIGN_ENVELOPE. - * How about merging the two */ - -typedef struct pkcs7_enc_content_st - { - ASN1_OBJECT *content_type; - X509_ALGOR *algorithm; - ASN1_OCTET_STRING *enc_data; /* [ 0 ] */ - const EVP_CIPHER *cipher; - } PKCS7_ENC_CONTENT; - -typedef struct pkcs7_enveloped_st - { - ASN1_INTEGER *version; /* version 0 */ - STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; - PKCS7_ENC_CONTENT *enc_data; - } PKCS7_ENVELOPE; - -typedef struct pkcs7_signedandenveloped_st - { - ASN1_INTEGER *version; /* version 1 */ - STACK_OF(X509_ALGOR) *md_algs; /* md used */ - STACK_OF(X509) *cert; /* [ 0 ] */ - STACK_OF(X509_CRL) *crl; /* [ 1 ] */ - STACK_OF(PKCS7_SIGNER_INFO) *signer_info; - - PKCS7_ENC_CONTENT *enc_data; - STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; - } PKCS7_SIGN_ENVELOPE; - -typedef struct pkcs7_digest_st - { - ASN1_INTEGER *version; /* version 0 */ - X509_ALGOR *md; /* md used */ - struct pkcs7_st *contents; - ASN1_OCTET_STRING *digest; - } PKCS7_DIGEST; - -typedef struct pkcs7_encrypted_st - { - ASN1_INTEGER *version; /* version 0 */ - PKCS7_ENC_CONTENT *enc_data; - } PKCS7_ENCRYPT; - -typedef struct pkcs7_st - { - /* The following is non NULL if it contains ASN1 encoding of - * this structure */ - unsigned char *asn1; - long length; - -#define PKCS7_S_HEADER 0 -#define PKCS7_S_BODY 1 -#define PKCS7_S_TAIL 2 - int state; /* used during processing */ - - int detached; - - ASN1_OBJECT *type; - /* content as defined by the type */ - /* all encryption/message digests are applied to the 'contents', - * leaving out the 'type' field. */ - union { - char *ptr; - - /* NID_pkcs7_data */ - ASN1_OCTET_STRING *data; - - /* NID_pkcs7_signed */ - PKCS7_SIGNED *sign; - - /* NID_pkcs7_enveloped */ - PKCS7_ENVELOPE *enveloped; - - /* NID_pkcs7_signedAndEnveloped */ - PKCS7_SIGN_ENVELOPE *signed_and_enveloped; - - /* NID_pkcs7_digest */ - PKCS7_DIGEST *digest; - - /* NID_pkcs7_encrypted */ - PKCS7_ENCRYPT *encrypted; - - /* Anything else */ - ASN1_TYPE *other; - } d; - } PKCS7; - -DECLARE_STACK_OF(PKCS7) -DECLARE_ASN1_SET_OF(PKCS7) -DECLARE_PKCS12_STACK_OF(PKCS7) - -#define PKCS7_OP_SET_DETACHED_SIGNATURE 1 -#define PKCS7_OP_GET_DETACHED_SIGNATURE 2 - -#define PKCS7_get_signed_attributes(si) ((si)->auth_attr) -#define PKCS7_get_attributes(si) ((si)->unauth_attr) - -#define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed) -#define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted) -#define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped) -#define PKCS7_type_is_signedAndEnveloped(a) \ - (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) -#define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data) - -#define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest) - -#define PKCS7_set_detached(p,v) \ - PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL) -#define PKCS7_get_detached(p) \ - PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL) - -#define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7)) - -#ifdef SSLEAY_MACROS -#ifndef PKCS7_ISSUER_AND_SERIAL_digest -#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \ - ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\ - (char *)data,md,len) -#endif -#endif - -/* S/MIME related flags */ - -#define PKCS7_TEXT 0x1 -#define PKCS7_NOCERTS 0x2 -#define PKCS7_NOSIGS 0x4 -#define PKCS7_NOCHAIN 0x8 -#define PKCS7_NOINTERN 0x10 -#define PKCS7_NOVERIFY 0x20 -#define PKCS7_DETACHED 0x40 -#define PKCS7_BINARY 0x80 -#define PKCS7_NOATTR 0x100 -#define PKCS7_NOSMIMECAP 0x200 -#define PKCS7_NOOLDMIMETYPE 0x400 -#define PKCS7_CRLFEOL 0x800 -#define PKCS7_STREAM 0x1000 -#define PKCS7_NOCRL 0x2000 - -/* Flags: for compatibility with older code */ - -#define SMIME_TEXT PKCS7_TEXT -#define SMIME_NOCERTS PKCS7_NOCERTS -#define SMIME_NOSIGS PKCS7_NOSIGS -#define SMIME_NOCHAIN PKCS7_NOCHAIN -#define SMIME_NOINTERN PKCS7_NOINTERN -#define SMIME_NOVERIFY PKCS7_NOVERIFY -#define SMIME_DETACHED PKCS7_DETACHED -#define SMIME_BINARY PKCS7_BINARY -#define SMIME_NOATTR PKCS7_NOATTR - -DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL) - -#ifndef SSLEAY_MACROS -int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,const EVP_MD *type, - unsigned char *md,unsigned int *len); -#ifndef OPENSSL_NO_FP_API -PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7); -int i2d_PKCS7_fp(FILE *fp,PKCS7 *p7); -#endif -PKCS7 *PKCS7_dup(PKCS7 *p7); -PKCS7 *d2i_PKCS7_bio(BIO *bp,PKCS7 **p7); -int i2d_PKCS7_bio(BIO *bp,PKCS7 *p7); -#endif - -DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO) -DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO) -DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED) -DECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT) -DECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE) -DECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE) -DECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST) -DECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT) -DECLARE_ASN1_FUNCTIONS(PKCS7) - -DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN) -DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY) - -DECLARE_ASN1_NDEF_FUNCTION(PKCS7) - -long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg); - -int PKCS7_set_type(PKCS7 *p7, int type); -int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other); -int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data); -int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, - const EVP_MD *dgst); -int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i); -int PKCS7_add_certificate(PKCS7 *p7, X509 *x509); -int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509); -int PKCS7_content_new(PKCS7 *p7, int nid); -int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, - BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si); -int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, - X509 *x509); - -BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio); -int PKCS7_dataFinal(PKCS7 *p7, BIO *bio); -BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert); - - -PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, - EVP_PKEY *pkey, const EVP_MD *dgst); -X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si); -int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md); -STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7); - -PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509); -int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri); -int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509); -int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher); - -PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx); -ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk); -int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si,int nid,int type, - void *data); -int PKCS7_add_attribute (PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, - void *value); -ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid); -ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid); -int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si, - STACK_OF(X509_ATTRIBUTE) *sk); -int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk); - - -PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, - BIO *data, int flags); -int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, - BIO *indata, BIO *out, int flags); -STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags); -PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, - int flags); -int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags); - -int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, - STACK_OF(X509_ALGOR) *cap); -STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si); -int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg); - -int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags); -PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont); -int SMIME_crlf_copy(BIO *in, BIO *out, int flags); -int SMIME_text(BIO *in, BIO *out); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_PKCS7_strings(void); - -/* Error codes for the PKCS7 functions. */ - -/* Function codes. */ -#define PKCS7_F_B64_READ_PKCS7 120 -#define PKCS7_F_B64_WRITE_PKCS7 121 -#define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 118 -#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100 -#define PKCS7_F_PKCS7_ADD_CRL 101 -#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102 -#define PKCS7_F_PKCS7_ADD_SIGNER 103 -#define PKCS7_F_PKCS7_BIO_ADD_DIGEST 125 -#define PKCS7_F_PKCS7_CTRL 104 -#define PKCS7_F_PKCS7_DATADECODE 112 -#define PKCS7_F_PKCS7_DATAFINAL 128 -#define PKCS7_F_PKCS7_DATAINIT 105 -#define PKCS7_F_PKCS7_DATASIGN 106 -#define PKCS7_F_PKCS7_DATAVERIFY 107 -#define PKCS7_F_PKCS7_DECRYPT 114 -#define PKCS7_F_PKCS7_ENCRYPT 115 -#define PKCS7_F_PKCS7_FIND_DIGEST 127 -#define PKCS7_F_PKCS7_GET0_SIGNERS 124 -#define PKCS7_F_PKCS7_SET_CIPHER 108 -#define PKCS7_F_PKCS7_SET_CONTENT 109 -#define PKCS7_F_PKCS7_SET_DIGEST 126 -#define PKCS7_F_PKCS7_SET_TYPE 110 -#define PKCS7_F_PKCS7_SIGN 116 -#define PKCS7_F_PKCS7_SIGNATUREVERIFY 113 -#define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 119 -#define PKCS7_F_PKCS7_VERIFY 117 -#define PKCS7_F_SMIME_READ_PKCS7 122 -#define PKCS7_F_SMIME_TEXT 123 - -/* Reason codes. */ -#define PKCS7_R_CERTIFICATE_VERIFY_ERROR 117 -#define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 144 -#define PKCS7_R_CIPHER_NOT_INITIALIZED 116 -#define PKCS7_R_CONTENT_AND_DATA_PRESENT 118 -#define PKCS7_R_DECODE_ERROR 130 -#define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH 100 -#define PKCS7_R_DECRYPT_ERROR 119 -#define PKCS7_R_DIGEST_FAILURE 101 -#define PKCS7_R_ERROR_ADDING_RECIPIENT 120 -#define PKCS7_R_ERROR_SETTING_CIPHER 121 -#define PKCS7_R_INVALID_MIME_TYPE 131 -#define PKCS7_R_INVALID_NULL_POINTER 143 -#define PKCS7_R_MIME_NO_CONTENT_TYPE 132 -#define PKCS7_R_MIME_PARSE_ERROR 133 -#define PKCS7_R_MIME_SIG_PARSE_ERROR 134 -#define PKCS7_R_MISSING_CERIPEND_INFO 103 -#define PKCS7_R_NO_CONTENT 122 -#define PKCS7_R_NO_CONTENT_TYPE 135 -#define PKCS7_R_NO_MULTIPART_BODY_FAILURE 136 -#define PKCS7_R_NO_MULTIPART_BOUNDARY 137 -#define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115 -#define PKCS7_R_NO_RECIPIENT_MATCHES_KEY 146 -#define PKCS7_R_NO_SIGNATURES_ON_DATA 123 -#define PKCS7_R_NO_SIGNERS 142 -#define PKCS7_R_NO_SIG_CONTENT_TYPE 138 -#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104 -#define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 124 -#define PKCS7_R_PKCS7_DATAFINAL 126 -#define PKCS7_R_PKCS7_DATAFINAL_ERROR 125 -#define PKCS7_R_PKCS7_DATASIGN 145 -#define PKCS7_R_PKCS7_PARSE_ERROR 139 -#define PKCS7_R_PKCS7_SIG_PARSE_ERROR 140 -#define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 127 -#define PKCS7_R_SIGNATURE_FAILURE 105 -#define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 128 -#define PKCS7_R_SIG_INVALID_MIME_TYPE 141 -#define PKCS7_R_SMIME_TEXT_ERROR 129 -#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106 -#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 107 -#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 108 -#define PKCS7_R_UNKNOWN_DIGEST_TYPE 109 -#define PKCS7_R_UNKNOWN_OPERATION 110 -#define PKCS7_R_UNSUPPORTED_CIPHER_TYPE 111 -#define PKCS7_R_UNSUPPORTED_CONTENT_TYPE 112 -#define PKCS7_R_WRONG_CONTENT_TYPE 113 -#define PKCS7_R_WRONG_PKCS7_TYPE 114 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/pkcs7/pkcs7.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_PKCS7_H +#define HEADER_PKCS7_H + +#include +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_SYS_WIN32 +/* Under Win32 thes are defined in wincrypt.h */ +#undef PKCS7_ISSUER_AND_SERIAL +#undef PKCS7_SIGNER_INFO +#endif + +/* +Encryption_ID DES-CBC +Digest_ID MD5 +Digest_Encryption_ID rsaEncryption +Key_Encryption_ID rsaEncryption +*/ + +typedef struct pkcs7_issuer_and_serial_st + { + X509_NAME *issuer; + ASN1_INTEGER *serial; + } PKCS7_ISSUER_AND_SERIAL; + +typedef struct pkcs7_signer_info_st + { + ASN1_INTEGER *version; /* version 1 */ + PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; + X509_ALGOR *digest_alg; + STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */ + X509_ALGOR *digest_enc_alg; + ASN1_OCTET_STRING *enc_digest; + STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */ + + /* The private key to sign with */ + EVP_PKEY *pkey; + } PKCS7_SIGNER_INFO; + +DECLARE_STACK_OF(PKCS7_SIGNER_INFO) +DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) + +typedef struct pkcs7_recip_info_st + { + ASN1_INTEGER *version; /* version 0 */ + PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; + X509_ALGOR *key_enc_algor; + ASN1_OCTET_STRING *enc_key; + X509 *cert; /* get the pub-key from this */ + } PKCS7_RECIP_INFO; + +DECLARE_STACK_OF(PKCS7_RECIP_INFO) +DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) + +typedef struct pkcs7_signed_st + { + ASN1_INTEGER *version; /* version 1 */ + STACK_OF(X509_ALGOR) *md_algs; /* md used */ + STACK_OF(X509) *cert; /* [ 0 ] */ + STACK_OF(X509_CRL) *crl; /* [ 1 ] */ + STACK_OF(PKCS7_SIGNER_INFO) *signer_info; + + struct pkcs7_st *contents; + } PKCS7_SIGNED; +/* The above structure is very very similar to PKCS7_SIGN_ENVELOPE. + * How about merging the two */ + +typedef struct pkcs7_enc_content_st + { + ASN1_OBJECT *content_type; + X509_ALGOR *algorithm; + ASN1_OCTET_STRING *enc_data; /* [ 0 ] */ + const EVP_CIPHER *cipher; + } PKCS7_ENC_CONTENT; + +typedef struct pkcs7_enveloped_st + { + ASN1_INTEGER *version; /* version 0 */ + STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; + PKCS7_ENC_CONTENT *enc_data; + } PKCS7_ENVELOPE; + +typedef struct pkcs7_signedandenveloped_st + { + ASN1_INTEGER *version; /* version 1 */ + STACK_OF(X509_ALGOR) *md_algs; /* md used */ + STACK_OF(X509) *cert; /* [ 0 ] */ + STACK_OF(X509_CRL) *crl; /* [ 1 ] */ + STACK_OF(PKCS7_SIGNER_INFO) *signer_info; + + PKCS7_ENC_CONTENT *enc_data; + STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; + } PKCS7_SIGN_ENVELOPE; + +typedef struct pkcs7_digest_st + { + ASN1_INTEGER *version; /* version 0 */ + X509_ALGOR *md; /* md used */ + struct pkcs7_st *contents; + ASN1_OCTET_STRING *digest; + } PKCS7_DIGEST; + +typedef struct pkcs7_encrypted_st + { + ASN1_INTEGER *version; /* version 0 */ + PKCS7_ENC_CONTENT *enc_data; + } PKCS7_ENCRYPT; + +typedef struct pkcs7_st + { + /* The following is non NULL if it contains ASN1 encoding of + * this structure */ + unsigned char *asn1; + long length; + +#define PKCS7_S_HEADER 0 +#define PKCS7_S_BODY 1 +#define PKCS7_S_TAIL 2 + int state; /* used during processing */ + + int detached; + + ASN1_OBJECT *type; + /* content as defined by the type */ + /* all encryption/message digests are applied to the 'contents', + * leaving out the 'type' field. */ + union { + char *ptr; + + /* NID_pkcs7_data */ + ASN1_OCTET_STRING *data; + + /* NID_pkcs7_signed */ + PKCS7_SIGNED *sign; + + /* NID_pkcs7_enveloped */ + PKCS7_ENVELOPE *enveloped; + + /* NID_pkcs7_signedAndEnveloped */ + PKCS7_SIGN_ENVELOPE *signed_and_enveloped; + + /* NID_pkcs7_digest */ + PKCS7_DIGEST *digest; + + /* NID_pkcs7_encrypted */ + PKCS7_ENCRYPT *encrypted; + + /* Anything else */ + ASN1_TYPE *other; + } d; + } PKCS7; + +DECLARE_STACK_OF(PKCS7) +DECLARE_ASN1_SET_OF(PKCS7) +DECLARE_PKCS12_STACK_OF(PKCS7) + +#define PKCS7_OP_SET_DETACHED_SIGNATURE 1 +#define PKCS7_OP_GET_DETACHED_SIGNATURE 2 + +#define PKCS7_get_signed_attributes(si) ((si)->auth_attr) +#define PKCS7_get_attributes(si) ((si)->unauth_attr) + +#define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed) +#define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted) +#define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped) +#define PKCS7_type_is_signedAndEnveloped(a) \ + (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) +#define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data) + +#define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest) + +#define PKCS7_set_detached(p,v) \ + PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL) +#define PKCS7_get_detached(p) \ + PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL) + +#define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7)) + +#ifdef SSLEAY_MACROS +#ifndef PKCS7_ISSUER_AND_SERIAL_digest +#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\ + (char *)data,md,len) +#endif +#endif + +/* S/MIME related flags */ + +#define PKCS7_TEXT 0x1 +#define PKCS7_NOCERTS 0x2 +#define PKCS7_NOSIGS 0x4 +#define PKCS7_NOCHAIN 0x8 +#define PKCS7_NOINTERN 0x10 +#define PKCS7_NOVERIFY 0x20 +#define PKCS7_DETACHED 0x40 +#define PKCS7_BINARY 0x80 +#define PKCS7_NOATTR 0x100 +#define PKCS7_NOSMIMECAP 0x200 +#define PKCS7_NOOLDMIMETYPE 0x400 +#define PKCS7_CRLFEOL 0x800 +#define PKCS7_STREAM 0x1000 +#define PKCS7_NOCRL 0x2000 + +/* Flags: for compatibility with older code */ + +#define SMIME_TEXT PKCS7_TEXT +#define SMIME_NOCERTS PKCS7_NOCERTS +#define SMIME_NOSIGS PKCS7_NOSIGS +#define SMIME_NOCHAIN PKCS7_NOCHAIN +#define SMIME_NOINTERN PKCS7_NOINTERN +#define SMIME_NOVERIFY PKCS7_NOVERIFY +#define SMIME_DETACHED PKCS7_DETACHED +#define SMIME_BINARY PKCS7_BINARY +#define SMIME_NOATTR PKCS7_NOATTR + +DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL) + +#ifndef SSLEAY_MACROS +int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,const EVP_MD *type, + unsigned char *md,unsigned int *len); +#ifndef OPENSSL_NO_FP_API +PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7); +int i2d_PKCS7_fp(FILE *fp,PKCS7 *p7); +#endif +PKCS7 *PKCS7_dup(PKCS7 *p7); +PKCS7 *d2i_PKCS7_bio(BIO *bp,PKCS7 **p7); +int i2d_PKCS7_bio(BIO *bp,PKCS7 *p7); +#endif + +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO) +DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO) +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE) +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE) +DECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT) +DECLARE_ASN1_FUNCTIONS(PKCS7) + +DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN) +DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY) + +DECLARE_ASN1_NDEF_FUNCTION(PKCS7) + +long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg); + +int PKCS7_set_type(PKCS7 *p7, int type); +int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other); +int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data); +int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, + const EVP_MD *dgst); +int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i); +int PKCS7_add_certificate(PKCS7 *p7, X509 *x509); +int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509); +int PKCS7_content_new(PKCS7 *p7, int nid); +int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, + BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si); +int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, + X509 *x509); + +BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio); +int PKCS7_dataFinal(PKCS7 *p7, BIO *bio); +BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert); + + +PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, + EVP_PKEY *pkey, const EVP_MD *dgst); +X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si); +int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md); +STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7); + +PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509); +int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri); +int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509); +int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher); + +PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx); +ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk); +int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si,int nid,int type, + void *data); +int PKCS7_add_attribute (PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, + void *value); +ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid); +ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid); +int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si, + STACK_OF(X509_ATTRIBUTE) *sk); +int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk); + + +PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, + BIO *data, int flags); +int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, + BIO *indata, BIO *out, int flags); +STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags); +PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, + int flags); +int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags); + +int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, + STACK_OF(X509_ALGOR) *cap); +STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si); +int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg); + +int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags); +PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont); +int SMIME_crlf_copy(BIO *in, BIO *out, int flags); +int SMIME_text(BIO *in, BIO *out); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_PKCS7_strings(void); + +/* Error codes for the PKCS7 functions. */ + +/* Function codes. */ +#define PKCS7_F_B64_READ_PKCS7 120 +#define PKCS7_F_B64_WRITE_PKCS7 121 +#define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 118 +#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100 +#define PKCS7_F_PKCS7_ADD_CRL 101 +#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102 +#define PKCS7_F_PKCS7_ADD_SIGNER 103 +#define PKCS7_F_PKCS7_BIO_ADD_DIGEST 125 +#define PKCS7_F_PKCS7_CTRL 104 +#define PKCS7_F_PKCS7_DATADECODE 112 +#define PKCS7_F_PKCS7_DATAFINAL 128 +#define PKCS7_F_PKCS7_DATAINIT 105 +#define PKCS7_F_PKCS7_DATASIGN 106 +#define PKCS7_F_PKCS7_DATAVERIFY 107 +#define PKCS7_F_PKCS7_DECRYPT 114 +#define PKCS7_F_PKCS7_ENCRYPT 115 +#define PKCS7_F_PKCS7_FIND_DIGEST 127 +#define PKCS7_F_PKCS7_GET0_SIGNERS 124 +#define PKCS7_F_PKCS7_SET_CIPHER 108 +#define PKCS7_F_PKCS7_SET_CONTENT 109 +#define PKCS7_F_PKCS7_SET_DIGEST 126 +#define PKCS7_F_PKCS7_SET_TYPE 110 +#define PKCS7_F_PKCS7_SIGN 116 +#define PKCS7_F_PKCS7_SIGNATUREVERIFY 113 +#define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 119 +#define PKCS7_F_PKCS7_VERIFY 117 +#define PKCS7_F_SMIME_READ_PKCS7 122 +#define PKCS7_F_SMIME_TEXT 123 + +/* Reason codes. */ +#define PKCS7_R_CERTIFICATE_VERIFY_ERROR 117 +#define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 144 +#define PKCS7_R_CIPHER_NOT_INITIALIZED 116 +#define PKCS7_R_CONTENT_AND_DATA_PRESENT 118 +#define PKCS7_R_DECODE_ERROR 130 +#define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH 100 +#define PKCS7_R_DECRYPT_ERROR 119 +#define PKCS7_R_DIGEST_FAILURE 101 +#define PKCS7_R_ERROR_ADDING_RECIPIENT 120 +#define PKCS7_R_ERROR_SETTING_CIPHER 121 +#define PKCS7_R_INVALID_MIME_TYPE 131 +#define PKCS7_R_INVALID_NULL_POINTER 143 +#define PKCS7_R_MIME_NO_CONTENT_TYPE 132 +#define PKCS7_R_MIME_PARSE_ERROR 133 +#define PKCS7_R_MIME_SIG_PARSE_ERROR 134 +#define PKCS7_R_MISSING_CERIPEND_INFO 103 +#define PKCS7_R_NO_CONTENT 122 +#define PKCS7_R_NO_CONTENT_TYPE 135 +#define PKCS7_R_NO_MULTIPART_BODY_FAILURE 136 +#define PKCS7_R_NO_MULTIPART_BOUNDARY 137 +#define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115 +#define PKCS7_R_NO_RECIPIENT_MATCHES_KEY 146 +#define PKCS7_R_NO_SIGNATURES_ON_DATA 123 +#define PKCS7_R_NO_SIGNERS 142 +#define PKCS7_R_NO_SIG_CONTENT_TYPE 138 +#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104 +#define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 124 +#define PKCS7_R_PKCS7_DATAFINAL 126 +#define PKCS7_R_PKCS7_DATAFINAL_ERROR 125 +#define PKCS7_R_PKCS7_DATASIGN 145 +#define PKCS7_R_PKCS7_PARSE_ERROR 139 +#define PKCS7_R_PKCS7_SIG_PARSE_ERROR 140 +#define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 127 +#define PKCS7_R_SIGNATURE_FAILURE 105 +#define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 128 +#define PKCS7_R_SIG_INVALID_MIME_TYPE 141 +#define PKCS7_R_SMIME_TEXT_ERROR 129 +#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106 +#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 107 +#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 108 +#define PKCS7_R_UNKNOWN_DIGEST_TYPE 109 +#define PKCS7_R_UNKNOWN_OPERATION 110 +#define PKCS7_R_UNSUPPORTED_CIPHER_TYPE 111 +#define PKCS7_R_UNSUPPORTED_CONTENT_TYPE 112 +#define PKCS7_R_WRONG_CONTENT_TYPE 113 +#define PKCS7_R_WRONG_PKCS7_TYPE 114 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/pq_compat.h b/src/dep/include/openssl/pq_compat.h index 8d29230..6cf4f7a 100644 --- a/src/dep/include/openssl/pq_compat.h +++ b/src/dep/include/openssl/pq_compat.h @@ -1,147 +1,147 @@ -/* crypto/pqueue/pqueue_compat.h */ -/* - * DTLS implementation written by Nagendra Modadugu - * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. - */ -/* ==================================================================== - * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#include "opensslconf.h" -#include - -/* - * The purpose of this header file is for supporting 64-bit integer - * manipulation on 32-bit (and lower) machines. Currently the only - * such environment is VMS, Utrix and those with smaller default integer - * sizes than 32 bits. For all such environment, we fall back to using - * BIGNUM. We may need to fine tune the conditions for systems that - * are incorrectly configured. - * - * The only clients of this code are (1) pqueue for priority, and - * (2) DTLS, for sequence number manipulation. - */ - -#if (defined(THIRTY_TWO_BIT) && !defined(BN_LLONG)) || defined(SIXTEEN_BIT) || defined(EIGHT_BIT) - -#define PQ_64BIT_IS_INTEGER 0 -#define PQ_64BIT_IS_BIGNUM 1 - -#define PQ_64BIT BIGNUM -#define PQ_64BIT_CTX BN_CTX - -#define pq_64bit_init(x) BN_init(x) -#define pq_64bit_free(x) BN_free(x) - -#define pq_64bit_ctx_new(ctx) BN_CTX_new() -#define pq_64bit_ctx_free(x) BN_CTX_free(x) - -#define pq_64bit_assign(x, y) BN_copy(x, y) -#define pq_64bit_assign_word(x, y) BN_set_word(x, y) -#define pq_64bit_gt(x, y) BN_ucmp(x, y) >= 1 ? 1 : 0 -#define pq_64bit_eq(x, y) BN_ucmp(x, y) == 0 ? 1 : 0 -#define pq_64bit_add_word(x, w) BN_add_word(x, w) -#define pq_64bit_sub(r, x, y) BN_sub(r, x, y) -#define pq_64bit_sub_word(x, w) BN_sub_word(x, w) -#define pq_64bit_mod(r, x, n, ctx) BN_mod(r, x, n, ctx) - -#define pq_64bit_bin2num(bn, bytes, len) BN_bin2bn(bytes, len, bn) -#define pq_64bit_num2bin(bn, bytes) BN_bn2bin(bn, bytes) -#define pq_64bit_get_word(x) BN_get_word(x) -#define pq_64bit_is_bit_set(x, offset) BN_is_bit_set(x, offset) -#define pq_64bit_lshift(r, x, shift) BN_lshift(r, x, shift) -#define pq_64bit_set_bit(x, num) BN_set_bit(x, num) -#define pq_64bit_get_length(x) BN_num_bits((x)) - -#else - -#define PQ_64BIT_IS_INTEGER 1 -#define PQ_64BIT_IS_BIGNUM 0 - -#if defined(SIXTY_FOUR_BIT) -#define PQ_64BIT BN_ULONG -#define PQ_64BIT_PRINT "%lld" -#elif defined(SIXTY_FOUR_BIT_LONG) -#define PQ_64BIT BN_ULONG -#define PQ_64BIT_PRINT "%ld" -#elif defined(THIRTY_TWO_BIT) -#define PQ_64BIT BN_ULLONG -#define PQ_64BIT_PRINT "%lld" -#endif - -#define PQ_64BIT_CTX void - -#define pq_64bit_init(x) -#define pq_64bit_free(x) -#define pq_64bit_ctx_new(ctx) (ctx) -#define pq_64bit_ctx_free(x) - -#define pq_64bit_assign(x, y) (*(x) = *(y)) -#define pq_64bit_assign_word(x, y) (*(x) = y) -#define pq_64bit_gt(x, y) (*(x) > *(y)) -#define pq_64bit_eq(x, y) (*(x) == *(y)) -#define pq_64bit_add_word(x, w) (*(x) = (*(x) + (w))) -#define pq_64bit_sub(r, x, y) (*(r) = (*(x) - *(y))) -#define pq_64bit_sub_word(x, w) (*(x) = (*(x) - (w))) -#define pq_64bit_mod(r, x, n, ctx) - -#define pq_64bit_bin2num(num, bytes, len) bytes_to_long_long(bytes, num) -#define pq_64bit_num2bin(num, bytes) long_long_to_bytes(num, bytes) -#define pq_64bit_get_word(x) *(x) -#define pq_64bit_lshift(r, x, shift) (*(r) = (*(x) << (shift))) -#define pq_64bit_set_bit(x, num) do { \ - PQ_64BIT mask = 1; \ - mask = mask << (num); \ - *(x) |= mask; \ - } while(0) -#endif /* OPENSSL_SYS_VMS */ +/* crypto/pqueue/pqueue_compat.h */ +/* + * DTLS implementation written by Nagendra Modadugu + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. + */ +/* ==================================================================== + * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include "opensslconf.h" +#include + +/* + * The purpose of this header file is for supporting 64-bit integer + * manipulation on 32-bit (and lower) machines. Currently the only + * such environment is VMS, Utrix and those with smaller default integer + * sizes than 32 bits. For all such environment, we fall back to using + * BIGNUM. We may need to fine tune the conditions for systems that + * are incorrectly configured. + * + * The only clients of this code are (1) pqueue for priority, and + * (2) DTLS, for sequence number manipulation. + */ + +#if (defined(THIRTY_TWO_BIT) && !defined(BN_LLONG)) || defined(SIXTEEN_BIT) || defined(EIGHT_BIT) + +#define PQ_64BIT_IS_INTEGER 0 +#define PQ_64BIT_IS_BIGNUM 1 + +#define PQ_64BIT BIGNUM +#define PQ_64BIT_CTX BN_CTX + +#define pq_64bit_init(x) BN_init(x) +#define pq_64bit_free(x) BN_free(x) + +#define pq_64bit_ctx_new(ctx) BN_CTX_new() +#define pq_64bit_ctx_free(x) BN_CTX_free(x) + +#define pq_64bit_assign(x, y) BN_copy(x, y) +#define pq_64bit_assign_word(x, y) BN_set_word(x, y) +#define pq_64bit_gt(x, y) BN_ucmp(x, y) >= 1 ? 1 : 0 +#define pq_64bit_eq(x, y) BN_ucmp(x, y) == 0 ? 1 : 0 +#define pq_64bit_add_word(x, w) BN_add_word(x, w) +#define pq_64bit_sub(r, x, y) BN_sub(r, x, y) +#define pq_64bit_sub_word(x, w) BN_sub_word(x, w) +#define pq_64bit_mod(r, x, n, ctx) BN_mod(r, x, n, ctx) + +#define pq_64bit_bin2num(bn, bytes, len) BN_bin2bn(bytes, len, bn) +#define pq_64bit_num2bin(bn, bytes) BN_bn2bin(bn, bytes) +#define pq_64bit_get_word(x) BN_get_word(x) +#define pq_64bit_is_bit_set(x, offset) BN_is_bit_set(x, offset) +#define pq_64bit_lshift(r, x, shift) BN_lshift(r, x, shift) +#define pq_64bit_set_bit(x, num) BN_set_bit(x, num) +#define pq_64bit_get_length(x) BN_num_bits((x)) + +#else + +#define PQ_64BIT_IS_INTEGER 1 +#define PQ_64BIT_IS_BIGNUM 0 + +#if defined(SIXTY_FOUR_BIT) +#define PQ_64BIT BN_ULONG +#define PQ_64BIT_PRINT "%lld" +#elif defined(SIXTY_FOUR_BIT_LONG) +#define PQ_64BIT BN_ULONG +#define PQ_64BIT_PRINT "%ld" +#elif defined(THIRTY_TWO_BIT) +#define PQ_64BIT BN_ULLONG +#define PQ_64BIT_PRINT "%lld" +#endif + +#define PQ_64BIT_CTX void + +#define pq_64bit_init(x) +#define pq_64bit_free(x) +#define pq_64bit_ctx_new(ctx) (ctx) +#define pq_64bit_ctx_free(x) + +#define pq_64bit_assign(x, y) (*(x) = *(y)) +#define pq_64bit_assign_word(x, y) (*(x) = y) +#define pq_64bit_gt(x, y) (*(x) > *(y)) +#define pq_64bit_eq(x, y) (*(x) == *(y)) +#define pq_64bit_add_word(x, w) (*(x) = (*(x) + (w))) +#define pq_64bit_sub(r, x, y) (*(r) = (*(x) - *(y))) +#define pq_64bit_sub_word(x, w) (*(x) = (*(x) - (w))) +#define pq_64bit_mod(r, x, n, ctx) + +#define pq_64bit_bin2num(num, bytes, len) bytes_to_long_long(bytes, num) +#define pq_64bit_num2bin(num, bytes) long_long_to_bytes(num, bytes) +#define pq_64bit_get_word(x) *(x) +#define pq_64bit_lshift(r, x, shift) (*(r) = (*(x) << (shift))) +#define pq_64bit_set_bit(x, num) do { \ + PQ_64BIT mask = 1; \ + mask = mask << (num); \ + *(x) |= mask; \ + } while(0) +#endif /* OPENSSL_SYS_VMS */ diff --git a/src/dep/include/openssl/pqueue.h b/src/dep/include/openssl/pqueue.h index 2e54572..d290092 100644 --- a/src/dep/include/openssl/pqueue.h +++ b/src/dep/include/openssl/pqueue.h @@ -1,95 +1,95 @@ -/* crypto/pqueue/pqueue.h */ -/* - * DTLS implementation written by Nagendra Modadugu - * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. - */ -/* ==================================================================== - * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_PQUEUE_H -#define HEADER_PQUEUE_H - -#include -#include -#include - -#include - -typedef struct _pqueue *pqueue; - -typedef struct _pitem - { - PQ_64BIT priority; - void *data; - struct _pitem *next; - } pitem; - -typedef struct _pitem *piterator; - -pitem *pitem_new(PQ_64BIT priority, void *data); -void pitem_free(pitem *item); - -pqueue pqueue_new(void); -void pqueue_free(pqueue pq); - -pitem *pqueue_insert(pqueue pq, pitem *item); -pitem *pqueue_peek(pqueue pq); -pitem *pqueue_pop(pqueue pq); -pitem *pqueue_find(pqueue pq, PQ_64BIT priority); -pitem *pqueue_iterator(pqueue pq); -pitem *pqueue_next(piterator *iter); - -void pqueue_print(pqueue pq); - -#endif /* ! HEADER_PQUEUE_H */ +/* crypto/pqueue/pqueue.h */ +/* + * DTLS implementation written by Nagendra Modadugu + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. + */ +/* ==================================================================== + * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_PQUEUE_H +#define HEADER_PQUEUE_H + +#include +#include +#include + +#include + +typedef struct _pqueue *pqueue; + +typedef struct _pitem + { + PQ_64BIT priority; + void *data; + struct _pitem *next; + } pitem; + +typedef struct _pitem *piterator; + +pitem *pitem_new(PQ_64BIT priority, void *data); +void pitem_free(pitem *item); + +pqueue pqueue_new(void); +void pqueue_free(pqueue pq); + +pitem *pqueue_insert(pqueue pq, pitem *item); +pitem *pqueue_peek(pqueue pq); +pitem *pqueue_pop(pqueue pq); +pitem *pqueue_find(pqueue pq, PQ_64BIT priority); +pitem *pqueue_iterator(pqueue pq); +pitem *pqueue_next(piterator *iter); + +void pqueue_print(pqueue pq); + +#endif /* ! HEADER_PQUEUE_H */ diff --git a/src/dep/include/openssl/rand.h b/src/dep/include/openssl/rand.h index f7dd381..3160248 100644 --- a/src/dep/include/openssl/rand.h +++ b/src/dep/include/openssl/rand.h @@ -1,140 +1,140 @@ -/* crypto/rand/rand.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_RAND_H -#define HEADER_RAND_H - -#include -#include -#include - -#if defined(OPENSSL_SYS_WINDOWS) -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(OPENSSL_FIPS) -#define FIPS_RAND_SIZE_T size_t -#endif - -/* Already defined in ossl_typ.h */ -/* typedef struct rand_meth_st RAND_METHOD; */ - -struct rand_meth_st - { - void (*seed)(const void *buf, int num); - int (*bytes)(unsigned char *buf, int num); - void (*cleanup)(void); - void (*add)(const void *buf, int num, double entropy); - int (*pseudorand)(unsigned char *buf, int num); - int (*status)(void); - }; - -#ifdef BN_DEBUG -extern int rand_predictable; -#endif - -int RAND_set_rand_method(const RAND_METHOD *meth); -const RAND_METHOD *RAND_get_rand_method(void); -#ifndef OPENSSL_NO_ENGINE -int RAND_set_rand_engine(ENGINE *engine); -#endif -RAND_METHOD *RAND_SSLeay(void); -void RAND_cleanup(void ); -int RAND_bytes(unsigned char *buf,int num); -int RAND_pseudo_bytes(unsigned char *buf,int num); -void RAND_seed(const void *buf,int num); -void RAND_add(const void *buf,int num,double entropy); -int RAND_load_file(const char *file,long max_bytes); -int RAND_write_file(const char *file); -const char *RAND_file_name(char *file,size_t num); -int RAND_status(void); -int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes); -int RAND_egd(const char *path); -int RAND_egd_bytes(const char *path,int bytes); -int RAND_poll(void); - -#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) - -void RAND_screen(void); -int RAND_event(UINT, WPARAM, LPARAM); - -#endif - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_RAND_strings(void); - -/* Error codes for the RAND functions. */ - -/* Function codes. */ -#define RAND_F_RAND_GET_RAND_METHOD 101 -#define RAND_F_SSLEAY_RAND_BYTES 100 - -/* Reason codes. */ -#define RAND_R_PRNG_NOT_SEEDED 100 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/rand/rand.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RAND_H +#define HEADER_RAND_H + +#include +#include +#include + +#if defined(OPENSSL_SYS_WINDOWS) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(OPENSSL_FIPS) +#define FIPS_RAND_SIZE_T size_t +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct rand_meth_st RAND_METHOD; */ + +struct rand_meth_st + { + void (*seed)(const void *buf, int num); + int (*bytes)(unsigned char *buf, int num); + void (*cleanup)(void); + void (*add)(const void *buf, int num, double entropy); + int (*pseudorand)(unsigned char *buf, int num); + int (*status)(void); + }; + +#ifdef BN_DEBUG +extern int rand_predictable; +#endif + +int RAND_set_rand_method(const RAND_METHOD *meth); +const RAND_METHOD *RAND_get_rand_method(void); +#ifndef OPENSSL_NO_ENGINE +int RAND_set_rand_engine(ENGINE *engine); +#endif +RAND_METHOD *RAND_SSLeay(void); +void RAND_cleanup(void ); +int RAND_bytes(unsigned char *buf,int num); +int RAND_pseudo_bytes(unsigned char *buf,int num); +void RAND_seed(const void *buf,int num); +void RAND_add(const void *buf,int num,double entropy); +int RAND_load_file(const char *file,long max_bytes); +int RAND_write_file(const char *file); +const char *RAND_file_name(char *file,size_t num); +int RAND_status(void); +int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes); +int RAND_egd(const char *path); +int RAND_egd_bytes(const char *path,int bytes); +int RAND_poll(void); + +#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) + +void RAND_screen(void); +int RAND_event(UINT, WPARAM, LPARAM); + +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_RAND_strings(void); + +/* Error codes for the RAND functions. */ + +/* Function codes. */ +#define RAND_F_RAND_GET_RAND_METHOD 101 +#define RAND_F_SSLEAY_RAND_BYTES 100 + +/* Reason codes. */ +#define RAND_R_PRNG_NOT_SEEDED 100 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/rc2.h b/src/dep/include/openssl/rc2.h index 80d5248..227136b 100644 --- a/src/dep/include/openssl/rc2.h +++ b/src/dep/include/openssl/rc2.h @@ -1,101 +1,101 @@ -/* crypto/rc2/rc2.h */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_RC2_H -#define HEADER_RC2_H - -#include /* OPENSSL_NO_RC2, RC2_INT */ -#ifdef OPENSSL_NO_RC2 -#error RC2 is disabled. -#endif - -#define RC2_ENCRYPT 1 -#define RC2_DECRYPT 0 - -#define RC2_BLOCK 8 -#define RC2_KEY_LENGTH 16 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rc2_key_st - { - RC2_INT data[64]; - } RC2_KEY; - - -void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits); -void RC2_ecb_encrypt(const unsigned char *in,unsigned char *out,RC2_KEY *key, - int enc); -void RC2_encrypt(unsigned long *data,RC2_KEY *key); -void RC2_decrypt(unsigned long *data,RC2_KEY *key); -void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, - RC2_KEY *ks, unsigned char *iv, int enc); -void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC2_KEY *schedule, unsigned char *ivec, - int *num, int enc); -void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC2_KEY *schedule, unsigned char *ivec, - int *num); - -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/rc2/rc2.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RC2_H +#define HEADER_RC2_H + +#include /* OPENSSL_NO_RC2, RC2_INT */ +#ifdef OPENSSL_NO_RC2 +#error RC2 is disabled. +#endif + +#define RC2_ENCRYPT 1 +#define RC2_DECRYPT 0 + +#define RC2_BLOCK 8 +#define RC2_KEY_LENGTH 16 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rc2_key_st + { + RC2_INT data[64]; + } RC2_KEY; + + +void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits); +void RC2_ecb_encrypt(const unsigned char *in,unsigned char *out,RC2_KEY *key, + int enc); +void RC2_encrypt(unsigned long *data,RC2_KEY *key); +void RC2_decrypt(unsigned long *data,RC2_KEY *key); +void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + RC2_KEY *ks, unsigned char *iv, int enc); +void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, RC2_KEY *schedule, unsigned char *ivec, + int *num, int enc); +void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, RC2_KEY *schedule, unsigned char *ivec, + int *num); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/rc4.h b/src/dep/include/openssl/rc4.h index c0bede5..c9f2cc8 100644 --- a/src/dep/include/openssl/rc4.h +++ b/src/dep/include/openssl/rc4.h @@ -1,87 +1,87 @@ -/* crypto/rc4/rc4.h */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_RC4_H -#define HEADER_RC4_H - -#include /* OPENSSL_NO_RC4, RC4_INT */ -#ifdef OPENSSL_NO_RC4 -#error RC4 is disabled. -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rc4_key_st - { - RC4_INT x,y; - RC4_INT data[256]; - } RC4_KEY; - - -const char *RC4_options(void); -void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); -void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, - unsigned char *outdata); - -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/rc4/rc4.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RC4_H +#define HEADER_RC4_H + +#include /* OPENSSL_NO_RC4, RC4_INT */ +#ifdef OPENSSL_NO_RC4 +#error RC4 is disabled. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rc4_key_st + { + RC4_INT x,y; + RC4_INT data[256]; + } RC4_KEY; + + +const char *RC4_options(void); +void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); +void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, + unsigned char *outdata); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/ripemd.h b/src/dep/include/openssl/ripemd.h index b4e701e..e922e0c 100644 --- a/src/dep/include/openssl/ripemd.h +++ b/src/dep/include/openssl/ripemd.h @@ -1,103 +1,103 @@ -/* crypto/ripemd/ripemd.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_RIPEMD_H -#define HEADER_RIPEMD_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef OPENSSL_NO_RIPEMD -#error RIPEMD is disabled. -#endif - -#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) -#define RIPEMD160_LONG unsigned long -#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) -#define RIPEMD160_LONG unsigned long -#define RIPEMD160_LONG_LOG2 3 -#else -#define RIPEMD160_LONG unsigned int -#endif - -#define RIPEMD160_CBLOCK 64 -#define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4) -#define RIPEMD160_DIGEST_LENGTH 20 - -typedef struct RIPEMD160state_st - { - RIPEMD160_LONG A,B,C,D,E; - RIPEMD160_LONG Nl,Nh; - RIPEMD160_LONG data[RIPEMD160_LBLOCK]; - unsigned int num; - } RIPEMD160_CTX; - -int RIPEMD160_Init(RIPEMD160_CTX *c); -int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); -int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); -unsigned char *RIPEMD160(const unsigned char *d, size_t n, - unsigned char *md); -void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b); -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/ripemd/ripemd.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RIPEMD_H +#define HEADER_RIPEMD_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_RIPEMD +#error RIPEMD is disabled. +#endif + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define RIPEMD160_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define RIPEMD160_LONG unsigned long +#define RIPEMD160_LONG_LOG2 3 +#else +#define RIPEMD160_LONG unsigned int +#endif + +#define RIPEMD160_CBLOCK 64 +#define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4) +#define RIPEMD160_DIGEST_LENGTH 20 + +typedef struct RIPEMD160state_st + { + RIPEMD160_LONG A,B,C,D,E; + RIPEMD160_LONG Nl,Nh; + RIPEMD160_LONG data[RIPEMD160_LBLOCK]; + unsigned int num; + } RIPEMD160_CTX; + +int RIPEMD160_Init(RIPEMD160_CTX *c); +int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); +int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); +unsigned char *RIPEMD160(const unsigned char *d, size_t n, + unsigned char *md); +void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/rsa.h b/src/dep/include/openssl/rsa.h index 1d179bc..be8320e 100644 --- a/src/dep/include/openssl/rsa.h +++ b/src/dep/include/openssl/rsa.h @@ -1,429 +1,429 @@ -/* crypto/rsa/rsa.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_RSA_H -#define HEADER_RSA_H - -#include - -#ifndef OPENSSL_NO_BIO -#include -#endif -#include -#include -#ifndef OPENSSL_NO_DEPRECATED -#include -#endif - -#ifdef OPENSSL_NO_RSA -#error RSA is disabled. -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Declared already in ossl_typ.h */ -/* typedef struct rsa_st RSA; */ -/* typedef struct rsa_meth_st RSA_METHOD; */ - -struct rsa_meth_st - { - const char *name; - int (*rsa_pub_enc)(int flen,const unsigned char *from, - unsigned char *to, - RSA *rsa,int padding); - int (*rsa_pub_dec)(int flen,const unsigned char *from, - unsigned char *to, - RSA *rsa,int padding); - int (*rsa_priv_enc)(int flen,const unsigned char *from, - unsigned char *to, - RSA *rsa,int padding); - int (*rsa_priv_dec)(int flen,const unsigned char *from, - unsigned char *to, - RSA *rsa,int padding); - int (*rsa_mod_exp)(BIGNUM *r0,const BIGNUM *I,RSA *rsa,BN_CTX *ctx); /* Can be null */ - int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); /* Can be null */ - int (*init)(RSA *rsa); /* called at new */ - int (*finish)(RSA *rsa); /* called at free */ - int flags; /* RSA_METHOD_FLAG_* things */ - char *app_data; /* may be needed! */ -/* New sign and verify functions: some libraries don't allow arbitrary data - * to be signed/verified: this allows them to be used. Note: for this to work - * the RSA_public_decrypt() and RSA_private_encrypt() should *NOT* be used - * RSA_sign(), RSA_verify() should be used instead. Note: for backwards - * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER - * option is set in 'flags'. - */ - int (*rsa_sign)(int type, - const unsigned char *m, unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, const RSA *rsa); - int (*rsa_verify)(int dtype, - const unsigned char *m, unsigned int m_length, - unsigned char *sigbuf, unsigned int siglen, const RSA *rsa); -/* If this callback is NULL, the builtin software RSA key-gen will be used. This - * is for behavioural compatibility whilst the code gets rewired, but one day - * it would be nice to assume there are no such things as "builtin software" - * implementations. */ - int (*rsa_keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); - }; - -struct rsa_st - { - /* The first parameter is used to pickup errors where - * this is passed instead of aEVP_PKEY, it is set to 0 */ - int pad; - long version; - const RSA_METHOD *meth; - /* functional reference if 'meth' is ENGINE-provided */ - ENGINE *engine; - BIGNUM *n; - BIGNUM *e; - BIGNUM *d; - BIGNUM *p; - BIGNUM *q; - BIGNUM *dmp1; - BIGNUM *dmq1; - BIGNUM *iqmp; - /* be careful using this if the RSA structure is shared */ - CRYPTO_EX_DATA ex_data; - int references; - int flags; - - /* Used to cache montgomery values */ - BN_MONT_CTX *_method_mod_n; - BN_MONT_CTX *_method_mod_p; - BN_MONT_CTX *_method_mod_q; - - /* all BIGNUM values are actually in the following data, if it is not - * NULL */ - char *bignum_data; - BN_BLINDING *blinding; - BN_BLINDING *mt_blinding; - }; - -#define RSA_3 0x3L -#define RSA_F4 0x10001L - -#define RSA_METHOD_FLAG_NO_CHECK 0x0001 /* don't check pub/private match */ - -#define RSA_FLAG_CACHE_PUBLIC 0x0002 -#define RSA_FLAG_CACHE_PRIVATE 0x0004 -#define RSA_FLAG_BLINDING 0x0008 -#define RSA_FLAG_THREAD_SAFE 0x0010 -/* This flag means the private key operations will be handled by rsa_mod_exp - * and that they do not depend on the private key components being present: - * for example a key stored in external hardware. Without this flag bn_mod_exp - * gets called when private key components are absent. - */ -#define RSA_FLAG_EXT_PKEY 0x0020 - -/* This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify functions. - */ -#define RSA_FLAG_SIGN_VER 0x0040 - -#define RSA_FLAG_NO_BLINDING 0x0080 /* new with 0.9.6j and 0.9.7b; the built-in - * RSA implementation now uses blinding by - * default (ignoring RSA_FLAG_BLINDING), - * but other engines might not need it - */ -#define RSA_FLAG_NO_EXP_CONSTTIME 0x0100 /* new with 0.9.7h; the built-in RSA - * implementation now uses constant time - * modular exponentiation for secret exponents - * by default. This flag causes the - * faster variable sliding window method to - * be used for all exponents. - */ - -#define RSA_PKCS1_PADDING 1 -#define RSA_SSLV23_PADDING 2 -#define RSA_NO_PADDING 3 -#define RSA_PKCS1_OAEP_PADDING 4 -#define RSA_X931_PADDING 5 - -#define RSA_PKCS1_PADDING_SIZE 11 - -#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg) -#define RSA_get_app_data(s) RSA_get_ex_data(s,0) - -RSA * RSA_new(void); -RSA * RSA_new_method(ENGINE *engine); -int RSA_size(const RSA *); - -/* Deprecated version */ -#ifndef OPENSSL_NO_DEPRECATED -RSA * RSA_generate_key(int bits, unsigned long e,void - (*callback)(int,int,void *),void *cb_arg); -#endif /* !defined(OPENSSL_NO_DEPRECATED) */ - -/* New version */ -int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); - -int RSA_check_key(const RSA *); - /* next 4 return -1 on error */ -int RSA_public_encrypt(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa,int padding); -int RSA_private_encrypt(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa,int padding); -int RSA_public_decrypt(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa,int padding); -int RSA_private_decrypt(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa,int padding); -void RSA_free (RSA *r); -/* "up" the RSA object's reference count */ -int RSA_up_ref(RSA *r); - -int RSA_flags(const RSA *r); - -void RSA_set_default_method(const RSA_METHOD *meth); -const RSA_METHOD *RSA_get_default_method(void); -const RSA_METHOD *RSA_get_method(const RSA *rsa); -int RSA_set_method(RSA *rsa, const RSA_METHOD *meth); - -/* This function needs the memory locking malloc callbacks to be installed */ -int RSA_memory_lock(RSA *r); - -/* these are the actual SSLeay RSA functions */ -const RSA_METHOD *RSA_PKCS1_SSLeay(void); - -const RSA_METHOD *RSA_null_method(void); - -DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey) -DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey) - -#ifndef OPENSSL_NO_FP_API -int RSA_print_fp(FILE *fp, const RSA *r,int offset); -#endif - -#ifndef OPENSSL_NO_BIO -int RSA_print(BIO *bp, const RSA *r,int offset); -#endif - -int i2d_RSA_NET(const RSA *a, unsigned char **pp, - int (*cb)(char *buf, int len, const char *prompt, int verify), - int sgckey); -RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, - int (*cb)(char *buf, int len, const char *prompt, int verify), - int sgckey); - -int i2d_Netscape_RSA(const RSA *a, unsigned char **pp, - int (*cb)(char *buf, int len, const char *prompt, - int verify)); -RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length, - int (*cb)(char *buf, int len, const char *prompt, - int verify)); - -/* The following 2 functions sign and verify a X509_SIG ASN1 object - * inside PKCS#1 padded RSA encryption */ -int RSA_sign(int type, const unsigned char *m, unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, RSA *rsa); -int RSA_verify(int type, const unsigned char *m, unsigned int m_length, - unsigned char *sigbuf, unsigned int siglen, RSA *rsa); - -/* The following 2 function sign and verify a ASN1_OCTET_STRING - * object inside PKCS#1 padded RSA encryption */ -int RSA_sign_ASN1_OCTET_STRING(int type, - const unsigned char *m, unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, RSA *rsa); -int RSA_verify_ASN1_OCTET_STRING(int type, - const unsigned char *m, unsigned int m_length, - unsigned char *sigbuf, unsigned int siglen, RSA *rsa); - -int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); -void RSA_blinding_off(RSA *rsa); -BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx); - -int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen, - const unsigned char *f,int fl); -int RSA_padding_check_PKCS1_type_1(unsigned char *to,int tlen, - const unsigned char *f,int fl,int rsa_len); -int RSA_padding_add_PKCS1_type_2(unsigned char *to,int tlen, - const unsigned char *f,int fl); -int RSA_padding_check_PKCS1_type_2(unsigned char *to,int tlen, - const unsigned char *f,int fl,int rsa_len); -int PKCS1_MGF1(unsigned char *mask, long len, - const unsigned char *seed, long seedlen, const EVP_MD *dgst); -int RSA_padding_add_PKCS1_OAEP(unsigned char *to,int tlen, - const unsigned char *f,int fl, - const unsigned char *p,int pl); -int RSA_padding_check_PKCS1_OAEP(unsigned char *to,int tlen, - const unsigned char *f,int fl,int rsa_len, - const unsigned char *p,int pl); -int RSA_padding_add_SSLv23(unsigned char *to,int tlen, - const unsigned char *f,int fl); -int RSA_padding_check_SSLv23(unsigned char *to,int tlen, - const unsigned char *f,int fl,int rsa_len); -int RSA_padding_add_none(unsigned char *to,int tlen, - const unsigned char *f,int fl); -int RSA_padding_check_none(unsigned char *to,int tlen, - const unsigned char *f,int fl,int rsa_len); -int RSA_padding_add_X931(unsigned char *to,int tlen, - const unsigned char *f,int fl); -int RSA_padding_check_X931(unsigned char *to,int tlen, - const unsigned char *f,int fl,int rsa_len); -int RSA_X931_hash_id(int nid); - -int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, - const EVP_MD *Hash, const unsigned char *EM, int sLen); -int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM, - const unsigned char *mHash, - const EVP_MD *Hash, int sLen); - -int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); -int RSA_set_ex_data(RSA *r,int idx,void *arg); -void *RSA_get_ex_data(const RSA *r, int idx); - -RSA *RSAPublicKey_dup(RSA *rsa); -RSA *RSAPrivateKey_dup(RSA *rsa); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_RSA_strings(void); - -/* Error codes for the RSA functions. */ - -/* Function codes. */ -#define RSA_F_MEMORY_LOCK 100 -#define RSA_F_RSA_BUILTIN_KEYGEN 129 -#define RSA_F_RSA_CHECK_KEY 123 -#define RSA_F_RSA_EAY_PRIVATE_DECRYPT 101 -#define RSA_F_RSA_EAY_PRIVATE_ENCRYPT 102 -#define RSA_F_RSA_EAY_PUBLIC_DECRYPT 103 -#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 104 -#define RSA_F_RSA_GENERATE_KEY 105 -#define RSA_F_RSA_MEMORY_LOCK 130 -#define RSA_F_RSA_NEW_METHOD 106 -#define RSA_F_RSA_NULL 124 -#define RSA_F_RSA_NULL_MOD_EXP 131 -#define RSA_F_RSA_NULL_PRIVATE_DECRYPT 132 -#define RSA_F_RSA_NULL_PRIVATE_ENCRYPT 133 -#define RSA_F_RSA_NULL_PUBLIC_DECRYPT 134 -#define RSA_F_RSA_NULL_PUBLIC_ENCRYPT 135 -#define RSA_F_RSA_PADDING_ADD_NONE 107 -#define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121 -#define RSA_F_RSA_PADDING_ADD_PKCS1_PSS 125 -#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108 -#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 109 -#define RSA_F_RSA_PADDING_ADD_SSLV23 110 -#define RSA_F_RSA_PADDING_ADD_X931 127 -#define RSA_F_RSA_PADDING_CHECK_NONE 111 -#define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP 122 -#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 112 -#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 113 -#define RSA_F_RSA_PADDING_CHECK_SSLV23 114 -#define RSA_F_RSA_PADDING_CHECK_X931 128 -#define RSA_F_RSA_PRINT 115 -#define RSA_F_RSA_PRINT_FP 116 -#define RSA_F_RSA_SETUP_BLINDING 136 -#define RSA_F_RSA_SIGN 117 -#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118 -#define RSA_F_RSA_VERIFY 119 -#define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 120 -#define RSA_F_RSA_VERIFY_PKCS1_PSS 126 - -/* Reason codes. */ -#define RSA_R_ALGORITHM_MISMATCH 100 -#define RSA_R_BAD_E_VALUE 101 -#define RSA_R_BAD_FIXED_HEADER_DECRYPT 102 -#define RSA_R_BAD_PAD_BYTE_COUNT 103 -#define RSA_R_BAD_SIGNATURE 104 -#define RSA_R_BLOCK_TYPE_IS_NOT_01 106 -#define RSA_R_BLOCK_TYPE_IS_NOT_02 107 -#define RSA_R_DATA_GREATER_THAN_MOD_LEN 108 -#define RSA_R_DATA_TOO_LARGE 109 -#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 -#define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 132 -#define RSA_R_DATA_TOO_SMALL 111 -#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122 -#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 -#define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124 -#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125 -#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123 -#define RSA_R_FIRST_OCTET_INVALID 133 -#define RSA_R_INVALID_HEADER 137 -#define RSA_R_INVALID_MESSAGE_LENGTH 131 -#define RSA_R_INVALID_PADDING 138 -#define RSA_R_INVALID_TRAILER 139 -#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126 -#define RSA_R_KEY_SIZE_TOO_SMALL 120 -#define RSA_R_LAST_OCTET_INVALID 134 -#define RSA_R_NO_PUBLIC_EXPONENT 140 -#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 -#define RSA_R_N_DOES_NOT_EQUAL_P_Q 127 -#define RSA_R_OAEP_DECODING_ERROR 121 -#define RSA_R_PADDING_CHECK_FAILED 114 -#define RSA_R_P_NOT_PRIME 128 -#define RSA_R_Q_NOT_PRIME 129 -#define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130 -#define RSA_R_SLEN_CHECK_FAILED 136 -#define RSA_R_SLEN_RECOVERY_FAILED 135 -#define RSA_R_SSLV3_ROLLBACK_ATTACK 115 -#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116 -#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117 -#define RSA_R_UNKNOWN_PADDING_TYPE 118 -#define RSA_R_WRONG_SIGNATURE_LENGTH 119 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/rsa/rsa.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RSA_H +#define HEADER_RSA_H + +#include + +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef OPENSSL_NO_RSA +#error RSA is disabled. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Declared already in ossl_typ.h */ +/* typedef struct rsa_st RSA; */ +/* typedef struct rsa_meth_st RSA_METHOD; */ + +struct rsa_meth_st + { + const char *name; + int (*rsa_pub_enc)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_pub_dec)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_priv_enc)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_priv_dec)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_mod_exp)(BIGNUM *r0,const BIGNUM *I,RSA *rsa,BN_CTX *ctx); /* Can be null */ + int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); /* Can be null */ + int (*init)(RSA *rsa); /* called at new */ + int (*finish)(RSA *rsa); /* called at free */ + int flags; /* RSA_METHOD_FLAG_* things */ + char *app_data; /* may be needed! */ +/* New sign and verify functions: some libraries don't allow arbitrary data + * to be signed/verified: this allows them to be used. Note: for this to work + * the RSA_public_decrypt() and RSA_private_encrypt() should *NOT* be used + * RSA_sign(), RSA_verify() should be used instead. Note: for backwards + * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER + * option is set in 'flags'. + */ + int (*rsa_sign)(int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, const RSA *rsa); + int (*rsa_verify)(int dtype, + const unsigned char *m, unsigned int m_length, + unsigned char *sigbuf, unsigned int siglen, const RSA *rsa); +/* If this callback is NULL, the builtin software RSA key-gen will be used. This + * is for behavioural compatibility whilst the code gets rewired, but one day + * it would be nice to assume there are no such things as "builtin software" + * implementations. */ + int (*rsa_keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); + }; + +struct rsa_st + { + /* The first parameter is used to pickup errors where + * this is passed instead of aEVP_PKEY, it is set to 0 */ + int pad; + long version; + const RSA_METHOD *meth; + /* functional reference if 'meth' is ENGINE-provided */ + ENGINE *engine; + BIGNUM *n; + BIGNUM *e; + BIGNUM *d; + BIGNUM *p; + BIGNUM *q; + BIGNUM *dmp1; + BIGNUM *dmq1; + BIGNUM *iqmp; + /* be careful using this if the RSA structure is shared */ + CRYPTO_EX_DATA ex_data; + int references; + int flags; + + /* Used to cache montgomery values */ + BN_MONT_CTX *_method_mod_n; + BN_MONT_CTX *_method_mod_p; + BN_MONT_CTX *_method_mod_q; + + /* all BIGNUM values are actually in the following data, if it is not + * NULL */ + char *bignum_data; + BN_BLINDING *blinding; + BN_BLINDING *mt_blinding; + }; + +#define RSA_3 0x3L +#define RSA_F4 0x10001L + +#define RSA_METHOD_FLAG_NO_CHECK 0x0001 /* don't check pub/private match */ + +#define RSA_FLAG_CACHE_PUBLIC 0x0002 +#define RSA_FLAG_CACHE_PRIVATE 0x0004 +#define RSA_FLAG_BLINDING 0x0008 +#define RSA_FLAG_THREAD_SAFE 0x0010 +/* This flag means the private key operations will be handled by rsa_mod_exp + * and that they do not depend on the private key components being present: + * for example a key stored in external hardware. Without this flag bn_mod_exp + * gets called when private key components are absent. + */ +#define RSA_FLAG_EXT_PKEY 0x0020 + +/* This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify functions. + */ +#define RSA_FLAG_SIGN_VER 0x0040 + +#define RSA_FLAG_NO_BLINDING 0x0080 /* new with 0.9.6j and 0.9.7b; the built-in + * RSA implementation now uses blinding by + * default (ignoring RSA_FLAG_BLINDING), + * but other engines might not need it + */ +#define RSA_FLAG_NO_EXP_CONSTTIME 0x0100 /* new with 0.9.7h; the built-in RSA + * implementation now uses constant time + * modular exponentiation for secret exponents + * by default. This flag causes the + * faster variable sliding window method to + * be used for all exponents. + */ + +#define RSA_PKCS1_PADDING 1 +#define RSA_SSLV23_PADDING 2 +#define RSA_NO_PADDING 3 +#define RSA_PKCS1_OAEP_PADDING 4 +#define RSA_X931_PADDING 5 + +#define RSA_PKCS1_PADDING_SIZE 11 + +#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg) +#define RSA_get_app_data(s) RSA_get_ex_data(s,0) + +RSA * RSA_new(void); +RSA * RSA_new_method(ENGINE *engine); +int RSA_size(const RSA *); + +/* Deprecated version */ +#ifndef OPENSSL_NO_DEPRECATED +RSA * RSA_generate_key(int bits, unsigned long e,void + (*callback)(int,int,void *),void *cb_arg); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* New version */ +int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); + +int RSA_check_key(const RSA *); + /* next 4 return -1 on error */ +int RSA_public_encrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +int RSA_private_encrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +int RSA_public_decrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +int RSA_private_decrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +void RSA_free (RSA *r); +/* "up" the RSA object's reference count */ +int RSA_up_ref(RSA *r); + +int RSA_flags(const RSA *r); + +void RSA_set_default_method(const RSA_METHOD *meth); +const RSA_METHOD *RSA_get_default_method(void); +const RSA_METHOD *RSA_get_method(const RSA *rsa); +int RSA_set_method(RSA *rsa, const RSA_METHOD *meth); + +/* This function needs the memory locking malloc callbacks to be installed */ +int RSA_memory_lock(RSA *r); + +/* these are the actual SSLeay RSA functions */ +const RSA_METHOD *RSA_PKCS1_SSLeay(void); + +const RSA_METHOD *RSA_null_method(void); + +DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey) +DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey) + +#ifndef OPENSSL_NO_FP_API +int RSA_print_fp(FILE *fp, const RSA *r,int offset); +#endif + +#ifndef OPENSSL_NO_BIO +int RSA_print(BIO *bp, const RSA *r,int offset); +#endif + +int i2d_RSA_NET(const RSA *a, unsigned char **pp, + int (*cb)(char *buf, int len, const char *prompt, int verify), + int sgckey); +RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, + int (*cb)(char *buf, int len, const char *prompt, int verify), + int sgckey); + +int i2d_Netscape_RSA(const RSA *a, unsigned char **pp, + int (*cb)(char *buf, int len, const char *prompt, + int verify)); +RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length, + int (*cb)(char *buf, int len, const char *prompt, + int verify)); + +/* The following 2 functions sign and verify a X509_SIG ASN1 object + * inside PKCS#1 padded RSA encryption */ +int RSA_sign(int type, const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, RSA *rsa); +int RSA_verify(int type, const unsigned char *m, unsigned int m_length, + unsigned char *sigbuf, unsigned int siglen, RSA *rsa); + +/* The following 2 function sign and verify a ASN1_OCTET_STRING + * object inside PKCS#1 padded RSA encryption */ +int RSA_sign_ASN1_OCTET_STRING(int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, RSA *rsa); +int RSA_verify_ASN1_OCTET_STRING(int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigbuf, unsigned int siglen, RSA *rsa); + +int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); +void RSA_blinding_off(RSA *rsa); +BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx); + +int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_PKCS1_type_1(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_padding_add_PKCS1_type_2(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_PKCS1_type_2(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int PKCS1_MGF1(unsigned char *mask, long len, + const unsigned char *seed, long seedlen, const EVP_MD *dgst); +int RSA_padding_add_PKCS1_OAEP(unsigned char *to,int tlen, + const unsigned char *f,int fl, + const unsigned char *p,int pl); +int RSA_padding_check_PKCS1_OAEP(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len, + const unsigned char *p,int pl); +int RSA_padding_add_SSLv23(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_SSLv23(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_padding_add_none(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_none(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_padding_add_X931(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_X931(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_X931_hash_id(int nid); + +int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, + const EVP_MD *Hash, const unsigned char *EM, int sLen); +int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM, + const unsigned char *mHash, + const EVP_MD *Hash, int sLen); + +int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int RSA_set_ex_data(RSA *r,int idx,void *arg); +void *RSA_get_ex_data(const RSA *r, int idx); + +RSA *RSAPublicKey_dup(RSA *rsa); +RSA *RSAPrivateKey_dup(RSA *rsa); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_RSA_strings(void); + +/* Error codes for the RSA functions. */ + +/* Function codes. */ +#define RSA_F_MEMORY_LOCK 100 +#define RSA_F_RSA_BUILTIN_KEYGEN 129 +#define RSA_F_RSA_CHECK_KEY 123 +#define RSA_F_RSA_EAY_PRIVATE_DECRYPT 101 +#define RSA_F_RSA_EAY_PRIVATE_ENCRYPT 102 +#define RSA_F_RSA_EAY_PUBLIC_DECRYPT 103 +#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 104 +#define RSA_F_RSA_GENERATE_KEY 105 +#define RSA_F_RSA_MEMORY_LOCK 130 +#define RSA_F_RSA_NEW_METHOD 106 +#define RSA_F_RSA_NULL 124 +#define RSA_F_RSA_NULL_MOD_EXP 131 +#define RSA_F_RSA_NULL_PRIVATE_DECRYPT 132 +#define RSA_F_RSA_NULL_PRIVATE_ENCRYPT 133 +#define RSA_F_RSA_NULL_PUBLIC_DECRYPT 134 +#define RSA_F_RSA_NULL_PUBLIC_ENCRYPT 135 +#define RSA_F_RSA_PADDING_ADD_NONE 107 +#define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121 +#define RSA_F_RSA_PADDING_ADD_PKCS1_PSS 125 +#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108 +#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 109 +#define RSA_F_RSA_PADDING_ADD_SSLV23 110 +#define RSA_F_RSA_PADDING_ADD_X931 127 +#define RSA_F_RSA_PADDING_CHECK_NONE 111 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP 122 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 112 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 113 +#define RSA_F_RSA_PADDING_CHECK_SSLV23 114 +#define RSA_F_RSA_PADDING_CHECK_X931 128 +#define RSA_F_RSA_PRINT 115 +#define RSA_F_RSA_PRINT_FP 116 +#define RSA_F_RSA_SETUP_BLINDING 136 +#define RSA_F_RSA_SIGN 117 +#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118 +#define RSA_F_RSA_VERIFY 119 +#define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 120 +#define RSA_F_RSA_VERIFY_PKCS1_PSS 126 + +/* Reason codes. */ +#define RSA_R_ALGORITHM_MISMATCH 100 +#define RSA_R_BAD_E_VALUE 101 +#define RSA_R_BAD_FIXED_HEADER_DECRYPT 102 +#define RSA_R_BAD_PAD_BYTE_COUNT 103 +#define RSA_R_BAD_SIGNATURE 104 +#define RSA_R_BLOCK_TYPE_IS_NOT_01 106 +#define RSA_R_BLOCK_TYPE_IS_NOT_02 107 +#define RSA_R_DATA_GREATER_THAN_MOD_LEN 108 +#define RSA_R_DATA_TOO_LARGE 109 +#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 +#define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 132 +#define RSA_R_DATA_TOO_SMALL 111 +#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122 +#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 +#define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124 +#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125 +#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123 +#define RSA_R_FIRST_OCTET_INVALID 133 +#define RSA_R_INVALID_HEADER 137 +#define RSA_R_INVALID_MESSAGE_LENGTH 131 +#define RSA_R_INVALID_PADDING 138 +#define RSA_R_INVALID_TRAILER 139 +#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126 +#define RSA_R_KEY_SIZE_TOO_SMALL 120 +#define RSA_R_LAST_OCTET_INVALID 134 +#define RSA_R_NO_PUBLIC_EXPONENT 140 +#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 +#define RSA_R_N_DOES_NOT_EQUAL_P_Q 127 +#define RSA_R_OAEP_DECODING_ERROR 121 +#define RSA_R_PADDING_CHECK_FAILED 114 +#define RSA_R_P_NOT_PRIME 128 +#define RSA_R_Q_NOT_PRIME 129 +#define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130 +#define RSA_R_SLEN_CHECK_FAILED 136 +#define RSA_R_SLEN_RECOVERY_FAILED 135 +#define RSA_R_SSLV3_ROLLBACK_ATTACK 115 +#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116 +#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117 +#define RSA_R_UNKNOWN_PADDING_TYPE 118 +#define RSA_R_WRONG_SIGNATURE_LENGTH 119 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/safestack.h b/src/dep/include/openssl/safestack.h index 8c69fd5..800e073 100644 --- a/src/dep/include/openssl/safestack.h +++ b/src/dep/include/openssl/safestack.h @@ -1,1784 +1,1784 @@ -/* ==================================================================== - * Copyright (c) 1999 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_SAFESTACK_H -#define HEADER_SAFESTACK_H - -#include - -typedef void (*openssl_fptr)(void); -#define openssl_fcast(f) ((openssl_fptr)f) - -#ifdef DEBUG_SAFESTACK - -#define STACK_OF(type) struct stack_st_##type -#define PREDECLARE_STACK_OF(type) STACK_OF(type); - -#define DECLARE_STACK_OF(type) \ -STACK_OF(type) \ - { \ - STACK stack; \ - }; - -#define IMPLEMENT_STACK_OF(type) /* nada (obsolete in new safestack approach)*/ - -/* SKM_sk_... stack macros are internal to safestack.h: - * never use them directly, use sk__... instead */ -#define SKM_sk_new(type, cmp) \ - ((STACK_OF(type) * (*)(int (*)(const type * const *, const type * const *)))openssl_fcast(sk_new))(cmp) -#define SKM_sk_new_null(type) \ - ((STACK_OF(type) * (*)(void))openssl_fcast(sk_new_null))() -#define SKM_sk_free(type, st) \ - ((void (*)(STACK_OF(type) *))openssl_fcast(sk_free))(st) -#define SKM_sk_num(type, st) \ - ((int (*)(const STACK_OF(type) *))openssl_fcast(sk_num))(st) -#define SKM_sk_value(type, st,i) \ - ((type * (*)(const STACK_OF(type) *, int))openssl_fcast(sk_value))(st, i) -#define SKM_sk_set(type, st,i,val) \ - ((type * (*)(STACK_OF(type) *, int, type *))openssl_fcast(sk_set))(st, i, val) -#define SKM_sk_zero(type, st) \ - ((void (*)(STACK_OF(type) *))openssl_fcast(sk_zero))(st) -#define SKM_sk_push(type, st,val) \ - ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_push))(st, val) -#define SKM_sk_unshift(type, st,val) \ - ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_unshift))(st, val) -#define SKM_sk_find(type, st,val) \ - ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_find))(st, val) -#define SKM_sk_delete(type, st,i) \ - ((type * (*)(STACK_OF(type) *, int))openssl_fcast(sk_delete))(st, i) -#define SKM_sk_delete_ptr(type, st,ptr) \ - ((type * (*)(STACK_OF(type) *, type *))openssl_fcast(sk_delete_ptr))(st, ptr) -#define SKM_sk_insert(type, st,val,i) \ - ((int (*)(STACK_OF(type) *, type *, int))openssl_fcast(sk_insert))(st, val, i) -#define SKM_sk_set_cmp_func(type, st,cmp) \ - ((int (*(*)(STACK_OF(type) *, int (*)(const type * const *, const type * const *))) \ - (const type * const *, const type * const *))openssl_fcast(sk_set_cmp_func))\ - (st, cmp) -#define SKM_sk_dup(type, st) \ - ((STACK_OF(type) *(*)(STACK_OF(type) *))openssl_fcast(sk_dup))(st) -#define SKM_sk_pop_free(type, st,free_func) \ - ((void (*)(STACK_OF(type) *, void (*)(type *)))openssl_fcast(sk_pop_free))\ - (st, free_func) -#define SKM_sk_shift(type, st) \ - ((type * (*)(STACK_OF(type) *))openssl_fcast(sk_shift))(st) -#define SKM_sk_pop(type, st) \ - ((type * (*)(STACK_OF(type) *))openssl_fcast(sk_pop))(st) -#define SKM_sk_sort(type, st) \ - ((void (*)(STACK_OF(type) *))openssl_fcast(sk_sort))(st) -#define SKM_sk_is_sorted(type, st) \ - ((int (*)(const STACK_OF(type) *))openssl_fcast(sk_is_sorted))(st) - -#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ -((STACK_OF(type) * (*) (STACK_OF(type) **,const unsigned char **, long , \ - type *(*)(type **, const unsigned char **,long), \ - void (*)(type *), int ,int )) openssl_fcast(d2i_ASN1_SET)) \ - (st,pp,length, d2i_func, free_func, ex_tag,ex_class) -#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \ - ((int (*)(STACK_OF(type) *,unsigned char **, \ - int (*)(type *,unsigned char **), int , int , int)) openssl_fcast(i2d_ASN1_SET)) \ - (st,pp,i2d_func,ex_tag,ex_class,is_set) - -#define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \ - ((unsigned char *(*)(STACK_OF(type) *, \ - int (*)(type *,unsigned char **), unsigned char **,int *)) openssl_fcast(ASN1_seq_pack)) \ - (st, i2d_func, buf, len) -#define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \ - ((STACK_OF(type) * (*)(const unsigned char *,int, \ - type *(*)(type **,const unsigned char **, long), \ - void (*)(type *)))openssl_fcast(ASN1_seq_unpack)) \ - (buf,len,d2i_func, free_func) - -#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \ - ((STACK_OF(type) * (*)(X509_ALGOR *, \ - type *(*)(type **, const unsigned char **, long), \ - void (*)(type *), \ - const char *, int, \ - ASN1_STRING *, int))PKCS12_decrypt_d2i) \ - (algor,d2i_func,free_func,pass,passlen,oct,seq) - -#else - -#define STACK_OF(type) STACK -#define PREDECLARE_STACK_OF(type) /* nada */ -#define DECLARE_STACK_OF(type) /* nada */ -#define IMPLEMENT_STACK_OF(type) /* nada */ - -#define SKM_sk_new(type, cmp) \ - sk_new((int (*)(const char * const *, const char * const *))(cmp)) -#define SKM_sk_new_null(type) \ - sk_new_null() -#define SKM_sk_free(type, st) \ - sk_free(st) -#define SKM_sk_num(type, st) \ - sk_num(st) -#define SKM_sk_value(type, st,i) \ - ((type *)sk_value(st, i)) -#define SKM_sk_set(type, st,i,val) \ - ((type *)sk_set(st, i,(char *)val)) -#define SKM_sk_zero(type, st) \ - sk_zero(st) -#define SKM_sk_push(type, st,val) \ - sk_push(st, (char *)val) -#define SKM_sk_unshift(type, st,val) \ - sk_unshift(st, val) -#define SKM_sk_find(type, st,val) \ - sk_find(st, (char *)val) -#define SKM_sk_delete(type, st,i) \ - ((type *)sk_delete(st, i)) -#define SKM_sk_delete_ptr(type, st,ptr) \ - ((type *)sk_delete_ptr(st,(char *)ptr)) -#define SKM_sk_insert(type, st,val,i) \ - sk_insert(st, (char *)val, i) -#define SKM_sk_set_cmp_func(type, st,cmp) \ - ((int (*)(const type * const *,const type * const *)) \ - sk_set_cmp_func(st, (int (*)(const char * const *, const char * const *))(cmp))) -#define SKM_sk_dup(type, st) \ - sk_dup(st) -#define SKM_sk_pop_free(type, st,free_func) \ - sk_pop_free(st, (void (*)(void *))free_func) -#define SKM_sk_shift(type, st) \ - ((type *)sk_shift(st)) -#define SKM_sk_pop(type, st) \ - ((type *)sk_pop(st)) -#define SKM_sk_sort(type, st) \ - sk_sort(st) -#define SKM_sk_is_sorted(type, st) \ - sk_is_sorted(st) - -#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - d2i_ASN1_SET(st,pp,length, (void *(*)(void ** ,const unsigned char ** ,long))d2i_func, (void (*)(void *))free_func, ex_tag,ex_class) -#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \ - i2d_ASN1_SET(st,pp,(int (*)(void *, unsigned char **))i2d_func,ex_tag,ex_class,is_set) - -#define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \ - ASN1_seq_pack(st, (int (*)(void *, unsigned char **))i2d_func, buf, len) -#define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \ - ASN1_seq_unpack(buf,len,(void *(*)(void **,const unsigned char **,long))d2i_func, (void(*)(void *))free_func) - -#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \ - ((STACK *)PKCS12_decrypt_d2i(algor,(char *(*)())d2i_func, (void(*)(void *))free_func,pass,passlen,oct,seq)) - -#endif - -/* This block of defines is updated by util/mkstack.pl, please do not touch! */ -#define sk_ACCESS_DESCRIPTION_new(st) SKM_sk_new(ACCESS_DESCRIPTION, (st)) -#define sk_ACCESS_DESCRIPTION_new_null() SKM_sk_new_null(ACCESS_DESCRIPTION) -#define sk_ACCESS_DESCRIPTION_free(st) SKM_sk_free(ACCESS_DESCRIPTION, (st)) -#define sk_ACCESS_DESCRIPTION_num(st) SKM_sk_num(ACCESS_DESCRIPTION, (st)) -#define sk_ACCESS_DESCRIPTION_value(st, i) SKM_sk_value(ACCESS_DESCRIPTION, (st), (i)) -#define sk_ACCESS_DESCRIPTION_set(st, i, val) SKM_sk_set(ACCESS_DESCRIPTION, (st), (i), (val)) -#define sk_ACCESS_DESCRIPTION_zero(st) SKM_sk_zero(ACCESS_DESCRIPTION, (st)) -#define sk_ACCESS_DESCRIPTION_push(st, val) SKM_sk_push(ACCESS_DESCRIPTION, (st), (val)) -#define sk_ACCESS_DESCRIPTION_unshift(st, val) SKM_sk_unshift(ACCESS_DESCRIPTION, (st), (val)) -#define sk_ACCESS_DESCRIPTION_find(st, val) SKM_sk_find(ACCESS_DESCRIPTION, (st), (val)) -#define sk_ACCESS_DESCRIPTION_find_ex(st, val) SKM_sk_find_ex(ACCESS_DESCRIPTION, (st), (val)) -#define sk_ACCESS_DESCRIPTION_delete(st, i) SKM_sk_delete(ACCESS_DESCRIPTION, (st), (i)) -#define sk_ACCESS_DESCRIPTION_delete_ptr(st, ptr) SKM_sk_delete_ptr(ACCESS_DESCRIPTION, (st), (ptr)) -#define sk_ACCESS_DESCRIPTION_insert(st, val, i) SKM_sk_insert(ACCESS_DESCRIPTION, (st), (val), (i)) -#define sk_ACCESS_DESCRIPTION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ACCESS_DESCRIPTION, (st), (cmp)) -#define sk_ACCESS_DESCRIPTION_dup(st) SKM_sk_dup(ACCESS_DESCRIPTION, st) -#define sk_ACCESS_DESCRIPTION_pop_free(st, free_func) SKM_sk_pop_free(ACCESS_DESCRIPTION, (st), (free_func)) -#define sk_ACCESS_DESCRIPTION_shift(st) SKM_sk_shift(ACCESS_DESCRIPTION, (st)) -#define sk_ACCESS_DESCRIPTION_pop(st) SKM_sk_pop(ACCESS_DESCRIPTION, (st)) -#define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st)) -#define sk_ACCESS_DESCRIPTION_is_sorted(st) SKM_sk_is_sorted(ACCESS_DESCRIPTION, (st)) - -#define sk_ASN1_GENERALSTRING_new(st) SKM_sk_new(ASN1_GENERALSTRING, (st)) -#define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING) -#define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st)) -#define sk_ASN1_GENERALSTRING_num(st) SKM_sk_num(ASN1_GENERALSTRING, (st)) -#define sk_ASN1_GENERALSTRING_value(st, i) SKM_sk_value(ASN1_GENERALSTRING, (st), (i)) -#define sk_ASN1_GENERALSTRING_set(st, i, val) SKM_sk_set(ASN1_GENERALSTRING, (st), (i), (val)) -#define sk_ASN1_GENERALSTRING_zero(st) SKM_sk_zero(ASN1_GENERALSTRING, (st)) -#define sk_ASN1_GENERALSTRING_push(st, val) SKM_sk_push(ASN1_GENERALSTRING, (st), (val)) -#define sk_ASN1_GENERALSTRING_unshift(st, val) SKM_sk_unshift(ASN1_GENERALSTRING, (st), (val)) -#define sk_ASN1_GENERALSTRING_find(st, val) SKM_sk_find(ASN1_GENERALSTRING, (st), (val)) -#define sk_ASN1_GENERALSTRING_find_ex(st, val) SKM_sk_find_ex(ASN1_GENERALSTRING, (st), (val)) -#define sk_ASN1_GENERALSTRING_delete(st, i) SKM_sk_delete(ASN1_GENERALSTRING, (st), (i)) -#define sk_ASN1_GENERALSTRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_GENERALSTRING, (st), (ptr)) -#define sk_ASN1_GENERALSTRING_insert(st, val, i) SKM_sk_insert(ASN1_GENERALSTRING, (st), (val), (i)) -#define sk_ASN1_GENERALSTRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_GENERALSTRING, (st), (cmp)) -#define sk_ASN1_GENERALSTRING_dup(st) SKM_sk_dup(ASN1_GENERALSTRING, st) -#define sk_ASN1_GENERALSTRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_GENERALSTRING, (st), (free_func)) -#define sk_ASN1_GENERALSTRING_shift(st) SKM_sk_shift(ASN1_GENERALSTRING, (st)) -#define sk_ASN1_GENERALSTRING_pop(st) SKM_sk_pop(ASN1_GENERALSTRING, (st)) -#define sk_ASN1_GENERALSTRING_sort(st) SKM_sk_sort(ASN1_GENERALSTRING, (st)) -#define sk_ASN1_GENERALSTRING_is_sorted(st) SKM_sk_is_sorted(ASN1_GENERALSTRING, (st)) - -#define sk_ASN1_INTEGER_new(st) SKM_sk_new(ASN1_INTEGER, (st)) -#define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER) -#define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st)) -#define sk_ASN1_INTEGER_num(st) SKM_sk_num(ASN1_INTEGER, (st)) -#define sk_ASN1_INTEGER_value(st, i) SKM_sk_value(ASN1_INTEGER, (st), (i)) -#define sk_ASN1_INTEGER_set(st, i, val) SKM_sk_set(ASN1_INTEGER, (st), (i), (val)) -#define sk_ASN1_INTEGER_zero(st) SKM_sk_zero(ASN1_INTEGER, (st)) -#define sk_ASN1_INTEGER_push(st, val) SKM_sk_push(ASN1_INTEGER, (st), (val)) -#define sk_ASN1_INTEGER_unshift(st, val) SKM_sk_unshift(ASN1_INTEGER, (st), (val)) -#define sk_ASN1_INTEGER_find(st, val) SKM_sk_find(ASN1_INTEGER, (st), (val)) -#define sk_ASN1_INTEGER_find_ex(st, val) SKM_sk_find_ex(ASN1_INTEGER, (st), (val)) -#define sk_ASN1_INTEGER_delete(st, i) SKM_sk_delete(ASN1_INTEGER, (st), (i)) -#define sk_ASN1_INTEGER_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_INTEGER, (st), (ptr)) -#define sk_ASN1_INTEGER_insert(st, val, i) SKM_sk_insert(ASN1_INTEGER, (st), (val), (i)) -#define sk_ASN1_INTEGER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_INTEGER, (st), (cmp)) -#define sk_ASN1_INTEGER_dup(st) SKM_sk_dup(ASN1_INTEGER, st) -#define sk_ASN1_INTEGER_pop_free(st, free_func) SKM_sk_pop_free(ASN1_INTEGER, (st), (free_func)) -#define sk_ASN1_INTEGER_shift(st) SKM_sk_shift(ASN1_INTEGER, (st)) -#define sk_ASN1_INTEGER_pop(st) SKM_sk_pop(ASN1_INTEGER, (st)) -#define sk_ASN1_INTEGER_sort(st) SKM_sk_sort(ASN1_INTEGER, (st)) -#define sk_ASN1_INTEGER_is_sorted(st) SKM_sk_is_sorted(ASN1_INTEGER, (st)) - -#define sk_ASN1_OBJECT_new(st) SKM_sk_new(ASN1_OBJECT, (st)) -#define sk_ASN1_OBJECT_new_null() SKM_sk_new_null(ASN1_OBJECT) -#define sk_ASN1_OBJECT_free(st) SKM_sk_free(ASN1_OBJECT, (st)) -#define sk_ASN1_OBJECT_num(st) SKM_sk_num(ASN1_OBJECT, (st)) -#define sk_ASN1_OBJECT_value(st, i) SKM_sk_value(ASN1_OBJECT, (st), (i)) -#define sk_ASN1_OBJECT_set(st, i, val) SKM_sk_set(ASN1_OBJECT, (st), (i), (val)) -#define sk_ASN1_OBJECT_zero(st) SKM_sk_zero(ASN1_OBJECT, (st)) -#define sk_ASN1_OBJECT_push(st, val) SKM_sk_push(ASN1_OBJECT, (st), (val)) -#define sk_ASN1_OBJECT_unshift(st, val) SKM_sk_unshift(ASN1_OBJECT, (st), (val)) -#define sk_ASN1_OBJECT_find(st, val) SKM_sk_find(ASN1_OBJECT, (st), (val)) -#define sk_ASN1_OBJECT_find_ex(st, val) SKM_sk_find_ex(ASN1_OBJECT, (st), (val)) -#define sk_ASN1_OBJECT_delete(st, i) SKM_sk_delete(ASN1_OBJECT, (st), (i)) -#define sk_ASN1_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_OBJECT, (st), (ptr)) -#define sk_ASN1_OBJECT_insert(st, val, i) SKM_sk_insert(ASN1_OBJECT, (st), (val), (i)) -#define sk_ASN1_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_OBJECT, (st), (cmp)) -#define sk_ASN1_OBJECT_dup(st) SKM_sk_dup(ASN1_OBJECT, st) -#define sk_ASN1_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(ASN1_OBJECT, (st), (free_func)) -#define sk_ASN1_OBJECT_shift(st) SKM_sk_shift(ASN1_OBJECT, (st)) -#define sk_ASN1_OBJECT_pop(st) SKM_sk_pop(ASN1_OBJECT, (st)) -#define sk_ASN1_OBJECT_sort(st) SKM_sk_sort(ASN1_OBJECT, (st)) -#define sk_ASN1_OBJECT_is_sorted(st) SKM_sk_is_sorted(ASN1_OBJECT, (st)) - -#define sk_ASN1_STRING_TABLE_new(st) SKM_sk_new(ASN1_STRING_TABLE, (st)) -#define sk_ASN1_STRING_TABLE_new_null() SKM_sk_new_null(ASN1_STRING_TABLE) -#define sk_ASN1_STRING_TABLE_free(st) SKM_sk_free(ASN1_STRING_TABLE, (st)) -#define sk_ASN1_STRING_TABLE_num(st) SKM_sk_num(ASN1_STRING_TABLE, (st)) -#define sk_ASN1_STRING_TABLE_value(st, i) SKM_sk_value(ASN1_STRING_TABLE, (st), (i)) -#define sk_ASN1_STRING_TABLE_set(st, i, val) SKM_sk_set(ASN1_STRING_TABLE, (st), (i), (val)) -#define sk_ASN1_STRING_TABLE_zero(st) SKM_sk_zero(ASN1_STRING_TABLE, (st)) -#define sk_ASN1_STRING_TABLE_push(st, val) SKM_sk_push(ASN1_STRING_TABLE, (st), (val)) -#define sk_ASN1_STRING_TABLE_unshift(st, val) SKM_sk_unshift(ASN1_STRING_TABLE, (st), (val)) -#define sk_ASN1_STRING_TABLE_find(st, val) SKM_sk_find(ASN1_STRING_TABLE, (st), (val)) -#define sk_ASN1_STRING_TABLE_find_ex(st, val) SKM_sk_find_ex(ASN1_STRING_TABLE, (st), (val)) -#define sk_ASN1_STRING_TABLE_delete(st, i) SKM_sk_delete(ASN1_STRING_TABLE, (st), (i)) -#define sk_ASN1_STRING_TABLE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_STRING_TABLE, (st), (ptr)) -#define sk_ASN1_STRING_TABLE_insert(st, val, i) SKM_sk_insert(ASN1_STRING_TABLE, (st), (val), (i)) -#define sk_ASN1_STRING_TABLE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_STRING_TABLE, (st), (cmp)) -#define sk_ASN1_STRING_TABLE_dup(st) SKM_sk_dup(ASN1_STRING_TABLE, st) -#define sk_ASN1_STRING_TABLE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_STRING_TABLE, (st), (free_func)) -#define sk_ASN1_STRING_TABLE_shift(st) SKM_sk_shift(ASN1_STRING_TABLE, (st)) -#define sk_ASN1_STRING_TABLE_pop(st) SKM_sk_pop(ASN1_STRING_TABLE, (st)) -#define sk_ASN1_STRING_TABLE_sort(st) SKM_sk_sort(ASN1_STRING_TABLE, (st)) -#define sk_ASN1_STRING_TABLE_is_sorted(st) SKM_sk_is_sorted(ASN1_STRING_TABLE, (st)) - -#define sk_ASN1_TYPE_new(st) SKM_sk_new(ASN1_TYPE, (st)) -#define sk_ASN1_TYPE_new_null() SKM_sk_new_null(ASN1_TYPE) -#define sk_ASN1_TYPE_free(st) SKM_sk_free(ASN1_TYPE, (st)) -#define sk_ASN1_TYPE_num(st) SKM_sk_num(ASN1_TYPE, (st)) -#define sk_ASN1_TYPE_value(st, i) SKM_sk_value(ASN1_TYPE, (st), (i)) -#define sk_ASN1_TYPE_set(st, i, val) SKM_sk_set(ASN1_TYPE, (st), (i), (val)) -#define sk_ASN1_TYPE_zero(st) SKM_sk_zero(ASN1_TYPE, (st)) -#define sk_ASN1_TYPE_push(st, val) SKM_sk_push(ASN1_TYPE, (st), (val)) -#define sk_ASN1_TYPE_unshift(st, val) SKM_sk_unshift(ASN1_TYPE, (st), (val)) -#define sk_ASN1_TYPE_find(st, val) SKM_sk_find(ASN1_TYPE, (st), (val)) -#define sk_ASN1_TYPE_find_ex(st, val) SKM_sk_find_ex(ASN1_TYPE, (st), (val)) -#define sk_ASN1_TYPE_delete(st, i) SKM_sk_delete(ASN1_TYPE, (st), (i)) -#define sk_ASN1_TYPE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_TYPE, (st), (ptr)) -#define sk_ASN1_TYPE_insert(st, val, i) SKM_sk_insert(ASN1_TYPE, (st), (val), (i)) -#define sk_ASN1_TYPE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_TYPE, (st), (cmp)) -#define sk_ASN1_TYPE_dup(st) SKM_sk_dup(ASN1_TYPE, st) -#define sk_ASN1_TYPE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_TYPE, (st), (free_func)) -#define sk_ASN1_TYPE_shift(st) SKM_sk_shift(ASN1_TYPE, (st)) -#define sk_ASN1_TYPE_pop(st) SKM_sk_pop(ASN1_TYPE, (st)) -#define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st)) -#define sk_ASN1_TYPE_is_sorted(st) SKM_sk_is_sorted(ASN1_TYPE, (st)) - -#define sk_ASN1_VALUE_new(st) SKM_sk_new(ASN1_VALUE, (st)) -#define sk_ASN1_VALUE_new_null() SKM_sk_new_null(ASN1_VALUE) -#define sk_ASN1_VALUE_free(st) SKM_sk_free(ASN1_VALUE, (st)) -#define sk_ASN1_VALUE_num(st) SKM_sk_num(ASN1_VALUE, (st)) -#define sk_ASN1_VALUE_value(st, i) SKM_sk_value(ASN1_VALUE, (st), (i)) -#define sk_ASN1_VALUE_set(st, i, val) SKM_sk_set(ASN1_VALUE, (st), (i), (val)) -#define sk_ASN1_VALUE_zero(st) SKM_sk_zero(ASN1_VALUE, (st)) -#define sk_ASN1_VALUE_push(st, val) SKM_sk_push(ASN1_VALUE, (st), (val)) -#define sk_ASN1_VALUE_unshift(st, val) SKM_sk_unshift(ASN1_VALUE, (st), (val)) -#define sk_ASN1_VALUE_find(st, val) SKM_sk_find(ASN1_VALUE, (st), (val)) -#define sk_ASN1_VALUE_find_ex(st, val) SKM_sk_find_ex(ASN1_VALUE, (st), (val)) -#define sk_ASN1_VALUE_delete(st, i) SKM_sk_delete(ASN1_VALUE, (st), (i)) -#define sk_ASN1_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_VALUE, (st), (ptr)) -#define sk_ASN1_VALUE_insert(st, val, i) SKM_sk_insert(ASN1_VALUE, (st), (val), (i)) -#define sk_ASN1_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_VALUE, (st), (cmp)) -#define sk_ASN1_VALUE_dup(st) SKM_sk_dup(ASN1_VALUE, st) -#define sk_ASN1_VALUE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_VALUE, (st), (free_func)) -#define sk_ASN1_VALUE_shift(st) SKM_sk_shift(ASN1_VALUE, (st)) -#define sk_ASN1_VALUE_pop(st) SKM_sk_pop(ASN1_VALUE, (st)) -#define sk_ASN1_VALUE_sort(st) SKM_sk_sort(ASN1_VALUE, (st)) -#define sk_ASN1_VALUE_is_sorted(st) SKM_sk_is_sorted(ASN1_VALUE, (st)) - -#define sk_BIO_new(st) SKM_sk_new(BIO, (st)) -#define sk_BIO_new_null() SKM_sk_new_null(BIO) -#define sk_BIO_free(st) SKM_sk_free(BIO, (st)) -#define sk_BIO_num(st) SKM_sk_num(BIO, (st)) -#define sk_BIO_value(st, i) SKM_sk_value(BIO, (st), (i)) -#define sk_BIO_set(st, i, val) SKM_sk_set(BIO, (st), (i), (val)) -#define sk_BIO_zero(st) SKM_sk_zero(BIO, (st)) -#define sk_BIO_push(st, val) SKM_sk_push(BIO, (st), (val)) -#define sk_BIO_unshift(st, val) SKM_sk_unshift(BIO, (st), (val)) -#define sk_BIO_find(st, val) SKM_sk_find(BIO, (st), (val)) -#define sk_BIO_find_ex(st, val) SKM_sk_find_ex(BIO, (st), (val)) -#define sk_BIO_delete(st, i) SKM_sk_delete(BIO, (st), (i)) -#define sk_BIO_delete_ptr(st, ptr) SKM_sk_delete_ptr(BIO, (st), (ptr)) -#define sk_BIO_insert(st, val, i) SKM_sk_insert(BIO, (st), (val), (i)) -#define sk_BIO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BIO, (st), (cmp)) -#define sk_BIO_dup(st) SKM_sk_dup(BIO, st) -#define sk_BIO_pop_free(st, free_func) SKM_sk_pop_free(BIO, (st), (free_func)) -#define sk_BIO_shift(st) SKM_sk_shift(BIO, (st)) -#define sk_BIO_pop(st) SKM_sk_pop(BIO, (st)) -#define sk_BIO_sort(st) SKM_sk_sort(BIO, (st)) -#define sk_BIO_is_sorted(st) SKM_sk_is_sorted(BIO, (st)) - -#define sk_CONF_IMODULE_new(st) SKM_sk_new(CONF_IMODULE, (st)) -#define sk_CONF_IMODULE_new_null() SKM_sk_new_null(CONF_IMODULE) -#define sk_CONF_IMODULE_free(st) SKM_sk_free(CONF_IMODULE, (st)) -#define sk_CONF_IMODULE_num(st) SKM_sk_num(CONF_IMODULE, (st)) -#define sk_CONF_IMODULE_value(st, i) SKM_sk_value(CONF_IMODULE, (st), (i)) -#define sk_CONF_IMODULE_set(st, i, val) SKM_sk_set(CONF_IMODULE, (st), (i), (val)) -#define sk_CONF_IMODULE_zero(st) SKM_sk_zero(CONF_IMODULE, (st)) -#define sk_CONF_IMODULE_push(st, val) SKM_sk_push(CONF_IMODULE, (st), (val)) -#define sk_CONF_IMODULE_unshift(st, val) SKM_sk_unshift(CONF_IMODULE, (st), (val)) -#define sk_CONF_IMODULE_find(st, val) SKM_sk_find(CONF_IMODULE, (st), (val)) -#define sk_CONF_IMODULE_find_ex(st, val) SKM_sk_find_ex(CONF_IMODULE, (st), (val)) -#define sk_CONF_IMODULE_delete(st, i) SKM_sk_delete(CONF_IMODULE, (st), (i)) -#define sk_CONF_IMODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_IMODULE, (st), (ptr)) -#define sk_CONF_IMODULE_insert(st, val, i) SKM_sk_insert(CONF_IMODULE, (st), (val), (i)) -#define sk_CONF_IMODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_IMODULE, (st), (cmp)) -#define sk_CONF_IMODULE_dup(st) SKM_sk_dup(CONF_IMODULE, st) -#define sk_CONF_IMODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_IMODULE, (st), (free_func)) -#define sk_CONF_IMODULE_shift(st) SKM_sk_shift(CONF_IMODULE, (st)) -#define sk_CONF_IMODULE_pop(st) SKM_sk_pop(CONF_IMODULE, (st)) -#define sk_CONF_IMODULE_sort(st) SKM_sk_sort(CONF_IMODULE, (st)) -#define sk_CONF_IMODULE_is_sorted(st) SKM_sk_is_sorted(CONF_IMODULE, (st)) - -#define sk_CONF_MODULE_new(st) SKM_sk_new(CONF_MODULE, (st)) -#define sk_CONF_MODULE_new_null() SKM_sk_new_null(CONF_MODULE) -#define sk_CONF_MODULE_free(st) SKM_sk_free(CONF_MODULE, (st)) -#define sk_CONF_MODULE_num(st) SKM_sk_num(CONF_MODULE, (st)) -#define sk_CONF_MODULE_value(st, i) SKM_sk_value(CONF_MODULE, (st), (i)) -#define sk_CONF_MODULE_set(st, i, val) SKM_sk_set(CONF_MODULE, (st), (i), (val)) -#define sk_CONF_MODULE_zero(st) SKM_sk_zero(CONF_MODULE, (st)) -#define sk_CONF_MODULE_push(st, val) SKM_sk_push(CONF_MODULE, (st), (val)) -#define sk_CONF_MODULE_unshift(st, val) SKM_sk_unshift(CONF_MODULE, (st), (val)) -#define sk_CONF_MODULE_find(st, val) SKM_sk_find(CONF_MODULE, (st), (val)) -#define sk_CONF_MODULE_find_ex(st, val) SKM_sk_find_ex(CONF_MODULE, (st), (val)) -#define sk_CONF_MODULE_delete(st, i) SKM_sk_delete(CONF_MODULE, (st), (i)) -#define sk_CONF_MODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_MODULE, (st), (ptr)) -#define sk_CONF_MODULE_insert(st, val, i) SKM_sk_insert(CONF_MODULE, (st), (val), (i)) -#define sk_CONF_MODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_MODULE, (st), (cmp)) -#define sk_CONF_MODULE_dup(st) SKM_sk_dup(CONF_MODULE, st) -#define sk_CONF_MODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_MODULE, (st), (free_func)) -#define sk_CONF_MODULE_shift(st) SKM_sk_shift(CONF_MODULE, (st)) -#define sk_CONF_MODULE_pop(st) SKM_sk_pop(CONF_MODULE, (st)) -#define sk_CONF_MODULE_sort(st) SKM_sk_sort(CONF_MODULE, (st)) -#define sk_CONF_MODULE_is_sorted(st) SKM_sk_is_sorted(CONF_MODULE, (st)) - -#define sk_CONF_VALUE_new(st) SKM_sk_new(CONF_VALUE, (st)) -#define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE) -#define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st)) -#define sk_CONF_VALUE_num(st) SKM_sk_num(CONF_VALUE, (st)) -#define sk_CONF_VALUE_value(st, i) SKM_sk_value(CONF_VALUE, (st), (i)) -#define sk_CONF_VALUE_set(st, i, val) SKM_sk_set(CONF_VALUE, (st), (i), (val)) -#define sk_CONF_VALUE_zero(st) SKM_sk_zero(CONF_VALUE, (st)) -#define sk_CONF_VALUE_push(st, val) SKM_sk_push(CONF_VALUE, (st), (val)) -#define sk_CONF_VALUE_unshift(st, val) SKM_sk_unshift(CONF_VALUE, (st), (val)) -#define sk_CONF_VALUE_find(st, val) SKM_sk_find(CONF_VALUE, (st), (val)) -#define sk_CONF_VALUE_find_ex(st, val) SKM_sk_find_ex(CONF_VALUE, (st), (val)) -#define sk_CONF_VALUE_delete(st, i) SKM_sk_delete(CONF_VALUE, (st), (i)) -#define sk_CONF_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_VALUE, (st), (ptr)) -#define sk_CONF_VALUE_insert(st, val, i) SKM_sk_insert(CONF_VALUE, (st), (val), (i)) -#define sk_CONF_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_VALUE, (st), (cmp)) -#define sk_CONF_VALUE_dup(st) SKM_sk_dup(CONF_VALUE, st) -#define sk_CONF_VALUE_pop_free(st, free_func) SKM_sk_pop_free(CONF_VALUE, (st), (free_func)) -#define sk_CONF_VALUE_shift(st) SKM_sk_shift(CONF_VALUE, (st)) -#define sk_CONF_VALUE_pop(st) SKM_sk_pop(CONF_VALUE, (st)) -#define sk_CONF_VALUE_sort(st) SKM_sk_sort(CONF_VALUE, (st)) -#define sk_CONF_VALUE_is_sorted(st) SKM_sk_is_sorted(CONF_VALUE, (st)) - -#define sk_CRYPTO_EX_DATA_FUNCS_new(st) SKM_sk_new(CRYPTO_EX_DATA_FUNCS, (st)) -#define sk_CRYPTO_EX_DATA_FUNCS_new_null() SKM_sk_new_null(CRYPTO_EX_DATA_FUNCS) -#define sk_CRYPTO_EX_DATA_FUNCS_free(st) SKM_sk_free(CRYPTO_EX_DATA_FUNCS, (st)) -#define sk_CRYPTO_EX_DATA_FUNCS_num(st) SKM_sk_num(CRYPTO_EX_DATA_FUNCS, (st)) -#define sk_CRYPTO_EX_DATA_FUNCS_value(st, i) SKM_sk_value(CRYPTO_EX_DATA_FUNCS, (st), (i)) -#define sk_CRYPTO_EX_DATA_FUNCS_set(st, i, val) SKM_sk_set(CRYPTO_EX_DATA_FUNCS, (st), (i), (val)) -#define sk_CRYPTO_EX_DATA_FUNCS_zero(st) SKM_sk_zero(CRYPTO_EX_DATA_FUNCS, (st)) -#define sk_CRYPTO_EX_DATA_FUNCS_push(st, val) SKM_sk_push(CRYPTO_EX_DATA_FUNCS, (st), (val)) -#define sk_CRYPTO_EX_DATA_FUNCS_unshift(st, val) SKM_sk_unshift(CRYPTO_EX_DATA_FUNCS, (st), (val)) -#define sk_CRYPTO_EX_DATA_FUNCS_find(st, val) SKM_sk_find(CRYPTO_EX_DATA_FUNCS, (st), (val)) -#define sk_CRYPTO_EX_DATA_FUNCS_find_ex(st, val) SKM_sk_find_ex(CRYPTO_EX_DATA_FUNCS, (st), (val)) -#define sk_CRYPTO_EX_DATA_FUNCS_delete(st, i) SKM_sk_delete(CRYPTO_EX_DATA_FUNCS, (st), (i)) -#define sk_CRYPTO_EX_DATA_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_EX_DATA_FUNCS, (st), (ptr)) -#define sk_CRYPTO_EX_DATA_FUNCS_insert(st, val, i) SKM_sk_insert(CRYPTO_EX_DATA_FUNCS, (st), (val), (i)) -#define sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_EX_DATA_FUNCS, (st), (cmp)) -#define sk_CRYPTO_EX_DATA_FUNCS_dup(st) SKM_sk_dup(CRYPTO_EX_DATA_FUNCS, st) -#define sk_CRYPTO_EX_DATA_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_EX_DATA_FUNCS, (st), (free_func)) -#define sk_CRYPTO_EX_DATA_FUNCS_shift(st) SKM_sk_shift(CRYPTO_EX_DATA_FUNCS, (st)) -#define sk_CRYPTO_EX_DATA_FUNCS_pop(st) SKM_sk_pop(CRYPTO_EX_DATA_FUNCS, (st)) -#define sk_CRYPTO_EX_DATA_FUNCS_sort(st) SKM_sk_sort(CRYPTO_EX_DATA_FUNCS, (st)) -#define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(st) SKM_sk_is_sorted(CRYPTO_EX_DATA_FUNCS, (st)) - -#define sk_CRYPTO_dynlock_new(st) SKM_sk_new(CRYPTO_dynlock, (st)) -#define sk_CRYPTO_dynlock_new_null() SKM_sk_new_null(CRYPTO_dynlock) -#define sk_CRYPTO_dynlock_free(st) SKM_sk_free(CRYPTO_dynlock, (st)) -#define sk_CRYPTO_dynlock_num(st) SKM_sk_num(CRYPTO_dynlock, (st)) -#define sk_CRYPTO_dynlock_value(st, i) SKM_sk_value(CRYPTO_dynlock, (st), (i)) -#define sk_CRYPTO_dynlock_set(st, i, val) SKM_sk_set(CRYPTO_dynlock, (st), (i), (val)) -#define sk_CRYPTO_dynlock_zero(st) SKM_sk_zero(CRYPTO_dynlock, (st)) -#define sk_CRYPTO_dynlock_push(st, val) SKM_sk_push(CRYPTO_dynlock, (st), (val)) -#define sk_CRYPTO_dynlock_unshift(st, val) SKM_sk_unshift(CRYPTO_dynlock, (st), (val)) -#define sk_CRYPTO_dynlock_find(st, val) SKM_sk_find(CRYPTO_dynlock, (st), (val)) -#define sk_CRYPTO_dynlock_find_ex(st, val) SKM_sk_find_ex(CRYPTO_dynlock, (st), (val)) -#define sk_CRYPTO_dynlock_delete(st, i) SKM_sk_delete(CRYPTO_dynlock, (st), (i)) -#define sk_CRYPTO_dynlock_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_dynlock, (st), (ptr)) -#define sk_CRYPTO_dynlock_insert(st, val, i) SKM_sk_insert(CRYPTO_dynlock, (st), (val), (i)) -#define sk_CRYPTO_dynlock_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_dynlock, (st), (cmp)) -#define sk_CRYPTO_dynlock_dup(st) SKM_sk_dup(CRYPTO_dynlock, st) -#define sk_CRYPTO_dynlock_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_dynlock, (st), (free_func)) -#define sk_CRYPTO_dynlock_shift(st) SKM_sk_shift(CRYPTO_dynlock, (st)) -#define sk_CRYPTO_dynlock_pop(st) SKM_sk_pop(CRYPTO_dynlock, (st)) -#define sk_CRYPTO_dynlock_sort(st) SKM_sk_sort(CRYPTO_dynlock, (st)) -#define sk_CRYPTO_dynlock_is_sorted(st) SKM_sk_is_sorted(CRYPTO_dynlock, (st)) - -#define sk_DIST_POINT_new(st) SKM_sk_new(DIST_POINT, (st)) -#define sk_DIST_POINT_new_null() SKM_sk_new_null(DIST_POINT) -#define sk_DIST_POINT_free(st) SKM_sk_free(DIST_POINT, (st)) -#define sk_DIST_POINT_num(st) SKM_sk_num(DIST_POINT, (st)) -#define sk_DIST_POINT_value(st, i) SKM_sk_value(DIST_POINT, (st), (i)) -#define sk_DIST_POINT_set(st, i, val) SKM_sk_set(DIST_POINT, (st), (i), (val)) -#define sk_DIST_POINT_zero(st) SKM_sk_zero(DIST_POINT, (st)) -#define sk_DIST_POINT_push(st, val) SKM_sk_push(DIST_POINT, (st), (val)) -#define sk_DIST_POINT_unshift(st, val) SKM_sk_unshift(DIST_POINT, (st), (val)) -#define sk_DIST_POINT_find(st, val) SKM_sk_find(DIST_POINT, (st), (val)) -#define sk_DIST_POINT_find_ex(st, val) SKM_sk_find_ex(DIST_POINT, (st), (val)) -#define sk_DIST_POINT_delete(st, i) SKM_sk_delete(DIST_POINT, (st), (i)) -#define sk_DIST_POINT_delete_ptr(st, ptr) SKM_sk_delete_ptr(DIST_POINT, (st), (ptr)) -#define sk_DIST_POINT_insert(st, val, i) SKM_sk_insert(DIST_POINT, (st), (val), (i)) -#define sk_DIST_POINT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(DIST_POINT, (st), (cmp)) -#define sk_DIST_POINT_dup(st) SKM_sk_dup(DIST_POINT, st) -#define sk_DIST_POINT_pop_free(st, free_func) SKM_sk_pop_free(DIST_POINT, (st), (free_func)) -#define sk_DIST_POINT_shift(st) SKM_sk_shift(DIST_POINT, (st)) -#define sk_DIST_POINT_pop(st) SKM_sk_pop(DIST_POINT, (st)) -#define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st)) -#define sk_DIST_POINT_is_sorted(st) SKM_sk_is_sorted(DIST_POINT, (st)) - -#define sk_ENGINE_new(st) SKM_sk_new(ENGINE, (st)) -#define sk_ENGINE_new_null() SKM_sk_new_null(ENGINE) -#define sk_ENGINE_free(st) SKM_sk_free(ENGINE, (st)) -#define sk_ENGINE_num(st) SKM_sk_num(ENGINE, (st)) -#define sk_ENGINE_value(st, i) SKM_sk_value(ENGINE, (st), (i)) -#define sk_ENGINE_set(st, i, val) SKM_sk_set(ENGINE, (st), (i), (val)) -#define sk_ENGINE_zero(st) SKM_sk_zero(ENGINE, (st)) -#define sk_ENGINE_push(st, val) SKM_sk_push(ENGINE, (st), (val)) -#define sk_ENGINE_unshift(st, val) SKM_sk_unshift(ENGINE, (st), (val)) -#define sk_ENGINE_find(st, val) SKM_sk_find(ENGINE, (st), (val)) -#define sk_ENGINE_find_ex(st, val) SKM_sk_find_ex(ENGINE, (st), (val)) -#define sk_ENGINE_delete(st, i) SKM_sk_delete(ENGINE, (st), (i)) -#define sk_ENGINE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE, (st), (ptr)) -#define sk_ENGINE_insert(st, val, i) SKM_sk_insert(ENGINE, (st), (val), (i)) -#define sk_ENGINE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE, (st), (cmp)) -#define sk_ENGINE_dup(st) SKM_sk_dup(ENGINE, st) -#define sk_ENGINE_pop_free(st, free_func) SKM_sk_pop_free(ENGINE, (st), (free_func)) -#define sk_ENGINE_shift(st) SKM_sk_shift(ENGINE, (st)) -#define sk_ENGINE_pop(st) SKM_sk_pop(ENGINE, (st)) -#define sk_ENGINE_sort(st) SKM_sk_sort(ENGINE, (st)) -#define sk_ENGINE_is_sorted(st) SKM_sk_is_sorted(ENGINE, (st)) - -#define sk_ENGINE_CLEANUP_ITEM_new(st) SKM_sk_new(ENGINE_CLEANUP_ITEM, (st)) -#define sk_ENGINE_CLEANUP_ITEM_new_null() SKM_sk_new_null(ENGINE_CLEANUP_ITEM) -#define sk_ENGINE_CLEANUP_ITEM_free(st) SKM_sk_free(ENGINE_CLEANUP_ITEM, (st)) -#define sk_ENGINE_CLEANUP_ITEM_num(st) SKM_sk_num(ENGINE_CLEANUP_ITEM, (st)) -#define sk_ENGINE_CLEANUP_ITEM_value(st, i) SKM_sk_value(ENGINE_CLEANUP_ITEM, (st), (i)) -#define sk_ENGINE_CLEANUP_ITEM_set(st, i, val) SKM_sk_set(ENGINE_CLEANUP_ITEM, (st), (i), (val)) -#define sk_ENGINE_CLEANUP_ITEM_zero(st) SKM_sk_zero(ENGINE_CLEANUP_ITEM, (st)) -#define sk_ENGINE_CLEANUP_ITEM_push(st, val) SKM_sk_push(ENGINE_CLEANUP_ITEM, (st), (val)) -#define sk_ENGINE_CLEANUP_ITEM_unshift(st, val) SKM_sk_unshift(ENGINE_CLEANUP_ITEM, (st), (val)) -#define sk_ENGINE_CLEANUP_ITEM_find(st, val) SKM_sk_find(ENGINE_CLEANUP_ITEM, (st), (val)) -#define sk_ENGINE_CLEANUP_ITEM_find_ex(st, val) SKM_sk_find_ex(ENGINE_CLEANUP_ITEM, (st), (val)) -#define sk_ENGINE_CLEANUP_ITEM_delete(st, i) SKM_sk_delete(ENGINE_CLEANUP_ITEM, (st), (i)) -#define sk_ENGINE_CLEANUP_ITEM_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE_CLEANUP_ITEM, (st), (ptr)) -#define sk_ENGINE_CLEANUP_ITEM_insert(st, val, i) SKM_sk_insert(ENGINE_CLEANUP_ITEM, (st), (val), (i)) -#define sk_ENGINE_CLEANUP_ITEM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE_CLEANUP_ITEM, (st), (cmp)) -#define sk_ENGINE_CLEANUP_ITEM_dup(st) SKM_sk_dup(ENGINE_CLEANUP_ITEM, st) -#define sk_ENGINE_CLEANUP_ITEM_pop_free(st, free_func) SKM_sk_pop_free(ENGINE_CLEANUP_ITEM, (st), (free_func)) -#define sk_ENGINE_CLEANUP_ITEM_shift(st) SKM_sk_shift(ENGINE_CLEANUP_ITEM, (st)) -#define sk_ENGINE_CLEANUP_ITEM_pop(st) SKM_sk_pop(ENGINE_CLEANUP_ITEM, (st)) -#define sk_ENGINE_CLEANUP_ITEM_sort(st) SKM_sk_sort(ENGINE_CLEANUP_ITEM, (st)) -#define sk_ENGINE_CLEANUP_ITEM_is_sorted(st) SKM_sk_is_sorted(ENGINE_CLEANUP_ITEM, (st)) - -#define sk_GENERAL_NAME_new(st) SKM_sk_new(GENERAL_NAME, (st)) -#define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME) -#define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st)) -#define sk_GENERAL_NAME_num(st) SKM_sk_num(GENERAL_NAME, (st)) -#define sk_GENERAL_NAME_value(st, i) SKM_sk_value(GENERAL_NAME, (st), (i)) -#define sk_GENERAL_NAME_set(st, i, val) SKM_sk_set(GENERAL_NAME, (st), (i), (val)) -#define sk_GENERAL_NAME_zero(st) SKM_sk_zero(GENERAL_NAME, (st)) -#define sk_GENERAL_NAME_push(st, val) SKM_sk_push(GENERAL_NAME, (st), (val)) -#define sk_GENERAL_NAME_unshift(st, val) SKM_sk_unshift(GENERAL_NAME, (st), (val)) -#define sk_GENERAL_NAME_find(st, val) SKM_sk_find(GENERAL_NAME, (st), (val)) -#define sk_GENERAL_NAME_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAME, (st), (val)) -#define sk_GENERAL_NAME_delete(st, i) SKM_sk_delete(GENERAL_NAME, (st), (i)) -#define sk_GENERAL_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAME, (st), (ptr)) -#define sk_GENERAL_NAME_insert(st, val, i) SKM_sk_insert(GENERAL_NAME, (st), (val), (i)) -#define sk_GENERAL_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAME, (st), (cmp)) -#define sk_GENERAL_NAME_dup(st) SKM_sk_dup(GENERAL_NAME, st) -#define sk_GENERAL_NAME_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAME, (st), (free_func)) -#define sk_GENERAL_NAME_shift(st) SKM_sk_shift(GENERAL_NAME, (st)) -#define sk_GENERAL_NAME_pop(st) SKM_sk_pop(GENERAL_NAME, (st)) -#define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st)) -#define sk_GENERAL_NAME_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAME, (st)) - -#define sk_GENERAL_SUBTREE_new(st) SKM_sk_new(GENERAL_SUBTREE, (st)) -#define sk_GENERAL_SUBTREE_new_null() SKM_sk_new_null(GENERAL_SUBTREE) -#define sk_GENERAL_SUBTREE_free(st) SKM_sk_free(GENERAL_SUBTREE, (st)) -#define sk_GENERAL_SUBTREE_num(st) SKM_sk_num(GENERAL_SUBTREE, (st)) -#define sk_GENERAL_SUBTREE_value(st, i) SKM_sk_value(GENERAL_SUBTREE, (st), (i)) -#define sk_GENERAL_SUBTREE_set(st, i, val) SKM_sk_set(GENERAL_SUBTREE, (st), (i), (val)) -#define sk_GENERAL_SUBTREE_zero(st) SKM_sk_zero(GENERAL_SUBTREE, (st)) -#define sk_GENERAL_SUBTREE_push(st, val) SKM_sk_push(GENERAL_SUBTREE, (st), (val)) -#define sk_GENERAL_SUBTREE_unshift(st, val) SKM_sk_unshift(GENERAL_SUBTREE, (st), (val)) -#define sk_GENERAL_SUBTREE_find(st, val) SKM_sk_find(GENERAL_SUBTREE, (st), (val)) -#define sk_GENERAL_SUBTREE_find_ex(st, val) SKM_sk_find_ex(GENERAL_SUBTREE, (st), (val)) -#define sk_GENERAL_SUBTREE_delete(st, i) SKM_sk_delete(GENERAL_SUBTREE, (st), (i)) -#define sk_GENERAL_SUBTREE_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_SUBTREE, (st), (ptr)) -#define sk_GENERAL_SUBTREE_insert(st, val, i) SKM_sk_insert(GENERAL_SUBTREE, (st), (val), (i)) -#define sk_GENERAL_SUBTREE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_SUBTREE, (st), (cmp)) -#define sk_GENERAL_SUBTREE_dup(st) SKM_sk_dup(GENERAL_SUBTREE, st) -#define sk_GENERAL_SUBTREE_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_SUBTREE, (st), (free_func)) -#define sk_GENERAL_SUBTREE_shift(st) SKM_sk_shift(GENERAL_SUBTREE, (st)) -#define sk_GENERAL_SUBTREE_pop(st) SKM_sk_pop(GENERAL_SUBTREE, (st)) -#define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st)) -#define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st)) - -#define sk_KRB5_APREQBODY_new(st) SKM_sk_new(KRB5_APREQBODY, (st)) -#define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY) -#define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st)) -#define sk_KRB5_APREQBODY_num(st) SKM_sk_num(KRB5_APREQBODY, (st)) -#define sk_KRB5_APREQBODY_value(st, i) SKM_sk_value(KRB5_APREQBODY, (st), (i)) -#define sk_KRB5_APREQBODY_set(st, i, val) SKM_sk_set(KRB5_APREQBODY, (st), (i), (val)) -#define sk_KRB5_APREQBODY_zero(st) SKM_sk_zero(KRB5_APREQBODY, (st)) -#define sk_KRB5_APREQBODY_push(st, val) SKM_sk_push(KRB5_APREQBODY, (st), (val)) -#define sk_KRB5_APREQBODY_unshift(st, val) SKM_sk_unshift(KRB5_APREQBODY, (st), (val)) -#define sk_KRB5_APREQBODY_find(st, val) SKM_sk_find(KRB5_APREQBODY, (st), (val)) -#define sk_KRB5_APREQBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_APREQBODY, (st), (val)) -#define sk_KRB5_APREQBODY_delete(st, i) SKM_sk_delete(KRB5_APREQBODY, (st), (i)) -#define sk_KRB5_APREQBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_APREQBODY, (st), (ptr)) -#define sk_KRB5_APREQBODY_insert(st, val, i) SKM_sk_insert(KRB5_APREQBODY, (st), (val), (i)) -#define sk_KRB5_APREQBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_APREQBODY, (st), (cmp)) -#define sk_KRB5_APREQBODY_dup(st) SKM_sk_dup(KRB5_APREQBODY, st) -#define sk_KRB5_APREQBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_APREQBODY, (st), (free_func)) -#define sk_KRB5_APREQBODY_shift(st) SKM_sk_shift(KRB5_APREQBODY, (st)) -#define sk_KRB5_APREQBODY_pop(st) SKM_sk_pop(KRB5_APREQBODY, (st)) -#define sk_KRB5_APREQBODY_sort(st) SKM_sk_sort(KRB5_APREQBODY, (st)) -#define sk_KRB5_APREQBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_APREQBODY, (st)) - -#define sk_KRB5_AUTHDATA_new(st) SKM_sk_new(KRB5_AUTHDATA, (st)) -#define sk_KRB5_AUTHDATA_new_null() SKM_sk_new_null(KRB5_AUTHDATA) -#define sk_KRB5_AUTHDATA_free(st) SKM_sk_free(KRB5_AUTHDATA, (st)) -#define sk_KRB5_AUTHDATA_num(st) SKM_sk_num(KRB5_AUTHDATA, (st)) -#define sk_KRB5_AUTHDATA_value(st, i) SKM_sk_value(KRB5_AUTHDATA, (st), (i)) -#define sk_KRB5_AUTHDATA_set(st, i, val) SKM_sk_set(KRB5_AUTHDATA, (st), (i), (val)) -#define sk_KRB5_AUTHDATA_zero(st) SKM_sk_zero(KRB5_AUTHDATA, (st)) -#define sk_KRB5_AUTHDATA_push(st, val) SKM_sk_push(KRB5_AUTHDATA, (st), (val)) -#define sk_KRB5_AUTHDATA_unshift(st, val) SKM_sk_unshift(KRB5_AUTHDATA, (st), (val)) -#define sk_KRB5_AUTHDATA_find(st, val) SKM_sk_find(KRB5_AUTHDATA, (st), (val)) -#define sk_KRB5_AUTHDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHDATA, (st), (val)) -#define sk_KRB5_AUTHDATA_delete(st, i) SKM_sk_delete(KRB5_AUTHDATA, (st), (i)) -#define sk_KRB5_AUTHDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHDATA, (st), (ptr)) -#define sk_KRB5_AUTHDATA_insert(st, val, i) SKM_sk_insert(KRB5_AUTHDATA, (st), (val), (i)) -#define sk_KRB5_AUTHDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHDATA, (st), (cmp)) -#define sk_KRB5_AUTHDATA_dup(st) SKM_sk_dup(KRB5_AUTHDATA, st) -#define sk_KRB5_AUTHDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHDATA, (st), (free_func)) -#define sk_KRB5_AUTHDATA_shift(st) SKM_sk_shift(KRB5_AUTHDATA, (st)) -#define sk_KRB5_AUTHDATA_pop(st) SKM_sk_pop(KRB5_AUTHDATA, (st)) -#define sk_KRB5_AUTHDATA_sort(st) SKM_sk_sort(KRB5_AUTHDATA, (st)) -#define sk_KRB5_AUTHDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHDATA, (st)) - -#define sk_KRB5_AUTHENTBODY_new(st) SKM_sk_new(KRB5_AUTHENTBODY, (st)) -#define sk_KRB5_AUTHENTBODY_new_null() SKM_sk_new_null(KRB5_AUTHENTBODY) -#define sk_KRB5_AUTHENTBODY_free(st) SKM_sk_free(KRB5_AUTHENTBODY, (st)) -#define sk_KRB5_AUTHENTBODY_num(st) SKM_sk_num(KRB5_AUTHENTBODY, (st)) -#define sk_KRB5_AUTHENTBODY_value(st, i) SKM_sk_value(KRB5_AUTHENTBODY, (st), (i)) -#define sk_KRB5_AUTHENTBODY_set(st, i, val) SKM_sk_set(KRB5_AUTHENTBODY, (st), (i), (val)) -#define sk_KRB5_AUTHENTBODY_zero(st) SKM_sk_zero(KRB5_AUTHENTBODY, (st)) -#define sk_KRB5_AUTHENTBODY_push(st, val) SKM_sk_push(KRB5_AUTHENTBODY, (st), (val)) -#define sk_KRB5_AUTHENTBODY_unshift(st, val) SKM_sk_unshift(KRB5_AUTHENTBODY, (st), (val)) -#define sk_KRB5_AUTHENTBODY_find(st, val) SKM_sk_find(KRB5_AUTHENTBODY, (st), (val)) -#define sk_KRB5_AUTHENTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHENTBODY, (st), (val)) -#define sk_KRB5_AUTHENTBODY_delete(st, i) SKM_sk_delete(KRB5_AUTHENTBODY, (st), (i)) -#define sk_KRB5_AUTHENTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHENTBODY, (st), (ptr)) -#define sk_KRB5_AUTHENTBODY_insert(st, val, i) SKM_sk_insert(KRB5_AUTHENTBODY, (st), (val), (i)) -#define sk_KRB5_AUTHENTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHENTBODY, (st), (cmp)) -#define sk_KRB5_AUTHENTBODY_dup(st) SKM_sk_dup(KRB5_AUTHENTBODY, st) -#define sk_KRB5_AUTHENTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHENTBODY, (st), (free_func)) -#define sk_KRB5_AUTHENTBODY_shift(st) SKM_sk_shift(KRB5_AUTHENTBODY, (st)) -#define sk_KRB5_AUTHENTBODY_pop(st) SKM_sk_pop(KRB5_AUTHENTBODY, (st)) -#define sk_KRB5_AUTHENTBODY_sort(st) SKM_sk_sort(KRB5_AUTHENTBODY, (st)) -#define sk_KRB5_AUTHENTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHENTBODY, (st)) - -#define sk_KRB5_CHECKSUM_new(st) SKM_sk_new(KRB5_CHECKSUM, (st)) -#define sk_KRB5_CHECKSUM_new_null() SKM_sk_new_null(KRB5_CHECKSUM) -#define sk_KRB5_CHECKSUM_free(st) SKM_sk_free(KRB5_CHECKSUM, (st)) -#define sk_KRB5_CHECKSUM_num(st) SKM_sk_num(KRB5_CHECKSUM, (st)) -#define sk_KRB5_CHECKSUM_value(st, i) SKM_sk_value(KRB5_CHECKSUM, (st), (i)) -#define sk_KRB5_CHECKSUM_set(st, i, val) SKM_sk_set(KRB5_CHECKSUM, (st), (i), (val)) -#define sk_KRB5_CHECKSUM_zero(st) SKM_sk_zero(KRB5_CHECKSUM, (st)) -#define sk_KRB5_CHECKSUM_push(st, val) SKM_sk_push(KRB5_CHECKSUM, (st), (val)) -#define sk_KRB5_CHECKSUM_unshift(st, val) SKM_sk_unshift(KRB5_CHECKSUM, (st), (val)) -#define sk_KRB5_CHECKSUM_find(st, val) SKM_sk_find(KRB5_CHECKSUM, (st), (val)) -#define sk_KRB5_CHECKSUM_find_ex(st, val) SKM_sk_find_ex(KRB5_CHECKSUM, (st), (val)) -#define sk_KRB5_CHECKSUM_delete(st, i) SKM_sk_delete(KRB5_CHECKSUM, (st), (i)) -#define sk_KRB5_CHECKSUM_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_CHECKSUM, (st), (ptr)) -#define sk_KRB5_CHECKSUM_insert(st, val, i) SKM_sk_insert(KRB5_CHECKSUM, (st), (val), (i)) -#define sk_KRB5_CHECKSUM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_CHECKSUM, (st), (cmp)) -#define sk_KRB5_CHECKSUM_dup(st) SKM_sk_dup(KRB5_CHECKSUM, st) -#define sk_KRB5_CHECKSUM_pop_free(st, free_func) SKM_sk_pop_free(KRB5_CHECKSUM, (st), (free_func)) -#define sk_KRB5_CHECKSUM_shift(st) SKM_sk_shift(KRB5_CHECKSUM, (st)) -#define sk_KRB5_CHECKSUM_pop(st) SKM_sk_pop(KRB5_CHECKSUM, (st)) -#define sk_KRB5_CHECKSUM_sort(st) SKM_sk_sort(KRB5_CHECKSUM, (st)) -#define sk_KRB5_CHECKSUM_is_sorted(st) SKM_sk_is_sorted(KRB5_CHECKSUM, (st)) - -#define sk_KRB5_ENCDATA_new(st) SKM_sk_new(KRB5_ENCDATA, (st)) -#define sk_KRB5_ENCDATA_new_null() SKM_sk_new_null(KRB5_ENCDATA) -#define sk_KRB5_ENCDATA_free(st) SKM_sk_free(KRB5_ENCDATA, (st)) -#define sk_KRB5_ENCDATA_num(st) SKM_sk_num(KRB5_ENCDATA, (st)) -#define sk_KRB5_ENCDATA_value(st, i) SKM_sk_value(KRB5_ENCDATA, (st), (i)) -#define sk_KRB5_ENCDATA_set(st, i, val) SKM_sk_set(KRB5_ENCDATA, (st), (i), (val)) -#define sk_KRB5_ENCDATA_zero(st) SKM_sk_zero(KRB5_ENCDATA, (st)) -#define sk_KRB5_ENCDATA_push(st, val) SKM_sk_push(KRB5_ENCDATA, (st), (val)) -#define sk_KRB5_ENCDATA_unshift(st, val) SKM_sk_unshift(KRB5_ENCDATA, (st), (val)) -#define sk_KRB5_ENCDATA_find(st, val) SKM_sk_find(KRB5_ENCDATA, (st), (val)) -#define sk_KRB5_ENCDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCDATA, (st), (val)) -#define sk_KRB5_ENCDATA_delete(st, i) SKM_sk_delete(KRB5_ENCDATA, (st), (i)) -#define sk_KRB5_ENCDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCDATA, (st), (ptr)) -#define sk_KRB5_ENCDATA_insert(st, val, i) SKM_sk_insert(KRB5_ENCDATA, (st), (val), (i)) -#define sk_KRB5_ENCDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCDATA, (st), (cmp)) -#define sk_KRB5_ENCDATA_dup(st) SKM_sk_dup(KRB5_ENCDATA, st) -#define sk_KRB5_ENCDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCDATA, (st), (free_func)) -#define sk_KRB5_ENCDATA_shift(st) SKM_sk_shift(KRB5_ENCDATA, (st)) -#define sk_KRB5_ENCDATA_pop(st) SKM_sk_pop(KRB5_ENCDATA, (st)) -#define sk_KRB5_ENCDATA_sort(st) SKM_sk_sort(KRB5_ENCDATA, (st)) -#define sk_KRB5_ENCDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCDATA, (st)) - -#define sk_KRB5_ENCKEY_new(st) SKM_sk_new(KRB5_ENCKEY, (st)) -#define sk_KRB5_ENCKEY_new_null() SKM_sk_new_null(KRB5_ENCKEY) -#define sk_KRB5_ENCKEY_free(st) SKM_sk_free(KRB5_ENCKEY, (st)) -#define sk_KRB5_ENCKEY_num(st) SKM_sk_num(KRB5_ENCKEY, (st)) -#define sk_KRB5_ENCKEY_value(st, i) SKM_sk_value(KRB5_ENCKEY, (st), (i)) -#define sk_KRB5_ENCKEY_set(st, i, val) SKM_sk_set(KRB5_ENCKEY, (st), (i), (val)) -#define sk_KRB5_ENCKEY_zero(st) SKM_sk_zero(KRB5_ENCKEY, (st)) -#define sk_KRB5_ENCKEY_push(st, val) SKM_sk_push(KRB5_ENCKEY, (st), (val)) -#define sk_KRB5_ENCKEY_unshift(st, val) SKM_sk_unshift(KRB5_ENCKEY, (st), (val)) -#define sk_KRB5_ENCKEY_find(st, val) SKM_sk_find(KRB5_ENCKEY, (st), (val)) -#define sk_KRB5_ENCKEY_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCKEY, (st), (val)) -#define sk_KRB5_ENCKEY_delete(st, i) SKM_sk_delete(KRB5_ENCKEY, (st), (i)) -#define sk_KRB5_ENCKEY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCKEY, (st), (ptr)) -#define sk_KRB5_ENCKEY_insert(st, val, i) SKM_sk_insert(KRB5_ENCKEY, (st), (val), (i)) -#define sk_KRB5_ENCKEY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCKEY, (st), (cmp)) -#define sk_KRB5_ENCKEY_dup(st) SKM_sk_dup(KRB5_ENCKEY, st) -#define sk_KRB5_ENCKEY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCKEY, (st), (free_func)) -#define sk_KRB5_ENCKEY_shift(st) SKM_sk_shift(KRB5_ENCKEY, (st)) -#define sk_KRB5_ENCKEY_pop(st) SKM_sk_pop(KRB5_ENCKEY, (st)) -#define sk_KRB5_ENCKEY_sort(st) SKM_sk_sort(KRB5_ENCKEY, (st)) -#define sk_KRB5_ENCKEY_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCKEY, (st)) - -#define sk_KRB5_PRINCNAME_new(st) SKM_sk_new(KRB5_PRINCNAME, (st)) -#define sk_KRB5_PRINCNAME_new_null() SKM_sk_new_null(KRB5_PRINCNAME) -#define sk_KRB5_PRINCNAME_free(st) SKM_sk_free(KRB5_PRINCNAME, (st)) -#define sk_KRB5_PRINCNAME_num(st) SKM_sk_num(KRB5_PRINCNAME, (st)) -#define sk_KRB5_PRINCNAME_value(st, i) SKM_sk_value(KRB5_PRINCNAME, (st), (i)) -#define sk_KRB5_PRINCNAME_set(st, i, val) SKM_sk_set(KRB5_PRINCNAME, (st), (i), (val)) -#define sk_KRB5_PRINCNAME_zero(st) SKM_sk_zero(KRB5_PRINCNAME, (st)) -#define sk_KRB5_PRINCNAME_push(st, val) SKM_sk_push(KRB5_PRINCNAME, (st), (val)) -#define sk_KRB5_PRINCNAME_unshift(st, val) SKM_sk_unshift(KRB5_PRINCNAME, (st), (val)) -#define sk_KRB5_PRINCNAME_find(st, val) SKM_sk_find(KRB5_PRINCNAME, (st), (val)) -#define sk_KRB5_PRINCNAME_find_ex(st, val) SKM_sk_find_ex(KRB5_PRINCNAME, (st), (val)) -#define sk_KRB5_PRINCNAME_delete(st, i) SKM_sk_delete(KRB5_PRINCNAME, (st), (i)) -#define sk_KRB5_PRINCNAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_PRINCNAME, (st), (ptr)) -#define sk_KRB5_PRINCNAME_insert(st, val, i) SKM_sk_insert(KRB5_PRINCNAME, (st), (val), (i)) -#define sk_KRB5_PRINCNAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_PRINCNAME, (st), (cmp)) -#define sk_KRB5_PRINCNAME_dup(st) SKM_sk_dup(KRB5_PRINCNAME, st) -#define sk_KRB5_PRINCNAME_pop_free(st, free_func) SKM_sk_pop_free(KRB5_PRINCNAME, (st), (free_func)) -#define sk_KRB5_PRINCNAME_shift(st) SKM_sk_shift(KRB5_PRINCNAME, (st)) -#define sk_KRB5_PRINCNAME_pop(st) SKM_sk_pop(KRB5_PRINCNAME, (st)) -#define sk_KRB5_PRINCNAME_sort(st) SKM_sk_sort(KRB5_PRINCNAME, (st)) -#define sk_KRB5_PRINCNAME_is_sorted(st) SKM_sk_is_sorted(KRB5_PRINCNAME, (st)) - -#define sk_KRB5_TKTBODY_new(st) SKM_sk_new(KRB5_TKTBODY, (st)) -#define sk_KRB5_TKTBODY_new_null() SKM_sk_new_null(KRB5_TKTBODY) -#define sk_KRB5_TKTBODY_free(st) SKM_sk_free(KRB5_TKTBODY, (st)) -#define sk_KRB5_TKTBODY_num(st) SKM_sk_num(KRB5_TKTBODY, (st)) -#define sk_KRB5_TKTBODY_value(st, i) SKM_sk_value(KRB5_TKTBODY, (st), (i)) -#define sk_KRB5_TKTBODY_set(st, i, val) SKM_sk_set(KRB5_TKTBODY, (st), (i), (val)) -#define sk_KRB5_TKTBODY_zero(st) SKM_sk_zero(KRB5_TKTBODY, (st)) -#define sk_KRB5_TKTBODY_push(st, val) SKM_sk_push(KRB5_TKTBODY, (st), (val)) -#define sk_KRB5_TKTBODY_unshift(st, val) SKM_sk_unshift(KRB5_TKTBODY, (st), (val)) -#define sk_KRB5_TKTBODY_find(st, val) SKM_sk_find(KRB5_TKTBODY, (st), (val)) -#define sk_KRB5_TKTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_TKTBODY, (st), (val)) -#define sk_KRB5_TKTBODY_delete(st, i) SKM_sk_delete(KRB5_TKTBODY, (st), (i)) -#define sk_KRB5_TKTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_TKTBODY, (st), (ptr)) -#define sk_KRB5_TKTBODY_insert(st, val, i) SKM_sk_insert(KRB5_TKTBODY, (st), (val), (i)) -#define sk_KRB5_TKTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_TKTBODY, (st), (cmp)) -#define sk_KRB5_TKTBODY_dup(st) SKM_sk_dup(KRB5_TKTBODY, st) -#define sk_KRB5_TKTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_TKTBODY, (st), (free_func)) -#define sk_KRB5_TKTBODY_shift(st) SKM_sk_shift(KRB5_TKTBODY, (st)) -#define sk_KRB5_TKTBODY_pop(st) SKM_sk_pop(KRB5_TKTBODY, (st)) -#define sk_KRB5_TKTBODY_sort(st) SKM_sk_sort(KRB5_TKTBODY, (st)) -#define sk_KRB5_TKTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_TKTBODY, (st)) - -#define sk_MIME_HEADER_new(st) SKM_sk_new(MIME_HEADER, (st)) -#define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER) -#define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st)) -#define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st)) -#define sk_MIME_HEADER_value(st, i) SKM_sk_value(MIME_HEADER, (st), (i)) -#define sk_MIME_HEADER_set(st, i, val) SKM_sk_set(MIME_HEADER, (st), (i), (val)) -#define sk_MIME_HEADER_zero(st) SKM_sk_zero(MIME_HEADER, (st)) -#define sk_MIME_HEADER_push(st, val) SKM_sk_push(MIME_HEADER, (st), (val)) -#define sk_MIME_HEADER_unshift(st, val) SKM_sk_unshift(MIME_HEADER, (st), (val)) -#define sk_MIME_HEADER_find(st, val) SKM_sk_find(MIME_HEADER, (st), (val)) -#define sk_MIME_HEADER_find_ex(st, val) SKM_sk_find_ex(MIME_HEADER, (st), (val)) -#define sk_MIME_HEADER_delete(st, i) SKM_sk_delete(MIME_HEADER, (st), (i)) -#define sk_MIME_HEADER_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_HEADER, (st), (ptr)) -#define sk_MIME_HEADER_insert(st, val, i) SKM_sk_insert(MIME_HEADER, (st), (val), (i)) -#define sk_MIME_HEADER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_HEADER, (st), (cmp)) -#define sk_MIME_HEADER_dup(st) SKM_sk_dup(MIME_HEADER, st) -#define sk_MIME_HEADER_pop_free(st, free_func) SKM_sk_pop_free(MIME_HEADER, (st), (free_func)) -#define sk_MIME_HEADER_shift(st) SKM_sk_shift(MIME_HEADER, (st)) -#define sk_MIME_HEADER_pop(st) SKM_sk_pop(MIME_HEADER, (st)) -#define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st)) -#define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st)) - -#define sk_MIME_PARAM_new(st) SKM_sk_new(MIME_PARAM, (st)) -#define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM) -#define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st)) -#define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st)) -#define sk_MIME_PARAM_value(st, i) SKM_sk_value(MIME_PARAM, (st), (i)) -#define sk_MIME_PARAM_set(st, i, val) SKM_sk_set(MIME_PARAM, (st), (i), (val)) -#define sk_MIME_PARAM_zero(st) SKM_sk_zero(MIME_PARAM, (st)) -#define sk_MIME_PARAM_push(st, val) SKM_sk_push(MIME_PARAM, (st), (val)) -#define sk_MIME_PARAM_unshift(st, val) SKM_sk_unshift(MIME_PARAM, (st), (val)) -#define sk_MIME_PARAM_find(st, val) SKM_sk_find(MIME_PARAM, (st), (val)) -#define sk_MIME_PARAM_find_ex(st, val) SKM_sk_find_ex(MIME_PARAM, (st), (val)) -#define sk_MIME_PARAM_delete(st, i) SKM_sk_delete(MIME_PARAM, (st), (i)) -#define sk_MIME_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_PARAM, (st), (ptr)) -#define sk_MIME_PARAM_insert(st, val, i) SKM_sk_insert(MIME_PARAM, (st), (val), (i)) -#define sk_MIME_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_PARAM, (st), (cmp)) -#define sk_MIME_PARAM_dup(st) SKM_sk_dup(MIME_PARAM, st) -#define sk_MIME_PARAM_pop_free(st, free_func) SKM_sk_pop_free(MIME_PARAM, (st), (free_func)) -#define sk_MIME_PARAM_shift(st) SKM_sk_shift(MIME_PARAM, (st)) -#define sk_MIME_PARAM_pop(st) SKM_sk_pop(MIME_PARAM, (st)) -#define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st)) -#define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st)) - -#define sk_NAME_FUNCS_new(st) SKM_sk_new(NAME_FUNCS, (st)) -#define sk_NAME_FUNCS_new_null() SKM_sk_new_null(NAME_FUNCS) -#define sk_NAME_FUNCS_free(st) SKM_sk_free(NAME_FUNCS, (st)) -#define sk_NAME_FUNCS_num(st) SKM_sk_num(NAME_FUNCS, (st)) -#define sk_NAME_FUNCS_value(st, i) SKM_sk_value(NAME_FUNCS, (st), (i)) -#define sk_NAME_FUNCS_set(st, i, val) SKM_sk_set(NAME_FUNCS, (st), (i), (val)) -#define sk_NAME_FUNCS_zero(st) SKM_sk_zero(NAME_FUNCS, (st)) -#define sk_NAME_FUNCS_push(st, val) SKM_sk_push(NAME_FUNCS, (st), (val)) -#define sk_NAME_FUNCS_unshift(st, val) SKM_sk_unshift(NAME_FUNCS, (st), (val)) -#define sk_NAME_FUNCS_find(st, val) SKM_sk_find(NAME_FUNCS, (st), (val)) -#define sk_NAME_FUNCS_find_ex(st, val) SKM_sk_find_ex(NAME_FUNCS, (st), (val)) -#define sk_NAME_FUNCS_delete(st, i) SKM_sk_delete(NAME_FUNCS, (st), (i)) -#define sk_NAME_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(NAME_FUNCS, (st), (ptr)) -#define sk_NAME_FUNCS_insert(st, val, i) SKM_sk_insert(NAME_FUNCS, (st), (val), (i)) -#define sk_NAME_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(NAME_FUNCS, (st), (cmp)) -#define sk_NAME_FUNCS_dup(st) SKM_sk_dup(NAME_FUNCS, st) -#define sk_NAME_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(NAME_FUNCS, (st), (free_func)) -#define sk_NAME_FUNCS_shift(st) SKM_sk_shift(NAME_FUNCS, (st)) -#define sk_NAME_FUNCS_pop(st) SKM_sk_pop(NAME_FUNCS, (st)) -#define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st)) -#define sk_NAME_FUNCS_is_sorted(st) SKM_sk_is_sorted(NAME_FUNCS, (st)) - -#define sk_OCSP_CERTID_new(st) SKM_sk_new(OCSP_CERTID, (st)) -#define sk_OCSP_CERTID_new_null() SKM_sk_new_null(OCSP_CERTID) -#define sk_OCSP_CERTID_free(st) SKM_sk_free(OCSP_CERTID, (st)) -#define sk_OCSP_CERTID_num(st) SKM_sk_num(OCSP_CERTID, (st)) -#define sk_OCSP_CERTID_value(st, i) SKM_sk_value(OCSP_CERTID, (st), (i)) -#define sk_OCSP_CERTID_set(st, i, val) SKM_sk_set(OCSP_CERTID, (st), (i), (val)) -#define sk_OCSP_CERTID_zero(st) SKM_sk_zero(OCSP_CERTID, (st)) -#define sk_OCSP_CERTID_push(st, val) SKM_sk_push(OCSP_CERTID, (st), (val)) -#define sk_OCSP_CERTID_unshift(st, val) SKM_sk_unshift(OCSP_CERTID, (st), (val)) -#define sk_OCSP_CERTID_find(st, val) SKM_sk_find(OCSP_CERTID, (st), (val)) -#define sk_OCSP_CERTID_find_ex(st, val) SKM_sk_find_ex(OCSP_CERTID, (st), (val)) -#define sk_OCSP_CERTID_delete(st, i) SKM_sk_delete(OCSP_CERTID, (st), (i)) -#define sk_OCSP_CERTID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_CERTID, (st), (ptr)) -#define sk_OCSP_CERTID_insert(st, val, i) SKM_sk_insert(OCSP_CERTID, (st), (val), (i)) -#define sk_OCSP_CERTID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_CERTID, (st), (cmp)) -#define sk_OCSP_CERTID_dup(st) SKM_sk_dup(OCSP_CERTID, st) -#define sk_OCSP_CERTID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_CERTID, (st), (free_func)) -#define sk_OCSP_CERTID_shift(st) SKM_sk_shift(OCSP_CERTID, (st)) -#define sk_OCSP_CERTID_pop(st) SKM_sk_pop(OCSP_CERTID, (st)) -#define sk_OCSP_CERTID_sort(st) SKM_sk_sort(OCSP_CERTID, (st)) -#define sk_OCSP_CERTID_is_sorted(st) SKM_sk_is_sorted(OCSP_CERTID, (st)) - -#define sk_OCSP_ONEREQ_new(st) SKM_sk_new(OCSP_ONEREQ, (st)) -#define sk_OCSP_ONEREQ_new_null() SKM_sk_new_null(OCSP_ONEREQ) -#define sk_OCSP_ONEREQ_free(st) SKM_sk_free(OCSP_ONEREQ, (st)) -#define sk_OCSP_ONEREQ_num(st) SKM_sk_num(OCSP_ONEREQ, (st)) -#define sk_OCSP_ONEREQ_value(st, i) SKM_sk_value(OCSP_ONEREQ, (st), (i)) -#define sk_OCSP_ONEREQ_set(st, i, val) SKM_sk_set(OCSP_ONEREQ, (st), (i), (val)) -#define sk_OCSP_ONEREQ_zero(st) SKM_sk_zero(OCSP_ONEREQ, (st)) -#define sk_OCSP_ONEREQ_push(st, val) SKM_sk_push(OCSP_ONEREQ, (st), (val)) -#define sk_OCSP_ONEREQ_unshift(st, val) SKM_sk_unshift(OCSP_ONEREQ, (st), (val)) -#define sk_OCSP_ONEREQ_find(st, val) SKM_sk_find(OCSP_ONEREQ, (st), (val)) -#define sk_OCSP_ONEREQ_find_ex(st, val) SKM_sk_find_ex(OCSP_ONEREQ, (st), (val)) -#define sk_OCSP_ONEREQ_delete(st, i) SKM_sk_delete(OCSP_ONEREQ, (st), (i)) -#define sk_OCSP_ONEREQ_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_ONEREQ, (st), (ptr)) -#define sk_OCSP_ONEREQ_insert(st, val, i) SKM_sk_insert(OCSP_ONEREQ, (st), (val), (i)) -#define sk_OCSP_ONEREQ_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_ONEREQ, (st), (cmp)) -#define sk_OCSP_ONEREQ_dup(st) SKM_sk_dup(OCSP_ONEREQ, st) -#define sk_OCSP_ONEREQ_pop_free(st, free_func) SKM_sk_pop_free(OCSP_ONEREQ, (st), (free_func)) -#define sk_OCSP_ONEREQ_shift(st) SKM_sk_shift(OCSP_ONEREQ, (st)) -#define sk_OCSP_ONEREQ_pop(st) SKM_sk_pop(OCSP_ONEREQ, (st)) -#define sk_OCSP_ONEREQ_sort(st) SKM_sk_sort(OCSP_ONEREQ, (st)) -#define sk_OCSP_ONEREQ_is_sorted(st) SKM_sk_is_sorted(OCSP_ONEREQ, (st)) - -#define sk_OCSP_SINGLERESP_new(st) SKM_sk_new(OCSP_SINGLERESP, (st)) -#define sk_OCSP_SINGLERESP_new_null() SKM_sk_new_null(OCSP_SINGLERESP) -#define sk_OCSP_SINGLERESP_free(st) SKM_sk_free(OCSP_SINGLERESP, (st)) -#define sk_OCSP_SINGLERESP_num(st) SKM_sk_num(OCSP_SINGLERESP, (st)) -#define sk_OCSP_SINGLERESP_value(st, i) SKM_sk_value(OCSP_SINGLERESP, (st), (i)) -#define sk_OCSP_SINGLERESP_set(st, i, val) SKM_sk_set(OCSP_SINGLERESP, (st), (i), (val)) -#define sk_OCSP_SINGLERESP_zero(st) SKM_sk_zero(OCSP_SINGLERESP, (st)) -#define sk_OCSP_SINGLERESP_push(st, val) SKM_sk_push(OCSP_SINGLERESP, (st), (val)) -#define sk_OCSP_SINGLERESP_unshift(st, val) SKM_sk_unshift(OCSP_SINGLERESP, (st), (val)) -#define sk_OCSP_SINGLERESP_find(st, val) SKM_sk_find(OCSP_SINGLERESP, (st), (val)) -#define sk_OCSP_SINGLERESP_find_ex(st, val) SKM_sk_find_ex(OCSP_SINGLERESP, (st), (val)) -#define sk_OCSP_SINGLERESP_delete(st, i) SKM_sk_delete(OCSP_SINGLERESP, (st), (i)) -#define sk_OCSP_SINGLERESP_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_SINGLERESP, (st), (ptr)) -#define sk_OCSP_SINGLERESP_insert(st, val, i) SKM_sk_insert(OCSP_SINGLERESP, (st), (val), (i)) -#define sk_OCSP_SINGLERESP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_SINGLERESP, (st), (cmp)) -#define sk_OCSP_SINGLERESP_dup(st) SKM_sk_dup(OCSP_SINGLERESP, st) -#define sk_OCSP_SINGLERESP_pop_free(st, free_func) SKM_sk_pop_free(OCSP_SINGLERESP, (st), (free_func)) -#define sk_OCSP_SINGLERESP_shift(st) SKM_sk_shift(OCSP_SINGLERESP, (st)) -#define sk_OCSP_SINGLERESP_pop(st) SKM_sk_pop(OCSP_SINGLERESP, (st)) -#define sk_OCSP_SINGLERESP_sort(st) SKM_sk_sort(OCSP_SINGLERESP, (st)) -#define sk_OCSP_SINGLERESP_is_sorted(st) SKM_sk_is_sorted(OCSP_SINGLERESP, (st)) - -#define sk_PKCS12_SAFEBAG_new(st) SKM_sk_new(PKCS12_SAFEBAG, (st)) -#define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG) -#define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st)) -#define sk_PKCS12_SAFEBAG_num(st) SKM_sk_num(PKCS12_SAFEBAG, (st)) -#define sk_PKCS12_SAFEBAG_value(st, i) SKM_sk_value(PKCS12_SAFEBAG, (st), (i)) -#define sk_PKCS12_SAFEBAG_set(st, i, val) SKM_sk_set(PKCS12_SAFEBAG, (st), (i), (val)) -#define sk_PKCS12_SAFEBAG_zero(st) SKM_sk_zero(PKCS12_SAFEBAG, (st)) -#define sk_PKCS12_SAFEBAG_push(st, val) SKM_sk_push(PKCS12_SAFEBAG, (st), (val)) -#define sk_PKCS12_SAFEBAG_unshift(st, val) SKM_sk_unshift(PKCS12_SAFEBAG, (st), (val)) -#define sk_PKCS12_SAFEBAG_find(st, val) SKM_sk_find(PKCS12_SAFEBAG, (st), (val)) -#define sk_PKCS12_SAFEBAG_find_ex(st, val) SKM_sk_find_ex(PKCS12_SAFEBAG, (st), (val)) -#define sk_PKCS12_SAFEBAG_delete(st, i) SKM_sk_delete(PKCS12_SAFEBAG, (st), (i)) -#define sk_PKCS12_SAFEBAG_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS12_SAFEBAG, (st), (ptr)) -#define sk_PKCS12_SAFEBAG_insert(st, val, i) SKM_sk_insert(PKCS12_SAFEBAG, (st), (val), (i)) -#define sk_PKCS12_SAFEBAG_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS12_SAFEBAG, (st), (cmp)) -#define sk_PKCS12_SAFEBAG_dup(st) SKM_sk_dup(PKCS12_SAFEBAG, st) -#define sk_PKCS12_SAFEBAG_pop_free(st, free_func) SKM_sk_pop_free(PKCS12_SAFEBAG, (st), (free_func)) -#define sk_PKCS12_SAFEBAG_shift(st) SKM_sk_shift(PKCS12_SAFEBAG, (st)) -#define sk_PKCS12_SAFEBAG_pop(st) SKM_sk_pop(PKCS12_SAFEBAG, (st)) -#define sk_PKCS12_SAFEBAG_sort(st) SKM_sk_sort(PKCS12_SAFEBAG, (st)) -#define sk_PKCS12_SAFEBAG_is_sorted(st) SKM_sk_is_sorted(PKCS12_SAFEBAG, (st)) - -#define sk_PKCS7_new(st) SKM_sk_new(PKCS7, (st)) -#define sk_PKCS7_new_null() SKM_sk_new_null(PKCS7) -#define sk_PKCS7_free(st) SKM_sk_free(PKCS7, (st)) -#define sk_PKCS7_num(st) SKM_sk_num(PKCS7, (st)) -#define sk_PKCS7_value(st, i) SKM_sk_value(PKCS7, (st), (i)) -#define sk_PKCS7_set(st, i, val) SKM_sk_set(PKCS7, (st), (i), (val)) -#define sk_PKCS7_zero(st) SKM_sk_zero(PKCS7, (st)) -#define sk_PKCS7_push(st, val) SKM_sk_push(PKCS7, (st), (val)) -#define sk_PKCS7_unshift(st, val) SKM_sk_unshift(PKCS7, (st), (val)) -#define sk_PKCS7_find(st, val) SKM_sk_find(PKCS7, (st), (val)) -#define sk_PKCS7_find_ex(st, val) SKM_sk_find_ex(PKCS7, (st), (val)) -#define sk_PKCS7_delete(st, i) SKM_sk_delete(PKCS7, (st), (i)) -#define sk_PKCS7_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7, (st), (ptr)) -#define sk_PKCS7_insert(st, val, i) SKM_sk_insert(PKCS7, (st), (val), (i)) -#define sk_PKCS7_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7, (st), (cmp)) -#define sk_PKCS7_dup(st) SKM_sk_dup(PKCS7, st) -#define sk_PKCS7_pop_free(st, free_func) SKM_sk_pop_free(PKCS7, (st), (free_func)) -#define sk_PKCS7_shift(st) SKM_sk_shift(PKCS7, (st)) -#define sk_PKCS7_pop(st) SKM_sk_pop(PKCS7, (st)) -#define sk_PKCS7_sort(st) SKM_sk_sort(PKCS7, (st)) -#define sk_PKCS7_is_sorted(st) SKM_sk_is_sorted(PKCS7, (st)) - -#define sk_PKCS7_RECIP_INFO_new(st) SKM_sk_new(PKCS7_RECIP_INFO, (st)) -#define sk_PKCS7_RECIP_INFO_new_null() SKM_sk_new_null(PKCS7_RECIP_INFO) -#define sk_PKCS7_RECIP_INFO_free(st) SKM_sk_free(PKCS7_RECIP_INFO, (st)) -#define sk_PKCS7_RECIP_INFO_num(st) SKM_sk_num(PKCS7_RECIP_INFO, (st)) -#define sk_PKCS7_RECIP_INFO_value(st, i) SKM_sk_value(PKCS7_RECIP_INFO, (st), (i)) -#define sk_PKCS7_RECIP_INFO_set(st, i, val) SKM_sk_set(PKCS7_RECIP_INFO, (st), (i), (val)) -#define sk_PKCS7_RECIP_INFO_zero(st) SKM_sk_zero(PKCS7_RECIP_INFO, (st)) -#define sk_PKCS7_RECIP_INFO_push(st, val) SKM_sk_push(PKCS7_RECIP_INFO, (st), (val)) -#define sk_PKCS7_RECIP_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_RECIP_INFO, (st), (val)) -#define sk_PKCS7_RECIP_INFO_find(st, val) SKM_sk_find(PKCS7_RECIP_INFO, (st), (val)) -#define sk_PKCS7_RECIP_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_RECIP_INFO, (st), (val)) -#define sk_PKCS7_RECIP_INFO_delete(st, i) SKM_sk_delete(PKCS7_RECIP_INFO, (st), (i)) -#define sk_PKCS7_RECIP_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_RECIP_INFO, (st), (ptr)) -#define sk_PKCS7_RECIP_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_RECIP_INFO, (st), (val), (i)) -#define sk_PKCS7_RECIP_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_RECIP_INFO, (st), (cmp)) -#define sk_PKCS7_RECIP_INFO_dup(st) SKM_sk_dup(PKCS7_RECIP_INFO, st) -#define sk_PKCS7_RECIP_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_RECIP_INFO, (st), (free_func)) -#define sk_PKCS7_RECIP_INFO_shift(st) SKM_sk_shift(PKCS7_RECIP_INFO, (st)) -#define sk_PKCS7_RECIP_INFO_pop(st) SKM_sk_pop(PKCS7_RECIP_INFO, (st)) -#define sk_PKCS7_RECIP_INFO_sort(st) SKM_sk_sort(PKCS7_RECIP_INFO, (st)) -#define sk_PKCS7_RECIP_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_RECIP_INFO, (st)) - -#define sk_PKCS7_SIGNER_INFO_new(st) SKM_sk_new(PKCS7_SIGNER_INFO, (st)) -#define sk_PKCS7_SIGNER_INFO_new_null() SKM_sk_new_null(PKCS7_SIGNER_INFO) -#define sk_PKCS7_SIGNER_INFO_free(st) SKM_sk_free(PKCS7_SIGNER_INFO, (st)) -#define sk_PKCS7_SIGNER_INFO_num(st) SKM_sk_num(PKCS7_SIGNER_INFO, (st)) -#define sk_PKCS7_SIGNER_INFO_value(st, i) SKM_sk_value(PKCS7_SIGNER_INFO, (st), (i)) -#define sk_PKCS7_SIGNER_INFO_set(st, i, val) SKM_sk_set(PKCS7_SIGNER_INFO, (st), (i), (val)) -#define sk_PKCS7_SIGNER_INFO_zero(st) SKM_sk_zero(PKCS7_SIGNER_INFO, (st)) -#define sk_PKCS7_SIGNER_INFO_push(st, val) SKM_sk_push(PKCS7_SIGNER_INFO, (st), (val)) -#define sk_PKCS7_SIGNER_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_SIGNER_INFO, (st), (val)) -#define sk_PKCS7_SIGNER_INFO_find(st, val) SKM_sk_find(PKCS7_SIGNER_INFO, (st), (val)) -#define sk_PKCS7_SIGNER_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_SIGNER_INFO, (st), (val)) -#define sk_PKCS7_SIGNER_INFO_delete(st, i) SKM_sk_delete(PKCS7_SIGNER_INFO, (st), (i)) -#define sk_PKCS7_SIGNER_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_SIGNER_INFO, (st), (ptr)) -#define sk_PKCS7_SIGNER_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_SIGNER_INFO, (st), (val), (i)) -#define sk_PKCS7_SIGNER_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_SIGNER_INFO, (st), (cmp)) -#define sk_PKCS7_SIGNER_INFO_dup(st) SKM_sk_dup(PKCS7_SIGNER_INFO, st) -#define sk_PKCS7_SIGNER_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_SIGNER_INFO, (st), (free_func)) -#define sk_PKCS7_SIGNER_INFO_shift(st) SKM_sk_shift(PKCS7_SIGNER_INFO, (st)) -#define sk_PKCS7_SIGNER_INFO_pop(st) SKM_sk_pop(PKCS7_SIGNER_INFO, (st)) -#define sk_PKCS7_SIGNER_INFO_sort(st) SKM_sk_sort(PKCS7_SIGNER_INFO, (st)) -#define sk_PKCS7_SIGNER_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_SIGNER_INFO, (st)) - -#define sk_POLICYINFO_new(st) SKM_sk_new(POLICYINFO, (st)) -#define sk_POLICYINFO_new_null() SKM_sk_new_null(POLICYINFO) -#define sk_POLICYINFO_free(st) SKM_sk_free(POLICYINFO, (st)) -#define sk_POLICYINFO_num(st) SKM_sk_num(POLICYINFO, (st)) -#define sk_POLICYINFO_value(st, i) SKM_sk_value(POLICYINFO, (st), (i)) -#define sk_POLICYINFO_set(st, i, val) SKM_sk_set(POLICYINFO, (st), (i), (val)) -#define sk_POLICYINFO_zero(st) SKM_sk_zero(POLICYINFO, (st)) -#define sk_POLICYINFO_push(st, val) SKM_sk_push(POLICYINFO, (st), (val)) -#define sk_POLICYINFO_unshift(st, val) SKM_sk_unshift(POLICYINFO, (st), (val)) -#define sk_POLICYINFO_find(st, val) SKM_sk_find(POLICYINFO, (st), (val)) -#define sk_POLICYINFO_find_ex(st, val) SKM_sk_find_ex(POLICYINFO, (st), (val)) -#define sk_POLICYINFO_delete(st, i) SKM_sk_delete(POLICYINFO, (st), (i)) -#define sk_POLICYINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYINFO, (st), (ptr)) -#define sk_POLICYINFO_insert(st, val, i) SKM_sk_insert(POLICYINFO, (st), (val), (i)) -#define sk_POLICYINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYINFO, (st), (cmp)) -#define sk_POLICYINFO_dup(st) SKM_sk_dup(POLICYINFO, st) -#define sk_POLICYINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYINFO, (st), (free_func)) -#define sk_POLICYINFO_shift(st) SKM_sk_shift(POLICYINFO, (st)) -#define sk_POLICYINFO_pop(st) SKM_sk_pop(POLICYINFO, (st)) -#define sk_POLICYINFO_sort(st) SKM_sk_sort(POLICYINFO, (st)) -#define sk_POLICYINFO_is_sorted(st) SKM_sk_is_sorted(POLICYINFO, (st)) - -#define sk_POLICYQUALINFO_new(st) SKM_sk_new(POLICYQUALINFO, (st)) -#define sk_POLICYQUALINFO_new_null() SKM_sk_new_null(POLICYQUALINFO) -#define sk_POLICYQUALINFO_free(st) SKM_sk_free(POLICYQUALINFO, (st)) -#define sk_POLICYQUALINFO_num(st) SKM_sk_num(POLICYQUALINFO, (st)) -#define sk_POLICYQUALINFO_value(st, i) SKM_sk_value(POLICYQUALINFO, (st), (i)) -#define sk_POLICYQUALINFO_set(st, i, val) SKM_sk_set(POLICYQUALINFO, (st), (i), (val)) -#define sk_POLICYQUALINFO_zero(st) SKM_sk_zero(POLICYQUALINFO, (st)) -#define sk_POLICYQUALINFO_push(st, val) SKM_sk_push(POLICYQUALINFO, (st), (val)) -#define sk_POLICYQUALINFO_unshift(st, val) SKM_sk_unshift(POLICYQUALINFO, (st), (val)) -#define sk_POLICYQUALINFO_find(st, val) SKM_sk_find(POLICYQUALINFO, (st), (val)) -#define sk_POLICYQUALINFO_find_ex(st, val) SKM_sk_find_ex(POLICYQUALINFO, (st), (val)) -#define sk_POLICYQUALINFO_delete(st, i) SKM_sk_delete(POLICYQUALINFO, (st), (i)) -#define sk_POLICYQUALINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYQUALINFO, (st), (ptr)) -#define sk_POLICYQUALINFO_insert(st, val, i) SKM_sk_insert(POLICYQUALINFO, (st), (val), (i)) -#define sk_POLICYQUALINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYQUALINFO, (st), (cmp)) -#define sk_POLICYQUALINFO_dup(st) SKM_sk_dup(POLICYQUALINFO, st) -#define sk_POLICYQUALINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYQUALINFO, (st), (free_func)) -#define sk_POLICYQUALINFO_shift(st) SKM_sk_shift(POLICYQUALINFO, (st)) -#define sk_POLICYQUALINFO_pop(st) SKM_sk_pop(POLICYQUALINFO, (st)) -#define sk_POLICYQUALINFO_sort(st) SKM_sk_sort(POLICYQUALINFO, (st)) -#define sk_POLICYQUALINFO_is_sorted(st) SKM_sk_is_sorted(POLICYQUALINFO, (st)) - -#define sk_POLICY_MAPPING_new(st) SKM_sk_new(POLICY_MAPPING, (st)) -#define sk_POLICY_MAPPING_new_null() SKM_sk_new_null(POLICY_MAPPING) -#define sk_POLICY_MAPPING_free(st) SKM_sk_free(POLICY_MAPPING, (st)) -#define sk_POLICY_MAPPING_num(st) SKM_sk_num(POLICY_MAPPING, (st)) -#define sk_POLICY_MAPPING_value(st, i) SKM_sk_value(POLICY_MAPPING, (st), (i)) -#define sk_POLICY_MAPPING_set(st, i, val) SKM_sk_set(POLICY_MAPPING, (st), (i), (val)) -#define sk_POLICY_MAPPING_zero(st) SKM_sk_zero(POLICY_MAPPING, (st)) -#define sk_POLICY_MAPPING_push(st, val) SKM_sk_push(POLICY_MAPPING, (st), (val)) -#define sk_POLICY_MAPPING_unshift(st, val) SKM_sk_unshift(POLICY_MAPPING, (st), (val)) -#define sk_POLICY_MAPPING_find(st, val) SKM_sk_find(POLICY_MAPPING, (st), (val)) -#define sk_POLICY_MAPPING_find_ex(st, val) SKM_sk_find_ex(POLICY_MAPPING, (st), (val)) -#define sk_POLICY_MAPPING_delete(st, i) SKM_sk_delete(POLICY_MAPPING, (st), (i)) -#define sk_POLICY_MAPPING_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICY_MAPPING, (st), (ptr)) -#define sk_POLICY_MAPPING_insert(st, val, i) SKM_sk_insert(POLICY_MAPPING, (st), (val), (i)) -#define sk_POLICY_MAPPING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICY_MAPPING, (st), (cmp)) -#define sk_POLICY_MAPPING_dup(st) SKM_sk_dup(POLICY_MAPPING, st) -#define sk_POLICY_MAPPING_pop_free(st, free_func) SKM_sk_pop_free(POLICY_MAPPING, (st), (free_func)) -#define sk_POLICY_MAPPING_shift(st) SKM_sk_shift(POLICY_MAPPING, (st)) -#define sk_POLICY_MAPPING_pop(st) SKM_sk_pop(POLICY_MAPPING, (st)) -#define sk_POLICY_MAPPING_sort(st) SKM_sk_sort(POLICY_MAPPING, (st)) -#define sk_POLICY_MAPPING_is_sorted(st) SKM_sk_is_sorted(POLICY_MAPPING, (st)) - -#define sk_SSL_CIPHER_new(st) SKM_sk_new(SSL_CIPHER, (st)) -#define sk_SSL_CIPHER_new_null() SKM_sk_new_null(SSL_CIPHER) -#define sk_SSL_CIPHER_free(st) SKM_sk_free(SSL_CIPHER, (st)) -#define sk_SSL_CIPHER_num(st) SKM_sk_num(SSL_CIPHER, (st)) -#define sk_SSL_CIPHER_value(st, i) SKM_sk_value(SSL_CIPHER, (st), (i)) -#define sk_SSL_CIPHER_set(st, i, val) SKM_sk_set(SSL_CIPHER, (st), (i), (val)) -#define sk_SSL_CIPHER_zero(st) SKM_sk_zero(SSL_CIPHER, (st)) -#define sk_SSL_CIPHER_push(st, val) SKM_sk_push(SSL_CIPHER, (st), (val)) -#define sk_SSL_CIPHER_unshift(st, val) SKM_sk_unshift(SSL_CIPHER, (st), (val)) -#define sk_SSL_CIPHER_find(st, val) SKM_sk_find(SSL_CIPHER, (st), (val)) -#define sk_SSL_CIPHER_find_ex(st, val) SKM_sk_find_ex(SSL_CIPHER, (st), (val)) -#define sk_SSL_CIPHER_delete(st, i) SKM_sk_delete(SSL_CIPHER, (st), (i)) -#define sk_SSL_CIPHER_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_CIPHER, (st), (ptr)) -#define sk_SSL_CIPHER_insert(st, val, i) SKM_sk_insert(SSL_CIPHER, (st), (val), (i)) -#define sk_SSL_CIPHER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_CIPHER, (st), (cmp)) -#define sk_SSL_CIPHER_dup(st) SKM_sk_dup(SSL_CIPHER, st) -#define sk_SSL_CIPHER_pop_free(st, free_func) SKM_sk_pop_free(SSL_CIPHER, (st), (free_func)) -#define sk_SSL_CIPHER_shift(st) SKM_sk_shift(SSL_CIPHER, (st)) -#define sk_SSL_CIPHER_pop(st) SKM_sk_pop(SSL_CIPHER, (st)) -#define sk_SSL_CIPHER_sort(st) SKM_sk_sort(SSL_CIPHER, (st)) -#define sk_SSL_CIPHER_is_sorted(st) SKM_sk_is_sorted(SSL_CIPHER, (st)) - -#define sk_SSL_COMP_new(st) SKM_sk_new(SSL_COMP, (st)) -#define sk_SSL_COMP_new_null() SKM_sk_new_null(SSL_COMP) -#define sk_SSL_COMP_free(st) SKM_sk_free(SSL_COMP, (st)) -#define sk_SSL_COMP_num(st) SKM_sk_num(SSL_COMP, (st)) -#define sk_SSL_COMP_value(st, i) SKM_sk_value(SSL_COMP, (st), (i)) -#define sk_SSL_COMP_set(st, i, val) SKM_sk_set(SSL_COMP, (st), (i), (val)) -#define sk_SSL_COMP_zero(st) SKM_sk_zero(SSL_COMP, (st)) -#define sk_SSL_COMP_push(st, val) SKM_sk_push(SSL_COMP, (st), (val)) -#define sk_SSL_COMP_unshift(st, val) SKM_sk_unshift(SSL_COMP, (st), (val)) -#define sk_SSL_COMP_find(st, val) SKM_sk_find(SSL_COMP, (st), (val)) -#define sk_SSL_COMP_find_ex(st, val) SKM_sk_find_ex(SSL_COMP, (st), (val)) -#define sk_SSL_COMP_delete(st, i) SKM_sk_delete(SSL_COMP, (st), (i)) -#define sk_SSL_COMP_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_COMP, (st), (ptr)) -#define sk_SSL_COMP_insert(st, val, i) SKM_sk_insert(SSL_COMP, (st), (val), (i)) -#define sk_SSL_COMP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_COMP, (st), (cmp)) -#define sk_SSL_COMP_dup(st) SKM_sk_dup(SSL_COMP, st) -#define sk_SSL_COMP_pop_free(st, free_func) SKM_sk_pop_free(SSL_COMP, (st), (free_func)) -#define sk_SSL_COMP_shift(st) SKM_sk_shift(SSL_COMP, (st)) -#define sk_SSL_COMP_pop(st) SKM_sk_pop(SSL_COMP, (st)) -#define sk_SSL_COMP_sort(st) SKM_sk_sort(SSL_COMP, (st)) -#define sk_SSL_COMP_is_sorted(st) SKM_sk_is_sorted(SSL_COMP, (st)) - -#define sk_STORE_OBJECT_new(st) SKM_sk_new(STORE_OBJECT, (st)) -#define sk_STORE_OBJECT_new_null() SKM_sk_new_null(STORE_OBJECT) -#define sk_STORE_OBJECT_free(st) SKM_sk_free(STORE_OBJECT, (st)) -#define sk_STORE_OBJECT_num(st) SKM_sk_num(STORE_OBJECT, (st)) -#define sk_STORE_OBJECT_value(st, i) SKM_sk_value(STORE_OBJECT, (st), (i)) -#define sk_STORE_OBJECT_set(st, i, val) SKM_sk_set(STORE_OBJECT, (st), (i), (val)) -#define sk_STORE_OBJECT_zero(st) SKM_sk_zero(STORE_OBJECT, (st)) -#define sk_STORE_OBJECT_push(st, val) SKM_sk_push(STORE_OBJECT, (st), (val)) -#define sk_STORE_OBJECT_unshift(st, val) SKM_sk_unshift(STORE_OBJECT, (st), (val)) -#define sk_STORE_OBJECT_find(st, val) SKM_sk_find(STORE_OBJECT, (st), (val)) -#define sk_STORE_OBJECT_find_ex(st, val) SKM_sk_find_ex(STORE_OBJECT, (st), (val)) -#define sk_STORE_OBJECT_delete(st, i) SKM_sk_delete(STORE_OBJECT, (st), (i)) -#define sk_STORE_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_OBJECT, (st), (ptr)) -#define sk_STORE_OBJECT_insert(st, val, i) SKM_sk_insert(STORE_OBJECT, (st), (val), (i)) -#define sk_STORE_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_OBJECT, (st), (cmp)) -#define sk_STORE_OBJECT_dup(st) SKM_sk_dup(STORE_OBJECT, st) -#define sk_STORE_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(STORE_OBJECT, (st), (free_func)) -#define sk_STORE_OBJECT_shift(st) SKM_sk_shift(STORE_OBJECT, (st)) -#define sk_STORE_OBJECT_pop(st) SKM_sk_pop(STORE_OBJECT, (st)) -#define sk_STORE_OBJECT_sort(st) SKM_sk_sort(STORE_OBJECT, (st)) -#define sk_STORE_OBJECT_is_sorted(st) SKM_sk_is_sorted(STORE_OBJECT, (st)) - -#define sk_SXNETID_new(st) SKM_sk_new(SXNETID, (st)) -#define sk_SXNETID_new_null() SKM_sk_new_null(SXNETID) -#define sk_SXNETID_free(st) SKM_sk_free(SXNETID, (st)) -#define sk_SXNETID_num(st) SKM_sk_num(SXNETID, (st)) -#define sk_SXNETID_value(st, i) SKM_sk_value(SXNETID, (st), (i)) -#define sk_SXNETID_set(st, i, val) SKM_sk_set(SXNETID, (st), (i), (val)) -#define sk_SXNETID_zero(st) SKM_sk_zero(SXNETID, (st)) -#define sk_SXNETID_push(st, val) SKM_sk_push(SXNETID, (st), (val)) -#define sk_SXNETID_unshift(st, val) SKM_sk_unshift(SXNETID, (st), (val)) -#define sk_SXNETID_find(st, val) SKM_sk_find(SXNETID, (st), (val)) -#define sk_SXNETID_find_ex(st, val) SKM_sk_find_ex(SXNETID, (st), (val)) -#define sk_SXNETID_delete(st, i) SKM_sk_delete(SXNETID, (st), (i)) -#define sk_SXNETID_delete_ptr(st, ptr) SKM_sk_delete_ptr(SXNETID, (st), (ptr)) -#define sk_SXNETID_insert(st, val, i) SKM_sk_insert(SXNETID, (st), (val), (i)) -#define sk_SXNETID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SXNETID, (st), (cmp)) -#define sk_SXNETID_dup(st) SKM_sk_dup(SXNETID, st) -#define sk_SXNETID_pop_free(st, free_func) SKM_sk_pop_free(SXNETID, (st), (free_func)) -#define sk_SXNETID_shift(st) SKM_sk_shift(SXNETID, (st)) -#define sk_SXNETID_pop(st) SKM_sk_pop(SXNETID, (st)) -#define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st)) -#define sk_SXNETID_is_sorted(st) SKM_sk_is_sorted(SXNETID, (st)) - -#define sk_UI_STRING_new(st) SKM_sk_new(UI_STRING, (st)) -#define sk_UI_STRING_new_null() SKM_sk_new_null(UI_STRING) -#define sk_UI_STRING_free(st) SKM_sk_free(UI_STRING, (st)) -#define sk_UI_STRING_num(st) SKM_sk_num(UI_STRING, (st)) -#define sk_UI_STRING_value(st, i) SKM_sk_value(UI_STRING, (st), (i)) -#define sk_UI_STRING_set(st, i, val) SKM_sk_set(UI_STRING, (st), (i), (val)) -#define sk_UI_STRING_zero(st) SKM_sk_zero(UI_STRING, (st)) -#define sk_UI_STRING_push(st, val) SKM_sk_push(UI_STRING, (st), (val)) -#define sk_UI_STRING_unshift(st, val) SKM_sk_unshift(UI_STRING, (st), (val)) -#define sk_UI_STRING_find(st, val) SKM_sk_find(UI_STRING, (st), (val)) -#define sk_UI_STRING_find_ex(st, val) SKM_sk_find_ex(UI_STRING, (st), (val)) -#define sk_UI_STRING_delete(st, i) SKM_sk_delete(UI_STRING, (st), (i)) -#define sk_UI_STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(UI_STRING, (st), (ptr)) -#define sk_UI_STRING_insert(st, val, i) SKM_sk_insert(UI_STRING, (st), (val), (i)) -#define sk_UI_STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(UI_STRING, (st), (cmp)) -#define sk_UI_STRING_dup(st) SKM_sk_dup(UI_STRING, st) -#define sk_UI_STRING_pop_free(st, free_func) SKM_sk_pop_free(UI_STRING, (st), (free_func)) -#define sk_UI_STRING_shift(st) SKM_sk_shift(UI_STRING, (st)) -#define sk_UI_STRING_pop(st) SKM_sk_pop(UI_STRING, (st)) -#define sk_UI_STRING_sort(st) SKM_sk_sort(UI_STRING, (st)) -#define sk_UI_STRING_is_sorted(st) SKM_sk_is_sorted(UI_STRING, (st)) - -#define sk_X509_new(st) SKM_sk_new(X509, (st)) -#define sk_X509_new_null() SKM_sk_new_null(X509) -#define sk_X509_free(st) SKM_sk_free(X509, (st)) -#define sk_X509_num(st) SKM_sk_num(X509, (st)) -#define sk_X509_value(st, i) SKM_sk_value(X509, (st), (i)) -#define sk_X509_set(st, i, val) SKM_sk_set(X509, (st), (i), (val)) -#define sk_X509_zero(st) SKM_sk_zero(X509, (st)) -#define sk_X509_push(st, val) SKM_sk_push(X509, (st), (val)) -#define sk_X509_unshift(st, val) SKM_sk_unshift(X509, (st), (val)) -#define sk_X509_find(st, val) SKM_sk_find(X509, (st), (val)) -#define sk_X509_find_ex(st, val) SKM_sk_find_ex(X509, (st), (val)) -#define sk_X509_delete(st, i) SKM_sk_delete(X509, (st), (i)) -#define sk_X509_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509, (st), (ptr)) -#define sk_X509_insert(st, val, i) SKM_sk_insert(X509, (st), (val), (i)) -#define sk_X509_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509, (st), (cmp)) -#define sk_X509_dup(st) SKM_sk_dup(X509, st) -#define sk_X509_pop_free(st, free_func) SKM_sk_pop_free(X509, (st), (free_func)) -#define sk_X509_shift(st) SKM_sk_shift(X509, (st)) -#define sk_X509_pop(st) SKM_sk_pop(X509, (st)) -#define sk_X509_sort(st) SKM_sk_sort(X509, (st)) -#define sk_X509_is_sorted(st) SKM_sk_is_sorted(X509, (st)) - -#define sk_X509V3_EXT_METHOD_new(st) SKM_sk_new(X509V3_EXT_METHOD, (st)) -#define sk_X509V3_EXT_METHOD_new_null() SKM_sk_new_null(X509V3_EXT_METHOD) -#define sk_X509V3_EXT_METHOD_free(st) SKM_sk_free(X509V3_EXT_METHOD, (st)) -#define sk_X509V3_EXT_METHOD_num(st) SKM_sk_num(X509V3_EXT_METHOD, (st)) -#define sk_X509V3_EXT_METHOD_value(st, i) SKM_sk_value(X509V3_EXT_METHOD, (st), (i)) -#define sk_X509V3_EXT_METHOD_set(st, i, val) SKM_sk_set(X509V3_EXT_METHOD, (st), (i), (val)) -#define sk_X509V3_EXT_METHOD_zero(st) SKM_sk_zero(X509V3_EXT_METHOD, (st)) -#define sk_X509V3_EXT_METHOD_push(st, val) SKM_sk_push(X509V3_EXT_METHOD, (st), (val)) -#define sk_X509V3_EXT_METHOD_unshift(st, val) SKM_sk_unshift(X509V3_EXT_METHOD, (st), (val)) -#define sk_X509V3_EXT_METHOD_find(st, val) SKM_sk_find(X509V3_EXT_METHOD, (st), (val)) -#define sk_X509V3_EXT_METHOD_find_ex(st, val) SKM_sk_find_ex(X509V3_EXT_METHOD, (st), (val)) -#define sk_X509V3_EXT_METHOD_delete(st, i) SKM_sk_delete(X509V3_EXT_METHOD, (st), (i)) -#define sk_X509V3_EXT_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509V3_EXT_METHOD, (st), (ptr)) -#define sk_X509V3_EXT_METHOD_insert(st, val, i) SKM_sk_insert(X509V3_EXT_METHOD, (st), (val), (i)) -#define sk_X509V3_EXT_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509V3_EXT_METHOD, (st), (cmp)) -#define sk_X509V3_EXT_METHOD_dup(st) SKM_sk_dup(X509V3_EXT_METHOD, st) -#define sk_X509V3_EXT_METHOD_pop_free(st, free_func) SKM_sk_pop_free(X509V3_EXT_METHOD, (st), (free_func)) -#define sk_X509V3_EXT_METHOD_shift(st) SKM_sk_shift(X509V3_EXT_METHOD, (st)) -#define sk_X509V3_EXT_METHOD_pop(st) SKM_sk_pop(X509V3_EXT_METHOD, (st)) -#define sk_X509V3_EXT_METHOD_sort(st) SKM_sk_sort(X509V3_EXT_METHOD, (st)) -#define sk_X509V3_EXT_METHOD_is_sorted(st) SKM_sk_is_sorted(X509V3_EXT_METHOD, (st)) - -#define sk_X509_ALGOR_new(st) SKM_sk_new(X509_ALGOR, (st)) -#define sk_X509_ALGOR_new_null() SKM_sk_new_null(X509_ALGOR) -#define sk_X509_ALGOR_free(st) SKM_sk_free(X509_ALGOR, (st)) -#define sk_X509_ALGOR_num(st) SKM_sk_num(X509_ALGOR, (st)) -#define sk_X509_ALGOR_value(st, i) SKM_sk_value(X509_ALGOR, (st), (i)) -#define sk_X509_ALGOR_set(st, i, val) SKM_sk_set(X509_ALGOR, (st), (i), (val)) -#define sk_X509_ALGOR_zero(st) SKM_sk_zero(X509_ALGOR, (st)) -#define sk_X509_ALGOR_push(st, val) SKM_sk_push(X509_ALGOR, (st), (val)) -#define sk_X509_ALGOR_unshift(st, val) SKM_sk_unshift(X509_ALGOR, (st), (val)) -#define sk_X509_ALGOR_find(st, val) SKM_sk_find(X509_ALGOR, (st), (val)) -#define sk_X509_ALGOR_find_ex(st, val) SKM_sk_find_ex(X509_ALGOR, (st), (val)) -#define sk_X509_ALGOR_delete(st, i) SKM_sk_delete(X509_ALGOR, (st), (i)) -#define sk_X509_ALGOR_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ALGOR, (st), (ptr)) -#define sk_X509_ALGOR_insert(st, val, i) SKM_sk_insert(X509_ALGOR, (st), (val), (i)) -#define sk_X509_ALGOR_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ALGOR, (st), (cmp)) -#define sk_X509_ALGOR_dup(st) SKM_sk_dup(X509_ALGOR, st) -#define sk_X509_ALGOR_pop_free(st, free_func) SKM_sk_pop_free(X509_ALGOR, (st), (free_func)) -#define sk_X509_ALGOR_shift(st) SKM_sk_shift(X509_ALGOR, (st)) -#define sk_X509_ALGOR_pop(st) SKM_sk_pop(X509_ALGOR, (st)) -#define sk_X509_ALGOR_sort(st) SKM_sk_sort(X509_ALGOR, (st)) -#define sk_X509_ALGOR_is_sorted(st) SKM_sk_is_sorted(X509_ALGOR, (st)) - -#define sk_X509_ATTRIBUTE_new(st) SKM_sk_new(X509_ATTRIBUTE, (st)) -#define sk_X509_ATTRIBUTE_new_null() SKM_sk_new_null(X509_ATTRIBUTE) -#define sk_X509_ATTRIBUTE_free(st) SKM_sk_free(X509_ATTRIBUTE, (st)) -#define sk_X509_ATTRIBUTE_num(st) SKM_sk_num(X509_ATTRIBUTE, (st)) -#define sk_X509_ATTRIBUTE_value(st, i) SKM_sk_value(X509_ATTRIBUTE, (st), (i)) -#define sk_X509_ATTRIBUTE_set(st, i, val) SKM_sk_set(X509_ATTRIBUTE, (st), (i), (val)) -#define sk_X509_ATTRIBUTE_zero(st) SKM_sk_zero(X509_ATTRIBUTE, (st)) -#define sk_X509_ATTRIBUTE_push(st, val) SKM_sk_push(X509_ATTRIBUTE, (st), (val)) -#define sk_X509_ATTRIBUTE_unshift(st, val) SKM_sk_unshift(X509_ATTRIBUTE, (st), (val)) -#define sk_X509_ATTRIBUTE_find(st, val) SKM_sk_find(X509_ATTRIBUTE, (st), (val)) -#define sk_X509_ATTRIBUTE_find_ex(st, val) SKM_sk_find_ex(X509_ATTRIBUTE, (st), (val)) -#define sk_X509_ATTRIBUTE_delete(st, i) SKM_sk_delete(X509_ATTRIBUTE, (st), (i)) -#define sk_X509_ATTRIBUTE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ATTRIBUTE, (st), (ptr)) -#define sk_X509_ATTRIBUTE_insert(st, val, i) SKM_sk_insert(X509_ATTRIBUTE, (st), (val), (i)) -#define sk_X509_ATTRIBUTE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ATTRIBUTE, (st), (cmp)) -#define sk_X509_ATTRIBUTE_dup(st) SKM_sk_dup(X509_ATTRIBUTE, st) -#define sk_X509_ATTRIBUTE_pop_free(st, free_func) SKM_sk_pop_free(X509_ATTRIBUTE, (st), (free_func)) -#define sk_X509_ATTRIBUTE_shift(st) SKM_sk_shift(X509_ATTRIBUTE, (st)) -#define sk_X509_ATTRIBUTE_pop(st) SKM_sk_pop(X509_ATTRIBUTE, (st)) -#define sk_X509_ATTRIBUTE_sort(st) SKM_sk_sort(X509_ATTRIBUTE, (st)) -#define sk_X509_ATTRIBUTE_is_sorted(st) SKM_sk_is_sorted(X509_ATTRIBUTE, (st)) - -#define sk_X509_CRL_new(st) SKM_sk_new(X509_CRL, (st)) -#define sk_X509_CRL_new_null() SKM_sk_new_null(X509_CRL) -#define sk_X509_CRL_free(st) SKM_sk_free(X509_CRL, (st)) -#define sk_X509_CRL_num(st) SKM_sk_num(X509_CRL, (st)) -#define sk_X509_CRL_value(st, i) SKM_sk_value(X509_CRL, (st), (i)) -#define sk_X509_CRL_set(st, i, val) SKM_sk_set(X509_CRL, (st), (i), (val)) -#define sk_X509_CRL_zero(st) SKM_sk_zero(X509_CRL, (st)) -#define sk_X509_CRL_push(st, val) SKM_sk_push(X509_CRL, (st), (val)) -#define sk_X509_CRL_unshift(st, val) SKM_sk_unshift(X509_CRL, (st), (val)) -#define sk_X509_CRL_find(st, val) SKM_sk_find(X509_CRL, (st), (val)) -#define sk_X509_CRL_find_ex(st, val) SKM_sk_find_ex(X509_CRL, (st), (val)) -#define sk_X509_CRL_delete(st, i) SKM_sk_delete(X509_CRL, (st), (i)) -#define sk_X509_CRL_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_CRL, (st), (ptr)) -#define sk_X509_CRL_insert(st, val, i) SKM_sk_insert(X509_CRL, (st), (val), (i)) -#define sk_X509_CRL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_CRL, (st), (cmp)) -#define sk_X509_CRL_dup(st) SKM_sk_dup(X509_CRL, st) -#define sk_X509_CRL_pop_free(st, free_func) SKM_sk_pop_free(X509_CRL, (st), (free_func)) -#define sk_X509_CRL_shift(st) SKM_sk_shift(X509_CRL, (st)) -#define sk_X509_CRL_pop(st) SKM_sk_pop(X509_CRL, (st)) -#define sk_X509_CRL_sort(st) SKM_sk_sort(X509_CRL, (st)) -#define sk_X509_CRL_is_sorted(st) SKM_sk_is_sorted(X509_CRL, (st)) - -#define sk_X509_EXTENSION_new(st) SKM_sk_new(X509_EXTENSION, (st)) -#define sk_X509_EXTENSION_new_null() SKM_sk_new_null(X509_EXTENSION) -#define sk_X509_EXTENSION_free(st) SKM_sk_free(X509_EXTENSION, (st)) -#define sk_X509_EXTENSION_num(st) SKM_sk_num(X509_EXTENSION, (st)) -#define sk_X509_EXTENSION_value(st, i) SKM_sk_value(X509_EXTENSION, (st), (i)) -#define sk_X509_EXTENSION_set(st, i, val) SKM_sk_set(X509_EXTENSION, (st), (i), (val)) -#define sk_X509_EXTENSION_zero(st) SKM_sk_zero(X509_EXTENSION, (st)) -#define sk_X509_EXTENSION_push(st, val) SKM_sk_push(X509_EXTENSION, (st), (val)) -#define sk_X509_EXTENSION_unshift(st, val) SKM_sk_unshift(X509_EXTENSION, (st), (val)) -#define sk_X509_EXTENSION_find(st, val) SKM_sk_find(X509_EXTENSION, (st), (val)) -#define sk_X509_EXTENSION_find_ex(st, val) SKM_sk_find_ex(X509_EXTENSION, (st), (val)) -#define sk_X509_EXTENSION_delete(st, i) SKM_sk_delete(X509_EXTENSION, (st), (i)) -#define sk_X509_EXTENSION_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_EXTENSION, (st), (ptr)) -#define sk_X509_EXTENSION_insert(st, val, i) SKM_sk_insert(X509_EXTENSION, (st), (val), (i)) -#define sk_X509_EXTENSION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_EXTENSION, (st), (cmp)) -#define sk_X509_EXTENSION_dup(st) SKM_sk_dup(X509_EXTENSION, st) -#define sk_X509_EXTENSION_pop_free(st, free_func) SKM_sk_pop_free(X509_EXTENSION, (st), (free_func)) -#define sk_X509_EXTENSION_shift(st) SKM_sk_shift(X509_EXTENSION, (st)) -#define sk_X509_EXTENSION_pop(st) SKM_sk_pop(X509_EXTENSION, (st)) -#define sk_X509_EXTENSION_sort(st) SKM_sk_sort(X509_EXTENSION, (st)) -#define sk_X509_EXTENSION_is_sorted(st) SKM_sk_is_sorted(X509_EXTENSION, (st)) - -#define sk_X509_INFO_new(st) SKM_sk_new(X509_INFO, (st)) -#define sk_X509_INFO_new_null() SKM_sk_new_null(X509_INFO) -#define sk_X509_INFO_free(st) SKM_sk_free(X509_INFO, (st)) -#define sk_X509_INFO_num(st) SKM_sk_num(X509_INFO, (st)) -#define sk_X509_INFO_value(st, i) SKM_sk_value(X509_INFO, (st), (i)) -#define sk_X509_INFO_set(st, i, val) SKM_sk_set(X509_INFO, (st), (i), (val)) -#define sk_X509_INFO_zero(st) SKM_sk_zero(X509_INFO, (st)) -#define sk_X509_INFO_push(st, val) SKM_sk_push(X509_INFO, (st), (val)) -#define sk_X509_INFO_unshift(st, val) SKM_sk_unshift(X509_INFO, (st), (val)) -#define sk_X509_INFO_find(st, val) SKM_sk_find(X509_INFO, (st), (val)) -#define sk_X509_INFO_find_ex(st, val) SKM_sk_find_ex(X509_INFO, (st), (val)) -#define sk_X509_INFO_delete(st, i) SKM_sk_delete(X509_INFO, (st), (i)) -#define sk_X509_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_INFO, (st), (ptr)) -#define sk_X509_INFO_insert(st, val, i) SKM_sk_insert(X509_INFO, (st), (val), (i)) -#define sk_X509_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_INFO, (st), (cmp)) -#define sk_X509_INFO_dup(st) SKM_sk_dup(X509_INFO, st) -#define sk_X509_INFO_pop_free(st, free_func) SKM_sk_pop_free(X509_INFO, (st), (free_func)) -#define sk_X509_INFO_shift(st) SKM_sk_shift(X509_INFO, (st)) -#define sk_X509_INFO_pop(st) SKM_sk_pop(X509_INFO, (st)) -#define sk_X509_INFO_sort(st) SKM_sk_sort(X509_INFO, (st)) -#define sk_X509_INFO_is_sorted(st) SKM_sk_is_sorted(X509_INFO, (st)) - -#define sk_X509_LOOKUP_new(st) SKM_sk_new(X509_LOOKUP, (st)) -#define sk_X509_LOOKUP_new_null() SKM_sk_new_null(X509_LOOKUP) -#define sk_X509_LOOKUP_free(st) SKM_sk_free(X509_LOOKUP, (st)) -#define sk_X509_LOOKUP_num(st) SKM_sk_num(X509_LOOKUP, (st)) -#define sk_X509_LOOKUP_value(st, i) SKM_sk_value(X509_LOOKUP, (st), (i)) -#define sk_X509_LOOKUP_set(st, i, val) SKM_sk_set(X509_LOOKUP, (st), (i), (val)) -#define sk_X509_LOOKUP_zero(st) SKM_sk_zero(X509_LOOKUP, (st)) -#define sk_X509_LOOKUP_push(st, val) SKM_sk_push(X509_LOOKUP, (st), (val)) -#define sk_X509_LOOKUP_unshift(st, val) SKM_sk_unshift(X509_LOOKUP, (st), (val)) -#define sk_X509_LOOKUP_find(st, val) SKM_sk_find(X509_LOOKUP, (st), (val)) -#define sk_X509_LOOKUP_find_ex(st, val) SKM_sk_find_ex(X509_LOOKUP, (st), (val)) -#define sk_X509_LOOKUP_delete(st, i) SKM_sk_delete(X509_LOOKUP, (st), (i)) -#define sk_X509_LOOKUP_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_LOOKUP, (st), (ptr)) -#define sk_X509_LOOKUP_insert(st, val, i) SKM_sk_insert(X509_LOOKUP, (st), (val), (i)) -#define sk_X509_LOOKUP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_LOOKUP, (st), (cmp)) -#define sk_X509_LOOKUP_dup(st) SKM_sk_dup(X509_LOOKUP, st) -#define sk_X509_LOOKUP_pop_free(st, free_func) SKM_sk_pop_free(X509_LOOKUP, (st), (free_func)) -#define sk_X509_LOOKUP_shift(st) SKM_sk_shift(X509_LOOKUP, (st)) -#define sk_X509_LOOKUP_pop(st) SKM_sk_pop(X509_LOOKUP, (st)) -#define sk_X509_LOOKUP_sort(st) SKM_sk_sort(X509_LOOKUP, (st)) -#define sk_X509_LOOKUP_is_sorted(st) SKM_sk_is_sorted(X509_LOOKUP, (st)) - -#define sk_X509_NAME_new(st) SKM_sk_new(X509_NAME, (st)) -#define sk_X509_NAME_new_null() SKM_sk_new_null(X509_NAME) -#define sk_X509_NAME_free(st) SKM_sk_free(X509_NAME, (st)) -#define sk_X509_NAME_num(st) SKM_sk_num(X509_NAME, (st)) -#define sk_X509_NAME_value(st, i) SKM_sk_value(X509_NAME, (st), (i)) -#define sk_X509_NAME_set(st, i, val) SKM_sk_set(X509_NAME, (st), (i), (val)) -#define sk_X509_NAME_zero(st) SKM_sk_zero(X509_NAME, (st)) -#define sk_X509_NAME_push(st, val) SKM_sk_push(X509_NAME, (st), (val)) -#define sk_X509_NAME_unshift(st, val) SKM_sk_unshift(X509_NAME, (st), (val)) -#define sk_X509_NAME_find(st, val) SKM_sk_find(X509_NAME, (st), (val)) -#define sk_X509_NAME_find_ex(st, val) SKM_sk_find_ex(X509_NAME, (st), (val)) -#define sk_X509_NAME_delete(st, i) SKM_sk_delete(X509_NAME, (st), (i)) -#define sk_X509_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME, (st), (ptr)) -#define sk_X509_NAME_insert(st, val, i) SKM_sk_insert(X509_NAME, (st), (val), (i)) -#define sk_X509_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME, (st), (cmp)) -#define sk_X509_NAME_dup(st) SKM_sk_dup(X509_NAME, st) -#define sk_X509_NAME_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME, (st), (free_func)) -#define sk_X509_NAME_shift(st) SKM_sk_shift(X509_NAME, (st)) -#define sk_X509_NAME_pop(st) SKM_sk_pop(X509_NAME, (st)) -#define sk_X509_NAME_sort(st) SKM_sk_sort(X509_NAME, (st)) -#define sk_X509_NAME_is_sorted(st) SKM_sk_is_sorted(X509_NAME, (st)) - -#define sk_X509_NAME_ENTRY_new(st) SKM_sk_new(X509_NAME_ENTRY, (st)) -#define sk_X509_NAME_ENTRY_new_null() SKM_sk_new_null(X509_NAME_ENTRY) -#define sk_X509_NAME_ENTRY_free(st) SKM_sk_free(X509_NAME_ENTRY, (st)) -#define sk_X509_NAME_ENTRY_num(st) SKM_sk_num(X509_NAME_ENTRY, (st)) -#define sk_X509_NAME_ENTRY_value(st, i) SKM_sk_value(X509_NAME_ENTRY, (st), (i)) -#define sk_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(X509_NAME_ENTRY, (st), (i), (val)) -#define sk_X509_NAME_ENTRY_zero(st) SKM_sk_zero(X509_NAME_ENTRY, (st)) -#define sk_X509_NAME_ENTRY_push(st, val) SKM_sk_push(X509_NAME_ENTRY, (st), (val)) -#define sk_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(X509_NAME_ENTRY, (st), (val)) -#define sk_X509_NAME_ENTRY_find(st, val) SKM_sk_find(X509_NAME_ENTRY, (st), (val)) -#define sk_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(X509_NAME_ENTRY, (st), (val)) -#define sk_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(X509_NAME_ENTRY, (st), (i)) -#define sk_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME_ENTRY, (st), (ptr)) -#define sk_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(X509_NAME_ENTRY, (st), (val), (i)) -#define sk_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME_ENTRY, (st), (cmp)) -#define sk_X509_NAME_ENTRY_dup(st) SKM_sk_dup(X509_NAME_ENTRY, st) -#define sk_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME_ENTRY, (st), (free_func)) -#define sk_X509_NAME_ENTRY_shift(st) SKM_sk_shift(X509_NAME_ENTRY, (st)) -#define sk_X509_NAME_ENTRY_pop(st) SKM_sk_pop(X509_NAME_ENTRY, (st)) -#define sk_X509_NAME_ENTRY_sort(st) SKM_sk_sort(X509_NAME_ENTRY, (st)) -#define sk_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(X509_NAME_ENTRY, (st)) - -#define sk_X509_OBJECT_new(st) SKM_sk_new(X509_OBJECT, (st)) -#define sk_X509_OBJECT_new_null() SKM_sk_new_null(X509_OBJECT) -#define sk_X509_OBJECT_free(st) SKM_sk_free(X509_OBJECT, (st)) -#define sk_X509_OBJECT_num(st) SKM_sk_num(X509_OBJECT, (st)) -#define sk_X509_OBJECT_value(st, i) SKM_sk_value(X509_OBJECT, (st), (i)) -#define sk_X509_OBJECT_set(st, i, val) SKM_sk_set(X509_OBJECT, (st), (i), (val)) -#define sk_X509_OBJECT_zero(st) SKM_sk_zero(X509_OBJECT, (st)) -#define sk_X509_OBJECT_push(st, val) SKM_sk_push(X509_OBJECT, (st), (val)) -#define sk_X509_OBJECT_unshift(st, val) SKM_sk_unshift(X509_OBJECT, (st), (val)) -#define sk_X509_OBJECT_find(st, val) SKM_sk_find(X509_OBJECT, (st), (val)) -#define sk_X509_OBJECT_find_ex(st, val) SKM_sk_find_ex(X509_OBJECT, (st), (val)) -#define sk_X509_OBJECT_delete(st, i) SKM_sk_delete(X509_OBJECT, (st), (i)) -#define sk_X509_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_OBJECT, (st), (ptr)) -#define sk_X509_OBJECT_insert(st, val, i) SKM_sk_insert(X509_OBJECT, (st), (val), (i)) -#define sk_X509_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_OBJECT, (st), (cmp)) -#define sk_X509_OBJECT_dup(st) SKM_sk_dup(X509_OBJECT, st) -#define sk_X509_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(X509_OBJECT, (st), (free_func)) -#define sk_X509_OBJECT_shift(st) SKM_sk_shift(X509_OBJECT, (st)) -#define sk_X509_OBJECT_pop(st) SKM_sk_pop(X509_OBJECT, (st)) -#define sk_X509_OBJECT_sort(st) SKM_sk_sort(X509_OBJECT, (st)) -#define sk_X509_OBJECT_is_sorted(st) SKM_sk_is_sorted(X509_OBJECT, (st)) - -#define sk_X509_POLICY_DATA_new(st) SKM_sk_new(X509_POLICY_DATA, (st)) -#define sk_X509_POLICY_DATA_new_null() SKM_sk_new_null(X509_POLICY_DATA) -#define sk_X509_POLICY_DATA_free(st) SKM_sk_free(X509_POLICY_DATA, (st)) -#define sk_X509_POLICY_DATA_num(st) SKM_sk_num(X509_POLICY_DATA, (st)) -#define sk_X509_POLICY_DATA_value(st, i) SKM_sk_value(X509_POLICY_DATA, (st), (i)) -#define sk_X509_POLICY_DATA_set(st, i, val) SKM_sk_set(X509_POLICY_DATA, (st), (i), (val)) -#define sk_X509_POLICY_DATA_zero(st) SKM_sk_zero(X509_POLICY_DATA, (st)) -#define sk_X509_POLICY_DATA_push(st, val) SKM_sk_push(X509_POLICY_DATA, (st), (val)) -#define sk_X509_POLICY_DATA_unshift(st, val) SKM_sk_unshift(X509_POLICY_DATA, (st), (val)) -#define sk_X509_POLICY_DATA_find(st, val) SKM_sk_find(X509_POLICY_DATA, (st), (val)) -#define sk_X509_POLICY_DATA_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_DATA, (st), (val)) -#define sk_X509_POLICY_DATA_delete(st, i) SKM_sk_delete(X509_POLICY_DATA, (st), (i)) -#define sk_X509_POLICY_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_DATA, (st), (ptr)) -#define sk_X509_POLICY_DATA_insert(st, val, i) SKM_sk_insert(X509_POLICY_DATA, (st), (val), (i)) -#define sk_X509_POLICY_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_DATA, (st), (cmp)) -#define sk_X509_POLICY_DATA_dup(st) SKM_sk_dup(X509_POLICY_DATA, st) -#define sk_X509_POLICY_DATA_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_DATA, (st), (free_func)) -#define sk_X509_POLICY_DATA_shift(st) SKM_sk_shift(X509_POLICY_DATA, (st)) -#define sk_X509_POLICY_DATA_pop(st) SKM_sk_pop(X509_POLICY_DATA, (st)) -#define sk_X509_POLICY_DATA_sort(st) SKM_sk_sort(X509_POLICY_DATA, (st)) -#define sk_X509_POLICY_DATA_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_DATA, (st)) - -#define sk_X509_POLICY_NODE_new(st) SKM_sk_new(X509_POLICY_NODE, (st)) -#define sk_X509_POLICY_NODE_new_null() SKM_sk_new_null(X509_POLICY_NODE) -#define sk_X509_POLICY_NODE_free(st) SKM_sk_free(X509_POLICY_NODE, (st)) -#define sk_X509_POLICY_NODE_num(st) SKM_sk_num(X509_POLICY_NODE, (st)) -#define sk_X509_POLICY_NODE_value(st, i) SKM_sk_value(X509_POLICY_NODE, (st), (i)) -#define sk_X509_POLICY_NODE_set(st, i, val) SKM_sk_set(X509_POLICY_NODE, (st), (i), (val)) -#define sk_X509_POLICY_NODE_zero(st) SKM_sk_zero(X509_POLICY_NODE, (st)) -#define sk_X509_POLICY_NODE_push(st, val) SKM_sk_push(X509_POLICY_NODE, (st), (val)) -#define sk_X509_POLICY_NODE_unshift(st, val) SKM_sk_unshift(X509_POLICY_NODE, (st), (val)) -#define sk_X509_POLICY_NODE_find(st, val) SKM_sk_find(X509_POLICY_NODE, (st), (val)) -#define sk_X509_POLICY_NODE_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_NODE, (st), (val)) -#define sk_X509_POLICY_NODE_delete(st, i) SKM_sk_delete(X509_POLICY_NODE, (st), (i)) -#define sk_X509_POLICY_NODE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_NODE, (st), (ptr)) -#define sk_X509_POLICY_NODE_insert(st, val, i) SKM_sk_insert(X509_POLICY_NODE, (st), (val), (i)) -#define sk_X509_POLICY_NODE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_NODE, (st), (cmp)) -#define sk_X509_POLICY_NODE_dup(st) SKM_sk_dup(X509_POLICY_NODE, st) -#define sk_X509_POLICY_NODE_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_NODE, (st), (free_func)) -#define sk_X509_POLICY_NODE_shift(st) SKM_sk_shift(X509_POLICY_NODE, (st)) -#define sk_X509_POLICY_NODE_pop(st) SKM_sk_pop(X509_POLICY_NODE, (st)) -#define sk_X509_POLICY_NODE_sort(st) SKM_sk_sort(X509_POLICY_NODE, (st)) -#define sk_X509_POLICY_NODE_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_NODE, (st)) - -#define sk_X509_POLICY_REF_new(st) SKM_sk_new(X509_POLICY_REF, (st)) -#define sk_X509_POLICY_REF_new_null() SKM_sk_new_null(X509_POLICY_REF) -#define sk_X509_POLICY_REF_free(st) SKM_sk_free(X509_POLICY_REF, (st)) -#define sk_X509_POLICY_REF_num(st) SKM_sk_num(X509_POLICY_REF, (st)) -#define sk_X509_POLICY_REF_value(st, i) SKM_sk_value(X509_POLICY_REF, (st), (i)) -#define sk_X509_POLICY_REF_set(st, i, val) SKM_sk_set(X509_POLICY_REF, (st), (i), (val)) -#define sk_X509_POLICY_REF_zero(st) SKM_sk_zero(X509_POLICY_REF, (st)) -#define sk_X509_POLICY_REF_push(st, val) SKM_sk_push(X509_POLICY_REF, (st), (val)) -#define sk_X509_POLICY_REF_unshift(st, val) SKM_sk_unshift(X509_POLICY_REF, (st), (val)) -#define sk_X509_POLICY_REF_find(st, val) SKM_sk_find(X509_POLICY_REF, (st), (val)) -#define sk_X509_POLICY_REF_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_REF, (st), (val)) -#define sk_X509_POLICY_REF_delete(st, i) SKM_sk_delete(X509_POLICY_REF, (st), (i)) -#define sk_X509_POLICY_REF_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_REF, (st), (ptr)) -#define sk_X509_POLICY_REF_insert(st, val, i) SKM_sk_insert(X509_POLICY_REF, (st), (val), (i)) -#define sk_X509_POLICY_REF_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_REF, (st), (cmp)) -#define sk_X509_POLICY_REF_dup(st) SKM_sk_dup(X509_POLICY_REF, st) -#define sk_X509_POLICY_REF_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_REF, (st), (free_func)) -#define sk_X509_POLICY_REF_shift(st) SKM_sk_shift(X509_POLICY_REF, (st)) -#define sk_X509_POLICY_REF_pop(st) SKM_sk_pop(X509_POLICY_REF, (st)) -#define sk_X509_POLICY_REF_sort(st) SKM_sk_sort(X509_POLICY_REF, (st)) -#define sk_X509_POLICY_REF_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_REF, (st)) - -#define sk_X509_PURPOSE_new(st) SKM_sk_new(X509_PURPOSE, (st)) -#define sk_X509_PURPOSE_new_null() SKM_sk_new_null(X509_PURPOSE) -#define sk_X509_PURPOSE_free(st) SKM_sk_free(X509_PURPOSE, (st)) -#define sk_X509_PURPOSE_num(st) SKM_sk_num(X509_PURPOSE, (st)) -#define sk_X509_PURPOSE_value(st, i) SKM_sk_value(X509_PURPOSE, (st), (i)) -#define sk_X509_PURPOSE_set(st, i, val) SKM_sk_set(X509_PURPOSE, (st), (i), (val)) -#define sk_X509_PURPOSE_zero(st) SKM_sk_zero(X509_PURPOSE, (st)) -#define sk_X509_PURPOSE_push(st, val) SKM_sk_push(X509_PURPOSE, (st), (val)) -#define sk_X509_PURPOSE_unshift(st, val) SKM_sk_unshift(X509_PURPOSE, (st), (val)) -#define sk_X509_PURPOSE_find(st, val) SKM_sk_find(X509_PURPOSE, (st), (val)) -#define sk_X509_PURPOSE_find_ex(st, val) SKM_sk_find_ex(X509_PURPOSE, (st), (val)) -#define sk_X509_PURPOSE_delete(st, i) SKM_sk_delete(X509_PURPOSE, (st), (i)) -#define sk_X509_PURPOSE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_PURPOSE, (st), (ptr)) -#define sk_X509_PURPOSE_insert(st, val, i) SKM_sk_insert(X509_PURPOSE, (st), (val), (i)) -#define sk_X509_PURPOSE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_PURPOSE, (st), (cmp)) -#define sk_X509_PURPOSE_dup(st) SKM_sk_dup(X509_PURPOSE, st) -#define sk_X509_PURPOSE_pop_free(st, free_func) SKM_sk_pop_free(X509_PURPOSE, (st), (free_func)) -#define sk_X509_PURPOSE_shift(st) SKM_sk_shift(X509_PURPOSE, (st)) -#define sk_X509_PURPOSE_pop(st) SKM_sk_pop(X509_PURPOSE, (st)) -#define sk_X509_PURPOSE_sort(st) SKM_sk_sort(X509_PURPOSE, (st)) -#define sk_X509_PURPOSE_is_sorted(st) SKM_sk_is_sorted(X509_PURPOSE, (st)) - -#define sk_X509_REVOKED_new(st) SKM_sk_new(X509_REVOKED, (st)) -#define sk_X509_REVOKED_new_null() SKM_sk_new_null(X509_REVOKED) -#define sk_X509_REVOKED_free(st) SKM_sk_free(X509_REVOKED, (st)) -#define sk_X509_REVOKED_num(st) SKM_sk_num(X509_REVOKED, (st)) -#define sk_X509_REVOKED_value(st, i) SKM_sk_value(X509_REVOKED, (st), (i)) -#define sk_X509_REVOKED_set(st, i, val) SKM_sk_set(X509_REVOKED, (st), (i), (val)) -#define sk_X509_REVOKED_zero(st) SKM_sk_zero(X509_REVOKED, (st)) -#define sk_X509_REVOKED_push(st, val) SKM_sk_push(X509_REVOKED, (st), (val)) -#define sk_X509_REVOKED_unshift(st, val) SKM_sk_unshift(X509_REVOKED, (st), (val)) -#define sk_X509_REVOKED_find(st, val) SKM_sk_find(X509_REVOKED, (st), (val)) -#define sk_X509_REVOKED_find_ex(st, val) SKM_sk_find_ex(X509_REVOKED, (st), (val)) -#define sk_X509_REVOKED_delete(st, i) SKM_sk_delete(X509_REVOKED, (st), (i)) -#define sk_X509_REVOKED_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_REVOKED, (st), (ptr)) -#define sk_X509_REVOKED_insert(st, val, i) SKM_sk_insert(X509_REVOKED, (st), (val), (i)) -#define sk_X509_REVOKED_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_REVOKED, (st), (cmp)) -#define sk_X509_REVOKED_dup(st) SKM_sk_dup(X509_REVOKED, st) -#define sk_X509_REVOKED_pop_free(st, free_func) SKM_sk_pop_free(X509_REVOKED, (st), (free_func)) -#define sk_X509_REVOKED_shift(st) SKM_sk_shift(X509_REVOKED, (st)) -#define sk_X509_REVOKED_pop(st) SKM_sk_pop(X509_REVOKED, (st)) -#define sk_X509_REVOKED_sort(st) SKM_sk_sort(X509_REVOKED, (st)) -#define sk_X509_REVOKED_is_sorted(st) SKM_sk_is_sorted(X509_REVOKED, (st)) - -#define sk_X509_TRUST_new(st) SKM_sk_new(X509_TRUST, (st)) -#define sk_X509_TRUST_new_null() SKM_sk_new_null(X509_TRUST) -#define sk_X509_TRUST_free(st) SKM_sk_free(X509_TRUST, (st)) -#define sk_X509_TRUST_num(st) SKM_sk_num(X509_TRUST, (st)) -#define sk_X509_TRUST_value(st, i) SKM_sk_value(X509_TRUST, (st), (i)) -#define sk_X509_TRUST_set(st, i, val) SKM_sk_set(X509_TRUST, (st), (i), (val)) -#define sk_X509_TRUST_zero(st) SKM_sk_zero(X509_TRUST, (st)) -#define sk_X509_TRUST_push(st, val) SKM_sk_push(X509_TRUST, (st), (val)) -#define sk_X509_TRUST_unshift(st, val) SKM_sk_unshift(X509_TRUST, (st), (val)) -#define sk_X509_TRUST_find(st, val) SKM_sk_find(X509_TRUST, (st), (val)) -#define sk_X509_TRUST_find_ex(st, val) SKM_sk_find_ex(X509_TRUST, (st), (val)) -#define sk_X509_TRUST_delete(st, i) SKM_sk_delete(X509_TRUST, (st), (i)) -#define sk_X509_TRUST_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_TRUST, (st), (ptr)) -#define sk_X509_TRUST_insert(st, val, i) SKM_sk_insert(X509_TRUST, (st), (val), (i)) -#define sk_X509_TRUST_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_TRUST, (st), (cmp)) -#define sk_X509_TRUST_dup(st) SKM_sk_dup(X509_TRUST, st) -#define sk_X509_TRUST_pop_free(st, free_func) SKM_sk_pop_free(X509_TRUST, (st), (free_func)) -#define sk_X509_TRUST_shift(st) SKM_sk_shift(X509_TRUST, (st)) -#define sk_X509_TRUST_pop(st) SKM_sk_pop(X509_TRUST, (st)) -#define sk_X509_TRUST_sort(st) SKM_sk_sort(X509_TRUST, (st)) -#define sk_X509_TRUST_is_sorted(st) SKM_sk_is_sorted(X509_TRUST, (st)) - -#define sk_X509_VERIFY_PARAM_new(st) SKM_sk_new(X509_VERIFY_PARAM, (st)) -#define sk_X509_VERIFY_PARAM_new_null() SKM_sk_new_null(X509_VERIFY_PARAM) -#define sk_X509_VERIFY_PARAM_free(st) SKM_sk_free(X509_VERIFY_PARAM, (st)) -#define sk_X509_VERIFY_PARAM_num(st) SKM_sk_num(X509_VERIFY_PARAM, (st)) -#define sk_X509_VERIFY_PARAM_value(st, i) SKM_sk_value(X509_VERIFY_PARAM, (st), (i)) -#define sk_X509_VERIFY_PARAM_set(st, i, val) SKM_sk_set(X509_VERIFY_PARAM, (st), (i), (val)) -#define sk_X509_VERIFY_PARAM_zero(st) SKM_sk_zero(X509_VERIFY_PARAM, (st)) -#define sk_X509_VERIFY_PARAM_push(st, val) SKM_sk_push(X509_VERIFY_PARAM, (st), (val)) -#define sk_X509_VERIFY_PARAM_unshift(st, val) SKM_sk_unshift(X509_VERIFY_PARAM, (st), (val)) -#define sk_X509_VERIFY_PARAM_find(st, val) SKM_sk_find(X509_VERIFY_PARAM, (st), (val)) -#define sk_X509_VERIFY_PARAM_find_ex(st, val) SKM_sk_find_ex(X509_VERIFY_PARAM, (st), (val)) -#define sk_X509_VERIFY_PARAM_delete(st, i) SKM_sk_delete(X509_VERIFY_PARAM, (st), (i)) -#define sk_X509_VERIFY_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_VERIFY_PARAM, (st), (ptr)) -#define sk_X509_VERIFY_PARAM_insert(st, val, i) SKM_sk_insert(X509_VERIFY_PARAM, (st), (val), (i)) -#define sk_X509_VERIFY_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_VERIFY_PARAM, (st), (cmp)) -#define sk_X509_VERIFY_PARAM_dup(st) SKM_sk_dup(X509_VERIFY_PARAM, st) -#define sk_X509_VERIFY_PARAM_pop_free(st, free_func) SKM_sk_pop_free(X509_VERIFY_PARAM, (st), (free_func)) -#define sk_X509_VERIFY_PARAM_shift(st) SKM_sk_shift(X509_VERIFY_PARAM, (st)) -#define sk_X509_VERIFY_PARAM_pop(st) SKM_sk_pop(X509_VERIFY_PARAM, (st)) -#define sk_X509_VERIFY_PARAM_sort(st) SKM_sk_sort(X509_VERIFY_PARAM, (st)) -#define sk_X509_VERIFY_PARAM_is_sorted(st) SKM_sk_is_sorted(X509_VERIFY_PARAM, (st)) - -#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(ACCESS_DESCRIPTION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_ACCESS_DESCRIPTION(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(ACCESS_DESCRIPTION, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_ACCESS_DESCRIPTION(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(ACCESS_DESCRIPTION, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_ASN1_INTEGER(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(ASN1_INTEGER, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_ASN1_INTEGER(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(ASN1_INTEGER, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_ASN1_INTEGER(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(ASN1_INTEGER, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_ASN1_INTEGER(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(ASN1_INTEGER, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_ASN1_OBJECT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(ASN1_OBJECT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_ASN1_OBJECT(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(ASN1_OBJECT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_ASN1_OBJECT(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(ASN1_OBJECT, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_ASN1_OBJECT(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(ASN1_OBJECT, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_ASN1_TYPE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(ASN1_TYPE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_ASN1_TYPE(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(ASN1_TYPE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_ASN1_TYPE(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(ASN1_TYPE, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_ASN1_TYPE(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(ASN1_TYPE, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_DIST_POINT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(DIST_POINT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_DIST_POINT(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(DIST_POINT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_DIST_POINT(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(DIST_POINT, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_DIST_POINT(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(DIST_POINT, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_GENERAL_NAME(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(GENERAL_NAME, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_GENERAL_NAME(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(GENERAL_NAME, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_GENERAL_NAME(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(GENERAL_NAME, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_GENERAL_NAME(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(GENERAL_NAME, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_OCSP_ONEREQ(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(OCSP_ONEREQ, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_OCSP_ONEREQ(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(OCSP_ONEREQ, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_OCSP_ONEREQ(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(OCSP_ONEREQ, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_OCSP_ONEREQ(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(OCSP_ONEREQ, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(OCSP_SINGLERESP, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(OCSP_SINGLERESP, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_OCSP_SINGLERESP(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(OCSP_SINGLERESP, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_OCSP_SINGLERESP(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(OCSP_SINGLERESP, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(PKCS12_SAFEBAG, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(PKCS12_SAFEBAG, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_PKCS12_SAFEBAG(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(PKCS12_SAFEBAG, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_PKCS12_SAFEBAG(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(PKCS12_SAFEBAG, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_PKCS7(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(PKCS7, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_PKCS7(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(PKCS7, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_PKCS7(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(PKCS7, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_PKCS7(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(PKCS7, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(PKCS7_RECIP_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(PKCS7_RECIP_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_PKCS7_RECIP_INFO(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(PKCS7_RECIP_INFO, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_PKCS7_RECIP_INFO(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(PKCS7_RECIP_INFO, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(PKCS7_SIGNER_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(PKCS7_SIGNER_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_PKCS7_SIGNER_INFO(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(PKCS7_SIGNER_INFO, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_PKCS7_SIGNER_INFO(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(PKCS7_SIGNER_INFO, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_POLICYINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(POLICYINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_POLICYINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(POLICYINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_POLICYINFO(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(POLICYINFO, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_POLICYINFO(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(POLICYINFO, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_POLICYQUALINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(POLICYQUALINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_POLICYQUALINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(POLICYQUALINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_POLICYQUALINFO(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(POLICYQUALINFO, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_POLICYQUALINFO(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(POLICYQUALINFO, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_SXNETID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(SXNETID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_SXNETID(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(SXNETID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_SXNETID(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(SXNETID, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_SXNETID(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(SXNETID, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_X509(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(X509, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_X509(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(X509, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_X509(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(X509, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_X509(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(X509, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_X509_ALGOR(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(X509_ALGOR, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_X509_ALGOR(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(X509_ALGOR, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_X509_ALGOR(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(X509_ALGOR, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_X509_ALGOR(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(X509_ALGOR, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(X509_ATTRIBUTE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(X509_ATTRIBUTE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_X509_ATTRIBUTE(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(X509_ATTRIBUTE, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_X509_ATTRIBUTE(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(X509_ATTRIBUTE, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_X509_CRL(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(X509_CRL, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_X509_CRL(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(X509_CRL, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_X509_CRL(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(X509_CRL, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_X509_CRL(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(X509_CRL, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_X509_EXTENSION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(X509_EXTENSION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_X509_EXTENSION(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(X509_EXTENSION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_X509_EXTENSION(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(X509_EXTENSION, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_X509_EXTENSION(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(X509_EXTENSION, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(X509_NAME_ENTRY, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(X509_NAME_ENTRY, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_X509_NAME_ENTRY(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(X509_NAME_ENTRY, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_X509_NAME_ENTRY(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(X509_NAME_ENTRY, (buf), (len), (d2i_func), (free_func)) - -#define d2i_ASN1_SET_OF_X509_REVOKED(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ - SKM_ASN1_SET_OF_d2i(X509_REVOKED, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) -#define i2d_ASN1_SET_OF_X509_REVOKED(st, pp, i2d_func, ex_tag, ex_class, is_set) \ - SKM_ASN1_SET_OF_i2d(X509_REVOKED, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) -#define ASN1_seq_pack_X509_REVOKED(st, i2d_func, buf, len) \ - SKM_ASN1_seq_pack(X509_REVOKED, (st), (i2d_func), (buf), (len)) -#define ASN1_seq_unpack_X509_REVOKED(buf, len, d2i_func, free_func) \ - SKM_ASN1_seq_unpack(X509_REVOKED, (buf), (len), (d2i_func), (free_func)) - -#define PKCS12_decrypt_d2i_PKCS12_SAFEBAG(algor, d2i_func, free_func, pass, passlen, oct, seq) \ - SKM_PKCS12_decrypt_d2i(PKCS12_SAFEBAG, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) - -#define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \ - SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) -/* End of util/mkstack.pl block, you may now edit :-) */ - -#endif /* !defined HEADER_SAFESTACK_H */ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_SAFESTACK_H +#define HEADER_SAFESTACK_H + +#include + +typedef void (*openssl_fptr)(void); +#define openssl_fcast(f) ((openssl_fptr)f) + +#ifdef DEBUG_SAFESTACK + +#define STACK_OF(type) struct stack_st_##type +#define PREDECLARE_STACK_OF(type) STACK_OF(type); + +#define DECLARE_STACK_OF(type) \ +STACK_OF(type) \ + { \ + STACK stack; \ + }; + +#define IMPLEMENT_STACK_OF(type) /* nada (obsolete in new safestack approach)*/ + +/* SKM_sk_... stack macros are internal to safestack.h: + * never use them directly, use sk__... instead */ +#define SKM_sk_new(type, cmp) \ + ((STACK_OF(type) * (*)(int (*)(const type * const *, const type * const *)))openssl_fcast(sk_new))(cmp) +#define SKM_sk_new_null(type) \ + ((STACK_OF(type) * (*)(void))openssl_fcast(sk_new_null))() +#define SKM_sk_free(type, st) \ + ((void (*)(STACK_OF(type) *))openssl_fcast(sk_free))(st) +#define SKM_sk_num(type, st) \ + ((int (*)(const STACK_OF(type) *))openssl_fcast(sk_num))(st) +#define SKM_sk_value(type, st,i) \ + ((type * (*)(const STACK_OF(type) *, int))openssl_fcast(sk_value))(st, i) +#define SKM_sk_set(type, st,i,val) \ + ((type * (*)(STACK_OF(type) *, int, type *))openssl_fcast(sk_set))(st, i, val) +#define SKM_sk_zero(type, st) \ + ((void (*)(STACK_OF(type) *))openssl_fcast(sk_zero))(st) +#define SKM_sk_push(type, st,val) \ + ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_push))(st, val) +#define SKM_sk_unshift(type, st,val) \ + ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_unshift))(st, val) +#define SKM_sk_find(type, st,val) \ + ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_find))(st, val) +#define SKM_sk_delete(type, st,i) \ + ((type * (*)(STACK_OF(type) *, int))openssl_fcast(sk_delete))(st, i) +#define SKM_sk_delete_ptr(type, st,ptr) \ + ((type * (*)(STACK_OF(type) *, type *))openssl_fcast(sk_delete_ptr))(st, ptr) +#define SKM_sk_insert(type, st,val,i) \ + ((int (*)(STACK_OF(type) *, type *, int))openssl_fcast(sk_insert))(st, val, i) +#define SKM_sk_set_cmp_func(type, st,cmp) \ + ((int (*(*)(STACK_OF(type) *, int (*)(const type * const *, const type * const *))) \ + (const type * const *, const type * const *))openssl_fcast(sk_set_cmp_func))\ + (st, cmp) +#define SKM_sk_dup(type, st) \ + ((STACK_OF(type) *(*)(STACK_OF(type) *))openssl_fcast(sk_dup))(st) +#define SKM_sk_pop_free(type, st,free_func) \ + ((void (*)(STACK_OF(type) *, void (*)(type *)))openssl_fcast(sk_pop_free))\ + (st, free_func) +#define SKM_sk_shift(type, st) \ + ((type * (*)(STACK_OF(type) *))openssl_fcast(sk_shift))(st) +#define SKM_sk_pop(type, st) \ + ((type * (*)(STACK_OF(type) *))openssl_fcast(sk_pop))(st) +#define SKM_sk_sort(type, st) \ + ((void (*)(STACK_OF(type) *))openssl_fcast(sk_sort))(st) +#define SKM_sk_is_sorted(type, st) \ + ((int (*)(const STACK_OF(type) *))openssl_fcast(sk_is_sorted))(st) + +#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ +((STACK_OF(type) * (*) (STACK_OF(type) **,const unsigned char **, long , \ + type *(*)(type **, const unsigned char **,long), \ + void (*)(type *), int ,int )) openssl_fcast(d2i_ASN1_SET)) \ + (st,pp,length, d2i_func, free_func, ex_tag,ex_class) +#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \ + ((int (*)(STACK_OF(type) *,unsigned char **, \ + int (*)(type *,unsigned char **), int , int , int)) openssl_fcast(i2d_ASN1_SET)) \ + (st,pp,i2d_func,ex_tag,ex_class,is_set) + +#define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \ + ((unsigned char *(*)(STACK_OF(type) *, \ + int (*)(type *,unsigned char **), unsigned char **,int *)) openssl_fcast(ASN1_seq_pack)) \ + (st, i2d_func, buf, len) +#define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \ + ((STACK_OF(type) * (*)(const unsigned char *,int, \ + type *(*)(type **,const unsigned char **, long), \ + void (*)(type *)))openssl_fcast(ASN1_seq_unpack)) \ + (buf,len,d2i_func, free_func) + +#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \ + ((STACK_OF(type) * (*)(X509_ALGOR *, \ + type *(*)(type **, const unsigned char **, long), \ + void (*)(type *), \ + const char *, int, \ + ASN1_STRING *, int))PKCS12_decrypt_d2i) \ + (algor,d2i_func,free_func,pass,passlen,oct,seq) + +#else + +#define STACK_OF(type) STACK +#define PREDECLARE_STACK_OF(type) /* nada */ +#define DECLARE_STACK_OF(type) /* nada */ +#define IMPLEMENT_STACK_OF(type) /* nada */ + +#define SKM_sk_new(type, cmp) \ + sk_new((int (*)(const char * const *, const char * const *))(cmp)) +#define SKM_sk_new_null(type) \ + sk_new_null() +#define SKM_sk_free(type, st) \ + sk_free(st) +#define SKM_sk_num(type, st) \ + sk_num(st) +#define SKM_sk_value(type, st,i) \ + ((type *)sk_value(st, i)) +#define SKM_sk_set(type, st,i,val) \ + ((type *)sk_set(st, i,(char *)val)) +#define SKM_sk_zero(type, st) \ + sk_zero(st) +#define SKM_sk_push(type, st,val) \ + sk_push(st, (char *)val) +#define SKM_sk_unshift(type, st,val) \ + sk_unshift(st, val) +#define SKM_sk_find(type, st,val) \ + sk_find(st, (char *)val) +#define SKM_sk_delete(type, st,i) \ + ((type *)sk_delete(st, i)) +#define SKM_sk_delete_ptr(type, st,ptr) \ + ((type *)sk_delete_ptr(st,(char *)ptr)) +#define SKM_sk_insert(type, st,val,i) \ + sk_insert(st, (char *)val, i) +#define SKM_sk_set_cmp_func(type, st,cmp) \ + ((int (*)(const type * const *,const type * const *)) \ + sk_set_cmp_func(st, (int (*)(const char * const *, const char * const *))(cmp))) +#define SKM_sk_dup(type, st) \ + sk_dup(st) +#define SKM_sk_pop_free(type, st,free_func) \ + sk_pop_free(st, (void (*)(void *))free_func) +#define SKM_sk_shift(type, st) \ + ((type *)sk_shift(st)) +#define SKM_sk_pop(type, st) \ + ((type *)sk_pop(st)) +#define SKM_sk_sort(type, st) \ + sk_sort(st) +#define SKM_sk_is_sorted(type, st) \ + sk_is_sorted(st) + +#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + d2i_ASN1_SET(st,pp,length, (void *(*)(void ** ,const unsigned char ** ,long))d2i_func, (void (*)(void *))free_func, ex_tag,ex_class) +#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \ + i2d_ASN1_SET(st,pp,(int (*)(void *, unsigned char **))i2d_func,ex_tag,ex_class,is_set) + +#define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \ + ASN1_seq_pack(st, (int (*)(void *, unsigned char **))i2d_func, buf, len) +#define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \ + ASN1_seq_unpack(buf,len,(void *(*)(void **,const unsigned char **,long))d2i_func, (void(*)(void *))free_func) + +#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \ + ((STACK *)PKCS12_decrypt_d2i(algor,(char *(*)())d2i_func, (void(*)(void *))free_func,pass,passlen,oct,seq)) + +#endif + +/* This block of defines is updated by util/mkstack.pl, please do not touch! */ +#define sk_ACCESS_DESCRIPTION_new(st) SKM_sk_new(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_new_null() SKM_sk_new_null(ACCESS_DESCRIPTION) +#define sk_ACCESS_DESCRIPTION_free(st) SKM_sk_free(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_num(st) SKM_sk_num(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_value(st, i) SKM_sk_value(ACCESS_DESCRIPTION, (st), (i)) +#define sk_ACCESS_DESCRIPTION_set(st, i, val) SKM_sk_set(ACCESS_DESCRIPTION, (st), (i), (val)) +#define sk_ACCESS_DESCRIPTION_zero(st) SKM_sk_zero(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_push(st, val) SKM_sk_push(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_unshift(st, val) SKM_sk_unshift(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_find(st, val) SKM_sk_find(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_find_ex(st, val) SKM_sk_find_ex(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_delete(st, i) SKM_sk_delete(ACCESS_DESCRIPTION, (st), (i)) +#define sk_ACCESS_DESCRIPTION_delete_ptr(st, ptr) SKM_sk_delete_ptr(ACCESS_DESCRIPTION, (st), (ptr)) +#define sk_ACCESS_DESCRIPTION_insert(st, val, i) SKM_sk_insert(ACCESS_DESCRIPTION, (st), (val), (i)) +#define sk_ACCESS_DESCRIPTION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ACCESS_DESCRIPTION, (st), (cmp)) +#define sk_ACCESS_DESCRIPTION_dup(st) SKM_sk_dup(ACCESS_DESCRIPTION, st) +#define sk_ACCESS_DESCRIPTION_pop_free(st, free_func) SKM_sk_pop_free(ACCESS_DESCRIPTION, (st), (free_func)) +#define sk_ACCESS_DESCRIPTION_shift(st) SKM_sk_shift(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_pop(st) SKM_sk_pop(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_is_sorted(st) SKM_sk_is_sorted(ACCESS_DESCRIPTION, (st)) + +#define sk_ASN1_GENERALSTRING_new(st) SKM_sk_new(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING) +#define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_num(st) SKM_sk_num(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_value(st, i) SKM_sk_value(ASN1_GENERALSTRING, (st), (i)) +#define sk_ASN1_GENERALSTRING_set(st, i, val) SKM_sk_set(ASN1_GENERALSTRING, (st), (i), (val)) +#define sk_ASN1_GENERALSTRING_zero(st) SKM_sk_zero(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_push(st, val) SKM_sk_push(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_unshift(st, val) SKM_sk_unshift(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_find(st, val) SKM_sk_find(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_find_ex(st, val) SKM_sk_find_ex(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_delete(st, i) SKM_sk_delete(ASN1_GENERALSTRING, (st), (i)) +#define sk_ASN1_GENERALSTRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_GENERALSTRING, (st), (ptr)) +#define sk_ASN1_GENERALSTRING_insert(st, val, i) SKM_sk_insert(ASN1_GENERALSTRING, (st), (val), (i)) +#define sk_ASN1_GENERALSTRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_GENERALSTRING, (st), (cmp)) +#define sk_ASN1_GENERALSTRING_dup(st) SKM_sk_dup(ASN1_GENERALSTRING, st) +#define sk_ASN1_GENERALSTRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_GENERALSTRING, (st), (free_func)) +#define sk_ASN1_GENERALSTRING_shift(st) SKM_sk_shift(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_pop(st) SKM_sk_pop(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_sort(st) SKM_sk_sort(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_is_sorted(st) SKM_sk_is_sorted(ASN1_GENERALSTRING, (st)) + +#define sk_ASN1_INTEGER_new(st) SKM_sk_new(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER) +#define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_num(st) SKM_sk_num(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_value(st, i) SKM_sk_value(ASN1_INTEGER, (st), (i)) +#define sk_ASN1_INTEGER_set(st, i, val) SKM_sk_set(ASN1_INTEGER, (st), (i), (val)) +#define sk_ASN1_INTEGER_zero(st) SKM_sk_zero(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_push(st, val) SKM_sk_push(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_unshift(st, val) SKM_sk_unshift(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_find(st, val) SKM_sk_find(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_find_ex(st, val) SKM_sk_find_ex(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_delete(st, i) SKM_sk_delete(ASN1_INTEGER, (st), (i)) +#define sk_ASN1_INTEGER_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_INTEGER, (st), (ptr)) +#define sk_ASN1_INTEGER_insert(st, val, i) SKM_sk_insert(ASN1_INTEGER, (st), (val), (i)) +#define sk_ASN1_INTEGER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_INTEGER, (st), (cmp)) +#define sk_ASN1_INTEGER_dup(st) SKM_sk_dup(ASN1_INTEGER, st) +#define sk_ASN1_INTEGER_pop_free(st, free_func) SKM_sk_pop_free(ASN1_INTEGER, (st), (free_func)) +#define sk_ASN1_INTEGER_shift(st) SKM_sk_shift(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_pop(st) SKM_sk_pop(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_sort(st) SKM_sk_sort(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_is_sorted(st) SKM_sk_is_sorted(ASN1_INTEGER, (st)) + +#define sk_ASN1_OBJECT_new(st) SKM_sk_new(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_new_null() SKM_sk_new_null(ASN1_OBJECT) +#define sk_ASN1_OBJECT_free(st) SKM_sk_free(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_num(st) SKM_sk_num(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_value(st, i) SKM_sk_value(ASN1_OBJECT, (st), (i)) +#define sk_ASN1_OBJECT_set(st, i, val) SKM_sk_set(ASN1_OBJECT, (st), (i), (val)) +#define sk_ASN1_OBJECT_zero(st) SKM_sk_zero(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_push(st, val) SKM_sk_push(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_unshift(st, val) SKM_sk_unshift(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_find(st, val) SKM_sk_find(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_find_ex(st, val) SKM_sk_find_ex(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_delete(st, i) SKM_sk_delete(ASN1_OBJECT, (st), (i)) +#define sk_ASN1_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_OBJECT, (st), (ptr)) +#define sk_ASN1_OBJECT_insert(st, val, i) SKM_sk_insert(ASN1_OBJECT, (st), (val), (i)) +#define sk_ASN1_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_OBJECT, (st), (cmp)) +#define sk_ASN1_OBJECT_dup(st) SKM_sk_dup(ASN1_OBJECT, st) +#define sk_ASN1_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(ASN1_OBJECT, (st), (free_func)) +#define sk_ASN1_OBJECT_shift(st) SKM_sk_shift(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_pop(st) SKM_sk_pop(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_sort(st) SKM_sk_sort(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_is_sorted(st) SKM_sk_is_sorted(ASN1_OBJECT, (st)) + +#define sk_ASN1_STRING_TABLE_new(st) SKM_sk_new(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_new_null() SKM_sk_new_null(ASN1_STRING_TABLE) +#define sk_ASN1_STRING_TABLE_free(st) SKM_sk_free(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_num(st) SKM_sk_num(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_value(st, i) SKM_sk_value(ASN1_STRING_TABLE, (st), (i)) +#define sk_ASN1_STRING_TABLE_set(st, i, val) SKM_sk_set(ASN1_STRING_TABLE, (st), (i), (val)) +#define sk_ASN1_STRING_TABLE_zero(st) SKM_sk_zero(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_push(st, val) SKM_sk_push(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_unshift(st, val) SKM_sk_unshift(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_find(st, val) SKM_sk_find(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_find_ex(st, val) SKM_sk_find_ex(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_delete(st, i) SKM_sk_delete(ASN1_STRING_TABLE, (st), (i)) +#define sk_ASN1_STRING_TABLE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_STRING_TABLE, (st), (ptr)) +#define sk_ASN1_STRING_TABLE_insert(st, val, i) SKM_sk_insert(ASN1_STRING_TABLE, (st), (val), (i)) +#define sk_ASN1_STRING_TABLE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_STRING_TABLE, (st), (cmp)) +#define sk_ASN1_STRING_TABLE_dup(st) SKM_sk_dup(ASN1_STRING_TABLE, st) +#define sk_ASN1_STRING_TABLE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_STRING_TABLE, (st), (free_func)) +#define sk_ASN1_STRING_TABLE_shift(st) SKM_sk_shift(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_pop(st) SKM_sk_pop(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_sort(st) SKM_sk_sort(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_is_sorted(st) SKM_sk_is_sorted(ASN1_STRING_TABLE, (st)) + +#define sk_ASN1_TYPE_new(st) SKM_sk_new(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_new_null() SKM_sk_new_null(ASN1_TYPE) +#define sk_ASN1_TYPE_free(st) SKM_sk_free(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_num(st) SKM_sk_num(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_value(st, i) SKM_sk_value(ASN1_TYPE, (st), (i)) +#define sk_ASN1_TYPE_set(st, i, val) SKM_sk_set(ASN1_TYPE, (st), (i), (val)) +#define sk_ASN1_TYPE_zero(st) SKM_sk_zero(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_push(st, val) SKM_sk_push(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_unshift(st, val) SKM_sk_unshift(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_find(st, val) SKM_sk_find(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_find_ex(st, val) SKM_sk_find_ex(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_delete(st, i) SKM_sk_delete(ASN1_TYPE, (st), (i)) +#define sk_ASN1_TYPE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_TYPE, (st), (ptr)) +#define sk_ASN1_TYPE_insert(st, val, i) SKM_sk_insert(ASN1_TYPE, (st), (val), (i)) +#define sk_ASN1_TYPE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_TYPE, (st), (cmp)) +#define sk_ASN1_TYPE_dup(st) SKM_sk_dup(ASN1_TYPE, st) +#define sk_ASN1_TYPE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_TYPE, (st), (free_func)) +#define sk_ASN1_TYPE_shift(st) SKM_sk_shift(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_pop(st) SKM_sk_pop(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_is_sorted(st) SKM_sk_is_sorted(ASN1_TYPE, (st)) + +#define sk_ASN1_VALUE_new(st) SKM_sk_new(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_new_null() SKM_sk_new_null(ASN1_VALUE) +#define sk_ASN1_VALUE_free(st) SKM_sk_free(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_num(st) SKM_sk_num(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_value(st, i) SKM_sk_value(ASN1_VALUE, (st), (i)) +#define sk_ASN1_VALUE_set(st, i, val) SKM_sk_set(ASN1_VALUE, (st), (i), (val)) +#define sk_ASN1_VALUE_zero(st) SKM_sk_zero(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_push(st, val) SKM_sk_push(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_unshift(st, val) SKM_sk_unshift(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_find(st, val) SKM_sk_find(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_find_ex(st, val) SKM_sk_find_ex(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_delete(st, i) SKM_sk_delete(ASN1_VALUE, (st), (i)) +#define sk_ASN1_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_VALUE, (st), (ptr)) +#define sk_ASN1_VALUE_insert(st, val, i) SKM_sk_insert(ASN1_VALUE, (st), (val), (i)) +#define sk_ASN1_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_VALUE, (st), (cmp)) +#define sk_ASN1_VALUE_dup(st) SKM_sk_dup(ASN1_VALUE, st) +#define sk_ASN1_VALUE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_VALUE, (st), (free_func)) +#define sk_ASN1_VALUE_shift(st) SKM_sk_shift(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_pop(st) SKM_sk_pop(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_sort(st) SKM_sk_sort(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_is_sorted(st) SKM_sk_is_sorted(ASN1_VALUE, (st)) + +#define sk_BIO_new(st) SKM_sk_new(BIO, (st)) +#define sk_BIO_new_null() SKM_sk_new_null(BIO) +#define sk_BIO_free(st) SKM_sk_free(BIO, (st)) +#define sk_BIO_num(st) SKM_sk_num(BIO, (st)) +#define sk_BIO_value(st, i) SKM_sk_value(BIO, (st), (i)) +#define sk_BIO_set(st, i, val) SKM_sk_set(BIO, (st), (i), (val)) +#define sk_BIO_zero(st) SKM_sk_zero(BIO, (st)) +#define sk_BIO_push(st, val) SKM_sk_push(BIO, (st), (val)) +#define sk_BIO_unshift(st, val) SKM_sk_unshift(BIO, (st), (val)) +#define sk_BIO_find(st, val) SKM_sk_find(BIO, (st), (val)) +#define sk_BIO_find_ex(st, val) SKM_sk_find_ex(BIO, (st), (val)) +#define sk_BIO_delete(st, i) SKM_sk_delete(BIO, (st), (i)) +#define sk_BIO_delete_ptr(st, ptr) SKM_sk_delete_ptr(BIO, (st), (ptr)) +#define sk_BIO_insert(st, val, i) SKM_sk_insert(BIO, (st), (val), (i)) +#define sk_BIO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BIO, (st), (cmp)) +#define sk_BIO_dup(st) SKM_sk_dup(BIO, st) +#define sk_BIO_pop_free(st, free_func) SKM_sk_pop_free(BIO, (st), (free_func)) +#define sk_BIO_shift(st) SKM_sk_shift(BIO, (st)) +#define sk_BIO_pop(st) SKM_sk_pop(BIO, (st)) +#define sk_BIO_sort(st) SKM_sk_sort(BIO, (st)) +#define sk_BIO_is_sorted(st) SKM_sk_is_sorted(BIO, (st)) + +#define sk_CONF_IMODULE_new(st) SKM_sk_new(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_new_null() SKM_sk_new_null(CONF_IMODULE) +#define sk_CONF_IMODULE_free(st) SKM_sk_free(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_num(st) SKM_sk_num(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_value(st, i) SKM_sk_value(CONF_IMODULE, (st), (i)) +#define sk_CONF_IMODULE_set(st, i, val) SKM_sk_set(CONF_IMODULE, (st), (i), (val)) +#define sk_CONF_IMODULE_zero(st) SKM_sk_zero(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_push(st, val) SKM_sk_push(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_unshift(st, val) SKM_sk_unshift(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_find(st, val) SKM_sk_find(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_find_ex(st, val) SKM_sk_find_ex(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_delete(st, i) SKM_sk_delete(CONF_IMODULE, (st), (i)) +#define sk_CONF_IMODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_IMODULE, (st), (ptr)) +#define sk_CONF_IMODULE_insert(st, val, i) SKM_sk_insert(CONF_IMODULE, (st), (val), (i)) +#define sk_CONF_IMODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_IMODULE, (st), (cmp)) +#define sk_CONF_IMODULE_dup(st) SKM_sk_dup(CONF_IMODULE, st) +#define sk_CONF_IMODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_IMODULE, (st), (free_func)) +#define sk_CONF_IMODULE_shift(st) SKM_sk_shift(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_pop(st) SKM_sk_pop(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_sort(st) SKM_sk_sort(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_is_sorted(st) SKM_sk_is_sorted(CONF_IMODULE, (st)) + +#define sk_CONF_MODULE_new(st) SKM_sk_new(CONF_MODULE, (st)) +#define sk_CONF_MODULE_new_null() SKM_sk_new_null(CONF_MODULE) +#define sk_CONF_MODULE_free(st) SKM_sk_free(CONF_MODULE, (st)) +#define sk_CONF_MODULE_num(st) SKM_sk_num(CONF_MODULE, (st)) +#define sk_CONF_MODULE_value(st, i) SKM_sk_value(CONF_MODULE, (st), (i)) +#define sk_CONF_MODULE_set(st, i, val) SKM_sk_set(CONF_MODULE, (st), (i), (val)) +#define sk_CONF_MODULE_zero(st) SKM_sk_zero(CONF_MODULE, (st)) +#define sk_CONF_MODULE_push(st, val) SKM_sk_push(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_unshift(st, val) SKM_sk_unshift(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_find(st, val) SKM_sk_find(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_find_ex(st, val) SKM_sk_find_ex(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_delete(st, i) SKM_sk_delete(CONF_MODULE, (st), (i)) +#define sk_CONF_MODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_MODULE, (st), (ptr)) +#define sk_CONF_MODULE_insert(st, val, i) SKM_sk_insert(CONF_MODULE, (st), (val), (i)) +#define sk_CONF_MODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_MODULE, (st), (cmp)) +#define sk_CONF_MODULE_dup(st) SKM_sk_dup(CONF_MODULE, st) +#define sk_CONF_MODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_MODULE, (st), (free_func)) +#define sk_CONF_MODULE_shift(st) SKM_sk_shift(CONF_MODULE, (st)) +#define sk_CONF_MODULE_pop(st) SKM_sk_pop(CONF_MODULE, (st)) +#define sk_CONF_MODULE_sort(st) SKM_sk_sort(CONF_MODULE, (st)) +#define sk_CONF_MODULE_is_sorted(st) SKM_sk_is_sorted(CONF_MODULE, (st)) + +#define sk_CONF_VALUE_new(st) SKM_sk_new(CONF_VALUE, (st)) +#define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE) +#define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st)) +#define sk_CONF_VALUE_num(st) SKM_sk_num(CONF_VALUE, (st)) +#define sk_CONF_VALUE_value(st, i) SKM_sk_value(CONF_VALUE, (st), (i)) +#define sk_CONF_VALUE_set(st, i, val) SKM_sk_set(CONF_VALUE, (st), (i), (val)) +#define sk_CONF_VALUE_zero(st) SKM_sk_zero(CONF_VALUE, (st)) +#define sk_CONF_VALUE_push(st, val) SKM_sk_push(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_unshift(st, val) SKM_sk_unshift(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_find(st, val) SKM_sk_find(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_find_ex(st, val) SKM_sk_find_ex(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_delete(st, i) SKM_sk_delete(CONF_VALUE, (st), (i)) +#define sk_CONF_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_VALUE, (st), (ptr)) +#define sk_CONF_VALUE_insert(st, val, i) SKM_sk_insert(CONF_VALUE, (st), (val), (i)) +#define sk_CONF_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_VALUE, (st), (cmp)) +#define sk_CONF_VALUE_dup(st) SKM_sk_dup(CONF_VALUE, st) +#define sk_CONF_VALUE_pop_free(st, free_func) SKM_sk_pop_free(CONF_VALUE, (st), (free_func)) +#define sk_CONF_VALUE_shift(st) SKM_sk_shift(CONF_VALUE, (st)) +#define sk_CONF_VALUE_pop(st) SKM_sk_pop(CONF_VALUE, (st)) +#define sk_CONF_VALUE_sort(st) SKM_sk_sort(CONF_VALUE, (st)) +#define sk_CONF_VALUE_is_sorted(st) SKM_sk_is_sorted(CONF_VALUE, (st)) + +#define sk_CRYPTO_EX_DATA_FUNCS_new(st) SKM_sk_new(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_new_null() SKM_sk_new_null(CRYPTO_EX_DATA_FUNCS) +#define sk_CRYPTO_EX_DATA_FUNCS_free(st) SKM_sk_free(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_num(st) SKM_sk_num(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_value(st, i) SKM_sk_value(CRYPTO_EX_DATA_FUNCS, (st), (i)) +#define sk_CRYPTO_EX_DATA_FUNCS_set(st, i, val) SKM_sk_set(CRYPTO_EX_DATA_FUNCS, (st), (i), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_zero(st) SKM_sk_zero(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_push(st, val) SKM_sk_push(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_unshift(st, val) SKM_sk_unshift(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_find(st, val) SKM_sk_find(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_find_ex(st, val) SKM_sk_find_ex(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_delete(st, i) SKM_sk_delete(CRYPTO_EX_DATA_FUNCS, (st), (i)) +#define sk_CRYPTO_EX_DATA_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_EX_DATA_FUNCS, (st), (ptr)) +#define sk_CRYPTO_EX_DATA_FUNCS_insert(st, val, i) SKM_sk_insert(CRYPTO_EX_DATA_FUNCS, (st), (val), (i)) +#define sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_EX_DATA_FUNCS, (st), (cmp)) +#define sk_CRYPTO_EX_DATA_FUNCS_dup(st) SKM_sk_dup(CRYPTO_EX_DATA_FUNCS, st) +#define sk_CRYPTO_EX_DATA_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_EX_DATA_FUNCS, (st), (free_func)) +#define sk_CRYPTO_EX_DATA_FUNCS_shift(st) SKM_sk_shift(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_pop(st) SKM_sk_pop(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_sort(st) SKM_sk_sort(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(st) SKM_sk_is_sorted(CRYPTO_EX_DATA_FUNCS, (st)) + +#define sk_CRYPTO_dynlock_new(st) SKM_sk_new(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_new_null() SKM_sk_new_null(CRYPTO_dynlock) +#define sk_CRYPTO_dynlock_free(st) SKM_sk_free(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_num(st) SKM_sk_num(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_value(st, i) SKM_sk_value(CRYPTO_dynlock, (st), (i)) +#define sk_CRYPTO_dynlock_set(st, i, val) SKM_sk_set(CRYPTO_dynlock, (st), (i), (val)) +#define sk_CRYPTO_dynlock_zero(st) SKM_sk_zero(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_push(st, val) SKM_sk_push(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_unshift(st, val) SKM_sk_unshift(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_find(st, val) SKM_sk_find(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_find_ex(st, val) SKM_sk_find_ex(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_delete(st, i) SKM_sk_delete(CRYPTO_dynlock, (st), (i)) +#define sk_CRYPTO_dynlock_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_dynlock, (st), (ptr)) +#define sk_CRYPTO_dynlock_insert(st, val, i) SKM_sk_insert(CRYPTO_dynlock, (st), (val), (i)) +#define sk_CRYPTO_dynlock_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_dynlock, (st), (cmp)) +#define sk_CRYPTO_dynlock_dup(st) SKM_sk_dup(CRYPTO_dynlock, st) +#define sk_CRYPTO_dynlock_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_dynlock, (st), (free_func)) +#define sk_CRYPTO_dynlock_shift(st) SKM_sk_shift(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_pop(st) SKM_sk_pop(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_sort(st) SKM_sk_sort(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_is_sorted(st) SKM_sk_is_sorted(CRYPTO_dynlock, (st)) + +#define sk_DIST_POINT_new(st) SKM_sk_new(DIST_POINT, (st)) +#define sk_DIST_POINT_new_null() SKM_sk_new_null(DIST_POINT) +#define sk_DIST_POINT_free(st) SKM_sk_free(DIST_POINT, (st)) +#define sk_DIST_POINT_num(st) SKM_sk_num(DIST_POINT, (st)) +#define sk_DIST_POINT_value(st, i) SKM_sk_value(DIST_POINT, (st), (i)) +#define sk_DIST_POINT_set(st, i, val) SKM_sk_set(DIST_POINT, (st), (i), (val)) +#define sk_DIST_POINT_zero(st) SKM_sk_zero(DIST_POINT, (st)) +#define sk_DIST_POINT_push(st, val) SKM_sk_push(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_unshift(st, val) SKM_sk_unshift(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_find(st, val) SKM_sk_find(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_find_ex(st, val) SKM_sk_find_ex(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_delete(st, i) SKM_sk_delete(DIST_POINT, (st), (i)) +#define sk_DIST_POINT_delete_ptr(st, ptr) SKM_sk_delete_ptr(DIST_POINT, (st), (ptr)) +#define sk_DIST_POINT_insert(st, val, i) SKM_sk_insert(DIST_POINT, (st), (val), (i)) +#define sk_DIST_POINT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(DIST_POINT, (st), (cmp)) +#define sk_DIST_POINT_dup(st) SKM_sk_dup(DIST_POINT, st) +#define sk_DIST_POINT_pop_free(st, free_func) SKM_sk_pop_free(DIST_POINT, (st), (free_func)) +#define sk_DIST_POINT_shift(st) SKM_sk_shift(DIST_POINT, (st)) +#define sk_DIST_POINT_pop(st) SKM_sk_pop(DIST_POINT, (st)) +#define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st)) +#define sk_DIST_POINT_is_sorted(st) SKM_sk_is_sorted(DIST_POINT, (st)) + +#define sk_ENGINE_new(st) SKM_sk_new(ENGINE, (st)) +#define sk_ENGINE_new_null() SKM_sk_new_null(ENGINE) +#define sk_ENGINE_free(st) SKM_sk_free(ENGINE, (st)) +#define sk_ENGINE_num(st) SKM_sk_num(ENGINE, (st)) +#define sk_ENGINE_value(st, i) SKM_sk_value(ENGINE, (st), (i)) +#define sk_ENGINE_set(st, i, val) SKM_sk_set(ENGINE, (st), (i), (val)) +#define sk_ENGINE_zero(st) SKM_sk_zero(ENGINE, (st)) +#define sk_ENGINE_push(st, val) SKM_sk_push(ENGINE, (st), (val)) +#define sk_ENGINE_unshift(st, val) SKM_sk_unshift(ENGINE, (st), (val)) +#define sk_ENGINE_find(st, val) SKM_sk_find(ENGINE, (st), (val)) +#define sk_ENGINE_find_ex(st, val) SKM_sk_find_ex(ENGINE, (st), (val)) +#define sk_ENGINE_delete(st, i) SKM_sk_delete(ENGINE, (st), (i)) +#define sk_ENGINE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE, (st), (ptr)) +#define sk_ENGINE_insert(st, val, i) SKM_sk_insert(ENGINE, (st), (val), (i)) +#define sk_ENGINE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE, (st), (cmp)) +#define sk_ENGINE_dup(st) SKM_sk_dup(ENGINE, st) +#define sk_ENGINE_pop_free(st, free_func) SKM_sk_pop_free(ENGINE, (st), (free_func)) +#define sk_ENGINE_shift(st) SKM_sk_shift(ENGINE, (st)) +#define sk_ENGINE_pop(st) SKM_sk_pop(ENGINE, (st)) +#define sk_ENGINE_sort(st) SKM_sk_sort(ENGINE, (st)) +#define sk_ENGINE_is_sorted(st) SKM_sk_is_sorted(ENGINE, (st)) + +#define sk_ENGINE_CLEANUP_ITEM_new(st) SKM_sk_new(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_new_null() SKM_sk_new_null(ENGINE_CLEANUP_ITEM) +#define sk_ENGINE_CLEANUP_ITEM_free(st) SKM_sk_free(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_num(st) SKM_sk_num(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_value(st, i) SKM_sk_value(ENGINE_CLEANUP_ITEM, (st), (i)) +#define sk_ENGINE_CLEANUP_ITEM_set(st, i, val) SKM_sk_set(ENGINE_CLEANUP_ITEM, (st), (i), (val)) +#define sk_ENGINE_CLEANUP_ITEM_zero(st) SKM_sk_zero(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_push(st, val) SKM_sk_push(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_unshift(st, val) SKM_sk_unshift(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_find(st, val) SKM_sk_find(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_find_ex(st, val) SKM_sk_find_ex(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_delete(st, i) SKM_sk_delete(ENGINE_CLEANUP_ITEM, (st), (i)) +#define sk_ENGINE_CLEANUP_ITEM_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE_CLEANUP_ITEM, (st), (ptr)) +#define sk_ENGINE_CLEANUP_ITEM_insert(st, val, i) SKM_sk_insert(ENGINE_CLEANUP_ITEM, (st), (val), (i)) +#define sk_ENGINE_CLEANUP_ITEM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE_CLEANUP_ITEM, (st), (cmp)) +#define sk_ENGINE_CLEANUP_ITEM_dup(st) SKM_sk_dup(ENGINE_CLEANUP_ITEM, st) +#define sk_ENGINE_CLEANUP_ITEM_pop_free(st, free_func) SKM_sk_pop_free(ENGINE_CLEANUP_ITEM, (st), (free_func)) +#define sk_ENGINE_CLEANUP_ITEM_shift(st) SKM_sk_shift(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_pop(st) SKM_sk_pop(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_sort(st) SKM_sk_sort(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_is_sorted(st) SKM_sk_is_sorted(ENGINE_CLEANUP_ITEM, (st)) + +#define sk_GENERAL_NAME_new(st) SKM_sk_new(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME) +#define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_num(st) SKM_sk_num(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_value(st, i) SKM_sk_value(GENERAL_NAME, (st), (i)) +#define sk_GENERAL_NAME_set(st, i, val) SKM_sk_set(GENERAL_NAME, (st), (i), (val)) +#define sk_GENERAL_NAME_zero(st) SKM_sk_zero(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_push(st, val) SKM_sk_push(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_unshift(st, val) SKM_sk_unshift(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_find(st, val) SKM_sk_find(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_delete(st, i) SKM_sk_delete(GENERAL_NAME, (st), (i)) +#define sk_GENERAL_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAME, (st), (ptr)) +#define sk_GENERAL_NAME_insert(st, val, i) SKM_sk_insert(GENERAL_NAME, (st), (val), (i)) +#define sk_GENERAL_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAME, (st), (cmp)) +#define sk_GENERAL_NAME_dup(st) SKM_sk_dup(GENERAL_NAME, st) +#define sk_GENERAL_NAME_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAME, (st), (free_func)) +#define sk_GENERAL_NAME_shift(st) SKM_sk_shift(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_pop(st) SKM_sk_pop(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAME, (st)) + +#define sk_GENERAL_SUBTREE_new(st) SKM_sk_new(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_new_null() SKM_sk_new_null(GENERAL_SUBTREE) +#define sk_GENERAL_SUBTREE_free(st) SKM_sk_free(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_num(st) SKM_sk_num(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_value(st, i) SKM_sk_value(GENERAL_SUBTREE, (st), (i)) +#define sk_GENERAL_SUBTREE_set(st, i, val) SKM_sk_set(GENERAL_SUBTREE, (st), (i), (val)) +#define sk_GENERAL_SUBTREE_zero(st) SKM_sk_zero(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_push(st, val) SKM_sk_push(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_unshift(st, val) SKM_sk_unshift(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_find(st, val) SKM_sk_find(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_find_ex(st, val) SKM_sk_find_ex(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_delete(st, i) SKM_sk_delete(GENERAL_SUBTREE, (st), (i)) +#define sk_GENERAL_SUBTREE_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_SUBTREE, (st), (ptr)) +#define sk_GENERAL_SUBTREE_insert(st, val, i) SKM_sk_insert(GENERAL_SUBTREE, (st), (val), (i)) +#define sk_GENERAL_SUBTREE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_SUBTREE, (st), (cmp)) +#define sk_GENERAL_SUBTREE_dup(st) SKM_sk_dup(GENERAL_SUBTREE, st) +#define sk_GENERAL_SUBTREE_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_SUBTREE, (st), (free_func)) +#define sk_GENERAL_SUBTREE_shift(st) SKM_sk_shift(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_pop(st) SKM_sk_pop(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st)) + +#define sk_KRB5_APREQBODY_new(st) SKM_sk_new(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY) +#define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_num(st) SKM_sk_num(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_value(st, i) SKM_sk_value(KRB5_APREQBODY, (st), (i)) +#define sk_KRB5_APREQBODY_set(st, i, val) SKM_sk_set(KRB5_APREQBODY, (st), (i), (val)) +#define sk_KRB5_APREQBODY_zero(st) SKM_sk_zero(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_push(st, val) SKM_sk_push(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_unshift(st, val) SKM_sk_unshift(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_find(st, val) SKM_sk_find(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_delete(st, i) SKM_sk_delete(KRB5_APREQBODY, (st), (i)) +#define sk_KRB5_APREQBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_APREQBODY, (st), (ptr)) +#define sk_KRB5_APREQBODY_insert(st, val, i) SKM_sk_insert(KRB5_APREQBODY, (st), (val), (i)) +#define sk_KRB5_APREQBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_APREQBODY, (st), (cmp)) +#define sk_KRB5_APREQBODY_dup(st) SKM_sk_dup(KRB5_APREQBODY, st) +#define sk_KRB5_APREQBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_APREQBODY, (st), (free_func)) +#define sk_KRB5_APREQBODY_shift(st) SKM_sk_shift(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_pop(st) SKM_sk_pop(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_sort(st) SKM_sk_sort(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_APREQBODY, (st)) + +#define sk_KRB5_AUTHDATA_new(st) SKM_sk_new(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_new_null() SKM_sk_new_null(KRB5_AUTHDATA) +#define sk_KRB5_AUTHDATA_free(st) SKM_sk_free(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_num(st) SKM_sk_num(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_value(st, i) SKM_sk_value(KRB5_AUTHDATA, (st), (i)) +#define sk_KRB5_AUTHDATA_set(st, i, val) SKM_sk_set(KRB5_AUTHDATA, (st), (i), (val)) +#define sk_KRB5_AUTHDATA_zero(st) SKM_sk_zero(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_push(st, val) SKM_sk_push(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_unshift(st, val) SKM_sk_unshift(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_find(st, val) SKM_sk_find(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_delete(st, i) SKM_sk_delete(KRB5_AUTHDATA, (st), (i)) +#define sk_KRB5_AUTHDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHDATA, (st), (ptr)) +#define sk_KRB5_AUTHDATA_insert(st, val, i) SKM_sk_insert(KRB5_AUTHDATA, (st), (val), (i)) +#define sk_KRB5_AUTHDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHDATA, (st), (cmp)) +#define sk_KRB5_AUTHDATA_dup(st) SKM_sk_dup(KRB5_AUTHDATA, st) +#define sk_KRB5_AUTHDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHDATA, (st), (free_func)) +#define sk_KRB5_AUTHDATA_shift(st) SKM_sk_shift(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_pop(st) SKM_sk_pop(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_sort(st) SKM_sk_sort(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHDATA, (st)) + +#define sk_KRB5_AUTHENTBODY_new(st) SKM_sk_new(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_new_null() SKM_sk_new_null(KRB5_AUTHENTBODY) +#define sk_KRB5_AUTHENTBODY_free(st) SKM_sk_free(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_num(st) SKM_sk_num(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_value(st, i) SKM_sk_value(KRB5_AUTHENTBODY, (st), (i)) +#define sk_KRB5_AUTHENTBODY_set(st, i, val) SKM_sk_set(KRB5_AUTHENTBODY, (st), (i), (val)) +#define sk_KRB5_AUTHENTBODY_zero(st) SKM_sk_zero(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_push(st, val) SKM_sk_push(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_unshift(st, val) SKM_sk_unshift(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_find(st, val) SKM_sk_find(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_delete(st, i) SKM_sk_delete(KRB5_AUTHENTBODY, (st), (i)) +#define sk_KRB5_AUTHENTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHENTBODY, (st), (ptr)) +#define sk_KRB5_AUTHENTBODY_insert(st, val, i) SKM_sk_insert(KRB5_AUTHENTBODY, (st), (val), (i)) +#define sk_KRB5_AUTHENTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHENTBODY, (st), (cmp)) +#define sk_KRB5_AUTHENTBODY_dup(st) SKM_sk_dup(KRB5_AUTHENTBODY, st) +#define sk_KRB5_AUTHENTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHENTBODY, (st), (free_func)) +#define sk_KRB5_AUTHENTBODY_shift(st) SKM_sk_shift(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_pop(st) SKM_sk_pop(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_sort(st) SKM_sk_sort(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHENTBODY, (st)) + +#define sk_KRB5_CHECKSUM_new(st) SKM_sk_new(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_new_null() SKM_sk_new_null(KRB5_CHECKSUM) +#define sk_KRB5_CHECKSUM_free(st) SKM_sk_free(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_num(st) SKM_sk_num(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_value(st, i) SKM_sk_value(KRB5_CHECKSUM, (st), (i)) +#define sk_KRB5_CHECKSUM_set(st, i, val) SKM_sk_set(KRB5_CHECKSUM, (st), (i), (val)) +#define sk_KRB5_CHECKSUM_zero(st) SKM_sk_zero(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_push(st, val) SKM_sk_push(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_unshift(st, val) SKM_sk_unshift(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_find(st, val) SKM_sk_find(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_find_ex(st, val) SKM_sk_find_ex(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_delete(st, i) SKM_sk_delete(KRB5_CHECKSUM, (st), (i)) +#define sk_KRB5_CHECKSUM_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_CHECKSUM, (st), (ptr)) +#define sk_KRB5_CHECKSUM_insert(st, val, i) SKM_sk_insert(KRB5_CHECKSUM, (st), (val), (i)) +#define sk_KRB5_CHECKSUM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_CHECKSUM, (st), (cmp)) +#define sk_KRB5_CHECKSUM_dup(st) SKM_sk_dup(KRB5_CHECKSUM, st) +#define sk_KRB5_CHECKSUM_pop_free(st, free_func) SKM_sk_pop_free(KRB5_CHECKSUM, (st), (free_func)) +#define sk_KRB5_CHECKSUM_shift(st) SKM_sk_shift(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_pop(st) SKM_sk_pop(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_sort(st) SKM_sk_sort(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_is_sorted(st) SKM_sk_is_sorted(KRB5_CHECKSUM, (st)) + +#define sk_KRB5_ENCDATA_new(st) SKM_sk_new(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_new_null() SKM_sk_new_null(KRB5_ENCDATA) +#define sk_KRB5_ENCDATA_free(st) SKM_sk_free(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_num(st) SKM_sk_num(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_value(st, i) SKM_sk_value(KRB5_ENCDATA, (st), (i)) +#define sk_KRB5_ENCDATA_set(st, i, val) SKM_sk_set(KRB5_ENCDATA, (st), (i), (val)) +#define sk_KRB5_ENCDATA_zero(st) SKM_sk_zero(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_push(st, val) SKM_sk_push(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_unshift(st, val) SKM_sk_unshift(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_find(st, val) SKM_sk_find(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_delete(st, i) SKM_sk_delete(KRB5_ENCDATA, (st), (i)) +#define sk_KRB5_ENCDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCDATA, (st), (ptr)) +#define sk_KRB5_ENCDATA_insert(st, val, i) SKM_sk_insert(KRB5_ENCDATA, (st), (val), (i)) +#define sk_KRB5_ENCDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCDATA, (st), (cmp)) +#define sk_KRB5_ENCDATA_dup(st) SKM_sk_dup(KRB5_ENCDATA, st) +#define sk_KRB5_ENCDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCDATA, (st), (free_func)) +#define sk_KRB5_ENCDATA_shift(st) SKM_sk_shift(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_pop(st) SKM_sk_pop(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_sort(st) SKM_sk_sort(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCDATA, (st)) + +#define sk_KRB5_ENCKEY_new(st) SKM_sk_new(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_new_null() SKM_sk_new_null(KRB5_ENCKEY) +#define sk_KRB5_ENCKEY_free(st) SKM_sk_free(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_num(st) SKM_sk_num(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_value(st, i) SKM_sk_value(KRB5_ENCKEY, (st), (i)) +#define sk_KRB5_ENCKEY_set(st, i, val) SKM_sk_set(KRB5_ENCKEY, (st), (i), (val)) +#define sk_KRB5_ENCKEY_zero(st) SKM_sk_zero(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_push(st, val) SKM_sk_push(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_unshift(st, val) SKM_sk_unshift(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_find(st, val) SKM_sk_find(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_delete(st, i) SKM_sk_delete(KRB5_ENCKEY, (st), (i)) +#define sk_KRB5_ENCKEY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCKEY, (st), (ptr)) +#define sk_KRB5_ENCKEY_insert(st, val, i) SKM_sk_insert(KRB5_ENCKEY, (st), (val), (i)) +#define sk_KRB5_ENCKEY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCKEY, (st), (cmp)) +#define sk_KRB5_ENCKEY_dup(st) SKM_sk_dup(KRB5_ENCKEY, st) +#define sk_KRB5_ENCKEY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCKEY, (st), (free_func)) +#define sk_KRB5_ENCKEY_shift(st) SKM_sk_shift(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_pop(st) SKM_sk_pop(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_sort(st) SKM_sk_sort(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCKEY, (st)) + +#define sk_KRB5_PRINCNAME_new(st) SKM_sk_new(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_new_null() SKM_sk_new_null(KRB5_PRINCNAME) +#define sk_KRB5_PRINCNAME_free(st) SKM_sk_free(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_num(st) SKM_sk_num(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_value(st, i) SKM_sk_value(KRB5_PRINCNAME, (st), (i)) +#define sk_KRB5_PRINCNAME_set(st, i, val) SKM_sk_set(KRB5_PRINCNAME, (st), (i), (val)) +#define sk_KRB5_PRINCNAME_zero(st) SKM_sk_zero(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_push(st, val) SKM_sk_push(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_unshift(st, val) SKM_sk_unshift(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_find(st, val) SKM_sk_find(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_find_ex(st, val) SKM_sk_find_ex(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_delete(st, i) SKM_sk_delete(KRB5_PRINCNAME, (st), (i)) +#define sk_KRB5_PRINCNAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_PRINCNAME, (st), (ptr)) +#define sk_KRB5_PRINCNAME_insert(st, val, i) SKM_sk_insert(KRB5_PRINCNAME, (st), (val), (i)) +#define sk_KRB5_PRINCNAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_PRINCNAME, (st), (cmp)) +#define sk_KRB5_PRINCNAME_dup(st) SKM_sk_dup(KRB5_PRINCNAME, st) +#define sk_KRB5_PRINCNAME_pop_free(st, free_func) SKM_sk_pop_free(KRB5_PRINCNAME, (st), (free_func)) +#define sk_KRB5_PRINCNAME_shift(st) SKM_sk_shift(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_pop(st) SKM_sk_pop(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_sort(st) SKM_sk_sort(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_is_sorted(st) SKM_sk_is_sorted(KRB5_PRINCNAME, (st)) + +#define sk_KRB5_TKTBODY_new(st) SKM_sk_new(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_new_null() SKM_sk_new_null(KRB5_TKTBODY) +#define sk_KRB5_TKTBODY_free(st) SKM_sk_free(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_num(st) SKM_sk_num(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_value(st, i) SKM_sk_value(KRB5_TKTBODY, (st), (i)) +#define sk_KRB5_TKTBODY_set(st, i, val) SKM_sk_set(KRB5_TKTBODY, (st), (i), (val)) +#define sk_KRB5_TKTBODY_zero(st) SKM_sk_zero(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_push(st, val) SKM_sk_push(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_unshift(st, val) SKM_sk_unshift(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_find(st, val) SKM_sk_find(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_delete(st, i) SKM_sk_delete(KRB5_TKTBODY, (st), (i)) +#define sk_KRB5_TKTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_TKTBODY, (st), (ptr)) +#define sk_KRB5_TKTBODY_insert(st, val, i) SKM_sk_insert(KRB5_TKTBODY, (st), (val), (i)) +#define sk_KRB5_TKTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_TKTBODY, (st), (cmp)) +#define sk_KRB5_TKTBODY_dup(st) SKM_sk_dup(KRB5_TKTBODY, st) +#define sk_KRB5_TKTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_TKTBODY, (st), (free_func)) +#define sk_KRB5_TKTBODY_shift(st) SKM_sk_shift(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_pop(st) SKM_sk_pop(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_sort(st) SKM_sk_sort(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_TKTBODY, (st)) + +#define sk_MIME_HEADER_new(st) SKM_sk_new(MIME_HEADER, (st)) +#define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER) +#define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st)) +#define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st)) +#define sk_MIME_HEADER_value(st, i) SKM_sk_value(MIME_HEADER, (st), (i)) +#define sk_MIME_HEADER_set(st, i, val) SKM_sk_set(MIME_HEADER, (st), (i), (val)) +#define sk_MIME_HEADER_zero(st) SKM_sk_zero(MIME_HEADER, (st)) +#define sk_MIME_HEADER_push(st, val) SKM_sk_push(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_unshift(st, val) SKM_sk_unshift(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_find(st, val) SKM_sk_find(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_find_ex(st, val) SKM_sk_find_ex(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_delete(st, i) SKM_sk_delete(MIME_HEADER, (st), (i)) +#define sk_MIME_HEADER_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_HEADER, (st), (ptr)) +#define sk_MIME_HEADER_insert(st, val, i) SKM_sk_insert(MIME_HEADER, (st), (val), (i)) +#define sk_MIME_HEADER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_HEADER, (st), (cmp)) +#define sk_MIME_HEADER_dup(st) SKM_sk_dup(MIME_HEADER, st) +#define sk_MIME_HEADER_pop_free(st, free_func) SKM_sk_pop_free(MIME_HEADER, (st), (free_func)) +#define sk_MIME_HEADER_shift(st) SKM_sk_shift(MIME_HEADER, (st)) +#define sk_MIME_HEADER_pop(st) SKM_sk_pop(MIME_HEADER, (st)) +#define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st)) +#define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st)) + +#define sk_MIME_PARAM_new(st) SKM_sk_new(MIME_PARAM, (st)) +#define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM) +#define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st)) +#define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st)) +#define sk_MIME_PARAM_value(st, i) SKM_sk_value(MIME_PARAM, (st), (i)) +#define sk_MIME_PARAM_set(st, i, val) SKM_sk_set(MIME_PARAM, (st), (i), (val)) +#define sk_MIME_PARAM_zero(st) SKM_sk_zero(MIME_PARAM, (st)) +#define sk_MIME_PARAM_push(st, val) SKM_sk_push(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_unshift(st, val) SKM_sk_unshift(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_find(st, val) SKM_sk_find(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_find_ex(st, val) SKM_sk_find_ex(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_delete(st, i) SKM_sk_delete(MIME_PARAM, (st), (i)) +#define sk_MIME_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_PARAM, (st), (ptr)) +#define sk_MIME_PARAM_insert(st, val, i) SKM_sk_insert(MIME_PARAM, (st), (val), (i)) +#define sk_MIME_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_PARAM, (st), (cmp)) +#define sk_MIME_PARAM_dup(st) SKM_sk_dup(MIME_PARAM, st) +#define sk_MIME_PARAM_pop_free(st, free_func) SKM_sk_pop_free(MIME_PARAM, (st), (free_func)) +#define sk_MIME_PARAM_shift(st) SKM_sk_shift(MIME_PARAM, (st)) +#define sk_MIME_PARAM_pop(st) SKM_sk_pop(MIME_PARAM, (st)) +#define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st)) +#define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st)) + +#define sk_NAME_FUNCS_new(st) SKM_sk_new(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_new_null() SKM_sk_new_null(NAME_FUNCS) +#define sk_NAME_FUNCS_free(st) SKM_sk_free(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_num(st) SKM_sk_num(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_value(st, i) SKM_sk_value(NAME_FUNCS, (st), (i)) +#define sk_NAME_FUNCS_set(st, i, val) SKM_sk_set(NAME_FUNCS, (st), (i), (val)) +#define sk_NAME_FUNCS_zero(st) SKM_sk_zero(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_push(st, val) SKM_sk_push(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_unshift(st, val) SKM_sk_unshift(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_find(st, val) SKM_sk_find(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_find_ex(st, val) SKM_sk_find_ex(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_delete(st, i) SKM_sk_delete(NAME_FUNCS, (st), (i)) +#define sk_NAME_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(NAME_FUNCS, (st), (ptr)) +#define sk_NAME_FUNCS_insert(st, val, i) SKM_sk_insert(NAME_FUNCS, (st), (val), (i)) +#define sk_NAME_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(NAME_FUNCS, (st), (cmp)) +#define sk_NAME_FUNCS_dup(st) SKM_sk_dup(NAME_FUNCS, st) +#define sk_NAME_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(NAME_FUNCS, (st), (free_func)) +#define sk_NAME_FUNCS_shift(st) SKM_sk_shift(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_pop(st) SKM_sk_pop(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_is_sorted(st) SKM_sk_is_sorted(NAME_FUNCS, (st)) + +#define sk_OCSP_CERTID_new(st) SKM_sk_new(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_new_null() SKM_sk_new_null(OCSP_CERTID) +#define sk_OCSP_CERTID_free(st) SKM_sk_free(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_num(st) SKM_sk_num(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_value(st, i) SKM_sk_value(OCSP_CERTID, (st), (i)) +#define sk_OCSP_CERTID_set(st, i, val) SKM_sk_set(OCSP_CERTID, (st), (i), (val)) +#define sk_OCSP_CERTID_zero(st) SKM_sk_zero(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_push(st, val) SKM_sk_push(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_unshift(st, val) SKM_sk_unshift(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_find(st, val) SKM_sk_find(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_find_ex(st, val) SKM_sk_find_ex(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_delete(st, i) SKM_sk_delete(OCSP_CERTID, (st), (i)) +#define sk_OCSP_CERTID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_CERTID, (st), (ptr)) +#define sk_OCSP_CERTID_insert(st, val, i) SKM_sk_insert(OCSP_CERTID, (st), (val), (i)) +#define sk_OCSP_CERTID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_CERTID, (st), (cmp)) +#define sk_OCSP_CERTID_dup(st) SKM_sk_dup(OCSP_CERTID, st) +#define sk_OCSP_CERTID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_CERTID, (st), (free_func)) +#define sk_OCSP_CERTID_shift(st) SKM_sk_shift(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_pop(st) SKM_sk_pop(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_sort(st) SKM_sk_sort(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_is_sorted(st) SKM_sk_is_sorted(OCSP_CERTID, (st)) + +#define sk_OCSP_ONEREQ_new(st) SKM_sk_new(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_new_null() SKM_sk_new_null(OCSP_ONEREQ) +#define sk_OCSP_ONEREQ_free(st) SKM_sk_free(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_num(st) SKM_sk_num(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_value(st, i) SKM_sk_value(OCSP_ONEREQ, (st), (i)) +#define sk_OCSP_ONEREQ_set(st, i, val) SKM_sk_set(OCSP_ONEREQ, (st), (i), (val)) +#define sk_OCSP_ONEREQ_zero(st) SKM_sk_zero(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_push(st, val) SKM_sk_push(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_unshift(st, val) SKM_sk_unshift(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_find(st, val) SKM_sk_find(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_find_ex(st, val) SKM_sk_find_ex(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_delete(st, i) SKM_sk_delete(OCSP_ONEREQ, (st), (i)) +#define sk_OCSP_ONEREQ_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_ONEREQ, (st), (ptr)) +#define sk_OCSP_ONEREQ_insert(st, val, i) SKM_sk_insert(OCSP_ONEREQ, (st), (val), (i)) +#define sk_OCSP_ONEREQ_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_ONEREQ, (st), (cmp)) +#define sk_OCSP_ONEREQ_dup(st) SKM_sk_dup(OCSP_ONEREQ, st) +#define sk_OCSP_ONEREQ_pop_free(st, free_func) SKM_sk_pop_free(OCSP_ONEREQ, (st), (free_func)) +#define sk_OCSP_ONEREQ_shift(st) SKM_sk_shift(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_pop(st) SKM_sk_pop(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_sort(st) SKM_sk_sort(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_is_sorted(st) SKM_sk_is_sorted(OCSP_ONEREQ, (st)) + +#define sk_OCSP_SINGLERESP_new(st) SKM_sk_new(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_new_null() SKM_sk_new_null(OCSP_SINGLERESP) +#define sk_OCSP_SINGLERESP_free(st) SKM_sk_free(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_num(st) SKM_sk_num(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_value(st, i) SKM_sk_value(OCSP_SINGLERESP, (st), (i)) +#define sk_OCSP_SINGLERESP_set(st, i, val) SKM_sk_set(OCSP_SINGLERESP, (st), (i), (val)) +#define sk_OCSP_SINGLERESP_zero(st) SKM_sk_zero(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_push(st, val) SKM_sk_push(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_unshift(st, val) SKM_sk_unshift(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_find(st, val) SKM_sk_find(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_find_ex(st, val) SKM_sk_find_ex(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_delete(st, i) SKM_sk_delete(OCSP_SINGLERESP, (st), (i)) +#define sk_OCSP_SINGLERESP_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_SINGLERESP, (st), (ptr)) +#define sk_OCSP_SINGLERESP_insert(st, val, i) SKM_sk_insert(OCSP_SINGLERESP, (st), (val), (i)) +#define sk_OCSP_SINGLERESP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_SINGLERESP, (st), (cmp)) +#define sk_OCSP_SINGLERESP_dup(st) SKM_sk_dup(OCSP_SINGLERESP, st) +#define sk_OCSP_SINGLERESP_pop_free(st, free_func) SKM_sk_pop_free(OCSP_SINGLERESP, (st), (free_func)) +#define sk_OCSP_SINGLERESP_shift(st) SKM_sk_shift(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_pop(st) SKM_sk_pop(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_sort(st) SKM_sk_sort(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_is_sorted(st) SKM_sk_is_sorted(OCSP_SINGLERESP, (st)) + +#define sk_PKCS12_SAFEBAG_new(st) SKM_sk_new(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG) +#define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_num(st) SKM_sk_num(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_value(st, i) SKM_sk_value(PKCS12_SAFEBAG, (st), (i)) +#define sk_PKCS12_SAFEBAG_set(st, i, val) SKM_sk_set(PKCS12_SAFEBAG, (st), (i), (val)) +#define sk_PKCS12_SAFEBAG_zero(st) SKM_sk_zero(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_push(st, val) SKM_sk_push(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_unshift(st, val) SKM_sk_unshift(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_find(st, val) SKM_sk_find(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_find_ex(st, val) SKM_sk_find_ex(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_delete(st, i) SKM_sk_delete(PKCS12_SAFEBAG, (st), (i)) +#define sk_PKCS12_SAFEBAG_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS12_SAFEBAG, (st), (ptr)) +#define sk_PKCS12_SAFEBAG_insert(st, val, i) SKM_sk_insert(PKCS12_SAFEBAG, (st), (val), (i)) +#define sk_PKCS12_SAFEBAG_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS12_SAFEBAG, (st), (cmp)) +#define sk_PKCS12_SAFEBAG_dup(st) SKM_sk_dup(PKCS12_SAFEBAG, st) +#define sk_PKCS12_SAFEBAG_pop_free(st, free_func) SKM_sk_pop_free(PKCS12_SAFEBAG, (st), (free_func)) +#define sk_PKCS12_SAFEBAG_shift(st) SKM_sk_shift(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_pop(st) SKM_sk_pop(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_sort(st) SKM_sk_sort(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_is_sorted(st) SKM_sk_is_sorted(PKCS12_SAFEBAG, (st)) + +#define sk_PKCS7_new(st) SKM_sk_new(PKCS7, (st)) +#define sk_PKCS7_new_null() SKM_sk_new_null(PKCS7) +#define sk_PKCS7_free(st) SKM_sk_free(PKCS7, (st)) +#define sk_PKCS7_num(st) SKM_sk_num(PKCS7, (st)) +#define sk_PKCS7_value(st, i) SKM_sk_value(PKCS7, (st), (i)) +#define sk_PKCS7_set(st, i, val) SKM_sk_set(PKCS7, (st), (i), (val)) +#define sk_PKCS7_zero(st) SKM_sk_zero(PKCS7, (st)) +#define sk_PKCS7_push(st, val) SKM_sk_push(PKCS7, (st), (val)) +#define sk_PKCS7_unshift(st, val) SKM_sk_unshift(PKCS7, (st), (val)) +#define sk_PKCS7_find(st, val) SKM_sk_find(PKCS7, (st), (val)) +#define sk_PKCS7_find_ex(st, val) SKM_sk_find_ex(PKCS7, (st), (val)) +#define sk_PKCS7_delete(st, i) SKM_sk_delete(PKCS7, (st), (i)) +#define sk_PKCS7_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7, (st), (ptr)) +#define sk_PKCS7_insert(st, val, i) SKM_sk_insert(PKCS7, (st), (val), (i)) +#define sk_PKCS7_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7, (st), (cmp)) +#define sk_PKCS7_dup(st) SKM_sk_dup(PKCS7, st) +#define sk_PKCS7_pop_free(st, free_func) SKM_sk_pop_free(PKCS7, (st), (free_func)) +#define sk_PKCS7_shift(st) SKM_sk_shift(PKCS7, (st)) +#define sk_PKCS7_pop(st) SKM_sk_pop(PKCS7, (st)) +#define sk_PKCS7_sort(st) SKM_sk_sort(PKCS7, (st)) +#define sk_PKCS7_is_sorted(st) SKM_sk_is_sorted(PKCS7, (st)) + +#define sk_PKCS7_RECIP_INFO_new(st) SKM_sk_new(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_new_null() SKM_sk_new_null(PKCS7_RECIP_INFO) +#define sk_PKCS7_RECIP_INFO_free(st) SKM_sk_free(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_num(st) SKM_sk_num(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_value(st, i) SKM_sk_value(PKCS7_RECIP_INFO, (st), (i)) +#define sk_PKCS7_RECIP_INFO_set(st, i, val) SKM_sk_set(PKCS7_RECIP_INFO, (st), (i), (val)) +#define sk_PKCS7_RECIP_INFO_zero(st) SKM_sk_zero(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_push(st, val) SKM_sk_push(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_find(st, val) SKM_sk_find(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_delete(st, i) SKM_sk_delete(PKCS7_RECIP_INFO, (st), (i)) +#define sk_PKCS7_RECIP_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_RECIP_INFO, (st), (ptr)) +#define sk_PKCS7_RECIP_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_RECIP_INFO, (st), (val), (i)) +#define sk_PKCS7_RECIP_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_RECIP_INFO, (st), (cmp)) +#define sk_PKCS7_RECIP_INFO_dup(st) SKM_sk_dup(PKCS7_RECIP_INFO, st) +#define sk_PKCS7_RECIP_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_RECIP_INFO, (st), (free_func)) +#define sk_PKCS7_RECIP_INFO_shift(st) SKM_sk_shift(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_pop(st) SKM_sk_pop(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_sort(st) SKM_sk_sort(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_RECIP_INFO, (st)) + +#define sk_PKCS7_SIGNER_INFO_new(st) SKM_sk_new(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_new_null() SKM_sk_new_null(PKCS7_SIGNER_INFO) +#define sk_PKCS7_SIGNER_INFO_free(st) SKM_sk_free(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_num(st) SKM_sk_num(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_value(st, i) SKM_sk_value(PKCS7_SIGNER_INFO, (st), (i)) +#define sk_PKCS7_SIGNER_INFO_set(st, i, val) SKM_sk_set(PKCS7_SIGNER_INFO, (st), (i), (val)) +#define sk_PKCS7_SIGNER_INFO_zero(st) SKM_sk_zero(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_push(st, val) SKM_sk_push(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_find(st, val) SKM_sk_find(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_delete(st, i) SKM_sk_delete(PKCS7_SIGNER_INFO, (st), (i)) +#define sk_PKCS7_SIGNER_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_SIGNER_INFO, (st), (ptr)) +#define sk_PKCS7_SIGNER_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_SIGNER_INFO, (st), (val), (i)) +#define sk_PKCS7_SIGNER_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_SIGNER_INFO, (st), (cmp)) +#define sk_PKCS7_SIGNER_INFO_dup(st) SKM_sk_dup(PKCS7_SIGNER_INFO, st) +#define sk_PKCS7_SIGNER_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_SIGNER_INFO, (st), (free_func)) +#define sk_PKCS7_SIGNER_INFO_shift(st) SKM_sk_shift(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_pop(st) SKM_sk_pop(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_sort(st) SKM_sk_sort(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_SIGNER_INFO, (st)) + +#define sk_POLICYINFO_new(st) SKM_sk_new(POLICYINFO, (st)) +#define sk_POLICYINFO_new_null() SKM_sk_new_null(POLICYINFO) +#define sk_POLICYINFO_free(st) SKM_sk_free(POLICYINFO, (st)) +#define sk_POLICYINFO_num(st) SKM_sk_num(POLICYINFO, (st)) +#define sk_POLICYINFO_value(st, i) SKM_sk_value(POLICYINFO, (st), (i)) +#define sk_POLICYINFO_set(st, i, val) SKM_sk_set(POLICYINFO, (st), (i), (val)) +#define sk_POLICYINFO_zero(st) SKM_sk_zero(POLICYINFO, (st)) +#define sk_POLICYINFO_push(st, val) SKM_sk_push(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_unshift(st, val) SKM_sk_unshift(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_find(st, val) SKM_sk_find(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_find_ex(st, val) SKM_sk_find_ex(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_delete(st, i) SKM_sk_delete(POLICYINFO, (st), (i)) +#define sk_POLICYINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYINFO, (st), (ptr)) +#define sk_POLICYINFO_insert(st, val, i) SKM_sk_insert(POLICYINFO, (st), (val), (i)) +#define sk_POLICYINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYINFO, (st), (cmp)) +#define sk_POLICYINFO_dup(st) SKM_sk_dup(POLICYINFO, st) +#define sk_POLICYINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYINFO, (st), (free_func)) +#define sk_POLICYINFO_shift(st) SKM_sk_shift(POLICYINFO, (st)) +#define sk_POLICYINFO_pop(st) SKM_sk_pop(POLICYINFO, (st)) +#define sk_POLICYINFO_sort(st) SKM_sk_sort(POLICYINFO, (st)) +#define sk_POLICYINFO_is_sorted(st) SKM_sk_is_sorted(POLICYINFO, (st)) + +#define sk_POLICYQUALINFO_new(st) SKM_sk_new(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_new_null() SKM_sk_new_null(POLICYQUALINFO) +#define sk_POLICYQUALINFO_free(st) SKM_sk_free(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_num(st) SKM_sk_num(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_value(st, i) SKM_sk_value(POLICYQUALINFO, (st), (i)) +#define sk_POLICYQUALINFO_set(st, i, val) SKM_sk_set(POLICYQUALINFO, (st), (i), (val)) +#define sk_POLICYQUALINFO_zero(st) SKM_sk_zero(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_push(st, val) SKM_sk_push(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_unshift(st, val) SKM_sk_unshift(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_find(st, val) SKM_sk_find(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_find_ex(st, val) SKM_sk_find_ex(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_delete(st, i) SKM_sk_delete(POLICYQUALINFO, (st), (i)) +#define sk_POLICYQUALINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYQUALINFO, (st), (ptr)) +#define sk_POLICYQUALINFO_insert(st, val, i) SKM_sk_insert(POLICYQUALINFO, (st), (val), (i)) +#define sk_POLICYQUALINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYQUALINFO, (st), (cmp)) +#define sk_POLICYQUALINFO_dup(st) SKM_sk_dup(POLICYQUALINFO, st) +#define sk_POLICYQUALINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYQUALINFO, (st), (free_func)) +#define sk_POLICYQUALINFO_shift(st) SKM_sk_shift(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_pop(st) SKM_sk_pop(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_sort(st) SKM_sk_sort(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_is_sorted(st) SKM_sk_is_sorted(POLICYQUALINFO, (st)) + +#define sk_POLICY_MAPPING_new(st) SKM_sk_new(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_new_null() SKM_sk_new_null(POLICY_MAPPING) +#define sk_POLICY_MAPPING_free(st) SKM_sk_free(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_num(st) SKM_sk_num(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_value(st, i) SKM_sk_value(POLICY_MAPPING, (st), (i)) +#define sk_POLICY_MAPPING_set(st, i, val) SKM_sk_set(POLICY_MAPPING, (st), (i), (val)) +#define sk_POLICY_MAPPING_zero(st) SKM_sk_zero(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_push(st, val) SKM_sk_push(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_unshift(st, val) SKM_sk_unshift(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_find(st, val) SKM_sk_find(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_find_ex(st, val) SKM_sk_find_ex(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_delete(st, i) SKM_sk_delete(POLICY_MAPPING, (st), (i)) +#define sk_POLICY_MAPPING_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICY_MAPPING, (st), (ptr)) +#define sk_POLICY_MAPPING_insert(st, val, i) SKM_sk_insert(POLICY_MAPPING, (st), (val), (i)) +#define sk_POLICY_MAPPING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICY_MAPPING, (st), (cmp)) +#define sk_POLICY_MAPPING_dup(st) SKM_sk_dup(POLICY_MAPPING, st) +#define sk_POLICY_MAPPING_pop_free(st, free_func) SKM_sk_pop_free(POLICY_MAPPING, (st), (free_func)) +#define sk_POLICY_MAPPING_shift(st) SKM_sk_shift(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_pop(st) SKM_sk_pop(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_sort(st) SKM_sk_sort(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_is_sorted(st) SKM_sk_is_sorted(POLICY_MAPPING, (st)) + +#define sk_SSL_CIPHER_new(st) SKM_sk_new(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_new_null() SKM_sk_new_null(SSL_CIPHER) +#define sk_SSL_CIPHER_free(st) SKM_sk_free(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_num(st) SKM_sk_num(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_value(st, i) SKM_sk_value(SSL_CIPHER, (st), (i)) +#define sk_SSL_CIPHER_set(st, i, val) SKM_sk_set(SSL_CIPHER, (st), (i), (val)) +#define sk_SSL_CIPHER_zero(st) SKM_sk_zero(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_push(st, val) SKM_sk_push(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_unshift(st, val) SKM_sk_unshift(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_find(st, val) SKM_sk_find(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_find_ex(st, val) SKM_sk_find_ex(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_delete(st, i) SKM_sk_delete(SSL_CIPHER, (st), (i)) +#define sk_SSL_CIPHER_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_CIPHER, (st), (ptr)) +#define sk_SSL_CIPHER_insert(st, val, i) SKM_sk_insert(SSL_CIPHER, (st), (val), (i)) +#define sk_SSL_CIPHER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_CIPHER, (st), (cmp)) +#define sk_SSL_CIPHER_dup(st) SKM_sk_dup(SSL_CIPHER, st) +#define sk_SSL_CIPHER_pop_free(st, free_func) SKM_sk_pop_free(SSL_CIPHER, (st), (free_func)) +#define sk_SSL_CIPHER_shift(st) SKM_sk_shift(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_pop(st) SKM_sk_pop(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_sort(st) SKM_sk_sort(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_is_sorted(st) SKM_sk_is_sorted(SSL_CIPHER, (st)) + +#define sk_SSL_COMP_new(st) SKM_sk_new(SSL_COMP, (st)) +#define sk_SSL_COMP_new_null() SKM_sk_new_null(SSL_COMP) +#define sk_SSL_COMP_free(st) SKM_sk_free(SSL_COMP, (st)) +#define sk_SSL_COMP_num(st) SKM_sk_num(SSL_COMP, (st)) +#define sk_SSL_COMP_value(st, i) SKM_sk_value(SSL_COMP, (st), (i)) +#define sk_SSL_COMP_set(st, i, val) SKM_sk_set(SSL_COMP, (st), (i), (val)) +#define sk_SSL_COMP_zero(st) SKM_sk_zero(SSL_COMP, (st)) +#define sk_SSL_COMP_push(st, val) SKM_sk_push(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_unshift(st, val) SKM_sk_unshift(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_find(st, val) SKM_sk_find(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_find_ex(st, val) SKM_sk_find_ex(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_delete(st, i) SKM_sk_delete(SSL_COMP, (st), (i)) +#define sk_SSL_COMP_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_COMP, (st), (ptr)) +#define sk_SSL_COMP_insert(st, val, i) SKM_sk_insert(SSL_COMP, (st), (val), (i)) +#define sk_SSL_COMP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_COMP, (st), (cmp)) +#define sk_SSL_COMP_dup(st) SKM_sk_dup(SSL_COMP, st) +#define sk_SSL_COMP_pop_free(st, free_func) SKM_sk_pop_free(SSL_COMP, (st), (free_func)) +#define sk_SSL_COMP_shift(st) SKM_sk_shift(SSL_COMP, (st)) +#define sk_SSL_COMP_pop(st) SKM_sk_pop(SSL_COMP, (st)) +#define sk_SSL_COMP_sort(st) SKM_sk_sort(SSL_COMP, (st)) +#define sk_SSL_COMP_is_sorted(st) SKM_sk_is_sorted(SSL_COMP, (st)) + +#define sk_STORE_OBJECT_new(st) SKM_sk_new(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_new_null() SKM_sk_new_null(STORE_OBJECT) +#define sk_STORE_OBJECT_free(st) SKM_sk_free(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_num(st) SKM_sk_num(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_value(st, i) SKM_sk_value(STORE_OBJECT, (st), (i)) +#define sk_STORE_OBJECT_set(st, i, val) SKM_sk_set(STORE_OBJECT, (st), (i), (val)) +#define sk_STORE_OBJECT_zero(st) SKM_sk_zero(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_push(st, val) SKM_sk_push(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_unshift(st, val) SKM_sk_unshift(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_find(st, val) SKM_sk_find(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_find_ex(st, val) SKM_sk_find_ex(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_delete(st, i) SKM_sk_delete(STORE_OBJECT, (st), (i)) +#define sk_STORE_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_OBJECT, (st), (ptr)) +#define sk_STORE_OBJECT_insert(st, val, i) SKM_sk_insert(STORE_OBJECT, (st), (val), (i)) +#define sk_STORE_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_OBJECT, (st), (cmp)) +#define sk_STORE_OBJECT_dup(st) SKM_sk_dup(STORE_OBJECT, st) +#define sk_STORE_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(STORE_OBJECT, (st), (free_func)) +#define sk_STORE_OBJECT_shift(st) SKM_sk_shift(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_pop(st) SKM_sk_pop(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_sort(st) SKM_sk_sort(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_is_sorted(st) SKM_sk_is_sorted(STORE_OBJECT, (st)) + +#define sk_SXNETID_new(st) SKM_sk_new(SXNETID, (st)) +#define sk_SXNETID_new_null() SKM_sk_new_null(SXNETID) +#define sk_SXNETID_free(st) SKM_sk_free(SXNETID, (st)) +#define sk_SXNETID_num(st) SKM_sk_num(SXNETID, (st)) +#define sk_SXNETID_value(st, i) SKM_sk_value(SXNETID, (st), (i)) +#define sk_SXNETID_set(st, i, val) SKM_sk_set(SXNETID, (st), (i), (val)) +#define sk_SXNETID_zero(st) SKM_sk_zero(SXNETID, (st)) +#define sk_SXNETID_push(st, val) SKM_sk_push(SXNETID, (st), (val)) +#define sk_SXNETID_unshift(st, val) SKM_sk_unshift(SXNETID, (st), (val)) +#define sk_SXNETID_find(st, val) SKM_sk_find(SXNETID, (st), (val)) +#define sk_SXNETID_find_ex(st, val) SKM_sk_find_ex(SXNETID, (st), (val)) +#define sk_SXNETID_delete(st, i) SKM_sk_delete(SXNETID, (st), (i)) +#define sk_SXNETID_delete_ptr(st, ptr) SKM_sk_delete_ptr(SXNETID, (st), (ptr)) +#define sk_SXNETID_insert(st, val, i) SKM_sk_insert(SXNETID, (st), (val), (i)) +#define sk_SXNETID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SXNETID, (st), (cmp)) +#define sk_SXNETID_dup(st) SKM_sk_dup(SXNETID, st) +#define sk_SXNETID_pop_free(st, free_func) SKM_sk_pop_free(SXNETID, (st), (free_func)) +#define sk_SXNETID_shift(st) SKM_sk_shift(SXNETID, (st)) +#define sk_SXNETID_pop(st) SKM_sk_pop(SXNETID, (st)) +#define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st)) +#define sk_SXNETID_is_sorted(st) SKM_sk_is_sorted(SXNETID, (st)) + +#define sk_UI_STRING_new(st) SKM_sk_new(UI_STRING, (st)) +#define sk_UI_STRING_new_null() SKM_sk_new_null(UI_STRING) +#define sk_UI_STRING_free(st) SKM_sk_free(UI_STRING, (st)) +#define sk_UI_STRING_num(st) SKM_sk_num(UI_STRING, (st)) +#define sk_UI_STRING_value(st, i) SKM_sk_value(UI_STRING, (st), (i)) +#define sk_UI_STRING_set(st, i, val) SKM_sk_set(UI_STRING, (st), (i), (val)) +#define sk_UI_STRING_zero(st) SKM_sk_zero(UI_STRING, (st)) +#define sk_UI_STRING_push(st, val) SKM_sk_push(UI_STRING, (st), (val)) +#define sk_UI_STRING_unshift(st, val) SKM_sk_unshift(UI_STRING, (st), (val)) +#define sk_UI_STRING_find(st, val) SKM_sk_find(UI_STRING, (st), (val)) +#define sk_UI_STRING_find_ex(st, val) SKM_sk_find_ex(UI_STRING, (st), (val)) +#define sk_UI_STRING_delete(st, i) SKM_sk_delete(UI_STRING, (st), (i)) +#define sk_UI_STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(UI_STRING, (st), (ptr)) +#define sk_UI_STRING_insert(st, val, i) SKM_sk_insert(UI_STRING, (st), (val), (i)) +#define sk_UI_STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(UI_STRING, (st), (cmp)) +#define sk_UI_STRING_dup(st) SKM_sk_dup(UI_STRING, st) +#define sk_UI_STRING_pop_free(st, free_func) SKM_sk_pop_free(UI_STRING, (st), (free_func)) +#define sk_UI_STRING_shift(st) SKM_sk_shift(UI_STRING, (st)) +#define sk_UI_STRING_pop(st) SKM_sk_pop(UI_STRING, (st)) +#define sk_UI_STRING_sort(st) SKM_sk_sort(UI_STRING, (st)) +#define sk_UI_STRING_is_sorted(st) SKM_sk_is_sorted(UI_STRING, (st)) + +#define sk_X509_new(st) SKM_sk_new(X509, (st)) +#define sk_X509_new_null() SKM_sk_new_null(X509) +#define sk_X509_free(st) SKM_sk_free(X509, (st)) +#define sk_X509_num(st) SKM_sk_num(X509, (st)) +#define sk_X509_value(st, i) SKM_sk_value(X509, (st), (i)) +#define sk_X509_set(st, i, val) SKM_sk_set(X509, (st), (i), (val)) +#define sk_X509_zero(st) SKM_sk_zero(X509, (st)) +#define sk_X509_push(st, val) SKM_sk_push(X509, (st), (val)) +#define sk_X509_unshift(st, val) SKM_sk_unshift(X509, (st), (val)) +#define sk_X509_find(st, val) SKM_sk_find(X509, (st), (val)) +#define sk_X509_find_ex(st, val) SKM_sk_find_ex(X509, (st), (val)) +#define sk_X509_delete(st, i) SKM_sk_delete(X509, (st), (i)) +#define sk_X509_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509, (st), (ptr)) +#define sk_X509_insert(st, val, i) SKM_sk_insert(X509, (st), (val), (i)) +#define sk_X509_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509, (st), (cmp)) +#define sk_X509_dup(st) SKM_sk_dup(X509, st) +#define sk_X509_pop_free(st, free_func) SKM_sk_pop_free(X509, (st), (free_func)) +#define sk_X509_shift(st) SKM_sk_shift(X509, (st)) +#define sk_X509_pop(st) SKM_sk_pop(X509, (st)) +#define sk_X509_sort(st) SKM_sk_sort(X509, (st)) +#define sk_X509_is_sorted(st) SKM_sk_is_sorted(X509, (st)) + +#define sk_X509V3_EXT_METHOD_new(st) SKM_sk_new(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_new_null() SKM_sk_new_null(X509V3_EXT_METHOD) +#define sk_X509V3_EXT_METHOD_free(st) SKM_sk_free(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_num(st) SKM_sk_num(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_value(st, i) SKM_sk_value(X509V3_EXT_METHOD, (st), (i)) +#define sk_X509V3_EXT_METHOD_set(st, i, val) SKM_sk_set(X509V3_EXT_METHOD, (st), (i), (val)) +#define sk_X509V3_EXT_METHOD_zero(st) SKM_sk_zero(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_push(st, val) SKM_sk_push(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_unshift(st, val) SKM_sk_unshift(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_find(st, val) SKM_sk_find(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_find_ex(st, val) SKM_sk_find_ex(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_delete(st, i) SKM_sk_delete(X509V3_EXT_METHOD, (st), (i)) +#define sk_X509V3_EXT_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509V3_EXT_METHOD, (st), (ptr)) +#define sk_X509V3_EXT_METHOD_insert(st, val, i) SKM_sk_insert(X509V3_EXT_METHOD, (st), (val), (i)) +#define sk_X509V3_EXT_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509V3_EXT_METHOD, (st), (cmp)) +#define sk_X509V3_EXT_METHOD_dup(st) SKM_sk_dup(X509V3_EXT_METHOD, st) +#define sk_X509V3_EXT_METHOD_pop_free(st, free_func) SKM_sk_pop_free(X509V3_EXT_METHOD, (st), (free_func)) +#define sk_X509V3_EXT_METHOD_shift(st) SKM_sk_shift(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_pop(st) SKM_sk_pop(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_sort(st) SKM_sk_sort(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_is_sorted(st) SKM_sk_is_sorted(X509V3_EXT_METHOD, (st)) + +#define sk_X509_ALGOR_new(st) SKM_sk_new(X509_ALGOR, (st)) +#define sk_X509_ALGOR_new_null() SKM_sk_new_null(X509_ALGOR) +#define sk_X509_ALGOR_free(st) SKM_sk_free(X509_ALGOR, (st)) +#define sk_X509_ALGOR_num(st) SKM_sk_num(X509_ALGOR, (st)) +#define sk_X509_ALGOR_value(st, i) SKM_sk_value(X509_ALGOR, (st), (i)) +#define sk_X509_ALGOR_set(st, i, val) SKM_sk_set(X509_ALGOR, (st), (i), (val)) +#define sk_X509_ALGOR_zero(st) SKM_sk_zero(X509_ALGOR, (st)) +#define sk_X509_ALGOR_push(st, val) SKM_sk_push(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_unshift(st, val) SKM_sk_unshift(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_find(st, val) SKM_sk_find(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_find_ex(st, val) SKM_sk_find_ex(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_delete(st, i) SKM_sk_delete(X509_ALGOR, (st), (i)) +#define sk_X509_ALGOR_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ALGOR, (st), (ptr)) +#define sk_X509_ALGOR_insert(st, val, i) SKM_sk_insert(X509_ALGOR, (st), (val), (i)) +#define sk_X509_ALGOR_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ALGOR, (st), (cmp)) +#define sk_X509_ALGOR_dup(st) SKM_sk_dup(X509_ALGOR, st) +#define sk_X509_ALGOR_pop_free(st, free_func) SKM_sk_pop_free(X509_ALGOR, (st), (free_func)) +#define sk_X509_ALGOR_shift(st) SKM_sk_shift(X509_ALGOR, (st)) +#define sk_X509_ALGOR_pop(st) SKM_sk_pop(X509_ALGOR, (st)) +#define sk_X509_ALGOR_sort(st) SKM_sk_sort(X509_ALGOR, (st)) +#define sk_X509_ALGOR_is_sorted(st) SKM_sk_is_sorted(X509_ALGOR, (st)) + +#define sk_X509_ATTRIBUTE_new(st) SKM_sk_new(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_new_null() SKM_sk_new_null(X509_ATTRIBUTE) +#define sk_X509_ATTRIBUTE_free(st) SKM_sk_free(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_num(st) SKM_sk_num(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_value(st, i) SKM_sk_value(X509_ATTRIBUTE, (st), (i)) +#define sk_X509_ATTRIBUTE_set(st, i, val) SKM_sk_set(X509_ATTRIBUTE, (st), (i), (val)) +#define sk_X509_ATTRIBUTE_zero(st) SKM_sk_zero(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_push(st, val) SKM_sk_push(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_unshift(st, val) SKM_sk_unshift(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_find(st, val) SKM_sk_find(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_find_ex(st, val) SKM_sk_find_ex(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_delete(st, i) SKM_sk_delete(X509_ATTRIBUTE, (st), (i)) +#define sk_X509_ATTRIBUTE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ATTRIBUTE, (st), (ptr)) +#define sk_X509_ATTRIBUTE_insert(st, val, i) SKM_sk_insert(X509_ATTRIBUTE, (st), (val), (i)) +#define sk_X509_ATTRIBUTE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ATTRIBUTE, (st), (cmp)) +#define sk_X509_ATTRIBUTE_dup(st) SKM_sk_dup(X509_ATTRIBUTE, st) +#define sk_X509_ATTRIBUTE_pop_free(st, free_func) SKM_sk_pop_free(X509_ATTRIBUTE, (st), (free_func)) +#define sk_X509_ATTRIBUTE_shift(st) SKM_sk_shift(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_pop(st) SKM_sk_pop(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_sort(st) SKM_sk_sort(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_is_sorted(st) SKM_sk_is_sorted(X509_ATTRIBUTE, (st)) + +#define sk_X509_CRL_new(st) SKM_sk_new(X509_CRL, (st)) +#define sk_X509_CRL_new_null() SKM_sk_new_null(X509_CRL) +#define sk_X509_CRL_free(st) SKM_sk_free(X509_CRL, (st)) +#define sk_X509_CRL_num(st) SKM_sk_num(X509_CRL, (st)) +#define sk_X509_CRL_value(st, i) SKM_sk_value(X509_CRL, (st), (i)) +#define sk_X509_CRL_set(st, i, val) SKM_sk_set(X509_CRL, (st), (i), (val)) +#define sk_X509_CRL_zero(st) SKM_sk_zero(X509_CRL, (st)) +#define sk_X509_CRL_push(st, val) SKM_sk_push(X509_CRL, (st), (val)) +#define sk_X509_CRL_unshift(st, val) SKM_sk_unshift(X509_CRL, (st), (val)) +#define sk_X509_CRL_find(st, val) SKM_sk_find(X509_CRL, (st), (val)) +#define sk_X509_CRL_find_ex(st, val) SKM_sk_find_ex(X509_CRL, (st), (val)) +#define sk_X509_CRL_delete(st, i) SKM_sk_delete(X509_CRL, (st), (i)) +#define sk_X509_CRL_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_CRL, (st), (ptr)) +#define sk_X509_CRL_insert(st, val, i) SKM_sk_insert(X509_CRL, (st), (val), (i)) +#define sk_X509_CRL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_CRL, (st), (cmp)) +#define sk_X509_CRL_dup(st) SKM_sk_dup(X509_CRL, st) +#define sk_X509_CRL_pop_free(st, free_func) SKM_sk_pop_free(X509_CRL, (st), (free_func)) +#define sk_X509_CRL_shift(st) SKM_sk_shift(X509_CRL, (st)) +#define sk_X509_CRL_pop(st) SKM_sk_pop(X509_CRL, (st)) +#define sk_X509_CRL_sort(st) SKM_sk_sort(X509_CRL, (st)) +#define sk_X509_CRL_is_sorted(st) SKM_sk_is_sorted(X509_CRL, (st)) + +#define sk_X509_EXTENSION_new(st) SKM_sk_new(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_new_null() SKM_sk_new_null(X509_EXTENSION) +#define sk_X509_EXTENSION_free(st) SKM_sk_free(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_num(st) SKM_sk_num(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_value(st, i) SKM_sk_value(X509_EXTENSION, (st), (i)) +#define sk_X509_EXTENSION_set(st, i, val) SKM_sk_set(X509_EXTENSION, (st), (i), (val)) +#define sk_X509_EXTENSION_zero(st) SKM_sk_zero(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_push(st, val) SKM_sk_push(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_unshift(st, val) SKM_sk_unshift(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_find(st, val) SKM_sk_find(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_find_ex(st, val) SKM_sk_find_ex(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_delete(st, i) SKM_sk_delete(X509_EXTENSION, (st), (i)) +#define sk_X509_EXTENSION_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_EXTENSION, (st), (ptr)) +#define sk_X509_EXTENSION_insert(st, val, i) SKM_sk_insert(X509_EXTENSION, (st), (val), (i)) +#define sk_X509_EXTENSION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_EXTENSION, (st), (cmp)) +#define sk_X509_EXTENSION_dup(st) SKM_sk_dup(X509_EXTENSION, st) +#define sk_X509_EXTENSION_pop_free(st, free_func) SKM_sk_pop_free(X509_EXTENSION, (st), (free_func)) +#define sk_X509_EXTENSION_shift(st) SKM_sk_shift(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_pop(st) SKM_sk_pop(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_sort(st) SKM_sk_sort(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_is_sorted(st) SKM_sk_is_sorted(X509_EXTENSION, (st)) + +#define sk_X509_INFO_new(st) SKM_sk_new(X509_INFO, (st)) +#define sk_X509_INFO_new_null() SKM_sk_new_null(X509_INFO) +#define sk_X509_INFO_free(st) SKM_sk_free(X509_INFO, (st)) +#define sk_X509_INFO_num(st) SKM_sk_num(X509_INFO, (st)) +#define sk_X509_INFO_value(st, i) SKM_sk_value(X509_INFO, (st), (i)) +#define sk_X509_INFO_set(st, i, val) SKM_sk_set(X509_INFO, (st), (i), (val)) +#define sk_X509_INFO_zero(st) SKM_sk_zero(X509_INFO, (st)) +#define sk_X509_INFO_push(st, val) SKM_sk_push(X509_INFO, (st), (val)) +#define sk_X509_INFO_unshift(st, val) SKM_sk_unshift(X509_INFO, (st), (val)) +#define sk_X509_INFO_find(st, val) SKM_sk_find(X509_INFO, (st), (val)) +#define sk_X509_INFO_find_ex(st, val) SKM_sk_find_ex(X509_INFO, (st), (val)) +#define sk_X509_INFO_delete(st, i) SKM_sk_delete(X509_INFO, (st), (i)) +#define sk_X509_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_INFO, (st), (ptr)) +#define sk_X509_INFO_insert(st, val, i) SKM_sk_insert(X509_INFO, (st), (val), (i)) +#define sk_X509_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_INFO, (st), (cmp)) +#define sk_X509_INFO_dup(st) SKM_sk_dup(X509_INFO, st) +#define sk_X509_INFO_pop_free(st, free_func) SKM_sk_pop_free(X509_INFO, (st), (free_func)) +#define sk_X509_INFO_shift(st) SKM_sk_shift(X509_INFO, (st)) +#define sk_X509_INFO_pop(st) SKM_sk_pop(X509_INFO, (st)) +#define sk_X509_INFO_sort(st) SKM_sk_sort(X509_INFO, (st)) +#define sk_X509_INFO_is_sorted(st) SKM_sk_is_sorted(X509_INFO, (st)) + +#define sk_X509_LOOKUP_new(st) SKM_sk_new(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_new_null() SKM_sk_new_null(X509_LOOKUP) +#define sk_X509_LOOKUP_free(st) SKM_sk_free(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_num(st) SKM_sk_num(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_value(st, i) SKM_sk_value(X509_LOOKUP, (st), (i)) +#define sk_X509_LOOKUP_set(st, i, val) SKM_sk_set(X509_LOOKUP, (st), (i), (val)) +#define sk_X509_LOOKUP_zero(st) SKM_sk_zero(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_push(st, val) SKM_sk_push(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_unshift(st, val) SKM_sk_unshift(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_find(st, val) SKM_sk_find(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_find_ex(st, val) SKM_sk_find_ex(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_delete(st, i) SKM_sk_delete(X509_LOOKUP, (st), (i)) +#define sk_X509_LOOKUP_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_LOOKUP, (st), (ptr)) +#define sk_X509_LOOKUP_insert(st, val, i) SKM_sk_insert(X509_LOOKUP, (st), (val), (i)) +#define sk_X509_LOOKUP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_LOOKUP, (st), (cmp)) +#define sk_X509_LOOKUP_dup(st) SKM_sk_dup(X509_LOOKUP, st) +#define sk_X509_LOOKUP_pop_free(st, free_func) SKM_sk_pop_free(X509_LOOKUP, (st), (free_func)) +#define sk_X509_LOOKUP_shift(st) SKM_sk_shift(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_pop(st) SKM_sk_pop(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_sort(st) SKM_sk_sort(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_is_sorted(st) SKM_sk_is_sorted(X509_LOOKUP, (st)) + +#define sk_X509_NAME_new(st) SKM_sk_new(X509_NAME, (st)) +#define sk_X509_NAME_new_null() SKM_sk_new_null(X509_NAME) +#define sk_X509_NAME_free(st) SKM_sk_free(X509_NAME, (st)) +#define sk_X509_NAME_num(st) SKM_sk_num(X509_NAME, (st)) +#define sk_X509_NAME_value(st, i) SKM_sk_value(X509_NAME, (st), (i)) +#define sk_X509_NAME_set(st, i, val) SKM_sk_set(X509_NAME, (st), (i), (val)) +#define sk_X509_NAME_zero(st) SKM_sk_zero(X509_NAME, (st)) +#define sk_X509_NAME_push(st, val) SKM_sk_push(X509_NAME, (st), (val)) +#define sk_X509_NAME_unshift(st, val) SKM_sk_unshift(X509_NAME, (st), (val)) +#define sk_X509_NAME_find(st, val) SKM_sk_find(X509_NAME, (st), (val)) +#define sk_X509_NAME_find_ex(st, val) SKM_sk_find_ex(X509_NAME, (st), (val)) +#define sk_X509_NAME_delete(st, i) SKM_sk_delete(X509_NAME, (st), (i)) +#define sk_X509_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME, (st), (ptr)) +#define sk_X509_NAME_insert(st, val, i) SKM_sk_insert(X509_NAME, (st), (val), (i)) +#define sk_X509_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME, (st), (cmp)) +#define sk_X509_NAME_dup(st) SKM_sk_dup(X509_NAME, st) +#define sk_X509_NAME_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME, (st), (free_func)) +#define sk_X509_NAME_shift(st) SKM_sk_shift(X509_NAME, (st)) +#define sk_X509_NAME_pop(st) SKM_sk_pop(X509_NAME, (st)) +#define sk_X509_NAME_sort(st) SKM_sk_sort(X509_NAME, (st)) +#define sk_X509_NAME_is_sorted(st) SKM_sk_is_sorted(X509_NAME, (st)) + +#define sk_X509_NAME_ENTRY_new(st) SKM_sk_new(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_new_null() SKM_sk_new_null(X509_NAME_ENTRY) +#define sk_X509_NAME_ENTRY_free(st) SKM_sk_free(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_num(st) SKM_sk_num(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_value(st, i) SKM_sk_value(X509_NAME_ENTRY, (st), (i)) +#define sk_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(X509_NAME_ENTRY, (st), (i), (val)) +#define sk_X509_NAME_ENTRY_zero(st) SKM_sk_zero(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_push(st, val) SKM_sk_push(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_find(st, val) SKM_sk_find(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(X509_NAME_ENTRY, (st), (i)) +#define sk_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME_ENTRY, (st), (ptr)) +#define sk_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(X509_NAME_ENTRY, (st), (val), (i)) +#define sk_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME_ENTRY, (st), (cmp)) +#define sk_X509_NAME_ENTRY_dup(st) SKM_sk_dup(X509_NAME_ENTRY, st) +#define sk_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME_ENTRY, (st), (free_func)) +#define sk_X509_NAME_ENTRY_shift(st) SKM_sk_shift(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_pop(st) SKM_sk_pop(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_sort(st) SKM_sk_sort(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(X509_NAME_ENTRY, (st)) + +#define sk_X509_OBJECT_new(st) SKM_sk_new(X509_OBJECT, (st)) +#define sk_X509_OBJECT_new_null() SKM_sk_new_null(X509_OBJECT) +#define sk_X509_OBJECT_free(st) SKM_sk_free(X509_OBJECT, (st)) +#define sk_X509_OBJECT_num(st) SKM_sk_num(X509_OBJECT, (st)) +#define sk_X509_OBJECT_value(st, i) SKM_sk_value(X509_OBJECT, (st), (i)) +#define sk_X509_OBJECT_set(st, i, val) SKM_sk_set(X509_OBJECT, (st), (i), (val)) +#define sk_X509_OBJECT_zero(st) SKM_sk_zero(X509_OBJECT, (st)) +#define sk_X509_OBJECT_push(st, val) SKM_sk_push(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_unshift(st, val) SKM_sk_unshift(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_find(st, val) SKM_sk_find(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_find_ex(st, val) SKM_sk_find_ex(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_delete(st, i) SKM_sk_delete(X509_OBJECT, (st), (i)) +#define sk_X509_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_OBJECT, (st), (ptr)) +#define sk_X509_OBJECT_insert(st, val, i) SKM_sk_insert(X509_OBJECT, (st), (val), (i)) +#define sk_X509_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_OBJECT, (st), (cmp)) +#define sk_X509_OBJECT_dup(st) SKM_sk_dup(X509_OBJECT, st) +#define sk_X509_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(X509_OBJECT, (st), (free_func)) +#define sk_X509_OBJECT_shift(st) SKM_sk_shift(X509_OBJECT, (st)) +#define sk_X509_OBJECT_pop(st) SKM_sk_pop(X509_OBJECT, (st)) +#define sk_X509_OBJECT_sort(st) SKM_sk_sort(X509_OBJECT, (st)) +#define sk_X509_OBJECT_is_sorted(st) SKM_sk_is_sorted(X509_OBJECT, (st)) + +#define sk_X509_POLICY_DATA_new(st) SKM_sk_new(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_new_null() SKM_sk_new_null(X509_POLICY_DATA) +#define sk_X509_POLICY_DATA_free(st) SKM_sk_free(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_num(st) SKM_sk_num(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_value(st, i) SKM_sk_value(X509_POLICY_DATA, (st), (i)) +#define sk_X509_POLICY_DATA_set(st, i, val) SKM_sk_set(X509_POLICY_DATA, (st), (i), (val)) +#define sk_X509_POLICY_DATA_zero(st) SKM_sk_zero(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_push(st, val) SKM_sk_push(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_unshift(st, val) SKM_sk_unshift(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_find(st, val) SKM_sk_find(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_delete(st, i) SKM_sk_delete(X509_POLICY_DATA, (st), (i)) +#define sk_X509_POLICY_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_DATA, (st), (ptr)) +#define sk_X509_POLICY_DATA_insert(st, val, i) SKM_sk_insert(X509_POLICY_DATA, (st), (val), (i)) +#define sk_X509_POLICY_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_DATA, (st), (cmp)) +#define sk_X509_POLICY_DATA_dup(st) SKM_sk_dup(X509_POLICY_DATA, st) +#define sk_X509_POLICY_DATA_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_DATA, (st), (free_func)) +#define sk_X509_POLICY_DATA_shift(st) SKM_sk_shift(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_pop(st) SKM_sk_pop(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_sort(st) SKM_sk_sort(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_DATA, (st)) + +#define sk_X509_POLICY_NODE_new(st) SKM_sk_new(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_new_null() SKM_sk_new_null(X509_POLICY_NODE) +#define sk_X509_POLICY_NODE_free(st) SKM_sk_free(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_num(st) SKM_sk_num(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_value(st, i) SKM_sk_value(X509_POLICY_NODE, (st), (i)) +#define sk_X509_POLICY_NODE_set(st, i, val) SKM_sk_set(X509_POLICY_NODE, (st), (i), (val)) +#define sk_X509_POLICY_NODE_zero(st) SKM_sk_zero(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_push(st, val) SKM_sk_push(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_unshift(st, val) SKM_sk_unshift(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_find(st, val) SKM_sk_find(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_delete(st, i) SKM_sk_delete(X509_POLICY_NODE, (st), (i)) +#define sk_X509_POLICY_NODE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_NODE, (st), (ptr)) +#define sk_X509_POLICY_NODE_insert(st, val, i) SKM_sk_insert(X509_POLICY_NODE, (st), (val), (i)) +#define sk_X509_POLICY_NODE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_NODE, (st), (cmp)) +#define sk_X509_POLICY_NODE_dup(st) SKM_sk_dup(X509_POLICY_NODE, st) +#define sk_X509_POLICY_NODE_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_NODE, (st), (free_func)) +#define sk_X509_POLICY_NODE_shift(st) SKM_sk_shift(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_pop(st) SKM_sk_pop(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_sort(st) SKM_sk_sort(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_NODE, (st)) + +#define sk_X509_POLICY_REF_new(st) SKM_sk_new(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_new_null() SKM_sk_new_null(X509_POLICY_REF) +#define sk_X509_POLICY_REF_free(st) SKM_sk_free(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_num(st) SKM_sk_num(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_value(st, i) SKM_sk_value(X509_POLICY_REF, (st), (i)) +#define sk_X509_POLICY_REF_set(st, i, val) SKM_sk_set(X509_POLICY_REF, (st), (i), (val)) +#define sk_X509_POLICY_REF_zero(st) SKM_sk_zero(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_push(st, val) SKM_sk_push(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_unshift(st, val) SKM_sk_unshift(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_find(st, val) SKM_sk_find(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_delete(st, i) SKM_sk_delete(X509_POLICY_REF, (st), (i)) +#define sk_X509_POLICY_REF_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_REF, (st), (ptr)) +#define sk_X509_POLICY_REF_insert(st, val, i) SKM_sk_insert(X509_POLICY_REF, (st), (val), (i)) +#define sk_X509_POLICY_REF_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_REF, (st), (cmp)) +#define sk_X509_POLICY_REF_dup(st) SKM_sk_dup(X509_POLICY_REF, st) +#define sk_X509_POLICY_REF_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_REF, (st), (free_func)) +#define sk_X509_POLICY_REF_shift(st) SKM_sk_shift(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_pop(st) SKM_sk_pop(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_sort(st) SKM_sk_sort(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_REF, (st)) + +#define sk_X509_PURPOSE_new(st) SKM_sk_new(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_new_null() SKM_sk_new_null(X509_PURPOSE) +#define sk_X509_PURPOSE_free(st) SKM_sk_free(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_num(st) SKM_sk_num(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_value(st, i) SKM_sk_value(X509_PURPOSE, (st), (i)) +#define sk_X509_PURPOSE_set(st, i, val) SKM_sk_set(X509_PURPOSE, (st), (i), (val)) +#define sk_X509_PURPOSE_zero(st) SKM_sk_zero(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_push(st, val) SKM_sk_push(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_unshift(st, val) SKM_sk_unshift(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_find(st, val) SKM_sk_find(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_find_ex(st, val) SKM_sk_find_ex(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_delete(st, i) SKM_sk_delete(X509_PURPOSE, (st), (i)) +#define sk_X509_PURPOSE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_PURPOSE, (st), (ptr)) +#define sk_X509_PURPOSE_insert(st, val, i) SKM_sk_insert(X509_PURPOSE, (st), (val), (i)) +#define sk_X509_PURPOSE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_PURPOSE, (st), (cmp)) +#define sk_X509_PURPOSE_dup(st) SKM_sk_dup(X509_PURPOSE, st) +#define sk_X509_PURPOSE_pop_free(st, free_func) SKM_sk_pop_free(X509_PURPOSE, (st), (free_func)) +#define sk_X509_PURPOSE_shift(st) SKM_sk_shift(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_pop(st) SKM_sk_pop(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_sort(st) SKM_sk_sort(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_is_sorted(st) SKM_sk_is_sorted(X509_PURPOSE, (st)) + +#define sk_X509_REVOKED_new(st) SKM_sk_new(X509_REVOKED, (st)) +#define sk_X509_REVOKED_new_null() SKM_sk_new_null(X509_REVOKED) +#define sk_X509_REVOKED_free(st) SKM_sk_free(X509_REVOKED, (st)) +#define sk_X509_REVOKED_num(st) SKM_sk_num(X509_REVOKED, (st)) +#define sk_X509_REVOKED_value(st, i) SKM_sk_value(X509_REVOKED, (st), (i)) +#define sk_X509_REVOKED_set(st, i, val) SKM_sk_set(X509_REVOKED, (st), (i), (val)) +#define sk_X509_REVOKED_zero(st) SKM_sk_zero(X509_REVOKED, (st)) +#define sk_X509_REVOKED_push(st, val) SKM_sk_push(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_unshift(st, val) SKM_sk_unshift(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_find(st, val) SKM_sk_find(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_find_ex(st, val) SKM_sk_find_ex(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_delete(st, i) SKM_sk_delete(X509_REVOKED, (st), (i)) +#define sk_X509_REVOKED_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_REVOKED, (st), (ptr)) +#define sk_X509_REVOKED_insert(st, val, i) SKM_sk_insert(X509_REVOKED, (st), (val), (i)) +#define sk_X509_REVOKED_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_REVOKED, (st), (cmp)) +#define sk_X509_REVOKED_dup(st) SKM_sk_dup(X509_REVOKED, st) +#define sk_X509_REVOKED_pop_free(st, free_func) SKM_sk_pop_free(X509_REVOKED, (st), (free_func)) +#define sk_X509_REVOKED_shift(st) SKM_sk_shift(X509_REVOKED, (st)) +#define sk_X509_REVOKED_pop(st) SKM_sk_pop(X509_REVOKED, (st)) +#define sk_X509_REVOKED_sort(st) SKM_sk_sort(X509_REVOKED, (st)) +#define sk_X509_REVOKED_is_sorted(st) SKM_sk_is_sorted(X509_REVOKED, (st)) + +#define sk_X509_TRUST_new(st) SKM_sk_new(X509_TRUST, (st)) +#define sk_X509_TRUST_new_null() SKM_sk_new_null(X509_TRUST) +#define sk_X509_TRUST_free(st) SKM_sk_free(X509_TRUST, (st)) +#define sk_X509_TRUST_num(st) SKM_sk_num(X509_TRUST, (st)) +#define sk_X509_TRUST_value(st, i) SKM_sk_value(X509_TRUST, (st), (i)) +#define sk_X509_TRUST_set(st, i, val) SKM_sk_set(X509_TRUST, (st), (i), (val)) +#define sk_X509_TRUST_zero(st) SKM_sk_zero(X509_TRUST, (st)) +#define sk_X509_TRUST_push(st, val) SKM_sk_push(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_unshift(st, val) SKM_sk_unshift(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_find(st, val) SKM_sk_find(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_find_ex(st, val) SKM_sk_find_ex(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_delete(st, i) SKM_sk_delete(X509_TRUST, (st), (i)) +#define sk_X509_TRUST_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_TRUST, (st), (ptr)) +#define sk_X509_TRUST_insert(st, val, i) SKM_sk_insert(X509_TRUST, (st), (val), (i)) +#define sk_X509_TRUST_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_TRUST, (st), (cmp)) +#define sk_X509_TRUST_dup(st) SKM_sk_dup(X509_TRUST, st) +#define sk_X509_TRUST_pop_free(st, free_func) SKM_sk_pop_free(X509_TRUST, (st), (free_func)) +#define sk_X509_TRUST_shift(st) SKM_sk_shift(X509_TRUST, (st)) +#define sk_X509_TRUST_pop(st) SKM_sk_pop(X509_TRUST, (st)) +#define sk_X509_TRUST_sort(st) SKM_sk_sort(X509_TRUST, (st)) +#define sk_X509_TRUST_is_sorted(st) SKM_sk_is_sorted(X509_TRUST, (st)) + +#define sk_X509_VERIFY_PARAM_new(st) SKM_sk_new(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_new_null() SKM_sk_new_null(X509_VERIFY_PARAM) +#define sk_X509_VERIFY_PARAM_free(st) SKM_sk_free(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_num(st) SKM_sk_num(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_value(st, i) SKM_sk_value(X509_VERIFY_PARAM, (st), (i)) +#define sk_X509_VERIFY_PARAM_set(st, i, val) SKM_sk_set(X509_VERIFY_PARAM, (st), (i), (val)) +#define sk_X509_VERIFY_PARAM_zero(st) SKM_sk_zero(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_push(st, val) SKM_sk_push(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_unshift(st, val) SKM_sk_unshift(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_find(st, val) SKM_sk_find(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_find_ex(st, val) SKM_sk_find_ex(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_delete(st, i) SKM_sk_delete(X509_VERIFY_PARAM, (st), (i)) +#define sk_X509_VERIFY_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_VERIFY_PARAM, (st), (ptr)) +#define sk_X509_VERIFY_PARAM_insert(st, val, i) SKM_sk_insert(X509_VERIFY_PARAM, (st), (val), (i)) +#define sk_X509_VERIFY_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_VERIFY_PARAM, (st), (cmp)) +#define sk_X509_VERIFY_PARAM_dup(st) SKM_sk_dup(X509_VERIFY_PARAM, st) +#define sk_X509_VERIFY_PARAM_pop_free(st, free_func) SKM_sk_pop_free(X509_VERIFY_PARAM, (st), (free_func)) +#define sk_X509_VERIFY_PARAM_shift(st) SKM_sk_shift(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_pop(st) SKM_sk_pop(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_sort(st) SKM_sk_sort(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_is_sorted(st) SKM_sk_is_sorted(X509_VERIFY_PARAM, (st)) + +#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ACCESS_DESCRIPTION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ACCESS_DESCRIPTION(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ACCESS_DESCRIPTION, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ACCESS_DESCRIPTION(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ACCESS_DESCRIPTION, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_ASN1_INTEGER(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ASN1_INTEGER, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ASN1_INTEGER(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ASN1_INTEGER, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ASN1_INTEGER(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ASN1_INTEGER, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ASN1_INTEGER(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ASN1_INTEGER, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_ASN1_OBJECT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ASN1_OBJECT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ASN1_OBJECT(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ASN1_OBJECT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ASN1_OBJECT(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ASN1_OBJECT, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ASN1_OBJECT(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ASN1_OBJECT, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_ASN1_TYPE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ASN1_TYPE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ASN1_TYPE(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ASN1_TYPE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ASN1_TYPE(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ASN1_TYPE, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ASN1_TYPE(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ASN1_TYPE, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_DIST_POINT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(DIST_POINT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_DIST_POINT(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(DIST_POINT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_DIST_POINT(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(DIST_POINT, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_DIST_POINT(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(DIST_POINT, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_GENERAL_NAME(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(GENERAL_NAME, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_GENERAL_NAME(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(GENERAL_NAME, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_GENERAL_NAME(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(GENERAL_NAME, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_GENERAL_NAME(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(GENERAL_NAME, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_OCSP_ONEREQ(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(OCSP_ONEREQ, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_OCSP_ONEREQ(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(OCSP_ONEREQ, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_OCSP_ONEREQ(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(OCSP_ONEREQ, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_OCSP_ONEREQ(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(OCSP_ONEREQ, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(OCSP_SINGLERESP, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(OCSP_SINGLERESP, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_OCSP_SINGLERESP(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(OCSP_SINGLERESP, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_OCSP_SINGLERESP(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(OCSP_SINGLERESP, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS12_SAFEBAG, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS12_SAFEBAG, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS12_SAFEBAG(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS12_SAFEBAG, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS12_SAFEBAG(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS12_SAFEBAG, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS7(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS7, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS7(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS7, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS7(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS7, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS7(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS7, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS7_RECIP_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS7_RECIP_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS7_RECIP_INFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS7_RECIP_INFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS7_RECIP_INFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS7_RECIP_INFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS7_SIGNER_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS7_SIGNER_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS7_SIGNER_INFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS7_SIGNER_INFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS7_SIGNER_INFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS7_SIGNER_INFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_POLICYINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(POLICYINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_POLICYINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(POLICYINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_POLICYINFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(POLICYINFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_POLICYINFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(POLICYINFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_POLICYQUALINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(POLICYQUALINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_POLICYQUALINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(POLICYQUALINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_POLICYQUALINFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(POLICYQUALINFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_POLICYQUALINFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(POLICYQUALINFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_SXNETID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(SXNETID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_SXNETID(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(SXNETID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_SXNETID(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(SXNETID, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_SXNETID(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(SXNETID, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_ALGOR(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_ALGOR, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_ALGOR(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_ALGOR, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_ALGOR(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_ALGOR, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_ALGOR(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_ALGOR, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_ATTRIBUTE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_ATTRIBUTE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_ATTRIBUTE(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_ATTRIBUTE, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_ATTRIBUTE(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_ATTRIBUTE, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_CRL(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_CRL, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_CRL(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_CRL, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_CRL(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_CRL, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_CRL(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_CRL, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_EXTENSION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_EXTENSION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_EXTENSION(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_EXTENSION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_EXTENSION(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_EXTENSION, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_EXTENSION(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_EXTENSION, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_NAME_ENTRY, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_NAME_ENTRY, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_NAME_ENTRY(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_NAME_ENTRY, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_NAME_ENTRY(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_NAME_ENTRY, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_REVOKED(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_REVOKED, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_REVOKED(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_REVOKED, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_REVOKED(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_REVOKED, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_REVOKED(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_REVOKED, (buf), (len), (d2i_func), (free_func)) + +#define PKCS12_decrypt_d2i_PKCS12_SAFEBAG(algor, d2i_func, free_func, pass, passlen, oct, seq) \ + SKM_PKCS12_decrypt_d2i(PKCS12_SAFEBAG, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) + +#define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \ + SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) +/* End of util/mkstack.pl block, you may now edit :-) */ + +#endif /* !defined HEADER_SAFESTACK_H */ diff --git a/src/dep/include/openssl/sha.h b/src/dep/include/openssl/sha.h index e94099c..5f37416 100644 --- a/src/dep/include/openssl/sha.h +++ b/src/dep/include/openssl/sha.h @@ -1,199 +1,199 @@ -/* crypto/sha/sha.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_SHA_H -#define HEADER_SHA_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1)) -#error SHA is disabled. -#endif - -#if defined(OPENSSL_FIPS) -#define FIPS_SHA_SIZE_T size_t -#endif - -/* - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then ! - * ! SHA_LONG_LOG2 has to be defined along. ! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - */ - -#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) -#define SHA_LONG unsigned long -#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) -#define SHA_LONG unsigned long -#define SHA_LONG_LOG2 3 -#else -#define SHA_LONG unsigned int -#endif - -#define SHA_LBLOCK 16 -#define SHA_CBLOCK (SHA_LBLOCK*4) /* SHA treats input data as a - * contiguous array of 32 bit - * wide big-endian values. */ -#define SHA_LAST_BLOCK (SHA_CBLOCK-8) -#define SHA_DIGEST_LENGTH 20 - -typedef struct SHAstate_st - { - SHA_LONG h0,h1,h2,h3,h4; - SHA_LONG Nl,Nh; - SHA_LONG data[SHA_LBLOCK]; - unsigned int num; - } SHA_CTX; - -#ifndef OPENSSL_NO_SHA0 -int SHA_Init(SHA_CTX *c); -int SHA_Update(SHA_CTX *c, const void *data, size_t len); -int SHA_Final(unsigned char *md, SHA_CTX *c); -unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md); -void SHA_Transform(SHA_CTX *c, const unsigned char *data); -#endif -#ifndef OPENSSL_NO_SHA1 -int SHA1_Init(SHA_CTX *c); -int SHA1_Update(SHA_CTX *c, const void *data, size_t len); -int SHA1_Final(unsigned char *md, SHA_CTX *c); -unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md); -void SHA1_Transform(SHA_CTX *c, const unsigned char *data); -#endif - -#define SHA256_CBLOCK (SHA_LBLOCK*4) /* SHA-256 treats input data as a - * contiguous array of 32 bit - * wide big-endian values. */ -#define SHA224_DIGEST_LENGTH 28 -#define SHA256_DIGEST_LENGTH 32 - -typedef struct SHA256state_st - { - SHA_LONG h[8]; - SHA_LONG Nl,Nh; - SHA_LONG data[SHA_LBLOCK]; - unsigned int num,md_len; - } SHA256_CTX; - -#ifndef OPENSSL_NO_SHA256 -int SHA224_Init(SHA256_CTX *c); -int SHA224_Update(SHA256_CTX *c, const void *data, size_t len); -int SHA224_Final(unsigned char *md, SHA256_CTX *c); -unsigned char *SHA224(const unsigned char *d, size_t n,unsigned char *md); -int SHA256_Init(SHA256_CTX *c); -int SHA256_Update(SHA256_CTX *c, const void *data, size_t len); -int SHA256_Final(unsigned char *md, SHA256_CTX *c); -unsigned char *SHA256(const unsigned char *d, size_t n,unsigned char *md); -void SHA256_Transform(SHA256_CTX *c, const unsigned char *data); -#endif - -#define SHA384_DIGEST_LENGTH 48 -#define SHA512_DIGEST_LENGTH 64 - -#ifndef OPENSSL_NO_SHA512 -/* - * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64 - * being exactly 64-bit wide. See Implementation Notes in sha512.c - * for further details. - */ -#define SHA512_CBLOCK (SHA_LBLOCK*8) /* SHA-512 treats input data as a - * contiguous array of 64 bit - * wide big-endian values. */ -#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) -#define SHA_LONG64 unsigned __int64 -#define U64(C) C##UI64 -#elif defined(__arch64__) -#define SHA_LONG64 unsigned long -#define U64(C) C##UL -#else -#define SHA_LONG64 unsigned long long -#define U64(C) C##ULL -#endif - -typedef struct SHA512state_st - { - SHA_LONG64 h[8]; - SHA_LONG64 Nl,Nh; - union { - SHA_LONG64 d[SHA_LBLOCK]; - unsigned char p[SHA512_CBLOCK]; - } u; - unsigned int num,md_len; - } SHA512_CTX; -#endif - -#ifndef OPENSSL_NO_SHA512 -int SHA384_Init(SHA512_CTX *c); -int SHA384_Update(SHA512_CTX *c, const void *data, size_t len); -int SHA384_Final(unsigned char *md, SHA512_CTX *c); -unsigned char *SHA384(const unsigned char *d, size_t n,unsigned char *md); -int SHA512_Init(SHA512_CTX *c); -int SHA512_Update(SHA512_CTX *c, const void *data, size_t len); -int SHA512_Final(unsigned char *md, SHA512_CTX *c); -unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md); -void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); -#endif - -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/sha/sha.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_SHA_H +#define HEADER_SHA_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1)) +#error SHA is disabled. +#endif + +#if defined(OPENSSL_FIPS) +#define FIPS_SHA_SIZE_T size_t +#endif + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! SHA_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define SHA_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define SHA_LONG unsigned long +#define SHA_LONG_LOG2 3 +#else +#define SHA_LONG unsigned int +#endif + +#define SHA_LBLOCK 16 +#define SHA_CBLOCK (SHA_LBLOCK*4) /* SHA treats input data as a + * contiguous array of 32 bit + * wide big-endian values. */ +#define SHA_LAST_BLOCK (SHA_CBLOCK-8) +#define SHA_DIGEST_LENGTH 20 + +typedef struct SHAstate_st + { + SHA_LONG h0,h1,h2,h3,h4; + SHA_LONG Nl,Nh; + SHA_LONG data[SHA_LBLOCK]; + unsigned int num; + } SHA_CTX; + +#ifndef OPENSSL_NO_SHA0 +int SHA_Init(SHA_CTX *c); +int SHA_Update(SHA_CTX *c, const void *data, size_t len); +int SHA_Final(unsigned char *md, SHA_CTX *c); +unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md); +void SHA_Transform(SHA_CTX *c, const unsigned char *data); +#endif +#ifndef OPENSSL_NO_SHA1 +int SHA1_Init(SHA_CTX *c); +int SHA1_Update(SHA_CTX *c, const void *data, size_t len); +int SHA1_Final(unsigned char *md, SHA_CTX *c); +unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md); +void SHA1_Transform(SHA_CTX *c, const unsigned char *data); +#endif + +#define SHA256_CBLOCK (SHA_LBLOCK*4) /* SHA-256 treats input data as a + * contiguous array of 32 bit + * wide big-endian values. */ +#define SHA224_DIGEST_LENGTH 28 +#define SHA256_DIGEST_LENGTH 32 + +typedef struct SHA256state_st + { + SHA_LONG h[8]; + SHA_LONG Nl,Nh; + SHA_LONG data[SHA_LBLOCK]; + unsigned int num,md_len; + } SHA256_CTX; + +#ifndef OPENSSL_NO_SHA256 +int SHA224_Init(SHA256_CTX *c); +int SHA224_Update(SHA256_CTX *c, const void *data, size_t len); +int SHA224_Final(unsigned char *md, SHA256_CTX *c); +unsigned char *SHA224(const unsigned char *d, size_t n,unsigned char *md); +int SHA256_Init(SHA256_CTX *c); +int SHA256_Update(SHA256_CTX *c, const void *data, size_t len); +int SHA256_Final(unsigned char *md, SHA256_CTX *c); +unsigned char *SHA256(const unsigned char *d, size_t n,unsigned char *md); +void SHA256_Transform(SHA256_CTX *c, const unsigned char *data); +#endif + +#define SHA384_DIGEST_LENGTH 48 +#define SHA512_DIGEST_LENGTH 64 + +#ifndef OPENSSL_NO_SHA512 +/* + * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64 + * being exactly 64-bit wide. See Implementation Notes in sha512.c + * for further details. + */ +#define SHA512_CBLOCK (SHA_LBLOCK*8) /* SHA-512 treats input data as a + * contiguous array of 64 bit + * wide big-endian values. */ +#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) +#define SHA_LONG64 unsigned __int64 +#define U64(C) C##UI64 +#elif defined(__arch64__) +#define SHA_LONG64 unsigned long +#define U64(C) C##UL +#else +#define SHA_LONG64 unsigned long long +#define U64(C) C##ULL +#endif + +typedef struct SHA512state_st + { + SHA_LONG64 h[8]; + SHA_LONG64 Nl,Nh; + union { + SHA_LONG64 d[SHA_LBLOCK]; + unsigned char p[SHA512_CBLOCK]; + } u; + unsigned int num,md_len; + } SHA512_CTX; +#endif + +#ifndef OPENSSL_NO_SHA512 +int SHA384_Init(SHA512_CTX *c); +int SHA384_Update(SHA512_CTX *c, const void *data, size_t len); +int SHA384_Final(unsigned char *md, SHA512_CTX *c); +unsigned char *SHA384(const unsigned char *d, size_t n,unsigned char *md); +int SHA512_Init(SHA512_CTX *c); +int SHA512_Update(SHA512_CTX *c, const void *data, size_t len); +int SHA512_Final(unsigned char *md, SHA512_CTX *c); +unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md); +void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/ssl.h b/src/dep/include/openssl/ssl.h index a1e7a4d..a124efc 100644 --- a/src/dep/include/openssl/ssl.h +++ b/src/dep/include/openssl/ssl.h @@ -1,1955 +1,1955 @@ -/* ssl/ssl.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -/* ==================================================================== - * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * ECC cipher suite support in OpenSSL originally developed by - * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. - */ - -#ifndef HEADER_SSL_H -#define HEADER_SSL_H - -#include - -#ifndef OPENSSL_NO_COMP -#include -#endif -#ifndef OPENSSL_NO_BIO -#include -#endif -#ifndef OPENSSL_NO_DEPRECATED -#ifndef OPENSSL_NO_X509 -#include -#endif -#include -#include -#include -#endif -#include - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* SSLeay version number for ASN.1 encoding of the session information */ -/* Version 0 - initial version - * Version 1 - added the optional peer certificate - */ -#define SSL_SESSION_ASN1_VERSION 0x0001 - -/* text strings for the ciphers */ -#define SSL_TXT_NULL_WITH_MD5 SSL2_TXT_NULL_WITH_MD5 -#define SSL_TXT_RC4_128_WITH_MD5 SSL2_TXT_RC4_128_WITH_MD5 -#define SSL_TXT_RC4_128_EXPORT40_WITH_MD5 SSL2_TXT_RC4_128_EXPORT40_WITH_MD5 -#define SSL_TXT_RC2_128_CBC_WITH_MD5 SSL2_TXT_RC2_128_CBC_WITH_MD5 -#define SSL_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 -#define SSL_TXT_IDEA_128_CBC_WITH_MD5 SSL2_TXT_IDEA_128_CBC_WITH_MD5 -#define SSL_TXT_DES_64_CBC_WITH_MD5 SSL2_TXT_DES_64_CBC_WITH_MD5 -#define SSL_TXT_DES_64_CBC_WITH_SHA SSL2_TXT_DES_64_CBC_WITH_SHA -#define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 -#define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA - -/* VRS Additional Kerberos5 entries - */ -#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA -#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA -#define SSL_TXT_KRB5_RC4_128_SHA SSL3_TXT_KRB5_RC4_128_SHA -#define SSL_TXT_KRB5_IDEA_128_CBC_SHA SSL3_TXT_KRB5_IDEA_128_CBC_SHA -#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5 -#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5 -#define SSL_TXT_KRB5_RC4_128_MD5 SSL3_TXT_KRB5_RC4_128_MD5 -#define SSL_TXT_KRB5_IDEA_128_CBC_MD5 SSL3_TXT_KRB5_IDEA_128_CBC_MD5 - -#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA -#define SSL_TXT_KRB5_RC2_40_CBC_SHA SSL3_TXT_KRB5_RC2_40_CBC_SHA -#define SSL_TXT_KRB5_RC4_40_SHA SSL3_TXT_KRB5_RC4_40_SHA -#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5 -#define SSL_TXT_KRB5_RC2_40_CBC_MD5 SSL3_TXT_KRB5_RC2_40_CBC_MD5 -#define SSL_TXT_KRB5_RC4_40_MD5 SSL3_TXT_KRB5_RC4_40_MD5 - -#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA -#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5 -#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA -#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5 -#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA -#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5 -#define SSL_MAX_KRB5_PRINCIPAL_LENGTH 256 - -#define SSL_MAX_SSL_SESSION_ID_LENGTH 32 -#define SSL_MAX_SID_CTX_LENGTH 32 - -#define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES (512/8) -#define SSL_MAX_KEY_ARG_LENGTH 8 -#define SSL_MAX_MASTER_KEY_LENGTH 48 - -/* These are used to specify which ciphers to use and not to use */ -#define SSL_TXT_LOW "LOW" -#define SSL_TXT_MEDIUM "MEDIUM" -#define SSL_TXT_HIGH "HIGH" -#define SSL_TXT_kFZA "kFZA" -#define SSL_TXT_aFZA "aFZA" -#define SSL_TXT_eFZA "eFZA" -#define SSL_TXT_FZA "FZA" - -#define SSL_TXT_aNULL "aNULL" -#define SSL_TXT_eNULL "eNULL" -#define SSL_TXT_NULL "NULL" - -#define SSL_TXT_kKRB5 "kKRB5" -#define SSL_TXT_aKRB5 "aKRB5" -#define SSL_TXT_KRB5 "KRB5" - -#define SSL_TXT_kRSA "kRSA" -#define SSL_TXT_kDHr "kDHr" -#define SSL_TXT_kDHd "kDHd" -#define SSL_TXT_kEDH "kEDH" -#define SSL_TXT_aRSA "aRSA" -#define SSL_TXT_aDSS "aDSS" -#define SSL_TXT_aDH "aDH" -#define SSL_TXT_DSS "DSS" -#define SSL_TXT_DH "DH" -#define SSL_TXT_EDH "EDH" -#define SSL_TXT_ADH "ADH" -#define SSL_TXT_RSA "RSA" -#define SSL_TXT_DES "DES" -#define SSL_TXT_3DES "3DES" -#define SSL_TXT_RC4 "RC4" -#define SSL_TXT_RC2 "RC2" -#define SSL_TXT_IDEA "IDEA" -#define SSL_TXT_AES "AES" -#define SSL_TXT_MD5 "MD5" -#define SSL_TXT_SHA1 "SHA1" -#define SSL_TXT_SHA "SHA" -#define SSL_TXT_EXP "EXP" -#define SSL_TXT_EXPORT "EXPORT" -#define SSL_TXT_EXP40 "EXPORT40" -#define SSL_TXT_EXP56 "EXPORT56" -#define SSL_TXT_SSLV2 "SSLv2" -#define SSL_TXT_SSLV3 "SSLv3" -#define SSL_TXT_TLSV1 "TLSv1" -#define SSL_TXT_ALL "ALL" -#define SSL_TXT_ECC "ECCdraft" /* ECC ciphersuites are not yet official */ - -/* - * COMPLEMENTOF* definitions. These identifiers are used to (de-select) - * ciphers normally not being used. - * Example: "RC4" will activate all ciphers using RC4 including ciphers - * without authentication, which would normally disabled by DEFAULT (due - * the "!ADH" being part of default). Therefore "RC4:!COMPLEMENTOFDEFAULT" - * will make sure that it is also disabled in the specific selection. - * COMPLEMENTOF* identifiers are portable between version, as adjustments - * to the default cipher setup will also be included here. - * - * COMPLEMENTOFDEFAULT does not experience the same special treatment that - * DEFAULT gets, as only selection is being done and no sorting as needed - * for DEFAULT. - */ -#define SSL_TXT_CMPALL "COMPLEMENTOFALL" -#define SSL_TXT_CMPDEF "COMPLEMENTOFDEFAULT" - -/* The following cipher list is used by default. - * It also is substituted when an application-defined cipher list string - * starts with 'DEFAULT'. */ -#define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:+RC4:@STRENGTH" /* low priority for RC4 */ - -/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ -#define SSL_SENT_SHUTDOWN 1 -#define SSL_RECEIVED_SHUTDOWN 2 - -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#if (defined(OPENSSL_NO_RSA) || defined(OPENSSL_NO_MD5)) && !defined(OPENSSL_NO_SSL2) -#define OPENSSL_NO_SSL2 -#endif - -#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 -#define SSL_FILETYPE_PEM X509_FILETYPE_PEM - -/* This is needed to stop compilers complaining about the - * 'struct ssl_st *' function parameters used to prototype callbacks - * in SSL_CTX. */ -typedef struct ssl_st *ssl_crock_st; - -/* used to hold info on the particular ciphers used */ -typedef struct ssl_cipher_st - { - int valid; - const char *name; /* text name */ - unsigned long id; /* id, 4 bytes, first is version */ - unsigned long algorithms; /* what ciphers are used */ - unsigned long algo_strength; /* strength and export flags */ - unsigned long algorithm2; /* Extra flags */ - int strength_bits; /* Number of bits really used */ - int alg_bits; /* Number of bits for algorithm */ - unsigned long mask; /* used for matching */ - unsigned long mask_strength; /* also used for matching */ - } SSL_CIPHER; - -DECLARE_STACK_OF(SSL_CIPHER) - -typedef struct ssl_st SSL; -typedef struct ssl_ctx_st SSL_CTX; - -/* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */ -typedef struct ssl_method_st - { - int version; - int (*ssl_new)(SSL *s); - void (*ssl_clear)(SSL *s); - void (*ssl_free)(SSL *s); - int (*ssl_accept)(SSL *s); - int (*ssl_connect)(SSL *s); - int (*ssl_read)(SSL *s,void *buf,int len); - int (*ssl_peek)(SSL *s,void *buf,int len); - int (*ssl_write)(SSL *s,const void *buf,int len); - int (*ssl_shutdown)(SSL *s); - int (*ssl_renegotiate)(SSL *s); - int (*ssl_renegotiate_check)(SSL *s); - long (*ssl_get_message)(SSL *s, int st1, int stn, int mt, long - max, int *ok); - int (*ssl_read_bytes)(SSL *s, int type, unsigned char *buf, int len, - int peek); - int (*ssl_write_bytes)(SSL *s, int type, const void *buf_, int len); - int (*ssl_dispatch_alert)(SSL *s); - long (*ssl_ctrl)(SSL *s,int cmd,long larg,void *parg); - long (*ssl_ctx_ctrl)(SSL_CTX *ctx,int cmd,long larg,void *parg); - SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr); - int (*put_cipher_by_char)(const SSL_CIPHER *cipher,unsigned char *ptr); - int (*ssl_pending)(const SSL *s); - int (*num_ciphers)(void); - SSL_CIPHER *(*get_cipher)(unsigned ncipher); - struct ssl_method_st *(*get_ssl_method)(int version); - long (*get_timeout)(void); - struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */ - int (*ssl_version)(void); - long (*ssl_callback_ctrl)(SSL *s, int cb_id, void (*fp)(void)); - long (*ssl_ctx_callback_ctrl)(SSL_CTX *s, int cb_id, void (*fp)(void)); - } SSL_METHOD; - -/* Lets make this into an ASN.1 type structure as follows - * SSL_SESSION_ID ::= SEQUENCE { - * version INTEGER, -- structure version number - * SSLversion INTEGER, -- SSL version number - * Cipher OCTET_STRING, -- the 3 byte cipher ID - * Session_ID OCTET_STRING, -- the Session ID - * Master_key OCTET_STRING, -- the master key - * KRB5_principal OCTET_STRING -- optional Kerberos principal - * Key_Arg [ 0 ] IMPLICIT OCTET_STRING, -- the optional Key argument - * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time - * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds - * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate - * Session_ID_context [ 4 ] EXPLICIT OCTET_STRING, -- the Session ID context - * Verify_result [ 5 ] EXPLICIT INTEGER -- X509_V_... code for `Peer' - * Compression [6] IMPLICIT ASN1_OBJECT -- compression OID XXXXX - * } - * Look in ssl/ssl_asn1.c for more details - * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-). - */ -typedef struct ssl_session_st - { - int ssl_version; /* what ssl version session info is - * being kept in here? */ - - /* only really used in SSLv2 */ - unsigned int key_arg_length; - unsigned char key_arg[SSL_MAX_KEY_ARG_LENGTH]; - int master_key_length; - unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH]; - /* session_id - valid? */ - unsigned int session_id_length; - unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; - /* this is used to determine whether the session is being reused in - * the appropriate context. It is up to the application to set this, - * via SSL_new */ - unsigned int sid_ctx_length; - unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; - -#ifndef OPENSSL_NO_KRB5 - unsigned int krb5_client_princ_len; - unsigned char krb5_client_princ[SSL_MAX_KRB5_PRINCIPAL_LENGTH]; -#endif /* OPENSSL_NO_KRB5 */ - - int not_resumable; - - /* The cert is the certificate used to establish this connection */ - struct sess_cert_st /* SESS_CERT */ *sess_cert; - - /* This is the cert for the other end. - * On clients, it will be the same as sess_cert->peer_key->x509 - * (the latter is not enough as sess_cert is not retained - * in the external representation of sessions, see ssl_asn1.c). */ - X509 *peer; - /* when app_verify_callback accepts a session where the peer's certificate - * is not ok, we must remember the error for session reuse: */ - long verify_result; /* only for servers */ - - int references; - long timeout; - long time; - - int compress_meth; /* Need to lookup the method */ - - SSL_CIPHER *cipher; - unsigned long cipher_id; /* when ASN.1 loaded, this - * needs to be used to load - * the 'cipher' structure */ - - STACK_OF(SSL_CIPHER) *ciphers; /* shared ciphers? */ - - CRYPTO_EX_DATA ex_data; /* application specific data */ - - /* These are used to make removal of session-ids more - * efficient and to implement a maximum cache size. */ - struct ssl_session_st *prev,*next; - } SSL_SESSION; - - -#define SSL_OP_MICROSOFT_SESS_ID_BUG 0x00000001L -#define SSL_OP_NETSCAPE_CHALLENGE_BUG 0x00000002L -#define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0x00000008L -#define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0x00000010L -#define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0x00000020L -#define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x00000040L /* no effect since 0.9.7h and 0.9.8b */ -#define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x00000080L -#define SSL_OP_TLS_D5_BUG 0x00000100L -#define SSL_OP_TLS_BLOCK_PADDING_BUG 0x00000200L - -/* Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added - * in OpenSSL 0.9.6d. Usually (depending on the application protocol) - * the workaround is not needed. Unfortunately some broken SSL/TLS - * implementations cannot handle it at all, which is why we include - * it in SSL_OP_ALL. */ -#define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0x00000800L /* added in 0.9.6e */ - -/* SSL_OP_ALL: various bug workarounds that should be rather harmless. - * This used to be 0x000FFFFFL before 0.9.7. */ -#define SSL_OP_ALL 0x00000FFFL - -/* DTLS options */ -#define SSL_OP_NO_QUERY_MTU 0x00001000L -/* Turn on Cookie Exchange (on relevant for servers) */ -#define SSL_OP_COOKIE_EXCHANGE 0x00002000L - -/* As server, disallow session resumption on renegotiation */ -#define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0x00010000L -/* If set, always create a new key when using tmp_ecdh parameters */ -#define SSL_OP_SINGLE_ECDH_USE 0x00080000L -/* If set, always create a new key when using tmp_dh parameters */ -#define SSL_OP_SINGLE_DH_USE 0x00100000L -/* Set to always use the tmp_rsa key when doing RSA operations, - * even when this violates protocol specs */ -#define SSL_OP_EPHEMERAL_RSA 0x00200000L -/* Set on servers to choose the cipher according to the server's - * preferences */ -#define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000L -/* If set, a server will allow a client to issue a SSLv3.0 version number - * as latest version supported in the premaster secret, even when TLSv1.0 - * (version 3.1) was announced in the client hello. Normally this is - * forbidden to prevent version rollback attacks. */ -#define SSL_OP_TLS_ROLLBACK_BUG 0x00800000L - -#define SSL_OP_NO_SSLv2 0x01000000L -#define SSL_OP_NO_SSLv3 0x02000000L -#define SSL_OP_NO_TLSv1 0x04000000L - -/* The next flag deliberately changes the ciphertest, this is a check - * for the PKCS#1 attack */ -#define SSL_OP_PKCS1_CHECK_1 0x08000000L -#define SSL_OP_PKCS1_CHECK_2 0x10000000L -#define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L -#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x40000000L - - -/* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success - * when just a single record has been written): */ -#define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001L -/* Make it possible to retry SSL_write() with changed buffer location - * (buffer contents must stay the same!); this is not the default to avoid - * the misconception that non-blocking SSL_write() behaves like - * non-blocking write(): */ -#define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002L -/* Never bother the application with retries if the transport - * is blocking: */ -#define SSL_MODE_AUTO_RETRY 0x00000004L -/* Don't attempt to automatically build certificate chain */ -#define SSL_MODE_NO_AUTO_CHAIN 0x00000008L - - -/* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, - * they cannot be used to clear bits. */ - -#define SSL_CTX_set_options(ctx,op) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL) -#define SSL_CTX_get_options(ctx) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,0,NULL) -#define SSL_set_options(ssl,op) \ - SSL_ctrl((ssl),SSL_CTRL_OPTIONS,(op),NULL) -#define SSL_get_options(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_OPTIONS,0,NULL) - -#define SSL_CTX_set_mode(ctx,op) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL) -#define SSL_CTX_get_mode(ctx) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL) -#define SSL_set_mode(ssl,op) \ - SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL) -#define SSL_get_mode(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL) -#define SSL_set_mtu(ssl, mtu) \ - SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL) - - -void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); -void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); -#define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) -#define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) - - - -#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32) -#define SSL_MAX_CERT_LIST_DEFAULT 1024*30 /* 30k max cert list :-) */ -#else -#define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */ -#endif - -#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20) - -/* This callback type is used inside SSL_CTX, SSL, and in the functions that set - * them. It is used to override the generation of SSL/TLS session IDs in a - * server. Return value should be zero on an error, non-zero to proceed. Also, - * callbacks should themselves check if the id they generate is unique otherwise - * the SSL handshake will fail with an error - callbacks can do this using the - * 'ssl' value they're passed by; - * SSL_has_matching_session_id(ssl, id, *id_len) - * The length value passed in is set at the maximum size the session ID can be. - * In SSLv2 this is 16 bytes, whereas SSLv3/TLSv1 it is 32 bytes. The callback - * can alter this length to be less if desired, but under SSLv2 session IDs are - * supposed to be fixed at 16 bytes so the id will be padded after the callback - * returns in this case. It is also an error for the callback to set the size to - * zero. */ -typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id, - unsigned int *id_len); - -typedef struct ssl_comp_st - { - int id; - const char *name; -#ifndef OPENSSL_NO_COMP - COMP_METHOD *method; -#else - char *method; -#endif - } SSL_COMP; - -DECLARE_STACK_OF(SSL_COMP) - -struct ssl_ctx_st - { - SSL_METHOD *method; - - STACK_OF(SSL_CIPHER) *cipher_list; - /* same as above but sorted for lookup */ - STACK_OF(SSL_CIPHER) *cipher_list_by_id; - - struct x509_store_st /* X509_STORE */ *cert_store; - struct lhash_st /* LHASH */ *sessions; /* a set of SSL_SESSIONs */ - /* Most session-ids that will be cached, default is - * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. */ - unsigned long session_cache_size; - struct ssl_session_st *session_cache_head; - struct ssl_session_st *session_cache_tail; - - /* This can have one of 2 values, ored together, - * SSL_SESS_CACHE_CLIENT, - * SSL_SESS_CACHE_SERVER, - * Default is SSL_SESSION_CACHE_SERVER, which means only - * SSL_accept which cache SSL_SESSIONS. */ - int session_cache_mode; - - /* If timeout is not 0, it is the default timeout value set - * when SSL_new() is called. This has been put in to make - * life easier to set things up */ - long session_timeout; - - /* If this callback is not null, it will be called each - * time a session id is added to the cache. If this function - * returns 1, it means that the callback will do a - * SSL_SESSION_free() when it has finished using it. Otherwise, - * on 0, it means the callback has finished with it. - * If remove_session_cb is not null, it will be called when - * a session-id is removed from the cache. After the call, - * OpenSSL will SSL_SESSION_free() it. */ - int (*new_session_cb)(struct ssl_st *ssl,SSL_SESSION *sess); - void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess); - SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, - unsigned char *data,int len,int *copy); - - struct - { - int sess_connect; /* SSL new conn - started */ - int sess_connect_renegotiate;/* SSL reneg - requested */ - int sess_connect_good; /* SSL new conne/reneg - finished */ - int sess_accept; /* SSL new accept - started */ - int sess_accept_renegotiate;/* SSL reneg - requested */ - int sess_accept_good; /* SSL accept/reneg - finished */ - int sess_miss; /* session lookup misses */ - int sess_timeout; /* reuse attempt on timeouted session */ - int sess_cache_full; /* session removed due to full cache */ - int sess_hit; /* session reuse actually done */ - int sess_cb_hit; /* session-id that was not - * in the cache was - * passed back via the callback. This - * indicates that the application is - * supplying session-id's from other - * processes - spooky :-) */ - } stats; - - int references; - - /* if defined, these override the X509_verify_cert() calls */ - int (*app_verify_callback)(X509_STORE_CTX *, void *); - void *app_verify_arg; - /* before OpenSSL 0.9.7, 'app_verify_arg' was ignored - * ('app_verify_callback' was called with just one argument) */ - - /* Default password callback. */ - pem_password_cb *default_passwd_callback; - - /* Default password callback user data. */ - void *default_passwd_callback_userdata; - - /* get client cert callback */ - int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey); - - /* cookie generate callback */ - int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie, - unsigned int *cookie_len); - - /* verify cookie callback */ - int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie, - unsigned int cookie_len); - - CRYPTO_EX_DATA ex_data; - - const EVP_MD *rsa_md5;/* For SSLv2 - name is 'ssl2-md5' */ - const EVP_MD *md5; /* For SSLv3/TLSv1 'ssl3-md5' */ - const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */ - - STACK_OF(X509) *extra_certs; - STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */ - - - /* Default values used when no per-SSL value is defined follow */ - - void (*info_callback)(const SSL *ssl,int type,int val); /* used if SSL's info_callback is NULL */ - - /* what we put in client cert requests */ - STACK_OF(X509_NAME) *client_CA; - - - /* Default values to use in SSL structures follow (these are copied by SSL_new) */ - - unsigned long options; - unsigned long mode; - long max_cert_list; - - struct cert_st /* CERT */ *cert; - int read_ahead; - - /* callback that allows applications to peek at protocol messages */ - void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg); - void *msg_callback_arg; - - int verify_mode; - unsigned int sid_ctx_length; - unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; - int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx); /* called 'verify_callback' in the SSL */ - - /* Default generate session ID callback. */ - GEN_SESSION_CB generate_session_id; - - X509_VERIFY_PARAM *param; - -#if 0 - int purpose; /* Purpose setting */ - int trust; /* Trust setting */ -#endif - - int quiet_shutdown; - }; - -#define SSL_SESS_CACHE_OFF 0x0000 -#define SSL_SESS_CACHE_CLIENT 0x0001 -#define SSL_SESS_CACHE_SERVER 0x0002 -#define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER) -#define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080 -/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */ -#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 -#define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200 -#define SSL_SESS_CACHE_NO_INTERNAL \ - (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE) - - struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx); -#define SSL_CTX_sess_number(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL) -#define SSL_CTX_sess_connect(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL) -#define SSL_CTX_sess_connect_good(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL) -#define SSL_CTX_sess_connect_renegotiate(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL) -#define SSL_CTX_sess_accept(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL) -#define SSL_CTX_sess_accept_renegotiate(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL) -#define SSL_CTX_sess_accept_good(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL) -#define SSL_CTX_sess_hits(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL) -#define SSL_CTX_sess_cb_hits(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL) -#define SSL_CTX_sess_misses(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL) -#define SSL_CTX_sess_timeouts(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL) -#define SSL_CTX_sess_cache_full(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL) - -#define SSL_CTX_sess_set_new_cb(ctx,cb) ((ctx)->new_session_cb=(cb)) -#define SSL_CTX_sess_get_new_cb(ctx) ((ctx)->new_session_cb) -#define SSL_CTX_sess_set_remove_cb(ctx,cb) ((ctx)->remove_session_cb=(cb)) -#define SSL_CTX_sess_get_remove_cb(ctx) ((ctx)->remove_session_cb) -#define SSL_CTX_sess_set_get_cb(ctx,cb) ((ctx)->get_session_cb=(cb)) -#define SSL_CTX_sess_get_get_cb(ctx) ((ctx)->get_session_cb) -#define SSL_CTX_set_info_callback(ctx,cb) ((ctx)->info_callback=(cb)) -#define SSL_CTX_get_info_callback(ctx) ((ctx)->info_callback) -#define SSL_CTX_set_client_cert_cb(ctx,cb) ((ctx)->client_cert_cb=(cb)) -#define SSL_CTX_get_client_cert_cb(ctx) ((ctx)->client_cert_cb) -#define SSL_CTX_set_cookie_generate_cb(ctx,cb) ((ctx)->app_gen_cookie_cb=(cb)) -#define SSL_CTX_set_cookie_verify_cb(ctx,cb) ((ctx)->app_verify_cookie_cb=(cb)) - -#define SSL_NOTHING 1 -#define SSL_WRITING 2 -#define SSL_READING 3 -#define SSL_X509_LOOKUP 4 - -/* These will only be used when doing non-blocking IO */ -#define SSL_want_nothing(s) (SSL_want(s) == SSL_NOTHING) -#define SSL_want_read(s) (SSL_want(s) == SSL_READING) -#define SSL_want_write(s) (SSL_want(s) == SSL_WRITING) -#define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP) - -struct ssl_st - { - /* protocol version - * (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION, DTLS1_VERSION) - */ - int version; - int type; /* SSL_ST_CONNECT or SSL_ST_ACCEPT */ - - SSL_METHOD *method; /* SSLv3 */ - - /* There are 2 BIO's even though they are normally both the - * same. This is so data can be read and written to different - * handlers */ - -#ifndef OPENSSL_NO_BIO - BIO *rbio; /* used by SSL_read */ - BIO *wbio; /* used by SSL_write */ - BIO *bbio; /* used during session-id reuse to concatenate - * messages */ -#else - char *rbio; /* used by SSL_read */ - char *wbio; /* used by SSL_write */ - char *bbio; -#endif - /* This holds a variable that indicates what we were doing - * when a 0 or -1 is returned. This is needed for - * non-blocking IO so we know what request needs re-doing when - * in SSL_accept or SSL_connect */ - int rwstate; - - /* true when we are actually in SSL_accept() or SSL_connect() */ - int in_handshake; - int (*handshake_func)(SSL *); - - /* Imagine that here's a boolean member "init" that is - * switched as soon as SSL_set_{accept/connect}_state - * is called for the first time, so that "state" and - * "handshake_func" are properly initialized. But as - * handshake_func is == 0 until then, we use this - * test instead of an "init" member. - */ - - int server; /* are we the server side? - mostly used by SSL_clear*/ - - int new_session;/* 1 if we are to use a new session. - * 2 if we are a server and are inside a handshake - * (i.e. not just sending a HelloRequest) - * NB: For servers, the 'new' session may actually be a previously - * cached session or even the previous session unless - * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */ - int quiet_shutdown;/* don't send shutdown packets */ - int shutdown; /* we have shut things down, 0x01 sent, 0x02 - * for received */ - int state; /* where we are */ - int rstate; /* where we are when reading */ - - BUF_MEM *init_buf; /* buffer used during init */ - void *init_msg; /* pointer to handshake message body, set by ssl3_get_message() */ - int init_num; /* amount read/written */ - int init_off; /* amount read/written */ - - /* used internally to point at a raw packet */ - unsigned char *packet; - unsigned int packet_length; - - struct ssl2_state_st *s2; /* SSLv2 variables */ - struct ssl3_state_st *s3; /* SSLv3 variables */ - struct dtls1_state_st *d1; /* DTLSv1 variables */ - - int read_ahead; /* Read as many input bytes as possible - * (for non-blocking reads) */ - - /* callback that allows applications to peek at protocol messages */ - void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg); - void *msg_callback_arg; - - int hit; /* reusing a previous session */ - - X509_VERIFY_PARAM *param; - -#if 0 - int purpose; /* Purpose setting */ - int trust; /* Trust setting */ -#endif - - /* crypto */ - STACK_OF(SSL_CIPHER) *cipher_list; - STACK_OF(SSL_CIPHER) *cipher_list_by_id; - - /* These are the ones being used, the ones in SSL_SESSION are - * the ones to be 'copied' into these ones */ - - EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ - const EVP_MD *read_hash; /* used for mac generation */ -#ifndef OPENSSL_NO_COMP - COMP_CTX *expand; /* uncompress */ -#else - char *expand; -#endif - - EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ - const EVP_MD *write_hash; /* used for mac generation */ -#ifndef OPENSSL_NO_COMP - COMP_CTX *compress; /* compression */ -#else - char *compress; -#endif - - /* session info */ - - /* client cert? */ - /* This is used to hold the server certificate used */ - struct cert_st /* CERT */ *cert; - - /* the session_id_context is used to ensure sessions are only reused - * in the appropriate context */ - unsigned int sid_ctx_length; - unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; - - /* This can also be in the session once a session is established */ - SSL_SESSION *session; - - /* Default generate session ID callback. */ - GEN_SESSION_CB generate_session_id; - - /* Used in SSL2 and SSL3 */ - int verify_mode; /* 0 don't care about verify failure. - * 1 fail if verify fails */ - int (*verify_callback)(int ok,X509_STORE_CTX *ctx); /* fail if callback returns 0 */ - - void (*info_callback)(const SSL *ssl,int type,int val); /* optional informational callback */ - - int error; /* error bytes to be written */ - int error_code; /* actual code */ - -#ifndef OPENSSL_NO_KRB5 - KSSL_CTX *kssl_ctx; /* Kerberos 5 context */ -#endif /* OPENSSL_NO_KRB5 */ - - SSL_CTX *ctx; - /* set this flag to 1 and a sleep(1) is put into all SSL_read() - * and SSL_write() calls, good for nbio debuging :-) */ - int debug; - - /* extra application data */ - long verify_result; - CRYPTO_EX_DATA ex_data; - - /* for server side, keep the list of CA_dn we can use */ - STACK_OF(X509_NAME) *client_CA; - - int references; - unsigned long options; /* protocol behaviour */ - unsigned long mode; /* API behaviour */ - long max_cert_list; - int first_packet; - int client_version; /* what was passed, used for - * SSLv3/TLS rollback check */ - }; - -#ifdef __cplusplus -} -#endif - -#include -#include -#include /* This is mostly sslv3 with a few tweaks */ -#include /* Datagram TLS */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* compatibility */ -#define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)arg)) -#define SSL_get_app_data(s) (SSL_get_ex_data(s,0)) -#define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0,(char *)a)) -#define SSL_SESSION_get_app_data(s) (SSL_SESSION_get_ex_data(s,0)) -#define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx,0)) -#define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg)) - -/* The following are the possible values for ssl->state are are - * used to indicate where we are up to in the SSL connection establishment. - * The macros that follow are about the only things you should need to use - * and even then, only when using non-blocking IO. - * It can also be useful to work out where you were when the connection - * failed */ - -#define SSL_ST_CONNECT 0x1000 -#define SSL_ST_ACCEPT 0x2000 -#define SSL_ST_MASK 0x0FFF -#define SSL_ST_INIT (SSL_ST_CONNECT|SSL_ST_ACCEPT) -#define SSL_ST_BEFORE 0x4000 -#define SSL_ST_OK 0x03 -#define SSL_ST_RENEGOTIATE (0x04|SSL_ST_INIT) - -#define SSL_CB_LOOP 0x01 -#define SSL_CB_EXIT 0x02 -#define SSL_CB_READ 0x04 -#define SSL_CB_WRITE 0x08 -#define SSL_CB_ALERT 0x4000 /* used in callback */ -#define SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ) -#define SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE) -#define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP) -#define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT) -#define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP) -#define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT) -#define SSL_CB_HANDSHAKE_START 0x10 -#define SSL_CB_HANDSHAKE_DONE 0x20 - -/* Is the SSL_connection established? */ -#define SSL_get_state(a) SSL_state(a) -#define SSL_is_init_finished(a) (SSL_state(a) == SSL_ST_OK) -#define SSL_in_init(a) (SSL_state(a)&SSL_ST_INIT) -#define SSL_in_before(a) (SSL_state(a)&SSL_ST_BEFORE) -#define SSL_in_connect_init(a) (SSL_state(a)&SSL_ST_CONNECT) -#define SSL_in_accept_init(a) (SSL_state(a)&SSL_ST_ACCEPT) - -/* The following 2 states are kept in ssl->rstate when reads fail, - * you should not need these */ -#define SSL_ST_READ_HEADER 0xF0 -#define SSL_ST_READ_BODY 0xF1 -#define SSL_ST_READ_DONE 0xF2 - -/* Obtain latest Finished message - * -- that we sent (SSL_get_finished) - * -- that we expected from peer (SSL_get_peer_finished). - * Returns length (0 == no Finished so far), copies up to 'count' bytes. */ -size_t SSL_get_finished(const SSL *s, void *buf, size_t count); -size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count); - -/* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options - * are 'ored' with SSL_VERIFY_PEER if they are desired */ -#define SSL_VERIFY_NONE 0x00 -#define SSL_VERIFY_PEER 0x01 -#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 -#define SSL_VERIFY_CLIENT_ONCE 0x04 - -#define OpenSSL_add_ssl_algorithms() SSL_library_init() -#define SSLeay_add_ssl_algorithms() SSL_library_init() - -/* this is for backward compatibility */ -#if 0 /* NEW_SSLEAY */ -#define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c) -#define SSL_set_pref_cipher(c,n) SSL_set_cipher_list(c,n) -#define SSL_add_session(a,b) SSL_CTX_add_session((a),(b)) -#define SSL_remove_session(a,b) SSL_CTX_remove_session((a),(b)) -#define SSL_flush_sessions(a,b) SSL_CTX_flush_sessions((a),(b)) -#endif -/* More backward compatibility */ -#define SSL_get_cipher(s) \ - SSL_CIPHER_get_name(SSL_get_current_cipher(s)) -#define SSL_get_cipher_bits(s,np) \ - SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np) -#define SSL_get_cipher_version(s) \ - SSL_CIPHER_get_version(SSL_get_current_cipher(s)) -#define SSL_get_cipher_name(s) \ - SSL_CIPHER_get_name(SSL_get_current_cipher(s)) -#define SSL_get_time(a) SSL_SESSION_get_time(a) -#define SSL_set_time(a,b) SSL_SESSION_set_time((a),(b)) -#define SSL_get_timeout(a) SSL_SESSION_get_timeout(a) -#define SSL_set_timeout(a,b) SSL_SESSION_set_timeout((a),(b)) - -#if 1 /*SSLEAY_MACROS*/ -#define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id) -#define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id) -#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \ - (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u) -#define PEM_read_bio_SSL_SESSION(bp,x,cb,u) PEM_ASN1_read_bio_of(SSL_SESSION,d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,x,cb,u) -#define PEM_write_SSL_SESSION(fp,x) \ - PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ - PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL) -#define PEM_write_bio_SSL_SESSION(bp,x) \ - PEM_ASN1_write_bio_of(SSL_SESSION,i2d_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,x,NULL,NULL,0,NULL,NULL) -#endif - -#define SSL_AD_REASON_OFFSET 1000 -/* These alert types are for SSLv3 and TLSv1 */ -#define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY -#define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE /* fatal */ -#define SSL_AD_BAD_RECORD_MAC SSL3_AD_BAD_RECORD_MAC /* fatal */ -#define SSL_AD_DECRYPTION_FAILED TLS1_AD_DECRYPTION_FAILED -#define SSL_AD_RECORD_OVERFLOW TLS1_AD_RECORD_OVERFLOW -#define SSL_AD_DECOMPRESSION_FAILURE SSL3_AD_DECOMPRESSION_FAILURE/* fatal */ -#define SSL_AD_HANDSHAKE_FAILURE SSL3_AD_HANDSHAKE_FAILURE/* fatal */ -#define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE /* Not for TLS */ -#define SSL_AD_BAD_CERTIFICATE SSL3_AD_BAD_CERTIFICATE -#define SSL_AD_UNSUPPORTED_CERTIFICATE SSL3_AD_UNSUPPORTED_CERTIFICATE -#define SSL_AD_CERTIFICATE_REVOKED SSL3_AD_CERTIFICATE_REVOKED -#define SSL_AD_CERTIFICATE_EXPIRED SSL3_AD_CERTIFICATE_EXPIRED -#define SSL_AD_CERTIFICATE_UNKNOWN SSL3_AD_CERTIFICATE_UNKNOWN -#define SSL_AD_ILLEGAL_PARAMETER SSL3_AD_ILLEGAL_PARAMETER /* fatal */ -#define SSL_AD_UNKNOWN_CA TLS1_AD_UNKNOWN_CA /* fatal */ -#define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED /* fatal */ -#define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR /* fatal */ -#define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR -#define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION/* fatal */ -#define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION /* fatal */ -#define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY/* fatal */ -#define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR /* fatal */ -#define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED -#define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION - -#define SSL_ERROR_NONE 0 -#define SSL_ERROR_SSL 1 -#define SSL_ERROR_WANT_READ 2 -#define SSL_ERROR_WANT_WRITE 3 -#define SSL_ERROR_WANT_X509_LOOKUP 4 -#define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */ -#define SSL_ERROR_ZERO_RETURN 6 -#define SSL_ERROR_WANT_CONNECT 7 -#define SSL_ERROR_WANT_ACCEPT 8 - -#define SSL_CTRL_NEED_TMP_RSA 1 -#define SSL_CTRL_SET_TMP_RSA 2 -#define SSL_CTRL_SET_TMP_DH 3 -#define SSL_CTRL_SET_TMP_ECDH 4 -#define SSL_CTRL_SET_TMP_RSA_CB 5 -#define SSL_CTRL_SET_TMP_DH_CB 6 -#define SSL_CTRL_SET_TMP_ECDH_CB 7 - -#define SSL_CTRL_GET_SESSION_REUSED 8 -#define SSL_CTRL_GET_CLIENT_CERT_REQUEST 9 -#define SSL_CTRL_GET_NUM_RENEGOTIATIONS 10 -#define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 11 -#define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 12 -#define SSL_CTRL_GET_FLAGS 13 -#define SSL_CTRL_EXTRA_CHAIN_CERT 14 - -#define SSL_CTRL_SET_MSG_CALLBACK 15 -#define SSL_CTRL_SET_MSG_CALLBACK_ARG 16 - -/* only applies to datagram connections */ -#define SSL_CTRL_SET_MTU 17 -/* Stats */ -#define SSL_CTRL_SESS_NUMBER 20 -#define SSL_CTRL_SESS_CONNECT 21 -#define SSL_CTRL_SESS_CONNECT_GOOD 22 -#define SSL_CTRL_SESS_CONNECT_RENEGOTIATE 23 -#define SSL_CTRL_SESS_ACCEPT 24 -#define SSL_CTRL_SESS_ACCEPT_GOOD 25 -#define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE 26 -#define SSL_CTRL_SESS_HIT 27 -#define SSL_CTRL_SESS_CB_HIT 28 -#define SSL_CTRL_SESS_MISSES 29 -#define SSL_CTRL_SESS_TIMEOUTS 30 -#define SSL_CTRL_SESS_CACHE_FULL 31 -#define SSL_CTRL_OPTIONS 32 -#define SSL_CTRL_MODE 33 - -#define SSL_CTRL_GET_READ_AHEAD 40 -#define SSL_CTRL_SET_READ_AHEAD 41 -#define SSL_CTRL_SET_SESS_CACHE_SIZE 42 -#define SSL_CTRL_GET_SESS_CACHE_SIZE 43 -#define SSL_CTRL_SET_SESS_CACHE_MODE 44 -#define SSL_CTRL_GET_SESS_CACHE_MODE 45 - -#define SSL_CTRL_GET_MAX_CERT_LIST 50 -#define SSL_CTRL_SET_MAX_CERT_LIST 51 - -#define SSL_session_reused(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL) -#define SSL_num_renegotiations(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL) -#define SSL_clear_num_renegotiations(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL) -#define SSL_total_renegotiations(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL) - -#define SSL_CTX_need_tmp_RSA(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL) -#define SSL_CTX_set_tmp_rsa(ctx,rsa) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa) -#define SSL_CTX_set_tmp_dh(ctx,dh) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)dh) -#define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh) - -#define SSL_need_tmp_RSA(ssl) \ - SSL_ctrl(ssl,SSL_CTRL_NEED_TMP_RSA,0,NULL) -#define SSL_set_tmp_rsa(ssl,rsa) \ - SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa) -#define SSL_set_tmp_dh(ssl,dh) \ - SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)dh) -#define SSL_set_tmp_ecdh(ssl,ecdh) \ - SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh) - -#define SSL_CTX_add_extra_chain_cert(ctx,x509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509) - -#ifndef OPENSSL_NO_BIO -BIO_METHOD *BIO_f_ssl(void); -BIO *BIO_new_ssl(SSL_CTX *ctx,int client); -BIO *BIO_new_ssl_connect(SSL_CTX *ctx); -BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx); -int BIO_ssl_copy_session_id(BIO *to,BIO *from); -void BIO_ssl_shutdown(BIO *ssl_bio); - -#endif - -int SSL_CTX_set_cipher_list(SSL_CTX *,const char *str); -SSL_CTX *SSL_CTX_new(SSL_METHOD *meth); -void SSL_CTX_free(SSL_CTX *); -long SSL_CTX_set_timeout(SSL_CTX *ctx,long t); -long SSL_CTX_get_timeout(const SSL_CTX *ctx); -X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *); -void SSL_CTX_set_cert_store(SSL_CTX *,X509_STORE *); -int SSL_want(const SSL *s); -int SSL_clear(SSL *s); - -void SSL_CTX_flush_sessions(SSL_CTX *ctx,long tm); - -SSL_CIPHER *SSL_get_current_cipher(const SSL *s); -int SSL_CIPHER_get_bits(const SSL_CIPHER *c,int *alg_bits); -char * SSL_CIPHER_get_version(const SSL_CIPHER *c); -const char * SSL_CIPHER_get_name(const SSL_CIPHER *c); - -int SSL_get_fd(const SSL *s); -int SSL_get_rfd(const SSL *s); -int SSL_get_wfd(const SSL *s); -const char * SSL_get_cipher_list(const SSL *s,int n); -char * SSL_get_shared_ciphers(const SSL *s, char *buf, int len); -int SSL_get_read_ahead(const SSL * s); -int SSL_pending(const SSL *s); -#ifndef OPENSSL_NO_SOCK -int SSL_set_fd(SSL *s, int fd); -int SSL_set_rfd(SSL *s, int fd); -int SSL_set_wfd(SSL *s, int fd); -#endif -#ifndef OPENSSL_NO_BIO -void SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio); -BIO * SSL_get_rbio(const SSL *s); -BIO * SSL_get_wbio(const SSL *s); -#endif -int SSL_set_cipher_list(SSL *s, const char *str); -void SSL_set_read_ahead(SSL *s, int yes); -int SSL_get_verify_mode(const SSL *s); -int SSL_get_verify_depth(const SSL *s); -int (*SSL_get_verify_callback(const SSL *s))(int,X509_STORE_CTX *); -void SSL_set_verify(SSL *s, int mode, - int (*callback)(int ok,X509_STORE_CTX *ctx)); -void SSL_set_verify_depth(SSL *s, int depth); -#ifndef OPENSSL_NO_RSA -int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); -#endif -int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len); -int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); -int SSL_use_PrivateKey_ASN1(int pk,SSL *ssl, const unsigned char *d, long len); -int SSL_use_certificate(SSL *ssl, X509 *x); -int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len); - -#ifndef OPENSSL_NO_STDIO -int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type); -int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type); -int SSL_use_certificate_file(SSL *ssl, const char *file, int type); -int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type); -int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type); -int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type); -int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); /* PEM type */ -STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); -int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, - const char *file); -#ifndef OPENSSL_SYS_VMS -#ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */ -int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, - const char *dir); -#endif -#endif - -#endif - -void SSL_load_error_strings(void ); -const char *SSL_state_string(const SSL *s); -const char *SSL_rstate_string(const SSL *s); -const char *SSL_state_string_long(const SSL *s); -const char *SSL_rstate_string_long(const SSL *s); -long SSL_SESSION_get_time(const SSL_SESSION *s); -long SSL_SESSION_set_time(SSL_SESSION *s, long t); -long SSL_SESSION_get_timeout(const SSL_SESSION *s); -long SSL_SESSION_set_timeout(SSL_SESSION *s, long t); -void SSL_copy_session_id(SSL *to,const SSL *from); - -SSL_SESSION *SSL_SESSION_new(void); -unsigned long SSL_SESSION_hash(const SSL_SESSION *a); -int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b); -const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len); -#ifndef OPENSSL_NO_FP_API -int SSL_SESSION_print_fp(FILE *fp,const SSL_SESSION *ses); -#endif -#ifndef OPENSSL_NO_BIO -int SSL_SESSION_print(BIO *fp,const SSL_SESSION *ses); -#endif -void SSL_SESSION_free(SSL_SESSION *ses); -int i2d_SSL_SESSION(SSL_SESSION *in,unsigned char **pp); -int SSL_set_session(SSL *to, SSL_SESSION *session); -int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c); -int SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c); -int SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB); -int SSL_set_generate_session_id(SSL *, GEN_SESSION_CB); -int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id, - unsigned int id_len); -SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,const unsigned char **pp, - long length); - -#ifdef HEADER_X509_H -X509 * SSL_get_peer_certificate(const SSL *s); -#endif - -STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s); - -int SSL_CTX_get_verify_mode(const SSL_CTX *ctx); -int SSL_CTX_get_verify_depth(const SSL_CTX *ctx); -int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int,X509_STORE_CTX *); -void SSL_CTX_set_verify(SSL_CTX *ctx,int mode, - int (*callback)(int, X509_STORE_CTX *)); -void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth); -void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *,void *), void *arg); -#ifndef OPENSSL_NO_RSA -int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); -#endif -int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len); -int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); -int SSL_CTX_use_PrivateKey_ASN1(int pk,SSL_CTX *ctx, - const unsigned char *d, long len); -int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); -int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, const unsigned char *d); - -void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb); -void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u); - -int SSL_CTX_check_private_key(const SSL_CTX *ctx); -int SSL_check_private_key(const SSL *ctx); - -int SSL_CTX_set_session_id_context(SSL_CTX *ctx,const unsigned char *sid_ctx, - unsigned int sid_ctx_len); - -SSL * SSL_new(SSL_CTX *ctx); -int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx, - unsigned int sid_ctx_len); - -int SSL_CTX_set_purpose(SSL_CTX *s, int purpose); -int SSL_set_purpose(SSL *s, int purpose); -int SSL_CTX_set_trust(SSL_CTX *s, int trust); -int SSL_set_trust(SSL *s, int trust); - -void SSL_free(SSL *ssl); -int SSL_accept(SSL *ssl); -int SSL_connect(SSL *ssl); -int SSL_read(SSL *ssl,void *buf,int num); -int SSL_peek(SSL *ssl,void *buf,int num); -int SSL_write(SSL *ssl,const void *buf,int num); -long SSL_ctrl(SSL *ssl,int cmd, long larg, void *parg); -long SSL_callback_ctrl(SSL *, int, void (*)(void)); -long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, void *parg); -long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void)); - -int SSL_get_error(const SSL *s,int ret_code); -const char *SSL_get_version(const SSL *s); - -/* This sets the 'default' SSL version that SSL_new() will create */ -int SSL_CTX_set_ssl_version(SSL_CTX *ctx,SSL_METHOD *meth); - -SSL_METHOD *SSLv2_method(void); /* SSLv2 */ -SSL_METHOD *SSLv2_server_method(void); /* SSLv2 */ -SSL_METHOD *SSLv2_client_method(void); /* SSLv2 */ - -SSL_METHOD *SSLv3_method(void); /* SSLv3 */ -SSL_METHOD *SSLv3_server_method(void); /* SSLv3 */ -SSL_METHOD *SSLv3_client_method(void); /* SSLv3 */ - -SSL_METHOD *SSLv23_method(void); /* SSLv3 but can rollback to v2 */ -SSL_METHOD *SSLv23_server_method(void); /* SSLv3 but can rollback to v2 */ -SSL_METHOD *SSLv23_client_method(void); /* SSLv3 but can rollback to v2 */ - -SSL_METHOD *TLSv1_method(void); /* TLSv1.0 */ -SSL_METHOD *TLSv1_server_method(void); /* TLSv1.0 */ -SSL_METHOD *TLSv1_client_method(void); /* TLSv1.0 */ - -SSL_METHOD *DTLSv1_method(void); /* DTLSv1.0 */ -SSL_METHOD *DTLSv1_server_method(void); /* DTLSv1.0 */ -SSL_METHOD *DTLSv1_client_method(void); /* DTLSv1.0 */ - -STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s); - -int SSL_do_handshake(SSL *s); -int SSL_renegotiate(SSL *s); -int SSL_renegotiate_pending(SSL *s); -int SSL_shutdown(SSL *s); - -SSL_METHOD *SSL_get_ssl_method(SSL *s); -int SSL_set_ssl_method(SSL *s,SSL_METHOD *method); -const char *SSL_alert_type_string_long(int value); -const char *SSL_alert_type_string(int value); -const char *SSL_alert_desc_string_long(int value); -const char *SSL_alert_desc_string(int value); - -void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list); -void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list); -STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s); -STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s); -int SSL_add_client_CA(SSL *ssl,X509 *x); -int SSL_CTX_add_client_CA(SSL_CTX *ctx,X509 *x); - -void SSL_set_connect_state(SSL *s); -void SSL_set_accept_state(SSL *s); - -long SSL_get_default_timeout(const SSL *s); - -int SSL_library_init(void ); - -char *SSL_CIPHER_description(SSL_CIPHER *,char *buf,int size); -STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk); - -SSL *SSL_dup(SSL *ssl); - -X509 *SSL_get_certificate(const SSL *ssl); -/* EVP_PKEY */ struct evp_pkey_st *SSL_get_privatekey(SSL *ssl); - -void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx,int mode); -int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx); -void SSL_set_quiet_shutdown(SSL *ssl,int mode); -int SSL_get_quiet_shutdown(const SSL *ssl); -void SSL_set_shutdown(SSL *ssl,int mode); -int SSL_get_shutdown(const SSL *ssl); -int SSL_version(const SSL *ssl); -int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); -int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, - const char *CApath); -#define SSL_get0_session SSL_get_session /* just peek at pointer */ -SSL_SESSION *SSL_get_session(const SSL *ssl); -SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */ -SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl); -void SSL_set_info_callback(SSL *ssl, - void (*cb)(const SSL *ssl,int type,int val)); -void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl,int type,int val); -int SSL_state(const SSL *ssl); - -void SSL_set_verify_result(SSL *ssl,long v); -long SSL_get_verify_result(const SSL *ssl); - -int SSL_set_ex_data(SSL *ssl,int idx,void *data); -void *SSL_get_ex_data(const SSL *ssl,int idx); -int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); - -int SSL_SESSION_set_ex_data(SSL_SESSION *ss,int idx,void *data); -void *SSL_SESSION_get_ex_data(const SSL_SESSION *ss,int idx); -int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); - -int SSL_CTX_set_ex_data(SSL_CTX *ssl,int idx,void *data); -void *SSL_CTX_get_ex_data(const SSL_CTX *ssl,int idx); -int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); - -int SSL_get_ex_data_X509_STORE_CTX_idx(void ); - -#define SSL_CTX_sess_set_cache_size(ctx,t) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL) -#define SSL_CTX_sess_get_cache_size(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL) -#define SSL_CTX_set_session_cache_mode(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL) -#define SSL_CTX_get_session_cache_mode(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL) - -#define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx) -#define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m) -#define SSL_CTX_get_read_ahead(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL) -#define SSL_CTX_set_read_ahead(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL) -#define SSL_CTX_get_max_cert_list(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) -#define SSL_CTX_set_max_cert_list(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) -#define SSL_get_max_cert_list(ssl) \ - SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) -#define SSL_set_max_cert_list(ssl,m) \ - SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) - - /* NB: the keylength is only applicable when is_export is true */ -#ifndef OPENSSL_NO_RSA -void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx, - RSA *(*cb)(SSL *ssl,int is_export, - int keylength)); - -void SSL_set_tmp_rsa_callback(SSL *ssl, - RSA *(*cb)(SSL *ssl,int is_export, - int keylength)); -#endif -#ifndef OPENSSL_NO_DH -void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, - DH *(*dh)(SSL *ssl,int is_export, - int keylength)); -void SSL_set_tmp_dh_callback(SSL *ssl, - DH *(*dh)(SSL *ssl,int is_export, - int keylength)); -#endif -#ifndef OPENSSL_NO_ECDH -void SSL_CTX_set_tmp_ecdh_callback(SSL_CTX *ctx, - EC_KEY *(*ecdh)(SSL *ssl,int is_export, - int keylength)); -void SSL_set_tmp_ecdh_callback(SSL *ssl, - EC_KEY *(*ecdh)(SSL *ssl,int is_export, - int keylength)); -#endif - -#ifndef OPENSSL_NO_COMP -const COMP_METHOD *SSL_get_current_compression(SSL *s); -const COMP_METHOD *SSL_get_current_expansion(SSL *s); -const char *SSL_COMP_get_name(const COMP_METHOD *comp); -STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void); -int SSL_COMP_add_compression_method(int id,COMP_METHOD *cm); -#else -const void *SSL_get_current_compression(SSL *s); -const void *SSL_get_current_expansion(SSL *s); -const char *SSL_COMP_get_name(const void *comp); -void *SSL_COMP_get_compression_methods(void); -int SSL_COMP_add_compression_method(int id,void *cm); -#endif - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_SSL_strings(void); - -/* Error codes for the SSL functions. */ - -/* Function codes. */ -#define SSL_F_CLIENT_CERTIFICATE 100 -#define SSL_F_CLIENT_FINISHED 167 -#define SSL_F_CLIENT_HELLO 101 -#define SSL_F_CLIENT_MASTER_KEY 102 -#define SSL_F_D2I_SSL_SESSION 103 -#define SSL_F_DO_DTLS1_WRITE 245 -#define SSL_F_DO_SSL3_WRITE 104 -#define SSL_F_DTLS1_ACCEPT 246 -#define SSL_F_DTLS1_BUFFER_RECORD 247 -#define SSL_F_DTLS1_CLIENT_HELLO 248 -#define SSL_F_DTLS1_CONNECT 249 -#define SSL_F_DTLS1_ENC 250 -#define SSL_F_DTLS1_GET_HELLO_VERIFY 251 -#define SSL_F_DTLS1_GET_MESSAGE 252 -#define SSL_F_DTLS1_GET_MESSAGE_FRAGMENT 253 -#define SSL_F_DTLS1_GET_RECORD 254 -#define SSL_F_DTLS1_OUTPUT_CERT_CHAIN 255 -#define SSL_F_DTLS1_PROCESS_OUT_OF_SEQ_MESSAGE 256 -#define SSL_F_DTLS1_PROCESS_RECORD 257 -#define SSL_F_DTLS1_READ_BYTES 258 -#define SSL_F_DTLS1_READ_FAILED 259 -#define SSL_F_DTLS1_SEND_CERTIFICATE_REQUEST 260 -#define SSL_F_DTLS1_SEND_CLIENT_CERTIFICATE 261 -#define SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE 262 -#define SSL_F_DTLS1_SEND_CLIENT_VERIFY 263 -#define SSL_F_DTLS1_SEND_HELLO_VERIFY_REQUEST 264 -#define SSL_F_DTLS1_SEND_SERVER_CERTIFICATE 265 -#define SSL_F_DTLS1_SEND_SERVER_HELLO 266 -#define SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE 267 -#define SSL_F_DTLS1_WRITE_APP_DATA_BYTES 268 -#define SSL_F_GET_CLIENT_FINISHED 105 -#define SSL_F_GET_CLIENT_HELLO 106 -#define SSL_F_GET_CLIENT_MASTER_KEY 107 -#define SSL_F_GET_SERVER_FINISHED 108 -#define SSL_F_GET_SERVER_HELLO 109 -#define SSL_F_GET_SERVER_VERIFY 110 -#define SSL_F_I2D_SSL_SESSION 111 -#define SSL_F_READ_N 112 -#define SSL_F_REQUEST_CERTIFICATE 113 -#define SSL_F_SERVER_FINISH 239 -#define SSL_F_SERVER_HELLO 114 -#define SSL_F_SERVER_VERIFY 240 -#define SSL_F_SSL23_ACCEPT 115 -#define SSL_F_SSL23_CLIENT_HELLO 116 -#define SSL_F_SSL23_CONNECT 117 -#define SSL_F_SSL23_GET_CLIENT_HELLO 118 -#define SSL_F_SSL23_GET_SERVER_HELLO 119 -#define SSL_F_SSL23_PEEK 237 -#define SSL_F_SSL23_READ 120 -#define SSL_F_SSL23_WRITE 121 -#define SSL_F_SSL2_ACCEPT 122 -#define SSL_F_SSL2_CONNECT 123 -#define SSL_F_SSL2_ENC_INIT 124 -#define SSL_F_SSL2_GENERATE_KEY_MATERIAL 241 -#define SSL_F_SSL2_PEEK 234 -#define SSL_F_SSL2_READ 125 -#define SSL_F_SSL2_READ_INTERNAL 236 -#define SSL_F_SSL2_SET_CERTIFICATE 126 -#define SSL_F_SSL2_WRITE 127 -#define SSL_F_SSL3_ACCEPT 128 -#define SSL_F_SSL3_CALLBACK_CTRL 233 -#define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 -#define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 -#define SSL_F_SSL3_CLIENT_HELLO 131 -#define SSL_F_SSL3_CONNECT 132 -#define SSL_F_SSL3_CTRL 213 -#define SSL_F_SSL3_CTX_CTRL 133 -#define SSL_F_SSL3_ENC 134 -#define SSL_F_SSL3_GENERATE_KEY_BLOCK 238 -#define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135 -#define SSL_F_SSL3_GET_CERT_VERIFY 136 -#define SSL_F_SSL3_GET_CLIENT_CERTIFICATE 137 -#define SSL_F_SSL3_GET_CLIENT_HELLO 138 -#define SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE 139 -#define SSL_F_SSL3_GET_FINISHED 140 -#define SSL_F_SSL3_GET_KEY_EXCHANGE 141 -#define SSL_F_SSL3_GET_MESSAGE 142 -#define SSL_F_SSL3_GET_RECORD 143 -#define SSL_F_SSL3_GET_SERVER_CERTIFICATE 144 -#define SSL_F_SSL3_GET_SERVER_DONE 145 -#define SSL_F_SSL3_GET_SERVER_HELLO 146 -#define SSL_F_SSL3_OUTPUT_CERT_CHAIN 147 -#define SSL_F_SSL3_PEEK 235 -#define SSL_F_SSL3_READ_BYTES 148 -#define SSL_F_SSL3_READ_N 149 -#define SSL_F_SSL3_SEND_CERTIFICATE_REQUEST 150 -#define SSL_F_SSL3_SEND_CLIENT_CERTIFICATE 151 -#define SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE 152 -#define SSL_F_SSL3_SEND_CLIENT_VERIFY 153 -#define SSL_F_SSL3_SEND_SERVER_CERTIFICATE 154 -#define SSL_F_SSL3_SEND_SERVER_HELLO 242 -#define SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE 155 -#define SSL_F_SSL3_SETUP_BUFFERS 156 -#define SSL_F_SSL3_SETUP_KEY_BLOCK 157 -#define SSL_F_SSL3_WRITE_BYTES 158 -#define SSL_F_SSL3_WRITE_PENDING 159 -#define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK 215 -#define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK 216 -#define SSL_F_SSL_BAD_METHOD 160 -#define SSL_F_SSL_BYTES_TO_CIPHER_LIST 161 -#define SSL_F_SSL_CERT_DUP 221 -#define SSL_F_SSL_CERT_INST 222 -#define SSL_F_SSL_CERT_INSTANTIATE 214 -#define SSL_F_SSL_CERT_NEW 162 -#define SSL_F_SSL_CHECK_PRIVATE_KEY 163 -#define SSL_F_SSL_CIPHER_PROCESS_RULESTR 230 -#define SSL_F_SSL_CIPHER_STRENGTH_SORT 231 -#define SSL_F_SSL_CLEAR 164 -#define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 165 -#define SSL_F_SSL_CREATE_CIPHER_LIST 166 -#define SSL_F_SSL_CTRL 232 -#define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 168 -#define SSL_F_SSL_CTX_NEW 169 -#define SSL_F_SSL_CTX_SET_CIPHER_LIST 269 -#define SSL_F_SSL_CTX_SET_PURPOSE 226 -#define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 219 -#define SSL_F_SSL_CTX_SET_SSL_VERSION 170 -#define SSL_F_SSL_CTX_SET_TRUST 229 -#define SSL_F_SSL_CTX_USE_CERTIFICATE 171 -#define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 172 -#define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE 220 -#define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 173 -#define SSL_F_SSL_CTX_USE_PRIVATEKEY 174 -#define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 175 -#define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 176 -#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 177 -#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 178 -#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 179 -#define SSL_F_SSL_DO_HANDSHAKE 180 -#define SSL_F_SSL_GET_NEW_SESSION 181 -#define SSL_F_SSL_GET_PREV_SESSION 217 -#define SSL_F_SSL_GET_SERVER_SEND_CERT 182 -#define SSL_F_SSL_GET_SIGN_PKEY 183 -#define SSL_F_SSL_INIT_WBIO_BUFFER 184 -#define SSL_F_SSL_LOAD_CLIENT_CA_FILE 185 -#define SSL_F_SSL_NEW 186 -#define SSL_F_SSL_PEEK 270 -#define SSL_F_SSL_READ 223 -#define SSL_F_SSL_RSA_PRIVATE_DECRYPT 187 -#define SSL_F_SSL_RSA_PUBLIC_ENCRYPT 188 -#define SSL_F_SSL_SESSION_NEW 189 -#define SSL_F_SSL_SESSION_PRINT_FP 190 -#define SSL_F_SSL_SESS_CERT_NEW 225 -#define SSL_F_SSL_SET_CERT 191 -#define SSL_F_SSL_SET_CIPHER_LIST 271 -#define SSL_F_SSL_SET_FD 192 -#define SSL_F_SSL_SET_PKEY 193 -#define SSL_F_SSL_SET_PURPOSE 227 -#define SSL_F_SSL_SET_RFD 194 -#define SSL_F_SSL_SET_SESSION 195 -#define SSL_F_SSL_SET_SESSION_ID_CONTEXT 218 -#define SSL_F_SSL_SET_TRUST 228 -#define SSL_F_SSL_SET_WFD 196 -#define SSL_F_SSL_SHUTDOWN 224 -#define SSL_F_SSL_UNDEFINED_CONST_FUNCTION 243 -#define SSL_F_SSL_UNDEFINED_FUNCTION 197 -#define SSL_F_SSL_UNDEFINED_VOID_FUNCTION 244 -#define SSL_F_SSL_USE_CERTIFICATE 198 -#define SSL_F_SSL_USE_CERTIFICATE_ASN1 199 -#define SSL_F_SSL_USE_CERTIFICATE_FILE 200 -#define SSL_F_SSL_USE_PRIVATEKEY 201 -#define SSL_F_SSL_USE_PRIVATEKEY_ASN1 202 -#define SSL_F_SSL_USE_PRIVATEKEY_FILE 203 -#define SSL_F_SSL_USE_RSAPRIVATEKEY 204 -#define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 205 -#define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 206 -#define SSL_F_SSL_VERIFY_CERT_CHAIN 207 -#define SSL_F_SSL_WRITE 208 -#define SSL_F_TLS1_CHANGE_CIPHER_STATE 209 -#define SSL_F_TLS1_ENC 210 -#define SSL_F_TLS1_SETUP_KEY_BLOCK 211 -#define SSL_F_WRITE_PENDING 212 - -/* Reason codes. */ -#define SSL_R_APP_DATA_IN_HANDSHAKE 100 -#define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272 -#define SSL_R_BAD_ALERT_RECORD 101 -#define SSL_R_BAD_AUTHENTICATION_TYPE 102 -#define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 -#define SSL_R_BAD_CHECKSUM 104 -#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106 -#define SSL_R_BAD_DECOMPRESSION 107 -#define SSL_R_BAD_DH_G_LENGTH 108 -#define SSL_R_BAD_DH_PUB_KEY_LENGTH 109 -#define SSL_R_BAD_DH_P_LENGTH 110 -#define SSL_R_BAD_DIGEST_LENGTH 111 -#define SSL_R_BAD_DSA_SIGNATURE 112 -#define SSL_R_BAD_ECC_CERT 304 -#define SSL_R_BAD_ECDSA_SIGNATURE 305 -#define SSL_R_BAD_ECPOINT 306 -#define SSL_R_BAD_HELLO_REQUEST 105 -#define SSL_R_BAD_LENGTH 271 -#define SSL_R_BAD_MAC_DECODE 113 -#define SSL_R_BAD_MESSAGE_TYPE 114 -#define SSL_R_BAD_PACKET_LENGTH 115 -#define SSL_R_BAD_PROTOCOL_VERSION_NUMBER 116 -#define SSL_R_BAD_RESPONSE_ARGUMENT 117 -#define SSL_R_BAD_RSA_DECRYPT 118 -#define SSL_R_BAD_RSA_ENCRYPT 119 -#define SSL_R_BAD_RSA_E_LENGTH 120 -#define SSL_R_BAD_RSA_MODULUS_LENGTH 121 -#define SSL_R_BAD_RSA_SIGNATURE 122 -#define SSL_R_BAD_SIGNATURE 123 -#define SSL_R_BAD_SSL_FILETYPE 124 -#define SSL_R_BAD_SSL_SESSION_ID_LENGTH 125 -#define SSL_R_BAD_STATE 126 -#define SSL_R_BAD_WRITE_RETRY 127 -#define SSL_R_BIO_NOT_SET 128 -#define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG 129 -#define SSL_R_BN_LIB 130 -#define SSL_R_CA_DN_LENGTH_MISMATCH 131 -#define SSL_R_CA_DN_TOO_LONG 132 -#define SSL_R_CCS_RECEIVED_EARLY 133 -#define SSL_R_CERTIFICATE_VERIFY_FAILED 134 -#define SSL_R_CERT_LENGTH_MISMATCH 135 -#define SSL_R_CHALLENGE_IS_DIFFERENT 136 -#define SSL_R_CIPHER_CODE_WRONG_LENGTH 137 -#define SSL_R_CIPHER_OR_HASH_UNAVAILABLE 138 -#define SSL_R_CIPHER_TABLE_SRC_ERROR 139 -#define SSL_R_COMPRESSED_LENGTH_TOO_LONG 140 -#define SSL_R_COMPRESSION_FAILURE 141 -#define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE 307 -#define SSL_R_COMPRESSION_LIBRARY_ERROR 142 -#define SSL_R_CONNECTION_ID_IS_DIFFERENT 143 -#define SSL_R_CONNECTION_TYPE_NOT_SET 144 -#define SSL_R_COOKIE_MISMATCH 308 -#define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 145 -#define SSL_R_DATA_LENGTH_TOO_LONG 146 -#define SSL_R_DECRYPTION_FAILED 147 -#define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 281 -#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148 -#define SSL_R_DIGEST_CHECK_FAILED 149 -#define SSL_R_DUPLICATE_COMPRESSION_ID 309 -#define SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER 310 -#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150 -#define SSL_R_ERROR_GENERATING_TMP_RSA_KEY 282 -#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 151 -#define SSL_R_EXCESSIVE_MESSAGE_SIZE 152 -#define SSL_R_EXTRA_DATA_IN_MESSAGE 153 -#define SSL_R_GOT_A_FIN_BEFORE_A_CCS 154 -#define SSL_R_HTTPS_PROXY_REQUEST 155 -#define SSL_R_HTTP_REQUEST 156 -#define SSL_R_ILLEGAL_PADDING 283 -#define SSL_R_INVALID_CHALLENGE_LENGTH 158 -#define SSL_R_INVALID_COMMAND 280 -#define SSL_R_INVALID_PURPOSE 278 -#define SSL_R_INVALID_TRUST 279 -#define SSL_R_KEY_ARG_TOO_LONG 284 -#define SSL_R_KRB5 285 -#define SSL_R_KRB5_C_CC_PRINC 286 -#define SSL_R_KRB5_C_GET_CRED 287 -#define SSL_R_KRB5_C_INIT 288 -#define SSL_R_KRB5_C_MK_REQ 289 -#define SSL_R_KRB5_S_BAD_TICKET 290 -#define SSL_R_KRB5_S_INIT 291 -#define SSL_R_KRB5_S_RD_REQ 292 -#define SSL_R_KRB5_S_TKT_EXPIRED 293 -#define SSL_R_KRB5_S_TKT_NYV 294 -#define SSL_R_KRB5_S_TKT_SKEW 295 -#define SSL_R_LENGTH_MISMATCH 159 -#define SSL_R_LENGTH_TOO_SHORT 160 -#define SSL_R_LIBRARY_BUG 274 -#define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 -#define SSL_R_MESSAGE_TOO_LONG 296 -#define SSL_R_MISSING_DH_DSA_CERT 162 -#define SSL_R_MISSING_DH_KEY 163 -#define SSL_R_MISSING_DH_RSA_CERT 164 -#define SSL_R_MISSING_DSA_SIGNING_CERT 165 -#define SSL_R_MISSING_EXPORT_TMP_DH_KEY 166 -#define SSL_R_MISSING_EXPORT_TMP_RSA_KEY 167 -#define SSL_R_MISSING_RSA_CERTIFICATE 168 -#define SSL_R_MISSING_RSA_ENCRYPTING_CERT 169 -#define SSL_R_MISSING_RSA_SIGNING_CERT 170 -#define SSL_R_MISSING_TMP_DH_KEY 171 -#define SSL_R_MISSING_TMP_ECDH_KEY 311 -#define SSL_R_MISSING_TMP_RSA_KEY 172 -#define SSL_R_MISSING_TMP_RSA_PKEY 173 -#define SSL_R_MISSING_VERIFY_MESSAGE 174 -#define SSL_R_NON_SSLV2_INITIAL_PACKET 175 -#define SSL_R_NO_CERTIFICATES_RETURNED 176 -#define SSL_R_NO_CERTIFICATE_ASSIGNED 177 -#define SSL_R_NO_CERTIFICATE_RETURNED 178 -#define SSL_R_NO_CERTIFICATE_SET 179 -#define SSL_R_NO_CERTIFICATE_SPECIFIED 180 -#define SSL_R_NO_CIPHERS_AVAILABLE 181 -#define SSL_R_NO_CIPHERS_PASSED 182 -#define SSL_R_NO_CIPHERS_SPECIFIED 183 -#define SSL_R_NO_CIPHER_LIST 184 -#define SSL_R_NO_CIPHER_MATCH 185 -#define SSL_R_NO_CLIENT_CERT_RECEIVED 186 -#define SSL_R_NO_COMPRESSION_SPECIFIED 187 -#define SSL_R_NO_METHOD_SPECIFIED 188 -#define SSL_R_NO_PRIVATEKEY 189 -#define SSL_R_NO_PRIVATE_KEY_ASSIGNED 190 -#define SSL_R_NO_PROTOCOLS_AVAILABLE 191 -#define SSL_R_NO_PUBLICKEY 192 -#define SSL_R_NO_SHARED_CIPHER 193 -#define SSL_R_NO_VERIFY_CALLBACK 194 -#define SSL_R_NULL_SSL_CTX 195 -#define SSL_R_NULL_SSL_METHOD_PASSED 196 -#define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 197 -#define SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE 297 -#define SSL_R_PACKET_LENGTH_TOO_LONG 198 -#define SSL_R_PATH_TOO_LONG 270 -#define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 199 -#define SSL_R_PEER_ERROR 200 -#define SSL_R_PEER_ERROR_CERTIFICATE 201 -#define SSL_R_PEER_ERROR_NO_CERTIFICATE 202 -#define SSL_R_PEER_ERROR_NO_CIPHER 203 -#define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 204 -#define SSL_R_PRE_MAC_LENGTH_TOO_LONG 205 -#define SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS 206 -#define SSL_R_PROTOCOL_IS_SHUTDOWN 207 -#define SSL_R_PUBLIC_KEY_ENCRYPT_ERROR 208 -#define SSL_R_PUBLIC_KEY_IS_NOT_RSA 209 -#define SSL_R_PUBLIC_KEY_NOT_RSA 210 -#define SSL_R_READ_BIO_NOT_SET 211 -#define SSL_R_READ_TIMEOUT_EXPIRED 312 -#define SSL_R_READ_WRONG_PACKET_TYPE 212 -#define SSL_R_RECORD_LENGTH_MISMATCH 213 -#define SSL_R_RECORD_TOO_LARGE 214 -#define SSL_R_RECORD_TOO_SMALL 298 -#define SSL_R_REQUIRED_CIPHER_MISSING 215 -#define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO 216 -#define SSL_R_REUSE_CERT_TYPE_NOT_ZERO 217 -#define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO 218 -#define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED 277 -#define SSL_R_SHORT_READ 219 -#define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 220 -#define SSL_R_SSL23_DOING_SESSION_ID_REUSE 221 -#define SSL_R_SSL2_CONNECTION_ID_TOO_LONG 299 -#define SSL_R_SSL3_SESSION_ID_TOO_LONG 300 -#define SSL_R_SSL3_SESSION_ID_TOO_SHORT 222 -#define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 -#define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 -#define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 -#define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044 -#define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046 -#define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030 -#define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 -#define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 -#define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 -#define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 -#define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 -#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 228 -#define SSL_R_SSL_HANDSHAKE_FAILURE 229 -#define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 230 -#define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED 301 -#define SSL_R_SSL_SESSION_ID_CONFLICT 302 -#define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273 -#define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH 303 -#define SSL_R_SSL_SESSION_ID_IS_DIFFERENT 231 -#define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 -#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 -#define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021 -#define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 -#define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060 -#define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 -#define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 -#define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 -#define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 -#define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022 -#define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048 -#define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 -#define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 232 -#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233 -#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 234 -#define SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER 235 -#define SSL_R_UNABLE_TO_DECODE_DH_CERTS 236 -#define SSL_R_UNABLE_TO_DECODE_ECDH_CERTS 313 -#define SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY 237 -#define SSL_R_UNABLE_TO_FIND_DH_PARAMETERS 238 -#define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS 314 -#define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS 239 -#define SSL_R_UNABLE_TO_FIND_SSL_METHOD 240 -#define SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES 241 -#define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES 242 -#define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES 243 -#define SSL_R_UNEXPECTED_MESSAGE 244 -#define SSL_R_UNEXPECTED_RECORD 245 -#define SSL_R_UNINITIALIZED 276 -#define SSL_R_UNKNOWN_ALERT_TYPE 246 -#define SSL_R_UNKNOWN_CERTIFICATE_TYPE 247 -#define SSL_R_UNKNOWN_CIPHER_RETURNED 248 -#define SSL_R_UNKNOWN_CIPHER_TYPE 249 -#define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 250 -#define SSL_R_UNKNOWN_PKEY_TYPE 251 -#define SSL_R_UNKNOWN_PROTOCOL 252 -#define SSL_R_UNKNOWN_REMOTE_ERROR_TYPE 253 -#define SSL_R_UNKNOWN_SSL_VERSION 254 -#define SSL_R_UNKNOWN_STATE 255 -#define SSL_R_UNSUPPORTED_CIPHER 256 -#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257 -#define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE 315 -#define SSL_R_UNSUPPORTED_PROTOCOL 258 -#define SSL_R_UNSUPPORTED_SSL_VERSION 259 -#define SSL_R_WRITE_BIO_NOT_SET 260 -#define SSL_R_WRONG_CIPHER_RETURNED 261 -#define SSL_R_WRONG_MESSAGE_TYPE 262 -#define SSL_R_WRONG_NUMBER_OF_KEY_BITS 263 -#define SSL_R_WRONG_SIGNATURE_LENGTH 264 -#define SSL_R_WRONG_SIGNATURE_SIZE 265 -#define SSL_R_WRONG_SSL_VERSION 266 -#define SSL_R_WRONG_VERSION_NUMBER 267 -#define SSL_R_X509_LIB 268 -#define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS 269 - -#ifdef __cplusplus -} -#endif -#endif +/* ssl/ssl.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECC cipher suite support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_SSL_H +#define HEADER_SSL_H + +#include + +#ifndef OPENSSL_NO_COMP +#include +#endif +#ifndef OPENSSL_NO_BIO +#include +#endif +#ifndef OPENSSL_NO_DEPRECATED +#ifndef OPENSSL_NO_X509 +#include +#endif +#include +#include +#include +#endif +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* SSLeay version number for ASN.1 encoding of the session information */ +/* Version 0 - initial version + * Version 1 - added the optional peer certificate + */ +#define SSL_SESSION_ASN1_VERSION 0x0001 + +/* text strings for the ciphers */ +#define SSL_TXT_NULL_WITH_MD5 SSL2_TXT_NULL_WITH_MD5 +#define SSL_TXT_RC4_128_WITH_MD5 SSL2_TXT_RC4_128_WITH_MD5 +#define SSL_TXT_RC4_128_EXPORT40_WITH_MD5 SSL2_TXT_RC4_128_EXPORT40_WITH_MD5 +#define SSL_TXT_RC2_128_CBC_WITH_MD5 SSL2_TXT_RC2_128_CBC_WITH_MD5 +#define SSL_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 +#define SSL_TXT_IDEA_128_CBC_WITH_MD5 SSL2_TXT_IDEA_128_CBC_WITH_MD5 +#define SSL_TXT_DES_64_CBC_WITH_MD5 SSL2_TXT_DES_64_CBC_WITH_MD5 +#define SSL_TXT_DES_64_CBC_WITH_SHA SSL2_TXT_DES_64_CBC_WITH_SHA +#define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 +#define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA + +/* VRS Additional Kerberos5 entries + */ +#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA +#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA +#define SSL_TXT_KRB5_RC4_128_SHA SSL3_TXT_KRB5_RC4_128_SHA +#define SSL_TXT_KRB5_IDEA_128_CBC_SHA SSL3_TXT_KRB5_IDEA_128_CBC_SHA +#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5 +#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5 +#define SSL_TXT_KRB5_RC4_128_MD5 SSL3_TXT_KRB5_RC4_128_MD5 +#define SSL_TXT_KRB5_IDEA_128_CBC_MD5 SSL3_TXT_KRB5_IDEA_128_CBC_MD5 + +#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA +#define SSL_TXT_KRB5_RC2_40_CBC_SHA SSL3_TXT_KRB5_RC2_40_CBC_SHA +#define SSL_TXT_KRB5_RC4_40_SHA SSL3_TXT_KRB5_RC4_40_SHA +#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5 +#define SSL_TXT_KRB5_RC2_40_CBC_MD5 SSL3_TXT_KRB5_RC2_40_CBC_MD5 +#define SSL_TXT_KRB5_RC4_40_MD5 SSL3_TXT_KRB5_RC4_40_MD5 + +#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA +#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5 +#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA +#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5 +#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA +#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5 +#define SSL_MAX_KRB5_PRINCIPAL_LENGTH 256 + +#define SSL_MAX_SSL_SESSION_ID_LENGTH 32 +#define SSL_MAX_SID_CTX_LENGTH 32 + +#define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES (512/8) +#define SSL_MAX_KEY_ARG_LENGTH 8 +#define SSL_MAX_MASTER_KEY_LENGTH 48 + +/* These are used to specify which ciphers to use and not to use */ +#define SSL_TXT_LOW "LOW" +#define SSL_TXT_MEDIUM "MEDIUM" +#define SSL_TXT_HIGH "HIGH" +#define SSL_TXT_kFZA "kFZA" +#define SSL_TXT_aFZA "aFZA" +#define SSL_TXT_eFZA "eFZA" +#define SSL_TXT_FZA "FZA" + +#define SSL_TXT_aNULL "aNULL" +#define SSL_TXT_eNULL "eNULL" +#define SSL_TXT_NULL "NULL" + +#define SSL_TXT_kKRB5 "kKRB5" +#define SSL_TXT_aKRB5 "aKRB5" +#define SSL_TXT_KRB5 "KRB5" + +#define SSL_TXT_kRSA "kRSA" +#define SSL_TXT_kDHr "kDHr" +#define SSL_TXT_kDHd "kDHd" +#define SSL_TXT_kEDH "kEDH" +#define SSL_TXT_aRSA "aRSA" +#define SSL_TXT_aDSS "aDSS" +#define SSL_TXT_aDH "aDH" +#define SSL_TXT_DSS "DSS" +#define SSL_TXT_DH "DH" +#define SSL_TXT_EDH "EDH" +#define SSL_TXT_ADH "ADH" +#define SSL_TXT_RSA "RSA" +#define SSL_TXT_DES "DES" +#define SSL_TXT_3DES "3DES" +#define SSL_TXT_RC4 "RC4" +#define SSL_TXT_RC2 "RC2" +#define SSL_TXT_IDEA "IDEA" +#define SSL_TXT_AES "AES" +#define SSL_TXT_MD5 "MD5" +#define SSL_TXT_SHA1 "SHA1" +#define SSL_TXT_SHA "SHA" +#define SSL_TXT_EXP "EXP" +#define SSL_TXT_EXPORT "EXPORT" +#define SSL_TXT_EXP40 "EXPORT40" +#define SSL_TXT_EXP56 "EXPORT56" +#define SSL_TXT_SSLV2 "SSLv2" +#define SSL_TXT_SSLV3 "SSLv3" +#define SSL_TXT_TLSV1 "TLSv1" +#define SSL_TXT_ALL "ALL" +#define SSL_TXT_ECC "ECCdraft" /* ECC ciphersuites are not yet official */ + +/* + * COMPLEMENTOF* definitions. These identifiers are used to (de-select) + * ciphers normally not being used. + * Example: "RC4" will activate all ciphers using RC4 including ciphers + * without authentication, which would normally disabled by DEFAULT (due + * the "!ADH" being part of default). Therefore "RC4:!COMPLEMENTOFDEFAULT" + * will make sure that it is also disabled in the specific selection. + * COMPLEMENTOF* identifiers are portable between version, as adjustments + * to the default cipher setup will also be included here. + * + * COMPLEMENTOFDEFAULT does not experience the same special treatment that + * DEFAULT gets, as only selection is being done and no sorting as needed + * for DEFAULT. + */ +#define SSL_TXT_CMPALL "COMPLEMENTOFALL" +#define SSL_TXT_CMPDEF "COMPLEMENTOFDEFAULT" + +/* The following cipher list is used by default. + * It also is substituted when an application-defined cipher list string + * starts with 'DEFAULT'. */ +#define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:+RC4:@STRENGTH" /* low priority for RC4 */ + +/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ +#define SSL_SENT_SHUTDOWN 1 +#define SSL_RECEIVED_SHUTDOWN 2 + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if (defined(OPENSSL_NO_RSA) || defined(OPENSSL_NO_MD5)) && !defined(OPENSSL_NO_SSL2) +#define OPENSSL_NO_SSL2 +#endif + +#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 +#define SSL_FILETYPE_PEM X509_FILETYPE_PEM + +/* This is needed to stop compilers complaining about the + * 'struct ssl_st *' function parameters used to prototype callbacks + * in SSL_CTX. */ +typedef struct ssl_st *ssl_crock_st; + +/* used to hold info on the particular ciphers used */ +typedef struct ssl_cipher_st + { + int valid; + const char *name; /* text name */ + unsigned long id; /* id, 4 bytes, first is version */ + unsigned long algorithms; /* what ciphers are used */ + unsigned long algo_strength; /* strength and export flags */ + unsigned long algorithm2; /* Extra flags */ + int strength_bits; /* Number of bits really used */ + int alg_bits; /* Number of bits for algorithm */ + unsigned long mask; /* used for matching */ + unsigned long mask_strength; /* also used for matching */ + } SSL_CIPHER; + +DECLARE_STACK_OF(SSL_CIPHER) + +typedef struct ssl_st SSL; +typedef struct ssl_ctx_st SSL_CTX; + +/* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */ +typedef struct ssl_method_st + { + int version; + int (*ssl_new)(SSL *s); + void (*ssl_clear)(SSL *s); + void (*ssl_free)(SSL *s); + int (*ssl_accept)(SSL *s); + int (*ssl_connect)(SSL *s); + int (*ssl_read)(SSL *s,void *buf,int len); + int (*ssl_peek)(SSL *s,void *buf,int len); + int (*ssl_write)(SSL *s,const void *buf,int len); + int (*ssl_shutdown)(SSL *s); + int (*ssl_renegotiate)(SSL *s); + int (*ssl_renegotiate_check)(SSL *s); + long (*ssl_get_message)(SSL *s, int st1, int stn, int mt, long + max, int *ok); + int (*ssl_read_bytes)(SSL *s, int type, unsigned char *buf, int len, + int peek); + int (*ssl_write_bytes)(SSL *s, int type, const void *buf_, int len); + int (*ssl_dispatch_alert)(SSL *s); + long (*ssl_ctrl)(SSL *s,int cmd,long larg,void *parg); + long (*ssl_ctx_ctrl)(SSL_CTX *ctx,int cmd,long larg,void *parg); + SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr); + int (*put_cipher_by_char)(const SSL_CIPHER *cipher,unsigned char *ptr); + int (*ssl_pending)(const SSL *s); + int (*num_ciphers)(void); + SSL_CIPHER *(*get_cipher)(unsigned ncipher); + struct ssl_method_st *(*get_ssl_method)(int version); + long (*get_timeout)(void); + struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */ + int (*ssl_version)(void); + long (*ssl_callback_ctrl)(SSL *s, int cb_id, void (*fp)(void)); + long (*ssl_ctx_callback_ctrl)(SSL_CTX *s, int cb_id, void (*fp)(void)); + } SSL_METHOD; + +/* Lets make this into an ASN.1 type structure as follows + * SSL_SESSION_ID ::= SEQUENCE { + * version INTEGER, -- structure version number + * SSLversion INTEGER, -- SSL version number + * Cipher OCTET_STRING, -- the 3 byte cipher ID + * Session_ID OCTET_STRING, -- the Session ID + * Master_key OCTET_STRING, -- the master key + * KRB5_principal OCTET_STRING -- optional Kerberos principal + * Key_Arg [ 0 ] IMPLICIT OCTET_STRING, -- the optional Key argument + * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time + * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds + * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate + * Session_ID_context [ 4 ] EXPLICIT OCTET_STRING, -- the Session ID context + * Verify_result [ 5 ] EXPLICIT INTEGER -- X509_V_... code for `Peer' + * Compression [6] IMPLICIT ASN1_OBJECT -- compression OID XXXXX + * } + * Look in ssl/ssl_asn1.c for more details + * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-). + */ +typedef struct ssl_session_st + { + int ssl_version; /* what ssl version session info is + * being kept in here? */ + + /* only really used in SSLv2 */ + unsigned int key_arg_length; + unsigned char key_arg[SSL_MAX_KEY_ARG_LENGTH]; + int master_key_length; + unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH]; + /* session_id - valid? */ + unsigned int session_id_length; + unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; + /* this is used to determine whether the session is being reused in + * the appropriate context. It is up to the application to set this, + * via SSL_new */ + unsigned int sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; + +#ifndef OPENSSL_NO_KRB5 + unsigned int krb5_client_princ_len; + unsigned char krb5_client_princ[SSL_MAX_KRB5_PRINCIPAL_LENGTH]; +#endif /* OPENSSL_NO_KRB5 */ + + int not_resumable; + + /* The cert is the certificate used to establish this connection */ + struct sess_cert_st /* SESS_CERT */ *sess_cert; + + /* This is the cert for the other end. + * On clients, it will be the same as sess_cert->peer_key->x509 + * (the latter is not enough as sess_cert is not retained + * in the external representation of sessions, see ssl_asn1.c). */ + X509 *peer; + /* when app_verify_callback accepts a session where the peer's certificate + * is not ok, we must remember the error for session reuse: */ + long verify_result; /* only for servers */ + + int references; + long timeout; + long time; + + int compress_meth; /* Need to lookup the method */ + + SSL_CIPHER *cipher; + unsigned long cipher_id; /* when ASN.1 loaded, this + * needs to be used to load + * the 'cipher' structure */ + + STACK_OF(SSL_CIPHER) *ciphers; /* shared ciphers? */ + + CRYPTO_EX_DATA ex_data; /* application specific data */ + + /* These are used to make removal of session-ids more + * efficient and to implement a maximum cache size. */ + struct ssl_session_st *prev,*next; + } SSL_SESSION; + + +#define SSL_OP_MICROSOFT_SESS_ID_BUG 0x00000001L +#define SSL_OP_NETSCAPE_CHALLENGE_BUG 0x00000002L +#define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0x00000008L +#define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0x00000010L +#define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0x00000020L +#define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x00000040L /* no effect since 0.9.7h and 0.9.8b */ +#define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x00000080L +#define SSL_OP_TLS_D5_BUG 0x00000100L +#define SSL_OP_TLS_BLOCK_PADDING_BUG 0x00000200L + +/* Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added + * in OpenSSL 0.9.6d. Usually (depending on the application protocol) + * the workaround is not needed. Unfortunately some broken SSL/TLS + * implementations cannot handle it at all, which is why we include + * it in SSL_OP_ALL. */ +#define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0x00000800L /* added in 0.9.6e */ + +/* SSL_OP_ALL: various bug workarounds that should be rather harmless. + * This used to be 0x000FFFFFL before 0.9.7. */ +#define SSL_OP_ALL 0x00000FFFL + +/* DTLS options */ +#define SSL_OP_NO_QUERY_MTU 0x00001000L +/* Turn on Cookie Exchange (on relevant for servers) */ +#define SSL_OP_COOKIE_EXCHANGE 0x00002000L + +/* As server, disallow session resumption on renegotiation */ +#define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0x00010000L +/* If set, always create a new key when using tmp_ecdh parameters */ +#define SSL_OP_SINGLE_ECDH_USE 0x00080000L +/* If set, always create a new key when using tmp_dh parameters */ +#define SSL_OP_SINGLE_DH_USE 0x00100000L +/* Set to always use the tmp_rsa key when doing RSA operations, + * even when this violates protocol specs */ +#define SSL_OP_EPHEMERAL_RSA 0x00200000L +/* Set on servers to choose the cipher according to the server's + * preferences */ +#define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000L +/* If set, a server will allow a client to issue a SSLv3.0 version number + * as latest version supported in the premaster secret, even when TLSv1.0 + * (version 3.1) was announced in the client hello. Normally this is + * forbidden to prevent version rollback attacks. */ +#define SSL_OP_TLS_ROLLBACK_BUG 0x00800000L + +#define SSL_OP_NO_SSLv2 0x01000000L +#define SSL_OP_NO_SSLv3 0x02000000L +#define SSL_OP_NO_TLSv1 0x04000000L + +/* The next flag deliberately changes the ciphertest, this is a check + * for the PKCS#1 attack */ +#define SSL_OP_PKCS1_CHECK_1 0x08000000L +#define SSL_OP_PKCS1_CHECK_2 0x10000000L +#define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L +#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x40000000L + + +/* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success + * when just a single record has been written): */ +#define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001L +/* Make it possible to retry SSL_write() with changed buffer location + * (buffer contents must stay the same!); this is not the default to avoid + * the misconception that non-blocking SSL_write() behaves like + * non-blocking write(): */ +#define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002L +/* Never bother the application with retries if the transport + * is blocking: */ +#define SSL_MODE_AUTO_RETRY 0x00000004L +/* Don't attempt to automatically build certificate chain */ +#define SSL_MODE_NO_AUTO_CHAIN 0x00000008L + + +/* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, + * they cannot be used to clear bits. */ + +#define SSL_CTX_set_options(ctx,op) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL) +#define SSL_CTX_get_options(ctx) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,0,NULL) +#define SSL_set_options(ssl,op) \ + SSL_ctrl((ssl),SSL_CTRL_OPTIONS,(op),NULL) +#define SSL_get_options(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_OPTIONS,0,NULL) + +#define SSL_CTX_set_mode(ctx,op) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL) +#define SSL_CTX_get_mode(ctx) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL) +#define SSL_set_mode(ssl,op) \ + SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL) +#define SSL_get_mode(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL) +#define SSL_set_mtu(ssl, mtu) \ + SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL) + + +void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); +void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); +#define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) +#define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) + + + +#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32) +#define SSL_MAX_CERT_LIST_DEFAULT 1024*30 /* 30k max cert list :-) */ +#else +#define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */ +#endif + +#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20) + +/* This callback type is used inside SSL_CTX, SSL, and in the functions that set + * them. It is used to override the generation of SSL/TLS session IDs in a + * server. Return value should be zero on an error, non-zero to proceed. Also, + * callbacks should themselves check if the id they generate is unique otherwise + * the SSL handshake will fail with an error - callbacks can do this using the + * 'ssl' value they're passed by; + * SSL_has_matching_session_id(ssl, id, *id_len) + * The length value passed in is set at the maximum size the session ID can be. + * In SSLv2 this is 16 bytes, whereas SSLv3/TLSv1 it is 32 bytes. The callback + * can alter this length to be less if desired, but under SSLv2 session IDs are + * supposed to be fixed at 16 bytes so the id will be padded after the callback + * returns in this case. It is also an error for the callback to set the size to + * zero. */ +typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id, + unsigned int *id_len); + +typedef struct ssl_comp_st + { + int id; + const char *name; +#ifndef OPENSSL_NO_COMP + COMP_METHOD *method; +#else + char *method; +#endif + } SSL_COMP; + +DECLARE_STACK_OF(SSL_COMP) + +struct ssl_ctx_st + { + SSL_METHOD *method; + + STACK_OF(SSL_CIPHER) *cipher_list; + /* same as above but sorted for lookup */ + STACK_OF(SSL_CIPHER) *cipher_list_by_id; + + struct x509_store_st /* X509_STORE */ *cert_store; + struct lhash_st /* LHASH */ *sessions; /* a set of SSL_SESSIONs */ + /* Most session-ids that will be cached, default is + * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. */ + unsigned long session_cache_size; + struct ssl_session_st *session_cache_head; + struct ssl_session_st *session_cache_tail; + + /* This can have one of 2 values, ored together, + * SSL_SESS_CACHE_CLIENT, + * SSL_SESS_CACHE_SERVER, + * Default is SSL_SESSION_CACHE_SERVER, which means only + * SSL_accept which cache SSL_SESSIONS. */ + int session_cache_mode; + + /* If timeout is not 0, it is the default timeout value set + * when SSL_new() is called. This has been put in to make + * life easier to set things up */ + long session_timeout; + + /* If this callback is not null, it will be called each + * time a session id is added to the cache. If this function + * returns 1, it means that the callback will do a + * SSL_SESSION_free() when it has finished using it. Otherwise, + * on 0, it means the callback has finished with it. + * If remove_session_cb is not null, it will be called when + * a session-id is removed from the cache. After the call, + * OpenSSL will SSL_SESSION_free() it. */ + int (*new_session_cb)(struct ssl_st *ssl,SSL_SESSION *sess); + void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess); + SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, + unsigned char *data,int len,int *copy); + + struct + { + int sess_connect; /* SSL new conn - started */ + int sess_connect_renegotiate;/* SSL reneg - requested */ + int sess_connect_good; /* SSL new conne/reneg - finished */ + int sess_accept; /* SSL new accept - started */ + int sess_accept_renegotiate;/* SSL reneg - requested */ + int sess_accept_good; /* SSL accept/reneg - finished */ + int sess_miss; /* session lookup misses */ + int sess_timeout; /* reuse attempt on timeouted session */ + int sess_cache_full; /* session removed due to full cache */ + int sess_hit; /* session reuse actually done */ + int sess_cb_hit; /* session-id that was not + * in the cache was + * passed back via the callback. This + * indicates that the application is + * supplying session-id's from other + * processes - spooky :-) */ + } stats; + + int references; + + /* if defined, these override the X509_verify_cert() calls */ + int (*app_verify_callback)(X509_STORE_CTX *, void *); + void *app_verify_arg; + /* before OpenSSL 0.9.7, 'app_verify_arg' was ignored + * ('app_verify_callback' was called with just one argument) */ + + /* Default password callback. */ + pem_password_cb *default_passwd_callback; + + /* Default password callback user data. */ + void *default_passwd_callback_userdata; + + /* get client cert callback */ + int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey); + + /* cookie generate callback */ + int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie, + unsigned int *cookie_len); + + /* verify cookie callback */ + int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie, + unsigned int cookie_len); + + CRYPTO_EX_DATA ex_data; + + const EVP_MD *rsa_md5;/* For SSLv2 - name is 'ssl2-md5' */ + const EVP_MD *md5; /* For SSLv3/TLSv1 'ssl3-md5' */ + const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */ + + STACK_OF(X509) *extra_certs; + STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */ + + + /* Default values used when no per-SSL value is defined follow */ + + void (*info_callback)(const SSL *ssl,int type,int val); /* used if SSL's info_callback is NULL */ + + /* what we put in client cert requests */ + STACK_OF(X509_NAME) *client_CA; + + + /* Default values to use in SSL structures follow (these are copied by SSL_new) */ + + unsigned long options; + unsigned long mode; + long max_cert_list; + + struct cert_st /* CERT */ *cert; + int read_ahead; + + /* callback that allows applications to peek at protocol messages */ + void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg); + void *msg_callback_arg; + + int verify_mode; + unsigned int sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; + int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx); /* called 'verify_callback' in the SSL */ + + /* Default generate session ID callback. */ + GEN_SESSION_CB generate_session_id; + + X509_VERIFY_PARAM *param; + +#if 0 + int purpose; /* Purpose setting */ + int trust; /* Trust setting */ +#endif + + int quiet_shutdown; + }; + +#define SSL_SESS_CACHE_OFF 0x0000 +#define SSL_SESS_CACHE_CLIENT 0x0001 +#define SSL_SESS_CACHE_SERVER 0x0002 +#define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER) +#define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080 +/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */ +#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 +#define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200 +#define SSL_SESS_CACHE_NO_INTERNAL \ + (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE) + + struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx); +#define SSL_CTX_sess_number(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL) +#define SSL_CTX_sess_connect(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL) +#define SSL_CTX_sess_connect_good(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL) +#define SSL_CTX_sess_connect_renegotiate(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL) +#define SSL_CTX_sess_accept(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL) +#define SSL_CTX_sess_accept_renegotiate(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL) +#define SSL_CTX_sess_accept_good(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL) +#define SSL_CTX_sess_hits(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL) +#define SSL_CTX_sess_cb_hits(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL) +#define SSL_CTX_sess_misses(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL) +#define SSL_CTX_sess_timeouts(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL) +#define SSL_CTX_sess_cache_full(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL) + +#define SSL_CTX_sess_set_new_cb(ctx,cb) ((ctx)->new_session_cb=(cb)) +#define SSL_CTX_sess_get_new_cb(ctx) ((ctx)->new_session_cb) +#define SSL_CTX_sess_set_remove_cb(ctx,cb) ((ctx)->remove_session_cb=(cb)) +#define SSL_CTX_sess_get_remove_cb(ctx) ((ctx)->remove_session_cb) +#define SSL_CTX_sess_set_get_cb(ctx,cb) ((ctx)->get_session_cb=(cb)) +#define SSL_CTX_sess_get_get_cb(ctx) ((ctx)->get_session_cb) +#define SSL_CTX_set_info_callback(ctx,cb) ((ctx)->info_callback=(cb)) +#define SSL_CTX_get_info_callback(ctx) ((ctx)->info_callback) +#define SSL_CTX_set_client_cert_cb(ctx,cb) ((ctx)->client_cert_cb=(cb)) +#define SSL_CTX_get_client_cert_cb(ctx) ((ctx)->client_cert_cb) +#define SSL_CTX_set_cookie_generate_cb(ctx,cb) ((ctx)->app_gen_cookie_cb=(cb)) +#define SSL_CTX_set_cookie_verify_cb(ctx,cb) ((ctx)->app_verify_cookie_cb=(cb)) + +#define SSL_NOTHING 1 +#define SSL_WRITING 2 +#define SSL_READING 3 +#define SSL_X509_LOOKUP 4 + +/* These will only be used when doing non-blocking IO */ +#define SSL_want_nothing(s) (SSL_want(s) == SSL_NOTHING) +#define SSL_want_read(s) (SSL_want(s) == SSL_READING) +#define SSL_want_write(s) (SSL_want(s) == SSL_WRITING) +#define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP) + +struct ssl_st + { + /* protocol version + * (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION, DTLS1_VERSION) + */ + int version; + int type; /* SSL_ST_CONNECT or SSL_ST_ACCEPT */ + + SSL_METHOD *method; /* SSLv3 */ + + /* There are 2 BIO's even though they are normally both the + * same. This is so data can be read and written to different + * handlers */ + +#ifndef OPENSSL_NO_BIO + BIO *rbio; /* used by SSL_read */ + BIO *wbio; /* used by SSL_write */ + BIO *bbio; /* used during session-id reuse to concatenate + * messages */ +#else + char *rbio; /* used by SSL_read */ + char *wbio; /* used by SSL_write */ + char *bbio; +#endif + /* This holds a variable that indicates what we were doing + * when a 0 or -1 is returned. This is needed for + * non-blocking IO so we know what request needs re-doing when + * in SSL_accept or SSL_connect */ + int rwstate; + + /* true when we are actually in SSL_accept() or SSL_connect() */ + int in_handshake; + int (*handshake_func)(SSL *); + + /* Imagine that here's a boolean member "init" that is + * switched as soon as SSL_set_{accept/connect}_state + * is called for the first time, so that "state" and + * "handshake_func" are properly initialized. But as + * handshake_func is == 0 until then, we use this + * test instead of an "init" member. + */ + + int server; /* are we the server side? - mostly used by SSL_clear*/ + + int new_session;/* 1 if we are to use a new session. + * 2 if we are a server and are inside a handshake + * (i.e. not just sending a HelloRequest) + * NB: For servers, the 'new' session may actually be a previously + * cached session or even the previous session unless + * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */ + int quiet_shutdown;/* don't send shutdown packets */ + int shutdown; /* we have shut things down, 0x01 sent, 0x02 + * for received */ + int state; /* where we are */ + int rstate; /* where we are when reading */ + + BUF_MEM *init_buf; /* buffer used during init */ + void *init_msg; /* pointer to handshake message body, set by ssl3_get_message() */ + int init_num; /* amount read/written */ + int init_off; /* amount read/written */ + + /* used internally to point at a raw packet */ + unsigned char *packet; + unsigned int packet_length; + + struct ssl2_state_st *s2; /* SSLv2 variables */ + struct ssl3_state_st *s3; /* SSLv3 variables */ + struct dtls1_state_st *d1; /* DTLSv1 variables */ + + int read_ahead; /* Read as many input bytes as possible + * (for non-blocking reads) */ + + /* callback that allows applications to peek at protocol messages */ + void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg); + void *msg_callback_arg; + + int hit; /* reusing a previous session */ + + X509_VERIFY_PARAM *param; + +#if 0 + int purpose; /* Purpose setting */ + int trust; /* Trust setting */ +#endif + + /* crypto */ + STACK_OF(SSL_CIPHER) *cipher_list; + STACK_OF(SSL_CIPHER) *cipher_list_by_id; + + /* These are the ones being used, the ones in SSL_SESSION are + * the ones to be 'copied' into these ones */ + + EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ + const EVP_MD *read_hash; /* used for mac generation */ +#ifndef OPENSSL_NO_COMP + COMP_CTX *expand; /* uncompress */ +#else + char *expand; +#endif + + EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ + const EVP_MD *write_hash; /* used for mac generation */ +#ifndef OPENSSL_NO_COMP + COMP_CTX *compress; /* compression */ +#else + char *compress; +#endif + + /* session info */ + + /* client cert? */ + /* This is used to hold the server certificate used */ + struct cert_st /* CERT */ *cert; + + /* the session_id_context is used to ensure sessions are only reused + * in the appropriate context */ + unsigned int sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; + + /* This can also be in the session once a session is established */ + SSL_SESSION *session; + + /* Default generate session ID callback. */ + GEN_SESSION_CB generate_session_id; + + /* Used in SSL2 and SSL3 */ + int verify_mode; /* 0 don't care about verify failure. + * 1 fail if verify fails */ + int (*verify_callback)(int ok,X509_STORE_CTX *ctx); /* fail if callback returns 0 */ + + void (*info_callback)(const SSL *ssl,int type,int val); /* optional informational callback */ + + int error; /* error bytes to be written */ + int error_code; /* actual code */ + +#ifndef OPENSSL_NO_KRB5 + KSSL_CTX *kssl_ctx; /* Kerberos 5 context */ +#endif /* OPENSSL_NO_KRB5 */ + + SSL_CTX *ctx; + /* set this flag to 1 and a sleep(1) is put into all SSL_read() + * and SSL_write() calls, good for nbio debuging :-) */ + int debug; + + /* extra application data */ + long verify_result; + CRYPTO_EX_DATA ex_data; + + /* for server side, keep the list of CA_dn we can use */ + STACK_OF(X509_NAME) *client_CA; + + int references; + unsigned long options; /* protocol behaviour */ + unsigned long mode; /* API behaviour */ + long max_cert_list; + int first_packet; + int client_version; /* what was passed, used for + * SSLv3/TLS rollback check */ + }; + +#ifdef __cplusplus +} +#endif + +#include +#include +#include /* This is mostly sslv3 with a few tweaks */ +#include /* Datagram TLS */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* compatibility */ +#define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)arg)) +#define SSL_get_app_data(s) (SSL_get_ex_data(s,0)) +#define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0,(char *)a)) +#define SSL_SESSION_get_app_data(s) (SSL_SESSION_get_ex_data(s,0)) +#define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx,0)) +#define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg)) + +/* The following are the possible values for ssl->state are are + * used to indicate where we are up to in the SSL connection establishment. + * The macros that follow are about the only things you should need to use + * and even then, only when using non-blocking IO. + * It can also be useful to work out where you were when the connection + * failed */ + +#define SSL_ST_CONNECT 0x1000 +#define SSL_ST_ACCEPT 0x2000 +#define SSL_ST_MASK 0x0FFF +#define SSL_ST_INIT (SSL_ST_CONNECT|SSL_ST_ACCEPT) +#define SSL_ST_BEFORE 0x4000 +#define SSL_ST_OK 0x03 +#define SSL_ST_RENEGOTIATE (0x04|SSL_ST_INIT) + +#define SSL_CB_LOOP 0x01 +#define SSL_CB_EXIT 0x02 +#define SSL_CB_READ 0x04 +#define SSL_CB_WRITE 0x08 +#define SSL_CB_ALERT 0x4000 /* used in callback */ +#define SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ) +#define SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE) +#define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP) +#define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT) +#define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP) +#define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT) +#define SSL_CB_HANDSHAKE_START 0x10 +#define SSL_CB_HANDSHAKE_DONE 0x20 + +/* Is the SSL_connection established? */ +#define SSL_get_state(a) SSL_state(a) +#define SSL_is_init_finished(a) (SSL_state(a) == SSL_ST_OK) +#define SSL_in_init(a) (SSL_state(a)&SSL_ST_INIT) +#define SSL_in_before(a) (SSL_state(a)&SSL_ST_BEFORE) +#define SSL_in_connect_init(a) (SSL_state(a)&SSL_ST_CONNECT) +#define SSL_in_accept_init(a) (SSL_state(a)&SSL_ST_ACCEPT) + +/* The following 2 states are kept in ssl->rstate when reads fail, + * you should not need these */ +#define SSL_ST_READ_HEADER 0xF0 +#define SSL_ST_READ_BODY 0xF1 +#define SSL_ST_READ_DONE 0xF2 + +/* Obtain latest Finished message + * -- that we sent (SSL_get_finished) + * -- that we expected from peer (SSL_get_peer_finished). + * Returns length (0 == no Finished so far), copies up to 'count' bytes. */ +size_t SSL_get_finished(const SSL *s, void *buf, size_t count); +size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count); + +/* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options + * are 'ored' with SSL_VERIFY_PEER if they are desired */ +#define SSL_VERIFY_NONE 0x00 +#define SSL_VERIFY_PEER 0x01 +#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 +#define SSL_VERIFY_CLIENT_ONCE 0x04 + +#define OpenSSL_add_ssl_algorithms() SSL_library_init() +#define SSLeay_add_ssl_algorithms() SSL_library_init() + +/* this is for backward compatibility */ +#if 0 /* NEW_SSLEAY */ +#define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c) +#define SSL_set_pref_cipher(c,n) SSL_set_cipher_list(c,n) +#define SSL_add_session(a,b) SSL_CTX_add_session((a),(b)) +#define SSL_remove_session(a,b) SSL_CTX_remove_session((a),(b)) +#define SSL_flush_sessions(a,b) SSL_CTX_flush_sessions((a),(b)) +#endif +/* More backward compatibility */ +#define SSL_get_cipher(s) \ + SSL_CIPHER_get_name(SSL_get_current_cipher(s)) +#define SSL_get_cipher_bits(s,np) \ + SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np) +#define SSL_get_cipher_version(s) \ + SSL_CIPHER_get_version(SSL_get_current_cipher(s)) +#define SSL_get_cipher_name(s) \ + SSL_CIPHER_get_name(SSL_get_current_cipher(s)) +#define SSL_get_time(a) SSL_SESSION_get_time(a) +#define SSL_set_time(a,b) SSL_SESSION_set_time((a),(b)) +#define SSL_get_timeout(a) SSL_SESSION_get_timeout(a) +#define SSL_set_timeout(a,b) SSL_SESSION_set_timeout((a),(b)) + +#if 1 /*SSLEAY_MACROS*/ +#define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id) +#define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id) +#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \ + (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u) +#define PEM_read_bio_SSL_SESSION(bp,x,cb,u) PEM_ASN1_read_bio_of(SSL_SESSION,d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,x,cb,u) +#define PEM_write_SSL_SESSION(fp,x) \ + PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ + PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_SSL_SESSION(bp,x) \ + PEM_ASN1_write_bio_of(SSL_SESSION,i2d_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,x,NULL,NULL,0,NULL,NULL) +#endif + +#define SSL_AD_REASON_OFFSET 1000 +/* These alert types are for SSLv3 and TLSv1 */ +#define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY +#define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE /* fatal */ +#define SSL_AD_BAD_RECORD_MAC SSL3_AD_BAD_RECORD_MAC /* fatal */ +#define SSL_AD_DECRYPTION_FAILED TLS1_AD_DECRYPTION_FAILED +#define SSL_AD_RECORD_OVERFLOW TLS1_AD_RECORD_OVERFLOW +#define SSL_AD_DECOMPRESSION_FAILURE SSL3_AD_DECOMPRESSION_FAILURE/* fatal */ +#define SSL_AD_HANDSHAKE_FAILURE SSL3_AD_HANDSHAKE_FAILURE/* fatal */ +#define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE /* Not for TLS */ +#define SSL_AD_BAD_CERTIFICATE SSL3_AD_BAD_CERTIFICATE +#define SSL_AD_UNSUPPORTED_CERTIFICATE SSL3_AD_UNSUPPORTED_CERTIFICATE +#define SSL_AD_CERTIFICATE_REVOKED SSL3_AD_CERTIFICATE_REVOKED +#define SSL_AD_CERTIFICATE_EXPIRED SSL3_AD_CERTIFICATE_EXPIRED +#define SSL_AD_CERTIFICATE_UNKNOWN SSL3_AD_CERTIFICATE_UNKNOWN +#define SSL_AD_ILLEGAL_PARAMETER SSL3_AD_ILLEGAL_PARAMETER /* fatal */ +#define SSL_AD_UNKNOWN_CA TLS1_AD_UNKNOWN_CA /* fatal */ +#define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED /* fatal */ +#define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR /* fatal */ +#define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR +#define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION/* fatal */ +#define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION /* fatal */ +#define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY/* fatal */ +#define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR /* fatal */ +#define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED +#define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION + +#define SSL_ERROR_NONE 0 +#define SSL_ERROR_SSL 1 +#define SSL_ERROR_WANT_READ 2 +#define SSL_ERROR_WANT_WRITE 3 +#define SSL_ERROR_WANT_X509_LOOKUP 4 +#define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */ +#define SSL_ERROR_ZERO_RETURN 6 +#define SSL_ERROR_WANT_CONNECT 7 +#define SSL_ERROR_WANT_ACCEPT 8 + +#define SSL_CTRL_NEED_TMP_RSA 1 +#define SSL_CTRL_SET_TMP_RSA 2 +#define SSL_CTRL_SET_TMP_DH 3 +#define SSL_CTRL_SET_TMP_ECDH 4 +#define SSL_CTRL_SET_TMP_RSA_CB 5 +#define SSL_CTRL_SET_TMP_DH_CB 6 +#define SSL_CTRL_SET_TMP_ECDH_CB 7 + +#define SSL_CTRL_GET_SESSION_REUSED 8 +#define SSL_CTRL_GET_CLIENT_CERT_REQUEST 9 +#define SSL_CTRL_GET_NUM_RENEGOTIATIONS 10 +#define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 11 +#define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 12 +#define SSL_CTRL_GET_FLAGS 13 +#define SSL_CTRL_EXTRA_CHAIN_CERT 14 + +#define SSL_CTRL_SET_MSG_CALLBACK 15 +#define SSL_CTRL_SET_MSG_CALLBACK_ARG 16 + +/* only applies to datagram connections */ +#define SSL_CTRL_SET_MTU 17 +/* Stats */ +#define SSL_CTRL_SESS_NUMBER 20 +#define SSL_CTRL_SESS_CONNECT 21 +#define SSL_CTRL_SESS_CONNECT_GOOD 22 +#define SSL_CTRL_SESS_CONNECT_RENEGOTIATE 23 +#define SSL_CTRL_SESS_ACCEPT 24 +#define SSL_CTRL_SESS_ACCEPT_GOOD 25 +#define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE 26 +#define SSL_CTRL_SESS_HIT 27 +#define SSL_CTRL_SESS_CB_HIT 28 +#define SSL_CTRL_SESS_MISSES 29 +#define SSL_CTRL_SESS_TIMEOUTS 30 +#define SSL_CTRL_SESS_CACHE_FULL 31 +#define SSL_CTRL_OPTIONS 32 +#define SSL_CTRL_MODE 33 + +#define SSL_CTRL_GET_READ_AHEAD 40 +#define SSL_CTRL_SET_READ_AHEAD 41 +#define SSL_CTRL_SET_SESS_CACHE_SIZE 42 +#define SSL_CTRL_GET_SESS_CACHE_SIZE 43 +#define SSL_CTRL_SET_SESS_CACHE_MODE 44 +#define SSL_CTRL_GET_SESS_CACHE_MODE 45 + +#define SSL_CTRL_GET_MAX_CERT_LIST 50 +#define SSL_CTRL_SET_MAX_CERT_LIST 51 + +#define SSL_session_reused(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL) +#define SSL_num_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL) +#define SSL_clear_num_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL) +#define SSL_total_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL) + +#define SSL_CTX_need_tmp_RSA(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL) +#define SSL_CTX_set_tmp_rsa(ctx,rsa) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa) +#define SSL_CTX_set_tmp_dh(ctx,dh) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)dh) +#define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh) + +#define SSL_need_tmp_RSA(ssl) \ + SSL_ctrl(ssl,SSL_CTRL_NEED_TMP_RSA,0,NULL) +#define SSL_set_tmp_rsa(ssl,rsa) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa) +#define SSL_set_tmp_dh(ssl,dh) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)dh) +#define SSL_set_tmp_ecdh(ssl,ecdh) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh) + +#define SSL_CTX_add_extra_chain_cert(ctx,x509) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509) + +#ifndef OPENSSL_NO_BIO +BIO_METHOD *BIO_f_ssl(void); +BIO *BIO_new_ssl(SSL_CTX *ctx,int client); +BIO *BIO_new_ssl_connect(SSL_CTX *ctx); +BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx); +int BIO_ssl_copy_session_id(BIO *to,BIO *from); +void BIO_ssl_shutdown(BIO *ssl_bio); + +#endif + +int SSL_CTX_set_cipher_list(SSL_CTX *,const char *str); +SSL_CTX *SSL_CTX_new(SSL_METHOD *meth); +void SSL_CTX_free(SSL_CTX *); +long SSL_CTX_set_timeout(SSL_CTX *ctx,long t); +long SSL_CTX_get_timeout(const SSL_CTX *ctx); +X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *); +void SSL_CTX_set_cert_store(SSL_CTX *,X509_STORE *); +int SSL_want(const SSL *s); +int SSL_clear(SSL *s); + +void SSL_CTX_flush_sessions(SSL_CTX *ctx,long tm); + +SSL_CIPHER *SSL_get_current_cipher(const SSL *s); +int SSL_CIPHER_get_bits(const SSL_CIPHER *c,int *alg_bits); +char * SSL_CIPHER_get_version(const SSL_CIPHER *c); +const char * SSL_CIPHER_get_name(const SSL_CIPHER *c); + +int SSL_get_fd(const SSL *s); +int SSL_get_rfd(const SSL *s); +int SSL_get_wfd(const SSL *s); +const char * SSL_get_cipher_list(const SSL *s,int n); +char * SSL_get_shared_ciphers(const SSL *s, char *buf, int len); +int SSL_get_read_ahead(const SSL * s); +int SSL_pending(const SSL *s); +#ifndef OPENSSL_NO_SOCK +int SSL_set_fd(SSL *s, int fd); +int SSL_set_rfd(SSL *s, int fd); +int SSL_set_wfd(SSL *s, int fd); +#endif +#ifndef OPENSSL_NO_BIO +void SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio); +BIO * SSL_get_rbio(const SSL *s); +BIO * SSL_get_wbio(const SSL *s); +#endif +int SSL_set_cipher_list(SSL *s, const char *str); +void SSL_set_read_ahead(SSL *s, int yes); +int SSL_get_verify_mode(const SSL *s); +int SSL_get_verify_depth(const SSL *s); +int (*SSL_get_verify_callback(const SSL *s))(int,X509_STORE_CTX *); +void SSL_set_verify(SSL *s, int mode, + int (*callback)(int ok,X509_STORE_CTX *ctx)); +void SSL_set_verify_depth(SSL *s, int depth); +#ifndef OPENSSL_NO_RSA +int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); +#endif +int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len); +int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); +int SSL_use_PrivateKey_ASN1(int pk,SSL *ssl, const unsigned char *d, long len); +int SSL_use_certificate(SSL *ssl, X509 *x); +int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len); + +#ifndef OPENSSL_NO_STDIO +int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type); +int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type); +int SSL_use_certificate_file(SSL *ssl, const char *file, int type); +int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type); +int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type); +int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type); +int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); /* PEM type */ +STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); +int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, + const char *file); +#ifndef OPENSSL_SYS_VMS +#ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */ +int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, + const char *dir); +#endif +#endif + +#endif + +void SSL_load_error_strings(void ); +const char *SSL_state_string(const SSL *s); +const char *SSL_rstate_string(const SSL *s); +const char *SSL_state_string_long(const SSL *s); +const char *SSL_rstate_string_long(const SSL *s); +long SSL_SESSION_get_time(const SSL_SESSION *s); +long SSL_SESSION_set_time(SSL_SESSION *s, long t); +long SSL_SESSION_get_timeout(const SSL_SESSION *s); +long SSL_SESSION_set_timeout(SSL_SESSION *s, long t); +void SSL_copy_session_id(SSL *to,const SSL *from); + +SSL_SESSION *SSL_SESSION_new(void); +unsigned long SSL_SESSION_hash(const SSL_SESSION *a); +int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b); +const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len); +#ifndef OPENSSL_NO_FP_API +int SSL_SESSION_print_fp(FILE *fp,const SSL_SESSION *ses); +#endif +#ifndef OPENSSL_NO_BIO +int SSL_SESSION_print(BIO *fp,const SSL_SESSION *ses); +#endif +void SSL_SESSION_free(SSL_SESSION *ses); +int i2d_SSL_SESSION(SSL_SESSION *in,unsigned char **pp); +int SSL_set_session(SSL *to, SSL_SESSION *session); +int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c); +int SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c); +int SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB); +int SSL_set_generate_session_id(SSL *, GEN_SESSION_CB); +int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id, + unsigned int id_len); +SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,const unsigned char **pp, + long length); + +#ifdef HEADER_X509_H +X509 * SSL_get_peer_certificate(const SSL *s); +#endif + +STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s); + +int SSL_CTX_get_verify_mode(const SSL_CTX *ctx); +int SSL_CTX_get_verify_depth(const SSL_CTX *ctx); +int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int,X509_STORE_CTX *); +void SSL_CTX_set_verify(SSL_CTX *ctx,int mode, + int (*callback)(int, X509_STORE_CTX *)); +void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth); +void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *,void *), void *arg); +#ifndef OPENSSL_NO_RSA +int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); +#endif +int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len); +int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); +int SSL_CTX_use_PrivateKey_ASN1(int pk,SSL_CTX *ctx, + const unsigned char *d, long len); +int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); +int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, const unsigned char *d); + +void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb); +void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u); + +int SSL_CTX_check_private_key(const SSL_CTX *ctx); +int SSL_check_private_key(const SSL *ctx); + +int SSL_CTX_set_session_id_context(SSL_CTX *ctx,const unsigned char *sid_ctx, + unsigned int sid_ctx_len); + +SSL * SSL_new(SSL_CTX *ctx); +int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx, + unsigned int sid_ctx_len); + +int SSL_CTX_set_purpose(SSL_CTX *s, int purpose); +int SSL_set_purpose(SSL *s, int purpose); +int SSL_CTX_set_trust(SSL_CTX *s, int trust); +int SSL_set_trust(SSL *s, int trust); + +void SSL_free(SSL *ssl); +int SSL_accept(SSL *ssl); +int SSL_connect(SSL *ssl); +int SSL_read(SSL *ssl,void *buf,int num); +int SSL_peek(SSL *ssl,void *buf,int num); +int SSL_write(SSL *ssl,const void *buf,int num); +long SSL_ctrl(SSL *ssl,int cmd, long larg, void *parg); +long SSL_callback_ctrl(SSL *, int, void (*)(void)); +long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, void *parg); +long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void)); + +int SSL_get_error(const SSL *s,int ret_code); +const char *SSL_get_version(const SSL *s); + +/* This sets the 'default' SSL version that SSL_new() will create */ +int SSL_CTX_set_ssl_version(SSL_CTX *ctx,SSL_METHOD *meth); + +SSL_METHOD *SSLv2_method(void); /* SSLv2 */ +SSL_METHOD *SSLv2_server_method(void); /* SSLv2 */ +SSL_METHOD *SSLv2_client_method(void); /* SSLv2 */ + +SSL_METHOD *SSLv3_method(void); /* SSLv3 */ +SSL_METHOD *SSLv3_server_method(void); /* SSLv3 */ +SSL_METHOD *SSLv3_client_method(void); /* SSLv3 */ + +SSL_METHOD *SSLv23_method(void); /* SSLv3 but can rollback to v2 */ +SSL_METHOD *SSLv23_server_method(void); /* SSLv3 but can rollback to v2 */ +SSL_METHOD *SSLv23_client_method(void); /* SSLv3 but can rollback to v2 */ + +SSL_METHOD *TLSv1_method(void); /* TLSv1.0 */ +SSL_METHOD *TLSv1_server_method(void); /* TLSv1.0 */ +SSL_METHOD *TLSv1_client_method(void); /* TLSv1.0 */ + +SSL_METHOD *DTLSv1_method(void); /* DTLSv1.0 */ +SSL_METHOD *DTLSv1_server_method(void); /* DTLSv1.0 */ +SSL_METHOD *DTLSv1_client_method(void); /* DTLSv1.0 */ + +STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s); + +int SSL_do_handshake(SSL *s); +int SSL_renegotiate(SSL *s); +int SSL_renegotiate_pending(SSL *s); +int SSL_shutdown(SSL *s); + +SSL_METHOD *SSL_get_ssl_method(SSL *s); +int SSL_set_ssl_method(SSL *s,SSL_METHOD *method); +const char *SSL_alert_type_string_long(int value); +const char *SSL_alert_type_string(int value); +const char *SSL_alert_desc_string_long(int value); +const char *SSL_alert_desc_string(int value); + +void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list); +void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list); +STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s); +STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s); +int SSL_add_client_CA(SSL *ssl,X509 *x); +int SSL_CTX_add_client_CA(SSL_CTX *ctx,X509 *x); + +void SSL_set_connect_state(SSL *s); +void SSL_set_accept_state(SSL *s); + +long SSL_get_default_timeout(const SSL *s); + +int SSL_library_init(void ); + +char *SSL_CIPHER_description(SSL_CIPHER *,char *buf,int size); +STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk); + +SSL *SSL_dup(SSL *ssl); + +X509 *SSL_get_certificate(const SSL *ssl); +/* EVP_PKEY */ struct evp_pkey_st *SSL_get_privatekey(SSL *ssl); + +void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx,int mode); +int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx); +void SSL_set_quiet_shutdown(SSL *ssl,int mode); +int SSL_get_quiet_shutdown(const SSL *ssl); +void SSL_set_shutdown(SSL *ssl,int mode); +int SSL_get_shutdown(const SSL *ssl); +int SSL_version(const SSL *ssl); +int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); +int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, + const char *CApath); +#define SSL_get0_session SSL_get_session /* just peek at pointer */ +SSL_SESSION *SSL_get_session(const SSL *ssl); +SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */ +SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl); +void SSL_set_info_callback(SSL *ssl, + void (*cb)(const SSL *ssl,int type,int val)); +void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl,int type,int val); +int SSL_state(const SSL *ssl); + +void SSL_set_verify_result(SSL *ssl,long v); +long SSL_get_verify_result(const SSL *ssl); + +int SSL_set_ex_data(SSL *ssl,int idx,void *data); +void *SSL_get_ex_data(const SSL *ssl,int idx); +int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); + +int SSL_SESSION_set_ex_data(SSL_SESSION *ss,int idx,void *data); +void *SSL_SESSION_get_ex_data(const SSL_SESSION *ss,int idx); +int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); + +int SSL_CTX_set_ex_data(SSL_CTX *ssl,int idx,void *data); +void *SSL_CTX_get_ex_data(const SSL_CTX *ssl,int idx); +int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); + +int SSL_get_ex_data_X509_STORE_CTX_idx(void ); + +#define SSL_CTX_sess_set_cache_size(ctx,t) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL) +#define SSL_CTX_sess_get_cache_size(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL) +#define SSL_CTX_set_session_cache_mode(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL) +#define SSL_CTX_get_session_cache_mode(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL) + +#define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx) +#define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m) +#define SSL_CTX_get_read_ahead(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL) +#define SSL_CTX_set_read_ahead(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL) +#define SSL_CTX_get_max_cert_list(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) +#define SSL_CTX_set_max_cert_list(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) +#define SSL_get_max_cert_list(ssl) \ + SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) +#define SSL_set_max_cert_list(ssl,m) \ + SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) + + /* NB: the keylength is only applicable when is_export is true */ +#ifndef OPENSSL_NO_RSA +void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx, + RSA *(*cb)(SSL *ssl,int is_export, + int keylength)); + +void SSL_set_tmp_rsa_callback(SSL *ssl, + RSA *(*cb)(SSL *ssl,int is_export, + int keylength)); +#endif +#ifndef OPENSSL_NO_DH +void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, + DH *(*dh)(SSL *ssl,int is_export, + int keylength)); +void SSL_set_tmp_dh_callback(SSL *ssl, + DH *(*dh)(SSL *ssl,int is_export, + int keylength)); +#endif +#ifndef OPENSSL_NO_ECDH +void SSL_CTX_set_tmp_ecdh_callback(SSL_CTX *ctx, + EC_KEY *(*ecdh)(SSL *ssl,int is_export, + int keylength)); +void SSL_set_tmp_ecdh_callback(SSL *ssl, + EC_KEY *(*ecdh)(SSL *ssl,int is_export, + int keylength)); +#endif + +#ifndef OPENSSL_NO_COMP +const COMP_METHOD *SSL_get_current_compression(SSL *s); +const COMP_METHOD *SSL_get_current_expansion(SSL *s); +const char *SSL_COMP_get_name(const COMP_METHOD *comp); +STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void); +int SSL_COMP_add_compression_method(int id,COMP_METHOD *cm); +#else +const void *SSL_get_current_compression(SSL *s); +const void *SSL_get_current_expansion(SSL *s); +const char *SSL_COMP_get_name(const void *comp); +void *SSL_COMP_get_compression_methods(void); +int SSL_COMP_add_compression_method(int id,void *cm); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_SSL_strings(void); + +/* Error codes for the SSL functions. */ + +/* Function codes. */ +#define SSL_F_CLIENT_CERTIFICATE 100 +#define SSL_F_CLIENT_FINISHED 167 +#define SSL_F_CLIENT_HELLO 101 +#define SSL_F_CLIENT_MASTER_KEY 102 +#define SSL_F_D2I_SSL_SESSION 103 +#define SSL_F_DO_DTLS1_WRITE 245 +#define SSL_F_DO_SSL3_WRITE 104 +#define SSL_F_DTLS1_ACCEPT 246 +#define SSL_F_DTLS1_BUFFER_RECORD 247 +#define SSL_F_DTLS1_CLIENT_HELLO 248 +#define SSL_F_DTLS1_CONNECT 249 +#define SSL_F_DTLS1_ENC 250 +#define SSL_F_DTLS1_GET_HELLO_VERIFY 251 +#define SSL_F_DTLS1_GET_MESSAGE 252 +#define SSL_F_DTLS1_GET_MESSAGE_FRAGMENT 253 +#define SSL_F_DTLS1_GET_RECORD 254 +#define SSL_F_DTLS1_OUTPUT_CERT_CHAIN 255 +#define SSL_F_DTLS1_PROCESS_OUT_OF_SEQ_MESSAGE 256 +#define SSL_F_DTLS1_PROCESS_RECORD 257 +#define SSL_F_DTLS1_READ_BYTES 258 +#define SSL_F_DTLS1_READ_FAILED 259 +#define SSL_F_DTLS1_SEND_CERTIFICATE_REQUEST 260 +#define SSL_F_DTLS1_SEND_CLIENT_CERTIFICATE 261 +#define SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE 262 +#define SSL_F_DTLS1_SEND_CLIENT_VERIFY 263 +#define SSL_F_DTLS1_SEND_HELLO_VERIFY_REQUEST 264 +#define SSL_F_DTLS1_SEND_SERVER_CERTIFICATE 265 +#define SSL_F_DTLS1_SEND_SERVER_HELLO 266 +#define SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE 267 +#define SSL_F_DTLS1_WRITE_APP_DATA_BYTES 268 +#define SSL_F_GET_CLIENT_FINISHED 105 +#define SSL_F_GET_CLIENT_HELLO 106 +#define SSL_F_GET_CLIENT_MASTER_KEY 107 +#define SSL_F_GET_SERVER_FINISHED 108 +#define SSL_F_GET_SERVER_HELLO 109 +#define SSL_F_GET_SERVER_VERIFY 110 +#define SSL_F_I2D_SSL_SESSION 111 +#define SSL_F_READ_N 112 +#define SSL_F_REQUEST_CERTIFICATE 113 +#define SSL_F_SERVER_FINISH 239 +#define SSL_F_SERVER_HELLO 114 +#define SSL_F_SERVER_VERIFY 240 +#define SSL_F_SSL23_ACCEPT 115 +#define SSL_F_SSL23_CLIENT_HELLO 116 +#define SSL_F_SSL23_CONNECT 117 +#define SSL_F_SSL23_GET_CLIENT_HELLO 118 +#define SSL_F_SSL23_GET_SERVER_HELLO 119 +#define SSL_F_SSL23_PEEK 237 +#define SSL_F_SSL23_READ 120 +#define SSL_F_SSL23_WRITE 121 +#define SSL_F_SSL2_ACCEPT 122 +#define SSL_F_SSL2_CONNECT 123 +#define SSL_F_SSL2_ENC_INIT 124 +#define SSL_F_SSL2_GENERATE_KEY_MATERIAL 241 +#define SSL_F_SSL2_PEEK 234 +#define SSL_F_SSL2_READ 125 +#define SSL_F_SSL2_READ_INTERNAL 236 +#define SSL_F_SSL2_SET_CERTIFICATE 126 +#define SSL_F_SSL2_WRITE 127 +#define SSL_F_SSL3_ACCEPT 128 +#define SSL_F_SSL3_CALLBACK_CTRL 233 +#define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 +#define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 +#define SSL_F_SSL3_CLIENT_HELLO 131 +#define SSL_F_SSL3_CONNECT 132 +#define SSL_F_SSL3_CTRL 213 +#define SSL_F_SSL3_CTX_CTRL 133 +#define SSL_F_SSL3_ENC 134 +#define SSL_F_SSL3_GENERATE_KEY_BLOCK 238 +#define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135 +#define SSL_F_SSL3_GET_CERT_VERIFY 136 +#define SSL_F_SSL3_GET_CLIENT_CERTIFICATE 137 +#define SSL_F_SSL3_GET_CLIENT_HELLO 138 +#define SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE 139 +#define SSL_F_SSL3_GET_FINISHED 140 +#define SSL_F_SSL3_GET_KEY_EXCHANGE 141 +#define SSL_F_SSL3_GET_MESSAGE 142 +#define SSL_F_SSL3_GET_RECORD 143 +#define SSL_F_SSL3_GET_SERVER_CERTIFICATE 144 +#define SSL_F_SSL3_GET_SERVER_DONE 145 +#define SSL_F_SSL3_GET_SERVER_HELLO 146 +#define SSL_F_SSL3_OUTPUT_CERT_CHAIN 147 +#define SSL_F_SSL3_PEEK 235 +#define SSL_F_SSL3_READ_BYTES 148 +#define SSL_F_SSL3_READ_N 149 +#define SSL_F_SSL3_SEND_CERTIFICATE_REQUEST 150 +#define SSL_F_SSL3_SEND_CLIENT_CERTIFICATE 151 +#define SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE 152 +#define SSL_F_SSL3_SEND_CLIENT_VERIFY 153 +#define SSL_F_SSL3_SEND_SERVER_CERTIFICATE 154 +#define SSL_F_SSL3_SEND_SERVER_HELLO 242 +#define SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE 155 +#define SSL_F_SSL3_SETUP_BUFFERS 156 +#define SSL_F_SSL3_SETUP_KEY_BLOCK 157 +#define SSL_F_SSL3_WRITE_BYTES 158 +#define SSL_F_SSL3_WRITE_PENDING 159 +#define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK 215 +#define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK 216 +#define SSL_F_SSL_BAD_METHOD 160 +#define SSL_F_SSL_BYTES_TO_CIPHER_LIST 161 +#define SSL_F_SSL_CERT_DUP 221 +#define SSL_F_SSL_CERT_INST 222 +#define SSL_F_SSL_CERT_INSTANTIATE 214 +#define SSL_F_SSL_CERT_NEW 162 +#define SSL_F_SSL_CHECK_PRIVATE_KEY 163 +#define SSL_F_SSL_CIPHER_PROCESS_RULESTR 230 +#define SSL_F_SSL_CIPHER_STRENGTH_SORT 231 +#define SSL_F_SSL_CLEAR 164 +#define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 165 +#define SSL_F_SSL_CREATE_CIPHER_LIST 166 +#define SSL_F_SSL_CTRL 232 +#define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 168 +#define SSL_F_SSL_CTX_NEW 169 +#define SSL_F_SSL_CTX_SET_CIPHER_LIST 269 +#define SSL_F_SSL_CTX_SET_PURPOSE 226 +#define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 219 +#define SSL_F_SSL_CTX_SET_SSL_VERSION 170 +#define SSL_F_SSL_CTX_SET_TRUST 229 +#define SSL_F_SSL_CTX_USE_CERTIFICATE 171 +#define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 172 +#define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE 220 +#define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 173 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY 174 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 175 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 176 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 177 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 178 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 179 +#define SSL_F_SSL_DO_HANDSHAKE 180 +#define SSL_F_SSL_GET_NEW_SESSION 181 +#define SSL_F_SSL_GET_PREV_SESSION 217 +#define SSL_F_SSL_GET_SERVER_SEND_CERT 182 +#define SSL_F_SSL_GET_SIGN_PKEY 183 +#define SSL_F_SSL_INIT_WBIO_BUFFER 184 +#define SSL_F_SSL_LOAD_CLIENT_CA_FILE 185 +#define SSL_F_SSL_NEW 186 +#define SSL_F_SSL_PEEK 270 +#define SSL_F_SSL_READ 223 +#define SSL_F_SSL_RSA_PRIVATE_DECRYPT 187 +#define SSL_F_SSL_RSA_PUBLIC_ENCRYPT 188 +#define SSL_F_SSL_SESSION_NEW 189 +#define SSL_F_SSL_SESSION_PRINT_FP 190 +#define SSL_F_SSL_SESS_CERT_NEW 225 +#define SSL_F_SSL_SET_CERT 191 +#define SSL_F_SSL_SET_CIPHER_LIST 271 +#define SSL_F_SSL_SET_FD 192 +#define SSL_F_SSL_SET_PKEY 193 +#define SSL_F_SSL_SET_PURPOSE 227 +#define SSL_F_SSL_SET_RFD 194 +#define SSL_F_SSL_SET_SESSION 195 +#define SSL_F_SSL_SET_SESSION_ID_CONTEXT 218 +#define SSL_F_SSL_SET_TRUST 228 +#define SSL_F_SSL_SET_WFD 196 +#define SSL_F_SSL_SHUTDOWN 224 +#define SSL_F_SSL_UNDEFINED_CONST_FUNCTION 243 +#define SSL_F_SSL_UNDEFINED_FUNCTION 197 +#define SSL_F_SSL_UNDEFINED_VOID_FUNCTION 244 +#define SSL_F_SSL_USE_CERTIFICATE 198 +#define SSL_F_SSL_USE_CERTIFICATE_ASN1 199 +#define SSL_F_SSL_USE_CERTIFICATE_FILE 200 +#define SSL_F_SSL_USE_PRIVATEKEY 201 +#define SSL_F_SSL_USE_PRIVATEKEY_ASN1 202 +#define SSL_F_SSL_USE_PRIVATEKEY_FILE 203 +#define SSL_F_SSL_USE_RSAPRIVATEKEY 204 +#define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 205 +#define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 206 +#define SSL_F_SSL_VERIFY_CERT_CHAIN 207 +#define SSL_F_SSL_WRITE 208 +#define SSL_F_TLS1_CHANGE_CIPHER_STATE 209 +#define SSL_F_TLS1_ENC 210 +#define SSL_F_TLS1_SETUP_KEY_BLOCK 211 +#define SSL_F_WRITE_PENDING 212 + +/* Reason codes. */ +#define SSL_R_APP_DATA_IN_HANDSHAKE 100 +#define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272 +#define SSL_R_BAD_ALERT_RECORD 101 +#define SSL_R_BAD_AUTHENTICATION_TYPE 102 +#define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 +#define SSL_R_BAD_CHECKSUM 104 +#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106 +#define SSL_R_BAD_DECOMPRESSION 107 +#define SSL_R_BAD_DH_G_LENGTH 108 +#define SSL_R_BAD_DH_PUB_KEY_LENGTH 109 +#define SSL_R_BAD_DH_P_LENGTH 110 +#define SSL_R_BAD_DIGEST_LENGTH 111 +#define SSL_R_BAD_DSA_SIGNATURE 112 +#define SSL_R_BAD_ECC_CERT 304 +#define SSL_R_BAD_ECDSA_SIGNATURE 305 +#define SSL_R_BAD_ECPOINT 306 +#define SSL_R_BAD_HELLO_REQUEST 105 +#define SSL_R_BAD_LENGTH 271 +#define SSL_R_BAD_MAC_DECODE 113 +#define SSL_R_BAD_MESSAGE_TYPE 114 +#define SSL_R_BAD_PACKET_LENGTH 115 +#define SSL_R_BAD_PROTOCOL_VERSION_NUMBER 116 +#define SSL_R_BAD_RESPONSE_ARGUMENT 117 +#define SSL_R_BAD_RSA_DECRYPT 118 +#define SSL_R_BAD_RSA_ENCRYPT 119 +#define SSL_R_BAD_RSA_E_LENGTH 120 +#define SSL_R_BAD_RSA_MODULUS_LENGTH 121 +#define SSL_R_BAD_RSA_SIGNATURE 122 +#define SSL_R_BAD_SIGNATURE 123 +#define SSL_R_BAD_SSL_FILETYPE 124 +#define SSL_R_BAD_SSL_SESSION_ID_LENGTH 125 +#define SSL_R_BAD_STATE 126 +#define SSL_R_BAD_WRITE_RETRY 127 +#define SSL_R_BIO_NOT_SET 128 +#define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG 129 +#define SSL_R_BN_LIB 130 +#define SSL_R_CA_DN_LENGTH_MISMATCH 131 +#define SSL_R_CA_DN_TOO_LONG 132 +#define SSL_R_CCS_RECEIVED_EARLY 133 +#define SSL_R_CERTIFICATE_VERIFY_FAILED 134 +#define SSL_R_CERT_LENGTH_MISMATCH 135 +#define SSL_R_CHALLENGE_IS_DIFFERENT 136 +#define SSL_R_CIPHER_CODE_WRONG_LENGTH 137 +#define SSL_R_CIPHER_OR_HASH_UNAVAILABLE 138 +#define SSL_R_CIPHER_TABLE_SRC_ERROR 139 +#define SSL_R_COMPRESSED_LENGTH_TOO_LONG 140 +#define SSL_R_COMPRESSION_FAILURE 141 +#define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE 307 +#define SSL_R_COMPRESSION_LIBRARY_ERROR 142 +#define SSL_R_CONNECTION_ID_IS_DIFFERENT 143 +#define SSL_R_CONNECTION_TYPE_NOT_SET 144 +#define SSL_R_COOKIE_MISMATCH 308 +#define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 145 +#define SSL_R_DATA_LENGTH_TOO_LONG 146 +#define SSL_R_DECRYPTION_FAILED 147 +#define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 281 +#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148 +#define SSL_R_DIGEST_CHECK_FAILED 149 +#define SSL_R_DUPLICATE_COMPRESSION_ID 309 +#define SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER 310 +#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150 +#define SSL_R_ERROR_GENERATING_TMP_RSA_KEY 282 +#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 151 +#define SSL_R_EXCESSIVE_MESSAGE_SIZE 152 +#define SSL_R_EXTRA_DATA_IN_MESSAGE 153 +#define SSL_R_GOT_A_FIN_BEFORE_A_CCS 154 +#define SSL_R_HTTPS_PROXY_REQUEST 155 +#define SSL_R_HTTP_REQUEST 156 +#define SSL_R_ILLEGAL_PADDING 283 +#define SSL_R_INVALID_CHALLENGE_LENGTH 158 +#define SSL_R_INVALID_COMMAND 280 +#define SSL_R_INVALID_PURPOSE 278 +#define SSL_R_INVALID_TRUST 279 +#define SSL_R_KEY_ARG_TOO_LONG 284 +#define SSL_R_KRB5 285 +#define SSL_R_KRB5_C_CC_PRINC 286 +#define SSL_R_KRB5_C_GET_CRED 287 +#define SSL_R_KRB5_C_INIT 288 +#define SSL_R_KRB5_C_MK_REQ 289 +#define SSL_R_KRB5_S_BAD_TICKET 290 +#define SSL_R_KRB5_S_INIT 291 +#define SSL_R_KRB5_S_RD_REQ 292 +#define SSL_R_KRB5_S_TKT_EXPIRED 293 +#define SSL_R_KRB5_S_TKT_NYV 294 +#define SSL_R_KRB5_S_TKT_SKEW 295 +#define SSL_R_LENGTH_MISMATCH 159 +#define SSL_R_LENGTH_TOO_SHORT 160 +#define SSL_R_LIBRARY_BUG 274 +#define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 +#define SSL_R_MESSAGE_TOO_LONG 296 +#define SSL_R_MISSING_DH_DSA_CERT 162 +#define SSL_R_MISSING_DH_KEY 163 +#define SSL_R_MISSING_DH_RSA_CERT 164 +#define SSL_R_MISSING_DSA_SIGNING_CERT 165 +#define SSL_R_MISSING_EXPORT_TMP_DH_KEY 166 +#define SSL_R_MISSING_EXPORT_TMP_RSA_KEY 167 +#define SSL_R_MISSING_RSA_CERTIFICATE 168 +#define SSL_R_MISSING_RSA_ENCRYPTING_CERT 169 +#define SSL_R_MISSING_RSA_SIGNING_CERT 170 +#define SSL_R_MISSING_TMP_DH_KEY 171 +#define SSL_R_MISSING_TMP_ECDH_KEY 311 +#define SSL_R_MISSING_TMP_RSA_KEY 172 +#define SSL_R_MISSING_TMP_RSA_PKEY 173 +#define SSL_R_MISSING_VERIFY_MESSAGE 174 +#define SSL_R_NON_SSLV2_INITIAL_PACKET 175 +#define SSL_R_NO_CERTIFICATES_RETURNED 176 +#define SSL_R_NO_CERTIFICATE_ASSIGNED 177 +#define SSL_R_NO_CERTIFICATE_RETURNED 178 +#define SSL_R_NO_CERTIFICATE_SET 179 +#define SSL_R_NO_CERTIFICATE_SPECIFIED 180 +#define SSL_R_NO_CIPHERS_AVAILABLE 181 +#define SSL_R_NO_CIPHERS_PASSED 182 +#define SSL_R_NO_CIPHERS_SPECIFIED 183 +#define SSL_R_NO_CIPHER_LIST 184 +#define SSL_R_NO_CIPHER_MATCH 185 +#define SSL_R_NO_CLIENT_CERT_RECEIVED 186 +#define SSL_R_NO_COMPRESSION_SPECIFIED 187 +#define SSL_R_NO_METHOD_SPECIFIED 188 +#define SSL_R_NO_PRIVATEKEY 189 +#define SSL_R_NO_PRIVATE_KEY_ASSIGNED 190 +#define SSL_R_NO_PROTOCOLS_AVAILABLE 191 +#define SSL_R_NO_PUBLICKEY 192 +#define SSL_R_NO_SHARED_CIPHER 193 +#define SSL_R_NO_VERIFY_CALLBACK 194 +#define SSL_R_NULL_SSL_CTX 195 +#define SSL_R_NULL_SSL_METHOD_PASSED 196 +#define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 197 +#define SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE 297 +#define SSL_R_PACKET_LENGTH_TOO_LONG 198 +#define SSL_R_PATH_TOO_LONG 270 +#define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 199 +#define SSL_R_PEER_ERROR 200 +#define SSL_R_PEER_ERROR_CERTIFICATE 201 +#define SSL_R_PEER_ERROR_NO_CERTIFICATE 202 +#define SSL_R_PEER_ERROR_NO_CIPHER 203 +#define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 204 +#define SSL_R_PRE_MAC_LENGTH_TOO_LONG 205 +#define SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS 206 +#define SSL_R_PROTOCOL_IS_SHUTDOWN 207 +#define SSL_R_PUBLIC_KEY_ENCRYPT_ERROR 208 +#define SSL_R_PUBLIC_KEY_IS_NOT_RSA 209 +#define SSL_R_PUBLIC_KEY_NOT_RSA 210 +#define SSL_R_READ_BIO_NOT_SET 211 +#define SSL_R_READ_TIMEOUT_EXPIRED 312 +#define SSL_R_READ_WRONG_PACKET_TYPE 212 +#define SSL_R_RECORD_LENGTH_MISMATCH 213 +#define SSL_R_RECORD_TOO_LARGE 214 +#define SSL_R_RECORD_TOO_SMALL 298 +#define SSL_R_REQUIRED_CIPHER_MISSING 215 +#define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO 216 +#define SSL_R_REUSE_CERT_TYPE_NOT_ZERO 217 +#define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO 218 +#define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED 277 +#define SSL_R_SHORT_READ 219 +#define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 220 +#define SSL_R_SSL23_DOING_SESSION_ID_REUSE 221 +#define SSL_R_SSL2_CONNECTION_ID_TOO_LONG 299 +#define SSL_R_SSL3_SESSION_ID_TOO_LONG 300 +#define SSL_R_SSL3_SESSION_ID_TOO_SHORT 222 +#define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 +#define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046 +#define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030 +#define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 +#define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 +#define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 +#define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 +#define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 +#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 228 +#define SSL_R_SSL_HANDSHAKE_FAILURE 229 +#define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 230 +#define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED 301 +#define SSL_R_SSL_SESSION_ID_CONFLICT 302 +#define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273 +#define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH 303 +#define SSL_R_SSL_SESSION_ID_IS_DIFFERENT 231 +#define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 +#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 +#define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021 +#define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 +#define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060 +#define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 +#define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 +#define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 +#define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 +#define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022 +#define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048 +#define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 +#define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 232 +#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233 +#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 234 +#define SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER 235 +#define SSL_R_UNABLE_TO_DECODE_DH_CERTS 236 +#define SSL_R_UNABLE_TO_DECODE_ECDH_CERTS 313 +#define SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY 237 +#define SSL_R_UNABLE_TO_FIND_DH_PARAMETERS 238 +#define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS 314 +#define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS 239 +#define SSL_R_UNABLE_TO_FIND_SSL_METHOD 240 +#define SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES 241 +#define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES 242 +#define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES 243 +#define SSL_R_UNEXPECTED_MESSAGE 244 +#define SSL_R_UNEXPECTED_RECORD 245 +#define SSL_R_UNINITIALIZED 276 +#define SSL_R_UNKNOWN_ALERT_TYPE 246 +#define SSL_R_UNKNOWN_CERTIFICATE_TYPE 247 +#define SSL_R_UNKNOWN_CIPHER_RETURNED 248 +#define SSL_R_UNKNOWN_CIPHER_TYPE 249 +#define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 250 +#define SSL_R_UNKNOWN_PKEY_TYPE 251 +#define SSL_R_UNKNOWN_PROTOCOL 252 +#define SSL_R_UNKNOWN_REMOTE_ERROR_TYPE 253 +#define SSL_R_UNKNOWN_SSL_VERSION 254 +#define SSL_R_UNKNOWN_STATE 255 +#define SSL_R_UNSUPPORTED_CIPHER 256 +#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257 +#define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE 315 +#define SSL_R_UNSUPPORTED_PROTOCOL 258 +#define SSL_R_UNSUPPORTED_SSL_VERSION 259 +#define SSL_R_WRITE_BIO_NOT_SET 260 +#define SSL_R_WRONG_CIPHER_RETURNED 261 +#define SSL_R_WRONG_MESSAGE_TYPE 262 +#define SSL_R_WRONG_NUMBER_OF_KEY_BITS 263 +#define SSL_R_WRONG_SIGNATURE_LENGTH 264 +#define SSL_R_WRONG_SIGNATURE_SIZE 265 +#define SSL_R_WRONG_SSL_VERSION 266 +#define SSL_R_WRONG_VERSION_NUMBER 267 +#define SSL_R_X509_LIB 268 +#define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS 269 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/ssl2.h b/src/dep/include/openssl/ssl2.h index e80e2a1..6d2bac3 100644 --- a/src/dep/include/openssl/ssl2.h +++ b/src/dep/include/openssl/ssl2.h @@ -1,268 +1,268 @@ -/* ssl/ssl2.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_SSL2_H -#define HEADER_SSL2_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Protocol Version Codes */ -#define SSL2_VERSION 0x0002 -#define SSL2_VERSION_MAJOR 0x00 -#define SSL2_VERSION_MINOR 0x02 -/* #define SSL2_CLIENT_VERSION 0x0002 */ -/* #define SSL2_SERVER_VERSION 0x0002 */ - -/* Protocol Message Codes */ -#define SSL2_MT_ERROR 0 -#define SSL2_MT_CLIENT_HELLO 1 -#define SSL2_MT_CLIENT_MASTER_KEY 2 -#define SSL2_MT_CLIENT_FINISHED 3 -#define SSL2_MT_SERVER_HELLO 4 -#define SSL2_MT_SERVER_VERIFY 5 -#define SSL2_MT_SERVER_FINISHED 6 -#define SSL2_MT_REQUEST_CERTIFICATE 7 -#define SSL2_MT_CLIENT_CERTIFICATE 8 - -/* Error Message Codes */ -#define SSL2_PE_UNDEFINED_ERROR 0x0000 -#define SSL2_PE_NO_CIPHER 0x0001 -#define SSL2_PE_NO_CERTIFICATE 0x0002 -#define SSL2_PE_BAD_CERTIFICATE 0x0004 -#define SSL2_PE_UNSUPPORTED_CERTIFICATE_TYPE 0x0006 - -/* Cipher Kind Values */ -#define SSL2_CK_NULL_WITH_MD5 0x02000000 /* v3 */ -#define SSL2_CK_RC4_128_WITH_MD5 0x02010080 -#define SSL2_CK_RC4_128_EXPORT40_WITH_MD5 0x02020080 -#define SSL2_CK_RC2_128_CBC_WITH_MD5 0x02030080 -#define SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5 0x02040080 -#define SSL2_CK_IDEA_128_CBC_WITH_MD5 0x02050080 -#define SSL2_CK_DES_64_CBC_WITH_MD5 0x02060040 -#define SSL2_CK_DES_64_CBC_WITH_SHA 0x02060140 /* v3 */ -#define SSL2_CK_DES_192_EDE3_CBC_WITH_MD5 0x020700c0 -#define SSL2_CK_DES_192_EDE3_CBC_WITH_SHA 0x020701c0 /* v3 */ -#define SSL2_CK_RC4_64_WITH_MD5 0x02080080 /* MS hack */ - -#define SSL2_CK_DES_64_CFB64_WITH_MD5_1 0x02ff0800 /* SSLeay */ -#define SSL2_CK_NULL 0x02ff0810 /* SSLeay */ - -#define SSL2_TXT_DES_64_CFB64_WITH_MD5_1 "DES-CFB-M1" -#define SSL2_TXT_NULL_WITH_MD5 "NULL-MD5" -#define SSL2_TXT_RC4_128_WITH_MD5 "RC4-MD5" -#define SSL2_TXT_RC4_128_EXPORT40_WITH_MD5 "EXP-RC4-MD5" -#define SSL2_TXT_RC2_128_CBC_WITH_MD5 "RC2-CBC-MD5" -#define SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 "EXP-RC2-CBC-MD5" -#define SSL2_TXT_IDEA_128_CBC_WITH_MD5 "IDEA-CBC-MD5" -#define SSL2_TXT_DES_64_CBC_WITH_MD5 "DES-CBC-MD5" -#define SSL2_TXT_DES_64_CBC_WITH_SHA "DES-CBC-SHA" -#define SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 "DES-CBC3-MD5" -#define SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA "DES-CBC3-SHA" -#define SSL2_TXT_RC4_64_WITH_MD5 "RC4-64-MD5" - -#define SSL2_TXT_NULL "NULL" - -/* Flags for the SSL_CIPHER.algorithm2 field */ -#define SSL2_CF_5_BYTE_ENC 0x01 -#define SSL2_CF_8_BYTE_ENC 0x02 - -/* Certificate Type Codes */ -#define SSL2_CT_X509_CERTIFICATE 0x01 - -/* Authentication Type Code */ -#define SSL2_AT_MD5_WITH_RSA_ENCRYPTION 0x01 - -#define SSL2_MAX_SSL_SESSION_ID_LENGTH 32 - -/* Upper/Lower Bounds */ -#define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS 256 -#ifdef OPENSSL_SYS_MPE -#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 29998u -#else -#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 32767u /* 2^15-1 */ -#endif -#define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER 16383 /* 2^14-1 */ - -#define SSL2_CHALLENGE_LENGTH 16 -/*#define SSL2_CHALLENGE_LENGTH 32 */ -#define SSL2_MIN_CHALLENGE_LENGTH 16 -#define SSL2_MAX_CHALLENGE_LENGTH 32 -#define SSL2_CONNECTION_ID_LENGTH 16 -#define SSL2_MAX_CONNECTION_ID_LENGTH 16 -#define SSL2_SSL_SESSION_ID_LENGTH 16 -#define SSL2_MAX_CERT_CHALLENGE_LENGTH 32 -#define SSL2_MIN_CERT_CHALLENGE_LENGTH 16 -#define SSL2_MAX_KEY_MATERIAL_LENGTH 24 - -#ifndef HEADER_SSL_LOCL_H -#define CERT char -#endif - -typedef struct ssl2_state_st - { - int three_byte_header; - int clear_text; /* clear text */ - int escape; /* not used in SSLv2 */ - int ssl2_rollback; /* used if SSLv23 rolled back to SSLv2 */ - - /* non-blocking io info, used to make sure the same - * args were passwd */ - unsigned int wnum; /* number of bytes sent so far */ - int wpend_tot; - const unsigned char *wpend_buf; - - int wpend_off; /* offset to data to write */ - int wpend_len; /* number of bytes passwd to write */ - int wpend_ret; /* number of bytes to return to caller */ - - /* buffer raw data */ - int rbuf_left; - int rbuf_offs; - unsigned char *rbuf; - unsigned char *wbuf; - - unsigned char *write_ptr;/* used to point to the start due to - * 2/3 byte header. */ - - unsigned int padding; - unsigned int rlength; /* passed to ssl2_enc */ - int ract_data_length; /* Set when things are encrypted. */ - unsigned int wlength; /* passed to ssl2_enc */ - int wact_data_length; /* Set when things are decrypted. */ - unsigned char *ract_data; - unsigned char *wact_data; - unsigned char *mac_data; - - unsigned char *read_key; - unsigned char *write_key; - - /* Stuff specifically to do with this SSL session */ - unsigned int challenge_length; - unsigned char challenge[SSL2_MAX_CHALLENGE_LENGTH]; - unsigned int conn_id_length; - unsigned char conn_id[SSL2_MAX_CONNECTION_ID_LENGTH]; - unsigned int key_material_length; - unsigned char key_material[SSL2_MAX_KEY_MATERIAL_LENGTH*2]; - - unsigned long read_sequence; - unsigned long write_sequence; - - struct { - unsigned int conn_id_length; - unsigned int cert_type; - unsigned int cert_length; - unsigned int csl; - unsigned int clear; - unsigned int enc; - unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH]; - unsigned int cipher_spec_length; - unsigned int session_id_length; - unsigned int clen; - unsigned int rlen; - } tmp; - } SSL2_STATE; - -/* SSLv2 */ -/* client */ -#define SSL2_ST_SEND_CLIENT_HELLO_A (0x10|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_HELLO_B (0x11|SSL_ST_CONNECT) -#define SSL2_ST_GET_SERVER_HELLO_A (0x20|SSL_ST_CONNECT) -#define SSL2_ST_GET_SERVER_HELLO_B (0x21|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_MASTER_KEY_A (0x30|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_MASTER_KEY_B (0x31|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_FINISHED_A (0x40|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_FINISHED_B (0x41|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_CERTIFICATE_A (0x50|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_CERTIFICATE_B (0x51|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_CERTIFICATE_C (0x52|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_CERTIFICATE_D (0x53|SSL_ST_CONNECT) -#define SSL2_ST_GET_SERVER_VERIFY_A (0x60|SSL_ST_CONNECT) -#define SSL2_ST_GET_SERVER_VERIFY_B (0x61|SSL_ST_CONNECT) -#define SSL2_ST_GET_SERVER_FINISHED_A (0x70|SSL_ST_CONNECT) -#define SSL2_ST_GET_SERVER_FINISHED_B (0x71|SSL_ST_CONNECT) -#define SSL2_ST_CLIENT_START_ENCRYPTION (0x80|SSL_ST_CONNECT) -#define SSL2_ST_X509_GET_CLIENT_CERTIFICATE (0x90|SSL_ST_CONNECT) -/* server */ -#define SSL2_ST_GET_CLIENT_HELLO_A (0x10|SSL_ST_ACCEPT) -#define SSL2_ST_GET_CLIENT_HELLO_B (0x11|SSL_ST_ACCEPT) -#define SSL2_ST_GET_CLIENT_HELLO_C (0x12|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_SERVER_HELLO_A (0x20|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_SERVER_HELLO_B (0x21|SSL_ST_ACCEPT) -#define SSL2_ST_GET_CLIENT_MASTER_KEY_A (0x30|SSL_ST_ACCEPT) -#define SSL2_ST_GET_CLIENT_MASTER_KEY_B (0x31|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_SERVER_VERIFY_A (0x40|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_SERVER_VERIFY_B (0x41|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_SERVER_VERIFY_C (0x42|SSL_ST_ACCEPT) -#define SSL2_ST_GET_CLIENT_FINISHED_A (0x50|SSL_ST_ACCEPT) -#define SSL2_ST_GET_CLIENT_FINISHED_B (0x51|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_SERVER_FINISHED_A (0x60|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_SERVER_FINISHED_B (0x61|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_REQUEST_CERTIFICATE_A (0x70|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_REQUEST_CERTIFICATE_B (0x71|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_REQUEST_CERTIFICATE_C (0x72|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_REQUEST_CERTIFICATE_D (0x73|SSL_ST_ACCEPT) -#define SSL2_ST_SERVER_START_ENCRYPTION (0x80|SSL_ST_ACCEPT) -#define SSL2_ST_X509_GET_SERVER_CERTIFICATE (0x90|SSL_ST_ACCEPT) - -#ifdef __cplusplus -} -#endif -#endif - +/* ssl/ssl2.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_SSL2_H +#define HEADER_SSL2_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Protocol Version Codes */ +#define SSL2_VERSION 0x0002 +#define SSL2_VERSION_MAJOR 0x00 +#define SSL2_VERSION_MINOR 0x02 +/* #define SSL2_CLIENT_VERSION 0x0002 */ +/* #define SSL2_SERVER_VERSION 0x0002 */ + +/* Protocol Message Codes */ +#define SSL2_MT_ERROR 0 +#define SSL2_MT_CLIENT_HELLO 1 +#define SSL2_MT_CLIENT_MASTER_KEY 2 +#define SSL2_MT_CLIENT_FINISHED 3 +#define SSL2_MT_SERVER_HELLO 4 +#define SSL2_MT_SERVER_VERIFY 5 +#define SSL2_MT_SERVER_FINISHED 6 +#define SSL2_MT_REQUEST_CERTIFICATE 7 +#define SSL2_MT_CLIENT_CERTIFICATE 8 + +/* Error Message Codes */ +#define SSL2_PE_UNDEFINED_ERROR 0x0000 +#define SSL2_PE_NO_CIPHER 0x0001 +#define SSL2_PE_NO_CERTIFICATE 0x0002 +#define SSL2_PE_BAD_CERTIFICATE 0x0004 +#define SSL2_PE_UNSUPPORTED_CERTIFICATE_TYPE 0x0006 + +/* Cipher Kind Values */ +#define SSL2_CK_NULL_WITH_MD5 0x02000000 /* v3 */ +#define SSL2_CK_RC4_128_WITH_MD5 0x02010080 +#define SSL2_CK_RC4_128_EXPORT40_WITH_MD5 0x02020080 +#define SSL2_CK_RC2_128_CBC_WITH_MD5 0x02030080 +#define SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5 0x02040080 +#define SSL2_CK_IDEA_128_CBC_WITH_MD5 0x02050080 +#define SSL2_CK_DES_64_CBC_WITH_MD5 0x02060040 +#define SSL2_CK_DES_64_CBC_WITH_SHA 0x02060140 /* v3 */ +#define SSL2_CK_DES_192_EDE3_CBC_WITH_MD5 0x020700c0 +#define SSL2_CK_DES_192_EDE3_CBC_WITH_SHA 0x020701c0 /* v3 */ +#define SSL2_CK_RC4_64_WITH_MD5 0x02080080 /* MS hack */ + +#define SSL2_CK_DES_64_CFB64_WITH_MD5_1 0x02ff0800 /* SSLeay */ +#define SSL2_CK_NULL 0x02ff0810 /* SSLeay */ + +#define SSL2_TXT_DES_64_CFB64_WITH_MD5_1 "DES-CFB-M1" +#define SSL2_TXT_NULL_WITH_MD5 "NULL-MD5" +#define SSL2_TXT_RC4_128_WITH_MD5 "RC4-MD5" +#define SSL2_TXT_RC4_128_EXPORT40_WITH_MD5 "EXP-RC4-MD5" +#define SSL2_TXT_RC2_128_CBC_WITH_MD5 "RC2-CBC-MD5" +#define SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 "EXP-RC2-CBC-MD5" +#define SSL2_TXT_IDEA_128_CBC_WITH_MD5 "IDEA-CBC-MD5" +#define SSL2_TXT_DES_64_CBC_WITH_MD5 "DES-CBC-MD5" +#define SSL2_TXT_DES_64_CBC_WITH_SHA "DES-CBC-SHA" +#define SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 "DES-CBC3-MD5" +#define SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA "DES-CBC3-SHA" +#define SSL2_TXT_RC4_64_WITH_MD5 "RC4-64-MD5" + +#define SSL2_TXT_NULL "NULL" + +/* Flags for the SSL_CIPHER.algorithm2 field */ +#define SSL2_CF_5_BYTE_ENC 0x01 +#define SSL2_CF_8_BYTE_ENC 0x02 + +/* Certificate Type Codes */ +#define SSL2_CT_X509_CERTIFICATE 0x01 + +/* Authentication Type Code */ +#define SSL2_AT_MD5_WITH_RSA_ENCRYPTION 0x01 + +#define SSL2_MAX_SSL_SESSION_ID_LENGTH 32 + +/* Upper/Lower Bounds */ +#define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS 256 +#ifdef OPENSSL_SYS_MPE +#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 29998u +#else +#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 32767u /* 2^15-1 */ +#endif +#define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER 16383 /* 2^14-1 */ + +#define SSL2_CHALLENGE_LENGTH 16 +/*#define SSL2_CHALLENGE_LENGTH 32 */ +#define SSL2_MIN_CHALLENGE_LENGTH 16 +#define SSL2_MAX_CHALLENGE_LENGTH 32 +#define SSL2_CONNECTION_ID_LENGTH 16 +#define SSL2_MAX_CONNECTION_ID_LENGTH 16 +#define SSL2_SSL_SESSION_ID_LENGTH 16 +#define SSL2_MAX_CERT_CHALLENGE_LENGTH 32 +#define SSL2_MIN_CERT_CHALLENGE_LENGTH 16 +#define SSL2_MAX_KEY_MATERIAL_LENGTH 24 + +#ifndef HEADER_SSL_LOCL_H +#define CERT char +#endif + +typedef struct ssl2_state_st + { + int three_byte_header; + int clear_text; /* clear text */ + int escape; /* not used in SSLv2 */ + int ssl2_rollback; /* used if SSLv23 rolled back to SSLv2 */ + + /* non-blocking io info, used to make sure the same + * args were passwd */ + unsigned int wnum; /* number of bytes sent so far */ + int wpend_tot; + const unsigned char *wpend_buf; + + int wpend_off; /* offset to data to write */ + int wpend_len; /* number of bytes passwd to write */ + int wpend_ret; /* number of bytes to return to caller */ + + /* buffer raw data */ + int rbuf_left; + int rbuf_offs; + unsigned char *rbuf; + unsigned char *wbuf; + + unsigned char *write_ptr;/* used to point to the start due to + * 2/3 byte header. */ + + unsigned int padding; + unsigned int rlength; /* passed to ssl2_enc */ + int ract_data_length; /* Set when things are encrypted. */ + unsigned int wlength; /* passed to ssl2_enc */ + int wact_data_length; /* Set when things are decrypted. */ + unsigned char *ract_data; + unsigned char *wact_data; + unsigned char *mac_data; + + unsigned char *read_key; + unsigned char *write_key; + + /* Stuff specifically to do with this SSL session */ + unsigned int challenge_length; + unsigned char challenge[SSL2_MAX_CHALLENGE_LENGTH]; + unsigned int conn_id_length; + unsigned char conn_id[SSL2_MAX_CONNECTION_ID_LENGTH]; + unsigned int key_material_length; + unsigned char key_material[SSL2_MAX_KEY_MATERIAL_LENGTH*2]; + + unsigned long read_sequence; + unsigned long write_sequence; + + struct { + unsigned int conn_id_length; + unsigned int cert_type; + unsigned int cert_length; + unsigned int csl; + unsigned int clear; + unsigned int enc; + unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH]; + unsigned int cipher_spec_length; + unsigned int session_id_length; + unsigned int clen; + unsigned int rlen; + } tmp; + } SSL2_STATE; + +/* SSLv2 */ +/* client */ +#define SSL2_ST_SEND_CLIENT_HELLO_A (0x10|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_HELLO_B (0x11|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_HELLO_A (0x20|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_HELLO_B (0x21|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_MASTER_KEY_A (0x30|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_MASTER_KEY_B (0x31|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_FINISHED_A (0x40|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_FINISHED_B (0x41|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_A (0x50|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_B (0x51|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_C (0x52|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_D (0x53|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_VERIFY_A (0x60|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_VERIFY_B (0x61|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_FINISHED_A (0x70|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_FINISHED_B (0x71|SSL_ST_CONNECT) +#define SSL2_ST_CLIENT_START_ENCRYPTION (0x80|SSL_ST_CONNECT) +#define SSL2_ST_X509_GET_CLIENT_CERTIFICATE (0x90|SSL_ST_CONNECT) +/* server */ +#define SSL2_ST_GET_CLIENT_HELLO_A (0x10|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_HELLO_B (0x11|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_HELLO_C (0x12|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_HELLO_A (0x20|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_HELLO_B (0x21|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_MASTER_KEY_A (0x30|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_MASTER_KEY_B (0x31|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_VERIFY_A (0x40|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_VERIFY_B (0x41|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_VERIFY_C (0x42|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_FINISHED_A (0x50|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_FINISHED_B (0x51|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_FINISHED_A (0x60|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_FINISHED_B (0x61|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_A (0x70|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_B (0x71|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_C (0x72|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_D (0x73|SSL_ST_ACCEPT) +#define SSL2_ST_SERVER_START_ENCRYPTION (0x80|SSL_ST_ACCEPT) +#define SSL2_ST_X509_GET_SERVER_CERTIFICATE (0x90|SSL_ST_ACCEPT) + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/src/dep/include/openssl/ssl23.h b/src/dep/include/openssl/ssl23.h index 00422f0..0b60538 100644 --- a/src/dep/include/openssl/ssl23.h +++ b/src/dep/include/openssl/ssl23.h @@ -1,83 +1,83 @@ -/* ssl/ssl23.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_SSL23_H -#define HEADER_SSL23_H - -#ifdef __cplusplus -extern "C" { -#endif - -/*client */ -/* write to server */ -#define SSL23_ST_CW_CLNT_HELLO_A (0x210|SSL_ST_CONNECT) -#define SSL23_ST_CW_CLNT_HELLO_B (0x211|SSL_ST_CONNECT) -/* read from server */ -#define SSL23_ST_CR_SRVR_HELLO_A (0x220|SSL_ST_CONNECT) -#define SSL23_ST_CR_SRVR_HELLO_B (0x221|SSL_ST_CONNECT) - -/* server */ -/* read from client */ -#define SSL23_ST_SR_CLNT_HELLO_A (0x210|SSL_ST_ACCEPT) -#define SSL23_ST_SR_CLNT_HELLO_B (0x211|SSL_ST_ACCEPT) - -#ifdef __cplusplus -} -#endif -#endif - +/* ssl/ssl23.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_SSL23_H +#define HEADER_SSL23_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*client */ +/* write to server */ +#define SSL23_ST_CW_CLNT_HELLO_A (0x210|SSL_ST_CONNECT) +#define SSL23_ST_CW_CLNT_HELLO_B (0x211|SSL_ST_CONNECT) +/* read from server */ +#define SSL23_ST_CR_SRVR_HELLO_A (0x220|SSL_ST_CONNECT) +#define SSL23_ST_CR_SRVR_HELLO_B (0x221|SSL_ST_CONNECT) + +/* server */ +/* read from client */ +#define SSL23_ST_SR_CLNT_HELLO_A (0x210|SSL_ST_ACCEPT) +#define SSL23_ST_SR_CLNT_HELLO_B (0x211|SSL_ST_ACCEPT) + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/src/dep/include/openssl/ssl3.h b/src/dep/include/openssl/ssl3.h index a029a1b..0aebaf3 100644 --- a/src/dep/include/openssl/ssl3.h +++ b/src/dep/include/openssl/ssl3.h @@ -1,555 +1,555 @@ -/* ssl/ssl3.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * ECC cipher suite support in OpenSSL originally developed by - * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. - */ - -#ifndef HEADER_SSL3_H -#define HEADER_SSL3_H - -#ifndef OPENSSL_NO_COMP -#include -#endif -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define SSL3_CK_RSA_NULL_MD5 0x03000001 -#define SSL3_CK_RSA_NULL_SHA 0x03000002 -#define SSL3_CK_RSA_RC4_40_MD5 0x03000003 -#define SSL3_CK_RSA_RC4_128_MD5 0x03000004 -#define SSL3_CK_RSA_RC4_128_SHA 0x03000005 -#define SSL3_CK_RSA_RC2_40_MD5 0x03000006 -#define SSL3_CK_RSA_IDEA_128_SHA 0x03000007 -#define SSL3_CK_RSA_DES_40_CBC_SHA 0x03000008 -#define SSL3_CK_RSA_DES_64_CBC_SHA 0x03000009 -#define SSL3_CK_RSA_DES_192_CBC3_SHA 0x0300000A - -#define SSL3_CK_DH_DSS_DES_40_CBC_SHA 0x0300000B -#define SSL3_CK_DH_DSS_DES_64_CBC_SHA 0x0300000C -#define SSL3_CK_DH_DSS_DES_192_CBC3_SHA 0x0300000D -#define SSL3_CK_DH_RSA_DES_40_CBC_SHA 0x0300000E -#define SSL3_CK_DH_RSA_DES_64_CBC_SHA 0x0300000F -#define SSL3_CK_DH_RSA_DES_192_CBC3_SHA 0x03000010 - -#define SSL3_CK_EDH_DSS_DES_40_CBC_SHA 0x03000011 -#define SSL3_CK_EDH_DSS_DES_64_CBC_SHA 0x03000012 -#define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA 0x03000013 -#define SSL3_CK_EDH_RSA_DES_40_CBC_SHA 0x03000014 -#define SSL3_CK_EDH_RSA_DES_64_CBC_SHA 0x03000015 -#define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA 0x03000016 - -#define SSL3_CK_ADH_RC4_40_MD5 0x03000017 -#define SSL3_CK_ADH_RC4_128_MD5 0x03000018 -#define SSL3_CK_ADH_DES_40_CBC_SHA 0x03000019 -#define SSL3_CK_ADH_DES_64_CBC_SHA 0x0300001A -#define SSL3_CK_ADH_DES_192_CBC_SHA 0x0300001B - -#define SSL3_CK_FZA_DMS_NULL_SHA 0x0300001C -#define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D -#if 0 /* Because it clashes with KRB5, is never used any more, and is safe - to remove according to David Hopwood - of the ietf-tls list */ -#define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E -#endif - -/* VRS Additional Kerberos5 entries - */ -#define SSL3_CK_KRB5_DES_64_CBC_SHA 0x0300001E -#define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x0300001F -#define SSL3_CK_KRB5_RC4_128_SHA 0x03000020 -#define SSL3_CK_KRB5_IDEA_128_CBC_SHA 0x03000021 -#define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000022 -#define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000023 -#define SSL3_CK_KRB5_RC4_128_MD5 0x03000024 -#define SSL3_CK_KRB5_IDEA_128_CBC_MD5 0x03000025 - -#define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000026 -#define SSL3_CK_KRB5_RC2_40_CBC_SHA 0x03000027 -#define SSL3_CK_KRB5_RC4_40_SHA 0x03000028 -#define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000029 -#define SSL3_CK_KRB5_RC2_40_CBC_MD5 0x0300002A -#define SSL3_CK_KRB5_RC4_40_MD5 0x0300002B - -#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" -#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" -#define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" -#define SSL3_TXT_RSA_RC4_128_MD5 "RC4-MD5" -#define SSL3_TXT_RSA_RC4_128_SHA "RC4-SHA" -#define SSL3_TXT_RSA_RC2_40_MD5 "EXP-RC2-CBC-MD5" -#define SSL3_TXT_RSA_IDEA_128_SHA "IDEA-CBC-SHA" -#define SSL3_TXT_RSA_DES_40_CBC_SHA "EXP-DES-CBC-SHA" -#define SSL3_TXT_RSA_DES_64_CBC_SHA "DES-CBC-SHA" -#define SSL3_TXT_RSA_DES_192_CBC3_SHA "DES-CBC3-SHA" - -#define SSL3_TXT_DH_DSS_DES_40_CBC_SHA "EXP-DH-DSS-DES-CBC-SHA" -#define SSL3_TXT_DH_DSS_DES_64_CBC_SHA "DH-DSS-DES-CBC-SHA" -#define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA "DH-DSS-DES-CBC3-SHA" -#define SSL3_TXT_DH_RSA_DES_40_CBC_SHA "EXP-DH-RSA-DES-CBC-SHA" -#define SSL3_TXT_DH_RSA_DES_64_CBC_SHA "DH-RSA-DES-CBC-SHA" -#define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA "DH-RSA-DES-CBC3-SHA" - -#define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA "EXP-EDH-DSS-DES-CBC-SHA" -#define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA "EDH-DSS-DES-CBC-SHA" -#define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA "EDH-DSS-DES-CBC3-SHA" -#define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA "EXP-EDH-RSA-DES-CBC-SHA" -#define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA "EDH-RSA-DES-CBC-SHA" -#define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA "EDH-RSA-DES-CBC3-SHA" - -#define SSL3_TXT_ADH_RC4_40_MD5 "EXP-ADH-RC4-MD5" -#define SSL3_TXT_ADH_RC4_128_MD5 "ADH-RC4-MD5" -#define SSL3_TXT_ADH_DES_40_CBC_SHA "EXP-ADH-DES-CBC-SHA" -#define SSL3_TXT_ADH_DES_64_CBC_SHA "ADH-DES-CBC-SHA" -#define SSL3_TXT_ADH_DES_192_CBC_SHA "ADH-DES-CBC3-SHA" - -#define SSL3_TXT_FZA_DMS_NULL_SHA "FZA-NULL-SHA" -#define SSL3_TXT_FZA_DMS_FZA_SHA "FZA-FZA-CBC-SHA" -#define SSL3_TXT_FZA_DMS_RC4_SHA "FZA-RC4-SHA" - -#define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA" -#define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA" -#define SSL3_TXT_KRB5_RC4_128_SHA "KRB5-RC4-SHA" -#define SSL3_TXT_KRB5_IDEA_128_CBC_SHA "KRB5-IDEA-CBC-SHA" -#define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5" -#define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5" -#define SSL3_TXT_KRB5_RC4_128_MD5 "KRB5-RC4-MD5" -#define SSL3_TXT_KRB5_IDEA_128_CBC_MD5 "KRB5-IDEA-CBC-MD5" - -#define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA" -#define SSL3_TXT_KRB5_RC2_40_CBC_SHA "EXP-KRB5-RC2-CBC-SHA" -#define SSL3_TXT_KRB5_RC4_40_SHA "EXP-KRB5-RC4-SHA" -#define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5" -#define SSL3_TXT_KRB5_RC2_40_CBC_MD5 "EXP-KRB5-RC2-CBC-MD5" -#define SSL3_TXT_KRB5_RC4_40_MD5 "EXP-KRB5-RC4-MD5" - -#define SSL3_SSL_SESSION_ID_LENGTH 32 -#define SSL3_MAX_SSL_SESSION_ID_LENGTH 32 - -#define SSL3_MASTER_SECRET_SIZE 48 -#define SSL3_RANDOM_SIZE 32 -#define SSL3_SESSION_ID_SIZE 32 -#define SSL3_RT_HEADER_LENGTH 5 - -/* Due to MS stuffing up, this can change.... */ -#if defined(OPENSSL_SYS_WIN16) || \ - (defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32)) -#define SSL3_RT_MAX_EXTRA (14000) -#else -#define SSL3_RT_MAX_EXTRA (16384) -#endif - -#define SSL3_RT_MAX_PLAIN_LENGTH 16384 -#ifdef OPENSSL_NO_COMP -#define SSL3_RT_MAX_COMPRESSED_LENGTH SSL3_RT_MAX_PLAIN_LENGTH -#else -#define SSL3_RT_MAX_COMPRESSED_LENGTH (1024+SSL3_RT_MAX_PLAIN_LENGTH) -#endif -#define SSL3_RT_MAX_ENCRYPTED_LENGTH (1024+SSL3_RT_MAX_COMPRESSED_LENGTH) -#define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH) -#define SSL3_RT_MAX_DATA_SIZE (1024*1024) - -#define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54" -#define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52" - -#define SSL3_VERSION 0x0300 -#define SSL3_VERSION_MAJOR 0x03 -#define SSL3_VERSION_MINOR 0x00 - -#define SSL3_RT_CHANGE_CIPHER_SPEC 20 -#define SSL3_RT_ALERT 21 -#define SSL3_RT_HANDSHAKE 22 -#define SSL3_RT_APPLICATION_DATA 23 - -#define SSL3_AL_WARNING 1 -#define SSL3_AL_FATAL 2 - -#define SSL3_AD_CLOSE_NOTIFY 0 -#define SSL3_AD_UNEXPECTED_MESSAGE 10 /* fatal */ -#define SSL3_AD_BAD_RECORD_MAC 20 /* fatal */ -#define SSL3_AD_DECOMPRESSION_FAILURE 30 /* fatal */ -#define SSL3_AD_HANDSHAKE_FAILURE 40 /* fatal */ -#define SSL3_AD_NO_CERTIFICATE 41 -#define SSL3_AD_BAD_CERTIFICATE 42 -#define SSL3_AD_UNSUPPORTED_CERTIFICATE 43 -#define SSL3_AD_CERTIFICATE_REVOKED 44 -#define SSL3_AD_CERTIFICATE_EXPIRED 45 -#define SSL3_AD_CERTIFICATE_UNKNOWN 46 -#define SSL3_AD_ILLEGAL_PARAMETER 47 /* fatal */ - -typedef struct ssl3_record_st - { -/*r */ int type; /* type of record */ -/*rw*/ unsigned int length; /* How many bytes available */ -/*r */ unsigned int off; /* read/write offset into 'buf' */ -/*rw*/ unsigned char *data; /* pointer to the record data */ -/*rw*/ unsigned char *input; /* where the decode bytes are */ -/*r */ unsigned char *comp; /* only used with decompression - malloc()ed */ -/*r */ unsigned long epoch; /* epoch number, needed by DTLS1 */ -/*r */ PQ_64BIT seq_num; /* sequence number, needed by DTLS1 */ - } SSL3_RECORD; - -typedef struct ssl3_buffer_st - { - unsigned char *buf; /* at least SSL3_RT_MAX_PACKET_SIZE bytes, - * see ssl3_setup_buffers() */ - size_t len; /* buffer size */ - int offset; /* where to 'copy from' */ - int left; /* how many bytes left */ - } SSL3_BUFFER; - -#define SSL3_CT_RSA_SIGN 1 -#define SSL3_CT_DSS_SIGN 2 -#define SSL3_CT_RSA_FIXED_DH 3 -#define SSL3_CT_DSS_FIXED_DH 4 -#define SSL3_CT_RSA_EPHEMERAL_DH 5 -#define SSL3_CT_DSS_EPHEMERAL_DH 6 -#define SSL3_CT_FORTEZZA_DMS 20 -/* SSL3_CT_NUMBER is used to size arrays and it must be large - * enough to contain all of the cert types defined either for - * SSLv3 and TLSv1. - */ -#define SSL3_CT_NUMBER 7 - - -#define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001 -#define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 -#define SSL3_FLAGS_POP_BUFFER 0x0004 -#define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 - -typedef struct ssl3_state_st - { - long flags; - int delay_buf_pop_ret; - - unsigned char read_sequence[8]; - unsigned char read_mac_secret[EVP_MAX_MD_SIZE]; - unsigned char write_sequence[8]; - unsigned char write_mac_secret[EVP_MAX_MD_SIZE]; - - unsigned char server_random[SSL3_RANDOM_SIZE]; - unsigned char client_random[SSL3_RANDOM_SIZE]; - - /* flags for countermeasure against known-IV weakness */ - int need_empty_fragments; - int empty_fragment_done; - - SSL3_BUFFER rbuf; /* read IO goes into here */ - SSL3_BUFFER wbuf; /* write IO goes into here */ - - SSL3_RECORD rrec; /* each decoded record goes in here */ - SSL3_RECORD wrec; /* goes out from here */ - - /* storage for Alert/Handshake protocol data received but not - * yet processed by ssl3_read_bytes: */ - unsigned char alert_fragment[2]; - unsigned int alert_fragment_len; - unsigned char handshake_fragment[4]; - unsigned int handshake_fragment_len; - - /* partial write - check the numbers match */ - unsigned int wnum; /* number of bytes sent so far */ - int wpend_tot; /* number bytes written */ - int wpend_type; - int wpend_ret; /* number of bytes submitted */ - const unsigned char *wpend_buf; - - /* used during startup, digest all incoming/outgoing packets */ - EVP_MD_CTX finish_dgst1; - EVP_MD_CTX finish_dgst2; - - /* this is set whenerver we see a change_cipher_spec message - * come in when we are not looking for one */ - int change_cipher_spec; - - int warn_alert; - int fatal_alert; - /* we allow one fatal and one warning alert to be outstanding, - * send close alert via the warning alert */ - int alert_dispatch; - unsigned char send_alert[2]; - - /* This flag is set when we should renegotiate ASAP, basically when - * there is no more data in the read or write buffers */ - int renegotiate; - int total_renegotiations; - int num_renegotiations; - - int in_read_app_data; - - struct { - /* actually only needs to be 16+20 */ - unsigned char cert_verify_md[EVP_MAX_MD_SIZE*2]; - - /* actually only need to be 16+20 for SSLv3 and 12 for TLS */ - unsigned char finish_md[EVP_MAX_MD_SIZE*2]; - int finish_md_len; - unsigned char peer_finish_md[EVP_MAX_MD_SIZE*2]; - int peer_finish_md_len; - - unsigned long message_size; - int message_type; - - /* used to hold the new cipher we are going to use */ - SSL_CIPHER *new_cipher; -#ifndef OPENSSL_NO_DH - DH *dh; -#endif - -#ifndef OPENSSL_NO_ECDH - EC_KEY *ecdh; /* holds short lived ECDH key */ -#endif - - /* used when SSL_ST_FLUSH_DATA is entered */ - int next_state; - - int reuse_message; - - /* used for certificate requests */ - int cert_req; - int ctype_num; - char ctype[SSL3_CT_NUMBER]; - STACK_OF(X509_NAME) *ca_names; - - int use_rsa_tmp; - - int key_block_length; - unsigned char *key_block; - - const EVP_CIPHER *new_sym_enc; - const EVP_MD *new_hash; -#ifndef OPENSSL_NO_COMP - const SSL_COMP *new_compression; -#else - char *new_compression; -#endif - int cert_request; - } tmp; - - } SSL3_STATE; - - -/* SSLv3 */ -/*client */ -/* extra state */ -#define SSL3_ST_CW_FLUSH (0x100|SSL_ST_CONNECT) -/* write to server */ -#define SSL3_ST_CW_CLNT_HELLO_A (0x110|SSL_ST_CONNECT) -#define SSL3_ST_CW_CLNT_HELLO_B (0x111|SSL_ST_CONNECT) -/* read from server */ -#define SSL3_ST_CR_SRVR_HELLO_A (0x120|SSL_ST_CONNECT) -#define SSL3_ST_CR_SRVR_HELLO_B (0x121|SSL_ST_CONNECT) -#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A (0x126|SSL_ST_CONNECT) -#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B (0x127|SSL_ST_CONNECT) -#define SSL3_ST_CR_CERT_A (0x130|SSL_ST_CONNECT) -#define SSL3_ST_CR_CERT_B (0x131|SSL_ST_CONNECT) -#define SSL3_ST_CR_KEY_EXCH_A (0x140|SSL_ST_CONNECT) -#define SSL3_ST_CR_KEY_EXCH_B (0x141|SSL_ST_CONNECT) -#define SSL3_ST_CR_CERT_REQ_A (0x150|SSL_ST_CONNECT) -#define SSL3_ST_CR_CERT_REQ_B (0x151|SSL_ST_CONNECT) -#define SSL3_ST_CR_SRVR_DONE_A (0x160|SSL_ST_CONNECT) -#define SSL3_ST_CR_SRVR_DONE_B (0x161|SSL_ST_CONNECT) -/* write to server */ -#define SSL3_ST_CW_CERT_A (0x170|SSL_ST_CONNECT) -#define SSL3_ST_CW_CERT_B (0x171|SSL_ST_CONNECT) -#define SSL3_ST_CW_CERT_C (0x172|SSL_ST_CONNECT) -#define SSL3_ST_CW_CERT_D (0x173|SSL_ST_CONNECT) -#define SSL3_ST_CW_KEY_EXCH_A (0x180|SSL_ST_CONNECT) -#define SSL3_ST_CW_KEY_EXCH_B (0x181|SSL_ST_CONNECT) -#define SSL3_ST_CW_CERT_VRFY_A (0x190|SSL_ST_CONNECT) -#define SSL3_ST_CW_CERT_VRFY_B (0x191|SSL_ST_CONNECT) -#define SSL3_ST_CW_CHANGE_A (0x1A0|SSL_ST_CONNECT) -#define SSL3_ST_CW_CHANGE_B (0x1A1|SSL_ST_CONNECT) -#define SSL3_ST_CW_FINISHED_A (0x1B0|SSL_ST_CONNECT) -#define SSL3_ST_CW_FINISHED_B (0x1B1|SSL_ST_CONNECT) -/* read from server */ -#define SSL3_ST_CR_CHANGE_A (0x1C0|SSL_ST_CONNECT) -#define SSL3_ST_CR_CHANGE_B (0x1C1|SSL_ST_CONNECT) -#define SSL3_ST_CR_FINISHED_A (0x1D0|SSL_ST_CONNECT) -#define SSL3_ST_CR_FINISHED_B (0x1D1|SSL_ST_CONNECT) - -/* server */ -/* extra state */ -#define SSL3_ST_SW_FLUSH (0x100|SSL_ST_ACCEPT) -/* read from client */ -/* Do not change the number values, they do matter */ -#define SSL3_ST_SR_CLNT_HELLO_A (0x110|SSL_ST_ACCEPT) -#define SSL3_ST_SR_CLNT_HELLO_B (0x111|SSL_ST_ACCEPT) -#define SSL3_ST_SR_CLNT_HELLO_C (0x112|SSL_ST_ACCEPT) -/* write to client */ -#define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A (0x113|SSL_ST_ACCEPT) -#define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B (0x114|SSL_ST_ACCEPT) -#define SSL3_ST_SW_HELLO_REQ_A (0x120|SSL_ST_ACCEPT) -#define SSL3_ST_SW_HELLO_REQ_B (0x121|SSL_ST_ACCEPT) -#define SSL3_ST_SW_HELLO_REQ_C (0x122|SSL_ST_ACCEPT) -#define SSL3_ST_SW_SRVR_HELLO_A (0x130|SSL_ST_ACCEPT) -#define SSL3_ST_SW_SRVR_HELLO_B (0x131|SSL_ST_ACCEPT) -#define SSL3_ST_SW_CERT_A (0x140|SSL_ST_ACCEPT) -#define SSL3_ST_SW_CERT_B (0x141|SSL_ST_ACCEPT) -#define SSL3_ST_SW_KEY_EXCH_A (0x150|SSL_ST_ACCEPT) -#define SSL3_ST_SW_KEY_EXCH_B (0x151|SSL_ST_ACCEPT) -#define SSL3_ST_SW_CERT_REQ_A (0x160|SSL_ST_ACCEPT) -#define SSL3_ST_SW_CERT_REQ_B (0x161|SSL_ST_ACCEPT) -#define SSL3_ST_SW_SRVR_DONE_A (0x170|SSL_ST_ACCEPT) -#define SSL3_ST_SW_SRVR_DONE_B (0x171|SSL_ST_ACCEPT) -/* read from client */ -#define SSL3_ST_SR_CERT_A (0x180|SSL_ST_ACCEPT) -#define SSL3_ST_SR_CERT_B (0x181|SSL_ST_ACCEPT) -#define SSL3_ST_SR_KEY_EXCH_A (0x190|SSL_ST_ACCEPT) -#define SSL3_ST_SR_KEY_EXCH_B (0x191|SSL_ST_ACCEPT) -#define SSL3_ST_SR_CERT_VRFY_A (0x1A0|SSL_ST_ACCEPT) -#define SSL3_ST_SR_CERT_VRFY_B (0x1A1|SSL_ST_ACCEPT) -#define SSL3_ST_SR_CHANGE_A (0x1B0|SSL_ST_ACCEPT) -#define SSL3_ST_SR_CHANGE_B (0x1B1|SSL_ST_ACCEPT) -#define SSL3_ST_SR_FINISHED_A (0x1C0|SSL_ST_ACCEPT) -#define SSL3_ST_SR_FINISHED_B (0x1C1|SSL_ST_ACCEPT) -/* write to client */ -#define SSL3_ST_SW_CHANGE_A (0x1D0|SSL_ST_ACCEPT) -#define SSL3_ST_SW_CHANGE_B (0x1D1|SSL_ST_ACCEPT) -#define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT) -#define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT) - -#define SSL3_MT_HELLO_REQUEST 0 -#define SSL3_MT_CLIENT_HELLO 1 -#define SSL3_MT_SERVER_HELLO 2 -#define SSL3_MT_CERTIFICATE 11 -#define SSL3_MT_SERVER_KEY_EXCHANGE 12 -#define SSL3_MT_CERTIFICATE_REQUEST 13 -#define SSL3_MT_SERVER_DONE 14 -#define SSL3_MT_CERTIFICATE_VERIFY 15 -#define SSL3_MT_CLIENT_KEY_EXCHANGE 16 -#define SSL3_MT_FINISHED 20 -#define DTLS1_MT_HELLO_VERIFY_REQUEST 3 - - -#define SSL3_MT_CCS 1 - -/* These are used when changing over to a new cipher */ -#define SSL3_CC_READ 0x01 -#define SSL3_CC_WRITE 0x02 -#define SSL3_CC_CLIENT 0x10 -#define SSL3_CC_SERVER 0x20 -#define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE) -#define SSL3_CHANGE_CIPHER_SERVER_READ (SSL3_CC_SERVER|SSL3_CC_READ) -#define SSL3_CHANGE_CIPHER_CLIENT_READ (SSL3_CC_CLIENT|SSL3_CC_READ) -#define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE) - -#ifdef __cplusplus -} -#endif -#endif - +/* ssl/ssl3.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECC cipher suite support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_SSL3_H +#define HEADER_SSL3_H + +#ifndef OPENSSL_NO_COMP +#include +#endif +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SSL3_CK_RSA_NULL_MD5 0x03000001 +#define SSL3_CK_RSA_NULL_SHA 0x03000002 +#define SSL3_CK_RSA_RC4_40_MD5 0x03000003 +#define SSL3_CK_RSA_RC4_128_MD5 0x03000004 +#define SSL3_CK_RSA_RC4_128_SHA 0x03000005 +#define SSL3_CK_RSA_RC2_40_MD5 0x03000006 +#define SSL3_CK_RSA_IDEA_128_SHA 0x03000007 +#define SSL3_CK_RSA_DES_40_CBC_SHA 0x03000008 +#define SSL3_CK_RSA_DES_64_CBC_SHA 0x03000009 +#define SSL3_CK_RSA_DES_192_CBC3_SHA 0x0300000A + +#define SSL3_CK_DH_DSS_DES_40_CBC_SHA 0x0300000B +#define SSL3_CK_DH_DSS_DES_64_CBC_SHA 0x0300000C +#define SSL3_CK_DH_DSS_DES_192_CBC3_SHA 0x0300000D +#define SSL3_CK_DH_RSA_DES_40_CBC_SHA 0x0300000E +#define SSL3_CK_DH_RSA_DES_64_CBC_SHA 0x0300000F +#define SSL3_CK_DH_RSA_DES_192_CBC3_SHA 0x03000010 + +#define SSL3_CK_EDH_DSS_DES_40_CBC_SHA 0x03000011 +#define SSL3_CK_EDH_DSS_DES_64_CBC_SHA 0x03000012 +#define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA 0x03000013 +#define SSL3_CK_EDH_RSA_DES_40_CBC_SHA 0x03000014 +#define SSL3_CK_EDH_RSA_DES_64_CBC_SHA 0x03000015 +#define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA 0x03000016 + +#define SSL3_CK_ADH_RC4_40_MD5 0x03000017 +#define SSL3_CK_ADH_RC4_128_MD5 0x03000018 +#define SSL3_CK_ADH_DES_40_CBC_SHA 0x03000019 +#define SSL3_CK_ADH_DES_64_CBC_SHA 0x0300001A +#define SSL3_CK_ADH_DES_192_CBC_SHA 0x0300001B + +#define SSL3_CK_FZA_DMS_NULL_SHA 0x0300001C +#define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D +#if 0 /* Because it clashes with KRB5, is never used any more, and is safe + to remove according to David Hopwood + of the ietf-tls list */ +#define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E +#endif + +/* VRS Additional Kerberos5 entries + */ +#define SSL3_CK_KRB5_DES_64_CBC_SHA 0x0300001E +#define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x0300001F +#define SSL3_CK_KRB5_RC4_128_SHA 0x03000020 +#define SSL3_CK_KRB5_IDEA_128_CBC_SHA 0x03000021 +#define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000022 +#define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000023 +#define SSL3_CK_KRB5_RC4_128_MD5 0x03000024 +#define SSL3_CK_KRB5_IDEA_128_CBC_MD5 0x03000025 + +#define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000026 +#define SSL3_CK_KRB5_RC2_40_CBC_SHA 0x03000027 +#define SSL3_CK_KRB5_RC4_40_SHA 0x03000028 +#define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000029 +#define SSL3_CK_KRB5_RC2_40_CBC_MD5 0x0300002A +#define SSL3_CK_KRB5_RC4_40_MD5 0x0300002B + +#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" +#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" +#define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" +#define SSL3_TXT_RSA_RC4_128_MD5 "RC4-MD5" +#define SSL3_TXT_RSA_RC4_128_SHA "RC4-SHA" +#define SSL3_TXT_RSA_RC2_40_MD5 "EXP-RC2-CBC-MD5" +#define SSL3_TXT_RSA_IDEA_128_SHA "IDEA-CBC-SHA" +#define SSL3_TXT_RSA_DES_40_CBC_SHA "EXP-DES-CBC-SHA" +#define SSL3_TXT_RSA_DES_64_CBC_SHA "DES-CBC-SHA" +#define SSL3_TXT_RSA_DES_192_CBC3_SHA "DES-CBC3-SHA" + +#define SSL3_TXT_DH_DSS_DES_40_CBC_SHA "EXP-DH-DSS-DES-CBC-SHA" +#define SSL3_TXT_DH_DSS_DES_64_CBC_SHA "DH-DSS-DES-CBC-SHA" +#define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA "DH-DSS-DES-CBC3-SHA" +#define SSL3_TXT_DH_RSA_DES_40_CBC_SHA "EXP-DH-RSA-DES-CBC-SHA" +#define SSL3_TXT_DH_RSA_DES_64_CBC_SHA "DH-RSA-DES-CBC-SHA" +#define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA "DH-RSA-DES-CBC3-SHA" + +#define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA "EXP-EDH-DSS-DES-CBC-SHA" +#define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA "EDH-DSS-DES-CBC-SHA" +#define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA "EDH-DSS-DES-CBC3-SHA" +#define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA "EXP-EDH-RSA-DES-CBC-SHA" +#define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA "EDH-RSA-DES-CBC-SHA" +#define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA "EDH-RSA-DES-CBC3-SHA" + +#define SSL3_TXT_ADH_RC4_40_MD5 "EXP-ADH-RC4-MD5" +#define SSL3_TXT_ADH_RC4_128_MD5 "ADH-RC4-MD5" +#define SSL3_TXT_ADH_DES_40_CBC_SHA "EXP-ADH-DES-CBC-SHA" +#define SSL3_TXT_ADH_DES_64_CBC_SHA "ADH-DES-CBC-SHA" +#define SSL3_TXT_ADH_DES_192_CBC_SHA "ADH-DES-CBC3-SHA" + +#define SSL3_TXT_FZA_DMS_NULL_SHA "FZA-NULL-SHA" +#define SSL3_TXT_FZA_DMS_FZA_SHA "FZA-FZA-CBC-SHA" +#define SSL3_TXT_FZA_DMS_RC4_SHA "FZA-RC4-SHA" + +#define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA" +#define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA" +#define SSL3_TXT_KRB5_RC4_128_SHA "KRB5-RC4-SHA" +#define SSL3_TXT_KRB5_IDEA_128_CBC_SHA "KRB5-IDEA-CBC-SHA" +#define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5" +#define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5" +#define SSL3_TXT_KRB5_RC4_128_MD5 "KRB5-RC4-MD5" +#define SSL3_TXT_KRB5_IDEA_128_CBC_MD5 "KRB5-IDEA-CBC-MD5" + +#define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA" +#define SSL3_TXT_KRB5_RC2_40_CBC_SHA "EXP-KRB5-RC2-CBC-SHA" +#define SSL3_TXT_KRB5_RC4_40_SHA "EXP-KRB5-RC4-SHA" +#define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5" +#define SSL3_TXT_KRB5_RC2_40_CBC_MD5 "EXP-KRB5-RC2-CBC-MD5" +#define SSL3_TXT_KRB5_RC4_40_MD5 "EXP-KRB5-RC4-MD5" + +#define SSL3_SSL_SESSION_ID_LENGTH 32 +#define SSL3_MAX_SSL_SESSION_ID_LENGTH 32 + +#define SSL3_MASTER_SECRET_SIZE 48 +#define SSL3_RANDOM_SIZE 32 +#define SSL3_SESSION_ID_SIZE 32 +#define SSL3_RT_HEADER_LENGTH 5 + +/* Due to MS stuffing up, this can change.... */ +#if defined(OPENSSL_SYS_WIN16) || \ + (defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32)) +#define SSL3_RT_MAX_EXTRA (14000) +#else +#define SSL3_RT_MAX_EXTRA (16384) +#endif + +#define SSL3_RT_MAX_PLAIN_LENGTH 16384 +#ifdef OPENSSL_NO_COMP +#define SSL3_RT_MAX_COMPRESSED_LENGTH SSL3_RT_MAX_PLAIN_LENGTH +#else +#define SSL3_RT_MAX_COMPRESSED_LENGTH (1024+SSL3_RT_MAX_PLAIN_LENGTH) +#endif +#define SSL3_RT_MAX_ENCRYPTED_LENGTH (1024+SSL3_RT_MAX_COMPRESSED_LENGTH) +#define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH) +#define SSL3_RT_MAX_DATA_SIZE (1024*1024) + +#define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54" +#define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52" + +#define SSL3_VERSION 0x0300 +#define SSL3_VERSION_MAJOR 0x03 +#define SSL3_VERSION_MINOR 0x00 + +#define SSL3_RT_CHANGE_CIPHER_SPEC 20 +#define SSL3_RT_ALERT 21 +#define SSL3_RT_HANDSHAKE 22 +#define SSL3_RT_APPLICATION_DATA 23 + +#define SSL3_AL_WARNING 1 +#define SSL3_AL_FATAL 2 + +#define SSL3_AD_CLOSE_NOTIFY 0 +#define SSL3_AD_UNEXPECTED_MESSAGE 10 /* fatal */ +#define SSL3_AD_BAD_RECORD_MAC 20 /* fatal */ +#define SSL3_AD_DECOMPRESSION_FAILURE 30 /* fatal */ +#define SSL3_AD_HANDSHAKE_FAILURE 40 /* fatal */ +#define SSL3_AD_NO_CERTIFICATE 41 +#define SSL3_AD_BAD_CERTIFICATE 42 +#define SSL3_AD_UNSUPPORTED_CERTIFICATE 43 +#define SSL3_AD_CERTIFICATE_REVOKED 44 +#define SSL3_AD_CERTIFICATE_EXPIRED 45 +#define SSL3_AD_CERTIFICATE_UNKNOWN 46 +#define SSL3_AD_ILLEGAL_PARAMETER 47 /* fatal */ + +typedef struct ssl3_record_st + { +/*r */ int type; /* type of record */ +/*rw*/ unsigned int length; /* How many bytes available */ +/*r */ unsigned int off; /* read/write offset into 'buf' */ +/*rw*/ unsigned char *data; /* pointer to the record data */ +/*rw*/ unsigned char *input; /* where the decode bytes are */ +/*r */ unsigned char *comp; /* only used with decompression - malloc()ed */ +/*r */ unsigned long epoch; /* epoch number, needed by DTLS1 */ +/*r */ PQ_64BIT seq_num; /* sequence number, needed by DTLS1 */ + } SSL3_RECORD; + +typedef struct ssl3_buffer_st + { + unsigned char *buf; /* at least SSL3_RT_MAX_PACKET_SIZE bytes, + * see ssl3_setup_buffers() */ + size_t len; /* buffer size */ + int offset; /* where to 'copy from' */ + int left; /* how many bytes left */ + } SSL3_BUFFER; + +#define SSL3_CT_RSA_SIGN 1 +#define SSL3_CT_DSS_SIGN 2 +#define SSL3_CT_RSA_FIXED_DH 3 +#define SSL3_CT_DSS_FIXED_DH 4 +#define SSL3_CT_RSA_EPHEMERAL_DH 5 +#define SSL3_CT_DSS_EPHEMERAL_DH 6 +#define SSL3_CT_FORTEZZA_DMS 20 +/* SSL3_CT_NUMBER is used to size arrays and it must be large + * enough to contain all of the cert types defined either for + * SSLv3 and TLSv1. + */ +#define SSL3_CT_NUMBER 7 + + +#define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001 +#define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 +#define SSL3_FLAGS_POP_BUFFER 0x0004 +#define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 + +typedef struct ssl3_state_st + { + long flags; + int delay_buf_pop_ret; + + unsigned char read_sequence[8]; + unsigned char read_mac_secret[EVP_MAX_MD_SIZE]; + unsigned char write_sequence[8]; + unsigned char write_mac_secret[EVP_MAX_MD_SIZE]; + + unsigned char server_random[SSL3_RANDOM_SIZE]; + unsigned char client_random[SSL3_RANDOM_SIZE]; + + /* flags for countermeasure against known-IV weakness */ + int need_empty_fragments; + int empty_fragment_done; + + SSL3_BUFFER rbuf; /* read IO goes into here */ + SSL3_BUFFER wbuf; /* write IO goes into here */ + + SSL3_RECORD rrec; /* each decoded record goes in here */ + SSL3_RECORD wrec; /* goes out from here */ + + /* storage for Alert/Handshake protocol data received but not + * yet processed by ssl3_read_bytes: */ + unsigned char alert_fragment[2]; + unsigned int alert_fragment_len; + unsigned char handshake_fragment[4]; + unsigned int handshake_fragment_len; + + /* partial write - check the numbers match */ + unsigned int wnum; /* number of bytes sent so far */ + int wpend_tot; /* number bytes written */ + int wpend_type; + int wpend_ret; /* number of bytes submitted */ + const unsigned char *wpend_buf; + + /* used during startup, digest all incoming/outgoing packets */ + EVP_MD_CTX finish_dgst1; + EVP_MD_CTX finish_dgst2; + + /* this is set whenerver we see a change_cipher_spec message + * come in when we are not looking for one */ + int change_cipher_spec; + + int warn_alert; + int fatal_alert; + /* we allow one fatal and one warning alert to be outstanding, + * send close alert via the warning alert */ + int alert_dispatch; + unsigned char send_alert[2]; + + /* This flag is set when we should renegotiate ASAP, basically when + * there is no more data in the read or write buffers */ + int renegotiate; + int total_renegotiations; + int num_renegotiations; + + int in_read_app_data; + + struct { + /* actually only needs to be 16+20 */ + unsigned char cert_verify_md[EVP_MAX_MD_SIZE*2]; + + /* actually only need to be 16+20 for SSLv3 and 12 for TLS */ + unsigned char finish_md[EVP_MAX_MD_SIZE*2]; + int finish_md_len; + unsigned char peer_finish_md[EVP_MAX_MD_SIZE*2]; + int peer_finish_md_len; + + unsigned long message_size; + int message_type; + + /* used to hold the new cipher we are going to use */ + SSL_CIPHER *new_cipher; +#ifndef OPENSSL_NO_DH + DH *dh; +#endif + +#ifndef OPENSSL_NO_ECDH + EC_KEY *ecdh; /* holds short lived ECDH key */ +#endif + + /* used when SSL_ST_FLUSH_DATA is entered */ + int next_state; + + int reuse_message; + + /* used for certificate requests */ + int cert_req; + int ctype_num; + char ctype[SSL3_CT_NUMBER]; + STACK_OF(X509_NAME) *ca_names; + + int use_rsa_tmp; + + int key_block_length; + unsigned char *key_block; + + const EVP_CIPHER *new_sym_enc; + const EVP_MD *new_hash; +#ifndef OPENSSL_NO_COMP + const SSL_COMP *new_compression; +#else + char *new_compression; +#endif + int cert_request; + } tmp; + + } SSL3_STATE; + + +/* SSLv3 */ +/*client */ +/* extra state */ +#define SSL3_ST_CW_FLUSH (0x100|SSL_ST_CONNECT) +/* write to server */ +#define SSL3_ST_CW_CLNT_HELLO_A (0x110|SSL_ST_CONNECT) +#define SSL3_ST_CW_CLNT_HELLO_B (0x111|SSL_ST_CONNECT) +/* read from server */ +#define SSL3_ST_CR_SRVR_HELLO_A (0x120|SSL_ST_CONNECT) +#define SSL3_ST_CR_SRVR_HELLO_B (0x121|SSL_ST_CONNECT) +#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A (0x126|SSL_ST_CONNECT) +#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B (0x127|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_A (0x130|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_B (0x131|SSL_ST_CONNECT) +#define SSL3_ST_CR_KEY_EXCH_A (0x140|SSL_ST_CONNECT) +#define SSL3_ST_CR_KEY_EXCH_B (0x141|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_REQ_A (0x150|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_REQ_B (0x151|SSL_ST_CONNECT) +#define SSL3_ST_CR_SRVR_DONE_A (0x160|SSL_ST_CONNECT) +#define SSL3_ST_CR_SRVR_DONE_B (0x161|SSL_ST_CONNECT) +/* write to server */ +#define SSL3_ST_CW_CERT_A (0x170|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_B (0x171|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_C (0x172|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_D (0x173|SSL_ST_CONNECT) +#define SSL3_ST_CW_KEY_EXCH_A (0x180|SSL_ST_CONNECT) +#define SSL3_ST_CW_KEY_EXCH_B (0x181|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_VRFY_A (0x190|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_VRFY_B (0x191|SSL_ST_CONNECT) +#define SSL3_ST_CW_CHANGE_A (0x1A0|SSL_ST_CONNECT) +#define SSL3_ST_CW_CHANGE_B (0x1A1|SSL_ST_CONNECT) +#define SSL3_ST_CW_FINISHED_A (0x1B0|SSL_ST_CONNECT) +#define SSL3_ST_CW_FINISHED_B (0x1B1|SSL_ST_CONNECT) +/* read from server */ +#define SSL3_ST_CR_CHANGE_A (0x1C0|SSL_ST_CONNECT) +#define SSL3_ST_CR_CHANGE_B (0x1C1|SSL_ST_CONNECT) +#define SSL3_ST_CR_FINISHED_A (0x1D0|SSL_ST_CONNECT) +#define SSL3_ST_CR_FINISHED_B (0x1D1|SSL_ST_CONNECT) + +/* server */ +/* extra state */ +#define SSL3_ST_SW_FLUSH (0x100|SSL_ST_ACCEPT) +/* read from client */ +/* Do not change the number values, they do matter */ +#define SSL3_ST_SR_CLNT_HELLO_A (0x110|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CLNT_HELLO_B (0x111|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CLNT_HELLO_C (0x112|SSL_ST_ACCEPT) +/* write to client */ +#define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A (0x113|SSL_ST_ACCEPT) +#define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B (0x114|SSL_ST_ACCEPT) +#define SSL3_ST_SW_HELLO_REQ_A (0x120|SSL_ST_ACCEPT) +#define SSL3_ST_SW_HELLO_REQ_B (0x121|SSL_ST_ACCEPT) +#define SSL3_ST_SW_HELLO_REQ_C (0x122|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_HELLO_A (0x130|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_HELLO_B (0x131|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_A (0x140|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_B (0x141|SSL_ST_ACCEPT) +#define SSL3_ST_SW_KEY_EXCH_A (0x150|SSL_ST_ACCEPT) +#define SSL3_ST_SW_KEY_EXCH_B (0x151|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_REQ_A (0x160|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_REQ_B (0x161|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_DONE_A (0x170|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_DONE_B (0x171|SSL_ST_ACCEPT) +/* read from client */ +#define SSL3_ST_SR_CERT_A (0x180|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CERT_B (0x181|SSL_ST_ACCEPT) +#define SSL3_ST_SR_KEY_EXCH_A (0x190|SSL_ST_ACCEPT) +#define SSL3_ST_SR_KEY_EXCH_B (0x191|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CERT_VRFY_A (0x1A0|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CERT_VRFY_B (0x1A1|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CHANGE_A (0x1B0|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CHANGE_B (0x1B1|SSL_ST_ACCEPT) +#define SSL3_ST_SR_FINISHED_A (0x1C0|SSL_ST_ACCEPT) +#define SSL3_ST_SR_FINISHED_B (0x1C1|SSL_ST_ACCEPT) +/* write to client */ +#define SSL3_ST_SW_CHANGE_A (0x1D0|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CHANGE_B (0x1D1|SSL_ST_ACCEPT) +#define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT) +#define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT) + +#define SSL3_MT_HELLO_REQUEST 0 +#define SSL3_MT_CLIENT_HELLO 1 +#define SSL3_MT_SERVER_HELLO 2 +#define SSL3_MT_CERTIFICATE 11 +#define SSL3_MT_SERVER_KEY_EXCHANGE 12 +#define SSL3_MT_CERTIFICATE_REQUEST 13 +#define SSL3_MT_SERVER_DONE 14 +#define SSL3_MT_CERTIFICATE_VERIFY 15 +#define SSL3_MT_CLIENT_KEY_EXCHANGE 16 +#define SSL3_MT_FINISHED 20 +#define DTLS1_MT_HELLO_VERIFY_REQUEST 3 + + +#define SSL3_MT_CCS 1 + +/* These are used when changing over to a new cipher */ +#define SSL3_CC_READ 0x01 +#define SSL3_CC_WRITE 0x02 +#define SSL3_CC_CLIENT 0x10 +#define SSL3_CC_SERVER 0x20 +#define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE) +#define SSL3_CHANGE_CIPHER_SERVER_READ (SSL3_CC_SERVER|SSL3_CC_READ) +#define SSL3_CHANGE_CIPHER_CLIENT_READ (SSL3_CC_CLIENT|SSL3_CC_READ) +#define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE) + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/src/dep/include/openssl/stack.h b/src/dep/include/openssl/stack.h index 785f7c8..e34d4fc 100644 --- a/src/dep/include/openssl/stack.h +++ b/src/dep/include/openssl/stack.h @@ -1,109 +1,109 @@ -/* crypto/stack/stack.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_STACK_H -#define HEADER_STACK_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct stack_st - { - int num; - char **data; - int sorted; - - int num_alloc; - int (*comp)(const char * const *, const char * const *); - } STACK; - -#define M_sk_num(sk) ((sk) ? (sk)->num:-1) -#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL) - -int sk_num(const STACK *); -char *sk_value(const STACK *, int); - -char *sk_set(STACK *, int, char *); - -STACK *sk_new(int (*cmp)(const char * const *, const char * const *)); -STACK *sk_new_null(void); -void sk_free(STACK *); -void sk_pop_free(STACK *st, void (*func)(void *)); -int sk_insert(STACK *sk,char *data,int where); -char *sk_delete(STACK *st,int loc); -char *sk_delete_ptr(STACK *st, char *p); -int sk_find(STACK *st,char *data); -int sk_find_ex(STACK *st,char *data); -int sk_push(STACK *st,char *data); -int sk_unshift(STACK *st,char *data); -char *sk_shift(STACK *st); -char *sk_pop(STACK *st); -void sk_zero(STACK *st); -int (*sk_set_cmp_func(STACK *sk, int (*c)(const char * const *, - const char * const *))) - (const char * const *, const char * const *); -STACK *sk_dup(STACK *st); -void sk_sort(STACK *st); -int sk_is_sorted(const STACK *st); - -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/stack/stack.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_STACK_H +#define HEADER_STACK_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct stack_st + { + int num; + char **data; + int sorted; + + int num_alloc; + int (*comp)(const char * const *, const char * const *); + } STACK; + +#define M_sk_num(sk) ((sk) ? (sk)->num:-1) +#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL) + +int sk_num(const STACK *); +char *sk_value(const STACK *, int); + +char *sk_set(STACK *, int, char *); + +STACK *sk_new(int (*cmp)(const char * const *, const char * const *)); +STACK *sk_new_null(void); +void sk_free(STACK *); +void sk_pop_free(STACK *st, void (*func)(void *)); +int sk_insert(STACK *sk,char *data,int where); +char *sk_delete(STACK *st,int loc); +char *sk_delete_ptr(STACK *st, char *p); +int sk_find(STACK *st,char *data); +int sk_find_ex(STACK *st,char *data); +int sk_push(STACK *st,char *data); +int sk_unshift(STACK *st,char *data); +char *sk_shift(STACK *st); +char *sk_pop(STACK *st); +void sk_zero(STACK *st); +int (*sk_set_cmp_func(STACK *sk, int (*c)(const char * const *, + const char * const *))) + (const char * const *, const char * const *); +STACK *sk_dup(STACK *st); +void sk_sort(STACK *st); +int sk_is_sorted(const STACK *st); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/store.h b/src/dep/include/openssl/store.h index a1817ab..ad96d2a 100644 --- a/src/dep/include/openssl/store.h +++ b/src/dep/include/openssl/store.h @@ -1,554 +1,554 @@ -/* crypto/store/store.h -*- mode:C; c-file-style: "eay" -*- */ -/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL - * project 2003. - */ -/* ==================================================================== - * Copyright (c) 2003 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_STORE_H -#define HEADER_STORE_H - -#include -#ifndef OPENSSL_NO_DEPRECATED -#include -#include -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Already defined in ossl_typ.h */ -/* typedef struct store_st STORE; */ -/* typedef struct store_method_st STORE_METHOD; */ - - -/* All the following functions return 0, a negative number or NULL on error. - When everything is fine, they return a positive value or a non-NULL - pointer, all depending on their purpose. */ - -/* Creators and destructor. */ -STORE *STORE_new_method(const STORE_METHOD *method); -STORE *STORE_new_engine(ENGINE *engine); -void STORE_free(STORE *ui); - - -/* Give a user interface parametrised control commands. This can be used to - send down an integer, a data pointer or a function pointer, as well as - be used to get information from a STORE. */ -int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)); - -/* A control to set the directory with keys and certificates. Used by the - built-in directory level method. */ -#define STORE_CTRL_SET_DIRECTORY 0x0001 -/* A control to set a file to load. Used by the built-in file level method. */ -#define STORE_CTRL_SET_FILE 0x0002 -/* A control to set a configuration file to load. Can be used by any method - that wishes to load a configuration file. */ -#define STORE_CTRL_SET_CONF_FILE 0x0003 -/* A control to set a the section of the loaded configuration file. Can be - used by any method that wishes to load a configuration file. */ -#define STORE_CTRL_SET_CONF_SECTION 0x0004 - - -/* Some methods may use extra data */ -#define STORE_set_app_data(s,arg) STORE_set_ex_data(s,0,arg) -#define STORE_get_app_data(s) STORE_get_ex_data(s,0) -int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); -int STORE_set_ex_data(STORE *r,int idx,void *arg); -void *STORE_get_ex_data(STORE *r, int idx); - -/* Use specific methods instead of the built-in one */ -const STORE_METHOD *STORE_get_method(STORE *store); -const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth); - -/* The standard OpenSSL methods. */ -/* This is the in-memory method. It does everything except revoking and updating, - and is of course volatile. It's used by other methods that have an in-memory - cache. */ -const STORE_METHOD *STORE_Memory(void); -#if 0 /* Not yet implemented */ -/* This is the directory store. It does everything except revoking and updating, - and uses STORE_Memory() to cache things in memory. */ -const STORE_METHOD *STORE_Directory(void); -/* This is the file store. It does everything except revoking and updating, - and uses STORE_Memory() to cache things in memory. Certificates are added - to it with the store operation, and it will only get cached certificates. */ -const STORE_METHOD *STORE_File(void); -#endif - -/* Store functions take a type code for the type of data they should store - or fetch */ -typedef enum STORE_object_types - { - STORE_OBJECT_TYPE_X509_CERTIFICATE= 0x01, /* X509 * */ - STORE_OBJECT_TYPE_X509_CRL= 0x02, /* X509_CRL * */ - STORE_OBJECT_TYPE_PRIVATE_KEY= 0x03, /* EVP_PKEY * */ - STORE_OBJECT_TYPE_PUBLIC_KEY= 0x04, /* EVP_PKEY * */ - STORE_OBJECT_TYPE_NUMBER= 0x05, /* BIGNUM * */ - STORE_OBJECT_TYPE_ARBITRARY= 0x06, /* BUF_MEM * */ - STORE_OBJECT_TYPE_NUM= 0x06 /* The amount of known - object types */ - } STORE_OBJECT_TYPES; -/* List of text strings corresponding to the object types. */ -extern const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1]; - -/* Some store functions take a parameter list. Those parameters come with - one of the following codes. The comments following the codes below indicate - what type the value should be a pointer to. */ -typedef enum STORE_params - { - STORE_PARAM_EVP_TYPE= 0x01, /* int */ - STORE_PARAM_BITS= 0x02, /* size_t */ - STORE_PARAM_KEY_PARAMETERS= 0x03, /* ??? */ - STORE_PARAM_KEY_NO_PARAMETERS= 0x04, /* N/A */ - STORE_PARAM_AUTH_PASSPHRASE= 0x05, /* char * */ - STORE_PARAM_AUTH_KRB5_TICKET= 0x06, /* void * */ - STORE_PARAM_TYPE_NUM= 0x06 /* The amount of known - parameter types */ - } STORE_PARAM_TYPES; -/* Parameter value sizes. -1 means unknown, anything else is the required size. */ -extern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1]; - -/* Store functions take attribute lists. Those attributes come with codes. - The comments following the codes below indicate what type the value should - be a pointer to. */ -typedef enum STORE_attribs - { - STORE_ATTR_END= 0x00, - STORE_ATTR_FRIENDLYNAME= 0x01, /* C string */ - STORE_ATTR_KEYID= 0x02, /* 160 bit string (SHA1) */ - STORE_ATTR_ISSUERKEYID= 0x03, /* 160 bit string (SHA1) */ - STORE_ATTR_SUBJECTKEYID= 0x04, /* 160 bit string (SHA1) */ - STORE_ATTR_ISSUERSERIALHASH= 0x05, /* 160 bit string (SHA1) */ - STORE_ATTR_ISSUER= 0x06, /* X509_NAME * */ - STORE_ATTR_SERIAL= 0x07, /* BIGNUM * */ - STORE_ATTR_SUBJECT= 0x08, /* X509_NAME * */ - STORE_ATTR_CERTHASH= 0x09, /* 160 bit string (SHA1) */ - STORE_ATTR_EMAIL= 0x0a, /* C string */ - STORE_ATTR_FILENAME= 0x0b, /* C string */ - STORE_ATTR_TYPE_NUM= 0x0b, /* The amount of known - attribute types */ - STORE_ATTR_OR= 0xff /* This is a special - separator, which - expresses the OR - operation. */ - } STORE_ATTR_TYPES; -/* Attribute value sizes. -1 means unknown, anything else is the required size. */ -extern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1]; - -typedef enum STORE_certificate_status - { - STORE_X509_VALID= 0x00, - STORE_X509_EXPIRED= 0x01, - STORE_X509_SUSPENDED= 0x02, - STORE_X509_REVOKED= 0x03 - } STORE_CERTIFICATE_STATUS; - -/* Engine store functions will return a structure that contains all the necessary - * information, including revokation status for certificates. This is really not - * needed for application authors, as the ENGINE framework functions will extract - * the OpenSSL-specific information when at all possible. However, for engine - * authors, it's crucial to know this structure. */ -typedef struct STORE_OBJECT_st - { - STORE_OBJECT_TYPES type; - union - { - struct - { - STORE_CERTIFICATE_STATUS status; - X509 *certificate; - } x509; - X509_CRL *crl; - EVP_PKEY *key; - BIGNUM *number; - BUF_MEM *arbitrary; - } data; - } STORE_OBJECT; -DECLARE_STACK_OF(STORE_OBJECT) -STORE_OBJECT *STORE_OBJECT_new(void); -void STORE_OBJECT_free(STORE_OBJECT *data); - - - -/* The following functions handle the storage. They return 0, a negative number - or NULL on error, anything else on success. */ -X509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[], - OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], - OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); -int STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -void *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -X509 *STORE_list_certificate_next(STORE *e, void *handle); -int STORE_list_certificate_end(STORE *e, void *handle); -int STORE_list_certificate_endp(STORE *e, void *handle); -EVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -EVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_store_private_key(STORE *e, EVP_PKEY *data, - OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); -int STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[], - OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], - OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); -int STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -void *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -EVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle); -int STORE_list_private_key_end(STORE *e, void *handle); -int STORE_list_private_key_endp(STORE *e, void *handle); -EVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_store_public_key(STORE *e, EVP_PKEY *data, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[], - OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], - OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); -int STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -void *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -EVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle); -int STORE_list_public_key_end(STORE *e, void *handle); -int STORE_list_public_key_endp(STORE *e, void *handle); -X509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -X509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[], - OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], - OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); -int STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -void *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -X509_CRL *STORE_list_crl_next(STORE *e, void *handle); -int STORE_list_crl_end(STORE *e, void *handle); -int STORE_list_crl_endp(STORE *e, void *handle); -int STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[], - OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], - OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); -BIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[], - OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], - OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); -BUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); - - -/* Create and manipulate methods */ -STORE_METHOD *STORE_create_method(char *name); -void STORE_destroy_method(STORE_METHOD *store_method); - -/* These callback types are use for store handlers */ -typedef int (*STORE_INITIALISE_FUNC_PTR)(STORE *); -typedef void (*STORE_CLEANUP_FUNC_PTR)(STORE *); -typedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); -typedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); -typedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); -typedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle); -typedef int (*STORE_END_OBJECT_FUNC_PTR)(STORE *, void *handle); -typedef int (*STORE_HANDLE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); -typedef int (*STORE_STORE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, STORE_OBJECT *data, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); -typedef int (*STORE_MODIFY_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); -typedef int (*STORE_GENERIC_FUNC_PTR)(STORE *, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); -typedef int (*STORE_CTRL_FUNC_PTR)(STORE *, int cmd, long l, void *p, void (*f)(void)); - -int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f); -int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f); -int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f); -int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f); -int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f); -int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR store_f); -int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f); -int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f); -int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f); -int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f); -int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f); -int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); -int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); -int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); -int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f); - -STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm); -STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm); -STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm); -STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm); -STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm); -STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm); -STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm); -STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm); -STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm); -STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm); -STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm); -STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm); -STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm); -STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm); -STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm); - -/* Method helper structures and functions. */ - -/* This structure is the result of parsing through the information in a list - of OPENSSL_ITEMs. It stores all the necessary information in a structured - way.*/ -typedef struct STORE_attr_info_st STORE_ATTR_INFO; - -/* Parse a list of OPENSSL_ITEMs and return a pointer to a STORE_ATTR_INFO. - Note that we do this in the list form, since the list of OPENSSL_ITEMs can - come in blocks separated with STORE_ATTR_OR. Note that the value returned - by STORE_parse_attrs_next() must be freed with STORE_ATTR_INFO_free(). */ -void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes); -STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle); -int STORE_parse_attrs_end(void *handle); -int STORE_parse_attrs_endp(void *handle); - -/* Creator and destructor */ -STORE_ATTR_INFO *STORE_ATTR_INFO_new(void); -int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs); - -/* Manipulators */ -char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); -unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, - STORE_ATTR_TYPES code); -X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); -BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); -int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - char *cstr, size_t cstr_size); -int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - unsigned char *sha1str, size_t sha1str_size); -int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - X509_NAME *dn); -int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - BIGNUM *number); -int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - char *cstr, size_t cstr_size); -int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - unsigned char *sha1str, size_t sha1str_size); -int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - X509_NAME *dn); -int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - BIGNUM *number); - -/* Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values - in each contained attribute. */ -int STORE_ATTR_INFO_compare(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); -/* Check if the set of attributes in a is within the range of attributes - set in b. */ -int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); -/* Check if the set of attributes in a are also set in b. */ -int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); -/* Same as STORE_ATTR_INFO_in(), but also checks the attribute values. */ -int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); - - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_STORE_strings(void); - -/* Error codes for the STORE functions. */ - -/* Function codes. */ -#define STORE_F_MEM_DELETE 134 -#define STORE_F_MEM_GENERATE 135 -#define STORE_F_MEM_LIST_END 168 -#define STORE_F_MEM_LIST_NEXT 136 -#define STORE_F_MEM_LIST_START 137 -#define STORE_F_MEM_MODIFY 169 -#define STORE_F_MEM_STORE 138 -#define STORE_F_STORE_ATTR_INFO_GET0_CSTR 139 -#define STORE_F_STORE_ATTR_INFO_GET0_DN 140 -#define STORE_F_STORE_ATTR_INFO_GET0_NUMBER 141 -#define STORE_F_STORE_ATTR_INFO_GET0_SHA1STR 142 -#define STORE_F_STORE_ATTR_INFO_MODIFY_CSTR 143 -#define STORE_F_STORE_ATTR_INFO_MODIFY_DN 144 -#define STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER 145 -#define STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR 146 -#define STORE_F_STORE_ATTR_INFO_SET_CSTR 147 -#define STORE_F_STORE_ATTR_INFO_SET_DN 148 -#define STORE_F_STORE_ATTR_INFO_SET_NUMBER 149 -#define STORE_F_STORE_ATTR_INFO_SET_SHA1STR 150 -#define STORE_F_STORE_CERTIFICATE 170 -#define STORE_F_STORE_CTRL 161 -#define STORE_F_STORE_DELETE_ARBITRARY 158 -#define STORE_F_STORE_DELETE_CERTIFICATE 102 -#define STORE_F_STORE_DELETE_CRL 103 -#define STORE_F_STORE_DELETE_NUMBER 104 -#define STORE_F_STORE_DELETE_PRIVATE_KEY 105 -#define STORE_F_STORE_DELETE_PUBLIC_KEY 106 -#define STORE_F_STORE_GENERATE_CRL 107 -#define STORE_F_STORE_GENERATE_KEY 108 -#define STORE_F_STORE_GET_ARBITRARY 159 -#define STORE_F_STORE_GET_CERTIFICATE 109 -#define STORE_F_STORE_GET_CRL 110 -#define STORE_F_STORE_GET_NUMBER 111 -#define STORE_F_STORE_GET_PRIVATE_KEY 112 -#define STORE_F_STORE_GET_PUBLIC_KEY 113 -#define STORE_F_STORE_LIST_CERTIFICATE_END 114 -#define STORE_F_STORE_LIST_CERTIFICATE_ENDP 153 -#define STORE_F_STORE_LIST_CERTIFICATE_NEXT 115 -#define STORE_F_STORE_LIST_CERTIFICATE_START 116 -#define STORE_F_STORE_LIST_CRL_END 117 -#define STORE_F_STORE_LIST_CRL_ENDP 154 -#define STORE_F_STORE_LIST_CRL_NEXT 118 -#define STORE_F_STORE_LIST_CRL_START 119 -#define STORE_F_STORE_LIST_PRIVATE_KEY_END 120 -#define STORE_F_STORE_LIST_PRIVATE_KEY_ENDP 155 -#define STORE_F_STORE_LIST_PRIVATE_KEY_NEXT 121 -#define STORE_F_STORE_LIST_PRIVATE_KEY_START 122 -#define STORE_F_STORE_LIST_PUBLIC_KEY_END 123 -#define STORE_F_STORE_LIST_PUBLIC_KEY_ENDP 156 -#define STORE_F_STORE_LIST_PUBLIC_KEY_NEXT 124 -#define STORE_F_STORE_LIST_PUBLIC_KEY_START 125 -#define STORE_F_STORE_MODIFY_ARBITRARY 162 -#define STORE_F_STORE_MODIFY_CERTIFICATE 163 -#define STORE_F_STORE_MODIFY_CRL 164 -#define STORE_F_STORE_MODIFY_NUMBER 165 -#define STORE_F_STORE_MODIFY_PRIVATE_KEY 166 -#define STORE_F_STORE_MODIFY_PUBLIC_KEY 167 -#define STORE_F_STORE_NEW_ENGINE 133 -#define STORE_F_STORE_NEW_METHOD 132 -#define STORE_F_STORE_PARSE_ATTRS_END 151 -#define STORE_F_STORE_PARSE_ATTRS_ENDP 172 -#define STORE_F_STORE_PARSE_ATTRS_NEXT 152 -#define STORE_F_STORE_PARSE_ATTRS_START 171 -#define STORE_F_STORE_REVOKE_CERTIFICATE 129 -#define STORE_F_STORE_REVOKE_PRIVATE_KEY 130 -#define STORE_F_STORE_REVOKE_PUBLIC_KEY 131 -#define STORE_F_STORE_STORE_ARBITRARY 157 -#define STORE_F_STORE_STORE_CERTIFICATE 100 -#define STORE_F_STORE_STORE_CRL 101 -#define STORE_F_STORE_STORE_NUMBER 126 -#define STORE_F_STORE_STORE_PRIVATE_KEY 127 -#define STORE_F_STORE_STORE_PUBLIC_KEY 128 - -/* Reason codes. */ -#define STORE_R_ALREADY_HAS_A_VALUE 127 -#define STORE_R_FAILED_DELETING_ARBITRARY 132 -#define STORE_R_FAILED_DELETING_CERTIFICATE 100 -#define STORE_R_FAILED_DELETING_KEY 101 -#define STORE_R_FAILED_DELETING_NUMBER 102 -#define STORE_R_FAILED_GENERATING_CRL 103 -#define STORE_R_FAILED_GENERATING_KEY 104 -#define STORE_R_FAILED_GETTING_ARBITRARY 133 -#define STORE_R_FAILED_GETTING_CERTIFICATE 105 -#define STORE_R_FAILED_GETTING_KEY 106 -#define STORE_R_FAILED_GETTING_NUMBER 107 -#define STORE_R_FAILED_LISTING_CERTIFICATES 108 -#define STORE_R_FAILED_LISTING_KEYS 109 -#define STORE_R_FAILED_MODIFYING_ARBITRARY 138 -#define STORE_R_FAILED_MODIFYING_CERTIFICATE 139 -#define STORE_R_FAILED_MODIFYING_CRL 140 -#define STORE_R_FAILED_MODIFYING_NUMBER 141 -#define STORE_R_FAILED_MODIFYING_PRIVATE_KEY 142 -#define STORE_R_FAILED_MODIFYING_PUBLIC_KEY 143 -#define STORE_R_FAILED_REVOKING_CERTIFICATE 110 -#define STORE_R_FAILED_REVOKING_KEY 111 -#define STORE_R_FAILED_STORING_ARBITRARY 134 -#define STORE_R_FAILED_STORING_CERTIFICATE 112 -#define STORE_R_FAILED_STORING_KEY 113 -#define STORE_R_FAILED_STORING_NUMBER 114 -#define STORE_R_NOT_IMPLEMENTED 128 -#define STORE_R_NO_CONTROL_FUNCTION 144 -#define STORE_R_NO_DELETE_ARBITRARY_FUNCTION 135 -#define STORE_R_NO_DELETE_NUMBER_FUNCTION 115 -#define STORE_R_NO_DELETE_OBJECT_FUNCTION 116 -#define STORE_R_NO_GENERATE_CRL_FUNCTION 117 -#define STORE_R_NO_GENERATE_OBJECT_FUNCTION 118 -#define STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION 136 -#define STORE_R_NO_GET_OBJECT_FUNCTION 119 -#define STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION 120 -#define STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION 131 -#define STORE_R_NO_LIST_OBJECT_END_FUNCTION 121 -#define STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION 122 -#define STORE_R_NO_LIST_OBJECT_START_FUNCTION 123 -#define STORE_R_NO_MODIFY_OBJECT_FUNCTION 145 -#define STORE_R_NO_REVOKE_OBJECT_FUNCTION 124 -#define STORE_R_NO_STORE 129 -#define STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION 137 -#define STORE_R_NO_STORE_OBJECT_FUNCTION 125 -#define STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION 126 -#define STORE_R_NO_VALUE 130 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/store/store.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2003. + */ +/* ==================================================================== + * Copyright (c) 2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_STORE_H +#define HEADER_STORE_H + +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct store_st STORE; */ +/* typedef struct store_method_st STORE_METHOD; */ + + +/* All the following functions return 0, a negative number or NULL on error. + When everything is fine, they return a positive value or a non-NULL + pointer, all depending on their purpose. */ + +/* Creators and destructor. */ +STORE *STORE_new_method(const STORE_METHOD *method); +STORE *STORE_new_engine(ENGINE *engine); +void STORE_free(STORE *ui); + + +/* Give a user interface parametrised control commands. This can be used to + send down an integer, a data pointer or a function pointer, as well as + be used to get information from a STORE. */ +int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)); + +/* A control to set the directory with keys and certificates. Used by the + built-in directory level method. */ +#define STORE_CTRL_SET_DIRECTORY 0x0001 +/* A control to set a file to load. Used by the built-in file level method. */ +#define STORE_CTRL_SET_FILE 0x0002 +/* A control to set a configuration file to load. Can be used by any method + that wishes to load a configuration file. */ +#define STORE_CTRL_SET_CONF_FILE 0x0003 +/* A control to set a the section of the loaded configuration file. Can be + used by any method that wishes to load a configuration file. */ +#define STORE_CTRL_SET_CONF_SECTION 0x0004 + + +/* Some methods may use extra data */ +#define STORE_set_app_data(s,arg) STORE_set_ex_data(s,0,arg) +#define STORE_get_app_data(s) STORE_get_ex_data(s,0) +int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int STORE_set_ex_data(STORE *r,int idx,void *arg); +void *STORE_get_ex_data(STORE *r, int idx); + +/* Use specific methods instead of the built-in one */ +const STORE_METHOD *STORE_get_method(STORE *store); +const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth); + +/* The standard OpenSSL methods. */ +/* This is the in-memory method. It does everything except revoking and updating, + and is of course volatile. It's used by other methods that have an in-memory + cache. */ +const STORE_METHOD *STORE_Memory(void); +#if 0 /* Not yet implemented */ +/* This is the directory store. It does everything except revoking and updating, + and uses STORE_Memory() to cache things in memory. */ +const STORE_METHOD *STORE_Directory(void); +/* This is the file store. It does everything except revoking and updating, + and uses STORE_Memory() to cache things in memory. Certificates are added + to it with the store operation, and it will only get cached certificates. */ +const STORE_METHOD *STORE_File(void); +#endif + +/* Store functions take a type code for the type of data they should store + or fetch */ +typedef enum STORE_object_types + { + STORE_OBJECT_TYPE_X509_CERTIFICATE= 0x01, /* X509 * */ + STORE_OBJECT_TYPE_X509_CRL= 0x02, /* X509_CRL * */ + STORE_OBJECT_TYPE_PRIVATE_KEY= 0x03, /* EVP_PKEY * */ + STORE_OBJECT_TYPE_PUBLIC_KEY= 0x04, /* EVP_PKEY * */ + STORE_OBJECT_TYPE_NUMBER= 0x05, /* BIGNUM * */ + STORE_OBJECT_TYPE_ARBITRARY= 0x06, /* BUF_MEM * */ + STORE_OBJECT_TYPE_NUM= 0x06 /* The amount of known + object types */ + } STORE_OBJECT_TYPES; +/* List of text strings corresponding to the object types. */ +extern const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1]; + +/* Some store functions take a parameter list. Those parameters come with + one of the following codes. The comments following the codes below indicate + what type the value should be a pointer to. */ +typedef enum STORE_params + { + STORE_PARAM_EVP_TYPE= 0x01, /* int */ + STORE_PARAM_BITS= 0x02, /* size_t */ + STORE_PARAM_KEY_PARAMETERS= 0x03, /* ??? */ + STORE_PARAM_KEY_NO_PARAMETERS= 0x04, /* N/A */ + STORE_PARAM_AUTH_PASSPHRASE= 0x05, /* char * */ + STORE_PARAM_AUTH_KRB5_TICKET= 0x06, /* void * */ + STORE_PARAM_TYPE_NUM= 0x06 /* The amount of known + parameter types */ + } STORE_PARAM_TYPES; +/* Parameter value sizes. -1 means unknown, anything else is the required size. */ +extern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1]; + +/* Store functions take attribute lists. Those attributes come with codes. + The comments following the codes below indicate what type the value should + be a pointer to. */ +typedef enum STORE_attribs + { + STORE_ATTR_END= 0x00, + STORE_ATTR_FRIENDLYNAME= 0x01, /* C string */ + STORE_ATTR_KEYID= 0x02, /* 160 bit string (SHA1) */ + STORE_ATTR_ISSUERKEYID= 0x03, /* 160 bit string (SHA1) */ + STORE_ATTR_SUBJECTKEYID= 0x04, /* 160 bit string (SHA1) */ + STORE_ATTR_ISSUERSERIALHASH= 0x05, /* 160 bit string (SHA1) */ + STORE_ATTR_ISSUER= 0x06, /* X509_NAME * */ + STORE_ATTR_SERIAL= 0x07, /* BIGNUM * */ + STORE_ATTR_SUBJECT= 0x08, /* X509_NAME * */ + STORE_ATTR_CERTHASH= 0x09, /* 160 bit string (SHA1) */ + STORE_ATTR_EMAIL= 0x0a, /* C string */ + STORE_ATTR_FILENAME= 0x0b, /* C string */ + STORE_ATTR_TYPE_NUM= 0x0b, /* The amount of known + attribute types */ + STORE_ATTR_OR= 0xff /* This is a special + separator, which + expresses the OR + operation. */ + } STORE_ATTR_TYPES; +/* Attribute value sizes. -1 means unknown, anything else is the required size. */ +extern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1]; + +typedef enum STORE_certificate_status + { + STORE_X509_VALID= 0x00, + STORE_X509_EXPIRED= 0x01, + STORE_X509_SUSPENDED= 0x02, + STORE_X509_REVOKED= 0x03 + } STORE_CERTIFICATE_STATUS; + +/* Engine store functions will return a structure that contains all the necessary + * information, including revokation status for certificates. This is really not + * needed for application authors, as the ENGINE framework functions will extract + * the OpenSSL-specific information when at all possible. However, for engine + * authors, it's crucial to know this structure. */ +typedef struct STORE_OBJECT_st + { + STORE_OBJECT_TYPES type; + union + { + struct + { + STORE_CERTIFICATE_STATUS status; + X509 *certificate; + } x509; + X509_CRL *crl; + EVP_PKEY *key; + BIGNUM *number; + BUF_MEM *arbitrary; + } data; + } STORE_OBJECT; +DECLARE_STACK_OF(STORE_OBJECT) +STORE_OBJECT *STORE_OBJECT_new(void); +void STORE_OBJECT_free(STORE_OBJECT *data); + + + +/* The following functions handle the storage. They return 0, a negative number + or NULL on error, anything else on success. */ +X509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +X509 *STORE_list_certificate_next(STORE *e, void *handle); +int STORE_list_certificate_end(STORE *e, void *handle); +int STORE_list_certificate_endp(STORE *e, void *handle); +EVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +EVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_private_key(STORE *e, EVP_PKEY *data, + OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +int STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +EVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle); +int STORE_list_private_key_end(STORE *e, void *handle); +int STORE_list_private_key_endp(STORE *e, void *handle); +EVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_public_key(STORE *e, EVP_PKEY *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +EVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle); +int STORE_list_public_key_end(STORE *e, void *handle); +int STORE_list_public_key_endp(STORE *e, void *handle); +X509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +X509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +X509_CRL *STORE_list_crl_next(STORE *e, void *handle); +int STORE_list_crl_end(STORE *e, void *handle); +int STORE_list_crl_endp(STORE *e, void *handle); +int STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +BIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +BUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); + + +/* Create and manipulate methods */ +STORE_METHOD *STORE_create_method(char *name); +void STORE_destroy_method(STORE_METHOD *store_method); + +/* These callback types are use for store handlers */ +typedef int (*STORE_INITIALISE_FUNC_PTR)(STORE *); +typedef void (*STORE_CLEANUP_FUNC_PTR)(STORE *); +typedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle); +typedef int (*STORE_END_OBJECT_FUNC_PTR)(STORE *, void *handle); +typedef int (*STORE_HANDLE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_STORE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, STORE_OBJECT *data, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_MODIFY_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_GENERIC_FUNC_PTR)(STORE *, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_CTRL_FUNC_PTR)(STORE *, int cmd, long l, void *p, void (*f)(void)); + +int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f); +int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f); +int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f); +int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f); +int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f); +int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR store_f); +int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f); +int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f); +int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f); +int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f); +int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f); +int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); +int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); +int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); +int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f); + +STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm); +STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm); +STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm); +STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm); +STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm); +STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm); +STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm); +STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm); +STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm); +STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm); +STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm); +STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm); +STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm); +STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm); +STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm); + +/* Method helper structures and functions. */ + +/* This structure is the result of parsing through the information in a list + of OPENSSL_ITEMs. It stores all the necessary information in a structured + way.*/ +typedef struct STORE_attr_info_st STORE_ATTR_INFO; + +/* Parse a list of OPENSSL_ITEMs and return a pointer to a STORE_ATTR_INFO. + Note that we do this in the list form, since the list of OPENSSL_ITEMs can + come in blocks separated with STORE_ATTR_OR. Note that the value returned + by STORE_parse_attrs_next() must be freed with STORE_ATTR_INFO_free(). */ +void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes); +STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle); +int STORE_parse_attrs_end(void *handle); +int STORE_parse_attrs_endp(void *handle); + +/* Creator and destructor */ +STORE_ATTR_INFO *STORE_ATTR_INFO_new(void); +int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs); + +/* Manipulators */ +char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); +unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, + STORE_ATTR_TYPES code); +X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); +BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); +int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + char *cstr, size_t cstr_size); +int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + unsigned char *sha1str, size_t sha1str_size); +int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + X509_NAME *dn); +int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + BIGNUM *number); +int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + char *cstr, size_t cstr_size); +int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + unsigned char *sha1str, size_t sha1str_size); +int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + X509_NAME *dn); +int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + BIGNUM *number); + +/* Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values + in each contained attribute. */ +int STORE_ATTR_INFO_compare(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); +/* Check if the set of attributes in a is within the range of attributes + set in b. */ +int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); +/* Check if the set of attributes in a are also set in b. */ +int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); +/* Same as STORE_ATTR_INFO_in(), but also checks the attribute values. */ +int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_STORE_strings(void); + +/* Error codes for the STORE functions. */ + +/* Function codes. */ +#define STORE_F_MEM_DELETE 134 +#define STORE_F_MEM_GENERATE 135 +#define STORE_F_MEM_LIST_END 168 +#define STORE_F_MEM_LIST_NEXT 136 +#define STORE_F_MEM_LIST_START 137 +#define STORE_F_MEM_MODIFY 169 +#define STORE_F_MEM_STORE 138 +#define STORE_F_STORE_ATTR_INFO_GET0_CSTR 139 +#define STORE_F_STORE_ATTR_INFO_GET0_DN 140 +#define STORE_F_STORE_ATTR_INFO_GET0_NUMBER 141 +#define STORE_F_STORE_ATTR_INFO_GET0_SHA1STR 142 +#define STORE_F_STORE_ATTR_INFO_MODIFY_CSTR 143 +#define STORE_F_STORE_ATTR_INFO_MODIFY_DN 144 +#define STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER 145 +#define STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR 146 +#define STORE_F_STORE_ATTR_INFO_SET_CSTR 147 +#define STORE_F_STORE_ATTR_INFO_SET_DN 148 +#define STORE_F_STORE_ATTR_INFO_SET_NUMBER 149 +#define STORE_F_STORE_ATTR_INFO_SET_SHA1STR 150 +#define STORE_F_STORE_CERTIFICATE 170 +#define STORE_F_STORE_CTRL 161 +#define STORE_F_STORE_DELETE_ARBITRARY 158 +#define STORE_F_STORE_DELETE_CERTIFICATE 102 +#define STORE_F_STORE_DELETE_CRL 103 +#define STORE_F_STORE_DELETE_NUMBER 104 +#define STORE_F_STORE_DELETE_PRIVATE_KEY 105 +#define STORE_F_STORE_DELETE_PUBLIC_KEY 106 +#define STORE_F_STORE_GENERATE_CRL 107 +#define STORE_F_STORE_GENERATE_KEY 108 +#define STORE_F_STORE_GET_ARBITRARY 159 +#define STORE_F_STORE_GET_CERTIFICATE 109 +#define STORE_F_STORE_GET_CRL 110 +#define STORE_F_STORE_GET_NUMBER 111 +#define STORE_F_STORE_GET_PRIVATE_KEY 112 +#define STORE_F_STORE_GET_PUBLIC_KEY 113 +#define STORE_F_STORE_LIST_CERTIFICATE_END 114 +#define STORE_F_STORE_LIST_CERTIFICATE_ENDP 153 +#define STORE_F_STORE_LIST_CERTIFICATE_NEXT 115 +#define STORE_F_STORE_LIST_CERTIFICATE_START 116 +#define STORE_F_STORE_LIST_CRL_END 117 +#define STORE_F_STORE_LIST_CRL_ENDP 154 +#define STORE_F_STORE_LIST_CRL_NEXT 118 +#define STORE_F_STORE_LIST_CRL_START 119 +#define STORE_F_STORE_LIST_PRIVATE_KEY_END 120 +#define STORE_F_STORE_LIST_PRIVATE_KEY_ENDP 155 +#define STORE_F_STORE_LIST_PRIVATE_KEY_NEXT 121 +#define STORE_F_STORE_LIST_PRIVATE_KEY_START 122 +#define STORE_F_STORE_LIST_PUBLIC_KEY_END 123 +#define STORE_F_STORE_LIST_PUBLIC_KEY_ENDP 156 +#define STORE_F_STORE_LIST_PUBLIC_KEY_NEXT 124 +#define STORE_F_STORE_LIST_PUBLIC_KEY_START 125 +#define STORE_F_STORE_MODIFY_ARBITRARY 162 +#define STORE_F_STORE_MODIFY_CERTIFICATE 163 +#define STORE_F_STORE_MODIFY_CRL 164 +#define STORE_F_STORE_MODIFY_NUMBER 165 +#define STORE_F_STORE_MODIFY_PRIVATE_KEY 166 +#define STORE_F_STORE_MODIFY_PUBLIC_KEY 167 +#define STORE_F_STORE_NEW_ENGINE 133 +#define STORE_F_STORE_NEW_METHOD 132 +#define STORE_F_STORE_PARSE_ATTRS_END 151 +#define STORE_F_STORE_PARSE_ATTRS_ENDP 172 +#define STORE_F_STORE_PARSE_ATTRS_NEXT 152 +#define STORE_F_STORE_PARSE_ATTRS_START 171 +#define STORE_F_STORE_REVOKE_CERTIFICATE 129 +#define STORE_F_STORE_REVOKE_PRIVATE_KEY 130 +#define STORE_F_STORE_REVOKE_PUBLIC_KEY 131 +#define STORE_F_STORE_STORE_ARBITRARY 157 +#define STORE_F_STORE_STORE_CERTIFICATE 100 +#define STORE_F_STORE_STORE_CRL 101 +#define STORE_F_STORE_STORE_NUMBER 126 +#define STORE_F_STORE_STORE_PRIVATE_KEY 127 +#define STORE_F_STORE_STORE_PUBLIC_KEY 128 + +/* Reason codes. */ +#define STORE_R_ALREADY_HAS_A_VALUE 127 +#define STORE_R_FAILED_DELETING_ARBITRARY 132 +#define STORE_R_FAILED_DELETING_CERTIFICATE 100 +#define STORE_R_FAILED_DELETING_KEY 101 +#define STORE_R_FAILED_DELETING_NUMBER 102 +#define STORE_R_FAILED_GENERATING_CRL 103 +#define STORE_R_FAILED_GENERATING_KEY 104 +#define STORE_R_FAILED_GETTING_ARBITRARY 133 +#define STORE_R_FAILED_GETTING_CERTIFICATE 105 +#define STORE_R_FAILED_GETTING_KEY 106 +#define STORE_R_FAILED_GETTING_NUMBER 107 +#define STORE_R_FAILED_LISTING_CERTIFICATES 108 +#define STORE_R_FAILED_LISTING_KEYS 109 +#define STORE_R_FAILED_MODIFYING_ARBITRARY 138 +#define STORE_R_FAILED_MODIFYING_CERTIFICATE 139 +#define STORE_R_FAILED_MODIFYING_CRL 140 +#define STORE_R_FAILED_MODIFYING_NUMBER 141 +#define STORE_R_FAILED_MODIFYING_PRIVATE_KEY 142 +#define STORE_R_FAILED_MODIFYING_PUBLIC_KEY 143 +#define STORE_R_FAILED_REVOKING_CERTIFICATE 110 +#define STORE_R_FAILED_REVOKING_KEY 111 +#define STORE_R_FAILED_STORING_ARBITRARY 134 +#define STORE_R_FAILED_STORING_CERTIFICATE 112 +#define STORE_R_FAILED_STORING_KEY 113 +#define STORE_R_FAILED_STORING_NUMBER 114 +#define STORE_R_NOT_IMPLEMENTED 128 +#define STORE_R_NO_CONTROL_FUNCTION 144 +#define STORE_R_NO_DELETE_ARBITRARY_FUNCTION 135 +#define STORE_R_NO_DELETE_NUMBER_FUNCTION 115 +#define STORE_R_NO_DELETE_OBJECT_FUNCTION 116 +#define STORE_R_NO_GENERATE_CRL_FUNCTION 117 +#define STORE_R_NO_GENERATE_OBJECT_FUNCTION 118 +#define STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION 136 +#define STORE_R_NO_GET_OBJECT_FUNCTION 119 +#define STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION 120 +#define STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION 131 +#define STORE_R_NO_LIST_OBJECT_END_FUNCTION 121 +#define STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION 122 +#define STORE_R_NO_LIST_OBJECT_START_FUNCTION 123 +#define STORE_R_NO_MODIFY_OBJECT_FUNCTION 145 +#define STORE_R_NO_REVOKE_OBJECT_FUNCTION 124 +#define STORE_R_NO_STORE 129 +#define STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION 137 +#define STORE_R_NO_STORE_OBJECT_FUNCTION 125 +#define STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION 126 +#define STORE_R_NO_VALUE 130 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/symhacks.h b/src/dep/include/openssl/symhacks.h index 4d1ecc3..15a86f3 100644 --- a/src/dep/include/openssl/symhacks.h +++ b/src/dep/include/openssl/symhacks.h @@ -1,383 +1,383 @@ -/* ==================================================================== - * Copyright (c) 1999 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_SYMHACKS_H -#define HEADER_SYMHACKS_H - -#include - -/* Hacks to solve the problem with linkers incapable of handling very long - symbol names. In the case of VMS, the limit is 31 characters on VMS for - VAX. */ -#ifdef OPENSSL_SYS_VMS - -/* Hack a long name in crypto/ex_data.c */ -#undef CRYPTO_get_ex_data_implementation -#define CRYPTO_get_ex_data_implementation CRYPTO_get_ex_data_impl -#undef CRYPTO_set_ex_data_implementation -#define CRYPTO_set_ex_data_implementation CRYPTO_set_ex_data_impl - -/* Hack a long name in crypto/asn1/a_mbstr.c */ -#undef ASN1_STRING_set_default_mask_asc -#define ASN1_STRING_set_default_mask_asc ASN1_STRING_set_def_mask_asc - -#if 0 /* No longer needed, since safestack macro magic does the job */ -/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */ -#undef i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO -#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO i2d_ASN1_SET_OF_PKCS7_SIGINF -#undef d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO -#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO d2i_ASN1_SET_OF_PKCS7_SIGINF -#endif - -#if 0 /* No longer needed, since safestack macro magic does the job */ -/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */ -#undef i2d_ASN1_SET_OF_PKCS7_RECIP_INFO -#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO i2d_ASN1_SET_OF_PKCS7_RECINF -#undef d2i_ASN1_SET_OF_PKCS7_RECIP_INFO -#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO d2i_ASN1_SET_OF_PKCS7_RECINF -#endif - -#if 0 /* No longer needed, since safestack macro magic does the job */ -/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */ -#undef i2d_ASN1_SET_OF_ACCESS_DESCRIPTION -#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION i2d_ASN1_SET_OF_ACC_DESC -#undef d2i_ASN1_SET_OF_ACCESS_DESCRIPTION -#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION d2i_ASN1_SET_OF_ACC_DESC -#endif - -/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */ -#undef PEM_read_NETSCAPE_CERT_SEQUENCE -#define PEM_read_NETSCAPE_CERT_SEQUENCE PEM_read_NS_CERT_SEQ -#undef PEM_write_NETSCAPE_CERT_SEQUENCE -#define PEM_write_NETSCAPE_CERT_SEQUENCE PEM_write_NS_CERT_SEQ -#undef PEM_read_bio_NETSCAPE_CERT_SEQUENCE -#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE PEM_read_bio_NS_CERT_SEQ -#undef PEM_write_bio_NETSCAPE_CERT_SEQUENCE -#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE PEM_write_bio_NS_CERT_SEQ -#undef PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE -#define PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE PEM_write_cb_bio_NS_CERT_SEQ - -/* Hack the names created with DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO) */ -#undef PEM_read_PKCS8_PRIV_KEY_INFO -#define PEM_read_PKCS8_PRIV_KEY_INFO PEM_read_P8_PRIV_KEY_INFO -#undef PEM_write_PKCS8_PRIV_KEY_INFO -#define PEM_write_PKCS8_PRIV_KEY_INFO PEM_write_P8_PRIV_KEY_INFO -#undef PEM_read_bio_PKCS8_PRIV_KEY_INFO -#define PEM_read_bio_PKCS8_PRIV_KEY_INFO PEM_read_bio_P8_PRIV_KEY_INFO -#undef PEM_write_bio_PKCS8_PRIV_KEY_INFO -#define PEM_write_bio_PKCS8_PRIV_KEY_INFO PEM_write_bio_P8_PRIV_KEY_INFO -#undef PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO -#define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO PEM_wrt_cb_bio_P8_PRIV_KEY_INFO - -/* Hack other PEM names */ -#undef PEM_write_bio_PKCS8PrivateKey_nid -#define PEM_write_bio_PKCS8PrivateKey_nid PEM_write_bio_PKCS8PrivKey_nid - -/* Hack some long X509 names */ -#undef X509_REVOKED_get_ext_by_critical -#define X509_REVOKED_get_ext_by_critical X509_REVOKED_get_ext_by_critic -#undef X509_policy_tree_get0_user_policies -#define X509_policy_tree_get0_user_policies X509_pcy_tree_get0_usr_policies -#undef X509_policy_node_get0_qualifiers -#define X509_policy_node_get0_qualifiers X509_pcy_node_get0_qualifiers -#undef X509_STORE_CTX_get_explicit_policy -#define X509_STORE_CTX_get_explicit_policy X509_STORE_CTX_get_expl_policy - -/* Hack some long CRYPTO names */ -#undef CRYPTO_set_dynlock_destroy_callback -#define CRYPTO_set_dynlock_destroy_callback CRYPTO_set_dynlock_destroy_cb -#undef CRYPTO_set_dynlock_create_callback -#define CRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_cb -#undef CRYPTO_set_dynlock_lock_callback -#define CRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_cb -#undef CRYPTO_get_dynlock_lock_callback -#define CRYPTO_get_dynlock_lock_callback CRYPTO_get_dynlock_lock_cb -#undef CRYPTO_get_dynlock_destroy_callback -#define CRYPTO_get_dynlock_destroy_callback CRYPTO_get_dynlock_destroy_cb -#undef CRYPTO_get_dynlock_create_callback -#define CRYPTO_get_dynlock_create_callback CRYPTO_get_dynlock_create_cb -#undef CRYPTO_set_locked_mem_ex_functions -#define CRYPTO_set_locked_mem_ex_functions CRYPTO_set_locked_mem_ex_funcs -#undef CRYPTO_get_locked_mem_ex_functions -#define CRYPTO_get_locked_mem_ex_functions CRYPTO_get_locked_mem_ex_funcs - -/* Hack some long SSL names */ -#undef SSL_CTX_set_default_verify_paths -#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_verify_paths -#undef SSL_get_ex_data_X509_STORE_CTX_idx -#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_d_X509_STORE_CTX_idx -#undef SSL_add_file_cert_subjects_to_stack -#define SSL_add_file_cert_subjects_to_stack SSL_add_file_cert_subjs_to_stk -#undef SSL_add_dir_cert_subjects_to_stack -#define SSL_add_dir_cert_subjects_to_stack SSL_add_dir_cert_subjs_to_stk -#undef SSL_CTX_use_certificate_chain_file -#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file -#undef SSL_CTX_set_cert_verify_callback -#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb -#undef SSL_CTX_set_default_passwd_cb_userdata -#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud -#undef SSL_COMP_get_compression_methods -#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods - -/* Hack some long ENGINE names */ -#undef ENGINE_get_default_BN_mod_exp_crt -#define ENGINE_get_default_BN_mod_exp_crt ENGINE_get_def_BN_mod_exp_crt -#undef ENGINE_set_default_BN_mod_exp_crt -#define ENGINE_set_default_BN_mod_exp_crt ENGINE_set_def_BN_mod_exp_crt -#undef ENGINE_set_load_privkey_function -#define ENGINE_set_load_privkey_function ENGINE_set_load_privkey_fn -#undef ENGINE_get_load_privkey_function -#define ENGINE_get_load_privkey_function ENGINE_get_load_privkey_fn - -/* Hack some long OCSP names */ -#undef OCSP_REQUEST_get_ext_by_critical -#define OCSP_REQUEST_get_ext_by_critical OCSP_REQUEST_get_ext_by_crit -#undef OCSP_BASICRESP_get_ext_by_critical -#define OCSP_BASICRESP_get_ext_by_critical OCSP_BASICRESP_get_ext_by_crit -#undef OCSP_SINGLERESP_get_ext_by_critical -#define OCSP_SINGLERESP_get_ext_by_critical OCSP_SINGLERESP_get_ext_by_crit - -/* Hack some long DES names */ -#undef _ossl_old_des_ede3_cfb64_encrypt -#define _ossl_old_des_ede3_cfb64_encrypt _ossl_odes_ede3_cfb64_encrypt -#undef _ossl_old_des_ede3_ofb64_encrypt -#define _ossl_old_des_ede3_ofb64_encrypt _ossl_odes_ede3_ofb64_encrypt - -/* Hack some long EVP names */ -#undef OPENSSL_add_all_algorithms_noconf -#define OPENSSL_add_all_algorithms_noconf OPENSSL_add_all_algo_noconf -#undef OPENSSL_add_all_algorithms_conf -#define OPENSSL_add_all_algorithms_conf OPENSSL_add_all_algo_conf - -/* Hack some long EC names */ -#undef EC_GROUP_set_point_conversion_form -#define EC_GROUP_set_point_conversion_form EC_GROUP_set_point_conv_form -#undef EC_GROUP_get_point_conversion_form -#define EC_GROUP_get_point_conversion_form EC_GROUP_get_point_conv_form -#undef EC_GROUP_clear_free_all_extra_data -#define EC_GROUP_clear_free_all_extra_data EC_GROUP_clr_free_all_xtra_data -#undef EC_POINT_set_Jprojective_coordinates_GFp -#define EC_POINT_set_Jprojective_coordinates_GFp \ - EC_POINT_set_Jproj_coords_GFp -#undef EC_POINT_get_Jprojective_coordinates_GFp -#define EC_POINT_get_Jprojective_coordinates_GFp \ - EC_POINT_get_Jproj_coords_GFp -#undef EC_POINT_set_affine_coordinates_GFp -#define EC_POINT_set_affine_coordinates_GFp EC_POINT_set_affine_coords_GFp -#undef EC_POINT_get_affine_coordinates_GFp -#define EC_POINT_get_affine_coordinates_GFp EC_POINT_get_affine_coords_GFp -#undef EC_POINT_set_compressed_coordinates_GFp -#define EC_POINT_set_compressed_coordinates_GFp EC_POINT_set_compr_coords_GFp -#undef EC_POINT_set_affine_coordinates_GF2m -#define EC_POINT_set_affine_coordinates_GF2m EC_POINT_set_affine_coords_GF2m -#undef EC_POINT_get_affine_coordinates_GF2m -#define EC_POINT_get_affine_coordinates_GF2m EC_POINT_get_affine_coords_GF2m -#undef EC_POINT_set_compressed_coordinates_GF2m -#define EC_POINT_set_compressed_coordinates_GF2m \ - EC_POINT_set_compr_coords_GF2m -#undef ec_GF2m_simple_group_clear_finish -#define ec_GF2m_simple_group_clear_finish ec_GF2m_simple_grp_clr_finish -#undef ec_GF2m_simple_group_check_discriminant -#define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim -#undef ec_GF2m_simple_point_clear_finish -#define ec_GF2m_simple_point_clear_finish ec_GF2m_simple_pt_clr_finish -#undef ec_GF2m_simple_point_set_to_infinity -#define ec_GF2m_simple_point_set_to_infinity ec_GF2m_simple_pt_set_to_inf -#undef ec_GF2m_simple_points_make_affine -#define ec_GF2m_simple_points_make_affine ec_GF2m_simple_pts_make_affine -#undef ec_GF2m_simple_point_set_affine_coordinates -#define ec_GF2m_simple_point_set_affine_coordinates \ - ec_GF2m_smp_pt_set_af_coords -#undef ec_GF2m_simple_point_get_affine_coordinates -#define ec_GF2m_simple_point_get_affine_coordinates \ - ec_GF2m_smp_pt_get_af_coords -#undef ec_GF2m_simple_set_compressed_coordinates -#define ec_GF2m_simple_set_compressed_coordinates \ - ec_GF2m_smp_set_compr_coords -#undef ec_GFp_simple_group_set_curve_GFp -#define ec_GFp_simple_group_set_curve_GFp ec_GFp_simple_grp_set_curve_GFp -#undef ec_GFp_simple_group_get_curve_GFp -#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp -#undef ec_GFp_simple_group_clear_finish -#define ec_GFp_simple_group_clear_finish ec_GFp_simple_grp_clear_finish -#undef ec_GFp_simple_group_set_generator -#define ec_GFp_simple_group_set_generator ec_GFp_simple_grp_set_generator -#undef ec_GFp_simple_group_get0_generator -#define ec_GFp_simple_group_get0_generator ec_GFp_simple_grp_gt0_generator -#undef ec_GFp_simple_group_get_cofactor -#define ec_GFp_simple_group_get_cofactor ec_GFp_simple_grp_get_cofactor -#undef ec_GFp_simple_point_clear_finish -#define ec_GFp_simple_point_clear_finish ec_GFp_simple_pt_clear_finish -#undef ec_GFp_simple_point_set_to_infinity -#define ec_GFp_simple_point_set_to_infinity ec_GFp_simple_pt_set_to_inf -#undef ec_GFp_simple_points_make_affine -#define ec_GFp_simple_points_make_affine ec_GFp_simple_pts_make_affine -#undef ec_GFp_simple_group_get_curve_GFp -#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp -#undef ec_GFp_simple_set_Jprojective_coordinates_GFp -#define ec_GFp_simple_set_Jprojective_coordinates_GFp \ - ec_GFp_smp_set_Jproj_coords_GFp -#undef ec_GFp_simple_get_Jprojective_coordinates_GFp -#define ec_GFp_simple_get_Jprojective_coordinates_GFp \ - ec_GFp_smp_get_Jproj_coords_GFp -#undef ec_GFp_simple_point_set_affine_coordinates_GFp -#define ec_GFp_simple_point_set_affine_coordinates_GFp \ - ec_GFp_smp_pt_set_af_coords_GFp -#undef ec_GFp_simple_point_get_affine_coordinates_GFp -#define ec_GFp_simple_point_get_affine_coordinates_GFp \ - ec_GFp_smp_pt_get_af_coords_GFp -#undef ec_GFp_simple_set_compressed_coordinates_GFp -#define ec_GFp_simple_set_compressed_coordinates_GFp \ - ec_GFp_smp_set_compr_coords_GFp -#undef ec_GFp_simple_point_set_affine_coordinates -#define ec_GFp_simple_point_set_affine_coordinates \ - ec_GFp_smp_pt_set_af_coords -#undef ec_GFp_simple_point_get_affine_coordinates -#define ec_GFp_simple_point_get_affine_coordinates \ - ec_GFp_smp_pt_get_af_coords -#undef ec_GFp_simple_set_compressed_coordinates -#define ec_GFp_simple_set_compressed_coordinates \ - ec_GFp_smp_set_compr_coords -#undef ec_GFp_simple_group_check_discriminant -#define ec_GFp_simple_group_check_discriminant ec_GFp_simple_grp_chk_discrim - -/* Hack som long STORE names */ -#undef STORE_method_set_initialise_function -#define STORE_method_set_initialise_function STORE_meth_set_initialise_fn -#undef STORE_method_set_cleanup_function -#define STORE_method_set_cleanup_function STORE_meth_set_cleanup_fn -#undef STORE_method_set_generate_function -#define STORE_method_set_generate_function STORE_meth_set_generate_fn -#undef STORE_method_set_modify_function -#define STORE_method_set_modify_function STORE_meth_set_modify_fn -#undef STORE_method_set_revoke_function -#define STORE_method_set_revoke_function STORE_meth_set_revoke_fn -#undef STORE_method_set_delete_function -#define STORE_method_set_delete_function STORE_meth_set_delete_fn -#undef STORE_method_set_list_start_function -#define STORE_method_set_list_start_function STORE_meth_set_list_start_fn -#undef STORE_method_set_list_next_function -#define STORE_method_set_list_next_function STORE_meth_set_list_next_fn -#undef STORE_method_set_list_end_function -#define STORE_method_set_list_end_function STORE_meth_set_list_end_fn -#undef STORE_method_set_update_store_function -#define STORE_method_set_update_store_function STORE_meth_set_update_store_fn -#undef STORE_method_set_lock_store_function -#define STORE_method_set_lock_store_function STORE_meth_set_lock_store_fn -#undef STORE_method_set_unlock_store_function -#define STORE_method_set_unlock_store_function STORE_meth_set_unlock_store_fn -#undef STORE_method_get_initialise_function -#define STORE_method_get_initialise_function STORE_meth_get_initialise_fn -#undef STORE_method_get_cleanup_function -#define STORE_method_get_cleanup_function STORE_meth_get_cleanup_fn -#undef STORE_method_get_generate_function -#define STORE_method_get_generate_function STORE_meth_get_generate_fn -#undef STORE_method_get_modify_function -#define STORE_method_get_modify_function STORE_meth_get_modify_fn -#undef STORE_method_get_revoke_function -#define STORE_method_get_revoke_function STORE_meth_get_revoke_fn -#undef STORE_method_get_delete_function -#define STORE_method_get_delete_function STORE_meth_get_delete_fn -#undef STORE_method_get_list_start_function -#define STORE_method_get_list_start_function STORE_meth_get_list_start_fn -#undef STORE_method_get_list_next_function -#define STORE_method_get_list_next_function STORE_meth_get_list_next_fn -#undef STORE_method_get_list_end_function -#define STORE_method_get_list_end_function STORE_meth_get_list_end_fn -#undef STORE_method_get_update_store_function -#define STORE_method_get_update_store_function STORE_meth_get_update_store_fn -#undef STORE_method_get_lock_store_function -#define STORE_method_get_lock_store_function STORE_meth_get_lock_store_fn -#undef STORE_method_get_unlock_store_function -#define STORE_method_get_unlock_store_function STORE_meth_get_unlock_store_fn - -#endif /* defined OPENSSL_SYS_VMS */ - - -/* Case insensiteve linking causes problems.... */ -#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) -#undef ERR_load_CRYPTO_strings -#define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings -#undef OCSP_crlID_new -#define OCSP_crlID_new OCSP_crlID2_new - -#undef d2i_ECPARAMETERS -#define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS -#undef i2d_ECPARAMETERS -#define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS -#undef d2i_ECPKPARAMETERS -#define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS -#undef i2d_ECPKPARAMETERS -#define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS - -/* These functions do not seem to exist! However, I'm paranoid... - Original command in x509v3.h: - These functions are being redefined in another directory, - and clash when the linker is case-insensitive, so let's - hide them a little, by giving them an extra 'o' at the - beginning of the name... */ -#undef X509v3_cleanup_extensions -#define X509v3_cleanup_extensions oX509v3_cleanup_extensions -#undef X509v3_add_extension -#define X509v3_add_extension oX509v3_add_extension -#undef X509v3_add_netscape_extensions -#define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions -#undef X509v3_add_standard_extensions -#define X509v3_add_standard_extensions oX509v3_add_standard_extensions - - -#endif - - -#endif /* ! defined HEADER_VMS_IDHACKS_H */ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_SYMHACKS_H +#define HEADER_SYMHACKS_H + +#include + +/* Hacks to solve the problem with linkers incapable of handling very long + symbol names. In the case of VMS, the limit is 31 characters on VMS for + VAX. */ +#ifdef OPENSSL_SYS_VMS + +/* Hack a long name in crypto/ex_data.c */ +#undef CRYPTO_get_ex_data_implementation +#define CRYPTO_get_ex_data_implementation CRYPTO_get_ex_data_impl +#undef CRYPTO_set_ex_data_implementation +#define CRYPTO_set_ex_data_implementation CRYPTO_set_ex_data_impl + +/* Hack a long name in crypto/asn1/a_mbstr.c */ +#undef ASN1_STRING_set_default_mask_asc +#define ASN1_STRING_set_default_mask_asc ASN1_STRING_set_def_mask_asc + +#if 0 /* No longer needed, since safestack macro magic does the job */ +/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */ +#undef i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO +#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO i2d_ASN1_SET_OF_PKCS7_SIGINF +#undef d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO +#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO d2i_ASN1_SET_OF_PKCS7_SIGINF +#endif + +#if 0 /* No longer needed, since safestack macro magic does the job */ +/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */ +#undef i2d_ASN1_SET_OF_PKCS7_RECIP_INFO +#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO i2d_ASN1_SET_OF_PKCS7_RECINF +#undef d2i_ASN1_SET_OF_PKCS7_RECIP_INFO +#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO d2i_ASN1_SET_OF_PKCS7_RECINF +#endif + +#if 0 /* No longer needed, since safestack macro magic does the job */ +/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */ +#undef i2d_ASN1_SET_OF_ACCESS_DESCRIPTION +#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION i2d_ASN1_SET_OF_ACC_DESC +#undef d2i_ASN1_SET_OF_ACCESS_DESCRIPTION +#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION d2i_ASN1_SET_OF_ACC_DESC +#endif + +/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */ +#undef PEM_read_NETSCAPE_CERT_SEQUENCE +#define PEM_read_NETSCAPE_CERT_SEQUENCE PEM_read_NS_CERT_SEQ +#undef PEM_write_NETSCAPE_CERT_SEQUENCE +#define PEM_write_NETSCAPE_CERT_SEQUENCE PEM_write_NS_CERT_SEQ +#undef PEM_read_bio_NETSCAPE_CERT_SEQUENCE +#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE PEM_read_bio_NS_CERT_SEQ +#undef PEM_write_bio_NETSCAPE_CERT_SEQUENCE +#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE PEM_write_bio_NS_CERT_SEQ +#undef PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE +#define PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE PEM_write_cb_bio_NS_CERT_SEQ + +/* Hack the names created with DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO) */ +#undef PEM_read_PKCS8_PRIV_KEY_INFO +#define PEM_read_PKCS8_PRIV_KEY_INFO PEM_read_P8_PRIV_KEY_INFO +#undef PEM_write_PKCS8_PRIV_KEY_INFO +#define PEM_write_PKCS8_PRIV_KEY_INFO PEM_write_P8_PRIV_KEY_INFO +#undef PEM_read_bio_PKCS8_PRIV_KEY_INFO +#define PEM_read_bio_PKCS8_PRIV_KEY_INFO PEM_read_bio_P8_PRIV_KEY_INFO +#undef PEM_write_bio_PKCS8_PRIV_KEY_INFO +#define PEM_write_bio_PKCS8_PRIV_KEY_INFO PEM_write_bio_P8_PRIV_KEY_INFO +#undef PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO +#define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO PEM_wrt_cb_bio_P8_PRIV_KEY_INFO + +/* Hack other PEM names */ +#undef PEM_write_bio_PKCS8PrivateKey_nid +#define PEM_write_bio_PKCS8PrivateKey_nid PEM_write_bio_PKCS8PrivKey_nid + +/* Hack some long X509 names */ +#undef X509_REVOKED_get_ext_by_critical +#define X509_REVOKED_get_ext_by_critical X509_REVOKED_get_ext_by_critic +#undef X509_policy_tree_get0_user_policies +#define X509_policy_tree_get0_user_policies X509_pcy_tree_get0_usr_policies +#undef X509_policy_node_get0_qualifiers +#define X509_policy_node_get0_qualifiers X509_pcy_node_get0_qualifiers +#undef X509_STORE_CTX_get_explicit_policy +#define X509_STORE_CTX_get_explicit_policy X509_STORE_CTX_get_expl_policy + +/* Hack some long CRYPTO names */ +#undef CRYPTO_set_dynlock_destroy_callback +#define CRYPTO_set_dynlock_destroy_callback CRYPTO_set_dynlock_destroy_cb +#undef CRYPTO_set_dynlock_create_callback +#define CRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_cb +#undef CRYPTO_set_dynlock_lock_callback +#define CRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_cb +#undef CRYPTO_get_dynlock_lock_callback +#define CRYPTO_get_dynlock_lock_callback CRYPTO_get_dynlock_lock_cb +#undef CRYPTO_get_dynlock_destroy_callback +#define CRYPTO_get_dynlock_destroy_callback CRYPTO_get_dynlock_destroy_cb +#undef CRYPTO_get_dynlock_create_callback +#define CRYPTO_get_dynlock_create_callback CRYPTO_get_dynlock_create_cb +#undef CRYPTO_set_locked_mem_ex_functions +#define CRYPTO_set_locked_mem_ex_functions CRYPTO_set_locked_mem_ex_funcs +#undef CRYPTO_get_locked_mem_ex_functions +#define CRYPTO_get_locked_mem_ex_functions CRYPTO_get_locked_mem_ex_funcs + +/* Hack some long SSL names */ +#undef SSL_CTX_set_default_verify_paths +#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_verify_paths +#undef SSL_get_ex_data_X509_STORE_CTX_idx +#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_d_X509_STORE_CTX_idx +#undef SSL_add_file_cert_subjects_to_stack +#define SSL_add_file_cert_subjects_to_stack SSL_add_file_cert_subjs_to_stk +#undef SSL_add_dir_cert_subjects_to_stack +#define SSL_add_dir_cert_subjects_to_stack SSL_add_dir_cert_subjs_to_stk +#undef SSL_CTX_use_certificate_chain_file +#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file +#undef SSL_CTX_set_cert_verify_callback +#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb +#undef SSL_CTX_set_default_passwd_cb_userdata +#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud +#undef SSL_COMP_get_compression_methods +#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods + +/* Hack some long ENGINE names */ +#undef ENGINE_get_default_BN_mod_exp_crt +#define ENGINE_get_default_BN_mod_exp_crt ENGINE_get_def_BN_mod_exp_crt +#undef ENGINE_set_default_BN_mod_exp_crt +#define ENGINE_set_default_BN_mod_exp_crt ENGINE_set_def_BN_mod_exp_crt +#undef ENGINE_set_load_privkey_function +#define ENGINE_set_load_privkey_function ENGINE_set_load_privkey_fn +#undef ENGINE_get_load_privkey_function +#define ENGINE_get_load_privkey_function ENGINE_get_load_privkey_fn + +/* Hack some long OCSP names */ +#undef OCSP_REQUEST_get_ext_by_critical +#define OCSP_REQUEST_get_ext_by_critical OCSP_REQUEST_get_ext_by_crit +#undef OCSP_BASICRESP_get_ext_by_critical +#define OCSP_BASICRESP_get_ext_by_critical OCSP_BASICRESP_get_ext_by_crit +#undef OCSP_SINGLERESP_get_ext_by_critical +#define OCSP_SINGLERESP_get_ext_by_critical OCSP_SINGLERESP_get_ext_by_crit + +/* Hack some long DES names */ +#undef _ossl_old_des_ede3_cfb64_encrypt +#define _ossl_old_des_ede3_cfb64_encrypt _ossl_odes_ede3_cfb64_encrypt +#undef _ossl_old_des_ede3_ofb64_encrypt +#define _ossl_old_des_ede3_ofb64_encrypt _ossl_odes_ede3_ofb64_encrypt + +/* Hack some long EVP names */ +#undef OPENSSL_add_all_algorithms_noconf +#define OPENSSL_add_all_algorithms_noconf OPENSSL_add_all_algo_noconf +#undef OPENSSL_add_all_algorithms_conf +#define OPENSSL_add_all_algorithms_conf OPENSSL_add_all_algo_conf + +/* Hack some long EC names */ +#undef EC_GROUP_set_point_conversion_form +#define EC_GROUP_set_point_conversion_form EC_GROUP_set_point_conv_form +#undef EC_GROUP_get_point_conversion_form +#define EC_GROUP_get_point_conversion_form EC_GROUP_get_point_conv_form +#undef EC_GROUP_clear_free_all_extra_data +#define EC_GROUP_clear_free_all_extra_data EC_GROUP_clr_free_all_xtra_data +#undef EC_POINT_set_Jprojective_coordinates_GFp +#define EC_POINT_set_Jprojective_coordinates_GFp \ + EC_POINT_set_Jproj_coords_GFp +#undef EC_POINT_get_Jprojective_coordinates_GFp +#define EC_POINT_get_Jprojective_coordinates_GFp \ + EC_POINT_get_Jproj_coords_GFp +#undef EC_POINT_set_affine_coordinates_GFp +#define EC_POINT_set_affine_coordinates_GFp EC_POINT_set_affine_coords_GFp +#undef EC_POINT_get_affine_coordinates_GFp +#define EC_POINT_get_affine_coordinates_GFp EC_POINT_get_affine_coords_GFp +#undef EC_POINT_set_compressed_coordinates_GFp +#define EC_POINT_set_compressed_coordinates_GFp EC_POINT_set_compr_coords_GFp +#undef EC_POINT_set_affine_coordinates_GF2m +#define EC_POINT_set_affine_coordinates_GF2m EC_POINT_set_affine_coords_GF2m +#undef EC_POINT_get_affine_coordinates_GF2m +#define EC_POINT_get_affine_coordinates_GF2m EC_POINT_get_affine_coords_GF2m +#undef EC_POINT_set_compressed_coordinates_GF2m +#define EC_POINT_set_compressed_coordinates_GF2m \ + EC_POINT_set_compr_coords_GF2m +#undef ec_GF2m_simple_group_clear_finish +#define ec_GF2m_simple_group_clear_finish ec_GF2m_simple_grp_clr_finish +#undef ec_GF2m_simple_group_check_discriminant +#define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim +#undef ec_GF2m_simple_point_clear_finish +#define ec_GF2m_simple_point_clear_finish ec_GF2m_simple_pt_clr_finish +#undef ec_GF2m_simple_point_set_to_infinity +#define ec_GF2m_simple_point_set_to_infinity ec_GF2m_simple_pt_set_to_inf +#undef ec_GF2m_simple_points_make_affine +#define ec_GF2m_simple_points_make_affine ec_GF2m_simple_pts_make_affine +#undef ec_GF2m_simple_point_set_affine_coordinates +#define ec_GF2m_simple_point_set_affine_coordinates \ + ec_GF2m_smp_pt_set_af_coords +#undef ec_GF2m_simple_point_get_affine_coordinates +#define ec_GF2m_simple_point_get_affine_coordinates \ + ec_GF2m_smp_pt_get_af_coords +#undef ec_GF2m_simple_set_compressed_coordinates +#define ec_GF2m_simple_set_compressed_coordinates \ + ec_GF2m_smp_set_compr_coords +#undef ec_GFp_simple_group_set_curve_GFp +#define ec_GFp_simple_group_set_curve_GFp ec_GFp_simple_grp_set_curve_GFp +#undef ec_GFp_simple_group_get_curve_GFp +#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp +#undef ec_GFp_simple_group_clear_finish +#define ec_GFp_simple_group_clear_finish ec_GFp_simple_grp_clear_finish +#undef ec_GFp_simple_group_set_generator +#define ec_GFp_simple_group_set_generator ec_GFp_simple_grp_set_generator +#undef ec_GFp_simple_group_get0_generator +#define ec_GFp_simple_group_get0_generator ec_GFp_simple_grp_gt0_generator +#undef ec_GFp_simple_group_get_cofactor +#define ec_GFp_simple_group_get_cofactor ec_GFp_simple_grp_get_cofactor +#undef ec_GFp_simple_point_clear_finish +#define ec_GFp_simple_point_clear_finish ec_GFp_simple_pt_clear_finish +#undef ec_GFp_simple_point_set_to_infinity +#define ec_GFp_simple_point_set_to_infinity ec_GFp_simple_pt_set_to_inf +#undef ec_GFp_simple_points_make_affine +#define ec_GFp_simple_points_make_affine ec_GFp_simple_pts_make_affine +#undef ec_GFp_simple_group_get_curve_GFp +#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp +#undef ec_GFp_simple_set_Jprojective_coordinates_GFp +#define ec_GFp_simple_set_Jprojective_coordinates_GFp \ + ec_GFp_smp_set_Jproj_coords_GFp +#undef ec_GFp_simple_get_Jprojective_coordinates_GFp +#define ec_GFp_simple_get_Jprojective_coordinates_GFp \ + ec_GFp_smp_get_Jproj_coords_GFp +#undef ec_GFp_simple_point_set_affine_coordinates_GFp +#define ec_GFp_simple_point_set_affine_coordinates_GFp \ + ec_GFp_smp_pt_set_af_coords_GFp +#undef ec_GFp_simple_point_get_affine_coordinates_GFp +#define ec_GFp_simple_point_get_affine_coordinates_GFp \ + ec_GFp_smp_pt_get_af_coords_GFp +#undef ec_GFp_simple_set_compressed_coordinates_GFp +#define ec_GFp_simple_set_compressed_coordinates_GFp \ + ec_GFp_smp_set_compr_coords_GFp +#undef ec_GFp_simple_point_set_affine_coordinates +#define ec_GFp_simple_point_set_affine_coordinates \ + ec_GFp_smp_pt_set_af_coords +#undef ec_GFp_simple_point_get_affine_coordinates +#define ec_GFp_simple_point_get_affine_coordinates \ + ec_GFp_smp_pt_get_af_coords +#undef ec_GFp_simple_set_compressed_coordinates +#define ec_GFp_simple_set_compressed_coordinates \ + ec_GFp_smp_set_compr_coords +#undef ec_GFp_simple_group_check_discriminant +#define ec_GFp_simple_group_check_discriminant ec_GFp_simple_grp_chk_discrim + +/* Hack som long STORE names */ +#undef STORE_method_set_initialise_function +#define STORE_method_set_initialise_function STORE_meth_set_initialise_fn +#undef STORE_method_set_cleanup_function +#define STORE_method_set_cleanup_function STORE_meth_set_cleanup_fn +#undef STORE_method_set_generate_function +#define STORE_method_set_generate_function STORE_meth_set_generate_fn +#undef STORE_method_set_modify_function +#define STORE_method_set_modify_function STORE_meth_set_modify_fn +#undef STORE_method_set_revoke_function +#define STORE_method_set_revoke_function STORE_meth_set_revoke_fn +#undef STORE_method_set_delete_function +#define STORE_method_set_delete_function STORE_meth_set_delete_fn +#undef STORE_method_set_list_start_function +#define STORE_method_set_list_start_function STORE_meth_set_list_start_fn +#undef STORE_method_set_list_next_function +#define STORE_method_set_list_next_function STORE_meth_set_list_next_fn +#undef STORE_method_set_list_end_function +#define STORE_method_set_list_end_function STORE_meth_set_list_end_fn +#undef STORE_method_set_update_store_function +#define STORE_method_set_update_store_function STORE_meth_set_update_store_fn +#undef STORE_method_set_lock_store_function +#define STORE_method_set_lock_store_function STORE_meth_set_lock_store_fn +#undef STORE_method_set_unlock_store_function +#define STORE_method_set_unlock_store_function STORE_meth_set_unlock_store_fn +#undef STORE_method_get_initialise_function +#define STORE_method_get_initialise_function STORE_meth_get_initialise_fn +#undef STORE_method_get_cleanup_function +#define STORE_method_get_cleanup_function STORE_meth_get_cleanup_fn +#undef STORE_method_get_generate_function +#define STORE_method_get_generate_function STORE_meth_get_generate_fn +#undef STORE_method_get_modify_function +#define STORE_method_get_modify_function STORE_meth_get_modify_fn +#undef STORE_method_get_revoke_function +#define STORE_method_get_revoke_function STORE_meth_get_revoke_fn +#undef STORE_method_get_delete_function +#define STORE_method_get_delete_function STORE_meth_get_delete_fn +#undef STORE_method_get_list_start_function +#define STORE_method_get_list_start_function STORE_meth_get_list_start_fn +#undef STORE_method_get_list_next_function +#define STORE_method_get_list_next_function STORE_meth_get_list_next_fn +#undef STORE_method_get_list_end_function +#define STORE_method_get_list_end_function STORE_meth_get_list_end_fn +#undef STORE_method_get_update_store_function +#define STORE_method_get_update_store_function STORE_meth_get_update_store_fn +#undef STORE_method_get_lock_store_function +#define STORE_method_get_lock_store_function STORE_meth_get_lock_store_fn +#undef STORE_method_get_unlock_store_function +#define STORE_method_get_unlock_store_function STORE_meth_get_unlock_store_fn + +#endif /* defined OPENSSL_SYS_VMS */ + + +/* Case insensiteve linking causes problems.... */ +#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) +#undef ERR_load_CRYPTO_strings +#define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings +#undef OCSP_crlID_new +#define OCSP_crlID_new OCSP_crlID2_new + +#undef d2i_ECPARAMETERS +#define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS +#undef i2d_ECPARAMETERS +#define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS +#undef d2i_ECPKPARAMETERS +#define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS +#undef i2d_ECPKPARAMETERS +#define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS + +/* These functions do not seem to exist! However, I'm paranoid... + Original command in x509v3.h: + These functions are being redefined in another directory, + and clash when the linker is case-insensitive, so let's + hide them a little, by giving them an extra 'o' at the + beginning of the name... */ +#undef X509v3_cleanup_extensions +#define X509v3_cleanup_extensions oX509v3_cleanup_extensions +#undef X509v3_add_extension +#define X509v3_add_extension oX509v3_add_extension +#undef X509v3_add_netscape_extensions +#define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions +#undef X509v3_add_standard_extensions +#define X509v3_add_standard_extensions oX509v3_add_standard_extensions + + +#endif + + +#endif /* ! defined HEADER_VMS_IDHACKS_H */ diff --git a/src/dep/include/openssl/tls1.h b/src/dep/include/openssl/tls1.h index 3c71619..04766da 100644 --- a/src/dep/include/openssl/tls1.h +++ b/src/dep/include/openssl/tls1.h @@ -1,274 +1,274 @@ -/* ssl/tls1.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * - * Portions of the attached software ("Contribution") are developed by - * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. - * - * The Contribution is licensed pursuant to the OpenSSL open source - * license provided above. - * - * ECC cipher suite support in OpenSSL originally written by - * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories. - * - */ - -#ifndef HEADER_TLS1_H -#define HEADER_TLS1_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 1 - -#define TLS1_VERSION 0x0301 -#define TLS1_VERSION_MAJOR 0x03 -#define TLS1_VERSION_MINOR 0x01 - -#define TLS1_AD_DECRYPTION_FAILED 21 -#define TLS1_AD_RECORD_OVERFLOW 22 -#define TLS1_AD_UNKNOWN_CA 48 /* fatal */ -#define TLS1_AD_ACCESS_DENIED 49 /* fatal */ -#define TLS1_AD_DECODE_ERROR 50 /* fatal */ -#define TLS1_AD_DECRYPT_ERROR 51 -#define TLS1_AD_EXPORT_RESTRICTION 60 /* fatal */ -#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */ -#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */ -#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */ -#define TLS1_AD_USER_CANCELLED 90 -#define TLS1_AD_NO_RENEGOTIATION 100 - -/* Additional TLS ciphersuites from draft-ietf-tls-56-bit-ciphersuites-00.txt - * (available if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES is defined, see - * s3_lib.c). We actually treat them like SSL 3.0 ciphers, which we probably - * shouldn't. */ -#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5 0x03000060 -#define TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 0x03000061 -#define TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA 0x03000062 -#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA 0x03000063 -#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA 0x03000064 -#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x03000065 -#define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066 - -/* AES ciphersuites from RFC3268 */ - -#define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F -#define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 -#define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 -#define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032 -#define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033 -#define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034 - -#define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035 -#define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036 -#define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037 -#define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038 -#define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039 -#define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A - -/* ECC ciphersuites from draft-ietf-tls-ecc-12.txt with changes soon to be in draft 13 */ -#define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA 0x0300C001 -#define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA 0x0300C002 -#define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C003 -#define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0x0300C004 -#define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0x0300C005 - -#define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA 0x0300C006 -#define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA 0x0300C007 -#define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C008 -#define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0x0300C009 -#define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0x0300C00A - -#define TLS1_CK_ECDH_RSA_WITH_NULL_SHA 0x0300C00B -#define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA 0x0300C00C -#define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA 0x0300C00D -#define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA 0x0300C00E -#define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA 0x0300C00F - -#define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA 0x0300C010 -#define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA 0x0300C011 -#define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA 0x0300C012 -#define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA 0x0300C013 -#define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA 0x0300C014 - -#define TLS1_CK_ECDH_anon_WITH_NULL_SHA 0x0300C015 -#define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA 0x0300C016 -#define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA 0x0300C017 -#define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA 0x0300C018 -#define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA 0x0300C019 - -/* XXX - * Inconsistency alert: - * The OpenSSL names of ciphers with ephemeral DH here include the string - * "DHE", while elsewhere it has always been "EDH". - * (The alias for the list of all such ciphers also is "EDH".) - * The specifications speak of "EDH"; maybe we should allow both forms - * for everything. */ -#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5 "EXP1024-RC4-MD5" -#define TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 "EXP1024-RC2-CBC-MD5" -#define TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DES-CBC-SHA" -#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DHE-DSS-DES-CBC-SHA" -#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA "EXP1024-RC4-SHA" -#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA "EXP1024-DHE-DSS-RC4-SHA" -#define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA" - -/* AES ciphersuites from RFC3268 */ -#define TLS1_TXT_RSA_WITH_AES_128_SHA "AES128-SHA" -#define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AES128-SHA" -#define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AES128-SHA" -#define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AES128-SHA" -#define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AES128-SHA" -#define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AES128-SHA" - -#define TLS1_TXT_RSA_WITH_AES_256_SHA "AES256-SHA" -#define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AES256-SHA" -#define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AES256-SHA" -#define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AES256-SHA" -#define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA" -#define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA" - -/* ECC ciphersuites from draft-ietf-tls-ecc-01.txt (Mar 15, 2001) */ -#define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA" -#define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA" -#define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA" -#define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA "ECDH-ECDSA-AES128-SHA" -#define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA "ECDH-ECDSA-AES256-SHA" - -#define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA "ECDHE-ECDSA-NULL-SHA" -#define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA "ECDHE-ECDSA-RC4-SHA" -#define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "ECDHE-ECDSA-DES-CBC3-SHA" -#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "ECDHE-ECDSA-AES128-SHA" -#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "ECDHE-ECDSA-AES256-SHA" - -#define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA "ECDH-RSA-NULL-SHA" -#define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA "ECDH-RSA-RC4-SHA" -#define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA "ECDH-RSA-DES-CBC3-SHA" -#define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA "ECDH-RSA-AES128-SHA" -#define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA "ECDH-RSA-AES256-SHA" - -#define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA "ECDHE-RSA-NULL-SHA" -#define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA "ECDHE-RSA-RC4-SHA" -#define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA "ECDHE-RSA-DES-CBC3-SHA" -#define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA "ECDHE-RSA-AES128-SHA" -#define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA "ECDHE-RSA-AES256-SHA" - -#define TLS1_TXT_ECDH_anon_WITH_NULL_SHA "AECDH-NULL-SHA" -#define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA "AECDH-RC4-SHA" -#define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA "AECDH-DES-CBC3-SHA" -#define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA "AECDH-AES128-SHA" -#define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA "AECDH-AES256-SHA" - -#define TLS_CT_RSA_SIGN 1 -#define TLS_CT_DSS_SIGN 2 -#define TLS_CT_RSA_FIXED_DH 3 -#define TLS_CT_DSS_FIXED_DH 4 -#define TLS_CT_ECDSA_SIGN 64 -#define TLS_CT_RSA_FIXED_ECDH 65 -#define TLS_CT_ECDSA_FIXED_ECDH 66 -#define TLS_CT_NUMBER 7 - -#define TLS1_FINISH_MAC_LENGTH 12 - -#define TLS_MD_MAX_CONST_SIZE 20 -#define TLS_MD_CLIENT_FINISH_CONST "client finished" -#define TLS_MD_CLIENT_FINISH_CONST_SIZE 15 -#define TLS_MD_SERVER_FINISH_CONST "server finished" -#define TLS_MD_SERVER_FINISH_CONST_SIZE 15 -#define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" -#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 -#define TLS_MD_KEY_EXPANSION_CONST "key expansion" -#define TLS_MD_KEY_EXPANSION_CONST_SIZE 13 -#define TLS_MD_CLIENT_WRITE_KEY_CONST "client write key" -#define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE 16 -#define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" -#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 -#define TLS_MD_IV_BLOCK_CONST "IV block" -#define TLS_MD_IV_BLOCK_CONST_SIZE 8 -#define TLS_MD_MASTER_SECRET_CONST "master secret" -#define TLS_MD_MASTER_SECRET_CONST_SIZE 13 - -#ifdef CHARSET_EBCDIC -#undef TLS_MD_CLIENT_FINISH_CONST -#define TLS_MD_CLIENT_FINISH_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*client finished*/ -#undef TLS_MD_SERVER_FINISH_CONST -#define TLS_MD_SERVER_FINISH_CONST "\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*server finished*/ -#undef TLS_MD_SERVER_WRITE_KEY_CONST -#define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write key*/ -#undef TLS_MD_KEY_EXPANSION_CONST -#define TLS_MD_KEY_EXPANSION_CONST "\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e" /*key expansion*/ -#undef TLS_MD_CLIENT_WRITE_KEY_CONST -#define TLS_MD_CLIENT_WRITE_KEY_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*client write key*/ -#undef TLS_MD_SERVER_WRITE_KEY_CONST -#define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write key*/ -#undef TLS_MD_IV_BLOCK_CONST -#define TLS_MD_IV_BLOCK_CONST "\x49\x56\x20\x62\x6c\x6f\x63\x6b" /*IV block*/ -#undef TLS_MD_MASTER_SECRET_CONST -#define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" /*master secret*/ -#endif - -#ifdef __cplusplus -} -#endif -#endif - - - +/* ssl/tls1.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the OpenSSL open source + * license provided above. + * + * ECC cipher suite support in OpenSSL originally written by + * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories. + * + */ + +#ifndef HEADER_TLS1_H +#define HEADER_TLS1_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 1 + +#define TLS1_VERSION 0x0301 +#define TLS1_VERSION_MAJOR 0x03 +#define TLS1_VERSION_MINOR 0x01 + +#define TLS1_AD_DECRYPTION_FAILED 21 +#define TLS1_AD_RECORD_OVERFLOW 22 +#define TLS1_AD_UNKNOWN_CA 48 /* fatal */ +#define TLS1_AD_ACCESS_DENIED 49 /* fatal */ +#define TLS1_AD_DECODE_ERROR 50 /* fatal */ +#define TLS1_AD_DECRYPT_ERROR 51 +#define TLS1_AD_EXPORT_RESTRICTION 60 /* fatal */ +#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */ +#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */ +#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */ +#define TLS1_AD_USER_CANCELLED 90 +#define TLS1_AD_NO_RENEGOTIATION 100 + +/* Additional TLS ciphersuites from draft-ietf-tls-56-bit-ciphersuites-00.txt + * (available if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES is defined, see + * s3_lib.c). We actually treat them like SSL 3.0 ciphers, which we probably + * shouldn't. */ +#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5 0x03000060 +#define TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 0x03000061 +#define TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA 0x03000062 +#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA 0x03000063 +#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA 0x03000064 +#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x03000065 +#define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066 + +/* AES ciphersuites from RFC3268 */ + +#define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F +#define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 +#define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 +#define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032 +#define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033 +#define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034 + +#define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035 +#define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036 +#define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037 +#define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038 +#define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039 +#define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A + +/* ECC ciphersuites from draft-ietf-tls-ecc-12.txt with changes soon to be in draft 13 */ +#define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA 0x0300C001 +#define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA 0x0300C002 +#define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C003 +#define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0x0300C004 +#define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0x0300C005 + +#define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA 0x0300C006 +#define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA 0x0300C007 +#define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C008 +#define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0x0300C009 +#define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0x0300C00A + +#define TLS1_CK_ECDH_RSA_WITH_NULL_SHA 0x0300C00B +#define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA 0x0300C00C +#define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA 0x0300C00D +#define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA 0x0300C00E +#define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA 0x0300C00F + +#define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA 0x0300C010 +#define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA 0x0300C011 +#define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA 0x0300C012 +#define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA 0x0300C013 +#define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA 0x0300C014 + +#define TLS1_CK_ECDH_anon_WITH_NULL_SHA 0x0300C015 +#define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA 0x0300C016 +#define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA 0x0300C017 +#define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA 0x0300C018 +#define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA 0x0300C019 + +/* XXX + * Inconsistency alert: + * The OpenSSL names of ciphers with ephemeral DH here include the string + * "DHE", while elsewhere it has always been "EDH". + * (The alias for the list of all such ciphers also is "EDH".) + * The specifications speak of "EDH"; maybe we should allow both forms + * for everything. */ +#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5 "EXP1024-RC4-MD5" +#define TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 "EXP1024-RC2-CBC-MD5" +#define TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DES-CBC-SHA" +#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DHE-DSS-DES-CBC-SHA" +#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA "EXP1024-RC4-SHA" +#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA "EXP1024-DHE-DSS-RC4-SHA" +#define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA" + +/* AES ciphersuites from RFC3268 */ +#define TLS1_TXT_RSA_WITH_AES_128_SHA "AES128-SHA" +#define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AES128-SHA" +#define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AES128-SHA" +#define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AES128-SHA" +#define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AES128-SHA" +#define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AES128-SHA" + +#define TLS1_TXT_RSA_WITH_AES_256_SHA "AES256-SHA" +#define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AES256-SHA" +#define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AES256-SHA" +#define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AES256-SHA" +#define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA" +#define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA" + +/* ECC ciphersuites from draft-ietf-tls-ecc-01.txt (Mar 15, 2001) */ +#define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA "ECDH-ECDSA-AES128-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA "ECDH-ECDSA-AES256-SHA" + +#define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA "ECDHE-ECDSA-NULL-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA "ECDHE-ECDSA-RC4-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "ECDHE-ECDSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "ECDHE-ECDSA-AES128-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "ECDHE-ECDSA-AES256-SHA" + +#define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA "ECDH-RSA-NULL-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA "ECDH-RSA-RC4-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA "ECDH-RSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA "ECDH-RSA-AES128-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA "ECDH-RSA-AES256-SHA" + +#define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA "ECDHE-RSA-NULL-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA "ECDHE-RSA-RC4-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA "ECDHE-RSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA "ECDHE-RSA-AES128-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA "ECDHE-RSA-AES256-SHA" + +#define TLS1_TXT_ECDH_anon_WITH_NULL_SHA "AECDH-NULL-SHA" +#define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA "AECDH-RC4-SHA" +#define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA "AECDH-DES-CBC3-SHA" +#define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA "AECDH-AES128-SHA" +#define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA "AECDH-AES256-SHA" + +#define TLS_CT_RSA_SIGN 1 +#define TLS_CT_DSS_SIGN 2 +#define TLS_CT_RSA_FIXED_DH 3 +#define TLS_CT_DSS_FIXED_DH 4 +#define TLS_CT_ECDSA_SIGN 64 +#define TLS_CT_RSA_FIXED_ECDH 65 +#define TLS_CT_ECDSA_FIXED_ECDH 66 +#define TLS_CT_NUMBER 7 + +#define TLS1_FINISH_MAC_LENGTH 12 + +#define TLS_MD_MAX_CONST_SIZE 20 +#define TLS_MD_CLIENT_FINISH_CONST "client finished" +#define TLS_MD_CLIENT_FINISH_CONST_SIZE 15 +#define TLS_MD_SERVER_FINISH_CONST "server finished" +#define TLS_MD_SERVER_FINISH_CONST_SIZE 15 +#define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" +#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 +#define TLS_MD_KEY_EXPANSION_CONST "key expansion" +#define TLS_MD_KEY_EXPANSION_CONST_SIZE 13 +#define TLS_MD_CLIENT_WRITE_KEY_CONST "client write key" +#define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE 16 +#define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" +#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 +#define TLS_MD_IV_BLOCK_CONST "IV block" +#define TLS_MD_IV_BLOCK_CONST_SIZE 8 +#define TLS_MD_MASTER_SECRET_CONST "master secret" +#define TLS_MD_MASTER_SECRET_CONST_SIZE 13 + +#ifdef CHARSET_EBCDIC +#undef TLS_MD_CLIENT_FINISH_CONST +#define TLS_MD_CLIENT_FINISH_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*client finished*/ +#undef TLS_MD_SERVER_FINISH_CONST +#define TLS_MD_SERVER_FINISH_CONST "\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*server finished*/ +#undef TLS_MD_SERVER_WRITE_KEY_CONST +#define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write key*/ +#undef TLS_MD_KEY_EXPANSION_CONST +#define TLS_MD_KEY_EXPANSION_CONST "\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e" /*key expansion*/ +#undef TLS_MD_CLIENT_WRITE_KEY_CONST +#define TLS_MD_CLIENT_WRITE_KEY_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*client write key*/ +#undef TLS_MD_SERVER_WRITE_KEY_CONST +#define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write key*/ +#undef TLS_MD_IV_BLOCK_CONST +#define TLS_MD_IV_BLOCK_CONST "\x49\x56\x20\x62\x6c\x6f\x63\x6b" /*IV block*/ +#undef TLS_MD_MASTER_SECRET_CONST +#define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" /*master secret*/ +#endif + +#ifdef __cplusplus +} +#endif +#endif + + + diff --git a/src/dep/include/openssl/tmdiff.h b/src/dep/include/openssl/tmdiff.h index e508346..1ddb28b 100644 --- a/src/dep/include/openssl/tmdiff.h +++ b/src/dep/include/openssl/tmdiff.h @@ -1,93 +1,93 @@ -/* crypto/tmdiff.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -/* Header for dynamic hash table routines - * Author - Eric Young - */ -/* ... erm yeah, "dynamic hash tables" you say? - * - * And what would dynamic hash tables have to do with any of this code *now*? - * AFAICS, this code is only referenced by crypto/bn/exp.c which is an unused - * file that I doubt compiles any more. speed.c is the only thing that could - * use this (and it has nothing to do with hash tables), yet it instead has its - * own duplication of all this stuff and looks, if anything, more complete. See - * the corresponding note in apps/speed.c. - * The Bemused - Geoff - */ - -#ifndef HEADER_TMDIFF_H -#define HEADER_TMDIFF_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct ms_tm MS_TM; - -MS_TM *ms_time_new(void ); -void ms_time_free(MS_TM *a); -void ms_time_get(MS_TM *a); -double ms_time_diff(MS_TM *start, MS_TM *end); -int ms_time_cmp(const MS_TM *ap, const MS_TM *bp); - -#ifdef __cplusplus -} -#endif - -#endif - +/* crypto/tmdiff.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* Header for dynamic hash table routines + * Author - Eric Young + */ +/* ... erm yeah, "dynamic hash tables" you say? + * + * And what would dynamic hash tables have to do with any of this code *now*? + * AFAICS, this code is only referenced by crypto/bn/exp.c which is an unused + * file that I doubt compiles any more. speed.c is the only thing that could + * use this (and it has nothing to do with hash tables), yet it instead has its + * own duplication of all this stuff and looks, if anything, more complete. See + * the corresponding note in apps/speed.c. + * The Bemused - Geoff + */ + +#ifndef HEADER_TMDIFF_H +#define HEADER_TMDIFF_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ms_tm MS_TM; + +MS_TM *ms_time_new(void ); +void ms_time_free(MS_TM *a); +void ms_time_get(MS_TM *a); +double ms_time_diff(MS_TM *start, MS_TM *end); +int ms_time_cmp(const MS_TM *ap, const MS_TM *bp); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/dep/include/openssl/txt_db.h b/src/dep/include/openssl/txt_db.h index 3c392f1..fc1a63e 100644 --- a/src/dep/include/openssl/txt_db.h +++ b/src/dep/include/openssl/txt_db.h @@ -1,109 +1,109 @@ -/* crypto/txt_db/txt_db.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_TXT_DB_H -#define HEADER_TXT_DB_H - -#include -#ifndef OPENSSL_NO_BIO -#include -#endif -#include -#include - -#define DB_ERROR_OK 0 -#define DB_ERROR_MALLOC 1 -#define DB_ERROR_INDEX_CLASH 2 -#define DB_ERROR_INDEX_OUT_OF_RANGE 3 -#define DB_ERROR_NO_INDEX 4 -#define DB_ERROR_INSERT_INDEX_CLASH 5 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct txt_db_st - { - int num_fields; - STACK /* char ** */ *data; - LHASH **index; - int (**qual)(char **); - long error; - long arg1; - long arg2; - char **arg_row; - } TXT_DB; - -#ifndef OPENSSL_NO_BIO -TXT_DB *TXT_DB_read(BIO *in, int num); -long TXT_DB_write(BIO *out, TXT_DB *db); -#else -TXT_DB *TXT_DB_read(char *in, int num); -long TXT_DB_write(char *out, TXT_DB *db); -#endif -int TXT_DB_create_index(TXT_DB *db,int field,int (*qual)(char **), - LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp); -void TXT_DB_free(TXT_DB *db); -char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value); -int TXT_DB_insert(TXT_DB *db,char **value); - -#ifdef __cplusplus -} -#endif - -#endif +/* crypto/txt_db/txt_db.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_TXT_DB_H +#define HEADER_TXT_DB_H + +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include + +#define DB_ERROR_OK 0 +#define DB_ERROR_MALLOC 1 +#define DB_ERROR_INDEX_CLASH 2 +#define DB_ERROR_INDEX_OUT_OF_RANGE 3 +#define DB_ERROR_NO_INDEX 4 +#define DB_ERROR_INSERT_INDEX_CLASH 5 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct txt_db_st + { + int num_fields; + STACK /* char ** */ *data; + LHASH **index; + int (**qual)(char **); + long error; + long arg1; + long arg2; + char **arg_row; + } TXT_DB; + +#ifndef OPENSSL_NO_BIO +TXT_DB *TXT_DB_read(BIO *in, int num); +long TXT_DB_write(BIO *out, TXT_DB *db); +#else +TXT_DB *TXT_DB_read(char *in, int num); +long TXT_DB_write(char *out, TXT_DB *db); +#endif +int TXT_DB_create_index(TXT_DB *db,int field,int (*qual)(char **), + LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp); +void TXT_DB_free(TXT_DB *db); +char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value); +int TXT_DB_insert(TXT_DB *db,char **value); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/include/openssl/ui.h b/src/dep/include/openssl/ui.h index c5637e4..874898f 100644 --- a/src/dep/include/openssl/ui.h +++ b/src/dep/include/openssl/ui.h @@ -1,381 +1,381 @@ -/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ -/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL - * project 2001. - */ -/* ==================================================================== - * Copyright (c) 2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_UI_H -#define HEADER_UI_H - -#ifndef OPENSSL_NO_DEPRECATED -#include -#endif -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Declared already in ossl_typ.h */ -/* typedef struct ui_st UI; */ -/* typedef struct ui_method_st UI_METHOD; */ - - -/* All the following functions return -1 or NULL on error and in some cases - (UI_process()) -2 if interrupted or in some other way cancelled. - When everything is fine, they return 0, a positive value or a non-NULL - pointer, all depending on their purpose. */ - -/* Creators and destructor. */ -UI *UI_new(void); -UI *UI_new_method(const UI_METHOD *method); -void UI_free(UI *ui); - -/* The following functions are used to add strings to be printed and prompt - strings to prompt for data. The names are UI_{add,dup}__string - and UI_{add,dup}_input_boolean. - - UI_{add,dup}__string have the following meanings: - add add a text or prompt string. The pointers given to these - functions are used verbatim, no copying is done. - dup make a copy of the text or prompt string, then add the copy - to the collection of strings in the user interface. - - The function is a name for the functionality that the given - string shall be used for. It can be one of: - input use the string as data prompt. - verify use the string as verification prompt. This - is used to verify a previous input. - info use the string for informational output. - error use the string for error output. - Honestly, there's currently no difference between info and error for the - moment. - - UI_{add,dup}_input_boolean have the same semantics for "add" and "dup", - and are typically used when one wants to prompt for a yes/no response. - - - All of the functions in this group take a UI and a prompt string. - The string input and verify addition functions also take a flag argument, - a buffer for the result to end up with, a minimum input size and a maximum - input size (the result buffer MUST be large enough to be able to contain - the maximum number of characters). Additionally, the verify addition - functions takes another buffer to compare the result against. - The boolean input functions take an action description string (which should - be safe to ignore if the expected user action is obvious, for example with - a dialog box with an OK button and a Cancel button), a string of acceptable - characters to mean OK and to mean Cancel. The two last strings are checked - to make sure they don't have common characters. Additionally, the same - flag argument as for the string input is taken, as well as a result buffer. - The result buffer is required to be at least one byte long. Depending on - the answer, the first character from the OK or the Cancel character strings - will be stored in the first byte of the result buffer. No NUL will be - added, so the result is *not* a string. - - On success, the all return an index of the added information. That index - is usefull when retrieving results with UI_get0_result(). */ -int UI_add_input_string(UI *ui, const char *prompt, int flags, - char *result_buf, int minsize, int maxsize); -int UI_dup_input_string(UI *ui, const char *prompt, int flags, - char *result_buf, int minsize, int maxsize); -int UI_add_verify_string(UI *ui, const char *prompt, int flags, - char *result_buf, int minsize, int maxsize, const char *test_buf); -int UI_dup_verify_string(UI *ui, const char *prompt, int flags, - char *result_buf, int minsize, int maxsize, const char *test_buf); -int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, - const char *ok_chars, const char *cancel_chars, - int flags, char *result_buf); -int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, - const char *ok_chars, const char *cancel_chars, - int flags, char *result_buf); -int UI_add_info_string(UI *ui, const char *text); -int UI_dup_info_string(UI *ui, const char *text); -int UI_add_error_string(UI *ui, const char *text); -int UI_dup_error_string(UI *ui, const char *text); - -/* These are the possible flags. They can be or'ed together. */ -/* Use to have echoing of input */ -#define UI_INPUT_FLAG_ECHO 0x01 -/* Use a default password. Where that password is found is completely - up to the application, it might for example be in the user data set - with UI_add_user_data(). It is not recommended to have more than - one input in each UI being marked with this flag, or the application - might get confused. */ -#define UI_INPUT_FLAG_DEFAULT_PWD 0x02 - -/* The user of these routines may want to define flags of their own. The core - UI won't look at those, but will pass them on to the method routines. They - must use higher bits so they don't get confused with the UI bits above. - UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use. A good - example of use is this: - - #define MY_UI_FLAG1 (0x01 << UI_INPUT_FLAG_USER_BASE) - -*/ -#define UI_INPUT_FLAG_USER_BASE 16 - - -/* The following function helps construct a prompt. object_desc is a - textual short description of the object, for example "pass phrase", - and object_name is the name of the object (might be a card name or - a file name. - The returned string shall always be allocated on the heap with - OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). - - If the ui_method doesn't contain a pointer to a user-defined prompt - constructor, a default string is built, looking like this: - - "Enter {object_desc} for {object_name}:" - - So, if object_desc has the value "pass phrase" and object_name has - the value "foo.key", the resulting string is: - - "Enter pass phrase for foo.key:" -*/ -char *UI_construct_prompt(UI *ui_method, - const char *object_desc, const char *object_name); - - -/* The following function is used to store a pointer to user-specific data. - Any previous such pointer will be returned and replaced. - - For callback purposes, this function makes a lot more sense than using - ex_data, since the latter requires that different parts of OpenSSL or - applications share the same ex_data index. - - Note that the UI_OpenSSL() method completely ignores the user data. - Other methods may not, however. */ -void *UI_add_user_data(UI *ui, void *user_data); -/* We need a user data retrieving function as well. */ -void *UI_get0_user_data(UI *ui); - -/* Return the result associated with a prompt given with the index i. */ -const char *UI_get0_result(UI *ui, int i); - -/* When all strings have been added, process the whole thing. */ -int UI_process(UI *ui); - -/* Give a user interface parametrised control commands. This can be used to - send down an integer, a data pointer or a function pointer, as well as - be used to get information from a UI. */ -int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void)); - -/* The commands */ -/* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the - OpenSSL error stack before printing any info or added error messages and - before any prompting. */ -#define UI_CTRL_PRINT_ERRORS 1 -/* Check if a UI_process() is possible to do again with the same instance of - a user interface. This makes UI_ctrl() return 1 if it is redoable, and 0 - if not. */ -#define UI_CTRL_IS_REDOABLE 2 - - -/* Some methods may use extra data */ -#define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg) -#define UI_get_app_data(s) UI_get_ex_data(s,0) -int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); -int UI_set_ex_data(UI *r,int idx,void *arg); -void *UI_get_ex_data(UI *r, int idx); - -/* Use specific methods instead of the built-in one */ -void UI_set_default_method(const UI_METHOD *meth); -const UI_METHOD *UI_get_default_method(void); -const UI_METHOD *UI_get_method(UI *ui); -const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth); - -/* The method with all the built-in thingies */ -UI_METHOD *UI_OpenSSL(void); - - -/* ---------- For method writers ---------- */ -/* A method contains a number of functions that implement the low level - of the User Interface. The functions are: - - an opener This function starts a session, maybe by opening - a channel to a tty, or by opening a window. - a writer This function is called to write a given string, - maybe to the tty, maybe as a field label in a - window. - a flusher This function is called to flush everything that - has been output so far. It can be used to actually - display a dialog box after it has been built. - a reader This function is called to read a given prompt, - maybe from the tty, maybe from a field in a - window. Note that it's called wth all string - structures, not only the prompt ones, so it must - check such things itself. - a closer This function closes the session, maybe by closing - the channel to the tty, or closing the window. - - All these functions are expected to return: - - 0 on error. - 1 on success. - -1 on out-of-band events, for example if some prompting has - been canceled (by pressing Ctrl-C, for example). This is - only checked when returned by the flusher or the reader. - - The way this is used, the opener is first called, then the writer for all - strings, then the flusher, then the reader for all strings and finally the - closer. Note that if you want to prompt from a terminal or other command - line interface, the best is to have the reader also write the prompts - instead of having the writer do it. If you want to prompt from a dialog - box, the writer can be used to build up the contents of the box, and the - flusher to actually display the box and run the event loop until all data - has been given, after which the reader only grabs the given data and puts - them back into the UI strings. - - All method functions take a UI as argument. Additionally, the writer and - the reader take a UI_STRING. -*/ - -/* The UI_STRING type is the data structure that contains all the needed info - about a string or a prompt, including test data for a verification prompt. -*/ -DECLARE_STACK_OF(UI_STRING) -typedef struct ui_string_st UI_STRING; - -/* The different types of strings that are currently supported. - This is only needed by method authors. */ -enum UI_string_types - { - UIT_NONE=0, - UIT_PROMPT, /* Prompt for a string */ - UIT_VERIFY, /* Prompt for a string and verify */ - UIT_BOOLEAN, /* Prompt for a yes/no response */ - UIT_INFO, /* Send info to the user */ - UIT_ERROR /* Send an error message to the user */ - }; - -/* Create and manipulate methods */ -UI_METHOD *UI_create_method(char *name); -void UI_destroy_method(UI_METHOD *ui_method); -int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui)); -int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis)); -int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui)); -int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis)); -int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)); -int (*UI_method_get_opener(UI_METHOD *method))(UI*); -int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*); -int (*UI_method_get_flusher(UI_METHOD *method))(UI*); -int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*); -int (*UI_method_get_closer(UI_METHOD *method))(UI*); - -/* The following functions are helpers for method writers to access relevant - data from a UI_STRING. */ - -/* Return type of the UI_STRING */ -enum UI_string_types UI_get_string_type(UI_STRING *uis); -/* Return input flags of the UI_STRING */ -int UI_get_input_flags(UI_STRING *uis); -/* Return the actual string to output (the prompt, info or error) */ -const char *UI_get0_output_string(UI_STRING *uis); -/* Return the optional action string to output (the boolean promtp instruction) */ -const char *UI_get0_action_string(UI_STRING *uis); -/* Return the result of a prompt */ -const char *UI_get0_result_string(UI_STRING *uis); -/* Return the string to test the result against. Only useful with verifies. */ -const char *UI_get0_test_string(UI_STRING *uis); -/* Return the required minimum size of the result */ -int UI_get_result_minsize(UI_STRING *uis); -/* Return the required maximum size of the result */ -int UI_get_result_maxsize(UI_STRING *uis); -/* Set the result of a UI_STRING. */ -int UI_set_result(UI *ui, UI_STRING *uis, const char *result); - - -/* A couple of popular utility functions */ -int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify); -int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); - - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_UI_strings(void); - -/* Error codes for the UI functions. */ - -/* Function codes. */ -#define UI_F_GENERAL_ALLOCATE_BOOLEAN 108 -#define UI_F_GENERAL_ALLOCATE_PROMPT 109 -#define UI_F_GENERAL_ALLOCATE_STRING 100 -#define UI_F_UI_CTRL 111 -#define UI_F_UI_DUP_ERROR_STRING 101 -#define UI_F_UI_DUP_INFO_STRING 102 -#define UI_F_UI_DUP_INPUT_BOOLEAN 110 -#define UI_F_UI_DUP_INPUT_STRING 103 -#define UI_F_UI_DUP_VERIFY_STRING 106 -#define UI_F_UI_GET0_RESULT 107 -#define UI_F_UI_NEW_METHOD 104 -#define UI_F_UI_SET_RESULT 105 - -/* Reason codes. */ -#define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS 104 -#define UI_R_INDEX_TOO_LARGE 102 -#define UI_R_INDEX_TOO_SMALL 103 -#define UI_R_NO_RESULT_BUFFER 105 -#define UI_R_RESULT_TOO_LARGE 100 -#define UI_R_RESULT_TOO_SMALL 101 -#define UI_R_UNKNOWN_CONTROL_COMMAND 106 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_UI_H +#define HEADER_UI_H + +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Declared already in ossl_typ.h */ +/* typedef struct ui_st UI; */ +/* typedef struct ui_method_st UI_METHOD; */ + + +/* All the following functions return -1 or NULL on error and in some cases + (UI_process()) -2 if interrupted or in some other way cancelled. + When everything is fine, they return 0, a positive value or a non-NULL + pointer, all depending on their purpose. */ + +/* Creators and destructor. */ +UI *UI_new(void); +UI *UI_new_method(const UI_METHOD *method); +void UI_free(UI *ui); + +/* The following functions are used to add strings to be printed and prompt + strings to prompt for data. The names are UI_{add,dup}__string + and UI_{add,dup}_input_boolean. + + UI_{add,dup}__string have the following meanings: + add add a text or prompt string. The pointers given to these + functions are used verbatim, no copying is done. + dup make a copy of the text or prompt string, then add the copy + to the collection of strings in the user interface. + + The function is a name for the functionality that the given + string shall be used for. It can be one of: + input use the string as data prompt. + verify use the string as verification prompt. This + is used to verify a previous input. + info use the string for informational output. + error use the string for error output. + Honestly, there's currently no difference between info and error for the + moment. + + UI_{add,dup}_input_boolean have the same semantics for "add" and "dup", + and are typically used when one wants to prompt for a yes/no response. + + + All of the functions in this group take a UI and a prompt string. + The string input and verify addition functions also take a flag argument, + a buffer for the result to end up with, a minimum input size and a maximum + input size (the result buffer MUST be large enough to be able to contain + the maximum number of characters). Additionally, the verify addition + functions takes another buffer to compare the result against. + The boolean input functions take an action description string (which should + be safe to ignore if the expected user action is obvious, for example with + a dialog box with an OK button and a Cancel button), a string of acceptable + characters to mean OK and to mean Cancel. The two last strings are checked + to make sure they don't have common characters. Additionally, the same + flag argument as for the string input is taken, as well as a result buffer. + The result buffer is required to be at least one byte long. Depending on + the answer, the first character from the OK or the Cancel character strings + will be stored in the first byte of the result buffer. No NUL will be + added, so the result is *not* a string. + + On success, the all return an index of the added information. That index + is usefull when retrieving results with UI_get0_result(). */ +int UI_add_input_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize); +int UI_dup_input_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize); +int UI_add_verify_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize, const char *test_buf); +int UI_dup_verify_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize, const char *test_buf); +int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, + const char *ok_chars, const char *cancel_chars, + int flags, char *result_buf); +int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, + const char *ok_chars, const char *cancel_chars, + int flags, char *result_buf); +int UI_add_info_string(UI *ui, const char *text); +int UI_dup_info_string(UI *ui, const char *text); +int UI_add_error_string(UI *ui, const char *text); +int UI_dup_error_string(UI *ui, const char *text); + +/* These are the possible flags. They can be or'ed together. */ +/* Use to have echoing of input */ +#define UI_INPUT_FLAG_ECHO 0x01 +/* Use a default password. Where that password is found is completely + up to the application, it might for example be in the user data set + with UI_add_user_data(). It is not recommended to have more than + one input in each UI being marked with this flag, or the application + might get confused. */ +#define UI_INPUT_FLAG_DEFAULT_PWD 0x02 + +/* The user of these routines may want to define flags of their own. The core + UI won't look at those, but will pass them on to the method routines. They + must use higher bits so they don't get confused with the UI bits above. + UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use. A good + example of use is this: + + #define MY_UI_FLAG1 (0x01 << UI_INPUT_FLAG_USER_BASE) + +*/ +#define UI_INPUT_FLAG_USER_BASE 16 + + +/* The following function helps construct a prompt. object_desc is a + textual short description of the object, for example "pass phrase", + and object_name is the name of the object (might be a card name or + a file name. + The returned string shall always be allocated on the heap with + OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). + + If the ui_method doesn't contain a pointer to a user-defined prompt + constructor, a default string is built, looking like this: + + "Enter {object_desc} for {object_name}:" + + So, if object_desc has the value "pass phrase" and object_name has + the value "foo.key", the resulting string is: + + "Enter pass phrase for foo.key:" +*/ +char *UI_construct_prompt(UI *ui_method, + const char *object_desc, const char *object_name); + + +/* The following function is used to store a pointer to user-specific data. + Any previous such pointer will be returned and replaced. + + For callback purposes, this function makes a lot more sense than using + ex_data, since the latter requires that different parts of OpenSSL or + applications share the same ex_data index. + + Note that the UI_OpenSSL() method completely ignores the user data. + Other methods may not, however. */ +void *UI_add_user_data(UI *ui, void *user_data); +/* We need a user data retrieving function as well. */ +void *UI_get0_user_data(UI *ui); + +/* Return the result associated with a prompt given with the index i. */ +const char *UI_get0_result(UI *ui, int i); + +/* When all strings have been added, process the whole thing. */ +int UI_process(UI *ui); + +/* Give a user interface parametrised control commands. This can be used to + send down an integer, a data pointer or a function pointer, as well as + be used to get information from a UI. */ +int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void)); + +/* The commands */ +/* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the + OpenSSL error stack before printing any info or added error messages and + before any prompting. */ +#define UI_CTRL_PRINT_ERRORS 1 +/* Check if a UI_process() is possible to do again with the same instance of + a user interface. This makes UI_ctrl() return 1 if it is redoable, and 0 + if not. */ +#define UI_CTRL_IS_REDOABLE 2 + + +/* Some methods may use extra data */ +#define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg) +#define UI_get_app_data(s) UI_get_ex_data(s,0) +int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int UI_set_ex_data(UI *r,int idx,void *arg); +void *UI_get_ex_data(UI *r, int idx); + +/* Use specific methods instead of the built-in one */ +void UI_set_default_method(const UI_METHOD *meth); +const UI_METHOD *UI_get_default_method(void); +const UI_METHOD *UI_get_method(UI *ui); +const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth); + +/* The method with all the built-in thingies */ +UI_METHOD *UI_OpenSSL(void); + + +/* ---------- For method writers ---------- */ +/* A method contains a number of functions that implement the low level + of the User Interface. The functions are: + + an opener This function starts a session, maybe by opening + a channel to a tty, or by opening a window. + a writer This function is called to write a given string, + maybe to the tty, maybe as a field label in a + window. + a flusher This function is called to flush everything that + has been output so far. It can be used to actually + display a dialog box after it has been built. + a reader This function is called to read a given prompt, + maybe from the tty, maybe from a field in a + window. Note that it's called wth all string + structures, not only the prompt ones, so it must + check such things itself. + a closer This function closes the session, maybe by closing + the channel to the tty, or closing the window. + + All these functions are expected to return: + + 0 on error. + 1 on success. + -1 on out-of-band events, for example if some prompting has + been canceled (by pressing Ctrl-C, for example). This is + only checked when returned by the flusher or the reader. + + The way this is used, the opener is first called, then the writer for all + strings, then the flusher, then the reader for all strings and finally the + closer. Note that if you want to prompt from a terminal or other command + line interface, the best is to have the reader also write the prompts + instead of having the writer do it. If you want to prompt from a dialog + box, the writer can be used to build up the contents of the box, and the + flusher to actually display the box and run the event loop until all data + has been given, after which the reader only grabs the given data and puts + them back into the UI strings. + + All method functions take a UI as argument. Additionally, the writer and + the reader take a UI_STRING. +*/ + +/* The UI_STRING type is the data structure that contains all the needed info + about a string or a prompt, including test data for a verification prompt. +*/ +DECLARE_STACK_OF(UI_STRING) +typedef struct ui_string_st UI_STRING; + +/* The different types of strings that are currently supported. + This is only needed by method authors. */ +enum UI_string_types + { + UIT_NONE=0, + UIT_PROMPT, /* Prompt for a string */ + UIT_VERIFY, /* Prompt for a string and verify */ + UIT_BOOLEAN, /* Prompt for a yes/no response */ + UIT_INFO, /* Send info to the user */ + UIT_ERROR /* Send an error message to the user */ + }; + +/* Create and manipulate methods */ +UI_METHOD *UI_create_method(char *name); +void UI_destroy_method(UI_METHOD *ui_method); +int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui)); +int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis)); +int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui)); +int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis)); +int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)); +int (*UI_method_get_opener(UI_METHOD *method))(UI*); +int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*); +int (*UI_method_get_flusher(UI_METHOD *method))(UI*); +int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*); +int (*UI_method_get_closer(UI_METHOD *method))(UI*); + +/* The following functions are helpers for method writers to access relevant + data from a UI_STRING. */ + +/* Return type of the UI_STRING */ +enum UI_string_types UI_get_string_type(UI_STRING *uis); +/* Return input flags of the UI_STRING */ +int UI_get_input_flags(UI_STRING *uis); +/* Return the actual string to output (the prompt, info or error) */ +const char *UI_get0_output_string(UI_STRING *uis); +/* Return the optional action string to output (the boolean promtp instruction) */ +const char *UI_get0_action_string(UI_STRING *uis); +/* Return the result of a prompt */ +const char *UI_get0_result_string(UI_STRING *uis); +/* Return the string to test the result against. Only useful with verifies. */ +const char *UI_get0_test_string(UI_STRING *uis); +/* Return the required minimum size of the result */ +int UI_get_result_minsize(UI_STRING *uis); +/* Return the required maximum size of the result */ +int UI_get_result_maxsize(UI_STRING *uis); +/* Set the result of a UI_STRING. */ +int UI_set_result(UI *ui, UI_STRING *uis, const char *result); + + +/* A couple of popular utility functions */ +int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify); +int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_UI_strings(void); + +/* Error codes for the UI functions. */ + +/* Function codes. */ +#define UI_F_GENERAL_ALLOCATE_BOOLEAN 108 +#define UI_F_GENERAL_ALLOCATE_PROMPT 109 +#define UI_F_GENERAL_ALLOCATE_STRING 100 +#define UI_F_UI_CTRL 111 +#define UI_F_UI_DUP_ERROR_STRING 101 +#define UI_F_UI_DUP_INFO_STRING 102 +#define UI_F_UI_DUP_INPUT_BOOLEAN 110 +#define UI_F_UI_DUP_INPUT_STRING 103 +#define UI_F_UI_DUP_VERIFY_STRING 106 +#define UI_F_UI_GET0_RESULT 107 +#define UI_F_UI_NEW_METHOD 104 +#define UI_F_UI_SET_RESULT 105 + +/* Reason codes. */ +#define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS 104 +#define UI_R_INDEX_TOO_LARGE 102 +#define UI_R_INDEX_TOO_SMALL 103 +#define UI_R_NO_RESULT_BUFFER 105 +#define UI_R_RESULT_TOO_LARGE 100 +#define UI_R_RESULT_TOO_SMALL 101 +#define UI_R_UNKNOWN_CONTROL_COMMAND 106 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/ui_compat.h b/src/dep/include/openssl/ui_compat.h index b8b3579..6439b2b 100644 --- a/src/dep/include/openssl/ui_compat.h +++ b/src/dep/include/openssl/ui_compat.h @@ -1,83 +1,83 @@ -/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ -/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL - * project 2001. - */ -/* ==================================================================== - * Copyright (c) 2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_UI_COMPAT_H -#define HEADER_UI_COMPAT_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* The following functions were previously part of the DES section, - and are provided here for backward compatibility reasons. */ - -#define des_read_pw_string(b,l,p,v) \ - _ossl_old_des_read_pw_string((b),(l),(p),(v)) -#define des_read_pw(b,bf,s,p,v) \ - _ossl_old_des_read_pw((b),(bf),(s),(p),(v)) - -int _ossl_old_des_read_pw_string(char *buf,int length,const char *prompt,int verify); -int _ossl_old_des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_UI_COMPAT_H +#define HEADER_UI_COMPAT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* The following functions were previously part of the DES section, + and are provided here for backward compatibility reasons. */ + +#define des_read_pw_string(b,l,p,v) \ + _ossl_old_des_read_pw_string((b),(l),(p),(v)) +#define des_read_pw(b,bf,s,p,v) \ + _ossl_old_des_read_pw((b),(bf),(s),(p),(v)) + +int _ossl_old_des_read_pw_string(char *buf,int length,const char *prompt,int verify); +int _ossl_old_des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/x509.h b/src/dep/include/openssl/x509.h index 76251e2..5e564b1 100644 --- a/src/dep/include/openssl/x509.h +++ b/src/dep/include/openssl/x509.h @@ -1,1340 +1,1340 @@ -/* crypto/x509/x509.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * ECDH support in OpenSSL originally developed by - * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. - */ - -#ifndef HEADER_X509_H -#define HEADER_X509_H - -#include -#include -#ifndef OPENSSL_NO_BUFFER -#include -#endif -#ifndef OPENSSL_NO_EVP -#include -#endif -#ifndef OPENSSL_NO_BIO -#include -#endif -#include -#include -#include - -#ifndef OPENSSL_NO_EC -#include -#endif - -#ifndef OPENSSL_NO_ECDSA -#include -#endif - -#ifndef OPENSSL_NO_ECDH -#include -#endif - -#ifndef OPENSSL_NO_DEPRECATED -#ifndef OPENSSL_NO_RSA -#include -#endif -#ifndef OPENSSL_NO_DSA -#include -#endif -#ifndef OPENSSL_NO_DH -#include -#endif -#endif - -#ifndef OPENSSL_NO_SHA -#include -#endif -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef OPENSSL_SYS_WIN32 -/* Under Win32 these are defined in wincrypt.h */ -#undef X509_NAME -#undef X509_CERT_PAIR -#endif - -#define X509_FILETYPE_PEM 1 -#define X509_FILETYPE_ASN1 2 -#define X509_FILETYPE_DEFAULT 3 - -#define X509v3_KU_DIGITAL_SIGNATURE 0x0080 -#define X509v3_KU_NON_REPUDIATION 0x0040 -#define X509v3_KU_KEY_ENCIPHERMENT 0x0020 -#define X509v3_KU_DATA_ENCIPHERMENT 0x0010 -#define X509v3_KU_KEY_AGREEMENT 0x0008 -#define X509v3_KU_KEY_CERT_SIGN 0x0004 -#define X509v3_KU_CRL_SIGN 0x0002 -#define X509v3_KU_ENCIPHER_ONLY 0x0001 -#define X509v3_KU_DECIPHER_ONLY 0x8000 -#define X509v3_KU_UNDEF 0xffff - -typedef struct X509_objects_st - { - int nid; - int (*a2i)(void); - int (*i2a)(void); - } X509_OBJECTS; - -struct X509_algor_st - { - ASN1_OBJECT *algorithm; - ASN1_TYPE *parameter; - } /* X509_ALGOR */; - -DECLARE_STACK_OF(X509_ALGOR) -DECLARE_ASN1_SET_OF(X509_ALGOR) - -typedef struct X509_val_st - { - ASN1_TIME *notBefore; - ASN1_TIME *notAfter; - } X509_VAL; - -typedef struct X509_pubkey_st - { - X509_ALGOR *algor; - ASN1_BIT_STRING *public_key; - EVP_PKEY *pkey; - } X509_PUBKEY; - -typedef struct X509_sig_st - { - X509_ALGOR *algor; - ASN1_OCTET_STRING *digest; - } X509_SIG; - -typedef struct X509_name_entry_st - { - ASN1_OBJECT *object; - ASN1_STRING *value; - int set; - int size; /* temp variable */ - } X509_NAME_ENTRY; - -DECLARE_STACK_OF(X509_NAME_ENTRY) -DECLARE_ASN1_SET_OF(X509_NAME_ENTRY) - -/* we always keep X509_NAMEs in 2 forms. */ -struct X509_name_st - { - STACK_OF(X509_NAME_ENTRY) *entries; - int modified; /* true if 'bytes' needs to be built */ -#ifndef OPENSSL_NO_BUFFER - BUF_MEM *bytes; -#else - char *bytes; -#endif - unsigned long hash; /* Keep the hash around for lookups */ - } /* X509_NAME */; - -DECLARE_STACK_OF(X509_NAME) - -#define X509_EX_V_NETSCAPE_HACK 0x8000 -#define X509_EX_V_INIT 0x0001 -typedef struct X509_extension_st - { - ASN1_OBJECT *object; - ASN1_BOOLEAN critical; - ASN1_OCTET_STRING *value; - } X509_EXTENSION; - -DECLARE_STACK_OF(X509_EXTENSION) -DECLARE_ASN1_SET_OF(X509_EXTENSION) - -/* a sequence of these are used */ -typedef struct x509_attributes_st - { - ASN1_OBJECT *object; - int single; /* 0 for a set, 1 for a single item (which is wrong) */ - union { - char *ptr; -/* 0 */ STACK_OF(ASN1_TYPE) *set; -/* 1 */ ASN1_TYPE *single; - } value; - } X509_ATTRIBUTE; - -DECLARE_STACK_OF(X509_ATTRIBUTE) -DECLARE_ASN1_SET_OF(X509_ATTRIBUTE) - - -typedef struct X509_req_info_st - { - ASN1_ENCODING enc; - ASN1_INTEGER *version; - X509_NAME *subject; - X509_PUBKEY *pubkey; - /* d=2 hl=2 l= 0 cons: cont: 00 */ - STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ - } X509_REQ_INFO; - -typedef struct X509_req_st - { - X509_REQ_INFO *req_info; - X509_ALGOR *sig_alg; - ASN1_BIT_STRING *signature; - int references; - } X509_REQ; - -typedef struct x509_cinf_st - { - ASN1_INTEGER *version; /* [ 0 ] default of v1 */ - ASN1_INTEGER *serialNumber; - X509_ALGOR *signature; - X509_NAME *issuer; - X509_VAL *validity; - X509_NAME *subject; - X509_PUBKEY *key; - ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */ - ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */ - STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */ - } X509_CINF; - -/* This stuff is certificate "auxiliary info" - * it contains details which are useful in certificate - * stores and databases. When used this is tagged onto - * the end of the certificate itself - */ - -typedef struct x509_cert_aux_st - { - STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */ - STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */ - ASN1_UTF8STRING *alias; /* "friendly name" */ - ASN1_OCTET_STRING *keyid; /* key id of private key */ - STACK_OF(X509_ALGOR) *other; /* other unspecified info */ - } X509_CERT_AUX; - -struct x509_st - { - X509_CINF *cert_info; - X509_ALGOR *sig_alg; - ASN1_BIT_STRING *signature; - int valid; - int references; - char *name; - CRYPTO_EX_DATA ex_data; - /* These contain copies of various extension values */ - long ex_pathlen; - long ex_pcpathlen; - unsigned long ex_flags; - unsigned long ex_kusage; - unsigned long ex_xkusage; - unsigned long ex_nscert; - ASN1_OCTET_STRING *skid; - struct AUTHORITY_KEYID_st *akid; - X509_POLICY_CACHE *policy_cache; -#ifndef OPENSSL_NO_SHA - unsigned char sha1_hash[SHA_DIGEST_LENGTH]; -#endif - X509_CERT_AUX *aux; - } /* X509 */; - -DECLARE_STACK_OF(X509) -DECLARE_ASN1_SET_OF(X509) - -/* This is used for a table of trust checking functions */ - -typedef struct x509_trust_st { - int trust; - int flags; - int (*check_trust)(struct x509_trust_st *, X509 *, int); - char *name; - int arg1; - void *arg2; -} X509_TRUST; - -DECLARE_STACK_OF(X509_TRUST) - -typedef struct x509_cert_pair_st { - X509 *forward; - X509 *reverse; -} X509_CERT_PAIR; - -/* standard trust ids */ - -#define X509_TRUST_DEFAULT -1 /* Only valid in purpose settings */ - -#define X509_TRUST_COMPAT 1 -#define X509_TRUST_SSL_CLIENT 2 -#define X509_TRUST_SSL_SERVER 3 -#define X509_TRUST_EMAIL 4 -#define X509_TRUST_OBJECT_SIGN 5 -#define X509_TRUST_OCSP_SIGN 6 -#define X509_TRUST_OCSP_REQUEST 7 - -/* Keep these up to date! */ -#define X509_TRUST_MIN 1 -#define X509_TRUST_MAX 7 - - -/* trust_flags values */ -#define X509_TRUST_DYNAMIC 1 -#define X509_TRUST_DYNAMIC_NAME 2 - -/* check_trust return codes */ - -#define X509_TRUST_TRUSTED 1 -#define X509_TRUST_REJECTED 2 -#define X509_TRUST_UNTRUSTED 3 - -/* Flags for X509_print_ex() */ - -#define X509_FLAG_COMPAT 0 -#define X509_FLAG_NO_HEADER 1L -#define X509_FLAG_NO_VERSION (1L << 1) -#define X509_FLAG_NO_SERIAL (1L << 2) -#define X509_FLAG_NO_SIGNAME (1L << 3) -#define X509_FLAG_NO_ISSUER (1L << 4) -#define X509_FLAG_NO_VALIDITY (1L << 5) -#define X509_FLAG_NO_SUBJECT (1L << 6) -#define X509_FLAG_NO_PUBKEY (1L << 7) -#define X509_FLAG_NO_EXTENSIONS (1L << 8) -#define X509_FLAG_NO_SIGDUMP (1L << 9) -#define X509_FLAG_NO_AUX (1L << 10) -#define X509_FLAG_NO_ATTRIBUTES (1L << 11) - -/* Flags specific to X509_NAME_print_ex() */ - -/* The field separator information */ - -#define XN_FLAG_SEP_MASK (0xf << 16) - -#define XN_FLAG_COMPAT 0 /* Traditional SSLeay: use old X509_NAME_print */ -#define XN_FLAG_SEP_COMMA_PLUS (1 << 16) /* RFC2253 ,+ */ -#define XN_FLAG_SEP_CPLUS_SPC (2 << 16) /* ,+ spaced: more readable */ -#define XN_FLAG_SEP_SPLUS_SPC (3 << 16) /* ;+ spaced */ -#define XN_FLAG_SEP_MULTILINE (4 << 16) /* One line per field */ - -#define XN_FLAG_DN_REV (1 << 20) /* Reverse DN order */ - -/* How the field name is shown */ - -#define XN_FLAG_FN_MASK (0x3 << 21) - -#define XN_FLAG_FN_SN 0 /* Object short name */ -#define XN_FLAG_FN_LN (1 << 21) /* Object long name */ -#define XN_FLAG_FN_OID (2 << 21) /* Always use OIDs */ -#define XN_FLAG_FN_NONE (3 << 21) /* No field names */ - -#define XN_FLAG_SPC_EQ (1 << 23) /* Put spaces round '=' */ - -/* This determines if we dump fields we don't recognise: - * RFC2253 requires this. - */ - -#define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24) - -#define XN_FLAG_FN_ALIGN (1 << 25) /* Align field names to 20 characters */ - -/* Complete set of RFC2253 flags */ - -#define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \ - XN_FLAG_SEP_COMMA_PLUS | \ - XN_FLAG_DN_REV | \ - XN_FLAG_FN_SN | \ - XN_FLAG_DUMP_UNKNOWN_FIELDS) - -/* readable oneline form */ - -#define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \ - ASN1_STRFLGS_ESC_QUOTE | \ - XN_FLAG_SEP_CPLUS_SPC | \ - XN_FLAG_SPC_EQ | \ - XN_FLAG_FN_SN) - -/* readable multiline form */ - -#define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \ - ASN1_STRFLGS_ESC_MSB | \ - XN_FLAG_SEP_MULTILINE | \ - XN_FLAG_SPC_EQ | \ - XN_FLAG_FN_LN | \ - XN_FLAG_FN_ALIGN) - -typedef struct X509_revoked_st - { - ASN1_INTEGER *serialNumber; - ASN1_TIME *revocationDate; - STACK_OF(X509_EXTENSION) /* optional */ *extensions; - int sequence; /* load sequence */ - } X509_REVOKED; - -DECLARE_STACK_OF(X509_REVOKED) -DECLARE_ASN1_SET_OF(X509_REVOKED) - -typedef struct X509_crl_info_st - { - ASN1_INTEGER *version; - X509_ALGOR *sig_alg; - X509_NAME *issuer; - ASN1_TIME *lastUpdate; - ASN1_TIME *nextUpdate; - STACK_OF(X509_REVOKED) *revoked; - STACK_OF(X509_EXTENSION) /* [0] */ *extensions; - ASN1_ENCODING enc; - } X509_CRL_INFO; - -struct X509_crl_st - { - /* actual signature */ - X509_CRL_INFO *crl; - X509_ALGOR *sig_alg; - ASN1_BIT_STRING *signature; - int references; - } /* X509_CRL */; - -DECLARE_STACK_OF(X509_CRL) -DECLARE_ASN1_SET_OF(X509_CRL) - -typedef struct private_key_st - { - int version; - /* The PKCS#8 data types */ - X509_ALGOR *enc_algor; - ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */ - - /* When decrypted, the following will not be NULL */ - EVP_PKEY *dec_pkey; - - /* used to encrypt and decrypt */ - int key_length; - char *key_data; - int key_free; /* true if we should auto free key_data */ - - /* expanded version of 'enc_algor' */ - EVP_CIPHER_INFO cipher; - - int references; - } X509_PKEY; - -#ifndef OPENSSL_NO_EVP -typedef struct X509_info_st - { - X509 *x509; - X509_CRL *crl; - X509_PKEY *x_pkey; - - EVP_CIPHER_INFO enc_cipher; - int enc_len; - char *enc_data; - - int references; - } X509_INFO; - -DECLARE_STACK_OF(X509_INFO) -#endif - -/* The next 2 structures and their 8 routines were sent to me by - * Pat Richard and are used to manipulate - * Netscapes spki structures - useful if you are writing a CA web page - */ -typedef struct Netscape_spkac_st - { - X509_PUBKEY *pubkey; - ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */ - } NETSCAPE_SPKAC; - -typedef struct Netscape_spki_st - { - NETSCAPE_SPKAC *spkac; /* signed public key and challenge */ - X509_ALGOR *sig_algor; - ASN1_BIT_STRING *signature; - } NETSCAPE_SPKI; - -/* Netscape certificate sequence structure */ -typedef struct Netscape_certificate_sequence - { - ASN1_OBJECT *type; - STACK_OF(X509) *certs; - } NETSCAPE_CERT_SEQUENCE; - -/* Unused (and iv length is wrong) -typedef struct CBCParameter_st - { - unsigned char iv[8]; - } CBC_PARAM; -*/ - -/* Password based encryption structure */ - -typedef struct PBEPARAM_st { -ASN1_OCTET_STRING *salt; -ASN1_INTEGER *iter; -} PBEPARAM; - -/* Password based encryption V2 structures */ - -typedef struct PBE2PARAM_st { -X509_ALGOR *keyfunc; -X509_ALGOR *encryption; -} PBE2PARAM; - -typedef struct PBKDF2PARAM_st { -ASN1_TYPE *salt; /* Usually OCTET STRING but could be anything */ -ASN1_INTEGER *iter; -ASN1_INTEGER *keylength; -X509_ALGOR *prf; -} PBKDF2PARAM; - - -/* PKCS#8 private key info structure */ - -typedef struct pkcs8_priv_key_info_st - { - int broken; /* Flag for various broken formats */ -#define PKCS8_OK 0 -#define PKCS8_NO_OCTET 1 -#define PKCS8_EMBEDDED_PARAM 2 -#define PKCS8_NS_DB 3 - ASN1_INTEGER *version; - X509_ALGOR *pkeyalg; - ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */ - STACK_OF(X509_ATTRIBUTE) *attributes; - } PKCS8_PRIV_KEY_INFO; - -#ifdef __cplusplus -} -#endif - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef SSLEAY_MACROS -#define X509_verify(a,r) ASN1_verify((int (*)())i2d_X509_CINF,a->sig_alg,\ - a->signature,(char *)a->cert_info,r) -#define X509_REQ_verify(a,r) ASN1_verify((int (*)())i2d_X509_REQ_INFO, \ - a->sig_alg,a->signature,(char *)a->req_info,r) -#define X509_CRL_verify(a,r) ASN1_verify((int (*)())i2d_X509_CRL_INFO, \ - a->sig_alg, a->signature,(char *)a->crl,r) - -#define X509_sign(x,pkey,md) \ - ASN1_sign((int (*)())i2d_X509_CINF, x->cert_info->signature, \ - x->sig_alg, x->signature, (char *)x->cert_info,pkey,md) -#define X509_REQ_sign(x,pkey,md) \ - ASN1_sign((int (*)())i2d_X509_REQ_INFO,x->sig_alg, NULL, \ - x->signature, (char *)x->req_info,pkey,md) -#define X509_CRL_sign(x,pkey,md) \ - ASN1_sign((int (*)())i2d_X509_CRL_INFO,x->crl->sig_alg,x->sig_alg, \ - x->signature, (char *)x->crl,pkey,md) -#define NETSCAPE_SPKI_sign(x,pkey,md) \ - ASN1_sign((int (*)())i2d_NETSCAPE_SPKAC, x->sig_algor,NULL, \ - x->signature, (char *)x->spkac,pkey,md) - -#define X509_dup(x509) (X509 *)ASN1_dup((int (*)())i2d_X509, \ - (char *(*)())d2i_X509,(char *)x509) -#define X509_ATTRIBUTE_dup(xa) (X509_ATTRIBUTE *)ASN1_dup(\ - (int (*)())i2d_X509_ATTRIBUTE, \ - (char *(*)())d2i_X509_ATTRIBUTE,(char *)xa) -#define X509_EXTENSION_dup(ex) (X509_EXTENSION *)ASN1_dup( \ - (int (*)())i2d_X509_EXTENSION, \ - (char *(*)())d2i_X509_EXTENSION,(char *)ex) -#define d2i_X509_fp(fp,x509) (X509 *)ASN1_d2i_fp((char *(*)())X509_new, \ - (char *(*)())d2i_X509, (fp),(unsigned char **)(x509)) -#define i2d_X509_fp(fp,x509) ASN1_i2d_fp(i2d_X509,fp,(unsigned char *)x509) -#define d2i_X509_bio(bp,x509) (X509 *)ASN1_d2i_bio((char *(*)())X509_new, \ - (char *(*)())d2i_X509, (bp),(unsigned char **)(x509)) -#define i2d_X509_bio(bp,x509) ASN1_i2d_bio(i2d_X509,bp,(unsigned char *)x509) - -#define X509_CRL_dup(crl) (X509_CRL *)ASN1_dup((int (*)())i2d_X509_CRL, \ - (char *(*)())d2i_X509_CRL,(char *)crl) -#define d2i_X509_CRL_fp(fp,crl) (X509_CRL *)ASN1_d2i_fp((char *(*)()) \ - X509_CRL_new,(char *(*)())d2i_X509_CRL, (fp),\ - (unsigned char **)(crl)) -#define i2d_X509_CRL_fp(fp,crl) ASN1_i2d_fp(i2d_X509_CRL,fp,\ - (unsigned char *)crl) -#define d2i_X509_CRL_bio(bp,crl) (X509_CRL *)ASN1_d2i_bio((char *(*)()) \ - X509_CRL_new,(char *(*)())d2i_X509_CRL, (bp),\ - (unsigned char **)(crl)) -#define i2d_X509_CRL_bio(bp,crl) ASN1_i2d_bio(i2d_X509_CRL,bp,\ - (unsigned char *)crl) - -#define PKCS7_dup(p7) (PKCS7 *)ASN1_dup((int (*)())i2d_PKCS7, \ - (char *(*)())d2i_PKCS7,(char *)p7) -#define d2i_PKCS7_fp(fp,p7) (PKCS7 *)ASN1_d2i_fp((char *(*)()) \ - PKCS7_new,(char *(*)())d2i_PKCS7, (fp),\ - (unsigned char **)(p7)) -#define i2d_PKCS7_fp(fp,p7) ASN1_i2d_fp(i2d_PKCS7,fp,\ - (unsigned char *)p7) -#define d2i_PKCS7_bio(bp,p7) (PKCS7 *)ASN1_d2i_bio((char *(*)()) \ - PKCS7_new,(char *(*)())d2i_PKCS7, (bp),\ - (unsigned char **)(p7)) -#define i2d_PKCS7_bio(bp,p7) ASN1_i2d_bio(i2d_PKCS7,bp,\ - (unsigned char *)p7) - -#define X509_REQ_dup(req) (X509_REQ *)ASN1_dup((int (*)())i2d_X509_REQ, \ - (char *(*)())d2i_X509_REQ,(char *)req) -#define d2i_X509_REQ_fp(fp,req) (X509_REQ *)ASN1_d2i_fp((char *(*)())\ - X509_REQ_new, (char *(*)())d2i_X509_REQ, (fp),\ - (unsigned char **)(req)) -#define i2d_X509_REQ_fp(fp,req) ASN1_i2d_fp(i2d_X509_REQ,fp,\ - (unsigned char *)req) -#define d2i_X509_REQ_bio(bp,req) (X509_REQ *)ASN1_d2i_bio((char *(*)())\ - X509_REQ_new, (char *(*)())d2i_X509_REQ, (bp),\ - (unsigned char **)(req)) -#define i2d_X509_REQ_bio(bp,req) ASN1_i2d_bio(i2d_X509_REQ,bp,\ - (unsigned char *)req) - -#define RSAPublicKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPublicKey, \ - (char *(*)())d2i_RSAPublicKey,(char *)rsa) -#define RSAPrivateKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPrivateKey, \ - (char *(*)())d2i_RSAPrivateKey,(char *)rsa) - -#define d2i_RSAPrivateKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\ - RSA_new,(char *(*)())d2i_RSAPrivateKey, (fp), \ - (unsigned char **)(rsa)) -#define i2d_RSAPrivateKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPrivateKey,fp, \ - (unsigned char *)rsa) -#define d2i_RSAPrivateKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\ - RSA_new,(char *(*)())d2i_RSAPrivateKey, (bp), \ - (unsigned char **)(rsa)) -#define i2d_RSAPrivateKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPrivateKey,bp, \ - (unsigned char *)rsa) - -#define d2i_RSAPublicKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\ - RSA_new,(char *(*)())d2i_RSAPublicKey, (fp), \ - (unsigned char **)(rsa)) -#define i2d_RSAPublicKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPublicKey,fp, \ - (unsigned char *)rsa) -#define d2i_RSAPublicKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\ - RSA_new,(char *(*)())d2i_RSAPublicKey, (bp), \ - (unsigned char **)(rsa)) -#define i2d_RSAPublicKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPublicKey,bp, \ - (unsigned char *)rsa) - -#define d2i_DSAPrivateKey_fp(fp,dsa) (DSA *)ASN1_d2i_fp((char *(*)())\ - DSA_new,(char *(*)())d2i_DSAPrivateKey, (fp), \ - (unsigned char **)(dsa)) -#define i2d_DSAPrivateKey_fp(fp,dsa) ASN1_i2d_fp(i2d_DSAPrivateKey,fp, \ - (unsigned char *)dsa) -#define d2i_DSAPrivateKey_bio(bp,dsa) (DSA *)ASN1_d2i_bio((char *(*)())\ - DSA_new,(char *(*)())d2i_DSAPrivateKey, (bp), \ - (unsigned char **)(dsa)) -#define i2d_DSAPrivateKey_bio(bp,dsa) ASN1_i2d_bio(i2d_DSAPrivateKey,bp, \ - (unsigned char *)dsa) - -#define d2i_ECPrivateKey_fp(fp,ecdsa) (EC_KEY *)ASN1_d2i_fp((char *(*)())\ - EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (fp), \ - (unsigned char **)(ecdsa)) -#define i2d_ECPrivateKey_fp(fp,ecdsa) ASN1_i2d_fp(i2d_ECPrivateKey,fp, \ - (unsigned char *)ecdsa) -#define d2i_ECPrivateKey_bio(bp,ecdsa) (EC_KEY *)ASN1_d2i_bio((char *(*)())\ - EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (bp), \ - (unsigned char **)(ecdsa)) -#define i2d_ECPrivateKey_bio(bp,ecdsa) ASN1_i2d_bio(i2d_ECPrivateKey,bp, \ - (unsigned char *)ecdsa) - -#define X509_ALGOR_dup(xn) (X509_ALGOR *)ASN1_dup((int (*)())i2d_X509_ALGOR,\ - (char *(*)())d2i_X509_ALGOR,(char *)xn) - -#define X509_NAME_dup(xn) (X509_NAME *)ASN1_dup((int (*)())i2d_X509_NAME, \ - (char *(*)())d2i_X509_NAME,(char *)xn) -#define X509_NAME_ENTRY_dup(ne) (X509_NAME_ENTRY *)ASN1_dup( \ - (int (*)())i2d_X509_NAME_ENTRY, \ - (char *(*)())d2i_X509_NAME_ENTRY,\ - (char *)ne) - -#define X509_digest(data,type,md,len) \ - ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len) -#define X509_NAME_digest(data,type,md,len) \ - ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len) -#ifndef PKCS7_ISSUER_AND_SERIAL_digest -#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \ - ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\ - (char *)data,md,len) -#endif -#endif - -#define X509_EXT_PACK_UNKNOWN 1 -#define X509_EXT_PACK_STRING 2 - -#define X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version) -/* #define X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */ -#define X509_get_notBefore(x) ((x)->cert_info->validity->notBefore) -#define X509_get_notAfter(x) ((x)->cert_info->validity->notAfter) -#define X509_extract_key(x) X509_get_pubkey(x) /*****/ -#define X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version) -#define X509_REQ_get_subject_name(x) ((x)->req_info->subject) -#define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a) -#define X509_name_cmp(a,b) X509_NAME_cmp((a),(b)) -#define X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm)) - -#define X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version) -#define X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate) -#define X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate) -#define X509_CRL_get_issuer(x) ((x)->crl->issuer) -#define X509_CRL_get_REVOKED(x) ((x)->crl->revoked) - -/* This one is only used so that a binary form can output, as in - * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) */ -#define X509_get_X509_PUBKEY(x) ((x)->cert_info->key) - - -const char *X509_verify_cert_error_string(long n); - -#ifndef SSLEAY_MACROS -#ifndef OPENSSL_NO_EVP -int X509_verify(X509 *a, EVP_PKEY *r); - -int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r); -int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r); -int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r); - -NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len); -char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x); -EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x); -int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey); - -int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki); - -int X509_signature_print(BIO *bp,X509_ALGOR *alg, ASN1_STRING *sig); - -int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); -int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); -int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); -int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md); - -int X509_pubkey_digest(const X509 *data,const EVP_MD *type, - unsigned char *md, unsigned int *len); -int X509_digest(const X509 *data,const EVP_MD *type, - unsigned char *md, unsigned int *len); -int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type, - unsigned char *md, unsigned int *len); -int X509_REQ_digest(const X509_REQ *data,const EVP_MD *type, - unsigned char *md, unsigned int *len); -int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type, - unsigned char *md, unsigned int *len); -#endif - -#ifndef OPENSSL_NO_FP_API -X509 *d2i_X509_fp(FILE *fp, X509 **x509); -int i2d_X509_fp(FILE *fp,X509 *x509); -X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl); -int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl); -X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req); -int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req); -#ifndef OPENSSL_NO_RSA -RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa); -int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa); -RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa); -int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa); -RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa); -int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa); -#endif -#ifndef OPENSSL_NO_DSA -DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa); -int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa); -DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa); -int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa); -#endif -#ifndef OPENSSL_NO_EC -EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey); -int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey); -EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey); -int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey); -#endif -X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8); -int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8); -PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, - PKCS8_PRIV_KEY_INFO **p8inf); -int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf); -int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key); -int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey); -EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a); -int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey); -EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a); -#endif - -#ifndef OPENSSL_NO_BIO -X509 *d2i_X509_bio(BIO *bp,X509 **x509); -int i2d_X509_bio(BIO *bp,X509 *x509); -X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl); -int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl); -X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req); -int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req); -#ifndef OPENSSL_NO_RSA -RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa); -int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa); -RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa); -int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa); -RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa); -int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa); -#endif -#ifndef OPENSSL_NO_DSA -DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa); -int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa); -DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa); -int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa); -#endif -#ifndef OPENSSL_NO_EC -EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey); -int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey); -EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey); -int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey); -#endif -X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8); -int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8); -PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, - PKCS8_PRIV_KEY_INFO **p8inf); -int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf); -int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key); -int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey); -EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a); -int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey); -EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a); -#endif - -X509 *X509_dup(X509 *x509); -X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa); -X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex); -X509_CRL *X509_CRL_dup(X509_CRL *crl); -X509_REQ *X509_REQ_dup(X509_REQ *req); -X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn); -X509_NAME *X509_NAME_dup(X509_NAME *xn); -X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne); - -#endif /* !SSLEAY_MACROS */ - -int X509_cmp_time(ASN1_TIME *s, time_t *t); -int X509_cmp_current_time(ASN1_TIME *s); -ASN1_TIME * X509_time_adj(ASN1_TIME *s, long adj, time_t *t); -ASN1_TIME * X509_gmtime_adj(ASN1_TIME *s, long adj); - -const char * X509_get_default_cert_area(void ); -const char * X509_get_default_cert_dir(void ); -const char * X509_get_default_cert_file(void ); -const char * X509_get_default_cert_dir_env(void ); -const char * X509_get_default_cert_file_env(void ); -const char * X509_get_default_private_dir(void ); - -X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); -X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey); - -DECLARE_ASN1_FUNCTIONS(X509_ALGOR) -DECLARE_ASN1_FUNCTIONS(X509_VAL) - -DECLARE_ASN1_FUNCTIONS(X509_PUBKEY) - -int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey); -EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key); -int X509_get_pubkey_parameters(EVP_PKEY *pkey, - STACK_OF(X509) *chain); -int i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp); -EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,const unsigned char **pp, - long length); -#ifndef OPENSSL_NO_RSA -int i2d_RSA_PUBKEY(RSA *a,unsigned char **pp); -RSA * d2i_RSA_PUBKEY(RSA **a,const unsigned char **pp, - long length); -#endif -#ifndef OPENSSL_NO_DSA -int i2d_DSA_PUBKEY(DSA *a,unsigned char **pp); -DSA * d2i_DSA_PUBKEY(DSA **a,const unsigned char **pp, - long length); -#endif -#ifndef OPENSSL_NO_EC -int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp); -EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, - long length); -#endif - -DECLARE_ASN1_FUNCTIONS(X509_SIG) -DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO) -DECLARE_ASN1_FUNCTIONS(X509_REQ) - -DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE) -X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value); - -DECLARE_ASN1_FUNCTIONS(X509_EXTENSION) - -DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY) - -DECLARE_ASN1_FUNCTIONS(X509_NAME) - -int X509_NAME_set(X509_NAME **xn, X509_NAME *name); - -DECLARE_ASN1_FUNCTIONS(X509_CINF) - -DECLARE_ASN1_FUNCTIONS(X509) -DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX) - -DECLARE_ASN1_FUNCTIONS(X509_CERT_PAIR) - -int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); -int X509_set_ex_data(X509 *r, int idx, void *arg); -void *X509_get_ex_data(X509 *r, int idx); -int i2d_X509_AUX(X509 *a,unsigned char **pp); -X509 * d2i_X509_AUX(X509 **a,const unsigned char **pp,long length); - -int X509_alias_set1(X509 *x, unsigned char *name, int len); -int X509_keyid_set1(X509 *x, unsigned char *id, int len); -unsigned char * X509_alias_get0(X509 *x, int *len); -unsigned char * X509_keyid_get0(X509 *x, int *len); -int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int); -int X509_TRUST_set(int *t, int trust); -int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj); -int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj); -void X509_trust_clear(X509 *x); -void X509_reject_clear(X509 *x); - -DECLARE_ASN1_FUNCTIONS(X509_REVOKED) -DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO) -DECLARE_ASN1_FUNCTIONS(X509_CRL) - -int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev); - -X509_PKEY * X509_PKEY_new(void ); -void X509_PKEY_free(X509_PKEY *a); -int i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp); -X509_PKEY * d2i_X509_PKEY(X509_PKEY **a,const unsigned char **pp,long length); - -DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI) -DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC) -DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE) - -#ifndef OPENSSL_NO_EVP -X509_INFO * X509_INFO_new(void); -void X509_INFO_free(X509_INFO *a); -char * X509_NAME_oneline(X509_NAME *a,char *buf,int size); - -int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1, - ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey); - -int ASN1_digest(i2d_of_void *i2d,const EVP_MD *type,char *data, - unsigned char *md,unsigned int *len); - -int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, - X509_ALGOR *algor2, ASN1_BIT_STRING *signature, - char *data,EVP_PKEY *pkey, const EVP_MD *type); - -int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data, - unsigned char *md,unsigned int *len); - -int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1, - ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey); - -int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, - ASN1_BIT_STRING *signature, - void *data, EVP_PKEY *pkey, const EVP_MD *type); -#endif - -int X509_set_version(X509 *x,long version); -int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial); -ASN1_INTEGER * X509_get_serialNumber(X509 *x); -int X509_set_issuer_name(X509 *x, X509_NAME *name); -X509_NAME * X509_get_issuer_name(X509 *a); -int X509_set_subject_name(X509 *x, X509_NAME *name); -X509_NAME * X509_get_subject_name(X509 *a); -int X509_set_notBefore(X509 *x, ASN1_TIME *tm); -int X509_set_notAfter(X509 *x, ASN1_TIME *tm); -int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); -EVP_PKEY * X509_get_pubkey(X509 *x); -ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x); -int X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */); - -int X509_REQ_set_version(X509_REQ *x,long version); -int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name); -int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); -EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req); -int X509_REQ_extension_nid(int nid); -int * X509_REQ_get_extension_nids(void); -void X509_REQ_set_extension_nids(int *nids); -STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req); -int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, - int nid); -int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts); -int X509_REQ_get_attr_count(const X509_REQ *req); -int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, - int lastpos); -int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj, - int lastpos); -X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc); -X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc); -int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr); -int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, - const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len); -int X509_REQ_add1_attr_by_NID(X509_REQ *req, - int nid, int type, - const unsigned char *bytes, int len); -int X509_REQ_add1_attr_by_txt(X509_REQ *req, - const char *attrname, int type, - const unsigned char *bytes, int len); - -int X509_CRL_set_version(X509_CRL *x, long version); -int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name); -int X509_CRL_set_lastUpdate(X509_CRL *x, ASN1_TIME *tm); -int X509_CRL_set_nextUpdate(X509_CRL *x, ASN1_TIME *tm); -int X509_CRL_sort(X509_CRL *crl); - -int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial); -int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm); - -int X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey); - -int X509_check_private_key(X509 *x509,EVP_PKEY *pkey); - -int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b); -unsigned long X509_issuer_and_serial_hash(X509 *a); - -int X509_issuer_name_cmp(const X509 *a, const X509 *b); -unsigned long X509_issuer_name_hash(X509 *a); - -int X509_subject_name_cmp(const X509 *a, const X509 *b); -unsigned long X509_subject_name_hash(X509 *x); - -int X509_cmp(const X509 *a, const X509 *b); -int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b); -unsigned long X509_NAME_hash(X509_NAME *x); - -int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); -#ifndef OPENSSL_NO_FP_API -int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag); -int X509_print_fp(FILE *bp,X509 *x); -int X509_CRL_print_fp(FILE *bp,X509_CRL *x); -int X509_REQ_print_fp(FILE *bp,X509_REQ *req); -int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags); -#endif - -#ifndef OPENSSL_NO_BIO -int X509_NAME_print(BIO *bp, X509_NAME *name, int obase); -int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags); -int X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag); -int X509_print(BIO *bp,X509 *x); -int X509_ocspid_print(BIO *bp,X509 *x); -int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent); -int X509_CRL_print(BIO *bp,X509_CRL *x); -int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag); -int X509_REQ_print(BIO *bp,X509_REQ *req); -#endif - -int X509_NAME_entry_count(X509_NAME *name); -int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, - char *buf,int len); -int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, - char *buf,int len); - -/* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use - * lastpos, search after that position on. */ -int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos); -int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj, - int lastpos); -X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc); -X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); -int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, - int loc, int set); -int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, - unsigned char *bytes, int len, int loc, int set); -int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, - unsigned char *bytes, int len, int loc, int set); -X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, - const char *field, int type, const unsigned char *bytes, int len); -X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, - int type,unsigned char *bytes, int len); -int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, - const unsigned char *bytes, int len, int loc, int set); -X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, - ASN1_OBJECT *obj, int type,const unsigned char *bytes, - int len); -int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, - ASN1_OBJECT *obj); -int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, - const unsigned char *bytes, int len); -ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne); -ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne); - -int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x); -int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, - int nid, int lastpos); -int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x, - ASN1_OBJECT *obj,int lastpos); -int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x, - int crit, int lastpos); -X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc); -X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc); -STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, - X509_EXTENSION *ex, int loc); - -int X509_get_ext_count(X509 *x); -int X509_get_ext_by_NID(X509 *x, int nid, int lastpos); -int X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos); -int X509_get_ext_by_critical(X509 *x, int crit, int lastpos); -X509_EXTENSION *X509_get_ext(X509 *x, int loc); -X509_EXTENSION *X509_delete_ext(X509 *x, int loc); -int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); -void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx); -int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, - unsigned long flags); - -int X509_CRL_get_ext_count(X509_CRL *x); -int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos); -int X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos); -int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos); -X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc); -X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); -int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); -void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx); -int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, - unsigned long flags); - -int X509_REVOKED_get_ext_count(X509_REVOKED *x); -int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos); -int X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos); -int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos); -X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc); -X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); -int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); -void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx); -int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, - unsigned long flags); - -X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, - int nid, int crit, ASN1_OCTET_STRING *data); -X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, - ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data); -int X509_EXTENSION_set_object(X509_EXTENSION *ex,ASN1_OBJECT *obj); -int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit); -int X509_EXTENSION_set_data(X509_EXTENSION *ex, - ASN1_OCTET_STRING *data); -ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex); -ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne); -int X509_EXTENSION_get_critical(X509_EXTENSION *ex); - -int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x); -int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, - int lastpos); -int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj, - int lastpos); -X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc); -X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc); -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, - X509_ATTRIBUTE *attr); -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x, - const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len); -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x, - int nid, int type, - const unsigned char *bytes, int len); -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x, - const char *attrname, int type, - const unsigned char *bytes, int len); -X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, - int atrtype, const void *data, int len); -X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, - const ASN1_OBJECT *obj, int atrtype, const void *data, int len); -X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, - const char *atrname, int type, const unsigned char *bytes, int len); -int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj); -int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len); -void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, - int atrtype, void *data); -int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr); -ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr); -ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx); - -int EVP_PKEY_get_attr_count(const EVP_PKEY *key); -int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, - int lastpos); -int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj, - int lastpos); -X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc); -X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc); -int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr); -int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key, - const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len); -int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key, - int nid, int type, - const unsigned char *bytes, int len); -int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key, - const char *attrname, int type, - const unsigned char *bytes, int len); - -int X509_verify_cert(X509_STORE_CTX *ctx); - -/* lookup a cert from a X509 STACK */ -X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name, - ASN1_INTEGER *serial); -X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name); - -DECLARE_ASN1_FUNCTIONS(PBEPARAM) -DECLARE_ASN1_FUNCTIONS(PBE2PARAM) -DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM) - -X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, int saltlen); -X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, - unsigned char *salt, int saltlen); - -/* PKCS#8 utilities */ - -DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) - -EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8); -PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey); -PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken); -PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken); - -int X509_check_trust(X509 *x, int id, int flags); -int X509_TRUST_get_count(void); -X509_TRUST * X509_TRUST_get0(int idx); -int X509_TRUST_get_by_id(int id); -int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), - char *name, int arg1, void *arg2); -void X509_TRUST_cleanup(void); -int X509_TRUST_get_flags(X509_TRUST *xp); -char *X509_TRUST_get0_name(X509_TRUST *xp); -int X509_TRUST_get_trust(X509_TRUST *xp); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_X509_strings(void); - -/* Error codes for the X509 functions. */ - -/* Function codes. */ -#define X509_F_ADD_CERT_DIR 100 -#define X509_F_BY_FILE_CTRL 101 -#define X509_F_CHECK_POLICY 145 -#define X509_F_DIR_CTRL 102 -#define X509_F_GET_CERT_BY_SUBJECT 103 -#define X509_F_NETSCAPE_SPKI_B64_DECODE 129 -#define X509_F_NETSCAPE_SPKI_B64_ENCODE 130 -#define X509_F_X509AT_ADD1_ATTR 135 -#define X509_F_X509V3_ADD_EXT 104 -#define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 136 -#define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 137 -#define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 140 -#define X509_F_X509_ATTRIBUTE_GET0_DATA 139 -#define X509_F_X509_ATTRIBUTE_SET1_DATA 138 -#define X509_F_X509_CHECK_PRIVATE_KEY 128 -#define X509_F_X509_CRL_PRINT_FP 147 -#define X509_F_X509_EXTENSION_CREATE_BY_NID 108 -#define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109 -#define X509_F_X509_GET_PUBKEY_PARAMETERS 110 -#define X509_F_X509_LOAD_CERT_CRL_FILE 132 -#define X509_F_X509_LOAD_CERT_FILE 111 -#define X509_F_X509_LOAD_CRL_FILE 112 -#define X509_F_X509_NAME_ADD_ENTRY 113 -#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114 -#define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 131 -#define X509_F_X509_NAME_ENTRY_SET_OBJECT 115 -#define X509_F_X509_NAME_ONELINE 116 -#define X509_F_X509_NAME_PRINT 117 -#define X509_F_X509_PRINT_EX_FP 118 -#define X509_F_X509_PUBKEY_GET 119 -#define X509_F_X509_PUBKEY_SET 120 -#define X509_F_X509_REQ_CHECK_PRIVATE_KEY 144 -#define X509_F_X509_REQ_PRINT_EX 121 -#define X509_F_X509_REQ_PRINT_FP 122 -#define X509_F_X509_REQ_TO_X509 123 -#define X509_F_X509_STORE_ADD_CERT 124 -#define X509_F_X509_STORE_ADD_CRL 125 -#define X509_F_X509_STORE_CTX_GET1_ISSUER 146 -#define X509_F_X509_STORE_CTX_INIT 143 -#define X509_F_X509_STORE_CTX_NEW 142 -#define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134 -#define X509_F_X509_TO_X509_REQ 126 -#define X509_F_X509_TRUST_ADD 133 -#define X509_F_X509_TRUST_SET 141 -#define X509_F_X509_VERIFY_CERT 127 - -/* Reason codes. */ -#define X509_R_BAD_X509_FILETYPE 100 -#define X509_R_BASE64_DECODE_ERROR 118 -#define X509_R_CANT_CHECK_DH_KEY 114 -#define X509_R_CERT_ALREADY_IN_HASH_TABLE 101 -#define X509_R_ERR_ASN1_LIB 102 -#define X509_R_INVALID_DIRECTORY 113 -#define X509_R_INVALID_FIELD_NAME 119 -#define X509_R_INVALID_TRUST 123 -#define X509_R_KEY_TYPE_MISMATCH 115 -#define X509_R_KEY_VALUES_MISMATCH 116 -#define X509_R_LOADING_CERT_DIR 103 -#define X509_R_LOADING_DEFAULTS 104 -#define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105 -#define X509_R_SHOULD_RETRY 106 -#define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107 -#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108 -#define X509_R_UNKNOWN_KEY_TYPE 117 -#define X509_R_UNKNOWN_NID 109 -#define X509_R_UNKNOWN_PURPOSE_ID 121 -#define X509_R_UNKNOWN_TRUST_ID 120 -#define X509_R_UNSUPPORTED_ALGORITHM 111 -#define X509_R_WRONG_LOOKUP_TYPE 112 -#define X509_R_WRONG_TYPE 122 - -#ifdef __cplusplus -} -#endif -#endif +/* crypto/x509/x509.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECDH support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_X509_H +#define HEADER_X509_H + +#include +#include +#ifndef OPENSSL_NO_BUFFER +#include +#endif +#ifndef OPENSSL_NO_EVP +#include +#endif +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include +#include + +#ifndef OPENSSL_NO_EC +#include +#endif + +#ifndef OPENSSL_NO_ECDSA +#include +#endif + +#ifndef OPENSSL_NO_ECDH +#include +#endif + +#ifndef OPENSSL_NO_DEPRECATED +#ifndef OPENSSL_NO_RSA +#include +#endif +#ifndef OPENSSL_NO_DSA +#include +#endif +#ifndef OPENSSL_NO_DH +#include +#endif +#endif + +#ifndef OPENSSL_NO_SHA +#include +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_SYS_WIN32 +/* Under Win32 these are defined in wincrypt.h */ +#undef X509_NAME +#undef X509_CERT_PAIR +#endif + +#define X509_FILETYPE_PEM 1 +#define X509_FILETYPE_ASN1 2 +#define X509_FILETYPE_DEFAULT 3 + +#define X509v3_KU_DIGITAL_SIGNATURE 0x0080 +#define X509v3_KU_NON_REPUDIATION 0x0040 +#define X509v3_KU_KEY_ENCIPHERMENT 0x0020 +#define X509v3_KU_DATA_ENCIPHERMENT 0x0010 +#define X509v3_KU_KEY_AGREEMENT 0x0008 +#define X509v3_KU_KEY_CERT_SIGN 0x0004 +#define X509v3_KU_CRL_SIGN 0x0002 +#define X509v3_KU_ENCIPHER_ONLY 0x0001 +#define X509v3_KU_DECIPHER_ONLY 0x8000 +#define X509v3_KU_UNDEF 0xffff + +typedef struct X509_objects_st + { + int nid; + int (*a2i)(void); + int (*i2a)(void); + } X509_OBJECTS; + +struct X509_algor_st + { + ASN1_OBJECT *algorithm; + ASN1_TYPE *parameter; + } /* X509_ALGOR */; + +DECLARE_STACK_OF(X509_ALGOR) +DECLARE_ASN1_SET_OF(X509_ALGOR) + +typedef struct X509_val_st + { + ASN1_TIME *notBefore; + ASN1_TIME *notAfter; + } X509_VAL; + +typedef struct X509_pubkey_st + { + X509_ALGOR *algor; + ASN1_BIT_STRING *public_key; + EVP_PKEY *pkey; + } X509_PUBKEY; + +typedef struct X509_sig_st + { + X509_ALGOR *algor; + ASN1_OCTET_STRING *digest; + } X509_SIG; + +typedef struct X509_name_entry_st + { + ASN1_OBJECT *object; + ASN1_STRING *value; + int set; + int size; /* temp variable */ + } X509_NAME_ENTRY; + +DECLARE_STACK_OF(X509_NAME_ENTRY) +DECLARE_ASN1_SET_OF(X509_NAME_ENTRY) + +/* we always keep X509_NAMEs in 2 forms. */ +struct X509_name_st + { + STACK_OF(X509_NAME_ENTRY) *entries; + int modified; /* true if 'bytes' needs to be built */ +#ifndef OPENSSL_NO_BUFFER + BUF_MEM *bytes; +#else + char *bytes; +#endif + unsigned long hash; /* Keep the hash around for lookups */ + } /* X509_NAME */; + +DECLARE_STACK_OF(X509_NAME) + +#define X509_EX_V_NETSCAPE_HACK 0x8000 +#define X509_EX_V_INIT 0x0001 +typedef struct X509_extension_st + { + ASN1_OBJECT *object; + ASN1_BOOLEAN critical; + ASN1_OCTET_STRING *value; + } X509_EXTENSION; + +DECLARE_STACK_OF(X509_EXTENSION) +DECLARE_ASN1_SET_OF(X509_EXTENSION) + +/* a sequence of these are used */ +typedef struct x509_attributes_st + { + ASN1_OBJECT *object; + int single; /* 0 for a set, 1 for a single item (which is wrong) */ + union { + char *ptr; +/* 0 */ STACK_OF(ASN1_TYPE) *set; +/* 1 */ ASN1_TYPE *single; + } value; + } X509_ATTRIBUTE; + +DECLARE_STACK_OF(X509_ATTRIBUTE) +DECLARE_ASN1_SET_OF(X509_ATTRIBUTE) + + +typedef struct X509_req_info_st + { + ASN1_ENCODING enc; + ASN1_INTEGER *version; + X509_NAME *subject; + X509_PUBKEY *pubkey; + /* d=2 hl=2 l= 0 cons: cont: 00 */ + STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ + } X509_REQ_INFO; + +typedef struct X509_req_st + { + X509_REQ_INFO *req_info; + X509_ALGOR *sig_alg; + ASN1_BIT_STRING *signature; + int references; + } X509_REQ; + +typedef struct x509_cinf_st + { + ASN1_INTEGER *version; /* [ 0 ] default of v1 */ + ASN1_INTEGER *serialNumber; + X509_ALGOR *signature; + X509_NAME *issuer; + X509_VAL *validity; + X509_NAME *subject; + X509_PUBKEY *key; + ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */ + ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */ + STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */ + } X509_CINF; + +/* This stuff is certificate "auxiliary info" + * it contains details which are useful in certificate + * stores and databases. When used this is tagged onto + * the end of the certificate itself + */ + +typedef struct x509_cert_aux_st + { + STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */ + STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */ + ASN1_UTF8STRING *alias; /* "friendly name" */ + ASN1_OCTET_STRING *keyid; /* key id of private key */ + STACK_OF(X509_ALGOR) *other; /* other unspecified info */ + } X509_CERT_AUX; + +struct x509_st + { + X509_CINF *cert_info; + X509_ALGOR *sig_alg; + ASN1_BIT_STRING *signature; + int valid; + int references; + char *name; + CRYPTO_EX_DATA ex_data; + /* These contain copies of various extension values */ + long ex_pathlen; + long ex_pcpathlen; + unsigned long ex_flags; + unsigned long ex_kusage; + unsigned long ex_xkusage; + unsigned long ex_nscert; + ASN1_OCTET_STRING *skid; + struct AUTHORITY_KEYID_st *akid; + X509_POLICY_CACHE *policy_cache; +#ifndef OPENSSL_NO_SHA + unsigned char sha1_hash[SHA_DIGEST_LENGTH]; +#endif + X509_CERT_AUX *aux; + } /* X509 */; + +DECLARE_STACK_OF(X509) +DECLARE_ASN1_SET_OF(X509) + +/* This is used for a table of trust checking functions */ + +typedef struct x509_trust_st { + int trust; + int flags; + int (*check_trust)(struct x509_trust_st *, X509 *, int); + char *name; + int arg1; + void *arg2; +} X509_TRUST; + +DECLARE_STACK_OF(X509_TRUST) + +typedef struct x509_cert_pair_st { + X509 *forward; + X509 *reverse; +} X509_CERT_PAIR; + +/* standard trust ids */ + +#define X509_TRUST_DEFAULT -1 /* Only valid in purpose settings */ + +#define X509_TRUST_COMPAT 1 +#define X509_TRUST_SSL_CLIENT 2 +#define X509_TRUST_SSL_SERVER 3 +#define X509_TRUST_EMAIL 4 +#define X509_TRUST_OBJECT_SIGN 5 +#define X509_TRUST_OCSP_SIGN 6 +#define X509_TRUST_OCSP_REQUEST 7 + +/* Keep these up to date! */ +#define X509_TRUST_MIN 1 +#define X509_TRUST_MAX 7 + + +/* trust_flags values */ +#define X509_TRUST_DYNAMIC 1 +#define X509_TRUST_DYNAMIC_NAME 2 + +/* check_trust return codes */ + +#define X509_TRUST_TRUSTED 1 +#define X509_TRUST_REJECTED 2 +#define X509_TRUST_UNTRUSTED 3 + +/* Flags for X509_print_ex() */ + +#define X509_FLAG_COMPAT 0 +#define X509_FLAG_NO_HEADER 1L +#define X509_FLAG_NO_VERSION (1L << 1) +#define X509_FLAG_NO_SERIAL (1L << 2) +#define X509_FLAG_NO_SIGNAME (1L << 3) +#define X509_FLAG_NO_ISSUER (1L << 4) +#define X509_FLAG_NO_VALIDITY (1L << 5) +#define X509_FLAG_NO_SUBJECT (1L << 6) +#define X509_FLAG_NO_PUBKEY (1L << 7) +#define X509_FLAG_NO_EXTENSIONS (1L << 8) +#define X509_FLAG_NO_SIGDUMP (1L << 9) +#define X509_FLAG_NO_AUX (1L << 10) +#define X509_FLAG_NO_ATTRIBUTES (1L << 11) + +/* Flags specific to X509_NAME_print_ex() */ + +/* The field separator information */ + +#define XN_FLAG_SEP_MASK (0xf << 16) + +#define XN_FLAG_COMPAT 0 /* Traditional SSLeay: use old X509_NAME_print */ +#define XN_FLAG_SEP_COMMA_PLUS (1 << 16) /* RFC2253 ,+ */ +#define XN_FLAG_SEP_CPLUS_SPC (2 << 16) /* ,+ spaced: more readable */ +#define XN_FLAG_SEP_SPLUS_SPC (3 << 16) /* ;+ spaced */ +#define XN_FLAG_SEP_MULTILINE (4 << 16) /* One line per field */ + +#define XN_FLAG_DN_REV (1 << 20) /* Reverse DN order */ + +/* How the field name is shown */ + +#define XN_FLAG_FN_MASK (0x3 << 21) + +#define XN_FLAG_FN_SN 0 /* Object short name */ +#define XN_FLAG_FN_LN (1 << 21) /* Object long name */ +#define XN_FLAG_FN_OID (2 << 21) /* Always use OIDs */ +#define XN_FLAG_FN_NONE (3 << 21) /* No field names */ + +#define XN_FLAG_SPC_EQ (1 << 23) /* Put spaces round '=' */ + +/* This determines if we dump fields we don't recognise: + * RFC2253 requires this. + */ + +#define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24) + +#define XN_FLAG_FN_ALIGN (1 << 25) /* Align field names to 20 characters */ + +/* Complete set of RFC2253 flags */ + +#define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \ + XN_FLAG_SEP_COMMA_PLUS | \ + XN_FLAG_DN_REV | \ + XN_FLAG_FN_SN | \ + XN_FLAG_DUMP_UNKNOWN_FIELDS) + +/* readable oneline form */ + +#define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \ + ASN1_STRFLGS_ESC_QUOTE | \ + XN_FLAG_SEP_CPLUS_SPC | \ + XN_FLAG_SPC_EQ | \ + XN_FLAG_FN_SN) + +/* readable multiline form */ + +#define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \ + ASN1_STRFLGS_ESC_MSB | \ + XN_FLAG_SEP_MULTILINE | \ + XN_FLAG_SPC_EQ | \ + XN_FLAG_FN_LN | \ + XN_FLAG_FN_ALIGN) + +typedef struct X509_revoked_st + { + ASN1_INTEGER *serialNumber; + ASN1_TIME *revocationDate; + STACK_OF(X509_EXTENSION) /* optional */ *extensions; + int sequence; /* load sequence */ + } X509_REVOKED; + +DECLARE_STACK_OF(X509_REVOKED) +DECLARE_ASN1_SET_OF(X509_REVOKED) + +typedef struct X509_crl_info_st + { + ASN1_INTEGER *version; + X509_ALGOR *sig_alg; + X509_NAME *issuer; + ASN1_TIME *lastUpdate; + ASN1_TIME *nextUpdate; + STACK_OF(X509_REVOKED) *revoked; + STACK_OF(X509_EXTENSION) /* [0] */ *extensions; + ASN1_ENCODING enc; + } X509_CRL_INFO; + +struct X509_crl_st + { + /* actual signature */ + X509_CRL_INFO *crl; + X509_ALGOR *sig_alg; + ASN1_BIT_STRING *signature; + int references; + } /* X509_CRL */; + +DECLARE_STACK_OF(X509_CRL) +DECLARE_ASN1_SET_OF(X509_CRL) + +typedef struct private_key_st + { + int version; + /* The PKCS#8 data types */ + X509_ALGOR *enc_algor; + ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */ + + /* When decrypted, the following will not be NULL */ + EVP_PKEY *dec_pkey; + + /* used to encrypt and decrypt */ + int key_length; + char *key_data; + int key_free; /* true if we should auto free key_data */ + + /* expanded version of 'enc_algor' */ + EVP_CIPHER_INFO cipher; + + int references; + } X509_PKEY; + +#ifndef OPENSSL_NO_EVP +typedef struct X509_info_st + { + X509 *x509; + X509_CRL *crl; + X509_PKEY *x_pkey; + + EVP_CIPHER_INFO enc_cipher; + int enc_len; + char *enc_data; + + int references; + } X509_INFO; + +DECLARE_STACK_OF(X509_INFO) +#endif + +/* The next 2 structures and their 8 routines were sent to me by + * Pat Richard and are used to manipulate + * Netscapes spki structures - useful if you are writing a CA web page + */ +typedef struct Netscape_spkac_st + { + X509_PUBKEY *pubkey; + ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */ + } NETSCAPE_SPKAC; + +typedef struct Netscape_spki_st + { + NETSCAPE_SPKAC *spkac; /* signed public key and challenge */ + X509_ALGOR *sig_algor; + ASN1_BIT_STRING *signature; + } NETSCAPE_SPKI; + +/* Netscape certificate sequence structure */ +typedef struct Netscape_certificate_sequence + { + ASN1_OBJECT *type; + STACK_OF(X509) *certs; + } NETSCAPE_CERT_SEQUENCE; + +/* Unused (and iv length is wrong) +typedef struct CBCParameter_st + { + unsigned char iv[8]; + } CBC_PARAM; +*/ + +/* Password based encryption structure */ + +typedef struct PBEPARAM_st { +ASN1_OCTET_STRING *salt; +ASN1_INTEGER *iter; +} PBEPARAM; + +/* Password based encryption V2 structures */ + +typedef struct PBE2PARAM_st { +X509_ALGOR *keyfunc; +X509_ALGOR *encryption; +} PBE2PARAM; + +typedef struct PBKDF2PARAM_st { +ASN1_TYPE *salt; /* Usually OCTET STRING but could be anything */ +ASN1_INTEGER *iter; +ASN1_INTEGER *keylength; +X509_ALGOR *prf; +} PBKDF2PARAM; + + +/* PKCS#8 private key info structure */ + +typedef struct pkcs8_priv_key_info_st + { + int broken; /* Flag for various broken formats */ +#define PKCS8_OK 0 +#define PKCS8_NO_OCTET 1 +#define PKCS8_EMBEDDED_PARAM 2 +#define PKCS8_NS_DB 3 + ASN1_INTEGER *version; + X509_ALGOR *pkeyalg; + ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */ + STACK_OF(X509_ATTRIBUTE) *attributes; + } PKCS8_PRIV_KEY_INFO; + +#ifdef __cplusplus +} +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef SSLEAY_MACROS +#define X509_verify(a,r) ASN1_verify((int (*)())i2d_X509_CINF,a->sig_alg,\ + a->signature,(char *)a->cert_info,r) +#define X509_REQ_verify(a,r) ASN1_verify((int (*)())i2d_X509_REQ_INFO, \ + a->sig_alg,a->signature,(char *)a->req_info,r) +#define X509_CRL_verify(a,r) ASN1_verify((int (*)())i2d_X509_CRL_INFO, \ + a->sig_alg, a->signature,(char *)a->crl,r) + +#define X509_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_X509_CINF, x->cert_info->signature, \ + x->sig_alg, x->signature, (char *)x->cert_info,pkey,md) +#define X509_REQ_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_X509_REQ_INFO,x->sig_alg, NULL, \ + x->signature, (char *)x->req_info,pkey,md) +#define X509_CRL_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_X509_CRL_INFO,x->crl->sig_alg,x->sig_alg, \ + x->signature, (char *)x->crl,pkey,md) +#define NETSCAPE_SPKI_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_NETSCAPE_SPKAC, x->sig_algor,NULL, \ + x->signature, (char *)x->spkac,pkey,md) + +#define X509_dup(x509) (X509 *)ASN1_dup((int (*)())i2d_X509, \ + (char *(*)())d2i_X509,(char *)x509) +#define X509_ATTRIBUTE_dup(xa) (X509_ATTRIBUTE *)ASN1_dup(\ + (int (*)())i2d_X509_ATTRIBUTE, \ + (char *(*)())d2i_X509_ATTRIBUTE,(char *)xa) +#define X509_EXTENSION_dup(ex) (X509_EXTENSION *)ASN1_dup( \ + (int (*)())i2d_X509_EXTENSION, \ + (char *(*)())d2i_X509_EXTENSION,(char *)ex) +#define d2i_X509_fp(fp,x509) (X509 *)ASN1_d2i_fp((char *(*)())X509_new, \ + (char *(*)())d2i_X509, (fp),(unsigned char **)(x509)) +#define i2d_X509_fp(fp,x509) ASN1_i2d_fp(i2d_X509,fp,(unsigned char *)x509) +#define d2i_X509_bio(bp,x509) (X509 *)ASN1_d2i_bio((char *(*)())X509_new, \ + (char *(*)())d2i_X509, (bp),(unsigned char **)(x509)) +#define i2d_X509_bio(bp,x509) ASN1_i2d_bio(i2d_X509,bp,(unsigned char *)x509) + +#define X509_CRL_dup(crl) (X509_CRL *)ASN1_dup((int (*)())i2d_X509_CRL, \ + (char *(*)())d2i_X509_CRL,(char *)crl) +#define d2i_X509_CRL_fp(fp,crl) (X509_CRL *)ASN1_d2i_fp((char *(*)()) \ + X509_CRL_new,(char *(*)())d2i_X509_CRL, (fp),\ + (unsigned char **)(crl)) +#define i2d_X509_CRL_fp(fp,crl) ASN1_i2d_fp(i2d_X509_CRL,fp,\ + (unsigned char *)crl) +#define d2i_X509_CRL_bio(bp,crl) (X509_CRL *)ASN1_d2i_bio((char *(*)()) \ + X509_CRL_new,(char *(*)())d2i_X509_CRL, (bp),\ + (unsigned char **)(crl)) +#define i2d_X509_CRL_bio(bp,crl) ASN1_i2d_bio(i2d_X509_CRL,bp,\ + (unsigned char *)crl) + +#define PKCS7_dup(p7) (PKCS7 *)ASN1_dup((int (*)())i2d_PKCS7, \ + (char *(*)())d2i_PKCS7,(char *)p7) +#define d2i_PKCS7_fp(fp,p7) (PKCS7 *)ASN1_d2i_fp((char *(*)()) \ + PKCS7_new,(char *(*)())d2i_PKCS7, (fp),\ + (unsigned char **)(p7)) +#define i2d_PKCS7_fp(fp,p7) ASN1_i2d_fp(i2d_PKCS7,fp,\ + (unsigned char *)p7) +#define d2i_PKCS7_bio(bp,p7) (PKCS7 *)ASN1_d2i_bio((char *(*)()) \ + PKCS7_new,(char *(*)())d2i_PKCS7, (bp),\ + (unsigned char **)(p7)) +#define i2d_PKCS7_bio(bp,p7) ASN1_i2d_bio(i2d_PKCS7,bp,\ + (unsigned char *)p7) + +#define X509_REQ_dup(req) (X509_REQ *)ASN1_dup((int (*)())i2d_X509_REQ, \ + (char *(*)())d2i_X509_REQ,(char *)req) +#define d2i_X509_REQ_fp(fp,req) (X509_REQ *)ASN1_d2i_fp((char *(*)())\ + X509_REQ_new, (char *(*)())d2i_X509_REQ, (fp),\ + (unsigned char **)(req)) +#define i2d_X509_REQ_fp(fp,req) ASN1_i2d_fp(i2d_X509_REQ,fp,\ + (unsigned char *)req) +#define d2i_X509_REQ_bio(bp,req) (X509_REQ *)ASN1_d2i_bio((char *(*)())\ + X509_REQ_new, (char *(*)())d2i_X509_REQ, (bp),\ + (unsigned char **)(req)) +#define i2d_X509_REQ_bio(bp,req) ASN1_i2d_bio(i2d_X509_REQ,bp,\ + (unsigned char *)req) + +#define RSAPublicKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPublicKey, \ + (char *(*)())d2i_RSAPublicKey,(char *)rsa) +#define RSAPrivateKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPrivateKey, \ + (char *(*)())d2i_RSAPrivateKey,(char *)rsa) + +#define d2i_RSAPrivateKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPrivateKey, (fp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPrivateKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPrivateKey,fp, \ + (unsigned char *)rsa) +#define d2i_RSAPrivateKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPrivateKey, (bp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPrivateKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPrivateKey,bp, \ + (unsigned char *)rsa) + +#define d2i_RSAPublicKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPublicKey, (fp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPublicKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPublicKey,fp, \ + (unsigned char *)rsa) +#define d2i_RSAPublicKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPublicKey, (bp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPublicKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPublicKey,bp, \ + (unsigned char *)rsa) + +#define d2i_DSAPrivateKey_fp(fp,dsa) (DSA *)ASN1_d2i_fp((char *(*)())\ + DSA_new,(char *(*)())d2i_DSAPrivateKey, (fp), \ + (unsigned char **)(dsa)) +#define i2d_DSAPrivateKey_fp(fp,dsa) ASN1_i2d_fp(i2d_DSAPrivateKey,fp, \ + (unsigned char *)dsa) +#define d2i_DSAPrivateKey_bio(bp,dsa) (DSA *)ASN1_d2i_bio((char *(*)())\ + DSA_new,(char *(*)())d2i_DSAPrivateKey, (bp), \ + (unsigned char **)(dsa)) +#define i2d_DSAPrivateKey_bio(bp,dsa) ASN1_i2d_bio(i2d_DSAPrivateKey,bp, \ + (unsigned char *)dsa) + +#define d2i_ECPrivateKey_fp(fp,ecdsa) (EC_KEY *)ASN1_d2i_fp((char *(*)())\ + EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (fp), \ + (unsigned char **)(ecdsa)) +#define i2d_ECPrivateKey_fp(fp,ecdsa) ASN1_i2d_fp(i2d_ECPrivateKey,fp, \ + (unsigned char *)ecdsa) +#define d2i_ECPrivateKey_bio(bp,ecdsa) (EC_KEY *)ASN1_d2i_bio((char *(*)())\ + EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (bp), \ + (unsigned char **)(ecdsa)) +#define i2d_ECPrivateKey_bio(bp,ecdsa) ASN1_i2d_bio(i2d_ECPrivateKey,bp, \ + (unsigned char *)ecdsa) + +#define X509_ALGOR_dup(xn) (X509_ALGOR *)ASN1_dup((int (*)())i2d_X509_ALGOR,\ + (char *(*)())d2i_X509_ALGOR,(char *)xn) + +#define X509_NAME_dup(xn) (X509_NAME *)ASN1_dup((int (*)())i2d_X509_NAME, \ + (char *(*)())d2i_X509_NAME,(char *)xn) +#define X509_NAME_ENTRY_dup(ne) (X509_NAME_ENTRY *)ASN1_dup( \ + (int (*)())i2d_X509_NAME_ENTRY, \ + (char *(*)())d2i_X509_NAME_ENTRY,\ + (char *)ne) + +#define X509_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len) +#define X509_NAME_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len) +#ifndef PKCS7_ISSUER_AND_SERIAL_digest +#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\ + (char *)data,md,len) +#endif +#endif + +#define X509_EXT_PACK_UNKNOWN 1 +#define X509_EXT_PACK_STRING 2 + +#define X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version) +/* #define X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */ +#define X509_get_notBefore(x) ((x)->cert_info->validity->notBefore) +#define X509_get_notAfter(x) ((x)->cert_info->validity->notAfter) +#define X509_extract_key(x) X509_get_pubkey(x) /*****/ +#define X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version) +#define X509_REQ_get_subject_name(x) ((x)->req_info->subject) +#define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a) +#define X509_name_cmp(a,b) X509_NAME_cmp((a),(b)) +#define X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm)) + +#define X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version) +#define X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate) +#define X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate) +#define X509_CRL_get_issuer(x) ((x)->crl->issuer) +#define X509_CRL_get_REVOKED(x) ((x)->crl->revoked) + +/* This one is only used so that a binary form can output, as in + * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) */ +#define X509_get_X509_PUBKEY(x) ((x)->cert_info->key) + + +const char *X509_verify_cert_error_string(long n); + +#ifndef SSLEAY_MACROS +#ifndef OPENSSL_NO_EVP +int X509_verify(X509 *a, EVP_PKEY *r); + +int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r); +int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r); +int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r); + +NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len); +char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x); +EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x); +int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey); + +int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki); + +int X509_signature_print(BIO *bp,X509_ALGOR *alg, ASN1_STRING *sig); + +int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); +int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); +int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); +int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md); + +int X509_pubkey_digest(const X509 *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_digest(const X509 *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_REQ_digest(const X509_REQ *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +#endif + +#ifndef OPENSSL_NO_FP_API +X509 *d2i_X509_fp(FILE *fp, X509 **x509); +int i2d_X509_fp(FILE *fp,X509 *x509); +X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl); +int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl); +X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req); +int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req); +#ifndef OPENSSL_NO_RSA +RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa); +int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa); +RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa); +int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa); +RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa); +int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa); +#endif +#ifndef OPENSSL_NO_DSA +DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa); +int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa); +DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa); +int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa); +#endif +#ifndef OPENSSL_NO_EC +EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey); +int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey); +EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey); +int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey); +#endif +X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8); +int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8); +PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, + PKCS8_PRIV_KEY_INFO **p8inf); +int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf); +int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key); +int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a); +int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a); +#endif + +#ifndef OPENSSL_NO_BIO +X509 *d2i_X509_bio(BIO *bp,X509 **x509); +int i2d_X509_bio(BIO *bp,X509 *x509); +X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl); +int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl); +X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req); +int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req); +#ifndef OPENSSL_NO_RSA +RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa); +int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa); +RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa); +int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa); +RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa); +int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa); +#endif +#ifndef OPENSSL_NO_DSA +DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa); +int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa); +DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa); +int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa); +#endif +#ifndef OPENSSL_NO_EC +EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey); +int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey); +EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey); +int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey); +#endif +X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8); +int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8); +PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, + PKCS8_PRIV_KEY_INFO **p8inf); +int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf); +int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key); +int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a); +int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a); +#endif + +X509 *X509_dup(X509 *x509); +X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa); +X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex); +X509_CRL *X509_CRL_dup(X509_CRL *crl); +X509_REQ *X509_REQ_dup(X509_REQ *req); +X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn); +X509_NAME *X509_NAME_dup(X509_NAME *xn); +X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne); + +#endif /* !SSLEAY_MACROS */ + +int X509_cmp_time(ASN1_TIME *s, time_t *t); +int X509_cmp_current_time(ASN1_TIME *s); +ASN1_TIME * X509_time_adj(ASN1_TIME *s, long adj, time_t *t); +ASN1_TIME * X509_gmtime_adj(ASN1_TIME *s, long adj); + +const char * X509_get_default_cert_area(void ); +const char * X509_get_default_cert_dir(void ); +const char * X509_get_default_cert_file(void ); +const char * X509_get_default_cert_dir_env(void ); +const char * X509_get_default_cert_file_env(void ); +const char * X509_get_default_private_dir(void ); + +X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); +X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey); + +DECLARE_ASN1_FUNCTIONS(X509_ALGOR) +DECLARE_ASN1_FUNCTIONS(X509_VAL) + +DECLARE_ASN1_FUNCTIONS(X509_PUBKEY) + +int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey); +EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key); +int X509_get_pubkey_parameters(EVP_PKEY *pkey, + STACK_OF(X509) *chain); +int i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp); +EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,const unsigned char **pp, + long length); +#ifndef OPENSSL_NO_RSA +int i2d_RSA_PUBKEY(RSA *a,unsigned char **pp); +RSA * d2i_RSA_PUBKEY(RSA **a,const unsigned char **pp, + long length); +#endif +#ifndef OPENSSL_NO_DSA +int i2d_DSA_PUBKEY(DSA *a,unsigned char **pp); +DSA * d2i_DSA_PUBKEY(DSA **a,const unsigned char **pp, + long length); +#endif +#ifndef OPENSSL_NO_EC +int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp); +EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, + long length); +#endif + +DECLARE_ASN1_FUNCTIONS(X509_SIG) +DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO) +DECLARE_ASN1_FUNCTIONS(X509_REQ) + +DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE) +X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value); + +DECLARE_ASN1_FUNCTIONS(X509_EXTENSION) + +DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY) + +DECLARE_ASN1_FUNCTIONS(X509_NAME) + +int X509_NAME_set(X509_NAME **xn, X509_NAME *name); + +DECLARE_ASN1_FUNCTIONS(X509_CINF) + +DECLARE_ASN1_FUNCTIONS(X509) +DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX) + +DECLARE_ASN1_FUNCTIONS(X509_CERT_PAIR) + +int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int X509_set_ex_data(X509 *r, int idx, void *arg); +void *X509_get_ex_data(X509 *r, int idx); +int i2d_X509_AUX(X509 *a,unsigned char **pp); +X509 * d2i_X509_AUX(X509 **a,const unsigned char **pp,long length); + +int X509_alias_set1(X509 *x, unsigned char *name, int len); +int X509_keyid_set1(X509 *x, unsigned char *id, int len); +unsigned char * X509_alias_get0(X509 *x, int *len); +unsigned char * X509_keyid_get0(X509 *x, int *len); +int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int); +int X509_TRUST_set(int *t, int trust); +int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj); +int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj); +void X509_trust_clear(X509 *x); +void X509_reject_clear(X509 *x); + +DECLARE_ASN1_FUNCTIONS(X509_REVOKED) +DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO) +DECLARE_ASN1_FUNCTIONS(X509_CRL) + +int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev); + +X509_PKEY * X509_PKEY_new(void ); +void X509_PKEY_free(X509_PKEY *a); +int i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp); +X509_PKEY * d2i_X509_PKEY(X509_PKEY **a,const unsigned char **pp,long length); + +DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI) +DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC) +DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE) + +#ifndef OPENSSL_NO_EVP +X509_INFO * X509_INFO_new(void); +void X509_INFO_free(X509_INFO *a); +char * X509_NAME_oneline(X509_NAME *a,char *buf,int size); + +int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1, + ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey); + +int ASN1_digest(i2d_of_void *i2d,const EVP_MD *type,char *data, + unsigned char *md,unsigned int *len); + +int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, + X509_ALGOR *algor2, ASN1_BIT_STRING *signature, + char *data,EVP_PKEY *pkey, const EVP_MD *type); + +int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data, + unsigned char *md,unsigned int *len); + +int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1, + ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey); + +int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, + ASN1_BIT_STRING *signature, + void *data, EVP_PKEY *pkey, const EVP_MD *type); +#endif + +int X509_set_version(X509 *x,long version); +int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial); +ASN1_INTEGER * X509_get_serialNumber(X509 *x); +int X509_set_issuer_name(X509 *x, X509_NAME *name); +X509_NAME * X509_get_issuer_name(X509 *a); +int X509_set_subject_name(X509 *x, X509_NAME *name); +X509_NAME * X509_get_subject_name(X509 *a); +int X509_set_notBefore(X509 *x, ASN1_TIME *tm); +int X509_set_notAfter(X509 *x, ASN1_TIME *tm); +int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); +EVP_PKEY * X509_get_pubkey(X509 *x); +ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x); +int X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */); + +int X509_REQ_set_version(X509_REQ *x,long version); +int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name); +int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); +EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req); +int X509_REQ_extension_nid(int nid); +int * X509_REQ_get_extension_nids(void); +void X509_REQ_set_extension_nids(int *nids); +STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req); +int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, + int nid); +int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts); +int X509_REQ_get_attr_count(const X509_REQ *req); +int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, + int lastpos); +int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc); +X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc); +int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr); +int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); +int X509_REQ_add1_attr_by_NID(X509_REQ *req, + int nid, int type, + const unsigned char *bytes, int len); +int X509_REQ_add1_attr_by_txt(X509_REQ *req, + const char *attrname, int type, + const unsigned char *bytes, int len); + +int X509_CRL_set_version(X509_CRL *x, long version); +int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name); +int X509_CRL_set_lastUpdate(X509_CRL *x, ASN1_TIME *tm); +int X509_CRL_set_nextUpdate(X509_CRL *x, ASN1_TIME *tm); +int X509_CRL_sort(X509_CRL *crl); + +int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial); +int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm); + +int X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey); + +int X509_check_private_key(X509 *x509,EVP_PKEY *pkey); + +int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b); +unsigned long X509_issuer_and_serial_hash(X509 *a); + +int X509_issuer_name_cmp(const X509 *a, const X509 *b); +unsigned long X509_issuer_name_hash(X509 *a); + +int X509_subject_name_cmp(const X509 *a, const X509 *b); +unsigned long X509_subject_name_hash(X509 *x); + +int X509_cmp(const X509 *a, const X509 *b); +int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b); +unsigned long X509_NAME_hash(X509_NAME *x); + +int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); +#ifndef OPENSSL_NO_FP_API +int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag); +int X509_print_fp(FILE *bp,X509 *x); +int X509_CRL_print_fp(FILE *bp,X509_CRL *x); +int X509_REQ_print_fp(FILE *bp,X509_REQ *req); +int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags); +#endif + +#ifndef OPENSSL_NO_BIO +int X509_NAME_print(BIO *bp, X509_NAME *name, int obase); +int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags); +int X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag); +int X509_print(BIO *bp,X509 *x); +int X509_ocspid_print(BIO *bp,X509 *x); +int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent); +int X509_CRL_print(BIO *bp,X509_CRL *x); +int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag); +int X509_REQ_print(BIO *bp,X509_REQ *req); +#endif + +int X509_NAME_entry_count(X509_NAME *name); +int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, + char *buf,int len); +int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, + char *buf,int len); + +/* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use + * lastpos, search after that position on. */ +int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos); +int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj, + int lastpos); +X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc); +X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); +int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, + int loc, int set); +int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, + unsigned char *bytes, int len, int loc, int set); +int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, + unsigned char *bytes, int len, int loc, int set); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, + const char *field, int type, const unsigned char *bytes, int len); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, + int type,unsigned char *bytes, int len); +int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, + const unsigned char *bytes, int len, int loc, int set); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, + ASN1_OBJECT *obj, int type,const unsigned char *bytes, + int len); +int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, + ASN1_OBJECT *obj); +int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, + const unsigned char *bytes, int len); +ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne); +ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne); + +int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x); +int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, + int nid, int lastpos); +int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x, + ASN1_OBJECT *obj,int lastpos); +int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x, + int crit, int lastpos); +X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc); +X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc); +STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, + X509_EXTENSION *ex, int loc); + +int X509_get_ext_count(X509 *x); +int X509_get_ext_by_NID(X509 *x, int nid, int lastpos); +int X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos); +int X509_get_ext_by_critical(X509 *x, int crit, int lastpos); +X509_EXTENSION *X509_get_ext(X509 *x, int loc); +X509_EXTENSION *X509_delete_ext(X509 *x, int loc); +int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); +void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx); +int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, + unsigned long flags); + +int X509_CRL_get_ext_count(X509_CRL *x); +int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos); +int X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos); +int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos); +X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc); +X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); +int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); +void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx); +int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, + unsigned long flags); + +int X509_REVOKED_get_ext_count(X509_REVOKED *x); +int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos); +int X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos); +int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos); +X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc); +X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); +int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); +void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx); +int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, + unsigned long flags); + +X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, + int nid, int crit, ASN1_OCTET_STRING *data); +X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, + ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data); +int X509_EXTENSION_set_object(X509_EXTENSION *ex,ASN1_OBJECT *obj); +int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit); +int X509_EXTENSION_set_data(X509_EXTENSION *ex, + ASN1_OCTET_STRING *data); +ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex); +ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne); +int X509_EXTENSION_get_critical(X509_EXTENSION *ex); + +int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x); +int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, + int lastpos); +int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc); +X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, + X509_ATTRIBUTE *attr); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x, + int nid, int type, + const unsigned char *bytes, int len); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x, + const char *attrname, int type, + const unsigned char *bytes, int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, + int atrtype, const void *data, int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, + const ASN1_OBJECT *obj, int atrtype, const void *data, int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, + const char *atrname, int type, const unsigned char *bytes, int len); +int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj); +int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len); +void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, + int atrtype, void *data); +int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr); +ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr); +ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx); + +int EVP_PKEY_get_attr_count(const EVP_PKEY *key); +int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, + int lastpos); +int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc); +X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc); +int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr); +int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); +int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key, + int nid, int type, + const unsigned char *bytes, int len); +int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key, + const char *attrname, int type, + const unsigned char *bytes, int len); + +int X509_verify_cert(X509_STORE_CTX *ctx); + +/* lookup a cert from a X509 STACK */ +X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name, + ASN1_INTEGER *serial); +X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name); + +DECLARE_ASN1_FUNCTIONS(PBEPARAM) +DECLARE_ASN1_FUNCTIONS(PBE2PARAM) +DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM) + +X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, int saltlen); +X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, + unsigned char *salt, int saltlen); + +/* PKCS#8 utilities */ + +DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) + +EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8); +PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey); +PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken); +PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken); + +int X509_check_trust(X509 *x, int id, int flags); +int X509_TRUST_get_count(void); +X509_TRUST * X509_TRUST_get0(int idx); +int X509_TRUST_get_by_id(int id); +int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), + char *name, int arg1, void *arg2); +void X509_TRUST_cleanup(void); +int X509_TRUST_get_flags(X509_TRUST *xp); +char *X509_TRUST_get0_name(X509_TRUST *xp); +int X509_TRUST_get_trust(X509_TRUST *xp); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_X509_strings(void); + +/* Error codes for the X509 functions. */ + +/* Function codes. */ +#define X509_F_ADD_CERT_DIR 100 +#define X509_F_BY_FILE_CTRL 101 +#define X509_F_CHECK_POLICY 145 +#define X509_F_DIR_CTRL 102 +#define X509_F_GET_CERT_BY_SUBJECT 103 +#define X509_F_NETSCAPE_SPKI_B64_DECODE 129 +#define X509_F_NETSCAPE_SPKI_B64_ENCODE 130 +#define X509_F_X509AT_ADD1_ATTR 135 +#define X509_F_X509V3_ADD_EXT 104 +#define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 136 +#define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 137 +#define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 140 +#define X509_F_X509_ATTRIBUTE_GET0_DATA 139 +#define X509_F_X509_ATTRIBUTE_SET1_DATA 138 +#define X509_F_X509_CHECK_PRIVATE_KEY 128 +#define X509_F_X509_CRL_PRINT_FP 147 +#define X509_F_X509_EXTENSION_CREATE_BY_NID 108 +#define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109 +#define X509_F_X509_GET_PUBKEY_PARAMETERS 110 +#define X509_F_X509_LOAD_CERT_CRL_FILE 132 +#define X509_F_X509_LOAD_CERT_FILE 111 +#define X509_F_X509_LOAD_CRL_FILE 112 +#define X509_F_X509_NAME_ADD_ENTRY 113 +#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114 +#define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 131 +#define X509_F_X509_NAME_ENTRY_SET_OBJECT 115 +#define X509_F_X509_NAME_ONELINE 116 +#define X509_F_X509_NAME_PRINT 117 +#define X509_F_X509_PRINT_EX_FP 118 +#define X509_F_X509_PUBKEY_GET 119 +#define X509_F_X509_PUBKEY_SET 120 +#define X509_F_X509_REQ_CHECK_PRIVATE_KEY 144 +#define X509_F_X509_REQ_PRINT_EX 121 +#define X509_F_X509_REQ_PRINT_FP 122 +#define X509_F_X509_REQ_TO_X509 123 +#define X509_F_X509_STORE_ADD_CERT 124 +#define X509_F_X509_STORE_ADD_CRL 125 +#define X509_F_X509_STORE_CTX_GET1_ISSUER 146 +#define X509_F_X509_STORE_CTX_INIT 143 +#define X509_F_X509_STORE_CTX_NEW 142 +#define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134 +#define X509_F_X509_TO_X509_REQ 126 +#define X509_F_X509_TRUST_ADD 133 +#define X509_F_X509_TRUST_SET 141 +#define X509_F_X509_VERIFY_CERT 127 + +/* Reason codes. */ +#define X509_R_BAD_X509_FILETYPE 100 +#define X509_R_BASE64_DECODE_ERROR 118 +#define X509_R_CANT_CHECK_DH_KEY 114 +#define X509_R_CERT_ALREADY_IN_HASH_TABLE 101 +#define X509_R_ERR_ASN1_LIB 102 +#define X509_R_INVALID_DIRECTORY 113 +#define X509_R_INVALID_FIELD_NAME 119 +#define X509_R_INVALID_TRUST 123 +#define X509_R_KEY_TYPE_MISMATCH 115 +#define X509_R_KEY_VALUES_MISMATCH 116 +#define X509_R_LOADING_CERT_DIR 103 +#define X509_R_LOADING_DEFAULTS 104 +#define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105 +#define X509_R_SHOULD_RETRY 106 +#define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107 +#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108 +#define X509_R_UNKNOWN_KEY_TYPE 117 +#define X509_R_UNKNOWN_NID 109 +#define X509_R_UNKNOWN_PURPOSE_ID 121 +#define X509_R_UNKNOWN_TRUST_ID 120 +#define X509_R_UNSUPPORTED_ALGORITHM 111 +#define X509_R_WRONG_LOOKUP_TYPE 112 +#define X509_R_WRONG_TYPE 122 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/include/openssl/x509_vfy.h b/src/dep/include/openssl/x509_vfy.h index df2d729..f69a703 100644 --- a/src/dep/include/openssl/x509_vfy.h +++ b/src/dep/include/openssl/x509_vfy.h @@ -1,530 +1,530 @@ -/* crypto/x509/x509_vfy.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_X509_H -#include -/* openssl/x509.h ends up #include-ing this file at about the only - * appropriate moment. */ -#endif - -#ifndef HEADER_X509_VFY_H -#define HEADER_X509_VFY_H - -#include -#ifndef OPENSSL_NO_LHASH -#include -#endif -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Outer object */ -typedef struct x509_hash_dir_st - { - int num_dirs; - char **dirs; - int *dirs_type; - int num_dirs_alloced; - } X509_HASH_DIR_CTX; - -typedef struct x509_file_st - { - int num_paths; /* number of paths to files or directories */ - int num_alloced; - char **paths; /* the list of paths or directories */ - int *path_type; - } X509_CERT_FILE_CTX; - -/*******************************/ -/* -SSL_CTX -> X509_STORE - -> X509_LOOKUP - ->X509_LOOKUP_METHOD - -> X509_LOOKUP - ->X509_LOOKUP_METHOD - -SSL -> X509_STORE_CTX - ->X509_STORE - -The X509_STORE holds the tables etc for verification stuff. -A X509_STORE_CTX is used while validating a single certificate. -The X509_STORE has X509_LOOKUPs for looking up certs. -The X509_STORE then calls a function to actually verify the -certificate chain. -*/ - -#define X509_LU_RETRY -1 -#define X509_LU_FAIL 0 -#define X509_LU_X509 1 -#define X509_LU_CRL 2 -#define X509_LU_PKEY 3 - -typedef struct x509_object_st - { - /* one of the above types */ - int type; - union { - char *ptr; - X509 *x509; - X509_CRL *crl; - EVP_PKEY *pkey; - } data; - } X509_OBJECT; - -typedef struct x509_lookup_st X509_LOOKUP; - -DECLARE_STACK_OF(X509_LOOKUP) -DECLARE_STACK_OF(X509_OBJECT) - -/* This is a static that defines the function interface */ -typedef struct x509_lookup_method_st - { - const char *name; - int (*new_item)(X509_LOOKUP *ctx); - void (*free)(X509_LOOKUP *ctx); - int (*init)(X509_LOOKUP *ctx); - int (*shutdown)(X509_LOOKUP *ctx); - int (*ctrl)(X509_LOOKUP *ctx,int cmd,const char *argc,long argl, - char **ret); - int (*get_by_subject)(X509_LOOKUP *ctx,int type,X509_NAME *name, - X509_OBJECT *ret); - int (*get_by_issuer_serial)(X509_LOOKUP *ctx,int type,X509_NAME *name, - ASN1_INTEGER *serial,X509_OBJECT *ret); - int (*get_by_fingerprint)(X509_LOOKUP *ctx,int type, - unsigned char *bytes,int len, - X509_OBJECT *ret); - int (*get_by_alias)(X509_LOOKUP *ctx,int type,char *str,int len, - X509_OBJECT *ret); - } X509_LOOKUP_METHOD; - -/* This structure hold all parameters associated with a verify operation - * by including an X509_VERIFY_PARAM structure in related structures the - * parameters used can be customized - */ - -typedef struct X509_VERIFY_PARAM_st - { - char *name; - time_t check_time; /* Time to use */ - unsigned long inh_flags; /* Inheritance flags */ - unsigned long flags; /* Various verify flags */ - int purpose; /* purpose to check untrusted certificates */ - int trust; /* trust setting to check */ - int depth; /* Verify depth */ - STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */ - } X509_VERIFY_PARAM; - -DECLARE_STACK_OF(X509_VERIFY_PARAM) - -/* This is used to hold everything. It is used for all certificate - * validation. Once we have a certificate chain, the 'verify' - * function is then called to actually check the cert chain. */ -struct x509_store_st - { - /* The following is a cache of trusted certs */ - int cache; /* if true, stash any hits */ - STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */ - - /* These are external lookup methods */ - STACK_OF(X509_LOOKUP) *get_cert_methods; - - X509_VERIFY_PARAM *param; - - /* Callbacks for various operations */ - int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ - int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ - int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ - int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ - int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */ - int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ - int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ - int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ - int (*cleanup)(X509_STORE_CTX *ctx); - - CRYPTO_EX_DATA ex_data; - int references; - } /* X509_STORE */; - -int X509_STORE_set_depth(X509_STORE *store, int depth); - -#define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func)) -#define X509_STORE_set_verify_func(ctx,func) ((ctx)->verify=(func)) - -/* This is the functions plus an instance of the local variables. */ -struct x509_lookup_st - { - int init; /* have we been started */ - int skip; /* don't use us. */ - X509_LOOKUP_METHOD *method; /* the functions */ - char *method_data; /* method data */ - - X509_STORE *store_ctx; /* who owns us */ - } /* X509_LOOKUP */; - -/* This is a used when verifying cert chains. Since the - * gathering of the cert chain can take some time (and have to be - * 'retried', this needs to be kept and passed around. */ -struct x509_store_ctx_st /* X509_STORE_CTX */ - { - X509_STORE *ctx; - int current_method; /* used when looking up certs */ - - /* The following are set by the caller */ - X509 *cert; /* The cert to check */ - STACK_OF(X509) *untrusted; /* chain of X509s - untrusted - passed in */ - STACK_OF(X509_CRL) *crls; /* set of CRLs passed in */ - - X509_VERIFY_PARAM *param; - void *other_ctx; /* Other info for use with get_issuer() */ - - /* Callbacks for various operations */ - int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ - int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ - int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ - int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ - int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */ - int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ - int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ - int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ - int (*check_policy)(X509_STORE_CTX *ctx); - int (*cleanup)(X509_STORE_CTX *ctx); - - /* The following is built up */ - int valid; /* if 0, rebuild chain */ - int last_untrusted; /* index of last untrusted cert */ - STACK_OF(X509) *chain; /* chain of X509s - built up and trusted */ - X509_POLICY_TREE *tree; /* Valid policy tree */ - - int explicit_policy; /* Require explicit policy value */ - - /* When something goes wrong, this is why */ - int error_depth; - int error; - X509 *current_cert; - X509 *current_issuer; /* cert currently being tested as valid issuer */ - X509_CRL *current_crl; /* current CRL */ - - CRYPTO_EX_DATA ex_data; - } /* X509_STORE_CTX */; - -void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); - -#define X509_STORE_CTX_set_app_data(ctx,data) \ - X509_STORE_CTX_set_ex_data(ctx,0,data) -#define X509_STORE_CTX_get_app_data(ctx) \ - X509_STORE_CTX_get_ex_data(ctx,0) - -#define X509_L_FILE_LOAD 1 -#define X509_L_ADD_DIR 2 - -#define X509_LOOKUP_load_file(x,name,type) \ - X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL) - -#define X509_LOOKUP_add_dir(x,name,type) \ - X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL) - -#define X509_V_OK 0 -/* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */ - -#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2 -#define X509_V_ERR_UNABLE_TO_GET_CRL 3 -#define X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4 -#define X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5 -#define X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6 -#define X509_V_ERR_CERT_SIGNATURE_FAILURE 7 -#define X509_V_ERR_CRL_SIGNATURE_FAILURE 8 -#define X509_V_ERR_CERT_NOT_YET_VALID 9 -#define X509_V_ERR_CERT_HAS_EXPIRED 10 -#define X509_V_ERR_CRL_NOT_YET_VALID 11 -#define X509_V_ERR_CRL_HAS_EXPIRED 12 -#define X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13 -#define X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14 -#define X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15 -#define X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16 -#define X509_V_ERR_OUT_OF_MEM 17 -#define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18 -#define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19 -#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20 -#define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21 -#define X509_V_ERR_CERT_CHAIN_TOO_LONG 22 -#define X509_V_ERR_CERT_REVOKED 23 -#define X509_V_ERR_INVALID_CA 24 -#define X509_V_ERR_PATH_LENGTH_EXCEEDED 25 -#define X509_V_ERR_INVALID_PURPOSE 26 -#define X509_V_ERR_CERT_UNTRUSTED 27 -#define X509_V_ERR_CERT_REJECTED 28 -/* These are 'informational' when looking for issuer cert */ -#define X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29 -#define X509_V_ERR_AKID_SKID_MISMATCH 30 -#define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31 -#define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32 - -#define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33 -#define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34 -#define X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35 -#define X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36 -#define X509_V_ERR_INVALID_NON_CA 37 -#define X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38 -#define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39 -#define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40 - -#define X509_V_ERR_INVALID_EXTENSION 41 -#define X509_V_ERR_INVALID_POLICY_EXTENSION 42 -#define X509_V_ERR_NO_EXPLICIT_POLICY 43 - - -/* The application is not happy */ -#define X509_V_ERR_APPLICATION_VERIFICATION 50 - -/* Certificate verify flags */ - -/* Send issuer+subject checks to verify_cb */ -#define X509_V_FLAG_CB_ISSUER_CHECK 0x1 -/* Use check time instead of current time */ -#define X509_V_FLAG_USE_CHECK_TIME 0x2 -/* Lookup CRLs */ -#define X509_V_FLAG_CRL_CHECK 0x4 -/* Lookup CRLs for whole chain */ -#define X509_V_FLAG_CRL_CHECK_ALL 0x8 -/* Ignore unhandled critical extensions */ -#define X509_V_FLAG_IGNORE_CRITICAL 0x10 -/* Disable workarounds for broken certificates */ -#define X509_V_FLAG_X509_STRICT 0x20 -/* Enable proxy certificate validation */ -#define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40 -/* Enable policy checking */ -#define X509_V_FLAG_POLICY_CHECK 0x80 -/* Policy variable require-explicit-policy */ -#define X509_V_FLAG_EXPLICIT_POLICY 0x100 -/* Policy variable inhibit-any-policy */ -#define X509_V_FLAG_INHIBIT_ANY 0x200 -/* Policy variable inhibit-policy-mapping */ -#define X509_V_FLAG_INHIBIT_MAP 0x400 -/* Notify callback that policy is OK */ -#define X509_V_FLAG_NOTIFY_POLICY 0x800 - -#define X509_VP_FLAG_DEFAULT 0x1 -#define X509_VP_FLAG_OVERWRITE 0x2 -#define X509_VP_FLAG_RESET_FLAGS 0x4 -#define X509_VP_FLAG_LOCKED 0x8 -#define X509_VP_FLAG_ONCE 0x10 - -/* Internal use: mask of policy related options */ -#define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \ - | X509_V_FLAG_EXPLICIT_POLICY \ - | X509_V_FLAG_INHIBIT_ANY \ - | X509_V_FLAG_INHIBIT_MAP) - -int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, - X509_NAME *name); -X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,int type,X509_NAME *name); -X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x); -void X509_OBJECT_up_ref_count(X509_OBJECT *a); -void X509_OBJECT_free_contents(X509_OBJECT *a); -X509_STORE *X509_STORE_new(void ); -void X509_STORE_free(X509_STORE *v); - -int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); -int X509_STORE_set_purpose(X509_STORE *ctx, int purpose); -int X509_STORE_set_trust(X509_STORE *ctx, int trust); -int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm); - -X509_STORE_CTX *X509_STORE_CTX_new(void); - -int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); - -void X509_STORE_CTX_free(X509_STORE_CTX *ctx); -int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, - X509 *x509, STACK_OF(X509) *chain); -void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); -void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); - -X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m); - -X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void); -X509_LOOKUP_METHOD *X509_LOOKUP_file(void); - -int X509_STORE_add_cert(X509_STORE *ctx, X509 *x); -int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x); - -int X509_STORE_get_by_subject(X509_STORE_CTX *vs,int type,X509_NAME *name, - X509_OBJECT *ret); - -int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, - long argl, char **ret); - -#ifndef OPENSSL_NO_STDIO -int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); -int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); -int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); -#endif - - -X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); -void X509_LOOKUP_free(X509_LOOKUP *ctx); -int X509_LOOKUP_init(X509_LOOKUP *ctx); -int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name, - X509_OBJECT *ret); -int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name, - ASN1_INTEGER *serial, X509_OBJECT *ret); -int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type, - unsigned char *bytes, int len, X509_OBJECT *ret); -int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, - int len, X509_OBJECT *ret); -int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); - -#ifndef OPENSSL_NO_STDIO -int X509_STORE_load_locations (X509_STORE *ctx, - const char *file, const char *dir); -int X509_STORE_set_default_paths(X509_STORE *ctx); -#endif - -int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); -int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data); -void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx); -int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s); -int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); -X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); -STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx); -STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x); -void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk); -void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c,STACK_OF(X509_CRL) *sk); -int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); -int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); -int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, - int purpose, int trust); -void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags); -void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, - time_t t); -void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, - int (*verify_cb)(int, X509_STORE_CTX *)); - -X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx); -int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx); - -X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param); -int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name); - -/* X509_VERIFY_PARAM functions */ - -X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void); -void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param); -int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, - const X509_VERIFY_PARAM *from); -int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, - const X509_VERIFY_PARAM *from); -int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name); -int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags); -int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, - unsigned long flags); -unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param); -int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); -int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); -void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); -void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); -int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, - ASN1_OBJECT *policy); -int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, - STACK_OF(ASN1_OBJECT) *policies); -int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); - -int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param); -const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name); -void X509_VERIFY_PARAM_table_cleanup(void); - -int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, - STACK_OF(X509) *certs, - STACK_OF(ASN1_OBJECT) *policy_oids, - unsigned int flags); - -void X509_policy_tree_free(X509_POLICY_TREE *tree); - -int X509_policy_tree_level_count(const X509_POLICY_TREE *tree); -X509_POLICY_LEVEL * - X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i); - -STACK_OF(X509_POLICY_NODE) * - X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree); - -STACK_OF(X509_POLICY_NODE) * - X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree); - -int X509_policy_level_node_count(X509_POLICY_LEVEL *level); - -X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i); - -const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node); - -STACK_OF(POLICYQUALINFO) * - X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node); -const X509_POLICY_NODE * - X509_policy_node_get0_parent(const X509_POLICY_NODE *node); - -#ifdef __cplusplus -} -#endif -#endif - +/* crypto/x509/x509_vfy.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_X509_H +#include +/* openssl/x509.h ends up #include-ing this file at about the only + * appropriate moment. */ +#endif + +#ifndef HEADER_X509_VFY_H +#define HEADER_X509_VFY_H + +#include +#ifndef OPENSSL_NO_LHASH +#include +#endif +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Outer object */ +typedef struct x509_hash_dir_st + { + int num_dirs; + char **dirs; + int *dirs_type; + int num_dirs_alloced; + } X509_HASH_DIR_CTX; + +typedef struct x509_file_st + { + int num_paths; /* number of paths to files or directories */ + int num_alloced; + char **paths; /* the list of paths or directories */ + int *path_type; + } X509_CERT_FILE_CTX; + +/*******************************/ +/* +SSL_CTX -> X509_STORE + -> X509_LOOKUP + ->X509_LOOKUP_METHOD + -> X509_LOOKUP + ->X509_LOOKUP_METHOD + +SSL -> X509_STORE_CTX + ->X509_STORE + +The X509_STORE holds the tables etc for verification stuff. +A X509_STORE_CTX is used while validating a single certificate. +The X509_STORE has X509_LOOKUPs for looking up certs. +The X509_STORE then calls a function to actually verify the +certificate chain. +*/ + +#define X509_LU_RETRY -1 +#define X509_LU_FAIL 0 +#define X509_LU_X509 1 +#define X509_LU_CRL 2 +#define X509_LU_PKEY 3 + +typedef struct x509_object_st + { + /* one of the above types */ + int type; + union { + char *ptr; + X509 *x509; + X509_CRL *crl; + EVP_PKEY *pkey; + } data; + } X509_OBJECT; + +typedef struct x509_lookup_st X509_LOOKUP; + +DECLARE_STACK_OF(X509_LOOKUP) +DECLARE_STACK_OF(X509_OBJECT) + +/* This is a static that defines the function interface */ +typedef struct x509_lookup_method_st + { + const char *name; + int (*new_item)(X509_LOOKUP *ctx); + void (*free)(X509_LOOKUP *ctx); + int (*init)(X509_LOOKUP *ctx); + int (*shutdown)(X509_LOOKUP *ctx); + int (*ctrl)(X509_LOOKUP *ctx,int cmd,const char *argc,long argl, + char **ret); + int (*get_by_subject)(X509_LOOKUP *ctx,int type,X509_NAME *name, + X509_OBJECT *ret); + int (*get_by_issuer_serial)(X509_LOOKUP *ctx,int type,X509_NAME *name, + ASN1_INTEGER *serial,X509_OBJECT *ret); + int (*get_by_fingerprint)(X509_LOOKUP *ctx,int type, + unsigned char *bytes,int len, + X509_OBJECT *ret); + int (*get_by_alias)(X509_LOOKUP *ctx,int type,char *str,int len, + X509_OBJECT *ret); + } X509_LOOKUP_METHOD; + +/* This structure hold all parameters associated with a verify operation + * by including an X509_VERIFY_PARAM structure in related structures the + * parameters used can be customized + */ + +typedef struct X509_VERIFY_PARAM_st + { + char *name; + time_t check_time; /* Time to use */ + unsigned long inh_flags; /* Inheritance flags */ + unsigned long flags; /* Various verify flags */ + int purpose; /* purpose to check untrusted certificates */ + int trust; /* trust setting to check */ + int depth; /* Verify depth */ + STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */ + } X509_VERIFY_PARAM; + +DECLARE_STACK_OF(X509_VERIFY_PARAM) + +/* This is used to hold everything. It is used for all certificate + * validation. Once we have a certificate chain, the 'verify' + * function is then called to actually check the cert chain. */ +struct x509_store_st + { + /* The following is a cache of trusted certs */ + int cache; /* if true, stash any hits */ + STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */ + + /* These are external lookup methods */ + STACK_OF(X509_LOOKUP) *get_cert_methods; + + X509_VERIFY_PARAM *param; + + /* Callbacks for various operations */ + int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ + int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ + int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ + int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ + int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */ + int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ + int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ + int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ + int (*cleanup)(X509_STORE_CTX *ctx); + + CRYPTO_EX_DATA ex_data; + int references; + } /* X509_STORE */; + +int X509_STORE_set_depth(X509_STORE *store, int depth); + +#define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func)) +#define X509_STORE_set_verify_func(ctx,func) ((ctx)->verify=(func)) + +/* This is the functions plus an instance of the local variables. */ +struct x509_lookup_st + { + int init; /* have we been started */ + int skip; /* don't use us. */ + X509_LOOKUP_METHOD *method; /* the functions */ + char *method_data; /* method data */ + + X509_STORE *store_ctx; /* who owns us */ + } /* X509_LOOKUP */; + +/* This is a used when verifying cert chains. Since the + * gathering of the cert chain can take some time (and have to be + * 'retried', this needs to be kept and passed around. */ +struct x509_store_ctx_st /* X509_STORE_CTX */ + { + X509_STORE *ctx; + int current_method; /* used when looking up certs */ + + /* The following are set by the caller */ + X509 *cert; /* The cert to check */ + STACK_OF(X509) *untrusted; /* chain of X509s - untrusted - passed in */ + STACK_OF(X509_CRL) *crls; /* set of CRLs passed in */ + + X509_VERIFY_PARAM *param; + void *other_ctx; /* Other info for use with get_issuer() */ + + /* Callbacks for various operations */ + int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ + int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ + int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ + int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ + int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */ + int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ + int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ + int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ + int (*check_policy)(X509_STORE_CTX *ctx); + int (*cleanup)(X509_STORE_CTX *ctx); + + /* The following is built up */ + int valid; /* if 0, rebuild chain */ + int last_untrusted; /* index of last untrusted cert */ + STACK_OF(X509) *chain; /* chain of X509s - built up and trusted */ + X509_POLICY_TREE *tree; /* Valid policy tree */ + + int explicit_policy; /* Require explicit policy value */ + + /* When something goes wrong, this is why */ + int error_depth; + int error; + X509 *current_cert; + X509 *current_issuer; /* cert currently being tested as valid issuer */ + X509_CRL *current_crl; /* current CRL */ + + CRYPTO_EX_DATA ex_data; + } /* X509_STORE_CTX */; + +void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); + +#define X509_STORE_CTX_set_app_data(ctx,data) \ + X509_STORE_CTX_set_ex_data(ctx,0,data) +#define X509_STORE_CTX_get_app_data(ctx) \ + X509_STORE_CTX_get_ex_data(ctx,0) + +#define X509_L_FILE_LOAD 1 +#define X509_L_ADD_DIR 2 + +#define X509_LOOKUP_load_file(x,name,type) \ + X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL) + +#define X509_LOOKUP_add_dir(x,name,type) \ + X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL) + +#define X509_V_OK 0 +/* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */ + +#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2 +#define X509_V_ERR_UNABLE_TO_GET_CRL 3 +#define X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4 +#define X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5 +#define X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6 +#define X509_V_ERR_CERT_SIGNATURE_FAILURE 7 +#define X509_V_ERR_CRL_SIGNATURE_FAILURE 8 +#define X509_V_ERR_CERT_NOT_YET_VALID 9 +#define X509_V_ERR_CERT_HAS_EXPIRED 10 +#define X509_V_ERR_CRL_NOT_YET_VALID 11 +#define X509_V_ERR_CRL_HAS_EXPIRED 12 +#define X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13 +#define X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14 +#define X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15 +#define X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16 +#define X509_V_ERR_OUT_OF_MEM 17 +#define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18 +#define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19 +#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20 +#define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21 +#define X509_V_ERR_CERT_CHAIN_TOO_LONG 22 +#define X509_V_ERR_CERT_REVOKED 23 +#define X509_V_ERR_INVALID_CA 24 +#define X509_V_ERR_PATH_LENGTH_EXCEEDED 25 +#define X509_V_ERR_INVALID_PURPOSE 26 +#define X509_V_ERR_CERT_UNTRUSTED 27 +#define X509_V_ERR_CERT_REJECTED 28 +/* These are 'informational' when looking for issuer cert */ +#define X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29 +#define X509_V_ERR_AKID_SKID_MISMATCH 30 +#define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31 +#define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32 + +#define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33 +#define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34 +#define X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35 +#define X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36 +#define X509_V_ERR_INVALID_NON_CA 37 +#define X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38 +#define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39 +#define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40 + +#define X509_V_ERR_INVALID_EXTENSION 41 +#define X509_V_ERR_INVALID_POLICY_EXTENSION 42 +#define X509_V_ERR_NO_EXPLICIT_POLICY 43 + + +/* The application is not happy */ +#define X509_V_ERR_APPLICATION_VERIFICATION 50 + +/* Certificate verify flags */ + +/* Send issuer+subject checks to verify_cb */ +#define X509_V_FLAG_CB_ISSUER_CHECK 0x1 +/* Use check time instead of current time */ +#define X509_V_FLAG_USE_CHECK_TIME 0x2 +/* Lookup CRLs */ +#define X509_V_FLAG_CRL_CHECK 0x4 +/* Lookup CRLs for whole chain */ +#define X509_V_FLAG_CRL_CHECK_ALL 0x8 +/* Ignore unhandled critical extensions */ +#define X509_V_FLAG_IGNORE_CRITICAL 0x10 +/* Disable workarounds for broken certificates */ +#define X509_V_FLAG_X509_STRICT 0x20 +/* Enable proxy certificate validation */ +#define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40 +/* Enable policy checking */ +#define X509_V_FLAG_POLICY_CHECK 0x80 +/* Policy variable require-explicit-policy */ +#define X509_V_FLAG_EXPLICIT_POLICY 0x100 +/* Policy variable inhibit-any-policy */ +#define X509_V_FLAG_INHIBIT_ANY 0x200 +/* Policy variable inhibit-policy-mapping */ +#define X509_V_FLAG_INHIBIT_MAP 0x400 +/* Notify callback that policy is OK */ +#define X509_V_FLAG_NOTIFY_POLICY 0x800 + +#define X509_VP_FLAG_DEFAULT 0x1 +#define X509_VP_FLAG_OVERWRITE 0x2 +#define X509_VP_FLAG_RESET_FLAGS 0x4 +#define X509_VP_FLAG_LOCKED 0x8 +#define X509_VP_FLAG_ONCE 0x10 + +/* Internal use: mask of policy related options */ +#define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \ + | X509_V_FLAG_EXPLICIT_POLICY \ + | X509_V_FLAG_INHIBIT_ANY \ + | X509_V_FLAG_INHIBIT_MAP) + +int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, + X509_NAME *name); +X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,int type,X509_NAME *name); +X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x); +void X509_OBJECT_up_ref_count(X509_OBJECT *a); +void X509_OBJECT_free_contents(X509_OBJECT *a); +X509_STORE *X509_STORE_new(void ); +void X509_STORE_free(X509_STORE *v); + +int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); +int X509_STORE_set_purpose(X509_STORE *ctx, int purpose); +int X509_STORE_set_trust(X509_STORE *ctx, int trust); +int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm); + +X509_STORE_CTX *X509_STORE_CTX_new(void); + +int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); + +void X509_STORE_CTX_free(X509_STORE_CTX *ctx); +int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, + X509 *x509, STACK_OF(X509) *chain); +void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); +void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); + +X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m); + +X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void); +X509_LOOKUP_METHOD *X509_LOOKUP_file(void); + +int X509_STORE_add_cert(X509_STORE *ctx, X509 *x); +int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x); + +int X509_STORE_get_by_subject(X509_STORE_CTX *vs,int type,X509_NAME *name, + X509_OBJECT *ret); + +int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, + long argl, char **ret); + +#ifndef OPENSSL_NO_STDIO +int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); +int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); +int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); +#endif + + +X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); +void X509_LOOKUP_free(X509_LOOKUP *ctx); +int X509_LOOKUP_init(X509_LOOKUP *ctx); +int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name, + X509_OBJECT *ret); +int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name, + ASN1_INTEGER *serial, X509_OBJECT *ret); +int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type, + unsigned char *bytes, int len, X509_OBJECT *ret); +int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, + int len, X509_OBJECT *ret); +int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); + +#ifndef OPENSSL_NO_STDIO +int X509_STORE_load_locations (X509_STORE *ctx, + const char *file, const char *dir); +int X509_STORE_set_default_paths(X509_STORE *ctx); +#endif + +int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data); +void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx); +int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); +void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s); +int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); +X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); +STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx); +STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx); +void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x); +void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk); +void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c,STACK_OF(X509_CRL) *sk); +int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); +int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); +int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, + int purpose, int trust); +void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags); +void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, + time_t t); +void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, + int (*verify_cb)(int, X509_STORE_CTX *)); + +X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx); +int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx); + +X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx); +void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param); +int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name); + +/* X509_VERIFY_PARAM functions */ + +X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void); +void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, + const X509_VERIFY_PARAM *from); +int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, + const X509_VERIFY_PARAM *from); +int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name); +int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags); +int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, + unsigned long flags); +unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); +int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); +void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); +void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); +int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, + ASN1_OBJECT *policy); +int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, + STACK_OF(ASN1_OBJECT) *policies); +int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); + +int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param); +const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name); +void X509_VERIFY_PARAM_table_cleanup(void); + +int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, + STACK_OF(X509) *certs, + STACK_OF(ASN1_OBJECT) *policy_oids, + unsigned int flags); + +void X509_policy_tree_free(X509_POLICY_TREE *tree); + +int X509_policy_tree_level_count(const X509_POLICY_TREE *tree); +X509_POLICY_LEVEL * + X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i); + +STACK_OF(X509_POLICY_NODE) * + X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree); + +STACK_OF(X509_POLICY_NODE) * + X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree); + +int X509_policy_level_node_count(X509_POLICY_LEVEL *level); + +X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i); + +const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node); + +STACK_OF(POLICYQUALINFO) * + X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node); +const X509_POLICY_NODE * + X509_policy_node_get0_parent(const X509_POLICY_NODE *node); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/src/dep/include/openssl/x509v3.h b/src/dep/include/openssl/x509v3.h index 9b9d979..d7abf81 100644 --- a/src/dep/include/openssl/x509v3.h +++ b/src/dep/include/openssl/x509v3.h @@ -1,759 +1,759 @@ -/* x509v3.h */ -/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL - * project 1999. - */ -/* ==================================================================== - * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -#ifndef HEADER_X509V3_H -#define HEADER_X509V3_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Forward reference */ -struct v3_ext_method; -struct v3_ext_ctx; - -/* Useful typedefs */ - -typedef void * (*X509V3_EXT_NEW)(void); -typedef void (*X509V3_EXT_FREE)(void *); -typedef void * (*X509V3_EXT_D2I)(void *, const unsigned char ** , long); -typedef int (*X509V3_EXT_I2D)(void *, unsigned char **); -typedef STACK_OF(CONF_VALUE) * (*X509V3_EXT_I2V)(struct v3_ext_method *method, void *ext, STACK_OF(CONF_VALUE) *extlist); -typedef void * (*X509V3_EXT_V2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, STACK_OF(CONF_VALUE) *values); -typedef char * (*X509V3_EXT_I2S)(struct v3_ext_method *method, void *ext); -typedef void * (*X509V3_EXT_S2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, const char *str); -typedef int (*X509V3_EXT_I2R)(struct v3_ext_method *method, void *ext, BIO *out, int indent); -typedef void * (*X509V3_EXT_R2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, const char *str); - -/* V3 extension structure */ - -struct v3_ext_method { -int ext_nid; -int ext_flags; -/* If this is set the following four fields are ignored */ -ASN1_ITEM_EXP *it; -/* Old style ASN1 calls */ -X509V3_EXT_NEW ext_new; -X509V3_EXT_FREE ext_free; -X509V3_EXT_D2I d2i; -X509V3_EXT_I2D i2d; - -/* The following pair is used for string extensions */ -X509V3_EXT_I2S i2s; -X509V3_EXT_S2I s2i; - -/* The following pair is used for multi-valued extensions */ -X509V3_EXT_I2V i2v; -X509V3_EXT_V2I v2i; - -/* The following are used for raw extensions */ -X509V3_EXT_I2R i2r; -X509V3_EXT_R2I r2i; - -void *usr_data; /* Any extension specific data */ -}; - -typedef struct X509V3_CONF_METHOD_st { -char * (*get_string)(void *db, char *section, char *value); -STACK_OF(CONF_VALUE) * (*get_section)(void *db, char *section); -void (*free_string)(void *db, char * string); -void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section); -} X509V3_CONF_METHOD; - -/* Context specific info */ -struct v3_ext_ctx { -#define CTX_TEST 0x1 -int flags; -X509 *issuer_cert; -X509 *subject_cert; -X509_REQ *subject_req; -X509_CRL *crl; -X509V3_CONF_METHOD *db_meth; -void *db; -/* Maybe more here */ -}; - -typedef struct v3_ext_method X509V3_EXT_METHOD; - -DECLARE_STACK_OF(X509V3_EXT_METHOD) - -/* ext_flags values */ -#define X509V3_EXT_DYNAMIC 0x1 -#define X509V3_EXT_CTX_DEP 0x2 -#define X509V3_EXT_MULTILINE 0x4 - -typedef BIT_STRING_BITNAME ENUMERATED_NAMES; - -typedef struct BASIC_CONSTRAINTS_st { -int ca; -ASN1_INTEGER *pathlen; -} BASIC_CONSTRAINTS; - - -typedef struct PKEY_USAGE_PERIOD_st { -ASN1_GENERALIZEDTIME *notBefore; -ASN1_GENERALIZEDTIME *notAfter; -} PKEY_USAGE_PERIOD; - -typedef struct otherName_st { -ASN1_OBJECT *type_id; -ASN1_TYPE *value; -} OTHERNAME; - -typedef struct EDIPartyName_st { - ASN1_STRING *nameAssigner; - ASN1_STRING *partyName; -} EDIPARTYNAME; - -typedef struct GENERAL_NAME_st { - -#define GEN_OTHERNAME 0 -#define GEN_EMAIL 1 -#define GEN_DNS 2 -#define GEN_X400 3 -#define GEN_DIRNAME 4 -#define GEN_EDIPARTY 5 -#define GEN_URI 6 -#define GEN_IPADD 7 -#define GEN_RID 8 - -int type; -union { - char *ptr; - OTHERNAME *otherName; /* otherName */ - ASN1_IA5STRING *rfc822Name; - ASN1_IA5STRING *dNSName; - ASN1_TYPE *x400Address; - X509_NAME *directoryName; - EDIPARTYNAME *ediPartyName; - ASN1_IA5STRING *uniformResourceIdentifier; - ASN1_OCTET_STRING *iPAddress; - ASN1_OBJECT *registeredID; - - /* Old names */ - ASN1_OCTET_STRING *ip; /* iPAddress */ - X509_NAME *dirn; /* dirn */ - ASN1_IA5STRING *ia5;/* rfc822Name, dNSName, uniformResourceIdentifier */ - ASN1_OBJECT *rid; /* registeredID */ - ASN1_TYPE *other; /* x400Address */ -} d; -} GENERAL_NAME; - -typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES; - -typedef struct ACCESS_DESCRIPTION_st { - ASN1_OBJECT *method; - GENERAL_NAME *location; -} ACCESS_DESCRIPTION; - -typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; - -typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE; - -DECLARE_STACK_OF(GENERAL_NAME) -DECLARE_ASN1_SET_OF(GENERAL_NAME) - -DECLARE_STACK_OF(ACCESS_DESCRIPTION) -DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) - -typedef struct DIST_POINT_NAME_st { -int type; -union { - GENERAL_NAMES *fullname; - STACK_OF(X509_NAME_ENTRY) *relativename; -} name; -} DIST_POINT_NAME; - -typedef struct DIST_POINT_st { -DIST_POINT_NAME *distpoint; -ASN1_BIT_STRING *reasons; -GENERAL_NAMES *CRLissuer; -} DIST_POINT; - -typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS; - -DECLARE_STACK_OF(DIST_POINT) -DECLARE_ASN1_SET_OF(DIST_POINT) - -typedef struct AUTHORITY_KEYID_st { -ASN1_OCTET_STRING *keyid; -GENERAL_NAMES *issuer; -ASN1_INTEGER *serial; -} AUTHORITY_KEYID; - -/* Strong extranet structures */ - -typedef struct SXNET_ID_st { - ASN1_INTEGER *zone; - ASN1_OCTET_STRING *user; -} SXNETID; - -DECLARE_STACK_OF(SXNETID) -DECLARE_ASN1_SET_OF(SXNETID) - -typedef struct SXNET_st { - ASN1_INTEGER *version; - STACK_OF(SXNETID) *ids; -} SXNET; - -typedef struct NOTICEREF_st { - ASN1_STRING *organization; - STACK_OF(ASN1_INTEGER) *noticenos; -} NOTICEREF; - -typedef struct USERNOTICE_st { - NOTICEREF *noticeref; - ASN1_STRING *exptext; -} USERNOTICE; - -typedef struct POLICYQUALINFO_st { - ASN1_OBJECT *pqualid; - union { - ASN1_IA5STRING *cpsuri; - USERNOTICE *usernotice; - ASN1_TYPE *other; - } d; -} POLICYQUALINFO; - -DECLARE_STACK_OF(POLICYQUALINFO) -DECLARE_ASN1_SET_OF(POLICYQUALINFO) - -typedef struct POLICYINFO_st { - ASN1_OBJECT *policyid; - STACK_OF(POLICYQUALINFO) *qualifiers; -} POLICYINFO; - -typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES; - -DECLARE_STACK_OF(POLICYINFO) -DECLARE_ASN1_SET_OF(POLICYINFO) - -typedef struct POLICY_MAPPING_st { - ASN1_OBJECT *issuerDomainPolicy; - ASN1_OBJECT *subjectDomainPolicy; -} POLICY_MAPPING; - -DECLARE_STACK_OF(POLICY_MAPPING) - -typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS; - -typedef struct GENERAL_SUBTREE_st { - GENERAL_NAME *base; - ASN1_INTEGER *minimum; - ASN1_INTEGER *maximum; -} GENERAL_SUBTREE; - -DECLARE_STACK_OF(GENERAL_SUBTREE) - -typedef struct NAME_CONSTRAINTS_st { - STACK_OF(GENERAL_SUBTREE) *permittedSubtrees; - STACK_OF(GENERAL_SUBTREE) *excludedSubtrees; -} NAME_CONSTRAINTS; - -typedef struct POLICY_CONSTRAINTS_st { - ASN1_INTEGER *requireExplicitPolicy; - ASN1_INTEGER *inhibitPolicyMapping; -} POLICY_CONSTRAINTS; - -/* Proxy certificate structures, see RFC 3820 */ -typedef struct PROXY_POLICY_st - { - ASN1_OBJECT *policyLanguage; - ASN1_OCTET_STRING *policy; - } PROXY_POLICY; - -typedef struct PROXY_CERT_INFO_EXTENSION_st - { - ASN1_INTEGER *pcPathLengthConstraint; - PROXY_POLICY *proxyPolicy; - } PROXY_CERT_INFO_EXTENSION; - -DECLARE_ASN1_FUNCTIONS(PROXY_POLICY) -DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) - - -#define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \ -",name:", val->name, ",value:", val->value); - -#define X509V3_set_ctx_test(ctx) \ - X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST) -#define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL; - -#define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \ - 0,0,0,0, \ - 0,0, \ - (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \ - (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \ - NULL, NULL, \ - table} - -#define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \ - 0,0,0,0, \ - (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ - (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \ - 0,0,0,0, \ - NULL} - -#define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - - -/* X509_PURPOSE stuff */ - -#define EXFLAG_BCONS 0x1 -#define EXFLAG_KUSAGE 0x2 -#define EXFLAG_XKUSAGE 0x4 -#define EXFLAG_NSCERT 0x8 - -#define EXFLAG_CA 0x10 -#define EXFLAG_SS 0x20 -#define EXFLAG_V1 0x40 -#define EXFLAG_INVALID 0x80 -#define EXFLAG_SET 0x100 -#define EXFLAG_CRITICAL 0x200 -#define EXFLAG_PROXY 0x400 - -#define EXFLAG_INVALID_POLICY 0x400 - -#define KU_DIGITAL_SIGNATURE 0x0080 -#define KU_NON_REPUDIATION 0x0040 -#define KU_KEY_ENCIPHERMENT 0x0020 -#define KU_DATA_ENCIPHERMENT 0x0010 -#define KU_KEY_AGREEMENT 0x0008 -#define KU_KEY_CERT_SIGN 0x0004 -#define KU_CRL_SIGN 0x0002 -#define KU_ENCIPHER_ONLY 0x0001 -#define KU_DECIPHER_ONLY 0x8000 - -#define NS_SSL_CLIENT 0x80 -#define NS_SSL_SERVER 0x40 -#define NS_SMIME 0x20 -#define NS_OBJSIGN 0x10 -#define NS_SSL_CA 0x04 -#define NS_SMIME_CA 0x02 -#define NS_OBJSIGN_CA 0x01 -#define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA) - -#define XKU_SSL_SERVER 0x1 -#define XKU_SSL_CLIENT 0x2 -#define XKU_SMIME 0x4 -#define XKU_CODE_SIGN 0x8 -#define XKU_SGC 0x10 -#define XKU_OCSP_SIGN 0x20 -#define XKU_TIMESTAMP 0x40 -#define XKU_DVCS 0x80 - -#define X509_PURPOSE_DYNAMIC 0x1 -#define X509_PURPOSE_DYNAMIC_NAME 0x2 - -typedef struct x509_purpose_st { - int purpose; - int trust; /* Default trust ID */ - int flags; - int (*check_purpose)(const struct x509_purpose_st *, - const X509 *, int); - char *name; - char *sname; - void *usr_data; -} X509_PURPOSE; - -#define X509_PURPOSE_SSL_CLIENT 1 -#define X509_PURPOSE_SSL_SERVER 2 -#define X509_PURPOSE_NS_SSL_SERVER 3 -#define X509_PURPOSE_SMIME_SIGN 4 -#define X509_PURPOSE_SMIME_ENCRYPT 5 -#define X509_PURPOSE_CRL_SIGN 6 -#define X509_PURPOSE_ANY 7 -#define X509_PURPOSE_OCSP_HELPER 8 - -#define X509_PURPOSE_MIN 1 -#define X509_PURPOSE_MAX 8 - -/* Flags for X509V3_EXT_print() */ - -#define X509V3_EXT_UNKNOWN_MASK (0xfL << 16) -/* Return error for unknown extensions */ -#define X509V3_EXT_DEFAULT 0 -/* Print error for unknown extensions */ -#define X509V3_EXT_ERROR_UNKNOWN (1L << 16) -/* ASN1 parse unknown extensions */ -#define X509V3_EXT_PARSE_UNKNOWN (2L << 16) -/* BIO_dump unknown extensions */ -#define X509V3_EXT_DUMP_UNKNOWN (3L << 16) - -/* Flags for X509V3_add1_i2d */ - -#define X509V3_ADD_OP_MASK 0xfL -#define X509V3_ADD_DEFAULT 0L -#define X509V3_ADD_APPEND 1L -#define X509V3_ADD_REPLACE 2L -#define X509V3_ADD_REPLACE_EXISTING 3L -#define X509V3_ADD_KEEP_EXISTING 4L -#define X509V3_ADD_DELETE 5L -#define X509V3_ADD_SILENT 0x10 - -DECLARE_STACK_OF(X509_PURPOSE) - -DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) - -DECLARE_ASN1_FUNCTIONS(SXNET) -DECLARE_ASN1_FUNCTIONS(SXNETID) - -int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen); -int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen); -int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user, int userlen); - -ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone); -ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); -ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone); - -DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID) - -DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) - -DECLARE_ASN1_FUNCTIONS(GENERAL_NAME) - - -ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); -STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, - ASN1_BIT_STRING *bits, - STACK_OF(CONF_VALUE) *extlist); - -STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret); -int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen); - -DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES) - -STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, - GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) *extlist); -GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); - -DECLARE_ASN1_FUNCTIONS(OTHERNAME) -DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME) - -char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5); -ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); - -DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) -int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a); - -DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) -DECLARE_ASN1_FUNCTIONS(POLICYINFO) -DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO) -DECLARE_ASN1_FUNCTIONS(USERNOTICE) -DECLARE_ASN1_FUNCTIONS(NOTICEREF) - -DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS) -DECLARE_ASN1_FUNCTIONS(DIST_POINT) -DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME) - -DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) -DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) - -DECLARE_ASN1_ITEM(POLICY_MAPPING) -DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING) -DECLARE_ASN1_ITEM(POLICY_MAPPINGS) - -DECLARE_ASN1_ITEM(GENERAL_SUBTREE) -DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) - -DECLARE_ASN1_ITEM(NAME_CONSTRAINTS) -DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) - -DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS) -DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS) - -#ifdef HEADER_CONF_H -GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, - CONF_VALUE *cnf); -GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc); -void X509V3_conf_free(CONF_VALUE *val); - -X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value); -X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value); -int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk); -int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert); -int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); -int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); - -X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value); -X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value); -int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert); -int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); -int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); - -int X509V3_add_value_bool_nf(char *name, int asn1_bool, - STACK_OF(CONF_VALUE) **extlist); -int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool); -int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint); -void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); -void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash); -#endif - -char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section); -STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section); -void X509V3_string_free(X509V3_CTX *ctx, char *str); -void X509V3_section_free( X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section); -void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, - X509_REQ *req, X509_CRL *crl, int flags); - -int X509V3_add_value(const char *name, const char *value, - STACK_OF(CONF_VALUE) **extlist); -int X509V3_add_value_uchar(const char *name, const unsigned char *value, - STACK_OF(CONF_VALUE) **extlist); -int X509V3_add_value_bool(const char *name, int asn1_bool, - STACK_OF(CONF_VALUE) **extlist); -int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint, - STACK_OF(CONF_VALUE) **extlist); -char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint); -ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value); -char * i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); -char * i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); -int X509V3_EXT_add(X509V3_EXT_METHOD *ext); -int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); -int X509V3_EXT_add_alias(int nid_to, int nid_from); -void X509V3_EXT_cleanup(void); - -X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); -X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); -int X509V3_add_standard_extensions(void); -STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); -void *X509V3_EXT_d2i(X509_EXTENSION *ext); -void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx); - - -X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); -int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags); - -char *hex_to_string(unsigned char *buffer, long len); -unsigned char *string_to_hex(char *str, long *len); -int name_cmp(const char *name, const char *cmp); - -void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, - int ml); -int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent); -int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); - -int X509V3_extensions_print(BIO *out, char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent); - -int X509_check_ca(X509 *x); -int X509_check_purpose(X509 *x, int id, int ca); -int X509_supported_extension(X509_EXTENSION *ex); -int X509_PURPOSE_set(int *p, int purpose); -int X509_check_issued(X509 *issuer, X509 *subject); -int X509_PURPOSE_get_count(void); -X509_PURPOSE * X509_PURPOSE_get0(int idx); -int X509_PURPOSE_get_by_sname(char *sname); -int X509_PURPOSE_get_by_id(int id); -int X509_PURPOSE_add(int id, int trust, int flags, - int (*ck)(const X509_PURPOSE *, const X509 *, int), - char *name, char *sname, void *arg); -char *X509_PURPOSE_get0_name(X509_PURPOSE *xp); -char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp); -int X509_PURPOSE_get_trust(X509_PURPOSE *xp); -void X509_PURPOSE_cleanup(void); -int X509_PURPOSE_get_id(X509_PURPOSE *); - -STACK *X509_get1_email(X509 *x); -STACK *X509_REQ_get1_email(X509_REQ *x); -void X509_email_free(STACK *sk); - -ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc); -ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc); -int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk, - unsigned long chtype); - -void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_X509V3_strings(void); - -/* Error codes for the X509V3 functions. */ - -/* Function codes. */ -#define X509V3_F_COPY_EMAIL 122 -#define X509V3_F_COPY_ISSUER 123 -#define X509V3_F_DO_DIRNAME 144 -#define X509V3_F_DO_EXT_CONF 124 -#define X509V3_F_DO_EXT_I2D 135 -#define X509V3_F_DO_EXT_NCONF 151 -#define X509V3_F_DO_I2V_NAME_CONSTRAINTS 148 -#define X509V3_F_HEX_TO_STRING 111 -#define X509V3_F_I2S_ASN1_ENUMERATED 121 -#define X509V3_F_I2S_ASN1_IA5STRING 149 -#define X509V3_F_I2S_ASN1_INTEGER 120 -#define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 138 -#define X509V3_F_NOTICE_SECTION 132 -#define X509V3_F_NREF_NOS 133 -#define X509V3_F_POLICY_SECTION 131 -#define X509V3_F_PROCESS_PCI_VALUE 150 -#define X509V3_F_R2I_CERTPOL 130 -#define X509V3_F_R2I_PCI 155 -#define X509V3_F_S2I_ASN1_IA5STRING 100 -#define X509V3_F_S2I_ASN1_INTEGER 108 -#define X509V3_F_S2I_ASN1_OCTET_STRING 112 -#define X509V3_F_S2I_ASN1_SKEY_ID 114 -#define X509V3_F_S2I_SKEY_ID 115 -#define X509V3_F_STRING_TO_HEX 113 -#define X509V3_F_SXNET_ADD_ID_ASC 125 -#define X509V3_F_SXNET_ADD_ID_INTEGER 126 -#define X509V3_F_SXNET_ADD_ID_ULONG 127 -#define X509V3_F_SXNET_GET_ID_ASC 128 -#define X509V3_F_SXNET_GET_ID_ULONG 129 -#define X509V3_F_V2I_ASN1_BIT_STRING 101 -#define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 139 -#define X509V3_F_V2I_AUTHORITY_KEYID 119 -#define X509V3_F_V2I_BASIC_CONSTRAINTS 102 -#define X509V3_F_V2I_CRLD 134 -#define X509V3_F_V2I_EXTENDED_KEY_USAGE 103 -#define X509V3_F_V2I_GENERAL_NAMES 118 -#define X509V3_F_V2I_GENERAL_NAME_EX 117 -#define X509V3_F_V2I_ISSUER_ALT 153 -#define X509V3_F_V2I_NAME_CONSTRAINTS 147 -#define X509V3_F_V2I_POLICY_CONSTRAINTS 146 -#define X509V3_F_V2I_POLICY_MAPPINGS 145 -#define X509V3_F_V2I_SUBJECT_ALT 154 -#define X509V3_F_V3_GENERIC_EXTENSION 116 -#define X509V3_F_X509V3_ADD1_I2D 140 -#define X509V3_F_X509V3_ADD_VALUE 105 -#define X509V3_F_X509V3_EXT_ADD 104 -#define X509V3_F_X509V3_EXT_ADD_ALIAS 106 -#define X509V3_F_X509V3_EXT_CONF 107 -#define X509V3_F_X509V3_EXT_I2D 136 -#define X509V3_F_X509V3_EXT_NCONF 152 -#define X509V3_F_X509V3_GET_SECTION 142 -#define X509V3_F_X509V3_GET_STRING 143 -#define X509V3_F_X509V3_GET_VALUE_BOOL 110 -#define X509V3_F_X509V3_PARSE_LIST 109 -#define X509V3_F_X509_PURPOSE_ADD 137 -#define X509V3_F_X509_PURPOSE_SET 141 - -/* Reason codes. */ -#define X509V3_R_BAD_IP_ADDRESS 118 -#define X509V3_R_BAD_OBJECT 119 -#define X509V3_R_BN_DEC2BN_ERROR 100 -#define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101 -#define X509V3_R_DIRNAME_ERROR 149 -#define X509V3_R_DUPLICATE_ZONE_ID 133 -#define X509V3_R_ERROR_CONVERTING_ZONE 131 -#define X509V3_R_ERROR_CREATING_EXTENSION 144 -#define X509V3_R_ERROR_IN_EXTENSION 128 -#define X509V3_R_EXPECTED_A_SECTION_NAME 137 -#define X509V3_R_EXTENSION_EXISTS 145 -#define X509V3_R_EXTENSION_NAME_ERROR 115 -#define X509V3_R_EXTENSION_NOT_FOUND 102 -#define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103 -#define X509V3_R_EXTENSION_VALUE_ERROR 116 -#define X509V3_R_ILLEGAL_EMPTY_EXTENSION 151 -#define X509V3_R_ILLEGAL_HEX_DIGIT 113 -#define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 152 -#define X509V3_R_INVALID_BOOLEAN_STRING 104 -#define X509V3_R_INVALID_EXTENSION_STRING 105 -#define X509V3_R_INVALID_NAME 106 -#define X509V3_R_INVALID_NULL_ARGUMENT 107 -#define X509V3_R_INVALID_NULL_NAME 108 -#define X509V3_R_INVALID_NULL_VALUE 109 -#define X509V3_R_INVALID_NUMBER 140 -#define X509V3_R_INVALID_NUMBERS 141 -#define X509V3_R_INVALID_OBJECT_IDENTIFIER 110 -#define X509V3_R_INVALID_OPTION 138 -#define X509V3_R_INVALID_POLICY_IDENTIFIER 134 -#define X509V3_R_INVALID_PROXY_POLICY_SETTING 153 -#define X509V3_R_INVALID_PURPOSE 146 -#define X509V3_R_INVALID_SECTION 135 -#define X509V3_R_INVALID_SYNTAX 143 -#define X509V3_R_ISSUER_DECODE_ERROR 126 -#define X509V3_R_MISSING_VALUE 124 -#define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142 -#define X509V3_R_NO_CONFIG_DATABASE 136 -#define X509V3_R_NO_ISSUER_CERTIFICATE 121 -#define X509V3_R_NO_ISSUER_DETAILS 127 -#define X509V3_R_NO_POLICY_IDENTIFIER 139 -#define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 154 -#define X509V3_R_NO_PUBLIC_KEY 114 -#define X509V3_R_NO_SUBJECT_DETAILS 125 -#define X509V3_R_ODD_NUMBER_OF_DIGITS 112 -#define X509V3_R_OPERATION_NOT_DEFINED 148 -#define X509V3_R_OTHERNAME_ERROR 147 -#define X509V3_R_POLICY_LANGUAGE_ALREADTY_DEFINED 155 -#define X509V3_R_POLICY_PATH_LENGTH 156 -#define X509V3_R_POLICY_PATH_LENGTH_ALREADTY_DEFINED 157 -#define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED 158 -#define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159 -#define X509V3_R_SECTION_NOT_FOUND 150 -#define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 122 -#define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 123 -#define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 111 -#define X509V3_R_UNKNOWN_EXTENSION 129 -#define X509V3_R_UNKNOWN_EXTENSION_NAME 130 -#define X509V3_R_UNKNOWN_OPTION 120 -#define X509V3_R_UNSUPPORTED_OPTION 117 -#define X509V3_R_USER_TOO_LONG 132 - -#ifdef __cplusplus -} -#endif -#endif +/* x509v3.h */ +/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL + * project 1999. + */ +/* ==================================================================== + * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_X509V3_H +#define HEADER_X509V3_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Forward reference */ +struct v3_ext_method; +struct v3_ext_ctx; + +/* Useful typedefs */ + +typedef void * (*X509V3_EXT_NEW)(void); +typedef void (*X509V3_EXT_FREE)(void *); +typedef void * (*X509V3_EXT_D2I)(void *, const unsigned char ** , long); +typedef int (*X509V3_EXT_I2D)(void *, unsigned char **); +typedef STACK_OF(CONF_VALUE) * (*X509V3_EXT_I2V)(struct v3_ext_method *method, void *ext, STACK_OF(CONF_VALUE) *extlist); +typedef void * (*X509V3_EXT_V2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, STACK_OF(CONF_VALUE) *values); +typedef char * (*X509V3_EXT_I2S)(struct v3_ext_method *method, void *ext); +typedef void * (*X509V3_EXT_S2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, const char *str); +typedef int (*X509V3_EXT_I2R)(struct v3_ext_method *method, void *ext, BIO *out, int indent); +typedef void * (*X509V3_EXT_R2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, const char *str); + +/* V3 extension structure */ + +struct v3_ext_method { +int ext_nid; +int ext_flags; +/* If this is set the following four fields are ignored */ +ASN1_ITEM_EXP *it; +/* Old style ASN1 calls */ +X509V3_EXT_NEW ext_new; +X509V3_EXT_FREE ext_free; +X509V3_EXT_D2I d2i; +X509V3_EXT_I2D i2d; + +/* The following pair is used for string extensions */ +X509V3_EXT_I2S i2s; +X509V3_EXT_S2I s2i; + +/* The following pair is used for multi-valued extensions */ +X509V3_EXT_I2V i2v; +X509V3_EXT_V2I v2i; + +/* The following are used for raw extensions */ +X509V3_EXT_I2R i2r; +X509V3_EXT_R2I r2i; + +void *usr_data; /* Any extension specific data */ +}; + +typedef struct X509V3_CONF_METHOD_st { +char * (*get_string)(void *db, char *section, char *value); +STACK_OF(CONF_VALUE) * (*get_section)(void *db, char *section); +void (*free_string)(void *db, char * string); +void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section); +} X509V3_CONF_METHOD; + +/* Context specific info */ +struct v3_ext_ctx { +#define CTX_TEST 0x1 +int flags; +X509 *issuer_cert; +X509 *subject_cert; +X509_REQ *subject_req; +X509_CRL *crl; +X509V3_CONF_METHOD *db_meth; +void *db; +/* Maybe more here */ +}; + +typedef struct v3_ext_method X509V3_EXT_METHOD; + +DECLARE_STACK_OF(X509V3_EXT_METHOD) + +/* ext_flags values */ +#define X509V3_EXT_DYNAMIC 0x1 +#define X509V3_EXT_CTX_DEP 0x2 +#define X509V3_EXT_MULTILINE 0x4 + +typedef BIT_STRING_BITNAME ENUMERATED_NAMES; + +typedef struct BASIC_CONSTRAINTS_st { +int ca; +ASN1_INTEGER *pathlen; +} BASIC_CONSTRAINTS; + + +typedef struct PKEY_USAGE_PERIOD_st { +ASN1_GENERALIZEDTIME *notBefore; +ASN1_GENERALIZEDTIME *notAfter; +} PKEY_USAGE_PERIOD; + +typedef struct otherName_st { +ASN1_OBJECT *type_id; +ASN1_TYPE *value; +} OTHERNAME; + +typedef struct EDIPartyName_st { + ASN1_STRING *nameAssigner; + ASN1_STRING *partyName; +} EDIPARTYNAME; + +typedef struct GENERAL_NAME_st { + +#define GEN_OTHERNAME 0 +#define GEN_EMAIL 1 +#define GEN_DNS 2 +#define GEN_X400 3 +#define GEN_DIRNAME 4 +#define GEN_EDIPARTY 5 +#define GEN_URI 6 +#define GEN_IPADD 7 +#define GEN_RID 8 + +int type; +union { + char *ptr; + OTHERNAME *otherName; /* otherName */ + ASN1_IA5STRING *rfc822Name; + ASN1_IA5STRING *dNSName; + ASN1_TYPE *x400Address; + X509_NAME *directoryName; + EDIPARTYNAME *ediPartyName; + ASN1_IA5STRING *uniformResourceIdentifier; + ASN1_OCTET_STRING *iPAddress; + ASN1_OBJECT *registeredID; + + /* Old names */ + ASN1_OCTET_STRING *ip; /* iPAddress */ + X509_NAME *dirn; /* dirn */ + ASN1_IA5STRING *ia5;/* rfc822Name, dNSName, uniformResourceIdentifier */ + ASN1_OBJECT *rid; /* registeredID */ + ASN1_TYPE *other; /* x400Address */ +} d; +} GENERAL_NAME; + +typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES; + +typedef struct ACCESS_DESCRIPTION_st { + ASN1_OBJECT *method; + GENERAL_NAME *location; +} ACCESS_DESCRIPTION; + +typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; + +typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE; + +DECLARE_STACK_OF(GENERAL_NAME) +DECLARE_ASN1_SET_OF(GENERAL_NAME) + +DECLARE_STACK_OF(ACCESS_DESCRIPTION) +DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) + +typedef struct DIST_POINT_NAME_st { +int type; +union { + GENERAL_NAMES *fullname; + STACK_OF(X509_NAME_ENTRY) *relativename; +} name; +} DIST_POINT_NAME; + +typedef struct DIST_POINT_st { +DIST_POINT_NAME *distpoint; +ASN1_BIT_STRING *reasons; +GENERAL_NAMES *CRLissuer; +} DIST_POINT; + +typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS; + +DECLARE_STACK_OF(DIST_POINT) +DECLARE_ASN1_SET_OF(DIST_POINT) + +typedef struct AUTHORITY_KEYID_st { +ASN1_OCTET_STRING *keyid; +GENERAL_NAMES *issuer; +ASN1_INTEGER *serial; +} AUTHORITY_KEYID; + +/* Strong extranet structures */ + +typedef struct SXNET_ID_st { + ASN1_INTEGER *zone; + ASN1_OCTET_STRING *user; +} SXNETID; + +DECLARE_STACK_OF(SXNETID) +DECLARE_ASN1_SET_OF(SXNETID) + +typedef struct SXNET_st { + ASN1_INTEGER *version; + STACK_OF(SXNETID) *ids; +} SXNET; + +typedef struct NOTICEREF_st { + ASN1_STRING *organization; + STACK_OF(ASN1_INTEGER) *noticenos; +} NOTICEREF; + +typedef struct USERNOTICE_st { + NOTICEREF *noticeref; + ASN1_STRING *exptext; +} USERNOTICE; + +typedef struct POLICYQUALINFO_st { + ASN1_OBJECT *pqualid; + union { + ASN1_IA5STRING *cpsuri; + USERNOTICE *usernotice; + ASN1_TYPE *other; + } d; +} POLICYQUALINFO; + +DECLARE_STACK_OF(POLICYQUALINFO) +DECLARE_ASN1_SET_OF(POLICYQUALINFO) + +typedef struct POLICYINFO_st { + ASN1_OBJECT *policyid; + STACK_OF(POLICYQUALINFO) *qualifiers; +} POLICYINFO; + +typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES; + +DECLARE_STACK_OF(POLICYINFO) +DECLARE_ASN1_SET_OF(POLICYINFO) + +typedef struct POLICY_MAPPING_st { + ASN1_OBJECT *issuerDomainPolicy; + ASN1_OBJECT *subjectDomainPolicy; +} POLICY_MAPPING; + +DECLARE_STACK_OF(POLICY_MAPPING) + +typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS; + +typedef struct GENERAL_SUBTREE_st { + GENERAL_NAME *base; + ASN1_INTEGER *minimum; + ASN1_INTEGER *maximum; +} GENERAL_SUBTREE; + +DECLARE_STACK_OF(GENERAL_SUBTREE) + +typedef struct NAME_CONSTRAINTS_st { + STACK_OF(GENERAL_SUBTREE) *permittedSubtrees; + STACK_OF(GENERAL_SUBTREE) *excludedSubtrees; +} NAME_CONSTRAINTS; + +typedef struct POLICY_CONSTRAINTS_st { + ASN1_INTEGER *requireExplicitPolicy; + ASN1_INTEGER *inhibitPolicyMapping; +} POLICY_CONSTRAINTS; + +/* Proxy certificate structures, see RFC 3820 */ +typedef struct PROXY_POLICY_st + { + ASN1_OBJECT *policyLanguage; + ASN1_OCTET_STRING *policy; + } PROXY_POLICY; + +typedef struct PROXY_CERT_INFO_EXTENSION_st + { + ASN1_INTEGER *pcPathLengthConstraint; + PROXY_POLICY *proxyPolicy; + } PROXY_CERT_INFO_EXTENSION; + +DECLARE_ASN1_FUNCTIONS(PROXY_POLICY) +DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) + + +#define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \ +",name:", val->name, ",value:", val->value); + +#define X509V3_set_ctx_test(ctx) \ + X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST) +#define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL; + +#define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \ + 0,0,0,0, \ + 0,0, \ + (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \ + (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \ + NULL, NULL, \ + table} + +#define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \ + 0,0,0,0, \ + (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ + (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \ + 0,0,0,0, \ + NULL} + +#define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + + +/* X509_PURPOSE stuff */ + +#define EXFLAG_BCONS 0x1 +#define EXFLAG_KUSAGE 0x2 +#define EXFLAG_XKUSAGE 0x4 +#define EXFLAG_NSCERT 0x8 + +#define EXFLAG_CA 0x10 +#define EXFLAG_SS 0x20 +#define EXFLAG_V1 0x40 +#define EXFLAG_INVALID 0x80 +#define EXFLAG_SET 0x100 +#define EXFLAG_CRITICAL 0x200 +#define EXFLAG_PROXY 0x400 + +#define EXFLAG_INVALID_POLICY 0x400 + +#define KU_DIGITAL_SIGNATURE 0x0080 +#define KU_NON_REPUDIATION 0x0040 +#define KU_KEY_ENCIPHERMENT 0x0020 +#define KU_DATA_ENCIPHERMENT 0x0010 +#define KU_KEY_AGREEMENT 0x0008 +#define KU_KEY_CERT_SIGN 0x0004 +#define KU_CRL_SIGN 0x0002 +#define KU_ENCIPHER_ONLY 0x0001 +#define KU_DECIPHER_ONLY 0x8000 + +#define NS_SSL_CLIENT 0x80 +#define NS_SSL_SERVER 0x40 +#define NS_SMIME 0x20 +#define NS_OBJSIGN 0x10 +#define NS_SSL_CA 0x04 +#define NS_SMIME_CA 0x02 +#define NS_OBJSIGN_CA 0x01 +#define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA) + +#define XKU_SSL_SERVER 0x1 +#define XKU_SSL_CLIENT 0x2 +#define XKU_SMIME 0x4 +#define XKU_CODE_SIGN 0x8 +#define XKU_SGC 0x10 +#define XKU_OCSP_SIGN 0x20 +#define XKU_TIMESTAMP 0x40 +#define XKU_DVCS 0x80 + +#define X509_PURPOSE_DYNAMIC 0x1 +#define X509_PURPOSE_DYNAMIC_NAME 0x2 + +typedef struct x509_purpose_st { + int purpose; + int trust; /* Default trust ID */ + int flags; + int (*check_purpose)(const struct x509_purpose_st *, + const X509 *, int); + char *name; + char *sname; + void *usr_data; +} X509_PURPOSE; + +#define X509_PURPOSE_SSL_CLIENT 1 +#define X509_PURPOSE_SSL_SERVER 2 +#define X509_PURPOSE_NS_SSL_SERVER 3 +#define X509_PURPOSE_SMIME_SIGN 4 +#define X509_PURPOSE_SMIME_ENCRYPT 5 +#define X509_PURPOSE_CRL_SIGN 6 +#define X509_PURPOSE_ANY 7 +#define X509_PURPOSE_OCSP_HELPER 8 + +#define X509_PURPOSE_MIN 1 +#define X509_PURPOSE_MAX 8 + +/* Flags for X509V3_EXT_print() */ + +#define X509V3_EXT_UNKNOWN_MASK (0xfL << 16) +/* Return error for unknown extensions */ +#define X509V3_EXT_DEFAULT 0 +/* Print error for unknown extensions */ +#define X509V3_EXT_ERROR_UNKNOWN (1L << 16) +/* ASN1 parse unknown extensions */ +#define X509V3_EXT_PARSE_UNKNOWN (2L << 16) +/* BIO_dump unknown extensions */ +#define X509V3_EXT_DUMP_UNKNOWN (3L << 16) + +/* Flags for X509V3_add1_i2d */ + +#define X509V3_ADD_OP_MASK 0xfL +#define X509V3_ADD_DEFAULT 0L +#define X509V3_ADD_APPEND 1L +#define X509V3_ADD_REPLACE 2L +#define X509V3_ADD_REPLACE_EXISTING 3L +#define X509V3_ADD_KEEP_EXISTING 4L +#define X509V3_ADD_DELETE 5L +#define X509V3_ADD_SILENT 0x10 + +DECLARE_STACK_OF(X509_PURPOSE) + +DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) + +DECLARE_ASN1_FUNCTIONS(SXNET) +DECLARE_ASN1_FUNCTIONS(SXNETID) + +int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen); +int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen); +int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user, int userlen); + +ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone); +ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); +ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone); + +DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID) + +DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) + +DECLARE_ASN1_FUNCTIONS(GENERAL_NAME) + + +ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); +STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, + ASN1_BIT_STRING *bits, + STACK_OF(CONF_VALUE) *extlist); + +STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret); +int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen); + +DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES) + +STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, + GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) *extlist); +GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); + +DECLARE_ASN1_FUNCTIONS(OTHERNAME) +DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME) + +char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5); +ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); + +DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) +int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a); + +DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) +DECLARE_ASN1_FUNCTIONS(POLICYINFO) +DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO) +DECLARE_ASN1_FUNCTIONS(USERNOTICE) +DECLARE_ASN1_FUNCTIONS(NOTICEREF) + +DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS) +DECLARE_ASN1_FUNCTIONS(DIST_POINT) +DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME) + +DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) +DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) + +DECLARE_ASN1_ITEM(POLICY_MAPPING) +DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING) +DECLARE_ASN1_ITEM(POLICY_MAPPINGS) + +DECLARE_ASN1_ITEM(GENERAL_SUBTREE) +DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) + +DECLARE_ASN1_ITEM(NAME_CONSTRAINTS) +DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) + +DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS) +DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS) + +#ifdef HEADER_CONF_H +GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, + CONF_VALUE *cnf); +GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc); +void X509V3_conf_free(CONF_VALUE *val); + +X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value); +X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value); +int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk); +int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert); +int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); +int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); + +X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value); +X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value); +int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert); +int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); +int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); + +int X509V3_add_value_bool_nf(char *name, int asn1_bool, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool); +int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint); +void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); +void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash); +#endif + +char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section); +STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section); +void X509V3_string_free(X509V3_CTX *ctx, char *str); +void X509V3_section_free( X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section); +void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, + X509_REQ *req, X509_CRL *crl, int flags); + +int X509V3_add_value(const char *name, const char *value, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_uchar(const char *name, const unsigned char *value, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_bool(const char *name, int asn1_bool, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint, + STACK_OF(CONF_VALUE) **extlist); +char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint); +ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value); +char * i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); +char * i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); +int X509V3_EXT_add(X509V3_EXT_METHOD *ext); +int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); +int X509V3_EXT_add_alias(int nid_to, int nid_from); +void X509V3_EXT_cleanup(void); + +X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); +X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); +int X509V3_add_standard_extensions(void); +STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); +void *X509V3_EXT_d2i(X509_EXTENSION *ext); +void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx); + + +X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); +int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags); + +char *hex_to_string(unsigned char *buffer, long len); +unsigned char *string_to_hex(char *str, long *len); +int name_cmp(const char *name, const char *cmp); + +void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, + int ml); +int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent); +int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); + +int X509V3_extensions_print(BIO *out, char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent); + +int X509_check_ca(X509 *x); +int X509_check_purpose(X509 *x, int id, int ca); +int X509_supported_extension(X509_EXTENSION *ex); +int X509_PURPOSE_set(int *p, int purpose); +int X509_check_issued(X509 *issuer, X509 *subject); +int X509_PURPOSE_get_count(void); +X509_PURPOSE * X509_PURPOSE_get0(int idx); +int X509_PURPOSE_get_by_sname(char *sname); +int X509_PURPOSE_get_by_id(int id); +int X509_PURPOSE_add(int id, int trust, int flags, + int (*ck)(const X509_PURPOSE *, const X509 *, int), + char *name, char *sname, void *arg); +char *X509_PURPOSE_get0_name(X509_PURPOSE *xp); +char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp); +int X509_PURPOSE_get_trust(X509_PURPOSE *xp); +void X509_PURPOSE_cleanup(void); +int X509_PURPOSE_get_id(X509_PURPOSE *); + +STACK *X509_get1_email(X509 *x); +STACK *X509_REQ_get1_email(X509_REQ *x); +void X509_email_free(STACK *sk); + +ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc); +ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc); +int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk, + unsigned long chtype); + +void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_X509V3_strings(void); + +/* Error codes for the X509V3 functions. */ + +/* Function codes. */ +#define X509V3_F_COPY_EMAIL 122 +#define X509V3_F_COPY_ISSUER 123 +#define X509V3_F_DO_DIRNAME 144 +#define X509V3_F_DO_EXT_CONF 124 +#define X509V3_F_DO_EXT_I2D 135 +#define X509V3_F_DO_EXT_NCONF 151 +#define X509V3_F_DO_I2V_NAME_CONSTRAINTS 148 +#define X509V3_F_HEX_TO_STRING 111 +#define X509V3_F_I2S_ASN1_ENUMERATED 121 +#define X509V3_F_I2S_ASN1_IA5STRING 149 +#define X509V3_F_I2S_ASN1_INTEGER 120 +#define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 138 +#define X509V3_F_NOTICE_SECTION 132 +#define X509V3_F_NREF_NOS 133 +#define X509V3_F_POLICY_SECTION 131 +#define X509V3_F_PROCESS_PCI_VALUE 150 +#define X509V3_F_R2I_CERTPOL 130 +#define X509V3_F_R2I_PCI 155 +#define X509V3_F_S2I_ASN1_IA5STRING 100 +#define X509V3_F_S2I_ASN1_INTEGER 108 +#define X509V3_F_S2I_ASN1_OCTET_STRING 112 +#define X509V3_F_S2I_ASN1_SKEY_ID 114 +#define X509V3_F_S2I_SKEY_ID 115 +#define X509V3_F_STRING_TO_HEX 113 +#define X509V3_F_SXNET_ADD_ID_ASC 125 +#define X509V3_F_SXNET_ADD_ID_INTEGER 126 +#define X509V3_F_SXNET_ADD_ID_ULONG 127 +#define X509V3_F_SXNET_GET_ID_ASC 128 +#define X509V3_F_SXNET_GET_ID_ULONG 129 +#define X509V3_F_V2I_ASN1_BIT_STRING 101 +#define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 139 +#define X509V3_F_V2I_AUTHORITY_KEYID 119 +#define X509V3_F_V2I_BASIC_CONSTRAINTS 102 +#define X509V3_F_V2I_CRLD 134 +#define X509V3_F_V2I_EXTENDED_KEY_USAGE 103 +#define X509V3_F_V2I_GENERAL_NAMES 118 +#define X509V3_F_V2I_GENERAL_NAME_EX 117 +#define X509V3_F_V2I_ISSUER_ALT 153 +#define X509V3_F_V2I_NAME_CONSTRAINTS 147 +#define X509V3_F_V2I_POLICY_CONSTRAINTS 146 +#define X509V3_F_V2I_POLICY_MAPPINGS 145 +#define X509V3_F_V2I_SUBJECT_ALT 154 +#define X509V3_F_V3_GENERIC_EXTENSION 116 +#define X509V3_F_X509V3_ADD1_I2D 140 +#define X509V3_F_X509V3_ADD_VALUE 105 +#define X509V3_F_X509V3_EXT_ADD 104 +#define X509V3_F_X509V3_EXT_ADD_ALIAS 106 +#define X509V3_F_X509V3_EXT_CONF 107 +#define X509V3_F_X509V3_EXT_I2D 136 +#define X509V3_F_X509V3_EXT_NCONF 152 +#define X509V3_F_X509V3_GET_SECTION 142 +#define X509V3_F_X509V3_GET_STRING 143 +#define X509V3_F_X509V3_GET_VALUE_BOOL 110 +#define X509V3_F_X509V3_PARSE_LIST 109 +#define X509V3_F_X509_PURPOSE_ADD 137 +#define X509V3_F_X509_PURPOSE_SET 141 + +/* Reason codes. */ +#define X509V3_R_BAD_IP_ADDRESS 118 +#define X509V3_R_BAD_OBJECT 119 +#define X509V3_R_BN_DEC2BN_ERROR 100 +#define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101 +#define X509V3_R_DIRNAME_ERROR 149 +#define X509V3_R_DUPLICATE_ZONE_ID 133 +#define X509V3_R_ERROR_CONVERTING_ZONE 131 +#define X509V3_R_ERROR_CREATING_EXTENSION 144 +#define X509V3_R_ERROR_IN_EXTENSION 128 +#define X509V3_R_EXPECTED_A_SECTION_NAME 137 +#define X509V3_R_EXTENSION_EXISTS 145 +#define X509V3_R_EXTENSION_NAME_ERROR 115 +#define X509V3_R_EXTENSION_NOT_FOUND 102 +#define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103 +#define X509V3_R_EXTENSION_VALUE_ERROR 116 +#define X509V3_R_ILLEGAL_EMPTY_EXTENSION 151 +#define X509V3_R_ILLEGAL_HEX_DIGIT 113 +#define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 152 +#define X509V3_R_INVALID_BOOLEAN_STRING 104 +#define X509V3_R_INVALID_EXTENSION_STRING 105 +#define X509V3_R_INVALID_NAME 106 +#define X509V3_R_INVALID_NULL_ARGUMENT 107 +#define X509V3_R_INVALID_NULL_NAME 108 +#define X509V3_R_INVALID_NULL_VALUE 109 +#define X509V3_R_INVALID_NUMBER 140 +#define X509V3_R_INVALID_NUMBERS 141 +#define X509V3_R_INVALID_OBJECT_IDENTIFIER 110 +#define X509V3_R_INVALID_OPTION 138 +#define X509V3_R_INVALID_POLICY_IDENTIFIER 134 +#define X509V3_R_INVALID_PROXY_POLICY_SETTING 153 +#define X509V3_R_INVALID_PURPOSE 146 +#define X509V3_R_INVALID_SECTION 135 +#define X509V3_R_INVALID_SYNTAX 143 +#define X509V3_R_ISSUER_DECODE_ERROR 126 +#define X509V3_R_MISSING_VALUE 124 +#define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142 +#define X509V3_R_NO_CONFIG_DATABASE 136 +#define X509V3_R_NO_ISSUER_CERTIFICATE 121 +#define X509V3_R_NO_ISSUER_DETAILS 127 +#define X509V3_R_NO_POLICY_IDENTIFIER 139 +#define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 154 +#define X509V3_R_NO_PUBLIC_KEY 114 +#define X509V3_R_NO_SUBJECT_DETAILS 125 +#define X509V3_R_ODD_NUMBER_OF_DIGITS 112 +#define X509V3_R_OPERATION_NOT_DEFINED 148 +#define X509V3_R_OTHERNAME_ERROR 147 +#define X509V3_R_POLICY_LANGUAGE_ALREADTY_DEFINED 155 +#define X509V3_R_POLICY_PATH_LENGTH 156 +#define X509V3_R_POLICY_PATH_LENGTH_ALREADTY_DEFINED 157 +#define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED 158 +#define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159 +#define X509V3_R_SECTION_NOT_FOUND 150 +#define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 122 +#define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 123 +#define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 111 +#define X509V3_R_UNKNOWN_EXTENSION 129 +#define X509V3_R_UNKNOWN_EXTENSION_NAME 130 +#define X509V3_R_UNKNOWN_OPTION 120 +#define X509V3_R_UNSUPPORTED_OPTION 117 +#define X509V3_R_USER_TOO_LONG 132 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/dep/src/irrlicht/BuiltInFont.h b/src/dep/src/irrlicht/BuiltInFont.h index ac40ca9..de7c6d2 100644 --- a/src/dep/src/irrlicht/BuiltInFont.h +++ b/src/dep/src/irrlicht/BuiltInFont.h @@ -1,1065 +1,1065 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __BUILD_IN_FONT_H_INCLUDED__ -#define __BUILD_IN_FONT_H_INCLUDED__ - -// headerfile generated by Bin2H, copyright 2002 by N.Gebhardt. -// Bin2H is Freeware. Download it freely from www.code3d.com. - -namespace irr -{ -namespace gui -{ - -u8 BuiltInFontData[] = -{ - 0x42, 0x4d, 0x76, 0x20, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x76, 0x0, 0x0, 0x0, 0x28, 0x0, - 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x80, 0x0, - 0x0, 0x0, 0x1, 0x0, 0x4, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x63, 0xb, - 0x0, 0x0, 0x63, 0xb, 0x0, 0x0, 0x10, 0x0, - 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xff, 0x0, 0x0, 0xff, - 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff, - 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff, - 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff, - 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff, - 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff, - 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff, - 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x10, - 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x10, - 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, - 0x0, 0x1, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, - 0x10, 0x0, 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, - 0x10, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, - 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, 0x33, - 0x33, 0x33, 0x30, 0x33, 0x33, 0x33, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x33, 0x33, 0x33, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x3, 0x33, 0x33, 0x33, 0x3, - 0x33, 0x33, 0x33, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, - 0x0, 0x0, 0x30, 0x30, 0x0, 0x3, 0x0, 0x3, - 0x30, 0x0, 0x3, 0x30, 0x33, 0x33, 0x33, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x30, 0x30, 0x0, 0x0, 0x3, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, 0x3, - 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, - 0x0, 0x0, 0x30, 0x30, 0x0, 0x3, 0x0, 0x0, - 0x33, 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, - 0x3, 0x30, 0x33, 0x0, 0x0, 0x33, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, 0x3, - 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, - 0x0, 0x0, 0x30, 0x30, 0x0, 0x3, 0x33, 0x0, - 0x3, 0x33, 0x30, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x33, 0x33, 0x33, 0x0, 0x3, 0x33, 0x0, 0x0, - 0x33, 0x30, 0x33, 0x30, 0x3, 0x33, 0x33, 0x0, - 0x3, 0x33, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x3, 0x30, 0x3, 0x0, 0x0, 0x3, 0x3, - 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, - 0x0, 0x0, 0x30, 0x33, 0x33, 0x33, 0x3, 0x0, - 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x33, 0x33, 0x30, 0x0, 0x33, 0x33, 0x30, 0x3, - 0x33, 0x30, 0x33, 0x33, 0x3, 0x30, 0x33, 0x30, - 0x0, 0x0, 0x0, 0x0, 0x33, 0x30, 0x0, 0x30, - 0x0, 0x33, 0x33, 0x3, 0x0, 0x0, 0x3, 0x3, - 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, - 0x0, 0x0, 0x30, 0x33, 0x33, 0x33, 0x3, 0x0, - 0x3, 0x33, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x3, 0x33, 0x0, 0x3, 0x33, 0x33, 0x33, 0x0, - 0x33, 0x30, 0x33, 0x30, 0x3, 0x0, 0x3, 0x33, - 0x0, 0x3, 0x0, 0x0, 0x3, 0x0, 0x3, 0x33, - 0x0, 0x33, 0x33, 0x3, 0x0, 0x33, 0x33, 0x3, - 0x33, 0x33, 0x33, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, - 0x0, 0x0, 0x30, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x33, 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x3, 0x30, 0x33, 0x0, 0x0, 0x0, 0x0, 0x33, - 0x0, 0x33, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x3, 0x30, 0x3, 0x0, 0x30, 0x30, 0x0, - 0x33, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, 0x33, - 0x33, 0x33, 0x30, 0x0, 0x33, 0x33, 0x33, 0x3, - 0x30, 0x0, 0x3, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x30, 0x30, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x3, 0x33, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x3, 0x0, 0x33, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, 0x33, - 0x33, 0x33, 0x30, 0x0, 0x33, 0x33, 0x33, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x3, 0x33, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, - 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x2, - 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x2, - 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x2, - 0x0, 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x0, - 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, 0x20, 0x0, - 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x2, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x10, 0x0, 0x1, 0x0, 0x10, 0x0, 0x10, 0x0, - 0x10, 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, 0x1, - 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, - 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, - 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, 0x1, 0x0, - 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, 0x10, 0x0, - 0x1, 0x0, 0x0, 0x10, 0x0, 0x1, 0x0, 0x10, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, - 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x0, 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, - 0x0, 0x3, 0x30, 0x3, 0x0, 0x30, 0x0, 0x30, - 0x0, 0x30, 0x0, 0x3, 0x30, 0x0, 0x30, 0x30, - 0x0, 0x33, 0x0, 0x0, 0x33, 0x0, 0x0, 0x33, - 0x0, 0x0, 0x33, 0x0, 0x0, 0x33, 0x0, 0x0, - 0x0, 0x0, 0x33, 0x30, 0x0, 0x3, 0x30, 0x0, - 0x33, 0x0, 0x3, 0x30, 0x0, 0x33, 0x0, 0x3, - 0x0, 0x3, 0x30, 0x0, 0x3, 0x0, 0x3, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x30, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, - 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x30, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, - 0x30, 0x0, 0x33, 0x3, 0x0, 0x30, 0x30, 0x3, - 0x3, 0x0, 0x30, 0x30, 0x3, 0x3, 0x0, 0x30, - 0x30, 0x3, 0x3, 0x0, 0x30, 0x30, 0x3, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x3, - 0x0, 0x30, 0x30, 0x3, 0x0, 0x30, 0x0, 0x30, - 0x0, 0x30, 0x0, 0x3, 0x30, 0x0, 0x30, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x33, 0x0, 0x30, 0x33, 0x0, 0x30, 0x30, 0x3, - 0x3, 0x0, 0x30, 0x30, 0x3, 0x3, 0x0, 0x30, - 0x30, 0x3, 0x3, 0x0, 0x30, 0x30, 0x3, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, - 0x0, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, - 0x0, 0x30, 0x0, 0x0, 0x30, 0x0, 0x33, 0x0, - 0x0, 0x33, 0x0, 0x0, 0x33, 0x0, 0x0, 0x33, - 0x0, 0x0, 0x33, 0x0, 0x0, 0x33, 0x0, 0x0, - 0x30, 0x0, 0x3, 0x33, 0x0, 0x30, 0x30, 0x3, - 0x3, 0x0, 0x30, 0x30, 0x3, 0x3, 0x0, 0x30, - 0x30, 0x3, 0x30, 0x0, 0x30, 0x30, 0x3, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x3, 0x30, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x3, - 0x0, 0x30, 0x30, 0x3, 0x0, 0x30, 0x3, 0x3, - 0x3, 0x3, 0x0, 0x0, 0x0, 0x0, 0x33, 0x0, - 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x30, - 0x30, 0x0, 0x33, 0x0, 0x3, 0x0, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, - 0x30, 0x0, 0x30, 0x30, 0x3, 0x3, 0x0, 0x3, - 0x0, 0x0, 0x0, 0x0, 0x30, 0x30, 0x3, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, - 0x0, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, 0x30, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x30, - 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, - 0x0, 0x0, 0x3, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, - 0x3, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, - 0x2, 0x0, 0x0, 0x20, 0x2, 0x0, 0x2, 0x0, - 0x2, 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, - 0x20, 0x0, 0x0, 0x20, 0x0, 0x0, 0x20, 0x0, - 0x0, 0x20, 0x0, 0x0, 0x20, 0x0, 0x0, 0x20, - 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, 0x20, - 0x0, 0x2, 0x0, 0x0, 0x20, 0x0, 0x2, 0x0, - 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x20, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x10, - 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x10, 0x0, - 0x0, 0x1, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, - 0x1, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x10, - 0x0, 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, 0x10, - 0x0, 0x1, 0x0, 0x0, 0x10, 0x0, 0x1, 0x0, - 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x10, - 0x0, 0x1, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, - 0x30, 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, 0x0, - 0x33, 0x33, 0x0, 0x0, 0x33, 0x30, 0x0, 0x3, - 0x33, 0x0, 0x0, 0x33, 0x30, 0x0, 0x3, 0x33, - 0x0, 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, - 0x30, 0x30, 0x0, 0x3, 0x30, 0x0, 0x33, 0x0, - 0x3, 0x30, 0x0, 0x33, 0x0, 0x3, 0x30, 0x0, - 0x33, 0x0, 0x33, 0x33, 0x30, 0x0, 0x33, 0x0, - 0x3, 0x30, 0x0, 0x33, 0x0, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x3, 0x0, - 0x33, 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, - 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, - 0x30, 0x0, 0x3, 0x0, 0x0, 0x33, 0x30, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x30, 0x3, 0x3, 0x0, - 0x30, 0x30, 0x3, 0x3, 0x0, 0x30, 0x30, 0x3, - 0x3, 0x0, 0x30, 0x33, 0x0, 0x3, 0x0, 0x0, - 0x30, 0x0, 0x3, 0x0, 0x0, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, 0x0, - 0x30, 0x30, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, - 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, - 0x30, 0x0, 0x3, 0x0, 0x0, 0x30, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x0, 0x30, 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, - 0x3, 0x0, 0x0, 0x30, 0x30, 0x3, 0x0, 0x0, - 0x30, 0x30, 0x3, 0x3, 0x0, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x3, 0x0, - 0x30, 0x30, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, - 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, - 0x30, 0x0, 0x3, 0x0, 0x0, 0x30, 0x3, 0x0, - 0x33, 0x30, 0x0, 0x33, 0x0, 0x3, 0x30, 0x0, - 0x33, 0x0, 0x3, 0x30, 0x0, 0x33, 0x0, 0x3, - 0x30, 0x0, 0x33, 0x3, 0x30, 0x0, 0x33, 0x0, - 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, - 0x30, 0x3, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, - 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, - 0x30, 0x0, 0x30, 0x30, 0x0, 0x33, 0x30, 0x0, - 0x30, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, - 0x30, 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, 0x0, - 0x3, 0x33, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, - 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, - 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, 0x0, - 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, - 0x30, 0x30, 0x3, 0x30, 0x0, 0x30, 0x30, 0x3, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x30, 0x30, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x0, 0x33, 0x0, 0x0, 0x0, 0x3, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, 0x20, 0x3, - 0x3, 0x2, 0x3, 0x3, 0x0, 0x20, 0x0, 0x2, - 0x0, 0x0, 0x0, 0x20, 0x30, 0x0, 0x2, 0x0, - 0x3, 0x0, 0x20, 0x3, 0x0, 0x2, 0x3, 0x3, - 0x0, 0x20, 0x0, 0x30, 0x2, 0x0, 0x0, 0x2, - 0x0, 0x0, 0x2, 0x0, 0x0, 0x20, 0x0, 0x2, - 0x0, 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x20, - 0x0, 0x2, 0x0, 0x0, 0x0, 0x20, 0x0, 0x2, - 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, - 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x10, - 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, - 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, - 0x0, 0x0, 0x1, 0x0, 0x10, 0x0, 0x10, 0x0, - 0x10, 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, - 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, - 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, - 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, - 0x30, 0x3, 0x33, 0x30, 0x0, 0x33, 0x0, 0x3, - 0x33, 0x30, 0x3, 0x33, 0x30, 0x3, 0x33, 0x30, - 0x3, 0x33, 0x30, 0x3, 0x0, 0x30, 0x0, 0x30, - 0x0, 0x30, 0x0, 0x33, 0x33, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x3, 0x33, 0x0, 0x0, 0x33, 0x30, - 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, 0x3, 0x33, - 0x33, 0x0, 0x33, 0x33, 0x30, 0x3, 0x33, 0x33, - 0x0, 0x33, 0x33, 0x30, 0x3, 0x33, 0x33, 0x0, - 0x33, 0x33, 0x0, 0x0, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, - 0x3, 0x0, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, - 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, - 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, - 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, - 0x30, 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, - 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, 0x0, - 0x3, 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, - 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, - 0x3, 0x0, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, - 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, - 0x33, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, - 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, - 0x30, 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, - 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, 0x0, - 0x0, 0x33, 0x33, 0x30, 0x3, 0x0, 0x0, 0x3, - 0x33, 0x30, 0x3, 0x33, 0x30, 0x3, 0x33, 0x30, - 0x3, 0x33, 0x30, 0x3, 0x0, 0x30, 0x0, 0x30, - 0x0, 0x30, 0x3, 0x33, 0x0, 0x30, 0x3, 0x3, - 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, - 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x3, - 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, 0x0, - 0x0, 0x33, 0x0, 0x0, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, - 0x3, 0x0, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, - 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, 0x3, 0x30, - 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, - 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x3, - 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, 0x0, - 0x0, 0x3, 0x33, 0x30, 0x0, 0x33, 0x0, 0x3, - 0x33, 0x30, 0x3, 0x33, 0x30, 0x3, 0x33, 0x30, - 0x3, 0x33, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x33, 0x33, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x3, 0x33, 0x0, 0x0, 0x33, 0x30, - 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x0, 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x30, 0x30, - 0x0, 0x0, 0x0, 0x3, 0x0, 0x30, 0x3, 0x3, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, - 0x30, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x3, 0x3, 0x0, 0x0, 0x0, 0x20, 0x0, - 0x30, 0x2, 0x0, 0x30, 0x0, 0x20, 0x3, 0x3, - 0x2, 0x3, 0x3, 0x0, 0x20, 0x3, 0x0, 0x2, - 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x20, - 0x30, 0x0, 0x20, 0x3, 0x0, 0x20, 0x3, 0x0, - 0x23, 0x0, 0x30, 0x20, 0x2, 0x3, 0x2, 0x30, - 0x2, 0x3, 0x2, 0x0, 0x0, 0x0, 0x20, 0x3, - 0x3, 0x2, 0x3, 0x0, 0x0, 0x20, 0x0, 0x30, - 0x2, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x10, 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x1, - 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x10, - 0x0, 0x0, 0x1, 0x0, 0x0, 0x10, 0x1, 0x0, - 0x0, 0x10, 0x1, 0x0, 0x10, 0x1, 0x0, 0x0, - 0x1, 0x0, 0x0, 0x10, 0x1, 0x0, 0x1, 0x0, - 0x10, 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, 0x0, - 0x1, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x1, - 0x0, 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x0, 0x33, 0x0, 0x0, 0x0, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x3, 0x3, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x30, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x30, - 0x30, 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x30, 0x30, 0x0, 0x30, 0x0, - 0x30, 0x3, 0x0, 0x33, 0x0, 0x30, 0x0, 0x30, - 0x3, 0x0, 0x0, 0x30, 0x0, 0x30, 0x0, 0x33, - 0x0, 0x0, 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, - 0x3, 0x3, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, - 0x3, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x3, - 0x0, 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x3, 0x3, 0x0, 0x3, 0x3, - 0x30, 0x0, 0x30, 0x33, 0x0, 0x3, 0x3, 0x30, - 0x0, 0x30, 0x0, 0x33, 0x33, 0x30, 0x3, 0x3, - 0x0, 0x0, 0x0, 0x30, 0x0, 0x30, 0x3, 0x30, - 0x0, 0x30, 0x30, 0x3, 0x33, 0x30, 0x3, 0x0, - 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x3, - 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x33, 0x0, 0x30, 0x30, 0x0, 0x0, 0x30, - 0x30, 0x0, 0x3, 0x0, 0x0, 0x0, 0x30, 0x30, - 0x0, 0x30, 0x0, 0x3, 0x3, 0x0, 0x3, 0x30, - 0x0, 0x0, 0x0, 0x30, 0x30, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x30, 0x30, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x30, 0x3, 0x0, 0x0, 0x3, 0x3, - 0x0, 0x3, 0x33, 0x0, 0x30, 0x0, 0x0, 0x3, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x0, 0x0, 0x3, 0x3, 0x0, 0x3, 0x3, - 0x0, 0x0, 0x0, 0x30, 0x0, 0x30, 0x3, 0x30, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x30, 0x3, 0x3, 0x0, 0x0, 0x0, - 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, - 0x30, 0x0, 0x30, 0x3, 0x0, 0x33, 0x0, 0x30, - 0x0, 0x30, 0x0, 0x0, 0x30, 0x0, 0x0, 0x30, - 0x3, 0x3, 0x0, 0x3, 0x33, 0x0, 0x0, 0x30, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x3, 0x33, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, - 0x0, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x0, 0x30, 0x0, 0x0, 0x33, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x33, 0x33, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x20, 0x0, - 0x2, 0x0, 0x2, 0x0, 0x0, 0x0, 0x20, 0x0, - 0x20, 0x0, 0x0, 0x20, 0x0, 0x0, 0x20, 0x2, - 0x0, 0x0, 0x0, 0x20, 0x0, 0x2, 0x0, 0x20, - 0x0, 0x2, 0x0, 0x20, 0x2, 0x0, 0x20, 0x0, - 0x0, 0x20, 0x0, 0x2, 0x0, 0x20, 0x0, 0x20, - 0x2, 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, - 0x0, 0x20, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, - 0x20, 0x0, 0x2, 0x3, 0x0, 0x0, 0x0, 0x10, - 0x1, 0x0, 0x10, 0x1, 0x0, 0x10, 0x1, 0x0, - 0x10, 0x1, 0x0, 0x10, 0x1, 0x0, 0x10, 0x1, - 0x0, 0x10, 0x1, 0x0, 0x10, 0x1, 0x0, 0x10, - 0x1, 0x0, 0x10, 0x1, 0x0, 0x10, 0x1, 0x0, - 0x10, 0x1, 0x0, 0x10, 0x1, 0x0, 0x10, 0x1, - 0x0, 0x10, 0x1, 0x0, 0x10, 0x1, 0x0, 0x10, - 0x1, 0x0, 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, - 0x1, 0x0, 0x0, 0x10, 0x1, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, 0x0, - 0x30, 0x0, 0x33, 0x0, 0x3, 0x33, 0x0, 0x0, - 0x0, 0x0, 0x30, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, 0x0, - 0x30, 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, - 0x0, 0x3, 0x33, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, 0x0, - 0x30, 0x3, 0x0, 0x0, 0x33, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x33, 0x0, 0x3, 0x0, 0x0, 0x30, - 0x30, 0x3, 0x33, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, 0x0, - 0x30, 0x0, 0x3, 0x0, 0x3, 0x3, 0x0, 0x3, - 0x0, 0x0, 0x30, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x30, - 0x30, 0x3, 0x3, 0x0, 0x30, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x2, - 0x0, 0x20, 0x2, 0x0, 0x20, 0x2, 0x0, 0x20, - 0x2, 0x0, 0x20, 0x2, 0x0, 0x20, 0x2, 0x0, - 0x20, 0x2, 0x0, 0x20, 0x2, 0x0, 0x20, 0x2, - 0x0, 0x20, 0x2, 0x0, 0x20, 0x2, 0x0, 0x20, - 0x2, 0x0, 0x20, 0x2, 0x0, 0x20, 0x2, 0x0, - 0x20, 0x2, 0x0, 0x20, 0x2, 0x0, 0x20, 0x2, - 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, - 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, - 0x10, 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, 0x1, - 0x0, 0x10, 0x1, 0x0, 0x0, 0x10, 0x1, 0x0, - 0x0, 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, 0x1, - 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, - 0x0, 0x0, 0x10, 0x0, 0x10, 0x0, 0x1, 0x0, - 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x10, - 0x0, 0x1, 0x0, 0x0, 0x10, 0x0, 0x10, 0x1, - 0x0, 0x1, 0x0, 0x0, 0x10, 0x1, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x3, 0x30, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x3, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x3, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x3, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, - 0x0, 0x30, 0x0, 0x3, 0x33, 0x0, 0x30, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x3, 0x0, 0x30, 0x3, - 0x3, 0x3, 0x0, 0x30, 0x30, 0x0, 0x33, 0x0, - 0x3, 0x33, 0x0, 0x0, 0x33, 0x30, 0x3, 0x0, - 0x3, 0x30, 0x0, 0x3, 0x0, 0x3, 0x30, 0x0, - 0x30, 0x0, 0x3, 0x3, 0x0, 0x3, 0x3, 0x0, - 0x3, 0x0, 0x3, 0x33, 0x0, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x0, 0x0, 0x0, 0x30, 0x3, 0x0, - 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x30, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x3, 0x0, 0x30, 0x3, - 0x3, 0x3, 0x0, 0x30, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, - 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, 0x30, 0x0, - 0x30, 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x0, - 0x30, 0x30, 0x3, 0x0, 0x0, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x0, 0x0, 0x0, 0x30, 0x3, 0x3, - 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x30, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x30, 0x0, 0x30, 0x3, - 0x3, 0x3, 0x0, 0x30, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, - 0x3, 0x0, 0x0, 0x30, 0x0, 0x30, 0x30, 0x3, - 0x3, 0x0, 0x30, 0x30, 0x30, 0x0, 0x30, 0x0, - 0x30, 0x30, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, - 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x30, - 0x0, 0x33, 0x0, 0x3, 0x33, 0x0, 0x33, 0x0, - 0x3, 0x0, 0x30, 0x3, 0x3, 0x0, 0x30, 0x3, - 0x33, 0x30, 0x0, 0x33, 0x0, 0x0, 0x33, 0x0, - 0x3, 0x33, 0x0, 0x0, 0x33, 0x30, 0x3, 0x30, - 0x0, 0x33, 0x0, 0x33, 0x0, 0x30, 0x30, 0x3, - 0x3, 0x0, 0x30, 0x30, 0x30, 0x3, 0x3, 0x0, - 0x30, 0x30, 0x3, 0x33, 0x0, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, - 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x30, 0x0, 0x30, 0x0, 0x0, - 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x0, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x3, 0x3, 0x0, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, - 0x2, 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, - 0x20, 0x2, 0x0, 0x20, 0x0, 0x2, 0x0, 0x20, - 0x0, 0x0, 0x2, 0x0, 0x0, 0x20, 0x0, 0x0, - 0x20, 0x0, 0x0, 0x20, 0x0, 0x0, 0x20, 0x0, - 0x20, 0x0, 0x2, 0x0, 0x2, 0x0, 0x0, 0x20, - 0x0, 0x2, 0x0, 0x0, 0x0, 0x20, 0x0, 0x2, - 0x0, 0x0, 0x20, 0x0, 0x2, 0x0, 0x2, 0x0, - 0x20, 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x0, - 0x1, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x1, - 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, - 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, - 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, - 0x10, 0x0, 0x0, 0x10, 0x0, 0x10, 0x0, 0x10, - 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, - 0x1, 0x0, 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, - 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x33, 0x0, 0x0, 0x0, - 0x33, 0x0, 0x0, 0x0, 0x33, 0x33, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x0, 0x33, 0x3, 0x0, 0x30, 0x0, 0x30, - 0x0, 0x33, 0x0, 0x0, 0x30, 0x0, 0x0, 0x33, - 0x30, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x3, - 0x0, 0x0, 0x30, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x0, 0x33, 0x33, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x33, 0x0, 0x33, 0x30, 0x0, 0x3, - 0x30, 0x0, 0x33, 0x30, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x3, - 0x0, 0x0, 0x3, 0x3, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x30, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x3, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x0, 0x3, 0x0, 0x30, 0x0, 0x0, 0x3, 0x33, - 0x0, 0x3, 0x3, 0x3, 0x0, 0x33, 0x33, 0x0, - 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, - 0x30, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x0, 0x3, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, - 0x0, 0x30, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, - 0x30, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, 0x0, - 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x3, 0x30, 0x0, 0x33, 0x30, 0x0, 0x3, - 0x30, 0x0, 0x33, 0x30, 0x0, 0x0, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x3, 0x0, - 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x0, - 0x3, 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, - 0x0, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, - 0x3, 0x0, 0x30, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x33, - 0x0, 0x0, 0x33, 0x30, 0x0, 0x33, 0x33, 0x0, - 0x0, 0x33, 0x0, 0x33, 0x33, 0x30, 0x3, 0x0, - 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x0, - 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, - 0x0, 0x33, 0x33, 0x0, 0x33, 0x0, 0x30, 0x0, - 0x33, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, - 0x0, 0x20, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, - 0x20, 0x0, 0x0, 0x20, 0x0, 0x0, 0x20, 0x0, - 0x0, 0x2, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, - 0x0, 0x2, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, - 0x2, 0x0, 0x0, 0x2, 0x0, 0x2, 0x0, 0x2, - 0x0, 0x2, 0x0, 0x0, 0x20, 0x0, 0x0, 0x20, - 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, - 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, - 0x0, 0x1, 0x0, 0x0, 0x10, 0x0, 0x1, 0x0, - 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, - 0x0, 0x1, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, - 0x1, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x10, - 0x0, 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, - 0x1, 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, 0x1, - 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x1, 0x0, - 0x0, 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, - 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, - 0x0, 0x30, 0x3, 0x33, 0x30, 0x0, 0x3, 0x33, - 0x0, 0x3, 0x33, 0x30, 0x0, 0x33, 0x33, 0x0, - 0x30, 0x0, 0x0, 0x3, 0x33, 0x30, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x33, 0x0, 0x3, 0x0, 0x30, - 0x3, 0x33, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x33, 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, - 0x3, 0x0, 0x3, 0x33, 0x0, 0x3, 0x0, 0x0, - 0x0, 0x0, 0x3, 0x0, 0x33, 0x30, 0x0, 0x30, - 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, - 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x30, 0x3, 0x3, 0x0, - 0x3, 0x0, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, - 0x0, 0x33, 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, - 0x30, 0x0, 0x3, 0x3, 0x3, 0x3, 0x0, 0x3, - 0x33, 0x0, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, - 0x0, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x30, 0x3, 0x30, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x0, 0x30, 0x3, 0x30, 0x0, - 0x3, 0x0, 0x0, 0x30, 0x30, 0x30, 0x30, 0x3, - 0x3, 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, - 0x3, 0x0, 0x3, 0x33, 0x0, 0x3, 0x0, 0x0, - 0x3, 0x0, 0x3, 0x0, 0x30, 0x3, 0x0, 0x3, - 0x3, 0x0, 0x3, 0x33, 0x30, 0x0, 0x30, 0x0, - 0x0, 0x3, 0x0, 0x3, 0x0, 0x33, 0x30, 0x0, - 0x33, 0x30, 0x0, 0x30, 0x0, 0x0, 0x3, 0x33, - 0x30, 0x3, 0x0, 0x0, 0x30, 0x3, 0x30, 0x0, - 0x3, 0x0, 0x0, 0x30, 0x30, 0x30, 0x30, 0x3, - 0x3, 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, - 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x3, - 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, - 0x30, 0x0, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, - 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x0, 0x30, 0x3, 0x3, 0x0, - 0x3, 0x0, 0x0, 0x33, 0x0, 0x3, 0x30, 0x3, - 0x30, 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x33, 0x0, 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x3, 0x33, 0x30, 0x0, 0x3, 0x33, - 0x0, 0x3, 0x33, 0x30, 0x0, 0x33, 0x33, 0x0, - 0x33, 0x33, 0x0, 0x3, 0x33, 0x0, 0x3, 0x0, - 0x30, 0x3, 0x0, 0x0, 0x30, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x0, 0x33, 0x0, 0x3, 0x30, 0x3, - 0x30, 0x3, 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x2, - 0x0, 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x20, - 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x2, 0x0, - 0x0, 0x0, 0x20, 0x0, 0x0, 0x2, 0x0, 0x0, - 0x0, 0x20, 0x0, 0x0, 0x2, 0x0, 0x0, 0x2, - 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x20, 0x0, - 0x0, 0x20, 0x2, 0x0, 0x0, 0x20, 0x0, 0x0, - 0x20, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x20, - 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x10, - 0x1, 0x0, 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, - 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, 0x0, 0x10, - 0x1, 0x0, 0x1, 0x0, 0x1, 0x0, 0x1, 0x0, - 0x0, 0x10, 0x1, 0x0, 0x1, 0x0, 0x10, 0x0, - 0x10, 0x0, 0x0, 0x10, 0x0, 0x10, 0x0, 0x0, - 0x10, 0x0, 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, - 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x10, 0x0, - 0x0, 0x10, 0x0, 0x0, 0x10, 0x1, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x30, 0x3, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x0, 0x3, 0x3, 0x0, 0x3, - 0x33, 0x0, 0x0, 0x33, 0x0, 0x3, 0x3, 0x0, - 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, 0x30, - 0x0, 0x3, 0x30, 0x0, 0x3, 0x0, 0x33, 0x33, - 0x0, 0x3, 0x30, 0x0, 0x0, 0x30, 0x0, 0x33, - 0x0, 0x0, 0x33, 0x0, 0x0, 0x30, 0x0, 0x3, - 0x30, 0x0, 0x3, 0x30, 0x0, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x33, 0x33, 0x30, 0x0, - 0x33, 0x0, 0x30, 0x33, 0x0, 0x30, 0x30, 0x0, - 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, - 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, - 0x0, 0x30, 0x3, 0x0, 0x33, 0x33, 0x0, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x0, 0x3, 0x3, 0x0, 0x0, - 0x30, 0x0, 0x3, 0x0, 0x0, 0x30, 0x33, 0x0, - 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, - 0x33, 0x0, 0x0, 0x3, 0x30, 0x0, 0x0, 0x30, - 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x3, 0x30, - 0x0, 0x0, 0x3, 0x0, 0x30, 0x30, 0x0, 0x0, - 0x30, 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, - 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x0, 0x3, 0x3, 0x0, 0x3, - 0x30, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, 0x0, - 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x0, 0x3, - 0x0, 0x0, 0x30, 0x0, 0x3, 0x30, 0x0, 0x33, - 0x0, 0x3, 0x33, 0x0, 0x0, 0x30, 0x0, 0x3, - 0x30, 0x0, 0x3, 0x33, 0x0, 0x30, 0x0, 0x0, - 0x30, 0x3, 0x3, 0x0, 0x33, 0x33, 0x30, 0x3, - 0x33, 0x0, 0x33, 0x3, 0x0, 0x30, 0x30, 0x0, - 0x30, 0x3, 0x0, 0x0, 0x30, 0x3, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x33, 0x0, 0x30, 0x3, - 0x0, 0x30, 0x3, 0x0, 0x3, 0x30, 0x0, 0x30, - 0x0, 0x3, 0x0, 0x0, 0x0, 0x3, 0x0, 0x30, - 0x3, 0x0, 0x30, 0x3, 0x0, 0x0, 0x0, 0x0, - 0x30, 0x3, 0x3, 0x0, 0x3, 0x3, 0x0, 0x0, - 0x30, 0x0, 0x33, 0x0, 0x0, 0x3, 0x0, 0x0, - 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x0, 0x3, 0x30, 0x0, 0x3, 0x0, 0x3, 0x30, - 0x0, 0x3, 0x30, 0x0, 0x0, 0x30, 0x0, 0x33, - 0x30, 0x0, 0x33, 0x0, 0x3, 0x33, 0x0, 0x3, - 0x30, 0x0, 0x3, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x2, - 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x0, 0x20, - 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, 0x2, - 0x0, 0x20, 0x0, 0x20, 0x0, 0x20, 0x0, 0x20, - 0x0, 0x2, 0x0, 0x20, 0x0, 0x20, 0x2, 0x0, - 0x2, 0x0, 0x0, 0x2, 0x0, 0x2, 0x0, 0x0, - 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, - 0x0, 0x20, 0x0, 0x0, 0x20, 0x0, 0x2, 0x0, - 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0 -}; - - u32 BuiltInFontDataSize = sizeof(BuiltInFontData); -} // end namespace gui -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __BUILD_IN_FONT_H_INCLUDED__ +#define __BUILD_IN_FONT_H_INCLUDED__ + +// headerfile generated by Bin2H, copyright 2002 by N.Gebhardt. +// Bin2H is Freeware. Download it freely from www.code3d.com. + +namespace irr +{ +namespace gui +{ + +u8 BuiltInFontData[] = +{ + 0x42, 0x4d, 0x76, 0x20, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x76, 0x0, 0x0, 0x0, 0x28, 0x0, + 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x80, 0x0, + 0x0, 0x0, 0x1, 0x0, 0x4, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x63, 0xb, + 0x0, 0x0, 0x63, 0xb, 0x0, 0x0, 0x10, 0x0, + 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0xff, 0x0, 0x0, 0xff, + 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff, + 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff, + 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff, + 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff, + 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff, + 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff, + 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x10, + 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x10, + 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, + 0x0, 0x1, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, + 0x10, 0x0, 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, + 0x10, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, + 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, 0x33, + 0x33, 0x33, 0x30, 0x33, 0x33, 0x33, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x33, 0x33, 0x33, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x3, 0x33, 0x33, 0x33, 0x3, + 0x33, 0x33, 0x33, 0x30, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, + 0x0, 0x0, 0x30, 0x30, 0x0, 0x3, 0x0, 0x3, + 0x30, 0x0, 0x3, 0x30, 0x33, 0x33, 0x33, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x30, 0x30, 0x0, 0x0, 0x3, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, 0x3, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, + 0x0, 0x0, 0x30, 0x30, 0x0, 0x3, 0x0, 0x0, + 0x33, 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, + 0x3, 0x30, 0x33, 0x0, 0x0, 0x33, 0x30, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, 0x3, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, + 0x0, 0x0, 0x30, 0x30, 0x0, 0x3, 0x33, 0x0, + 0x3, 0x33, 0x30, 0x0, 0x0, 0x0, 0x0, 0x3, + 0x33, 0x33, 0x33, 0x0, 0x3, 0x33, 0x0, 0x0, + 0x33, 0x30, 0x33, 0x30, 0x3, 0x33, 0x33, 0x0, + 0x3, 0x33, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x3, 0x30, 0x3, 0x0, 0x0, 0x3, 0x3, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, + 0x0, 0x0, 0x30, 0x33, 0x33, 0x33, 0x3, 0x0, + 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x33, 0x33, 0x30, 0x0, 0x33, 0x33, 0x30, 0x3, + 0x33, 0x30, 0x33, 0x33, 0x3, 0x30, 0x33, 0x30, + 0x0, 0x0, 0x0, 0x0, 0x33, 0x30, 0x0, 0x30, + 0x0, 0x33, 0x33, 0x3, 0x0, 0x0, 0x3, 0x3, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, + 0x0, 0x0, 0x30, 0x33, 0x33, 0x33, 0x3, 0x0, + 0x3, 0x33, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x3, 0x33, 0x0, 0x3, 0x33, 0x33, 0x33, 0x0, + 0x33, 0x30, 0x33, 0x30, 0x3, 0x0, 0x3, 0x33, + 0x0, 0x3, 0x0, 0x0, 0x3, 0x0, 0x3, 0x33, + 0x0, 0x33, 0x33, 0x3, 0x0, 0x33, 0x33, 0x3, + 0x33, 0x33, 0x33, 0x30, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, + 0x0, 0x0, 0x30, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x33, 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x3, 0x30, 0x33, 0x0, 0x0, 0x0, 0x0, 0x33, + 0x0, 0x33, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x3, 0x30, 0x3, 0x0, 0x30, 0x30, 0x0, + 0x33, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, 0x33, + 0x33, 0x33, 0x30, 0x0, 0x33, 0x33, 0x33, 0x3, + 0x30, 0x0, 0x3, 0x30, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x30, 0x30, 0x0, 0x0, 0x0, 0x0, 0x3, + 0x3, 0x33, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x3, 0x0, 0x33, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, 0x33, + 0x33, 0x33, 0x30, 0x0, 0x33, 0x33, 0x33, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x3, 0x33, 0x30, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, + 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x2, + 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x2, + 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x2, + 0x0, 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x0, + 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, 0x20, 0x0, + 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x2, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x10, 0x0, 0x1, 0x0, 0x10, 0x0, 0x10, 0x0, + 0x10, 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, 0x1, + 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, + 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, + 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, 0x1, 0x0, + 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, 0x10, 0x0, + 0x1, 0x0, 0x0, 0x10, 0x0, 0x1, 0x0, 0x10, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, + 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, + 0x0, 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, + 0x0, 0x3, 0x30, 0x3, 0x0, 0x30, 0x0, 0x30, + 0x0, 0x30, 0x0, 0x3, 0x30, 0x0, 0x30, 0x30, + 0x0, 0x33, 0x0, 0x0, 0x33, 0x0, 0x0, 0x33, + 0x0, 0x0, 0x33, 0x0, 0x0, 0x33, 0x0, 0x0, + 0x0, 0x0, 0x33, 0x30, 0x0, 0x3, 0x30, 0x0, + 0x33, 0x0, 0x3, 0x30, 0x0, 0x33, 0x0, 0x3, + 0x0, 0x3, 0x30, 0x0, 0x3, 0x0, 0x3, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x30, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, + 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x30, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, + 0x30, 0x0, 0x33, 0x3, 0x0, 0x30, 0x30, 0x3, + 0x3, 0x0, 0x30, 0x30, 0x3, 0x3, 0x0, 0x30, + 0x30, 0x3, 0x3, 0x0, 0x30, 0x30, 0x3, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x3, + 0x0, 0x30, 0x30, 0x3, 0x0, 0x30, 0x0, 0x30, + 0x0, 0x30, 0x0, 0x3, 0x30, 0x0, 0x30, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x33, 0x0, 0x30, 0x33, 0x0, 0x30, 0x30, 0x3, + 0x3, 0x0, 0x30, 0x30, 0x3, 0x3, 0x0, 0x30, + 0x30, 0x3, 0x3, 0x0, 0x30, 0x30, 0x3, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, + 0x0, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, + 0x0, 0x30, 0x0, 0x0, 0x30, 0x0, 0x33, 0x0, + 0x0, 0x33, 0x0, 0x0, 0x33, 0x0, 0x0, 0x33, + 0x0, 0x0, 0x33, 0x0, 0x0, 0x33, 0x0, 0x0, + 0x30, 0x0, 0x3, 0x33, 0x0, 0x30, 0x30, 0x3, + 0x3, 0x0, 0x30, 0x30, 0x3, 0x3, 0x0, 0x30, + 0x30, 0x3, 0x30, 0x0, 0x30, 0x30, 0x3, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x3, 0x30, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x3, + 0x0, 0x30, 0x30, 0x3, 0x0, 0x30, 0x3, 0x3, + 0x3, 0x3, 0x0, 0x0, 0x0, 0x0, 0x33, 0x0, + 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x30, + 0x30, 0x0, 0x33, 0x0, 0x3, 0x0, 0x30, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, + 0x30, 0x0, 0x30, 0x30, 0x3, 0x3, 0x0, 0x3, + 0x0, 0x0, 0x0, 0x0, 0x30, 0x30, 0x3, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, 0x30, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x30, + 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, + 0x0, 0x0, 0x3, 0x30, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, + 0x3, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, + 0x2, 0x0, 0x0, 0x20, 0x2, 0x0, 0x2, 0x0, + 0x2, 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, + 0x20, 0x0, 0x0, 0x20, 0x0, 0x0, 0x20, 0x0, + 0x0, 0x20, 0x0, 0x0, 0x20, 0x0, 0x0, 0x20, + 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, 0x20, + 0x0, 0x2, 0x0, 0x0, 0x20, 0x0, 0x2, 0x0, + 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x20, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x10, + 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x10, 0x0, + 0x0, 0x1, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, + 0x1, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x10, + 0x0, 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, 0x10, + 0x0, 0x1, 0x0, 0x0, 0x10, 0x0, 0x1, 0x0, + 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x10, + 0x0, 0x1, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, + 0x30, 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, 0x0, + 0x33, 0x33, 0x0, 0x0, 0x33, 0x30, 0x0, 0x3, + 0x33, 0x0, 0x0, 0x33, 0x30, 0x0, 0x3, 0x33, + 0x0, 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, + 0x30, 0x30, 0x0, 0x3, 0x30, 0x0, 0x33, 0x0, + 0x3, 0x30, 0x0, 0x33, 0x0, 0x3, 0x30, 0x0, + 0x33, 0x0, 0x33, 0x33, 0x30, 0x0, 0x33, 0x0, + 0x3, 0x30, 0x0, 0x33, 0x0, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x3, 0x0, + 0x33, 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, + 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, + 0x30, 0x0, 0x3, 0x0, 0x0, 0x33, 0x30, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x30, 0x3, 0x3, 0x0, + 0x30, 0x30, 0x3, 0x3, 0x0, 0x30, 0x30, 0x3, + 0x3, 0x0, 0x30, 0x33, 0x0, 0x3, 0x0, 0x0, + 0x30, 0x0, 0x3, 0x0, 0x0, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, 0x0, + 0x30, 0x30, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, + 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, + 0x30, 0x0, 0x3, 0x0, 0x0, 0x30, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x0, 0x30, 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, + 0x3, 0x0, 0x0, 0x30, 0x30, 0x3, 0x0, 0x0, + 0x30, 0x30, 0x3, 0x3, 0x0, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x3, 0x0, + 0x30, 0x30, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, + 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, + 0x30, 0x0, 0x3, 0x0, 0x0, 0x30, 0x3, 0x0, + 0x33, 0x30, 0x0, 0x33, 0x0, 0x3, 0x30, 0x0, + 0x33, 0x0, 0x3, 0x30, 0x0, 0x33, 0x0, 0x3, + 0x30, 0x0, 0x33, 0x3, 0x30, 0x0, 0x33, 0x0, + 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, + 0x30, 0x3, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, + 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, + 0x30, 0x0, 0x30, 0x30, 0x0, 0x33, 0x30, 0x0, + 0x30, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, + 0x30, 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, 0x0, + 0x3, 0x33, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, + 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, + 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, 0x0, + 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, + 0x30, 0x30, 0x3, 0x30, 0x0, 0x30, 0x30, 0x3, + 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, + 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x30, 0x30, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x0, 0x33, 0x0, 0x0, 0x0, 0x3, + 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, 0x20, 0x3, + 0x3, 0x2, 0x3, 0x3, 0x0, 0x20, 0x0, 0x2, + 0x0, 0x0, 0x0, 0x20, 0x30, 0x0, 0x2, 0x0, + 0x3, 0x0, 0x20, 0x3, 0x0, 0x2, 0x3, 0x3, + 0x0, 0x20, 0x0, 0x30, 0x2, 0x0, 0x0, 0x2, + 0x0, 0x0, 0x2, 0x0, 0x0, 0x20, 0x0, 0x2, + 0x0, 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x20, + 0x0, 0x2, 0x0, 0x0, 0x0, 0x20, 0x0, 0x2, + 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, + 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x10, + 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, + 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, + 0x0, 0x0, 0x1, 0x0, 0x10, 0x0, 0x10, 0x0, + 0x10, 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, + 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, + 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, + 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, + 0x30, 0x3, 0x33, 0x30, 0x0, 0x33, 0x0, 0x3, + 0x33, 0x30, 0x3, 0x33, 0x30, 0x3, 0x33, 0x30, + 0x3, 0x33, 0x30, 0x3, 0x0, 0x30, 0x0, 0x30, + 0x0, 0x30, 0x0, 0x33, 0x33, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x3, 0x33, 0x0, 0x0, 0x33, 0x30, + 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, 0x3, 0x33, + 0x33, 0x0, 0x33, 0x33, 0x30, 0x3, 0x33, 0x33, + 0x0, 0x33, 0x33, 0x30, 0x3, 0x33, 0x33, 0x0, + 0x33, 0x33, 0x0, 0x0, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, + 0x3, 0x0, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, + 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, + 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, + 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, + 0x30, 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, + 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, 0x0, + 0x3, 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, + 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, + 0x3, 0x0, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, + 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, + 0x33, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, + 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, + 0x30, 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, + 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, 0x0, + 0x0, 0x33, 0x33, 0x30, 0x3, 0x0, 0x0, 0x3, + 0x33, 0x30, 0x3, 0x33, 0x30, 0x3, 0x33, 0x30, + 0x3, 0x33, 0x30, 0x3, 0x0, 0x30, 0x0, 0x30, + 0x0, 0x30, 0x3, 0x33, 0x0, 0x30, 0x3, 0x3, + 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, + 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x3, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, 0x0, + 0x0, 0x33, 0x0, 0x0, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, + 0x3, 0x0, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, + 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, 0x3, 0x30, + 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, + 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x3, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, 0x0, + 0x0, 0x3, 0x33, 0x30, 0x0, 0x33, 0x0, 0x3, + 0x33, 0x30, 0x3, 0x33, 0x30, 0x3, 0x33, 0x30, + 0x3, 0x33, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x33, 0x33, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x3, 0x33, 0x0, 0x0, 0x33, 0x30, + 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, 0x0, 0x3, + 0x0, 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x30, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x30, 0x30, + 0x0, 0x0, 0x0, 0x3, 0x0, 0x30, 0x3, 0x3, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, + 0x30, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x3, 0x3, 0x0, 0x0, 0x0, 0x20, 0x0, + 0x30, 0x2, 0x0, 0x30, 0x0, 0x20, 0x3, 0x3, + 0x2, 0x3, 0x3, 0x0, 0x20, 0x3, 0x0, 0x2, + 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x20, + 0x30, 0x0, 0x20, 0x3, 0x0, 0x20, 0x3, 0x0, + 0x23, 0x0, 0x30, 0x20, 0x2, 0x3, 0x2, 0x30, + 0x2, 0x3, 0x2, 0x0, 0x0, 0x0, 0x20, 0x3, + 0x3, 0x2, 0x3, 0x0, 0x0, 0x20, 0x0, 0x30, + 0x2, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x10, 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x1, + 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x10, + 0x0, 0x0, 0x1, 0x0, 0x0, 0x10, 0x1, 0x0, + 0x0, 0x10, 0x1, 0x0, 0x10, 0x1, 0x0, 0x0, + 0x1, 0x0, 0x0, 0x10, 0x1, 0x0, 0x1, 0x0, + 0x10, 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, 0x0, + 0x1, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x1, + 0x0, 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x30, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x0, 0x33, 0x0, 0x0, 0x0, 0x30, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x3, 0x3, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x30, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, + 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x30, + 0x30, 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x30, 0x30, 0x0, 0x30, 0x0, + 0x30, 0x3, 0x0, 0x33, 0x0, 0x30, 0x0, 0x30, + 0x3, 0x0, 0x0, 0x30, 0x0, 0x30, 0x0, 0x33, + 0x0, 0x0, 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, + 0x3, 0x3, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, + 0x3, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x3, + 0x0, 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x3, 0x3, 0x0, 0x3, 0x3, + 0x30, 0x0, 0x30, 0x33, 0x0, 0x3, 0x3, 0x30, + 0x0, 0x30, 0x0, 0x33, 0x33, 0x30, 0x3, 0x3, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x30, 0x3, 0x30, + 0x0, 0x30, 0x30, 0x3, 0x33, 0x30, 0x3, 0x0, + 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x3, + 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x3, + 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x33, 0x0, 0x30, 0x30, 0x0, 0x0, 0x30, + 0x30, 0x0, 0x3, 0x0, 0x0, 0x0, 0x30, 0x30, + 0x0, 0x30, 0x0, 0x3, 0x3, 0x0, 0x3, 0x30, + 0x0, 0x0, 0x0, 0x30, 0x30, 0x30, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x30, 0x30, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x30, 0x3, 0x0, 0x0, 0x3, 0x3, + 0x0, 0x3, 0x33, 0x0, 0x30, 0x0, 0x0, 0x3, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x0, 0x0, 0x3, 0x3, 0x0, 0x3, 0x3, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x30, 0x3, 0x30, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x30, 0x3, 0x3, 0x0, 0x0, 0x0, + 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, 0x0, 0x3, + 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, + 0x30, 0x0, 0x30, 0x3, 0x0, 0x33, 0x0, 0x30, + 0x0, 0x30, 0x0, 0x0, 0x30, 0x0, 0x0, 0x30, + 0x3, 0x3, 0x0, 0x3, 0x33, 0x0, 0x0, 0x30, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x3, 0x33, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, + 0x0, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, 0x0, + 0x0, 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x3, + 0x0, 0x33, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x0, 0x30, 0x0, 0x0, 0x33, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x33, 0x33, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x20, 0x0, + 0x2, 0x0, 0x2, 0x0, 0x0, 0x0, 0x20, 0x0, + 0x20, 0x0, 0x0, 0x20, 0x0, 0x0, 0x20, 0x2, + 0x0, 0x0, 0x0, 0x20, 0x0, 0x2, 0x0, 0x20, + 0x0, 0x2, 0x0, 0x20, 0x2, 0x0, 0x20, 0x0, + 0x0, 0x20, 0x0, 0x2, 0x0, 0x20, 0x0, 0x20, + 0x2, 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, + 0x0, 0x20, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, + 0x20, 0x0, 0x2, 0x3, 0x0, 0x0, 0x0, 0x10, + 0x1, 0x0, 0x10, 0x1, 0x0, 0x10, 0x1, 0x0, + 0x10, 0x1, 0x0, 0x10, 0x1, 0x0, 0x10, 0x1, + 0x0, 0x10, 0x1, 0x0, 0x10, 0x1, 0x0, 0x10, + 0x1, 0x0, 0x10, 0x1, 0x0, 0x10, 0x1, 0x0, + 0x10, 0x1, 0x0, 0x10, 0x1, 0x0, 0x10, 0x1, + 0x0, 0x10, 0x1, 0x0, 0x10, 0x1, 0x0, 0x10, + 0x1, 0x0, 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, + 0x1, 0x0, 0x0, 0x10, 0x1, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, 0x0, + 0x30, 0x0, 0x33, 0x0, 0x3, 0x33, 0x0, 0x0, + 0x0, 0x0, 0x30, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, 0x0, + 0x30, 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, + 0x0, 0x3, 0x33, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, 0x0, + 0x30, 0x3, 0x0, 0x0, 0x33, 0x30, 0x0, 0x0, + 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, 0x0, + 0x0, 0x0, 0x33, 0x0, 0x3, 0x0, 0x0, 0x30, + 0x30, 0x3, 0x33, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, 0x0, + 0x30, 0x0, 0x3, 0x0, 0x3, 0x3, 0x0, 0x3, + 0x0, 0x0, 0x30, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x30, + 0x30, 0x3, 0x3, 0x0, 0x30, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x2, + 0x0, 0x20, 0x2, 0x0, 0x20, 0x2, 0x0, 0x20, + 0x2, 0x0, 0x20, 0x2, 0x0, 0x20, 0x2, 0x0, + 0x20, 0x2, 0x0, 0x20, 0x2, 0x0, 0x20, 0x2, + 0x0, 0x20, 0x2, 0x0, 0x20, 0x2, 0x0, 0x20, + 0x2, 0x0, 0x20, 0x2, 0x0, 0x20, 0x2, 0x0, + 0x20, 0x2, 0x0, 0x20, 0x2, 0x0, 0x20, 0x2, + 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, + 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, + 0x10, 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, 0x1, + 0x0, 0x10, 0x1, 0x0, 0x0, 0x10, 0x1, 0x0, + 0x0, 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, 0x1, + 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, + 0x0, 0x0, 0x10, 0x0, 0x10, 0x0, 0x1, 0x0, + 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x10, + 0x0, 0x1, 0x0, 0x0, 0x10, 0x0, 0x10, 0x1, + 0x0, 0x1, 0x0, 0x0, 0x10, 0x1, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x3, 0x30, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x3, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x3, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x3, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33, + 0x0, 0x30, 0x0, 0x3, 0x33, 0x0, 0x30, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x3, 0x0, 0x30, 0x3, + 0x3, 0x3, 0x0, 0x30, 0x30, 0x0, 0x33, 0x0, + 0x3, 0x33, 0x0, 0x0, 0x33, 0x30, 0x3, 0x0, + 0x3, 0x30, 0x0, 0x3, 0x0, 0x3, 0x30, 0x0, + 0x30, 0x0, 0x3, 0x3, 0x0, 0x3, 0x3, 0x0, + 0x3, 0x0, 0x3, 0x33, 0x0, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x0, 0x0, 0x0, 0x30, 0x3, 0x0, + 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x30, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x3, 0x0, 0x30, 0x3, + 0x3, 0x3, 0x0, 0x30, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, + 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, 0x30, 0x0, + 0x30, 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x0, + 0x30, 0x30, 0x3, 0x0, 0x0, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x0, 0x0, 0x0, 0x30, 0x3, 0x3, + 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x30, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x30, 0x0, 0x30, 0x3, + 0x3, 0x3, 0x0, 0x30, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, 0x0, + 0x3, 0x0, 0x0, 0x30, 0x0, 0x30, 0x30, 0x3, + 0x3, 0x0, 0x30, 0x30, 0x30, 0x0, 0x30, 0x0, + 0x30, 0x30, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, + 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x30, + 0x0, 0x33, 0x0, 0x3, 0x33, 0x0, 0x33, 0x0, + 0x3, 0x0, 0x30, 0x3, 0x3, 0x0, 0x30, 0x3, + 0x33, 0x30, 0x0, 0x33, 0x0, 0x0, 0x33, 0x0, + 0x3, 0x33, 0x0, 0x0, 0x33, 0x30, 0x3, 0x30, + 0x0, 0x33, 0x0, 0x33, 0x0, 0x30, 0x30, 0x3, + 0x3, 0x0, 0x30, 0x30, 0x30, 0x3, 0x3, 0x0, + 0x30, 0x30, 0x3, 0x33, 0x0, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, + 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, + 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x30, 0x0, 0x30, 0x0, 0x0, + 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x0, 0x30, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x3, 0x3, 0x0, 0x30, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, + 0x2, 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, + 0x20, 0x2, 0x0, 0x20, 0x0, 0x2, 0x0, 0x20, + 0x0, 0x0, 0x2, 0x0, 0x0, 0x20, 0x0, 0x0, + 0x20, 0x0, 0x0, 0x20, 0x0, 0x0, 0x20, 0x0, + 0x20, 0x0, 0x2, 0x0, 0x2, 0x0, 0x0, 0x20, + 0x0, 0x2, 0x0, 0x0, 0x0, 0x20, 0x0, 0x2, + 0x0, 0x0, 0x20, 0x0, 0x2, 0x0, 0x2, 0x0, + 0x20, 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x0, + 0x1, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x1, + 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, + 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, + 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, + 0x10, 0x0, 0x0, 0x10, 0x0, 0x10, 0x0, 0x10, + 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, + 0x1, 0x0, 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, + 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x33, 0x0, 0x0, 0x0, + 0x33, 0x0, 0x0, 0x0, 0x33, 0x33, 0x30, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x0, 0x33, 0x3, 0x0, 0x30, 0x0, 0x30, + 0x0, 0x33, 0x0, 0x0, 0x30, 0x0, 0x0, 0x33, + 0x30, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x3, + 0x0, 0x0, 0x30, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x0, 0x33, 0x33, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x33, 0x0, 0x33, 0x30, 0x0, 0x3, + 0x30, 0x0, 0x33, 0x30, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x3, + 0x0, 0x0, 0x3, 0x3, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x30, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x3, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x0, 0x3, 0x0, 0x30, 0x0, 0x0, 0x3, 0x33, + 0x0, 0x3, 0x3, 0x3, 0x0, 0x33, 0x33, 0x0, + 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, + 0x30, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x3, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x0, 0x3, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, + 0x0, 0x30, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, + 0x30, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, 0x0, + 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x3, 0x30, 0x0, 0x33, 0x30, 0x0, 0x3, + 0x30, 0x0, 0x33, 0x30, 0x0, 0x0, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x3, 0x0, + 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x0, + 0x3, 0x0, 0x3, 0x3, 0x0, 0x0, 0x30, 0x30, + 0x0, 0x0, 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, + 0x3, 0x0, 0x30, 0x30, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x33, + 0x0, 0x0, 0x33, 0x30, 0x0, 0x33, 0x33, 0x0, + 0x0, 0x33, 0x0, 0x33, 0x33, 0x30, 0x3, 0x0, + 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x0, + 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, + 0x0, 0x33, 0x33, 0x0, 0x33, 0x0, 0x30, 0x0, + 0x33, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, + 0x0, 0x20, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, + 0x20, 0x0, 0x0, 0x20, 0x0, 0x0, 0x20, 0x0, + 0x0, 0x2, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, + 0x0, 0x2, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, + 0x2, 0x0, 0x0, 0x2, 0x0, 0x2, 0x0, 0x2, + 0x0, 0x2, 0x0, 0x0, 0x20, 0x0, 0x0, 0x20, + 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, + 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, + 0x0, 0x1, 0x0, 0x0, 0x10, 0x0, 0x1, 0x0, + 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, + 0x0, 0x1, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, + 0x1, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x10, + 0x0, 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, + 0x1, 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, 0x1, + 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x1, 0x0, + 0x0, 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, + 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, + 0x0, 0x30, 0x3, 0x33, 0x30, 0x0, 0x3, 0x33, + 0x0, 0x3, 0x33, 0x30, 0x0, 0x33, 0x33, 0x0, + 0x30, 0x0, 0x0, 0x3, 0x33, 0x30, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x33, 0x0, 0x3, 0x0, 0x30, + 0x3, 0x33, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x33, 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, + 0x3, 0x0, 0x3, 0x33, 0x0, 0x3, 0x0, 0x0, + 0x0, 0x0, 0x3, 0x0, 0x33, 0x30, 0x0, 0x30, + 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, + 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x30, 0x3, 0x3, 0x0, + 0x3, 0x0, 0x0, 0x30, 0x3, 0x0, 0x30, 0x3, + 0x0, 0x33, 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, + 0x30, 0x0, 0x3, 0x3, 0x3, 0x3, 0x0, 0x3, + 0x33, 0x0, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, + 0x0, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x30, 0x3, 0x30, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x0, 0x30, 0x3, 0x30, 0x0, + 0x3, 0x0, 0x0, 0x30, 0x30, 0x30, 0x30, 0x3, + 0x3, 0x3, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, + 0x3, 0x0, 0x3, 0x33, 0x0, 0x3, 0x0, 0x0, + 0x3, 0x0, 0x3, 0x0, 0x30, 0x3, 0x0, 0x3, + 0x3, 0x0, 0x3, 0x33, 0x30, 0x0, 0x30, 0x0, + 0x0, 0x3, 0x0, 0x3, 0x0, 0x33, 0x30, 0x0, + 0x33, 0x30, 0x0, 0x30, 0x0, 0x0, 0x3, 0x33, + 0x30, 0x3, 0x0, 0x0, 0x30, 0x3, 0x30, 0x0, + 0x3, 0x0, 0x0, 0x30, 0x30, 0x30, 0x30, 0x3, + 0x3, 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, + 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x3, + 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, + 0x30, 0x0, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, + 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x30, 0x0, 0x30, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x0, 0x30, 0x3, 0x3, 0x0, + 0x3, 0x0, 0x0, 0x33, 0x0, 0x3, 0x30, 0x3, + 0x30, 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x33, 0x0, 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x3, 0x33, 0x30, 0x0, 0x3, 0x33, + 0x0, 0x3, 0x33, 0x30, 0x0, 0x33, 0x33, 0x0, + 0x33, 0x33, 0x0, 0x3, 0x33, 0x0, 0x3, 0x0, + 0x30, 0x3, 0x0, 0x0, 0x30, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x0, 0x33, 0x0, 0x3, 0x30, 0x3, + 0x30, 0x3, 0x0, 0x3, 0x33, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x2, + 0x0, 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x20, + 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x2, 0x0, + 0x0, 0x0, 0x20, 0x0, 0x0, 0x2, 0x0, 0x0, + 0x0, 0x20, 0x0, 0x0, 0x2, 0x0, 0x0, 0x2, + 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x20, 0x0, + 0x0, 0x20, 0x2, 0x0, 0x0, 0x20, 0x0, 0x0, + 0x20, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x20, + 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x10, + 0x1, 0x0, 0x0, 0x10, 0x0, 0x0, 0x1, 0x0, + 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, 0x0, 0x10, + 0x1, 0x0, 0x1, 0x0, 0x1, 0x0, 0x1, 0x0, + 0x0, 0x10, 0x1, 0x0, 0x1, 0x0, 0x10, 0x0, + 0x10, 0x0, 0x0, 0x10, 0x0, 0x10, 0x0, 0x0, + 0x10, 0x0, 0x0, 0x10, 0x0, 0x0, 0x10, 0x0, + 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x10, 0x0, + 0x0, 0x10, 0x0, 0x0, 0x10, 0x1, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x30, 0x3, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x0, 0x3, 0x3, 0x0, 0x3, + 0x33, 0x0, 0x0, 0x33, 0x0, 0x3, 0x3, 0x0, + 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, 0x0, 0x30, + 0x0, 0x3, 0x30, 0x0, 0x3, 0x0, 0x33, 0x33, + 0x0, 0x3, 0x30, 0x0, 0x0, 0x30, 0x0, 0x33, + 0x0, 0x0, 0x33, 0x0, 0x0, 0x30, 0x0, 0x3, + 0x30, 0x0, 0x3, 0x30, 0x0, 0x30, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x33, 0x33, 0x30, 0x0, + 0x33, 0x0, 0x30, 0x33, 0x0, 0x30, 0x30, 0x0, + 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, + 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x30, 0x0, + 0x0, 0x30, 0x3, 0x0, 0x33, 0x33, 0x0, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x0, 0x3, 0x3, 0x0, 0x0, + 0x30, 0x0, 0x3, 0x0, 0x0, 0x30, 0x33, 0x0, + 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x3, + 0x33, 0x0, 0x0, 0x3, 0x30, 0x0, 0x0, 0x30, + 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x3, 0x30, + 0x0, 0x0, 0x3, 0x0, 0x30, 0x30, 0x0, 0x0, + 0x30, 0x3, 0x0, 0x30, 0x0, 0x30, 0x0, 0x30, + 0x3, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x0, 0x3, 0x3, 0x0, 0x3, + 0x30, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, 0x0, + 0x0, 0x3, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x3, 0x0, 0x0, 0x3, + 0x0, 0x0, 0x30, 0x0, 0x3, 0x30, 0x0, 0x33, + 0x0, 0x3, 0x33, 0x0, 0x0, 0x30, 0x0, 0x3, + 0x30, 0x0, 0x3, 0x33, 0x0, 0x30, 0x0, 0x0, + 0x30, 0x3, 0x3, 0x0, 0x33, 0x33, 0x30, 0x3, + 0x33, 0x0, 0x33, 0x3, 0x0, 0x30, 0x30, 0x0, + 0x30, 0x3, 0x0, 0x0, 0x30, 0x3, 0x30, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x33, 0x0, 0x30, 0x3, + 0x0, 0x30, 0x3, 0x0, 0x3, 0x30, 0x0, 0x30, + 0x0, 0x3, 0x0, 0x0, 0x0, 0x3, 0x0, 0x30, + 0x3, 0x0, 0x30, 0x3, 0x0, 0x0, 0x0, 0x0, + 0x30, 0x3, 0x3, 0x0, 0x3, 0x3, 0x0, 0x0, + 0x30, 0x0, 0x33, 0x0, 0x0, 0x3, 0x0, 0x0, + 0x30, 0x0, 0x30, 0x3, 0x0, 0x3, 0x30, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, + 0x0, 0x3, 0x30, 0x0, 0x3, 0x0, 0x3, 0x30, + 0x0, 0x3, 0x30, 0x0, 0x0, 0x30, 0x0, 0x33, + 0x30, 0x0, 0x33, 0x0, 0x3, 0x33, 0x0, 0x3, + 0x30, 0x0, 0x3, 0x30, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x2, + 0x0, 0x20, 0x0, 0x2, 0x0, 0x0, 0x0, 0x20, + 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, 0x2, + 0x0, 0x20, 0x0, 0x20, 0x0, 0x20, 0x0, 0x20, + 0x0, 0x2, 0x0, 0x20, 0x0, 0x20, 0x2, 0x0, + 0x2, 0x0, 0x0, 0x2, 0x0, 0x2, 0x0, 0x0, + 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, + 0x0, 0x20, 0x0, 0x0, 0x20, 0x0, 0x2, 0x0, + 0x0, 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0 +}; + + u32 BuiltInFontDataSize = sizeof(BuiltInFontData); +} // end namespace gui +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/C3DSMeshFileLoader.cpp b/src/dep/src/irrlicht/C3DSMeshFileLoader.cpp index f3a9ba3..631a835 100644 --- a/src/dep/src/irrlicht/C3DSMeshFileLoader.cpp +++ b/src/dep/src/irrlicht/C3DSMeshFileLoader.cpp @@ -1,1264 +1,1264 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "C3DSMeshFileLoader.h" -#include "os.h" -#include "SMeshBuffer.h" -#include "SAnimatedMesh.h" - -namespace irr -{ -namespace scene -{ - - -// Primary chunk -const u16 C3DS_MAIN3DS = 0x4D4D; - -// Main Chunks -const u16 C3DS_EDIT3DS = 0x3D3D; -const u16 C3DS_KEYF3DS = 0xB000; -const u16 C3DS_VERSION = 0x0002; -const u16 C3DS_MESHVERSION = 0x3D3E; - -// sub chunks of C3DS_EDIT3DS -const u16 C3DS_EDIT_MATERIAL = 0xAFFF; -const u16 C3DS_EDIT_OBJECT = 0x4000; - -// sub chunks of C3DS_EDIT_MATERIAL -const u16 C3DS_MATNAME = 0xA000; -const u16 C3DS_MATAMBIENT = 0xA010; -const u16 C3DS_MATDIFFUSE = 0xA020; -const u16 C3DS_MATSPECULAR = 0xA030; -const u16 C3DS_MATSHININESS = 0xA040; -const u16 C3DS_MATSHIN2PCT = 0xA041; -const u16 C3DS_TRANSPARENCY = 0xA050; -const u16 C3DS_TWO_SIDE = 0xA081; -const u16 C3DS_WIRE = 0xA085; -const u16 C3DS_SHADING = 0xA100; -const u16 C3DS_MATTEXMAP = 0xA200; -const u16 C3DS_MATSPECMAP = 0xA204; -const u16 C3DS_MATOPACMAP = 0xA210; -const u16 C3DS_MATREFLMAP = 0xA220; -const u16 C3DS_MATBUMPMAP = 0xA230; -const u16 C3DS_MATMAPFILE = 0xA300; -const u16 C3DS_MAT_TEXTILING = 0xA351; -const u16 C3DS_MAT_USCALE = 0xA354; -const u16 C3DS_MAT_VSCALE = 0xA356; -const u16 C3DS_MAT_UOFFSET = 0xA358; -const u16 C3DS_MAT_VOFFSET = 0xA35A; - -// subs of C3DS_EDIT_OBJECT -const u16 C3DS_OBJTRIMESH = 0x4100; - -// subs of C3DS_OBJTRIMESH -const u16 C3DS_TRIVERT = 0x4110; -const u16 C3DS_POINTFLAGARRAY= 0x4111; -const u16 C3DS_TRIFACE = 0x4120; -const u16 C3DS_TRIFACEMAT = 0x4130; -const u16 C3DS_TRIUV = 0x4140; -const u16 C3DS_TRISMOOTH = 0x4150; -const u16 C3DS_TRIMATRIX = 0x4160; -const u16 C3DS_MESHCOLOR = 0x4165; -const u16 C3DS_DIRECT_LIGHT = 0x4600; -const u16 C3DS_DL_INNER_RANGE= 0x4659; -const u16 C3DS_DL_OUTER_RANGE= 0x465A; -const u16 C3DS_DL_MULTIPLIER = 0x465B; -const u16 C3DS_CAMERA = 0x4700; -const u16 C3DS_CAM_SEE_CONE = 0x4710; -const u16 C3DS_CAM_RANGES = 0x4720; - -// subs of C3DS_KEYF3DS -const u16 C3DS_KF_HDR = 0xB00A; -const u16 C3DS_AMBIENT_TAG = 0xB001; -const u16 C3DS_OBJECT_TAG = 0xB002; -const u16 C3DS_CAMERA_TAG = 0xB003; -const u16 C3DS_TARGET_TAG = 0xB004; -const u16 C3DS_LIGHTNODE_TAG = 0xB005; -const u16 C3DS_KF_SEG = 0xB008; -const u16 C3DS_KF_CURTIME = 0xB009; -const u16 C3DS_KF_NODE_HDR = 0xB010; -const u16 C3DS_PIVOTPOINT = 0xB013; -const u16 C3DS_BOUNDBOX = 0xB014; -const u16 C3DS_POS_TRACK_TAG = 0xB020; -const u16 C3DS_ROT_TRACK_TAG = 0xB021; -const u16 C3DS_SCL_TRACK_TAG = 0xB022; -const u16 C3DS_NODE_ID = 0xB030; - -// different color chunk types -const u16 C3DS_COL_RGB = 0x0010; -const u16 C3DS_COL_TRU = 0x0011; -const u16 C3DS_COL_LIN_24 = 0x0012; -const u16 C3DS_COL_LIN_F = 0x0013; - -// percentage chunk types -const u16 C3DS_PERCENTAGE_I = 0x0030; -const u16 C3DS_PERCENTAGE_F = 0x0031; - - -//! Constructor -C3DSMeshFileLoader::C3DSMeshFileLoader(IMeshManipulator* manip,io::IFileSystem* fs, video::IVideoDriver* driver) -: FileSystem(fs), Driver(driver), Vertices(0), Indices(0), TCoords(0), - CountVertices(0), CountFaces(0), CountTCoords(0), Mesh(0), Manipulator(manip) -{ - TransformationMatrix.makeIdentity(); - if (FileSystem) - FileSystem->grab(); - - if (Driver) - Driver->grab(); -} - - - -//! destructor -C3DSMeshFileLoader::~C3DSMeshFileLoader() -{ - if (FileSystem) - FileSystem->drop(); - - if (Driver) - Driver->drop(); - - if (Vertices) - delete [] Vertices; - - if (Indices) - delete [] Indices; - - if (TCoords) - delete [] TCoords; - - if (Mesh) - Mesh->drop(); -} - - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool C3DSMeshFileLoader::isALoadableFileExtension(const c8* filename) -{ - return strstr(filename, ".3ds")!=0; -} - - - -//! creates/loads an animated mesh from the file. -//! \return Pointer to the created mesh. Returns 0 if loading failed. -//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). -//! See IUnknown::drop() for more information. -IAnimatedMesh* C3DSMeshFileLoader::createMesh(io::IReadFile* file) -{ - ChunkData data; - - readChunkData(file, data); - - if (data.header.id != C3DS_MAIN3DS ) - return false; - - CurrentMaterial.clear(); - Materials.clear(); - MeshBufferNames.clear(); - cleanUp(); - - if (Mesh) - Mesh->drop(); - - Mesh = new SMesh(); - - if (readChunk(file, &data)) - { - // success - SAnimatedMesh* am = new SAnimatedMesh(); - am->Type = EAMT_3DS; - - for (u32 i=0; igetMeshBufferCount(); ++i) - { - SMeshBuffer* mb = ((SMeshBuffer*)Mesh->getMeshBuffer(i)); - // drop empty buffers - if (mb->getIndexCount() == 0 || mb->getVertexCount() == 0) - { - Mesh->MeshBuffers.erase(i--); - mb->drop(); - } - else - mb->recalculateBoundingBox(); - } - - Mesh->recalculateBoundingBox(); - - am->addMesh(Mesh); - am->recalculateBoundingBox(); - Mesh->drop(); - Mesh = 0; - return am; - } - - Mesh->drop(); - Mesh = 0; - - return 0; -} - - -bool C3DSMeshFileLoader::readPercentageChunk(io::IReadFile* file, - ChunkData* chunk, f32& percentage) -{ - ChunkData data; - readChunkData(file, data); - - short intpercentage; - float fpercentage; - - switch(data.header.id) - { - case C3DS_PERCENTAGE_I: - { - // read short - file->read(&intpercentage, 2); -#ifdef __BIG_ENDIAN__ - intpercentage = os::Byteswap::byteswap(intpercentage); -#endif - percentage=intpercentage/100.0f; - data.read += 2; - } - break; - case C3DS_PERCENTAGE_F: - { - // read float - file->read(&fpercentage, sizeof(float)); - data.read += sizeof(float); -#ifdef __BIG_ENDIAN__ - percentage = os::Byteswap::byteswap(fpercentage); -#else - percentage = (f32)fpercentage; -#endif - } - break; - default: - { - // unknown percentage chunk - os::Printer::log("Unknown percentage chunk in 3Ds file.", ELL_WARNING); - file->seek(data.header.length - data.read, true); - data.read += data.header.length - data.read; - } - } - - chunk->read += data.read; - - return true; -} - -bool C3DSMeshFileLoader::readColorChunk(io::IReadFile* file, ChunkData* chunk, - video::SColor& out) -{ - ChunkData data; - readChunkData(file, data); - - u8 c[3]; - f32 cf[3]; - - switch(data.header.id) - { - case C3DS_COL_TRU: - case C3DS_COL_LIN_24: - { - // read 8 bit data - file->read(c, sizeof(c)); - out.set(255, c[0], c[1], c[2]); - data.read += sizeof(c); - } - break; - case C3DS_COL_RGB: - case C3DS_COL_LIN_F: - { - // read float data - file->read(cf, sizeof(cf)); -#ifdef __BIG_ENDIAN__ - cf[0] = os::Byteswap::byteswap(cf[0]); - cf[1] = os::Byteswap::byteswap(cf[1]); - cf[2] = os::Byteswap::byteswap(cf[2]); -#endif - out.set(255, (s32)(cf[0]*255.0f), (s32)(cf[1]*255.0f), (s32)(cf[2]*255.0f)); - data.read += sizeof(cf); - } - break; - default: - { - // unknown color chunk size - os::Printer::log("Unknown size of color chunk in 3Ds file.", ELL_WARNING); - file->seek(data.header.length - data.read, true); - data.read += data.header.length - data.read; - } - } - - chunk->read += data.read; - - return true; -} - - -bool C3DSMeshFileLoader::readMaterialChunk(io::IReadFile* file, ChunkData* parent) -{ - u16 matSection=0; - - while(parent->read < parent->header.length) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case C3DS_MATNAME: - { - c8* c = new c8[data.header.length - data.read]; - file->read(c, data.header.length - data.read); - - if (strlen(c)) - CurrentMaterial.Name = c; - - data.read += data.header.length - data.read; - delete [] c; - } - break; - case C3DS_MATAMBIENT: - readColorChunk(file, &data, CurrentMaterial.Material.AmbientColor); - break; - case C3DS_MATDIFFUSE: - readColorChunk(file, &data, CurrentMaterial.Material.DiffuseColor); - break; - case C3DS_MATSPECULAR: - readColorChunk(file, &data, CurrentMaterial.Material.SpecularColor); - break; - case C3DS_MATSHININESS: - readPercentageChunk(file, &data, CurrentMaterial.Material.Shininess); - break; - case C3DS_TRANSPARENCY: - { - f32 percentage; - readPercentageChunk(file, &data, percentage); - if (percentage>0.0f) - { - CurrentMaterial.Material.MaterialTypeParam=percentage; - CurrentMaterial.Material.MaterialType=video::EMT_TRANSPARENT_VERTEX_ALPHA; - } - else - { - CurrentMaterial.Material.MaterialType=video::EMT_SOLID; - } - } - break; - case C3DS_WIRE: - CurrentMaterial.Material.Wireframe=true; - break; - case C3DS_TWO_SIDE: - CurrentMaterial.Material.BackfaceCulling=false; - break; - case C3DS_SHADING: - { - s16 flags; - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - switch (flags) - { - case 0: - CurrentMaterial.Material.Wireframe=true; - break; - case 1: - CurrentMaterial.Material.Wireframe=false; - CurrentMaterial.Material.GouraudShading=false; - break; - case 2: - CurrentMaterial.Material.Wireframe=false; - CurrentMaterial.Material.GouraudShading=true; - break; - default: - // phong and metal missing - break; - } - data.read += data.header.length - data.read; - } - break; - case C3DS_MATTEXMAP: - case C3DS_MATSPECMAP: - case C3DS_MATOPACMAP: - case C3DS_MATREFLMAP: - case C3DS_MATBUMPMAP: - { - matSection=data.header.id; -#if 0 // Should contain a percentage chunk, but does not work with the meshes - f32 percentage=0; - if (matSection!=C3DS_MATREFLMAP) - readPercentageChunk(file, &data, percentage); -#endif - } - break; - case C3DS_MATMAPFILE: - { - // read texture file name - c8* c = new c8[data.header.length - data.read]; - file->read(c, data.header.length - data.read); - if (matSection == C3DS_MATTEXMAP) - CurrentMaterial.Filename[0] = c; - else if (matSection == C3DS_MATSPECMAP) - CurrentMaterial.Filename[1] = c; - else if (matSection == C3DS_MATOPACMAP) - CurrentMaterial.Filename[2] = c; - else if (matSection == C3DS_MATREFLMAP) - CurrentMaterial.Filename[3] = c; - else if (matSection == C3DS_MATBUMPMAP) - CurrentMaterial.Filename[4] = c; - data.read += data.header.length - data.read; - delete [] c; - } - break; - case C3DS_MAT_TEXTILING: - { - s16 flags; - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - data.read += 2; - } - break; - case C3DS_MAT_USCALE: - case C3DS_MAT_VSCALE: - case C3DS_MAT_UOFFSET: - case C3DS_MAT_VOFFSET: - { - f32 value; - file->read(&value, 4); -#ifdef __BIG_ENDIAN__ - value = os::Byteswap::byteswap(value); -#endif - data.read += 4; - } - break; - default: - // ignore chunk - file->seek(data.header.length - data.read, true); - data.read += data.header.length - data.read; - } - - parent->read += data.read; - } - - Materials.push_back(CurrentMaterial); - CurrentMaterial.clear(); - - return true; -} - - - -bool C3DSMeshFileLoader::readTrackChunk(io::IReadFile* file, ChunkData& data, - IMeshBuffer* mb, const core::vector3df& pivot) -{ - u16 flags; - u32 flags2; - // Track flags - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - file->read(&flags2, 4); -#ifdef __BIG_ENDIAN__ - flags2 = os::Byteswap::byteswap(flags2); -#endif - file->read(&flags2, 4); -#ifdef __BIG_ENDIAN__ - flags2 = os::Byteswap::byteswap(flags2); -#endif - // Num keys - file->read(&flags2, 4); -#ifdef __BIG_ENDIAN__ - flags2 = os::Byteswap::byteswap(flags2); -#endif - file->read(&flags2, 4); -#ifdef __BIG_ENDIAN__ - flags2 = os::Byteswap::byteswap(flags2); -#endif - // TCB flags - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - data.read += 20; - - f32 angle=0.0f; - if (data.header.id== C3DS_ROT_TRACK_TAG) - { - // Angle - file->read(&angle, sizeof(f32)); -#ifdef __BIG_ENDIAN__ - angle = os::Byteswap::byteswap(angle); -#endif - data.read += sizeof(f32); - } - core::vector3df vec; - file->read(&vec.X, sizeof(f32)); - file->read(&vec.Y, sizeof(f32)); - file->read(&vec.Z, sizeof(f32)); -#ifdef __BIG_ENDIAN__ - vec.X = os::Byteswap::byteswap(vec.X); - vec.Y = os::Byteswap::byteswap(vec.X); - vec.Z = os::Byteswap::byteswap(vec.X); -#endif - data.read += 12; - vec-=pivot; - - // apply transformation to mesh buffer - if (false)//mb) - { - video::S3DVertex *vertices=(video::S3DVertex*)mb->getVertices(); - if (data.header.id==C3DS_POS_TRACK_TAG) - { - for (u32 i=0; igetVertexCount(); ++i) - vertices[i].Pos+=vec; - } - else if (data.header.id==C3DS_ROT_TRACK_TAG) - { - //TODO - } - else if (data.header.id==C3DS_SCL_TRACK_TAG) - { - //TODO - } - } - // skip further frames - file->seek(data.header.length - data.read, true); - data.read += data.header.length - data.read; - return true; -} - - - -bool C3DSMeshFileLoader::readFrameChunk(io::IReadFile* file, ChunkData* parent) -{ - ChunkData data; - - //KF_HDR is always at the beginning - readChunkData(file, data); - if (data.header.id != C3DS_KF_HDR) - return false; - else - { - u16 flags; - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - c8* c = new c8[data.header.length - data.read-4]; - file->read(c, data.header.length - data.read-4); - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - - data.read += data.header.length - data.read; - parent->read += data.read; - delete [] c; - } - - IMeshBuffer* mb=0; - core::vector3df pivot,bboxCenter; - while(parent->read < parent->header.length) - { - readChunkData(file, data); - - switch(data.header.id) - { - case C3DS_OBJECT_TAG: - { - mb=0; - pivot.set(0.0f, 0.0f, 0.0f); - } - break; - case C3DS_KF_SEG: - { - u32 flags; - file->read(&flags, 4); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - file->read(&flags, 4); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - data.read += 8; - } - break; - case C3DS_KF_NODE_HDR: - { - s16 flags; - c8* c = new c8[data.header.length - data.read-6]; - file->read(c, data.header.length - data.read-6); - - // search mesh buffer to apply these transformations to - for (u32 i=0; igetMeshBuffer(i); - break; - } - } - - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - data.read += data.header.length - data.read; - delete [] c; - } - break; - case C3DS_KF_CURTIME: - { - u32 flags; - file->read(&flags, 4); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - data.read += 4; - } - break; - case C3DS_NODE_ID: - { - u16 flags; - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - data.read += 2; - } - break; - case C3DS_PIVOTPOINT: - { - file->read(&pivot.X, sizeof(f32)); - file->read(&pivot.Y, sizeof(f32)); - file->read(&pivot.Z, sizeof(f32)); -#ifdef __BIG_ENDIAN__ - pivot.X = os::Byteswap::byteswap(pivot.X); - pivot.Y = os::Byteswap::byteswap(pivot.Y); - pivot.Z = os::Byteswap::byteswap(pivot.Z); -#endif - data.read += 12; - } - break; - case C3DS_BOUNDBOX: - { - core::aabbox3df bbox; - // abuse bboxCenter as temporary variable - file->read(&bboxCenter.X, sizeof(f32)); - file->read(&bboxCenter.Y, sizeof(f32)); - file->read(&bboxCenter.Z, sizeof(f32)); -#ifdef __BIG_ENDIAN__ - bboxCenter.X = os::Byteswap::byteswap(bboxCenter.X); - bboxCenter.Y = os::Byteswap::byteswap(bboxCenter.Y); - bboxCenter.Z = os::Byteswap::byteswap(bboxCenter.Z); -#endif - bbox.reset(bboxCenter); - file->read(&bboxCenter.X, sizeof(f32)); - file->read(&bboxCenter.Y, sizeof(f32)); - file->read(&bboxCenter.Z, sizeof(f32)); -#ifdef __BIG_ENDIAN__ - bboxCenter.X = os::Byteswap::byteswap(bboxCenter.X); - bboxCenter.Y = os::Byteswap::byteswap(bboxCenter.Y); - bboxCenter.Z = os::Byteswap::byteswap(bboxCenter.Z); -#endif - bbox.addInternalPoint(bboxCenter); - bboxCenter=bbox.getCenter(); - data.read += 24; - } - break; - case C3DS_POS_TRACK_TAG: - case C3DS_ROT_TRACK_TAG: - case C3DS_SCL_TRACK_TAG: - readTrackChunk(file, data, mb, bboxCenter-pivot); - break; - default: - // ignore chunk - file->seek(data.header.length - data.read, true); - data.read += data.header.length - data.read; - } - - parent->read += data.read; - data.read=0; - } - - return true; -} - - - -bool C3DSMeshFileLoader::readChunk(io::IReadFile* file, ChunkData* parent) -{ - while(parent->read < parent->header.length) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case C3DS_VERSION: - { - u16 version; - file->read(&version, sizeof(u16)); -#ifdef __BIG_ENDIAN__ - version = os::Byteswap::byteswap(version); -#endif - file->seek(data.header.length - data.read - 2, true); - data.read += data.header.length - data.read; - if (version != 0x03) - os::Printer::log("3ds file version is other than 3.", ELL_ERROR); - } - break; - case C3DS_EDIT_MATERIAL: - readMaterialChunk(file, &data); - break; - case C3DS_KEYF3DS: - readFrameChunk(file, &data); - break; - case C3DS_EDIT3DS: - break; - case C3DS_MESHVERSION: - case 0x01: - { - u32 version; - file->read(&version, sizeof(u32)); -#ifdef __BIG_ENDIAN__ - version = os::Byteswap::byteswap(version); -#endif - data.read += sizeof(u32); - } - break; - case C3DS_EDIT_OBJECT: - { - core::stringc name; - readString(file, data, name); - readObjectChunk(file, &data); - composeObject(file, name); - } - break; - - default: - // ignore chunk - file->seek(data.header.length - data.read, true); - data.read += data.header.length - data.read; - } - - parent->read += data.read; - } - - return true; -} - - - -bool C3DSMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData* parent) -{ - while(parent->read < parent->header.length) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case C3DS_OBJTRIMESH: - readObjectChunk(file, &data); - break; - - case C3DS_TRIVERT: - readVertices(file, data); - break; - - case C3DS_POINTFLAGARRAY: - { - u16 numVertex, flags; - file->read(&numVertex, sizeof(u16)); -#ifdef __BIG_ENDIAN__ - numVertex= os::Byteswap::byteswap(numVertex); -#endif - for (u16 i=0; iread(&flags, sizeof(u16)); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - } - data.read += (numVertex+1)*sizeof(u16); - } - break; - - case C3DS_TRIFACE: - readIndices(file, data); - readObjectChunk(file, &data); // read smooth and material groups - break; - - case C3DS_TRIFACEMAT: - readMaterialGroup(file, data); - break; - - case C3DS_TRIUV: // getting texture coordinates - readTextureCoords(file, data); - break; - - case C3DS_TRIMATRIX: - { - f32 mat[4][3]; - file->read(&mat, 12*sizeof(f32)); - TransformationMatrix.makeIdentity(); - for (int i=0; i<4; ++i) - { - for (int j=0; j<3; ++j) - { -#ifdef __BIG_ENDIAN__ - TransformationMatrix(i,j)=os::Byteswap::byteswap(mat[i][j]); -#else - TransformationMatrix(i,j)=mat[i][j]; -#endif - } - } - data.read += 12*sizeof(f32); - } - break; - case C3DS_MESHCOLOR: - { - u8 flag; - file->read(&flag, sizeof(u8)); - ++data.read; - } - break; - case C3DS_TRISMOOTH: // TODO - { - u32 flags; - for (u16 i=0; iread(&flags, sizeof(u32)); -#ifdef __BIG_ENDIAN__ - for (u16 i=0; iseek(data.header.length - data.read, true); - data.read += data.header.length - data.read; - } - - parent->read += data.read; - } - - return true; -} - - -void C3DSMeshFileLoader::composeObject(io::IReadFile* file, const core::stringc& name) -{ - if (Mesh->getMeshBufferCount() != Materials.size()) - loadMaterials(file); - - if (MaterialGroups.empty()) - { - // no material group, so add all - SMaterialGroup group; - group.faceCount = CountFaces; - group.faces = new s16[group.faceCount]; - for (int i=0; iaddMeshBuffer(mb); - mb->Material = Materials[0].Material; - mb->drop(); - // add an empty mesh buffer name - core::stringc c = ""; - MeshBufferNames.push_back(c); - } - } - - for (u32 i=0; igetMaximalPrimitiveCount(), (u32)((1<<16)-1))-3; // currently hardcoded s16 max value for index pointers - - // find mesh buffer for this group - for (mbPos=0; mbPosgetMeshBuffer(mbPos); - mat=&Materials[mbPos].Material; - MeshBufferNames[mbPos]=name; - break; - } - } - - if (mb != 0) - { - // add geometry to the buffer. - - video::S3DVertex vtx; - core::vector3df vec; - vtx.Color=mat->DiffuseColor; - if (mat->MaterialType==video::EMT_TRANSPARENT_VERTEX_ALPHA) - { - vtx.Color.setAlpha((int)(255.0f*mat->MaterialTypeParam)); - } - vtx.Normal.set(0,0,0); - - for (s32 f=0; fVertices.size(); - if (vtxCount>maxPrimitives) - { - Mesh->addMeshBuffer(new SMeshBuffer()); - IMeshBuffer* tmp = mb; - mb=(SMeshBuffer*)(Mesh->MeshBuffers[mbPos]=Mesh->MeshBuffers.getLast()); - Mesh->MeshBuffers[Mesh->MeshBuffers.size()-1]=tmp; - mb->Material=*mat; - vtxCount=0; - } - - for (s32 v=0; v<3; ++v) - { - s32 idx = Indices[MaterialGroups[i].faces[f]*4 +v]; - - if (CountVertices > idx) - { - vtx.Pos.X = Vertices[idx*3 + 0]; - vtx.Pos.Z = Vertices[idx*3 + 1]; - vtx.Pos.Y = Vertices[idx*3 + 2]; -// TransformationMatrix.transformVect(vtx.Pos); - } - - if (CountTCoords > idx) - { - vtx.TCoords.X = TCoords[idx*2 + 0]; - vtx.TCoords.Y = 1.0f -TCoords[idx*2 + 1]; - } - - mb->Vertices.push_back(vtx); - } - - // compute normal - core::plane3d pl(mb->Vertices[vtxCount].Pos, mb->Vertices[vtxCount+2].Pos, - mb->Vertices[vtxCount+1].Pos); - - mb->Vertices[vtxCount].Normal = pl.Normal; - mb->Vertices[vtxCount+1].Normal = pl.Normal; - mb->Vertices[vtxCount+2].Normal = pl.Normal; - - // add indices - - mb->Indices.push_back(vtxCount); - mb->Indices.push_back(vtxCount+2); - mb->Indices.push_back(vtxCount+1); - } - } - else - os::Printer::log("Found no matching material for Group in 3ds file.", ELL_WARNING); - } - - cleanUp(); -} - - -core::stringc C3DSMeshFileLoader::getTextureFileName(const core::stringc& texture, - core::stringc& model) -{ - s32 idx = -1; - idx = model.findLast('/'); - - if (idx == -1) - idx = model.findLast('\\'); - - if (idx == -1) - return core::stringc(); - - core::stringc p = model.subString(0, idx+1); - p.append(texture); - return p; -} - - -void C3DSMeshFileLoader::loadMaterials(io::IReadFile* file) -{ - // create a mesh buffer for every material - core::stringc modelFilename = file->getFileName(); - - if (Materials.empty()) - os::Printer::log("No materials found in 3ds file.", ELL_INFORMATION); - - MeshBufferNames.reallocate(Materials.size()); - for (u32 i=0; iaddMeshBuffer(m); - - m->Material = Materials[i].Material; - if (Materials[i].Filename[0].size()) - { - m->Material.Textures[0] = Driver->getTexture(Materials[i].Filename[0].c_str()); - - if (!m->Material.Textures[0]) - { - core::stringc fname = getTextureFileName( - Materials[i].Filename[0], modelFilename); - if (fname.size()) - m->Material.Textures[0] = Driver->getTexture(fname.c_str()); - } - - if (!m->Material.Textures[0]) - os::Printer::log("Could not load a texture for entry in 3ds file", - Materials[i].Filename[0].c_str(), ELL_WARNING); - } - - if (Materials[i].Filename[2].size()) - { - m->Material.Textures[0] = Driver->getTexture(Materials[i].Filename[2].c_str()); - - if (!m->Material.Textures[0]) - { - core::stringc fname = getTextureFileName( - Materials[i].Filename[2], modelFilename); - if (fname.size()) - m->Material.Textures[0] = Driver->getTexture(fname.c_str()); - } - - if (!m->Material.Textures[0]) - { - os::Printer::log("Could not load a texture for entry in 3ds file", - Materials[i].Filename[2].c_str(), ELL_WARNING); - } - else - { - m->Material.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR; - } - } - - if (Materials[i].Filename[3].size()) - { - m->Material.Textures[1]=m->Material.Textures[0]; - m->Material.Textures[0]=0; - m->Material.Textures[0] = Driver->getTexture(Materials[i].Filename[3].c_str()); - - if (!m->Material.Textures[0]) - { - core::stringc fname = getTextureFileName( - Materials[i].Filename[3], modelFilename); - if (fname.size()) - m->Material.Textures[0] = Driver->getTexture(fname.c_str()); - } - - if (!m->Material.Textures[0]) - { - os::Printer::log("Could not load a texture for entry in 3ds file", - Materials[i].Filename[3].c_str(), ELL_WARNING); - m->Material.Textures[0]=m->Material.Textures[1]; - m->Material.Textures[1]=0; - } - else - { - m->Material.MaterialType=video::EMT_REFLECTION_2_LAYER; - } - } - - if (Materials[i].Filename[4].size()) - { - m->Material.Textures[1] = Driver->getTexture(Materials[i].Filename[4].c_str()); - - if (!m->Material.Textures[1]) - { - core::stringc fname = getTextureFileName( - Materials[i].Filename[4], modelFilename); - if (fname.size()) - m->Material.Textures[1] = Driver->getTexture(fname.c_str()); - } - - if (!m->Material.Textures[1]) - os::Printer::log("Could not load a texture for entry in 3ds file", - Materials[i].Filename[4].c_str(), ELL_WARNING); - else - { - Driver->makeNormalMapTexture(m->Material.Textures[1], 9.0f); - m->Material.MaterialType=video::EMT_PARALLAX_MAP_SOLID; - m->Material.MaterialTypeParam=0.035f; - } - } - - m->drop(); - } -} - - -void C3DSMeshFileLoader::cleanUp() -{ - delete [] Vertices; - CountVertices = 0; - Vertices = 0; - delete [] Indices; - Indices = 0; - CountFaces = 0; - delete [] TCoords; - TCoords = 0; - CountTCoords = 0; - - MaterialGroups.clear(); -} - - - - -void C3DSMeshFileLoader::readTextureCoords(io::IReadFile* file, ChunkData& data) -{ - file->read(&CountTCoords, sizeof(CountTCoords)); -#ifdef __BIG_ENDIAN__ - CountTCoords = os::Byteswap::byteswap(CountTCoords); -#endif - data.read += sizeof(CountTCoords); - - s32 tcoordsBufferByteSize = CountTCoords * sizeof(f32) * 2; - - if (data.header.length - data.read != tcoordsBufferByteSize) - { - os::Printer::log("Invalid size of tcoords found in 3ds file.", ELL_WARNING); - return; - } - - TCoords = new f32[CountTCoords * 3]; - file->read(TCoords, tcoordsBufferByteSize); -#ifdef __BIG_ENDIAN__ - for (int i=0;iread(&group.faceCount, sizeof(group.faceCount)); -#ifdef __BIG_ENDIAN__ - group.faceCount = os::Byteswap::byteswap(group.faceCount); -#endif - data.read += sizeof(group.faceCount); - - // read faces - group.faces = new s16[group.faceCount]; - file->read(group.faces, sizeof(s16) * group.faceCount); -#ifdef __BIG_ENDIAN__ - for (int i=0;iread(&CountFaces, sizeof(CountFaces)); -#ifdef __BIG_ENDIAN__ - CountFaces = os::Byteswap::byteswap(CountFaces); -#endif - data.read += sizeof(CountFaces); - - s32 indexBufferByteSize = CountFaces * sizeof(u16) * 4; - - // Indices are u16s. - // After every 3 Indices in the array, there follows an edge flag. - Indices = new u16[CountFaces * 4]; - file->read(Indices, indexBufferByteSize); -#ifdef __BIG_ENDIAN__ - for (int i=0;iread(&CountVertices, sizeof(CountVertices)); -#ifdef __BIG_ENDIAN__ - CountVertices = os::Byteswap::byteswap(CountVertices); -#endif - data.read += sizeof(CountVertices); - - s32 vertexBufferByteSize = CountVertices * sizeof(f32) * 3; - - if (data.header.length - data.read != vertexBufferByteSize) - { - os::Printer::log("Invalid size of vertices found in 3ds file.", ELL_WARNING); - return; - } - - Vertices = new f32[CountVertices * 3]; - file->read(Vertices, vertexBufferByteSize); -#ifdef __BIG_ENDIAN__ - for (int i=0;iread(&data.header, sizeof(ChunkHeader)); -#ifdef __BIG_ENDIAN__ - data.header.id = os::Byteswap::byteswap(data.header.id); - data.header.length = os::Byteswap::byteswap(data.header.length); -#endif - data.read += sizeof(ChunkHeader); -} - - -void C3DSMeshFileLoader::readString(io::IReadFile* file, ChunkData& data, core::stringc& out) -{ - c8 c = 1; - out = ""; - - while (c) - { - file->read(&c, sizeof(c8)); - if (c) - out.append(c); - - ++data.read; - } -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "C3DSMeshFileLoader.h" +#include "os.h" +#include "SMeshBuffer.h" +#include "SAnimatedMesh.h" + +namespace irr +{ +namespace scene +{ + + +// Primary chunk +const u16 C3DS_MAIN3DS = 0x4D4D; + +// Main Chunks +const u16 C3DS_EDIT3DS = 0x3D3D; +const u16 C3DS_KEYF3DS = 0xB000; +const u16 C3DS_VERSION = 0x0002; +const u16 C3DS_MESHVERSION = 0x3D3E; + +// sub chunks of C3DS_EDIT3DS +const u16 C3DS_EDIT_MATERIAL = 0xAFFF; +const u16 C3DS_EDIT_OBJECT = 0x4000; + +// sub chunks of C3DS_EDIT_MATERIAL +const u16 C3DS_MATNAME = 0xA000; +const u16 C3DS_MATAMBIENT = 0xA010; +const u16 C3DS_MATDIFFUSE = 0xA020; +const u16 C3DS_MATSPECULAR = 0xA030; +const u16 C3DS_MATSHININESS = 0xA040; +const u16 C3DS_MATSHIN2PCT = 0xA041; +const u16 C3DS_TRANSPARENCY = 0xA050; +const u16 C3DS_TWO_SIDE = 0xA081; +const u16 C3DS_WIRE = 0xA085; +const u16 C3DS_SHADING = 0xA100; +const u16 C3DS_MATTEXMAP = 0xA200; +const u16 C3DS_MATSPECMAP = 0xA204; +const u16 C3DS_MATOPACMAP = 0xA210; +const u16 C3DS_MATREFLMAP = 0xA220; +const u16 C3DS_MATBUMPMAP = 0xA230; +const u16 C3DS_MATMAPFILE = 0xA300; +const u16 C3DS_MAT_TEXTILING = 0xA351; +const u16 C3DS_MAT_USCALE = 0xA354; +const u16 C3DS_MAT_VSCALE = 0xA356; +const u16 C3DS_MAT_UOFFSET = 0xA358; +const u16 C3DS_MAT_VOFFSET = 0xA35A; + +// subs of C3DS_EDIT_OBJECT +const u16 C3DS_OBJTRIMESH = 0x4100; + +// subs of C3DS_OBJTRIMESH +const u16 C3DS_TRIVERT = 0x4110; +const u16 C3DS_POINTFLAGARRAY= 0x4111; +const u16 C3DS_TRIFACE = 0x4120; +const u16 C3DS_TRIFACEMAT = 0x4130; +const u16 C3DS_TRIUV = 0x4140; +const u16 C3DS_TRISMOOTH = 0x4150; +const u16 C3DS_TRIMATRIX = 0x4160; +const u16 C3DS_MESHCOLOR = 0x4165; +const u16 C3DS_DIRECT_LIGHT = 0x4600; +const u16 C3DS_DL_INNER_RANGE= 0x4659; +const u16 C3DS_DL_OUTER_RANGE= 0x465A; +const u16 C3DS_DL_MULTIPLIER = 0x465B; +const u16 C3DS_CAMERA = 0x4700; +const u16 C3DS_CAM_SEE_CONE = 0x4710; +const u16 C3DS_CAM_RANGES = 0x4720; + +// subs of C3DS_KEYF3DS +const u16 C3DS_KF_HDR = 0xB00A; +const u16 C3DS_AMBIENT_TAG = 0xB001; +const u16 C3DS_OBJECT_TAG = 0xB002; +const u16 C3DS_CAMERA_TAG = 0xB003; +const u16 C3DS_TARGET_TAG = 0xB004; +const u16 C3DS_LIGHTNODE_TAG = 0xB005; +const u16 C3DS_KF_SEG = 0xB008; +const u16 C3DS_KF_CURTIME = 0xB009; +const u16 C3DS_KF_NODE_HDR = 0xB010; +const u16 C3DS_PIVOTPOINT = 0xB013; +const u16 C3DS_BOUNDBOX = 0xB014; +const u16 C3DS_POS_TRACK_TAG = 0xB020; +const u16 C3DS_ROT_TRACK_TAG = 0xB021; +const u16 C3DS_SCL_TRACK_TAG = 0xB022; +const u16 C3DS_NODE_ID = 0xB030; + +// different color chunk types +const u16 C3DS_COL_RGB = 0x0010; +const u16 C3DS_COL_TRU = 0x0011; +const u16 C3DS_COL_LIN_24 = 0x0012; +const u16 C3DS_COL_LIN_F = 0x0013; + +// percentage chunk types +const u16 C3DS_PERCENTAGE_I = 0x0030; +const u16 C3DS_PERCENTAGE_F = 0x0031; + + +//! Constructor +C3DSMeshFileLoader::C3DSMeshFileLoader(IMeshManipulator* manip,io::IFileSystem* fs, video::IVideoDriver* driver) +: FileSystem(fs), Driver(driver), Vertices(0), Indices(0), TCoords(0), + CountVertices(0), CountFaces(0), CountTCoords(0), Mesh(0), Manipulator(manip) +{ + TransformationMatrix.makeIdentity(); + if (FileSystem) + FileSystem->grab(); + + if (Driver) + Driver->grab(); +} + + + +//! destructor +C3DSMeshFileLoader::~C3DSMeshFileLoader() +{ + if (FileSystem) + FileSystem->drop(); + + if (Driver) + Driver->drop(); + + if (Vertices) + delete [] Vertices; + + if (Indices) + delete [] Indices; + + if (TCoords) + delete [] TCoords; + + if (Mesh) + Mesh->drop(); +} + + + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".bsp") +bool C3DSMeshFileLoader::isALoadableFileExtension(const c8* filename) +{ + return strstr(filename, ".3ds")!=0; +} + + + +//! creates/loads an animated mesh from the file. +//! \return Pointer to the created mesh. Returns 0 if loading failed. +//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). +//! See IUnknown::drop() for more information. +IAnimatedMesh* C3DSMeshFileLoader::createMesh(io::IReadFile* file) +{ + ChunkData data; + + readChunkData(file, data); + + if (data.header.id != C3DS_MAIN3DS ) + return false; + + CurrentMaterial.clear(); + Materials.clear(); + MeshBufferNames.clear(); + cleanUp(); + + if (Mesh) + Mesh->drop(); + + Mesh = new SMesh(); + + if (readChunk(file, &data)) + { + // success + SAnimatedMesh* am = new SAnimatedMesh(); + am->Type = EAMT_3DS; + + for (u32 i=0; igetMeshBufferCount(); ++i) + { + SMeshBuffer* mb = ((SMeshBuffer*)Mesh->getMeshBuffer(i)); + // drop empty buffers + if (mb->getIndexCount() == 0 || mb->getVertexCount() == 0) + { + Mesh->MeshBuffers.erase(i--); + mb->drop(); + } + else + mb->recalculateBoundingBox(); + } + + Mesh->recalculateBoundingBox(); + + am->addMesh(Mesh); + am->recalculateBoundingBox(); + Mesh->drop(); + Mesh = 0; + return am; + } + + Mesh->drop(); + Mesh = 0; + + return 0; +} + + +bool C3DSMeshFileLoader::readPercentageChunk(io::IReadFile* file, + ChunkData* chunk, f32& percentage) +{ + ChunkData data; + readChunkData(file, data); + + short intpercentage; + float fpercentage; + + switch(data.header.id) + { + case C3DS_PERCENTAGE_I: + { + // read short + file->read(&intpercentage, 2); +#ifdef __BIG_ENDIAN__ + intpercentage = os::Byteswap::byteswap(intpercentage); +#endif + percentage=intpercentage/100.0f; + data.read += 2; + } + break; + case C3DS_PERCENTAGE_F: + { + // read float + file->read(&fpercentage, sizeof(float)); + data.read += sizeof(float); +#ifdef __BIG_ENDIAN__ + percentage = os::Byteswap::byteswap(fpercentage); +#else + percentage = (f32)fpercentage; +#endif + } + break; + default: + { + // unknown percentage chunk + os::Printer::log("Unknown percentage chunk in 3Ds file.", ELL_WARNING); + file->seek(data.header.length - data.read, true); + data.read += data.header.length - data.read; + } + } + + chunk->read += data.read; + + return true; +} + +bool C3DSMeshFileLoader::readColorChunk(io::IReadFile* file, ChunkData* chunk, + video::SColor& out) +{ + ChunkData data; + readChunkData(file, data); + + u8 c[3]; + f32 cf[3]; + + switch(data.header.id) + { + case C3DS_COL_TRU: + case C3DS_COL_LIN_24: + { + // read 8 bit data + file->read(c, sizeof(c)); + out.set(255, c[0], c[1], c[2]); + data.read += sizeof(c); + } + break; + case C3DS_COL_RGB: + case C3DS_COL_LIN_F: + { + // read float data + file->read(cf, sizeof(cf)); +#ifdef __BIG_ENDIAN__ + cf[0] = os::Byteswap::byteswap(cf[0]); + cf[1] = os::Byteswap::byteswap(cf[1]); + cf[2] = os::Byteswap::byteswap(cf[2]); +#endif + out.set(255, (s32)(cf[0]*255.0f), (s32)(cf[1]*255.0f), (s32)(cf[2]*255.0f)); + data.read += sizeof(cf); + } + break; + default: + { + // unknown color chunk size + os::Printer::log("Unknown size of color chunk in 3Ds file.", ELL_WARNING); + file->seek(data.header.length - data.read, true); + data.read += data.header.length - data.read; + } + } + + chunk->read += data.read; + + return true; +} + + +bool C3DSMeshFileLoader::readMaterialChunk(io::IReadFile* file, ChunkData* parent) +{ + u16 matSection=0; + + while(parent->read < parent->header.length) + { + ChunkData data; + readChunkData(file, data); + + switch(data.header.id) + { + case C3DS_MATNAME: + { + c8* c = new c8[data.header.length - data.read]; + file->read(c, data.header.length - data.read); + + if (strlen(c)) + CurrentMaterial.Name = c; + + data.read += data.header.length - data.read; + delete [] c; + } + break; + case C3DS_MATAMBIENT: + readColorChunk(file, &data, CurrentMaterial.Material.AmbientColor); + break; + case C3DS_MATDIFFUSE: + readColorChunk(file, &data, CurrentMaterial.Material.DiffuseColor); + break; + case C3DS_MATSPECULAR: + readColorChunk(file, &data, CurrentMaterial.Material.SpecularColor); + break; + case C3DS_MATSHININESS: + readPercentageChunk(file, &data, CurrentMaterial.Material.Shininess); + break; + case C3DS_TRANSPARENCY: + { + f32 percentage; + readPercentageChunk(file, &data, percentage); + if (percentage>0.0f) + { + CurrentMaterial.Material.MaterialTypeParam=percentage; + CurrentMaterial.Material.MaterialType=video::EMT_TRANSPARENT_VERTEX_ALPHA; + } + else + { + CurrentMaterial.Material.MaterialType=video::EMT_SOLID; + } + } + break; + case C3DS_WIRE: + CurrentMaterial.Material.Wireframe=true; + break; + case C3DS_TWO_SIDE: + CurrentMaterial.Material.BackfaceCulling=false; + break; + case C3DS_SHADING: + { + s16 flags; + file->read(&flags, 2); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + switch (flags) + { + case 0: + CurrentMaterial.Material.Wireframe=true; + break; + case 1: + CurrentMaterial.Material.Wireframe=false; + CurrentMaterial.Material.GouraudShading=false; + break; + case 2: + CurrentMaterial.Material.Wireframe=false; + CurrentMaterial.Material.GouraudShading=true; + break; + default: + // phong and metal missing + break; + } + data.read += data.header.length - data.read; + } + break; + case C3DS_MATTEXMAP: + case C3DS_MATSPECMAP: + case C3DS_MATOPACMAP: + case C3DS_MATREFLMAP: + case C3DS_MATBUMPMAP: + { + matSection=data.header.id; +#if 0 // Should contain a percentage chunk, but does not work with the meshes + f32 percentage=0; + if (matSection!=C3DS_MATREFLMAP) + readPercentageChunk(file, &data, percentage); +#endif + } + break; + case C3DS_MATMAPFILE: + { + // read texture file name + c8* c = new c8[data.header.length - data.read]; + file->read(c, data.header.length - data.read); + if (matSection == C3DS_MATTEXMAP) + CurrentMaterial.Filename[0] = c; + else if (matSection == C3DS_MATSPECMAP) + CurrentMaterial.Filename[1] = c; + else if (matSection == C3DS_MATOPACMAP) + CurrentMaterial.Filename[2] = c; + else if (matSection == C3DS_MATREFLMAP) + CurrentMaterial.Filename[3] = c; + else if (matSection == C3DS_MATBUMPMAP) + CurrentMaterial.Filename[4] = c; + data.read += data.header.length - data.read; + delete [] c; + } + break; + case C3DS_MAT_TEXTILING: + { + s16 flags; + file->read(&flags, 2); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + data.read += 2; + } + break; + case C3DS_MAT_USCALE: + case C3DS_MAT_VSCALE: + case C3DS_MAT_UOFFSET: + case C3DS_MAT_VOFFSET: + { + f32 value; + file->read(&value, 4); +#ifdef __BIG_ENDIAN__ + value = os::Byteswap::byteswap(value); +#endif + data.read += 4; + } + break; + default: + // ignore chunk + file->seek(data.header.length - data.read, true); + data.read += data.header.length - data.read; + } + + parent->read += data.read; + } + + Materials.push_back(CurrentMaterial); + CurrentMaterial.clear(); + + return true; +} + + + +bool C3DSMeshFileLoader::readTrackChunk(io::IReadFile* file, ChunkData& data, + IMeshBuffer* mb, const core::vector3df& pivot) +{ + u16 flags; + u32 flags2; + // Track flags + file->read(&flags, 2); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + file->read(&flags2, 4); +#ifdef __BIG_ENDIAN__ + flags2 = os::Byteswap::byteswap(flags2); +#endif + file->read(&flags2, 4); +#ifdef __BIG_ENDIAN__ + flags2 = os::Byteswap::byteswap(flags2); +#endif + // Num keys + file->read(&flags2, 4); +#ifdef __BIG_ENDIAN__ + flags2 = os::Byteswap::byteswap(flags2); +#endif + file->read(&flags2, 4); +#ifdef __BIG_ENDIAN__ + flags2 = os::Byteswap::byteswap(flags2); +#endif + // TCB flags + file->read(&flags, 2); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + data.read += 20; + + f32 angle=0.0f; + if (data.header.id== C3DS_ROT_TRACK_TAG) + { + // Angle + file->read(&angle, sizeof(f32)); +#ifdef __BIG_ENDIAN__ + angle = os::Byteswap::byteswap(angle); +#endif + data.read += sizeof(f32); + } + core::vector3df vec; + file->read(&vec.X, sizeof(f32)); + file->read(&vec.Y, sizeof(f32)); + file->read(&vec.Z, sizeof(f32)); +#ifdef __BIG_ENDIAN__ + vec.X = os::Byteswap::byteswap(vec.X); + vec.Y = os::Byteswap::byteswap(vec.X); + vec.Z = os::Byteswap::byteswap(vec.X); +#endif + data.read += 12; + vec-=pivot; + + // apply transformation to mesh buffer + if (false)//mb) + { + video::S3DVertex *vertices=(video::S3DVertex*)mb->getVertices(); + if (data.header.id==C3DS_POS_TRACK_TAG) + { + for (u32 i=0; igetVertexCount(); ++i) + vertices[i].Pos+=vec; + } + else if (data.header.id==C3DS_ROT_TRACK_TAG) + { + //TODO + } + else if (data.header.id==C3DS_SCL_TRACK_TAG) + { + //TODO + } + } + // skip further frames + file->seek(data.header.length - data.read, true); + data.read += data.header.length - data.read; + return true; +} + + + +bool C3DSMeshFileLoader::readFrameChunk(io::IReadFile* file, ChunkData* parent) +{ + ChunkData data; + + //KF_HDR is always at the beginning + readChunkData(file, data); + if (data.header.id != C3DS_KF_HDR) + return false; + else + { + u16 flags; + file->read(&flags, 2); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + c8* c = new c8[data.header.length - data.read-4]; + file->read(c, data.header.length - data.read-4); + file->read(&flags, 2); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + + data.read += data.header.length - data.read; + parent->read += data.read; + delete [] c; + } + + IMeshBuffer* mb=0; + core::vector3df pivot,bboxCenter; + while(parent->read < parent->header.length) + { + readChunkData(file, data); + + switch(data.header.id) + { + case C3DS_OBJECT_TAG: + { + mb=0; + pivot.set(0.0f, 0.0f, 0.0f); + } + break; + case C3DS_KF_SEG: + { + u32 flags; + file->read(&flags, 4); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + file->read(&flags, 4); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + data.read += 8; + } + break; + case C3DS_KF_NODE_HDR: + { + s16 flags; + c8* c = new c8[data.header.length - data.read-6]; + file->read(c, data.header.length - data.read-6); + + // search mesh buffer to apply these transformations to + for (u32 i=0; igetMeshBuffer(i); + break; + } + } + + file->read(&flags, 2); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + file->read(&flags, 2); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + file->read(&flags, 2); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + data.read += data.header.length - data.read; + delete [] c; + } + break; + case C3DS_KF_CURTIME: + { + u32 flags; + file->read(&flags, 4); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + data.read += 4; + } + break; + case C3DS_NODE_ID: + { + u16 flags; + file->read(&flags, 2); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + data.read += 2; + } + break; + case C3DS_PIVOTPOINT: + { + file->read(&pivot.X, sizeof(f32)); + file->read(&pivot.Y, sizeof(f32)); + file->read(&pivot.Z, sizeof(f32)); +#ifdef __BIG_ENDIAN__ + pivot.X = os::Byteswap::byteswap(pivot.X); + pivot.Y = os::Byteswap::byteswap(pivot.Y); + pivot.Z = os::Byteswap::byteswap(pivot.Z); +#endif + data.read += 12; + } + break; + case C3DS_BOUNDBOX: + { + core::aabbox3df bbox; + // abuse bboxCenter as temporary variable + file->read(&bboxCenter.X, sizeof(f32)); + file->read(&bboxCenter.Y, sizeof(f32)); + file->read(&bboxCenter.Z, sizeof(f32)); +#ifdef __BIG_ENDIAN__ + bboxCenter.X = os::Byteswap::byteswap(bboxCenter.X); + bboxCenter.Y = os::Byteswap::byteswap(bboxCenter.Y); + bboxCenter.Z = os::Byteswap::byteswap(bboxCenter.Z); +#endif + bbox.reset(bboxCenter); + file->read(&bboxCenter.X, sizeof(f32)); + file->read(&bboxCenter.Y, sizeof(f32)); + file->read(&bboxCenter.Z, sizeof(f32)); +#ifdef __BIG_ENDIAN__ + bboxCenter.X = os::Byteswap::byteswap(bboxCenter.X); + bboxCenter.Y = os::Byteswap::byteswap(bboxCenter.Y); + bboxCenter.Z = os::Byteswap::byteswap(bboxCenter.Z); +#endif + bbox.addInternalPoint(bboxCenter); + bboxCenter=bbox.getCenter(); + data.read += 24; + } + break; + case C3DS_POS_TRACK_TAG: + case C3DS_ROT_TRACK_TAG: + case C3DS_SCL_TRACK_TAG: + readTrackChunk(file, data, mb, bboxCenter-pivot); + break; + default: + // ignore chunk + file->seek(data.header.length - data.read, true); + data.read += data.header.length - data.read; + } + + parent->read += data.read; + data.read=0; + } + + return true; +} + + + +bool C3DSMeshFileLoader::readChunk(io::IReadFile* file, ChunkData* parent) +{ + while(parent->read < parent->header.length) + { + ChunkData data; + readChunkData(file, data); + + switch(data.header.id) + { + case C3DS_VERSION: + { + u16 version; + file->read(&version, sizeof(u16)); +#ifdef __BIG_ENDIAN__ + version = os::Byteswap::byteswap(version); +#endif + file->seek(data.header.length - data.read - 2, true); + data.read += data.header.length - data.read; + if (version != 0x03) + os::Printer::log("3ds file version is other than 3.", ELL_ERROR); + } + break; + case C3DS_EDIT_MATERIAL: + readMaterialChunk(file, &data); + break; + case C3DS_KEYF3DS: + readFrameChunk(file, &data); + break; + case C3DS_EDIT3DS: + break; + case C3DS_MESHVERSION: + case 0x01: + { + u32 version; + file->read(&version, sizeof(u32)); +#ifdef __BIG_ENDIAN__ + version = os::Byteswap::byteswap(version); +#endif + data.read += sizeof(u32); + } + break; + case C3DS_EDIT_OBJECT: + { + core::stringc name; + readString(file, data, name); + readObjectChunk(file, &data); + composeObject(file, name); + } + break; + + default: + // ignore chunk + file->seek(data.header.length - data.read, true); + data.read += data.header.length - data.read; + } + + parent->read += data.read; + } + + return true; +} + + + +bool C3DSMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData* parent) +{ + while(parent->read < parent->header.length) + { + ChunkData data; + readChunkData(file, data); + + switch(data.header.id) + { + case C3DS_OBJTRIMESH: + readObjectChunk(file, &data); + break; + + case C3DS_TRIVERT: + readVertices(file, data); + break; + + case C3DS_POINTFLAGARRAY: + { + u16 numVertex, flags; + file->read(&numVertex, sizeof(u16)); +#ifdef __BIG_ENDIAN__ + numVertex= os::Byteswap::byteswap(numVertex); +#endif + for (u16 i=0; iread(&flags, sizeof(u16)); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + } + data.read += (numVertex+1)*sizeof(u16); + } + break; + + case C3DS_TRIFACE: + readIndices(file, data); + readObjectChunk(file, &data); // read smooth and material groups + break; + + case C3DS_TRIFACEMAT: + readMaterialGroup(file, data); + break; + + case C3DS_TRIUV: // getting texture coordinates + readTextureCoords(file, data); + break; + + case C3DS_TRIMATRIX: + { + f32 mat[4][3]; + file->read(&mat, 12*sizeof(f32)); + TransformationMatrix.makeIdentity(); + for (int i=0; i<4; ++i) + { + for (int j=0; j<3; ++j) + { +#ifdef __BIG_ENDIAN__ + TransformationMatrix(i,j)=os::Byteswap::byteswap(mat[i][j]); +#else + TransformationMatrix(i,j)=mat[i][j]; +#endif + } + } + data.read += 12*sizeof(f32); + } + break; + case C3DS_MESHCOLOR: + { + u8 flag; + file->read(&flag, sizeof(u8)); + ++data.read; + } + break; + case C3DS_TRISMOOTH: // TODO + { + u32 flags; + for (u16 i=0; iread(&flags, sizeof(u32)); +#ifdef __BIG_ENDIAN__ + for (u16 i=0; iseek(data.header.length - data.read, true); + data.read += data.header.length - data.read; + } + + parent->read += data.read; + } + + return true; +} + + +void C3DSMeshFileLoader::composeObject(io::IReadFile* file, const core::stringc& name) +{ + if (Mesh->getMeshBufferCount() != Materials.size()) + loadMaterials(file); + + if (MaterialGroups.empty()) + { + // no material group, so add all + SMaterialGroup group; + group.faceCount = CountFaces; + group.faces = new s16[group.faceCount]; + for (int i=0; iaddMeshBuffer(mb); + mb->Material = Materials[0].Material; + mb->drop(); + // add an empty mesh buffer name + core::stringc c = ""; + MeshBufferNames.push_back(c); + } + } + + for (u32 i=0; igetMaximalPrimitiveCount(), (u32)((1<<16)-1))-3; // currently hardcoded s16 max value for index pointers + + // find mesh buffer for this group + for (mbPos=0; mbPosgetMeshBuffer(mbPos); + mat=&Materials[mbPos].Material; + MeshBufferNames[mbPos]=name; + break; + } + } + + if (mb != 0) + { + // add geometry to the buffer. + + video::S3DVertex vtx; + core::vector3df vec; + vtx.Color=mat->DiffuseColor; + if (mat->MaterialType==video::EMT_TRANSPARENT_VERTEX_ALPHA) + { + vtx.Color.setAlpha((int)(255.0f*mat->MaterialTypeParam)); + } + vtx.Normal.set(0,0,0); + + for (s32 f=0; fVertices.size(); + if (vtxCount>maxPrimitives) + { + Mesh->addMeshBuffer(new SMeshBuffer()); + IMeshBuffer* tmp = mb; + mb=(SMeshBuffer*)(Mesh->MeshBuffers[mbPos]=Mesh->MeshBuffers.getLast()); + Mesh->MeshBuffers[Mesh->MeshBuffers.size()-1]=tmp; + mb->Material=*mat; + vtxCount=0; + } + + for (s32 v=0; v<3; ++v) + { + s32 idx = Indices[MaterialGroups[i].faces[f]*4 +v]; + + if (CountVertices > idx) + { + vtx.Pos.X = Vertices[idx*3 + 0]; + vtx.Pos.Z = Vertices[idx*3 + 1]; + vtx.Pos.Y = Vertices[idx*3 + 2]; +// TransformationMatrix.transformVect(vtx.Pos); + } + + if (CountTCoords > idx) + { + vtx.TCoords.X = TCoords[idx*2 + 0]; + vtx.TCoords.Y = 1.0f -TCoords[idx*2 + 1]; + } + + mb->Vertices.push_back(vtx); + } + + // compute normal + core::plane3d pl(mb->Vertices[vtxCount].Pos, mb->Vertices[vtxCount+2].Pos, + mb->Vertices[vtxCount+1].Pos); + + mb->Vertices[vtxCount].Normal = pl.Normal; + mb->Vertices[vtxCount+1].Normal = pl.Normal; + mb->Vertices[vtxCount+2].Normal = pl.Normal; + + // add indices + + mb->Indices.push_back(vtxCount); + mb->Indices.push_back(vtxCount+2); + mb->Indices.push_back(vtxCount+1); + } + } + else + os::Printer::log("Found no matching material for Group in 3ds file.", ELL_WARNING); + } + + cleanUp(); +} + + +core::stringc C3DSMeshFileLoader::getTextureFileName(const core::stringc& texture, + core::stringc& model) +{ + s32 idx = -1; + idx = model.findLast('/'); + + if (idx == -1) + idx = model.findLast('\\'); + + if (idx == -1) + return core::stringc(); + + core::stringc p = model.subString(0, idx+1); + p.append(texture); + return p; +} + + +void C3DSMeshFileLoader::loadMaterials(io::IReadFile* file) +{ + // create a mesh buffer for every material + core::stringc modelFilename = file->getFileName(); + + if (Materials.empty()) + os::Printer::log("No materials found in 3ds file.", ELL_INFORMATION); + + MeshBufferNames.reallocate(Materials.size()); + for (u32 i=0; iaddMeshBuffer(m); + + m->Material = Materials[i].Material; + if (Materials[i].Filename[0].size()) + { + m->Material.Textures[0] = Driver->getTexture(Materials[i].Filename[0].c_str()); + + if (!m->Material.Textures[0]) + { + core::stringc fname = getTextureFileName( + Materials[i].Filename[0], modelFilename); + if (fname.size()) + m->Material.Textures[0] = Driver->getTexture(fname.c_str()); + } + + if (!m->Material.Textures[0]) + os::Printer::log("Could not load a texture for entry in 3ds file", + Materials[i].Filename[0].c_str(), ELL_WARNING); + } + + if (Materials[i].Filename[2].size()) + { + m->Material.Textures[0] = Driver->getTexture(Materials[i].Filename[2].c_str()); + + if (!m->Material.Textures[0]) + { + core::stringc fname = getTextureFileName( + Materials[i].Filename[2], modelFilename); + if (fname.size()) + m->Material.Textures[0] = Driver->getTexture(fname.c_str()); + } + + if (!m->Material.Textures[0]) + { + os::Printer::log("Could not load a texture for entry in 3ds file", + Materials[i].Filename[2].c_str(), ELL_WARNING); + } + else + { + m->Material.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR; + } + } + + if (Materials[i].Filename[3].size()) + { + m->Material.Textures[1]=m->Material.Textures[0]; + m->Material.Textures[0]=0; + m->Material.Textures[0] = Driver->getTexture(Materials[i].Filename[3].c_str()); + + if (!m->Material.Textures[0]) + { + core::stringc fname = getTextureFileName( + Materials[i].Filename[3], modelFilename); + if (fname.size()) + m->Material.Textures[0] = Driver->getTexture(fname.c_str()); + } + + if (!m->Material.Textures[0]) + { + os::Printer::log("Could not load a texture for entry in 3ds file", + Materials[i].Filename[3].c_str(), ELL_WARNING); + m->Material.Textures[0]=m->Material.Textures[1]; + m->Material.Textures[1]=0; + } + else + { + m->Material.MaterialType=video::EMT_REFLECTION_2_LAYER; + } + } + + if (Materials[i].Filename[4].size()) + { + m->Material.Textures[1] = Driver->getTexture(Materials[i].Filename[4].c_str()); + + if (!m->Material.Textures[1]) + { + core::stringc fname = getTextureFileName( + Materials[i].Filename[4], modelFilename); + if (fname.size()) + m->Material.Textures[1] = Driver->getTexture(fname.c_str()); + } + + if (!m->Material.Textures[1]) + os::Printer::log("Could not load a texture for entry in 3ds file", + Materials[i].Filename[4].c_str(), ELL_WARNING); + else + { + Driver->makeNormalMapTexture(m->Material.Textures[1], 9.0f); + m->Material.MaterialType=video::EMT_PARALLAX_MAP_SOLID; + m->Material.MaterialTypeParam=0.035f; + } + } + + m->drop(); + } +} + + +void C3DSMeshFileLoader::cleanUp() +{ + delete [] Vertices; + CountVertices = 0; + Vertices = 0; + delete [] Indices; + Indices = 0; + CountFaces = 0; + delete [] TCoords; + TCoords = 0; + CountTCoords = 0; + + MaterialGroups.clear(); +} + + + + +void C3DSMeshFileLoader::readTextureCoords(io::IReadFile* file, ChunkData& data) +{ + file->read(&CountTCoords, sizeof(CountTCoords)); +#ifdef __BIG_ENDIAN__ + CountTCoords = os::Byteswap::byteswap(CountTCoords); +#endif + data.read += sizeof(CountTCoords); + + s32 tcoordsBufferByteSize = CountTCoords * sizeof(f32) * 2; + + if (data.header.length - data.read != tcoordsBufferByteSize) + { + os::Printer::log("Invalid size of tcoords found in 3ds file.", ELL_WARNING); + return; + } + + TCoords = new f32[CountTCoords * 3]; + file->read(TCoords, tcoordsBufferByteSize); +#ifdef __BIG_ENDIAN__ + for (int i=0;iread(&group.faceCount, sizeof(group.faceCount)); +#ifdef __BIG_ENDIAN__ + group.faceCount = os::Byteswap::byteswap(group.faceCount); +#endif + data.read += sizeof(group.faceCount); + + // read faces + group.faces = new s16[group.faceCount]; + file->read(group.faces, sizeof(s16) * group.faceCount); +#ifdef __BIG_ENDIAN__ + for (int i=0;iread(&CountFaces, sizeof(CountFaces)); +#ifdef __BIG_ENDIAN__ + CountFaces = os::Byteswap::byteswap(CountFaces); +#endif + data.read += sizeof(CountFaces); + + s32 indexBufferByteSize = CountFaces * sizeof(u16) * 4; + + // Indices are u16s. + // After every 3 Indices in the array, there follows an edge flag. + Indices = new u16[CountFaces * 4]; + file->read(Indices, indexBufferByteSize); +#ifdef __BIG_ENDIAN__ + for (int i=0;iread(&CountVertices, sizeof(CountVertices)); +#ifdef __BIG_ENDIAN__ + CountVertices = os::Byteswap::byteswap(CountVertices); +#endif + data.read += sizeof(CountVertices); + + s32 vertexBufferByteSize = CountVertices * sizeof(f32) * 3; + + if (data.header.length - data.read != vertexBufferByteSize) + { + os::Printer::log("Invalid size of vertices found in 3ds file.", ELL_WARNING); + return; + } + + Vertices = new f32[CountVertices * 3]; + file->read(Vertices, vertexBufferByteSize); +#ifdef __BIG_ENDIAN__ + for (int i=0;iread(&data.header, sizeof(ChunkHeader)); +#ifdef __BIG_ENDIAN__ + data.header.id = os::Byteswap::byteswap(data.header.id); + data.header.length = os::Byteswap::byteswap(data.header.length); +#endif + data.read += sizeof(ChunkHeader); +} + + +void C3DSMeshFileLoader::readString(io::IReadFile* file, ChunkData& data, core::stringc& out) +{ + c8 c = 1; + out = ""; + + while (c) + { + file->read(&c, sizeof(c8)); + if (c) + out.append(c); + + ++data.read; + } +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/C3DSMeshFileLoader.h b/src/dep/src/irrlicht/C3DSMeshFileLoader.h index ee85e49..3279e77 100644 --- a/src/dep/src/irrlicht/C3DSMeshFileLoader.h +++ b/src/dep/src/irrlicht/C3DSMeshFileLoader.h @@ -1,180 +1,180 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_3DS_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_3DS_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "irrString.h" -#include "SMesh.h" -#include "IMeshManipulator.h" -#include "matrix4.h" - -namespace irr -{ -namespace scene -{ - -//! Meshloader capable of loading 3ds meshes. -class C3DSMeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - C3DSMeshFileLoader(IMeshManipulator* manip,io::IFileSystem* fs, video::IVideoDriver* driver); - - //! destructor - virtual ~C3DSMeshFileLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".cob") - virtual bool isALoadableFileExtension(const c8* fileName); - - //! creates/loads an animated mesh from the file. - //! \return Pointer to the created mesh. Returns 0 if loading failed. - //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). - //! See IUnknown::drop() for more information. - virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); - -private: - - // byte-align structures - #ifdef _MSC_VER - # pragma pack( push, packing ) - # pragma pack( 1 ) - # define PACK_STRUCT - #elif defined( __GNUC__ ) - # define PACK_STRUCT __attribute__((packed)) - #else - # error compiler not supported - #endif - - struct ChunkHeader - { - u16 id; - s32 length; - } PACK_STRUCT; - - // Default alignment - #ifdef _MSC_VER - # pragma pack( pop, packing ) - #endif - - #undef PACK_STRUCT - - - struct ChunkData - { - ChunkData() : read(0) {} - - ChunkHeader header; - s32 read; - }; - - struct SCurrentMaterial - { - SCurrentMaterial() {}; - - ~SCurrentMaterial() { }; - - void clear() { - Material=video::SMaterial(); - Name=""; - Filename[0]=""; - Filename[1]=""; - Filename[2]=""; - Filename[3]=""; - Filename[4]=""; - } - - video::SMaterial Material; - core::stringc Name; - core::stringc Filename[5]; - }; - - struct SMaterialGroup - { - SMaterialGroup() : faceCount(0), faces(0) {}; - - SMaterialGroup(const SMaterialGroup& o) - { - *this = o; - } - - ~SMaterialGroup() - { - clear(); - } - - void clear() - { - if (faces) delete [] faces; - faces = 0; - faceCount = 0; - } - - void operator =(const SMaterialGroup& o) - { - MaterialName = o.MaterialName; - faceCount = o.faceCount; - faces = new s16[faceCount]; - for (s32 i=0; i TempIndices; - f32* TCoords; - u16 CountVertices; - u16 CountFaces; // = CountIndices/4 - u16 CountTCoords; - core::array MaterialGroups; - - SCurrentMaterial CurrentMaterial; - core::array Materials; - core::array MeshBufferNames; - core::matrix4 TransformationMatrix; - - SMesh* Mesh; - - IMeshManipulator* Manipulator; -}; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_3DS_MESH_FILE_LOADER_H_INCLUDED__ +#define __C_3DS_MESH_FILE_LOADER_H_INCLUDED__ + +#include "IMeshLoader.h" +#include "IFileSystem.h" +#include "IVideoDriver.h" +#include "irrString.h" +#include "SMesh.h" +#include "IMeshManipulator.h" +#include "matrix4.h" + +namespace irr +{ +namespace scene +{ + +//! Meshloader capable of loading 3ds meshes. +class C3DSMeshFileLoader : public IMeshLoader +{ +public: + + //! Constructor + C3DSMeshFileLoader(IMeshManipulator* manip,io::IFileSystem* fs, video::IVideoDriver* driver); + + //! destructor + virtual ~C3DSMeshFileLoader(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".cob") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! creates/loads an animated mesh from the file. + //! \return Pointer to the created mesh. Returns 0 if loading failed. + //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). + //! See IUnknown::drop() for more information. + virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); + +private: + + // byte-align structures + #ifdef _MSC_VER + # pragma pack( push, packing ) + # pragma pack( 1 ) + # define PACK_STRUCT + #elif defined( __GNUC__ ) + # define PACK_STRUCT __attribute__((packed)) + #else + # error compiler not supported + #endif + + struct ChunkHeader + { + u16 id; + s32 length; + } PACK_STRUCT; + + // Default alignment + #ifdef _MSC_VER + # pragma pack( pop, packing ) + #endif + + #undef PACK_STRUCT + + + struct ChunkData + { + ChunkData() : read(0) {} + + ChunkHeader header; + s32 read; + }; + + struct SCurrentMaterial + { + SCurrentMaterial() {}; + + ~SCurrentMaterial() { }; + + void clear() { + Material=video::SMaterial(); + Name=""; + Filename[0]=""; + Filename[1]=""; + Filename[2]=""; + Filename[3]=""; + Filename[4]=""; + } + + video::SMaterial Material; + core::stringc Name; + core::stringc Filename[5]; + }; + + struct SMaterialGroup + { + SMaterialGroup() : faceCount(0), faces(0) {}; + + SMaterialGroup(const SMaterialGroup& o) + { + *this = o; + } + + ~SMaterialGroup() + { + clear(); + } + + void clear() + { + if (faces) delete [] faces; + faces = 0; + faceCount = 0; + } + + void operator =(const SMaterialGroup& o) + { + MaterialName = o.MaterialName; + faceCount = o.faceCount; + faces = new s16[faceCount]; + for (s32 i=0; i TempIndices; + f32* TCoords; + u16 CountVertices; + u16 CountFaces; // = CountIndices/4 + u16 CountTCoords; + core::array MaterialGroups; + + SCurrentMaterial CurrentMaterial; + core::array Materials; + core::array MeshBufferNames; + core::matrix4 TransformationMatrix; + + SMesh* Mesh; + + IMeshManipulator* Manipulator; +}; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CAnimatedMeshB3d.cpp b/src/dep/src/irrlicht/CAnimatedMeshB3d.cpp index 1dea487..3760729 100644 --- a/src/dep/src/irrlicht/CAnimatedMeshB3d.cpp +++ b/src/dep/src/irrlicht/CAnimatedMeshB3d.cpp @@ -1,1956 +1,1956 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// B3D file loader by Luke Hoschke, File format by Mark Sibly - -#include "CAnimatedMeshB3d.h" -#include "os.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace scene -{ - - -struct B3dChunkHeader -{ - c8 name[4]; - s32 size; -}; - - -//! constructor -CAnimatedMeshB3d::CAnimatedMeshB3d(video::IVideoDriver* driver) -: Driver(driver) -{ - if (Driver) - Driver->grab(); -} - - -//! destructor -CAnimatedMeshB3d::~CAnimatedMeshB3d() -{ - - if (Driver) - Driver->drop(); - - s32 n; - for (n=BaseVertices.size()-1; n>=0; --n) - { - delete BaseVertices[n]; - BaseVertices.erase(n); - } - - for (n=Buffers.size()-1; n>=0; --n) - { - delete Buffers[n]; - Buffers.erase(n); - } - - for (n=Materials.size()-1; n>=0; --n) - { - if (Materials[n].Material) - delete Materials[n].Material; - Materials.erase(n); - } - - for (n=Nodes.size()-1; n>=0; --n) - { - delete Nodes[n]; - Nodes.erase(n); - } - -} - - - -core::stringc CAnimatedMeshB3d::readString(io::IReadFile* file) -{ - core::stringc newstring; - - while (file->getPos() <= file->getSize() ) - { - c8 character; - file->read(&character, sizeof(character)); - - if (character==0) - return newstring; - - newstring.append(character); - } - return newstring; -} - - - -core::stringc CAnimatedMeshB3d::stripPathString(core::string oldstring, bool keepPath) -{ - s32 lastA=oldstring.findLast('/'); // forward slash - s32 lastB=oldstring.findLast('\\'); // back slash - - if (!keepPath) - { - if (lastA==-1 && lastB==-1) - return oldstring; - } - else - { - if (lastA==-1 && lastB==-1) - return core::stringc(); - } - - - if (lastA > lastB) - { - if (!keepPath) - return oldstring.subString(lastA+1, oldstring.size() - (lastA+1)); - else - return oldstring.subString(0, lastA + 1); - } - else - { - if (!keepPath) - return oldstring.subString(lastB+1, oldstring.size() - (lastB+1)); - else - return oldstring.subString(0, lastB + 1); - } -} - - - -void CAnimatedMeshB3d::readFloats(io::IReadFile* file, f32* vec, u32 count) -{ - file->read(vec, count*sizeof(f32)); - #ifdef __BIG_ENDIAN__ - for (u32 n=0; ngetTextureCreationFlag(video::ETCF_ALWAYS_32_BIT); - - Driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true); - - - while(B3dStack.getLast().startposition + B3dStack.getLast().length>file->getPos()) //this chunk repeats - { - core::stringc TextureName=readString(file); - - TextureName=stripPathString(file->getFileName(),true) + stripPathString(TextureName,false); - - SB3dTexture B3dTexture; - - B3dTexture.Texture=Driver->getTexture ( TextureName.c_str() ); - - file->read(&B3dTexture.Flags, sizeof(s32)); - file->read(&B3dTexture.Blend, sizeof(s32)); - readFloats(file, &B3dTexture.Xpos, 1); - readFloats(file, &B3dTexture.Ypos, 1); - readFloats(file, &B3dTexture.Xscale, 1); - readFloats(file, &B3dTexture.Yscale, 1); - readFloats(file, &B3dTexture.Angle, 1); - - #ifdef __BIG_ENDIAN__ - B3dTexture.Flags = os::Byteswap::byteswap(B3dTexture.Flags); - B3dTexture.Blend = os::Byteswap::byteswap(B3dTexture.Blend); - #endif - - Textures.push_back(B3dTexture); - - /* - Flags: - 1: Color (default) - 2: Alpha - 4: Masked - 8: Mipmapped - 16: Clamp U - 32: Clamp V - 64: Spherical environment map - 128: Cubic environment map - 256: Store texture in vram - 512: Force the use of high color textures - 65536: texture uses secondary UV values - - Blend: - 0: Do not blend - 1: No blend, or Alpha (alpha when texture loaded with alpha flag - not recommended for multitexturing - see below) - 2: Multiply (default) - 3: Add - 4: Dot3 - 5: Multiply 2 - */ - } - - B3dStack.erase(B3dStack.size()-1); - - Driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, Previous32BitTextureFlag); - - return true; -} - - - - -bool CAnimatedMeshB3d::ReadChunkBRUS(io::IReadFile* file) -{ - - s32 n_texs; - - file->read(&n_texs, sizeof(s32)); - - #ifdef __BIG_ENDIAN__ - n_texs = os::Byteswap::byteswap(n_texs); - #endif - - while(B3dStack.getLast().startposition + B3dStack.getLast().length>file->getPos()) //this chunk repeats - { - // This is what blitz basic calls a brush, like a Irrlicht Material - core::stringc MaterialName=readString(file); //Not used but we still need the read it - - SB3dMaterial B3dMaterial; - - B3dMaterial.Material = new irr::video::SMaterial(); - - B3dMaterial.Textures[0]=0; - B3dMaterial.Textures[1]=0; - - s32 texture_id[8]; - texture_id[0]=-1; - texture_id[1]=-1; - - file->read(&B3dMaterial.red, sizeof(B3dMaterial.red)); - file->read(&B3dMaterial.green, sizeof(B3dMaterial.green)); - file->read(&B3dMaterial.blue, sizeof(B3dMaterial.blue)); - file->read(&B3dMaterial.alpha, sizeof(B3dMaterial.alpha)); - file->read(&B3dMaterial.shininess, sizeof(B3dMaterial.shininess)); - file->read(&B3dMaterial.blend, sizeof(B3dMaterial.blend)); - file->read(&B3dMaterial.fx, sizeof(B3dMaterial.fx)); - - for (s32 n=0; n < n_texs; ++n) - { - file->read(&texture_id[n], sizeof(s32)); //I'm not sure of getting the sizeof an array - //cout << "Material is using texture id:"<< texture_id[n] <Textures[0] = B3dMaterial.Textures[0]->Texture; - if (B3dMaterial.Textures[1] != 0) - B3dMaterial.Material->Textures[1] = B3dMaterial.Textures[1]->Texture; - - //the other textures are skipped, irrlicht I think can only have 2 Textures per Material - - if (B3dMaterial.Textures[1] != 0 && B3dMaterial.Textures[0] == 0) //It could happen - { - B3dMaterial.Textures[0] = B3dMaterial.Textures[1]; - B3dMaterial.Textures[1] = 0; - } - - //Hacky code to convert blitz fx to irrlicht... - if (B3dMaterial.Textures[1]) //Two textures - { - if (B3dMaterial.alpha==1) - { - if (B3dMaterial.Textures[1]->Blend & 5) - { - //B3dMaterial.Material->MaterialType = video::EMT_LIGHTMAP; - B3dMaterial.Material->MaterialType = video::EMT_LIGHTMAP_M2 ; - } - else - { - B3dMaterial.Material->MaterialType = video::EMT_LIGHTMAP; - } - } - else - { - //B3dMaterial.Material->MaterialType = video::EMT_LIGHTMAP; - //B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - //B3dMaterial.Material->MaterialTypeParam=B3dMaterial.alpha; - B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - } - } - else if (B3dMaterial.Textures[0]) //one texture - { - if (B3dMaterial.Textures[0]->Flags & 2) // Alpha mapped - { - B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - } - else if (B3dMaterial.Textures[0]->Flags & 4) // Masked - { - // Not working like blitz basic, because Irrlicht is using alpha to mask, not colour like blitz basic - - B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; - - } - else if (B3dMaterial.alpha == 1) - { - B3dMaterial.Material->MaterialType = video::EMT_SOLID; - } - else - { - //B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - //B3dMaterial.Material->MaterialTypeParam=B3dMaterial.alpha; - B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - } - } - else //No texture - { - - if (B3dMaterial.alpha == 1) - { - B3dMaterial.Material->MaterialType = video::EMT_SOLID; - } - else - { - B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - } - } - - - if (B3dMaterial.fx & 32) //force vertex alpha-blending - { - B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - //B3dMaterial.Material->Lighting=false; - } - - - // Material fx... - - if (B3dMaterial.fx & 1) //full-bright - { - //B3dMaterial.Material->AmbientColor = video::SColor(1, 1, 1, 1).toSColor (); - B3dMaterial.Material->AmbientColor = video::SColor(255, 255, 255, 255); - //B3dMaterial.Material->EmissiveColor = video::SColorf(1, 1, 1, 0).toSColor ();//Would be too bright and brighter than blitz basic - B3dMaterial.Material->Lighting = false; - } - else - { - B3dMaterial.Material->AmbientColor = video::SColorf(B3dMaterial.red, B3dMaterial.green, B3dMaterial.blue, B3dMaterial.alpha).toSColor (); - } - - if (B3dMaterial.fx & 4) //flatshaded - B3dMaterial.Material->GouraudShading = false; - - if (B3dMaterial.fx & 16) //disable backface culling - B3dMaterial.Material->BackfaceCulling = false; - - - B3dMaterial.Material->DiffuseColor = video::SColorf(B3dMaterial.red, B3dMaterial.green, B3dMaterial.blue, B3dMaterial.alpha).toSColor (); - B3dMaterial.Material->EmissiveColor = video::SColorf(0.5, 0.5, 0.5, 0).toSColor (); //Thoughts, I'm no sure what I should set it to? - //B3dMaterial.Material->SpecularColor = video::SColorf(0, 0, 0, 0).toSColor (); //? - B3dMaterial.Material->Shininess = B3dMaterial.shininess; - - Materials.push_back(B3dMaterial); - } - - B3dStack.erase(B3dStack.size()-1); - - return true; -} - - - -bool CAnimatedMeshB3d::ReadChunkMESH(io::IReadFile* file, SB3dNode *InNode) -{ - - s32 Vertices_Start=BaseVertices.size(); //B3Ds have Vertex ID's local within the mesh I don't want this - - s32 brush_id; - - file->read(&brush_id, sizeof(brush_id)); - - #ifdef __BIG_ENDIAN__ - brush_id = os::Byteswap::byteswap(brush_id); - #endif - - NormalsInFile=false; - - - - while(B3dStack.getLast().startposition + B3dStack.getLast().length>file->getPos()) //this chunk repeats - { - - B3dStack.push_back(B3dChunk()); - - B3dChunkHeader header; - file->read(&header, sizeof(header)); - - #ifdef __BIG_ENDIAN__ - header.size = os::Byteswap::byteswap(header.size); - #endif - - B3dStack.getLast().name[0]=header.name[0]; - B3dStack.getLast().name[1]=header.name[1]; //Not sure of an easier way - B3dStack.getLast().name[2]=header.name[2]; - B3dStack.getLast().name[3]=header.name[3]; - - B3dStack.getLast().length = header.size + 8; - - B3dStack.getLast().startposition = file->getPos() - 8; - - bool read=false; - - if ( strncmp( B3dStack.getLast().name, "VRTS", 4 ) == 0 ) - { - read=true; - if (!ReadChunkVRTS(file,InNode ,0, Vertices_Start)) - return false; - } - else if ( strncmp( B3dStack.getLast().name, "TRIS", 4 ) == 0 ) - { - read=true; - - SB3DMeshBuffer *MeshBuffer = new SB3DMeshBuffer(); - MeshBuffer->VertexType=video::EVT_STANDARD; - - if (brush_id!=-1) - MeshBuffer->Material=(*Materials[brush_id].Material); - - if(ReadChunkTRIS(file,InNode ,MeshBuffer, Vertices_Start)==false) - return false; - - MeshBuffer->recalculateBoundingBox(); - - if (!NormalsInFile && MeshBuffer->Material.Lighting) // No point wasting time of lightmapped levels - { - s32 i; - - for ( i=0; i<(s32)MeshBuffer->Indices.size(); i+=3) - { - core::plane3d p( MeshBuffer->getVertex(MeshBuffer->Indices[i+0])->Pos, - MeshBuffer->getVertex(MeshBuffer->Indices[i+1])->Pos, - MeshBuffer->getVertex(MeshBuffer->Indices[i+2])->Pos); - - MeshBuffer->getVertex(MeshBuffer->Indices[i+0])->Normal += p.Normal; - MeshBuffer->getVertex(MeshBuffer->Indices[i+1])->Normal += p.Normal; - MeshBuffer->getVertex(MeshBuffer->Indices[i+2])->Normal += p.Normal; - } - - for ( i = 0; i<(s32)MeshBuffer->getVertexCount(); ++i ) - { - MeshBuffer->getVertex(i)->Normal.normalize (); - BaseVertices[Vertices_Start+i]->Normal=MeshBuffer->getVertex(i)->Normal; - } - } - - Buffers.push_back(MeshBuffer); - - } - - if (!read) - { - os::Printer::log("Unknown chunk found in mesh - skipping"); - file->seek( (B3dStack.getLast().startposition + B3dStack.getLast().length) , false); - B3dStack.erase(B3dStack.size()-1); - } - } - - - B3dStack.erase(B3dStack.size()-1); - - return true; -} - -/* -VRTS: - int flags ;1=normal values present, 2=rgba values present - int tex_coord_sets ;texture coords per vertex (eg: 1 for simple U/V) max=8 - int tex_coord_set_size ;components per set (eg: 2 for simple U/V) max=4 - { - float x,y,z ;always present - float nx,ny,nz ;vertex normal: present if (flags&1) - float red,green,blue,alpha ;vertex color: present if (flags&2) - float tex_coords[tex_coord_sets][tex_coord_set_size] ;tex coords - } -*/ - -bool CAnimatedMeshB3d::ReadChunkVRTS(io::IReadFile* file, SB3dNode *InNode, SB3DMeshBuffer *MeshBuffer,s32 Vertices_Start) -{ - - s32 flags, tex_coord_sets, tex_coord_set_size; - - file->read(&flags, sizeof(flags)); - file->read(&tex_coord_sets, sizeof(tex_coord_sets)); - file->read(&tex_coord_set_size, sizeof(tex_coord_set_size)); - - #ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); - tex_coord_sets = os::Byteswap::byteswap(tex_coord_sets); - tex_coord_set_size = os::Byteswap::byteswap(tex_coord_set_size); - #endif - - if (tex_coord_sets >= 3 || tex_coord_set_size >= 4) // Something is wrong - { - os::Printer::log("tex_coord_sets or tex_coord_set_size too big", file->getFileName(), ELL_ERROR); - return false; - } - - //------ Allocate Memory, for speed -----------// - - s32 MemoryNeeded = B3dStack.getLast().length / sizeof(f32); - s32 NumberOfReads = 3; - - if (flags & 1) NumberOfReads += 3; - if (flags & 2) NumberOfReads += 4; - - for (s32 i=0; i file->getPos()) // this chunk repeats - { - f32 x=0.0f, y=0.0f, z=0.0f; - f32 nx=0.0f, ny=0.0f, nz=0.0f; - f32 red=1.0f, green=1.0f, blue=1.0f, alpha=1.0f; - f32 tex_coords[3][4]; - - file->read(&x, sizeof(x)); - file->read(&y, sizeof(y)); - file->read(&z, sizeof(z)); - - if (flags & 1) - { - NormalsInFile = true; - file->read(&nx, sizeof(nx)); - file->read(&ny, sizeof(ny)); - file->read(&nz, sizeof(nz)); - } - - if (flags & 2) - { - file->read(&red, sizeof(red)); - file->read(&green, sizeof(green)); - file->read(&blue, sizeof(blue)); - file->read(&alpha, sizeof(alpha)); - } - - for (s32 i=0; iread(&tex_coords[i][j], sizeof(f32)); - - #ifdef __BIG_ENDIAN__ - x = os::Byteswap::byteswap(x); - y = os::Byteswap::byteswap(y); - z = os::Byteswap::byteswap(z); - - if (flags&1) - { - nx = os::Byteswap::byteswap(nx); - ny = os::Byteswap::byteswap(ny); - nz = os::Byteswap::byteswap(nz); - } - - if (flags & 2) - { - red = os::Byteswap::byteswap(red); - green = os::Byteswap::byteswap(green); - blue = os::Byteswap::byteswap(blue); - alpha = os::Byteswap::byteswap(alpha); - } - - for (s32 i=0; i<=tex_coord_sets-1; i++) - for (s32 j=0; j<=tex_coord_set_size-1; j++) - tex_coords[i][j] = os::Byteswap::byteswap(tex_coords[i][j]); - #endif - - f32 tu=0.0f, tv=0.0f; - - if (tex_coord_sets >= 1 && tex_coord_set_size >= 2) - { - tu=tex_coords[0][0]; - tv=tex_coords[0][1]; - } - - f32 tu2=0.0f, tv2=0.0f; - - if (tex_coord_sets>=2 && tex_coord_set_size>=2) - { - tu2=tex_coords[1][0]; - tv2=tex_coords[1][1]; - } - - // Create Vertex... - video::S3DVertex2TCoords *Vertex=new video::S3DVertex2TCoords - (x, y, z, video::SColorf(red, green, blue, alpha).toSColor(), tu, tv, tu2, tv2); - //video::S3DVertex *Vertex=new video::S3DVertex - // (x, y, z, nx, ny, nz, video::SColorf(red, green, blue, alpha).toSColor(), tu, tv); - - Vertex->Normal = core::vector3df(nx, ny, nz); // should this be effected by the Node's Global Matrix (eg rotation)? - - // Transform the Vertex position by nested node... - core::matrix4 VertexMatrix; - VertexMatrix.setTranslation(Vertex->Pos); - - //Vertices_GlobalPosition.push_back(Vertex->Pos); - - //Normal_GlobalRotation.push_back(Vertex->Normal); - - VertexMatrix=InNode->GlobalMatrix*VertexMatrix; - Vertex->Pos=VertexMatrix.getTranslation(); - - - //Add it... - - BaseVertices.push_back(Vertex); - - Vertices_Moved.push_back(false); - AnimatedVertices_VertexID.push_back(-1); - AnimatedVertices_MeshBuffer.push_back(0); - Vertices_Alpha.push_back(alpha); - } - - B3dStack.erase(B3dStack.size()-1); - - return true; -} - - -bool CAnimatedMeshB3d::ReadChunkTRIS(io::IReadFile* file, SB3dNode *InNode, SB3DMeshBuffer *MeshBuffer,s32 Vertices_Start) -{ - - s32 triangle_brush_id; // Note: Irrlicht can't have different brushes for each triangle (I'm using a workaround) - - file->read(&triangle_brush_id, sizeof(triangle_brush_id)); - - #ifdef __BIG_ENDIAN__ - triangle_brush_id = os::Byteswap::byteswap(triangle_brush_id); - #endif - - SB3dMaterial *B3dMaterial; - - if (triangle_brush_id != -1) - B3dMaterial = &Materials[triangle_brush_id]; - else - B3dMaterial = 0; - - if (B3dMaterial) - MeshBuffer->Material = (*B3dMaterial->Material); - - s32 MemoryNeeded = B3dStack.getLast().length / sizeof(s32); - - MeshBuffer->Indices.reallocate(MemoryNeeded + MeshBuffer->Indices.size() + 1); - - while(B3dStack.getLast().startposition + B3dStack.getLast().length > file->getPos()) // this chunk repeats - { - s32 vertex_id[3]; - - file->read(&vertex_id[0], sizeof(s32)); - file->read(&vertex_id[1], sizeof(s32)); - file->read(&vertex_id[2], sizeof(s32)); - - #ifdef __BIG_ENDIAN__ - vertex_id[0] = os::Byteswap::byteswap(vertex_id[0]); - vertex_id[1] = os::Byteswap::byteswap(vertex_id[1]); - vertex_id[2] = os::Byteswap::byteswap(vertex_id[2]); - #endif - - - vertex_id[0] += Vertices_Start; - vertex_id[1] += Vertices_Start; - vertex_id[2] += Vertices_Start; - - for(s32 i=0; i<3; ++i) - { - if (AnimatedVertices_VertexID[ vertex_id[i] ] == -1) - { - if (BaseVertices[ vertex_id[i] ]->TCoords2 != core::vector2d(0,0)) - { - MeshBuffer->MoveTo_2TCoords(); - } - - - if (MeshBuffer->VertexType == video::EVT_STANDARD) - MeshBuffer->Vertices_Standard.push_back( *((video::S3DVertex*)BaseVertices[ vertex_id[i] ] ) ); - else - MeshBuffer->Vertices_2TCoords.push_back(*BaseVertices[ vertex_id[i] ] ); - - AnimatedVertices_VertexID[ vertex_id[i] ] = MeshBuffer->getVertexCount()-1; - AnimatedVertices_MeshBuffer[ vertex_id[i] ] = MeshBuffer; - - // Apply Material... - irr::video::S3DVertex *Vertex=MeshBuffer->getVertex(MeshBuffer->getVertexCount()-1); - - - if (Vertices_Alpha[ vertex_id[i] ] != 1.0f) - Vertex->Color.setAlpha( (s32)(Vertices_Alpha[ vertex_id[i] ] * 255.0f) ); - else if (B3dMaterial) - Vertex->Color.setAlpha( (s32)(B3dMaterial->alpha * 255.0f) ); - - if (B3dMaterial) - { - // A bit of a hack, there - if (B3dMaterial->Textures[0]) - { - Vertex->TCoords.X *=B3dMaterial->Textures[0]->Xscale; - Vertex->TCoords.Y *=B3dMaterial->Textures[0]->Yscale; - } - - /* - if (B3dMaterial->Textures[1]) - { - Vertex->TCoords2.X *=B3dMaterial->Textures[1]->Xscale; - Vertex->TCoords2.Y *=B3dMaterial->Textures[1]->Yscale; - } - */ - - } - - - } - } - - MeshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[0] ] ); - MeshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[1] ] ); - MeshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[2] ] ); - } - - B3dStack.erase(B3dStack.size()-1); - - return true; -} - -bool CAnimatedMeshB3d::ReadChunkNODE(io::IReadFile* file, SB3dNode *InNode) -{ - - core::stringc NodeName = readString(file); - - f32 position[3]; - f32 scale[3]; - f32 rotation[4]; - - s32 n; - - for (n=0; n<=2; n++) - file->read(&position[n], sizeof(f32)); - - for (n=0; n<=2; n++) - file->read(&scale[n], sizeof(f32)); - - for (n=0; n<=3; n++) - file->read(&rotation[n], sizeof(f32)); - - #ifdef __BIG_ENDIAN__ - for (n=0; n<=2; n++) - position[n] = os::Byteswap::byteswap(position[n]); - - for (n=0; n<=2; n++) - scale[n] = os::Byteswap::byteswap(scale[n]); - - for (n=0; n<=4; n++) - rotation[n] = os::Byteswap::byteswap(rotation[n]); - #endif - - - SB3dNode *Node = new SB3dNode(); - Node->Name = NodeName; - - Node->Animate = true; - Node->AnimatingPositionKeys = false; - Node->AnimatingScaleKeys = false; - Node->AnimatingRotationKeys = false; - Node->HasScaleAnimation = false; - - Node->position = core::vector3df(position[0],position[1],position[2]); - Node->scale = core::vector3df(scale[0],scale[1],scale[2]); - Node->rotation = core::quaternion(rotation[1], rotation[2], rotation[3], rotation[0]); // meant to be in this order - Node->Animatedposition = Node->position; - Node->Animatedscale = Node->scale; - Node->Animatedrotation = Node->rotation; - - irr::core::matrix4 positionMatrix; - positionMatrix.setTranslation(Node->position); - irr::core::matrix4 scaleMatrix; - scaleMatrix.setScale(Node->scale); - irr::core::matrix4 rotationMatrix = Node->rotation.getMatrix(); - Node->LocalMatrix = positionMatrix * rotationMatrix * scaleMatrix; - Node->LocalAnimatedMatrix = Node->LocalMatrix; //For non-animated meshes - - if (!InNode) - { - Node->GlobalMatrix = Node->LocalMatrix; - RootNodes.push_back(Node); - } - else - { - Node->GlobalMatrix = InNode->GlobalMatrix * Node->LocalMatrix; - } - - Node->GlobalInversedMatrix = Node->GlobalMatrix; - Node->GlobalInversedMatrix.makeInverse(); // slow - - Nodes.push_back(Node); - - if (InNode != 0) - InNode->Nodes.push_back(Node); - - while(B3dStack.getLast().startposition + B3dStack.getLast().length > file->getPos()) // this chunk repeats - { - B3dStack.push_back(B3dChunk()); - - B3dChunkHeader header; - file->read(&header, sizeof(header)); - - #ifdef __BIG_ENDIAN__ - header.size = os::Byteswap::byteswap(header.size); - #endif - - B3dStack.getLast().name[0] = header.name[0]; - B3dStack.getLast().name[1] = header.name[1]; //Not sure of an easier way - B3dStack.getLast().name[2] = header.name[2]; - B3dStack.getLast().name[3] = header.name[3]; - B3dStack.getLast().length = header.size+8; - B3dStack.getLast().startposition = file->getPos() - 8; - - bool read = false; - - if ( strncmp( B3dStack.getLast().name, "NODE", 4 ) == 0 ) - { - read = true; - if (!ReadChunkNODE(file, Node)) - return false; - } - else if ( strncmp( B3dStack.getLast().name, "MESH", 4 ) == 0 ) - { - read = true; - if (!ReadChunkMESH(file,Node)) - return false; - } - else if ( strncmp( B3dStack.getLast().name, "ANIM", 4 ) == 0 ) - { - read = true; - if (!ReadChunkANIM(file,Node)) - return false; - } - else if ( strncmp( B3dStack.getLast().name, "BONE", 4 ) == 0 ) - { - read = true; - if (!ReadChunkBONE(file,Node)) - return false; - } - else if ( strncmp( B3dStack.getLast().name, "KEYS", 4 ) == 0 ) - { - read = true; - if(!ReadChunkKEYS(file,Node)) - return false; - } - - if (!read) - { - os::Printer::log("Unknown chunk found in node - skipping"); - file->seek( (B3dStack.getLast().startposition + B3dStack.getLast().length), false); - B3dStack.erase(B3dStack.size()-1); - } - } - - B3dStack.erase(B3dStack.size()-1); - - return true; -} - - - - -bool CAnimatedMeshB3d::ReadChunkBONE(io::IReadFile* file, SB3dNode *InNode) -{ - - if (B3dStack.getLast().length > 8) - { - while(B3dStack.getLast().startposition + B3dStack.getLast().length>file->getPos()) // this chunk repeats - { - SB3dBone Bone; - - file->read(&Bone.vertex_id, sizeof(Bone.vertex_id)); - file->read(&Bone.weight, sizeof(Bone.weight)); - - #ifdef __BIG_ENDIAN__ - Bone.vertex_id = os::Byteswap::byteswap(Bone.vertex_id); - Bone.weight = os::Byteswap::byteswap(Bone.weight); - #endif - - if (Bone.weight != 0 || Bone.weight < 0) - { - HasBones = true; - InNode->Bones.push_back(Bone); - } - - } - } - - B3dStack.erase(B3dStack.size()-1); - return true; -} - - - - -bool CAnimatedMeshB3d::ReadChunkKEYS(io::IReadFile* file, SB3dNode *InNode) -{ - - s32 flags; - file->read(&flags, sizeof(flags)); - #ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); - #endif - - while(B3dStack.getLast().startposition + B3dStack.getLast().length>file->getPos()) //this chunk repeats - { - - if (flags & 2) //scale - InNode->HasScaleAnimation = true; - - s32 frame; - - f32 positionData[3]; - f32 scaleData[3]; - f32 rotationData[4]; - - file->read(&frame, sizeof(frame)); - - if (flags&1) - readFloats(file, positionData, 3); - - if (flags&2) - readFloats(file, scaleData, 3); - - if (flags&4) - readFloats(file, rotationData, 4); - - #ifdef __BIG_ENDIAN__ - frame = os::Byteswap::byteswap(frame); - #endif - - frame *= 100; // Scale the animation frames up - - core::vector3df position = core::vector3df(positionData[0], positionData[1], positionData[2]); - core::vector3df scale = core::vector3df(scaleData[0], scaleData[1], scaleData[2]); - core::quaternion rotation = core::quaternion(rotationData[1], rotationData[2], rotationData[3], rotationData[0]); // meant to be in this order - - - // Workout what types of keys need to animate - - if (InNode->PositionKeys.size() > 0) - if (flags&1 && InNode->Animatedposition != position) - InNode->AnimatingPositionKeys = true; - - if (InNode->ScaleKeys.size() > 0) - if (flags&2 && InNode->Animatedscale != scale) - InNode->AnimatingScaleKeys = true; - - if (InNode->RotationKeys.size() > 0) - { - if (flags & 4) - { - if (InNode->Animatedrotation.W != rotation.W - || InNode->Animatedrotation.X != rotation.X - || InNode->Animatedrotation.Y != rotation.Y - || InNode->Animatedrotation.Z != rotation.Z) - { - InNode->AnimatingRotationKeys = true; - } - } - } - - if (flags & 1) - InNode->Animatedposition = position; - - if (flags & 2) - InNode->Animatedscale = scale; - - if (flags & 4) - InNode->Animatedrotation = rotation; - - - // Add key frame - - if (flags & 1) - { - SB3dPositionKey Key; - Key.frame = frame; - Key.position = position; - InNode->PositionKeys.push_back(Key); - } - if (flags & 2) - { - SB3dScaleKey Key; - Key.frame = frame; - Key.scale=scale; - InNode->ScaleKeys.push_back(Key); - } - if (flags & 4) - { - SB3dRotationKey Key; - Key.frame = frame; - Key.rotation = rotation; - InNode->RotationKeys.push_back(Key); - } - - } - - B3dStack.erase(B3dStack.size()-1); - return true; -} - - -bool CAnimatedMeshB3d::ReadChunkANIM(io::IReadFile* file, SB3dNode *InNode) -{ - - file->read(&AnimFlags, sizeof(s32)); - file->read(&AnimFrames, sizeof(s32)); - readFloats(file, &AnimFPS, 1); - - #ifdef __BIG_ENDIAN__ - AnimFlags = os::Byteswap::byteswap(AnimFlags); - AnimFrames = os::Byteswap::byteswap(AnimFrames); - #endif - - AnimFrames*=100; - - totalTime=(f32)AnimFrames; - HasAnimation = 1; - lastCalculatedFrame = -1; - - B3dStack.erase(B3dStack.size()-1); - return true; -} - - - -bool CAnimatedMeshB3d::loadFile(io::IReadFile* file) -{ - if (!file) - return false; - - totalTime = 0; - HasAnimation = 0; - - HasBones = 0; - lastCalculatedFrame = -1; - lastAnimateMode = -1; - - AnimFlags = 0; // Unused for now - AnimFrames = 1; // how many frames in anim - AnimFPS = 0.0f; - - AnimateNormals = false; - - InterpolationMode = 1; // Set linear interpolation animation - AnimateMode = 3; // Update both the nodes and the skin in animation - - B3dChunkHeader header; - - file->read(&header, sizeof(header)); - - #ifdef __BIG_ENDIAN__ - header.size = os::Byteswap::byteswap(header.size); - #endif - - if ( strncmp( header.name, "BB3D", 4 ) != 0 ) - { - os::Printer::log("File is not a b3d file. Loading failed", file->getFileName(), ELL_ERROR); - return false; - } - - // header Chunk size here - - B3dStack.clear(); - - B3dStack.push_back(B3dChunk()); - B3dStack.getLast().name[0] = header.name[0]; - B3dStack.getLast().name[1] = header.name[1]; - B3dStack.getLast().name[2] = header.name[2]; - B3dStack.getLast().name[3] = header.name[3]; - B3dStack.getLast().startposition = file->getPos()-8; - B3dStack.getLast().length = header.size+8; - - //Get file version... - - u32 FileVersion; - file->read(&FileVersion, sizeof(FileVersion)); - #ifdef __BIG_ENDIAN__ - FileVersion = os::Byteswap::byteswap(FileVersion); - #endif - - while (B3dStack.getLast().startposition + B3dStack.getLast().length > file->getPos()) - { - - B3dStack.push_back(B3dChunk()); - - file->read(&header, sizeof(header)); - - #ifdef __BIG_ENDIAN__ - header.size = os::Byteswap::byteswap(header.size); - #endif - - B3dStack.getLast().name[0] = header.name[0]; - B3dStack.getLast().name[1] = header.name[1]; - B3dStack.getLast().name[2] = header.name[2]; - B3dStack.getLast().name[3] = header.name[3]; - B3dStack.getLast().startposition = file->getPos() - 8; - B3dStack.getLast().length = header.size + 8; - - bool read = false; - - if ( strncmp( B3dStack.getLast().name, "TEXS", 4 ) == 0 ) - { - read = true; - if (!ReadChunkTEXS(file)) - return false; - } - else if ( strncmp( B3dStack.getLast().name, "BRUS", 4 ) == 0 ) - { - read = true; - if (!ReadChunkBRUS(file)) - return false; - } - else if ( strncmp( B3dStack.getLast().name, "NODE", 4 ) == 0 ) - { - read = true; - if (!ReadChunkNODE(file, (SB3dNode*)0) ) - return false; - } - - if (!read) - { - os::Printer::log("Unknown chunk found in mesh base - skipping"); - - file->seek( (B3dStack.getLast().startposition + B3dStack.getLast().length) , false); - - B3dStack.erase(B3dStack.size()-1); - - } - } - - B3dStack.clear(); - - if (HasBones) - normalizeWeights(); - - - // Get BoundingBox... - if (Buffers.empty()) - BoundingBox.reset(0,0,0); - else - { - BoundingBox.reset(Buffers[0]->BoundingBox.MaxEdge); - for (s32 i=0; i<(s32)Buffers.size(); ++i) - { - BoundingBox.addInternalBox(Buffers[i]->BoundingBox); - } - } - - // For skinning - for (s32 i=0; i<(s32)Nodes.size(); ++i) - { - SB3dNode *Node = Nodes[i]; - for (s32 j=0; j<(s32)Node->Bones.size(); ++j) - { - Node->Bones[j].pos = BaseVertices[Node->Bones[j].vertex_id]->Pos; - Node->Bones[j].normal = BaseVertices[Node->Bones[j].vertex_id]->Normal; - Node->Bones[j].vertex = - AnimatedVertices_MeshBuffer[ Node->Bones[j].vertex_id ]->getVertex( - AnimatedVertices_VertexID[ Node->Bones[j].vertex_id ] ); - } - } - - return true; -} - - - - - - - -void CAnimatedMeshB3d::normalizeWeights() -{ - - // Normalise the weights on bones - - s32 i; - core::array Vertices_TotalWeight; - - Vertices_TotalWeight.set_used(BaseVertices.size()); - - for (i=0; i<(s32)Vertices_TotalWeight.size(); ++i) - Vertices_TotalWeight[i] = 0; - - for (i=0; i<(s32)Nodes.size(); ++i) - { - SB3dNode *Node=Nodes[i]; - for (s32 j=0; j<(s32)Node->Bones.size(); ++j) - Vertices_TotalWeight[ Node->Bones[j].vertex_id ] += Node->Bones[j].weight; - } - - for (i=0; i<(s32)Nodes.size(); ++i) - { - SB3dNode *Node=Nodes[i]; - for (s32 j=0; j<(s32)Node->Bones.size(); ++j) - { - f32 total = Vertices_TotalWeight[ Node->Bones[j].vertex_id ]; - if (total != 0 && total != 1) - Node->Bones[j].weight /= total; - } - } -} - - - - -//! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. -s32 CAnimatedMeshB3d::getFrameCount() -{ - return AnimFrames; -} - -//! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. -IMesh* CAnimatedMeshB3d::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) -{ - animate(frame,startFrameLoop, endFrameLoop); - return this; -} - -//! Returns a pointer to a transformation matrix of a part of the -//! mesh based on a frame time. -core::matrix4* CAnimatedMeshB3d::getMatrixOfJoint(s32 jointNumber, s32 frame) -{ - if (!HasAnimation || jointNumber < 0 || jointNumber >= (s32)Nodes.size()) - return 0; - - return &Nodes[jointNumber]->GlobalAnimatedMatrix; -} - -core::matrix4* CAnimatedMeshB3d::getLocalMatrixOfJoint(s32 jointNumber) -{ - if (!HasAnimation || jointNumber < 0 || jointNumber >= (s32)Nodes.size()) - return 0; - - return &Nodes[jointNumber]->LocalMatrix; -} - - -core::matrix4* CAnimatedMeshB3d::getMatrixOfJointUnanimated(s32 jointNumber) -{ - if (!HasAnimation || jointNumber < 0 || jointNumber >= (s32)Nodes.size()) - return 0; - - return &Nodes[jointNumber]->GlobalMatrix; -} - -//! Gets joint count. -s32 CAnimatedMeshB3d::getJointCount() const -{ - return Nodes.size(); -} - - -//! Gets the name of a joint. -void CAnimatedMeshB3d::setJointAnimation(s32 jointNumber, bool On) -{ - if (jointNumber < 0 || jointNumber >= (s32)Nodes.size()) - return; - Nodes[jointNumber]->Animate = On; -} - - -//! Gets the name of a joint. -const c8* CAnimatedMeshB3d::getJointName(s32 number) const -{ - if (number < 0 || number >= (s32)Nodes.size()) - return 0; - return Nodes[number]->Name.c_str(); -} - - - -//! Gets a joint number from its name -s32 CAnimatedMeshB3d::getJointNumber(const c8* name) const -{ - for (s32 i=0; i<(s32)Nodes.size(); ++i) - if (Nodes[i]->Name == name) - return i; - - return -1; -} - - -void CAnimatedMeshB3d::CalculateGlobalMatrixes(SB3dNode *Node,SB3dNode *ParentNode) -{ - if (!Node && ParentNode) // bit of protection from endless loops - return; - - if (!Node) - { - for (s32 i=0; i<(s32)RootNodes.size(); ++i) - CalculateGlobalMatrixes(RootNodes[i],0); - return; - } - - if (!ParentNode) - Node->GlobalAnimatedMatrix = Node->LocalAnimatedMatrix; - else - Node->GlobalAnimatedMatrix = ParentNode->GlobalAnimatedMatrix * Node->LocalAnimatedMatrix; - - for (s32 j=0; j<(s32)Node->Nodes.size(); ++j) - CalculateGlobalMatrixes(Node->Nodes[j],Node); -} - - -void CAnimatedMeshB3d::animateSkin(f32 frame,f32 startFrame, f32 endFrame,SB3dNode *Node,SB3dNode *ParentNode) -{ - // Get animated matrix... - if (!ParentNode) - Node->GlobalAnimatedMatrix = Node->LocalAnimatedMatrix; - else - Node->GlobalAnimatedMatrix = ParentNode->GlobalAnimatedMatrix * Node->LocalAnimatedMatrix; - - if (Node->Bones.size()) - { - core::matrix4 VerticesMatrixMove(core::matrix4::EM4CONST_NOTHING); - VerticesMatrixMove.setbyproduct(Node->GlobalAnimatedMatrix,Node->GlobalInversedMatrix); - core::vector3df ThisVertexMove, ThisNormalMove; - SB3dBone *Bone; - - //__ Skin Vertex's Normals __// - if (AnimateNormals) - { - for (u32 i=0; iBones.size(); ++i) - { - Bone=&Node->Bones[i]; - //Transform normal... - //Normal_Rotation=&Base_Vertex->Normal; - ThisNormalMove.X = Bone->normal.X*VerticesMatrixMove[0] + Bone->normal.Y*VerticesMatrixMove[4] + Bone->normal.Z*VerticesMatrixMove[8]; - ThisNormalMove.Y = Bone->normal.X*VerticesMatrixMove[1] + Bone->normal.Y*VerticesMatrixMove[5] + Bone->normal.Z*VerticesMatrixMove[9]; - ThisNormalMove.Z = Bone->normal.X*VerticesMatrixMove[2] + Bone->normal.Y*VerticesMatrixMove[6] + Bone->normal.Z*VerticesMatrixMove[10]; - - if (!Vertices_Moved[Bone->vertex_id]) - Bone->vertex->Normal = ThisNormalMove*Bone->weight; - else - Bone->vertex->Normal = Bone->vertex->Normal + (ThisNormalMove * Bone->weight); - } - } - - - //__ Skin Vertex's Position __// - for (u32 i=0; iBones.size(); ++i) - { - Bone=&Node->Bones[i]; - - // Transform vector... - ThisVertexMove.X = VerticesMatrixMove[0]*Bone->pos.X + VerticesMatrixMove[4]*Bone->pos.Y + VerticesMatrixMove[8]*Bone->pos.Z + VerticesMatrixMove[12]; - ThisVertexMove.Y = VerticesMatrixMove[1]*Bone->pos.X + VerticesMatrixMove[5]*Bone->pos.Y + VerticesMatrixMove[9]*Bone->pos.Z + VerticesMatrixMove[13]; - ThisVertexMove.Z = VerticesMatrixMove[2]*Bone->pos.X + VerticesMatrixMove[6]*Bone->pos.Y + VerticesMatrixMove[10]*Bone->pos.Z + VerticesMatrixMove[14]; - - if (!Vertices_Moved[Bone->vertex_id]) - { - Vertices_Moved[Bone->vertex_id] = true; - Bone->vertex->Pos = ThisVertexMove * Bone->weight; - } - else - { - Bone->vertex->Pos = Bone->vertex->Pos + (ThisVertexMove*Bone->weight); - } - } - - } - - - for (s32 j=0; j<(s32)Node->Nodes.size(); ++j) - animateSkin(frame, startFrame, endFrame, Node->Nodes[j], Node); - -} - - - -void CAnimatedMeshB3d::getNodeAnimation(f32 frame,SB3dNode *Node,core::vector3df &position, core::vector3df &scale, core::quaternion &rotation) -{ - - bool foundPosition = false; - bool foundScale = false; - bool foundRotation = false; - - s32 LastPosition = -1; - s32 LastScale = -1; - s32 LastRotation = -1; - - s32 j, k; - - if (Node->AnimatingPositionKeys) - { - j=0; - for (k=0; k < (s32)Node->PositionKeys.size(); k += 40) - { - if (Node->PositionKeys[k].frame < frame) - j=k; - else - break; - } - - for (; j<(s32)Node->PositionKeys.size(); j++) - { - SB3dPositionKey *Key=&Node->PositionKeys[j]; - if (Key->frame >= frame) - { - if (InterpolationMode == 0) - { - // Constant interpolate... - if (LastPosition != -1) - position = Node->PositionKeys[LastPosition].position; - else - position = Key->position; - - } - else if (InterpolationMode == 1) - { - //Linear interpolate... - if (LastPosition == -1) - position = Key->position; - else - { - SB3dPositionKey *LastKey = &Node->PositionKeys[LastPosition]; - if (Key->position == LastKey->position) - position = Key->position; - else - { - f32 fd1 = frame-LastKey->frame; - f32 fd2 = Key->frame-frame; - position = ((Key->position-LastKey->position)/(fd1+fd2))*fd1 + LastKey->position; - } - } - } - foundPosition = true; - break; - } - LastPosition = j; - - } - if (!foundPosition && LastPosition != -1) - position = Node->PositionKeys[LastPosition].position; - } - - - - if (Node->AnimatingRotationKeys) - { - - j=0; - for (k=0; k<(s32)Node->RotationKeys.size(); k += 40) - { - if (Node->RotationKeys[k].frame < frame) - j=k; - else - break; - } - - for (; j<(s32)Node->RotationKeys.size(); ++j) - { - SB3dRotationKey *Key = &Node->RotationKeys[j]; - - if (Key->frame >= frame) - { - if (InterpolationMode == 0) - { - // Constant interpolate... - if (LastRotation != -1) - rotation = Node->RotationKeys[LastRotation].rotation; - else - rotation = Key->rotation; - } - else if (InterpolationMode == 1) - { - // Linear interpolate... - - if (LastRotation == -1) - rotation = Key->rotation; - else - { - SB3dRotationKey *LastKey=&Node->RotationKeys[LastRotation]; - if (Key->rotation == LastKey->rotation) - rotation = Key->rotation; - else - { - f32 fd1 = frame-LastKey->frame; - f32 fd2 = Key->frame - frame; - f32 t = (1.0f/(fd1+fd2))*fd1; - rotation.slerp(LastKey->rotation, Key->rotation, t); - } - } - } - foundRotation = true; - break; - } - LastRotation = j; - - } - if (!foundRotation && LastRotation != -1) - rotation = Node->RotationKeys[LastRotation].rotation; - } - - if (Node->AnimatingScaleKeys) - { - j=0; - for (k=0; k<(s32)Node->ScaleKeys.size(); k+=40) - { - if (Node->ScaleKeys[k].frame < frame) - j = k; - else - break; - } - - for (; j<(s32)Node->ScaleKeys.size(); j++) - { - SB3dScaleKey *Key = &Node->ScaleKeys[j]; - - if (Key->frame >= frame) - { - if (InterpolationMode == 0) - { - // Constant interpolate... - if (LastScale != -1) - scale = Node->ScaleKeys[LastScale].scale; - else - scale = Key->scale; - } - else if (InterpolationMode == 1) - { - // Linear interpolate... - - if (LastScale == -1) - scale = Key->scale; - else - { - SB3dScaleKey *LastKey = &Node->ScaleKeys[LastScale]; - if (Key->scale == LastKey->scale) - scale = Key->scale; - else - { - f32 fd1 = frame-LastKey->frame; - f32 fd2 = Key->frame - frame; - scale = (((Key->scale-LastKey->scale)/(fd1+fd2))*fd1) + LastKey->scale; - } - } - } - foundScale = true; - break; - } - LastScale = j; - - } - if (!foundScale && LastScale != -1) - scale = Node->ScaleKeys[LastScale].scale; - } - - -} - - - -void CAnimatedMeshB3d::animateNodes(f32 frame,f32 startFrame, f32 endFrame) -{ - for (s32 i=0; i<(s32)Nodes.size(); ++i) - { - SB3dNode *Node = Nodes[i]; - - if (Node->Animate) - { - - //Get keyframe... - core::vector3df position = Node->position; - core::vector3df scale = Node->scale; - core::quaternion rotation = Node->rotation; - - getNodeAnimation(frame, Node, position, scale, rotation); - - Node->Animatedposition = position; - Node->Animatedscale = scale; - Node->Animatedrotation = rotation; - - core::matrix4 positionMatrix; - positionMatrix.setTranslation(Node->Animatedposition); - - core::matrix4 rotationMatrix; - rotationMatrix = Node->Animatedrotation.getMatrix(); - - if (!Node->HasScaleAnimation) - { - Node->LocalAnimatedMatrix = positionMatrix * rotationMatrix; - } - else - { - core::matrix4 scaleMatrix; - scaleMatrix.setScale(Node->Animatedscale); - Node->LocalAnimatedMatrix = positionMatrix * rotationMatrix * scaleMatrix; - } - - } - } -} - - -void CAnimatedMeshB3d::animate(s32 intframe,s32 startFrameLoop, s32 endFrameLoop)// Why cannot this be "animate(f32 frame)", it would make so much nicer animations -{ - - if ( !HasAnimation || (lastCalculatedFrame == intframe && lastAnimateMode == AnimateMode) ) - return; - - lastCalculatedFrame = intframe; - lastAnimateMode = AnimateMode; - - f32 frame = (f32)intframe; - f32 startFrame = (f32)startFrameLoop; - f32 endFrame = (f32)endFrameLoop; - - - - if (AnimateMode & 1) // Update Nodes - animateNodes(frame, startFrame, endFrame); - - - - if (AnimateMode & 2) // Update skin - { - // Reset skin - s32 i; - for (i=0; i<(s32)Vertices_Moved.size(); ++i) - Vertices_Moved[i]=false; - - for (i=0; i<(s32)RootNodes.size(); ++i) - { - animateSkin(frame, startFrame, endFrame, RootNodes[i], 0); - } - /* - if (AnimateNormals) - { - for (i=0; i<(s32)Nodes.size(); ++i) - { - SB3dNode *Node = Nodes[i]; - for (s32 j=0; j<(s32)Node->Bones.size(); ++j) - { - u16 VertexID = AnimatedVertices_VertexID[ Node->Bones[j].vertex_id ]; - SB3DMeshBuffer *MeshBuffer = AnimatedVertices_MeshBuffer[ Node->Bones[j].vertex_id ]; - video::S3DVertex2TCoords *Vertex = &MeshBuffer->Vertices[VertexID]; - //video::S3DVertex *Vertex = &MeshBuffer->Vertices[VertexID]; - //Vertex->Normal.normalize(); - } - } - } - */ - } - - - -} - - -//! returns amount of mesh buffers. -u32 CAnimatedMeshB3d::getMeshBufferCount() const -{ - return Buffers.size(); -} - - -//! returns pointer to a mesh buffer -IMeshBuffer* CAnimatedMeshB3d::getMeshBuffer(u32 nr) const -{ - if (nr < Buffers.size()) - return Buffers[nr]; - else - return 0; -} - -//! Returns pointer to a mesh buffer which fits a material -IMeshBuffer* CAnimatedMeshB3d::getMeshBuffer( const video::SMaterial &material) const -{ - for (u32 i=0; i < Buffers.size(); ++i) - { - if (Buffers[i]->getMaterial() == material) - return Buffers[i]; - } - return 0; -} - -//! returns an axis aligned bounding box -const core::aabbox3d& CAnimatedMeshB3d::getBoundingBox() const -{ - return BoundingBox; -} - -//! set user axis aligned bounding box -void CAnimatedMeshB3d::setBoundingBox( const core::aabbox3df& box) -{ - BoundingBox = box; -} - -//! sets a flag of all contained materials to a new value -void CAnimatedMeshB3d::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) -{ - for (s32 i=0; i < (s32)Buffers.size(); ++i) - Buffers[i]->Material.setFlag(flag, newvalue); -} - -//! Returns the type of the animated mesh. -E_ANIMATED_MESH_TYPE CAnimatedMeshB3d::getMeshType() const -{ - return EAMT_B3D; -} - -//!Update Normals when Animating -//!False= Don't (default) -//!True= Update normals, slower -void CAnimatedMeshB3d::updateNormalsWhenAnimating(bool on) -{ - AnimateNormals = on; -} - -//!Sets Interpolation Mode -//!0- Constant -//!1- Linear (default) -void CAnimatedMeshB3d::setInterpolationMode(s32 mode) -{ - InterpolationMode = mode; -} - -//!Want should happen on when animating -//!0-Nothing -//!1-Update nodes only -//!2-Update skin only -//!3-Update both nodes and skin (default) -void CAnimatedMeshB3d::setAnimateMode(s32 mode) -{ - AnimateMode = mode; -} - - - - - - -void CAnimatedMeshB3d::recoverJointsFromMesh(core::array &JointChildSceneNodes) -{ - // Note: This function works because of the way the b3d fomat nests nodes, other mesh loaders may need a different function - for (s32 i=0; i<(s32)Nodes.size(); ++i) - { - ISceneNode* node = JointChildSceneNodes[i]; - SB3dNode *B3dNode = Nodes[i]; - node->setPosition( B3dNode->LocalAnimatedMatrix.getTranslation() ); - node->setRotation( B3dNode->LocalAnimatedMatrix.getRotationDegrees() ); - //node->setScale( B3dNode->LocalAnimatedMatrix.getScale() ); - node->updateAbsolutePosition(); // works because of nests nodes - } -} - -void CAnimatedMeshB3d::tranferJointsToMesh(core::array &JointChildSceneNodes) -{ - for (s32 i=0;i<(s32)Nodes.size();++i) - { - ISceneNode* node = JointChildSceneNodes[i]; - SB3dNode *B3dNode = Nodes[i]; - B3dNode->LocalAnimatedMatrix.setTranslation( node->getPosition() ); - B3dNode->LocalAnimatedMatrix.setRotationDegrees( node->getRotation() ); - //B3dNode->LocalAnimatedMatrix.setScale( node->getScale() ); - } - lastCalculatedFrame = -1; -} - -void CAnimatedMeshB3d::createJoints(core::array &JointChildSceneNodes, ISceneNode* AnimatedMeshSceneNode, ISceneManager* SceneManager) -{ - // Note: This function works because of the way the b3d format nests nodes, other mesh loaders may need a different function - createSkelton_Helper(SceneManager, JointChildSceneNodes, AnimatedMeshSceneNode, 0, 0, 0); -} - -void CAnimatedMeshB3d::createSkelton_Helper(ISceneManager* SceneManager, core::array &JointChildSceneNodes, ISceneNode* AnimatedMeshSceneNode, ISceneNode* ParentNode, SB3dNode *ParentB3dNode,SB3dNode *B3dNode) -{ - // Note: This function works because of the way the b3d fomat nests nodes, other mesh loaders may need a different function - if (!ParentNode) - { - for (s32 i=0; i<(s32)RootNodes.size(); ++i) - { - B3dNode = RootNodes[i]; - ISceneNode* node = SceneManager->addEmptySceneNode(AnimatedMeshSceneNode); - JointChildSceneNodes.push_back(node); - for (s32 j=0; j<(s32)B3dNode->Nodes.size(); ++j) - createSkelton_Helper(SceneManager, JointChildSceneNodes, AnimatedMeshSceneNode, node, B3dNode, B3dNode->Nodes[j]); - } - } - else - { - ISceneNode* node = SceneManager->addEmptySceneNode(ParentNode); - JointChildSceneNodes.push_back(node); - for (s32 j=0; j<(s32)B3dNode->Nodes.size(); ++j) - createSkelton_Helper(SceneManager, JointChildSceneNodes, AnimatedMeshSceneNode, node, B3dNode, B3dNode->Nodes[j]); - } -} - - - -void CAnimatedMeshB3d::convertToTangents() -{ - - // now calculate tangents - for (u32 b=0; b < Buffers.size(); ++b) - { - if (Buffers[b]) - { - - Buffers[b]->MoveTo_Tangents(); - - s32 idxCnt = Buffers[b]->getIndexCount(); - - u16* idx = Buffers[b]->getIndices(); - video::S3DVertexTangents* v = - (video::S3DVertexTangents*)Buffers[b]->getVertices(); - - for (s32 i=0; iBones.size(); ++j) - { - Node->Bones[j].pos = BaseVertices[Node->Bones[j].vertex_id]->Pos; - Node->Bones[j].normal = BaseVertices[Node->Bones[j].vertex_id]->Normal; - Node->Bones[j].vertex = - AnimatedVertices_MeshBuffer[ Node->Bones[j].vertex_id ]->getVertex( - AnimatedVertices_VertexID[ Node->Bones[j].vertex_id ] ); - } - } - -} - - - -void CAnimatedMeshB3d::calculateTangents( - core::vector3df& normal, - core::vector3df& tangent, - core::vector3df& binormal, - core::vector3df& vt1, core::vector3df& vt2, core::vector3df& vt3, // vertices - core::vector2df& tc1, core::vector2df& tc2, core::vector2df& tc3) // texture coords -{ - core::vector3df v1 = vt1 - vt2; - core::vector3df v2 = vt3 - vt1; - normal = v2.crossProduct(v1); - normal.normalize(); - - // binormal - - f32 deltaX1 = tc1.X - tc2.X; - f32 deltaX2 = tc3.X - tc1.X; - binormal = (v1 * deltaX2) - (v2 * deltaX1); - binormal.normalize(); - - // tangent - - f32 deltaY1 = tc1.Y - tc2.Y; - f32 deltaY2 = tc3.Y - tc1.Y; - tangent = (v1 * deltaY2) - (v2 * deltaY1); - tangent.normalize(); - - // adjust - - core::vector3df txb = tangent.crossProduct(binormal); - if (txb.dotProduct(normal) < 0.0f) - { - tangent *= -1.0f; - binormal *= -1.0f; - } -} - - - - - - -} // end namespace scene -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// B3D file loader by Luke Hoschke, File format by Mark Sibly + +#include "CAnimatedMeshB3d.h" +#include "os.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace scene +{ + + +struct B3dChunkHeader +{ + c8 name[4]; + s32 size; +}; + + +//! constructor +CAnimatedMeshB3d::CAnimatedMeshB3d(video::IVideoDriver* driver) +: Driver(driver) +{ + if (Driver) + Driver->grab(); +} + + +//! destructor +CAnimatedMeshB3d::~CAnimatedMeshB3d() +{ + + if (Driver) + Driver->drop(); + + s32 n; + for (n=BaseVertices.size()-1; n>=0; --n) + { + delete BaseVertices[n]; + BaseVertices.erase(n); + } + + for (n=Buffers.size()-1; n>=0; --n) + { + delete Buffers[n]; + Buffers.erase(n); + } + + for (n=Materials.size()-1; n>=0; --n) + { + if (Materials[n].Material) + delete Materials[n].Material; + Materials.erase(n); + } + + for (n=Nodes.size()-1; n>=0; --n) + { + delete Nodes[n]; + Nodes.erase(n); + } + +} + + + +core::stringc CAnimatedMeshB3d::readString(io::IReadFile* file) +{ + core::stringc newstring; + + while (file->getPos() <= file->getSize() ) + { + c8 character; + file->read(&character, sizeof(character)); + + if (character==0) + return newstring; + + newstring.append(character); + } + return newstring; +} + + + +core::stringc CAnimatedMeshB3d::stripPathString(core::string oldstring, bool keepPath) +{ + s32 lastA=oldstring.findLast('/'); // forward slash + s32 lastB=oldstring.findLast('\\'); // back slash + + if (!keepPath) + { + if (lastA==-1 && lastB==-1) + return oldstring; + } + else + { + if (lastA==-1 && lastB==-1) + return core::stringc(); + } + + + if (lastA > lastB) + { + if (!keepPath) + return oldstring.subString(lastA+1, oldstring.size() - (lastA+1)); + else + return oldstring.subString(0, lastA + 1); + } + else + { + if (!keepPath) + return oldstring.subString(lastB+1, oldstring.size() - (lastB+1)); + else + return oldstring.subString(0, lastB + 1); + } +} + + + +void CAnimatedMeshB3d::readFloats(io::IReadFile* file, f32* vec, u32 count) +{ + file->read(vec, count*sizeof(f32)); + #ifdef __BIG_ENDIAN__ + for (u32 n=0; ngetTextureCreationFlag(video::ETCF_ALWAYS_32_BIT); + + Driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true); + + + while(B3dStack.getLast().startposition + B3dStack.getLast().length>file->getPos()) //this chunk repeats + { + core::stringc TextureName=readString(file); + + TextureName=stripPathString(file->getFileName(),true) + stripPathString(TextureName,false); + + SB3dTexture B3dTexture; + + B3dTexture.Texture=Driver->getTexture ( TextureName.c_str() ); + + file->read(&B3dTexture.Flags, sizeof(s32)); + file->read(&B3dTexture.Blend, sizeof(s32)); + readFloats(file, &B3dTexture.Xpos, 1); + readFloats(file, &B3dTexture.Ypos, 1); + readFloats(file, &B3dTexture.Xscale, 1); + readFloats(file, &B3dTexture.Yscale, 1); + readFloats(file, &B3dTexture.Angle, 1); + + #ifdef __BIG_ENDIAN__ + B3dTexture.Flags = os::Byteswap::byteswap(B3dTexture.Flags); + B3dTexture.Blend = os::Byteswap::byteswap(B3dTexture.Blend); + #endif + + Textures.push_back(B3dTexture); + + /* + Flags: + 1: Color (default) + 2: Alpha + 4: Masked + 8: Mipmapped + 16: Clamp U + 32: Clamp V + 64: Spherical environment map + 128: Cubic environment map + 256: Store texture in vram + 512: Force the use of high color textures + 65536: texture uses secondary UV values + + Blend: + 0: Do not blend + 1: No blend, or Alpha (alpha when texture loaded with alpha flag - not recommended for multitexturing - see below) + 2: Multiply (default) + 3: Add + 4: Dot3 + 5: Multiply 2 + */ + } + + B3dStack.erase(B3dStack.size()-1); + + Driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, Previous32BitTextureFlag); + + return true; +} + + + + +bool CAnimatedMeshB3d::ReadChunkBRUS(io::IReadFile* file) +{ + + s32 n_texs; + + file->read(&n_texs, sizeof(s32)); + + #ifdef __BIG_ENDIAN__ + n_texs = os::Byteswap::byteswap(n_texs); + #endif + + while(B3dStack.getLast().startposition + B3dStack.getLast().length>file->getPos()) //this chunk repeats + { + // This is what blitz basic calls a brush, like a Irrlicht Material + core::stringc MaterialName=readString(file); //Not used but we still need the read it + + SB3dMaterial B3dMaterial; + + B3dMaterial.Material = new irr::video::SMaterial(); + + B3dMaterial.Textures[0]=0; + B3dMaterial.Textures[1]=0; + + s32 texture_id[8]; + texture_id[0]=-1; + texture_id[1]=-1; + + file->read(&B3dMaterial.red, sizeof(B3dMaterial.red)); + file->read(&B3dMaterial.green, sizeof(B3dMaterial.green)); + file->read(&B3dMaterial.blue, sizeof(B3dMaterial.blue)); + file->read(&B3dMaterial.alpha, sizeof(B3dMaterial.alpha)); + file->read(&B3dMaterial.shininess, sizeof(B3dMaterial.shininess)); + file->read(&B3dMaterial.blend, sizeof(B3dMaterial.blend)); + file->read(&B3dMaterial.fx, sizeof(B3dMaterial.fx)); + + for (s32 n=0; n < n_texs; ++n) + { + file->read(&texture_id[n], sizeof(s32)); //I'm not sure of getting the sizeof an array + //cout << "Material is using texture id:"<< texture_id[n] <Textures[0] = B3dMaterial.Textures[0]->Texture; + if (B3dMaterial.Textures[1] != 0) + B3dMaterial.Material->Textures[1] = B3dMaterial.Textures[1]->Texture; + + //the other textures are skipped, irrlicht I think can only have 2 Textures per Material + + if (B3dMaterial.Textures[1] != 0 && B3dMaterial.Textures[0] == 0) //It could happen + { + B3dMaterial.Textures[0] = B3dMaterial.Textures[1]; + B3dMaterial.Textures[1] = 0; + } + + //Hacky code to convert blitz fx to irrlicht... + if (B3dMaterial.Textures[1]) //Two textures + { + if (B3dMaterial.alpha==1) + { + if (B3dMaterial.Textures[1]->Blend & 5) + { + //B3dMaterial.Material->MaterialType = video::EMT_LIGHTMAP; + B3dMaterial.Material->MaterialType = video::EMT_LIGHTMAP_M2 ; + } + else + { + B3dMaterial.Material->MaterialType = video::EMT_LIGHTMAP; + } + } + else + { + //B3dMaterial.Material->MaterialType = video::EMT_LIGHTMAP; + //B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; + //B3dMaterial.Material->MaterialTypeParam=B3dMaterial.alpha; + B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; + } + } + else if (B3dMaterial.Textures[0]) //one texture + { + if (B3dMaterial.Textures[0]->Flags & 2) // Alpha mapped + { + B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; + } + else if (B3dMaterial.Textures[0]->Flags & 4) // Masked + { + // Not working like blitz basic, because Irrlicht is using alpha to mask, not colour like blitz basic + + B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + + } + else if (B3dMaterial.alpha == 1) + { + B3dMaterial.Material->MaterialType = video::EMT_SOLID; + } + else + { + //B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; + //B3dMaterial.Material->MaterialTypeParam=B3dMaterial.alpha; + B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; + } + } + else //No texture + { + + if (B3dMaterial.alpha == 1) + { + B3dMaterial.Material->MaterialType = video::EMT_SOLID; + } + else + { + B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; + } + } + + + if (B3dMaterial.fx & 32) //force vertex alpha-blending + { + B3dMaterial.Material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; + //B3dMaterial.Material->Lighting=false; + } + + + // Material fx... + + if (B3dMaterial.fx & 1) //full-bright + { + //B3dMaterial.Material->AmbientColor = video::SColor(1, 1, 1, 1).toSColor (); + B3dMaterial.Material->AmbientColor = video::SColor(255, 255, 255, 255); + //B3dMaterial.Material->EmissiveColor = video::SColorf(1, 1, 1, 0).toSColor ();//Would be too bright and brighter than blitz basic + B3dMaterial.Material->Lighting = false; + } + else + { + B3dMaterial.Material->AmbientColor = video::SColorf(B3dMaterial.red, B3dMaterial.green, B3dMaterial.blue, B3dMaterial.alpha).toSColor (); + } + + if (B3dMaterial.fx & 4) //flatshaded + B3dMaterial.Material->GouraudShading = false; + + if (B3dMaterial.fx & 16) //disable backface culling + B3dMaterial.Material->BackfaceCulling = false; + + + B3dMaterial.Material->DiffuseColor = video::SColorf(B3dMaterial.red, B3dMaterial.green, B3dMaterial.blue, B3dMaterial.alpha).toSColor (); + B3dMaterial.Material->EmissiveColor = video::SColorf(0.5, 0.5, 0.5, 0).toSColor (); //Thoughts, I'm no sure what I should set it to? + //B3dMaterial.Material->SpecularColor = video::SColorf(0, 0, 0, 0).toSColor (); //? + B3dMaterial.Material->Shininess = B3dMaterial.shininess; + + Materials.push_back(B3dMaterial); + } + + B3dStack.erase(B3dStack.size()-1); + + return true; +} + + + +bool CAnimatedMeshB3d::ReadChunkMESH(io::IReadFile* file, SB3dNode *InNode) +{ + + s32 Vertices_Start=BaseVertices.size(); //B3Ds have Vertex ID's local within the mesh I don't want this + + s32 brush_id; + + file->read(&brush_id, sizeof(brush_id)); + + #ifdef __BIG_ENDIAN__ + brush_id = os::Byteswap::byteswap(brush_id); + #endif + + NormalsInFile=false; + + + + while(B3dStack.getLast().startposition + B3dStack.getLast().length>file->getPos()) //this chunk repeats + { + + B3dStack.push_back(B3dChunk()); + + B3dChunkHeader header; + file->read(&header, sizeof(header)); + + #ifdef __BIG_ENDIAN__ + header.size = os::Byteswap::byteswap(header.size); + #endif + + B3dStack.getLast().name[0]=header.name[0]; + B3dStack.getLast().name[1]=header.name[1]; //Not sure of an easier way + B3dStack.getLast().name[2]=header.name[2]; + B3dStack.getLast().name[3]=header.name[3]; + + B3dStack.getLast().length = header.size + 8; + + B3dStack.getLast().startposition = file->getPos() - 8; + + bool read=false; + + if ( strncmp( B3dStack.getLast().name, "VRTS", 4 ) == 0 ) + { + read=true; + if (!ReadChunkVRTS(file,InNode ,0, Vertices_Start)) + return false; + } + else if ( strncmp( B3dStack.getLast().name, "TRIS", 4 ) == 0 ) + { + read=true; + + SB3DMeshBuffer *MeshBuffer = new SB3DMeshBuffer(); + MeshBuffer->VertexType=video::EVT_STANDARD; + + if (brush_id!=-1) + MeshBuffer->Material=(*Materials[brush_id].Material); + + if(ReadChunkTRIS(file,InNode ,MeshBuffer, Vertices_Start)==false) + return false; + + MeshBuffer->recalculateBoundingBox(); + + if (!NormalsInFile && MeshBuffer->Material.Lighting) // No point wasting time of lightmapped levels + { + s32 i; + + for ( i=0; i<(s32)MeshBuffer->Indices.size(); i+=3) + { + core::plane3d p( MeshBuffer->getVertex(MeshBuffer->Indices[i+0])->Pos, + MeshBuffer->getVertex(MeshBuffer->Indices[i+1])->Pos, + MeshBuffer->getVertex(MeshBuffer->Indices[i+2])->Pos); + + MeshBuffer->getVertex(MeshBuffer->Indices[i+0])->Normal += p.Normal; + MeshBuffer->getVertex(MeshBuffer->Indices[i+1])->Normal += p.Normal; + MeshBuffer->getVertex(MeshBuffer->Indices[i+2])->Normal += p.Normal; + } + + for ( i = 0; i<(s32)MeshBuffer->getVertexCount(); ++i ) + { + MeshBuffer->getVertex(i)->Normal.normalize (); + BaseVertices[Vertices_Start+i]->Normal=MeshBuffer->getVertex(i)->Normal; + } + } + + Buffers.push_back(MeshBuffer); + + } + + if (!read) + { + os::Printer::log("Unknown chunk found in mesh - skipping"); + file->seek( (B3dStack.getLast().startposition + B3dStack.getLast().length) , false); + B3dStack.erase(B3dStack.size()-1); + } + } + + + B3dStack.erase(B3dStack.size()-1); + + return true; +} + +/* +VRTS: + int flags ;1=normal values present, 2=rgba values present + int tex_coord_sets ;texture coords per vertex (eg: 1 for simple U/V) max=8 + int tex_coord_set_size ;components per set (eg: 2 for simple U/V) max=4 + { + float x,y,z ;always present + float nx,ny,nz ;vertex normal: present if (flags&1) + float red,green,blue,alpha ;vertex color: present if (flags&2) + float tex_coords[tex_coord_sets][tex_coord_set_size] ;tex coords + } +*/ + +bool CAnimatedMeshB3d::ReadChunkVRTS(io::IReadFile* file, SB3dNode *InNode, SB3DMeshBuffer *MeshBuffer,s32 Vertices_Start) +{ + + s32 flags, tex_coord_sets, tex_coord_set_size; + + file->read(&flags, sizeof(flags)); + file->read(&tex_coord_sets, sizeof(tex_coord_sets)); + file->read(&tex_coord_set_size, sizeof(tex_coord_set_size)); + + #ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); + tex_coord_sets = os::Byteswap::byteswap(tex_coord_sets); + tex_coord_set_size = os::Byteswap::byteswap(tex_coord_set_size); + #endif + + if (tex_coord_sets >= 3 || tex_coord_set_size >= 4) // Something is wrong + { + os::Printer::log("tex_coord_sets or tex_coord_set_size too big", file->getFileName(), ELL_ERROR); + return false; + } + + //------ Allocate Memory, for speed -----------// + + s32 MemoryNeeded = B3dStack.getLast().length / sizeof(f32); + s32 NumberOfReads = 3; + + if (flags & 1) NumberOfReads += 3; + if (flags & 2) NumberOfReads += 4; + + for (s32 i=0; i file->getPos()) // this chunk repeats + { + f32 x=0.0f, y=0.0f, z=0.0f; + f32 nx=0.0f, ny=0.0f, nz=0.0f; + f32 red=1.0f, green=1.0f, blue=1.0f, alpha=1.0f; + f32 tex_coords[3][4]; + + file->read(&x, sizeof(x)); + file->read(&y, sizeof(y)); + file->read(&z, sizeof(z)); + + if (flags & 1) + { + NormalsInFile = true; + file->read(&nx, sizeof(nx)); + file->read(&ny, sizeof(ny)); + file->read(&nz, sizeof(nz)); + } + + if (flags & 2) + { + file->read(&red, sizeof(red)); + file->read(&green, sizeof(green)); + file->read(&blue, sizeof(blue)); + file->read(&alpha, sizeof(alpha)); + } + + for (s32 i=0; iread(&tex_coords[i][j], sizeof(f32)); + + #ifdef __BIG_ENDIAN__ + x = os::Byteswap::byteswap(x); + y = os::Byteswap::byteswap(y); + z = os::Byteswap::byteswap(z); + + if (flags&1) + { + nx = os::Byteswap::byteswap(nx); + ny = os::Byteswap::byteswap(ny); + nz = os::Byteswap::byteswap(nz); + } + + if (flags & 2) + { + red = os::Byteswap::byteswap(red); + green = os::Byteswap::byteswap(green); + blue = os::Byteswap::byteswap(blue); + alpha = os::Byteswap::byteswap(alpha); + } + + for (s32 i=0; i<=tex_coord_sets-1; i++) + for (s32 j=0; j<=tex_coord_set_size-1; j++) + tex_coords[i][j] = os::Byteswap::byteswap(tex_coords[i][j]); + #endif + + f32 tu=0.0f, tv=0.0f; + + if (tex_coord_sets >= 1 && tex_coord_set_size >= 2) + { + tu=tex_coords[0][0]; + tv=tex_coords[0][1]; + } + + f32 tu2=0.0f, tv2=0.0f; + + if (tex_coord_sets>=2 && tex_coord_set_size>=2) + { + tu2=tex_coords[1][0]; + tv2=tex_coords[1][1]; + } + + // Create Vertex... + video::S3DVertex2TCoords *Vertex=new video::S3DVertex2TCoords + (x, y, z, video::SColorf(red, green, blue, alpha).toSColor(), tu, tv, tu2, tv2); + //video::S3DVertex *Vertex=new video::S3DVertex + // (x, y, z, nx, ny, nz, video::SColorf(red, green, blue, alpha).toSColor(), tu, tv); + + Vertex->Normal = core::vector3df(nx, ny, nz); // should this be effected by the Node's Global Matrix (eg rotation)? + + // Transform the Vertex position by nested node... + core::matrix4 VertexMatrix; + VertexMatrix.setTranslation(Vertex->Pos); + + //Vertices_GlobalPosition.push_back(Vertex->Pos); + + //Normal_GlobalRotation.push_back(Vertex->Normal); + + VertexMatrix=InNode->GlobalMatrix*VertexMatrix; + Vertex->Pos=VertexMatrix.getTranslation(); + + + //Add it... + + BaseVertices.push_back(Vertex); + + Vertices_Moved.push_back(false); + AnimatedVertices_VertexID.push_back(-1); + AnimatedVertices_MeshBuffer.push_back(0); + Vertices_Alpha.push_back(alpha); + } + + B3dStack.erase(B3dStack.size()-1); + + return true; +} + + +bool CAnimatedMeshB3d::ReadChunkTRIS(io::IReadFile* file, SB3dNode *InNode, SB3DMeshBuffer *MeshBuffer,s32 Vertices_Start) +{ + + s32 triangle_brush_id; // Note: Irrlicht can't have different brushes for each triangle (I'm using a workaround) + + file->read(&triangle_brush_id, sizeof(triangle_brush_id)); + + #ifdef __BIG_ENDIAN__ + triangle_brush_id = os::Byteswap::byteswap(triangle_brush_id); + #endif + + SB3dMaterial *B3dMaterial; + + if (triangle_brush_id != -1) + B3dMaterial = &Materials[triangle_brush_id]; + else + B3dMaterial = 0; + + if (B3dMaterial) + MeshBuffer->Material = (*B3dMaterial->Material); + + s32 MemoryNeeded = B3dStack.getLast().length / sizeof(s32); + + MeshBuffer->Indices.reallocate(MemoryNeeded + MeshBuffer->Indices.size() + 1); + + while(B3dStack.getLast().startposition + B3dStack.getLast().length > file->getPos()) // this chunk repeats + { + s32 vertex_id[3]; + + file->read(&vertex_id[0], sizeof(s32)); + file->read(&vertex_id[1], sizeof(s32)); + file->read(&vertex_id[2], sizeof(s32)); + + #ifdef __BIG_ENDIAN__ + vertex_id[0] = os::Byteswap::byteswap(vertex_id[0]); + vertex_id[1] = os::Byteswap::byteswap(vertex_id[1]); + vertex_id[2] = os::Byteswap::byteswap(vertex_id[2]); + #endif + + + vertex_id[0] += Vertices_Start; + vertex_id[1] += Vertices_Start; + vertex_id[2] += Vertices_Start; + + for(s32 i=0; i<3; ++i) + { + if (AnimatedVertices_VertexID[ vertex_id[i] ] == -1) + { + if (BaseVertices[ vertex_id[i] ]->TCoords2 != core::vector2d(0,0)) + { + MeshBuffer->MoveTo_2TCoords(); + } + + + if (MeshBuffer->VertexType == video::EVT_STANDARD) + MeshBuffer->Vertices_Standard.push_back( *((video::S3DVertex*)BaseVertices[ vertex_id[i] ] ) ); + else + MeshBuffer->Vertices_2TCoords.push_back(*BaseVertices[ vertex_id[i] ] ); + + AnimatedVertices_VertexID[ vertex_id[i] ] = MeshBuffer->getVertexCount()-1; + AnimatedVertices_MeshBuffer[ vertex_id[i] ] = MeshBuffer; + + // Apply Material... + irr::video::S3DVertex *Vertex=MeshBuffer->getVertex(MeshBuffer->getVertexCount()-1); + + + if (Vertices_Alpha[ vertex_id[i] ] != 1.0f) + Vertex->Color.setAlpha( (s32)(Vertices_Alpha[ vertex_id[i] ] * 255.0f) ); + else if (B3dMaterial) + Vertex->Color.setAlpha( (s32)(B3dMaterial->alpha * 255.0f) ); + + if (B3dMaterial) + { + // A bit of a hack, there + if (B3dMaterial->Textures[0]) + { + Vertex->TCoords.X *=B3dMaterial->Textures[0]->Xscale; + Vertex->TCoords.Y *=B3dMaterial->Textures[0]->Yscale; + } + + /* + if (B3dMaterial->Textures[1]) + { + Vertex->TCoords2.X *=B3dMaterial->Textures[1]->Xscale; + Vertex->TCoords2.Y *=B3dMaterial->Textures[1]->Yscale; + } + */ + + } + + + } + } + + MeshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[0] ] ); + MeshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[1] ] ); + MeshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[2] ] ); + } + + B3dStack.erase(B3dStack.size()-1); + + return true; +} + +bool CAnimatedMeshB3d::ReadChunkNODE(io::IReadFile* file, SB3dNode *InNode) +{ + + core::stringc NodeName = readString(file); + + f32 position[3]; + f32 scale[3]; + f32 rotation[4]; + + s32 n; + + for (n=0; n<=2; n++) + file->read(&position[n], sizeof(f32)); + + for (n=0; n<=2; n++) + file->read(&scale[n], sizeof(f32)); + + for (n=0; n<=3; n++) + file->read(&rotation[n], sizeof(f32)); + + #ifdef __BIG_ENDIAN__ + for (n=0; n<=2; n++) + position[n] = os::Byteswap::byteswap(position[n]); + + for (n=0; n<=2; n++) + scale[n] = os::Byteswap::byteswap(scale[n]); + + for (n=0; n<=4; n++) + rotation[n] = os::Byteswap::byteswap(rotation[n]); + #endif + + + SB3dNode *Node = new SB3dNode(); + Node->Name = NodeName; + + Node->Animate = true; + Node->AnimatingPositionKeys = false; + Node->AnimatingScaleKeys = false; + Node->AnimatingRotationKeys = false; + Node->HasScaleAnimation = false; + + Node->position = core::vector3df(position[0],position[1],position[2]); + Node->scale = core::vector3df(scale[0],scale[1],scale[2]); + Node->rotation = core::quaternion(rotation[1], rotation[2], rotation[3], rotation[0]); // meant to be in this order + Node->Animatedposition = Node->position; + Node->Animatedscale = Node->scale; + Node->Animatedrotation = Node->rotation; + + irr::core::matrix4 positionMatrix; + positionMatrix.setTranslation(Node->position); + irr::core::matrix4 scaleMatrix; + scaleMatrix.setScale(Node->scale); + irr::core::matrix4 rotationMatrix = Node->rotation.getMatrix(); + Node->LocalMatrix = positionMatrix * rotationMatrix * scaleMatrix; + Node->LocalAnimatedMatrix = Node->LocalMatrix; //For non-animated meshes + + if (!InNode) + { + Node->GlobalMatrix = Node->LocalMatrix; + RootNodes.push_back(Node); + } + else + { + Node->GlobalMatrix = InNode->GlobalMatrix * Node->LocalMatrix; + } + + Node->GlobalInversedMatrix = Node->GlobalMatrix; + Node->GlobalInversedMatrix.makeInverse(); // slow + + Nodes.push_back(Node); + + if (InNode != 0) + InNode->Nodes.push_back(Node); + + while(B3dStack.getLast().startposition + B3dStack.getLast().length > file->getPos()) // this chunk repeats + { + B3dStack.push_back(B3dChunk()); + + B3dChunkHeader header; + file->read(&header, sizeof(header)); + + #ifdef __BIG_ENDIAN__ + header.size = os::Byteswap::byteswap(header.size); + #endif + + B3dStack.getLast().name[0] = header.name[0]; + B3dStack.getLast().name[1] = header.name[1]; //Not sure of an easier way + B3dStack.getLast().name[2] = header.name[2]; + B3dStack.getLast().name[3] = header.name[3]; + B3dStack.getLast().length = header.size+8; + B3dStack.getLast().startposition = file->getPos() - 8; + + bool read = false; + + if ( strncmp( B3dStack.getLast().name, "NODE", 4 ) == 0 ) + { + read = true; + if (!ReadChunkNODE(file, Node)) + return false; + } + else if ( strncmp( B3dStack.getLast().name, "MESH", 4 ) == 0 ) + { + read = true; + if (!ReadChunkMESH(file,Node)) + return false; + } + else if ( strncmp( B3dStack.getLast().name, "ANIM", 4 ) == 0 ) + { + read = true; + if (!ReadChunkANIM(file,Node)) + return false; + } + else if ( strncmp( B3dStack.getLast().name, "BONE", 4 ) == 0 ) + { + read = true; + if (!ReadChunkBONE(file,Node)) + return false; + } + else if ( strncmp( B3dStack.getLast().name, "KEYS", 4 ) == 0 ) + { + read = true; + if(!ReadChunkKEYS(file,Node)) + return false; + } + + if (!read) + { + os::Printer::log("Unknown chunk found in node - skipping"); + file->seek( (B3dStack.getLast().startposition + B3dStack.getLast().length), false); + B3dStack.erase(B3dStack.size()-1); + } + } + + B3dStack.erase(B3dStack.size()-1); + + return true; +} + + + + +bool CAnimatedMeshB3d::ReadChunkBONE(io::IReadFile* file, SB3dNode *InNode) +{ + + if (B3dStack.getLast().length > 8) + { + while(B3dStack.getLast().startposition + B3dStack.getLast().length>file->getPos()) // this chunk repeats + { + SB3dBone Bone; + + file->read(&Bone.vertex_id, sizeof(Bone.vertex_id)); + file->read(&Bone.weight, sizeof(Bone.weight)); + + #ifdef __BIG_ENDIAN__ + Bone.vertex_id = os::Byteswap::byteswap(Bone.vertex_id); + Bone.weight = os::Byteswap::byteswap(Bone.weight); + #endif + + if (Bone.weight != 0 || Bone.weight < 0) + { + HasBones = true; + InNode->Bones.push_back(Bone); + } + + } + } + + B3dStack.erase(B3dStack.size()-1); + return true; +} + + + + +bool CAnimatedMeshB3d::ReadChunkKEYS(io::IReadFile* file, SB3dNode *InNode) +{ + + s32 flags; + file->read(&flags, sizeof(flags)); + #ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); + #endif + + while(B3dStack.getLast().startposition + B3dStack.getLast().length>file->getPos()) //this chunk repeats + { + + if (flags & 2) //scale + InNode->HasScaleAnimation = true; + + s32 frame; + + f32 positionData[3]; + f32 scaleData[3]; + f32 rotationData[4]; + + file->read(&frame, sizeof(frame)); + + if (flags&1) + readFloats(file, positionData, 3); + + if (flags&2) + readFloats(file, scaleData, 3); + + if (flags&4) + readFloats(file, rotationData, 4); + + #ifdef __BIG_ENDIAN__ + frame = os::Byteswap::byteswap(frame); + #endif + + frame *= 100; // Scale the animation frames up + + core::vector3df position = core::vector3df(positionData[0], positionData[1], positionData[2]); + core::vector3df scale = core::vector3df(scaleData[0], scaleData[1], scaleData[2]); + core::quaternion rotation = core::quaternion(rotationData[1], rotationData[2], rotationData[3], rotationData[0]); // meant to be in this order + + + // Workout what types of keys need to animate + + if (InNode->PositionKeys.size() > 0) + if (flags&1 && InNode->Animatedposition != position) + InNode->AnimatingPositionKeys = true; + + if (InNode->ScaleKeys.size() > 0) + if (flags&2 && InNode->Animatedscale != scale) + InNode->AnimatingScaleKeys = true; + + if (InNode->RotationKeys.size() > 0) + { + if (flags & 4) + { + if (InNode->Animatedrotation.W != rotation.W + || InNode->Animatedrotation.X != rotation.X + || InNode->Animatedrotation.Y != rotation.Y + || InNode->Animatedrotation.Z != rotation.Z) + { + InNode->AnimatingRotationKeys = true; + } + } + } + + if (flags & 1) + InNode->Animatedposition = position; + + if (flags & 2) + InNode->Animatedscale = scale; + + if (flags & 4) + InNode->Animatedrotation = rotation; + + + // Add key frame + + if (flags & 1) + { + SB3dPositionKey Key; + Key.frame = frame; + Key.position = position; + InNode->PositionKeys.push_back(Key); + } + if (flags & 2) + { + SB3dScaleKey Key; + Key.frame = frame; + Key.scale=scale; + InNode->ScaleKeys.push_back(Key); + } + if (flags & 4) + { + SB3dRotationKey Key; + Key.frame = frame; + Key.rotation = rotation; + InNode->RotationKeys.push_back(Key); + } + + } + + B3dStack.erase(B3dStack.size()-1); + return true; +} + + +bool CAnimatedMeshB3d::ReadChunkANIM(io::IReadFile* file, SB3dNode *InNode) +{ + + file->read(&AnimFlags, sizeof(s32)); + file->read(&AnimFrames, sizeof(s32)); + readFloats(file, &AnimFPS, 1); + + #ifdef __BIG_ENDIAN__ + AnimFlags = os::Byteswap::byteswap(AnimFlags); + AnimFrames = os::Byteswap::byteswap(AnimFrames); + #endif + + AnimFrames*=100; + + totalTime=(f32)AnimFrames; + HasAnimation = 1; + lastCalculatedFrame = -1; + + B3dStack.erase(B3dStack.size()-1); + return true; +} + + + +bool CAnimatedMeshB3d::loadFile(io::IReadFile* file) +{ + if (!file) + return false; + + totalTime = 0; + HasAnimation = 0; + + HasBones = 0; + lastCalculatedFrame = -1; + lastAnimateMode = -1; + + AnimFlags = 0; // Unused for now + AnimFrames = 1; // how many frames in anim + AnimFPS = 0.0f; + + AnimateNormals = false; + + InterpolationMode = 1; // Set linear interpolation animation + AnimateMode = 3; // Update both the nodes and the skin in animation + + B3dChunkHeader header; + + file->read(&header, sizeof(header)); + + #ifdef __BIG_ENDIAN__ + header.size = os::Byteswap::byteswap(header.size); + #endif + + if ( strncmp( header.name, "BB3D", 4 ) != 0 ) + { + os::Printer::log("File is not a b3d file. Loading failed", file->getFileName(), ELL_ERROR); + return false; + } + + // header Chunk size here + + B3dStack.clear(); + + B3dStack.push_back(B3dChunk()); + B3dStack.getLast().name[0] = header.name[0]; + B3dStack.getLast().name[1] = header.name[1]; + B3dStack.getLast().name[2] = header.name[2]; + B3dStack.getLast().name[3] = header.name[3]; + B3dStack.getLast().startposition = file->getPos()-8; + B3dStack.getLast().length = header.size+8; + + //Get file version... + + u32 FileVersion; + file->read(&FileVersion, sizeof(FileVersion)); + #ifdef __BIG_ENDIAN__ + FileVersion = os::Byteswap::byteswap(FileVersion); + #endif + + while (B3dStack.getLast().startposition + B3dStack.getLast().length > file->getPos()) + { + + B3dStack.push_back(B3dChunk()); + + file->read(&header, sizeof(header)); + + #ifdef __BIG_ENDIAN__ + header.size = os::Byteswap::byteswap(header.size); + #endif + + B3dStack.getLast().name[0] = header.name[0]; + B3dStack.getLast().name[1] = header.name[1]; + B3dStack.getLast().name[2] = header.name[2]; + B3dStack.getLast().name[3] = header.name[3]; + B3dStack.getLast().startposition = file->getPos() - 8; + B3dStack.getLast().length = header.size + 8; + + bool read = false; + + if ( strncmp( B3dStack.getLast().name, "TEXS", 4 ) == 0 ) + { + read = true; + if (!ReadChunkTEXS(file)) + return false; + } + else if ( strncmp( B3dStack.getLast().name, "BRUS", 4 ) == 0 ) + { + read = true; + if (!ReadChunkBRUS(file)) + return false; + } + else if ( strncmp( B3dStack.getLast().name, "NODE", 4 ) == 0 ) + { + read = true; + if (!ReadChunkNODE(file, (SB3dNode*)0) ) + return false; + } + + if (!read) + { + os::Printer::log("Unknown chunk found in mesh base - skipping"); + + file->seek( (B3dStack.getLast().startposition + B3dStack.getLast().length) , false); + + B3dStack.erase(B3dStack.size()-1); + + } + } + + B3dStack.clear(); + + if (HasBones) + normalizeWeights(); + + + // Get BoundingBox... + if (Buffers.empty()) + BoundingBox.reset(0,0,0); + else + { + BoundingBox.reset(Buffers[0]->BoundingBox.MaxEdge); + for (s32 i=0; i<(s32)Buffers.size(); ++i) + { + BoundingBox.addInternalBox(Buffers[i]->BoundingBox); + } + } + + // For skinning + for (s32 i=0; i<(s32)Nodes.size(); ++i) + { + SB3dNode *Node = Nodes[i]; + for (s32 j=0; j<(s32)Node->Bones.size(); ++j) + { + Node->Bones[j].pos = BaseVertices[Node->Bones[j].vertex_id]->Pos; + Node->Bones[j].normal = BaseVertices[Node->Bones[j].vertex_id]->Normal; + Node->Bones[j].vertex = + AnimatedVertices_MeshBuffer[ Node->Bones[j].vertex_id ]->getVertex( + AnimatedVertices_VertexID[ Node->Bones[j].vertex_id ] ); + } + } + + return true; +} + + + + + + + +void CAnimatedMeshB3d::normalizeWeights() +{ + + // Normalise the weights on bones + + s32 i; + core::array Vertices_TotalWeight; + + Vertices_TotalWeight.set_used(BaseVertices.size()); + + for (i=0; i<(s32)Vertices_TotalWeight.size(); ++i) + Vertices_TotalWeight[i] = 0; + + for (i=0; i<(s32)Nodes.size(); ++i) + { + SB3dNode *Node=Nodes[i]; + for (s32 j=0; j<(s32)Node->Bones.size(); ++j) + Vertices_TotalWeight[ Node->Bones[j].vertex_id ] += Node->Bones[j].weight; + } + + for (i=0; i<(s32)Nodes.size(); ++i) + { + SB3dNode *Node=Nodes[i]; + for (s32 j=0; j<(s32)Node->Bones.size(); ++j) + { + f32 total = Vertices_TotalWeight[ Node->Bones[j].vertex_id ]; + if (total != 0 && total != 1) + Node->Bones[j].weight /= total; + } + } +} + + + + +//! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. +s32 CAnimatedMeshB3d::getFrameCount() +{ + return AnimFrames; +} + +//! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. +IMesh* CAnimatedMeshB3d::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) +{ + animate(frame,startFrameLoop, endFrameLoop); + return this; +} + +//! Returns a pointer to a transformation matrix of a part of the +//! mesh based on a frame time. +core::matrix4* CAnimatedMeshB3d::getMatrixOfJoint(s32 jointNumber, s32 frame) +{ + if (!HasAnimation || jointNumber < 0 || jointNumber >= (s32)Nodes.size()) + return 0; + + return &Nodes[jointNumber]->GlobalAnimatedMatrix; +} + +core::matrix4* CAnimatedMeshB3d::getLocalMatrixOfJoint(s32 jointNumber) +{ + if (!HasAnimation || jointNumber < 0 || jointNumber >= (s32)Nodes.size()) + return 0; + + return &Nodes[jointNumber]->LocalMatrix; +} + + +core::matrix4* CAnimatedMeshB3d::getMatrixOfJointUnanimated(s32 jointNumber) +{ + if (!HasAnimation || jointNumber < 0 || jointNumber >= (s32)Nodes.size()) + return 0; + + return &Nodes[jointNumber]->GlobalMatrix; +} + +//! Gets joint count. +s32 CAnimatedMeshB3d::getJointCount() const +{ + return Nodes.size(); +} + + +//! Gets the name of a joint. +void CAnimatedMeshB3d::setJointAnimation(s32 jointNumber, bool On) +{ + if (jointNumber < 0 || jointNumber >= (s32)Nodes.size()) + return; + Nodes[jointNumber]->Animate = On; +} + + +//! Gets the name of a joint. +const c8* CAnimatedMeshB3d::getJointName(s32 number) const +{ + if (number < 0 || number >= (s32)Nodes.size()) + return 0; + return Nodes[number]->Name.c_str(); +} + + + +//! Gets a joint number from its name +s32 CAnimatedMeshB3d::getJointNumber(const c8* name) const +{ + for (s32 i=0; i<(s32)Nodes.size(); ++i) + if (Nodes[i]->Name == name) + return i; + + return -1; +} + + +void CAnimatedMeshB3d::CalculateGlobalMatrixes(SB3dNode *Node,SB3dNode *ParentNode) +{ + if (!Node && ParentNode) // bit of protection from endless loops + return; + + if (!Node) + { + for (s32 i=0; i<(s32)RootNodes.size(); ++i) + CalculateGlobalMatrixes(RootNodes[i],0); + return; + } + + if (!ParentNode) + Node->GlobalAnimatedMatrix = Node->LocalAnimatedMatrix; + else + Node->GlobalAnimatedMatrix = ParentNode->GlobalAnimatedMatrix * Node->LocalAnimatedMatrix; + + for (s32 j=0; j<(s32)Node->Nodes.size(); ++j) + CalculateGlobalMatrixes(Node->Nodes[j],Node); +} + + +void CAnimatedMeshB3d::animateSkin(f32 frame,f32 startFrame, f32 endFrame,SB3dNode *Node,SB3dNode *ParentNode) +{ + // Get animated matrix... + if (!ParentNode) + Node->GlobalAnimatedMatrix = Node->LocalAnimatedMatrix; + else + Node->GlobalAnimatedMatrix = ParentNode->GlobalAnimatedMatrix * Node->LocalAnimatedMatrix; + + if (Node->Bones.size()) + { + core::matrix4 VerticesMatrixMove(core::matrix4::EM4CONST_NOTHING); + VerticesMatrixMove.setbyproduct(Node->GlobalAnimatedMatrix,Node->GlobalInversedMatrix); + core::vector3df ThisVertexMove, ThisNormalMove; + SB3dBone *Bone; + + //__ Skin Vertex's Normals __// + if (AnimateNormals) + { + for (u32 i=0; iBones.size(); ++i) + { + Bone=&Node->Bones[i]; + //Transform normal... + //Normal_Rotation=&Base_Vertex->Normal; + ThisNormalMove.X = Bone->normal.X*VerticesMatrixMove[0] + Bone->normal.Y*VerticesMatrixMove[4] + Bone->normal.Z*VerticesMatrixMove[8]; + ThisNormalMove.Y = Bone->normal.X*VerticesMatrixMove[1] + Bone->normal.Y*VerticesMatrixMove[5] + Bone->normal.Z*VerticesMatrixMove[9]; + ThisNormalMove.Z = Bone->normal.X*VerticesMatrixMove[2] + Bone->normal.Y*VerticesMatrixMove[6] + Bone->normal.Z*VerticesMatrixMove[10]; + + if (!Vertices_Moved[Bone->vertex_id]) + Bone->vertex->Normal = ThisNormalMove*Bone->weight; + else + Bone->vertex->Normal = Bone->vertex->Normal + (ThisNormalMove * Bone->weight); + } + } + + + //__ Skin Vertex's Position __// + for (u32 i=0; iBones.size(); ++i) + { + Bone=&Node->Bones[i]; + + // Transform vector... + ThisVertexMove.X = VerticesMatrixMove[0]*Bone->pos.X + VerticesMatrixMove[4]*Bone->pos.Y + VerticesMatrixMove[8]*Bone->pos.Z + VerticesMatrixMove[12]; + ThisVertexMove.Y = VerticesMatrixMove[1]*Bone->pos.X + VerticesMatrixMove[5]*Bone->pos.Y + VerticesMatrixMove[9]*Bone->pos.Z + VerticesMatrixMove[13]; + ThisVertexMove.Z = VerticesMatrixMove[2]*Bone->pos.X + VerticesMatrixMove[6]*Bone->pos.Y + VerticesMatrixMove[10]*Bone->pos.Z + VerticesMatrixMove[14]; + + if (!Vertices_Moved[Bone->vertex_id]) + { + Vertices_Moved[Bone->vertex_id] = true; + Bone->vertex->Pos = ThisVertexMove * Bone->weight; + } + else + { + Bone->vertex->Pos = Bone->vertex->Pos + (ThisVertexMove*Bone->weight); + } + } + + } + + + for (s32 j=0; j<(s32)Node->Nodes.size(); ++j) + animateSkin(frame, startFrame, endFrame, Node->Nodes[j], Node); + +} + + + +void CAnimatedMeshB3d::getNodeAnimation(f32 frame,SB3dNode *Node,core::vector3df &position, core::vector3df &scale, core::quaternion &rotation) +{ + + bool foundPosition = false; + bool foundScale = false; + bool foundRotation = false; + + s32 LastPosition = -1; + s32 LastScale = -1; + s32 LastRotation = -1; + + s32 j, k; + + if (Node->AnimatingPositionKeys) + { + j=0; + for (k=0; k < (s32)Node->PositionKeys.size(); k += 40) + { + if (Node->PositionKeys[k].frame < frame) + j=k; + else + break; + } + + for (; j<(s32)Node->PositionKeys.size(); j++) + { + SB3dPositionKey *Key=&Node->PositionKeys[j]; + if (Key->frame >= frame) + { + if (InterpolationMode == 0) + { + // Constant interpolate... + if (LastPosition != -1) + position = Node->PositionKeys[LastPosition].position; + else + position = Key->position; + + } + else if (InterpolationMode == 1) + { + //Linear interpolate... + if (LastPosition == -1) + position = Key->position; + else + { + SB3dPositionKey *LastKey = &Node->PositionKeys[LastPosition]; + if (Key->position == LastKey->position) + position = Key->position; + else + { + f32 fd1 = frame-LastKey->frame; + f32 fd2 = Key->frame-frame; + position = ((Key->position-LastKey->position)/(fd1+fd2))*fd1 + LastKey->position; + } + } + } + foundPosition = true; + break; + } + LastPosition = j; + + } + if (!foundPosition && LastPosition != -1) + position = Node->PositionKeys[LastPosition].position; + } + + + + if (Node->AnimatingRotationKeys) + { + + j=0; + for (k=0; k<(s32)Node->RotationKeys.size(); k += 40) + { + if (Node->RotationKeys[k].frame < frame) + j=k; + else + break; + } + + for (; j<(s32)Node->RotationKeys.size(); ++j) + { + SB3dRotationKey *Key = &Node->RotationKeys[j]; + + if (Key->frame >= frame) + { + if (InterpolationMode == 0) + { + // Constant interpolate... + if (LastRotation != -1) + rotation = Node->RotationKeys[LastRotation].rotation; + else + rotation = Key->rotation; + } + else if (InterpolationMode == 1) + { + // Linear interpolate... + + if (LastRotation == -1) + rotation = Key->rotation; + else + { + SB3dRotationKey *LastKey=&Node->RotationKeys[LastRotation]; + if (Key->rotation == LastKey->rotation) + rotation = Key->rotation; + else + { + f32 fd1 = frame-LastKey->frame; + f32 fd2 = Key->frame - frame; + f32 t = (1.0f/(fd1+fd2))*fd1; + rotation.slerp(LastKey->rotation, Key->rotation, t); + } + } + } + foundRotation = true; + break; + } + LastRotation = j; + + } + if (!foundRotation && LastRotation != -1) + rotation = Node->RotationKeys[LastRotation].rotation; + } + + if (Node->AnimatingScaleKeys) + { + j=0; + for (k=0; k<(s32)Node->ScaleKeys.size(); k+=40) + { + if (Node->ScaleKeys[k].frame < frame) + j = k; + else + break; + } + + for (; j<(s32)Node->ScaleKeys.size(); j++) + { + SB3dScaleKey *Key = &Node->ScaleKeys[j]; + + if (Key->frame >= frame) + { + if (InterpolationMode == 0) + { + // Constant interpolate... + if (LastScale != -1) + scale = Node->ScaleKeys[LastScale].scale; + else + scale = Key->scale; + } + else if (InterpolationMode == 1) + { + // Linear interpolate... + + if (LastScale == -1) + scale = Key->scale; + else + { + SB3dScaleKey *LastKey = &Node->ScaleKeys[LastScale]; + if (Key->scale == LastKey->scale) + scale = Key->scale; + else + { + f32 fd1 = frame-LastKey->frame; + f32 fd2 = Key->frame - frame; + scale = (((Key->scale-LastKey->scale)/(fd1+fd2))*fd1) + LastKey->scale; + } + } + } + foundScale = true; + break; + } + LastScale = j; + + } + if (!foundScale && LastScale != -1) + scale = Node->ScaleKeys[LastScale].scale; + } + + +} + + + +void CAnimatedMeshB3d::animateNodes(f32 frame,f32 startFrame, f32 endFrame) +{ + for (s32 i=0; i<(s32)Nodes.size(); ++i) + { + SB3dNode *Node = Nodes[i]; + + if (Node->Animate) + { + + //Get keyframe... + core::vector3df position = Node->position; + core::vector3df scale = Node->scale; + core::quaternion rotation = Node->rotation; + + getNodeAnimation(frame, Node, position, scale, rotation); + + Node->Animatedposition = position; + Node->Animatedscale = scale; + Node->Animatedrotation = rotation; + + core::matrix4 positionMatrix; + positionMatrix.setTranslation(Node->Animatedposition); + + core::matrix4 rotationMatrix; + rotationMatrix = Node->Animatedrotation.getMatrix(); + + if (!Node->HasScaleAnimation) + { + Node->LocalAnimatedMatrix = positionMatrix * rotationMatrix; + } + else + { + core::matrix4 scaleMatrix; + scaleMatrix.setScale(Node->Animatedscale); + Node->LocalAnimatedMatrix = positionMatrix * rotationMatrix * scaleMatrix; + } + + } + } +} + + +void CAnimatedMeshB3d::animate(s32 intframe,s32 startFrameLoop, s32 endFrameLoop)// Why cannot this be "animate(f32 frame)", it would make so much nicer animations +{ + + if ( !HasAnimation || (lastCalculatedFrame == intframe && lastAnimateMode == AnimateMode) ) + return; + + lastCalculatedFrame = intframe; + lastAnimateMode = AnimateMode; + + f32 frame = (f32)intframe; + f32 startFrame = (f32)startFrameLoop; + f32 endFrame = (f32)endFrameLoop; + + + + if (AnimateMode & 1) // Update Nodes + animateNodes(frame, startFrame, endFrame); + + + + if (AnimateMode & 2) // Update skin + { + // Reset skin + s32 i; + for (i=0; i<(s32)Vertices_Moved.size(); ++i) + Vertices_Moved[i]=false; + + for (i=0; i<(s32)RootNodes.size(); ++i) + { + animateSkin(frame, startFrame, endFrame, RootNodes[i], 0); + } + /* + if (AnimateNormals) + { + for (i=0; i<(s32)Nodes.size(); ++i) + { + SB3dNode *Node = Nodes[i]; + for (s32 j=0; j<(s32)Node->Bones.size(); ++j) + { + u16 VertexID = AnimatedVertices_VertexID[ Node->Bones[j].vertex_id ]; + SB3DMeshBuffer *MeshBuffer = AnimatedVertices_MeshBuffer[ Node->Bones[j].vertex_id ]; + video::S3DVertex2TCoords *Vertex = &MeshBuffer->Vertices[VertexID]; + //video::S3DVertex *Vertex = &MeshBuffer->Vertices[VertexID]; + //Vertex->Normal.normalize(); + } + } + } + */ + } + + + +} + + +//! returns amount of mesh buffers. +u32 CAnimatedMeshB3d::getMeshBufferCount() const +{ + return Buffers.size(); +} + + +//! returns pointer to a mesh buffer +IMeshBuffer* CAnimatedMeshB3d::getMeshBuffer(u32 nr) const +{ + if (nr < Buffers.size()) + return Buffers[nr]; + else + return 0; +} + +//! Returns pointer to a mesh buffer which fits a material +IMeshBuffer* CAnimatedMeshB3d::getMeshBuffer( const video::SMaterial &material) const +{ + for (u32 i=0; i < Buffers.size(); ++i) + { + if (Buffers[i]->getMaterial() == material) + return Buffers[i]; + } + return 0; +} + +//! returns an axis aligned bounding box +const core::aabbox3d& CAnimatedMeshB3d::getBoundingBox() const +{ + return BoundingBox; +} + +//! set user axis aligned bounding box +void CAnimatedMeshB3d::setBoundingBox( const core::aabbox3df& box) +{ + BoundingBox = box; +} + +//! sets a flag of all contained materials to a new value +void CAnimatedMeshB3d::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) +{ + for (s32 i=0; i < (s32)Buffers.size(); ++i) + Buffers[i]->Material.setFlag(flag, newvalue); +} + +//! Returns the type of the animated mesh. +E_ANIMATED_MESH_TYPE CAnimatedMeshB3d::getMeshType() const +{ + return EAMT_B3D; +} + +//!Update Normals when Animating +//!False= Don't (default) +//!True= Update normals, slower +void CAnimatedMeshB3d::updateNormalsWhenAnimating(bool on) +{ + AnimateNormals = on; +} + +//!Sets Interpolation Mode +//!0- Constant +//!1- Linear (default) +void CAnimatedMeshB3d::setInterpolationMode(s32 mode) +{ + InterpolationMode = mode; +} + +//!Want should happen on when animating +//!0-Nothing +//!1-Update nodes only +//!2-Update skin only +//!3-Update both nodes and skin (default) +void CAnimatedMeshB3d::setAnimateMode(s32 mode) +{ + AnimateMode = mode; +} + + + + + + +void CAnimatedMeshB3d::recoverJointsFromMesh(core::array &JointChildSceneNodes) +{ + // Note: This function works because of the way the b3d fomat nests nodes, other mesh loaders may need a different function + for (s32 i=0; i<(s32)Nodes.size(); ++i) + { + ISceneNode* node = JointChildSceneNodes[i]; + SB3dNode *B3dNode = Nodes[i]; + node->setPosition( B3dNode->LocalAnimatedMatrix.getTranslation() ); + node->setRotation( B3dNode->LocalAnimatedMatrix.getRotationDegrees() ); + //node->setScale( B3dNode->LocalAnimatedMatrix.getScale() ); + node->updateAbsolutePosition(); // works because of nests nodes + } +} + +void CAnimatedMeshB3d::tranferJointsToMesh(core::array &JointChildSceneNodes) +{ + for (s32 i=0;i<(s32)Nodes.size();++i) + { + ISceneNode* node = JointChildSceneNodes[i]; + SB3dNode *B3dNode = Nodes[i]; + B3dNode->LocalAnimatedMatrix.setTranslation( node->getPosition() ); + B3dNode->LocalAnimatedMatrix.setRotationDegrees( node->getRotation() ); + //B3dNode->LocalAnimatedMatrix.setScale( node->getScale() ); + } + lastCalculatedFrame = -1; +} + +void CAnimatedMeshB3d::createJoints(core::array &JointChildSceneNodes, ISceneNode* AnimatedMeshSceneNode, ISceneManager* SceneManager) +{ + // Note: This function works because of the way the b3d format nests nodes, other mesh loaders may need a different function + createSkelton_Helper(SceneManager, JointChildSceneNodes, AnimatedMeshSceneNode, 0, 0, 0); +} + +void CAnimatedMeshB3d::createSkelton_Helper(ISceneManager* SceneManager, core::array &JointChildSceneNodes, ISceneNode* AnimatedMeshSceneNode, ISceneNode* ParentNode, SB3dNode *ParentB3dNode,SB3dNode *B3dNode) +{ + // Note: This function works because of the way the b3d fomat nests nodes, other mesh loaders may need a different function + if (!ParentNode) + { + for (s32 i=0; i<(s32)RootNodes.size(); ++i) + { + B3dNode = RootNodes[i]; + ISceneNode* node = SceneManager->addEmptySceneNode(AnimatedMeshSceneNode); + JointChildSceneNodes.push_back(node); + for (s32 j=0; j<(s32)B3dNode->Nodes.size(); ++j) + createSkelton_Helper(SceneManager, JointChildSceneNodes, AnimatedMeshSceneNode, node, B3dNode, B3dNode->Nodes[j]); + } + } + else + { + ISceneNode* node = SceneManager->addEmptySceneNode(ParentNode); + JointChildSceneNodes.push_back(node); + for (s32 j=0; j<(s32)B3dNode->Nodes.size(); ++j) + createSkelton_Helper(SceneManager, JointChildSceneNodes, AnimatedMeshSceneNode, node, B3dNode, B3dNode->Nodes[j]); + } +} + + + +void CAnimatedMeshB3d::convertToTangents() +{ + + // now calculate tangents + for (u32 b=0; b < Buffers.size(); ++b) + { + if (Buffers[b]) + { + + Buffers[b]->MoveTo_Tangents(); + + s32 idxCnt = Buffers[b]->getIndexCount(); + + u16* idx = Buffers[b]->getIndices(); + video::S3DVertexTangents* v = + (video::S3DVertexTangents*)Buffers[b]->getVertices(); + + for (s32 i=0; iBones.size(); ++j) + { + Node->Bones[j].pos = BaseVertices[Node->Bones[j].vertex_id]->Pos; + Node->Bones[j].normal = BaseVertices[Node->Bones[j].vertex_id]->Normal; + Node->Bones[j].vertex = + AnimatedVertices_MeshBuffer[ Node->Bones[j].vertex_id ]->getVertex( + AnimatedVertices_VertexID[ Node->Bones[j].vertex_id ] ); + } + } + +} + + + +void CAnimatedMeshB3d::calculateTangents( + core::vector3df& normal, + core::vector3df& tangent, + core::vector3df& binormal, + core::vector3df& vt1, core::vector3df& vt2, core::vector3df& vt3, // vertices + core::vector2df& tc1, core::vector2df& tc2, core::vector2df& tc3) // texture coords +{ + core::vector3df v1 = vt1 - vt2; + core::vector3df v2 = vt3 - vt1; + normal = v2.crossProduct(v1); + normal.normalize(); + + // binormal + + f32 deltaX1 = tc1.X - tc2.X; + f32 deltaX2 = tc3.X - tc1.X; + binormal = (v1 * deltaX2) - (v2 * deltaX1); + binormal.normalize(); + + // tangent + + f32 deltaY1 = tc1.Y - tc2.Y; + f32 deltaY2 = tc3.Y - tc1.Y; + tangent = (v1 * deltaY2) - (v2 * deltaY1); + tangent.normalize(); + + // adjust + + core::vector3df txb = tangent.crossProduct(binormal); + if (txb.dotProduct(normal) < 0.0f) + { + tangent *= -1.0f; + binormal *= -1.0f; + } +} + + + + + + +} // end namespace scene +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CAnimatedMeshB3d.h b/src/dep/src/irrlicht/CAnimatedMeshB3d.h index f2f701c..0fee9b5 100644 --- a/src/dep/src/irrlicht/CAnimatedMeshB3d.h +++ b/src/dep/src/irrlicht/CAnimatedMeshB3d.h @@ -1,498 +1,498 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - - -//B3D file loader by Luke Hoschke, File format by Mark Sibly - -#ifndef __C_ANIMATED_MESH_B3D_H_INCLUDED__ -#define __C_ANIMATED_MESH_B3D_H_INCLUDED__ - -#include "IAnimatedMeshB3d.h" -#include "IMesh.h" -#include "IReadFile.h" - -#include "SMeshBuffer.h" -#include "S3DVertex.h" - -#include "irrString.h" -#include "matrix4.h" -#include "quaternion.h" - -namespace irr -{ -namespace video -{ - class IVideoDriver; -} // end namespace video -namespace scene -{ - class CAnimatedMeshB3d : public IAnimatedMeshB3d, public IMesh - { - public: - - //! constructor - CAnimatedMeshB3d(video::IVideoDriver* driver); - - //! destructor - virtual ~CAnimatedMeshB3d(); - - //! loads an B3d file - virtual bool loadFile(io::IReadFile* file); - - //! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. - virtual s32 getFrameCount(); - - //! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. - virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1); - - //! returns amount of mesh buffers. - virtual u32 getMeshBufferCount() const; - - //! returns pointer to a mesh buffer - virtual IMeshBuffer* getMeshBuffer(u32 nr) const; - - //! Returns pointer to a mesh buffer which fits a material - /** \param material: material to search for - \return Returns the pointer to the mesh buffer or - NULL if there is no such mesh buffer. */ - virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const; - - //! returns an axis aligned bounding box - virtual const core::aabbox3d& getBoundingBox() const; - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box); - - //! sets a flag of all contained materials to a new value - virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue); - - //! Returns the type of the animated mesh. - virtual E_ANIMATED_MESH_TYPE getMeshType() const; - - //! Returns a pointer to a transformation matrix of a part of the - //! mesh based on a frame time. - virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame); - - //! Gets joint count. - virtual s32 getJointCount() const; - - //! Gets the name of a joint. - virtual const c8* getJointName(s32 number) const; - - //! Gets a joint number from its name - virtual s32 getJointNumber(const c8* name) const; - - - virtual core::matrix4* getLocalMatrixOfJoint(s32 jointNumber); - - virtual core::matrix4* getMatrixOfJointUnanimated(s32 jointNumber); - - virtual void setJointAnimation(s32 jointNumber, bool On); - - //!Update Normals when Animating - //!False= Don't (default) - //!True= Update normals, slower - virtual void updateNormalsWhenAnimating(bool on); - - - //!Sets Interpolation Mode - //!0- Constant - //!1- Linear (default) - virtual void setInterpolationMode(s32 mode); - - //!Want should happen on when animating - //!0-Nothing - //!1-Update nodes only - //!2-Update skin only - //!3-Update both nodes and skin (default) - virtual void setAnimateMode(s32 mode); - - - //!Convert all mesh buffers to use tangent vertices - virtual void convertToTangents(); - - - - //New Animation System Stuff (WIP)... - virtual void recoverJointsFromMesh(core::array &JointChildSceneNodes); - virtual void tranferJointsToMesh(core::array &JointChildSceneNodes); - virtual void createJoints(core::array &JointChildSceneNodes, ISceneNode* AnimatedMeshSceneNode, ISceneManager* SceneManager); - - - - - -private: - struct SB3DMeshBuffer : public IMeshBuffer - { - SB3DMeshBuffer() - { - #ifdef _DEBUG - setDebugName("SSkinMeshBuffer"); - #endif - } - - ~SB3DMeshBuffer() {}; - - virtual const video::SMaterial& getMaterial() const - { - return Material; - } - - virtual video::SMaterial& getMaterial() - { - return Material; - } - - virtual video::S3DVertex *getVertex(u32 index) - { - if (VertexType==video::EVT_STANDARD) return &Vertices_Standard[index]; - if (VertexType==video::EVT_TANGENTS) return (video::S3DVertex*)&Vertices_Tangents[index]; - return (video::S3DVertex*)&Vertices_2TCoords[index]; - } - - virtual const void* getVertices() const - { - if (VertexType==video::EVT_STANDARD) return Vertices_Standard.const_pointer(); - if (VertexType==video::EVT_TANGENTS) return Vertices_Tangents.const_pointer(); - return Vertices_2TCoords.const_pointer(); - } - - virtual void* getVertices() - { - if (VertexType==video::EVT_STANDARD) return Vertices_Standard.pointer(); - if (VertexType==video::EVT_TANGENTS) return Vertices_Tangents.pointer(); - return Vertices_2TCoords.pointer(); - } - - virtual u32 getVertexCount() const - { - if (VertexType==video::EVT_STANDARD) return Vertices_Standard.size(); - if (VertexType==video::EVT_TANGENTS) return Vertices_Tangents.size(); - return Vertices_2TCoords.size(); - } - - virtual const u16* getIndices() const - { - return Indices.const_pointer(); - } - - virtual u16* getIndices() - { - return Indices.pointer(); - } - - virtual u32 getIndexCount() const - { - return Indices.size(); - } - - virtual const core::aabbox3d& getBoundingBox() const - { - return BoundingBox; - } - - virtual void setBoundingBox( const core::aabbox3df& box) - { - BoundingBox = box; - } - - virtual void recalculateBoundingBox() - { - if (VertexType==video::EVT_STANDARD) - { - if (Vertices_Standard.empty()) - BoundingBox.reset(0,0,0); - else - { - BoundingBox.reset(Vertices_Standard[0].Pos); - for (u32 i=1; i Vertices_Tangents; - core::array Vertices_2TCoords; - core::array Vertices_Standard; - core::array Indices; - core::aabbox3d BoundingBox; - }; - - struct B3dChunk - { - c8 name[4]; - s32 length; - s32 startposition; - }; - - s32 AnimFlags; - s32 AnimFrames; //how many frames in anim - f32 AnimFPS; - - struct SB3dBone - { - s32 vertex_id; - f32 weight; - core::vector3df pos; - core::vector3df normal; - video::S3DVertex *vertex; - }; - - struct SB3dPositionKey - { - s32 frame; - core::vector3df position; - }; - - struct SB3dScaleKey - { - s32 frame; - core::vector3df scale; - }; - - struct SB3dRotationKey - { - s32 frame; - core::quaternion rotation; - }; - - struct SB3dNode - { - core::stringc Name; - - core::vector3df position; - core::vector3df scale; - core::quaternion rotation; - - core::vector3df Animatedposition; - core::vector3df Animatedscale; - core::quaternion Animatedrotation; - - core::matrix4 GlobalAnimatedMatrix; - core::matrix4 LocalAnimatedMatrix; - - core::matrix4 LocalMatrix; - core::matrix4 GlobalMatrix; - core::matrix4 GlobalInversedMatrix; - - bool Animate; //Move this nodes local matrix when animating? - bool AnimatingPositionKeys; - bool AnimatingScaleKeys; - bool AnimatingRotationKeys; - - bool HasScaleAnimation; - - core::array PositionKeys; - core::array ScaleKeys; - core::array RotationKeys; - - core::array Bones; - - core::array Nodes; - - }; - - core::array Nodes; - - core::array RootNodes; - - struct SB3dTexture - { - irr::video::ITexture* Texture; - s32 Flags; - s32 Blend; - f32 Xpos; - f32 Ypos; - f32 Xscale; - f32 Yscale; - f32 Angle; - }; - - struct SB3dMaterial - { - irr::video::SMaterial* Material; - f32 red, green, blue, alpha; - f32 shininess; - s32 blend,fx; - SB3dTexture *Textures[2]; - - }; - - bool ReadChunkTEXS(io::IReadFile* file); - bool ReadChunkBRUS(io::IReadFile* file); - bool ReadChunkMESH(io::IReadFile* file, SB3dNode *InNode); - bool ReadChunkVRTS(io::IReadFile* file, SB3dNode *InNode, SB3DMeshBuffer *MeshBuffer, s32 Vertices_Start); - bool ReadChunkTRIS(io::IReadFile* file, SB3dNode *InNode, SB3DMeshBuffer *MeshBuffer, s32 Vertices_Start); - bool ReadChunkNODE(io::IReadFile* file, SB3dNode *InNode); - bool ReadChunkBONE(io::IReadFile* file, SB3dNode *InNode); - bool ReadChunkKEYS(io::IReadFile* file, SB3dNode *InNode); - bool ReadChunkANIM(io::IReadFile* file, SB3dNode *InNode); - - void normalizeWeights(); - void animate(s32 frame,s32 startFrameLoop, s32 endFrameLoop); - void CalculateGlobalMatrixes(SB3dNode *Node,SB3dNode *ParentNode); - void animateSkin(f32 frame,f32 startFrame, f32 endFrame,SB3dNode *InNode,SB3dNode *ParentNode); - void getNodeAnimation(f32 frame,SB3dNode *Node,core::vector3df &position, core::vector3df &scale, core::quaternion &rotation); - void animateNodes(f32 frame,f32 startFrame, f32 endFrame); - void slerp(core::quaternion A,core::quaternion B,core::quaternion &C,f32 t); - - void calculateTangents(core::vector3df& normal, - core::vector3df& tangent, core::vector3df& binormal, - core::vector3df& vt1, core::vector3df& vt2, core::vector3df& vt3, - core::vector2df& tc1, core::vector2df& tc2, core::vector2df& tc3); - - - void createSkelton_Helper(ISceneManager* SceneManager, core::array &JointChildSceneNodes, ISceneNode *AnimatedMeshSceneNode, ISceneNode* ParentNode, SB3dNode *ParentB3dNode, SB3dNode *B3dNode); - - - - core::array B3dStack; - - f32 totalTime; - bool HasAnimation; - bool HasBones; - - s32 lastCalculatedFrame; - s32 lastAnimateMode; - - bool NormalsInFile; - bool AnimateNormals; - - //0- Constant 1- Linear - s32 InterpolationMode; - - //0-None 1-Update nodes only 2-Update skin only 3-Update both nodes and skin - s32 AnimateMode; - - core::stringc readString(io::IReadFile* file); - core::stringc stripPathString(core::stringc oldstring, bool keepPath); - void readFloats(io::IReadFile* file, f32* vec, u32 count); - - core::aabbox3d BoundingBox; - core::array Materials; - core::array Textures; - - core::array BaseVertices; - - core::array Vertices_Moved; - core::array Vertices_Alpha; - core::array AnimatedVertices_VertexID; - core::array AnimatedVertices_MeshBuffer; - core::array Buffers; - - video::IVideoDriver* Driver; - }; - -} // end namespace scene -} // end namespace irr - -#endif - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + + +//B3D file loader by Luke Hoschke, File format by Mark Sibly + +#ifndef __C_ANIMATED_MESH_B3D_H_INCLUDED__ +#define __C_ANIMATED_MESH_B3D_H_INCLUDED__ + +#include "IAnimatedMeshB3d.h" +#include "IMesh.h" +#include "IReadFile.h" + +#include "SMeshBuffer.h" +#include "S3DVertex.h" + +#include "irrString.h" +#include "matrix4.h" +#include "quaternion.h" + +namespace irr +{ +namespace video +{ + class IVideoDriver; +} // end namespace video +namespace scene +{ + class CAnimatedMeshB3d : public IAnimatedMeshB3d, public IMesh + { + public: + + //! constructor + CAnimatedMeshB3d(video::IVideoDriver* driver); + + //! destructor + virtual ~CAnimatedMeshB3d(); + + //! loads an B3d file + virtual bool loadFile(io::IReadFile* file); + + //! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. + virtual s32 getFrameCount(); + + //! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. + virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1); + + //! returns amount of mesh buffers. + virtual u32 getMeshBufferCount() const; + + //! returns pointer to a mesh buffer + virtual IMeshBuffer* getMeshBuffer(u32 nr) const; + + //! Returns pointer to a mesh buffer which fits a material + /** \param material: material to search for + \return Returns the pointer to the mesh buffer or + NULL if there is no such mesh buffer. */ + virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const; + + //! returns an axis aligned bounding box + virtual const core::aabbox3d& getBoundingBox() const; + + //! set user axis aligned bounding box + virtual void setBoundingBox( const core::aabbox3df& box); + + //! sets a flag of all contained materials to a new value + virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue); + + //! Returns the type of the animated mesh. + virtual E_ANIMATED_MESH_TYPE getMeshType() const; + + //! Returns a pointer to a transformation matrix of a part of the + //! mesh based on a frame time. + virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame); + + //! Gets joint count. + virtual s32 getJointCount() const; + + //! Gets the name of a joint. + virtual const c8* getJointName(s32 number) const; + + //! Gets a joint number from its name + virtual s32 getJointNumber(const c8* name) const; + + + virtual core::matrix4* getLocalMatrixOfJoint(s32 jointNumber); + + virtual core::matrix4* getMatrixOfJointUnanimated(s32 jointNumber); + + virtual void setJointAnimation(s32 jointNumber, bool On); + + //!Update Normals when Animating + //!False= Don't (default) + //!True= Update normals, slower + virtual void updateNormalsWhenAnimating(bool on); + + + //!Sets Interpolation Mode + //!0- Constant + //!1- Linear (default) + virtual void setInterpolationMode(s32 mode); + + //!Want should happen on when animating + //!0-Nothing + //!1-Update nodes only + //!2-Update skin only + //!3-Update both nodes and skin (default) + virtual void setAnimateMode(s32 mode); + + + //!Convert all mesh buffers to use tangent vertices + virtual void convertToTangents(); + + + + //New Animation System Stuff (WIP)... + virtual void recoverJointsFromMesh(core::array &JointChildSceneNodes); + virtual void tranferJointsToMesh(core::array &JointChildSceneNodes); + virtual void createJoints(core::array &JointChildSceneNodes, ISceneNode* AnimatedMeshSceneNode, ISceneManager* SceneManager); + + + + + +private: + struct SB3DMeshBuffer : public IMeshBuffer + { + SB3DMeshBuffer() + { + #ifdef _DEBUG + setDebugName("SSkinMeshBuffer"); + #endif + } + + ~SB3DMeshBuffer() {}; + + virtual const video::SMaterial& getMaterial() const + { + return Material; + } + + virtual video::SMaterial& getMaterial() + { + return Material; + } + + virtual video::S3DVertex *getVertex(u32 index) + { + if (VertexType==video::EVT_STANDARD) return &Vertices_Standard[index]; + if (VertexType==video::EVT_TANGENTS) return (video::S3DVertex*)&Vertices_Tangents[index]; + return (video::S3DVertex*)&Vertices_2TCoords[index]; + } + + virtual const void* getVertices() const + { + if (VertexType==video::EVT_STANDARD) return Vertices_Standard.const_pointer(); + if (VertexType==video::EVT_TANGENTS) return Vertices_Tangents.const_pointer(); + return Vertices_2TCoords.const_pointer(); + } + + virtual void* getVertices() + { + if (VertexType==video::EVT_STANDARD) return Vertices_Standard.pointer(); + if (VertexType==video::EVT_TANGENTS) return Vertices_Tangents.pointer(); + return Vertices_2TCoords.pointer(); + } + + virtual u32 getVertexCount() const + { + if (VertexType==video::EVT_STANDARD) return Vertices_Standard.size(); + if (VertexType==video::EVT_TANGENTS) return Vertices_Tangents.size(); + return Vertices_2TCoords.size(); + } + + virtual const u16* getIndices() const + { + return Indices.const_pointer(); + } + + virtual u16* getIndices() + { + return Indices.pointer(); + } + + virtual u32 getIndexCount() const + { + return Indices.size(); + } + + virtual const core::aabbox3d& getBoundingBox() const + { + return BoundingBox; + } + + virtual void setBoundingBox( const core::aabbox3df& box) + { + BoundingBox = box; + } + + virtual void recalculateBoundingBox() + { + if (VertexType==video::EVT_STANDARD) + { + if (Vertices_Standard.empty()) + BoundingBox.reset(0,0,0); + else + { + BoundingBox.reset(Vertices_Standard[0].Pos); + for (u32 i=1; i Vertices_Tangents; + core::array Vertices_2TCoords; + core::array Vertices_Standard; + core::array Indices; + core::aabbox3d BoundingBox; + }; + + struct B3dChunk + { + c8 name[4]; + s32 length; + s32 startposition; + }; + + s32 AnimFlags; + s32 AnimFrames; //how many frames in anim + f32 AnimFPS; + + struct SB3dBone + { + s32 vertex_id; + f32 weight; + core::vector3df pos; + core::vector3df normal; + video::S3DVertex *vertex; + }; + + struct SB3dPositionKey + { + s32 frame; + core::vector3df position; + }; + + struct SB3dScaleKey + { + s32 frame; + core::vector3df scale; + }; + + struct SB3dRotationKey + { + s32 frame; + core::quaternion rotation; + }; + + struct SB3dNode + { + core::stringc Name; + + core::vector3df position; + core::vector3df scale; + core::quaternion rotation; + + core::vector3df Animatedposition; + core::vector3df Animatedscale; + core::quaternion Animatedrotation; + + core::matrix4 GlobalAnimatedMatrix; + core::matrix4 LocalAnimatedMatrix; + + core::matrix4 LocalMatrix; + core::matrix4 GlobalMatrix; + core::matrix4 GlobalInversedMatrix; + + bool Animate; //Move this nodes local matrix when animating? + bool AnimatingPositionKeys; + bool AnimatingScaleKeys; + bool AnimatingRotationKeys; + + bool HasScaleAnimation; + + core::array PositionKeys; + core::array ScaleKeys; + core::array RotationKeys; + + core::array Bones; + + core::array Nodes; + + }; + + core::array Nodes; + + core::array RootNodes; + + struct SB3dTexture + { + irr::video::ITexture* Texture; + s32 Flags; + s32 Blend; + f32 Xpos; + f32 Ypos; + f32 Xscale; + f32 Yscale; + f32 Angle; + }; + + struct SB3dMaterial + { + irr::video::SMaterial* Material; + f32 red, green, blue, alpha; + f32 shininess; + s32 blend,fx; + SB3dTexture *Textures[2]; + + }; + + bool ReadChunkTEXS(io::IReadFile* file); + bool ReadChunkBRUS(io::IReadFile* file); + bool ReadChunkMESH(io::IReadFile* file, SB3dNode *InNode); + bool ReadChunkVRTS(io::IReadFile* file, SB3dNode *InNode, SB3DMeshBuffer *MeshBuffer, s32 Vertices_Start); + bool ReadChunkTRIS(io::IReadFile* file, SB3dNode *InNode, SB3DMeshBuffer *MeshBuffer, s32 Vertices_Start); + bool ReadChunkNODE(io::IReadFile* file, SB3dNode *InNode); + bool ReadChunkBONE(io::IReadFile* file, SB3dNode *InNode); + bool ReadChunkKEYS(io::IReadFile* file, SB3dNode *InNode); + bool ReadChunkANIM(io::IReadFile* file, SB3dNode *InNode); + + void normalizeWeights(); + void animate(s32 frame,s32 startFrameLoop, s32 endFrameLoop); + void CalculateGlobalMatrixes(SB3dNode *Node,SB3dNode *ParentNode); + void animateSkin(f32 frame,f32 startFrame, f32 endFrame,SB3dNode *InNode,SB3dNode *ParentNode); + void getNodeAnimation(f32 frame,SB3dNode *Node,core::vector3df &position, core::vector3df &scale, core::quaternion &rotation); + void animateNodes(f32 frame,f32 startFrame, f32 endFrame); + void slerp(core::quaternion A,core::quaternion B,core::quaternion &C,f32 t); + + void calculateTangents(core::vector3df& normal, + core::vector3df& tangent, core::vector3df& binormal, + core::vector3df& vt1, core::vector3df& vt2, core::vector3df& vt3, + core::vector2df& tc1, core::vector2df& tc2, core::vector2df& tc3); + + + void createSkelton_Helper(ISceneManager* SceneManager, core::array &JointChildSceneNodes, ISceneNode *AnimatedMeshSceneNode, ISceneNode* ParentNode, SB3dNode *ParentB3dNode, SB3dNode *B3dNode); + + + + core::array B3dStack; + + f32 totalTime; + bool HasAnimation; + bool HasBones; + + s32 lastCalculatedFrame; + s32 lastAnimateMode; + + bool NormalsInFile; + bool AnimateNormals; + + //0- Constant 1- Linear + s32 InterpolationMode; + + //0-None 1-Update nodes only 2-Update skin only 3-Update both nodes and skin + s32 AnimateMode; + + core::stringc readString(io::IReadFile* file); + core::stringc stripPathString(core::stringc oldstring, bool keepPath); + void readFloats(io::IReadFile* file, f32* vec, u32 count); + + core::aabbox3d BoundingBox; + core::array Materials; + core::array Textures; + + core::array BaseVertices; + + core::array Vertices_Moved; + core::array Vertices_Alpha; + core::array AnimatedVertices_VertexID; + core::array AnimatedVertices_MeshBuffer; + core::array Buffers; + + video::IVideoDriver* Driver; + }; + +} // end namespace scene +} // end namespace irr + +#endif + + diff --git a/src/dep/src/irrlicht/CAnimatedMeshMD2.cpp b/src/dep/src/irrlicht/CAnimatedMeshMD2.cpp index ec45988..c0dff29 100644 --- a/src/dep/src/irrlicht/CAnimatedMeshMD2.cpp +++ b/src/dep/src/irrlicht/CAnimatedMeshMD2.cpp @@ -1,855 +1,855 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CAnimatedMeshMD2.h" -#include "os.h" -#include "SColor.h" -#include "IReadFile.h" -#include "irrMath.h" - -namespace irr -{ -namespace scene -{ - -#ifdef _MSC_VER -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - // structs needed to load the md2-format - - const s32 MD2_MAGIC_NUMBER = 844121161; - const s32 MD2_VERSION = 8; - const s32 MD2_MAX_VERTS = 2048; - - // TA: private - const s32 MD2_FRAME_SHIFT = 2; - const f32 MD2_FRAME_SHIFT_RECIPROCAL = 1.f / ( 1 << MD2_FRAME_SHIFT ); - - struct SMD2Header - { - s32 magic; - s32 version; - s32 skinWidth; - s32 skinHeight; - s32 frameSize; - s32 numSkins; - s32 numVertices; - s32 numTexcoords; - s32 numTriangles; - s32 numGlCommands; - s32 numFrames; - s32 offsetSkins; - s32 offsetTexcoords; - s32 offsetTriangles; - s32 offsetFrames; - s32 offsetGlCommands; - s32 offsetEnd; - } PACK_STRUCT; - - struct SMD2Vertex - { - u8 vertex[3]; - u8 lightNormalIndex; - } PACK_STRUCT; - - struct SMD2Frame - { - f32 scale[3]; - f32 translate[3]; - c8 name[16]; - SMD2Vertex vertices[1]; - } PACK_STRUCT; - - struct SMD2Triangle - { - u16 vertexIndices[3]; - u16 textureIndices[3]; - } PACK_STRUCT; - - struct SMD2TextureCoordinate - { - s16 s; - s16 t; - } PACK_STRUCT; - - struct SMD2GLCommand - { - f32 s, t; - s32 vertexIndex; - } PACK_STRUCT; - -// Default alignment -#ifdef _MSC_VER -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - - -const s32 Q2_VERTEX_NORMAL_TABLE_SIZE = 162; - -static const f32 Q2_VERTEX_NORMAL_TABLE[Q2_VERTEX_NORMAL_TABLE_SIZE][3] = { - {-0.525731f, 0.000000f, 0.850651f}, - {-0.442863f, 0.238856f, 0.864188f}, - {-0.295242f, 0.000000f, 0.955423f}, - {-0.309017f, 0.500000f, 0.809017f}, - {-0.162460f, 0.262866f, 0.951056f}, - {0.000000f, 0.000000f, 1.000000f}, - {0.000000f, 0.850651f, 0.525731f}, - {-0.147621f, 0.716567f, 0.681718f}, - {0.147621f, 0.716567f, 0.681718f}, - {0.000000f, 0.525731f, 0.850651f}, - {0.309017f, 0.500000f, 0.809017f}, - {0.525731f, 0.000000f, 0.850651f}, - {0.295242f, 0.000000f, 0.955423f}, - {0.442863f, 0.238856f, 0.864188f}, - {0.162460f, 0.262866f, 0.951056f}, - {-0.681718f, 0.147621f, 0.716567f}, - {-0.809017f, 0.309017f, 0.500000f}, - {-0.587785f, 0.425325f, 0.688191f}, - {-0.850651f, 0.525731f, 0.000000f}, - {-0.864188f, 0.442863f, 0.238856f}, - {-0.716567f, 0.681718f, 0.147621f}, - {-0.688191f, 0.587785f, 0.425325f}, - {-0.500000f, 0.809017f, 0.309017f}, - {-0.238856f, 0.864188f, 0.442863f}, - {-0.425325f, 0.688191f, 0.587785f}, - {-0.716567f, 0.681718f, -0.147621f}, - {-0.500000f, 0.809017f, -0.309017f}, - {-0.525731f, 0.850651f, 0.000000f}, - {0.000000f, 0.850651f, -0.525731f}, - {-0.238856f, 0.864188f, -0.442863f}, - {0.000000f, 0.955423f, -0.295242f}, - {-0.262866f, 0.951056f, -0.162460f}, - {0.000000f, 1.000000f, 0.000000f}, - {0.000000f, 0.955423f, 0.295242f}, - {-0.262866f, 0.951056f, 0.162460f}, - {0.238856f, 0.864188f, 0.442863f}, - {0.262866f, 0.951056f, 0.162460f}, - {0.500000f, 0.809017f, 0.309017f}, - {0.238856f, 0.864188f, -0.442863f}, - {0.262866f, 0.951056f, -0.162460f}, - {0.500000f, 0.809017f, -0.309017f}, - {0.850651f, 0.525731f, 0.000000f}, - {0.716567f, 0.681718f, 0.147621f}, - {0.716567f, 0.681718f, -0.147621f}, - {0.525731f, 0.850651f, 0.000000f}, - {0.425325f, 0.688191f, 0.587785f}, - {0.864188f, 0.442863f, 0.238856f}, - {0.688191f, 0.587785f, 0.425325f}, - {0.809017f, 0.309017f, 0.500000f}, - {0.681718f, 0.147621f, 0.716567f}, - {0.587785f, 0.425325f, 0.688191f}, - {0.955423f, 0.295242f, 0.000000f}, - {1.000000f, 0.000000f, 0.000000f}, - {0.951056f, 0.162460f, 0.262866f}, - {0.850651f, -0.525731f, 0.000000f}, - {0.955423f, -0.295242f, 0.000000f}, - {0.864188f, -0.442863f, 0.238856f}, - {0.951056f, -0.162460f, 0.262866f}, - {0.809017f, -0.309017f, 0.500000f}, - {0.681718f, -0.147621f, 0.716567f}, - {0.850651f, 0.000000f, 0.525731f}, - {0.864188f, 0.442863f, -0.238856f}, - {0.809017f, 0.309017f, -0.500000f}, - {0.951056f, 0.162460f, -0.262866f}, - {0.525731f, 0.000000f, -0.850651f}, - {0.681718f, 0.147621f, -0.716567f}, - {0.681718f, -0.147621f, -0.716567f}, - {0.850651f, 0.000000f, -0.525731f}, - {0.809017f, -0.309017f, -0.500000f}, - {0.864188f, -0.442863f, -0.238856f}, - {0.951056f, -0.162460f, -0.262866f}, - {0.147621f, 0.716567f, -0.681718f}, - {0.309017f, 0.500000f, -0.809017f}, - {0.425325f, 0.688191f, -0.587785f}, - {0.442863f, 0.238856f, -0.864188f}, - {0.587785f, 0.425325f, -0.688191f}, - {0.688191f, 0.587785f, -0.425325f}, - {-0.147621f, 0.716567f, -0.681718f}, - {-0.309017f, 0.500000f, -0.809017f}, - {0.000000f, 0.525731f, -0.850651f}, - {-0.525731f, 0.000000f, -0.850651f}, - {-0.442863f, 0.238856f, -0.864188f}, - {-0.295242f, 0.000000f, -0.955423f}, - {-0.162460f, 0.262866f, -0.951056f}, - {0.000000f, 0.000000f, -1.000000f}, - {0.295242f, 0.000000f, -0.955423f}, - {0.162460f, 0.262866f, -0.951056f}, - {-0.442863f, -0.238856f, -0.864188f}, - {-0.309017f, -0.500000f, -0.809017f}, - {-0.162460f, -0.262866f, -0.951056f}, - {0.000000f, -0.850651f, -0.525731f}, - {-0.147621f, -0.716567f, -0.681718f}, - {0.147621f, -0.716567f, -0.681718f}, - {0.000000f, -0.525731f, -0.850651f}, - {0.309017f, -0.500000f, -0.809017f}, - {0.442863f, -0.238856f, -0.864188f}, - {0.162460f, -0.262866f, -0.951056f}, - {0.238856f, -0.864188f, -0.442863f}, - {0.500000f, -0.809017f, -0.309017f}, - {0.425325f, -0.688191f, -0.587785f}, - {0.716567f, -0.681718f, -0.147621f}, - {0.688191f, -0.587785f, -0.425325f}, - {0.587785f, -0.425325f, -0.688191f}, - {0.000000f, -0.955423f, -0.295242f}, - {0.000000f, -1.000000f, 0.000000f}, - {0.262866f, -0.951056f, -0.162460f}, - {0.000000f, -0.850651f, 0.525731f}, - {0.000000f, -0.955423f, 0.295242f}, - {0.238856f, -0.864188f, 0.442863f}, - {0.262866f, -0.951056f, 0.162460f}, - {0.500000f, -0.809017f, 0.309017f}, - {0.716567f, -0.681718f, 0.147621f}, - {0.525731f, -0.850651f, 0.000000f}, - {-0.238856f, -0.864188f, -0.442863f}, - {-0.500000f, -0.809017f, -0.309017f}, - {-0.262866f, -0.951056f, -0.162460f}, - {-0.850651f, -0.525731f, 0.000000f}, - {-0.716567f, -0.681718f, -0.147621f}, - {-0.716567f, -0.681718f, 0.147621f}, - {-0.525731f, -0.850651f, 0.000000f}, - {-0.500000f, -0.809017f, 0.309017f}, - {-0.238856f, -0.864188f, 0.442863f}, - {-0.262866f, -0.951056f, 0.162460f}, - {-0.864188f, -0.442863f, 0.238856f}, - {-0.809017f, -0.309017f, 0.500000f}, - {-0.688191f, -0.587785f, 0.425325f}, - {-0.681718f, -0.147621f, 0.716567f}, - {-0.442863f, -0.238856f, 0.864188f}, - {-0.587785f, -0.425325f, 0.688191f}, - {-0.309017f, -0.500000f, 0.809017f}, - {-0.147621f, -0.716567f, 0.681718f}, - {-0.425325f, -0.688191f, 0.587785f}, - {-0.162460f, -0.262866f, 0.951056f}, - {0.442863f, -0.238856f, 0.864188f}, - {0.162460f, -0.262866f, 0.951056f}, - {0.309017f, -0.500000f, 0.809017f}, - {0.147621f, -0.716567f, 0.681718f}, - {0.000000f, -0.525731f, 0.850651f}, - {0.425325f, -0.688191f, 0.587785f}, - {0.587785f, -0.425325f, 0.688191f}, - {0.688191f, -0.587785f, 0.425325f}, - {-0.955423f, 0.295242f, 0.000000f}, - {-0.951056f, 0.162460f, 0.262866f}, - {-1.000000f, 0.000000f, 0.000000f}, - {-0.850651f, 0.000000f, 0.525731f}, - {-0.955423f, -0.295242f, 0.000000f}, - {-0.951056f, -0.162460f, 0.262866f}, - {-0.864188f, 0.442863f, -0.238856f}, - {-0.951056f, 0.162460f, -0.262866f}, - {-0.809017f, 0.309017f, -0.500000f}, - {-0.864188f, -0.442863f, -0.238856f}, - {-0.951056f, -0.162460f, -0.262866f}, - {-0.809017f, -0.309017f, -0.500000f}, - {-0.681718f, 0.147621f, -0.716567f}, - {-0.681718f, -0.147621f, -0.716567f}, - {-0.850651f, 0.000000f, -0.525731f}, - {-0.688191f, 0.587785f, -0.425325f}, - {-0.587785f, 0.425325f, -0.688191f}, - {-0.425325f, 0.688191f, -0.587785f}, - {-0.425325f, -0.688191f, -0.587785f}, - {-0.587785f, -0.425325f, -0.688191f}, - {-0.688191f, -0.587785f, -0.425325f}, - }; - -struct SMD2AnimationType -{ - s32 begin; - s32 end; - s32 fps; -}; - -static const SMD2AnimationType MD2AnimationTypeList[21] = -{ - { 0, 39, 9 }, // STAND - { 40, 45, 10 }, // RUN - { 46, 53, 10 }, // ATTACK - { 54, 57, 7 }, // PAIN_A - { 58, 61, 7 }, // PAIN_B - { 62, 65, 7 }, // PAIN_C - { 66, 71, 7 }, // JUMP - { 72, 83, 7 }, // FLIP - { 84, 94, 7 }, // SALUTE - { 95, 111, 10 }, // FALLBACK - { 112, 122, 7 }, // WAVE - { 123, 134, 6 }, // POINT - { 135, 153, 10 }, // CROUCH_STAND - { 154, 159, 7 }, // CROUCH_WALK - { 160, 168, 10 }, // CROUCH_ATTACK - { 169, 172, 7 }, // CROUCH_PAIN - { 173, 177, 5 }, // CROUCH_DEATH - { 178, 183, 7 }, // DEATH_FALLBACK - { 184, 189, 7 }, // DEATH_FALLFORWARD - { 190, 197, 7 }, // DEATH_FALLBACKSLOW - { 198, 198, 5 }, // BOOM -}; - - -//! constructor -CAnimatedMeshMD2::CAnimatedMeshMD2() -: FrameList(0), FrameCount(0), TriangleCount(0) -{ - #ifdef _DEBUG - IAnimatedMesh::setDebugName("CAnimatedMeshMD2 IAnimatedMesh"); - IMesh::setDebugName("CAnimatedMeshMD2 IMesh"); - IMeshBuffer::setDebugName("CAnimatedMeshMD2 IMeshBuffer"); - #endif -} - - - -//! destructor -CAnimatedMeshMD2::~CAnimatedMeshMD2() -{ - if (FrameList) - delete [] FrameList; -} - - - -//! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. -s32 CAnimatedMeshMD2::getFrameCount() -{ - return FrameCount< (FrameCount<>MD2_FRAME_SHIFT; - secondFrame = frame>>MD2_FRAME_SHIFT; - div = 1.0f; - } - else - { - // key frames - u32 s = startFrameLoop >> MD2_FRAME_SHIFT; - u32 e = endFrameLoop >> MD2_FRAME_SHIFT; - - firstFrame = frame >> MD2_FRAME_SHIFT; - secondFrame = core::if_c_a_else_b ( firstFrame + 1 > e, s, firstFrame + 1 ); - - firstFrame = core::s32_min ( FrameCount - 1, firstFrame ); - secondFrame = core::s32_min ( FrameCount - 1, secondFrame ); - - //div = (frame % (1<Pos = (second->Pos - first->Pos) * div + first->Pos; - target->Normal = (second->Normal - first->Normal) * div + first->Normal; - - ++target; - ++first; - ++second; - } - - //update bounding box - BoundingBox = BoxList[secondFrame].getInterpolated(BoxList[firstFrame], div); -} - - - - -//! loads an md2 file -bool CAnimatedMeshMD2::loadFile(io::IReadFile* file) -{ - if (!file) - return false; - - SMD2Header header; - - file->read(&header, sizeof(SMD2Header)); - -#ifdef __BIG_ENDIAN__ - header.magic = os::Byteswap::byteswap(header.magic); - header.version = os::Byteswap::byteswap(header.version); - header.skinWidth = os::Byteswap::byteswap(header.skinWidth); - header.skinHeight = os::Byteswap::byteswap(header.skinHeight); - header.frameSize = os::Byteswap::byteswap(header.frameSize); - header.numSkins = os::Byteswap::byteswap(header.numSkins); - header.numVertices = os::Byteswap::byteswap(header.numVertices); - header.numTexcoords = os::Byteswap::byteswap(header.numTexcoords); - header.numTriangles = os::Byteswap::byteswap(header.numTriangles); - header.numGlCommands = os::Byteswap::byteswap(header.numGlCommands); - header.numFrames = os::Byteswap::byteswap(header.numFrames); - header.offsetSkins = os::Byteswap::byteswap(header.offsetSkins); - header.offsetTexcoords = os::Byteswap::byteswap(header.offsetTexcoords); - header.offsetTriangles = os::Byteswap::byteswap(header.offsetTriangles); - header.offsetFrames = os::Byteswap::byteswap(header.offsetFrames); - header.offsetGlCommands = os::Byteswap::byteswap(header.offsetGlCommands); - header.offsetEnd = os::Byteswap::byteswap(header.offsetEnd); -#endif - - if (header.magic != MD2_MAGIC_NUMBER || header.version != MD2_VERSION) - { - os::Printer::log("MD2 Loader: Wrong file header", file->getFileName(), ELL_WARNING); - return false; - } - - // create Memory for indices and frames - - TriangleCount = header.numTriangles; - if (FrameList) - delete [] FrameList; - FrameList = new core::array[header.numFrames]; - FrameCount = header.numFrames; - - s32 i; - - for (i=0; iseek(header.offsetTexcoords, false); - SMD2TextureCoordinate* textureCoords = new SMD2TextureCoordinate[header.numTexcoords]; - - if (!file->read(textureCoords, sizeof(SMD2TextureCoordinate)*header.numTexcoords)) - { - os::Printer::log("MD2 Loader: Error reading TextureCoords.", file->getFileName(), ELL_ERROR); - return false; - } - -#ifdef __BIG_ENDIAN__ - for (i=0; iseek(header.offsetTriangles, false); - - SMD2Triangle *triangles = new SMD2Triangle[header.numTriangles]; - if (!file->read(triangles, header.numTriangles *sizeof(SMD2Triangle))) - { - os::Printer::log("MD2 Loader: Error reading triangles.", file->getFileName(), ELL_ERROR); - return false; - } - -#ifdef __BIG_ENDIAN__ - for (i=0; i* vertices = new core::array< core::vector3df >[header.numFrames]; - core::array< core::vector3df >* normals = new core::array< core::vector3df >[header.numFrames]; - - file->seek(header.offsetFrames, false); - - for (i = 0; iread(frame, header.frameSize); - -#ifdef __BIG_ENDIAN__ - frame->scale[0] = os::Byteswap::byteswap(frame->scale[0]); - frame->scale[1] = os::Byteswap::byteswap(frame->scale[1]); - frame->scale[2] = os::Byteswap::byteswap(frame->scale[2]); - frame->translate[0] = os::Byteswap::byteswap(frame->translate[0]); - frame->translate[1] = os::Byteswap::byteswap(frame->translate[1]); - frame->translate[2] = os::Byteswap::byteswap(frame->translate[2]); -#endif - // store frame data - - SFrameData fdata; - fdata.begin = i; - fdata.end = i; - fdata.fps = 7; - - if (frame->name[0]) - { - for (s32 s = 0; frame->name[s]!=0 && (frame->name[s] < '0' || - frame->name[s] > '9'); ++s) - fdata.name += frame->name[s]; - - if (!FrameData.empty() && FrameData[FrameData.size()-1].name == fdata.name) - ++FrameData[FrameData.size()-1].end; - else - FrameData.push_back(fdata); - } - - // add vertices - - vertices[i].reallocate(header.numVertices); - for (s32 j=0; jvertices[j].vertex[0] * frame->scale[0] + frame->translate[0]; - v.Z = frame->vertices[j].vertex[1] * frame->scale[1] + frame->translate[1]; - v.Y = frame->vertices[j].vertex[2] * frame->scale[2] + frame->translate[2]; - - vertices[i].push_back(v); - - s32 normalidx = frame->vertices[j].lightNormalIndex; - if (normalidx > 0 && normalidx < Q2_VERTEX_NORMAL_TABLE_SIZE) - { - v.X = Q2_VERTEX_NORMAL_TABLE[normalidx][0]; - v.Y = Q2_VERTEX_NORMAL_TABLE[normalidx][1]; - v.Z = Q2_VERTEX_NORMAL_TABLE[normalidx][2]; - } - - normals[i].push_back(v); - } - - // calculate bounding boxes - if (header.numVertices) - { - core::aabbox3d box; - box.reset(vertices[i][0]); - - for (s32 j=1; j& vert = vertices[f]; - - for (s32 t=0; t=FrameCount) - defaultFrame = 0; - - for (u32 j=0; j& CAnimatedMeshMD2::getBoundingBox() const -{ - return BoundingBox; -} - -//! set user axis aligned bounding box -void CAnimatedMeshMD2::setBoundingBox( const core::aabbox3df& box) -{ - BoundingBox = box; -} - - - -//! calculates normals -void CAnimatedMeshMD2::calculateNormals() -{ - for (u32 i=0; i plane( - vtx[Indices[j]].Pos, vtx[Indices[j+1]].Pos, vtx[Indices[j+2]].Pos); - - vtx[Indices[j]].Normal = plane.Normal; - vtx[Indices[j+1]].Normal = plane.Normal; - vtx[Indices[j+2]].Normal = plane.Normal; - } - } -} - - -//! Returns the type of the animated mesh. -E_ANIMATED_MESH_TYPE CAnimatedMeshMD2::getMeshType() const -{ - return EAMT_MD2; -} - - -//! Returns frame loop data for a special MD2 animation type. -void CAnimatedMeshMD2::getFrameLoop(EMD2_ANIMATION_TYPE l, - s32& outBegin, s32& outEnd, s32& outFPS) const -{ - if (l < 0 || l >= EMAT_COUNT) - return; - - outBegin = MD2AnimationTypeList[l].begin << MD2_FRAME_SHIFT; - outEnd = MD2AnimationTypeList[l].end << MD2_FRAME_SHIFT; - - // correct to anim between last->first frame - outEnd += MD2_FRAME_SHIFT == 0 ? 1 : ( 1 << MD2_FRAME_SHIFT ) - 1; - outFPS = MD2AnimationTypeList[l].fps << MD2_FRAME_SHIFT; -} - - -//! Returns frame loop data for a special MD2 animation type. -bool CAnimatedMeshMD2::getFrameLoop(const c8* name, - s32& outBegin, s32&outEnd, s32& outFPS) const -{ - for (s32 i=0; i<(s32)FrameData.size(); ++i) - if (FrameData[i].name == name) - { - outBegin = FrameData[i].begin << MD2_FRAME_SHIFT; - outEnd = FrameData[i].end << MD2_FRAME_SHIFT; - outEnd += MD2_FRAME_SHIFT == 0 ? 1 : ( 1 << MD2_FRAME_SHIFT ) - 1; - outFPS = FrameData[i].fps << MD2_FRAME_SHIFT; - return true; - } - - return false; -} - - - -//! Returns amount of md2 animations in this file. -s32 CAnimatedMeshMD2::getAnimationCount() const -{ - return FrameData.size(); -} - - -//! Returns name of md2 animation. -const c8* CAnimatedMeshMD2::getAnimationName(s32 nr) const -{ - if (nr < 0 || nr >= (s32)FrameData.size()) - return 0; - - return FrameData[nr].name.c_str(); -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CAnimatedMeshMD2.h" +#include "os.h" +#include "SColor.h" +#include "IReadFile.h" +#include "irrMath.h" + +namespace irr +{ +namespace scene +{ + +#ifdef _MSC_VER +# pragma pack( push, packing ) +# pragma pack( 1 ) +# define PACK_STRUCT +#elif defined( __GNUC__ ) +# define PACK_STRUCT __attribute__((packed)) +#else +# error compiler not supported +#endif + + // structs needed to load the md2-format + + const s32 MD2_MAGIC_NUMBER = 844121161; + const s32 MD2_VERSION = 8; + const s32 MD2_MAX_VERTS = 2048; + + // TA: private + const s32 MD2_FRAME_SHIFT = 2; + const f32 MD2_FRAME_SHIFT_RECIPROCAL = 1.f / ( 1 << MD2_FRAME_SHIFT ); + + struct SMD2Header + { + s32 magic; + s32 version; + s32 skinWidth; + s32 skinHeight; + s32 frameSize; + s32 numSkins; + s32 numVertices; + s32 numTexcoords; + s32 numTriangles; + s32 numGlCommands; + s32 numFrames; + s32 offsetSkins; + s32 offsetTexcoords; + s32 offsetTriangles; + s32 offsetFrames; + s32 offsetGlCommands; + s32 offsetEnd; + } PACK_STRUCT; + + struct SMD2Vertex + { + u8 vertex[3]; + u8 lightNormalIndex; + } PACK_STRUCT; + + struct SMD2Frame + { + f32 scale[3]; + f32 translate[3]; + c8 name[16]; + SMD2Vertex vertices[1]; + } PACK_STRUCT; + + struct SMD2Triangle + { + u16 vertexIndices[3]; + u16 textureIndices[3]; + } PACK_STRUCT; + + struct SMD2TextureCoordinate + { + s16 s; + s16 t; + } PACK_STRUCT; + + struct SMD2GLCommand + { + f32 s, t; + s32 vertexIndex; + } PACK_STRUCT; + +// Default alignment +#ifdef _MSC_VER +# pragma pack( pop, packing ) +#endif + +#undef PACK_STRUCT + + +const s32 Q2_VERTEX_NORMAL_TABLE_SIZE = 162; + +static const f32 Q2_VERTEX_NORMAL_TABLE[Q2_VERTEX_NORMAL_TABLE_SIZE][3] = { + {-0.525731f, 0.000000f, 0.850651f}, + {-0.442863f, 0.238856f, 0.864188f}, + {-0.295242f, 0.000000f, 0.955423f}, + {-0.309017f, 0.500000f, 0.809017f}, + {-0.162460f, 0.262866f, 0.951056f}, + {0.000000f, 0.000000f, 1.000000f}, + {0.000000f, 0.850651f, 0.525731f}, + {-0.147621f, 0.716567f, 0.681718f}, + {0.147621f, 0.716567f, 0.681718f}, + {0.000000f, 0.525731f, 0.850651f}, + {0.309017f, 0.500000f, 0.809017f}, + {0.525731f, 0.000000f, 0.850651f}, + {0.295242f, 0.000000f, 0.955423f}, + {0.442863f, 0.238856f, 0.864188f}, + {0.162460f, 0.262866f, 0.951056f}, + {-0.681718f, 0.147621f, 0.716567f}, + {-0.809017f, 0.309017f, 0.500000f}, + {-0.587785f, 0.425325f, 0.688191f}, + {-0.850651f, 0.525731f, 0.000000f}, + {-0.864188f, 0.442863f, 0.238856f}, + {-0.716567f, 0.681718f, 0.147621f}, + {-0.688191f, 0.587785f, 0.425325f}, + {-0.500000f, 0.809017f, 0.309017f}, + {-0.238856f, 0.864188f, 0.442863f}, + {-0.425325f, 0.688191f, 0.587785f}, + {-0.716567f, 0.681718f, -0.147621f}, + {-0.500000f, 0.809017f, -0.309017f}, + {-0.525731f, 0.850651f, 0.000000f}, + {0.000000f, 0.850651f, -0.525731f}, + {-0.238856f, 0.864188f, -0.442863f}, + {0.000000f, 0.955423f, -0.295242f}, + {-0.262866f, 0.951056f, -0.162460f}, + {0.000000f, 1.000000f, 0.000000f}, + {0.000000f, 0.955423f, 0.295242f}, + {-0.262866f, 0.951056f, 0.162460f}, + {0.238856f, 0.864188f, 0.442863f}, + {0.262866f, 0.951056f, 0.162460f}, + {0.500000f, 0.809017f, 0.309017f}, + {0.238856f, 0.864188f, -0.442863f}, + {0.262866f, 0.951056f, -0.162460f}, + {0.500000f, 0.809017f, -0.309017f}, + {0.850651f, 0.525731f, 0.000000f}, + {0.716567f, 0.681718f, 0.147621f}, + {0.716567f, 0.681718f, -0.147621f}, + {0.525731f, 0.850651f, 0.000000f}, + {0.425325f, 0.688191f, 0.587785f}, + {0.864188f, 0.442863f, 0.238856f}, + {0.688191f, 0.587785f, 0.425325f}, + {0.809017f, 0.309017f, 0.500000f}, + {0.681718f, 0.147621f, 0.716567f}, + {0.587785f, 0.425325f, 0.688191f}, + {0.955423f, 0.295242f, 0.000000f}, + {1.000000f, 0.000000f, 0.000000f}, + {0.951056f, 0.162460f, 0.262866f}, + {0.850651f, -0.525731f, 0.000000f}, + {0.955423f, -0.295242f, 0.000000f}, + {0.864188f, -0.442863f, 0.238856f}, + {0.951056f, -0.162460f, 0.262866f}, + {0.809017f, -0.309017f, 0.500000f}, + {0.681718f, -0.147621f, 0.716567f}, + {0.850651f, 0.000000f, 0.525731f}, + {0.864188f, 0.442863f, -0.238856f}, + {0.809017f, 0.309017f, -0.500000f}, + {0.951056f, 0.162460f, -0.262866f}, + {0.525731f, 0.000000f, -0.850651f}, + {0.681718f, 0.147621f, -0.716567f}, + {0.681718f, -0.147621f, -0.716567f}, + {0.850651f, 0.000000f, -0.525731f}, + {0.809017f, -0.309017f, -0.500000f}, + {0.864188f, -0.442863f, -0.238856f}, + {0.951056f, -0.162460f, -0.262866f}, + {0.147621f, 0.716567f, -0.681718f}, + {0.309017f, 0.500000f, -0.809017f}, + {0.425325f, 0.688191f, -0.587785f}, + {0.442863f, 0.238856f, -0.864188f}, + {0.587785f, 0.425325f, -0.688191f}, + {0.688191f, 0.587785f, -0.425325f}, + {-0.147621f, 0.716567f, -0.681718f}, + {-0.309017f, 0.500000f, -0.809017f}, + {0.000000f, 0.525731f, -0.850651f}, + {-0.525731f, 0.000000f, -0.850651f}, + {-0.442863f, 0.238856f, -0.864188f}, + {-0.295242f, 0.000000f, -0.955423f}, + {-0.162460f, 0.262866f, -0.951056f}, + {0.000000f, 0.000000f, -1.000000f}, + {0.295242f, 0.000000f, -0.955423f}, + {0.162460f, 0.262866f, -0.951056f}, + {-0.442863f, -0.238856f, -0.864188f}, + {-0.309017f, -0.500000f, -0.809017f}, + {-0.162460f, -0.262866f, -0.951056f}, + {0.000000f, -0.850651f, -0.525731f}, + {-0.147621f, -0.716567f, -0.681718f}, + {0.147621f, -0.716567f, -0.681718f}, + {0.000000f, -0.525731f, -0.850651f}, + {0.309017f, -0.500000f, -0.809017f}, + {0.442863f, -0.238856f, -0.864188f}, + {0.162460f, -0.262866f, -0.951056f}, + {0.238856f, -0.864188f, -0.442863f}, + {0.500000f, -0.809017f, -0.309017f}, + {0.425325f, -0.688191f, -0.587785f}, + {0.716567f, -0.681718f, -0.147621f}, + {0.688191f, -0.587785f, -0.425325f}, + {0.587785f, -0.425325f, -0.688191f}, + {0.000000f, -0.955423f, -0.295242f}, + {0.000000f, -1.000000f, 0.000000f}, + {0.262866f, -0.951056f, -0.162460f}, + {0.000000f, -0.850651f, 0.525731f}, + {0.000000f, -0.955423f, 0.295242f}, + {0.238856f, -0.864188f, 0.442863f}, + {0.262866f, -0.951056f, 0.162460f}, + {0.500000f, -0.809017f, 0.309017f}, + {0.716567f, -0.681718f, 0.147621f}, + {0.525731f, -0.850651f, 0.000000f}, + {-0.238856f, -0.864188f, -0.442863f}, + {-0.500000f, -0.809017f, -0.309017f}, + {-0.262866f, -0.951056f, -0.162460f}, + {-0.850651f, -0.525731f, 0.000000f}, + {-0.716567f, -0.681718f, -0.147621f}, + {-0.716567f, -0.681718f, 0.147621f}, + {-0.525731f, -0.850651f, 0.000000f}, + {-0.500000f, -0.809017f, 0.309017f}, + {-0.238856f, -0.864188f, 0.442863f}, + {-0.262866f, -0.951056f, 0.162460f}, + {-0.864188f, -0.442863f, 0.238856f}, + {-0.809017f, -0.309017f, 0.500000f}, + {-0.688191f, -0.587785f, 0.425325f}, + {-0.681718f, -0.147621f, 0.716567f}, + {-0.442863f, -0.238856f, 0.864188f}, + {-0.587785f, -0.425325f, 0.688191f}, + {-0.309017f, -0.500000f, 0.809017f}, + {-0.147621f, -0.716567f, 0.681718f}, + {-0.425325f, -0.688191f, 0.587785f}, + {-0.162460f, -0.262866f, 0.951056f}, + {0.442863f, -0.238856f, 0.864188f}, + {0.162460f, -0.262866f, 0.951056f}, + {0.309017f, -0.500000f, 0.809017f}, + {0.147621f, -0.716567f, 0.681718f}, + {0.000000f, -0.525731f, 0.850651f}, + {0.425325f, -0.688191f, 0.587785f}, + {0.587785f, -0.425325f, 0.688191f}, + {0.688191f, -0.587785f, 0.425325f}, + {-0.955423f, 0.295242f, 0.000000f}, + {-0.951056f, 0.162460f, 0.262866f}, + {-1.000000f, 0.000000f, 0.000000f}, + {-0.850651f, 0.000000f, 0.525731f}, + {-0.955423f, -0.295242f, 0.000000f}, + {-0.951056f, -0.162460f, 0.262866f}, + {-0.864188f, 0.442863f, -0.238856f}, + {-0.951056f, 0.162460f, -0.262866f}, + {-0.809017f, 0.309017f, -0.500000f}, + {-0.864188f, -0.442863f, -0.238856f}, + {-0.951056f, -0.162460f, -0.262866f}, + {-0.809017f, -0.309017f, -0.500000f}, + {-0.681718f, 0.147621f, -0.716567f}, + {-0.681718f, -0.147621f, -0.716567f}, + {-0.850651f, 0.000000f, -0.525731f}, + {-0.688191f, 0.587785f, -0.425325f}, + {-0.587785f, 0.425325f, -0.688191f}, + {-0.425325f, 0.688191f, -0.587785f}, + {-0.425325f, -0.688191f, -0.587785f}, + {-0.587785f, -0.425325f, -0.688191f}, + {-0.688191f, -0.587785f, -0.425325f}, + }; + +struct SMD2AnimationType +{ + s32 begin; + s32 end; + s32 fps; +}; + +static const SMD2AnimationType MD2AnimationTypeList[21] = +{ + { 0, 39, 9 }, // STAND + { 40, 45, 10 }, // RUN + { 46, 53, 10 }, // ATTACK + { 54, 57, 7 }, // PAIN_A + { 58, 61, 7 }, // PAIN_B + { 62, 65, 7 }, // PAIN_C + { 66, 71, 7 }, // JUMP + { 72, 83, 7 }, // FLIP + { 84, 94, 7 }, // SALUTE + { 95, 111, 10 }, // FALLBACK + { 112, 122, 7 }, // WAVE + { 123, 134, 6 }, // POINT + { 135, 153, 10 }, // CROUCH_STAND + { 154, 159, 7 }, // CROUCH_WALK + { 160, 168, 10 }, // CROUCH_ATTACK + { 169, 172, 7 }, // CROUCH_PAIN + { 173, 177, 5 }, // CROUCH_DEATH + { 178, 183, 7 }, // DEATH_FALLBACK + { 184, 189, 7 }, // DEATH_FALLFORWARD + { 190, 197, 7 }, // DEATH_FALLBACKSLOW + { 198, 198, 5 }, // BOOM +}; + + +//! constructor +CAnimatedMeshMD2::CAnimatedMeshMD2() +: FrameList(0), FrameCount(0), TriangleCount(0) +{ + #ifdef _DEBUG + IAnimatedMesh::setDebugName("CAnimatedMeshMD2 IAnimatedMesh"); + IMesh::setDebugName("CAnimatedMeshMD2 IMesh"); + IMeshBuffer::setDebugName("CAnimatedMeshMD2 IMeshBuffer"); + #endif +} + + + +//! destructor +CAnimatedMeshMD2::~CAnimatedMeshMD2() +{ + if (FrameList) + delete [] FrameList; +} + + + +//! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. +s32 CAnimatedMeshMD2::getFrameCount() +{ + return FrameCount< (FrameCount<>MD2_FRAME_SHIFT; + secondFrame = frame>>MD2_FRAME_SHIFT; + div = 1.0f; + } + else + { + // key frames + u32 s = startFrameLoop >> MD2_FRAME_SHIFT; + u32 e = endFrameLoop >> MD2_FRAME_SHIFT; + + firstFrame = frame >> MD2_FRAME_SHIFT; + secondFrame = core::if_c_a_else_b ( firstFrame + 1 > e, s, firstFrame + 1 ); + + firstFrame = core::s32_min ( FrameCount - 1, firstFrame ); + secondFrame = core::s32_min ( FrameCount - 1, secondFrame ); + + //div = (frame % (1<Pos = (second->Pos - first->Pos) * div + first->Pos; + target->Normal = (second->Normal - first->Normal) * div + first->Normal; + + ++target; + ++first; + ++second; + } + + //update bounding box + BoundingBox = BoxList[secondFrame].getInterpolated(BoxList[firstFrame], div); +} + + + + +//! loads an md2 file +bool CAnimatedMeshMD2::loadFile(io::IReadFile* file) +{ + if (!file) + return false; + + SMD2Header header; + + file->read(&header, sizeof(SMD2Header)); + +#ifdef __BIG_ENDIAN__ + header.magic = os::Byteswap::byteswap(header.magic); + header.version = os::Byteswap::byteswap(header.version); + header.skinWidth = os::Byteswap::byteswap(header.skinWidth); + header.skinHeight = os::Byteswap::byteswap(header.skinHeight); + header.frameSize = os::Byteswap::byteswap(header.frameSize); + header.numSkins = os::Byteswap::byteswap(header.numSkins); + header.numVertices = os::Byteswap::byteswap(header.numVertices); + header.numTexcoords = os::Byteswap::byteswap(header.numTexcoords); + header.numTriangles = os::Byteswap::byteswap(header.numTriangles); + header.numGlCommands = os::Byteswap::byteswap(header.numGlCommands); + header.numFrames = os::Byteswap::byteswap(header.numFrames); + header.offsetSkins = os::Byteswap::byteswap(header.offsetSkins); + header.offsetTexcoords = os::Byteswap::byteswap(header.offsetTexcoords); + header.offsetTriangles = os::Byteswap::byteswap(header.offsetTriangles); + header.offsetFrames = os::Byteswap::byteswap(header.offsetFrames); + header.offsetGlCommands = os::Byteswap::byteswap(header.offsetGlCommands); + header.offsetEnd = os::Byteswap::byteswap(header.offsetEnd); +#endif + + if (header.magic != MD2_MAGIC_NUMBER || header.version != MD2_VERSION) + { + os::Printer::log("MD2 Loader: Wrong file header", file->getFileName(), ELL_WARNING); + return false; + } + + // create Memory for indices and frames + + TriangleCount = header.numTriangles; + if (FrameList) + delete [] FrameList; + FrameList = new core::array[header.numFrames]; + FrameCount = header.numFrames; + + s32 i; + + for (i=0; iseek(header.offsetTexcoords, false); + SMD2TextureCoordinate* textureCoords = new SMD2TextureCoordinate[header.numTexcoords]; + + if (!file->read(textureCoords, sizeof(SMD2TextureCoordinate)*header.numTexcoords)) + { + os::Printer::log("MD2 Loader: Error reading TextureCoords.", file->getFileName(), ELL_ERROR); + return false; + } + +#ifdef __BIG_ENDIAN__ + for (i=0; iseek(header.offsetTriangles, false); + + SMD2Triangle *triangles = new SMD2Triangle[header.numTriangles]; + if (!file->read(triangles, header.numTriangles *sizeof(SMD2Triangle))) + { + os::Printer::log("MD2 Loader: Error reading triangles.", file->getFileName(), ELL_ERROR); + return false; + } + +#ifdef __BIG_ENDIAN__ + for (i=0; i* vertices = new core::array< core::vector3df >[header.numFrames]; + core::array< core::vector3df >* normals = new core::array< core::vector3df >[header.numFrames]; + + file->seek(header.offsetFrames, false); + + for (i = 0; iread(frame, header.frameSize); + +#ifdef __BIG_ENDIAN__ + frame->scale[0] = os::Byteswap::byteswap(frame->scale[0]); + frame->scale[1] = os::Byteswap::byteswap(frame->scale[1]); + frame->scale[2] = os::Byteswap::byteswap(frame->scale[2]); + frame->translate[0] = os::Byteswap::byteswap(frame->translate[0]); + frame->translate[1] = os::Byteswap::byteswap(frame->translate[1]); + frame->translate[2] = os::Byteswap::byteswap(frame->translate[2]); +#endif + // store frame data + + SFrameData fdata; + fdata.begin = i; + fdata.end = i; + fdata.fps = 7; + + if (frame->name[0]) + { + for (s32 s = 0; frame->name[s]!=0 && (frame->name[s] < '0' || + frame->name[s] > '9'); ++s) + fdata.name += frame->name[s]; + + if (!FrameData.empty() && FrameData[FrameData.size()-1].name == fdata.name) + ++FrameData[FrameData.size()-1].end; + else + FrameData.push_back(fdata); + } + + // add vertices + + vertices[i].reallocate(header.numVertices); + for (s32 j=0; jvertices[j].vertex[0] * frame->scale[0] + frame->translate[0]; + v.Z = frame->vertices[j].vertex[1] * frame->scale[1] + frame->translate[1]; + v.Y = frame->vertices[j].vertex[2] * frame->scale[2] + frame->translate[2]; + + vertices[i].push_back(v); + + s32 normalidx = frame->vertices[j].lightNormalIndex; + if (normalidx > 0 && normalidx < Q2_VERTEX_NORMAL_TABLE_SIZE) + { + v.X = Q2_VERTEX_NORMAL_TABLE[normalidx][0]; + v.Y = Q2_VERTEX_NORMAL_TABLE[normalidx][1]; + v.Z = Q2_VERTEX_NORMAL_TABLE[normalidx][2]; + } + + normals[i].push_back(v); + } + + // calculate bounding boxes + if (header.numVertices) + { + core::aabbox3d box; + box.reset(vertices[i][0]); + + for (s32 j=1; j& vert = vertices[f]; + + for (s32 t=0; t=FrameCount) + defaultFrame = 0; + + for (u32 j=0; j& CAnimatedMeshMD2::getBoundingBox() const +{ + return BoundingBox; +} + +//! set user axis aligned bounding box +void CAnimatedMeshMD2::setBoundingBox( const core::aabbox3df& box) +{ + BoundingBox = box; +} + + + +//! calculates normals +void CAnimatedMeshMD2::calculateNormals() +{ + for (u32 i=0; i plane( + vtx[Indices[j]].Pos, vtx[Indices[j+1]].Pos, vtx[Indices[j+2]].Pos); + + vtx[Indices[j]].Normal = plane.Normal; + vtx[Indices[j+1]].Normal = plane.Normal; + vtx[Indices[j+2]].Normal = plane.Normal; + } + } +} + + +//! Returns the type of the animated mesh. +E_ANIMATED_MESH_TYPE CAnimatedMeshMD2::getMeshType() const +{ + return EAMT_MD2; +} + + +//! Returns frame loop data for a special MD2 animation type. +void CAnimatedMeshMD2::getFrameLoop(EMD2_ANIMATION_TYPE l, + s32& outBegin, s32& outEnd, s32& outFPS) const +{ + if (l < 0 || l >= EMAT_COUNT) + return; + + outBegin = MD2AnimationTypeList[l].begin << MD2_FRAME_SHIFT; + outEnd = MD2AnimationTypeList[l].end << MD2_FRAME_SHIFT; + + // correct to anim between last->first frame + outEnd += MD2_FRAME_SHIFT == 0 ? 1 : ( 1 << MD2_FRAME_SHIFT ) - 1; + outFPS = MD2AnimationTypeList[l].fps << MD2_FRAME_SHIFT; +} + + +//! Returns frame loop data for a special MD2 animation type. +bool CAnimatedMeshMD2::getFrameLoop(const c8* name, + s32& outBegin, s32&outEnd, s32& outFPS) const +{ + for (s32 i=0; i<(s32)FrameData.size(); ++i) + if (FrameData[i].name == name) + { + outBegin = FrameData[i].begin << MD2_FRAME_SHIFT; + outEnd = FrameData[i].end << MD2_FRAME_SHIFT; + outEnd += MD2_FRAME_SHIFT == 0 ? 1 : ( 1 << MD2_FRAME_SHIFT ) - 1; + outFPS = FrameData[i].fps << MD2_FRAME_SHIFT; + return true; + } + + return false; +} + + + +//! Returns amount of md2 animations in this file. +s32 CAnimatedMeshMD2::getAnimationCount() const +{ + return FrameData.size(); +} + + +//! Returns name of md2 animation. +const c8* CAnimatedMeshMD2::getAnimationName(s32 nr) const +{ + if (nr < 0 || nr >= (s32)FrameData.size()) + return 0; + + return FrameData[nr].name.c_str(); +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CAnimatedMeshMD2.h b/src/dep/src/irrlicht/CAnimatedMeshMD2.h index 233570c..d5f7867 100644 --- a/src/dep/src/irrlicht/CAnimatedMeshMD2.h +++ b/src/dep/src/irrlicht/CAnimatedMeshMD2.h @@ -1,143 +1,143 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_ANIMATED_MESH_MD2_H_INCLUDED__ -#define __C_ANIMATED_MESH_MD2_H_INCLUDED__ - -#include "IAnimatedMeshMD2.h" -#include "IReadFile.h" -#include "S3DVertex.h" -#include "irrArray.h" -#include "irrString.h" - -namespace irr -{ -namespace scene -{ - - class CAnimatedMeshMD2 : public IAnimatedMeshMD2, public IMesh, public IMeshBuffer - { - public: - - //! constructor - CAnimatedMeshMD2(); - - //! destructor - virtual ~CAnimatedMeshMD2(); - - //! loads an md2 file - virtual bool loadFile(io::IReadFile* file); - - //! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. - virtual s32 getFrameCount(); - - //! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. - virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1); - - //! returns amount of mesh buffers. - virtual u32 getMeshBufferCount() const; - - //! returns pointer to a mesh buffer - virtual IMeshBuffer* getMeshBuffer(u32 nr) const; - - //! Returns pointer to a mesh buffer which fits a material - /** \param material: material to search for - \return Returns the pointer to the mesh buffer or - NULL if there is no such mesh buffer. */ - virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const; - - //! returns the material of this meshbuffer - virtual const video::SMaterial& getMaterial() const; - - //! returns the material of this meshbuffer - virtual video::SMaterial& getMaterial(); - - //! returns pointer to vertices - virtual const void* getVertices() const; - - //! returns pointer to vertices - virtual void* getVertices(); - - //! returns which type of vertex data is stored. - virtual video::E_VERTEX_TYPE getVertexType() const; - - //! returns the byte size (stride, pitch) of the vertex - virtual u32 getVertexPitch() const; - - //! returns amount of vertices - virtual u32 getVertexCount() const; - - //! returns pointer to Indices - virtual const u16* getIndices() const; - - //! returns pointer to Indices - virtual u16* getIndices(); - - //! returns amount of indices - virtual u32 getIndexCount() const; - - //! returns an axis aligned bounding box - virtual const core::aabbox3d& getBoundingBox() const; - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box); - - //! sets a flag of all contained materials to a new value - virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue); - - //! Returns the type of the animated mesh. - virtual E_ANIMATED_MESH_TYPE getMeshType() const; - - //! Returns frame loop data for a special MD2 animation type. - virtual void getFrameLoop(EMD2_ANIMATION_TYPE, - s32& outBegin, s32& outEnd, s32& outFps) const; - - //! Returns frame loop data for a special MD2 animation type. - virtual bool getFrameLoop(const c8* name, - s32& outBegin, s32& outEnd, s32& outFps) const; - - //! Returns amount of md2 animations in this file. - virtual s32 getAnimationCount() const; - - //! Returns name of md2 animation. - //! \param nr: Zero based index of animation. - virtual const c8* getAnimationName(s32 nr) const; - - private: - - //! updates the interpolation buffer - void updateInterpolationBuffer(s32 frame, s32 startFrame, s32 endFrame); - - //! calculates the bounding box - virtual void calculateBoundingBox(); - - //! calculates normals - void calculateNormals(); - - core::array Indices; - core::array *FrameList; - core::array > BoxList; - u32 FrameCount; - s32 TriangleCount; - video::SMaterial Material; - - core::array InterpolateBuffer; - core::aabbox3d BoundingBox; - - struct SFrameData - { - core::stringc name; - s32 begin; - s32 end; - s32 fps; - }; - - core::array< SFrameData > FrameData; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_ANIMATED_MESH_MD2_H_INCLUDED__ +#define __C_ANIMATED_MESH_MD2_H_INCLUDED__ + +#include "IAnimatedMeshMD2.h" +#include "IReadFile.h" +#include "S3DVertex.h" +#include "irrArray.h" +#include "irrString.h" + +namespace irr +{ +namespace scene +{ + + class CAnimatedMeshMD2 : public IAnimatedMeshMD2, public IMesh, public IMeshBuffer + { + public: + + //! constructor + CAnimatedMeshMD2(); + + //! destructor + virtual ~CAnimatedMeshMD2(); + + //! loads an md2 file + virtual bool loadFile(io::IReadFile* file); + + //! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. + virtual s32 getFrameCount(); + + //! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. + virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1); + + //! returns amount of mesh buffers. + virtual u32 getMeshBufferCount() const; + + //! returns pointer to a mesh buffer + virtual IMeshBuffer* getMeshBuffer(u32 nr) const; + + //! Returns pointer to a mesh buffer which fits a material + /** \param material: material to search for + \return Returns the pointer to the mesh buffer or + NULL if there is no such mesh buffer. */ + virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const; + + //! returns the material of this meshbuffer + virtual const video::SMaterial& getMaterial() const; + + //! returns the material of this meshbuffer + virtual video::SMaterial& getMaterial(); + + //! returns pointer to vertices + virtual const void* getVertices() const; + + //! returns pointer to vertices + virtual void* getVertices(); + + //! returns which type of vertex data is stored. + virtual video::E_VERTEX_TYPE getVertexType() const; + + //! returns the byte size (stride, pitch) of the vertex + virtual u32 getVertexPitch() const; + + //! returns amount of vertices + virtual u32 getVertexCount() const; + + //! returns pointer to Indices + virtual const u16* getIndices() const; + + //! returns pointer to Indices + virtual u16* getIndices(); + + //! returns amount of indices + virtual u32 getIndexCount() const; + + //! returns an axis aligned bounding box + virtual const core::aabbox3d& getBoundingBox() const; + + //! set user axis aligned bounding box + virtual void setBoundingBox( const core::aabbox3df& box); + + //! sets a flag of all contained materials to a new value + virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue); + + //! Returns the type of the animated mesh. + virtual E_ANIMATED_MESH_TYPE getMeshType() const; + + //! Returns frame loop data for a special MD2 animation type. + virtual void getFrameLoop(EMD2_ANIMATION_TYPE, + s32& outBegin, s32& outEnd, s32& outFps) const; + + //! Returns frame loop data for a special MD2 animation type. + virtual bool getFrameLoop(const c8* name, + s32& outBegin, s32& outEnd, s32& outFps) const; + + //! Returns amount of md2 animations in this file. + virtual s32 getAnimationCount() const; + + //! Returns name of md2 animation. + //! \param nr: Zero based index of animation. + virtual const c8* getAnimationName(s32 nr) const; + + private: + + //! updates the interpolation buffer + void updateInterpolationBuffer(s32 frame, s32 startFrame, s32 endFrame); + + //! calculates the bounding box + virtual void calculateBoundingBox(); + + //! calculates normals + void calculateNormals(); + + core::array Indices; + core::array *FrameList; + core::array > BoxList; + u32 FrameCount; + s32 TriangleCount; + video::SMaterial Material; + + core::array InterpolateBuffer; + core::aabbox3d BoundingBox; + + struct SFrameData + { + core::stringc name; + s32 begin; + s32 end; + s32 fps; + }; + + core::array< SFrameData > FrameData; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CAnimatedMeshMD3.cpp b/src/dep/src/irrlicht/CAnimatedMeshMD3.cpp index 3a7d716..1255424 100644 --- a/src/dep/src/irrlicht/CAnimatedMeshMD3.cpp +++ b/src/dep/src/irrlicht/CAnimatedMeshMD3.cpp @@ -1,413 +1,413 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Fabio Concas / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CAnimatedMeshMD3.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - - -#ifdef _MSC_VER -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - -struct SMD3Bone -{ - f32 Mins[3]; // bounding box per frame - f32 Maxs[3]; - f32 Position[3]; // position of bounding box - f32 scale; - c8 creator[16]; -}; - - -struct SMD3Tag -{ - c8 Name[64]; //name of 'tag' as it's usually called in the md3 files try to see it as a sub-mesh/seperate mesh-part. - f32 position[3]; //relative position of tag - f32 rotationMatrix[9]; //3x3 rotation direction of tag -}; - -struct SMD3Skin -{ - c8 name[68]; // name of skin -}; - - - -// Default alignment -#ifdef _MSC_VER -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - - -//! Constructor -CAnimatedMeshMD3::CAnimatedMeshMD3 () -: Mesh ( 0 ) -{ -#ifdef _DEBUG - setDebugName("CAnimatedMeshMD3"); -#endif - - Mesh = new SMD3Mesh (); - memset ( &Mesh->MD3Header, 0, sizeof ( Mesh->MD3Header ) ); - - setInterpolationShift ( 0, 0 ); -} - - - -//! Destructor -CAnimatedMeshMD3::~CAnimatedMeshMD3() -{ - if ( Mesh ) - Mesh->drop (); - -} - - - -//! Returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. -s32 CAnimatedMeshMD3::getFrameCount() -{ - return Mesh->MD3Header.numFrames << IPolShift; -} - -//! Rendering Hint -void CAnimatedMeshMD3::setInterpolationShift ( u32 shift, u32 loopMode ) -{ - IPolShift = shift; -} - - -//! Returns the animated tag list based on a detail level. 0 is the lowest, 255 the highest detail. -SMD3QuaterionTagList *CAnimatedMeshMD3::getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) -{ - if ( 0 == Mesh ) - return 0; - - getMesh ( frame, detailLevel, startFrameLoop, endFrameLoop ); - return &TagListIPol; -} - -//! Returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. -IMesh* CAnimatedMeshMD3::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) -{ - if ( 0 == Mesh ) - return 0; - - u32 i; - - //! check if we have the mesh in our private cache - SCacheInfo candidate ( frame, startFrameLoop, endFrameLoop ); - if ( candidate == Current ) - return &MeshIPol; - - startFrameLoop = core::s32_max ( 0, startFrameLoop >> IPolShift ); - endFrameLoop = core::if_c_a_else_b ( endFrameLoop < 0, Mesh->MD3Header.numFrames - 1, endFrameLoop >> IPolShift ); - - const u32 mask = 1 << IPolShift; - - s32 frameA; - s32 frameB; - f32 iPol; - - if ( LoopMode ) - { - // correct frame to "pixel center" - frame -= mask >> 1; - - // interpolation - iPol = f32(frame & ( mask - 1 )) * core::reciprocal ( f32(mask) ); - - // wrap anim - frame >>= IPolShift; - frameA = core::if_c_a_else_b ( frame < startFrameLoop, endFrameLoop, frame ); - frameB = core::if_c_a_else_b ( frameA + 1 > endFrameLoop, startFrameLoop, frameA + 1 ); - } - else - { - // correct frame to "pixel center" - frame -= mask >> 1; - - iPol = f32(frame & ( mask - 1 )) * core::reciprocal ( f32(mask) ); - - // clamp anim - frame >>= IPolShift; - frameA = core::s32_clamp ( frame, startFrameLoop, endFrameLoop ); - frameB = core::s32_min ( frameA + 1, endFrameLoop ); - - } - - // build curren vertex - for ( i = 0; i!= Mesh->Buffer.size (); ++i ) - { - buildVertexArray ( frameA, frameB, iPol, - Mesh->Buffer[i], - (SMeshBuffer*) MeshIPol.getMeshBuffer ( i ) - ); - } - MeshIPol.recalculateBoundingBox (); - - // build current tags - buildTagArray ( frameA, frameB, iPol ); - - Current = candidate; - return &MeshIPol; -} - -//! create a Irrlicht MeshBuffer for a MD3 MeshBuffer -IMeshBuffer * CAnimatedMeshMD3::createMeshBuffer ( const SMD3MeshBuffer * source ) -{ - SMeshBuffer * dest = new SMeshBuffer (); - dest->Vertices.set_used ( source->MeshHeader.numVertices ); - dest->Indices.set_used ( source->Indices.size () ); - - u32 i; - - // fill in static face info - for ( i = 0; i < source->Indices.size (); i += 3 ) - { - dest->Indices[i + 0 ] = (u16) source->Indices[i + 0]; - dest->Indices[i + 1 ] = (u16) source->Indices[i + 1]; - dest->Indices[i + 2 ] = (u16) source->Indices[i + 2]; - } - - // fill in static vertex info - for ( i = 0; i!= (u32)source->MeshHeader.numVertices; ++i ) - { - video::S3DVertex &v = dest->Vertices [ i ]; - v.Color = 0xFFFFFFFF; - v.TCoords.X = source->Tex[i].u; - v.TCoords.Y = source->Tex[i].v; - } - return dest; -} - -//! build final mesh's vertices from frames frameA and frameB with linear interpolation. -void CAnimatedMeshMD3::buildVertexArray ( u32 frameA, u32 frameB, f32 interpolate, - const SMD3MeshBuffer * source, - SMeshBuffer * dest - ) -{ - u32 i; - u32 frameOffsetA = frameA * source->MeshHeader.numVertices; - u32 frameOffsetB = frameB * source->MeshHeader.numVertices; - - f32 scale = ( 1.f/ 64.f ); - - core::vector3df nA; - core::vector3df nB; - - for ( i = 0; i!= (u32)source->MeshHeader.numVertices; ++i ) - { - video::S3DVertex &v = dest->Vertices [ i ]; - - const SMD3Vertex &vA = source->Vertices [ frameOffsetA + i ]; - const SMD3Vertex &vB = source->Vertices [ frameOffsetB + i ]; - - // position - v.Pos.X = scale * ( vA.position[0] + interpolate * ( vB.position[0] - vA.position[0] ) ); - v.Pos.Y = scale * ( vA.position[2] + interpolate * ( vB.position[2] - vA.position[2] ) ); - v.Pos.Z = scale * ( vA.position[1] + interpolate * ( vB.position[1] - vA.position[1] ) ); - - // normal - getNormal ( nA, vA.normal[0], vA.normal[1] ); - getNormal ( nB, vB.normal[0], vB.normal[1] ); - - v.Normal.X = nA.X + interpolate * ( nB.X - nA.X ); - v.Normal.Y = nA.Z + interpolate * ( nB.Z - nA.Z ); - v.Normal.Z = nA.Y + interpolate * ( nB.Y - nA.Y ); - - } - - dest->recalculateBoundingBox (); -} - - -//! build final mesh's tag from frames frameA and frameB with linear interpolation. -void CAnimatedMeshMD3::buildTagArray ( u32 frameA, u32 frameB, f32 interpolate ) -{ - u32 i; - u32 frameOffsetA = frameA * Mesh->MD3Header.numTags; - u32 frameOffsetB = frameB * Mesh->MD3Header.numTags; - - for ( i = 0; i!= (u32)Mesh->MD3Header.numTags; ++i ) - { - SMD3QuaterionTag &d = TagListIPol [ i ]; - - const SMD3QuaterionTag &qA = Mesh->TagList.Container[ frameOffsetA + i]; - const SMD3QuaterionTag &qB = Mesh->TagList.Container[ frameOffsetB + i]; - - // rotation - d.rotation.slerp( qA.rotation, qB.rotation, interpolate ); - - // position - d.position.X = qA.position.X + interpolate * ( qB.position.X - qA.position.X ); - d.position.Y = qA.position.Y + interpolate * ( qB.position.Y - qA.position.Y ); - d.position.Z = qA.position.Z + interpolate * ( qB.position.Z - qA.position.Z ); - - } -} - - -/*! - loads a model -*/ -bool CAnimatedMeshMD3::loadModelFile( u32 modelIndex, io::IReadFile* file) -{ - if (!file) - return false; - - u32 i,g; - - file->seek(0); - - //! Check MD3Header - { - file->read( &Mesh->MD3Header, sizeof(SMD3Header) ); - - if ( strncmp("IDP3", Mesh->MD3Header.headerID, 4) ) - { - os::Printer::log("MD3 Loader: invalid header"); - return false; - } - } - - //! store model name - Mesh->Name = file->getFileName(); - - //! Bone Frames Data ( ignore ) - //! Tag Data - const u32 totalTags = Mesh->MD3Header.numTags * Mesh->MD3Header.numFrames; - - SMD3Tag import; - SMD3QuaterionTag exp; - - file->seek( Mesh->MD3Header.tagStart ); - for (i = 0; i != totalTags; ++i ) - { - file->read(&import, sizeof(import) ); - - //! tag name - exp.Name = import.Name; - - //! position - exp.position.X = import.position[0]; - exp.position.Y = import.position[2]; - exp.position.Z = import.position[1]; - - //! construct quaternion from a RH 3x3 Matrix - exp.rotation.set (import.rotationMatrix[7], - 0.f, - -import.rotationMatrix[6], - 1 + import.rotationMatrix[8]); - exp.rotation.normalize (); - Mesh->TagList.Container.push_back ( exp ); - } - - //! Meshes - u32 offset = Mesh->MD3Header.tagEnd; - - SMD3Skin skin; - - for (i = 0; i != (u32)Mesh->MD3Header.numMeshes; ++i ) - { - //! construct a new mesh buffer - SMD3MeshBuffer * buf = new SMD3MeshBuffer (); - - // !read mesh header info - SMD3MeshHeader &meshHeader = buf->MeshHeader; - - //! read mesh info - file->seek( offset ); - file->read( &meshHeader, sizeof(SMD3MeshHeader) ); - - //! prepare memory - buf->Vertices.set_used ( meshHeader.numVertices * Mesh->MD3Header.numFrames ); - buf->Indices.set_used ( meshHeader.numTriangles * 3 ); - buf->Tex.set_used ( meshHeader.numVertices ); - - - //! read skins (shaders) - file->seek( offset + buf->MeshHeader.offset_shaders ); - for ( g = 0; g != (u32)buf->MeshHeader.numShader; ++g ) - { - file->read( &skin, sizeof(skin) ); - buf->Shader.push_back ( skin.name ); - } - - //! read texture coordinates - file->seek( offset + buf->MeshHeader.offset_st); - file->read( buf->Tex.pointer(), buf->MeshHeader.numVertices * sizeof(SMD3TexCoord) ); - - //! read vertices - file->seek(offset + meshHeader.vertexStart); - file->read( buf->Vertices.pointer(), Mesh->MD3Header.numFrames * meshHeader.numVertices * sizeof(SMD3Vertex) ); - - //! read indices - file->seek( offset + meshHeader.offset_triangles ); - file->read( buf->Indices.pointer(), meshHeader.numTriangles * sizeof(SMD3Face) ); - - //! store meshBuffer - Mesh->Buffer.push_back ( buf ); - - offset += meshHeader.offset_end; - } - - // Init Mesh Interpolation - for ( i = 0; i != Mesh->Buffer.size (); ++i ) - { - IMeshBuffer * buffer = createMeshBuffer ( Mesh->Buffer[i] ); - MeshIPol.addMeshBuffer ( buffer ); - buffer->drop (); - } - - // Init Tag Interpolation - for (i = 0; i != (u32)Mesh->MD3Header.numTags; ++i ) - { - TagListIPol.Container.push_back ( Mesh->TagList.Container[i] ); - } - - - return true; -} - - -SMD3Mesh * CAnimatedMeshMD3::getOriginalMesh () -{ - return Mesh; -} - - - -//! Returns an axis aligned bounding box -const core::aabbox3d& CAnimatedMeshMD3::getBoundingBox() const -{ - return MeshIPol.BoundingBox; -} - -//! Returns the type of the animated mesh. -E_ANIMATED_MESH_TYPE CAnimatedMeshMD3::getMeshType() const -{ - return EAMT_MD3; -} - - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Fabio Concas / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CAnimatedMeshMD3.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + + +#ifdef _MSC_VER +# pragma pack( push, packing ) +# pragma pack( 1 ) +# define PACK_STRUCT +#elif defined( __GNUC__ ) +# define PACK_STRUCT __attribute__((packed)) +#else +# error compiler not supported +#endif + + +struct SMD3Bone +{ + f32 Mins[3]; // bounding box per frame + f32 Maxs[3]; + f32 Position[3]; // position of bounding box + f32 scale; + c8 creator[16]; +}; + + +struct SMD3Tag +{ + c8 Name[64]; //name of 'tag' as it's usually called in the md3 files try to see it as a sub-mesh/seperate mesh-part. + f32 position[3]; //relative position of tag + f32 rotationMatrix[9]; //3x3 rotation direction of tag +}; + +struct SMD3Skin +{ + c8 name[68]; // name of skin +}; + + + +// Default alignment +#ifdef _MSC_VER +# pragma pack( pop, packing ) +#endif + +#undef PACK_STRUCT + + +//! Constructor +CAnimatedMeshMD3::CAnimatedMeshMD3 () +: Mesh ( 0 ) +{ +#ifdef _DEBUG + setDebugName("CAnimatedMeshMD3"); +#endif + + Mesh = new SMD3Mesh (); + memset ( &Mesh->MD3Header, 0, sizeof ( Mesh->MD3Header ) ); + + setInterpolationShift ( 0, 0 ); +} + + + +//! Destructor +CAnimatedMeshMD3::~CAnimatedMeshMD3() +{ + if ( Mesh ) + Mesh->drop (); + +} + + + +//! Returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. +s32 CAnimatedMeshMD3::getFrameCount() +{ + return Mesh->MD3Header.numFrames << IPolShift; +} + +//! Rendering Hint +void CAnimatedMeshMD3::setInterpolationShift ( u32 shift, u32 loopMode ) +{ + IPolShift = shift; +} + + +//! Returns the animated tag list based on a detail level. 0 is the lowest, 255 the highest detail. +SMD3QuaterionTagList *CAnimatedMeshMD3::getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) +{ + if ( 0 == Mesh ) + return 0; + + getMesh ( frame, detailLevel, startFrameLoop, endFrameLoop ); + return &TagListIPol; +} + +//! Returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. +IMesh* CAnimatedMeshMD3::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) +{ + if ( 0 == Mesh ) + return 0; + + u32 i; + + //! check if we have the mesh in our private cache + SCacheInfo candidate ( frame, startFrameLoop, endFrameLoop ); + if ( candidate == Current ) + return &MeshIPol; + + startFrameLoop = core::s32_max ( 0, startFrameLoop >> IPolShift ); + endFrameLoop = core::if_c_a_else_b ( endFrameLoop < 0, Mesh->MD3Header.numFrames - 1, endFrameLoop >> IPolShift ); + + const u32 mask = 1 << IPolShift; + + s32 frameA; + s32 frameB; + f32 iPol; + + if ( LoopMode ) + { + // correct frame to "pixel center" + frame -= mask >> 1; + + // interpolation + iPol = f32(frame & ( mask - 1 )) * core::reciprocal ( f32(mask) ); + + // wrap anim + frame >>= IPolShift; + frameA = core::if_c_a_else_b ( frame < startFrameLoop, endFrameLoop, frame ); + frameB = core::if_c_a_else_b ( frameA + 1 > endFrameLoop, startFrameLoop, frameA + 1 ); + } + else + { + // correct frame to "pixel center" + frame -= mask >> 1; + + iPol = f32(frame & ( mask - 1 )) * core::reciprocal ( f32(mask) ); + + // clamp anim + frame >>= IPolShift; + frameA = core::s32_clamp ( frame, startFrameLoop, endFrameLoop ); + frameB = core::s32_min ( frameA + 1, endFrameLoop ); + + } + + // build curren vertex + for ( i = 0; i!= Mesh->Buffer.size (); ++i ) + { + buildVertexArray ( frameA, frameB, iPol, + Mesh->Buffer[i], + (SMeshBuffer*) MeshIPol.getMeshBuffer ( i ) + ); + } + MeshIPol.recalculateBoundingBox (); + + // build current tags + buildTagArray ( frameA, frameB, iPol ); + + Current = candidate; + return &MeshIPol; +} + +//! create a Irrlicht MeshBuffer for a MD3 MeshBuffer +IMeshBuffer * CAnimatedMeshMD3::createMeshBuffer ( const SMD3MeshBuffer * source ) +{ + SMeshBuffer * dest = new SMeshBuffer (); + dest->Vertices.set_used ( source->MeshHeader.numVertices ); + dest->Indices.set_used ( source->Indices.size () ); + + u32 i; + + // fill in static face info + for ( i = 0; i < source->Indices.size (); i += 3 ) + { + dest->Indices[i + 0 ] = (u16) source->Indices[i + 0]; + dest->Indices[i + 1 ] = (u16) source->Indices[i + 1]; + dest->Indices[i + 2 ] = (u16) source->Indices[i + 2]; + } + + // fill in static vertex info + for ( i = 0; i!= (u32)source->MeshHeader.numVertices; ++i ) + { + video::S3DVertex &v = dest->Vertices [ i ]; + v.Color = 0xFFFFFFFF; + v.TCoords.X = source->Tex[i].u; + v.TCoords.Y = source->Tex[i].v; + } + return dest; +} + +//! build final mesh's vertices from frames frameA and frameB with linear interpolation. +void CAnimatedMeshMD3::buildVertexArray ( u32 frameA, u32 frameB, f32 interpolate, + const SMD3MeshBuffer * source, + SMeshBuffer * dest + ) +{ + u32 i; + u32 frameOffsetA = frameA * source->MeshHeader.numVertices; + u32 frameOffsetB = frameB * source->MeshHeader.numVertices; + + f32 scale = ( 1.f/ 64.f ); + + core::vector3df nA; + core::vector3df nB; + + for ( i = 0; i!= (u32)source->MeshHeader.numVertices; ++i ) + { + video::S3DVertex &v = dest->Vertices [ i ]; + + const SMD3Vertex &vA = source->Vertices [ frameOffsetA + i ]; + const SMD3Vertex &vB = source->Vertices [ frameOffsetB + i ]; + + // position + v.Pos.X = scale * ( vA.position[0] + interpolate * ( vB.position[0] - vA.position[0] ) ); + v.Pos.Y = scale * ( vA.position[2] + interpolate * ( vB.position[2] - vA.position[2] ) ); + v.Pos.Z = scale * ( vA.position[1] + interpolate * ( vB.position[1] - vA.position[1] ) ); + + // normal + getNormal ( nA, vA.normal[0], vA.normal[1] ); + getNormal ( nB, vB.normal[0], vB.normal[1] ); + + v.Normal.X = nA.X + interpolate * ( nB.X - nA.X ); + v.Normal.Y = nA.Z + interpolate * ( nB.Z - nA.Z ); + v.Normal.Z = nA.Y + interpolate * ( nB.Y - nA.Y ); + + } + + dest->recalculateBoundingBox (); +} + + +//! build final mesh's tag from frames frameA and frameB with linear interpolation. +void CAnimatedMeshMD3::buildTagArray ( u32 frameA, u32 frameB, f32 interpolate ) +{ + u32 i; + u32 frameOffsetA = frameA * Mesh->MD3Header.numTags; + u32 frameOffsetB = frameB * Mesh->MD3Header.numTags; + + for ( i = 0; i!= (u32)Mesh->MD3Header.numTags; ++i ) + { + SMD3QuaterionTag &d = TagListIPol [ i ]; + + const SMD3QuaterionTag &qA = Mesh->TagList.Container[ frameOffsetA + i]; + const SMD3QuaterionTag &qB = Mesh->TagList.Container[ frameOffsetB + i]; + + // rotation + d.rotation.slerp( qA.rotation, qB.rotation, interpolate ); + + // position + d.position.X = qA.position.X + interpolate * ( qB.position.X - qA.position.X ); + d.position.Y = qA.position.Y + interpolate * ( qB.position.Y - qA.position.Y ); + d.position.Z = qA.position.Z + interpolate * ( qB.position.Z - qA.position.Z ); + + } +} + + +/*! + loads a model +*/ +bool CAnimatedMeshMD3::loadModelFile( u32 modelIndex, io::IReadFile* file) +{ + if (!file) + return false; + + u32 i,g; + + file->seek(0); + + //! Check MD3Header + { + file->read( &Mesh->MD3Header, sizeof(SMD3Header) ); + + if ( strncmp("IDP3", Mesh->MD3Header.headerID, 4) ) + { + os::Printer::log("MD3 Loader: invalid header"); + return false; + } + } + + //! store model name + Mesh->Name = file->getFileName(); + + //! Bone Frames Data ( ignore ) + //! Tag Data + const u32 totalTags = Mesh->MD3Header.numTags * Mesh->MD3Header.numFrames; + + SMD3Tag import; + SMD3QuaterionTag exp; + + file->seek( Mesh->MD3Header.tagStart ); + for (i = 0; i != totalTags; ++i ) + { + file->read(&import, sizeof(import) ); + + //! tag name + exp.Name = import.Name; + + //! position + exp.position.X = import.position[0]; + exp.position.Y = import.position[2]; + exp.position.Z = import.position[1]; + + //! construct quaternion from a RH 3x3 Matrix + exp.rotation.set (import.rotationMatrix[7], + 0.f, + -import.rotationMatrix[6], + 1 + import.rotationMatrix[8]); + exp.rotation.normalize (); + Mesh->TagList.Container.push_back ( exp ); + } + + //! Meshes + u32 offset = Mesh->MD3Header.tagEnd; + + SMD3Skin skin; + + for (i = 0; i != (u32)Mesh->MD3Header.numMeshes; ++i ) + { + //! construct a new mesh buffer + SMD3MeshBuffer * buf = new SMD3MeshBuffer (); + + // !read mesh header info + SMD3MeshHeader &meshHeader = buf->MeshHeader; + + //! read mesh info + file->seek( offset ); + file->read( &meshHeader, sizeof(SMD3MeshHeader) ); + + //! prepare memory + buf->Vertices.set_used ( meshHeader.numVertices * Mesh->MD3Header.numFrames ); + buf->Indices.set_used ( meshHeader.numTriangles * 3 ); + buf->Tex.set_used ( meshHeader.numVertices ); + + + //! read skins (shaders) + file->seek( offset + buf->MeshHeader.offset_shaders ); + for ( g = 0; g != (u32)buf->MeshHeader.numShader; ++g ) + { + file->read( &skin, sizeof(skin) ); + buf->Shader.push_back ( skin.name ); + } + + //! read texture coordinates + file->seek( offset + buf->MeshHeader.offset_st); + file->read( buf->Tex.pointer(), buf->MeshHeader.numVertices * sizeof(SMD3TexCoord) ); + + //! read vertices + file->seek(offset + meshHeader.vertexStart); + file->read( buf->Vertices.pointer(), Mesh->MD3Header.numFrames * meshHeader.numVertices * sizeof(SMD3Vertex) ); + + //! read indices + file->seek( offset + meshHeader.offset_triangles ); + file->read( buf->Indices.pointer(), meshHeader.numTriangles * sizeof(SMD3Face) ); + + //! store meshBuffer + Mesh->Buffer.push_back ( buf ); + + offset += meshHeader.offset_end; + } + + // Init Mesh Interpolation + for ( i = 0; i != Mesh->Buffer.size (); ++i ) + { + IMeshBuffer * buffer = createMeshBuffer ( Mesh->Buffer[i] ); + MeshIPol.addMeshBuffer ( buffer ); + buffer->drop (); + } + + // Init Tag Interpolation + for (i = 0; i != (u32)Mesh->MD3Header.numTags; ++i ) + { + TagListIPol.Container.push_back ( Mesh->TagList.Container[i] ); + } + + + return true; +} + + +SMD3Mesh * CAnimatedMeshMD3::getOriginalMesh () +{ + return Mesh; +} + + + +//! Returns an axis aligned bounding box +const core::aabbox3d& CAnimatedMeshMD3::getBoundingBox() const +{ + return MeshIPol.BoundingBox; +} + +//! Returns the type of the animated mesh. +E_ANIMATED_MESH_TYPE CAnimatedMeshMD3::getMeshType() const +{ + return EAMT_MD3; +} + + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CAnimatedMeshMD3.h b/src/dep/src/irrlicht/CAnimatedMeshMD3.h index 1a83425..8f6126c 100644 --- a/src/dep/src/irrlicht/CAnimatedMeshMD3.h +++ b/src/dep/src/irrlicht/CAnimatedMeshMD3.h @@ -1,104 +1,104 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_ANIMATED_MESH_MD3_H_INCLUDED__ -#define __C_ANIMATED_MESH_MD3_H_INCLUDED__ - -#include "IAnimatedMeshMD3.h" -#include "IReadFile.h" -#include "IFileSystem.h" -#include "irrArray.h" -#include "irrString.h" -#include "SMesh.h" -#include "SMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - - - class CAnimatedMeshMD3 : public IAnimatedMeshMD3 - { - public: - - //! constructor - CAnimatedMeshMD3(); - - //! destructor - virtual ~CAnimatedMeshMD3(); - - //! loads a quake3 md3 file - virtual bool loadModelFile( u32 modelIndex, io::IReadFile* file); - - // IAnimatedMeshMD3 - virtual void setInterpolationShift ( u32 shift, u32 loopMode ); - virtual SMD3Mesh * getOriginalMesh (); - virtual SMD3QuaterionTagList *getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop); - - //IAnimatedMesh - virtual s32 getFrameCount(); - virtual IMesh* getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop); - virtual const core::aabbox3d& getBoundingBox() const; - virtual E_ANIMATED_MESH_TYPE getMeshType() const; - - private: - //! animates one frame - inline void Animate (u32 frame); - - video::SMaterial Material; - - //! hold original compressed MD3 Info - SMD3Mesh *Mesh; - - u32 IPolShift; - u32 LoopMode; - f32 Scaling; - - //! Cache Info - struct SCacheInfo - { - SCacheInfo ( s32 frame = -1, s32 start = -1, s32 end = -1 ) - : Frame ( frame ), startFrameLoop ( start ), - endFrameLoop ( end ) {} - - bool operator == ( const SCacheInfo &other ) const - { - return 0 == memcmp ( this, &other, sizeof ( SCacheInfo ) ); - } - s32 Frame; - s32 startFrameLoop; - s32 endFrameLoop; - }; - SCacheInfo Current; - - //! return a Mesh per frame - SMesh MeshIPol; - SMD3QuaterionTagList TagListIPol; - - IMeshBuffer * createMeshBuffer ( const SMD3MeshBuffer *source ); - - void buildVertexArray ( u32 frameA, u32 frameB, f32 interpolate, - const SMD3MeshBuffer * source, - SMeshBuffer * dest - ); - - void buildTagArray ( u32 frameA, u32 frameB, f32 interpolate ); - - void getNormal ( core::vector3df & out, u32 i, u32 j ) - { - f32 lng = i * 2.0f * core::PI / 255.0f; - f32 lat = j * 2.0f * core::PI / 255.0f; - out.X = cosf ( lat ) * sinf ( lng ); - out.Y = sinf ( lat ) * sinf ( lng ); - out.Z = cos ( lng ); - } - - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_ANIMATED_MESH_MD3_H_INCLUDED__ +#define __C_ANIMATED_MESH_MD3_H_INCLUDED__ + +#include "IAnimatedMeshMD3.h" +#include "IReadFile.h" +#include "IFileSystem.h" +#include "irrArray.h" +#include "irrString.h" +#include "SMesh.h" +#include "SMeshBuffer.h" + +namespace irr +{ +namespace scene +{ + + + class CAnimatedMeshMD3 : public IAnimatedMeshMD3 + { + public: + + //! constructor + CAnimatedMeshMD3(); + + //! destructor + virtual ~CAnimatedMeshMD3(); + + //! loads a quake3 md3 file + virtual bool loadModelFile( u32 modelIndex, io::IReadFile* file); + + // IAnimatedMeshMD3 + virtual void setInterpolationShift ( u32 shift, u32 loopMode ); + virtual SMD3Mesh * getOriginalMesh (); + virtual SMD3QuaterionTagList *getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop); + + //IAnimatedMesh + virtual s32 getFrameCount(); + virtual IMesh* getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop); + virtual const core::aabbox3d& getBoundingBox() const; + virtual E_ANIMATED_MESH_TYPE getMeshType() const; + + private: + //! animates one frame + inline void Animate (u32 frame); + + video::SMaterial Material; + + //! hold original compressed MD3 Info + SMD3Mesh *Mesh; + + u32 IPolShift; + u32 LoopMode; + f32 Scaling; + + //! Cache Info + struct SCacheInfo + { + SCacheInfo ( s32 frame = -1, s32 start = -1, s32 end = -1 ) + : Frame ( frame ), startFrameLoop ( start ), + endFrameLoop ( end ) {} + + bool operator == ( const SCacheInfo &other ) const + { + return 0 == memcmp ( this, &other, sizeof ( SCacheInfo ) ); + } + s32 Frame; + s32 startFrameLoop; + s32 endFrameLoop; + }; + SCacheInfo Current; + + //! return a Mesh per frame + SMesh MeshIPol; + SMD3QuaterionTagList TagListIPol; + + IMeshBuffer * createMeshBuffer ( const SMD3MeshBuffer *source ); + + void buildVertexArray ( u32 frameA, u32 frameB, f32 interpolate, + const SMD3MeshBuffer * source, + SMeshBuffer * dest + ); + + void buildTagArray ( u32 frameA, u32 frameB, f32 interpolate ); + + void getNormal ( core::vector3df & out, u32 i, u32 j ) + { + f32 lng = i * 2.0f * core::PI / 255.0f; + f32 lat = j * 2.0f * core::PI / 255.0f; + out.X = cosf ( lat ) * sinf ( lng ); + out.Y = sinf ( lat ) * sinf ( lng ); + out.Z = cos ( lng ); + } + + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CAnimatedMeshMS3D.cpp b/src/dep/src/irrlicht/CAnimatedMeshMS3D.cpp index c3b9174..3c10f6d 100644 --- a/src/dep/src/irrlicht/CAnimatedMeshMS3D.cpp +++ b/src/dep/src/irrlicht/CAnimatedMeshMS3D.cpp @@ -1,801 +1,801 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CAnimatedMeshMS3D.h" -#include "os.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace scene -{ - - -// byte-align structures -#ifdef _MSC_VER -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - -// File header -struct MS3DHeader -{ - c8 ID[10]; - s32 Version; -} PACK_STRUCT; - -// Vertex information -struct MS3DVertex -{ - u8 Flags; - f32 Vertex[3]; - s8 BoneID; - u8 RefCount; -} PACK_STRUCT; - -// Triangle information -struct MS3DTriangle -{ - u16 Flags; - u16 VertexIndices[3]; - f32 VertexNormals[3][3]; - f32 S[3], T[3]; - u8 SmoothingGroup; - u8 GroupIndex; -} PACK_STRUCT; - -// Material information -struct MS3DMaterial -{ - s8 Name[32]; - f32 Ambient[4]; - f32 Diffuse[4]; - f32 Specular[4]; - f32 Emissive[4]; - f32 Shininess; // 0.0f - 128.0f - f32 Transparency; // 0.0f - 1.0f - u8 Mode; // 0, 1, 2 is unused now - s8 Texture[128]; - s8 Alphamap[128]; -} PACK_STRUCT; - -// Joint information -struct MS3DJoint -{ - u8 Flags; - s8 Name[32]; - s8 ParentName[32]; - f32 Rotation[3]; - f32 Translation[3]; - u16 NumRotationKeyframes; - u16 NumTranslationKeyframes; -} PACK_STRUCT; - -// Keyframe data -struct MS3DKeyframe -{ - f32 Time; - f32 Parameter[3]; -} PACK_STRUCT; - -// Default alignment -#ifdef _MSC_VER -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - - -//! constructor -CAnimatedMeshMS3D::CAnimatedMeshMS3D(video::IVideoDriver* driver) -: Driver(driver) -{ - if (Driver) - Driver->grab(); - - lastCalculatedFrame = -1; -} - - - -//! destructor -CAnimatedMeshMS3D::~CAnimatedMeshMS3D() -{ - if (Driver) - Driver->drop(); -} - - - -//! loads an md2 file -bool CAnimatedMeshMS3D::loadFile(io::IReadFile* file) -{ - s32 i=0,j; - - if (!file) - return false; - - HasAnimation = false; - - // find file size - - size_t fileSize = file->getSize(); - - // read whole file - - u8* buffer = new u8[fileSize]; - size_t read = (s32)file->read(buffer, fileSize); - if (read != fileSize) - { - delete [] buffer; - os::Printer::log("Could not read full file. Loading failed", file->getFileName(), ELL_ERROR); - return false; - } - - // read header - - const u8 *pPtr = (u8*)((void*)buffer); - MS3DHeader *pHeader = (MS3DHeader*)pPtr; - pPtr += sizeof(MS3DHeader); - - if ( strncmp( pHeader->ID, "MS3D000000", 10 ) != 0 ) - { - delete [] buffer; - os::Printer::log("Not a valid Milkshape3D Model File. Loading failed", file->getFileName(), ELL_ERROR); - return false; - } - -#ifdef __BIG_ENDIAN__ - pHeader->Version = os::Byteswap::byteswap(pHeader->Version); -#endif - if ( pHeader->Version < 3 || pHeader->Version > 4 ) - { - delete [] buffer; - os::Printer::log("Only Milkshape3D version 1.3 and 1.4 is supported. Loading failed", file->getFileName(), ELL_ERROR); - return false; - } - - // get pointers to data - - // vertices - u16 numVertices = *(u16*)pPtr; -#ifdef __BIG_ENDIAN__ - numVertices = os::Byteswap::byteswap(numVertices); -#endif - pPtr += sizeof(u16); - MS3DVertex *vertices = (MS3DVertex*)pPtr; - pPtr += sizeof(MS3DVertex) * numVertices; -#ifdef __BIG_ENDIAN__ - for (i=0; iAmbient[j] = os::Byteswap::byteswap(material->Ambient[j]); - for (j=0; j<4; ++j) - material->Diffuse[j] = os::Byteswap::byteswap(material->Diffuse[j]); - for (j=0; j<4; ++j) - material->Specular[j] = os::Byteswap::byteswap(material->Specular[j]); - for (j=0; j<4; ++j) - material->Emissive[j] = os::Byteswap::byteswap(material->Emissive[j]); - material->Shininess = os::Byteswap::byteswap(material->Shininess); - material->Transparency = os::Byteswap::byteswap(material->Transparency); -#endif - pPtr += sizeof(MS3DMaterial); - - Buffers.push_back (SMS3DMeshBuffer ()); - SMS3DMeshBuffer& tmpBuffer = Buffers.getLast(); - - tmpBuffer.Material.MaterialType = video::EMT_SOLID; - - tmpBuffer.Material.AmbientColor = video::SColorf(material->Ambient[0], material->Ambient[1], material->Ambient[2], material->Ambient[3]).toSColor (); - tmpBuffer.Material.DiffuseColor = video::SColorf(material->Diffuse[0], material->Diffuse[1], material->Diffuse[2], material->Diffuse[3]).toSColor (); - tmpBuffer.Material.EmissiveColor = video::SColorf(material->Emissive[0], material->Emissive[1], material->Emissive[2], material->Emissive[3]).toSColor (); - tmpBuffer.Material.SpecularColor = video::SColorf(material->Specular[0], material->Specular[1], material->Specular[2], material->Specular[3]).toSColor (); - tmpBuffer.Material.Shininess = material->Shininess; - tmpBuffer.Material.Textures[0] = Driver->getTexture((const c8*)material->Texture); - tmpBuffer.BoundingBox = &BoundingBox; - tmpBuffer.Vertices = &AnimatedVertices; - } - - // animation time - f32 framesPerSecond = *(f32*)pPtr; -#ifdef __BIG_ENDIAN__ - framesPerSecond = os::Byteswap::byteswap(framesPerSecond); -#endif - pPtr += sizeof(f32) * 2; // fps and current time - - s32 frameCount = *(s32*)pPtr; -#ifdef __BIG_ENDIAN__ - frameCount = os::Byteswap::byteswap(frameCount); -#endif - pPtr += sizeof(s32); - - totalTime = (frameCount / framesPerSecond) * 1000.0f; - - u16 jointCount = *(u16*)pPtr; -#ifdef __BIG_ENDIAN__ - jointCount = os::Byteswap::byteswap(jointCount); -#endif - pPtr += sizeof(u16); - - // load joints - SJoint t; - - for (i=0; iRotation[j] = os::Byteswap::byteswap(pJoint->Rotation[j]); - for (j=0; j<3; ++j) - pJoint->Translation[j] = os::Byteswap::byteswap(pJoint->Translation[j]); - pJoint->NumRotationKeyframes= os::Byteswap::byteswap(pJoint->NumRotationKeyframes); - pJoint->NumTranslationKeyframes = os::Byteswap::byteswap(pJoint->NumTranslationKeyframes); -#endif - pPtr += sizeof(MS3DJoint); - Joints.push_back(t); - SJoint& jnt = Joints[Joints.size()-1]; - - jnt.Name = pJoint->Name; - jnt.Index = i; - jnt.Rotation.X = pJoint->Rotation[0]; - jnt.Rotation.Y = pJoint->Rotation[1]; - jnt.Rotation.Z = pJoint->Rotation[2]; - jnt.Translation.X = pJoint->Translation[0]; - jnt.Translation.Y = pJoint->Translation[1]; - jnt.Translation.Z = pJoint->Translation[2]; - jnt.ParentName = pJoint->ParentName; - jnt.Parent = -1; - - if (pJoint->NumRotationKeyframes || - pJoint->NumTranslationKeyframes) - HasAnimation = true; - - // get rotation keyframes - for (j=0; jNumRotationKeyframes; ++j) - { - MS3DKeyframe* kf = (MS3DKeyframe*)pPtr; -#ifdef __BIG_ENDIAN__ - kf->Time = os::Byteswap::byteswap(kf->Time); - for (u32 l=0; l<3; ++l) - kf->Parameter[l] = os::Byteswap::byteswap(kf->Parameter[l]); -#endif - pPtr += sizeof(MS3DKeyframe); - - SKeyframe k; - k.timeindex = kf->Time * 1000.0f; - k.data.X = kf->Parameter[0]; - k.data.Y = kf->Parameter[1]; - k.data.Z = kf->Parameter[2]; - jnt.RotationKeys.push_back(k); - } - - // get translation keyframes - for (j=0; jNumTranslationKeyframes; ++j) - { - MS3DKeyframe* kf = (MS3DKeyframe*)pPtr; -#ifdef __BIG_ENDIAN__ - kf->Time = os::Byteswap::byteswap(kf->Time); - for (u32 l=0; l<3; ++l) - kf->Parameter[l] = os::Byteswap::byteswap(kf->Parameter[l]); -#endif - pPtr += sizeof(MS3DKeyframe); - - SKeyframe k; - k.timeindex = kf->Time * 1000.0f; - k.data.X = kf->Parameter[0]; - k.data.Y = kf->Parameter[1]; - k.data.Z = kf->Parameter[2]; - jnt.TranslationKeys.push_back(k); - } - } - - //find parent of every joint - for (i=0; i<(s32)Joints.size(); ++i) - { - if (Joints[i].ParentName.size() != 0) - { - for (j=0; j<(s32)Joints.size(); ++j) - if (i != j && Joints[i].ParentName == Joints[j].Name) - { - Joints[i].Parent = j; - break; - } - - if (Joints[i].Parent == -1) - os::Printer::log("Found joint in model without parent.", ELL_WARNING); - } - } - - // sets up all joints with initial rotation and translation - for (i=0; i<(s32)Joints.size(); ++i) - { - SJoint& jnt = Joints[i]; - - jnt.RelativeTransformation.setRotationRadians(jnt.Rotation); - jnt.RelativeTransformation.setTranslation(jnt.Translation); - - if (jnt.Parent == -1) - jnt.AbsoluteTransformation = jnt.RelativeTransformation; - else - { - jnt.AbsoluteTransformation = Joints[jnt.Parent].AbsoluteTransformation; - jnt.AbsoluteTransformation *= jnt.RelativeTransformation; - } - - jnt.AbsoluteTransformationAnimated = jnt.AbsoluteTransformation; - } - - // create vertices and indices, attach them to the joints. - video::S3DVertex v; - - for (i=0; i=0 && boneid<(s32)Joints.size()) - Joints[boneid].VertexIds.push_back(Vertices.size()); - - Vertices.push_back(v); - index = Vertices.size() - 1; - } - Indices.push_back(index); - } - } - - //create groups - s32 iIndex = -1; - for (i=0; i<(int)Groups.size(); ++i) - { - SGroup& grp = Groups[i]; - - if (grp.MaterialIdx >= Buffers.size()) - grp.MaterialIdx = 0; - - core::array& indices = Buffers[grp.MaterialIdx].Indices; - - for (u32 k=0; k& keys, f32 time, core::vector3df& outdata) -{ - - if (keys.size()) - { - if (time < keys[0].timeindex) - { - outdata = keys[0].data; - return; - } - if (time > keys[keys.size()-1].timeindex) - { - outdata = keys[keys.size()-1].data; - return; - } - - for (s32 i=0; i<(s32)keys.size()-1; ++i) - { - if (keys[i].timeindex <= time && keys[i+1].timeindex >= time) - { - f32 interpolate = (time - keys[i].timeindex)/(keys[i+1].timeindex - keys[i].timeindex); - outdata = keys[i].data + ((keys[i+1].data - keys[i].data) * interpolate); - return; - } - } - } -} - - -//! Returns a pointer to a transformation matrix of a part of the -//! mesh based on a frame time. -core::matrix4* CAnimatedMeshMS3D::getMatrixOfJoint(s32 jointNumber, s32 frame) -{ - if (jointNumber < 0 || jointNumber >= (s32)Joints.size()) - return 0; - - animate(frame); - - return &Joints[jointNumber].AbsoluteTransformationAnimated; -} - - -//! Gets joint count. -s32 CAnimatedMeshMS3D::getJointCount() const -{ - return Joints.size(); -} - - -//! Gets the name of a joint. -const c8* CAnimatedMeshMS3D::getJointName(s32 number) const -{ - if (number < 0 || number >= (s32)Joints.size()) - return 0; - return Joints[number].Name.c_str(); -} - - -//! Gets a joint number from its name -s32 CAnimatedMeshMS3D::getJointNumber(const c8* name) const -{ - for (s32 i=0; i<(s32)Joints.size(); ++i) - if (Joints[i].Name == name) - return i; - - return -1; -} - - -void CAnimatedMeshMS3D::animate(s32 frame) -{ - if (!HasAnimation || lastCalculatedFrame == frame) - return; - - f32 time = (f32)frame; - core::matrix4 transform; - lastCalculatedFrame = frame; - - for (s32 i=0; i<(s32)Joints.size(); ++i) - { - core::vector3df translation = Joints[i].Translation; - core::vector3df rotation = Joints[i].Rotation; - - // find keyframe translation and roation - getKeyframeData(Joints[i].TranslationKeys, time, translation); - getKeyframeData(Joints[i].RotationKeys, time, rotation); - - transform.makeIdentity(); - transform.setRotationRadians(rotation); - transform.setTranslation(translation); - - Joints[i].AbsoluteTransformationAnimated = Joints[i].RelativeTransformation * transform; - - if (Joints[i].Parent != -1) - Joints[i].AbsoluteTransformationAnimated = Joints[Joints[i].Parent].AbsoluteTransformationAnimated * Joints[i].AbsoluteTransformationAnimated; - - if (i==0) - BoundingBox.reset(Joints[0].AbsoluteTransformationAnimated.getTranslation()); - else - BoundingBox.addInternalPoint(Joints[i].AbsoluteTransformationAnimated.getTranslation()); - - - // transform all vertices - for (s32 j=0; j<(s32)Joints[i].VertexIds.size(); ++j) - { - Joints[i].AbsoluteTransformationAnimated.transformVect( - AnimatedVertices[Joints[i].VertexIds[j]].Pos, - Vertices[Joints[i].VertexIds[j]].Pos - ); - - Joints[i].AbsoluteTransformationAnimated.transformVect( - AnimatedVertices[Joints[i].VertexIds[j]].Normal, - Vertices[Joints[i].VertexIds[j]].Normal - ); - - // TODO: this could be done much more faster by - // first getting 8 extreme points and putting them in. - BoundingBox.addInternalPoint(AnimatedVertices[Joints[i].VertexIds[j]].Pos); - } - } - -} - - - -//! returns amount of mesh buffers. -u32 CAnimatedMeshMS3D::getMeshBufferCount() const -{ - return Buffers.size(); -} - - - -//! returns pointer to a mesh buffer -IMeshBuffer* CAnimatedMeshMS3D::getMeshBuffer(u32 nr) const -{ - if (nr < Buffers.size()) - return (IMeshBuffer*) &Buffers[nr]; - else - return 0; -} - -//! Returns pointer to a mesh buffer which fits a material -IMeshBuffer* CAnimatedMeshMS3D::getMeshBuffer( const video::SMaterial &material) const -{ - for (u32 i=0; i& CAnimatedMeshMS3D::getBoundingBox() const -{ - return BoundingBox; -} - - -//! set user axis aligned bounding box -void CAnimatedMeshMS3D::setBoundingBox( const core::aabbox3df& box) -{ - BoundingBox = box; -} - -//! sets a flag of all contained materials to a new value -void CAnimatedMeshMS3D::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) -{ - for (s32 i=0; i<(int)Buffers.size(); ++i) - Buffers[i].Material.setFlag(flag, newvalue); -} - - -//! Returns the type of the animated mesh. -E_ANIMATED_MESH_TYPE CAnimatedMeshMS3D::getMeshType() const -{ - return EAMT_MS3D; -} - -//! constructor -CAnimatedMeshMS3D::SMS3DMeshBuffer::SMS3DMeshBuffer() -{ - #ifdef _DEBUG - setDebugName("SMS3DMeshBuffer"); - #endif -} - -//! destructor -CAnimatedMeshMS3D::SMS3DMeshBuffer::~SMS3DMeshBuffer() -{ -} - -//! returns the material of this meshbuffer -const video::SMaterial& CAnimatedMeshMS3D::SMS3DMeshBuffer::getMaterial() const -{ - return Material; -} - -//! returns the material of this meshbuffer -video::SMaterial& CAnimatedMeshMS3D::SMS3DMeshBuffer::getMaterial() -{ - return Material; -} - -//! returns pointer to vertices -const void* CAnimatedMeshMS3D::SMS3DMeshBuffer::getVertices() const -{ - return Vertices->const_pointer(); -} - -//! returns pointer to vertices -void* CAnimatedMeshMS3D::SMS3DMeshBuffer::getVertices() -{ - return Vertices->pointer(); -} - -//! returns amount of vertices -u32 CAnimatedMeshMS3D::SMS3DMeshBuffer::getVertexCount() const -{ - return Vertices->size(); -} - -//! returns pointer to Indices -const u16* CAnimatedMeshMS3D::SMS3DMeshBuffer::getIndices() const -{ - return Indices.const_pointer(); -} - -//! returns pointer to Indices -u16* CAnimatedMeshMS3D::SMS3DMeshBuffer::getIndices() -{ - return Indices.pointer(); -} - -//! returns amount of indices -u32 CAnimatedMeshMS3D::SMS3DMeshBuffer::getIndexCount() const -{ - return Indices.size(); -} - -//! returns an axis aligned bounding box -const core::aabbox3d& CAnimatedMeshMS3D::SMS3DMeshBuffer::getBoundingBox() const -{ - return *BoundingBox; -} - -//! returns an axis aligned bounding box -void CAnimatedMeshMS3D::SMS3DMeshBuffer::setBoundingBox( const core::aabbox3df& box) -{ - *BoundingBox = box; -} - -//! returns which type of vertex data is stored. -video::E_VERTEX_TYPE CAnimatedMeshMS3D::SMS3DMeshBuffer::getVertexType() const -{ - return video::EVT_STANDARD; -} - -//! returns the byte size (stride, pitch) of the vertex -u32 CAnimatedMeshMS3D::SMS3DMeshBuffer::getVertexPitch() const -{ - return sizeof ( video::S3DVertex ); -} - - -} // end namespace scene -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CAnimatedMeshMS3D.h" +#include "os.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace scene +{ + + +// byte-align structures +#ifdef _MSC_VER +# pragma pack( push, packing ) +# pragma pack( 1 ) +# define PACK_STRUCT +#elif defined( __GNUC__ ) +# define PACK_STRUCT __attribute__((packed)) +#else +# error compiler not supported +#endif + +// File header +struct MS3DHeader +{ + c8 ID[10]; + s32 Version; +} PACK_STRUCT; + +// Vertex information +struct MS3DVertex +{ + u8 Flags; + f32 Vertex[3]; + s8 BoneID; + u8 RefCount; +} PACK_STRUCT; + +// Triangle information +struct MS3DTriangle +{ + u16 Flags; + u16 VertexIndices[3]; + f32 VertexNormals[3][3]; + f32 S[3], T[3]; + u8 SmoothingGroup; + u8 GroupIndex; +} PACK_STRUCT; + +// Material information +struct MS3DMaterial +{ + s8 Name[32]; + f32 Ambient[4]; + f32 Diffuse[4]; + f32 Specular[4]; + f32 Emissive[4]; + f32 Shininess; // 0.0f - 128.0f + f32 Transparency; // 0.0f - 1.0f + u8 Mode; // 0, 1, 2 is unused now + s8 Texture[128]; + s8 Alphamap[128]; +} PACK_STRUCT; + +// Joint information +struct MS3DJoint +{ + u8 Flags; + s8 Name[32]; + s8 ParentName[32]; + f32 Rotation[3]; + f32 Translation[3]; + u16 NumRotationKeyframes; + u16 NumTranslationKeyframes; +} PACK_STRUCT; + +// Keyframe data +struct MS3DKeyframe +{ + f32 Time; + f32 Parameter[3]; +} PACK_STRUCT; + +// Default alignment +#ifdef _MSC_VER +# pragma pack( pop, packing ) +#endif + +#undef PACK_STRUCT + + +//! constructor +CAnimatedMeshMS3D::CAnimatedMeshMS3D(video::IVideoDriver* driver) +: Driver(driver) +{ + if (Driver) + Driver->grab(); + + lastCalculatedFrame = -1; +} + + + +//! destructor +CAnimatedMeshMS3D::~CAnimatedMeshMS3D() +{ + if (Driver) + Driver->drop(); +} + + + +//! loads an md2 file +bool CAnimatedMeshMS3D::loadFile(io::IReadFile* file) +{ + s32 i=0,j; + + if (!file) + return false; + + HasAnimation = false; + + // find file size + + size_t fileSize = file->getSize(); + + // read whole file + + u8* buffer = new u8[fileSize]; + size_t read = (s32)file->read(buffer, fileSize); + if (read != fileSize) + { + delete [] buffer; + os::Printer::log("Could not read full file. Loading failed", file->getFileName(), ELL_ERROR); + return false; + } + + // read header + + const u8 *pPtr = (u8*)((void*)buffer); + MS3DHeader *pHeader = (MS3DHeader*)pPtr; + pPtr += sizeof(MS3DHeader); + + if ( strncmp( pHeader->ID, "MS3D000000", 10 ) != 0 ) + { + delete [] buffer; + os::Printer::log("Not a valid Milkshape3D Model File. Loading failed", file->getFileName(), ELL_ERROR); + return false; + } + +#ifdef __BIG_ENDIAN__ + pHeader->Version = os::Byteswap::byteswap(pHeader->Version); +#endif + if ( pHeader->Version < 3 || pHeader->Version > 4 ) + { + delete [] buffer; + os::Printer::log("Only Milkshape3D version 1.3 and 1.4 is supported. Loading failed", file->getFileName(), ELL_ERROR); + return false; + } + + // get pointers to data + + // vertices + u16 numVertices = *(u16*)pPtr; +#ifdef __BIG_ENDIAN__ + numVertices = os::Byteswap::byteswap(numVertices); +#endif + pPtr += sizeof(u16); + MS3DVertex *vertices = (MS3DVertex*)pPtr; + pPtr += sizeof(MS3DVertex) * numVertices; +#ifdef __BIG_ENDIAN__ + for (i=0; iAmbient[j] = os::Byteswap::byteswap(material->Ambient[j]); + for (j=0; j<4; ++j) + material->Diffuse[j] = os::Byteswap::byteswap(material->Diffuse[j]); + for (j=0; j<4; ++j) + material->Specular[j] = os::Byteswap::byteswap(material->Specular[j]); + for (j=0; j<4; ++j) + material->Emissive[j] = os::Byteswap::byteswap(material->Emissive[j]); + material->Shininess = os::Byteswap::byteswap(material->Shininess); + material->Transparency = os::Byteswap::byteswap(material->Transparency); +#endif + pPtr += sizeof(MS3DMaterial); + + Buffers.push_back (SMS3DMeshBuffer ()); + SMS3DMeshBuffer& tmpBuffer = Buffers.getLast(); + + tmpBuffer.Material.MaterialType = video::EMT_SOLID; + + tmpBuffer.Material.AmbientColor = video::SColorf(material->Ambient[0], material->Ambient[1], material->Ambient[2], material->Ambient[3]).toSColor (); + tmpBuffer.Material.DiffuseColor = video::SColorf(material->Diffuse[0], material->Diffuse[1], material->Diffuse[2], material->Diffuse[3]).toSColor (); + tmpBuffer.Material.EmissiveColor = video::SColorf(material->Emissive[0], material->Emissive[1], material->Emissive[2], material->Emissive[3]).toSColor (); + tmpBuffer.Material.SpecularColor = video::SColorf(material->Specular[0], material->Specular[1], material->Specular[2], material->Specular[3]).toSColor (); + tmpBuffer.Material.Shininess = material->Shininess; + tmpBuffer.Material.Textures[0] = Driver->getTexture((const c8*)material->Texture); + tmpBuffer.BoundingBox = &BoundingBox; + tmpBuffer.Vertices = &AnimatedVertices; + } + + // animation time + f32 framesPerSecond = *(f32*)pPtr; +#ifdef __BIG_ENDIAN__ + framesPerSecond = os::Byteswap::byteswap(framesPerSecond); +#endif + pPtr += sizeof(f32) * 2; // fps and current time + + s32 frameCount = *(s32*)pPtr; +#ifdef __BIG_ENDIAN__ + frameCount = os::Byteswap::byteswap(frameCount); +#endif + pPtr += sizeof(s32); + + totalTime = (frameCount / framesPerSecond) * 1000.0f; + + u16 jointCount = *(u16*)pPtr; +#ifdef __BIG_ENDIAN__ + jointCount = os::Byteswap::byteswap(jointCount); +#endif + pPtr += sizeof(u16); + + // load joints + SJoint t; + + for (i=0; iRotation[j] = os::Byteswap::byteswap(pJoint->Rotation[j]); + for (j=0; j<3; ++j) + pJoint->Translation[j] = os::Byteswap::byteswap(pJoint->Translation[j]); + pJoint->NumRotationKeyframes= os::Byteswap::byteswap(pJoint->NumRotationKeyframes); + pJoint->NumTranslationKeyframes = os::Byteswap::byteswap(pJoint->NumTranslationKeyframes); +#endif + pPtr += sizeof(MS3DJoint); + Joints.push_back(t); + SJoint& jnt = Joints[Joints.size()-1]; + + jnt.Name = pJoint->Name; + jnt.Index = i; + jnt.Rotation.X = pJoint->Rotation[0]; + jnt.Rotation.Y = pJoint->Rotation[1]; + jnt.Rotation.Z = pJoint->Rotation[2]; + jnt.Translation.X = pJoint->Translation[0]; + jnt.Translation.Y = pJoint->Translation[1]; + jnt.Translation.Z = pJoint->Translation[2]; + jnt.ParentName = pJoint->ParentName; + jnt.Parent = -1; + + if (pJoint->NumRotationKeyframes || + pJoint->NumTranslationKeyframes) + HasAnimation = true; + + // get rotation keyframes + for (j=0; jNumRotationKeyframes; ++j) + { + MS3DKeyframe* kf = (MS3DKeyframe*)pPtr; +#ifdef __BIG_ENDIAN__ + kf->Time = os::Byteswap::byteswap(kf->Time); + for (u32 l=0; l<3; ++l) + kf->Parameter[l] = os::Byteswap::byteswap(kf->Parameter[l]); +#endif + pPtr += sizeof(MS3DKeyframe); + + SKeyframe k; + k.timeindex = kf->Time * 1000.0f; + k.data.X = kf->Parameter[0]; + k.data.Y = kf->Parameter[1]; + k.data.Z = kf->Parameter[2]; + jnt.RotationKeys.push_back(k); + } + + // get translation keyframes + for (j=0; jNumTranslationKeyframes; ++j) + { + MS3DKeyframe* kf = (MS3DKeyframe*)pPtr; +#ifdef __BIG_ENDIAN__ + kf->Time = os::Byteswap::byteswap(kf->Time); + for (u32 l=0; l<3; ++l) + kf->Parameter[l] = os::Byteswap::byteswap(kf->Parameter[l]); +#endif + pPtr += sizeof(MS3DKeyframe); + + SKeyframe k; + k.timeindex = kf->Time * 1000.0f; + k.data.X = kf->Parameter[0]; + k.data.Y = kf->Parameter[1]; + k.data.Z = kf->Parameter[2]; + jnt.TranslationKeys.push_back(k); + } + } + + //find parent of every joint + for (i=0; i<(s32)Joints.size(); ++i) + { + if (Joints[i].ParentName.size() != 0) + { + for (j=0; j<(s32)Joints.size(); ++j) + if (i != j && Joints[i].ParentName == Joints[j].Name) + { + Joints[i].Parent = j; + break; + } + + if (Joints[i].Parent == -1) + os::Printer::log("Found joint in model without parent.", ELL_WARNING); + } + } + + // sets up all joints with initial rotation and translation + for (i=0; i<(s32)Joints.size(); ++i) + { + SJoint& jnt = Joints[i]; + + jnt.RelativeTransformation.setRotationRadians(jnt.Rotation); + jnt.RelativeTransformation.setTranslation(jnt.Translation); + + if (jnt.Parent == -1) + jnt.AbsoluteTransformation = jnt.RelativeTransformation; + else + { + jnt.AbsoluteTransformation = Joints[jnt.Parent].AbsoluteTransformation; + jnt.AbsoluteTransformation *= jnt.RelativeTransformation; + } + + jnt.AbsoluteTransformationAnimated = jnt.AbsoluteTransformation; + } + + // create vertices and indices, attach them to the joints. + video::S3DVertex v; + + for (i=0; i=0 && boneid<(s32)Joints.size()) + Joints[boneid].VertexIds.push_back(Vertices.size()); + + Vertices.push_back(v); + index = Vertices.size() - 1; + } + Indices.push_back(index); + } + } + + //create groups + s32 iIndex = -1; + for (i=0; i<(int)Groups.size(); ++i) + { + SGroup& grp = Groups[i]; + + if (grp.MaterialIdx >= Buffers.size()) + grp.MaterialIdx = 0; + + core::array& indices = Buffers[grp.MaterialIdx].Indices; + + for (u32 k=0; k& keys, f32 time, core::vector3df& outdata) +{ + + if (keys.size()) + { + if (time < keys[0].timeindex) + { + outdata = keys[0].data; + return; + } + if (time > keys[keys.size()-1].timeindex) + { + outdata = keys[keys.size()-1].data; + return; + } + + for (s32 i=0; i<(s32)keys.size()-1; ++i) + { + if (keys[i].timeindex <= time && keys[i+1].timeindex >= time) + { + f32 interpolate = (time - keys[i].timeindex)/(keys[i+1].timeindex - keys[i].timeindex); + outdata = keys[i].data + ((keys[i+1].data - keys[i].data) * interpolate); + return; + } + } + } +} + + +//! Returns a pointer to a transformation matrix of a part of the +//! mesh based on a frame time. +core::matrix4* CAnimatedMeshMS3D::getMatrixOfJoint(s32 jointNumber, s32 frame) +{ + if (jointNumber < 0 || jointNumber >= (s32)Joints.size()) + return 0; + + animate(frame); + + return &Joints[jointNumber].AbsoluteTransformationAnimated; +} + + +//! Gets joint count. +s32 CAnimatedMeshMS3D::getJointCount() const +{ + return Joints.size(); +} + + +//! Gets the name of a joint. +const c8* CAnimatedMeshMS3D::getJointName(s32 number) const +{ + if (number < 0 || number >= (s32)Joints.size()) + return 0; + return Joints[number].Name.c_str(); +} + + +//! Gets a joint number from its name +s32 CAnimatedMeshMS3D::getJointNumber(const c8* name) const +{ + for (s32 i=0; i<(s32)Joints.size(); ++i) + if (Joints[i].Name == name) + return i; + + return -1; +} + + +void CAnimatedMeshMS3D::animate(s32 frame) +{ + if (!HasAnimation || lastCalculatedFrame == frame) + return; + + f32 time = (f32)frame; + core::matrix4 transform; + lastCalculatedFrame = frame; + + for (s32 i=0; i<(s32)Joints.size(); ++i) + { + core::vector3df translation = Joints[i].Translation; + core::vector3df rotation = Joints[i].Rotation; + + // find keyframe translation and roation + getKeyframeData(Joints[i].TranslationKeys, time, translation); + getKeyframeData(Joints[i].RotationKeys, time, rotation); + + transform.makeIdentity(); + transform.setRotationRadians(rotation); + transform.setTranslation(translation); + + Joints[i].AbsoluteTransformationAnimated = Joints[i].RelativeTransformation * transform; + + if (Joints[i].Parent != -1) + Joints[i].AbsoluteTransformationAnimated = Joints[Joints[i].Parent].AbsoluteTransformationAnimated * Joints[i].AbsoluteTransformationAnimated; + + if (i==0) + BoundingBox.reset(Joints[0].AbsoluteTransformationAnimated.getTranslation()); + else + BoundingBox.addInternalPoint(Joints[i].AbsoluteTransformationAnimated.getTranslation()); + + + // transform all vertices + for (s32 j=0; j<(s32)Joints[i].VertexIds.size(); ++j) + { + Joints[i].AbsoluteTransformationAnimated.transformVect( + AnimatedVertices[Joints[i].VertexIds[j]].Pos, + Vertices[Joints[i].VertexIds[j]].Pos + ); + + Joints[i].AbsoluteTransformationAnimated.transformVect( + AnimatedVertices[Joints[i].VertexIds[j]].Normal, + Vertices[Joints[i].VertexIds[j]].Normal + ); + + // TODO: this could be done much more faster by + // first getting 8 extreme points and putting them in. + BoundingBox.addInternalPoint(AnimatedVertices[Joints[i].VertexIds[j]].Pos); + } + } + +} + + + +//! returns amount of mesh buffers. +u32 CAnimatedMeshMS3D::getMeshBufferCount() const +{ + return Buffers.size(); +} + + + +//! returns pointer to a mesh buffer +IMeshBuffer* CAnimatedMeshMS3D::getMeshBuffer(u32 nr) const +{ + if (nr < Buffers.size()) + return (IMeshBuffer*) &Buffers[nr]; + else + return 0; +} + +//! Returns pointer to a mesh buffer which fits a material +IMeshBuffer* CAnimatedMeshMS3D::getMeshBuffer( const video::SMaterial &material) const +{ + for (u32 i=0; i& CAnimatedMeshMS3D::getBoundingBox() const +{ + return BoundingBox; +} + + +//! set user axis aligned bounding box +void CAnimatedMeshMS3D::setBoundingBox( const core::aabbox3df& box) +{ + BoundingBox = box; +} + +//! sets a flag of all contained materials to a new value +void CAnimatedMeshMS3D::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) +{ + for (s32 i=0; i<(int)Buffers.size(); ++i) + Buffers[i].Material.setFlag(flag, newvalue); +} + + +//! Returns the type of the animated mesh. +E_ANIMATED_MESH_TYPE CAnimatedMeshMS3D::getMeshType() const +{ + return EAMT_MS3D; +} + +//! constructor +CAnimatedMeshMS3D::SMS3DMeshBuffer::SMS3DMeshBuffer() +{ + #ifdef _DEBUG + setDebugName("SMS3DMeshBuffer"); + #endif +} + +//! destructor +CAnimatedMeshMS3D::SMS3DMeshBuffer::~SMS3DMeshBuffer() +{ +} + +//! returns the material of this meshbuffer +const video::SMaterial& CAnimatedMeshMS3D::SMS3DMeshBuffer::getMaterial() const +{ + return Material; +} + +//! returns the material of this meshbuffer +video::SMaterial& CAnimatedMeshMS3D::SMS3DMeshBuffer::getMaterial() +{ + return Material; +} + +//! returns pointer to vertices +const void* CAnimatedMeshMS3D::SMS3DMeshBuffer::getVertices() const +{ + return Vertices->const_pointer(); +} + +//! returns pointer to vertices +void* CAnimatedMeshMS3D::SMS3DMeshBuffer::getVertices() +{ + return Vertices->pointer(); +} + +//! returns amount of vertices +u32 CAnimatedMeshMS3D::SMS3DMeshBuffer::getVertexCount() const +{ + return Vertices->size(); +} + +//! returns pointer to Indices +const u16* CAnimatedMeshMS3D::SMS3DMeshBuffer::getIndices() const +{ + return Indices.const_pointer(); +} + +//! returns pointer to Indices +u16* CAnimatedMeshMS3D::SMS3DMeshBuffer::getIndices() +{ + return Indices.pointer(); +} + +//! returns amount of indices +u32 CAnimatedMeshMS3D::SMS3DMeshBuffer::getIndexCount() const +{ + return Indices.size(); +} + +//! returns an axis aligned bounding box +const core::aabbox3d& CAnimatedMeshMS3D::SMS3DMeshBuffer::getBoundingBox() const +{ + return *BoundingBox; +} + +//! returns an axis aligned bounding box +void CAnimatedMeshMS3D::SMS3DMeshBuffer::setBoundingBox( const core::aabbox3df& box) +{ + *BoundingBox = box; +} + +//! returns which type of vertex data is stored. +video::E_VERTEX_TYPE CAnimatedMeshMS3D::SMS3DMeshBuffer::getVertexType() const +{ + return video::EVT_STANDARD; +} + +//! returns the byte size (stride, pitch) of the vertex +u32 CAnimatedMeshMS3D::SMS3DMeshBuffer::getVertexPitch() const +{ + return sizeof ( video::S3DVertex ); +} + + +} // end namespace scene +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CAnimatedMeshMS3D.h b/src/dep/src/irrlicht/CAnimatedMeshMS3D.h index 3cb5700..7a25aa8 100644 --- a/src/dep/src/irrlicht/CAnimatedMeshMS3D.h +++ b/src/dep/src/irrlicht/CAnimatedMeshMS3D.h @@ -1,191 +1,191 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_ANIMATED_MESH_MS3D_H_INCLUDED__ -#define __C_ANIMATED_MESH_MS3D_H_INCLUDED__ - -#include "IAnimatedMeshMS3D.h" -#include "IReadFile.h" -#include "S3DVertex.h" -#include "irrString.h" -#include "matrix4.h" -#include "SMeshBuffer.h" - -namespace irr -{ -namespace video -{ - class IVideoDriver; -} // end namespace video -namespace scene -{ - - class CAnimatedMeshMS3D : public IAnimatedMeshMS3D, public IMesh - { - public: - - //! constructor - CAnimatedMeshMS3D(video::IVideoDriver* driver); - - //! destructor - virtual ~CAnimatedMeshMS3D(); - - //! loads an md2 file - virtual bool loadFile(io::IReadFile* file); - - //! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. - virtual s32 getFrameCount(); - - //! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. - virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1); - - //! returns amount of mesh buffers. - virtual u32 getMeshBufferCount() const; - - //! returns pointer to a mesh buffer - virtual IMeshBuffer* getMeshBuffer(u32 nr) const; - - //! Returns pointer to a mesh buffer which fits a material - /** \param material: material to search for - \return Returns the pointer to the mesh buffer or - NULL if there is no such mesh buffer. */ - virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const; - - //! returns an axis aligned bounding box - virtual const core::aabbox3d& getBoundingBox() const; - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box); - - //! sets a flag of all contained materials to a new value - virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue); - - //! Returns the type of the animated mesh. - virtual E_ANIMATED_MESH_TYPE getMeshType() const; - - //! Returns a pointer to a transformation matrix of a part of the - //! mesh based on a frame time. - virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame); - - //! Gets joint count. - virtual s32 getJointCount() const; - - //! Gets the name of a joint. - virtual const c8* getJointName(s32 number) const; - - //! Gets a joint number from its name - virtual s32 getJointNumber(const c8* name) const; - - private: - - struct SKeyframe - { - f32 timeindex; - core::vector3df data; // translation or rotation - }; - - struct SJoint - { - core::stringc Name; - s32 Index; - core::vector3df Rotation; - core::vector3df Translation; - - core::matrix4 RelativeTransformation; - core::matrix4 AbsoluteTransformation; - core::matrix4 AbsoluteTransformationAnimated; - - core::array TranslationKeys; - core::array RotationKeys; - core::array VertexIds; - - s32 Parent; - core::stringc ParentName; - }; - - struct SGroup - { - core::stringc Name; - core::array VertexIds; - - u16 MaterialIdx; - }; - - //! Simple implementation of the IMeshBuffer interface with S3DVertex vertices. - struct SMS3DMeshBuffer : public IMeshBuffer - { - //! constructor - SMS3DMeshBuffer(); - - //! destructor - ~SMS3DMeshBuffer(); - - //! returns the material of this meshbuffer - virtual const video::SMaterial& getMaterial() const; - - //! returns the material of this meshbuffer - virtual video::SMaterial& getMaterial(); - - //! returns pointer to vertices - virtual const void* getVertices() const; - - //! returns pointer to vertices - virtual void* getVertices(); - - //! returns amount of vertices - virtual u32 getVertexCount() const; - - //! returns pointer to Indices - virtual const u16* getIndices() const; - - //! returns pointer to Indices - virtual u16* getIndices(); - - //! returns amount of indices - virtual u32 getIndexCount() const; - - //! returns an axis aligned bounding box - virtual const core::aabbox3d& getBoundingBox() const; - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box); - - //! returns which type of vertex data is stored. - virtual video::E_VERTEX_TYPE getVertexType() const; - - //! returns the byte size (stride, pitch) of the vertex - virtual u32 getVertexPitch() const; - - - video::SMaterial Material; //! material for this meshBuffer. - core::array *Vertices; //! Array of vertices - core::array Indices; //! Array of the Indices. - core::aabbox3d *BoundingBox; - }; - - void animate(s32 frame); - void getKeyframeData(core::array& keys, f32 time, core::vector3df& outdata); - - core::aabbox3d BoundingBox; - - core::array Vertices; - core::array AnimatedVertices; - core::array Indices; - - core::array Joints; - core::array Groups; - core::array Buffers; - - f32 totalTime; - bool HasAnimation; - s32 lastCalculatedFrame; - - video::IVideoDriver* Driver; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_ANIMATED_MESH_MS3D_H_INCLUDED__ +#define __C_ANIMATED_MESH_MS3D_H_INCLUDED__ + +#include "IAnimatedMeshMS3D.h" +#include "IReadFile.h" +#include "S3DVertex.h" +#include "irrString.h" +#include "matrix4.h" +#include "SMeshBuffer.h" + +namespace irr +{ +namespace video +{ + class IVideoDriver; +} // end namespace video +namespace scene +{ + + class CAnimatedMeshMS3D : public IAnimatedMeshMS3D, public IMesh + { + public: + + //! constructor + CAnimatedMeshMS3D(video::IVideoDriver* driver); + + //! destructor + virtual ~CAnimatedMeshMS3D(); + + //! loads an md2 file + virtual bool loadFile(io::IReadFile* file); + + //! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. + virtual s32 getFrameCount(); + + //! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. + virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1); + + //! returns amount of mesh buffers. + virtual u32 getMeshBufferCount() const; + + //! returns pointer to a mesh buffer + virtual IMeshBuffer* getMeshBuffer(u32 nr) const; + + //! Returns pointer to a mesh buffer which fits a material + /** \param material: material to search for + \return Returns the pointer to the mesh buffer or + NULL if there is no such mesh buffer. */ + virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const; + + //! returns an axis aligned bounding box + virtual const core::aabbox3d& getBoundingBox() const; + + //! set user axis aligned bounding box + virtual void setBoundingBox( const core::aabbox3df& box); + + //! sets a flag of all contained materials to a new value + virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue); + + //! Returns the type of the animated mesh. + virtual E_ANIMATED_MESH_TYPE getMeshType() const; + + //! Returns a pointer to a transformation matrix of a part of the + //! mesh based on a frame time. + virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame); + + //! Gets joint count. + virtual s32 getJointCount() const; + + //! Gets the name of a joint. + virtual const c8* getJointName(s32 number) const; + + //! Gets a joint number from its name + virtual s32 getJointNumber(const c8* name) const; + + private: + + struct SKeyframe + { + f32 timeindex; + core::vector3df data; // translation or rotation + }; + + struct SJoint + { + core::stringc Name; + s32 Index; + core::vector3df Rotation; + core::vector3df Translation; + + core::matrix4 RelativeTransformation; + core::matrix4 AbsoluteTransformation; + core::matrix4 AbsoluteTransformationAnimated; + + core::array TranslationKeys; + core::array RotationKeys; + core::array VertexIds; + + s32 Parent; + core::stringc ParentName; + }; + + struct SGroup + { + core::stringc Name; + core::array VertexIds; + + u16 MaterialIdx; + }; + + //! Simple implementation of the IMeshBuffer interface with S3DVertex vertices. + struct SMS3DMeshBuffer : public IMeshBuffer + { + //! constructor + SMS3DMeshBuffer(); + + //! destructor + ~SMS3DMeshBuffer(); + + //! returns the material of this meshbuffer + virtual const video::SMaterial& getMaterial() const; + + //! returns the material of this meshbuffer + virtual video::SMaterial& getMaterial(); + + //! returns pointer to vertices + virtual const void* getVertices() const; + + //! returns pointer to vertices + virtual void* getVertices(); + + //! returns amount of vertices + virtual u32 getVertexCount() const; + + //! returns pointer to Indices + virtual const u16* getIndices() const; + + //! returns pointer to Indices + virtual u16* getIndices(); + + //! returns amount of indices + virtual u32 getIndexCount() const; + + //! returns an axis aligned bounding box + virtual const core::aabbox3d& getBoundingBox() const; + + //! set user axis aligned bounding box + virtual void setBoundingBox( const core::aabbox3df& box); + + //! returns which type of vertex data is stored. + virtual video::E_VERTEX_TYPE getVertexType() const; + + //! returns the byte size (stride, pitch) of the vertex + virtual u32 getVertexPitch() const; + + + video::SMaterial Material; //! material for this meshBuffer. + core::array *Vertices; //! Array of vertices + core::array Indices; //! Array of the Indices. + core::aabbox3d *BoundingBox; + }; + + void animate(s32 frame); + void getKeyframeData(core::array& keys, f32 time, core::vector3df& outdata); + + core::aabbox3d BoundingBox; + + core::array Vertices; + core::array AnimatedVertices; + core::array Indices; + + core::array Joints; + core::array Groups; + core::array Buffers; + + f32 totalTime; + bool HasAnimation; + s32 lastCalculatedFrame; + + video::IVideoDriver* Driver; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CAnimatedMeshSceneNode.cpp b/src/dep/src/irrlicht/CAnimatedMeshSceneNode.cpp index 7ab294a..54a81db 100644 --- a/src/dep/src/irrlicht/CAnimatedMeshSceneNode.cpp +++ b/src/dep/src/irrlicht/CAnimatedMeshSceneNode.cpp @@ -1,837 +1,837 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CAnimatedMeshSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "S3DVertex.h" -#include "os.h" -#include "CShadowVolumeSceneNode.h" -#include "ICameraSceneNode.h" -#include "IAnimatedMeshMS3D.h" -#include "IAnimatedMeshMD3.h" -#include "IAnimatedMeshX.h" -#include "IAnimatedMeshB3d.h" -#include "IDummyTransformationSceneNode.h" -#include "IMaterialRenderer.h" -#include "IMeshCache.h" -#include "IAnimatedMesh.h" -#include "quaternion.h" - -namespace irr -{ -namespace scene -{ - - - -//! constructor -CAnimatedMeshSceneNode::CAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) -: IAnimatedMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0), - BeginFrameTime(0), StartFrame(0), EndFrame(0), FramesPerSecond(25.f / 1000.f ), - CurrentFrameNr(0), Looping(true), ReadOnlyMaterials(false), - LoopCallBack(0), PassCount(0), Shadow(0) -{ - #ifdef _DEBUG - setDebugName("CAnimatedMeshSceneNode"); - #endif - - BeginFrameTime = os::Timer::getTime(); - - setMesh(mesh); -} - - - -//! destructor -CAnimatedMeshSceneNode::~CAnimatedMeshSceneNode() -{ - if (Mesh) - Mesh->drop(); - - if (Shadow) - Shadow->drop(); - - for (s32 i=0; i<(s32)JointChildSceneNodes.size(); ++i) - if (JointChildSceneNodes[i]) - JointChildSceneNodes[i]->drop(); - - if (LoopCallBack) - LoopCallBack->drop(); -} - - - -//! Sets the current frame. From now on the animation is played from this frame. -void CAnimatedMeshSceneNode::setCurrentFrame(s32 frame) -{ - // if you pass an out of range value, we just clamp it - CurrentFrameNr = core::s32_clamp ( frame, StartFrame, EndFrame ); - - BeginFrameTime = os::Timer::getTime() - (s32)((CurrentFrameNr - StartFrame) / FramesPerSecond); -} - - -//! Returns the current displayed frame number. -s32 CAnimatedMeshSceneNode::getFrameNr() -{ - return CurrentFrameNr; -} - - -u32 CAnimatedMeshSceneNode::buildFrameNr( u32 timeMs) -{ - s32 len = EndFrame - StartFrame + 1; - - - s32 deltaFrame = core::floor32 ( f32 ( timeMs - BeginFrameTime ) * FramesPerSecond ); - - s32 frame; - if (Looping) - { - // play animation looped - frame = StartFrame + ( deltaFrame % len ); - } - else - { - // play animation non looped - frame = StartFrame + deltaFrame; - - if (frame > EndFrame) - { - frame = EndFrame; - if (LoopCallBack) - LoopCallBack->OnAnimationEnd(this); - } - } - - return frame; -} - -//! frame -void CAnimatedMeshSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - // because this node supports rendering of mixed mode meshes consisting of - // transparent and solid material at the same time, we need to go through all - // materials, check of what type they are and register this node for the right - // render pass according to that. - - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - PassCount = 0; - int transparentCount = 0; - int solidCount = 0; - - // count transparent and solid materials in this scene node - for (u32 i=0; igetMaterialRenderer(Materials[i].MaterialType); - - if (rnd && rnd->isTransparent()) - ++transparentCount; - else - ++solidCount; - - if (solidCount && transparentCount) - break; - } - - // register according to material types counted - - if (solidCount) - SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID); - - if (transparentCount) - SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT); - - ISceneNode::OnRegisterSceneNode(); - - for (s32 j=0; j<(s32)JointChildSceneNodes.size(); ++j) - if (JointChildSceneNodes[j]) - JointChildSceneNodes[j]->OnRegisterSceneNode(); - } -} - - - -//! OnAnimate() is called just before rendering the whole scene. -void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs) -{ - CurrentFrameNr = buildFrameNr ( timeMs ); - - if ( Mesh ) - { - scene::IMesh *m = Mesh->getMesh(CurrentFrameNr, 255, StartFrame, EndFrame); - if ( m ) - { - Box = m->getBoundingBox(); - } - } - - - IAnimatedMeshSceneNode::OnAnimate ( timeMs ); -} - - -/* - angle = dotproduct ( v(0,1,0), up ) - axis = crossproduct ( v(0,1,0), up ) -*/ -inline void AlignToUpVector(irr::core::matrix4 &m, const irr::core::vector3df &up ) -{ - core::quaternion quatRot( up.Z, 0.f, -up.X, 1 + up.Y ); - quatRot.normalize(); - quatRot.getMatrix ( m ); -} - - - -//! renders the node. -void CAnimatedMeshSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - if (!Mesh || !driver) - return; - - bool isTransparentPass = - SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; - - ++PassCount; - - u32 i,g; - video::SMaterial mat; - - s32 frame = getFrameNr(); - scene::IMesh* m = Mesh->getMesh(frame, 255, StartFrame, EndFrame); - - if ( 0 == m ) - { - #ifdef _DEBUG - os::Printer::log("Animated Mesh returned no mesh to render.", Mesh->getDebugName(), ELL_WARNING); - #endif - } - - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - - - // update all dummy transformation nodes - if (!JointChildSceneNodes.empty() && Mesh && - (Mesh->getMeshType() == EAMT_MS3D || Mesh->getMeshType() == EAMT_X || Mesh->getMeshType() == EAMT_B3D )) - { - IAnimatedMeshMS3D* amm = (IAnimatedMeshMS3D*)Mesh; - core::matrix4* mat; - - for ( i=0; i< JointChildSceneNodes.size(); ++i) - if (JointChildSceneNodes[i]) - { - mat = amm->getMatrixOfJoint(i, frame); - if (mat) - JointChildSceneNodes[i]->getRelativeTransformationMatrix() = *mat; - } - } - - if (Shadow && PassCount==1) - Shadow->setMeshToRenderFrom(m); - - // for debug purposes only: - - u32 renderMeshes = 1; - if (DebugDataVisible && PassCount==1) - { - // overwrite half transparency - if ( DebugDataVisible & scene::EDS_HALF_TRANSPARENCY ) - { - for ( g=0; ggetMeshBufferCount(); ++g) - { - mat = Materials[g]; - mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; - driver->setMaterial(mat); - driver->drawMeshBuffer ( m->getMeshBuffer ( g ) ); - } - renderMeshes = 0; - } - } - - // render original meshes - if ( renderMeshes ) - { - for ( i=0; igetMeshBufferCount(); ++i) - { - video::IMaterialRenderer* rnd = driver->getMaterialRenderer(Materials[i].MaterialType); - bool transparent = (rnd && rnd->isTransparent()); - - // only render transparent buffer if this is the transparent render pass - // and solid only in solid pass - if (transparent == isTransparentPass) - { - scene::IMeshBuffer* mb = m->getMeshBuffer(i); - driver->setMaterial(Materials[i]); - driver->drawMeshBuffer(mb); - } - } - } - - // for debug purposes only: - if (DebugDataVisible && PassCount==1) - { - mat.Lighting = false; - driver->setMaterial(mat); - - // show bounding box - if ( DebugDataVisible & scene::EDS_BBOX_BUFFERS ) - { - for ( g=0; g< m->getMeshBufferCount(); ++g) - { - driver->draw3DBox( m->getMeshBuffer(g)->getBoundingBox(), - video::SColor(0,190,128,128) - ); - } - } - - if ( DebugDataVisible & scene::EDS_BBOX ) - { - driver->draw3DBox(Box, video::SColor(0,255,255,255)); - } - - - // show skeleton - if ( DebugDataVisible & scene::EDS_SKELETON ) - { - if (Mesh->getMeshType() == EAMT_X) - { - // draw skeleton - const core::array* ds = - ((IAnimatedMeshX*)Mesh)->getDrawableSkeleton(frame); - - for ( g=0; g < ds->size(); g +=2 ) - driver->draw3DLine((*ds)[g], (*ds)[g+1], video::SColor(0,51,66,255)); - } - - // show tag for quake3 models - if (Mesh->getMeshType() == EAMT_MD3 ) - { - IAnimatedMesh * arrow = SceneManager->addArrowMesh ( "__tag_show", - 4, 8, 5.f, 4.f, 0.5f, 1.f, 0xFF0000FF, 0xFF000088 - ); - if ( 0 == arrow ) - { - arrow = SceneManager->getMesh ( "__tag_show" ); - } - IMesh *arrowMesh = arrow->getMesh ( 0 ); - - video::SMaterial mat; - mat.Lighting = false; - driver->setMaterial(mat); - - core::matrix4 m; - - SMD3QuaterionTagList *taglist = ((IAnimatedMeshMD3*)Mesh)->getTagList ( getFrameNr(), - 255, - getStartFrame (), - getEndFrame () - ); - if ( taglist ) - { - for ( u32 g = 0; g != taglist->size();++g ) - { - (*taglist)[g].setto ( m ); - - driver->setTransform(video::ETS_WORLD, m ); - - for ( u32 a = 0; a != arrowMesh->getMeshBufferCount(); ++a ) - driver->drawMeshBuffer ( arrowMesh->getMeshBuffer ( a ) ); - } - } - } - } - - - // show normals - if ( DebugDataVisible & scene::EDS_NORMALS ) - { - IAnimatedMesh * arrow = SceneManager->addArrowMesh ( "__debugnormal", - 4, 8, 1.f, 0.6f, 0.05f, 0.3f, 0xFFECEC00, 0xFF999900 - ); - if ( 0 == arrow ) - { - arrow = SceneManager->getMesh ( "__debugnormal" ); - } - IMesh *mesh = arrow->getMesh ( 0 ); - - // find a good scaling factor - - core::matrix4 m2; - - // draw normals - for ( g=0; ggetMeshBufferCount(); ++g) - { - scene::IMeshBuffer* mb = m->getMeshBuffer(g); - - const u32 vSize = mb->getVertexPitch(); - - const video::S3DVertex* v = ( const video::S3DVertex*)mb->getVertices(); - for ( i = 0; i != mb->getVertexCount(); ++i ) - { - AlignToUpVector ( m2, v->Normal ); - AbsoluteTransformation.transformVect ( m2.pointer(), v->Pos ); - - driver->setTransform(video::ETS_WORLD, m2 ); - for ( u32 a = 0; a != mesh->getMeshBufferCount(); ++a ) - driver->drawMeshBuffer ( mesh->getMeshBuffer ( a ) ); - - v = (const video::S3DVertex*) ( (u8*) v + vSize ); - } - } - - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - } - - // show mesh - if ( DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY ) - { - mat.Lighting = false; - mat.Wireframe = true; - driver->setMaterial(mat); - - for ( g=0; ggetMeshBufferCount(); ++g) - { - driver->drawMeshBuffer ( m->getMeshBuffer ( g ) ); - } - - } - } -} - - -//! Returns the current start frame number. -s32 CAnimatedMeshSceneNode::getStartFrame() -{ - return StartFrame; -} - -//! Returns the current start frame number. -s32 CAnimatedMeshSceneNode::getEndFrame() -{ - return EndFrame; -} - -//! sets the frames between the animation is looped. -//! the default is 0 - MaximalFrameCount of the mesh. -bool CAnimatedMeshSceneNode::setFrameLoop(s32 begin, s32 end) -{ - if ( end < begin ) - { - StartFrame = core::s32_max(0, end); - EndFrame = core::s32_clamp(begin, StartFrame, Mesh->getFrameCount() - 1); - } - else - { - StartFrame = core::s32_max(0, begin); - EndFrame = core::s32_clamp(end, StartFrame, Mesh->getFrameCount() - 1); - } - setCurrentFrame ( StartFrame ); - - return true; -} - - - -//! sets the speed with witch the animation is played -void CAnimatedMeshSceneNode::setAnimationSpeed(f32 framesPerSecond) -{ - FramesPerSecond = framesPerSecond * 0.001f; -} - - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CAnimatedMeshSceneNode::getBoundingBox() const -{ - return Box; -} - - - -//! returns the material based on the zero based index i. To get the amount -//! of materials used by this scene node, use getMaterialCount(). -//! This function is needed for inserting the node into the scene hirachy on a -//! optimal position for minimizing renderstate changes, but can also be used -//! to directly modify the material of a scene node. -video::SMaterial& CAnimatedMeshSceneNode::getMaterial(u32 i) -{ - if ( i >= Materials.size() ) - return ISceneNode::getMaterial(i); - - return Materials[i]; -} - - - -//! returns amount of materials used by this scene node. -u32 CAnimatedMeshSceneNode::getMaterialCount() -{ - return Materials.size(); -} - - -//! Creates shadow volume scene node as child of this node -//! and returns a pointer to it. -IShadowVolumeSceneNode* CAnimatedMeshSceneNode::addShadowVolumeSceneNode(s32 id, - bool zfailmethod, - f32 infinity) -{ - if (!SceneManager->getVideoDriver()->queryFeature(video::EVDF_STENCIL_BUFFER)) - return 0; - - if (Shadow) - { - os::Printer::log("This node already has a shadow.", ELL_WARNING); - return 0; - } - - Shadow = new CShadowVolumeSceneNode(this, SceneManager, id, zfailmethod, infinity); - return Shadow; -} - - - -//! Returns a pointer to a child node, which has the same transformation as -//! the corrsesponding joint, if the mesh in this scene node is a ms3d mesh. -ISceneNode* CAnimatedMeshSceneNode::getMS3DJointNode(const c8* jointName) -{ - if (!Mesh || Mesh->getMeshType() != EAMT_MS3D) - return 0; - - IAnimatedMeshMS3D* amm = (IAnimatedMeshMS3D*)Mesh; - s32 jointCount = amm->getJointCount(); - s32 number = amm->getJointNumber(jointName); - - if (number == -1) - { - os::Printer::log("Joint with specified name not found in ms3d mesh.", jointName, ELL_WARNING); - return 0; - } - - if (JointChildSceneNodes.empty()) - { - // allocate joints for the first time. - JointChildSceneNodes.set_used(jointCount); - for (s32 i=0; iaddDummyTransformationSceneNode(this); - JointChildSceneNodes[number]->grab(); - } - - return JointChildSceneNodes[number]; -} - - -//! Returns a pointer to a child node, which has the same transformation as -//! the corrsesponding joint, if the mesh in this scene node is a ms3d mesh. -ISceneNode* CAnimatedMeshSceneNode::getXJointNode(const c8* jointName) -{ - if (!Mesh || Mesh->getMeshType() != EAMT_X) - return 0; - - IAnimatedMeshX* amm = (IAnimatedMeshX*)Mesh; - s32 jointCount = amm->getJointCount(); - s32 number = amm->getJointNumber(jointName); - - if (number == -1) - { - os::Printer::log("Joint with specified name not found in x mesh.", jointName, ELL_WARNING); - return 0; - } - - if (JointChildSceneNodes.empty()) - { - // allocate joints for the first time. - JointChildSceneNodes.set_used(jointCount); - for (s32 i=0; iaddDummyTransformationSceneNode(this); - JointChildSceneNodes[number]->grab(); - } - - return JointChildSceneNodes[number]; -} - - -//! Returns a pointer to a child node, which has the same transformation as -//! the corrsesponding joint, if the mesh in this scene node is a b3d mesh. -ISceneNode* CAnimatedMeshSceneNode::getB3DJointNode(const c8* jointName) -{ - if (!Mesh || Mesh->getMeshType() != EAMT_B3D) - return 0; - - IAnimatedMeshB3d* amm = (IAnimatedMeshB3d*)Mesh; - s32 jointCount = amm->getJointCount(); - s32 number = amm->getJointNumber(jointName); - - if (number == -1) - { - os::Printer::log("Joint with specified name not found in b3d mesh.", jointName, ELL_WARNING); - return 0; - } - - if (JointChildSceneNodes.empty()) - { - // allocate joints for the first time. - JointChildSceneNodes.set_used(jointCount); - for (s32 i=0; iaddDummyTransformationSceneNode(this); - JointChildSceneNodes[number]->grab(); - } - - return JointChildSceneNodes[number]; -} - -//! Removes a child from this scene node. -//! Implemented here, to be able to remove the shadow properly, if there is one, -//! or to remove attached childs. -bool CAnimatedMeshSceneNode::removeChild(ISceneNode* child) -{ - if (child && Shadow == child) - { - Shadow->drop(); - Shadow = 0; - return true; - } - - if (ISceneNode::removeChild(child)) - { - for (s32 i=0; i<(s32)JointChildSceneNodes.size(); ++i) - if (JointChildSceneNodes[i] == child) - { - JointChildSceneNodes[i]->drop(); - JointChildSceneNodes[i] = 0; - return true; - } - - return true; - } - - return false; -} - - -//! Starts a MD2 animation. -bool CAnimatedMeshSceneNode::setMD2Animation(EMD2_ANIMATION_TYPE anim) -{ - if (!Mesh || Mesh->getMeshType() != EAMT_MD2) - return false; - - IAnimatedMeshMD2* m = (IAnimatedMeshMD2*)Mesh; - - s32 begin, end, speed; - m->getFrameLoop(anim, begin, end, speed); - - setAnimationSpeed( f32(speed) ); - setFrameLoop(begin, end); - return true; -} - - -//! Starts a special MD2 animation. -bool CAnimatedMeshSceneNode::setMD2Animation(const c8* animationName) -{ - if (!Mesh || Mesh->getMeshType() != EAMT_MD2) - return false; - - IAnimatedMeshMD2* m = (IAnimatedMeshMD2*)Mesh; - - s32 begin, end, speed; - if (!m->getFrameLoop(animationName, begin, end, speed)) - return false; - - setAnimationSpeed( f32(speed) ); - setFrameLoop(begin, end); - return true; -} - - - -//! Sets looping mode which is on by default. If set to false, -//! animations will not be looped. -void CAnimatedMeshSceneNode::setLoopMode(bool playAnimationLooped) -{ - Looping = playAnimationLooped; -} - - -//! Sets a callback interface which will be called if an animation -//! playback has ended. Set this to 0 to disable the callback again. -void CAnimatedMeshSceneNode::setAnimationEndCallback(IAnimationEndCallBack* callback) -{ - if (LoopCallBack) - LoopCallBack->drop(); - - LoopCallBack = callback; - - if (LoopCallBack) - LoopCallBack->grab(); -} - - -//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. -void CAnimatedMeshSceneNode::setReadOnlyMaterials(bool readonly) -{ - ReadOnlyMaterials = readonly; -} - - -//! Returns if the scene node should not copy the materials of the mesh but use them in a read only style -bool CAnimatedMeshSceneNode::isReadOnlyMaterials() -{ - return ReadOnlyMaterials; -} - - -//! Writes attributes of the scene node. -void CAnimatedMeshSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - IAnimatedMeshSceneNode::serializeAttributes(out, options); - - out->addString("Mesh", SceneManager->getMeshCache()->getMeshFilename(Mesh)); - out->addBool("Looping", Looping); - out->addBool("ReadOnlyMaterials", ReadOnlyMaterials); - out->addFloat("FramesPerSecond", FramesPerSecond); - - // TODO: write animation names instead of frame begin and ends -} - - -//! Reads attributes of the scene node. -void CAnimatedMeshSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - IAnimatedMeshSceneNode::deserializeAttributes(in, options); - - core::stringc oldMeshStr = SceneManager->getMeshCache()->getMeshFilename(Mesh); - core::stringc newMeshStr = in->getAttributeAsString("Mesh"); - - Looping = in->getAttributeAsBool("Looping"); - ReadOnlyMaterials = in->getAttributeAsBool("ReadOnlyMaterials"); - FramesPerSecond = in->getAttributeAsFloat("FramesPerSecond"); - - if (newMeshStr != "" && oldMeshStr != newMeshStr) - { - IAnimatedMesh* newAnimatedMesh = SceneManager->getMesh(newMeshStr.c_str()); - - if (newAnimatedMesh) - setMesh(newAnimatedMesh); - } - - // TODO: read animation names instead of frame begin and ends -} - - -//! Sets a new mesh -void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh* mesh) -{ - if (!mesh) - return; // won't set null mesh - - if (Mesh) - Mesh->drop(); - - Mesh = mesh; - - // get materials and bounding box - Box = Mesh->getBoundingBox(); - - IMesh* m = Mesh->getMesh(0,0); - if (m) - { - Materials.clear(); - - video::SMaterial mat; - for (u32 i=0; igetMeshBufferCount(); ++i) - { - IMeshBuffer* mb = m->getMeshBuffer(i); - if (mb) - mat = mb->getMaterial(); - - Materials.push_back(mat); - } - } - - // get start and begin time - setFrameLoop ( 0, Mesh->getFrameCount() ); - - // grab the mesh - if (Mesh) - Mesh->grab(); -} - -// returns the absolute transformation for a special MD3 Tag if the mesh is a md3 mesh, -// or the absolutetransformation if it's a normal scenenode -const SMD3QuaterionTag& CAnimatedMeshSceneNode::getAbsoluteTransformation( const core::stringc & tagname) -{ - SMD3QuaterionTag * tag = MD3Special.AbsoluteTagList.get ( tagname ); - if ( tag ) - return *tag; - - MD3Special.AbsoluteTagList.Container.push_back ( SMD3QuaterionTag ( tagname, AbsoluteTransformation ) ); - return *MD3Special.AbsoluteTagList.get ( tagname ); -} - - -//! updates the absolute position based on the relative and the parents position -void CAnimatedMeshSceneNode::updateAbsolutePosition() -{ - if ( 0 == Mesh || Mesh->getMeshType() != EAMT_MD3 ) - { - IAnimatedMeshSceneNode::updateAbsolutePosition(); - return; - } - - SMD3QuaterionTag parent; - if ( Parent && Parent->getType () == ESNT_ANIMATED_MESH) - { - parent = ((IAnimatedMeshSceneNode*) Parent)->getAbsoluteTransformation ( MD3Special.Tagname ); - } - - SMD3QuaterionTag relative( RelativeTranslation, RelativeRotation ); - - SMD3QuaterionTagList *taglist; - taglist = ( (IAnimatedMeshMD3*) Mesh )->getTagList ( getFrameNr(),255,getStartFrame (),getEndFrame () ); - if ( taglist ) - { - MD3Special.AbsoluteTagList.Container.set_used ( taglist->size () ); - u32 i; - for ( i = 0; i!= taglist->size (); ++i ) - { - MD3Special.AbsoluteTagList[i].position = parent.position + (*taglist)[i].position + relative.position; - MD3Special.AbsoluteTagList[i].rotation = parent.rotation * (*taglist)[i].rotation * relative.rotation; - } - - } - -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CAnimatedMeshSceneNode.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" +#include "S3DVertex.h" +#include "os.h" +#include "CShadowVolumeSceneNode.h" +#include "ICameraSceneNode.h" +#include "IAnimatedMeshMS3D.h" +#include "IAnimatedMeshMD3.h" +#include "IAnimatedMeshX.h" +#include "IAnimatedMeshB3d.h" +#include "IDummyTransformationSceneNode.h" +#include "IMaterialRenderer.h" +#include "IMeshCache.h" +#include "IAnimatedMesh.h" +#include "quaternion.h" + +namespace irr +{ +namespace scene +{ + + + +//! constructor +CAnimatedMeshSceneNode::CAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) +: IAnimatedMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0), + BeginFrameTime(0), StartFrame(0), EndFrame(0), FramesPerSecond(25.f / 1000.f ), + CurrentFrameNr(0), Looping(true), ReadOnlyMaterials(false), + LoopCallBack(0), PassCount(0), Shadow(0) +{ + #ifdef _DEBUG + setDebugName("CAnimatedMeshSceneNode"); + #endif + + BeginFrameTime = os::Timer::getTime(); + + setMesh(mesh); +} + + + +//! destructor +CAnimatedMeshSceneNode::~CAnimatedMeshSceneNode() +{ + if (Mesh) + Mesh->drop(); + + if (Shadow) + Shadow->drop(); + + for (s32 i=0; i<(s32)JointChildSceneNodes.size(); ++i) + if (JointChildSceneNodes[i]) + JointChildSceneNodes[i]->drop(); + + if (LoopCallBack) + LoopCallBack->drop(); +} + + + +//! Sets the current frame. From now on the animation is played from this frame. +void CAnimatedMeshSceneNode::setCurrentFrame(s32 frame) +{ + // if you pass an out of range value, we just clamp it + CurrentFrameNr = core::s32_clamp ( frame, StartFrame, EndFrame ); + + BeginFrameTime = os::Timer::getTime() - (s32)((CurrentFrameNr - StartFrame) / FramesPerSecond); +} + + +//! Returns the current displayed frame number. +s32 CAnimatedMeshSceneNode::getFrameNr() +{ + return CurrentFrameNr; +} + + +u32 CAnimatedMeshSceneNode::buildFrameNr( u32 timeMs) +{ + s32 len = EndFrame - StartFrame + 1; + + + s32 deltaFrame = core::floor32 ( f32 ( timeMs - BeginFrameTime ) * FramesPerSecond ); + + s32 frame; + if (Looping) + { + // play animation looped + frame = StartFrame + ( deltaFrame % len ); + } + else + { + // play animation non looped + frame = StartFrame + deltaFrame; + + if (frame > EndFrame) + { + frame = EndFrame; + if (LoopCallBack) + LoopCallBack->OnAnimationEnd(this); + } + } + + return frame; +} + +//! frame +void CAnimatedMeshSceneNode::OnRegisterSceneNode() +{ + if (IsVisible) + { + // because this node supports rendering of mixed mode meshes consisting of + // transparent and solid material at the same time, we need to go through all + // materials, check of what type they are and register this node for the right + // render pass according to that. + + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + + PassCount = 0; + int transparentCount = 0; + int solidCount = 0; + + // count transparent and solid materials in this scene node + for (u32 i=0; igetMaterialRenderer(Materials[i].MaterialType); + + if (rnd && rnd->isTransparent()) + ++transparentCount; + else + ++solidCount; + + if (solidCount && transparentCount) + break; + } + + // register according to material types counted + + if (solidCount) + SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID); + + if (transparentCount) + SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT); + + ISceneNode::OnRegisterSceneNode(); + + for (s32 j=0; j<(s32)JointChildSceneNodes.size(); ++j) + if (JointChildSceneNodes[j]) + JointChildSceneNodes[j]->OnRegisterSceneNode(); + } +} + + + +//! OnAnimate() is called just before rendering the whole scene. +void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs) +{ + CurrentFrameNr = buildFrameNr ( timeMs ); + + if ( Mesh ) + { + scene::IMesh *m = Mesh->getMesh(CurrentFrameNr, 255, StartFrame, EndFrame); + if ( m ) + { + Box = m->getBoundingBox(); + } + } + + + IAnimatedMeshSceneNode::OnAnimate ( timeMs ); +} + + +/* + angle = dotproduct ( v(0,1,0), up ) + axis = crossproduct ( v(0,1,0), up ) +*/ +inline void AlignToUpVector(irr::core::matrix4 &m, const irr::core::vector3df &up ) +{ + core::quaternion quatRot( up.Z, 0.f, -up.X, 1 + up.Y ); + quatRot.normalize(); + quatRot.getMatrix ( m ); +} + + + +//! renders the node. +void CAnimatedMeshSceneNode::render() +{ + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + + if (!Mesh || !driver) + return; + + bool isTransparentPass = + SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; + + ++PassCount; + + u32 i,g; + video::SMaterial mat; + + s32 frame = getFrameNr(); + scene::IMesh* m = Mesh->getMesh(frame, 255, StartFrame, EndFrame); + + if ( 0 == m ) + { + #ifdef _DEBUG + os::Printer::log("Animated Mesh returned no mesh to render.", Mesh->getDebugName(), ELL_WARNING); + #endif + } + + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + + + // update all dummy transformation nodes + if (!JointChildSceneNodes.empty() && Mesh && + (Mesh->getMeshType() == EAMT_MS3D || Mesh->getMeshType() == EAMT_X || Mesh->getMeshType() == EAMT_B3D )) + { + IAnimatedMeshMS3D* amm = (IAnimatedMeshMS3D*)Mesh; + core::matrix4* mat; + + for ( i=0; i< JointChildSceneNodes.size(); ++i) + if (JointChildSceneNodes[i]) + { + mat = amm->getMatrixOfJoint(i, frame); + if (mat) + JointChildSceneNodes[i]->getRelativeTransformationMatrix() = *mat; + } + } + + if (Shadow && PassCount==1) + Shadow->setMeshToRenderFrom(m); + + // for debug purposes only: + + u32 renderMeshes = 1; + if (DebugDataVisible && PassCount==1) + { + // overwrite half transparency + if ( DebugDataVisible & scene::EDS_HALF_TRANSPARENCY ) + { + for ( g=0; ggetMeshBufferCount(); ++g) + { + mat = Materials[g]; + mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; + driver->setMaterial(mat); + driver->drawMeshBuffer ( m->getMeshBuffer ( g ) ); + } + renderMeshes = 0; + } + } + + // render original meshes + if ( renderMeshes ) + { + for ( i=0; igetMeshBufferCount(); ++i) + { + video::IMaterialRenderer* rnd = driver->getMaterialRenderer(Materials[i].MaterialType); + bool transparent = (rnd && rnd->isTransparent()); + + // only render transparent buffer if this is the transparent render pass + // and solid only in solid pass + if (transparent == isTransparentPass) + { + scene::IMeshBuffer* mb = m->getMeshBuffer(i); + driver->setMaterial(Materials[i]); + driver->drawMeshBuffer(mb); + } + } + } + + // for debug purposes only: + if (DebugDataVisible && PassCount==1) + { + mat.Lighting = false; + driver->setMaterial(mat); + + // show bounding box + if ( DebugDataVisible & scene::EDS_BBOX_BUFFERS ) + { + for ( g=0; g< m->getMeshBufferCount(); ++g) + { + driver->draw3DBox( m->getMeshBuffer(g)->getBoundingBox(), + video::SColor(0,190,128,128) + ); + } + } + + if ( DebugDataVisible & scene::EDS_BBOX ) + { + driver->draw3DBox(Box, video::SColor(0,255,255,255)); + } + + + // show skeleton + if ( DebugDataVisible & scene::EDS_SKELETON ) + { + if (Mesh->getMeshType() == EAMT_X) + { + // draw skeleton + const core::array* ds = + ((IAnimatedMeshX*)Mesh)->getDrawableSkeleton(frame); + + for ( g=0; g < ds->size(); g +=2 ) + driver->draw3DLine((*ds)[g], (*ds)[g+1], video::SColor(0,51,66,255)); + } + + // show tag for quake3 models + if (Mesh->getMeshType() == EAMT_MD3 ) + { + IAnimatedMesh * arrow = SceneManager->addArrowMesh ( "__tag_show", + 4, 8, 5.f, 4.f, 0.5f, 1.f, 0xFF0000FF, 0xFF000088 + ); + if ( 0 == arrow ) + { + arrow = SceneManager->getMesh ( "__tag_show" ); + } + IMesh *arrowMesh = arrow->getMesh ( 0 ); + + video::SMaterial mat; + mat.Lighting = false; + driver->setMaterial(mat); + + core::matrix4 m; + + SMD3QuaterionTagList *taglist = ((IAnimatedMeshMD3*)Mesh)->getTagList ( getFrameNr(), + 255, + getStartFrame (), + getEndFrame () + ); + if ( taglist ) + { + for ( u32 g = 0; g != taglist->size();++g ) + { + (*taglist)[g].setto ( m ); + + driver->setTransform(video::ETS_WORLD, m ); + + for ( u32 a = 0; a != arrowMesh->getMeshBufferCount(); ++a ) + driver->drawMeshBuffer ( arrowMesh->getMeshBuffer ( a ) ); + } + } + } + } + + + // show normals + if ( DebugDataVisible & scene::EDS_NORMALS ) + { + IAnimatedMesh * arrow = SceneManager->addArrowMesh ( "__debugnormal", + 4, 8, 1.f, 0.6f, 0.05f, 0.3f, 0xFFECEC00, 0xFF999900 + ); + if ( 0 == arrow ) + { + arrow = SceneManager->getMesh ( "__debugnormal" ); + } + IMesh *mesh = arrow->getMesh ( 0 ); + + // find a good scaling factor + + core::matrix4 m2; + + // draw normals + for ( g=0; ggetMeshBufferCount(); ++g) + { + scene::IMeshBuffer* mb = m->getMeshBuffer(g); + + const u32 vSize = mb->getVertexPitch(); + + const video::S3DVertex* v = ( const video::S3DVertex*)mb->getVertices(); + for ( i = 0; i != mb->getVertexCount(); ++i ) + { + AlignToUpVector ( m2, v->Normal ); + AbsoluteTransformation.transformVect ( m2.pointer(), v->Pos ); + + driver->setTransform(video::ETS_WORLD, m2 ); + for ( u32 a = 0; a != mesh->getMeshBufferCount(); ++a ) + driver->drawMeshBuffer ( mesh->getMeshBuffer ( a ) ); + + v = (const video::S3DVertex*) ( (u8*) v + vSize ); + } + } + + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + } + + // show mesh + if ( DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY ) + { + mat.Lighting = false; + mat.Wireframe = true; + driver->setMaterial(mat); + + for ( g=0; ggetMeshBufferCount(); ++g) + { + driver->drawMeshBuffer ( m->getMeshBuffer ( g ) ); + } + + } + } +} + + +//! Returns the current start frame number. +s32 CAnimatedMeshSceneNode::getStartFrame() +{ + return StartFrame; +} + +//! Returns the current start frame number. +s32 CAnimatedMeshSceneNode::getEndFrame() +{ + return EndFrame; +} + +//! sets the frames between the animation is looped. +//! the default is 0 - MaximalFrameCount of the mesh. +bool CAnimatedMeshSceneNode::setFrameLoop(s32 begin, s32 end) +{ + if ( end < begin ) + { + StartFrame = core::s32_max(0, end); + EndFrame = core::s32_clamp(begin, StartFrame, Mesh->getFrameCount() - 1); + } + else + { + StartFrame = core::s32_max(0, begin); + EndFrame = core::s32_clamp(end, StartFrame, Mesh->getFrameCount() - 1); + } + setCurrentFrame ( StartFrame ); + + return true; +} + + + +//! sets the speed with witch the animation is played +void CAnimatedMeshSceneNode::setAnimationSpeed(f32 framesPerSecond) +{ + FramesPerSecond = framesPerSecond * 0.001f; +} + + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CAnimatedMeshSceneNode::getBoundingBox() const +{ + return Box; +} + + + +//! returns the material based on the zero based index i. To get the amount +//! of materials used by this scene node, use getMaterialCount(). +//! This function is needed for inserting the node into the scene hirachy on a +//! optimal position for minimizing renderstate changes, but can also be used +//! to directly modify the material of a scene node. +video::SMaterial& CAnimatedMeshSceneNode::getMaterial(u32 i) +{ + if ( i >= Materials.size() ) + return ISceneNode::getMaterial(i); + + return Materials[i]; +} + + + +//! returns amount of materials used by this scene node. +u32 CAnimatedMeshSceneNode::getMaterialCount() +{ + return Materials.size(); +} + + +//! Creates shadow volume scene node as child of this node +//! and returns a pointer to it. +IShadowVolumeSceneNode* CAnimatedMeshSceneNode::addShadowVolumeSceneNode(s32 id, + bool zfailmethod, + f32 infinity) +{ + if (!SceneManager->getVideoDriver()->queryFeature(video::EVDF_STENCIL_BUFFER)) + return 0; + + if (Shadow) + { + os::Printer::log("This node already has a shadow.", ELL_WARNING); + return 0; + } + + Shadow = new CShadowVolumeSceneNode(this, SceneManager, id, zfailmethod, infinity); + return Shadow; +} + + + +//! Returns a pointer to a child node, which has the same transformation as +//! the corrsesponding joint, if the mesh in this scene node is a ms3d mesh. +ISceneNode* CAnimatedMeshSceneNode::getMS3DJointNode(const c8* jointName) +{ + if (!Mesh || Mesh->getMeshType() != EAMT_MS3D) + return 0; + + IAnimatedMeshMS3D* amm = (IAnimatedMeshMS3D*)Mesh; + s32 jointCount = amm->getJointCount(); + s32 number = amm->getJointNumber(jointName); + + if (number == -1) + { + os::Printer::log("Joint with specified name not found in ms3d mesh.", jointName, ELL_WARNING); + return 0; + } + + if (JointChildSceneNodes.empty()) + { + // allocate joints for the first time. + JointChildSceneNodes.set_used(jointCount); + for (s32 i=0; iaddDummyTransformationSceneNode(this); + JointChildSceneNodes[number]->grab(); + } + + return JointChildSceneNodes[number]; +} + + +//! Returns a pointer to a child node, which has the same transformation as +//! the corrsesponding joint, if the mesh in this scene node is a ms3d mesh. +ISceneNode* CAnimatedMeshSceneNode::getXJointNode(const c8* jointName) +{ + if (!Mesh || Mesh->getMeshType() != EAMT_X) + return 0; + + IAnimatedMeshX* amm = (IAnimatedMeshX*)Mesh; + s32 jointCount = amm->getJointCount(); + s32 number = amm->getJointNumber(jointName); + + if (number == -1) + { + os::Printer::log("Joint with specified name not found in x mesh.", jointName, ELL_WARNING); + return 0; + } + + if (JointChildSceneNodes.empty()) + { + // allocate joints for the first time. + JointChildSceneNodes.set_used(jointCount); + for (s32 i=0; iaddDummyTransformationSceneNode(this); + JointChildSceneNodes[number]->grab(); + } + + return JointChildSceneNodes[number]; +} + + +//! Returns a pointer to a child node, which has the same transformation as +//! the corrsesponding joint, if the mesh in this scene node is a b3d mesh. +ISceneNode* CAnimatedMeshSceneNode::getB3DJointNode(const c8* jointName) +{ + if (!Mesh || Mesh->getMeshType() != EAMT_B3D) + return 0; + + IAnimatedMeshB3d* amm = (IAnimatedMeshB3d*)Mesh; + s32 jointCount = amm->getJointCount(); + s32 number = amm->getJointNumber(jointName); + + if (number == -1) + { + os::Printer::log("Joint with specified name not found in b3d mesh.", jointName, ELL_WARNING); + return 0; + } + + if (JointChildSceneNodes.empty()) + { + // allocate joints for the first time. + JointChildSceneNodes.set_used(jointCount); + for (s32 i=0; iaddDummyTransformationSceneNode(this); + JointChildSceneNodes[number]->grab(); + } + + return JointChildSceneNodes[number]; +} + +//! Removes a child from this scene node. +//! Implemented here, to be able to remove the shadow properly, if there is one, +//! or to remove attached childs. +bool CAnimatedMeshSceneNode::removeChild(ISceneNode* child) +{ + if (child && Shadow == child) + { + Shadow->drop(); + Shadow = 0; + return true; + } + + if (ISceneNode::removeChild(child)) + { + for (s32 i=0; i<(s32)JointChildSceneNodes.size(); ++i) + if (JointChildSceneNodes[i] == child) + { + JointChildSceneNodes[i]->drop(); + JointChildSceneNodes[i] = 0; + return true; + } + + return true; + } + + return false; +} + + +//! Starts a MD2 animation. +bool CAnimatedMeshSceneNode::setMD2Animation(EMD2_ANIMATION_TYPE anim) +{ + if (!Mesh || Mesh->getMeshType() != EAMT_MD2) + return false; + + IAnimatedMeshMD2* m = (IAnimatedMeshMD2*)Mesh; + + s32 begin, end, speed; + m->getFrameLoop(anim, begin, end, speed); + + setAnimationSpeed( f32(speed) ); + setFrameLoop(begin, end); + return true; +} + + +//! Starts a special MD2 animation. +bool CAnimatedMeshSceneNode::setMD2Animation(const c8* animationName) +{ + if (!Mesh || Mesh->getMeshType() != EAMT_MD2) + return false; + + IAnimatedMeshMD2* m = (IAnimatedMeshMD2*)Mesh; + + s32 begin, end, speed; + if (!m->getFrameLoop(animationName, begin, end, speed)) + return false; + + setAnimationSpeed( f32(speed) ); + setFrameLoop(begin, end); + return true; +} + + + +//! Sets looping mode which is on by default. If set to false, +//! animations will not be looped. +void CAnimatedMeshSceneNode::setLoopMode(bool playAnimationLooped) +{ + Looping = playAnimationLooped; +} + + +//! Sets a callback interface which will be called if an animation +//! playback has ended. Set this to 0 to disable the callback again. +void CAnimatedMeshSceneNode::setAnimationEndCallback(IAnimationEndCallBack* callback) +{ + if (LoopCallBack) + LoopCallBack->drop(); + + LoopCallBack = callback; + + if (LoopCallBack) + LoopCallBack->grab(); +} + + +//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. +void CAnimatedMeshSceneNode::setReadOnlyMaterials(bool readonly) +{ + ReadOnlyMaterials = readonly; +} + + +//! Returns if the scene node should not copy the materials of the mesh but use them in a read only style +bool CAnimatedMeshSceneNode::isReadOnlyMaterials() +{ + return ReadOnlyMaterials; +} + + +//! Writes attributes of the scene node. +void CAnimatedMeshSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + IAnimatedMeshSceneNode::serializeAttributes(out, options); + + out->addString("Mesh", SceneManager->getMeshCache()->getMeshFilename(Mesh)); + out->addBool("Looping", Looping); + out->addBool("ReadOnlyMaterials", ReadOnlyMaterials); + out->addFloat("FramesPerSecond", FramesPerSecond); + + // TODO: write animation names instead of frame begin and ends +} + + +//! Reads attributes of the scene node. +void CAnimatedMeshSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + IAnimatedMeshSceneNode::deserializeAttributes(in, options); + + core::stringc oldMeshStr = SceneManager->getMeshCache()->getMeshFilename(Mesh); + core::stringc newMeshStr = in->getAttributeAsString("Mesh"); + + Looping = in->getAttributeAsBool("Looping"); + ReadOnlyMaterials = in->getAttributeAsBool("ReadOnlyMaterials"); + FramesPerSecond = in->getAttributeAsFloat("FramesPerSecond"); + + if (newMeshStr != "" && oldMeshStr != newMeshStr) + { + IAnimatedMesh* newAnimatedMesh = SceneManager->getMesh(newMeshStr.c_str()); + + if (newAnimatedMesh) + setMesh(newAnimatedMesh); + } + + // TODO: read animation names instead of frame begin and ends +} + + +//! Sets a new mesh +void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh* mesh) +{ + if (!mesh) + return; // won't set null mesh + + if (Mesh) + Mesh->drop(); + + Mesh = mesh; + + // get materials and bounding box + Box = Mesh->getBoundingBox(); + + IMesh* m = Mesh->getMesh(0,0); + if (m) + { + Materials.clear(); + + video::SMaterial mat; + for (u32 i=0; igetMeshBufferCount(); ++i) + { + IMeshBuffer* mb = m->getMeshBuffer(i); + if (mb) + mat = mb->getMaterial(); + + Materials.push_back(mat); + } + } + + // get start and begin time + setFrameLoop ( 0, Mesh->getFrameCount() ); + + // grab the mesh + if (Mesh) + Mesh->grab(); +} + +// returns the absolute transformation for a special MD3 Tag if the mesh is a md3 mesh, +// or the absolutetransformation if it's a normal scenenode +const SMD3QuaterionTag& CAnimatedMeshSceneNode::getAbsoluteTransformation( const core::stringc & tagname) +{ + SMD3QuaterionTag * tag = MD3Special.AbsoluteTagList.get ( tagname ); + if ( tag ) + return *tag; + + MD3Special.AbsoluteTagList.Container.push_back ( SMD3QuaterionTag ( tagname, AbsoluteTransformation ) ); + return *MD3Special.AbsoluteTagList.get ( tagname ); +} + + +//! updates the absolute position based on the relative and the parents position +void CAnimatedMeshSceneNode::updateAbsolutePosition() +{ + if ( 0 == Mesh || Mesh->getMeshType() != EAMT_MD3 ) + { + IAnimatedMeshSceneNode::updateAbsolutePosition(); + return; + } + + SMD3QuaterionTag parent; + if ( Parent && Parent->getType () == ESNT_ANIMATED_MESH) + { + parent = ((IAnimatedMeshSceneNode*) Parent)->getAbsoluteTransformation ( MD3Special.Tagname ); + } + + SMD3QuaterionTag relative( RelativeTranslation, RelativeRotation ); + + SMD3QuaterionTagList *taglist; + taglist = ( (IAnimatedMeshMD3*) Mesh )->getTagList ( getFrameNr(),255,getStartFrame (),getEndFrame () ); + if ( taglist ) + { + MD3Special.AbsoluteTagList.Container.set_used ( taglist->size () ); + u32 i; + for ( i = 0; i!= taglist->size (); ++i ) + { + MD3Special.AbsoluteTagList[i].position = parent.position + (*taglist)[i].position + relative.position; + MD3Special.AbsoluteTagList[i].rotation = parent.rotation * (*taglist)[i].rotation * relative.rotation; + } + + } + +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CAnimatedMeshSceneNode.h b/src/dep/src/irrlicht/CAnimatedMeshSceneNode.h index 4b96bfa..67cca21 100644 --- a/src/dep/src/irrlicht/CAnimatedMeshSceneNode.h +++ b/src/dep/src/irrlicht/CAnimatedMeshSceneNode.h @@ -1,173 +1,173 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ -#define __C_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ - -#include "IAnimatedMeshSceneNode.h" -#include "IAnimatedMesh.h" - -namespace irr -{ -namespace scene -{ - class IDummyTransformationSceneNode; - - class CAnimatedMeshSceneNode : public IAnimatedMeshSceneNode - { - public: - - //! constructor - CAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! destructor - virtual ~CAnimatedMeshSceneNode(); - - //! sets the current frame. from now on the animation is played from this frame. - virtual void setCurrentFrame(s32 frame); - - //! frame - virtual void OnRegisterSceneNode(); - - //! OnAnimate() is called just before rendering the whole scene. - virtual void OnAnimate(u32 timeMs); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! sets the frames between the animation is looped. - //! the default is 0 - MaximalFrameCount of the mesh. - virtual bool setFrameLoop(s32 begin, s32 end); - - //! Sets looping mode which is on by default. If set to false, - //! animations will not be looped. - virtual void setLoopMode(bool playAnimationLooped); - - //! Sets a callback interface which will be called if an animation - //! playback has ended. Set this to 0 to disable the callback again. - virtual void setAnimationEndCallback(IAnimationEndCallBack* callback=0); - - //! sets the speed with witch the animation is played - virtual void setAnimationSpeed(f32 framesPerSecond); - - //! returns the material based on the zero based index i. To get the amount - //! of materials used by this scene node, use getMaterialCount(). - //! This function is needed for inserting the node into the scene hirachy on a - //! optimal position for minimizing renderstate changes, but can also be used - //! to directly modify the material of a scene node. - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount(); - - //! Creates shadow volume scene node as child of this node - //! and returns a pointer to it. - virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(s32 id, - bool zfailmethod=true, f32 infinity=10000.0f); - - //! Returns a pointer to a child node, which has the same transformation as - //! the corrsesponding joint, if the mesh in this scene node is a ms3d mesh. - virtual ISceneNode* getMS3DJointNode(const c8* jointName); - - //! Returns a pointer to a child node, which has the same transformation as - //! the corrsesponding joint, if the mesh in this scene node is a x mesh. - virtual ISceneNode* getXJointNode(const c8* jointName); - - //! Returns a pointer to a child node, which has the same transformation as - //! the corresponding joint, if the mesh in this scene node is a b3d mesh. - virtual ISceneNode* getB3DJointNode(const c8* jointName); - - //! Removes a child from this scene node. - //! Implemented here, to be able to remove the shadow properly, if there is one, - //! or to remove attached childs. - virtual bool removeChild(ISceneNode* child); - - //! Starts a MD2 animation. - virtual bool setMD2Animation(EMD2_ANIMATION_TYPE anim); - - //! Starts a special MD2 animation. - virtual bool setMD2Animation(const c8* animationName); - - //! Returns the current displayed frame number. - virtual s32 getFrameNr(); - //! Returns the current start frame number. - virtual s32 getStartFrame(); - //! Returns the current end frame number. - virtual s32 getEndFrame(); - - //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. - /* In this way it is possible to change the materials a mesh causing all mesh scene nodes - referencing this mesh to change too. */ - virtual void setReadOnlyMaterials(bool readonly); - - //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style - virtual bool isReadOnlyMaterials(); - - //! Sets a new mesh - virtual void setMesh(IAnimatedMesh* mesh); - - //! Returns the current mesh - virtual IAnimatedMesh* getMesh(void) { return Mesh; } - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_ANIMATED_MESH; } - - // returns the absolute transformation for a special MD3 Tag if the mesh is a md3 mesh, - // or the absolutetransformation if it's a normal scenenode - const SMD3QuaterionTag& getAbsoluteTransformation( const core::stringc & tagname); - - //! updates the absolute position based on the relative and the parents position - virtual void updateAbsolutePosition(); - - private: - - u32 buildFrameNr( u32 timeMs); - - core::array Materials; - core::aabbox3d Box; - IAnimatedMesh* Mesh; - - u32 BeginFrameTime; - s32 StartFrame; - s32 EndFrame; - f32 FramesPerSecond; - - u32 CurrentFrameNr; - - bool Looping; - bool ReadOnlyMaterials; - - IAnimationEndCallBack* LoopCallBack; - s32 PassCount; - - IShadowVolumeSceneNode* Shadow; - - core::array JointChildSceneNodes; - - struct SMD3Special - { - core::stringc Tagname; - SMD3QuaterionTagList AbsoluteTagList; - }; - SMD3Special MD3Special; - - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ +#define __C_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ + +#include "IAnimatedMeshSceneNode.h" +#include "IAnimatedMesh.h" + +namespace irr +{ +namespace scene +{ + class IDummyTransformationSceneNode; + + class CAnimatedMeshSceneNode : public IAnimatedMeshSceneNode + { + public: + + //! constructor + CAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); + + //! destructor + virtual ~CAnimatedMeshSceneNode(); + + //! sets the current frame. from now on the animation is played from this frame. + virtual void setCurrentFrame(s32 frame); + + //! frame + virtual void OnRegisterSceneNode(); + + //! OnAnimate() is called just before rendering the whole scene. + virtual void OnAnimate(u32 timeMs); + + //! renders the node. + virtual void render(); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! sets the frames between the animation is looped. + //! the default is 0 - MaximalFrameCount of the mesh. + virtual bool setFrameLoop(s32 begin, s32 end); + + //! Sets looping mode which is on by default. If set to false, + //! animations will not be looped. + virtual void setLoopMode(bool playAnimationLooped); + + //! Sets a callback interface which will be called if an animation + //! playback has ended. Set this to 0 to disable the callback again. + virtual void setAnimationEndCallback(IAnimationEndCallBack* callback=0); + + //! sets the speed with witch the animation is played + virtual void setAnimationSpeed(f32 framesPerSecond); + + //! returns the material based on the zero based index i. To get the amount + //! of materials used by this scene node, use getMaterialCount(). + //! This function is needed for inserting the node into the scene hirachy on a + //! optimal position for minimizing renderstate changes, but can also be used + //! to directly modify the material of a scene node. + virtual video::SMaterial& getMaterial(u32 i); + + //! returns amount of materials used by this scene node. + virtual u32 getMaterialCount(); + + //! Creates shadow volume scene node as child of this node + //! and returns a pointer to it. + virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(s32 id, + bool zfailmethod=true, f32 infinity=10000.0f); + + //! Returns a pointer to a child node, which has the same transformation as + //! the corrsesponding joint, if the mesh in this scene node is a ms3d mesh. + virtual ISceneNode* getMS3DJointNode(const c8* jointName); + + //! Returns a pointer to a child node, which has the same transformation as + //! the corrsesponding joint, if the mesh in this scene node is a x mesh. + virtual ISceneNode* getXJointNode(const c8* jointName); + + //! Returns a pointer to a child node, which has the same transformation as + //! the corresponding joint, if the mesh in this scene node is a b3d mesh. + virtual ISceneNode* getB3DJointNode(const c8* jointName); + + //! Removes a child from this scene node. + //! Implemented here, to be able to remove the shadow properly, if there is one, + //! or to remove attached childs. + virtual bool removeChild(ISceneNode* child); + + //! Starts a MD2 animation. + virtual bool setMD2Animation(EMD2_ANIMATION_TYPE anim); + + //! Starts a special MD2 animation. + virtual bool setMD2Animation(const c8* animationName); + + //! Returns the current displayed frame number. + virtual s32 getFrameNr(); + //! Returns the current start frame number. + virtual s32 getStartFrame(); + //! Returns the current end frame number. + virtual s32 getEndFrame(); + + //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. + /* In this way it is possible to change the materials a mesh causing all mesh scene nodes + referencing this mesh to change too. */ + virtual void setReadOnlyMaterials(bool readonly); + + //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style + virtual bool isReadOnlyMaterials(); + + //! Sets a new mesh + virtual void setMesh(IAnimatedMesh* mesh); + + //! Returns the current mesh + virtual IAnimatedMesh* getMesh(void) { return Mesh; } + + //! Writes attributes of the scene node. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_ANIMATED_MESH; } + + // returns the absolute transformation for a special MD3 Tag if the mesh is a md3 mesh, + // or the absolutetransformation if it's a normal scenenode + const SMD3QuaterionTag& getAbsoluteTransformation( const core::stringc & tagname); + + //! updates the absolute position based on the relative and the parents position + virtual void updateAbsolutePosition(); + + private: + + u32 buildFrameNr( u32 timeMs); + + core::array Materials; + core::aabbox3d Box; + IAnimatedMesh* Mesh; + + u32 BeginFrameTime; + s32 StartFrame; + s32 EndFrame; + f32 FramesPerSecond; + + u32 CurrentFrameNr; + + bool Looping; + bool ReadOnlyMaterials; + + IAnimationEndCallBack* LoopCallBack; + s32 PassCount; + + IShadowVolumeSceneNode* Shadow; + + core::array JointChildSceneNodes; + + struct SMD3Special + { + core::stringc Tagname; + SMD3QuaterionTagList AbsoluteTagList; + }; + SMD3Special MD3Special; + + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CAttributeImpl.h b/src/dep/src/irrlicht/CAttributeImpl.h index 592ffd3..5f83e5e 100644 --- a/src/dep/src/irrlicht/CAttributeImpl.h +++ b/src/dep/src/irrlicht/CAttributeImpl.h @@ -1,1937 +1,1937 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CAttributes.h" -#include "fast_atof.h" -#include "ITexture.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace io -{ - -/* - basic types -*/ - -// Attribute implemented for boolean values -class CBoolAttribute : public IAttribute -{ -public: - - CBoolAttribute(const char* name, bool value) - { - Name = name; - setBool(value); - } - - virtual s32 getInt() - { - return BoolValue ? 1 : 0; - } - - virtual f32 getFloat() - { - return BoolValue ? 1.0f : 0.0f; - } - - virtual bool getBool() - { - return BoolValue; - } - - virtual core::stringw getStringW() - { - return core::stringw( BoolValue ? L"true" : L"false" ); - } - - virtual void setInt(s32 intValue) - { - BoolValue = (intValue != 0); - } - - virtual void setFloat(f32 floatValue) - { - BoolValue = (floatValue != 0); - } - - virtual void setBool(bool boolValue) - { - BoolValue = boolValue; - } - - virtual void setString(const char* string) - { - BoolValue = strcmp(string, "true") == 0; - } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_BOOL; - } - - virtual const wchar_t* getTypeString() - { - return L"bool"; - } - - bool BoolValue; -}; - -// Attribute implemented for integers -class CIntAttribute : public IAttribute -{ -public: - - CIntAttribute(const char* name, s32 value) - { - Name = name; - setInt(value); - } - - virtual s32 getInt() - { - return Value; - } - - virtual f32 getFloat() - { - return (f32)Value; - } - - virtual bool getBool() - { - return (Value != 0); - } - - virtual core::stringw getStringW() - { - return core::stringw(Value); - } - - virtual void setInt(s32 intValue) - { - Value = intValue; - } - - virtual void setFloat(f32 floatValue) - { - Value = (s32)floatValue; - }; - - virtual void setString(const char* text) - { - Value = atoi(text); - } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_INT; - } - - - virtual const wchar_t* getTypeString() - { - return L"int"; - } - - s32 Value; -}; - -// Attribute implemented for floats -class CFloatAttribute : public IAttribute -{ -public: - - CFloatAttribute(const char* name, f32 value) - { - Name = name; - setFloat(value); - } - - virtual s32 getInt() - { - return (s32)Value; - } - - virtual f32 getFloat() - { - return Value; - } - - virtual bool getBool() - { - return (Value != 0); - } - - virtual core::stringw getStringW() - { - return core::stringw(Value); - } - - virtual void setInt(s32 intValue) - { - Value = (f32)intValue; - } - - virtual void setFloat(f32 floatValue) - { - Value = floatValue; - } - - virtual void setString(const char* text) - { - Value = core::fast_atof(text); - } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_FLOAT; - } - - - virtual const wchar_t* getTypeString() - { - return L"float"; - } - - f32 Value; -}; - - - -/* - Types which can be represented as a list of numbers -*/ - -// Base class for all attributes which are a list of numbers- -// vectors, colors, positions, triangles, etc -class CNumbersAttribute : public IAttribute -{ -public: - - CNumbersAttribute(const char* name, video::SColorf value) : - ValueI(), ValueF(), Count(4), IsFloat(true) - { - Name = name; - ValueF.push_back(value.r); - ValueF.push_back(value.g); - ValueF.push_back(value.b); - ValueF.push_back(value.a); - } - - CNumbersAttribute(const char* name, video::SColor value) : - ValueI(), ValueF(), Count(4), IsFloat(false) - { - Name = name; - ValueI.push_back(value.getRed()); - ValueI.push_back(value.getGreen()); - ValueI.push_back(value.getBlue()); - ValueI.push_back(value.getAlpha()); - } - - - CNumbersAttribute(const char* name, core::vector3df value) : - ValueI(), ValueF(), Count(3), IsFloat(true) - { - Name = name; - ValueF.push_back(value.X); - ValueF.push_back(value.Y); - ValueF.push_back(value.Z); - } - - CNumbersAttribute(const char* name, core::position2df value) : - ValueI(), ValueF(), Count(2), IsFloat(true) - { - Name = name; - ValueF.push_back(value.X); - ValueF.push_back(value.Y); - } - - CNumbersAttribute(const char* name, core::position2di value) : - ValueI(), ValueF(), Count(2), IsFloat(false) - { - Name = name; - ValueI.push_back(value.X); - ValueI.push_back(value.Y); - } - - CNumbersAttribute(const char* name, core::rect value) : - ValueI(), ValueF(), Count(4), IsFloat(false) - { - Name = name; - ValueI.push_back(value.UpperLeftCorner.X); - ValueI.push_back(value.UpperLeftCorner.Y); - ValueI.push_back(value.LowerRightCorner.X); - ValueI.push_back(value.LowerRightCorner.Y); - } - - CNumbersAttribute(const char* name, core::rect value) : - ValueI(), ValueF(), Count(4), IsFloat(true) - { - Name = name; - ValueF.push_back(value.UpperLeftCorner.X); - ValueF.push_back(value.UpperLeftCorner.Y); - ValueF.push_back(value.LowerRightCorner.X); - ValueF.push_back(value.LowerRightCorner.Y); - } - - CNumbersAttribute(const char* name, core::matrix4 value) : - ValueI(), ValueF(), Count(16), IsFloat(true) - { - Name = name; - for (s32 r=0; r<4; ++r) - for (s32 c=0; c<4; ++c) - ValueF.push_back(value(r,c)); - } - - CNumbersAttribute(const char* name, core::quaternion value) : - ValueI(), ValueF(), Count(4), IsFloat(true) - { - Name = name; - ValueF.push_back(value.X); - ValueF.push_back(value.Y); - ValueF.push_back(value.Z); - ValueF.push_back(value.W); - } - - CNumbersAttribute(const char* name, core::aabbox3d value) : - ValueI(), ValueF(), Count(6), IsFloat(true) - { - Name = name; - ValueF.push_back(value.MinEdge.X); - ValueF.push_back(value.MinEdge.Y); - ValueF.push_back(value.MinEdge.Z); - ValueF.push_back(value.MaxEdge.X); - ValueF.push_back(value.MaxEdge.Y); - ValueF.push_back(value.MaxEdge.Z); - } - - CNumbersAttribute(const char* name, core::plane3df value) : - ValueI(), ValueF(), Count(4), IsFloat(true) - { - Name = name; - ValueF.push_back(value.Normal.X); - ValueF.push_back(value.Normal.Y); - ValueF.push_back(value.Normal.Z); - ValueF.push_back(value.D); - } - - CNumbersAttribute(const char* name, core::triangle3df value) : - ValueI(), ValueF(), Count(9), IsFloat(true) - { - Name = name; - ValueF.push_back(value.pointA.X); - ValueF.push_back(value.pointA.Y); - ValueF.push_back(value.pointA.Z); - ValueF.push_back(value.pointB.X); - ValueF.push_back(value.pointB.Y); - ValueF.push_back(value.pointB.Z); - ValueF.push_back(value.pointC.X); - ValueF.push_back(value.pointC.Y); - ValueF.push_back(value.pointC.Z); - } - - CNumbersAttribute(const char* name, core::vector2df value) : - ValueI(), ValueF(), Count(2), IsFloat(true) - { - Name = name; - ValueF.push_back(value.X); - ValueF.push_back(value.Y); - } - - CNumbersAttribute(const char* name, core::vector2di value) : - ValueI(), ValueF(), Count(2), IsFloat(false) - { - Name = name; - ValueI.push_back(value.X); - ValueI.push_back(value.Y); - } - - CNumbersAttribute(const char* name, core::line2di value) : - ValueI(), ValueF(), Count(4), IsFloat(false) - { - Name = name; - ValueI.push_back(value.start.X); - ValueI.push_back(value.start.Y); - ValueI.push_back(value.end.X); - ValueI.push_back(value.end.Y); - } - - CNumbersAttribute(const char* name, core::line2df value) : - ValueI(), ValueF(), Count(4), IsFloat(true) - { - Name = name; - ValueF.push_back(value.start.X); - ValueF.push_back(value.start.Y); - ValueF.push_back(value.end.X); - ValueF.push_back(value.end.Y); - } - - CNumbersAttribute(const char* name, core::line3df value) : - ValueI(), ValueF(), Count(6), IsFloat(true) - { - Name = name; - ValueF.push_back(value.start.X); - ValueF.push_back(value.start.Y); - ValueF.push_back(value.start.Z); - ValueF.push_back(value.end.X); - ValueF.push_back(value.end.Y); - ValueF.push_back(value.end.Z); - } - - CNumbersAttribute(const char* name, core::dimension2di value) : - ValueI(), ValueF(), Count(2), IsFloat(false) - { - Name = name; - ValueI.push_back(value.Width); - ValueI.push_back(value.Height); - } - - - CNumbersAttribute(const char* name, core::dimension2df value) : - ValueI(), ValueF(), Count(2), IsFloat(true) - { - Name = name; - ValueF.push_back(value.Width); - ValueF.push_back(value.Height); - } - - - - // getting values - virtual s32 getInt() - { - if (Count==0) - return 0; - - if (IsFloat) - return (s32)ValueF[0]; - else - return ValueI[0]; - } - - virtual f32 getFloat() - { - if (Count==0) - return 0.0f; - - if (IsFloat) - return ValueF[0]; - else - return (f32)ValueI[0]; - } - - virtual bool getBool() - { - // return true if any number is nonzero - bool ret=false; - - for (u32 i=0; i < Count; ++i) - if ( IsFloat ? (ValueF[i] != 0) : (ValueI[i] != 0) ) - { - ret=true; - break; - } - - return ret; - - } - - - virtual core::stringc getString() - { - core::stringc outstr; - - for (u32 i=0; i 0 ? ValueF[0] : 0); - p.Y = (s32)(Count > 1 ? ValueF[1] : 0); - } - else - { - p.X = Count > 0 ? ValueI[0] : 0; - p.Y = Count > 1 ? ValueI[1] : 0; - } - - return p; - } - - virtual core::vector3df getVector() - { - core::vector3df v; - - if (IsFloat) - { - v.X = Count > 0 ? ValueF[0] : 0; - v.Y = Count > 1 ? ValueF[1] : 0; - v.Z = Count > 2 ? ValueF[2] : 0; - } - else - { - v.X = (f32)(Count > 0 ? ValueI[0] : 0); - v.Y = (f32)(Count > 1 ? ValueI[1] : 0); - v.Z = (f32)(Count > 2 ? ValueI[2] : 0); - } - - return v; - } - - virtual video::SColorf getColorf() - { - video::SColorf c; - if (IsFloat) - { - c.setColorComponentValue(0, Count > 0 ? ValueF[0] : 0); - c.setColorComponentValue(1, Count > 1 ? ValueF[1] : 0); - c.setColorComponentValue(2, Count > 2 ? ValueF[2] : 0); - c.setColorComponentValue(3, Count > 3 ? ValueF[3] : 0); - } - else - { - c.setColorComponentValue(0, Count > 0 ? (f32)(ValueI[0]) / 255.0f : 0); - c.setColorComponentValue(1, Count > 1 ? (f32)(ValueI[1]) / 255.0f : 0); - c.setColorComponentValue(2, Count > 2 ? (f32)(ValueI[2]) / 255.0f : 0); - c.setColorComponentValue(3, Count > 3 ? (f32)(ValueI[3]) / 255.0f : 0); - } - - return c; - } - - virtual video::SColor getColor() - { - return getColorf().toSColor(); - } - - - virtual core::rect getRect() - { - core::rect r; - - if (IsFloat) - { - r.UpperLeftCorner.X = (s32)(Count > 0 ? ValueF[0] : 0); - r.UpperLeftCorner.Y = (s32)(Count > 1 ? ValueF[1] : 0); - r.LowerRightCorner.X = (s32)(Count > 2 ? ValueF[2] : r.UpperLeftCorner.X); - r.LowerRightCorner.Y = (s32)(Count > 3 ? ValueF[3] : r.UpperLeftCorner.Y); - } - else - { - r.UpperLeftCorner.X = Count > 0 ? ValueI[0] : 0; - r.UpperLeftCorner.Y = Count > 1 ? ValueI[1] : 0; - r.LowerRightCorner.X = Count > 2 ? ValueI[2] : r.UpperLeftCorner.X; - r.LowerRightCorner.Y = Count > 3 ? ValueI[3] : r.UpperLeftCorner.Y; - } - return r; - } - - virtual core::matrix4 getMatrix() - { - core::matrix4 ret; - if (IsFloat) - { - for (u32 r=0; r<4; ++r) - for (u32 c=0; c<4; ++c) - if (Count > c+r*4) - ret(r,c) = ValueF[c+r*4]; - } - else - { - for (u32 r=0; r<4; ++r) - for (u32 c=0; c<4; ++c) - if (Count > c+r*4) - ret(r,c) = (f32)ValueI[c+r*4]; - } - return ret; - } - - virtual core::quaternion getQuaternion() - { - core::quaternion ret; - if (IsFloat) - { - ret.X = Count > 0 ? ValueF[0] : 0.0f; - ret.Y = Count > 1 ? ValueF[1] : 0.0f; - ret.Z = Count > 2 ? ValueF[2] : 0.0f; - ret.W = Count > 3 ? ValueF[3] : 0.0f; - } - else - { - ret.X = Count > 0 ? (f32)ValueI[0] : 0.0f; - ret.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; - ret.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; - ret.W = Count > 3 ? (f32)ValueI[3] : 0.0f; - } - return ret; - } - - virtual core::triangle3df getTriangle() - { - core::triangle3df ret; - - if (IsFloat) - { - ret.pointA.X = Count > 0 ? ValueF[0] : 0.0f; - ret.pointA.Y = Count > 1 ? ValueF[1] : 0.0f; - ret.pointA.Z = Count > 2 ? ValueF[2] : 0.0f; - ret.pointB.X = Count > 3 ? ValueF[3] : 0.0f; - ret.pointB.Y = Count > 4 ? ValueF[4] : 0.0f; - ret.pointB.Z = Count > 5 ? ValueF[5] : 0.0f; - ret.pointC.X = Count > 6 ? ValueF[6] : 0.0f; - ret.pointC.X = Count > 7 ? ValueF[7] : 0.0f; - ret.pointC.Z = Count > 8 ? ValueF[8] : 0.0f; - } - else - { - ret.pointA.X = Count > 0 ? (f32)ValueI[0] : 0.0f; - ret.pointA.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; - ret.pointA.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; - ret.pointB.X = Count > 3 ? (f32)ValueI[3] : 0.0f; - ret.pointB.Y = Count > 4 ? (f32)ValueI[4] : 0.0f; - ret.pointB.Z = Count > 5 ? (f32)ValueI[5] : 0.0f; - ret.pointC.X = Count > 6 ? (f32)ValueI[6] : 0.0f; - ret.pointC.X = Count > 7 ? (f32)ValueI[7] : 0.0f; - ret.pointC.Z = Count > 8 ? (f32)ValueI[8] : 0.0f; - } - - return ret; - } - - virtual core::plane3df getPlane() - { - core::plane3df ret; - - if (IsFloat) - { - ret.Normal.X = Count > 0 ? ValueF[0] : 0.0f; - ret.Normal.Y = Count > 1 ? ValueF[1] : 0.0f; - ret.Normal.Z = Count > 2 ? ValueF[2] : 0.0f; - ret.D = Count > 3 ? ValueF[3] : 0.0f; - } - else - { - ret.Normal.X = Count > 0 ? (f32)ValueI[0] : 0.0f; - ret.Normal.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; - ret.Normal.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; - ret.D = Count > 3 ? (f32)ValueI[3] : 0.0f; - } - - return ret; - } - - virtual core::aabbox3df getBBox() - { - core::aabbox3df ret; - if (IsFloat) - { - ret.MinEdge.X = Count > 0 ? ValueF[0] : 0.0f; - ret.MinEdge.Y = Count > 1 ? ValueF[1] : 0.0f; - ret.MinEdge.Z = Count > 2 ? ValueF[2] : 0.0f; - ret.MaxEdge.X = Count > 3 ? ValueF[3] : 0.0f; - ret.MaxEdge.Y = Count > 4 ? ValueF[4] : 0.0f; - ret.MaxEdge.Z = Count > 5 ? ValueF[5] : 0.0f; - } - else - { - ret.MinEdge.X = Count > 0 ? (f32)ValueI[0] : 0.0f; - ret.MinEdge.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; - ret.MinEdge.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; - ret.MaxEdge.X = Count > 3 ? (f32)ValueI[3] : 0.0f; - ret.MaxEdge.Y = Count > 4 ? (f32)ValueI[4] : 0.0f; - ret.MaxEdge.Z = Count > 5 ? (f32)ValueI[5] : 0.0f; - } - return ret; - - } - - virtual core::line2df getLine2d() - { - core::line2df ret; - if (IsFloat) - { - ret.start.X = Count > 0 ? ValueF[0] : 0.0f; - ret.start.Y = Count > 1 ? ValueF[1] : 0.0f; - ret.end.X = Count > 2 ? ValueF[2] : 0.0f; - ret.end.Y = Count > 3 ? ValueF[3] : 0.0f; - } - else - { - ret.start.X = Count > 0 ? (f32)ValueI[0] : 0.0f; - ret.start.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; - ret.end.X = Count > 2 ? (f32)ValueI[2] : 0.0f; - ret.end.Y = Count > 3 ? (f32)ValueI[3] : 0.0f; - } - return ret; - } - - virtual core::line3df getLine3d() - { - core::line3df ret; - if (IsFloat) - { - ret.start.X = Count > 0 ? ValueF[0] : 0.0f; - ret.start.Y = Count > 1 ? ValueF[1] : 0.0f; - ret.start.Z = Count > 2 ? ValueF[2] : 0.0f; - ret.end.X = Count > 3 ? ValueF[3] : 0.0f; - ret.end.Y = Count > 4 ? ValueF[4] : 0.0f; - ret.end.Z = Count > 5 ? ValueF[5] : 0.0f; - } - else - { - ret.start.X = Count > 0 ? (f32)ValueI[0] : 0.0f; - ret.start.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; - ret.start.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; - ret.end.X = Count > 3 ? (f32)ValueI[3] : 0.0f; - ret.end.Y = Count > 4 ? (f32)ValueI[4] : 0.0f; - ret.end.Z = Count > 5 ? (f32)ValueI[5] : 0.0f; - } - return ret; - } - - //! get float array - virtual core::array getFloatArray() - { - if (!IsFloat) - { - ValueF.clear(); - for (u32 i=0; i getIntArray() - { - if (IsFloat) - { - ValueI.clear(); - for (u32 i=0; i '9') ) ) - ++P; - - // set value - if ( *P) - { - if (IsFloat) - { - f32 c = 0; - P = core::fast_atof_move(P, c); - ValueF[i] = c; - } - else - { - // todo: fix this to read ints properly - f32 c = 0; - P = core::fast_atof_move(P, c); - ValueI[i] = (s32)c; - - } - } - } - // todo: warning message - //if (i < Count-1) - //{ - // - //} - } - - virtual void setPosition(core::position2di v) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = (f32)v.X; - if (Count > 1) ValueF[1] = (f32)v.Y; - } - else - { - if (Count > 0) ValueI[0] = v.X; - if (Count > 1) ValueI[1] = v.Y; - } - } - - virtual void setVector(core::vector3df v) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = v.X; - if (Count > 1) ValueF[1] = v.Y; - if (Count > 2) ValueF[2] = v.Z; - } - else - { - if (Count > 0) ValueI[0] = (s32)v.X; - if (Count > 1) ValueI[1] = (s32)v.Y; - if (Count > 2) ValueI[2] = (s32)v.Z; - } - } - - virtual void setColor(video::SColorf color) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = color.r; - if (Count > 1) ValueF[1] = color.g; - if (Count > 2) ValueF[2] = color.b; - if (Count > 3) ValueF[3] = color.a; - } - else - { - if (Count > 0) ValueI[0] = (s32)(color.r * 255); - if (Count > 1) ValueI[1] = (s32)(color.g * 255); - if (Count > 2) ValueI[2] = (s32)(color.b * 255); - if (Count > 3) ValueI[3] = (s32)(color.a * 255); - } - - } - - virtual void setColor(video::SColor color) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = (f32)color.getRed() / 255.0f; - if (Count > 1) ValueF[1] = (f32)color.getGreen() / 255.0f; - if (Count > 2) ValueF[2] = (f32)color.getBlue() / 255.0f; - if (Count > 3) ValueF[3] = (f32)color.getAlpha() / 255.0f; - } - else - { - if (Count > 0) ValueI[0] = color.getRed(); - if (Count > 1) ValueI[1] = color.getGreen(); - if (Count > 2) ValueI[2] = color.getBlue(); - if (Count > 3) ValueI[3] = color.getAlpha(); - } - } - - virtual void setRect(core::rect value) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = (f32)value.UpperLeftCorner.X; - if (Count > 1) ValueF[1] = (f32)value.UpperLeftCorner.Y; - if (Count > 2) ValueF[2] = (f32)value.LowerRightCorner.X; - if (Count > 3) ValueF[3] = (f32)value.LowerRightCorner.Y; - } - else - { - if (Count > 0) ValueI[0] = value.UpperLeftCorner.X; - if (Count > 1) ValueI[1] = value.UpperLeftCorner.Y; - if (Count > 2) ValueI[2] = value.LowerRightCorner.X; - if (Count > 3) ValueI[3] = value.LowerRightCorner.Y; - } - } - - virtual void setMatrix(core::matrix4 value) - { - reset(); - if (IsFloat) - { - for (u32 r=0; r<4; ++r) - for (u32 c=0; c<4; ++c) - if (Count > c+r*4) - ValueF[c+r*4] = value(r,c); - } - else - { - for (u32 r=0; r<4; ++r) - for (u32 c=0; c<4; ++c) - if (Count > c+r*4) - ValueI[c+r*4] = (s32)value(r,c); - } - } - - virtual void setQuaternion(core::quaternion value) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = value.X; - if (Count > 1) ValueF[1] = value.Y; - if (Count > 2) ValueF[2] = value.Z; - if (Count > 3) ValueF[3] = value.W; - } - else - { - if (Count > 0) ValueI[0] = (s32)value.X; - if (Count > 1) ValueI[1] = (s32)value.Y; - if (Count > 2) ValueI[2] = (s32)value.Z; - if (Count > 3) ValueI[3] = (s32)value.W; - } - } - - virtual void setBoundingBox(core::aabbox3d value) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = value.MinEdge.X; - if (Count > 1) ValueF[1] = value.MinEdge.Y; - if (Count > 2) ValueF[2] = value.MinEdge.Z; - if (Count > 3) ValueF[3] = value.MaxEdge.X; - if (Count > 4) ValueF[4] = value.MaxEdge.Y; - if (Count > 5) ValueF[5] = value.MaxEdge.Z; - } - else - { - if (Count > 0) ValueI[0] = (s32)value.MinEdge.X; - if (Count > 1) ValueI[1] = (s32)value.MinEdge.Y; - if (Count > 2) ValueI[2] = (s32)value.MinEdge.Z; - if (Count > 3) ValueI[3] = (s32)value.MaxEdge.X; - if (Count > 4) ValueI[4] = (s32)value.MaxEdge.Y; - if (Count > 5) ValueI[5] = (s32)value.MaxEdge.Z; - } - } - - virtual void setPlane(core::plane3df value) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = value.Normal.X; - if (Count > 1) ValueF[1] = value.Normal.Y; - if (Count > 2) ValueF[2] = value.Normal.Z; - if (Count > 3) ValueF[3] = value.D; - } - else - { - if (Count > 0) ValueI[0] = (s32)value.Normal.X; - if (Count > 1) ValueI[1] = (s32)value.Normal.Y; - if (Count > 2) ValueI[2] = (s32)value.Normal.Z; - if (Count > 3) ValueI[3] = (s32)value.D; - } - } - - virtual void setTriangle3d(core::triangle3df value) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = value.pointA.X; - if (Count > 1) ValueF[1] = value.pointA.Y; - if (Count > 2) ValueF[2] = value.pointA.Z; - if (Count > 3) ValueF[3] = value.pointB.X; - if (Count > 4) ValueF[4] = value.pointB.Y; - if (Count > 5) ValueF[5] = value.pointB.Z; - if (Count > 6) ValueF[6] = value.pointC.X; - if (Count > 7) ValueF[7] = value.pointC.Y; - if (Count > 8) ValueF[8] = value.pointC.Z; - } - else - { - if (Count > 0) ValueI[0] = (s32)value.pointA.X; - if (Count > 1) ValueI[1] = (s32)value.pointA.Y; - if (Count > 2) ValueI[2] = (s32)value.pointA.Z; - if (Count > 3) ValueI[3] = (s32)value.pointB.X; - if (Count > 4) ValueI[4] = (s32)value.pointB.Y; - if (Count > 5) ValueI[5] = (s32)value.pointB.Z; - if (Count > 6) ValueI[6] = (s32)value.pointC.X; - if (Count > 7) ValueI[7] = (s32)value.pointC.Y; - if (Count > 8) ValueI[8] = (s32)value.pointC.Z; - } - } - - virtual void setVector2d(core::vector2df v) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = v.X; - if (Count > 1) ValueF[1] = v.Y; - } - else - { - if (Count > 0) ValueI[0] = (s32)v.X; - if (Count > 1) ValueI[1] = (s32)v.Y; - } - } - - virtual void setVector2d(core::vector2di v) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = (f32)v.X; - if (Count > 1) ValueF[1] = (f32)v.Y; - } - else - { - if (Count > 0) ValueI[0] = v.X; - if (Count > 1) ValueI[1] = v.Y; - } - } - - virtual void setLine2d(core::line2di v) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = (f32)v.start.X; - if (Count > 1) ValueF[1] = (f32)v.start.Y; - if (Count > 2) ValueF[2] = (f32)v.end.X; - if (Count > 3) ValueF[3] = (f32)v.end.Y; - } - else - { - if (Count > 0) ValueI[0] = v.start.X; - if (Count > 1) ValueI[1] = v.start.Y; - if (Count > 2) ValueI[2] = v.end.X; - if (Count > 3) ValueI[3] = v.end.Y; - } - } - - virtual void setLine2d(core::line2df v) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = v.start.X; - if (Count > 1) ValueF[1] = v.start.Y; - if (Count > 2) ValueF[2] = v.end.X; - if (Count > 3) ValueF[3] = v.end.Y; - } - else - { - if (Count > 0) ValueI[0] = (s32)v.start.X; - if (Count > 1) ValueI[1] = (s32)v.start.Y; - if (Count > 2) ValueI[2] = (s32)v.end.X; - if (Count > 3) ValueI[3] = (s32)v.end.Y; - } - } - - virtual void setDimension2d(core::dimension2di v) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = (f32)v.Width; - if (Count > 1) ValueF[1] = (f32)v.Height; - } - else - { - if (Count > 0) ValueI[0] = v.Width; - if (Count > 1) ValueI[1] = v.Height; - } - } - - //! set float array - virtual void setFloatArray(core::array &vals) - { - reset(); - - for (u32 i=0; i &vals) - { - reset(); - - for (u32 i=0; i ValueI; - core::array ValueF; - u32 Count; - bool IsFloat; -}; - - -// Attribute implemented for floating point colors -class CColorfAttribute : public CNumbersAttribute -{ -public: - - CColorfAttribute(const char* name, video::SColorf value) : CNumbersAttribute(name, value) {} - - virtual s32 getInt() - { - return getColor().color; - } - - virtual f32 getFloat() - { - return (f32)getColor().color; - } - - virtual void setInt(s32 intValue) - { - video::SColorf c = video::SColor(intValue); - ValueF[0] = c.r; - ValueF[1] = c.g; - ValueF[2] = c.b; - ValueF[3] = c.a; - } - - virtual void setFloat(f32 floatValue) - { - setInt((s32)floatValue); - } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_COLORF; - } - - - virtual const wchar_t* getTypeString() - { - return L"colorf"; - } -}; - - - -// Attribute implemented for colors -class CColorAttribute : public CNumbersAttribute -{ -public: - - CColorAttribute(const char* name, video::SColorf value) : CNumbersAttribute(name, value) {} - - virtual s32 getInt() - { - return getColor().color; - } - - virtual f32 getFloat() - { - return (f32)getColor().color; - } - - virtual void setInt(s32 intValue) - { - video::SColorf c = video::SColor(intValue); - ValueF[0] = c.r; - ValueF[1] = c.g; - ValueF[2] = c.b; - ValueF[3] = c.a; - } - - virtual void setFloat(f32 floatValue) - { - setInt((s32)floatValue); - } - - virtual core::stringw getStringW() - { - char tmp[10]; - video::SColor c = getColor(); - sprintf(tmp, "%08x", c.color); - return core::stringw(tmp); - } - - virtual void setString(const char* text) - { - video::SColor c; - sscanf(text, "%08x", &c.color); - setColor(c); - } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_COLOR; - } - - - virtual const wchar_t* getTypeString() - { - return L"color"; - } - -}; - - -// Attribute implemented for 3d vectors -class CVector3DAttribute : public CNumbersAttribute -{ -public: - - CVector3DAttribute(const char* name, core::vector3df value) : CNumbersAttribute(name, value) {} - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_VECTOR3D; - } - - virtual core::matrix4 getMatrix() - { - core::matrix4 ret; - ret.makeIdentity(); - ret.setTranslation( core::vector3df(ValueF[0],ValueF[1],ValueF[2]) ); - return ret; - } - - virtual const wchar_t* getTypeString() - { - return L"vector3d"; - } -}; - -// Attribute implemented for 2d vectors -class CPosition2DAttribute : public CNumbersAttribute -{ -public: - - CPosition2DAttribute(const char* name, core::position2di value) : CNumbersAttribute(name, value) {} - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_POSITION2D; - } - - virtual const wchar_t* getTypeString() - { - return L"position"; - } -}; - - - -// Attribute implemented for rectangles -class CRectAttribute : public CNumbersAttribute -{ -public: - - CRectAttribute(const char* name, core::rect value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_RECT; - } - - virtual const wchar_t* getTypeString() - { - return L"rect"; - } -}; - -// Attribute implemented for matrices -class CMatrixAttribute : public CNumbersAttribute -{ -public: - - CMatrixAttribute(const char* name, core::matrix4 value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_MATRIX; - } - - virtual core::quaternion getQuaternion() - { - return core::quaternion(getMatrix()); - } - - virtual const wchar_t* getTypeString() - { - return L"matrix"; - } -}; - -// Attribute implemented for quaternions -class CQuaternionAttribute : public CNumbersAttribute -{ -public: - - CQuaternionAttribute(const char* name, core::quaternion value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_QUATERNION; - } - - virtual core::matrix4 getMatrix() - { - return getQuaternion().getMatrix(); - } - - virtual const wchar_t* getTypeString() - { - return L"quaternion"; - } -}; - - -// Attribute implemented for bounding boxes -class CBBoxAttribute : public CNumbersAttribute -{ -public: - - CBBoxAttribute(const char* name, core::aabbox3df value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_BBOX; - } - - virtual const wchar_t* getTypeString() - { - return L"box3d"; - } -}; - -// Attribute implemented for planes -class CPlaneAttribute : public CNumbersAttribute -{ -public: - - CPlaneAttribute(const char* name, core::plane3df value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_PLANE; - } - - virtual const wchar_t* getTypeString() - { - return L"plane"; - } -}; - -// Attribute implemented for triangles -class CTriangleAttribute : public CNumbersAttribute -{ -public: - - CTriangleAttribute(const char* name, core::triangle3df value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_TRIANGLE3D; - } - - virtual core::plane3df getPlane() - { - return getTriangle().getPlane(); - } - - virtual const wchar_t* getTypeString() - { - return L"triangle"; - } -}; - - -// Attribute implemented for 2d lines -class CLine2dAttribute : public CNumbersAttribute -{ -public: - - CLine2dAttribute(const char* name, core::line2df value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_LINE2D; - } - - virtual const wchar_t* getTypeString() - { - return L"line2d"; - } -}; - -// Attribute implemented for 3d lines -class CLine3dAttribute : public CNumbersAttribute -{ -public: - - CLine3dAttribute(const char* name, core::line3df value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_LINE3D; - } - - virtual const wchar_t* getTypeString() - { - return L"line3d"; - } -}; - - -// vector2df -// dimension2di - -/* - Special attributes -*/ - -// Attribute implemented for enumeration literals -class CEnumAttribute : public IAttribute -{ -public: - - CEnumAttribute(const char* name, const char* value, const char* const* literals) - { - Name = name; - setEnum(value, literals); - } - - virtual void setEnum(const char* enumValue, const char* const* enumerationLiterals) - { - int literalCount = 0; - - if (enumerationLiterals) - { - s32 i; - for (i=0; enumerationLiterals[i]; ++i) - ++literalCount; - - EnumLiterals.reallocate(literalCount); - for (i=0; enumerationLiterals[i]; ++i) - EnumLiterals.push_back(enumerationLiterals[i]); - } - - setString(enumValue); - } - - virtual s32 getInt() - { - for (s32 i=0; EnumLiterals.size(); ++i) - if (Value.equals_ignore_case(EnumLiterals[i])) - { - return i; - } - - return -1; - } - - virtual f32 getFloat() - { - return (f32)getInt(); - } - - virtual bool getBool() - { - return (getInt() != 0); // does not make a lot of sense, I know - } - - virtual core::stringc getString() - { - return Value; - } - - virtual core::stringw getStringW() - { - return core::stringw(Value.c_str()); - } - - virtual void setInt(s32 intValue) - { - if (intValue>=0 && intValue<(s32)EnumLiterals.size()) - Value = EnumLiterals[intValue]; - else - Value = ""; - } - - virtual void setFloat(f32 floatValue) - { - setInt((s32)floatValue); - }; - - virtual void setString(const char* text) - { - Value = text; - } - - virtual const char* getEnum() - { - return Value.c_str(); - } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_ENUM; - } - - - virtual const wchar_t* getTypeString() - { - return L"enum"; - } - - core::stringc Value; - core::array EnumLiterals; -}; - - - - - -// Attribute implemented for strings -class CStringAttribute : public IAttribute -{ -public: - - CStringAttribute(const char* name, const char* value) - { - IsStringW=false; - Name = name; - setString(value); - } - - CStringAttribute(const char* name, const wchar_t* value) - { - IsStringW = true; - Name = name; - setString(value); - } - - CStringAttribute(const char* name, void* binaryData, s32 lenghtInBytes) - { - IsStringW=false; - Name = name; - setBinary(binaryData, lenghtInBytes); - } - - virtual s32 getInt() - { - if (IsStringW) - return atoi(core::stringc(ValueW.c_str()).c_str()); - else - return atoi(Value.c_str()); - } - - virtual f32 getFloat() - { - if (IsStringW) - return core::fast_atof(core::stringc(ValueW.c_str()).c_str()); - else - return core::fast_atof(Value.c_str()); - } - - virtual bool getBool() - { - if (IsStringW) - return Value.equals_ignore_case(L"true"); - else - return Value.equals_ignore_case("true"); - } - - virtual core::stringc getString() - { - if (IsStringW) - return core::stringc(ValueW.c_str()); - else - return Value; - } - virtual core::stringw getStringW() - { - if (IsStringW) - return ValueW; - else - return core::stringw(Value.c_str()); - } - - virtual void setInt(s32 intValue) - { - if (IsStringW) - ValueW = core::stringw(intValue); - else - Value = core::stringc(intValue); - } - - virtual void setFloat(f32 floatValue) - { - if (IsStringW) - { - ValueW = core::stringw(floatValue); - } - else - { - Value = core::stringc(floatValue); - } - }; - - virtual void setString(const char* text) - { - if (IsStringW) - ValueW = core::stringw(text); - else - Value = text; - } - - virtual void setString(const wchar_t* text) - { - if (IsStringW) - ValueW = text; - else - Value = core::stringc(text); - } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_STRING; - } - - - virtual const wchar_t* getTypeString() - { - return L"string"; - } - - virtual void getBinary(void* outdata, s32 maxLenght) - { - s32 dataSize = maxLenght; - c8* datac8 = (c8*)(outdata); - s32 p = 0; - const c8* dataString = Value.c_str(); - - for (s32 i=0; i= '0' && h <='9') - return h-'0'; - - if (h >= 'a' && h <='f') - return h-'a' + 10; - - return 0; - } - - static inline void getHexStrFromByte(c8 byte, c8* out) - { - s32 b = (byte & 0xf0) >> 4; - - for (s32 i=0; i<2; ++i) - { - if (b >=0 && b <= 9) - out[i] = b+'0'; - if (b >=10 && b <= 15) - out[i] = (b-10)+'a'; - - b = byte & 0x0f; - } - } -}; - -// Attribute implemented for binary data -class CBinaryAttribute : public CStringAttribute -{ -public: - - CBinaryAttribute(const char* name, void* binaryData, s32 lenghtInBytes) - : CStringAttribute(name, binaryData, lenghtInBytes) - { - - } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_BINARY; - } - - - virtual const wchar_t* getTypeString() - { - return L"binary"; - } -}; - - - -// Attribute implemented for texture references -class CTextureAttribute : public IAttribute -{ -public: - - CTextureAttribute(const char* name, video::ITexture* value, video::IVideoDriver* driver) - : Value(0), Driver(driver) - { - if (Driver) - Driver->grab(); - - Name = name; - setTexture(value); - } - - ~CTextureAttribute() - { - if (Driver) - Driver->drop(); - - if (Value) - Value->drop(); - } - - virtual video::ITexture* getTexture() - { - return Value; - } - - virtual bool getBool() - { - return (Value != 0); - } - - virtual core::stringw getStringW() - { - return core::stringw(Value ? Value->getName().c_str() : 0); - } - - virtual core::stringc getString() - { - return Value ? Value->getName() : core::stringc(); - } - - virtual void getString(char* target) - { - if (Value) - strcpy(target, Value->getName().c_str()); - else - target[0] = 0x0; - } - - virtual void setString(const char* text) - { - if (Driver) - { - if (text && *text) - setTexture(Driver->getTexture(text)); - else - setTexture(0); - } - } - - virtual void setTexture(video::ITexture* value) - { - if (Value) - Value->drop(); - - Value = value; - - if (Value) - Value->grab(); - } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_TEXTURE; - } - - - virtual const wchar_t* getTypeString() - { - return L"texture"; - } - - video::ITexture* Value; - video::IVideoDriver* Driver; -}; - - - -// Attribute implemented for array of stringw -class CStringWArrayAttribute : public IAttribute -{ -public: - - CStringWArrayAttribute(const char* name, core::array value) - { - Name = name; - setArray(value); - } - - virtual core::array getArray() - { - return Value; - } - - virtual void setArray(core::array value) - { - Value = value; - } - - virtual E_ATTRIBUTE_TYPE getType() - { - return EAT_STRINGWARRAY; - } - - virtual const wchar_t* getTypeString() - { - return L"stringwarray"; - } - - core::array Value; -}; - - - - -// todo: CGUIFontAttribute - -} // end namespace io -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CAttributes.h" +#include "fast_atof.h" +#include "ITexture.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace io +{ + +/* + basic types +*/ + +// Attribute implemented for boolean values +class CBoolAttribute : public IAttribute +{ +public: + + CBoolAttribute(const char* name, bool value) + { + Name = name; + setBool(value); + } + + virtual s32 getInt() + { + return BoolValue ? 1 : 0; + } + + virtual f32 getFloat() + { + return BoolValue ? 1.0f : 0.0f; + } + + virtual bool getBool() + { + return BoolValue; + } + + virtual core::stringw getStringW() + { + return core::stringw( BoolValue ? L"true" : L"false" ); + } + + virtual void setInt(s32 intValue) + { + BoolValue = (intValue != 0); + } + + virtual void setFloat(f32 floatValue) + { + BoolValue = (floatValue != 0); + } + + virtual void setBool(bool boolValue) + { + BoolValue = boolValue; + } + + virtual void setString(const char* string) + { + BoolValue = strcmp(string, "true") == 0; + } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_BOOL; + } + + virtual const wchar_t* getTypeString() + { + return L"bool"; + } + + bool BoolValue; +}; + +// Attribute implemented for integers +class CIntAttribute : public IAttribute +{ +public: + + CIntAttribute(const char* name, s32 value) + { + Name = name; + setInt(value); + } + + virtual s32 getInt() + { + return Value; + } + + virtual f32 getFloat() + { + return (f32)Value; + } + + virtual bool getBool() + { + return (Value != 0); + } + + virtual core::stringw getStringW() + { + return core::stringw(Value); + } + + virtual void setInt(s32 intValue) + { + Value = intValue; + } + + virtual void setFloat(f32 floatValue) + { + Value = (s32)floatValue; + }; + + virtual void setString(const char* text) + { + Value = atoi(text); + } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_INT; + } + + + virtual const wchar_t* getTypeString() + { + return L"int"; + } + + s32 Value; +}; + +// Attribute implemented for floats +class CFloatAttribute : public IAttribute +{ +public: + + CFloatAttribute(const char* name, f32 value) + { + Name = name; + setFloat(value); + } + + virtual s32 getInt() + { + return (s32)Value; + } + + virtual f32 getFloat() + { + return Value; + } + + virtual bool getBool() + { + return (Value != 0); + } + + virtual core::stringw getStringW() + { + return core::stringw(Value); + } + + virtual void setInt(s32 intValue) + { + Value = (f32)intValue; + } + + virtual void setFloat(f32 floatValue) + { + Value = floatValue; + } + + virtual void setString(const char* text) + { + Value = core::fast_atof(text); + } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_FLOAT; + } + + + virtual const wchar_t* getTypeString() + { + return L"float"; + } + + f32 Value; +}; + + + +/* + Types which can be represented as a list of numbers +*/ + +// Base class for all attributes which are a list of numbers- +// vectors, colors, positions, triangles, etc +class CNumbersAttribute : public IAttribute +{ +public: + + CNumbersAttribute(const char* name, video::SColorf value) : + ValueI(), ValueF(), Count(4), IsFloat(true) + { + Name = name; + ValueF.push_back(value.r); + ValueF.push_back(value.g); + ValueF.push_back(value.b); + ValueF.push_back(value.a); + } + + CNumbersAttribute(const char* name, video::SColor value) : + ValueI(), ValueF(), Count(4), IsFloat(false) + { + Name = name; + ValueI.push_back(value.getRed()); + ValueI.push_back(value.getGreen()); + ValueI.push_back(value.getBlue()); + ValueI.push_back(value.getAlpha()); + } + + + CNumbersAttribute(const char* name, core::vector3df value) : + ValueI(), ValueF(), Count(3), IsFloat(true) + { + Name = name; + ValueF.push_back(value.X); + ValueF.push_back(value.Y); + ValueF.push_back(value.Z); + } + + CNumbersAttribute(const char* name, core::position2df value) : + ValueI(), ValueF(), Count(2), IsFloat(true) + { + Name = name; + ValueF.push_back(value.X); + ValueF.push_back(value.Y); + } + + CNumbersAttribute(const char* name, core::position2di value) : + ValueI(), ValueF(), Count(2), IsFloat(false) + { + Name = name; + ValueI.push_back(value.X); + ValueI.push_back(value.Y); + } + + CNumbersAttribute(const char* name, core::rect value) : + ValueI(), ValueF(), Count(4), IsFloat(false) + { + Name = name; + ValueI.push_back(value.UpperLeftCorner.X); + ValueI.push_back(value.UpperLeftCorner.Y); + ValueI.push_back(value.LowerRightCorner.X); + ValueI.push_back(value.LowerRightCorner.Y); + } + + CNumbersAttribute(const char* name, core::rect value) : + ValueI(), ValueF(), Count(4), IsFloat(true) + { + Name = name; + ValueF.push_back(value.UpperLeftCorner.X); + ValueF.push_back(value.UpperLeftCorner.Y); + ValueF.push_back(value.LowerRightCorner.X); + ValueF.push_back(value.LowerRightCorner.Y); + } + + CNumbersAttribute(const char* name, core::matrix4 value) : + ValueI(), ValueF(), Count(16), IsFloat(true) + { + Name = name; + for (s32 r=0; r<4; ++r) + for (s32 c=0; c<4; ++c) + ValueF.push_back(value(r,c)); + } + + CNumbersAttribute(const char* name, core::quaternion value) : + ValueI(), ValueF(), Count(4), IsFloat(true) + { + Name = name; + ValueF.push_back(value.X); + ValueF.push_back(value.Y); + ValueF.push_back(value.Z); + ValueF.push_back(value.W); + } + + CNumbersAttribute(const char* name, core::aabbox3d value) : + ValueI(), ValueF(), Count(6), IsFloat(true) + { + Name = name; + ValueF.push_back(value.MinEdge.X); + ValueF.push_back(value.MinEdge.Y); + ValueF.push_back(value.MinEdge.Z); + ValueF.push_back(value.MaxEdge.X); + ValueF.push_back(value.MaxEdge.Y); + ValueF.push_back(value.MaxEdge.Z); + } + + CNumbersAttribute(const char* name, core::plane3df value) : + ValueI(), ValueF(), Count(4), IsFloat(true) + { + Name = name; + ValueF.push_back(value.Normal.X); + ValueF.push_back(value.Normal.Y); + ValueF.push_back(value.Normal.Z); + ValueF.push_back(value.D); + } + + CNumbersAttribute(const char* name, core::triangle3df value) : + ValueI(), ValueF(), Count(9), IsFloat(true) + { + Name = name; + ValueF.push_back(value.pointA.X); + ValueF.push_back(value.pointA.Y); + ValueF.push_back(value.pointA.Z); + ValueF.push_back(value.pointB.X); + ValueF.push_back(value.pointB.Y); + ValueF.push_back(value.pointB.Z); + ValueF.push_back(value.pointC.X); + ValueF.push_back(value.pointC.Y); + ValueF.push_back(value.pointC.Z); + } + + CNumbersAttribute(const char* name, core::vector2df value) : + ValueI(), ValueF(), Count(2), IsFloat(true) + { + Name = name; + ValueF.push_back(value.X); + ValueF.push_back(value.Y); + } + + CNumbersAttribute(const char* name, core::vector2di value) : + ValueI(), ValueF(), Count(2), IsFloat(false) + { + Name = name; + ValueI.push_back(value.X); + ValueI.push_back(value.Y); + } + + CNumbersAttribute(const char* name, core::line2di value) : + ValueI(), ValueF(), Count(4), IsFloat(false) + { + Name = name; + ValueI.push_back(value.start.X); + ValueI.push_back(value.start.Y); + ValueI.push_back(value.end.X); + ValueI.push_back(value.end.Y); + } + + CNumbersAttribute(const char* name, core::line2df value) : + ValueI(), ValueF(), Count(4), IsFloat(true) + { + Name = name; + ValueF.push_back(value.start.X); + ValueF.push_back(value.start.Y); + ValueF.push_back(value.end.X); + ValueF.push_back(value.end.Y); + } + + CNumbersAttribute(const char* name, core::line3df value) : + ValueI(), ValueF(), Count(6), IsFloat(true) + { + Name = name; + ValueF.push_back(value.start.X); + ValueF.push_back(value.start.Y); + ValueF.push_back(value.start.Z); + ValueF.push_back(value.end.X); + ValueF.push_back(value.end.Y); + ValueF.push_back(value.end.Z); + } + + CNumbersAttribute(const char* name, core::dimension2di value) : + ValueI(), ValueF(), Count(2), IsFloat(false) + { + Name = name; + ValueI.push_back(value.Width); + ValueI.push_back(value.Height); + } + + + CNumbersAttribute(const char* name, core::dimension2df value) : + ValueI(), ValueF(), Count(2), IsFloat(true) + { + Name = name; + ValueF.push_back(value.Width); + ValueF.push_back(value.Height); + } + + + + // getting values + virtual s32 getInt() + { + if (Count==0) + return 0; + + if (IsFloat) + return (s32)ValueF[0]; + else + return ValueI[0]; + } + + virtual f32 getFloat() + { + if (Count==0) + return 0.0f; + + if (IsFloat) + return ValueF[0]; + else + return (f32)ValueI[0]; + } + + virtual bool getBool() + { + // return true if any number is nonzero + bool ret=false; + + for (u32 i=0; i < Count; ++i) + if ( IsFloat ? (ValueF[i] != 0) : (ValueI[i] != 0) ) + { + ret=true; + break; + } + + return ret; + + } + + + virtual core::stringc getString() + { + core::stringc outstr; + + for (u32 i=0; i 0 ? ValueF[0] : 0); + p.Y = (s32)(Count > 1 ? ValueF[1] : 0); + } + else + { + p.X = Count > 0 ? ValueI[0] : 0; + p.Y = Count > 1 ? ValueI[1] : 0; + } + + return p; + } + + virtual core::vector3df getVector() + { + core::vector3df v; + + if (IsFloat) + { + v.X = Count > 0 ? ValueF[0] : 0; + v.Y = Count > 1 ? ValueF[1] : 0; + v.Z = Count > 2 ? ValueF[2] : 0; + } + else + { + v.X = (f32)(Count > 0 ? ValueI[0] : 0); + v.Y = (f32)(Count > 1 ? ValueI[1] : 0); + v.Z = (f32)(Count > 2 ? ValueI[2] : 0); + } + + return v; + } + + virtual video::SColorf getColorf() + { + video::SColorf c; + if (IsFloat) + { + c.setColorComponentValue(0, Count > 0 ? ValueF[0] : 0); + c.setColorComponentValue(1, Count > 1 ? ValueF[1] : 0); + c.setColorComponentValue(2, Count > 2 ? ValueF[2] : 0); + c.setColorComponentValue(3, Count > 3 ? ValueF[3] : 0); + } + else + { + c.setColorComponentValue(0, Count > 0 ? (f32)(ValueI[0]) / 255.0f : 0); + c.setColorComponentValue(1, Count > 1 ? (f32)(ValueI[1]) / 255.0f : 0); + c.setColorComponentValue(2, Count > 2 ? (f32)(ValueI[2]) / 255.0f : 0); + c.setColorComponentValue(3, Count > 3 ? (f32)(ValueI[3]) / 255.0f : 0); + } + + return c; + } + + virtual video::SColor getColor() + { + return getColorf().toSColor(); + } + + + virtual core::rect getRect() + { + core::rect r; + + if (IsFloat) + { + r.UpperLeftCorner.X = (s32)(Count > 0 ? ValueF[0] : 0); + r.UpperLeftCorner.Y = (s32)(Count > 1 ? ValueF[1] : 0); + r.LowerRightCorner.X = (s32)(Count > 2 ? ValueF[2] : r.UpperLeftCorner.X); + r.LowerRightCorner.Y = (s32)(Count > 3 ? ValueF[3] : r.UpperLeftCorner.Y); + } + else + { + r.UpperLeftCorner.X = Count > 0 ? ValueI[0] : 0; + r.UpperLeftCorner.Y = Count > 1 ? ValueI[1] : 0; + r.LowerRightCorner.X = Count > 2 ? ValueI[2] : r.UpperLeftCorner.X; + r.LowerRightCorner.Y = Count > 3 ? ValueI[3] : r.UpperLeftCorner.Y; + } + return r; + } + + virtual core::matrix4 getMatrix() + { + core::matrix4 ret; + if (IsFloat) + { + for (u32 r=0; r<4; ++r) + for (u32 c=0; c<4; ++c) + if (Count > c+r*4) + ret(r,c) = ValueF[c+r*4]; + } + else + { + for (u32 r=0; r<4; ++r) + for (u32 c=0; c<4; ++c) + if (Count > c+r*4) + ret(r,c) = (f32)ValueI[c+r*4]; + } + return ret; + } + + virtual core::quaternion getQuaternion() + { + core::quaternion ret; + if (IsFloat) + { + ret.X = Count > 0 ? ValueF[0] : 0.0f; + ret.Y = Count > 1 ? ValueF[1] : 0.0f; + ret.Z = Count > 2 ? ValueF[2] : 0.0f; + ret.W = Count > 3 ? ValueF[3] : 0.0f; + } + else + { + ret.X = Count > 0 ? (f32)ValueI[0] : 0.0f; + ret.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; + ret.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; + ret.W = Count > 3 ? (f32)ValueI[3] : 0.0f; + } + return ret; + } + + virtual core::triangle3df getTriangle() + { + core::triangle3df ret; + + if (IsFloat) + { + ret.pointA.X = Count > 0 ? ValueF[0] : 0.0f; + ret.pointA.Y = Count > 1 ? ValueF[1] : 0.0f; + ret.pointA.Z = Count > 2 ? ValueF[2] : 0.0f; + ret.pointB.X = Count > 3 ? ValueF[3] : 0.0f; + ret.pointB.Y = Count > 4 ? ValueF[4] : 0.0f; + ret.pointB.Z = Count > 5 ? ValueF[5] : 0.0f; + ret.pointC.X = Count > 6 ? ValueF[6] : 0.0f; + ret.pointC.X = Count > 7 ? ValueF[7] : 0.0f; + ret.pointC.Z = Count > 8 ? ValueF[8] : 0.0f; + } + else + { + ret.pointA.X = Count > 0 ? (f32)ValueI[0] : 0.0f; + ret.pointA.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; + ret.pointA.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; + ret.pointB.X = Count > 3 ? (f32)ValueI[3] : 0.0f; + ret.pointB.Y = Count > 4 ? (f32)ValueI[4] : 0.0f; + ret.pointB.Z = Count > 5 ? (f32)ValueI[5] : 0.0f; + ret.pointC.X = Count > 6 ? (f32)ValueI[6] : 0.0f; + ret.pointC.X = Count > 7 ? (f32)ValueI[7] : 0.0f; + ret.pointC.Z = Count > 8 ? (f32)ValueI[8] : 0.0f; + } + + return ret; + } + + virtual core::plane3df getPlane() + { + core::plane3df ret; + + if (IsFloat) + { + ret.Normal.X = Count > 0 ? ValueF[0] : 0.0f; + ret.Normal.Y = Count > 1 ? ValueF[1] : 0.0f; + ret.Normal.Z = Count > 2 ? ValueF[2] : 0.0f; + ret.D = Count > 3 ? ValueF[3] : 0.0f; + } + else + { + ret.Normal.X = Count > 0 ? (f32)ValueI[0] : 0.0f; + ret.Normal.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; + ret.Normal.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; + ret.D = Count > 3 ? (f32)ValueI[3] : 0.0f; + } + + return ret; + } + + virtual core::aabbox3df getBBox() + { + core::aabbox3df ret; + if (IsFloat) + { + ret.MinEdge.X = Count > 0 ? ValueF[0] : 0.0f; + ret.MinEdge.Y = Count > 1 ? ValueF[1] : 0.0f; + ret.MinEdge.Z = Count > 2 ? ValueF[2] : 0.0f; + ret.MaxEdge.X = Count > 3 ? ValueF[3] : 0.0f; + ret.MaxEdge.Y = Count > 4 ? ValueF[4] : 0.0f; + ret.MaxEdge.Z = Count > 5 ? ValueF[5] : 0.0f; + } + else + { + ret.MinEdge.X = Count > 0 ? (f32)ValueI[0] : 0.0f; + ret.MinEdge.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; + ret.MinEdge.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; + ret.MaxEdge.X = Count > 3 ? (f32)ValueI[3] : 0.0f; + ret.MaxEdge.Y = Count > 4 ? (f32)ValueI[4] : 0.0f; + ret.MaxEdge.Z = Count > 5 ? (f32)ValueI[5] : 0.0f; + } + return ret; + + } + + virtual core::line2df getLine2d() + { + core::line2df ret; + if (IsFloat) + { + ret.start.X = Count > 0 ? ValueF[0] : 0.0f; + ret.start.Y = Count > 1 ? ValueF[1] : 0.0f; + ret.end.X = Count > 2 ? ValueF[2] : 0.0f; + ret.end.Y = Count > 3 ? ValueF[3] : 0.0f; + } + else + { + ret.start.X = Count > 0 ? (f32)ValueI[0] : 0.0f; + ret.start.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; + ret.end.X = Count > 2 ? (f32)ValueI[2] : 0.0f; + ret.end.Y = Count > 3 ? (f32)ValueI[3] : 0.0f; + } + return ret; + } + + virtual core::line3df getLine3d() + { + core::line3df ret; + if (IsFloat) + { + ret.start.X = Count > 0 ? ValueF[0] : 0.0f; + ret.start.Y = Count > 1 ? ValueF[1] : 0.0f; + ret.start.Z = Count > 2 ? ValueF[2] : 0.0f; + ret.end.X = Count > 3 ? ValueF[3] : 0.0f; + ret.end.Y = Count > 4 ? ValueF[4] : 0.0f; + ret.end.Z = Count > 5 ? ValueF[5] : 0.0f; + } + else + { + ret.start.X = Count > 0 ? (f32)ValueI[0] : 0.0f; + ret.start.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; + ret.start.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; + ret.end.X = Count > 3 ? (f32)ValueI[3] : 0.0f; + ret.end.Y = Count > 4 ? (f32)ValueI[4] : 0.0f; + ret.end.Z = Count > 5 ? (f32)ValueI[5] : 0.0f; + } + return ret; + } + + //! get float array + virtual core::array getFloatArray() + { + if (!IsFloat) + { + ValueF.clear(); + for (u32 i=0; i getIntArray() + { + if (IsFloat) + { + ValueI.clear(); + for (u32 i=0; i '9') ) ) + ++P; + + // set value + if ( *P) + { + if (IsFloat) + { + f32 c = 0; + P = core::fast_atof_move(P, c); + ValueF[i] = c; + } + else + { + // todo: fix this to read ints properly + f32 c = 0; + P = core::fast_atof_move(P, c); + ValueI[i] = (s32)c; + + } + } + } + // todo: warning message + //if (i < Count-1) + //{ + // + //} + } + + virtual void setPosition(core::position2di v) + { + reset(); + if (IsFloat) + { + if (Count > 0) ValueF[0] = (f32)v.X; + if (Count > 1) ValueF[1] = (f32)v.Y; + } + else + { + if (Count > 0) ValueI[0] = v.X; + if (Count > 1) ValueI[1] = v.Y; + } + } + + virtual void setVector(core::vector3df v) + { + reset(); + if (IsFloat) + { + if (Count > 0) ValueF[0] = v.X; + if (Count > 1) ValueF[1] = v.Y; + if (Count > 2) ValueF[2] = v.Z; + } + else + { + if (Count > 0) ValueI[0] = (s32)v.X; + if (Count > 1) ValueI[1] = (s32)v.Y; + if (Count > 2) ValueI[2] = (s32)v.Z; + } + } + + virtual void setColor(video::SColorf color) + { + reset(); + if (IsFloat) + { + if (Count > 0) ValueF[0] = color.r; + if (Count > 1) ValueF[1] = color.g; + if (Count > 2) ValueF[2] = color.b; + if (Count > 3) ValueF[3] = color.a; + } + else + { + if (Count > 0) ValueI[0] = (s32)(color.r * 255); + if (Count > 1) ValueI[1] = (s32)(color.g * 255); + if (Count > 2) ValueI[2] = (s32)(color.b * 255); + if (Count > 3) ValueI[3] = (s32)(color.a * 255); + } + + } + + virtual void setColor(video::SColor color) + { + reset(); + if (IsFloat) + { + if (Count > 0) ValueF[0] = (f32)color.getRed() / 255.0f; + if (Count > 1) ValueF[1] = (f32)color.getGreen() / 255.0f; + if (Count > 2) ValueF[2] = (f32)color.getBlue() / 255.0f; + if (Count > 3) ValueF[3] = (f32)color.getAlpha() / 255.0f; + } + else + { + if (Count > 0) ValueI[0] = color.getRed(); + if (Count > 1) ValueI[1] = color.getGreen(); + if (Count > 2) ValueI[2] = color.getBlue(); + if (Count > 3) ValueI[3] = color.getAlpha(); + } + } + + virtual void setRect(core::rect value) + { + reset(); + if (IsFloat) + { + if (Count > 0) ValueF[0] = (f32)value.UpperLeftCorner.X; + if (Count > 1) ValueF[1] = (f32)value.UpperLeftCorner.Y; + if (Count > 2) ValueF[2] = (f32)value.LowerRightCorner.X; + if (Count > 3) ValueF[3] = (f32)value.LowerRightCorner.Y; + } + else + { + if (Count > 0) ValueI[0] = value.UpperLeftCorner.X; + if (Count > 1) ValueI[1] = value.UpperLeftCorner.Y; + if (Count > 2) ValueI[2] = value.LowerRightCorner.X; + if (Count > 3) ValueI[3] = value.LowerRightCorner.Y; + } + } + + virtual void setMatrix(core::matrix4 value) + { + reset(); + if (IsFloat) + { + for (u32 r=0; r<4; ++r) + for (u32 c=0; c<4; ++c) + if (Count > c+r*4) + ValueF[c+r*4] = value(r,c); + } + else + { + for (u32 r=0; r<4; ++r) + for (u32 c=0; c<4; ++c) + if (Count > c+r*4) + ValueI[c+r*4] = (s32)value(r,c); + } + } + + virtual void setQuaternion(core::quaternion value) + { + reset(); + if (IsFloat) + { + if (Count > 0) ValueF[0] = value.X; + if (Count > 1) ValueF[1] = value.Y; + if (Count > 2) ValueF[2] = value.Z; + if (Count > 3) ValueF[3] = value.W; + } + else + { + if (Count > 0) ValueI[0] = (s32)value.X; + if (Count > 1) ValueI[1] = (s32)value.Y; + if (Count > 2) ValueI[2] = (s32)value.Z; + if (Count > 3) ValueI[3] = (s32)value.W; + } + } + + virtual void setBoundingBox(core::aabbox3d value) + { + reset(); + if (IsFloat) + { + if (Count > 0) ValueF[0] = value.MinEdge.X; + if (Count > 1) ValueF[1] = value.MinEdge.Y; + if (Count > 2) ValueF[2] = value.MinEdge.Z; + if (Count > 3) ValueF[3] = value.MaxEdge.X; + if (Count > 4) ValueF[4] = value.MaxEdge.Y; + if (Count > 5) ValueF[5] = value.MaxEdge.Z; + } + else + { + if (Count > 0) ValueI[0] = (s32)value.MinEdge.X; + if (Count > 1) ValueI[1] = (s32)value.MinEdge.Y; + if (Count > 2) ValueI[2] = (s32)value.MinEdge.Z; + if (Count > 3) ValueI[3] = (s32)value.MaxEdge.X; + if (Count > 4) ValueI[4] = (s32)value.MaxEdge.Y; + if (Count > 5) ValueI[5] = (s32)value.MaxEdge.Z; + } + } + + virtual void setPlane(core::plane3df value) + { + reset(); + if (IsFloat) + { + if (Count > 0) ValueF[0] = value.Normal.X; + if (Count > 1) ValueF[1] = value.Normal.Y; + if (Count > 2) ValueF[2] = value.Normal.Z; + if (Count > 3) ValueF[3] = value.D; + } + else + { + if (Count > 0) ValueI[0] = (s32)value.Normal.X; + if (Count > 1) ValueI[1] = (s32)value.Normal.Y; + if (Count > 2) ValueI[2] = (s32)value.Normal.Z; + if (Count > 3) ValueI[3] = (s32)value.D; + } + } + + virtual void setTriangle3d(core::triangle3df value) + { + reset(); + if (IsFloat) + { + if (Count > 0) ValueF[0] = value.pointA.X; + if (Count > 1) ValueF[1] = value.pointA.Y; + if (Count > 2) ValueF[2] = value.pointA.Z; + if (Count > 3) ValueF[3] = value.pointB.X; + if (Count > 4) ValueF[4] = value.pointB.Y; + if (Count > 5) ValueF[5] = value.pointB.Z; + if (Count > 6) ValueF[6] = value.pointC.X; + if (Count > 7) ValueF[7] = value.pointC.Y; + if (Count > 8) ValueF[8] = value.pointC.Z; + } + else + { + if (Count > 0) ValueI[0] = (s32)value.pointA.X; + if (Count > 1) ValueI[1] = (s32)value.pointA.Y; + if (Count > 2) ValueI[2] = (s32)value.pointA.Z; + if (Count > 3) ValueI[3] = (s32)value.pointB.X; + if (Count > 4) ValueI[4] = (s32)value.pointB.Y; + if (Count > 5) ValueI[5] = (s32)value.pointB.Z; + if (Count > 6) ValueI[6] = (s32)value.pointC.X; + if (Count > 7) ValueI[7] = (s32)value.pointC.Y; + if (Count > 8) ValueI[8] = (s32)value.pointC.Z; + } + } + + virtual void setVector2d(core::vector2df v) + { + reset(); + if (IsFloat) + { + if (Count > 0) ValueF[0] = v.X; + if (Count > 1) ValueF[1] = v.Y; + } + else + { + if (Count > 0) ValueI[0] = (s32)v.X; + if (Count > 1) ValueI[1] = (s32)v.Y; + } + } + + virtual void setVector2d(core::vector2di v) + { + reset(); + if (IsFloat) + { + if (Count > 0) ValueF[0] = (f32)v.X; + if (Count > 1) ValueF[1] = (f32)v.Y; + } + else + { + if (Count > 0) ValueI[0] = v.X; + if (Count > 1) ValueI[1] = v.Y; + } + } + + virtual void setLine2d(core::line2di v) + { + reset(); + if (IsFloat) + { + if (Count > 0) ValueF[0] = (f32)v.start.X; + if (Count > 1) ValueF[1] = (f32)v.start.Y; + if (Count > 2) ValueF[2] = (f32)v.end.X; + if (Count > 3) ValueF[3] = (f32)v.end.Y; + } + else + { + if (Count > 0) ValueI[0] = v.start.X; + if (Count > 1) ValueI[1] = v.start.Y; + if (Count > 2) ValueI[2] = v.end.X; + if (Count > 3) ValueI[3] = v.end.Y; + } + } + + virtual void setLine2d(core::line2df v) + { + reset(); + if (IsFloat) + { + if (Count > 0) ValueF[0] = v.start.X; + if (Count > 1) ValueF[1] = v.start.Y; + if (Count > 2) ValueF[2] = v.end.X; + if (Count > 3) ValueF[3] = v.end.Y; + } + else + { + if (Count > 0) ValueI[0] = (s32)v.start.X; + if (Count > 1) ValueI[1] = (s32)v.start.Y; + if (Count > 2) ValueI[2] = (s32)v.end.X; + if (Count > 3) ValueI[3] = (s32)v.end.Y; + } + } + + virtual void setDimension2d(core::dimension2di v) + { + reset(); + if (IsFloat) + { + if (Count > 0) ValueF[0] = (f32)v.Width; + if (Count > 1) ValueF[1] = (f32)v.Height; + } + else + { + if (Count > 0) ValueI[0] = v.Width; + if (Count > 1) ValueI[1] = v.Height; + } + } + + //! set float array + virtual void setFloatArray(core::array &vals) + { + reset(); + + for (u32 i=0; i &vals) + { + reset(); + + for (u32 i=0; i ValueI; + core::array ValueF; + u32 Count; + bool IsFloat; +}; + + +// Attribute implemented for floating point colors +class CColorfAttribute : public CNumbersAttribute +{ +public: + + CColorfAttribute(const char* name, video::SColorf value) : CNumbersAttribute(name, value) {} + + virtual s32 getInt() + { + return getColor().color; + } + + virtual f32 getFloat() + { + return (f32)getColor().color; + } + + virtual void setInt(s32 intValue) + { + video::SColorf c = video::SColor(intValue); + ValueF[0] = c.r; + ValueF[1] = c.g; + ValueF[2] = c.b; + ValueF[3] = c.a; + } + + virtual void setFloat(f32 floatValue) + { + setInt((s32)floatValue); + } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_COLORF; + } + + + virtual const wchar_t* getTypeString() + { + return L"colorf"; + } +}; + + + +// Attribute implemented for colors +class CColorAttribute : public CNumbersAttribute +{ +public: + + CColorAttribute(const char* name, video::SColorf value) : CNumbersAttribute(name, value) {} + + virtual s32 getInt() + { + return getColor().color; + } + + virtual f32 getFloat() + { + return (f32)getColor().color; + } + + virtual void setInt(s32 intValue) + { + video::SColorf c = video::SColor(intValue); + ValueF[0] = c.r; + ValueF[1] = c.g; + ValueF[2] = c.b; + ValueF[3] = c.a; + } + + virtual void setFloat(f32 floatValue) + { + setInt((s32)floatValue); + } + + virtual core::stringw getStringW() + { + char tmp[10]; + video::SColor c = getColor(); + sprintf(tmp, "%08x", c.color); + return core::stringw(tmp); + } + + virtual void setString(const char* text) + { + video::SColor c; + sscanf(text, "%08x", &c.color); + setColor(c); + } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_COLOR; + } + + + virtual const wchar_t* getTypeString() + { + return L"color"; + } + +}; + + +// Attribute implemented for 3d vectors +class CVector3DAttribute : public CNumbersAttribute +{ +public: + + CVector3DAttribute(const char* name, core::vector3df value) : CNumbersAttribute(name, value) {} + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_VECTOR3D; + } + + virtual core::matrix4 getMatrix() + { + core::matrix4 ret; + ret.makeIdentity(); + ret.setTranslation( core::vector3df(ValueF[0],ValueF[1],ValueF[2]) ); + return ret; + } + + virtual const wchar_t* getTypeString() + { + return L"vector3d"; + } +}; + +// Attribute implemented for 2d vectors +class CPosition2DAttribute : public CNumbersAttribute +{ +public: + + CPosition2DAttribute(const char* name, core::position2di value) : CNumbersAttribute(name, value) {} + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_POSITION2D; + } + + virtual const wchar_t* getTypeString() + { + return L"position"; + } +}; + + + +// Attribute implemented for rectangles +class CRectAttribute : public CNumbersAttribute +{ +public: + + CRectAttribute(const char* name, core::rect value) : CNumbersAttribute(name, value) { } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_RECT; + } + + virtual const wchar_t* getTypeString() + { + return L"rect"; + } +}; + +// Attribute implemented for matrices +class CMatrixAttribute : public CNumbersAttribute +{ +public: + + CMatrixAttribute(const char* name, core::matrix4 value) : CNumbersAttribute(name, value) { } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_MATRIX; + } + + virtual core::quaternion getQuaternion() + { + return core::quaternion(getMatrix()); + } + + virtual const wchar_t* getTypeString() + { + return L"matrix"; + } +}; + +// Attribute implemented for quaternions +class CQuaternionAttribute : public CNumbersAttribute +{ +public: + + CQuaternionAttribute(const char* name, core::quaternion value) : CNumbersAttribute(name, value) { } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_QUATERNION; + } + + virtual core::matrix4 getMatrix() + { + return getQuaternion().getMatrix(); + } + + virtual const wchar_t* getTypeString() + { + return L"quaternion"; + } +}; + + +// Attribute implemented for bounding boxes +class CBBoxAttribute : public CNumbersAttribute +{ +public: + + CBBoxAttribute(const char* name, core::aabbox3df value) : CNumbersAttribute(name, value) { } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_BBOX; + } + + virtual const wchar_t* getTypeString() + { + return L"box3d"; + } +}; + +// Attribute implemented for planes +class CPlaneAttribute : public CNumbersAttribute +{ +public: + + CPlaneAttribute(const char* name, core::plane3df value) : CNumbersAttribute(name, value) { } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_PLANE; + } + + virtual const wchar_t* getTypeString() + { + return L"plane"; + } +}; + +// Attribute implemented for triangles +class CTriangleAttribute : public CNumbersAttribute +{ +public: + + CTriangleAttribute(const char* name, core::triangle3df value) : CNumbersAttribute(name, value) { } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_TRIANGLE3D; + } + + virtual core::plane3df getPlane() + { + return getTriangle().getPlane(); + } + + virtual const wchar_t* getTypeString() + { + return L"triangle"; + } +}; + + +// Attribute implemented for 2d lines +class CLine2dAttribute : public CNumbersAttribute +{ +public: + + CLine2dAttribute(const char* name, core::line2df value) : CNumbersAttribute(name, value) { } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_LINE2D; + } + + virtual const wchar_t* getTypeString() + { + return L"line2d"; + } +}; + +// Attribute implemented for 3d lines +class CLine3dAttribute : public CNumbersAttribute +{ +public: + + CLine3dAttribute(const char* name, core::line3df value) : CNumbersAttribute(name, value) { } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_LINE3D; + } + + virtual const wchar_t* getTypeString() + { + return L"line3d"; + } +}; + + +// vector2df +// dimension2di + +/* + Special attributes +*/ + +// Attribute implemented for enumeration literals +class CEnumAttribute : public IAttribute +{ +public: + + CEnumAttribute(const char* name, const char* value, const char* const* literals) + { + Name = name; + setEnum(value, literals); + } + + virtual void setEnum(const char* enumValue, const char* const* enumerationLiterals) + { + int literalCount = 0; + + if (enumerationLiterals) + { + s32 i; + for (i=0; enumerationLiterals[i]; ++i) + ++literalCount; + + EnumLiterals.reallocate(literalCount); + for (i=0; enumerationLiterals[i]; ++i) + EnumLiterals.push_back(enumerationLiterals[i]); + } + + setString(enumValue); + } + + virtual s32 getInt() + { + for (s32 i=0; EnumLiterals.size(); ++i) + if (Value.equals_ignore_case(EnumLiterals[i])) + { + return i; + } + + return -1; + } + + virtual f32 getFloat() + { + return (f32)getInt(); + } + + virtual bool getBool() + { + return (getInt() != 0); // does not make a lot of sense, I know + } + + virtual core::stringc getString() + { + return Value; + } + + virtual core::stringw getStringW() + { + return core::stringw(Value.c_str()); + } + + virtual void setInt(s32 intValue) + { + if (intValue>=0 && intValue<(s32)EnumLiterals.size()) + Value = EnumLiterals[intValue]; + else + Value = ""; + } + + virtual void setFloat(f32 floatValue) + { + setInt((s32)floatValue); + }; + + virtual void setString(const char* text) + { + Value = text; + } + + virtual const char* getEnum() + { + return Value.c_str(); + } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_ENUM; + } + + + virtual const wchar_t* getTypeString() + { + return L"enum"; + } + + core::stringc Value; + core::array EnumLiterals; +}; + + + + + +// Attribute implemented for strings +class CStringAttribute : public IAttribute +{ +public: + + CStringAttribute(const char* name, const char* value) + { + IsStringW=false; + Name = name; + setString(value); + } + + CStringAttribute(const char* name, const wchar_t* value) + { + IsStringW = true; + Name = name; + setString(value); + } + + CStringAttribute(const char* name, void* binaryData, s32 lenghtInBytes) + { + IsStringW=false; + Name = name; + setBinary(binaryData, lenghtInBytes); + } + + virtual s32 getInt() + { + if (IsStringW) + return atoi(core::stringc(ValueW.c_str()).c_str()); + else + return atoi(Value.c_str()); + } + + virtual f32 getFloat() + { + if (IsStringW) + return core::fast_atof(core::stringc(ValueW.c_str()).c_str()); + else + return core::fast_atof(Value.c_str()); + } + + virtual bool getBool() + { + if (IsStringW) + return Value.equals_ignore_case(L"true"); + else + return Value.equals_ignore_case("true"); + } + + virtual core::stringc getString() + { + if (IsStringW) + return core::stringc(ValueW.c_str()); + else + return Value; + } + virtual core::stringw getStringW() + { + if (IsStringW) + return ValueW; + else + return core::stringw(Value.c_str()); + } + + virtual void setInt(s32 intValue) + { + if (IsStringW) + ValueW = core::stringw(intValue); + else + Value = core::stringc(intValue); + } + + virtual void setFloat(f32 floatValue) + { + if (IsStringW) + { + ValueW = core::stringw(floatValue); + } + else + { + Value = core::stringc(floatValue); + } + }; + + virtual void setString(const char* text) + { + if (IsStringW) + ValueW = core::stringw(text); + else + Value = text; + } + + virtual void setString(const wchar_t* text) + { + if (IsStringW) + ValueW = text; + else + Value = core::stringc(text); + } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_STRING; + } + + + virtual const wchar_t* getTypeString() + { + return L"string"; + } + + virtual void getBinary(void* outdata, s32 maxLenght) + { + s32 dataSize = maxLenght; + c8* datac8 = (c8*)(outdata); + s32 p = 0; + const c8* dataString = Value.c_str(); + + for (s32 i=0; i= '0' && h <='9') + return h-'0'; + + if (h >= 'a' && h <='f') + return h-'a' + 10; + + return 0; + } + + static inline void getHexStrFromByte(c8 byte, c8* out) + { + s32 b = (byte & 0xf0) >> 4; + + for (s32 i=0; i<2; ++i) + { + if (b >=0 && b <= 9) + out[i] = b+'0'; + if (b >=10 && b <= 15) + out[i] = (b-10)+'a'; + + b = byte & 0x0f; + } + } +}; + +// Attribute implemented for binary data +class CBinaryAttribute : public CStringAttribute +{ +public: + + CBinaryAttribute(const char* name, void* binaryData, s32 lenghtInBytes) + : CStringAttribute(name, binaryData, lenghtInBytes) + { + + } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_BINARY; + } + + + virtual const wchar_t* getTypeString() + { + return L"binary"; + } +}; + + + +// Attribute implemented for texture references +class CTextureAttribute : public IAttribute +{ +public: + + CTextureAttribute(const char* name, video::ITexture* value, video::IVideoDriver* driver) + : Value(0), Driver(driver) + { + if (Driver) + Driver->grab(); + + Name = name; + setTexture(value); + } + + ~CTextureAttribute() + { + if (Driver) + Driver->drop(); + + if (Value) + Value->drop(); + } + + virtual video::ITexture* getTexture() + { + return Value; + } + + virtual bool getBool() + { + return (Value != 0); + } + + virtual core::stringw getStringW() + { + return core::stringw(Value ? Value->getName().c_str() : 0); + } + + virtual core::stringc getString() + { + return Value ? Value->getName() : core::stringc(); + } + + virtual void getString(char* target) + { + if (Value) + strcpy(target, Value->getName().c_str()); + else + target[0] = 0x0; + } + + virtual void setString(const char* text) + { + if (Driver) + { + if (text && *text) + setTexture(Driver->getTexture(text)); + else + setTexture(0); + } + } + + virtual void setTexture(video::ITexture* value) + { + if (Value) + Value->drop(); + + Value = value; + + if (Value) + Value->grab(); + } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_TEXTURE; + } + + + virtual const wchar_t* getTypeString() + { + return L"texture"; + } + + video::ITexture* Value; + video::IVideoDriver* Driver; +}; + + + +// Attribute implemented for array of stringw +class CStringWArrayAttribute : public IAttribute +{ +public: + + CStringWArrayAttribute(const char* name, core::array value) + { + Name = name; + setArray(value); + } + + virtual core::array getArray() + { + return Value; + } + + virtual void setArray(core::array value) + { + Value = value; + } + + virtual E_ATTRIBUTE_TYPE getType() + { + return EAT_STRINGWARRAY; + } + + virtual const wchar_t* getTypeString() + { + return L"stringwarray"; + } + + core::array Value; +}; + + + + +// todo: CGUIFontAttribute + +} // end namespace io +} // end namespace irr diff --git a/src/dep/src/irrlicht/CAttributes.cpp b/src/dep/src/irrlicht/CAttributes.cpp index f479095..68b9d31 100644 --- a/src/dep/src/irrlicht/CAttributes.cpp +++ b/src/dep/src/irrlicht/CAttributes.cpp @@ -1,1558 +1,1558 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CAttributes.h" -#include "CAttributeImpl.h" -#include "ITexture.h" -#include "IXMLWriter.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace io -{ - -CAttributes::CAttributes(video::IVideoDriver* driver) -: Driver(driver) -{ - #ifdef _DEBUG - setDebugName("CAttributes"); - #endif - - if (Driver) - Driver->grab(); -} - -CAttributes::~CAttributes() -{ - clear(); - - if (Driver) - Driver->drop(); -} - - -//! Removes all attributes -void CAttributes::clear() -{ - for (int i=0; i<(int)Attributes.size(); ++i) - Attributes[i]->drop(); - - Attributes.clear(); -} - - -//! Sets a string attribute. -//! \param attributeName: Name for the attribute -//! \param value: Value for the attribute. Set this to 0 to delete the attribute -void CAttributes::setAttribute(const c8* attributeName, const c8* value) -{ - for (int i=0; i<(int)Attributes.size(); ++i) - if (Attributes[i]->Name == attributeName) - { - if (!value) - { - Attributes[i]->drop(); - Attributes.erase(i); - } - else - Attributes[i]->setString(value); - - return; - } - - if (value) - { - Attributes.push_back(new CStringAttribute(attributeName, value)); - } -} - -//! Gets a string attribute. -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setStringAttribute() -//! or 0 if attribute is not set. -core::stringc CAttributes::getAttributeAsString(const c8* attributeName) -{ - core::stringc str; - - IAttribute* att = getAttributeP(attributeName); - if (att) - return att->getString(); - else - return str; -} - -//! Gets a string attribute. -//! \param attributeName: Name of the attribute to get. -//! \param target: Buffer where the string is copied to. -void CAttributes::getAttributeAsString(const c8* attributeName, char* target) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - { - core::stringc str = att->getString(); - strcpy(target,str.c_str()); - } - else - target[0] = 0; -} - -//! Returns string attribute value by index. -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -core::stringc CAttributes::getAttributeAsString(s32 index) -{ - core::stringc str; - - if (index >= 0 && index < (int)Attributes.size()) - return Attributes[index]->getString(); - - return str; -} - - -//! Sets a string attribute. -//! \param attributeName: Name for the attribute -//! \param value: Value for the attribute. Set this to 0 to delete the attribute -void CAttributes::setAttribute(const c8* attributeName, const wchar_t* value) -{ - for (int i=0; i<(int)Attributes.size(); ++i) - if (Attributes[i]->Name == attributeName) - { - if (!value) - { - Attributes[i]->drop(); - Attributes.erase(i); - } - else - Attributes[i]->setString(value); - - return; - } - - if (value) - { - Attributes.push_back(new CStringAttribute(attributeName, value)); - } -} - -//! Gets a string attribute. -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setStringAttribute() -//! or 0 if attribute is not set. -core::stringw CAttributes::getAttributeAsStringW(const c8* attributeName) -{ - core::stringw str; - - IAttribute* att = getAttributeP(attributeName); - if (att) - str = att->getStringW(); - - return str; -} - -//! Gets a string attribute. -//! \param attributeName: Name of the attribute to get. -//! \param target: Buffer where the string is copied to. -void CAttributes::getAttributeAsStringW(const c8* attributeName, wchar_t* target) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - { - core::stringw str = att->getStringW(); - wcscpy(target,str.c_str()); - } - else - target[0] = 0; -} - -//! Returns string attribute value by index. -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -core::stringw CAttributes::getAttributeAsStringW(s32 index) -{ - core::stringw str; - - if (index >= 0 && index < (int)Attributes.size()) - { - str = Attributes[index]->getStringW(); - } - - return str; -} - - -//! Adds an attribute as an array of wide strings -void CAttributes::addArray(const c8* attributeName, core::array value) -{ - Attributes.push_back(new CStringWArrayAttribute(attributeName, value)); -} - -//! Sets an attribute value as an array of wide strings. -void CAttributes::setAttribute(const c8* attributeName, const core::array value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setArray(value); - else - { - Attributes.push_back(new CStringWArrayAttribute(attributeName, value)); - } -} - -//! Gets an attribute as an array of wide strings. -core::array CAttributes::getAttributeAsArray(const c8* attributeName) -{ - core::array ret; - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getArray(); - - return ret; -} - -//! Returns attribute value as an array of wide strings by index. -core::array CAttributes::getAttributeAsArray(s32 index) -{ - core::array ret; - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getArray(); - - return ret; -} - -//! Sets an attribute as an array of wide strings -void CAttributes::setAttribute(s32 index, core::array value) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setArray(value); -} - - - - -//! Returns attribute index from name, -1 if not found -s32 CAttributes::findAttribute(const c8* attributeName) -{ - for (int i=0; i<(int)Attributes.size(); ++i) - if (Attributes[i]->Name == attributeName) - return i; - - return -1; -} - - -IAttribute* CAttributes::getAttributeP(const c8* attributeName) -{ - for (int i=0; i<(int)Attributes.size(); ++i) - if (Attributes[i]->Name == attributeName) - return Attributes[i]; - - return 0; -} - - -//! Sets a attribute as boolean value -void CAttributes::setAttribute(const c8* attributeName, bool value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setBool(value); - else - { - Attributes.push_back(new CBoolAttribute(attributeName, value)); - } -} - -//! Gets a attribute as boolean value -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() as bool -//! or 0 if attribute is not set. -bool CAttributes::getAttributeAsBool(const c8* attributeName) -{ - bool ret = false; - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getBool(); - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - -//! Sets a attribute as integer value -void CAttributes::setAttribute(const c8* attributeName, s32 value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setInt(value); - else - { - Attributes.push_back(new CIntAttribute(attributeName, value)); - } -} - -//! Gets a attribute as integer value -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() as integer -//! or 0 if attribute is not set. -s32 CAttributes::getAttributeAsInt(const c8* attributeName) -{ - s32 ret = 0; - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getInt(); - - return ret; -} - -//! Sets a attribute as float value -void CAttributes::setAttribute(const c8* attributeName, f32 value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setFloat(value); - else - { - Attributes.push_back(new CFloatAttribute(attributeName, value)); - } -} - -//! Gets a attribute as integer value -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() as float value -//! or 0 if attribute is not set. -f32 CAttributes::getAttributeAsFloat(const c8* attributeName) -{ - f32 ret = 0; - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getFloat(); - - return ret; -} - -//! Sets a attribute as color -void CAttributes::setAttribute(const c8* attributeName, video::SColor value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setColor(value); - else - { - Attributes.push_back(new CColorAttribute(attributeName, value)); - } -} - -//! Gets an attribute as color -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() -video::SColor CAttributes::getAttributeAsColor(const c8* attributeName) -{ - video::SColor ret(0); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getColor(); - - return ret; -} - -//! Sets a attribute as floating point color -void CAttributes::setAttribute(const c8* attributeName, video::SColorf value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setColor(value); - else - { - Attributes.push_back(new CColorfAttribute(attributeName, value)); - } -} - -//! Gets an attribute as floating point color -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() -video::SColorf CAttributes::getAttributeAsColorf(const c8* attributeName) -{ - video::SColorf ret; - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getColorf(); - - return ret; -} - -//! Sets a attribute as 2d position -void CAttributes::setAttribute(const c8* attributeName, core::position2di value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setPosition(value); - else - { - Attributes.push_back(new CPosition2DAttribute(attributeName, value)); - } -} - -//! Gets an attribute as 2d position -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() -core::position2di CAttributes::getAttributeAsPosition2d(const c8* attributeName) -{ - core::position2di ret; - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getPosition(); - - return ret; -} - -//! Sets a attribute as rectangle -void CAttributes::setAttribute(const c8* attributeName, core::rect value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setRect(value); - else - { - Attributes.push_back(new CRectAttribute(attributeName, value)); - } -} - -//! Gets an attribute as rectangle -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() -core::rect CAttributes::getAttributeAsRect(const c8* attributeName) -{ - core::rect ret; - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getRect(); - - return ret; -} - -//! Sets a attribute as vector -void CAttributes::setAttribute(const c8* attributeName, core::vector3df value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setVector(value); - else - { - Attributes.push_back(new CVector3DAttribute(attributeName, value)); - } -} - -//! Gets an attribute as vector -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() -core::vector3df CAttributes::getAttributeAsVector3d(const c8* attributeName) -{ - core::vector3df ret; - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getVector(); - - return ret; -} - -//! Sets an attribute as binary data -void CAttributes::setAttribute(const c8* attributeName, void* data, s32 dataSizeInBytes ) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setBinary(data, dataSizeInBytes); - else - { - Attributes.push_back(new CBinaryAttribute(attributeName, data, dataSizeInBytes)); - } -} - -//! Gets an attribute as binary data -//! \param attributeName: Name of the attribute to get. -void CAttributes::getAttributeAsBinaryData(const c8* attributeName, void* outData, s32 maxSizeInBytes) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->getBinary(outData, maxSizeInBytes); -} - -//! Sets an attribute as enumeration -void CAttributes::setAttribute(const c8* attributeName, const char* enumValue, const char* const* enumerationLiterals) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setEnum(enumValue, enumerationLiterals); - else - { - Attributes.push_back(new CEnumAttribute(attributeName, enumValue, enumerationLiterals)); - } -} - -//! Gets an attribute as enumeration -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() -const char* CAttributes::getAttributeAsEnumeration(const c8* attributeName) -{ - const char* ret = 0; - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getEnum(); - - return ret; -} - -//! Gets an attribute as enumeration -s32 CAttributes::getAttributeAsEnumeration(const c8* attributeName, const char* const* enumerationLiteralsToUse) -{ - s32 ret = -1; - - IAttribute* att = getAttributeP(attributeName); - - if (enumerationLiteralsToUse && att) - { - const char* value = att->getEnum(); - if (value) - { - for (s32 i=0; enumerationLiteralsToUse[i]; ++i) - if (!strcmp(value, enumerationLiteralsToUse[i])) - return i; - } - } - - return ret; -} - -//! Gets the list of enumeration literals of an enumeration attribute -//! \param attributeName: Name of the attribute to get. -void CAttributes::getAttributeEnumerationLiteralsOfEnumeration(const c8* attributeName, core::array& outLiterals) -{ - IAttribute* att = getAttributeP(attributeName); - - if (att && att->getType() == EAT_ENUM) - outLiterals = ((CEnumAttribute*)att)->EnumLiterals; -} - -//! Sets an attribute as texture reference -void CAttributes::setAttribute(const c8* attributeName, video::ITexture* value ) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setTexture(value); - else - { - Attributes.push_back(new CTextureAttribute(attributeName, value, Driver)); - } -} - - -//! Gets an attribute as texture reference -//! \param attributeName: Name of the attribute to get. -video::ITexture* CAttributes::getAttributeAsTexture(const c8* attributeName) -{ - video::ITexture* tex = 0; - - IAttribute* att = getAttributeP(attributeName); - if (att) - tex = att->getTexture(); - - return tex; -} - -//! Gets an attribute as texture reference -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -video::ITexture* CAttributes::getAttributeAsTexture(s32 index) -{ - video::ITexture* tex = 0; - - if (index >= 0 && index < (s32)Attributes.size()) - tex = Attributes[index]->getTexture(); - - return tex; -} - - -//! Returns amount of string attributes set in this scene manager. -s32 CAttributes::getAttributeCount() -{ - return Attributes.size(); -} - -//! Returns string attribute name by index. -//! \param index: Index value, must be between 0 and getStringAttributeCount()-1. -const c8* CAttributes::getAttributeName(s32 index) -{ - if (index < 0 || index >= (int)Attributes.size()) - return 0; - - return Attributes[index]->Name.c_str(); -} - -//! Returns the type of an attribute -E_ATTRIBUTE_TYPE CAttributes::getAttributeType(const c8* attributeName) -{ - E_ATTRIBUTE_TYPE ret = EAT_UNKNOWN; - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getType(); - - return ret; -} - -//! Returns attribute type by index. -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -E_ATTRIBUTE_TYPE CAttributes::getAttributeType(s32 index) -{ - if (index < 0 || index >= (int)Attributes.size()) - return EAT_UNKNOWN; - - return Attributes[index]->getType(); -} - -//! Returns the type of an attribute -const wchar_t* CAttributes::getAttributeTypeString(const c8* attributeName) -{ - const wchar_t* ret = L"unknown"; - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getTypeString(); - - return ret; -} - -//! Returns attribute type string by index. -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -const wchar_t* CAttributes::getAttributeTypeString(s32 index) -{ - if (index < 0 || index >= (int)Attributes.size()) - return L"unknown"; - - return Attributes[index]->getTypeString(); -} - -//! Gets an attribute as boolean value -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -bool CAttributes::getAttributeAsBool(s32 index) -{ - bool ret = false; - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getBool(); - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - -//! Gets an attribute as integer value -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -s32 CAttributes::getAttributeAsInt(s32 index) -{ - s32 ret = 0; - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getInt(); - - return ret; -} - -//! Gets an attribute as float value -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -f32 CAttributes::getAttributeAsFloat(s32 index) -{ - f32 ret = 0; - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getFloat(); - - return ret; -} - -//! Gets an attribute as color -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -video::SColor CAttributes::getAttributeAsColor(s32 index) -{ - video::SColor ret; - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getColor(); - - return ret; -} - -//! Gets an attribute as floating point color -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -video::SColorf CAttributes::getAttributeAsColorf(s32 index) -{ - video::SColorf ret; - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getColorf(); - - return ret; -} - -//! Gets an attribute as 3d vector -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -core::vector3df CAttributes::getAttributeAsVector3d(s32 index) -{ - core::vector3df ret; - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getVector(); - - return ret; -} - -//! Gets an attribute as rectangle -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -core::position2di CAttributes::getAttributeAsPosition2d(s32 index) -{ - core::position2di ret; - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getPosition(); - - return ret; -} - -//! Gets an attribute as rectangle -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -core::rect CAttributes::getAttributeAsRect(s32 index) -{ - core::rect ret; - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getRect(); - - return ret; -} - - -//! Gets an attribute as binary data -///! \param index: Index value, must be between 0 and getAttributeCount()-1. -void CAttributes::getAttributeAsBinaryData(s32 index, void* outData, s32 maxSizeInBytes) -{ - if (index >= 0 && index < (s32)Attributes.size()) - Attributes[index]->getBinary(outData, maxSizeInBytes); -} - -//! Gets an attribute as enumeration -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -const char* CAttributes::getAttributeAsEnumeration(s32 index) -{ - const char* ret = 0; - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getEnum(); - - return ret; -} - -//! Gets an attribute as enumeration -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -s32 CAttributes::getAttributeAsEnumeration(s32 index, const char* const* enumerationLiteralsToUse) -{ - if (index >= 0 && index < (s32)Attributes.size()) - { - IAttribute* att = Attributes[index]; - - if (enumerationLiteralsToUse && att) - { - const char* value = att->getEnum(); - if (value) - { - for (s32 i=0; enumerationLiteralsToUse[i]; ++i) - if (!strcmp(value, enumerationLiteralsToUse[i])) - return i; - } - } - } - - return -1; -} - -//! Gets the list of enumeration literals of an enumeration attribute -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -void CAttributes::getAttributeEnumerationLiteralsOfEnumeration(s32 index, core::array& outLiterals) -{ - if (index >= 0 && index < (s32)Attributes.size() && Attributes[index]->getType() == EAT_ENUM) - outLiterals = ((CEnumAttribute*)Attributes[index])->EnumLiterals; -} - - -//! Adds an attribute as integer -void CAttributes::addInt(const c8* attributeName, s32 value) -{ - Attributes.push_back(new CIntAttribute(attributeName, value)); -} - -//! Adds an attribute as float -void CAttributes::addFloat(const c8* attributeName, f32 value) -{ - Attributes.push_back(new CFloatAttribute(attributeName, value)); -} - -//! Adds an attribute as string -void CAttributes::addString(const c8* attributeName, const char* value) -{ - Attributes.push_back(new CStringAttribute(attributeName, value)); -} - -//! Adds an attribute as wchar string -void CAttributes::addString(const c8* attributeName, const wchar_t* value) -{ - Attributes.push_back(new CStringAttribute(attributeName, value)); -} - -//! Adds an attribute as bool -void CAttributes::addBool(const c8* attributeName, bool value) -{ - Attributes.push_back(new CBoolAttribute(attributeName, value)); -} - -//! Adds an attribute as enum -void CAttributes::addEnum(const c8* attributeName, const char* enumValue, const char* const* enumerationLiterals) -{ - Attributes.push_back(new CEnumAttribute(attributeName, enumValue, enumerationLiterals)); -} - -//! Adds an attribute as enum -void CAttributes::addEnum(const c8* attributeName, s32 enumValue, const char* const* enumerationLiterals) -{ - addEnum(attributeName, "", enumerationLiterals); - Attributes.getLast()->setInt(enumValue); -} - -//! Adds an attribute as color -void CAttributes::addColor(const c8* attributeName, video::SColor value) -{ - Attributes.push_back(new CColorAttribute(attributeName, value)); -} - -//! Adds an attribute as floating point color -void CAttributes::addColorf(const c8* attributeName, video::SColorf value) -{ - Attributes.push_back(new CColorfAttribute(attributeName, value)); -} - -//! Adds an attribute as 3d vector -void CAttributes::addVector3d(const c8* attributeName, core::vector3df value) -{ - Attributes.push_back(new CVector3DAttribute(attributeName, value)); -} - -//! Adds an attribute as 2d position -void CAttributes::addPosition2d(const c8* attributeName, core::position2di value) -{ - Attributes.push_back(new CPosition2DAttribute(attributeName, value)); -} - -//! Adds an attribute as rectangle -void CAttributes::addRect(const c8* attributeName, core::rect value) -{ - Attributes.push_back(new CRectAttribute(attributeName, value)); -} - -//! Adds an attribute as binary data -void CAttributes::addBinary(const c8* attributeName, void* data, s32 dataSizeInBytes) -{ - Attributes.push_back(new CBinaryAttribute(attributeName, data, dataSizeInBytes)); -} - -//! Adds an attribute as texture reference -void CAttributes::addTexture(const c8* attributeName, video::ITexture* texture) -{ - Attributes.push_back(new CTextureAttribute(attributeName, texture, Driver)); -} - -//! Returns if an attribute with a name exists -bool CAttributes::existsAttribute(const c8* attributeName) -{ - return getAttributeP(attributeName) != 0; -} - -//! Sets an attribute value as string. -//! \param attributeName: Name for the attribute -void CAttributes::setAttribute(s32 index, const c8* value) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setString(value); -} - -//! Sets an attribute value as string. -//! \param attributeName: Name for the attribute -void CAttributes::setAttribute(s32 index, const wchar_t* value) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setString(value); -} - -//! Sets an attribute as boolean value -void CAttributes::setAttribute(s32 index, bool value) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setBool(value); -} - -//! Sets an attribute as integer value -void CAttributes::setAttribute(s32 index, s32 value) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setInt(value); -} - -//! Sets a attribute as float value -void CAttributes::setAttribute(s32 index, f32 value) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setFloat(value); -} - -//! Sets a attribute as color -void CAttributes::setAttribute(s32 index, video::SColor color) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setColor(color); -} - -//! Sets a attribute as floating point color -void CAttributes::setAttribute(s32 index, video::SColorf color) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setColor(color); -} - -//! Sets a attribute as vector -void CAttributes::setAttribute(s32 index, core::vector3df v) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setVector(v); -} - -//! Sets a attribute as position -void CAttributes::setAttribute(s32 index, core::position2di v) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setPosition(v); -} - -//! Sets a attribute as rectangle -void CAttributes::setAttribute(s32 index, core::rect v) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setRect(v); -} - -//! Sets an attribute as binary data -void CAttributes::setAttribute(s32 index, void* data, s32 dataSizeInBytes ) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setBinary(data, dataSizeInBytes); -} - -//! Sets an attribute as enumeration -void CAttributes::setAttribute(s32 index, const char* enumValue, const char* const* enumerationLiterals) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setEnum(enumValue, enumerationLiterals); -} - - -//! Sets an attribute as texture reference -void CAttributes::setAttribute(s32 index, video::ITexture* texture) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setTexture(texture); -} - - - -//! Adds an attribute as matrix -void CAttributes::addMatrix(const c8* attributeName, core::matrix4 v) -{ - Attributes.push_back(new CMatrixAttribute(attributeName, v)); -} - - -//! Sets an attribute as matrix -void CAttributes::setAttribute(const c8* attributeName, core::matrix4 v) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setMatrix(v); - else - { - Attributes.push_back(new CMatrixAttribute(attributeName, v)); - } -} - -//! Gets an attribute as a matrix4 -core::matrix4 CAttributes::getAttributeAsMatrix(const c8* attributeName) -{ - core::matrix4 ret; - ret.makeIdentity(); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getMatrix(); - - return ret; -} - -//! Gets an attribute as matrix -core::matrix4 CAttributes::getAttributeAsMatrix(s32 index) -{ - core::matrix4 ret; - ret.makeIdentity(); - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getMatrix(); - - return ret; -} - -//! Sets an attribute as matrix -void CAttributes::setAttribute(s32 index, core::matrix4 v) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setMatrix(v); -} - - -//! Adds an attribute as quaternion -void CAttributes::addQuaternion(const c8* attributeName, core::quaternion v) -{ - Attributes.push_back(new CQuaternionAttribute(attributeName, v)); -} - - -//! Sets an attribute as quaternion -void CAttributes::setAttribute(const c8* attributeName, core::quaternion v) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setQuaternion(v); - else - { - Attributes.push_back(new CQuaternionAttribute(attributeName, v)); - } -} - -//! Gets an attribute as a quaternion -core::quaternion CAttributes::getAttributeAsQuaternion(const c8* attributeName) -{ - core::quaternion ret(0,1,0, 0); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getQuaternion(); - - return ret; -} - -//! Gets an attribute as quaternion -core::quaternion CAttributes::getAttributeAsQuaternion(s32 index) -{ - core::quaternion ret(0,1,0, 0); - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getQuaternion(); - - return ret; -} - -//! Sets an attribute as quaternion -void CAttributes::setAttribute(s32 index, core::quaternion v) -{ -if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setQuaternion(v); -} - -//! Adds an attribute as axis aligned bounding box -void CAttributes::addBox3d(const c8* attributeName, core::aabbox3df v) -{ - Attributes.push_back(new CBBoxAttribute(attributeName, v)); -} - -//! Sets an attribute as axis aligned bounding box -void CAttributes::setAttribute(const c8* attributeName, core::aabbox3df v) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setBBox(v); - else - { - Attributes.push_back(new CBBoxAttribute(attributeName, v)); - } -} - -//! Gets an attribute as a axis aligned bounding box -core::aabbox3df CAttributes::getAttributeAsBox3d(const c8* attributeName) -{ - core::aabbox3df ret(0,0,0, 0,0,0); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getBBox(); - - return ret; -} - -//! Gets an attribute as axis aligned bounding box -core::aabbox3df CAttributes::getAttributeAsBox3d(s32 index) -{ - core::aabbox3df ret(0,0,0, 0,0,0); - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getBBox(); - - return ret; -} - -//! Sets an attribute as axis aligned bounding box -void CAttributes::setAttribute(s32 index, core::aabbox3df v) -{ -if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setBBox(v); -} - -//! Adds an attribute as 3d plane -void CAttributes::addPlane3d(const c8* attributeName, core::plane3df v) -{ - Attributes.push_back(new CPlaneAttribute(attributeName, v)); -} - -//! Sets an attribute as 3d plane -void CAttributes::setAttribute(const c8* attributeName, core::plane3df v) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setPlane(v); - else - { - Attributes.push_back(new CPlaneAttribute(attributeName, v)); - } -} - -//! Gets an attribute as a 3d plane -core::plane3df CAttributes::getAttributeAsPlane3d(const c8* attributeName) -{ - core::plane3df ret(0,0,0, 0,1,0); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getPlane(); - - return ret; -} - -//! Gets an attribute as 3d plane -core::plane3df CAttributes::getAttributeAsPlane3d(s32 index) -{ - core::plane3df ret(0,0,0, 0,1,0); - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getPlane(); - - return ret; -} - -//! Sets an attribute as 3d plane -void CAttributes::setAttribute(s32 index, core::plane3df v) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setPlane(v); -} - -//! Adds an attribute as 3d triangle -void CAttributes::addTriangle3d(const c8* attributeName, core::triangle3df v) -{ - Attributes.push_back(new CTriangleAttribute(attributeName, v)); -} - -//! Sets an attribute as 3d triangle -void CAttributes::setAttribute(const c8* attributeName, core::triangle3df v) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setTriangle(v); - else - { - Attributes.push_back(new CTriangleAttribute(attributeName, v)); - } -} - -//! Gets an attribute as a 3d triangle -core::triangle3df CAttributes::getAttributeAsTriangle3d(const c8* attributeName) -{ - core::triangle3df ret; - ret.pointA = ret.pointB = ret.pointC = core::vector3df(0,0,0); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getTriangle(); - - return ret; -} - -//! Gets an attribute as 3d triangle -core::triangle3df CAttributes::getAttributeAsTriangle3d(s32 index) -{ - core::triangle3df ret; - ret.pointA = ret.pointB = ret.pointC = core::vector3df(0,0,0); - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getTriangle(); - - return ret; -} - -//! Sets an attribute as 3d triangle -void CAttributes::setAttribute(s32 index, core::triangle3df v) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setTriangle(v); -} - -//! Adds an attribute as a 2d line -void CAttributes::addLine2d(const c8* attributeName, core::line2df v) -{ - Attributes.push_back(new CLine2dAttribute(attributeName, v)); -} - -//! Sets an attribute as a 2d line -void CAttributes::setAttribute(const c8* attributeName, core::line2df v) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setLine2d(v); - else - { - Attributes.push_back(new CLine2dAttribute(attributeName, v)); - } -} - -//! Gets an attribute as a 2d line -core::line2df CAttributes::getAttributeAsLine2d(const c8* attributeName) -{ - core::line2df ret(0,0, 0,0); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getLine2d(); - - return ret; -} - -//! Gets an attribute as a 2d line -core::line2df CAttributes::getAttributeAsLine2d(s32 index) -{ - core::line2df ret(0,0, 0,0); - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getLine2d(); - - return ret; -} - -//! Sets an attribute as a 2d line -void CAttributes::setAttribute(s32 index, core::line2df v) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setLine2d(v); -} - -//! Adds an attribute as a 3d line -void CAttributes::addLine3d(const c8* attributeName, core::line3df v) -{ - Attributes.push_back(new CLine3dAttribute(attributeName, v)); -} - -//! Sets an attribute as a 3d line -void CAttributes::setAttribute(const c8* attributeName, core::line3df v) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setLine3d(v); - else - { - Attributes.push_back(new CLine3dAttribute(attributeName, v)); - } -} - -//! Gets an attribute as a 3d line -core::line3df CAttributes::getAttributeAsLine3d(const c8* attributeName) -{ - core::line3df ret(0,0,0, 0,0,0); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getLine3d(); - - return ret; -} - -//! Gets an attribute as a 3d line -core::line3df CAttributes::getAttributeAsLine3d(s32 index) -{ - core::line3df ret(0,0,0, 0,0,0); - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getLine3d(); - - return ret; -} - -//! Sets an attribute as a 3d line -void CAttributes::setAttribute(s32 index, core::line3df v) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setLine3d(v); - -} - - - - - -//! Reads attributes from a xml file. -//! \param readCurrentElementOnly: If set to true, reading only works if current element has the name 'attributes'. -//! IF set to false, the first appearing list attributes are read. -bool CAttributes::read(irr::io::IXMLReader* reader, bool readCurrentElementOnly) -{ - if (!reader) - return false; - - clear(); - - const core::stringw elementName = L"attributes"; - - if (readCurrentElementOnly) - { - if (elementName != reader->getNodeName()) - return false; - } - - while(reader->read()) - { - switch(reader->getNodeType()) - { - case io::EXN_ELEMENT: - readAttributeFromXML(reader); - break; - case io::EXN_ELEMENT_END: - if (elementName == reader->getNodeName()) - return true; - break; - default: - break; - } - } - - return true; -} - - -void CAttributes::readAttributeFromXML(io::IXMLReader* reader) -{ - core::stringw element = reader->getNodeName(); - core::stringc name = reader->getAttributeValue(L"name"); - - if (element == L"enum") - { - addEnum(name.c_str(), 0, 0); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"color") - { - addColor(name.c_str(), video::SColor()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"colorf") - { - addColorf(name.c_str(), video::SColorf()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"float") - { - addFloat(name.c_str(), 0); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"int") - { - addInt(name.c_str(), 0); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"bool") - { - addBool(name.c_str(), 0); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"string") - { - addString(name.c_str(), ""); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"texture") - { - addTexture(name.c_str(), 0); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"vector3d") - { - addVector3d(name.c_str(), core::vector3df()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"position") - { - addPosition2d(name.c_str(), core::position2di()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"rect") - { - addRect(name.c_str(), core::rect()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"matrix") - { - addMatrix(name.c_str(), core::matrix4()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"quaternion") - { - addQuaternion(name.c_str(), core::quaternion()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"box3d") - { - addBox3d(name.c_str(), core::aabbox3df()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"plane") - { - addPlane3d(name.c_str(), core::plane3df()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"triangle") - { - addTriangle3d(name.c_str(), core::triangle3df()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"line2d") - { - addLine2d(name.c_str(), core::line2df()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"line3d") - { - addLine3d(name.c_str(), core::line3df()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"stringwarray") - { - core::array tmpArray; - - s32 count = reader->getAttributeValueAsInt(L"count"); - s32 n=0; - const core::stringw tmpName(L"value"); - for (; ngetAttributeValue((tmpName+n).c_str())); - } - addArray(name.c_str(),tmpArray); - } -} - -//! Write these attributes into a xml file -bool CAttributes::write(io::IXMLWriter* writer, bool writeXMLHeader) -{ - if (!writer) - return false; - - if (writeXMLHeader) - writer->writeXMLHeader(); - - writer->writeElement(L"attributes", false); - writer->writeLineBreak(); - - s32 i=0; - for (; i<(s32)Attributes.size(); ++i) - { - if ( Attributes[i]->getType() == EAT_STRINGWARRAY ) - { - core::array arraynames, arrayvalues; - core::array arrayinput = Attributes[i]->getArray(); - - // build arrays - - // name - arraynames.push_back(core::stringw(L"name")); - arrayvalues.push_back(core::stringw(Attributes[i]->Name.c_str()) ); - - // count - arraynames.push_back(core::stringw(L"count")); - arrayvalues.push_back(core::stringw((s32)arrayinput.size())); - - // array... - u32 n=0; - const core::stringw tmpName(L"value"); - for (; n < arrayinput.size(); ++n) - { - arraynames.push_back((tmpName+n).c_str()); - arrayvalues.push_back(arrayinput[n]); - } - - // write them - writer->writeElement( Attributes[i]->getTypeString(), true, arraynames, arrayvalues); - } - else - { - writer->writeElement( - Attributes[i]->getTypeString(), true, - L"name", core::stringw(Attributes[i]->Name.c_str()).c_str(), - L"value", Attributes[i]->getStringW().c_str() ); - } - - writer->writeLineBreak(); - } - - writer->writeClosingTag(L"attributes"); - writer->writeLineBreak(); - - return true; -} - - -} // end namespace io -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CAttributes.h" +#include "CAttributeImpl.h" +#include "ITexture.h" +#include "IXMLWriter.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace io +{ + +CAttributes::CAttributes(video::IVideoDriver* driver) +: Driver(driver) +{ + #ifdef _DEBUG + setDebugName("CAttributes"); + #endif + + if (Driver) + Driver->grab(); +} + +CAttributes::~CAttributes() +{ + clear(); + + if (Driver) + Driver->drop(); +} + + +//! Removes all attributes +void CAttributes::clear() +{ + for (int i=0; i<(int)Attributes.size(); ++i) + Attributes[i]->drop(); + + Attributes.clear(); +} + + +//! Sets a string attribute. +//! \param attributeName: Name for the attribute +//! \param value: Value for the attribute. Set this to 0 to delete the attribute +void CAttributes::setAttribute(const c8* attributeName, const c8* value) +{ + for (int i=0; i<(int)Attributes.size(); ++i) + if (Attributes[i]->Name == attributeName) + { + if (!value) + { + Attributes[i]->drop(); + Attributes.erase(i); + } + else + Attributes[i]->setString(value); + + return; + } + + if (value) + { + Attributes.push_back(new CStringAttribute(attributeName, value)); + } +} + +//! Gets a string attribute. +//! \param attributeName: Name of the attribute to get. +//! \return Returns value of the attribute previously set by setStringAttribute() +//! or 0 if attribute is not set. +core::stringc CAttributes::getAttributeAsString(const c8* attributeName) +{ + core::stringc str; + + IAttribute* att = getAttributeP(attributeName); + if (att) + return att->getString(); + else + return str; +} + +//! Gets a string attribute. +//! \param attributeName: Name of the attribute to get. +//! \param target: Buffer where the string is copied to. +void CAttributes::getAttributeAsString(const c8* attributeName, char* target) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + { + core::stringc str = att->getString(); + strcpy(target,str.c_str()); + } + else + target[0] = 0; +} + +//! Returns string attribute value by index. +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +core::stringc CAttributes::getAttributeAsString(s32 index) +{ + core::stringc str; + + if (index >= 0 && index < (int)Attributes.size()) + return Attributes[index]->getString(); + + return str; +} + + +//! Sets a string attribute. +//! \param attributeName: Name for the attribute +//! \param value: Value for the attribute. Set this to 0 to delete the attribute +void CAttributes::setAttribute(const c8* attributeName, const wchar_t* value) +{ + for (int i=0; i<(int)Attributes.size(); ++i) + if (Attributes[i]->Name == attributeName) + { + if (!value) + { + Attributes[i]->drop(); + Attributes.erase(i); + } + else + Attributes[i]->setString(value); + + return; + } + + if (value) + { + Attributes.push_back(new CStringAttribute(attributeName, value)); + } +} + +//! Gets a string attribute. +//! \param attributeName: Name of the attribute to get. +//! \return Returns value of the attribute previously set by setStringAttribute() +//! or 0 if attribute is not set. +core::stringw CAttributes::getAttributeAsStringW(const c8* attributeName) +{ + core::stringw str; + + IAttribute* att = getAttributeP(attributeName); + if (att) + str = att->getStringW(); + + return str; +} + +//! Gets a string attribute. +//! \param attributeName: Name of the attribute to get. +//! \param target: Buffer where the string is copied to. +void CAttributes::getAttributeAsStringW(const c8* attributeName, wchar_t* target) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + { + core::stringw str = att->getStringW(); + wcscpy(target,str.c_str()); + } + else + target[0] = 0; +} + +//! Returns string attribute value by index. +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +core::stringw CAttributes::getAttributeAsStringW(s32 index) +{ + core::stringw str; + + if (index >= 0 && index < (int)Attributes.size()) + { + str = Attributes[index]->getStringW(); + } + + return str; +} + + +//! Adds an attribute as an array of wide strings +void CAttributes::addArray(const c8* attributeName, core::array value) +{ + Attributes.push_back(new CStringWArrayAttribute(attributeName, value)); +} + +//! Sets an attribute value as an array of wide strings. +void CAttributes::setAttribute(const c8* attributeName, const core::array value) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setArray(value); + else + { + Attributes.push_back(new CStringWArrayAttribute(attributeName, value)); + } +} + +//! Gets an attribute as an array of wide strings. +core::array CAttributes::getAttributeAsArray(const c8* attributeName) +{ + core::array ret; + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getArray(); + + return ret; +} + +//! Returns attribute value as an array of wide strings by index. +core::array CAttributes::getAttributeAsArray(s32 index) +{ + core::array ret; + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getArray(); + + return ret; +} + +//! Sets an attribute as an array of wide strings +void CAttributes::setAttribute(s32 index, core::array value) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setArray(value); +} + + + + +//! Returns attribute index from name, -1 if not found +s32 CAttributes::findAttribute(const c8* attributeName) +{ + for (int i=0; i<(int)Attributes.size(); ++i) + if (Attributes[i]->Name == attributeName) + return i; + + return -1; +} + + +IAttribute* CAttributes::getAttributeP(const c8* attributeName) +{ + for (int i=0; i<(int)Attributes.size(); ++i) + if (Attributes[i]->Name == attributeName) + return Attributes[i]; + + return 0; +} + + +//! Sets a attribute as boolean value +void CAttributes::setAttribute(const c8* attributeName, bool value) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setBool(value); + else + { + Attributes.push_back(new CBoolAttribute(attributeName, value)); + } +} + +//! Gets a attribute as boolean value +//! \param attributeName: Name of the attribute to get. +//! \return Returns value of the attribute previously set by setAttribute() as bool +//! or 0 if attribute is not set. +bool CAttributes::getAttributeAsBool(const c8* attributeName) +{ + bool ret = false; + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getBool(); + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return ret; +} + +//! Sets a attribute as integer value +void CAttributes::setAttribute(const c8* attributeName, s32 value) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setInt(value); + else + { + Attributes.push_back(new CIntAttribute(attributeName, value)); + } +} + +//! Gets a attribute as integer value +//! \param attributeName: Name of the attribute to get. +//! \return Returns value of the attribute previously set by setAttribute() as integer +//! or 0 if attribute is not set. +s32 CAttributes::getAttributeAsInt(const c8* attributeName) +{ + s32 ret = 0; + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getInt(); + + return ret; +} + +//! Sets a attribute as float value +void CAttributes::setAttribute(const c8* attributeName, f32 value) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setFloat(value); + else + { + Attributes.push_back(new CFloatAttribute(attributeName, value)); + } +} + +//! Gets a attribute as integer value +//! \param attributeName: Name of the attribute to get. +//! \return Returns value of the attribute previously set by setAttribute() as float value +//! or 0 if attribute is not set. +f32 CAttributes::getAttributeAsFloat(const c8* attributeName) +{ + f32 ret = 0; + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getFloat(); + + return ret; +} + +//! Sets a attribute as color +void CAttributes::setAttribute(const c8* attributeName, video::SColor value) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setColor(value); + else + { + Attributes.push_back(new CColorAttribute(attributeName, value)); + } +} + +//! Gets an attribute as color +//! \param attributeName: Name of the attribute to get. +//! \return Returns value of the attribute previously set by setAttribute() +video::SColor CAttributes::getAttributeAsColor(const c8* attributeName) +{ + video::SColor ret(0); + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getColor(); + + return ret; +} + +//! Sets a attribute as floating point color +void CAttributes::setAttribute(const c8* attributeName, video::SColorf value) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setColor(value); + else + { + Attributes.push_back(new CColorfAttribute(attributeName, value)); + } +} + +//! Gets an attribute as floating point color +//! \param attributeName: Name of the attribute to get. +//! \return Returns value of the attribute previously set by setAttribute() +video::SColorf CAttributes::getAttributeAsColorf(const c8* attributeName) +{ + video::SColorf ret; + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getColorf(); + + return ret; +} + +//! Sets a attribute as 2d position +void CAttributes::setAttribute(const c8* attributeName, core::position2di value) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setPosition(value); + else + { + Attributes.push_back(new CPosition2DAttribute(attributeName, value)); + } +} + +//! Gets an attribute as 2d position +//! \param attributeName: Name of the attribute to get. +//! \return Returns value of the attribute previously set by setAttribute() +core::position2di CAttributes::getAttributeAsPosition2d(const c8* attributeName) +{ + core::position2di ret; + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getPosition(); + + return ret; +} + +//! Sets a attribute as rectangle +void CAttributes::setAttribute(const c8* attributeName, core::rect value) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setRect(value); + else + { + Attributes.push_back(new CRectAttribute(attributeName, value)); + } +} + +//! Gets an attribute as rectangle +//! \param attributeName: Name of the attribute to get. +//! \return Returns value of the attribute previously set by setAttribute() +core::rect CAttributes::getAttributeAsRect(const c8* attributeName) +{ + core::rect ret; + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getRect(); + + return ret; +} + +//! Sets a attribute as vector +void CAttributes::setAttribute(const c8* attributeName, core::vector3df value) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setVector(value); + else + { + Attributes.push_back(new CVector3DAttribute(attributeName, value)); + } +} + +//! Gets an attribute as vector +//! \param attributeName: Name of the attribute to get. +//! \return Returns value of the attribute previously set by setAttribute() +core::vector3df CAttributes::getAttributeAsVector3d(const c8* attributeName) +{ + core::vector3df ret; + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getVector(); + + return ret; +} + +//! Sets an attribute as binary data +void CAttributes::setAttribute(const c8* attributeName, void* data, s32 dataSizeInBytes ) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setBinary(data, dataSizeInBytes); + else + { + Attributes.push_back(new CBinaryAttribute(attributeName, data, dataSizeInBytes)); + } +} + +//! Gets an attribute as binary data +//! \param attributeName: Name of the attribute to get. +void CAttributes::getAttributeAsBinaryData(const c8* attributeName, void* outData, s32 maxSizeInBytes) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->getBinary(outData, maxSizeInBytes); +} + +//! Sets an attribute as enumeration +void CAttributes::setAttribute(const c8* attributeName, const char* enumValue, const char* const* enumerationLiterals) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setEnum(enumValue, enumerationLiterals); + else + { + Attributes.push_back(new CEnumAttribute(attributeName, enumValue, enumerationLiterals)); + } +} + +//! Gets an attribute as enumeration +//! \param attributeName: Name of the attribute to get. +//! \return Returns value of the attribute previously set by setAttribute() +const char* CAttributes::getAttributeAsEnumeration(const c8* attributeName) +{ + const char* ret = 0; + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getEnum(); + + return ret; +} + +//! Gets an attribute as enumeration +s32 CAttributes::getAttributeAsEnumeration(const c8* attributeName, const char* const* enumerationLiteralsToUse) +{ + s32 ret = -1; + + IAttribute* att = getAttributeP(attributeName); + + if (enumerationLiteralsToUse && att) + { + const char* value = att->getEnum(); + if (value) + { + for (s32 i=0; enumerationLiteralsToUse[i]; ++i) + if (!strcmp(value, enumerationLiteralsToUse[i])) + return i; + } + } + + return ret; +} + +//! Gets the list of enumeration literals of an enumeration attribute +//! \param attributeName: Name of the attribute to get. +void CAttributes::getAttributeEnumerationLiteralsOfEnumeration(const c8* attributeName, core::array& outLiterals) +{ + IAttribute* att = getAttributeP(attributeName); + + if (att && att->getType() == EAT_ENUM) + outLiterals = ((CEnumAttribute*)att)->EnumLiterals; +} + +//! Sets an attribute as texture reference +void CAttributes::setAttribute(const c8* attributeName, video::ITexture* value ) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setTexture(value); + else + { + Attributes.push_back(new CTextureAttribute(attributeName, value, Driver)); + } +} + + +//! Gets an attribute as texture reference +//! \param attributeName: Name of the attribute to get. +video::ITexture* CAttributes::getAttributeAsTexture(const c8* attributeName) +{ + video::ITexture* tex = 0; + + IAttribute* att = getAttributeP(attributeName); + if (att) + tex = att->getTexture(); + + return tex; +} + +//! Gets an attribute as texture reference +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +video::ITexture* CAttributes::getAttributeAsTexture(s32 index) +{ + video::ITexture* tex = 0; + + if (index >= 0 && index < (s32)Attributes.size()) + tex = Attributes[index]->getTexture(); + + return tex; +} + + +//! Returns amount of string attributes set in this scene manager. +s32 CAttributes::getAttributeCount() +{ + return Attributes.size(); +} + +//! Returns string attribute name by index. +//! \param index: Index value, must be between 0 and getStringAttributeCount()-1. +const c8* CAttributes::getAttributeName(s32 index) +{ + if (index < 0 || index >= (int)Attributes.size()) + return 0; + + return Attributes[index]->Name.c_str(); +} + +//! Returns the type of an attribute +E_ATTRIBUTE_TYPE CAttributes::getAttributeType(const c8* attributeName) +{ + E_ATTRIBUTE_TYPE ret = EAT_UNKNOWN; + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getType(); + + return ret; +} + +//! Returns attribute type by index. +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +E_ATTRIBUTE_TYPE CAttributes::getAttributeType(s32 index) +{ + if (index < 0 || index >= (int)Attributes.size()) + return EAT_UNKNOWN; + + return Attributes[index]->getType(); +} + +//! Returns the type of an attribute +const wchar_t* CAttributes::getAttributeTypeString(const c8* attributeName) +{ + const wchar_t* ret = L"unknown"; + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getTypeString(); + + return ret; +} + +//! Returns attribute type string by index. +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +const wchar_t* CAttributes::getAttributeTypeString(s32 index) +{ + if (index < 0 || index >= (int)Attributes.size()) + return L"unknown"; + + return Attributes[index]->getTypeString(); +} + +//! Gets an attribute as boolean value +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +bool CAttributes::getAttributeAsBool(s32 index) +{ + bool ret = false; + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getBool(); + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return ret; +} + +//! Gets an attribute as integer value +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +s32 CAttributes::getAttributeAsInt(s32 index) +{ + s32 ret = 0; + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getInt(); + + return ret; +} + +//! Gets an attribute as float value +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +f32 CAttributes::getAttributeAsFloat(s32 index) +{ + f32 ret = 0; + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getFloat(); + + return ret; +} + +//! Gets an attribute as color +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +video::SColor CAttributes::getAttributeAsColor(s32 index) +{ + video::SColor ret; + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getColor(); + + return ret; +} + +//! Gets an attribute as floating point color +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +video::SColorf CAttributes::getAttributeAsColorf(s32 index) +{ + video::SColorf ret; + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getColorf(); + + return ret; +} + +//! Gets an attribute as 3d vector +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +core::vector3df CAttributes::getAttributeAsVector3d(s32 index) +{ + core::vector3df ret; + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getVector(); + + return ret; +} + +//! Gets an attribute as rectangle +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +core::position2di CAttributes::getAttributeAsPosition2d(s32 index) +{ + core::position2di ret; + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getPosition(); + + return ret; +} + +//! Gets an attribute as rectangle +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +core::rect CAttributes::getAttributeAsRect(s32 index) +{ + core::rect ret; + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getRect(); + + return ret; +} + + +//! Gets an attribute as binary data +///! \param index: Index value, must be between 0 and getAttributeCount()-1. +void CAttributes::getAttributeAsBinaryData(s32 index, void* outData, s32 maxSizeInBytes) +{ + if (index >= 0 && index < (s32)Attributes.size()) + Attributes[index]->getBinary(outData, maxSizeInBytes); +} + +//! Gets an attribute as enumeration +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +const char* CAttributes::getAttributeAsEnumeration(s32 index) +{ + const char* ret = 0; + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getEnum(); + + return ret; +} + +//! Gets an attribute as enumeration +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +s32 CAttributes::getAttributeAsEnumeration(s32 index, const char* const* enumerationLiteralsToUse) +{ + if (index >= 0 && index < (s32)Attributes.size()) + { + IAttribute* att = Attributes[index]; + + if (enumerationLiteralsToUse && att) + { + const char* value = att->getEnum(); + if (value) + { + for (s32 i=0; enumerationLiteralsToUse[i]; ++i) + if (!strcmp(value, enumerationLiteralsToUse[i])) + return i; + } + } + } + + return -1; +} + +//! Gets the list of enumeration literals of an enumeration attribute +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +void CAttributes::getAttributeEnumerationLiteralsOfEnumeration(s32 index, core::array& outLiterals) +{ + if (index >= 0 && index < (s32)Attributes.size() && Attributes[index]->getType() == EAT_ENUM) + outLiterals = ((CEnumAttribute*)Attributes[index])->EnumLiterals; +} + + +//! Adds an attribute as integer +void CAttributes::addInt(const c8* attributeName, s32 value) +{ + Attributes.push_back(new CIntAttribute(attributeName, value)); +} + +//! Adds an attribute as float +void CAttributes::addFloat(const c8* attributeName, f32 value) +{ + Attributes.push_back(new CFloatAttribute(attributeName, value)); +} + +//! Adds an attribute as string +void CAttributes::addString(const c8* attributeName, const char* value) +{ + Attributes.push_back(new CStringAttribute(attributeName, value)); +} + +//! Adds an attribute as wchar string +void CAttributes::addString(const c8* attributeName, const wchar_t* value) +{ + Attributes.push_back(new CStringAttribute(attributeName, value)); +} + +//! Adds an attribute as bool +void CAttributes::addBool(const c8* attributeName, bool value) +{ + Attributes.push_back(new CBoolAttribute(attributeName, value)); +} + +//! Adds an attribute as enum +void CAttributes::addEnum(const c8* attributeName, const char* enumValue, const char* const* enumerationLiterals) +{ + Attributes.push_back(new CEnumAttribute(attributeName, enumValue, enumerationLiterals)); +} + +//! Adds an attribute as enum +void CAttributes::addEnum(const c8* attributeName, s32 enumValue, const char* const* enumerationLiterals) +{ + addEnum(attributeName, "", enumerationLiterals); + Attributes.getLast()->setInt(enumValue); +} + +//! Adds an attribute as color +void CAttributes::addColor(const c8* attributeName, video::SColor value) +{ + Attributes.push_back(new CColorAttribute(attributeName, value)); +} + +//! Adds an attribute as floating point color +void CAttributes::addColorf(const c8* attributeName, video::SColorf value) +{ + Attributes.push_back(new CColorfAttribute(attributeName, value)); +} + +//! Adds an attribute as 3d vector +void CAttributes::addVector3d(const c8* attributeName, core::vector3df value) +{ + Attributes.push_back(new CVector3DAttribute(attributeName, value)); +} + +//! Adds an attribute as 2d position +void CAttributes::addPosition2d(const c8* attributeName, core::position2di value) +{ + Attributes.push_back(new CPosition2DAttribute(attributeName, value)); +} + +//! Adds an attribute as rectangle +void CAttributes::addRect(const c8* attributeName, core::rect value) +{ + Attributes.push_back(new CRectAttribute(attributeName, value)); +} + +//! Adds an attribute as binary data +void CAttributes::addBinary(const c8* attributeName, void* data, s32 dataSizeInBytes) +{ + Attributes.push_back(new CBinaryAttribute(attributeName, data, dataSizeInBytes)); +} + +//! Adds an attribute as texture reference +void CAttributes::addTexture(const c8* attributeName, video::ITexture* texture) +{ + Attributes.push_back(new CTextureAttribute(attributeName, texture, Driver)); +} + +//! Returns if an attribute with a name exists +bool CAttributes::existsAttribute(const c8* attributeName) +{ + return getAttributeP(attributeName) != 0; +} + +//! Sets an attribute value as string. +//! \param attributeName: Name for the attribute +void CAttributes::setAttribute(s32 index, const c8* value) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setString(value); +} + +//! Sets an attribute value as string. +//! \param attributeName: Name for the attribute +void CAttributes::setAttribute(s32 index, const wchar_t* value) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setString(value); +} + +//! Sets an attribute as boolean value +void CAttributes::setAttribute(s32 index, bool value) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setBool(value); +} + +//! Sets an attribute as integer value +void CAttributes::setAttribute(s32 index, s32 value) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setInt(value); +} + +//! Sets a attribute as float value +void CAttributes::setAttribute(s32 index, f32 value) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setFloat(value); +} + +//! Sets a attribute as color +void CAttributes::setAttribute(s32 index, video::SColor color) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setColor(color); +} + +//! Sets a attribute as floating point color +void CAttributes::setAttribute(s32 index, video::SColorf color) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setColor(color); +} + +//! Sets a attribute as vector +void CAttributes::setAttribute(s32 index, core::vector3df v) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setVector(v); +} + +//! Sets a attribute as position +void CAttributes::setAttribute(s32 index, core::position2di v) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setPosition(v); +} + +//! Sets a attribute as rectangle +void CAttributes::setAttribute(s32 index, core::rect v) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setRect(v); +} + +//! Sets an attribute as binary data +void CAttributes::setAttribute(s32 index, void* data, s32 dataSizeInBytes ) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setBinary(data, dataSizeInBytes); +} + +//! Sets an attribute as enumeration +void CAttributes::setAttribute(s32 index, const char* enumValue, const char* const* enumerationLiterals) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setEnum(enumValue, enumerationLiterals); +} + + +//! Sets an attribute as texture reference +void CAttributes::setAttribute(s32 index, video::ITexture* texture) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setTexture(texture); +} + + + +//! Adds an attribute as matrix +void CAttributes::addMatrix(const c8* attributeName, core::matrix4 v) +{ + Attributes.push_back(new CMatrixAttribute(attributeName, v)); +} + + +//! Sets an attribute as matrix +void CAttributes::setAttribute(const c8* attributeName, core::matrix4 v) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setMatrix(v); + else + { + Attributes.push_back(new CMatrixAttribute(attributeName, v)); + } +} + +//! Gets an attribute as a matrix4 +core::matrix4 CAttributes::getAttributeAsMatrix(const c8* attributeName) +{ + core::matrix4 ret; + ret.makeIdentity(); + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getMatrix(); + + return ret; +} + +//! Gets an attribute as matrix +core::matrix4 CAttributes::getAttributeAsMatrix(s32 index) +{ + core::matrix4 ret; + ret.makeIdentity(); + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getMatrix(); + + return ret; +} + +//! Sets an attribute as matrix +void CAttributes::setAttribute(s32 index, core::matrix4 v) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setMatrix(v); +} + + +//! Adds an attribute as quaternion +void CAttributes::addQuaternion(const c8* attributeName, core::quaternion v) +{ + Attributes.push_back(new CQuaternionAttribute(attributeName, v)); +} + + +//! Sets an attribute as quaternion +void CAttributes::setAttribute(const c8* attributeName, core::quaternion v) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setQuaternion(v); + else + { + Attributes.push_back(new CQuaternionAttribute(attributeName, v)); + } +} + +//! Gets an attribute as a quaternion +core::quaternion CAttributes::getAttributeAsQuaternion(const c8* attributeName) +{ + core::quaternion ret(0,1,0, 0); + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getQuaternion(); + + return ret; +} + +//! Gets an attribute as quaternion +core::quaternion CAttributes::getAttributeAsQuaternion(s32 index) +{ + core::quaternion ret(0,1,0, 0); + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getQuaternion(); + + return ret; +} + +//! Sets an attribute as quaternion +void CAttributes::setAttribute(s32 index, core::quaternion v) +{ +if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setQuaternion(v); +} + +//! Adds an attribute as axis aligned bounding box +void CAttributes::addBox3d(const c8* attributeName, core::aabbox3df v) +{ + Attributes.push_back(new CBBoxAttribute(attributeName, v)); +} + +//! Sets an attribute as axis aligned bounding box +void CAttributes::setAttribute(const c8* attributeName, core::aabbox3df v) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setBBox(v); + else + { + Attributes.push_back(new CBBoxAttribute(attributeName, v)); + } +} + +//! Gets an attribute as a axis aligned bounding box +core::aabbox3df CAttributes::getAttributeAsBox3d(const c8* attributeName) +{ + core::aabbox3df ret(0,0,0, 0,0,0); + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getBBox(); + + return ret; +} + +//! Gets an attribute as axis aligned bounding box +core::aabbox3df CAttributes::getAttributeAsBox3d(s32 index) +{ + core::aabbox3df ret(0,0,0, 0,0,0); + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getBBox(); + + return ret; +} + +//! Sets an attribute as axis aligned bounding box +void CAttributes::setAttribute(s32 index, core::aabbox3df v) +{ +if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setBBox(v); +} + +//! Adds an attribute as 3d plane +void CAttributes::addPlane3d(const c8* attributeName, core::plane3df v) +{ + Attributes.push_back(new CPlaneAttribute(attributeName, v)); +} + +//! Sets an attribute as 3d plane +void CAttributes::setAttribute(const c8* attributeName, core::plane3df v) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setPlane(v); + else + { + Attributes.push_back(new CPlaneAttribute(attributeName, v)); + } +} + +//! Gets an attribute as a 3d plane +core::plane3df CAttributes::getAttributeAsPlane3d(const c8* attributeName) +{ + core::plane3df ret(0,0,0, 0,1,0); + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getPlane(); + + return ret; +} + +//! Gets an attribute as 3d plane +core::plane3df CAttributes::getAttributeAsPlane3d(s32 index) +{ + core::plane3df ret(0,0,0, 0,1,0); + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getPlane(); + + return ret; +} + +//! Sets an attribute as 3d plane +void CAttributes::setAttribute(s32 index, core::plane3df v) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setPlane(v); +} + +//! Adds an attribute as 3d triangle +void CAttributes::addTriangle3d(const c8* attributeName, core::triangle3df v) +{ + Attributes.push_back(new CTriangleAttribute(attributeName, v)); +} + +//! Sets an attribute as 3d triangle +void CAttributes::setAttribute(const c8* attributeName, core::triangle3df v) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setTriangle(v); + else + { + Attributes.push_back(new CTriangleAttribute(attributeName, v)); + } +} + +//! Gets an attribute as a 3d triangle +core::triangle3df CAttributes::getAttributeAsTriangle3d(const c8* attributeName) +{ + core::triangle3df ret; + ret.pointA = ret.pointB = ret.pointC = core::vector3df(0,0,0); + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getTriangle(); + + return ret; +} + +//! Gets an attribute as 3d triangle +core::triangle3df CAttributes::getAttributeAsTriangle3d(s32 index) +{ + core::triangle3df ret; + ret.pointA = ret.pointB = ret.pointC = core::vector3df(0,0,0); + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getTriangle(); + + return ret; +} + +//! Sets an attribute as 3d triangle +void CAttributes::setAttribute(s32 index, core::triangle3df v) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setTriangle(v); +} + +//! Adds an attribute as a 2d line +void CAttributes::addLine2d(const c8* attributeName, core::line2df v) +{ + Attributes.push_back(new CLine2dAttribute(attributeName, v)); +} + +//! Sets an attribute as a 2d line +void CAttributes::setAttribute(const c8* attributeName, core::line2df v) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setLine2d(v); + else + { + Attributes.push_back(new CLine2dAttribute(attributeName, v)); + } +} + +//! Gets an attribute as a 2d line +core::line2df CAttributes::getAttributeAsLine2d(const c8* attributeName) +{ + core::line2df ret(0,0, 0,0); + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getLine2d(); + + return ret; +} + +//! Gets an attribute as a 2d line +core::line2df CAttributes::getAttributeAsLine2d(s32 index) +{ + core::line2df ret(0,0, 0,0); + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getLine2d(); + + return ret; +} + +//! Sets an attribute as a 2d line +void CAttributes::setAttribute(s32 index, core::line2df v) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setLine2d(v); +} + +//! Adds an attribute as a 3d line +void CAttributes::addLine3d(const c8* attributeName, core::line3df v) +{ + Attributes.push_back(new CLine3dAttribute(attributeName, v)); +} + +//! Sets an attribute as a 3d line +void CAttributes::setAttribute(const c8* attributeName, core::line3df v) +{ + IAttribute* att = getAttributeP(attributeName); + if (att) + att->setLine3d(v); + else + { + Attributes.push_back(new CLine3dAttribute(attributeName, v)); + } +} + +//! Gets an attribute as a 3d line +core::line3df CAttributes::getAttributeAsLine3d(const c8* attributeName) +{ + core::line3df ret(0,0,0, 0,0,0); + + IAttribute* att = getAttributeP(attributeName); + if (att) + ret = att->getLine3d(); + + return ret; +} + +//! Gets an attribute as a 3d line +core::line3df CAttributes::getAttributeAsLine3d(s32 index) +{ + core::line3df ret(0,0,0, 0,0,0); + + if (index >= 0 && index < (s32)Attributes.size()) + ret = Attributes[index]->getLine3d(); + + return ret; +} + +//! Sets an attribute as a 3d line +void CAttributes::setAttribute(s32 index, core::line3df v) +{ + if (index >= 0 && index < (s32)Attributes.size() ) + Attributes[index]->setLine3d(v); + +} + + + + + +//! Reads attributes from a xml file. +//! \param readCurrentElementOnly: If set to true, reading only works if current element has the name 'attributes'. +//! IF set to false, the first appearing list attributes are read. +bool CAttributes::read(irr::io::IXMLReader* reader, bool readCurrentElementOnly) +{ + if (!reader) + return false; + + clear(); + + const core::stringw elementName = L"attributes"; + + if (readCurrentElementOnly) + { + if (elementName != reader->getNodeName()) + return false; + } + + while(reader->read()) + { + switch(reader->getNodeType()) + { + case io::EXN_ELEMENT: + readAttributeFromXML(reader); + break; + case io::EXN_ELEMENT_END: + if (elementName == reader->getNodeName()) + return true; + break; + default: + break; + } + } + + return true; +} + + +void CAttributes::readAttributeFromXML(io::IXMLReader* reader) +{ + core::stringw element = reader->getNodeName(); + core::stringc name = reader->getAttributeValue(L"name"); + + if (element == L"enum") + { + addEnum(name.c_str(), 0, 0); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"color") + { + addColor(name.c_str(), video::SColor()); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"colorf") + { + addColorf(name.c_str(), video::SColorf()); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"float") + { + addFloat(name.c_str(), 0); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"int") + { + addInt(name.c_str(), 0); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"bool") + { + addBool(name.c_str(), 0); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"string") + { + addString(name.c_str(), ""); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"texture") + { + addTexture(name.c_str(), 0); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"vector3d") + { + addVector3d(name.c_str(), core::vector3df()); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"position") + { + addPosition2d(name.c_str(), core::position2di()); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"rect") + { + addRect(name.c_str(), core::rect()); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"matrix") + { + addMatrix(name.c_str(), core::matrix4()); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"quaternion") + { + addQuaternion(name.c_str(), core::quaternion()); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"box3d") + { + addBox3d(name.c_str(), core::aabbox3df()); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"plane") + { + addPlane3d(name.c_str(), core::plane3df()); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"triangle") + { + addTriangle3d(name.c_str(), core::triangle3df()); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"line2d") + { + addLine2d(name.c_str(), core::line2df()); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"line3d") + { + addLine3d(name.c_str(), core::line3df()); + Attributes.getLast()->setString(reader->getAttributeValue(L"value")); + } + else + if (element == L"stringwarray") + { + core::array tmpArray; + + s32 count = reader->getAttributeValueAsInt(L"count"); + s32 n=0; + const core::stringw tmpName(L"value"); + for (; ngetAttributeValue((tmpName+n).c_str())); + } + addArray(name.c_str(),tmpArray); + } +} + +//! Write these attributes into a xml file +bool CAttributes::write(io::IXMLWriter* writer, bool writeXMLHeader) +{ + if (!writer) + return false; + + if (writeXMLHeader) + writer->writeXMLHeader(); + + writer->writeElement(L"attributes", false); + writer->writeLineBreak(); + + s32 i=0; + for (; i<(s32)Attributes.size(); ++i) + { + if ( Attributes[i]->getType() == EAT_STRINGWARRAY ) + { + core::array arraynames, arrayvalues; + core::array arrayinput = Attributes[i]->getArray(); + + // build arrays + + // name + arraynames.push_back(core::stringw(L"name")); + arrayvalues.push_back(core::stringw(Attributes[i]->Name.c_str()) ); + + // count + arraynames.push_back(core::stringw(L"count")); + arrayvalues.push_back(core::stringw((s32)arrayinput.size())); + + // array... + u32 n=0; + const core::stringw tmpName(L"value"); + for (; n < arrayinput.size(); ++n) + { + arraynames.push_back((tmpName+n).c_str()); + arrayvalues.push_back(arrayinput[n]); + } + + // write them + writer->writeElement( Attributes[i]->getTypeString(), true, arraynames, arrayvalues); + } + else + { + writer->writeElement( + Attributes[i]->getTypeString(), true, + L"name", core::stringw(Attributes[i]->Name.c_str()).c_str(), + L"value", Attributes[i]->getStringW().c_str() ); + } + + writer->writeLineBreak(); + } + + writer->writeClosingTag(L"attributes"); + writer->writeLineBreak(); + + return true; +} + + +} // end namespace io +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CAttributes.h b/src/dep/src/irrlicht/CAttributes.h index d353eac..01cae3a 100644 --- a/src/dep/src/irrlicht/CAttributes.h +++ b/src/dep/src/irrlicht/CAttributes.h @@ -1,704 +1,704 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_ATTRIBUTES_H_INCLUDED__ -#define __C_ATTRIBUTES_H_INCLUDED__ - -#include "IAttributes.h" - -namespace irr -{ -namespace video -{ - class ITexture; - class IVideoDriver; -} -namespace io -{ - -class IAttribute; - -//! Implementation of the IAttributes interface -class CAttributes : public IAttributes -{ -public: - - CAttributes(video::IVideoDriver* driver=0); - ~CAttributes(); - - //! Returns amount of attributes in this collection of attributes. - virtual s32 getAttributeCount(); - - //! Returns attribute name by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual const c8* getAttributeName(s32 index); - - //! Returns the type of an attribute - //! \param attributeName: Name for the attribute - virtual E_ATTRIBUTE_TYPE getAttributeType(const c8* attributeName); - - //! Returns attribute type by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual E_ATTRIBUTE_TYPE getAttributeType(s32 index); - - //! Returns the type string of the attribute - //! \param attributeName: String for the attribute type - virtual const wchar_t* getAttributeTypeString(const c8* attributeName); - - //! Returns the type string of the attribute by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual const wchar_t* getAttributeTypeString(s32 index); - - //! Returns if an attribute with a name exists - virtual bool existsAttribute(const c8* attributeName); - - //! Returns attribute index from name, -1 if not found - virtual s32 findAttribute(const c8* attributeName); - - //! Removes all attributes - virtual void clear(); - - //! Reads attributes from a xml file. - //! \param readCurrentElementOnly: If set to true, reading only works if current element has the name 'attributes'. - //! IF set to false, the first appearing list attributes are read. - virtual bool read(irr::io::IXMLReader* reader, bool readCurrentElementOnly=false); - - //! Write these attributes into a xml file - virtual bool write(io::IXMLWriter* writer, bool writeXMLHeader=false); - - - /* - - Integer Attribute - - */ - - //! Adds an attribute as integer - virtual void addInt(const c8* attributeName, s32 value); - - //! Sets an attribute as integer value - virtual void setAttribute(const c8* attributeName, s32 value); - - //! Gets an attribute as integer value - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual s32 getAttributeAsInt(const c8* attributeName); - - //! Gets an attribute as integer value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual s32 getAttributeAsInt(s32 index); - - //! Sets an attribute as integer value - virtual void setAttribute(s32 index, s32 value); - - /* - - Float Attribute - - */ - - //! Adds an attribute as float - virtual void addFloat(const c8* attributeName, f32 value); - - //! Sets a attribute as float value - virtual void setAttribute(const c8* attributeName, f32 value); - - //! Gets an attribute as float value - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual f32 getAttributeAsFloat(const c8* attributeName); - - //! Gets an attribute as float value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual f32 getAttributeAsFloat(s32 index); - - //! Sets an attribute as float value - virtual void setAttribute(s32 index, f32 value); - - /* - - String Attribute - - */ - - //! Adds an attribute as string - virtual void addString(const c8* attributeName, const c8* value); - - //! Sets an attribute value as string. - //! \param attributeName: Name for the attribute - //! \param value: Value for the attribute. Set this to 0 to delete the attribute - virtual void setAttribute(const c8* attributeName, const c8* value); - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - //! or 0 if attribute is not set. - virtual core::stringc getAttributeAsString(const c8* attributeName); - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \param target: Buffer where the string is copied to. - virtual void getAttributeAsString(const c8* attributeName, c8* target); - - //! Returns attribute value as string by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::stringc getAttributeAsString(s32 index); - - //! Sets an attribute value as string. - //! \param attributeName: Name for the attribute - virtual void setAttribute(s32 index, const c8* value); - - // wide strings - - //! Adds an attribute as string - virtual void addString(const c8* attributeName, const wchar_t* value); - - //! Sets an attribute value as string. - //! \param attributeName: Name for the attribute - //! \param value: Value for the attribute. Set this to 0 to delete the attribute - virtual void setAttribute(const c8* attributeName, const wchar_t* value); - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - //! or 0 if attribute is not set. - virtual core::stringw getAttributeAsStringW(const c8* attributeName); - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \param target: Buffer where the string is copied to. - virtual void getAttributeAsStringW(const c8* attributeName, wchar_t* target); - - //! Returns attribute value as string by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::stringw getAttributeAsStringW(s32 index); - - //! Sets an attribute value as string. - //! \param attributeName: Name for the attribute - virtual void setAttribute(s32 index, const wchar_t* value); - - /* - - Binary Data Attribute - - */ - - //! Adds an attribute as binary data - virtual void addBinary(const c8* attributeName, void* data, s32 dataSizeInBytes); - - //! Sets an attribute as binary data - virtual void setAttribute(const c8* attributeName, void* data, s32 dataSizeInBytes); - - //! Gets an attribute as binary data - //! \param attributeName: Name of the attribute to get. - virtual void getAttributeAsBinaryData(const c8* attributeName, void* outData, s32 maxSizeInBytes); - - //! Gets an attribute as binary data - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual void getAttributeAsBinaryData(s32 index, void* outData, s32 maxSizeInBytes); - - //! Sets an attribute as binary data - virtual void setAttribute(s32 index, void* data, s32 dataSizeInBytes); - - - /* - - Array Attribute - - */ - - //! Adds an attribute as wide string array - virtual void addArray(const c8* attributeName, core::array value); - - //! Sets an attribute value as a wide string array. - //! \param attributeName: Name for the attribute - //! \param value: Value for the attribute. Set this to 0 to delete the attribute - virtual void setAttribute(const c8* attributeName, const core::array value); - - //! Gets an attribute as an array of wide strings. - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - //! or 0 if attribute is not set. - virtual core::array getAttributeAsArray(const c8* attributeName); - - //! Returns attribute value as an array of wide strings by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::array getAttributeAsArray(s32 index); - - //! Sets an attribute as an array of wide strings - virtual void setAttribute(s32 index, core::array value); - - /* - - Bool Attribute - - */ - - //! Adds an attribute as bool - virtual void addBool(const c8* attributeName, bool value); - - //! Sets an attribute as boolean value - virtual void setAttribute(const c8* attributeName, bool value); - - //! Gets an attribute as boolean value - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual bool getAttributeAsBool(const c8* attributeName); - - //! Gets an attribute as boolean value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual bool getAttributeAsBool(s32 index); - - //! Sets an attribute as boolean value - virtual void setAttribute(s32 index, bool value); - - /* - - Enumeration Attribute - - */ - - //! Adds an attribute as enum - virtual void addEnum(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals); - - //! Adds an attribute as enum - virtual void addEnum(const c8* attributeName, s32 enumValue, const c8* const* enumerationLiterals); - - //! Sets an attribute as enumeration - virtual void setAttribute(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals); - - //! Gets an attribute as enumeration - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual const c8* getAttributeAsEnumeration(const c8* attributeName); - - //! Gets an attribute as enumeration - //! \param attributeName: Name of the attribute to get. - //! \param enumerationLiteralsToUse: Use these enumeration literals to get the index value instead of the set ones. - //! This is useful when the attribute list maybe was read from an xml file, and only contains the enumeration string, but - //! no information about its index. - //! \return Returns value of the attribute previously set by setAttribute() - virtual s32 getAttributeAsEnumeration(const c8* attributeName, const c8* const* enumerationLiteralsToUse); - - //! Gets an attribute as enumeration - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual s32 getAttributeAsEnumeration(s32 index, const c8* const* enumerationLiteralsToUse); - - //! Gets an attribute as enumeration - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual const c8* getAttributeAsEnumeration(s32 index); - - //! Gets the list of enumeration literals of an enumeration attribute - //! \param attributeName: Name of the attribute to get. - virtual void getAttributeEnumerationLiteralsOfEnumeration(const c8* attributeName, core::array& outLiterals); - - //! Gets the list of enumeration literals of an enumeration attribute - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual void getAttributeEnumerationLiteralsOfEnumeration(s32 index, core::array& outLiterals); - - //! Sets an attribute as enumeration - virtual void setAttribute(s32 index, const c8* enumValue, const c8* const* enumerationLiterals); - - - /* - - SColor Attribute - - */ - - //! Adds an attribute as color - virtual void addColor(const c8* attributeName, video::SColor value); - - //! Sets a attribute as color - virtual void setAttribute(const c8* attributeName, video::SColor color); - - //! Gets an attribute as color - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual video::SColor getAttributeAsColor(const c8* attributeName); - - //! Gets an attribute as color - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual video::SColor getAttributeAsColor(s32 index); - - //! Sets an attribute as color - virtual void setAttribute(s32 index, video::SColor color); - - /* - - SColorf Attribute - - */ - - //! Adds an attribute as floating point color - virtual void addColorf(const c8* attributeName, video::SColorf value); - - //! Sets a attribute as floating point color - virtual void setAttribute(const c8* attributeName, video::SColorf color); - - //! Gets an attribute as floating point color - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual video::SColorf getAttributeAsColorf(const c8* attributeName); - - //! Gets an attribute as floating point color - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual video::SColorf getAttributeAsColorf(s32 index); - - //! Sets an attribute as floating point color - virtual void setAttribute(s32 index, video::SColorf color); - - - /* - - Vector3d Attribute - - */ - - //! Adds an attribute as 3d vector - virtual void addVector3d(const c8* attributeName, core::vector3df value); - - //! Sets a attribute as 3d vector - virtual void setAttribute(const c8* attributeName, core::vector3df v); - - //! Gets an attribute as 3d vector - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::vector3df getAttributeAsVector3d(const c8* attributeName); - - //! Gets an attribute as 3d vector - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::vector3df getAttributeAsVector3d(s32 index); - - //! Sets an attribute as vector - virtual void setAttribute(s32 index, core::vector3df v); - - /* - - Position2d Attribute - - */ - - //! Adds an attribute as 2d position - virtual void addPosition2d(const c8* attributeName, core::position2di value); - - //! Sets a attribute as 2d position - virtual void setAttribute(const c8* attributeName, core::position2di v); - - //! Gets an attribute as position - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::position2di getAttributeAsPosition2d(const c8* attributeName); - - //! Gets an attribute as position - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::position2di getAttributeAsPosition2d(s32 index); - - //! Sets an attribute as 2d position - virtual void setAttribute(s32 index, core::position2di v); - - /* - - Rectangle Attribute - - */ - - //! Adds an attribute as rectangle - virtual void addRect(const c8* attributeName, core::rect value); - - //! Sets an attribute as rectangle - virtual void setAttribute(const c8* attributeName, core::rect v); - - //! Gets an attribute as rectangle - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::rect getAttributeAsRect(const c8* attributeName); - - //! Gets an attribute as rectangle - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::rect getAttributeAsRect(s32 index); - - //! Sets an attribute as rectangle - virtual void setAttribute(s32 index, core::rect v); - - - /* - - matrix attribute - - */ - - //! Adds an attribute as matrix - virtual void addMatrix(const c8* attributeName, core::matrix4 v); - - //! Sets an attribute as matrix - virtual void setAttribute(const c8* attributeName, core::matrix4 v); - - //! Gets an attribute as a matrix4 - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::matrix4 getAttributeAsMatrix(const c8* attributeName); - - //! Gets an attribute as matrix - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::matrix4 getAttributeAsMatrix(s32 index); - - //! Sets an attribute as matrix - virtual void setAttribute(s32 index, core::matrix4 v); - - /* - quaternion attribute - - */ - - //! Adds an attribute as quaternion - virtual void addQuaternion(const c8* attributeName, core::quaternion v); - - //! Sets an attribute as quaternion - virtual void setAttribute(const c8* attributeName, core::quaternion v); - - //! Gets an attribute as a quaternion - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::quaternion getAttributeAsQuaternion(const c8* attributeName); - - //! Gets an attribute as quaternion - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::quaternion getAttributeAsQuaternion(s32 index); - - //! Sets an attribute as quaternion - virtual void setAttribute(s32 index, core::quaternion v); - - /* - - 3d bounding box - - */ - - //! Adds an attribute as axis aligned bounding box - virtual void addBox3d(const c8* attributeName, core::aabbox3df v); - - //! Sets an attribute as axis aligned bounding box - virtual void setAttribute(const c8* attributeName, core::aabbox3df v); - - //! Gets an attribute as a axis aligned bounding box - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::aabbox3df getAttributeAsBox3d(const c8* attributeName); - - //! Gets an attribute as axis aligned bounding box - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::aabbox3df getAttributeAsBox3d(s32 index); - - //! Sets an attribute as axis aligned bounding box - virtual void setAttribute(s32 index, core::aabbox3df v); - - /* - - plane - - */ - - //! Adds an attribute as 3d plane - virtual void addPlane3d(const c8* attributeName, core::plane3df v); - - //! Sets an attribute as 3d plane - virtual void setAttribute(const c8* attributeName, core::plane3df v); - - //! Gets an attribute as a 3d plane - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::plane3df getAttributeAsPlane3d(const c8* attributeName); - - //! Gets an attribute as 3d plane - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::plane3df getAttributeAsPlane3d(s32 index); - - //! Sets an attribute as 3d plane - virtual void setAttribute(s32 index, core::plane3df v); - - - /* - - 3d triangle - - */ - - //! Adds an attribute as 3d triangle - virtual void addTriangle3d(const c8* attributeName, core::triangle3df v); - - //! Sets an attribute as 3d trianle - virtual void setAttribute(const c8* attributeName, core::triangle3df v); - - //! Gets an attribute as a 3d triangle - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::triangle3df getAttributeAsTriangle3d(const c8* attributeName); - - //! Gets an attribute as 3d triangle - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::triangle3df getAttributeAsTriangle3d(s32 index); - - //! Sets an attribute as 3d triangle - virtual void setAttribute(s32 index, core::triangle3df v); - - - /* - - line 2d - - */ - - //! Adds an attribute as a 2d line - virtual void addLine2d(const c8* attributeName, core::line2df v); - - //! Sets an attribute as a 2d line - virtual void setAttribute(const c8* attributeName, core::line2df v); - - //! Gets an attribute as a 2d line - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::line2df getAttributeAsLine2d(const c8* attributeName); - - //! Gets an attribute as a 2d line - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::line2df getAttributeAsLine2d(s32 index); - - //! Sets an attribute as a 2d line - virtual void setAttribute(s32 index, core::line2df v); - - - /* - - line 3d - - */ - - //! Adds an attribute as a 3d line - virtual void addLine3d(const c8* attributeName, core::line3df v); - - //! Sets an attribute as a 3d line - virtual void setAttribute(const c8* attributeName, core::line3df v); - - //! Gets an attribute as a 3d line - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::line3df getAttributeAsLine3d(const c8* attributeName); - - //! Gets an attribute as a 3d line - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::line3df getAttributeAsLine3d(s32 index); - - //! Sets an attribute as a 3d line - virtual void setAttribute(s32 index, core::line3df v); - - - /* - - Texture Attribute - - */ - - //! Adds an attribute as texture reference - virtual void addTexture(const c8* attributeName, video::ITexture* texture); - - //! Sets an attribute as texture reference - virtual void setAttribute(const c8* attributeName, video::ITexture* texture ); - - //! Gets an attribute as texture reference - //! \param attributeName: Name of the attribute to get. - virtual video::ITexture* getAttributeAsTexture(const c8* attributeName); - - //! Gets an attribute as texture reference - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual video::ITexture* getAttributeAsTexture(s32 index); - - //! Sets an attribute as texture reference - virtual void setAttribute(s32 index, video::ITexture* texture); - -protected: - - void readAttributeFromXML(io::IXMLReader* reader); - - core::array Attributes; - - IAttribute* getAttributeP(const c8* attributeName); - - video::IVideoDriver* Driver; -}; - - -class IAttribute : public virtual IUnknown -{ -public: - - virtual ~IAttribute() {}; - - virtual s32 getInt() { return 0; } - virtual f32 getFloat() { return 0; } - virtual video::SColorf getColorf() { return video::SColorf(1.0f,1.0f,1.0f,1.0f); } - virtual video::SColor getColor() { return video::SColor(255,255,255,255); } - virtual core::stringc getString() { return core::stringc(getStringW().c_str()); } - virtual core::stringw getStringW() { return core::stringw(); } - virtual core::array getArray() { return core::array(); }; - virtual bool getBool() { return false; } - virtual void getBinary(void* outdata, s32 maxLength) {}; - virtual core::vector3df getVector() { return core::vector3df(); } - virtual core::position2di getPosition() { return core::position2di(); } - virtual core::rect getRect() { return core::rect(); } - virtual core::quaternion getQuaternion(){ return core::quaternion(); } - virtual core::matrix4 getMatrix() { return core::matrix4(); } - virtual core::triangle3df getTriangle() { return core::triangle3df(); } - virtual core::vector2df getVector2d() { return core::vector2df(); } - virtual core::vector2di getVector2di() { return core::vector2di(); } - virtual core::line2df getLine2d() { return core::line2df(); } - virtual core::line2di getLine2di() { return core::line2di(); } - virtual core::line3df getLine3d() { return core::line3df(); } - virtual core::line3di getLine3di() { return core::line3di(); } - virtual core::dimension2di getDimension2d() { return core::dimension2di(); } - virtual core::aabbox3d getBBox() { return core::aabbox3d(); } - virtual core::plane3df getPlane() { return core::plane3df(); } - - virtual video::ITexture* getTexture() { return 0; } - virtual const char* getEnum() { return 0; } - - virtual void setInt(s32 intValue) {}; - virtual void setFloat(f32 floatValue) {}; - virtual void setString(const char* text) {}; - virtual void setString(const wchar_t* text){ setString(core::stringc(text).c_str()); }; - virtual void setArray( core::array arr ) {}; - virtual void setColor(video::SColorf color) {}; - virtual void setColor(video::SColor color) {}; - virtual void setBool(bool boolValue) {}; - virtual void setBinary(void* data, s32 maxLenght) {}; - virtual void setVector(core::vector3df v) {}; - virtual void setPosition(core::position2di v) {}; - virtual void setRect(core::rect v) {}; - virtual void setQuaternion(core::quaternion v) {}; - virtual void setMatrix(core::matrix4 v) {}; - virtual void setTriangle(core::triangle3df v) {}; - virtual void setVector2d(core::vector2df v) {}; - virtual void setVector2d(core::vector2di v) {}; - virtual void setLine2d(core::line2df v) {}; - virtual void setLine2d(core::line2di v) {}; - virtual void setLine3d(core::line3df v) {}; - virtual void setLine3d(core::line3di v) {}; - virtual void setDimension2d(core::dimension2di v) {}; - virtual void setBBox(core::aabbox3d v) {}; - virtual void setPlane(core::plane3df v) {}; - - virtual void setEnum(const char* enumValue, const char* const* enumerationLiterals) {}; - virtual void setTexture(video::ITexture*) {}; - - core::stringc Name; - - virtual E_ATTRIBUTE_TYPE getType() = 0; - virtual const wchar_t* getTypeString() = 0; -}; - -} // end namespace io -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_ATTRIBUTES_H_INCLUDED__ +#define __C_ATTRIBUTES_H_INCLUDED__ + +#include "IAttributes.h" + +namespace irr +{ +namespace video +{ + class ITexture; + class IVideoDriver; +} +namespace io +{ + +class IAttribute; + +//! Implementation of the IAttributes interface +class CAttributes : public IAttributes +{ +public: + + CAttributes(video::IVideoDriver* driver=0); + ~CAttributes(); + + //! Returns amount of attributes in this collection of attributes. + virtual s32 getAttributeCount(); + + //! Returns attribute name by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual const c8* getAttributeName(s32 index); + + //! Returns the type of an attribute + //! \param attributeName: Name for the attribute + virtual E_ATTRIBUTE_TYPE getAttributeType(const c8* attributeName); + + //! Returns attribute type by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual E_ATTRIBUTE_TYPE getAttributeType(s32 index); + + //! Returns the type string of the attribute + //! \param attributeName: String for the attribute type + virtual const wchar_t* getAttributeTypeString(const c8* attributeName); + + //! Returns the type string of the attribute by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual const wchar_t* getAttributeTypeString(s32 index); + + //! Returns if an attribute with a name exists + virtual bool existsAttribute(const c8* attributeName); + + //! Returns attribute index from name, -1 if not found + virtual s32 findAttribute(const c8* attributeName); + + //! Removes all attributes + virtual void clear(); + + //! Reads attributes from a xml file. + //! \param readCurrentElementOnly: If set to true, reading only works if current element has the name 'attributes'. + //! IF set to false, the first appearing list attributes are read. + virtual bool read(irr::io::IXMLReader* reader, bool readCurrentElementOnly=false); + + //! Write these attributes into a xml file + virtual bool write(io::IXMLWriter* writer, bool writeXMLHeader=false); + + + /* + + Integer Attribute + + */ + + //! Adds an attribute as integer + virtual void addInt(const c8* attributeName, s32 value); + + //! Sets an attribute as integer value + virtual void setAttribute(const c8* attributeName, s32 value); + + //! Gets an attribute as integer value + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual s32 getAttributeAsInt(const c8* attributeName); + + //! Gets an attribute as integer value + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual s32 getAttributeAsInt(s32 index); + + //! Sets an attribute as integer value + virtual void setAttribute(s32 index, s32 value); + + /* + + Float Attribute + + */ + + //! Adds an attribute as float + virtual void addFloat(const c8* attributeName, f32 value); + + //! Sets a attribute as float value + virtual void setAttribute(const c8* attributeName, f32 value); + + //! Gets an attribute as float value + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual f32 getAttributeAsFloat(const c8* attributeName); + + //! Gets an attribute as float value + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual f32 getAttributeAsFloat(s32 index); + + //! Sets an attribute as float value + virtual void setAttribute(s32 index, f32 value); + + /* + + String Attribute + + */ + + //! Adds an attribute as string + virtual void addString(const c8* attributeName, const c8* value); + + //! Sets an attribute value as string. + //! \param attributeName: Name for the attribute + //! \param value: Value for the attribute. Set this to 0 to delete the attribute + virtual void setAttribute(const c8* attributeName, const c8* value); + + //! Gets an attribute as string. + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + //! or 0 if attribute is not set. + virtual core::stringc getAttributeAsString(const c8* attributeName); + + //! Gets an attribute as string. + //! \param attributeName: Name of the attribute to get. + //! \param target: Buffer where the string is copied to. + virtual void getAttributeAsString(const c8* attributeName, c8* target); + + //! Returns attribute value as string by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::stringc getAttributeAsString(s32 index); + + //! Sets an attribute value as string. + //! \param attributeName: Name for the attribute + virtual void setAttribute(s32 index, const c8* value); + + // wide strings + + //! Adds an attribute as string + virtual void addString(const c8* attributeName, const wchar_t* value); + + //! Sets an attribute value as string. + //! \param attributeName: Name for the attribute + //! \param value: Value for the attribute. Set this to 0 to delete the attribute + virtual void setAttribute(const c8* attributeName, const wchar_t* value); + + //! Gets an attribute as string. + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + //! or 0 if attribute is not set. + virtual core::stringw getAttributeAsStringW(const c8* attributeName); + + //! Gets an attribute as string. + //! \param attributeName: Name of the attribute to get. + //! \param target: Buffer where the string is copied to. + virtual void getAttributeAsStringW(const c8* attributeName, wchar_t* target); + + //! Returns attribute value as string by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::stringw getAttributeAsStringW(s32 index); + + //! Sets an attribute value as string. + //! \param attributeName: Name for the attribute + virtual void setAttribute(s32 index, const wchar_t* value); + + /* + + Binary Data Attribute + + */ + + //! Adds an attribute as binary data + virtual void addBinary(const c8* attributeName, void* data, s32 dataSizeInBytes); + + //! Sets an attribute as binary data + virtual void setAttribute(const c8* attributeName, void* data, s32 dataSizeInBytes); + + //! Gets an attribute as binary data + //! \param attributeName: Name of the attribute to get. + virtual void getAttributeAsBinaryData(const c8* attributeName, void* outData, s32 maxSizeInBytes); + + //! Gets an attribute as binary data + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual void getAttributeAsBinaryData(s32 index, void* outData, s32 maxSizeInBytes); + + //! Sets an attribute as binary data + virtual void setAttribute(s32 index, void* data, s32 dataSizeInBytes); + + + /* + + Array Attribute + + */ + + //! Adds an attribute as wide string array + virtual void addArray(const c8* attributeName, core::array value); + + //! Sets an attribute value as a wide string array. + //! \param attributeName: Name for the attribute + //! \param value: Value for the attribute. Set this to 0 to delete the attribute + virtual void setAttribute(const c8* attributeName, const core::array value); + + //! Gets an attribute as an array of wide strings. + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + //! or 0 if attribute is not set. + virtual core::array getAttributeAsArray(const c8* attributeName); + + //! Returns attribute value as an array of wide strings by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::array getAttributeAsArray(s32 index); + + //! Sets an attribute as an array of wide strings + virtual void setAttribute(s32 index, core::array value); + + /* + + Bool Attribute + + */ + + //! Adds an attribute as bool + virtual void addBool(const c8* attributeName, bool value); + + //! Sets an attribute as boolean value + virtual void setAttribute(const c8* attributeName, bool value); + + //! Gets an attribute as boolean value + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual bool getAttributeAsBool(const c8* attributeName); + + //! Gets an attribute as boolean value + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual bool getAttributeAsBool(s32 index); + + //! Sets an attribute as boolean value + virtual void setAttribute(s32 index, bool value); + + /* + + Enumeration Attribute + + */ + + //! Adds an attribute as enum + virtual void addEnum(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals); + + //! Adds an attribute as enum + virtual void addEnum(const c8* attributeName, s32 enumValue, const c8* const* enumerationLiterals); + + //! Sets an attribute as enumeration + virtual void setAttribute(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals); + + //! Gets an attribute as enumeration + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual const c8* getAttributeAsEnumeration(const c8* attributeName); + + //! Gets an attribute as enumeration + //! \param attributeName: Name of the attribute to get. + //! \param enumerationLiteralsToUse: Use these enumeration literals to get the index value instead of the set ones. + //! This is useful when the attribute list maybe was read from an xml file, and only contains the enumeration string, but + //! no information about its index. + //! \return Returns value of the attribute previously set by setAttribute() + virtual s32 getAttributeAsEnumeration(const c8* attributeName, const c8* const* enumerationLiteralsToUse); + + //! Gets an attribute as enumeration + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual s32 getAttributeAsEnumeration(s32 index, const c8* const* enumerationLiteralsToUse); + + //! Gets an attribute as enumeration + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual const c8* getAttributeAsEnumeration(s32 index); + + //! Gets the list of enumeration literals of an enumeration attribute + //! \param attributeName: Name of the attribute to get. + virtual void getAttributeEnumerationLiteralsOfEnumeration(const c8* attributeName, core::array& outLiterals); + + //! Gets the list of enumeration literals of an enumeration attribute + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual void getAttributeEnumerationLiteralsOfEnumeration(s32 index, core::array& outLiterals); + + //! Sets an attribute as enumeration + virtual void setAttribute(s32 index, const c8* enumValue, const c8* const* enumerationLiterals); + + + /* + + SColor Attribute + + */ + + //! Adds an attribute as color + virtual void addColor(const c8* attributeName, video::SColor value); + + //! Sets a attribute as color + virtual void setAttribute(const c8* attributeName, video::SColor color); + + //! Gets an attribute as color + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual video::SColor getAttributeAsColor(const c8* attributeName); + + //! Gets an attribute as color + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual video::SColor getAttributeAsColor(s32 index); + + //! Sets an attribute as color + virtual void setAttribute(s32 index, video::SColor color); + + /* + + SColorf Attribute + + */ + + //! Adds an attribute as floating point color + virtual void addColorf(const c8* attributeName, video::SColorf value); + + //! Sets a attribute as floating point color + virtual void setAttribute(const c8* attributeName, video::SColorf color); + + //! Gets an attribute as floating point color + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual video::SColorf getAttributeAsColorf(const c8* attributeName); + + //! Gets an attribute as floating point color + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual video::SColorf getAttributeAsColorf(s32 index); + + //! Sets an attribute as floating point color + virtual void setAttribute(s32 index, video::SColorf color); + + + /* + + Vector3d Attribute + + */ + + //! Adds an attribute as 3d vector + virtual void addVector3d(const c8* attributeName, core::vector3df value); + + //! Sets a attribute as 3d vector + virtual void setAttribute(const c8* attributeName, core::vector3df v); + + //! Gets an attribute as 3d vector + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::vector3df getAttributeAsVector3d(const c8* attributeName); + + //! Gets an attribute as 3d vector + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::vector3df getAttributeAsVector3d(s32 index); + + //! Sets an attribute as vector + virtual void setAttribute(s32 index, core::vector3df v); + + /* + + Position2d Attribute + + */ + + //! Adds an attribute as 2d position + virtual void addPosition2d(const c8* attributeName, core::position2di value); + + //! Sets a attribute as 2d position + virtual void setAttribute(const c8* attributeName, core::position2di v); + + //! Gets an attribute as position + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::position2di getAttributeAsPosition2d(const c8* attributeName); + + //! Gets an attribute as position + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::position2di getAttributeAsPosition2d(s32 index); + + //! Sets an attribute as 2d position + virtual void setAttribute(s32 index, core::position2di v); + + /* + + Rectangle Attribute + + */ + + //! Adds an attribute as rectangle + virtual void addRect(const c8* attributeName, core::rect value); + + //! Sets an attribute as rectangle + virtual void setAttribute(const c8* attributeName, core::rect v); + + //! Gets an attribute as rectangle + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::rect getAttributeAsRect(const c8* attributeName); + + //! Gets an attribute as rectangle + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::rect getAttributeAsRect(s32 index); + + //! Sets an attribute as rectangle + virtual void setAttribute(s32 index, core::rect v); + + + /* + + matrix attribute + + */ + + //! Adds an attribute as matrix + virtual void addMatrix(const c8* attributeName, core::matrix4 v); + + //! Sets an attribute as matrix + virtual void setAttribute(const c8* attributeName, core::matrix4 v); + + //! Gets an attribute as a matrix4 + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::matrix4 getAttributeAsMatrix(const c8* attributeName); + + //! Gets an attribute as matrix + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::matrix4 getAttributeAsMatrix(s32 index); + + //! Sets an attribute as matrix + virtual void setAttribute(s32 index, core::matrix4 v); + + /* + quaternion attribute + + */ + + //! Adds an attribute as quaternion + virtual void addQuaternion(const c8* attributeName, core::quaternion v); + + //! Sets an attribute as quaternion + virtual void setAttribute(const c8* attributeName, core::quaternion v); + + //! Gets an attribute as a quaternion + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::quaternion getAttributeAsQuaternion(const c8* attributeName); + + //! Gets an attribute as quaternion + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::quaternion getAttributeAsQuaternion(s32 index); + + //! Sets an attribute as quaternion + virtual void setAttribute(s32 index, core::quaternion v); + + /* + + 3d bounding box + + */ + + //! Adds an attribute as axis aligned bounding box + virtual void addBox3d(const c8* attributeName, core::aabbox3df v); + + //! Sets an attribute as axis aligned bounding box + virtual void setAttribute(const c8* attributeName, core::aabbox3df v); + + //! Gets an attribute as a axis aligned bounding box + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::aabbox3df getAttributeAsBox3d(const c8* attributeName); + + //! Gets an attribute as axis aligned bounding box + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::aabbox3df getAttributeAsBox3d(s32 index); + + //! Sets an attribute as axis aligned bounding box + virtual void setAttribute(s32 index, core::aabbox3df v); + + /* + + plane + + */ + + //! Adds an attribute as 3d plane + virtual void addPlane3d(const c8* attributeName, core::plane3df v); + + //! Sets an attribute as 3d plane + virtual void setAttribute(const c8* attributeName, core::plane3df v); + + //! Gets an attribute as a 3d plane + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::plane3df getAttributeAsPlane3d(const c8* attributeName); + + //! Gets an attribute as 3d plane + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::plane3df getAttributeAsPlane3d(s32 index); + + //! Sets an attribute as 3d plane + virtual void setAttribute(s32 index, core::plane3df v); + + + /* + + 3d triangle + + */ + + //! Adds an attribute as 3d triangle + virtual void addTriangle3d(const c8* attributeName, core::triangle3df v); + + //! Sets an attribute as 3d trianle + virtual void setAttribute(const c8* attributeName, core::triangle3df v); + + //! Gets an attribute as a 3d triangle + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::triangle3df getAttributeAsTriangle3d(const c8* attributeName); + + //! Gets an attribute as 3d triangle + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::triangle3df getAttributeAsTriangle3d(s32 index); + + //! Sets an attribute as 3d triangle + virtual void setAttribute(s32 index, core::triangle3df v); + + + /* + + line 2d + + */ + + //! Adds an attribute as a 2d line + virtual void addLine2d(const c8* attributeName, core::line2df v); + + //! Sets an attribute as a 2d line + virtual void setAttribute(const c8* attributeName, core::line2df v); + + //! Gets an attribute as a 2d line + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::line2df getAttributeAsLine2d(const c8* attributeName); + + //! Gets an attribute as a 2d line + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::line2df getAttributeAsLine2d(s32 index); + + //! Sets an attribute as a 2d line + virtual void setAttribute(s32 index, core::line2df v); + + + /* + + line 3d + + */ + + //! Adds an attribute as a 3d line + virtual void addLine3d(const c8* attributeName, core::line3df v); + + //! Sets an attribute as a 3d line + virtual void setAttribute(const c8* attributeName, core::line3df v); + + //! Gets an attribute as a 3d line + //! \param attributeName: Name of the attribute to get. + //! \return Returns value of the attribute previously set by setAttribute() + virtual core::line3df getAttributeAsLine3d(const c8* attributeName); + + //! Gets an attribute as a 3d line + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual core::line3df getAttributeAsLine3d(s32 index); + + //! Sets an attribute as a 3d line + virtual void setAttribute(s32 index, core::line3df v); + + + /* + + Texture Attribute + + */ + + //! Adds an attribute as texture reference + virtual void addTexture(const c8* attributeName, video::ITexture* texture); + + //! Sets an attribute as texture reference + virtual void setAttribute(const c8* attributeName, video::ITexture* texture ); + + //! Gets an attribute as texture reference + //! \param attributeName: Name of the attribute to get. + virtual video::ITexture* getAttributeAsTexture(const c8* attributeName); + + //! Gets an attribute as texture reference + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual video::ITexture* getAttributeAsTexture(s32 index); + + //! Sets an attribute as texture reference + virtual void setAttribute(s32 index, video::ITexture* texture); + +protected: + + void readAttributeFromXML(io::IXMLReader* reader); + + core::array Attributes; + + IAttribute* getAttributeP(const c8* attributeName); + + video::IVideoDriver* Driver; +}; + + +class IAttribute : public virtual IUnknown +{ +public: + + virtual ~IAttribute() {}; + + virtual s32 getInt() { return 0; } + virtual f32 getFloat() { return 0; } + virtual video::SColorf getColorf() { return video::SColorf(1.0f,1.0f,1.0f,1.0f); } + virtual video::SColor getColor() { return video::SColor(255,255,255,255); } + virtual core::stringc getString() { return core::stringc(getStringW().c_str()); } + virtual core::stringw getStringW() { return core::stringw(); } + virtual core::array getArray() { return core::array(); }; + virtual bool getBool() { return false; } + virtual void getBinary(void* outdata, s32 maxLength) {}; + virtual core::vector3df getVector() { return core::vector3df(); } + virtual core::position2di getPosition() { return core::position2di(); } + virtual core::rect getRect() { return core::rect(); } + virtual core::quaternion getQuaternion(){ return core::quaternion(); } + virtual core::matrix4 getMatrix() { return core::matrix4(); } + virtual core::triangle3df getTriangle() { return core::triangle3df(); } + virtual core::vector2df getVector2d() { return core::vector2df(); } + virtual core::vector2di getVector2di() { return core::vector2di(); } + virtual core::line2df getLine2d() { return core::line2df(); } + virtual core::line2di getLine2di() { return core::line2di(); } + virtual core::line3df getLine3d() { return core::line3df(); } + virtual core::line3di getLine3di() { return core::line3di(); } + virtual core::dimension2di getDimension2d() { return core::dimension2di(); } + virtual core::aabbox3d getBBox() { return core::aabbox3d(); } + virtual core::plane3df getPlane() { return core::plane3df(); } + + virtual video::ITexture* getTexture() { return 0; } + virtual const char* getEnum() { return 0; } + + virtual void setInt(s32 intValue) {}; + virtual void setFloat(f32 floatValue) {}; + virtual void setString(const char* text) {}; + virtual void setString(const wchar_t* text){ setString(core::stringc(text).c_str()); }; + virtual void setArray( core::array arr ) {}; + virtual void setColor(video::SColorf color) {}; + virtual void setColor(video::SColor color) {}; + virtual void setBool(bool boolValue) {}; + virtual void setBinary(void* data, s32 maxLenght) {}; + virtual void setVector(core::vector3df v) {}; + virtual void setPosition(core::position2di v) {}; + virtual void setRect(core::rect v) {}; + virtual void setQuaternion(core::quaternion v) {}; + virtual void setMatrix(core::matrix4 v) {}; + virtual void setTriangle(core::triangle3df v) {}; + virtual void setVector2d(core::vector2df v) {}; + virtual void setVector2d(core::vector2di v) {}; + virtual void setLine2d(core::line2df v) {}; + virtual void setLine2d(core::line2di v) {}; + virtual void setLine3d(core::line3df v) {}; + virtual void setLine3d(core::line3di v) {}; + virtual void setDimension2d(core::dimension2di v) {}; + virtual void setBBox(core::aabbox3d v) {}; + virtual void setPlane(core::plane3df v) {}; + + virtual void setEnum(const char* enumValue, const char* const* enumerationLiterals) {}; + virtual void setTexture(video::ITexture*) {}; + + core::stringc Name; + + virtual E_ATTRIBUTE_TYPE getType() = 0; + virtual const wchar_t* getTypeString() = 0; +}; + +} // end namespace io +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CBillboardSceneNode.cpp b/src/dep/src/irrlicht/CBillboardSceneNode.cpp index ad591c6..fd95932 100644 --- a/src/dep/src/irrlicht/CBillboardSceneNode.cpp +++ b/src/dep/src/irrlicht/CBillboardSceneNode.cpp @@ -1,228 +1,228 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CBillboardSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "ICameraSceneNode.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CBillboardSceneNode::CBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::dimension2d& size, - video::SColor shade_top, video::SColor shade_down - ) -: IBillboardSceneNode(parent, mgr, id, position) -{ - #ifdef _DEBUG - setDebugName("CBillboardSceneNode"); - #endif - - setSize(size); - - indices[0] = 0; - indices[1] = 2; - indices[2] = 1; - indices[3] = 0; - indices[4] = 3; - indices[5] = 2; - - vertices[0].TCoords.set(1.0f, 1.0f); - vertices[0].Color = shade_down; - - vertices[1].TCoords.set(1.0f, 0.0f); - vertices[1].Color = shade_top; - - vertices[2].TCoords.set(0.0f, 0.0f); - vertices[2].Color = shade_top; - - vertices[3].TCoords.set(0.0f, 1.0f); - vertices[3].Color = shade_down; -} - - - -CBillboardSceneNode::~CBillboardSceneNode() -{ -} - - - -//! pre render event -void CBillboardSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - SceneManager->registerNodeForRendering(this); - ISceneNode::OnRegisterSceneNode(); - } -} - - -//! render -void CBillboardSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - ICameraSceneNode* camera = SceneManager->getActiveCamera(); - - if (!camera || !driver) - return; - - // make billboard look to camera - - core::vector3df pos = getAbsolutePosition(); - - core::vector3df campos = camera->getAbsolutePosition(); - core::vector3df target = camera->getTarget(); - core::vector3df up = camera->getUpVector(); - core::vector3df view = target - campos; - view.normalize(); - - core::vector3df horizontal = up.crossProduct(view); - if ( horizontal.getLength() == 0 ) - { - horizontal.set(up.Y,up.X,up.Z); - } - horizontal.normalize(); - horizontal *= 0.5f * Size.Width; - - core::vector3df vertical = horizontal.crossProduct(view); - vertical.normalize(); - vertical *= 0.5f * Size.Height; - - view *= -1.0f; - - for (s32 i=0; i<4; ++i) - vertices[i].Normal = view; - - vertices[0].Pos = pos + horizontal + vertical; - vertices[1].Pos = pos + horizontal - vertical; - vertices[2].Pos = pos - horizontal - vertical; - vertices[3].Pos = pos - horizontal + vertical; - - // draw - - if (DebugDataVisible) - { - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - driver->draw3DBox(BBox, video::SColor(0,208,195,152)); - } - - core::matrix4 mat; - driver->setTransform(video::ETS_WORLD, mat); - - driver->setMaterial(Material); - - driver->drawIndexedTriangleList(vertices, 4, indices, 2); -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CBillboardSceneNode::getBoundingBox() const -{ - return BBox; -} - - -//! sets the size of the billboard -void CBillboardSceneNode::setSize(const core::dimension2d& size) -{ - Size = size; - - if (Size.Width == 0.0f) - Size.Width = 1.0f; - - if (Size.Height == 0.0f ) - Size.Height = 1.0f; - - f32 avg = (size.Width + size.Height)/6; - BBox.MinEdge.set(-avg,-avg,-avg); - BBox.MaxEdge.set(avg,avg,avg); -} - - -video::SMaterial& CBillboardSceneNode::getMaterial(u32 i) -{ - return Material; -} - - -//! returns amount of materials used by this scene node. -u32 CBillboardSceneNode::getMaterialCount() -{ - return 1; -} - - -//! gets the size of the billboard -const core::dimension2d& CBillboardSceneNode::getSize() -{ - return Size; -} - - -//! Writes attributes of the scene node. -void CBillboardSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - IBillboardSceneNode::serializeAttributes(out, options); - - out->addFloat("Width", Size.Width); - out->addFloat("Height", Size.Height); - out->addColor ("Shade_Top", vertices[1].Color ); - out->addColor ("Shade_Down", vertices[0].Color ); -} - -//! Reads attributes of the scene node. -void CBillboardSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - IBillboardSceneNode::deserializeAttributes(in, options); - - Size.Width = in->getAttributeAsFloat("Width"); - Size.Height = in->getAttributeAsFloat("Height"); - vertices[1].Color = in->getAttributeAsColor ( "Shade_Top" ); - vertices[0].Color = in->getAttributeAsColor ( "Shade_Down" ); - - setSize(Size); -} - -//! Set the color of all vertices of the billboard -//! \param overallColor: the color to set -void CBillboardSceneNode::setColor(const video::SColor & overallColor) -{ - for(u32 vertex = 0; vertex < 4; ++vertex) - vertices[0].Color = overallColor; -} - -//! Set the color of the top and bottom vertices of the billboard -//! \param topColor: the color to set the top vertices -//! \param bottomColor: the color to set the bottom vertices -void CBillboardSceneNode::setColor(const video::SColor & topColor, const video::SColor & bottomColor) -{ - vertices[0].Color = bottomColor; - vertices[1].Color = topColor; - vertices[2].Color = topColor; - vertices[3].Color = bottomColor; -} - -//! Gets the color of the top and bottom vertices of the billboard -//! \param[out] topColor: stores the color of the top vertices -//! \param[out] bottomColor: stores the color of the bottom vertices -void CBillboardSceneNode::getColor(video::SColor & topColor, video::SColor & bottomColor) -{ - bottomColor = vertices[0].Color; - topColor = vertices[1].Color; -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CBillboardSceneNode.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" +#include "ICameraSceneNode.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CBillboardSceneNode::CBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position, const core::dimension2d& size, + video::SColor shade_top, video::SColor shade_down + ) +: IBillboardSceneNode(parent, mgr, id, position) +{ + #ifdef _DEBUG + setDebugName("CBillboardSceneNode"); + #endif + + setSize(size); + + indices[0] = 0; + indices[1] = 2; + indices[2] = 1; + indices[3] = 0; + indices[4] = 3; + indices[5] = 2; + + vertices[0].TCoords.set(1.0f, 1.0f); + vertices[0].Color = shade_down; + + vertices[1].TCoords.set(1.0f, 0.0f); + vertices[1].Color = shade_top; + + vertices[2].TCoords.set(0.0f, 0.0f); + vertices[2].Color = shade_top; + + vertices[3].TCoords.set(0.0f, 1.0f); + vertices[3].Color = shade_down; +} + + + +CBillboardSceneNode::~CBillboardSceneNode() +{ +} + + + +//! pre render event +void CBillboardSceneNode::OnRegisterSceneNode() +{ + if (IsVisible) + { + SceneManager->registerNodeForRendering(this); + ISceneNode::OnRegisterSceneNode(); + } +} + + +//! render +void CBillboardSceneNode::render() +{ + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + ICameraSceneNode* camera = SceneManager->getActiveCamera(); + + if (!camera || !driver) + return; + + // make billboard look to camera + + core::vector3df pos = getAbsolutePosition(); + + core::vector3df campos = camera->getAbsolutePosition(); + core::vector3df target = camera->getTarget(); + core::vector3df up = camera->getUpVector(); + core::vector3df view = target - campos; + view.normalize(); + + core::vector3df horizontal = up.crossProduct(view); + if ( horizontal.getLength() == 0 ) + { + horizontal.set(up.Y,up.X,up.Z); + } + horizontal.normalize(); + horizontal *= 0.5f * Size.Width; + + core::vector3df vertical = horizontal.crossProduct(view); + vertical.normalize(); + vertical *= 0.5f * Size.Height; + + view *= -1.0f; + + for (s32 i=0; i<4; ++i) + vertices[i].Normal = view; + + vertices[0].Pos = pos + horizontal + vertical; + vertices[1].Pos = pos + horizontal - vertical; + vertices[2].Pos = pos - horizontal - vertical; + vertices[3].Pos = pos - horizontal + vertical; + + // draw + + if (DebugDataVisible) + { + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + video::SMaterial m; + m.Lighting = false; + driver->setMaterial(m); + driver->draw3DBox(BBox, video::SColor(0,208,195,152)); + } + + core::matrix4 mat; + driver->setTransform(video::ETS_WORLD, mat); + + driver->setMaterial(Material); + + driver->drawIndexedTriangleList(vertices, 4, indices, 2); +} + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CBillboardSceneNode::getBoundingBox() const +{ + return BBox; +} + + +//! sets the size of the billboard +void CBillboardSceneNode::setSize(const core::dimension2d& size) +{ + Size = size; + + if (Size.Width == 0.0f) + Size.Width = 1.0f; + + if (Size.Height == 0.0f ) + Size.Height = 1.0f; + + f32 avg = (size.Width + size.Height)/6; + BBox.MinEdge.set(-avg,-avg,-avg); + BBox.MaxEdge.set(avg,avg,avg); +} + + +video::SMaterial& CBillboardSceneNode::getMaterial(u32 i) +{ + return Material; +} + + +//! returns amount of materials used by this scene node. +u32 CBillboardSceneNode::getMaterialCount() +{ + return 1; +} + + +//! gets the size of the billboard +const core::dimension2d& CBillboardSceneNode::getSize() +{ + return Size; +} + + +//! Writes attributes of the scene node. +void CBillboardSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + IBillboardSceneNode::serializeAttributes(out, options); + + out->addFloat("Width", Size.Width); + out->addFloat("Height", Size.Height); + out->addColor ("Shade_Top", vertices[1].Color ); + out->addColor ("Shade_Down", vertices[0].Color ); +} + +//! Reads attributes of the scene node. +void CBillboardSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + IBillboardSceneNode::deserializeAttributes(in, options); + + Size.Width = in->getAttributeAsFloat("Width"); + Size.Height = in->getAttributeAsFloat("Height"); + vertices[1].Color = in->getAttributeAsColor ( "Shade_Top" ); + vertices[0].Color = in->getAttributeAsColor ( "Shade_Down" ); + + setSize(Size); +} + +//! Set the color of all vertices of the billboard +//! \param overallColor: the color to set +void CBillboardSceneNode::setColor(const video::SColor & overallColor) +{ + for(u32 vertex = 0; vertex < 4; ++vertex) + vertices[0].Color = overallColor; +} + +//! Set the color of the top and bottom vertices of the billboard +//! \param topColor: the color to set the top vertices +//! \param bottomColor: the color to set the bottom vertices +void CBillboardSceneNode::setColor(const video::SColor & topColor, const video::SColor & bottomColor) +{ + vertices[0].Color = bottomColor; + vertices[1].Color = topColor; + vertices[2].Color = topColor; + vertices[3].Color = bottomColor; +} + +//! Gets the color of the top and bottom vertices of the billboard +//! \param[out] topColor: stores the color of the top vertices +//! \param[out] bottomColor: stores the color of the bottom vertices +void CBillboardSceneNode::getColor(video::SColor & topColor, video::SColor & bottomColor) +{ + bottomColor = vertices[0].Color; + topColor = vertices[1].Color; +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CBillboardSceneNode.h b/src/dep/src/irrlicht/CBillboardSceneNode.h index 1d9296f..62b3cb5 100644 --- a/src/dep/src/irrlicht/CBillboardSceneNode.h +++ b/src/dep/src/irrlicht/CBillboardSceneNode.h @@ -1,88 +1,88 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_BILLBOARD_SCENE_NODE_H_INCLUDED__ -#define __C_BILLBOARD_SCENE_NODE_H_INCLUDED__ - -#include "IBillboardSceneNode.h" -#include "S3DVertex.h" - -namespace irr -{ -namespace scene -{ - -//! Scene node which is a billboard. A billboard is like a 3d sprite: A 2d element, -//! which always looks to the camera. -class CBillboardSceneNode : public IBillboardSceneNode -{ -public: - - //! constructor - CBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::dimension2d& size, - video::SColor shade_top=video::SColor(0xFFFFFFFF),video::SColor shade_down=video::SColor(0xFFFFFFFF)); - - virtual ~CBillboardSceneNode(); - - //! pre render event - virtual void OnRegisterSceneNode(); - - //! render - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! sets the size of the billboard - virtual void setSize(const core::dimension2d& size); - - //! gets the size of the billboard - virtual const core::dimension2d& getSize(); - - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount(); - - //! Set the color of all vertices of the billboard - //! \param overallColor: the color to set - virtual void setColor(const video::SColor & overallColor); - - //! Set the color of the top and bottom vertices of the billboard - //! \param topColor: the color to set the top vertices - //! \param bottomColor: the color to set the bottom vertices - virtual void setColor(const video::SColor & topColor, const video::SColor & bottomColor); - - //! Gets the color of the top and bottom vertices of the billboard - //! \param[out] topColor: stores the color of the top vertices - //! \param[out] bottomColor: stores the color of the bottom vertices - virtual void getColor(video::SColor & topColor, video::SColor & bottomColor); - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_BILLBOARD; } - -private: - - core::dimension2d Size; - core::aabbox3d BBox; - video::SMaterial Material; - - video::S3DVertex vertices[4]; - u16 indices[6]; -}; - - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_BILLBOARD_SCENE_NODE_H_INCLUDED__ +#define __C_BILLBOARD_SCENE_NODE_H_INCLUDED__ + +#include "IBillboardSceneNode.h" +#include "S3DVertex.h" + +namespace irr +{ +namespace scene +{ + +//! Scene node which is a billboard. A billboard is like a 3d sprite: A 2d element, +//! which always looks to the camera. +class CBillboardSceneNode : public IBillboardSceneNode +{ +public: + + //! constructor + CBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position, const core::dimension2d& size, + video::SColor shade_top=video::SColor(0xFFFFFFFF),video::SColor shade_down=video::SColor(0xFFFFFFFF)); + + virtual ~CBillboardSceneNode(); + + //! pre render event + virtual void OnRegisterSceneNode(); + + //! render + virtual void render(); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! sets the size of the billboard + virtual void setSize(const core::dimension2d& size); + + //! gets the size of the billboard + virtual const core::dimension2d& getSize(); + + virtual video::SMaterial& getMaterial(u32 i); + + //! returns amount of materials used by this scene node. + virtual u32 getMaterialCount(); + + //! Set the color of all vertices of the billboard + //! \param overallColor: the color to set + virtual void setColor(const video::SColor & overallColor); + + //! Set the color of the top and bottom vertices of the billboard + //! \param topColor: the color to set the top vertices + //! \param bottomColor: the color to set the bottom vertices + virtual void setColor(const video::SColor & topColor, const video::SColor & bottomColor); + + //! Gets the color of the top and bottom vertices of the billboard + //! \param[out] topColor: stores the color of the top vertices + //! \param[out] bottomColor: stores the color of the bottom vertices + virtual void getColor(video::SColor & topColor, video::SColor & bottomColor); + + //! Writes attributes of the scene node. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_BILLBOARD; } + +private: + + core::dimension2d Size; + core::aabbox3d BBox; + video::SMaterial Material; + + video::S3DVertex vertices[4]; + u16 indices[6]; +}; + + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CCSMLoader.cpp b/src/dep/src/irrlicht/CCSMLoader.cpp index 1d53c61..aa27179 100644 --- a/src/dep/src/irrlicht/CCSMLoader.cpp +++ b/src/dep/src/irrlicht/CCSMLoader.cpp @@ -1,873 +1,873 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This file was written by Saurav Mohapatra and modified by Nikolaus Gebhardt. -// See CCSMLoader.h for details. - -#include "CCSMLoader.h" -#include "os.h" -#include "IFileSystem.h" -#include "IReadFile.h" -#include "ISceneManager.h" -#include "IAttributes.h" -#include "SMesh.h" -#include "IVideoDriver.h" -#include "SAnimatedMesh.h" -#include "SMeshBufferLightMap.h" - -namespace irr -{ -namespace scene -{ - // - // the CSM data types - // - struct color_rgb_t - { - s32 red; - s32 green; - s32 blue; - - void clear() - { - red = 0; - green = 0; - blue = 0; - } - }; - - class BinaryFileReader; - - // - // The file header - // - class Header - { - public: - - static const s32 VERSION_4; - static const s32 VERSION_4_1; - - Header(){ clear(); } - virtual ~Header(){ clear(); } - - s32 getVersion() const{ return version; } - void clear(){ version = 0; } - void load(BinaryFileReader* pReader); - - private: - - s32 version; - }; - - - // - // The groups - // - class Group - { - public: - - Group(){ clear(); } - virtual ~Group(){ clear(); } - - void clear(); - void load(BinaryFileReader* pReader); - - s32 getFlags() const { return flags; } - s32 getParentGroupID() const { return parentGroup; } - const core::stringc& getProperties() const { return props; } - const color_rgb_t* getColor() const { return &color; } - - private: - - s32 flags; - s32 parentGroup; - core::stringc props; - color_rgb_t color; - }; - - - // - // The visgroups - // - class VisGroup - { - public: - - VisGroup(){ clear(); } - virtual ~VisGroup(){ clear(); } - void clear(); - void load(BinaryFileReader* pReader); - - s32 getFlags() const{ return flags; } - const core::stringc& getName() const{ return name; } - const color_rgb_t* getColor() const{ return &color; } - - private: - - core::stringc name; - s32 flags; - color_rgb_t color; - }; - - - // - // Lightmaps - // - class LightMap - { - public: - - LightMap() : pixelData(0){ clear(); } - virtual ~LightMap(){ clear(); } - void clear(); - void load(BinaryFileReader* pReader); - s32 getWidth() const{ return width; } - s32 getHeight() const{ return height; } - const s32* getPixelData() const{ return pixelData; } - - private: - - s32 width; - s32 height; - s32* pixelData; - }; - - struct Triangle - { - s32 a,b,c; - }; - - - struct Line - { - s32 a,b; - }; - - - class Vertex - { - public: - - Vertex(){ clear(); } - virtual ~Vertex(){ clear(); } - void clear(); - void load(BinaryFileReader* pReader); - - const core::vector3df* getPosition() const { return &position; } - const core::vector3df* getNormal() const { return &normal; } - const color_rgb_t* getColor() const { return &color; } - const core::vector3df* getTextureCoordinates() const { return &texCoords; } - const core::vector3df* getLightMapCoordinates() const { return &lmapCoords; } - - private: - - core::vector3df position; - core::vector3df normal; - color_rgb_t color; - core::vector3df texCoords; - core::vector3df lmapCoords; - }; - - - class Surface - { - public: - - Surface() { clear(); } - virtual ~Surface(){ clear(); } - - void clear(); - void load(BinaryFileReader *pReader); - - s32 getFlags() const{ return flags; } - const core::stringc& getTextureName() const{ return textureName; } - s32 getLightMapId() const{ return lightMapId; } - const core::vector2df* getUVOffset() const{ return &uvOffset; } - const core::vector2df* getUVScale() const{ return &uvScale; } - f32 getUVRotation() const{ return uvRotation; } - - u32 getVertexCount() const{ return vertices.size(); } - const Vertex* getVertexAt(const s32 index) const{ return vertices[index]; } - - s32 getTriangleCount() const{ return triangles.size(); } - const Triangle& getTriangleAt(const s32 index) const{ return triangles[index]; } - - private: - - s32 flags; - core::stringc textureName; - s32 lightMapId; - core::vector2df uvOffset; - core::vector2df uvScale; - f32 uvRotation; - core::array vertices; - core::array triangles; - core::array lines; - }; - - class Mesh - { - public: - - Mesh(){ clear(); } - virtual ~Mesh(){ clear(); } - - void clear(); - void load(BinaryFileReader* pReader, bool bReadVisGroups); - - s32 getFlags() const { return flags; } - s32 getGroupID() const { return groupId; } - const core::stringc& getProperties() const { return props; } - const color_rgb_t* getColor() const { return &color; } - const core::vector3df* getPosition() const { return &position; } - s32 getVisgroupID() const { return visgroupId; } - s32 getSurfaceCount() const { return surfaces.size(); } - const Surface* getSurfaceAt(const s32 index) const { return surfaces[index]; } - - private: - - s32 flags; - s32 groupId; - core::stringc props; - color_rgb_t color; - core::vector3df position; - s32 visgroupId; - - core::array surfaces; - }; - - class Entity - { - public: - - Entity() { clear(); } - virtual ~Entity() { clear(); } - - void clear(); - void load(BinaryFileReader* pReader); - s32 getVisgroupID() const { return visgroupId; } - s32 getGroupID() const { return groupId; } - const core::stringc& getProperties() const { return props; } - const core::vector3df* getPosition() const { return &position; } - - private: - - s32 visgroupId; - s32 groupId; - core::stringc props; - core::vector3df position; - }; - - - class CameraData - { - public: - - CameraData(){ clear(); } - virtual ~CameraData(){ clear(); } - - void clear(); - void load(BinaryFileReader* pReader); - - const core::vector3df* getPosition(){ return &position; } - f32 getPitch(){ return pitch; } - f32 getYaw(){ return yaw; } - - private: - - core::vector3df position; - f32 pitch; - f32 yaw; - }; - - // - // A CSM File - // - class CSMFile - { - public: - - CSMFile(){ clear(); } - virtual ~CSMFile(){ clear(); } - void clear(); - void load(BinaryFileReader* pReader); - - const Header* getHeader() const{ return &header; } - - s32 getGroupCount() const{ return groups.size(); } - const Group* getGroupAt(const s32 index) const{ return groups[index]; } - - s32 getVisGroupCount() const{ return visgroups.size(); } - const VisGroup* getVisGroupAt(const s32 index) const{ return visgroups[index]; } - - s32 getLightMapCount() const{ return lightmaps.size(); } - const LightMap* getLightMapAt(const s32 index) const { return lightmaps[index]; } - - s32 getMeshCount() const{ return meshes.size(); } - const Mesh* getMeshAt(const s32 index) const{ return meshes[index]; } - - s32 getEntityCount() const{ return entities.size(); } - const Entity* getEntityAt(const s32 index) const{ return entities[index]; } - - const CameraData* getCameraData() const{ return &cameraData; } - - private: - - Header header; - core::array groups; - core::array visgroups; - core::array lightmaps; - core::array meshes; - core::array entities; - CameraData cameraData; - }; - - - // - // A Binary File Reader - // - class BinaryFileReader - { - public: - - BinaryFileReader(io::IReadFile* pFile, bool closeWhenDone=true); - virtual ~BinaryFileReader(); - - virtual s32 readBuffer(void* buffer, s32 len); - - s32 readLong(); - f32 readFloat(); - u8 readByte(); - - core::stringc readString(); - void readVec3f(core::vector3df* v); - void readVec2f(core::vector2df* v); - void readColorRGB(color_rgb_t* color); - - private: - - io::IReadFile *file; - bool autoClose; - - }; - - CCSMLoader::CCSMLoader(scene::ISceneManager* manager, io::IFileSystem* fs) - : FileSystem(fs), SceneManager(manager) - { - } - - CCSMLoader::~CCSMLoader() - { - } - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".bsp") - bool CCSMLoader::isALoadableFileExtension(const c8* fileName) - { - return strstr(fileName, ".csm")!=0; - } - - //! creates/loads an animated mesh from the file. - IAnimatedMesh* CCSMLoader::createMesh(irr::io::IReadFile* file) - { - file->grab(); // originally, this loader created the file on its own. - - scene::IMesh* m = createCSMMesh(file); - - if (!m) - return 0; - - SAnimatedMesh* am = new SAnimatedMesh(); - am->Type = EAMT_CSM; - am->addMesh(m); - m->drop(); - - am->recalculateBoundingBox(); - return am; - } - - scene::IMesh* CCSMLoader::createCSMMesh(irr::io::IReadFile* file) - { - if (!file) - return 0; - - if(file) - { - BinaryFileReader reader(file, true); - CSMFile csmFile; - csmFile.load(&reader); - - scene::IMesh* pMesh = createIrrlichtMesh(&csmFile, - SceneManager->getParameters()->getAttributeAsString(CSM_TEXTURE_PATH), - file->getFileName()); - return pMesh; - } - - return 0; - } - - scene::IMesh* CCSMLoader::createIrrlichtMesh(const CSMFile* csmFile, - core::stringc textureRoot, const c8* lmprefix) - { - scene::SMesh *pMesh = new scene::SMesh(); - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - for(s32 l = 0; lgetLightMapCount(); l++) - { - const LightMap* lmap = csmFile->getLightMapAt(l); - - core::stringc lmapName = lmprefix; - lmapName += "LMAP_"; - lmapName += (int)(l+1); - os::Printer::log("CCSMLoader loading light map", lmapName.c_str()); - - video::IImage* lmapImg = driver->createImageFromData( - video::ECF_A8R8G8B8, - core::dimension2d(lmap->getWidth(),lmap->getHeight()), - (void *)(lmap->getPixelData())); - - driver->addTexture(lmapName.c_str(), lmapImg); - lmapImg->drop(); - - } - - for(s32 m = 0; mgetMeshCount(); m++) - { - const Mesh* mshPtr = csmFile->getMeshAt(m); - - for(s32 s = 0; s < mshPtr->getSurfaceCount(); s++) - { - const Surface* surface = mshPtr->getSurfaceAt(s); - - core::stringc texName = textureRoot; - texName+= "/"; - texName+= surface->getTextureName(); - - video::ITexture* texture = driver->getTexture(texName.c_str()); - scene::SMeshBufferLightMap *buffer = new scene::SMeshBufferLightMap(); - - //material - core::stringc lmapName = lmprefix; - lmapName += "LMAP_"; - lmapName += (int)surface->getLightMapId(); - - buffer->Material.Textures[0] = texture; - buffer->Material.Textures[1] = driver->getTexture(lmapName.c_str()); - buffer->Material.Lighting = false; - buffer->Material.MaterialType = video::EMT_LIGHTMAP_M4; - - for(u32 v = 0; v < surface->getVertexCount(); v++) - { - const Vertex *vtxPtr = surface->getVertexAt(v); - video::S3DVertex2TCoords vtx; - vtx.Pos = *(vtxPtr->getPosition()); - vtx.Normal = *(vtxPtr->getPosition()); - vtx.Color.set(255,vtxPtr->getColor()->red,vtxPtr->getColor()->green,vtxPtr->getColor()->blue); - vtx.TCoords.set(vtxPtr->getTextureCoordinates()->X,vtxPtr->getTextureCoordinates()->Y); - vtx.TCoords2.set(vtxPtr->getLightMapCoordinates()->X,0.0f - vtxPtr->getLightMapCoordinates()->Y); - - buffer->Vertices.push_back(vtx); - } - - for(s32 t = 0; t < surface->getTriangleCount(); t++) - { - const Triangle& tri = surface->getTriangleAt(t); - buffer->Indices.push_back(tri.a); - buffer->Indices.push_back(tri.c); - buffer->Indices.push_back(tri.b); - } - - buffer->recalculateBoundingBox(); - pMesh->addMeshBuffer(buffer); - buffer->drop(); - } - } - - pMesh->recalculateBoundingBox(); - return pMesh; - } - - const s32 Header::VERSION_4 = 4; - const s32 Header::VERSION_4_1 = 5; - - void Header::load(BinaryFileReader* pReader) - { - version = pReader->readLong(); - } - - void Group::clear() - { - color.clear(); - flags = 0; - parentGroup = 0; - props = ""; - } - - void Group::load(BinaryFileReader* pReader) - { - flags = pReader->readLong(); - parentGroup = pReader->readLong(); - props = pReader->readString(); - pReader->readColorRGB(&color); - } - - void VisGroup::clear() - { - color.clear(); - flags = 0; - name = ""; - - } - - void VisGroup::load(BinaryFileReader* pReader) - { - name = pReader->readString(); - flags = pReader->readLong(); - pReader->readColorRGB(&color); - } - - void LightMap::clear() - { - if(pixelData) - { - delete[] pixelData; - pixelData = 0; - } - width = height = 0; - } - - void LightMap::load(BinaryFileReader* pReader) - { - width = pReader->readLong(); - height = pReader->readLong(); - pixelData = new s32[width * height]; - pReader->readBuffer(pixelData, width * height * sizeof(s32)); - } - - void Mesh::clear() - { - flags = 0; - groupId = 0; - visgroupId = 0; - props = ""; - color.clear(); - position.set(0,0,0); - - for(u32 s = 0; s < surfaces.size(); s++) - { - if(surfaces[s]) - { - delete surfaces[s]; - } - } - surfaces.clear(); - } - - void Mesh::load(BinaryFileReader* pReader, bool bReadVisGroups) - { - flags = pReader->readLong(); - groupId = pReader->readLong(); - props = pReader->readString(); - pReader->readColorRGB(&color); - pReader->readVec3f(&position); - if(bReadVisGroups) - visgroupId = pReader->readLong(); - else - visgroupId = 0; - - s32 count = pReader->readLong(); - - for(s32 i = 0; i < count; i++) - { - Surface* surf = new Surface(); - surf->load(pReader); - surfaces.push_back(surf); - } - } - - void Surface::clear() - { - flags = 0; - lightMapId = 0; - textureName = 0; - uvOffset.set(0.0f,0.0f); - uvScale.set(0.0f,0.0f); - uvRotation = 0.0f; - triangles.clear(); - lines.clear(); - - for(u32 v = 0; v < vertices.size(); v++) - delete vertices[v]; - - vertices.clear(); - } - - void Surface::load(BinaryFileReader* pReader) - { - flags = pReader->readLong(); - textureName = pReader->readString(); - - lightMapId = pReader->readLong(); - pReader->readVec2f(&uvOffset); - pReader->readVec2f(&uvScale); - uvRotation = pReader->readFloat(); - s32 vtxCount = pReader->readLong(); - s32 triCount = pReader->readLong(); - s32 lineCount = pReader->readLong(); - - for(s32 v = 0; v < vtxCount; v++) - { - Vertex *vtx = new Vertex(); - vtx->load(pReader); - vertices.push_back(vtx); - } - - for(s32 t = 0; t < triCount; t++) - { - Triangle tri; - pReader->readBuffer(&tri, sizeof(tri)); - triangles.push_back(tri); - } - - for(s32 l = 0; l < lineCount; l++) - { - Line line; - pReader->readBuffer(&line,sizeof(line)); - lines.push_back(line); - - } - - } - - void Vertex::clear() - { - position.set(0,0,0); - normal.set(0,0,0); - color.clear(); - texCoords.set(0,0,0); - lmapCoords.set(0,0,0); - } - - void Vertex::load(BinaryFileReader* pReader) - { - pReader->readVec3f(&position); - pReader->readVec3f(&normal); - pReader->readColorRGB(&color); - pReader->readVec3f(&texCoords); - pReader->readVec3f(&lmapCoords); - } - - void Entity::clear() - { - visgroupId = groupId = 0; - props = ""; - position.set(0,0,0); - } - - void Entity::load(BinaryFileReader* pReader) - { - visgroupId = pReader->readLong(); - groupId = pReader->readLong(); - props = pReader->readString(); - pReader->readVec3f(&position); - } - - void CameraData::clear() - { - position.set(0,0,0); - pitch = 0; - yaw = 0; - } - - void CameraData::load(BinaryFileReader* pReader) - { - pReader->readVec3f(&position); - pitch = pReader->readFloat(); - yaw = pReader->readFloat(); - } - - void CSMFile::clear() - { - header.clear(); - cameraData.clear(); - - u32 x =0; - for( x= 0; x < groups.size(); x++) - delete groups[x]; - - groups.clear(); - - for(x= 0; x < visgroups.size(); x++) - delete visgroups[x]; - - visgroups.clear(); - - for(x= 0; x < lightmaps.size(); x++) - delete lightmaps[x]; - - lightmaps.clear(); - - for(x= 0; x < meshes.size(); x++) - delete meshes[x]; - - meshes.clear(); - - for(x= 0; x < entities.size(); x++) - delete entities[x]; - - entities.clear(); - } - - void CSMFile::load(BinaryFileReader* pReader) - { - clear(); - - header.load(pReader); - - //groups - { - s32 count = pReader->readLong(); - - for (s32 i = 0; i < count; i++) - { - Group* grp = new Group(); - grp->load(pReader); - groups.push_back(grp); - } - } - bool bHasVGroups = (header.getVersion() == Header::VERSION_4_1); - - if (bHasVGroups) - { - //visgroups - s32 count = pReader->readLong(); - - for (s32 i = 0; i < count; i++) - { - VisGroup* grp = new VisGroup(); - grp->load(pReader); - visgroups.push_back(grp); - } - } - - //lightmaps - { - s32 count = pReader->readLong(); - - for(s32 i = 0; i < count; i++) - { - LightMap* grp = new LightMap(); - grp->load(pReader); - lightmaps.push_back(grp); - } - } - - //meshes - { - s32 count = pReader->readLong(); - - for(s32 i = 0; i < count; i++) - { - Mesh* grp = new Mesh(); - grp->load(pReader,bHasVGroups); - meshes.push_back(grp); - } - } - - //entities - { - s32 count = pReader->readLong(); - - for(s32 i = 0; i < count; i++) - { - Entity* grp = new Entity(); - grp->load(pReader); - entities.push_back(grp); - } - } - - //camera data - cameraData.load(pReader); - - - } - - BinaryFileReader::BinaryFileReader(io::IReadFile* pFile, - bool closeWhenDone) - : file(pFile), autoClose(closeWhenDone) - { - } - - BinaryFileReader::~BinaryFileReader() - { - if(autoClose && file) - { - file->drop(); - file = 0; - - } - } - - s32 BinaryFileReader::readBuffer(void* buffer, s32 len) - { - return file->read(buffer,len); - - } - - s32 BinaryFileReader::readLong() - { - int ret = 0; - readBuffer(&ret,sizeof(int)); - return (s32)ret; - } - - f32 BinaryFileReader::readFloat() - { - float ret = 0; - readBuffer(&ret,sizeof(float)); - return (f32)ret; - } - - u8 BinaryFileReader::readByte() - { - char ret = 0; - readBuffer(&ret,sizeof(char)); - return (u8)ret; - } - - core::stringc BinaryFileReader::readString() - { - core::stringc str = ""; - c8 c = (c8)readByte(); - while(c != 0) - { - str += c; - c = (c8)readByte(); - } - return str; - } - - void BinaryFileReader::readVec3f(core::vector3df* v) - { - v->X = readFloat(); - v->Y = readFloat(); - v->Z = readFloat(); - } - - void BinaryFileReader::readVec2f(core::vector2df* v) - { - v->X = readFloat(); - v->Y = readFloat(); - } - - void BinaryFileReader::readColorRGB(color_rgb_t* color) - { - readBuffer(color,sizeof(color_rgb_t)); - } - -} // end namespace -} // end namespace - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// +// This file was written by Saurav Mohapatra and modified by Nikolaus Gebhardt. +// See CCSMLoader.h for details. + +#include "CCSMLoader.h" +#include "os.h" +#include "IFileSystem.h" +#include "IReadFile.h" +#include "ISceneManager.h" +#include "IAttributes.h" +#include "SMesh.h" +#include "IVideoDriver.h" +#include "SAnimatedMesh.h" +#include "SMeshBufferLightMap.h" + +namespace irr +{ +namespace scene +{ + // + // the CSM data types + // + struct color_rgb_t + { + s32 red; + s32 green; + s32 blue; + + void clear() + { + red = 0; + green = 0; + blue = 0; + } + }; + + class BinaryFileReader; + + // + // The file header + // + class Header + { + public: + + static const s32 VERSION_4; + static const s32 VERSION_4_1; + + Header(){ clear(); } + virtual ~Header(){ clear(); } + + s32 getVersion() const{ return version; } + void clear(){ version = 0; } + void load(BinaryFileReader* pReader); + + private: + + s32 version; + }; + + + // + // The groups + // + class Group + { + public: + + Group(){ clear(); } + virtual ~Group(){ clear(); } + + void clear(); + void load(BinaryFileReader* pReader); + + s32 getFlags() const { return flags; } + s32 getParentGroupID() const { return parentGroup; } + const core::stringc& getProperties() const { return props; } + const color_rgb_t* getColor() const { return &color; } + + private: + + s32 flags; + s32 parentGroup; + core::stringc props; + color_rgb_t color; + }; + + + // + // The visgroups + // + class VisGroup + { + public: + + VisGroup(){ clear(); } + virtual ~VisGroup(){ clear(); } + void clear(); + void load(BinaryFileReader* pReader); + + s32 getFlags() const{ return flags; } + const core::stringc& getName() const{ return name; } + const color_rgb_t* getColor() const{ return &color; } + + private: + + core::stringc name; + s32 flags; + color_rgb_t color; + }; + + + // + // Lightmaps + // + class LightMap + { + public: + + LightMap() : pixelData(0){ clear(); } + virtual ~LightMap(){ clear(); } + void clear(); + void load(BinaryFileReader* pReader); + s32 getWidth() const{ return width; } + s32 getHeight() const{ return height; } + const s32* getPixelData() const{ return pixelData; } + + private: + + s32 width; + s32 height; + s32* pixelData; + }; + + struct Triangle + { + s32 a,b,c; + }; + + + struct Line + { + s32 a,b; + }; + + + class Vertex + { + public: + + Vertex(){ clear(); } + virtual ~Vertex(){ clear(); } + void clear(); + void load(BinaryFileReader* pReader); + + const core::vector3df* getPosition() const { return &position; } + const core::vector3df* getNormal() const { return &normal; } + const color_rgb_t* getColor() const { return &color; } + const core::vector3df* getTextureCoordinates() const { return &texCoords; } + const core::vector3df* getLightMapCoordinates() const { return &lmapCoords; } + + private: + + core::vector3df position; + core::vector3df normal; + color_rgb_t color; + core::vector3df texCoords; + core::vector3df lmapCoords; + }; + + + class Surface + { + public: + + Surface() { clear(); } + virtual ~Surface(){ clear(); } + + void clear(); + void load(BinaryFileReader *pReader); + + s32 getFlags() const{ return flags; } + const core::stringc& getTextureName() const{ return textureName; } + s32 getLightMapId() const{ return lightMapId; } + const core::vector2df* getUVOffset() const{ return &uvOffset; } + const core::vector2df* getUVScale() const{ return &uvScale; } + f32 getUVRotation() const{ return uvRotation; } + + u32 getVertexCount() const{ return vertices.size(); } + const Vertex* getVertexAt(const s32 index) const{ return vertices[index]; } + + s32 getTriangleCount() const{ return triangles.size(); } + const Triangle& getTriangleAt(const s32 index) const{ return triangles[index]; } + + private: + + s32 flags; + core::stringc textureName; + s32 lightMapId; + core::vector2df uvOffset; + core::vector2df uvScale; + f32 uvRotation; + core::array vertices; + core::array triangles; + core::array lines; + }; + + class Mesh + { + public: + + Mesh(){ clear(); } + virtual ~Mesh(){ clear(); } + + void clear(); + void load(BinaryFileReader* pReader, bool bReadVisGroups); + + s32 getFlags() const { return flags; } + s32 getGroupID() const { return groupId; } + const core::stringc& getProperties() const { return props; } + const color_rgb_t* getColor() const { return &color; } + const core::vector3df* getPosition() const { return &position; } + s32 getVisgroupID() const { return visgroupId; } + s32 getSurfaceCount() const { return surfaces.size(); } + const Surface* getSurfaceAt(const s32 index) const { return surfaces[index]; } + + private: + + s32 flags; + s32 groupId; + core::stringc props; + color_rgb_t color; + core::vector3df position; + s32 visgroupId; + + core::array surfaces; + }; + + class Entity + { + public: + + Entity() { clear(); } + virtual ~Entity() { clear(); } + + void clear(); + void load(BinaryFileReader* pReader); + s32 getVisgroupID() const { return visgroupId; } + s32 getGroupID() const { return groupId; } + const core::stringc& getProperties() const { return props; } + const core::vector3df* getPosition() const { return &position; } + + private: + + s32 visgroupId; + s32 groupId; + core::stringc props; + core::vector3df position; + }; + + + class CameraData + { + public: + + CameraData(){ clear(); } + virtual ~CameraData(){ clear(); } + + void clear(); + void load(BinaryFileReader* pReader); + + const core::vector3df* getPosition(){ return &position; } + f32 getPitch(){ return pitch; } + f32 getYaw(){ return yaw; } + + private: + + core::vector3df position; + f32 pitch; + f32 yaw; + }; + + // + // A CSM File + // + class CSMFile + { + public: + + CSMFile(){ clear(); } + virtual ~CSMFile(){ clear(); } + void clear(); + void load(BinaryFileReader* pReader); + + const Header* getHeader() const{ return &header; } + + s32 getGroupCount() const{ return groups.size(); } + const Group* getGroupAt(const s32 index) const{ return groups[index]; } + + s32 getVisGroupCount() const{ return visgroups.size(); } + const VisGroup* getVisGroupAt(const s32 index) const{ return visgroups[index]; } + + s32 getLightMapCount() const{ return lightmaps.size(); } + const LightMap* getLightMapAt(const s32 index) const { return lightmaps[index]; } + + s32 getMeshCount() const{ return meshes.size(); } + const Mesh* getMeshAt(const s32 index) const{ return meshes[index]; } + + s32 getEntityCount() const{ return entities.size(); } + const Entity* getEntityAt(const s32 index) const{ return entities[index]; } + + const CameraData* getCameraData() const{ return &cameraData; } + + private: + + Header header; + core::array groups; + core::array visgroups; + core::array lightmaps; + core::array meshes; + core::array entities; + CameraData cameraData; + }; + + + // + // A Binary File Reader + // + class BinaryFileReader + { + public: + + BinaryFileReader(io::IReadFile* pFile, bool closeWhenDone=true); + virtual ~BinaryFileReader(); + + virtual s32 readBuffer(void* buffer, s32 len); + + s32 readLong(); + f32 readFloat(); + u8 readByte(); + + core::stringc readString(); + void readVec3f(core::vector3df* v); + void readVec2f(core::vector2df* v); + void readColorRGB(color_rgb_t* color); + + private: + + io::IReadFile *file; + bool autoClose; + + }; + + CCSMLoader::CCSMLoader(scene::ISceneManager* manager, io::IFileSystem* fs) + : FileSystem(fs), SceneManager(manager) + { + } + + CCSMLoader::~CCSMLoader() + { + } + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".bsp") + bool CCSMLoader::isALoadableFileExtension(const c8* fileName) + { + return strstr(fileName, ".csm")!=0; + } + + //! creates/loads an animated mesh from the file. + IAnimatedMesh* CCSMLoader::createMesh(irr::io::IReadFile* file) + { + file->grab(); // originally, this loader created the file on its own. + + scene::IMesh* m = createCSMMesh(file); + + if (!m) + return 0; + + SAnimatedMesh* am = new SAnimatedMesh(); + am->Type = EAMT_CSM; + am->addMesh(m); + m->drop(); + + am->recalculateBoundingBox(); + return am; + } + + scene::IMesh* CCSMLoader::createCSMMesh(irr::io::IReadFile* file) + { + if (!file) + return 0; + + if(file) + { + BinaryFileReader reader(file, true); + CSMFile csmFile; + csmFile.load(&reader); + + scene::IMesh* pMesh = createIrrlichtMesh(&csmFile, + SceneManager->getParameters()->getAttributeAsString(CSM_TEXTURE_PATH), + file->getFileName()); + return pMesh; + } + + return 0; + } + + scene::IMesh* CCSMLoader::createIrrlichtMesh(const CSMFile* csmFile, + core::stringc textureRoot, const c8* lmprefix) + { + scene::SMesh *pMesh = new scene::SMesh(); + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + + for(s32 l = 0; lgetLightMapCount(); l++) + { + const LightMap* lmap = csmFile->getLightMapAt(l); + + core::stringc lmapName = lmprefix; + lmapName += "LMAP_"; + lmapName += (int)(l+1); + os::Printer::log("CCSMLoader loading light map", lmapName.c_str()); + + video::IImage* lmapImg = driver->createImageFromData( + video::ECF_A8R8G8B8, + core::dimension2d(lmap->getWidth(),lmap->getHeight()), + (void *)(lmap->getPixelData())); + + driver->addTexture(lmapName.c_str(), lmapImg); + lmapImg->drop(); + + } + + for(s32 m = 0; mgetMeshCount(); m++) + { + const Mesh* mshPtr = csmFile->getMeshAt(m); + + for(s32 s = 0; s < mshPtr->getSurfaceCount(); s++) + { + const Surface* surface = mshPtr->getSurfaceAt(s); + + core::stringc texName = textureRoot; + texName+= "/"; + texName+= surface->getTextureName(); + + video::ITexture* texture = driver->getTexture(texName.c_str()); + scene::SMeshBufferLightMap *buffer = new scene::SMeshBufferLightMap(); + + //material + core::stringc lmapName = lmprefix; + lmapName += "LMAP_"; + lmapName += (int)surface->getLightMapId(); + + buffer->Material.Textures[0] = texture; + buffer->Material.Textures[1] = driver->getTexture(lmapName.c_str()); + buffer->Material.Lighting = false; + buffer->Material.MaterialType = video::EMT_LIGHTMAP_M4; + + for(u32 v = 0; v < surface->getVertexCount(); v++) + { + const Vertex *vtxPtr = surface->getVertexAt(v); + video::S3DVertex2TCoords vtx; + vtx.Pos = *(vtxPtr->getPosition()); + vtx.Normal = *(vtxPtr->getPosition()); + vtx.Color.set(255,vtxPtr->getColor()->red,vtxPtr->getColor()->green,vtxPtr->getColor()->blue); + vtx.TCoords.set(vtxPtr->getTextureCoordinates()->X,vtxPtr->getTextureCoordinates()->Y); + vtx.TCoords2.set(vtxPtr->getLightMapCoordinates()->X,0.0f - vtxPtr->getLightMapCoordinates()->Y); + + buffer->Vertices.push_back(vtx); + } + + for(s32 t = 0; t < surface->getTriangleCount(); t++) + { + const Triangle& tri = surface->getTriangleAt(t); + buffer->Indices.push_back(tri.a); + buffer->Indices.push_back(tri.c); + buffer->Indices.push_back(tri.b); + } + + buffer->recalculateBoundingBox(); + pMesh->addMeshBuffer(buffer); + buffer->drop(); + } + } + + pMesh->recalculateBoundingBox(); + return pMesh; + } + + const s32 Header::VERSION_4 = 4; + const s32 Header::VERSION_4_1 = 5; + + void Header::load(BinaryFileReader* pReader) + { + version = pReader->readLong(); + } + + void Group::clear() + { + color.clear(); + flags = 0; + parentGroup = 0; + props = ""; + } + + void Group::load(BinaryFileReader* pReader) + { + flags = pReader->readLong(); + parentGroup = pReader->readLong(); + props = pReader->readString(); + pReader->readColorRGB(&color); + } + + void VisGroup::clear() + { + color.clear(); + flags = 0; + name = ""; + + } + + void VisGroup::load(BinaryFileReader* pReader) + { + name = pReader->readString(); + flags = pReader->readLong(); + pReader->readColorRGB(&color); + } + + void LightMap::clear() + { + if(pixelData) + { + delete[] pixelData; + pixelData = 0; + } + width = height = 0; + } + + void LightMap::load(BinaryFileReader* pReader) + { + width = pReader->readLong(); + height = pReader->readLong(); + pixelData = new s32[width * height]; + pReader->readBuffer(pixelData, width * height * sizeof(s32)); + } + + void Mesh::clear() + { + flags = 0; + groupId = 0; + visgroupId = 0; + props = ""; + color.clear(); + position.set(0,0,0); + + for(u32 s = 0; s < surfaces.size(); s++) + { + if(surfaces[s]) + { + delete surfaces[s]; + } + } + surfaces.clear(); + } + + void Mesh::load(BinaryFileReader* pReader, bool bReadVisGroups) + { + flags = pReader->readLong(); + groupId = pReader->readLong(); + props = pReader->readString(); + pReader->readColorRGB(&color); + pReader->readVec3f(&position); + if(bReadVisGroups) + visgroupId = pReader->readLong(); + else + visgroupId = 0; + + s32 count = pReader->readLong(); + + for(s32 i = 0; i < count; i++) + { + Surface* surf = new Surface(); + surf->load(pReader); + surfaces.push_back(surf); + } + } + + void Surface::clear() + { + flags = 0; + lightMapId = 0; + textureName = 0; + uvOffset.set(0.0f,0.0f); + uvScale.set(0.0f,0.0f); + uvRotation = 0.0f; + triangles.clear(); + lines.clear(); + + for(u32 v = 0; v < vertices.size(); v++) + delete vertices[v]; + + vertices.clear(); + } + + void Surface::load(BinaryFileReader* pReader) + { + flags = pReader->readLong(); + textureName = pReader->readString(); + + lightMapId = pReader->readLong(); + pReader->readVec2f(&uvOffset); + pReader->readVec2f(&uvScale); + uvRotation = pReader->readFloat(); + s32 vtxCount = pReader->readLong(); + s32 triCount = pReader->readLong(); + s32 lineCount = pReader->readLong(); + + for(s32 v = 0; v < vtxCount; v++) + { + Vertex *vtx = new Vertex(); + vtx->load(pReader); + vertices.push_back(vtx); + } + + for(s32 t = 0; t < triCount; t++) + { + Triangle tri; + pReader->readBuffer(&tri, sizeof(tri)); + triangles.push_back(tri); + } + + for(s32 l = 0; l < lineCount; l++) + { + Line line; + pReader->readBuffer(&line,sizeof(line)); + lines.push_back(line); + + } + + } + + void Vertex::clear() + { + position.set(0,0,0); + normal.set(0,0,0); + color.clear(); + texCoords.set(0,0,0); + lmapCoords.set(0,0,0); + } + + void Vertex::load(BinaryFileReader* pReader) + { + pReader->readVec3f(&position); + pReader->readVec3f(&normal); + pReader->readColorRGB(&color); + pReader->readVec3f(&texCoords); + pReader->readVec3f(&lmapCoords); + } + + void Entity::clear() + { + visgroupId = groupId = 0; + props = ""; + position.set(0,0,0); + } + + void Entity::load(BinaryFileReader* pReader) + { + visgroupId = pReader->readLong(); + groupId = pReader->readLong(); + props = pReader->readString(); + pReader->readVec3f(&position); + } + + void CameraData::clear() + { + position.set(0,0,0); + pitch = 0; + yaw = 0; + } + + void CameraData::load(BinaryFileReader* pReader) + { + pReader->readVec3f(&position); + pitch = pReader->readFloat(); + yaw = pReader->readFloat(); + } + + void CSMFile::clear() + { + header.clear(); + cameraData.clear(); + + u32 x =0; + for( x= 0; x < groups.size(); x++) + delete groups[x]; + + groups.clear(); + + for(x= 0; x < visgroups.size(); x++) + delete visgroups[x]; + + visgroups.clear(); + + for(x= 0; x < lightmaps.size(); x++) + delete lightmaps[x]; + + lightmaps.clear(); + + for(x= 0; x < meshes.size(); x++) + delete meshes[x]; + + meshes.clear(); + + for(x= 0; x < entities.size(); x++) + delete entities[x]; + + entities.clear(); + } + + void CSMFile::load(BinaryFileReader* pReader) + { + clear(); + + header.load(pReader); + + //groups + { + s32 count = pReader->readLong(); + + for (s32 i = 0; i < count; i++) + { + Group* grp = new Group(); + grp->load(pReader); + groups.push_back(grp); + } + } + bool bHasVGroups = (header.getVersion() == Header::VERSION_4_1); + + if (bHasVGroups) + { + //visgroups + s32 count = pReader->readLong(); + + for (s32 i = 0; i < count; i++) + { + VisGroup* grp = new VisGroup(); + grp->load(pReader); + visgroups.push_back(grp); + } + } + + //lightmaps + { + s32 count = pReader->readLong(); + + for(s32 i = 0; i < count; i++) + { + LightMap* grp = new LightMap(); + grp->load(pReader); + lightmaps.push_back(grp); + } + } + + //meshes + { + s32 count = pReader->readLong(); + + for(s32 i = 0; i < count; i++) + { + Mesh* grp = new Mesh(); + grp->load(pReader,bHasVGroups); + meshes.push_back(grp); + } + } + + //entities + { + s32 count = pReader->readLong(); + + for(s32 i = 0; i < count; i++) + { + Entity* grp = new Entity(); + grp->load(pReader); + entities.push_back(grp); + } + } + + //camera data + cameraData.load(pReader); + + + } + + BinaryFileReader::BinaryFileReader(io::IReadFile* pFile, + bool closeWhenDone) + : file(pFile), autoClose(closeWhenDone) + { + } + + BinaryFileReader::~BinaryFileReader() + { + if(autoClose && file) + { + file->drop(); + file = 0; + + } + } + + s32 BinaryFileReader::readBuffer(void* buffer, s32 len) + { + return file->read(buffer,len); + + } + + s32 BinaryFileReader::readLong() + { + int ret = 0; + readBuffer(&ret,sizeof(int)); + return (s32)ret; + } + + f32 BinaryFileReader::readFloat() + { + float ret = 0; + readBuffer(&ret,sizeof(float)); + return (f32)ret; + } + + u8 BinaryFileReader::readByte() + { + char ret = 0; + readBuffer(&ret,sizeof(char)); + return (u8)ret; + } + + core::stringc BinaryFileReader::readString() + { + core::stringc str = ""; + c8 c = (c8)readByte(); + while(c != 0) + { + str += c; + c = (c8)readByte(); + } + return str; + } + + void BinaryFileReader::readVec3f(core::vector3df* v) + { + v->X = readFloat(); + v->Y = readFloat(); + v->Z = readFloat(); + } + + void BinaryFileReader::readVec2f(core::vector2df* v) + { + v->X = readFloat(); + v->Y = readFloat(); + } + + void BinaryFileReader::readColorRGB(color_rgb_t* color) + { + readBuffer(color,sizeof(color_rgb_t)); + } + +} // end namespace +} // end namespace + diff --git a/src/dep/src/irrlicht/CCSMLoader.h b/src/dep/src/irrlicht/CCSMLoader.h index e2c6051..1d38f87 100644 --- a/src/dep/src/irrlicht/CCSMLoader.h +++ b/src/dep/src/irrlicht/CCSMLoader.h @@ -1,83 +1,83 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This Loader has been originally written by Saurav Mohapatra. I (Nikolaus Gebhardt) -// modified some minor things and integrated it into Irrlicht 0.9. Thanks a lot -// to Saurav Mohapatra for his work on this and that he gave me his permission to -// add it into Irrlicht. -// I did some changes to Saurav Mohapatra's loader, so I'm writing this down here: -// - Replaced all dependencies to STL and stdio with irr:: methods/constructs. -// - Moved everything into namespace irr::scene -// - Replaced logging with Irrlicht's internal logger. -// - Removed dependency to IrrlichtDevice -// - Moved all internal structures into CCSMLoader.cpp -// - Made the texture root parameter dependent on a ISceneManager string parameter -// - removed exceptions -// - Implemented CCCSMLoader as IMeshLoader -// - Fixed some problems with memory leaks -// - Fixed bounding box calculation -// -// The original readme of this file looks like this: -// -// This component provides a loader for the Cartography shop 4.x .csm maps for Irrlicht Engine. -// This is a part of the M_TRIX Project. -// This is licensed under the ZLib/LibPNG license -// The IrrCSM library is written by Saurav Mohapatra. -// -// Features -// -// The IrrCSM library features the following capabilities -// -// * Loads the .csm 4.0 and 4.1 files transparently -// * Presents the loaded file as irr::scene::IAnimatedMesh for easy creation of IOctTreeSceneNode -// * Loads the textures given the correct texture root. hence map and textures can be in separate directories -// -// For more informations go to http://www.geocities.com/standard_template/irrcsm/downloads.html - -#ifndef __CSM_LOADER_H_INCLUDED__ -#define __CSM_LOADER_H_INCLUDED__ - -#include "irrArray.h" -#include "IMesh.h" -#include "irrString.h" -#include "IFileSystem.h" -#include "IMeshLoader.h" - -namespace irr -{ -namespace scene -{ - class CSMFile; - class ISceneManager; - - class CCSMLoader : public scene::IMeshLoader - { - public: - - CCSMLoader(ISceneManager* manager, io::IFileSystem* fs); - virtual ~CCSMLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".bsp") - virtual bool isALoadableFileExtension(const c8* fileName); - - //! creates/loads an animated mesh from the file. - virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); - - private: - - scene::IMesh* createCSMMesh(irr::io::IReadFile* file); - - scene::IMesh* createIrrlichtMesh(const CSMFile* csmFile, - core::stringc textureRoot, const c8* lmprefix); - - io::IFileSystem* FileSystem; - scene::ISceneManager* SceneManager; - }; - -} // end namespace -} // end namespace - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// +// This Loader has been originally written by Saurav Mohapatra. I (Nikolaus Gebhardt) +// modified some minor things and integrated it into Irrlicht 0.9. Thanks a lot +// to Saurav Mohapatra for his work on this and that he gave me his permission to +// add it into Irrlicht. +// I did some changes to Saurav Mohapatra's loader, so I'm writing this down here: +// - Replaced all dependencies to STL and stdio with irr:: methods/constructs. +// - Moved everything into namespace irr::scene +// - Replaced logging with Irrlicht's internal logger. +// - Removed dependency to IrrlichtDevice +// - Moved all internal structures into CCSMLoader.cpp +// - Made the texture root parameter dependent on a ISceneManager string parameter +// - removed exceptions +// - Implemented CCCSMLoader as IMeshLoader +// - Fixed some problems with memory leaks +// - Fixed bounding box calculation +// +// The original readme of this file looks like this: +// +// This component provides a loader for the Cartography shop 4.x .csm maps for Irrlicht Engine. +// This is a part of the M_TRIX Project. +// This is licensed under the ZLib/LibPNG license +// The IrrCSM library is written by Saurav Mohapatra. +// +// Features +// +// The IrrCSM library features the following capabilities +// +// * Loads the .csm 4.0 and 4.1 files transparently +// * Presents the loaded file as irr::scene::IAnimatedMesh for easy creation of IOctTreeSceneNode +// * Loads the textures given the correct texture root. hence map and textures can be in separate directories +// +// For more informations go to http://www.geocities.com/standard_template/irrcsm/downloads.html + +#ifndef __CSM_LOADER_H_INCLUDED__ +#define __CSM_LOADER_H_INCLUDED__ + +#include "irrArray.h" +#include "IMesh.h" +#include "irrString.h" +#include "IFileSystem.h" +#include "IMeshLoader.h" + +namespace irr +{ +namespace scene +{ + class CSMFile; + class ISceneManager; + + class CCSMLoader : public scene::IMeshLoader + { + public: + + CCSMLoader(ISceneManager* manager, io::IFileSystem* fs); + virtual ~CCSMLoader(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".bsp") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! creates/loads an animated mesh from the file. + virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); + + private: + + scene::IMesh* createCSMMesh(irr::io::IReadFile* file); + + scene::IMesh* createIrrlichtMesh(const CSMFile* csmFile, + core::stringc textureRoot, const c8* lmprefix); + + io::IFileSystem* FileSystem; + scene::ISceneManager* SceneManager; + }; + +} // end namespace +} // end namespace + +#endif + diff --git a/src/dep/src/irrlicht/CCameraFPSSceneNode.cpp b/src/dep/src/irrlicht/CCameraFPSSceneNode.cpp index 032a054..0dc500f 100644 --- a/src/dep/src/irrlicht/CCameraFPSSceneNode.cpp +++ b/src/dep/src/irrlicht/CCameraFPSSceneNode.cpp @@ -1,303 +1,303 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CCameraFPSSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "os.h" -#include "Keycodes.h" -#include "quaternion.h" - -namespace irr -{ -namespace scene -{ - -const f32 MAX_VERTICAL_ANGLE = 88.0f; - -//! constructor -CCameraFPSSceneNode::CCameraFPSSceneNode(ISceneNode* parent, ISceneManager* mgr, - gui::ICursorControl* cursorControl, s32 id, f32 rotateSpeed , f32 moveSpeed,f32 jumpSpeed, - SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement) -: CCameraSceneNode(parent, mgr, id), CursorControl(cursorControl), - MoveSpeed(moveSpeed), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed), - firstUpdate(true), LastAnimationTime(0), NoVerticalMovement(noVerticalMovement) -{ - #ifdef _DEBUG - setDebugName("CCameraFPSSceneNode"); - #endif - - if (CursorControl) - CursorControl->grab(); - - MoveSpeed /= 1000.0f; - - recalculateViewArea(); - - allKeysUp(); - - // create key map - if (!keyMapArray || !keyMapSize) - { - // create default key map - KeyMap.push_back(SCamKeyMap(0, irr::KEY_UP)); - KeyMap.push_back(SCamKeyMap(1, irr::KEY_DOWN)); - KeyMap.push_back(SCamKeyMap(2, irr::KEY_LEFT)); - KeyMap.push_back(SCamKeyMap(3, irr::KEY_RIGHT)); - KeyMap.push_back(SCamKeyMap(4, irr::KEY_KEY_J)); - } - else - { - // create custom key map - - for (s32 i=0; idrop(); -} - - -//! It is possible to send mouse and key events to the camera. Most cameras -//! may ignore this input, but camera scene nodes which are created for -//! example with scene::ISceneManager::addMayaCameraSceneNode or -//! scene::ISceneManager::addFPSCameraSceneNode, may want to get this input -//! for changing their position, look at target or whatever. -bool CCameraFPSSceneNode::OnEvent(SEvent event) -{ - if (event.EventType == EET_KEY_INPUT_EVENT) - { - const u32 cnt = KeyMap.size(); - for (u32 i=0; i::Iterator ait = Animators.begin(); - for (; ait != Animators.end(); ++ait) - (*ait)->animateNode(this, timeMs); - - updateAbsolutePosition(); - Target = getPosition() + TargetVector; - - core::list::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - (*it)->OnAnimate(timeMs); -} - - -void CCameraFPSSceneNode::animate( u32 timeMs ) -{ - const u32 camIsMe = SceneManager->getActiveCamera() == this; - - if (firstUpdate) - { - if (CursorControl && camIsMe) - { - CursorControl->setPosition(0.5f, 0.5f); - CenterCursor = CursorControl->getRelativePosition(); - } - - LastAnimationTime = os::Timer::getTime(); - - firstUpdate = false; - } - - // get time. only operate on valid camera - f32 timeDiff = 0.f; - - if ( camIsMe ) - { - timeDiff = (f32) ( timeMs - LastAnimationTime ); - LastAnimationTime = timeMs; - } - - - // update position - core::vector3df pos = getPosition(); - - // Update rotation -// if (InputReceiverEnabled) - { - Target.set(0,0,1); - - - if (CursorControl && InputReceiverEnabled && camIsMe ) - { - core::position2d cursorpos = CursorControl->getRelativePosition(); - - if (!core::equals(cursorpos.X, CenterCursor.X) || - !core::equals(cursorpos.Y, CenterCursor.Y)) - { - RelativeRotation.X *= -1.0f; - RelativeRotation.Y *= -1.0f; - - RelativeRotation.Y += (0.5f - cursorpos.X) * RotateSpeed; - RelativeRotation.X = core::clamp ( RelativeRotation.X + (0.5f - cursorpos.Y) * RotateSpeed, - -MAX_VERTICAL_ANGLE, - +MAX_VERTICAL_ANGLE - ); - - RelativeRotation.X *= -1.0f; - RelativeRotation.Y *= -1.0f; - - CursorControl->setPosition(0.5f, 0.5f); - CenterCursor = CursorControl->getRelativePosition(); - } - } - - // set target - - core::matrix4 mat; - mat.setRotationDegrees(core::vector3df( RelativeRotation.X, RelativeRotation.Y, 0)); - mat.transformVect(Target); - - core::vector3df movedir = Target; - - if (NoVerticalMovement) - movedir.Y = 0.f; - - movedir.normalize(); - - if (InputReceiverEnabled && camIsMe) - { - if (CursorKeys[0]) - pos += movedir * timeDiff * MoveSpeed; - - if (CursorKeys[1]) - pos -= movedir * timeDiff * MoveSpeed; - - // strafing - - core::vector3df strafevect = Target; - strafevect = strafevect.crossProduct(UpVector); - - if (NoVerticalMovement) - strafevect.Y = 0.0f; - - strafevect.normalize(); - - if (CursorKeys[2]) - pos += strafevect * timeDiff * MoveSpeed; - - if (CursorKeys[3]) - pos -= strafevect * timeDiff * MoveSpeed; - - // jumping ( need's a gravity , else it's a fly to the World-UpVector ) - if (CursorKeys[4]) - { - pos += UpVector * timeDiff * JumpSpeed; - } - } - - // write translation - - setPosition(pos); - } - - // write right target - - TargetVector = Target; - Target += pos; - -} - -void CCameraFPSSceneNode::allKeysUp() -{ - for (s32 i=0; i<6; ++i) - CursorKeys[i] = false; -} - - -//! sets the look at target of the camera -//! \param pos: Look at target of the camera. -void CCameraFPSSceneNode::setTarget(const core::vector3df& tgt) -{ - updateAbsolutePosition(); - core::vector3df vect = tgt - getAbsolutePosition(); - vect = vect.getHorizontalAngle(); - RelativeRotation.X = vect.X; - RelativeRotation.Y = vect.Y; - - if (RelativeRotation.X > MAX_VERTICAL_ANGLE) - RelativeRotation.X -= 360.0f; -} - -//! Disables or enables the camera to get key or mouse inputs. -void CCameraFPSSceneNode::setInputReceiverEnabled(bool enabled) -{ - // So we don't skip when we return from a non-enabled mode and the - // mouse cursor is now not in the middle of the screen - if( !InputReceiverEnabled && enabled ) - firstUpdate = true; - - InputReceiverEnabled = enabled; -} - -//! Sets the rotation speed -void CCameraFPSSceneNode::setRotateSpeed(const f32 speed) -{ - RotateSpeed = speed; -} - -//! Sets the movement speed -void CCameraFPSSceneNode::setMoveSpeed(const f32 speed) -{ - MoveSpeed = speed; -} - -//! Gets the rotation speed -f32 CCameraFPSSceneNode::getRotateSpeed() -{ - return RotateSpeed; -} - -// Gets the movement speed -f32 CCameraFPSSceneNode::getMoveSpeed() -{ - return MoveSpeed; -} - -} // end namespace -} // end namespace - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CCameraFPSSceneNode.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" +#include "os.h" +#include "Keycodes.h" +#include "quaternion.h" + +namespace irr +{ +namespace scene +{ + +const f32 MAX_VERTICAL_ANGLE = 88.0f; + +//! constructor +CCameraFPSSceneNode::CCameraFPSSceneNode(ISceneNode* parent, ISceneManager* mgr, + gui::ICursorControl* cursorControl, s32 id, f32 rotateSpeed , f32 moveSpeed,f32 jumpSpeed, + SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement) +: CCameraSceneNode(parent, mgr, id), CursorControl(cursorControl), + MoveSpeed(moveSpeed), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed), + firstUpdate(true), LastAnimationTime(0), NoVerticalMovement(noVerticalMovement) +{ + #ifdef _DEBUG + setDebugName("CCameraFPSSceneNode"); + #endif + + if (CursorControl) + CursorControl->grab(); + + MoveSpeed /= 1000.0f; + + recalculateViewArea(); + + allKeysUp(); + + // create key map + if (!keyMapArray || !keyMapSize) + { + // create default key map + KeyMap.push_back(SCamKeyMap(0, irr::KEY_UP)); + KeyMap.push_back(SCamKeyMap(1, irr::KEY_DOWN)); + KeyMap.push_back(SCamKeyMap(2, irr::KEY_LEFT)); + KeyMap.push_back(SCamKeyMap(3, irr::KEY_RIGHT)); + KeyMap.push_back(SCamKeyMap(4, irr::KEY_KEY_J)); + } + else + { + // create custom key map + + for (s32 i=0; idrop(); +} + + +//! It is possible to send mouse and key events to the camera. Most cameras +//! may ignore this input, but camera scene nodes which are created for +//! example with scene::ISceneManager::addMayaCameraSceneNode or +//! scene::ISceneManager::addFPSCameraSceneNode, may want to get this input +//! for changing their position, look at target or whatever. +bool CCameraFPSSceneNode::OnEvent(SEvent event) +{ + if (event.EventType == EET_KEY_INPUT_EVENT) + { + const u32 cnt = KeyMap.size(); + for (u32 i=0; i::Iterator ait = Animators.begin(); + for (; ait != Animators.end(); ++ait) + (*ait)->animateNode(this, timeMs); + + updateAbsolutePosition(); + Target = getPosition() + TargetVector; + + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + (*it)->OnAnimate(timeMs); +} + + +void CCameraFPSSceneNode::animate( u32 timeMs ) +{ + const u32 camIsMe = SceneManager->getActiveCamera() == this; + + if (firstUpdate) + { + if (CursorControl && camIsMe) + { + CursorControl->setPosition(0.5f, 0.5f); + CenterCursor = CursorControl->getRelativePosition(); + } + + LastAnimationTime = os::Timer::getTime(); + + firstUpdate = false; + } + + // get time. only operate on valid camera + f32 timeDiff = 0.f; + + if ( camIsMe ) + { + timeDiff = (f32) ( timeMs - LastAnimationTime ); + LastAnimationTime = timeMs; + } + + + // update position + core::vector3df pos = getPosition(); + + // Update rotation +// if (InputReceiverEnabled) + { + Target.set(0,0,1); + + + if (CursorControl && InputReceiverEnabled && camIsMe ) + { + core::position2d cursorpos = CursorControl->getRelativePosition(); + + if (!core::equals(cursorpos.X, CenterCursor.X) || + !core::equals(cursorpos.Y, CenterCursor.Y)) + { + RelativeRotation.X *= -1.0f; + RelativeRotation.Y *= -1.0f; + + RelativeRotation.Y += (0.5f - cursorpos.X) * RotateSpeed; + RelativeRotation.X = core::clamp ( RelativeRotation.X + (0.5f - cursorpos.Y) * RotateSpeed, + -MAX_VERTICAL_ANGLE, + +MAX_VERTICAL_ANGLE + ); + + RelativeRotation.X *= -1.0f; + RelativeRotation.Y *= -1.0f; + + CursorControl->setPosition(0.5f, 0.5f); + CenterCursor = CursorControl->getRelativePosition(); + } + } + + // set target + + core::matrix4 mat; + mat.setRotationDegrees(core::vector3df( RelativeRotation.X, RelativeRotation.Y, 0)); + mat.transformVect(Target); + + core::vector3df movedir = Target; + + if (NoVerticalMovement) + movedir.Y = 0.f; + + movedir.normalize(); + + if (InputReceiverEnabled && camIsMe) + { + if (CursorKeys[0]) + pos += movedir * timeDiff * MoveSpeed; + + if (CursorKeys[1]) + pos -= movedir * timeDiff * MoveSpeed; + + // strafing + + core::vector3df strafevect = Target; + strafevect = strafevect.crossProduct(UpVector); + + if (NoVerticalMovement) + strafevect.Y = 0.0f; + + strafevect.normalize(); + + if (CursorKeys[2]) + pos += strafevect * timeDiff * MoveSpeed; + + if (CursorKeys[3]) + pos -= strafevect * timeDiff * MoveSpeed; + + // jumping ( need's a gravity , else it's a fly to the World-UpVector ) + if (CursorKeys[4]) + { + pos += UpVector * timeDiff * JumpSpeed; + } + } + + // write translation + + setPosition(pos); + } + + // write right target + + TargetVector = Target; + Target += pos; + +} + +void CCameraFPSSceneNode::allKeysUp() +{ + for (s32 i=0; i<6; ++i) + CursorKeys[i] = false; +} + + +//! sets the look at target of the camera +//! \param pos: Look at target of the camera. +void CCameraFPSSceneNode::setTarget(const core::vector3df& tgt) +{ + updateAbsolutePosition(); + core::vector3df vect = tgt - getAbsolutePosition(); + vect = vect.getHorizontalAngle(); + RelativeRotation.X = vect.X; + RelativeRotation.Y = vect.Y; + + if (RelativeRotation.X > MAX_VERTICAL_ANGLE) + RelativeRotation.X -= 360.0f; +} + +//! Disables or enables the camera to get key or mouse inputs. +void CCameraFPSSceneNode::setInputReceiverEnabled(bool enabled) +{ + // So we don't skip when we return from a non-enabled mode and the + // mouse cursor is now not in the middle of the screen + if( !InputReceiverEnabled && enabled ) + firstUpdate = true; + + InputReceiverEnabled = enabled; +} + +//! Sets the rotation speed +void CCameraFPSSceneNode::setRotateSpeed(const f32 speed) +{ + RotateSpeed = speed; +} + +//! Sets the movement speed +void CCameraFPSSceneNode::setMoveSpeed(const f32 speed) +{ + MoveSpeed = speed; +} + +//! Gets the rotation speed +f32 CCameraFPSSceneNode::getRotateSpeed() +{ + return RotateSpeed; +} + +// Gets the movement speed +f32 CCameraFPSSceneNode::getMoveSpeed() +{ + return MoveSpeed; +} + +} // end namespace +} // end namespace + diff --git a/src/dep/src/irrlicht/CCameraFPSSceneNode.h b/src/dep/src/irrlicht/CCameraFPSSceneNode.h index 3b48ce9..4c35a48 100644 --- a/src/dep/src/irrlicht/CCameraFPSSceneNode.h +++ b/src/dep/src/irrlicht/CCameraFPSSceneNode.h @@ -1,104 +1,104 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_CAMERA_FPS_SCENE_NODE_H_INCLUDED__ -#define __C_CAMERA_FPS_SCENE_NODE_H_INCLUDED__ - -#include "ICursorControl.h" -#include "CCameraSceneNode.h" -#include "vector2d.h" -#include "SKeyMap.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - - class CCameraFPSSceneNode : public CCameraSceneNode - { - public: - - //! constructor - CCameraFPSSceneNode(ISceneNode* parent, ISceneManager* mgr, - gui::ICursorControl* cursorControl, s32 id, - f32 rotateSpeed, f32 moveSpeed,f32 jumpSpeed, - SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement = false ); - - //! destructor - virtual ~CCameraFPSSceneNode(); - - //! It is possible to send mouse and key events to the camera. Most cameras - //! may ignore this input, but camera scene nodes which are created for - //! example with scene::ISceneManager::addMayaCameraSceneNode or - //! scene::ISceneManager::addMeshViewerCameraSceneNode, may want to get this input - //! for changing their position, look at target or whatever. - virtual bool OnEvent(SEvent event); - - //! OnAnimate() is called just before rendering the whole scene. - //! nodes may calculate or store animations here, and may do other useful things, - //! dependent on what they are. - virtual void OnAnimate(u32 timeMs); - - //! sets the look at target of the camera - //! \param pos: Look at target of the camera. - virtual void setTarget(const core::vector3df& pos); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_CAMERA_FPS; } - - //! Disables or enables the camera to get key or mouse inputs. - //! If this is set to true, the camera will respond to key inputs - //! otherwise not. - virtual void setInputReceiverEnabled(bool enabled); - - //! Sets the speed that this camera rotates - virtual void setRotateSpeed(const f32 speed); - - //! Sets the speed that this camera moves - virtual void setMoveSpeed(const f32 speed); - - //! Gets the rotation speed - virtual f32 getRotateSpeed(); - - // Gets the movement speed - virtual f32 getMoveSpeed(); - - private: - - struct SCamKeyMap - { - SCamKeyMap() {}; - SCamKeyMap(s32 a, EKEY_CODE k) : action(a), keycode(k) {} - - s32 action; - EKEY_CODE keycode; - }; - - void allKeysUp(); - void animate( u32 timeMs ); - - bool CursorKeys[6]; - - gui::ICursorControl* CursorControl; - - f32 MoveSpeed; - f32 RotateSpeed; - f32 JumpSpeed; - - bool firstUpdate; - s32 LastAnimationTime; - - core::vector3df TargetVector; - core::array KeyMap; - core::position2d CenterCursor; - - bool NoVerticalMovement; - }; - -} // end namespace -} // end namespace - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_CAMERA_FPS_SCENE_NODE_H_INCLUDED__ +#define __C_CAMERA_FPS_SCENE_NODE_H_INCLUDED__ + +#include "ICursorControl.h" +#include "CCameraSceneNode.h" +#include "vector2d.h" +#include "SKeyMap.h" +#include "irrArray.h" + +namespace irr +{ +namespace scene +{ + + class CCameraFPSSceneNode : public CCameraSceneNode + { + public: + + //! constructor + CCameraFPSSceneNode(ISceneNode* parent, ISceneManager* mgr, + gui::ICursorControl* cursorControl, s32 id, + f32 rotateSpeed, f32 moveSpeed,f32 jumpSpeed, + SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement = false ); + + //! destructor + virtual ~CCameraFPSSceneNode(); + + //! It is possible to send mouse and key events to the camera. Most cameras + //! may ignore this input, but camera scene nodes which are created for + //! example with scene::ISceneManager::addMayaCameraSceneNode or + //! scene::ISceneManager::addMeshViewerCameraSceneNode, may want to get this input + //! for changing their position, look at target or whatever. + virtual bool OnEvent(SEvent event); + + //! OnAnimate() is called just before rendering the whole scene. + //! nodes may calculate or store animations here, and may do other useful things, + //! dependent on what they are. + virtual void OnAnimate(u32 timeMs); + + //! sets the look at target of the camera + //! \param pos: Look at target of the camera. + virtual void setTarget(const core::vector3df& pos); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_CAMERA_FPS; } + + //! Disables or enables the camera to get key or mouse inputs. + //! If this is set to true, the camera will respond to key inputs + //! otherwise not. + virtual void setInputReceiverEnabled(bool enabled); + + //! Sets the speed that this camera rotates + virtual void setRotateSpeed(const f32 speed); + + //! Sets the speed that this camera moves + virtual void setMoveSpeed(const f32 speed); + + //! Gets the rotation speed + virtual f32 getRotateSpeed(); + + // Gets the movement speed + virtual f32 getMoveSpeed(); + + private: + + struct SCamKeyMap + { + SCamKeyMap() {}; + SCamKeyMap(s32 a, EKEY_CODE k) : action(a), keycode(k) {} + + s32 action; + EKEY_CODE keycode; + }; + + void allKeysUp(); + void animate( u32 timeMs ); + + bool CursorKeys[6]; + + gui::ICursorControl* CursorControl; + + f32 MoveSpeed; + f32 RotateSpeed; + f32 JumpSpeed; + + bool firstUpdate; + s32 LastAnimationTime; + + core::vector3df TargetVector; + core::array KeyMap; + core::position2d CenterCursor; + + bool NoVerticalMovement; + }; + +} // end namespace +} // end namespace + +#endif + diff --git a/src/dep/src/irrlicht/CCameraMayaSceneNode.cpp b/src/dep/src/irrlicht/CCameraMayaSceneNode.cpp index 27b8008..29ada4e 100644 --- a/src/dep/src/irrlicht/CCameraMayaSceneNode.cpp +++ b/src/dep/src/irrlicht/CCameraMayaSceneNode.cpp @@ -1,329 +1,329 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CCameraMayaSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CCameraMayaSceneNode::CCameraMayaSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - f32 rs, f32 zs, f32 ts) -: CCameraSceneNode(parent, mgr, id), - zooming(false), rotating(false), moving(false), translating(false), - zoomSpeed(zs), rotateSpeed(ts), translateSpeed(ts), - rotateStartX(0.0f), rotateStartY(0.0f), zoomStartX(0.0f), zoomStartY(0.0f), - translateStartX(0.0f), translateStartY(0.0f), currentZoom(70.0f), rotX(0.0f), rotY(0.0f) -{ - #ifdef _DEBUG - setDebugName("CCameraMayaSceneNode"); - #endif - - Target.set(0.0f, 0.0f, 0.0f); - oldTarget = Target; - - allKeysUp(); - recalculateViewArea(); -} - - -//! destructor -CCameraMayaSceneNode::~CCameraMayaSceneNode() -{ -} - - -//! It is possible to send mouse and key events to the camera. Most cameras -//! may ignore this input, but camera scene nodes which are created for -//! example with scene::ISceneManager::addMayaCameraSceneNode or -//! scene::ISceneManager::addMeshViewerCameraSceneNode, may want to get this input -//! for changing their position, look at target or whatever. -bool CCameraMayaSceneNode::OnEvent(SEvent event) -{ - if (event.EventType != EET_MOUSE_INPUT_EVENT || - !InputReceiverEnabled) - return false; - - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_PRESSED_DOWN: - MouseKeys[0] = true; - break; - case EMIE_RMOUSE_PRESSED_DOWN: - MouseKeys[2] = true; - break; - case EMIE_MMOUSE_PRESSED_DOWN: - MouseKeys[1] = true; - break; - case EMIE_LMOUSE_LEFT_UP: - MouseKeys[0] = false; - break; - case EMIE_RMOUSE_LEFT_UP: - MouseKeys[2] = false; - break; - case EMIE_MMOUSE_LEFT_UP: - MouseKeys[1] = false; - break; - case EMIE_MOUSE_MOVED: - { - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - if (driver) - { - core::dimension2d ssize = SceneManager->getVideoDriver()->getScreenSize(); - MousePos.X = event.MouseInput.X / (f32)ssize.Width; - MousePos.Y = event.MouseInput.Y / (f32)ssize.Height; - } - } - break; - case EMIE_MOUSE_WHEEL: - case EMIE_COUNT: - break; - } - return true; -} - -//! OnAnimate() is called just before rendering the whole scene. -//! nodes may calculate or store animations here, and may do other useful things, -//! dependent on what they are. -void CCameraMayaSceneNode::OnAnimate(u32 timeMs) -{ - animate(); - - ISceneNode::setPosition(Pos); - updateAbsolutePosition(); - - // This scene node cannot be animated by scene node animators, so - // don't invoke them. -} - - -bool CCameraMayaSceneNode::isMouseKeyDown(s32 key) -{ - return MouseKeys[key]; -} - - - -void CCameraMayaSceneNode::animate() -{ - //Alt + LM = Rotieren um KameraDrehpunkt - //Alt + LM + MM = Dolly vor/zurück in Kamerablickrichtung (Geschwindigkeit % von Abstand Kamera zu Drehpunkt - Maximalweg zum Kameradrehpunkt) - //Alt + MM = Verschieben in Kameraebene (Bildmitte hängt vom Tempo ungefähr am Mauszeiger) - - const SViewFrustum* va = getViewFrustum(); - - f32 nRotX = rotX; - f32 nRotY = rotY; - f32 nZoom = currentZoom; - - if ( (isMouseKeyDown(0) && isMouseKeyDown(2)) || isMouseKeyDown(1) ) - { - if (!zooming) - { - zoomStartX = MousePos.X; - zoomStartY = MousePos.Y; - zooming = true; - nZoom = currentZoom; - } - else - { - f32 old = nZoom; - nZoom += (zoomStartX - MousePos.X) * zoomSpeed; - - f32 targetMinDistance = 0.1f; - if (nZoom < targetMinDistance) // jox: fixed bug: bounce back when zooming to close - nZoom = targetMinDistance; - - if (nZoom < 0) - nZoom = old; - } - } - else - { - if (zooming) - { - f32 old = currentZoom; - currentZoom = currentZoom + (zoomStartX - MousePos.X ) * zoomSpeed; - nZoom = currentZoom; - - if (nZoom < 0) - nZoom = currentZoom = old; - } - - zooming = false; - } - - // Translation --------------------------------- - - core::vector3df translate(oldTarget); - - core::vector3df tvectX = Pos - Target; - tvectX = tvectX.crossProduct(UpVector); - tvectX.normalize(); - - core::vector3df tvectY = (va->getFarLeftDown() - va->getFarRightDown()); - tvectY = tvectY.crossProduct(UpVector.Y > 0 ? Pos - Target : Target - Pos); - tvectY.normalize(); - - - if (isMouseKeyDown(2) && !zooming) - { - if (!translating) - { - translateStartX = MousePos.X; - translateStartY = MousePos.Y; - translating = true; - } - else - { - translate += tvectX * (translateStartX - MousePos.X)*translateSpeed + - tvectY * (translateStartY - MousePos.Y)*translateSpeed; - } - } - else - { - if (translating) - { - translate += tvectX * (translateStartX - MousePos.X)*translateSpeed + - tvectY * (translateStartY - MousePos.Y)*translateSpeed; - oldTarget = translate; - } - - translating = false; - } - - // Rotation ------------------------------------ - - if (isMouseKeyDown(0) && !zooming) - { - if (!rotating) - { - rotateStartX = MousePos.X; - rotateStartY = MousePos.Y; - rotating = true; - nRotX = rotX; - nRotY = rotY; - } - else - { - nRotX += (rotateStartX - MousePos.X) * rotateSpeed; - nRotY += (rotateStartY - MousePos.Y) * rotateSpeed; - } - } - else - { - if (rotating) - { - rotX = rotX + (rotateStartX - MousePos.X) * rotateSpeed; - rotY = rotY + (rotateStartY - MousePos.Y) * rotateSpeed; - nRotX = rotX; - nRotY = rotY; - } - - rotating = false; - } - - // Set Pos ------------------------------------ - - Target = translate; - - Pos.X = nZoom + Target.X; - Pos.Y = Target.Y; - Pos.Z = Target.Z; - - Pos.rotateXYBy(nRotY, Target); - Pos.rotateXZBy(-nRotX, Target); - - // Rotation Error ---------------------------- - - // jox: fixed bug: jitter when rotating to the top and bottom of y - UpVector.set(0,1,0); - UpVector.rotateXYBy(-nRotY, core::vector3df(0,0,0)); - UpVector.rotateXZBy(-nRotX+180.f, core::vector3df(0,0,0)); - - /*if (nRotY < 0.0f) - nRotY *= -1.0f; - - nRotY = (f32)fmod(nRotY, 360.0f); - - - if (nRotY >= 90.0f && nRotY <= 270.0f) - UpVector.set(0, -1, 0); - else - UpVector.set(0, 1, 0);*/ -} - - -void CCameraMayaSceneNode::allKeysUp() -{ - for (s32 i=0; i<3; ++i) - MouseKeys[i] = false; -} - -// function added by jox: fix setPosition() -void CCameraMayaSceneNode::setPosition(const core::vector3df& pos) -{ - Pos = pos; - updateAnimationState(); - - ISceneNode::setPosition(pos); -} - -// function added by jox: fix setTarget() -void CCameraMayaSceneNode::setTarget(const core::vector3df& pos) -{ - Target = oldTarget = pos; - updateAnimationState(); -} - - -// function added by jox -void CCameraMayaSceneNode::updateAnimationState() -{ - core::vector3df pos(Pos - Target); - - // X rotation - core::vector2df vec2d(pos.X, pos.Z); - rotX = (f32)vec2d.getAngle(); - - // Y rotation - pos.rotateXZBy(rotX, core::vector3df()); - vec2d.set(pos.X, pos.Y); - rotY = -(f32)vec2d.getAngle(); - - // Zoom - currentZoom = (f32)Pos.getDistanceFrom(Target); -} - -//! Sets the rotation speed -void CCameraMayaSceneNode::setRotateSpeed(const f32 speed) -{ - rotateSpeed = speed; -} - -//! Sets the movement speed -void CCameraMayaSceneNode::setMoveSpeed(const f32 speed) -{ - translateSpeed = speed; -} - -//! Gets the rotation speed -f32 CCameraMayaSceneNode::getRotateSpeed() -{ - return rotateSpeed; -} - -// Gets the movement speed -f32 CCameraMayaSceneNode::getMoveSpeed() -{ - return translateSpeed; -} - -} // end namespace -} // end namespace - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CCameraMayaSceneNode.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CCameraMayaSceneNode::CCameraMayaSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + f32 rs, f32 zs, f32 ts) +: CCameraSceneNode(parent, mgr, id), + zooming(false), rotating(false), moving(false), translating(false), + zoomSpeed(zs), rotateSpeed(ts), translateSpeed(ts), + rotateStartX(0.0f), rotateStartY(0.0f), zoomStartX(0.0f), zoomStartY(0.0f), + translateStartX(0.0f), translateStartY(0.0f), currentZoom(70.0f), rotX(0.0f), rotY(0.0f) +{ + #ifdef _DEBUG + setDebugName("CCameraMayaSceneNode"); + #endif + + Target.set(0.0f, 0.0f, 0.0f); + oldTarget = Target; + + allKeysUp(); + recalculateViewArea(); +} + + +//! destructor +CCameraMayaSceneNode::~CCameraMayaSceneNode() +{ +} + + +//! It is possible to send mouse and key events to the camera. Most cameras +//! may ignore this input, but camera scene nodes which are created for +//! example with scene::ISceneManager::addMayaCameraSceneNode or +//! scene::ISceneManager::addMeshViewerCameraSceneNode, may want to get this input +//! for changing their position, look at target or whatever. +bool CCameraMayaSceneNode::OnEvent(SEvent event) +{ + if (event.EventType != EET_MOUSE_INPUT_EVENT || + !InputReceiverEnabled) + return false; + + switch(event.MouseInput.Event) + { + case EMIE_LMOUSE_PRESSED_DOWN: + MouseKeys[0] = true; + break; + case EMIE_RMOUSE_PRESSED_DOWN: + MouseKeys[2] = true; + break; + case EMIE_MMOUSE_PRESSED_DOWN: + MouseKeys[1] = true; + break; + case EMIE_LMOUSE_LEFT_UP: + MouseKeys[0] = false; + break; + case EMIE_RMOUSE_LEFT_UP: + MouseKeys[2] = false; + break; + case EMIE_MMOUSE_LEFT_UP: + MouseKeys[1] = false; + break; + case EMIE_MOUSE_MOVED: + { + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + if (driver) + { + core::dimension2d ssize = SceneManager->getVideoDriver()->getScreenSize(); + MousePos.X = event.MouseInput.X / (f32)ssize.Width; + MousePos.Y = event.MouseInput.Y / (f32)ssize.Height; + } + } + break; + case EMIE_MOUSE_WHEEL: + case EMIE_COUNT: + break; + } + return true; +} + +//! OnAnimate() is called just before rendering the whole scene. +//! nodes may calculate or store animations here, and may do other useful things, +//! dependent on what they are. +void CCameraMayaSceneNode::OnAnimate(u32 timeMs) +{ + animate(); + + ISceneNode::setPosition(Pos); + updateAbsolutePosition(); + + // This scene node cannot be animated by scene node animators, so + // don't invoke them. +} + + +bool CCameraMayaSceneNode::isMouseKeyDown(s32 key) +{ + return MouseKeys[key]; +} + + + +void CCameraMayaSceneNode::animate() +{ + //Alt + LM = Rotieren um KameraDrehpunkt + //Alt + LM + MM = Dolly vor/zurück in Kamerablickrichtung (Geschwindigkeit % von Abstand Kamera zu Drehpunkt - Maximalweg zum Kameradrehpunkt) + //Alt + MM = Verschieben in Kameraebene (Bildmitte hängt vom Tempo ungefähr am Mauszeiger) + + const SViewFrustum* va = getViewFrustum(); + + f32 nRotX = rotX; + f32 nRotY = rotY; + f32 nZoom = currentZoom; + + if ( (isMouseKeyDown(0) && isMouseKeyDown(2)) || isMouseKeyDown(1) ) + { + if (!zooming) + { + zoomStartX = MousePos.X; + zoomStartY = MousePos.Y; + zooming = true; + nZoom = currentZoom; + } + else + { + f32 old = nZoom; + nZoom += (zoomStartX - MousePos.X) * zoomSpeed; + + f32 targetMinDistance = 0.1f; + if (nZoom < targetMinDistance) // jox: fixed bug: bounce back when zooming to close + nZoom = targetMinDistance; + + if (nZoom < 0) + nZoom = old; + } + } + else + { + if (zooming) + { + f32 old = currentZoom; + currentZoom = currentZoom + (zoomStartX - MousePos.X ) * zoomSpeed; + nZoom = currentZoom; + + if (nZoom < 0) + nZoom = currentZoom = old; + } + + zooming = false; + } + + // Translation --------------------------------- + + core::vector3df translate(oldTarget); + + core::vector3df tvectX = Pos - Target; + tvectX = tvectX.crossProduct(UpVector); + tvectX.normalize(); + + core::vector3df tvectY = (va->getFarLeftDown() - va->getFarRightDown()); + tvectY = tvectY.crossProduct(UpVector.Y > 0 ? Pos - Target : Target - Pos); + tvectY.normalize(); + + + if (isMouseKeyDown(2) && !zooming) + { + if (!translating) + { + translateStartX = MousePos.X; + translateStartY = MousePos.Y; + translating = true; + } + else + { + translate += tvectX * (translateStartX - MousePos.X)*translateSpeed + + tvectY * (translateStartY - MousePos.Y)*translateSpeed; + } + } + else + { + if (translating) + { + translate += tvectX * (translateStartX - MousePos.X)*translateSpeed + + tvectY * (translateStartY - MousePos.Y)*translateSpeed; + oldTarget = translate; + } + + translating = false; + } + + // Rotation ------------------------------------ + + if (isMouseKeyDown(0) && !zooming) + { + if (!rotating) + { + rotateStartX = MousePos.X; + rotateStartY = MousePos.Y; + rotating = true; + nRotX = rotX; + nRotY = rotY; + } + else + { + nRotX += (rotateStartX - MousePos.X) * rotateSpeed; + nRotY += (rotateStartY - MousePos.Y) * rotateSpeed; + } + } + else + { + if (rotating) + { + rotX = rotX + (rotateStartX - MousePos.X) * rotateSpeed; + rotY = rotY + (rotateStartY - MousePos.Y) * rotateSpeed; + nRotX = rotX; + nRotY = rotY; + } + + rotating = false; + } + + // Set Pos ------------------------------------ + + Target = translate; + + Pos.X = nZoom + Target.X; + Pos.Y = Target.Y; + Pos.Z = Target.Z; + + Pos.rotateXYBy(nRotY, Target); + Pos.rotateXZBy(-nRotX, Target); + + // Rotation Error ---------------------------- + + // jox: fixed bug: jitter when rotating to the top and bottom of y + UpVector.set(0,1,0); + UpVector.rotateXYBy(-nRotY, core::vector3df(0,0,0)); + UpVector.rotateXZBy(-nRotX+180.f, core::vector3df(0,0,0)); + + /*if (nRotY < 0.0f) + nRotY *= -1.0f; + + nRotY = (f32)fmod(nRotY, 360.0f); + + + if (nRotY >= 90.0f && nRotY <= 270.0f) + UpVector.set(0, -1, 0); + else + UpVector.set(0, 1, 0);*/ +} + + +void CCameraMayaSceneNode::allKeysUp() +{ + for (s32 i=0; i<3; ++i) + MouseKeys[i] = false; +} + +// function added by jox: fix setPosition() +void CCameraMayaSceneNode::setPosition(const core::vector3df& pos) +{ + Pos = pos; + updateAnimationState(); + + ISceneNode::setPosition(pos); +} + +// function added by jox: fix setTarget() +void CCameraMayaSceneNode::setTarget(const core::vector3df& pos) +{ + Target = oldTarget = pos; + updateAnimationState(); +} + + +// function added by jox +void CCameraMayaSceneNode::updateAnimationState() +{ + core::vector3df pos(Pos - Target); + + // X rotation + core::vector2df vec2d(pos.X, pos.Z); + rotX = (f32)vec2d.getAngle(); + + // Y rotation + pos.rotateXZBy(rotX, core::vector3df()); + vec2d.set(pos.X, pos.Y); + rotY = -(f32)vec2d.getAngle(); + + // Zoom + currentZoom = (f32)Pos.getDistanceFrom(Target); +} + +//! Sets the rotation speed +void CCameraMayaSceneNode::setRotateSpeed(const f32 speed) +{ + rotateSpeed = speed; +} + +//! Sets the movement speed +void CCameraMayaSceneNode::setMoveSpeed(const f32 speed) +{ + translateSpeed = speed; +} + +//! Gets the rotation speed +f32 CCameraMayaSceneNode::getRotateSpeed() +{ + return rotateSpeed; +} + +// Gets the movement speed +f32 CCameraMayaSceneNode::getMoveSpeed() +{ + return translateSpeed; +} + +} // end namespace +} // end namespace + diff --git a/src/dep/src/irrlicht/CCameraMayaSceneNode.h b/src/dep/src/irrlicht/CCameraMayaSceneNode.h index a694252..0c56101 100644 --- a/src/dep/src/irrlicht/CCameraMayaSceneNode.h +++ b/src/dep/src/irrlicht/CCameraMayaSceneNode.h @@ -1,90 +1,90 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_CAMERA_MAYA_SCENE_NODE_H_INCLUDED__ -#define __C_CAMERA_MAYA_SCENE_NODE_H_INCLUDED__ - -#include "CCameraSceneNode.h" -#include "vector2d.h" - -namespace irr -{ -namespace scene -{ - - class CCameraMayaSceneNode : public CCameraSceneNode - { - public: - - //! constructor - CCameraMayaSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 translationSpeed = 100.0f); - - //! destructor - virtual ~CCameraMayaSceneNode(); - - //! It is possible to send mouse and key events to the camera. Most cameras - //! may ignore this input, but camera scene nodes which are created for - //! example with scene::ISceneManager::addMayaCameraSceneNode or - //! scene::ISceneManager::addMeshViewerCameraSceneNode, may want to get this input - //! for changing their position, look at target or whatever. - virtual bool OnEvent(SEvent event); - - //! OnAnimate() is called just before rendering the whole scene. - //! nodes may calculate or store animations here, and may do other useful things, - //! dependent on what they are. - virtual void OnAnimate(u32 timeMs); - - //! Sets the position of the node. Note that the position is - //! relative to the parent. - virtual void setPosition(const core::vector3df& newpos); - - //! Sets the position of the node. Note that the position is - //! relative to the parent. - virtual void setTarget(const core::vector3df& newpos); - - //! Sets the rotation speed - virtual void setRotateSpeed(const f32 speed); - - //! Sets the movement speed - virtual void setMoveSpeed(const f32 speed); - - //! Gets the rotation speed - virtual f32 getRotateSpeed(); - - // Gets the movement speed - virtual f32 getMoveSpeed(); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_CAMERA_MAYA; } - - private: - - void allKeysUp(); - void animate(); - bool isMouseKeyDown(s32 key); - void updateAnimationState(); - - bool MouseKeys[3]; - - core::vector3df Pos; - bool zooming, rotating, moving, translating; - f32 zoomSpeed; - f32 rotateSpeed; - f32 translateSpeed; - f32 rotateStartX, rotateStartY; - f32 zoomStartX, zoomStartY; - f32 translateStartX, translateStartY; - f32 currentZoom; - f32 rotX, rotY; - core::vector3df oldTarget; - - core::vector2df MousePos; - }; - -} // end namespace -} // end namespace - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_CAMERA_MAYA_SCENE_NODE_H_INCLUDED__ +#define __C_CAMERA_MAYA_SCENE_NODE_H_INCLUDED__ + +#include "CCameraSceneNode.h" +#include "vector2d.h" + +namespace irr +{ +namespace scene +{ + + class CCameraMayaSceneNode : public CCameraSceneNode + { + public: + + //! constructor + CCameraMayaSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 translationSpeed = 100.0f); + + //! destructor + virtual ~CCameraMayaSceneNode(); + + //! It is possible to send mouse and key events to the camera. Most cameras + //! may ignore this input, but camera scene nodes which are created for + //! example with scene::ISceneManager::addMayaCameraSceneNode or + //! scene::ISceneManager::addMeshViewerCameraSceneNode, may want to get this input + //! for changing their position, look at target or whatever. + virtual bool OnEvent(SEvent event); + + //! OnAnimate() is called just before rendering the whole scene. + //! nodes may calculate or store animations here, and may do other useful things, + //! dependent on what they are. + virtual void OnAnimate(u32 timeMs); + + //! Sets the position of the node. Note that the position is + //! relative to the parent. + virtual void setPosition(const core::vector3df& newpos); + + //! Sets the position of the node. Note that the position is + //! relative to the parent. + virtual void setTarget(const core::vector3df& newpos); + + //! Sets the rotation speed + virtual void setRotateSpeed(const f32 speed); + + //! Sets the movement speed + virtual void setMoveSpeed(const f32 speed); + + //! Gets the rotation speed + virtual f32 getRotateSpeed(); + + // Gets the movement speed + virtual f32 getMoveSpeed(); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_CAMERA_MAYA; } + + private: + + void allKeysUp(); + void animate(); + bool isMouseKeyDown(s32 key); + void updateAnimationState(); + + bool MouseKeys[3]; + + core::vector3df Pos; + bool zooming, rotating, moving, translating; + f32 zoomSpeed; + f32 rotateSpeed; + f32 translateSpeed; + f32 rotateStartX, rotateStartY; + f32 zoomStartX, zoomStartY; + f32 translateStartX, translateStartY; + f32 currentZoom; + f32 rotX, rotY; + core::vector3df oldTarget; + + core::vector2df MousePos; + }; + +} // end namespace +} // end namespace + +#endif + diff --git a/src/dep/src/irrlicht/CCameraSceneNode.cpp b/src/dep/src/irrlicht/CCameraSceneNode.cpp index d10bb45..0cbeb9b 100644 --- a/src/dep/src/irrlicht/CCameraSceneNode.cpp +++ b/src/dep/src/irrlicht/CCameraSceneNode.cpp @@ -1,309 +1,309 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CCameraSceneNode.h" -#include "ISceneManager.h" -#include "IVideoDriver.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CCameraSceneNode::CCameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::vector3df& lookat) - : ICameraSceneNode(parent, mgr, id, position, core::vector3df(0.0f, 0.0f, 0.0f), - core::vector3df(1.0f, 1.0f, 1.0f)), InputReceiverEnabled(true) -{ - #ifdef _DEBUG - setDebugName("CCameraSceneNode"); - #endif - - // set default view - - UpVector.set(0.0f, 1.0f, 0.0f); - Target.set(lookat); - - // set default projection - - Fovy = core::PI / 2.5f; // Field of view, in radians. - Aspect = 4.0f / 3.0f; // Aspect ratio. - ZNear = 1.0f; // value of the near view-plane. - ZFar = 3000.0f; // Z-value of the far view-plane. - - video::IVideoDriver* d = mgr->getVideoDriver(); - if (d) - Aspect = (f32)d->getCurrentRenderTargetSize().Width / - (f32)d->getCurrentRenderTargetSize().Height; - - recalculateProjectionMatrix(); - recalculateViewArea(); -} - - - -//! destructor -CCameraSceneNode::~CCameraSceneNode() -{ -} - - -//! Disables or enables the camera to get key or mouse inputs. -void CCameraSceneNode::setInputReceiverEnabled(bool enabled) -{ - InputReceiverEnabled = enabled; -} - - -//! Returns if the input receiver of the camera is currently enabled. -bool CCameraSceneNode::isInputReceiverEnabled() -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return InputReceiverEnabled; -} - - -//! Sets the projection matrix of the camera. The core::matrix4 class has some methods -//! to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH -//! \param projection: The new projection matrix of the camera. -void CCameraSceneNode::setProjectionMatrix(const core::matrix4& projection) -{ - ViewArea.Matrices [ video::ETS_PROJECTION ] = projection; - ViewArea.setTransformState ( video::ETS_PROJECTION ); -} - - - -//! Gets the current projection matrix of the camera -//! \return Returns the current projection matrix of the camera. -const core::matrix4& CCameraSceneNode::getProjectionMatrix() -{ - return ViewArea.Matrices [ video::ETS_PROJECTION ]; -} - - - -//! Gets the current view matrix of the camera -//! \return Returns the current view matrix of the camera. -const core::matrix4& CCameraSceneNode::getViewMatrix() -{ - return ViewArea.Matrices [ video::ETS_VIEW ]; -} - - - -//! It is possible to send mouse and key events to the camera. Most cameras -//! may ignore this input, but camera scene nodes which are created for -//! example with scene::ISceneManager::addMayaCameraSceneNode or -//! scene::ISceneManager::addFPSCameraSceneNode, may want to get this input -//! for changing their position, look at target or whatever. -bool CCameraSceneNode::OnEvent(SEvent event) -{ - return false; -} - - - -//! sets the look at target of the camera -//! \param pos: Look at target of the camera. -void CCameraSceneNode::setTarget(const core::vector3df& pos) -{ - Target = pos; -} - - - -//! Gets the current look at target of the camera -//! \return Returns the current look at target of the camera -core::vector3df CCameraSceneNode::getTarget() const -{ - return Target; -} - - - -//! sets the up vector of the camera -//! \param pos: New upvector of the camera. -void CCameraSceneNode::setUpVector(const core::vector3df& pos) -{ - UpVector = pos; -} - - - -//! Gets the up vector of the camera. -//! \return Returns the up vector of the camera. -core::vector3df CCameraSceneNode::getUpVector() const -{ - return UpVector; -} - - -f32 CCameraSceneNode::getNearValue() -{ - return ZNear; -} - -f32 CCameraSceneNode::getFarValue() -{ - return ZFar; -} - -f32 CCameraSceneNode::getAspectRatio() -{ - return Aspect; -} - -f32 CCameraSceneNode::getFOV() -{ - return Fovy; -} - -void CCameraSceneNode::setNearValue(f32 f) -{ - ZNear = f; - recalculateProjectionMatrix(); -} - -void CCameraSceneNode::setFarValue(f32 f) -{ - ZFar = f; - recalculateProjectionMatrix(); -} - -void CCameraSceneNode::setAspectRatio(f32 f) -{ - Aspect = f; - recalculateProjectionMatrix(); -} - -void CCameraSceneNode::setFOV(f32 f) -{ - Fovy = f; - recalculateProjectionMatrix(); -} - -void CCameraSceneNode::recalculateProjectionMatrix() -{ - ViewArea.Matrices [ video::ETS_PROJECTION ].buildProjectionMatrixPerspectiveFovLH(Fovy, Aspect, ZNear, ZFar); - ViewArea.setTransformState ( video::ETS_PROJECTION ); -} - - -//! prerender -void CCameraSceneNode::OnRegisterSceneNode() -{ - // if upvector and vector to the target are the same, we have a - // problem. so solve this problem: - - core::vector3df pos = getAbsolutePosition(); - core::vector3df tgtv = Target - pos; - tgtv.normalize(); - - core::vector3df up = UpVector; - up.normalize(); - - f32 dp = tgtv.dotProduct(up); - - if ( core::equals ( fabs ( dp ), 1.f ) ) - { - up.X += 0.5f; - } - - ViewArea.Matrices [ video::ETS_VIEW ].buildCameraLookAtMatrixLH(pos, Target, up); - ViewArea.setTransformState ( video::ETS_VIEW ); - recalculateViewArea(); - - if ( SceneManager->getActiveCamera () == this ) - SceneManager->registerNodeForRendering(this, ESNRP_CAMERA); - - if (IsVisible) - ISceneNode::OnRegisterSceneNode(); -} - - - -//! render -void CCameraSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - if ( driver) - { - driver->setTransform(video::ETS_PROJECTION, ViewArea.Matrices [ video::ETS_PROJECTION ] ); - driver->setTransform(video::ETS_VIEW, ViewArea.Matrices [ video::ETS_VIEW ] ); - } -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CCameraSceneNode::getBoundingBox() const -{ - return ViewArea.getBoundingBox(); -} - - - -//! returns the view frustum. needed sometimes by bsp or lod render nodes. -const SViewFrustum* CCameraSceneNode::getViewFrustum() const -{ - return &ViewArea; -} - -core::vector3df CCameraSceneNode::getAbsolutePosition() const -{ - return AbsoluteTransformation.getTranslation(); -} - -void CCameraSceneNode::recalculateViewArea() -{ - ViewArea.cameraPosition = getAbsolutePosition(); - ViewArea.setFrom ( ViewArea.Matrices [ SViewFrustum::ETS_VIEW_PROJECTION_3 ] ); -/* - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - if ( driver) - { - driver->setTransform(video::ETS_PROJECTION, ViewArea.Matrices [ video::ETS_PROJECTION ] ); - driver->setTransform(video::ETS_VIEW, ViewArea.Matrices [ video::ETS_VIEW ] ); - } -*/ -} - - -//! Writes attributes of the scene node. -void CCameraSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - ISceneNode::serializeAttributes(out, options); - - out->addVector3d("Target", Target); - out->addVector3d("UpVector", UpVector); - out->addFloat("Fovy", Fovy); - out->addFloat("Aspect", Aspect); - out->addFloat("ZNear", ZNear); - out->addFloat("ZFar", ZFar); -} - - -//! Reads attributes of the scene node. -void CCameraSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - ISceneNode::deserializeAttributes(in, options); - - Target = in->getAttributeAsVector3d("Target"); - UpVector = in->getAttributeAsVector3d("UpVector"); - Fovy = in->getAttributeAsFloat("Fovy"); - Aspect = in->getAttributeAsFloat("Aspect"); - ZNear = in->getAttributeAsFloat("ZNear"); - ZFar = in->getAttributeAsFloat("ZFar"); - - recalculateProjectionMatrix(); - recalculateViewArea(); -} - - -} // end namespace -} // end namespace - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CCameraSceneNode.h" +#include "ISceneManager.h" +#include "IVideoDriver.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + + +//! constructor +CCameraSceneNode::CCameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position, const core::vector3df& lookat) + : ICameraSceneNode(parent, mgr, id, position, core::vector3df(0.0f, 0.0f, 0.0f), + core::vector3df(1.0f, 1.0f, 1.0f)), InputReceiverEnabled(true) +{ + #ifdef _DEBUG + setDebugName("CCameraSceneNode"); + #endif + + // set default view + + UpVector.set(0.0f, 1.0f, 0.0f); + Target.set(lookat); + + // set default projection + + Fovy = core::PI / 2.5f; // Field of view, in radians. + Aspect = 4.0f / 3.0f; // Aspect ratio. + ZNear = 1.0f; // value of the near view-plane. + ZFar = 3000.0f; // Z-value of the far view-plane. + + video::IVideoDriver* d = mgr->getVideoDriver(); + if (d) + Aspect = (f32)d->getCurrentRenderTargetSize().Width / + (f32)d->getCurrentRenderTargetSize().Height; + + recalculateProjectionMatrix(); + recalculateViewArea(); +} + + + +//! destructor +CCameraSceneNode::~CCameraSceneNode() +{ +} + + +//! Disables or enables the camera to get key or mouse inputs. +void CCameraSceneNode::setInputReceiverEnabled(bool enabled) +{ + InputReceiverEnabled = enabled; +} + + +//! Returns if the input receiver of the camera is currently enabled. +bool CCameraSceneNode::isInputReceiverEnabled() +{ + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return InputReceiverEnabled; +} + + +//! Sets the projection matrix of the camera. The core::matrix4 class has some methods +//! to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH +//! \param projection: The new projection matrix of the camera. +void CCameraSceneNode::setProjectionMatrix(const core::matrix4& projection) +{ + ViewArea.Matrices [ video::ETS_PROJECTION ] = projection; + ViewArea.setTransformState ( video::ETS_PROJECTION ); +} + + + +//! Gets the current projection matrix of the camera +//! \return Returns the current projection matrix of the camera. +const core::matrix4& CCameraSceneNode::getProjectionMatrix() +{ + return ViewArea.Matrices [ video::ETS_PROJECTION ]; +} + + + +//! Gets the current view matrix of the camera +//! \return Returns the current view matrix of the camera. +const core::matrix4& CCameraSceneNode::getViewMatrix() +{ + return ViewArea.Matrices [ video::ETS_VIEW ]; +} + + + +//! It is possible to send mouse and key events to the camera. Most cameras +//! may ignore this input, but camera scene nodes which are created for +//! example with scene::ISceneManager::addMayaCameraSceneNode or +//! scene::ISceneManager::addFPSCameraSceneNode, may want to get this input +//! for changing their position, look at target or whatever. +bool CCameraSceneNode::OnEvent(SEvent event) +{ + return false; +} + + + +//! sets the look at target of the camera +//! \param pos: Look at target of the camera. +void CCameraSceneNode::setTarget(const core::vector3df& pos) +{ + Target = pos; +} + + + +//! Gets the current look at target of the camera +//! \return Returns the current look at target of the camera +core::vector3df CCameraSceneNode::getTarget() const +{ + return Target; +} + + + +//! sets the up vector of the camera +//! \param pos: New upvector of the camera. +void CCameraSceneNode::setUpVector(const core::vector3df& pos) +{ + UpVector = pos; +} + + + +//! Gets the up vector of the camera. +//! \return Returns the up vector of the camera. +core::vector3df CCameraSceneNode::getUpVector() const +{ + return UpVector; +} + + +f32 CCameraSceneNode::getNearValue() +{ + return ZNear; +} + +f32 CCameraSceneNode::getFarValue() +{ + return ZFar; +} + +f32 CCameraSceneNode::getAspectRatio() +{ + return Aspect; +} + +f32 CCameraSceneNode::getFOV() +{ + return Fovy; +} + +void CCameraSceneNode::setNearValue(f32 f) +{ + ZNear = f; + recalculateProjectionMatrix(); +} + +void CCameraSceneNode::setFarValue(f32 f) +{ + ZFar = f; + recalculateProjectionMatrix(); +} + +void CCameraSceneNode::setAspectRatio(f32 f) +{ + Aspect = f; + recalculateProjectionMatrix(); +} + +void CCameraSceneNode::setFOV(f32 f) +{ + Fovy = f; + recalculateProjectionMatrix(); +} + +void CCameraSceneNode::recalculateProjectionMatrix() +{ + ViewArea.Matrices [ video::ETS_PROJECTION ].buildProjectionMatrixPerspectiveFovLH(Fovy, Aspect, ZNear, ZFar); + ViewArea.setTransformState ( video::ETS_PROJECTION ); +} + + +//! prerender +void CCameraSceneNode::OnRegisterSceneNode() +{ + // if upvector and vector to the target are the same, we have a + // problem. so solve this problem: + + core::vector3df pos = getAbsolutePosition(); + core::vector3df tgtv = Target - pos; + tgtv.normalize(); + + core::vector3df up = UpVector; + up.normalize(); + + f32 dp = tgtv.dotProduct(up); + + if ( core::equals ( fabs ( dp ), 1.f ) ) + { + up.X += 0.5f; + } + + ViewArea.Matrices [ video::ETS_VIEW ].buildCameraLookAtMatrixLH(pos, Target, up); + ViewArea.setTransformState ( video::ETS_VIEW ); + recalculateViewArea(); + + if ( SceneManager->getActiveCamera () == this ) + SceneManager->registerNodeForRendering(this, ESNRP_CAMERA); + + if (IsVisible) + ISceneNode::OnRegisterSceneNode(); +} + + + +//! render +void CCameraSceneNode::render() +{ + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + if ( driver) + { + driver->setTransform(video::ETS_PROJECTION, ViewArea.Matrices [ video::ETS_PROJECTION ] ); + driver->setTransform(video::ETS_VIEW, ViewArea.Matrices [ video::ETS_VIEW ] ); + } +} + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CCameraSceneNode::getBoundingBox() const +{ + return ViewArea.getBoundingBox(); +} + + + +//! returns the view frustum. needed sometimes by bsp or lod render nodes. +const SViewFrustum* CCameraSceneNode::getViewFrustum() const +{ + return &ViewArea; +} + +core::vector3df CCameraSceneNode::getAbsolutePosition() const +{ + return AbsoluteTransformation.getTranslation(); +} + +void CCameraSceneNode::recalculateViewArea() +{ + ViewArea.cameraPosition = getAbsolutePosition(); + ViewArea.setFrom ( ViewArea.Matrices [ SViewFrustum::ETS_VIEW_PROJECTION_3 ] ); +/* + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + if ( driver) + { + driver->setTransform(video::ETS_PROJECTION, ViewArea.Matrices [ video::ETS_PROJECTION ] ); + driver->setTransform(video::ETS_VIEW, ViewArea.Matrices [ video::ETS_VIEW ] ); + } +*/ +} + + +//! Writes attributes of the scene node. +void CCameraSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + ISceneNode::serializeAttributes(out, options); + + out->addVector3d("Target", Target); + out->addVector3d("UpVector", UpVector); + out->addFloat("Fovy", Fovy); + out->addFloat("Aspect", Aspect); + out->addFloat("ZNear", ZNear); + out->addFloat("ZFar", ZFar); +} + + +//! Reads attributes of the scene node. +void CCameraSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + ISceneNode::deserializeAttributes(in, options); + + Target = in->getAttributeAsVector3d("Target"); + UpVector = in->getAttributeAsVector3d("UpVector"); + Fovy = in->getAttributeAsFloat("Fovy"); + Aspect = in->getAttributeAsFloat("Aspect"); + ZNear = in->getAttributeAsFloat("ZNear"); + ZFar = in->getAttributeAsFloat("ZFar"); + + recalculateProjectionMatrix(); + recalculateViewArea(); +} + + +} // end namespace +} // end namespace + diff --git a/src/dep/src/irrlicht/CCameraSceneNode.h b/src/dep/src/irrlicht/CCameraSceneNode.h index 33175e0..30e53cb 100644 --- a/src/dep/src/irrlicht/CCameraSceneNode.h +++ b/src/dep/src/irrlicht/CCameraSceneNode.h @@ -1,145 +1,145 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_CAMERA_SCENE_NODE_H_INCLUDED__ -#define __C_CAMERA_SCENE_NODE_H_INCLUDED__ - -#include "ICameraSceneNode.h" -#include "SViewFrustum.h" - -namespace irr -{ -namespace scene -{ - - class CCameraSceneNode : public ICameraSceneNode - { - public: - - //! constructor - CCameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& lookat = core::vector3df(0,0,100)); - - //! destructor - virtual ~CCameraSceneNode(); - - //! Sets the projection matrix of the camera. The core::matrix4 class has some methods - //! to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH - //! \param projection: The new projection matrix of the camera. - virtual void setProjectionMatrix(const core::matrix4& projection); - - //! Gets the current projection matrix of the camera - //! \return Returns the current projection matrix of the camera. - virtual const core::matrix4& getProjectionMatrix(); - - //! Gets the current view matrix of the camera - //! \return Returns the current view matrix of the camera. - virtual const core::matrix4& getViewMatrix(); - - //! It is possible to send mouse and key events to the camera. Most cameras - //! may ignore this input, but camera scene nodes which are created for - //! example with scene::ISceneManager::addMayaCameraSceneNode or - //! scene::ISceneManager::addMeshViewerCameraSceneNode, may want to get this input - //! for changing their position, look at target or whatever. - virtual bool OnEvent(SEvent event); - - //! sets the look at target of the camera - //! \param pos: Look at target of the camera. - virtual void setTarget(const core::vector3df& pos); - - //! Gets the current look at target of the camera - //! \return Returns the current look at target of the camera - virtual core::vector3df getTarget() const; - - //! Sets the up vector of the camera. - //! \param pos: New upvector of the camera. - virtual void setUpVector(const core::vector3df& pos); - - //! Gets the up vector of the camera. - //! \return Returns the up vector of the camera. - virtual core::vector3df getUpVector() const; - - //! Gets distance from the camera to the near plane. - //! \return Value of the near plane of the camera. - virtual f32 getNearValue(); - - //! Gets the distance from the camera to the far plane. - //! \return Value of the far plane of the camera. - virtual f32 getFarValue(); - - //! Get the aspect ratio of the camera. - //! \return The aspect ratio of the camera. - virtual f32 getAspectRatio(); - - //! Gets the field of view of the camera. - //! \return Field of view of the camera - virtual f32 getFOV(); - - //! Sets the value of the near clipping plane. (default: 1.0f) - virtual void setNearValue(f32 zn); - - //! Sets the value of the far clipping plane (default: 2000.0f) - virtual void setFarValue(f32 zf); - - //! Sets the aspect ratio (default: 4.0f / 3.0f) - virtual void setAspectRatio(f32 aspect); - - //! Sets the field of view (Default: PI / 3.5f) - virtual void setFOV(f32 fovy); - - //! PreRender event - virtual void OnRegisterSceneNode(); - - //! Render - virtual void render(); - - //! Returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! Returns the view area. Sometimes needed by bsp or lod render nodes. - virtual const SViewFrustum* getViewFrustum() const; - - //! Disables or enables the camera to get key or mouse inputs. - //! If this is set to true, the camera will respond to key inputs - //! otherwise not. - virtual void setInputReceiverEnabled(bool enabled); - - //! Returns if the input receiver of the camera is currently enabled. - virtual bool isInputReceiverEnabled(); - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_CAMERA; } - - virtual core::vector3df getAbsolutePosition() const; - - protected: - - void recalculateProjectionMatrix(); - void recalculateViewArea(); - - core::vector3df Target; - core::vector3df UpVector; - - f32 Fovy; // Field of view, in radians. - f32 Aspect; // Aspect ratio. - f32 ZNear; // value of the near view-plane. - f32 ZFar; // Z-value of the far view-plane. - - SViewFrustum ViewArea; - - bool InputReceiverEnabled; - }; - -} // end namespace -} // end namespace - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_CAMERA_SCENE_NODE_H_INCLUDED__ +#define __C_CAMERA_SCENE_NODE_H_INCLUDED__ + +#include "ICameraSceneNode.h" +#include "SViewFrustum.h" + +namespace irr +{ +namespace scene +{ + + class CCameraSceneNode : public ICameraSceneNode + { + public: + + //! constructor + CCameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& lookat = core::vector3df(0,0,100)); + + //! destructor + virtual ~CCameraSceneNode(); + + //! Sets the projection matrix of the camera. The core::matrix4 class has some methods + //! to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH + //! \param projection: The new projection matrix of the camera. + virtual void setProjectionMatrix(const core::matrix4& projection); + + //! Gets the current projection matrix of the camera + //! \return Returns the current projection matrix of the camera. + virtual const core::matrix4& getProjectionMatrix(); + + //! Gets the current view matrix of the camera + //! \return Returns the current view matrix of the camera. + virtual const core::matrix4& getViewMatrix(); + + //! It is possible to send mouse and key events to the camera. Most cameras + //! may ignore this input, but camera scene nodes which are created for + //! example with scene::ISceneManager::addMayaCameraSceneNode or + //! scene::ISceneManager::addMeshViewerCameraSceneNode, may want to get this input + //! for changing their position, look at target or whatever. + virtual bool OnEvent(SEvent event); + + //! sets the look at target of the camera + //! \param pos: Look at target of the camera. + virtual void setTarget(const core::vector3df& pos); + + //! Gets the current look at target of the camera + //! \return Returns the current look at target of the camera + virtual core::vector3df getTarget() const; + + //! Sets the up vector of the camera. + //! \param pos: New upvector of the camera. + virtual void setUpVector(const core::vector3df& pos); + + //! Gets the up vector of the camera. + //! \return Returns the up vector of the camera. + virtual core::vector3df getUpVector() const; + + //! Gets distance from the camera to the near plane. + //! \return Value of the near plane of the camera. + virtual f32 getNearValue(); + + //! Gets the distance from the camera to the far plane. + //! \return Value of the far plane of the camera. + virtual f32 getFarValue(); + + //! Get the aspect ratio of the camera. + //! \return The aspect ratio of the camera. + virtual f32 getAspectRatio(); + + //! Gets the field of view of the camera. + //! \return Field of view of the camera + virtual f32 getFOV(); + + //! Sets the value of the near clipping plane. (default: 1.0f) + virtual void setNearValue(f32 zn); + + //! Sets the value of the far clipping plane (default: 2000.0f) + virtual void setFarValue(f32 zf); + + //! Sets the aspect ratio (default: 4.0f / 3.0f) + virtual void setAspectRatio(f32 aspect); + + //! Sets the field of view (Default: PI / 3.5f) + virtual void setFOV(f32 fovy); + + //! PreRender event + virtual void OnRegisterSceneNode(); + + //! Render + virtual void render(); + + //! Returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! Returns the view area. Sometimes needed by bsp or lod render nodes. + virtual const SViewFrustum* getViewFrustum() const; + + //! Disables or enables the camera to get key or mouse inputs. + //! If this is set to true, the camera will respond to key inputs + //! otherwise not. + virtual void setInputReceiverEnabled(bool enabled); + + //! Returns if the input receiver of the camera is currently enabled. + virtual bool isInputReceiverEnabled(); + + //! Writes attributes of the scene node. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_CAMERA; } + + virtual core::vector3df getAbsolutePosition() const; + + protected: + + void recalculateProjectionMatrix(); + void recalculateViewArea(); + + core::vector3df Target; + core::vector3df UpVector; + + f32 Fovy; // Field of view, in radians. + f32 Aspect; // Aspect ratio. + f32 ZNear; // value of the near view-plane. + f32 ZFar; // Z-value of the far view-plane. + + SViewFrustum ViewArea; + + bool InputReceiverEnabled; + }; + +} // end namespace +} // end namespace + +#endif + diff --git a/src/dep/src/irrlicht/CColladaFileLoader.cpp b/src/dep/src/irrlicht/CColladaFileLoader.cpp index c30b9f8..1ba4fcc 100644 --- a/src/dep/src/irrlicht/CColladaFileLoader.cpp +++ b/src/dep/src/irrlicht/CColladaFileLoader.cpp @@ -1,1409 +1,1409 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CColladaFileLoader.h" -#include "os.h" -#include "IXMLReader.h" -#include "IDummyTransformationSceneNode.h" -#include "SAnimatedMesh.h" -#include "fast_atof.h" -#include "quaternion.h" -#include "ILightSceneNode.h" -#include "ICameraSceneNode.h" -#include "IMeshManipulator.h" -#include "IAttributes.h" -#include "IMeshCache.h" -#include "IMeshSceneNode.h" -#include "SMeshBufferLightMap.h" - -//#define COLLADA_READER_DEBUG -namespace irr -{ -namespace scene -{ - // currently supported COLLADA tag names - - const core::stringc colladaSectionName = "COLLADA"; - const core::stringc librarySectionName = "library"; - const core::stringc assetSectionName = "asset"; - const core::stringc sceneSectionName = "scene"; - - const core::stringc lightPrefabName = "light"; - const core::stringc cameraPrefabName = "camera"; - const core::stringc materialSectionName = "material"; - const core::stringc geometrySectionName = "geometry"; - - const core::stringc meshSectionName = "mesh"; - const core::stringc sourceSectionName = "source"; - const core::stringc arraySectionName = "array"; - const core::stringc accessorSectionName = "accessor"; - const core::stringc verticesSectionName = "vertices"; - const core::stringc inputTagName = "input"; - const core::stringc polygonsSectionName = "polygons"; - const core::stringc polygonName = "p"; - const core::stringc nodeSectionName = "node"; - const core::stringc lookatNodeName = "lookat"; - const core::stringc matrixNodeName = "matrix"; - const core::stringc perspectiveNodeName = "perspective"; - const core::stringc rotateNodeName = "rotate"; - const core::stringc scaleNodeName = "scale"; - const core::stringc translateNodeName = "translate"; - const core::stringc skewNodeName = "skew"; - const core::stringc instanceNodeName = "instance"; - - const core::stringc paramTagName = "param"; - - const char* const inputSemanticNames[] = {"POSITION", "VERTEX", "NORMAL", "TEXCOORD", - "UV", "TANGENT", 0}; - - //! following class is for holding and creating instances of library objects, - //! named prefabs in this loader. - class CPrefab : public IColladaPrefab - { - public: - - CPrefab(const char* id) - { - Id = id; - } - - //! creates an instance of this prefab - virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, - scene::ISceneManager* mgr) - { - // empty implementation - return 0; - } - - //! returns id of this prefab - virtual const c8* getId() - { - return Id.c_str(); - } - - protected: - - core::stringc Id; - }; - - - //! prefab for a light scene node - class CLightPrefab : public CPrefab - { - public: - - CLightPrefab(const char* id) : CPrefab(id) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA: loaded light prefab:", Id.c_str()); - #endif - } - - video::SLight LightData; // publically accessible - - //! creates an instance of this prefab - virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, - scene::ISceneManager* mgr) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA: Constructing light instance:", Id.c_str()); - #endif - - scene::ILightSceneNode* l = mgr->addLightSceneNode(parent); - l->setLightData ( LightData ); - return l; - } - }; - - - //! prefab for a mesh scene node - class CGeometryPrefab : public CPrefab - { - public: - - CGeometryPrefab(const char* id) : CPrefab(id) - { - } - - scene::IMesh* Mesh; // public accessible - - //! creates an instance of this prefab - virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, - scene::ISceneManager* mgr) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA: Constructing mesh instance:", Id.c_str()); - #endif - - scene::ISceneNode* m = mgr->addMeshSceneNode(Mesh, parent); - return m; - } - }; - - - //! prefab for a camera scene node - class CCameraPrefab : public CPrefab - { - public: - - CCameraPrefab(const char* id) - : CPrefab(id), YFov(core::PI / 2.5f), ZNear(1.0f), ZFar(3000.0f) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA: loaded camera prefab:", Id.c_str()); - #endif - } - - // public accessible data - f32 YFov; - f32 ZNear; - f32 ZFar; - - //! creates an instance of this prefab - virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, - scene::ISceneManager* mgr) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA: Constructing camera instance:", Id.c_str()); - #endif - - scene::ICameraSceneNode* c = mgr->addCameraSceneNode(parent); - c->setFOV(YFov); - c->setNearValue(ZNear); - c->setFarValue(ZFar); - return c; - } - }; - -//! Constructor -CColladaFileLoader::CColladaFileLoader(video::IVideoDriver* driver, - scene::ISceneManager* smgr, io::IFileSystem* fs) -: Driver(driver), SceneManager(smgr), FileSystem(fs), DummyMesh(0), - FirstLoadedMesh(0), LoadedMeshCount(0), CreateInstances(false) -{ - -} - - -//! destructor -CColladaFileLoader::~CColladaFileLoader() -{ - if (DummyMesh) - DummyMesh->drop(); - - if (FirstLoadedMesh) - FirstLoadedMesh->drop(); -} - - -//! Returns true if the file maybe is able to be loaded by this class. -/** This decision should be based only on the file extension (e.g. ".cob") */ -bool CColladaFileLoader::isALoadableFileExtension(const c8* fileName) -{ - return strstr(fileName, ".xml") || - strstr(fileName, ".dae"); -} - - -//! creates/loads an animated mesh from the file. -//! \return Pointer to the created mesh. Returns 0 if loading failed. -//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). -//! See IUnknown::drop() for more information. -IAnimatedMesh* CColladaFileLoader::createMesh(irr::io::IReadFile* file) -{ - io::IXMLReaderUTF8* reader = FileSystem->createXMLReaderUTF8(file); - if (!reader) - return 0; - - CurrentlyLoadingMesh = file->getFileName(); - CreateInstances = SceneManager->getParameters()->getAttributeAsBool( - scene::COLLADA_CREATE_SCENE_INSTANCES); - - // read until COLLADA section, skip other parts - - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (colladaSectionName == reader->getNodeName()) - readColladaSection(reader); - else - skipSection(reader, true); // unknown section - } - } - - reader->drop(); - - scene::IAnimatedMesh* returnMesh = DummyMesh; - - // because this loader loads and creates a complete scene instead of - // a single mesh, return an empty dummy mesh to make the scene manager - // know that everything went well. - if (!DummyMesh) - { - DummyMesh = new SAnimatedMesh(); - returnMesh = DummyMesh; - } - - // add the first loaded mesh into the mesh cache too, if more than one - // meshes have been loaded from the file - if (LoadedMeshCount>1 && FirstLoadedMesh) - { - os::Printer::log("Added COLLADA mesh", FirstLoadedMeshName.c_str()); - SceneManager->getMeshCache()->addMesh(FirstLoadedMeshName.c_str(), FirstLoadedMesh); - } - - // clean up temporary loaded data - clearData(); - - returnMesh->grab(); // store until this loader is destroyed - - DummyMesh->drop(); - DummyMesh = 0; - - if (FirstLoadedMesh) - FirstLoadedMesh->drop(); - FirstLoadedMesh = 0; - LoadedMeshCount = 0; - - return returnMesh; -} - - - -//! skips an (unknown) section in the collada document -void CColladaFileLoader::skipSection(io::IXMLReaderUTF8* reader, bool reportSkipping) -{ - #ifndef COLLADA_READER_DEBUG - if (reportSkipping) // always report in COLLADA_READER_DEBUG mode - #endif - os::Printer::log("COLLADA skipping section", core::stringc(reader->getNodeName()).c_str()); - - // skip if this element is empty anyway. - if (reader->isEmptyElement()) - return; - - // read until we've reached the last element in this section - int tagCounter = 1; - - while(tagCounter && reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT && - !reader->isEmptyElement()) - { - #ifdef COLLADA_READER_DEBUG - if (reportSkipping) - os::Printer::log("COLLADA unknown element:", core::stringc(reader->getNodeName()).c_str()); - #endif // COLLADA_READER_DEBUG - - ++tagCounter; - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - --tagCounter; - } -} - - -//! reads the section and its content -void CColladaFileLoader::readColladaSection(io::IXMLReaderUTF8* reader) -{ - if (reader->isEmptyElement()) - return; - - // I ignore version information here. Keep on reading content: - - while(reader->read()) - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (librarySectionName == reader->getNodeName()) - readLibrarySection(reader); - else - if (assetSectionName == reader->getNodeName()) - readAssetSection(reader); - else - if (sceneSectionName == reader->getNodeName()) - readSceneSection(reader); - else - skipSection(reader, true); // unknown section - } -} - - - -//! reads a section and its content -void CColladaFileLoader::readLibrarySection(io::IXMLReaderUTF8* reader) -{ - while(reader->read()) - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (lightPrefabName == reader->getNodeName()) - readLightPrefab(reader); - else - if (materialSectionName == reader->getNodeName()) - readMaterial(reader); - else - if (cameraPrefabName == reader->getNodeName()) - readCameraPrefab(reader); - else - if (geometrySectionName == reader->getNodeName()) - readGeometry(reader); - else - skipSection(reader, true); // unknown section - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (librarySectionName == reader->getNodeName()) - break; // end reading. - } -} - - -//! reads a section and its content -void CColladaFileLoader::readSceneSection(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading scene"); - #endif - - if (reader->isEmptyElement()) - return; - - // read the scene - - while(reader->read()) - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (nodeSectionName == reader->getNodeName()) - readNodeSection(reader, SceneManager->getRootSceneNode()); - else - skipSection(reader, true); // ignore all other sections - } -} - - - -//! reads a section and its content -void CColladaFileLoader::readAssetSection(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading asset"); - #endif - - // don't need asset data so far, so skip it - skipSection(reader, false); -} - - - -//! reads a section and its content -void CColladaFileLoader::readNodeSection(io::IXMLReaderUTF8* reader, scene::ISceneNode* parent) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading node"); - #endif - - if (reader->isEmptyElement()) - return; - - core::stringc name = reader->getAttributeValue("name"); // name of the node - core::matrix4 transform; // transformation of this node - scene::ISceneNode* node = 0; // instance - - // read the node - - while(reader->read()) - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (lookatNodeName == reader->getNodeName()) - transform *= readLookAtNode(reader); - else - if (matrixNodeName == reader->getNodeName()) - transform *= readMatrixNode(reader); - else - if (perspectiveNodeName == reader->getNodeName()) - transform *= readPerspectiveNode(reader); - else - if (rotateNodeName == reader->getNodeName()) - transform *= readRotateNode(reader); - else - if (scaleNodeName == reader->getNodeName()) - transform *= readScaleNode(reader); - else - if (translateNodeName == reader->getNodeName()) - transform *= readTranslateNode(reader); - else - if (skewNodeName == reader->getNodeName()) - transform *= readSkewNode(reader); - else - if (instanceNodeName == reader->getNodeName()) - { - scene::ISceneNode* newnode = 0; - readInstanceNode(reader, parent, &newnode); - - if (node && newnode) - { - // move children from dummy to new node - core::list::Iterator it = node->getChildren().begin(); - for (; it != node->getChildren().end(); it = node->getChildren().begin()) - (*it)->setParent(newnode); - - // remove previous dummy node - node->remove(); - } - - node = newnode; - } - else - if (nodeSectionName == reader->getNodeName()) - { - // create dummy node if there is none yet. - if (!node) - { - scene::IDummyTransformationSceneNode* dummy = - SceneManager->addDummyTransformationSceneNode(parent); - dummy->getRelativeTransformationMatrix() = transform; - node = dummy; - } - - // read and add child - readNodeSection(reader, node); - } - else - skipSection(reader, true); // ignore all other sections - - } // end if node - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (nodeSectionName == reader->getNodeName()) - break; - } - - if (node) - { - // TODO: set transformation correctly into node. - // currently this isn't done correctly. Need to get transformation, - // rotation and scale from the matrix. - core::vector3df trans = transform.getTranslation(); - core::vector3df rot = transform.getRotationDegrees(); - - node->setPosition(trans); - node->setRotation(rot); - node->updateAbsolutePosition(); - - node->setName(name.c_str()); - } -} - - -//! reads a element and its content and creates a matrix from it -core::matrix4 CColladaFileLoader::readLookAtNode(io::IXMLReaderUTF8* reader) -{ - core::matrix4 mat; - if (reader->isEmptyElement()) - return mat; - - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading look at node"); - #endif - - f32 floats[9]; - readFloatsInsideElement(reader, floats, 9); - - mat.buildCameraLookAtMatrixLH( - core::vector3df(floats[0], floats[1], floats[2]), - core::vector3df(floats[3], floats[4], floats[5]), - core::vector3df(floats[6], floats[7], floats[8])); - - return mat; -} - -//! reads a element and its content and creates a matrix from it -core::matrix4 CColladaFileLoader::readSkewNode(io::IXMLReaderUTF8* reader) -{ - core::matrix4 mat; - if (reader->isEmptyElement()) - return mat; - - f32 floats[7]; - readFloatsInsideElement(reader, floats, 7); - - // TODO: build skew matrix from these 7 floats - - os::Printer::log("COLLADA loader warning: not implemented yet.", ELL_WARNING); - - return mat; -} - -//! reads a element and its content and creates a matrix from it -core::matrix4 CColladaFileLoader::readMatrixNode(io::IXMLReaderUTF8* reader) -{ - core::matrix4 mat; - if (reader->isEmptyElement()) - return mat; - - readFloatsInsideElement(reader, mat.pointer(), 16); - - return mat; -} - -//! reads a element and its content and creates a matrix from it -core::matrix4 CColladaFileLoader::readPerspectiveNode(io::IXMLReaderUTF8* reader) -{ - core::matrix4 mat; - if (reader->isEmptyElement()) - return mat; - - f32 floats[1]; - readFloatsInsideElement(reader, floats, 1); - - // TODO: build perspecitve matrix from this float - - os::Printer::log("COLLADA loader warning: not implemented yet.", ELL_WARNING); - - return mat; -} - -//! reads a element and its content and creates a matrix from it -core::matrix4 CColladaFileLoader::readRotateNode(io::IXMLReaderUTF8* reader) -{ - core::matrix4 mat; - if (reader->isEmptyElement()) - return mat; - - f32 floats[4]; - readFloatsInsideElement(reader, floats, 4); - - core::quaternion q(floats[0], floats[1], floats[2], floats[3]); - mat = q.getMatrix(); - - return mat; -} - -//! reads a element and its content and creates a matrix from it -core::matrix4 CColladaFileLoader::readScaleNode(io::IXMLReaderUTF8* reader) -{ - core::matrix4 mat; - if (reader->isEmptyElement()) - return mat; - - f32 floats[3]; - readFloatsInsideElement(reader, floats, 3); - - mat.setScale(core::vector3df(floats[0], floats[1], floats[2])); - - return mat; -} - - -//! reads a element and its content and creates a matrix from it -core::matrix4 CColladaFileLoader::readTranslateNode(io::IXMLReaderUTF8* reader) -{ - core::matrix4 mat; - if (reader->isEmptyElement()) - return mat; - - f32 floats[3]; - readFloatsInsideElement(reader, floats, 3); - - mat.setTranslation(core::vector3df(floats[0], floats[1], floats[2])); - - return mat; -} - -//! reads a node and creates a scene node from it -void CColladaFileLoader::readInstanceNode(io::IXMLReaderUTF8* reader, scene::ISceneNode* parent, - scene::ISceneNode** outNode) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading instance"); - #endif - - // find prefab of the specified id - core::stringc url = reader->getAttributeValue("url"); - uriToId(url); - - if (CreateInstances) - for (int i=0; i<(int)Prefabs.size(); ++i) - if (url == Prefabs[i]->getId()) - { - *outNode = Prefabs[i]->addInstance(parent, SceneManager); - if (*outNode) - (*outNode)->setName(reader->getAttributeValue("id")); - return; - } -} - -//! reads a element and stores it as prefab -void CColladaFileLoader::readCameraPrefab(io::IXMLReaderUTF8* reader) -{ - CCameraPrefab* prefab = new CCameraPrefab(reader->getAttributeValue("id")); - - if (!reader->isEmptyElement()) - { - readColladaParameters(reader, cameraPrefabName); - - SColladaParam* p; - - p = getColladaParameter(ECPN_YFOV); - if (p && p->Type == ECPT_FLOAT) - prefab->YFov = p->Floats[0]; - - p = getColladaParameter(ECPN_ZNEAR); - if (p && p->Type == ECPT_FLOAT) - prefab->ZNear = p->Floats[0]; - - p = getColladaParameter(ECPN_ZFAR); - if (p && p->Type == ECPT_FLOAT) - prefab->ZFar = p->Floats[0]; - } - - Prefabs.push_back(prefab); -} - - -//! reads a element and stores it in the material section -void CColladaFileLoader::readMaterial(io::IXMLReaderUTF8* reader) -{ - SColladaMaterial material; - material.Id = reader->getAttributeValue("id"); - - if (!reader->isEmptyElement()) - { - // TODO: implement material parsing later. - // for now we only read and discard then all tags. - readColladaParameters(reader, materialSectionName); - } - - // add material to list of loaded materials. - Materials.push_back(material); -} - -//! reads a element and stores it as mesh if possible -void CColladaFileLoader::readGeometry(io::IXMLReaderUTF8* reader) -{ - core::stringc id = reader->getAttributeValue("id"); - - core::stringc VertexPositionSource; // each mesh has exactly one member, containing - // a POSITION input. This string stores the source of this input. - core::array sources; - bool okToReadArray = false; - - SAnimatedMesh* amesh = new SAnimatedMesh(); - scene::SMesh* mesh = new SMesh(); - amesh->addMesh(mesh); - - // read sources with arrays and accessor for each mesh - - if (!reader->isEmptyElement()) - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - const char* nodeName = reader->getNodeName(); - if (meshSectionName == nodeName) - { - // inside a mesh section. Don't have to do anything here. - } - else - if (sourceSectionName == nodeName) - { - // create a new source - sources.push_back(SSource()); - sources.getLast().Id = reader->getAttributeValue("id"); - - #ifdef COLLADA_READER_DEBUG - os::Printer::log("Loaded source", sources.getLast().Id.c_str()); - #endif - } - else - if (arraySectionName == nodeName) - { - // create a new array and read it. - if (!sources.empty()) - { - sources.getLast().Array.Name = reader->getAttributeValue("id"); - - int count = reader->getAttributeValueAsInt("count"); - sources.getLast().Array.Data.set_used(count); // pre allocate - - // check if type of array is ok - const char* type = reader->getAttributeValue("type"); - okToReadArray = (!strcmp("float", type) || !strcmp("int", type)); - - #ifdef COLLADA_READER_DEBUG - os::Printer::log("Read array", sources.getLast().Array.Name.c_str()); - #endif - } - #ifdef COLLADA_READER_DEBUG - else - os::Printer::log("Warning, array found, but no source", - reader->getAttributeValue("id")); - #endif - - } - else - if (accessorSectionName == nodeName) - { - SAccessor accessor; - accessor.Count = reader->getAttributeValueAsInt("count"); - accessor.Offset = reader->getAttributeValueAsInt("offset"); - accessor.Stride = reader->getAttributeValueAsInt("stride"); - if (accessor.Stride == 0) - accessor.Stride = 1; - - // the accessor contains some information on how to access (boi!) the array, - // the info is stored in collada style parameters, so just read them. - readColladaParameters(reader, accessorSectionName); - if (!sources.empty()) - { - sources.getLast().Accessors.push_back(accessor); - sources.getLast().Accessors.getLast().Parameters = Parameters; - } - } - else - if (verticesSectionName == nodeName) - { - // read vertex input position source - readColladaInputs(reader, verticesSectionName); - SColladaInput* input = getColladaInput(ECIS_POSITION); - if (input) - VertexPositionSource = input->Source; - } - else - if (polygonsSectionName == nodeName) - { - // read polygons section - readPolygonSection(reader, VertexPositionSource, sources, mesh); - } - - } // end if node type is element - else - if (reader->getNodeType() == io::EXN_TEXT) - { - // read array data - if (okToReadArray && !sources.empty()) - { - core::array& a = sources.getLast().Array.Data; - core::stringc data = reader->getNodeData(); - const c8* p = &data[0]; - - for (int i=0; i<(int)a.size(); ++i) - { - findNextNoneWhiteSpace(&p); - a[i] = readFloat(&p); - } - } // end reading array - - okToReadArray = false; - - } // end if node type is text - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (geometrySectionName == reader->getNodeName()) - { - // end of geometry section reached, cancel out - break; - } - } - } // end while reader->read(); - - // add mesh as geometry - - mesh->recalculateBoundingBox(); - - // create virtual file name - core::stringc filename = CurrentlyLoadingMesh; - filename += '#'; - filename += id; - - // add to scene manager - if (LoadedMeshCount) - { - SceneManager->getMeshCache()->addMesh(filename.c_str(), amesh); - os::Printer::log("Added COLLADA mesh", filename.c_str()); - } - else - { - FirstLoadedMeshName = filename; - FirstLoadedMesh = amesh; - FirstLoadedMesh->grab(); - } - - ++LoadedMeshCount; - mesh->drop(); - amesh->drop(); - - // create geometry prefab - CGeometryPrefab* prefab = new CGeometryPrefab(id.c_str()); - prefab->Mesh = mesh; - Prefabs.push_back(prefab); - - // store as dummy mesh if no instances will be created - if (!CreateInstances && !DummyMesh) - { - DummyMesh = amesh; - DummyMesh->grab(); - } -} - - -struct SInputSlot -{ - f32* Data; // Pointer to source data - ECOLLADA_INPUT_SEMANTIC Semantic; -}; - -struct SPolygon -{ - core::array Indices; -}; - -//! reads a polygons section and creates a mesh from it -void CColladaFileLoader::readPolygonSection(io::IXMLReaderUTF8* reader, - core::stringc vertexPositionSource, core::array& sources, - scene::SMesh* mesh) -{ - core::stringc material = reader->getAttributeValue("material"); - // int polygonCount = reader->getAttributeValueAsInt("count"); - core::array slots; - core::array polygons; - bool parsePolygonOK = false; - int inputSemanticCount = 0; - - // read all and - if (!reader->isEmptyElement()) - while(reader->read()) - { - const char* nodeName = reader->getNodeName(); - - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (inputTagName == nodeName) - { - // read input tag - readColladaInput(reader); - - // create new input slot - if (!Inputs.empty()) - { - SInputSlot slot; - slot.Semantic = Inputs.getLast().Semantic; - - core::stringc sourceArrayURI; - - // get input source array id, if it is a vertex input, take - // the -source attribute. - if (slot.Semantic == ECIS_VERTEX) - sourceArrayURI = vertexPositionSource; - else - sourceArrayURI = Inputs.getLast().Source; - - uriToId(sourceArrayURI); - - // find source array (we'll ignore acessors for this implementation) - int s; - for (s=0; s<(int)sources.size(); ++s) - if (sources[s].Id == sourceArrayURI) - { - // slot found - slot.Data = sources[s].Array.Data.pointer(); - break; - } - - if (s == (int)sources.size()) - os::Printer::log("COLLADA Warning, polygon input source not found", - sourceArrayURI.c_str()); - else - slots.push_back(slot); - - #ifdef COLLADA_READER_DEBUG - // print slot - // core::stringc tmp = "Added slot "; - // tmp += inputSemanticNames[Inputs.getLast().Semantic]; - // tmp += " sourceArray:"; - // tmp += sourceArrayURI; - // os::Printer::log(tmp.c_str()); - #endif - - ++inputSemanticCount; - } - } // end is input node - else - if (polygonName == nodeName) - { - parsePolygonOK = true; - polygons.push_back(SPolygon()); - } // end is polygon node - - } // end is element node - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (polygonName == nodeName) - parsePolygonOK = false; // end parsing a polygon - else - if (polygonsSectionName == nodeName) - break; // cancel out and create mesh - - } // end is element end - else - if (reader->getNodeType() == io::EXN_TEXT) - { - if (parsePolygonOK && polygons.size()) - { - // parse this text and add it to the last polygon data - core::stringc data = reader->getNodeData(); - const c8* p = &data[0]; - SPolygon& poly = polygons.getLast(); - while(*p) - { - findNextNoneWhiteSpace(&p); - poly.Indices.push_back(readInt(&p)); - } - parsePolygonOK = false; - } - } - - } // end while reader->read() - - if (inputSemanticCount == 0 || inputSemanticCount != (int)slots.size()) - return; // we cannot create the mesh if one of the input semantics wasn't found. - - if (!polygons.size()) - return; // cancel if there are no polygons anyway. - - // analyze content of slots to create a fitting mesh buffer - - int i; - int textureCoordSetCount = 0; - int normalSlotCount = 0; - int secondTexCoordSetIndex = -1; - - for (i=0; i<(int)slots.size(); ++i) - { - if (slots[i].Semantic == ECIS_TEXCOORD || slots[i].Semantic == ECIS_UV ) - { - ++textureCoordSetCount; - - if (textureCoordSetCount==2) - secondTexCoordSetIndex = i; - } - else - if (slots[i].Semantic == ECIS_NORMAL) - ++normalSlotCount; - } - - // if there is more than one texture coordinate set, create a lightmap mesh buffer, - // otherwise use a standard mesh buffer - - scene::IMeshBuffer* buffer = 0; - - if ( textureCoordSetCount <= 1 ) - { - // standard mesh buffer - - scene::SMeshBuffer* mbuffer = new SMeshBuffer(); - buffer = mbuffer; - - for (i=0; i<(int)polygons.size(); ++i) - { - int vertexCount = polygons[i].Indices.size() / inputSemanticCount; - - // for all vertices in array - for (int v=0; v<(int)polygons[i].Indices.size(); v+=inputSemanticCount) - { - video::S3DVertex vtx; - vtx.Color.set(100,255,255,255); - - // for all input semantics - for (int k=0; k<(int)slots.size(); ++k) - { - // build vertex from input semantics. - - int idx = polygons[i].Indices[v+k]; - - switch(slots[k].Semantic) - { - case ECIS_POSITION: - case ECIS_VERTEX: - vtx.Pos.X = slots[k].Data[(idx*3)+0]; - vtx.Pos.Y = slots[k].Data[(idx*3)+1]; - vtx.Pos.Z = slots[k].Data[(idx*3)+2]; - break; - case ECIS_NORMAL: - vtx.Normal.X = slots[k].Data[(idx*3)+0]; - vtx.Normal.Y = slots[k].Data[(idx*3)+1]; - vtx.Normal.Z = slots[k].Data[(idx*3)+2]; - break; - case ECIS_TEXCOORD: - case ECIS_UV: - vtx.TCoords.X = slots[k].Data[(idx*2)+0]; - vtx.TCoords.Y = slots[k].Data[(idx*2)+1]; - break; - case ECIS_TANGENT: - break; - default: - break; - } - } - - mbuffer->Vertices.push_back(vtx); - - } // end for all vertices - - // add vertex indices - int currentVertexCount = mbuffer->Vertices.size(); - int oldVertexCount = currentVertexCount - vertexCount; - for (int face=0; faceIndices.push_back(oldVertexCount + 0); - mbuffer->Indices.push_back(oldVertexCount + 1 + face); - mbuffer->Indices.push_back(oldVertexCount + 2 + face); - } - - } // end for all polygons - } - else - { - // lightmap mesh buffer - - scene::SMeshBufferLightMap* mbuffer = new SMeshBufferLightMap(); - buffer = mbuffer; - - for (i=0; i<(int)polygons.size(); ++i) - { - int vertexCount = polygons[i].Indices.size() / inputSemanticCount; - - // for all vertices in array - for (int v=0; v<(int)polygons[i].Indices.size(); v+=inputSemanticCount) - { - video::S3DVertex2TCoords vtx; - vtx.Color.set(100,255,255,255); - - // for all input semantics - for (int k=0; k<(int)slots.size(); ++k) - { - // build vertex from input semantics. - - int idx = polygons[i].Indices[v+k]; - - switch(slots[k].Semantic) - { - case ECIS_POSITION: - case ECIS_VERTEX: - vtx.Pos.X = slots[k].Data[(idx*3)+0]; - vtx.Pos.Y = slots[k].Data[(idx*3)+1]; - vtx.Pos.Z = slots[k].Data[(idx*3)+2]; - break; - case ECIS_NORMAL: - vtx.Normal.X = slots[k].Data[(idx*3)+0]; - vtx.Normal.Y = slots[k].Data[(idx*3)+1]; - vtx.Normal.Z = slots[k].Data[(idx*3)+2]; - break; - case ECIS_TEXCOORD: - case ECIS_UV: - if (k==secondTexCoordSetIndex) - { - vtx.TCoords2.X = slots[k].Data[(idx*2)+0]; - vtx.TCoords2.Y = slots[k].Data[(idx*2)+1]; - } - else - { - vtx.TCoords.X = slots[k].Data[(idx*2)+0]; - vtx.TCoords.Y = slots[k].Data[(idx*2)+1]; - } - break; - case ECIS_TANGENT: - break; - default: - break; - } - } - - mbuffer->Vertices.push_back(vtx); - - } // end for all vertices - - // add vertex indices - int currentVertexCount = mbuffer->Vertices.size(); - int oldVertexCount = currentVertexCount - vertexCount; - for (int face=0; faceIndices.push_back(oldVertexCount + 0); - mbuffer->Indices.push_back(oldVertexCount + 1 + face); - mbuffer->Indices.push_back(oldVertexCount + 2 + face); - } - - } // end for all polygons - } - - // calculate normals if there is no slot for it - - if (!normalSlotCount) - SceneManager->getMeshManipulator()->recalculateNormals(buffer); - - // recalculate bounding box - SceneManager->getMeshManipulator()->recalculateBoundingBox(buffer); - - // add mesh buffer - mesh->addMeshBuffer(buffer); - - buffer->drop(); -} - - -//! reads a element and stores it as prefab -void CColladaFileLoader::readLightPrefab(io::IXMLReaderUTF8* reader) -{ - CLightPrefab* prefab = new CLightPrefab(reader->getAttributeValue("id")); - - if (!reader->isEmptyElement()) - { - readColladaParameters(reader, lightPrefabName); - - SColladaParam* p = getColladaParameter(ECPN_COLOR); - if (p && p->Type == ECPT_FLOAT3) - prefab->LightData.DiffuseColor.set(p->Floats[0], p->Floats[1], p->Floats[2]); - } - - Prefabs.push_back(prefab); -} - - -//! returns a collada parameter or none if not found -SColladaParam* CColladaFileLoader::getColladaParameter(ECOLLADA_PARAM_NAME name) -{ - for (int i=0; i<(int)Parameters.size(); ++i) - if (Parameters[i].Name == name) - return &Parameters[i]; - - return 0; -} - -//! returns a collada input or none if not found -SColladaInput* CColladaFileLoader::getColladaInput(ECOLLADA_INPUT_SEMANTIC input) -{ - for (int i=0; i<(int)Inputs.size(); ++i) - if (Inputs[i].Semantic == input) - return &Inputs[i]; - - return 0; -} - - -//! reads a collada input tag and adds it to the input parameter -void CColladaFileLoader::readColladaInput(io::IXMLReaderUTF8* reader) -{ - // parse param - SColladaInput p; - - // get type - int i; - core::stringc semanticName = reader->getAttributeValue("semantic"); - for (i=0; inputSemanticNames[i]; ++i) - if (semanticName == inputSemanticNames[i]) - { - p.Semantic = (ECOLLADA_INPUT_SEMANTIC)i; - break; - } - - // get source - p.Source = reader->getAttributeValue("source"); - - // add input - Inputs.push_back(p); -} - -//! parses all collada inuts inside an element and stores them in Parameters -void CColladaFileLoader::readColladaInputs(io::IXMLReaderUTF8* reader, const core::stringc& parentName) -{ - Inputs.clear(); - - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT && - inputTagName == reader->getNodeName()) - { - readColladaInput(reader); - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (parentName == reader->getNodeName()) - return; // end of parent reached - } - - } // end while reader->read(); -} - -//! parses all collada parameters inside an element and stores them in Parameters -void CColladaFileLoader::readColladaParameters(io::IXMLReaderUTF8* reader, - const core::stringc& parentName) -{ - Parameters.clear(); - - const char* const paramNames[] = {"COLOR", "AMBIENT", "DIFFUSE", - "SPECULAR", "SHININESS", "YFOV", "ZNEAR", "ZFAR", 0}; - - const char* const typeNames[] = {"float", "float2", "float3", 0}; - - while(reader->read()) - { - const char* nodeName = reader->getNodeName(); - if (reader->getNodeType() == io::EXN_ELEMENT && - paramTagName == nodeName) - { - // parse param - SColladaParam p; - - // get type - int i; - core::stringc typeName = reader->getAttributeValue("type"); - for (i=0; typeNames[i]; ++i) - if (typeName == typeNames[i]) - { - p.Type = (ECOLLADA_PARAM_TYPE)i; - break; - } - - // get name - core::stringc nameName = reader->getAttributeValue("name"); - for (i=0; typeNames[i]; ++i) - if (nameName == paramNames[i]) - { - p.Name = (ECOLLADA_PARAM_NAME)i; - break; - } - - // read parameter data inside parameter tags - switch(p.Type) - { - case ECPT_FLOAT: - case ECPT_FLOAT2: - case ECPT_FLOAT3: - case ECPT_FLOAT4: - readFloatsInsideElement(reader, p.Floats, p.Type - ECPT_FLOAT + 1); - break; - - // TODO: other types of data (ints, bools or whatever) - default: - break; - } - - // add param - Parameters.push_back(p); - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (parentName == reader->getNodeName()) - return; // end of parent reached - } - - } // end while reader->read(); -} - - -//! parses a float from a char pointer and moves the pointer -//! to the end of the parsed float -inline f32 CColladaFileLoader::readFloat(const c8** p) -{ - f32 ftmp; - *p = core::fast_atof_move(*p, ftmp); - return ftmp; -} - -//! parses an int from a char pointer and moves the pointer to -//! the end of the parsed float -inline s32 CColladaFileLoader::readInt(const c8** p) -{ - return (s32)readFloat(p); -} - -//! places pointer to next begin of a token -void CColladaFileLoader::findNextNoneWhiteSpace(const c8** start) -{ - const c8* p = *start; - - while(*p && (*p==' ' || *p=='\n' || *p=='\r' || *p=='\t')) - ++p; - - // TODO: skip comments - - *start = p; -} - - -//! reads floats from inside of xml element until end of xml element -void CColladaFileLoader::readFloatsInsideElement(io::IXMLReaderUTF8* reader, f32* floats, s32 count) -{ - if (reader->isEmptyElement()) - return; - - while(reader->read()) - { - // TODO: check for comments inside the element - // and ignore them. - - if (reader->getNodeType() == io::EXN_TEXT) - { - // parse float data - core::stringc data = reader->getNodeData(); - const c8* p = &data[0]; - - for (int i=0; igetNodeType() == io::EXN_ELEMENT_END) - break; // end parsing text - } -} - - -//! clears all loaded data -void CColladaFileLoader::clearData() -{ - // delete all prefabs - - for (int i=0; i<(int)Prefabs.size(); ++i) - Prefabs[i]->drop(); - - Prefabs.clear(); - - // clear all parameters - Parameters.clear(); - - // clear all materials - Materials.clear(); - - // clear all inputs - Inputs.clear(); -} - -//! changes the XML URI into an internal id -void CColladaFileLoader::uriToId(core::stringc& str) -{ - // currently, we only remove the # from the begin if there - // because we simply don't support referencing other files. - if (!str.size()) - return; - - if (str[0] == '#') - str.erase(0); -} - - - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CColladaFileLoader.h" +#include "os.h" +#include "IXMLReader.h" +#include "IDummyTransformationSceneNode.h" +#include "SAnimatedMesh.h" +#include "fast_atof.h" +#include "quaternion.h" +#include "ILightSceneNode.h" +#include "ICameraSceneNode.h" +#include "IMeshManipulator.h" +#include "IAttributes.h" +#include "IMeshCache.h" +#include "IMeshSceneNode.h" +#include "SMeshBufferLightMap.h" + +//#define COLLADA_READER_DEBUG +namespace irr +{ +namespace scene +{ + // currently supported COLLADA tag names + + const core::stringc colladaSectionName = "COLLADA"; + const core::stringc librarySectionName = "library"; + const core::stringc assetSectionName = "asset"; + const core::stringc sceneSectionName = "scene"; + + const core::stringc lightPrefabName = "light"; + const core::stringc cameraPrefabName = "camera"; + const core::stringc materialSectionName = "material"; + const core::stringc geometrySectionName = "geometry"; + + const core::stringc meshSectionName = "mesh"; + const core::stringc sourceSectionName = "source"; + const core::stringc arraySectionName = "array"; + const core::stringc accessorSectionName = "accessor"; + const core::stringc verticesSectionName = "vertices"; + const core::stringc inputTagName = "input"; + const core::stringc polygonsSectionName = "polygons"; + const core::stringc polygonName = "p"; + const core::stringc nodeSectionName = "node"; + const core::stringc lookatNodeName = "lookat"; + const core::stringc matrixNodeName = "matrix"; + const core::stringc perspectiveNodeName = "perspective"; + const core::stringc rotateNodeName = "rotate"; + const core::stringc scaleNodeName = "scale"; + const core::stringc translateNodeName = "translate"; + const core::stringc skewNodeName = "skew"; + const core::stringc instanceNodeName = "instance"; + + const core::stringc paramTagName = "param"; + + const char* const inputSemanticNames[] = {"POSITION", "VERTEX", "NORMAL", "TEXCOORD", + "UV", "TANGENT", 0}; + + //! following class is for holding and creating instances of library objects, + //! named prefabs in this loader. + class CPrefab : public IColladaPrefab + { + public: + + CPrefab(const char* id) + { + Id = id; + } + + //! creates an instance of this prefab + virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, + scene::ISceneManager* mgr) + { + // empty implementation + return 0; + } + + //! returns id of this prefab + virtual const c8* getId() + { + return Id.c_str(); + } + + protected: + + core::stringc Id; + }; + + + //! prefab for a light scene node + class CLightPrefab : public CPrefab + { + public: + + CLightPrefab(const char* id) : CPrefab(id) + { + #ifdef COLLADA_READER_DEBUG + os::Printer::log("COLLADA: loaded light prefab:", Id.c_str()); + #endif + } + + video::SLight LightData; // publically accessible + + //! creates an instance of this prefab + virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, + scene::ISceneManager* mgr) + { + #ifdef COLLADA_READER_DEBUG + os::Printer::log("COLLADA: Constructing light instance:", Id.c_str()); + #endif + + scene::ILightSceneNode* l = mgr->addLightSceneNode(parent); + l->setLightData ( LightData ); + return l; + } + }; + + + //! prefab for a mesh scene node + class CGeometryPrefab : public CPrefab + { + public: + + CGeometryPrefab(const char* id) : CPrefab(id) + { + } + + scene::IMesh* Mesh; // public accessible + + //! creates an instance of this prefab + virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, + scene::ISceneManager* mgr) + { + #ifdef COLLADA_READER_DEBUG + os::Printer::log("COLLADA: Constructing mesh instance:", Id.c_str()); + #endif + + scene::ISceneNode* m = mgr->addMeshSceneNode(Mesh, parent); + return m; + } + }; + + + //! prefab for a camera scene node + class CCameraPrefab : public CPrefab + { + public: + + CCameraPrefab(const char* id) + : CPrefab(id), YFov(core::PI / 2.5f), ZNear(1.0f), ZFar(3000.0f) + { + #ifdef COLLADA_READER_DEBUG + os::Printer::log("COLLADA: loaded camera prefab:", Id.c_str()); + #endif + } + + // public accessible data + f32 YFov; + f32 ZNear; + f32 ZFar; + + //! creates an instance of this prefab + virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, + scene::ISceneManager* mgr) + { + #ifdef COLLADA_READER_DEBUG + os::Printer::log("COLLADA: Constructing camera instance:", Id.c_str()); + #endif + + scene::ICameraSceneNode* c = mgr->addCameraSceneNode(parent); + c->setFOV(YFov); + c->setNearValue(ZNear); + c->setFarValue(ZFar); + return c; + } + }; + +//! Constructor +CColladaFileLoader::CColladaFileLoader(video::IVideoDriver* driver, + scene::ISceneManager* smgr, io::IFileSystem* fs) +: Driver(driver), SceneManager(smgr), FileSystem(fs), DummyMesh(0), + FirstLoadedMesh(0), LoadedMeshCount(0), CreateInstances(false) +{ + +} + + +//! destructor +CColladaFileLoader::~CColladaFileLoader() +{ + if (DummyMesh) + DummyMesh->drop(); + + if (FirstLoadedMesh) + FirstLoadedMesh->drop(); +} + + +//! Returns true if the file maybe is able to be loaded by this class. +/** This decision should be based only on the file extension (e.g. ".cob") */ +bool CColladaFileLoader::isALoadableFileExtension(const c8* fileName) +{ + return strstr(fileName, ".xml") || + strstr(fileName, ".dae"); +} + + +//! creates/loads an animated mesh from the file. +//! \return Pointer to the created mesh. Returns 0 if loading failed. +//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). +//! See IUnknown::drop() for more information. +IAnimatedMesh* CColladaFileLoader::createMesh(irr::io::IReadFile* file) +{ + io::IXMLReaderUTF8* reader = FileSystem->createXMLReaderUTF8(file); + if (!reader) + return 0; + + CurrentlyLoadingMesh = file->getFileName(); + CreateInstances = SceneManager->getParameters()->getAttributeAsBool( + scene::COLLADA_CREATE_SCENE_INSTANCES); + + // read until COLLADA section, skip other parts + + while(reader->read()) + { + if (reader->getNodeType() == io::EXN_ELEMENT) + { + if (colladaSectionName == reader->getNodeName()) + readColladaSection(reader); + else + skipSection(reader, true); // unknown section + } + } + + reader->drop(); + + scene::IAnimatedMesh* returnMesh = DummyMesh; + + // because this loader loads and creates a complete scene instead of + // a single mesh, return an empty dummy mesh to make the scene manager + // know that everything went well. + if (!DummyMesh) + { + DummyMesh = new SAnimatedMesh(); + returnMesh = DummyMesh; + } + + // add the first loaded mesh into the mesh cache too, if more than one + // meshes have been loaded from the file + if (LoadedMeshCount>1 && FirstLoadedMesh) + { + os::Printer::log("Added COLLADA mesh", FirstLoadedMeshName.c_str()); + SceneManager->getMeshCache()->addMesh(FirstLoadedMeshName.c_str(), FirstLoadedMesh); + } + + // clean up temporary loaded data + clearData(); + + returnMesh->grab(); // store until this loader is destroyed + + DummyMesh->drop(); + DummyMesh = 0; + + if (FirstLoadedMesh) + FirstLoadedMesh->drop(); + FirstLoadedMesh = 0; + LoadedMeshCount = 0; + + return returnMesh; +} + + + +//! skips an (unknown) section in the collada document +void CColladaFileLoader::skipSection(io::IXMLReaderUTF8* reader, bool reportSkipping) +{ + #ifndef COLLADA_READER_DEBUG + if (reportSkipping) // always report in COLLADA_READER_DEBUG mode + #endif + os::Printer::log("COLLADA skipping section", core::stringc(reader->getNodeName()).c_str()); + + // skip if this element is empty anyway. + if (reader->isEmptyElement()) + return; + + // read until we've reached the last element in this section + int tagCounter = 1; + + while(tagCounter && reader->read()) + { + if (reader->getNodeType() == io::EXN_ELEMENT && + !reader->isEmptyElement()) + { + #ifdef COLLADA_READER_DEBUG + if (reportSkipping) + os::Printer::log("COLLADA unknown element:", core::stringc(reader->getNodeName()).c_str()); + #endif // COLLADA_READER_DEBUG + + ++tagCounter; + } + else + if (reader->getNodeType() == io::EXN_ELEMENT_END) + --tagCounter; + } +} + + +//! reads the section and its content +void CColladaFileLoader::readColladaSection(io::IXMLReaderUTF8* reader) +{ + if (reader->isEmptyElement()) + return; + + // I ignore version information here. Keep on reading content: + + while(reader->read()) + if (reader->getNodeType() == io::EXN_ELEMENT) + { + if (librarySectionName == reader->getNodeName()) + readLibrarySection(reader); + else + if (assetSectionName == reader->getNodeName()) + readAssetSection(reader); + else + if (sceneSectionName == reader->getNodeName()) + readSceneSection(reader); + else + skipSection(reader, true); // unknown section + } +} + + + +//! reads a section and its content +void CColladaFileLoader::readLibrarySection(io::IXMLReaderUTF8* reader) +{ + while(reader->read()) + if (reader->getNodeType() == io::EXN_ELEMENT) + { + if (lightPrefabName == reader->getNodeName()) + readLightPrefab(reader); + else + if (materialSectionName == reader->getNodeName()) + readMaterial(reader); + else + if (cameraPrefabName == reader->getNodeName()) + readCameraPrefab(reader); + else + if (geometrySectionName == reader->getNodeName()) + readGeometry(reader); + else + skipSection(reader, true); // unknown section + } + else + if (reader->getNodeType() == io::EXN_ELEMENT_END) + { + if (librarySectionName == reader->getNodeName()) + break; // end reading. + } +} + + +//! reads a section and its content +void CColladaFileLoader::readSceneSection(io::IXMLReaderUTF8* reader) +{ + #ifdef COLLADA_READER_DEBUG + os::Printer::log("COLLADA reading scene"); + #endif + + if (reader->isEmptyElement()) + return; + + // read the scene + + while(reader->read()) + if (reader->getNodeType() == io::EXN_ELEMENT) + { + if (nodeSectionName == reader->getNodeName()) + readNodeSection(reader, SceneManager->getRootSceneNode()); + else + skipSection(reader, true); // ignore all other sections + } +} + + + +//! reads a section and its content +void CColladaFileLoader::readAssetSection(io::IXMLReaderUTF8* reader) +{ + #ifdef COLLADA_READER_DEBUG + os::Printer::log("COLLADA reading asset"); + #endif + + // don't need asset data so far, so skip it + skipSection(reader, false); +} + + + +//! reads a section and its content +void CColladaFileLoader::readNodeSection(io::IXMLReaderUTF8* reader, scene::ISceneNode* parent) +{ + #ifdef COLLADA_READER_DEBUG + os::Printer::log("COLLADA reading node"); + #endif + + if (reader->isEmptyElement()) + return; + + core::stringc name = reader->getAttributeValue("name"); // name of the node + core::matrix4 transform; // transformation of this node + scene::ISceneNode* node = 0; // instance + + // read the node + + while(reader->read()) + if (reader->getNodeType() == io::EXN_ELEMENT) + { + if (lookatNodeName == reader->getNodeName()) + transform *= readLookAtNode(reader); + else + if (matrixNodeName == reader->getNodeName()) + transform *= readMatrixNode(reader); + else + if (perspectiveNodeName == reader->getNodeName()) + transform *= readPerspectiveNode(reader); + else + if (rotateNodeName == reader->getNodeName()) + transform *= readRotateNode(reader); + else + if (scaleNodeName == reader->getNodeName()) + transform *= readScaleNode(reader); + else + if (translateNodeName == reader->getNodeName()) + transform *= readTranslateNode(reader); + else + if (skewNodeName == reader->getNodeName()) + transform *= readSkewNode(reader); + else + if (instanceNodeName == reader->getNodeName()) + { + scene::ISceneNode* newnode = 0; + readInstanceNode(reader, parent, &newnode); + + if (node && newnode) + { + // move children from dummy to new node + core::list::Iterator it = node->getChildren().begin(); + for (; it != node->getChildren().end(); it = node->getChildren().begin()) + (*it)->setParent(newnode); + + // remove previous dummy node + node->remove(); + } + + node = newnode; + } + else + if (nodeSectionName == reader->getNodeName()) + { + // create dummy node if there is none yet. + if (!node) + { + scene::IDummyTransformationSceneNode* dummy = + SceneManager->addDummyTransformationSceneNode(parent); + dummy->getRelativeTransformationMatrix() = transform; + node = dummy; + } + + // read and add child + readNodeSection(reader, node); + } + else + skipSection(reader, true); // ignore all other sections + + } // end if node + else + if (reader->getNodeType() == io::EXN_ELEMENT_END) + { + if (nodeSectionName == reader->getNodeName()) + break; + } + + if (node) + { + // TODO: set transformation correctly into node. + // currently this isn't done correctly. Need to get transformation, + // rotation and scale from the matrix. + core::vector3df trans = transform.getTranslation(); + core::vector3df rot = transform.getRotationDegrees(); + + node->setPosition(trans); + node->setRotation(rot); + node->updateAbsolutePosition(); + + node->setName(name.c_str()); + } +} + + +//! reads a element and its content and creates a matrix from it +core::matrix4 CColladaFileLoader::readLookAtNode(io::IXMLReaderUTF8* reader) +{ + core::matrix4 mat; + if (reader->isEmptyElement()) + return mat; + + #ifdef COLLADA_READER_DEBUG + os::Printer::log("COLLADA reading look at node"); + #endif + + f32 floats[9]; + readFloatsInsideElement(reader, floats, 9); + + mat.buildCameraLookAtMatrixLH( + core::vector3df(floats[0], floats[1], floats[2]), + core::vector3df(floats[3], floats[4], floats[5]), + core::vector3df(floats[6], floats[7], floats[8])); + + return mat; +} + +//! reads a element and its content and creates a matrix from it +core::matrix4 CColladaFileLoader::readSkewNode(io::IXMLReaderUTF8* reader) +{ + core::matrix4 mat; + if (reader->isEmptyElement()) + return mat; + + f32 floats[7]; + readFloatsInsideElement(reader, floats, 7); + + // TODO: build skew matrix from these 7 floats + + os::Printer::log("COLLADA loader warning: not implemented yet.", ELL_WARNING); + + return mat; +} + +//! reads a element and its content and creates a matrix from it +core::matrix4 CColladaFileLoader::readMatrixNode(io::IXMLReaderUTF8* reader) +{ + core::matrix4 mat; + if (reader->isEmptyElement()) + return mat; + + readFloatsInsideElement(reader, mat.pointer(), 16); + + return mat; +} + +//! reads a element and its content and creates a matrix from it +core::matrix4 CColladaFileLoader::readPerspectiveNode(io::IXMLReaderUTF8* reader) +{ + core::matrix4 mat; + if (reader->isEmptyElement()) + return mat; + + f32 floats[1]; + readFloatsInsideElement(reader, floats, 1); + + // TODO: build perspecitve matrix from this float + + os::Printer::log("COLLADA loader warning: not implemented yet.", ELL_WARNING); + + return mat; +} + +//! reads a element and its content and creates a matrix from it +core::matrix4 CColladaFileLoader::readRotateNode(io::IXMLReaderUTF8* reader) +{ + core::matrix4 mat; + if (reader->isEmptyElement()) + return mat; + + f32 floats[4]; + readFloatsInsideElement(reader, floats, 4); + + core::quaternion q(floats[0], floats[1], floats[2], floats[3]); + mat = q.getMatrix(); + + return mat; +} + +//! reads a element and its content and creates a matrix from it +core::matrix4 CColladaFileLoader::readScaleNode(io::IXMLReaderUTF8* reader) +{ + core::matrix4 mat; + if (reader->isEmptyElement()) + return mat; + + f32 floats[3]; + readFloatsInsideElement(reader, floats, 3); + + mat.setScale(core::vector3df(floats[0], floats[1], floats[2])); + + return mat; +} + + +//! reads a element and its content and creates a matrix from it +core::matrix4 CColladaFileLoader::readTranslateNode(io::IXMLReaderUTF8* reader) +{ + core::matrix4 mat; + if (reader->isEmptyElement()) + return mat; + + f32 floats[3]; + readFloatsInsideElement(reader, floats, 3); + + mat.setTranslation(core::vector3df(floats[0], floats[1], floats[2])); + + return mat; +} + +//! reads a node and creates a scene node from it +void CColladaFileLoader::readInstanceNode(io::IXMLReaderUTF8* reader, scene::ISceneNode* parent, + scene::ISceneNode** outNode) +{ + #ifdef COLLADA_READER_DEBUG + os::Printer::log("COLLADA reading instance"); + #endif + + // find prefab of the specified id + core::stringc url = reader->getAttributeValue("url"); + uriToId(url); + + if (CreateInstances) + for (int i=0; i<(int)Prefabs.size(); ++i) + if (url == Prefabs[i]->getId()) + { + *outNode = Prefabs[i]->addInstance(parent, SceneManager); + if (*outNode) + (*outNode)->setName(reader->getAttributeValue("id")); + return; + } +} + +//! reads a element and stores it as prefab +void CColladaFileLoader::readCameraPrefab(io::IXMLReaderUTF8* reader) +{ + CCameraPrefab* prefab = new CCameraPrefab(reader->getAttributeValue("id")); + + if (!reader->isEmptyElement()) + { + readColladaParameters(reader, cameraPrefabName); + + SColladaParam* p; + + p = getColladaParameter(ECPN_YFOV); + if (p && p->Type == ECPT_FLOAT) + prefab->YFov = p->Floats[0]; + + p = getColladaParameter(ECPN_ZNEAR); + if (p && p->Type == ECPT_FLOAT) + prefab->ZNear = p->Floats[0]; + + p = getColladaParameter(ECPN_ZFAR); + if (p && p->Type == ECPT_FLOAT) + prefab->ZFar = p->Floats[0]; + } + + Prefabs.push_back(prefab); +} + + +//! reads a element and stores it in the material section +void CColladaFileLoader::readMaterial(io::IXMLReaderUTF8* reader) +{ + SColladaMaterial material; + material.Id = reader->getAttributeValue("id"); + + if (!reader->isEmptyElement()) + { + // TODO: implement material parsing later. + // for now we only read and discard then all tags. + readColladaParameters(reader, materialSectionName); + } + + // add material to list of loaded materials. + Materials.push_back(material); +} + +//! reads a element and stores it as mesh if possible +void CColladaFileLoader::readGeometry(io::IXMLReaderUTF8* reader) +{ + core::stringc id = reader->getAttributeValue("id"); + + core::stringc VertexPositionSource; // each mesh has exactly one member, containing + // a POSITION input. This string stores the source of this input. + core::array sources; + bool okToReadArray = false; + + SAnimatedMesh* amesh = new SAnimatedMesh(); + scene::SMesh* mesh = new SMesh(); + amesh->addMesh(mesh); + + // read sources with arrays and accessor for each mesh + + if (!reader->isEmptyElement()) + while(reader->read()) + { + if (reader->getNodeType() == io::EXN_ELEMENT) + { + const char* nodeName = reader->getNodeName(); + if (meshSectionName == nodeName) + { + // inside a mesh section. Don't have to do anything here. + } + else + if (sourceSectionName == nodeName) + { + // create a new source + sources.push_back(SSource()); + sources.getLast().Id = reader->getAttributeValue("id"); + + #ifdef COLLADA_READER_DEBUG + os::Printer::log("Loaded source", sources.getLast().Id.c_str()); + #endif + } + else + if (arraySectionName == nodeName) + { + // create a new array and read it. + if (!sources.empty()) + { + sources.getLast().Array.Name = reader->getAttributeValue("id"); + + int count = reader->getAttributeValueAsInt("count"); + sources.getLast().Array.Data.set_used(count); // pre allocate + + // check if type of array is ok + const char* type = reader->getAttributeValue("type"); + okToReadArray = (!strcmp("float", type) || !strcmp("int", type)); + + #ifdef COLLADA_READER_DEBUG + os::Printer::log("Read array", sources.getLast().Array.Name.c_str()); + #endif + } + #ifdef COLLADA_READER_DEBUG + else + os::Printer::log("Warning, array found, but no source", + reader->getAttributeValue("id")); + #endif + + } + else + if (accessorSectionName == nodeName) + { + SAccessor accessor; + accessor.Count = reader->getAttributeValueAsInt("count"); + accessor.Offset = reader->getAttributeValueAsInt("offset"); + accessor.Stride = reader->getAttributeValueAsInt("stride"); + if (accessor.Stride == 0) + accessor.Stride = 1; + + // the accessor contains some information on how to access (boi!) the array, + // the info is stored in collada style parameters, so just read them. + readColladaParameters(reader, accessorSectionName); + if (!sources.empty()) + { + sources.getLast().Accessors.push_back(accessor); + sources.getLast().Accessors.getLast().Parameters = Parameters; + } + } + else + if (verticesSectionName == nodeName) + { + // read vertex input position source + readColladaInputs(reader, verticesSectionName); + SColladaInput* input = getColladaInput(ECIS_POSITION); + if (input) + VertexPositionSource = input->Source; + } + else + if (polygonsSectionName == nodeName) + { + // read polygons section + readPolygonSection(reader, VertexPositionSource, sources, mesh); + } + + } // end if node type is element + else + if (reader->getNodeType() == io::EXN_TEXT) + { + // read array data + if (okToReadArray && !sources.empty()) + { + core::array& a = sources.getLast().Array.Data; + core::stringc data = reader->getNodeData(); + const c8* p = &data[0]; + + for (int i=0; i<(int)a.size(); ++i) + { + findNextNoneWhiteSpace(&p); + a[i] = readFloat(&p); + } + } // end reading array + + okToReadArray = false; + + } // end if node type is text + else + if (reader->getNodeType() == io::EXN_ELEMENT_END) + { + if (geometrySectionName == reader->getNodeName()) + { + // end of geometry section reached, cancel out + break; + } + } + } // end while reader->read(); + + // add mesh as geometry + + mesh->recalculateBoundingBox(); + + // create virtual file name + core::stringc filename = CurrentlyLoadingMesh; + filename += '#'; + filename += id; + + // add to scene manager + if (LoadedMeshCount) + { + SceneManager->getMeshCache()->addMesh(filename.c_str(), amesh); + os::Printer::log("Added COLLADA mesh", filename.c_str()); + } + else + { + FirstLoadedMeshName = filename; + FirstLoadedMesh = amesh; + FirstLoadedMesh->grab(); + } + + ++LoadedMeshCount; + mesh->drop(); + amesh->drop(); + + // create geometry prefab + CGeometryPrefab* prefab = new CGeometryPrefab(id.c_str()); + prefab->Mesh = mesh; + Prefabs.push_back(prefab); + + // store as dummy mesh if no instances will be created + if (!CreateInstances && !DummyMesh) + { + DummyMesh = amesh; + DummyMesh->grab(); + } +} + + +struct SInputSlot +{ + f32* Data; // Pointer to source data + ECOLLADA_INPUT_SEMANTIC Semantic; +}; + +struct SPolygon +{ + core::array Indices; +}; + +//! reads a polygons section and creates a mesh from it +void CColladaFileLoader::readPolygonSection(io::IXMLReaderUTF8* reader, + core::stringc vertexPositionSource, core::array& sources, + scene::SMesh* mesh) +{ + core::stringc material = reader->getAttributeValue("material"); + // int polygonCount = reader->getAttributeValueAsInt("count"); + core::array slots; + core::array polygons; + bool parsePolygonOK = false; + int inputSemanticCount = 0; + + // read all and + if (!reader->isEmptyElement()) + while(reader->read()) + { + const char* nodeName = reader->getNodeName(); + + if (reader->getNodeType() == io::EXN_ELEMENT) + { + if (inputTagName == nodeName) + { + // read input tag + readColladaInput(reader); + + // create new input slot + if (!Inputs.empty()) + { + SInputSlot slot; + slot.Semantic = Inputs.getLast().Semantic; + + core::stringc sourceArrayURI; + + // get input source array id, if it is a vertex input, take + // the -source attribute. + if (slot.Semantic == ECIS_VERTEX) + sourceArrayURI = vertexPositionSource; + else + sourceArrayURI = Inputs.getLast().Source; + + uriToId(sourceArrayURI); + + // find source array (we'll ignore acessors for this implementation) + int s; + for (s=0; s<(int)sources.size(); ++s) + if (sources[s].Id == sourceArrayURI) + { + // slot found + slot.Data = sources[s].Array.Data.pointer(); + break; + } + + if (s == (int)sources.size()) + os::Printer::log("COLLADA Warning, polygon input source not found", + sourceArrayURI.c_str()); + else + slots.push_back(slot); + + #ifdef COLLADA_READER_DEBUG + // print slot + // core::stringc tmp = "Added slot "; + // tmp += inputSemanticNames[Inputs.getLast().Semantic]; + // tmp += " sourceArray:"; + // tmp += sourceArrayURI; + // os::Printer::log(tmp.c_str()); + #endif + + ++inputSemanticCount; + } + } // end is input node + else + if (polygonName == nodeName) + { + parsePolygonOK = true; + polygons.push_back(SPolygon()); + } // end is polygon node + + } // end is element node + else + if (reader->getNodeType() == io::EXN_ELEMENT_END) + { + if (polygonName == nodeName) + parsePolygonOK = false; // end parsing a polygon + else + if (polygonsSectionName == nodeName) + break; // cancel out and create mesh + + } // end is element end + else + if (reader->getNodeType() == io::EXN_TEXT) + { + if (parsePolygonOK && polygons.size()) + { + // parse this text and add it to the last polygon data + core::stringc data = reader->getNodeData(); + const c8* p = &data[0]; + SPolygon& poly = polygons.getLast(); + while(*p) + { + findNextNoneWhiteSpace(&p); + poly.Indices.push_back(readInt(&p)); + } + parsePolygonOK = false; + } + } + + } // end while reader->read() + + if (inputSemanticCount == 0 || inputSemanticCount != (int)slots.size()) + return; // we cannot create the mesh if one of the input semantics wasn't found. + + if (!polygons.size()) + return; // cancel if there are no polygons anyway. + + // analyze content of slots to create a fitting mesh buffer + + int i; + int textureCoordSetCount = 0; + int normalSlotCount = 0; + int secondTexCoordSetIndex = -1; + + for (i=0; i<(int)slots.size(); ++i) + { + if (slots[i].Semantic == ECIS_TEXCOORD || slots[i].Semantic == ECIS_UV ) + { + ++textureCoordSetCount; + + if (textureCoordSetCount==2) + secondTexCoordSetIndex = i; + } + else + if (slots[i].Semantic == ECIS_NORMAL) + ++normalSlotCount; + } + + // if there is more than one texture coordinate set, create a lightmap mesh buffer, + // otherwise use a standard mesh buffer + + scene::IMeshBuffer* buffer = 0; + + if ( textureCoordSetCount <= 1 ) + { + // standard mesh buffer + + scene::SMeshBuffer* mbuffer = new SMeshBuffer(); + buffer = mbuffer; + + for (i=0; i<(int)polygons.size(); ++i) + { + int vertexCount = polygons[i].Indices.size() / inputSemanticCount; + + // for all vertices in array + for (int v=0; v<(int)polygons[i].Indices.size(); v+=inputSemanticCount) + { + video::S3DVertex vtx; + vtx.Color.set(100,255,255,255); + + // for all input semantics + for (int k=0; k<(int)slots.size(); ++k) + { + // build vertex from input semantics. + + int idx = polygons[i].Indices[v+k]; + + switch(slots[k].Semantic) + { + case ECIS_POSITION: + case ECIS_VERTEX: + vtx.Pos.X = slots[k].Data[(idx*3)+0]; + vtx.Pos.Y = slots[k].Data[(idx*3)+1]; + vtx.Pos.Z = slots[k].Data[(idx*3)+2]; + break; + case ECIS_NORMAL: + vtx.Normal.X = slots[k].Data[(idx*3)+0]; + vtx.Normal.Y = slots[k].Data[(idx*3)+1]; + vtx.Normal.Z = slots[k].Data[(idx*3)+2]; + break; + case ECIS_TEXCOORD: + case ECIS_UV: + vtx.TCoords.X = slots[k].Data[(idx*2)+0]; + vtx.TCoords.Y = slots[k].Data[(idx*2)+1]; + break; + case ECIS_TANGENT: + break; + default: + break; + } + } + + mbuffer->Vertices.push_back(vtx); + + } // end for all vertices + + // add vertex indices + int currentVertexCount = mbuffer->Vertices.size(); + int oldVertexCount = currentVertexCount - vertexCount; + for (int face=0; faceIndices.push_back(oldVertexCount + 0); + mbuffer->Indices.push_back(oldVertexCount + 1 + face); + mbuffer->Indices.push_back(oldVertexCount + 2 + face); + } + + } // end for all polygons + } + else + { + // lightmap mesh buffer + + scene::SMeshBufferLightMap* mbuffer = new SMeshBufferLightMap(); + buffer = mbuffer; + + for (i=0; i<(int)polygons.size(); ++i) + { + int vertexCount = polygons[i].Indices.size() / inputSemanticCount; + + // for all vertices in array + for (int v=0; v<(int)polygons[i].Indices.size(); v+=inputSemanticCount) + { + video::S3DVertex2TCoords vtx; + vtx.Color.set(100,255,255,255); + + // for all input semantics + for (int k=0; k<(int)slots.size(); ++k) + { + // build vertex from input semantics. + + int idx = polygons[i].Indices[v+k]; + + switch(slots[k].Semantic) + { + case ECIS_POSITION: + case ECIS_VERTEX: + vtx.Pos.X = slots[k].Data[(idx*3)+0]; + vtx.Pos.Y = slots[k].Data[(idx*3)+1]; + vtx.Pos.Z = slots[k].Data[(idx*3)+2]; + break; + case ECIS_NORMAL: + vtx.Normal.X = slots[k].Data[(idx*3)+0]; + vtx.Normal.Y = slots[k].Data[(idx*3)+1]; + vtx.Normal.Z = slots[k].Data[(idx*3)+2]; + break; + case ECIS_TEXCOORD: + case ECIS_UV: + if (k==secondTexCoordSetIndex) + { + vtx.TCoords2.X = slots[k].Data[(idx*2)+0]; + vtx.TCoords2.Y = slots[k].Data[(idx*2)+1]; + } + else + { + vtx.TCoords.X = slots[k].Data[(idx*2)+0]; + vtx.TCoords.Y = slots[k].Data[(idx*2)+1]; + } + break; + case ECIS_TANGENT: + break; + default: + break; + } + } + + mbuffer->Vertices.push_back(vtx); + + } // end for all vertices + + // add vertex indices + int currentVertexCount = mbuffer->Vertices.size(); + int oldVertexCount = currentVertexCount - vertexCount; + for (int face=0; faceIndices.push_back(oldVertexCount + 0); + mbuffer->Indices.push_back(oldVertexCount + 1 + face); + mbuffer->Indices.push_back(oldVertexCount + 2 + face); + } + + } // end for all polygons + } + + // calculate normals if there is no slot for it + + if (!normalSlotCount) + SceneManager->getMeshManipulator()->recalculateNormals(buffer); + + // recalculate bounding box + SceneManager->getMeshManipulator()->recalculateBoundingBox(buffer); + + // add mesh buffer + mesh->addMeshBuffer(buffer); + + buffer->drop(); +} + + +//! reads a element and stores it as prefab +void CColladaFileLoader::readLightPrefab(io::IXMLReaderUTF8* reader) +{ + CLightPrefab* prefab = new CLightPrefab(reader->getAttributeValue("id")); + + if (!reader->isEmptyElement()) + { + readColladaParameters(reader, lightPrefabName); + + SColladaParam* p = getColladaParameter(ECPN_COLOR); + if (p && p->Type == ECPT_FLOAT3) + prefab->LightData.DiffuseColor.set(p->Floats[0], p->Floats[1], p->Floats[2]); + } + + Prefabs.push_back(prefab); +} + + +//! returns a collada parameter or none if not found +SColladaParam* CColladaFileLoader::getColladaParameter(ECOLLADA_PARAM_NAME name) +{ + for (int i=0; i<(int)Parameters.size(); ++i) + if (Parameters[i].Name == name) + return &Parameters[i]; + + return 0; +} + +//! returns a collada input or none if not found +SColladaInput* CColladaFileLoader::getColladaInput(ECOLLADA_INPUT_SEMANTIC input) +{ + for (int i=0; i<(int)Inputs.size(); ++i) + if (Inputs[i].Semantic == input) + return &Inputs[i]; + + return 0; +} + + +//! reads a collada input tag and adds it to the input parameter +void CColladaFileLoader::readColladaInput(io::IXMLReaderUTF8* reader) +{ + // parse param + SColladaInput p; + + // get type + int i; + core::stringc semanticName = reader->getAttributeValue("semantic"); + for (i=0; inputSemanticNames[i]; ++i) + if (semanticName == inputSemanticNames[i]) + { + p.Semantic = (ECOLLADA_INPUT_SEMANTIC)i; + break; + } + + // get source + p.Source = reader->getAttributeValue("source"); + + // add input + Inputs.push_back(p); +} + +//! parses all collada inuts inside an element and stores them in Parameters +void CColladaFileLoader::readColladaInputs(io::IXMLReaderUTF8* reader, const core::stringc& parentName) +{ + Inputs.clear(); + + while(reader->read()) + { + if (reader->getNodeType() == io::EXN_ELEMENT && + inputTagName == reader->getNodeName()) + { + readColladaInput(reader); + } + else + if (reader->getNodeType() == io::EXN_ELEMENT_END) + { + if (parentName == reader->getNodeName()) + return; // end of parent reached + } + + } // end while reader->read(); +} + +//! parses all collada parameters inside an element and stores them in Parameters +void CColladaFileLoader::readColladaParameters(io::IXMLReaderUTF8* reader, + const core::stringc& parentName) +{ + Parameters.clear(); + + const char* const paramNames[] = {"COLOR", "AMBIENT", "DIFFUSE", + "SPECULAR", "SHININESS", "YFOV", "ZNEAR", "ZFAR", 0}; + + const char* const typeNames[] = {"float", "float2", "float3", 0}; + + while(reader->read()) + { + const char* nodeName = reader->getNodeName(); + if (reader->getNodeType() == io::EXN_ELEMENT && + paramTagName == nodeName) + { + // parse param + SColladaParam p; + + // get type + int i; + core::stringc typeName = reader->getAttributeValue("type"); + for (i=0; typeNames[i]; ++i) + if (typeName == typeNames[i]) + { + p.Type = (ECOLLADA_PARAM_TYPE)i; + break; + } + + // get name + core::stringc nameName = reader->getAttributeValue("name"); + for (i=0; typeNames[i]; ++i) + if (nameName == paramNames[i]) + { + p.Name = (ECOLLADA_PARAM_NAME)i; + break; + } + + // read parameter data inside parameter tags + switch(p.Type) + { + case ECPT_FLOAT: + case ECPT_FLOAT2: + case ECPT_FLOAT3: + case ECPT_FLOAT4: + readFloatsInsideElement(reader, p.Floats, p.Type - ECPT_FLOAT + 1); + break; + + // TODO: other types of data (ints, bools or whatever) + default: + break; + } + + // add param + Parameters.push_back(p); + } + else + if (reader->getNodeType() == io::EXN_ELEMENT_END) + { + if (parentName == reader->getNodeName()) + return; // end of parent reached + } + + } // end while reader->read(); +} + + +//! parses a float from a char pointer and moves the pointer +//! to the end of the parsed float +inline f32 CColladaFileLoader::readFloat(const c8** p) +{ + f32 ftmp; + *p = core::fast_atof_move(*p, ftmp); + return ftmp; +} + +//! parses an int from a char pointer and moves the pointer to +//! the end of the parsed float +inline s32 CColladaFileLoader::readInt(const c8** p) +{ + return (s32)readFloat(p); +} + +//! places pointer to next begin of a token +void CColladaFileLoader::findNextNoneWhiteSpace(const c8** start) +{ + const c8* p = *start; + + while(*p && (*p==' ' || *p=='\n' || *p=='\r' || *p=='\t')) + ++p; + + // TODO: skip comments + + *start = p; +} + + +//! reads floats from inside of xml element until end of xml element +void CColladaFileLoader::readFloatsInsideElement(io::IXMLReaderUTF8* reader, f32* floats, s32 count) +{ + if (reader->isEmptyElement()) + return; + + while(reader->read()) + { + // TODO: check for comments inside the element + // and ignore them. + + if (reader->getNodeType() == io::EXN_TEXT) + { + // parse float data + core::stringc data = reader->getNodeData(); + const c8* p = &data[0]; + + for (int i=0; igetNodeType() == io::EXN_ELEMENT_END) + break; // end parsing text + } +} + + +//! clears all loaded data +void CColladaFileLoader::clearData() +{ + // delete all prefabs + + for (int i=0; i<(int)Prefabs.size(); ++i) + Prefabs[i]->drop(); + + Prefabs.clear(); + + // clear all parameters + Parameters.clear(); + + // clear all materials + Materials.clear(); + + // clear all inputs + Inputs.clear(); +} + +//! changes the XML URI into an internal id +void CColladaFileLoader::uriToId(core::stringc& str) +{ + // currently, we only remove the # from the begin if there + // because we simply don't support referencing other files. + if (!str.size()) + return; + + if (str[0] == '#') + str.erase(0); +} + + + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CColladaFileLoader.h b/src/dep/src/irrlicht/CColladaFileLoader.h index d6e355b..448eed0 100644 --- a/src/dep/src/irrlicht/CColladaFileLoader.h +++ b/src/dep/src/irrlicht/CColladaFileLoader.h @@ -1,286 +1,286 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_COLLADA_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_COLLADA_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "irrString.h" -#include "SMesh.h" -#include "SMeshBuffer.h" -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - -#ifdef _DEBUG -//#define COLLADA_READER_DEBUG -#endif - -class IColladaPrefab; - -enum ECOLLADA_PARAM_NAME -{ - ECPN_COLOR = 0, - ECPN_AMBIENT, - ECPN_DIFFUSE, - ECPN_SPECULAR, - ECPN_SHININESS, - ECPN_YFOV, - ECPN_ZNEAR, - ECPN_ZFAR, - - ECPN_COUNT -}; - -enum ECOLLADA_PARAM_TYPE -{ - ECPT_FLOAT = 0, - ECPT_FLOAT2, - ECPT_FLOAT3, - ECPT_FLOAT4, - - ECPT_COUNT -}; - -//! Collada Parameter -struct SColladaParam -{ - SColladaParam() - : Name(ECPN_COUNT), Type(ECPT_COUNT) - { - for (int i=0; i<4; ++i) Floats[i] = 0; - } - - ECOLLADA_PARAM_NAME Name; - ECOLLADA_PARAM_TYPE Type; - - f32 Floats[4]; -}; - -enum ECOLLADA_INPUT_SEMANTIC -{ - ECIS_POSITION = 0, - ECIS_VERTEX, - ECIS_NORMAL, - ECIS_TEXCOORD, - ECIS_UV, - ECIS_TANGENT, - - ECIS_COUNT -}; - -//! Collada Input -struct SColladaInput -{ - SColladaInput() - : Semantic(ECIS_COUNT) - { - } - - ECOLLADA_INPUT_SEMANTIC Semantic; - core::stringc Source; -}; - -//! Collada material -struct SColladaMaterial -{ - video::SMaterial Mat; - core::stringc Id; -}; - - -struct SNumberArray // for stroring float and int arrays -{ - core::stringc Name; - core::array Data; -}; - -struct SAccessor -{ - SAccessor() - : Count(0), Offset(0), Stride(1) {} - // I don't store the source of the accessor here because I assume - // it to use the array of the source this accessor is located in. - - int Count; - int Offset; - int Stride; - - core::array Parameters; // parameters defining the accessor -}; - -struct SSource -{ - core::stringc Id; - SNumberArray Array; - core::array Accessors; -}; - - -//! Meshloader capable of loading COLLADA meshes and scene descriptions into Irrlicht. -class CColladaFileLoader : public IMeshLoader -{ -public: - - //! Constructor - CColladaFileLoader(video::IVideoDriver* driver, - scene::ISceneManager* smgr, io::IFileSystem* fs); - - //! destructor - virtual ~CColladaFileLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".cob") - virtual bool isALoadableFileExtension(const c8* fileName); - - //! creates/loads an animated mesh from the file. - //! \return Pointer to the created mesh. Returns 0 if loading failed. - //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). - //! See IUnknown::drop() for more information. - virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); - -private: - - //! skips an (unknown) section in the collada document - void skipSection(io::IXMLReaderUTF8* reader, bool reportSkipping); - - //! reads the section and its content - void readColladaSection(io::IXMLReaderUTF8* reader); - - //! reads a section and its content - void readLibrarySection(io::IXMLReaderUTF8* reader); - - //! reads a section and its content - void readSceneSection(io::IXMLReaderUTF8* reader); - - //! reads a section and its content - void readAssetSection(io::IXMLReaderUTF8* reader); - - //! reads a section and its content - void readNodeSection(io::IXMLReaderUTF8* reader, scene::ISceneNode* parent); - - //! reads a element and its content and creates a matrix from it - core::matrix4 readLookAtNode(io::IXMLReaderUTF8* reader); - - //! reads a element and its content and creates a matrix from it - core::matrix4 readMatrixNode(io::IXMLReaderUTF8* reader); - - //! reads a element and its content and creates a matrix from it - core::matrix4 readPerspectiveNode(io::IXMLReaderUTF8* reader); - - //! reads a element and its content and creates a matrix from it - core::matrix4 readRotateNode(io::IXMLReaderUTF8* reader); - - //! reads a element and its content and creates a matrix from it - core::matrix4 readSkewNode(io::IXMLReaderUTF8* reader); - - //! reads a element and its content and creates a matrix from it - core::matrix4 readScaleNode(io::IXMLReaderUTF8* reader); - - //! reads a element and its content and creates a matrix from it - core::matrix4 readTranslateNode(io::IXMLReaderUTF8* reader); - - //! reads a node and creates a scene node from it - void readInstanceNode(io::IXMLReaderUTF8* reader, scene::ISceneNode* parent, - scene::ISceneNode** outNode); - - //! reads a element and stores it as prefab - void readLightPrefab(io::IXMLReaderUTF8* reader); - - //! reads a element and stores it as prefab - void readCameraPrefab(io::IXMLReaderUTF8* reader); - - //! reads a element and stores it in the material section - void readMaterial(io::IXMLReaderUTF8* reader); - - //! reads a element and stores it as mesh if possible - void readGeometry(io::IXMLReaderUTF8* reader); - - //! parses a float from a char pointer and moves the pointer to - //! the end of the parsed float - inline f32 readFloat(const c8** p); - - //! parses an int from a char pointer and moves the pointer to - //! the end of the parsed float - inline s32 readInt(const c8** p); - - //! places pointer to next begin of a token - void findNextNoneWhiteSpace(const c8** p); - - //! reads floats from inside of xml element until end of xml element - void readFloatsInsideElement(io::IXMLReaderUTF8* reader, f32* floats, s32 count); - - //! clears all loaded data - void clearData(); - - //! parses all collada parameters inside an element and stores them in Parameters - void readColladaParameters(io::IXMLReaderUTF8* reader, const core::stringc& parentName); - - //! returns a collada parameter or none if not found - SColladaParam* getColladaParameter(ECOLLADA_PARAM_NAME name); - - //! parses all collada inuts inside an element and stores them in Inputs. Reads - //! until first tag which is not an input tag or the end of the parent is reached - void readColladaInputs(io::IXMLReaderUTF8* reader, const core::stringc& parentName); - - //! reads a collada input tag and adds it to the input parameter - void readColladaInput(io::IXMLReaderUTF8* reader); - - //! returns a collada input or none if not found - SColladaInput* getColladaInput(ECOLLADA_INPUT_SEMANTIC input); - - //! changes the XML URI into an internal id - void uriToId(core::stringc& str); - - //! reads a polygons section and creates a mesh from it - void readPolygonSection(io::IXMLReaderUTF8* reader, - core::stringc vertexPositionSource, core::array& sources, - scene::SMesh* mesh); - - video::IVideoDriver* Driver; - scene::ISceneManager* SceneManager; - io::IFileSystem* FileSystem; - - scene::IAnimatedMesh* DummyMesh; - core::stringc CurrentlyLoadingMesh; - - scene::IAnimatedMesh* FirstLoadedMesh; - core::stringc FirstLoadedMeshName; - s32 LoadedMeshCount; - - core::array Prefabs; - core::array Parameters; - core::array Materials; - core::array Inputs; - - bool CreateInstances; -}; - - - -//! following class is for holding and createing instances of library objects, -//! named prefabs in this loader. -class IColladaPrefab : public virtual IUnknown -{ -public: - - //! creates an instance of this prefab - virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, - scene::ISceneManager* mgr) = 0; - - //! returns id of this prefab - virtual const c8* getId() = 0; -}; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_COLLADA_MESH_FILE_LOADER_H_INCLUDED__ +#define __C_COLLADA_MESH_FILE_LOADER_H_INCLUDED__ + +#include "IMeshLoader.h" +#include "IFileSystem.h" +#include "IVideoDriver.h" +#include "irrString.h" +#include "SMesh.h" +#include "SMeshBuffer.h" +#include "ISceneManager.h" + +namespace irr +{ +namespace scene +{ + +#ifdef _DEBUG +//#define COLLADA_READER_DEBUG +#endif + +class IColladaPrefab; + +enum ECOLLADA_PARAM_NAME +{ + ECPN_COLOR = 0, + ECPN_AMBIENT, + ECPN_DIFFUSE, + ECPN_SPECULAR, + ECPN_SHININESS, + ECPN_YFOV, + ECPN_ZNEAR, + ECPN_ZFAR, + + ECPN_COUNT +}; + +enum ECOLLADA_PARAM_TYPE +{ + ECPT_FLOAT = 0, + ECPT_FLOAT2, + ECPT_FLOAT3, + ECPT_FLOAT4, + + ECPT_COUNT +}; + +//! Collada Parameter +struct SColladaParam +{ + SColladaParam() + : Name(ECPN_COUNT), Type(ECPT_COUNT) + { + for (int i=0; i<4; ++i) Floats[i] = 0; + } + + ECOLLADA_PARAM_NAME Name; + ECOLLADA_PARAM_TYPE Type; + + f32 Floats[4]; +}; + +enum ECOLLADA_INPUT_SEMANTIC +{ + ECIS_POSITION = 0, + ECIS_VERTEX, + ECIS_NORMAL, + ECIS_TEXCOORD, + ECIS_UV, + ECIS_TANGENT, + + ECIS_COUNT +}; + +//! Collada Input +struct SColladaInput +{ + SColladaInput() + : Semantic(ECIS_COUNT) + { + } + + ECOLLADA_INPUT_SEMANTIC Semantic; + core::stringc Source; +}; + +//! Collada material +struct SColladaMaterial +{ + video::SMaterial Mat; + core::stringc Id; +}; + + +struct SNumberArray // for stroring float and int arrays +{ + core::stringc Name; + core::array Data; +}; + +struct SAccessor +{ + SAccessor() + : Count(0), Offset(0), Stride(1) {} + // I don't store the source of the accessor here because I assume + // it to use the array of the source this accessor is located in. + + int Count; + int Offset; + int Stride; + + core::array Parameters; // parameters defining the accessor +}; + +struct SSource +{ + core::stringc Id; + SNumberArray Array; + core::array Accessors; +}; + + +//! Meshloader capable of loading COLLADA meshes and scene descriptions into Irrlicht. +class CColladaFileLoader : public IMeshLoader +{ +public: + + //! Constructor + CColladaFileLoader(video::IVideoDriver* driver, + scene::ISceneManager* smgr, io::IFileSystem* fs); + + //! destructor + virtual ~CColladaFileLoader(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".cob") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! creates/loads an animated mesh from the file. + //! \return Pointer to the created mesh. Returns 0 if loading failed. + //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). + //! See IUnknown::drop() for more information. + virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); + +private: + + //! skips an (unknown) section in the collada document + void skipSection(io::IXMLReaderUTF8* reader, bool reportSkipping); + + //! reads the section and its content + void readColladaSection(io::IXMLReaderUTF8* reader); + + //! reads a section and its content + void readLibrarySection(io::IXMLReaderUTF8* reader); + + //! reads a section and its content + void readSceneSection(io::IXMLReaderUTF8* reader); + + //! reads a section and its content + void readAssetSection(io::IXMLReaderUTF8* reader); + + //! reads a section and its content + void readNodeSection(io::IXMLReaderUTF8* reader, scene::ISceneNode* parent); + + //! reads a element and its content and creates a matrix from it + core::matrix4 readLookAtNode(io::IXMLReaderUTF8* reader); + + //! reads a element and its content and creates a matrix from it + core::matrix4 readMatrixNode(io::IXMLReaderUTF8* reader); + + //! reads a element and its content and creates a matrix from it + core::matrix4 readPerspectiveNode(io::IXMLReaderUTF8* reader); + + //! reads a element and its content and creates a matrix from it + core::matrix4 readRotateNode(io::IXMLReaderUTF8* reader); + + //! reads a element and its content and creates a matrix from it + core::matrix4 readSkewNode(io::IXMLReaderUTF8* reader); + + //! reads a element and its content and creates a matrix from it + core::matrix4 readScaleNode(io::IXMLReaderUTF8* reader); + + //! reads a element and its content and creates a matrix from it + core::matrix4 readTranslateNode(io::IXMLReaderUTF8* reader); + + //! reads a node and creates a scene node from it + void readInstanceNode(io::IXMLReaderUTF8* reader, scene::ISceneNode* parent, + scene::ISceneNode** outNode); + + //! reads a element and stores it as prefab + void readLightPrefab(io::IXMLReaderUTF8* reader); + + //! reads a element and stores it as prefab + void readCameraPrefab(io::IXMLReaderUTF8* reader); + + //! reads a element and stores it in the material section + void readMaterial(io::IXMLReaderUTF8* reader); + + //! reads a element and stores it as mesh if possible + void readGeometry(io::IXMLReaderUTF8* reader); + + //! parses a float from a char pointer and moves the pointer to + //! the end of the parsed float + inline f32 readFloat(const c8** p); + + //! parses an int from a char pointer and moves the pointer to + //! the end of the parsed float + inline s32 readInt(const c8** p); + + //! places pointer to next begin of a token + void findNextNoneWhiteSpace(const c8** p); + + //! reads floats from inside of xml element until end of xml element + void readFloatsInsideElement(io::IXMLReaderUTF8* reader, f32* floats, s32 count); + + //! clears all loaded data + void clearData(); + + //! parses all collada parameters inside an element and stores them in Parameters + void readColladaParameters(io::IXMLReaderUTF8* reader, const core::stringc& parentName); + + //! returns a collada parameter or none if not found + SColladaParam* getColladaParameter(ECOLLADA_PARAM_NAME name); + + //! parses all collada inuts inside an element and stores them in Inputs. Reads + //! until first tag which is not an input tag or the end of the parent is reached + void readColladaInputs(io::IXMLReaderUTF8* reader, const core::stringc& parentName); + + //! reads a collada input tag and adds it to the input parameter + void readColladaInput(io::IXMLReaderUTF8* reader); + + //! returns a collada input or none if not found + SColladaInput* getColladaInput(ECOLLADA_INPUT_SEMANTIC input); + + //! changes the XML URI into an internal id + void uriToId(core::stringc& str); + + //! reads a polygons section and creates a mesh from it + void readPolygonSection(io::IXMLReaderUTF8* reader, + core::stringc vertexPositionSource, core::array& sources, + scene::SMesh* mesh); + + video::IVideoDriver* Driver; + scene::ISceneManager* SceneManager; + io::IFileSystem* FileSystem; + + scene::IAnimatedMesh* DummyMesh; + core::stringc CurrentlyLoadingMesh; + + scene::IAnimatedMesh* FirstLoadedMesh; + core::stringc FirstLoadedMeshName; + s32 LoadedMeshCount; + + core::array Prefabs; + core::array Parameters; + core::array Materials; + core::array Inputs; + + bool CreateInstances; +}; + + + +//! following class is for holding and createing instances of library objects, +//! named prefabs in this loader. +class IColladaPrefab : public virtual IUnknown +{ +public: + + //! creates an instance of this prefab + virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, + scene::ISceneManager* mgr) = 0; + + //! returns id of this prefab + virtual const c8* getId() = 0; +}; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CColorConverter.cpp b/src/dep/src/irrlicht/CColorConverter.cpp index 516ff30..41051cb 100644 --- a/src/dep/src/irrlicht/CColorConverter.cpp +++ b/src/dep/src/irrlicht/CColorConverter.cpp @@ -1,494 +1,494 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CColorConverter.h" -#include "SColor.h" -#include "os.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -//! converts a monochrome bitmap to A1R5G5B5 data -void CColorConverter::convert1BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, s32 linepad, bool flip) -{ - if (!in || !out) - return; - - if (flip) - out += width * height; - - for (s32 y=0; y>shift & 0x01 ? (s16)0xffff : (s16)0x0000; - - if ((--shift)<0) // 8 pixel done - { - shift=7; - ++in; - } - } - - if (shift != 7) // width did not fill last byte - ++in; - - if (!flip) - out += width; - in += linepad; - } -} - - - -//! converts a 4 bit palettized image to A1R5G5B5 -void CColorConverter::convert4BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad, bool flip) -{ - if (!in || !out || !palette) - return; - - if (flip) - out += width*height; - - for (s32 y=0; y> shift) & 0xf)]); - - if (shift==0) - { - shift = 4; - ++in; - } - else - shift = 0; - } - - if (shift == 0) // odd width - ++in; - - if (!flip) - out += width; - in += linepad; - } -} - - - -//! converts a 8 bit palettized image into A1R5G5B5 -void CColorConverter::convert8BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad, bool flip) -{ - if (!in || !out || !palette) - return; - - if (flip) - out += width * height; - - for (s32 y=0; y> 15)&0x1)<<31) | (((t >> 10)&0x1F)<<19) | - (((t >> 5)&0x1F)<<11) | (t&0x1F)<<3; - out[(s32)(y*newWidth + x)] = t; - - sy+=sourceYStep; - } - } -} - - - -//! copies X8R8G8B8 32 bit data -void CColorConverter::convert32BitTo32Bit(const s32* in, s32* out, s32 width, s32 height, s32 linepad, bool flip) -{ - if (!in || !out) - return; - - if (flip) - out += width * height; - - for (s32 y=0; y> 3; - s32 g = sB[1] >> 2; - s32 b = sB[0] >> 3; - - dB[0] = (r << 11) | (g << 5) | (b); - - sB += 4; - dB += 1; - } -} - -void CColorConverter::convert_A8R8G8B8toR3G3B2(const void* sP, s32 sN, void* dP) -{ - u8* sB = (u8*)sP; - u8* dB = (u8*)dP; - - for (s32 x = 0; x < sN; ++x) - { - u8 r = sB[2] & 0xe0; - u8 g = (sB[1] & 0xe0) >> 3; - u8 b = (sB[0] & 0xc0) >> 6; - - dB[0] = (r | g | b); - - sB += 4; - dB += 1; - } -} - -void CColorConverter::convert_R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP) -{ - memcpy(dP, sP, sN * 3); -} - -void CColorConverter::convert_R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP) -{ - u8* sB = (u8* )sP; - u32* dB = (u32*)dP; - - for (s32 x = 0; x < sN; ++x) - { - *dB = 0xff000000 | (sB[0]<<16) | (sB[1]<<8) | sB[2]; - - sB += 3; - ++dB; - } -} - -void CColorConverter::convert_R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP) -{ - u8 * sB = (u8 *)sP; - u16* dB = (u16*)dP; - - for (s32 x = 0; x < sN; ++x) - { - s32 r = sB[0] >> 3; - s32 g = sB[1] >> 3; - s32 b = sB[2] >> 3; - - dB[0] = (0x8000) | (r << 10) | (g << 5) | (b); - - sB += 3; - dB += 1; - } -} - -void CColorConverter::convert_R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP) -{ - u8 * sB = (u8 *)sP; - u16* dB = (u16*)dP; - - for (s32 x = 0; x < sN; ++x) - { - s32 r = sB[0] >> 3; - s32 g = sB[1] >> 2; - s32 b = sB[2] >> 3; - - dB[0] = (r << 11) | (g << 5) | (b); - - sB += 3; - dB += 1; - } -} - -void CColorConverter::convert_R5G6B5toR5G6B5(const void* sP, s32 sN, void* dP) -{ - memcpy(dP, sP, sN * 2); -} - -void CColorConverter::convert_R5G6B5toR8G8B8(const void* sP, s32 sN, void* dP) -{ - u16* sB = (u16*)sP; - u8 * dB = (u8 *)dP; - - for (s32 x = 0; x < sN; ++x) - { - dB[0] = (*sB & 0xf800) << 8; - dB[1] = (*sB & 0x07e0) << 2; - dB[2] = (*sB & 0x001f) << 3; - - sB += 4; - dB += 3; - } -} - -void CColorConverter::convert_R5G6B5toB8G8R8(const void* sP, s32 sN, void* dP) -{ - u16* sB = (u16*)sP; - u8 * dB = (u8 *)dP; - - for (s32 x = 0; x < sN; ++x) - { - dB[2] = (*sB & 0xf800) << 8; - dB[1] = (*sB & 0x07e0) << 2; - dB[0] = (*sB & 0x001f) << 3; - - sB += 4; - dB += 3; - } -} - -void CColorConverter::convert_R5G6B5toA8R8G8B8(const void* sP, s32 sN, void* dP) -{ - u16* sB = (u16*)sP; - u32* dB = (u32*)dP; - - for (s32 x = 0; x < sN; ++x) - *dB++ = R5G6B5toA8R8G8B8(*sB++); -} - -void CColorConverter::convert_R5G6B5toA1R5G5B5(const void* sP, s32 sN, void* dP) -{ - u16* sB = (u16*)sP; - u16* dB = (u16*)dP; - - for (s32 x = 0; x < sN; ++x) - *dB++ = R5G6B5toA1R5G5B5(*sB++); -} - - -} // end namespace video -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CColorConverter.h" +#include "SColor.h" +#include "os.h" +#include "irrString.h" + +namespace irr +{ +namespace video +{ + +//! converts a monochrome bitmap to A1R5G5B5 data +void CColorConverter::convert1BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, s32 linepad, bool flip) +{ + if (!in || !out) + return; + + if (flip) + out += width * height; + + for (s32 y=0; y>shift & 0x01 ? (s16)0xffff : (s16)0x0000; + + if ((--shift)<0) // 8 pixel done + { + shift=7; + ++in; + } + } + + if (shift != 7) // width did not fill last byte + ++in; + + if (!flip) + out += width; + in += linepad; + } +} + + + +//! converts a 4 bit palettized image to A1R5G5B5 +void CColorConverter::convert4BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad, bool flip) +{ + if (!in || !out || !palette) + return; + + if (flip) + out += width*height; + + for (s32 y=0; y> shift) & 0xf)]); + + if (shift==0) + { + shift = 4; + ++in; + } + else + shift = 0; + } + + if (shift == 0) // odd width + ++in; + + if (!flip) + out += width; + in += linepad; + } +} + + + +//! converts a 8 bit palettized image into A1R5G5B5 +void CColorConverter::convert8BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad, bool flip) +{ + if (!in || !out || !palette) + return; + + if (flip) + out += width * height; + + for (s32 y=0; y> 15)&0x1)<<31) | (((t >> 10)&0x1F)<<19) | + (((t >> 5)&0x1F)<<11) | (t&0x1F)<<3; + out[(s32)(y*newWidth + x)] = t; + + sy+=sourceYStep; + } + } +} + + + +//! copies X8R8G8B8 32 bit data +void CColorConverter::convert32BitTo32Bit(const s32* in, s32* out, s32 width, s32 height, s32 linepad, bool flip) +{ + if (!in || !out) + return; + + if (flip) + out += width * height; + + for (s32 y=0; y> 3; + s32 g = sB[1] >> 2; + s32 b = sB[0] >> 3; + + dB[0] = (r << 11) | (g << 5) | (b); + + sB += 4; + dB += 1; + } +} + +void CColorConverter::convert_A8R8G8B8toR3G3B2(const void* sP, s32 sN, void* dP) +{ + u8* sB = (u8*)sP; + u8* dB = (u8*)dP; + + for (s32 x = 0; x < sN; ++x) + { + u8 r = sB[2] & 0xe0; + u8 g = (sB[1] & 0xe0) >> 3; + u8 b = (sB[0] & 0xc0) >> 6; + + dB[0] = (r | g | b); + + sB += 4; + dB += 1; + } +} + +void CColorConverter::convert_R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP) +{ + memcpy(dP, sP, sN * 3); +} + +void CColorConverter::convert_R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP) +{ + u8* sB = (u8* )sP; + u32* dB = (u32*)dP; + + for (s32 x = 0; x < sN; ++x) + { + *dB = 0xff000000 | (sB[0]<<16) | (sB[1]<<8) | sB[2]; + + sB += 3; + ++dB; + } +} + +void CColorConverter::convert_R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP) +{ + u8 * sB = (u8 *)sP; + u16* dB = (u16*)dP; + + for (s32 x = 0; x < sN; ++x) + { + s32 r = sB[0] >> 3; + s32 g = sB[1] >> 3; + s32 b = sB[2] >> 3; + + dB[0] = (0x8000) | (r << 10) | (g << 5) | (b); + + sB += 3; + dB += 1; + } +} + +void CColorConverter::convert_R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP) +{ + u8 * sB = (u8 *)sP; + u16* dB = (u16*)dP; + + for (s32 x = 0; x < sN; ++x) + { + s32 r = sB[0] >> 3; + s32 g = sB[1] >> 2; + s32 b = sB[2] >> 3; + + dB[0] = (r << 11) | (g << 5) | (b); + + sB += 3; + dB += 1; + } +} + +void CColorConverter::convert_R5G6B5toR5G6B5(const void* sP, s32 sN, void* dP) +{ + memcpy(dP, sP, sN * 2); +} + +void CColorConverter::convert_R5G6B5toR8G8B8(const void* sP, s32 sN, void* dP) +{ + u16* sB = (u16*)sP; + u8 * dB = (u8 *)dP; + + for (s32 x = 0; x < sN; ++x) + { + dB[0] = (*sB & 0xf800) << 8; + dB[1] = (*sB & 0x07e0) << 2; + dB[2] = (*sB & 0x001f) << 3; + + sB += 4; + dB += 3; + } +} + +void CColorConverter::convert_R5G6B5toB8G8R8(const void* sP, s32 sN, void* dP) +{ + u16* sB = (u16*)sP; + u8 * dB = (u8 *)dP; + + for (s32 x = 0; x < sN; ++x) + { + dB[2] = (*sB & 0xf800) << 8; + dB[1] = (*sB & 0x07e0) << 2; + dB[0] = (*sB & 0x001f) << 3; + + sB += 4; + dB += 3; + } +} + +void CColorConverter::convert_R5G6B5toA8R8G8B8(const void* sP, s32 sN, void* dP) +{ + u16* sB = (u16*)sP; + u32* dB = (u32*)dP; + + for (s32 x = 0; x < sN; ++x) + *dB++ = R5G6B5toA8R8G8B8(*sB++); +} + +void CColorConverter::convert_R5G6B5toA1R5G5B5(const void* sP, s32 sN, void* dP) +{ + u16* sB = (u16*)sP; + u16* dB = (u16*)dP; + + for (s32 x = 0; x < sN; ++x) + *dB++ = R5G6B5toA1R5G5B5(*sB++); +} + + +} // end namespace video +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CColorConverter.h b/src/dep/src/irrlicht/CColorConverter.h index 801f55f..831dcb2 100644 --- a/src/dep/src/irrlicht/CColorConverter.h +++ b/src/dep/src/irrlicht/CColorConverter.h @@ -1,81 +1,81 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_COLOR_CONVERTER_H_INCLUDED__ -#define __C_COLOR_CONVERTER_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr -{ -namespace video -{ - -class CColorConverter -{ -public: - - //! converts a monochrome bitmap to A1R5G5B5 - static void convert1BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, s32 linepad=0, bool flip=false); - - //! converts a 4 bit palettized image to A1R5G5B5 - static void convert4BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad=0, bool flip=false); - - //! converts a 8 bit palettized image to A1R5G5B5 - static void convert8BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad=0, bool flip=false); - - //! converts R8G8B8 16 bit data to A1R5G5B5 data - static void convert16BitTo16Bit(const s16* in, s16* out, s32 width, s32 height, s32 linepad=0, bool flip=false); - - //! copies R8G8B8 24 bit data to 24 data, and flips and - //! mirrors the image during the process. - static void convert24BitTo24Bit(const u8* in, u8* out, s32 width, s32 height, s32 linepad=0, bool flip=false, bool bgr=false); - - //! Resizes the surface to a new size and converts it at the same time - //! to an A8R8G8B8 format, returning the pointer to the new buffer. - static void convert16bitToA8R8G8B8andResize(const s16* in, s32* out, s32 newWidth, s32 newHeight, s32 currentWidth, s32 currentHeight); - - //! copies X8R8G8B8 32 bit data, and flips and - //! mirrors the image during the process. - static void convert32BitTo32Bit(const s32* in, s32* out, s32 width, s32 height, s32 linepad, bool flip=false); - - - //! functions for converting one image format to another efficiently - //! and hopefully correctly. - //! - //! \param sP pointer to source pixel data - //! \param sN number of source pixels to copy - //! \param dP pointer to destination data buffer. must be big enough - //! to hold sN pixels in the output format. - static void convert_A1R5G5B5toR8G8B8(const void* sP, s32 sN, void* dP); - static void convert_A1R5G5B5toB8G8R8(const void* sP, s32 sN, void* dP); - static void convert_A1R5G5B5toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_A1R5G5B5toA1R5G5B5(const void* sP, s32 sN, void* dP); - static void convert_A1R5G5B5toR5G6B5(const void* sP, s32 sN, void* dP); - - static void convert_A8R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP); - - static void convert_A8R8G8B8toR3G3B2(const void* sP, s32 sN, void* dP); - static void convert_R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP); - static void convert_R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP); - static void convert_R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP); - - static void convert_R5G6B5toR5G6B5(const void* sP, s32 sN, void* dP); - static void convert_R5G6B5toR8G8B8(const void* sP, s32 sN, void* dP); - static void convert_R5G6B5toB8G8R8(const void* sP, s32 sN, void* dP); - static void convert_R5G6B5toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_R5G6B5toA1R5G5B5(const void* sP, s32 sN, void* dP); -}; - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_COLOR_CONVERTER_H_INCLUDED__ +#define __C_COLOR_CONVERTER_H_INCLUDED__ + +#include "irrTypes.h" + +namespace irr +{ +namespace video +{ + +class CColorConverter +{ +public: + + //! converts a monochrome bitmap to A1R5G5B5 + static void convert1BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, s32 linepad=0, bool flip=false); + + //! converts a 4 bit palettized image to A1R5G5B5 + static void convert4BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad=0, bool flip=false); + + //! converts a 8 bit palettized image to A1R5G5B5 + static void convert8BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad=0, bool flip=false); + + //! converts R8G8B8 16 bit data to A1R5G5B5 data + static void convert16BitTo16Bit(const s16* in, s16* out, s32 width, s32 height, s32 linepad=0, bool flip=false); + + //! copies R8G8B8 24 bit data to 24 data, and flips and + //! mirrors the image during the process. + static void convert24BitTo24Bit(const u8* in, u8* out, s32 width, s32 height, s32 linepad=0, bool flip=false, bool bgr=false); + + //! Resizes the surface to a new size and converts it at the same time + //! to an A8R8G8B8 format, returning the pointer to the new buffer. + static void convert16bitToA8R8G8B8andResize(const s16* in, s32* out, s32 newWidth, s32 newHeight, s32 currentWidth, s32 currentHeight); + + //! copies X8R8G8B8 32 bit data, and flips and + //! mirrors the image during the process. + static void convert32BitTo32Bit(const s32* in, s32* out, s32 width, s32 height, s32 linepad, bool flip=false); + + + //! functions for converting one image format to another efficiently + //! and hopefully correctly. + //! + //! \param sP pointer to source pixel data + //! \param sN number of source pixels to copy + //! \param dP pointer to destination data buffer. must be big enough + //! to hold sN pixels in the output format. + static void convert_A1R5G5B5toR8G8B8(const void* sP, s32 sN, void* dP); + static void convert_A1R5G5B5toB8G8R8(const void* sP, s32 sN, void* dP); + static void convert_A1R5G5B5toA8R8G8B8(const void* sP, s32 sN, void* dP); + static void convert_A1R5G5B5toA1R5G5B5(const void* sP, s32 sN, void* dP); + static void convert_A1R5G5B5toR5G6B5(const void* sP, s32 sN, void* dP); + + static void convert_A8R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP); + static void convert_A8R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP); + static void convert_A8R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP); + static void convert_A8R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP); + static void convert_A8R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP); + + static void convert_A8R8G8B8toR3G3B2(const void* sP, s32 sN, void* dP); + static void convert_R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP); + static void convert_R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP); + static void convert_R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP); + static void convert_R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP); + + static void convert_R5G6B5toR5G6B5(const void* sP, s32 sN, void* dP); + static void convert_R5G6B5toR8G8B8(const void* sP, s32 sN, void* dP); + static void convert_R5G6B5toB8G8R8(const void* sP, s32 sN, void* dP); + static void convert_R5G6B5toA8R8G8B8(const void* sP, s32 sN, void* dP); + static void convert_R5G6B5toA1R5G5B5(const void* sP, s32 sN, void* dP); +}; + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CCubeSceneNode.cpp b/src/dep/src/irrlicht/CCubeSceneNode.cpp index f1a194f..63d518c 100644 --- a/src/dep/src/irrlicht/CCubeSceneNode.cpp +++ b/src/dep/src/irrlicht/CCubeSceneNode.cpp @@ -1,163 +1,163 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CCubeSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "S3DVertex.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CCubeSceneNode::CCubeSceneNode(f32 size, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) -: ISceneNode(parent, mgr, id, position, rotation, scale), Size(size) -{ - #ifdef _DEBUG - setDebugName("CCubeSceneNode"); - #endif - - u16 u[36] = { 0,2,1, 0,3,2, 1,5,4, 1,2,5, 4,6,7, 4,5,6, - 7,3,0, 7,6,3, 9,5,2, 9,8,5, 0,11,10, 0,10,7}; - - Buffer.Indices.set_used(36); - for (s32 i=0; i<36; ++i) - Buffer.Indices[i] = u[i]; - - setSize(); -} - - - -//! destructor -CCubeSceneNode::~CCubeSceneNode() -{ -} - - -void CCubeSceneNode::setSize() -{ - // we are creating the cube mesh here. - - // nicer texture mapping sent in by Dr Andros C Bragianos - // .. and then improved by jox. - - video::SColor clr(255,255,255,255); - - Buffer.Vertices.set_used(12); - Buffer.Vertices[0] = video::S3DVertex(0,0,0, -1,-1,-1, clr, 0, 1); - Buffer.Vertices[1] = video::S3DVertex(1,0,0, 1,-1,-1, clr, 1, 1); - Buffer.Vertices[2] = video::S3DVertex(1,1,0, 1, 1,-1, clr, 1, 0); - Buffer.Vertices[3] = video::S3DVertex(0,1,0, -1, 1,-1, clr, 0, 0); - Buffer.Vertices[4] = video::S3DVertex(1,0,1, 1,-1, 1, clr, 0, 1); - Buffer.Vertices[5] = video::S3DVertex(1,1,1, 1, 1, 1, clr, 0, 0); - Buffer.Vertices[6] = video::S3DVertex(0,1,1, -1, 1, 1, clr, 1, 0); - Buffer.Vertices[7] = video::S3DVertex(0,0,1, -1,-1, 1, clr, 1, 1); - Buffer.Vertices[8] = video::S3DVertex(0,1,1, -1, 1, 1, clr, 0, 1); - Buffer.Vertices[9] = video::S3DVertex(0,1,0, -1, 1,-1, clr, 1, 1); - Buffer.Vertices[10] = video::S3DVertex(1,0,1, 1,-1, 1, clr, 1, 0); - Buffer.Vertices[11] = video::S3DVertex(1,0,0, 1,-1,-1, clr, 0, 0); - - Buffer.BoundingBox.reset(0,0,0); - - for (int i=0; i<12; ++i) - { - Buffer.Vertices[i].Pos -= core::vector3df(0.5f, 0.5f, 0.5f); - Buffer.Vertices[i].Pos *= Size; - Buffer.BoundingBox.addInternalPoint(Buffer.Vertices[i].Pos); - } -} - - - -//! renders the node. -void CCubeSceneNode::render() -{ - /* - 011 111 - /6--------/5 y - / | / | ^ z - / | / | | / - 010 3---------2 | |/ - | 7- - -| -4 101 *---->x - | / | / - |/ | / - 0---------1/ - 000 100 - */ - - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - driver->setMaterial(Buffer.Material); - - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - - driver->drawMeshBuffer(&Buffer); -} - - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CCubeSceneNode::getBoundingBox() const -{ - return Buffer.BoundingBox; -} - - -void CCubeSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - SceneManager->registerNodeForRendering(this); - ISceneNode::OnRegisterSceneNode(); - } -} - - -//! returns the material based on the zero based index i. To get the amount -//! of materials used by this scene node, use getMaterialCount(). -//! This function is needed for inserting the node into the scene hirachy on a -//! optimal position for minimizing renderstate changes, but can also be used -//! to directly modify the material of a scene node. -video::SMaterial& CCubeSceneNode::getMaterial(u32 i) -{ - return Buffer.Material; -} - - -//! returns amount of materials used by this scene node. -u32 CCubeSceneNode::getMaterialCount() -{ - return 1; -} - - -//! Writes attributes of the scene node. -void CCubeSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - ISceneNode::serializeAttributes(out, options); - - out->addFloat("Size", Size); -} - - -//! Reads attributes of the scene node. -void CCubeSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Size = in->getAttributeAsFloat("Size"); - Size = irr::core::max_(Size, 0.0001f); - setSize(); - - ISceneNode::deserializeAttributes(in, options); -} - - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CCubeSceneNode.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" +#include "S3DVertex.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CCubeSceneNode::CCubeSceneNode(f32 size, ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) +: ISceneNode(parent, mgr, id, position, rotation, scale), Size(size) +{ + #ifdef _DEBUG + setDebugName("CCubeSceneNode"); + #endif + + u16 u[36] = { 0,2,1, 0,3,2, 1,5,4, 1,2,5, 4,6,7, 4,5,6, + 7,3,0, 7,6,3, 9,5,2, 9,8,5, 0,11,10, 0,10,7}; + + Buffer.Indices.set_used(36); + for (s32 i=0; i<36; ++i) + Buffer.Indices[i] = u[i]; + + setSize(); +} + + + +//! destructor +CCubeSceneNode::~CCubeSceneNode() +{ +} + + +void CCubeSceneNode::setSize() +{ + // we are creating the cube mesh here. + + // nicer texture mapping sent in by Dr Andros C Bragianos + // .. and then improved by jox. + + video::SColor clr(255,255,255,255); + + Buffer.Vertices.set_used(12); + Buffer.Vertices[0] = video::S3DVertex(0,0,0, -1,-1,-1, clr, 0, 1); + Buffer.Vertices[1] = video::S3DVertex(1,0,0, 1,-1,-1, clr, 1, 1); + Buffer.Vertices[2] = video::S3DVertex(1,1,0, 1, 1,-1, clr, 1, 0); + Buffer.Vertices[3] = video::S3DVertex(0,1,0, -1, 1,-1, clr, 0, 0); + Buffer.Vertices[4] = video::S3DVertex(1,0,1, 1,-1, 1, clr, 0, 1); + Buffer.Vertices[5] = video::S3DVertex(1,1,1, 1, 1, 1, clr, 0, 0); + Buffer.Vertices[6] = video::S3DVertex(0,1,1, -1, 1, 1, clr, 1, 0); + Buffer.Vertices[7] = video::S3DVertex(0,0,1, -1,-1, 1, clr, 1, 1); + Buffer.Vertices[8] = video::S3DVertex(0,1,1, -1, 1, 1, clr, 0, 1); + Buffer.Vertices[9] = video::S3DVertex(0,1,0, -1, 1,-1, clr, 1, 1); + Buffer.Vertices[10] = video::S3DVertex(1,0,1, 1,-1, 1, clr, 1, 0); + Buffer.Vertices[11] = video::S3DVertex(1,0,0, 1,-1,-1, clr, 0, 0); + + Buffer.BoundingBox.reset(0,0,0); + + for (int i=0; i<12; ++i) + { + Buffer.Vertices[i].Pos -= core::vector3df(0.5f, 0.5f, 0.5f); + Buffer.Vertices[i].Pos *= Size; + Buffer.BoundingBox.addInternalPoint(Buffer.Vertices[i].Pos); + } +} + + + +//! renders the node. +void CCubeSceneNode::render() +{ + /* + 011 111 + /6--------/5 y + / | / | ^ z + / | / | | / + 010 3---------2 | |/ + | 7- - -| -4 101 *---->x + | / | / + |/ | / + 0---------1/ + 000 100 + */ + + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + + driver->setMaterial(Buffer.Material); + + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + + driver->drawMeshBuffer(&Buffer); +} + + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CCubeSceneNode::getBoundingBox() const +{ + return Buffer.BoundingBox; +} + + +void CCubeSceneNode::OnRegisterSceneNode() +{ + if (IsVisible) + { + SceneManager->registerNodeForRendering(this); + ISceneNode::OnRegisterSceneNode(); + } +} + + +//! returns the material based on the zero based index i. To get the amount +//! of materials used by this scene node, use getMaterialCount(). +//! This function is needed for inserting the node into the scene hirachy on a +//! optimal position for minimizing renderstate changes, but can also be used +//! to directly modify the material of a scene node. +video::SMaterial& CCubeSceneNode::getMaterial(u32 i) +{ + return Buffer.Material; +} + + +//! returns amount of materials used by this scene node. +u32 CCubeSceneNode::getMaterialCount() +{ + return 1; +} + + +//! Writes attributes of the scene node. +void CCubeSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + ISceneNode::serializeAttributes(out, options); + + out->addFloat("Size", Size); +} + + +//! Reads attributes of the scene node. +void CCubeSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + Size = in->getAttributeAsFloat("Size"); + Size = irr::core::max_(Size, 0.0001f); + setSize(); + + ISceneNode::deserializeAttributes(in, options); +} + + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CCubeSceneNode.h b/src/dep/src/irrlicht/CCubeSceneNode.h index 82185b5..546eef0 100644 --- a/src/dep/src/irrlicht/CCubeSceneNode.h +++ b/src/dep/src/irrlicht/CCubeSceneNode.h @@ -1,67 +1,67 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_TEST_SCENE_NODE_H_INCLUDED__ -#define __C_TEST_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "SMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - class CCubeSceneNode : public ISceneNode - { - public: - - //! constructor - CCubeSceneNode(f32 size, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! destructor - virtual ~CCubeSceneNode(); - - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! returns the material based on the zero based index i. To get the amount - //! of materials used by this scene node, use getMaterialCount(). - //! This function is needed for inserting the node into the scene hirachy on a - //! optimal position for minimizing renderstate changes, but can also be used - //! to directly modify the material of a scene node. - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount(); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_CUBE; } - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - private: - - void setSize(); - - SMeshBuffer Buffer; - f32 Size; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_TEST_SCENE_NODE_H_INCLUDED__ +#define __C_TEST_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" +#include "SMeshBuffer.h" + +namespace irr +{ +namespace scene +{ + class CCubeSceneNode : public ISceneNode + { + public: + + //! constructor + CCubeSceneNode(f32 size, ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); + + //! destructor + virtual ~CCubeSceneNode(); + + virtual void OnRegisterSceneNode(); + + //! renders the node. + virtual void render(); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! returns the material based on the zero based index i. To get the amount + //! of materials used by this scene node, use getMaterialCount(). + //! This function is needed for inserting the node into the scene hirachy on a + //! optimal position for minimizing renderstate changes, but can also be used + //! to directly modify the material of a scene node. + virtual video::SMaterial& getMaterial(u32 i); + + //! returns amount of materials used by this scene node. + virtual u32 getMaterialCount(); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_CUBE; } + + //! Writes attributes of the scene node. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + private: + + void setSize(); + + SMeshBuffer Buffer; + f32 Size; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CD3D8Driver.cpp b/src/dep/src/irrlicht/CD3D8Driver.cpp index 0620f47..88ba4a0 100644 --- a/src/dep/src/irrlicht/CD3D8Driver.cpp +++ b/src/dep/src/irrlicht/CD3D8Driver.cpp @@ -1,2113 +1,2113 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#define _IRR_DONT_DO_MEMORY_DEBUGGING_HERE -#include "CD3D8Driver.h" -#include "os.h" -#include "S3DVertex.h" -#include "CD3D8Texture.h" -#include "CImage.h" - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - -#include "CD3D8MaterialRenderer.h" -#include "CD3D8ShaderMaterialRenderer.h" -#include "CD3D8NormalMapRenderer.h" -#include "CD3D8ParallaxMapRenderer.h" - -namespace irr -{ -namespace video -{ - - -//! constructor -CD3D8Driver::CD3D8Driver(const core::dimension2d& screenSize, HWND window, - bool fullscreen, bool stencilbuffer, - io::IFileSystem* io, bool pureSoftware, bool vsync) -: CNullDriver(io, screenSize), CurrentRenderMode(ERM_NONE), - ResetRenderStates(true), Transformation3DChanged(false), StencilBuffer(stencilbuffer), - D3DLibrary(0), pID3D(0), pID3DDevice(0), PrevRenderTarget(0), - LastVertexType((video::E_VERTEX_TYPE)-1), MaxTextureUnits(0), - MaxLightDistance(sqrtf(FLT_MAX)), LastSetLight(-1), DeviceLost(false) -{ - #ifdef _DEBUG - setDebugName("CD3D8Driver"); - #endif - - printVersion(); - - for (u32 i=0; idrop(); - - // drop d3d8 - - if (pID3DDevice) - pID3DDevice->Release(); - - if (pID3D) - pID3D->Release(); -} - - -void CD3D8Driver::createMaterialRenderers() -{ - // create D3D8 material renderers - - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_SOLID(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_SOLID_2_LAYER(pID3DDevice, this)); - - // add the same renderer for all lightmap types - CD3D8MaterialRenderer_LIGHTMAP* lmr = new CD3D8MaterialRenderer_LIGHTMAP(pID3DDevice, this); - addMaterialRenderer(lmr); // for EMT_LIGHTMAP: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_ADD: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M2: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M4: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M2: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M4: - lmr->drop(); - - // add remaining material renderers - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_DETAIL_MAP(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_SPHERE_MAP(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_REFLECTION_2_LAYER(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_ADD_COLOR(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(pID3DDevice, this)); - - // add normal map renderers - s32 tmp = 0; - video::IMaterialRenderer* renderer = 0; - - renderer = new CD3D8NormalMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_SOLID].Renderer); - renderer->drop(); - - renderer = new CD3D8NormalMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); - renderer->drop(); - - renderer = new CD3D8NormalMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); - renderer->drop(); - - // add parallax map renderers - - renderer = new CD3D8ParallaxMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_SOLID].Renderer); - renderer->drop(); - - renderer = new CD3D8ParallaxMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); - renderer->drop(); - - renderer = new CD3D8ParallaxMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); - renderer->drop(); - - // add basic 1 texture blending - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_ONETEXTURE_BLEND(pID3DDevice, this)); - -} - - -//! initialises the Direct3D API -bool CD3D8Driver::initDriver(const core::dimension2d& screenSize, HWND hwnd, - u32 bits, bool fullScreen, bool pureSoftware, - bool highPrecisionFPU, bool vsync, bool antiAlias) -{ - HRESULT hr; - D3DLibrary = LoadLibrary( "d3d8.dll" ); - - if (!D3DLibrary) - { - os::Printer::log("Error, could not load d3d8.dll.", ELL_ERROR); - return false; - } - - typedef IDirect3D8 * (__stdcall *D3DCREATETYPE)(UINT); - D3DCREATETYPE d3dCreate = (D3DCREATETYPE) GetProcAddress(D3DLibrary, "Direct3DCreate8"); - - if (!d3dCreate) - { - os::Printer::log("Error, could not get proc adress of Direct3DCreate8.", ELL_ERROR); - return false; - } - - //just like pID3D = Direct3DCreate8(D3D_SDK_VERSION); - pID3D = (*d3dCreate)(D3D_SDK_VERSION); - - if (!pID3D) - { - os::Printer::log("Error initializing D3D.", ELL_ERROR); - return false; - } - - // print device information - D3DADAPTER_IDENTIFIER8 dai; - if (!FAILED(pID3D->GetAdapterIdentifier(D3DADAPTER_DEFAULT, D3DENUM_NO_WHQL_LEVEL, &dai))) - { - char tmp[512]; - - s32 Product = HIWORD(dai.DriverVersion.HighPart); - s32 Version = LOWORD(dai.DriverVersion.HighPart); - s32 SubVersion = HIWORD(dai.DriverVersion.LowPart); - s32 Build = LOWORD(dai.DriverVersion.LowPart); - - sprintf(tmp, "%s %s %d.%d.%d.%d", dai.Description, dai.Driver, Product, Version, - SubVersion, Build); - os::Printer::log(tmp, ELL_INFORMATION); - } - - - - D3DDISPLAYMODE d3ddm; - hr = pID3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm); - if (FAILED(hr)) - { - os::Printer::log("Error: Could not get Adapter Display mode.", ELL_ERROR); - return false; - } - - - ZeroMemory(&present, sizeof(present)); - - present.SwapEffect = D3DSWAPEFFECT_COPY; - present.Windowed = TRUE; - present.BackBufferFormat = d3ddm.Format; - present.EnableAutoDepthStencil = TRUE; - - if (fullScreen) - { - present.SwapEffect = D3DSWAPEFFECT_FLIP; - present.Windowed = FALSE; - present.BackBufferWidth = screenSize.Width; - present.BackBufferHeight = screenSize.Height; - present.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; - present.FullScreen_PresentationInterval = vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; - - if (bits == 32) - present.BackBufferFormat = D3DFMT_X8R8G8B8; - else - present.BackBufferFormat = D3DFMT_R5G6B5; - } - - D3DDEVTYPE devtype = D3DDEVTYPE_HAL; - #ifndef _IRR_D3D_NO_SHADER_DEBUGGING - devtype = D3DDEVTYPE_REF; - #endif - - // enable anti alias if possible and whished - if (antiAlias) - { - DWORD qualityLevels = 0; - - if (!FAILED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, - devtype , present.BackBufferFormat, !fullScreen, - D3DMULTISAMPLE_2_SAMPLES))) - { - // enable multi sampling - present.SwapEffect = D3DSWAPEFFECT_DISCARD; - present.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES; - } - else - { - os::Printer::log("Anti aliasing disabled because hardware/driver lacks necessary caps.", ELL_WARNING); - antiAlias = false; - } - } - - // check stencil buffer compatibility - if (StencilBuffer) - { - present.AutoDepthStencilFormat = D3DFMT_D24S8; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D24X4S4; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D15S1; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - os::Printer::log("Device does not support stencilbuffer, disabling stencil buffer.", ELL_WARNING); - StencilBuffer = false; - } - } - } - else - if(FAILED(pID3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, present.BackBufferFormat, present.AutoDepthStencilFormat))) - { - os::Printer::log("Depth-stencil format is not compatible with display format, disabling stencil buffer.", ELL_WARNING); - StencilBuffer = false; - } - } - // do not use else here to cope with flag change in previous block - if (!StencilBuffer) - { - present.AutoDepthStencilFormat = D3DFMT_D32; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D24X8; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D16; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - os::Printer::log("Device does not support required depth buffer.", ELL_WARNING); - return false; - } - } - } - } - - // create device - - DWORD fpuPrecision = highPrecisionFPU ? D3DCREATE_FPU_PRESERVE : 0; - if (pureSoftware) - { - hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, hwnd, - fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); - - if (FAILED(hr)) - os::Printer::log("Was not able to create Direct3D8 software device.", ELL_ERROR); - } - else - { - hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, - fpuPrecision | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice); - - if(FAILED(hr)) - hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, - fpuPrecision | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice); - if(FAILED(hr)) - hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, - fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); - if (FAILED(hr)) - os::Printer::log("Was not able to create Direct3D8 device.", ELL_ERROR); - } - - if (!pID3DDevice) - { - os::Printer::log("Was not able to create Direct3D8 device.", ELL_ERROR); - return false; - } - - // get caps - pID3DDevice->GetDeviceCaps(&Caps); - - if (StencilBuffer && - (!(Caps.StencilCaps & D3DSTENCILCAPS_DECRSAT) || - !(Caps.StencilCaps & D3DSTENCILCAPS_INCRSAT) || - !(Caps.StencilCaps & D3DSTENCILCAPS_KEEP))) - { - os::Printer::log("Device not able to use stencil buffer, disabling stencil buffer.", ELL_WARNING); - StencilBuffer = false; - } - - // set default vertex shader - setVertexShader(EVT_STANDARD); - - // enable antialiasing - if (antiAlias) - pID3DDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE); - - // set fog mode - setFog(FogColor, LinearFog, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); - - // set exposed data - ExposedData.D3D8.D3D8 = pID3D; - ExposedData.D3D8.D3DDev8 = pID3DDevice; - ExposedData.D3D8.HWnd = reinterpret_cast(hwnd); - - ResetRenderStates = true; - - // create materials - createMaterialRenderers(); - - MaxTextureUnits = core::min_((u32)Caps.MaxSimultaneousTextures, MATERIAL_MAX_TEXTURES); - - // set the renderstates - setRenderStates3DMode(); - - // set max anisotropy - pID3DDevice->SetTextureStageState(0, D3DTSS_MAXANISOTROPY, core::min_( (DWORD) 16, Caps.MaxAnisotropy)); - pID3DDevice->SetTextureStageState(1, D3DTSS_MAXANISOTROPY, core::min_( (DWORD) 16, Caps.MaxAnisotropy)); - pID3DDevice->SetTextureStageState(2, D3DTSS_MAXANISOTROPY, core::min_( (DWORD) 16, Caps.MaxAnisotropy)); - pID3DDevice->SetTextureStageState(3, D3DTSS_MAXANISOTROPY, core::min_( (DWORD) 16, Caps.MaxAnisotropy)); - - // so far so good. - return true; -} - - - - -//! applications must call this method before performing any rendering. returns false if failed. -bool CD3D8Driver::beginScene(bool backBuffer, bool zBuffer, SColor color) -{ - CNullDriver::beginScene(backBuffer, zBuffer, color); - HRESULT hr; - - if (!pID3DDevice) - return false; - - if (DeviceLost) - { - if(FAILED(hr = pID3DDevice->TestCooperativeLevel())) - { - if (hr == D3DERR_DEVICELOST) - return false; - - if (hr == D3DERR_DEVICENOTRESET) - reset(); - return false; - } - } - - DWORD flags = 0; - - if (backBuffer) - flags |= D3DCLEAR_TARGET; - - if (zBuffer) - flags |= D3DCLEAR_ZBUFFER; - - if (StencilBuffer) - flags |= D3DCLEAR_STENCIL; - - hr = pID3DDevice->Clear( 0, NULL, flags, color.color, 1.0, 0); - if (FAILED(hr)) - os::Printer::log("Direct3D8 clear failed.", ELL_WARNING); - - hr = pID3DDevice->BeginScene(); - if (FAILED(hr)) - { - os::Printer::log("Direct3D8 begin scene failed.", ELL_WARNING); - return false; - } - - return true; -} - - - -//! resets the device -bool CD3D8Driver::reset() -{ - // reset - HRESULT hr; - os::Printer::log("Resetting D3D8 device.", ELL_INFORMATION); - if (FAILED(hr = pID3DDevice->Reset(&present))) - { - if (hr == D3DERR_DEVICELOST) - { - DeviceLost = true; - os::Printer::log("Resetting failed due to device lost.", ELL_WARNING); - } - else - os::Printer::log("Resetting failed.", ELL_WARNING); - return false; - } - - DeviceLost = false; - ResetRenderStates = true; - LastVertexType = (E_VERTEX_TYPE)-1; - - for (u32 i=0; idrop(); - CurrentTexture[i] = 0; - } - - setVertexShader(EVT_STANDARD); - setRenderStates3DMode(); - setFog(FogColor, LinearFog, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); - setAmbientLight(AmbientLight); - - return true; -} - - - -//! applications must call this method after performing any rendering. returns false if failed. -bool CD3D8Driver::endScene( s32 windowId, core::rect* sourceRect ) -{ - CNullDriver::endScene(); - - HRESULT hr = pID3DDevice->EndScene(); - if (FAILED(hr)) - { - os::Printer::log("DIRECT3D8 end scene failed.", ELL_WARNING); - return false; - } - - RECT* srcRct = 0; - RECT sourceRectData; - if ( sourceRect) - { - srcRct = &sourceRectData; - sourceRectData.left = sourceRect->UpperLeftCorner.X; - sourceRectData.top = sourceRect->UpperLeftCorner.Y; - sourceRectData.right = sourceRect->LowerRightCorner.X; - sourceRectData.bottom = sourceRect->LowerRightCorner.Y; - } - - hr = pID3DDevice->Present(srcRct, NULL, (HWND)windowId, NULL); - - if (hr == D3DERR_DEVICELOST) - { - DeviceLost = true; - os::Printer::log("DIRECT3D8 device lost.", ELL_WARNING); - } - else - if (FAILED(hr) && hr != D3DERR_INVALIDCALL) - { - os::Printer::log("DIRECT3D8 present failed.", ELL_WARNING); - return false; - } - - return true; -} - - - -//! queries the features of the driver, returns true if feature is available -bool CD3D8Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) -{ - switch (feature) - { - case EVDF_RENDER_TO_TARGET: - case EVDF_MULTITEXTURE: - case EVDF_BILINEAR_FILTER: - return true; - case EVDF_HARDWARE_TL: - return (Caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) != 0; - case EVDF_MIP_MAP: - return (Caps.TextureCaps & D3DPTEXTURECAPS_MIPMAP) != 0; - case EVDF_STENCIL_BUFFER: - return StencilBuffer && Caps.StencilCaps; - case EVDF_VERTEX_SHADER_1_1: - return Caps.VertexShaderVersion >= D3DVS_VERSION(1,1); - case EVDF_VERTEX_SHADER_2_0: - return Caps.VertexShaderVersion >= D3DVS_VERSION(2,0); - case EVDF_VERTEX_SHADER_3_0: - return Caps.VertexShaderVersion >= D3DVS_VERSION(3,0); - case EVDF_PIXEL_SHADER_1_1: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,1); - case EVDF_PIXEL_SHADER_1_2: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,2); - case EVDF_PIXEL_SHADER_1_3: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,3); - case EVDF_PIXEL_SHADER_1_4: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,4); - case EVDF_PIXEL_SHADER_2_0: - return Caps.PixelShaderVersion >= D3DPS_VERSION(2,0); - case EVDF_PIXEL_SHADER_3_0: - return Caps.PixelShaderVersion >= D3DPS_VERSION(3,0); - case EVDF_TEXTURE_NPOT: - return (Caps.TextureCaps & D3DPTEXTURECAPS_POW2) == 0; - default: - return false; - }; -} - - - -//! sets transformation -void CD3D8Driver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) -{ - switch(state) - { - case ETS_VIEW: - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); - Transformation3DChanged = true; - break; - case ETS_WORLD: - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); - Transformation3DChanged = true; - break; - case ETS_PROJECTION: - pID3DDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); - Transformation3DChanged = true; - break; - case ETS_TEXTURE_0: - case ETS_TEXTURE_1: - case ETS_TEXTURE_2: - case ETS_TEXTURE_3: - if (mat.isIdentity()) - break; - pID3DDevice->SetTextureStageState( state - ETS_TEXTURE_0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTransform((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+ ( state - ETS_TEXTURE_0 )), - (D3DMATRIX*)((void*)mat.pointer())); - break; - } - - Matrices[state] = mat; -} - - - -//! sets the current Texture -bool CD3D8Driver::setTexture(s32 stage, video::ITexture* texture) -{ - if (CurrentTexture[stage] == texture) - return true; - - if (texture && texture->getDriverType() != EDT_DIRECT3D8) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - if (CurrentTexture[stage]) - CurrentTexture[stage]->drop(); - - CurrentTexture[stage] = texture; - - if (!texture) - { - pID3DDevice->SetTexture(stage, 0); - pID3DDevice->SetTextureStageState( stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - } - else - { - pID3DDevice->SetTexture(stage, ((CD3D8Texture*)texture)->getDX8Texture()); - texture->grab(); - } - return true; -} - - - -//! sets a material -void CD3D8Driver::setMaterial(const SMaterial& material) -{ - Material = material; - - for (u32 i=0; igetDriverType() != EDT_DIRECT3D8) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - // check for valid render target - - CD3D8Texture* tex = (CD3D8Texture*)texture; - - if (texture && !tex->isRenderTarget()) - { - os::Printer::log("Fatal Error: Tried to set a non render target texture as render target.", ELL_ERROR); - return false; - } - - if (texture && (tex->getSize().Width > ScreenSize.Width || - tex->getSize().Height > ScreenSize.Height )) - { - os::Printer::log("Error: Tried to set a render target texture which is bigger than the screen.", ELL_ERROR); - return false; - } - - // check if we should set the previous RT back - - bool ret = true; - - if (tex == 0) - { - if (PrevRenderTarget) - { - IDirect3DSurface8* dss = 0; - pID3DDevice->GetDepthStencilSurface(&dss); - - if (FAILED(pID3DDevice->SetRenderTarget(PrevRenderTarget, dss))) - { - os::Printer::log("Error: Could not set back to previous render target.", ELL_ERROR); - ret = false; - } - - if (dss) - dss->Release(); - - CurrentRendertargetSize = core::dimension2d(0,0); - PrevRenderTarget->Release(); - PrevRenderTarget = 0; - } - } - else - { - // we want to set a new target. so do this. - - // store previous target - - if (!PrevRenderTarget) - if (FAILED(pID3DDevice->GetRenderTarget(&PrevRenderTarget))) - { - os::Printer::log("Could not get previous render target.", ELL_ERROR); - return false; - } - - // set new render target - - IDirect3DSurface8* dss = 0; - pID3DDevice->GetDepthStencilSurface(&dss); - - if (FAILED(pID3DDevice->SetRenderTarget(tex->getRenderTargetSurface(), dss))) - { - os::Printer::log("Error: Could not set render target.", ELL_ERROR); - ret = false; - } - - if (dss) - dss->Release(); - - CurrentRendertargetSize = tex->getSize(); - } - - if (clearBackBuffer || clearZBuffer) - { - DWORD flags = 0; - - if (clearBackBuffer) - flags |= D3DCLEAR_TARGET; - - if (clearZBuffer) - flags |= D3DCLEAR_ZBUFFER; - - pID3DDevice->Clear(0, NULL, flags, color.color, 1.0f, 0); - } - - return ret; -} - -//! Creates a render target texture. -ITexture* CD3D8Driver::createRenderTargetTexture(const core::dimension2d& size) -{ - return new CD3D8Texture(this, size, 0); -} - - - -//! sets a viewport -void CD3D8Driver::setViewPort(const core::rect& area) -{ - core::rect vp(area); - core::rect rendert(0,0, ScreenSize.Width, ScreenSize.Height); - vp.clipAgainst(rendert); - - D3DVIEWPORT8 viewPort; - viewPort.X = vp.UpperLeftCorner.X; - viewPort.Y = vp.UpperLeftCorner.Y; - viewPort.Width = vp.getWidth(); - viewPort.Height = vp.getHeight(); - viewPort.MinZ = 0.0f; - viewPort.MaxZ = 1.0f; - - HRESULT hr = D3DERR_INVALIDCALL; - if (vp.getHeight()>0 && vp.getWidth()>0) - hr = pID3DDevice->SetViewport(&viewPort); - - if (FAILED(hr)) - os::Printer::log("Failed setting the viewport.", ELL_WARNING); - - ViewPort = vp; -} - - - -//! gets the area of the current viewport -const core::rect& CD3D8Driver::getViewPort() const -{ - return ViewPort; -} - - - -//! draws a vertex primitive list -void CD3D8Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) -{ - if (!checkPrimitiveCount(primitiveCount)) - return; - - CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType); - - if (!vertexCount || !primitiveCount) - return; - - setVertexShader(vType); - - size_t stride=0; - switch (vType) - { - case EVT_STANDARD: - stride=sizeof(S3DVertex); - break; - case EVT_2TCOORDS: - stride=sizeof(S3DVertex2TCoords); - break; - case EVT_TANGENTS: - stride=sizeof(S3DVertexTangents); - break; - } - if (setRenderStates3DMode()) - { - switch (pType) - { - case scene::EPT_POINTS: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_POINTLIST, 0, vertexCount, - primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); - break; - case scene::EPT_LINE_STRIP: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount, - primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); - break; - case scene::EPT_LINE_LOOP: - { - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount, - primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); - u16 tmpIndices[] = {0, primitiveCount}; - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, - 1, tmpIndices, D3DFMT_INDEX16, vertices, stride); - } - break; - case scene::EPT_LINES: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, - primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); - break; - case scene::EPT_TRIANGLE_STRIP: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount, - primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); - break; - case scene::EPT_TRIANGLE_FAN: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount, - primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); - break; - case scene::EPT_TRIANGLES: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vertexCount, - primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); - break; - } - } -} - - - -//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. -void CD3D8Driver::draw2DImage(video::ITexture* texture, const core::position2d& pos, - const core::rect& sourceRect, - const core::rect* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - if (!texture) - return; - - if (!sourceRect.isValid()) - return; - - if (!setTexture(0, texture)) - return; - - core::position2d targetPos = pos; - core::position2d sourcePos = sourceRect.UpperLeftCorner; - core::dimension2d sourceSize(sourceRect.getSize()); - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - - if (clipRect) - { - if (targetPos.X < clipRect->UpperLeftCorner.X) - { - sourceSize.Width += targetPos.X - clipRect->UpperLeftCorner.X; - if (sourceSize.Width <= 0) - return; - - sourcePos.X -= targetPos.X - clipRect->UpperLeftCorner.X; - targetPos.X = clipRect->UpperLeftCorner.X; - } - - if (targetPos.X + sourceSize.Width > clipRect->LowerRightCorner.X) - { - sourceSize.Width -= (targetPos.X + sourceSize.Width) - clipRect->LowerRightCorner.X; - if (sourceSize.Width <= 0) - return; - } - - if (targetPos.Y < clipRect->UpperLeftCorner.Y) - { - sourceSize.Height += targetPos.Y - clipRect->UpperLeftCorner.Y; - if (sourceSize.Height <= 0) - return; - - sourcePos.Y -= targetPos.Y - clipRect->UpperLeftCorner.Y; - targetPos.Y = clipRect->UpperLeftCorner.Y; - } - - if (targetPos.Y + sourceSize.Height > clipRect->LowerRightCorner.Y) - { - sourceSize.Height -= (targetPos.Y + sourceSize.Height) - clipRect->LowerRightCorner.Y; - if (sourceSize.Height <= 0) - return; - } - } - - // clip these coordinates - - if (targetPos.X<0) - { - sourceSize.Width += targetPos.X; - if (sourceSize.Width <= 0) - return; - - sourcePos.X -= targetPos.X; - targetPos.X = 0; - } - - if (targetPos.X + sourceSize.Width > renderTargetSize.Width) - { - sourceSize.Width -= (targetPos.X + sourceSize.Width) - renderTargetSize.Width; - if (sourceSize.Width <= 0) - return; - } - - if (targetPos.Y<0) - { - sourceSize.Height += targetPos.Y; - if (sourceSize.Height <= 0) - return; - - sourcePos.Y -= targetPos.Y; - targetPos.Y = 0; - } - - if (targetPos.Y + sourceSize.Height > renderTargetSize.Height) - { - sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height; - if (sourceSize.Height <= 0) - return; - } - - // ok, we've clipped everything. - // now draw it. - - s32 xPlus = -(renderTargetSize.Width>>1); - f32 xFact = 1.0f / (renderTargetSize.Width>>1); - - s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); - f32 yFact = 1.0f / (renderTargetSize.Height>>1); - - const core::dimension2d sourceSurfaceSize = texture->getOriginalSize(); - core::rect tcoords; - tcoords.UpperLeftCorner.X = (((f32)sourcePos.X)+0.5f) / texture->getOriginalSize().Width ; - tcoords.UpperLeftCorner.Y = (((f32)sourcePos.Y)+0.5f) / texture->getOriginalSize().Height; - tcoords.LowerRightCorner.X = (((f32)sourcePos.X +0.5f + (f32)sourceSize.Width)) / texture->getOriginalSize().Width; - tcoords.LowerRightCorner.Y = (((f32)sourcePos.Y +0.5f + (f32)sourceSize.Height)) / texture->getOriginalSize().Height; - - core::rect poss(targetPos, sourceSize); - - setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); - - S3DVertex vtx[4]; - vtx[0] = S3DVertex((f32)(poss.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-poss.UpperLeftCorner.Y ) * yFact , 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); - vtx[1] = S3DVertex((f32)(poss.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus- poss.UpperLeftCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); - vtx[2] = S3DVertex((f32)(poss.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus-poss.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); - vtx[3] = S3DVertex((f32)(poss.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-poss.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - - s16 indices[6] = {0,1,2,0,2,3}; - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16,&vtx[0], sizeof(S3DVertex)); -} - - - -void CD3D8Driver::draw2DImage(video::ITexture* texture, const core::rect& destRect, - const core::rect& sourceRect, const core::rect* clipRect, - video::SColor* colors, bool useAlphaChannelOfTexture) -{ - if(!texture) - return; - - const core::dimension2d& ss = texture->getOriginalSize(); - core::rect tcoords; - tcoords.UpperLeftCorner.X = (f32)sourceRect.UpperLeftCorner.X / (f32)ss.Width; - tcoords.UpperLeftCorner.Y = (f32)sourceRect.UpperLeftCorner.Y / (f32)ss.Height; - tcoords.LowerRightCorner.X = (f32)sourceRect.LowerRightCorner.X / (f32)ss.Width; - tcoords.LowerRightCorner.Y = (f32)sourceRect.LowerRightCorner.Y / (f32)ss.Height; - - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - core::rect npos; - f32 xFact = 2.0f / ( renderTargetSize.Width ); - f32 yFact = 2.0f / ( renderTargetSize.Height ); - npos.UpperLeftCorner.X = ( destRect.UpperLeftCorner.X * xFact ) - 1.0f; - npos.UpperLeftCorner.Y = 1.0f - ( destRect.UpperLeftCorner.Y * yFact ); - npos.LowerRightCorner.X = ( destRect.LowerRightCorner.X * xFact ) - 1.0f; - npos.LowerRightCorner.Y = 1.0f - ( destRect.LowerRightCorner.Y * yFact ); - - video::SColor temp[4] = - { - 0xFFFFFFFF, - 0xFFFFFFFF, - 0xFFFFFFFF, - 0xFFFFFFFF - }; - - video::SColor* useColor = colors ? colors : temp; - - S3DVertex vtx[4]; // clock wise - vtx[0] = S3DVertex(npos.UpperLeftCorner.X, npos.UpperLeftCorner.Y , 0.0f, 0.0f, 0.0f, 0.0f, useColor[0], tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); - vtx[1] = S3DVertex(npos.LowerRightCorner.X, npos.UpperLeftCorner.Y , 0.0f, 0.0f, 0.0f, 0.0f, useColor[3], tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); - vtx[2] = S3DVertex(npos.LowerRightCorner.X, npos.LowerRightCorner.Y, 0.0f, 0.0f, 0.0f, 0.0f, useColor[2], tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); - vtx[3] = S3DVertex(npos.UpperLeftCorner.X, npos.LowerRightCorner.Y, 0.0f, 0.0f, 0.0f, 0.0f, useColor[1], tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - - s16 indices[6] = {0,1,2,0,2,3}; - - setRenderStates2DMode(useColor[0].getAlpha()<255 || useColor[1].getAlpha()<255 || useColor[2].getAlpha()<255 || useColor[3].getAlpha()<255, true, useAlphaChannelOfTexture); - - setTexture(0, texture); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16,&vtx[0], sizeof(S3DVertex)); -} - - - -//!Draws an 2d rectangle with a gradient. -void CD3D8Driver::draw2DRectangle(const core::rect& position, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect* clip) -{ - core::rect pos(position); - - if (clip) - pos.clipAgainst(*clip); - - if (!pos.isValid()) - return; - - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - s32 xPlus = -(renderTargetSize.Width>>1); - f32 xFact = 1.0f / (renderTargetSize.Width>>1); - - s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); - f32 yFact = 1.0f / (renderTargetSize.Height>>1); - - S3DVertex vtx[4]; - vtx[0] = S3DVertex((f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.UpperLeftCorner.Y) * yFact , 0.0f, 0.0f, 0.0f, 0.0f, colorLeftUp, 0.0f, 0.0f); - vtx[1] = S3DVertex((f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus- pos.UpperLeftCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorRightUp, 0.0f, 1.0f); - vtx[2] = S3DVertex((f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorRightDown, 1.0f, 0.0f); - vtx[3] = S3DVertex((f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorLeftDown, 1.0f, 1.0f); - - s16 indices[6] = {0,1,2,0,2,3}; - - setRenderStates2DMode( - colorLeftUp.getAlpha() < 255 || - colorRightUp.getAlpha() < 255 || - colorLeftDown.getAlpha() < 255 || - colorRightDown.getAlpha() < 255, false, false); - - setTexture(0,0); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); - -} - - - -//! Draws a 2d line. -void CD3D8Driver::draw2DLine(const core::position2d& start, - const core::position2d& end, - SColor color) -{ - // thanks to Vash TheStampede who sent in his implementation - - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - const s32 xPlus = -(renderTargetSize.Width>>1); - const f32 xFact = 1.0f / (renderTargetSize.Width>>1); - - const s32 yPlus = - renderTargetSize.Height-(renderTargetSize.Height>>1); - const f32 yFact = 1.0f / (renderTargetSize.Height>>1); - - S3DVertex vtx[2]; - vtx[0] = S3DVertex((f32)(start.X + xPlus) * xFact, - (f32)(yPlus - start.Y) * yFact, - 0.0f, // z - 0.0f, 0.0f, 0.0f, // normal - color, - 0.0f, 0.0f); // texture - - vtx[1] = S3DVertex((f32)(end.X+xPlus) * xFact, - (f32)(yPlus- end.Y) * yFact, - 0.0f, - 0.0f, 0.0f, 0.0f, - color, - 0.0f, 0.0f); - - setRenderStates2DMode(color.getAlpha() < 255, false, false); - setTexture(0,0); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, &vtx[0], sizeof(S3DVertex)); -} - - - -//! sets right vertex shader -void CD3D8Driver::setVertexShader(E_VERTEX_TYPE newType) -{ - // Because we don't know if a vertex shader was set in a material instead of a - // fvf, this call cannot be prevented in D3D8. - //if (newType != LastVertexType) - { - LastVertexType = newType; - HRESULT hr = 0; - - switch(newType) - { - case EVT_STANDARD: - hr = pID3DDevice->SetVertexShader(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1); - break; - case EVT_2TCOORDS: - hr = pID3DDevice->SetVertexShader(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX2); - break; - case EVT_TANGENTS: - hr = pID3DDevice->SetVertexShader(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX3 | - D3DFVF_TEXCOORDSIZE2(0) | // real texture coord - D3DFVF_TEXCOORDSIZE3(1) | // misuse texture coord 2 for tangent - D3DFVF_TEXCOORDSIZE3(2) // misuse texture coord 3 for binormal - ); - break; - } - - if (FAILED(hr)) - { - os::Printer::log("Could not set vertex Shader.", ELL_ERROR); - return; - } - } -} - - -//! sets the needed renderstates -bool CD3D8Driver::setRenderStates3DMode() -{ - if (!pID3DDevice) - return false; - - if (CurrentRenderMode != ERM_3D) - { - // switch back the matrices - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&Matrices[ETS_VIEW])); - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&Matrices[ETS_WORLD])); - pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&Matrices[ETS_PROJECTION])); - - pID3DDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE); - - ResetRenderStates = true; - } - - if (ResetRenderStates || LastMaterial != Material) - { - // unset old material - - if (CurrentRenderMode == ERM_3D && - LastMaterial.MaterialType != Material.MaterialType && - LastMaterial.MaterialType >= 0 && LastMaterial.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); - - // set new material. - - if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial( - Material, LastMaterial, ResetRenderStates, this); - } - - bool shaderOK = true; - - if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - shaderOK = MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, LastVertexType); - - LastMaterial = Material; - - ResetRenderStates = false; - - CurrentRenderMode = ERM_3D; - - return shaderOK; -} - - -//! Can be called by an IMaterialRenderer to make its work easier. -void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, - bool resetAllRenderstates) -{ - if (resetAllRenderstates || - lastmaterial.AmbientColor != material.AmbientColor || - lastmaterial.DiffuseColor != material.DiffuseColor || - lastmaterial.SpecularColor != material.SpecularColor || - lastmaterial.EmissiveColor != material.EmissiveColor || - lastmaterial.Shininess != material.Shininess) - { - D3DMATERIAL8 mat; - mat.Diffuse = colorToD3D(material.DiffuseColor); - mat.Ambient = colorToD3D(material.AmbientColor); - mat.Specular = colorToD3D(material.SpecularColor); - mat.Emissive = colorToD3D(material.EmissiveColor); - mat.Power = material.Shininess; - pID3DDevice->SetMaterial(&mat); - } - - // Bilinear and/or trilinear - if (resetAllRenderstates || - lastmaterial.BilinearFilter != material.BilinearFilter || - lastmaterial.TrilinearFilter != material.TrilinearFilter || - lastmaterial.AnisotropicFilter != material.AnisotropicFilter ) - { - if (material.BilinearFilter || material.TrilinearFilter || material.AnisotropicFilter) - { - D3DTEXTUREFILTERTYPE tftMag = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) && material.AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; - D3DTEXTUREFILTERTYPE tftMin = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) && material.AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; - D3DTEXTUREFILTERTYPE tftMip = material.TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT; - - for (u32 st=0; stSetTextureStageState(st, D3DTSS_MAGFILTER, tftMag); - pID3DDevice->SetTextureStageState(st, D3DTSS_MINFILTER, tftMin); - pID3DDevice->SetTextureStageState(st, D3DTSS_MIPFILTER, tftMip); - } - } - else - { - for (u32 st=0; stSetTextureStageState(st, D3DTSS_MINFILTER, D3DTEXF_POINT); - pID3DDevice->SetTextureStageState(st, D3DTSS_MIPFILTER, D3DTEXF_NONE); - pID3DDevice->SetTextureStageState(st, D3DTSS_MAGFILTER, D3DTEXF_POINT); - } - } - } - - // fillmode - if (resetAllRenderstates || lastmaterial.Wireframe != material.Wireframe || lastmaterial.PointCloud != material.PointCloud) - { - if (material.Wireframe) - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); - else - if (material.PointCloud) - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_POINT); - else - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); - } - - // shademode - - if (resetAllRenderstates || lastmaterial.GouraudShading != material.GouraudShading) - { - if (material.GouraudShading) - pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); - else - pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); - } - - // lighting - - if (resetAllRenderstates || lastmaterial.Lighting != material.Lighting) - { - if (material.Lighting) - pID3DDevice->SetRenderState(D3DRS_LIGHTING, TRUE); - else - pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); - } - - - // zbuffer - - if (resetAllRenderstates || lastmaterial.ZBuffer != material.ZBuffer) - { - switch (material.ZBuffer) - { - case 0: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - break; - case 1: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); - break; - case 2: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL); - break; - } - } - - - // zwrite - if (resetAllRenderstates || lastmaterial.ZWriteEnable != material.ZWriteEnable) - { - if (material.ZWriteEnable) - pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE); - else - pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE); - } - - // back face culling - - - if (resetAllRenderstates || lastmaterial.BackfaceCulling != material.BackfaceCulling) - { - if (material.BackfaceCulling) - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW); - else - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE); - } - - // fog - if (resetAllRenderstates || lastmaterial.FogEnable != material.FogEnable) - { - pID3DDevice->SetRenderState(D3DRS_FOGENABLE, material.FogEnable); - } - - // specular highlights - if (resetAllRenderstates || !core::equals(lastmaterial.Shininess, material.Shininess)) - { - bool enable = (material.Shininess!=0); - pID3DDevice->SetRenderState(D3DRS_SPECULARENABLE, enable); - pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, enable); - pID3DDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL); - } - - // normalization - if (resetAllRenderstates || lastmaterial.NormalizeNormals != material.NormalizeNormals) - { - pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, material.NormalizeNormals); - } - - // texture address mode - for (u32 st=0; stSetTextureStageState(st, D3DTSS_ADDRESSU, mode ); - pID3DDevice->SetTextureStageState(st, D3DTSS_ADDRESSV, mode ); - } - - } - - -} - - - -//! sets the needed renderstates -void CD3D8Driver::setRenderStatesStencilShadowMode(bool zfail) -{ - if ((CurrentRenderMode != ERM_SHADOW_VOLUME_ZFAIL && - CurrentRenderMode != ERM_SHADOW_VOLUME_ZPASS) || - Transformation3DChanged) - { - // switch back the matrices - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&Matrices[ETS_VIEW])); - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&Matrices[ETS_WORLD])); - pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&Matrices[ETS_PROJECTION])); - - Transformation3DChanged = false; - - setTexture(0,0); - setTexture(1,0); - setTexture(2,0); - setTexture(3,0); - - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetVertexShader(D3DFVF_XYZ); - LastVertexType = (video::E_VERTEX_TYPE)(-1); - - pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE ); - pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE ); - pID3DDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT); - - //pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); - //pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); - - // unset last 3d material - if (CurrentRenderMode == ERM_3D && - Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); - } - - if (CurrentRenderMode != ERM_SHADOW_VOLUME_ZPASS && !zfail) - { - // USE THE ZPASS METHOD - - pID3DDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP ); - - pID3DDevice->SetRenderState( D3DRS_STENCILREF, 0x1 ); - pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); - pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); - - pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO ); - pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); - } - else - if (CurrentRenderMode != ERM_SHADOW_VOLUME_ZFAIL && zfail) - { - // USE THE ZFAIL METHOD - - pID3DDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_KEEP ); - - pID3DDevice->SetRenderState( D3DRS_STENCILREF, 0x0 ); - pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); - pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); - - pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); - pID3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO ); - pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); - } - - CurrentRenderMode = zfail ? ERM_SHADOW_VOLUME_ZFAIL : ERM_SHADOW_VOLUME_ZPASS; -} - - - -//! sets the needed renderstates -void CD3D8Driver::setRenderStatesStencilFillMode(bool alpha) -{ - if (CurrentRenderMode != ERM_STENCIL_FILL || Transformation3DChanged) - { - core::matrix4 mat; - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); - pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); - - pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); - pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetRenderState(D3DRS_STENCILREF, 0x1 ); - pID3DDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_LESSEQUAL); - //pID3DDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_GREATEREQUAL); - pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); - pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); - - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW); - - Transformation3DChanged = false; - - if (alpha) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE ); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - } - - CurrentRenderMode = ERM_STENCIL_FILL; -} - - - -//! sets the needed renderstates -void CD3D8Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) -{ - if (!pID3DDevice) - return; - - if (CurrentRenderMode != ERM_2D || Transformation3DChanged) - { - core::matrix4 mat; - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); - pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); - - pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - //pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); - pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); - pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - - pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE ); - - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW); - - pID3DDevice->SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP ); - pID3DDevice->SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP ); - pID3DDevice->SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP ); - pID3DDevice->SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP ); - pID3DDevice->SetTextureStageState(2, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP ); - pID3DDevice->SetTextureStageState(2, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP ); - pID3DDevice->SetTextureStageState(3, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP ); - pID3DDevice->SetTextureStageState(3, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP ); - - pID3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0); - pID3DDevice->SetTransform( D3DTS_TEXTURE0, &UnitMatrixD3D8 ); - - Transformation3DChanged = false; - - // unset last 3d material - if (CurrentRenderMode == ERM_3D && - Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); - } - - if (texture) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_POINT); - pID3DDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_NONE); - pID3DDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_POINT); - - if (alphaChannel) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - - if (alpha) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); - } - else - { - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - } - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); - } - else - { - if (alpha) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - } - } - else - { - if (alpha) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE ); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - } - - CurrentRenderMode = ERM_2D; -} - - -//! deletes all dynamic lights there are -void CD3D8Driver::deleteAllDynamicLights() -{ - for (s32 i=0; iLightEnable(i, false); - - LastSetLight = -1; - - CNullDriver::deleteAllDynamicLights(); -} - - - -//! adds a dynamic light -void CD3D8Driver::addDynamicLight(const SLight& dl) -{ - if ((u32)LastSetLight == Caps.MaxActiveLights-1) - return; - - CNullDriver::addDynamicLight(dl); - - D3DLIGHT8 light; - - if ( dl.Type == ELT_POINT ) - { - light.Type = D3DLIGHT_POINT; - light.Position = *(D3DVECTOR*)((void*)(&dl.Position)); - } - else - if ( dl.Type == ELT_DIRECTIONAL ) - { - light.Type = D3DLIGHT_DIRECTIONAL; - light.Direction = *(D3DVECTOR*)((void*)(&dl.Position)); - } - - light.Diffuse = *(D3DCOLORVALUE*)((void*)(&dl.DiffuseColor)); - light.Specular = *(D3DCOLORVALUE*)((void*)(&dl.SpecularColor)); - light.Ambient = *(D3DCOLORVALUE*)((void*)(&dl.AmbientColor)); - light.Range = MaxLightDistance; - - light.Attenuation0 = 0.0f; - light.Attenuation1 = 1.0f / dl.Radius; - light.Attenuation2 = 0.0f; - - ++LastSetLight; - pID3DDevice->SetLight(LastSetLight, &light); - pID3DDevice->LightEnable(LastSetLight, true); -} - - - -//! returns the maximal amount of dynamic lights the device can handle -u32 CD3D8Driver::getMaximalDynamicLightAmount() -{ - return Caps.MaxActiveLights; -} - - - -//! Sets the dynamic ambient light color. The default color is -//! (0,0,0,0) which means it is dark. -//! \param color: New color of the ambient light. -void CD3D8Driver::setAmbientLight(const SColorf& color) -{ - if (!pID3DDevice) - return; - - AmbientLight = color; - D3DCOLOR col = color.toSColor().color; - pID3DDevice->SetRenderState(D3DRS_AMBIENT, col); -} - - - -//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 -//! driver, it would return "Direct3D8.1". -const wchar_t* CD3D8Driver::getName() -{ - return L"Direct3D 8.1"; -} - - - -//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do -//! this: Frist, draw all geometry. Then use this method, to draw the shadow -//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. -void CD3D8Driver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail) -{ - if (!StencilBuffer || !count) - return; - - setRenderStatesStencilShadowMode(zfail); - - if (!zfail) - { - // ZPASS Method - - // Draw front-side of shadow volume in stencil/z only - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW ); - pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_INCRSAT); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - - // Now reverse cull order so front sides of shadow volume are written. - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW ); - pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_DECRSAT); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - } - else - { - // ZFAIL Method - - // Draw front-side of shadow volume in stencil/z only - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW ); - pID3DDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_INCRSAT ); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - - // Now reverse cull order so front sides of shadow volume are written. - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_DECRSAT ); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - } -} - - - -//! Fills the stencil shadow with color. After the shadow volume has been drawn -//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this -//! to draw the color of the shadow. -void CD3D8Driver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge, - video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge) -{ - if (!StencilBuffer) - return; - - S3DVertex vtx[4]; - vtx[0] = S3DVertex(1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftUpEdge, 0.0f, 0.0f); - vtx[1] = S3DVertex(1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightUpEdge, 0.0f, 1.0f); - vtx[2] = S3DVertex(-1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftDownEdge, 1.0f, 0.0f); - vtx[3] = S3DVertex(-1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightDownEdge, 1.0f, 1.0f); - - s16 indices[6] = {0,1,2,1,3,2}; - - setRenderStatesStencilFillMode( - leftUpEdge.getAlpha() < 255 || - rightUpEdge.getAlpha() < 255 || - leftDownEdge.getAlpha() < 255 || - rightDownEdge.getAlpha() < 255); - - setTexture(0,0); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); - - if (clearStencilBuffer) - pID3DDevice->Clear( 0, NULL, D3DCLEAR_STENCIL,0, 1.0, 0); -} - - - -//! Returns the maximum amount of primitives (mostly vertices) which -//! the device is able to render with one drawIndexedTriangleList -//! call. -u32 CD3D8Driver::getMaximalPrimitiveCount() -{ - return Caps.MaxPrimitiveCount; -} - - -//! Sets the fog mode. -void CD3D8Driver::setFog(SColor color, bool linearFog, f32 start, - f32 end, f32 density, bool pixelFog, bool rangeFog) -{ - CNullDriver::setFog(color, linearFog, start, end, density, pixelFog, rangeFog); - - if (!pID3DDevice) - return; - - pID3DDevice->SetRenderState(D3DRS_FOGCOLOR, color.color); - - pID3DDevice->SetRenderState( - pixelFog ? D3DRS_FOGTABLEMODE : D3DRS_FOGVERTEXMODE, - linearFog ? D3DFOG_LINEAR : D3DFOG_EXP); - - if(linearFog) - { - pID3DDevice->SetRenderState(D3DRS_FOGSTART, *(DWORD*)(&start)); - pID3DDevice->SetRenderState(D3DRS_FOGEND, *(DWORD*)(&end)); - } - else - pID3DDevice->SetRenderState(D3DRS_FOGDENSITY, *(DWORD*)(&density)); - - if(!pixelFog) - pID3DDevice->SetRenderState (D3DRS_RANGEFOGENABLE, rangeFog); -} - -//! Draws a 3d line. -void CD3D8Driver::draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color) -{ - setVertexShader(EVT_STANDARD); - setRenderStates3DMode(); - video::S3DVertex v[2]; - v[0].Color = color; - v[1].Color = color; - v[0].Pos = start; - v[1].Pos = end; - - pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, v, sizeof(S3DVertex)); -} - - -void CD3D8Driver::OnResize(const core::dimension2d& size) -{ - if (!pID3DDevice) - return; - - CNullDriver::OnResize(size); - reset(); -} - -//! Returns type of video driver -E_DRIVER_TYPE CD3D8Driver::getDriverType() -{ - return EDT_DIRECT3D8; -} - -//! Returns the transformation set by setTransform -const core::matrix4& CD3D8Driver::getTransform(E_TRANSFORMATION_STATE state) -{ - return Matrices[state]; -} - -//! Sets a vertex shader constant. -void CD3D8Driver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ - if (data) - pID3DDevice->SetVertexShaderConstant(startRegister, data, constantAmount); -} - -//! Sets a pixel shader constant. -void CD3D8Driver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ - if (data) - pID3DDevice->SetPixelShaderConstant(startRegister, data, constantAmount); -} - -//! Sets a constant for the vertex shader based on a name. -bool CD3D8Driver::setVertexShaderConstant(const c8* name, const f32* floats, int count) -{ - os::Printer::log("Cannot set constant, no HLSL supported in D3D8"); - return false; -} - -//! Sets a constant for the pixel shader based on a name. -bool CD3D8Driver::setPixelShaderConstant(const c8* name, const f32* floats, int count) -{ - os::Printer::log("Cannot set constant, no HLSL supported in D3D8"); - return false; -} - -//! Returns pointer to the IGPUProgrammingServices interface. -IGPUProgrammingServices* CD3D8Driver::getGPUProgrammingServices() -{ - return this; -} - - -//! Adds a new material renderer to the VideoDriver, using pixel and/or -//! vertex shaders to render geometry. -s32 CD3D8Driver::addShaderMaterial(const c8* vertexShaderProgram, - const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, s32 userData) -{ - s32 nr = -1; - CD3D8ShaderMaterialRenderer* r = new CD3D8ShaderMaterialRenderer( - pID3DDevice, this, nr, vertexShaderProgram, pixelShaderProgram, - callback, getMaterialRenderer(baseMaterial), userData); - - r->drop(); - return nr; -} - - -//! Returns a pointer to the IVideoDriver interface. (Implementation for -//! IMaterialRendererServices) -IVideoDriver* CD3D8Driver::getVideoDriver() -{ - return this; -} - - - -//! Clears the ZBuffer. -void CD3D8Driver::clearZBuffer() -{ - HRESULT hr = pID3DDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0, 0); - - if (FAILED(hr)) - os::Printer::log("CD3D8Driver clearZBuffer() failed.", ELL_WARNING); -} - -//! Returns an image created from the last rendered frame. -IImage* CD3D8Driver::createScreenShot() -{ - HRESULT hr; - - // query the screen dimensions of the current adapter - D3DDISPLAYMODE displayMode; - pID3DDevice->GetDisplayMode(&displayMode); - - // create the image surface to store the front buffer image [always A8R8G8B8] - LPDIRECT3DSURFACE8 lpSurface; - if (FAILED(hr = pID3DDevice->CreateImageSurface(displayMode.Width, displayMode.Height, D3DFMT_A8R8G8B8, &lpSurface))) - return 0; - - // read the front buffer into the image surface - if (FAILED(hr = pID3DDevice->GetFrontBuffer(lpSurface))) - { - lpSurface->Release(); - return 0; - } - - RECT clientRect; - { - POINT clientPoint; - clientPoint.x = 0; - clientPoint.y = 0; - - ClientToScreen( (HWND)getExposedVideoData().D3D8.HWnd, &clientPoint ); - - clientRect.left = clientPoint.x; - clientRect.top = clientPoint.y; - clientRect.right = clientRect.left + ScreenSize.Width; - clientRect.bottom = clientRect.top + ScreenSize.Height; - } - - // lock our area of the surface - D3DLOCKED_RECT lockedRect; - if (FAILED(lpSurface->LockRect(&lockedRect, &clientRect, D3DLOCK_READONLY))) - { - lpSurface->Release(); - return 0; - } - - // this could throw, but we aren't going to worry about that case very much - IImage* newImage = new CImage(ECF_A8R8G8B8, ScreenSize); - - // d3d pads the image, so we need to copy the correct number of bytes - u32* pPixels = (u32*)newImage->lock(); - if (pPixels) - { - u8 * sP = (u8 *)lockedRect.pBits; - u32* dP = (u32*)pPixels; - - for (s32 y = 0; y < ScreenSize.Height; ++y) - { - memcpy(dP, sP, ScreenSize.Width * 4); - - sP += lockedRect.Pitch; - dP += ScreenSize.Width; - } - - newImage->unlock(); - } - - // we can unlock and release the surface - lpSurface->UnlockRect(); - - // release the image surface - lpSurface->Release(); - - // return status of save operation to caller - return newImage; -} - - - -// returns the current size of the screen or rendertarget -core::dimension2d CD3D8Driver::getCurrentRenderTargetSize() -{ - if ( CurrentRendertargetSize.Width == 0 ) - return ScreenSize; - else - return CurrentRendertargetSize; -} - - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ -#endif // _IRR_WINDOWS_ - - - - -namespace irr -{ -namespace video -{ - -#ifdef _IRR_WINDOWS_ -//! creates a video driver -IVideoDriver* createDirectX8Driver(const core::dimension2d& screenSize, HWND window, - u32 bits, bool fullscreen, bool stencilbuffer, - io::IFileSystem* io, bool pureSoftware, bool highPrecisionFPU, - bool vsync, bool antiAlias) -{ - #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - CD3D8Driver* dx8 = new CD3D8Driver(screenSize, window, fullscreen, - stencilbuffer, io, pureSoftware); - - if (!dx8->initDriver(screenSize, window, bits, fullscreen, - pureSoftware, highPrecisionFPU, vsync, antiAlias)) - { - dx8->drop(); - dx8 = 0; - } - - return dx8; - - #else - - return 0; - - #endif // _IRR_COMPILE_WITH_DIRECT3D_8_ -} -#endif - -} // end namespace video -} // end namespace irr - - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_WINDOWS_ + +#define _IRR_DONT_DO_MEMORY_DEBUGGING_HERE +#include "CD3D8Driver.h" +#include "os.h" +#include "S3DVertex.h" +#include "CD3D8Texture.h" +#include "CImage.h" + +#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ + +#include "CD3D8MaterialRenderer.h" +#include "CD3D8ShaderMaterialRenderer.h" +#include "CD3D8NormalMapRenderer.h" +#include "CD3D8ParallaxMapRenderer.h" + +namespace irr +{ +namespace video +{ + + +//! constructor +CD3D8Driver::CD3D8Driver(const core::dimension2d& screenSize, HWND window, + bool fullscreen, bool stencilbuffer, + io::IFileSystem* io, bool pureSoftware, bool vsync) +: CNullDriver(io, screenSize), CurrentRenderMode(ERM_NONE), + ResetRenderStates(true), Transformation3DChanged(false), StencilBuffer(stencilbuffer), + D3DLibrary(0), pID3D(0), pID3DDevice(0), PrevRenderTarget(0), + LastVertexType((video::E_VERTEX_TYPE)-1), MaxTextureUnits(0), + MaxLightDistance(sqrtf(FLT_MAX)), LastSetLight(-1), DeviceLost(false) +{ + #ifdef _DEBUG + setDebugName("CD3D8Driver"); + #endif + + printVersion(); + + for (u32 i=0; idrop(); + + // drop d3d8 + + if (pID3DDevice) + pID3DDevice->Release(); + + if (pID3D) + pID3D->Release(); +} + + +void CD3D8Driver::createMaterialRenderers() +{ + // create D3D8 material renderers + + addAndDropMaterialRenderer(new CD3D8MaterialRenderer_SOLID(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D8MaterialRenderer_SOLID_2_LAYER(pID3DDevice, this)); + + // add the same renderer for all lightmap types + CD3D8MaterialRenderer_LIGHTMAP* lmr = new CD3D8MaterialRenderer_LIGHTMAP(pID3DDevice, this); + addMaterialRenderer(lmr); // for EMT_LIGHTMAP: + addMaterialRenderer(lmr); // for EMT_LIGHTMAP_ADD: + addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M2: + addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M4: + addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING: + addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M2: + addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M4: + lmr->drop(); + + // add remaining material renderers + addAndDropMaterialRenderer(new CD3D8MaterialRenderer_DETAIL_MAP(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D8MaterialRenderer_SPHERE_MAP(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D8MaterialRenderer_REFLECTION_2_LAYER(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_ADD_COLOR(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(pID3DDevice, this)); + + // add normal map renderers + s32 tmp = 0; + video::IMaterialRenderer* renderer = 0; + + renderer = new CD3D8NormalMapRenderer(pID3DDevice, this, tmp, + MaterialRenderers[EMT_SOLID].Renderer); + renderer->drop(); + + renderer = new CD3D8NormalMapRenderer(pID3DDevice, this, tmp, + MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); + renderer->drop(); + + renderer = new CD3D8NormalMapRenderer(pID3DDevice, this, tmp, + MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); + renderer->drop(); + + // add parallax map renderers + + renderer = new CD3D8ParallaxMapRenderer(pID3DDevice, this, tmp, + MaterialRenderers[EMT_SOLID].Renderer); + renderer->drop(); + + renderer = new CD3D8ParallaxMapRenderer(pID3DDevice, this, tmp, + MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); + renderer->drop(); + + renderer = new CD3D8ParallaxMapRenderer(pID3DDevice, this, tmp, + MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); + renderer->drop(); + + // add basic 1 texture blending + addAndDropMaterialRenderer(new CD3D8MaterialRenderer_ONETEXTURE_BLEND(pID3DDevice, this)); + +} + + +//! initialises the Direct3D API +bool CD3D8Driver::initDriver(const core::dimension2d& screenSize, HWND hwnd, + u32 bits, bool fullScreen, bool pureSoftware, + bool highPrecisionFPU, bool vsync, bool antiAlias) +{ + HRESULT hr; + D3DLibrary = LoadLibrary( "d3d8.dll" ); + + if (!D3DLibrary) + { + os::Printer::log("Error, could not load d3d8.dll.", ELL_ERROR); + return false; + } + + typedef IDirect3D8 * (__stdcall *D3DCREATETYPE)(UINT); + D3DCREATETYPE d3dCreate = (D3DCREATETYPE) GetProcAddress(D3DLibrary, "Direct3DCreate8"); + + if (!d3dCreate) + { + os::Printer::log("Error, could not get proc adress of Direct3DCreate8.", ELL_ERROR); + return false; + } + + //just like pID3D = Direct3DCreate8(D3D_SDK_VERSION); + pID3D = (*d3dCreate)(D3D_SDK_VERSION); + + if (!pID3D) + { + os::Printer::log("Error initializing D3D.", ELL_ERROR); + return false; + } + + // print device information + D3DADAPTER_IDENTIFIER8 dai; + if (!FAILED(pID3D->GetAdapterIdentifier(D3DADAPTER_DEFAULT, D3DENUM_NO_WHQL_LEVEL, &dai))) + { + char tmp[512]; + + s32 Product = HIWORD(dai.DriverVersion.HighPart); + s32 Version = LOWORD(dai.DriverVersion.HighPart); + s32 SubVersion = HIWORD(dai.DriverVersion.LowPart); + s32 Build = LOWORD(dai.DriverVersion.LowPart); + + sprintf(tmp, "%s %s %d.%d.%d.%d", dai.Description, dai.Driver, Product, Version, + SubVersion, Build); + os::Printer::log(tmp, ELL_INFORMATION); + } + + + + D3DDISPLAYMODE d3ddm; + hr = pID3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm); + if (FAILED(hr)) + { + os::Printer::log("Error: Could not get Adapter Display mode.", ELL_ERROR); + return false; + } + + + ZeroMemory(&present, sizeof(present)); + + present.SwapEffect = D3DSWAPEFFECT_COPY; + present.Windowed = TRUE; + present.BackBufferFormat = d3ddm.Format; + present.EnableAutoDepthStencil = TRUE; + + if (fullScreen) + { + present.SwapEffect = D3DSWAPEFFECT_FLIP; + present.Windowed = FALSE; + present.BackBufferWidth = screenSize.Width; + present.BackBufferHeight = screenSize.Height; + present.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; + present.FullScreen_PresentationInterval = vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; + + if (bits == 32) + present.BackBufferFormat = D3DFMT_X8R8G8B8; + else + present.BackBufferFormat = D3DFMT_R5G6B5; + } + + D3DDEVTYPE devtype = D3DDEVTYPE_HAL; + #ifndef _IRR_D3D_NO_SHADER_DEBUGGING + devtype = D3DDEVTYPE_REF; + #endif + + // enable anti alias if possible and whished + if (antiAlias) + { + DWORD qualityLevels = 0; + + if (!FAILED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, + devtype , present.BackBufferFormat, !fullScreen, + D3DMULTISAMPLE_2_SAMPLES))) + { + // enable multi sampling + present.SwapEffect = D3DSWAPEFFECT_DISCARD; + present.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES; + } + else + { + os::Printer::log("Anti aliasing disabled because hardware/driver lacks necessary caps.", ELL_WARNING); + antiAlias = false; + } + } + + // check stencil buffer compatibility + if (StencilBuffer) + { + present.AutoDepthStencilFormat = D3DFMT_D24S8; + if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, + present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, + D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) + { + present.AutoDepthStencilFormat = D3DFMT_D24X4S4; + if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, + present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, + D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) + { + present.AutoDepthStencilFormat = D3DFMT_D15S1; + if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, + present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, + D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) + { + os::Printer::log("Device does not support stencilbuffer, disabling stencil buffer.", ELL_WARNING); + StencilBuffer = false; + } + } + } + else + if(FAILED(pID3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, devtype, + present.BackBufferFormat, present.BackBufferFormat, present.AutoDepthStencilFormat))) + { + os::Printer::log("Depth-stencil format is not compatible with display format, disabling stencil buffer.", ELL_WARNING); + StencilBuffer = false; + } + } + // do not use else here to cope with flag change in previous block + if (!StencilBuffer) + { + present.AutoDepthStencilFormat = D3DFMT_D32; + if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, + present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, + D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) + { + present.AutoDepthStencilFormat = D3DFMT_D24X8; + if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, + present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, + D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) + { + present.AutoDepthStencilFormat = D3DFMT_D16; + if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, + present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, + D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) + { + os::Printer::log("Device does not support required depth buffer.", ELL_WARNING); + return false; + } + } + } + } + + // create device + + DWORD fpuPrecision = highPrecisionFPU ? D3DCREATE_FPU_PRESERVE : 0; + if (pureSoftware) + { + hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, hwnd, + fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); + + if (FAILED(hr)) + os::Printer::log("Was not able to create Direct3D8 software device.", ELL_ERROR); + } + else + { + hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, + fpuPrecision | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice); + + if(FAILED(hr)) + hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, + fpuPrecision | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice); + if(FAILED(hr)) + hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, + fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); + if (FAILED(hr)) + os::Printer::log("Was not able to create Direct3D8 device.", ELL_ERROR); + } + + if (!pID3DDevice) + { + os::Printer::log("Was not able to create Direct3D8 device.", ELL_ERROR); + return false; + } + + // get caps + pID3DDevice->GetDeviceCaps(&Caps); + + if (StencilBuffer && + (!(Caps.StencilCaps & D3DSTENCILCAPS_DECRSAT) || + !(Caps.StencilCaps & D3DSTENCILCAPS_INCRSAT) || + !(Caps.StencilCaps & D3DSTENCILCAPS_KEEP))) + { + os::Printer::log("Device not able to use stencil buffer, disabling stencil buffer.", ELL_WARNING); + StencilBuffer = false; + } + + // set default vertex shader + setVertexShader(EVT_STANDARD); + + // enable antialiasing + if (antiAlias) + pID3DDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE); + + // set fog mode + setFog(FogColor, LinearFog, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); + + // set exposed data + ExposedData.D3D8.D3D8 = pID3D; + ExposedData.D3D8.D3DDev8 = pID3DDevice; + ExposedData.D3D8.HWnd = reinterpret_cast(hwnd); + + ResetRenderStates = true; + + // create materials + createMaterialRenderers(); + + MaxTextureUnits = core::min_((u32)Caps.MaxSimultaneousTextures, MATERIAL_MAX_TEXTURES); + + // set the renderstates + setRenderStates3DMode(); + + // set max anisotropy + pID3DDevice->SetTextureStageState(0, D3DTSS_MAXANISOTROPY, core::min_( (DWORD) 16, Caps.MaxAnisotropy)); + pID3DDevice->SetTextureStageState(1, D3DTSS_MAXANISOTROPY, core::min_( (DWORD) 16, Caps.MaxAnisotropy)); + pID3DDevice->SetTextureStageState(2, D3DTSS_MAXANISOTROPY, core::min_( (DWORD) 16, Caps.MaxAnisotropy)); + pID3DDevice->SetTextureStageState(3, D3DTSS_MAXANISOTROPY, core::min_( (DWORD) 16, Caps.MaxAnisotropy)); + + // so far so good. + return true; +} + + + + +//! applications must call this method before performing any rendering. returns false if failed. +bool CD3D8Driver::beginScene(bool backBuffer, bool zBuffer, SColor color) +{ + CNullDriver::beginScene(backBuffer, zBuffer, color); + HRESULT hr; + + if (!pID3DDevice) + return false; + + if (DeviceLost) + { + if(FAILED(hr = pID3DDevice->TestCooperativeLevel())) + { + if (hr == D3DERR_DEVICELOST) + return false; + + if (hr == D3DERR_DEVICENOTRESET) + reset(); + return false; + } + } + + DWORD flags = 0; + + if (backBuffer) + flags |= D3DCLEAR_TARGET; + + if (zBuffer) + flags |= D3DCLEAR_ZBUFFER; + + if (StencilBuffer) + flags |= D3DCLEAR_STENCIL; + + hr = pID3DDevice->Clear( 0, NULL, flags, color.color, 1.0, 0); + if (FAILED(hr)) + os::Printer::log("Direct3D8 clear failed.", ELL_WARNING); + + hr = pID3DDevice->BeginScene(); + if (FAILED(hr)) + { + os::Printer::log("Direct3D8 begin scene failed.", ELL_WARNING); + return false; + } + + return true; +} + + + +//! resets the device +bool CD3D8Driver::reset() +{ + // reset + HRESULT hr; + os::Printer::log("Resetting D3D8 device.", ELL_INFORMATION); + if (FAILED(hr = pID3DDevice->Reset(&present))) + { + if (hr == D3DERR_DEVICELOST) + { + DeviceLost = true; + os::Printer::log("Resetting failed due to device lost.", ELL_WARNING); + } + else + os::Printer::log("Resetting failed.", ELL_WARNING); + return false; + } + + DeviceLost = false; + ResetRenderStates = true; + LastVertexType = (E_VERTEX_TYPE)-1; + + for (u32 i=0; idrop(); + CurrentTexture[i] = 0; + } + + setVertexShader(EVT_STANDARD); + setRenderStates3DMode(); + setFog(FogColor, LinearFog, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); + setAmbientLight(AmbientLight); + + return true; +} + + + +//! applications must call this method after performing any rendering. returns false if failed. +bool CD3D8Driver::endScene( s32 windowId, core::rect* sourceRect ) +{ + CNullDriver::endScene(); + + HRESULT hr = pID3DDevice->EndScene(); + if (FAILED(hr)) + { + os::Printer::log("DIRECT3D8 end scene failed.", ELL_WARNING); + return false; + } + + RECT* srcRct = 0; + RECT sourceRectData; + if ( sourceRect) + { + srcRct = &sourceRectData; + sourceRectData.left = sourceRect->UpperLeftCorner.X; + sourceRectData.top = sourceRect->UpperLeftCorner.Y; + sourceRectData.right = sourceRect->LowerRightCorner.X; + sourceRectData.bottom = sourceRect->LowerRightCorner.Y; + } + + hr = pID3DDevice->Present(srcRct, NULL, (HWND)windowId, NULL); + + if (hr == D3DERR_DEVICELOST) + { + DeviceLost = true; + os::Printer::log("DIRECT3D8 device lost.", ELL_WARNING); + } + else + if (FAILED(hr) && hr != D3DERR_INVALIDCALL) + { + os::Printer::log("DIRECT3D8 present failed.", ELL_WARNING); + return false; + } + + return true; +} + + + +//! queries the features of the driver, returns true if feature is available +bool CD3D8Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) +{ + switch (feature) + { + case EVDF_RENDER_TO_TARGET: + case EVDF_MULTITEXTURE: + case EVDF_BILINEAR_FILTER: + return true; + case EVDF_HARDWARE_TL: + return (Caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) != 0; + case EVDF_MIP_MAP: + return (Caps.TextureCaps & D3DPTEXTURECAPS_MIPMAP) != 0; + case EVDF_STENCIL_BUFFER: + return StencilBuffer && Caps.StencilCaps; + case EVDF_VERTEX_SHADER_1_1: + return Caps.VertexShaderVersion >= D3DVS_VERSION(1,1); + case EVDF_VERTEX_SHADER_2_0: + return Caps.VertexShaderVersion >= D3DVS_VERSION(2,0); + case EVDF_VERTEX_SHADER_3_0: + return Caps.VertexShaderVersion >= D3DVS_VERSION(3,0); + case EVDF_PIXEL_SHADER_1_1: + return Caps.PixelShaderVersion >= D3DPS_VERSION(1,1); + case EVDF_PIXEL_SHADER_1_2: + return Caps.PixelShaderVersion >= D3DPS_VERSION(1,2); + case EVDF_PIXEL_SHADER_1_3: + return Caps.PixelShaderVersion >= D3DPS_VERSION(1,3); + case EVDF_PIXEL_SHADER_1_4: + return Caps.PixelShaderVersion >= D3DPS_VERSION(1,4); + case EVDF_PIXEL_SHADER_2_0: + return Caps.PixelShaderVersion >= D3DPS_VERSION(2,0); + case EVDF_PIXEL_SHADER_3_0: + return Caps.PixelShaderVersion >= D3DPS_VERSION(3,0); + case EVDF_TEXTURE_NPOT: + return (Caps.TextureCaps & D3DPTEXTURECAPS_POW2) == 0; + default: + return false; + }; +} + + + +//! sets transformation +void CD3D8Driver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) +{ + switch(state) + { + case ETS_VIEW: + pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); + Transformation3DChanged = true; + break; + case ETS_WORLD: + pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); + Transformation3DChanged = true; + break; + case ETS_PROJECTION: + pID3DDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); + Transformation3DChanged = true; + break; + case ETS_TEXTURE_0: + case ETS_TEXTURE_1: + case ETS_TEXTURE_2: + case ETS_TEXTURE_3: + if (mat.isIdentity()) + break; + pID3DDevice->SetTextureStageState( state - ETS_TEXTURE_0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); + pID3DDevice->SetTransform((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+ ( state - ETS_TEXTURE_0 )), + (D3DMATRIX*)((void*)mat.pointer())); + break; + } + + Matrices[state] = mat; +} + + + +//! sets the current Texture +bool CD3D8Driver::setTexture(s32 stage, video::ITexture* texture) +{ + if (CurrentTexture[stage] == texture) + return true; + + if (texture && texture->getDriverType() != EDT_DIRECT3D8) + { + os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); + return false; + } + + if (CurrentTexture[stage]) + CurrentTexture[stage]->drop(); + + CurrentTexture[stage] = texture; + + if (!texture) + { + pID3DDevice->SetTexture(stage, 0); + pID3DDevice->SetTextureStageState( stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); + } + else + { + pID3DDevice->SetTexture(stage, ((CD3D8Texture*)texture)->getDX8Texture()); + texture->grab(); + } + return true; +} + + + +//! sets a material +void CD3D8Driver::setMaterial(const SMaterial& material) +{ + Material = material; + + for (u32 i=0; igetDriverType() != EDT_DIRECT3D8) + { + os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); + return false; + } + + // check for valid render target + + CD3D8Texture* tex = (CD3D8Texture*)texture; + + if (texture && !tex->isRenderTarget()) + { + os::Printer::log("Fatal Error: Tried to set a non render target texture as render target.", ELL_ERROR); + return false; + } + + if (texture && (tex->getSize().Width > ScreenSize.Width || + tex->getSize().Height > ScreenSize.Height )) + { + os::Printer::log("Error: Tried to set a render target texture which is bigger than the screen.", ELL_ERROR); + return false; + } + + // check if we should set the previous RT back + + bool ret = true; + + if (tex == 0) + { + if (PrevRenderTarget) + { + IDirect3DSurface8* dss = 0; + pID3DDevice->GetDepthStencilSurface(&dss); + + if (FAILED(pID3DDevice->SetRenderTarget(PrevRenderTarget, dss))) + { + os::Printer::log("Error: Could not set back to previous render target.", ELL_ERROR); + ret = false; + } + + if (dss) + dss->Release(); + + CurrentRendertargetSize = core::dimension2d(0,0); + PrevRenderTarget->Release(); + PrevRenderTarget = 0; + } + } + else + { + // we want to set a new target. so do this. + + // store previous target + + if (!PrevRenderTarget) + if (FAILED(pID3DDevice->GetRenderTarget(&PrevRenderTarget))) + { + os::Printer::log("Could not get previous render target.", ELL_ERROR); + return false; + } + + // set new render target + + IDirect3DSurface8* dss = 0; + pID3DDevice->GetDepthStencilSurface(&dss); + + if (FAILED(pID3DDevice->SetRenderTarget(tex->getRenderTargetSurface(), dss))) + { + os::Printer::log("Error: Could not set render target.", ELL_ERROR); + ret = false; + } + + if (dss) + dss->Release(); + + CurrentRendertargetSize = tex->getSize(); + } + + if (clearBackBuffer || clearZBuffer) + { + DWORD flags = 0; + + if (clearBackBuffer) + flags |= D3DCLEAR_TARGET; + + if (clearZBuffer) + flags |= D3DCLEAR_ZBUFFER; + + pID3DDevice->Clear(0, NULL, flags, color.color, 1.0f, 0); + } + + return ret; +} + +//! Creates a render target texture. +ITexture* CD3D8Driver::createRenderTargetTexture(const core::dimension2d& size) +{ + return new CD3D8Texture(this, size, 0); +} + + + +//! sets a viewport +void CD3D8Driver::setViewPort(const core::rect& area) +{ + core::rect vp(area); + core::rect rendert(0,0, ScreenSize.Width, ScreenSize.Height); + vp.clipAgainst(rendert); + + D3DVIEWPORT8 viewPort; + viewPort.X = vp.UpperLeftCorner.X; + viewPort.Y = vp.UpperLeftCorner.Y; + viewPort.Width = vp.getWidth(); + viewPort.Height = vp.getHeight(); + viewPort.MinZ = 0.0f; + viewPort.MaxZ = 1.0f; + + HRESULT hr = D3DERR_INVALIDCALL; + if (vp.getHeight()>0 && vp.getWidth()>0) + hr = pID3DDevice->SetViewport(&viewPort); + + if (FAILED(hr)) + os::Printer::log("Failed setting the viewport.", ELL_WARNING); + + ViewPort = vp; +} + + + +//! gets the area of the current viewport +const core::rect& CD3D8Driver::getViewPort() const +{ + return ViewPort; +} + + + +//! draws a vertex primitive list +void CD3D8Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) +{ + if (!checkPrimitiveCount(primitiveCount)) + return; + + CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType); + + if (!vertexCount || !primitiveCount) + return; + + setVertexShader(vType); + + size_t stride=0; + switch (vType) + { + case EVT_STANDARD: + stride=sizeof(S3DVertex); + break; + case EVT_2TCOORDS: + stride=sizeof(S3DVertex2TCoords); + break; + case EVT_TANGENTS: + stride=sizeof(S3DVertexTangents); + break; + } + if (setRenderStates3DMode()) + { + switch (pType) + { + case scene::EPT_POINTS: + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_POINTLIST, 0, vertexCount, + primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); + break; + case scene::EPT_LINE_STRIP: + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount, + primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); + break; + case scene::EPT_LINE_LOOP: + { + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount, + primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); + u16 tmpIndices[] = {0, primitiveCount}; + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, + 1, tmpIndices, D3DFMT_INDEX16, vertices, stride); + } + break; + case scene::EPT_LINES: + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, + primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); + break; + case scene::EPT_TRIANGLE_STRIP: + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount, + primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); + break; + case scene::EPT_TRIANGLE_FAN: + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount, + primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); + break; + case scene::EPT_TRIANGLES: + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vertexCount, + primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); + break; + } + } +} + + + +//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. +void CD3D8Driver::draw2DImage(video::ITexture* texture, const core::position2d& pos, + const core::rect& sourceRect, + const core::rect* clipRect, SColor color, + bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + if (!sourceRect.isValid()) + return; + + if (!setTexture(0, texture)) + return; + + core::position2d targetPos = pos; + core::position2d sourcePos = sourceRect.UpperLeftCorner; + core::dimension2d sourceSize(sourceRect.getSize()); + const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); + + if (clipRect) + { + if (targetPos.X < clipRect->UpperLeftCorner.X) + { + sourceSize.Width += targetPos.X - clipRect->UpperLeftCorner.X; + if (sourceSize.Width <= 0) + return; + + sourcePos.X -= targetPos.X - clipRect->UpperLeftCorner.X; + targetPos.X = clipRect->UpperLeftCorner.X; + } + + if (targetPos.X + sourceSize.Width > clipRect->LowerRightCorner.X) + { + sourceSize.Width -= (targetPos.X + sourceSize.Width) - clipRect->LowerRightCorner.X; + if (sourceSize.Width <= 0) + return; + } + + if (targetPos.Y < clipRect->UpperLeftCorner.Y) + { + sourceSize.Height += targetPos.Y - clipRect->UpperLeftCorner.Y; + if (sourceSize.Height <= 0) + return; + + sourcePos.Y -= targetPos.Y - clipRect->UpperLeftCorner.Y; + targetPos.Y = clipRect->UpperLeftCorner.Y; + } + + if (targetPos.Y + sourceSize.Height > clipRect->LowerRightCorner.Y) + { + sourceSize.Height -= (targetPos.Y + sourceSize.Height) - clipRect->LowerRightCorner.Y; + if (sourceSize.Height <= 0) + return; + } + } + + // clip these coordinates + + if (targetPos.X<0) + { + sourceSize.Width += targetPos.X; + if (sourceSize.Width <= 0) + return; + + sourcePos.X -= targetPos.X; + targetPos.X = 0; + } + + if (targetPos.X + sourceSize.Width > renderTargetSize.Width) + { + sourceSize.Width -= (targetPos.X + sourceSize.Width) - renderTargetSize.Width; + if (sourceSize.Width <= 0) + return; + } + + if (targetPos.Y<0) + { + sourceSize.Height += targetPos.Y; + if (sourceSize.Height <= 0) + return; + + sourcePos.Y -= targetPos.Y; + targetPos.Y = 0; + } + + if (targetPos.Y + sourceSize.Height > renderTargetSize.Height) + { + sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height; + if (sourceSize.Height <= 0) + return; + } + + // ok, we've clipped everything. + // now draw it. + + s32 xPlus = -(renderTargetSize.Width>>1); + f32 xFact = 1.0f / (renderTargetSize.Width>>1); + + s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); + f32 yFact = 1.0f / (renderTargetSize.Height>>1); + + const core::dimension2d sourceSurfaceSize = texture->getOriginalSize(); + core::rect tcoords; + tcoords.UpperLeftCorner.X = (((f32)sourcePos.X)+0.5f) / texture->getOriginalSize().Width ; + tcoords.UpperLeftCorner.Y = (((f32)sourcePos.Y)+0.5f) / texture->getOriginalSize().Height; + tcoords.LowerRightCorner.X = (((f32)sourcePos.X +0.5f + (f32)sourceSize.Width)) / texture->getOriginalSize().Width; + tcoords.LowerRightCorner.Y = (((f32)sourcePos.Y +0.5f + (f32)sourceSize.Height)) / texture->getOriginalSize().Height; + + core::rect poss(targetPos, sourceSize); + + setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); + + S3DVertex vtx[4]; + vtx[0] = S3DVertex((f32)(poss.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-poss.UpperLeftCorner.Y ) * yFact , 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); + vtx[1] = S3DVertex((f32)(poss.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus- poss.UpperLeftCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); + vtx[2] = S3DVertex((f32)(poss.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus-poss.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); + vtx[3] = S3DVertex((f32)(poss.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-poss.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); + + s16 indices[6] = {0,1,2,0,2,3}; + + setVertexShader(EVT_STANDARD); + + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], + D3DFMT_INDEX16,&vtx[0], sizeof(S3DVertex)); +} + + + +void CD3D8Driver::draw2DImage(video::ITexture* texture, const core::rect& destRect, + const core::rect& sourceRect, const core::rect* clipRect, + video::SColor* colors, bool useAlphaChannelOfTexture) +{ + if(!texture) + return; + + const core::dimension2d& ss = texture->getOriginalSize(); + core::rect tcoords; + tcoords.UpperLeftCorner.X = (f32)sourceRect.UpperLeftCorner.X / (f32)ss.Width; + tcoords.UpperLeftCorner.Y = (f32)sourceRect.UpperLeftCorner.Y / (f32)ss.Height; + tcoords.LowerRightCorner.X = (f32)sourceRect.LowerRightCorner.X / (f32)ss.Width; + tcoords.LowerRightCorner.Y = (f32)sourceRect.LowerRightCorner.Y / (f32)ss.Height; + + const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); + core::rect npos; + f32 xFact = 2.0f / ( renderTargetSize.Width ); + f32 yFact = 2.0f / ( renderTargetSize.Height ); + npos.UpperLeftCorner.X = ( destRect.UpperLeftCorner.X * xFact ) - 1.0f; + npos.UpperLeftCorner.Y = 1.0f - ( destRect.UpperLeftCorner.Y * yFact ); + npos.LowerRightCorner.X = ( destRect.LowerRightCorner.X * xFact ) - 1.0f; + npos.LowerRightCorner.Y = 1.0f - ( destRect.LowerRightCorner.Y * yFact ); + + video::SColor temp[4] = + { + 0xFFFFFFFF, + 0xFFFFFFFF, + 0xFFFFFFFF, + 0xFFFFFFFF + }; + + video::SColor* useColor = colors ? colors : temp; + + S3DVertex vtx[4]; // clock wise + vtx[0] = S3DVertex(npos.UpperLeftCorner.X, npos.UpperLeftCorner.Y , 0.0f, 0.0f, 0.0f, 0.0f, useColor[0], tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); + vtx[1] = S3DVertex(npos.LowerRightCorner.X, npos.UpperLeftCorner.Y , 0.0f, 0.0f, 0.0f, 0.0f, useColor[3], tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); + vtx[2] = S3DVertex(npos.LowerRightCorner.X, npos.LowerRightCorner.Y, 0.0f, 0.0f, 0.0f, 0.0f, useColor[2], tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); + vtx[3] = S3DVertex(npos.UpperLeftCorner.X, npos.LowerRightCorner.Y, 0.0f, 0.0f, 0.0f, 0.0f, useColor[1], tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); + + s16 indices[6] = {0,1,2,0,2,3}; + + setRenderStates2DMode(useColor[0].getAlpha()<255 || useColor[1].getAlpha()<255 || useColor[2].getAlpha()<255 || useColor[3].getAlpha()<255, true, useAlphaChannelOfTexture); + + setTexture(0, texture); + + setVertexShader(EVT_STANDARD); + + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], + D3DFMT_INDEX16,&vtx[0], sizeof(S3DVertex)); +} + + + +//!Draws an 2d rectangle with a gradient. +void CD3D8Driver::draw2DRectangle(const core::rect& position, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect* clip) +{ + core::rect pos(position); + + if (clip) + pos.clipAgainst(*clip); + + if (!pos.isValid()) + return; + + const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); + s32 xPlus = -(renderTargetSize.Width>>1); + f32 xFact = 1.0f / (renderTargetSize.Width>>1); + + s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); + f32 yFact = 1.0f / (renderTargetSize.Height>>1); + + S3DVertex vtx[4]; + vtx[0] = S3DVertex((f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.UpperLeftCorner.Y) * yFact , 0.0f, 0.0f, 0.0f, 0.0f, colorLeftUp, 0.0f, 0.0f); + vtx[1] = S3DVertex((f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus- pos.UpperLeftCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorRightUp, 0.0f, 1.0f); + vtx[2] = S3DVertex((f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorRightDown, 1.0f, 0.0f); + vtx[3] = S3DVertex((f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorLeftDown, 1.0f, 1.0f); + + s16 indices[6] = {0,1,2,0,2,3}; + + setRenderStates2DMode( + colorLeftUp.getAlpha() < 255 || + colorRightUp.getAlpha() < 255 || + colorLeftDown.getAlpha() < 255 || + colorRightDown.getAlpha() < 255, false, false); + + setTexture(0,0); + + setVertexShader(EVT_STANDARD); + + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], + D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); + +} + + + +//! Draws a 2d line. +void CD3D8Driver::draw2DLine(const core::position2d& start, + const core::position2d& end, + SColor color) +{ + // thanks to Vash TheStampede who sent in his implementation + + const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); + const s32 xPlus = -(renderTargetSize.Width>>1); + const f32 xFact = 1.0f / (renderTargetSize.Width>>1); + + const s32 yPlus = + renderTargetSize.Height-(renderTargetSize.Height>>1); + const f32 yFact = 1.0f / (renderTargetSize.Height>>1); + + S3DVertex vtx[2]; + vtx[0] = S3DVertex((f32)(start.X + xPlus) * xFact, + (f32)(yPlus - start.Y) * yFact, + 0.0f, // z + 0.0f, 0.0f, 0.0f, // normal + color, + 0.0f, 0.0f); // texture + + vtx[1] = S3DVertex((f32)(end.X+xPlus) * xFact, + (f32)(yPlus- end.Y) * yFact, + 0.0f, + 0.0f, 0.0f, 0.0f, + color, + 0.0f, 0.0f); + + setRenderStates2DMode(color.getAlpha() < 255, false, false); + setTexture(0,0); + + setVertexShader(EVT_STANDARD); + + pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, &vtx[0], sizeof(S3DVertex)); +} + + + +//! sets right vertex shader +void CD3D8Driver::setVertexShader(E_VERTEX_TYPE newType) +{ + // Because we don't know if a vertex shader was set in a material instead of a + // fvf, this call cannot be prevented in D3D8. + //if (newType != LastVertexType) + { + LastVertexType = newType; + HRESULT hr = 0; + + switch(newType) + { + case EVT_STANDARD: + hr = pID3DDevice->SetVertexShader(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1); + break; + case EVT_2TCOORDS: + hr = pID3DDevice->SetVertexShader(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX2); + break; + case EVT_TANGENTS: + hr = pID3DDevice->SetVertexShader(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX3 | + D3DFVF_TEXCOORDSIZE2(0) | // real texture coord + D3DFVF_TEXCOORDSIZE3(1) | // misuse texture coord 2 for tangent + D3DFVF_TEXCOORDSIZE3(2) // misuse texture coord 3 for binormal + ); + break; + } + + if (FAILED(hr)) + { + os::Printer::log("Could not set vertex Shader.", ELL_ERROR); + return; + } + } +} + + +//! sets the needed renderstates +bool CD3D8Driver::setRenderStates3DMode() +{ + if (!pID3DDevice) + return false; + + if (CurrentRenderMode != ERM_3D) + { + // switch back the matrices + pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&Matrices[ETS_VIEW])); + pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&Matrices[ETS_WORLD])); + pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&Matrices[ETS_PROJECTION])); + + pID3DDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE); + + ResetRenderStates = true; + } + + if (ResetRenderStates || LastMaterial != Material) + { + // unset old material + + if (CurrentRenderMode == ERM_3D && + LastMaterial.MaterialType != Material.MaterialType && + LastMaterial.MaterialType >= 0 && LastMaterial.MaterialType < (s32)MaterialRenderers.size()) + MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); + + // set new material. + + if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial( + Material, LastMaterial, ResetRenderStates, this); + } + + bool shaderOK = true; + + if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) + shaderOK = MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, LastVertexType); + + LastMaterial = Material; + + ResetRenderStates = false; + + CurrentRenderMode = ERM_3D; + + return shaderOK; +} + + +//! Can be called by an IMaterialRenderer to make its work easier. +void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, + bool resetAllRenderstates) +{ + if (resetAllRenderstates || + lastmaterial.AmbientColor != material.AmbientColor || + lastmaterial.DiffuseColor != material.DiffuseColor || + lastmaterial.SpecularColor != material.SpecularColor || + lastmaterial.EmissiveColor != material.EmissiveColor || + lastmaterial.Shininess != material.Shininess) + { + D3DMATERIAL8 mat; + mat.Diffuse = colorToD3D(material.DiffuseColor); + mat.Ambient = colorToD3D(material.AmbientColor); + mat.Specular = colorToD3D(material.SpecularColor); + mat.Emissive = colorToD3D(material.EmissiveColor); + mat.Power = material.Shininess; + pID3DDevice->SetMaterial(&mat); + } + + // Bilinear and/or trilinear + if (resetAllRenderstates || + lastmaterial.BilinearFilter != material.BilinearFilter || + lastmaterial.TrilinearFilter != material.TrilinearFilter || + lastmaterial.AnisotropicFilter != material.AnisotropicFilter ) + { + if (material.BilinearFilter || material.TrilinearFilter || material.AnisotropicFilter) + { + D3DTEXTUREFILTERTYPE tftMag = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) && material.AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; + D3DTEXTUREFILTERTYPE tftMin = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) && material.AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; + D3DTEXTUREFILTERTYPE tftMip = material.TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT; + + for (u32 st=0; stSetTextureStageState(st, D3DTSS_MAGFILTER, tftMag); + pID3DDevice->SetTextureStageState(st, D3DTSS_MINFILTER, tftMin); + pID3DDevice->SetTextureStageState(st, D3DTSS_MIPFILTER, tftMip); + } + } + else + { + for (u32 st=0; stSetTextureStageState(st, D3DTSS_MINFILTER, D3DTEXF_POINT); + pID3DDevice->SetTextureStageState(st, D3DTSS_MIPFILTER, D3DTEXF_NONE); + pID3DDevice->SetTextureStageState(st, D3DTSS_MAGFILTER, D3DTEXF_POINT); + } + } + } + + // fillmode + if (resetAllRenderstates || lastmaterial.Wireframe != material.Wireframe || lastmaterial.PointCloud != material.PointCloud) + { + if (material.Wireframe) + pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); + else + if (material.PointCloud) + pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_POINT); + else + pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); + } + + // shademode + + if (resetAllRenderstates || lastmaterial.GouraudShading != material.GouraudShading) + { + if (material.GouraudShading) + pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); + else + pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); + } + + // lighting + + if (resetAllRenderstates || lastmaterial.Lighting != material.Lighting) + { + if (material.Lighting) + pID3DDevice->SetRenderState(D3DRS_LIGHTING, TRUE); + else + pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); + } + + + // zbuffer + + if (resetAllRenderstates || lastmaterial.ZBuffer != material.ZBuffer) + { + switch (material.ZBuffer) + { + case 0: + pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); + break; + case 1: + pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); + break; + case 2: + pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL); + break; + } + } + + + // zwrite + if (resetAllRenderstates || lastmaterial.ZWriteEnable != material.ZWriteEnable) + { + if (material.ZWriteEnable) + pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE); + else + pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE); + } + + // back face culling + + + if (resetAllRenderstates || lastmaterial.BackfaceCulling != material.BackfaceCulling) + { + if (material.BackfaceCulling) + pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW); + else + pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE); + } + + // fog + if (resetAllRenderstates || lastmaterial.FogEnable != material.FogEnable) + { + pID3DDevice->SetRenderState(D3DRS_FOGENABLE, material.FogEnable); + } + + // specular highlights + if (resetAllRenderstates || !core::equals(lastmaterial.Shininess, material.Shininess)) + { + bool enable = (material.Shininess!=0); + pID3DDevice->SetRenderState(D3DRS_SPECULARENABLE, enable); + pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, enable); + pID3DDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL); + } + + // normalization + if (resetAllRenderstates || lastmaterial.NormalizeNormals != material.NormalizeNormals) + { + pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, material.NormalizeNormals); + } + + // texture address mode + for (u32 st=0; stSetTextureStageState(st, D3DTSS_ADDRESSU, mode ); + pID3DDevice->SetTextureStageState(st, D3DTSS_ADDRESSV, mode ); + } + + } + + +} + + + +//! sets the needed renderstates +void CD3D8Driver::setRenderStatesStencilShadowMode(bool zfail) +{ + if ((CurrentRenderMode != ERM_SHADOW_VOLUME_ZFAIL && + CurrentRenderMode != ERM_SHADOW_VOLUME_ZPASS) || + Transformation3DChanged) + { + // switch back the matrices + pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&Matrices[ETS_VIEW])); + pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&Matrices[ETS_WORLD])); + pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&Matrices[ETS_PROJECTION])); + + Transformation3DChanged = false; + + setTexture(0,0); + setTexture(1,0); + setTexture(2,0); + setTexture(3,0); + + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetVertexShader(D3DFVF_XYZ); + LastVertexType = (video::E_VERTEX_TYPE)(-1); + + pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE ); + pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE ); + pID3DDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT); + + //pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); + //pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); + + // unset last 3d material + if (CurrentRenderMode == ERM_3D && + Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); + } + + if (CurrentRenderMode != ERM_SHADOW_VOLUME_ZPASS && !zfail) + { + // USE THE ZPASS METHOD + + pID3DDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS ); + pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); + pID3DDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP ); + + pID3DDevice->SetRenderState( D3DRS_STENCILREF, 0x1 ); + pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); + pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); + + pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO ); + pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); + } + else + if (CurrentRenderMode != ERM_SHADOW_VOLUME_ZFAIL && zfail) + { + // USE THE ZFAIL METHOD + + pID3DDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS ); + pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); + pID3DDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP ); + pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_KEEP ); + + pID3DDevice->SetRenderState( D3DRS_STENCILREF, 0x0 ); + pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); + pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); + + pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); + pID3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO ); + pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); + } + + CurrentRenderMode = zfail ? ERM_SHADOW_VOLUME_ZFAIL : ERM_SHADOW_VOLUME_ZPASS; +} + + + +//! sets the needed renderstates +void CD3D8Driver::setRenderStatesStencilFillMode(bool alpha) +{ + if (CurrentRenderMode != ERM_STENCIL_FILL || Transformation3DChanged) + { + core::matrix4 mat; + pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); + pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); + pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); + + pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); + pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); + pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetRenderState(D3DRS_STENCILREF, 0x1 ); + pID3DDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_LESSEQUAL); + //pID3DDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_GREATEREQUAL); + pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_KEEP ); + pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); + pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); + pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); + + pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW); + + Transformation3DChanged = false; + + if (alpha) + { + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE ); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); + } + else + { + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + } + } + + CurrentRenderMode = ERM_STENCIL_FILL; +} + + + +//! sets the needed renderstates +void CD3D8Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) +{ + if (!pID3DDevice) + return; + + if (CurrentRenderMode != ERM_2D || Transformation3DChanged) + { + core::matrix4 mat; + pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); + pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); + pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); + + pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); + //pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); + pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); + pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); + pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); + pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); + pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); + + pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE ); + + pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW); + + pID3DDevice->SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP ); + pID3DDevice->SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP ); + pID3DDevice->SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP ); + pID3DDevice->SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP ); + pID3DDevice->SetTextureStageState(2, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP ); + pID3DDevice->SetTextureStageState(2, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP ); + pID3DDevice->SetTextureStageState(3, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP ); + pID3DDevice->SetTextureStageState(3, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP ); + + pID3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0); + pID3DDevice->SetTransform( D3DTS_TEXTURE0, &UnitMatrixD3D8 ); + + Transformation3DChanged = false; + + // unset last 3d material + if (CurrentRenderMode == ERM_3D && + Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); + } + + if (texture) + { + pID3DDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_POINT); + pID3DDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_NONE); + pID3DDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_POINT); + + if (alphaChannel) + { + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + + if (alpha) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); + } + else + { + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + } + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + } + else + { + if (alpha) + { + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); + } + else + { + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + } + } + } + else + { + if (alpha) + { + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE ); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); + } + else + { + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + } + } + + CurrentRenderMode = ERM_2D; +} + + +//! deletes all dynamic lights there are +void CD3D8Driver::deleteAllDynamicLights() +{ + for (s32 i=0; iLightEnable(i, false); + + LastSetLight = -1; + + CNullDriver::deleteAllDynamicLights(); +} + + + +//! adds a dynamic light +void CD3D8Driver::addDynamicLight(const SLight& dl) +{ + if ((u32)LastSetLight == Caps.MaxActiveLights-1) + return; + + CNullDriver::addDynamicLight(dl); + + D3DLIGHT8 light; + + if ( dl.Type == ELT_POINT ) + { + light.Type = D3DLIGHT_POINT; + light.Position = *(D3DVECTOR*)((void*)(&dl.Position)); + } + else + if ( dl.Type == ELT_DIRECTIONAL ) + { + light.Type = D3DLIGHT_DIRECTIONAL; + light.Direction = *(D3DVECTOR*)((void*)(&dl.Position)); + } + + light.Diffuse = *(D3DCOLORVALUE*)((void*)(&dl.DiffuseColor)); + light.Specular = *(D3DCOLORVALUE*)((void*)(&dl.SpecularColor)); + light.Ambient = *(D3DCOLORVALUE*)((void*)(&dl.AmbientColor)); + light.Range = MaxLightDistance; + + light.Attenuation0 = 0.0f; + light.Attenuation1 = 1.0f / dl.Radius; + light.Attenuation2 = 0.0f; + + ++LastSetLight; + pID3DDevice->SetLight(LastSetLight, &light); + pID3DDevice->LightEnable(LastSetLight, true); +} + + + +//! returns the maximal amount of dynamic lights the device can handle +u32 CD3D8Driver::getMaximalDynamicLightAmount() +{ + return Caps.MaxActiveLights; +} + + + +//! Sets the dynamic ambient light color. The default color is +//! (0,0,0,0) which means it is dark. +//! \param color: New color of the ambient light. +void CD3D8Driver::setAmbientLight(const SColorf& color) +{ + if (!pID3DDevice) + return; + + AmbientLight = color; + D3DCOLOR col = color.toSColor().color; + pID3DDevice->SetRenderState(D3DRS_AMBIENT, col); +} + + + +//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 +//! driver, it would return "Direct3D8.1". +const wchar_t* CD3D8Driver::getName() +{ + return L"Direct3D 8.1"; +} + + + +//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do +//! this: Frist, draw all geometry. Then use this method, to draw the shadow +//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. +void CD3D8Driver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail) +{ + if (!StencilBuffer || !count) + return; + + setRenderStatesStencilShadowMode(zfail); + + if (!zfail) + { + // ZPASS Method + + // Draw front-side of shadow volume in stencil/z only + pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW ); + pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_INCRSAT); + pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); + + // Now reverse cull order so front sides of shadow volume are written. + pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW ); + pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_DECRSAT); + pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); + } + else + { + // ZFAIL Method + + // Draw front-side of shadow volume in stencil/z only + pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW ); + pID3DDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_INCRSAT ); + pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); + + // Now reverse cull order so front sides of shadow volume are written. + pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); + pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_DECRSAT ); + pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); + } +} + + + +//! Fills the stencil shadow with color. After the shadow volume has been drawn +//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this +//! to draw the color of the shadow. +void CD3D8Driver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge, + video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge) +{ + if (!StencilBuffer) + return; + + S3DVertex vtx[4]; + vtx[0] = S3DVertex(1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftUpEdge, 0.0f, 0.0f); + vtx[1] = S3DVertex(1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightUpEdge, 0.0f, 1.0f); + vtx[2] = S3DVertex(-1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftDownEdge, 1.0f, 0.0f); + vtx[3] = S3DVertex(-1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightDownEdge, 1.0f, 1.0f); + + s16 indices[6] = {0,1,2,1,3,2}; + + setRenderStatesStencilFillMode( + leftUpEdge.getAlpha() < 255 || + rightUpEdge.getAlpha() < 255 || + leftDownEdge.getAlpha() < 255 || + rightDownEdge.getAlpha() < 255); + + setTexture(0,0); + + setVertexShader(EVT_STANDARD); + + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], + D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); + + if (clearStencilBuffer) + pID3DDevice->Clear( 0, NULL, D3DCLEAR_STENCIL,0, 1.0, 0); +} + + + +//! Returns the maximum amount of primitives (mostly vertices) which +//! the device is able to render with one drawIndexedTriangleList +//! call. +u32 CD3D8Driver::getMaximalPrimitiveCount() +{ + return Caps.MaxPrimitiveCount; +} + + +//! Sets the fog mode. +void CD3D8Driver::setFog(SColor color, bool linearFog, f32 start, + f32 end, f32 density, bool pixelFog, bool rangeFog) +{ + CNullDriver::setFog(color, linearFog, start, end, density, pixelFog, rangeFog); + + if (!pID3DDevice) + return; + + pID3DDevice->SetRenderState(D3DRS_FOGCOLOR, color.color); + + pID3DDevice->SetRenderState( + pixelFog ? D3DRS_FOGTABLEMODE : D3DRS_FOGVERTEXMODE, + linearFog ? D3DFOG_LINEAR : D3DFOG_EXP); + + if(linearFog) + { + pID3DDevice->SetRenderState(D3DRS_FOGSTART, *(DWORD*)(&start)); + pID3DDevice->SetRenderState(D3DRS_FOGEND, *(DWORD*)(&end)); + } + else + pID3DDevice->SetRenderState(D3DRS_FOGDENSITY, *(DWORD*)(&density)); + + if(!pixelFog) + pID3DDevice->SetRenderState (D3DRS_RANGEFOGENABLE, rangeFog); +} + +//! Draws a 3d line. +void CD3D8Driver::draw3DLine(const core::vector3df& start, + const core::vector3df& end, SColor color) +{ + setVertexShader(EVT_STANDARD); + setRenderStates3DMode(); + video::S3DVertex v[2]; + v[0].Color = color; + v[1].Color = color; + v[0].Pos = start; + v[1].Pos = end; + + pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, v, sizeof(S3DVertex)); +} + + +void CD3D8Driver::OnResize(const core::dimension2d& size) +{ + if (!pID3DDevice) + return; + + CNullDriver::OnResize(size); + reset(); +} + +//! Returns type of video driver +E_DRIVER_TYPE CD3D8Driver::getDriverType() +{ + return EDT_DIRECT3D8; +} + +//! Returns the transformation set by setTransform +const core::matrix4& CD3D8Driver::getTransform(E_TRANSFORMATION_STATE state) +{ + return Matrices[state]; +} + +//! Sets a vertex shader constant. +void CD3D8Driver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) +{ + if (data) + pID3DDevice->SetVertexShaderConstant(startRegister, data, constantAmount); +} + +//! Sets a pixel shader constant. +void CD3D8Driver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) +{ + if (data) + pID3DDevice->SetPixelShaderConstant(startRegister, data, constantAmount); +} + +//! Sets a constant for the vertex shader based on a name. +bool CD3D8Driver::setVertexShaderConstant(const c8* name, const f32* floats, int count) +{ + os::Printer::log("Cannot set constant, no HLSL supported in D3D8"); + return false; +} + +//! Sets a constant for the pixel shader based on a name. +bool CD3D8Driver::setPixelShaderConstant(const c8* name, const f32* floats, int count) +{ + os::Printer::log("Cannot set constant, no HLSL supported in D3D8"); + return false; +} + +//! Returns pointer to the IGPUProgrammingServices interface. +IGPUProgrammingServices* CD3D8Driver::getGPUProgrammingServices() +{ + return this; +} + + +//! Adds a new material renderer to the VideoDriver, using pixel and/or +//! vertex shaders to render geometry. +s32 CD3D8Driver::addShaderMaterial(const c8* vertexShaderProgram, + const c8* pixelShaderProgram, + IShaderConstantSetCallBack* callback, + E_MATERIAL_TYPE baseMaterial, s32 userData) +{ + s32 nr = -1; + CD3D8ShaderMaterialRenderer* r = new CD3D8ShaderMaterialRenderer( + pID3DDevice, this, nr, vertexShaderProgram, pixelShaderProgram, + callback, getMaterialRenderer(baseMaterial), userData); + + r->drop(); + return nr; +} + + +//! Returns a pointer to the IVideoDriver interface. (Implementation for +//! IMaterialRendererServices) +IVideoDriver* CD3D8Driver::getVideoDriver() +{ + return this; +} + + + +//! Clears the ZBuffer. +void CD3D8Driver::clearZBuffer() +{ + HRESULT hr = pID3DDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0, 0); + + if (FAILED(hr)) + os::Printer::log("CD3D8Driver clearZBuffer() failed.", ELL_WARNING); +} + +//! Returns an image created from the last rendered frame. +IImage* CD3D8Driver::createScreenShot() +{ + HRESULT hr; + + // query the screen dimensions of the current adapter + D3DDISPLAYMODE displayMode; + pID3DDevice->GetDisplayMode(&displayMode); + + // create the image surface to store the front buffer image [always A8R8G8B8] + LPDIRECT3DSURFACE8 lpSurface; + if (FAILED(hr = pID3DDevice->CreateImageSurface(displayMode.Width, displayMode.Height, D3DFMT_A8R8G8B8, &lpSurface))) + return 0; + + // read the front buffer into the image surface + if (FAILED(hr = pID3DDevice->GetFrontBuffer(lpSurface))) + { + lpSurface->Release(); + return 0; + } + + RECT clientRect; + { + POINT clientPoint; + clientPoint.x = 0; + clientPoint.y = 0; + + ClientToScreen( (HWND)getExposedVideoData().D3D8.HWnd, &clientPoint ); + + clientRect.left = clientPoint.x; + clientRect.top = clientPoint.y; + clientRect.right = clientRect.left + ScreenSize.Width; + clientRect.bottom = clientRect.top + ScreenSize.Height; + } + + // lock our area of the surface + D3DLOCKED_RECT lockedRect; + if (FAILED(lpSurface->LockRect(&lockedRect, &clientRect, D3DLOCK_READONLY))) + { + lpSurface->Release(); + return 0; + } + + // this could throw, but we aren't going to worry about that case very much + IImage* newImage = new CImage(ECF_A8R8G8B8, ScreenSize); + + // d3d pads the image, so we need to copy the correct number of bytes + u32* pPixels = (u32*)newImage->lock(); + if (pPixels) + { + u8 * sP = (u8 *)lockedRect.pBits; + u32* dP = (u32*)pPixels; + + for (s32 y = 0; y < ScreenSize.Height; ++y) + { + memcpy(dP, sP, ScreenSize.Width * 4); + + sP += lockedRect.Pitch; + dP += ScreenSize.Width; + } + + newImage->unlock(); + } + + // we can unlock and release the surface + lpSurface->UnlockRect(); + + // release the image surface + lpSurface->Release(); + + // return status of save operation to caller + return newImage; +} + + + +// returns the current size of the screen or rendertarget +core::dimension2d CD3D8Driver::getCurrentRenderTargetSize() +{ + if ( CurrentRendertargetSize.Width == 0 ) + return ScreenSize; + else + return CurrentRendertargetSize; +} + + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ +#endif // _IRR_WINDOWS_ + + + + +namespace irr +{ +namespace video +{ + +#ifdef _IRR_WINDOWS_ +//! creates a video driver +IVideoDriver* createDirectX8Driver(const core::dimension2d& screenSize, HWND window, + u32 bits, bool fullscreen, bool stencilbuffer, + io::IFileSystem* io, bool pureSoftware, bool highPrecisionFPU, + bool vsync, bool antiAlias) +{ + #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ + CD3D8Driver* dx8 = new CD3D8Driver(screenSize, window, fullscreen, + stencilbuffer, io, pureSoftware); + + if (!dx8->initDriver(screenSize, window, bits, fullscreen, + pureSoftware, highPrecisionFPU, vsync, antiAlias)) + { + dx8->drop(); + dx8 = 0; + } + + return dx8; + + #else + + return 0; + + #endif // _IRR_COMPILE_WITH_DIRECT3D_8_ +} +#endif + +} // end namespace video +} // end namespace irr + + + + diff --git a/src/dep/src/irrlicht/CD3D8Driver.h b/src/dep/src/irrlicht/CD3D8Driver.h index bc63851..0c8e4a4 100644 --- a/src/dep/src/irrlicht/CD3D8Driver.h +++ b/src/dep/src/irrlicht/CD3D8Driver.h @@ -1,284 +1,284 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_VIDEO_DIRECTX_8_H_INCLUDED__ -#define __C_VIDEO_DIRECTX_8_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#if defined(_IRR_WINDOWS_) || defined(_XBOX) - -#ifdef _IRR_WINDOWS_ - #define WIN32_LEAN_AND_MEAN - #include "CNullDriver.h" - #include "IMaterialRendererServices.h" - #include -#endif - -#ifdef _XBOX - #include -#endif - - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ -#include "d3d8.h" - -namespace irr -{ -namespace video -{ - class CD3D8Driver : public CNullDriver, IMaterialRendererServices - { - public: - - //! constructor - CD3D8Driver(const core::dimension2d& screenSize, HWND window, bool fullscreen, - bool stencibuffer, io::IFileSystem* io, bool pureSoftware=false, bool vsync=false); - - //! destructor - virtual ~CD3D8Driver(); - - //! applications must call this method before performing any rendering. returns false if failed. - virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color); - - //! applications must call this method after performing any rendering. returns false if failed. - virtual bool endScene( s32 windowId, core::rect* sourceRect=0 ); - - //! queries the features of the driver, returns true if feature is available - virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature); - - //! sets transformation - virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); - - //! sets a material - virtual void setMaterial(const SMaterial& material); - - //! sets a render target - virtual bool setRenderTarget(video::ITexture* texture, - bool clearBackBuffer=false, bool clearZBuffer=false, - SColor color=video::SColor(0,0,0,0)); - - //! sets a viewport - virtual void setViewPort(const core::rect& area); - - //! gets the area of the current viewport - virtual const core::rect& getViewPort() const; - - //! draws a vertex primitive list - void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); - - //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. - virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos, - const core::rect& sourceRect, const core::rect* clipRect = 0, - SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); - - //! Draws a part of the texture into the rectangle. - virtual void draw2DImage(video::ITexture* texture, const core::rect& destRect, - const core::rect& sourceRect, const core::rect* clipRect = 0, - video::SColor* colors=0, bool useAlphaChannelOfTexture=false); - - //!Draws an 2d rectangle with a gradient. - virtual void draw2DRectangle(const core::rect& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect* clip = 0); - - //! Draws a 2d line. - virtual void draw2DLine(const core::position2d& start, - const core::position2d& end, - SColor color=SColor(255,255,255,255)); - - //! Draws a 3d line. - virtual void draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color = SColor(255,255,255,255)); - - //! initialises the Direct3D API - bool initDriver(const core::dimension2d& screenSize, HWND hwnd, - u32 bits, bool fullScreen, bool pureSoftware, - bool highPrecisionFPU, bool vsync, bool antiAlias); - - //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 - //! driver, it would return "Direct3D8.1". - virtual const wchar_t* getName(); - - //! deletes all dynamic lights there are - virtual void deleteAllDynamicLights(); - - //! adds a dynamic light - virtual void addDynamicLight(const SLight& light); - - //! returns the maximal amount of dynamic lights the device can handle - virtual u32 getMaximalDynamicLightAmount(); - - //! Sets the dynamic ambient light color. The default color is - //! (0,0,0,0) which means it is dark. - //! \param color: New color of the ambient light. - virtual void setAmbientLight(const SColorf& color); - - //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do - //! this: Frist, draw all geometry. Then use this method, to draw the shadow - //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. - virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail); - - //! Fills the stencil shadow with color. After the shadow volume has been drawn - //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this - //! to draw the color of the shadow. - virtual void drawStencilShadow(bool clearStencilBuffer=false, - video::SColor leftUpEdge = video::SColor(0,0,0,0), - video::SColor rightUpEdge = video::SColor(0,0,0,0), - video::SColor leftDownEdge = video::SColor(0,0,0,0), - video::SColor rightDownEdge = video::SColor(0,0,0,0)); - - //! Returns the maximum amount of primitives (mostly vertices) which - //! the device is able to render with one drawIndexedTriangleList - //! call. - virtual u32 getMaximalPrimitiveCount(); - - //! Enables or disables a texture creation flag. - virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled); - - //! Sets the fog mode. - virtual void setFog(SColor color, bool linearFog, f32 start, - f32 end, f32 density, bool pixelFog, bool rangeFog); - - //! Only used by the internal engine. Used to notify the driver that - //! the window was resized. - virtual void OnResize(const core::dimension2d& size); - - //! Returns type of video driver - virtual E_DRIVER_TYPE getDriverType(); - - //! Returns the transformation set by setTransform - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state); - - //! Can be called by an IMaterialRenderer to make its work easier. - virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates); - - //! Sets a vertex shader constant. - virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - - //! Sets a pixel shader constant. - virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - - //! Sets a constant for the vertex shader based on a name. - virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); - - //! Sets a constant for the pixel shader based on a name. - virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); - - //! Returns pointer to the IGPUProgrammingServices interface. - virtual IGPUProgrammingServices* getGPUProgrammingServices(); - - //! Returns a pointer to the IVideoDriver interface. (Implementation for - //! IMaterialRendererServices) - virtual IVideoDriver* getVideoDriver(); - - //! Creates a render target texture. - virtual ITexture* createRenderTargetTexture(const core::dimension2d& size); - - //! Clears the ZBuffer. - virtual void clearZBuffer(); - - //! Returns an image created from the last rendered frame. - virtual IImage* createScreenShot(); - - private: - - // enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. - enum E_RENDER_MODE - { - ERM_NONE = 0, // no render state has been set yet. - ERM_2D, // 2d drawing rendermode - ERM_3D, // 3d rendering mode - ERM_STENCIL_FILL, // stencil fill mode - ERM_SHADOW_VOLUME_ZFAIL, // stencil volume draw mode - ERM_SHADOW_VOLUME_ZPASS // stencil volume draw mode - }; - - //! sets right vertex shader - void setVertexShader(video::E_VERTEX_TYPE newType); - - //! sets the needed renderstates - bool setRenderStates3DMode(); - - //! sets the needed renderstates - void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); - - //! sets the needed renderstates - void setRenderStatesStencilFillMode(bool alpha); - - //! sets the needed renderstates - void setRenderStatesStencilShadowMode(bool zfail); - - //! sets the current Texture - bool setTexture(s32 stage, video::ITexture* texture); - - //! resets the device - bool reset(); - - //! returns a device dependent texture from a software surface (IImage) - //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES - virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const char* name); - - // returns the current size of the screen or rendertarget - core::dimension2d getCurrentRenderTargetSize(); - - //! Adds a new material renderer to the VideoDriver, using pixel and/or - //! vertex shaders to render geometry. - s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, s32 userData); - - void createMaterialRenderers(); - - inline D3DCOLORVALUE colorToD3D(const SColor& col) - { - const f32 f = 1.0f / 255.0f; - D3DCOLORVALUE v; - v.r = col.getRed() * f; - v.g = col.getGreen() * f; - v.b = col.getBlue() * f; - v.a = col.getAlpha() * f; - return v; - } - - E_RENDER_MODE CurrentRenderMode; - D3DPRESENT_PARAMETERS present; - - SMaterial Material, LastMaterial; - bool ResetRenderStates; // bool to make all renderstates be reseted if set. - bool Transformation3DChanged; - bool StencilBuffer; - ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES]; - core::matrix4 Matrices[ETS_COUNT]; // matrices of the 3d mode we need to restore when we switch back from the 2d mode. - - HINSTANCE D3DLibrary; - IDirect3D8* pID3D; - IDirect3DDevice8* pID3DDevice; - - IDirect3DSurface8* PrevRenderTarget; - core::dimension2d CurrentRendertargetSize; - - D3DCAPS8 Caps; - - E_VERTEX_TYPE LastVertexType; - - D3DMATRIX UnitMatrix; - - u32 MaxTextureUnits; - f32 MaxLightDistance; - s32 LastSetLight; - bool DeviceLost; - - SColorf AmbientLight; - }; - -} // end namespace video -} // end namespace irr - - -#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ -#endif // _IRR_WINDOWS_ -#endif // __C_VIDEO_DIRECTX_8_H_INCLUDED__ - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_VIDEO_DIRECTX_8_H_INCLUDED__ +#define __C_VIDEO_DIRECTX_8_H_INCLUDED__ + +#include "IrrCompileConfig.h" + +#if defined(_IRR_WINDOWS_) || defined(_XBOX) + +#ifdef _IRR_WINDOWS_ + #define WIN32_LEAN_AND_MEAN + #include "CNullDriver.h" + #include "IMaterialRendererServices.h" + #include +#endif + +#ifdef _XBOX + #include +#endif + + +#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ +#include "d3d8.h" + +namespace irr +{ +namespace video +{ + class CD3D8Driver : public CNullDriver, IMaterialRendererServices + { + public: + + //! constructor + CD3D8Driver(const core::dimension2d& screenSize, HWND window, bool fullscreen, + bool stencibuffer, io::IFileSystem* io, bool pureSoftware=false, bool vsync=false); + + //! destructor + virtual ~CD3D8Driver(); + + //! applications must call this method before performing any rendering. returns false if failed. + virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color); + + //! applications must call this method after performing any rendering. returns false if failed. + virtual bool endScene( s32 windowId, core::rect* sourceRect=0 ); + + //! queries the features of the driver, returns true if feature is available + virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature); + + //! sets transformation + virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); + + //! sets a material + virtual void setMaterial(const SMaterial& material); + + //! sets a render target + virtual bool setRenderTarget(video::ITexture* texture, + bool clearBackBuffer=false, bool clearZBuffer=false, + SColor color=video::SColor(0,0,0,0)); + + //! sets a viewport + virtual void setViewPort(const core::rect& area); + + //! gets the area of the current viewport + virtual const core::rect& getViewPort() const; + + //! draws a vertex primitive list + void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); + + //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. + virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos, + const core::rect& sourceRect, const core::rect* clipRect = 0, + SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); + + //! Draws a part of the texture into the rectangle. + virtual void draw2DImage(video::ITexture* texture, const core::rect& destRect, + const core::rect& sourceRect, const core::rect* clipRect = 0, + video::SColor* colors=0, bool useAlphaChannelOfTexture=false); + + //!Draws an 2d rectangle with a gradient. + virtual void draw2DRectangle(const core::rect& pos, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect* clip = 0); + + //! Draws a 2d line. + virtual void draw2DLine(const core::position2d& start, + const core::position2d& end, + SColor color=SColor(255,255,255,255)); + + //! Draws a 3d line. + virtual void draw3DLine(const core::vector3df& start, + const core::vector3df& end, SColor color = SColor(255,255,255,255)); + + //! initialises the Direct3D API + bool initDriver(const core::dimension2d& screenSize, HWND hwnd, + u32 bits, bool fullScreen, bool pureSoftware, + bool highPrecisionFPU, bool vsync, bool antiAlias); + + //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 + //! driver, it would return "Direct3D8.1". + virtual const wchar_t* getName(); + + //! deletes all dynamic lights there are + virtual void deleteAllDynamicLights(); + + //! adds a dynamic light + virtual void addDynamicLight(const SLight& light); + + //! returns the maximal amount of dynamic lights the device can handle + virtual u32 getMaximalDynamicLightAmount(); + + //! Sets the dynamic ambient light color. The default color is + //! (0,0,0,0) which means it is dark. + //! \param color: New color of the ambient light. + virtual void setAmbientLight(const SColorf& color); + + //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do + //! this: Frist, draw all geometry. Then use this method, to draw the shadow + //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. + virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail); + + //! Fills the stencil shadow with color. After the shadow volume has been drawn + //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this + //! to draw the color of the shadow. + virtual void drawStencilShadow(bool clearStencilBuffer=false, + video::SColor leftUpEdge = video::SColor(0,0,0,0), + video::SColor rightUpEdge = video::SColor(0,0,0,0), + video::SColor leftDownEdge = video::SColor(0,0,0,0), + video::SColor rightDownEdge = video::SColor(0,0,0,0)); + + //! Returns the maximum amount of primitives (mostly vertices) which + //! the device is able to render with one drawIndexedTriangleList + //! call. + virtual u32 getMaximalPrimitiveCount(); + + //! Enables or disables a texture creation flag. + virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled); + + //! Sets the fog mode. + virtual void setFog(SColor color, bool linearFog, f32 start, + f32 end, f32 density, bool pixelFog, bool rangeFog); + + //! Only used by the internal engine. Used to notify the driver that + //! the window was resized. + virtual void OnResize(const core::dimension2d& size); + + //! Returns type of video driver + virtual E_DRIVER_TYPE getDriverType(); + + //! Returns the transformation set by setTransform + virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state); + + //! Can be called by an IMaterialRenderer to make its work easier. + virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates); + + //! Sets a vertex shader constant. + virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); + + //! Sets a pixel shader constant. + virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); + + //! Sets a constant for the vertex shader based on a name. + virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); + + //! Sets a constant for the pixel shader based on a name. + virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); + + //! Returns pointer to the IGPUProgrammingServices interface. + virtual IGPUProgrammingServices* getGPUProgrammingServices(); + + //! Returns a pointer to the IVideoDriver interface. (Implementation for + //! IMaterialRendererServices) + virtual IVideoDriver* getVideoDriver(); + + //! Creates a render target texture. + virtual ITexture* createRenderTargetTexture(const core::dimension2d& size); + + //! Clears the ZBuffer. + virtual void clearZBuffer(); + + //! Returns an image created from the last rendered frame. + virtual IImage* createScreenShot(); + + private: + + // enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. + enum E_RENDER_MODE + { + ERM_NONE = 0, // no render state has been set yet. + ERM_2D, // 2d drawing rendermode + ERM_3D, // 3d rendering mode + ERM_STENCIL_FILL, // stencil fill mode + ERM_SHADOW_VOLUME_ZFAIL, // stencil volume draw mode + ERM_SHADOW_VOLUME_ZPASS // stencil volume draw mode + }; + + //! sets right vertex shader + void setVertexShader(video::E_VERTEX_TYPE newType); + + //! sets the needed renderstates + bool setRenderStates3DMode(); + + //! sets the needed renderstates + void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); + + //! sets the needed renderstates + void setRenderStatesStencilFillMode(bool alpha); + + //! sets the needed renderstates + void setRenderStatesStencilShadowMode(bool zfail); + + //! sets the current Texture + bool setTexture(s32 stage, video::ITexture* texture); + + //! resets the device + bool reset(); + + //! returns a device dependent texture from a software surface (IImage) + //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES + virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const char* name); + + // returns the current size of the screen or rendertarget + core::dimension2d getCurrentRenderTargetSize(); + + //! Adds a new material renderer to the VideoDriver, using pixel and/or + //! vertex shaders to render geometry. + s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram, + IShaderConstantSetCallBack* callback, + E_MATERIAL_TYPE baseMaterial, s32 userData); + + void createMaterialRenderers(); + + inline D3DCOLORVALUE colorToD3D(const SColor& col) + { + const f32 f = 1.0f / 255.0f; + D3DCOLORVALUE v; + v.r = col.getRed() * f; + v.g = col.getGreen() * f; + v.b = col.getBlue() * f; + v.a = col.getAlpha() * f; + return v; + } + + E_RENDER_MODE CurrentRenderMode; + D3DPRESENT_PARAMETERS present; + + SMaterial Material, LastMaterial; + bool ResetRenderStates; // bool to make all renderstates be reseted if set. + bool Transformation3DChanged; + bool StencilBuffer; + ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES]; + core::matrix4 Matrices[ETS_COUNT]; // matrices of the 3d mode we need to restore when we switch back from the 2d mode. + + HINSTANCE D3DLibrary; + IDirect3D8* pID3D; + IDirect3DDevice8* pID3DDevice; + + IDirect3DSurface8* PrevRenderTarget; + core::dimension2d CurrentRendertargetSize; + + D3DCAPS8 Caps; + + E_VERTEX_TYPE LastVertexType; + + D3DMATRIX UnitMatrix; + + u32 MaxTextureUnits; + f32 MaxLightDistance; + s32 LastSetLight; + bool DeviceLost; + + SColorf AmbientLight; + }; + +} // end namespace video +} // end namespace irr + + +#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ +#endif // _IRR_WINDOWS_ +#endif // __C_VIDEO_DIRECTX_8_H_INCLUDED__ + diff --git a/src/dep/src/irrlicht/CD3D8MaterialRenderer.h b/src/dep/src/irrlicht/CD3D8MaterialRenderer.h index 70a74c8..a356cda 100644 --- a/src/dep/src/irrlicht/CD3D8MaterialRenderer.h +++ b/src/dep/src/irrlicht/CD3D8MaterialRenderer.h @@ -1,587 +1,587 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D8_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D8_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ -#include "d3d8.h" - -#include "IMaterialRenderer.h" - -namespace irr -{ -namespace video -{ - -D3DMATRIX UnitMatrixD3D8; -D3DMATRIX SphereMapMatrixD3D8; - -//! Base class for all internal D3D8 material renderers -class CD3D8MaterialRenderer : public IMaterialRenderer -{ -public: - - //! Constructor - CD3D8MaterialRenderer(IDirect3DDevice8* d3ddev, video::IVideoDriver* driver) - : pID3DDevice(d3ddev), Driver(driver) - { - } - -protected: - - IDirect3DDevice8* pID3DDevice; - video::IVideoDriver* Driver; -}; - - -//! Solid material renderer -class CD3D8MaterialRenderer_SOLID : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_SOLID(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - } - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - -//! Generic Texture Blend -class CD3D8MaterialRenderer_ONETEXTURE_BLEND : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_ONETEXTURE_BLEND(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || - material.MaterialTypeParam != lastMaterial.MaterialTypeParam || - resetAllRenderstates) - { - - E_BLEND_FACTOR srcFact,dstFact; - E_MODULATE_FUNC modulate; - unpack_texureBlendFunc ( srcFact, dstFact, modulate, material.MaterialTypeParam ); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, getD3DBlend ( srcFact ) ); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, getD3DBlend ( dstFact ) ); - - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, getD3DModulate ( modulate ) ); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - - if ( getTexelAlpha ( srcFact ) + getTexelAlpha ( dstFact ) ) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - } - else - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - } - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - } - - private: - - u32 getD3DBlend ( E_BLEND_FACTOR factor ) const - { - u32 r = 0; - switch ( factor ) - { - case EBF_ZERO: r = D3DBLEND_ZERO; break; - case EBF_ONE: r = D3DBLEND_ONE; break; - case EBF_DST_COLOR: r = D3DBLEND_DESTCOLOR; break; - case EBF_ONE_MINUS_DST_COLOR: r = D3DBLEND_INVDESTCOLOR; break; - case EBF_SRC_COLOR: r = D3DBLEND_SRCCOLOR; break; - case EBF_ONE_MINUS_SRC_COLOR: r = D3DBLEND_INVSRCCOLOR; break; - case EBF_SRC_ALPHA: r = D3DBLEND_SRCALPHA; break; - case EBF_ONE_MINUS_SRC_ALPHA: r = D3DBLEND_INVSRCALPHA; break; - case EBF_DST_ALPHA: r = D3DBLEND_DESTALPHA; break; - case EBF_ONE_MINUS_DST_ALPHA: r = D3DBLEND_INVDESTALPHA; break; - case EBF_SRC_ALPHA_SATURATE: r = D3DBLEND_SRCALPHASAT; break; - } - return r; - } - - u32 getTexelAlpha ( E_BLEND_FACTOR factor ) const - { - u32 r = 0; - switch ( factor ) - { - case EBF_SRC_ALPHA: r = 1; break; - case EBF_ONE_MINUS_SRC_ALPHA: r = 1; break; - case EBF_DST_ALPHA: r = 1; break; - case EBF_ONE_MINUS_DST_ALPHA: r = 1; break; - case EBF_SRC_ALPHA_SATURATE: r = 1; break; - } - return r; - } - - u32 getD3DModulate ( E_MODULATE_FUNC func ) const - { - u32 r = D3DTOP_MODULATE; - switch ( func ) - { - case EMFN_MODULATE_1X: r = D3DTOP_MODULATE; break; - case EMFN_MODULATE_2X: r = D3DTOP_MODULATE2X; break; - case EMFN_MODULATE_4X: r = D3DTOP_MODULATE4X; break; - } - return r; - } - -}; - - -//! Solid 2 layer material renderer -class CD3D8MaterialRenderer_SOLID_2_LAYER : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_SOLID_2_LAYER(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 0); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDDIFFUSEALPHA); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - - -//! Transparent add color material renderer -class CD3D8MaterialRenderer_TRANSPARENT_ADD_COLOR : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_TRANSPARENT_ADD_COLOR(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR); - } - - material.ZWriteEnable = false; - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() - { - return true; - } -}; - - -//! Transparent vertex alpha material renderer -class CD3D8MaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); - } - - material.ZWriteEnable = false; - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() - { - return true; - } -}; - - -//! Transparent alpha channel material renderer -class CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates - || material.MaterialTypeParam != lastMaterial.MaterialTypeParam ) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - - pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - - s32 refValue = core::floor32(material.MaterialTypeParam * 255.f); - if ( !refValue ) - refValue = 127; // default value - - pID3DDevice->SetRenderState(D3DRS_ALPHAREF, refValue); - pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); - } - - //material.ZWriteEnable = false; - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() - { - return true; - } -}; - - -//! Transparent alpha channel material renderer -class CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - - pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - s32 refValue = core::floor32(material.MaterialTypeParam * 255.f); - if ( !refValue ) - refValue = 127; // default value - - pID3DDevice->SetRenderState(D3DRS_ALPHAREF,refValue); - pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); - } - - //! Returns if the material is transparent. The scene managment needs to know this - //! for being able to sort the materials by opaque and transparent. - virtual bool isTransparent() - { - return false; // this material is not really transparent because it does no blending. - } -}; - - - -//! material renderer for all kinds of linghtmaps -class CD3D8MaterialRenderer_LIGHTMAP : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_LIGHTMAP(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (material.MaterialType >= EMT_LIGHTMAP_LIGHTING) - { - // with lighting - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - } - else - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - } - - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); - - if (material.MaterialType == EMT_LIGHTMAP_ADD) - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD); - else - if (material.MaterialType == EMT_LIGHTMAP_M4) - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE4X); - else - if (material.MaterialType == EMT_LIGHTMAP_M2) - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE2X); - else - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); - pID3DDevice->SetTextureStageState (1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - -//! material renderer for detail maps -class CD3D8MaterialRenderer_DETAIL_MAP : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_DETAIL_MAP(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState (1, D3DTSS_COLOROP, D3DTOP_ADDSIGNED); - pID3DDevice->SetTextureStageState (1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (1, D3DTSS_COLORARG2, D3DTA_CURRENT); - pID3DDevice->SetTextureStageState (1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - - -//! sphere map material renderer -class CD3D8MaterialRenderer_SPHERE_MAP : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_SPHERE_MAP(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - pID3DDevice->SetTransform( D3DTS_TEXTURE0, &SphereMapMatrixD3D8 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACENORMAL ); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0); - pID3DDevice->SetTransform( D3DTS_TEXTURE0, &UnitMatrixD3D8 ); - } -}; - - -//! reflection 2 layer material renderer -class CD3D8MaterialRenderer_REFLECTION_2_LAYER : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_REFLECTION_2_LAYER(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); - - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D8 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1); - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D8 ); - } -}; - - -//! reflection 2 layer material renderer -class CD3D8MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); - - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D8 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - - material.ZWriteEnable = false; - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1); - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D8 ); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() - { - return true; - } -}; - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_D3D8_MATERIAL_RENDERER_H_INCLUDED__ +#define __C_D3D8_MATERIAL_RENDERER_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_WINDOWS_ + +#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ +#include "d3d8.h" + +#include "IMaterialRenderer.h" + +namespace irr +{ +namespace video +{ + +D3DMATRIX UnitMatrixD3D8; +D3DMATRIX SphereMapMatrixD3D8; + +//! Base class for all internal D3D8 material renderers +class CD3D8MaterialRenderer : public IMaterialRenderer +{ +public: + + //! Constructor + CD3D8MaterialRenderer(IDirect3DDevice8* d3ddev, video::IVideoDriver* driver) + : pID3DDevice(d3ddev), Driver(driver) + { + } + +protected: + + IDirect3DDevice8* pID3DDevice; + video::IVideoDriver* Driver; +}; + + +//! Solid material renderer +class CD3D8MaterialRenderer_SOLID : public CD3D8MaterialRenderer +{ +public: + + CD3D8MaterialRenderer_SOLID(IDirect3DDevice8* p, video::IVideoDriver* d) + : CD3D8MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + } + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } +}; + +//! Generic Texture Blend +class CD3D8MaterialRenderer_ONETEXTURE_BLEND : public CD3D8MaterialRenderer +{ +public: + + CD3D8MaterialRenderer_ONETEXTURE_BLEND(IDirect3DDevice8* p, video::IVideoDriver* d) + : CD3D8MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || + material.MaterialTypeParam != lastMaterial.MaterialTypeParam || + resetAllRenderstates) + { + + E_BLEND_FACTOR srcFact,dstFact; + E_MODULATE_FUNC modulate; + unpack_texureBlendFunc ( srcFact, dstFact, modulate, material.MaterialTypeParam ); + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, getD3DBlend ( srcFact ) ); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, getD3DBlend ( dstFact ) ); + + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, getD3DModulate ( modulate ) ); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + + if ( getTexelAlpha ( srcFact ) + getTexelAlpha ( dstFact ) ) + { + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + } + else + { + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); + } + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + } + + private: + + u32 getD3DBlend ( E_BLEND_FACTOR factor ) const + { + u32 r = 0; + switch ( factor ) + { + case EBF_ZERO: r = D3DBLEND_ZERO; break; + case EBF_ONE: r = D3DBLEND_ONE; break; + case EBF_DST_COLOR: r = D3DBLEND_DESTCOLOR; break; + case EBF_ONE_MINUS_DST_COLOR: r = D3DBLEND_INVDESTCOLOR; break; + case EBF_SRC_COLOR: r = D3DBLEND_SRCCOLOR; break; + case EBF_ONE_MINUS_SRC_COLOR: r = D3DBLEND_INVSRCCOLOR; break; + case EBF_SRC_ALPHA: r = D3DBLEND_SRCALPHA; break; + case EBF_ONE_MINUS_SRC_ALPHA: r = D3DBLEND_INVSRCALPHA; break; + case EBF_DST_ALPHA: r = D3DBLEND_DESTALPHA; break; + case EBF_ONE_MINUS_DST_ALPHA: r = D3DBLEND_INVDESTALPHA; break; + case EBF_SRC_ALPHA_SATURATE: r = D3DBLEND_SRCALPHASAT; break; + } + return r; + } + + u32 getTexelAlpha ( E_BLEND_FACTOR factor ) const + { + u32 r = 0; + switch ( factor ) + { + case EBF_SRC_ALPHA: r = 1; break; + case EBF_ONE_MINUS_SRC_ALPHA: r = 1; break; + case EBF_DST_ALPHA: r = 1; break; + case EBF_ONE_MINUS_DST_ALPHA: r = 1; break; + case EBF_SRC_ALPHA_SATURATE: r = 1; break; + } + return r; + } + + u32 getD3DModulate ( E_MODULATE_FUNC func ) const + { + u32 r = D3DTOP_MODULATE; + switch ( func ) + { + case EMFN_MODULATE_1X: r = D3DTOP_MODULATE; break; + case EMFN_MODULATE_2X: r = D3DTOP_MODULATE2X; break; + case EMFN_MODULATE_4X: r = D3DTOP_MODULATE4X; break; + } + return r; + } + +}; + + +//! Solid 2 layer material renderer +class CD3D8MaterialRenderer_SOLID_2_LAYER : public CD3D8MaterialRenderer +{ +public: + + CD3D8MaterialRenderer_SOLID_2_LAYER(IDirect3DDevice8* p, video::IVideoDriver* d) + : CD3D8MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 0); + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDDIFFUSEALPHA); + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } +}; + + +//! Transparent add color material renderer +class CD3D8MaterialRenderer_TRANSPARENT_ADD_COLOR : public CD3D8MaterialRenderer +{ +public: + + CD3D8MaterialRenderer_TRANSPARENT_ADD_COLOR(IDirect3DDevice8* p, video::IVideoDriver* d) + : CD3D8MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR); + } + + material.ZWriteEnable = false; + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + //! Returns if the material is transparent. + virtual bool isTransparent() + { + return true; + } +}; + + +//! Transparent vertex alpha material renderer +class CD3D8MaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public CD3D8MaterialRenderer +{ +public: + + CD3D8MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(IDirect3DDevice8* p, video::IVideoDriver* d) + : CD3D8MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + } + + material.ZWriteEnable = false; + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + //! Returns if the material is transparent. + virtual bool isTransparent() + { + return true; + } +}; + + +//! Transparent alpha channel material renderer +class CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL : public CD3D8MaterialRenderer +{ +public: + + CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(IDirect3DDevice8* p, video::IVideoDriver* d) + : CD3D8MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates + || material.MaterialTypeParam != lastMaterial.MaterialTypeParam ) + { + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + + pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); + + s32 refValue = core::floor32(material.MaterialTypeParam * 255.f); + if ( !refValue ) + refValue = 127; // default value + + pID3DDevice->SetRenderState(D3DRS_ALPHAREF, refValue); + pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); + pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); + } + + //material.ZWriteEnable = false; + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + virtual void OnUnsetMaterial() + { + pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); + } + + //! Returns if the material is transparent. + virtual bool isTransparent() + { + return true; + } +}; + + +//! Transparent alpha channel material renderer +class CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF : public CD3D8MaterialRenderer +{ +public: + + CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(IDirect3DDevice8* p, video::IVideoDriver* d) + : CD3D8MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + + pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + + s32 refValue = core::floor32(material.MaterialTypeParam * 255.f); + if ( !refValue ) + refValue = 127; // default value + + pID3DDevice->SetRenderState(D3DRS_ALPHAREF,refValue); + pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); + pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + virtual void OnUnsetMaterial() + { + pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); + } + + //! Returns if the material is transparent. The scene managment needs to know this + //! for being able to sort the materials by opaque and transparent. + virtual bool isTransparent() + { + return false; // this material is not really transparent because it does no blending. + } +}; + + + +//! material renderer for all kinds of linghtmaps +class CD3D8MaterialRenderer_LIGHTMAP : public CD3D8MaterialRenderer +{ +public: + + CD3D8MaterialRenderer_LIGHTMAP(IDirect3DDevice8* p, video::IVideoDriver* d) + : CD3D8MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + if (material.MaterialType >= EMT_LIGHTMAP_LIGHTING) + { + // with lighting + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + } + else + { + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + } + + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); + + if (material.MaterialType == EMT_LIGHTMAP_ADD) + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD); + else + if (material.MaterialType == EMT_LIGHTMAP_M4) + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE4X); + else + if (material.MaterialType == EMT_LIGHTMAP_M2) + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE2X); + else + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); + pID3DDevice->SetTextureStageState (1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } +}; + +//! material renderer for detail maps +class CD3D8MaterialRenderer_DETAIL_MAP : public CD3D8MaterialRenderer +{ +public: + + CD3D8MaterialRenderer_DETAIL_MAP(IDirect3DDevice8* p, video::IVideoDriver* d) + : CD3D8MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetTextureStageState (1, D3DTSS_COLOROP, D3DTOP_ADDSIGNED); + pID3DDevice->SetTextureStageState (1, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (1, D3DTSS_COLORARG2, D3DTA_CURRENT); + pID3DDevice->SetTextureStageState (1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } +}; + + +//! sphere map material renderer +class CD3D8MaterialRenderer_SPHERE_MAP : public CD3D8MaterialRenderer +{ +public: + + CD3D8MaterialRenderer_SPHERE_MAP(IDirect3DDevice8* p, video::IVideoDriver* d) + : CD3D8MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + + pID3DDevice->SetTransform( D3DTS_TEXTURE0, &SphereMapMatrixD3D8 ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACENORMAL ); + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + virtual void OnUnsetMaterial() + { + pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0); + pID3DDevice->SetTransform( D3DTS_TEXTURE0, &UnitMatrixD3D8 ); + } +}; + + +//! reflection 2 layer material renderer +class CD3D8MaterialRenderer_REFLECTION_2_LAYER : public CD3D8MaterialRenderer +{ +public: + + CD3D8MaterialRenderer_REFLECTION_2_LAYER(IDirect3DDevice8* p, video::IVideoDriver* d) + : CD3D8MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); + + pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D8 ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + virtual void OnUnsetMaterial() + { + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1); + pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D8 ); + } +}; + + +//! reflection 2 layer material renderer +class CD3D8MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER : public CD3D8MaterialRenderer +{ +public: + + CD3D8MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(IDirect3DDevice8* p, video::IVideoDriver* d) + : CD3D8MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); + + pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D8 ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); + } + + material.ZWriteEnable = false; + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + virtual void OnUnsetMaterial() + { + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1); + pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D8 ); + } + + //! Returns if the material is transparent. + virtual bool isTransparent() + { + return true; + } +}; + +} // end namespace video +} // end namespace irr + +#endif +#endif +#endif + diff --git a/src/dep/src/irrlicht/CD3D8NormalMapRenderer.cpp b/src/dep/src/irrlicht/CD3D8NormalMapRenderer.cpp index e622735..67e7499 100644 --- a/src/dep/src/irrlicht/CD3D8NormalMapRenderer.cpp +++ b/src/dep/src/irrlicht/CD3D8NormalMapRenderer.cpp @@ -1,238 +1,238 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - -#include "CD3D8NormalMapRenderer.h" -#include "IMaterialRendererServices.h" -#include "IVideoDriver.h" -#include "os.h" -#include "SLight.h" - -namespace irr -{ -namespace video -{ - - // 1.1 Shaders with two lights and vertex based attenuation - - // Irrlicht Engine D3D8 render path normal map vertex shader - const char D3D8_NORMAL_MAP_VSH[] = - ";Irrlicht Engine 0.8 D3D8 render path normal map vertex shader\n"\ - "; c0-3: Transposed world matrix \n"\ - "; c8-11: Transposed worldViewProj matrix (Projection * View * World) \n"\ - "; c12: Light01 position \n"\ - "; c13: x,y,z: Light01 color; .w: 1/LightRadius² \n"\ - "; c14: Light02 position \n"\ - "; c15: x,y,z: Light02 color; .w: 1/LightRadius² \n"\ - "\n"\ - "; v0 - position \n"\ - "; v1 - normal \n"\ - "; v2 - color \n"\ - "; v3 - texture coord \n"\ - "; v4 - tangent \n"\ - "; v5 - binormal \n"\ - "\n"\ - "vs.1.1\n"\ - "\n"\ - "m4x4 oPos, v0, c8 ; transform position to clip space with worldViewProj matrix\n"\ - "\n"\ - "m3x3 r5, v4, c0 ; transform tangent U\n"\ - "m3x3 r7, v1, c0 ; transform normal W\n"\ - "m3x3 r6, v5, c0 ; transform binormal V\n"\ - "\n"\ - "m4x4 r4, v0, c0 ; vertex into world position\n"\ - "add r2, c12, -r4 ; vtxpos - lightpos1\n"\ - "add r3, c14, -r4 ; vtxpos - lightpos2\n"\ - "\n"\ - "dp3 r8.x, r5, r2 ; transform the light vector 1 with U, V, W\n"\ - "dp3 r8.y, r6, r2 \n"\ - "dp3 r8.z, r7, r2 \n"\ - "dp3 r9.x, r5, r3 ; transform the light vector 2 with U, V, W\n"\ - "dp3 r9.y, r6, r3 \n"\ - "dp3 r9.z, r7, r3 \n"\ - "\n"\ - "dp3 r8.w, r8, r8 ; normalize light vector 1 (r8)\n"\ - "rsq r8.w, r8.w \n"\ - "mul r8, r8, r8.w \n"\ - "dp3 r9.w, r9, r9 ; normalize light vector 2 (r9)\n"\ - "rsq r9.w, r9.w \n"\ - "mul r9, r9, r9.w \n"\ - "\n"\ - "mad oT2.xyz, r8.xyz, c95, c95 ; move light vector 1 from -1..1 into 0..1 \n"\ - "mad oT3.xyz, r9.xyz, c95, c95 ; move light vector 2 from -1..1 into 0..1 \n"\ - "\n"\ - " ; calculate attenuation of light 1 \n"\ - "dp3 r2.x, r2.xyz, r2.xyz ; r2.x = r2.x² + r2.y² + r2.z² \n"\ - "mul r2.x, r2.x, c13.w ; r2.x * attenutation \n"\ - "rsq r2, r2.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD0, r2, c13 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - " ; calculate attenuation of light 2 \n"\ - "dp3 r3.x, r3.xyz, r3.xyz ; r3.x = r3.x² + r3.y² + r3.z² \n"\ - "mul r3.x, r3.x, c15.w ; r2.x * attenutation \n"\ - "rsq r3, r3.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD1, r3, c15 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "mov oT0.xy, v3.xy ; move out texture coordinates 1\n"\ - "mov oT1.xy, v3.xy ; move out texture coordinates 2\n"\ - "mov oD0.a, v2.a ; move out original alpha value \n"\ - "\n"; - - // Irrlicht Engine D3D8 render path normal map pixel shader - const char D3D8_NORMAL_MAP_PSH[] = - ";Irrlicht Engine 0.8 D3D8 render path normal map pixel shader\n"\ - ";Input: \n"\ - ";t0: color map texture coord \n"\ - ";t1: normal map texture coords \n"\ - ";t2: light 1 vector in tangent space \n"\ - ";v0: light 1 color \n"\ - ";t3: light 2 vector in tangent space \n"\ - ";v1: light 2 color \n"\ - ";v0.a: vertex alpha value \n"\ - "ps.1.1 \n"\ - "tex t0 ; sample color map \n"\ - "tex t1 ; sample normal map\n"\ - "texcoord t2 ; fetch light vector 1\n"\ - "texcoord t3 ; fetch light vector 2\n"\ - "\n"\ - "dp3_sat r0, t1_bx2, t2_bx2 ; normal dot light 1 (_bx2 because moved into 0..1)\n"\ - "mul r0, r0, v0 ; luminance1 * light color 1 \n"\ - "\n"\ - "dp3_sat r1, t1_bx2, t3_bx2 ; normal dot light 2 (_bx2 because moved into 0..1)\n"\ - "mad r0, r1, v1, r0 ; (luminance2 * light color 2) + luminance 1 \n"\ - "\n"\ - "mul r0, t0, r0 ; total luminance * base color\n"\ - "mov r0.a, v0.a ; write interpolated vertex alpha value \n"\ - "\n"\ - ""; - - CD3D8NormalMapRenderer::CD3D8NormalMapRenderer( - IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) - : CD3D8ShaderMaterialRenderer(d3ddev, driver, 0, baseMaterial), - CompiledShaders(true) - { - // set this as callback. We could have done this in - // the initialization list, but some compilers don't like it. - - CallBack = this; - - // basicly, this thing simply compiles these hardcoded shaders if the - // hardware is able to do them, otherwise it maps to the base material - - if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) || - !driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - { - // this hardware is not able to do shaders. Fall back to - // base material. - outMaterialTypeNr = driver->addMaterialRenderer(this); - return; - } - - // check if already compiled normal map shaders are there. - - video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_NORMAL_MAP_SOLID); - if (renderer) - { - // use the already compiled shaders - video::CD3D8NormalMapRenderer* nmr = (video::CD3D8NormalMapRenderer*)renderer; - CompiledShaders = false; - - VertexShader = nmr->VertexShader; - PixelShader = nmr->PixelShader; - - outMaterialTypeNr = driver->addMaterialRenderer(this); - } - else - { - // compile shaders on our own - init(outMaterialTypeNr, D3D8_NORMAL_MAP_VSH, D3D8_NORMAL_MAP_PSH, EVT_TANGENTS); - } - } - - CD3D8NormalMapRenderer::~CD3D8NormalMapRenderer() - { - if (CallBack == this) - CallBack = 0; - - if (!CompiledShaders) - { - // prevent this from deleting shaders we did not create - VertexShader = 0; - PixelShader = 0; - } - } - - bool CD3D8NormalMapRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) - { - if (vtxtype != video::EVT_TANGENTS) - { - os::Printer::log("Error: Normal map renderer only supports vertices of type EVT_TANGENTS", ELL_ERROR); - return false; - } - - return CD3D8ShaderMaterialRenderer::OnRender(service, vtxtype); - } - - //! Returns the render capability of the material. - s32 CD3D8NormalMapRenderer::getRenderCapability() - { - if (Driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) && - Driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - return 0; - - return 1; - } - - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - void CD3D8NormalMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) - { - video::IVideoDriver* driver = services->getVideoDriver(); - - // set transposed world matrix - services->setVertexShaderConstant(driver->getTransform(video::ETS_WORLD).getTransposed().pointer(), 0, 4); - - // set transposed worldViewProj matrix - core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - services->setVertexShaderConstant(worldViewProj.getTransposed().pointer(), 8, 4); - - // here we've got to fetch the fixed function lights from the - // driver and set them as constants - - u32 cnt = driver->getDynamicLightCount(); - - for (u32 i=0; i<2; ++i) - { - SLight light; - - if (igetDynamicLight(i); - else - { - light.DiffuseColor.set(0,0,0); // make light dark - light.Radius = 1.0f; - } - - light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation - - services->setVertexShaderConstant(reinterpret_cast(&light.Position), 12+(i*2), 1); - services->setVertexShaderConstant(reinterpret_cast(&light.DiffuseColor), 13+(i*2), 1); - } - - f32 c95[] = {0.5f, 0.5f, 0.5f, 0.5f}; - services->setVertexShaderConstant(c95, 95, 1); - } - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ + +#include "CD3D8NormalMapRenderer.h" +#include "IMaterialRendererServices.h" +#include "IVideoDriver.h" +#include "os.h" +#include "SLight.h" + +namespace irr +{ +namespace video +{ + + // 1.1 Shaders with two lights and vertex based attenuation + + // Irrlicht Engine D3D8 render path normal map vertex shader + const char D3D8_NORMAL_MAP_VSH[] = + ";Irrlicht Engine 0.8 D3D8 render path normal map vertex shader\n"\ + "; c0-3: Transposed world matrix \n"\ + "; c8-11: Transposed worldViewProj matrix (Projection * View * World) \n"\ + "; c12: Light01 position \n"\ + "; c13: x,y,z: Light01 color; .w: 1/LightRadius² \n"\ + "; c14: Light02 position \n"\ + "; c15: x,y,z: Light02 color; .w: 1/LightRadius² \n"\ + "\n"\ + "; v0 - position \n"\ + "; v1 - normal \n"\ + "; v2 - color \n"\ + "; v3 - texture coord \n"\ + "; v4 - tangent \n"\ + "; v5 - binormal \n"\ + "\n"\ + "vs.1.1\n"\ + "\n"\ + "m4x4 oPos, v0, c8 ; transform position to clip space with worldViewProj matrix\n"\ + "\n"\ + "m3x3 r5, v4, c0 ; transform tangent U\n"\ + "m3x3 r7, v1, c0 ; transform normal W\n"\ + "m3x3 r6, v5, c0 ; transform binormal V\n"\ + "\n"\ + "m4x4 r4, v0, c0 ; vertex into world position\n"\ + "add r2, c12, -r4 ; vtxpos - lightpos1\n"\ + "add r3, c14, -r4 ; vtxpos - lightpos2\n"\ + "\n"\ + "dp3 r8.x, r5, r2 ; transform the light vector 1 with U, V, W\n"\ + "dp3 r8.y, r6, r2 \n"\ + "dp3 r8.z, r7, r2 \n"\ + "dp3 r9.x, r5, r3 ; transform the light vector 2 with U, V, W\n"\ + "dp3 r9.y, r6, r3 \n"\ + "dp3 r9.z, r7, r3 \n"\ + "\n"\ + "dp3 r8.w, r8, r8 ; normalize light vector 1 (r8)\n"\ + "rsq r8.w, r8.w \n"\ + "mul r8, r8, r8.w \n"\ + "dp3 r9.w, r9, r9 ; normalize light vector 2 (r9)\n"\ + "rsq r9.w, r9.w \n"\ + "mul r9, r9, r9.w \n"\ + "\n"\ + "mad oT2.xyz, r8.xyz, c95, c95 ; move light vector 1 from -1..1 into 0..1 \n"\ + "mad oT3.xyz, r9.xyz, c95, c95 ; move light vector 2 from -1..1 into 0..1 \n"\ + "\n"\ + " ; calculate attenuation of light 1 \n"\ + "dp3 r2.x, r2.xyz, r2.xyz ; r2.x = r2.x² + r2.y² + r2.z² \n"\ + "mul r2.x, r2.x, c13.w ; r2.x * attenutation \n"\ + "rsq r2, r2.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ + "mul oD0, r2, c13 ; resulting light color = lightcolor * attenuation \n"\ + "\n"\ + " ; calculate attenuation of light 2 \n"\ + "dp3 r3.x, r3.xyz, r3.xyz ; r3.x = r3.x² + r3.y² + r3.z² \n"\ + "mul r3.x, r3.x, c15.w ; r2.x * attenutation \n"\ + "rsq r3, r3.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ + "mul oD1, r3, c15 ; resulting light color = lightcolor * attenuation \n"\ + "\n"\ + "mov oT0.xy, v3.xy ; move out texture coordinates 1\n"\ + "mov oT1.xy, v3.xy ; move out texture coordinates 2\n"\ + "mov oD0.a, v2.a ; move out original alpha value \n"\ + "\n"; + + // Irrlicht Engine D3D8 render path normal map pixel shader + const char D3D8_NORMAL_MAP_PSH[] = + ";Irrlicht Engine 0.8 D3D8 render path normal map pixel shader\n"\ + ";Input: \n"\ + ";t0: color map texture coord \n"\ + ";t1: normal map texture coords \n"\ + ";t2: light 1 vector in tangent space \n"\ + ";v0: light 1 color \n"\ + ";t3: light 2 vector in tangent space \n"\ + ";v1: light 2 color \n"\ + ";v0.a: vertex alpha value \n"\ + "ps.1.1 \n"\ + "tex t0 ; sample color map \n"\ + "tex t1 ; sample normal map\n"\ + "texcoord t2 ; fetch light vector 1\n"\ + "texcoord t3 ; fetch light vector 2\n"\ + "\n"\ + "dp3_sat r0, t1_bx2, t2_bx2 ; normal dot light 1 (_bx2 because moved into 0..1)\n"\ + "mul r0, r0, v0 ; luminance1 * light color 1 \n"\ + "\n"\ + "dp3_sat r1, t1_bx2, t3_bx2 ; normal dot light 2 (_bx2 because moved into 0..1)\n"\ + "mad r0, r1, v1, r0 ; (luminance2 * light color 2) + luminance 1 \n"\ + "\n"\ + "mul r0, t0, r0 ; total luminance * base color\n"\ + "mov r0.a, v0.a ; write interpolated vertex alpha value \n"\ + "\n"\ + ""; + + CD3D8NormalMapRenderer::CD3D8NormalMapRenderer( + IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, + s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) + : CD3D8ShaderMaterialRenderer(d3ddev, driver, 0, baseMaterial), + CompiledShaders(true) + { + // set this as callback. We could have done this in + // the initialization list, but some compilers don't like it. + + CallBack = this; + + // basicly, this thing simply compiles these hardcoded shaders if the + // hardware is able to do them, otherwise it maps to the base material + + if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) || + !driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) + { + // this hardware is not able to do shaders. Fall back to + // base material. + outMaterialTypeNr = driver->addMaterialRenderer(this); + return; + } + + // check if already compiled normal map shaders are there. + + video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_NORMAL_MAP_SOLID); + if (renderer) + { + // use the already compiled shaders + video::CD3D8NormalMapRenderer* nmr = (video::CD3D8NormalMapRenderer*)renderer; + CompiledShaders = false; + + VertexShader = nmr->VertexShader; + PixelShader = nmr->PixelShader; + + outMaterialTypeNr = driver->addMaterialRenderer(this); + } + else + { + // compile shaders on our own + init(outMaterialTypeNr, D3D8_NORMAL_MAP_VSH, D3D8_NORMAL_MAP_PSH, EVT_TANGENTS); + } + } + + CD3D8NormalMapRenderer::~CD3D8NormalMapRenderer() + { + if (CallBack == this) + CallBack = 0; + + if (!CompiledShaders) + { + // prevent this from deleting shaders we did not create + VertexShader = 0; + PixelShader = 0; + } + } + + bool CD3D8NormalMapRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) + { + if (vtxtype != video::EVT_TANGENTS) + { + os::Printer::log("Error: Normal map renderer only supports vertices of type EVT_TANGENTS", ELL_ERROR); + return false; + } + + return CD3D8ShaderMaterialRenderer::OnRender(service, vtxtype); + } + + //! Returns the render capability of the material. + s32 CD3D8NormalMapRenderer::getRenderCapability() + { + if (Driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) && + Driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) + return 0; + + return 1; + } + + + //! Called by the engine when the vertex and/or pixel shader constants for an + //! material renderer should be set. + void CD3D8NormalMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) + { + video::IVideoDriver* driver = services->getVideoDriver(); + + // set transposed world matrix + services->setVertexShaderConstant(driver->getTransform(video::ETS_WORLD).getTransposed().pointer(), 0, 4); + + // set transposed worldViewProj matrix + core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); + worldViewProj *= driver->getTransform(video::ETS_VIEW); + worldViewProj *= driver->getTransform(video::ETS_WORLD); + services->setVertexShaderConstant(worldViewProj.getTransposed().pointer(), 8, 4); + + // here we've got to fetch the fixed function lights from the + // driver and set them as constants + + u32 cnt = driver->getDynamicLightCount(); + + for (u32 i=0; i<2; ++i) + { + SLight light; + + if (igetDynamicLight(i); + else + { + light.DiffuseColor.set(0,0,0); // make light dark + light.Radius = 1.0f; + } + + light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation + + services->setVertexShaderConstant(reinterpret_cast(&light.Position), 12+(i*2), 1); + services->setVertexShaderConstant(reinterpret_cast(&light.DiffuseColor), 13+(i*2), 1); + } + + f32 c95[] = {0.5f, 0.5f, 0.5f, 0.5f}; + services->setVertexShaderConstant(c95, 95, 1); + } + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CD3D8NormalMapRenderer.h b/src/dep/src/irrlicht/CD3D8NormalMapRenderer.h index 7e44665..b224596 100644 --- a/src/dep/src/irrlicht/CD3D8NormalMapRenderer.h +++ b/src/dep/src/irrlicht/CD3D8NormalMapRenderer.h @@ -1,56 +1,56 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D8_NORMAL_MAPMATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D8_NORMAL_MAPMATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ -#include "d3d8.h" - -#include "CD3D8ShaderMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" - -namespace irr -{ -namespace video -{ - -//! Renderer for normal maps -class CD3D8NormalMapRenderer : public CD3D8ShaderMaterialRenderer, IShaderConstantSetCallBack -{ -public: - - CD3D8NormalMapRenderer( - IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); - ~CD3D8NormalMapRenderer(); - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); - - bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - //! Returns the render capability of the material. - virtual s32 getRenderCapability(); - -private: - - //! stores if this shader compiled the shaders and is - //! allowed to delete them again. D3D8 lacks reference counting - //! support for shaders. - bool CompiledShaders; - -}; - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_D3D8_NORMAL_MAPMATERIAL_RENDERER_H_INCLUDED__ +#define __C_D3D8_NORMAL_MAPMATERIAL_RENDERER_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_WINDOWS_ + +#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ +#include "d3d8.h" + +#include "CD3D8ShaderMaterialRenderer.h" +#include "IShaderConstantSetCallBack.h" + +namespace irr +{ +namespace video +{ + +//! Renderer for normal maps +class CD3D8NormalMapRenderer : public CD3D8ShaderMaterialRenderer, IShaderConstantSetCallBack +{ +public: + + CD3D8NormalMapRenderer( + IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, + s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); + ~CD3D8NormalMapRenderer(); + + //! Called by the engine when the vertex and/or pixel shader constants for an + //! material renderer should be set. + virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); + + bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); + + //! Returns the render capability of the material. + virtual s32 getRenderCapability(); + +private: + + //! stores if this shader compiled the shaders and is + //! allowed to delete them again. D3D8 lacks reference counting + //! support for shaders. + bool CompiledShaders; + +}; + +} // end namespace video +} // end namespace irr + +#endif +#endif +#endif + diff --git a/src/dep/src/irrlicht/CD3D8ParallaxMapRenderer.cpp b/src/dep/src/irrlicht/CD3D8ParallaxMapRenderer.cpp index a46b5cd..2f954af 100644 --- a/src/dep/src/irrlicht/CD3D8ParallaxMapRenderer.cpp +++ b/src/dep/src/irrlicht/CD3D8ParallaxMapRenderer.cpp @@ -1,306 +1,306 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - -#include "CD3D8ParallaxMapRenderer.h" -#include "IMaterialRendererServices.h" -#include "IVideoDriver.h" -#include "os.h" -#include "SLight.h" - -namespace irr -{ -namespace video -{ - // 1.1/1.4 Shaders with two lights and vertex based attenuation - - // Irrlicht Engine D3D8 render path normal map vertex shader - const char D3D8_PARALLAX_MAP_VSH[] = - ";Irrlicht Engine 0.10 D3D8 render path parallax mapping vertex shader\n"\ - "; c0-3: Transposed world matrix \n"\ - "; c4: Eye position \n"\ - "; c8-11: Transposed worldViewProj matrix (Projection * View * World) \n"\ - "; c12: Light01 position \n"\ - "; c13: x,y,z: Light01 color; .w: 1/LightRadius² \n"\ - "; c14: Light02 position \n"\ - "; c15: x,y,z: Light02 color; .w: 1/LightRadius² \n"\ - "vs.1.1\n"\ - "; v0 ; position \n"\ - "; v1 ; normal \n"\ - "; v2 ; color \n"\ - "; v3 ; texture coord \n"\ - "; v4 ; tangent \n"\ - "; v5 ; binormal \n"\ - "\n"\ - "def c95, 0.5, 0.5, 0.5, 0.5 ; used for moving light vector to ps \n"\ - "def c96, -1, 1, 1, 1 ; somewhere I've got a bug. flipping the vectors with this fixes it. \n"\ - "\n"\ - "m4x4 oPos, v0, c8 ; transform position to clip space with worldViewProj matrix\n"\ - "\n"\ - "m3x3 r5, v4, c0 ; transform tangent U\n"\ - "m3x3 r7, v1, c0 ; transform normal W\n"\ - "m3x3 r6, v5, c0 ; transform binormal V\n"\ - "\n"\ - "m4x4 r4, v0, c0 ; vertex into world position\n"\ - "add r2, c12, -r4 ; vtxpos - light1 pos\n"\ - "add r3, c14, -r4 ; vtxpos - light2 pos\n"\ - "add r1, -c4, r4 ; eye - vtxpos \n"\ - "\n"\ - "dp3 r8.x, r5, r2 ; transform the light1 vector with U, V, W\n"\ - "dp3 r8.y, r6, r2 \n"\ - "dp3 r8.z, r7, r2 \n"\ - "dp3 r9.x, r5, r3 ; transform the light2 vector with U, V, W\n"\ - "dp3 r9.y, r6, r3 \n"\ - "dp3 r9.z, r7, r3 \n"\ - "dp3 r10.x, r5, r1 ; transform the eye vector with U, V, W\n"\ - "dp3 r10.y, r6, r1 \n"\ - "dp3 r10.z, r7, r1 \n"\ - "\n"\ - "dp3 r8.w, r8, r8 ; normalize light vector 1 (r8)\n"\ - "rsq r8.w, r8.w \n"\ - "mul r8, r8, r8.w \n"\ - ";mul r8, r8, c96 \n"\ - "dp3 r9.w, r9, r9 ; normalize light vector 2 (r9)\n"\ - "rsq r9.w, r9.w \n"\ - "mul r9, r9, r9.w \n"\ - ";mul r9, r9, c96 \n"\ - "dp3 r10.w, r10, r10 ; normalize eye vector (r10)\n"\ - "rsq r10.w, r10.w \n"\ - "mul r10, r10, r10.w \n"\ - "mul r10, r10, c96 \n"\ - "\n"\ - "\n"\ - "mad oT2.xyz, r8.xyz, c95, c95 ; move light vector 1 from -1..1 into 0..1 \n"\ - "mad oT3.xyz, r9.xyz, c95, c95 ; move light vector 2 from -1..1 into 0..1 \n"\ - "mad oT4.xyz, r10.xyz, c95, c95 ; move eye vector from -1..1 into 0..1 \n"\ - "\n"\ - " ; calculate attenuation of light 1 \n"\ - "dp3 r2.x, r2.xyz, r2.xyz ; r2.x = r2.x² + r2.y² + r2.z² \n"\ - "mul r2.x, r2.x, c13.w ; r2.x * attenutation \n"\ - "rsq r2, r2.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD0, r2, c13 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - " ; calculate attenuation of light 2 \n"\ - "dp3 r3.x, r3.xyz, r3.xyz ; r3.x = r3.x² + r3.y² + r3.z² \n"\ - "mul r3.x, r3.x, c15.w ; r2.x * attenutation \n"\ - "rsq r3, r3.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD1, r3, c15 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "mov oT0.xy, v3.xy ; move out texture coordinates 1\n"\ - "mov oT1.xy, v3.xy ; move out texture coordinates 2\n"\ - "mov oD0.a, v2.a ; move out original alpha value \n"\ - "\n"; - - - // Irrlicht Engine D3D8 render path normal map pixel shader version 1.4 - const char D3D8_PARALLAX_MAP_PSH[] = - ";Irrlicht Engine 0.10 D3D8 render path parallax mapping pixel shader \n"\ - ";Input: \n"\ - ";t0: color map texture coord \n"\ - ";t1: normal map texture coords \n"\ - ";t2: light 1 vector in tangent space \n"\ - ";t4: eye vector in tangent space \n"\ - ";v0: light 1 color \n"\ - ";t3: light 2 vector in tangent space \n"\ - ";v1: light 2 color \n"\ - ";v0.a: vertex alpha value \n"\ - " \n"\ - "ps.1.4 \n"\ - " \n"\ - ";def c6, 0.02f, 0.02f, 0.02f, 0.0f ; scale factor, now set in callback \n"\ - " \n"\ - "texld r1, t1 ; sample (normal.x, normal.y, normal.z, height) \n"\ - "texcrd r4.xyz, t4 ; fetch eye vector \n"\ - "texcrd r0.xyz, t0 ; color map \n"\ - " \n"\ - "; original parallax mapping: \n"\ - ";mul r3, r1_bx2.wwww, c6; ; r3 = (height, height, height) * scale \n"\ - ";mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ - " \n"\ - "; modified parallax mapping to reduce swimming effect: \n"\ - "mul r3, r1_bx2.wwww, r1_bx2.zzzz ; (nh,nh,nh,nh) = (h,h,h,h) * (n.z,n.z,n.z,n.z,) \n"\ - "mul r3, r3, c6; ; r3 = (nh, nh, nh) * scale \n"\ - "mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ - " \n"\ - "phase \n"\ - " \n"\ - "texld r0, r2 ; load diffuse texture with new tex coord \n"\ - "texld r1, r2 ; sample normal map \n"\ - "texcrd r2.xyz, t2 ; fetch light vector 1 \n"\ - "texcrd r3.xyz, t3 ; fetch light vector 2 \n"\ - " \n"\ - "dp3_sat r2, r1_bx2, r2_bx2 ; normal dot light 1 (_bx2 because moved into 0..1) \n"\ - "mul r2, r2, v0 ; luminance1 * light color 1 \n"\ - " \n"\ - "dp3_sat r3, r1_bx2, r3_bx2 ; normal dot light 2 (_bx2 because moved into 0..1) \n"\ - "mad r3, r3, v1, r2 ; (luminance2 * light color 2) + luminance1 \n"\ - " \n"\ - "mul r0.xyz, r0, r3 ; total luminance * base color \n"\ - "+mov r0.a, v0.a ; write original alpha value \n"\ - "\n"; - - - CD3D8ParallaxMapRenderer::CD3D8ParallaxMapRenderer( - IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) - : CD3D8ShaderMaterialRenderer(d3ddev, driver, 0, baseMaterial), - CompiledShaders(true), CurrentScale(0.0f) - { - // set this as callback. We could have done this in - // the initialization list, but some compilers don't like it. - - CallBack = this; - - // basicly, this thing simply compiles these hardcoded shaders if the - // hardware is able to do them, otherwise it maps to the base material - - if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_4) || - !driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - { - // this hardware is not able to do shaders. Fall back to - // base material. - outMaterialTypeNr = driver->addMaterialRenderer(this); - return; - } - - // check if already compiled parallax map shaders are there. - - video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_PARALLAX_MAP_SOLID); - if (renderer) - { - // use the already compiled shaders - video::CD3D8ParallaxMapRenderer* nmr = (video::CD3D8ParallaxMapRenderer*)renderer; - CompiledShaders = false; - - VertexShader = nmr->VertexShader; - PixelShader = nmr->PixelShader; - - outMaterialTypeNr = driver->addMaterialRenderer(this); - } - else - { - // compile shaders on our own - init(outMaterialTypeNr, D3D8_PARALLAX_MAP_VSH, D3D8_PARALLAX_MAP_PSH, EVT_TANGENTS); - } - } - - CD3D8ParallaxMapRenderer::~CD3D8ParallaxMapRenderer() - { - if (CallBack == this) - CallBack = 0; - - if (!CompiledShaders) - { - // prevent this from deleting shaders we did not create - VertexShader = 0; - PixelShader = 0; - } - } - - bool CD3D8ParallaxMapRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) - { - if (vtxtype != video::EVT_TANGENTS) - { - os::Printer::log("Error: Normal map renderer only supports vertices of type EVT_TANGENTS", ELL_ERROR); - return false; - } - - return CD3D8ShaderMaterialRenderer::OnRender(service, vtxtype); - } - - void CD3D8ParallaxMapRenderer::OnSetMaterial(video::SMaterial& material, - const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services) - { - CD3D8ShaderMaterialRenderer::OnSetMaterial(material, lastMaterial, - resetAllRenderstates, services); - - CurrentScale = material.MaterialTypeParam; - } - - //! Returns the render capability of the material. - s32 CD3D8ParallaxMapRenderer::getRenderCapability() - { - if (Driver->queryFeature(video::EVDF_PIXEL_SHADER_1_4) && - Driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - return 0; - - return 1; - } - - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - void CD3D8ParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) - { - video::IVideoDriver* driver = services->getVideoDriver(); - - // set transposed world matrix - services->setVertexShaderConstant(driver->getTransform(video::ETS_WORLD).getTransposed().pointer(), 0, 4); - - // set eye position - - // The viewpoint is at (0., 0., 0.) in eye space. - // Turning this into a vector [0 0 0 1] and multiply it by - // the inverse of the view matrix, the resulting vector is the - // object space location of the camera. - - f32 floats[4] = {0,0,0,1}; - core::matrix4 minv(driver->getTransform(video::ETS_VIEW)); - minv.makeInverse(); - minv.multiplyWith1x4Matrix(floats); - services->setVertexShaderConstant(floats, 4, 1); - - // set transposed worldViewProj matrix - core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - services->setVertexShaderConstant(worldViewProj.getTransposed().pointer(), 8, 4); - - // here we've got to fetch the fixed function lights from the driver - // and set them as constants - - u32 cnt = driver->getDynamicLightCount(); - - for (u32 i=0; i<2; ++i) - { - SLight light; - - if (igetDynamicLight(i); - else - { - light.DiffuseColor.set(0,0,0); // make light dark - light.Radius = 1.0f; - } - - light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation - - services->setVertexShaderConstant(reinterpret_cast(&light.Position), 12+(i*2), 1); - services->setVertexShaderConstant(reinterpret_cast(&light.DiffuseColor), 13+(i*2), 1); - } - - // this is not really necessary in d3d9 (used a def instruction), but to be sure: - f32 c95[] = {0.5f, 0.5f, 0.5f, 0.5f}; - services->setVertexShaderConstant(c95, 95, 1); - f32 c96[] = {-1, 1, 1, 1}; - services->setVertexShaderConstant(c96, 96, 1); - - // set scale factor - f32 factor = 0.02f; // default value - if (CurrentScale != 0) - factor = CurrentScale; - - f32 c6[] = {factor, factor, factor, 0}; - services->setPixelShaderConstant(c6, 6, 1); - } - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ + +#include "CD3D8ParallaxMapRenderer.h" +#include "IMaterialRendererServices.h" +#include "IVideoDriver.h" +#include "os.h" +#include "SLight.h" + +namespace irr +{ +namespace video +{ + // 1.1/1.4 Shaders with two lights and vertex based attenuation + + // Irrlicht Engine D3D8 render path normal map vertex shader + const char D3D8_PARALLAX_MAP_VSH[] = + ";Irrlicht Engine 0.10 D3D8 render path parallax mapping vertex shader\n"\ + "; c0-3: Transposed world matrix \n"\ + "; c4: Eye position \n"\ + "; c8-11: Transposed worldViewProj matrix (Projection * View * World) \n"\ + "; c12: Light01 position \n"\ + "; c13: x,y,z: Light01 color; .w: 1/LightRadius² \n"\ + "; c14: Light02 position \n"\ + "; c15: x,y,z: Light02 color; .w: 1/LightRadius² \n"\ + "vs.1.1\n"\ + "; v0 ; position \n"\ + "; v1 ; normal \n"\ + "; v2 ; color \n"\ + "; v3 ; texture coord \n"\ + "; v4 ; tangent \n"\ + "; v5 ; binormal \n"\ + "\n"\ + "def c95, 0.5, 0.5, 0.5, 0.5 ; used for moving light vector to ps \n"\ + "def c96, -1, 1, 1, 1 ; somewhere I've got a bug. flipping the vectors with this fixes it. \n"\ + "\n"\ + "m4x4 oPos, v0, c8 ; transform position to clip space with worldViewProj matrix\n"\ + "\n"\ + "m3x3 r5, v4, c0 ; transform tangent U\n"\ + "m3x3 r7, v1, c0 ; transform normal W\n"\ + "m3x3 r6, v5, c0 ; transform binormal V\n"\ + "\n"\ + "m4x4 r4, v0, c0 ; vertex into world position\n"\ + "add r2, c12, -r4 ; vtxpos - light1 pos\n"\ + "add r3, c14, -r4 ; vtxpos - light2 pos\n"\ + "add r1, -c4, r4 ; eye - vtxpos \n"\ + "\n"\ + "dp3 r8.x, r5, r2 ; transform the light1 vector with U, V, W\n"\ + "dp3 r8.y, r6, r2 \n"\ + "dp3 r8.z, r7, r2 \n"\ + "dp3 r9.x, r5, r3 ; transform the light2 vector with U, V, W\n"\ + "dp3 r9.y, r6, r3 \n"\ + "dp3 r9.z, r7, r3 \n"\ + "dp3 r10.x, r5, r1 ; transform the eye vector with U, V, W\n"\ + "dp3 r10.y, r6, r1 \n"\ + "dp3 r10.z, r7, r1 \n"\ + "\n"\ + "dp3 r8.w, r8, r8 ; normalize light vector 1 (r8)\n"\ + "rsq r8.w, r8.w \n"\ + "mul r8, r8, r8.w \n"\ + ";mul r8, r8, c96 \n"\ + "dp3 r9.w, r9, r9 ; normalize light vector 2 (r9)\n"\ + "rsq r9.w, r9.w \n"\ + "mul r9, r9, r9.w \n"\ + ";mul r9, r9, c96 \n"\ + "dp3 r10.w, r10, r10 ; normalize eye vector (r10)\n"\ + "rsq r10.w, r10.w \n"\ + "mul r10, r10, r10.w \n"\ + "mul r10, r10, c96 \n"\ + "\n"\ + "\n"\ + "mad oT2.xyz, r8.xyz, c95, c95 ; move light vector 1 from -1..1 into 0..1 \n"\ + "mad oT3.xyz, r9.xyz, c95, c95 ; move light vector 2 from -1..1 into 0..1 \n"\ + "mad oT4.xyz, r10.xyz, c95, c95 ; move eye vector from -1..1 into 0..1 \n"\ + "\n"\ + " ; calculate attenuation of light 1 \n"\ + "dp3 r2.x, r2.xyz, r2.xyz ; r2.x = r2.x² + r2.y² + r2.z² \n"\ + "mul r2.x, r2.x, c13.w ; r2.x * attenutation \n"\ + "rsq r2, r2.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ + "mul oD0, r2, c13 ; resulting light color = lightcolor * attenuation \n"\ + "\n"\ + " ; calculate attenuation of light 2 \n"\ + "dp3 r3.x, r3.xyz, r3.xyz ; r3.x = r3.x² + r3.y² + r3.z² \n"\ + "mul r3.x, r3.x, c15.w ; r2.x * attenutation \n"\ + "rsq r3, r3.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ + "mul oD1, r3, c15 ; resulting light color = lightcolor * attenuation \n"\ + "\n"\ + "mov oT0.xy, v3.xy ; move out texture coordinates 1\n"\ + "mov oT1.xy, v3.xy ; move out texture coordinates 2\n"\ + "mov oD0.a, v2.a ; move out original alpha value \n"\ + "\n"; + + + // Irrlicht Engine D3D8 render path normal map pixel shader version 1.4 + const char D3D8_PARALLAX_MAP_PSH[] = + ";Irrlicht Engine 0.10 D3D8 render path parallax mapping pixel shader \n"\ + ";Input: \n"\ + ";t0: color map texture coord \n"\ + ";t1: normal map texture coords \n"\ + ";t2: light 1 vector in tangent space \n"\ + ";t4: eye vector in tangent space \n"\ + ";v0: light 1 color \n"\ + ";t3: light 2 vector in tangent space \n"\ + ";v1: light 2 color \n"\ + ";v0.a: vertex alpha value \n"\ + " \n"\ + "ps.1.4 \n"\ + " \n"\ + ";def c6, 0.02f, 0.02f, 0.02f, 0.0f ; scale factor, now set in callback \n"\ + " \n"\ + "texld r1, t1 ; sample (normal.x, normal.y, normal.z, height) \n"\ + "texcrd r4.xyz, t4 ; fetch eye vector \n"\ + "texcrd r0.xyz, t0 ; color map \n"\ + " \n"\ + "; original parallax mapping: \n"\ + ";mul r3, r1_bx2.wwww, c6; ; r3 = (height, height, height) * scale \n"\ + ";mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ + " \n"\ + "; modified parallax mapping to reduce swimming effect: \n"\ + "mul r3, r1_bx2.wwww, r1_bx2.zzzz ; (nh,nh,nh,nh) = (h,h,h,h) * (n.z,n.z,n.z,n.z,) \n"\ + "mul r3, r3, c6; ; r3 = (nh, nh, nh) * scale \n"\ + "mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ + " \n"\ + "phase \n"\ + " \n"\ + "texld r0, r2 ; load diffuse texture with new tex coord \n"\ + "texld r1, r2 ; sample normal map \n"\ + "texcrd r2.xyz, t2 ; fetch light vector 1 \n"\ + "texcrd r3.xyz, t3 ; fetch light vector 2 \n"\ + " \n"\ + "dp3_sat r2, r1_bx2, r2_bx2 ; normal dot light 1 (_bx2 because moved into 0..1) \n"\ + "mul r2, r2, v0 ; luminance1 * light color 1 \n"\ + " \n"\ + "dp3_sat r3, r1_bx2, r3_bx2 ; normal dot light 2 (_bx2 because moved into 0..1) \n"\ + "mad r3, r3, v1, r2 ; (luminance2 * light color 2) + luminance1 \n"\ + " \n"\ + "mul r0.xyz, r0, r3 ; total luminance * base color \n"\ + "+mov r0.a, v0.a ; write original alpha value \n"\ + "\n"; + + + CD3D8ParallaxMapRenderer::CD3D8ParallaxMapRenderer( + IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, + s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) + : CD3D8ShaderMaterialRenderer(d3ddev, driver, 0, baseMaterial), + CompiledShaders(true), CurrentScale(0.0f) + { + // set this as callback. We could have done this in + // the initialization list, but some compilers don't like it. + + CallBack = this; + + // basicly, this thing simply compiles these hardcoded shaders if the + // hardware is able to do them, otherwise it maps to the base material + + if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_4) || + !driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) + { + // this hardware is not able to do shaders. Fall back to + // base material. + outMaterialTypeNr = driver->addMaterialRenderer(this); + return; + } + + // check if already compiled parallax map shaders are there. + + video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_PARALLAX_MAP_SOLID); + if (renderer) + { + // use the already compiled shaders + video::CD3D8ParallaxMapRenderer* nmr = (video::CD3D8ParallaxMapRenderer*)renderer; + CompiledShaders = false; + + VertexShader = nmr->VertexShader; + PixelShader = nmr->PixelShader; + + outMaterialTypeNr = driver->addMaterialRenderer(this); + } + else + { + // compile shaders on our own + init(outMaterialTypeNr, D3D8_PARALLAX_MAP_VSH, D3D8_PARALLAX_MAP_PSH, EVT_TANGENTS); + } + } + + CD3D8ParallaxMapRenderer::~CD3D8ParallaxMapRenderer() + { + if (CallBack == this) + CallBack = 0; + + if (!CompiledShaders) + { + // prevent this from deleting shaders we did not create + VertexShader = 0; + PixelShader = 0; + } + } + + bool CD3D8ParallaxMapRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) + { + if (vtxtype != video::EVT_TANGENTS) + { + os::Printer::log("Error: Normal map renderer only supports vertices of type EVT_TANGENTS", ELL_ERROR); + return false; + } + + return CD3D8ShaderMaterialRenderer::OnRender(service, vtxtype); + } + + void CD3D8ParallaxMapRenderer::OnSetMaterial(video::SMaterial& material, + const video::SMaterial& lastMaterial, + bool resetAllRenderstates, video::IMaterialRendererServices* services) + { + CD3D8ShaderMaterialRenderer::OnSetMaterial(material, lastMaterial, + resetAllRenderstates, services); + + CurrentScale = material.MaterialTypeParam; + } + + //! Returns the render capability of the material. + s32 CD3D8ParallaxMapRenderer::getRenderCapability() + { + if (Driver->queryFeature(video::EVDF_PIXEL_SHADER_1_4) && + Driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) + return 0; + + return 1; + } + + + //! Called by the engine when the vertex and/or pixel shader constants for an + //! material renderer should be set. + void CD3D8ParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) + { + video::IVideoDriver* driver = services->getVideoDriver(); + + // set transposed world matrix + services->setVertexShaderConstant(driver->getTransform(video::ETS_WORLD).getTransposed().pointer(), 0, 4); + + // set eye position + + // The viewpoint is at (0., 0., 0.) in eye space. + // Turning this into a vector [0 0 0 1] and multiply it by + // the inverse of the view matrix, the resulting vector is the + // object space location of the camera. + + f32 floats[4] = {0,0,0,1}; + core::matrix4 minv(driver->getTransform(video::ETS_VIEW)); + minv.makeInverse(); + minv.multiplyWith1x4Matrix(floats); + services->setVertexShaderConstant(floats, 4, 1); + + // set transposed worldViewProj matrix + core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); + worldViewProj *= driver->getTransform(video::ETS_VIEW); + worldViewProj *= driver->getTransform(video::ETS_WORLD); + services->setVertexShaderConstant(worldViewProj.getTransposed().pointer(), 8, 4); + + // here we've got to fetch the fixed function lights from the driver + // and set them as constants + + u32 cnt = driver->getDynamicLightCount(); + + for (u32 i=0; i<2; ++i) + { + SLight light; + + if (igetDynamicLight(i); + else + { + light.DiffuseColor.set(0,0,0); // make light dark + light.Radius = 1.0f; + } + + light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation + + services->setVertexShaderConstant(reinterpret_cast(&light.Position), 12+(i*2), 1); + services->setVertexShaderConstant(reinterpret_cast(&light.DiffuseColor), 13+(i*2), 1); + } + + // this is not really necessary in d3d9 (used a def instruction), but to be sure: + f32 c95[] = {0.5f, 0.5f, 0.5f, 0.5f}; + services->setVertexShaderConstant(c95, 95, 1); + f32 c96[] = {-1, 1, 1, 1}; + services->setVertexShaderConstant(c96, 96, 1); + + // set scale factor + f32 factor = 0.02f; // default value + if (CurrentScale != 0) + factor = CurrentScale; + + f32 c6[] = {factor, factor, factor, 0}; + services->setPixelShaderConstant(c6, 6, 1); + } + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CD3D8ParallaxMapRenderer.h b/src/dep/src/irrlicht/CD3D8ParallaxMapRenderer.h index 9d8306d..1c3e4e7 100644 --- a/src/dep/src/irrlicht/CD3D8ParallaxMapRenderer.h +++ b/src/dep/src/irrlicht/CD3D8ParallaxMapRenderer.h @@ -1,61 +1,61 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D8_PARALLAX_MAPMATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D8_PARALLAX_MAPMATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ -#include "d3d8.h" - -#include "CD3D8ShaderMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" - -namespace irr -{ -namespace video -{ - -//! Renderer for parallax maps -class CD3D8ParallaxMapRenderer : public CD3D8ShaderMaterialRenderer, IShaderConstantSetCallBack -{ -public: - - CD3D8ParallaxMapRenderer( - IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); - ~CD3D8ParallaxMapRenderer(); - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); - - bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - void OnSetMaterial(video::SMaterial& material, - const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services); - - //! Returns the render capability of the material. - virtual s32 getRenderCapability(); - -private: - - //! stores if this shader compiled the shaders and is - //! allowed to delete them again. D3D8 lacks reference counting - //! support for shaders. - bool CompiledShaders; - - f32 CurrentScale; -}; - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_D3D8_PARALLAX_MAPMATERIAL_RENDERER_H_INCLUDED__ +#define __C_D3D8_PARALLAX_MAPMATERIAL_RENDERER_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_WINDOWS_ + +#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ +#include "d3d8.h" + +#include "CD3D8ShaderMaterialRenderer.h" +#include "IShaderConstantSetCallBack.h" + +namespace irr +{ +namespace video +{ + +//! Renderer for parallax maps +class CD3D8ParallaxMapRenderer : public CD3D8ShaderMaterialRenderer, IShaderConstantSetCallBack +{ +public: + + CD3D8ParallaxMapRenderer( + IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, + s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); + ~CD3D8ParallaxMapRenderer(); + + //! Called by the engine when the vertex and/or pixel shader constants for an + //! material renderer should be set. + virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); + + bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); + + void OnSetMaterial(video::SMaterial& material, + const video::SMaterial& lastMaterial, + bool resetAllRenderstates, video::IMaterialRendererServices* services); + + //! Returns the render capability of the material. + virtual s32 getRenderCapability(); + +private: + + //! stores if this shader compiled the shaders and is + //! allowed to delete them again. D3D8 lacks reference counting + //! support for shaders. + bool CompiledShaders; + + f32 CurrentScale; +}; + +} // end namespace video +} // end namespace irr + +#endif +#endif +#endif + diff --git a/src/dep/src/irrlicht/CD3D8ShaderMaterialRenderer.cpp b/src/dep/src/irrlicht/CD3D8ShaderMaterialRenderer.cpp index a25030b..6c19a0f 100644 --- a/src/dep/src/irrlicht/CD3D8ShaderMaterialRenderer.cpp +++ b/src/dep/src/irrlicht/CD3D8ShaderMaterialRenderer.cpp @@ -1,316 +1,316 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CD3D8ShaderMaterialRenderer.h" - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ -#include "d3d8.h" -#include "d3dx8core.h" -//#pragma comment (lib, "d3dx8.lib") - -#include "IShaderConstantSetCallBack.h" -#include "IMaterialRendererServices.h" -#include "IVideoDriver.h" -#include "os.h" - -#ifndef _IRR_D3D_NO_SHADER_DEBUGGING -#include -#endif - -namespace irr -{ -namespace video -{ - -//! Public constructor -CD3D8ShaderMaterialRenderer::CD3D8ShaderMaterialRenderer(IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData) -: pID3DDevice(d3ddev), Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), - VertexShader(0), OldVertexShader(0), PixelShader(0), UserData(userData) -{ - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); - - init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram, EVT_STANDARD); -} - -//! constructor only for use by derived classes who want to -//! create a fall back material for example. -CD3D8ShaderMaterialRenderer::CD3D8ShaderMaterialRenderer(IDirect3DDevice8* d3ddev, - video::IVideoDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, - s32 userData) -: pID3DDevice(d3ddev), Driver(driver), BaseMaterial(baseMaterial), CallBack(callback), - VertexShader(0), PixelShader(0), UserData(userData) -{ - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); -} - - - -//! Destructor -CD3D8ShaderMaterialRenderer::~CD3D8ShaderMaterialRenderer() -{ - if (CallBack) - CallBack->drop(); - - if (VertexShader) - pID3DDevice->DeleteVertexShader(VertexShader); - - if (PixelShader) - pID3DDevice->DeletePixelShader(PixelShader); - - if (BaseMaterial) - BaseMaterial->drop (); -} - - -void CD3D8ShaderMaterialRenderer::init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, - const c8* pixelShaderProgram, E_VERTEX_TYPE type) -{ - outMaterialTypeNr = -1; - - // create vertex shader - if (!createVertexShader(vertexShaderProgram, type)) - return; - - // create pixel shader - if (!createPixelShader(pixelShaderProgram)) - return; - - // register myself as new material - outMaterialTypeNr = Driver->addMaterialRenderer(this); -} - - -bool CD3D8ShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) -{ - // call callback to set shader constants - if (CallBack && (VertexShader || PixelShader)) - CallBack->OnSetConstants(service, UserData); - - return true; -} - - -void CD3D8ShaderMaterialRenderer::OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services) -{ - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (VertexShader) - { - // We do not need to save and reset the old vertex shader, because - // in D3D8, this is mixed up with the fvf, and this is set by the driver - // every time. - //pID3DDevice->GetVertexShader(&OldVertexShader); - - // set new vertex shader - if (FAILED(pID3DDevice->SetVertexShader(VertexShader))) - os::Printer::log("Could not set vertex shader."); - } - - // set new pixel shader - if (PixelShader) - { - if (FAILED(pID3DDevice->SetPixelShader(PixelShader))) - os::Printer::log("Could not set pixel shader."); - } - - if (BaseMaterial) - BaseMaterial->OnSetMaterial(material, material, true, services); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); -} - -void CD3D8ShaderMaterialRenderer::OnUnsetMaterial() -{ - // We do not need to save and reset the old vertex shader, because - // in D3D8, this is mixed up with the fvf, and this is set by the driver - // every time. - // if (VertexShader) - // pID3DDevice->SetVertexShader(OldVertexShader); - - if (PixelShader) - pID3DDevice->SetPixelShader(0); - - if (BaseMaterial) - BaseMaterial->OnUnsetMaterial(); -} - - -//! Returns if the material is transparent. The scene managment needs to know this -//! for being able to sort the materials by opaque and transparent. -bool CD3D8ShaderMaterialRenderer::isTransparent() -{ - return BaseMaterial ? BaseMaterial->isTransparent() : false; -} - -bool CD3D8ShaderMaterialRenderer::createPixelShader(const c8* pxsh) -{ - if (!pxsh) - return true; - - // compile shader - - LPD3DXBUFFER code = 0; - LPD3DXBUFFER errors = 0; - - #ifdef _IRR_D3D_NO_SHADER_DEBUGGING - - // compile shader without debug info - D3DXAssembleShader(pxsh, strlen(pxsh), 0, 0, &code, &errors); - - #else - - // compile shader and emitt some debug informations to - // make it possible to debug the shader in visual studio - - static int irr_dbg_file_nr = 0; - ++irr_dbg_file_nr; - char tmp[32]; - sprintf(tmp, "irr_d3d8_dbg_shader_%d.psh", irr_dbg_file_nr); - - FILE* f = fopen(tmp, "wb"); - fwrite(pxsh, strlen(pxsh), 1, f); - fflush(f); - fclose(f); - - D3DXAssembleShaderFromFile(tmp, D3DXASM_DEBUG, 0, &code, &errors); - - #endif - - if (errors) - { - // print out compilation errors. - os::Printer::log("Pixel shader compilation failed:"); - os::Printer::log((c8*)errors->GetBufferPointer()); - - if (code) - code->Release(); - - errors->Release(); - return false; - } - - if (FAILED(pID3DDevice->CreatePixelShader((DWORD*)code->GetBufferPointer(), &PixelShader))) - { - os::Printer::log("Could not create pixel shader."); - code->Release(); - return false; - } - - code->Release(); - return true; -} - - - -bool CD3D8ShaderMaterialRenderer::createVertexShader(const char* vtxsh, E_VERTEX_TYPE type) -{ - if (!vtxsh) - return true; - - // compile shader - - LPD3DXBUFFER code = 0; - LPD3DXBUFFER errors = 0; - - #ifdef _IRR_D3D_NO_SHADER_DEBUGGING - - // compile shader without debug info - D3DXAssembleShader(vtxsh, strlen(vtxsh), 0, 0, &code, &errors); - - #else - - // compile shader and emitt some debug informations to - // make it possible to debug the shader in visual studio - static int irr_dbg_file_nr = 0; - ++irr_dbg_file_nr; - char tmp[32]; - sprintf(tmp, "irr_d3d8_dbg_shader_%d.vsh", irr_dbg_file_nr); - - FILE* f = fopen(tmp, "wb"); - fwrite(vtxsh, strlen(vtxsh), 1, f); - fflush(f); - fclose(f); - - D3DXAssembleShaderFromFile(tmp, D3DXASM_DEBUG, 0, &code, &errors); - - #endif - - - if (errors) - { - // print out compilation errors. - os::Printer::log("Vertex shader compilation failed:"); - os::Printer::log((c8*)errors->GetBufferPointer()); - - if (code) - code->Release(); - - errors->Release(); - return false; - } - - DWORD* decl = 0; - - DWORD dwStdDecl[] = - { - D3DVSD_STREAM(0), - D3DVSD_REG(0, D3DVSDT_FLOAT3), // position 0 - D3DVSD_REG(1, D3DVSDT_FLOAT3), // normal 1 - D3DVSD_REG(2, D3DVSDT_D3DCOLOR ),// color 2 - D3DVSD_REG(3, D3DVSDT_FLOAT2 ), // tex1 3 - D3DVSD_REG(4, D3DVSDT_FLOAT2 ), // tex2 4 - D3DVSD_END() - }; - - DWORD dwTngtDecl[] = - { - D3DVSD_STREAM(0), - D3DVSD_REG(0 , D3DVSDT_FLOAT3), // position 0 - D3DVSD_REG(1 , D3DVSDT_FLOAT3), // normal 1 - D3DVSD_REG(2 , D3DVSDT_D3DCOLOR ),// color 2 - D3DVSD_REG(3 , D3DVSDT_FLOAT2 ), // tex1 3 - D3DVSD_REG(4, D3DVSDT_FLOAT3 ), // tangent 4 - D3DVSD_REG(5, D3DVSDT_FLOAT3 ), // binormal 5 - D3DVSD_END() - }; - - if (type == EVT_TANGENTS) - decl = dwTngtDecl; - else - decl = dwStdDecl; - - if (FAILED(pID3DDevice->CreateVertexShader(decl, - (DWORD*)code->GetBufferPointer(), &VertexShader, 0))) - { - os::Printer::log("Could not create vertex shader."); - code->Release(); - return false; - } - - code->Release(); - return true; -} - - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CD3D8ShaderMaterialRenderer.h" + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ +#include "d3d8.h" +#include "d3dx8core.h" +//#pragma comment (lib, "d3dx8.lib") + +#include "IShaderConstantSetCallBack.h" +#include "IMaterialRendererServices.h" +#include "IVideoDriver.h" +#include "os.h" + +#ifndef _IRR_D3D_NO_SHADER_DEBUGGING +#include +#endif + +namespace irr +{ +namespace video +{ + +//! Public constructor +CD3D8ShaderMaterialRenderer::CD3D8ShaderMaterialRenderer(IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, + s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, + IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData) +: pID3DDevice(d3ddev), Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), + VertexShader(0), OldVertexShader(0), PixelShader(0), UserData(userData) +{ + if (BaseMaterial) + BaseMaterial->grab(); + + if (CallBack) + CallBack->grab(); + + init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram, EVT_STANDARD); +} + +//! constructor only for use by derived classes who want to +//! create a fall back material for example. +CD3D8ShaderMaterialRenderer::CD3D8ShaderMaterialRenderer(IDirect3DDevice8* d3ddev, + video::IVideoDriver* driver, + IShaderConstantSetCallBack* callback, + IMaterialRenderer* baseMaterial, + s32 userData) +: pID3DDevice(d3ddev), Driver(driver), BaseMaterial(baseMaterial), CallBack(callback), + VertexShader(0), PixelShader(0), UserData(userData) +{ + if (BaseMaterial) + BaseMaterial->grab(); + + if (CallBack) + CallBack->grab(); +} + + + +//! Destructor +CD3D8ShaderMaterialRenderer::~CD3D8ShaderMaterialRenderer() +{ + if (CallBack) + CallBack->drop(); + + if (VertexShader) + pID3DDevice->DeleteVertexShader(VertexShader); + + if (PixelShader) + pID3DDevice->DeletePixelShader(PixelShader); + + if (BaseMaterial) + BaseMaterial->drop (); +} + + +void CD3D8ShaderMaterialRenderer::init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, + const c8* pixelShaderProgram, E_VERTEX_TYPE type) +{ + outMaterialTypeNr = -1; + + // create vertex shader + if (!createVertexShader(vertexShaderProgram, type)) + return; + + // create pixel shader + if (!createPixelShader(pixelShaderProgram)) + return; + + // register myself as new material + outMaterialTypeNr = Driver->addMaterialRenderer(this); +} + + +bool CD3D8ShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) +{ + // call callback to set shader constants + if (CallBack && (VertexShader || PixelShader)) + CallBack->OnSetConstants(service, UserData); + + return true; +} + + +void CD3D8ShaderMaterialRenderer::OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, + bool resetAllRenderstates, video::IMaterialRendererServices* services) +{ + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + if (VertexShader) + { + // We do not need to save and reset the old vertex shader, because + // in D3D8, this is mixed up with the fvf, and this is set by the driver + // every time. + //pID3DDevice->GetVertexShader(&OldVertexShader); + + // set new vertex shader + if (FAILED(pID3DDevice->SetVertexShader(VertexShader))) + os::Printer::log("Could not set vertex shader."); + } + + // set new pixel shader + if (PixelShader) + { + if (FAILED(pID3DDevice->SetPixelShader(PixelShader))) + os::Printer::log("Could not set pixel shader."); + } + + if (BaseMaterial) + BaseMaterial->OnSetMaterial(material, material, true, services); + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); +} + +void CD3D8ShaderMaterialRenderer::OnUnsetMaterial() +{ + // We do not need to save and reset the old vertex shader, because + // in D3D8, this is mixed up with the fvf, and this is set by the driver + // every time. + // if (VertexShader) + // pID3DDevice->SetVertexShader(OldVertexShader); + + if (PixelShader) + pID3DDevice->SetPixelShader(0); + + if (BaseMaterial) + BaseMaterial->OnUnsetMaterial(); +} + + +//! Returns if the material is transparent. The scene managment needs to know this +//! for being able to sort the materials by opaque and transparent. +bool CD3D8ShaderMaterialRenderer::isTransparent() +{ + return BaseMaterial ? BaseMaterial->isTransparent() : false; +} + +bool CD3D8ShaderMaterialRenderer::createPixelShader(const c8* pxsh) +{ + if (!pxsh) + return true; + + // compile shader + + LPD3DXBUFFER code = 0; + LPD3DXBUFFER errors = 0; + + #ifdef _IRR_D3D_NO_SHADER_DEBUGGING + + // compile shader without debug info + D3DXAssembleShader(pxsh, strlen(pxsh), 0, 0, &code, &errors); + + #else + + // compile shader and emitt some debug informations to + // make it possible to debug the shader in visual studio + + static int irr_dbg_file_nr = 0; + ++irr_dbg_file_nr; + char tmp[32]; + sprintf(tmp, "irr_d3d8_dbg_shader_%d.psh", irr_dbg_file_nr); + + FILE* f = fopen(tmp, "wb"); + fwrite(pxsh, strlen(pxsh), 1, f); + fflush(f); + fclose(f); + + D3DXAssembleShaderFromFile(tmp, D3DXASM_DEBUG, 0, &code, &errors); + + #endif + + if (errors) + { + // print out compilation errors. + os::Printer::log("Pixel shader compilation failed:"); + os::Printer::log((c8*)errors->GetBufferPointer()); + + if (code) + code->Release(); + + errors->Release(); + return false; + } + + if (FAILED(pID3DDevice->CreatePixelShader((DWORD*)code->GetBufferPointer(), &PixelShader))) + { + os::Printer::log("Could not create pixel shader."); + code->Release(); + return false; + } + + code->Release(); + return true; +} + + + +bool CD3D8ShaderMaterialRenderer::createVertexShader(const char* vtxsh, E_VERTEX_TYPE type) +{ + if (!vtxsh) + return true; + + // compile shader + + LPD3DXBUFFER code = 0; + LPD3DXBUFFER errors = 0; + + #ifdef _IRR_D3D_NO_SHADER_DEBUGGING + + // compile shader without debug info + D3DXAssembleShader(vtxsh, strlen(vtxsh), 0, 0, &code, &errors); + + #else + + // compile shader and emitt some debug informations to + // make it possible to debug the shader in visual studio + static int irr_dbg_file_nr = 0; + ++irr_dbg_file_nr; + char tmp[32]; + sprintf(tmp, "irr_d3d8_dbg_shader_%d.vsh", irr_dbg_file_nr); + + FILE* f = fopen(tmp, "wb"); + fwrite(vtxsh, strlen(vtxsh), 1, f); + fflush(f); + fclose(f); + + D3DXAssembleShaderFromFile(tmp, D3DXASM_DEBUG, 0, &code, &errors); + + #endif + + + if (errors) + { + // print out compilation errors. + os::Printer::log("Vertex shader compilation failed:"); + os::Printer::log((c8*)errors->GetBufferPointer()); + + if (code) + code->Release(); + + errors->Release(); + return false; + } + + DWORD* decl = 0; + + DWORD dwStdDecl[] = + { + D3DVSD_STREAM(0), + D3DVSD_REG(0, D3DVSDT_FLOAT3), // position 0 + D3DVSD_REG(1, D3DVSDT_FLOAT3), // normal 1 + D3DVSD_REG(2, D3DVSDT_D3DCOLOR ),// color 2 + D3DVSD_REG(3, D3DVSDT_FLOAT2 ), // tex1 3 + D3DVSD_REG(4, D3DVSDT_FLOAT2 ), // tex2 4 + D3DVSD_END() + }; + + DWORD dwTngtDecl[] = + { + D3DVSD_STREAM(0), + D3DVSD_REG(0 , D3DVSDT_FLOAT3), // position 0 + D3DVSD_REG(1 , D3DVSDT_FLOAT3), // normal 1 + D3DVSD_REG(2 , D3DVSDT_D3DCOLOR ),// color 2 + D3DVSD_REG(3 , D3DVSDT_FLOAT2 ), // tex1 3 + D3DVSD_REG(4, D3DVSDT_FLOAT3 ), // tangent 4 + D3DVSD_REG(5, D3DVSDT_FLOAT3 ), // binormal 5 + D3DVSD_END() + }; + + if (type == EVT_TANGENTS) + decl = dwTngtDecl; + else + decl = dwStdDecl; + + if (FAILED(pID3DDevice->CreateVertexShader(decl, + (DWORD*)code->GetBufferPointer(), &VertexShader, 0))) + { + os::Printer::log("Could not create vertex shader."); + code->Release(); + return false; + } + + code->Release(); + return true; +} + + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CD3D8ShaderMaterialRenderer.h b/src/dep/src/irrlicht/CD3D8ShaderMaterialRenderer.h index 9ac1eb4..149658c 100644 --- a/src/dep/src/irrlicht/CD3D8ShaderMaterialRenderer.h +++ b/src/dep/src/irrlicht/CD3D8ShaderMaterialRenderer.h @@ -1,82 +1,82 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D8_SHADER_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D8_SHADER_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ -#include "d3d8.h" -#include "d3dx8core.h" - -#include "IMaterialRenderer.h" -#include "S3DVertex.h" - -namespace irr -{ -namespace video -{ - -class IVideoDriver; -class IShaderConstantSetCallBack; -class IMaterialRenderer; - -//! Class for using vertex and pixel shaders with D3D8 -class CD3D8ShaderMaterialRenderer : public IMaterialRenderer -{ -public: - - //! Public constructor - CD3D8ShaderMaterialRenderer(IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData); - - //! Destructor - ~CD3D8ShaderMaterialRenderer(); - - virtual void OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services); - - virtual void OnUnsetMaterial(); - - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - //! Returns if the material is transparent. - virtual bool isTransparent(); - -protected: - - //! constructor only for use by derived classes who want to - //! create a fall back material for example. - CD3D8ShaderMaterialRenderer(IDirect3DDevice8* d3ddev, - video::IVideoDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, s32 userData=0); - - void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, - E_VERTEX_TYPE type); - bool createPixelShader(const c8* pxsh); - bool createVertexShader(const char* vtxsh, E_VERTEX_TYPE type); - - IDirect3DDevice8* pID3DDevice; - video::IVideoDriver* Driver; - IShaderConstantSetCallBack* CallBack; - IMaterialRenderer* BaseMaterial; - - DWORD VertexShader; - DWORD OldVertexShader; - DWORD PixelShader; - s32 UserData; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_D3D8_SHADER_MATERIAL_RENDERER_H_INCLUDED__ +#define __C_D3D8_SHADER_MATERIAL_RENDERER_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_WINDOWS_ + +#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ +#include "d3d8.h" +#include "d3dx8core.h" + +#include "IMaterialRenderer.h" +#include "S3DVertex.h" + +namespace irr +{ +namespace video +{ + +class IVideoDriver; +class IShaderConstantSetCallBack; +class IMaterialRenderer; + +//! Class for using vertex and pixel shaders with D3D8 +class CD3D8ShaderMaterialRenderer : public IMaterialRenderer +{ +public: + + //! Public constructor + CD3D8ShaderMaterialRenderer(IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, + s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, + IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData); + + //! Destructor + ~CD3D8ShaderMaterialRenderer(); + + virtual void OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, + bool resetAllRenderstates, video::IMaterialRendererServices* services); + + virtual void OnUnsetMaterial(); + + virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); + + //! Returns if the material is transparent. + virtual bool isTransparent(); + +protected: + + //! constructor only for use by derived classes who want to + //! create a fall back material for example. + CD3D8ShaderMaterialRenderer(IDirect3DDevice8* d3ddev, + video::IVideoDriver* driver, + IShaderConstantSetCallBack* callback, + IMaterialRenderer* baseMaterial, s32 userData=0); + + void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, + E_VERTEX_TYPE type); + bool createPixelShader(const c8* pxsh); + bool createVertexShader(const char* vtxsh, E_VERTEX_TYPE type); + + IDirect3DDevice8* pID3DDevice; + video::IVideoDriver* Driver; + IShaderConstantSetCallBack* CallBack; + IMaterialRenderer* BaseMaterial; + + DWORD VertexShader; + DWORD OldVertexShader; + DWORD PixelShader; + s32 UserData; +}; + + +} // end namespace video +} // end namespace irr + +#endif +#endif +#endif + diff --git a/src/dep/src/irrlicht/CD3D8Texture.cpp b/src/dep/src/irrlicht/CD3D8Texture.cpp index 4d8fa4f..73fdc90 100644 --- a/src/dep/src/irrlicht/CD3D8Texture.cpp +++ b/src/dep/src/irrlicht/CD3D8Texture.cpp @@ -1,801 +1,801 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - -#define _IRR_DONT_DO_MEMORY_DEBUGGING_HERE -#include "CD3D8Texture.h" -#include "CD3D8Driver.h" -#include "os.h" - - -#ifndef _IRR_COMPILE_WITH_DIRECT3D_9_ -// The D3DXFilterTexture function seems to get linked wrong when -// compiling with both D3D8 and 9, causing it not to work in the D3D9 device. -// So mipmapgeneration is replaced with my own bad generation in d3d 8 when -// compiling with both D3D 8 and 9. -//#define _IRR_USE_D3DXFilterTexture_ -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ - -#include "d3dx8tex.h" - -#ifdef _IRR_USE_D3DXFilterTexture_ -//#pragma comment (lib, "d3dx8.lib") -#endif // _IRR_USE_D3DXFilterTexture_ - -namespace irr -{ -namespace video -{ - -//! rendertarget constructor -CD3D8Texture::CD3D8Texture(CD3D8Driver* driver, core::dimension2d size, const char* name) -: ITexture(name), Image(0), Texture(0), RTTSurface(0), Driver(driver), - TextureSize(size), ImageSize(size), Pitch(0), SurfaceHasSameSize(true), - HasMipMaps(false), IsRenderTarget(true) -{ - #ifdef _DEBUG - setDebugName("CD3D8Texture"); - #endif - - Device=driver->getExposedVideoData().D3D8.D3DDev8; - if (Device) - Device->AddRef(); - - createRenderTarget(); -} - - -//! constructor -CD3D8Texture::CD3D8Texture(IImage* image, CD3D8Driver* driver, - u32 flags, const char* name) -: ITexture(name), Image(image), Texture(0), RTTSurface(0), Driver(driver), -TextureSize(0,0), ImageSize(0,0), Pitch(0), SurfaceHasSameSize(true), -HasMipMaps(false), IsRenderTarget(false) -{ - #ifdef _DEBUG - setDebugName("CD3D8Texture"); - #endif - - bool generateMipLevels = (flags & video::ETCF_CREATE_MIP_MAPS) != 0; - - Device=driver->getExposedVideoData().D3D8.D3DDev8; - if (Device) - Device->AddRef(); - - if (Image) - { - Image->grab(); - - createTexture(flags); - - if (Texture) - { - if (copyTexture() && generateMipLevels) - { - // create mip maps. - - #ifndef _IRR_USE_D3DXFilterTexture_ - // The D3DXFilterTexture function seems to get linked wrong when - // compiling with both D3D8 and 9, causing it not to work in the D3D9 device. - // So mipmapgeneration is replaced with my own bad generation in d3d 8 when - // compiling with both D3D 8 and 9. - HRESULT hr = D3DXFilterTexture(Texture, NULL, D3DX_DEFAULT , D3DX_DEFAULT ); - if (FAILED(hr)) - os::Printer::log("Could not create direct3d mip map levels.", ELL_WARNING); - else - HasMipMaps = true; - #else - createMipMaps(); - HasMipMaps = true; - #endif - } - } - else - os::Printer::log("Could not create DIRECT3D8 Texture.", ELL_WARNING); - } -} - - - -//! creates the hardware texture -void CD3D8Texture::createTexture(u32 flags) -{ - core::dimension2d optSize; - ImageSize = Image->getDimension(); - - if (Driver->queryFeature(EVDF_TEXTURE_NPOT)) - optSize=ImageSize; - else - { - optSize.Width = getTextureSizeFromImageSize(ImageSize.Width); - optSize.Height = getTextureSizeFromImageSize(ImageSize.Height); - } - - HRESULT hr; - D3DFORMAT format = D3DFMT_A1R5G5B5; - - switch(getTextureFormatFromFlags(flags)) - { - case ETCF_ALWAYS_16_BIT: - format = D3DFMT_A1R5G5B5; break; - case ETCF_ALWAYS_32_BIT: - format = D3DFMT_A8R8G8B8; break; - case ETCF_OPTIMIZED_FOR_QUALITY: - { - switch(Image->getColorFormat()) - { - case ECF_R8G8B8: - case ECF_A8R8G8B8: - format = D3DFMT_A8R8G8B8; break; - case ECF_A1R5G5B5: - case ECF_R5G6B5: - format = D3DFMT_A1R5G5B5; break; - } - } - break; - case ETCF_OPTIMIZED_FOR_SPEED: - format = D3DFMT_A1R5G5B5; break; - } - - bool mipmaps = (flags & video::ETCF_CREATE_MIP_MAPS) != 0; - - hr = Device->CreateTexture(optSize.Width, optSize.Height, - mipmaps ? 0 : 1, // number of mipmaplevels (0 = automatic all) - 0, format, D3DPOOL_MANAGED, &Texture); - - if (FAILED(hr) && format == D3DFMT_A8R8G8B8) - { - // try brute force 16 bit - - format = D3DFMT_A1R5G5B5; - - hr = Device->CreateTexture(optSize.Width, optSize.Height, - (flags & ETCF_CREATE_MIP_MAPS) ? 0 : 1, // number of mipmaplevels (0 = automatic all) - 0, D3DFMT_A1R5G5B5, D3DPOOL_MANAGED, &Texture); - } - - ColorFormat = (format == D3DFMT_A1R5G5B5) ? ECF_A1R5G5B5 : ECF_A8R8G8B8; -} - - - -//! copies the image to the texture -bool CD3D8Texture::copyTexture() -{ - if (Texture && Image) - { - D3DSURFACE_DESC desc; - Texture->GetLevelDesc(0, &desc); - - TextureSize.Width = desc.Width; - TextureSize.Height = desc.Height; - - SurfaceHasSameSize = (TextureSize == ImageSize); - - if (desc.Format == D3DFMT_A1R5G5B5) - return copyTo16BitTexture(); - else - if (desc.Format == D3DFMT_A8R8G8B8) - return copyTo32BitTexture(); - else - os::Printer::log("CD3D8Texture: Unsupported D3D8 hardware texture format", ELL_ERROR); - } - - return true; -} - - -//! copies texture to 32 bit hardware texture -bool CD3D8Texture::copyTo32BitTexture() -{ - D3DLOCKED_RECT rect; - HRESULT hr = Texture->LockRect(0, &rect, 0, 0); - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D8 32 bit Texture.", ELL_ERROR); - return false; - } - - u32* dest = (u32*)rect.pBits; - u32* source = (u32*)Image->lock(); - Pitch = rect.Pitch; - s32 pitch = rect.Pitch / 4; - - if (SurfaceHasSameSize) - { - if (Image->getColorFormat() == ECF_A8R8G8B8) - { - // direct copy, fast - - for (s32 y=0; ygetPixel(x,y).color; - } - } - else - { - // scale texture - - f32 sourceXStep = (f32)ImageSize.Width / (f32)TextureSize.Width; - f32 sourceYStep = (f32)ImageSize.Height / (f32)TextureSize.Height; - f32 sy; - - if (Image->getColorFormat() == ECF_A8R8G8B8) - { - // copy texture scaling - - for (s32 x=0; xgetPixel((s32)(x*sourceXStep), (s32)sy).color; - - sy+=sourceYStep; - } - } - } - } - - Image->unlock(); - - hr = Texture->UnlockRect(0); - if (FAILED(hr)) - { - os::Printer::log("Could not unlock DIRECT3D8 Texture.", ELL_ERROR); - return false; - } - - return true; - -} - - -//! optimized for 16 bit to 16 copy. -bool CD3D8Texture::copyTo16BitTexture() -{ - D3DLOCKED_RECT rect; - HRESULT hr = Texture->LockRect(0, &rect, 0, 0); - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D8 16 bit Texture.", ELL_ERROR); - return false; - } - - s16* dest = (s16*)rect.pBits; - s16* source = (s16*)Image->lock(); - Pitch = rect.Pitch; - s32 pitch = rect.Pitch/2; - - if (SurfaceHasSameSize) - { - // copy texture - - if (Image->getColorFormat() == ECF_A1R5G5B5) - { - // direct copy, fast - - for (s32 y=0; ygetPixel(x,y).toA1R5G5B5(); - } - } - else - { - // scale texture - - f32 sourceXStep = (f32)ImageSize.Width / (f32)TextureSize.Width; - f32 sourceYStep = (f32)ImageSize.Height / (f32)TextureSize.Height; - f32 sy; - - if (Image->getColorFormat() == ECF_A1R5G5B5) - { - // copy texture scaling - - for (s32 x=0; xgetPixel((s32)(x*sourceXStep), (s32)sy).toA1R5G5B5(); - - sy+=sourceYStep; - } - } - } - } - - Image->unlock(); - - hr = Texture->UnlockRect(0); - if (FAILED(hr)) - { - os::Printer::log("Could not unlock DIRECT3D8 16 bit Texture.", ELL_ERROR); - return false; - } - - return true; -} - - - -//! destructor -CD3D8Texture::~CD3D8Texture() -{ - if (Device) - Device->Release(); - - if (Image) - Image->drop(); - - if (Texture) - Texture->Release(); - - if (RTTSurface) - RTTSurface->Release(); -} - - - -//! lock function -void* CD3D8Texture::lock() -{ - if (!Texture) - return 0; - - HRESULT hr; - D3DLOCKED_RECT rect; - if(!IsRenderTarget) - { - hr = Texture->LockRect(0, &rect, 0, 0); - } - else - { - D3DSURFACE_DESC desc; - Texture->GetLevelDesc(0, &desc); - if (!RTTSurface) - { - hr = Device->CreateImageSurface(desc.Width, desc.Height, desc.Format, &RTTSurface); - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); - return 0; - } - } - - IDirect3DSurface8 *surface = NULL; - hr = Texture->GetSurfaceLevel(0, &surface); - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); - return 0; - } - hr = Device->CopyRects(surface, NULL, 0, RTTSurface, NULL); - if(FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); - return 0; - } - hr = RTTSurface->LockRect(&rect, NULL, 0); - if(FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); - return 0; - } - return rect.pBits; - } - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); - return 0; - } - - return rect.pBits; -} - - - -//! unlock function -void CD3D8Texture::unlock() -{ - if (!Texture) - return; - - if (!IsRenderTarget) - Texture->UnlockRect(0); - else if (RTTSurface) - RTTSurface->UnlockRect(); -} - - -//! Returns original size of the texture. -const core::dimension2d& CD3D8Texture::getOriginalSize() -{ - return ImageSize; -} - - -//! Returns (=size) of the texture. -const core::dimension2d& CD3D8Texture::getSize() -{ - return TextureSize; -} - - -//! returns the size of a texture which would be the optimize size for rendering it -inline s32 CD3D8Texture::getTextureSizeFromImageSize(s32 size) -{ - s32 ts = 0x01; - - while(ts < size) - ts <<= 1; - - if (ts > size && ts > 64) - ts >>= 1; - - return ts; -} - - - -//! returns driver type of texture (=the driver, who created the texture) -E_DRIVER_TYPE CD3D8Texture::getDriverType() -{ - return EDT_DIRECT3D8; -} - - - -//! returns color format of texture -ECOLOR_FORMAT CD3D8Texture::getColorFormat() const -{ - return ColorFormat; -} - - - -//! returns pitch of texture (in bytes) -u32 CD3D8Texture::getPitch() const -{ - return Pitch; -} - - - -//! returns the DIRECT3D8 Texture -IDirect3DTexture8* CD3D8Texture::getDX8Texture() -{ - return Texture; -} - - -//! returns if texture has mipmap levels -bool CD3D8Texture::hasMipMaps() -{ - return HasMipMaps; -} - - -bool CD3D8Texture::createMipMaps(s32 level) -{ - // The D3DXFilterTexture function seems to get linked wrong when - // compiling with both D3D8 and 9, causing it not to work in the D3D9 device. - // So mipmapgeneration is replaced with my own bad generation in d3d 8 when - // compiling with both D3D 8 and 9. - - IDirect3DSurface8* upperSurface = 0; - IDirect3DSurface8* lowerSurface = 0; - - // get upper level - HRESULT hr = Texture->GetSurfaceLevel(level-1, &upperSurface); - if (FAILED(hr) || !upperSurface) - { - os::Printer::log("Could not get upper surface level for mip map generation", ELL_WARNING); - return false; - } - - // get lower level - hr = Texture->GetSurfaceLevel(level, &lowerSurface); - if (FAILED(hr) || !lowerSurface) - { - os::Printer::log("Could not get lower surface level for mip map generation", ELL_WARNING); - upperSurface->Release(); - return false; - } - - D3DSURFACE_DESC upperDesc, lowerDesc; - upperSurface->GetDesc(&upperDesc); - lowerSurface->GetDesc(&lowerDesc); - - - D3DLOCKED_RECT upperlr; - D3DLOCKED_RECT lowerlr; - - // lock upper surface - if (FAILED(upperSurface->LockRect(&upperlr, NULL, 0))) - { - os::Printer::log("Could not lock upper texture for mip map generation", ELL_WARNING); - return false; - } - - // lock lower surface - if (FAILED(lowerSurface->LockRect(&lowerlr, NULL, 0))) - { - os::Printer::log("Could not lock lower texture for mip map generation", ELL_WARNING); - return false; - } - - if (upperDesc.Format != lowerDesc.Format) - { - os::Printer::log("Cannot copy mip maps with different formats.", ELL_WARNING); - } - else - { - if (upperDesc.Format == D3DFMT_A1R5G5B5) - copy16BitMipMap((char*)upperlr.pBits, (char*)lowerlr.pBits, - lowerDesc.Width, lowerDesc.Height, - upperlr.Pitch, lowerlr.Pitch); - else - if (upperDesc.Format == D3DFMT_A8R8G8B8) - copy32BitMipMap((char*)upperlr.pBits, (char*)lowerlr.pBits, - lowerDesc.Width, lowerDesc.Height, - upperlr.Pitch, lowerlr.Pitch); - else - os::Printer::log("Unsupported mipmap format, cannot copy.", ELL_WARNING); - } - - // unlock - if (FAILED(upperSurface->UnlockRect())) - return false; - if (FAILED(lowerSurface->UnlockRect())) - return false; - - // release - upperSurface->Release(); - lowerSurface->Release(); - - if (upperDesc.Width <= 2 || upperDesc.Height <= 2) - return true; // stop generating levels - - // generate next level - return createMipMaps(level+1); -} - - - -void CD3D8Texture::copy16BitMipMap(char* src, char* tgt, - s32 width, s32 height, - s32 pitchsrc, s32 pitchtgt) -{ - u16 c; - - for (int x=0; x>= 2; - r >>= 2; - g >>= 2; - b >>= 2; - - c = ((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff); - *(u32*)((void*)&tgt[(x*4)+(y*pitchtgt)]) = c.color; - } - } -} - - - -void CD3D8Texture::createRenderTarget() -{ - TextureSize.Width = getTextureSizeFromImageSize(TextureSize.Width); - TextureSize.Height = getTextureSizeFromImageSize(TextureSize.Height); - - // get backbuffer format to create the render target in the - // same format - - IDirect3DSurface8* bb; - D3DFORMAT d3DFormat = D3DFMT_A8R8G8B8; - - if (!FAILED(Device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &bb))) - { - D3DSURFACE_DESC desc; - bb->GetDesc(&desc); - d3DFormat = desc.Format; - - if (d3DFormat == D3DFMT_X8R8G8B8) - d3DFormat = D3DFMT_A8R8G8B8; - - bb->Release(); - } - else - { - os::Printer::log("Could not create RenderTarget texture: could not get BackBuffer.", - ELL_WARNING); - return; - } - - // create texture - HRESULT hr; - - hr = Device->CreateTexture( - TextureSize.Width, - TextureSize.Height, - 1, // mip map level count, we don't want mipmaps here - D3DUSAGE_RENDERTARGET, - d3DFormat, - D3DPOOL_DEFAULT, - &Texture); - - // get irrlicht format from D3D format - - switch(d3DFormat) - { - case D3DFMT_X1R5G5B5: - case D3DFMT_A1R5G5B5: - ColorFormat = ECF_A1R5G5B5; - break; - case D3DFMT_A8R8G8B8: - case D3DFMT_X8R8G8B8: - ColorFormat = ECF_A8R8G8B8; - break; - case D3DFMT_R5G6B5: - ColorFormat = ECF_R5G6B5; - break; - default: - ColorFormat = (ECOLOR_FORMAT)-1; - }; - - if (FAILED(hr)) - os::Printer::log("Could not create render target texture"); -} - - - -//! Regenerates the mip map levels of the texture. Useful after locking and -//! modifying the texture -void CD3D8Texture::regenerateMipMapLevels() -{ - if (HasMipMaps) - createMipMaps(); -} - - -//! returns if it is a render target -bool CD3D8Texture::isRenderTarget() -{ - return IsRenderTarget; -} - -//! Returns pointer to the render target surface -IDirect3DSurface8* CD3D8Texture::getRenderTargetSurface() -{ - if (!IsRenderTarget) - return 0; - - IDirect3DSurface8 *pRTTSurface = 0; - if (Texture) - Texture->GetSurfaceLevel(0, &pRTTSurface); - - if (pRTTSurface) - pRTTSurface->Release(); - - return pRTTSurface; -} - - - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ + +#define _IRR_DONT_DO_MEMORY_DEBUGGING_HERE +#include "CD3D8Texture.h" +#include "CD3D8Driver.h" +#include "os.h" + + +#ifndef _IRR_COMPILE_WITH_DIRECT3D_9_ +// The D3DXFilterTexture function seems to get linked wrong when +// compiling with both D3D8 and 9, causing it not to work in the D3D9 device. +// So mipmapgeneration is replaced with my own bad generation in d3d 8 when +// compiling with both D3D 8 and 9. +//#define _IRR_USE_D3DXFilterTexture_ +#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ + +#include "d3dx8tex.h" + +#ifdef _IRR_USE_D3DXFilterTexture_ +//#pragma comment (lib, "d3dx8.lib") +#endif // _IRR_USE_D3DXFilterTexture_ + +namespace irr +{ +namespace video +{ + +//! rendertarget constructor +CD3D8Texture::CD3D8Texture(CD3D8Driver* driver, core::dimension2d size, const char* name) +: ITexture(name), Image(0), Texture(0), RTTSurface(0), Driver(driver), + TextureSize(size), ImageSize(size), Pitch(0), SurfaceHasSameSize(true), + HasMipMaps(false), IsRenderTarget(true) +{ + #ifdef _DEBUG + setDebugName("CD3D8Texture"); + #endif + + Device=driver->getExposedVideoData().D3D8.D3DDev8; + if (Device) + Device->AddRef(); + + createRenderTarget(); +} + + +//! constructor +CD3D8Texture::CD3D8Texture(IImage* image, CD3D8Driver* driver, + u32 flags, const char* name) +: ITexture(name), Image(image), Texture(0), RTTSurface(0), Driver(driver), +TextureSize(0,0), ImageSize(0,0), Pitch(0), SurfaceHasSameSize(true), +HasMipMaps(false), IsRenderTarget(false) +{ + #ifdef _DEBUG + setDebugName("CD3D8Texture"); + #endif + + bool generateMipLevels = (flags & video::ETCF_CREATE_MIP_MAPS) != 0; + + Device=driver->getExposedVideoData().D3D8.D3DDev8; + if (Device) + Device->AddRef(); + + if (Image) + { + Image->grab(); + + createTexture(flags); + + if (Texture) + { + if (copyTexture() && generateMipLevels) + { + // create mip maps. + + #ifndef _IRR_USE_D3DXFilterTexture_ + // The D3DXFilterTexture function seems to get linked wrong when + // compiling with both D3D8 and 9, causing it not to work in the D3D9 device. + // So mipmapgeneration is replaced with my own bad generation in d3d 8 when + // compiling with both D3D 8 and 9. + HRESULT hr = D3DXFilterTexture(Texture, NULL, D3DX_DEFAULT , D3DX_DEFAULT ); + if (FAILED(hr)) + os::Printer::log("Could not create direct3d mip map levels.", ELL_WARNING); + else + HasMipMaps = true; + #else + createMipMaps(); + HasMipMaps = true; + #endif + } + } + else + os::Printer::log("Could not create DIRECT3D8 Texture.", ELL_WARNING); + } +} + + + +//! creates the hardware texture +void CD3D8Texture::createTexture(u32 flags) +{ + core::dimension2d optSize; + ImageSize = Image->getDimension(); + + if (Driver->queryFeature(EVDF_TEXTURE_NPOT)) + optSize=ImageSize; + else + { + optSize.Width = getTextureSizeFromImageSize(ImageSize.Width); + optSize.Height = getTextureSizeFromImageSize(ImageSize.Height); + } + + HRESULT hr; + D3DFORMAT format = D3DFMT_A1R5G5B5; + + switch(getTextureFormatFromFlags(flags)) + { + case ETCF_ALWAYS_16_BIT: + format = D3DFMT_A1R5G5B5; break; + case ETCF_ALWAYS_32_BIT: + format = D3DFMT_A8R8G8B8; break; + case ETCF_OPTIMIZED_FOR_QUALITY: + { + switch(Image->getColorFormat()) + { + case ECF_R8G8B8: + case ECF_A8R8G8B8: + format = D3DFMT_A8R8G8B8; break; + case ECF_A1R5G5B5: + case ECF_R5G6B5: + format = D3DFMT_A1R5G5B5; break; + } + } + break; + case ETCF_OPTIMIZED_FOR_SPEED: + format = D3DFMT_A1R5G5B5; break; + } + + bool mipmaps = (flags & video::ETCF_CREATE_MIP_MAPS) != 0; + + hr = Device->CreateTexture(optSize.Width, optSize.Height, + mipmaps ? 0 : 1, // number of mipmaplevels (0 = automatic all) + 0, format, D3DPOOL_MANAGED, &Texture); + + if (FAILED(hr) && format == D3DFMT_A8R8G8B8) + { + // try brute force 16 bit + + format = D3DFMT_A1R5G5B5; + + hr = Device->CreateTexture(optSize.Width, optSize.Height, + (flags & ETCF_CREATE_MIP_MAPS) ? 0 : 1, // number of mipmaplevels (0 = automatic all) + 0, D3DFMT_A1R5G5B5, D3DPOOL_MANAGED, &Texture); + } + + ColorFormat = (format == D3DFMT_A1R5G5B5) ? ECF_A1R5G5B5 : ECF_A8R8G8B8; +} + + + +//! copies the image to the texture +bool CD3D8Texture::copyTexture() +{ + if (Texture && Image) + { + D3DSURFACE_DESC desc; + Texture->GetLevelDesc(0, &desc); + + TextureSize.Width = desc.Width; + TextureSize.Height = desc.Height; + + SurfaceHasSameSize = (TextureSize == ImageSize); + + if (desc.Format == D3DFMT_A1R5G5B5) + return copyTo16BitTexture(); + else + if (desc.Format == D3DFMT_A8R8G8B8) + return copyTo32BitTexture(); + else + os::Printer::log("CD3D8Texture: Unsupported D3D8 hardware texture format", ELL_ERROR); + } + + return true; +} + + +//! copies texture to 32 bit hardware texture +bool CD3D8Texture::copyTo32BitTexture() +{ + D3DLOCKED_RECT rect; + HRESULT hr = Texture->LockRect(0, &rect, 0, 0); + if (FAILED(hr)) + { + os::Printer::log("Could not lock DIRECT3D8 32 bit Texture.", ELL_ERROR); + return false; + } + + u32* dest = (u32*)rect.pBits; + u32* source = (u32*)Image->lock(); + Pitch = rect.Pitch; + s32 pitch = rect.Pitch / 4; + + if (SurfaceHasSameSize) + { + if (Image->getColorFormat() == ECF_A8R8G8B8) + { + // direct copy, fast + + for (s32 y=0; ygetPixel(x,y).color; + } + } + else + { + // scale texture + + f32 sourceXStep = (f32)ImageSize.Width / (f32)TextureSize.Width; + f32 sourceYStep = (f32)ImageSize.Height / (f32)TextureSize.Height; + f32 sy; + + if (Image->getColorFormat() == ECF_A8R8G8B8) + { + // copy texture scaling + + for (s32 x=0; xgetPixel((s32)(x*sourceXStep), (s32)sy).color; + + sy+=sourceYStep; + } + } + } + } + + Image->unlock(); + + hr = Texture->UnlockRect(0); + if (FAILED(hr)) + { + os::Printer::log("Could not unlock DIRECT3D8 Texture.", ELL_ERROR); + return false; + } + + return true; + +} + + +//! optimized for 16 bit to 16 copy. +bool CD3D8Texture::copyTo16BitTexture() +{ + D3DLOCKED_RECT rect; + HRESULT hr = Texture->LockRect(0, &rect, 0, 0); + if (FAILED(hr)) + { + os::Printer::log("Could not lock DIRECT3D8 16 bit Texture.", ELL_ERROR); + return false; + } + + s16* dest = (s16*)rect.pBits; + s16* source = (s16*)Image->lock(); + Pitch = rect.Pitch; + s32 pitch = rect.Pitch/2; + + if (SurfaceHasSameSize) + { + // copy texture + + if (Image->getColorFormat() == ECF_A1R5G5B5) + { + // direct copy, fast + + for (s32 y=0; ygetPixel(x,y).toA1R5G5B5(); + } + } + else + { + // scale texture + + f32 sourceXStep = (f32)ImageSize.Width / (f32)TextureSize.Width; + f32 sourceYStep = (f32)ImageSize.Height / (f32)TextureSize.Height; + f32 sy; + + if (Image->getColorFormat() == ECF_A1R5G5B5) + { + // copy texture scaling + + for (s32 x=0; xgetPixel((s32)(x*sourceXStep), (s32)sy).toA1R5G5B5(); + + sy+=sourceYStep; + } + } + } + } + + Image->unlock(); + + hr = Texture->UnlockRect(0); + if (FAILED(hr)) + { + os::Printer::log("Could not unlock DIRECT3D8 16 bit Texture.", ELL_ERROR); + return false; + } + + return true; +} + + + +//! destructor +CD3D8Texture::~CD3D8Texture() +{ + if (Device) + Device->Release(); + + if (Image) + Image->drop(); + + if (Texture) + Texture->Release(); + + if (RTTSurface) + RTTSurface->Release(); +} + + + +//! lock function +void* CD3D8Texture::lock() +{ + if (!Texture) + return 0; + + HRESULT hr; + D3DLOCKED_RECT rect; + if(!IsRenderTarget) + { + hr = Texture->LockRect(0, &rect, 0, 0); + } + else + { + D3DSURFACE_DESC desc; + Texture->GetLevelDesc(0, &desc); + if (!RTTSurface) + { + hr = Device->CreateImageSurface(desc.Width, desc.Height, desc.Format, &RTTSurface); + if (FAILED(hr)) + { + os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); + return 0; + } + } + + IDirect3DSurface8 *surface = NULL; + hr = Texture->GetSurfaceLevel(0, &surface); + if (FAILED(hr)) + { + os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); + return 0; + } + hr = Device->CopyRects(surface, NULL, 0, RTTSurface, NULL); + if(FAILED(hr)) + { + os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); + return 0; + } + hr = RTTSurface->LockRect(&rect, NULL, 0); + if(FAILED(hr)) + { + os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); + return 0; + } + return rect.pBits; + } + if (FAILED(hr)) + { + os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); + return 0; + } + + return rect.pBits; +} + + + +//! unlock function +void CD3D8Texture::unlock() +{ + if (!Texture) + return; + + if (!IsRenderTarget) + Texture->UnlockRect(0); + else if (RTTSurface) + RTTSurface->UnlockRect(); +} + + +//! Returns original size of the texture. +const core::dimension2d& CD3D8Texture::getOriginalSize() +{ + return ImageSize; +} + + +//! Returns (=size) of the texture. +const core::dimension2d& CD3D8Texture::getSize() +{ + return TextureSize; +} + + +//! returns the size of a texture which would be the optimize size for rendering it +inline s32 CD3D8Texture::getTextureSizeFromImageSize(s32 size) +{ + s32 ts = 0x01; + + while(ts < size) + ts <<= 1; + + if (ts > size && ts > 64) + ts >>= 1; + + return ts; +} + + + +//! returns driver type of texture (=the driver, who created the texture) +E_DRIVER_TYPE CD3D8Texture::getDriverType() +{ + return EDT_DIRECT3D8; +} + + + +//! returns color format of texture +ECOLOR_FORMAT CD3D8Texture::getColorFormat() const +{ + return ColorFormat; +} + + + +//! returns pitch of texture (in bytes) +u32 CD3D8Texture::getPitch() const +{ + return Pitch; +} + + + +//! returns the DIRECT3D8 Texture +IDirect3DTexture8* CD3D8Texture::getDX8Texture() +{ + return Texture; +} + + +//! returns if texture has mipmap levels +bool CD3D8Texture::hasMipMaps() +{ + return HasMipMaps; +} + + +bool CD3D8Texture::createMipMaps(s32 level) +{ + // The D3DXFilterTexture function seems to get linked wrong when + // compiling with both D3D8 and 9, causing it not to work in the D3D9 device. + // So mipmapgeneration is replaced with my own bad generation in d3d 8 when + // compiling with both D3D 8 and 9. + + IDirect3DSurface8* upperSurface = 0; + IDirect3DSurface8* lowerSurface = 0; + + // get upper level + HRESULT hr = Texture->GetSurfaceLevel(level-1, &upperSurface); + if (FAILED(hr) || !upperSurface) + { + os::Printer::log("Could not get upper surface level for mip map generation", ELL_WARNING); + return false; + } + + // get lower level + hr = Texture->GetSurfaceLevel(level, &lowerSurface); + if (FAILED(hr) || !lowerSurface) + { + os::Printer::log("Could not get lower surface level for mip map generation", ELL_WARNING); + upperSurface->Release(); + return false; + } + + D3DSURFACE_DESC upperDesc, lowerDesc; + upperSurface->GetDesc(&upperDesc); + lowerSurface->GetDesc(&lowerDesc); + + + D3DLOCKED_RECT upperlr; + D3DLOCKED_RECT lowerlr; + + // lock upper surface + if (FAILED(upperSurface->LockRect(&upperlr, NULL, 0))) + { + os::Printer::log("Could not lock upper texture for mip map generation", ELL_WARNING); + return false; + } + + // lock lower surface + if (FAILED(lowerSurface->LockRect(&lowerlr, NULL, 0))) + { + os::Printer::log("Could not lock lower texture for mip map generation", ELL_WARNING); + return false; + } + + if (upperDesc.Format != lowerDesc.Format) + { + os::Printer::log("Cannot copy mip maps with different formats.", ELL_WARNING); + } + else + { + if (upperDesc.Format == D3DFMT_A1R5G5B5) + copy16BitMipMap((char*)upperlr.pBits, (char*)lowerlr.pBits, + lowerDesc.Width, lowerDesc.Height, + upperlr.Pitch, lowerlr.Pitch); + else + if (upperDesc.Format == D3DFMT_A8R8G8B8) + copy32BitMipMap((char*)upperlr.pBits, (char*)lowerlr.pBits, + lowerDesc.Width, lowerDesc.Height, + upperlr.Pitch, lowerlr.Pitch); + else + os::Printer::log("Unsupported mipmap format, cannot copy.", ELL_WARNING); + } + + // unlock + if (FAILED(upperSurface->UnlockRect())) + return false; + if (FAILED(lowerSurface->UnlockRect())) + return false; + + // release + upperSurface->Release(); + lowerSurface->Release(); + + if (upperDesc.Width <= 2 || upperDesc.Height <= 2) + return true; // stop generating levels + + // generate next level + return createMipMaps(level+1); +} + + + +void CD3D8Texture::copy16BitMipMap(char* src, char* tgt, + s32 width, s32 height, + s32 pitchsrc, s32 pitchtgt) +{ + u16 c; + + for (int x=0; x>= 2; + r >>= 2; + g >>= 2; + b >>= 2; + + c = ((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff); + *(u32*)((void*)&tgt[(x*4)+(y*pitchtgt)]) = c.color; + } + } +} + + + +void CD3D8Texture::createRenderTarget() +{ + TextureSize.Width = getTextureSizeFromImageSize(TextureSize.Width); + TextureSize.Height = getTextureSizeFromImageSize(TextureSize.Height); + + // get backbuffer format to create the render target in the + // same format + + IDirect3DSurface8* bb; + D3DFORMAT d3DFormat = D3DFMT_A8R8G8B8; + + if (!FAILED(Device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &bb))) + { + D3DSURFACE_DESC desc; + bb->GetDesc(&desc); + d3DFormat = desc.Format; + + if (d3DFormat == D3DFMT_X8R8G8B8) + d3DFormat = D3DFMT_A8R8G8B8; + + bb->Release(); + } + else + { + os::Printer::log("Could not create RenderTarget texture: could not get BackBuffer.", + ELL_WARNING); + return; + } + + // create texture + HRESULT hr; + + hr = Device->CreateTexture( + TextureSize.Width, + TextureSize.Height, + 1, // mip map level count, we don't want mipmaps here + D3DUSAGE_RENDERTARGET, + d3DFormat, + D3DPOOL_DEFAULT, + &Texture); + + // get irrlicht format from D3D format + + switch(d3DFormat) + { + case D3DFMT_X1R5G5B5: + case D3DFMT_A1R5G5B5: + ColorFormat = ECF_A1R5G5B5; + break; + case D3DFMT_A8R8G8B8: + case D3DFMT_X8R8G8B8: + ColorFormat = ECF_A8R8G8B8; + break; + case D3DFMT_R5G6B5: + ColorFormat = ECF_R5G6B5; + break; + default: + ColorFormat = (ECOLOR_FORMAT)-1; + }; + + if (FAILED(hr)) + os::Printer::log("Could not create render target texture"); +} + + + +//! Regenerates the mip map levels of the texture. Useful after locking and +//! modifying the texture +void CD3D8Texture::regenerateMipMapLevels() +{ + if (HasMipMaps) + createMipMaps(); +} + + +//! returns if it is a render target +bool CD3D8Texture::isRenderTarget() +{ + return IsRenderTarget; +} + +//! Returns pointer to the render target surface +IDirect3DSurface8* CD3D8Texture::getRenderTargetSurface() +{ + if (!IsRenderTarget) + return 0; + + IDirect3DSurface8 *pRTTSurface = 0; + if (Texture) + Texture->GetSurfaceLevel(0, &pRTTSurface); + + if (pRTTSurface) + pRTTSurface->Release(); + + return pRTTSurface; +} + + + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ diff --git a/src/dep/src/irrlicht/CD3D8Texture.h b/src/dep/src/irrlicht/CD3D8Texture.h index ad1b03e..4fd5d8e 100644 --- a/src/dep/src/irrlicht/CD3D8Texture.h +++ b/src/dep/src/irrlicht/CD3D8Texture.h @@ -1,124 +1,124 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_DIRECTX8_TEXTURE_H_INCLUDED__ -#define __C_DIRECTX8_TEXTURE_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - -#include "ITexture.h" -#include "IImage.h" -#include "d3d8.h" - -namespace irr -{ -namespace video -{ - -class CD3D8Driver; - -/*! - interface for a Video Driver dependent Texture. -*/ -class CD3D8Texture : public ITexture -{ -public: - - //! constructor - CD3D8Texture(IImage* image, CD3D8Driver* driver, - u32 flags, const char* name); - - //! rendertarget constructor - CD3D8Texture(CD3D8Driver* driver, core::dimension2d size, const char* name); - - //! destructor - virtual ~CD3D8Texture(); - - //! lock function - virtual void* lock(); - - //! unlock function - virtual void unlock(); - - //! Returns original size of the texture. - virtual const core::dimension2d& getOriginalSize(); - - //! Returns (=size) of the texture. - virtual const core::dimension2d& getSize(); - - //! returns driver type of texture (=the driver, who created the texture) - virtual E_DRIVER_TYPE getDriverType(); - - //! returns color format of texture - virtual ECOLOR_FORMAT getColorFormat() const; - - //! returns pitch of texture (in bytes) - virtual u32 getPitch() const; - - //! returns the DIRECT3D8 Texture - IDirect3DTexture8* getDX8Texture(); - - //! returns if texture has mipmap levels - bool hasMipMaps(); - - //! Regenerates the mip map levels of the texture. Useful after locking and - //! modifying the texture - virtual void regenerateMipMapLevels(); - - //! returns if it is a render target - bool isRenderTarget(); - - //! Returns pointer to the render target surface - IDirect3DSurface8* getRenderTargetSurface(); - -private: - - void createRenderTarget(); - - //! returns the size of a texture which would be the optimize size for rendering it - inline s32 getTextureSizeFromImageSize(s32 size); - - //! creates the hardware texture - void createTexture(u32 flags); - - //! copies the image to the texture - bool copyTexture(); - - //! optimized for 16 bit to 16 copy. - bool copyTo16BitTexture(); - - //! copies texture to 32 bit hardware texture - bool copyTo32BitTexture(); - - bool createMipMaps(s32 level=1); - - void copy16BitMipMap(char* src, char* tgt, - s32 width, s32 height, s32 pitchsrc, s32 pitchtgt); - - void copy32BitMipMap(char* src, char* tgt, - s32 width, s32 height, s32 pitchsrc, s32 pitchtgt); - - IImage* Image; - IDirect3DDevice8* Device; - IDirect3DTexture8* Texture; - IDirect3DSurface8* RTTSurface; - CD3D8Driver* Driver; - core::dimension2d TextureSize; - core::dimension2d ImageSize; - s32 Pitch; - ECOLOR_FORMAT ColorFormat; - bool SurfaceHasSameSize; // true if image has the same dimension as texture. - bool HasMipMaps; - bool IsRenderTarget; -}; - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ - -#endif // __C_DIRECTX8_TEXTURE_H_INCLUDED__ - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_DIRECTX8_TEXTURE_H_INCLUDED__ +#define __C_DIRECTX8_TEXTURE_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ + +#include "ITexture.h" +#include "IImage.h" +#include "d3d8.h" + +namespace irr +{ +namespace video +{ + +class CD3D8Driver; + +/*! + interface for a Video Driver dependent Texture. +*/ +class CD3D8Texture : public ITexture +{ +public: + + //! constructor + CD3D8Texture(IImage* image, CD3D8Driver* driver, + u32 flags, const char* name); + + //! rendertarget constructor + CD3D8Texture(CD3D8Driver* driver, core::dimension2d size, const char* name); + + //! destructor + virtual ~CD3D8Texture(); + + //! lock function + virtual void* lock(); + + //! unlock function + virtual void unlock(); + + //! Returns original size of the texture. + virtual const core::dimension2d& getOriginalSize(); + + //! Returns (=size) of the texture. + virtual const core::dimension2d& getSize(); + + //! returns driver type of texture (=the driver, who created the texture) + virtual E_DRIVER_TYPE getDriverType(); + + //! returns color format of texture + virtual ECOLOR_FORMAT getColorFormat() const; + + //! returns pitch of texture (in bytes) + virtual u32 getPitch() const; + + //! returns the DIRECT3D8 Texture + IDirect3DTexture8* getDX8Texture(); + + //! returns if texture has mipmap levels + bool hasMipMaps(); + + //! Regenerates the mip map levels of the texture. Useful after locking and + //! modifying the texture + virtual void regenerateMipMapLevels(); + + //! returns if it is a render target + bool isRenderTarget(); + + //! Returns pointer to the render target surface + IDirect3DSurface8* getRenderTargetSurface(); + +private: + + void createRenderTarget(); + + //! returns the size of a texture which would be the optimize size for rendering it + inline s32 getTextureSizeFromImageSize(s32 size); + + //! creates the hardware texture + void createTexture(u32 flags); + + //! copies the image to the texture + bool copyTexture(); + + //! optimized for 16 bit to 16 copy. + bool copyTo16BitTexture(); + + //! copies texture to 32 bit hardware texture + bool copyTo32BitTexture(); + + bool createMipMaps(s32 level=1); + + void copy16BitMipMap(char* src, char* tgt, + s32 width, s32 height, s32 pitchsrc, s32 pitchtgt); + + void copy32BitMipMap(char* src, char* tgt, + s32 width, s32 height, s32 pitchsrc, s32 pitchtgt); + + IImage* Image; + IDirect3DDevice8* Device; + IDirect3DTexture8* Texture; + IDirect3DSurface8* RTTSurface; + CD3D8Driver* Driver; + core::dimension2d TextureSize; + core::dimension2d ImageSize; + s32 Pitch; + ECOLOR_FORMAT ColorFormat; + bool SurfaceHasSameSize; // true if image has the same dimension as texture. + bool HasMipMaps; + bool IsRenderTarget; +}; + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ + +#endif // __C_DIRECTX8_TEXTURE_H_INCLUDED__ + diff --git a/src/dep/src/irrlicht/CD3D9Driver.cpp b/src/dep/src/irrlicht/CD3D9Driver.cpp index 37afd14..a15a665 100644 --- a/src/dep/src/irrlicht/CD3D9Driver.cpp +++ b/src/dep/src/irrlicht/CD3D9Driver.cpp @@ -1,2206 +1,2206 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#define _IRR_DONT_DO_MEMORY_DEBUGGING_HERE -#include "CD3D9Driver.h" -#include "os.h" -#include "S3DVertex.h" -#include "CD3D9Texture.h" -#include "CImage.h" - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - -#include "CD3D9MaterialRenderer.h" -#include "CD3D9ShaderMaterialRenderer.h" -#include "CD3D9NormalMapRenderer.h" -#include "CD3D9ParallaxMapRenderer.h" -#include "CD3D9HLSLMaterialRenderer.h" -#include - -namespace irr -{ -namespace video -{ - - -//! constructor -CD3D9Driver::CD3D9Driver(const core::dimension2d& screenSize, HWND window, - bool fullscreen, bool stencilbuffer, - io::IFileSystem* io, bool pureSoftware) -: CNullDriver(io, screenSize), CurrentRenderMode(ERM_NONE), - ResetRenderStates(true), Transformation3DChanged(false), StencilBuffer(stencilbuffer), - D3DLibrary(0), pID3D(0), pID3DDevice(0), PrevRenderTarget(0), - LastVertexType((video::E_VERTEX_TYPE)-1), MaxTextureUnits(0), - MaxLightDistance(sqrtf(FLT_MAX)), LastSetLight(-1), DeviceLost(false), - Fullscreen(fullscreen) -{ - #ifdef _DEBUG - setDebugName("CD3D9Driver"); - #endif - - printVersion(); - - for (u32 i=0; idrop(); - - // drop d3d9 - - if (pID3DDevice) - pID3DDevice->Release(); - - if (pID3D) - pID3D->Release(); -} - - - -void CD3D9Driver::createMaterialRenderers() -{ - // create D3D9 material renderers - - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SOLID(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SOLID_2_LAYER(pID3DDevice, this)); - - // add the same renderer for all lightmap types - - CD3D9MaterialRenderer_LIGHTMAP* lmr = new CD3D9MaterialRenderer_LIGHTMAP(pID3DDevice, this); - addMaterialRenderer(lmr); // for EMT_LIGHTMAP: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_ADD: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M2: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M4: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M2: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M4: - lmr->drop(); - - // add remaining fixed function pipeline material renderers - - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_DETAIL_MAP(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SPHERE_MAP(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_REFLECTION_2_LAYER(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ADD_COLOR(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(pID3DDevice, this)); - - // add normal map renderers - - s32 tmp = 0; - video::IMaterialRenderer* renderer = 0; - - renderer = new CD3D9NormalMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_SOLID].Renderer); - renderer->drop(); - - renderer = new CD3D9NormalMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); - renderer->drop(); - - renderer = new CD3D9NormalMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); - renderer->drop(); - - - // add parallax map renderers - - renderer = new CD3D9ParallaxMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_SOLID].Renderer); - renderer->drop(); - - renderer = new CD3D9ParallaxMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); - renderer->drop(); - - renderer = new CD3D9ParallaxMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); - renderer->drop(); - - - // add basic 1 texture blending - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_ONETEXTURE_BLEND(pID3DDevice, this)); - -} - - - -//! initialises the Direct3D API -bool CD3D9Driver::initDriver(const core::dimension2d& screenSize, HWND hwnd, - u32 bits, bool fullScreen, bool pureSoftware, - bool highPrecisionFPU, bool vsync, bool antiAlias) -{ - HRESULT hr; - Fullscreen = fullScreen; - - if (!pID3D) - { - D3DLibrary = LoadLibrary( "d3d9.dll" ); - - if (!D3DLibrary) - { - os::Printer::log("Error, could not load d3d9.dll.", ELL_ERROR); - return false; - } - - typedef IDirect3D9 * (__stdcall *D3DCREATETYPE)(UINT); - D3DCREATETYPE d3dCreate = (D3DCREATETYPE) GetProcAddress(D3DLibrary, "Direct3DCreate9"); - - if (!d3dCreate) - { - os::Printer::log("Error, could not get proc adress of Direct3DCreate9.", ELL_ERROR); - return false; - } - - //just like pID3D = Direct3DCreate9(D3D_SDK_VERSION); - pID3D = (*d3dCreate)(D3D_SDK_VERSION); - - if (!pID3D) - { - os::Printer::log("Error initializing D3D.", ELL_ERROR); - return false; - } - } - - // print device information - D3DADAPTER_IDENTIFIER9 dai; - if (!FAILED(pID3D->GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0, &dai))) - { - char tmp[512]; - - s32 Product = HIWORD(dai.DriverVersion.HighPart); - s32 Version = LOWORD(dai.DriverVersion.HighPart); - s32 SubVersion = HIWORD(dai.DriverVersion.LowPart); - s32 Build = LOWORD(dai.DriverVersion.LowPart); - - sprintf(tmp, "%s %s %d.%d.%d.%d", dai.Description, dai.Driver, Product, Version, - SubVersion, Build); - os::Printer::log(tmp, ELL_INFORMATION); - } - - D3DDISPLAYMODE d3ddm; - hr = pID3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm); - if (FAILED(hr)) - { - os::Printer::log("Error: Could not get Adapter Display mode.", ELL_ERROR); - return false; - } - - ZeroMemory(&present, sizeof(present)); - - present.BackBufferCount = 1; - present.EnableAutoDepthStencil = TRUE; - if (vsync) - present.PresentationInterval = D3DPRESENT_INTERVAL_ONE; - else - present.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - - if (fullScreen) - { - present.BackBufferWidth = screenSize.Width; - present.BackBufferHeight = screenSize.Height; - // request 32bit mode if user specified 32 bit, added by Thomas Stüfe - if (bits == 32) - present.BackBufferFormat = D3DFMT_X8R8G8B8; - else - present.BackBufferFormat = D3DFMT_R5G6B5; - present.SwapEffect = D3DSWAPEFFECT_FLIP; - present.Windowed = FALSE; - present.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; - } - else - { - present.BackBufferFormat = d3ddm.Format; - present.SwapEffect = D3DSWAPEFFECT_COPY; - present.Windowed = TRUE; - } - - D3DDEVTYPE devtype = D3DDEVTYPE_HAL; - #ifndef _IRR_D3D_NO_SHADER_DEBUGGING - devtype = D3DDEVTYPE_REF; - #endif - - // enable anti alias if possible and desired - if (antiAlias) - { - DWORD qualityLevels = 0; - - if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, - devtype, present.BackBufferFormat, !fullScreen, - D3DMULTISAMPLE_4_SAMPLES, &qualityLevels))) - { - // enable multi sampling - present.MultiSampleType = D3DMULTISAMPLE_4_SAMPLES; - present.MultiSampleQuality = qualityLevels-1; - present.SwapEffect = D3DSWAPEFFECT_DISCARD; - } - else - if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, - devtype, present.BackBufferFormat, !fullScreen, - D3DMULTISAMPLE_2_SAMPLES, &qualityLevels))) - { - // enable multi sampling - present.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES; - present.MultiSampleQuality = qualityLevels-1; - present.SwapEffect = D3DSWAPEFFECT_DISCARD; - } - else - if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, - devtype, present.BackBufferFormat, !fullScreen, - D3DMULTISAMPLE_NONMASKABLE, &qualityLevels))) - { - // enable non maskable multi sampling - present.SwapEffect = D3DSWAPEFFECT_DISCARD; - present.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE; - present.MultiSampleQuality = qualityLevels-1; - } - else - { - os::Printer::log("Anti aliasing disabled because hardware/driver lacks necessary caps.", ELL_WARNING); - antiAlias = false; - } - } - - // check stencil buffer compatibility - if (StencilBuffer) - { - present.AutoDepthStencilFormat = D3DFMT_D24S8; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D24X4S4; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D15S1; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - os::Printer::log("Device does not support stencilbuffer, disabling stencil buffer.", ELL_WARNING); - StencilBuffer = false; - } - } - } - else - if(FAILED(pID3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, present.BackBufferFormat, present.AutoDepthStencilFormat))) - { - os::Printer::log("Depth-stencil format is not compatible with display format, disabling stencil buffer.", ELL_WARNING); - StencilBuffer = false; - } - } - // do not use else here to cope with flag change in previous block - if (!StencilBuffer) - { - present.AutoDepthStencilFormat = D3DFMT_D32; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D24X8; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D16; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - os::Printer::log("Device does not support required depth buffer.", ELL_WARNING); - return false; - } - } - } - } - - // create device - - DWORD fpuPrecision = highPrecisionFPU ? D3DCREATE_FPU_PRESERVE : 0; - if (pureSoftware) - { - hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, hwnd, - fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); - - if (FAILED(hr)) - os::Printer::log("Was not able to create Direct3D9 software device.", ELL_ERROR); - } - else - { - hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, - fpuPrecision | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice); - - if(FAILED(hr)) - hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, - fpuPrecision | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice); - - if(FAILED(hr)) - hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, - fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); - - if (FAILED(hr)) - os::Printer::log("Was not able to create Direct3D9 device.", ELL_ERROR); - } - - if (!pID3DDevice) - { - os::Printer::log("Was not able to create DIRECT3D9 device.", ELL_ERROR); - return false; - } - - // get caps - pID3DDevice->GetDeviceCaps(&Caps); - - // disable stencilbuffer if necessary - if (StencilBuffer && - (!(Caps.StencilCaps & D3DSTENCILCAPS_DECRSAT) || - !(Caps.StencilCaps & D3DSTENCILCAPS_INCRSAT) || - !(Caps.StencilCaps & D3DSTENCILCAPS_KEEP))) - { - os::Printer::log("Device not able to use stencil buffer, disabling stencil buffer.", ELL_WARNING); - StencilBuffer = false; - } - - // set default vertex shader - setVertexShader(EVT_STANDARD); - - // enable antialiasing - if (antiAlias) - pID3DDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE); - - // set fog mode - setFog(FogColor, LinearFog, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); - - // set exposed data - ExposedData.D3D9.D3D9 = pID3D; - ExposedData.D3D9.D3DDev9 = pID3DDevice; - ExposedData.D3D9.HWnd = reinterpret_cast(hwnd); - - ResetRenderStates = true; - - // create materials - createMaterialRenderers(); - - MaxTextureUnits = core::min_((u32)Caps.MaxSimultaneousTextures, MATERIAL_MAX_TEXTURES); - - // set the renderstates - setRenderStates3DMode(); - - // set maximal anisotropy - pID3DDevice->SetSamplerState(0, D3DSAMP_MAXANISOTROPY, min(16, Caps.MaxAnisotropy)); - pID3DDevice->SetSamplerState(1, D3DSAMP_MAXANISOTROPY, min(16, Caps.MaxAnisotropy)); - pID3DDevice->SetSamplerState(2, D3DSAMP_MAXANISOTROPY, min(16, Caps.MaxAnisotropy)); - pID3DDevice->SetSamplerState(3, D3DSAMP_MAXANISOTROPY, min(16, Caps.MaxAnisotropy)); - - // so far so good. - return true; -} - - - -//! applications must call this method before performing any rendering. returns false if failed. -bool CD3D9Driver::beginScene(bool backBuffer, bool zBuffer, SColor color) -{ - CNullDriver::beginScene(backBuffer, zBuffer, color); - HRESULT hr; - - if (!pID3DDevice) - return false; - - if (DeviceLost) - { - if(FAILED(hr = pID3DDevice->TestCooperativeLevel())) - { - if (hr == D3DERR_DEVICELOST) - return false; - - if (hr == D3DERR_DEVICENOTRESET) - reset(); - return false; - } - } - - DWORD flags = 0; - - if (backBuffer) - flags |= D3DCLEAR_TARGET; - - if (zBuffer) - flags |= D3DCLEAR_ZBUFFER; - - if (StencilBuffer) - flags |= D3DCLEAR_STENCIL; - - hr = pID3DDevice->Clear( 0, NULL, flags, color.color, 1.0, 0); - if (FAILED(hr)) - os::Printer::log("DIRECT3D9 clear failed.", ELL_WARNING); - - hr = pID3DDevice->BeginScene(); - if (FAILED(hr)) - { - os::Printer::log("DIRECT3D9 begin scene failed.", ELL_WARNING); - return false; - } - - return true; -} - - - -//! applications must call this method after performing any rendering. returns false if failed. -bool CD3D9Driver::endScene( s32 windowId, core::rect* sourceRect ) -{ - if (DeviceLost) - return false; - - CNullDriver::endScene(); - - HRESULT hr = pID3DDevice->EndScene(); - if (FAILED(hr)) - { - os::Printer::log("DIRECT3D9 end scene failed.", ELL_WARNING); - return false; - } - - RECT* srcRct = 0; - RECT sourceRectData; - if ( sourceRect ) - { - srcRct = &sourceRectData; - sourceRectData.left = sourceRect->UpperLeftCorner.X; - sourceRectData.top = sourceRect->UpperLeftCorner.Y; - sourceRectData.right = sourceRect->LowerRightCorner.X; - sourceRectData.bottom = sourceRect->LowerRightCorner.Y; - } - - hr = pID3DDevice->Present(srcRct, NULL, (HWND)windowId, NULL); - - if (hr == D3DERR_DEVICELOST) - { - DeviceLost = true; - os::Printer::log("DIRECT3D9 device lost.", ELL_WARNING); - } - else - if (FAILED(hr) && hr != D3DERR_INVALIDCALL) - { - os::Printer::log("DIRECT3D9 present failed.", ELL_WARNING); - return false; - } - - return true; -} - - - -//! queries the features of the driver, returns true if feature is available -bool CD3D9Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) -{ - switch (feature) - { - case EVDF_MULTITEXTURE: - case EVDF_BILINEAR_FILTER: - return true; - case EVDF_RENDER_TO_TARGET: - return Caps.NumSimultaneousRTs > 0; - case EVDF_HARDWARE_TL: - return (Caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) != 0; - case EVDF_MIP_MAP: - return (Caps.TextureCaps & D3DPTEXTURECAPS_MIPMAP) != 0; - case EVDF_STENCIL_BUFFER: - return StencilBuffer && Caps.StencilCaps; - case EVDF_VERTEX_SHADER_1_1: - return Caps.VertexShaderVersion >= D3DVS_VERSION(1,1); - case EVDF_VERTEX_SHADER_2_0: - return Caps.VertexShaderVersion >= D3DVS_VERSION(2,0); - case EVDF_VERTEX_SHADER_3_0: - return Caps.VertexShaderVersion >= D3DVS_VERSION(3,0); - case EVDF_PIXEL_SHADER_1_1: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,1); - case EVDF_PIXEL_SHADER_1_2: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,2); - case EVDF_PIXEL_SHADER_1_3: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,3); - case EVDF_PIXEL_SHADER_1_4: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,4); - case EVDF_PIXEL_SHADER_2_0: - return Caps.PixelShaderVersion >= D3DPS_VERSION(2,0); - case EVDF_PIXEL_SHADER_3_0: - return Caps.PixelShaderVersion >= D3DPS_VERSION(3,0); - case EVDF_HLSL: - return Caps.VertexShaderVersion >= D3DVS_VERSION(1,1); - case EVDF_TEXTURE_NPOT: - return (Caps.TextureCaps & D3DPTEXTURECAPS_POW2) == 0; - default: - return false; - }; -} - - - -//! sets transformation -void CD3D9Driver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) -{ - Transformation3DChanged = true; - - switch(state) - { - case ETS_VIEW: - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); - break; - case ETS_WORLD: - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); - break; - case ETS_PROJECTION: - pID3DDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); - break; - case ETS_TEXTURE_0: - case ETS_TEXTURE_1: - case ETS_TEXTURE_2: - case ETS_TEXTURE_3: - if (mat.isIdentity()) - break; - pID3DDevice->SetTextureStageState( state - ETS_TEXTURE_0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTransform((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+ ( state - ETS_TEXTURE_0 )), - (D3DMATRIX*)((void*)mat.pointer())); - break; - case ETS_COUNT: - break; - } - - Matrices[state] = mat; -} - - - -//! sets the current Texture -bool CD3D9Driver::setTexture(s32 stage, video::ITexture* texture) -{ - if (CurrentTexture[stage] == texture) - return true; - - if (texture && texture->getDriverType() != EDT_DIRECT3D9) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - if (CurrentTexture[stage]) - CurrentTexture[stage]->drop(); - - CurrentTexture[stage] = texture; - - if (!texture) - { - pID3DDevice->SetTexture(stage, 0); - pID3DDevice->SetTextureStageState( stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - } - else - { - pID3DDevice->SetTexture(stage, ((CD3D9Texture*)texture)->getDX9Texture()); - texture->grab(); - - } - return true; -} - - - -//! sets a material -void CD3D9Driver::setMaterial(const SMaterial& material) -{ - Material = material; - - for (u32 i=0; igetDriverType() != EDT_DIRECT3D9) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - // check for valid render target - - CD3D9Texture* tex = (CD3D9Texture*)texture; - - if (texture && !tex->isRenderTarget()) - { - os::Printer::log("Fatal Error: Tried to set a non render target texture as render target.", ELL_ERROR); - return false; - } - - if (texture && (tex->getSize().Width > ScreenSize.Width || - tex->getSize().Height > ScreenSize.Height )) - { - os::Printer::log("Error: Tried to set a render target texture which is bigger than the screen.", ELL_ERROR); - return false; - } - - // check if we should set the previous RT back - - bool ret = true; - - if (tex == 0) - { - if (PrevRenderTarget) - { - if (FAILED(pID3DDevice->SetRenderTarget(0, PrevRenderTarget))) - { - os::Printer::log("Error: Could not set back to previous render target.", ELL_ERROR); - ret = false; - } - - CurrentRendertargetSize = core::dimension2d(0,0); - PrevRenderTarget->Release(); - PrevRenderTarget = 0; - } - } - else - { - // we want to set a new target. so do this. - - // store previous target - - if (!PrevRenderTarget) - if (FAILED(pID3DDevice->GetRenderTarget(0, &PrevRenderTarget))) - { - os::Printer::log("Could not get previous render target.", ELL_ERROR); - return false; - } - - // set new render target - - if (FAILED(pID3DDevice->SetRenderTarget(0, tex->getRenderTargetSurface()))) - { - os::Printer::log("Error: Could not set render target.", ELL_ERROR); - return false; - } - - CurrentRendertargetSize = tex->getSize(); - } - - if (clearBackBuffer || clearZBuffer) - { - DWORD flags = 0; - - if (clearBackBuffer) - flags |= D3DCLEAR_TARGET; - - if (clearZBuffer) - flags |= D3DCLEAR_ZBUFFER; - - pID3DDevice->Clear(0, NULL, flags, color.color, 1.0f, 0); - } - - return ret; -} - - - -//! sets a viewport -void CD3D9Driver::setViewPort(const core::rect& area) -{ - core::rect vp = area; - core::rect rendert(0,0, ScreenSize.Width, ScreenSize.Height); - vp.clipAgainst(rendert); - - D3DVIEWPORT9 viewPort; - viewPort.X = vp.UpperLeftCorner.X; - viewPort.Y = vp.UpperLeftCorner.Y; - viewPort.Width = vp.getWidth(); - viewPort.Height = vp.getHeight(); - viewPort.MinZ = 0.0f; - viewPort.MaxZ = 1.0f; - - HRESULT hr = D3DERR_INVALIDCALL; - if (vp.getHeight()>0 && vp.getWidth()>0) - hr = pID3DDevice->SetViewport(&viewPort); - - if (FAILED(hr)) - os::Printer::log("Failed setting the viewport.", ELL_WARNING); - - ViewPort = vp; -} - - - -//! gets the area of the current viewport -const core::rect& CD3D9Driver::getViewPort() const -{ - return ViewPort; -} - - - -//! draws a vertex primitive list -void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) -{ - if (!checkPrimitiveCount(primitiveCount)) - return; - - CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType); - - if (!vertexCount || !primitiveCount) - return; - - setVertexShader(vType); - - size_t stride=0; - switch (vType) - { - case EVT_STANDARD: - stride=sizeof(S3DVertex); - break; - case EVT_2TCOORDS: - stride=sizeof(S3DVertex2TCoords); - break; - case EVT_TANGENTS: - stride=sizeof(S3DVertexTangents); - break; - } - if (setRenderStates3DMode()) - { - switch (pType) - { - case scene::EPT_POINTS: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_POINTLIST, 0, vertexCount, - primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); - break; - case scene::EPT_LINE_STRIP: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount, - primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); - break; - case scene::EPT_LINE_LOOP: - { - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount, - primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); - u16 tmpIndices[] = {0, primitiveCount}; - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, - 1, tmpIndices, D3DFMT_INDEX16, vertices, stride); - } - break; - case scene::EPT_LINES: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, - primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); - break; - case scene::EPT_TRIANGLE_STRIP: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount, - primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); - break; - case scene::EPT_TRIANGLE_FAN: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount, - primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); - break; - case scene::EPT_TRIANGLES: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vertexCount, - primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); - break; - } - } -} - - - -void CD3D9Driver::draw2DImage(video::ITexture* texture, const core::rect& destRect, - const core::rect& sourceRect, const core::rect* clipRect, - video::SColor* colors, bool useAlphaChannelOfTexture) -{ - if(!texture) - return; - - const core::dimension2d& ss = texture->getOriginalSize(); - core::rect tcoords; - tcoords.UpperLeftCorner.X = (f32)sourceRect.UpperLeftCorner.X / (f32)ss.Width; - tcoords.UpperLeftCorner.Y = (f32)sourceRect.UpperLeftCorner.Y / (f32)ss.Height; - tcoords.LowerRightCorner.X = (f32)sourceRect.LowerRightCorner.X / (f32)ss.Width; - tcoords.LowerRightCorner.Y = (f32)sourceRect.LowerRightCorner.Y / (f32)ss.Height; - - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - core::rect npos; - f32 xFact = 2.0f / ( renderTargetSize.Width ); - f32 yFact = 2.0f / ( renderTargetSize.Height ); - npos.UpperLeftCorner.X = ( destRect.UpperLeftCorner.X * xFact ) - 1.0f; - npos.UpperLeftCorner.Y = 1.0f - ( destRect.UpperLeftCorner.Y * yFact ); - npos.LowerRightCorner.X = ( destRect.LowerRightCorner.X * xFact ) - 1.0f; - npos.LowerRightCorner.Y = 1.0f - ( destRect.LowerRightCorner.Y * yFact ); - - video::SColor temp[4] = - { - 0xFFFFFFFF, - 0xFFFFFFFF, - 0xFFFFFFFF, - 0xFFFFFFFF - }; - - video::SColor* useColor = colors ? colors : temp; - - S3DVertex vtx[4]; // clock wise - vtx[0] = S3DVertex(npos.UpperLeftCorner.X, npos.UpperLeftCorner.Y , 0.0f, 0.0f, 0.0f, 0.0f, useColor[0], tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); - vtx[1] = S3DVertex(npos.LowerRightCorner.X, npos.UpperLeftCorner.Y , 0.0f, 0.0f, 0.0f, 0.0f, useColor[3], tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); - vtx[2] = S3DVertex(npos.LowerRightCorner.X, npos.LowerRightCorner.Y, 0.0f, 0.0f, 0.0f, 0.0f, useColor[2], tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); - vtx[3] = S3DVertex(npos.UpperLeftCorner.X, npos.LowerRightCorner.Y, 0.0f, 0.0f, 0.0f, 0.0f, useColor[1], tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - - s16 indices[6] = {0,1,2,0,2,3}; - - setRenderStates2DMode(useColor[0].getAlpha()<255 || useColor[1].getAlpha()<255 || useColor[2].getAlpha()<255 || useColor[3].getAlpha()<255, true, useAlphaChannelOfTexture); - - setTexture(0, texture); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16,&vtx[0], sizeof(S3DVertex)); - -} - - - -//! draws a 2d image, using a color and the alpha channel of the texture if -//! desired. The image is drawn at pos and clipped against clipRect (if != 0). -void CD3D9Driver::draw2DImage(video::ITexture* texture, - const core::position2d& pos, - const core::rect& sourceRect, - const core::rect* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - if (!texture) - return; - - if (!sourceRect.isValid()) - return; - - if (!setTexture(0, texture)) - return; - - core::position2d targetPos = pos; - core::position2d sourcePos = sourceRect.UpperLeftCorner; - core::dimension2d sourceSize(sourceRect.getSize()); - - core::dimension2d renderTargetSize = getCurrentRenderTargetSize(); - - if (clipRect) - { - if (targetPos.X < clipRect->UpperLeftCorner.X) - { - sourceSize.Width += targetPos.X - clipRect->UpperLeftCorner.X; - if (sourceSize.Width <= 0) - return; - - sourcePos.X -= targetPos.X - clipRect->UpperLeftCorner.X; - targetPos.X = clipRect->UpperLeftCorner.X; - } - - if (targetPos.X + sourceSize.Width > clipRect->LowerRightCorner.X) - { - sourceSize.Width -= (targetPos.X + sourceSize.Width) - clipRect->LowerRightCorner.X; - if (sourceSize.Width <= 0) - return; - } - - if (targetPos.Y < clipRect->UpperLeftCorner.Y) - { - sourceSize.Height += targetPos.Y - clipRect->UpperLeftCorner.Y; - if (sourceSize.Height <= 0) - return; - - sourcePos.Y -= targetPos.Y - clipRect->UpperLeftCorner.Y; - targetPos.Y = clipRect->UpperLeftCorner.Y; - } - - if (targetPos.Y + sourceSize.Height > clipRect->LowerRightCorner.Y) - { - sourceSize.Height -= (targetPos.Y + sourceSize.Height) - clipRect->LowerRightCorner.Y; - if (sourceSize.Height <= 0) - return; - } - } - - // clip these coordinates - - if (targetPos.X<0) - { - sourceSize.Width += targetPos.X; - if (sourceSize.Width <= 0) - return; - - sourcePos.X -= targetPos.X; - targetPos.X = 0; - } - - if (targetPos.X + sourceSize.Width > renderTargetSize.Width) - { - sourceSize.Width -= (targetPos.X + sourceSize.Width) - renderTargetSize.Width; - if (sourceSize.Width <= 0) - return; - } - - if (targetPos.Y<0) - { - sourceSize.Height += targetPos.Y; - if (sourceSize.Height <= 0) - return; - - sourcePos.Y -= targetPos.Y; - targetPos.Y = 0; - } - - if (targetPos.Y + sourceSize.Height > renderTargetSize.Height) - { - sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height; - if (sourceSize.Height <= 0) - return; - } - - // ok, we've clipped everything. - // now draw it. - - f32 xPlus = - renderTargetSize.Width / 2.f; - f32 xFact = 1.0f / (renderTargetSize.Width / 2.f); - - f32 yPlus = renderTargetSize.Height-(renderTargetSize.Height / 2.f); - f32 yFact = 1.0f / (renderTargetSize.Height / 2.f); - - core::rect tcoords; - tcoords.UpperLeftCorner.X = (((f32)sourcePos.X)+0.5f) / texture->getOriginalSize().Width ; - tcoords.UpperLeftCorner.Y = (((f32)sourcePos.Y)+0.5f) / texture->getOriginalSize().Height; - tcoords.LowerRightCorner.X = (((f32)sourcePos.X +0.5f + (f32)sourceSize.Width)) / texture->getOriginalSize().Width; - tcoords.LowerRightCorner.Y = (((f32)sourcePos.Y +0.5f + (f32)sourceSize.Height)) / texture->getOriginalSize().Height; - - core::rect poss(targetPos, sourceSize); - - setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); - - S3DVertex vtx[4]; - vtx[0] = S3DVertex((f32)(poss.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-poss.UpperLeftCorner.Y ) * yFact , 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); - vtx[1] = S3DVertex((f32)(poss.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus- poss.UpperLeftCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); - vtx[2] = S3DVertex((f32)(poss.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus-poss.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); - vtx[3] = S3DVertex((f32)(poss.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-poss.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - - s16 indices[6] = {0,1,2,0,2,3}; - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16,&vtx[0], sizeof(S3DVertex)); -} - - - -//!Draws a 2d rectangle with a gradient. -void CD3D9Driver::draw2DRectangle(const core::rect& position, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect* clip) -{ - core::rect pos(position); - - if (clip) - pos.clipAgainst(*clip); - - if (!pos.isValid()) - return; - - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - - s32 xPlus = -(renderTargetSize.Width>>1); - f32 xFact = 1.0f / (renderTargetSize.Width>>1); - - s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); - f32 yFact = 1.0f / (renderTargetSize.Height>>1); - - S3DVertex vtx[4]; - vtx[0] = S3DVertex((f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.UpperLeftCorner.Y) * yFact , 0.0f, 0.0f, 0.0f, 0.0f, colorLeftUp, 0.0f, 0.0f); - vtx[1] = S3DVertex((f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus- pos.UpperLeftCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorRightUp, 0.0f, 1.0f); - vtx[2] = S3DVertex((f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorRightDown, 1.0f, 0.0f); - vtx[3] = S3DVertex((f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorLeftDown, 1.0f, 1.0f); - - s16 indices[6] = {0,1,2,0,2,3}; - - setRenderStates2DMode( - colorLeftUp.getAlpha() < 255 || - colorRightUp.getAlpha() < 255 || - colorLeftDown.getAlpha() < 255 || - colorRightDown.getAlpha() < 255, false, false); - - setTexture(0,0); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); - -} - - - -//! Draws a 2d line. -void CD3D9Driver::draw2DLine(const core::position2d& start, - const core::position2d& end, - SColor color) -{ - // thanks to Vash TheStampede who sent in his implementation - - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - const s32 xPlus = -(renderTargetSize.Width>>1); - const f32 xFact = 1.0f / (renderTargetSize.Width>>1); - - const s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); - const f32 yFact = 1.0f / (renderTargetSize.Height>>1); - - S3DVertex vtx[2]; - vtx[0] = S3DVertex((f32)(start.X + xPlus) * xFact, - (f32)(yPlus - start.Y) * yFact, - 0.0f, // z - 0.0f, 0.0f, 0.0f, // normal - color, - 0.0f, 0.0f); // texture - - vtx[1] = S3DVertex((f32)(end.X+xPlus) * xFact, - (f32)(yPlus- end.Y) * yFact, - 0.0f, - 0.0f, 0.0f, 0.0f, - color, - 0.0f, 0.0f); - - setRenderStates2DMode(color.getAlpha() < 255, false, false); - setTexture(0,0); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, - &vtx[0], sizeof(S3DVertex) ); -} - - - -//! sets right vertex shader -void CD3D9Driver::setVertexShader(E_VERTEX_TYPE newType) -{ - if (newType != LastVertexType) - { - LastVertexType = newType; - HRESULT hr = 0; - - switch(newType) - { - case EVT_STANDARD: - hr = pID3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1); - break; - case EVT_2TCOORDS: - hr = pID3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX2); - break; - case EVT_TANGENTS: - hr = pID3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX3 | - D3DFVF_TEXCOORDSIZE2(0) | // real texture coord - D3DFVF_TEXCOORDSIZE3(1) | // misuse texture coord 2 for tangent - D3DFVF_TEXCOORDSIZE3(2) // misuse texture coord 3 for binormal - ); - break; - } - - if (FAILED(hr)) - { - os::Printer::log("Could not set vertex Shader.", ELL_ERROR); - return; - } - } -} - - - -//! sets the needed renderstates -bool CD3D9Driver::setRenderStates3DMode() -{ - if (!pID3DDevice) - return false; - - if (CurrentRenderMode != ERM_3D) - { - // switch back the matrices - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&Matrices[ETS_VIEW])); - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&Matrices[ETS_WORLD])); - pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&Matrices[ETS_PROJECTION])); - - pID3DDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE); - - ResetRenderStates = true; - } - - if (ResetRenderStates || LastMaterial != Material) - { - // unset old material - - if (CurrentRenderMode == ERM_3D && - LastMaterial.MaterialType != Material.MaterialType && - LastMaterial.MaterialType >= 0 && LastMaterial.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); - - // set new material. - - if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial( - Material, LastMaterial, ResetRenderStates, this); - } - - bool shaderOK = true; - if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - shaderOK = MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, LastVertexType); - - LastMaterial = Material; - - ResetRenderStates = false; - - CurrentRenderMode = ERM_3D; - - return shaderOK; -} - - - -//! Can be called by an IMaterialRenderer to make its work easier. -void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, - bool resetAllRenderstates) -{ - if (resetAllRenderstates || - lastmaterial.AmbientColor != material.AmbientColor || - lastmaterial.DiffuseColor != material.DiffuseColor || - lastmaterial.SpecularColor != material.SpecularColor || - lastmaterial.EmissiveColor != material.EmissiveColor || - lastmaterial.Shininess != material.Shininess) - { - D3DMATERIAL9 mat; - mat.Diffuse = colorToD3D(material.DiffuseColor); - mat.Ambient = colorToD3D(material.AmbientColor); - mat.Specular = colorToD3D(material.SpecularColor); - mat.Emissive = colorToD3D(material.EmissiveColor); - mat.Power = material.Shininess; - pID3DDevice->SetMaterial(&mat); - } - - // Bilinear and/or trilinear - if (resetAllRenderstates || - lastmaterial.BilinearFilter != material.BilinearFilter || - lastmaterial.TrilinearFilter != material.TrilinearFilter || - lastmaterial.AnisotropicFilter != material.AnisotropicFilter - //|| !LastTextureMipMapsAvailable[0] - //|| !LastTextureMipMapsAvailable[1] - ) - { - if (material.BilinearFilter || material.TrilinearFilter || material.AnisotropicFilter) - { - D3DTEXTUREFILTERTYPE tftMag = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) && material.AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; - D3DTEXTUREFILTERTYPE tftMin = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) && material.AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; - D3DTEXTUREFILTERTYPE tftMip = material.TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT; - - for (u32 st=0; stSetSamplerState(st, D3DSAMP_MAGFILTER, tftMag); - pID3DDevice->SetSamplerState(st, D3DSAMP_MINFILTER, tftMin); - pID3DDevice->SetSamplerState(st, D3DSAMP_MIPFILTER, tftMip); - } - } - else - { - for (u32 st=0; stSetSamplerState(st, D3DSAMP_MINFILTER, D3DTEXF_POINT); - pID3DDevice->SetSamplerState(st, D3DSAMP_MIPFILTER, D3DTEXF_NONE); - pID3DDevice->SetSamplerState(st, D3DSAMP_MAGFILTER, D3DTEXF_POINT); - } - } - } - - // fillmode - if (resetAllRenderstates || lastmaterial.Wireframe != material.Wireframe || lastmaterial.PointCloud != material.PointCloud) - { - if (material.Wireframe) - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); - else - if (material.PointCloud) - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_POINT); - else - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); - } - - // shademode - - if (resetAllRenderstates || lastmaterial.GouraudShading != material.GouraudShading) - { - if (material.GouraudShading) - pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); - else - pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); - } - - // lighting - - if (resetAllRenderstates || lastmaterial.Lighting != material.Lighting) - { - if (material.Lighting) - pID3DDevice->SetRenderState(D3DRS_LIGHTING, TRUE); - else - pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); - } - - // zbuffer - - if (resetAllRenderstates || lastmaterial.ZBuffer != material.ZBuffer) - { - switch (material.ZBuffer) - { - case 0: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - break; - case 1: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); - break; - case 2: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL); - break; - } - } - - // zwrite - if (resetAllRenderstates || lastmaterial.ZWriteEnable != material.ZWriteEnable) - { - if ( material.ZWriteEnable ) - pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE); - else - pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE); - } - - // back face culling - - if (resetAllRenderstates || lastmaterial.BackfaceCulling != material.BackfaceCulling) - { - if (material.BackfaceCulling) - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW); - else - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE); - } - - // fog - if (resetAllRenderstates || lastmaterial.FogEnable != material.FogEnable) - { - pID3DDevice->SetRenderState(D3DRS_FOGENABLE, material.FogEnable); - } - - // specular highlights - if (resetAllRenderstates || !core::equals(lastmaterial.Shininess,material.Shininess)) - { - bool enable = (material.Shininess!=0.0f); - pID3DDevice->SetRenderState(D3DRS_SPECULARENABLE, enable); - pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, enable); - pID3DDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL); - } - - // normalization - if (resetAllRenderstates || lastmaterial.NormalizeNormals != material.NormalizeNormals) - { - pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, material.NormalizeNormals); - } - - // texture address mode - for (u32 st=0; stSetSamplerState(st, D3DSAMP_ADDRESSU, mode ); - pID3DDevice->SetSamplerState(st, D3DSAMP_ADDRESSV, mode ); - } - } - - -} - - - -//! sets the needed renderstates -void CD3D9Driver::setRenderStatesStencilShadowMode(bool zfail) -{ - if ((CurrentRenderMode != ERM_SHADOW_VOLUME_ZFAIL && - CurrentRenderMode != ERM_SHADOW_VOLUME_ZPASS) || - Transformation3DChanged) - { - // switch back the matrices - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&Matrices[ETS_VIEW])); - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&Matrices[ETS_WORLD])); - pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&Matrices[ETS_PROJECTION])); - - Transformation3DChanged = false; - - setTexture(0,0); - setTexture(1,0); - setTexture(2,0); - setTexture(3,0); - - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetFVF(D3DFVF_XYZ); - LastVertexType = (video::E_VERTEX_TYPE)(-1); - - pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE ); - pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE ); - pID3DDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT); - - // unset last 3d material - if (CurrentRenderMode == ERM_3D && - Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); - - //pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); - //pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); - } - - if (CurrentRenderMode != ERM_SHADOW_VOLUME_ZPASS && !zfail) - { - // USE THE ZPASS METHOD - - pID3DDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP ); - - pID3DDevice->SetRenderState( D3DRS_STENCILREF, 0x1 ); - pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); - pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); - - pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO ); - pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); - } - else - if (CurrentRenderMode != ERM_SHADOW_VOLUME_ZFAIL && zfail) - { - // USE THE ZFAIL METHOD - - pID3DDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_KEEP ); - - pID3DDevice->SetRenderState( D3DRS_STENCILREF, 0x0 ); - pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); - pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); - - pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); - pID3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO ); - pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); - } - - CurrentRenderMode = zfail ? ERM_SHADOW_VOLUME_ZFAIL : ERM_SHADOW_VOLUME_ZPASS; -} - - - -//! sets the needed renderstates -void CD3D9Driver::setRenderStatesStencilFillMode(bool alpha) -{ - if (CurrentRenderMode != ERM_STENCIL_FILL || Transformation3DChanged) - { - core::matrix4 mat; - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); - pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); - - pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); - pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetRenderState(D3DRS_STENCILREF, 0x1); - pID3DDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_LESSEQUAL); - //pID3DDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_GREATEREQUAL); - pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState(D3DRS_STENCILMASK, 0xffffffff ); - pID3DDevice->SetRenderState(D3DRS_STENCILWRITEMASK, 0xffffffff ); - - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); - - Transformation3DChanged = false; - - if (alpha) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE ); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - } - - CurrentRenderMode = ERM_STENCIL_FILL; -} - - - -//! sets the needed renderstates -void CD3D9Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) -{ - if (!pID3DDevice) - return; - - if (CurrentRenderMode != ERM_2D || Transformation3DChanged) - { - core::matrix4 mat; - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); - pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); - - pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - //pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); - pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); - pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); - pID3DDevice->SetRenderState(D3DRS_SPECULARENABLE, FALSE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE ); - - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); - - pID3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP ); - pID3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP ); - - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0); - pID3DDevice->SetTransform( D3DTS_TEXTURE0, &UnitMatrixD3D9 ); - - Transformation3DChanged = false; - - // unset last 3d material - if (CurrentRenderMode == ERM_3D && - Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); - } - - if (texture) - { - pID3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); - pID3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE); - pID3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); - - if (alphaChannel) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - - if (alpha) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); - } - else - { - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - } - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - if (alpha) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - } - } - else - { - if (alpha) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE ); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - } - - CurrentRenderMode = ERM_2D; -} - - - -//! deletes all dynamic lights there are -void CD3D9Driver::deleteAllDynamicLights() -{ - for (s32 i=0; iLightEnable(i, false); - - LastSetLight = -1; - - CNullDriver::deleteAllDynamicLights(); -} - - - -//! adds a dynamic light -void CD3D9Driver::addDynamicLight(const SLight& dl) -{ - if ((u32)LastSetLight == Caps.MaxActiveLights-1) - return; - - CNullDriver::addDynamicLight(dl); - - D3DLIGHT9 light; - - if ( dl.Type == ELT_POINT ) - { - light.Type = D3DLIGHT_POINT; - light.Position = *(D3DVECTOR*)((void*)(&dl.Position)); - } - else - if ( dl.Type == ELT_DIRECTIONAL ) - { - light.Type = D3DLIGHT_DIRECTIONAL; - light.Direction = *(D3DVECTOR*)((void*)(&dl.Position)); - } - - light.Range = MaxLightDistance; - - light.Diffuse = *(D3DCOLORVALUE*)((void*)(&dl.DiffuseColor)); - light.Specular = *(D3DCOLORVALUE*)((void*)(&dl.SpecularColor)); - light.Ambient = *(D3DCOLORVALUE*)((void*)(&dl.AmbientColor)); - - light.Attenuation0 = 0.0f; - light.Attenuation1 = 1.f / dl.Radius; - light.Attenuation2 = 0.0f; - - ++LastSetLight; - pID3DDevice->SetLight(LastSetLight, &light); - pID3DDevice->LightEnable(LastSetLight, true); -} - - - -//! returns the maximal amount of dynamic lights the device can handle -u32 CD3D9Driver::getMaximalDynamicLightAmount() -{ - return Caps.MaxActiveLights; -} - - - -//! Sets the dynamic ambient light color. The default color is -//! (0,0,0,0) which means it is dark. -//! \param color: New color of the ambient light. -void CD3D9Driver::setAmbientLight(const SColorf& color) -{ - if (!pID3DDevice) - return; - - AmbientLight = color; - D3DCOLOR col = color.toSColor().color; - pID3DDevice->SetRenderState(D3DRS_AMBIENT, col); -} - - - -//! \return Returns the name of the video driver. Example: In case of the DIRECT3D9 -//! driver, it would return "Direct3D9.1". -const wchar_t* CD3D9Driver::getName() -{ - return L"Direct3D 9.0"; -} - - - -//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do -//! this: Frist, draw all geometry. Then use this method, to draw the shadow -//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. -void CD3D9Driver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail) -{ - if (!StencilBuffer || !count) - return; - - setRenderStatesStencilShadowMode(zfail); - - if (!zfail) - { - // ZPASS Method - - // Draw front-side of shadow volume in stencil/z only - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW ); - pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_INCRSAT); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - - // Now reverse cull order so front sides of shadow volume are written. - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW ); - pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_DECRSAT); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - } - else - { - // ZFAIL Method - - // Draw front-side of shadow volume in stencil/z only - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW ); - pID3DDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_INCRSAT ); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - - // Now reverse cull order so front sides of shadow volume are written. - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_DECRSAT ); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - } -} - - - -//! Fills the stencil shadow with color. After the shadow volume has been drawn -//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this -//! to draw the color of the shadow. -void CD3D9Driver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge, - video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge) -{ - if (!StencilBuffer) - return; - - S3DVertex vtx[4]; - vtx[0] = S3DVertex(1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftUpEdge, 0.0f, 0.0f); - vtx[1] = S3DVertex(1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightUpEdge, 0.0f, 1.0f); - vtx[2] = S3DVertex(-1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftDownEdge, 1.0f, 0.0f); - vtx[3] = S3DVertex(-1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightDownEdge, 1.0f, 1.0f); - - s16 indices[6] = {0,1,2,1,3,2}; - - setRenderStatesStencilFillMode( - leftUpEdge.getAlpha() < 255 || - rightUpEdge.getAlpha() < 255 || - leftDownEdge.getAlpha() < 255 || - rightDownEdge.getAlpha() < 255); - - setTexture(0,0); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); - - if (clearStencilBuffer) - pID3DDevice->Clear( 0, NULL, D3DCLEAR_STENCIL,0, 1.0, 0); -} - - - -//! Returns the maximum amount of primitives (mostly vertices) which -//! the device is able to render with one drawIndexedTriangleList -//! call. -u32 CD3D9Driver::getMaximalPrimitiveCount() -{ - return Caps.MaxPrimitiveCount; -} - - - -//! Sets the fog mode. -void CD3D9Driver::setFog(SColor color, bool linearFog, f32 start, - f32 end, f32 density, bool pixelFog, bool rangeFog) -{ - CNullDriver::setFog(color, linearFog, start, end, density, pixelFog, rangeFog); - - if (!pID3DDevice) - return; - - pID3DDevice->SetRenderState(D3DRS_FOGCOLOR, color.color); - - pID3DDevice->SetRenderState( - pixelFog ? D3DRS_FOGTABLEMODE : D3DRS_FOGVERTEXMODE, - linearFog ? D3DFOG_LINEAR : D3DFOG_EXP); - - if(linearFog) - { - pID3DDevice->SetRenderState(D3DRS_FOGSTART, *(DWORD*)(&start)); - pID3DDevice->SetRenderState(D3DRS_FOGEND, *(DWORD*)(&end)); - } - else - pID3DDevice->SetRenderState(D3DRS_FOGDENSITY, *(DWORD*)(&density)); - - if(!pixelFog) - pID3DDevice->SetRenderState(D3DRS_RANGEFOGENABLE, rangeFog); -} - - - -//! Draws a 3d line. -void CD3D9Driver::draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color) -{ - setVertexShader(EVT_STANDARD); - setRenderStates3DMode(); - video::S3DVertex v[2]; - v[0].Color = color; - v[1].Color = color; - v[0].Pos = start; - v[1].Pos = end; - - pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, v, sizeof(S3DVertex)); -} - - - -//! resets the device -bool CD3D9Driver::reset() -{ - // reset - HRESULT hr; - os::Printer::log("Resetting D3D9 device.", ELL_INFORMATION); - if (FAILED(hr = pID3DDevice->Reset(&present))) - { - if (hr == D3DERR_DEVICELOST) - { - DeviceLost = true; - os::Printer::log("Resetting failed due to device lost.", ELL_WARNING); - } - else - os::Printer::log("Resetting failed.", ELL_WARNING); - return false; - } - - DeviceLost = false; - ResetRenderStates = true; - LastVertexType = (E_VERTEX_TYPE)-1; - - for (u32 i=0; idrop(); - - CurrentTexture[i] = 0; - } - - setVertexShader(EVT_STANDARD); - setRenderStates3DMode(); - setFog(FogColor, LinearFog, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); - setAmbientLight(AmbientLight); - - return true; -} - - - -void CD3D9Driver::OnResize(const core::dimension2d& size) -{ - if (!pID3DDevice) - return; - - CNullDriver::OnResize(size); - present.BackBufferWidth = size.Width; - present.BackBufferHeight = size.Height; - - reset(); -} - - - -//! Returns type of video driver -E_DRIVER_TYPE CD3D9Driver::getDriverType() -{ - return EDT_DIRECT3D9; -} - - - -//! Returns the transformation set by setTransform -const core::matrix4& CD3D9Driver::getTransform(E_TRANSFORMATION_STATE state) -{ - return Matrices[state]; -} - - - -//! Sets a vertex shader constant. -void CD3D9Driver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ - if (data) - pID3DDevice->SetVertexShaderConstantF(startRegister, data, constantAmount); -} - -//! Sets a pixel shader constant. -void CD3D9Driver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ - if (data) - pID3DDevice->SetPixelShaderConstantF(startRegister, data, constantAmount); -} - -//! Sets a constant for the vertex shader based on a name. -bool CD3D9Driver::setVertexShaderConstant(const c8* name, const f32* floats, int count) -{ - if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - { - CD3D9MaterialRenderer* r = (CD3D9MaterialRenderer*)MaterialRenderers[Material.MaterialType].Renderer; - return r->setVariable(true, name, floats, count); - } - - return false; -} - -//! Sets a constant for the pixel shader based on a name. -bool CD3D9Driver::setPixelShaderConstant(const c8* name, const f32* floats, int count) -{ - if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - { - CD3D9MaterialRenderer* r = (CD3D9MaterialRenderer*)MaterialRenderers[Material.MaterialType].Renderer; - return r->setVariable(false, name, floats, count); - } - - return false; -} - -//! Returns pointer to the IGPUProgrammingServices interface. -IGPUProgrammingServices* CD3D9Driver::getGPUProgrammingServices() -{ - return this; -} - -//! Adds a new material renderer to the VideoDriver, using pixel and/or -//! vertex shaders to render geometry. -s32 CD3D9Driver::addShaderMaterial(const c8* vertexShaderProgram, - const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, s32 userData) -{ - s32 nr = -1; - CD3D9ShaderMaterialRenderer* r = new CD3D9ShaderMaterialRenderer( - pID3DDevice, this, nr, vertexShaderProgram, pixelShaderProgram, - callback, getMaterialRenderer(baseMaterial), userData); - - r->drop(); - return nr; -} - - -//! Adds a new material renderer to the VideoDriver, based on a high level shading -//! language. -s32 CD3D9Driver::addHighLevelShaderMaterial( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - s32 nr = -1; - - CD3D9HLSLMaterialRenderer* hlsl = new CD3D9HLSLMaterialRenderer( - pID3DDevice, this, nr, - vertexShaderProgram, - vertexShaderEntryPointName, - vsCompileTarget, - pixelShaderProgram, - pixelShaderEntryPointName, - psCompileTarget, - callback, - getMaterialRenderer(baseMaterial), - userData); - - hlsl->drop(); - return nr; -} - - -//! Returns a pointer to the IVideoDriver interface. (Implementation for -//! IMaterialRendererServices) -IVideoDriver* CD3D9Driver::getVideoDriver() -{ - return this; -} - - -//! Creates a render target texture. -ITexture* CD3D9Driver::createRenderTargetTexture(const core::dimension2d& size) -{ - return new CD3D9Texture(this, size, 0); -} - - -//! Clears the ZBuffer. -void CD3D9Driver::clearZBuffer() -{ - HRESULT hr = pID3DDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0, 0); - - if (FAILED(hr)) - os::Printer::log("CD3D9Driver clearZBuffer() failed.", ELL_WARNING); -} - - -//! Returns an image created from the last rendered frame. -IImage* CD3D9Driver::createScreenShot() -{ - HRESULT hr; - - // query the screen dimensions of the current adapter - D3DDISPLAYMODE displayMode; - pID3DDevice->GetDisplayMode(0, &displayMode); - - // create the image surface to store the front buffer image [always A8R8G8B8] - LPDIRECT3DSURFACE9 lpSurface; - if (FAILED(hr = pID3DDevice->CreateOffscreenPlainSurface(displayMode.Width, displayMode.Height, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &lpSurface, 0))) - return 0; - - // read the front buffer into the image surface - if (FAILED(hr = pID3DDevice->GetFrontBufferData(0, lpSurface))) - { - lpSurface->Release(); - return 0; - } - - RECT clientRect; - { - POINT clientPoint; - clientPoint.x = 0; - clientPoint.y = 0; - - ClientToScreen((HWND)getExposedVideoData().D3D8.HWnd, &clientPoint); - - clientRect.left = clientPoint.x; - clientRect.top = clientPoint.y; - clientRect.right = clientRect.left + ScreenSize.Width; - clientRect.bottom = clientRect.top + ScreenSize.Height; - } - - // lock our area of the surface - D3DLOCKED_RECT lockedRect; - if (FAILED(lpSurface->LockRect(&lockedRect, &clientRect, D3DLOCK_READONLY))) - { - lpSurface->Release(); - return 0; - } - - // this could throw, but we aren't going to worry about that case very much - IImage* newImage = new CImage(ECF_A8R8G8B8, ScreenSize); - - // d3d pads the image, so we need to copy the correct number of bytes - u32* pPixels = (u32*)newImage->lock(); - if (pPixels) - { - u8 * sP = (u8 *)lockedRect.pBits; - u32* dP = (u32*)pPixels; - - s32 y; - for (y = 0; y < ScreenSize.Height; ++y) - { - memcpy(dP, sP, ScreenSize.Width * 4); - - sP += lockedRect.Pitch; - dP += ScreenSize.Width; - } - - newImage->unlock(); - } - - // we can unlock and release the surface - lpSurface->UnlockRect(); - - // release the image surface - lpSurface->Release(); - - // return status of save operation to caller - return newImage; -} - - -// returns the current size of the screen or rendertarget -core::dimension2d CD3D9Driver::getCurrentRenderTargetSize() -{ - if ( CurrentRendertargetSize.Width == 0 ) - return ScreenSize; - else - return CurrentRendertargetSize; -} - - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ -#endif // _IRR_WINDOWS_ - - - - -namespace irr -{ -namespace video -{ - -#if (defined(_IRR_WINDOWS_) || defined(_XBOX)) -//! creates a video driver -IVideoDriver* createDirectX9Driver(const core::dimension2d& screenSize, HWND window, - u32 bits, bool fullscreen, bool stencilbuffer, - io::IFileSystem* io, bool pureSoftware, bool highPrecisionFPU, - bool vsync, bool antiAlias) -{ - #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - CD3D9Driver* dx9 = new CD3D9Driver(screenSize, window, fullscreen, stencilbuffer, io, pureSoftware); - if (!dx9->initDriver(screenSize, window, bits, fullscreen, pureSoftware, highPrecisionFPU, vsync, antiAlias)) - { - dx9->drop(); - dx9 = 0; - } - - return dx9; - - #else - - return 0; - - #endif // _IRR_COMPILE_WITH_DIRECT3D_9_ -} -#endif - -} // end namespace video -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_WINDOWS_ + +#define _IRR_DONT_DO_MEMORY_DEBUGGING_HERE +#include "CD3D9Driver.h" +#include "os.h" +#include "S3DVertex.h" +#include "CD3D9Texture.h" +#include "CImage.h" + +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + +#include "CD3D9MaterialRenderer.h" +#include "CD3D9ShaderMaterialRenderer.h" +#include "CD3D9NormalMapRenderer.h" +#include "CD3D9ParallaxMapRenderer.h" +#include "CD3D9HLSLMaterialRenderer.h" +#include + +namespace irr +{ +namespace video +{ + + +//! constructor +CD3D9Driver::CD3D9Driver(const core::dimension2d& screenSize, HWND window, + bool fullscreen, bool stencilbuffer, + io::IFileSystem* io, bool pureSoftware) +: CNullDriver(io, screenSize), CurrentRenderMode(ERM_NONE), + ResetRenderStates(true), Transformation3DChanged(false), StencilBuffer(stencilbuffer), + D3DLibrary(0), pID3D(0), pID3DDevice(0), PrevRenderTarget(0), + LastVertexType((video::E_VERTEX_TYPE)-1), MaxTextureUnits(0), + MaxLightDistance(sqrtf(FLT_MAX)), LastSetLight(-1), DeviceLost(false), + Fullscreen(fullscreen) +{ + #ifdef _DEBUG + setDebugName("CD3D9Driver"); + #endif + + printVersion(); + + for (u32 i=0; idrop(); + + // drop d3d9 + + if (pID3DDevice) + pID3DDevice->Release(); + + if (pID3D) + pID3D->Release(); +} + + + +void CD3D9Driver::createMaterialRenderers() +{ + // create D3D9 material renderers + + addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SOLID(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SOLID_2_LAYER(pID3DDevice, this)); + + // add the same renderer for all lightmap types + + CD3D9MaterialRenderer_LIGHTMAP* lmr = new CD3D9MaterialRenderer_LIGHTMAP(pID3DDevice, this); + addMaterialRenderer(lmr); // for EMT_LIGHTMAP: + addMaterialRenderer(lmr); // for EMT_LIGHTMAP_ADD: + addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M2: + addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M4: + addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING: + addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M2: + addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M4: + lmr->drop(); + + // add remaining fixed function pipeline material renderers + + addAndDropMaterialRenderer(new CD3D9MaterialRenderer_DETAIL_MAP(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SPHERE_MAP(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D9MaterialRenderer_REFLECTION_2_LAYER(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ADD_COLOR(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(pID3DDevice, this)); + addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(pID3DDevice, this)); + + // add normal map renderers + + s32 tmp = 0; + video::IMaterialRenderer* renderer = 0; + + renderer = new CD3D9NormalMapRenderer(pID3DDevice, this, tmp, + MaterialRenderers[EMT_SOLID].Renderer); + renderer->drop(); + + renderer = new CD3D9NormalMapRenderer(pID3DDevice, this, tmp, + MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); + renderer->drop(); + + renderer = new CD3D9NormalMapRenderer(pID3DDevice, this, tmp, + MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); + renderer->drop(); + + + // add parallax map renderers + + renderer = new CD3D9ParallaxMapRenderer(pID3DDevice, this, tmp, + MaterialRenderers[EMT_SOLID].Renderer); + renderer->drop(); + + renderer = new CD3D9ParallaxMapRenderer(pID3DDevice, this, tmp, + MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); + renderer->drop(); + + renderer = new CD3D9ParallaxMapRenderer(pID3DDevice, this, tmp, + MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); + renderer->drop(); + + + // add basic 1 texture blending + addAndDropMaterialRenderer(new CD3D9MaterialRenderer_ONETEXTURE_BLEND(pID3DDevice, this)); + +} + + + +//! initialises the Direct3D API +bool CD3D9Driver::initDriver(const core::dimension2d& screenSize, HWND hwnd, + u32 bits, bool fullScreen, bool pureSoftware, + bool highPrecisionFPU, bool vsync, bool antiAlias) +{ + HRESULT hr; + Fullscreen = fullScreen; + + if (!pID3D) + { + D3DLibrary = LoadLibrary( "d3d9.dll" ); + + if (!D3DLibrary) + { + os::Printer::log("Error, could not load d3d9.dll.", ELL_ERROR); + return false; + } + + typedef IDirect3D9 * (__stdcall *D3DCREATETYPE)(UINT); + D3DCREATETYPE d3dCreate = (D3DCREATETYPE) GetProcAddress(D3DLibrary, "Direct3DCreate9"); + + if (!d3dCreate) + { + os::Printer::log("Error, could not get proc adress of Direct3DCreate9.", ELL_ERROR); + return false; + } + + //just like pID3D = Direct3DCreate9(D3D_SDK_VERSION); + pID3D = (*d3dCreate)(D3D_SDK_VERSION); + + if (!pID3D) + { + os::Printer::log("Error initializing D3D.", ELL_ERROR); + return false; + } + } + + // print device information + D3DADAPTER_IDENTIFIER9 dai; + if (!FAILED(pID3D->GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0, &dai))) + { + char tmp[512]; + + s32 Product = HIWORD(dai.DriverVersion.HighPart); + s32 Version = LOWORD(dai.DriverVersion.HighPart); + s32 SubVersion = HIWORD(dai.DriverVersion.LowPart); + s32 Build = LOWORD(dai.DriverVersion.LowPart); + + sprintf(tmp, "%s %s %d.%d.%d.%d", dai.Description, dai.Driver, Product, Version, + SubVersion, Build); + os::Printer::log(tmp, ELL_INFORMATION); + } + + D3DDISPLAYMODE d3ddm; + hr = pID3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm); + if (FAILED(hr)) + { + os::Printer::log("Error: Could not get Adapter Display mode.", ELL_ERROR); + return false; + } + + ZeroMemory(&present, sizeof(present)); + + present.BackBufferCount = 1; + present.EnableAutoDepthStencil = TRUE; + if (vsync) + present.PresentationInterval = D3DPRESENT_INTERVAL_ONE; + else + present.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; + + if (fullScreen) + { + present.BackBufferWidth = screenSize.Width; + present.BackBufferHeight = screenSize.Height; + // request 32bit mode if user specified 32 bit, added by Thomas Stüfe + if (bits == 32) + present.BackBufferFormat = D3DFMT_X8R8G8B8; + else + present.BackBufferFormat = D3DFMT_R5G6B5; + present.SwapEffect = D3DSWAPEFFECT_FLIP; + present.Windowed = FALSE; + present.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; + } + else + { + present.BackBufferFormat = d3ddm.Format; + present.SwapEffect = D3DSWAPEFFECT_COPY; + present.Windowed = TRUE; + } + + D3DDEVTYPE devtype = D3DDEVTYPE_HAL; + #ifndef _IRR_D3D_NO_SHADER_DEBUGGING + devtype = D3DDEVTYPE_REF; + #endif + + // enable anti alias if possible and desired + if (antiAlias) + { + DWORD qualityLevels = 0; + + if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, + devtype, present.BackBufferFormat, !fullScreen, + D3DMULTISAMPLE_4_SAMPLES, &qualityLevels))) + { + // enable multi sampling + present.MultiSampleType = D3DMULTISAMPLE_4_SAMPLES; + present.MultiSampleQuality = qualityLevels-1; + present.SwapEffect = D3DSWAPEFFECT_DISCARD; + } + else + if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, + devtype, present.BackBufferFormat, !fullScreen, + D3DMULTISAMPLE_2_SAMPLES, &qualityLevels))) + { + // enable multi sampling + present.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES; + present.MultiSampleQuality = qualityLevels-1; + present.SwapEffect = D3DSWAPEFFECT_DISCARD; + } + else + if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, + devtype, present.BackBufferFormat, !fullScreen, + D3DMULTISAMPLE_NONMASKABLE, &qualityLevels))) + { + // enable non maskable multi sampling + present.SwapEffect = D3DSWAPEFFECT_DISCARD; + present.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE; + present.MultiSampleQuality = qualityLevels-1; + } + else + { + os::Printer::log("Anti aliasing disabled because hardware/driver lacks necessary caps.", ELL_WARNING); + antiAlias = false; + } + } + + // check stencil buffer compatibility + if (StencilBuffer) + { + present.AutoDepthStencilFormat = D3DFMT_D24S8; + if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, + present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, + D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) + { + present.AutoDepthStencilFormat = D3DFMT_D24X4S4; + if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, + present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, + D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) + { + present.AutoDepthStencilFormat = D3DFMT_D15S1; + if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, + present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, + D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) + { + os::Printer::log("Device does not support stencilbuffer, disabling stencil buffer.", ELL_WARNING); + StencilBuffer = false; + } + } + } + else + if(FAILED(pID3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, devtype, + present.BackBufferFormat, present.BackBufferFormat, present.AutoDepthStencilFormat))) + { + os::Printer::log("Depth-stencil format is not compatible with display format, disabling stencil buffer.", ELL_WARNING); + StencilBuffer = false; + } + } + // do not use else here to cope with flag change in previous block + if (!StencilBuffer) + { + present.AutoDepthStencilFormat = D3DFMT_D32; + if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, + present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, + D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) + { + present.AutoDepthStencilFormat = D3DFMT_D24X8; + if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, + present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, + D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) + { + present.AutoDepthStencilFormat = D3DFMT_D16; + if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, + present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, + D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) + { + os::Printer::log("Device does not support required depth buffer.", ELL_WARNING); + return false; + } + } + } + } + + // create device + + DWORD fpuPrecision = highPrecisionFPU ? D3DCREATE_FPU_PRESERVE : 0; + if (pureSoftware) + { + hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, hwnd, + fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); + + if (FAILED(hr)) + os::Printer::log("Was not able to create Direct3D9 software device.", ELL_ERROR); + } + else + { + hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, + fpuPrecision | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice); + + if(FAILED(hr)) + hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, + fpuPrecision | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice); + + if(FAILED(hr)) + hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, + fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); + + if (FAILED(hr)) + os::Printer::log("Was not able to create Direct3D9 device.", ELL_ERROR); + } + + if (!pID3DDevice) + { + os::Printer::log("Was not able to create DIRECT3D9 device.", ELL_ERROR); + return false; + } + + // get caps + pID3DDevice->GetDeviceCaps(&Caps); + + // disable stencilbuffer if necessary + if (StencilBuffer && + (!(Caps.StencilCaps & D3DSTENCILCAPS_DECRSAT) || + !(Caps.StencilCaps & D3DSTENCILCAPS_INCRSAT) || + !(Caps.StencilCaps & D3DSTENCILCAPS_KEEP))) + { + os::Printer::log("Device not able to use stencil buffer, disabling stencil buffer.", ELL_WARNING); + StencilBuffer = false; + } + + // set default vertex shader + setVertexShader(EVT_STANDARD); + + // enable antialiasing + if (antiAlias) + pID3DDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE); + + // set fog mode + setFog(FogColor, LinearFog, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); + + // set exposed data + ExposedData.D3D9.D3D9 = pID3D; + ExposedData.D3D9.D3DDev9 = pID3DDevice; + ExposedData.D3D9.HWnd = reinterpret_cast(hwnd); + + ResetRenderStates = true; + + // create materials + createMaterialRenderers(); + + MaxTextureUnits = core::min_((u32)Caps.MaxSimultaneousTextures, MATERIAL_MAX_TEXTURES); + + // set the renderstates + setRenderStates3DMode(); + + // set maximal anisotropy + pID3DDevice->SetSamplerState(0, D3DSAMP_MAXANISOTROPY, min(16, Caps.MaxAnisotropy)); + pID3DDevice->SetSamplerState(1, D3DSAMP_MAXANISOTROPY, min(16, Caps.MaxAnisotropy)); + pID3DDevice->SetSamplerState(2, D3DSAMP_MAXANISOTROPY, min(16, Caps.MaxAnisotropy)); + pID3DDevice->SetSamplerState(3, D3DSAMP_MAXANISOTROPY, min(16, Caps.MaxAnisotropy)); + + // so far so good. + return true; +} + + + +//! applications must call this method before performing any rendering. returns false if failed. +bool CD3D9Driver::beginScene(bool backBuffer, bool zBuffer, SColor color) +{ + CNullDriver::beginScene(backBuffer, zBuffer, color); + HRESULT hr; + + if (!pID3DDevice) + return false; + + if (DeviceLost) + { + if(FAILED(hr = pID3DDevice->TestCooperativeLevel())) + { + if (hr == D3DERR_DEVICELOST) + return false; + + if (hr == D3DERR_DEVICENOTRESET) + reset(); + return false; + } + } + + DWORD flags = 0; + + if (backBuffer) + flags |= D3DCLEAR_TARGET; + + if (zBuffer) + flags |= D3DCLEAR_ZBUFFER; + + if (StencilBuffer) + flags |= D3DCLEAR_STENCIL; + + hr = pID3DDevice->Clear( 0, NULL, flags, color.color, 1.0, 0); + if (FAILED(hr)) + os::Printer::log("DIRECT3D9 clear failed.", ELL_WARNING); + + hr = pID3DDevice->BeginScene(); + if (FAILED(hr)) + { + os::Printer::log("DIRECT3D9 begin scene failed.", ELL_WARNING); + return false; + } + + return true; +} + + + +//! applications must call this method after performing any rendering. returns false if failed. +bool CD3D9Driver::endScene( s32 windowId, core::rect* sourceRect ) +{ + if (DeviceLost) + return false; + + CNullDriver::endScene(); + + HRESULT hr = pID3DDevice->EndScene(); + if (FAILED(hr)) + { + os::Printer::log("DIRECT3D9 end scene failed.", ELL_WARNING); + return false; + } + + RECT* srcRct = 0; + RECT sourceRectData; + if ( sourceRect ) + { + srcRct = &sourceRectData; + sourceRectData.left = sourceRect->UpperLeftCorner.X; + sourceRectData.top = sourceRect->UpperLeftCorner.Y; + sourceRectData.right = sourceRect->LowerRightCorner.X; + sourceRectData.bottom = sourceRect->LowerRightCorner.Y; + } + + hr = pID3DDevice->Present(srcRct, NULL, (HWND)windowId, NULL); + + if (hr == D3DERR_DEVICELOST) + { + DeviceLost = true; + os::Printer::log("DIRECT3D9 device lost.", ELL_WARNING); + } + else + if (FAILED(hr) && hr != D3DERR_INVALIDCALL) + { + os::Printer::log("DIRECT3D9 present failed.", ELL_WARNING); + return false; + } + + return true; +} + + + +//! queries the features of the driver, returns true if feature is available +bool CD3D9Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) +{ + switch (feature) + { + case EVDF_MULTITEXTURE: + case EVDF_BILINEAR_FILTER: + return true; + case EVDF_RENDER_TO_TARGET: + return Caps.NumSimultaneousRTs > 0; + case EVDF_HARDWARE_TL: + return (Caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) != 0; + case EVDF_MIP_MAP: + return (Caps.TextureCaps & D3DPTEXTURECAPS_MIPMAP) != 0; + case EVDF_STENCIL_BUFFER: + return StencilBuffer && Caps.StencilCaps; + case EVDF_VERTEX_SHADER_1_1: + return Caps.VertexShaderVersion >= D3DVS_VERSION(1,1); + case EVDF_VERTEX_SHADER_2_0: + return Caps.VertexShaderVersion >= D3DVS_VERSION(2,0); + case EVDF_VERTEX_SHADER_3_0: + return Caps.VertexShaderVersion >= D3DVS_VERSION(3,0); + case EVDF_PIXEL_SHADER_1_1: + return Caps.PixelShaderVersion >= D3DPS_VERSION(1,1); + case EVDF_PIXEL_SHADER_1_2: + return Caps.PixelShaderVersion >= D3DPS_VERSION(1,2); + case EVDF_PIXEL_SHADER_1_3: + return Caps.PixelShaderVersion >= D3DPS_VERSION(1,3); + case EVDF_PIXEL_SHADER_1_4: + return Caps.PixelShaderVersion >= D3DPS_VERSION(1,4); + case EVDF_PIXEL_SHADER_2_0: + return Caps.PixelShaderVersion >= D3DPS_VERSION(2,0); + case EVDF_PIXEL_SHADER_3_0: + return Caps.PixelShaderVersion >= D3DPS_VERSION(3,0); + case EVDF_HLSL: + return Caps.VertexShaderVersion >= D3DVS_VERSION(1,1); + case EVDF_TEXTURE_NPOT: + return (Caps.TextureCaps & D3DPTEXTURECAPS_POW2) == 0; + default: + return false; + }; +} + + + +//! sets transformation +void CD3D9Driver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) +{ + Transformation3DChanged = true; + + switch(state) + { + case ETS_VIEW: + pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); + break; + case ETS_WORLD: + pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); + break; + case ETS_PROJECTION: + pID3DDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); + break; + case ETS_TEXTURE_0: + case ETS_TEXTURE_1: + case ETS_TEXTURE_2: + case ETS_TEXTURE_3: + if (mat.isIdentity()) + break; + pID3DDevice->SetTextureStageState( state - ETS_TEXTURE_0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); + pID3DDevice->SetTransform((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+ ( state - ETS_TEXTURE_0 )), + (D3DMATRIX*)((void*)mat.pointer())); + break; + case ETS_COUNT: + break; + } + + Matrices[state] = mat; +} + + + +//! sets the current Texture +bool CD3D9Driver::setTexture(s32 stage, video::ITexture* texture) +{ + if (CurrentTexture[stage] == texture) + return true; + + if (texture && texture->getDriverType() != EDT_DIRECT3D9) + { + os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); + return false; + } + + if (CurrentTexture[stage]) + CurrentTexture[stage]->drop(); + + CurrentTexture[stage] = texture; + + if (!texture) + { + pID3DDevice->SetTexture(stage, 0); + pID3DDevice->SetTextureStageState( stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); + } + else + { + pID3DDevice->SetTexture(stage, ((CD3D9Texture*)texture)->getDX9Texture()); + texture->grab(); + + } + return true; +} + + + +//! sets a material +void CD3D9Driver::setMaterial(const SMaterial& material) +{ + Material = material; + + for (u32 i=0; igetDriverType() != EDT_DIRECT3D9) + { + os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); + return false; + } + + // check for valid render target + + CD3D9Texture* tex = (CD3D9Texture*)texture; + + if (texture && !tex->isRenderTarget()) + { + os::Printer::log("Fatal Error: Tried to set a non render target texture as render target.", ELL_ERROR); + return false; + } + + if (texture && (tex->getSize().Width > ScreenSize.Width || + tex->getSize().Height > ScreenSize.Height )) + { + os::Printer::log("Error: Tried to set a render target texture which is bigger than the screen.", ELL_ERROR); + return false; + } + + // check if we should set the previous RT back + + bool ret = true; + + if (tex == 0) + { + if (PrevRenderTarget) + { + if (FAILED(pID3DDevice->SetRenderTarget(0, PrevRenderTarget))) + { + os::Printer::log("Error: Could not set back to previous render target.", ELL_ERROR); + ret = false; + } + + CurrentRendertargetSize = core::dimension2d(0,0); + PrevRenderTarget->Release(); + PrevRenderTarget = 0; + } + } + else + { + // we want to set a new target. so do this. + + // store previous target + + if (!PrevRenderTarget) + if (FAILED(pID3DDevice->GetRenderTarget(0, &PrevRenderTarget))) + { + os::Printer::log("Could not get previous render target.", ELL_ERROR); + return false; + } + + // set new render target + + if (FAILED(pID3DDevice->SetRenderTarget(0, tex->getRenderTargetSurface()))) + { + os::Printer::log("Error: Could not set render target.", ELL_ERROR); + return false; + } + + CurrentRendertargetSize = tex->getSize(); + } + + if (clearBackBuffer || clearZBuffer) + { + DWORD flags = 0; + + if (clearBackBuffer) + flags |= D3DCLEAR_TARGET; + + if (clearZBuffer) + flags |= D3DCLEAR_ZBUFFER; + + pID3DDevice->Clear(0, NULL, flags, color.color, 1.0f, 0); + } + + return ret; +} + + + +//! sets a viewport +void CD3D9Driver::setViewPort(const core::rect& area) +{ + core::rect vp = area; + core::rect rendert(0,0, ScreenSize.Width, ScreenSize.Height); + vp.clipAgainst(rendert); + + D3DVIEWPORT9 viewPort; + viewPort.X = vp.UpperLeftCorner.X; + viewPort.Y = vp.UpperLeftCorner.Y; + viewPort.Width = vp.getWidth(); + viewPort.Height = vp.getHeight(); + viewPort.MinZ = 0.0f; + viewPort.MaxZ = 1.0f; + + HRESULT hr = D3DERR_INVALIDCALL; + if (vp.getHeight()>0 && vp.getWidth()>0) + hr = pID3DDevice->SetViewport(&viewPort); + + if (FAILED(hr)) + os::Printer::log("Failed setting the viewport.", ELL_WARNING); + + ViewPort = vp; +} + + + +//! gets the area of the current viewport +const core::rect& CD3D9Driver::getViewPort() const +{ + return ViewPort; +} + + + +//! draws a vertex primitive list +void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) +{ + if (!checkPrimitiveCount(primitiveCount)) + return; + + CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType); + + if (!vertexCount || !primitiveCount) + return; + + setVertexShader(vType); + + size_t stride=0; + switch (vType) + { + case EVT_STANDARD: + stride=sizeof(S3DVertex); + break; + case EVT_2TCOORDS: + stride=sizeof(S3DVertex2TCoords); + break; + case EVT_TANGENTS: + stride=sizeof(S3DVertexTangents); + break; + } + if (setRenderStates3DMode()) + { + switch (pType) + { + case scene::EPT_POINTS: + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_POINTLIST, 0, vertexCount, + primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); + break; + case scene::EPT_LINE_STRIP: + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount, + primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); + break; + case scene::EPT_LINE_LOOP: + { + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount, + primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); + u16 tmpIndices[] = {0, primitiveCount}; + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, + 1, tmpIndices, D3DFMT_INDEX16, vertices, stride); + } + break; + case scene::EPT_LINES: + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, + primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); + break; + case scene::EPT_TRIANGLE_STRIP: + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount, + primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); + break; + case scene::EPT_TRIANGLE_FAN: + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount, + primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); + break; + case scene::EPT_TRIANGLES: + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vertexCount, + primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); + break; + } + } +} + + + +void CD3D9Driver::draw2DImage(video::ITexture* texture, const core::rect& destRect, + const core::rect& sourceRect, const core::rect* clipRect, + video::SColor* colors, bool useAlphaChannelOfTexture) +{ + if(!texture) + return; + + const core::dimension2d& ss = texture->getOriginalSize(); + core::rect tcoords; + tcoords.UpperLeftCorner.X = (f32)sourceRect.UpperLeftCorner.X / (f32)ss.Width; + tcoords.UpperLeftCorner.Y = (f32)sourceRect.UpperLeftCorner.Y / (f32)ss.Height; + tcoords.LowerRightCorner.X = (f32)sourceRect.LowerRightCorner.X / (f32)ss.Width; + tcoords.LowerRightCorner.Y = (f32)sourceRect.LowerRightCorner.Y / (f32)ss.Height; + + const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); + core::rect npos; + f32 xFact = 2.0f / ( renderTargetSize.Width ); + f32 yFact = 2.0f / ( renderTargetSize.Height ); + npos.UpperLeftCorner.X = ( destRect.UpperLeftCorner.X * xFact ) - 1.0f; + npos.UpperLeftCorner.Y = 1.0f - ( destRect.UpperLeftCorner.Y * yFact ); + npos.LowerRightCorner.X = ( destRect.LowerRightCorner.X * xFact ) - 1.0f; + npos.LowerRightCorner.Y = 1.0f - ( destRect.LowerRightCorner.Y * yFact ); + + video::SColor temp[4] = + { + 0xFFFFFFFF, + 0xFFFFFFFF, + 0xFFFFFFFF, + 0xFFFFFFFF + }; + + video::SColor* useColor = colors ? colors : temp; + + S3DVertex vtx[4]; // clock wise + vtx[0] = S3DVertex(npos.UpperLeftCorner.X, npos.UpperLeftCorner.Y , 0.0f, 0.0f, 0.0f, 0.0f, useColor[0], tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); + vtx[1] = S3DVertex(npos.LowerRightCorner.X, npos.UpperLeftCorner.Y , 0.0f, 0.0f, 0.0f, 0.0f, useColor[3], tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); + vtx[2] = S3DVertex(npos.LowerRightCorner.X, npos.LowerRightCorner.Y, 0.0f, 0.0f, 0.0f, 0.0f, useColor[2], tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); + vtx[3] = S3DVertex(npos.UpperLeftCorner.X, npos.LowerRightCorner.Y, 0.0f, 0.0f, 0.0f, 0.0f, useColor[1], tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); + + s16 indices[6] = {0,1,2,0,2,3}; + + setRenderStates2DMode(useColor[0].getAlpha()<255 || useColor[1].getAlpha()<255 || useColor[2].getAlpha()<255 || useColor[3].getAlpha()<255, true, useAlphaChannelOfTexture); + + setTexture(0, texture); + + setVertexShader(EVT_STANDARD); + + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], + D3DFMT_INDEX16,&vtx[0], sizeof(S3DVertex)); + +} + + + +//! draws a 2d image, using a color and the alpha channel of the texture if +//! desired. The image is drawn at pos and clipped against clipRect (if != 0). +void CD3D9Driver::draw2DImage(video::ITexture* texture, + const core::position2d& pos, + const core::rect& sourceRect, + const core::rect* clipRect, SColor color, + bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + if (!sourceRect.isValid()) + return; + + if (!setTexture(0, texture)) + return; + + core::position2d targetPos = pos; + core::position2d sourcePos = sourceRect.UpperLeftCorner; + core::dimension2d sourceSize(sourceRect.getSize()); + + core::dimension2d renderTargetSize = getCurrentRenderTargetSize(); + + if (clipRect) + { + if (targetPos.X < clipRect->UpperLeftCorner.X) + { + sourceSize.Width += targetPos.X - clipRect->UpperLeftCorner.X; + if (sourceSize.Width <= 0) + return; + + sourcePos.X -= targetPos.X - clipRect->UpperLeftCorner.X; + targetPos.X = clipRect->UpperLeftCorner.X; + } + + if (targetPos.X + sourceSize.Width > clipRect->LowerRightCorner.X) + { + sourceSize.Width -= (targetPos.X + sourceSize.Width) - clipRect->LowerRightCorner.X; + if (sourceSize.Width <= 0) + return; + } + + if (targetPos.Y < clipRect->UpperLeftCorner.Y) + { + sourceSize.Height += targetPos.Y - clipRect->UpperLeftCorner.Y; + if (sourceSize.Height <= 0) + return; + + sourcePos.Y -= targetPos.Y - clipRect->UpperLeftCorner.Y; + targetPos.Y = clipRect->UpperLeftCorner.Y; + } + + if (targetPos.Y + sourceSize.Height > clipRect->LowerRightCorner.Y) + { + sourceSize.Height -= (targetPos.Y + sourceSize.Height) - clipRect->LowerRightCorner.Y; + if (sourceSize.Height <= 0) + return; + } + } + + // clip these coordinates + + if (targetPos.X<0) + { + sourceSize.Width += targetPos.X; + if (sourceSize.Width <= 0) + return; + + sourcePos.X -= targetPos.X; + targetPos.X = 0; + } + + if (targetPos.X + sourceSize.Width > renderTargetSize.Width) + { + sourceSize.Width -= (targetPos.X + sourceSize.Width) - renderTargetSize.Width; + if (sourceSize.Width <= 0) + return; + } + + if (targetPos.Y<0) + { + sourceSize.Height += targetPos.Y; + if (sourceSize.Height <= 0) + return; + + sourcePos.Y -= targetPos.Y; + targetPos.Y = 0; + } + + if (targetPos.Y + sourceSize.Height > renderTargetSize.Height) + { + sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height; + if (sourceSize.Height <= 0) + return; + } + + // ok, we've clipped everything. + // now draw it. + + f32 xPlus = - renderTargetSize.Width / 2.f; + f32 xFact = 1.0f / (renderTargetSize.Width / 2.f); + + f32 yPlus = renderTargetSize.Height-(renderTargetSize.Height / 2.f); + f32 yFact = 1.0f / (renderTargetSize.Height / 2.f); + + core::rect tcoords; + tcoords.UpperLeftCorner.X = (((f32)sourcePos.X)+0.5f) / texture->getOriginalSize().Width ; + tcoords.UpperLeftCorner.Y = (((f32)sourcePos.Y)+0.5f) / texture->getOriginalSize().Height; + tcoords.LowerRightCorner.X = (((f32)sourcePos.X +0.5f + (f32)sourceSize.Width)) / texture->getOriginalSize().Width; + tcoords.LowerRightCorner.Y = (((f32)sourcePos.Y +0.5f + (f32)sourceSize.Height)) / texture->getOriginalSize().Height; + + core::rect poss(targetPos, sourceSize); + + setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); + + S3DVertex vtx[4]; + vtx[0] = S3DVertex((f32)(poss.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-poss.UpperLeftCorner.Y ) * yFact , 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); + vtx[1] = S3DVertex((f32)(poss.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus- poss.UpperLeftCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); + vtx[2] = S3DVertex((f32)(poss.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus-poss.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); + vtx[3] = S3DVertex((f32)(poss.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-poss.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); + + s16 indices[6] = {0,1,2,0,2,3}; + + setVertexShader(EVT_STANDARD); + + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], + D3DFMT_INDEX16,&vtx[0], sizeof(S3DVertex)); +} + + + +//!Draws a 2d rectangle with a gradient. +void CD3D9Driver::draw2DRectangle(const core::rect& position, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect* clip) +{ + core::rect pos(position); + + if (clip) + pos.clipAgainst(*clip); + + if (!pos.isValid()) + return; + + const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); + + s32 xPlus = -(renderTargetSize.Width>>1); + f32 xFact = 1.0f / (renderTargetSize.Width>>1); + + s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); + f32 yFact = 1.0f / (renderTargetSize.Height>>1); + + S3DVertex vtx[4]; + vtx[0] = S3DVertex((f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.UpperLeftCorner.Y) * yFact , 0.0f, 0.0f, 0.0f, 0.0f, colorLeftUp, 0.0f, 0.0f); + vtx[1] = S3DVertex((f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus- pos.UpperLeftCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorRightUp, 0.0f, 1.0f); + vtx[2] = S3DVertex((f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorRightDown, 1.0f, 0.0f); + vtx[3] = S3DVertex((f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorLeftDown, 1.0f, 1.0f); + + s16 indices[6] = {0,1,2,0,2,3}; + + setRenderStates2DMode( + colorLeftUp.getAlpha() < 255 || + colorRightUp.getAlpha() < 255 || + colorLeftDown.getAlpha() < 255 || + colorRightDown.getAlpha() < 255, false, false); + + setTexture(0,0); + + setVertexShader(EVT_STANDARD); + + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], + D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); + +} + + + +//! Draws a 2d line. +void CD3D9Driver::draw2DLine(const core::position2d& start, + const core::position2d& end, + SColor color) +{ + // thanks to Vash TheStampede who sent in his implementation + + const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); + const s32 xPlus = -(renderTargetSize.Width>>1); + const f32 xFact = 1.0f / (renderTargetSize.Width>>1); + + const s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); + const f32 yFact = 1.0f / (renderTargetSize.Height>>1); + + S3DVertex vtx[2]; + vtx[0] = S3DVertex((f32)(start.X + xPlus) * xFact, + (f32)(yPlus - start.Y) * yFact, + 0.0f, // z + 0.0f, 0.0f, 0.0f, // normal + color, + 0.0f, 0.0f); // texture + + vtx[1] = S3DVertex((f32)(end.X+xPlus) * xFact, + (f32)(yPlus- end.Y) * yFact, + 0.0f, + 0.0f, 0.0f, 0.0f, + color, + 0.0f, 0.0f); + + setRenderStates2DMode(color.getAlpha() < 255, false, false); + setTexture(0,0); + + setVertexShader(EVT_STANDARD); + + pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, + &vtx[0], sizeof(S3DVertex) ); +} + + + +//! sets right vertex shader +void CD3D9Driver::setVertexShader(E_VERTEX_TYPE newType) +{ + if (newType != LastVertexType) + { + LastVertexType = newType; + HRESULT hr = 0; + + switch(newType) + { + case EVT_STANDARD: + hr = pID3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1); + break; + case EVT_2TCOORDS: + hr = pID3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX2); + break; + case EVT_TANGENTS: + hr = pID3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX3 | + D3DFVF_TEXCOORDSIZE2(0) | // real texture coord + D3DFVF_TEXCOORDSIZE3(1) | // misuse texture coord 2 for tangent + D3DFVF_TEXCOORDSIZE3(2) // misuse texture coord 3 for binormal + ); + break; + } + + if (FAILED(hr)) + { + os::Printer::log("Could not set vertex Shader.", ELL_ERROR); + return; + } + } +} + + + +//! sets the needed renderstates +bool CD3D9Driver::setRenderStates3DMode() +{ + if (!pID3DDevice) + return false; + + if (CurrentRenderMode != ERM_3D) + { + // switch back the matrices + pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&Matrices[ETS_VIEW])); + pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&Matrices[ETS_WORLD])); + pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&Matrices[ETS_PROJECTION])); + + pID3DDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE); + + ResetRenderStates = true; + } + + if (ResetRenderStates || LastMaterial != Material) + { + // unset old material + + if (CurrentRenderMode == ERM_3D && + LastMaterial.MaterialType != Material.MaterialType && + LastMaterial.MaterialType >= 0 && LastMaterial.MaterialType < (s32)MaterialRenderers.size()) + MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); + + // set new material. + + if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial( + Material, LastMaterial, ResetRenderStates, this); + } + + bool shaderOK = true; + if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) + shaderOK = MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, LastVertexType); + + LastMaterial = Material; + + ResetRenderStates = false; + + CurrentRenderMode = ERM_3D; + + return shaderOK; +} + + + +//! Can be called by an IMaterialRenderer to make its work easier. +void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, + bool resetAllRenderstates) +{ + if (resetAllRenderstates || + lastmaterial.AmbientColor != material.AmbientColor || + lastmaterial.DiffuseColor != material.DiffuseColor || + lastmaterial.SpecularColor != material.SpecularColor || + lastmaterial.EmissiveColor != material.EmissiveColor || + lastmaterial.Shininess != material.Shininess) + { + D3DMATERIAL9 mat; + mat.Diffuse = colorToD3D(material.DiffuseColor); + mat.Ambient = colorToD3D(material.AmbientColor); + mat.Specular = colorToD3D(material.SpecularColor); + mat.Emissive = colorToD3D(material.EmissiveColor); + mat.Power = material.Shininess; + pID3DDevice->SetMaterial(&mat); + } + + // Bilinear and/or trilinear + if (resetAllRenderstates || + lastmaterial.BilinearFilter != material.BilinearFilter || + lastmaterial.TrilinearFilter != material.TrilinearFilter || + lastmaterial.AnisotropicFilter != material.AnisotropicFilter + //|| !LastTextureMipMapsAvailable[0] + //|| !LastTextureMipMapsAvailable[1] + ) + { + if (material.BilinearFilter || material.TrilinearFilter || material.AnisotropicFilter) + { + D3DTEXTUREFILTERTYPE tftMag = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) && material.AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; + D3DTEXTUREFILTERTYPE tftMin = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) && material.AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; + D3DTEXTUREFILTERTYPE tftMip = material.TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT; + + for (u32 st=0; stSetSamplerState(st, D3DSAMP_MAGFILTER, tftMag); + pID3DDevice->SetSamplerState(st, D3DSAMP_MINFILTER, tftMin); + pID3DDevice->SetSamplerState(st, D3DSAMP_MIPFILTER, tftMip); + } + } + else + { + for (u32 st=0; stSetSamplerState(st, D3DSAMP_MINFILTER, D3DTEXF_POINT); + pID3DDevice->SetSamplerState(st, D3DSAMP_MIPFILTER, D3DTEXF_NONE); + pID3DDevice->SetSamplerState(st, D3DSAMP_MAGFILTER, D3DTEXF_POINT); + } + } + } + + // fillmode + if (resetAllRenderstates || lastmaterial.Wireframe != material.Wireframe || lastmaterial.PointCloud != material.PointCloud) + { + if (material.Wireframe) + pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); + else + if (material.PointCloud) + pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_POINT); + else + pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); + } + + // shademode + + if (resetAllRenderstates || lastmaterial.GouraudShading != material.GouraudShading) + { + if (material.GouraudShading) + pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); + else + pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); + } + + // lighting + + if (resetAllRenderstates || lastmaterial.Lighting != material.Lighting) + { + if (material.Lighting) + pID3DDevice->SetRenderState(D3DRS_LIGHTING, TRUE); + else + pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); + } + + // zbuffer + + if (resetAllRenderstates || lastmaterial.ZBuffer != material.ZBuffer) + { + switch (material.ZBuffer) + { + case 0: + pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); + break; + case 1: + pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); + break; + case 2: + pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL); + break; + } + } + + // zwrite + if (resetAllRenderstates || lastmaterial.ZWriteEnable != material.ZWriteEnable) + { + if ( material.ZWriteEnable ) + pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE); + else + pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE); + } + + // back face culling + + if (resetAllRenderstates || lastmaterial.BackfaceCulling != material.BackfaceCulling) + { + if (material.BackfaceCulling) + pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW); + else + pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE); + } + + // fog + if (resetAllRenderstates || lastmaterial.FogEnable != material.FogEnable) + { + pID3DDevice->SetRenderState(D3DRS_FOGENABLE, material.FogEnable); + } + + // specular highlights + if (resetAllRenderstates || !core::equals(lastmaterial.Shininess,material.Shininess)) + { + bool enable = (material.Shininess!=0.0f); + pID3DDevice->SetRenderState(D3DRS_SPECULARENABLE, enable); + pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, enable); + pID3DDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL); + } + + // normalization + if (resetAllRenderstates || lastmaterial.NormalizeNormals != material.NormalizeNormals) + { + pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, material.NormalizeNormals); + } + + // texture address mode + for (u32 st=0; stSetSamplerState(st, D3DSAMP_ADDRESSU, mode ); + pID3DDevice->SetSamplerState(st, D3DSAMP_ADDRESSV, mode ); + } + } + + +} + + + +//! sets the needed renderstates +void CD3D9Driver::setRenderStatesStencilShadowMode(bool zfail) +{ + if ((CurrentRenderMode != ERM_SHADOW_VOLUME_ZFAIL && + CurrentRenderMode != ERM_SHADOW_VOLUME_ZPASS) || + Transformation3DChanged) + { + // switch back the matrices + pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&Matrices[ETS_VIEW])); + pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&Matrices[ETS_WORLD])); + pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&Matrices[ETS_PROJECTION])); + + Transformation3DChanged = false; + + setTexture(0,0); + setTexture(1,0); + setTexture(2,0); + setTexture(3,0); + + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetFVF(D3DFVF_XYZ); + LastVertexType = (video::E_VERTEX_TYPE)(-1); + + pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE ); + pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE ); + pID3DDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT); + + // unset last 3d material + if (CurrentRenderMode == ERM_3D && + Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); + + //pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); + //pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); + } + + if (CurrentRenderMode != ERM_SHADOW_VOLUME_ZPASS && !zfail) + { + // USE THE ZPASS METHOD + + pID3DDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS ); + pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); + pID3DDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP ); + + pID3DDevice->SetRenderState( D3DRS_STENCILREF, 0x1 ); + pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); + pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); + + pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO ); + pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); + } + else + if (CurrentRenderMode != ERM_SHADOW_VOLUME_ZFAIL && zfail) + { + // USE THE ZFAIL METHOD + + pID3DDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS ); + pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); + pID3DDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP ); + pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_KEEP ); + + pID3DDevice->SetRenderState( D3DRS_STENCILREF, 0x0 ); + pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); + pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); + + pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); + pID3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO ); + pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); + } + + CurrentRenderMode = zfail ? ERM_SHADOW_VOLUME_ZFAIL : ERM_SHADOW_VOLUME_ZPASS; +} + + + +//! sets the needed renderstates +void CD3D9Driver::setRenderStatesStencilFillMode(bool alpha) +{ + if (CurrentRenderMode != ERM_STENCIL_FILL || Transformation3DChanged) + { + core::matrix4 mat; + pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); + pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); + pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); + + pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); + pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); + pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetRenderState(D3DRS_STENCILREF, 0x1); + pID3DDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_LESSEQUAL); + //pID3DDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_GREATEREQUAL); + pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_KEEP ); + pID3DDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); + pID3DDevice->SetRenderState(D3DRS_STENCILMASK, 0xffffffff ); + pID3DDevice->SetRenderState(D3DRS_STENCILWRITEMASK, 0xffffffff ); + + pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); + + Transformation3DChanged = false; + + if (alpha) + { + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE ); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); + } + else + { + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + } + } + + CurrentRenderMode = ERM_STENCIL_FILL; +} + + + +//! sets the needed renderstates +void CD3D9Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) +{ + if (!pID3DDevice) + return; + + if (CurrentRenderMode != ERM_2D || Transformation3DChanged) + { + core::matrix4 mat; + pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); + pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); + pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); + + pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); + //pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); + pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); + pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); + pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); + pID3DDevice->SetRenderState(D3DRS_SPECULARENABLE, FALSE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE ); + + pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); + + pID3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP ); + pID3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP ); + + pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0); + pID3DDevice->SetTransform( D3DTS_TEXTURE0, &UnitMatrixD3D9 ); + + Transformation3DChanged = false; + + // unset last 3d material + if (CurrentRenderMode == ERM_3D && + Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); + } + + if (texture) + { + pID3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); + pID3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE); + pID3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); + + if (alphaChannel) + { + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + + if (alpha) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); + } + else + { + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + } + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); + } + else + { + if (alpha) + { + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); + } + else + { + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + } + } + } + else + { + if (alpha) + { + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE ); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); + } + else + { + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + } + } + + CurrentRenderMode = ERM_2D; +} + + + +//! deletes all dynamic lights there are +void CD3D9Driver::deleteAllDynamicLights() +{ + for (s32 i=0; iLightEnable(i, false); + + LastSetLight = -1; + + CNullDriver::deleteAllDynamicLights(); +} + + + +//! adds a dynamic light +void CD3D9Driver::addDynamicLight(const SLight& dl) +{ + if ((u32)LastSetLight == Caps.MaxActiveLights-1) + return; + + CNullDriver::addDynamicLight(dl); + + D3DLIGHT9 light; + + if ( dl.Type == ELT_POINT ) + { + light.Type = D3DLIGHT_POINT; + light.Position = *(D3DVECTOR*)((void*)(&dl.Position)); + } + else + if ( dl.Type == ELT_DIRECTIONAL ) + { + light.Type = D3DLIGHT_DIRECTIONAL; + light.Direction = *(D3DVECTOR*)((void*)(&dl.Position)); + } + + light.Range = MaxLightDistance; + + light.Diffuse = *(D3DCOLORVALUE*)((void*)(&dl.DiffuseColor)); + light.Specular = *(D3DCOLORVALUE*)((void*)(&dl.SpecularColor)); + light.Ambient = *(D3DCOLORVALUE*)((void*)(&dl.AmbientColor)); + + light.Attenuation0 = 0.0f; + light.Attenuation1 = 1.f / dl.Radius; + light.Attenuation2 = 0.0f; + + ++LastSetLight; + pID3DDevice->SetLight(LastSetLight, &light); + pID3DDevice->LightEnable(LastSetLight, true); +} + + + +//! returns the maximal amount of dynamic lights the device can handle +u32 CD3D9Driver::getMaximalDynamicLightAmount() +{ + return Caps.MaxActiveLights; +} + + + +//! Sets the dynamic ambient light color. The default color is +//! (0,0,0,0) which means it is dark. +//! \param color: New color of the ambient light. +void CD3D9Driver::setAmbientLight(const SColorf& color) +{ + if (!pID3DDevice) + return; + + AmbientLight = color; + D3DCOLOR col = color.toSColor().color; + pID3DDevice->SetRenderState(D3DRS_AMBIENT, col); +} + + + +//! \return Returns the name of the video driver. Example: In case of the DIRECT3D9 +//! driver, it would return "Direct3D9.1". +const wchar_t* CD3D9Driver::getName() +{ + return L"Direct3D 9.0"; +} + + + +//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do +//! this: Frist, draw all geometry. Then use this method, to draw the shadow +//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. +void CD3D9Driver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail) +{ + if (!StencilBuffer || !count) + return; + + setRenderStatesStencilShadowMode(zfail); + + if (!zfail) + { + // ZPASS Method + + // Draw front-side of shadow volume in stencil/z only + pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW ); + pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_INCRSAT); + pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); + + // Now reverse cull order so front sides of shadow volume are written. + pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW ); + pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_DECRSAT); + pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); + } + else + { + // ZFAIL Method + + // Draw front-side of shadow volume in stencil/z only + pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW ); + pID3DDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_INCRSAT ); + pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); + + // Now reverse cull order so front sides of shadow volume are written. + pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); + pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_DECRSAT ); + pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); + } +} + + + +//! Fills the stencil shadow with color. After the shadow volume has been drawn +//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this +//! to draw the color of the shadow. +void CD3D9Driver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge, + video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge) +{ + if (!StencilBuffer) + return; + + S3DVertex vtx[4]; + vtx[0] = S3DVertex(1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftUpEdge, 0.0f, 0.0f); + vtx[1] = S3DVertex(1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightUpEdge, 0.0f, 1.0f); + vtx[2] = S3DVertex(-1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftDownEdge, 1.0f, 0.0f); + vtx[3] = S3DVertex(-1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightDownEdge, 1.0f, 1.0f); + + s16 indices[6] = {0,1,2,1,3,2}; + + setRenderStatesStencilFillMode( + leftUpEdge.getAlpha() < 255 || + rightUpEdge.getAlpha() < 255 || + leftDownEdge.getAlpha() < 255 || + rightDownEdge.getAlpha() < 255); + + setTexture(0,0); + + setVertexShader(EVT_STANDARD); + + pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], + D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); + + if (clearStencilBuffer) + pID3DDevice->Clear( 0, NULL, D3DCLEAR_STENCIL,0, 1.0, 0); +} + + + +//! Returns the maximum amount of primitives (mostly vertices) which +//! the device is able to render with one drawIndexedTriangleList +//! call. +u32 CD3D9Driver::getMaximalPrimitiveCount() +{ + return Caps.MaxPrimitiveCount; +} + + + +//! Sets the fog mode. +void CD3D9Driver::setFog(SColor color, bool linearFog, f32 start, + f32 end, f32 density, bool pixelFog, bool rangeFog) +{ + CNullDriver::setFog(color, linearFog, start, end, density, pixelFog, rangeFog); + + if (!pID3DDevice) + return; + + pID3DDevice->SetRenderState(D3DRS_FOGCOLOR, color.color); + + pID3DDevice->SetRenderState( + pixelFog ? D3DRS_FOGTABLEMODE : D3DRS_FOGVERTEXMODE, + linearFog ? D3DFOG_LINEAR : D3DFOG_EXP); + + if(linearFog) + { + pID3DDevice->SetRenderState(D3DRS_FOGSTART, *(DWORD*)(&start)); + pID3DDevice->SetRenderState(D3DRS_FOGEND, *(DWORD*)(&end)); + } + else + pID3DDevice->SetRenderState(D3DRS_FOGDENSITY, *(DWORD*)(&density)); + + if(!pixelFog) + pID3DDevice->SetRenderState(D3DRS_RANGEFOGENABLE, rangeFog); +} + + + +//! Draws a 3d line. +void CD3D9Driver::draw3DLine(const core::vector3df& start, + const core::vector3df& end, SColor color) +{ + setVertexShader(EVT_STANDARD); + setRenderStates3DMode(); + video::S3DVertex v[2]; + v[0].Color = color; + v[1].Color = color; + v[0].Pos = start; + v[1].Pos = end; + + pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, v, sizeof(S3DVertex)); +} + + + +//! resets the device +bool CD3D9Driver::reset() +{ + // reset + HRESULT hr; + os::Printer::log("Resetting D3D9 device.", ELL_INFORMATION); + if (FAILED(hr = pID3DDevice->Reset(&present))) + { + if (hr == D3DERR_DEVICELOST) + { + DeviceLost = true; + os::Printer::log("Resetting failed due to device lost.", ELL_WARNING); + } + else + os::Printer::log("Resetting failed.", ELL_WARNING); + return false; + } + + DeviceLost = false; + ResetRenderStates = true; + LastVertexType = (E_VERTEX_TYPE)-1; + + for (u32 i=0; idrop(); + + CurrentTexture[i] = 0; + } + + setVertexShader(EVT_STANDARD); + setRenderStates3DMode(); + setFog(FogColor, LinearFog, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); + setAmbientLight(AmbientLight); + + return true; +} + + + +void CD3D9Driver::OnResize(const core::dimension2d& size) +{ + if (!pID3DDevice) + return; + + CNullDriver::OnResize(size); + present.BackBufferWidth = size.Width; + present.BackBufferHeight = size.Height; + + reset(); +} + + + +//! Returns type of video driver +E_DRIVER_TYPE CD3D9Driver::getDriverType() +{ + return EDT_DIRECT3D9; +} + + + +//! Returns the transformation set by setTransform +const core::matrix4& CD3D9Driver::getTransform(E_TRANSFORMATION_STATE state) +{ + return Matrices[state]; +} + + + +//! Sets a vertex shader constant. +void CD3D9Driver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) +{ + if (data) + pID3DDevice->SetVertexShaderConstantF(startRegister, data, constantAmount); +} + +//! Sets a pixel shader constant. +void CD3D9Driver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) +{ + if (data) + pID3DDevice->SetPixelShaderConstantF(startRegister, data, constantAmount); +} + +//! Sets a constant for the vertex shader based on a name. +bool CD3D9Driver::setVertexShaderConstant(const c8* name, const f32* floats, int count) +{ + if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) + { + CD3D9MaterialRenderer* r = (CD3D9MaterialRenderer*)MaterialRenderers[Material.MaterialType].Renderer; + return r->setVariable(true, name, floats, count); + } + + return false; +} + +//! Sets a constant for the pixel shader based on a name. +bool CD3D9Driver::setPixelShaderConstant(const c8* name, const f32* floats, int count) +{ + if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) + { + CD3D9MaterialRenderer* r = (CD3D9MaterialRenderer*)MaterialRenderers[Material.MaterialType].Renderer; + return r->setVariable(false, name, floats, count); + } + + return false; +} + +//! Returns pointer to the IGPUProgrammingServices interface. +IGPUProgrammingServices* CD3D9Driver::getGPUProgrammingServices() +{ + return this; +} + +//! Adds a new material renderer to the VideoDriver, using pixel and/or +//! vertex shaders to render geometry. +s32 CD3D9Driver::addShaderMaterial(const c8* vertexShaderProgram, + const c8* pixelShaderProgram, + IShaderConstantSetCallBack* callback, + E_MATERIAL_TYPE baseMaterial, s32 userData) +{ + s32 nr = -1; + CD3D9ShaderMaterialRenderer* r = new CD3D9ShaderMaterialRenderer( + pID3DDevice, this, nr, vertexShaderProgram, pixelShaderProgram, + callback, getMaterialRenderer(baseMaterial), userData); + + r->drop(); + return nr; +} + + +//! Adds a new material renderer to the VideoDriver, based on a high level shading +//! language. +s32 CD3D9Driver::addHighLevelShaderMaterial( + const c8* vertexShaderProgram, + const c8* vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8* pixelShaderProgram, + const c8* pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + IShaderConstantSetCallBack* callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) +{ + s32 nr = -1; + + CD3D9HLSLMaterialRenderer* hlsl = new CD3D9HLSLMaterialRenderer( + pID3DDevice, this, nr, + vertexShaderProgram, + vertexShaderEntryPointName, + vsCompileTarget, + pixelShaderProgram, + pixelShaderEntryPointName, + psCompileTarget, + callback, + getMaterialRenderer(baseMaterial), + userData); + + hlsl->drop(); + return nr; +} + + +//! Returns a pointer to the IVideoDriver interface. (Implementation for +//! IMaterialRendererServices) +IVideoDriver* CD3D9Driver::getVideoDriver() +{ + return this; +} + + +//! Creates a render target texture. +ITexture* CD3D9Driver::createRenderTargetTexture(const core::dimension2d& size) +{ + return new CD3D9Texture(this, size, 0); +} + + +//! Clears the ZBuffer. +void CD3D9Driver::clearZBuffer() +{ + HRESULT hr = pID3DDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0, 0); + + if (FAILED(hr)) + os::Printer::log("CD3D9Driver clearZBuffer() failed.", ELL_WARNING); +} + + +//! Returns an image created from the last rendered frame. +IImage* CD3D9Driver::createScreenShot() +{ + HRESULT hr; + + // query the screen dimensions of the current adapter + D3DDISPLAYMODE displayMode; + pID3DDevice->GetDisplayMode(0, &displayMode); + + // create the image surface to store the front buffer image [always A8R8G8B8] + LPDIRECT3DSURFACE9 lpSurface; + if (FAILED(hr = pID3DDevice->CreateOffscreenPlainSurface(displayMode.Width, displayMode.Height, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &lpSurface, 0))) + return 0; + + // read the front buffer into the image surface + if (FAILED(hr = pID3DDevice->GetFrontBufferData(0, lpSurface))) + { + lpSurface->Release(); + return 0; + } + + RECT clientRect; + { + POINT clientPoint; + clientPoint.x = 0; + clientPoint.y = 0; + + ClientToScreen((HWND)getExposedVideoData().D3D8.HWnd, &clientPoint); + + clientRect.left = clientPoint.x; + clientRect.top = clientPoint.y; + clientRect.right = clientRect.left + ScreenSize.Width; + clientRect.bottom = clientRect.top + ScreenSize.Height; + } + + // lock our area of the surface + D3DLOCKED_RECT lockedRect; + if (FAILED(lpSurface->LockRect(&lockedRect, &clientRect, D3DLOCK_READONLY))) + { + lpSurface->Release(); + return 0; + } + + // this could throw, but we aren't going to worry about that case very much + IImage* newImage = new CImage(ECF_A8R8G8B8, ScreenSize); + + // d3d pads the image, so we need to copy the correct number of bytes + u32* pPixels = (u32*)newImage->lock(); + if (pPixels) + { + u8 * sP = (u8 *)lockedRect.pBits; + u32* dP = (u32*)pPixels; + + s32 y; + for (y = 0; y < ScreenSize.Height; ++y) + { + memcpy(dP, sP, ScreenSize.Width * 4); + + sP += lockedRect.Pitch; + dP += ScreenSize.Width; + } + + newImage->unlock(); + } + + // we can unlock and release the surface + lpSurface->UnlockRect(); + + // release the image surface + lpSurface->Release(); + + // return status of save operation to caller + return newImage; +} + + +// returns the current size of the screen or rendertarget +core::dimension2d CD3D9Driver::getCurrentRenderTargetSize() +{ + if ( CurrentRendertargetSize.Width == 0 ) + return ScreenSize; + else + return CurrentRendertargetSize; +} + + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ +#endif // _IRR_WINDOWS_ + + + + +namespace irr +{ +namespace video +{ + +#if (defined(_IRR_WINDOWS_) || defined(_XBOX)) +//! creates a video driver +IVideoDriver* createDirectX9Driver(const core::dimension2d& screenSize, HWND window, + u32 bits, bool fullscreen, bool stencilbuffer, + io::IFileSystem* io, bool pureSoftware, bool highPrecisionFPU, + bool vsync, bool antiAlias) +{ + #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + CD3D9Driver* dx9 = new CD3D9Driver(screenSize, window, fullscreen, stencilbuffer, io, pureSoftware); + if (!dx9->initDriver(screenSize, window, bits, fullscreen, pureSoftware, highPrecisionFPU, vsync, antiAlias)) + { + dx9->drop(); + dx9 = 0; + } + + return dx9; + + #else + + return 0; + + #endif // _IRR_COMPILE_WITH_DIRECT3D_9_ +} +#endif + +} // end namespace video +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CD3D9Driver.h b/src/dep/src/irrlicht/CD3D9Driver.h index 3235899..bc16de4 100644 --- a/src/dep/src/irrlicht/CD3D9Driver.h +++ b/src/dep/src/irrlicht/CD3D9Driver.h @@ -1,290 +1,290 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_VIDEO_DIRECTX_9_H_INCLUDED__ -#define __C_VIDEO_DIRECTX_9_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_WINDOWS_ -#define WIN32_LEAN_AND_MEAN -#include "CNullDriver.h" -#include "IMaterialRendererServices.h" -#include -#endif - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ -#include "d3d9.h" - -namespace irr -{ -namespace video -{ - class CD3D9Driver : public CNullDriver, IMaterialRendererServices - { - public: - - //! constructor - CD3D9Driver(const core::dimension2d& screenSize, HWND window, bool fullscreen, - bool stencibuffer, io::IFileSystem* io, bool pureSoftware=false); - - //! destructor - virtual ~CD3D9Driver(); - - //! applications must call this method before performing any rendering. returns false if failed. - virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color); - - //! applications must call this method after performing any rendering. returns false if failed. - virtual bool endScene( s32 windowId = 0, core::rect* sourceRect=0 ); - - //! queries the features of the driver, returns true if feature is available - virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature); - - //! sets transformation - virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); - - //! sets a material - virtual void setMaterial(const SMaterial& material); - - //! sets a render target - virtual bool setRenderTarget(video::ITexture* texture, - bool clearBackBuffer=false, bool clearZBuffer=false, - SColor color=video::SColor(0,0,0,0)); - - //! sets a viewport - virtual void setViewPort(const core::rect& area); - - //! gets the area of the current viewport - virtual const core::rect& getViewPort() const; - - //! draws a vertex primitive list - virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); - - //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. - virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos, - const core::rect& sourceRect, const core::rect* clipRect = 0, - SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); - - //! Draws a part of the texture into the rectangle. - virtual void draw2DImage(video::ITexture* texture, const core::rect& destRect, - const core::rect& sourceRect, const core::rect* clipRect = 0, - video::SColor* colors=0, bool useAlphaChannelOfTexture=false); - - //!Draws an 2d rectangle with a gradient. - virtual void draw2DRectangle(const core::rect& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect* clip); - - //! Draws a 2d line. - virtual void draw2DLine(const core::position2d& start, - const core::position2d& end, - SColor color=SColor(255,255,255,255)); - - //! Draws a 3d line. - virtual void draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color = SColor(255,255,255,255)); - - //! initialises the Direct3D API - bool initDriver(const core::dimension2d& screenSize, HWND hwnd, - u32 bits, bool fullScreen, bool pureSoftware, - bool highPrecisionFPU, bool vsync, bool antiAlias); - - //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 - //! driver, it would return "Direct3D8.1". - virtual const wchar_t* getName(); - - //! deletes all dynamic lights there are - virtual void deleteAllDynamicLights(); - - //! adds a dynamic light - virtual void addDynamicLight(const SLight& light); - - //! returns the maximal amount of dynamic lights the device can handle - virtual u32 getMaximalDynamicLightAmount(); - - //! Sets the dynamic ambient light color. The default color is - //! (0,0,0,0) which means it is dark. - //! \param color: New color of the ambient light. - virtual void setAmbientLight(const SColorf& color); - - //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do - //! this: Frist, draw all geometry. Then use this method, to draw the shadow - //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. - virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail); - - //! Fills the stencil shadow with color. After the shadow volume has been drawn - //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this - //! to draw the color of the shadow. - virtual void drawStencilShadow(bool clearStencilBuffer=false, - video::SColor leftUpEdge = video::SColor(0,0,0,0), - video::SColor rightUpEdge = video::SColor(0,0,0,0), - video::SColor leftDownEdge = video::SColor(0,0,0,0), - video::SColor rightDownEdge = video::SColor(0,0,0,0)); - - //! Returns the maximum amount of primitives (mostly vertices) which - //! the device is able to render with one drawIndexedTriangleList - //! call. - virtual u32 getMaximalPrimitiveCount(); - - //! Enables or disables a texture creation flag. - virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled); - - //! Sets the fog mode. - virtual void setFog(SColor color, bool linearFog, f32 start, - f32 end, f32 density, bool pixelFog, bool rangeFog); - - //! Only used by the internal engine. Used to notify the driver that - //! the window was resized. - virtual void OnResize(const core::dimension2d& size); - - //! Can be called by an IMaterialRenderer to make its work easier. - virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates); - - //! Returns type of video driver - virtual E_DRIVER_TYPE getDriverType(); - - //! Returns the transformation set by setTransform - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state); - - //! Sets a vertex shader constant. - virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - - //! Sets a pixel shader constant. - virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - - //! Sets a constant for the vertex shader based on a name. - virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); - - //! Sets a constant for the pixel shader based on a name. - virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); - - //! Returns pointer to the IGPUProgrammingServices interface. - virtual IGPUProgrammingServices* getGPUProgrammingServices(); - - //! Returns a pointer to the IVideoDriver interface. (Implementation for - //! IMaterialRendererServices) - virtual IVideoDriver* getVideoDriver(); - - //! Creates a render target texture. - virtual ITexture* createRenderTargetTexture(const core::dimension2d& size); - - //! Clears the ZBuffer. - virtual void clearZBuffer(); - - //! Returns an image created from the last rendered frame. - virtual IImage* createScreenShot(); - - private: - - // enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. - enum E_RENDER_MODE - { - ERM_NONE = 0, // no render state has been set yet. - ERM_2D, // 2d drawing rendermode - ERM_3D, // 3d rendering mode - ERM_STENCIL_FILL, // stencil fill mode - ERM_SHADOW_VOLUME_ZFAIL, // stencil volume draw mode - ERM_SHADOW_VOLUME_ZPASS // stencil volume draw mode - }; - - //! sets right vertex shader - void setVertexShader(video::E_VERTEX_TYPE newType); - - //! sets the needed renderstates - bool setRenderStates3DMode(); - - //! sets the needed renderstates - void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); - - //! sets the needed renderstates - void setRenderStatesStencilFillMode(bool alpha); - - //! sets the needed renderstates - void setRenderStatesStencilShadowMode(bool zfail); - - //! sets the current Texture - bool setTexture(s32 stage, video::ITexture* texture); - - //! resets the device - bool reset(); - - //! returns a device dependent texture from a software surface (IImage) - //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES - virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const char* name); - - // returns the current size of the screen or rendertarget - core::dimension2d getCurrentRenderTargetSize(); - - //! Adds a new material renderer to the VideoDriver, using pixel and/or - //! vertex shaders to render geometry. - s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, s32 userData); - - //! Adds a new material renderer to the VideoDriver, based on a high level shading - //! language. - virtual s32 addHighLevelShaderMaterial( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName = "main", - E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, - const c8* pixelShaderProgram = 0, - const c8* pixelShaderEntryPointName = "main", - E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData=0); - - void createMaterialRenderers(); - - inline D3DCOLORVALUE colorToD3D(const SColor& col) - { - const f32 f = 1.0f / 255.0f; - D3DCOLORVALUE v; - v.r = col.getRed() * f; - v.g = col.getGreen() * f; - v.b = col.getBlue() * f; - v.a = col.getAlpha() * f; - return v; - } - - E_RENDER_MODE CurrentRenderMode; - D3DPRESENT_PARAMETERS present; - - SMaterial Material, LastMaterial; - bool ResetRenderStates; // bool to make all renderstates be reseted if set. - bool Transformation3DChanged; - bool StencilBuffer; - ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES]; - bool LastTextureMipMapsAvailable[MATERIAL_MAX_TEXTURES]; - core::matrix4 Matrices[ETS_COUNT]; // matrizes of the 3d mode we need to restore when we switch back from the 2d mode. - - HINSTANCE D3DLibrary; - IDirect3D9* pID3D; - IDirect3DDevice9* pID3DDevice; - - IDirect3DSurface9* PrevRenderTarget; - core::dimension2d CurrentRendertargetSize; - - D3DCAPS9 Caps; - - E_VERTEX_TYPE LastVertexType; - - u32 MaxTextureUnits; - f32 MaxLightDistance; - s32 LastSetLight; - bool DeviceLost; - bool Fullscreen; - - SColorf AmbientLight; - }; - - -} // end namespace video -} // end namespace irr - - -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ -#endif // __C_VIDEO_DIRECTX_8_H_INCLUDED__ - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_VIDEO_DIRECTX_9_H_INCLUDED__ +#define __C_VIDEO_DIRECTX_9_H_INCLUDED__ + +#include "IrrCompileConfig.h" + +#ifdef _IRR_WINDOWS_ +#define WIN32_LEAN_AND_MEAN +#include "CNullDriver.h" +#include "IMaterialRendererServices.h" +#include +#endif + +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ +#include "d3d9.h" + +namespace irr +{ +namespace video +{ + class CD3D9Driver : public CNullDriver, IMaterialRendererServices + { + public: + + //! constructor + CD3D9Driver(const core::dimension2d& screenSize, HWND window, bool fullscreen, + bool stencibuffer, io::IFileSystem* io, bool pureSoftware=false); + + //! destructor + virtual ~CD3D9Driver(); + + //! applications must call this method before performing any rendering. returns false if failed. + virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color); + + //! applications must call this method after performing any rendering. returns false if failed. + virtual bool endScene( s32 windowId = 0, core::rect* sourceRect=0 ); + + //! queries the features of the driver, returns true if feature is available + virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature); + + //! sets transformation + virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); + + //! sets a material + virtual void setMaterial(const SMaterial& material); + + //! sets a render target + virtual bool setRenderTarget(video::ITexture* texture, + bool clearBackBuffer=false, bool clearZBuffer=false, + SColor color=video::SColor(0,0,0,0)); + + //! sets a viewport + virtual void setViewPort(const core::rect& area); + + //! gets the area of the current viewport + virtual const core::rect& getViewPort() const; + + //! draws a vertex primitive list + virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); + + //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. + virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos, + const core::rect& sourceRect, const core::rect* clipRect = 0, + SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); + + //! Draws a part of the texture into the rectangle. + virtual void draw2DImage(video::ITexture* texture, const core::rect& destRect, + const core::rect& sourceRect, const core::rect* clipRect = 0, + video::SColor* colors=0, bool useAlphaChannelOfTexture=false); + + //!Draws an 2d rectangle with a gradient. + virtual void draw2DRectangle(const core::rect& pos, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect* clip); + + //! Draws a 2d line. + virtual void draw2DLine(const core::position2d& start, + const core::position2d& end, + SColor color=SColor(255,255,255,255)); + + //! Draws a 3d line. + virtual void draw3DLine(const core::vector3df& start, + const core::vector3df& end, SColor color = SColor(255,255,255,255)); + + //! initialises the Direct3D API + bool initDriver(const core::dimension2d& screenSize, HWND hwnd, + u32 bits, bool fullScreen, bool pureSoftware, + bool highPrecisionFPU, bool vsync, bool antiAlias); + + //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 + //! driver, it would return "Direct3D8.1". + virtual const wchar_t* getName(); + + //! deletes all dynamic lights there are + virtual void deleteAllDynamicLights(); + + //! adds a dynamic light + virtual void addDynamicLight(const SLight& light); + + //! returns the maximal amount of dynamic lights the device can handle + virtual u32 getMaximalDynamicLightAmount(); + + //! Sets the dynamic ambient light color. The default color is + //! (0,0,0,0) which means it is dark. + //! \param color: New color of the ambient light. + virtual void setAmbientLight(const SColorf& color); + + //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do + //! this: Frist, draw all geometry. Then use this method, to draw the shadow + //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. + virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail); + + //! Fills the stencil shadow with color. After the shadow volume has been drawn + //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this + //! to draw the color of the shadow. + virtual void drawStencilShadow(bool clearStencilBuffer=false, + video::SColor leftUpEdge = video::SColor(0,0,0,0), + video::SColor rightUpEdge = video::SColor(0,0,0,0), + video::SColor leftDownEdge = video::SColor(0,0,0,0), + video::SColor rightDownEdge = video::SColor(0,0,0,0)); + + //! Returns the maximum amount of primitives (mostly vertices) which + //! the device is able to render with one drawIndexedTriangleList + //! call. + virtual u32 getMaximalPrimitiveCount(); + + //! Enables or disables a texture creation flag. + virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled); + + //! Sets the fog mode. + virtual void setFog(SColor color, bool linearFog, f32 start, + f32 end, f32 density, bool pixelFog, bool rangeFog); + + //! Only used by the internal engine. Used to notify the driver that + //! the window was resized. + virtual void OnResize(const core::dimension2d& size); + + //! Can be called by an IMaterialRenderer to make its work easier. + virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates); + + //! Returns type of video driver + virtual E_DRIVER_TYPE getDriverType(); + + //! Returns the transformation set by setTransform + virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state); + + //! Sets a vertex shader constant. + virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); + + //! Sets a pixel shader constant. + virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); + + //! Sets a constant for the vertex shader based on a name. + virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); + + //! Sets a constant for the pixel shader based on a name. + virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); + + //! Returns pointer to the IGPUProgrammingServices interface. + virtual IGPUProgrammingServices* getGPUProgrammingServices(); + + //! Returns a pointer to the IVideoDriver interface. (Implementation for + //! IMaterialRendererServices) + virtual IVideoDriver* getVideoDriver(); + + //! Creates a render target texture. + virtual ITexture* createRenderTargetTexture(const core::dimension2d& size); + + //! Clears the ZBuffer. + virtual void clearZBuffer(); + + //! Returns an image created from the last rendered frame. + virtual IImage* createScreenShot(); + + private: + + // enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. + enum E_RENDER_MODE + { + ERM_NONE = 0, // no render state has been set yet. + ERM_2D, // 2d drawing rendermode + ERM_3D, // 3d rendering mode + ERM_STENCIL_FILL, // stencil fill mode + ERM_SHADOW_VOLUME_ZFAIL, // stencil volume draw mode + ERM_SHADOW_VOLUME_ZPASS // stencil volume draw mode + }; + + //! sets right vertex shader + void setVertexShader(video::E_VERTEX_TYPE newType); + + //! sets the needed renderstates + bool setRenderStates3DMode(); + + //! sets the needed renderstates + void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); + + //! sets the needed renderstates + void setRenderStatesStencilFillMode(bool alpha); + + //! sets the needed renderstates + void setRenderStatesStencilShadowMode(bool zfail); + + //! sets the current Texture + bool setTexture(s32 stage, video::ITexture* texture); + + //! resets the device + bool reset(); + + //! returns a device dependent texture from a software surface (IImage) + //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES + virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const char* name); + + // returns the current size of the screen or rendertarget + core::dimension2d getCurrentRenderTargetSize(); + + //! Adds a new material renderer to the VideoDriver, using pixel and/or + //! vertex shaders to render geometry. + s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram, + IShaderConstantSetCallBack* callback, + E_MATERIAL_TYPE baseMaterial, s32 userData); + + //! Adds a new material renderer to the VideoDriver, based on a high level shading + //! language. + virtual s32 addHighLevelShaderMaterial( + const c8* vertexShaderProgram, + const c8* vertexShaderEntryPointName = "main", + E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, + const c8* pixelShaderProgram = 0, + const c8* pixelShaderEntryPointName = "main", + E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, + IShaderConstantSetCallBack* callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData=0); + + void createMaterialRenderers(); + + inline D3DCOLORVALUE colorToD3D(const SColor& col) + { + const f32 f = 1.0f / 255.0f; + D3DCOLORVALUE v; + v.r = col.getRed() * f; + v.g = col.getGreen() * f; + v.b = col.getBlue() * f; + v.a = col.getAlpha() * f; + return v; + } + + E_RENDER_MODE CurrentRenderMode; + D3DPRESENT_PARAMETERS present; + + SMaterial Material, LastMaterial; + bool ResetRenderStates; // bool to make all renderstates be reseted if set. + bool Transformation3DChanged; + bool StencilBuffer; + ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES]; + bool LastTextureMipMapsAvailable[MATERIAL_MAX_TEXTURES]; + core::matrix4 Matrices[ETS_COUNT]; // matrizes of the 3d mode we need to restore when we switch back from the 2d mode. + + HINSTANCE D3DLibrary; + IDirect3D9* pID3D; + IDirect3DDevice9* pID3DDevice; + + IDirect3DSurface9* PrevRenderTarget; + core::dimension2d CurrentRendertargetSize; + + D3DCAPS9 Caps; + + E_VERTEX_TYPE LastVertexType; + + u32 MaxTextureUnits; + f32 MaxLightDistance; + s32 LastSetLight; + bool DeviceLost; + bool Fullscreen; + + SColorf AmbientLight; + }; + + +} // end namespace video +} // end namespace irr + + +#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ +#endif // __C_VIDEO_DIRECTX_8_H_INCLUDED__ + diff --git a/src/dep/src/irrlicht/CD3D9HLSLMaterialRenderer.cpp b/src/dep/src/irrlicht/CD3D9HLSLMaterialRenderer.cpp index 7d89cc5..d2bdd97 100644 --- a/src/dep/src/irrlicht/CD3D9HLSLMaterialRenderer.cpp +++ b/src/dep/src/irrlicht/CD3D9HLSLMaterialRenderer.cpp @@ -1,291 +1,291 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - -#include "CD3D9HLSLMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" -#include "IVideoDriver.h" -#include "os.h" -#include "irrString.h" - -#ifndef _IRR_D3D_NO_SHADER_DEBUGGING -#include -#endif - - -namespace irr -{ -namespace video -{ - - -//! Public constructor -CD3D9HLSLMaterialRenderer::CD3D9HLSLMaterialRenderer(IDirect3DDevice9* d3ddev, - video::IVideoDriver* driver, s32& outMaterialTypeNr, - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, - s32 userData) - : CD3D9ShaderMaterialRenderer(d3ddev, driver, callback, baseMaterial, userData), - VSConstantsTable(0), PSConstantsTable(0) -{ - outMaterialTypeNr = -1; - - // now create shaders - - if (vsCompileTarget < 0 || vsCompileTarget > EVST_COUNT) - { - os::Printer::log("Invalid HLSL vertex shader compilation target"); - return; - } - - if (!createHLSLVertexShader(vertexShaderProgram, - vertexShaderEntryPointName, VERTEX_SHADER_TYPE_NAMES[vsCompileTarget])) - return; - - if (!createHLSLPixelShader(pixelShaderProgram, - pixelShaderEntryPointName, PIXEL_SHADER_TYPE_NAMES[psCompileTarget])) - return; - - // register myself as new material - outMaterialTypeNr = Driver->addMaterialRenderer(this); -} - - //! Destructor -CD3D9HLSLMaterialRenderer::~CD3D9HLSLMaterialRenderer() -{ - if (VSConstantsTable) - VSConstantsTable->Release(); - - if (PSConstantsTable) - PSConstantsTable->Release(); -} - - -bool CD3D9HLSLMaterialRenderer::createHLSLVertexShader(const char* vertexShaderProgram, - const char* shaderEntryPointName, - const char* shaderTargetName) -{ - if (!vertexShaderProgram) - return true; - - LPD3DXBUFFER buffer = 0; - LPD3DXBUFFER errors = 0; - - #ifdef _IRR_D3D_NO_SHADER_DEBUGGING - - // compile without debug info - - HRESULT h = stubD3DXCompileShader( - vertexShaderProgram, - strlen(vertexShaderProgram), - 0, // macros - 0, // no includes - shaderEntryPointName, - shaderTargetName, - 0, // no flags - &buffer, - &errors, - &VSConstantsTable); - - #else - - // compile shader and emitt some debug informations to - // make it possible to debug the shader in visual studio - - static int irr_dbg_hlsl_file_nr = 0; - ++irr_dbg_hlsl_file_nr; - char tmp[32]; - sprintf(tmp, "irr_d3d9_dbg_hlsl_%d.vsh", irr_dbg_hlsl_file_nr); - - FILE* f = fopen(tmp, "wb"); - fwrite(vertexShaderProgram, strlen(vertexShaderProgram), 1, f); - fflush(f); - fclose(f); - - HRESULT h = stubD3DXCompileShaderFromFile( - tmp, - 0, // macros - 0, // no includes - shaderEntryPointName, - shaderTargetName, - D3DXSHADER_DEBUG | D3DXSHADER_SKIPOPTIMIZATION, - &buffer, - &errors, - &VSConstantsTable); - - #endif - - if (FAILED(h)) - { - os::Printer::log("HLSL vertex shader compilation failed:"); - if (errors) - { - os::Printer::log((c8*)errors->GetBufferPointer()); - errors->Release(); - if (buffer) - buffer->Release(); - } - return false; - } - - if (errors) - errors->Release(); - - if (buffer) - { - if (FAILED(pID3DDevice->CreateVertexShader((DWORD*)buffer->GetBufferPointer(), - &VertexShader))) - { - os::Printer::log("Could not create hlsl vertex shader."); - buffer->Release(); - return false; - } - - buffer->Release(); - return true; - } - - return false; -} - - -bool CD3D9HLSLMaterialRenderer::createHLSLPixelShader(const char* pixelShaderProgram, - const char* shaderEntryPointName, - const char* shaderTargetName) -{ - if (!pixelShaderProgram) - return true; - - LPD3DXBUFFER buffer = 0; - LPD3DXBUFFER errors = 0; - - HRESULT h = stubD3DXCompileShader( - pixelShaderProgram, - strlen(pixelShaderProgram), - 0, // macros - 0, // no includes - shaderEntryPointName, - shaderTargetName, - 0, // no flags (D3DXSHADER_DEBUG) - &buffer, - &errors, - &PSConstantsTable); - - if (FAILED(h)) - { - os::Printer::log("HLSL pixel shader compilation failed:"); - if (errors) - { - os::Printer::log((c8*)errors->GetBufferPointer()); - errors->Release(); - if (buffer) - buffer->Release(); - } - return false; - } - - if (errors) - errors->Release(); - - if (buffer) - { - if (FAILED(pID3DDevice->CreatePixelShader((DWORD*)buffer->GetBufferPointer(), - &PixelShader))) - { - os::Printer::log("Could not create hlsl pixel shader."); - buffer->Release(); - return false; - } - - buffer->Release(); - return true; - } - - return false; -} - - -bool CD3D9HLSLMaterialRenderer::setVariable(bool vertexShader, const c8* name, - const f32* floats, int count) -{ - LPD3DXCONSTANTTABLE tbl = vertexShader ? VSConstantsTable : PSConstantsTable; - if (!tbl) - return false; - - // currently we only support top level parameters. - // Should be enough for the beginning. (TODO) - - D3DXHANDLE hndl = tbl->GetConstantByName(NULL, name); - if (!hndl) - { - core::stringc s = "HLSL Variable to set not found: '"; - s += name; - s += "'. Available variables are:"; - os::Printer::log(s.c_str(), ELL_WARNING); - printHLSLVariables(tbl); - return false; - } - - HRESULT hr = tbl->SetFloatArray(pID3DDevice, hndl, floats, count); - if (FAILED(hr)) - { - os::Printer::log("Error setting float array for HLSL variable", ELL_WARNING); - return false; - } - - return true; -} - -bool CD3D9HLSLMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) -{ - if (VSConstantsTable) - VSConstantsTable->SetDefaults(pID3DDevice); - - return CD3D9ShaderMaterialRenderer::OnRender(service, vtxtype); -} - -void CD3D9HLSLMaterialRenderer::printHLSLVariables(LPD3DXCONSTANTTABLE table) -{ - // currently we only support top level parameters. - // Should be enough for the beginning. (TODO) - - // print out constant names - D3DXCONSTANTTABLE_DESC tblDesc; - HRESULT hr = table->GetDesc(&tblDesc); - if (!FAILED(hr)) - { - for (int i=0; i<(int)tblDesc.Constants; ++i) - { - D3DXCONSTANT_DESC d; - UINT n = 1; - D3DXHANDLE cHndl = table->GetConstant(NULL, i); - if (!FAILED(table->GetConstantDesc(cHndl, &d, &n))) - { - core::stringc s = " '"; - s += d.Name; - s += "' Registers:[begin:"; - s += (int)d.RegisterIndex; - s += ", count:"; - s += (int)d.RegisterCount; - s += "]"; - os::Printer::log(s.c_str()); - } - } - } -} - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + +#include "CD3D9HLSLMaterialRenderer.h" +#include "IShaderConstantSetCallBack.h" +#include "IVideoDriver.h" +#include "os.h" +#include "irrString.h" + +#ifndef _IRR_D3D_NO_SHADER_DEBUGGING +#include +#endif + + +namespace irr +{ +namespace video +{ + + +//! Public constructor +CD3D9HLSLMaterialRenderer::CD3D9HLSLMaterialRenderer(IDirect3DDevice9* d3ddev, + video::IVideoDriver* driver, s32& outMaterialTypeNr, + const c8* vertexShaderProgram, + const c8* vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8* pixelShaderProgram, + const c8* pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + IShaderConstantSetCallBack* callback, + IMaterialRenderer* baseMaterial, + s32 userData) + : CD3D9ShaderMaterialRenderer(d3ddev, driver, callback, baseMaterial, userData), + VSConstantsTable(0), PSConstantsTable(0) +{ + outMaterialTypeNr = -1; + + // now create shaders + + if (vsCompileTarget < 0 || vsCompileTarget > EVST_COUNT) + { + os::Printer::log("Invalid HLSL vertex shader compilation target"); + return; + } + + if (!createHLSLVertexShader(vertexShaderProgram, + vertexShaderEntryPointName, VERTEX_SHADER_TYPE_NAMES[vsCompileTarget])) + return; + + if (!createHLSLPixelShader(pixelShaderProgram, + pixelShaderEntryPointName, PIXEL_SHADER_TYPE_NAMES[psCompileTarget])) + return; + + // register myself as new material + outMaterialTypeNr = Driver->addMaterialRenderer(this); +} + + //! Destructor +CD3D9HLSLMaterialRenderer::~CD3D9HLSLMaterialRenderer() +{ + if (VSConstantsTable) + VSConstantsTable->Release(); + + if (PSConstantsTable) + PSConstantsTable->Release(); +} + + +bool CD3D9HLSLMaterialRenderer::createHLSLVertexShader(const char* vertexShaderProgram, + const char* shaderEntryPointName, + const char* shaderTargetName) +{ + if (!vertexShaderProgram) + return true; + + LPD3DXBUFFER buffer = 0; + LPD3DXBUFFER errors = 0; + + #ifdef _IRR_D3D_NO_SHADER_DEBUGGING + + // compile without debug info + + HRESULT h = stubD3DXCompileShader( + vertexShaderProgram, + strlen(vertexShaderProgram), + 0, // macros + 0, // no includes + shaderEntryPointName, + shaderTargetName, + 0, // no flags + &buffer, + &errors, + &VSConstantsTable); + + #else + + // compile shader and emitt some debug informations to + // make it possible to debug the shader in visual studio + + static int irr_dbg_hlsl_file_nr = 0; + ++irr_dbg_hlsl_file_nr; + char tmp[32]; + sprintf(tmp, "irr_d3d9_dbg_hlsl_%d.vsh", irr_dbg_hlsl_file_nr); + + FILE* f = fopen(tmp, "wb"); + fwrite(vertexShaderProgram, strlen(vertexShaderProgram), 1, f); + fflush(f); + fclose(f); + + HRESULT h = stubD3DXCompileShaderFromFile( + tmp, + 0, // macros + 0, // no includes + shaderEntryPointName, + shaderTargetName, + D3DXSHADER_DEBUG | D3DXSHADER_SKIPOPTIMIZATION, + &buffer, + &errors, + &VSConstantsTable); + + #endif + + if (FAILED(h)) + { + os::Printer::log("HLSL vertex shader compilation failed:"); + if (errors) + { + os::Printer::log((c8*)errors->GetBufferPointer()); + errors->Release(); + if (buffer) + buffer->Release(); + } + return false; + } + + if (errors) + errors->Release(); + + if (buffer) + { + if (FAILED(pID3DDevice->CreateVertexShader((DWORD*)buffer->GetBufferPointer(), + &VertexShader))) + { + os::Printer::log("Could not create hlsl vertex shader."); + buffer->Release(); + return false; + } + + buffer->Release(); + return true; + } + + return false; +} + + +bool CD3D9HLSLMaterialRenderer::createHLSLPixelShader(const char* pixelShaderProgram, + const char* shaderEntryPointName, + const char* shaderTargetName) +{ + if (!pixelShaderProgram) + return true; + + LPD3DXBUFFER buffer = 0; + LPD3DXBUFFER errors = 0; + + HRESULT h = stubD3DXCompileShader( + pixelShaderProgram, + strlen(pixelShaderProgram), + 0, // macros + 0, // no includes + shaderEntryPointName, + shaderTargetName, + 0, // no flags (D3DXSHADER_DEBUG) + &buffer, + &errors, + &PSConstantsTable); + + if (FAILED(h)) + { + os::Printer::log("HLSL pixel shader compilation failed:"); + if (errors) + { + os::Printer::log((c8*)errors->GetBufferPointer()); + errors->Release(); + if (buffer) + buffer->Release(); + } + return false; + } + + if (errors) + errors->Release(); + + if (buffer) + { + if (FAILED(pID3DDevice->CreatePixelShader((DWORD*)buffer->GetBufferPointer(), + &PixelShader))) + { + os::Printer::log("Could not create hlsl pixel shader."); + buffer->Release(); + return false; + } + + buffer->Release(); + return true; + } + + return false; +} + + +bool CD3D9HLSLMaterialRenderer::setVariable(bool vertexShader, const c8* name, + const f32* floats, int count) +{ + LPD3DXCONSTANTTABLE tbl = vertexShader ? VSConstantsTable : PSConstantsTable; + if (!tbl) + return false; + + // currently we only support top level parameters. + // Should be enough for the beginning. (TODO) + + D3DXHANDLE hndl = tbl->GetConstantByName(NULL, name); + if (!hndl) + { + core::stringc s = "HLSL Variable to set not found: '"; + s += name; + s += "'. Available variables are:"; + os::Printer::log(s.c_str(), ELL_WARNING); + printHLSLVariables(tbl); + return false; + } + + HRESULT hr = tbl->SetFloatArray(pID3DDevice, hndl, floats, count); + if (FAILED(hr)) + { + os::Printer::log("Error setting float array for HLSL variable", ELL_WARNING); + return false; + } + + return true; +} + +bool CD3D9HLSLMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) +{ + if (VSConstantsTable) + VSConstantsTable->SetDefaults(pID3DDevice); + + return CD3D9ShaderMaterialRenderer::OnRender(service, vtxtype); +} + +void CD3D9HLSLMaterialRenderer::printHLSLVariables(LPD3DXCONSTANTTABLE table) +{ + // currently we only support top level parameters. + // Should be enough for the beginning. (TODO) + + // print out constant names + D3DXCONSTANTTABLE_DESC tblDesc; + HRESULT hr = table->GetDesc(&tblDesc); + if (!FAILED(hr)) + { + for (int i=0; i<(int)tblDesc.Constants; ++i) + { + D3DXCONSTANT_DESC d; + UINT n = 1; + D3DXHANDLE cHndl = table->GetConstant(NULL, i); + if (!FAILED(table->GetConstantDesc(cHndl, &d, &n))) + { + core::stringc s = " '"; + s += d.Name; + s += "' Registers:[begin:"; + s += (int)d.RegisterIndex; + s += ", count:"; + s += (int)d.RegisterCount; + s += "]"; + os::Printer::log(s.c_str()); + } + } + } +} + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CD3D9HLSLMaterialRenderer.h b/src/dep/src/irrlicht/CD3D9HLSLMaterialRenderer.h index a65d030..de54752 100644 --- a/src/dep/src/irrlicht/CD3D9HLSLMaterialRenderer.h +++ b/src/dep/src/irrlicht/CD3D9HLSLMaterialRenderer.h @@ -1,79 +1,79 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D9_HLSL_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D9_HLSL_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - -#include "CD3D9ShaderMaterialRenderer.h" -#include "IGPUProgrammingServices.h" - -namespace irr -{ -namespace video -{ - -class IVideoDriver; -class IShaderConstantSetCallBack; -class IMaterialRenderer; - -//! Class for using vertex and pixel shaders via HLSL with D3D9 -class CD3D9HLSLMaterialRenderer : public CD3D9ShaderMaterialRenderer -{ -public: - - //! Public constructor - CD3D9HLSLMaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, - s32 userData); - - //! Destructor - ~CD3D9HLSLMaterialRenderer(); - - //! sets a variable in the shader. - //! \param vertexShader: True if this should be set in the vertex shader, false if - //! in the pixel shader. - //! \param name: Name of the variable - //! \param floats: Pointer to array of floats - //! \param count: Amount of floats in array. - virtual bool setVariable(bool vertexShader, const c8* name, const f32* floats, int count); - - bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - -protected: - - bool createHLSLVertexShader(const char* vertexShaderProgram, - const char* shaderEntryPointName, - const char* shaderTargetName); - - bool createHLSLPixelShader(const char* pixelShaderProgram, - const char* shaderEntryPointName, - const char* shaderTargetName); - - void printHLSLVariables(LPD3DXCONSTANTTABLE table); - - LPD3DXCONSTANTTABLE VSConstantsTable; - LPD3DXCONSTANTTABLE PSConstantsTable; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_D3D9_HLSL_MATERIAL_RENDERER_H_INCLUDED__ +#define __C_D3D9_HLSL_MATERIAL_RENDERER_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_WINDOWS_ + +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + +#include "CD3D9ShaderMaterialRenderer.h" +#include "IGPUProgrammingServices.h" + +namespace irr +{ +namespace video +{ + +class IVideoDriver; +class IShaderConstantSetCallBack; +class IMaterialRenderer; + +//! Class for using vertex and pixel shaders via HLSL with D3D9 +class CD3D9HLSLMaterialRenderer : public CD3D9ShaderMaterialRenderer +{ +public: + + //! Public constructor + CD3D9HLSLMaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, + s32& outMaterialTypeNr, + const c8* vertexShaderProgram, + const c8* vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8* pixelShaderProgram, + const c8* pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + IShaderConstantSetCallBack* callback, + IMaterialRenderer* baseMaterial, + s32 userData); + + //! Destructor + ~CD3D9HLSLMaterialRenderer(); + + //! sets a variable in the shader. + //! \param vertexShader: True if this should be set in the vertex shader, false if + //! in the pixel shader. + //! \param name: Name of the variable + //! \param floats: Pointer to array of floats + //! \param count: Amount of floats in array. + virtual bool setVariable(bool vertexShader, const c8* name, const f32* floats, int count); + + bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); + +protected: + + bool createHLSLVertexShader(const char* vertexShaderProgram, + const char* shaderEntryPointName, + const char* shaderTargetName); + + bool createHLSLPixelShader(const char* pixelShaderProgram, + const char* shaderEntryPointName, + const char* shaderTargetName); + + void printHLSLVariables(LPD3DXCONSTANTTABLE table); + + LPD3DXCONSTANTTABLE VSConstantsTable; + LPD3DXCONSTANTTABLE PSConstantsTable; +}; + + +} // end namespace video +} // end namespace irr + +#endif +#endif +#endif + diff --git a/src/dep/src/irrlicht/CD3D9MaterialRenderer.h b/src/dep/src/irrlicht/CD3D9MaterialRenderer.h index 3a90c45..f54cb03 100644 --- a/src/dep/src/irrlicht/CD3D9MaterialRenderer.h +++ b/src/dep/src/irrlicht/CD3D9MaterialRenderer.h @@ -1,613 +1,613 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D9_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D9_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ -#include "d3d9.h" - -#include "IMaterialRenderer.h" - -namespace irr -{ -namespace video -{ - -D3DMATRIX UnitMatrixD3D9; -D3DMATRIX SphereMapMatrixD3D9; - -//! Base class for all internal D3D9 material renderers -class CD3D9MaterialRenderer : public IMaterialRenderer -{ -public: - - //! Constructor - CD3D9MaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver) - : pID3DDevice(d3ddev), Driver(driver) - { - } - - ~CD3D9MaterialRenderer() - { - } - - //! sets a variable in the shader. - //! \param vertexShader: True if this should be set in the vertex shader, false if - //! in the pixel shader. - //! \param name: Name of the variable - //! \param floats: Pointer to array of floats - //! \param count: Amount of floats in array. - virtual bool setVariable(bool vertexShader, const c8* name, const f32* floats, int count) - { - os::Printer::log("Invalid material to set variable in."); - return false; - } - -protected: - - IDirect3DDevice9* pID3DDevice; - video::IVideoDriver* Driver; -}; - - -//! Solid material renderer -class CD3D9MaterialRenderer_SOLID : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_SOLID(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - } - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - -//! Generic Texture Blend -class CD3D9MaterialRenderer_ONETEXTURE_BLEND : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_ONETEXTURE_BLEND(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || - material.MaterialTypeParam != lastMaterial.MaterialTypeParam || - resetAllRenderstates) - { - - E_BLEND_FACTOR srcFact,dstFact; - E_MODULATE_FUNC modulate; - unpack_texureBlendFunc ( srcFact, dstFact, modulate, material.MaterialTypeParam ); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, getD3DBlend ( srcFact ) ); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, getD3DBlend ( dstFact ) ); - - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, getD3DModulate ( modulate ) ); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - - if ( getTexelAlpha ( srcFact ) + getTexelAlpha ( dstFact ) ) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - } - else - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - } - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - } - - private: - - u32 getD3DBlend ( E_BLEND_FACTOR factor ) const - { - u32 r = 0; - switch ( factor ) - { - case EBF_ZERO: r = D3DBLEND_ZERO; break; - case EBF_ONE: r = D3DBLEND_ONE; break; - case EBF_DST_COLOR: r = D3DBLEND_DESTCOLOR; break; - case EBF_ONE_MINUS_DST_COLOR: r = D3DBLEND_INVDESTCOLOR; break; - case EBF_SRC_COLOR: r = D3DBLEND_SRCCOLOR; break; - case EBF_ONE_MINUS_SRC_COLOR: r = D3DBLEND_INVSRCCOLOR; break; - case EBF_SRC_ALPHA: r = D3DBLEND_SRCALPHA; break; - case EBF_ONE_MINUS_SRC_ALPHA: r = D3DBLEND_INVSRCALPHA; break; - case EBF_DST_ALPHA: r = D3DBLEND_DESTALPHA; break; - case EBF_ONE_MINUS_DST_ALPHA: r = D3DBLEND_INVDESTALPHA; break; - case EBF_SRC_ALPHA_SATURATE: r = D3DBLEND_SRCALPHASAT; break; - } - return r; - } - - u32 getTexelAlpha ( E_BLEND_FACTOR factor ) const - { - u32 r = 0; - switch ( factor ) - { - case EBF_SRC_ALPHA: r = 1; break; - case EBF_ONE_MINUS_SRC_ALPHA: r = 1; break; - case EBF_DST_ALPHA: r = 1; break; - case EBF_ONE_MINUS_DST_ALPHA: r = 1; break; - case EBF_SRC_ALPHA_SATURATE: r = 1; break; - } - return r; - } - - u32 getD3DModulate ( E_MODULATE_FUNC func ) const - { - u32 r = D3DTOP_MODULATE; - switch ( func ) - { - case EMFN_MODULATE_1X: r = D3DTOP_MODULATE; break; - case EMFN_MODULATE_2X: r = D3DTOP_MODULATE2X; break; - case EMFN_MODULATE_4X: r = D3DTOP_MODULATE4X; break; - } - return r; - } - -}; - - - -//! Solid 2 layer material renderer -class CD3D9MaterialRenderer_SOLID_2_LAYER : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_SOLID_2_LAYER(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDDIFFUSEALPHA); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - - -//! Transparent add color material renderer -class CD3D9MaterialRenderer_TRANSPARENT_ADD_COLOR : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_TRANSPARENT_ADD_COLOR(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR); - } - - material.ZWriteEnable = false; - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - //! Returns if the material is transparent. The scene management needs to know this - //! for being able to sort the materials by opaque and transparent. - virtual bool isTransparent() - { - return true; - } -}; - - -//! Transparent vertex alpha material renderer -class CD3D9MaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); - } - - material.ZWriteEnable = false; - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - //! Returns if the material is transparent. The scene managment needs to know this - //! for being able to sort the materials by opaque and transparent. - virtual bool isTransparent() - { - return true; - } -}; - - -//! Transparent alpha channel material renderer -class CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates - || material.MaterialTypeParam != lastMaterial.MaterialTypeParam ) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - - pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - - s32 refValue = core::floor32(material.MaterialTypeParam * 255.f); - if ( !refValue ) - refValue = 127; // default value - - pID3DDevice->SetRenderState(D3DRS_ALPHAREF, refValue); - pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); - - } - - //material.ZWriteEnable = false; - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); - } - - //! Returns if the material is transparent. The scene managment needs to know this - //! for being able to sort the materials by opaque and transparent. - virtual bool isTransparent() - { - return true; - } -}; - - - -//! Transparent alpha channel material renderer -class CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - - pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - s32 refValue = core::floor32(material.MaterialTypeParam * 255); - if ( !refValue ) - refValue = 127; // default value - - pID3DDevice->SetRenderState(D3DRS_ALPHAREF,refValue); - pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); - } - - //! Returns if the material is transparent. The scene managment needs to know this - //! for being able to sort the materials by opaque and transparent. - virtual bool isTransparent() - { - return false; // this material is not really transparent because it does no blending. - } -}; - - -//! material renderer for all kinds of linghtmaps -class CD3D9MaterialRenderer_LIGHTMAP : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_LIGHTMAP(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (material.MaterialType >= EMT_LIGHTMAP_LIGHTING) - { - // with lighting - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - } - else - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - } - - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); - - if (material.MaterialType == EMT_LIGHTMAP_ADD) - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD); - else - if (material.MaterialType == EMT_LIGHTMAP_M4) - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE4X); - else - if (material.MaterialType == EMT_LIGHTMAP_M2) - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE2X); - else - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); - pID3DDevice->SetTextureStageState (1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - - - -//! material renderer for detail maps -class CD3D9MaterialRenderer_DETAIL_MAP : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_DETAIL_MAP(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState (1, D3DTSS_COLOROP, D3DTOP_ADDSIGNED); - pID3DDevice->SetTextureStageState (1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (1, D3DTSS_COLORARG2, D3DTA_CURRENT); - pID3DDevice->SetTextureStageState (1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - - -//! sphere map material renderer -class CD3D9MaterialRenderer_SPHERE_MAP : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_SPHERE_MAP(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - pID3DDevice->SetTransform( D3DTS_TEXTURE0, &SphereMapMatrixD3D9 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACENORMAL ); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0); - pID3DDevice->SetTransform( D3DTS_TEXTURE0, &UnitMatrixD3D9 ); - } -}; - - -//! reflection 2 layer material renderer -class CD3D9MaterialRenderer_REFLECTION_2_LAYER : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_REFLECTION_2_LAYER(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); - - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D9 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1); - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D9 ); - } -}; - - -//! reflection 2 layer material renderer -class CD3D9MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); - - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D9 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - - material.ZWriteEnable = false; - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1); - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D9 ); - } - - //! Returns if the material is transparent. The scene managment needs to know this - //! for being able to sort the materials by opaque and transparent. - virtual bool isTransparent() - { - return true; - } -}; - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_D3D9_MATERIAL_RENDERER_H_INCLUDED__ +#define __C_D3D9_MATERIAL_RENDERER_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_WINDOWS_ + +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ +#include "d3d9.h" + +#include "IMaterialRenderer.h" + +namespace irr +{ +namespace video +{ + +D3DMATRIX UnitMatrixD3D9; +D3DMATRIX SphereMapMatrixD3D9; + +//! Base class for all internal D3D9 material renderers +class CD3D9MaterialRenderer : public IMaterialRenderer +{ +public: + + //! Constructor + CD3D9MaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver) + : pID3DDevice(d3ddev), Driver(driver) + { + } + + ~CD3D9MaterialRenderer() + { + } + + //! sets a variable in the shader. + //! \param vertexShader: True if this should be set in the vertex shader, false if + //! in the pixel shader. + //! \param name: Name of the variable + //! \param floats: Pointer to array of floats + //! \param count: Amount of floats in array. + virtual bool setVariable(bool vertexShader, const c8* name, const f32* floats, int count) + { + os::Printer::log("Invalid material to set variable in."); + return false; + } + +protected: + + IDirect3DDevice9* pID3DDevice; + video::IVideoDriver* Driver; +}; + + +//! Solid material renderer +class CD3D9MaterialRenderer_SOLID : public CD3D9MaterialRenderer +{ +public: + + CD3D9MaterialRenderer_SOLID(IDirect3DDevice9* p, video::IVideoDriver* d) + : CD3D9MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + } + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } +}; + +//! Generic Texture Blend +class CD3D9MaterialRenderer_ONETEXTURE_BLEND : public CD3D9MaterialRenderer +{ +public: + + CD3D9MaterialRenderer_ONETEXTURE_BLEND(IDirect3DDevice9* p, video::IVideoDriver* d) + : CD3D9MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || + material.MaterialTypeParam != lastMaterial.MaterialTypeParam || + resetAllRenderstates) + { + + E_BLEND_FACTOR srcFact,dstFact; + E_MODULATE_FUNC modulate; + unpack_texureBlendFunc ( srcFact, dstFact, modulate, material.MaterialTypeParam ); + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, getD3DBlend ( srcFact ) ); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, getD3DBlend ( dstFact ) ); + + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, getD3DModulate ( modulate ) ); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + + if ( getTexelAlpha ( srcFact ) + getTexelAlpha ( dstFact ) ) + { + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + } + else + { + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); + } + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + } + + private: + + u32 getD3DBlend ( E_BLEND_FACTOR factor ) const + { + u32 r = 0; + switch ( factor ) + { + case EBF_ZERO: r = D3DBLEND_ZERO; break; + case EBF_ONE: r = D3DBLEND_ONE; break; + case EBF_DST_COLOR: r = D3DBLEND_DESTCOLOR; break; + case EBF_ONE_MINUS_DST_COLOR: r = D3DBLEND_INVDESTCOLOR; break; + case EBF_SRC_COLOR: r = D3DBLEND_SRCCOLOR; break; + case EBF_ONE_MINUS_SRC_COLOR: r = D3DBLEND_INVSRCCOLOR; break; + case EBF_SRC_ALPHA: r = D3DBLEND_SRCALPHA; break; + case EBF_ONE_MINUS_SRC_ALPHA: r = D3DBLEND_INVSRCALPHA; break; + case EBF_DST_ALPHA: r = D3DBLEND_DESTALPHA; break; + case EBF_ONE_MINUS_DST_ALPHA: r = D3DBLEND_INVDESTALPHA; break; + case EBF_SRC_ALPHA_SATURATE: r = D3DBLEND_SRCALPHASAT; break; + } + return r; + } + + u32 getTexelAlpha ( E_BLEND_FACTOR factor ) const + { + u32 r = 0; + switch ( factor ) + { + case EBF_SRC_ALPHA: r = 1; break; + case EBF_ONE_MINUS_SRC_ALPHA: r = 1; break; + case EBF_DST_ALPHA: r = 1; break; + case EBF_ONE_MINUS_DST_ALPHA: r = 1; break; + case EBF_SRC_ALPHA_SATURATE: r = 1; break; + } + return r; + } + + u32 getD3DModulate ( E_MODULATE_FUNC func ) const + { + u32 r = D3DTOP_MODULATE; + switch ( func ) + { + case EMFN_MODULATE_1X: r = D3DTOP_MODULATE; break; + case EMFN_MODULATE_2X: r = D3DTOP_MODULATE2X; break; + case EMFN_MODULATE_4X: r = D3DTOP_MODULATE4X; break; + } + return r; + } + +}; + + + +//! Solid 2 layer material renderer +class CD3D9MaterialRenderer_SOLID_2_LAYER : public CD3D9MaterialRenderer +{ +public: + + CD3D9MaterialRenderer_SOLID_2_LAYER(IDirect3DDevice9* p, video::IVideoDriver* d) + : CD3D9MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0); + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDDIFFUSEALPHA); + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } +}; + + +//! Transparent add color material renderer +class CD3D9MaterialRenderer_TRANSPARENT_ADD_COLOR : public CD3D9MaterialRenderer +{ +public: + + CD3D9MaterialRenderer_TRANSPARENT_ADD_COLOR(IDirect3DDevice9* p, video::IVideoDriver* d) + : CD3D9MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR); + } + + material.ZWriteEnable = false; + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + //! Returns if the material is transparent. The scene management needs to know this + //! for being able to sort the materials by opaque and transparent. + virtual bool isTransparent() + { + return true; + } +}; + + +//! Transparent vertex alpha material renderer +class CD3D9MaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public CD3D9MaterialRenderer +{ +public: + + CD3D9MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(IDirect3DDevice9* p, video::IVideoDriver* d) + : CD3D9MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + } + + material.ZWriteEnable = false; + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + //! Returns if the material is transparent. The scene managment needs to know this + //! for being able to sort the materials by opaque and transparent. + virtual bool isTransparent() + { + return true; + } +}; + + +//! Transparent alpha channel material renderer +class CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL : public CD3D9MaterialRenderer +{ +public: + + CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(IDirect3DDevice9* p, video::IVideoDriver* d) + : CD3D9MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates + || material.MaterialTypeParam != lastMaterial.MaterialTypeParam ) + { + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + + pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); + + s32 refValue = core::floor32(material.MaterialTypeParam * 255.f); + if ( !refValue ) + refValue = 127; // default value + + pID3DDevice->SetRenderState(D3DRS_ALPHAREF, refValue); + pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); + pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); + + } + + //material.ZWriteEnable = false; + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + virtual void OnUnsetMaterial() + { + pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); + } + + //! Returns if the material is transparent. The scene managment needs to know this + //! for being able to sort the materials by opaque and transparent. + virtual bool isTransparent() + { + return true; + } +}; + + + +//! Transparent alpha channel material renderer +class CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF : public CD3D9MaterialRenderer +{ +public: + + CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(IDirect3DDevice9* p, video::IVideoDriver* d) + : CD3D9MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + + pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + + s32 refValue = core::floor32(material.MaterialTypeParam * 255); + if ( !refValue ) + refValue = 127; // default value + + pID3DDevice->SetRenderState(D3DRS_ALPHAREF,refValue); + pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); + pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + virtual void OnUnsetMaterial() + { + pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); + } + + //! Returns if the material is transparent. The scene managment needs to know this + //! for being able to sort the materials by opaque and transparent. + virtual bool isTransparent() + { + return false; // this material is not really transparent because it does no blending. + } +}; + + +//! material renderer for all kinds of linghtmaps +class CD3D9MaterialRenderer_LIGHTMAP : public CD3D9MaterialRenderer +{ +public: + + CD3D9MaterialRenderer_LIGHTMAP(IDirect3DDevice9* p, video::IVideoDriver* d) + : CD3D9MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + if (material.MaterialType >= EMT_LIGHTMAP_LIGHTING) + { + // with lighting + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + } + else + { + pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); + pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + } + + pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); + + if (material.MaterialType == EMT_LIGHTMAP_ADD) + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD); + else + if (material.MaterialType == EMT_LIGHTMAP_M4) + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE4X); + else + if (material.MaterialType == EMT_LIGHTMAP_M2) + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE2X); + else + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); + pID3DDevice->SetTextureStageState (1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } +}; + + + +//! material renderer for detail maps +class CD3D9MaterialRenderer_DETAIL_MAP : public CD3D9MaterialRenderer +{ +public: + + CD3D9MaterialRenderer_DETAIL_MAP(IDirect3DDevice9* p, video::IVideoDriver* d) + : CD3D9MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetTextureStageState (1, D3DTSS_COLOROP, D3DTOP_ADDSIGNED); + pID3DDevice->SetTextureStageState (1, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (1, D3DTSS_COLORARG2, D3DTA_CURRENT); + pID3DDevice->SetTextureStageState (1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } +}; + + +//! sphere map material renderer +class CD3D9MaterialRenderer_SPHERE_MAP : public CD3D9MaterialRenderer +{ +public: + + CD3D9MaterialRenderer_SPHERE_MAP(IDirect3DDevice9* p, video::IVideoDriver* d) + : CD3D9MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + + pID3DDevice->SetTransform( D3DTS_TEXTURE0, &SphereMapMatrixD3D9 ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACENORMAL ); + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + virtual void OnUnsetMaterial() + { + pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0); + pID3DDevice->SetTransform( D3DTS_TEXTURE0, &UnitMatrixD3D9 ); + } +}; + + +//! reflection 2 layer material renderer +class CD3D9MaterialRenderer_REFLECTION_2_LAYER : public CD3D9MaterialRenderer +{ +public: + + CD3D9MaterialRenderer_REFLECTION_2_LAYER(IDirect3DDevice9* p, video::IVideoDriver* d) + : CD3D9MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); + + pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D9 ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + virtual void OnUnsetMaterial() + { + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1); + pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D9 ); + } +}; + + +//! reflection 2 layer material renderer +class CD3D9MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER : public CD3D9MaterialRenderer +{ +public: + + CD3D9MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(IDirect3DDevice9* p, video::IVideoDriver* d) + : CD3D9MaterialRenderer(p, d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); + pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); + pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); + + pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D9 ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + + pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); + } + + material.ZWriteEnable = false; + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + virtual void OnUnsetMaterial() + { + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); + pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1); + pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D9 ); + } + + //! Returns if the material is transparent. The scene managment needs to know this + //! for being able to sort the materials by opaque and transparent. + virtual bool isTransparent() + { + return true; + } +}; + +} // end namespace video +} // end namespace irr + +#endif +#endif +#endif + diff --git a/src/dep/src/irrlicht/CD3D9NormalMapRenderer.cpp b/src/dep/src/irrlicht/CD3D9NormalMapRenderer.cpp index 57db416..56a609e 100644 --- a/src/dep/src/irrlicht/CD3D9NormalMapRenderer.cpp +++ b/src/dep/src/irrlicht/CD3D9NormalMapRenderer.cpp @@ -1,235 +1,235 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - -#include "CD3D9NormalMapRenderer.h" -#include "IVideoDriver.h" -#include "IMaterialRendererServices.h" -#include "os.h" -#include "SLight.h" - -namespace irr -{ -namespace video -{ - - // 1.1 Shaders with two lights and vertex based attenuation - - // Irrlicht Engine D3D9 render path normal map vertex shader - const char D3D9_NORMAL_MAP_VSH[] = - ";Irrlicht Engine 0.8 D3D9 render path normal map vertex shader\n"\ - "; c0-3: Transposed world matrix \n"\ - "; c8-11: Transposed worldViewProj matrix (Projection * View * World) \n"\ - "; c12: Light01 position \n"\ - "; c13: x,y,z: Light01 color; .w: 1/LightRadius² \n"\ - "; c14: Light02 position \n"\ - "; c15: x,y,z: Light02 color; .w: 1/LightRadius² \n"\ - "vs.1.1\n"\ - "dcl_position v0 ; position \n"\ - "dcl_normal v1 ; normal \n"\ - "dcl_color v2 ; color \n"\ - "dcl_texcoord0 v3 ; texture coord \n"\ - "dcl_texcoord1 v4 ; tangent \n"\ - "dcl_texcoord2 v5 ; binormal \n"\ - "\n"\ - "def c95, 0.5, 0.5, 0.5, 0.5 ; used for moving light vector to ps \n"\ - "\n"\ - "m4x4 oPos, v0, c8 ; transform position to clip space with worldViewProj matrix\n"\ - "\n"\ - "m3x3 r5, v4, c0 ; transform tangent U\n"\ - "m3x3 r7, v1, c0 ; transform normal W\n"\ - "m3x3 r6, v5, c0 ; transform binormal V\n"\ - "\n"\ - "m4x4 r4, v0, c0 ; vertex into world position\n"\ - "add r2, c12, -r4 ; vtxpos - lightpos1\n"\ - "add r3, c14, -r4 ; vtxpos - lightpos2\n"\ - "\n"\ - "dp3 r8.x, r5, r2 ; transform the light vector 1 with U, V, W\n"\ - "dp3 r8.y, r6, r2 \n"\ - "dp3 r8.z, r7, r2 \n"\ - "dp3 r9.x, r5, r3 ; transform the light vector 2 with U, V, W\n"\ - "dp3 r9.y, r6, r3 \n"\ - "dp3 r9.z, r7, r3 \n"\ - "\n"\ - "dp3 r8.w, r8, r8 ; normalize light vector 1 (r8)\n"\ - "rsq r8.w, r8.w \n"\ - "mul r8, r8, r8.w \n"\ - "dp3 r9.w, r9, r9 ; normalize light vector 2 (r9)\n"\ - "rsq r9.w, r9.w \n"\ - "mul r9, r9, r9.w \n"\ - "\n"\ - "mad oT2.xyz, r8.xyz, c95, c95 ; move light vector 1 from -1..1 into 0..1 \n"\ - "mad oT3.xyz, r9.xyz, c95, c95 ; move light vector 2 from -1..1 into 0..1 \n"\ - "\n"\ - " ; calculate attenuation of light 1 \n"\ - "dp3 r2.x, r2.xyz, r2.xyz ; r2.x = r2.x² + r2.y² + r2.z² \n"\ - "mul r2.x, r2.x, c13.w ; r2.x * attenutation \n"\ - "rsq r2, r2.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD0, r2, c13 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - " ; calculate attenuation of light 2 \n"\ - "dp3 r3.x, r3.xyz, r3.xyz ; r3.x = r3.x² + r3.y² + r3.z² \n"\ - "mul r3.x, r3.x, c15.w ; r2.x * attenutation \n"\ - "rsq r3, r3.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD1, r3, c15 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "mov oT0.xy, v3.xy ; move out texture coordinates 1\n"\ - "mov oT1.xy, v3.xy ; move out texture coordinates 2\n"\ - "mov oD0.a, v2.a ; move out original alpha value \n"\ - "\n"; - - // Irrlicht Engine D3D9 render path normal map pixel shader - const char D3D9_NORMAL_MAP_PSH[] = - ";Irrlicht Engine 0.8 D3D9 render path normal map pixel shader\n"\ - ";Input: \n"\ - ";t0: color map texture coord \n"\ - ";t1: normal map texture coords \n"\ - ";t2: light 1 vector in tangent space \n"\ - ";v0: light 1 color \n"\ - ";t3: light 2 vector in tangent space \n"\ - ";v1: light 2 color \n"\ - ";v0.a: vertex alpha value \n"\ - "ps.1.1 \n"\ - "tex t0 ; sample color map \n"\ - "tex t1 ; sample normal map\n"\ - "texcoord t2 ; fetch light vector 1\n"\ - "texcoord t3 ; fetch light vector 2\n"\ - "\n"\ - "dp3_sat r0, t1_bx2, t2_bx2 ; normal dot light 1 (_bx2 because moved into 0..1)\n"\ - "mul r0, r0, v0 ; luminance1 * light color 1 \n"\ - "\n"\ - "dp3_sat r1, t1_bx2, t3_bx2 ; normal dot light 2 (_bx2 because moved into 0..1)\n"\ - "mad r0, r1, v1, r0 ; (luminance2 * light color 2) + luminance 1 \n"\ - "\n"\ - "mul r0.xyz, t0, r0 ; total luminance * base color\n"\ - "+mov r0.a, v0.a ; write interpolated vertex alpha value \n"\ - "\n"\ - ""; - - CD3D9NormalMapRenderer::CD3D9NormalMapRenderer( - IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) - : CD3D9ShaderMaterialRenderer(d3ddev, driver, 0, baseMaterial) - { - // set this as callback. We could have done this in - // the initialization list, but some compilers don't like it. - - CallBack = this; - - // basicly, this thing simply compiles these hardcoded shaders if the - // hardware is able to do them, otherwise it maps to the base material - - if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) || - !driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - { - // this hardware is not able to do shaders. Fall back to - // base material. - outMaterialTypeNr = driver->addMaterialRenderer(this); - return; - } - - // check if already compiled normal map shaders are there. - - video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_NORMAL_MAP_SOLID); - if (renderer) - { - // use the already compiled shaders - video::CD3D9NormalMapRenderer* nmr = (video::CD3D9NormalMapRenderer*)renderer; - VertexShader = nmr->VertexShader; - if (VertexShader) - VertexShader->AddRef(); - - PixelShader = nmr->PixelShader; - if (PixelShader) - PixelShader->AddRef(); - - outMaterialTypeNr = driver->addMaterialRenderer(this); - } - else - { - // compile shaders on our own - init(outMaterialTypeNr, D3D9_NORMAL_MAP_VSH, D3D9_NORMAL_MAP_PSH); - } - } - - CD3D9NormalMapRenderer::~CD3D9NormalMapRenderer() - { - if (CallBack == this) - CallBack = 0; - } - - bool CD3D9NormalMapRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) - { - if (vtxtype != video::EVT_TANGENTS) - { - os::Printer::log("Error: Normal map renderer only supports vertices of type EVT_TANGENTS", ELL_ERROR); - return false; - } - - return CD3D9ShaderMaterialRenderer::OnRender(service, vtxtype); - } - - - //! Returns the render capability of the material. - s32 CD3D9NormalMapRenderer::getRenderCapability() - { - if (Driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) && - Driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - return 0; - - return 1; - } - - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - void CD3D9NormalMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) - { - video::IVideoDriver* driver = services->getVideoDriver(); - - // set transposed world matrix - services->setVertexShaderConstant(driver->getTransform(video::ETS_WORLD).getTransposed().pointer(), 0, 4); - - // set transposed worldViewProj matrix - core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - services->setVertexShaderConstant(worldViewProj.getTransposed().pointer(), 8, 4); - - // here we've got to fetch the fixed function lights from the driver - // and set them as constants - - u32 cnt = driver->getDynamicLightCount(); - - for (u32 i=0; i<2; ++i) - { - SLight light; - - if (igetDynamicLight(i); - else - { - light.DiffuseColor.set(0,0,0); // make light dark - light.Radius = 1.0f; - } - - light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation - - services->setVertexShaderConstant(reinterpret_cast(&light.Position), 12+(i*2), 1); - services->setVertexShaderConstant(reinterpret_cast(&light.DiffuseColor), 13+(i*2), 1); - } - - // this is not really necessary in d3d9 (used a def instruction), but to be sure: - f32 c95[] = {0.5f, 0.5f, 0.5f, 0.5f}; - services->setVertexShaderConstant(c95, 95, 1); - } - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + +#include "CD3D9NormalMapRenderer.h" +#include "IVideoDriver.h" +#include "IMaterialRendererServices.h" +#include "os.h" +#include "SLight.h" + +namespace irr +{ +namespace video +{ + + // 1.1 Shaders with two lights and vertex based attenuation + + // Irrlicht Engine D3D9 render path normal map vertex shader + const char D3D9_NORMAL_MAP_VSH[] = + ";Irrlicht Engine 0.8 D3D9 render path normal map vertex shader\n"\ + "; c0-3: Transposed world matrix \n"\ + "; c8-11: Transposed worldViewProj matrix (Projection * View * World) \n"\ + "; c12: Light01 position \n"\ + "; c13: x,y,z: Light01 color; .w: 1/LightRadius² \n"\ + "; c14: Light02 position \n"\ + "; c15: x,y,z: Light02 color; .w: 1/LightRadius² \n"\ + "vs.1.1\n"\ + "dcl_position v0 ; position \n"\ + "dcl_normal v1 ; normal \n"\ + "dcl_color v2 ; color \n"\ + "dcl_texcoord0 v3 ; texture coord \n"\ + "dcl_texcoord1 v4 ; tangent \n"\ + "dcl_texcoord2 v5 ; binormal \n"\ + "\n"\ + "def c95, 0.5, 0.5, 0.5, 0.5 ; used for moving light vector to ps \n"\ + "\n"\ + "m4x4 oPos, v0, c8 ; transform position to clip space with worldViewProj matrix\n"\ + "\n"\ + "m3x3 r5, v4, c0 ; transform tangent U\n"\ + "m3x3 r7, v1, c0 ; transform normal W\n"\ + "m3x3 r6, v5, c0 ; transform binormal V\n"\ + "\n"\ + "m4x4 r4, v0, c0 ; vertex into world position\n"\ + "add r2, c12, -r4 ; vtxpos - lightpos1\n"\ + "add r3, c14, -r4 ; vtxpos - lightpos2\n"\ + "\n"\ + "dp3 r8.x, r5, r2 ; transform the light vector 1 with U, V, W\n"\ + "dp3 r8.y, r6, r2 \n"\ + "dp3 r8.z, r7, r2 \n"\ + "dp3 r9.x, r5, r3 ; transform the light vector 2 with U, V, W\n"\ + "dp3 r9.y, r6, r3 \n"\ + "dp3 r9.z, r7, r3 \n"\ + "\n"\ + "dp3 r8.w, r8, r8 ; normalize light vector 1 (r8)\n"\ + "rsq r8.w, r8.w \n"\ + "mul r8, r8, r8.w \n"\ + "dp3 r9.w, r9, r9 ; normalize light vector 2 (r9)\n"\ + "rsq r9.w, r9.w \n"\ + "mul r9, r9, r9.w \n"\ + "\n"\ + "mad oT2.xyz, r8.xyz, c95, c95 ; move light vector 1 from -1..1 into 0..1 \n"\ + "mad oT3.xyz, r9.xyz, c95, c95 ; move light vector 2 from -1..1 into 0..1 \n"\ + "\n"\ + " ; calculate attenuation of light 1 \n"\ + "dp3 r2.x, r2.xyz, r2.xyz ; r2.x = r2.x² + r2.y² + r2.z² \n"\ + "mul r2.x, r2.x, c13.w ; r2.x * attenutation \n"\ + "rsq r2, r2.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ + "mul oD0, r2, c13 ; resulting light color = lightcolor * attenuation \n"\ + "\n"\ + " ; calculate attenuation of light 2 \n"\ + "dp3 r3.x, r3.xyz, r3.xyz ; r3.x = r3.x² + r3.y² + r3.z² \n"\ + "mul r3.x, r3.x, c15.w ; r2.x * attenutation \n"\ + "rsq r3, r3.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ + "mul oD1, r3, c15 ; resulting light color = lightcolor * attenuation \n"\ + "\n"\ + "mov oT0.xy, v3.xy ; move out texture coordinates 1\n"\ + "mov oT1.xy, v3.xy ; move out texture coordinates 2\n"\ + "mov oD0.a, v2.a ; move out original alpha value \n"\ + "\n"; + + // Irrlicht Engine D3D9 render path normal map pixel shader + const char D3D9_NORMAL_MAP_PSH[] = + ";Irrlicht Engine 0.8 D3D9 render path normal map pixel shader\n"\ + ";Input: \n"\ + ";t0: color map texture coord \n"\ + ";t1: normal map texture coords \n"\ + ";t2: light 1 vector in tangent space \n"\ + ";v0: light 1 color \n"\ + ";t3: light 2 vector in tangent space \n"\ + ";v1: light 2 color \n"\ + ";v0.a: vertex alpha value \n"\ + "ps.1.1 \n"\ + "tex t0 ; sample color map \n"\ + "tex t1 ; sample normal map\n"\ + "texcoord t2 ; fetch light vector 1\n"\ + "texcoord t3 ; fetch light vector 2\n"\ + "\n"\ + "dp3_sat r0, t1_bx2, t2_bx2 ; normal dot light 1 (_bx2 because moved into 0..1)\n"\ + "mul r0, r0, v0 ; luminance1 * light color 1 \n"\ + "\n"\ + "dp3_sat r1, t1_bx2, t3_bx2 ; normal dot light 2 (_bx2 because moved into 0..1)\n"\ + "mad r0, r1, v1, r0 ; (luminance2 * light color 2) + luminance 1 \n"\ + "\n"\ + "mul r0.xyz, t0, r0 ; total luminance * base color\n"\ + "+mov r0.a, v0.a ; write interpolated vertex alpha value \n"\ + "\n"\ + ""; + + CD3D9NormalMapRenderer::CD3D9NormalMapRenderer( + IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, + s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) + : CD3D9ShaderMaterialRenderer(d3ddev, driver, 0, baseMaterial) + { + // set this as callback. We could have done this in + // the initialization list, but some compilers don't like it. + + CallBack = this; + + // basicly, this thing simply compiles these hardcoded shaders if the + // hardware is able to do them, otherwise it maps to the base material + + if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) || + !driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) + { + // this hardware is not able to do shaders. Fall back to + // base material. + outMaterialTypeNr = driver->addMaterialRenderer(this); + return; + } + + // check if already compiled normal map shaders are there. + + video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_NORMAL_MAP_SOLID); + if (renderer) + { + // use the already compiled shaders + video::CD3D9NormalMapRenderer* nmr = (video::CD3D9NormalMapRenderer*)renderer; + VertexShader = nmr->VertexShader; + if (VertexShader) + VertexShader->AddRef(); + + PixelShader = nmr->PixelShader; + if (PixelShader) + PixelShader->AddRef(); + + outMaterialTypeNr = driver->addMaterialRenderer(this); + } + else + { + // compile shaders on our own + init(outMaterialTypeNr, D3D9_NORMAL_MAP_VSH, D3D9_NORMAL_MAP_PSH); + } + } + + CD3D9NormalMapRenderer::~CD3D9NormalMapRenderer() + { + if (CallBack == this) + CallBack = 0; + } + + bool CD3D9NormalMapRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) + { + if (vtxtype != video::EVT_TANGENTS) + { + os::Printer::log("Error: Normal map renderer only supports vertices of type EVT_TANGENTS", ELL_ERROR); + return false; + } + + return CD3D9ShaderMaterialRenderer::OnRender(service, vtxtype); + } + + + //! Returns the render capability of the material. + s32 CD3D9NormalMapRenderer::getRenderCapability() + { + if (Driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) && + Driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) + return 0; + + return 1; + } + + + //! Called by the engine when the vertex and/or pixel shader constants for an + //! material renderer should be set. + void CD3D9NormalMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) + { + video::IVideoDriver* driver = services->getVideoDriver(); + + // set transposed world matrix + services->setVertexShaderConstant(driver->getTransform(video::ETS_WORLD).getTransposed().pointer(), 0, 4); + + // set transposed worldViewProj matrix + core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); + worldViewProj *= driver->getTransform(video::ETS_VIEW); + worldViewProj *= driver->getTransform(video::ETS_WORLD); + services->setVertexShaderConstant(worldViewProj.getTransposed().pointer(), 8, 4); + + // here we've got to fetch the fixed function lights from the driver + // and set them as constants + + u32 cnt = driver->getDynamicLightCount(); + + for (u32 i=0; i<2; ++i) + { + SLight light; + + if (igetDynamicLight(i); + else + { + light.DiffuseColor.set(0,0,0); // make light dark + light.Radius = 1.0f; + } + + light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation + + services->setVertexShaderConstant(reinterpret_cast(&light.Position), 12+(i*2), 1); + services->setVertexShaderConstant(reinterpret_cast(&light.DiffuseColor), 13+(i*2), 1); + } + + // this is not really necessary in d3d9 (used a def instruction), but to be sure: + f32 c95[] = {0.5f, 0.5f, 0.5f, 0.5f}; + services->setVertexShaderConstant(c95, 95, 1); + } + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CD3D9NormalMapRenderer.h b/src/dep/src/irrlicht/CD3D9NormalMapRenderer.h index 5827aff..3a67208 100644 --- a/src/dep/src/irrlicht/CD3D9NormalMapRenderer.h +++ b/src/dep/src/irrlicht/CD3D9NormalMapRenderer.h @@ -1,53 +1,53 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D9_NORMAL_MAPMATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D9_NORMAL_MAPMATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ -#include "d3d9.h" - -#include "CD3D9ShaderMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" - -namespace irr -{ -namespace video -{ - -//! Renderer for normal maps -class CD3D9NormalMapRenderer : - public CD3D9ShaderMaterialRenderer, IShaderConstantSetCallBack -{ -public: - - CD3D9NormalMapRenderer( - IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); - - ~CD3D9NormalMapRenderer(); - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); - - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - //! Returns the render capability of the material. - virtual s32 getRenderCapability(); - -private: - -}; - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_D3D9_NORMAL_MAPMATERIAL_RENDERER_H_INCLUDED__ +#define __C_D3D9_NORMAL_MAPMATERIAL_RENDERER_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_WINDOWS_ + +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ +#include "d3d9.h" + +#include "CD3D9ShaderMaterialRenderer.h" +#include "IShaderConstantSetCallBack.h" + +namespace irr +{ +namespace video +{ + +//! Renderer for normal maps +class CD3D9NormalMapRenderer : + public CD3D9ShaderMaterialRenderer, IShaderConstantSetCallBack +{ +public: + + CD3D9NormalMapRenderer( + IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, + s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); + + ~CD3D9NormalMapRenderer(); + + //! Called by the engine when the vertex and/or pixel shader constants for an + //! material renderer should be set. + virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); + + virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); + + //! Returns the render capability of the material. + virtual s32 getRenderCapability(); + +private: + +}; + +} // end namespace video +} // end namespace irr + +#endif +#endif +#endif + diff --git a/src/dep/src/irrlicht/CD3D9ParallaxMapRenderer.cpp b/src/dep/src/irrlicht/CD3D9ParallaxMapRenderer.cpp index 8c5044d..625a0f4 100644 --- a/src/dep/src/irrlicht/CD3D9ParallaxMapRenderer.cpp +++ b/src/dep/src/irrlicht/CD3D9ParallaxMapRenderer.cpp @@ -1,399 +1,399 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - -#include "CD3D9ParallaxMapRenderer.h" -#include "IMaterialRendererServices.h" -#include "IVideoDriver.h" -#include "os.h" -#include "SLight.h" - -//#define SHADER_EXTERNAL_DEBUG - -#ifdef SHADER_EXTERNAL_DEBUG -#include "CReadFile.h" -#endif - -namespace irr -{ -namespace video -{ - // 1.1/1.4 Shaders with two lights and vertex based attenuation - - // Irrlicht Engine D3D9 render path normal map vertex shader - const char D3D9_PARALLAX_MAP_VSH[] = - ";Irrlicht Engine 0.10 D3D9 render path parallax mapping vertex shader\n"\ - "; c0-3: Transposed world matrix \n"\ - "; c4: Eye position \n"\ - "; c8-11: Transposed worldViewProj matrix (Projection * View * World) \n"\ - "; c12: Light01 position \n"\ - "; c13: x,y,z: Light01 color; .w: 1/LightRadius² \n"\ - "; c14: Light02 position \n"\ - "; c15: x,y,z: Light02 color; .w: 1/LightRadius² \n"\ - "vs.1.1\n"\ - "dcl_position v0 ; position \n"\ - "dcl_normal v1 ; normal \n"\ - "dcl_color v2 ; color \n"\ - "dcl_texcoord0 v3 ; texture coord \n"\ - "dcl_texcoord1 v4 ; tangent \n"\ - "dcl_texcoord2 v5 ; binormal \n"\ - "\n"\ - "def c95, 0.5, 0.5, 0.5, 0.5 ; used for moving light vector to ps \n"\ - "def c96, -1, 1, 1, 1 ; somewhere I've got a bug. flipping the vectors with this fixes it. \n"\ - "\n"\ - "m4x4 oPos, v0, c8 ; transform position to clip space with worldViewProj matrix\n"\ - "\n"\ - "m3x3 r5, v4, c0 ; transform tangent U\n"\ - "m3x3 r7, v1, c0 ; transform normal W\n"\ - "m3x3 r6, v5, c0 ; transform binormal V\n"\ - "\n"\ - "m4x4 r4, v0, c0 ; vertex into world position\n"\ - "add r2, c12, -r4 ; vtxpos - light1 pos\n"\ - "add r3, c14, -r4 ; vtxpos - light2 pos\n"\ - "add r1, -c4, r4 ; eye - vtxpos \n"\ - "\n"\ - "dp3 r8.x, r5, r2 ; transform the light1 vector with U, V, W\n"\ - "dp3 r8.y, r6, r2 \n"\ - "dp3 r8.z, r7, r2 \n"\ - "dp3 r9.x, r5, r3 ; transform the light2 vector with U, V, W\n"\ - "dp3 r9.y, r6, r3 \n"\ - "dp3 r9.z, r7, r3 \n"\ - "dp3 r10.x, r5, r1 ; transform the eye vector with U, V, W\n"\ - "dp3 r10.y, r6, r1 \n"\ - "dp3 r10.z, r7, r1 \n"\ - "\n"\ - "dp3 r8.w, r8, r8 ; normalize light vector 1 (r8)\n"\ - "rsq r8.w, r8.w \n"\ - "mul r8, r8, r8.w \n"\ - ";mul r8, r8, c96 \n"\ - "dp3 r9.w, r9, r9 ; normalize light vector 2 (r9)\n"\ - "rsq r9.w, r9.w \n"\ - "mul r9, r9, r9.w \n"\ - ";mul r9, r9, c96 \n"\ - "dp3 r10.w, r10, r10 ; normalize eye vector (r10)\n"\ - "rsq r10.w, r10.w \n"\ - "mul r10, r10, r10.w \n"\ - "mul r10, r10, c96 \n"\ - "\n"\ - "\n"\ - "mad oT2.xyz, r8.xyz, c95, c95 ; move light vector 1 from -1..1 into 0..1 \n"\ - "mad oT3.xyz, r9.xyz, c95, c95 ; move light vector 2 from -1..1 into 0..1 \n"\ - "mad oT4.xyz, r10.xyz, c95, c95 ; move eye vector from -1..1 into 0..1 \n"\ - "\n"\ - " ; calculate attenuation of light 1 \n"\ - "dp3 r2.x, r2.xyz, r2.xyz ; r2.x = r2.x² + r2.y² + r2.z² \n"\ - "mul r2.x, r2.x, c13.w ; r2.x * attenutation \n"\ - "rsq r2, r2.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD0, r2, c13 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - " ; calculate attenuation of light 2 \n"\ - "dp3 r3.x, r3.xyz, r3.xyz ; r3.x = r3.x² + r3.y² + r3.z² \n"\ - "mul r3.x, r3.x, c15.w ; r2.x * attenutation \n"\ - "rsq r3, r3.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD1, r3, c15 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "mov oT0.xy, v3.xy ; move out texture coordinates 1\n"\ - "mov oT1.xy, v3.xy ; move out texture coordinates 2\n"\ - "mov oD0.a, v2.a ; move out original alpha value \n"\ - "\n"; - - - // Irrlicht Engine D3D9 render path normal map pixel shader version 1.4 - const char D3D9_PARALLAX_MAP_PSH[] = - ";Irrlicht Engine 0.10 D3D9 render path parallax mapping pixel shader \n"\ - ";Input: \n"\ - ";t0: color map texture coord \n"\ - ";t1: normal map texture coords \n"\ - ";t2: light 1 vector in tangent space \n"\ - ";t4: eye vector in tangent space \n"\ - ";v0: light 1 color \n"\ - ";t3: light 2 vector in tangent space \n"\ - ";v1: light 2 color \n"\ - ";v0.a: vertex alpha value \n"\ - " \n"\ - "ps.1.4 \n"\ - " \n"\ - ";def c6, 0.02f, 0.02f, 0.02f, 0.0f ; scale factor, now set in callback \n"\ - "def c5, 0.5f, 0.5f, 0.5f, 0.0f ; for specular division \n"\ - " \n"\ - "texld r1, t1 ; sample (normal.x, normal.y, normal.z, height) \n"\ - "texcrd r4.xyz, t4 ; fetch eye vector \n"\ - "texcrd r0.xyz, t0 ; color map \n"\ - " \n"\ - "; original parallax mapping: \n"\ - ";mul r3, r1_bx2.wwww, c6; ; r3 = (height, height, height) * scale \n"\ - ";mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ - " \n"\ - "; modified parallax mapping to reduce swimming effect: \n"\ - "mul r3, r1_bx2.wwww, r1_bx2.zzzz ; (nh,nh,nh,nh) = (h,h,h,h) * (n.z,n.z,n.z,n.z,) \n"\ - "mul r3, r3, c6; ; r3 = (nh, nh, nh) * scale \n"\ - "mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ - " \n"\ - "phase \n"\ - " \n"\ - "texld r0, r2 ; load diffuse texture with new tex coord \n"\ - "texld r1, r2 ; sample normal map \n"\ - "texcrd r2.xyz, t2 ; fetch light vector 1 \n"\ - "texcrd r3.xyz, t3 ; fetch light vector 2 \n"\ - " \n"\ - "dp3_sat r5, r1_bx2, r2_bx2 ; normal dot light 1 (_bx2 because moved into 0..1) \n"\ - "mul r5, r5, v0 ; luminance1 * light color 1 \n"\ - " \n"\ - "dp3_sat r3, r1_bx2, r3_bx2 ; normal dot light 2 (_bx2 because moved into 0..1) \n"\ - "mad r3, r3, v1, r5 ; (luminance2 * light color 2) + luminance1 \n"\ - " \n"\ - "mul r0.xyz, r0, r3 ; total luminance * base color \n"\ - "+mov r0.a, v0.a ; write original alpha value \n"\ - "\n"; - - // Irrlicht Engine D3D9 render path normal map pixel shader version 2.0 - const char D3D9_PARALLAX_MAP_PSH_20[] = - ";Irrlicht Engine 0.10 D3D9 render path parallax mapping pixel shader \n"\ - ";Input: \n"\ - " \n"\ - ";t0: color map texture coord \n"\ - ";t1: normal map texture coords \n"\ - ";t2: light 1 vector in tangent space \n"\ - ";t4: eye vector in tangent space \n"\ - ";v0: light 1 color \n"\ - ";t3: light 2 vector in tangent space \n"\ - ";v1: light 2 color \n"\ - ";v0.a: vertex alpha value \n"\ - " \n"\ - "ps.2.0 \n"\ - " \n"\ - "dcl_2d s0 ; Declare the s0 register to be the sampler for stage 0 \n"\ - "dcl t0.xy ; Declare t0 to have 2D texture coordinates from stage 0 \n"\ - "dcl t1.xy ; Declare t0 to have 2D texture coordinates from stage 0 \n"\ - "dcl_2d s1 ; Declare the s1 register to be the sampler for stage 1 \n"\ - " \n"\ - "dcl t2.xyz ; \n"\ - "dcl t3.xyz ; \n"\ - "dcl t4.xyz ; \n"\ - "dcl v0.xyzw; \n"\ - "dcl v1.xyzw; \n"\ - " \n"\ - "def c0, -1.0f, -1.0f, -1.0f, -1.0f ; for _bx2 emulation \n"\ - "def c1, 2.0f, 2.0f, 2.0f, 2.0f ; for _bx2 emulation \n"\ - "mov r11, c1; \n"\ - " \n"\ - "texld r1, t1, s1 ; sample (normal.x, normal.y, normal.z, height) \n"\ - "mov r4.xyz, t4 ; fetch eye vector \n"\ - "mov r0.xy, t0 ; color map \n"\ - " \n"\ - "; original parallax mapping: \n"\ - "; emulate ps1x _bx2, so substract 0.5f and multiply by 2 \n"\ - "mad r1.xyz, r1, r11, c0; \n"\ - " \n"\ - "mul r3, r1.wwww, c6; ; r3 = (height, height, height) * scale \n"\ - " \n"\ - "; emulate ps1x _bx2, so substract 0.5f and multiply by 2 \n"\ - "mad r4.xyz, r4, r11, c0; \n"\ - " \n"\ - "mad r2.xy, r3, r4, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ - " \n"\ - "; modified parallax mapping to avoid swimming: \n"\ - ";mul r3, r1_bx2.wwww, r1_bx2.zzzz ; r3 = (h,h,h,h) * (n.z, n.z, n.z, n.z,) \n"\ - ";mul r3, r3, c6; ; r3 = (nh, nh, nh) * scale \n"\ - ";mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ - " \n"\ - "texld r0, r2, s0 ; load diffuse texture with new tex coord \n"\ - "texld r1, r2, s1 ; sample normal map \n"\ - "mov r2.xyz, t2 ; fetch light vector 1 \n"\ - "mov r3.xyz, t3 ; fetch light vector 2 \n"\ - " \n"\ - "; emulate ps1x _bx2, so substract 0.5f and multiply by 2 \n"\ - "mad r1.xyz, r1, r11, c0; \n"\ - "mad r2.xyz, r2, r11, c0; \n"\ - "mad r3.xyz, r3, r11, c0; \n"\ - " \n"\ - "dp3_sat r2, r1, r2 ; normal dot light 1 (_bx2 because moved into 0..1) \n"\ - "mul r2, r2, v0 ; luminance1 * light color 1 \n"\ - " \n"\ - "dp3_sat r3, r1, r3 ; normal dot light 2 (_bx2 because moved into 0..1) \n"\ - "mad r3, r3, v1, r2 ; (luminance2 * light color 2) + luminance1 \n"\ - " \n"\ - "mul r0.xyz, r0, r3 ; total luminance * base color \n"\ - "mov r0.a, v0.a ; write original alpha value \n"\ - "mov oC0, r0; \n"\ - "\n"; - - CD3D9ParallaxMapRenderer::CD3D9ParallaxMapRenderer( - IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) - : CD3D9ShaderMaterialRenderer(d3ddev, driver, 0, baseMaterial), - CurrentScale(0.0f) - { - // set this as callback. We could have done this in - // the initialization list, but some compilers don't like it. - - CallBack = this; - - // basicly, this thing simply compiles these hardcoded shaders if the - // hardware is able to do them, otherwise it maps to the base material - - if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_4) || - !driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - { - // this hardware is not able to do shaders. Fall back to - // base material. - outMaterialTypeNr = driver->addMaterialRenderer(this); - return; - } - - // check if already compiled parallax map shaders are there. - - video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_PARALLAX_MAP_SOLID); - if (renderer) - { - // use the already compiled shaders - video::CD3D9ParallaxMapRenderer* nmr = (video::CD3D9ParallaxMapRenderer*)renderer; - VertexShader = nmr->VertexShader; - if (VertexShader) - VertexShader->AddRef(); - - PixelShader = nmr->PixelShader; - if (PixelShader) - PixelShader->AddRef(); - - outMaterialTypeNr = driver->addMaterialRenderer(this); - } - else - { - #ifdef SHADER_EXTERNAL_DEBUG - - // quickly load shader from external file - io::CReadFile* file = new io::CReadFile("parallax.psh"); - s32 sz = file->getSize(); - char* s = new char[sz+1]; - file->read(s, sz); - s[sz] = 0; - - init(outMaterialTypeNr, D3D9_PARALLAX_MAP_VSH, s); - - delete [] s; - file->drop(); - - #else - - // compile shaders on our own - init(outMaterialTypeNr, D3D9_PARALLAX_MAP_VSH, D3D9_PARALLAX_MAP_PSH); - - #endif // SHADER_EXTERNAL_DEBUG - } - } - - CD3D9ParallaxMapRenderer::~CD3D9ParallaxMapRenderer() - { - if (CallBack == this) - CallBack = 0; - } - - bool CD3D9ParallaxMapRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) - { - if (vtxtype != video::EVT_TANGENTS) - { - os::Printer::log("Error: Parallax map renderer only supports vertices of type EVT_TANGENTS", ELL_ERROR); - return false; - } - - return CD3D9ShaderMaterialRenderer::OnRender(service, vtxtype); - } - - void CD3D9ParallaxMapRenderer::OnSetMaterial(video::SMaterial& material, - const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services) - { - CD3D9ShaderMaterialRenderer::OnSetMaterial(material, lastMaterial, - resetAllRenderstates, services); - - CurrentScale = material.MaterialTypeParam; - } - - //! Returns the render capability of the material. - s32 CD3D9ParallaxMapRenderer::getRenderCapability() - { - if (Driver->queryFeature(video::EVDF_PIXEL_SHADER_1_4) && - Driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - return 0; - - return 1; - } - - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - void CD3D9ParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) - { - video::IVideoDriver* driver = services->getVideoDriver(); - - // set transposed world matrix - services->setVertexShaderConstant(driver->getTransform(video::ETS_WORLD).getTransposed().pointer(), 0, 4); - - // set eye position - - // The viewpoint is at (0., 0., 0.) in eye space. - // Turning this into a vector [0 0 0 1] and multiply it by - // the inverse of the view matrix, the resulting vector is the - // object space location of the camera. - - f32 floats[4] = {0,0,0,1}; - core::matrix4 minv = driver->getTransform(video::ETS_VIEW); - minv.makeInverse(); - minv.multiplyWith1x4Matrix(floats); - services->setVertexShaderConstant(floats, 4, 1); - - // set transposed worldViewProj matrix - core::matrix4 worldViewProj; - worldViewProj = driver->getTransform(video::ETS_PROJECTION); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - services->setVertexShaderConstant(worldViewProj.getTransposed().pointer(), 8, 4); - - // here we've got to fetch the fixed function lights from the driver - // and set them as constants - - int cnt = driver->getDynamicLightCount(); - - for (int i=0; i<2; ++i) - { - SLight light; - - if (igetDynamicLight(i); - else - { - light.DiffuseColor.set(0,0,0); // make light dark - light.Radius = 1.0f; - } - - light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation - - services->setVertexShaderConstant(reinterpret_cast(&light.Position), 12+(i*2), 1); - services->setVertexShaderConstant(reinterpret_cast(&light.DiffuseColor), 13+(i*2), 1); - } - - // this is not really necessary in d3d9 (used a def instruction), but to be sure: - f32 c95[] = {0.5f, 0.5f, 0.5f, 0.5f}; - services->setVertexShaderConstant(c95, 95, 1); - f32 c96[] = {-1, 1, 1, 1}; - services->setVertexShaderConstant(c96, 96, 1); - - // set scale factor - f32 factor = 0.02f; // default value - if (CurrentScale != 0) - factor = CurrentScale; - - f32 c6[] = {factor, factor, factor, 0}; - services->setPixelShaderConstant(c6, 6, 1); - } - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + +#include "CD3D9ParallaxMapRenderer.h" +#include "IMaterialRendererServices.h" +#include "IVideoDriver.h" +#include "os.h" +#include "SLight.h" + +//#define SHADER_EXTERNAL_DEBUG + +#ifdef SHADER_EXTERNAL_DEBUG +#include "CReadFile.h" +#endif + +namespace irr +{ +namespace video +{ + // 1.1/1.4 Shaders with two lights and vertex based attenuation + + // Irrlicht Engine D3D9 render path normal map vertex shader + const char D3D9_PARALLAX_MAP_VSH[] = + ";Irrlicht Engine 0.10 D3D9 render path parallax mapping vertex shader\n"\ + "; c0-3: Transposed world matrix \n"\ + "; c4: Eye position \n"\ + "; c8-11: Transposed worldViewProj matrix (Projection * View * World) \n"\ + "; c12: Light01 position \n"\ + "; c13: x,y,z: Light01 color; .w: 1/LightRadius² \n"\ + "; c14: Light02 position \n"\ + "; c15: x,y,z: Light02 color; .w: 1/LightRadius² \n"\ + "vs.1.1\n"\ + "dcl_position v0 ; position \n"\ + "dcl_normal v1 ; normal \n"\ + "dcl_color v2 ; color \n"\ + "dcl_texcoord0 v3 ; texture coord \n"\ + "dcl_texcoord1 v4 ; tangent \n"\ + "dcl_texcoord2 v5 ; binormal \n"\ + "\n"\ + "def c95, 0.5, 0.5, 0.5, 0.5 ; used for moving light vector to ps \n"\ + "def c96, -1, 1, 1, 1 ; somewhere I've got a bug. flipping the vectors with this fixes it. \n"\ + "\n"\ + "m4x4 oPos, v0, c8 ; transform position to clip space with worldViewProj matrix\n"\ + "\n"\ + "m3x3 r5, v4, c0 ; transform tangent U\n"\ + "m3x3 r7, v1, c0 ; transform normal W\n"\ + "m3x3 r6, v5, c0 ; transform binormal V\n"\ + "\n"\ + "m4x4 r4, v0, c0 ; vertex into world position\n"\ + "add r2, c12, -r4 ; vtxpos - light1 pos\n"\ + "add r3, c14, -r4 ; vtxpos - light2 pos\n"\ + "add r1, -c4, r4 ; eye - vtxpos \n"\ + "\n"\ + "dp3 r8.x, r5, r2 ; transform the light1 vector with U, V, W\n"\ + "dp3 r8.y, r6, r2 \n"\ + "dp3 r8.z, r7, r2 \n"\ + "dp3 r9.x, r5, r3 ; transform the light2 vector with U, V, W\n"\ + "dp3 r9.y, r6, r3 \n"\ + "dp3 r9.z, r7, r3 \n"\ + "dp3 r10.x, r5, r1 ; transform the eye vector with U, V, W\n"\ + "dp3 r10.y, r6, r1 \n"\ + "dp3 r10.z, r7, r1 \n"\ + "\n"\ + "dp3 r8.w, r8, r8 ; normalize light vector 1 (r8)\n"\ + "rsq r8.w, r8.w \n"\ + "mul r8, r8, r8.w \n"\ + ";mul r8, r8, c96 \n"\ + "dp3 r9.w, r9, r9 ; normalize light vector 2 (r9)\n"\ + "rsq r9.w, r9.w \n"\ + "mul r9, r9, r9.w \n"\ + ";mul r9, r9, c96 \n"\ + "dp3 r10.w, r10, r10 ; normalize eye vector (r10)\n"\ + "rsq r10.w, r10.w \n"\ + "mul r10, r10, r10.w \n"\ + "mul r10, r10, c96 \n"\ + "\n"\ + "\n"\ + "mad oT2.xyz, r8.xyz, c95, c95 ; move light vector 1 from -1..1 into 0..1 \n"\ + "mad oT3.xyz, r9.xyz, c95, c95 ; move light vector 2 from -1..1 into 0..1 \n"\ + "mad oT4.xyz, r10.xyz, c95, c95 ; move eye vector from -1..1 into 0..1 \n"\ + "\n"\ + " ; calculate attenuation of light 1 \n"\ + "dp3 r2.x, r2.xyz, r2.xyz ; r2.x = r2.x² + r2.y² + r2.z² \n"\ + "mul r2.x, r2.x, c13.w ; r2.x * attenutation \n"\ + "rsq r2, r2.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ + "mul oD0, r2, c13 ; resulting light color = lightcolor * attenuation \n"\ + "\n"\ + " ; calculate attenuation of light 2 \n"\ + "dp3 r3.x, r3.xyz, r3.xyz ; r3.x = r3.x² + r3.y² + r3.z² \n"\ + "mul r3.x, r3.x, c15.w ; r2.x * attenutation \n"\ + "rsq r3, r3.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ + "mul oD1, r3, c15 ; resulting light color = lightcolor * attenuation \n"\ + "\n"\ + "mov oT0.xy, v3.xy ; move out texture coordinates 1\n"\ + "mov oT1.xy, v3.xy ; move out texture coordinates 2\n"\ + "mov oD0.a, v2.a ; move out original alpha value \n"\ + "\n"; + + + // Irrlicht Engine D3D9 render path normal map pixel shader version 1.4 + const char D3D9_PARALLAX_MAP_PSH[] = + ";Irrlicht Engine 0.10 D3D9 render path parallax mapping pixel shader \n"\ + ";Input: \n"\ + ";t0: color map texture coord \n"\ + ";t1: normal map texture coords \n"\ + ";t2: light 1 vector in tangent space \n"\ + ";t4: eye vector in tangent space \n"\ + ";v0: light 1 color \n"\ + ";t3: light 2 vector in tangent space \n"\ + ";v1: light 2 color \n"\ + ";v0.a: vertex alpha value \n"\ + " \n"\ + "ps.1.4 \n"\ + " \n"\ + ";def c6, 0.02f, 0.02f, 0.02f, 0.0f ; scale factor, now set in callback \n"\ + "def c5, 0.5f, 0.5f, 0.5f, 0.0f ; for specular division \n"\ + " \n"\ + "texld r1, t1 ; sample (normal.x, normal.y, normal.z, height) \n"\ + "texcrd r4.xyz, t4 ; fetch eye vector \n"\ + "texcrd r0.xyz, t0 ; color map \n"\ + " \n"\ + "; original parallax mapping: \n"\ + ";mul r3, r1_bx2.wwww, c6; ; r3 = (height, height, height) * scale \n"\ + ";mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ + " \n"\ + "; modified parallax mapping to reduce swimming effect: \n"\ + "mul r3, r1_bx2.wwww, r1_bx2.zzzz ; (nh,nh,nh,nh) = (h,h,h,h) * (n.z,n.z,n.z,n.z,) \n"\ + "mul r3, r3, c6; ; r3 = (nh, nh, nh) * scale \n"\ + "mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ + " \n"\ + "phase \n"\ + " \n"\ + "texld r0, r2 ; load diffuse texture with new tex coord \n"\ + "texld r1, r2 ; sample normal map \n"\ + "texcrd r2.xyz, t2 ; fetch light vector 1 \n"\ + "texcrd r3.xyz, t3 ; fetch light vector 2 \n"\ + " \n"\ + "dp3_sat r5, r1_bx2, r2_bx2 ; normal dot light 1 (_bx2 because moved into 0..1) \n"\ + "mul r5, r5, v0 ; luminance1 * light color 1 \n"\ + " \n"\ + "dp3_sat r3, r1_bx2, r3_bx2 ; normal dot light 2 (_bx2 because moved into 0..1) \n"\ + "mad r3, r3, v1, r5 ; (luminance2 * light color 2) + luminance1 \n"\ + " \n"\ + "mul r0.xyz, r0, r3 ; total luminance * base color \n"\ + "+mov r0.a, v0.a ; write original alpha value \n"\ + "\n"; + + // Irrlicht Engine D3D9 render path normal map pixel shader version 2.0 + const char D3D9_PARALLAX_MAP_PSH_20[] = + ";Irrlicht Engine 0.10 D3D9 render path parallax mapping pixel shader \n"\ + ";Input: \n"\ + " \n"\ + ";t0: color map texture coord \n"\ + ";t1: normal map texture coords \n"\ + ";t2: light 1 vector in tangent space \n"\ + ";t4: eye vector in tangent space \n"\ + ";v0: light 1 color \n"\ + ";t3: light 2 vector in tangent space \n"\ + ";v1: light 2 color \n"\ + ";v0.a: vertex alpha value \n"\ + " \n"\ + "ps.2.0 \n"\ + " \n"\ + "dcl_2d s0 ; Declare the s0 register to be the sampler for stage 0 \n"\ + "dcl t0.xy ; Declare t0 to have 2D texture coordinates from stage 0 \n"\ + "dcl t1.xy ; Declare t0 to have 2D texture coordinates from stage 0 \n"\ + "dcl_2d s1 ; Declare the s1 register to be the sampler for stage 1 \n"\ + " \n"\ + "dcl t2.xyz ; \n"\ + "dcl t3.xyz ; \n"\ + "dcl t4.xyz ; \n"\ + "dcl v0.xyzw; \n"\ + "dcl v1.xyzw; \n"\ + " \n"\ + "def c0, -1.0f, -1.0f, -1.0f, -1.0f ; for _bx2 emulation \n"\ + "def c1, 2.0f, 2.0f, 2.0f, 2.0f ; for _bx2 emulation \n"\ + "mov r11, c1; \n"\ + " \n"\ + "texld r1, t1, s1 ; sample (normal.x, normal.y, normal.z, height) \n"\ + "mov r4.xyz, t4 ; fetch eye vector \n"\ + "mov r0.xy, t0 ; color map \n"\ + " \n"\ + "; original parallax mapping: \n"\ + "; emulate ps1x _bx2, so substract 0.5f and multiply by 2 \n"\ + "mad r1.xyz, r1, r11, c0; \n"\ + " \n"\ + "mul r3, r1.wwww, c6; ; r3 = (height, height, height) * scale \n"\ + " \n"\ + "; emulate ps1x _bx2, so substract 0.5f and multiply by 2 \n"\ + "mad r4.xyz, r4, r11, c0; \n"\ + " \n"\ + "mad r2.xy, r3, r4, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ + " \n"\ + "; modified parallax mapping to avoid swimming: \n"\ + ";mul r3, r1_bx2.wwww, r1_bx2.zzzz ; r3 = (h,h,h,h) * (n.z, n.z, n.z, n.z,) \n"\ + ";mul r3, r3, c6; ; r3 = (nh, nh, nh) * scale \n"\ + ";mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ + " \n"\ + "texld r0, r2, s0 ; load diffuse texture with new tex coord \n"\ + "texld r1, r2, s1 ; sample normal map \n"\ + "mov r2.xyz, t2 ; fetch light vector 1 \n"\ + "mov r3.xyz, t3 ; fetch light vector 2 \n"\ + " \n"\ + "; emulate ps1x _bx2, so substract 0.5f and multiply by 2 \n"\ + "mad r1.xyz, r1, r11, c0; \n"\ + "mad r2.xyz, r2, r11, c0; \n"\ + "mad r3.xyz, r3, r11, c0; \n"\ + " \n"\ + "dp3_sat r2, r1, r2 ; normal dot light 1 (_bx2 because moved into 0..1) \n"\ + "mul r2, r2, v0 ; luminance1 * light color 1 \n"\ + " \n"\ + "dp3_sat r3, r1, r3 ; normal dot light 2 (_bx2 because moved into 0..1) \n"\ + "mad r3, r3, v1, r2 ; (luminance2 * light color 2) + luminance1 \n"\ + " \n"\ + "mul r0.xyz, r0, r3 ; total luminance * base color \n"\ + "mov r0.a, v0.a ; write original alpha value \n"\ + "mov oC0, r0; \n"\ + "\n"; + + CD3D9ParallaxMapRenderer::CD3D9ParallaxMapRenderer( + IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, + s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) + : CD3D9ShaderMaterialRenderer(d3ddev, driver, 0, baseMaterial), + CurrentScale(0.0f) + { + // set this as callback. We could have done this in + // the initialization list, but some compilers don't like it. + + CallBack = this; + + // basicly, this thing simply compiles these hardcoded shaders if the + // hardware is able to do them, otherwise it maps to the base material + + if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_4) || + !driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) + { + // this hardware is not able to do shaders. Fall back to + // base material. + outMaterialTypeNr = driver->addMaterialRenderer(this); + return; + } + + // check if already compiled parallax map shaders are there. + + video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_PARALLAX_MAP_SOLID); + if (renderer) + { + // use the already compiled shaders + video::CD3D9ParallaxMapRenderer* nmr = (video::CD3D9ParallaxMapRenderer*)renderer; + VertexShader = nmr->VertexShader; + if (VertexShader) + VertexShader->AddRef(); + + PixelShader = nmr->PixelShader; + if (PixelShader) + PixelShader->AddRef(); + + outMaterialTypeNr = driver->addMaterialRenderer(this); + } + else + { + #ifdef SHADER_EXTERNAL_DEBUG + + // quickly load shader from external file + io::CReadFile* file = new io::CReadFile("parallax.psh"); + s32 sz = file->getSize(); + char* s = new char[sz+1]; + file->read(s, sz); + s[sz] = 0; + + init(outMaterialTypeNr, D3D9_PARALLAX_MAP_VSH, s); + + delete [] s; + file->drop(); + + #else + + // compile shaders on our own + init(outMaterialTypeNr, D3D9_PARALLAX_MAP_VSH, D3D9_PARALLAX_MAP_PSH); + + #endif // SHADER_EXTERNAL_DEBUG + } + } + + CD3D9ParallaxMapRenderer::~CD3D9ParallaxMapRenderer() + { + if (CallBack == this) + CallBack = 0; + } + + bool CD3D9ParallaxMapRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) + { + if (vtxtype != video::EVT_TANGENTS) + { + os::Printer::log("Error: Parallax map renderer only supports vertices of type EVT_TANGENTS", ELL_ERROR); + return false; + } + + return CD3D9ShaderMaterialRenderer::OnRender(service, vtxtype); + } + + void CD3D9ParallaxMapRenderer::OnSetMaterial(video::SMaterial& material, + const video::SMaterial& lastMaterial, + bool resetAllRenderstates, video::IMaterialRendererServices* services) + { + CD3D9ShaderMaterialRenderer::OnSetMaterial(material, lastMaterial, + resetAllRenderstates, services); + + CurrentScale = material.MaterialTypeParam; + } + + //! Returns the render capability of the material. + s32 CD3D9ParallaxMapRenderer::getRenderCapability() + { + if (Driver->queryFeature(video::EVDF_PIXEL_SHADER_1_4) && + Driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) + return 0; + + return 1; + } + + + //! Called by the engine when the vertex and/or pixel shader constants for an + //! material renderer should be set. + void CD3D9ParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) + { + video::IVideoDriver* driver = services->getVideoDriver(); + + // set transposed world matrix + services->setVertexShaderConstant(driver->getTransform(video::ETS_WORLD).getTransposed().pointer(), 0, 4); + + // set eye position + + // The viewpoint is at (0., 0., 0.) in eye space. + // Turning this into a vector [0 0 0 1] and multiply it by + // the inverse of the view matrix, the resulting vector is the + // object space location of the camera. + + f32 floats[4] = {0,0,0,1}; + core::matrix4 minv = driver->getTransform(video::ETS_VIEW); + minv.makeInverse(); + minv.multiplyWith1x4Matrix(floats); + services->setVertexShaderConstant(floats, 4, 1); + + // set transposed worldViewProj matrix + core::matrix4 worldViewProj; + worldViewProj = driver->getTransform(video::ETS_PROJECTION); + worldViewProj *= driver->getTransform(video::ETS_VIEW); + worldViewProj *= driver->getTransform(video::ETS_WORLD); + services->setVertexShaderConstant(worldViewProj.getTransposed().pointer(), 8, 4); + + // here we've got to fetch the fixed function lights from the driver + // and set them as constants + + int cnt = driver->getDynamicLightCount(); + + for (int i=0; i<2; ++i) + { + SLight light; + + if (igetDynamicLight(i); + else + { + light.DiffuseColor.set(0,0,0); // make light dark + light.Radius = 1.0f; + } + + light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation + + services->setVertexShaderConstant(reinterpret_cast(&light.Position), 12+(i*2), 1); + services->setVertexShaderConstant(reinterpret_cast(&light.DiffuseColor), 13+(i*2), 1); + } + + // this is not really necessary in d3d9 (used a def instruction), but to be sure: + f32 c95[] = {0.5f, 0.5f, 0.5f, 0.5f}; + services->setVertexShaderConstant(c95, 95, 1); + f32 c96[] = {-1, 1, 1, 1}; + services->setVertexShaderConstant(c96, 96, 1); + + // set scale factor + f32 factor = 0.02f; // default value + if (CurrentScale != 0) + factor = CurrentScale; + + f32 c6[] = {factor, factor, factor, 0}; + services->setPixelShaderConstant(c6, 6, 1); + } + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CD3D9ParallaxMapRenderer.h b/src/dep/src/irrlicht/CD3D9ParallaxMapRenderer.h index ec9e9c0..a223ef6 100644 --- a/src/dep/src/irrlicht/CD3D9ParallaxMapRenderer.h +++ b/src/dep/src/irrlicht/CD3D9ParallaxMapRenderer.h @@ -1,59 +1,59 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D9_PARALLAX_MAPMATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D9_PARALLAX_MAPMATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ -#include "d3d9.h" - -#include "CD3D9ShaderMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" - -namespace irr -{ -namespace video -{ - -//! Renderer for normal maps using parallax mapping -class CD3D9ParallaxMapRenderer : - public CD3D9ShaderMaterialRenderer, IShaderConstantSetCallBack -{ -public: - - CD3D9ParallaxMapRenderer( - IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); - - ~CD3D9ParallaxMapRenderer(); - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); - - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - //! Returns the render capability of the material. - virtual s32 getRenderCapability(); - - virtual void OnSetMaterial(video::SMaterial& material, - const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services); - -private: - - f32 CurrentScale; - -}; - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_D3D9_PARALLAX_MAPMATERIAL_RENDERER_H_INCLUDED__ +#define __C_D3D9_PARALLAX_MAPMATERIAL_RENDERER_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_WINDOWS_ + +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ +#include "d3d9.h" + +#include "CD3D9ShaderMaterialRenderer.h" +#include "IShaderConstantSetCallBack.h" + +namespace irr +{ +namespace video +{ + +//! Renderer for normal maps using parallax mapping +class CD3D9ParallaxMapRenderer : + public CD3D9ShaderMaterialRenderer, IShaderConstantSetCallBack +{ +public: + + CD3D9ParallaxMapRenderer( + IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, + s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); + + ~CD3D9ParallaxMapRenderer(); + + //! Called by the engine when the vertex and/or pixel shader constants for an + //! material renderer should be set. + virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); + + virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); + + //! Returns the render capability of the material. + virtual s32 getRenderCapability(); + + virtual void OnSetMaterial(video::SMaterial& material, + const video::SMaterial& lastMaterial, + bool resetAllRenderstates, video::IMaterialRendererServices* services); + +private: + + f32 CurrentScale; + +}; + +} // end namespace video +} // end namespace irr + +#endif +#endif +#endif + diff --git a/src/dep/src/irrlicht/CD3D9ShaderMaterialRenderer.cpp b/src/dep/src/irrlicht/CD3D9ShaderMaterialRenderer.cpp index 50796ab..65914f3 100644 --- a/src/dep/src/irrlicht/CD3D9ShaderMaterialRenderer.cpp +++ b/src/dep/src/irrlicht/CD3D9ShaderMaterialRenderer.cpp @@ -1,520 +1,520 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - -#include "CD3D9ShaderMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" -#include "IMaterialRendererServices.h" -#include "IVideoDriver.h" -#include "os.h" -#include "irrString.h" - -#ifndef _IRR_D3D_NO_SHADER_DEBUGGING -#include -#endif - - -namespace irr -{ -namespace video -{ - -//! Public constructor -CD3D9ShaderMaterialRenderer::CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData) -: pID3DDevice(d3ddev), Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), - VertexShader(0), OldVertexShader(0), PixelShader(0), UserData(userData) -{ - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); - - init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram); -} - - - -//! constructor only for use by derived classes who want to -//! create a fall back material for example. -CD3D9ShaderMaterialRenderer::CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev, - video::IVideoDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, - s32 userData) -: pID3DDevice(d3ddev), Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), - VertexShader(0), OldVertexShader(0), PixelShader(0), UserData(userData) -{ - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); -} - - -void CD3D9ShaderMaterialRenderer::init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, - const c8* pixelShaderProgram) -{ - outMaterialTypeNr = -1; - - // create vertex shader - if (!createVertexShader(vertexShaderProgram)) - return; - - // create pixel shader - if (!createPixelShader(pixelShaderProgram)) - return; - - // register myself as new material - outMaterialTypeNr = Driver->addMaterialRenderer(this); -} - - - -//! Destructor -CD3D9ShaderMaterialRenderer::~CD3D9ShaderMaterialRenderer() -{ - if (CallBack) - CallBack->drop(); - - if (VertexShader) - VertexShader->Release(); - - if (PixelShader) - PixelShader->Release(); - - if (BaseMaterial) - BaseMaterial->drop (); -} - -bool CD3D9ShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) -{ - // call callback to set shader constants - if (CallBack && (VertexShader || PixelShader)) - CallBack->OnSetConstants(service, UserData); - - return true; -} - -void CD3D9ShaderMaterialRenderer::OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services) -{ - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (VertexShader) - { - // save old vertex shader - pID3DDevice->GetVertexShader(&OldVertexShader); - - // set new vertex shader - if (FAILED(pID3DDevice->SetVertexShader(VertexShader))) - os::Printer::log("Could not set vertex shader."); - } - - // set new pixel shader - if (PixelShader) - { - if (FAILED(pID3DDevice->SetPixelShader(PixelShader))) - os::Printer::log("Could not set pixel shader."); - } - - if (BaseMaterial) - BaseMaterial->OnSetMaterial(material, material, true, services); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); -} - -void CD3D9ShaderMaterialRenderer::OnUnsetMaterial() -{ - if (VertexShader) - pID3DDevice->SetVertexShader(OldVertexShader); - - if (PixelShader) - pID3DDevice->SetPixelShader(0); - - if (BaseMaterial) - BaseMaterial->OnUnsetMaterial(); -} - - -//! Returns if the material is transparent. The scene managment needs to know this -//! for being able to sort the materials by opaque and transparent. -bool CD3D9ShaderMaterialRenderer::isTransparent() -{ - return BaseMaterial ? BaseMaterial->isTransparent() : false; -} - -bool CD3D9ShaderMaterialRenderer::createPixelShader(const c8* pxsh) -{ - if (!pxsh) - return true; - - // compile shader - - LPD3DXBUFFER code = 0; - LPD3DXBUFFER errors = 0; - - #ifdef _IRR_D3D_NO_SHADER_DEBUGGING - - // compile shader without debug info - stubD3DXAssembleShader(pxsh, strlen(pxsh), 0, 0, 0, &code, &errors); - #else - - // compile shader and emitt some debug informations to - // make it possible to debug the shader in visual studio - - static int irr_dbg_file_nr = 0; - ++irr_dbg_file_nr; - char tmp[32]; - sprintf(tmp, "irr_d3d9_dbg_shader_%d.psh", irr_dbg_file_nr); - - FILE* f = fopen(tmp, "wb"); - fwrite(pxsh, strlen(pxsh), 1, f); - fflush(f); - fclose(f); - - stubD3DXAssembleShaderFromFile(tmp, 0, 0, D3DXSHADER_DEBUG, &code, &errors); - - #endif - - - if (errors) - { - // print out compilation errors. - os::Printer::log("Pixel shader compilation failed:"); - os::Printer::log((c8*)errors->GetBufferPointer()); - - if (code) - code->Release(); - - errors->Release(); - return false; - } - - if (FAILED(pID3DDevice->CreatePixelShader((DWORD*)code->GetBufferPointer(), &PixelShader))) - { - os::Printer::log("Could not create pixel shader."); - code->Release(); - return false; - } - - code->Release(); - return true; -} - - - -bool CD3D9ShaderMaterialRenderer::createVertexShader(const char* vtxsh) -{ - if (!vtxsh) - return true; - - // compile shader - - LPD3DXBUFFER code = 0; - LPD3DXBUFFER errors = 0; - - #ifdef _IRR_D3D_NO_SHADER_DEBUGGING - - // compile shader without debug info - stubD3DXAssembleShader(vtxsh, strlen(vtxsh), 0, 0, 0, &code, &errors); - - #else - - // compile shader and emitt some debug informations to - // make it possible to debug the shader in visual studio - - static int irr_dbg_file_nr = 0; - ++irr_dbg_file_nr; - char tmp[32]; - sprintf(tmp, "irr_d3d9_dbg_shader_%d.vsh", irr_dbg_file_nr); - - FILE* f = fopen(tmp, "wb"); - fwrite(vtxsh, strlen(vtxsh), 1, f); - fflush(f); - fclose(f); - - stubD3DXAssembleShaderFromFile(tmp, 0, 0, D3DXSHADER_DEBUG, &code, &errors); - - #endif - - - if (errors) - { - // print out compilation errors. - os::Printer::log("Vertex shader compilation failed:"); - os::Printer::log((c8*)errors->GetBufferPointer()); - - if (code) - code->Release(); - - errors->Release(); - return false; - } - - if (!code || FAILED(pID3DDevice->CreateVertexShader((DWORD*)code->GetBufferPointer(), &VertexShader))) - { - os::Printer::log("Could not create vertex shader."); - if (code) - code->Release(); - return false; - } - - code->Release(); - return true; -} - -HRESULT CD3D9ShaderMaterialRenderer::stubD3DXAssembleShader(LPCSTR pSrcData, UINT SrcDataLen, - CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - DWORD Flags, LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs) -{ - // Because Irrlicht needs to be able to start up even without installed d3d dlls, it - // needs to load external d3d dlls manually. examples for the dlls are: - // SDK dll name D3DX_SDK_VERSION - // Summer 2004: no dll 22 - // February 2005: d3dx9_24.dll 24 - // April 2005: d3dx9_25.dll 25 - // June 2005: d3dx9_26.dll 26 - // August 2005: d3dx9_27.dll 27 - // October 2005, - // December 2005: d3dx9_28.dll 28 - - #if ( D3DX_SDK_VERSION < 24 ) - // directly link functions, old d3d sdks didn't try to load external dlls - // when linking to the d3dx9.lib - #pragma comment (lib, "d3dx9.lib") - - // invoke static linked function - return D3DXAssembleShader(pSrcData, SrcDataLen, pDefines, pInclude, - Flags, ppShader, ppErrorMsgs); - #else - { - // try to load shader functions from the dll and print error if failed. - - // D3DXAssembleShader signature - typedef HRESULT (WINAPI *AssembleShaderFunction)(LPCSTR pSrcData, UINT SrcDataLen, - CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - DWORD Flags, LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs); - - static bool LoadFailed = false; - static AssembleShaderFunction pFn = 0; - - if (!pFn && !LoadFailed) - { - // try to load dll - core::stringc strDllName = "d3dx9_"; - strDllName += (int)D3DX_SDK_VERSION; - strDllName += ".dll"; - - HMODULE hMod = LoadLibrary(strDllName.c_str()); - if (hMod) - pFn = (AssembleShaderFunction)GetProcAddress(hMod, "D3DXAssembleShader"); - - if (!pFn) - { - LoadFailed = true; - os::Printer::log("Could not load shader function D3DXAssembleShader from dll, shaders disabled", - strDllName.c_str(), ELL_ERROR); - } - } - - if (pFn) - { - // call already loaded function - return (*pFn)(pSrcData, SrcDataLen, pDefines, pInclude, Flags, ppShader, ppErrorMsgs); - } - } - #endif // D3DX_SDK_VERSION < 24 - - return 0; -} - -HRESULT CD3D9ShaderMaterialRenderer::stubD3DXAssembleShaderFromFile(LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, DWORD Flags, - LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs) -{ - // wondering what I'm doing here? - // see comment in CD3D9ShaderMaterialRenderer::stubD3DXAssembleShader() - - #if ( D3DX_SDK_VERSION < 24 ) - // directly link functions, old d3d sdks didn't try to load external dlls - // when linking to the d3dx9.lib - #pragma comment (lib, "d3dx9.lib") - - // invoke static linked function - return D3DXAssembleShaderFromFile(pSrcFile, pDefines, pInclude, Flags, - ppShader, ppErrorMsgs); - #else - { - // try to load shader functions from the dll and print error if failed. - - // D3DXAssembleShaderFromFileA signature - typedef HRESULT (WINAPI *AssembleShaderFromFileFunction)(LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, DWORD Flags, - LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs); - - static bool LoadFailed = false; - static AssembleShaderFromFileFunction pFn = 0; - - if (!pFn && !LoadFailed) - { - // try to load dll - core::stringc strDllName = "d3dx9_"; - strDllName += (int)D3DX_SDK_VERSION; - strDllName += ".dll"; - - HMODULE hMod = LoadLibrary(strDllName.c_str()); - if (hMod) - pFn = (AssembleShaderFromFileFunction)GetProcAddress(hMod, "D3DXAssembleShaderFromFileA"); - - if (!pFn) - { - LoadFailed = true; - os::Printer::log("Could not load shader function D3DXAssembleShaderFromFileA from dll, shaders disabled", - strDllName.c_str(), ELL_ERROR); - } - } - - if (pFn) - { - // call already loaded function - return (*pFn)(pSrcFile, pDefines, pInclude, Flags, ppShader, ppErrorMsgs); - } - } - #endif // D3DX_SDK_VERSION < 24 - - return 0; -} - - -HRESULT CD3D9ShaderMaterialRenderer::stubD3DXCompileShader(LPCSTR pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, - LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable) -{ - // wondering what I'm doing here? - // see comment in CD3D9ShaderMaterialRenderer::stubD3DXAssembleShader() - - #if ( D3DX_SDK_VERSION < 24 ) - // directly link functions, old d3d sdks didn't try to load external dlls - // when linking to the d3dx9.lib - #pragma comment (lib, "d3dx9.lib") - - // invoke static linked function - return D3DXCompileShader(pSrcData, SrcDataLen, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); - #else - { - // try to load shader functions from the dll and print error if failed. - - // D3DXCompileShader - typedef HRESULT (WINAPI *D3DXCompileShaderFunction)(LPCSTR pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, - LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable); - - static bool LoadFailed = false; - static D3DXCompileShaderFunction pFn = 0; - - if (!pFn && !LoadFailed) - { - // try to load dll - core::stringc strDllName = "d3dx9_"; - strDllName += (int)D3DX_SDK_VERSION; - strDllName += ".dll"; - - HMODULE hMod = LoadLibrary(strDllName.c_str()); - if (hMod) - pFn = (D3DXCompileShaderFunction)GetProcAddress(hMod, "D3DXCompileShader"); - - if (!pFn) - { - LoadFailed = true; - os::Printer::log("Could not load shader function D3DXCompileShader from dll, shaders disabled", - strDllName.c_str(), ELL_ERROR); - } - } - - if (pFn) - { - // call already loaded function - return (*pFn)(pSrcData, SrcDataLen, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); - } - } - #endif // D3DX_SDK_VERSION < 24 - - return 0; -} - -HRESULT CD3D9ShaderMaterialRenderer::stubD3DXCompileShaderFromFile(LPCSTR pSrcFile, CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, - LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable) -{ - // wondering what I'm doing here? - // see comment in CD3D9ShaderMaterialRenderer::stubD3DXAssembleShader() - - #if ( D3DX_SDK_VERSION < 24 ) - // directly link functions, old d3d sdks didn't try to load external dlls - // when linking to the d3dx9.lib - #pragma comment (lib, "d3dx9.lib") - - // invoke static linked function - return D3DXCompileShaderFromFile(pSrcFile, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); - #else - { - // try to load shader functions from the dll and print error if failed. - - // D3DXCompileShaderFromFileA - typedef HRESULT (WINAPI *D3DXCompileShaderFromFileFunction)(LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, - LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable); - - static bool LoadFailed = false; - static D3DXCompileShaderFromFileFunction pFn = 0; - - if (!pFn && !LoadFailed) - { - // try to load dll - core::stringc strDllName = "d3dx9_"; - strDllName += (int)D3DX_SDK_VERSION; - strDllName += ".dll"; - - HMODULE hMod = LoadLibrary(strDllName.c_str()); - if (hMod) - pFn = (D3DXCompileShaderFromFileFunction)GetProcAddress(hMod, "D3DXCompileShaderFromFileA"); - - if (!pFn) - { - LoadFailed = true; - os::Printer::log("Could not load shader function D3DXCompileShaderFromFileA from dll, shaders disabled", - strDllName.c_str(), ELL_ERROR); - } - } - - if (pFn) - { - // call already loaded function - return (*pFn)(pSrcFile, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); - } - } - #endif // D3DX_SDK_VERSION < 24 - - return 0; -} - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + +#include "CD3D9ShaderMaterialRenderer.h" +#include "IShaderConstantSetCallBack.h" +#include "IMaterialRendererServices.h" +#include "IVideoDriver.h" +#include "os.h" +#include "irrString.h" + +#ifndef _IRR_D3D_NO_SHADER_DEBUGGING +#include +#endif + + +namespace irr +{ +namespace video +{ + +//! Public constructor +CD3D9ShaderMaterialRenderer::CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, + s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, + IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData) +: pID3DDevice(d3ddev), Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), + VertexShader(0), OldVertexShader(0), PixelShader(0), UserData(userData) +{ + if (BaseMaterial) + BaseMaterial->grab(); + + if (CallBack) + CallBack->grab(); + + init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram); +} + + + +//! constructor only for use by derived classes who want to +//! create a fall back material for example. +CD3D9ShaderMaterialRenderer::CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev, + video::IVideoDriver* driver, + IShaderConstantSetCallBack* callback, + IMaterialRenderer* baseMaterial, + s32 userData) +: pID3DDevice(d3ddev), Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), + VertexShader(0), OldVertexShader(0), PixelShader(0), UserData(userData) +{ + if (BaseMaterial) + BaseMaterial->grab(); + + if (CallBack) + CallBack->grab(); +} + + +void CD3D9ShaderMaterialRenderer::init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, + const c8* pixelShaderProgram) +{ + outMaterialTypeNr = -1; + + // create vertex shader + if (!createVertexShader(vertexShaderProgram)) + return; + + // create pixel shader + if (!createPixelShader(pixelShaderProgram)) + return; + + // register myself as new material + outMaterialTypeNr = Driver->addMaterialRenderer(this); +} + + + +//! Destructor +CD3D9ShaderMaterialRenderer::~CD3D9ShaderMaterialRenderer() +{ + if (CallBack) + CallBack->drop(); + + if (VertexShader) + VertexShader->Release(); + + if (PixelShader) + PixelShader->Release(); + + if (BaseMaterial) + BaseMaterial->drop (); +} + +bool CD3D9ShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) +{ + // call callback to set shader constants + if (CallBack && (VertexShader || PixelShader)) + CallBack->OnSetConstants(service, UserData); + + return true; +} + +void CD3D9ShaderMaterialRenderer::OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, + bool resetAllRenderstates, video::IMaterialRendererServices* services) +{ + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + if (VertexShader) + { + // save old vertex shader + pID3DDevice->GetVertexShader(&OldVertexShader); + + // set new vertex shader + if (FAILED(pID3DDevice->SetVertexShader(VertexShader))) + os::Printer::log("Could not set vertex shader."); + } + + // set new pixel shader + if (PixelShader) + { + if (FAILED(pID3DDevice->SetPixelShader(PixelShader))) + os::Printer::log("Could not set pixel shader."); + } + + if (BaseMaterial) + BaseMaterial->OnSetMaterial(material, material, true, services); + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); +} + +void CD3D9ShaderMaterialRenderer::OnUnsetMaterial() +{ + if (VertexShader) + pID3DDevice->SetVertexShader(OldVertexShader); + + if (PixelShader) + pID3DDevice->SetPixelShader(0); + + if (BaseMaterial) + BaseMaterial->OnUnsetMaterial(); +} + + +//! Returns if the material is transparent. The scene managment needs to know this +//! for being able to sort the materials by opaque and transparent. +bool CD3D9ShaderMaterialRenderer::isTransparent() +{ + return BaseMaterial ? BaseMaterial->isTransparent() : false; +} + +bool CD3D9ShaderMaterialRenderer::createPixelShader(const c8* pxsh) +{ + if (!pxsh) + return true; + + // compile shader + + LPD3DXBUFFER code = 0; + LPD3DXBUFFER errors = 0; + + #ifdef _IRR_D3D_NO_SHADER_DEBUGGING + + // compile shader without debug info + stubD3DXAssembleShader(pxsh, strlen(pxsh), 0, 0, 0, &code, &errors); + #else + + // compile shader and emitt some debug informations to + // make it possible to debug the shader in visual studio + + static int irr_dbg_file_nr = 0; + ++irr_dbg_file_nr; + char tmp[32]; + sprintf(tmp, "irr_d3d9_dbg_shader_%d.psh", irr_dbg_file_nr); + + FILE* f = fopen(tmp, "wb"); + fwrite(pxsh, strlen(pxsh), 1, f); + fflush(f); + fclose(f); + + stubD3DXAssembleShaderFromFile(tmp, 0, 0, D3DXSHADER_DEBUG, &code, &errors); + + #endif + + + if (errors) + { + // print out compilation errors. + os::Printer::log("Pixel shader compilation failed:"); + os::Printer::log((c8*)errors->GetBufferPointer()); + + if (code) + code->Release(); + + errors->Release(); + return false; + } + + if (FAILED(pID3DDevice->CreatePixelShader((DWORD*)code->GetBufferPointer(), &PixelShader))) + { + os::Printer::log("Could not create pixel shader."); + code->Release(); + return false; + } + + code->Release(); + return true; +} + + + +bool CD3D9ShaderMaterialRenderer::createVertexShader(const char* vtxsh) +{ + if (!vtxsh) + return true; + + // compile shader + + LPD3DXBUFFER code = 0; + LPD3DXBUFFER errors = 0; + + #ifdef _IRR_D3D_NO_SHADER_DEBUGGING + + // compile shader without debug info + stubD3DXAssembleShader(vtxsh, strlen(vtxsh), 0, 0, 0, &code, &errors); + + #else + + // compile shader and emitt some debug informations to + // make it possible to debug the shader in visual studio + + static int irr_dbg_file_nr = 0; + ++irr_dbg_file_nr; + char tmp[32]; + sprintf(tmp, "irr_d3d9_dbg_shader_%d.vsh", irr_dbg_file_nr); + + FILE* f = fopen(tmp, "wb"); + fwrite(vtxsh, strlen(vtxsh), 1, f); + fflush(f); + fclose(f); + + stubD3DXAssembleShaderFromFile(tmp, 0, 0, D3DXSHADER_DEBUG, &code, &errors); + + #endif + + + if (errors) + { + // print out compilation errors. + os::Printer::log("Vertex shader compilation failed:"); + os::Printer::log((c8*)errors->GetBufferPointer()); + + if (code) + code->Release(); + + errors->Release(); + return false; + } + + if (!code || FAILED(pID3DDevice->CreateVertexShader((DWORD*)code->GetBufferPointer(), &VertexShader))) + { + os::Printer::log("Could not create vertex shader."); + if (code) + code->Release(); + return false; + } + + code->Release(); + return true; +} + +HRESULT CD3D9ShaderMaterialRenderer::stubD3DXAssembleShader(LPCSTR pSrcData, UINT SrcDataLen, + CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, + DWORD Flags, LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs) +{ + // Because Irrlicht needs to be able to start up even without installed d3d dlls, it + // needs to load external d3d dlls manually. examples for the dlls are: + // SDK dll name D3DX_SDK_VERSION + // Summer 2004: no dll 22 + // February 2005: d3dx9_24.dll 24 + // April 2005: d3dx9_25.dll 25 + // June 2005: d3dx9_26.dll 26 + // August 2005: d3dx9_27.dll 27 + // October 2005, + // December 2005: d3dx9_28.dll 28 + + #if ( D3DX_SDK_VERSION < 24 ) + // directly link functions, old d3d sdks didn't try to load external dlls + // when linking to the d3dx9.lib + #pragma comment (lib, "d3dx9.lib") + + // invoke static linked function + return D3DXAssembleShader(pSrcData, SrcDataLen, pDefines, pInclude, + Flags, ppShader, ppErrorMsgs); + #else + { + // try to load shader functions from the dll and print error if failed. + + // D3DXAssembleShader signature + typedef HRESULT (WINAPI *AssembleShaderFunction)(LPCSTR pSrcData, UINT SrcDataLen, + CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, + DWORD Flags, LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs); + + static bool LoadFailed = false; + static AssembleShaderFunction pFn = 0; + + if (!pFn && !LoadFailed) + { + // try to load dll + core::stringc strDllName = "d3dx9_"; + strDllName += (int)D3DX_SDK_VERSION; + strDllName += ".dll"; + + HMODULE hMod = LoadLibrary(strDllName.c_str()); + if (hMod) + pFn = (AssembleShaderFunction)GetProcAddress(hMod, "D3DXAssembleShader"); + + if (!pFn) + { + LoadFailed = true; + os::Printer::log("Could not load shader function D3DXAssembleShader from dll, shaders disabled", + strDllName.c_str(), ELL_ERROR); + } + } + + if (pFn) + { + // call already loaded function + return (*pFn)(pSrcData, SrcDataLen, pDefines, pInclude, Flags, ppShader, ppErrorMsgs); + } + } + #endif // D3DX_SDK_VERSION < 24 + + return 0; +} + +HRESULT CD3D9ShaderMaterialRenderer::stubD3DXAssembleShaderFromFile(LPCSTR pSrcFile, + CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, DWORD Flags, + LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs) +{ + // wondering what I'm doing here? + // see comment in CD3D9ShaderMaterialRenderer::stubD3DXAssembleShader() + + #if ( D3DX_SDK_VERSION < 24 ) + // directly link functions, old d3d sdks didn't try to load external dlls + // when linking to the d3dx9.lib + #pragma comment (lib, "d3dx9.lib") + + // invoke static linked function + return D3DXAssembleShaderFromFile(pSrcFile, pDefines, pInclude, Flags, + ppShader, ppErrorMsgs); + #else + { + // try to load shader functions from the dll and print error if failed. + + // D3DXAssembleShaderFromFileA signature + typedef HRESULT (WINAPI *AssembleShaderFromFileFunction)(LPCSTR pSrcFile, + CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, DWORD Flags, + LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs); + + static bool LoadFailed = false; + static AssembleShaderFromFileFunction pFn = 0; + + if (!pFn && !LoadFailed) + { + // try to load dll + core::stringc strDllName = "d3dx9_"; + strDllName += (int)D3DX_SDK_VERSION; + strDllName += ".dll"; + + HMODULE hMod = LoadLibrary(strDllName.c_str()); + if (hMod) + pFn = (AssembleShaderFromFileFunction)GetProcAddress(hMod, "D3DXAssembleShaderFromFileA"); + + if (!pFn) + { + LoadFailed = true; + os::Printer::log("Could not load shader function D3DXAssembleShaderFromFileA from dll, shaders disabled", + strDllName.c_str(), ELL_ERROR); + } + } + + if (pFn) + { + // call already loaded function + return (*pFn)(pSrcFile, pDefines, pInclude, Flags, ppShader, ppErrorMsgs); + } + } + #endif // D3DX_SDK_VERSION < 24 + + return 0; +} + + +HRESULT CD3D9ShaderMaterialRenderer::stubD3DXCompileShader(LPCSTR pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, + LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable) +{ + // wondering what I'm doing here? + // see comment in CD3D9ShaderMaterialRenderer::stubD3DXAssembleShader() + + #if ( D3DX_SDK_VERSION < 24 ) + // directly link functions, old d3d sdks didn't try to load external dlls + // when linking to the d3dx9.lib + #pragma comment (lib, "d3dx9.lib") + + // invoke static linked function + return D3DXCompileShader(pSrcData, SrcDataLen, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); + #else + { + // try to load shader functions from the dll and print error if failed. + + // D3DXCompileShader + typedef HRESULT (WINAPI *D3DXCompileShaderFunction)(LPCSTR pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, + LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable); + + static bool LoadFailed = false; + static D3DXCompileShaderFunction pFn = 0; + + if (!pFn && !LoadFailed) + { + // try to load dll + core::stringc strDllName = "d3dx9_"; + strDllName += (int)D3DX_SDK_VERSION; + strDllName += ".dll"; + + HMODULE hMod = LoadLibrary(strDllName.c_str()); + if (hMod) + pFn = (D3DXCompileShaderFunction)GetProcAddress(hMod, "D3DXCompileShader"); + + if (!pFn) + { + LoadFailed = true; + os::Printer::log("Could not load shader function D3DXCompileShader from dll, shaders disabled", + strDllName.c_str(), ELL_ERROR); + } + } + + if (pFn) + { + // call already loaded function + return (*pFn)(pSrcData, SrcDataLen, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); + } + } + #endif // D3DX_SDK_VERSION < 24 + + return 0; +} + +HRESULT CD3D9ShaderMaterialRenderer::stubD3DXCompileShaderFromFile(LPCSTR pSrcFile, CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, + LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, + LPD3DXCONSTANTTABLE* ppConstantTable) +{ + // wondering what I'm doing here? + // see comment in CD3D9ShaderMaterialRenderer::stubD3DXAssembleShader() + + #if ( D3DX_SDK_VERSION < 24 ) + // directly link functions, old d3d sdks didn't try to load external dlls + // when linking to the d3dx9.lib + #pragma comment (lib, "d3dx9.lib") + + // invoke static linked function + return D3DXCompileShaderFromFile(pSrcFile, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); + #else + { + // try to load shader functions from the dll and print error if failed. + + // D3DXCompileShaderFromFileA + typedef HRESULT (WINAPI *D3DXCompileShaderFromFileFunction)(LPCSTR pSrcFile, + CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, + LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, + LPD3DXCONSTANTTABLE* ppConstantTable); + + static bool LoadFailed = false; + static D3DXCompileShaderFromFileFunction pFn = 0; + + if (!pFn && !LoadFailed) + { + // try to load dll + core::stringc strDllName = "d3dx9_"; + strDllName += (int)D3DX_SDK_VERSION; + strDllName += ".dll"; + + HMODULE hMod = LoadLibrary(strDllName.c_str()); + if (hMod) + pFn = (D3DXCompileShaderFromFileFunction)GetProcAddress(hMod, "D3DXCompileShaderFromFileA"); + + if (!pFn) + { + LoadFailed = true; + os::Printer::log("Could not load shader function D3DXCompileShaderFromFileA from dll, shaders disabled", + strDllName.c_str(), ELL_ERROR); + } + } + + if (pFn) + { + // call already loaded function + return (*pFn)(pSrcFile, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); + } + } + #endif // D3DX_SDK_VERSION < 24 + + return 0; +} + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CD3D9ShaderMaterialRenderer.h b/src/dep/src/irrlicht/CD3D9ShaderMaterialRenderer.h index 4955f42..d8bd275 100644 --- a/src/dep/src/irrlicht/CD3D9ShaderMaterialRenderer.h +++ b/src/dep/src/irrlicht/CD3D9ShaderMaterialRenderer.h @@ -1,100 +1,100 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D9_SHADER_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D9_SHADER_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ -#include "d3d9.h" -#include "d3dx9shader.h" - -#include "IMaterialRenderer.h" - -namespace irr -{ -namespace video -{ - -class IVideoDriver; -class IShaderConstantSetCallBack; -class IMaterialRenderer; - -//! Class for using vertex and pixel shaders with D3D9 -class CD3D9ShaderMaterialRenderer : public IMaterialRenderer -{ -public: - - //! Public constructor - CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData); - - //! Destructor - ~CD3D9ShaderMaterialRenderer(); - - virtual void OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services); - - virtual void OnUnsetMaterial(); - - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - //! Returns if the material is transparent. - virtual bool isTransparent(); - -protected: - - //! constructor only for use by derived classes who want to - //! create a fall back material for example. - CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev, - video::IVideoDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, s32 userData=0); - - - void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram); - bool createPixelShader(const c8* pxsh); - bool createVertexShader(const char* vtxsh); - - HRESULT stubD3DXAssembleShader(LPCSTR pSrcData, UINT SrcDataLen, - CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - DWORD Flags, LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs); - - HRESULT stubD3DXAssembleShaderFromFile(LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, DWORD Flags, - LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs); - - HRESULT stubD3DXCompileShader(LPCSTR pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, - LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable); - - HRESULT stubD3DXCompileShaderFromFile(LPCSTR pSrcFile, CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, - LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable); - - IDirect3DDevice9* pID3DDevice; - video::IVideoDriver* Driver; - IShaderConstantSetCallBack* CallBack; - IMaterialRenderer* BaseMaterial; - - IDirect3DVertexShader9* VertexShader; - IDirect3DVertexShader9* OldVertexShader; - IDirect3DPixelShader9* PixelShader; - s32 UserData; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_D3D9_SHADER_MATERIAL_RENDERER_H_INCLUDED__ +#define __C_D3D9_SHADER_MATERIAL_RENDERER_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_WINDOWS_ + +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ +#include "d3d9.h" +#include "d3dx9shader.h" + +#include "IMaterialRenderer.h" + +namespace irr +{ +namespace video +{ + +class IVideoDriver; +class IShaderConstantSetCallBack; +class IMaterialRenderer; + +//! Class for using vertex and pixel shaders with D3D9 +class CD3D9ShaderMaterialRenderer : public IMaterialRenderer +{ +public: + + //! Public constructor + CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, + s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, + IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData); + + //! Destructor + ~CD3D9ShaderMaterialRenderer(); + + virtual void OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, + bool resetAllRenderstates, video::IMaterialRendererServices* services); + + virtual void OnUnsetMaterial(); + + virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); + + //! Returns if the material is transparent. + virtual bool isTransparent(); + +protected: + + //! constructor only for use by derived classes who want to + //! create a fall back material for example. + CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev, + video::IVideoDriver* driver, + IShaderConstantSetCallBack* callback, + IMaterialRenderer* baseMaterial, s32 userData=0); + + + void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram); + bool createPixelShader(const c8* pxsh); + bool createVertexShader(const char* vtxsh); + + HRESULT stubD3DXAssembleShader(LPCSTR pSrcData, UINT SrcDataLen, + CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, + DWORD Flags, LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs); + + HRESULT stubD3DXAssembleShaderFromFile(LPCSTR pSrcFile, + CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, DWORD Flags, + LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs); + + HRESULT stubD3DXCompileShader(LPCSTR pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, + LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable); + + HRESULT stubD3DXCompileShaderFromFile(LPCSTR pSrcFile, CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, + LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, + LPD3DXCONSTANTTABLE* ppConstantTable); + + IDirect3DDevice9* pID3DDevice; + video::IVideoDriver* Driver; + IShaderConstantSetCallBack* CallBack; + IMaterialRenderer* BaseMaterial; + + IDirect3DVertexShader9* VertexShader; + IDirect3DVertexShader9* OldVertexShader; + IDirect3DPixelShader9* PixelShader; + s32 UserData; +}; + + +} // end namespace video +} // end namespace irr + +#endif +#endif +#endif + diff --git a/src/dep/src/irrlicht/CD3D9Texture.cpp b/src/dep/src/irrlicht/CD3D9Texture.cpp index 6627b0a..d053ccc 100644 --- a/src/dep/src/irrlicht/CD3D9Texture.cpp +++ b/src/dep/src/irrlicht/CD3D9Texture.cpp @@ -1,814 +1,814 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - -#define _IRR_DONT_DO_MEMORY_DEBUGGING_HERE -#include "CD3D9Texture.h" -#include "CD3D9Driver.h" -#include "os.h" - -#include "d3dx9tex.h" - -#ifndef _IRR_COMPILE_WITH_DIRECT3D_8_ -// The D3DXFilterTexture function seems to get linked wrong when -// compiling with both D3D8 and 9, causing it not to work in the D3D9 device. -// So mipmapgeneration is replaced with my own bad generation in d3d 8 when -// compiling with both D3D 8 and 9. -// #define _IRR_USE_D3DXFilterTexture_ -#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ - -#ifdef _IRR_USE_D3DXFilterTexture_ -#pragma comment(lib, "d3dx9.lib") -#endif - -namespace irr -{ -namespace video -{ - -//! rendertarget constructor -CD3D9Texture::CD3D9Texture(CD3D9Driver* driver, core::dimension2d size, const char* name) -: ITexture(name), Image(0), Texture(0), RTTSurface(0), Driver(driver), - TextureSize(size), ImageSize(size), Pitch(0), SurfaceHasSameSize(true), - HasMipMaps(false), HardwareMipMaps(false), IsRenderTarget(true) -{ - #ifdef _DEBUG - setDebugName("CD3D9Texture"); - #endif - - Device=driver->getExposedVideoData().D3D9.D3DDev9; - if (Device) - Device->AddRef(); - - createRenderTarget(); -} - - -//! constructor -CD3D9Texture::CD3D9Texture(IImage* image, CD3D9Driver* driver, - u32 flags, const char* name) -: ITexture(name), Image(image), Texture(0), RTTSurface(0), Driver(driver), -TextureSize(0,0), ImageSize(0,0), Pitch(0), SurfaceHasSameSize(true), -HasMipMaps(false), HardwareMipMaps(false), IsRenderTarget(false) -{ - #ifdef _DEBUG - setDebugName("CD3D9Texture"); - #endif - - bool generateMipLevels = (flags & video::ETCF_CREATE_MIP_MAPS) != 0; - - Device=driver->getExposedVideoData().D3D9.D3DDev9; - if (Device) - Device->AddRef(); - - if (Image) - { - Image->grab(); - - createTexture(flags); - - if (Texture) - { - if (copyTexture() && generateMipLevels) - { - // create mip maps. - #ifdef _IRR_USE_D3DXFilterTexture_ - // The D3DXFilterTexture function seems to get linked wrong when - // compiling with both D3D8 and 9, causing it not to work in the D3D9 device. - // So mipmapgeneration is replaced with my own bad generation in d3d 8 when - // compiling with both D3D 8 and 9. - HRESULT hr = D3DXFilterTexture(Texture, NULL, D3DX_DEFAULT, D3DX_DEFAULT); - if (FAILED(hr)) - os::Printer::log("Could not create direct3d mip map levels.", ELL_WARNING); - else - HasMipMaps = true; - #else - createMipMaps(); - HasMipMaps = true; - #endif - } - } - else - os::Printer::log("Could not create DIRECT3D9 Texture.", ELL_WARNING); - } -} - - -void CD3D9Texture::createRenderTarget() -{ - TextureSize.Width = getTextureSizeFromImageSize(TextureSize.Width); - TextureSize.Height = getTextureSizeFromImageSize(TextureSize.Height); - - // get backbuffer format to create the render target in the - // same format - - IDirect3DSurface9* bb; - D3DFORMAT d3DFormat = D3DFMT_A8R8G8B8; - - if (!FAILED(Device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &bb))) - { - D3DSURFACE_DESC desc; - bb->GetDesc(&desc); - d3DFormat = desc.Format; - - if (d3DFormat == D3DFMT_X8R8G8B8) - d3DFormat = D3DFMT_A8R8G8B8; - - bb->Release(); - } - else - { - os::Printer::log("Could not create RenderTarget texture: could not get BackBuffer.", - ELL_WARNING); - return; - } - - // create texture - HRESULT hr; - - hr = Device->CreateTexture( - TextureSize.Width, - TextureSize.Height, - 1, // mip map level count, we don't want mipmaps here - D3DUSAGE_RENDERTARGET, - d3DFormat, - D3DPOOL_DEFAULT, - &Texture, - NULL); - - // get irrlicht format from D3D format - - switch(d3DFormat) - { - case D3DFMT_X1R5G5B5: - case D3DFMT_A1R5G5B5: - ColorFormat = ECF_A1R5G5B5; - break; - case D3DFMT_A8B8G8R8: - case D3DFMT_A8R8G8B8: - case D3DFMT_X8R8G8B8: - ColorFormat = ECF_A8R8G8B8; - break; - case D3DFMT_R5G6B5: - ColorFormat = ECF_R5G6B5; - break; - default: - ColorFormat = (ECOLOR_FORMAT)-1; - }; - - if (FAILED(hr)) - os::Printer::log("Could not create render target texture"); -} - - -bool CD3D9Texture::createMipMaps(s32 level) -{ - if (HardwareMipMaps && Texture) - { - // generate mipmaps in hardware - - Texture->GenerateMipSubLevels(); - return true; - } - //os::Printer::log("manual mipmap"); - - // The D3DXFilterTexture function seems to get linked wrong when - // compiling with both D3D8 and 9, causing it not to work in the D3D9 device. - // So mipmapgeneration is replaced with my own bad generation here when - // compiling with both D3D 8 and 9. - - IDirect3DSurface9* upperSurface = 0; - IDirect3DSurface9* lowerSurface = 0; - - // get upper level - HRESULT hr = Texture->GetSurfaceLevel(level-1, &upperSurface); - if (FAILED(hr) || !upperSurface) - { - os::Printer::log("Could not get upper surface level for mip map generation", ELL_WARNING); - return false; - } - - // get lower level - hr = Texture->GetSurfaceLevel(level, &lowerSurface); - if (FAILED(hr) || !lowerSurface) - { - os::Printer::log("Could not get lower surface level for mip map generation", ELL_WARNING); - upperSurface->Release(); - return false; - } - - D3DSURFACE_DESC upperDesc, lowerDesc; - upperSurface->GetDesc(&upperDesc); - lowerSurface->GetDesc(&lowerDesc); - - - D3DLOCKED_RECT upperlr; - D3DLOCKED_RECT lowerlr; - - // lock upper surface - if (FAILED(upperSurface->LockRect(&upperlr, NULL, 0))) - { - os::Printer::log("Could not lock upper texture for mip map generation", ELL_WARNING); - return false; - } - - // lock lower surface - if (FAILED(lowerSurface->LockRect(&lowerlr, NULL, 0))) - { - os::Printer::log("Could not lock lower texture for mip map generation", ELL_WARNING); - return false; - } - - if (upperDesc.Format != lowerDesc.Format) - { - os::Printer::log("Cannot copy mip maps with different formats.", ELL_WARNING); - } - else - { - if (upperDesc.Format == D3DFMT_A1R5G5B5) - copy16BitMipMap((char*)upperlr.pBits, (char*)lowerlr.pBits, - lowerDesc.Width, lowerDesc.Height, - upperlr.Pitch, lowerlr.Pitch); - else - if (upperDesc.Format == D3DFMT_A8R8G8B8) - copy32BitMipMap((char*)upperlr.pBits, (char*)lowerlr.pBits, - lowerDesc.Width, lowerDesc.Height, - upperlr.Pitch, lowerlr.Pitch); - else - os::Printer::log("Unsupported mipmap format, cannot copy.", ELL_WARNING); - } - - // unlock - if (FAILED(upperSurface->UnlockRect())) - return false; - if (FAILED(lowerSurface->UnlockRect())) - return false; - - // release - upperSurface->Release(); - lowerSurface->Release(); - - if (upperDesc.Width <= 2 || upperDesc.Height <= 2) - return true; // stop generating levels - - // generate next level - return createMipMaps(level+1); -} - - -//! creates the hardware texture -void CD3D9Texture::createTexture(u32 flags) -{ - core::dimension2d optSize; - ImageSize = Image->getDimension(); - - if (Driver->queryFeature(EVDF_TEXTURE_NPOT)) - optSize=ImageSize; - else - { - optSize.Width = getTextureSizeFromImageSize(ImageSize.Width); - optSize.Height = getTextureSizeFromImageSize(ImageSize.Height); - } - - HRESULT hr; - D3DFORMAT format = D3DFMT_A1R5G5B5; - - switch(getTextureFormatFromFlags(flags)) - { - case ETCF_ALWAYS_16_BIT: - format = D3DFMT_A1R5G5B5; break; - case ETCF_ALWAYS_32_BIT: - format = D3DFMT_A8R8G8B8; break; - case ETCF_OPTIMIZED_FOR_QUALITY: - { - switch(Image->getColorFormat()) - { - case ECF_R8G8B8: - case ECF_A8R8G8B8: - format = D3DFMT_A8R8G8B8; break; - case ECF_A1R5G5B5: - case ECF_R5G6B5: - format = D3DFMT_A1R5G5B5; break; - } - } - break; - case ETCF_OPTIMIZED_FOR_SPEED: - format = D3DFMT_A1R5G5B5; break; - } - - bool mipmaps = (flags & video::ETCF_CREATE_MIP_MAPS) != 0; - - DWORD usage = 0; - - // This enables hardware mip map generation. Disabled because - // some cards or drivers seem to have problems with this. - // D3DCAPS9 caps; - // Device->GetDeviceCaps(&caps); - // if (caps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP) - // { - // usage = D3DUSAGE_AUTOGENMIPMAP; - // HardwareMipMaps = true; - //} - - hr = Device->CreateTexture(optSize.Width, optSize.Height, - mipmaps ? 0 : 1, // number of mipmaplevels (0 = automatic all) - usage, // usage - format, D3DPOOL_MANAGED , &Texture, NULL); - - if (FAILED(hr) && format == D3DFMT_A8R8G8B8) - { - // try brute force 16 bit - - format = D3DFMT_A1R5G5B5; - - hr = Device->CreateTexture(optSize.Width, optSize.Height, - (flags & ETCF_CREATE_MIP_MAPS) ? 0 : 1, // number of mipmaplevels (0 = automatic all) - 0, D3DFMT_A1R5G5B5, D3DPOOL_MANAGED, &Texture, NULL); - } - - ColorFormat = (format == D3DFMT_A1R5G5B5) ? ECF_A1R5G5B5 : ECF_A8R8G8B8; -} - - - -//! copies the image to the texture -bool CD3D9Texture::copyTexture() -{ - if (Texture && Image) - { - D3DSURFACE_DESC desc; - Texture->GetLevelDesc(0, &desc); - - TextureSize.Width = desc.Width; - TextureSize.Height = desc.Height; - - SurfaceHasSameSize = (TextureSize == ImageSize); - - if (desc.Format == D3DFMT_A1R5G5B5) - return copyTo16BitTexture(); - else - if (desc.Format == D3DFMT_A8R8G8B8) - return copyTo32BitTexture(); - else - os::Printer::log("CD3D9Texture: Unsupported D3D9 hardware texture format", ELL_ERROR); - } - - return true; -} - - -//! copies texture to 32 bit hardware texture -bool CD3D9Texture::copyTo32BitTexture() -{ - D3DLOCKED_RECT rect; - HRESULT hr = Texture->LockRect(0, &rect, 0, 0); - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D9 32 bit Texture.", ELL_ERROR); - return false; - } - - s32* dest = (s32*)rect.pBits; - s32* source = (s32*)Image->lock(); - Pitch = rect.Pitch; - s32 pitch = rect.Pitch / 4; - - if (SurfaceHasSameSize) - { - if (Image->getColorFormat() == ECF_A8R8G8B8) - { - // direct copy, fast - - for (s32 y=0; ygetPixel(x,y).color; - } - } - else - { - // scale texture - - f32 sourceXStep = (f32)ImageSize.Width / (f32)TextureSize.Width; - f32 sourceYStep = (f32)ImageSize.Height / (f32)TextureSize.Height; - f32 sy; - - if (Image->getColorFormat() == ECF_A8R8G8B8) - { - // copy texture scaling - - for (s32 x=0; xgetPixel((s32)(x*sourceXStep), (s32)sy).color; - - sy+=sourceYStep; - } - } - } - } - - Image->unlock(); - - hr = Texture->UnlockRect(0); - if (FAILED(hr)) - { - os::Printer::log("Could not unlock DIRECT3D9 Texture.", ELL_ERROR); - return false; - } - - return true; - -} - - -//! optimized for 16 bit to 16 copy. -bool CD3D9Texture::copyTo16BitTexture() -{ - D3DLOCKED_RECT rect; - HRESULT hr = Texture->LockRect(0, &rect, 0, 0); - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D9 16 bit Texture.", ELL_ERROR); - return false; - } - - s16* dest = (s16*)rect.pBits; - s16* source = (s16*)Image->lock(); - Pitch = rect.Pitch; - s32 pitch = rect.Pitch/2; - - if (SurfaceHasSameSize) - { - // copy texture - - if (Image->getColorFormat() == ECF_A1R5G5B5) - { - // direct copy, fast - - for (s32 y=0; ygetPixel(x,y).toA1R5G5B5(); - } - } - else - { - // scale texture - - f32 sourceXStep = (f32)ImageSize.Width / (f32)TextureSize.Width; - f32 sourceYStep = (f32)ImageSize.Height / (f32)TextureSize.Height; - f32 sy; - - if (Image->getColorFormat() == ECF_A1R5G5B5) - { - // copy texture scaling - - for (s32 x=0; xgetPixel((s32)(x*sourceXStep), (s32)sy).toA1R5G5B5(); - - sy+=sourceYStep; - } - } - } - } - - Image->unlock(); - - hr = Texture->UnlockRect(0); - if (FAILED(hr)) - { - os::Printer::log("Could not unlock DIRECT3D9 16 bit Texture.", ELL_ERROR); - return false; - } - - return true; -} - - - -//! destructor -CD3D9Texture::~CD3D9Texture() -{ - if (Device) - Device->Release(); - - if (Image) - Image->drop(); - - if (Texture) - Texture->Release(); - - if (RTTSurface) - RTTSurface->Release(); -} - - - -//! lock function -void* CD3D9Texture::lock() -{ - if (!Texture) - return 0; - - HRESULT hr; - D3DLOCKED_RECT rect; - if(!IsRenderTarget) - { - hr = Texture->LockRect(0, &rect, 0, 0); - } - else - { - D3DSURFACE_DESC desc; - Texture->GetLevelDesc(0, &desc); - if (!RTTSurface) - { - hr = Device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &RTTSurface, NULL); - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR); - return 0; - } - } - - IDirect3DSurface9 *surface = NULL; - hr = Texture->GetSurfaceLevel(0, &surface); - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR); - return 0; - } - hr = Device->GetRenderTargetData(surface, RTTSurface); - if(FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR); - return 0; - } - hr = RTTSurface->LockRect(&rect, NULL, 0); - if(FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR); - return 0; - } - return rect.pBits; - } - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR); - return 0; - } - - return rect.pBits; -} - - - -//! unlock function -void CD3D9Texture::unlock() -{ - if (!Texture) - return; - - if (!IsRenderTarget) - Texture->UnlockRect(0); - else if (RTTSurface) - RTTSurface->UnlockRect(); -} - - -//! Returns original size of the texture. -const core::dimension2d& CD3D9Texture::getOriginalSize() -{ - return ImageSize; -} - - -//! Returns (=size) of the texture. -const core::dimension2d& CD3D9Texture::getSize() -{ - return TextureSize; -} - - -//! returns the size of a texture which would be the optimize size for rendering it -inline s32 CD3D9Texture::getTextureSizeFromImageSize(s32 size) -{ - s32 ts = 0x01; - - while(ts < size) - ts <<= 1; - - if (ts > size && ts > 64) - ts >>= 1; - - return ts; -} - - - -//! returns driver type of texture (=the driver, who created the texture) -E_DRIVER_TYPE CD3D9Texture::getDriverType() -{ - return EDT_DIRECT3D9; -} - - - -//! returns color format of texture -ECOLOR_FORMAT CD3D9Texture::getColorFormat() const -{ - return ColorFormat; -} - - - -//! returns pitch of texture (in bytes) -u32 CD3D9Texture::getPitch() const -{ - return Pitch; -} - - - -//! returns the DIRECT3D9 Texture -IDirect3DTexture9* CD3D9Texture::getDX9Texture() -{ - return Texture; -} - - -//! returns if texture has mipmap levels -bool CD3D9Texture::hasMipMaps() -{ - return HasMipMaps; -} - - -void CD3D9Texture::copy16BitMipMap(char* src, char* tgt, - s32 width, s32 height, - s32 pitchsrc, s32 pitchtgt) -{ - u16 c; - - for (int x=0; x>= 2; - r >>= 2; - g >>= 2; - b >>= 2; - - c = ((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff); - *(u32*)((void*)&tgt[(x*4)+(y*pitchtgt)]) = c.color; - } - } -} - - -//! Regenerates the mip map levels of the texture. Useful after locking and -//! modifying the texture -void CD3D9Texture::regenerateMipMapLevels() -{ - if (HasMipMaps) - createMipMaps(); -} - - -//! returns if it is a render target -bool CD3D9Texture::isRenderTarget() -{ - return IsRenderTarget; -} - -//! Returns pointer to the render target surface -IDirect3DSurface9* CD3D9Texture::getRenderTargetSurface() -{ - if (!IsRenderTarget) - return 0; - - IDirect3DSurface9 *pRTTSurface = 0; - if (Texture) - Texture->GetSurfaceLevel(0, &pRTTSurface); - - if (pRTTSurface) - pRTTSurface->Release(); - - return pRTTSurface; -} - - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + +#define _IRR_DONT_DO_MEMORY_DEBUGGING_HERE +#include "CD3D9Texture.h" +#include "CD3D9Driver.h" +#include "os.h" + +#include "d3dx9tex.h" + +#ifndef _IRR_COMPILE_WITH_DIRECT3D_8_ +// The D3DXFilterTexture function seems to get linked wrong when +// compiling with both D3D8 and 9, causing it not to work in the D3D9 device. +// So mipmapgeneration is replaced with my own bad generation in d3d 8 when +// compiling with both D3D 8 and 9. +// #define _IRR_USE_D3DXFilterTexture_ +#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ + +#ifdef _IRR_USE_D3DXFilterTexture_ +#pragma comment(lib, "d3dx9.lib") +#endif + +namespace irr +{ +namespace video +{ + +//! rendertarget constructor +CD3D9Texture::CD3D9Texture(CD3D9Driver* driver, core::dimension2d size, const char* name) +: ITexture(name), Image(0), Texture(0), RTTSurface(0), Driver(driver), + TextureSize(size), ImageSize(size), Pitch(0), SurfaceHasSameSize(true), + HasMipMaps(false), HardwareMipMaps(false), IsRenderTarget(true) +{ + #ifdef _DEBUG + setDebugName("CD3D9Texture"); + #endif + + Device=driver->getExposedVideoData().D3D9.D3DDev9; + if (Device) + Device->AddRef(); + + createRenderTarget(); +} + + +//! constructor +CD3D9Texture::CD3D9Texture(IImage* image, CD3D9Driver* driver, + u32 flags, const char* name) +: ITexture(name), Image(image), Texture(0), RTTSurface(0), Driver(driver), +TextureSize(0,0), ImageSize(0,0), Pitch(0), SurfaceHasSameSize(true), +HasMipMaps(false), HardwareMipMaps(false), IsRenderTarget(false) +{ + #ifdef _DEBUG + setDebugName("CD3D9Texture"); + #endif + + bool generateMipLevels = (flags & video::ETCF_CREATE_MIP_MAPS) != 0; + + Device=driver->getExposedVideoData().D3D9.D3DDev9; + if (Device) + Device->AddRef(); + + if (Image) + { + Image->grab(); + + createTexture(flags); + + if (Texture) + { + if (copyTexture() && generateMipLevels) + { + // create mip maps. + #ifdef _IRR_USE_D3DXFilterTexture_ + // The D3DXFilterTexture function seems to get linked wrong when + // compiling with both D3D8 and 9, causing it not to work in the D3D9 device. + // So mipmapgeneration is replaced with my own bad generation in d3d 8 when + // compiling with both D3D 8 and 9. + HRESULT hr = D3DXFilterTexture(Texture, NULL, D3DX_DEFAULT, D3DX_DEFAULT); + if (FAILED(hr)) + os::Printer::log("Could not create direct3d mip map levels.", ELL_WARNING); + else + HasMipMaps = true; + #else + createMipMaps(); + HasMipMaps = true; + #endif + } + } + else + os::Printer::log("Could not create DIRECT3D9 Texture.", ELL_WARNING); + } +} + + +void CD3D9Texture::createRenderTarget() +{ + TextureSize.Width = getTextureSizeFromImageSize(TextureSize.Width); + TextureSize.Height = getTextureSizeFromImageSize(TextureSize.Height); + + // get backbuffer format to create the render target in the + // same format + + IDirect3DSurface9* bb; + D3DFORMAT d3DFormat = D3DFMT_A8R8G8B8; + + if (!FAILED(Device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &bb))) + { + D3DSURFACE_DESC desc; + bb->GetDesc(&desc); + d3DFormat = desc.Format; + + if (d3DFormat == D3DFMT_X8R8G8B8) + d3DFormat = D3DFMT_A8R8G8B8; + + bb->Release(); + } + else + { + os::Printer::log("Could not create RenderTarget texture: could not get BackBuffer.", + ELL_WARNING); + return; + } + + // create texture + HRESULT hr; + + hr = Device->CreateTexture( + TextureSize.Width, + TextureSize.Height, + 1, // mip map level count, we don't want mipmaps here + D3DUSAGE_RENDERTARGET, + d3DFormat, + D3DPOOL_DEFAULT, + &Texture, + NULL); + + // get irrlicht format from D3D format + + switch(d3DFormat) + { + case D3DFMT_X1R5G5B5: + case D3DFMT_A1R5G5B5: + ColorFormat = ECF_A1R5G5B5; + break; + case D3DFMT_A8B8G8R8: + case D3DFMT_A8R8G8B8: + case D3DFMT_X8R8G8B8: + ColorFormat = ECF_A8R8G8B8; + break; + case D3DFMT_R5G6B5: + ColorFormat = ECF_R5G6B5; + break; + default: + ColorFormat = (ECOLOR_FORMAT)-1; + }; + + if (FAILED(hr)) + os::Printer::log("Could not create render target texture"); +} + + +bool CD3D9Texture::createMipMaps(s32 level) +{ + if (HardwareMipMaps && Texture) + { + // generate mipmaps in hardware + + Texture->GenerateMipSubLevels(); + return true; + } + //os::Printer::log("manual mipmap"); + + // The D3DXFilterTexture function seems to get linked wrong when + // compiling with both D3D8 and 9, causing it not to work in the D3D9 device. + // So mipmapgeneration is replaced with my own bad generation here when + // compiling with both D3D 8 and 9. + + IDirect3DSurface9* upperSurface = 0; + IDirect3DSurface9* lowerSurface = 0; + + // get upper level + HRESULT hr = Texture->GetSurfaceLevel(level-1, &upperSurface); + if (FAILED(hr) || !upperSurface) + { + os::Printer::log("Could not get upper surface level for mip map generation", ELL_WARNING); + return false; + } + + // get lower level + hr = Texture->GetSurfaceLevel(level, &lowerSurface); + if (FAILED(hr) || !lowerSurface) + { + os::Printer::log("Could not get lower surface level for mip map generation", ELL_WARNING); + upperSurface->Release(); + return false; + } + + D3DSURFACE_DESC upperDesc, lowerDesc; + upperSurface->GetDesc(&upperDesc); + lowerSurface->GetDesc(&lowerDesc); + + + D3DLOCKED_RECT upperlr; + D3DLOCKED_RECT lowerlr; + + // lock upper surface + if (FAILED(upperSurface->LockRect(&upperlr, NULL, 0))) + { + os::Printer::log("Could not lock upper texture for mip map generation", ELL_WARNING); + return false; + } + + // lock lower surface + if (FAILED(lowerSurface->LockRect(&lowerlr, NULL, 0))) + { + os::Printer::log("Could not lock lower texture for mip map generation", ELL_WARNING); + return false; + } + + if (upperDesc.Format != lowerDesc.Format) + { + os::Printer::log("Cannot copy mip maps with different formats.", ELL_WARNING); + } + else + { + if (upperDesc.Format == D3DFMT_A1R5G5B5) + copy16BitMipMap((char*)upperlr.pBits, (char*)lowerlr.pBits, + lowerDesc.Width, lowerDesc.Height, + upperlr.Pitch, lowerlr.Pitch); + else + if (upperDesc.Format == D3DFMT_A8R8G8B8) + copy32BitMipMap((char*)upperlr.pBits, (char*)lowerlr.pBits, + lowerDesc.Width, lowerDesc.Height, + upperlr.Pitch, lowerlr.Pitch); + else + os::Printer::log("Unsupported mipmap format, cannot copy.", ELL_WARNING); + } + + // unlock + if (FAILED(upperSurface->UnlockRect())) + return false; + if (FAILED(lowerSurface->UnlockRect())) + return false; + + // release + upperSurface->Release(); + lowerSurface->Release(); + + if (upperDesc.Width <= 2 || upperDesc.Height <= 2) + return true; // stop generating levels + + // generate next level + return createMipMaps(level+1); +} + + +//! creates the hardware texture +void CD3D9Texture::createTexture(u32 flags) +{ + core::dimension2d optSize; + ImageSize = Image->getDimension(); + + if (Driver->queryFeature(EVDF_TEXTURE_NPOT)) + optSize=ImageSize; + else + { + optSize.Width = getTextureSizeFromImageSize(ImageSize.Width); + optSize.Height = getTextureSizeFromImageSize(ImageSize.Height); + } + + HRESULT hr; + D3DFORMAT format = D3DFMT_A1R5G5B5; + + switch(getTextureFormatFromFlags(flags)) + { + case ETCF_ALWAYS_16_BIT: + format = D3DFMT_A1R5G5B5; break; + case ETCF_ALWAYS_32_BIT: + format = D3DFMT_A8R8G8B8; break; + case ETCF_OPTIMIZED_FOR_QUALITY: + { + switch(Image->getColorFormat()) + { + case ECF_R8G8B8: + case ECF_A8R8G8B8: + format = D3DFMT_A8R8G8B8; break; + case ECF_A1R5G5B5: + case ECF_R5G6B5: + format = D3DFMT_A1R5G5B5; break; + } + } + break; + case ETCF_OPTIMIZED_FOR_SPEED: + format = D3DFMT_A1R5G5B5; break; + } + + bool mipmaps = (flags & video::ETCF_CREATE_MIP_MAPS) != 0; + + DWORD usage = 0; + + // This enables hardware mip map generation. Disabled because + // some cards or drivers seem to have problems with this. + // D3DCAPS9 caps; + // Device->GetDeviceCaps(&caps); + // if (caps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP) + // { + // usage = D3DUSAGE_AUTOGENMIPMAP; + // HardwareMipMaps = true; + //} + + hr = Device->CreateTexture(optSize.Width, optSize.Height, + mipmaps ? 0 : 1, // number of mipmaplevels (0 = automatic all) + usage, // usage + format, D3DPOOL_MANAGED , &Texture, NULL); + + if (FAILED(hr) && format == D3DFMT_A8R8G8B8) + { + // try brute force 16 bit + + format = D3DFMT_A1R5G5B5; + + hr = Device->CreateTexture(optSize.Width, optSize.Height, + (flags & ETCF_CREATE_MIP_MAPS) ? 0 : 1, // number of mipmaplevels (0 = automatic all) + 0, D3DFMT_A1R5G5B5, D3DPOOL_MANAGED, &Texture, NULL); + } + + ColorFormat = (format == D3DFMT_A1R5G5B5) ? ECF_A1R5G5B5 : ECF_A8R8G8B8; +} + + + +//! copies the image to the texture +bool CD3D9Texture::copyTexture() +{ + if (Texture && Image) + { + D3DSURFACE_DESC desc; + Texture->GetLevelDesc(0, &desc); + + TextureSize.Width = desc.Width; + TextureSize.Height = desc.Height; + + SurfaceHasSameSize = (TextureSize == ImageSize); + + if (desc.Format == D3DFMT_A1R5G5B5) + return copyTo16BitTexture(); + else + if (desc.Format == D3DFMT_A8R8G8B8) + return copyTo32BitTexture(); + else + os::Printer::log("CD3D9Texture: Unsupported D3D9 hardware texture format", ELL_ERROR); + } + + return true; +} + + +//! copies texture to 32 bit hardware texture +bool CD3D9Texture::copyTo32BitTexture() +{ + D3DLOCKED_RECT rect; + HRESULT hr = Texture->LockRect(0, &rect, 0, 0); + if (FAILED(hr)) + { + os::Printer::log("Could not lock DIRECT3D9 32 bit Texture.", ELL_ERROR); + return false; + } + + s32* dest = (s32*)rect.pBits; + s32* source = (s32*)Image->lock(); + Pitch = rect.Pitch; + s32 pitch = rect.Pitch / 4; + + if (SurfaceHasSameSize) + { + if (Image->getColorFormat() == ECF_A8R8G8B8) + { + // direct copy, fast + + for (s32 y=0; ygetPixel(x,y).color; + } + } + else + { + // scale texture + + f32 sourceXStep = (f32)ImageSize.Width / (f32)TextureSize.Width; + f32 sourceYStep = (f32)ImageSize.Height / (f32)TextureSize.Height; + f32 sy; + + if (Image->getColorFormat() == ECF_A8R8G8B8) + { + // copy texture scaling + + for (s32 x=0; xgetPixel((s32)(x*sourceXStep), (s32)sy).color; + + sy+=sourceYStep; + } + } + } + } + + Image->unlock(); + + hr = Texture->UnlockRect(0); + if (FAILED(hr)) + { + os::Printer::log("Could not unlock DIRECT3D9 Texture.", ELL_ERROR); + return false; + } + + return true; + +} + + +//! optimized for 16 bit to 16 copy. +bool CD3D9Texture::copyTo16BitTexture() +{ + D3DLOCKED_RECT rect; + HRESULT hr = Texture->LockRect(0, &rect, 0, 0); + if (FAILED(hr)) + { + os::Printer::log("Could not lock DIRECT3D9 16 bit Texture.", ELL_ERROR); + return false; + } + + s16* dest = (s16*)rect.pBits; + s16* source = (s16*)Image->lock(); + Pitch = rect.Pitch; + s32 pitch = rect.Pitch/2; + + if (SurfaceHasSameSize) + { + // copy texture + + if (Image->getColorFormat() == ECF_A1R5G5B5) + { + // direct copy, fast + + for (s32 y=0; ygetPixel(x,y).toA1R5G5B5(); + } + } + else + { + // scale texture + + f32 sourceXStep = (f32)ImageSize.Width / (f32)TextureSize.Width; + f32 sourceYStep = (f32)ImageSize.Height / (f32)TextureSize.Height; + f32 sy; + + if (Image->getColorFormat() == ECF_A1R5G5B5) + { + // copy texture scaling + + for (s32 x=0; xgetPixel((s32)(x*sourceXStep), (s32)sy).toA1R5G5B5(); + + sy+=sourceYStep; + } + } + } + } + + Image->unlock(); + + hr = Texture->UnlockRect(0); + if (FAILED(hr)) + { + os::Printer::log("Could not unlock DIRECT3D9 16 bit Texture.", ELL_ERROR); + return false; + } + + return true; +} + + + +//! destructor +CD3D9Texture::~CD3D9Texture() +{ + if (Device) + Device->Release(); + + if (Image) + Image->drop(); + + if (Texture) + Texture->Release(); + + if (RTTSurface) + RTTSurface->Release(); +} + + + +//! lock function +void* CD3D9Texture::lock() +{ + if (!Texture) + return 0; + + HRESULT hr; + D3DLOCKED_RECT rect; + if(!IsRenderTarget) + { + hr = Texture->LockRect(0, &rect, 0, 0); + } + else + { + D3DSURFACE_DESC desc; + Texture->GetLevelDesc(0, &desc); + if (!RTTSurface) + { + hr = Device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &RTTSurface, NULL); + if (FAILED(hr)) + { + os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR); + return 0; + } + } + + IDirect3DSurface9 *surface = NULL; + hr = Texture->GetSurfaceLevel(0, &surface); + if (FAILED(hr)) + { + os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR); + return 0; + } + hr = Device->GetRenderTargetData(surface, RTTSurface); + if(FAILED(hr)) + { + os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR); + return 0; + } + hr = RTTSurface->LockRect(&rect, NULL, 0); + if(FAILED(hr)) + { + os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR); + return 0; + } + return rect.pBits; + } + if (FAILED(hr)) + { + os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR); + return 0; + } + + return rect.pBits; +} + + + +//! unlock function +void CD3D9Texture::unlock() +{ + if (!Texture) + return; + + if (!IsRenderTarget) + Texture->UnlockRect(0); + else if (RTTSurface) + RTTSurface->UnlockRect(); +} + + +//! Returns original size of the texture. +const core::dimension2d& CD3D9Texture::getOriginalSize() +{ + return ImageSize; +} + + +//! Returns (=size) of the texture. +const core::dimension2d& CD3D9Texture::getSize() +{ + return TextureSize; +} + + +//! returns the size of a texture which would be the optimize size for rendering it +inline s32 CD3D9Texture::getTextureSizeFromImageSize(s32 size) +{ + s32 ts = 0x01; + + while(ts < size) + ts <<= 1; + + if (ts > size && ts > 64) + ts >>= 1; + + return ts; +} + + + +//! returns driver type of texture (=the driver, who created the texture) +E_DRIVER_TYPE CD3D9Texture::getDriverType() +{ + return EDT_DIRECT3D9; +} + + + +//! returns color format of texture +ECOLOR_FORMAT CD3D9Texture::getColorFormat() const +{ + return ColorFormat; +} + + + +//! returns pitch of texture (in bytes) +u32 CD3D9Texture::getPitch() const +{ + return Pitch; +} + + + +//! returns the DIRECT3D9 Texture +IDirect3DTexture9* CD3D9Texture::getDX9Texture() +{ + return Texture; +} + + +//! returns if texture has mipmap levels +bool CD3D9Texture::hasMipMaps() +{ + return HasMipMaps; +} + + +void CD3D9Texture::copy16BitMipMap(char* src, char* tgt, + s32 width, s32 height, + s32 pitchsrc, s32 pitchtgt) +{ + u16 c; + + for (int x=0; x>= 2; + r >>= 2; + g >>= 2; + b >>= 2; + + c = ((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff); + *(u32*)((void*)&tgt[(x*4)+(y*pitchtgt)]) = c.color; + } + } +} + + +//! Regenerates the mip map levels of the texture. Useful after locking and +//! modifying the texture +void CD3D9Texture::regenerateMipMapLevels() +{ + if (HasMipMaps) + createMipMaps(); +} + + +//! returns if it is a render target +bool CD3D9Texture::isRenderTarget() +{ + return IsRenderTarget; +} + +//! Returns pointer to the render target surface +IDirect3DSurface9* CD3D9Texture::getRenderTargetSurface() +{ + if (!IsRenderTarget) + return 0; + + IDirect3DSurface9 *pRTTSurface = 0; + if (Texture) + Texture->GetSurfaceLevel(0, &pRTTSurface); + + if (pRTTSurface) + pRTTSurface->Release(); + + return pRTTSurface; +} + + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ diff --git a/src/dep/src/irrlicht/CD3D9Texture.h b/src/dep/src/irrlicht/CD3D9Texture.h index e846d83..958e288 100644 --- a/src/dep/src/irrlicht/CD3D9Texture.h +++ b/src/dep/src/irrlicht/CD3D9Texture.h @@ -1,125 +1,125 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_DIRECTX9_TEXTURE_H_INCLUDED__ -#define __C_DIRECTX9_TEXTURE_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - -#include "ITexture.h" -#include "IImage.h" -#include "d3d9.h" - -namespace irr -{ -namespace video -{ - -class CD3D9Driver; -/*! - interface for a Video Driver dependent Texture. -*/ -class CD3D9Texture : public ITexture -{ -public: - - //! constructor - CD3D9Texture(IImage* image, CD3D9Driver* driver, - u32 flags, const char* name); - - //! rendertarget constructor - CD3D9Texture(CD3D9Driver* driver, core::dimension2d size, const char* name); - - //! destructor - virtual ~CD3D9Texture(); - - //! lock function - virtual void* lock(); - - //! unlock function - virtual void unlock(); - - //! Returns original size of the texture. - virtual const core::dimension2d& getOriginalSize(); - - //! Returns (=size) of the texture. - virtual const core::dimension2d& getSize(); - - //! returns driver type of texture (=the driver, who created the texture) - virtual E_DRIVER_TYPE getDriverType(); - - //! returns color format of texture - virtual ECOLOR_FORMAT getColorFormat() const; - - //! returns pitch of texture (in bytes) - virtual u32 getPitch() const; - - //! returns the DIRECT3D9 Texture - IDirect3DTexture9* getDX9Texture(); - - //! returns if texture has mipmap levels - bool hasMipMaps(); - - //! Regenerates the mip map levels of the texture. Useful after locking and - //! modifying the texture - virtual void regenerateMipMapLevels(); - - //! returns if it is a render target - bool isRenderTarget(); - - //! Returns pointer to the render target surface - IDirect3DSurface9* getRenderTargetSurface(); - -private: - - void createRenderTarget(); - - //! returns the size of a texture which would be the optimize size for rendering it - inline s32 getTextureSizeFromImageSize(s32 size); - - //! creates the hardware texture - void createTexture(u32 flags); - - //! copies the image to the texture - bool copyTexture(); - - //! optimized for 16 bit to 16 copy. - bool copyTo16BitTexture(); - - //! copies texture to 32 bit hardware texture - bool copyTo32BitTexture(); - - bool createMipMaps(s32 level=1); - - void copy16BitMipMap(char* src, char* tgt, - s32 width, s32 height, s32 pitchsrc, s32 pitchtgt); - - void copy32BitMipMap(char* src, char* tgt, - s32 width, s32 height, s32 pitchsrc, s32 pitchtgt); - - IImage* Image; - IDirect3DDevice9* Device; - IDirect3DTexture9* Texture; - IDirect3DSurface9* RTTSurface; - CD3D9Driver* Driver; - core::dimension2d TextureSize; - core::dimension2d ImageSize; - s32 Pitch; - ECOLOR_FORMAT ColorFormat; - - bool SurfaceHasSameSize; // true if image has the same dimension as texture. - bool HasMipMaps; - bool HardwareMipMaps; - bool IsRenderTarget; -}; - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ - -#endif // __C_DIRECTX9_TEXTURE_H_INCLUDED__ - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_DIRECTX9_TEXTURE_H_INCLUDED__ +#define __C_DIRECTX9_TEXTURE_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + +#include "ITexture.h" +#include "IImage.h" +#include "d3d9.h" + +namespace irr +{ +namespace video +{ + +class CD3D9Driver; +/*! + interface for a Video Driver dependent Texture. +*/ +class CD3D9Texture : public ITexture +{ +public: + + //! constructor + CD3D9Texture(IImage* image, CD3D9Driver* driver, + u32 flags, const char* name); + + //! rendertarget constructor + CD3D9Texture(CD3D9Driver* driver, core::dimension2d size, const char* name); + + //! destructor + virtual ~CD3D9Texture(); + + //! lock function + virtual void* lock(); + + //! unlock function + virtual void unlock(); + + //! Returns original size of the texture. + virtual const core::dimension2d& getOriginalSize(); + + //! Returns (=size) of the texture. + virtual const core::dimension2d& getSize(); + + //! returns driver type of texture (=the driver, who created the texture) + virtual E_DRIVER_TYPE getDriverType(); + + //! returns color format of texture + virtual ECOLOR_FORMAT getColorFormat() const; + + //! returns pitch of texture (in bytes) + virtual u32 getPitch() const; + + //! returns the DIRECT3D9 Texture + IDirect3DTexture9* getDX9Texture(); + + //! returns if texture has mipmap levels + bool hasMipMaps(); + + //! Regenerates the mip map levels of the texture. Useful after locking and + //! modifying the texture + virtual void regenerateMipMapLevels(); + + //! returns if it is a render target + bool isRenderTarget(); + + //! Returns pointer to the render target surface + IDirect3DSurface9* getRenderTargetSurface(); + +private: + + void createRenderTarget(); + + //! returns the size of a texture which would be the optimize size for rendering it + inline s32 getTextureSizeFromImageSize(s32 size); + + //! creates the hardware texture + void createTexture(u32 flags); + + //! copies the image to the texture + bool copyTexture(); + + //! optimized for 16 bit to 16 copy. + bool copyTo16BitTexture(); + + //! copies texture to 32 bit hardware texture + bool copyTo32BitTexture(); + + bool createMipMaps(s32 level=1); + + void copy16BitMipMap(char* src, char* tgt, + s32 width, s32 height, s32 pitchsrc, s32 pitchtgt); + + void copy32BitMipMap(char* src, char* tgt, + s32 width, s32 height, s32 pitchsrc, s32 pitchtgt); + + IImage* Image; + IDirect3DDevice9* Device; + IDirect3DTexture9* Texture; + IDirect3DSurface9* RTTSurface; + CD3D9Driver* Driver; + core::dimension2d TextureSize; + core::dimension2d ImageSize; + s32 Pitch; + ECOLOR_FORMAT ColorFormat; + + bool SurfaceHasSameSize; // true if image has the same dimension as texture. + bool HasMipMaps; + bool HardwareMipMaps; + bool IsRenderTarget; +}; + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ + +#endif // __C_DIRECTX9_TEXTURE_H_INCLUDED__ + diff --git a/src/dep/src/irrlicht/CDMFLoader.cpp b/src/dep/src/irrlicht/CDMFLoader.cpp index e5f095b..39d9679 100644 --- a/src/dep/src/irrlicht/CDMFLoader.cpp +++ b/src/dep/src/irrlicht/CDMFLoader.cpp @@ -1,493 +1,493 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This file was originally written by Salvatore Russo. -// I (Nikolaus Gebhardt) did some minor modifications and changes to it and -// integrated it into Irrlicht. -// Thanks a lot to Salvatore for his work on this and that he gave me -// his permission to add it into Irrlicht using the zlib license. -/* - CDMFLoader by Salvatore Russo (September 2005) - - See the header file for additional information including use and distribution rights. -*/ - -#include "CDMFLoader.h" -#include "ISceneManager.h" -#include "IAttributes.h" -#include "SAnimatedMesh.h" -#include "SMeshBufferLightMap.h" -#include "irrString.h" -#include "irrMath.h" -#include "dmfsupport.h" - -namespace irr -{ -namespace scene -{ - -/** Constructor*/ -CDMFLoader::CDMFLoader(video::IVideoDriver* driver, ISceneManager* smgr) -: Driver(driver) , SceneMgr(smgr) -{ - #ifdef _DEBUG - IUnknown::setDebugName("CDMFLoader"); - #endif - - if (Driver) - Driver->grab(); -} - - -/** Destructor*/ -CDMFLoader::~CDMFLoader() -{ - if (Driver) - Driver->drop(); -} - - - -/** Given first three points of a face, returns a face normal*/ -void CDMFLoader::GetFaceNormal( f32 a[3], //First point - f32 b[3], //Second point - f32 c[3], //Third point - f32 out[3]) //Normal computed -{ - f32 v1[3], v2[3]; - - v1[0] = a[0] - b[0]; - v1[1] = a[1] - b[1]; - v1[2] = a[2] - b[2]; - - v2[0] = b[0] - c[0]; - v2[1] = b[1] - c[1]; - v2[2] = b[2] - c[2]; - - out[0] = (v1[1] * v2[2]) - (v1[2] * v2[1]); - out[1] = (v1[2] * v2[0]) - (v1[0] * v2[2]); - out[2] = (v1[0] * v2[1]) - (v1[1] * v2[0]); - - f32 dist = (f32)sqrtf((out[0] * out[0]) + (out[1] * out[1]) + (out[2] * out[2])); - - if (dist == 0.0f) - dist = 0.001f; - - out[0] /= dist; - out[1] /= dist; - out[2] /= dist; -} - - -/**Creates/loads an animated mesh from the file. - \return Pointer to the created mesh. Returns 0 if loading failed. - If you no longer need the mesh, you should call IAnimatedMesh::drop(). - See IUnknown::drop() for more information.*/ -IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) -{ - SMesh * Mesh = new SMesh(); - - u32 i; - - if (!file) - return false; - - //Load stringlist - StringList dmfRawFile(file); - - if (dmfRawFile.size()==0) - return false; - - //begin logging with - //fprintf(flog,"DMF Loader version %1.1f log file\nTrying to load: %s\n",DMFloader_vers,file->getFileName()); - dmfHeader header; - - //load header - if (GetDMFHeader(dmfRawFile, header)) - { - //print in log file some statistics - /*fprintf(flog,"DeleD Map Detected\nDeleD Map Version:%1.1f\nScene Name:%s\n" - "Ambient Color(r,g,b):%d,%d,%d\nShadow Intensity:%f\n" - "Number of Objects:%u\nNumber of Materials:%u\n" - "Total Vertices: %u\nTotal Faces: %u\n" - "Total Number of Dynamic Lights: %u\n" - "Trying to Load Materials...", - header.dmfVersion,header.dmfName, - header.dmfAmbient.getRed(),header.dmfAmbient.getGreen(),header.dmfAmbient.getBlue(), - header.dmfShadow,header.numObjects,header.numMaterials, - header.numVertices,header.numFaces,header.numLights);*/ - - //let's set ambient light - SceneMgr->setAmbientLight( header.dmfAmbient); - - //let's create the correct number of materials, vertices and faces - dmfMaterial *materiali=new dmfMaterial[header.numMaterials]; - dmfVert *verts=new dmfVert[header.numVertices]; - dmfFace *faces=new dmfFace[header.numFaces]; - - //let's get the materials - bool use_mat_dirs=false; - use_mat_dirs=SceneMgr->getParameters()->getAttributeAsBool(DMF_USE_MATERIALS_DIRS); - - if ( GetDMFMaterials(dmfRawFile , materiali,header.numMaterials,use_mat_dirs)) - { - //print to log file some stats - /*fprintf(flog,"Materials Loaded\nShowing 1st and last infos:\n" - " -1st Material (id,texname,lmapname):%u,%s,%s\n" - " -Last Material (id,texname,lmapname):%u,%s,%s\n", - materiali[0].materialID,materiali[0].textureName, - materiali[0].lightmapName,materiali[header.numMaterials-1].materialID, - materiali[header.numMaterials-1].textureName,materiali[header.numMaterials-1].lightmapName);*/ - } - /*else - fprintf(flog,"Cannot Load Materials.\n"); - - fprintf(flog,"Trying to load Vertices and Faces...");*/ - - //let's get vertices and faces - if(GetDMFVerticesFaces(dmfRawFile, verts,faces)) - { - /* fprintf(flog,"Loaded\nShowing 1st face and last vertex infos:\n" - " -1st Face (1st vertex,vert num,material id): %u,%u,%u\n" - " -Last vertice (position;tex uv;lmap uv): %f,%f,%f;%f,%f;%f,%f\n", - faces[0].firstVert,faces[0].numVerts,faces[0].materialID, - verts[header.numVertices-1].pos[0],verts[header.numVertices-1].pos[1],verts[header.numVertices-1].pos[2], - verts[header.numVertices-1].tc[0],verts[header.numVertices-1].tc[1], - verts[header.numVertices-1].lc[0],verts[header.numVertices-1].lc[1]);*/ - } - /*else - fprintf(flog,"Cannot Load Vertices and Faces.\n");*/ - - //create a meshbuffer for each material, then we'll remove empty ones - for (i=0; iMaterial.MaterialType = video::EMT_LIGHTMAP_LIGHTING ; - buffer->Material.Wireframe = false; - buffer->Material.Lighting = true; - buffer->Material.BilinearFilter = true; - Mesh->addMeshBuffer(buffer); - buffer->drop(); - } - - // Build the mesh buffers - for (i = 0; i < header.numFaces; i++) - { - if (faces[i].numVerts < 3) - continue; - - f32 normal[3]; - - GetFaceNormal(verts[faces[i].firstVert].pos, - verts[faces[i].firstVert+1].pos, verts[faces[i].firstVert+2].pos, normal); - - SMeshBufferLightMap * meshBuffer = (SMeshBufferLightMap*)Mesh->getMeshBuffer( - faces[i].materialID); - - u32 base = meshBuffer->Vertices.size(); - - // Add this face's verts - u32 v; - for (v = 0; v < faces[i].numVerts; v++) - { - dmfVert * vv = &verts[faces[i].firstVert + v]; - video::S3DVertex2TCoords vert(vv->pos[0], vv->pos[1], vv->pos[2], - normal[0], normal[1], normal[2], video::SColor(0,255,255,255), 0.0f, 0.0f); - if ( materiali[faces[i].materialID].textureBlend==4 && - SceneMgr->getParameters()->getAttributeAsBool(DMF_FLIP_ALPHA_TEXTURES)) - { - vert.TCoords.set(vv->tc[0],-vv->tc[1]); - vert.TCoords2.set(vv->lc[0],vv->lc[1]); - } - else - { - vert.TCoords.set(vv->tc[0], vv->tc[1]); - vert.TCoords2.set(vv->lc[0], vv->lc[1]); - } - meshBuffer->Vertices.push_back(vert); - } - - // Now add the indices - // This weird loop turns convex polygons into triangle strips. - // I do it this way instead of a simple fan because it usually - // looks a lot better in wireframe, for example. - u32 h = faces[i].numVerts - 1, l = 0, c; // High, Low, Center - for (v = 0; v < faces[i].numVerts - 2; v++) - { - if (v & 1) - c = h - 1; - else - c = l + 1; - - meshBuffer->Indices.push_back(base + h); - meshBuffer->Indices.push_back(base + l); - meshBuffer->Indices.push_back(base + c); - - if (v & 1) - h--; - else - l++; - } - } - - //load textures and lightmaps in materials. - //don't worry if you receive a could not load texture, cause if you don't need - //a particular material in your scene it will be loaded and then destroyed. - for (i=0; igetParameters()->existsAttribute(DMF_TEXTURE_PATH) ) - { - //get the right path for textures - StringList filepath = SubdivideString(String(file->getFileName()),"\\"); - StringList filepath1 = SubdivideString(String(file->getFileName()),"/"); - if(filepath1.size()>filepath.size()) - { - filepath.clear(); - filepath=filepath1; - } - - for (int j=0; j<(int)(filepath.size()-1); j++) - path = path + filepath[j] + String("\\"); - } - else - path = path + - String( SceneMgr->getParameters()->getAttributeAsString(DMF_TEXTURE_PATH)) + String("\\"); - - //texture and lightmap - ITexture *tex = 0; - ITexture *lig = 0; - - //currrent buffer to apply material - SMeshBufferLightMap* buffer = (SMeshBufferLightMap*)Mesh->getMeshBuffer(i); - - //Primary texture is normal - if (materiali[i].textureFlag==0) - if(materiali[i].textureBlend==4) Driver->setTextureCreationFlag (ETCF_ALWAYS_32_BIT,true); - tex = Driver->getTexture((path+String(materiali[i].textureName)).c_str()); - - //Primary texture is just a colour - if(materiali[i].textureFlag==1) - { - String colour(materiali[i].textureName); - String alpha,red,green,blue; - - alpha.append((char*)&colour[0]); - alpha.append((char*)&colour[1]); - blue.append((char*)&colour[2]); - blue.append((char*)&colour[3]); - green.append((char*)&colour[4]); - green.append((char*)&colour[5]); - red.append((char*)&colour[6]); - red.append((char*)&colour[7]); - - SColor color(axtoi(alpha.c_str()), - axtoi(red.c_str()),axtoi(green.c_str()), - axtoi(blue.c_str())); - - s32 col = color.color; - s32 buf[64]; - - for (int k=0; k<64; k++) - buf[k]=col; - - //just for compatibility with older Irrlicht versions - //to support transparent materials - if(color.getAlpha()!=255 && materiali[i].textureBlend==4) Driver->setTextureCreationFlag (ETCF_ALWAYS_32_BIT,true); - - IImage *immagine=Driver->createImageFromData(ECF_A8R8G8B8, - core::dimension2d(8,8),buf); - - tex = Driver->addTexture("", immagine); - - //to support transparent materials - if(color.getAlpha()!=255 && materiali[i].textureBlend==4){ - buffer->Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL ; - buffer->Material.MaterialTypeParam =(((f32) (color.getAlpha()-1))/255.0f); - } - immagine->drop(); - } - - //Lightmap is present - if (materiali[i].lightmapFlag == 0) - lig = Driver->getTexture((path+String(materiali[i].lightmapName)).c_str()); - else //no lightmap - { - lig = 0; - buffer->Material.MaterialType = video::EMT_SOLID; - f32 mult = 100.0f - header.dmfShadow; - mult /= 100.0f; - buffer->Material.AmbientColor=header.dmfAmbient.getInterpolated ( SColor(255,0,0,0),mult); - } - - if(materiali[i].textureBlend==4) { - buffer->Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - buffer->Material.MaterialTypeParam =SceneMgr->getParameters()->getAttributeAsFloat(DMF_ALPHA_CHANNEL_REF); - } - - core::dimension2d texsize; - core::dimension2d ligsize; - - if (tex && header.dmfVersion<1.1) - texsize=tex->getSize(); - - if (lig && header.dmfVersion<1.1) - ligsize=lig->getSize(); - - // fprintf(flog,"%s real size w:%d h:%d\n",materiali[i].textureName,texsize.Width,texsize.Height); - - //if texture is present mirror vertically owing to DeleD rapresentation - if (tex && header.dmfVersion<1.1) - { - void* pp = tex->lock(); - if (pp) - { - video::ECOLOR_FORMAT format = tex->getColorFormat(); - if (format == video::ECF_A1R5G5B5) - { - s16* p = (s16*)pp; - s16 tmp=0; - for (s32 x=0; xunlock(); - tex->regenerateMipMapLevels(); - } - - //if lightmap is present mirror vertically owing to DeleD rapresentation - if (lig && header.dmfVersion<1.1) - { - void* pp = lig->lock(); - if (pp) - { - video::ECOLOR_FORMAT format = lig->getColorFormat(); - if (format == video::ECF_A1R5G5B5) - { - s16* p = (s16*)pp; - s16 tmp=0; - for (s32 x=0; xunlock(); - lig->regenerateMipMapLevels(); - } - - buffer->Material.Textures[0]=tex; - buffer->Material.Textures[1]=lig; - } - - delete verts; - delete faces; - delete materiali; -} -//else -// fprintf(flog,"Cannot load %s, please check it's generated with DeleD 0.91+."); - - //closing log file - //fclose(flog); - - // delete all buffers without geometry in it. - i = 0; - while(i < Mesh->MeshBuffers.size()) - { - if (Mesh->MeshBuffers[i]->getVertexCount() == 0 || - Mesh->MeshBuffers[i]->getIndexCount() == 0 || - Mesh->MeshBuffers[i]->getMaterial().Textures[0] == 0) - { - // Meshbuffer is empty -- drop it - Mesh->MeshBuffers[i]->drop(); - Mesh->MeshBuffers.erase(i); - } - else - { - i++; - } - } - - - // create bounding box - for (i = 0; i < Mesh->MeshBuffers.size(); i++) - { - ((SMeshBufferLightMap*)Mesh->MeshBuffers[i])->recalculateBoundingBox(); - } - Mesh->recalculateBoundingBox(); - - - // Set up an animated mesh to hold the mesh - SAnimatedMesh* AMesh = new SAnimatedMesh(); - AMesh->Type = EAMT_UNKNOWN; - AMesh->addMesh(Mesh); - AMesh->recalculateBoundingBox(); - Mesh->drop(); - - return AMesh; -} - - -/** \brief Tell us if this file is able to be loaded by this class - based on the file extension (e.g. ".bsp") - \return true if file is loadable.*/ -bool CDMFLoader::isALoadableFileExtension(const c8* filename) -{ - return strstr(filename, ".dmf") != 0; -} - - -} // end namespace scene -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// +// This file was originally written by Salvatore Russo. +// I (Nikolaus Gebhardt) did some minor modifications and changes to it and +// integrated it into Irrlicht. +// Thanks a lot to Salvatore for his work on this and that he gave me +// his permission to add it into Irrlicht using the zlib license. +/* + CDMFLoader by Salvatore Russo (September 2005) + + See the header file for additional information including use and distribution rights. +*/ + +#include "CDMFLoader.h" +#include "ISceneManager.h" +#include "IAttributes.h" +#include "SAnimatedMesh.h" +#include "SMeshBufferLightMap.h" +#include "irrString.h" +#include "irrMath.h" +#include "dmfsupport.h" + +namespace irr +{ +namespace scene +{ + +/** Constructor*/ +CDMFLoader::CDMFLoader(video::IVideoDriver* driver, ISceneManager* smgr) +: Driver(driver) , SceneMgr(smgr) +{ + #ifdef _DEBUG + IUnknown::setDebugName("CDMFLoader"); + #endif + + if (Driver) + Driver->grab(); +} + + +/** Destructor*/ +CDMFLoader::~CDMFLoader() +{ + if (Driver) + Driver->drop(); +} + + + +/** Given first three points of a face, returns a face normal*/ +void CDMFLoader::GetFaceNormal( f32 a[3], //First point + f32 b[3], //Second point + f32 c[3], //Third point + f32 out[3]) //Normal computed +{ + f32 v1[3], v2[3]; + + v1[0] = a[0] - b[0]; + v1[1] = a[1] - b[1]; + v1[2] = a[2] - b[2]; + + v2[0] = b[0] - c[0]; + v2[1] = b[1] - c[1]; + v2[2] = b[2] - c[2]; + + out[0] = (v1[1] * v2[2]) - (v1[2] * v2[1]); + out[1] = (v1[2] * v2[0]) - (v1[0] * v2[2]); + out[2] = (v1[0] * v2[1]) - (v1[1] * v2[0]); + + f32 dist = (f32)sqrtf((out[0] * out[0]) + (out[1] * out[1]) + (out[2] * out[2])); + + if (dist == 0.0f) + dist = 0.001f; + + out[0] /= dist; + out[1] /= dist; + out[2] /= dist; +} + + +/**Creates/loads an animated mesh from the file. + \return Pointer to the created mesh. Returns 0 if loading failed. + If you no longer need the mesh, you should call IAnimatedMesh::drop(). + See IUnknown::drop() for more information.*/ +IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) +{ + SMesh * Mesh = new SMesh(); + + u32 i; + + if (!file) + return false; + + //Load stringlist + StringList dmfRawFile(file); + + if (dmfRawFile.size()==0) + return false; + + //begin logging with + //fprintf(flog,"DMF Loader version %1.1f log file\nTrying to load: %s\n",DMFloader_vers,file->getFileName()); + dmfHeader header; + + //load header + if (GetDMFHeader(dmfRawFile, header)) + { + //print in log file some statistics + /*fprintf(flog,"DeleD Map Detected\nDeleD Map Version:%1.1f\nScene Name:%s\n" + "Ambient Color(r,g,b):%d,%d,%d\nShadow Intensity:%f\n" + "Number of Objects:%u\nNumber of Materials:%u\n" + "Total Vertices: %u\nTotal Faces: %u\n" + "Total Number of Dynamic Lights: %u\n" + "Trying to Load Materials...", + header.dmfVersion,header.dmfName, + header.dmfAmbient.getRed(),header.dmfAmbient.getGreen(),header.dmfAmbient.getBlue(), + header.dmfShadow,header.numObjects,header.numMaterials, + header.numVertices,header.numFaces,header.numLights);*/ + + //let's set ambient light + SceneMgr->setAmbientLight( header.dmfAmbient); + + //let's create the correct number of materials, vertices and faces + dmfMaterial *materiali=new dmfMaterial[header.numMaterials]; + dmfVert *verts=new dmfVert[header.numVertices]; + dmfFace *faces=new dmfFace[header.numFaces]; + + //let's get the materials + bool use_mat_dirs=false; + use_mat_dirs=SceneMgr->getParameters()->getAttributeAsBool(DMF_USE_MATERIALS_DIRS); + + if ( GetDMFMaterials(dmfRawFile , materiali,header.numMaterials,use_mat_dirs)) + { + //print to log file some stats + /*fprintf(flog,"Materials Loaded\nShowing 1st and last infos:\n" + " -1st Material (id,texname,lmapname):%u,%s,%s\n" + " -Last Material (id,texname,lmapname):%u,%s,%s\n", + materiali[0].materialID,materiali[0].textureName, + materiali[0].lightmapName,materiali[header.numMaterials-1].materialID, + materiali[header.numMaterials-1].textureName,materiali[header.numMaterials-1].lightmapName);*/ + } + /*else + fprintf(flog,"Cannot Load Materials.\n"); + + fprintf(flog,"Trying to load Vertices and Faces...");*/ + + //let's get vertices and faces + if(GetDMFVerticesFaces(dmfRawFile, verts,faces)) + { + /* fprintf(flog,"Loaded\nShowing 1st face and last vertex infos:\n" + " -1st Face (1st vertex,vert num,material id): %u,%u,%u\n" + " -Last vertice (position;tex uv;lmap uv): %f,%f,%f;%f,%f;%f,%f\n", + faces[0].firstVert,faces[0].numVerts,faces[0].materialID, + verts[header.numVertices-1].pos[0],verts[header.numVertices-1].pos[1],verts[header.numVertices-1].pos[2], + verts[header.numVertices-1].tc[0],verts[header.numVertices-1].tc[1], + verts[header.numVertices-1].lc[0],verts[header.numVertices-1].lc[1]);*/ + } + /*else + fprintf(flog,"Cannot Load Vertices and Faces.\n");*/ + + //create a meshbuffer for each material, then we'll remove empty ones + for (i=0; iMaterial.MaterialType = video::EMT_LIGHTMAP_LIGHTING ; + buffer->Material.Wireframe = false; + buffer->Material.Lighting = true; + buffer->Material.BilinearFilter = true; + Mesh->addMeshBuffer(buffer); + buffer->drop(); + } + + // Build the mesh buffers + for (i = 0; i < header.numFaces; i++) + { + if (faces[i].numVerts < 3) + continue; + + f32 normal[3]; + + GetFaceNormal(verts[faces[i].firstVert].pos, + verts[faces[i].firstVert+1].pos, verts[faces[i].firstVert+2].pos, normal); + + SMeshBufferLightMap * meshBuffer = (SMeshBufferLightMap*)Mesh->getMeshBuffer( + faces[i].materialID); + + u32 base = meshBuffer->Vertices.size(); + + // Add this face's verts + u32 v; + for (v = 0; v < faces[i].numVerts; v++) + { + dmfVert * vv = &verts[faces[i].firstVert + v]; + video::S3DVertex2TCoords vert(vv->pos[0], vv->pos[1], vv->pos[2], + normal[0], normal[1], normal[2], video::SColor(0,255,255,255), 0.0f, 0.0f); + if ( materiali[faces[i].materialID].textureBlend==4 && + SceneMgr->getParameters()->getAttributeAsBool(DMF_FLIP_ALPHA_TEXTURES)) + { + vert.TCoords.set(vv->tc[0],-vv->tc[1]); + vert.TCoords2.set(vv->lc[0],vv->lc[1]); + } + else + { + vert.TCoords.set(vv->tc[0], vv->tc[1]); + vert.TCoords2.set(vv->lc[0], vv->lc[1]); + } + meshBuffer->Vertices.push_back(vert); + } + + // Now add the indices + // This weird loop turns convex polygons into triangle strips. + // I do it this way instead of a simple fan because it usually + // looks a lot better in wireframe, for example. + u32 h = faces[i].numVerts - 1, l = 0, c; // High, Low, Center + for (v = 0; v < faces[i].numVerts - 2; v++) + { + if (v & 1) + c = h - 1; + else + c = l + 1; + + meshBuffer->Indices.push_back(base + h); + meshBuffer->Indices.push_back(base + l); + meshBuffer->Indices.push_back(base + c); + + if (v & 1) + h--; + else + l++; + } + } + + //load textures and lightmaps in materials. + //don't worry if you receive a could not load texture, cause if you don't need + //a particular material in your scene it will be loaded and then destroyed. + for (i=0; igetParameters()->existsAttribute(DMF_TEXTURE_PATH) ) + { + //get the right path for textures + StringList filepath = SubdivideString(String(file->getFileName()),"\\"); + StringList filepath1 = SubdivideString(String(file->getFileName()),"/"); + if(filepath1.size()>filepath.size()) + { + filepath.clear(); + filepath=filepath1; + } + + for (int j=0; j<(int)(filepath.size()-1); j++) + path = path + filepath[j] + String("\\"); + } + else + path = path + + String( SceneMgr->getParameters()->getAttributeAsString(DMF_TEXTURE_PATH)) + String("\\"); + + //texture and lightmap + ITexture *tex = 0; + ITexture *lig = 0; + + //currrent buffer to apply material + SMeshBufferLightMap* buffer = (SMeshBufferLightMap*)Mesh->getMeshBuffer(i); + + //Primary texture is normal + if (materiali[i].textureFlag==0) + if(materiali[i].textureBlend==4) Driver->setTextureCreationFlag (ETCF_ALWAYS_32_BIT,true); + tex = Driver->getTexture((path+String(materiali[i].textureName)).c_str()); + + //Primary texture is just a colour + if(materiali[i].textureFlag==1) + { + String colour(materiali[i].textureName); + String alpha,red,green,blue; + + alpha.append((char*)&colour[0]); + alpha.append((char*)&colour[1]); + blue.append((char*)&colour[2]); + blue.append((char*)&colour[3]); + green.append((char*)&colour[4]); + green.append((char*)&colour[5]); + red.append((char*)&colour[6]); + red.append((char*)&colour[7]); + + SColor color(axtoi(alpha.c_str()), + axtoi(red.c_str()),axtoi(green.c_str()), + axtoi(blue.c_str())); + + s32 col = color.color; + s32 buf[64]; + + for (int k=0; k<64; k++) + buf[k]=col; + + //just for compatibility with older Irrlicht versions + //to support transparent materials + if(color.getAlpha()!=255 && materiali[i].textureBlend==4) Driver->setTextureCreationFlag (ETCF_ALWAYS_32_BIT,true); + + IImage *immagine=Driver->createImageFromData(ECF_A8R8G8B8, + core::dimension2d(8,8),buf); + + tex = Driver->addTexture("", immagine); + + //to support transparent materials + if(color.getAlpha()!=255 && materiali[i].textureBlend==4){ + buffer->Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL ; + buffer->Material.MaterialTypeParam =(((f32) (color.getAlpha()-1))/255.0f); + } + immagine->drop(); + } + + //Lightmap is present + if (materiali[i].lightmapFlag == 0) + lig = Driver->getTexture((path+String(materiali[i].lightmapName)).c_str()); + else //no lightmap + { + lig = 0; + buffer->Material.MaterialType = video::EMT_SOLID; + f32 mult = 100.0f - header.dmfShadow; + mult /= 100.0f; + buffer->Material.AmbientColor=header.dmfAmbient.getInterpolated ( SColor(255,0,0,0),mult); + } + + if(materiali[i].textureBlend==4) { + buffer->Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; + buffer->Material.MaterialTypeParam =SceneMgr->getParameters()->getAttributeAsFloat(DMF_ALPHA_CHANNEL_REF); + } + + core::dimension2d texsize; + core::dimension2d ligsize; + + if (tex && header.dmfVersion<1.1) + texsize=tex->getSize(); + + if (lig && header.dmfVersion<1.1) + ligsize=lig->getSize(); + + // fprintf(flog,"%s real size w:%d h:%d\n",materiali[i].textureName,texsize.Width,texsize.Height); + + //if texture is present mirror vertically owing to DeleD rapresentation + if (tex && header.dmfVersion<1.1) + { + void* pp = tex->lock(); + if (pp) + { + video::ECOLOR_FORMAT format = tex->getColorFormat(); + if (format == video::ECF_A1R5G5B5) + { + s16* p = (s16*)pp; + s16 tmp=0; + for (s32 x=0; xunlock(); + tex->regenerateMipMapLevels(); + } + + //if lightmap is present mirror vertically owing to DeleD rapresentation + if (lig && header.dmfVersion<1.1) + { + void* pp = lig->lock(); + if (pp) + { + video::ECOLOR_FORMAT format = lig->getColorFormat(); + if (format == video::ECF_A1R5G5B5) + { + s16* p = (s16*)pp; + s16 tmp=0; + for (s32 x=0; xunlock(); + lig->regenerateMipMapLevels(); + } + + buffer->Material.Textures[0]=tex; + buffer->Material.Textures[1]=lig; + } + + delete verts; + delete faces; + delete materiali; +} +//else +// fprintf(flog,"Cannot load %s, please check it's generated with DeleD 0.91+."); + + //closing log file + //fclose(flog); + + // delete all buffers without geometry in it. + i = 0; + while(i < Mesh->MeshBuffers.size()) + { + if (Mesh->MeshBuffers[i]->getVertexCount() == 0 || + Mesh->MeshBuffers[i]->getIndexCount() == 0 || + Mesh->MeshBuffers[i]->getMaterial().Textures[0] == 0) + { + // Meshbuffer is empty -- drop it + Mesh->MeshBuffers[i]->drop(); + Mesh->MeshBuffers.erase(i); + } + else + { + i++; + } + } + + + // create bounding box + for (i = 0; i < Mesh->MeshBuffers.size(); i++) + { + ((SMeshBufferLightMap*)Mesh->MeshBuffers[i])->recalculateBoundingBox(); + } + Mesh->recalculateBoundingBox(); + + + // Set up an animated mesh to hold the mesh + SAnimatedMesh* AMesh = new SAnimatedMesh(); + AMesh->Type = EAMT_UNKNOWN; + AMesh->addMesh(Mesh); + AMesh->recalculateBoundingBox(); + Mesh->drop(); + + return AMesh; +} + + +/** \brief Tell us if this file is able to be loaded by this class + based on the file extension (e.g. ".bsp") + \return true if file is loadable.*/ +bool CDMFLoader::isALoadableFileExtension(const c8* filename) +{ + return strstr(filename, ".dmf") != 0; +} + + +} // end namespace scene +} // end namespace irr diff --git a/src/dep/src/irrlicht/CDMFLoader.h b/src/dep/src/irrlicht/CDMFLoader.h index 19bb849..db89b8d 100644 --- a/src/dep/src/irrlicht/CDMFLoader.h +++ b/src/dep/src/irrlicht/CDMFLoader.h @@ -1,97 +1,97 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This file was originally written by Salvatore Russo. -// I (Nikolaus Gebhardt) did some minor modifications changes to it and integrated -// it into Irrlicht: -// - removed STL dependency -// - removed log file and replaced it with irrlicht logging -// - adapted code formatting a bit to Irrlicht style -// - removed memory leaks -// Thanks a lot to Salvatore for his work on this and that he gave me -// his permission to add it into Irrlicht. - -/* - CDMFLoader by Salvatore Russo - Version 1.3 - - This loader is used to load DMF files in Irrlicht. - Look at the documentation for a sample application. - - Parts of this code are from Irrlicht's CQ3LevelMesh and C3DSMeshFileLoader, - and are Copyright (C) 2002-2004 Nikolaus Gebhardt. - - Parts of this code are from Murphy McCauley COCTLoader just like GetFaceNormal() or indexes - creation routines and a routine to add faces. So please refer to COCTLoader.h to know more - about rights granted. - - You can use this software as you wish but you must not remove these notes about license nor - credits to others for parts of this code. -*/ - -#ifndef __C_DMF_LOADER_H_INCLUDED__ -#define __C_DMF_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IReadFile.h" -#include "SMesh.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "SAnimatedMesh.h" - -namespace irr -{ -namespace scene -{ - /** A class to load DeleD mesh files.*/ - class CDMFLoader : public IMeshLoader - { - public: - - /** constructor*/ - CDMFLoader(video::IVideoDriver* driver,irr::scene::ISceneManager* smgr); - - /** destructor*/ - virtual ~CDMFLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".cob") - virtual bool isALoadableFileExtension(const c8* fileName); - - /** creates/loads an animated mesh from the file. - \return Pointer to the created mesh. Returns 0 if loading failed. - If you no longer need the mesh, you should call IAnimatedMesh::drop(). - See IUnknown::drop() for more information.*/ - virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); - - /** loads dynamic lights present in this scene. - Note that loaded lights from DeleD must have the suffix \b dynamic_ and must be \b pointlight. - Irrlicht correctly loads specular color, diffuse color , position and distance of object affected by light. - \return number of lights loaded or 0 if loading failed.*/ - int loadLights(const c8 * filename, irr::scene::ISceneManager* smgr, - ISceneNode* parent = 0, s32 base_id = 1000); - - /** loads water plains present in this scene. - Note that loaded water plains from DeleD must have the suffix \b water_ and must be \b rectangle (with just 1 rectangular face). - Irrlicht correctly loads position and rotation of water plain as well as texture layers. - \return number of water plains loaded or 0 if loading failed.*/ - int loadWaterPlains ( const c8 *filename, - irr::scene::ISceneManager* smgr, - ISceneNode * parent = 0, - s32 base_id = 2000, - bool mode = true); - - private: - - void GetFaceNormal(f32 a[3], f32 b[3], f32 c[3], f32 out[3]); - - video::IVideoDriver* Driver; - scene::ISceneManager* SceneMgr; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// +// This file was originally written by Salvatore Russo. +// I (Nikolaus Gebhardt) did some minor modifications changes to it and integrated +// it into Irrlicht: +// - removed STL dependency +// - removed log file and replaced it with irrlicht logging +// - adapted code formatting a bit to Irrlicht style +// - removed memory leaks +// Thanks a lot to Salvatore for his work on this and that he gave me +// his permission to add it into Irrlicht. + +/* + CDMFLoader by Salvatore Russo + Version 1.3 + + This loader is used to load DMF files in Irrlicht. + Look at the documentation for a sample application. + + Parts of this code are from Irrlicht's CQ3LevelMesh and C3DSMeshFileLoader, + and are Copyright (C) 2002-2004 Nikolaus Gebhardt. + + Parts of this code are from Murphy McCauley COCTLoader just like GetFaceNormal() or indexes + creation routines and a routine to add faces. So please refer to COCTLoader.h to know more + about rights granted. + + You can use this software as you wish but you must not remove these notes about license nor + credits to others for parts of this code. +*/ + +#ifndef __C_DMF_LOADER_H_INCLUDED__ +#define __C_DMF_LOADER_H_INCLUDED__ + +#include "IMeshLoader.h" +#include "IReadFile.h" +#include "SMesh.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" +#include "SAnimatedMesh.h" + +namespace irr +{ +namespace scene +{ + /** A class to load DeleD mesh files.*/ + class CDMFLoader : public IMeshLoader + { + public: + + /** constructor*/ + CDMFLoader(video::IVideoDriver* driver,irr::scene::ISceneManager* smgr); + + /** destructor*/ + virtual ~CDMFLoader(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".cob") + virtual bool isALoadableFileExtension(const c8* fileName); + + /** creates/loads an animated mesh from the file. + \return Pointer to the created mesh. Returns 0 if loading failed. + If you no longer need the mesh, you should call IAnimatedMesh::drop(). + See IUnknown::drop() for more information.*/ + virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); + + /** loads dynamic lights present in this scene. + Note that loaded lights from DeleD must have the suffix \b dynamic_ and must be \b pointlight. + Irrlicht correctly loads specular color, diffuse color , position and distance of object affected by light. + \return number of lights loaded or 0 if loading failed.*/ + int loadLights(const c8 * filename, irr::scene::ISceneManager* smgr, + ISceneNode* parent = 0, s32 base_id = 1000); + + /** loads water plains present in this scene. + Note that loaded water plains from DeleD must have the suffix \b water_ and must be \b rectangle (with just 1 rectangular face). + Irrlicht correctly loads position and rotation of water plain as well as texture layers. + \return number of water plains loaded or 0 if loading failed.*/ + int loadWaterPlains ( const c8 *filename, + irr::scene::ISceneManager* smgr, + ISceneNode * parent = 0, + s32 base_id = 2000, + bool mode = true); + + private: + + void GetFaceNormal(f32 a[3], f32 b[3], f32 c[3], f32 out[3]); + + video::IVideoDriver* Driver; + scene::ISceneManager* SceneMgr; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CDefaultGUIElementFactory.cpp b/src/dep/src/irrlicht/CDefaultGUIElementFactory.cpp index 4cfc12a..15545f8 100644 --- a/src/dep/src/irrlicht/CDefaultGUIElementFactory.cpp +++ b/src/dep/src/irrlicht/CDefaultGUIElementFactory.cpp @@ -1,153 +1,153 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CDefaultGUIElementFactory.h" -#include "IGUIEnvironment.h" -#include "IGUIButton.h" -#include "IGUICheckBox.h" -#include "IGUIComboBox.h" -#include "IGUIContextMenu.h" -#include "IGUIEditBox.h" -#include "IGUIFileOpenDialog.h" -#include "IGUIColorSelectDialog.h" -#include "IGUIInOutFader.h" -#include "IGUIImage.h" -#include "IGUIListBox.h" -#include "IGUIMeshViewer.h" -#include "IGUIScrollBar.h" -#include "IGUIStaticText.h" -#include "IGUITabControl.h" -#include "IGUIToolbar.h" -#include "IGUIWindow.h" - -#include - -namespace irr -{ -namespace gui -{ - -CDefaultGUIElementFactory::CDefaultGUIElementFactory(IGUIEnvironment* env) -: Environment(env) -{ - // don't grab the gui environment here to prevent cyclic references -} - - -CDefaultGUIElementFactory::~CDefaultGUIElementFactory() -{ -} - - -//! adds an element to the env based on its type id -IGUIElement* CDefaultGUIElementFactory::addGUIElement(EGUI_ELEMENT_TYPE type, IGUIElement* parent) -{ - - switch(type) - { - case EGUIET_BUTTON: - return Environment->addButton(core::rect(0,0,100,100),parent); - case EGUIET_CHECK_BOX: - return Environment->addCheckBox(false, core::rect(0,0,100,100), parent); - case EGUIET_COLOR_SELECT_DIALOG: - return Environment->addColorSelectDialog(0,true,parent); - case EGUIET_COMBO_BOX: - return Environment->addComboBox(core::rect(0,0,100,100),parent); - case EGUIET_CONTEXT_MENU: - return Environment->addContextMenu(core::rect(0,0,100,100),parent); - case EGUIET_MENU: - return Environment->addMenu(parent); - case EGUIET_EDIT_BOX: - return Environment->addEditBox(0,core::rect(0,0,100,100),true, parent); - case EGUIET_FILE_OPEN_DIALOG: - return Environment->addFileOpenDialog(0,true,parent); - case EGUIET_IMAGE: - return Environment->addImage(0,core::position2di(0,0), true, parent); - case EGUIET_IN_OUT_FADER: - return Environment->addInOutFader(0,parent); - case EGUIET_LIST_BOX: - return Environment->addListBox(core::rect(0,0,100,100),parent); - case EGUIET_MESH_VIEWER: - return Environment->addMeshViewer(core::rect(0,0,100,100),parent); - case EGUIET_MODAL_SCREEN: - return Environment->addModalScreen(parent); - case EGUIET_MESSAGE_BOX: - return Environment->addMessageBox(0,0,false,0,parent); - case EGUIET_SCROLL_BAR: - return Environment->addScrollBar(false,core::rect(0,0,100,100),parent); - case EGUIET_STATIC_TEXT: - return Environment->addStaticText(0,core::rect(0,0,100,100),false,true,parent); - case EGUIET_TAB: - return Environment->addTab(core::rect(0,0,100,100),parent); - case EGUIET_TAB_CONTROL: - return Environment->addTabControl(core::rect(0,0,100,100),parent); - case EGUIET_TOOL_BAR: - return Environment->addToolBar(parent); - case EGUIET_WINDOW: - return Environment->addWindow(core::rect(0,0,100,100),false,0,parent); - - } - - return 0; -} - - -//! adds an element to the environment based on its type name -IGUIElement* CDefaultGUIElementFactory::addGUIElement(const c8* typeName, IGUIElement* parent) -{ - return addGUIElement( getTypeFromName(typeName), parent ); -} - - -//! returns amount of element types this factory is able to create -s32 CDefaultGUIElementFactory::getCreatableGUIElementTypeCount() -{ - return EGUIET_COUNT; -} - - -//! returns type of a createable element type -EGUI_ELEMENT_TYPE CDefaultGUIElementFactory::getCreateableGUIElementType(s32 idx) -{ - if (idx>=0 && idx=0 && idx=0 && type + +namespace irr +{ +namespace gui +{ + +CDefaultGUIElementFactory::CDefaultGUIElementFactory(IGUIEnvironment* env) +: Environment(env) +{ + // don't grab the gui environment here to prevent cyclic references +} + + +CDefaultGUIElementFactory::~CDefaultGUIElementFactory() +{ +} + + +//! adds an element to the env based on its type id +IGUIElement* CDefaultGUIElementFactory::addGUIElement(EGUI_ELEMENT_TYPE type, IGUIElement* parent) +{ + + switch(type) + { + case EGUIET_BUTTON: + return Environment->addButton(core::rect(0,0,100,100),parent); + case EGUIET_CHECK_BOX: + return Environment->addCheckBox(false, core::rect(0,0,100,100), parent); + case EGUIET_COLOR_SELECT_DIALOG: + return Environment->addColorSelectDialog(0,true,parent); + case EGUIET_COMBO_BOX: + return Environment->addComboBox(core::rect(0,0,100,100),parent); + case EGUIET_CONTEXT_MENU: + return Environment->addContextMenu(core::rect(0,0,100,100),parent); + case EGUIET_MENU: + return Environment->addMenu(parent); + case EGUIET_EDIT_BOX: + return Environment->addEditBox(0,core::rect(0,0,100,100),true, parent); + case EGUIET_FILE_OPEN_DIALOG: + return Environment->addFileOpenDialog(0,true,parent); + case EGUIET_IMAGE: + return Environment->addImage(0,core::position2di(0,0), true, parent); + case EGUIET_IN_OUT_FADER: + return Environment->addInOutFader(0,parent); + case EGUIET_LIST_BOX: + return Environment->addListBox(core::rect(0,0,100,100),parent); + case EGUIET_MESH_VIEWER: + return Environment->addMeshViewer(core::rect(0,0,100,100),parent); + case EGUIET_MODAL_SCREEN: + return Environment->addModalScreen(parent); + case EGUIET_MESSAGE_BOX: + return Environment->addMessageBox(0,0,false,0,parent); + case EGUIET_SCROLL_BAR: + return Environment->addScrollBar(false,core::rect(0,0,100,100),parent); + case EGUIET_STATIC_TEXT: + return Environment->addStaticText(0,core::rect(0,0,100,100),false,true,parent); + case EGUIET_TAB: + return Environment->addTab(core::rect(0,0,100,100),parent); + case EGUIET_TAB_CONTROL: + return Environment->addTabControl(core::rect(0,0,100,100),parent); + case EGUIET_TOOL_BAR: + return Environment->addToolBar(parent); + case EGUIET_WINDOW: + return Environment->addWindow(core::rect(0,0,100,100),false,0,parent); + + } + + return 0; +} + + +//! adds an element to the environment based on its type name +IGUIElement* CDefaultGUIElementFactory::addGUIElement(const c8* typeName, IGUIElement* parent) +{ + return addGUIElement( getTypeFromName(typeName), parent ); +} + + +//! returns amount of element types this factory is able to create +s32 CDefaultGUIElementFactory::getCreatableGUIElementTypeCount() +{ + return EGUIET_COUNT; +} + + +//! returns type of a createable element type +EGUI_ELEMENT_TYPE CDefaultGUIElementFactory::getCreateableGUIElementType(s32 idx) +{ + if (idx>=0 && idx=0 && idx=0 && typegrab(); - - if (Driver) - Driver->grab(); - -} - - - -//! destructor -CDefaultMeshFormatLoader::~CDefaultMeshFormatLoader() -{ - if (FileSystem) - FileSystem->drop(); - - if (Driver) - Driver->drop(); - -} - - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool CDefaultMeshFormatLoader::isALoadableFileExtension(const c8* filename) -{ - return strstr(filename, ".md2") || strstr(filename, ".b3d") || - strstr(filename, ".ms3d") || strstr(filename, ".bsp") || - strstr(filename, ".shader"); -} - - - -//! creates/loads an animated mesh from the file. -//! \return Pointer to the created mesh. Returns 0 if loading failed. -//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). -//! See IUnknown::drop() for more information. -IAnimatedMesh* CDefaultMeshFormatLoader::createMesh(irr::io::IReadFile* file) -{ - IAnimatedMesh* msh = 0; - - // This method loads a mesh if it cans. - // Someday I will have to refactor this, and split the DefaultMeshFormatloader - // into one loader for every format. - - bool success = false; - - // load quake 2 md2 model - if (strstr(file->getFileName(), ".md2")) - { - msh = new CAnimatedMeshMD2(); - success = ((CAnimatedMeshMD2*)msh)->loadFile(file); - if (success) - return msh; - - msh->drop(); - } - - // load milkshape - if (strstr(file->getFileName(), ".ms3d")) - { - msh = new CAnimatedMeshMS3D(Driver); - success = ((CAnimatedMeshMS3D*)msh)->loadFile(file); - if (success) - return msh; - - msh->drop(); - } - - // load quake 3 bsp - if (strstr(file->getFileName(), ".bsp")) - { - CQ3LevelMesh* q = new CQ3LevelMesh(FileSystem, Driver, SceneManager); - - q->getShader ( "scripts/models.shader", 1 ); - q->getShader ( "scripts/liquid.shader", 1 ); - //q->getShader ( "scripts/sky.shader", 1 ); - - if ( q->loadFile(file) ) - return q; - - q->drop(); - } - - // load quake 3 shader container - if (strstr(file->getFileName(), ".shader")) - { - CQ3LevelMesh* q = new CQ3LevelMesh(FileSystem, Driver, SceneManager); - q->getShader ( file->getFileName(), 1 ); - return q; - } - - // load blitz basic - if (strstr(file->getFileName(), ".b3d")) - { - file->seek(0); - - msh = new CAnimatedMeshB3d(Driver); - success = ((CAnimatedMeshB3d*)msh)->loadFile(file); - if (success) - return msh; - - msh->drop(); - } - - return 0; -} - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CDefaultMeshFormatLoader.h" +#include "CAnimatedMeshMD2.h" +#include "CAnimatedMeshMS3D.h" +#include "CQ3LevelMesh.h" +#include "CAnimatedMeshB3d.h" + +namespace irr +{ +namespace scene +{ + +//! Constructor +CDefaultMeshFormatLoader::CDefaultMeshFormatLoader(io::IFileSystem* fs,video::IVideoDriver* driver, scene::ISceneManager* smgr) +: FileSystem(fs), Driver(driver), SceneManager(smgr) +{ + if (FileSystem) + FileSystem->grab(); + + if (Driver) + Driver->grab(); + +} + + + +//! destructor +CDefaultMeshFormatLoader::~CDefaultMeshFormatLoader() +{ + if (FileSystem) + FileSystem->drop(); + + if (Driver) + Driver->drop(); + +} + + + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".bsp") +bool CDefaultMeshFormatLoader::isALoadableFileExtension(const c8* filename) +{ + return strstr(filename, ".md2") || strstr(filename, ".b3d") || + strstr(filename, ".ms3d") || strstr(filename, ".bsp") || + strstr(filename, ".shader"); +} + + + +//! creates/loads an animated mesh from the file. +//! \return Pointer to the created mesh. Returns 0 if loading failed. +//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). +//! See IUnknown::drop() for more information. +IAnimatedMesh* CDefaultMeshFormatLoader::createMesh(irr::io::IReadFile* file) +{ + IAnimatedMesh* msh = 0; + + // This method loads a mesh if it cans. + // Someday I will have to refactor this, and split the DefaultMeshFormatloader + // into one loader for every format. + + bool success = false; + + // load quake 2 md2 model + if (strstr(file->getFileName(), ".md2")) + { + msh = new CAnimatedMeshMD2(); + success = ((CAnimatedMeshMD2*)msh)->loadFile(file); + if (success) + return msh; + + msh->drop(); + } + + // load milkshape + if (strstr(file->getFileName(), ".ms3d")) + { + msh = new CAnimatedMeshMS3D(Driver); + success = ((CAnimatedMeshMS3D*)msh)->loadFile(file); + if (success) + return msh; + + msh->drop(); + } + + // load quake 3 bsp + if (strstr(file->getFileName(), ".bsp")) + { + CQ3LevelMesh* q = new CQ3LevelMesh(FileSystem, Driver, SceneManager); + + q->getShader ( "scripts/models.shader", 1 ); + q->getShader ( "scripts/liquid.shader", 1 ); + //q->getShader ( "scripts/sky.shader", 1 ); + + if ( q->loadFile(file) ) + return q; + + q->drop(); + } + + // load quake 3 shader container + if (strstr(file->getFileName(), ".shader")) + { + CQ3LevelMesh* q = new CQ3LevelMesh(FileSystem, Driver, SceneManager); + q->getShader ( file->getFileName(), 1 ); + return q; + } + + // load blitz basic + if (strstr(file->getFileName(), ".b3d")) + { + file->seek(0); + + msh = new CAnimatedMeshB3d(Driver); + success = ((CAnimatedMeshB3d*)msh)->loadFile(file); + if (success) + return msh; + + msh->drop(); + } + + return 0; +} + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CDefaultMeshFormatLoader.h b/src/dep/src/irrlicht/CDefaultMeshFormatLoader.h index 6dda26b..6769245 100644 --- a/src/dep/src/irrlicht/CDefaultMeshFormatLoader.h +++ b/src/dep/src/irrlicht/CDefaultMeshFormatLoader.h @@ -1,51 +1,51 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_DEFAULT_MESH_FORMAT_LOADER_H_INCLUDED__ -#define __C_DEFAULT_MESH_FORMAT_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - -//! Meshloader capable of loading all Irrlicht default build in formats. -/** Which are: Quake 3 Bsp level, Quake 2 MD2 model, Milkshape .ms3d model. */ -class CDefaultMeshFormatLoader : public IMeshLoader -{ -public: - - //! Constructor - CDefaultMeshFormatLoader(io::IFileSystem* fs, video::IVideoDriver* driver, scene::ISceneManager* smgr); - - //! destructor - virtual ~CDefaultMeshFormatLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".bsp") - virtual bool isALoadableFileExtension(const c8* fileName); - - //! creates/loads an animated mesh from the file. - //! \return Pointer to the created mesh. Returns 0 if loading failed. - //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). - //! See IUnknown::drop() for more information. - virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); - -private: - - io::IFileSystem* FileSystem; - video::IVideoDriver* Driver; - scene::ISceneManager* SceneManager; -}; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_DEFAULT_MESH_FORMAT_LOADER_H_INCLUDED__ +#define __C_DEFAULT_MESH_FORMAT_LOADER_H_INCLUDED__ + +#include "IMeshLoader.h" +#include "IFileSystem.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" + +namespace irr +{ +namespace scene +{ + +//! Meshloader capable of loading all Irrlicht default build in formats. +/** Which are: Quake 3 Bsp level, Quake 2 MD2 model, Milkshape .ms3d model. */ +class CDefaultMeshFormatLoader : public IMeshLoader +{ +public: + + //! Constructor + CDefaultMeshFormatLoader(io::IFileSystem* fs, video::IVideoDriver* driver, scene::ISceneManager* smgr); + + //! destructor + virtual ~CDefaultMeshFormatLoader(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".bsp") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! creates/loads an animated mesh from the file. + //! \return Pointer to the created mesh. Returns 0 if loading failed. + //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). + //! See IUnknown::drop() for more information. + virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); + +private: + + io::IFileSystem* FileSystem; + video::IVideoDriver* Driver; + scene::ISceneManager* SceneManager; +}; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CDefaultSceneNodeAnimatorFactory.cpp b/src/dep/src/irrlicht/CDefaultSceneNodeAnimatorFactory.cpp index a7ada45..a6c40ca 100644 --- a/src/dep/src/irrlicht/CDefaultSceneNodeAnimatorFactory.cpp +++ b/src/dep/src/irrlicht/CDefaultSceneNodeAnimatorFactory.cpp @@ -1,143 +1,143 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CDefaultSceneNodeAnimatorFactory.h" -#include "ISceneNodeAnimatorCollisionResponse.h" -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - -//! Names for scene node types -const c8* const SceneNodeAnimatorTypeNames[] = -{ - "flyCircle", - "flyStraight", - "followSpline", - "rotation", - "texture", - "deletion", - "collisionResponse", - 0 -}; - - -CDefaultSceneNodeAnimatorFactory::CDefaultSceneNodeAnimatorFactory(ISceneManager* mgr) -: Manager(mgr) -{ - // don't grab the scene manager here to prevent cyclic references -} - - -CDefaultSceneNodeAnimatorFactory::~CDefaultSceneNodeAnimatorFactory() -{ -} - - -//! creates a scene node animator based on its type id -ISceneNodeAnimator* CDefaultSceneNodeAnimatorFactory::createSceneNodeAnimator(ESCENE_NODE_ANIMATOR_TYPE type, ISceneNode* target) -{ - scene::ISceneNodeAnimator* anim = 0; - - switch(type) - { - case ESNAT_FLY_CIRCLE: - anim = Manager->createFlyCircleAnimator(core::vector3df(0,0,0), 10); - break; - case ESNAT_FLY_STRAIGHT: - anim = Manager->createFlyStraightAnimator(core::vector3df(0,0,0), core::vector3df(100,100,100), 10000, true ); - break; - case ESNAT_FOLLOW_SPLINE: - { - core::array points; - points.push_back(core::vector3df(0,0,0)); - points.push_back(core::vector3df(10,5,10)); - anim = Manager->createFollowSplineAnimator(0, points); - } - break; - case ESNAT_ROTATION: - anim = Manager->createRotationAnimator(core::vector3df(0.3f,0,0)); - break; - case ESNAT_TEXTURE: - { - core::array textures; - anim = Manager->createTextureAnimator(textures, 250); - } - break; - case ESNAT_DELETION: - anim = Manager->createDeleteAnimator(5000); - break; - case ESNAT_COLLISION_RESPONSE: - anim = Manager->createCollisionResponseAnimator(0, target); - break; - default: - break; - } - - if (anim && target) - target->addAnimator(anim); - - return anim; -} - - -//! creates a scene node animator based on its type name -ISceneNodeAnimator* CDefaultSceneNodeAnimatorFactory::createSceneNodeAnimator(const c8* typeName, ISceneNode* target) -{ - return createSceneNodeAnimator( getTypeFromName(typeName), target ); -} - - -//! returns amount of scene node animator types this factory is able to create -s32 CDefaultSceneNodeAnimatorFactory::getCreatableSceneNodeAnimatorTypeCount() -{ - return ESNAT_COUNT; -} - - -//! returns type of a createable scene node animator type -ESCENE_NODE_ANIMATOR_TYPE CDefaultSceneNodeAnimatorFactory::getCreateableSceneNodeAnimatorType(s32 idx) -{ - if (idx>=0 && idx=0 && idx=0 && typecreateFlyCircleAnimator(core::vector3df(0,0,0), 10); + break; + case ESNAT_FLY_STRAIGHT: + anim = Manager->createFlyStraightAnimator(core::vector3df(0,0,0), core::vector3df(100,100,100), 10000, true ); + break; + case ESNAT_FOLLOW_SPLINE: + { + core::array points; + points.push_back(core::vector3df(0,0,0)); + points.push_back(core::vector3df(10,5,10)); + anim = Manager->createFollowSplineAnimator(0, points); + } + break; + case ESNAT_ROTATION: + anim = Manager->createRotationAnimator(core::vector3df(0.3f,0,0)); + break; + case ESNAT_TEXTURE: + { + core::array textures; + anim = Manager->createTextureAnimator(textures, 250); + } + break; + case ESNAT_DELETION: + anim = Manager->createDeleteAnimator(5000); + break; + case ESNAT_COLLISION_RESPONSE: + anim = Manager->createCollisionResponseAnimator(0, target); + break; + default: + break; + } + + if (anim && target) + target->addAnimator(anim); + + return anim; +} + + +//! creates a scene node animator based on its type name +ISceneNodeAnimator* CDefaultSceneNodeAnimatorFactory::createSceneNodeAnimator(const c8* typeName, ISceneNode* target) +{ + return createSceneNodeAnimator( getTypeFromName(typeName), target ); +} + + +//! returns amount of scene node animator types this factory is able to create +s32 CDefaultSceneNodeAnimatorFactory::getCreatableSceneNodeAnimatorTypeCount() +{ + return ESNAT_COUNT; +} + + +//! returns type of a createable scene node animator type +ESCENE_NODE_ANIMATOR_TYPE CDefaultSceneNodeAnimatorFactory::getCreateableSceneNodeAnimatorType(s32 idx) +{ + if (idx>=0 && idx=0 && idx=0 && typeaddCubeSceneNode(10, parent); - case ESNT_SPHERE: - return Manager->addSphereSceneNode(5, 16, parent); - case ESNT_TEXT: - return Manager->addTextSceneNode(0, L"example"); - case ESNT_WATER_SURFACE: - return Manager->addWaterSurfaceSceneNode(0, 2.0f, 300.0f, 10.0f, parent); - case ESNT_TERRAIN: - return Manager->addTerrainSceneNode((const char*)0, parent); - case ESNT_SKY_BOX: - return Manager->addSkyBoxSceneNode(0,0,0,0,0,0, parent); - case ESNT_SHADOW_VOLUME: - return 0; - case ESNT_OCT_TREE: - return Manager->addOctTreeSceneNode((IMesh*)0, parent, -1, 128, true); - case ESNT_MESH: - return Manager->addMeshSceneNode(0, parent, -1, core::vector3df(), - core::vector3df(), core::vector3df(1,1,1), true); - case ESNT_LIGHT: - return Manager->addLightSceneNode(parent); - case ESNT_EMPTY: - return Manager->addEmptySceneNode(parent); - case ESNT_DUMMY_TRANSFORMATION: - return Manager->addDummyTransformationSceneNode(parent); - case ESNT_CAMERA: - return Manager->addCameraSceneNode(parent); - case ESNT_CAMERA_MAYA: - return Manager->addCameraSceneNodeMaya(parent); - case ESNT_CAMERA_FPS: - return Manager->addCameraSceneNodeFPS(parent); - case ESNT_BILLBOARD: - return Manager->addBillboardSceneNode(parent); - case ESNT_ANIMATED_MESH: - return Manager->addAnimatedMeshSceneNode(0, parent, -1, core::vector3df(), - core::vector3df(), core::vector3df(1,1,1), true); - case ESNT_PARTICLE_SYSTEM: - return Manager->addParticleSystemSceneNode(true, parent); - default: - break; - } - - return 0; -} - - -//! adds a scene node to the scene graph based on its type name -ISceneNode* CDefaultSceneNodeFactory::addSceneNode(const c8* typeName, ISceneNode* parent) -{ - return addSceneNode( getTypeFromName(typeName), parent ); -} - - -//! returns amount of scene node types this factory is able to create -s32 CDefaultSceneNodeFactory::getCreatableSceneNodeTypeCount() -{ - return ESNT_COUNT; -} - - -//! returns type of a createable scene node type -ESCENE_NODE_TYPE CDefaultSceneNodeFactory::getCreateableSceneNodeType(s32 idx) -{ - if (idx>=0 && idx=0 && idx=0 && typeaddCubeSceneNode(10, parent); + case ESNT_SPHERE: + return Manager->addSphereSceneNode(5, 16, parent); + case ESNT_TEXT: + return Manager->addTextSceneNode(0, L"example"); + case ESNT_WATER_SURFACE: + return Manager->addWaterSurfaceSceneNode(0, 2.0f, 300.0f, 10.0f, parent); + case ESNT_TERRAIN: + return Manager->addTerrainSceneNode((const char*)0, parent); + case ESNT_SKY_BOX: + return Manager->addSkyBoxSceneNode(0,0,0,0,0,0, parent); + case ESNT_SHADOW_VOLUME: + return 0; + case ESNT_OCT_TREE: + return Manager->addOctTreeSceneNode((IMesh*)0, parent, -1, 128, true); + case ESNT_MESH: + return Manager->addMeshSceneNode(0, parent, -1, core::vector3df(), + core::vector3df(), core::vector3df(1,1,1), true); + case ESNT_LIGHT: + return Manager->addLightSceneNode(parent); + case ESNT_EMPTY: + return Manager->addEmptySceneNode(parent); + case ESNT_DUMMY_TRANSFORMATION: + return Manager->addDummyTransformationSceneNode(parent); + case ESNT_CAMERA: + return Manager->addCameraSceneNode(parent); + case ESNT_CAMERA_MAYA: + return Manager->addCameraSceneNodeMaya(parent); + case ESNT_CAMERA_FPS: + return Manager->addCameraSceneNodeFPS(parent); + case ESNT_BILLBOARD: + return Manager->addBillboardSceneNode(parent); + case ESNT_ANIMATED_MESH: + return Manager->addAnimatedMeshSceneNode(0, parent, -1, core::vector3df(), + core::vector3df(), core::vector3df(1,1,1), true); + case ESNT_PARTICLE_SYSTEM: + return Manager->addParticleSystemSceneNode(true, parent); + default: + break; + } + + return 0; +} + + +//! adds a scene node to the scene graph based on its type name +ISceneNode* CDefaultSceneNodeFactory::addSceneNode(const c8* typeName, ISceneNode* parent) +{ + return addSceneNode( getTypeFromName(typeName), parent ); +} + + +//! returns amount of scene node types this factory is able to create +s32 CDefaultSceneNodeFactory::getCreatableSceneNodeTypeCount() +{ + return ESNT_COUNT; +} + + +//! returns type of a createable scene node type +ESCENE_NODE_TYPE CDefaultSceneNodeFactory::getCreateableSceneNodeType(s32 idx) +{ + if (idx>=0 && idx=0 && idx=0 && type& size) -: Buffer(0), Size(0,0) -{ - #ifdef _DEBUG - setDebugName("CDepthBuffer"); - #endif - - setSize(size); -} - - - -//! destructor -CDepthBuffer::~CDepthBuffer() -{ - if (Buffer) - delete [] Buffer; -} - - - -//! clears the zbuffer -void CDepthBuffer::clear() -{ - -#ifdef SOFTWARE_DRIVER_2_USE_WBUFFER - f32 zMax = 0.f; -#else - f32 zMax = 1.f; -#endif - - u32 zMaxValue; - zMaxValue = *(u32*) &zMax; - - memset32 ( Buffer, zMaxValue, TotalSize ); -} - - - -//! sets the new size of the zbuffer -void CDepthBuffer::setSize(const core::dimension2d& size) -{ - if (size == Size) - return; - - Size = size; - - if (Buffer) - delete [] Buffer; - - TotalSize = size.Width * size.Height * sizeof ( fp24 ); - Buffer = new u8[TotalSize]; -} - - - -//! returns the size of the zbuffer -const core::dimension2d& CDepthBuffer::getSize() -{ - return Size; -} - - - -//! locks the zbuffer -fp24* CDepthBuffer::lock() -{ - return (fp24*) Buffer; -} - - - -//! unlocks the zbuffer -void CDepthBuffer::unlock() -{ -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a ZBuffer -IDepthBuffer* createDepthBuffer(const core::dimension2d& size) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CDepthBuffer(size); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - -} // end namespace video -} // end namespace irr - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "SoftwareDriver2_compile_config.h" +#include "CDepthBuffer.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + + + +//! constructor +CDepthBuffer::CDepthBuffer(const core::dimension2d& size) +: Buffer(0), Size(0,0) +{ + #ifdef _DEBUG + setDebugName("CDepthBuffer"); + #endif + + setSize(size); +} + + + +//! destructor +CDepthBuffer::~CDepthBuffer() +{ + if (Buffer) + delete [] Buffer; +} + + + +//! clears the zbuffer +void CDepthBuffer::clear() +{ + +#ifdef SOFTWARE_DRIVER_2_USE_WBUFFER + f32 zMax = 0.f; +#else + f32 zMax = 1.f; +#endif + + u32 zMaxValue; + zMaxValue = *(u32*) &zMax; + + memset32 ( Buffer, zMaxValue, TotalSize ); +} + + + +//! sets the new size of the zbuffer +void CDepthBuffer::setSize(const core::dimension2d& size) +{ + if (size == Size) + return; + + Size = size; + + if (Buffer) + delete [] Buffer; + + TotalSize = size.Width * size.Height * sizeof ( fp24 ); + Buffer = new u8[TotalSize]; +} + + + +//! returns the size of the zbuffer +const core::dimension2d& CDepthBuffer::getSize() +{ + return Size; +} + + + +//! locks the zbuffer +fp24* CDepthBuffer::lock() +{ + return (fp24*) Buffer; +} + + + +//! unlocks the zbuffer +void CDepthBuffer::unlock() +{ +} + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a ZBuffer +IDepthBuffer* createDepthBuffer(const core::dimension2d& size) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CDepthBuffer(size); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + +} // end namespace video +} // end namespace irr + + + diff --git a/src/dep/src/irrlicht/CDepthBuffer.h b/src/dep/src/irrlicht/CDepthBuffer.h index 0e35d9a..ce7e17d 100644 --- a/src/dep/src/irrlicht/CDepthBuffer.h +++ b/src/dep/src/irrlicht/CDepthBuffer.h @@ -1,51 +1,51 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_Z_BUFFER_H_INCLUDED__ -#define __C_Z_BUFFER_H_INCLUDED__ - -#include "IDepthBuffer.h" - -namespace irr -{ -namespace video -{ - - class CDepthBuffer : public IDepthBuffer - { - public: - - //! constructor - CDepthBuffer(const core::dimension2d& size); - - //! destructor - virtual ~CDepthBuffer(); - - //! clears the zbuffer - virtual void clear(); - - //! sets the new size of the zbuffer - virtual void setSize(const core::dimension2d& size); - - //! returns the size of the zbuffer - virtual const core::dimension2d& getSize(); - - //! locks the zbuffer - virtual fp24* lock(); - - //! unlocks the zbuffer - virtual void unlock(); - - private: - - u8* Buffer; - core::dimension2d Size; - u32 TotalSize; - }; - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_Z_BUFFER_H_INCLUDED__ +#define __C_Z_BUFFER_H_INCLUDED__ + +#include "IDepthBuffer.h" + +namespace irr +{ +namespace video +{ + + class CDepthBuffer : public IDepthBuffer + { + public: + + //! constructor + CDepthBuffer(const core::dimension2d& size); + + //! destructor + virtual ~CDepthBuffer(); + + //! clears the zbuffer + virtual void clear(); + + //! sets the new size of the zbuffer + virtual void setSize(const core::dimension2d& size); + + //! returns the size of the zbuffer + virtual const core::dimension2d& getSize(); + + //! locks the zbuffer + virtual fp24* lock(); + + //! unlocks the zbuffer + virtual void unlock(); + + private: + + u8* Buffer; + core::dimension2d Size; + u32 TotalSize; + }; + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CDummyTransformationSceneNode.cpp b/src/dep/src/irrlicht/CDummyTransformationSceneNode.cpp index 2aee01e..3c37f28 100644 --- a/src/dep/src/irrlicht/CDummyTransformationSceneNode.cpp +++ b/src/dep/src/irrlicht/CDummyTransformationSceneNode.cpp @@ -1,59 +1,59 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CDummyTransformationSceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CDummyTransformationSceneNode::CDummyTransformationSceneNode( - ISceneNode* parent, ISceneManager* mgr, s32 id) - : IDummyTransformationSceneNode(parent, mgr, id) -{ - #ifdef _DEBUG - setDebugName("CDummyTransformationSceneNode"); - #endif - - setAutomaticCulling(scene::EAC_OFF); -} - - - -//! destructor -CDummyTransformationSceneNode::~CDummyTransformationSceneNode() -{ -} - - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CDummyTransformationSceneNode::getBoundingBox() const -{ - return Box; -} - - - -//! Returns a reference to the current relative transformation matrix. -//! This is the matrix, this scene node uses instead of scale, translation -//! and rotation. -core::matrix4& CDummyTransformationSceneNode::getRelativeTransformationMatrix() -{ - return RelativeTransformationMatrix; -} - - -//! Returns the relative transformation of the scene node. -core::matrix4 CDummyTransformationSceneNode::getRelativeTransformation() const -{ - return RelativeTransformationMatrix; -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CDummyTransformationSceneNode.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CDummyTransformationSceneNode::CDummyTransformationSceneNode( + ISceneNode* parent, ISceneManager* mgr, s32 id) + : IDummyTransformationSceneNode(parent, mgr, id) +{ + #ifdef _DEBUG + setDebugName("CDummyTransformationSceneNode"); + #endif + + setAutomaticCulling(scene::EAC_OFF); +} + + + +//! destructor +CDummyTransformationSceneNode::~CDummyTransformationSceneNode() +{ +} + + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CDummyTransformationSceneNode::getBoundingBox() const +{ + return Box; +} + + + +//! Returns a reference to the current relative transformation matrix. +//! This is the matrix, this scene node uses instead of scale, translation +//! and rotation. +core::matrix4& CDummyTransformationSceneNode::getRelativeTransformationMatrix() +{ + return RelativeTransformationMatrix; +} + + +//! Returns the relative transformation of the scene node. +core::matrix4 CDummyTransformationSceneNode::getRelativeTransformation() const +{ + return RelativeTransformationMatrix; +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CDummyTransformationSceneNode.h b/src/dep/src/irrlicht/CDummyTransformationSceneNode.h index ac8103d..c7deae6 100644 --- a/src/dep/src/irrlicht/CDummyTransformationSceneNode.h +++ b/src/dep/src/irrlicht/CDummyTransformationSceneNode.h @@ -1,52 +1,52 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_DUMMY_TRANSFORMATION_SCENE_NODE_H_INCLUDED__ -#define __C_DUMMY_TRANSFORMATION_SCENE_NODE_H_INCLUDED__ - -#include "IDummyTransformationSceneNode.h" - -namespace irr -{ -namespace scene -{ - - class CDummyTransformationSceneNode : public IDummyTransformationSceneNode - { - public: - - //! constructor - CDummyTransformationSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id); - - //! destructor - ~CDummyTransformationSceneNode(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! Returns a reference to the current relative transformation matrix. - //! This is the matrix, this scene node uses instead of scale, translation - //! and rotation. - virtual core::matrix4& getRelativeTransformationMatrix(); - - //! Returns the relative transformation of the scene node. - virtual core::matrix4 getRelativeTransformation() const; - - //! does nothing. - virtual void render() {}; - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_DUMMY_TRANSFORMATION; } - - private: - - core::matrix4 RelativeTransformationMatrix; - core::aabbox3d Box; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_DUMMY_TRANSFORMATION_SCENE_NODE_H_INCLUDED__ +#define __C_DUMMY_TRANSFORMATION_SCENE_NODE_H_INCLUDED__ + +#include "IDummyTransformationSceneNode.h" + +namespace irr +{ +namespace scene +{ + + class CDummyTransformationSceneNode : public IDummyTransformationSceneNode + { + public: + + //! constructor + CDummyTransformationSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id); + + //! destructor + ~CDummyTransformationSceneNode(); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! Returns a reference to the current relative transformation matrix. + //! This is the matrix, this scene node uses instead of scale, translation + //! and rotation. + virtual core::matrix4& getRelativeTransformationMatrix(); + + //! Returns the relative transformation of the scene node. + virtual core::matrix4 getRelativeTransformation() const; + + //! does nothing. + virtual void render() {}; + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_DUMMY_TRANSFORMATION; } + + private: + + core::matrix4 RelativeTransformationMatrix; + core::aabbox3d Box; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CEmptySceneNode.cpp b/src/dep/src/irrlicht/CEmptySceneNode.cpp index 75b8f23..71e5457 100644 --- a/src/dep/src/irrlicht/CEmptySceneNode.cpp +++ b/src/dep/src/irrlicht/CEmptySceneNode.cpp @@ -1,51 +1,51 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CEmptySceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CEmptySceneNode::CEmptySceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id) -: ISceneNode(parent, mgr, id) -{ - #ifdef _DEBUG - setDebugName("CEmptySceneNode"); - #endif - - setAutomaticCulling(scene::EAC_OFF); -} - - -//! pre render event -void CEmptySceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - SceneManager->registerNodeForRendering(this); - ISceneNode::OnRegisterSceneNode(); - } -} - - -//! render -void CEmptySceneNode::render() -{ - // do nothing -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CEmptySceneNode::getBoundingBox() const -{ - return Box; -} - -} // end namespace scene -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CEmptySceneNode.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CEmptySceneNode::CEmptySceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id) +: ISceneNode(parent, mgr, id) +{ + #ifdef _DEBUG + setDebugName("CEmptySceneNode"); + #endif + + setAutomaticCulling(scene::EAC_OFF); +} + + +//! pre render event +void CEmptySceneNode::OnRegisterSceneNode() +{ + if (IsVisible) + { + SceneManager->registerNodeForRendering(this); + ISceneNode::OnRegisterSceneNode(); + } +} + + +//! render +void CEmptySceneNode::render() +{ + // do nothing +} + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CEmptySceneNode::getBoundingBox() const +{ + return Box; +} + +} // end namespace scene +} // end namespace irr diff --git a/src/dep/src/irrlicht/CEmptySceneNode.h b/src/dep/src/irrlicht/CEmptySceneNode.h index 05ca477..54fc079 100644 --- a/src/dep/src/irrlicht/CEmptySceneNode.h +++ b/src/dep/src/irrlicht/CEmptySceneNode.h @@ -1,43 +1,43 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_EMPTY_SCENE_NODE_H_INCLUDED__ -#define __C_EMPTY_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - - class CEmptySceneNode : public ISceneNode - { - public: - - //! constructor - CEmptySceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! This method is called just before the rendering process of the whole scene. - virtual void OnRegisterSceneNode(); - - //! does nothing. - virtual void render(); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_EMPTY; } - - private: - - core::aabbox3d Box; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_EMPTY_SCENE_NODE_H_INCLUDED__ +#define __C_EMPTY_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + + class CEmptySceneNode : public ISceneNode + { + public: + + //! constructor + CEmptySceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! This method is called just before the rendering process of the whole scene. + virtual void OnRegisterSceneNode(); + + //! does nothing. + virtual void render(); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_EMPTY; } + + private: + + core::aabbox3d Box; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CFPSCounter.cpp b/src/dep/src/irrlicht/CFPSCounter.cpp index e08d710..00ff300 100644 --- a/src/dep/src/irrlicht/CFPSCounter.cpp +++ b/src/dep/src/irrlicht/CFPSCounter.cpp @@ -1,67 +1,67 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CFPSCounter.h" -#include "irrMath.h" - -namespace irr -{ -namespace video -{ - - -CFPSCounter::CFPSCounter() -: FPS(60), Primitive(0), StartTime(0), FramesCounted(0), - PrimitivesCounted(0), PrimitiveAverage(0) -{ - -} - - - -//! returns current fps -s32 CFPSCounter::getFPS() -{ - return FPS; -} - -//! returns current primitive count -u32 CFPSCounter::getPrimitive() -{ - return Primitive; -} - - -u32 CFPSCounter::getPrimitiveAverage() -{ - return PrimitiveAverage; -} - - -//! to be called every frame -void CFPSCounter::registerFrame(u32 now, u32 primitivesDrawn ) -{ - ++FramesCounted; - Primitive += primitivesDrawn; - PrimitivesCounted += primitivesDrawn; - - u32 milliseconds = now - StartTime; - - if (milliseconds >= 1500 ) - { - f32 invMilli = core::reciprocal ( (f32) milliseconds ); - - FPS = core::ceil32 ( ( 1000 * FramesCounted ) * invMilli ); - PrimitiveAverage = core::ceil32 ( ( 1000 * PrimitivesCounted ) * invMilli ); - - FramesCounted = 0; - PrimitivesCounted = 0; - StartTime = now; - } -} - - -} // end namespace video -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CFPSCounter.h" +#include "irrMath.h" + +namespace irr +{ +namespace video +{ + + +CFPSCounter::CFPSCounter() +: FPS(60), Primitive(0), StartTime(0), FramesCounted(0), + PrimitivesCounted(0), PrimitiveAverage(0) +{ + +} + + + +//! returns current fps +s32 CFPSCounter::getFPS() +{ + return FPS; +} + +//! returns current primitive count +u32 CFPSCounter::getPrimitive() +{ + return Primitive; +} + + +u32 CFPSCounter::getPrimitiveAverage() +{ + return PrimitiveAverage; +} + + +//! to be called every frame +void CFPSCounter::registerFrame(u32 now, u32 primitivesDrawn ) +{ + ++FramesCounted; + Primitive += primitivesDrawn; + PrimitivesCounted += primitivesDrawn; + + u32 milliseconds = now - StartTime; + + if (milliseconds >= 1500 ) + { + f32 invMilli = core::reciprocal ( (f32) milliseconds ); + + FPS = core::ceil32 ( ( 1000 * FramesCounted ) * invMilli ); + PrimitiveAverage = core::ceil32 ( ( 1000 * PrimitivesCounted ) * invMilli ); + + FramesCounted = 0; + PrimitivesCounted = 0; + StartTime = now; + } +} + + +} // end namespace video +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CFPSCounter.h b/src/dep/src/irrlicht/CFPSCounter.h index 89ab99b..677e803 100644 --- a/src/dep/src/irrlicht/CFPSCounter.h +++ b/src/dep/src/irrlicht/CFPSCounter.h @@ -1,50 +1,50 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_FPSCOUNTER_H_INCLUDED__ -#define __C_FPSCOUNTER_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr -{ -namespace video -{ - - -class CFPSCounter -{ -public: - CFPSCounter(); - - //! returns current fps - s32 getFPS(); - - //! returns primitive count - u32 getPrimitive(); - - //! returns average primitive count - u32 getPrimitiveAverage(); - - //! to be called every frame - void registerFrame(u32 now, u32 primitive); - -private: - - s32 FPS; - u32 Primitive; - u32 StartTime; - - u32 FramesCounted; - u32 PrimitivesCounted; - u32 PrimitiveAverage; -}; - - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_FPSCOUNTER_H_INCLUDED__ +#define __C_FPSCOUNTER_H_INCLUDED__ + +#include "irrTypes.h" + +namespace irr +{ +namespace video +{ + + +class CFPSCounter +{ +public: + CFPSCounter(); + + //! returns current fps + s32 getFPS(); + + //! returns primitive count + u32 getPrimitive(); + + //! returns average primitive count + u32 getPrimitiveAverage(); + + //! to be called every frame + void registerFrame(u32 now, u32 primitive); + +private: + + s32 FPS; + u32 Primitive; + u32 StartTime; + + u32 FramesCounted; + u32 PrimitivesCounted; + u32 PrimitiveAverage; +}; + + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CFileList.cpp b/src/dep/src/irrlicht/CFileList.cpp index 1e71985..74518c7 100644 --- a/src/dep/src/irrlicht/CFileList.cpp +++ b/src/dep/src/irrlicht/CFileList.cpp @@ -1,181 +1,181 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CFileList.h" -#include "IrrCompileConfig.h" -#include "irrArray.h" -#include - -namespace irr -{ -namespace io -{ - -#if (defined(LINUX) || defined(MACOSX)) -#include -#include -#include - -#include -#include -#include -#include -#endif - -#ifdef _IRR_WINDOWS_ -#include -#include -#endif - - -CFileList::CFileList() -{ - // -------------------------------------------- - // Windows version - #ifdef _IRR_WINDOWS_ - - char tmp[_MAX_PATH]; - _getcwd(tmp, _MAX_PATH); - Path = tmp; - - struct _finddata_t c_file; - long hFile; - FileEntry entry; - - if( (hFile = _findfirst( "*", &c_file )) != -1L ) - { - do - { - entry.Name = c_file.name; - entry.Size = c_file.size; - entry.isDirectory = (_A_SUBDIR & c_file.attrib) != 0; - Files.push_back(entry); - } - while( _findnext( hFile, &c_file ) == 0 ); - - _findclose( hFile ); - } - - //TODO add drives - //entry.Name = "E:\\"; - //entry.isDirectory = true; - //Files.push_back(entry); - #endif - - // -------------------------------------------- - // Linux version - #if (defined(LINUX) || defined(MACOSX)) - - FileEntry entry; - - // Add default parent - even when at /, this is available - entry.Name = ".."; - entry.Size = 0; - entry.isDirectory = true; - Files.push_back(entry); - - // getting the CWD is rather complex as we do not know the size - // so try it until the call was successful - // Note that neither the first nor the second parameter may be 0 according to POSIX - u32 pathSize=256; - char *tmpPath = new char[pathSize]; - while ((pathSize < (1<<16)) && !(getcwd(tmpPath,pathSize))) - { - delete [] tmpPath; - pathSize *= 2; - tmpPath = new char[pathSize]; - } - if (!tmpPath) - return; - Path = tmpPath; - delete [] tmpPath; - // We use the POSIX compliant methods instead of scandir - DIR* dirHandle=opendir(Path.c_str()); - if (!dirHandle) - return; - - struct dirent *dirEntry; - while ((dirEntry=readdir(dirHandle))) - { - if((strcmp(dirEntry->d_name, ".")==0) || - (strcmp(dirEntry->d_name, "..")==0)) - continue; - entry.Name = dirEntry->d_name; - entry.Size = 0; - entry.isDirectory = false; - struct stat buf; - if (stat(dirEntry->d_name, &buf)==0) - { - entry.Size = buf.st_size; - entry.isDirectory = S_ISDIR(buf.st_mode); - } - #if !defined(__sun__) && !defined(__CYGWIN__) - // only available on some systems - else - { - entry.isDirectory = dirEntry->d_type == DT_DIR; - } - #endif - Files.push_back(entry); - } - closedir(dirHandle); - #endif - // sort the list on all platforms - Files.sort(); -} - - -CFileList::~CFileList() -{ -} - - -s32 CFileList::getFileCount() -{ - return Files.size(); -} - - -const c8* CFileList::getFileName(s32 index) -{ - if (index < 0 || index > (s32)Files.size()) - return 0; - - return Files[index].Name.c_str(); -} - - -//! Gets the full name of a file in the list, path included, based on an index. -const c8* CFileList::getFullFileName(s32 index) -{ - if (index < 0 || index > (s32)Files.size()) - return 0; - - if (Files[index].FullName.size() < Files[index].Name.size()) - { - // create full name - Files[index].FullName = Path; - - if (Path.size() > 3) - Files[index].FullName.append('/'); - - Files[index].FullName.append(Files[index].Name); - } - - return Files[index].FullName.c_str(); -} - - -bool CFileList::isDirectory(s32 index) -{ - if (index < 0 || index > (s32)Files.size()) - return false; - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Files[index].isDirectory; -} - -} // end namespace irr -} // end namespace io - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CFileList.h" +#include "IrrCompileConfig.h" +#include "irrArray.h" +#include + +namespace irr +{ +namespace io +{ + +#if (defined(LINUX) || defined(MACOSX)) +#include +#include +#include + +#include +#include +#include +#include +#endif + +#ifdef _IRR_WINDOWS_ +#include +#include +#endif + + +CFileList::CFileList() +{ + // -------------------------------------------- + // Windows version + #ifdef _IRR_WINDOWS_ + + char tmp[_MAX_PATH]; + _getcwd(tmp, _MAX_PATH); + Path = tmp; + + struct _finddata_t c_file; + long hFile; + FileEntry entry; + + if( (hFile = _findfirst( "*", &c_file )) != -1L ) + { + do + { + entry.Name = c_file.name; + entry.Size = c_file.size; + entry.isDirectory = (_A_SUBDIR & c_file.attrib) != 0; + Files.push_back(entry); + } + while( _findnext( hFile, &c_file ) == 0 ); + + _findclose( hFile ); + } + + //TODO add drives + //entry.Name = "E:\\"; + //entry.isDirectory = true; + //Files.push_back(entry); + #endif + + // -------------------------------------------- + // Linux version + #if (defined(LINUX) || defined(MACOSX)) + + FileEntry entry; + + // Add default parent - even when at /, this is available + entry.Name = ".."; + entry.Size = 0; + entry.isDirectory = true; + Files.push_back(entry); + + // getting the CWD is rather complex as we do not know the size + // so try it until the call was successful + // Note that neither the first nor the second parameter may be 0 according to POSIX + u32 pathSize=256; + char *tmpPath = new char[pathSize]; + while ((pathSize < (1<<16)) && !(getcwd(tmpPath,pathSize))) + { + delete [] tmpPath; + pathSize *= 2; + tmpPath = new char[pathSize]; + } + if (!tmpPath) + return; + Path = tmpPath; + delete [] tmpPath; + // We use the POSIX compliant methods instead of scandir + DIR* dirHandle=opendir(Path.c_str()); + if (!dirHandle) + return; + + struct dirent *dirEntry; + while ((dirEntry=readdir(dirHandle))) + { + if((strcmp(dirEntry->d_name, ".")==0) || + (strcmp(dirEntry->d_name, "..")==0)) + continue; + entry.Name = dirEntry->d_name; + entry.Size = 0; + entry.isDirectory = false; + struct stat buf; + if (stat(dirEntry->d_name, &buf)==0) + { + entry.Size = buf.st_size; + entry.isDirectory = S_ISDIR(buf.st_mode); + } + #if !defined(__sun__) && !defined(__CYGWIN__) + // only available on some systems + else + { + entry.isDirectory = dirEntry->d_type == DT_DIR; + } + #endif + Files.push_back(entry); + } + closedir(dirHandle); + #endif + // sort the list on all platforms + Files.sort(); +} + + +CFileList::~CFileList() +{ +} + + +s32 CFileList::getFileCount() +{ + return Files.size(); +} + + +const c8* CFileList::getFileName(s32 index) +{ + if (index < 0 || index > (s32)Files.size()) + return 0; + + return Files[index].Name.c_str(); +} + + +//! Gets the full name of a file in the list, path included, based on an index. +const c8* CFileList::getFullFileName(s32 index) +{ + if (index < 0 || index > (s32)Files.size()) + return 0; + + if (Files[index].FullName.size() < Files[index].Name.size()) + { + // create full name + Files[index].FullName = Path; + + if (Path.size() > 3) + Files[index].FullName.append('/'); + + Files[index].FullName.append(Files[index].Name); + } + + return Files[index].FullName.c_str(); +} + + +bool CFileList::isDirectory(s32 index) +{ + if (index < 0 || index > (s32)Files.size()) + return false; + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return Files[index].isDirectory; +} + +} // end namespace irr +} // end namespace io + diff --git a/src/dep/src/irrlicht/CFileList.h b/src/dep/src/irrlicht/CFileList.h index bd04dc1..ddfc84d 100644 --- a/src/dep/src/irrlicht/CFileList.h +++ b/src/dep/src/irrlicht/CFileList.h @@ -1,81 +1,81 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_FILE_LIST_H_INCLUDED__ -#define __C_FILE_LIST_H_INCLUDED__ - -#include "IFileList.h" -#include "irrString.h" -#include "irrArray.h" - -namespace irr -{ -namespace io -{ - -/*! - FileSystem, which manages where files are, so that modules which - use the the io do not need to know where every file is located. -*/ -class CFileList : public IFileList -{ -public: - - //! constructor - CFileList(); - - //! destructor - virtual ~CFileList(); - - //! Returns the amount of files in the filelist. - //! \return - //! Returns the amount of files and directories in the file list. - virtual s32 getFileCount(); - - //! Gets the name of a file in the list, based on an index. - //! \param index is the zero based index of the file which name should - //! be returned. The index has to be smaller than the amount getFileCount() returns. - //! \return - //! Returns the file name of the file. Returns 0, if an error occured. - virtual const c8* getFileName(s32 index); - - //! Gets the full name of a file in the list, path included, based on an index. - virtual const c8* getFullFileName(s32 index); - - //! Returns of the file is a directory - //! \param index is the zero based index of the file which name should - //! be returned. The index has to be smaller than the amount getFileCount() returns. - //! \return - //! Returns true, if the file is a directory, and false, if it is not. - //! If an error occurs, the result is undefined. - virtual bool isDirectory(s32 index); - -private: - - struct FileEntry - { - core::stringc Name; - core::stringc FullName; - s32 Size; - bool isDirectory; - - bool operator <(const struct FileEntry& other) const - { - if ( isDirectory ^ other.isDirectory ) - return isDirectory; - - return Name.lower_ignore_case ( other.Name ); - } - }; - - core::stringc Path; - core::array< FileEntry > Files; -}; - -} // end namespace irr -} // end namespace io - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_FILE_LIST_H_INCLUDED__ +#define __C_FILE_LIST_H_INCLUDED__ + +#include "IFileList.h" +#include "irrString.h" +#include "irrArray.h" + +namespace irr +{ +namespace io +{ + +/*! + FileSystem, which manages where files are, so that modules which + use the the io do not need to know where every file is located. +*/ +class CFileList : public IFileList +{ +public: + + //! constructor + CFileList(); + + //! destructor + virtual ~CFileList(); + + //! Returns the amount of files in the filelist. + //! \return + //! Returns the amount of files and directories in the file list. + virtual s32 getFileCount(); + + //! Gets the name of a file in the list, based on an index. + //! \param index is the zero based index of the file which name should + //! be returned. The index has to be smaller than the amount getFileCount() returns. + //! \return + //! Returns the file name of the file. Returns 0, if an error occured. + virtual const c8* getFileName(s32 index); + + //! Gets the full name of a file in the list, path included, based on an index. + virtual const c8* getFullFileName(s32 index); + + //! Returns of the file is a directory + //! \param index is the zero based index of the file which name should + //! be returned. The index has to be smaller than the amount getFileCount() returns. + //! \return + //! Returns true, if the file is a directory, and false, if it is not. + //! If an error occurs, the result is undefined. + virtual bool isDirectory(s32 index); + +private: + + struct FileEntry + { + core::stringc Name; + core::stringc FullName; + s32 Size; + bool isDirectory; + + bool operator <(const struct FileEntry& other) const + { + if ( isDirectory ^ other.isDirectory ) + return isDirectory; + + return Name.lower_ignore_case ( other.Name ); + } + }; + + core::stringc Path; + core::array< FileEntry > Files; +}; + +} // end namespace irr +} // end namespace io + + +#endif + diff --git a/src/dep/src/irrlicht/CFileSystem.cpp b/src/dep/src/irrlicht/CFileSystem.cpp index 0edf2e0..697631a 100644 --- a/src/dep/src/irrlicht/CFileSystem.cpp +++ b/src/dep/src/irrlicht/CFileSystem.cpp @@ -1,352 +1,352 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CFileSystem.h" -#include "IReadFile.h" -#include "IWriteFile.h" -#include "CZipReader.h" -#include "CPakReader.h" -#include "CFileList.h" -#include "CXMLReader.h" -#include "CXMLWriter.h" -#include "stdio.h" -#include "os.h" -#include "IrrCompileConfig.h" -#include "CAttributes.h" -#include "CMemoryReadFile.h" - -#ifdef _IRR_WINDOWS_ -#include // for _chdir -#endif - -#if (defined(LINUX) || defined(MACOSX)) -#include -#include -#include -#endif - -namespace irr -{ -namespace io -{ - - -//! constructor -CFileSystem::CFileSystem() -{ - #ifdef _DEBUG - setDebugName("CFileSystem"); - #endif -} - - - -//! destructor -CFileSystem::~CFileSystem() -{ - u32 i; - - for ( i=0; idrop(); - - for ( i=0; idrop(); - - for ( i= 0; idrop(); -} - - - -//! opens a file for read access -IReadFile* CFileSystem::createAndOpenFile(const c8* filename) -{ - IReadFile* file = 0; - u32 i; - - for ( i=0; iopenFile(filename); - if (file) - return file; - } - - for ( i = 0; iopenFile(filename); - if (file) - return file; - } - - for ( i = 0; iopenFile(filename); - if (file) - return file; - } - - file = createReadFile(filename); - return file; -} - -//! Creates an IReadFile interface for treating memory like a file. -IReadFile* CFileSystem::createMemoryReadFile(void* memory, s32 len, - const c8* fileName, bool deleteMemoryWhenDropped) -{ - if (!memory) - return 0; - else - return new CMemoryReadFile(memory, len, fileName, deleteMemoryWhenDropped); -} - -//! Opens a file for write access. -IWriteFile* CFileSystem::createAndWriteFile(const c8* filename, bool append) -{ - return createWriteFile(filename, append); -} - - -bool CFileSystem::addFolderFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths) -{ - bool ret = false; - - CUnZipReader* zr = new CUnZipReader( this, filename, ignoreCase, ignorePaths); - if (zr) - { - UnZipFileSystems.push_back(zr); - ret = true; - } - - #ifdef _DEBUG - if ( false == ret ) - { - os::Printer::log("Could not open file. UnZipfile not added", filename, ELL_ERROR); - } - #endif - - return ret; - -} - - -//! adds an zip archive to the filesystem -bool CFileSystem::addZipFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths) -{ - IReadFile* file = createReadFile(filename); - if (file) - { - CZipReader* zr = new CZipReader(file, ignoreCase, ignorePaths); - if (zr) - ZipFileSystems.push_back(zr); - - file->drop(); - - bool ret = (zr != 0); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; - } - - #ifdef _DEBUG - os::Printer::log("Could not open file. Zipfile not added", filename, ELL_ERROR); - #endif - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; -} - - -//! adds an pak archive to the filesystem -bool CFileSystem::addPakFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths) -{ - IReadFile* file = createReadFile(filename); - if (file) - { - CPakReader* zr = new CPakReader(file, ignoreCase, ignorePaths); - if (zr) - PakFileSystems.push_back(zr); - - file->drop(); - - bool ret = (zr != 0); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; - } - - #ifdef _DEBUG - os::Printer::log("Could not open file. Pakfile not added", filename, ELL_ERROR); - #endif - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; -} - - -//! Returns the string of the current working directory -const c8* CFileSystem::getWorkingDirectory() -{ -#ifdef _IRR_WINDOWS_ - _getcwd(WorkingDirectory, FILE_SYSTEM_MAX_PATH); -#endif - -#if (defined(LINUX) || defined(MACOSX)) - getcwd(WorkingDirectory, (size_t)FILE_SYSTEM_MAX_PATH); -#endif - return WorkingDirectory; -} - - -//! Changes the current Working Directory to the string given. -//! The string is operating system dependent. Under Windows it will look -//! like this: "drive:\directory\sudirectory\" -//! \return -//! Returns true if successful, otherwise false. -bool CFileSystem::changeWorkingDirectoryTo(const c8* newDirectory) -{ - bool success=false; -#ifdef _IRR_WINDOWS_ - success=(_chdir(newDirectory) == 0); -#endif - -#if (defined(LINUX) || defined(MACOSX)) - success=(chdir(newDirectory) == 0); -#endif - return success; -} - -irr::core::stringc CFileSystem::getAbsolutePath(irr::core::stringc &filename) -{ - c8 *p=0; - irr::core::stringc ret; - -#ifdef _IRR_WINDOWS_ - - c8 fpath[_MAX_PATH]; - p = _fullpath( fpath, filename.c_str(), _MAX_PATH); - ret = p; - -#elif (defined(LINUX) || defined(MACOSX)) - - c8 fpath[4096]; - p = realpath(filename.c_str(), fpath); - ret = p; - -#endif - - return ret; -} - - -//! Creates a list of files and directories in the current working directory -IFileList* CFileSystem::createFileList() -{ - return new CFileList(); -} - - -//! determines if a file exists and would be able to be opened. -bool CFileSystem::existFile(const c8* filename) -{ - u32 i; - - for (i=0; ifindFile(filename)!=-1) - return true; - - for (i=0; ifindFile(filename)!=-1) - return true; - - for (i=0; ifindFile(filename)!=-1) - return true; - - FILE* f = fopen(filename, "rb"); - if (f) - { - fclose(f); - return true; - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; -} - - -//! Creates a XML Reader from a file. -IXMLReader* CFileSystem::createXMLReader(const c8* filename) -{ - IReadFile* file = createAndOpenFile(filename); - if (!file) - return 0; - - IXMLReader* reader = createXMLReader(file); - file->drop(); - return reader; -} - - -//! Creates a XML Reader from a file. -IXMLReader* CFileSystem::createXMLReader(IReadFile* file) -{ - if (!file) - return 0; - - return createIXMLReader(file); -} - -//! Creates a XML Reader from a file. -IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(const c8* filename) -{ - IReadFile* file = createAndOpenFile(filename); - if (!file) - return 0; - - IXMLReaderUTF8* reader = createIXMLReaderUTF8(file); - file->drop(); - return reader; -} - -//! Creates a XML Reader from a file. -IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(IReadFile* file) -{ - if (!file) - return 0; - - return createIXMLReaderUTF8(file); -} - - -//! Creates a XML Writer from a file. -IXMLWriter* CFileSystem::createXMLWriter(const c8* filename) -{ - IWriteFile* file = createAndWriteFile(filename); - IXMLWriter* writer = createXMLWriter(file); - file->drop(); - return writer; -} - - -//! Creates a XML Writer from a file. -IXMLWriter* CFileSystem::createXMLWriter(IWriteFile* file) -{ - return new CXMLWriter(file); -} - - -//! creates a filesystem which is able to open files from the ordinary file system, -//! and out of zipfiles, which are able to be added to the filesystem. -IFileSystem* createFileSystem() -{ - return new CFileSystem(); -} - -//! Creates a new empty collection of attributes, usable for serialization and more. -IAttributes* CFileSystem::createEmptyAttributes(video::IVideoDriver* driver) -{ - return new CAttributes(driver); -} - -} // end namespace irr -} // end namespace io - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CFileSystem.h" +#include "IReadFile.h" +#include "IWriteFile.h" +#include "CZipReader.h" +#include "CPakReader.h" +#include "CFileList.h" +#include "CXMLReader.h" +#include "CXMLWriter.h" +#include "stdio.h" +#include "os.h" +#include "IrrCompileConfig.h" +#include "CAttributes.h" +#include "CMemoryReadFile.h" + +#ifdef _IRR_WINDOWS_ +#include // for _chdir +#endif + +#if (defined(LINUX) || defined(MACOSX)) +#include +#include +#include +#endif + +namespace irr +{ +namespace io +{ + + +//! constructor +CFileSystem::CFileSystem() +{ + #ifdef _DEBUG + setDebugName("CFileSystem"); + #endif +} + + + +//! destructor +CFileSystem::~CFileSystem() +{ + u32 i; + + for ( i=0; idrop(); + + for ( i=0; idrop(); + + for ( i= 0; idrop(); +} + + + +//! opens a file for read access +IReadFile* CFileSystem::createAndOpenFile(const c8* filename) +{ + IReadFile* file = 0; + u32 i; + + for ( i=0; iopenFile(filename); + if (file) + return file; + } + + for ( i = 0; iopenFile(filename); + if (file) + return file; + } + + for ( i = 0; iopenFile(filename); + if (file) + return file; + } + + file = createReadFile(filename); + return file; +} + +//! Creates an IReadFile interface for treating memory like a file. +IReadFile* CFileSystem::createMemoryReadFile(void* memory, s32 len, + const c8* fileName, bool deleteMemoryWhenDropped) +{ + if (!memory) + return 0; + else + return new CMemoryReadFile(memory, len, fileName, deleteMemoryWhenDropped); +} + +//! Opens a file for write access. +IWriteFile* CFileSystem::createAndWriteFile(const c8* filename, bool append) +{ + return createWriteFile(filename, append); +} + + +bool CFileSystem::addFolderFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths) +{ + bool ret = false; + + CUnZipReader* zr = new CUnZipReader( this, filename, ignoreCase, ignorePaths); + if (zr) + { + UnZipFileSystems.push_back(zr); + ret = true; + } + + #ifdef _DEBUG + if ( false == ret ) + { + os::Printer::log("Could not open file. UnZipfile not added", filename, ELL_ERROR); + } + #endif + + return ret; + +} + + +//! adds an zip archive to the filesystem +bool CFileSystem::addZipFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths) +{ + IReadFile* file = createReadFile(filename); + if (file) + { + CZipReader* zr = new CZipReader(file, ignoreCase, ignorePaths); + if (zr) + ZipFileSystems.push_back(zr); + + file->drop(); + + bool ret = (zr != 0); + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return ret; + } + + #ifdef _DEBUG + os::Printer::log("Could not open file. Zipfile not added", filename, ELL_ERROR); + #endif + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return false; +} + + +//! adds an pak archive to the filesystem +bool CFileSystem::addPakFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths) +{ + IReadFile* file = createReadFile(filename); + if (file) + { + CPakReader* zr = new CPakReader(file, ignoreCase, ignorePaths); + if (zr) + PakFileSystems.push_back(zr); + + file->drop(); + + bool ret = (zr != 0); + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return ret; + } + + #ifdef _DEBUG + os::Printer::log("Could not open file. Pakfile not added", filename, ELL_ERROR); + #endif + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return false; +} + + +//! Returns the string of the current working directory +const c8* CFileSystem::getWorkingDirectory() +{ +#ifdef _IRR_WINDOWS_ + _getcwd(WorkingDirectory, FILE_SYSTEM_MAX_PATH); +#endif + +#if (defined(LINUX) || defined(MACOSX)) + getcwd(WorkingDirectory, (size_t)FILE_SYSTEM_MAX_PATH); +#endif + return WorkingDirectory; +} + + +//! Changes the current Working Directory to the string given. +//! The string is operating system dependent. Under Windows it will look +//! like this: "drive:\directory\sudirectory\" +//! \return +//! Returns true if successful, otherwise false. +bool CFileSystem::changeWorkingDirectoryTo(const c8* newDirectory) +{ + bool success=false; +#ifdef _IRR_WINDOWS_ + success=(_chdir(newDirectory) == 0); +#endif + +#if (defined(LINUX) || defined(MACOSX)) + success=(chdir(newDirectory) == 0); +#endif + return success; +} + +irr::core::stringc CFileSystem::getAbsolutePath(irr::core::stringc &filename) +{ + c8 *p=0; + irr::core::stringc ret; + +#ifdef _IRR_WINDOWS_ + + c8 fpath[_MAX_PATH]; + p = _fullpath( fpath, filename.c_str(), _MAX_PATH); + ret = p; + +#elif (defined(LINUX) || defined(MACOSX)) + + c8 fpath[4096]; + p = realpath(filename.c_str(), fpath); + ret = p; + +#endif + + return ret; +} + + +//! Creates a list of files and directories in the current working directory +IFileList* CFileSystem::createFileList() +{ + return new CFileList(); +} + + +//! determines if a file exists and would be able to be opened. +bool CFileSystem::existFile(const c8* filename) +{ + u32 i; + + for (i=0; ifindFile(filename)!=-1) + return true; + + for (i=0; ifindFile(filename)!=-1) + return true; + + for (i=0; ifindFile(filename)!=-1) + return true; + + FILE* f = fopen(filename, "rb"); + if (f) + { + fclose(f); + return true; + } + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return false; +} + + +//! Creates a XML Reader from a file. +IXMLReader* CFileSystem::createXMLReader(const c8* filename) +{ + IReadFile* file = createAndOpenFile(filename); + if (!file) + return 0; + + IXMLReader* reader = createXMLReader(file); + file->drop(); + return reader; +} + + +//! Creates a XML Reader from a file. +IXMLReader* CFileSystem::createXMLReader(IReadFile* file) +{ + if (!file) + return 0; + + return createIXMLReader(file); +} + +//! Creates a XML Reader from a file. +IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(const c8* filename) +{ + IReadFile* file = createAndOpenFile(filename); + if (!file) + return 0; + + IXMLReaderUTF8* reader = createIXMLReaderUTF8(file); + file->drop(); + return reader; +} + +//! Creates a XML Reader from a file. +IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(IReadFile* file) +{ + if (!file) + return 0; + + return createIXMLReaderUTF8(file); +} + + +//! Creates a XML Writer from a file. +IXMLWriter* CFileSystem::createXMLWriter(const c8* filename) +{ + IWriteFile* file = createAndWriteFile(filename); + IXMLWriter* writer = createXMLWriter(file); + file->drop(); + return writer; +} + + +//! Creates a XML Writer from a file. +IXMLWriter* CFileSystem::createXMLWriter(IWriteFile* file) +{ + return new CXMLWriter(file); +} + + +//! creates a filesystem which is able to open files from the ordinary file system, +//! and out of zipfiles, which are able to be added to the filesystem. +IFileSystem* createFileSystem() +{ + return new CFileSystem(); +} + +//! Creates a new empty collection of attributes, usable for serialization and more. +IAttributes* CFileSystem::createEmptyAttributes(video::IVideoDriver* driver) +{ + return new CAttributes(driver); +} + +} // end namespace irr +} // end namespace io + diff --git a/src/dep/src/irrlicht/CFileSystem.h b/src/dep/src/irrlicht/CFileSystem.h index 5f95e62..fbe7cb2 100644 --- a/src/dep/src/irrlicht/CFileSystem.h +++ b/src/dep/src/irrlicht/CFileSystem.h @@ -1,103 +1,103 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_FILE_SYSTEM_H_INCLUDED__ -#define __C_FILE_SYSTEM_H_INCLUDED__ - -#include "IFileSystem.h" -#include "irrArray.h" - -namespace irr -{ -namespace io -{ - - class CZipReader; - class CPakReader; - class CUnZipReader; - const s32 FILE_SYSTEM_MAX_PATH = 1024; - -/*! - FileSystem which uses normal files and one zipfile -*/ -class CFileSystem : public IFileSystem -{ -public: - - //! constructor - CFileSystem(); - - //! destructor - virtual ~CFileSystem(); - - //! opens a file for read access - virtual IReadFile* createAndOpenFile(const c8* filename); - - //! Creates an IReadFile interface for accessing memory like a file. - virtual IReadFile* createMemoryReadFile(void* memory, s32 len, const c8* fileName, bool deleteMemoryWhenDropped = false); - - //! Opens a file for write access. - virtual IWriteFile* createAndWriteFile(const c8* filename, bool append=false); - - //! adds an zip archive to the filesystem - virtual bool addZipFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true); - virtual bool addFolderFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true); - - //! adds an pak archive to the filesystem - virtual bool addPakFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true); - - //! Returns the string of the current working directory - virtual const c8* getWorkingDirectory(); - - //! Changes the current Working Directory to the string given. - //! The string is operating system dependent. Under Windows it will look - //! like this: "drive:\directory\sudirectory\" - virtual bool changeWorkingDirectoryTo(const c8* newDirectory); - - //! Converts a relative path to an absolute (unique) path, resolving symbolic links - virtual irr::core::stringc getAbsolutePath(irr::core::stringc &filename); - - //! Creates a list of files and directories in the current working directory - //! and returns it. - virtual IFileList* createFileList(); - - //! determinates if a file exists and would be able to be opened. - virtual bool existFile(const c8* filename); - - //! Creates a XML Reader from a file. - virtual IXMLReader* createXMLReader(const c8* filename); - - //! Creates a XML Reader from a file. - virtual IXMLReader* createXMLReader(IReadFile* file); - - //! Creates a XML Reader from a file. - virtual IXMLReaderUTF8* createXMLReaderUTF8(const c8* filename); - - //! Creates a XML Reader from a file. - virtual IXMLReaderUTF8* createXMLReaderUTF8(IReadFile* file); - - //! Creates a XML Writer from a file. - virtual IXMLWriter* createXMLWriter(const c8* filename); - - //! Creates a XML Writer from a file. - virtual IXMLWriter* createXMLWriter(IWriteFile* file); - - //! Creates a new empty collection of attributes, usable for serialization and more. - virtual IAttributes* createEmptyAttributes(video::IVideoDriver* driver); - -private: - - core::array ZipFileSystems; - core::array PakFileSystems; - core::array UnZipFileSystems; - c8 WorkingDirectory[FILE_SYSTEM_MAX_PATH]; -}; - - - -} // end namespace irr -} // end namespace io - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_FILE_SYSTEM_H_INCLUDED__ +#define __C_FILE_SYSTEM_H_INCLUDED__ + +#include "IFileSystem.h" +#include "irrArray.h" + +namespace irr +{ +namespace io +{ + + class CZipReader; + class CPakReader; + class CUnZipReader; + const s32 FILE_SYSTEM_MAX_PATH = 1024; + +/*! + FileSystem which uses normal files and one zipfile +*/ +class CFileSystem : public IFileSystem +{ +public: + + //! constructor + CFileSystem(); + + //! destructor + virtual ~CFileSystem(); + + //! opens a file for read access + virtual IReadFile* createAndOpenFile(const c8* filename); + + //! Creates an IReadFile interface for accessing memory like a file. + virtual IReadFile* createMemoryReadFile(void* memory, s32 len, const c8* fileName, bool deleteMemoryWhenDropped = false); + + //! Opens a file for write access. + virtual IWriteFile* createAndWriteFile(const c8* filename, bool append=false); + + //! adds an zip archive to the filesystem + virtual bool addZipFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true); + virtual bool addFolderFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true); + + //! adds an pak archive to the filesystem + virtual bool addPakFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true); + + //! Returns the string of the current working directory + virtual const c8* getWorkingDirectory(); + + //! Changes the current Working Directory to the string given. + //! The string is operating system dependent. Under Windows it will look + //! like this: "drive:\directory\sudirectory\" + virtual bool changeWorkingDirectoryTo(const c8* newDirectory); + + //! Converts a relative path to an absolute (unique) path, resolving symbolic links + virtual irr::core::stringc getAbsolutePath(irr::core::stringc &filename); + + //! Creates a list of files and directories in the current working directory + //! and returns it. + virtual IFileList* createFileList(); + + //! determinates if a file exists and would be able to be opened. + virtual bool existFile(const c8* filename); + + //! Creates a XML Reader from a file. + virtual IXMLReader* createXMLReader(const c8* filename); + + //! Creates a XML Reader from a file. + virtual IXMLReader* createXMLReader(IReadFile* file); + + //! Creates a XML Reader from a file. + virtual IXMLReaderUTF8* createXMLReaderUTF8(const c8* filename); + + //! Creates a XML Reader from a file. + virtual IXMLReaderUTF8* createXMLReaderUTF8(IReadFile* file); + + //! Creates a XML Writer from a file. + virtual IXMLWriter* createXMLWriter(const c8* filename); + + //! Creates a XML Writer from a file. + virtual IXMLWriter* createXMLWriter(IWriteFile* file); + + //! Creates a new empty collection of attributes, usable for serialization and more. + virtual IAttributes* createEmptyAttributes(video::IVideoDriver* driver); + +private: + + core::array ZipFileSystems; + core::array PakFileSystems; + core::array UnZipFileSystems; + c8 WorkingDirectory[FILE_SYSTEM_MAX_PATH]; +}; + + + +} // end namespace irr +} // end namespace io + +#endif + diff --git a/src/dep/src/irrlicht/CGUIButton.cpp b/src/dep/src/irrlicht/CGUIButton.cpp index e9f415b..f78d045 100644 --- a/src/dep/src/irrlicht/CGUIButton.cpp +++ b/src/dep/src/irrlicht/CGUIButton.cpp @@ -1,439 +1,439 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIButton.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIFont.h" -#include "IGUISkin.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIButton::CGUIButton(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect rectangle, bool noclip) -: IGUIButton(environment, parent, id, rectangle), Pressed(false), - IsPushButton(false), UseAlphaChannel(false), Border(true), - MouseOverTime(0), FocusTime(0), ClickTime(0), SpriteBank(0), - OverrideFont(0), Image(0), PressedImage(0) -{ - #ifdef _DEBUG - setDebugName("CGUIButton"); - #endif - setNotClipped(noclip); - - // reset sprites - for (u32 i=0; idrop(); - - if (Image) - Image->drop(); - - if (PressedImage) - PressedImage->drop(); - - if (SpriteBank) - SpriteBank->drop(); -} - -//! Sets if the button should use the skin to draw its border -void CGUIButton::setDrawBorder(bool border) -{ - Border = border; -} - -void CGUIButton::setSpriteBank(IGUISpriteBank* sprites) -{ - if (sprites) - sprites->grab(); - - if (SpriteBank) - SpriteBank->drop(); - - SpriteBank = sprites; -} - -void CGUIButton::setSprite(EGUI_BUTTON_STATE state, s32 index, video::SColor color, bool loop) -{ - if (SpriteBank) - { - ButtonSprites[(u32)state].Index = index; - ButtonSprites[(u32)state].Color = color; - ButtonSprites[(u32)state].Loop = loop; - } - else - { - ButtonSprites[(u32)state].Index = -1; - } -} - -//! called if an event happened. -bool CGUIButton::OnEvent(SEvent event) -{ - if (!IsEnabled) - return Parent ? Parent->OnEvent(event) : false; - - switch(event.EventType) - { - case EET_KEY_INPUT_EVENT: - if (event.KeyInput.PressedDown && - (event.KeyInput.Key == KEY_RETURN || - event.KeyInput.Key == KEY_SPACE)) - { - if (!IsPushButton) - setPressed(true); - else - setPressed(!Pressed); - - return true; - } - else - if (!event.KeyInput.PressedDown && Pressed && - (event.KeyInput.Key == KEY_RETURN || - event.KeyInput.Key == KEY_SPACE)) - { - Environment->removeFocus(this); - - if (!IsPushButton) - setPressed(false); - - if (Parent) - { - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - newEvent.GUIEvent.EventType = EGET_BUTTON_CLICKED; - Parent->OnEvent(newEvent); - } - return true; - } - break; - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) - { - if (event.GUIEvent.Caller == (IGUIElement*) this && !IsPushButton) - setPressed(false); - } - break; - case EET_MOUSE_INPUT_EVENT: - if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) - { - if (Environment->hasFocus(this) && - !AbsoluteClippingRect.isPointInside(core::position2d(event.MouseInput.X, event.MouseInput.Y))) - { - Environment->removeFocus(this); - return false; - } - - if (!IsPushButton) - setPressed(true); - - Environment->setFocus(this); - return true; - } - else - if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) - { - bool wasPressed = Pressed; - Environment->removeFocus(this); - - if ( !AbsoluteClippingRect.isPointInside( core::position2d(event.MouseInput.X, event.MouseInput.Y ) ) ) - { - if (!IsPushButton) - setPressed(false); - return true; - } - - if (!IsPushButton) - setPressed(false); - else - { - setPressed(!Pressed); - } - - if ((!IsPushButton && wasPressed && Parent) || - (IsPushButton && wasPressed != Pressed)) - { - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - newEvent.GUIEvent.EventType = EGET_BUTTON_CLICKED; - Parent->OnEvent(newEvent); - } - - return true; - } - break; - } - - return Parent ? Parent->OnEvent(event) : false; -} - - - -//! draws the element and its children -void CGUIButton::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - irr::video::IVideoDriver* driver = Environment->getVideoDriver(); - - IGUIFont* font = OverrideFont; - if (!OverrideFont) - font = skin->getFont(); - - core::rect rect = AbsoluteRect; - - // todo: move sprite up and text down if the pressed state has a sprite - // draw sprites for focused and mouse-over - core::position2di spritePos = AbsoluteRect.getCenter(); - - if (!Pressed) - { - if (Border) - skin->draw3DButtonPaneStandard(this, rect, &AbsoluteClippingRect); - - if (Image) - { - core::position2d pos = AbsoluteRect.getCenter(); - pos.X -= ImageRect.getWidth() / 2; - pos.Y -= ImageRect.getHeight() / 2; - - driver->draw2DImage(Image, pos, ImageRect, &AbsoluteClippingRect, - video::SColor(255,255,255,255), UseAlphaChannel); - } - if (SpriteBank && ButtonSprites[EGBS_BUTTON_UP].Index != -1) - { - // draw pressed sprite - SpriteBank->draw2DSprite(ButtonSprites[EGBS_BUTTON_UP].Index, spritePos, - &AbsoluteClippingRect, ButtonSprites[EGBS_BUTTON_UP].Color, ClickTime, os::Timer::getTime(), - ButtonSprites[EGBS_BUTTON_UP].Loop, true); - } - } - else - { - if (Border) - skin->draw3DButtonPanePressed(this, rect, &AbsoluteClippingRect); - - if (PressedImage) - { - core::position2d pos = AbsoluteRect.getCenter(); - pos.X -= PressedImageRect.getWidth() / 2; - pos.Y -= PressedImageRect.getHeight() / 2; - // patch by Alan Tyndall/Jonas Petersen - if (Image == PressedImage) - { - pos.X += 1; - pos.Y += 1; - } - driver->draw2DImage(PressedImage, pos, PressedImageRect, &AbsoluteClippingRect, - video::SColor(255,255,255,255), UseAlphaChannel); - } - - if (SpriteBank && ButtonSprites[EGBS_BUTTON_DOWN].Index != -1) - { - // draw sprite - SpriteBank->draw2DSprite(ButtonSprites[EGBS_BUTTON_DOWN].Index, spritePos, - &AbsoluteClippingRect, ButtonSprites[EGBS_BUTTON_DOWN].Color, ClickTime, os::Timer::getTime(), - ButtonSprites[EGBS_BUTTON_DOWN].Loop, true); - } - - } - - if (Text.size()) - { - rect = AbsoluteRect; - if (Pressed) - rect.UpperLeftCorner.Y += 2; - - if (font) - font->draw(Text.c_str(), rect, - skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), true, true, - &AbsoluteClippingRect); - } - - IGUIElement::draw(); -} - - - -//! sets another skin independent font. if this is set to zero, the button uses the font of the skin. -void CGUIButton::setOverrideFont(IGUIFont* font) -{ - if (OverrideFont) - OverrideFont->drop(); - - OverrideFont = font; - - if (OverrideFont) - OverrideFont->grab(); -} - - -//! Sets an image which should be displayed on the button when it is in normal state. -void CGUIButton::setImage(video::ITexture* image) -{ - if (Image) - Image->drop(); - - Image = image; - if (image) - ImageRect = core::rect(core::position2d(0,0), image->getSize()); - - if (Image) - Image->grab(); - - if (!PressedImage) - setPressedImage(Image); -} - -//! Sets an image which should be displayed on the button when it is in normal state. -void CGUIButton::setImage(video::ITexture* image, const core::rect& pos) -{ - if (Image) - Image->drop(); - - Image = image; - ImageRect = pos; - - if (Image) - Image->grab(); - - if (!PressedImage) - setPressedImage(Image, pos); -} - -//! Sets an image which should be displayed on the button when it is in pressed state. -void CGUIButton::setPressedImage(video::ITexture* image) -{ - if (PressedImage) - PressedImage->drop(); - - PressedImage = image; - if (image) - PressedImageRect = core::rect(core::position2d(0,0), image->getSize()); - - if (PressedImage) - PressedImage->grab(); -} - -//! Sets an image which should be displayed on the button when it is in pressed state. -void CGUIButton::setPressedImage(video::ITexture* image, const core::rect& pos) -{ - if (PressedImage) - PressedImage->drop(); - - PressedImage = image; - PressedImageRect = pos; - - if (PressedImage) - PressedImage->grab(); -} - - -//! Sets if the button should behave like a push button. Which means it -//! can be in two states: Normal or Pressed. With a click on the button, -//! the user can change the state of the button. -void CGUIButton::setIsPushButton(bool isPushButton) -{ - IsPushButton = isPushButton; -} - - -//! Returns if the button is currently pressed -bool CGUIButton::isPressed() -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Pressed; -} - -//! Sets the pressed state of the button if this is a pushbutton -void CGUIButton::setPressed(bool pressed) -{ - if (Pressed != pressed) - { - ClickTime = os::Timer::getTime(); - Pressed = pressed; - } -} - -//! Sets if the alpha channel should be used for drawing images on the button (default is false) -void CGUIButton::setUseAlphaChannel(bool useAlphaChannel) -{ - UseAlphaChannel = useAlphaChannel; -} - -//! Returns if the alpha channel should be used for drawing images on the button -bool CGUIButton::getUseAlphaChannel() -{ - return UseAlphaChannel; -} - -//! Writes attributes of the element. -void CGUIButton::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) -{ - - IGUIButton::serializeAttributes(out,options); - - out->addBool ("PushButton", IsPushButton ); - if (IsPushButton) - out->addBool ("Pressed", Pressed); - - out->addTexture ("Image", Image); - out->addRect ("ImageRect", ImageRect); - out->addTexture ("PressedImage", PressedImage); - out->addRect ("PressedImageRect",PressedImageRect); - - out->addBool ("Border", Border); - out->addBool ("UseAlphaChannel", UseAlphaChannel); - - // out->addString ("OverrideFont", OverrideFont); -} - -//! Reads attributes of the element -void CGUIButton::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIButton::deserializeAttributes(in,options); - - IsPushButton = in->getAttributeAsBool("PushButton"); - Pressed = IsPushButton ? in->getAttributeAsBool("Pressed") : false; - - core::rect rec = in->getAttributeAsRect("ImageRect"); - if (rec.isValid()) - setImage( in->getAttributeAsTexture("Image"), rec); - else - setImage( in->getAttributeAsTexture("Image") ); - - rec = in->getAttributeAsRect("PressedImageRect"); - if (rec.isValid()) - setPressedImage( in->getAttributeAsTexture("PressedImage"), rec); - else - setPressedImage( in->getAttributeAsTexture("PressedImage") ); - - setDrawBorder(in->getAttributeAsBool("Border")); - UseAlphaChannel = in->getAttributeAsBool("UseAlphaChannel"); - - // setOverrideFont(in->getAttributeAsString("OverrideFont")); - - updateAbsolutePosition(); -} - -} // end namespace gui -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIButton.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUIFont.h" +#include "IGUISkin.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIButton::CGUIButton(IGUIEnvironment* environment, IGUIElement* parent, + s32 id, core::rect rectangle, bool noclip) +: IGUIButton(environment, parent, id, rectangle), Pressed(false), + IsPushButton(false), UseAlphaChannel(false), Border(true), + MouseOverTime(0), FocusTime(0), ClickTime(0), SpriteBank(0), + OverrideFont(0), Image(0), PressedImage(0) +{ + #ifdef _DEBUG + setDebugName("CGUIButton"); + #endif + setNotClipped(noclip); + + // reset sprites + for (u32 i=0; idrop(); + + if (Image) + Image->drop(); + + if (PressedImage) + PressedImage->drop(); + + if (SpriteBank) + SpriteBank->drop(); +} + +//! Sets if the button should use the skin to draw its border +void CGUIButton::setDrawBorder(bool border) +{ + Border = border; +} + +void CGUIButton::setSpriteBank(IGUISpriteBank* sprites) +{ + if (sprites) + sprites->grab(); + + if (SpriteBank) + SpriteBank->drop(); + + SpriteBank = sprites; +} + +void CGUIButton::setSprite(EGUI_BUTTON_STATE state, s32 index, video::SColor color, bool loop) +{ + if (SpriteBank) + { + ButtonSprites[(u32)state].Index = index; + ButtonSprites[(u32)state].Color = color; + ButtonSprites[(u32)state].Loop = loop; + } + else + { + ButtonSprites[(u32)state].Index = -1; + } +} + +//! called if an event happened. +bool CGUIButton::OnEvent(SEvent event) +{ + if (!IsEnabled) + return Parent ? Parent->OnEvent(event) : false; + + switch(event.EventType) + { + case EET_KEY_INPUT_EVENT: + if (event.KeyInput.PressedDown && + (event.KeyInput.Key == KEY_RETURN || + event.KeyInput.Key == KEY_SPACE)) + { + if (!IsPushButton) + setPressed(true); + else + setPressed(!Pressed); + + return true; + } + else + if (!event.KeyInput.PressedDown && Pressed && + (event.KeyInput.Key == KEY_RETURN || + event.KeyInput.Key == KEY_SPACE)) + { + Environment->removeFocus(this); + + if (!IsPushButton) + setPressed(false); + + if (Parent) + { + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + newEvent.GUIEvent.EventType = EGET_BUTTON_CLICKED; + Parent->OnEvent(newEvent); + } + return true; + } + break; + case EET_GUI_EVENT: + if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) + { + if (event.GUIEvent.Caller == (IGUIElement*) this && !IsPushButton) + setPressed(false); + } + break; + case EET_MOUSE_INPUT_EVENT: + if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) + { + if (Environment->hasFocus(this) && + !AbsoluteClippingRect.isPointInside(core::position2d(event.MouseInput.X, event.MouseInput.Y))) + { + Environment->removeFocus(this); + return false; + } + + if (!IsPushButton) + setPressed(true); + + Environment->setFocus(this); + return true; + } + else + if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) + { + bool wasPressed = Pressed; + Environment->removeFocus(this); + + if ( !AbsoluteClippingRect.isPointInside( core::position2d(event.MouseInput.X, event.MouseInput.Y ) ) ) + { + if (!IsPushButton) + setPressed(false); + return true; + } + + if (!IsPushButton) + setPressed(false); + else + { + setPressed(!Pressed); + } + + if ((!IsPushButton && wasPressed && Parent) || + (IsPushButton && wasPressed != Pressed)) + { + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + newEvent.GUIEvent.EventType = EGET_BUTTON_CLICKED; + Parent->OnEvent(newEvent); + } + + return true; + } + break; + } + + return Parent ? Parent->OnEvent(event) : false; +} + + + +//! draws the element and its children +void CGUIButton::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + irr::video::IVideoDriver* driver = Environment->getVideoDriver(); + + IGUIFont* font = OverrideFont; + if (!OverrideFont) + font = skin->getFont(); + + core::rect rect = AbsoluteRect; + + // todo: move sprite up and text down if the pressed state has a sprite + // draw sprites for focused and mouse-over + core::position2di spritePos = AbsoluteRect.getCenter(); + + if (!Pressed) + { + if (Border) + skin->draw3DButtonPaneStandard(this, rect, &AbsoluteClippingRect); + + if (Image) + { + core::position2d pos = AbsoluteRect.getCenter(); + pos.X -= ImageRect.getWidth() / 2; + pos.Y -= ImageRect.getHeight() / 2; + + driver->draw2DImage(Image, pos, ImageRect, &AbsoluteClippingRect, + video::SColor(255,255,255,255), UseAlphaChannel); + } + if (SpriteBank && ButtonSprites[EGBS_BUTTON_UP].Index != -1) + { + // draw pressed sprite + SpriteBank->draw2DSprite(ButtonSprites[EGBS_BUTTON_UP].Index, spritePos, + &AbsoluteClippingRect, ButtonSprites[EGBS_BUTTON_UP].Color, ClickTime, os::Timer::getTime(), + ButtonSprites[EGBS_BUTTON_UP].Loop, true); + } + } + else + { + if (Border) + skin->draw3DButtonPanePressed(this, rect, &AbsoluteClippingRect); + + if (PressedImage) + { + core::position2d pos = AbsoluteRect.getCenter(); + pos.X -= PressedImageRect.getWidth() / 2; + pos.Y -= PressedImageRect.getHeight() / 2; + // patch by Alan Tyndall/Jonas Petersen + if (Image == PressedImage) + { + pos.X += 1; + pos.Y += 1; + } + driver->draw2DImage(PressedImage, pos, PressedImageRect, &AbsoluteClippingRect, + video::SColor(255,255,255,255), UseAlphaChannel); + } + + if (SpriteBank && ButtonSprites[EGBS_BUTTON_DOWN].Index != -1) + { + // draw sprite + SpriteBank->draw2DSprite(ButtonSprites[EGBS_BUTTON_DOWN].Index, spritePos, + &AbsoluteClippingRect, ButtonSprites[EGBS_BUTTON_DOWN].Color, ClickTime, os::Timer::getTime(), + ButtonSprites[EGBS_BUTTON_DOWN].Loop, true); + } + + } + + if (Text.size()) + { + rect = AbsoluteRect; + if (Pressed) + rect.UpperLeftCorner.Y += 2; + + if (font) + font->draw(Text.c_str(), rect, + skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), true, true, + &AbsoluteClippingRect); + } + + IGUIElement::draw(); +} + + + +//! sets another skin independent font. if this is set to zero, the button uses the font of the skin. +void CGUIButton::setOverrideFont(IGUIFont* font) +{ + if (OverrideFont) + OverrideFont->drop(); + + OverrideFont = font; + + if (OverrideFont) + OverrideFont->grab(); +} + + +//! Sets an image which should be displayed on the button when it is in normal state. +void CGUIButton::setImage(video::ITexture* image) +{ + if (Image) + Image->drop(); + + Image = image; + if (image) + ImageRect = core::rect(core::position2d(0,0), image->getSize()); + + if (Image) + Image->grab(); + + if (!PressedImage) + setPressedImage(Image); +} + +//! Sets an image which should be displayed on the button when it is in normal state. +void CGUIButton::setImage(video::ITexture* image, const core::rect& pos) +{ + if (Image) + Image->drop(); + + Image = image; + ImageRect = pos; + + if (Image) + Image->grab(); + + if (!PressedImage) + setPressedImage(Image, pos); +} + +//! Sets an image which should be displayed on the button when it is in pressed state. +void CGUIButton::setPressedImage(video::ITexture* image) +{ + if (PressedImage) + PressedImage->drop(); + + PressedImage = image; + if (image) + PressedImageRect = core::rect(core::position2d(0,0), image->getSize()); + + if (PressedImage) + PressedImage->grab(); +} + +//! Sets an image which should be displayed on the button when it is in pressed state. +void CGUIButton::setPressedImage(video::ITexture* image, const core::rect& pos) +{ + if (PressedImage) + PressedImage->drop(); + + PressedImage = image; + PressedImageRect = pos; + + if (PressedImage) + PressedImage->grab(); +} + + +//! Sets if the button should behave like a push button. Which means it +//! can be in two states: Normal or Pressed. With a click on the button, +//! the user can change the state of the button. +void CGUIButton::setIsPushButton(bool isPushButton) +{ + IsPushButton = isPushButton; +} + + +//! Returns if the button is currently pressed +bool CGUIButton::isPressed() +{ + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return Pressed; +} + +//! Sets the pressed state of the button if this is a pushbutton +void CGUIButton::setPressed(bool pressed) +{ + if (Pressed != pressed) + { + ClickTime = os::Timer::getTime(); + Pressed = pressed; + } +} + +//! Sets if the alpha channel should be used for drawing images on the button (default is false) +void CGUIButton::setUseAlphaChannel(bool useAlphaChannel) +{ + UseAlphaChannel = useAlphaChannel; +} + +//! Returns if the alpha channel should be used for drawing images on the button +bool CGUIButton::getUseAlphaChannel() +{ + return UseAlphaChannel; +} + +//! Writes attributes of the element. +void CGUIButton::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +{ + + IGUIButton::serializeAttributes(out,options); + + out->addBool ("PushButton", IsPushButton ); + if (IsPushButton) + out->addBool ("Pressed", Pressed); + + out->addTexture ("Image", Image); + out->addRect ("ImageRect", ImageRect); + out->addTexture ("PressedImage", PressedImage); + out->addRect ("PressedImageRect",PressedImageRect); + + out->addBool ("Border", Border); + out->addBool ("UseAlphaChannel", UseAlphaChannel); + + // out->addString ("OverrideFont", OverrideFont); +} + +//! Reads attributes of the element +void CGUIButton::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +{ + IGUIButton::deserializeAttributes(in,options); + + IsPushButton = in->getAttributeAsBool("PushButton"); + Pressed = IsPushButton ? in->getAttributeAsBool("Pressed") : false; + + core::rect rec = in->getAttributeAsRect("ImageRect"); + if (rec.isValid()) + setImage( in->getAttributeAsTexture("Image"), rec); + else + setImage( in->getAttributeAsTexture("Image") ); + + rec = in->getAttributeAsRect("PressedImageRect"); + if (rec.isValid()) + setPressedImage( in->getAttributeAsTexture("PressedImage"), rec); + else + setPressedImage( in->getAttributeAsTexture("PressedImage") ); + + setDrawBorder(in->getAttributeAsBool("Border")); + UseAlphaChannel = in->getAttributeAsBool("UseAlphaChannel"); + + // setOverrideFont(in->getAttributeAsString("OverrideFont")); + + updateAbsolutePosition(); +} + +} // end namespace gui +} // end namespace irr diff --git a/src/dep/src/irrlicht/CGUIButton.h b/src/dep/src/irrlicht/CGUIButton.h index f173554..dcecbca 100644 --- a/src/dep/src/irrlicht/CGUIButton.h +++ b/src/dep/src/irrlicht/CGUIButton.h @@ -1,122 +1,122 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_BUTTON_H_INCLUDED__ -#define __C_GUI_BUTTON_H_INCLUDED__ - -#include "IGUIButton.h" -#include "IGUISpriteBank.h" -#include "SColor.h" - -namespace irr -{ -namespace gui -{ - - class CGUIButton : public IGUIButton - { - public: - - //! constructor - CGUIButton(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect rectangle, bool noclip=false); - - //! destructor - ~CGUIButton(); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! draws the element and its children - virtual void draw(); - - //! sets another skin independent font. if this is set to zero, the button uses the font of the skin. - virtual void setOverrideFont(IGUIFont* font=0); - - //! Sets an image which should be displayed on the button when it is in normal state. - virtual void setImage(video::ITexture* image); - - //! Sets an image which should be displayed on the button when it is in normal state. - virtual void setImage(video::ITexture* image, const core::rect& pos); - - //! Sets an image which should be displayed on the button when it is in pressed state. - virtual void setPressedImage(video::ITexture* image); - - //! Sets an image which should be displayed on the button when it is in pressed state. - virtual void setPressedImage(video::ITexture* image, const core::rect& pos); - - //! Sets the sprite bank used by the button - virtual void setSpriteBank(IGUISpriteBank* bank); - - //! Sets the animated sprite for a specific button state - /** \param index: Number of the sprite within the sprite bank, use -1 for no sprite - \param state: State of the button to set the sprite for - \param index: The sprite number from the current sprite bank - \param color: The color of the sprite - */ - virtual void setSprite(EGUI_BUTTON_STATE state, s32 index, - video::SColor color=video::SColor(255,255,255,255), bool loop=false); - - //! Sets if the button should behave like a push button. Which means it - //! can be in two states: Normal or Pressed. With a click on the button, - //! the user can change the state of the button. - virtual void setIsPushButton(bool isPushButton); - - //! Returns if the button is currently pressed - virtual bool isPressed(); - - //! Sets the pressed state of the button if this is a pushbutton - virtual void setPressed(bool pressed); - - //! Sets if the button should use the skin to draw its border - virtual void setDrawBorder(bool border); - - //! Sets if the alpha channel should be used for drawing images on the button (default is false) - virtual void setUseAlphaChannel(bool useAlphaChannel); - - //! Returns if the alpha channel should be used for drawing images on the button - virtual bool getUseAlphaChannel(); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - struct ButtonSprite - { - s32 Index; - video::SColor Color; - bool Loop; - }; - - bool Pressed; - bool IsPushButton; - bool UseAlphaChannel; - - bool Border; - - u32 MouseOverTime; - u32 FocusTime; - u32 ClickTime; - - IGUISpriteBank* SpriteBank; - IGUIFont* OverrideFont; - - ButtonSprite ButtonSprites[EGBS_COUNT]; - - video::ITexture* Image; - video::ITexture* PressedImage; - - core::rect ImageRect; - core::rect PressedImageRect; - }; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_BUTTON_H_INCLUDED__ +#define __C_GUI_BUTTON_H_INCLUDED__ + +#include "IGUIButton.h" +#include "IGUISpriteBank.h" +#include "SColor.h" + +namespace irr +{ +namespace gui +{ + + class CGUIButton : public IGUIButton + { + public: + + //! constructor + CGUIButton(IGUIEnvironment* environment, IGUIElement* parent, + s32 id, core::rect rectangle, bool noclip=false); + + //! destructor + ~CGUIButton(); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! draws the element and its children + virtual void draw(); + + //! sets another skin independent font. if this is set to zero, the button uses the font of the skin. + virtual void setOverrideFont(IGUIFont* font=0); + + //! Sets an image which should be displayed on the button when it is in normal state. + virtual void setImage(video::ITexture* image); + + //! Sets an image which should be displayed on the button when it is in normal state. + virtual void setImage(video::ITexture* image, const core::rect& pos); + + //! Sets an image which should be displayed on the button when it is in pressed state. + virtual void setPressedImage(video::ITexture* image); + + //! Sets an image which should be displayed on the button when it is in pressed state. + virtual void setPressedImage(video::ITexture* image, const core::rect& pos); + + //! Sets the sprite bank used by the button + virtual void setSpriteBank(IGUISpriteBank* bank); + + //! Sets the animated sprite for a specific button state + /** \param index: Number of the sprite within the sprite bank, use -1 for no sprite + \param state: State of the button to set the sprite for + \param index: The sprite number from the current sprite bank + \param color: The color of the sprite + */ + virtual void setSprite(EGUI_BUTTON_STATE state, s32 index, + video::SColor color=video::SColor(255,255,255,255), bool loop=false); + + //! Sets if the button should behave like a push button. Which means it + //! can be in two states: Normal or Pressed. With a click on the button, + //! the user can change the state of the button. + virtual void setIsPushButton(bool isPushButton); + + //! Returns if the button is currently pressed + virtual bool isPressed(); + + //! Sets the pressed state of the button if this is a pushbutton + virtual void setPressed(bool pressed); + + //! Sets if the button should use the skin to draw its border + virtual void setDrawBorder(bool border); + + //! Sets if the alpha channel should be used for drawing images on the button (default is false) + virtual void setUseAlphaChannel(bool useAlphaChannel); + + //! Returns if the alpha channel should be used for drawing images on the button + virtual bool getUseAlphaChannel(); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + private: + + struct ButtonSprite + { + s32 Index; + video::SColor Color; + bool Loop; + }; + + bool Pressed; + bool IsPushButton; + bool UseAlphaChannel; + + bool Border; + + u32 MouseOverTime; + u32 FocusTime; + u32 ClickTime; + + IGUISpriteBank* SpriteBank; + IGUIFont* OverrideFont; + + ButtonSprite ButtonSprites[EGBS_COUNT]; + + video::ITexture* Image; + video::ITexture* PressedImage; + + core::rect ImageRect; + core::rect PressedImageRect; + }; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUICheckBox.cpp b/src/dep/src/irrlicht/CGUICheckBox.cpp index bedd76f..c7e15b4 100644 --- a/src/dep/src/irrlicht/CGUICheckBox.cpp +++ b/src/dep/src/irrlicht/CGUICheckBox.cpp @@ -1,160 +1,160 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUICheckBox.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIFont.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUICheckBox::CGUICheckBox(bool checked, IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) -: IGUICheckBox(environment, parent, id, rectangle), Pressed(false), Checked(checked), checkTime(0) -{ - #ifdef _DEBUG - setDebugName("CGUICheckBox"); - #endif -} - - - -//! destructor -CGUICheckBox::~CGUICheckBox() -{ -} - - - -//! called if an event happened. -bool CGUICheckBox::OnEvent(SEvent event) -{ - switch(event.EventType) - { - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) - { - if (event.GUIEvent.Caller == (IGUIElement*)this) - Pressed = false; - } - break; - case EET_MOUSE_INPUT_EVENT: - if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) - { - Pressed = true; - checkTime = os::Timer::getTime(); - Environment->setFocus(this); - return true; - } - else - if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) - { - bool wasPressed = Pressed; - Environment->removeFocus(this); - Pressed = false; - - if (wasPressed && Parent) - { - if ( !AbsoluteClippingRect.isPointInside( core::position2d(event.MouseInput.X, event.MouseInput.Y) ) ) - { - Pressed = false; - return true; - } - - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - Checked = !Checked; - newEvent.GUIEvent.EventType = EGET_CHECKBOX_CHANGED; - Parent->OnEvent(newEvent); - } - - return true; - } - break; - } - - return Parent ? Parent->OnEvent(event) : false; -} - - - -//! draws the element and its children -void CGUICheckBox::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - - core::rect rect = AbsoluteRect; - - s32 height = skin->getSize(EGDS_CHECK_BOX_WIDTH); - - core::rect checkRect(AbsoluteRect.UpperLeftCorner.X, - ((AbsoluteRect.getHeight() - height) / 2) + AbsoluteRect.UpperLeftCorner.Y, - 0, 0); - - checkRect.LowerRightCorner.X = checkRect.UpperLeftCorner.X + height; - checkRect.LowerRightCorner.Y = checkRect.UpperLeftCorner.Y + height; - - skin->draw3DSunkenPane(this, skin->getColor(Pressed ? EGDC_3D_FACE : EGDC_ACTIVE_CAPTION), - false, true, checkRect, &AbsoluteClippingRect); - - if (Checked && Environment->getSkin()) - Environment->getSkin()->drawIcon(this, EGDI_CHECK_BOX_CHECKED, checkRect.getCenter(), - checkTime, os::Timer::getTime(), false, &AbsoluteClippingRect); - - if (Text.size()) - { - checkRect = AbsoluteRect; - checkRect.UpperLeftCorner.X += height + 5; - - IGUIFont* font = skin->getFont(); - if (font) - font->draw(Text.c_str(), checkRect, - skin->getColor(EGDC_BUTTON_TEXT), false, true, &AbsoluteClippingRect); - } - - IGUIElement::draw(); -} - - -//! set if box is checked -void CGUICheckBox::setChecked(bool checked) -{ - Checked = checked; -} - - -//! returns if box is checked -bool CGUICheckBox::isChecked() -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Checked; -} - -//! Writes attributes of the element. -void CGUICheckBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) -{ - IGUICheckBox::serializeAttributes(out,options); - out->addBool ("Checked", Checked ); -} - -//! Reads attributes of the element -void CGUICheckBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - Checked = in->getAttributeAsBool ("Checked"); - - IGUICheckBox::deserializeAttributes(in,options); -} - - -} // end namespace gui -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUICheckBox.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUIFont.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUICheckBox::CGUICheckBox(bool checked, IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) +: IGUICheckBox(environment, parent, id, rectangle), Pressed(false), Checked(checked), checkTime(0) +{ + #ifdef _DEBUG + setDebugName("CGUICheckBox"); + #endif +} + + + +//! destructor +CGUICheckBox::~CGUICheckBox() +{ +} + + + +//! called if an event happened. +bool CGUICheckBox::OnEvent(SEvent event) +{ + switch(event.EventType) + { + case EET_GUI_EVENT: + if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) + { + if (event.GUIEvent.Caller == (IGUIElement*)this) + Pressed = false; + } + break; + case EET_MOUSE_INPUT_EVENT: + if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) + { + Pressed = true; + checkTime = os::Timer::getTime(); + Environment->setFocus(this); + return true; + } + else + if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) + { + bool wasPressed = Pressed; + Environment->removeFocus(this); + Pressed = false; + + if (wasPressed && Parent) + { + if ( !AbsoluteClippingRect.isPointInside( core::position2d(event.MouseInput.X, event.MouseInput.Y) ) ) + { + Pressed = false; + return true; + } + + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + Checked = !Checked; + newEvent.GUIEvent.EventType = EGET_CHECKBOX_CHANGED; + Parent->OnEvent(newEvent); + } + + return true; + } + break; + } + + return Parent ? Parent->OnEvent(event) : false; +} + + + +//! draws the element and its children +void CGUICheckBox::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + + core::rect rect = AbsoluteRect; + + s32 height = skin->getSize(EGDS_CHECK_BOX_WIDTH); + + core::rect checkRect(AbsoluteRect.UpperLeftCorner.X, + ((AbsoluteRect.getHeight() - height) / 2) + AbsoluteRect.UpperLeftCorner.Y, + 0, 0); + + checkRect.LowerRightCorner.X = checkRect.UpperLeftCorner.X + height; + checkRect.LowerRightCorner.Y = checkRect.UpperLeftCorner.Y + height; + + skin->draw3DSunkenPane(this, skin->getColor(Pressed ? EGDC_3D_FACE : EGDC_ACTIVE_CAPTION), + false, true, checkRect, &AbsoluteClippingRect); + + if (Checked && Environment->getSkin()) + Environment->getSkin()->drawIcon(this, EGDI_CHECK_BOX_CHECKED, checkRect.getCenter(), + checkTime, os::Timer::getTime(), false, &AbsoluteClippingRect); + + if (Text.size()) + { + checkRect = AbsoluteRect; + checkRect.UpperLeftCorner.X += height + 5; + + IGUIFont* font = skin->getFont(); + if (font) + font->draw(Text.c_str(), checkRect, + skin->getColor(EGDC_BUTTON_TEXT), false, true, &AbsoluteClippingRect); + } + + IGUIElement::draw(); +} + + +//! set if box is checked +void CGUICheckBox::setChecked(bool checked) +{ + Checked = checked; +} + + +//! returns if box is checked +bool CGUICheckBox::isChecked() +{ + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return Checked; +} + +//! Writes attributes of the element. +void CGUICheckBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +{ + IGUICheckBox::serializeAttributes(out,options); + out->addBool ("Checked", Checked ); +} + +//! Reads attributes of the element +void CGUICheckBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +{ + Checked = in->getAttributeAsBool ("Checked"); + + IGUICheckBox::deserializeAttributes(in,options); +} + + +} // end namespace gui +} // end namespace irr diff --git a/src/dep/src/irrlicht/CGUICheckBox.h b/src/dep/src/irrlicht/CGUICheckBox.h index 343e8d8..71f4c8b 100644 --- a/src/dep/src/irrlicht/CGUICheckBox.h +++ b/src/dep/src/irrlicht/CGUICheckBox.h @@ -1,54 +1,54 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_CHECKBOX_H_INCLUDED__ -#define __C_GUI_CHECKBOX_H_INCLUDED__ - -#include "IGUICheckBox.h" - -namespace irr -{ -namespace gui -{ - - class CGUICheckBox : public IGUICheckBox - { - public: - - //! constructor - CGUICheckBox(bool checked, IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle); - - //! destructor - ~CGUICheckBox(); - - //! set if box is checked - virtual void setChecked(bool checked); - - //! returns if box is checked - virtual bool isChecked(); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! draws the element and its children - virtual void draw(); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - bool Pressed; - bool Checked; - u32 checkTime; - }; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_CHECKBOX_H_INCLUDED__ +#define __C_GUI_CHECKBOX_H_INCLUDED__ + +#include "IGUICheckBox.h" + +namespace irr +{ +namespace gui +{ + + class CGUICheckBox : public IGUICheckBox + { + public: + + //! constructor + CGUICheckBox(bool checked, IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle); + + //! destructor + ~CGUICheckBox(); + + //! set if box is checked + virtual void setChecked(bool checked); + + //! returns if box is checked + virtual bool isChecked(); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! draws the element and its children + virtual void draw(); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + private: + + bool Pressed; + bool Checked; + u32 checkTime; + }; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIColorSelectDialog.cpp b/src/dep/src/irrlicht/CGUIColorSelectDialog.cpp index 47f8364..4adcdf6 100644 --- a/src/dep/src/irrlicht/CGUIColorSelectDialog.cpp +++ b/src/dep/src/irrlicht/CGUIColorSelectDialog.cpp @@ -1,480 +1,480 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIColorSelectDialog.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIButton.h" -#include "IGUIStaticText.h" -#include "IGUIFont.h" -#include "IGUISpriteBank.h" -#include "IFileList.h" -#include "os.h" -#include "SoftwareDriver2_helper.h" - -namespace irr -{ -namespace gui -{ - -const s32 CSD_WIDTH = 350; -const s32 CSD_HEIGHT = 300; - -struct sTemplate -{ - const wchar_t *pre; - const wchar_t *init; - const wchar_t *pos; - int x, y; - int range_down ,range_up; -}; - -static const sTemplate Template [] = -{ - { L"A:", L"0", 0,20,165, 0, 255 }, - { L"R:", L"0", 0,20,205, 0, 255 }, - { L"G:", L"0", 0,20,230, 0, 255 }, - { L"B:", L"0", 0,20,255, 0, 255 }, - { L"H:", L"0", L"°",180,205, 0, 360 }, - { L"S:", L"0", L"%",180,230, 0, 100 }, - { L"L:", L"0", L"%",180,255, 0, 100 }, -}; - -//! constructor -CGUIColorSelectDialog::CGUIColorSelectDialog( const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id) -: IGUIColorSelectDialog(environment, parent, id, - core::rect((parent->getAbsolutePosition().getWidth()-CSD_WIDTH)/2, - (parent->getAbsolutePosition().getHeight()-CSD_HEIGHT)/2, - (parent->getAbsolutePosition().getWidth()-CSD_WIDTH)/2+CSD_WIDTH, - (parent->getAbsolutePosition().getHeight()-CSD_HEIGHT)/2+CSD_HEIGHT)), - Dragging(false) -{ - #ifdef _DEBUG - IGUIElement::setDebugName("CGUIColorSelectDialog"); - #endif - - Text = title; - - IGUISkin* skin = Environment->getSkin(); - core::rect rec; - - s32 buttonw = environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH); - s32 posx = RelativeRect.getWidth() - buttonw - 4; - - CloseButton = Environment->addButton(core::rect(posx, 3, posx + buttonw, 3 + buttonw), - this, -1, L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close"); - if (skin && skin->getSpriteBank()) - { - CloseButton->setSpriteBank(skin->getSpriteBank()); - CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), skin->getColor(EGDC_WINDOW_SYMBOL)); - CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), skin->getColor(EGDC_WINDOW_SYMBOL)); - } - CloseButton->setSubElement(true); - CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - CloseButton->grab(); - - OKButton = Environment->addButton( - core::rect(RelativeRect.getWidth()-80, 30, RelativeRect.getWidth()-10, 50), - this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_OK) : L"OK"); - OKButton->setSubElement(true); - OKButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - OKButton->grab(); - - CancelButton = Environment->addButton( - core::rect(RelativeRect.getWidth()-80, 55, RelativeRect.getWidth()-10, 75), - this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_CANCEL) : L"Cancel"); - CancelButton->setSubElement(true); - CancelButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - CancelButton->grab(); - - core::rect r; - - video::IVideoDriver* driver = Environment->getVideoDriver(); - ColorRing.Texture = driver->getTexture ( "#colorring" ); - if ( 0 == ColorRing.Texture ) - { - buildColorRing(core::dimension2d(128, 128), 1, - Environment->getSkin()->getColor(EGDC_3D_SHADOW).color); - } - - r.UpperLeftCorner.X = 20; - r.UpperLeftCorner.Y = 20; - ColorRing.Control = Environment->addImage(ColorRing.Texture, r.UpperLeftCorner, true, this); - ColorRing.Control->setSubElement(true); - ColorRing.Control->grab(); - - for ( u32 i = 0; i != sizeof (Template) / sizeof ( sTemplate ); ++i ) - { - if ( Template[i].pre ) - { - r.UpperLeftCorner.X = Template[i].x; - r.UpperLeftCorner.Y = Template[i].y; - r.LowerRightCorner.X = r.UpperLeftCorner.X + 15; - r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 20; - IGUIElement *t = Environment->addStaticText( Template[i].pre, r, false, false, this); - t->setSubElement(true); - } - - if ( Template[i].pos ) - { - r.UpperLeftCorner.X = Template[i].x + 52; - r.UpperLeftCorner.Y = Template[i].y; - r.LowerRightCorner.X = r.UpperLeftCorner.X + 15; - r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 20; - IGUIElement *t = Environment->addStaticText( Template[i].pos, r, false, false, this); - t->setSubElement(true); - } - - SBatteryItem item; - - r.UpperLeftCorner.X = Template[i].x + 15; - r.UpperLeftCorner.Y = Template[i].y; - r.LowerRightCorner.X = r.UpperLeftCorner.X + 35; - r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 20; - - item.Edit = Environment->addEditBox( Template[i].init, r, true, this); - item.Edit->setSubElement(true); - item.Edit->grab(); - - r.UpperLeftCorner.X = Template[i].x + 70; - r.UpperLeftCorner.Y = Template[i].y + 4; - r.LowerRightCorner.X = r.UpperLeftCorner.X + 60; - r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 12; - - item.Scrollbar = Environment->addScrollBar(true, r, this); - item.Scrollbar->grab (); - item.Scrollbar->setSubElement(true); - item.Scrollbar->setMax ( Template[i].range_up - Template[i].range_down ); - item.Scrollbar->setSmallStep ( 1 ); - - Battery.push_back ( item ); - } - - bringToFront(CancelButton); - bringToFront(OKButton); - -} - - - -//! destructor -CGUIColorSelectDialog::~CGUIColorSelectDialog() -{ - if (CloseButton) - CloseButton->drop(); - - if (OKButton) - OKButton->drop(); - - if (CancelButton) - CancelButton->drop(); - - for ( u32 i = 0; i != Battery.size ();++i ) - { - Battery[i].Edit->drop (); - Battery[i].Scrollbar->drop (); - } - - if ( ColorRing.Control ) - { - ColorRing.Control->drop (); - } - -} - -//! renders a antialiased, colored ring -void CGUIColorSelectDialog::buildColorRing( const core::dimension2d & dim, s32 supersample, const u32 borderColor ) -{ - video::CImage *RawTexture; - - core::dimension2d d; - d.Width = dim.Width * supersample; - d.Height = dim.Height * supersample; - - RawTexture = new video::CImage ( irr::video::ECF_A8R8G8B8, d ); - - RawTexture->fill ( 0x00808080 ); - - - u8 * data= (u8*) RawTexture->lock(); - const u32 pitch = RawTexture->getPitch (); - - s32 radiusOut = ( d.Width / 2 ) - 4; - - const s32 fullR2 = radiusOut * radiusOut; - - - video::SColorHSL hsl; - video::SColor rgb; - - rgb.color = 0xFF000000; - hsl.Luminance = 0.5f; - hsl.Saturation = 1.f; - - - - core::position2d p; - u32 *dst; - for ( p.Y = -radiusOut; p.Y <= radiusOut; p.Y += 1 ) - { - s32 y2 = p.Y * p.Y; - - dst = (u32*) ( (u8* ) data + ( ( 4 + p.Y + radiusOut ) * pitch ) + (4 << 2 ) ); - - for ( p.X = -radiusOut; p.X <= radiusOut; p.X += 1, dst += 1 ) - { - s32 r2 = y2 + ( p.X * p.X ); - - // test point in circle - s32 testa = r2 - fullR2; - - if ( testa < 0 ) - { - // dotproduct u ( x,y ) * v ( 1, 0 ) = cosinus(a) - - f32 r = (f32) sqrt ( (f32) r2 ); - - // normalize, dotproduct = xnorm - f32 t = (f32) 1.0 / r; - f32 xn = -p.X * t; - - hsl.Hue = (f32) acos ( xn ); - if ( p.Y > 0 ) - hsl.Hue = (2.f * core::PI ) - hsl.Hue; - - hsl.Hue -= core::PI / 2.f; - - f32 rTest = r / radiusOut; -/* - if ( rTest < 0.25f ) - { - hsl.Luminance = rTest / 0.25f; - hsl.Saturation = 0.f; - hsl.settoRGB ( rgb ); - *dst = rgb.color; - } - else - if ( rTest < 0.4f ) - { - hsl.Saturation = ( rTest - 0.25f ) / 0.15f; - hsl.Luminance = 1.f - ( hsl.Saturation / 2.4f ); - hsl.Luminance = 0.5f; - hsl.settoRGB ( rgb ); - // *dst = rgb.color; - } - else - if ( rTest < 0.75f ) - { - hsl.Luminance = 0.5f; - hsl.Saturation = 1.f; - hsl.settoRGB ( rgb ); - *dst = rgb.color; - } - else - if ( rTest < 0.98f ) - { - hsl.Luminance = 0.5f - ( ( rTest - 0.75f ) / 0.75f ); - hsl.Saturation = 1.f; - hsl.settoRGB ( rgb ); - *dst = rgb.color; - } -*/ - - if ( rTest >= 0.5f ) - { - hsl.Luminance = 0.5f; - hsl.Saturation = 1.f; - hsl.settoRGB ( rgb ); - *dst = rgb.color; - } - - if ( rTest >= 0.5f && rTest <= 0.55f ) - { - u32 alpha = (s32) ( (rTest - 0.5f ) * ( 255.f / 0.05f ) ); - *dst = *dst & 0x00ffffff | (alpha << 24); - } - - if ( rTest >= 0.95f ) - { - u32 alpha = (s32) ( (rTest - 0.95f ) * ( 255.f / 0.05f ) ); - alpha = 255 - alpha; - *dst = *dst & 0x00ffffff | (alpha << 24); - } - - } - } - - } - - RawTexture->unlock (); - - if ( supersample > 1 ) - { - video::CImage * filter = new video::CImage(irr::video::ECF_A8R8G8B8, dim ); - RawTexture->copyToScalingBoxFilter ( filter, 0 ); - RawTexture->drop (); - RawTexture = filter; - } - - - video::IVideoDriver* driver = Environment->getVideoDriver(); - - bool generateMipLevels = driver->getTextureCreationFlag( video::ETCF_CREATE_MIP_MAPS ); - driver->setTextureCreationFlag( video::ETCF_CREATE_MIP_MAPS, false); - - ColorRing.Texture = driver->addTexture ( "#colorring", RawTexture ); - RawTexture->drop (); - - driver->setTextureCreationFlag( video::ETCF_CREATE_MIP_MAPS, generateMipLevels); - -} - - - -//! called if an event happened. -bool CGUIColorSelectDialog::OnEvent(SEvent event) -{ - - switch(event.EventType) - { - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case EGET_SCROLL_BAR_CHANGED: - { - for ( u32 i = 0; i!= Battery.size (); ++i ) - { - if ( event.GUIEvent.Caller == Battery[i].Scrollbar ) - { - s32 pos = Battery[i].Scrollbar->getPos (); - s32 value = Template[i].range_down + ( pos ); - core::stringw s ( value ); - Battery[i].Edit->setText ( s.c_str() ); - } - } - return true; - } break; - - case EGET_ELEMENT_FOCUS_LOST: - Dragging = false; - break; - case EGET_BUTTON_CLICKED: - if (event.GUIEvent.Caller == CloseButton || - event.GUIEvent.Caller == CancelButton) - { - sendCancelEvent(); - remove(); - return true; - } - else - if (event.GUIEvent.Caller == OKButton) - { - sendSelectedEvent(); - remove(); - return true; - } - break; - - case EGET_LISTBOX_CHANGED: - { - } - break; - - case EGET_LISTBOX_SELECTED_AGAIN: - { - } - break; - } - break; - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_PRESSED_DOWN: - DragStart.X = event.MouseInput.X; - DragStart.Y = event.MouseInput.Y; - Dragging = true; - Environment->setFocus(this); - return true; - case EMIE_LMOUSE_LEFT_UP: - Dragging = false; - Environment->removeFocus(this); - return true; - case EMIE_MOUSE_MOVED: - if (Dragging) - { - // gui window should not be dragged outside its parent - if (Parent) - if (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 || - event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 || - event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 || - event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1) - - return true; - - move(core::position2d(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y)); - DragStart.X = event.MouseInput.X; - DragStart.Y = event.MouseInput.Y; - return true; - } - break; - } - } - - return Parent ? Parent->OnEvent(event) : false; -} - - -//! draws the element and its children -void CGUIColorSelectDialog::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - - core::rect rect = AbsoluteRect; - - rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER), - rect, &AbsoluteClippingRect); - - if (Text.size()) - { - rect.UpperLeftCorner.X += 2; - rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; - - IGUIFont* font = skin->getFont(); - if (font) - font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true, - &AbsoluteClippingRect); - } - - IGUIElement::draw(); -} - - - - -//! sends the event that the file has been selected. -void CGUIColorSelectDialog::sendSelectedEvent() -{ - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.EventType = EGET_FILE_SELECTED; - Parent->OnEvent(event); -} - -//! sends the event that the file choose process has been canceld -void CGUIColorSelectDialog::sendCancelEvent() -{ - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.EventType = EGET_FILE_CHOOSE_DIALOG_CANCELLED; - Parent->OnEvent(event); -} - -} // end namespace gui -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIColorSelectDialog.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUIButton.h" +#include "IGUIStaticText.h" +#include "IGUIFont.h" +#include "IGUISpriteBank.h" +#include "IFileList.h" +#include "os.h" +#include "SoftwareDriver2_helper.h" + +namespace irr +{ +namespace gui +{ + +const s32 CSD_WIDTH = 350; +const s32 CSD_HEIGHT = 300; + +struct sTemplate +{ + const wchar_t *pre; + const wchar_t *init; + const wchar_t *pos; + int x, y; + int range_down ,range_up; +}; + +static const sTemplate Template [] = +{ + { L"A:", L"0", 0,20,165, 0, 255 }, + { L"R:", L"0", 0,20,205, 0, 255 }, + { L"G:", L"0", 0,20,230, 0, 255 }, + { L"B:", L"0", 0,20,255, 0, 255 }, + { L"H:", L"0", L"°",180,205, 0, 360 }, + { L"S:", L"0", L"%",180,230, 0, 100 }, + { L"L:", L"0", L"%",180,255, 0, 100 }, +}; + +//! constructor +CGUIColorSelectDialog::CGUIColorSelectDialog( const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id) +: IGUIColorSelectDialog(environment, parent, id, + core::rect((parent->getAbsolutePosition().getWidth()-CSD_WIDTH)/2, + (parent->getAbsolutePosition().getHeight()-CSD_HEIGHT)/2, + (parent->getAbsolutePosition().getWidth()-CSD_WIDTH)/2+CSD_WIDTH, + (parent->getAbsolutePosition().getHeight()-CSD_HEIGHT)/2+CSD_HEIGHT)), + Dragging(false) +{ + #ifdef _DEBUG + IGUIElement::setDebugName("CGUIColorSelectDialog"); + #endif + + Text = title; + + IGUISkin* skin = Environment->getSkin(); + core::rect rec; + + s32 buttonw = environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH); + s32 posx = RelativeRect.getWidth() - buttonw - 4; + + CloseButton = Environment->addButton(core::rect(posx, 3, posx + buttonw, 3 + buttonw), + this, -1, L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close"); + if (skin && skin->getSpriteBank()) + { + CloseButton->setSpriteBank(skin->getSpriteBank()); + CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), skin->getColor(EGDC_WINDOW_SYMBOL)); + CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), skin->getColor(EGDC_WINDOW_SYMBOL)); + } + CloseButton->setSubElement(true); + CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + CloseButton->grab(); + + OKButton = Environment->addButton( + core::rect(RelativeRect.getWidth()-80, 30, RelativeRect.getWidth()-10, 50), + this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_OK) : L"OK"); + OKButton->setSubElement(true); + OKButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + OKButton->grab(); + + CancelButton = Environment->addButton( + core::rect(RelativeRect.getWidth()-80, 55, RelativeRect.getWidth()-10, 75), + this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_CANCEL) : L"Cancel"); + CancelButton->setSubElement(true); + CancelButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + CancelButton->grab(); + + core::rect r; + + video::IVideoDriver* driver = Environment->getVideoDriver(); + ColorRing.Texture = driver->getTexture ( "#colorring" ); + if ( 0 == ColorRing.Texture ) + { + buildColorRing(core::dimension2d(128, 128), 1, + Environment->getSkin()->getColor(EGDC_3D_SHADOW).color); + } + + r.UpperLeftCorner.X = 20; + r.UpperLeftCorner.Y = 20; + ColorRing.Control = Environment->addImage(ColorRing.Texture, r.UpperLeftCorner, true, this); + ColorRing.Control->setSubElement(true); + ColorRing.Control->grab(); + + for ( u32 i = 0; i != sizeof (Template) / sizeof ( sTemplate ); ++i ) + { + if ( Template[i].pre ) + { + r.UpperLeftCorner.X = Template[i].x; + r.UpperLeftCorner.Y = Template[i].y; + r.LowerRightCorner.X = r.UpperLeftCorner.X + 15; + r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 20; + IGUIElement *t = Environment->addStaticText( Template[i].pre, r, false, false, this); + t->setSubElement(true); + } + + if ( Template[i].pos ) + { + r.UpperLeftCorner.X = Template[i].x + 52; + r.UpperLeftCorner.Y = Template[i].y; + r.LowerRightCorner.X = r.UpperLeftCorner.X + 15; + r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 20; + IGUIElement *t = Environment->addStaticText( Template[i].pos, r, false, false, this); + t->setSubElement(true); + } + + SBatteryItem item; + + r.UpperLeftCorner.X = Template[i].x + 15; + r.UpperLeftCorner.Y = Template[i].y; + r.LowerRightCorner.X = r.UpperLeftCorner.X + 35; + r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 20; + + item.Edit = Environment->addEditBox( Template[i].init, r, true, this); + item.Edit->setSubElement(true); + item.Edit->grab(); + + r.UpperLeftCorner.X = Template[i].x + 70; + r.UpperLeftCorner.Y = Template[i].y + 4; + r.LowerRightCorner.X = r.UpperLeftCorner.X + 60; + r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 12; + + item.Scrollbar = Environment->addScrollBar(true, r, this); + item.Scrollbar->grab (); + item.Scrollbar->setSubElement(true); + item.Scrollbar->setMax ( Template[i].range_up - Template[i].range_down ); + item.Scrollbar->setSmallStep ( 1 ); + + Battery.push_back ( item ); + } + + bringToFront(CancelButton); + bringToFront(OKButton); + +} + + + +//! destructor +CGUIColorSelectDialog::~CGUIColorSelectDialog() +{ + if (CloseButton) + CloseButton->drop(); + + if (OKButton) + OKButton->drop(); + + if (CancelButton) + CancelButton->drop(); + + for ( u32 i = 0; i != Battery.size ();++i ) + { + Battery[i].Edit->drop (); + Battery[i].Scrollbar->drop (); + } + + if ( ColorRing.Control ) + { + ColorRing.Control->drop (); + } + +} + +//! renders a antialiased, colored ring +void CGUIColorSelectDialog::buildColorRing( const core::dimension2d & dim, s32 supersample, const u32 borderColor ) +{ + video::CImage *RawTexture; + + core::dimension2d d; + d.Width = dim.Width * supersample; + d.Height = dim.Height * supersample; + + RawTexture = new video::CImage ( irr::video::ECF_A8R8G8B8, d ); + + RawTexture->fill ( 0x00808080 ); + + + u8 * data= (u8*) RawTexture->lock(); + const u32 pitch = RawTexture->getPitch (); + + s32 radiusOut = ( d.Width / 2 ) - 4; + + const s32 fullR2 = radiusOut * radiusOut; + + + video::SColorHSL hsl; + video::SColor rgb; + + rgb.color = 0xFF000000; + hsl.Luminance = 0.5f; + hsl.Saturation = 1.f; + + + + core::position2d p; + u32 *dst; + for ( p.Y = -radiusOut; p.Y <= radiusOut; p.Y += 1 ) + { + s32 y2 = p.Y * p.Y; + + dst = (u32*) ( (u8* ) data + ( ( 4 + p.Y + radiusOut ) * pitch ) + (4 << 2 ) ); + + for ( p.X = -radiusOut; p.X <= radiusOut; p.X += 1, dst += 1 ) + { + s32 r2 = y2 + ( p.X * p.X ); + + // test point in circle + s32 testa = r2 - fullR2; + + if ( testa < 0 ) + { + // dotproduct u ( x,y ) * v ( 1, 0 ) = cosinus(a) + + f32 r = (f32) sqrt ( (f32) r2 ); + + // normalize, dotproduct = xnorm + f32 t = (f32) 1.0 / r; + f32 xn = -p.X * t; + + hsl.Hue = (f32) acos ( xn ); + if ( p.Y > 0 ) + hsl.Hue = (2.f * core::PI ) - hsl.Hue; + + hsl.Hue -= core::PI / 2.f; + + f32 rTest = r / radiusOut; +/* + if ( rTest < 0.25f ) + { + hsl.Luminance = rTest / 0.25f; + hsl.Saturation = 0.f; + hsl.settoRGB ( rgb ); + *dst = rgb.color; + } + else + if ( rTest < 0.4f ) + { + hsl.Saturation = ( rTest - 0.25f ) / 0.15f; + hsl.Luminance = 1.f - ( hsl.Saturation / 2.4f ); + hsl.Luminance = 0.5f; + hsl.settoRGB ( rgb ); + // *dst = rgb.color; + } + else + if ( rTest < 0.75f ) + { + hsl.Luminance = 0.5f; + hsl.Saturation = 1.f; + hsl.settoRGB ( rgb ); + *dst = rgb.color; + } + else + if ( rTest < 0.98f ) + { + hsl.Luminance = 0.5f - ( ( rTest - 0.75f ) / 0.75f ); + hsl.Saturation = 1.f; + hsl.settoRGB ( rgb ); + *dst = rgb.color; + } +*/ + + if ( rTest >= 0.5f ) + { + hsl.Luminance = 0.5f; + hsl.Saturation = 1.f; + hsl.settoRGB ( rgb ); + *dst = rgb.color; + } + + if ( rTest >= 0.5f && rTest <= 0.55f ) + { + u32 alpha = (s32) ( (rTest - 0.5f ) * ( 255.f / 0.05f ) ); + *dst = *dst & 0x00ffffff | (alpha << 24); + } + + if ( rTest >= 0.95f ) + { + u32 alpha = (s32) ( (rTest - 0.95f ) * ( 255.f / 0.05f ) ); + alpha = 255 - alpha; + *dst = *dst & 0x00ffffff | (alpha << 24); + } + + } + } + + } + + RawTexture->unlock (); + + if ( supersample > 1 ) + { + video::CImage * filter = new video::CImage(irr::video::ECF_A8R8G8B8, dim ); + RawTexture->copyToScalingBoxFilter ( filter, 0 ); + RawTexture->drop (); + RawTexture = filter; + } + + + video::IVideoDriver* driver = Environment->getVideoDriver(); + + bool generateMipLevels = driver->getTextureCreationFlag( video::ETCF_CREATE_MIP_MAPS ); + driver->setTextureCreationFlag( video::ETCF_CREATE_MIP_MAPS, false); + + ColorRing.Texture = driver->addTexture ( "#colorring", RawTexture ); + RawTexture->drop (); + + driver->setTextureCreationFlag( video::ETCF_CREATE_MIP_MAPS, generateMipLevels); + +} + + + +//! called if an event happened. +bool CGUIColorSelectDialog::OnEvent(SEvent event) +{ + + switch(event.EventType) + { + case EET_GUI_EVENT: + switch(event.GUIEvent.EventType) + { + case EGET_SCROLL_BAR_CHANGED: + { + for ( u32 i = 0; i!= Battery.size (); ++i ) + { + if ( event.GUIEvent.Caller == Battery[i].Scrollbar ) + { + s32 pos = Battery[i].Scrollbar->getPos (); + s32 value = Template[i].range_down + ( pos ); + core::stringw s ( value ); + Battery[i].Edit->setText ( s.c_str() ); + } + } + return true; + } break; + + case EGET_ELEMENT_FOCUS_LOST: + Dragging = false; + break; + case EGET_BUTTON_CLICKED: + if (event.GUIEvent.Caller == CloseButton || + event.GUIEvent.Caller == CancelButton) + { + sendCancelEvent(); + remove(); + return true; + } + else + if (event.GUIEvent.Caller == OKButton) + { + sendSelectedEvent(); + remove(); + return true; + } + break; + + case EGET_LISTBOX_CHANGED: + { + } + break; + + case EGET_LISTBOX_SELECTED_AGAIN: + { + } + break; + } + break; + case EET_MOUSE_INPUT_EVENT: + switch(event.MouseInput.Event) + { + case EMIE_LMOUSE_PRESSED_DOWN: + DragStart.X = event.MouseInput.X; + DragStart.Y = event.MouseInput.Y; + Dragging = true; + Environment->setFocus(this); + return true; + case EMIE_LMOUSE_LEFT_UP: + Dragging = false; + Environment->removeFocus(this); + return true; + case EMIE_MOUSE_MOVED: + if (Dragging) + { + // gui window should not be dragged outside its parent + if (Parent) + if (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 || + event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 || + event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 || + event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1) + + return true; + + move(core::position2d(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y)); + DragStart.X = event.MouseInput.X; + DragStart.Y = event.MouseInput.Y; + return true; + } + break; + } + } + + return Parent ? Parent->OnEvent(event) : false; +} + + +//! draws the element and its children +void CGUIColorSelectDialog::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + + core::rect rect = AbsoluteRect; + + rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER), + rect, &AbsoluteClippingRect); + + if (Text.size()) + { + rect.UpperLeftCorner.X += 2; + rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; + + IGUIFont* font = skin->getFont(); + if (font) + font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true, + &AbsoluteClippingRect); + } + + IGUIElement::draw(); +} + + + + +//! sends the event that the file has been selected. +void CGUIColorSelectDialog::sendSelectedEvent() +{ + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.EventType = EGET_FILE_SELECTED; + Parent->OnEvent(event); +} + +//! sends the event that the file choose process has been canceld +void CGUIColorSelectDialog::sendCancelEvent() +{ + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.EventType = EGET_FILE_CHOOSE_DIALOG_CANCELLED; + Parent->OnEvent(event); +} + +} // end namespace gui +} // end namespace irr diff --git a/src/dep/src/irrlicht/CGUIColorSelectDialog.h b/src/dep/src/irrlicht/CGUIColorSelectDialog.h index 0a38c38..cd60b33 100644 --- a/src/dep/src/irrlicht/CGUIColorSelectDialog.h +++ b/src/dep/src/irrlicht/CGUIColorSelectDialog.h @@ -1,79 +1,79 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ -#define __C_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ - -#include "IGUIColorSelectDialog.h" -#include "IGUIButton.h" -#include "IGUIListBox.h" -#include "IGUIEditBox.h" -#include "IGUIScrollBar.h" -#include "IGUIImage.h" - -#include "irrArray.h" -#include "CImage.h" - - -namespace irr -{ -namespace gui -{ - - class CGUIColorSelectDialog : public IGUIColorSelectDialog - { - public: - - //! constructor - CGUIColorSelectDialog(const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id); - - //! destructor - virtual ~CGUIColorSelectDialog(); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! draws the element and its children - virtual void draw(); - - private: - - //! sends the event that the file has been selected. - void sendSelectedEvent(); - - //! sends the event that the file choose process has been canceld - void sendCancelEvent(); - - core::position2d DragStart; - bool Dragging; - IGUIButton* CloseButton; - IGUIButton* OKButton; - IGUIButton* CancelButton; - - struct SBatteryItem - { - f32 Incoming; - f32 Outgoing; - IGUIEditBox * Edit; - IGUIScrollBar *Scrollbar; - }; - core::array< SBatteryItem > Battery; - - struct SColorCircle - { - IGUIImage * Control; - video::ITexture * Texture; - }; - SColorCircle ColorRing; - - void buildColorRing( const core::dimension2d & dim, s32 supersample, const u32 borderColor ); - - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ +#define __C_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ + +#include "IGUIColorSelectDialog.h" +#include "IGUIButton.h" +#include "IGUIListBox.h" +#include "IGUIEditBox.h" +#include "IGUIScrollBar.h" +#include "IGUIImage.h" + +#include "irrArray.h" +#include "CImage.h" + + +namespace irr +{ +namespace gui +{ + + class CGUIColorSelectDialog : public IGUIColorSelectDialog + { + public: + + //! constructor + CGUIColorSelectDialog(const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id); + + //! destructor + virtual ~CGUIColorSelectDialog(); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! draws the element and its children + virtual void draw(); + + private: + + //! sends the event that the file has been selected. + void sendSelectedEvent(); + + //! sends the event that the file choose process has been canceld + void sendCancelEvent(); + + core::position2d DragStart; + bool Dragging; + IGUIButton* CloseButton; + IGUIButton* OKButton; + IGUIButton* CancelButton; + + struct SBatteryItem + { + f32 Incoming; + f32 Outgoing; + IGUIEditBox * Edit; + IGUIScrollBar *Scrollbar; + }; + core::array< SBatteryItem > Battery; + + struct SColorCircle + { + IGUIImage * Control; + video::ITexture * Texture; + }; + SColorCircle ColorRing; + + void buildColorRing( const core::dimension2d & dim, s32 supersample, const u32 borderColor ); + + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIComboBox.cpp b/src/dep/src/irrlicht/CGUIComboBox.cpp index 3f3105f..f4131c4 100644 --- a/src/dep/src/irrlicht/CGUIComboBox.cpp +++ b/src/dep/src/irrlicht/CGUIComboBox.cpp @@ -1,326 +1,326 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "CGUIComboBox.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IGUIFont.h" -#include "CGUIListBox.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIComboBox::CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect rectangle) - : IGUIComboBox(environment, parent, id, rectangle), - ListButton(0), ListBox(0), Selected(-1) -{ - #ifdef _DEBUG - setDebugName("CGUICheckBox"); - #endif - - IGUISkin* skin = Environment->getSkin(); - - s32 width = 15; - if (skin) - width = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); - - core::rect r; - r.UpperLeftCorner.X = rectangle.getWidth() - width - 2; - r.LowerRightCorner.X = rectangle.getWidth() - 2; - - r.UpperLeftCorner.Y = 2; - r.LowerRightCorner.Y = rectangle.getHeight() - 2; - - ListButton = Environment->addButton(r, this, -1, L""); - if (skin && skin->getSpriteBank()) - { - ListButton->setSpriteBank(skin->getSpriteBank()); - ListButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(EGDC_WINDOW_SYMBOL)); - ListButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(EGDC_WINDOW_SYMBOL)); - } - ListButton->setSubElement(true); - - setNotClipped(true); -} - - -//! destructor -CGUIComboBox::~CGUIComboBox() -{ -} - - -//! Returns amount of items in box -s32 CGUIComboBox::getItemCount() -{ - return Items.size(); -} - -//! returns string of an item. the idx may be a value from 0 to itemCount-1 -const wchar_t* CGUIComboBox::getItem(s32 idx) -{ - if (idx < 0 || idx >= (s32)Items.size()) - return 0; - - return Items[idx].c_str(); -} - -//! Returns caption of this element. -const wchar_t* CGUIComboBox::getText() -{ - return getItem(Selected); -} - - -//! adds an item and returns the index of it -s32 CGUIComboBox::addItem(const wchar_t* text) -{ - Items.push_back(core::stringw(text)); - - if (Selected == -1) - Selected = 0; - - return Items.size() - 1; -} - - - -//! deletes all items in the combo box -void CGUIComboBox::clear() -{ - Items.clear(); - Selected = -1; -} - - - -//! returns id of selected item. returns -1 if no item is selected. -s32 CGUIComboBox::getSelected() -{ - return Selected; -} - - - -//! sets the selected item. Set this to -1 if no item should be selected -void CGUIComboBox::setSelected(s32 id) -{ - if (id <0 || id>=(s32)Items.size()) - return; - - Selected = id; -} - -void CGUIComboBox::updateAbsolutePosition() -{ - IGUIElement::updateAbsolutePosition(); - - s32 width = Environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH); - - ListButton->setRelativePosition(core::rect(RelativeRect.getWidth() - width - 2, 2, - RelativeRect.getWidth() - 2, RelativeRect.getHeight() - 2)); -} - - -//! called if an event happened. -bool CGUIComboBox::OnEvent(SEvent event) -{ - switch(event.EventType) - { - case EET_GUI_EVENT: - - switch(event.GUIEvent.EventType) - { - case EGET_BUTTON_CLICKED: - if (event.GUIEvent.Caller == ListButton) - { - openCloseMenu(); - return true; - } - break; - case EGET_LISTBOX_SELECTED_AGAIN: - case EGET_LISTBOX_CHANGED: - if (event.GUIEvent.Caller == ListBox) - { - Selected = ListBox->getSelected(); - if (Selected <0 || Selected >= (s32)Items.size()) - Selected = -1; - openCloseMenu(); - - sendSelectionChangedEvent(); - } - return true; - } - break; - case EET_MOUSE_INPUT_EVENT: - - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_PRESSED_DOWN: - { - if (!ListBox) - Environment->removeFocus(this); - - core::position2d p(event.MouseInput.X, event.MouseInput.Y); - - // send to list box - if (ListBox && ListBox->getAbsolutePosition().isPointInside(p) && - ListBox->OnEvent(event)) - return true; - - // check if it is outside - if (!AbsoluteClippingRect.isPointInside(p)) - { - Environment->removeFocus(this); - return false; - } - return true; - } - case EMIE_LMOUSE_LEFT_UP: - { - core::position2d p(event.MouseInput.X, event.MouseInput.Y); - - // send to list box - if (ListBox && ListBox->getAbsolutePosition().isPointInside(p) && - ListBox->OnEvent(event)) - return true; - else - openCloseMenu(); - - if (!AbsoluteClippingRect.isPointInside(p)) - { - Environment->removeFocus(this); - return false; - } - } - break; - } - break; - } - - return Parent ? Parent->OnEvent(event) : false; -} - - - -void CGUIComboBox::sendSelectionChangedEvent() -{ - if (Parent) - { - SEvent event; - - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.EventType = EGET_COMBO_BOX_CHANGED; - Parent->OnEvent(event); - } -} - - - -//! draws the element and its children -void CGUIComboBox::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - - core::rect frameRect(AbsoluteRect); - - // draw the border - - skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), - true, true, frameRect, &AbsoluteClippingRect); - - // Draw text - - if (Selected != -1) - { - frameRect = AbsoluteRect; - frameRect.UpperLeftCorner.X += 2; - - IGUIFont* font = skin->getFont(); - if (font) - font->draw(Items[Selected].c_str(), frameRect, - skin->getColor(EGDC_BUTTON_TEXT), - false, true, &AbsoluteClippingRect); - } - - // draw buttons - IGUIElement::draw(); -} - - -void CGUIComboBox::openCloseMenu() -{ - if (ListBox) - { - // close list box - ListBox->remove(); - ListBox = 0; - } - else - { - if (Parent) - Parent->bringToFront(this); - - IGUISkin* skin = Environment->getSkin(); - s32 h = Items.size(); - - if (h > 5) - h = 5; - if (h == 0) - h = 1; - - IGUIFont* font = skin->getFont(); - if (font) - h *= (font->getDimension(L"A").Height + 4); - - // open list box - core::rect r(0, AbsoluteRect.getHeight(), - AbsoluteRect.getWidth(), AbsoluteRect.getHeight() + h); - - ListBox = new CGUIListBox(Environment, this, -1, r, false, true, true); - ListBox->setSubElement(true); - ListBox->drop(); - - for (s32 i=0; i<(s32)Items.size(); ++i) - ListBox->addItem(Items[i].c_str()); - - ListBox->setSelected(Selected); - - // set focus - Environment->setFocus(ListBox); - } -} - -//! Writes attributes of the element. -void CGUIComboBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) -{ - IGUIComboBox::serializeAttributes(out,options); - - out->addInt ("Selected", Selected ); - out->addArray ("Items", Items); -} - -//! Reads attributes of the element -void CGUIComboBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - Items = in->getAttributeAsArray("Items"); - IGUIComboBox::deserializeAttributes(in,options); - - setSelected(in->getAttributeAsInt("Selected")); -} - -} // end namespace gui -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "CGUIComboBox.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IGUIFont.h" +#include "CGUIListBox.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIComboBox::CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent, + s32 id, core::rect rectangle) + : IGUIComboBox(environment, parent, id, rectangle), + ListButton(0), ListBox(0), Selected(-1) +{ + #ifdef _DEBUG + setDebugName("CGUICheckBox"); + #endif + + IGUISkin* skin = Environment->getSkin(); + + s32 width = 15; + if (skin) + width = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); + + core::rect r; + r.UpperLeftCorner.X = rectangle.getWidth() - width - 2; + r.LowerRightCorner.X = rectangle.getWidth() - 2; + + r.UpperLeftCorner.Y = 2; + r.LowerRightCorner.Y = rectangle.getHeight() - 2; + + ListButton = Environment->addButton(r, this, -1, L""); + if (skin && skin->getSpriteBank()) + { + ListButton->setSpriteBank(skin->getSpriteBank()); + ListButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(EGDC_WINDOW_SYMBOL)); + ListButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(EGDC_WINDOW_SYMBOL)); + } + ListButton->setSubElement(true); + + setNotClipped(true); +} + + +//! destructor +CGUIComboBox::~CGUIComboBox() +{ +} + + +//! Returns amount of items in box +s32 CGUIComboBox::getItemCount() +{ + return Items.size(); +} + +//! returns string of an item. the idx may be a value from 0 to itemCount-1 +const wchar_t* CGUIComboBox::getItem(s32 idx) +{ + if (idx < 0 || idx >= (s32)Items.size()) + return 0; + + return Items[idx].c_str(); +} + +//! Returns caption of this element. +const wchar_t* CGUIComboBox::getText() +{ + return getItem(Selected); +} + + +//! adds an item and returns the index of it +s32 CGUIComboBox::addItem(const wchar_t* text) +{ + Items.push_back(core::stringw(text)); + + if (Selected == -1) + Selected = 0; + + return Items.size() - 1; +} + + + +//! deletes all items in the combo box +void CGUIComboBox::clear() +{ + Items.clear(); + Selected = -1; +} + + + +//! returns id of selected item. returns -1 if no item is selected. +s32 CGUIComboBox::getSelected() +{ + return Selected; +} + + + +//! sets the selected item. Set this to -1 if no item should be selected +void CGUIComboBox::setSelected(s32 id) +{ + if (id <0 || id>=(s32)Items.size()) + return; + + Selected = id; +} + +void CGUIComboBox::updateAbsolutePosition() +{ + IGUIElement::updateAbsolutePosition(); + + s32 width = Environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH); + + ListButton->setRelativePosition(core::rect(RelativeRect.getWidth() - width - 2, 2, + RelativeRect.getWidth() - 2, RelativeRect.getHeight() - 2)); +} + + +//! called if an event happened. +bool CGUIComboBox::OnEvent(SEvent event) +{ + switch(event.EventType) + { + case EET_GUI_EVENT: + + switch(event.GUIEvent.EventType) + { + case EGET_BUTTON_CLICKED: + if (event.GUIEvent.Caller == ListButton) + { + openCloseMenu(); + return true; + } + break; + case EGET_LISTBOX_SELECTED_AGAIN: + case EGET_LISTBOX_CHANGED: + if (event.GUIEvent.Caller == ListBox) + { + Selected = ListBox->getSelected(); + if (Selected <0 || Selected >= (s32)Items.size()) + Selected = -1; + openCloseMenu(); + + sendSelectionChangedEvent(); + } + return true; + } + break; + case EET_MOUSE_INPUT_EVENT: + + switch(event.MouseInput.Event) + { + case EMIE_LMOUSE_PRESSED_DOWN: + { + if (!ListBox) + Environment->removeFocus(this); + + core::position2d p(event.MouseInput.X, event.MouseInput.Y); + + // send to list box + if (ListBox && ListBox->getAbsolutePosition().isPointInside(p) && + ListBox->OnEvent(event)) + return true; + + // check if it is outside + if (!AbsoluteClippingRect.isPointInside(p)) + { + Environment->removeFocus(this); + return false; + } + return true; + } + case EMIE_LMOUSE_LEFT_UP: + { + core::position2d p(event.MouseInput.X, event.MouseInput.Y); + + // send to list box + if (ListBox && ListBox->getAbsolutePosition().isPointInside(p) && + ListBox->OnEvent(event)) + return true; + else + openCloseMenu(); + + if (!AbsoluteClippingRect.isPointInside(p)) + { + Environment->removeFocus(this); + return false; + } + } + break; + } + break; + } + + return Parent ? Parent->OnEvent(event) : false; +} + + + +void CGUIComboBox::sendSelectionChangedEvent() +{ + if (Parent) + { + SEvent event; + + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.EventType = EGET_COMBO_BOX_CHANGED; + Parent->OnEvent(event); + } +} + + + +//! draws the element and its children +void CGUIComboBox::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + + core::rect frameRect(AbsoluteRect); + + // draw the border + + skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), + true, true, frameRect, &AbsoluteClippingRect); + + // Draw text + + if (Selected != -1) + { + frameRect = AbsoluteRect; + frameRect.UpperLeftCorner.X += 2; + + IGUIFont* font = skin->getFont(); + if (font) + font->draw(Items[Selected].c_str(), frameRect, + skin->getColor(EGDC_BUTTON_TEXT), + false, true, &AbsoluteClippingRect); + } + + // draw buttons + IGUIElement::draw(); +} + + +void CGUIComboBox::openCloseMenu() +{ + if (ListBox) + { + // close list box + ListBox->remove(); + ListBox = 0; + } + else + { + if (Parent) + Parent->bringToFront(this); + + IGUISkin* skin = Environment->getSkin(); + s32 h = Items.size(); + + if (h > 5) + h = 5; + if (h == 0) + h = 1; + + IGUIFont* font = skin->getFont(); + if (font) + h *= (font->getDimension(L"A").Height + 4); + + // open list box + core::rect r(0, AbsoluteRect.getHeight(), + AbsoluteRect.getWidth(), AbsoluteRect.getHeight() + h); + + ListBox = new CGUIListBox(Environment, this, -1, r, false, true, true); + ListBox->setSubElement(true); + ListBox->drop(); + + for (s32 i=0; i<(s32)Items.size(); ++i) + ListBox->addItem(Items[i].c_str()); + + ListBox->setSelected(Selected); + + // set focus + Environment->setFocus(ListBox); + } +} + +//! Writes attributes of the element. +void CGUIComboBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +{ + IGUIComboBox::serializeAttributes(out,options); + + out->addInt ("Selected", Selected ); + out->addArray ("Items", Items); +} + +//! Reads attributes of the element +void CGUIComboBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +{ + Items = in->getAttributeAsArray("Items"); + IGUIComboBox::deserializeAttributes(in,options); + + setSelected(in->getAttributeAsInt("Selected")); +} + +} // end namespace gui +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CGUIComboBox.h b/src/dep/src/irrlicht/CGUIComboBox.h index 8257ccf..6ecfc10 100644 --- a/src/dep/src/irrlicht/CGUIComboBox.h +++ b/src/dep/src/irrlicht/CGUIComboBox.h @@ -1,80 +1,80 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_COMBO_BOX_H_INCLUDED__ -#define __C_GUI_COMBO_BOX_H_INCLUDED__ - -#include "IGUIComboBox.h" -#include "irrString.h" -#include "irrArray.h" - -namespace irr -{ -namespace gui -{ - //! Single line edit box for editing simple text. - class CGUIComboBox : public IGUIComboBox - { - public: - - //! constructor - CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect rectangle); - - //! destructor - ~CGUIComboBox(); - - //! Returns amount of items in box - virtual s32 getItemCount(); - - //! returns string of an item. the idx may be a value from 0 to itemCount-1 - virtual const wchar_t* getItem(s32 idx); - - //! adds an item and returns the index of it - virtual s32 addItem(const wchar_t* text); - - //! deletes all items in the combo box - virtual void clear(); - - //! returns the text of the currently selected item - virtual const wchar_t* getText(); - - //! returns id of selected item. returns -1 if no item is selected. - virtual s32 getSelected(); - - //! sets the selected item. Set this to -1 if no item should be selected - virtual void setSelected(s32 id); - - //! update the position - virtual void updateAbsolutePosition(); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! draws the element and its children - virtual void draw(); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - void openCloseMenu(); - void sendSelectionChangedEvent(); - - IGUIButton* ListButton; - IGUIListBox* ListBox; - core::array< core::stringw > Items; - s32 Selected; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_COMBO_BOX_H_INCLUDED__ +#define __C_GUI_COMBO_BOX_H_INCLUDED__ + +#include "IGUIComboBox.h" +#include "irrString.h" +#include "irrArray.h" + +namespace irr +{ +namespace gui +{ + //! Single line edit box for editing simple text. + class CGUIComboBox : public IGUIComboBox + { + public: + + //! constructor + CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent, + s32 id, core::rect rectangle); + + //! destructor + ~CGUIComboBox(); + + //! Returns amount of items in box + virtual s32 getItemCount(); + + //! returns string of an item. the idx may be a value from 0 to itemCount-1 + virtual const wchar_t* getItem(s32 idx); + + //! adds an item and returns the index of it + virtual s32 addItem(const wchar_t* text); + + //! deletes all items in the combo box + virtual void clear(); + + //! returns the text of the currently selected item + virtual const wchar_t* getText(); + + //! returns id of selected item. returns -1 if no item is selected. + virtual s32 getSelected(); + + //! sets the selected item. Set this to -1 if no item should be selected + virtual void setSelected(s32 id); + + //! update the position + virtual void updateAbsolutePosition(); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! draws the element and its children + virtual void draw(); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + private: + + void openCloseMenu(); + void sendSelectionChangedEvent(); + + IGUIButton* ListButton; + IGUIListBox* ListBox; + core::array< core::stringw > Items; + s32 Selected; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIContextMenu.cpp b/src/dep/src/irrlicht/CGUIContextMenu.cpp index ced0d35..2a6cf82 100644 --- a/src/dep/src/irrlicht/CGUIContextMenu.cpp +++ b/src/dep/src/irrlicht/CGUIContextMenu.cpp @@ -1,656 +1,656 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIContextMenu.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIFont.h" -#include "IGUISpriteBank.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - - - -//! constructor -CGUIContextMenu::CGUIContextMenu(IGUIEnvironment* environment, - IGUIElement* parent, s32 id, - core::rect rectangle, bool getFocus) -: IGUIContextMenu(environment, parent, id, rectangle), HighLighted(-1), ChangeTime(0) -{ - #ifdef _DEBUG - setDebugName("CGUIContextMenu"); - #endif - - Pos = rectangle.UpperLeftCorner; - recalculateSize(); - - if (getFocus) - Environment->setFocus(this); - - setNotClipped(true); -} - - -//! destructor -CGUIContextMenu::~CGUIContextMenu() -{ - for (s32 i=0; i<(s32)Items.size(); ++i) - if (Items[i].SubMenu) - Items[i].SubMenu->drop(); -} - - -//! Returns amount of menu items -s32 CGUIContextMenu::getItemCount() const -{ - return Items.size(); -} - - -//! Adds a menu item. -s32 CGUIContextMenu::addItem(const wchar_t* text, s32 id, bool enabled, bool hasSubMenu, bool checked) -{ - SItem s; - s.Enabled = enabled; - s.Checked = checked; - s.Text = text; - s.IsSeparator = (text == 0); - s.SubMenu = 0; - s.CommandId = id; - - if (hasSubMenu) - { - s.SubMenu = new CGUIContextMenu(Environment, this, id, - core::rect(0,0,100,100), false); - s.SubMenu->setVisible(false); - } - - Items.push_back(s); - - recalculateSize(); - return Items.size() - 1; -} - -//! Adds a sub menu from an element that already exists. -void CGUIContextMenu::setSubMenu(s32 index, CGUIContextMenu* menu) -{ - if (index >= (s32)Items.size() || index < 0) - return; - - if (Items[index].SubMenu) - Items[index].SubMenu->drop(); - - Items[index].SubMenu = menu; - menu->setVisible(false); - - if (Items[index].SubMenu) - menu->grab(); - - recalculateSize(); -} - - -//! Adds a separator item to the menu -void CGUIContextMenu::addSeparator() -{ - addItem(0, -1, true, false, false); -} - - -//! Returns text of the menu item. -const wchar_t* CGUIContextMenu::getItemText(s32 idx) -{ - if (idx < 0 || idx >= (s32)Items.size()) - return 0; - - return Items[idx].Text.c_str(); -} - - -//! Sets text of the menu item. -void CGUIContextMenu::setItemText(s32 idx, const wchar_t* text) -{ - if (idx < 0 || idx >= (s32)Items.size()) - return; - - Items[idx].Text = text; - recalculateSize(); -} - - -//! Returns if a menu item is enabled -bool CGUIContextMenu::isItemEnabled(s32 idx) -{ - if (idx < 0 || idx >= (s32)Items.size()) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Items[idx].Enabled; -} - - -//! Sets if the menu item should be enabled. -void CGUIContextMenu::setItemEnabled(s32 idx, bool enabled) -{ - if (idx < 0 || idx >= (s32)Items.size()) - return; - - Items[idx].Enabled = enabled; -} - -//! Sets if the menu item should be checked. -void CGUIContextMenu::setItemChecked(s32 idx, bool checked ) -{ - if (idx < 0 || idx >= (s32)Items.size()) - return; - - Items[idx].Checked = checked; -} - - -//! Removes a menu item -void CGUIContextMenu::removeItem(s32 idx) -{ - if (idx < 0 || idx >= (s32)Items.size()) - return; - - if (Items[idx].SubMenu) - { - Items[idx].SubMenu->drop(); - Items[idx].SubMenu = 0; - } - - Items.erase(idx); - recalculateSize(); -} - - -//! Removes all menu items -void CGUIContextMenu::removeAllItems() -{ - for (s32 i=0; i<(s32)Items.size(); ++i) - if (Items[i].SubMenu) - Items[i].SubMenu->drop(); - - Items.clear(); - recalculateSize(); -} - - -//! called if an event happened. -bool CGUIContextMenu::OnEvent(SEvent event) -{ - if (!IsEnabled) - return Parent ? Parent->OnEvent(event) : false; - - switch(event.EventType) - { - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case gui::EGET_ELEMENT_FOCUS_LOST: - if (event.GUIEvent.Caller == (IGUIElement*)this) - { - remove(); - return true; - } - break; - } - break; - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_LEFT_UP: - { - // menu might be removed if it loses focus in sendClick, so grab a reference - grab(); - s32 t = sendClick(core::position2d(event.MouseInput.X, event.MouseInput.Y)); - if ((t==0 || t==1) && Environment->hasFocus(this)) - Environment->removeFocus(this); - drop(); - } - return true; - case EMIE_LMOUSE_PRESSED_DOWN: - return true; - case EMIE_MOUSE_MOVED: - if (Environment->hasFocus(this)) - highlight(core::position2d(event.MouseInput.X, event.MouseInput.Y)); - return true; - } - break; - } - - return Parent ? Parent->OnEvent(event) : false; -} - - -//! Sets the visible state of this element. -void CGUIContextMenu::setVisible(bool visible) -{ - HighLighted = -1; - ChangeTime = os::Timer::getTime(); - for (s32 j=0; j<(s32)Items.size(); ++j) - if (Items[j].SubMenu) - Items[j].SubMenu->setVisible(false); - - IGUIElement::setVisible(visible); -} - - -//! sends a click Returns: -//! 0 if click went outside of the element, -//! 1 if a valid button was clicked, -//! 2 if a nonclickable element was clicked -s32 CGUIContextMenu::sendClick(core::position2d p) -{ - s32 t = 0; - - // get number of open submenu - s32 openmenu = -1; - s32 j; - for (j=0; j<(s32)Items.size(); ++j) - if (Items[j].SubMenu && Items[j].SubMenu->isVisible()) - { - openmenu = j; - break; - } - - // delegate click operation to submenu - if (openmenu != -1) - { - t = Items[j].SubMenu->sendClick(p); - if (t != 0) - return t; // clicked something - } - - // check click on myself - if (AbsoluteClippingRect.isPointInside(p) && - HighLighted >= 0 && HighLighted <(s32)Items.size()) - { - if (!Items[HighLighted].Enabled || - Items[HighLighted].IsSeparator || - Items[HighLighted].SubMenu) - return 2; - - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.EventType = EGET_MENU_ITEM_SELECTED; - Parent->OnEvent(event); - - return 1; - } - - return 0; -} - - -//! returns true, if an element was highligted -bool CGUIContextMenu::highlight(core::position2d p) -{ - // get number of open submenu - s32 openmenu = -1; - s32 i; - for (i=0; i<(s32)Items.size(); ++i) - if (Items[i].SubMenu && Items[i].SubMenu->isVisible()) - { - openmenu = i; - break; - } - - // delegate highlight operation to submenu - if (openmenu != -1) - { - if (Items[openmenu].SubMenu->highlight(p)) - { - HighLighted = openmenu; - ChangeTime = os::Timer::getTime(); - return true; - } - } - - // highlight myself - for (i=0; i<(s32)Items.size(); ++i) - if (getHRect(Items[i], AbsoluteRect).isPointInside(p)) - { - HighLighted = i; - ChangeTime = os::Timer::getTime(); - - // make submenus visible/invisible - for (s32 j=0; j<(s32)Items.size(); ++j) - if (Items[j].SubMenu) - Items[j].SubMenu->setVisible(j == i); - return true; - } - - HighLighted = openmenu; - return false; -} - - -//! returns the item highlight-area -core::rect CGUIContextMenu::getHRect(const SItem& i, const core::rect& absolute) -{ - core::rect r = absolute; - r.UpperLeftCorner.Y += i.PosY; - r.LowerRightCorner.Y = r.UpperLeftCorner.Y + i.Dim.Height; - return r; -} - - -//! Gets drawing rect of Item -core::rect CGUIContextMenu::getRect(const SItem& i, const core::rect& absolute) -{ - core::rect r = absolute; - r.UpperLeftCorner.Y += i.PosY; - r.LowerRightCorner.Y = r.UpperLeftCorner.Y + i.Dim.Height; - r.UpperLeftCorner.X += 20; - return r; -} - - -//! draws the element and its children -void CGUIContextMenu::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - - if (!skin) - return; - - IGUIFont* font = skin->getFont(); - IGUISpriteBank* sprites = skin->getSpriteBank(); - - video::IVideoDriver* driver = Environment->getVideoDriver(); - - core::rect rect = AbsoluteRect; - core::rect* clip = 0; - - // draw frame - skin->draw3DMenuPane(this, AbsoluteRect, clip); - - // loop through all menu items - - rect = AbsoluteRect; - s32 y = AbsoluteRect.UpperLeftCorner.Y; - - for (s32 i=0; i<(s32)Items.size(); ++i) - { - if (Items[i].IsSeparator) - { - // draw separator - rect = AbsoluteRect; - rect.UpperLeftCorner.Y += Items[i].PosY + 3; - rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; - rect.UpperLeftCorner.X += 5; - rect.LowerRightCorner.X -= 5; - driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), rect, clip); - - rect.LowerRightCorner.Y += 1; - rect.UpperLeftCorner.Y += 1; - driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - - y += 10; - } - else - { - rect = getRect(Items[i], AbsoluteRect); - - // draw highlighted - - if (i == HighLighted && Items[i].Enabled) - { - core::rect r = AbsoluteRect; - r.LowerRightCorner.Y = rect.LowerRightCorner.Y; - r.UpperLeftCorner.Y = rect.UpperLeftCorner.Y; - r.LowerRightCorner.X -= 5; - r.UpperLeftCorner.X += 5; - driver->draw2DRectangle(skin->getColor(EGDC_HIGH_LIGHT), r, clip); - } - - // draw text - - EGUI_DEFAULT_COLOR c = EGDC_BUTTON_TEXT; - - if (i == HighLighted) - c = EGDC_HIGH_LIGHT_TEXT; - - if (!Items[i].Enabled) - c = EGDC_GRAY_TEXT; - - if (font) - font->draw(Items[i].Text.c_str(), rect, - skin->getColor(c), false, true, clip); - - // draw submenu symbol - if (Items[i].SubMenu && sprites) - { - core::rect r = rect; - r.UpperLeftCorner.X = r.LowerRightCorner.X - 15; - - sprites->draw2DSprite(skin->getIcon(EGDI_CURSOR_RIGHT), - r.getCenter(), clip, skin->getColor(c), - (i == HighLighted) ? ChangeTime : 0, - (i == HighLighted) ? os::Timer::getTime() : 0, - (i == HighLighted), true); - } - - // draw checked symbol - if (Items[i].Checked && sprites) - { - core::rect r = rect; - r.UpperLeftCorner.X -= 15; - sprites->draw2DSprite(skin->getIcon(EGDI_CHECK_BOX_CHECKED), - r.getCenter(), clip, skin->getColor(c), - (i == HighLighted) ? ChangeTime : 0, - (i == HighLighted) ? os::Timer::getTime() : 0, - (i == HighLighted), true); - } - - } - } - - IGUIElement::draw(); -} - - -void CGUIContextMenu::recalculateSize() -{ - IGUISkin* skin = Environment->getSkin(); - IGUIFont* font = skin->getFont(); - - if (!font) - return; - - core::rect rect; - rect.UpperLeftCorner = RelativeRect.UpperLeftCorner; - s32 width = 100; - s32 height = 3; - s32 i; - - for (i=0; i<(s32)Items.size(); ++i) - { - if (Items[i].IsSeparator) - { - Items[i].Dim.Width = 100; - Items[i].Dim.Height = 10; - } - else - { - Items[i].Dim = font->getDimension(Items[i].Text.c_str()); - Items[i].Dim.Width += 40; - - if (Items[i].Dim.Width > width) - width = Items[i].Dim.Width; - } - - Items[i].PosY = height; - height += Items[i].Dim.Height; - } - - height += 5; - - if (height < 10) - height = 10; - - rect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + width; - rect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + height; - - setRelativePosition(rect); - - // recalculate submenus - for (i=0; i<(s32)Items.size(); ++i) - if (Items[i].SubMenu) - { - // move submenu - s32 w = Items[i].SubMenu->getAbsolutePosition().getWidth(); - s32 h = Items[i].SubMenu->getAbsolutePosition().getHeight(); - - Items[i].SubMenu->setRelativePosition( - core::rect(width-5, Items[i].PosY, - width+w-5, Items[i].PosY+h)); - } -} - - -//! Returns the selected item in the menu -s32 CGUIContextMenu::getSelectedItem() -{ - return HighLighted; -} - - -//! \return Returns a pointer to the submenu of an item. -IGUIContextMenu* CGUIContextMenu::getSubMenu(s32 idx) -{ - if (idx < 0 || idx >= (s32)Items.size()) - return 0; - - return Items[idx].SubMenu; -} - - -//! Returns command id of a menu item -s32 CGUIContextMenu::getItemCommandId(s32 idx) -{ - if (idx < 0 || idx >= (s32)Items.size()) - return -1; - - return Items[idx].CommandId; -} - -//! Sets the command id of a menu item -void CGUIContextMenu::setItemCommandId(s32 idx, s32 id) -{ - if (idx < 0 || idx >= (s32)Items.size()) - return; - - Items[idx].CommandId = id; -} - -//! Writes attributes of the element. -void CGUIContextMenu::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) -{ - IGUIElement::serializeAttributes(out,options); - out->addPosition2d ("Position", Pos); - - if (Parent->getType() == EGUIET_CONTEXT_MENU || Parent->getType() == EGUIET_MENU ) - { - IGUIContextMenu* ptr = (IGUIContextMenu*)Parent; - s32 i=0; - // find the position of this item in its parent's list - for (; i<(s32)ptr->getItemCount() && ptr->getSubMenu(i) != this; ++i); - - out->addInt("ParentItem", i); - } - - // write out the item list - out->addInt("ItemCount", Items.size()); - - core::stringc tmp; - - s32 i=0; - for (; i < (s32)Items.size(); ++i) - { - tmp = "IsSeparator"; tmp += i; - out->addBool(tmp.c_str(), Items[i].IsSeparator); - - if (!Items[i].IsSeparator) - { - tmp = "Text"; tmp += i; - out->addString(tmp.c_str(), Items[i].Text.c_str()); - tmp = "CommandID"; tmp += i; - out->addInt(tmp.c_str(), Items[i].CommandId); - tmp = "Enabled"; tmp += i; - out->addBool(tmp.c_str(), Items[i].Enabled); - } - } -} - -//! Reads attributes of the element -void CGUIContextMenu::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIElement::deserializeAttributes(in,options); - - Pos = in->getAttributeAsPosition2d("Position"); - - // link to this item's parent - if (Parent && ( Parent->getType() == EGUIET_CONTEXT_MENU || Parent->getType() == EGUIET_MENU ) ) - ((CGUIContextMenu*)Parent)->setSubMenu(in->getAttributeAsInt("ParentItem"),this); - - - removeAllItems(); - - // read the item list - s32 count = in->getAttributeAsInt("ItemCount"); - - s32 i=0; - for (; i<(s32)count; ++i) - { - core::stringc tmp; - core::stringw txt; - s32 commandid; - bool enabled; - bool checked; - - tmp = "IsSeparator"; tmp += i; - if ( in->getAttributeAsBool(tmp.c_str()) ) - addSeparator(); - else - { - tmp = "Text"; tmp += i; - txt = in->getAttributeAsStringW(tmp.c_str()); - - tmp = "CommandID"; tmp += i; - commandid = in->getAttributeAsInt(tmp.c_str()); - - tmp = "Enabled"; tmp += i; - enabled = in->getAttributeAsBool(tmp.c_str()); - - tmp = "Checked"; tmp += i; - checked = in->getAttributeAsBool(tmp.c_str()); - - addItem(core::stringw(txt.c_str()).c_str(), commandid, enabled, false, checked); - } - } - - - recalculateSize(); - -} - - -} // end namespace -} // end namespace - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIContextMenu.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUIFont.h" +#include "IGUISpriteBank.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + + + +//! constructor +CGUIContextMenu::CGUIContextMenu(IGUIEnvironment* environment, + IGUIElement* parent, s32 id, + core::rect rectangle, bool getFocus) +: IGUIContextMenu(environment, parent, id, rectangle), HighLighted(-1), ChangeTime(0) +{ + #ifdef _DEBUG + setDebugName("CGUIContextMenu"); + #endif + + Pos = rectangle.UpperLeftCorner; + recalculateSize(); + + if (getFocus) + Environment->setFocus(this); + + setNotClipped(true); +} + + +//! destructor +CGUIContextMenu::~CGUIContextMenu() +{ + for (s32 i=0; i<(s32)Items.size(); ++i) + if (Items[i].SubMenu) + Items[i].SubMenu->drop(); +} + + +//! Returns amount of menu items +s32 CGUIContextMenu::getItemCount() const +{ + return Items.size(); +} + + +//! Adds a menu item. +s32 CGUIContextMenu::addItem(const wchar_t* text, s32 id, bool enabled, bool hasSubMenu, bool checked) +{ + SItem s; + s.Enabled = enabled; + s.Checked = checked; + s.Text = text; + s.IsSeparator = (text == 0); + s.SubMenu = 0; + s.CommandId = id; + + if (hasSubMenu) + { + s.SubMenu = new CGUIContextMenu(Environment, this, id, + core::rect(0,0,100,100), false); + s.SubMenu->setVisible(false); + } + + Items.push_back(s); + + recalculateSize(); + return Items.size() - 1; +} + +//! Adds a sub menu from an element that already exists. +void CGUIContextMenu::setSubMenu(s32 index, CGUIContextMenu* menu) +{ + if (index >= (s32)Items.size() || index < 0) + return; + + if (Items[index].SubMenu) + Items[index].SubMenu->drop(); + + Items[index].SubMenu = menu; + menu->setVisible(false); + + if (Items[index].SubMenu) + menu->grab(); + + recalculateSize(); +} + + +//! Adds a separator item to the menu +void CGUIContextMenu::addSeparator() +{ + addItem(0, -1, true, false, false); +} + + +//! Returns text of the menu item. +const wchar_t* CGUIContextMenu::getItemText(s32 idx) +{ + if (idx < 0 || idx >= (s32)Items.size()) + return 0; + + return Items[idx].Text.c_str(); +} + + +//! Sets text of the menu item. +void CGUIContextMenu::setItemText(s32 idx, const wchar_t* text) +{ + if (idx < 0 || idx >= (s32)Items.size()) + return; + + Items[idx].Text = text; + recalculateSize(); +} + + +//! Returns if a menu item is enabled +bool CGUIContextMenu::isItemEnabled(s32 idx) +{ + if (idx < 0 || idx >= (s32)Items.size()) + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return false; + } + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return Items[idx].Enabled; +} + + +//! Sets if the menu item should be enabled. +void CGUIContextMenu::setItemEnabled(s32 idx, bool enabled) +{ + if (idx < 0 || idx >= (s32)Items.size()) + return; + + Items[idx].Enabled = enabled; +} + +//! Sets if the menu item should be checked. +void CGUIContextMenu::setItemChecked(s32 idx, bool checked ) +{ + if (idx < 0 || idx >= (s32)Items.size()) + return; + + Items[idx].Checked = checked; +} + + +//! Removes a menu item +void CGUIContextMenu::removeItem(s32 idx) +{ + if (idx < 0 || idx >= (s32)Items.size()) + return; + + if (Items[idx].SubMenu) + { + Items[idx].SubMenu->drop(); + Items[idx].SubMenu = 0; + } + + Items.erase(idx); + recalculateSize(); +} + + +//! Removes all menu items +void CGUIContextMenu::removeAllItems() +{ + for (s32 i=0; i<(s32)Items.size(); ++i) + if (Items[i].SubMenu) + Items[i].SubMenu->drop(); + + Items.clear(); + recalculateSize(); +} + + +//! called if an event happened. +bool CGUIContextMenu::OnEvent(SEvent event) +{ + if (!IsEnabled) + return Parent ? Parent->OnEvent(event) : false; + + switch(event.EventType) + { + case EET_GUI_EVENT: + switch(event.GUIEvent.EventType) + { + case gui::EGET_ELEMENT_FOCUS_LOST: + if (event.GUIEvent.Caller == (IGUIElement*)this) + { + remove(); + return true; + } + break; + } + break; + case EET_MOUSE_INPUT_EVENT: + switch(event.MouseInput.Event) + { + case EMIE_LMOUSE_LEFT_UP: + { + // menu might be removed if it loses focus in sendClick, so grab a reference + grab(); + s32 t = sendClick(core::position2d(event.MouseInput.X, event.MouseInput.Y)); + if ((t==0 || t==1) && Environment->hasFocus(this)) + Environment->removeFocus(this); + drop(); + } + return true; + case EMIE_LMOUSE_PRESSED_DOWN: + return true; + case EMIE_MOUSE_MOVED: + if (Environment->hasFocus(this)) + highlight(core::position2d(event.MouseInput.X, event.MouseInput.Y)); + return true; + } + break; + } + + return Parent ? Parent->OnEvent(event) : false; +} + + +//! Sets the visible state of this element. +void CGUIContextMenu::setVisible(bool visible) +{ + HighLighted = -1; + ChangeTime = os::Timer::getTime(); + for (s32 j=0; j<(s32)Items.size(); ++j) + if (Items[j].SubMenu) + Items[j].SubMenu->setVisible(false); + + IGUIElement::setVisible(visible); +} + + +//! sends a click Returns: +//! 0 if click went outside of the element, +//! 1 if a valid button was clicked, +//! 2 if a nonclickable element was clicked +s32 CGUIContextMenu::sendClick(core::position2d p) +{ + s32 t = 0; + + // get number of open submenu + s32 openmenu = -1; + s32 j; + for (j=0; j<(s32)Items.size(); ++j) + if (Items[j].SubMenu && Items[j].SubMenu->isVisible()) + { + openmenu = j; + break; + } + + // delegate click operation to submenu + if (openmenu != -1) + { + t = Items[j].SubMenu->sendClick(p); + if (t != 0) + return t; // clicked something + } + + // check click on myself + if (AbsoluteClippingRect.isPointInside(p) && + HighLighted >= 0 && HighLighted <(s32)Items.size()) + { + if (!Items[HighLighted].Enabled || + Items[HighLighted].IsSeparator || + Items[HighLighted].SubMenu) + return 2; + + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.EventType = EGET_MENU_ITEM_SELECTED; + Parent->OnEvent(event); + + return 1; + } + + return 0; +} + + +//! returns true, if an element was highligted +bool CGUIContextMenu::highlight(core::position2d p) +{ + // get number of open submenu + s32 openmenu = -1; + s32 i; + for (i=0; i<(s32)Items.size(); ++i) + if (Items[i].SubMenu && Items[i].SubMenu->isVisible()) + { + openmenu = i; + break; + } + + // delegate highlight operation to submenu + if (openmenu != -1) + { + if (Items[openmenu].SubMenu->highlight(p)) + { + HighLighted = openmenu; + ChangeTime = os::Timer::getTime(); + return true; + } + } + + // highlight myself + for (i=0; i<(s32)Items.size(); ++i) + if (getHRect(Items[i], AbsoluteRect).isPointInside(p)) + { + HighLighted = i; + ChangeTime = os::Timer::getTime(); + + // make submenus visible/invisible + for (s32 j=0; j<(s32)Items.size(); ++j) + if (Items[j].SubMenu) + Items[j].SubMenu->setVisible(j == i); + return true; + } + + HighLighted = openmenu; + return false; +} + + +//! returns the item highlight-area +core::rect CGUIContextMenu::getHRect(const SItem& i, const core::rect& absolute) +{ + core::rect r = absolute; + r.UpperLeftCorner.Y += i.PosY; + r.LowerRightCorner.Y = r.UpperLeftCorner.Y + i.Dim.Height; + return r; +} + + +//! Gets drawing rect of Item +core::rect CGUIContextMenu::getRect(const SItem& i, const core::rect& absolute) +{ + core::rect r = absolute; + r.UpperLeftCorner.Y += i.PosY; + r.LowerRightCorner.Y = r.UpperLeftCorner.Y + i.Dim.Height; + r.UpperLeftCorner.X += 20; + return r; +} + + +//! draws the element and its children +void CGUIContextMenu::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + + if (!skin) + return; + + IGUIFont* font = skin->getFont(); + IGUISpriteBank* sprites = skin->getSpriteBank(); + + video::IVideoDriver* driver = Environment->getVideoDriver(); + + core::rect rect = AbsoluteRect; + core::rect* clip = 0; + + // draw frame + skin->draw3DMenuPane(this, AbsoluteRect, clip); + + // loop through all menu items + + rect = AbsoluteRect; + s32 y = AbsoluteRect.UpperLeftCorner.Y; + + for (s32 i=0; i<(s32)Items.size(); ++i) + { + if (Items[i].IsSeparator) + { + // draw separator + rect = AbsoluteRect; + rect.UpperLeftCorner.Y += Items[i].PosY + 3; + rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; + rect.UpperLeftCorner.X += 5; + rect.LowerRightCorner.X -= 5; + driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), rect, clip); + + rect.LowerRightCorner.Y += 1; + rect.UpperLeftCorner.Y += 1; + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), rect, clip); + + y += 10; + } + else + { + rect = getRect(Items[i], AbsoluteRect); + + // draw highlighted + + if (i == HighLighted && Items[i].Enabled) + { + core::rect r = AbsoluteRect; + r.LowerRightCorner.Y = rect.LowerRightCorner.Y; + r.UpperLeftCorner.Y = rect.UpperLeftCorner.Y; + r.LowerRightCorner.X -= 5; + r.UpperLeftCorner.X += 5; + driver->draw2DRectangle(skin->getColor(EGDC_HIGH_LIGHT), r, clip); + } + + // draw text + + EGUI_DEFAULT_COLOR c = EGDC_BUTTON_TEXT; + + if (i == HighLighted) + c = EGDC_HIGH_LIGHT_TEXT; + + if (!Items[i].Enabled) + c = EGDC_GRAY_TEXT; + + if (font) + font->draw(Items[i].Text.c_str(), rect, + skin->getColor(c), false, true, clip); + + // draw submenu symbol + if (Items[i].SubMenu && sprites) + { + core::rect r = rect; + r.UpperLeftCorner.X = r.LowerRightCorner.X - 15; + + sprites->draw2DSprite(skin->getIcon(EGDI_CURSOR_RIGHT), + r.getCenter(), clip, skin->getColor(c), + (i == HighLighted) ? ChangeTime : 0, + (i == HighLighted) ? os::Timer::getTime() : 0, + (i == HighLighted), true); + } + + // draw checked symbol + if (Items[i].Checked && sprites) + { + core::rect r = rect; + r.UpperLeftCorner.X -= 15; + sprites->draw2DSprite(skin->getIcon(EGDI_CHECK_BOX_CHECKED), + r.getCenter(), clip, skin->getColor(c), + (i == HighLighted) ? ChangeTime : 0, + (i == HighLighted) ? os::Timer::getTime() : 0, + (i == HighLighted), true); + } + + } + } + + IGUIElement::draw(); +} + + +void CGUIContextMenu::recalculateSize() +{ + IGUISkin* skin = Environment->getSkin(); + IGUIFont* font = skin->getFont(); + + if (!font) + return; + + core::rect rect; + rect.UpperLeftCorner = RelativeRect.UpperLeftCorner; + s32 width = 100; + s32 height = 3; + s32 i; + + for (i=0; i<(s32)Items.size(); ++i) + { + if (Items[i].IsSeparator) + { + Items[i].Dim.Width = 100; + Items[i].Dim.Height = 10; + } + else + { + Items[i].Dim = font->getDimension(Items[i].Text.c_str()); + Items[i].Dim.Width += 40; + + if (Items[i].Dim.Width > width) + width = Items[i].Dim.Width; + } + + Items[i].PosY = height; + height += Items[i].Dim.Height; + } + + height += 5; + + if (height < 10) + height = 10; + + rect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + width; + rect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + height; + + setRelativePosition(rect); + + // recalculate submenus + for (i=0; i<(s32)Items.size(); ++i) + if (Items[i].SubMenu) + { + // move submenu + s32 w = Items[i].SubMenu->getAbsolutePosition().getWidth(); + s32 h = Items[i].SubMenu->getAbsolutePosition().getHeight(); + + Items[i].SubMenu->setRelativePosition( + core::rect(width-5, Items[i].PosY, + width+w-5, Items[i].PosY+h)); + } +} + + +//! Returns the selected item in the menu +s32 CGUIContextMenu::getSelectedItem() +{ + return HighLighted; +} + + +//! \return Returns a pointer to the submenu of an item. +IGUIContextMenu* CGUIContextMenu::getSubMenu(s32 idx) +{ + if (idx < 0 || idx >= (s32)Items.size()) + return 0; + + return Items[idx].SubMenu; +} + + +//! Returns command id of a menu item +s32 CGUIContextMenu::getItemCommandId(s32 idx) +{ + if (idx < 0 || idx >= (s32)Items.size()) + return -1; + + return Items[idx].CommandId; +} + +//! Sets the command id of a menu item +void CGUIContextMenu::setItemCommandId(s32 idx, s32 id) +{ + if (idx < 0 || idx >= (s32)Items.size()) + return; + + Items[idx].CommandId = id; +} + +//! Writes attributes of the element. +void CGUIContextMenu::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +{ + IGUIElement::serializeAttributes(out,options); + out->addPosition2d ("Position", Pos); + + if (Parent->getType() == EGUIET_CONTEXT_MENU || Parent->getType() == EGUIET_MENU ) + { + IGUIContextMenu* ptr = (IGUIContextMenu*)Parent; + s32 i=0; + // find the position of this item in its parent's list + for (; i<(s32)ptr->getItemCount() && ptr->getSubMenu(i) != this; ++i); + + out->addInt("ParentItem", i); + } + + // write out the item list + out->addInt("ItemCount", Items.size()); + + core::stringc tmp; + + s32 i=0; + for (; i < (s32)Items.size(); ++i) + { + tmp = "IsSeparator"; tmp += i; + out->addBool(tmp.c_str(), Items[i].IsSeparator); + + if (!Items[i].IsSeparator) + { + tmp = "Text"; tmp += i; + out->addString(tmp.c_str(), Items[i].Text.c_str()); + tmp = "CommandID"; tmp += i; + out->addInt(tmp.c_str(), Items[i].CommandId); + tmp = "Enabled"; tmp += i; + out->addBool(tmp.c_str(), Items[i].Enabled); + } + } +} + +//! Reads attributes of the element +void CGUIContextMenu::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +{ + IGUIElement::deserializeAttributes(in,options); + + Pos = in->getAttributeAsPosition2d("Position"); + + // link to this item's parent + if (Parent && ( Parent->getType() == EGUIET_CONTEXT_MENU || Parent->getType() == EGUIET_MENU ) ) + ((CGUIContextMenu*)Parent)->setSubMenu(in->getAttributeAsInt("ParentItem"),this); + + + removeAllItems(); + + // read the item list + s32 count = in->getAttributeAsInt("ItemCount"); + + s32 i=0; + for (; i<(s32)count; ++i) + { + core::stringc tmp; + core::stringw txt; + s32 commandid; + bool enabled; + bool checked; + + tmp = "IsSeparator"; tmp += i; + if ( in->getAttributeAsBool(tmp.c_str()) ) + addSeparator(); + else + { + tmp = "Text"; tmp += i; + txt = in->getAttributeAsStringW(tmp.c_str()); + + tmp = "CommandID"; tmp += i; + commandid = in->getAttributeAsInt(tmp.c_str()); + + tmp = "Enabled"; tmp += i; + enabled = in->getAttributeAsBool(tmp.c_str()); + + tmp = "Checked"; tmp += i; + checked = in->getAttributeAsBool(tmp.c_str()); + + addItem(core::stringw(txt.c_str()).c_str(), commandid, enabled, false, checked); + } + } + + + recalculateSize(); + +} + + +} // end namespace +} // end namespace + diff --git a/src/dep/src/irrlicht/CGUIContextMenu.h b/src/dep/src/irrlicht/CGUIContextMenu.h index 520b36c..84c3288 100644 --- a/src/dep/src/irrlicht/CGUIContextMenu.h +++ b/src/dep/src/irrlicht/CGUIContextMenu.h @@ -1,134 +1,134 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_CONTEXT_MENU_H_INCLUDED__ -#define __C_GUI_CONTEXT_MENU_H_INCLUDED__ - -#include "IGUIContextMenu.h" -#include "irrString.h" -#include "irrArray.h" - -namespace irr -{ -namespace gui -{ - - //! GUI Context menu interface. - class CGUIContextMenu : public IGUIContextMenu - { - public: - - //! constructor - CGUIContextMenu(IGUIEnvironment* environment, - IGUIElement* parent, s32 id, core::rect rectangle, - bool getFocus = true); - - //! destructor - ~CGUIContextMenu(); - - //! Returns amount of menu items - virtual s32 getItemCount() const; - - //! Adds a menu item. - virtual s32 addItem(const wchar_t* text, s32 commandid, bool enabled, - bool hasSubMenu, - bool checked); - - //! Adds a separator item to the menu - virtual void addSeparator(); - - //! Returns text of the menu item. - virtual const wchar_t* getItemText(s32 idx); - - //! Sets text of the menu item. - virtual void setItemText(s32 idx, const wchar_t* text); - - //! Returns if a menu item is enabled - virtual bool isItemEnabled(s32 idx); - - //! Sets if the menu item should be enabled. - virtual void setItemEnabled(s32 idx, bool enabled); - - //! Sets if the menu item should be checked. - virtual void setItemChecked(s32 idx, bool enabled); - - //! Removes a menu item - virtual void removeItem(s32 idx); - - //! Removes all menu items - virtual void removeAllItems(); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! draws the element and its children - virtual void draw(); - - //! Returns the selected item in the menu - virtual s32 getSelectedItem(); - - //! Returns a pointer to the submenu of an item. - //! \return Pointer to the submenu of an item. - virtual IGUIContextMenu* getSubMenu(s32 idx); - - //! Sets the visible state of this element. - virtual void setVisible(bool visible); - - //! Returns command id of a menu item - virtual s32 getItemCommandId(s32 idx); - - //! Sets the command id of a menu item - virtual void setItemCommandId(s32 idx, s32 id); - - //! Adds a sub menu from an element that already exists. - virtual void setSubMenu(s32 index, CGUIContextMenu* menu); - - protected: - - struct SItem - { - core::stringw Text; - bool IsSeparator; - bool Enabled; - bool Checked; - core::dimension2d Dim; - s32 PosY; - CGUIContextMenu* SubMenu; - s32 CommandId; - }; - - virtual void recalculateSize(); - - //! returns true, if an element was highligted - virtual bool highlight(core::position2d p); - - //! sends a click Returns: - //! 0 if click went outside of the element, - //! 1 if a valid button was clicked, - //! 2 if a nonclickable element was clicked - virtual s32 sendClick(core::position2d p); - - //! returns the item highlight-area - virtual core::rect getHRect(const SItem& i, const core::rect& absolute); - - //! Gets drawing rect of Item - virtual core::rect getRect(const SItem& i, const core::rect& absolute); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - s32 HighLighted; - core::array Items; - core::position2d Pos; - u32 ChangeTime; - }; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_CONTEXT_MENU_H_INCLUDED__ +#define __C_GUI_CONTEXT_MENU_H_INCLUDED__ + +#include "IGUIContextMenu.h" +#include "irrString.h" +#include "irrArray.h" + +namespace irr +{ +namespace gui +{ + + //! GUI Context menu interface. + class CGUIContextMenu : public IGUIContextMenu + { + public: + + //! constructor + CGUIContextMenu(IGUIEnvironment* environment, + IGUIElement* parent, s32 id, core::rect rectangle, + bool getFocus = true); + + //! destructor + ~CGUIContextMenu(); + + //! Returns amount of menu items + virtual s32 getItemCount() const; + + //! Adds a menu item. + virtual s32 addItem(const wchar_t* text, s32 commandid, bool enabled, + bool hasSubMenu, + bool checked); + + //! Adds a separator item to the menu + virtual void addSeparator(); + + //! Returns text of the menu item. + virtual const wchar_t* getItemText(s32 idx); + + //! Sets text of the menu item. + virtual void setItemText(s32 idx, const wchar_t* text); + + //! Returns if a menu item is enabled + virtual bool isItemEnabled(s32 idx); + + //! Sets if the menu item should be enabled. + virtual void setItemEnabled(s32 idx, bool enabled); + + //! Sets if the menu item should be checked. + virtual void setItemChecked(s32 idx, bool enabled); + + //! Removes a menu item + virtual void removeItem(s32 idx); + + //! Removes all menu items + virtual void removeAllItems(); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! draws the element and its children + virtual void draw(); + + //! Returns the selected item in the menu + virtual s32 getSelectedItem(); + + //! Returns a pointer to the submenu of an item. + //! \return Pointer to the submenu of an item. + virtual IGUIContextMenu* getSubMenu(s32 idx); + + //! Sets the visible state of this element. + virtual void setVisible(bool visible); + + //! Returns command id of a menu item + virtual s32 getItemCommandId(s32 idx); + + //! Sets the command id of a menu item + virtual void setItemCommandId(s32 idx, s32 id); + + //! Adds a sub menu from an element that already exists. + virtual void setSubMenu(s32 index, CGUIContextMenu* menu); + + protected: + + struct SItem + { + core::stringw Text; + bool IsSeparator; + bool Enabled; + bool Checked; + core::dimension2d Dim; + s32 PosY; + CGUIContextMenu* SubMenu; + s32 CommandId; + }; + + virtual void recalculateSize(); + + //! returns true, if an element was highligted + virtual bool highlight(core::position2d p); + + //! sends a click Returns: + //! 0 if click went outside of the element, + //! 1 if a valid button was clicked, + //! 2 if a nonclickable element was clicked + virtual s32 sendClick(core::position2d p); + + //! returns the item highlight-area + virtual core::rect getHRect(const SItem& i, const core::rect& absolute); + + //! Gets drawing rect of Item + virtual core::rect getRect(const SItem& i, const core::rect& absolute); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + s32 HighLighted; + core::array Items; + core::position2d Pos; + u32 ChangeTime; + }; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIEditBox.cpp b/src/dep/src/irrlicht/CGUIEditBox.cpp index 95fa088..e791623 100644 --- a/src/dep/src/irrlicht/CGUIEditBox.cpp +++ b/src/dep/src/irrlicht/CGUIEditBox.cpp @@ -1,728 +1,728 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIEditBox.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IGUIFont.h" -#include "IVideoDriver.h" -#include "rect.h" -#include "os.h" -#include "Keycodes.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIEditBox::CGUIEditBox(const wchar_t* text, bool border, IGUIEnvironment* environment, - IGUIElement* parent, s32 id, - const core::rect& rectangle, IOSOperator* op) -: IGUIEditBox(environment, parent, id, rectangle), MouseMarking(false), - Border(border), OverrideColorEnabled(false), MarkBegin(0), MarkEnd(0), - OverrideColor(video::SColor(101,255,255,255)), - OverrideFont(0), Operator(op), CursorPos(0), ScrollPos(0), Max(0) -{ - #ifdef _DEBUG - setDebugName("CGUIEditBox"); - #endif - - Text = text; - - if (Operator) - Operator->grab(); -} - - -//! destructor -CGUIEditBox::~CGUIEditBox() -{ - if (OverrideFont) - OverrideFont->drop(); - - if (Operator) - Operator->drop(); -} - - -//! Sets another skin independent font. -void CGUIEditBox::setOverrideFont(IGUIFont* font) -{ - if (OverrideFont) - OverrideFont->drop(); - - OverrideFont = font; - - if (OverrideFont) - OverrideFont->grab(); -} - - -//! Sets another color for the text. -void CGUIEditBox::setOverrideColor(video::SColor color) -{ - OverrideColor = color; - OverrideColorEnabled = true; -} - - -//! Sets if the text should use the overide color or the -//! color in the gui skin. -void CGUIEditBox::enableOverrideColor(bool enable) -{ - OverrideColorEnabled = enable; -} - - -//! called if an event happened. -bool CGUIEditBox::OnEvent(SEvent event) -{ - switch(event.EventType) - { - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) - { - if (event.GUIEvent.Caller == (IGUIElement*)this) - { - MouseMarking = false; - MarkBegin = 0; - MarkEnd = 0; - } - } - break; - case EET_KEY_INPUT_EVENT: - if (processKey(event)) - return true; - break; - case EET_MOUSE_INPUT_EVENT: - if (processMouse(event)) - return true; - break; - } - - return Parent ? Parent->OnEvent(event) : false; -} - - -bool CGUIEditBox::processKey(const SEvent& event) -{ - if (!event.KeyInput.PressedDown) - return false; - - // control shortcut handling - - if (event.KeyInput.Control) - { - switch(event.KeyInput.Key) - { - case KEY_KEY_C: - // copy to clipboard - if (Operator && MarkBegin != MarkEnd) - { - s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - - core::stringc s; - s = Text.subString(realmbgn, realmend - realmbgn).c_str(); - Operator->copyToClipboard(s.c_str()); - } - break; - case KEY_KEY_X: - if ( !this->IsEnabled ) - break; - - // cut to the clipboard - if (Operator && MarkBegin != MarkEnd) - { - s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - - // copy - core::stringc sc; - sc = Text.subString(realmbgn, realmend - realmbgn).c_str(); - Operator->copyToClipboard(sc.c_str()); - - // delete - core::stringw s; - s = Text.subString(0, realmbgn); - s.append( Text.subString(realmend, Text.size()-realmend) ); - Text = s; - - CursorPos = realmbgn; - MarkBegin = 0; - MarkEnd = 0; - } - break; - case KEY_KEY_V: - if ( !this->IsEnabled ) - break; - - // paste from the clipboard - if (Operator) - { - s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - - // add new character - const c8* p = Operator->getTextFromClipboard(); - if (p) - { - if (MarkBegin == MarkEnd) - { - // insert text - core::stringw s = Text.subString(0, CursorPos); - s.append(p); - s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); - - if (!Max || s.size()<=(u32)Max) // thx to Fish FH for fix - { - Text = s; - s = p; - CursorPos += s.size(); - } - } - else - { - // replace text - - core::stringw s = Text.subString(0, realmbgn); - s.append(p); - s.append( Text.subString(realmend, Text.size()-realmend) ); - - if (!Max || s.size()<=(u32)Max) // thx to Fish FH for fix - { - Text = s; - s = p; - CursorPos = realmbgn + s.size(); - } - } - } - - MarkBegin = 0; - MarkEnd = 0; - } - break; - default: - return false; - } - } - - // default keyboard handling - - if (!event.KeyInput.Control) - switch(event.KeyInput.Key) - { - case KEY_END: - if (event.KeyInput.Shift) - { - if (MarkBegin == MarkEnd) - MarkBegin = CursorPos; - MarkEnd = Text.size(); - } - else - { - MarkBegin = 0; - MarkEnd = 0; - } - CursorPos = Text.size(); - BlinkStartTime = os::Timer::getTime(); - break; - case KEY_HOME: - if (event.KeyInput.Shift) - { - if (MarkBegin == MarkEnd) - MarkBegin = CursorPos; - MarkEnd = 0; - } - else - { - MarkBegin = 0; - MarkEnd = 0; - } - CursorPos = 0; - BlinkStartTime = os::Timer::getTime(); - break; - case KEY_RETURN: - { - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = this; - e.GUIEvent.EventType = EGET_EDITBOX_ENTER; - Parent->OnEvent(e); - } - break; - case KEY_LEFT: - - if (event.KeyInput.Shift) - { - if (CursorPos > 0) - { - if (MarkBegin == MarkEnd) - MarkBegin = CursorPos; - - MarkEnd = CursorPos-1; - } - } - else - { - MarkBegin = 0; - MarkEnd = 0; - } - - if (CursorPos > 0) CursorPos--; - BlinkStartTime = os::Timer::getTime(); - break; - - case KEY_RIGHT: - - if (event.KeyInput.Shift) - { - if (Text.size() > (u32)CursorPos) - { - if (MarkBegin == MarkEnd) - MarkBegin = CursorPos; - - MarkEnd = CursorPos+1; - } - } - else - { - MarkBegin = 0; - MarkEnd = 0; - } - - if (Text.size() > (u32)CursorPos) CursorPos++; - BlinkStartTime = os::Timer::getTime(); - break; - - case KEY_BACK: - if ( !this->IsEnabled ) - break; - - if (Text.size()) - { - core::stringw s; - - if (MarkBegin != MarkEnd) - { - // delete marked text - s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - - s = Text.subString(0, realmbgn); - s.append( Text.subString(realmend, Text.size()-realmend) ); - Text = s; - - CursorPos = realmbgn; - } - else - { - // delete text behind cursor - if (CursorPos>0) - s = Text.subString(0, CursorPos-1); - else - s = L""; - s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); - Text = s; - --CursorPos; - } - - if (CursorPos < 0) - CursorPos = 0; - BlinkStartTime = os::Timer::getTime(); - MarkBegin = 0; - MarkEnd = 0; - } - break; - case KEY_DELETE: - if ( !this->IsEnabled ) - break; - - if (Text.size() != 0) - { - core::stringw s; - - if (MarkBegin != MarkEnd) - { - // delete marked text - s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - - s = Text.subString(0, realmbgn); - s.append( Text.subString(realmend, Text.size()-realmend) ); - Text = s; - - CursorPos = realmbgn; - } - else - { - // delete text before cursor - s = Text.subString(0, CursorPos); - s.append( Text.subString(CursorPos+1, Text.size()-CursorPos-1) ); - Text = s; - } - - if (CursorPos > (s32)Text.size()) - CursorPos = (s32)Text.size(); - - BlinkStartTime = os::Timer::getTime(); - MarkBegin = 0; - MarkEnd = 0; - } - break; - default: - if ( !this->IsEnabled ) - break; - - if (event.KeyInput.Char != 0) - { - if (Text.size() < (u32)Max || Max == 0) - { - core::stringw s; - - if (MarkBegin != MarkEnd) - { - // replace marked text - s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - - s = Text.subString(0, realmbgn); - s.append(event.KeyInput.Char); - s.append( Text.subString(realmend, Text.size()-realmend) ); - Text = s; - CursorPos = realmbgn+1; - } - else - { - // add new character - s = Text.subString(0, CursorPos); - s.append(event.KeyInput.Char); - s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); - Text = s; - ++CursorPos; - } - - BlinkStartTime = os::Timer::getTime(); - MarkBegin = 0; - MarkEnd = 0; - } - } - break; - } - - // calculate scrollpos - - IGUIFont* font = OverrideFont; - IGUISkin* skin = Environment->getSkin(); - if (!OverrideFont) - font = skin->getFont(); - - s32 cursorwidth = font->getDimension(L"_ ").Width; - - s32 minwidht = cursorwidth*2; - if (minwidht >= AbsoluteRect.getWidth()) - minwidht = AbsoluteRect.getWidth() / 2; - - s32 tries = Text.size()*2; - if (tries < 100) - tries = 100; - - for (s32 t=0; tgetDimension(s.c_str()).Width; - - s = Text.subString(0, ScrollPos); - s32 charscrollpos = font->getDimension(s.c_str()).Width; - - if ((charcursorpos + cursorwidth - charscrollpos) > AbsoluteRect.getWidth()) - ScrollPos++; - else - if ((charcursorpos + cursorwidth - charscrollpos) < minwidht) - { - if (ScrollPos > 0) - ScrollPos--; - else - break; - } - else - break; - } - - return true; -} - -//! draws the element and its children -void CGUIEditBox::draw() -{ - if (!IsVisible) - return; - - bool focus = Environment->hasFocus(this); - - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - - irr::video::IVideoDriver* driver = Environment->getVideoDriver(); - - core::rect frameRect(AbsoluteRect); - - // draw the border - - if (Border) - { - skin->draw3DSunkenPane(this, skin->getColor(EGDC_WINDOW), - false, true, frameRect, &AbsoluteClippingRect); - - frameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X); - } - - // draw the text - - IGUIFont* font = OverrideFont; - if (!OverrideFont) - font = skin->getFont(); - - if (font) - { - // calculate cursor pos - - core::stringw s = Text.subString(0,CursorPos); - s32 charcursorpos = font->getDimension(s.c_str()).Width; - - s = Text.subString(0, ScrollPos); - s32 charscrollpos = font->getDimension(s.c_str()).Width; - - core::rect rct; - - // draw mark - - if (focus && MarkBegin != MarkEnd) - { - rct = frameRect; - - rct.LowerRightCorner.Y -= skin->getSize(EGDS_TEXT_DISTANCE_Y); - rct.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y); - - s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - - s = Text.subString(0, realmbgn); - s32 mbegin = font->getDimension(s.c_str()).Width; - - s = Text.subString(realmbgn, realmend - realmbgn); - s32 mend = font->getDimension(s.c_str()).Width; - - rct.UpperLeftCorner.X += mbegin - charscrollpos; - rct.LowerRightCorner.X = rct.UpperLeftCorner.X + mend; - - driver->draw2DRectangle(skin->getColor(EGDC_HIGH_LIGHT), rct, &AbsoluteClippingRect); - } - - // draw cursor - - if (focus && (os::Timer::getTime() - BlinkStartTime) % 700 < 350) - { - rct = frameRect; - rct.UpperLeftCorner.X += charcursorpos; - rct.UpperLeftCorner.X -= charscrollpos; - - font->draw(L"_", rct, - OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), - false, true, &AbsoluteClippingRect); - } - - // draw text - - if (Text.size()) - { - rct = frameRect; - rct.UpperLeftCorner.X -= charscrollpos; - - // Save the override color information. - // Then, alter it if the edit box is disabled. - bool prevOver = OverrideColorEnabled; - video::SColor prevColor = OverrideColor; - if ( !this->IsEnabled && !OverrideColorEnabled ) - { - OverrideColorEnabled = true; - OverrideColor = skin->getColor( EGDC_GRAY_TEXT ); - } - - if (focus && MarkBegin != MarkEnd) - { - // marked text - - font->draw(Text.c_str(), rct, - OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), - false, true, &AbsoluteClippingRect); - - s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - - s = Text.subString(0, realmbgn); - s32 mbegin = font->getDimension(s.c_str()).Width; - - s = Text.subString(realmbgn, realmend - realmbgn); - - rct.UpperLeftCorner.X += mbegin; - - font->draw(s.c_str(), rct, - OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_HIGH_LIGHT_TEXT), - false, true, &AbsoluteClippingRect); - } - else - { - // normal text - font->draw(Text.c_str(), rct, - OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), - false, true, &AbsoluteClippingRect); - } - - // Return the override color information to its previous settings. - OverrideColorEnabled = prevOver; - OverrideColor = prevColor; - } - } -} - -//! Sets the new caption of this element. -void CGUIEditBox::setText(const wchar_t* text) -{ - Text = text; - CursorPos = 0; - ScrollPos = 0; - MarkBegin = 0; - MarkEnd = 0; -} - - -//! Sets the maximum amount of characters which may be entered in the box. -//! \param max: Maximum amount of characters. If 0, the character amount is -//! infinity. -void CGUIEditBox::setMax(s32 max) -{ - Max = max; - if (Max < 0) - Max = 0; - - if (Text.size() > (u32)Max && Max != 0) - Text = Text.subString(0, Max); -} - - -//! Returns maximum amount of characters, previously set by setMax(); -s32 CGUIEditBox::getMax() -{ - return Max; -} - - -bool CGUIEditBox::processMouse(const SEvent& event) -{ - switch(event.MouseInput.Event) - { - case irr::EMIE_LMOUSE_LEFT_UP: - if (Environment->hasFocus(this)) - { - CursorPos = getCursorPos(event.MouseInput.X); - if (MouseMarking) - MarkEnd = CursorPos; - MouseMarking = false; - return true; - } - break; - case irr::EMIE_MOUSE_MOVED: - { - if (MouseMarking) - { - CursorPos = getCursorPos(event.MouseInput.X); - MarkEnd = CursorPos; - return true; - } - } - break; - case EMIE_LMOUSE_PRESSED_DOWN: - if (!Environment->hasFocus(this)) - { - // get focus - BlinkStartTime = os::Timer::getTime(); - Environment->setFocus(this); - MouseMarking = true; - CursorPos = getCursorPos(event.MouseInput.X); - MarkBegin = CursorPos; - MarkEnd = CursorPos; - return true; - } - else - { - if (!AbsoluteClippingRect.isPointInside( - core::position2d(event.MouseInput.X, event.MouseInput.Y))) - { - // remove focus - Environment->removeFocus(this); - return false; - } - - // move cursor - - CursorPos = getCursorPos(event.MouseInput.X); - - if (!MouseMarking) - MarkBegin = CursorPos; - - MouseMarking = true; - MarkEnd = CursorPos; - return true; - } - } - - return false; -} - - -s32 CGUIEditBox::getCursorPos(s32 x) -{ - IGUIFont* font = OverrideFont; - IGUISkin* skin = Environment->getSkin(); - if (!OverrideFont) - font = skin->getFont(); - - core::stringw s = Text.subString(0, ScrollPos); - s32 charscrollpos = font->getDimension(s.c_str()).Width; - - s32 idx = font->getCharacterFromPos(Text.c_str(), x - (AbsoluteRect.UpperLeftCorner.X + 3) + charscrollpos); - if (idx != -1) - return idx; - - return Text.size(); -} - -//! Writes attributes of the element. -void CGUIEditBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) -{ - IGUIEditBox::serializeAttributes(out,options); - out->addBool ("OverrideColorEnabled", OverrideColorEnabled ); - out->addColor ("OverrideColor", OverrideColor); - // out->addFont("OverrideFont",OverrideFont); - out->addInt ("MaxChars", Max); -} - -//! Reads attributes of the element -void CGUIEditBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIEditBox::deserializeAttributes(in,options); - setOverrideColor(in->getAttributeAsColor("OverrideColor")); - enableOverrideColor(in->getAttributeAsBool("OverrideColorEnabled")); - setMax(in->getAttributeAsInt("MaxChars")); - - // setOverrideFont(in->getAttributeAsFont("OverrideFont")); -} - - -} // end namespace gui -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIEditBox.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IGUIFont.h" +#include "IVideoDriver.h" +#include "rect.h" +#include "os.h" +#include "Keycodes.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIEditBox::CGUIEditBox(const wchar_t* text, bool border, IGUIEnvironment* environment, + IGUIElement* parent, s32 id, + const core::rect& rectangle, IOSOperator* op) +: IGUIEditBox(environment, parent, id, rectangle), MouseMarking(false), + Border(border), OverrideColorEnabled(false), MarkBegin(0), MarkEnd(0), + OverrideColor(video::SColor(101,255,255,255)), + OverrideFont(0), Operator(op), CursorPos(0), ScrollPos(0), Max(0) +{ + #ifdef _DEBUG + setDebugName("CGUIEditBox"); + #endif + + Text = text; + + if (Operator) + Operator->grab(); +} + + +//! destructor +CGUIEditBox::~CGUIEditBox() +{ + if (OverrideFont) + OverrideFont->drop(); + + if (Operator) + Operator->drop(); +} + + +//! Sets another skin independent font. +void CGUIEditBox::setOverrideFont(IGUIFont* font) +{ + if (OverrideFont) + OverrideFont->drop(); + + OverrideFont = font; + + if (OverrideFont) + OverrideFont->grab(); +} + + +//! Sets another color for the text. +void CGUIEditBox::setOverrideColor(video::SColor color) +{ + OverrideColor = color; + OverrideColorEnabled = true; +} + + +//! Sets if the text should use the overide color or the +//! color in the gui skin. +void CGUIEditBox::enableOverrideColor(bool enable) +{ + OverrideColorEnabled = enable; +} + + +//! called if an event happened. +bool CGUIEditBox::OnEvent(SEvent event) +{ + switch(event.EventType) + { + case EET_GUI_EVENT: + if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) + { + if (event.GUIEvent.Caller == (IGUIElement*)this) + { + MouseMarking = false; + MarkBegin = 0; + MarkEnd = 0; + } + } + break; + case EET_KEY_INPUT_EVENT: + if (processKey(event)) + return true; + break; + case EET_MOUSE_INPUT_EVENT: + if (processMouse(event)) + return true; + break; + } + + return Parent ? Parent->OnEvent(event) : false; +} + + +bool CGUIEditBox::processKey(const SEvent& event) +{ + if (!event.KeyInput.PressedDown) + return false; + + // control shortcut handling + + if (event.KeyInput.Control) + { + switch(event.KeyInput.Key) + { + case KEY_KEY_C: + // copy to clipboard + if (Operator && MarkBegin != MarkEnd) + { + s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + core::stringc s; + s = Text.subString(realmbgn, realmend - realmbgn).c_str(); + Operator->copyToClipboard(s.c_str()); + } + break; + case KEY_KEY_X: + if ( !this->IsEnabled ) + break; + + // cut to the clipboard + if (Operator && MarkBegin != MarkEnd) + { + s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + // copy + core::stringc sc; + sc = Text.subString(realmbgn, realmend - realmbgn).c_str(); + Operator->copyToClipboard(sc.c_str()); + + // delete + core::stringw s; + s = Text.subString(0, realmbgn); + s.append( Text.subString(realmend, Text.size()-realmend) ); + Text = s; + + CursorPos = realmbgn; + MarkBegin = 0; + MarkEnd = 0; + } + break; + case KEY_KEY_V: + if ( !this->IsEnabled ) + break; + + // paste from the clipboard + if (Operator) + { + s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + // add new character + const c8* p = Operator->getTextFromClipboard(); + if (p) + { + if (MarkBegin == MarkEnd) + { + // insert text + core::stringw s = Text.subString(0, CursorPos); + s.append(p); + s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); + + if (!Max || s.size()<=(u32)Max) // thx to Fish FH for fix + { + Text = s; + s = p; + CursorPos += s.size(); + } + } + else + { + // replace text + + core::stringw s = Text.subString(0, realmbgn); + s.append(p); + s.append( Text.subString(realmend, Text.size()-realmend) ); + + if (!Max || s.size()<=(u32)Max) // thx to Fish FH for fix + { + Text = s; + s = p; + CursorPos = realmbgn + s.size(); + } + } + } + + MarkBegin = 0; + MarkEnd = 0; + } + break; + default: + return false; + } + } + + // default keyboard handling + + if (!event.KeyInput.Control) + switch(event.KeyInput.Key) + { + case KEY_END: + if (event.KeyInput.Shift) + { + if (MarkBegin == MarkEnd) + MarkBegin = CursorPos; + MarkEnd = Text.size(); + } + else + { + MarkBegin = 0; + MarkEnd = 0; + } + CursorPos = Text.size(); + BlinkStartTime = os::Timer::getTime(); + break; + case KEY_HOME: + if (event.KeyInput.Shift) + { + if (MarkBegin == MarkEnd) + MarkBegin = CursorPos; + MarkEnd = 0; + } + else + { + MarkBegin = 0; + MarkEnd = 0; + } + CursorPos = 0; + BlinkStartTime = os::Timer::getTime(); + break; + case KEY_RETURN: + { + SEvent e; + e.EventType = EET_GUI_EVENT; + e.GUIEvent.Caller = this; + e.GUIEvent.EventType = EGET_EDITBOX_ENTER; + Parent->OnEvent(e); + } + break; + case KEY_LEFT: + + if (event.KeyInput.Shift) + { + if (CursorPos > 0) + { + if (MarkBegin == MarkEnd) + MarkBegin = CursorPos; + + MarkEnd = CursorPos-1; + } + } + else + { + MarkBegin = 0; + MarkEnd = 0; + } + + if (CursorPos > 0) CursorPos--; + BlinkStartTime = os::Timer::getTime(); + break; + + case KEY_RIGHT: + + if (event.KeyInput.Shift) + { + if (Text.size() > (u32)CursorPos) + { + if (MarkBegin == MarkEnd) + MarkBegin = CursorPos; + + MarkEnd = CursorPos+1; + } + } + else + { + MarkBegin = 0; + MarkEnd = 0; + } + + if (Text.size() > (u32)CursorPos) CursorPos++; + BlinkStartTime = os::Timer::getTime(); + break; + + case KEY_BACK: + if ( !this->IsEnabled ) + break; + + if (Text.size()) + { + core::stringw s; + + if (MarkBegin != MarkEnd) + { + // delete marked text + s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + s = Text.subString(0, realmbgn); + s.append( Text.subString(realmend, Text.size()-realmend) ); + Text = s; + + CursorPos = realmbgn; + } + else + { + // delete text behind cursor + if (CursorPos>0) + s = Text.subString(0, CursorPos-1); + else + s = L""; + s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); + Text = s; + --CursorPos; + } + + if (CursorPos < 0) + CursorPos = 0; + BlinkStartTime = os::Timer::getTime(); + MarkBegin = 0; + MarkEnd = 0; + } + break; + case KEY_DELETE: + if ( !this->IsEnabled ) + break; + + if (Text.size() != 0) + { + core::stringw s; + + if (MarkBegin != MarkEnd) + { + // delete marked text + s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + s = Text.subString(0, realmbgn); + s.append( Text.subString(realmend, Text.size()-realmend) ); + Text = s; + + CursorPos = realmbgn; + } + else + { + // delete text before cursor + s = Text.subString(0, CursorPos); + s.append( Text.subString(CursorPos+1, Text.size()-CursorPos-1) ); + Text = s; + } + + if (CursorPos > (s32)Text.size()) + CursorPos = (s32)Text.size(); + + BlinkStartTime = os::Timer::getTime(); + MarkBegin = 0; + MarkEnd = 0; + } + break; + default: + if ( !this->IsEnabled ) + break; + + if (event.KeyInput.Char != 0) + { + if (Text.size() < (u32)Max || Max == 0) + { + core::stringw s; + + if (MarkBegin != MarkEnd) + { + // replace marked text + s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + s = Text.subString(0, realmbgn); + s.append(event.KeyInput.Char); + s.append( Text.subString(realmend, Text.size()-realmend) ); + Text = s; + CursorPos = realmbgn+1; + } + else + { + // add new character + s = Text.subString(0, CursorPos); + s.append(event.KeyInput.Char); + s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); + Text = s; + ++CursorPos; + } + + BlinkStartTime = os::Timer::getTime(); + MarkBegin = 0; + MarkEnd = 0; + } + } + break; + } + + // calculate scrollpos + + IGUIFont* font = OverrideFont; + IGUISkin* skin = Environment->getSkin(); + if (!OverrideFont) + font = skin->getFont(); + + s32 cursorwidth = font->getDimension(L"_ ").Width; + + s32 minwidht = cursorwidth*2; + if (minwidht >= AbsoluteRect.getWidth()) + minwidht = AbsoluteRect.getWidth() / 2; + + s32 tries = Text.size()*2; + if (tries < 100) + tries = 100; + + for (s32 t=0; tgetDimension(s.c_str()).Width; + + s = Text.subString(0, ScrollPos); + s32 charscrollpos = font->getDimension(s.c_str()).Width; + + if ((charcursorpos + cursorwidth - charscrollpos) > AbsoluteRect.getWidth()) + ScrollPos++; + else + if ((charcursorpos + cursorwidth - charscrollpos) < minwidht) + { + if (ScrollPos > 0) + ScrollPos--; + else + break; + } + else + break; + } + + return true; +} + +//! draws the element and its children +void CGUIEditBox::draw() +{ + if (!IsVisible) + return; + + bool focus = Environment->hasFocus(this); + + IGUISkin* skin = Environment->getSkin(); + if (!skin) + return; + + irr::video::IVideoDriver* driver = Environment->getVideoDriver(); + + core::rect frameRect(AbsoluteRect); + + // draw the border + + if (Border) + { + skin->draw3DSunkenPane(this, skin->getColor(EGDC_WINDOW), + false, true, frameRect, &AbsoluteClippingRect); + + frameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X); + } + + // draw the text + + IGUIFont* font = OverrideFont; + if (!OverrideFont) + font = skin->getFont(); + + if (font) + { + // calculate cursor pos + + core::stringw s = Text.subString(0,CursorPos); + s32 charcursorpos = font->getDimension(s.c_str()).Width; + + s = Text.subString(0, ScrollPos); + s32 charscrollpos = font->getDimension(s.c_str()).Width; + + core::rect rct; + + // draw mark + + if (focus && MarkBegin != MarkEnd) + { + rct = frameRect; + + rct.LowerRightCorner.Y -= skin->getSize(EGDS_TEXT_DISTANCE_Y); + rct.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y); + + s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + s = Text.subString(0, realmbgn); + s32 mbegin = font->getDimension(s.c_str()).Width; + + s = Text.subString(realmbgn, realmend - realmbgn); + s32 mend = font->getDimension(s.c_str()).Width; + + rct.UpperLeftCorner.X += mbegin - charscrollpos; + rct.LowerRightCorner.X = rct.UpperLeftCorner.X + mend; + + driver->draw2DRectangle(skin->getColor(EGDC_HIGH_LIGHT), rct, &AbsoluteClippingRect); + } + + // draw cursor + + if (focus && (os::Timer::getTime() - BlinkStartTime) % 700 < 350) + { + rct = frameRect; + rct.UpperLeftCorner.X += charcursorpos; + rct.UpperLeftCorner.X -= charscrollpos; + + font->draw(L"_", rct, + OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), + false, true, &AbsoluteClippingRect); + } + + // draw text + + if (Text.size()) + { + rct = frameRect; + rct.UpperLeftCorner.X -= charscrollpos; + + // Save the override color information. + // Then, alter it if the edit box is disabled. + bool prevOver = OverrideColorEnabled; + video::SColor prevColor = OverrideColor; + if ( !this->IsEnabled && !OverrideColorEnabled ) + { + OverrideColorEnabled = true; + OverrideColor = skin->getColor( EGDC_GRAY_TEXT ); + } + + if (focus && MarkBegin != MarkEnd) + { + // marked text + + font->draw(Text.c_str(), rct, + OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), + false, true, &AbsoluteClippingRect); + + s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + s = Text.subString(0, realmbgn); + s32 mbegin = font->getDimension(s.c_str()).Width; + + s = Text.subString(realmbgn, realmend - realmbgn); + + rct.UpperLeftCorner.X += mbegin; + + font->draw(s.c_str(), rct, + OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_HIGH_LIGHT_TEXT), + false, true, &AbsoluteClippingRect); + } + else + { + // normal text + font->draw(Text.c_str(), rct, + OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), + false, true, &AbsoluteClippingRect); + } + + // Return the override color information to its previous settings. + OverrideColorEnabled = prevOver; + OverrideColor = prevColor; + } + } +} + +//! Sets the new caption of this element. +void CGUIEditBox::setText(const wchar_t* text) +{ + Text = text; + CursorPos = 0; + ScrollPos = 0; + MarkBegin = 0; + MarkEnd = 0; +} + + +//! Sets the maximum amount of characters which may be entered in the box. +//! \param max: Maximum amount of characters. If 0, the character amount is +//! infinity. +void CGUIEditBox::setMax(s32 max) +{ + Max = max; + if (Max < 0) + Max = 0; + + if (Text.size() > (u32)Max && Max != 0) + Text = Text.subString(0, Max); +} + + +//! Returns maximum amount of characters, previously set by setMax(); +s32 CGUIEditBox::getMax() +{ + return Max; +} + + +bool CGUIEditBox::processMouse(const SEvent& event) +{ + switch(event.MouseInput.Event) + { + case irr::EMIE_LMOUSE_LEFT_UP: + if (Environment->hasFocus(this)) + { + CursorPos = getCursorPos(event.MouseInput.X); + if (MouseMarking) + MarkEnd = CursorPos; + MouseMarking = false; + return true; + } + break; + case irr::EMIE_MOUSE_MOVED: + { + if (MouseMarking) + { + CursorPos = getCursorPos(event.MouseInput.X); + MarkEnd = CursorPos; + return true; + } + } + break; + case EMIE_LMOUSE_PRESSED_DOWN: + if (!Environment->hasFocus(this)) + { + // get focus + BlinkStartTime = os::Timer::getTime(); + Environment->setFocus(this); + MouseMarking = true; + CursorPos = getCursorPos(event.MouseInput.X); + MarkBegin = CursorPos; + MarkEnd = CursorPos; + return true; + } + else + { + if (!AbsoluteClippingRect.isPointInside( + core::position2d(event.MouseInput.X, event.MouseInput.Y))) + { + // remove focus + Environment->removeFocus(this); + return false; + } + + // move cursor + + CursorPos = getCursorPos(event.MouseInput.X); + + if (!MouseMarking) + MarkBegin = CursorPos; + + MouseMarking = true; + MarkEnd = CursorPos; + return true; + } + } + + return false; +} + + +s32 CGUIEditBox::getCursorPos(s32 x) +{ + IGUIFont* font = OverrideFont; + IGUISkin* skin = Environment->getSkin(); + if (!OverrideFont) + font = skin->getFont(); + + core::stringw s = Text.subString(0, ScrollPos); + s32 charscrollpos = font->getDimension(s.c_str()).Width; + + s32 idx = font->getCharacterFromPos(Text.c_str(), x - (AbsoluteRect.UpperLeftCorner.X + 3) + charscrollpos); + if (idx != -1) + return idx; + + return Text.size(); +} + +//! Writes attributes of the element. +void CGUIEditBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +{ + IGUIEditBox::serializeAttributes(out,options); + out->addBool ("OverrideColorEnabled", OverrideColorEnabled ); + out->addColor ("OverrideColor", OverrideColor); + // out->addFont("OverrideFont",OverrideFont); + out->addInt ("MaxChars", Max); +} + +//! Reads attributes of the element +void CGUIEditBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +{ + IGUIEditBox::deserializeAttributes(in,options); + setOverrideColor(in->getAttributeAsColor("OverrideColor")); + enableOverrideColor(in->getAttributeAsBool("OverrideColorEnabled")); + setMax(in->getAttributeAsInt("MaxChars")); + + // setOverrideFont(in->getAttributeAsFont("OverrideFont")); +} + + +} // end namespace gui +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CGUIEditBox.h b/src/dep/src/irrlicht/CGUIEditBox.h index de956dd..938c926 100644 --- a/src/dep/src/irrlicht/CGUIEditBox.h +++ b/src/dep/src/irrlicht/CGUIEditBox.h @@ -1,87 +1,87 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_EDIT_BOX_H_INCLUDED__ -#define __C_GUI_EDIT_BOX_H_INCLUDED__ - -#include "IGUIEditBox.h" -#include "irrArray.h" -#include "IOSOperator.h" - -namespace irr -{ -namespace gui -{ - class CGUIEditBox : public IGUIEditBox - { - public: - - //! constructor - CGUIEditBox(const wchar_t* text, bool border, IGUIEnvironment* environment, - IGUIElement* parent, s32 id, const core::rect& rectangle, - IOSOperator* op); - - //! destructor - ~CGUIEditBox(); - - //! Sets another skin independent font. - virtual void setOverrideFont(IGUIFont* font=0); - - //! Sets another color for the text. - virtual void setOverrideColor(video::SColor color); - - //! Sets if the text should use the overide color or the - //! color in the gui skin. - virtual void enableOverrideColor(bool enable); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! draws the element and its children - virtual void draw(); - - //! Sets the new caption of this element. - virtual void setText(const wchar_t* text); - - //! Sets the maximum amount of characters which may be entered in the box. - //! \param max: Maximum amount of characters. If 0, the character amount is - //! infinity. - virtual void setMax(s32 max); - - //! Returns maximum amount of characters, previously set by setMax(); - virtual s32 getMax(); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - protected: - - bool processKey(const SEvent& event); - bool processMouse(const SEvent& event); - s32 getCursorPos(s32 x); - - bool MouseMarking; - bool Border; - bool OverrideColorEnabled; - s32 MarkBegin; - s32 MarkEnd; - - video::SColor OverrideColor; - gui::IGUIFont* OverrideFont; - IOSOperator* Operator; - - u32 BlinkStartTime; - s32 CursorPos; - s32 ScrollPos; // scrollpos in characters - s32 Max; - }; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_EDIT_BOX_H_INCLUDED__ +#define __C_GUI_EDIT_BOX_H_INCLUDED__ + +#include "IGUIEditBox.h" +#include "irrArray.h" +#include "IOSOperator.h" + +namespace irr +{ +namespace gui +{ + class CGUIEditBox : public IGUIEditBox + { + public: + + //! constructor + CGUIEditBox(const wchar_t* text, bool border, IGUIEnvironment* environment, + IGUIElement* parent, s32 id, const core::rect& rectangle, + IOSOperator* op); + + //! destructor + ~CGUIEditBox(); + + //! Sets another skin independent font. + virtual void setOverrideFont(IGUIFont* font=0); + + //! Sets another color for the text. + virtual void setOverrideColor(video::SColor color); + + //! Sets if the text should use the overide color or the + //! color in the gui skin. + virtual void enableOverrideColor(bool enable); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! draws the element and its children + virtual void draw(); + + //! Sets the new caption of this element. + virtual void setText(const wchar_t* text); + + //! Sets the maximum amount of characters which may be entered in the box. + //! \param max: Maximum amount of characters. If 0, the character amount is + //! infinity. + virtual void setMax(s32 max); + + //! Returns maximum amount of characters, previously set by setMax(); + virtual s32 getMax(); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + protected: + + bool processKey(const SEvent& event); + bool processMouse(const SEvent& event); + s32 getCursorPos(s32 x); + + bool MouseMarking; + bool Border; + bool OverrideColorEnabled; + s32 MarkBegin; + s32 MarkEnd; + + video::SColor OverrideColor; + gui::IGUIFont* OverrideFont; + IOSOperator* Operator; + + u32 BlinkStartTime; + s32 CursorPos; + s32 ScrollPos; // scrollpos in characters + s32 Max; + }; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIEnvironment.cpp b/src/dep/src/irrlicht/CGUIEnvironment.cpp index 808575e..8c1aab1 100644 --- a/src/dep/src/irrlicht/CGUIEnvironment.cpp +++ b/src/dep/src/irrlicht/CGUIEnvironment.cpp @@ -1,1271 +1,1271 @@ - -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIEnvironment.h" -#include "IVideoDriver.h" - -#include "CGUISkin.h" -#include "CGUIButton.h" -#include "CGUIWindow.h" -#include "CGUIScrollBar.h" -#include "CGUIFont.h" -#include "CGUISpriteBank.h" -#include "CGUIImage.h" -#include "CGUIMeshViewer.h" -#include "CGUICheckBox.h" -#include "CGUIListBox.h" -#include "CGUIFileOpenDialog.h" -#include "CGUIColorSelectDialog.h" -#include "CGUIStaticText.h" -#include "CGUIEditBox.h" -#include "CGUIInOutFader.h" -#include "CGUIMessageBox.h" -#include "CGUIModalScreen.h" -#include "CGUITabControl.h" -#include "CGUIContextMenu.h" -#include "CGUIComboBox.h" -#include "CGUIMenu.h" -#include "CGUIToolBar.h" - -#include "CDefaultGUIElementFactory.h" -#include "IWriteFile.h" -#include "IXMLWriter.h" - -#include "BuiltInFont.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -const wchar_t* IRR_XML_FORMAT_GUI_ENV = L"irr_gui"; -const wchar_t* IRR_XML_FORMAT_GUI_ELEMENT = L"element"; -const wchar_t* IRR_XML_FORMAT_GUI_ELEMENT_ATTR_TYPE = L"type"; - -//! constructor -CGUIEnvironment::CGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* driver, IOSOperator* op) -: IGUIElement(EGUIET_ELEMENT, 0, 0, 0, core::rect(core::position2d(0,0), driver ? driver->getScreenSize() : core::dimension2d(0,0))), - Driver(driver), Hovered(0), Focus(0), CurrentSkin(0), - FileSystem(fs), UserReceiver(0), Operator(op) -{ - if (Driver) - Driver->grab(); - - if (FileSystem) - FileSystem->grab(); - - if (Operator) - Operator->grab(); - - #ifdef _DEBUG - IGUIEnvironment::setDebugName("CGUIEnvironment"); - #endif - - // gui factory - IGUIElementFactory* factory = new CDefaultGUIElementFactory(this); - registerGUIElementFactory(factory); - factory->drop(); - - loadBuiltInFont(); - - IGUISkin* skin = createSkin( gui::EGST_WINDOWS_METALLIC ); - setSkin(skin); - skin->drop(); - - //set tooltip default - ToolTip.LastTime = 0; - ToolTip.LaunchTime = 1000; - ToolTip.Element = 0; -} - - -//! destructor -CGUIEnvironment::~CGUIEnvironment() -{ - if (Hovered && Hovered != this) - Hovered->drop(); - - if (CurrentSkin) - CurrentSkin->drop(); - - if (Driver) - Driver->drop(); - - if (Focus) - Focus->drop(); - - if (FileSystem) - FileSystem->drop(); - - if (Operator) - Operator->drop(); - - // delete all fonts - u32 i; - - for (i=0; idrop(); - - // remove all factories - for (i=0; idrop(); - -} - - -void CGUIEnvironment::loadBuiltInFont() -{ - const c8* filename = "#DefaultFont"; - io::IReadFile* file = io::createMemoryReadFile(BuiltInFontData, BuiltInFontDataSize, filename, false); - - CGUIFont* font = new CGUIFont(this, "#DefaultFont"); - if (!font->load(file)) - { - os::Printer::log("Error: Could not load built-in Font.", ELL_ERROR); - font->drop(); - file->drop(); - return; - } - - SFont f; - f.Filename = filename; - f.Font = font; - Fonts.push_back(f); - - file->drop(); -} - - - -//! draws all gui elements -void CGUIEnvironment::drawAll() -{ - if (Driver) - { - core::dimension2d dim = Driver->getScreenSize(); - if (AbsoluteRect.LowerRightCorner.X != dim.Width || - AbsoluteRect.LowerRightCorner.Y != dim.Height) - { - // resize gui environment - RelativeRect.LowerRightCorner.X = Driver->getScreenSize().Width; - RelativeRect.LowerRightCorner.Y = Driver->getScreenSize().Height; - AbsoluteClippingRect = RelativeRect; - AbsoluteRect = RelativeRect; - updateAbsolutePosition(); - } - } - - draw(); - OnPostRender ( os::Timer::getTime () ); -} - - -//! sets the focus to an element -void CGUIEnvironment::setFocus(IGUIElement* element) -{ - if (Focus == element) - return; - - removeFocus(Focus); - - Focus = element; - - if (Focus) - { - Focus->grab(); - - // send focused event - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = Focus; - e.GUIEvent.EventType = EGET_ELEMENT_FOCUSED; - Focus->OnEvent(e); - } -} - -//! returns the element with the focus -IGUIElement* CGUIEnvironment::getFocus() -{ - return Focus; -} - - -//! removes the focus from an element -void CGUIEnvironment::removeFocus(IGUIElement* element) -{ - if (Focus && Focus==element) - { - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = Focus; - e.GUIEvent.EventType = EGET_ELEMENT_FOCUS_LOST; - Focus->OnEvent(e); - Focus->drop(); - Focus = 0; - } -} - - -//! Returns if the element has focus -bool CGUIEnvironment::hasFocus(IGUIElement* element) -{ - bool ret = (element == Focus); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! returns the current video driver -video::IVideoDriver* CGUIEnvironment::getVideoDriver() -{ - return Driver; -} - -//! returns the current file system -io::IFileSystem* CGUIEnvironment::getFileSystem() -{ - return FileSystem; -} - - -//! clear all GUI elements -void CGUIEnvironment::clear() -{ - // get the root's children in case the root changes in future - const core::list& children = getRootGUIElement()->getChildren(); - - while (!children.empty()) - (*children.getLast())->remove(); -} - - -//! called by ui if an event happened. -bool CGUIEnvironment::OnEvent(SEvent event) -{ - if (UserReceiver && event.GUIEvent.Caller != this) - return UserReceiver->OnEvent(event); - - return false; -} - -/* -*/ -void CGUIEnvironment::OnPostRender( u32 time ) -{ - // check tooltip - - // launch tooltip - if ( time - ToolTip.LastTime >= ToolTip.LaunchTime && - Hovered && Hovered != this && - ToolTip.Element == 0 && - Hovered != ToolTip.Element && - Hovered->getToolTipText().size() - ) - { - core::rect pos; - pos.UpperLeftCorner = Hovered->getAbsolutePosition().LowerRightCorner; - pos.LowerRightCorner = pos.UpperLeftCorner + core::position2d ( 100, 50 ); - if (getSkin() && getSkin()->getFont()) - { - pos.LowerRightCorner = pos.UpperLeftCorner + - getSkin()->getFont()->getDimension(Hovered->getToolTipText().c_str()) + - core::position2di(getSkin()->getSize(EGDS_TEXT_DISTANCE_X)*2, getSkin()->getSize(EGDS_TEXT_DISTANCE_Y)*2); - } - - ToolTip.Element = addStaticText ( Hovered->getToolTipText().c_str(), pos, true, true, this, -1, true ); - ToolTip.Element->setOverrideColor ( getSkin()->getColor ( EGDC_TOOLTIP ) ); - - s32 textHeight = ToolTip.Element->getTextHeight(); - pos = ToolTip.Element->getRelativePosition(); - pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + textHeight; - ToolTip.Element->setRelativePosition(pos); - - } - - IGUIElement::OnPostRender ( time ); -} - -/* -*/ -void CGUIEnvironment::updateHoveredElement(core::position2d mousePos) -{ - IGUIElement* lastHovered = Hovered; - - Hovered = getElementFromPoint(mousePos); - - if (Hovered) - { - u32 now = os::Timer::getTime (); - - if (Hovered != this) - Hovered->grab(); - - if (Hovered != lastHovered) - { - SEvent event; - event.EventType = EET_GUI_EVENT; - - if (lastHovered) - { - event.GUIEvent.Caller = lastHovered; - event.GUIEvent.EventType = EGET_ELEMENT_LEFT; - lastHovered->OnEvent(event); - } - - if ( ToolTip.Element ) - { - ToolTip.Element->remove (); - ToolTip.Element = 0; - } - else - { - // boost tooltip generation for relaunch - if ( now - ToolTip.LastTime < ToolTip.LastTime ) - { - ToolTip.LastTime += 100; - } - else - { - ToolTip.LastTime = now; - } - } - - - event.GUIEvent.Caller = Hovered; - event.GUIEvent.EventType = EGET_ELEMENT_HOVERED; - Hovered->OnEvent(event); - } - } - - if (lastHovered && lastHovered != this) - lastHovered->drop(); -} - - -//! This sets a new event receiver for gui events. Usually you do not have to -//! use this method, it is used by the internal engine. -void CGUIEnvironment::setUserEventReceiver(IEventReceiver* evr) -{ - UserReceiver = evr; -} - - -//! posts an input event to the environment -bool CGUIEnvironment::postEventFromUser(SEvent event) -{ - switch(event.EventType) - { - case EET_GUI_EVENT: - // hey, why is the user sending gui events..? - break; - case EET_MOUSE_INPUT_EVENT: - - // sending input to focus, stopping of focus processed input - - if (Focus && Focus->OnEvent(event)) - return true; - - if (!Focus) // focus could have died in last call - { - // trying to send input to hovered element - updateHoveredElement(core::position2d(event.MouseInput.X, event.MouseInput.Y)); - - if (Hovered && Hovered != this) - return Hovered->OnEvent(event); - } - break; - case EET_KEY_INPUT_EVENT: - if (Focus && Focus != this) - return Focus->OnEvent(event); - break; - } // end switch - - return false; -} - - - -//! returns the current gui skin -IGUISkin* CGUIEnvironment::getSkin() -{ - return CurrentSkin; -} - - -//! Sets a new GUI Skin -void CGUIEnvironment::setSkin(IGUISkin* skin) -{ - if (CurrentSkin) - CurrentSkin->drop(); - - CurrentSkin = skin; - - if (CurrentSkin) - CurrentSkin->grab(); -} - -//! Creates a new GUI Skin based on a template. -/** \return Returns a pointer to the created skin. -If you no longer need the skin, you should call IGUISkin::drop(). -See IUnknown::drop() for more information. */ -IGUISkin* CGUIEnvironment::createSkin(EGUI_SKIN_TYPE type) -{ - IGUISkin* skin = new CGUISkin(type, Driver); - - IGUIFont* builtinfont = getBuiltInFont(); - IGUIFontBitmap* bitfont = 0; - if (builtinfont && builtinfont->getType() == EGFT_BITMAP) - bitfont = (IGUIFontBitmap*)builtinfont; - - IGUISpriteBank* bank = 0; - skin->setFont(builtinfont); - - if (bitfont) - bank = bitfont->getSpriteBank(); - - skin->setSpriteBank(bank); - - return skin; -} - - -//! Returns the default element factory which can create all built in elements -IGUIElementFactory* CGUIEnvironment::getDefaultGUIElementFactory() -{ - return getGUIElementFactory(0); -} - -//! Adds an element factory to the gui environment. -/** Use this to extend the gui environment with new element types which it should be -able to create automaticly, for example when loading data from xml files. */ -void CGUIEnvironment::registerGUIElementFactory(IGUIElementFactory* factoryToAdd) -{ - if (factoryToAdd) - { - factoryToAdd->grab(); - GUIElementFactoryList.push_back(factoryToAdd); - } -} - -//! Returns amount of registered scene node factories. -s32 CGUIEnvironment::getRegisteredGUIElementFactoryCount() -{ - return GUIElementFactoryList.size(); -} - -//! Returns a scene node factory by index -IGUIElementFactory* CGUIEnvironment::getGUIElementFactory(s32 index) -{ - if (index>=0 && index<(int)GUIElementFactoryList.size()) - return GUIElementFactoryList[index]; - - return 0; -} - -//! adds a GUI Element using its name -IGUIElement* CGUIEnvironment::addGUIElement(const c8* elementName, IGUIElement* parent) -{ - IGUIElement* node=0; - - if (!parent) - parent = this; - - for (s32 i=0; i<(int)GUIElementFactoryList.size() && !node; ++i) - node = GUIElementFactoryList[i]->addGUIElement(elementName, parent); - - return node; -} - - -//! Saves the current gui into a file. -//! \param filename: Name of the file . -bool CGUIEnvironment::saveGUI(const c8* filename) -{ - io::IWriteFile* file = FileSystem->createAndWriteFile(filename); - if (!file) - return false; - - bool ret = saveGUI(file); - file->drop(); - return ret; -} - - -//! Saves the current gui into a file. -bool CGUIEnvironment::saveGUI(io::IWriteFile* file) -{ - if (!file) - return false; - - io::IXMLWriter* writer = FileSystem->createXMLWriter(file); - if (!writer) - return false; - - writer->writeXMLHeader(); - writeGUIElement(writer, this); - writer->drop(); - - return true; -} - - -//! Loads the gui. Note that the current gui is not cleared before. -//! \param filename: Name of the file . -bool CGUIEnvironment::loadGUI(const c8* filename) -{ - io::IReadFile* read = FileSystem->createAndOpenFile(filename); - if (!read) - { - os::Printer::log("Unable to open gui file", filename, ELL_ERROR); - return false; - } - - bool ret = loadGUI(read); - read->drop(); - - return ret; -} - - -//! Loads the gui. Note that the current gui is not cleared before. -bool CGUIEnvironment::loadGUI(io::IReadFile* file) -{ - - if (!file) - { - os::Printer::log("Unable to open gui file", ELL_ERROR); - return false; - } - - io::IXMLReader* reader = FileSystem->createXMLReader(file); - if (!reader) - { - os::Printer::log("GUI is not a valid XML file", file->getFileName(), ELL_ERROR); - return false; - } - - // read file - while(reader->read()) - { - readGUIElement(reader, 0); - } - - // finish up - - reader->drop(); - return true; - -} - - - -//! reads an element -void CGUIEnvironment::readGUIElement(io::IXMLReader* reader, IGUIElement* parent) -{ - if (!reader) - return; - - gui::IGUIElement* node = 0; - - if ((!parent && !wcscmp(IRR_XML_FORMAT_GUI_ENV, reader->getNodeName())) || - ( parent && !wcscmp(IRR_XML_FORMAT_GUI_ELEMENT, reader->getNodeName()))) - { - if (parent) - { - // find node type and create it - core::stringc attrName = reader->getAttributeValue(IRR_XML_FORMAT_GUI_ELEMENT_ATTR_TYPE); - - node = addGUIElement(attrName.c_str(), parent); - - if (!node) - os::Printer::log("Could not create GUI element of unknown type", attrName.c_str()); - } - else - node = this; // root - } - - // read attributes - - while(reader->read()) - { - bool endreached = false; - - switch (reader->getNodeType()) - { - case io::EXN_ELEMENT_END: - if (!wcscmp(IRR_XML_FORMAT_GUI_ELEMENT, reader->getNodeName()) || - !wcscmp(IRR_XML_FORMAT_GUI_ENV, reader->getNodeName())) - { - endreached = true; - } - break; - case io::EXN_ELEMENT: - if (!wcscmp(L"attributes", reader->getNodeName())) - { - // read attributes - io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); - attr->read(reader, true); - - if (node) - node->deserializeAttributes(attr); - - attr->drop(); - } - else - if (!wcscmp(IRR_XML_FORMAT_GUI_ELEMENT, reader->getNodeName()) || - !wcscmp(IRR_XML_FORMAT_GUI_ENV, reader->getNodeName())) - { - readGUIElement(reader, node); - } - else - { - os::Printer::log("Found unknown element in irrlicht GUI file", - core::stringc(reader->getNodeName()).c_str()); - } - - break; - } - - if (endreached) - break; - } -} - - - -//! writes an element -void CGUIEnvironment::writeGUIElement(io::IXMLWriter* writer, IGUIElement* node) -{ - if (!writer || !node ) - return; - - const wchar_t* name = 0; - - // write properties - - io::IAttributes* attr = FileSystem->createEmptyAttributes(); - node->serializeAttributes(attr); - - // all gui elements must have at least one attribute - // if they have nothing then we ignore them. - if (attr->getAttributeCount() > 0) - { - if (node == this) - { - name = IRR_XML_FORMAT_GUI_ENV; - writer->writeElement(name, false); - } - else - { - name = IRR_XML_FORMAT_GUI_ELEMENT; - writer->writeElement(name, false, IRR_XML_FORMAT_GUI_ELEMENT_ATTR_TYPE, - core::stringw(node->getTypeName()).c_str()); - } - - writer->writeLineBreak(); - writer->writeLineBreak(); - - attr->write(writer); - writer->writeLineBreak(); - } - - // write children - - core::list::Iterator it = node->getChildren().begin(); - for (; it != node->getChildren().end(); ++it) - { - if (!(*it)->isSubElement()) - writeGUIElement(writer, (*it)); - } - - // write closing brace if required - if (attr->getAttributeCount() > 0) - { - writer->writeClosingTag(name); - writer->writeLineBreak(); - writer->writeLineBreak(); - } - - attr->drop(); - -} - - -//! Writes attributes of the environment -void CGUIEnvironment::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - IGUISkin* skin = getSkin(); - - if (skin) - { - out->addEnum("Skin",getSkin()->getType(),GUISkinTypeNames); - skin->serializeAttributes(out, options); - } -} - -//! Reads attributes of the environment -void CGUIEnvironment::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - - if (in->existsAttribute("Skin")) - { - IGUISkin *skin = getSkin(); - - EGUI_SKIN_TYPE t = (EGUI_SKIN_TYPE) in->getAttributeAsEnumeration("Skin",GUISkinTypeNames); - if ( !skin || t != skin->getType()) - { - skin = createSkin(t); - setSkin(skin); - skin->drop(); - } - - skin = getSkin(); - - if (skin) - { - skin->deserializeAttributes(in, options); - } - - } - - RelativeRect = AbsoluteRect = - core::rect(core::position2d(0,0), - Driver ? Driver->getScreenSize() : core::dimension2d(0,0)); - -} - - - - -//! adds an button. The returned pointer must not be dropped. -IGUIButton* CGUIEnvironment::addButton(const core::rect& rectangle, IGUIElement* parent, s32 id, const wchar_t* text, const wchar_t *tooltiptext) -{ - IGUIButton* button = new CGUIButton(this, parent ? parent : this, id, rectangle); - if (text) - button->setText(text); - - if ( tooltiptext ) - button->setToolTipText ( tooltiptext ); - - button->drop(); - return button; -} - - -//! adds a window. The returned pointer must not be dropped. -IGUIWindow* CGUIEnvironment::addWindow(const core::rect& rectangle, bool modal, - const wchar_t* text, IGUIElement* parent, s32 id) -{ - parent = parent ? parent : this; - - if (modal) - { - parent = new CGUIModalScreen(this, parent, -1); - parent->drop(); - } - - IGUIWindow* win = new CGUIWindow(this, parent, id, rectangle); - if (text) - win->setText(text); - win->drop(); - - return win; -} -//! adds a modal screen. The returned pointer must not be dropped. -IGUIElement* CGUIEnvironment::addModalScreen(IGUIElement* parent) -{ - parent = parent ? parent : this; - - IGUIElement *win = new CGUIModalScreen(this, parent, -1); - win->drop(); - - return win; -} - -//! Adds a message box. -IGUIWindow* CGUIEnvironment::addMessageBox(const wchar_t* caption, const wchar_t* text, - bool modal, s32 flag, IGUIElement* parent, s32 id) -{ - if (!CurrentSkin) - return 0; - - parent = parent ? parent : this; - - core::rect rect; - core::dimension2d screenDim, msgBoxDim; - - screenDim.Width = parent->getAbsolutePosition().getWidth(); - screenDim.Height = parent->getAbsolutePosition().getHeight(); - msgBoxDim.Width = CurrentSkin->getSize(gui::EGDS_MESSAGE_BOX_WIDTH); - msgBoxDim.Height = CurrentSkin->getSize(gui::EGDS_MESSAGE_BOX_HEIGHT); - - rect.UpperLeftCorner.X = (screenDim.Width - msgBoxDim.Width) / 2; - rect.UpperLeftCorner.Y = (screenDim.Height - msgBoxDim.Height) / 2; - rect.LowerRightCorner.X = rect.UpperLeftCorner.X + msgBoxDim.Width; - rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + msgBoxDim.Height; - - if (modal) - { - parent = new CGUIModalScreen(this, parent, -1); - parent->drop(); - } - - IGUIWindow* win = new CGUIMessageBox(this, caption, text, flag, - parent, id, rect); - - win->drop(); - return win; -} - - -//! adds a scrollbar. The returned pointer must not be dropped. -IGUIScrollBar* CGUIEnvironment::addScrollBar(bool horizontal, const core::rect& rectangle, IGUIElement* parent, s32 id) -{ - IGUIScrollBar* bar = new CGUIScrollBar(horizontal, this, parent ? parent : this, id, rectangle); - bar->drop(); - return bar; -} - - -//! Adds an image element. -IGUIImage* CGUIEnvironment::addImage(video::ITexture* image, core::position2d pos, - bool useAlphaChannel, IGUIElement* parent, s32 id, const wchar_t* text) -{ - core::dimension2d sz(0,0); - if (image) - sz = image->getOriginalSize(); - - IGUIImage* img = new CGUIImage(this, parent ? parent : this, - id, core::rect(pos, sz)); - - if (text) - img->setText(text); - - if (useAlphaChannel) - img->setUseAlphaChannel(true); - - if (image) - img->setImage(image); - - img->drop(); - return img; -} - - -//! adds an image. The returned pointer must not be dropped. -IGUIImage* CGUIEnvironment::addImage(const core::rect& rectangle, IGUIElement* parent, s32 id, const wchar_t* text) -{ - IGUIImage* img = new CGUIImage(this, parent ? parent : this, - id, rectangle); - - if (text) - img->setText(text); - - img->drop(); - return img; -} - - -//! adds an mesh viewer. The returned pointer must not be dropped. -IGUIMeshViewer* CGUIEnvironment::addMeshViewer(const core::rect& rectangle, IGUIElement* parent, s32 id, const wchar_t* text) -{ - IGUIMeshViewer* v = new CGUIMeshViewer(this, parent ? parent : this, - id, rectangle); - - if (text) - v->setText(text); - - v->drop(); - return v; -} - - -//! adds a checkbox -IGUICheckBox* CGUIEnvironment::addCheckBox(bool checked, const core::rect& rectangle, IGUIElement* parent, s32 id, const wchar_t* text) -{ - IGUICheckBox* b = new CGUICheckBox(checked, this, - parent ? parent : this , id , rectangle); - - if (text) - b->setText(text); - - b->drop(); - return b; -} - - - -//! adds a list box -IGUIListBox* CGUIEnvironment::addListBox(const core::rect& rectangle, - IGUIElement* parent, s32 id, - bool drawBackground) -{ - IGUIListBox* b = new CGUIListBox(this, parent ? parent : this, id, rectangle, - true, drawBackground, false); - - if (getBuiltInFont() && getBuiltInFont()->getType() == EGFT_BITMAP) - b->setSpriteBank( ((IGUIFontBitmap*)getBuiltInFont())->getSpriteBank()); - - b->drop(); - return b; - -} - - - -//! adds a file open dialog. The returned pointer must not be dropped. -IGUIFileOpenDialog* CGUIEnvironment::addFileOpenDialog(const wchar_t* title, - bool modal, - IGUIElement* parent, s32 id) -{ - parent = parent ? parent : this; - - if (modal) - { - parent = new CGUIModalScreen(this, parent, -1); - parent->drop(); - } - - IGUIFileOpenDialog* d = new CGUIFileOpenDialog(title, this, parent, id); - - d->drop(); - return d; -} - - -//! adds a color select dialog. The returned pointer must not be dropped. -IGUIColorSelectDialog* CGUIEnvironment::addColorSelectDialog(const wchar_t* title, - bool modal, - IGUIElement* parent, s32 id) -{ - parent = parent ? parent : this; - - if (modal) - { - parent = new CGUIModalScreen(this, parent, -1); - parent->drop(); - } - - IGUIColorSelectDialog* d = new CGUIColorSelectDialog( title, - this, parent, id); - - d->drop(); - return d; -} - - - -//! adds a static text. The returned pointer must not be dropped. -IGUIStaticText* CGUIEnvironment::addStaticText(const wchar_t* text, - const core::rect& rectangle, - bool border, - bool wordWrap, - IGUIElement* parent, s32 id, - bool background) -{ - IGUIStaticText* d = new CGUIStaticText(text, border, this, - parent ? parent : this, id, rectangle, background); - - d->setWordWrap(wordWrap); - d->drop(); - - return d; -} - - - -//! Adds an edit box. The returned pointer must not be dropped. -IGUIEditBox* CGUIEnvironment::addEditBox(const wchar_t* text, - const core::rect& rectangle, - bool border, IGUIElement* parent, - s32 id) -{ - IGUIEditBox* d = new CGUIEditBox(text, border, this, - parent ? parent : this, id, rectangle, Operator); - - d->drop(); - return d; -} - -//! Adds a tab control to the environment. -IGUITabControl* CGUIEnvironment::addTabControl(const core::rect& rectangle, - IGUIElement* parent, bool fillbackground, bool border, s32 id) -{ - IGUITabControl* t = new CGUITabControl(this, parent ? parent : this, - rectangle, fillbackground, border, id); - t->drop(); - return t; -} - - -//! Adds tab to the environment. -IGUITab* CGUIEnvironment::addTab(const core::rect& rectangle, - IGUIElement* parent, s32 id) -{ - IGUITab* t = new CGUITab(-1, this, parent ? parent : this, - rectangle, id); - t->drop(); - return t; -} - - -//! Adds a context menu to the environment. -IGUIContextMenu* CGUIEnvironment::addContextMenu(const core::rect& rectangle, - IGUIElement* parent, s32 id) -{ - IGUIContextMenu* c = new CGUIContextMenu(this, - parent ? parent : this, id, rectangle, true); - c->drop(); - return c; -} - - -//! Adds a menu to the environment. -IGUIContextMenu* CGUIEnvironment::addMenu(IGUIElement* parent, s32 id) -{ - if (!parent) - parent = this; - - IGUIContextMenu* c = new CGUIMenu(this, - parent, id, core::rect(0,0, - parent->getAbsolutePosition().getWidth(), - parent->getAbsolutePosition().getHeight())); - - c->drop(); - return c; -} - -//! Adds a toolbar to the environment. It is like a menu is always placed on top -//! in its parent, and contains buttons. -IGUIToolBar* CGUIEnvironment::addToolBar(IGUIElement* parent, s32 id) -{ - if (!parent) - parent = this; - - IGUIToolBar* b = new CGUIToolBar(this, parent, id, core::rect(0,0,10,10)); - b->drop(); - return b; -} - - - -//! Adds an element for fading in or out. -IGUIInOutFader* CGUIEnvironment::addInOutFader(const core::rect* rectangle, IGUIElement* parent, s32 id) -{ - core::rect rect; - - if (rectangle) - rect = *rectangle; - else - if (Driver) - rect = core::rect(core::position2d(0,0), Driver->getScreenSize()); - - if (!parent) - parent = this; - - IGUIInOutFader* fader = new CGUIInOutFader(this, parent, id, rect); - fader->drop(); - return fader; -} - - -//! Adds a combo box to the environment. -IGUIComboBox* CGUIEnvironment::addComboBox(const core::rect& rectangle, - IGUIElement* parent, s32 id) -{ - IGUIComboBox* t = new CGUIComboBox(this, parent ? parent : this, - id, rectangle); - t->drop(); - return t; - -} - - - -//! returns the font -IGUIFont* CGUIEnvironment::getFont(const c8* filename) -{ - // search existing font - - SFont f; - IGUIFont* ifont=0; - if (!filename) - f.Filename = ""; - else - f.Filename = filename; - - f.Filename.make_lower(); - - s32 index = Fonts.binary_search(f); - if (index != -1) - return Fonts[index].Font; - - // font doesn't exist, attempt to load it - - // does the file exist? - - if (!FileSystem->existFile(f.Filename.c_str())) - { - os::Printer::log("Could not load font because the file does not exist", f.Filename.c_str(), ELL_ERROR); - return 0; - } - - io::IXMLReader *xml = FileSystem->createXMLReader(f.Filename.c_str()); - if (xml) - { - // this is an XML font, but we need to know what type - EGUI_FONT_TYPE t = EGFT_CUSTOM; - - bool found=false; - while(xml->read() && !found) - { - if (xml->getNodeType() == io::EXN_ELEMENT) - { - if (core::stringw(L"font") == xml->getNodeName()) - { - if (core::stringw(L"vector") == xml->getAttributeValue(L"type")) - { - t = EGFT_VECTOR; - found=true; - } - else if (core::stringw(L"bitmap") == xml->getAttributeValue(L"type")) - { - t = EGFT_BITMAP; - found=true; - } - else found=true; - } - } - } - - if (t==EGFT_BITMAP) - { - CGUIFont* font = new CGUIFont(this, f.Filename.c_str()); - ifont = (IGUIFont*)font; - if (!font->load(xml)) - { - font->drop(); - font = 0; - ifont = 0; - } - } - else if (t==EGFT_VECTOR) - { - // todo: vector fonts - - //CGUIFontVector* font = new CGUIFontVector(Driver); - //ifont = (IGUIFont*)font; - //if (!font->load(xml)) - } - xml->drop(); - } - - - if (!ifont) - { - - CGUIFont* font = new CGUIFont(this, f.Filename.c_str()); - ifont = (IGUIFont*)font; - if (!font->load(f.Filename.c_str())) - { - font->drop(); - return 0; - } - } - - // add to fonts. - - f.Font = ifont; - Fonts.push_back(f); - - return ifont; -} - -IGUISpriteBank* CGUIEnvironment::getSpriteBank(const c8* filename) -{ - // search for the file name - - SSpriteBank b; - if (!filename) - b.Filename = ""; - else - b.Filename = filename; - - b.Filename.make_lower(); - - s32 index = Banks.binary_search(b); - if (index != -1) - return Banks[index].Bank; - - // we don't have this sprite bank, we should load it - - if (!FileSystem->existFile(b.Filename.c_str())) - { - os::Printer::log("Could not load sprite bank because the file does not exist", filename, ELL_ERROR); - return 0; - } - - // todo: load it! - - return 0; - -} - -IGUISpriteBank* CGUIEnvironment::addEmptySpriteBank(const c8 *name) -{ - // no duplicate names allowed - - SSpriteBank b; - if (!name) - b.Filename = ""; - else - b.Filename = name; - - s32 index = Banks.binary_search(b); - if (index != -1) - return 0; - - - // create a new sprite bank - - b.Bank = new CGUISpriteBank(this); - - Banks.push_back(b); - - return b.Bank; - -} - -//! returns default font -IGUIFont* CGUIEnvironment::getBuiltInFont() -{ - if (Fonts.empty()) - return 0; - - return Fonts[0].Font; -} - - - -//! Returns the root gui element. -IGUIElement* CGUIEnvironment::getRootGUIElement() -{ - return this; -} - - - -//! creates an GUI Environment -IGUIEnvironment* createGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* Driver, - IOSOperator* op) -{ - return new CGUIEnvironment(fs, Driver, op); -} - - -} // end namespace gui -} // end namespace irr - + +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIEnvironment.h" +#include "IVideoDriver.h" + +#include "CGUISkin.h" +#include "CGUIButton.h" +#include "CGUIWindow.h" +#include "CGUIScrollBar.h" +#include "CGUIFont.h" +#include "CGUISpriteBank.h" +#include "CGUIImage.h" +#include "CGUIMeshViewer.h" +#include "CGUICheckBox.h" +#include "CGUIListBox.h" +#include "CGUIFileOpenDialog.h" +#include "CGUIColorSelectDialog.h" +#include "CGUIStaticText.h" +#include "CGUIEditBox.h" +#include "CGUIInOutFader.h" +#include "CGUIMessageBox.h" +#include "CGUIModalScreen.h" +#include "CGUITabControl.h" +#include "CGUIContextMenu.h" +#include "CGUIComboBox.h" +#include "CGUIMenu.h" +#include "CGUIToolBar.h" + +#include "CDefaultGUIElementFactory.h" +#include "IWriteFile.h" +#include "IXMLWriter.h" + +#include "BuiltInFont.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + +const wchar_t* IRR_XML_FORMAT_GUI_ENV = L"irr_gui"; +const wchar_t* IRR_XML_FORMAT_GUI_ELEMENT = L"element"; +const wchar_t* IRR_XML_FORMAT_GUI_ELEMENT_ATTR_TYPE = L"type"; + +//! constructor +CGUIEnvironment::CGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* driver, IOSOperator* op) +: IGUIElement(EGUIET_ELEMENT, 0, 0, 0, core::rect(core::position2d(0,0), driver ? driver->getScreenSize() : core::dimension2d(0,0))), + Driver(driver), Hovered(0), Focus(0), CurrentSkin(0), + FileSystem(fs), UserReceiver(0), Operator(op) +{ + if (Driver) + Driver->grab(); + + if (FileSystem) + FileSystem->grab(); + + if (Operator) + Operator->grab(); + + #ifdef _DEBUG + IGUIEnvironment::setDebugName("CGUIEnvironment"); + #endif + + // gui factory + IGUIElementFactory* factory = new CDefaultGUIElementFactory(this); + registerGUIElementFactory(factory); + factory->drop(); + + loadBuiltInFont(); + + IGUISkin* skin = createSkin( gui::EGST_WINDOWS_METALLIC ); + setSkin(skin); + skin->drop(); + + //set tooltip default + ToolTip.LastTime = 0; + ToolTip.LaunchTime = 1000; + ToolTip.Element = 0; +} + + +//! destructor +CGUIEnvironment::~CGUIEnvironment() +{ + if (Hovered && Hovered != this) + Hovered->drop(); + + if (CurrentSkin) + CurrentSkin->drop(); + + if (Driver) + Driver->drop(); + + if (Focus) + Focus->drop(); + + if (FileSystem) + FileSystem->drop(); + + if (Operator) + Operator->drop(); + + // delete all fonts + u32 i; + + for (i=0; idrop(); + + // remove all factories + for (i=0; idrop(); + +} + + +void CGUIEnvironment::loadBuiltInFont() +{ + const c8* filename = "#DefaultFont"; + io::IReadFile* file = io::createMemoryReadFile(BuiltInFontData, BuiltInFontDataSize, filename, false); + + CGUIFont* font = new CGUIFont(this, "#DefaultFont"); + if (!font->load(file)) + { + os::Printer::log("Error: Could not load built-in Font.", ELL_ERROR); + font->drop(); + file->drop(); + return; + } + + SFont f; + f.Filename = filename; + f.Font = font; + Fonts.push_back(f); + + file->drop(); +} + + + +//! draws all gui elements +void CGUIEnvironment::drawAll() +{ + if (Driver) + { + core::dimension2d dim = Driver->getScreenSize(); + if (AbsoluteRect.LowerRightCorner.X != dim.Width || + AbsoluteRect.LowerRightCorner.Y != dim.Height) + { + // resize gui environment + RelativeRect.LowerRightCorner.X = Driver->getScreenSize().Width; + RelativeRect.LowerRightCorner.Y = Driver->getScreenSize().Height; + AbsoluteClippingRect = RelativeRect; + AbsoluteRect = RelativeRect; + updateAbsolutePosition(); + } + } + + draw(); + OnPostRender ( os::Timer::getTime () ); +} + + +//! sets the focus to an element +void CGUIEnvironment::setFocus(IGUIElement* element) +{ + if (Focus == element) + return; + + removeFocus(Focus); + + Focus = element; + + if (Focus) + { + Focus->grab(); + + // send focused event + SEvent e; + e.EventType = EET_GUI_EVENT; + e.GUIEvent.Caller = Focus; + e.GUIEvent.EventType = EGET_ELEMENT_FOCUSED; + Focus->OnEvent(e); + } +} + +//! returns the element with the focus +IGUIElement* CGUIEnvironment::getFocus() +{ + return Focus; +} + + +//! removes the focus from an element +void CGUIEnvironment::removeFocus(IGUIElement* element) +{ + if (Focus && Focus==element) + { + SEvent e; + e.EventType = EET_GUI_EVENT; + e.GUIEvent.Caller = Focus; + e.GUIEvent.EventType = EGET_ELEMENT_FOCUS_LOST; + Focus->OnEvent(e); + Focus->drop(); + Focus = 0; + } +} + + +//! Returns if the element has focus +bool CGUIEnvironment::hasFocus(IGUIElement* element) +{ + bool ret = (element == Focus); + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return ret; +} + + +//! returns the current video driver +video::IVideoDriver* CGUIEnvironment::getVideoDriver() +{ + return Driver; +} + +//! returns the current file system +io::IFileSystem* CGUIEnvironment::getFileSystem() +{ + return FileSystem; +} + + +//! clear all GUI elements +void CGUIEnvironment::clear() +{ + // get the root's children in case the root changes in future + const core::list& children = getRootGUIElement()->getChildren(); + + while (!children.empty()) + (*children.getLast())->remove(); +} + + +//! called by ui if an event happened. +bool CGUIEnvironment::OnEvent(SEvent event) +{ + if (UserReceiver && event.GUIEvent.Caller != this) + return UserReceiver->OnEvent(event); + + return false; +} + +/* +*/ +void CGUIEnvironment::OnPostRender( u32 time ) +{ + // check tooltip + + // launch tooltip + if ( time - ToolTip.LastTime >= ToolTip.LaunchTime && + Hovered && Hovered != this && + ToolTip.Element == 0 && + Hovered != ToolTip.Element && + Hovered->getToolTipText().size() + ) + { + core::rect pos; + pos.UpperLeftCorner = Hovered->getAbsolutePosition().LowerRightCorner; + pos.LowerRightCorner = pos.UpperLeftCorner + core::position2d ( 100, 50 ); + if (getSkin() && getSkin()->getFont()) + { + pos.LowerRightCorner = pos.UpperLeftCorner + + getSkin()->getFont()->getDimension(Hovered->getToolTipText().c_str()) + + core::position2di(getSkin()->getSize(EGDS_TEXT_DISTANCE_X)*2, getSkin()->getSize(EGDS_TEXT_DISTANCE_Y)*2); + } + + ToolTip.Element = addStaticText ( Hovered->getToolTipText().c_str(), pos, true, true, this, -1, true ); + ToolTip.Element->setOverrideColor ( getSkin()->getColor ( EGDC_TOOLTIP ) ); + + s32 textHeight = ToolTip.Element->getTextHeight(); + pos = ToolTip.Element->getRelativePosition(); + pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + textHeight; + ToolTip.Element->setRelativePosition(pos); + + } + + IGUIElement::OnPostRender ( time ); +} + +/* +*/ +void CGUIEnvironment::updateHoveredElement(core::position2d mousePos) +{ + IGUIElement* lastHovered = Hovered; + + Hovered = getElementFromPoint(mousePos); + + if (Hovered) + { + u32 now = os::Timer::getTime (); + + if (Hovered != this) + Hovered->grab(); + + if (Hovered != lastHovered) + { + SEvent event; + event.EventType = EET_GUI_EVENT; + + if (lastHovered) + { + event.GUIEvent.Caller = lastHovered; + event.GUIEvent.EventType = EGET_ELEMENT_LEFT; + lastHovered->OnEvent(event); + } + + if ( ToolTip.Element ) + { + ToolTip.Element->remove (); + ToolTip.Element = 0; + } + else + { + // boost tooltip generation for relaunch + if ( now - ToolTip.LastTime < ToolTip.LastTime ) + { + ToolTip.LastTime += 100; + } + else + { + ToolTip.LastTime = now; + } + } + + + event.GUIEvent.Caller = Hovered; + event.GUIEvent.EventType = EGET_ELEMENT_HOVERED; + Hovered->OnEvent(event); + } + } + + if (lastHovered && lastHovered != this) + lastHovered->drop(); +} + + +//! This sets a new event receiver for gui events. Usually you do not have to +//! use this method, it is used by the internal engine. +void CGUIEnvironment::setUserEventReceiver(IEventReceiver* evr) +{ + UserReceiver = evr; +} + + +//! posts an input event to the environment +bool CGUIEnvironment::postEventFromUser(SEvent event) +{ + switch(event.EventType) + { + case EET_GUI_EVENT: + // hey, why is the user sending gui events..? + break; + case EET_MOUSE_INPUT_EVENT: + + // sending input to focus, stopping of focus processed input + + if (Focus && Focus->OnEvent(event)) + return true; + + if (!Focus) // focus could have died in last call + { + // trying to send input to hovered element + updateHoveredElement(core::position2d(event.MouseInput.X, event.MouseInput.Y)); + + if (Hovered && Hovered != this) + return Hovered->OnEvent(event); + } + break; + case EET_KEY_INPUT_EVENT: + if (Focus && Focus != this) + return Focus->OnEvent(event); + break; + } // end switch + + return false; +} + + + +//! returns the current gui skin +IGUISkin* CGUIEnvironment::getSkin() +{ + return CurrentSkin; +} + + +//! Sets a new GUI Skin +void CGUIEnvironment::setSkin(IGUISkin* skin) +{ + if (CurrentSkin) + CurrentSkin->drop(); + + CurrentSkin = skin; + + if (CurrentSkin) + CurrentSkin->grab(); +} + +//! Creates a new GUI Skin based on a template. +/** \return Returns a pointer to the created skin. +If you no longer need the skin, you should call IGUISkin::drop(). +See IUnknown::drop() for more information. */ +IGUISkin* CGUIEnvironment::createSkin(EGUI_SKIN_TYPE type) +{ + IGUISkin* skin = new CGUISkin(type, Driver); + + IGUIFont* builtinfont = getBuiltInFont(); + IGUIFontBitmap* bitfont = 0; + if (builtinfont && builtinfont->getType() == EGFT_BITMAP) + bitfont = (IGUIFontBitmap*)builtinfont; + + IGUISpriteBank* bank = 0; + skin->setFont(builtinfont); + + if (bitfont) + bank = bitfont->getSpriteBank(); + + skin->setSpriteBank(bank); + + return skin; +} + + +//! Returns the default element factory which can create all built in elements +IGUIElementFactory* CGUIEnvironment::getDefaultGUIElementFactory() +{ + return getGUIElementFactory(0); +} + +//! Adds an element factory to the gui environment. +/** Use this to extend the gui environment with new element types which it should be +able to create automaticly, for example when loading data from xml files. */ +void CGUIEnvironment::registerGUIElementFactory(IGUIElementFactory* factoryToAdd) +{ + if (factoryToAdd) + { + factoryToAdd->grab(); + GUIElementFactoryList.push_back(factoryToAdd); + } +} + +//! Returns amount of registered scene node factories. +s32 CGUIEnvironment::getRegisteredGUIElementFactoryCount() +{ + return GUIElementFactoryList.size(); +} + +//! Returns a scene node factory by index +IGUIElementFactory* CGUIEnvironment::getGUIElementFactory(s32 index) +{ + if (index>=0 && index<(int)GUIElementFactoryList.size()) + return GUIElementFactoryList[index]; + + return 0; +} + +//! adds a GUI Element using its name +IGUIElement* CGUIEnvironment::addGUIElement(const c8* elementName, IGUIElement* parent) +{ + IGUIElement* node=0; + + if (!parent) + parent = this; + + for (s32 i=0; i<(int)GUIElementFactoryList.size() && !node; ++i) + node = GUIElementFactoryList[i]->addGUIElement(elementName, parent); + + return node; +} + + +//! Saves the current gui into a file. +//! \param filename: Name of the file . +bool CGUIEnvironment::saveGUI(const c8* filename) +{ + io::IWriteFile* file = FileSystem->createAndWriteFile(filename); + if (!file) + return false; + + bool ret = saveGUI(file); + file->drop(); + return ret; +} + + +//! Saves the current gui into a file. +bool CGUIEnvironment::saveGUI(io::IWriteFile* file) +{ + if (!file) + return false; + + io::IXMLWriter* writer = FileSystem->createXMLWriter(file); + if (!writer) + return false; + + writer->writeXMLHeader(); + writeGUIElement(writer, this); + writer->drop(); + + return true; +} + + +//! Loads the gui. Note that the current gui is not cleared before. +//! \param filename: Name of the file . +bool CGUIEnvironment::loadGUI(const c8* filename) +{ + io::IReadFile* read = FileSystem->createAndOpenFile(filename); + if (!read) + { + os::Printer::log("Unable to open gui file", filename, ELL_ERROR); + return false; + } + + bool ret = loadGUI(read); + read->drop(); + + return ret; +} + + +//! Loads the gui. Note that the current gui is not cleared before. +bool CGUIEnvironment::loadGUI(io::IReadFile* file) +{ + + if (!file) + { + os::Printer::log("Unable to open gui file", ELL_ERROR); + return false; + } + + io::IXMLReader* reader = FileSystem->createXMLReader(file); + if (!reader) + { + os::Printer::log("GUI is not a valid XML file", file->getFileName(), ELL_ERROR); + return false; + } + + // read file + while(reader->read()) + { + readGUIElement(reader, 0); + } + + // finish up + + reader->drop(); + return true; + +} + + + +//! reads an element +void CGUIEnvironment::readGUIElement(io::IXMLReader* reader, IGUIElement* parent) +{ + if (!reader) + return; + + gui::IGUIElement* node = 0; + + if ((!parent && !wcscmp(IRR_XML_FORMAT_GUI_ENV, reader->getNodeName())) || + ( parent && !wcscmp(IRR_XML_FORMAT_GUI_ELEMENT, reader->getNodeName()))) + { + if (parent) + { + // find node type and create it + core::stringc attrName = reader->getAttributeValue(IRR_XML_FORMAT_GUI_ELEMENT_ATTR_TYPE); + + node = addGUIElement(attrName.c_str(), parent); + + if (!node) + os::Printer::log("Could not create GUI element of unknown type", attrName.c_str()); + } + else + node = this; // root + } + + // read attributes + + while(reader->read()) + { + bool endreached = false; + + switch (reader->getNodeType()) + { + case io::EXN_ELEMENT_END: + if (!wcscmp(IRR_XML_FORMAT_GUI_ELEMENT, reader->getNodeName()) || + !wcscmp(IRR_XML_FORMAT_GUI_ENV, reader->getNodeName())) + { + endreached = true; + } + break; + case io::EXN_ELEMENT: + if (!wcscmp(L"attributes", reader->getNodeName())) + { + // read attributes + io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); + attr->read(reader, true); + + if (node) + node->deserializeAttributes(attr); + + attr->drop(); + } + else + if (!wcscmp(IRR_XML_FORMAT_GUI_ELEMENT, reader->getNodeName()) || + !wcscmp(IRR_XML_FORMAT_GUI_ENV, reader->getNodeName())) + { + readGUIElement(reader, node); + } + else + { + os::Printer::log("Found unknown element in irrlicht GUI file", + core::stringc(reader->getNodeName()).c_str()); + } + + break; + } + + if (endreached) + break; + } +} + + + +//! writes an element +void CGUIEnvironment::writeGUIElement(io::IXMLWriter* writer, IGUIElement* node) +{ + if (!writer || !node ) + return; + + const wchar_t* name = 0; + + // write properties + + io::IAttributes* attr = FileSystem->createEmptyAttributes(); + node->serializeAttributes(attr); + + // all gui elements must have at least one attribute + // if they have nothing then we ignore them. + if (attr->getAttributeCount() > 0) + { + if (node == this) + { + name = IRR_XML_FORMAT_GUI_ENV; + writer->writeElement(name, false); + } + else + { + name = IRR_XML_FORMAT_GUI_ELEMENT; + writer->writeElement(name, false, IRR_XML_FORMAT_GUI_ELEMENT_ATTR_TYPE, + core::stringw(node->getTypeName()).c_str()); + } + + writer->writeLineBreak(); + writer->writeLineBreak(); + + attr->write(writer); + writer->writeLineBreak(); + } + + // write children + + core::list::Iterator it = node->getChildren().begin(); + for (; it != node->getChildren().end(); ++it) + { + if (!(*it)->isSubElement()) + writeGUIElement(writer, (*it)); + } + + // write closing brace if required + if (attr->getAttributeCount() > 0) + { + writer->writeClosingTag(name); + writer->writeLineBreak(); + writer->writeLineBreak(); + } + + attr->drop(); + +} + + +//! Writes attributes of the environment +void CGUIEnvironment::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + IGUISkin* skin = getSkin(); + + if (skin) + { + out->addEnum("Skin",getSkin()->getType(),GUISkinTypeNames); + skin->serializeAttributes(out, options); + } +} + +//! Reads attributes of the environment +void CGUIEnvironment::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + + if (in->existsAttribute("Skin")) + { + IGUISkin *skin = getSkin(); + + EGUI_SKIN_TYPE t = (EGUI_SKIN_TYPE) in->getAttributeAsEnumeration("Skin",GUISkinTypeNames); + if ( !skin || t != skin->getType()) + { + skin = createSkin(t); + setSkin(skin); + skin->drop(); + } + + skin = getSkin(); + + if (skin) + { + skin->deserializeAttributes(in, options); + } + + } + + RelativeRect = AbsoluteRect = + core::rect(core::position2d(0,0), + Driver ? Driver->getScreenSize() : core::dimension2d(0,0)); + +} + + + + +//! adds an button. The returned pointer must not be dropped. +IGUIButton* CGUIEnvironment::addButton(const core::rect& rectangle, IGUIElement* parent, s32 id, const wchar_t* text, const wchar_t *tooltiptext) +{ + IGUIButton* button = new CGUIButton(this, parent ? parent : this, id, rectangle); + if (text) + button->setText(text); + + if ( tooltiptext ) + button->setToolTipText ( tooltiptext ); + + button->drop(); + return button; +} + + +//! adds a window. The returned pointer must not be dropped. +IGUIWindow* CGUIEnvironment::addWindow(const core::rect& rectangle, bool modal, + const wchar_t* text, IGUIElement* parent, s32 id) +{ + parent = parent ? parent : this; + + if (modal) + { + parent = new CGUIModalScreen(this, parent, -1); + parent->drop(); + } + + IGUIWindow* win = new CGUIWindow(this, parent, id, rectangle); + if (text) + win->setText(text); + win->drop(); + + return win; +} +//! adds a modal screen. The returned pointer must not be dropped. +IGUIElement* CGUIEnvironment::addModalScreen(IGUIElement* parent) +{ + parent = parent ? parent : this; + + IGUIElement *win = new CGUIModalScreen(this, parent, -1); + win->drop(); + + return win; +} + +//! Adds a message box. +IGUIWindow* CGUIEnvironment::addMessageBox(const wchar_t* caption, const wchar_t* text, + bool modal, s32 flag, IGUIElement* parent, s32 id) +{ + if (!CurrentSkin) + return 0; + + parent = parent ? parent : this; + + core::rect rect; + core::dimension2d screenDim, msgBoxDim; + + screenDim.Width = parent->getAbsolutePosition().getWidth(); + screenDim.Height = parent->getAbsolutePosition().getHeight(); + msgBoxDim.Width = CurrentSkin->getSize(gui::EGDS_MESSAGE_BOX_WIDTH); + msgBoxDim.Height = CurrentSkin->getSize(gui::EGDS_MESSAGE_BOX_HEIGHT); + + rect.UpperLeftCorner.X = (screenDim.Width - msgBoxDim.Width) / 2; + rect.UpperLeftCorner.Y = (screenDim.Height - msgBoxDim.Height) / 2; + rect.LowerRightCorner.X = rect.UpperLeftCorner.X + msgBoxDim.Width; + rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + msgBoxDim.Height; + + if (modal) + { + parent = new CGUIModalScreen(this, parent, -1); + parent->drop(); + } + + IGUIWindow* win = new CGUIMessageBox(this, caption, text, flag, + parent, id, rect); + + win->drop(); + return win; +} + + +//! adds a scrollbar. The returned pointer must not be dropped. +IGUIScrollBar* CGUIEnvironment::addScrollBar(bool horizontal, const core::rect& rectangle, IGUIElement* parent, s32 id) +{ + IGUIScrollBar* bar = new CGUIScrollBar(horizontal, this, parent ? parent : this, id, rectangle); + bar->drop(); + return bar; +} + + +//! Adds an image element. +IGUIImage* CGUIEnvironment::addImage(video::ITexture* image, core::position2d pos, + bool useAlphaChannel, IGUIElement* parent, s32 id, const wchar_t* text) +{ + core::dimension2d sz(0,0); + if (image) + sz = image->getOriginalSize(); + + IGUIImage* img = new CGUIImage(this, parent ? parent : this, + id, core::rect(pos, sz)); + + if (text) + img->setText(text); + + if (useAlphaChannel) + img->setUseAlphaChannel(true); + + if (image) + img->setImage(image); + + img->drop(); + return img; +} + + +//! adds an image. The returned pointer must not be dropped. +IGUIImage* CGUIEnvironment::addImage(const core::rect& rectangle, IGUIElement* parent, s32 id, const wchar_t* text) +{ + IGUIImage* img = new CGUIImage(this, parent ? parent : this, + id, rectangle); + + if (text) + img->setText(text); + + img->drop(); + return img; +} + + +//! adds an mesh viewer. The returned pointer must not be dropped. +IGUIMeshViewer* CGUIEnvironment::addMeshViewer(const core::rect& rectangle, IGUIElement* parent, s32 id, const wchar_t* text) +{ + IGUIMeshViewer* v = new CGUIMeshViewer(this, parent ? parent : this, + id, rectangle); + + if (text) + v->setText(text); + + v->drop(); + return v; +} + + +//! adds a checkbox +IGUICheckBox* CGUIEnvironment::addCheckBox(bool checked, const core::rect& rectangle, IGUIElement* parent, s32 id, const wchar_t* text) +{ + IGUICheckBox* b = new CGUICheckBox(checked, this, + parent ? parent : this , id , rectangle); + + if (text) + b->setText(text); + + b->drop(); + return b; +} + + + +//! adds a list box +IGUIListBox* CGUIEnvironment::addListBox(const core::rect& rectangle, + IGUIElement* parent, s32 id, + bool drawBackground) +{ + IGUIListBox* b = new CGUIListBox(this, parent ? parent : this, id, rectangle, + true, drawBackground, false); + + if (getBuiltInFont() && getBuiltInFont()->getType() == EGFT_BITMAP) + b->setSpriteBank( ((IGUIFontBitmap*)getBuiltInFont())->getSpriteBank()); + + b->drop(); + return b; + +} + + + +//! adds a file open dialog. The returned pointer must not be dropped. +IGUIFileOpenDialog* CGUIEnvironment::addFileOpenDialog(const wchar_t* title, + bool modal, + IGUIElement* parent, s32 id) +{ + parent = parent ? parent : this; + + if (modal) + { + parent = new CGUIModalScreen(this, parent, -1); + parent->drop(); + } + + IGUIFileOpenDialog* d = new CGUIFileOpenDialog(title, this, parent, id); + + d->drop(); + return d; +} + + +//! adds a color select dialog. The returned pointer must not be dropped. +IGUIColorSelectDialog* CGUIEnvironment::addColorSelectDialog(const wchar_t* title, + bool modal, + IGUIElement* parent, s32 id) +{ + parent = parent ? parent : this; + + if (modal) + { + parent = new CGUIModalScreen(this, parent, -1); + parent->drop(); + } + + IGUIColorSelectDialog* d = new CGUIColorSelectDialog( title, + this, parent, id); + + d->drop(); + return d; +} + + + +//! adds a static text. The returned pointer must not be dropped. +IGUIStaticText* CGUIEnvironment::addStaticText(const wchar_t* text, + const core::rect& rectangle, + bool border, + bool wordWrap, + IGUIElement* parent, s32 id, + bool background) +{ + IGUIStaticText* d = new CGUIStaticText(text, border, this, + parent ? parent : this, id, rectangle, background); + + d->setWordWrap(wordWrap); + d->drop(); + + return d; +} + + + +//! Adds an edit box. The returned pointer must not be dropped. +IGUIEditBox* CGUIEnvironment::addEditBox(const wchar_t* text, + const core::rect& rectangle, + bool border, IGUIElement* parent, + s32 id) +{ + IGUIEditBox* d = new CGUIEditBox(text, border, this, + parent ? parent : this, id, rectangle, Operator); + + d->drop(); + return d; +} + +//! Adds a tab control to the environment. +IGUITabControl* CGUIEnvironment::addTabControl(const core::rect& rectangle, + IGUIElement* parent, bool fillbackground, bool border, s32 id) +{ + IGUITabControl* t = new CGUITabControl(this, parent ? parent : this, + rectangle, fillbackground, border, id); + t->drop(); + return t; +} + + +//! Adds tab to the environment. +IGUITab* CGUIEnvironment::addTab(const core::rect& rectangle, + IGUIElement* parent, s32 id) +{ + IGUITab* t = new CGUITab(-1, this, parent ? parent : this, + rectangle, id); + t->drop(); + return t; +} + + +//! Adds a context menu to the environment. +IGUIContextMenu* CGUIEnvironment::addContextMenu(const core::rect& rectangle, + IGUIElement* parent, s32 id) +{ + IGUIContextMenu* c = new CGUIContextMenu(this, + parent ? parent : this, id, rectangle, true); + c->drop(); + return c; +} + + +//! Adds a menu to the environment. +IGUIContextMenu* CGUIEnvironment::addMenu(IGUIElement* parent, s32 id) +{ + if (!parent) + parent = this; + + IGUIContextMenu* c = new CGUIMenu(this, + parent, id, core::rect(0,0, + parent->getAbsolutePosition().getWidth(), + parent->getAbsolutePosition().getHeight())); + + c->drop(); + return c; +} + +//! Adds a toolbar to the environment. It is like a menu is always placed on top +//! in its parent, and contains buttons. +IGUIToolBar* CGUIEnvironment::addToolBar(IGUIElement* parent, s32 id) +{ + if (!parent) + parent = this; + + IGUIToolBar* b = new CGUIToolBar(this, parent, id, core::rect(0,0,10,10)); + b->drop(); + return b; +} + + + +//! Adds an element for fading in or out. +IGUIInOutFader* CGUIEnvironment::addInOutFader(const core::rect* rectangle, IGUIElement* parent, s32 id) +{ + core::rect rect; + + if (rectangle) + rect = *rectangle; + else + if (Driver) + rect = core::rect(core::position2d(0,0), Driver->getScreenSize()); + + if (!parent) + parent = this; + + IGUIInOutFader* fader = new CGUIInOutFader(this, parent, id, rect); + fader->drop(); + return fader; +} + + +//! Adds a combo box to the environment. +IGUIComboBox* CGUIEnvironment::addComboBox(const core::rect& rectangle, + IGUIElement* parent, s32 id) +{ + IGUIComboBox* t = new CGUIComboBox(this, parent ? parent : this, + id, rectangle); + t->drop(); + return t; + +} + + + +//! returns the font +IGUIFont* CGUIEnvironment::getFont(const c8* filename) +{ + // search existing font + + SFont f; + IGUIFont* ifont=0; + if (!filename) + f.Filename = ""; + else + f.Filename = filename; + + f.Filename.make_lower(); + + s32 index = Fonts.binary_search(f); + if (index != -1) + return Fonts[index].Font; + + // font doesn't exist, attempt to load it + + // does the file exist? + + if (!FileSystem->existFile(f.Filename.c_str())) + { + os::Printer::log("Could not load font because the file does not exist", f.Filename.c_str(), ELL_ERROR); + return 0; + } + + io::IXMLReader *xml = FileSystem->createXMLReader(f.Filename.c_str()); + if (xml) + { + // this is an XML font, but we need to know what type + EGUI_FONT_TYPE t = EGFT_CUSTOM; + + bool found=false; + while(xml->read() && !found) + { + if (xml->getNodeType() == io::EXN_ELEMENT) + { + if (core::stringw(L"font") == xml->getNodeName()) + { + if (core::stringw(L"vector") == xml->getAttributeValue(L"type")) + { + t = EGFT_VECTOR; + found=true; + } + else if (core::stringw(L"bitmap") == xml->getAttributeValue(L"type")) + { + t = EGFT_BITMAP; + found=true; + } + else found=true; + } + } + } + + if (t==EGFT_BITMAP) + { + CGUIFont* font = new CGUIFont(this, f.Filename.c_str()); + ifont = (IGUIFont*)font; + if (!font->load(xml)) + { + font->drop(); + font = 0; + ifont = 0; + } + } + else if (t==EGFT_VECTOR) + { + // todo: vector fonts + + //CGUIFontVector* font = new CGUIFontVector(Driver); + //ifont = (IGUIFont*)font; + //if (!font->load(xml)) + } + xml->drop(); + } + + + if (!ifont) + { + + CGUIFont* font = new CGUIFont(this, f.Filename.c_str()); + ifont = (IGUIFont*)font; + if (!font->load(f.Filename.c_str())) + { + font->drop(); + return 0; + } + } + + // add to fonts. + + f.Font = ifont; + Fonts.push_back(f); + + return ifont; +} + +IGUISpriteBank* CGUIEnvironment::getSpriteBank(const c8* filename) +{ + // search for the file name + + SSpriteBank b; + if (!filename) + b.Filename = ""; + else + b.Filename = filename; + + b.Filename.make_lower(); + + s32 index = Banks.binary_search(b); + if (index != -1) + return Banks[index].Bank; + + // we don't have this sprite bank, we should load it + + if (!FileSystem->existFile(b.Filename.c_str())) + { + os::Printer::log("Could not load sprite bank because the file does not exist", filename, ELL_ERROR); + return 0; + } + + // todo: load it! + + return 0; + +} + +IGUISpriteBank* CGUIEnvironment::addEmptySpriteBank(const c8 *name) +{ + // no duplicate names allowed + + SSpriteBank b; + if (!name) + b.Filename = ""; + else + b.Filename = name; + + s32 index = Banks.binary_search(b); + if (index != -1) + return 0; + + + // create a new sprite bank + + b.Bank = new CGUISpriteBank(this); + + Banks.push_back(b); + + return b.Bank; + +} + +//! returns default font +IGUIFont* CGUIEnvironment::getBuiltInFont() +{ + if (Fonts.empty()) + return 0; + + return Fonts[0].Font; +} + + + +//! Returns the root gui element. +IGUIElement* CGUIEnvironment::getRootGUIElement() +{ + return this; +} + + + +//! creates an GUI Environment +IGUIEnvironment* createGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* Driver, + IOSOperator* op) +{ + return new CGUIEnvironment(fs, Driver, op); +} + + +} // end namespace gui +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CGUIEnvironment.h b/src/dep/src/irrlicht/CGUIEnvironment.h index 9bdde11..e2c3d6a 100644 --- a/src/dep/src/irrlicht/CGUIEnvironment.h +++ b/src/dep/src/irrlicht/CGUIEnvironment.h @@ -1,265 +1,265 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_ENVIRNMENT_H_INCLUDED__ -#define __C_GUI_ENVIRNMENT_H_INCLUDED__ - -#include "IGUIEnvironment.h" -#include "IGUIElement.h" -#include "irrArray.h" -#include "IFileSystem.h" -#include "IOSOperator.h" - -namespace irr -{ -namespace io -{ - class IXMLWriter; -} -namespace gui -{ - -class CGUIEnvironment : public IGUIEnvironment, public IGUIElement -{ -public: - - //! constructor - CGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* driver, IOSOperator* op); - - //! destructor - virtual ~CGUIEnvironment(); - - //! draws all gui elements - virtual void drawAll(); - - //! returns the current video driver - virtual video::IVideoDriver* getVideoDriver(); - - //! returns the current video driver - virtual io::IFileSystem* getFileSystem(); - - //! posts an input event to the environment - virtual bool postEventFromUser(SEvent event); - - //! This sets a new event receiver for gui events. Usually you do not have to - //! use this method, it is used by the internal engine. - virtual void setUserEventReceiver(IEventReceiver* evr); - - //! removes all elements from the environment - virtual void clear(); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! returns the current gui skin - virtual IGUISkin* getSkin(); - - //! Sets a new GUI Skin - virtual void setSkin(IGUISkin* skin); - - //! Creates a new GUI Skin based on a template. - /** \return Returns a pointer to the created skin. - If you no longer need the skin, you should call IGUISkin::drop(). - See IUnknown::drop() for more information. */ - virtual IGUISkin* createSkin(EGUI_SKIN_TYPE type); - - //! returns the font - virtual IGUIFont* getFont(const c8* filename); - - //! returns the sprite bank - virtual IGUISpriteBank* getSpriteBank(const c8* filename); - - //! returns the sprite bank - virtual IGUISpriteBank* addEmptySpriteBank(const c8* name); - - //! adds an button. The returned pointer must not be dropped. - virtual IGUIButton* addButton(const core::rect& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0,const wchar_t* tooltiptext = 0); - - //! adds a window. The returned pointer must not be dropped. - virtual IGUIWindow* addWindow(const core::rect& rectangle, bool modal = false, - const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1); - - //! adds a modal screen. The returned pointer must not be dropped. - virtual IGUIElement* addModalScreen(IGUIElement* parent); - - //! Adds a message box. - virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0, - bool modal = true, s32 flag = EMBF_OK, IGUIElement* parent=0, s32 id=-1); - - //! adds a scrollbar. The returned pointer must not be dropped. - virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect& rectangle, IGUIElement* parent=0, s32 id=-1); - - //! Adds an image element. - virtual IGUIImage* addImage(video::ITexture* image, core::position2d pos, - bool useAlphaChannel=true, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0); - - //! adds an image. The returned pointer must not be dropped. - virtual IGUIImage* addImage(const core::rect& rectangle, - IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0); - - //! adds a checkbox - virtual IGUICheckBox* addCheckBox(bool checked, const core::rect& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0); - - //! adds a list box - virtual IGUIListBox* addListBox(const core::rect& rectangle, - IGUIElement* parent=0, s32 id=-1, bool drawBackground=false); - - //! adds an mesh viewer. The returned pointer must not be dropped. - virtual IGUIMeshViewer* addMeshViewer(const core::rect& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0); - - //! Adds a file open dialog. - virtual IGUIFileOpenDialog* addFileOpenDialog(const wchar_t* title = 0, bool modal=true, IGUIElement* parent=0, s32 id=-1); - virtual IGUIColorSelectDialog* addColorSelectDialog(const wchar_t* title = 0, bool modal=true, IGUIElement* parent=0, s32 id=-1); - - //! adds a static text. The returned pointer must not be dropped. - virtual IGUIStaticText* addStaticText(const wchar_t* text, const core::rect& rectangle, - bool border=false, bool wordWrap=true, IGUIElement* parent=0, s32 id=-1, bool drawBackground = false); - - //! Adds an edit box. The returned pointer must not be dropped. - virtual IGUIEditBox* addEditBox(const wchar_t* text, const core::rect& rectangle, - bool border=false, IGUIElement* parent=0, s32 id=-1); - - //! Adds a tab control to the environment. - virtual IGUITabControl* addTabControl(const core::rect& rectangle, - IGUIElement* parent=0, bool fillbackground=false, bool border=true, s32 id=-1); - - //! Adds tab to the environment. - virtual IGUITab* addTab(const core::rect& rectangle, - IGUIElement* parent=0, s32 id=-1); - - //! Adds a context menu to the environment. - virtual IGUIContextMenu* addContextMenu(const core::rect& rectangle, - IGUIElement* parent=0, s32 id=-1); - - //! Adds a menu to the environment. - virtual IGUIContextMenu* addMenu(IGUIElement* parent=0, s32 id=-1); - - //! Adds a toolbar to the environment. It is like a menu is always placed on top - //! in its parent, and contains buttons. - virtual IGUIToolBar* addToolBar(IGUIElement* parent=0, s32 id=-1); - - //! Adds a combo box to the environment. - virtual IGUIComboBox* addComboBox(const core::rect& rectangle, - IGUIElement* parent=0, s32 id=-1); - - //! sets the focus to an element - virtual void setFocus(IGUIElement* element); - - //! removes the focus from an element - virtual void removeFocus(IGUIElement* element); - - //! Returns if the element has focus - virtual bool hasFocus(IGUIElement* element); - - //! Returns the element with the focus - virtual IGUIElement* getFocus(); - - //! returns default font - virtual IGUIFont* getBuiltInFont(); - - //! Adds an element for fading in or out. - virtual IGUIInOutFader* addInOutFader(const core::rect* rectangle=0, IGUIElement* parent=0, s32 id=-1); - - //! Returns the root gui element. - virtual IGUIElement* getRootGUIElement(); - - virtual void OnPostRender( u32 time ); - - //! Returns the default element factory which can create all built in elements - virtual IGUIElementFactory* getDefaultGUIElementFactory(); - - //! Adds an element factory to the gui environment. - /** Use this to extend the gui environment with new element types which it should be - able to create automaticly, for example when loading data from xml files. */ - virtual void registerGUIElementFactory(IGUIElementFactory* factoryToAdd); - - //! Returns amount of registered scene node factories. - virtual s32 getRegisteredGUIElementFactoryCount(); - - //! Returns a scene node factory by index - virtual IGUIElementFactory* getGUIElementFactory(s32 index); - - //! Adds a GUI Element by its name - virtual IGUIElement* addGUIElement(const c8* elementName, IGUIElement* parent=0); - - //! Saves the current gui into a file. - //! \param filename: Name of the file. - virtual bool saveGUI(const c8* filename); - - //! Saves the current gui into a file. - virtual bool saveGUI(io::IWriteFile* file); - - //! Loads the gui. Note that the current gui is not cleared before. - //! \param filename: Name of the file . - virtual bool loadGUI(const c8* filename); - - //! Loads the gui. Note that the current gui is not cleared before. - virtual bool loadGUI(io::IReadFile* file); - - //! Writes attributes of the environment - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the environment. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! writes an element - virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node); - - //! reads an element - virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* parent); - - -private: - - struct SFont - { - core::stringc Filename; - IGUIFont* Font; - - bool operator < (const SFont& other) const - { - return (Filename < other.Filename); - } - }; - - struct SSpriteBank - { - core::stringc Filename; - IGUISpriteBank* Bank; - - bool operator < (const SSpriteBank& other) const - { - return (Filename < other.Filename); - } - }; - - struct SToolTip - { - u32 LastTime; - u32 LaunchTime; - IGUIStaticText* Element; - }; - SToolTip ToolTip; - void updateHoveredElement(core::position2d mousePos); - - void loadBuiltInFont(); - - core::array GUIElementFactoryList; - - core::array Fonts; - core::array Banks; - video::IVideoDriver* Driver; - IGUIElement* Hovered; - IGUIElement* Focus; - IGUISkin* CurrentSkin; - io::IFileSystem* FileSystem; - IEventReceiver* UserReceiver; - IOSOperator* Operator; -}; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_ENVIRNMENT_H_INCLUDED__ +#define __C_GUI_ENVIRNMENT_H_INCLUDED__ + +#include "IGUIEnvironment.h" +#include "IGUIElement.h" +#include "irrArray.h" +#include "IFileSystem.h" +#include "IOSOperator.h" + +namespace irr +{ +namespace io +{ + class IXMLWriter; +} +namespace gui +{ + +class CGUIEnvironment : public IGUIEnvironment, public IGUIElement +{ +public: + + //! constructor + CGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* driver, IOSOperator* op); + + //! destructor + virtual ~CGUIEnvironment(); + + //! draws all gui elements + virtual void drawAll(); + + //! returns the current video driver + virtual video::IVideoDriver* getVideoDriver(); + + //! returns the current video driver + virtual io::IFileSystem* getFileSystem(); + + //! posts an input event to the environment + virtual bool postEventFromUser(SEvent event); + + //! This sets a new event receiver for gui events. Usually you do not have to + //! use this method, it is used by the internal engine. + virtual void setUserEventReceiver(IEventReceiver* evr); + + //! removes all elements from the environment + virtual void clear(); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! returns the current gui skin + virtual IGUISkin* getSkin(); + + //! Sets a new GUI Skin + virtual void setSkin(IGUISkin* skin); + + //! Creates a new GUI Skin based on a template. + /** \return Returns a pointer to the created skin. + If you no longer need the skin, you should call IGUISkin::drop(). + See IUnknown::drop() for more information. */ + virtual IGUISkin* createSkin(EGUI_SKIN_TYPE type); + + //! returns the font + virtual IGUIFont* getFont(const c8* filename); + + //! returns the sprite bank + virtual IGUISpriteBank* getSpriteBank(const c8* filename); + + //! returns the sprite bank + virtual IGUISpriteBank* addEmptySpriteBank(const c8* name); + + //! adds an button. The returned pointer must not be dropped. + virtual IGUIButton* addButton(const core::rect& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0,const wchar_t* tooltiptext = 0); + + //! adds a window. The returned pointer must not be dropped. + virtual IGUIWindow* addWindow(const core::rect& rectangle, bool modal = false, + const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1); + + //! adds a modal screen. The returned pointer must not be dropped. + virtual IGUIElement* addModalScreen(IGUIElement* parent); + + //! Adds a message box. + virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0, + bool modal = true, s32 flag = EMBF_OK, IGUIElement* parent=0, s32 id=-1); + + //! adds a scrollbar. The returned pointer must not be dropped. + virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect& rectangle, IGUIElement* parent=0, s32 id=-1); + + //! Adds an image element. + virtual IGUIImage* addImage(video::ITexture* image, core::position2d pos, + bool useAlphaChannel=true, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0); + + //! adds an image. The returned pointer must not be dropped. + virtual IGUIImage* addImage(const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0); + + //! adds a checkbox + virtual IGUICheckBox* addCheckBox(bool checked, const core::rect& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0); + + //! adds a list box + virtual IGUIListBox* addListBox(const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1, bool drawBackground=false); + + //! adds an mesh viewer. The returned pointer must not be dropped. + virtual IGUIMeshViewer* addMeshViewer(const core::rect& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0); + + //! Adds a file open dialog. + virtual IGUIFileOpenDialog* addFileOpenDialog(const wchar_t* title = 0, bool modal=true, IGUIElement* parent=0, s32 id=-1); + virtual IGUIColorSelectDialog* addColorSelectDialog(const wchar_t* title = 0, bool modal=true, IGUIElement* parent=0, s32 id=-1); + + //! adds a static text. The returned pointer must not be dropped. + virtual IGUIStaticText* addStaticText(const wchar_t* text, const core::rect& rectangle, + bool border=false, bool wordWrap=true, IGUIElement* parent=0, s32 id=-1, bool drawBackground = false); + + //! Adds an edit box. The returned pointer must not be dropped. + virtual IGUIEditBox* addEditBox(const wchar_t* text, const core::rect& rectangle, + bool border=false, IGUIElement* parent=0, s32 id=-1); + + //! Adds a tab control to the environment. + virtual IGUITabControl* addTabControl(const core::rect& rectangle, + IGUIElement* parent=0, bool fillbackground=false, bool border=true, s32 id=-1); + + //! Adds tab to the environment. + virtual IGUITab* addTab(const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1); + + //! Adds a context menu to the environment. + virtual IGUIContextMenu* addContextMenu(const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1); + + //! Adds a menu to the environment. + virtual IGUIContextMenu* addMenu(IGUIElement* parent=0, s32 id=-1); + + //! Adds a toolbar to the environment. It is like a menu is always placed on top + //! in its parent, and contains buttons. + virtual IGUIToolBar* addToolBar(IGUIElement* parent=0, s32 id=-1); + + //! Adds a combo box to the environment. + virtual IGUIComboBox* addComboBox(const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1); + + //! sets the focus to an element + virtual void setFocus(IGUIElement* element); + + //! removes the focus from an element + virtual void removeFocus(IGUIElement* element); + + //! Returns if the element has focus + virtual bool hasFocus(IGUIElement* element); + + //! Returns the element with the focus + virtual IGUIElement* getFocus(); + + //! returns default font + virtual IGUIFont* getBuiltInFont(); + + //! Adds an element for fading in or out. + virtual IGUIInOutFader* addInOutFader(const core::rect* rectangle=0, IGUIElement* parent=0, s32 id=-1); + + //! Returns the root gui element. + virtual IGUIElement* getRootGUIElement(); + + virtual void OnPostRender( u32 time ); + + //! Returns the default element factory which can create all built in elements + virtual IGUIElementFactory* getDefaultGUIElementFactory(); + + //! Adds an element factory to the gui environment. + /** Use this to extend the gui environment with new element types which it should be + able to create automaticly, for example when loading data from xml files. */ + virtual void registerGUIElementFactory(IGUIElementFactory* factoryToAdd); + + //! Returns amount of registered scene node factories. + virtual s32 getRegisteredGUIElementFactoryCount(); + + //! Returns a scene node factory by index + virtual IGUIElementFactory* getGUIElementFactory(s32 index); + + //! Adds a GUI Element by its name + virtual IGUIElement* addGUIElement(const c8* elementName, IGUIElement* parent=0); + + //! Saves the current gui into a file. + //! \param filename: Name of the file. + virtual bool saveGUI(const c8* filename); + + //! Saves the current gui into a file. + virtual bool saveGUI(io::IWriteFile* file); + + //! Loads the gui. Note that the current gui is not cleared before. + //! \param filename: Name of the file . + virtual bool loadGUI(const c8* filename); + + //! Loads the gui. Note that the current gui is not cleared before. + virtual bool loadGUI(io::IReadFile* file); + + //! Writes attributes of the environment + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the environment. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + //! writes an element + virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node); + + //! reads an element + virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* parent); + + +private: + + struct SFont + { + core::stringc Filename; + IGUIFont* Font; + + bool operator < (const SFont& other) const + { + return (Filename < other.Filename); + } + }; + + struct SSpriteBank + { + core::stringc Filename; + IGUISpriteBank* Bank; + + bool operator < (const SSpriteBank& other) const + { + return (Filename < other.Filename); + } + }; + + struct SToolTip + { + u32 LastTime; + u32 LaunchTime; + IGUIStaticText* Element; + }; + SToolTip ToolTip; + void updateHoveredElement(core::position2d mousePos); + + void loadBuiltInFont(); + + core::array GUIElementFactoryList; + + core::array Fonts; + core::array Banks; + video::IVideoDriver* Driver; + IGUIElement* Hovered; + IGUIElement* Focus; + IGUISkin* CurrentSkin; + io::IFileSystem* FileSystem; + IEventReceiver* UserReceiver; + IOSOperator* Operator; +}; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIFileOpenDialog.cpp b/src/dep/src/irrlicht/CGUIFileOpenDialog.cpp index 96c1b0d..ff432e3 100644 --- a/src/dep/src/irrlicht/CGUIFileOpenDialog.cpp +++ b/src/dep/src/irrlicht/CGUIFileOpenDialog.cpp @@ -1,311 +1,311 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIFileOpenDialog.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIButton.h" -#include "IGUIStaticText.h" -#include "IGUIFont.h" -#include "IGUIFontBitmap.h" -#include "IFileList.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -const s32 FOD_WIDTH = 350; -const s32 FOD_HEIGHT = 250; - - -//! constructor -CGUIFileOpenDialog::CGUIFileOpenDialog(const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id) -: IGUIFileOpenDialog(environment, parent, id, - core::rect((parent->getAbsolutePosition().getWidth()-FOD_WIDTH)/2, - (parent->getAbsolutePosition().getHeight()-FOD_HEIGHT)/2, - (parent->getAbsolutePosition().getWidth()-FOD_WIDTH)/2+FOD_WIDTH, - (parent->getAbsolutePosition().getHeight()-FOD_HEIGHT)/2+FOD_HEIGHT)), - Dragging(false), FileNameText(0), FileList(0) -{ - #ifdef _DEBUG - IGUIElement::setDebugName("CGUIFileOpenDialog"); - #endif - - Text = title; - - IGUISkin* skin = Environment->getSkin(); - IGUISpriteBank* sprites = 0; - video::SColor color(255,255,255,255); - if (skin) - { - sprites = skin->getSpriteBank(); - color = skin->getColor(EGDC_WINDOW_SYMBOL); - } - - s32 buttonw = environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH); - s32 posx = RelativeRect.getWidth() - buttonw - 4; - - CloseButton = Environment->addButton(core::rect(posx, 3, posx + buttonw, 3 + buttonw), this, -1, - L"", skin ? skin->getDefaultText(EGDT_MSG_BOX_OK) : L"Close"); - CloseButton->setSubElement(true); - if (sprites) - { - CloseButton->setSpriteBank(sprites); - CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color); - CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color); - } - CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - CloseButton->grab(); - - OKButton = Environment->addButton( - core::rect(RelativeRect.getWidth()-80, 30, RelativeRect.getWidth()-10, 50), - this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_OK) : L"OK"); - OKButton->setSubElement(true); - OKButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - OKButton->grab(); - - CancelButton = Environment->addButton( - core::rect(RelativeRect.getWidth()-80, 55, RelativeRect.getWidth()-10, 75), - this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_CANCEL) : L"Cancel"); - CancelButton->setSubElement(true); - CancelButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - CancelButton->grab(); - - FileBox = Environment->addListBox(core::rect(10, 55, RelativeRect.getWidth()-90, 230), this, -1, true); - FileBox->setSubElement(true); - FileBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - FileBox->grab(); - - FileNameText = Environment->addStaticText(0, core::rect(10, 30, RelativeRect.getWidth()-90, 50), true, false, this); - FileNameText->setSubElement(true); - FileNameText->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - FileNameText->grab(); - - FileSystem = Environment->getFileSystem(); - - if (FileSystem) - FileSystem->grab(); - - fillListBox(); -} - - - -//! destructor -CGUIFileOpenDialog::~CGUIFileOpenDialog() -{ - if (CloseButton) - CloseButton->drop(); - - if (OKButton) - OKButton->drop(); - - if (CancelButton) - CancelButton->drop(); - - if (FileBox) - FileBox->drop(); - - if (FileNameText) - FileNameText->drop(); - - if (FileSystem) - FileSystem->drop(); - - if (FileList) - FileList->drop(); -} - - -//! returns the filename of the selected file. Returns NULL, if no file was selected. -const wchar_t* CGUIFileOpenDialog::getFilename() -{ - return FileName.c_str(); -} - - - -//! called if an event happened. -bool CGUIFileOpenDialog::OnEvent(SEvent event) -{ - switch(event.EventType) - { - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case EGET_ELEMENT_FOCUS_LOST: - Dragging = false; - break; - case EGET_BUTTON_CLICKED: - if (event.GUIEvent.Caller == CloseButton || - event.GUIEvent.Caller == CancelButton) - { - sendCancelEvent(); - remove(); - return true; - } - else - if (event.GUIEvent.Caller == OKButton && FileName != L"") - { - sendSelectedEvent(); - remove(); - return true; - } - break; - - case EGET_LISTBOX_CHANGED: - { - s32 selected = FileBox->getSelected(); - if (FileList && FileSystem) - { - if (FileList->isDirectory(selected)) - FileName = L""; - else - FileName = FileList->getFullFileName(selected); - } - } - break; - - case EGET_LISTBOX_SELECTED_AGAIN: - { - s32 selected = FileBox->getSelected(); - if (FileList && FileSystem) - { - if (FileList->isDirectory(selected)) - { - FileSystem->changeWorkingDirectoryTo(FileList->getFileName(selected)); - fillListBox(); - FileName = L""; - } - else - { - FileName = FileList->getFullFileName(selected); - return true; - } - } - } - break; - } - break; - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_PRESSED_DOWN: - DragStart.X = event.MouseInput.X; - DragStart.Y = event.MouseInput.Y; - Dragging = true; - Environment->setFocus(this); - return true; - case EMIE_LMOUSE_LEFT_UP: - Dragging = false; - Environment->removeFocus(this); - return true; - case EMIE_MOUSE_MOVED: - if (Dragging) - { - // gui window should not be dragged outside its parent - if (Parent) - if (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 || - event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 || - event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 || - event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1) - - return true; - - move(core::position2d(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y)); - DragStart.X = event.MouseInput.X; - DragStart.Y = event.MouseInput.Y; - return true; - } - break; - } - } - - return Parent ? Parent->OnEvent(event) : false; -} - - -//! draws the element and its children -void CGUIFileOpenDialog::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - - core::rect rect = AbsoluteRect; - - rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER), - rect, &AbsoluteClippingRect); - - if (Text.size()) - { - rect.UpperLeftCorner.X += 2; - rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; - - IGUIFont* font = skin->getFont(); - if (font) - font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true, - &AbsoluteClippingRect); - } - - IGUIElement::draw(); -} - - -//! fills the listbox with files. -void CGUIFileOpenDialog::fillListBox() -{ - IGUISkin *skin = Environment->getSkin(); - - if (!FileSystem || !FileBox || !skin) - return; - - if (FileList) - FileList->drop(); - - FileBox->clear(); - - FileList = FileSystem->createFileList(); - core::stringw s; - - for (s32 i=0; igetFileCount(); ++i) - { - s = FileList->getFileName(i); - FileBox->addItem(s.c_str(), skin->getIcon(FileList->isDirectory(i) ? EGDI_DIRECTORY : EGDI_FILE)); - } - - if (FileNameText) - { - s = FileSystem->getWorkingDirectory(); - FileNameText->setText(s.c_str()); - } -} - - -//! sends the event that the file has been selected. -void CGUIFileOpenDialog::sendSelectedEvent() -{ - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.EventType = EGET_FILE_SELECTED; - Parent->OnEvent(event); -} - -//! sends the event that the file choose process has been canceld -void CGUIFileOpenDialog::sendCancelEvent() -{ - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.EventType = EGET_FILE_CHOOSE_DIALOG_CANCELLED; - Parent->OnEvent(event); -} - -} // end namespace gui -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIFileOpenDialog.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUIButton.h" +#include "IGUIStaticText.h" +#include "IGUIFont.h" +#include "IGUIFontBitmap.h" +#include "IFileList.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + +const s32 FOD_WIDTH = 350; +const s32 FOD_HEIGHT = 250; + + +//! constructor +CGUIFileOpenDialog::CGUIFileOpenDialog(const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id) +: IGUIFileOpenDialog(environment, parent, id, + core::rect((parent->getAbsolutePosition().getWidth()-FOD_WIDTH)/2, + (parent->getAbsolutePosition().getHeight()-FOD_HEIGHT)/2, + (parent->getAbsolutePosition().getWidth()-FOD_WIDTH)/2+FOD_WIDTH, + (parent->getAbsolutePosition().getHeight()-FOD_HEIGHT)/2+FOD_HEIGHT)), + Dragging(false), FileNameText(0), FileList(0) +{ + #ifdef _DEBUG + IGUIElement::setDebugName("CGUIFileOpenDialog"); + #endif + + Text = title; + + IGUISkin* skin = Environment->getSkin(); + IGUISpriteBank* sprites = 0; + video::SColor color(255,255,255,255); + if (skin) + { + sprites = skin->getSpriteBank(); + color = skin->getColor(EGDC_WINDOW_SYMBOL); + } + + s32 buttonw = environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH); + s32 posx = RelativeRect.getWidth() - buttonw - 4; + + CloseButton = Environment->addButton(core::rect(posx, 3, posx + buttonw, 3 + buttonw), this, -1, + L"", skin ? skin->getDefaultText(EGDT_MSG_BOX_OK) : L"Close"); + CloseButton->setSubElement(true); + if (sprites) + { + CloseButton->setSpriteBank(sprites); + CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color); + CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color); + } + CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + CloseButton->grab(); + + OKButton = Environment->addButton( + core::rect(RelativeRect.getWidth()-80, 30, RelativeRect.getWidth()-10, 50), + this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_OK) : L"OK"); + OKButton->setSubElement(true); + OKButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + OKButton->grab(); + + CancelButton = Environment->addButton( + core::rect(RelativeRect.getWidth()-80, 55, RelativeRect.getWidth()-10, 75), + this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_CANCEL) : L"Cancel"); + CancelButton->setSubElement(true); + CancelButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + CancelButton->grab(); + + FileBox = Environment->addListBox(core::rect(10, 55, RelativeRect.getWidth()-90, 230), this, -1, true); + FileBox->setSubElement(true); + FileBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + FileBox->grab(); + + FileNameText = Environment->addStaticText(0, core::rect(10, 30, RelativeRect.getWidth()-90, 50), true, false, this); + FileNameText->setSubElement(true); + FileNameText->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + FileNameText->grab(); + + FileSystem = Environment->getFileSystem(); + + if (FileSystem) + FileSystem->grab(); + + fillListBox(); +} + + + +//! destructor +CGUIFileOpenDialog::~CGUIFileOpenDialog() +{ + if (CloseButton) + CloseButton->drop(); + + if (OKButton) + OKButton->drop(); + + if (CancelButton) + CancelButton->drop(); + + if (FileBox) + FileBox->drop(); + + if (FileNameText) + FileNameText->drop(); + + if (FileSystem) + FileSystem->drop(); + + if (FileList) + FileList->drop(); +} + + +//! returns the filename of the selected file. Returns NULL, if no file was selected. +const wchar_t* CGUIFileOpenDialog::getFilename() +{ + return FileName.c_str(); +} + + + +//! called if an event happened. +bool CGUIFileOpenDialog::OnEvent(SEvent event) +{ + switch(event.EventType) + { + case EET_GUI_EVENT: + switch(event.GUIEvent.EventType) + { + case EGET_ELEMENT_FOCUS_LOST: + Dragging = false; + break; + case EGET_BUTTON_CLICKED: + if (event.GUIEvent.Caller == CloseButton || + event.GUIEvent.Caller == CancelButton) + { + sendCancelEvent(); + remove(); + return true; + } + else + if (event.GUIEvent.Caller == OKButton && FileName != L"") + { + sendSelectedEvent(); + remove(); + return true; + } + break; + + case EGET_LISTBOX_CHANGED: + { + s32 selected = FileBox->getSelected(); + if (FileList && FileSystem) + { + if (FileList->isDirectory(selected)) + FileName = L""; + else + FileName = FileList->getFullFileName(selected); + } + } + break; + + case EGET_LISTBOX_SELECTED_AGAIN: + { + s32 selected = FileBox->getSelected(); + if (FileList && FileSystem) + { + if (FileList->isDirectory(selected)) + { + FileSystem->changeWorkingDirectoryTo(FileList->getFileName(selected)); + fillListBox(); + FileName = L""; + } + else + { + FileName = FileList->getFullFileName(selected); + return true; + } + } + } + break; + } + break; + case EET_MOUSE_INPUT_EVENT: + switch(event.MouseInput.Event) + { + case EMIE_LMOUSE_PRESSED_DOWN: + DragStart.X = event.MouseInput.X; + DragStart.Y = event.MouseInput.Y; + Dragging = true; + Environment->setFocus(this); + return true; + case EMIE_LMOUSE_LEFT_UP: + Dragging = false; + Environment->removeFocus(this); + return true; + case EMIE_MOUSE_MOVED: + if (Dragging) + { + // gui window should not be dragged outside its parent + if (Parent) + if (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 || + event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 || + event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 || + event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1) + + return true; + + move(core::position2d(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y)); + DragStart.X = event.MouseInput.X; + DragStart.Y = event.MouseInput.Y; + return true; + } + break; + } + } + + return Parent ? Parent->OnEvent(event) : false; +} + + +//! draws the element and its children +void CGUIFileOpenDialog::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + + core::rect rect = AbsoluteRect; + + rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER), + rect, &AbsoluteClippingRect); + + if (Text.size()) + { + rect.UpperLeftCorner.X += 2; + rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; + + IGUIFont* font = skin->getFont(); + if (font) + font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true, + &AbsoluteClippingRect); + } + + IGUIElement::draw(); +} + + +//! fills the listbox with files. +void CGUIFileOpenDialog::fillListBox() +{ + IGUISkin *skin = Environment->getSkin(); + + if (!FileSystem || !FileBox || !skin) + return; + + if (FileList) + FileList->drop(); + + FileBox->clear(); + + FileList = FileSystem->createFileList(); + core::stringw s; + + for (s32 i=0; igetFileCount(); ++i) + { + s = FileList->getFileName(i); + FileBox->addItem(s.c_str(), skin->getIcon(FileList->isDirectory(i) ? EGDI_DIRECTORY : EGDI_FILE)); + } + + if (FileNameText) + { + s = FileSystem->getWorkingDirectory(); + FileNameText->setText(s.c_str()); + } +} + + +//! sends the event that the file has been selected. +void CGUIFileOpenDialog::sendSelectedEvent() +{ + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.EventType = EGET_FILE_SELECTED; + Parent->OnEvent(event); +} + +//! sends the event that the file choose process has been canceld +void CGUIFileOpenDialog::sendCancelEvent() +{ + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.EventType = EGET_FILE_CHOOSE_DIALOG_CANCELLED; + Parent->OnEvent(event); +} + +} // end namespace gui +} // end namespace irr diff --git a/src/dep/src/irrlicht/CGUIFileOpenDialog.h b/src/dep/src/irrlicht/CGUIFileOpenDialog.h index b91a42f..62cccba 100644 --- a/src/dep/src/irrlicht/CGUIFileOpenDialog.h +++ b/src/dep/src/irrlicht/CGUIFileOpenDialog.h @@ -1,66 +1,66 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ -#define __C_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ - -#include "IGUIFileOpenDialog.h" -#include "IGUIButton.h" -#include "IGUIListBox.h" -#include "IFileSystem.h" - -namespace irr -{ -namespace gui -{ - - class CGUIFileOpenDialog : public IGUIFileOpenDialog - { - public: - - //! constructor - CGUIFileOpenDialog(const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id); - - //! destructor - virtual ~CGUIFileOpenDialog(); - - //! returns the filename of the selected file. Returns NULL, if no file was selected. - virtual const wchar_t* getFilename(); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! draws the element and its children - virtual void draw(); - - protected: - - //! fills the listbox with files. - void fillListBox(); - - //! sends the event that the file has been selected. - void sendSelectedEvent(); - - //! sends the event that the file choose process has been canceld - void sendCancelEvent(); - - core::position2d DragStart; - core::stringw FileName; - bool Dragging; - IGUIButton* CloseButton; - IGUIButton* OKButton; - IGUIButton* CancelButton; - IGUIListBox* FileBox; - IGUIElement* FileNameText; - io::IFileSystem* FileSystem; - - io::IFileList* FileList; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ +#define __C_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ + +#include "IGUIFileOpenDialog.h" +#include "IGUIButton.h" +#include "IGUIListBox.h" +#include "IFileSystem.h" + +namespace irr +{ +namespace gui +{ + + class CGUIFileOpenDialog : public IGUIFileOpenDialog + { + public: + + //! constructor + CGUIFileOpenDialog(const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id); + + //! destructor + virtual ~CGUIFileOpenDialog(); + + //! returns the filename of the selected file. Returns NULL, if no file was selected. + virtual const wchar_t* getFilename(); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! draws the element and its children + virtual void draw(); + + protected: + + //! fills the listbox with files. + void fillListBox(); + + //! sends the event that the file has been selected. + void sendSelectedEvent(); + + //! sends the event that the file choose process has been canceld + void sendCancelEvent(); + + core::position2d DragStart; + core::stringw FileName; + bool Dragging; + IGUIButton* CloseButton; + IGUIButton* OKButton; + IGUIButton* CancelButton; + IGUIListBox* FileBox; + IGUIElement* FileNameText; + io::IFileSystem* FileSystem; + + io::IFileList* FileList; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIFont.cpp b/src/dep/src/irrlicht/CGUIFont.cpp index c2a1779..719dd6a 100644 --- a/src/dep/src/irrlicht/CGUIFont.cpp +++ b/src/dep/src/irrlicht/CGUIFont.cpp @@ -1,623 +1,623 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIFont.h" -#include "os.h" -#include "IGUIEnvironment.h" -#include "IXMLReader.h" -#include "IReadFile.h" -#include "IVideoDriver.h" -#include "IGUISpriteBank.h" -#include "CImage.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIFont::CGUIFont(IGUIEnvironment *env, const c8* filename) -: Driver(0), SpriteBank(0), Environment(env), WrongCharacter(0), - MaxHeight(0), GlobalKerningWidth(0), GlobalKerningHeight(0) -{ - #ifdef _DEBUG - setDebugName("CGUIFont"); - #endif - - if (Environment) - { - // don't grab environment, to avoid circular references - Driver = Environment->getVideoDriver(); - - SpriteBank = Environment->addEmptySpriteBank(filename); - } - - if (Driver) - Driver->grab(); -} - - - -//! destructor -CGUIFont::~CGUIFont() -{ - if (Driver) - Driver->drop(); - - if (SpriteBank) - SpriteBank->drop(); - -} - -//! loads a font file from xml -bool CGUIFont::load(io::IXMLReader* xml) -{ - if (!SpriteBank) - return false; - - while (xml->read()) - { - if (io::EXN_ELEMENT == xml->getNodeType()) - { - if (core::stringw(L"Texture") == xml->getNodeName()) - { - // add a texture - core::stringc fn = xml->getAttributeValue(L"filename"); - u32 i = (u32)xml->getAttributeValueAsInt(L"index"); - core::stringw alpha = xml->getAttributeValue(L"hasAlpha"); - - while (i+1 > SpriteBank->getTextureCount()) - SpriteBank->addTexture(0); - - // disable mipmaps+filtering - bool mipmap = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); - - // load texture - SpriteBank->setTexture(i, Driver->getTexture(fn.c_str())); - - // set previous mip-map+filter state - Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mipmap); - - // couldn't load texture, abort. - if (!SpriteBank->getTexture(i)) - { - os::Printer::log("Unable to load all textures in the font, aborting", ELL_ERROR); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - else - { - // colorkey texture rather than alpha channel? - if (alpha == core::stringw("false")) - Driver->makeColorKeyTexture(SpriteBank->getTexture(i), core::position2di(0,0)); - } - } - else if (core::stringw(L"c") == xml->getNodeName()) - { - // adding a character to this font - SFontArea a; - SGUISpriteFrame f; - SGUISprite s; - core::rect rectangle; - - a.underhang = xml->getAttributeValueAsInt(L"u"); - a.overhang = xml->getAttributeValueAsInt(L"o"); - a.spriteno = SpriteBank->getSprites().size(); - s32 texno = xml->getAttributeValueAsInt(L"i"); - - // parse rectangle - core::stringc rectstr = xml->getAttributeValue(L"r"); - wchar_t ch = xml->getAttributeValue(L"c")[0]; - - const c8 *c = rectstr.c_str(); - s32 val; - val = 0; - while (*c >= '0' && *c <= '9') - { - val *= 10; - val += *c - '0'; - c++; - } - rectangle.UpperLeftCorner.X = val; - while (*c == L' ' || *c == L',') c++; - - val = 0; - while (*c >= '0' && *c <= '9') - { - val *= 10; - val += *c - '0'; - c++; - } - rectangle.UpperLeftCorner.Y = val; - while (*c == L' ' || *c == L',') c++; - - val = 0; - while (*c >= '0' && *c <= '9') - { - val *= 10; - val += *c - '0'; - c++; - } - rectangle.LowerRightCorner.X = val; - while (*c == L' ' || *c == L',') c++; - - val = 0; - while (*c >= '0' && *c <= '9') - { - val *= 10; - val += *c - '0'; - c++; - } - rectangle.LowerRightCorner.Y = val; - - CharacterMap.insert(ch,Areas.size()); - - // make frame - f.rectNumber = SpriteBank->getPositions().size(); - f.textureNumber = texno; - - // add frame to sprite - s.Frames.push_back(f); - s.frameTime = 0; - - // add rectangle to sprite bank - SpriteBank->getPositions().push_back(rectangle); - a.width = rectangle.getWidth(); - - // add sprite to sprite bank - SpriteBank->getSprites().push_back(s); - - // add character to font - Areas.push_back(a); - } - } - - } - - // set bad character - WrongCharacter = getAreaFromCharacter(L' '); - - setMaxHeight(); - - return true; -} - -void CGUIFont::setMaxHeight() -{ - MaxHeight = 0; - s32 t; - - core::array< core::rect >& p = SpriteBank->getPositions(); - - for (u32 i=0; iMaxHeight) - MaxHeight = t; - } - -} - - -//! loads a font file, native file needed, for texture parsing -bool CGUIFont::load(io::IReadFile* file) -{ - if (!Driver) - return false; - - return loadTexture(Driver->createImageFromFile(file), - file->getFileName()); -} - -//! loads a font file, native file needed, for texture parsing -bool CGUIFont::load(const c8* filename) -{ - if (!Driver) - return false; - return loadTexture(Driver->createImageFromFile( filename ), - filename); -} - -//! load & prepare font from ITexture -bool CGUIFont::loadTexture(video::IImage* image, const c8* name) -{ - if (!image) - return false; - - s32 lowerRightPositions = 0; - - video::IImage* tmpImage=image; - bool deleteTmpImage=false; - switch(image->getColorFormat()) - { - case video::ECF_R5G6B5: - tmpImage = new video::CImage(video::ECF_A1R5G5B5,image); - deleteTmpImage=true; - case video::ECF_A1R5G5B5: - readPositions16bit(tmpImage, lowerRightPositions); - break; - case video::ECF_R8G8B8: - tmpImage = new video::CImage(video::ECF_A8R8G8B8,image); - deleteTmpImage=true; - case video::ECF_A8R8G8B8: - readPositions32bit (tmpImage, lowerRightPositions); - break; - } - - WrongCharacter = getAreaFromCharacter(L' '); - - // output warnings - if (!lowerRightPositions || !SpriteBank->getSprites().size()) - os::Printer::log("The amount of upper corner pixels or lower corner pixels is == 0, font file may be corrupted.", ELL_ERROR); - else - if (lowerRightPositions != (s32)SpriteBank->getPositions().size()) - os::Printer::log("The amount of upper corner pixels and the lower corner pixels is not equal, font file may be corrupted.", ELL_ERROR); - - bool ret = ( !SpriteBank->getSprites().empty() && lowerRightPositions ); - - - if ( ret ) - { - SpriteBank->addTexture(Driver->addTexture(name, tmpImage)); - } - if (deleteTmpImage) - tmpImage->drop(); - image->drop(); - - setMaxHeight(); - - return ret; -} - - - -void CGUIFont::readPositions32bit(video::IImage* image, s32& lowerRightPositions) -{ - const core::dimension2d& size = image->getDimension(); - - s32* p = (s32*)image->lock(); - if (!p) - { - os::Printer::log("Could not lock texture while preparing texture for a font.", ELL_ERROR); - return; - } - - // TODO: Hack till it's getting better... - // Pixel(0,0) == half opacity assume font with alpha.. - - s32 truealphaFont = ( (p[0] & 0xFF000000) == 0x7f000000 ); - p[0] |= 0xFF000000; - - s32 colorTopLeft = p[0]; - s32 colorLowerRight = *(p+1); - s32 colorBackGround = *(p+2); - s32 colorBackGroundTransparent = 0x00FFFFFF & colorBackGround; - s32 colorFont = 0xFFFFFFFF; - - *(p+1) = colorBackGround; - - // start parsing - - core::position2d pos(0,0); - for (pos.Y=0; pos.YgetPositions().push_back(core::rect(pos, pos)); - } - else - if (*p == colorLowerRight) - { - if (SpriteBank->getPositions().size()<=(u32)lowerRightPositions) - { - image->unlock(); - lowerRightPositions = 0; - return; - } - - *p = colorBackGroundTransparent; - SpriteBank->getPositions()[lowerRightPositions].LowerRightCorner = pos; - // add frame to sprite bank - SGUISpriteFrame f; - f.rectNumber = lowerRightPositions; - f.textureNumber = 0; - SGUISprite s; - s.Frames.push_back(f); - s.frameTime = 0; - SpriteBank->getSprites().push_back(s); - // add character to font - SFontArea a; - a.overhang = 0; - a.underhang = 0; - a.spriteno = lowerRightPositions; - a.width = SpriteBank->getPositions()[lowerRightPositions].getWidth(); - Areas.push_back(a); - // map letter to character - wchar_t ch = (wchar_t)(lowerRightPositions + 32); - CharacterMap.set(ch, lowerRightPositions); - - ++lowerRightPositions; - } - else - if (*p == colorBackGround) - { - *p = colorBackGroundTransparent; - } - else - if ( 0 == truealphaFont ) - { - *p = colorFont; - } - ++p; - } - } - - // Positions parsed. - - image->unlock(); -} - - - - -void CGUIFont::readPositions16bit(video::IImage* image, s32& lowerRightPositions) -{ - core::dimension2d size = image->getDimension(); - - s16* p = (s16*)image->lock(); - if (!p) - { - os::Printer::log("Could not lock texture while preparing texture for a font.", ELL_ERROR); - return; - } - - s16 truealphaFont = ( (p[0] & 0x8000) == 0x8000 ); - p[0] |= 0x8000; - - s16 colorTopLeft = p[0];; - s16 colorLowerRight = *(p+1); - s16 colorBackGround = *(p+2); - s16 colorBackGroundTransparent = 0x7FFF & colorBackGround; - u16 colorFont = 0xFFFF; - - *(p+1) = colorBackGround; - - // start parsing - - core::position2d pos(0,0); - for (pos.Y=0; pos.YgetPositions().push_back(core::rect(pos, pos)); - } - else - if (*p == colorLowerRight) - { - // too many lower right points - if (SpriteBank->getPositions().size()<=(u32)lowerRightPositions) - { - image->unlock(); - lowerRightPositions = 0; - return; - } - - *p = colorBackGroundTransparent; - SpriteBank->getPositions()[lowerRightPositions].LowerRightCorner = pos; - // add frame to sprite bank - SGUISpriteFrame f; - f.rectNumber = lowerRightPositions; - f.textureNumber = 0; - SGUISprite s; - s.Frames.push_back(f); - s.frameTime = 0; - SpriteBank->getSprites().push_back(s); - // add character to font - SFontArea a; - a.overhang = 0; - a.underhang = 0; - a.spriteno = lowerRightPositions; - a.width = SpriteBank->getPositions()[lowerRightPositions].getWidth(); - Areas.push_back(a); - // map letter to character - wchar_t ch = (wchar_t)(lowerRightPositions + 32); - CharacterMap.set(ch, lowerRightPositions); - - ++lowerRightPositions; - } - else - if (*p == colorBackGround) - *p = colorBackGroundTransparent; - else - if ( 0 == truealphaFont ) - { - *p = colorFont; - } - ++p; - } - } - - // Positions parsed. - - image->unlock(); -} - - -//! returns the dimension of text -core::dimension2d CGUIFont::getDimension(const wchar_t* text) -{ - core::dimension2d dim(0, 0); - - for (const wchar_t* p = text; *p; ++p) - { - SFontArea &area = Areas[getAreaFromCharacter(*p)]; - - dim.Width += area.underhang; - dim.Width += area.width + area.overhang + GlobalKerningWidth; - } - - dim.Height = MaxHeight; - - return dim; -} - -//! set an Pixel Offset on Drawing ( scale position on width ) -void CGUIFont::setKerningWidth ( s32 kerning ) -{ - GlobalKerningWidth = kerning; -} - -//! set an Pixel Offset on Drawing ( scale position on width ) -s32 CGUIFont::getKerningWidth(const wchar_t* thisLetter, const wchar_t* previousLetter) -{ - s32 ret = GlobalKerningWidth; - - if (thisLetter) - { - ret += Areas[getAreaFromCharacter(*thisLetter)].overhang; - - if (previousLetter) - { - ret += Areas[getAreaFromCharacter(*previousLetter)].underhang; - } - } - - return ret; -} - -//! set an Pixel Offset on Drawing ( scale position on height ) -void CGUIFont::setKerningHeight ( s32 kerning ) -{ - GlobalKerningHeight = kerning; -} - -//! set an Pixel Offset on Drawing ( scale position on height ) -s32 CGUIFont::getKerningHeight () -{ - return GlobalKerningHeight; -} - -//! returns the sprite number from a given character -u32 CGUIFont::getSpriteNoFromChar(const wchar_t *c) -{ - return Areas[getAreaFromCharacter(*c)].spriteno; -} - - -s32 CGUIFont::getAreaFromCharacter(const wchar_t c) -{ - core::map::Node* n = CharacterMap.find(c); - if (n) - return n->getValue(); - else - return WrongCharacter; -} - -/* -//! draws an text and clips it to the specified rectangle if wanted -void CGUIFont::draw(const wchar_t* text, const core::rect& position, video::SColor color, bool hcenter, bool vcenter, const core::rect* clip) -{ - if (!Driver) - return; - - core::dimension2d textDimension; - core::position2d offset = position.UpperLeftCorner; - - if (hcenter || vcenter) - { - textDimension = getDimension(text); - - if (hcenter) - offset.X = ((position.getWidth() - textDimension.Width)>>1) + offset.X; - - if (vcenter) - offset.Y = ((position.getHeight() - textDimension.Height)>>1) + offset.Y; - } - - core::array indices; - indices.reallocate(core::stringw(text).size()); - u32 n; - while(*text) - { - n = (*text) - 32; - if ( n > Positions.size()) - n = WrongCharacter; - indices.push_back(n); - ++text; - } - Driver->draw2DImage(Texture, offset, Positions, indices, GlobalKerningWidth, clip, color, true); -} -*/ - - -//! draws an text and clips it to the specified rectangle if wanted -void CGUIFont::draw(const wchar_t* text, const core::rect& position, video::SColor color, bool hcenter, bool vcenter, const core::rect* clip) -{ - if (!Driver) - return; - - core::dimension2d textDimension; - core::position2d offset = position.UpperLeftCorner; - core::rect pos; - - if (hcenter || vcenter) - { - textDimension = getDimension(text); - - if (hcenter) - offset.X = ((position.getWidth() - textDimension.Width)>>1) + offset.X; - - if (vcenter) - offset.Y = ((position.getHeight() - textDimension.Height)>>1) + offset.Y; - } - - while(*text) - { - SFontArea& area = Areas[getAreaFromCharacter(*text)]; - - offset.X += area.underhang; - - SpriteBank->draw2DSprite(area.spriteno, offset, clip, color); - - offset.X += area.width + area.overhang + GlobalKerningWidth; - - ++text; - } -} - -//! Calculates the index of the character in the text which is on a specific position. -s32 CGUIFont::getCharacterFromPos(const wchar_t* text, s32 pixel_x) -{ - s32 x = 0; - s32 idx = 0; - - while (text[idx]) - { - SFontArea &a = Areas[getAreaFromCharacter(text[idx])]; - - x += a.width + a.overhang + a.underhang; - - if (x >= pixel_x) - return idx; - - ++idx; - } - - return -1; -} - -IGUISpriteBank* CGUIFont::getSpriteBank() -{ - return SpriteBank; -} - -} // end namespace gui -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIFont.h" +#include "os.h" +#include "IGUIEnvironment.h" +#include "IXMLReader.h" +#include "IReadFile.h" +#include "IVideoDriver.h" +#include "IGUISpriteBank.h" +#include "CImage.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIFont::CGUIFont(IGUIEnvironment *env, const c8* filename) +: Driver(0), SpriteBank(0), Environment(env), WrongCharacter(0), + MaxHeight(0), GlobalKerningWidth(0), GlobalKerningHeight(0) +{ + #ifdef _DEBUG + setDebugName("CGUIFont"); + #endif + + if (Environment) + { + // don't grab environment, to avoid circular references + Driver = Environment->getVideoDriver(); + + SpriteBank = Environment->addEmptySpriteBank(filename); + } + + if (Driver) + Driver->grab(); +} + + + +//! destructor +CGUIFont::~CGUIFont() +{ + if (Driver) + Driver->drop(); + + if (SpriteBank) + SpriteBank->drop(); + +} + +//! loads a font file from xml +bool CGUIFont::load(io::IXMLReader* xml) +{ + if (!SpriteBank) + return false; + + while (xml->read()) + { + if (io::EXN_ELEMENT == xml->getNodeType()) + { + if (core::stringw(L"Texture") == xml->getNodeName()) + { + // add a texture + core::stringc fn = xml->getAttributeValue(L"filename"); + u32 i = (u32)xml->getAttributeValueAsInt(L"index"); + core::stringw alpha = xml->getAttributeValue(L"hasAlpha"); + + while (i+1 > SpriteBank->getTextureCount()) + SpriteBank->addTexture(0); + + // disable mipmaps+filtering + bool mipmap = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); + Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); + + // load texture + SpriteBank->setTexture(i, Driver->getTexture(fn.c_str())); + + // set previous mip-map+filter state + Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mipmap); + + // couldn't load texture, abort. + if (!SpriteBank->getTexture(i)) + { + os::Printer::log("Unable to load all textures in the font, aborting", ELL_ERROR); + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return false; + } + else + { + // colorkey texture rather than alpha channel? + if (alpha == core::stringw("false")) + Driver->makeColorKeyTexture(SpriteBank->getTexture(i), core::position2di(0,0)); + } + } + else if (core::stringw(L"c") == xml->getNodeName()) + { + // adding a character to this font + SFontArea a; + SGUISpriteFrame f; + SGUISprite s; + core::rect rectangle; + + a.underhang = xml->getAttributeValueAsInt(L"u"); + a.overhang = xml->getAttributeValueAsInt(L"o"); + a.spriteno = SpriteBank->getSprites().size(); + s32 texno = xml->getAttributeValueAsInt(L"i"); + + // parse rectangle + core::stringc rectstr = xml->getAttributeValue(L"r"); + wchar_t ch = xml->getAttributeValue(L"c")[0]; + + const c8 *c = rectstr.c_str(); + s32 val; + val = 0; + while (*c >= '0' && *c <= '9') + { + val *= 10; + val += *c - '0'; + c++; + } + rectangle.UpperLeftCorner.X = val; + while (*c == L' ' || *c == L',') c++; + + val = 0; + while (*c >= '0' && *c <= '9') + { + val *= 10; + val += *c - '0'; + c++; + } + rectangle.UpperLeftCorner.Y = val; + while (*c == L' ' || *c == L',') c++; + + val = 0; + while (*c >= '0' && *c <= '9') + { + val *= 10; + val += *c - '0'; + c++; + } + rectangle.LowerRightCorner.X = val; + while (*c == L' ' || *c == L',') c++; + + val = 0; + while (*c >= '0' && *c <= '9') + { + val *= 10; + val += *c - '0'; + c++; + } + rectangle.LowerRightCorner.Y = val; + + CharacterMap.insert(ch,Areas.size()); + + // make frame + f.rectNumber = SpriteBank->getPositions().size(); + f.textureNumber = texno; + + // add frame to sprite + s.Frames.push_back(f); + s.frameTime = 0; + + // add rectangle to sprite bank + SpriteBank->getPositions().push_back(rectangle); + a.width = rectangle.getWidth(); + + // add sprite to sprite bank + SpriteBank->getSprites().push_back(s); + + // add character to font + Areas.push_back(a); + } + } + + } + + // set bad character + WrongCharacter = getAreaFromCharacter(L' '); + + setMaxHeight(); + + return true; +} + +void CGUIFont::setMaxHeight() +{ + MaxHeight = 0; + s32 t; + + core::array< core::rect >& p = SpriteBank->getPositions(); + + for (u32 i=0; iMaxHeight) + MaxHeight = t; + } + +} + + +//! loads a font file, native file needed, for texture parsing +bool CGUIFont::load(io::IReadFile* file) +{ + if (!Driver) + return false; + + return loadTexture(Driver->createImageFromFile(file), + file->getFileName()); +} + +//! loads a font file, native file needed, for texture parsing +bool CGUIFont::load(const c8* filename) +{ + if (!Driver) + return false; + return loadTexture(Driver->createImageFromFile( filename ), + filename); +} + +//! load & prepare font from ITexture +bool CGUIFont::loadTexture(video::IImage* image, const c8* name) +{ + if (!image) + return false; + + s32 lowerRightPositions = 0; + + video::IImage* tmpImage=image; + bool deleteTmpImage=false; + switch(image->getColorFormat()) + { + case video::ECF_R5G6B5: + tmpImage = new video::CImage(video::ECF_A1R5G5B5,image); + deleteTmpImage=true; + case video::ECF_A1R5G5B5: + readPositions16bit(tmpImage, lowerRightPositions); + break; + case video::ECF_R8G8B8: + tmpImage = new video::CImage(video::ECF_A8R8G8B8,image); + deleteTmpImage=true; + case video::ECF_A8R8G8B8: + readPositions32bit (tmpImage, lowerRightPositions); + break; + } + + WrongCharacter = getAreaFromCharacter(L' '); + + // output warnings + if (!lowerRightPositions || !SpriteBank->getSprites().size()) + os::Printer::log("The amount of upper corner pixels or lower corner pixels is == 0, font file may be corrupted.", ELL_ERROR); + else + if (lowerRightPositions != (s32)SpriteBank->getPositions().size()) + os::Printer::log("The amount of upper corner pixels and the lower corner pixels is not equal, font file may be corrupted.", ELL_ERROR); + + bool ret = ( !SpriteBank->getSprites().empty() && lowerRightPositions ); + + + if ( ret ) + { + SpriteBank->addTexture(Driver->addTexture(name, tmpImage)); + } + if (deleteTmpImage) + tmpImage->drop(); + image->drop(); + + setMaxHeight(); + + return ret; +} + + + +void CGUIFont::readPositions32bit(video::IImage* image, s32& lowerRightPositions) +{ + const core::dimension2d& size = image->getDimension(); + + s32* p = (s32*)image->lock(); + if (!p) + { + os::Printer::log("Could not lock texture while preparing texture for a font.", ELL_ERROR); + return; + } + + // TODO: Hack till it's getting better... + // Pixel(0,0) == half opacity assume font with alpha.. + + s32 truealphaFont = ( (p[0] & 0xFF000000) == 0x7f000000 ); + p[0] |= 0xFF000000; + + s32 colorTopLeft = p[0]; + s32 colorLowerRight = *(p+1); + s32 colorBackGround = *(p+2); + s32 colorBackGroundTransparent = 0x00FFFFFF & colorBackGround; + s32 colorFont = 0xFFFFFFFF; + + *(p+1) = colorBackGround; + + // start parsing + + core::position2d pos(0,0); + for (pos.Y=0; pos.YgetPositions().push_back(core::rect(pos, pos)); + } + else + if (*p == colorLowerRight) + { + if (SpriteBank->getPositions().size()<=(u32)lowerRightPositions) + { + image->unlock(); + lowerRightPositions = 0; + return; + } + + *p = colorBackGroundTransparent; + SpriteBank->getPositions()[lowerRightPositions].LowerRightCorner = pos; + // add frame to sprite bank + SGUISpriteFrame f; + f.rectNumber = lowerRightPositions; + f.textureNumber = 0; + SGUISprite s; + s.Frames.push_back(f); + s.frameTime = 0; + SpriteBank->getSprites().push_back(s); + // add character to font + SFontArea a; + a.overhang = 0; + a.underhang = 0; + a.spriteno = lowerRightPositions; + a.width = SpriteBank->getPositions()[lowerRightPositions].getWidth(); + Areas.push_back(a); + // map letter to character + wchar_t ch = (wchar_t)(lowerRightPositions + 32); + CharacterMap.set(ch, lowerRightPositions); + + ++lowerRightPositions; + } + else + if (*p == colorBackGround) + { + *p = colorBackGroundTransparent; + } + else + if ( 0 == truealphaFont ) + { + *p = colorFont; + } + ++p; + } + } + + // Positions parsed. + + image->unlock(); +} + + + + +void CGUIFont::readPositions16bit(video::IImage* image, s32& lowerRightPositions) +{ + core::dimension2d size = image->getDimension(); + + s16* p = (s16*)image->lock(); + if (!p) + { + os::Printer::log("Could not lock texture while preparing texture for a font.", ELL_ERROR); + return; + } + + s16 truealphaFont = ( (p[0] & 0x8000) == 0x8000 ); + p[0] |= 0x8000; + + s16 colorTopLeft = p[0];; + s16 colorLowerRight = *(p+1); + s16 colorBackGround = *(p+2); + s16 colorBackGroundTransparent = 0x7FFF & colorBackGround; + u16 colorFont = 0xFFFF; + + *(p+1) = colorBackGround; + + // start parsing + + core::position2d pos(0,0); + for (pos.Y=0; pos.YgetPositions().push_back(core::rect(pos, pos)); + } + else + if (*p == colorLowerRight) + { + // too many lower right points + if (SpriteBank->getPositions().size()<=(u32)lowerRightPositions) + { + image->unlock(); + lowerRightPositions = 0; + return; + } + + *p = colorBackGroundTransparent; + SpriteBank->getPositions()[lowerRightPositions].LowerRightCorner = pos; + // add frame to sprite bank + SGUISpriteFrame f; + f.rectNumber = lowerRightPositions; + f.textureNumber = 0; + SGUISprite s; + s.Frames.push_back(f); + s.frameTime = 0; + SpriteBank->getSprites().push_back(s); + // add character to font + SFontArea a; + a.overhang = 0; + a.underhang = 0; + a.spriteno = lowerRightPositions; + a.width = SpriteBank->getPositions()[lowerRightPositions].getWidth(); + Areas.push_back(a); + // map letter to character + wchar_t ch = (wchar_t)(lowerRightPositions + 32); + CharacterMap.set(ch, lowerRightPositions); + + ++lowerRightPositions; + } + else + if (*p == colorBackGround) + *p = colorBackGroundTransparent; + else + if ( 0 == truealphaFont ) + { + *p = colorFont; + } + ++p; + } + } + + // Positions parsed. + + image->unlock(); +} + + +//! returns the dimension of text +core::dimension2d CGUIFont::getDimension(const wchar_t* text) +{ + core::dimension2d dim(0, 0); + + for (const wchar_t* p = text; *p; ++p) + { + SFontArea &area = Areas[getAreaFromCharacter(*p)]; + + dim.Width += area.underhang; + dim.Width += area.width + area.overhang + GlobalKerningWidth; + } + + dim.Height = MaxHeight; + + return dim; +} + +//! set an Pixel Offset on Drawing ( scale position on width ) +void CGUIFont::setKerningWidth ( s32 kerning ) +{ + GlobalKerningWidth = kerning; +} + +//! set an Pixel Offset on Drawing ( scale position on width ) +s32 CGUIFont::getKerningWidth(const wchar_t* thisLetter, const wchar_t* previousLetter) +{ + s32 ret = GlobalKerningWidth; + + if (thisLetter) + { + ret += Areas[getAreaFromCharacter(*thisLetter)].overhang; + + if (previousLetter) + { + ret += Areas[getAreaFromCharacter(*previousLetter)].underhang; + } + } + + return ret; +} + +//! set an Pixel Offset on Drawing ( scale position on height ) +void CGUIFont::setKerningHeight ( s32 kerning ) +{ + GlobalKerningHeight = kerning; +} + +//! set an Pixel Offset on Drawing ( scale position on height ) +s32 CGUIFont::getKerningHeight () +{ + return GlobalKerningHeight; +} + +//! returns the sprite number from a given character +u32 CGUIFont::getSpriteNoFromChar(const wchar_t *c) +{ + return Areas[getAreaFromCharacter(*c)].spriteno; +} + + +s32 CGUIFont::getAreaFromCharacter(const wchar_t c) +{ + core::map::Node* n = CharacterMap.find(c); + if (n) + return n->getValue(); + else + return WrongCharacter; +} + +/* +//! draws an text and clips it to the specified rectangle if wanted +void CGUIFont::draw(const wchar_t* text, const core::rect& position, video::SColor color, bool hcenter, bool vcenter, const core::rect* clip) +{ + if (!Driver) + return; + + core::dimension2d textDimension; + core::position2d offset = position.UpperLeftCorner; + + if (hcenter || vcenter) + { + textDimension = getDimension(text); + + if (hcenter) + offset.X = ((position.getWidth() - textDimension.Width)>>1) + offset.X; + + if (vcenter) + offset.Y = ((position.getHeight() - textDimension.Height)>>1) + offset.Y; + } + + core::array indices; + indices.reallocate(core::stringw(text).size()); + u32 n; + while(*text) + { + n = (*text) - 32; + if ( n > Positions.size()) + n = WrongCharacter; + indices.push_back(n); + ++text; + } + Driver->draw2DImage(Texture, offset, Positions, indices, GlobalKerningWidth, clip, color, true); +} +*/ + + +//! draws an text and clips it to the specified rectangle if wanted +void CGUIFont::draw(const wchar_t* text, const core::rect& position, video::SColor color, bool hcenter, bool vcenter, const core::rect* clip) +{ + if (!Driver) + return; + + core::dimension2d textDimension; + core::position2d offset = position.UpperLeftCorner; + core::rect pos; + + if (hcenter || vcenter) + { + textDimension = getDimension(text); + + if (hcenter) + offset.X = ((position.getWidth() - textDimension.Width)>>1) + offset.X; + + if (vcenter) + offset.Y = ((position.getHeight() - textDimension.Height)>>1) + offset.Y; + } + + while(*text) + { + SFontArea& area = Areas[getAreaFromCharacter(*text)]; + + offset.X += area.underhang; + + SpriteBank->draw2DSprite(area.spriteno, offset, clip, color); + + offset.X += area.width + area.overhang + GlobalKerningWidth; + + ++text; + } +} + +//! Calculates the index of the character in the text which is on a specific position. +s32 CGUIFont::getCharacterFromPos(const wchar_t* text, s32 pixel_x) +{ + s32 x = 0; + s32 idx = 0; + + while (text[idx]) + { + SFontArea &a = Areas[getAreaFromCharacter(text[idx])]; + + x += a.width + a.overhang + a.underhang; + + if (x >= pixel_x) + return idx; + + ++idx; + } + + return -1; +} + +IGUISpriteBank* CGUIFont::getSpriteBank() +{ + return SpriteBank; +} + +} // end namespace gui +} // end namespace irr diff --git a/src/dep/src/irrlicht/CGUIFont.h b/src/dep/src/irrlicht/CGUIFont.h index 4f77ca8..b672984 100644 --- a/src/dep/src/irrlicht/CGUIFont.h +++ b/src/dep/src/irrlicht/CGUIFont.h @@ -1,106 +1,106 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_FONT_H_INCLUDED__ -#define __C_GUI_FONT_H_INCLUDED__ - -#include "IGUIFontBitmap.h" -#include "irrString.h" -#include "irrMap.h" -#include "IXMLReader.h" -#include "IReadFile.h" - -namespace irr -{ - -namespace video -{ - class IVideoDriver; -} - -namespace gui -{ - - class IGUIEnvironment; - -class CGUIFont : public IGUIFontBitmap -{ -public: - - //! constructor - CGUIFont(IGUIEnvironment* env, const c8* filename); - - //! destructor - virtual ~CGUIFont(); - - //! loads a font from a texture file - bool load(const c8* filename); - - //! loads a font from a texture file - bool load(io::IReadFile* file); - - //! loads a font from an XML file - bool load(io::IXMLReader* xml); - - //! draws an text and clips it to the specified rectangle if wanted - virtual void draw(const wchar_t* text, const core::rect& position, video::SColor color, bool hcenter=false, bool vcenter=false, const core::rect* clip=0); - - //! returns the dimension of a text - virtual core::dimension2d getDimension(const wchar_t* text); - - //! Calculates the index of the character in the text which is on a specific position. - virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x); - - //! Returns the type of this font - virtual EGUI_FONT_TYPE getType() { return EGFT_BITMAP; } - - //! set an Pixel Offset on Drawing ( scale position on width ) - virtual void setKerningWidth (s32 kerning); - virtual void setKerningHeight (s32 kerning); - - //! set an Pixel Offset on Drawing ( scale position on width ) - virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0); - virtual s32 getKerningHeight(); - - //! gets the sprite bank - virtual IGUISpriteBank* getSpriteBank(); - - //! returns the sprite number from a given character - virtual u32 getSpriteNoFromChar(const wchar_t *c); - -private: - - struct SFontArea - { - SFontArea() : underhang(0), overhang(0), width(0), spriteno(0) {} - s32 underhang; - s32 overhang; - s32 width; - u32 spriteno; - }; - - //! load & prepare font from ITexture - bool loadTexture(video::IImage * image, const c8* name); - - void readPositions16bit(video::IImage* texture, s32& lowerRightPositions); - void readPositions32bit(video::IImage* texture, s32& lowerRightPositions); - - s32 getAreaFromCharacter (const wchar_t c); - void setMaxHeight(); - - core::array Areas; - core::map CharacterMap; - video::IVideoDriver* Driver; - IGUISpriteBank* SpriteBank; - IGUIEnvironment* Environment; - u32 WrongCharacter; - s32 MaxHeight; - s32 GlobalKerningWidth, GlobalKerningHeight; -}; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_FONT_H_INCLUDED__ +#define __C_GUI_FONT_H_INCLUDED__ + +#include "IGUIFontBitmap.h" +#include "irrString.h" +#include "irrMap.h" +#include "IXMLReader.h" +#include "IReadFile.h" + +namespace irr +{ + +namespace video +{ + class IVideoDriver; +} + +namespace gui +{ + + class IGUIEnvironment; + +class CGUIFont : public IGUIFontBitmap +{ +public: + + //! constructor + CGUIFont(IGUIEnvironment* env, const c8* filename); + + //! destructor + virtual ~CGUIFont(); + + //! loads a font from a texture file + bool load(const c8* filename); + + //! loads a font from a texture file + bool load(io::IReadFile* file); + + //! loads a font from an XML file + bool load(io::IXMLReader* xml); + + //! draws an text and clips it to the specified rectangle if wanted + virtual void draw(const wchar_t* text, const core::rect& position, video::SColor color, bool hcenter=false, bool vcenter=false, const core::rect* clip=0); + + //! returns the dimension of a text + virtual core::dimension2d getDimension(const wchar_t* text); + + //! Calculates the index of the character in the text which is on a specific position. + virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x); + + //! Returns the type of this font + virtual EGUI_FONT_TYPE getType() { return EGFT_BITMAP; } + + //! set an Pixel Offset on Drawing ( scale position on width ) + virtual void setKerningWidth (s32 kerning); + virtual void setKerningHeight (s32 kerning); + + //! set an Pixel Offset on Drawing ( scale position on width ) + virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0); + virtual s32 getKerningHeight(); + + //! gets the sprite bank + virtual IGUISpriteBank* getSpriteBank(); + + //! returns the sprite number from a given character + virtual u32 getSpriteNoFromChar(const wchar_t *c); + +private: + + struct SFontArea + { + SFontArea() : underhang(0), overhang(0), width(0), spriteno(0) {} + s32 underhang; + s32 overhang; + s32 width; + u32 spriteno; + }; + + //! load & prepare font from ITexture + bool loadTexture(video::IImage * image, const c8* name); + + void readPositions16bit(video::IImage* texture, s32& lowerRightPositions); + void readPositions32bit(video::IImage* texture, s32& lowerRightPositions); + + s32 getAreaFromCharacter (const wchar_t c); + void setMaxHeight(); + + core::array Areas; + core::map CharacterMap; + video::IVideoDriver* Driver; + IGUISpriteBank* SpriteBank; + IGUIEnvironment* Environment; + u32 WrongCharacter; + s32 MaxHeight; + s32 GlobalKerningWidth, GlobalKerningHeight; +}; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIImage.cpp b/src/dep/src/irrlicht/CGUIImage.cpp index f9f3f34..e9de828 100644 --- a/src/dep/src/irrlicht/CGUIImage.cpp +++ b/src/dep/src/irrlicht/CGUIImage.cpp @@ -1,105 +1,105 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIImage.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace gui -{ - - - -//! constructor -CGUIImage::CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) -: IGUIImage(environment, parent, id, rectangle), Texture(0), UseAlphaChannel(false) -{ - #ifdef _DEBUG - setDebugName("CGUIImage"); - #endif -} - - - -//! destructor -CGUIImage::~CGUIImage() -{ - if (Texture) - Texture->drop(); -} - - - -//! sets an image -void CGUIImage::setImage(video::ITexture* image) -{ - if (Texture) - Texture->drop(); - - Texture = image; - - if (Texture) - Texture->grab(); -} - - - -//! draws the element and its children -void CGUIImage::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - irr::video::IVideoDriver* driver = Environment->getVideoDriver(); - - core::rect rect = AbsoluteRect; - - if (Texture) - driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, - core::rect(core::position2d(0,0), Texture->getOriginalSize()), - &AbsoluteClippingRect, video::SColor(255,255,255,255), UseAlphaChannel); - else - driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &AbsoluteClippingRect); - - IGUIElement::draw(); -} - - -//! sets if the image should use its alpha channel to draw itself -void CGUIImage::setUseAlphaChannel(bool use) -{ - UseAlphaChannel = use; -} - - -//! Writes attributes of the element. -void CGUIImage::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) -{ - IGUIImage::serializeAttributes(out,options); - - out->addTexture ("Texture", Texture); - out->addBool ("UseAlphaChannel", UseAlphaChannel); - -} - -//! Reads attributes of the element -void CGUIImage::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIImage::deserializeAttributes(in,options); - - setImage(in->getAttributeAsTexture("Texture")); - setUseAlphaChannel(in->getAttributeAsBool("UseAlphaChannel")); - -} - - - - -} // end namespace gui -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIImage.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace gui +{ + + + +//! constructor +CGUIImage::CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) +: IGUIImage(environment, parent, id, rectangle), Texture(0), UseAlphaChannel(false) +{ + #ifdef _DEBUG + setDebugName("CGUIImage"); + #endif +} + + + +//! destructor +CGUIImage::~CGUIImage() +{ + if (Texture) + Texture->drop(); +} + + + +//! sets an image +void CGUIImage::setImage(video::ITexture* image) +{ + if (Texture) + Texture->drop(); + + Texture = image; + + if (Texture) + Texture->grab(); +} + + + +//! draws the element and its children +void CGUIImage::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + irr::video::IVideoDriver* driver = Environment->getVideoDriver(); + + core::rect rect = AbsoluteRect; + + if (Texture) + driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, + core::rect(core::position2d(0,0), Texture->getOriginalSize()), + &AbsoluteClippingRect, video::SColor(255,255,255,255), UseAlphaChannel); + else + driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &AbsoluteClippingRect); + + IGUIElement::draw(); +} + + +//! sets if the image should use its alpha channel to draw itself +void CGUIImage::setUseAlphaChannel(bool use) +{ + UseAlphaChannel = use; +} + + +//! Writes attributes of the element. +void CGUIImage::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +{ + IGUIImage::serializeAttributes(out,options); + + out->addTexture ("Texture", Texture); + out->addBool ("UseAlphaChannel", UseAlphaChannel); + +} + +//! Reads attributes of the element +void CGUIImage::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +{ + IGUIImage::deserializeAttributes(in,options); + + setImage(in->getAttributeAsTexture("Texture")); + setUseAlphaChannel(in->getAttributeAsBool("UseAlphaChannel")); + +} + + + + +} // end namespace gui +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CGUIImage.h b/src/dep/src/irrlicht/CGUIImage.h index 4cdd345..858cab3 100644 --- a/src/dep/src/irrlicht/CGUIImage.h +++ b/src/dep/src/irrlicht/CGUIImage.h @@ -1,53 +1,53 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_IMAGE_H_INCLUDED__ -#define __C_GUI_IMAGE_H_INCLUDED__ - -#include "IGUIImage.h" - -namespace irr -{ -namespace gui -{ - - class CGUIImage : public IGUIImage - { - public: - - //! constructor - CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle); - - //! destructor - ~CGUIImage(); - - //! sets an image - virtual void setImage(video::ITexture* image); - - //! draws the element and its children - virtual void draw(); - - //! sets if the image should use its alpha channel to draw itself - virtual void setUseAlphaChannel(bool use); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - - private: - - video::ITexture* Texture; - bool UseAlphaChannel; - - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_IMAGE_H_INCLUDED__ +#define __C_GUI_IMAGE_H_INCLUDED__ + +#include "IGUIImage.h" + +namespace irr +{ +namespace gui +{ + + class CGUIImage : public IGUIImage + { + public: + + //! constructor + CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle); + + //! destructor + ~CGUIImage(); + + //! sets an image + virtual void setImage(video::ITexture* image); + + //! draws the element and its children + virtual void draw(); + + //! sets if the image should use its alpha channel to draw itself + virtual void setUseAlphaChannel(bool use); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + + private: + + video::ITexture* Texture; + bool UseAlphaChannel; + + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIInOutFader.cpp b/src/dep/src/irrlicht/CGUIInOutFader.cpp index 345a369..db9a624 100644 --- a/src/dep/src/irrlicht/CGUIInOutFader.cpp +++ b/src/dep/src/irrlicht/CGUIInOutFader.cpp @@ -1,183 +1,183 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIInOutFader.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - - -//! constructor -CGUIInOutFader::CGUIInOutFader(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) -: IGUIInOutFader(environment, parent, id, rectangle) -{ - #ifdef _DEBUG - setDebugName("CGUIInOutFader"); - #endif - - Action = EFA_NOTHING; - StartTime = 0; - EndTime = 0; - - setColor(video::SColor(0,0,0,0)); -} - - - -//! destructor -CGUIInOutFader::~CGUIInOutFader() -{ -} - - - -//! draws the element and its children -void CGUIInOutFader::draw() -{ - if (!IsVisible || !Action) - return; - - u32 now = os::Timer::getTime(); - if (now > EndTime && Action == EFA_FADE_IN) - { - Action = EFA_NOTHING; - return; - } - - irr::video::IVideoDriver* driver = Environment->getVideoDriver(); - - if (driver) - { - f32 d; - - if (now > EndTime) - d = 0.0f; - else - d = (EndTime - now) / (f32)(EndTime - StartTime); - - video::SColor newCol = FullColor.getInterpolated(TransColor, d); - driver->draw2DRectangle(newCol, AbsoluteRect, &AbsoluteClippingRect); - } - - IGUIElement::draw(); -} - - - -//! Gets the color to fade out to or to fade in from. -video::SColor CGUIInOutFader::getColor() const -{ - return Color[1]; -} - - - -//! Sets the color to fade out to or to fade in from. -void CGUIInOutFader::setColor(video::SColor color) -{ - video::SColor s = color; - video::SColor d = color; - - s.setAlpha ( 255 ); - d.setAlpha ( 0 ); - setColor ( s,d ); - -/* - Color[0] = color; - - FullColor = Color[0]; - TransColor = Color[0]; - - if (Action == EFA_FADE_OUT) - { - FullColor.setAlpha(0); - TransColor.setAlpha(255); - } - else - if (Action == EFA_FADE_IN) - { - FullColor.setAlpha(255); - TransColor.setAlpha(0); - } -*/ -} - -void CGUIInOutFader::setColor(video::SColor source, video::SColor dest) -{ - Color[0] = source; - Color[1] = dest; - - if (Action == EFA_FADE_OUT) - { - FullColor = Color[1]; - TransColor = Color[0]; - } - else - if (Action == EFA_FADE_IN) - { - FullColor = Color[0]; - TransColor = Color[1]; - } - -} - - -//! Returns if the fade in or out process is done. -bool CGUIInOutFader::isReady() const -{ - u32 now = os::Timer::getTime(); - bool ret = (now > EndTime); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - - -//! Starts the fade in process. -void CGUIInOutFader::fadeIn(u32 time) -{ - StartTime = os::Timer::getTime(); - EndTime = StartTime + time; - Action = EFA_FADE_IN; - setColor(Color[0],Color[1]); -} - - -//! Starts the fade out process. -void CGUIInOutFader::fadeOut(u32 time) -{ - StartTime = os::Timer::getTime(); - EndTime = StartTime + time; - Action = EFA_FADE_OUT; - setColor(Color[0],Color[1]); -} - -//! Writes attributes of the element. -void CGUIInOutFader::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) -{ - IGUIInOutFader::serializeAttributes(out,options); - - out->addColor ("FullColor", FullColor); - out->addColor ("TransColor", TransColor); - -} - -//! Reads attributes of the element -void CGUIInOutFader::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIInOutFader::deserializeAttributes(in,options); - - FullColor = in->getAttributeAsColor("FullColor"); - TransColor = in->getAttributeAsColor("TransColor"); -} - - - -} // end namespace gui -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIInOutFader.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + + +//! constructor +CGUIInOutFader::CGUIInOutFader(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) +: IGUIInOutFader(environment, parent, id, rectangle) +{ + #ifdef _DEBUG + setDebugName("CGUIInOutFader"); + #endif + + Action = EFA_NOTHING; + StartTime = 0; + EndTime = 0; + + setColor(video::SColor(0,0,0,0)); +} + + + +//! destructor +CGUIInOutFader::~CGUIInOutFader() +{ +} + + + +//! draws the element and its children +void CGUIInOutFader::draw() +{ + if (!IsVisible || !Action) + return; + + u32 now = os::Timer::getTime(); + if (now > EndTime && Action == EFA_FADE_IN) + { + Action = EFA_NOTHING; + return; + } + + irr::video::IVideoDriver* driver = Environment->getVideoDriver(); + + if (driver) + { + f32 d; + + if (now > EndTime) + d = 0.0f; + else + d = (EndTime - now) / (f32)(EndTime - StartTime); + + video::SColor newCol = FullColor.getInterpolated(TransColor, d); + driver->draw2DRectangle(newCol, AbsoluteRect, &AbsoluteClippingRect); + } + + IGUIElement::draw(); +} + + + +//! Gets the color to fade out to or to fade in from. +video::SColor CGUIInOutFader::getColor() const +{ + return Color[1]; +} + + + +//! Sets the color to fade out to or to fade in from. +void CGUIInOutFader::setColor(video::SColor color) +{ + video::SColor s = color; + video::SColor d = color; + + s.setAlpha ( 255 ); + d.setAlpha ( 0 ); + setColor ( s,d ); + +/* + Color[0] = color; + + FullColor = Color[0]; + TransColor = Color[0]; + + if (Action == EFA_FADE_OUT) + { + FullColor.setAlpha(0); + TransColor.setAlpha(255); + } + else + if (Action == EFA_FADE_IN) + { + FullColor.setAlpha(255); + TransColor.setAlpha(0); + } +*/ +} + +void CGUIInOutFader::setColor(video::SColor source, video::SColor dest) +{ + Color[0] = source; + Color[1] = dest; + + if (Action == EFA_FADE_OUT) + { + FullColor = Color[1]; + TransColor = Color[0]; + } + else + if (Action == EFA_FADE_IN) + { + FullColor = Color[0]; + TransColor = Color[1]; + } + +} + + +//! Returns if the fade in or out process is done. +bool CGUIInOutFader::isReady() const +{ + u32 now = os::Timer::getTime(); + bool ret = (now > EndTime); + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return ret; +} + + + +//! Starts the fade in process. +void CGUIInOutFader::fadeIn(u32 time) +{ + StartTime = os::Timer::getTime(); + EndTime = StartTime + time; + Action = EFA_FADE_IN; + setColor(Color[0],Color[1]); +} + + +//! Starts the fade out process. +void CGUIInOutFader::fadeOut(u32 time) +{ + StartTime = os::Timer::getTime(); + EndTime = StartTime + time; + Action = EFA_FADE_OUT; + setColor(Color[0],Color[1]); +} + +//! Writes attributes of the element. +void CGUIInOutFader::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +{ + IGUIInOutFader::serializeAttributes(out,options); + + out->addColor ("FullColor", FullColor); + out->addColor ("TransColor", TransColor); + +} + +//! Reads attributes of the element +void CGUIInOutFader::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +{ + IGUIInOutFader::deserializeAttributes(in,options); + + FullColor = in->getAttributeAsColor("FullColor"); + TransColor = in->getAttributeAsColor("TransColor"); +} + + + +} // end namespace gui +} // end namespace irr diff --git a/src/dep/src/irrlicht/CGUIInOutFader.h b/src/dep/src/irrlicht/CGUIInOutFader.h index 72bcfe6..47b2281 100644 --- a/src/dep/src/irrlicht/CGUIInOutFader.h +++ b/src/dep/src/irrlicht/CGUIInOutFader.h @@ -1,74 +1,74 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_IN_OUT_FADER_H_INCLUDED__ -#define __C_GUI_IN_OUT_FADER_H_INCLUDED__ - -#include "IGUIInOutFader.h" - -namespace irr -{ -namespace gui -{ - - class CGUIInOutFader : public IGUIInOutFader - { - public: - - //! constructor - CGUIInOutFader(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect rectangle); - - //! destructor - ~CGUIInOutFader(); - - //! draws the element and its children - virtual void draw(); - - //! Gets the color to fade out to or to fade in from. - virtual video::SColor getColor() const; - - //! Sets the color to fade out to or to fade in from. - virtual void setColor(video::SColor color ); - virtual void setColor(video::SColor source, video::SColor dest); - - //! Starts the fade in process. - virtual void fadeIn(u32 time); - - //! Starts the fade out process. - virtual void fadeOut(u32 time); - - //! Returns if the fade in or out process is done. - virtual bool isReady() const; - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - enum EFadeAction - { - EFA_NOTHING = 0, - EFA_FADE_IN, - EFA_FADE_OUT - }; - - u32 StartTime; - u32 EndTime; - EFadeAction Action; - - video::SColor Color[2]; - video::SColor FullColor; - video::SColor TransColor; - - }; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_IN_OUT_FADER_H_INCLUDED__ +#define __C_GUI_IN_OUT_FADER_H_INCLUDED__ + +#include "IGUIInOutFader.h" + +namespace irr +{ +namespace gui +{ + + class CGUIInOutFader : public IGUIInOutFader + { + public: + + //! constructor + CGUIInOutFader(IGUIEnvironment* environment, IGUIElement* parent, + s32 id, core::rect rectangle); + + //! destructor + ~CGUIInOutFader(); + + //! draws the element and its children + virtual void draw(); + + //! Gets the color to fade out to or to fade in from. + virtual video::SColor getColor() const; + + //! Sets the color to fade out to or to fade in from. + virtual void setColor(video::SColor color ); + virtual void setColor(video::SColor source, video::SColor dest); + + //! Starts the fade in process. + virtual void fadeIn(u32 time); + + //! Starts the fade out process. + virtual void fadeOut(u32 time); + + //! Returns if the fade in or out process is done. + virtual bool isReady() const; + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + private: + + enum EFadeAction + { + EFA_NOTHING = 0, + EFA_FADE_IN, + EFA_FADE_OUT + }; + + u32 StartTime; + u32 EndTime; + EFadeAction Action; + + video::SColor Color[2]; + video::SColor FullColor; + video::SColor TransColor; + + }; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIListBox.cpp b/src/dep/src/irrlicht/CGUIListBox.cpp index a9ac6f9..b302c7a 100644 --- a/src/dep/src/irrlicht/CGUIListBox.cpp +++ b/src/dep/src/irrlicht/CGUIListBox.cpp @@ -1,464 +1,464 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIListBox.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIFont.h" -#include "IGUISpriteBank.h" -#include "CGUIScrollBar.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIListBox::CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect rectangle, bool clip, - bool drawBack, bool moveOverSelect) -: IGUIListBox(environment, parent, id, rectangle), Selected(-1), ItemHeight(0), - TotalItemHeight(0), ItemsIconWidth(0), Font(0), IconBank(0), - ScrollBar(0), Selecting(false), DrawBack(drawBack), - MoveOverSelect(moveOverSelect), selectTime(0) -{ - #ifdef _DEBUG - setDebugName("CGUIListBox"); - #endif - - IGUISkin* skin = Environment->getSkin(); - s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE); - - ScrollBar = new CGUIScrollBar(false, Environment, this, 0, - core::rect(RelativeRect.getWidth() - s, 0, RelativeRect.getWidth(), RelativeRect.getHeight()), - !clip); - ScrollBar->setSubElement(true); - ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - ScrollBar->drop(); - - ScrollBar->setPos(0); - ScrollBar->grab(); - - setNotClipped(!clip); - - updateAbsolutePosition(); -} - - -//! destructor -CGUIListBox::~CGUIListBox() -{ - if (ScrollBar) - ScrollBar->drop(); - - if (Font) - Font->drop(); - - if (IconBank) - IconBank->drop(); -} - - - -//! returns amount of list items -s32 CGUIListBox::getItemCount() -{ - return Items.size(); -} - - - -//! returns string of a list item. the may be a value from 0 to itemCount-1 -const wchar_t* CGUIListBox::getListItem(s32 id) -{ - if (id<0 || id>((s32)Items.size())-1) - return 0; - - return Items[id].text.c_str(); -} - - - -//! adds an list item, returns id of item -s32 CGUIListBox::addItem(const wchar_t* text) -{ - ListItem i; - i.text = text; - - Items.push_back(i); - recalculateItemHeight(); - return Items.size() - 1; -} - -//! adds an list item, returns id of item -void CGUIListBox::removeItem(s32 id) -{ - if (id < 0 || id >= (s32)Items.size()) - return; - - if (Selected==id) - { - Selected = -1; - } - else if (Selected > id) - { - Selected -= 1; - selectTime = os::Timer::getTime(); - } - - Items.erase(id); - - recalculateItemHeight(); -} - - - - -//! clears the list -void CGUIListBox::clear() -{ - Items.clear(); - ItemsIconWidth = 0; - Selected = -1; - - if (ScrollBar) - ScrollBar->setPos(0); - - recalculateItemHeight(); -} - - - -void CGUIListBox::recalculateItemHeight() -{ - IGUISkin* skin = Environment->getSkin(); - - if (Font != skin->getFont()) - { - if (Font) - Font->drop(); - - Font = skin->getFont(); - ItemHeight = 0; - - if (Font) - { - ItemHeight = Font->getDimension(L"A").Height + 4; - Font->grab(); - } - } - - TotalItemHeight = ItemHeight * Items.size(); - ScrollBar->setMax(TotalItemHeight - AbsoluteRect.getHeight()); -} - - - -//! returns id of selected item. returns -1 if no item is selected. -s32 CGUIListBox::getSelected() -{ - return Selected; -} - - - -//! sets the selected item. Set this to -1 if no item should be selected -void CGUIListBox::setSelected(s32 id) -{ - if (id<0 || id>((s32)Items.size())-1) - Selected = -1; - else - Selected = id; - - selectTime = os::Timer::getTime(); -} - - - -//! called if an event happened. -bool CGUIListBox::OnEvent(SEvent event) -{ - switch(event.EventType) - { - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case gui::EGET_SCROLL_BAR_CHANGED: - if (event.GUIEvent.Caller == ScrollBar) - { -// s32 pos = ((gui::IGUIScrollBar*)event.GUIEvent.Caller)->getPos(); - return true; - } - break; - case gui::EGET_ELEMENT_FOCUS_LOST: - { - if (event.GUIEvent.Caller == (IGUIElement*)this) - Selecting = false; - } - } - break; - case EET_MOUSE_INPUT_EVENT: - { - core::position2d p(event.MouseInput.X, event.MouseInput.Y); - - switch(event.MouseInput.Event) - { - case EMIE_MOUSE_WHEEL: - ScrollBar->setPos(ScrollBar->getPos() + (s32)event.MouseInput.Wheel*-10); - return true; - - case EMIE_LMOUSE_PRESSED_DOWN: - { - IGUIElement *el = Environment->getRootGUIElement()->getElementFromPoint( - core::position2di(event.MouseInput.X, event.MouseInput.Y)); - - if (Environment->hasFocus(this) && - ScrollBar == el && - ScrollBar->OnEvent(event)) - return true; - } - - Selecting = true; - Environment->setFocus(this); - return true; - - case EMIE_LMOUSE_LEFT_UP: - if (Environment->hasFocus(this) && - ScrollBar->getAbsolutePosition().isPointInside(p) && - ScrollBar->OnEvent(event)) - return true; - - Selecting = false; - Environment->removeFocus(this); - selectNew(event.MouseInput.Y); - return true; - - case EMIE_MOUSE_MOVED: - if (Selecting || MoveOverSelect) - { - if (getAbsolutePosition().isPointInside(p)) - { - selectNew(event.MouseInput.Y, true); - return true; - } - } - } - } - break; - } - - - return Parent ? Parent->OnEvent(event) : false; -} - - -void CGUIListBox::selectNew(s32 ypos, bool onlyHover) -{ - s32 oldSelected = Selected; - - // find new selected item. - if (ItemHeight!=0) - Selected = ((ypos - AbsoluteRect.UpperLeftCorner.Y - 1) + ScrollBar->getPos()) / ItemHeight; - - if (Selected >= (s32)Items.size()) - Selected = Items.size() - 1; - else - if (Selected<0) - Selected = 0; - - // post the news - - if (Parent && !onlyHover) - { - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.EventType = (Selected != oldSelected) ? EGET_LISTBOX_CHANGED : EGET_LISTBOX_SELECTED_AGAIN; - Parent->OnEvent(event); - } -} - -//! Update the position and size of the listbox, and update the scrollbar -void CGUIListBox::updateAbsolutePosition() -{ - recalculateItemHeight(); - - IGUIElement::updateAbsolutePosition(); -} - -//! draws the element and its children -void CGUIListBox::draw() -{ - if (!IsVisible) - return; - - recalculateItemHeight(); // if the font changed - - IGUISkin* skin = Environment->getSkin(); - irr::video::IVideoDriver* driver = Environment->getVideoDriver(); - - core::rect* clipRect = 0; - - // draw background - core::rect frameRect(AbsoluteRect); - - skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), true, - DrawBack, frameRect, clipRect); - - // draw items - - core::rect clientClip(AbsoluteRect); - clientClip.UpperLeftCorner.Y += 1; - clientClip.UpperLeftCorner.X += 1; - clientClip.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE); - clientClip.LowerRightCorner.Y -= 1; - clientClip.clipAgainst(AbsoluteClippingRect); - - if (clipRect) - clientClip.clipAgainst(*clipRect); - - frameRect = AbsoluteRect; - frameRect.UpperLeftCorner.X += 1; - frameRect.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE); - frameRect.LowerRightCorner.Y = AbsoluteRect.UpperLeftCorner.Y + ItemHeight; - - frameRect.UpperLeftCorner.Y -= ScrollBar->getPos(); - frameRect.LowerRightCorner.Y -= ScrollBar->getPos(); - - for (s32 i=0; i<(s32)Items.size(); ++i) - { - if (frameRect.LowerRightCorner.Y >= AbsoluteRect.UpperLeftCorner.Y && - frameRect.UpperLeftCorner.Y <= AbsoluteRect.LowerRightCorner.Y) - { - if (i == Selected) - driver->draw2DRectangle(skin->getColor(EGDC_HIGH_LIGHT), frameRect, &clientClip); - - core::rect textRect = frameRect; - textRect.UpperLeftCorner.X += 3; - - if (Font) - { - if (IconBank && (Items[i].icon > -1)) - { - core::position2di iconPos = textRect.UpperLeftCorner; - iconPos.Y += textRect.getHeight() / 2; - iconPos.X += ItemsIconWidth/2; - IconBank->draw2DSprite( (u32)Items[i].icon, iconPos, &clientClip, - skin->getColor((i==Selected) ? EGDC_ICON_HIGH_LIGHT : EGDC_ICON), - (i==Selected) ? selectTime : 0 , (i==Selected) ? os::Timer::getTime() : 0, false, true); - } - - textRect.UpperLeftCorner.X += ItemsIconWidth+3; - - Font->draw(Items[i].text.c_str(), textRect, skin->getColor((i==Selected) ? EGDC_HIGH_LIGHT_TEXT : EGDC_BUTTON_TEXT), false, true, &clientClip); - - textRect.UpperLeftCorner.X -= ItemsIconWidth+3; - } - } - - frameRect.UpperLeftCorner.Y += ItemHeight; - frameRect.LowerRightCorner.Y += ItemHeight; - } - - IGUIElement::draw(); -} - - - -//! adds an list item with an icon -s32 CGUIListBox::addItem(const wchar_t* text, s32 icon) -{ - ListItem i; - i.text = text; - i.icon = icon; - - Items.push_back(i); - recalculateItemHeight(); - - if (IconBank && icon > -1 && - IconBank->getSprites().size() > (u32)icon && - IconBank->getSprites()[(u32)icon].Frames.size()) - { - u32 rno = IconBank->getSprites()[(u32)icon].Frames[0].rectNumber; - if (IconBank->getPositions().size() > rno) - { - s32 w = IconBank->getPositions()[rno].getWidth(); - if (w > ItemsIconWidth) - ItemsIconWidth = w; - } - } - - return Items.size() - 1; -} - - -void CGUIListBox::setSpriteBank(IGUISpriteBank* bank) -{ - if (IconBank) - IconBank->drop(); - - IconBank = bank; - if (IconBank) - IconBank->grab(); -} - - -//! Writes attributes of the element. -void CGUIListBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) -{ - IGUIListBox::serializeAttributes(out,options); - - // todo: out->addString ("IconBank", IconBank->getName?); - out->addBool ("DrawBack", DrawBack); - out->addBool ("MoveOverSelect", MoveOverSelect); - - // todo: save list of items and icons. - /*core::array tmpText; - core::array tmpIcons; - u32 i; - for (i=0;iaddArray ("ItemText", tmpText); - out->addArray ("ItemIcons", tmpIcons); - - out->addInt ("Selected", Selected); - */ - -} - -//! Reads attributes of the element -void CGUIListBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - DrawBack = in->getAttributeAsBool("DrawBack"); - MoveOverSelect = in->getAttributeAsBool("MoveOverSelect"); - - IGUIListBox::deserializeAttributes(in,options); - - // read arrays - /* - core::array tmpText; - core::array tmpIcons; - - tmpText = in->getAttributeAsArray("ItemText"); - tmpIcons = in->getAttributeAsArray("ItemIcons"); - u32 i; - for (i=0; isetSelected(in->getAttributeAsInt("Selected")); - */ - -} - - - -} // end namespace gui -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIListBox.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUIFont.h" +#include "IGUISpriteBank.h" +#include "CGUIScrollBar.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIListBox::CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent, + s32 id, core::rect rectangle, bool clip, + bool drawBack, bool moveOverSelect) +: IGUIListBox(environment, parent, id, rectangle), Selected(-1), ItemHeight(0), + TotalItemHeight(0), ItemsIconWidth(0), Font(0), IconBank(0), + ScrollBar(0), Selecting(false), DrawBack(drawBack), + MoveOverSelect(moveOverSelect), selectTime(0) +{ + #ifdef _DEBUG + setDebugName("CGUIListBox"); + #endif + + IGUISkin* skin = Environment->getSkin(); + s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE); + + ScrollBar = new CGUIScrollBar(false, Environment, this, 0, + core::rect(RelativeRect.getWidth() - s, 0, RelativeRect.getWidth(), RelativeRect.getHeight()), + !clip); + ScrollBar->setSubElement(true); + ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + ScrollBar->drop(); + + ScrollBar->setPos(0); + ScrollBar->grab(); + + setNotClipped(!clip); + + updateAbsolutePosition(); +} + + +//! destructor +CGUIListBox::~CGUIListBox() +{ + if (ScrollBar) + ScrollBar->drop(); + + if (Font) + Font->drop(); + + if (IconBank) + IconBank->drop(); +} + + + +//! returns amount of list items +s32 CGUIListBox::getItemCount() +{ + return Items.size(); +} + + + +//! returns string of a list item. the may be a value from 0 to itemCount-1 +const wchar_t* CGUIListBox::getListItem(s32 id) +{ + if (id<0 || id>((s32)Items.size())-1) + return 0; + + return Items[id].text.c_str(); +} + + + +//! adds an list item, returns id of item +s32 CGUIListBox::addItem(const wchar_t* text) +{ + ListItem i; + i.text = text; + + Items.push_back(i); + recalculateItemHeight(); + return Items.size() - 1; +} + +//! adds an list item, returns id of item +void CGUIListBox::removeItem(s32 id) +{ + if (id < 0 || id >= (s32)Items.size()) + return; + + if (Selected==id) + { + Selected = -1; + } + else if (Selected > id) + { + Selected -= 1; + selectTime = os::Timer::getTime(); + } + + Items.erase(id); + + recalculateItemHeight(); +} + + + + +//! clears the list +void CGUIListBox::clear() +{ + Items.clear(); + ItemsIconWidth = 0; + Selected = -1; + + if (ScrollBar) + ScrollBar->setPos(0); + + recalculateItemHeight(); +} + + + +void CGUIListBox::recalculateItemHeight() +{ + IGUISkin* skin = Environment->getSkin(); + + if (Font != skin->getFont()) + { + if (Font) + Font->drop(); + + Font = skin->getFont(); + ItemHeight = 0; + + if (Font) + { + ItemHeight = Font->getDimension(L"A").Height + 4; + Font->grab(); + } + } + + TotalItemHeight = ItemHeight * Items.size(); + ScrollBar->setMax(TotalItemHeight - AbsoluteRect.getHeight()); +} + + + +//! returns id of selected item. returns -1 if no item is selected. +s32 CGUIListBox::getSelected() +{ + return Selected; +} + + + +//! sets the selected item. Set this to -1 if no item should be selected +void CGUIListBox::setSelected(s32 id) +{ + if (id<0 || id>((s32)Items.size())-1) + Selected = -1; + else + Selected = id; + + selectTime = os::Timer::getTime(); +} + + + +//! called if an event happened. +bool CGUIListBox::OnEvent(SEvent event) +{ + switch(event.EventType) + { + case EET_GUI_EVENT: + switch(event.GUIEvent.EventType) + { + case gui::EGET_SCROLL_BAR_CHANGED: + if (event.GUIEvent.Caller == ScrollBar) + { +// s32 pos = ((gui::IGUIScrollBar*)event.GUIEvent.Caller)->getPos(); + return true; + } + break; + case gui::EGET_ELEMENT_FOCUS_LOST: + { + if (event.GUIEvent.Caller == (IGUIElement*)this) + Selecting = false; + } + } + break; + case EET_MOUSE_INPUT_EVENT: + { + core::position2d p(event.MouseInput.X, event.MouseInput.Y); + + switch(event.MouseInput.Event) + { + case EMIE_MOUSE_WHEEL: + ScrollBar->setPos(ScrollBar->getPos() + (s32)event.MouseInput.Wheel*-10); + return true; + + case EMIE_LMOUSE_PRESSED_DOWN: + { + IGUIElement *el = Environment->getRootGUIElement()->getElementFromPoint( + core::position2di(event.MouseInput.X, event.MouseInput.Y)); + + if (Environment->hasFocus(this) && + ScrollBar == el && + ScrollBar->OnEvent(event)) + return true; + } + + Selecting = true; + Environment->setFocus(this); + return true; + + case EMIE_LMOUSE_LEFT_UP: + if (Environment->hasFocus(this) && + ScrollBar->getAbsolutePosition().isPointInside(p) && + ScrollBar->OnEvent(event)) + return true; + + Selecting = false; + Environment->removeFocus(this); + selectNew(event.MouseInput.Y); + return true; + + case EMIE_MOUSE_MOVED: + if (Selecting || MoveOverSelect) + { + if (getAbsolutePosition().isPointInside(p)) + { + selectNew(event.MouseInput.Y, true); + return true; + } + } + } + } + break; + } + + + return Parent ? Parent->OnEvent(event) : false; +} + + +void CGUIListBox::selectNew(s32 ypos, bool onlyHover) +{ + s32 oldSelected = Selected; + + // find new selected item. + if (ItemHeight!=0) + Selected = ((ypos - AbsoluteRect.UpperLeftCorner.Y - 1) + ScrollBar->getPos()) / ItemHeight; + + if (Selected >= (s32)Items.size()) + Selected = Items.size() - 1; + else + if (Selected<0) + Selected = 0; + + // post the news + + if (Parent && !onlyHover) + { + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.EventType = (Selected != oldSelected) ? EGET_LISTBOX_CHANGED : EGET_LISTBOX_SELECTED_AGAIN; + Parent->OnEvent(event); + } +} + +//! Update the position and size of the listbox, and update the scrollbar +void CGUIListBox::updateAbsolutePosition() +{ + recalculateItemHeight(); + + IGUIElement::updateAbsolutePosition(); +} + +//! draws the element and its children +void CGUIListBox::draw() +{ + if (!IsVisible) + return; + + recalculateItemHeight(); // if the font changed + + IGUISkin* skin = Environment->getSkin(); + irr::video::IVideoDriver* driver = Environment->getVideoDriver(); + + core::rect* clipRect = 0; + + // draw background + core::rect frameRect(AbsoluteRect); + + skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), true, + DrawBack, frameRect, clipRect); + + // draw items + + core::rect clientClip(AbsoluteRect); + clientClip.UpperLeftCorner.Y += 1; + clientClip.UpperLeftCorner.X += 1; + clientClip.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE); + clientClip.LowerRightCorner.Y -= 1; + clientClip.clipAgainst(AbsoluteClippingRect); + + if (clipRect) + clientClip.clipAgainst(*clipRect); + + frameRect = AbsoluteRect; + frameRect.UpperLeftCorner.X += 1; + frameRect.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE); + frameRect.LowerRightCorner.Y = AbsoluteRect.UpperLeftCorner.Y + ItemHeight; + + frameRect.UpperLeftCorner.Y -= ScrollBar->getPos(); + frameRect.LowerRightCorner.Y -= ScrollBar->getPos(); + + for (s32 i=0; i<(s32)Items.size(); ++i) + { + if (frameRect.LowerRightCorner.Y >= AbsoluteRect.UpperLeftCorner.Y && + frameRect.UpperLeftCorner.Y <= AbsoluteRect.LowerRightCorner.Y) + { + if (i == Selected) + driver->draw2DRectangle(skin->getColor(EGDC_HIGH_LIGHT), frameRect, &clientClip); + + core::rect textRect = frameRect; + textRect.UpperLeftCorner.X += 3; + + if (Font) + { + if (IconBank && (Items[i].icon > -1)) + { + core::position2di iconPos = textRect.UpperLeftCorner; + iconPos.Y += textRect.getHeight() / 2; + iconPos.X += ItemsIconWidth/2; + IconBank->draw2DSprite( (u32)Items[i].icon, iconPos, &clientClip, + skin->getColor((i==Selected) ? EGDC_ICON_HIGH_LIGHT : EGDC_ICON), + (i==Selected) ? selectTime : 0 , (i==Selected) ? os::Timer::getTime() : 0, false, true); + } + + textRect.UpperLeftCorner.X += ItemsIconWidth+3; + + Font->draw(Items[i].text.c_str(), textRect, skin->getColor((i==Selected) ? EGDC_HIGH_LIGHT_TEXT : EGDC_BUTTON_TEXT), false, true, &clientClip); + + textRect.UpperLeftCorner.X -= ItemsIconWidth+3; + } + } + + frameRect.UpperLeftCorner.Y += ItemHeight; + frameRect.LowerRightCorner.Y += ItemHeight; + } + + IGUIElement::draw(); +} + + + +//! adds an list item with an icon +s32 CGUIListBox::addItem(const wchar_t* text, s32 icon) +{ + ListItem i; + i.text = text; + i.icon = icon; + + Items.push_back(i); + recalculateItemHeight(); + + if (IconBank && icon > -1 && + IconBank->getSprites().size() > (u32)icon && + IconBank->getSprites()[(u32)icon].Frames.size()) + { + u32 rno = IconBank->getSprites()[(u32)icon].Frames[0].rectNumber; + if (IconBank->getPositions().size() > rno) + { + s32 w = IconBank->getPositions()[rno].getWidth(); + if (w > ItemsIconWidth) + ItemsIconWidth = w; + } + } + + return Items.size() - 1; +} + + +void CGUIListBox::setSpriteBank(IGUISpriteBank* bank) +{ + if (IconBank) + IconBank->drop(); + + IconBank = bank; + if (IconBank) + IconBank->grab(); +} + + +//! Writes attributes of the element. +void CGUIListBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +{ + IGUIListBox::serializeAttributes(out,options); + + // todo: out->addString ("IconBank", IconBank->getName?); + out->addBool ("DrawBack", DrawBack); + out->addBool ("MoveOverSelect", MoveOverSelect); + + // todo: save list of items and icons. + /*core::array tmpText; + core::array tmpIcons; + u32 i; + for (i=0;iaddArray ("ItemText", tmpText); + out->addArray ("ItemIcons", tmpIcons); + + out->addInt ("Selected", Selected); + */ + +} + +//! Reads attributes of the element +void CGUIListBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +{ + DrawBack = in->getAttributeAsBool("DrawBack"); + MoveOverSelect = in->getAttributeAsBool("MoveOverSelect"); + + IGUIListBox::deserializeAttributes(in,options); + + // read arrays + /* + core::array tmpText; + core::array tmpIcons; + + tmpText = in->getAttributeAsArray("ItemText"); + tmpIcons = in->getAttributeAsArray("ItemIcons"); + u32 i; + for (i=0; isetSelected(in->getAttributeAsInt("Selected")); + */ + +} + + + +} // end namespace gui +} // end namespace irr diff --git a/src/dep/src/irrlicht/CGUIListBox.h b/src/dep/src/irrlicht/CGUIListBox.h index f20d568..91034e4 100644 --- a/src/dep/src/irrlicht/CGUIListBox.h +++ b/src/dep/src/irrlicht/CGUIListBox.h @@ -1,112 +1,112 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_LIST_BOX_BAR_H_INCLUDED__ -#define __C_GUI_LIST_BOX_BAR_H_INCLUDED__ - -#include "IGUIListBox.h" -#include "irrArray.h" - -namespace irr -{ -namespace gui -{ - - class IGUIFont; - class IGUIScrollBar; - - class CGUIListBox : public IGUIListBox - { - public: - - //! constructor - CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect rectangle, bool clip=true, - bool drawBack=false, bool moveOverSelect=false); - - //! destructor - ~CGUIListBox(); - - //! returns amount of list items - virtual s32 getItemCount(); - - //! returns string of a list item. the may be a value from 0 to itemCount-1 - virtual const wchar_t* getListItem(s32 id); - - //! adds an list item, returns id of item - virtual s32 addItem(const wchar_t* text); - - //! clears the list - virtual void clear(); - - //! returns id of selected item. returns -1 if no item is selected. - virtual s32 getSelected(); - - //! sets the selected item. Set this to -1 if no item should be selected - virtual void setSelected(s32 id); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! draws the element and its children - virtual void draw(); - - //! adds an list item with an icon - //! \param text Text of list entry - //! \param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon - //! \return - //! returns the id of the new created item - virtual s32 addItem(const wchar_t* text, s32 icon); - - //! removes an item from the list - virtual void removeItem(s32 id); - - //! Sets the sprite bank which should be used to draw list icons. This font is set to the sprite bank of - //! the built-in-font by default. A sprite can be displayed in front of every list item. - //! An icon is an index within the icon sprite bank. Several default icons are available in the - //! skin through getIcon - virtual void setSpriteBank(IGUISpriteBank* bank); - - //! Update the position and size of the listbox, and update the scrollbar - virtual void updateAbsolutePosition(); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - struct ListItem - { - ListItem() : icon(-1) {} - - core::stringw text; - s32 icon; - }; - - void recalculateItemHeight(); - void selectNew(s32 ypos, bool onlyHover=false); - - core::array< ListItem > Items; - s32 Selected; - s32 ItemHeight; - s32 TotalItemHeight; - s32 ItemsIconWidth; - gui::IGUIFont* Font; - gui::IGUISpriteBank* IconBank; - gui::IGUIScrollBar* ScrollBar; - bool Selecting; - bool DrawBack; - bool MoveOverSelect; - u32 selectTime; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_LIST_BOX_BAR_H_INCLUDED__ +#define __C_GUI_LIST_BOX_BAR_H_INCLUDED__ + +#include "IGUIListBox.h" +#include "irrArray.h" + +namespace irr +{ +namespace gui +{ + + class IGUIFont; + class IGUIScrollBar; + + class CGUIListBox : public IGUIListBox + { + public: + + //! constructor + CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent, + s32 id, core::rect rectangle, bool clip=true, + bool drawBack=false, bool moveOverSelect=false); + + //! destructor + ~CGUIListBox(); + + //! returns amount of list items + virtual s32 getItemCount(); + + //! returns string of a list item. the may be a value from 0 to itemCount-1 + virtual const wchar_t* getListItem(s32 id); + + //! adds an list item, returns id of item + virtual s32 addItem(const wchar_t* text); + + //! clears the list + virtual void clear(); + + //! returns id of selected item. returns -1 if no item is selected. + virtual s32 getSelected(); + + //! sets the selected item. Set this to -1 if no item should be selected + virtual void setSelected(s32 id); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! draws the element and its children + virtual void draw(); + + //! adds an list item with an icon + //! \param text Text of list entry + //! \param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon + //! \return + //! returns the id of the new created item + virtual s32 addItem(const wchar_t* text, s32 icon); + + //! removes an item from the list + virtual void removeItem(s32 id); + + //! Sets the sprite bank which should be used to draw list icons. This font is set to the sprite bank of + //! the built-in-font by default. A sprite can be displayed in front of every list item. + //! An icon is an index within the icon sprite bank. Several default icons are available in the + //! skin through getIcon + virtual void setSpriteBank(IGUISpriteBank* bank); + + //! Update the position and size of the listbox, and update the scrollbar + virtual void updateAbsolutePosition(); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + private: + + struct ListItem + { + ListItem() : icon(-1) {} + + core::stringw text; + s32 icon; + }; + + void recalculateItemHeight(); + void selectNew(s32 ypos, bool onlyHover=false); + + core::array< ListItem > Items; + s32 Selected; + s32 ItemHeight; + s32 TotalItemHeight; + s32 ItemsIconWidth; + gui::IGUIFont* Font; + gui::IGUISpriteBank* IconBank; + gui::IGUIScrollBar* ScrollBar; + bool Selecting; + bool DrawBack; + bool MoveOverSelect; + u32 selectTime; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIMenu.cpp b/src/dep/src/irrlicht/CGUIMenu.cpp index f5f1c84..bbad1c9 100644 --- a/src/dep/src/irrlicht/CGUIMenu.cpp +++ b/src/dep/src/irrlicht/CGUIMenu.cpp @@ -1,248 +1,248 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIMenu.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIFont.h" - -#include "os.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIMenu::CGUIMenu(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect rectangle) - : CGUIContextMenu(environment, parent, id, rectangle, false) -{ - #ifdef _DEBUG - setDebugName("CGUIMenu"); - #endif - - Type = EGUIET_MENU; - - recalculateSize(); -} - - -//! destructor -CGUIMenu::~CGUIMenu() -{ - -} - -//! draws the element and its children -void CGUIMenu::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - IGUIFont* font = skin->getFont(); - - core::rect rect = AbsoluteRect; - - // draw frame - - skin->draw3DToolBar(this, rect, &AbsoluteClippingRect); - - // loop through all menu items - - rect = AbsoluteRect; - - for (s32 i=0; i<(s32)Items.size(); ++i) - { - if (!Items[i].IsSeparator) - { - rect = getRect(Items[i], AbsoluteRect); - - // draw highlighted - if (i == HighLighted && Items[i].Enabled) - { - skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_DARK_SHADOW), - true, true, rect, &AbsoluteClippingRect); - } - // draw text - - EGUI_DEFAULT_COLOR c = EGDC_BUTTON_TEXT; - - if (i == HighLighted) - c = EGDC_HIGH_LIGHT_TEXT; - - if (!Items[i].Enabled) - c = EGDC_GRAY_TEXT; - - if (font) - font->draw(Items[i].Text.c_str(), rect, - skin->getColor(c), true, true, &AbsoluteClippingRect); - } - } - - IGUIElement::draw(); -} - - -//! called if an event happened. -bool CGUIMenu::OnEvent(SEvent event) -{ - if (!IsEnabled) - return Parent ? Parent->OnEvent(event) : false; - - switch(event.EventType) - { - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case gui::EGET_ELEMENT_FOCUS_LOST: - if (event.GUIEvent.Caller == (IGUIElement*)this) - closeAllSubMenus(); - return true; - } - break; - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_LEFT_UP: - { - core::position2d p(event.MouseInput.X, event.MouseInput.Y); - if (AbsoluteClippingRect.isPointInside(p)) - { - if (HighLighted != -1) - Environment->removeFocus(this); - else - highlight(core::position2d(event.MouseInput.X, event.MouseInput.Y)); - } - else - { - s32 t = sendClick(p); - if ((t==0 || t==1) && Environment->hasFocus(this)) - Environment->removeFocus(this); - } - } - return true; - case EMIE_LMOUSE_PRESSED_DOWN: - if (!Environment->hasFocus(this)) - { - Environment->setFocus(this); - if (Parent) - Parent->bringToFront(this); - } - return true; - case EMIE_MOUSE_MOVED: - if (Environment->hasFocus(this)) - highlight(core::position2d(event.MouseInput.X, event.MouseInput.Y)); - return true; - } - break; - } - - return Parent ? Parent->OnEvent(event) : false; -} - - -void CGUIMenu::recalculateSize() -{ - IGUISkin* skin = Environment->getSkin(); - IGUIFont* font = skin->getFont(); - - if (!font) - { - if (Parent && skin) - RelativeRect = core::rect(0,0, - Parent->getAbsolutePosition().LowerRightCorner.X, - skin->getSize(EGDS_MENU_HEIGHT)); - return; - } - - core::rect rect; - rect.UpperLeftCorner.X = 0; - rect.UpperLeftCorner.Y = 0; - s32 height = font->getDimension(L"A").Height + 5; - //if (skin && height < skin->getSize ( EGDS_MENU_HEIGHT )) - // height = skin->getSize(EGDS_MENU_HEIGHT); - s32 width = 0; - s32 i; - - for (i=0; i<(s32)Items.size(); ++i) - { - if (Items[i].IsSeparator) - { - Items[i].Dim.Width = 0; - Items[i].Dim.Height = height; - } - else - { - Items[i].Dim = font->getDimension(Items[i].Text.c_str()); - Items[i].Dim.Width += 20; - } - - Items[i].PosY = width; - width += Items[i].Dim.Width; - } - - if (Parent) - width = Parent->getAbsolutePosition().getWidth(); - - rect.LowerRightCorner.X = width; - rect.LowerRightCorner.Y = height; - - setRelativePosition(rect); - - // recalculate submenus - for (i=0; i<(s32)Items.size(); ++i) - if (Items[i].SubMenu) - { - // move submenu - s32 w = Items[i].SubMenu->getAbsolutePosition().getWidth(); - s32 h = Items[i].SubMenu->getAbsolutePosition().getHeight(); - - Items[i].SubMenu->setRelativePosition( - core::rect(Items[i].PosY, height , - Items[i].PosY+w-5, height+h)); - } -} - - -//! returns the item highlight-area -core::rect CGUIMenu::getHRect(const SItem& i, const core::rect& absolute) -{ - core::rect r = absolute; - r.UpperLeftCorner.X += i.PosY; - r.LowerRightCorner.X = r.UpperLeftCorner.X + i.Dim.Width; - return r; -} - -//! Gets drawing rect of Item -core::rect CGUIMenu::getRect(const SItem& i, const core::rect& absolute) -{ - return getHRect(i, absolute); -} - - -void CGUIMenu::closeAllSubMenus() -{ - for (s32 i=0; i<(s32)Items.size(); ++i) - if (Items[i].SubMenu) - Items[i].SubMenu->setVisible(false); - - HighLighted = -1; -} - - -void CGUIMenu::updateAbsolutePosition() -{ - if (Parent) - RelativeRect.LowerRightCorner.X = Parent->getAbsolutePosition().getWidth(); - - IGUIElement::updateAbsolutePosition(); -} - - -} // end namespace -} // end namespace - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIMenu.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUIFont.h" + +#include "os.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIMenu::CGUIMenu(IGUIEnvironment* environment, IGUIElement* parent, + s32 id, core::rect rectangle) + : CGUIContextMenu(environment, parent, id, rectangle, false) +{ + #ifdef _DEBUG + setDebugName("CGUIMenu"); + #endif + + Type = EGUIET_MENU; + + recalculateSize(); +} + + +//! destructor +CGUIMenu::~CGUIMenu() +{ + +} + +//! draws the element and its children +void CGUIMenu::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + IGUIFont* font = skin->getFont(); + + core::rect rect = AbsoluteRect; + + // draw frame + + skin->draw3DToolBar(this, rect, &AbsoluteClippingRect); + + // loop through all menu items + + rect = AbsoluteRect; + + for (s32 i=0; i<(s32)Items.size(); ++i) + { + if (!Items[i].IsSeparator) + { + rect = getRect(Items[i], AbsoluteRect); + + // draw highlighted + if (i == HighLighted && Items[i].Enabled) + { + skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_DARK_SHADOW), + true, true, rect, &AbsoluteClippingRect); + } + // draw text + + EGUI_DEFAULT_COLOR c = EGDC_BUTTON_TEXT; + + if (i == HighLighted) + c = EGDC_HIGH_LIGHT_TEXT; + + if (!Items[i].Enabled) + c = EGDC_GRAY_TEXT; + + if (font) + font->draw(Items[i].Text.c_str(), rect, + skin->getColor(c), true, true, &AbsoluteClippingRect); + } + } + + IGUIElement::draw(); +} + + +//! called if an event happened. +bool CGUIMenu::OnEvent(SEvent event) +{ + if (!IsEnabled) + return Parent ? Parent->OnEvent(event) : false; + + switch(event.EventType) + { + case EET_GUI_EVENT: + switch(event.GUIEvent.EventType) + { + case gui::EGET_ELEMENT_FOCUS_LOST: + if (event.GUIEvent.Caller == (IGUIElement*)this) + closeAllSubMenus(); + return true; + } + break; + case EET_MOUSE_INPUT_EVENT: + switch(event.MouseInput.Event) + { + case EMIE_LMOUSE_LEFT_UP: + { + core::position2d p(event.MouseInput.X, event.MouseInput.Y); + if (AbsoluteClippingRect.isPointInside(p)) + { + if (HighLighted != -1) + Environment->removeFocus(this); + else + highlight(core::position2d(event.MouseInput.X, event.MouseInput.Y)); + } + else + { + s32 t = sendClick(p); + if ((t==0 || t==1) && Environment->hasFocus(this)) + Environment->removeFocus(this); + } + } + return true; + case EMIE_LMOUSE_PRESSED_DOWN: + if (!Environment->hasFocus(this)) + { + Environment->setFocus(this); + if (Parent) + Parent->bringToFront(this); + } + return true; + case EMIE_MOUSE_MOVED: + if (Environment->hasFocus(this)) + highlight(core::position2d(event.MouseInput.X, event.MouseInput.Y)); + return true; + } + break; + } + + return Parent ? Parent->OnEvent(event) : false; +} + + +void CGUIMenu::recalculateSize() +{ + IGUISkin* skin = Environment->getSkin(); + IGUIFont* font = skin->getFont(); + + if (!font) + { + if (Parent && skin) + RelativeRect = core::rect(0,0, + Parent->getAbsolutePosition().LowerRightCorner.X, + skin->getSize(EGDS_MENU_HEIGHT)); + return; + } + + core::rect rect; + rect.UpperLeftCorner.X = 0; + rect.UpperLeftCorner.Y = 0; + s32 height = font->getDimension(L"A").Height + 5; + //if (skin && height < skin->getSize ( EGDS_MENU_HEIGHT )) + // height = skin->getSize(EGDS_MENU_HEIGHT); + s32 width = 0; + s32 i; + + for (i=0; i<(s32)Items.size(); ++i) + { + if (Items[i].IsSeparator) + { + Items[i].Dim.Width = 0; + Items[i].Dim.Height = height; + } + else + { + Items[i].Dim = font->getDimension(Items[i].Text.c_str()); + Items[i].Dim.Width += 20; + } + + Items[i].PosY = width; + width += Items[i].Dim.Width; + } + + if (Parent) + width = Parent->getAbsolutePosition().getWidth(); + + rect.LowerRightCorner.X = width; + rect.LowerRightCorner.Y = height; + + setRelativePosition(rect); + + // recalculate submenus + for (i=0; i<(s32)Items.size(); ++i) + if (Items[i].SubMenu) + { + // move submenu + s32 w = Items[i].SubMenu->getAbsolutePosition().getWidth(); + s32 h = Items[i].SubMenu->getAbsolutePosition().getHeight(); + + Items[i].SubMenu->setRelativePosition( + core::rect(Items[i].PosY, height , + Items[i].PosY+w-5, height+h)); + } +} + + +//! returns the item highlight-area +core::rect CGUIMenu::getHRect(const SItem& i, const core::rect& absolute) +{ + core::rect r = absolute; + r.UpperLeftCorner.X += i.PosY; + r.LowerRightCorner.X = r.UpperLeftCorner.X + i.Dim.Width; + return r; +} + +//! Gets drawing rect of Item +core::rect CGUIMenu::getRect(const SItem& i, const core::rect& absolute) +{ + return getHRect(i, absolute); +} + + +void CGUIMenu::closeAllSubMenus() +{ + for (s32 i=0; i<(s32)Items.size(); ++i) + if (Items[i].SubMenu) + Items[i].SubMenu->setVisible(false); + + HighLighted = -1; +} + + +void CGUIMenu::updateAbsolutePosition() +{ + if (Parent) + RelativeRect.LowerRightCorner.X = Parent->getAbsolutePosition().getWidth(); + + IGUIElement::updateAbsolutePosition(); +} + + +} // end namespace +} // end namespace + diff --git a/src/dep/src/irrlicht/CGUIMenu.h b/src/dep/src/irrlicht/CGUIMenu.h index bf94dfd..00891b6 100644 --- a/src/dep/src/irrlicht/CGUIMenu.h +++ b/src/dep/src/irrlicht/CGUIMenu.h @@ -1,53 +1,53 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_MENU_H_INCLUDED__ -#define __C_GUI_MENU_H_INCLUDED__ - -#include "CGUIContextMenu.h" - -namespace irr -{ -namespace gui -{ - - //! GUI menu interface. - class CGUIMenu : public CGUIContextMenu - { - public: - - //! constructor - CGUIMenu(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle); - - //! destructor - ~CGUIMenu(); - - //! draws the element and its children - virtual void draw(); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! Updates the absolute position. - virtual void updateAbsolutePosition(); - - protected: - - virtual void recalculateSize(); - - //! returns the item highlight-area - virtual core::rect getHRect(const SItem& i, const core::rect& absolute); - - //! Gets drawing rect of Item - virtual core::rect getRect(const SItem& i, const core::rect& absolute); - - void closeAllSubMenus(); - - }; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_MENU_H_INCLUDED__ +#define __C_GUI_MENU_H_INCLUDED__ + +#include "CGUIContextMenu.h" + +namespace irr +{ +namespace gui +{ + + //! GUI menu interface. + class CGUIMenu : public CGUIContextMenu + { + public: + + //! constructor + CGUIMenu(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle); + + //! destructor + ~CGUIMenu(); + + //! draws the element and its children + virtual void draw(); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! Updates the absolute position. + virtual void updateAbsolutePosition(); + + protected: + + virtual void recalculateSize(); + + //! returns the item highlight-area + virtual core::rect getHRect(const SItem& i, const core::rect& absolute); + + //! Gets drawing rect of Item + virtual core::rect getRect(const SItem& i, const core::rect& absolute); + + void closeAllSubMenus(); + + }; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIMeshViewer.cpp b/src/dep/src/irrlicht/CGUIMeshViewer.cpp index 6db3c68..51035c4 100644 --- a/src/dep/src/irrlicht/CGUIMeshViewer.cpp +++ b/src/dep/src/irrlicht/CGUIMeshViewer.cpp @@ -1,178 +1,178 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIMeshViewer.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IAnimatedMesh.h" -#include "irrMath.h" -#include "os.h" -#include "IGUISkin.h" - -namespace irr -{ - -namespace gui -{ - - -//! constructor -CGUIMeshViewer::CGUIMeshViewer(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) -: IGUIMeshViewer(environment, parent, id, rectangle), Mesh(0) -{ - #ifdef _DEBUG - setDebugName("CGUIMeshViewer"); - #endif -} - - - -//! destructor -CGUIMeshViewer::~CGUIMeshViewer() -{ - if (Mesh) - Mesh->drop(); -} - - - -//! sets the mesh to be shown -void CGUIMeshViewer::setMesh(scene::IAnimatedMesh* mesh) -{ - if (Mesh) - Mesh->drop(); - - Mesh = mesh; - if (!Mesh) - return; - - core::vector3df center(0.0f,0.0f,0.0f); - core::aabbox3d box; - - if (mesh->getFrameCount()) - { - box = mesh->getMesh(0)->getBoundingBox(); - center = (box.MaxEdge + box.MinEdge) / 2; - } - - if (Mesh) - Mesh->grab(); -} - - - -//! sets the material -void CGUIMeshViewer::setMaterial(const video::SMaterial& material) -{ - Material = material; -} - - - -//! gets the material -const video::SMaterial& CGUIMeshViewer::getMaterial() -{ - return Material; -} - - - -//! called if an event happened. -bool CGUIMeshViewer::OnEvent(SEvent event) -{ - return Parent ? Parent->OnEvent(event) : false; -} - - - -//! draws the element and its children -void CGUIMeshViewer::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - video::IVideoDriver* driver = Environment->getVideoDriver(); - core::rect viewPort = AbsoluteRect; - viewPort.LowerRightCorner.X -= 1; - viewPort.LowerRightCorner.Y -= 1; - viewPort.UpperLeftCorner.X += 1; - viewPort.UpperLeftCorner.Y += 1; - - viewPort.clipAgainst(AbsoluteClippingRect); - - // draw the frame - - core::rect frameRect(AbsoluteRect); - frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + 1; - driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), frameRect, &AbsoluteClippingRect); - - frameRect.LowerRightCorner.Y = AbsoluteRect.LowerRightCorner.Y; - frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + 1; - driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), frameRect, &AbsoluteClippingRect); - - frameRect = AbsoluteRect; - frameRect.UpperLeftCorner.X = frameRect.LowerRightCorner.X - 1; - driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); - - frameRect = AbsoluteRect; - frameRect.UpperLeftCorner.Y = AbsoluteRect.LowerRightCorner.Y - 1; - frameRect.LowerRightCorner.Y = AbsoluteRect.LowerRightCorner.Y; - driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); - - // draw the mesh - - if (Mesh) - { - //TODO: if outside of screen, dont draw. - // - why is the absolute clipping rect not already the screen? - - core::rect oldViewPort = driver->getViewPort(); - - driver->setViewPort(viewPort); - - core::matrix4 mat; - - //CameraControl->calculateProjectionMatrix(mat); - //driver->setTransform(video::TS_PROJECTION, mat); - - mat.makeIdentity(); - mat.setTranslation(core::vector3df(0,0,0)); - driver->setTransform(video::ETS_WORLD, mat); - - //CameraControl->calculateViewMatrix(mat); - //driver->setTransform(video::TS_VIEW, mat); - - driver->setMaterial(Material); - - scene::IMesh* m = Mesh->getMesh(os::Timer::getTime()/20); - for (u32 i=0; igetMeshBufferCount(); ++i) - { - scene::IMeshBuffer* mb = m->getMeshBuffer(i); - - switch(mb->getVertexType()) - { - case video::EVT_STANDARD: - driver->drawIndexedTriangleList((video::S3DVertex*)mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getIndexCount()/ 3); - break; - case video::EVT_2TCOORDS: - driver->drawIndexedTriangleList((video::S3DVertex2TCoords*)mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getIndexCount()/ 3); - break; - case video::EVT_TANGENTS: - driver->drawIndexedTriangleList((video::S3DVertexTangents*)mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getIndexCount()/ 3); - break; - } - } - - driver->setViewPort(oldViewPort); - } - - IGUIElement::draw(); -} - - -} // end namespace gui -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIMeshViewer.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IAnimatedMesh.h" +#include "irrMath.h" +#include "os.h" +#include "IGUISkin.h" + +namespace irr +{ + +namespace gui +{ + + +//! constructor +CGUIMeshViewer::CGUIMeshViewer(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) +: IGUIMeshViewer(environment, parent, id, rectangle), Mesh(0) +{ + #ifdef _DEBUG + setDebugName("CGUIMeshViewer"); + #endif +} + + + +//! destructor +CGUIMeshViewer::~CGUIMeshViewer() +{ + if (Mesh) + Mesh->drop(); +} + + + +//! sets the mesh to be shown +void CGUIMeshViewer::setMesh(scene::IAnimatedMesh* mesh) +{ + if (Mesh) + Mesh->drop(); + + Mesh = mesh; + if (!Mesh) + return; + + core::vector3df center(0.0f,0.0f,0.0f); + core::aabbox3d box; + + if (mesh->getFrameCount()) + { + box = mesh->getMesh(0)->getBoundingBox(); + center = (box.MaxEdge + box.MinEdge) / 2; + } + + if (Mesh) + Mesh->grab(); +} + + + +//! sets the material +void CGUIMeshViewer::setMaterial(const video::SMaterial& material) +{ + Material = material; +} + + + +//! gets the material +const video::SMaterial& CGUIMeshViewer::getMaterial() +{ + return Material; +} + + + +//! called if an event happened. +bool CGUIMeshViewer::OnEvent(SEvent event) +{ + return Parent ? Parent->OnEvent(event) : false; +} + + + +//! draws the element and its children +void CGUIMeshViewer::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + video::IVideoDriver* driver = Environment->getVideoDriver(); + core::rect viewPort = AbsoluteRect; + viewPort.LowerRightCorner.X -= 1; + viewPort.LowerRightCorner.Y -= 1; + viewPort.UpperLeftCorner.X += 1; + viewPort.UpperLeftCorner.Y += 1; + + viewPort.clipAgainst(AbsoluteClippingRect); + + // draw the frame + + core::rect frameRect(AbsoluteRect); + frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + 1; + driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), frameRect, &AbsoluteClippingRect); + + frameRect.LowerRightCorner.Y = AbsoluteRect.LowerRightCorner.Y; + frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + 1; + driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), frameRect, &AbsoluteClippingRect); + + frameRect = AbsoluteRect; + frameRect.UpperLeftCorner.X = frameRect.LowerRightCorner.X - 1; + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); + + frameRect = AbsoluteRect; + frameRect.UpperLeftCorner.Y = AbsoluteRect.LowerRightCorner.Y - 1; + frameRect.LowerRightCorner.Y = AbsoluteRect.LowerRightCorner.Y; + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); + + // draw the mesh + + if (Mesh) + { + //TODO: if outside of screen, dont draw. + // - why is the absolute clipping rect not already the screen? + + core::rect oldViewPort = driver->getViewPort(); + + driver->setViewPort(viewPort); + + core::matrix4 mat; + + //CameraControl->calculateProjectionMatrix(mat); + //driver->setTransform(video::TS_PROJECTION, mat); + + mat.makeIdentity(); + mat.setTranslation(core::vector3df(0,0,0)); + driver->setTransform(video::ETS_WORLD, mat); + + //CameraControl->calculateViewMatrix(mat); + //driver->setTransform(video::TS_VIEW, mat); + + driver->setMaterial(Material); + + scene::IMesh* m = Mesh->getMesh(os::Timer::getTime()/20); + for (u32 i=0; igetMeshBufferCount(); ++i) + { + scene::IMeshBuffer* mb = m->getMeshBuffer(i); + + switch(mb->getVertexType()) + { + case video::EVT_STANDARD: + driver->drawIndexedTriangleList((video::S3DVertex*)mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getIndexCount()/ 3); + break; + case video::EVT_2TCOORDS: + driver->drawIndexedTriangleList((video::S3DVertex2TCoords*)mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getIndexCount()/ 3); + break; + case video::EVT_TANGENTS: + driver->drawIndexedTriangleList((video::S3DVertexTangents*)mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getIndexCount()/ 3); + break; + } + } + + driver->setViewPort(oldViewPort); + } + + IGUIElement::draw(); +} + + +} // end namespace gui +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CGUIMeshViewer.h b/src/dep/src/irrlicht/CGUIMeshViewer.h index 94fc0c4..51f71fe 100644 --- a/src/dep/src/irrlicht/CGUIMeshViewer.h +++ b/src/dep/src/irrlicht/CGUIMeshViewer.h @@ -1,55 +1,55 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_MESH_VIEWER_H_INCLUDED__ -#define __C_GUI_MESH_VIEWER_H_INCLUDED__ - -#include "IGUIMeshViewer.h" -#include "SMaterial.h" -#include "vector3d.h" - -namespace irr -{ - -namespace gui -{ - - class CGUIMeshViewer : public IGUIMeshViewer - { - public: - - //! constructor - CGUIMeshViewer(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle); - - //! destructor - ~CGUIMeshViewer(); - - //! sets the mesh to be shown - virtual void setMesh(scene::IAnimatedMesh* mesh); - - //! sets the material - virtual void setMaterial(const video::SMaterial& material); - - //! gets the material - virtual const video::SMaterial& getMaterial(); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! draws the element and its children - virtual void draw(); - - - private: - - video::SMaterial Material; - scene::IAnimatedMesh* Mesh; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_MESH_VIEWER_H_INCLUDED__ +#define __C_GUI_MESH_VIEWER_H_INCLUDED__ + +#include "IGUIMeshViewer.h" +#include "SMaterial.h" +#include "vector3d.h" + +namespace irr +{ + +namespace gui +{ + + class CGUIMeshViewer : public IGUIMeshViewer + { + public: + + //! constructor + CGUIMeshViewer(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle); + + //! destructor + ~CGUIMeshViewer(); + + //! sets the mesh to be shown + virtual void setMesh(scene::IAnimatedMesh* mesh); + + //! sets the material + virtual void setMaterial(const video::SMaterial& material); + + //! gets the material + virtual const video::SMaterial& getMaterial(); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! draws the element and its children + virtual void draw(); + + + private: + + video::SMaterial Material; + scene::IAnimatedMesh* Mesh; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIMessageBox.cpp b/src/dep/src/irrlicht/CGUIMessageBox.cpp index 85e0034..1468812 100644 --- a/src/dep/src/irrlicht/CGUIMessageBox.cpp +++ b/src/dep/src/irrlicht/CGUIMessageBox.cpp @@ -1,319 +1,319 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIMessageBox.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IGUIButton.h" -#include "IGUIFont.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIMessageBox::CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* caption, - const wchar_t* text, s32 flags, - IGUIElement* parent, s32 id, core::rect rectangle) -: CGUIWindow(environment, parent, id, rectangle), - OkButton(0), CancelButton(0), YesButton(0), NoButton(0), StaticText(0), - Flags(flags), MessageText(text) -{ - #ifdef _DEBUG - setDebugName("CGUIMessageBox"); - #endif - - // set element type - Type = EGUIET_MESSAGE_BOX; - - // remove focus - Environment->setFocus(0); - - // remove buttons - - getMaximizeButton()->remove(); - getMinimizeButton()->remove(); - - if (caption) - setText(caption); - - Environment->setFocus(this); - - refreshControls(); -} - -void CGUIMessageBox::refreshControls() -{ - IGUISkin* skin = Environment->getSkin(); - - s32 buttonHeight = skin->getSize(EGDS_BUTTON_HEIGHT); - s32 buttonWidth = skin->getSize(EGDS_BUTTON_WIDTH); - s32 titleHeight = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH)+2; - s32 buttonDistance = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); - - // add static multiline text - - core::dimension2d dim(AbsoluteClippingRect.getWidth() - buttonWidth, - AbsoluteClippingRect.getHeight() - (buttonHeight * 3)); - core::position2d pos((AbsoluteClippingRect.getWidth() - dim.Width) / 2, - buttonHeight / 2 + titleHeight); - - if (!StaticText) - { - StaticText = Environment->addStaticText(MessageText.c_str(), - core::rect(pos, dim), false, false, this); - StaticText->setWordWrap(true); - StaticText->setSubElement(true); - StaticText->grab(); - } - else - { - StaticText->setRelativePosition( core::rect(pos, dim)); - StaticText->setText(MessageText.c_str()); - } - - // adjust static text height - - s32 textHeight = StaticText->getTextHeight(); - core::rect tmp = StaticText->getRelativePosition(); - tmp.LowerRightCorner.Y = tmp.UpperLeftCorner.Y + textHeight; - StaticText->setRelativePosition(tmp); - dim.Height = textHeight; - - // adjust message box height - - tmp = getRelativePosition(); - s32 msgBoxHeight = textHeight + (s32)(2.5f * buttonHeight) + titleHeight; - - // adjust message box position - - tmp.UpperLeftCorner.Y = (Parent->getAbsolutePosition().getHeight() - msgBoxHeight) / 2; - tmp.LowerRightCorner.Y = tmp.UpperLeftCorner.Y + msgBoxHeight; - setRelativePosition(tmp); - - // add buttons - - s32 countButtons = 0; - if (Flags & EMBF_OK) ++countButtons; - if (Flags & EMBF_CANCEL) ++countButtons; - if (Flags & EMBF_YES) ++countButtons; - if (Flags & EMBF_NO) ++countButtons; - - core::rect btnRect; - btnRect.UpperLeftCorner.Y = pos.Y + dim.Height + buttonHeight / 2; - btnRect.LowerRightCorner.Y = btnRect.UpperLeftCorner.Y + buttonHeight; - btnRect.UpperLeftCorner.X = (AbsoluteClippingRect.getWidth() - - ((buttonWidth + buttonDistance)*countButtons)) / 2; - btnRect.LowerRightCorner.X = btnRect.UpperLeftCorner.X + buttonWidth; - - // add/remove ok button - if (Flags & EMBF_OK) - { - if (!OkButton) - { - OkButton = Environment->addButton(btnRect, this); - OkButton->setSubElement(true); - OkButton->grab(); - } - else - OkButton->setRelativePosition(btnRect); - - OkButton->setText(skin->getDefaultText(EGDT_MSG_BOX_OK)); - - btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; - btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; - - if (Environment->getFocus() == this) - Environment->setFocus(OkButton); - } - else if (OkButton) - { - OkButton->drop(); - OkButton->remove(); - OkButton =0; - } - - - // add/remove yes button - if (Flags & EMBF_YES) - { - if (!YesButton) - { - YesButton = Environment->addButton(btnRect, this); - YesButton->setSubElement(true); - YesButton->grab(); - } - else - YesButton->setRelativePosition(btnRect); - - YesButton->setText(skin->getDefaultText(EGDT_MSG_BOX_YES)); - - btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; - btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; - } - else if (YesButton) - { - YesButton->drop(); - YesButton->remove(); - YesButton = 0; - } - - - // add no button - if (Flags & EMBF_NO) - { - if (!NoButton) - { - NoButton = Environment->addButton(btnRect, this); - NoButton->setSubElement(true); - NoButton->grab(); - } - else - NoButton->setRelativePosition(btnRect); - - NoButton->setText(skin->getDefaultText(EGDT_MSG_BOX_NO)); - - btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; - btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; - } - else if (NoButton) - { - NoButton->drop(); - NoButton->remove(); - NoButton = 0; - } - - // add cancel button - if (Flags & EMBF_CANCEL) - { - if (!CancelButton) - { - CancelButton = Environment->addButton(btnRect, this); - CancelButton->setSubElement(true); - CancelButton->grab(); - } - else - CancelButton->setRelativePosition(btnRect); - - CancelButton->setText(skin->getDefaultText(EGDT_MSG_BOX_CANCEL)); - CancelButton->grab(); - - btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; - btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; - } - else if (CancelButton) - { - CancelButton->drop(); - CancelButton->remove(); - CancelButton = 0; - } -} - - -//! destructor -CGUIMessageBox::~CGUIMessageBox() -{ - if (StaticText) - StaticText->drop(); - - if (OkButton) - OkButton->drop(); - - if (CancelButton) - CancelButton->drop(); - - if (YesButton) - YesButton->drop(); - - if (NoButton) - NoButton->drop(); -} - - -//! called if an event happened. -bool CGUIMessageBox::OnEvent(SEvent event) -{ - SEvent outevent; - outevent.EventType = EET_GUI_EVENT; - outevent.GUIEvent.Caller = this; - - switch(event.EventType) - { - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) - { - if (event.GUIEvent.Caller == OkButton) - { - outevent.GUIEvent.EventType = EGET_MESSAGEBOX_OK; - Parent->OnEvent(outevent); - remove(); - return true; - } - else - if (event.GUIEvent.Caller == CancelButton || - event.GUIEvent.Caller == CloseButton) - { - outevent.GUIEvent.EventType = EGET_MESSAGEBOX_CANCEL; - Parent->OnEvent(outevent); - remove(); - return true; - } - else - if (event.GUIEvent.Caller == YesButton) - { - outevent.GUIEvent.EventType = EGET_MESSAGEBOX_YES; - Parent->OnEvent(outevent); - remove(); - return true; - } - else - if (event.GUIEvent.Caller == NoButton) - { - outevent.GUIEvent.EventType = EGET_MESSAGEBOX_NO; - Parent->OnEvent(outevent); - remove(); - return true; - } - } - break; - } - - return CGUIWindow::OnEvent(event); -} - -//! Writes attributes of the element. -void CGUIMessageBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) -{ - CGUIWindow::serializeAttributes(out,options); - - out->addBool ("OkayButton", (Flags & EMBF_OK) != 0 ); - out->addBool ("CancelButton", (Flags & EMBF_CANCEL)!= 0 ); - out->addBool ("YesButton", (Flags & EMBF_YES) != 0 ); - out->addBool ("NoButton", (Flags & EMBF_NO) != 0 ); - - out->addString ("MessageText", MessageText.c_str() ); -} - -//! Reads attributes of the element -void CGUIMessageBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - Flags = 0; - - Flags = in->getAttributeAsBool("OkayButton") ? EMBF_OK : 0; - Flags |= in->getAttributeAsBool("CancelButton") ? EMBF_CANCEL : 0; - Flags |= in->getAttributeAsBool("YesButton") ? EMBF_YES : 0; - Flags |= in->getAttributeAsBool("NoButton") ? EMBF_NO : 0; - - MessageText = in->getAttributeAsStringW("MessageText").c_str(); - - CGUIWindow::deserializeAttributes(in,options); - - refreshControls(); - -} - - -} // end namespace gui -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIMessageBox.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IGUIButton.h" +#include "IGUIFont.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIMessageBox::CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* caption, + const wchar_t* text, s32 flags, + IGUIElement* parent, s32 id, core::rect rectangle) +: CGUIWindow(environment, parent, id, rectangle), + OkButton(0), CancelButton(0), YesButton(0), NoButton(0), StaticText(0), + Flags(flags), MessageText(text) +{ + #ifdef _DEBUG + setDebugName("CGUIMessageBox"); + #endif + + // set element type + Type = EGUIET_MESSAGE_BOX; + + // remove focus + Environment->setFocus(0); + + // remove buttons + + getMaximizeButton()->remove(); + getMinimizeButton()->remove(); + + if (caption) + setText(caption); + + Environment->setFocus(this); + + refreshControls(); +} + +void CGUIMessageBox::refreshControls() +{ + IGUISkin* skin = Environment->getSkin(); + + s32 buttonHeight = skin->getSize(EGDS_BUTTON_HEIGHT); + s32 buttonWidth = skin->getSize(EGDS_BUTTON_WIDTH); + s32 titleHeight = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH)+2; + s32 buttonDistance = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); + + // add static multiline text + + core::dimension2d dim(AbsoluteClippingRect.getWidth() - buttonWidth, + AbsoluteClippingRect.getHeight() - (buttonHeight * 3)); + core::position2d pos((AbsoluteClippingRect.getWidth() - dim.Width) / 2, + buttonHeight / 2 + titleHeight); + + if (!StaticText) + { + StaticText = Environment->addStaticText(MessageText.c_str(), + core::rect(pos, dim), false, false, this); + StaticText->setWordWrap(true); + StaticText->setSubElement(true); + StaticText->grab(); + } + else + { + StaticText->setRelativePosition( core::rect(pos, dim)); + StaticText->setText(MessageText.c_str()); + } + + // adjust static text height + + s32 textHeight = StaticText->getTextHeight(); + core::rect tmp = StaticText->getRelativePosition(); + tmp.LowerRightCorner.Y = tmp.UpperLeftCorner.Y + textHeight; + StaticText->setRelativePosition(tmp); + dim.Height = textHeight; + + // adjust message box height + + tmp = getRelativePosition(); + s32 msgBoxHeight = textHeight + (s32)(2.5f * buttonHeight) + titleHeight; + + // adjust message box position + + tmp.UpperLeftCorner.Y = (Parent->getAbsolutePosition().getHeight() - msgBoxHeight) / 2; + tmp.LowerRightCorner.Y = tmp.UpperLeftCorner.Y + msgBoxHeight; + setRelativePosition(tmp); + + // add buttons + + s32 countButtons = 0; + if (Flags & EMBF_OK) ++countButtons; + if (Flags & EMBF_CANCEL) ++countButtons; + if (Flags & EMBF_YES) ++countButtons; + if (Flags & EMBF_NO) ++countButtons; + + core::rect btnRect; + btnRect.UpperLeftCorner.Y = pos.Y + dim.Height + buttonHeight / 2; + btnRect.LowerRightCorner.Y = btnRect.UpperLeftCorner.Y + buttonHeight; + btnRect.UpperLeftCorner.X = (AbsoluteClippingRect.getWidth() - + ((buttonWidth + buttonDistance)*countButtons)) / 2; + btnRect.LowerRightCorner.X = btnRect.UpperLeftCorner.X + buttonWidth; + + // add/remove ok button + if (Flags & EMBF_OK) + { + if (!OkButton) + { + OkButton = Environment->addButton(btnRect, this); + OkButton->setSubElement(true); + OkButton->grab(); + } + else + OkButton->setRelativePosition(btnRect); + + OkButton->setText(skin->getDefaultText(EGDT_MSG_BOX_OK)); + + btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; + btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; + + if (Environment->getFocus() == this) + Environment->setFocus(OkButton); + } + else if (OkButton) + { + OkButton->drop(); + OkButton->remove(); + OkButton =0; + } + + + // add/remove yes button + if (Flags & EMBF_YES) + { + if (!YesButton) + { + YesButton = Environment->addButton(btnRect, this); + YesButton->setSubElement(true); + YesButton->grab(); + } + else + YesButton->setRelativePosition(btnRect); + + YesButton->setText(skin->getDefaultText(EGDT_MSG_BOX_YES)); + + btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; + btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; + } + else if (YesButton) + { + YesButton->drop(); + YesButton->remove(); + YesButton = 0; + } + + + // add no button + if (Flags & EMBF_NO) + { + if (!NoButton) + { + NoButton = Environment->addButton(btnRect, this); + NoButton->setSubElement(true); + NoButton->grab(); + } + else + NoButton->setRelativePosition(btnRect); + + NoButton->setText(skin->getDefaultText(EGDT_MSG_BOX_NO)); + + btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; + btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; + } + else if (NoButton) + { + NoButton->drop(); + NoButton->remove(); + NoButton = 0; + } + + // add cancel button + if (Flags & EMBF_CANCEL) + { + if (!CancelButton) + { + CancelButton = Environment->addButton(btnRect, this); + CancelButton->setSubElement(true); + CancelButton->grab(); + } + else + CancelButton->setRelativePosition(btnRect); + + CancelButton->setText(skin->getDefaultText(EGDT_MSG_BOX_CANCEL)); + CancelButton->grab(); + + btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; + btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; + } + else if (CancelButton) + { + CancelButton->drop(); + CancelButton->remove(); + CancelButton = 0; + } +} + + +//! destructor +CGUIMessageBox::~CGUIMessageBox() +{ + if (StaticText) + StaticText->drop(); + + if (OkButton) + OkButton->drop(); + + if (CancelButton) + CancelButton->drop(); + + if (YesButton) + YesButton->drop(); + + if (NoButton) + NoButton->drop(); +} + + +//! called if an event happened. +bool CGUIMessageBox::OnEvent(SEvent event) +{ + SEvent outevent; + outevent.EventType = EET_GUI_EVENT; + outevent.GUIEvent.Caller = this; + + switch(event.EventType) + { + case EET_GUI_EVENT: + if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) + { + if (event.GUIEvent.Caller == OkButton) + { + outevent.GUIEvent.EventType = EGET_MESSAGEBOX_OK; + Parent->OnEvent(outevent); + remove(); + return true; + } + else + if (event.GUIEvent.Caller == CancelButton || + event.GUIEvent.Caller == CloseButton) + { + outevent.GUIEvent.EventType = EGET_MESSAGEBOX_CANCEL; + Parent->OnEvent(outevent); + remove(); + return true; + } + else + if (event.GUIEvent.Caller == YesButton) + { + outevent.GUIEvent.EventType = EGET_MESSAGEBOX_YES; + Parent->OnEvent(outevent); + remove(); + return true; + } + else + if (event.GUIEvent.Caller == NoButton) + { + outevent.GUIEvent.EventType = EGET_MESSAGEBOX_NO; + Parent->OnEvent(outevent); + remove(); + return true; + } + } + break; + } + + return CGUIWindow::OnEvent(event); +} + +//! Writes attributes of the element. +void CGUIMessageBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +{ + CGUIWindow::serializeAttributes(out,options); + + out->addBool ("OkayButton", (Flags & EMBF_OK) != 0 ); + out->addBool ("CancelButton", (Flags & EMBF_CANCEL)!= 0 ); + out->addBool ("YesButton", (Flags & EMBF_YES) != 0 ); + out->addBool ("NoButton", (Flags & EMBF_NO) != 0 ); + + out->addString ("MessageText", MessageText.c_str() ); +} + +//! Reads attributes of the element +void CGUIMessageBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +{ + Flags = 0; + + Flags = in->getAttributeAsBool("OkayButton") ? EMBF_OK : 0; + Flags |= in->getAttributeAsBool("CancelButton") ? EMBF_CANCEL : 0; + Flags |= in->getAttributeAsBool("YesButton") ? EMBF_YES : 0; + Flags |= in->getAttributeAsBool("NoButton") ? EMBF_NO : 0; + + MessageText = in->getAttributeAsStringW("MessageText").c_str(); + + CGUIWindow::deserializeAttributes(in,options); + + refreshControls(); + +} + + +} // end namespace gui +} // end namespace irr diff --git a/src/dep/src/irrlicht/CGUIMessageBox.h b/src/dep/src/irrlicht/CGUIMessageBox.h index a58f3f7..ca1932b 100644 --- a/src/dep/src/irrlicht/CGUIMessageBox.h +++ b/src/dep/src/irrlicht/CGUIMessageBox.h @@ -1,55 +1,55 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_MESSAGE_BOX_H_INCLUDED__ -#define __C_GUI_MESSAGE_BOX_H_INCLUDED__ - -#include "CGUIWindow.h" -#include "IGUIStaticText.h" -#include "irrArray.h" - -namespace irr -{ -namespace gui -{ - class CGUIMessageBox : public CGUIWindow - { - public: - - //! constructor - CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* caption, - const wchar_t* text, s32 flag, - IGUIElement* parent, s32 id, core::rect rectangle); - - //! destructor - ~CGUIMessageBox(); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - void refreshControls(); - - IGUIButton* OkButton; - IGUIButton* CancelButton; - IGUIButton* YesButton; - IGUIButton* NoButton; - IGUIStaticText* StaticText; - - s32 Flags; - core::stringw MessageText; - }; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_MESSAGE_BOX_H_INCLUDED__ +#define __C_GUI_MESSAGE_BOX_H_INCLUDED__ + +#include "CGUIWindow.h" +#include "IGUIStaticText.h" +#include "irrArray.h" + +namespace irr +{ +namespace gui +{ + class CGUIMessageBox : public CGUIWindow + { + public: + + //! constructor + CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* caption, + const wchar_t* text, s32 flag, + IGUIElement* parent, s32 id, core::rect rectangle); + + //! destructor + ~CGUIMessageBox(); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + private: + + void refreshControls(); + + IGUIButton* OkButton; + IGUIButton* CancelButton; + IGUIButton* YesButton; + IGUIButton* NoButton; + IGUIStaticText* StaticText; + + s32 Flags; + core::stringw MessageText; + }; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIModalScreen.cpp b/src/dep/src/irrlicht/CGUIModalScreen.cpp index 2039d6d..db0ff1e 100644 --- a/src/dep/src/irrlicht/CGUIModalScreen.cpp +++ b/src/dep/src/irrlicht/CGUIModalScreen.cpp @@ -1,119 +1,119 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIModalScreen.h" -#include "IGUIEnvironment.h" -#include "os.h" -#include "IVideoDriver.h" -#include "IGUISkin.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIModalScreen::CGUIModalScreen(IGUIEnvironment* environment, IGUIElement* parent, s32 id) -: IGUIElement(EGUIET_MODAL_SCREEN, environment, parent, id, parent->getAbsolutePosition()), - MouseDownTime(0) -{ - #ifdef _DEBUG - setDebugName("CGUIModalScreen"); - #endif -} - - -//! destructor -CGUIModalScreen::~CGUIModalScreen() -{ -} - - -//! called if an event happened. -bool CGUIModalScreen::OnEvent(SEvent event) -{ - switch(event.EventType) - { - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_PRESSED_DOWN: - MouseDownTime = os::Timer::getTime(); - } - } - - return IGUIElement::OnEvent(event); -} - - -//! draws the element and its children -void CGUIModalScreen::draw() -{ - u32 now = os::Timer::getTime(); - if (now - MouseDownTime < 300 && (now / 70)%2) - { - core::list::Iterator it = Children.begin(); - core::rect r; - video::IVideoDriver* driver = Environment->getVideoDriver(); - video::SColor c = Environment->getSkin()->getColor(gui::EGDC_3D_HIGH_LIGHT); - - for (; it != Children.end(); ++it) - { - r = (*it)->getAbsolutePosition(); - r.LowerRightCorner.X += 1; - r.LowerRightCorner.Y += 1; - r.UpperLeftCorner.X -= 1; - r.UpperLeftCorner.Y -= 1; - - driver->draw2DRectangle(c, r, &AbsoluteClippingRect); - } - } - - IGUIElement::draw(); -} - - - -//! Removes a child. -void CGUIModalScreen::removeChild(IGUIElement* child) -{ - IGUIElement::removeChild(child); - - if (Children.empty()) - remove(); -} - - -void CGUIModalScreen::updateAbsolutePosition() -{ - core::rect parentRect(0,0,0,0); - - if (Parent) - { - parentRect = Parent->getAbsolutePosition(); - RelativeRect.UpperLeftCorner.X = 0; - RelativeRect.UpperLeftCorner.Y = 0; - RelativeRect.LowerRightCorner.X = parentRect.getWidth(); - RelativeRect.LowerRightCorner.Y = parentRect.getHeight(); - } - - IGUIElement::updateAbsolutePosition(); -} - -//! Writes attributes of the element. -void CGUIModalScreen::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) -{ - // these don't get serialized, their status is added to their children. -} - -//! Reads attributes of the element -void CGUIModalScreen::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - // these don't get deserialized. children create them if required -} - - -} // end namespace gui -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIModalScreen.h" +#include "IGUIEnvironment.h" +#include "os.h" +#include "IVideoDriver.h" +#include "IGUISkin.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIModalScreen::CGUIModalScreen(IGUIEnvironment* environment, IGUIElement* parent, s32 id) +: IGUIElement(EGUIET_MODAL_SCREEN, environment, parent, id, parent->getAbsolutePosition()), + MouseDownTime(0) +{ + #ifdef _DEBUG + setDebugName("CGUIModalScreen"); + #endif +} + + +//! destructor +CGUIModalScreen::~CGUIModalScreen() +{ +} + + +//! called if an event happened. +bool CGUIModalScreen::OnEvent(SEvent event) +{ + switch(event.EventType) + { + case EET_MOUSE_INPUT_EVENT: + switch(event.MouseInput.Event) + { + case EMIE_LMOUSE_PRESSED_DOWN: + MouseDownTime = os::Timer::getTime(); + } + } + + return IGUIElement::OnEvent(event); +} + + +//! draws the element and its children +void CGUIModalScreen::draw() +{ + u32 now = os::Timer::getTime(); + if (now - MouseDownTime < 300 && (now / 70)%2) + { + core::list::Iterator it = Children.begin(); + core::rect r; + video::IVideoDriver* driver = Environment->getVideoDriver(); + video::SColor c = Environment->getSkin()->getColor(gui::EGDC_3D_HIGH_LIGHT); + + for (; it != Children.end(); ++it) + { + r = (*it)->getAbsolutePosition(); + r.LowerRightCorner.X += 1; + r.LowerRightCorner.Y += 1; + r.UpperLeftCorner.X -= 1; + r.UpperLeftCorner.Y -= 1; + + driver->draw2DRectangle(c, r, &AbsoluteClippingRect); + } + } + + IGUIElement::draw(); +} + + + +//! Removes a child. +void CGUIModalScreen::removeChild(IGUIElement* child) +{ + IGUIElement::removeChild(child); + + if (Children.empty()) + remove(); +} + + +void CGUIModalScreen::updateAbsolutePosition() +{ + core::rect parentRect(0,0,0,0); + + if (Parent) + { + parentRect = Parent->getAbsolutePosition(); + RelativeRect.UpperLeftCorner.X = 0; + RelativeRect.UpperLeftCorner.Y = 0; + RelativeRect.LowerRightCorner.X = parentRect.getWidth(); + RelativeRect.LowerRightCorner.Y = parentRect.getHeight(); + } + + IGUIElement::updateAbsolutePosition(); +} + +//! Writes attributes of the element. +void CGUIModalScreen::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +{ + // these don't get serialized, their status is added to their children. +} + +//! Reads attributes of the element +void CGUIModalScreen::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +{ + // these don't get deserialized. children create them if required +} + + +} // end namespace gui +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CGUIModalScreen.h b/src/dep/src/irrlicht/CGUIModalScreen.h index 632d7a7..0205cb5 100644 --- a/src/dep/src/irrlicht/CGUIModalScreen.h +++ b/src/dep/src/irrlicht/CGUIModalScreen.h @@ -1,53 +1,53 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_MODAL_SCREEN_H_INCLUDED__ -#define __C_GUI_MODAL_SCREEN_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace gui -{ - - class CGUIModalScreen : public IGUIElement - { - public: - - //! constructor - CGUIModalScreen(IGUIEnvironment* environment, IGUIElement* parent, s32 id); - - //! destructor - ~CGUIModalScreen(); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! Removes a child. - virtual void removeChild(IGUIElement* child); - - //! draws the element and its children - virtual void draw(); - - //! Updates the absolute position. - virtual void updateAbsolutePosition(); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - u32 MouseDownTime; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_MODAL_SCREEN_H_INCLUDED__ +#define __C_GUI_MODAL_SCREEN_H_INCLUDED__ + +#include "IGUIElement.h" + +namespace irr +{ +namespace gui +{ + + class CGUIModalScreen : public IGUIElement + { + public: + + //! constructor + CGUIModalScreen(IGUIEnvironment* environment, IGUIElement* parent, s32 id); + + //! destructor + ~CGUIModalScreen(); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! Removes a child. + virtual void removeChild(IGUIElement* child); + + //! draws the element and its children + virtual void draw(); + + //! Updates the absolute position. + virtual void updateAbsolutePosition(); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + private: + + u32 MouseDownTime; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIScrollBar.cpp b/src/dep/src/irrlicht/CGUIScrollBar.cpp index 3b2e757..1e6bba3 100644 --- a/src/dep/src/irrlicht/CGUIScrollBar.cpp +++ b/src/dep/src/irrlicht/CGUIScrollBar.cpp @@ -1,382 +1,382 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIScrollBar.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "CGUIButton.h" -#include "IGUIFont.h" -#include "IGUIFontBitmap.h" - -namespace irr -{ -namespace gui -{ - - -//! constructor -CGUIScrollBar::CGUIScrollBar(bool horizontal, IGUIEnvironment* environment, - IGUIElement* parent, s32 id, - core::rect rectangle, bool noclip) -: IGUIScrollBar(environment, parent, id, rectangle), UpButton(0), DownButton(0), - Dragging(false), Horizontal(horizontal), Pos(0), DrawPos(0), - DrawHeight(0), Max(100), SmallStep(10) -{ - #ifdef _DEBUG - setDebugName("CGUIScrollBar"); - #endif - - refreshControls(); - - setNotClipped(noclip); - - setPos(0); -} - - -//! destructor -CGUIScrollBar::~CGUIScrollBar() -{ - if (UpButton) - UpButton->drop(); - - if (DownButton) - DownButton->drop(); -} - - -//! called if an event happened. -bool CGUIScrollBar::OnEvent(SEvent event) -{ - switch(event.EventType) - { - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) - { - if (event.GUIEvent.Caller == UpButton) - setPos(Pos-SmallStep); - else - if (event.GUIEvent.Caller == DownButton) - setPos(Pos+SmallStep); - - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; - Parent->OnEvent(newEvent); - - return true; - } - else - if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) - { - if (event.GUIEvent.Caller == (IGUIElement*)this) - Dragging = false; - } - break; - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_MOUSE_WHEEL: - if (Environment->getFocus() == this) - { // thanks to a bug report by REAPER - setPos(getPos() + (s32)event.MouseInput.Wheel* -SmallStep); - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; - Parent->OnEvent(newEvent); - return true; - } - break; - case EMIE_LMOUSE_PRESSED_DOWN: - { - IGUIElement *el = Environment->getRootGUIElement()->getElementFromPoint( - core::position2di(event.MouseInput.X, event.MouseInput.Y)); - if (el == this ) - { - Dragging = true; - Environment->setFocus(this); - return true; - } - else - { - if (Environment->getFocus() == this) - { - Environment->setFocus(el); - return el->OnEvent(event); - } - } - break; - } - case EMIE_LMOUSE_LEFT_UP: - Dragging = false; - return true; - - break; - case EMIE_MOUSE_MOVED: - if (Dragging) - { - s32 oldPos = Pos; - setPosFromMousePos(event.MouseInput.X, event.MouseInput.Y); - if (Pos != oldPos && Parent) - { - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; - Parent->OnEvent(newEvent); - } - return true; - } - } - break; - } - - return Parent ? Parent->OnEvent(event) : false; -} - -//! draws the element and its children -void CGUIScrollBar::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - - irr::video::IVideoDriver* driver = Environment->getVideoDriver(); - - core::rect rect = AbsoluteRect; - - // draws the background - driver->draw2DRectangle(skin->getColor(EGDC_SCROLLBAR), rect, &AbsoluteClippingRect); - - if (Max!=0) - { - // draw thumb - if (Horizontal) - { - rect.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X + DrawPos + RelativeRect.getHeight() - DrawHeight/2; - rect.LowerRightCorner.X = rect.UpperLeftCorner.X + DrawHeight; - } - else - { - rect.UpperLeftCorner.Y = AbsoluteRect.UpperLeftCorner.Y + DrawPos + RelativeRect.getWidth() - DrawHeight/2; - rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + DrawHeight; - } - - skin->draw3DButtonPaneStandard(this, rect, &AbsoluteClippingRect); - } - - // draw buttons - IGUIElement::draw(); -} - -void CGUIScrollBar::updateAbsolutePosition() -{ - IGUIElement::updateAbsolutePosition(); - // todo: properly resize - refreshControls(); - - if (Horizontal) - { - f32 f = (RelativeRect.getWidth() - ((f32)RelativeRect.getHeight()*3.0f)) / (f32)Max; - DrawPos = (s32)((Pos * f) + ((f32)RelativeRect.getHeight() * 0.5f)); - DrawHeight = RelativeRect.getHeight(); - } - else - { - f32 f = 0.0f; - if (Max != 0) - f = (RelativeRect.getHeight() - ((f32)RelativeRect.getWidth()*3.0f)) / (f32)Max; - - DrawPos = (s32)((Pos * f) + ((f32)RelativeRect.getWidth() * 0.5f)); - DrawHeight = RelativeRect.getWidth(); - } -} - -void CGUIScrollBar::setPosFromMousePos(s32 x, s32 y) -{ - if (Horizontal) - { - f32 f = (RelativeRect.getWidth() - ((f32)RelativeRect.getHeight()*3.0f)) / (f32)Max; - setPos((s32)(((f32)(x - AbsoluteRect.UpperLeftCorner.X - RelativeRect.getHeight())) / f)); - } - else - { - f32 f = (RelativeRect.getHeight() - ((f32)RelativeRect.getWidth()*3.0f)) / (f32)Max; - setPos((s32)(((f32)y - AbsoluteRect.UpperLeftCorner.Y - RelativeRect.getWidth()) / f)); - } -} - - - -//! sets the position of the scrollbar -void CGUIScrollBar::setPos(s32 pos) -{ - Pos = pos; - if (Pos < 0) - Pos = 0; - if (Pos > Max) - Pos = Max; - - if (Horizontal) - { - f32 f = (RelativeRect.getWidth() - ((f32)RelativeRect.getHeight()*3.0f)) / (f32)Max; - DrawPos = (s32)((Pos * f) + ((f32)RelativeRect.getHeight() * 0.5f)); - DrawHeight = RelativeRect.getHeight(); - } - else - { - f32 f = 0.0f; - if (Max != 0) - f = (RelativeRect.getHeight() - ((f32)RelativeRect.getWidth()*3.0f)) / (f32)Max; - - DrawPos = (s32)((Pos * f) + ((f32)RelativeRect.getWidth() * 0.5f)); - DrawHeight = RelativeRect.getWidth(); - } -} - - -//! sets the small step value -void CGUIScrollBar::setSmallStep(s32 step) -{ - if (step > 0) - SmallStep = step; - else - SmallStep = 10; - -} - - -//! sets the maximum value of the scrollbar. must be > 0 -void CGUIScrollBar::setMax(s32 max) -{ - if (max > 0) - Max = max; - else - Max = 0; - - bool enable = (Max != 0); - UpButton->setEnabled(enable); - DownButton->setEnabled(enable); - setPos(Pos); -} - - - -//! gets the current position of the scrollbar -s32 CGUIScrollBar::getPos() -{ - return Pos; -} - -//! refreshes the position and text on child buttons -void CGUIScrollBar::refreshControls() -{ - video::SColor color(255,255,255,255); - - IGUISkin* skin = Environment->getSkin(); - IGUISpriteBank* sprites = 0; - - if (skin) - { - sprites = skin->getSpriteBank(); - color = skin->getColor(EGDC_WINDOW_SYMBOL); - } - - if (Horizontal) - { - s32 h = RelativeRect.getHeight(); - if (!UpButton) - { - UpButton = new CGUIButton(Environment, this, -1, core::rect(0,0, h, h), NoClip); - UpButton->setSubElement(true); - } - if (sprites) - { - UpButton->setSpriteBank(sprites); - UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_LEFT), color); - UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_LEFT), color); - } - UpButton->setRelativePosition(core::rect(0,0, h, h)); - UpButton->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - if (!DownButton) - { - DownButton = new CGUIButton(Environment, this, -1, core::rect(RelativeRect.getWidth()-h, 0, RelativeRect.getWidth(), h), NoClip); - DownButton->setSubElement(true); - } - if (sprites) - { - DownButton->setSpriteBank(sprites); - DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_RIGHT), color); - DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_RIGHT), color); - } - DownButton->setRelativePosition(core::rect(RelativeRect.getWidth()-h, 0, RelativeRect.getWidth(), h)); - DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - } - else - { - s32 w = RelativeRect.getWidth(); - if (!UpButton) - { - UpButton = new CGUIButton(Environment, this, -1, core::rect(0,0, w, w), NoClip); - UpButton->setSubElement(true); - } - if (sprites) - { - UpButton->setSpriteBank(sprites); - UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_UP), color); - UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_UP), color); - } - UpButton->setRelativePosition(core::rect(0,0, w, w)); - UpButton->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - if (!DownButton) - { - DownButton = new CGUIButton(Environment, this, -1, core::rect(0,RelativeRect.getHeight()-w, w, RelativeRect.getHeight()), NoClip); - DownButton->setSubElement(true); - } - if (sprites) - { - DownButton->setSpriteBank(sprites); - DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_DOWN), color); - DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_DOWN), color); - } - DownButton->setRelativePosition(core::rect(0,RelativeRect.getHeight()-w, w, RelativeRect.getHeight())); - DownButton->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); - } -} - -//! Writes attributes of the element. -void CGUIScrollBar::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) -{ - IGUIScrollBar::serializeAttributes(out,options); - - out->addBool("Horizontal", Horizontal); - out->addInt ("Value", Pos); - out->addInt ("Max", Max); - out->addInt ("SmallStep", SmallStep); -} - -//! Reads attributes of the element -void CGUIScrollBar::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIScrollBar::deserializeAttributes(in,options); - - Horizontal = in->getAttributeAsBool("Horizontal"); - setMax(in->getAttributeAsInt("Max")); - setPos(in->getAttributeAsInt("Value")); - setSmallStep(in->getAttributeAsInt("SmallStep")); - NoClip = in->getAttributeAsBool("NoClip"); - - refreshControls(); -} - - -} // end namespace gui -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIScrollBar.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "CGUIButton.h" +#include "IGUIFont.h" +#include "IGUIFontBitmap.h" + +namespace irr +{ +namespace gui +{ + + +//! constructor +CGUIScrollBar::CGUIScrollBar(bool horizontal, IGUIEnvironment* environment, + IGUIElement* parent, s32 id, + core::rect rectangle, bool noclip) +: IGUIScrollBar(environment, parent, id, rectangle), UpButton(0), DownButton(0), + Dragging(false), Horizontal(horizontal), Pos(0), DrawPos(0), + DrawHeight(0), Max(100), SmallStep(10) +{ + #ifdef _DEBUG + setDebugName("CGUIScrollBar"); + #endif + + refreshControls(); + + setNotClipped(noclip); + + setPos(0); +} + + +//! destructor +CGUIScrollBar::~CGUIScrollBar() +{ + if (UpButton) + UpButton->drop(); + + if (DownButton) + DownButton->drop(); +} + + +//! called if an event happened. +bool CGUIScrollBar::OnEvent(SEvent event) +{ + switch(event.EventType) + { + case EET_GUI_EVENT: + if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) + { + if (event.GUIEvent.Caller == UpButton) + setPos(Pos-SmallStep); + else + if (event.GUIEvent.Caller == DownButton) + setPos(Pos+SmallStep); + + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; + Parent->OnEvent(newEvent); + + return true; + } + else + if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) + { + if (event.GUIEvent.Caller == (IGUIElement*)this) + Dragging = false; + } + break; + case EET_MOUSE_INPUT_EVENT: + switch(event.MouseInput.Event) + { + case EMIE_MOUSE_WHEEL: + if (Environment->getFocus() == this) + { // thanks to a bug report by REAPER + setPos(getPos() + (s32)event.MouseInput.Wheel* -SmallStep); + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; + Parent->OnEvent(newEvent); + return true; + } + break; + case EMIE_LMOUSE_PRESSED_DOWN: + { + IGUIElement *el = Environment->getRootGUIElement()->getElementFromPoint( + core::position2di(event.MouseInput.X, event.MouseInput.Y)); + if (el == this ) + { + Dragging = true; + Environment->setFocus(this); + return true; + } + else + { + if (Environment->getFocus() == this) + { + Environment->setFocus(el); + return el->OnEvent(event); + } + } + break; + } + case EMIE_LMOUSE_LEFT_UP: + Dragging = false; + return true; + + break; + case EMIE_MOUSE_MOVED: + if (Dragging) + { + s32 oldPos = Pos; + setPosFromMousePos(event.MouseInput.X, event.MouseInput.Y); + if (Pos != oldPos && Parent) + { + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; + Parent->OnEvent(newEvent); + } + return true; + } + } + break; + } + + return Parent ? Parent->OnEvent(event) : false; +} + +//! draws the element and its children +void CGUIScrollBar::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + if (!skin) + return; + + irr::video::IVideoDriver* driver = Environment->getVideoDriver(); + + core::rect rect = AbsoluteRect; + + // draws the background + driver->draw2DRectangle(skin->getColor(EGDC_SCROLLBAR), rect, &AbsoluteClippingRect); + + if (Max!=0) + { + // draw thumb + if (Horizontal) + { + rect.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X + DrawPos + RelativeRect.getHeight() - DrawHeight/2; + rect.LowerRightCorner.X = rect.UpperLeftCorner.X + DrawHeight; + } + else + { + rect.UpperLeftCorner.Y = AbsoluteRect.UpperLeftCorner.Y + DrawPos + RelativeRect.getWidth() - DrawHeight/2; + rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + DrawHeight; + } + + skin->draw3DButtonPaneStandard(this, rect, &AbsoluteClippingRect); + } + + // draw buttons + IGUIElement::draw(); +} + +void CGUIScrollBar::updateAbsolutePosition() +{ + IGUIElement::updateAbsolutePosition(); + // todo: properly resize + refreshControls(); + + if (Horizontal) + { + f32 f = (RelativeRect.getWidth() - ((f32)RelativeRect.getHeight()*3.0f)) / (f32)Max; + DrawPos = (s32)((Pos * f) + ((f32)RelativeRect.getHeight() * 0.5f)); + DrawHeight = RelativeRect.getHeight(); + } + else + { + f32 f = 0.0f; + if (Max != 0) + f = (RelativeRect.getHeight() - ((f32)RelativeRect.getWidth()*3.0f)) / (f32)Max; + + DrawPos = (s32)((Pos * f) + ((f32)RelativeRect.getWidth() * 0.5f)); + DrawHeight = RelativeRect.getWidth(); + } +} + +void CGUIScrollBar::setPosFromMousePos(s32 x, s32 y) +{ + if (Horizontal) + { + f32 f = (RelativeRect.getWidth() - ((f32)RelativeRect.getHeight()*3.0f)) / (f32)Max; + setPos((s32)(((f32)(x - AbsoluteRect.UpperLeftCorner.X - RelativeRect.getHeight())) / f)); + } + else + { + f32 f = (RelativeRect.getHeight() - ((f32)RelativeRect.getWidth()*3.0f)) / (f32)Max; + setPos((s32)(((f32)y - AbsoluteRect.UpperLeftCorner.Y - RelativeRect.getWidth()) / f)); + } +} + + + +//! sets the position of the scrollbar +void CGUIScrollBar::setPos(s32 pos) +{ + Pos = pos; + if (Pos < 0) + Pos = 0; + if (Pos > Max) + Pos = Max; + + if (Horizontal) + { + f32 f = (RelativeRect.getWidth() - ((f32)RelativeRect.getHeight()*3.0f)) / (f32)Max; + DrawPos = (s32)((Pos * f) + ((f32)RelativeRect.getHeight() * 0.5f)); + DrawHeight = RelativeRect.getHeight(); + } + else + { + f32 f = 0.0f; + if (Max != 0) + f = (RelativeRect.getHeight() - ((f32)RelativeRect.getWidth()*3.0f)) / (f32)Max; + + DrawPos = (s32)((Pos * f) + ((f32)RelativeRect.getWidth() * 0.5f)); + DrawHeight = RelativeRect.getWidth(); + } +} + + +//! sets the small step value +void CGUIScrollBar::setSmallStep(s32 step) +{ + if (step > 0) + SmallStep = step; + else + SmallStep = 10; + +} + + +//! sets the maximum value of the scrollbar. must be > 0 +void CGUIScrollBar::setMax(s32 max) +{ + if (max > 0) + Max = max; + else + Max = 0; + + bool enable = (Max != 0); + UpButton->setEnabled(enable); + DownButton->setEnabled(enable); + setPos(Pos); +} + + + +//! gets the current position of the scrollbar +s32 CGUIScrollBar::getPos() +{ + return Pos; +} + +//! refreshes the position and text on child buttons +void CGUIScrollBar::refreshControls() +{ + video::SColor color(255,255,255,255); + + IGUISkin* skin = Environment->getSkin(); + IGUISpriteBank* sprites = 0; + + if (skin) + { + sprites = skin->getSpriteBank(); + color = skin->getColor(EGDC_WINDOW_SYMBOL); + } + + if (Horizontal) + { + s32 h = RelativeRect.getHeight(); + if (!UpButton) + { + UpButton = new CGUIButton(Environment, this, -1, core::rect(0,0, h, h), NoClip); + UpButton->setSubElement(true); + } + if (sprites) + { + UpButton->setSpriteBank(sprites); + UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_LEFT), color); + UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_LEFT), color); + } + UpButton->setRelativePosition(core::rect(0,0, h, h)); + UpButton->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + if (!DownButton) + { + DownButton = new CGUIButton(Environment, this, -1, core::rect(RelativeRect.getWidth()-h, 0, RelativeRect.getWidth(), h), NoClip); + DownButton->setSubElement(true); + } + if (sprites) + { + DownButton->setSpriteBank(sprites); + DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_RIGHT), color); + DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_RIGHT), color); + } + DownButton->setRelativePosition(core::rect(RelativeRect.getWidth()-h, 0, RelativeRect.getWidth(), h)); + DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + } + else + { + s32 w = RelativeRect.getWidth(); + if (!UpButton) + { + UpButton = new CGUIButton(Environment, this, -1, core::rect(0,0, w, w), NoClip); + UpButton->setSubElement(true); + } + if (sprites) + { + UpButton->setSpriteBank(sprites); + UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_UP), color); + UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_UP), color); + } + UpButton->setRelativePosition(core::rect(0,0, w, w)); + UpButton->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + if (!DownButton) + { + DownButton = new CGUIButton(Environment, this, -1, core::rect(0,RelativeRect.getHeight()-w, w, RelativeRect.getHeight()), NoClip); + DownButton->setSubElement(true); + } + if (sprites) + { + DownButton->setSpriteBank(sprites); + DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_DOWN), color); + DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_DOWN), color); + } + DownButton->setRelativePosition(core::rect(0,RelativeRect.getHeight()-w, w, RelativeRect.getHeight())); + DownButton->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); + } +} + +//! Writes attributes of the element. +void CGUIScrollBar::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +{ + IGUIScrollBar::serializeAttributes(out,options); + + out->addBool("Horizontal", Horizontal); + out->addInt ("Value", Pos); + out->addInt ("Max", Max); + out->addInt ("SmallStep", SmallStep); +} + +//! Reads attributes of the element +void CGUIScrollBar::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +{ + IGUIScrollBar::deserializeAttributes(in,options); + + Horizontal = in->getAttributeAsBool("Horizontal"); + setMax(in->getAttributeAsInt("Max")); + setPos(in->getAttributeAsInt("Value")); + setSmallStep(in->getAttributeAsInt("SmallStep")); + NoClip = in->getAttributeAsBool("NoClip"); + + refreshControls(); +} + + +} // end namespace gui +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CGUIScrollBar.h b/src/dep/src/irrlicht/CGUIScrollBar.h index f40e0f9..0ad3d85 100644 --- a/src/dep/src/irrlicht/CGUIScrollBar.h +++ b/src/dep/src/irrlicht/CGUIScrollBar.h @@ -1,80 +1,80 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_SCROLL_BAR_H_INCLUDED__ -#define __C_GUI_SCROLL_BAR_H_INCLUDED__ - - -#include "IGUIScrollBar.h" -#include "IGUIButton.h" - -namespace irr -{ -namespace gui -{ - - class CGUIScrollBar : public IGUIScrollBar - { - public: - - //! constructor - CGUIScrollBar(bool horizontal, IGUIEnvironment* environment, - IGUIElement* parent, s32 id, core::rect rectangle, - bool noclip=false); - - //! destructor - ~CGUIScrollBar(); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! draws the element and its children - virtual void draw(); - - //! sets the position of the scrollbar - virtual void setPos(s32 pos); - - //! sets the maximum value of the scrollbar. must be > 0 - virtual void setMax(s32 max); - - //! sets the small step value - virtual void setSmallStep(s32 step); - - //! gets the current position of the scrollbar - virtual s32 getPos(); - - //! updates the rectangle - virtual void updateAbsolutePosition(); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - - private: - - void refreshControls(); - void setPosFromMousePos(s32 x, s32 y); - - IGUIButton* UpButton; - IGUIButton* DownButton; - - bool Dragging; - bool Horizontal; - s32 Pos; - s32 DrawPos; - s32 DrawHeight; - s32 Max; - s32 SmallStep; - - - }; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_SCROLL_BAR_H_INCLUDED__ +#define __C_GUI_SCROLL_BAR_H_INCLUDED__ + + +#include "IGUIScrollBar.h" +#include "IGUIButton.h" + +namespace irr +{ +namespace gui +{ + + class CGUIScrollBar : public IGUIScrollBar + { + public: + + //! constructor + CGUIScrollBar(bool horizontal, IGUIEnvironment* environment, + IGUIElement* parent, s32 id, core::rect rectangle, + bool noclip=false); + + //! destructor + ~CGUIScrollBar(); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! draws the element and its children + virtual void draw(); + + //! sets the position of the scrollbar + virtual void setPos(s32 pos); + + //! sets the maximum value of the scrollbar. must be > 0 + virtual void setMax(s32 max); + + //! sets the small step value + virtual void setSmallStep(s32 step); + + //! gets the current position of the scrollbar + virtual s32 getPos(); + + //! updates the rectangle + virtual void updateAbsolutePosition(); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + + private: + + void refreshControls(); + void setPosFromMousePos(s32 x, s32 y); + + IGUIButton* UpButton; + IGUIButton* DownButton; + + bool Dragging; + bool Horizontal; + s32 Pos; + s32 DrawPos; + s32 DrawHeight; + s32 Max; + s32 SmallStep; + + + }; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUISkin.cpp b/src/dep/src/irrlicht/CGUISkin.cpp index 45976be..229945d 100644 --- a/src/dep/src/irrlicht/CGUISkin.cpp +++ b/src/dep/src/irrlicht/CGUISkin.cpp @@ -1,803 +1,803 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUISkin.h" -#include "IGUIFont.h" -#include "IGUISpriteBank.h" -#include "IVideoDriver.h" -#include "IAttributes.h" -#include "SoftwareDriver2_helper.h" - -namespace irr -{ -namespace gui -{ - -CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver) -: Font(0), SpriteBank(0), Driver(driver), Type(type) -{ - #ifdef _DEBUG - setDebugName("CGUISkin"); - #endif - - if ( (Type == EGST_WINDOWS_CLASSIC) | - (Type == EGST_WINDOWS_METALLIC) - ) - { - Colors[EGDC_3D_DARK_SHADOW] = video::SColor(101,50,50,50); - Colors[EGDC_3D_SHADOW] = video::SColor(101,130,130,130); - Colors[EGDC_3D_FACE] = video::SColor(101,210,210,210); - Colors[EGDC_3D_HIGH_LIGHT] = video::SColor(101,255,255,255); - Colors[EGDC_3D_LIGHT] = video::SColor(101,210,210,210); - Colors[EGDC_ACTIVE_BORDER] = video::SColor(101,16,14,115); - Colors[EGDC_ACTIVE_CAPTION] = video::SColor(240,255,255,255); - Colors[EGDC_APP_WORKSPACE] = video::SColor(101,100,100,100); - Colors[EGDC_BUTTON_TEXT] = video::SColor(240,10,10,10); - Colors[EGDC_GRAY_TEXT] = video::SColor(240,130,130,130); - Colors[EGDC_HIGH_LIGHT] = video::SColor(101,8,36,107); - Colors[EGDC_HIGH_LIGHT_TEXT] = video::SColor(240,255,255,255); - Colors[EGDC_INACTIVE_BORDER] = video::SColor(101,165,165,165); - Colors[EGDC_INACTIVE_CAPTION] = video::SColor(101,210,210,210); - Colors[EGDC_TOOLTIP] = video::SColor(101,255,255,230); - Colors[EGDC_SCROLLBAR] = video::SColor(101,230,230,230); - Colors[EGDC_WINDOW] = video::SColor(101,255,255,255); - Colors[EGDC_WINDOW_SYMBOL] = video::SColor(240,10,10,10); - Colors[EGDC_ICON] = video::SColor(240,255,255,255); - Colors[EGDC_ICON_HIGH_LIGHT] = video::SColor(240,10,10,10); - - Sizes[EGDS_SCROLLBAR_SIZE] = 14; - Sizes[EGDS_MENU_HEIGHT] = 30; - Sizes[EGDS_WINDOW_BUTTON_WIDTH] = 15; - Sizes[EGDS_CHECK_BOX_WIDTH] = 18; - Sizes[EGDS_MESSAGE_BOX_WIDTH] = 500; - Sizes[EGDS_MESSAGE_BOX_HEIGHT] = 200; - Sizes[EGDS_BUTTON_WIDTH] = 80; - Sizes[EGDS_BUTTON_HEIGHT] = 30; - - Sizes[EGDS_TEXT_DISTANCE_X] = 2; - Sizes[EGDS_TEXT_DISTANCE_Y] = 0; - - } - else - { - //0x80a6a8af - Colors[EGDC_3D_DARK_SHADOW] = 0x60767982; - //Colors[EGDC_3D_FACE] = 0xc0c9ccd4; // tab background - Colors[EGDC_3D_FACE] = 0xc0cbd2d9; // tab background - Colors[EGDC_3D_SHADOW] = 0x50e4e8f1; // tab background, and left-top highlight - Colors[EGDC_3D_HIGH_LIGHT] = 0x40c7ccdc; - Colors[EGDC_3D_LIGHT] = 0x802e313a; - Colors[EGDC_ACTIVE_BORDER] = 0x80404040; // window title - Colors[EGDC_ACTIVE_CAPTION] = 0xf0d0d0d0; - Colors[EGDC_APP_WORKSPACE] = 0xc0646464; // unused - Colors[EGDC_BUTTON_TEXT] = 0xd0161616; - Colors[EGDC_GRAY_TEXT] = 0x3c141414; - Colors[EGDC_HIGH_LIGHT] = 0x6c606060; - Colors[EGDC_HIGH_LIGHT_TEXT]= 0xd0e0e0e0; - Colors[EGDC_INACTIVE_BORDER]= 0xf0a5a5a5; - Colors[EGDC_INACTIVE_CAPTION]= 0xf0d2d2d2; - Colors[EGDC_TOOLTIP] = 0xf00f2033; - Colors[EGDC_SCROLLBAR] = 0xf0e0e0e0; - Colors[EGDC_WINDOW] = 0xf0f0f0f0; - Colors[EGDC_WINDOW_SYMBOL] = 0xd0161616; - Colors[EGDC_ICON] = 0xd0161616; - Colors[EGDC_ICON_HIGH_LIGHT]= 0xd0e0e0e0; - - Sizes[EGDS_SCROLLBAR_SIZE] = 14; - Sizes[EGDS_MENU_HEIGHT] = 48; - Sizes[EGDS_WINDOW_BUTTON_WIDTH] = 15; - Sizes[EGDS_CHECK_BOX_WIDTH] = 18; - Sizes[EGDS_MESSAGE_BOX_WIDTH] = 500; - Sizes[EGDS_MESSAGE_BOX_HEIGHT] = 200; - Sizes[EGDS_BUTTON_WIDTH] = 80; - Sizes[EGDS_BUTTON_HEIGHT] = 30; - - Sizes[EGDS_TEXT_DISTANCE_X] = 3; - Sizes[EGDS_TEXT_DISTANCE_Y] = 2; - } - - Texts[EGDT_MSG_BOX_OK] = L"OK"; - Texts[EGDT_MSG_BOX_CANCEL] = L"Cancel"; - Texts[EGDT_MSG_BOX_YES] = L"Yes"; - Texts[EGDT_MSG_BOX_NO] = L"No"; - Texts[EGDT_WINDOW_CLOSE] = L"Close"; - Texts[EGDT_WINDOW_RESTORE] = L"Restore"; - Texts[EGDT_WINDOW_MINIMIZE] = L"Minimize"; - Texts[EGDT_WINDOW_MAXIMIZE] = L"Maximize"; - - Icons[EGDI_WINDOW_MAXIMIZE] = 225; - Icons[EGDI_WINDOW_RESTORE] = 226; - Icons[EGDI_WINDOW_CLOSE] = 227; - Icons[EGDI_WINDOW_MINIMIZE] = 228; - Icons[EGDI_CURSOR_UP] = 229; - Icons[EGDI_CURSOR_DOWN] = 230; - Icons[EGDI_CURSOR_LEFT] = 231; - Icons[EGDI_CURSOR_RIGHT] = 232; - Icons[EGDI_MENU_MORE] = 232; - Icons[EGDI_CHECK_BOX_CHECKED] = 233; - Icons[EGDI_DROP_DOWN] = 234; - Icons[EGDI_SMALL_CURSOR_UP] = 235; - Icons[EGDI_SMALL_CURSOR_DOWN] = 236; - Icons[EGDI_RADIO_BUTTON_CHECKED] = 237; - Icons[EGDI_FILE] = 238; - Icons[EGDI_DIRECTORY] = 239; - - UseGradient = (Type == EGST_WINDOWS_METALLIC) || - (Type == EGST_BURNING_SKIN) ; -} - - -//! destructor -CGUISkin::~CGUISkin() -{ - if (Font) - Font->drop(); - if (SpriteBank) - SpriteBank->drop(); -} - - - -//! returns default color -video::SColor CGUISkin::getColor(EGUI_DEFAULT_COLOR color) -{ - return Colors[color]; -} - - -//! sets a default color -void CGUISkin::setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) -{ - if (which>=0 && which<= EGDC_COUNT) - Colors[which] = newColor; -} - - -//! returns default color -s32 CGUISkin::getSize(EGUI_DEFAULT_SIZE size) -{ - return Sizes[size]; -} - - - -//! sets a default size -void CGUISkin::setSize(EGUI_DEFAULT_SIZE which, s32 size) -{ - if (which >= 0 && which <= EGDS_COUNT) - Sizes[which] = size; -} - - - -//! returns the default font -IGUIFont* CGUISkin::getFont() -{ - return Font; -} - -//! sets a default font -void CGUISkin::setFont(IGUIFont* font) -{ - if (Font) - Font->drop(); - - Font = font; - - if (Font) - Font->grab(); -} - -IGUISpriteBank* CGUISkin::getSpriteBank() -{ - return SpriteBank; -} - -void CGUISkin::setSpriteBank(IGUISpriteBank* bank) -{ - if (SpriteBank) - SpriteBank->drop(); - - if (bank) - bank->grab(); - - SpriteBank = bank; -} - -//! Returns a default icon -u32 CGUISkin::getIcon(EGUI_DEFAULT_ICON icon) -{ - return Icons[icon]; -} - -//! Sets a default icon -void CGUISkin::setIcon(EGUI_DEFAULT_ICON icon, u32 index) -{ - Icons[icon] = index; -} - -//! Returns a default text. For example for Message box button captions: -//! "OK", "Cancel", "Yes", "No" and so on. -const wchar_t* CGUISkin::getDefaultText(EGUI_DEFAULT_TEXT text) -{ - return Texts[text].c_str(); -} - - -//! Sets a default text. For example for Message box button captions: -//! "OK", "Cancel", "Yes", "No" and so on. -void CGUISkin::setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText) -{ - Texts[which] = newText; -} - -//! draws a standard 3d button pane -/** Used for drawing for example buttons in normal state. -It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and -EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. -\param rect: Defining area where to draw. -\param clip: Clip area. -\param element: Pointer to the element which whiches to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. */ -void CGUISkin::draw3DButtonPaneStandard(IGUIElement* element, - const core::rect& r, - const core::rect* clip) -{ - if (!Driver) - return; - - core::rect rect = r; - - if ( Type == EGST_BURNING_SKIN ) - { - rect.UpperLeftCorner.X -= 1; - rect.UpperLeftCorner.Y -= 1; - rect.LowerRightCorner.X += 1; - rect.LowerRightCorner.Y += 1; - draw3DSunkenPane(element, - getColor( EGDC_WINDOW ).getInterpolated( 0xFFFFFFFF, 0.9f ) - ,false, true, rect, clip); - return; - } - - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); - - rect.LowerRightCorner.X -= 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - - rect.UpperLeftCorner.X += 1; - rect.UpperLeftCorner.Y += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect.LowerRightCorner.X -= 1; - rect.LowerRightCorner.Y -= 1; - - if (!UseGradient) - { - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); - } - else - { - video::SColor c1 = getColor(EGDC_3D_FACE); - video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f); - Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); - } -} - - -//! draws a pressed 3d button pane -/** Used for drawing for example buttons in pressed state. -It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and -EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. -\param rect: Defining area where to draw. -\param clip: Clip area. -\param element: Pointer to the element which whiches to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. */ -void CGUISkin::draw3DButtonPanePressed(IGUIElement* element, - const core::rect& r, - const core::rect* clip) -{ - if (!Driver) - return; - - core::rect rect = r; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - - rect.LowerRightCorner.X -= 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); - - rect.UpperLeftCorner.X += 1; - rect.UpperLeftCorner.Y += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect.UpperLeftCorner.X += 1; - rect.UpperLeftCorner.Y += 1; - - if (!UseGradient) - { - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); - } - else - { - video::SColor c1 = getColor(EGDC_3D_FACE); - video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f); - Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); - } -} - - -//! draws a sunken 3d pane -/** Used for drawing the background of edit, combo or check boxes. -\param element: Pointer to the element which whiches to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. -\param bgcolor: Background color. -\param flat: Specifies if the sunken pane should be flat or displayed as sunken - deep into the ground. -\param rect: Defining area where to draw. -\param clip: Clip area. */ -void CGUISkin::draw3DSunkenPane(IGUIElement* element, - video::SColor bgcolor, bool flat, bool fillBackGround, - const core::rect& r, - const core::rect* clip) -{ - if (!Driver) - return; - - core::rect rect = r; - - - if (flat) - { - // draw flat sunken pane - if (fillBackGround) - Driver->draw2DRectangle(bgcolor, rect, clip); - - rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect = r; - rect.UpperLeftCorner.X = rect.LowerRightCorner.X - 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - - rect = r; - rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - } - else - { - // draw deep sunken pane - if (fillBackGround) - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - - rect.LowerRightCorner.X -= 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect.UpperLeftCorner.X += 1; - rect.UpperLeftCorner.Y += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_LIGHT), rect, clip); - - rect.LowerRightCorner.X -= 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); - - rect.UpperLeftCorner.X += 1; - rect.UpperLeftCorner.Y += 1; - Driver->draw2DRectangle(bgcolor, rect, clip); - } -} - - -//! draws a window background -/** Used for drawing the background of dialogs and windows. -\param element: Pointer to the element which whiches to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. -\param titleBarColor: Title color. -\param drawTitleBar: True to enable title drawing. -\param rect: Defining area where to draw. -\param clip: Clip area. -\return Returns rect where to draw title bar text. */ -core::rect CGUISkin::draw3DWindowBackground(IGUIElement* element, - bool drawTitleBar, video::SColor titleBarColor, - const core::rect& r, - const core::rect* cl) -{ - if (!Driver) - return r; - - core::rect rect = r; - - - rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, cl); - - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, cl); - - rect.UpperLeftCorner.X = r.LowerRightCorner.X - 1; - rect.LowerRightCorner.X = r.LowerRightCorner.X; - rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y; - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, cl); - - rect.UpperLeftCorner.X -= 1; - rect.LowerRightCorner.X -= 1; - rect.UpperLeftCorner.Y += 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, cl); - - rect.UpperLeftCorner.X = r.UpperLeftCorner.X; - rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - rect.LowerRightCorner.X = r.LowerRightCorner.X; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, cl); - - rect.UpperLeftCorner.X += 1; - rect.LowerRightCorner.X -= 1; - rect.UpperLeftCorner.Y -= 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, cl); - - rect = r; - rect.UpperLeftCorner.X +=1; - rect.UpperLeftCorner.Y +=1; - rect.LowerRightCorner.X -= 2; - rect.LowerRightCorner.Y -= 2; - - if (!UseGradient) - { - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, cl); - } - else - if ( Type == EGST_BURNING_SKIN ) - { - video::SColor c1 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.9f ); - video::SColor c2 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.8f ); - - Driver->draw2DRectangle(rect, c1, c1, c2, c2, cl); - } - else - { - video::SColor c2 = getColor(EGDC_3D_SHADOW); - video::SColor c1 = getColor(EGDC_3D_FACE); - Driver->draw2DRectangle(rect, c1, c1, c1, c2, cl); - } - - rect = r; - rect.UpperLeftCorner.X += 2; - rect.UpperLeftCorner.Y += 2; - rect.LowerRightCorner.X -= 2; - rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + getSize(EGDS_WINDOW_BUTTON_WIDTH) + 2; - - if (drawTitleBar) - { - // draw title bar - //if (!UseGradient) - // Driver->draw2DRectangle(titleBarColor, rect, cl); - //else - if ( Type == EGST_BURNING_SKIN ) - { - video::SColor c = titleBarColor.getInterpolated( 0xffffffff, 0.8f); - Driver->draw2DRectangle(rect, titleBarColor, titleBarColor, c, c, cl); - } - else - { - video::SColor c = titleBarColor.getInterpolated(video::SColor(255,0,0,0), 0.2f); - Driver->draw2DRectangle(rect, titleBarColor, c, titleBarColor, c, cl); - } - } - - return rect; -} - - -//! draws a standard 3d menu pane -/** Used for drawing for menus and context menus. -It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and -EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. -\param element: Pointer to the element which whiches to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. -\param rect: Defining area where to draw. -\param clip: Clip area. */ -void CGUISkin::draw3DMenuPane(IGUIElement* element, - const core::rect& r, const core::rect* clip) -{ - if ( Type == EGST_BURNING_SKIN ) - { - core::rect rect = r; - rect.UpperLeftCorner.Y -= 3; - draw3DButtonPaneStandard(element, rect, clip); - return; - } - - if (!Driver) - return; - - // in this skin, this is exactly what non pressed buttons look like, - // so we could simply call - // draw3DButtonPaneStandard(element, rect, clip); - // here. - // but if the skin is transparent, this doesn't look that nice. So - // We draw it a little bit better, with some more draw2DRectangle calls, - // but there aren't that much menus visible anyway. - - core::rect rect = r; - rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - - rect.UpperLeftCorner.X = r.LowerRightCorner.X - 1; - rect.LowerRightCorner.X = r.LowerRightCorner.X; - rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y; - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); - - rect.UpperLeftCorner.X -= 1; - rect.LowerRightCorner.X -= 1; - rect.UpperLeftCorner.Y += 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect.UpperLeftCorner.X = r.UpperLeftCorner.X; - rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - rect.LowerRightCorner.X = r.LowerRightCorner.X; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); - - rect.UpperLeftCorner.X += 1; - rect.LowerRightCorner.X -= 1; - rect.UpperLeftCorner.Y -= 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect = r; - rect.UpperLeftCorner.X +=1; - rect.UpperLeftCorner.Y +=1; - rect.LowerRightCorner.X -= 2; - rect.LowerRightCorner.Y -= 2; - - if (!UseGradient) - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); - else - { - video::SColor c1 = getColor(EGDC_3D_FACE); - video::SColor c2 = getColor(EGDC_3D_SHADOW); - Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); - } -} - - -//! draws a standard 3d tool bar -/** Used for drawing for toolbars and menus. -\param element: Pointer to the element which whiches to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. -\param rect: Defining area where to draw. -\param clip: Clip area. */ -void CGUISkin::draw3DToolBar(IGUIElement* element, - const core::rect& r, - const core::rect* clip) -{ - if (!Driver) - return; - - core::rect rect = r; - - rect.UpperLeftCorner.X = r.UpperLeftCorner.X; - rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - rect.LowerRightCorner.X = r.LowerRightCorner.X; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect = r; - rect.LowerRightCorner.Y -= 1; - - if (!UseGradient) - { - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); - } - else - if ( Type == EGST_BURNING_SKIN ) - { - video::SColor c1 = 0xF0000000 | getColor(EGDC_3D_FACE).color; - video::SColor c2 = 0xF0000000 | getColor(EGDC_3D_SHADOW).color; - - rect.LowerRightCorner.Y += 1; - Driver->draw2DRectangle(rect, c1, c2, c1, c2, clip); - - } - else - { - video::SColor c1 = getColor(EGDC_3D_FACE); - video::SColor c2 = getColor(EGDC_3D_SHADOW); - Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); - } -} - -//! draws a tab button -/** Used for drawing for tab buttons on top of tabs. -\param element: Pointer to the element which whiches to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. -\param active: Specifies if the tab is currently active. -\param rect: Defining area where to draw. -\param clip: Clip area. */ -void CGUISkin::draw3DTabButton(IGUIElement* element, bool active, - const core::rect& frameRect, const core::rect* clip) -{ - if (!Driver) - return; - - core::rect tr = frameRect; - - tr.LowerRightCorner.X -= 2; - tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1; - tr.UpperLeftCorner.X += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); - - // draw left highlight - tr = frameRect; - tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; - tr.UpperLeftCorner.Y += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); - - // draw grey background - tr = frameRect; - tr.UpperLeftCorner.X += 1; - tr.UpperLeftCorner.Y += 1; - tr.LowerRightCorner.X -= 2; - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); - - // draw right middle gray shadow - tr.LowerRightCorner.X += 1; - tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); - - tr.LowerRightCorner.X += 1; - tr.UpperLeftCorner.X += 1; - tr.UpperLeftCorner.Y += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip); -} - - -//! draws a tab control body -/** \param element: Pointer to the element which whiches to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. -\param border: Specifies if the border should be drawn. -\param background: Specifies if the background should be drawn. -\param rect: Defining area where to draw. -\param clip: Clip area. */ -void CGUISkin::draw3DTabBody(IGUIElement* element, bool border, bool background, - const core::rect& rect, const core::rect* clip) -{ - if (!Driver) - return; - - core::rect tr = rect; - - // draw border. - if (border) - { - // draw left hightlight - tr.UpperLeftCorner.Y += getSize(gui::EGDS_BUTTON_HEIGHT) + 2; - tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); - - // draw right shadow - tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1; - tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); - - // draw lower shadow - tr = rect; - tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); - } - - if (background) - { - tr = rect; - tr.UpperLeftCorner.Y += getSize(gui::EGDS_BUTTON_HEIGHT) + 2; - tr.LowerRightCorner.X -= 1; - tr.UpperLeftCorner.X += 1; - tr.LowerRightCorner.Y -= 1; - - if (!UseGradient) - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); - else - { - video::SColor c1 = getColor(EGDC_3D_FACE); - video::SColor c2 = getColor(EGDC_3D_SHADOW); - Driver->draw2DRectangle(tr, c1, c1, c2, c2, clip); - } - } -} - -//! draws an icon, usually from the skin's sprite bank -/** \param parent: Pointer to the element which wishes to draw this icon. -This parameter is usually not used by IGUISkin, but can be used for example -by more complex implementations to find out how to draw the part exactly. -\param icon: Specifies the icon to be drawn. -\param position: The position to draw the icon -\param starttime: The time at the start of the animation -\param currenttime: The present time, used to calculate the frame number -\param loop: Whether the animation should loop or not -\param clip: Clip area. */ -void CGUISkin::drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon, - const core::position2di position, u32 starttime, u32 currenttime, - bool loop, const core::rect* clip) -{ - if (!SpriteBank) - return; - - SpriteBank->draw2DSprite(Icons[icon], position, clip, - video::SColor(255,0,0,0), starttime, currenttime, loop, true); - -} - -EGUI_SKIN_TYPE CGUISkin::getType() -{ - return Type; -} - -//! Writes attributes of the object. -//! Implement this to expose the attributes of your scene node animator for -//! scripting languages, editors, debuggers or xml serialization purposes. -void CGUISkin::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - u32 i; - for (i=0; iaddColor(GUISkinColorNames[i], Colors[i]); - - for (i=0; iaddInt(GUISkinSizeNames[i], Sizes[i]); - - for (i=0; iaddString(GUISkinTextNames[i], Texts[i].c_str()); - - for (i=0; iaddInt(GUISkinIconNames[i], Icons[i]); -} - -//! Reads attributes of the object. -//! Implement this to set the attributes of your scene node animator for -//! scripting languages, editors, debuggers or xml deserialization purposes. -void CGUISkin::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - u32 i; - for (i=0; igetAttributeAsColor(GUISkinColorNames[i]); - - for (i=0; igetAttributeAsInt(GUISkinSizeNames[i]); - - for (i=0; igetAttributeAsStringW(GUISkinTextNames[i]); - - for (i=0; igetAttributeAsInt(GUISkinIconNames[i]); - -} - - -} // end namespace gui -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUISkin.h" +#include "IGUIFont.h" +#include "IGUISpriteBank.h" +#include "IVideoDriver.h" +#include "IAttributes.h" +#include "SoftwareDriver2_helper.h" + +namespace irr +{ +namespace gui +{ + +CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver) +: Font(0), SpriteBank(0), Driver(driver), Type(type) +{ + #ifdef _DEBUG + setDebugName("CGUISkin"); + #endif + + if ( (Type == EGST_WINDOWS_CLASSIC) | + (Type == EGST_WINDOWS_METALLIC) + ) + { + Colors[EGDC_3D_DARK_SHADOW] = video::SColor(101,50,50,50); + Colors[EGDC_3D_SHADOW] = video::SColor(101,130,130,130); + Colors[EGDC_3D_FACE] = video::SColor(101,210,210,210); + Colors[EGDC_3D_HIGH_LIGHT] = video::SColor(101,255,255,255); + Colors[EGDC_3D_LIGHT] = video::SColor(101,210,210,210); + Colors[EGDC_ACTIVE_BORDER] = video::SColor(101,16,14,115); + Colors[EGDC_ACTIVE_CAPTION] = video::SColor(240,255,255,255); + Colors[EGDC_APP_WORKSPACE] = video::SColor(101,100,100,100); + Colors[EGDC_BUTTON_TEXT] = video::SColor(240,10,10,10); + Colors[EGDC_GRAY_TEXT] = video::SColor(240,130,130,130); + Colors[EGDC_HIGH_LIGHT] = video::SColor(101,8,36,107); + Colors[EGDC_HIGH_LIGHT_TEXT] = video::SColor(240,255,255,255); + Colors[EGDC_INACTIVE_BORDER] = video::SColor(101,165,165,165); + Colors[EGDC_INACTIVE_CAPTION] = video::SColor(101,210,210,210); + Colors[EGDC_TOOLTIP] = video::SColor(101,255,255,230); + Colors[EGDC_SCROLLBAR] = video::SColor(101,230,230,230); + Colors[EGDC_WINDOW] = video::SColor(101,255,255,255); + Colors[EGDC_WINDOW_SYMBOL] = video::SColor(240,10,10,10); + Colors[EGDC_ICON] = video::SColor(240,255,255,255); + Colors[EGDC_ICON_HIGH_LIGHT] = video::SColor(240,10,10,10); + + Sizes[EGDS_SCROLLBAR_SIZE] = 14; + Sizes[EGDS_MENU_HEIGHT] = 30; + Sizes[EGDS_WINDOW_BUTTON_WIDTH] = 15; + Sizes[EGDS_CHECK_BOX_WIDTH] = 18; + Sizes[EGDS_MESSAGE_BOX_WIDTH] = 500; + Sizes[EGDS_MESSAGE_BOX_HEIGHT] = 200; + Sizes[EGDS_BUTTON_WIDTH] = 80; + Sizes[EGDS_BUTTON_HEIGHT] = 30; + + Sizes[EGDS_TEXT_DISTANCE_X] = 2; + Sizes[EGDS_TEXT_DISTANCE_Y] = 0; + + } + else + { + //0x80a6a8af + Colors[EGDC_3D_DARK_SHADOW] = 0x60767982; + //Colors[EGDC_3D_FACE] = 0xc0c9ccd4; // tab background + Colors[EGDC_3D_FACE] = 0xc0cbd2d9; // tab background + Colors[EGDC_3D_SHADOW] = 0x50e4e8f1; // tab background, and left-top highlight + Colors[EGDC_3D_HIGH_LIGHT] = 0x40c7ccdc; + Colors[EGDC_3D_LIGHT] = 0x802e313a; + Colors[EGDC_ACTIVE_BORDER] = 0x80404040; // window title + Colors[EGDC_ACTIVE_CAPTION] = 0xf0d0d0d0; + Colors[EGDC_APP_WORKSPACE] = 0xc0646464; // unused + Colors[EGDC_BUTTON_TEXT] = 0xd0161616; + Colors[EGDC_GRAY_TEXT] = 0x3c141414; + Colors[EGDC_HIGH_LIGHT] = 0x6c606060; + Colors[EGDC_HIGH_LIGHT_TEXT]= 0xd0e0e0e0; + Colors[EGDC_INACTIVE_BORDER]= 0xf0a5a5a5; + Colors[EGDC_INACTIVE_CAPTION]= 0xf0d2d2d2; + Colors[EGDC_TOOLTIP] = 0xf00f2033; + Colors[EGDC_SCROLLBAR] = 0xf0e0e0e0; + Colors[EGDC_WINDOW] = 0xf0f0f0f0; + Colors[EGDC_WINDOW_SYMBOL] = 0xd0161616; + Colors[EGDC_ICON] = 0xd0161616; + Colors[EGDC_ICON_HIGH_LIGHT]= 0xd0e0e0e0; + + Sizes[EGDS_SCROLLBAR_SIZE] = 14; + Sizes[EGDS_MENU_HEIGHT] = 48; + Sizes[EGDS_WINDOW_BUTTON_WIDTH] = 15; + Sizes[EGDS_CHECK_BOX_WIDTH] = 18; + Sizes[EGDS_MESSAGE_BOX_WIDTH] = 500; + Sizes[EGDS_MESSAGE_BOX_HEIGHT] = 200; + Sizes[EGDS_BUTTON_WIDTH] = 80; + Sizes[EGDS_BUTTON_HEIGHT] = 30; + + Sizes[EGDS_TEXT_DISTANCE_X] = 3; + Sizes[EGDS_TEXT_DISTANCE_Y] = 2; + } + + Texts[EGDT_MSG_BOX_OK] = L"OK"; + Texts[EGDT_MSG_BOX_CANCEL] = L"Cancel"; + Texts[EGDT_MSG_BOX_YES] = L"Yes"; + Texts[EGDT_MSG_BOX_NO] = L"No"; + Texts[EGDT_WINDOW_CLOSE] = L"Close"; + Texts[EGDT_WINDOW_RESTORE] = L"Restore"; + Texts[EGDT_WINDOW_MINIMIZE] = L"Minimize"; + Texts[EGDT_WINDOW_MAXIMIZE] = L"Maximize"; + + Icons[EGDI_WINDOW_MAXIMIZE] = 225; + Icons[EGDI_WINDOW_RESTORE] = 226; + Icons[EGDI_WINDOW_CLOSE] = 227; + Icons[EGDI_WINDOW_MINIMIZE] = 228; + Icons[EGDI_CURSOR_UP] = 229; + Icons[EGDI_CURSOR_DOWN] = 230; + Icons[EGDI_CURSOR_LEFT] = 231; + Icons[EGDI_CURSOR_RIGHT] = 232; + Icons[EGDI_MENU_MORE] = 232; + Icons[EGDI_CHECK_BOX_CHECKED] = 233; + Icons[EGDI_DROP_DOWN] = 234; + Icons[EGDI_SMALL_CURSOR_UP] = 235; + Icons[EGDI_SMALL_CURSOR_DOWN] = 236; + Icons[EGDI_RADIO_BUTTON_CHECKED] = 237; + Icons[EGDI_FILE] = 238; + Icons[EGDI_DIRECTORY] = 239; + + UseGradient = (Type == EGST_WINDOWS_METALLIC) || + (Type == EGST_BURNING_SKIN) ; +} + + +//! destructor +CGUISkin::~CGUISkin() +{ + if (Font) + Font->drop(); + if (SpriteBank) + SpriteBank->drop(); +} + + + +//! returns default color +video::SColor CGUISkin::getColor(EGUI_DEFAULT_COLOR color) +{ + return Colors[color]; +} + + +//! sets a default color +void CGUISkin::setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) +{ + if (which>=0 && which<= EGDC_COUNT) + Colors[which] = newColor; +} + + +//! returns default color +s32 CGUISkin::getSize(EGUI_DEFAULT_SIZE size) +{ + return Sizes[size]; +} + + + +//! sets a default size +void CGUISkin::setSize(EGUI_DEFAULT_SIZE which, s32 size) +{ + if (which >= 0 && which <= EGDS_COUNT) + Sizes[which] = size; +} + + + +//! returns the default font +IGUIFont* CGUISkin::getFont() +{ + return Font; +} + +//! sets a default font +void CGUISkin::setFont(IGUIFont* font) +{ + if (Font) + Font->drop(); + + Font = font; + + if (Font) + Font->grab(); +} + +IGUISpriteBank* CGUISkin::getSpriteBank() +{ + return SpriteBank; +} + +void CGUISkin::setSpriteBank(IGUISpriteBank* bank) +{ + if (SpriteBank) + SpriteBank->drop(); + + if (bank) + bank->grab(); + + SpriteBank = bank; +} + +//! Returns a default icon +u32 CGUISkin::getIcon(EGUI_DEFAULT_ICON icon) +{ + return Icons[icon]; +} + +//! Sets a default icon +void CGUISkin::setIcon(EGUI_DEFAULT_ICON icon, u32 index) +{ + Icons[icon] = index; +} + +//! Returns a default text. For example for Message box button captions: +//! "OK", "Cancel", "Yes", "No" and so on. +const wchar_t* CGUISkin::getDefaultText(EGUI_DEFAULT_TEXT text) +{ + return Texts[text].c_str(); +} + + +//! Sets a default text. For example for Message box button captions: +//! "OK", "Cancel", "Yes", "No" and so on. +void CGUISkin::setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText) +{ + Texts[which] = newText; +} + +//! draws a standard 3d button pane +/** Used for drawing for example buttons in normal state. +It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and +EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. +\param rect: Defining area where to draw. +\param clip: Clip area. +\param element: Pointer to the element which whiches to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. */ +void CGUISkin::draw3DButtonPaneStandard(IGUIElement* element, + const core::rect& r, + const core::rect* clip) +{ + if (!Driver) + return; + + core::rect rect = r; + + if ( Type == EGST_BURNING_SKIN ) + { + rect.UpperLeftCorner.X -= 1; + rect.UpperLeftCorner.Y -= 1; + rect.LowerRightCorner.X += 1; + rect.LowerRightCorner.Y += 1; + draw3DSunkenPane(element, + getColor( EGDC_WINDOW ).getInterpolated( 0xFFFFFFFF, 0.9f ) + ,false, true, rect, clip); + return; + } + + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); + + rect.LowerRightCorner.X -= 1; + rect.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); + + rect.UpperLeftCorner.X += 1; + rect.UpperLeftCorner.Y += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + + rect.LowerRightCorner.X -= 1; + rect.LowerRightCorner.Y -= 1; + + if (!UseGradient) + { + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); + } + else + { + video::SColor c1 = getColor(EGDC_3D_FACE); + video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f); + Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); + } +} + + +//! draws a pressed 3d button pane +/** Used for drawing for example buttons in pressed state. +It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and +EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. +\param rect: Defining area where to draw. +\param clip: Clip area. +\param element: Pointer to the element which whiches to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. */ +void CGUISkin::draw3DButtonPanePressed(IGUIElement* element, + const core::rect& r, + const core::rect* clip) +{ + if (!Driver) + return; + + core::rect rect = r; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); + + rect.LowerRightCorner.X -= 1; + rect.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); + + rect.UpperLeftCorner.X += 1; + rect.UpperLeftCorner.Y += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + + rect.UpperLeftCorner.X += 1; + rect.UpperLeftCorner.Y += 1; + + if (!UseGradient) + { + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); + } + else + { + video::SColor c1 = getColor(EGDC_3D_FACE); + video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f); + Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); + } +} + + +//! draws a sunken 3d pane +/** Used for drawing the background of edit, combo or check boxes. +\param element: Pointer to the element which whiches to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. +\param bgcolor: Background color. +\param flat: Specifies if the sunken pane should be flat or displayed as sunken + deep into the ground. +\param rect: Defining area where to draw. +\param clip: Clip area. */ +void CGUISkin::draw3DSunkenPane(IGUIElement* element, + video::SColor bgcolor, bool flat, bool fillBackGround, + const core::rect& r, + const core::rect* clip) +{ + if (!Driver) + return; + + core::rect rect = r; + + + if (flat) + { + // draw flat sunken pane + if (fillBackGround) + Driver->draw2DRectangle(bgcolor, rect, clip); + + rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + + rect = r; + rect.UpperLeftCorner.X = rect.LowerRightCorner.X - 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); + + rect = r; + rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); + } + else + { + // draw deep sunken pane + if (fillBackGround) + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); + + rect.LowerRightCorner.X -= 1; + rect.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + + rect.UpperLeftCorner.X += 1; + rect.UpperLeftCorner.Y += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_LIGHT), rect, clip); + + rect.LowerRightCorner.X -= 1; + rect.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); + + rect.UpperLeftCorner.X += 1; + rect.UpperLeftCorner.Y += 1; + Driver->draw2DRectangle(bgcolor, rect, clip); + } +} + + +//! draws a window background +/** Used for drawing the background of dialogs and windows. +\param element: Pointer to the element which whiches to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. +\param titleBarColor: Title color. +\param drawTitleBar: True to enable title drawing. +\param rect: Defining area where to draw. +\param clip: Clip area. +\return Returns rect where to draw title bar text. */ +core::rect CGUISkin::draw3DWindowBackground(IGUIElement* element, + bool drawTitleBar, video::SColor titleBarColor, + const core::rect& r, + const core::rect* cl) +{ + if (!Driver) + return r; + + core::rect rect = r; + + + rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, cl); + + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, cl); + + rect.UpperLeftCorner.X = r.LowerRightCorner.X - 1; + rect.LowerRightCorner.X = r.LowerRightCorner.X; + rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y; + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, cl); + + rect.UpperLeftCorner.X -= 1; + rect.LowerRightCorner.X -= 1; + rect.UpperLeftCorner.Y += 1; + rect.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, cl); + + rect.UpperLeftCorner.X = r.UpperLeftCorner.X; + rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + rect.LowerRightCorner.X = r.LowerRightCorner.X; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, cl); + + rect.UpperLeftCorner.X += 1; + rect.LowerRightCorner.X -= 1; + rect.UpperLeftCorner.Y -= 1; + rect.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, cl); + + rect = r; + rect.UpperLeftCorner.X +=1; + rect.UpperLeftCorner.Y +=1; + rect.LowerRightCorner.X -= 2; + rect.LowerRightCorner.Y -= 2; + + if (!UseGradient) + { + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, cl); + } + else + if ( Type == EGST_BURNING_SKIN ) + { + video::SColor c1 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.9f ); + video::SColor c2 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.8f ); + + Driver->draw2DRectangle(rect, c1, c1, c2, c2, cl); + } + else + { + video::SColor c2 = getColor(EGDC_3D_SHADOW); + video::SColor c1 = getColor(EGDC_3D_FACE); + Driver->draw2DRectangle(rect, c1, c1, c1, c2, cl); + } + + rect = r; + rect.UpperLeftCorner.X += 2; + rect.UpperLeftCorner.Y += 2; + rect.LowerRightCorner.X -= 2; + rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + getSize(EGDS_WINDOW_BUTTON_WIDTH) + 2; + + if (drawTitleBar) + { + // draw title bar + //if (!UseGradient) + // Driver->draw2DRectangle(titleBarColor, rect, cl); + //else + if ( Type == EGST_BURNING_SKIN ) + { + video::SColor c = titleBarColor.getInterpolated( 0xffffffff, 0.8f); + Driver->draw2DRectangle(rect, titleBarColor, titleBarColor, c, c, cl); + } + else + { + video::SColor c = titleBarColor.getInterpolated(video::SColor(255,0,0,0), 0.2f); + Driver->draw2DRectangle(rect, titleBarColor, c, titleBarColor, c, cl); + } + } + + return rect; +} + + +//! draws a standard 3d menu pane +/** Used for drawing for menus and context menus. +It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and +EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. +\param element: Pointer to the element which whiches to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. +\param rect: Defining area where to draw. +\param clip: Clip area. */ +void CGUISkin::draw3DMenuPane(IGUIElement* element, + const core::rect& r, const core::rect* clip) +{ + if ( Type == EGST_BURNING_SKIN ) + { + core::rect rect = r; + rect.UpperLeftCorner.Y -= 3; + draw3DButtonPaneStandard(element, rect, clip); + return; + } + + if (!Driver) + return; + + // in this skin, this is exactly what non pressed buttons look like, + // so we could simply call + // draw3DButtonPaneStandard(element, rect, clip); + // here. + // but if the skin is transparent, this doesn't look that nice. So + // We draw it a little bit better, with some more draw2DRectangle calls, + // but there aren't that much menus visible anyway. + + core::rect rect = r; + rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); + + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); + + rect.UpperLeftCorner.X = r.LowerRightCorner.X - 1; + rect.LowerRightCorner.X = r.LowerRightCorner.X; + rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y; + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); + + rect.UpperLeftCorner.X -= 1; + rect.LowerRightCorner.X -= 1; + rect.UpperLeftCorner.Y += 1; + rect.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + + rect.UpperLeftCorner.X = r.UpperLeftCorner.X; + rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + rect.LowerRightCorner.X = r.LowerRightCorner.X; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); + + rect.UpperLeftCorner.X += 1; + rect.LowerRightCorner.X -= 1; + rect.UpperLeftCorner.Y -= 1; + rect.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + + rect = r; + rect.UpperLeftCorner.X +=1; + rect.UpperLeftCorner.Y +=1; + rect.LowerRightCorner.X -= 2; + rect.LowerRightCorner.Y -= 2; + + if (!UseGradient) + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); + else + { + video::SColor c1 = getColor(EGDC_3D_FACE); + video::SColor c2 = getColor(EGDC_3D_SHADOW); + Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); + } +} + + +//! draws a standard 3d tool bar +/** Used for drawing for toolbars and menus. +\param element: Pointer to the element which whiches to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. +\param rect: Defining area where to draw. +\param clip: Clip area. */ +void CGUISkin::draw3DToolBar(IGUIElement* element, + const core::rect& r, + const core::rect* clip) +{ + if (!Driver) + return; + + core::rect rect = r; + + rect.UpperLeftCorner.X = r.UpperLeftCorner.X; + rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + rect.LowerRightCorner.X = r.LowerRightCorner.X; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + + rect = r; + rect.LowerRightCorner.Y -= 1; + + if (!UseGradient) + { + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); + } + else + if ( Type == EGST_BURNING_SKIN ) + { + video::SColor c1 = 0xF0000000 | getColor(EGDC_3D_FACE).color; + video::SColor c2 = 0xF0000000 | getColor(EGDC_3D_SHADOW).color; + + rect.LowerRightCorner.Y += 1; + Driver->draw2DRectangle(rect, c1, c2, c1, c2, clip); + + } + else + { + video::SColor c1 = getColor(EGDC_3D_FACE); + video::SColor c2 = getColor(EGDC_3D_SHADOW); + Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); + } +} + +//! draws a tab button +/** Used for drawing for tab buttons on top of tabs. +\param element: Pointer to the element which whiches to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. +\param active: Specifies if the tab is currently active. +\param rect: Defining area where to draw. +\param clip: Clip area. */ +void CGUISkin::draw3DTabButton(IGUIElement* element, bool active, + const core::rect& frameRect, const core::rect* clip) +{ + if (!Driver) + return; + + core::rect tr = frameRect; + + tr.LowerRightCorner.X -= 2; + tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1; + tr.UpperLeftCorner.X += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + + // draw left highlight + tr = frameRect; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + tr.UpperLeftCorner.Y += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + + // draw grey background + tr = frameRect; + tr.UpperLeftCorner.X += 1; + tr.UpperLeftCorner.Y += 1; + tr.LowerRightCorner.X -= 2; + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); + + // draw right middle gray shadow + tr.LowerRightCorner.X += 1; + tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); + + tr.LowerRightCorner.X += 1; + tr.UpperLeftCorner.X += 1; + tr.UpperLeftCorner.Y += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip); +} + + +//! draws a tab control body +/** \param element: Pointer to the element which whiches to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. +\param border: Specifies if the border should be drawn. +\param background: Specifies if the background should be drawn. +\param rect: Defining area where to draw. +\param clip: Clip area. */ +void CGUISkin::draw3DTabBody(IGUIElement* element, bool border, bool background, + const core::rect& rect, const core::rect* clip) +{ + if (!Driver) + return; + + core::rect tr = rect; + + // draw border. + if (border) + { + // draw left hightlight + tr.UpperLeftCorner.Y += getSize(gui::EGDS_BUTTON_HEIGHT) + 2; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + + // draw right shadow + tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); + + // draw lower shadow + tr = rect; + tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); + } + + if (background) + { + tr = rect; + tr.UpperLeftCorner.Y += getSize(gui::EGDS_BUTTON_HEIGHT) + 2; + tr.LowerRightCorner.X -= 1; + tr.UpperLeftCorner.X += 1; + tr.LowerRightCorner.Y -= 1; + + if (!UseGradient) + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); + else + { + video::SColor c1 = getColor(EGDC_3D_FACE); + video::SColor c2 = getColor(EGDC_3D_SHADOW); + Driver->draw2DRectangle(tr, c1, c1, c2, c2, clip); + } + } +} + +//! draws an icon, usually from the skin's sprite bank +/** \param parent: Pointer to the element which wishes to draw this icon. +This parameter is usually not used by IGUISkin, but can be used for example +by more complex implementations to find out how to draw the part exactly. +\param icon: Specifies the icon to be drawn. +\param position: The position to draw the icon +\param starttime: The time at the start of the animation +\param currenttime: The present time, used to calculate the frame number +\param loop: Whether the animation should loop or not +\param clip: Clip area. */ +void CGUISkin::drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon, + const core::position2di position, u32 starttime, u32 currenttime, + bool loop, const core::rect* clip) +{ + if (!SpriteBank) + return; + + SpriteBank->draw2DSprite(Icons[icon], position, clip, + video::SColor(255,0,0,0), starttime, currenttime, loop, true); + +} + +EGUI_SKIN_TYPE CGUISkin::getType() +{ + return Type; +} + +//! Writes attributes of the object. +//! Implement this to expose the attributes of your scene node animator for +//! scripting languages, editors, debuggers or xml serialization purposes. +void CGUISkin::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + u32 i; + for (i=0; iaddColor(GUISkinColorNames[i], Colors[i]); + + for (i=0; iaddInt(GUISkinSizeNames[i], Sizes[i]); + + for (i=0; iaddString(GUISkinTextNames[i], Texts[i].c_str()); + + for (i=0; iaddInt(GUISkinIconNames[i], Icons[i]); +} + +//! Reads attributes of the object. +//! Implement this to set the attributes of your scene node animator for +//! scripting languages, editors, debuggers or xml deserialization purposes. +void CGUISkin::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + u32 i; + for (i=0; igetAttributeAsColor(GUISkinColorNames[i]); + + for (i=0; igetAttributeAsInt(GUISkinSizeNames[i]); + + for (i=0; igetAttributeAsStringW(GUISkinTextNames[i]); + + for (i=0; igetAttributeAsInt(GUISkinIconNames[i]); + +} + + +} // end namespace gui +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CGUISkin.h b/src/dep/src/irrlicht/CGUISkin.h index ba3f64e..b715bf5 100644 --- a/src/dep/src/irrlicht/CGUISkin.h +++ b/src/dep/src/irrlicht/CGUISkin.h @@ -1,224 +1,224 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_SKIN_H_INCLUDED__ -#define __C_GUI_SKIN_H_INCLUDED__ - -#include "IGUISkin.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - class IVideoDriver; -} -namespace gui -{ - - class CGUISkin : public IGUISkin - { - public: - - CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver); - - //! destructor - ~CGUISkin(); - - //! returns default color - virtual video::SColor getColor(EGUI_DEFAULT_COLOR color); - - //! sets a default color - virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor); - - //! returns default color - virtual s32 getSize(EGUI_DEFAULT_SIZE size); - - //! sets a default size - virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size); - - //! returns the default font - virtual IGUIFont* getFont(); - - //! sets a default font - virtual void setFont(IGUIFont* font); - - //! sets the sprite bank used for drawing icons - virtual void setSpriteBank(IGUISpriteBank* bank); - - //! gets the sprite bank used for drawing icons - virtual IGUISpriteBank* getSpriteBank(); - - //! Returns a default icon - /** Returns the sprite index within the sprite bank */ - virtual u32 getIcon(EGUI_DEFAULT_ICON icon); - - //! Sets a default icon - /** Sets the sprite index used for drawing icons like arrows, - close buttons and ticks in checkboxes - \param icon: Enum specifying which icon to change - \param index: The sprite index used to draw this icon */ - virtual void setIcon(EGUI_DEFAULT_ICON icon, u32 index); - - //! Returns a default text. - /** For example for Message box button captions: - "OK", "Cancel", "Yes", "No" and so on. */ - virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text); - - //! Sets a default text. - /** For example for Message box button captions: - "OK", "Cancel", "Yes", "No" and so on. */ - virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText); - - //! draws a standard 3d button pane - /** Used for drawing for example buttons in normal state. - It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and - EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. - \param rect: Defining area where to draw. - \param clip: Clip area. - \param element: Pointer to the element which whiches to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. */ - virtual void draw3DButtonPaneStandard(IGUIElement* element, - const core::rect& rect, - const core::rect* clip=0); - - //! draws a pressed 3d button pane - /** Used for drawing for example buttons in pressed state. - It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and - EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. - \param rect: Defining area where to draw. - \param clip: Clip area. - \param element: Pointer to the element which whiches to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. */ - virtual void draw3DButtonPanePressed(IGUIElement* element, - const core::rect& rect, - const core::rect* clip=0); - - //! draws a sunken 3d pane - /** Used for drawing the background of edit, combo or check boxes. - \param element: Pointer to the element which whiches to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param bgcolor: Background color. - \param flat: Specifies if the sunken pane should be flat or displayed as sunken - deep into the ground. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DSunkenPane(IGUIElement* element, - video::SColor bgcolor, bool flat, bool fillBackGround, - const core::rect& rect, - const core::rect* clip=0); - - //! draws a window background - /** Used for drawing the background of dialogs and windows. - \param element: Pointer to the element which whiches to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param titleBarColor: Title color. - \param drawTitleBar: True to enable title drawing. - \param rect: Defining area where to draw. - \param clip: Clip area. - \return Returns rect where to draw title bar text. */ - virtual core::rect draw3DWindowBackground(IGUIElement* element, - bool drawTitleBar, video::SColor titleBarColor, - const core::rect& rect, - const core::rect* clip=0); - - //! draws a standard 3d menu pane - /** Used for drawing for menus and context menus. - It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and - EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. - \param element: Pointer to the element which whishes to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DMenuPane(IGUIElement* element, - const core::rect& rect, - const core::rect* clip=0); - - //! draws a standard 3d tool bar - /** Used for drawing for toolbars and menus. - \param element: Pointer to the element which whiches to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DToolBar(IGUIElement* element, - const core::rect& rect, - const core::rect* clip=0); - - //! draws a tab button - /** Used for drawing for tab buttons on top of tabs. - \param element: Pointer to the element which whiches to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param active: Specifies if the tab is currently active. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DTabButton(IGUIElement* element, bool active, - const core::rect& rect, - const core::rect* clip=0); - - //! draws a tab control body - /** \param element: Pointer to the element which whiches to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param border: Specifies if the border should be drawn. - \param background: Specifies if the background should be drawn. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DTabBody(IGUIElement* element, bool border, bool background, - const core::rect& rect, - const core::rect* clip=0); - - //! draws an icon, usually from the skin's sprite bank - /** \param parent: Pointer to the element which wishes to draw this icon. - This parameter is usually not used by IGUISkin, but can be used for example - by more complex implementations to find out how to draw the part exactly. - \param icon: Specifies the icon to be drawn. - \param position: The position to draw the icon - \param starttime: The time at the start of the animation - \param currenttime: The present time, used to calculate the frame number - \param loop: Whether the animation should loop or not - \param clip: Clip area. */ - virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon, - const core::position2di position, u32 starttime=0, u32 currenttime=0, - bool loop=false, const core::rect* clip=0); - - //! get the type of this skin - virtual EGUI_SKIN_TYPE getType(); - - //! Writes attributes of the object. - //! Implement this to expose the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the object. - //! Implement this to set the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml deserialization purposes. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - private: - - video::SColor Colors[EGDC_COUNT]; - s32 Sizes[EGDS_COUNT]; - u32 Icons[EGDI_COUNT]; - IGUIFont* Font; - IGUISpriteBank* SpriteBank; - core::stringw Texts[EGDT_COUNT]; - video::IVideoDriver* Driver; - bool UseGradient; - - EGUI_SKIN_TYPE Type; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_SKIN_H_INCLUDED__ +#define __C_GUI_SKIN_H_INCLUDED__ + +#include "IGUISkin.h" +#include "irrString.h" + +namespace irr +{ +namespace video +{ + class IVideoDriver; +} +namespace gui +{ + + class CGUISkin : public IGUISkin + { + public: + + CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver); + + //! destructor + ~CGUISkin(); + + //! returns default color + virtual video::SColor getColor(EGUI_DEFAULT_COLOR color); + + //! sets a default color + virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor); + + //! returns default color + virtual s32 getSize(EGUI_DEFAULT_SIZE size); + + //! sets a default size + virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size); + + //! returns the default font + virtual IGUIFont* getFont(); + + //! sets a default font + virtual void setFont(IGUIFont* font); + + //! sets the sprite bank used for drawing icons + virtual void setSpriteBank(IGUISpriteBank* bank); + + //! gets the sprite bank used for drawing icons + virtual IGUISpriteBank* getSpriteBank(); + + //! Returns a default icon + /** Returns the sprite index within the sprite bank */ + virtual u32 getIcon(EGUI_DEFAULT_ICON icon); + + //! Sets a default icon + /** Sets the sprite index used for drawing icons like arrows, + close buttons and ticks in checkboxes + \param icon: Enum specifying which icon to change + \param index: The sprite index used to draw this icon */ + virtual void setIcon(EGUI_DEFAULT_ICON icon, u32 index); + + //! Returns a default text. + /** For example for Message box button captions: + "OK", "Cancel", "Yes", "No" and so on. */ + virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text); + + //! Sets a default text. + /** For example for Message box button captions: + "OK", "Cancel", "Yes", "No" and so on. */ + virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText); + + //! draws a standard 3d button pane + /** Used for drawing for example buttons in normal state. + It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and + EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. + \param rect: Defining area where to draw. + \param clip: Clip area. + \param element: Pointer to the element which whiches to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. */ + virtual void draw3DButtonPaneStandard(IGUIElement* element, + const core::rect& rect, + const core::rect* clip=0); + + //! draws a pressed 3d button pane + /** Used for drawing for example buttons in pressed state. + It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and + EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. + \param rect: Defining area where to draw. + \param clip: Clip area. + \param element: Pointer to the element which whiches to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. */ + virtual void draw3DButtonPanePressed(IGUIElement* element, + const core::rect& rect, + const core::rect* clip=0); + + //! draws a sunken 3d pane + /** Used for drawing the background of edit, combo or check boxes. + \param element: Pointer to the element which whiches to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param bgcolor: Background color. + \param flat: Specifies if the sunken pane should be flat or displayed as sunken + deep into the ground. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DSunkenPane(IGUIElement* element, + video::SColor bgcolor, bool flat, bool fillBackGround, + const core::rect& rect, + const core::rect* clip=0); + + //! draws a window background + /** Used for drawing the background of dialogs and windows. + \param element: Pointer to the element which whiches to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param titleBarColor: Title color. + \param drawTitleBar: True to enable title drawing. + \param rect: Defining area where to draw. + \param clip: Clip area. + \return Returns rect where to draw title bar text. */ + virtual core::rect draw3DWindowBackground(IGUIElement* element, + bool drawTitleBar, video::SColor titleBarColor, + const core::rect& rect, + const core::rect* clip=0); + + //! draws a standard 3d menu pane + /** Used for drawing for menus and context menus. + It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and + EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. + \param element: Pointer to the element which whishes to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DMenuPane(IGUIElement* element, + const core::rect& rect, + const core::rect* clip=0); + + //! draws a standard 3d tool bar + /** Used for drawing for toolbars and menus. + \param element: Pointer to the element which whiches to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DToolBar(IGUIElement* element, + const core::rect& rect, + const core::rect* clip=0); + + //! draws a tab button + /** Used for drawing for tab buttons on top of tabs. + \param element: Pointer to the element which whiches to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param active: Specifies if the tab is currently active. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DTabButton(IGUIElement* element, bool active, + const core::rect& rect, + const core::rect* clip=0); + + //! draws a tab control body + /** \param element: Pointer to the element which whiches to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param border: Specifies if the border should be drawn. + \param background: Specifies if the background should be drawn. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DTabBody(IGUIElement* element, bool border, bool background, + const core::rect& rect, + const core::rect* clip=0); + + //! draws an icon, usually from the skin's sprite bank + /** \param parent: Pointer to the element which wishes to draw this icon. + This parameter is usually not used by IGUISkin, but can be used for example + by more complex implementations to find out how to draw the part exactly. + \param icon: Specifies the icon to be drawn. + \param position: The position to draw the icon + \param starttime: The time at the start of the animation + \param currenttime: The present time, used to calculate the frame number + \param loop: Whether the animation should loop or not + \param clip: Clip area. */ + virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon, + const core::position2di position, u32 starttime=0, u32 currenttime=0, + bool loop=false, const core::rect* clip=0); + + //! get the type of this skin + virtual EGUI_SKIN_TYPE getType(); + + //! Writes attributes of the object. + //! Implement this to expose the attributes of your scene node animator for + //! scripting languages, editors, debuggers or xml serialization purposes. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the object. + //! Implement this to set the attributes of your scene node animator for + //! scripting languages, editors, debuggers or xml deserialization purposes. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + private: + + video::SColor Colors[EGDC_COUNT]; + s32 Sizes[EGDS_COUNT]; + u32 Icons[EGDI_COUNT]; + IGUIFont* Font; + IGUISpriteBank* SpriteBank; + core::stringw Texts[EGDT_COUNT]; + video::IVideoDriver* Driver; + bool UseGradient; + + EGUI_SKIN_TYPE Type; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUISpriteBank.cpp b/src/dep/src/irrlicht/CGUISpriteBank.cpp index 9b9c199..0d28f73 100644 --- a/src/dep/src/irrlicht/CGUISpriteBank.cpp +++ b/src/dep/src/irrlicht/CGUISpriteBank.cpp @@ -1,125 +1,125 @@ - -#include "CGUISpriteBank.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "ITexture.h" - -namespace irr -{ -namespace gui -{ - -CGUISpriteBank::CGUISpriteBank(IGUIEnvironment* env) : - Environment(env), Driver(0) -{ - if (Environment) - { - Driver = Environment->getVideoDriver(); - if (Driver) - Driver->grab(); - } - -} - -CGUISpriteBank::~CGUISpriteBank() -{ - // drop textures - for (u32 i=0; idrop(); - - // drop video driver - if (Driver) - Driver->drop(); - -} - -core::array< core::rect >& CGUISpriteBank::getPositions() -{ - return Rectangles; -} - -core::array< SGUISprite >& CGUISpriteBank::getSprites() -{ - return Sprites; -} - -u32 CGUISpriteBank::getTextureCount() -{ - return Textures.size(); -} - -video::ITexture* CGUISpriteBank::getTexture(u32 index) -{ - if (index < Textures.size()) - return Textures[index]; - else - return 0; -} - -void CGUISpriteBank::addTexture(video::ITexture* texture) -{ - if (texture) - texture->grab(); - - Textures.push_back(texture); -} - -void CGUISpriteBank::setTexture(u32 index, video::ITexture* texture) -{ - while (index > Textures.size()) - Textures.push_back(0); - - if (Textures[index]) - Textures[index]->drop(); - - if (texture) - texture->grab(); - - Textures[index] = texture; -} - - -//! draws a sprite in 2d with scale and color -void CGUISpriteBank::draw2DSprite(u32 index, const core::position2di& pos, const core::rect* clip, - const video::SColor& color, u32 starttime, u32 currenttime, bool loop, bool center) -{ - if (index >= Sprites.size() || Sprites[index].Frames.empty()) - return; - - // work out frame number - u32 frame = 0; - if (Sprites[index].frameTime) - { - u32 f = ((currenttime - starttime) / Sprites[index].frameTime); - if (loop) - frame = f % Sprites[index].Frames.size(); - else - frame = (f >= Sprites[index].Frames.size()) ? Sprites[index].Frames.size() : f; - } - - video::ITexture* tex = Textures[Sprites[index].Frames[frame].textureNumber]; - if (!tex) - return; - u32 rn = Sprites[index].Frames[frame].rectNumber; - if (rn >= Rectangles.size()) - return; - - core::rect &r = Rectangles[rn]; - - if (center) - { - core::position2di p = pos; - p -= r.getSize() / 2; - Driver->draw2DImage(tex, p, r, clip, color, true); - } - else - { - Driver->draw2DImage(tex, pos, r, clip, color, true); - } - - -} - -} // namespace gui -} // namespace irr + +#include "CGUISpriteBank.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "ITexture.h" + +namespace irr +{ +namespace gui +{ + +CGUISpriteBank::CGUISpriteBank(IGUIEnvironment* env) : + Environment(env), Driver(0) +{ + if (Environment) + { + Driver = Environment->getVideoDriver(); + if (Driver) + Driver->grab(); + } + +} + +CGUISpriteBank::~CGUISpriteBank() +{ + // drop textures + for (u32 i=0; idrop(); + + // drop video driver + if (Driver) + Driver->drop(); + +} + +core::array< core::rect >& CGUISpriteBank::getPositions() +{ + return Rectangles; +} + +core::array< SGUISprite >& CGUISpriteBank::getSprites() +{ + return Sprites; +} + +u32 CGUISpriteBank::getTextureCount() +{ + return Textures.size(); +} + +video::ITexture* CGUISpriteBank::getTexture(u32 index) +{ + if (index < Textures.size()) + return Textures[index]; + else + return 0; +} + +void CGUISpriteBank::addTexture(video::ITexture* texture) +{ + if (texture) + texture->grab(); + + Textures.push_back(texture); +} + +void CGUISpriteBank::setTexture(u32 index, video::ITexture* texture) +{ + while (index > Textures.size()) + Textures.push_back(0); + + if (Textures[index]) + Textures[index]->drop(); + + if (texture) + texture->grab(); + + Textures[index] = texture; +} + + +//! draws a sprite in 2d with scale and color +void CGUISpriteBank::draw2DSprite(u32 index, const core::position2di& pos, const core::rect* clip, + const video::SColor& color, u32 starttime, u32 currenttime, bool loop, bool center) +{ + if (index >= Sprites.size() || Sprites[index].Frames.empty()) + return; + + // work out frame number + u32 frame = 0; + if (Sprites[index].frameTime) + { + u32 f = ((currenttime - starttime) / Sprites[index].frameTime); + if (loop) + frame = f % Sprites[index].Frames.size(); + else + frame = (f >= Sprites[index].Frames.size()) ? Sprites[index].Frames.size() : f; + } + + video::ITexture* tex = Textures[Sprites[index].Frames[frame].textureNumber]; + if (!tex) + return; + u32 rn = Sprites[index].Frames[frame].rectNumber; + if (rn >= Rectangles.size()) + return; + + core::rect &r = Rectangles[rn]; + + if (center) + { + core::position2di p = pos; + p -= r.getSize() / 2; + Driver->draw2DImage(tex, p, r, clip, color, true); + } + else + { + Driver->draw2DImage(tex, pos, r, clip, color, true); + } + + +} + +} // namespace gui +} // namespace irr diff --git a/src/dep/src/irrlicht/CGUISpriteBank.h b/src/dep/src/irrlicht/CGUISpriteBank.h index 362fde6..ac222a4 100644 --- a/src/dep/src/irrlicht/CGUISpriteBank.h +++ b/src/dep/src/irrlicht/CGUISpriteBank.h @@ -1,57 +1,57 @@ - -#ifndef __C_GUI_SPRITE_BANK_H_INCLUDED__ -#define __C_GUI_SPRITE_BANK_H_INCLUDED__ - -#include "IGUISpriteBank.h" - -namespace irr -{ - -namespace video -{ - class IVideoDriver; - class ITexture; -} - -namespace gui -{ - - class IGUIEnvironment; - -//! Sprite bank interface. -class CGUISpriteBank : public IGUISpriteBank -{ -public: - - CGUISpriteBank(IGUIEnvironment* env); - virtual ~CGUISpriteBank(); - - virtual core::array< core::rect >& getPositions(); - virtual core::array< SGUISprite >& getSprites(); - - virtual u32 getTextureCount(); - virtual video::ITexture* getTexture(u32 index); - virtual void addTexture(video::ITexture* texture); - virtual void setTexture(u32 index, video::ITexture* texture); - - //! draws a sprite in 2d with position and color - virtual void draw2DSprite(u32 index, const core::position2di& pos, const core::rect* clip=0, - const video::SColor& color= video::SColor(255,255,255,255), - u32 starttime=0, u32 currenttime=0, bool loop=true, bool center=false); - -protected: - - core::array Sprites; - core::array< core::rect > Rectangles; - core::array Textures; - IGUIEnvironment* Environment; - video::IVideoDriver* Driver; - -}; - -} // end namespace gui -} // end namespace irr - -#endif // __C_GUI_SPRITE_BANK_H_INCLUDED__ - - + +#ifndef __C_GUI_SPRITE_BANK_H_INCLUDED__ +#define __C_GUI_SPRITE_BANK_H_INCLUDED__ + +#include "IGUISpriteBank.h" + +namespace irr +{ + +namespace video +{ + class IVideoDriver; + class ITexture; +} + +namespace gui +{ + + class IGUIEnvironment; + +//! Sprite bank interface. +class CGUISpriteBank : public IGUISpriteBank +{ +public: + + CGUISpriteBank(IGUIEnvironment* env); + virtual ~CGUISpriteBank(); + + virtual core::array< core::rect >& getPositions(); + virtual core::array< SGUISprite >& getSprites(); + + virtual u32 getTextureCount(); + virtual video::ITexture* getTexture(u32 index); + virtual void addTexture(video::ITexture* texture); + virtual void setTexture(u32 index, video::ITexture* texture); + + //! draws a sprite in 2d with position and color + virtual void draw2DSprite(u32 index, const core::position2di& pos, const core::rect* clip=0, + const video::SColor& color= video::SColor(255,255,255,255), + u32 starttime=0, u32 currenttime=0, bool loop=true, bool center=false); + +protected: + + core::array Sprites; + core::array< core::rect > Rectangles; + core::array Textures; + IGUIEnvironment* Environment; + video::IVideoDriver* Driver; + +}; + +} // end namespace gui +} // end namespace irr + +#endif // __C_GUI_SPRITE_BANK_H_INCLUDED__ + + diff --git a/src/dep/src/irrlicht/CGUIStaticText.cpp b/src/dep/src/irrlicht/CGUIStaticText.cpp index cd06806..ad7c30f 100644 --- a/src/dep/src/irrlicht/CGUIStaticText.cpp +++ b/src/dep/src/irrlicht/CGUIStaticText.cpp @@ -1,378 +1,378 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIStaticText.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IGUIFont.h" -#include "IVideoDriver.h" -#include "rect.h" - -namespace irr -{ -namespace gui -{ - - -//! constructor -CGUIStaticText::CGUIStaticText(const wchar_t* text, bool border, - IGUIEnvironment* environment, IGUIElement* parent, - s32 id, const core::rect& rectangle, - bool background) -: IGUIStaticText(environment, parent, id, rectangle), Border(border), - OverrideColorEnabled(false), WordWrap(false), Background(background), - OverrideColor(video::SColor(101,255,255,255)), OverrideFont(0), LastBreakFont(0) -{ - #ifdef _DEBUG - setDebugName("CGUIStaticText"); - #endif - Text = text; -} - - -//! destructor -CGUIStaticText::~CGUIStaticText() -{ - if (OverrideFont) - OverrideFont->drop(); -} - - -//! draws the element and its children -void CGUIStaticText::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - irr::video::IVideoDriver* driver = Environment->getVideoDriver(); - - core::rect frameRect(AbsoluteRect); - - // draw background - - if (Background) - { - driver->draw2DRectangle( skin->getColor(gui::EGDC_3D_FACE), - frameRect, &AbsoluteClippingRect); - } - - // draw the border - - if (Border) - { - skin->draw3DSunkenPane(this, 0, true, false, frameRect, &AbsoluteClippingRect); - frameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X); - } - - // draw the text - if (Text.size()) - { - IGUIFont* font = OverrideFont; - if (!OverrideFont) - font = skin->getFont(); - - if (font) - { - if (!WordWrap) - font->draw(Text.c_str(), frameRect, - OverrideColorEnabled ? OverrideColor : skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), - false, true, &AbsoluteClippingRect); - else - { - if (font != LastBreakFont) - breakText(); - - core::rect r = frameRect; - s32 height = font->getDimension(L"A").Height + font->getKerningHeight(); - - for (u32 i=0; idraw(BrokenText[i].c_str(), r, - OverrideColorEnabled ? OverrideColor : skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), - false, false, &AbsoluteClippingRect); - - r.LowerRightCorner.Y += height; - r.UpperLeftCorner.Y += height; - } - } - } - } - - IGUIElement::draw(); -} - - - -//! Sets another skin independent font. -void CGUIStaticText::setOverrideFont(IGUIFont* font) -{ - if (OverrideFont) - OverrideFont->drop(); - - OverrideFont = font; - - if (OverrideFont) - OverrideFont->grab(); - - breakText(); -} - -IGUIFont * CGUIStaticText::getOverrideFont(void) -{ - return OverrideFont; -} - - -//! Sets another color for the text. -void CGUIStaticText::setOverrideColor(video::SColor color) -{ - OverrideColor = color; - OverrideColorEnabled = true; -} - -video::SColor const & CGUIStaticText::getOverrideColor(void) -{ - return OverrideColor; -} - - -//! Sets if the static text should use the overide color or the -//! color in the gui skin. -void CGUIStaticText::enableOverrideColor(bool enable) -{ - OverrideColorEnabled = enable; -} - -bool CGUIStaticText::isOverrideColorEnabled(void) -{ - return OverrideColorEnabled; -} - - -//! Enables or disables word wrap for using the static text as -//! multiline text control. -void CGUIStaticText::setWordWrap(bool enable) -{ - WordWrap = enable; - breakText(); -} - -bool CGUIStaticText::isWordWrapEnabled(void) -{ - return WordWrap; -} - - -//! Breaks the single text line. -void CGUIStaticText::breakText() -{ - IGUISkin* skin = Environment->getSkin(); - - if (!WordWrap || !skin) - return; - - BrokenText.clear(); - - IGUIFont* font = OverrideFont; - if (!OverrideFont) - font = skin->getFont(); - - if (!font) - return; - - LastBreakFont = font; - - core::stringw line; - core::stringw word; - core::stringw whitespace; - s32 size = Text.size(); - s32 length = 0; - s32 elWidth = RelativeRect.getWidth() - 6; - wchar_t c; - - for (s32 i=0; igetDimension(whitespace.c_str()).Width; - s32 worldlgth = font->getDimension(word.c_str()).Width; - - if (length + worldlgth + whitelgth > elWidth) - { - // break to next line - length = worldlgth; - BrokenText.push_back(line); - line = word; - } - else - { - // add word to line - line += whitespace; - line += word; - length += whitelgth + worldlgth; - } - - word = L""; - whitespace = L""; - } - - whitespace += c; - - // compute line break - if (lineBreak) - { - line += whitespace; - line += word; - BrokenText.push_back(line); - line = L""; - word = L""; - whitespace = L""; - length = 0; - } - } - else - { - // yippee this is a word.. - word += c; - } - } - - line += whitespace; - line += word; - BrokenText.push_back(line); -} - - -//! Sets the new caption of this element. -void CGUIStaticText::setText(const wchar_t* text) -{ - IGUIElement::setText(text); - breakText(); -} - - -//! Returns the height of the text in pixels when it is drawn. -s32 CGUIStaticText::getTextHeight() -{ - IGUISkin* skin = Environment->getSkin(); - - if (!skin) - return 0; - - IGUIFont* font = OverrideFont; - if (!OverrideFont) - font = skin->getFont(); - - if (!font) - return 0; - - s32 height = font->getDimension(L"A").Height + font->getKerningHeight(); - - if (WordWrap) - height *= BrokenText.size(); - - return height; -} - - -s32 CGUIStaticText::getTextWidth(void) -{ - IGUIFont * font = OverrideFont; - - if(!OverrideFont) - { - IGUISkin * skin = Environment->getSkin(); - if(skin) - font = skin->getFont(); - } - - if(!font) - return 0; - - if(WordWrap) - { - s32 widest = 0; - - for(u32 line = 0; line < BrokenText.size(); ++line) - { - s32 width = font->getDimension(BrokenText[line].c_str()).Width; - - if(width > widest) - widest = width; - } - - return widest; - } - else - { - return font->getDimension(Text.c_str()).Width; - } -} - - - -//! Writes attributes of the element. -//! Implement this to expose the attributes of your element for -//! scripting languages, editors, debuggers or xml serialization purposes. -void CGUIStaticText::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) -{ - - out->addBool ("Border", Border); - out->addBool ("OverrideColorEnabled", OverrideColorEnabled); - out->addBool ("WordWrap", WordWrap); - out->addBool ("Background", Background); - out->addColor ("OverrideColor", OverrideColor); - - // out->addFont ("OverrideFont", OverrideFont); - - IGUIStaticText::serializeAttributes(out,options); -} - -//! Reads attributes of the element -void CGUIStaticText::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - - IGUIStaticText::deserializeAttributes(in,options); - - Border = in->getAttributeAsBool ("Border"); - OverrideColor = in->getAttributeAsBool("OverrideColor"); - - enableOverrideColor(in->getAttributeAsBool("OverrideColorEnabled")); - setWordWrap(in->getAttributeAsBool("WordWrap")); - Background = in->getAttributeAsBool("Background"); - - // OverrideFont = in->getAttributeAsFont("OverrideFont"); -} - - -} // end namespace gui -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIStaticText.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IGUIFont.h" +#include "IVideoDriver.h" +#include "rect.h" + +namespace irr +{ +namespace gui +{ + + +//! constructor +CGUIStaticText::CGUIStaticText(const wchar_t* text, bool border, + IGUIEnvironment* environment, IGUIElement* parent, + s32 id, const core::rect& rectangle, + bool background) +: IGUIStaticText(environment, parent, id, rectangle), Border(border), + OverrideColorEnabled(false), WordWrap(false), Background(background), + OverrideColor(video::SColor(101,255,255,255)), OverrideFont(0), LastBreakFont(0) +{ + #ifdef _DEBUG + setDebugName("CGUIStaticText"); + #endif + Text = text; +} + + +//! destructor +CGUIStaticText::~CGUIStaticText() +{ + if (OverrideFont) + OverrideFont->drop(); +} + + +//! draws the element and its children +void CGUIStaticText::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + if (!skin) + return; + irr::video::IVideoDriver* driver = Environment->getVideoDriver(); + + core::rect frameRect(AbsoluteRect); + + // draw background + + if (Background) + { + driver->draw2DRectangle( skin->getColor(gui::EGDC_3D_FACE), + frameRect, &AbsoluteClippingRect); + } + + // draw the border + + if (Border) + { + skin->draw3DSunkenPane(this, 0, true, false, frameRect, &AbsoluteClippingRect); + frameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X); + } + + // draw the text + if (Text.size()) + { + IGUIFont* font = OverrideFont; + if (!OverrideFont) + font = skin->getFont(); + + if (font) + { + if (!WordWrap) + font->draw(Text.c_str(), frameRect, + OverrideColorEnabled ? OverrideColor : skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), + false, true, &AbsoluteClippingRect); + else + { + if (font != LastBreakFont) + breakText(); + + core::rect r = frameRect; + s32 height = font->getDimension(L"A").Height + font->getKerningHeight(); + + for (u32 i=0; idraw(BrokenText[i].c_str(), r, + OverrideColorEnabled ? OverrideColor : skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), + false, false, &AbsoluteClippingRect); + + r.LowerRightCorner.Y += height; + r.UpperLeftCorner.Y += height; + } + } + } + } + + IGUIElement::draw(); +} + + + +//! Sets another skin independent font. +void CGUIStaticText::setOverrideFont(IGUIFont* font) +{ + if (OverrideFont) + OverrideFont->drop(); + + OverrideFont = font; + + if (OverrideFont) + OverrideFont->grab(); + + breakText(); +} + +IGUIFont * CGUIStaticText::getOverrideFont(void) +{ + return OverrideFont; +} + + +//! Sets another color for the text. +void CGUIStaticText::setOverrideColor(video::SColor color) +{ + OverrideColor = color; + OverrideColorEnabled = true; +} + +video::SColor const & CGUIStaticText::getOverrideColor(void) +{ + return OverrideColor; +} + + +//! Sets if the static text should use the overide color or the +//! color in the gui skin. +void CGUIStaticText::enableOverrideColor(bool enable) +{ + OverrideColorEnabled = enable; +} + +bool CGUIStaticText::isOverrideColorEnabled(void) +{ + return OverrideColorEnabled; +} + + +//! Enables or disables word wrap for using the static text as +//! multiline text control. +void CGUIStaticText::setWordWrap(bool enable) +{ + WordWrap = enable; + breakText(); +} + +bool CGUIStaticText::isWordWrapEnabled(void) +{ + return WordWrap; +} + + +//! Breaks the single text line. +void CGUIStaticText::breakText() +{ + IGUISkin* skin = Environment->getSkin(); + + if (!WordWrap || !skin) + return; + + BrokenText.clear(); + + IGUIFont* font = OverrideFont; + if (!OverrideFont) + font = skin->getFont(); + + if (!font) + return; + + LastBreakFont = font; + + core::stringw line; + core::stringw word; + core::stringw whitespace; + s32 size = Text.size(); + s32 length = 0; + s32 elWidth = RelativeRect.getWidth() - 6; + wchar_t c; + + for (s32 i=0; igetDimension(whitespace.c_str()).Width; + s32 worldlgth = font->getDimension(word.c_str()).Width; + + if (length + worldlgth + whitelgth > elWidth) + { + // break to next line + length = worldlgth; + BrokenText.push_back(line); + line = word; + } + else + { + // add word to line + line += whitespace; + line += word; + length += whitelgth + worldlgth; + } + + word = L""; + whitespace = L""; + } + + whitespace += c; + + // compute line break + if (lineBreak) + { + line += whitespace; + line += word; + BrokenText.push_back(line); + line = L""; + word = L""; + whitespace = L""; + length = 0; + } + } + else + { + // yippee this is a word.. + word += c; + } + } + + line += whitespace; + line += word; + BrokenText.push_back(line); +} + + +//! Sets the new caption of this element. +void CGUIStaticText::setText(const wchar_t* text) +{ + IGUIElement::setText(text); + breakText(); +} + + +//! Returns the height of the text in pixels when it is drawn. +s32 CGUIStaticText::getTextHeight() +{ + IGUISkin* skin = Environment->getSkin(); + + if (!skin) + return 0; + + IGUIFont* font = OverrideFont; + if (!OverrideFont) + font = skin->getFont(); + + if (!font) + return 0; + + s32 height = font->getDimension(L"A").Height + font->getKerningHeight(); + + if (WordWrap) + height *= BrokenText.size(); + + return height; +} + + +s32 CGUIStaticText::getTextWidth(void) +{ + IGUIFont * font = OverrideFont; + + if(!OverrideFont) + { + IGUISkin * skin = Environment->getSkin(); + if(skin) + font = skin->getFont(); + } + + if(!font) + return 0; + + if(WordWrap) + { + s32 widest = 0; + + for(u32 line = 0; line < BrokenText.size(); ++line) + { + s32 width = font->getDimension(BrokenText[line].c_str()).Width; + + if(width > widest) + widest = width; + } + + return widest; + } + else + { + return font->getDimension(Text.c_str()).Width; + } +} + + + +//! Writes attributes of the element. +//! Implement this to expose the attributes of your element for +//! scripting languages, editors, debuggers or xml serialization purposes. +void CGUIStaticText::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +{ + + out->addBool ("Border", Border); + out->addBool ("OverrideColorEnabled", OverrideColorEnabled); + out->addBool ("WordWrap", WordWrap); + out->addBool ("Background", Background); + out->addColor ("OverrideColor", OverrideColor); + + // out->addFont ("OverrideFont", OverrideFont); + + IGUIStaticText::serializeAttributes(out,options); +} + +//! Reads attributes of the element +void CGUIStaticText::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +{ + + IGUIStaticText::deserializeAttributes(in,options); + + Border = in->getAttributeAsBool ("Border"); + OverrideColor = in->getAttributeAsBool("OverrideColor"); + + enableOverrideColor(in->getAttributeAsBool("OverrideColorEnabled")); + setWordWrap(in->getAttributeAsBool("WordWrap")); + Background = in->getAttributeAsBool("Background"); + + // OverrideFont = in->getAttributeAsFont("OverrideFont"); +} + + +} // end namespace gui +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CGUIStaticText.h b/src/dep/src/irrlicht/CGUIStaticText.h index 509f19a..d695918 100644 --- a/src/dep/src/irrlicht/CGUIStaticText.h +++ b/src/dep/src/irrlicht/CGUIStaticText.h @@ -1,93 +1,93 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_STATIC_TEXT_H_INCLUDED__ -#define __C_GUI_STATIC_TEXT_H_INCLUDED__ - -#include "IGUIStaticText.h" -#include "irrArray.h" - -namespace irr -{ -namespace gui -{ - class CGUIStaticText : public IGUIStaticText - { - public: - - //! constructor - CGUIStaticText(const wchar_t* text, bool border, IGUIEnvironment* environment, - IGUIElement* parent, s32 id, const core::rect& rectangle, - bool background = false); - - //! destructor - ~CGUIStaticText(); - - //! draws the element and its children - virtual void draw(); - - //! Sets another skin independent font. - virtual void setOverrideFont(IGUIFont* font=0); - - //! Gets the override font (if any) - virtual IGUIFont * getOverrideFont(void); - - //! Sets another color for the text. - virtual void setOverrideColor(video::SColor color); - - //! Gets the override color - virtual video::SColor const & getOverrideColor(void); - - //! Sets if the static text should use the overide color or the - //! color in the gui skin. - virtual void enableOverrideColor(bool enable); - - //! Checks if an override color is enabled - virtual bool isOverrideColorEnabled(void); - - //! Enables or disables word wrap for using the static text as - //! multiline text control. - virtual void setWordWrap(bool enable); - - //! Checks if word wrap is enabled - virtual bool isWordWrapEnabled(void); - - //! Sets the new caption of this element. - virtual void setText(const wchar_t* text); - - //! Returns the height of the text in pixels when it is drawn. - virtual s32 getTextHeight(); - - //! Returns the width of the current text, in the current font - virtual s32 getTextWidth(void); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - //! Breaks the single text line. - void breakText(); - - bool Border; - bool OverrideColorEnabled; - bool WordWrap; - bool Background; - - video::SColor OverrideColor; - gui::IGUIFont* OverrideFont; - gui::IGUIFont* LastBreakFont; // stored because: if skin changes, line break must be recalculated. - - core::array< core::stringw > BrokenText; - }; - -} // end namespace gui -} // end namespace irr - -#endif - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_STATIC_TEXT_H_INCLUDED__ +#define __C_GUI_STATIC_TEXT_H_INCLUDED__ + +#include "IGUIStaticText.h" +#include "irrArray.h" + +namespace irr +{ +namespace gui +{ + class CGUIStaticText : public IGUIStaticText + { + public: + + //! constructor + CGUIStaticText(const wchar_t* text, bool border, IGUIEnvironment* environment, + IGUIElement* parent, s32 id, const core::rect& rectangle, + bool background = false); + + //! destructor + ~CGUIStaticText(); + + //! draws the element and its children + virtual void draw(); + + //! Sets another skin independent font. + virtual void setOverrideFont(IGUIFont* font=0); + + //! Gets the override font (if any) + virtual IGUIFont * getOverrideFont(void); + + //! Sets another color for the text. + virtual void setOverrideColor(video::SColor color); + + //! Gets the override color + virtual video::SColor const & getOverrideColor(void); + + //! Sets if the static text should use the overide color or the + //! color in the gui skin. + virtual void enableOverrideColor(bool enable); + + //! Checks if an override color is enabled + virtual bool isOverrideColorEnabled(void); + + //! Enables or disables word wrap for using the static text as + //! multiline text control. + virtual void setWordWrap(bool enable); + + //! Checks if word wrap is enabled + virtual bool isWordWrapEnabled(void); + + //! Sets the new caption of this element. + virtual void setText(const wchar_t* text); + + //! Returns the height of the text in pixels when it is drawn. + virtual s32 getTextHeight(); + + //! Returns the width of the current text, in the current font + virtual s32 getTextWidth(void); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + private: + + //! Breaks the single text line. + void breakText(); + + bool Border; + bool OverrideColorEnabled; + bool WordWrap; + bool Background; + + video::SColor OverrideColor; + gui::IGUIFont* OverrideFont; + gui::IGUIFont* LastBreakFont; // stored because: if skin changes, line break must be recalculated. + + core::array< core::stringw > BrokenText; + }; + +} // end namespace gui +} // end namespace irr + +#endif + + diff --git a/src/dep/src/irrlicht/CGUITabControl.cpp b/src/dep/src/irrlicht/CGUITabControl.cpp index e26592e..15087e0 100644 --- a/src/dep/src/irrlicht/CGUITabControl.cpp +++ b/src/dep/src/irrlicht/CGUITabControl.cpp @@ -1,483 +1,483 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUITabControl.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IGUIFont.h" -#include "IVideoDriver.h" -#include "rect.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -// ------------------------------------------------------------------ -// Tab -// ------------------------------------------------------------------ - -//! constructor -CGUITab::CGUITab(s32 number, IGUIEnvironment* environment, - IGUIElement* parent, const core::rect& rectangle, - s32 id) - : IGUITab(environment, parent, id, rectangle), Number(number), - DrawBackground(false), BackColor(0,0,0,0) -{ - #ifdef _DEBUG - setDebugName("CGUITab"); - #endif -} - - - -//! destructor -CGUITab::~CGUITab() -{ -} - - - -//! Returns number of tab in tabcontrol. Can be accessed -//! later IGUITabControl::getTab() by this number. -s32 CGUITab::getNumber() -{ - return Number; -} - - -//! Sets the number -void CGUITab::setNumber(s32 n) -{ - Number = n; -} - - -//! draws the element and its children -void CGUITab::draw() -{ - if (!IsVisible) - return; - - video::IVideoDriver* driver = Environment->getVideoDriver(); - - if (DrawBackground) - driver->draw2DRectangle(BackColor, AbsoluteRect, &AbsoluteClippingRect); - - IGUIElement::draw(); -} - -//! sets if the tab should draw its background -void CGUITab::setDrawBackground(bool draw) -{ - DrawBackground = draw; -} - -//! sets the color of the background, if it should be drawn. -void CGUITab::setBackgroundColor(video::SColor c) -{ - BackColor = c; -} - - -//! Writes attributes of the element. -void CGUITab::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) -{ - IGUITab::serializeAttributes(out,options); - - out->addInt ("TabNumber", Number); - out->addBool ("DrawBackground", DrawBackground); - out->addColor ("BackColor", BackColor); - -} - -//! Reads attributes of the element -void CGUITab::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUITab::deserializeAttributes(in,options); - - setNumber(in->getAttributeAsInt("TabNumber")); - setDrawBackground(in->getAttributeAsBool("DrawBackground")); - setBackgroundColor(in->getAttributeAsColor("BackColor")); - - if (Parent && Parent->getType() == EGUIET_TAB_CONTROL) - { - ((CGUITabControl*)Parent)->addTab(this); - if (isVisible()) - ((CGUITabControl*)Parent)->setActiveTab(this); - } - -} - - -// ------------------------------------------------------------------ -// Tabcontrol -// ------------------------------------------------------------------ - -//! destructor -CGUITabControl::CGUITabControl(IGUIEnvironment* environment, - IGUIElement* parent, const core::rect& rectangle, - bool fillbackground, bool border, s32 id) - : IGUITabControl(environment, parent, id, rectangle), ActiveTab(-1), - Border(border), FillBackground(fillbackground) -{ -} - - - -//! destructor -CGUITabControl::~CGUITabControl() -{ - for (s32 i=0; i<(s32)Tabs.size(); ++i) - if (Tabs[i]) - Tabs[i]->drop(); -} - - -//! Adds a tab -IGUITab* CGUITabControl::addTab(const wchar_t* caption, s32 id) -{ - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return 0; - - s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT) + 2; - core::rect r(1,tabheight, - AbsoluteRect.getWidth()-1, - AbsoluteRect.getHeight()-1); - - CGUITab* tab = new CGUITab(Tabs.size(), Environment, this, - r, id); - tab->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - - tab->setText(caption); - tab->setVisible(false); - Tabs.push_back(tab); - - if (ActiveTab == -1) - { - ActiveTab = 0; - tab->setVisible(true); - } - - return tab; -} - -//! adds a tab which has been created elsewhere -void CGUITabControl::addTab(CGUITab* tab) -{ - if (!tab) - return; - - // check if its already added - for (s32 i=0; i < (s32)Tabs.size(); ++i) - if (Tabs[i] == tab) - return; - - tab->grab(); - - if (tab->getNumber() == -1) - tab->setNumber((s32)Tabs.size()); - - while (tab->getNumber() >= (s32)Tabs.size()) - Tabs.push_back(0); - - if (Tabs[tab->getNumber()]) - { - Tabs.push_back(Tabs[tab->getNumber()]); - Tabs[Tabs.size()-1]->setNumber(Tabs.size()); - } - Tabs[tab->getNumber()] = tab; - - if (ActiveTab == -1) - ActiveTab = tab->getNumber(); - - - if (tab->getNumber() == ActiveTab) - { - setActiveTab(ActiveTab); - } -} - -//! Returns amount of tabs in the tabcontrol -s32 CGUITabControl::getTabcount() -{ - return Tabs.size(); -} - - - -//! Returns a tab based on zero based index -IGUITab* CGUITabControl::getTab(s32 idx) -{ - if (idx < 0 || idx >= (s32)Tabs.size()) - return 0; - - return Tabs[idx]; -} - - - -//! called if an event happened. -bool CGUITabControl::OnEvent(SEvent event) -{ - if (!IsEnabled) - return Parent ? Parent->OnEvent(event) : false; - - switch(event.EventType) - { - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case gui::EGET_ELEMENT_FOCUS_LOST: - if (event.GUIEvent.Caller == (IGUIElement*)this) - return true; - } - break; - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_PRESSED_DOWN: - Environment->setFocus(this); - return true; - case EMIE_LMOUSE_LEFT_UP: - Environment->removeFocus(this); - selectTab(core::position2d(event.MouseInput.X, event.MouseInput.Y)); - return true; - } - break; - } - - return Parent ? Parent->OnEvent(event) : false; -} - -void CGUITabControl::selectTab(core::position2d p) -{ - IGUISkin* skin = Environment->getSkin(); - IGUIFont* font = skin->getFont(); - - core::rect frameRect(AbsoluteRect); - - s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT); - frameRect.UpperLeftCorner.Y += 2; - frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + tabheight; - s32 pos = frameRect.UpperLeftCorner.X + 2; - - for (s32 i=0; i<(s32)Tabs.size(); ++i) - { - // get Text - const wchar_t* text = 0; - if (Tabs[i]) - text = Tabs[i]->getText(); - - // get text length - s32 len = 20; - if (font) - len += font->getDimension(text).Width; - - frameRect.UpperLeftCorner.X = pos; - frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; - pos += len; - - if (frameRect.isPointInside(p)) - { - setActiveTab(i); - return; - } - } -} - - -//! draws the element and its children -void CGUITabControl::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - - IGUIFont* font = skin->getFont(); - video::IVideoDriver* driver = Environment->getVideoDriver(); - - core::rect frameRect(AbsoluteRect); - - if (Tabs.empty()) - driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), - frameRect, &AbsoluteClippingRect); - - if (!font) - return; - - s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT); - frameRect.UpperLeftCorner.Y += 2; - frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + tabheight; - core::rect tr; - s32 pos = frameRect.UpperLeftCorner.X + 2; - - // left and right pos of the active tab - s32 left = 0; - s32 right = 0; - const wchar_t* activetext = 0; - - for (s32 i=0; i<(s32)Tabs.size(); ++i) - { - // get Text - const wchar_t* text = 0; - if (Tabs[i]) - text = Tabs[i]->getText(); - - // get text length - s32 len = font->getDimension(text).Width + 20; - frameRect.UpperLeftCorner.X = pos; - frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; - pos += len; - - if (i == ActiveTab) - { - left = frameRect.UpperLeftCorner.X; - right = frameRect.LowerRightCorner.X; - activetext = text; - } - else - { - skin->draw3DTabButton(this, false, frameRect, &AbsoluteClippingRect); - - // draw text - font->draw(text, frameRect, skin->getColor(EGDC_BUTTON_TEXT), - true, true, &AbsoluteClippingRect); - } - } - - // draw active tab - if (left != 0 && right != 0) - { - frameRect.UpperLeftCorner.X = left-2; - frameRect.LowerRightCorner.X = right+2; - frameRect.UpperLeftCorner.Y -= 2; - - skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect); - - // draw text - font->draw(activetext, frameRect, skin->getColor(EGDC_BUTTON_TEXT), - true, true, &AbsoluteClippingRect); - - // draw upper highlight frame - tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; - tr.LowerRightCorner.X = left - 1; - tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1; - tr.LowerRightCorner.Y = frameRect.LowerRightCorner.Y; - driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); - - tr.UpperLeftCorner.X = right; - tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; - driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); - } - - skin->draw3DTabBody(this, Border, FillBackground, AbsoluteRect, &AbsoluteClippingRect); - - IGUIElement::draw(); -} - - -//! Returns which tab is currently active -s32 CGUITabControl::getActiveTab() -{ - return ActiveTab; -} - - -bool CGUITabControl::setActiveTab(IGUIElement *tab) -{ - for (s32 i=0; i<(s32)Tabs.size(); ++i) - if (Tabs[i] == tab) - return setActiveTab(i); - return false; -} - -//! Brings a tab to front. -bool CGUITabControl::setActiveTab(s32 idx) -{ - if (idx < 0 || idx >= (s32)Tabs.size()) - return false; - - bool changed = (ActiveTab != idx); - - ActiveTab = idx; - - for (s32 i=0; i<(s32)Tabs.size(); ++i) - if (Tabs[i]) - Tabs[i]->setVisible( i == ActiveTab ); - - if (changed) - { - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.EventType = EGET_TAB_CHANGED; - Parent->OnEvent(event); - } - - return true; -} - - -//! Removes a child. -void CGUITabControl::removeChild(IGUIElement* child) -{ - bool isTab = false; - s32 i=0; - - // check if it is a tab - for (i=0; i<(s32)Tabs.size(); ) - if (Tabs[i] == child) - { - Tabs[i]->drop(); - Tabs.erase(i); - isTab = true; - } - else - ++i; - - // reassign numbers - if (isTab) - for (i=0; i<(s32)Tabs.size(); ++i) - if (Tabs[i]) - Tabs[i]->setNumber(i); - - // remove real element - IGUIElement::removeChild(child); -} - - -//! Writes attributes of the element. -void CGUITabControl::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) -{ - IGUITabControl::serializeAttributes(out,options); - - out->addInt ("ActiveTab", ActiveTab); - out->addBool("Border", Border); - out->addBool("FillBackground", FillBackground); - -} - -//! Reads attributes of the element -void CGUITabControl::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - Border = in->getAttributeAsBool("Border"); - FillBackground = in->getAttributeAsBool("FillBackground"); - - ActiveTab = -1; - - IGUITabControl::deserializeAttributes(in,options); - - setActiveTab(in->getAttributeAsInt("ActiveTab")); -} - - -} // end namespace irr -} // end namespace gui - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUITabControl.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IGUIFont.h" +#include "IVideoDriver.h" +#include "rect.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + +// ------------------------------------------------------------------ +// Tab +// ------------------------------------------------------------------ + +//! constructor +CGUITab::CGUITab(s32 number, IGUIEnvironment* environment, + IGUIElement* parent, const core::rect& rectangle, + s32 id) + : IGUITab(environment, parent, id, rectangle), Number(number), + DrawBackground(false), BackColor(0,0,0,0) +{ + #ifdef _DEBUG + setDebugName("CGUITab"); + #endif +} + + + +//! destructor +CGUITab::~CGUITab() +{ +} + + + +//! Returns number of tab in tabcontrol. Can be accessed +//! later IGUITabControl::getTab() by this number. +s32 CGUITab::getNumber() +{ + return Number; +} + + +//! Sets the number +void CGUITab::setNumber(s32 n) +{ + Number = n; +} + + +//! draws the element and its children +void CGUITab::draw() +{ + if (!IsVisible) + return; + + video::IVideoDriver* driver = Environment->getVideoDriver(); + + if (DrawBackground) + driver->draw2DRectangle(BackColor, AbsoluteRect, &AbsoluteClippingRect); + + IGUIElement::draw(); +} + +//! sets if the tab should draw its background +void CGUITab::setDrawBackground(bool draw) +{ + DrawBackground = draw; +} + +//! sets the color of the background, if it should be drawn. +void CGUITab::setBackgroundColor(video::SColor c) +{ + BackColor = c; +} + + +//! Writes attributes of the element. +void CGUITab::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +{ + IGUITab::serializeAttributes(out,options); + + out->addInt ("TabNumber", Number); + out->addBool ("DrawBackground", DrawBackground); + out->addColor ("BackColor", BackColor); + +} + +//! Reads attributes of the element +void CGUITab::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +{ + IGUITab::deserializeAttributes(in,options); + + setNumber(in->getAttributeAsInt("TabNumber")); + setDrawBackground(in->getAttributeAsBool("DrawBackground")); + setBackgroundColor(in->getAttributeAsColor("BackColor")); + + if (Parent && Parent->getType() == EGUIET_TAB_CONTROL) + { + ((CGUITabControl*)Parent)->addTab(this); + if (isVisible()) + ((CGUITabControl*)Parent)->setActiveTab(this); + } + +} + + +// ------------------------------------------------------------------ +// Tabcontrol +// ------------------------------------------------------------------ + +//! destructor +CGUITabControl::CGUITabControl(IGUIEnvironment* environment, + IGUIElement* parent, const core::rect& rectangle, + bool fillbackground, bool border, s32 id) + : IGUITabControl(environment, parent, id, rectangle), ActiveTab(-1), + Border(border), FillBackground(fillbackground) +{ +} + + + +//! destructor +CGUITabControl::~CGUITabControl() +{ + for (s32 i=0; i<(s32)Tabs.size(); ++i) + if (Tabs[i]) + Tabs[i]->drop(); +} + + +//! Adds a tab +IGUITab* CGUITabControl::addTab(const wchar_t* caption, s32 id) +{ + IGUISkin* skin = Environment->getSkin(); + if (!skin) + return 0; + + s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT) + 2; + core::rect r(1,tabheight, + AbsoluteRect.getWidth()-1, + AbsoluteRect.getHeight()-1); + + CGUITab* tab = new CGUITab(Tabs.size(), Environment, this, + r, id); + tab->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + + tab->setText(caption); + tab->setVisible(false); + Tabs.push_back(tab); + + if (ActiveTab == -1) + { + ActiveTab = 0; + tab->setVisible(true); + } + + return tab; +} + +//! adds a tab which has been created elsewhere +void CGUITabControl::addTab(CGUITab* tab) +{ + if (!tab) + return; + + // check if its already added + for (s32 i=0; i < (s32)Tabs.size(); ++i) + if (Tabs[i] == tab) + return; + + tab->grab(); + + if (tab->getNumber() == -1) + tab->setNumber((s32)Tabs.size()); + + while (tab->getNumber() >= (s32)Tabs.size()) + Tabs.push_back(0); + + if (Tabs[tab->getNumber()]) + { + Tabs.push_back(Tabs[tab->getNumber()]); + Tabs[Tabs.size()-1]->setNumber(Tabs.size()); + } + Tabs[tab->getNumber()] = tab; + + if (ActiveTab == -1) + ActiveTab = tab->getNumber(); + + + if (tab->getNumber() == ActiveTab) + { + setActiveTab(ActiveTab); + } +} + +//! Returns amount of tabs in the tabcontrol +s32 CGUITabControl::getTabcount() +{ + return Tabs.size(); +} + + + +//! Returns a tab based on zero based index +IGUITab* CGUITabControl::getTab(s32 idx) +{ + if (idx < 0 || idx >= (s32)Tabs.size()) + return 0; + + return Tabs[idx]; +} + + + +//! called if an event happened. +bool CGUITabControl::OnEvent(SEvent event) +{ + if (!IsEnabled) + return Parent ? Parent->OnEvent(event) : false; + + switch(event.EventType) + { + case EET_GUI_EVENT: + switch(event.GUIEvent.EventType) + { + case gui::EGET_ELEMENT_FOCUS_LOST: + if (event.GUIEvent.Caller == (IGUIElement*)this) + return true; + } + break; + case EET_MOUSE_INPUT_EVENT: + switch(event.MouseInput.Event) + { + case EMIE_LMOUSE_PRESSED_DOWN: + Environment->setFocus(this); + return true; + case EMIE_LMOUSE_LEFT_UP: + Environment->removeFocus(this); + selectTab(core::position2d(event.MouseInput.X, event.MouseInput.Y)); + return true; + } + break; + } + + return Parent ? Parent->OnEvent(event) : false; +} + +void CGUITabControl::selectTab(core::position2d p) +{ + IGUISkin* skin = Environment->getSkin(); + IGUIFont* font = skin->getFont(); + + core::rect frameRect(AbsoluteRect); + + s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT); + frameRect.UpperLeftCorner.Y += 2; + frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + tabheight; + s32 pos = frameRect.UpperLeftCorner.X + 2; + + for (s32 i=0; i<(s32)Tabs.size(); ++i) + { + // get Text + const wchar_t* text = 0; + if (Tabs[i]) + text = Tabs[i]->getText(); + + // get text length + s32 len = 20; + if (font) + len += font->getDimension(text).Width; + + frameRect.UpperLeftCorner.X = pos; + frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; + pos += len; + + if (frameRect.isPointInside(p)) + { + setActiveTab(i); + return; + } + } +} + + +//! draws the element and its children +void CGUITabControl::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + if (!skin) + return; + + IGUIFont* font = skin->getFont(); + video::IVideoDriver* driver = Environment->getVideoDriver(); + + core::rect frameRect(AbsoluteRect); + + if (Tabs.empty()) + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), + frameRect, &AbsoluteClippingRect); + + if (!font) + return; + + s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT); + frameRect.UpperLeftCorner.Y += 2; + frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + tabheight; + core::rect tr; + s32 pos = frameRect.UpperLeftCorner.X + 2; + + // left and right pos of the active tab + s32 left = 0; + s32 right = 0; + const wchar_t* activetext = 0; + + for (s32 i=0; i<(s32)Tabs.size(); ++i) + { + // get Text + const wchar_t* text = 0; + if (Tabs[i]) + text = Tabs[i]->getText(); + + // get text length + s32 len = font->getDimension(text).Width + 20; + frameRect.UpperLeftCorner.X = pos; + frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; + pos += len; + + if (i == ActiveTab) + { + left = frameRect.UpperLeftCorner.X; + right = frameRect.LowerRightCorner.X; + activetext = text; + } + else + { + skin->draw3DTabButton(this, false, frameRect, &AbsoluteClippingRect); + + // draw text + font->draw(text, frameRect, skin->getColor(EGDC_BUTTON_TEXT), + true, true, &AbsoluteClippingRect); + } + } + + // draw active tab + if (left != 0 && right != 0) + { + frameRect.UpperLeftCorner.X = left-2; + frameRect.LowerRightCorner.X = right+2; + frameRect.UpperLeftCorner.Y -= 2; + + skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect); + + // draw text + font->draw(activetext, frameRect, skin->getColor(EGDC_BUTTON_TEXT), + true, true, &AbsoluteClippingRect); + + // draw upper highlight frame + tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; + tr.LowerRightCorner.X = left - 1; + tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1; + tr.LowerRightCorner.Y = frameRect.LowerRightCorner.Y; + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); + + tr.UpperLeftCorner.X = right; + tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); + } + + skin->draw3DTabBody(this, Border, FillBackground, AbsoluteRect, &AbsoluteClippingRect); + + IGUIElement::draw(); +} + + +//! Returns which tab is currently active +s32 CGUITabControl::getActiveTab() +{ + return ActiveTab; +} + + +bool CGUITabControl::setActiveTab(IGUIElement *tab) +{ + for (s32 i=0; i<(s32)Tabs.size(); ++i) + if (Tabs[i] == tab) + return setActiveTab(i); + return false; +} + +//! Brings a tab to front. +bool CGUITabControl::setActiveTab(s32 idx) +{ + if (idx < 0 || idx >= (s32)Tabs.size()) + return false; + + bool changed = (ActiveTab != idx); + + ActiveTab = idx; + + for (s32 i=0; i<(s32)Tabs.size(); ++i) + if (Tabs[i]) + Tabs[i]->setVisible( i == ActiveTab ); + + if (changed) + { + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.EventType = EGET_TAB_CHANGED; + Parent->OnEvent(event); + } + + return true; +} + + +//! Removes a child. +void CGUITabControl::removeChild(IGUIElement* child) +{ + bool isTab = false; + s32 i=0; + + // check if it is a tab + for (i=0; i<(s32)Tabs.size(); ) + if (Tabs[i] == child) + { + Tabs[i]->drop(); + Tabs.erase(i); + isTab = true; + } + else + ++i; + + // reassign numbers + if (isTab) + for (i=0; i<(s32)Tabs.size(); ++i) + if (Tabs[i]) + Tabs[i]->setNumber(i); + + // remove real element + IGUIElement::removeChild(child); +} + + +//! Writes attributes of the element. +void CGUITabControl::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +{ + IGUITabControl::serializeAttributes(out,options); + + out->addInt ("ActiveTab", ActiveTab); + out->addBool("Border", Border); + out->addBool("FillBackground", FillBackground); + +} + +//! Reads attributes of the element +void CGUITabControl::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +{ + Border = in->getAttributeAsBool("Border"); + FillBackground = in->getAttributeAsBool("FillBackground"); + + ActiveTab = -1; + + IGUITabControl::deserializeAttributes(in,options); + + setActiveTab(in->getAttributeAsInt("ActiveTab")); +} + + +} // end namespace irr +} // end namespace gui + diff --git a/src/dep/src/irrlicht/CGUITabControl.h b/src/dep/src/irrlicht/CGUITabControl.h index 8301e33..5c62034 100644 --- a/src/dep/src/irrlicht/CGUITabControl.h +++ b/src/dep/src/irrlicht/CGUITabControl.h @@ -1,124 +1,124 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_TAB_CONTROL_H_INCLUDED__ -#define __C_GUI_TAB_CONTROL_H_INCLUDED__ - -#include "IGUITabControl.h" -#include "irrArray.h" - -namespace irr -{ -namespace gui -{ - // A tab, onto which other gui elements could be added. - class CGUITab : public IGUITab - { - public: - - //! constructor - CGUITab(s32 number, IGUIEnvironment* environment, - IGUIElement* parent, const core::rect& rectangle, - s32 id); - - //! destructor - virtual ~CGUITab(); - - //! Returns number of this tab in tabcontrol. Can be accessed - //! later IGUITabControl::getTab() by this number. - virtual s32 getNumber(); - - //! Sets the number - virtual void setNumber(s32 n); - - //! draws the element and its children - virtual void draw(); - - //! sets if the tab should draw its background - virtual void setDrawBackground(bool draw=true); - - //! sets the color of the background, if it should be drawn. - virtual void setBackgroundColor(video::SColor c); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - - private: - - s32 Number; - bool DrawBackground; - video::SColor BackColor; - }; - - - - //! A standard tab control - class CGUITabControl : public IGUITabControl - { - public: - - //! destructor - CGUITabControl(IGUIEnvironment* environment, - IGUIElement* parent, const core::rect& rectangle, - bool fillbackground=true, bool border=true, s32 id=-1); - - //! destructor - virtual ~CGUITabControl(); - - //! Adds a tab - virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1); - - //! Adds a tab that has already been created - virtual void addTab(CGUITab* tab); - - //! Returns amount of tabs in the tabcontrol - virtual s32 getTabcount(); - - //! Returns a tab based on zero based index - virtual IGUITab* getTab(s32 idx); - - //! Brings a tab to front. - virtual bool setActiveTab(s32 idx); - - //! Brings a tab to front. - virtual bool setActiveTab(IGUIElement *tab); - - //! Returns which tab is currently active - virtual s32 getActiveTab(); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! draws the element and its children - virtual void draw(); - - //! Removes a child. - virtual void removeChild(IGUIElement* child); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - void selectTab(core::position2d p); - - core::array Tabs; - s32 ActiveTab; - bool Border; - bool FillBackground; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_TAB_CONTROL_H_INCLUDED__ +#define __C_GUI_TAB_CONTROL_H_INCLUDED__ + +#include "IGUITabControl.h" +#include "irrArray.h" + +namespace irr +{ +namespace gui +{ + // A tab, onto which other gui elements could be added. + class CGUITab : public IGUITab + { + public: + + //! constructor + CGUITab(s32 number, IGUIEnvironment* environment, + IGUIElement* parent, const core::rect& rectangle, + s32 id); + + //! destructor + virtual ~CGUITab(); + + //! Returns number of this tab in tabcontrol. Can be accessed + //! later IGUITabControl::getTab() by this number. + virtual s32 getNumber(); + + //! Sets the number + virtual void setNumber(s32 n); + + //! draws the element and its children + virtual void draw(); + + //! sets if the tab should draw its background + virtual void setDrawBackground(bool draw=true); + + //! sets the color of the background, if it should be drawn. + virtual void setBackgroundColor(video::SColor c); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + + private: + + s32 Number; + bool DrawBackground; + video::SColor BackColor; + }; + + + + //! A standard tab control + class CGUITabControl : public IGUITabControl + { + public: + + //! destructor + CGUITabControl(IGUIEnvironment* environment, + IGUIElement* parent, const core::rect& rectangle, + bool fillbackground=true, bool border=true, s32 id=-1); + + //! destructor + virtual ~CGUITabControl(); + + //! Adds a tab + virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1); + + //! Adds a tab that has already been created + virtual void addTab(CGUITab* tab); + + //! Returns amount of tabs in the tabcontrol + virtual s32 getTabcount(); + + //! Returns a tab based on zero based index + virtual IGUITab* getTab(s32 idx); + + //! Brings a tab to front. + virtual bool setActiveTab(s32 idx); + + //! Brings a tab to front. + virtual bool setActiveTab(IGUIElement *tab); + + //! Returns which tab is currently active + virtual s32 getActiveTab(); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! draws the element and its children + virtual void draw(); + + //! Removes a child. + virtual void removeChild(IGUIElement* child); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + private: + + void selectTab(core::position2d p); + + core::array Tabs; + s32 ActiveTab; + bool Border; + bool FillBackground; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIToolBar.cpp b/src/dep/src/irrlicht/CGUIToolBar.cpp index 0e92e0a..30d88a5 100644 --- a/src/dep/src/irrlicht/CGUIToolBar.cpp +++ b/src/dep/src/irrlicht/CGUIToolBar.cpp @@ -1,148 +1,148 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIToolBar.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIButton.h" -#include "IGUIFont.h" -#include "CGUIButton.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIToolBar::CGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) -:IGUIToolBar(environment, parent, id, rectangle), ButtonX(5) -{ - #ifdef _DEBUG - setDebugName("CGUIToolBar"); - #endif - - // calculate position and find other menubars - s32 y = 0; - s32 parentwidth = 100; - - if (parent) - { - parentwidth = Parent->getAbsolutePosition().getWidth(); - - const core::list& children = parent->getChildren(); - core::list::Iterator it = children.begin(); - for (; it != children.end(); ++it) - { - core::rect r = (*it)->getAbsolutePosition(); - if (r.UpperLeftCorner.X == 0 && r.UpperLeftCorner.Y <= y && - r.LowerRightCorner.X == parentwidth) - y = r.LowerRightCorner.Y; - } - } - - core::rect rr; - rr.UpperLeftCorner.X = 0; - rr.UpperLeftCorner.Y = y; - s32 height = Environment->getSkin()->getSize ( EGDS_MENU_HEIGHT ); - - /*IGUISkin* skin = Environment->getSkin(); - IGUIFont* font = skin->getFont(); - if (font) - { - s32 t = font->getDimension(L"A").Height + 5; - if (t > height) - height = t; - }*/ - - rr.LowerRightCorner.X = parentwidth; - rr.LowerRightCorner.Y = rr.UpperLeftCorner.Y + height; - setRelativePosition(rr); -} - - - -//! destructor -CGUIToolBar::~CGUIToolBar() -{ -} - - - -//! draws the element and its children -void CGUIToolBar::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - - core::rect rect = AbsoluteRect; - core::rect* clip = 0; - - // draw frame - skin->draw3DToolBar(this, rect, clip); - - IGUIElement::draw(); -} - - -//! Updates the absolute position. -void CGUIToolBar::updateAbsolutePosition() -{ - if (Parent) - { - DesiredRect.UpperLeftCorner.X = 0; - DesiredRect.LowerRightCorner.X = Parent->getAbsolutePosition().getWidth(); - } - - IGUIElement::updateAbsolutePosition(); -} - - -//! Adds a button to the tool bar -IGUIButton* CGUIToolBar::addButton(s32 id, const wchar_t* text,const wchar_t* tooltiptext, - video::ITexture* img, video::ITexture* pressed, bool isPushButton, - bool useAlphaChannel) -{ - ButtonX += 3; - - core::rect rectangle(ButtonX,2,0,0); - if ( img ) - { - const core::dimension2di &size = img->getOriginalSize(); - rectangle.LowerRightCorner.X = rectangle.UpperLeftCorner.X + size.Width + 8; - rectangle.LowerRightCorner.Y = rectangle.UpperLeftCorner.Y + size.Height + 6; - } - - ButtonX += rectangle.getWidth(); - - IGUIButton* button = new CGUIButton(Environment, this, id, rectangle); - button->drop(); - - if (text) - button->setText(text); - - if (tooltiptext) - button->setToolTipText(tooltiptext); - - if (img) - button->setImage(img); - - if (pressed) - button->setPressedImage(pressed); - - if (isPushButton) - button->setIsPushButton(isPushButton); - - if (useAlphaChannel) - button->setUseAlphaChannel(useAlphaChannel); - - return button; -} - -} // end namespace gui -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIToolBar.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUIButton.h" +#include "IGUIFont.h" +#include "CGUIButton.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIToolBar::CGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) +:IGUIToolBar(environment, parent, id, rectangle), ButtonX(5) +{ + #ifdef _DEBUG + setDebugName("CGUIToolBar"); + #endif + + // calculate position and find other menubars + s32 y = 0; + s32 parentwidth = 100; + + if (parent) + { + parentwidth = Parent->getAbsolutePosition().getWidth(); + + const core::list& children = parent->getChildren(); + core::list::Iterator it = children.begin(); + for (; it != children.end(); ++it) + { + core::rect r = (*it)->getAbsolutePosition(); + if (r.UpperLeftCorner.X == 0 && r.UpperLeftCorner.Y <= y && + r.LowerRightCorner.X == parentwidth) + y = r.LowerRightCorner.Y; + } + } + + core::rect rr; + rr.UpperLeftCorner.X = 0; + rr.UpperLeftCorner.Y = y; + s32 height = Environment->getSkin()->getSize ( EGDS_MENU_HEIGHT ); + + /*IGUISkin* skin = Environment->getSkin(); + IGUIFont* font = skin->getFont(); + if (font) + { + s32 t = font->getDimension(L"A").Height + 5; + if (t > height) + height = t; + }*/ + + rr.LowerRightCorner.X = parentwidth; + rr.LowerRightCorner.Y = rr.UpperLeftCorner.Y + height; + setRelativePosition(rr); +} + + + +//! destructor +CGUIToolBar::~CGUIToolBar() +{ +} + + + +//! draws the element and its children +void CGUIToolBar::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + if (!skin) + return; + + core::rect rect = AbsoluteRect; + core::rect* clip = 0; + + // draw frame + skin->draw3DToolBar(this, rect, clip); + + IGUIElement::draw(); +} + + +//! Updates the absolute position. +void CGUIToolBar::updateAbsolutePosition() +{ + if (Parent) + { + DesiredRect.UpperLeftCorner.X = 0; + DesiredRect.LowerRightCorner.X = Parent->getAbsolutePosition().getWidth(); + } + + IGUIElement::updateAbsolutePosition(); +} + + +//! Adds a button to the tool bar +IGUIButton* CGUIToolBar::addButton(s32 id, const wchar_t* text,const wchar_t* tooltiptext, + video::ITexture* img, video::ITexture* pressed, bool isPushButton, + bool useAlphaChannel) +{ + ButtonX += 3; + + core::rect rectangle(ButtonX,2,0,0); + if ( img ) + { + const core::dimension2di &size = img->getOriginalSize(); + rectangle.LowerRightCorner.X = rectangle.UpperLeftCorner.X + size.Width + 8; + rectangle.LowerRightCorner.Y = rectangle.UpperLeftCorner.Y + size.Height + 6; + } + + ButtonX += rectangle.getWidth(); + + IGUIButton* button = new CGUIButton(Environment, this, id, rectangle); + button->drop(); + + if (text) + button->setText(text); + + if (tooltiptext) + button->setToolTipText(tooltiptext); + + if (img) + button->setImage(img); + + if (pressed) + button->setPressedImage(pressed); + + if (isPushButton) + button->setIsPushButton(isPushButton); + + if (useAlphaChannel) + button->setUseAlphaChannel(useAlphaChannel); + + return button; +} + +} // end namespace gui +} // end namespace irr diff --git a/src/dep/src/irrlicht/CGUIToolBar.h b/src/dep/src/irrlicht/CGUIToolBar.h index a098866..88d1c24 100644 --- a/src/dep/src/irrlicht/CGUIToolBar.h +++ b/src/dep/src/irrlicht/CGUIToolBar.h @@ -1,47 +1,47 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_TOOL_BAR_H_INCLUDED__ -#define __C_GUI_TOOL_BAR_H_INCLUDED__ - -#include "IGUIToolbar.h" - -namespace irr -{ -namespace gui -{ - - //! Stays at the top of its parent like the menu bar and contains tool buttons - class CGUIToolBar : public IGUIToolBar - { - public: - - //! constructor - CGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle); - - //! destructor - ~CGUIToolBar(); - - //! draws the element and its children - virtual void draw(); - - //! Updates the absolute position. - virtual void updateAbsolutePosition(); - - //! Adds a button to the tool bar - virtual IGUIButton* addButton(s32 id=-1, const wchar_t* text=0,const wchar_t* tooltiptext=0, - video::ITexture* img=0, video::ITexture* pressed=0, - bool isPushButton=false, bool useAlphaChannel=false); - - private: - - s32 ButtonX; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_TOOL_BAR_H_INCLUDED__ +#define __C_GUI_TOOL_BAR_H_INCLUDED__ + +#include "IGUIToolbar.h" + +namespace irr +{ +namespace gui +{ + + //! Stays at the top of its parent like the menu bar and contains tool buttons + class CGUIToolBar : public IGUIToolBar + { + public: + + //! constructor + CGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle); + + //! destructor + ~CGUIToolBar(); + + //! draws the element and its children + virtual void draw(); + + //! Updates the absolute position. + virtual void updateAbsolutePosition(); + + //! Adds a button to the tool bar + virtual IGUIButton* addButton(s32 id=-1, const wchar_t* text=0,const wchar_t* tooltiptext=0, + video::ITexture* img=0, video::ITexture* pressed=0, + bool isPushButton=false, bool useAlphaChannel=false); + + private: + + s32 ButtonX; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGUIWindow.cpp b/src/dep/src/irrlicht/CGUIWindow.cpp index dc25c5d..002bde8 100644 --- a/src/dep/src/irrlicht/CGUIWindow.cpp +++ b/src/dep/src/irrlicht/CGUIWindow.cpp @@ -1,229 +1,229 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIWindow.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIButton.h" -#include "IGUIFont.h" -#include "IGUIFontBitmap.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) -: IGUIWindow(environment, parent, id, rectangle), Dragging(false) -{ - #ifdef _DEBUG - setDebugName("CGUIWindow"); - #endif - - IGUISkin* skin = 0; - if (environment) - skin = environment->getSkin(); - - IGUISpriteBank* sprites = 0; - video::SColor color(255,255,255,255); - - s32 buttonw = 15; - if (skin) - { - buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); - sprites = skin->getSpriteBank(); - color = skin->getColor(EGDC_WINDOW_SYMBOL); - } - s32 posx = RelativeRect.getWidth() - buttonw - 4; - - CloseButton = Environment->addButton(core::rect(posx, 3, posx + buttonw, 3 + buttonw), this, -1, - L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close" ); - CloseButton->setSubElement(true); - CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - if (sprites) - { - CloseButton->setSpriteBank(sprites); - CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color); - CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color); - } - posx -= buttonw + 2; - - RestoreButton = Environment->addButton(core::rect(posx, 3, posx + buttonw, 3 + buttonw), this, -1, - L"", skin ? skin->getDefaultText(EGDT_WINDOW_RESTORE) : L"Restore" ); - RestoreButton->setVisible(false); - RestoreButton->setSubElement(true); - RestoreButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - if (sprites) - { - RestoreButton->setSpriteBank(sprites); - RestoreButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_RESTORE), color); - RestoreButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_RESTORE), color); - } - posx -= buttonw + 2; - - MinButton = Environment->addButton(core::rect(posx, 3, posx + buttonw, 3 + buttonw), this, -1, - L"", skin ? skin->getDefaultText(EGDT_WINDOW_MINIMIZE) : L"Minimize" ); - MinButton->setVisible(false); - MinButton->setSubElement(true); - MinButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - if (sprites) - { - MinButton->setSpriteBank(sprites); - MinButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_MINIMIZE), color); - MinButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_MINIMIZE), color); - } - - MinButton->grab(); - RestoreButton->grab(); - CloseButton->grab(); -} - - - -//! destructor -CGUIWindow::~CGUIWindow() -{ - if (MinButton) - MinButton->drop(); - - if (RestoreButton) - RestoreButton->drop(); - - if (CloseButton) - CloseButton->drop(); -} - - - -//! called if an event happened. -bool CGUIWindow::OnEvent(SEvent event) -{ - switch(event.EventType) - { - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) - { - if (event.GUIEvent.Caller == (IGUIElement*)this) - Dragging = false; - return true; - } - else - if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) - { - if (event.GUIEvent.Caller == CloseButton) - { - remove(); - return true; - } - } - break; - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_PRESSED_DOWN: - DragStart.X = event.MouseInput.X; - DragStart.Y = event.MouseInput.Y; - if (!Environment->hasFocus(this)) - { - Dragging = true; - Environment->setFocus(this); - if (Parent) - Parent->bringToFront(this); - } - return true; - case EMIE_LMOUSE_LEFT_UP: - Dragging = false; - Environment->removeFocus(this); - return true; - case EMIE_MOUSE_MOVED: - if (Dragging) - { - // gui window should not be dragged outside its parent - if (Parent) - if (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 || - event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 || - event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 || - event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1) - - return true; - - - move(core::position2d(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y)); - DragStart.X = event.MouseInput.X; - DragStart.Y = event.MouseInput.Y; - return true; - } - break; - } - } - - return Parent ? Parent->OnEvent(event) : false; -} - -//! Updates the absolute position. -void CGUIWindow::updateAbsolutePosition() -{ - IGUIElement::updateAbsolutePosition(); -} - - - -//! draws the element and its children -void CGUIWindow::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - - core::rect rect = AbsoluteRect; - core::rect *cl = &AbsoluteClippingRect; - - // draw body fast - rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER), - AbsoluteRect, &AbsoluteClippingRect); - - if (Text.size()) - { - rect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X); - rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y); - rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; - - IGUIFont* font = skin->getFont(); - if (font) - font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true, cl); - } - - IGUIElement::draw(); -} - - - -//! Returns pointer to the close button -IGUIButton* CGUIWindow::getCloseButton() -{ - return CloseButton; -} - - - -//! Returns pointer to the minimize button -IGUIButton* CGUIWindow::getMinimizeButton() -{ - return MinButton; -} - - - -//! Returns pointer to the maximize button -IGUIButton* CGUIWindow::getMaximizeButton() -{ - return RestoreButton; -} - - -} // end namespace gui -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIWindow.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUIButton.h" +#include "IGUIFont.h" +#include "IGUIFontBitmap.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) +: IGUIWindow(environment, parent, id, rectangle), Dragging(false) +{ + #ifdef _DEBUG + setDebugName("CGUIWindow"); + #endif + + IGUISkin* skin = 0; + if (environment) + skin = environment->getSkin(); + + IGUISpriteBank* sprites = 0; + video::SColor color(255,255,255,255); + + s32 buttonw = 15; + if (skin) + { + buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); + sprites = skin->getSpriteBank(); + color = skin->getColor(EGDC_WINDOW_SYMBOL); + } + s32 posx = RelativeRect.getWidth() - buttonw - 4; + + CloseButton = Environment->addButton(core::rect(posx, 3, posx + buttonw, 3 + buttonw), this, -1, + L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close" ); + CloseButton->setSubElement(true); + CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + if (sprites) + { + CloseButton->setSpriteBank(sprites); + CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color); + CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color); + } + posx -= buttonw + 2; + + RestoreButton = Environment->addButton(core::rect(posx, 3, posx + buttonw, 3 + buttonw), this, -1, + L"", skin ? skin->getDefaultText(EGDT_WINDOW_RESTORE) : L"Restore" ); + RestoreButton->setVisible(false); + RestoreButton->setSubElement(true); + RestoreButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + if (sprites) + { + RestoreButton->setSpriteBank(sprites); + RestoreButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_RESTORE), color); + RestoreButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_RESTORE), color); + } + posx -= buttonw + 2; + + MinButton = Environment->addButton(core::rect(posx, 3, posx + buttonw, 3 + buttonw), this, -1, + L"", skin ? skin->getDefaultText(EGDT_WINDOW_MINIMIZE) : L"Minimize" ); + MinButton->setVisible(false); + MinButton->setSubElement(true); + MinButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + if (sprites) + { + MinButton->setSpriteBank(sprites); + MinButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_MINIMIZE), color); + MinButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_MINIMIZE), color); + } + + MinButton->grab(); + RestoreButton->grab(); + CloseButton->grab(); +} + + + +//! destructor +CGUIWindow::~CGUIWindow() +{ + if (MinButton) + MinButton->drop(); + + if (RestoreButton) + RestoreButton->drop(); + + if (CloseButton) + CloseButton->drop(); +} + + + +//! called if an event happened. +bool CGUIWindow::OnEvent(SEvent event) +{ + switch(event.EventType) + { + case EET_GUI_EVENT: + if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) + { + if (event.GUIEvent.Caller == (IGUIElement*)this) + Dragging = false; + return true; + } + else + if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) + { + if (event.GUIEvent.Caller == CloseButton) + { + remove(); + return true; + } + } + break; + case EET_MOUSE_INPUT_EVENT: + switch(event.MouseInput.Event) + { + case EMIE_LMOUSE_PRESSED_DOWN: + DragStart.X = event.MouseInput.X; + DragStart.Y = event.MouseInput.Y; + if (!Environment->hasFocus(this)) + { + Dragging = true; + Environment->setFocus(this); + if (Parent) + Parent->bringToFront(this); + } + return true; + case EMIE_LMOUSE_LEFT_UP: + Dragging = false; + Environment->removeFocus(this); + return true; + case EMIE_MOUSE_MOVED: + if (Dragging) + { + // gui window should not be dragged outside its parent + if (Parent) + if (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 || + event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 || + event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 || + event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1) + + return true; + + + move(core::position2d(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y)); + DragStart.X = event.MouseInput.X; + DragStart.Y = event.MouseInput.Y; + return true; + } + break; + } + } + + return Parent ? Parent->OnEvent(event) : false; +} + +//! Updates the absolute position. +void CGUIWindow::updateAbsolutePosition() +{ + IGUIElement::updateAbsolutePosition(); +} + + + +//! draws the element and its children +void CGUIWindow::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + + core::rect rect = AbsoluteRect; + core::rect *cl = &AbsoluteClippingRect; + + // draw body fast + rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER), + AbsoluteRect, &AbsoluteClippingRect); + + if (Text.size()) + { + rect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X); + rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y); + rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; + + IGUIFont* font = skin->getFont(); + if (font) + font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true, cl); + } + + IGUIElement::draw(); +} + + + +//! Returns pointer to the close button +IGUIButton* CGUIWindow::getCloseButton() +{ + return CloseButton; +} + + + +//! Returns pointer to the minimize button +IGUIButton* CGUIWindow::getMinimizeButton() +{ + return MinButton; +} + + + +//! Returns pointer to the maximize button +IGUIButton* CGUIWindow::getMaximizeButton() +{ + return RestoreButton; +} + + +} // end namespace gui +} // end namespace irr diff --git a/src/dep/src/irrlicht/CGUIWindow.h b/src/dep/src/irrlicht/CGUIWindow.h index 8c0c852..2ea5b71 100644 --- a/src/dep/src/irrlicht/CGUIWindow.h +++ b/src/dep/src/irrlicht/CGUIWindow.h @@ -1,58 +1,58 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_WINDOW_H_INCLUDED__ -#define __C_GUI_WINDOW_H_INCLUDED__ - -#include "IGUIWindow.h" - -namespace irr -{ -namespace gui -{ - class IGUIButton; - - class CGUIWindow : public IGUIWindow - { - public: - - //! constructor - CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle); - - //! destructor - ~CGUIWindow(); - - //! called if an event happened. - virtual bool OnEvent(SEvent event); - - //! update absolute position - virtual void updateAbsolutePosition(); - - //! draws the element and its children - virtual void draw(); - - //! Returns pointer to the close button - virtual IGUIButton* getCloseButton(); - - //! Returns pointer to the minimize button - virtual IGUIButton* getMinimizeButton(); - - //! Returns pointer to the maximize button - virtual IGUIButton* getMaximizeButton(); - - protected: - - core::position2d DragStart; - bool Dragging; - - IGUIButton* CloseButton; - IGUIButton* MinButton; - IGUIButton* RestoreButton; - }; - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_WINDOW_H_INCLUDED__ +#define __C_GUI_WINDOW_H_INCLUDED__ + +#include "IGUIWindow.h" + +namespace irr +{ +namespace gui +{ + class IGUIButton; + + class CGUIWindow : public IGUIWindow + { + public: + + //! constructor + CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle); + + //! destructor + ~CGUIWindow(); + + //! called if an event happened. + virtual bool OnEvent(SEvent event); + + //! update absolute position + virtual void updateAbsolutePosition(); + + //! draws the element and its children + virtual void draw(); + + //! Returns pointer to the close button + virtual IGUIButton* getCloseButton(); + + //! Returns pointer to the minimize button + virtual IGUIButton* getMinimizeButton(); + + //! Returns pointer to the maximize button + virtual IGUIButton* getMaximizeButton(); + + protected: + + core::position2d DragStart; + bool Dragging; + + IGUIButton* CloseButton; + IGUIButton* MinButton; + IGUIButton* RestoreButton; + }; + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CGeometryCreator.cpp b/src/dep/src/irrlicht/CGeometryCreator.cpp index eb54504..ebbcfca 100644 --- a/src/dep/src/irrlicht/CGeometryCreator.cpp +++ b/src/dep/src/irrlicht/CGeometryCreator.cpp @@ -1,482 +1,482 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGeometryCreator.h" -#include "SAnimatedMesh.h" -#include "SMeshBuffer.h" -#include "SMesh.h" -#include "IVideoDriver.h" -#include "CImage.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -// creates a hill plane -IAnimatedMesh* CGeometryCreator::createHillPlaneMesh(const core::dimension2d& tileSize, const core::dimension2d& tc, - video::SMaterial* material, f32 hillHeight, const core::dimension2d& ch, - const core::dimension2d& textureRepeatCount) -{ - core::dimension2d tileCount = tc; - core::dimension2d countHills = ch; - - SMeshBuffer* buffer = new SMeshBuffer(); - SMesh* mesh = new SMesh(); - video::S3DVertex vtx; - vtx.Color.set(255,255,255,255); - - if (countHills.Width < 0.01f) countHills.Width = 1; - if (countHills.Height < 0.01f) countHills.Height = 1; - - f32 halfX = (tileSize.Width * tileCount.Width) / 2.0f; - f32 halfY = (tileSize.Height * tileCount.Height) / 2.0f; - - core::dimension2d tx; - tx.Width = 1.0f / (tileCount.Width / textureRepeatCount.Width); - tx.Height = 1.0f / (tileCount.Height / textureRepeatCount.Height); - - ++tileCount.Height; - ++tileCount.Width; - - // create vertices - s32 x; - - for (x=0; xVertices.push_back(vtx); - } - } - - // create indices - - for (x=0; xIndices.push_back(current); - buffer->Indices.push_back(current + 1); - buffer->Indices.push_back(current + tileCount.Width); - - buffer->Indices.push_back(current + 1); - buffer->Indices.push_back(current + 1 + tileCount.Width); - buffer->Indices.push_back(current + tileCount.Width); - } - } - - // recalculate normals - for (s32 i=0; i<(s32)buffer->Indices.size(); i+=3) - { - core::plane3d p( - buffer->Vertices[buffer->Indices[i+0]].Pos, - buffer->Vertices[buffer->Indices[i+1]].Pos, - buffer->Vertices[buffer->Indices[i+2]].Pos); - - p.Normal.normalize(); - - buffer->Vertices[buffer->Indices[i+0]].Normal = p.Normal; - buffer->Vertices[buffer->Indices[i+1]].Normal = p.Normal; - buffer->Vertices[buffer->Indices[i+2]].Normal = p.Normal; - } - - if (material) - buffer->Material = *material; - - buffer->recalculateBoundingBox(); - - SAnimatedMesh* animatedMesh = new SAnimatedMesh(); - mesh->addMeshBuffer(buffer); - mesh->recalculateBoundingBox(); - animatedMesh->addMesh(mesh); - animatedMesh->recalculateBoundingBox(); - - mesh->drop(); - buffer->drop(); - - return animatedMesh; -} - - - -IAnimatedMesh* CGeometryCreator::createTerrainMesh(video::IImage* texture, - video::IImage* heightmap, const core::dimension2d& stretchSize, - f32 maxHeight, video::IVideoDriver* driver, - const core::dimension2d maxVtxBlockSize, - bool debugBorders) -{ - u32 tm = os::Timer::getRealTime()/1000; - - if (!texture || !heightmap) - return 0; - - video::SMaterial material; - c8 textureName[64]; - c8 tmp[255]; - - // debug border - s32 borderSkip = debugBorders ? 0 : 1; - - video::S3DVertex vtx; - vtx.Color.set(255,255,255,255); - - SMesh* mesh = new SMesh(); - - core::dimension2d hMapSize= heightmap->getDimension(); - core::dimension2d tMapSize= texture->getDimension(); - core::position2d thRel((f32)tMapSize.Width / hMapSize.Width, (f32)tMapSize.Height / hMapSize.Height); - core::position2d processed(0,0); - - while (processed.Y blockSize = maxVtxBlockSize; - if (processed.X + blockSize.Width > hMapSize.Width) - blockSize.Width = hMapSize.Width - processed.X; - if (processed.Y + blockSize.Height > hMapSize.Height) - blockSize.Height = hMapSize.Height - processed.Y; - - SMeshBuffer* buffer = new SMeshBuffer(); - - // add vertices of vertex block - s32 y; - - for (y=0; ygetPixel(x+processed.X, y+processed.Y); - f32 height = ((clr.getRed() + clr.getGreen() + clr.getBlue()) / 3.0f)/255.0f * maxHeight; - - vtx.Pos.set((f32)(x+processed.X) * stretchSize.Width, - height, (f32)(y+processed.Y) * stretchSize.Height); - - vtx.TCoords.set((x+0.5f) / blockSize.Width, - (y+0.5f) / blockSize.Height); - buffer->Vertices.push_back(vtx); - } - } - - // add indices of vertex block - for (y=0; yIndices.push_back(c); - buffer->Indices.push_back(c + blockSize.Width); - buffer->Indices.push_back(c + 1); - - buffer->Indices.push_back(c + 1); - buffer->Indices.push_back(c + blockSize.Width); - buffer->Indices.push_back(c + 1 + blockSize.Width); - } - } - - // recalculate normals - for (s32 i=0; i<(s32)buffer->Indices.size(); i+=3) - { - core::plane3d p( - buffer->Vertices[buffer->Indices[i+0]].Pos, - buffer->Vertices[buffer->Indices[i+1]].Pos, - buffer->Vertices[buffer->Indices[i+2]].Pos); - p.Normal.normalize(); - - buffer->Vertices[buffer->Indices[i+0]].Normal = p.Normal; - buffer->Vertices[buffer->Indices[i+1]].Normal = p.Normal; - buffer->Vertices[buffer->Indices[i+2]].Normal = p.Normal; - } - - if (buffer->Vertices.size()) - { - // create texture for this block - video::IImage* img = new video::CImage(texture, - core::position2d((s32)(processed.X*thRel.X), (s32)(processed.Y*thRel.Y)), - core::dimension2d((s32)(blockSize.Width*thRel.X), (s32)(blockSize.Height*thRel.Y))); - - sprintf(textureName, "terrain%u_%d", tm, mesh->getMeshBufferCount()); - - material.Textures[0] = driver->addTexture(textureName, img); - - if (material.Textures[0]) - { - sprintf(tmp, "Generated terrain texture (%dx%d): %s", - material.Textures[0]->getSize().Width, - material.Textures[0]->getSize().Height, - textureName); - os::Printer::log(tmp); - } - else - os::Printer::log("Could not create terrain texture.", textureName, ELL_ERROR); - - buffer->Material = material; - img->drop(); - } - - buffer->recalculateBoundingBox(); - mesh->addMeshBuffer(buffer); - buffer->drop(); - - // keep on processing - processed.X += maxVtxBlockSize.Width - borderSkip; - } - - // keep on processing - processed.X = 0; - processed.Y += maxVtxBlockSize.Height - borderSkip; - } - - SAnimatedMesh* animatedMesh = new SAnimatedMesh(); - mesh->recalculateBoundingBox(); - animatedMesh->addMesh(mesh); - animatedMesh->recalculateBoundingBox(); - - mesh->drop(); - - return animatedMesh; -} - -/* - a cylinder, a cone and a cross - point up on (0,1.f, 0.f ) -*/ -IAnimatedMesh* CGeometryCreator::createArrowMesh ( const u32 tesselationCylinder, - const u32 tesselationCone, - const f32 height, - const f32 cylinderHeight, - const f32 width0, - const f32 width1, - const video::SColor vtxColor0, - const video::SColor vtxColor1 - ) -{ - SMeshBuffer* buffer; - video::S3DVertex v; - u32 i; - - v.Color = vtxColor0; - - SMesh* mesh = new SMesh(); - - // cylinder - buffer = new SMeshBuffer(); - - // floor, bottom - f32 angleStep = (core::PI * 2.f ) / tesselationCylinder; - - - for ( i = 0; i != tesselationCylinder; ++i ) - { - f32 angle = angleStep * f32(i); - v.Color = vtxColor0; - v.Pos.X = width0 * cosf ( angle ); - v.Pos.Y = 0.f; - v.Pos.Z = width0 * sinf ( angle ); - v.Normal = v.Pos; - v.Normal.normalize (); - buffer->Vertices.push_back ( v ); - - v.Pos.X = width0 * 0.5f * cosf ( angle ); - v.Pos.Y = cylinderHeight; - v.Pos.Z = width0 * 0.5f * sinf ( angle ); - v.Normal = v.Pos; - v.Normal.normalize (); - buffer->Vertices.push_back ( v ); - - angle += ( angleStep / 2.f ); - v.Color = vtxColor1; - v.Pos.X = ( width0 * 0.75f ) * cosf ( angle ); - v.Pos.Y = 0.f; - v.Pos.Z = ( width0 * 0.75f ) * sinf ( angle ); - v.Normal = v.Pos; - v.Normal.normalize (); - buffer->Vertices.push_back ( v ); - - v.Pos.X = ( width0 * 0.25f ) * cosf ( angle ); - v.Pos.Y = cylinderHeight; - v.Pos.Z = ( width0 * 0.25f ) * sinf ( angle ); - v.Normal = v.Pos; - v.Normal.normalize (); - buffer->Vertices.push_back ( v ); - - } - - u32 nonWrappedSize = ( ( tesselationCylinder * 2 ) - 1 ) * 2; - for ( i = 0; i != nonWrappedSize; i += 2 ) - { - buffer->Indices.push_back ( i + 2 ); - buffer->Indices.push_back ( i + 0 ); - buffer->Indices.push_back ( i + 1 ); - - buffer->Indices.push_back ( i + 2 ); - buffer->Indices.push_back ( i + 1 ); - buffer->Indices.push_back ( i + 3 ); - } - - buffer->Indices.push_back ( 0 ); - buffer->Indices.push_back ( i + 0 ); - buffer->Indices.push_back ( i + 1 ); - - buffer->Indices.push_back ( 0 ); - buffer->Indices.push_back ( i + 1 ); - buffer->Indices.push_back ( 1 ); - - // close down - v.Pos.X = 0.f; - v.Pos.Y = 0.f; - v.Pos.Z = 0.f; - v.Normal.X = 0.f; - v.Normal.Y = -1.f; - v.Normal.Z = 0.f; - buffer->Vertices.push_back ( v ); - - u32 index = buffer->Vertices.size () - 1; - - for ( i = 0; i != nonWrappedSize; i += 2 ) - { - buffer->Indices.push_back ( index ); - buffer->Indices.push_back ( i + 0 ); - buffer->Indices.push_back ( i + 2 ); - } - - buffer->Indices.push_back ( index ); - buffer->Indices.push_back ( i + 0 ); - buffer->Indices.push_back ( 0 ); - -/* - // close top - v.Pos.X = 0.f; - v.Pos.Y = cylinderHeight; - v.Pos.Z = 0.f; - v.Normal.X = 0.f; - v.Normal.Y = 1.f; - v.Normal.Z = 0.f; - buffer->Vertices.push_back ( v ); - - index = buffer->Vertices.size () - 1; - - for ( i = 0; i != nonWrappedSize; i += 2 ) - { - buffer->Indices.push_back ( i + 1 ); - buffer->Indices.push_back ( index ); - buffer->Indices.push_back ( i + 3 ); - } - - buffer->Indices.push_back ( i + 1 ); - buffer->Indices.push_back ( index ); - buffer->Indices.push_back ( 1 ); -*/ - // add to mesh - mesh->addMeshBuffer ( buffer ); - buffer->drop (); - - // cone - buffer = new SMeshBuffer(); - - angleStep = (core::PI * 2.f ) / tesselationCone; - - v.Color = vtxColor0; - for ( i = 0; i != tesselationCone; ++i ) - { - f32 angle = angleStep * f32(i); - - v.Color = vtxColor0; - v.Pos.X = width1 * cosf ( angle ); - v.Pos.Y = cylinderHeight; - v.Pos.Z = width1 * sinf ( angle ); - v.Normal = v.Pos; - v.Normal.normalize (); - - buffer->Vertices.push_back ( v ); - - angle += angleStep / 2.f; - v.Color = vtxColor1; - v.Pos.X = (width1 * 0.75f ) * cosf ( angle ); - v.Pos.Y = cylinderHeight; - v.Pos.Z = (width1 * 0.75f ) * sinf ( angle ); - v.Normal = v.Pos; - v.Normal.normalize (); - - buffer->Vertices.push_back ( v ); - } - nonWrappedSize = buffer->Vertices.size () - 1; - - // close top - v.Pos.X = 0.f; - v.Pos.Y = height; - v.Pos.Z = 0.f; - v.Normal.X = 0.f; - v.Normal.Y = 1.f; - v.Normal.Z = 0.f; - buffer->Vertices.push_back ( v ); - - index = buffer->Vertices.size () - 1; - - for ( i = 0; i != nonWrappedSize; i += 1 ) - { - buffer->Indices.push_back ( i + 0 ); - buffer->Indices.push_back ( index ); - buffer->Indices.push_back ( i + 1 ); - } - - buffer->Indices.push_back ( i + 0 ); - buffer->Indices.push_back ( index ); - buffer->Indices.push_back ( 0 ); - - // close down - v.Pos.X = 0.f; - v.Pos.Y = cylinderHeight; - v.Pos.Z = 0.f; - v.Normal.X = 0.f; - v.Normal.Y = -1.f; - v.Normal.Z = 0.f; - buffer->Vertices.push_back ( v ); - - index = buffer->Vertices.size () - 1; - - for ( i = 0; i != nonWrappedSize; i += 1 ) - { - buffer->Indices.push_back ( index ); - buffer->Indices.push_back ( i + 0 ); - buffer->Indices.push_back ( i + 1 ); - } - - buffer->Indices.push_back ( index ); - buffer->Indices.push_back ( i + 0 ); - buffer->Indices.push_back ( 0 ); - - // add to mesh - mesh->addMeshBuffer ( buffer ); - buffer->drop (); - - - SAnimatedMesh* animatedMesh = new SAnimatedMesh(); - mesh->recalculateBoundingBox(); - - animatedMesh->addMesh(mesh); - animatedMesh->recalculateBoundingBox(); - - mesh->drop(); - - return animatedMesh; - -} - - -} // end namespace scene -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGeometryCreator.h" +#include "SAnimatedMesh.h" +#include "SMeshBuffer.h" +#include "SMesh.h" +#include "IVideoDriver.h" +#include "CImage.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +// creates a hill plane +IAnimatedMesh* CGeometryCreator::createHillPlaneMesh(const core::dimension2d& tileSize, const core::dimension2d& tc, + video::SMaterial* material, f32 hillHeight, const core::dimension2d& ch, + const core::dimension2d& textureRepeatCount) +{ + core::dimension2d tileCount = tc; + core::dimension2d countHills = ch; + + SMeshBuffer* buffer = new SMeshBuffer(); + SMesh* mesh = new SMesh(); + video::S3DVertex vtx; + vtx.Color.set(255,255,255,255); + + if (countHills.Width < 0.01f) countHills.Width = 1; + if (countHills.Height < 0.01f) countHills.Height = 1; + + f32 halfX = (tileSize.Width * tileCount.Width) / 2.0f; + f32 halfY = (tileSize.Height * tileCount.Height) / 2.0f; + + core::dimension2d tx; + tx.Width = 1.0f / (tileCount.Width / textureRepeatCount.Width); + tx.Height = 1.0f / (tileCount.Height / textureRepeatCount.Height); + + ++tileCount.Height; + ++tileCount.Width; + + // create vertices + s32 x; + + for (x=0; xVertices.push_back(vtx); + } + } + + // create indices + + for (x=0; xIndices.push_back(current); + buffer->Indices.push_back(current + 1); + buffer->Indices.push_back(current + tileCount.Width); + + buffer->Indices.push_back(current + 1); + buffer->Indices.push_back(current + 1 + tileCount.Width); + buffer->Indices.push_back(current + tileCount.Width); + } + } + + // recalculate normals + for (s32 i=0; i<(s32)buffer->Indices.size(); i+=3) + { + core::plane3d p( + buffer->Vertices[buffer->Indices[i+0]].Pos, + buffer->Vertices[buffer->Indices[i+1]].Pos, + buffer->Vertices[buffer->Indices[i+2]].Pos); + + p.Normal.normalize(); + + buffer->Vertices[buffer->Indices[i+0]].Normal = p.Normal; + buffer->Vertices[buffer->Indices[i+1]].Normal = p.Normal; + buffer->Vertices[buffer->Indices[i+2]].Normal = p.Normal; + } + + if (material) + buffer->Material = *material; + + buffer->recalculateBoundingBox(); + + SAnimatedMesh* animatedMesh = new SAnimatedMesh(); + mesh->addMeshBuffer(buffer); + mesh->recalculateBoundingBox(); + animatedMesh->addMesh(mesh); + animatedMesh->recalculateBoundingBox(); + + mesh->drop(); + buffer->drop(); + + return animatedMesh; +} + + + +IAnimatedMesh* CGeometryCreator::createTerrainMesh(video::IImage* texture, + video::IImage* heightmap, const core::dimension2d& stretchSize, + f32 maxHeight, video::IVideoDriver* driver, + const core::dimension2d maxVtxBlockSize, + bool debugBorders) +{ + u32 tm = os::Timer::getRealTime()/1000; + + if (!texture || !heightmap) + return 0; + + video::SMaterial material; + c8 textureName[64]; + c8 tmp[255]; + + // debug border + s32 borderSkip = debugBorders ? 0 : 1; + + video::S3DVertex vtx; + vtx.Color.set(255,255,255,255); + + SMesh* mesh = new SMesh(); + + core::dimension2d hMapSize= heightmap->getDimension(); + core::dimension2d tMapSize= texture->getDimension(); + core::position2d thRel((f32)tMapSize.Width / hMapSize.Width, (f32)tMapSize.Height / hMapSize.Height); + core::position2d processed(0,0); + + while (processed.Y blockSize = maxVtxBlockSize; + if (processed.X + blockSize.Width > hMapSize.Width) + blockSize.Width = hMapSize.Width - processed.X; + if (processed.Y + blockSize.Height > hMapSize.Height) + blockSize.Height = hMapSize.Height - processed.Y; + + SMeshBuffer* buffer = new SMeshBuffer(); + + // add vertices of vertex block + s32 y; + + for (y=0; ygetPixel(x+processed.X, y+processed.Y); + f32 height = ((clr.getRed() + clr.getGreen() + clr.getBlue()) / 3.0f)/255.0f * maxHeight; + + vtx.Pos.set((f32)(x+processed.X) * stretchSize.Width, + height, (f32)(y+processed.Y) * stretchSize.Height); + + vtx.TCoords.set((x+0.5f) / blockSize.Width, + (y+0.5f) / blockSize.Height); + buffer->Vertices.push_back(vtx); + } + } + + // add indices of vertex block + for (y=0; yIndices.push_back(c); + buffer->Indices.push_back(c + blockSize.Width); + buffer->Indices.push_back(c + 1); + + buffer->Indices.push_back(c + 1); + buffer->Indices.push_back(c + blockSize.Width); + buffer->Indices.push_back(c + 1 + blockSize.Width); + } + } + + // recalculate normals + for (s32 i=0; i<(s32)buffer->Indices.size(); i+=3) + { + core::plane3d p( + buffer->Vertices[buffer->Indices[i+0]].Pos, + buffer->Vertices[buffer->Indices[i+1]].Pos, + buffer->Vertices[buffer->Indices[i+2]].Pos); + p.Normal.normalize(); + + buffer->Vertices[buffer->Indices[i+0]].Normal = p.Normal; + buffer->Vertices[buffer->Indices[i+1]].Normal = p.Normal; + buffer->Vertices[buffer->Indices[i+2]].Normal = p.Normal; + } + + if (buffer->Vertices.size()) + { + // create texture for this block + video::IImage* img = new video::CImage(texture, + core::position2d((s32)(processed.X*thRel.X), (s32)(processed.Y*thRel.Y)), + core::dimension2d((s32)(blockSize.Width*thRel.X), (s32)(blockSize.Height*thRel.Y))); + + sprintf(textureName, "terrain%u_%d", tm, mesh->getMeshBufferCount()); + + material.Textures[0] = driver->addTexture(textureName, img); + + if (material.Textures[0]) + { + sprintf(tmp, "Generated terrain texture (%dx%d): %s", + material.Textures[0]->getSize().Width, + material.Textures[0]->getSize().Height, + textureName); + os::Printer::log(tmp); + } + else + os::Printer::log("Could not create terrain texture.", textureName, ELL_ERROR); + + buffer->Material = material; + img->drop(); + } + + buffer->recalculateBoundingBox(); + mesh->addMeshBuffer(buffer); + buffer->drop(); + + // keep on processing + processed.X += maxVtxBlockSize.Width - borderSkip; + } + + // keep on processing + processed.X = 0; + processed.Y += maxVtxBlockSize.Height - borderSkip; + } + + SAnimatedMesh* animatedMesh = new SAnimatedMesh(); + mesh->recalculateBoundingBox(); + animatedMesh->addMesh(mesh); + animatedMesh->recalculateBoundingBox(); + + mesh->drop(); + + return animatedMesh; +} + +/* + a cylinder, a cone and a cross + point up on (0,1.f, 0.f ) +*/ +IAnimatedMesh* CGeometryCreator::createArrowMesh ( const u32 tesselationCylinder, + const u32 tesselationCone, + const f32 height, + const f32 cylinderHeight, + const f32 width0, + const f32 width1, + const video::SColor vtxColor0, + const video::SColor vtxColor1 + ) +{ + SMeshBuffer* buffer; + video::S3DVertex v; + u32 i; + + v.Color = vtxColor0; + + SMesh* mesh = new SMesh(); + + // cylinder + buffer = new SMeshBuffer(); + + // floor, bottom + f32 angleStep = (core::PI * 2.f ) / tesselationCylinder; + + + for ( i = 0; i != tesselationCylinder; ++i ) + { + f32 angle = angleStep * f32(i); + v.Color = vtxColor0; + v.Pos.X = width0 * cosf ( angle ); + v.Pos.Y = 0.f; + v.Pos.Z = width0 * sinf ( angle ); + v.Normal = v.Pos; + v.Normal.normalize (); + buffer->Vertices.push_back ( v ); + + v.Pos.X = width0 * 0.5f * cosf ( angle ); + v.Pos.Y = cylinderHeight; + v.Pos.Z = width0 * 0.5f * sinf ( angle ); + v.Normal = v.Pos; + v.Normal.normalize (); + buffer->Vertices.push_back ( v ); + + angle += ( angleStep / 2.f ); + v.Color = vtxColor1; + v.Pos.X = ( width0 * 0.75f ) * cosf ( angle ); + v.Pos.Y = 0.f; + v.Pos.Z = ( width0 * 0.75f ) * sinf ( angle ); + v.Normal = v.Pos; + v.Normal.normalize (); + buffer->Vertices.push_back ( v ); + + v.Pos.X = ( width0 * 0.25f ) * cosf ( angle ); + v.Pos.Y = cylinderHeight; + v.Pos.Z = ( width0 * 0.25f ) * sinf ( angle ); + v.Normal = v.Pos; + v.Normal.normalize (); + buffer->Vertices.push_back ( v ); + + } + + u32 nonWrappedSize = ( ( tesselationCylinder * 2 ) - 1 ) * 2; + for ( i = 0; i != nonWrappedSize; i += 2 ) + { + buffer->Indices.push_back ( i + 2 ); + buffer->Indices.push_back ( i + 0 ); + buffer->Indices.push_back ( i + 1 ); + + buffer->Indices.push_back ( i + 2 ); + buffer->Indices.push_back ( i + 1 ); + buffer->Indices.push_back ( i + 3 ); + } + + buffer->Indices.push_back ( 0 ); + buffer->Indices.push_back ( i + 0 ); + buffer->Indices.push_back ( i + 1 ); + + buffer->Indices.push_back ( 0 ); + buffer->Indices.push_back ( i + 1 ); + buffer->Indices.push_back ( 1 ); + + // close down + v.Pos.X = 0.f; + v.Pos.Y = 0.f; + v.Pos.Z = 0.f; + v.Normal.X = 0.f; + v.Normal.Y = -1.f; + v.Normal.Z = 0.f; + buffer->Vertices.push_back ( v ); + + u32 index = buffer->Vertices.size () - 1; + + for ( i = 0; i != nonWrappedSize; i += 2 ) + { + buffer->Indices.push_back ( index ); + buffer->Indices.push_back ( i + 0 ); + buffer->Indices.push_back ( i + 2 ); + } + + buffer->Indices.push_back ( index ); + buffer->Indices.push_back ( i + 0 ); + buffer->Indices.push_back ( 0 ); + +/* + // close top + v.Pos.X = 0.f; + v.Pos.Y = cylinderHeight; + v.Pos.Z = 0.f; + v.Normal.X = 0.f; + v.Normal.Y = 1.f; + v.Normal.Z = 0.f; + buffer->Vertices.push_back ( v ); + + index = buffer->Vertices.size () - 1; + + for ( i = 0; i != nonWrappedSize; i += 2 ) + { + buffer->Indices.push_back ( i + 1 ); + buffer->Indices.push_back ( index ); + buffer->Indices.push_back ( i + 3 ); + } + + buffer->Indices.push_back ( i + 1 ); + buffer->Indices.push_back ( index ); + buffer->Indices.push_back ( 1 ); +*/ + // add to mesh + mesh->addMeshBuffer ( buffer ); + buffer->drop (); + + // cone + buffer = new SMeshBuffer(); + + angleStep = (core::PI * 2.f ) / tesselationCone; + + v.Color = vtxColor0; + for ( i = 0; i != tesselationCone; ++i ) + { + f32 angle = angleStep * f32(i); + + v.Color = vtxColor0; + v.Pos.X = width1 * cosf ( angle ); + v.Pos.Y = cylinderHeight; + v.Pos.Z = width1 * sinf ( angle ); + v.Normal = v.Pos; + v.Normal.normalize (); + + buffer->Vertices.push_back ( v ); + + angle += angleStep / 2.f; + v.Color = vtxColor1; + v.Pos.X = (width1 * 0.75f ) * cosf ( angle ); + v.Pos.Y = cylinderHeight; + v.Pos.Z = (width1 * 0.75f ) * sinf ( angle ); + v.Normal = v.Pos; + v.Normal.normalize (); + + buffer->Vertices.push_back ( v ); + } + nonWrappedSize = buffer->Vertices.size () - 1; + + // close top + v.Pos.X = 0.f; + v.Pos.Y = height; + v.Pos.Z = 0.f; + v.Normal.X = 0.f; + v.Normal.Y = 1.f; + v.Normal.Z = 0.f; + buffer->Vertices.push_back ( v ); + + index = buffer->Vertices.size () - 1; + + for ( i = 0; i != nonWrappedSize; i += 1 ) + { + buffer->Indices.push_back ( i + 0 ); + buffer->Indices.push_back ( index ); + buffer->Indices.push_back ( i + 1 ); + } + + buffer->Indices.push_back ( i + 0 ); + buffer->Indices.push_back ( index ); + buffer->Indices.push_back ( 0 ); + + // close down + v.Pos.X = 0.f; + v.Pos.Y = cylinderHeight; + v.Pos.Z = 0.f; + v.Normal.X = 0.f; + v.Normal.Y = -1.f; + v.Normal.Z = 0.f; + buffer->Vertices.push_back ( v ); + + index = buffer->Vertices.size () - 1; + + for ( i = 0; i != nonWrappedSize; i += 1 ) + { + buffer->Indices.push_back ( index ); + buffer->Indices.push_back ( i + 0 ); + buffer->Indices.push_back ( i + 1 ); + } + + buffer->Indices.push_back ( index ); + buffer->Indices.push_back ( i + 0 ); + buffer->Indices.push_back ( 0 ); + + // add to mesh + mesh->addMeshBuffer ( buffer ); + buffer->drop (); + + + SAnimatedMesh* animatedMesh = new SAnimatedMesh(); + mesh->recalculateBoundingBox(); + + animatedMesh->addMesh(mesh); + animatedMesh->recalculateBoundingBox(); + + mesh->drop(); + + return animatedMesh; + +} + + +} // end namespace scene +} // end namespace irr diff --git a/src/dep/src/irrlicht/CGeometryCreator.h b/src/dep/src/irrlicht/CGeometryCreator.h index 7bab3e4..119746d 100644 --- a/src/dep/src/irrlicht/CGeometryCreator.h +++ b/src/dep/src/irrlicht/CGeometryCreator.h @@ -1,57 +1,57 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GEOMETRY_CREATOR_H_INCLUDED__ -#define __C_GEOMETRY_CREATOR_H_INCLUDED__ - -#include "IAnimatedMesh.h" -#include "IImage.h" - - - -namespace irr -{ -namespace video -{ - class IVideoDriver; -} - -namespace scene -{ - -//! class for creating geometry on the fly -class CGeometryCreator -{ -public: - - static IAnimatedMesh* createHillPlaneMesh( - const core::dimension2d& tileSize, const core::dimension2d& tileCount, - video::SMaterial* material, f32 hillHeight, const core::dimension2d& countHills, - const core::dimension2d& textureRepeatCount); - - static IAnimatedMesh* createTerrainMesh(video::IImage* texture, - video::IImage* heightmap, const core::dimension2d& stretchSize, f32 maxHeight, - video::IVideoDriver* driver, - const core::dimension2d defaultVertexBlockSize, - bool debugBorders=false); - - static IAnimatedMesh* createArrowMesh ( const u32 tesselationCylinder, - const u32 tesselationCone, - const f32 height, - const f32 cylinderHeight, - const f32 width0, - const f32 width1, - const video::SColor vtxColor0, - const video::SColor vtxColor1 - ); - - -}; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GEOMETRY_CREATOR_H_INCLUDED__ +#define __C_GEOMETRY_CREATOR_H_INCLUDED__ + +#include "IAnimatedMesh.h" +#include "IImage.h" + + + +namespace irr +{ +namespace video +{ + class IVideoDriver; +} + +namespace scene +{ + +//! class for creating geometry on the fly +class CGeometryCreator +{ +public: + + static IAnimatedMesh* createHillPlaneMesh( + const core::dimension2d& tileSize, const core::dimension2d& tileCount, + video::SMaterial* material, f32 hillHeight, const core::dimension2d& countHills, + const core::dimension2d& textureRepeatCount); + + static IAnimatedMesh* createTerrainMesh(video::IImage* texture, + video::IImage* heightmap, const core::dimension2d& stretchSize, f32 maxHeight, + video::IVideoDriver* driver, + const core::dimension2d defaultVertexBlockSize, + bool debugBorders=false); + + static IAnimatedMesh* createArrowMesh ( const u32 tesselationCylinder, + const u32 tesselationCone, + const f32 height, + const f32 cylinderHeight, + const f32 width0, + const f32 width1, + const video::SColor vtxColor0, + const video::SColor vtxColor1 + ); + + +}; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CImage.cpp b/src/dep/src/irrlicht/CImage.cpp index 9105d3f..ae38197 100644 --- a/src/dep/src/irrlicht/CImage.cpp +++ b/src/dep/src/irrlicht/CImage.cpp @@ -1,1390 +1,1390 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImage.h" -#include "irrString.h" -#include "SoftwareDriver2_helper.h" - -namespace irr -{ - - struct SBlitJob - { - AbsRectangle Dest; - AbsRectangle Source; - - u32 argb; - - void * src; - void * dst; - - s32 width; - s32 height; - - u32 srcPitch; - u32 dstPitch; - - u32 srcPixelMul; - u32 dstPixelMul; - }; - - // Blitter Operation - enum eBlitter - { - BLITTER_INVALID = 0, - BLITTER_COLOR, - BLITTER_COLOR_ALPHA, - BLITTER_TEXTURE, - BLITTER_TEXTURE_ALPHA_BLEND, - BLITTER_TEXTURE_ALPHA_COLOR_BLEND - }; - - typedef void (*tExecuteBlit) ( const SBlitJob * job ); - - - // Bitfields Cohen Sutherland - enum eClipCode - { - CLIPCODE_EMPTY = 0, - CLIPCODE_BOTTOM = 1, - CLIPCODE_TOP = 2, - CLIPCODE_LEFT = 4, - CLIPCODE_RIGHT = 8 - }; - -inline u32 GetClipCode ( const AbsRectangle &r, const core::position2d &p ) -{ - u32 code = CLIPCODE_EMPTY; - - if ( p.X < r.x0 ) - code = CLIPCODE_LEFT; - else - if ( p.X > r.x1 ) - code = CLIPCODE_RIGHT; - - if ( p.Y < r.y0 ) - code |= CLIPCODE_TOP; - else - if ( p.Y > r.y1 ) - code |= CLIPCODE_BOTTOM; - - return code; -} - - -/*! - Cohen Sutherland clipping - @return: 1 if valid -*/ - -static int ClipLine (const AbsRectangle &clipping, - core::position2d &p0, - core::position2d &p1, - const core::position2d& p0_in, - const core::position2d& p1_in) -{ - u32 code0; - u32 code1; - u32 code; - - p0 = p0_in; - p1 = p1_in; - - code0 = GetClipCode ( clipping, p0 ); - code1 = GetClipCode ( clipping, p1 ); - - // trivial accepted - while ( code0 | code1 ) - { - s32 x=0; - s32 y=0; - - // trivial reject - if ( code0 & code1 ) - return 0; - - if ( code0 ) - { - // clip first point - code = code0; - } - else - { - // clip last point - code = code1; - } - - if ( (code & CLIPCODE_BOTTOM) == CLIPCODE_BOTTOM ) - { - // clip bottom viewport - y = clipping.y1; - x = p0.X + ( p1.X - p0.X ) * ( y - p0.Y ) / ( p1.Y - p0.Y ); - } - else - if ( (code & CLIPCODE_TOP) == CLIPCODE_TOP ) - { - // clip to viewport - y = clipping.y0; - x = p0.X + ( p1.X - p0.X ) * ( y - p0.Y ) / ( p1.Y - p0.Y ); - } - else - if ( (code & CLIPCODE_RIGHT) == CLIPCODE_RIGHT ) - { - // clip right viewport - x = clipping.x1; - y = p0.Y + ( p1.Y - p0.Y ) * ( x - p0.X ) / ( p1.X - p0.X ); - } - else - if ( (code & CLIPCODE_LEFT) == CLIPCODE_LEFT ) - { - // clip left viewport - x = clipping.x0; - y = p0.Y + ( p1.Y - p0.Y ) * ( x - p0.X ) / ( p1.X - p0.X ); - } - - if ( code == code0 ) - { - // modify first point - p0.X = x; - p0.Y = y; - code0 = GetClipCode ( clipping, p0 ); - } - else - { - // modify second point - p1.X = x; - p1.Y = y; - code1 = GetClipCode ( clipping, p1 ); - } - } - - return 1; -} - -/* -*/ -inline void GetClip(AbsRectangle &clipping, video::IImage * t) -{ - clipping.x0 = 0; - clipping.y0 = 0; - clipping.x1 = t->getDimension().Width - 1; - clipping.y1 = t->getDimension().Height - 1; -} - -/* -*/ -static void RenderLine32_Decal(video::IImage *t, - const core::position2d &p0, - const core::position2d &p1, - u32 argb ) -{ - s32 dx = p1.X - p0.X; - s32 dy = p1.Y - p0.Y; - - s32 c; - s32 m; - s32 d = 0; - s32 run; - - s32 xInc = 4; - s32 yInc = (s32) t->getPitch(); - - if ( dx < 0 ) - { - xInc = -xInc; - dx = -dx; - } - - if ( dy < 0 ) - { - yInc = -yInc; - dy = -dy; - } - - u32 *dst; - dst = (u32*) ( (u8*) t->lock() + ( p0.Y * t->getPitch() ) + ( p0.X << 2 ) ); - - if ( dy > dx ) - { - s32 tmp; - tmp = dx; - dx = dy; - dy = tmp; - tmp = xInc; - xInc = yInc; - yInc = tmp; - } - - c = dx << 1; - m = dy << 1; - - run = dx; - while ( run ) - { - *dst = argb; - - dst = (u32*) ( (u8*) dst + xInc ); // x += xInc - d += m; - if ( d > dx ) - { - dst = (u32*) ( (u8*) dst + yInc ); // y += yInc - d -= c; - } - run -= 1; - } - - t->unlock(); -} - - -/* -*/ -static void RenderLine32_Blend(video::IImage *t, - const core::position2d &p0, - const core::position2d &p1, - u32 argb, u32 alpha) -{ - s32 dx = p1.X - p0.X; - s32 dy = p1.Y - p0.Y; - - s32 c; - s32 m; - s32 d = 0; - s32 run; - - s32 xInc = 4; - s32 yInc = (s32) t->getPitch(); - - if ( dx < 0 ) - { - xInc = -xInc; - dx = -dx; - } - - if ( dy < 0 ) - { - yInc = -yInc; - dy = -dy; - } - - u32 *dst; - dst = (u32*) ( (u8*) t->lock() + ( p0.Y * t->getPitch() ) + ( p0.X << 2 ) ); - - if ( dy > dx ) - { - s32 tmp; - tmp = dx; - dx = dy; - dy = tmp; - tmp = xInc; - xInc = yInc; - yInc = tmp; - } - - c = dx << 1; - m = dy << 1; - - run = dx; - while ( run ) - { - *dst = PixelBlend32 ( *dst, argb, alpha ); - - dst = (u32*) ( (u8*) dst + xInc ); // x += xInc - d += m; - if ( d > dx ) - { - dst = (u32*) ( (u8*) dst + yInc ); // y += yInc - d -= c; - } - run -= 1; - } - - t->unlock(); -} - -/* -*/ -static void RenderLine16_Decal (video::IImage *t, - const core::position2d &p0, - const core::position2d &p1, - u32 argb ) -{ - s32 dx = p1.X - p0.X; - s32 dy = p1.Y - p0.Y; - - s32 c; - s32 m; - s32 d = 0; - s32 run; - - s32 xInc = 2; - s32 yInc = (s32) t->getPitch(); - - if ( dx < 0 ) - { - xInc = -xInc; - dx = -dx; - } - - if ( dy < 0 ) - { - yInc = -yInc; - dy = -dy; - } - - u16 *dst; - dst = (u16*) ( (u8*) t->lock() + ( p0.Y * t->getPitch() ) + ( p0.X << 1 ) ); - - if ( dy > dx ) - { - s32 tmp; - tmp = dx; - dx = dy; - dy = tmp; - tmp = xInc; - xInc = yInc; - yInc = tmp; - } - - c = dx << 1; - m = dy << 1; - - run = dx; - while ( run ) - { - *dst = argb; - - dst = (u16*) ( (u8*) dst + xInc ); // x += xInc - d += m; - if ( d > dx ) - { - dst = (u16*) ( (u8*) dst + yInc ); // y += yInc - d -= c; - } - run -= 1; - } - - t->unlock(); -} - -/* -*/ -static void RenderLine16_Blend (video::IImage *t, - const core::position2d &p0, - const core::position2d &p1, - u32 argb, - u32 alpha) -{ - s32 dx = p1.X - p0.X; - s32 dy = p1.Y - p0.Y; - - s32 c; - s32 m; - s32 d = 0; - s32 run; - - s32 xInc = 2; - s32 yInc = (s32) t->getPitch(); - - if ( dx < 0 ) - { - xInc = -xInc; - dx = -dx; - } - - if ( dy < 0 ) - { - yInc = -yInc; - dy = -dy; - } - - u16 *dst; - dst = (u16*) ( (u8*) t->lock() + ( p0.Y * t->getPitch() ) + ( p0.X << 1 ) ); - - if ( dy > dx ) - { - s32 tmp; - tmp = dx; - dx = dy; - dy = tmp; - tmp = xInc; - xInc = yInc; - yInc = tmp; - } - - c = dx << 1; - m = dy << 1; - - run = dx; - while ( run ) - { - *dst = PixelBlend16 ( *dst, argb, alpha ); - - dst = (u16*) ( (u8*) dst + xInc ); // x += xInc - d += m; - if ( d > dx ) - { - dst = (u16*) ( (u8*) dst + yInc ); // y += yInc - d -= c; - } - run -= 1; - } - - t->unlock(); -} - - -/*! -*/ -static void executeBlit_TextureCopy_x_to_x ( const SBlitJob * job ) -{ - const void *src = (void*) job->src; - void *dst = (void*) job->dst; - - const u32 widthPitch = job->width * job->dstPixelMul; - for ( s32 dy = 0; dy != job->height; ++dy ) - { - memcpy ( dst, src, widthPitch ); - - src = (void*) ( (u8*) (src) + job->srcPitch ); - dst = (void*) ( (u8*) (dst) + job->dstPitch ); - } -} - - -/*! -*/ -static void executeBlit_TextureCopy_32_to_16 ( const SBlitJob * job ) -{ - const u32 *src = (u32*) job->src; - u16 *dst = (u16*) job->dst; - - u32 s; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - //16 bit Blitter depends on pre-multiplied color - s = PixelLerp32 ( src[dx] | 0xFF000000, extractAlpha ( src[dx] ) ); - dst[dx] = video::A8R8G8B8toA1R5G5B5 ( s ); - } - - src = (u32*) ( (u8*) (src) + job->srcPitch ); - dst = (u16*) ( (u8*) (dst) + job->dstPitch ); - } -} - -/*! -*/ -static void executeBlit_TextureCopy_24_to_16 ( const SBlitJob * job ) -{ - const void *src = (void*) job->src; - u16 *dst = (u16*) job->dst; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - u8 * s = (u8*) src; - - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = video::RGB16(s[0], s[1], s[2]); - s += 3; - } - - src = (void*) ( (u8*) (src) + job->srcPitch ); - dst = (u16*) ( (u8*) (dst) + job->dstPitch ); - } -} - - -/*! -*/ -static void executeBlit_TextureCopy_16_to_32 ( const SBlitJob * job ) -{ - const u16 *src = (u16*) job->src; - u32 *dst = (u32*) job->dst; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = video::A1R5G5B5toA8R8G8B8 ( src[dx] ); - } - - src = (u16*) ( (u8*) (src) + job->srcPitch ); - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } -} - -/*! -*/ -static void executeBlit_TextureCopy_24_to_32 ( const SBlitJob * job ) -{ - void *src = (void*) job->src; - u32 *dst = (u32*) job->dst; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - u8 * s = (u8*) src; - - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = 0xFF000000 | s[0] << 16 | s[1] << 8 | s[2]; - s += 3; - } - - src = (void*) ( (u8*) (src) + job->srcPitch ); - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } -} - - -/*! -*/ -static void executeBlit_TextureBlend_16_to_16 ( const SBlitJob * job ) -{ - u32 dx; - s32 dy; - - u32 *src = (u32*) job->src; - u32 *dst = (u32*) job->dst; - - - const u32 rdx = job->width >> 1; - const u32 off = core::if_c_a_else_b ( job->width & 1 ,job->width - 1, 0 ); - - - if ( 0 == off ) - { - for ( dy = 0; dy != job->height; ++dy ) - { - for ( dx = 0; dx != rdx; ++dx ) - { - dst[dx] = PixelBlend16_simd ( dst[dx], src[dx] ); - } - - src = (u32*) ( (u8*) (src) + job->srcPitch ); - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } - - } - else - { - for ( dy = 0; dy != job->height; ++dy ) - { - for ( dx = 0; dx != rdx; ++dx ) - { - dst[dx] = PixelBlend16_simd ( dst[dx], src[dx] ); - } - - ((u16*) dst)[off] = PixelBlend16 ( ((u16*) dst)[off], ((u16*) src)[off] ); - - src = (u32*) ( (u8*) (src) + job->srcPitch ); - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } - - } -} - -/*! -*/ -static void executeBlit_TextureBlend_32_to_32 ( const SBlitJob * job ) -{ - u32 *src = (u32*) job->src; - u32 *dst = (u32*) job->dst; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = PixelBlend32 ( dst[dx], src[dx] ); - } - src = (u32*) ( (u8*) (src) + job->srcPitch ); - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } -} - -/*! -*/ -static void executeBlit_TextureBlendColor_16_to_16 ( const SBlitJob * job ) -{ - u16 *src = (u16*) job->src; - u16 *dst = (u16*) job->dst; - - u16 blend = video::A8R8G8B8toA1R5G5B5 ( job->argb ); - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = PixelBlend16 ( dst[dx], PixelMul16_2 ( src[dx], blend ) ); - } - src = (u16*) ( (u8*) (src) + job->srcPitch ); - dst = (u16*) ( (u8*) (dst) + job->dstPitch ); - } -} - - -/*! -*/ -static void executeBlit_TextureBlendColor_32_to_32 ( const SBlitJob * job ) -{ - u32 *src = (u32*) job->src; - u32 *dst = (u32*) job->dst; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = PixelBlend32 ( dst[dx], PixelMul32_2 ( src[dx], job->argb ) ); - } - src = (u32*) ( (u8*) (src) + job->srcPitch ); - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } -} - -/*! -*/ -static void executeBlit_Color_16_to_16 ( const SBlitJob * job ) -{ - u16 *dst = (u16*) job->dst; - - u16 c0 = video::A8R8G8B8toA1R5G5B5 ( job->argb ); - u32 c = c0 | c0 << 16; - - if ( 0 == (job->srcPitch & 3 ) ) - { - for ( s32 dy = 0; dy != job->height; ++dy ) - { - memset32 ( dst, c, job->srcPitch ); - dst = (u16*) ( (u8*) (dst) + job->dstPitch ); - } - } - else - { - s32 dx = job->width - 1; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - memset32 ( dst, c, job->srcPitch ); - dst[dx] = c0; - dst = (u16*) ( (u8*) (dst) + job->dstPitch ); - } - - } -} - -/*! -*/ -static void executeBlit_Color_32_to_32 ( const SBlitJob * job ) -{ - u32 *dst = (u32*) job->dst; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - memset32 ( dst, job->argb, job->srcPitch ); - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } -} - -/*! -*/ -static void executeBlit_ColorAlpha_16_to_16 ( const SBlitJob * job ) -{ - u16 *dst = (u16*) job->dst; - - const u32 alpha = extractAlpha ( job->argb ) >> 3; - const u32 src = video::A8R8G8B8toA1R5G5B5 ( job->argb ); - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = PixelBlend16 ( dst[dx], src, alpha ); - } - dst = (u16*) ( (u8*) (dst) + job->dstPitch ); - } -} - -/*! -*/ -static void executeBlit_ColorAlpha_32_to_32 ( const SBlitJob * job ) -{ - u32 *dst = (u32*) job->dst; - - const u32 alpha = extractAlpha ( job->argb ); - const u32 src = job->argb; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = PixelBlend32 ( dst[dx], src, alpha ); - } - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } -} - -/*! -*/ -static tExecuteBlit getBlitter ( eBlitter operation,const video::IImage * dest,const video::IImage * source ) -{ - video::ECOLOR_FORMAT sourceFormat = (video::ECOLOR_FORMAT) -1; - video::ECOLOR_FORMAT destFormat = (video::ECOLOR_FORMAT) -1; - - if ( source ) - sourceFormat = source->getColorFormat (); - - if ( dest ) - destFormat = dest->getColorFormat (); - - switch ( operation ) - { - case BLITTER_TEXTURE: - { - if ( sourceFormat == destFormat ) - return executeBlit_TextureCopy_x_to_x; - - if ( destFormat == video::ECF_A1R5G5B5 && sourceFormat == video::ECF_A8R8G8B8 ) - return executeBlit_TextureCopy_32_to_16; - - if ( destFormat == video::ECF_A1R5G5B5 && sourceFormat == video::ECF_R8G8B8 ) - return executeBlit_TextureCopy_24_to_16; - - if ( destFormat == video::ECF_A8R8G8B8 && sourceFormat == video::ECF_A1R5G5B5 ) - return executeBlit_TextureCopy_16_to_32; - - if ( destFormat == video::ECF_A8R8G8B8 && sourceFormat == video::ECF_R8G8B8 ) - return executeBlit_TextureCopy_24_to_32; - - } break; - - case BLITTER_TEXTURE_ALPHA_BLEND: - { - if ( destFormat == video::ECF_A1R5G5B5 && sourceFormat == video::ECF_A1R5G5B5 ) - return executeBlit_TextureBlend_16_to_16; - - if ( destFormat == video::ECF_A8R8G8B8 && sourceFormat == video::ECF_A8R8G8B8 ) - return executeBlit_TextureBlend_32_to_32; - - } break; - - case BLITTER_TEXTURE_ALPHA_COLOR_BLEND: - { - if ( destFormat == video::ECF_A1R5G5B5 && sourceFormat == video::ECF_A1R5G5B5 ) - return executeBlit_TextureBlendColor_16_to_16; - - if ( destFormat == video::ECF_A8R8G8B8 && sourceFormat == video::ECF_A8R8G8B8 ) - return executeBlit_TextureBlendColor_32_to_32; - } break; - - case BLITTER_COLOR: - { - if ( destFormat == video::ECF_A1R5G5B5 ) - return executeBlit_Color_16_to_16; - - if ( destFormat == video::ECF_A8R8G8B8 ) - return executeBlit_Color_32_to_32; - } break; - - case BLITTER_COLOR_ALPHA: - { - if ( destFormat == video::ECF_A1R5G5B5 ) - return executeBlit_ColorAlpha_16_to_16; - - if ( destFormat == video::ECF_A8R8G8B8 ) - return executeBlit_ColorAlpha_32_to_32; - - } break; - - case BLITTER_INVALID: - break; - } -/* - char buf[64]; - sprintf ( buf, "Blit: %d %d->%d unsupported",operation,sourceFormat,destFormat ); - os::Printer::log (buf ); -*/ - return 0; - -} - - - -/*! - a generic 2D Blitter -*/ -static s32 Blit ( eBlitter operation, - video::IImage * dest, - const core::rect *destClipping, - const core::position2d *destPos, - video::IImage * source, - const core::rect *sourceClipping, - u32 argb - ) -{ - tExecuteBlit blitter = getBlitter ( operation, dest, source ); - if ( 0 == blitter ) - { - return 0; - } - - // Clipping - AbsRectangle sourceClip; - AbsRectangle destClip; - AbsRectangle v; - - SBlitJob job; - - if ( sourceClipping ) - { - sourceClip.x0 = sourceClipping->UpperLeftCorner.X; - sourceClip.y0 = sourceClipping->UpperLeftCorner.Y; - sourceClip.x1 = sourceClipping->LowerRightCorner.X; - sourceClip.y1 = sourceClipping->LowerRightCorner.Y; - } - else - { - sourceClip.x0 = 0; - sourceClip.y0 = 0; - sourceClip.x1 = source ? source->getDimension().Width : 0; - sourceClip.y1 = source ? source->getDimension().Height : 0; - } - - if ( destClipping ) - { - destClip.x0 = destClipping->UpperLeftCorner.X; - destClip.y0 = destClipping->UpperLeftCorner.Y; - destClip.x1 = destClipping->LowerRightCorner.X; - destClip.y1 = destClipping->LowerRightCorner.Y; - } - else - { - destClip.x0 = 0; - destClip.y0 = 0; - destClip.x1 = dest ? dest->getDimension().Width : 0; - destClip.y1 = dest ? dest->getDimension().Height : 0; - } - - v.x0 = destPos ? destPos->X : 0; - v.y0 = destPos ? destPos->Y : 0; - v.x1 = v.x0 + ( sourceClip.x1 - sourceClip.x0 ); - v.y1 = v.y0 + ( sourceClip.y1 - sourceClip.y0 ); - - intersect ( job.Dest, destClip, v ); - if ( !isValid ( job.Dest ) ) - return 0; - - job.width = job.Dest.x1 - job.Dest.x0; - job.height = job.Dest.y1 - job.Dest.y0; - - - job.Source.x0 = sourceClip.x0 + ( job.Dest.x0 - v.x0 ); - job.Source.x1 = job.Source.x0 + job.width; - - job.Source.y0 = sourceClip.y0 + ( job.Dest.y0 - v.y0 ); - job.Source.y1 = job.Source.y0 + job.height; - - job.argb = argb; - - if ( source ) - { - job.srcPitch = source->getPitch(); - job.srcPixelMul = source->getBytesPerPixel(); - job.src = (void*) ( (u8*) source->lock() + ( job.Source.y0 * job.srcPitch ) + ( job.Source.x0 * job.srcPixelMul ) ); - } - else - { - // use srcPitch for color operation on dest - job.srcPitch = job.width * dest->getBytesPerPixel(); - } - - job.dstPitch = dest->getPitch(); - job.dstPixelMul = dest->getBytesPerPixel(); - job.dst = (void*) ( (u8*) dest->lock() + ( job.Dest.y0 * job.dstPitch ) + ( job.Dest.x0 * job.dstPixelMul ) ); - - blitter ( &job ); - - if ( source ) - source->unlock (); - - if ( dest ) - dest->unlock(); - - return 1; -} - -} - -namespace irr -{ -namespace video -{ - -//! constructor -CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d& size) -:Data(0), Size(size), Format(format), DeleteMemory(true) -{ - initData(); -} - - -//! constructor -CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d& size, void* data, - bool ownForeignMemory, bool deleteForeignMemory) -: Data(0), Size(size), Format(format), DeleteMemory(deleteForeignMemory) -{ - if (ownForeignMemory) - { - Data = (void*)0xbadf00d; - initData(); - Data = data; - } - else - { - Data = 0; - initData(); - memcpy(Data, data, Size.Height * Size.Width * BytesPerPixel); - } -} - - - -//! constructor -CImage::CImage(ECOLOR_FORMAT format, IImage* imageToCopy) -: Data(0), Format(format), DeleteMemory(true) -{ - if (!imageToCopy) - return; - - Size = imageToCopy->getDimension(); - initData(); - - // now copy data from other image - - Blit ( BLITTER_TEXTURE, this, 0, 0, imageToCopy, 0,0 ); -} - - - -//! constructor -CImage::CImage(IImage* imageToCopy, const core::position2d& pos, - const core::dimension2d& size) - : Data(0), Size(0,0), DeleteMemory(true) -{ - if (!imageToCopy) - return; - - Format = imageToCopy->getColorFormat(); - Size = size; - - initData(); - - core::rect sClip( pos.X, pos.Y, pos.X + size.Width,pos.Y + size.Height ); - Blit ( BLITTER_TEXTURE, this, 0, 0, imageToCopy, &sClip,0 ); -} - - - -//! assumes format and size has been set and creates the rest -void CImage::initData() -{ - BitsPerPixel = getBitsPerPixelFromFormat(); - BytesPerPixel = BitsPerPixel / 8; - - // Pitch should be aligned... - Pitch = BytesPerPixel * Size.Width; - - if (!Data) - Data = new s8[Size.Height * Pitch]; -} - - -//! destructor -CImage::~CImage() -{ - if ( DeleteMemory ) - delete [] (s8*)Data; -} - - -//! Returns width and height of image data. -const core::dimension2d& CImage::getDimension() -{ - return Size; -} - - - -//! Returns bits per pixel. -s32 CImage::getBitsPerPixel() -{ - return BitsPerPixel; -} - - -//! Returns bytes per pixel -s32 CImage::getBytesPerPixel() -{ - return BytesPerPixel; -} - - - -//! Returns image data size in bytes -s32 CImage::getImageDataSizeInBytes() -{ - return Pitch * Size.Height; -} - - - -//! Returns image data size in pixels -s32 CImage::getImageDataSizeInPixels() -{ - return Size.Width * Size.Height; -} - - - -//! returns mask for red value of a pixel -u32 CImage::getRedMask() -{ - return RedMask; -} - - - -//! returns mask for green value of a pixel -u32 CImage::getGreenMask() -{ - return GreenMask; -} - - - -//! returns mask for blue value of a pixel -u32 CImage::getBlueMask() -{ - return BlueMask; -} - - - -//! returns mask for alpha value of a pixel -u32 CImage::getAlphaMask() -{ - return AlphaMask; -} - - -s32 CImage::getBitsPerPixelFromFormat() -{ - switch(Format) - { - case ECF_A1R5G5B5: - AlphaMask = 0x1<<15; - RedMask = 0x1F<<10; - GreenMask = 0x1F<<5; - BlueMask = 0x1F; - return 16; - case ECF_R5G6B5: - AlphaMask = 0x0; - RedMask = 0x1F<<11; - GreenMask = 0x3F<<5; - BlueMask = 0x1F; - return 16; - case ECF_R8G8B8: - AlphaMask = 0x0; - RedMask = 0xFF<<16; - GreenMask = 0xFF<<8; - BlueMask = 0xFF; - return 24; - case ECF_A8R8G8B8: - AlphaMask = 0xFF<<24; - RedMask = 0xFF<<16; - GreenMask = 0xFF<<8; - BlueMask = 0xFF; - return 32; - } - -// os::Printer::log("CImage: Unknown color format.", ELL_ERROR); - return 0; -} - -//! sets a pixel -void CImage::setPixel(s32 x, s32 y, const SColor &color ) -{ - if (x < 0 || y < 0 || x >= Size.Width || y >= Size.Height) - return; - - switch(Format) - { - case ECF_A1R5G5B5: - { - u16 * dest = (u16*) ((u8*) Data + ( y * Pitch ) + ( x << 1 )); - *dest = video::A8R8G8B8toA1R5G5B5 ( color.color ); - } break; - - case ECF_A8R8G8B8: - { - u32 * dest = (u32*) ((u8*) Data + ( y * Pitch ) + ( x << 2 )); - *dest = color.color; - } break; - - } -} - - -//! returns a pixel -SColor CImage::getPixel(s32 x, s32 y) -{ - if (x < 0 || y < 0 || x >= Size.Width || y >= Size.Height) - return SColor(0); - - switch(Format) - { - case ECF_A1R5G5B5: - return A1R5G5B5toA8R8G8B8(((u16*)Data)[y*Size.Width + x]); - case ECF_R5G6B5: - return R5G6B5toA8R8G8B8(((u16*)Data)[y*Size.Width + x]); - case ECF_A8R8G8B8: - return ((u32*)Data)[y*Size.Width + x]; - case ECF_R8G8B8: - { - u8* p = &((u8*)Data)[(y*3)*Size.Width + (x*3)]; - return SColor(255,p[0],p[1],p[2]); - } - } - - return SColor(0); -} - - -//! returns the color format -ECOLOR_FORMAT CImage::getColorFormat() const -{ - return Format; -} - -//! draws a rectangle -void CImage::drawRectangle(const core::rect& rect, const SColor &color) -{ - Blit ( color.getAlpha() == 0xFF ? BLITTER_COLOR : BLITTER_COLOR_ALPHA, - this, 0, &rect.UpperLeftCorner, 0, &rect, color.color ); -} - - -//! copies this surface into another -void CImage::copyTo(CImage* target, const core::position2d& pos) -{ - Blit ( BLITTER_TEXTURE, target, 0, &pos, this, 0, 0 ); -} - - -//! copies this surface into another -void CImage::copyTo(CImage* target, const core::position2d& pos, const core::rect& sourceRect, const core::rect* clipRect) -{ - Blit ( BLITTER_TEXTURE, target, clipRect, &pos, this, &sourceRect, 0 ); -} - - - -//! copies this surface into another, using the alpha mask, an cliprect and a color to add with -void CImage::copyToWithAlpha(CImage* target, const core::position2d& pos, const core::rect& sourceRect, const SColor &color, const core::rect* clipRect) -{ - // color blend only necessary on not full spectrum aka. color.color != 0xFFFFFFFF - Blit ( color.color == 0xFFFFFFFF ? BLITTER_TEXTURE_ALPHA_BLEND: BLITTER_TEXTURE_ALPHA_COLOR_BLEND, - target, clipRect, &pos, this, &sourceRect, color.color ); -} - - - -//! draws a line from to with color -void CImage::drawLine(const core::position2d& from, const core::position2d& to, const SColor &color) -{ - AbsRectangle clip; - GetClip ( clip, this ); - - core::position2d p[2]; - - if ( ClipLine ( clip, p[0], p[1], from, to ) ) - { - u32 alpha = extractAlpha ( color.color ); - - switch ( Format ) - { - case ECF_A1R5G5B5: - if ( alpha == 256 ) - { - RenderLine16_Decal ( this, p[0], p[1], video::A8R8G8B8toA1R5G5B5 ( color.color ) ); - } - else - { - RenderLine16_Blend ( this, p[0], p[1], video::A8R8G8B8toA1R5G5B5 ( color.color ), alpha >> 3 ); - } - break; - case ECF_A8R8G8B8: - if ( alpha == 256 ) - { - RenderLine32_Decal ( this, p[0], p[1], color.color ); - } - else - { - RenderLine32_Blend ( this, p[0], p[1], color.color, alpha ); - } - break; - } - } -} - - - -//! copies this surface into another, scaling it to the target image size -// note: this is very very slow. (i didn't want to write a fast version. -// but hopefully, nobody wants to scale surfaces every frame. -void CImage::copyToScaling(CImage* target) -{ - if (Format != target->getColorFormat() ) - { -// os::Printer::log("Format not equal", ELL_ERROR); - return; - } - - core::dimension2d targetSize = target->getDimension(); - - if (!targetSize.Width || !targetSize.Height) - return; - - f32 sourceXStep = (f32)Size.Width / (f32)targetSize.Width; - f32 sourceYStep = (f32)Size.Height / (f32)targetSize.Height; - f32 sx,sy; - s32 bpp=target->getBytesPerPixel(); - - u8* nData = (u8*)target->lock(); - - if (targetSize==Size) - { - memcpy(nData,Data,targetSize.Width*targetSize.Height*bpp); - target->unlock(); - return; - } - - sy = 0.0f; - for (s32 y=0; yunlock(); -} - - -//! fills the surface with given color -void CImage::fill(const SColor &color) -{ - u32 c; - - switch ( Format ) - { - case ECF_A1R5G5B5: - c = video::A8R8G8B8toA1R5G5B5 ( color.color ); - c |= c << 16; - break; - case ECF_A8R8G8B8: - c = color.color; - break; - default: -// os::Printer::log("CImage::Format not supported", ELL_ERROR); - return; - } - - memset32 ( Data, c, getImageDataSizeInBytes () ); -} - - -//! get a filtered pixel -inline SColor CImage::getPixelBox ( s32 x, s32 y, s32 fx, s32 fy, s32 bias ) -{ - SColor c; - s32 a = 0, r = 0, g = 0, b = 0; - - for ( s32 dx = 0; dx != fx; ++dx ) - { - for ( s32 dy = 0; dy != fy; ++dy ) - { - c = getPixel ( x + dx , y + dy ); - - a += c.getAlpha (); - r += c.getRed(); - g += c.getGreen(); - b += c.getBlue(); - } - } - - s32 sdiv = s32_log2_s32(fx * fy); - - a = core::s32_clamp ( ( a >> sdiv ) + bias, 0, 255 ); - r = core::s32_clamp ( ( r >> sdiv ) + bias, 0, 255 ); - g = core::s32_clamp ( ( g >> sdiv ) + bias, 0, 255 ); - b = core::s32_clamp ( ( b >> sdiv ) + bias, 0, 255 ); - - c.set ( a, r, g, b ); - return c; -} - - -//! copies this surface into another, scaling it to fit it. -void CImage::copyToScalingBoxFilter(CImage* target, s32 bias) -{ - video::ECOLOR_FORMAT destFormat = target->getColorFormat(); - - if (Format != destFormat ) - { - //os::Printer::log("Format not equal", ELL_ERROR); - return; - } - - core::dimension2d destSize = target->getDimension(); - - f32 sourceXStep = (f32) Size.Width; - f32 sourceYStep = (f32) Size.Height; - - sourceXStep /= (f32) ( destSize.Width - 0 ); - sourceYStep /= (f32) ( destSize.Height - 0 ); - - s32 fx = irr::core::ceil32 ( sourceXStep ); - s32 fy = irr::core::ceil32 ( sourceYStep ); - f32 sx; - f32 sy; - SColor p; - - sy = 0.f; - - for ( s32 y = 0; y != destSize.Height; ++y ) - { - sx = 0.f; - for ( s32 x = 0; x != destSize.Width; ++x ) - { - target->setPixel ( x, y,getPixelBox ( core::floor32 ( sx ), core::floor32 ( sy ), fx, fy, bias ) ); - - sx += sourceXStep; - } - sy += sourceYStep; - } - - target->unlock (); - -} - - - -} // end namespace video -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CImage.h" +#include "irrString.h" +#include "SoftwareDriver2_helper.h" + +namespace irr +{ + + struct SBlitJob + { + AbsRectangle Dest; + AbsRectangle Source; + + u32 argb; + + void * src; + void * dst; + + s32 width; + s32 height; + + u32 srcPitch; + u32 dstPitch; + + u32 srcPixelMul; + u32 dstPixelMul; + }; + + // Blitter Operation + enum eBlitter + { + BLITTER_INVALID = 0, + BLITTER_COLOR, + BLITTER_COLOR_ALPHA, + BLITTER_TEXTURE, + BLITTER_TEXTURE_ALPHA_BLEND, + BLITTER_TEXTURE_ALPHA_COLOR_BLEND + }; + + typedef void (*tExecuteBlit) ( const SBlitJob * job ); + + + // Bitfields Cohen Sutherland + enum eClipCode + { + CLIPCODE_EMPTY = 0, + CLIPCODE_BOTTOM = 1, + CLIPCODE_TOP = 2, + CLIPCODE_LEFT = 4, + CLIPCODE_RIGHT = 8 + }; + +inline u32 GetClipCode ( const AbsRectangle &r, const core::position2d &p ) +{ + u32 code = CLIPCODE_EMPTY; + + if ( p.X < r.x0 ) + code = CLIPCODE_LEFT; + else + if ( p.X > r.x1 ) + code = CLIPCODE_RIGHT; + + if ( p.Y < r.y0 ) + code |= CLIPCODE_TOP; + else + if ( p.Y > r.y1 ) + code |= CLIPCODE_BOTTOM; + + return code; +} + + +/*! + Cohen Sutherland clipping + @return: 1 if valid +*/ + +static int ClipLine (const AbsRectangle &clipping, + core::position2d &p0, + core::position2d &p1, + const core::position2d& p0_in, + const core::position2d& p1_in) +{ + u32 code0; + u32 code1; + u32 code; + + p0 = p0_in; + p1 = p1_in; + + code0 = GetClipCode ( clipping, p0 ); + code1 = GetClipCode ( clipping, p1 ); + + // trivial accepted + while ( code0 | code1 ) + { + s32 x=0; + s32 y=0; + + // trivial reject + if ( code0 & code1 ) + return 0; + + if ( code0 ) + { + // clip first point + code = code0; + } + else + { + // clip last point + code = code1; + } + + if ( (code & CLIPCODE_BOTTOM) == CLIPCODE_BOTTOM ) + { + // clip bottom viewport + y = clipping.y1; + x = p0.X + ( p1.X - p0.X ) * ( y - p0.Y ) / ( p1.Y - p0.Y ); + } + else + if ( (code & CLIPCODE_TOP) == CLIPCODE_TOP ) + { + // clip to viewport + y = clipping.y0; + x = p0.X + ( p1.X - p0.X ) * ( y - p0.Y ) / ( p1.Y - p0.Y ); + } + else + if ( (code & CLIPCODE_RIGHT) == CLIPCODE_RIGHT ) + { + // clip right viewport + x = clipping.x1; + y = p0.Y + ( p1.Y - p0.Y ) * ( x - p0.X ) / ( p1.X - p0.X ); + } + else + if ( (code & CLIPCODE_LEFT) == CLIPCODE_LEFT ) + { + // clip left viewport + x = clipping.x0; + y = p0.Y + ( p1.Y - p0.Y ) * ( x - p0.X ) / ( p1.X - p0.X ); + } + + if ( code == code0 ) + { + // modify first point + p0.X = x; + p0.Y = y; + code0 = GetClipCode ( clipping, p0 ); + } + else + { + // modify second point + p1.X = x; + p1.Y = y; + code1 = GetClipCode ( clipping, p1 ); + } + } + + return 1; +} + +/* +*/ +inline void GetClip(AbsRectangle &clipping, video::IImage * t) +{ + clipping.x0 = 0; + clipping.y0 = 0; + clipping.x1 = t->getDimension().Width - 1; + clipping.y1 = t->getDimension().Height - 1; +} + +/* +*/ +static void RenderLine32_Decal(video::IImage *t, + const core::position2d &p0, + const core::position2d &p1, + u32 argb ) +{ + s32 dx = p1.X - p0.X; + s32 dy = p1.Y - p0.Y; + + s32 c; + s32 m; + s32 d = 0; + s32 run; + + s32 xInc = 4; + s32 yInc = (s32) t->getPitch(); + + if ( dx < 0 ) + { + xInc = -xInc; + dx = -dx; + } + + if ( dy < 0 ) + { + yInc = -yInc; + dy = -dy; + } + + u32 *dst; + dst = (u32*) ( (u8*) t->lock() + ( p0.Y * t->getPitch() ) + ( p0.X << 2 ) ); + + if ( dy > dx ) + { + s32 tmp; + tmp = dx; + dx = dy; + dy = tmp; + tmp = xInc; + xInc = yInc; + yInc = tmp; + } + + c = dx << 1; + m = dy << 1; + + run = dx; + while ( run ) + { + *dst = argb; + + dst = (u32*) ( (u8*) dst + xInc ); // x += xInc + d += m; + if ( d > dx ) + { + dst = (u32*) ( (u8*) dst + yInc ); // y += yInc + d -= c; + } + run -= 1; + } + + t->unlock(); +} + + +/* +*/ +static void RenderLine32_Blend(video::IImage *t, + const core::position2d &p0, + const core::position2d &p1, + u32 argb, u32 alpha) +{ + s32 dx = p1.X - p0.X; + s32 dy = p1.Y - p0.Y; + + s32 c; + s32 m; + s32 d = 0; + s32 run; + + s32 xInc = 4; + s32 yInc = (s32) t->getPitch(); + + if ( dx < 0 ) + { + xInc = -xInc; + dx = -dx; + } + + if ( dy < 0 ) + { + yInc = -yInc; + dy = -dy; + } + + u32 *dst; + dst = (u32*) ( (u8*) t->lock() + ( p0.Y * t->getPitch() ) + ( p0.X << 2 ) ); + + if ( dy > dx ) + { + s32 tmp; + tmp = dx; + dx = dy; + dy = tmp; + tmp = xInc; + xInc = yInc; + yInc = tmp; + } + + c = dx << 1; + m = dy << 1; + + run = dx; + while ( run ) + { + *dst = PixelBlend32 ( *dst, argb, alpha ); + + dst = (u32*) ( (u8*) dst + xInc ); // x += xInc + d += m; + if ( d > dx ) + { + dst = (u32*) ( (u8*) dst + yInc ); // y += yInc + d -= c; + } + run -= 1; + } + + t->unlock(); +} + +/* +*/ +static void RenderLine16_Decal (video::IImage *t, + const core::position2d &p0, + const core::position2d &p1, + u32 argb ) +{ + s32 dx = p1.X - p0.X; + s32 dy = p1.Y - p0.Y; + + s32 c; + s32 m; + s32 d = 0; + s32 run; + + s32 xInc = 2; + s32 yInc = (s32) t->getPitch(); + + if ( dx < 0 ) + { + xInc = -xInc; + dx = -dx; + } + + if ( dy < 0 ) + { + yInc = -yInc; + dy = -dy; + } + + u16 *dst; + dst = (u16*) ( (u8*) t->lock() + ( p0.Y * t->getPitch() ) + ( p0.X << 1 ) ); + + if ( dy > dx ) + { + s32 tmp; + tmp = dx; + dx = dy; + dy = tmp; + tmp = xInc; + xInc = yInc; + yInc = tmp; + } + + c = dx << 1; + m = dy << 1; + + run = dx; + while ( run ) + { + *dst = argb; + + dst = (u16*) ( (u8*) dst + xInc ); // x += xInc + d += m; + if ( d > dx ) + { + dst = (u16*) ( (u8*) dst + yInc ); // y += yInc + d -= c; + } + run -= 1; + } + + t->unlock(); +} + +/* +*/ +static void RenderLine16_Blend (video::IImage *t, + const core::position2d &p0, + const core::position2d &p1, + u32 argb, + u32 alpha) +{ + s32 dx = p1.X - p0.X; + s32 dy = p1.Y - p0.Y; + + s32 c; + s32 m; + s32 d = 0; + s32 run; + + s32 xInc = 2; + s32 yInc = (s32) t->getPitch(); + + if ( dx < 0 ) + { + xInc = -xInc; + dx = -dx; + } + + if ( dy < 0 ) + { + yInc = -yInc; + dy = -dy; + } + + u16 *dst; + dst = (u16*) ( (u8*) t->lock() + ( p0.Y * t->getPitch() ) + ( p0.X << 1 ) ); + + if ( dy > dx ) + { + s32 tmp; + tmp = dx; + dx = dy; + dy = tmp; + tmp = xInc; + xInc = yInc; + yInc = tmp; + } + + c = dx << 1; + m = dy << 1; + + run = dx; + while ( run ) + { + *dst = PixelBlend16 ( *dst, argb, alpha ); + + dst = (u16*) ( (u8*) dst + xInc ); // x += xInc + d += m; + if ( d > dx ) + { + dst = (u16*) ( (u8*) dst + yInc ); // y += yInc + d -= c; + } + run -= 1; + } + + t->unlock(); +} + + +/*! +*/ +static void executeBlit_TextureCopy_x_to_x ( const SBlitJob * job ) +{ + const void *src = (void*) job->src; + void *dst = (void*) job->dst; + + const u32 widthPitch = job->width * job->dstPixelMul; + for ( s32 dy = 0; dy != job->height; ++dy ) + { + memcpy ( dst, src, widthPitch ); + + src = (void*) ( (u8*) (src) + job->srcPitch ); + dst = (void*) ( (u8*) (dst) + job->dstPitch ); + } +} + + +/*! +*/ +static void executeBlit_TextureCopy_32_to_16 ( const SBlitJob * job ) +{ + const u32 *src = (u32*) job->src; + u16 *dst = (u16*) job->dst; + + u32 s; + + for ( s32 dy = 0; dy != job->height; ++dy ) + { + for ( s32 dx = 0; dx != job->width; ++dx ) + { + //16 bit Blitter depends on pre-multiplied color + s = PixelLerp32 ( src[dx] | 0xFF000000, extractAlpha ( src[dx] ) ); + dst[dx] = video::A8R8G8B8toA1R5G5B5 ( s ); + } + + src = (u32*) ( (u8*) (src) + job->srcPitch ); + dst = (u16*) ( (u8*) (dst) + job->dstPitch ); + } +} + +/*! +*/ +static void executeBlit_TextureCopy_24_to_16 ( const SBlitJob * job ) +{ + const void *src = (void*) job->src; + u16 *dst = (u16*) job->dst; + + for ( s32 dy = 0; dy != job->height; ++dy ) + { + u8 * s = (u8*) src; + + for ( s32 dx = 0; dx != job->width; ++dx ) + { + dst[dx] = video::RGB16(s[0], s[1], s[2]); + s += 3; + } + + src = (void*) ( (u8*) (src) + job->srcPitch ); + dst = (u16*) ( (u8*) (dst) + job->dstPitch ); + } +} + + +/*! +*/ +static void executeBlit_TextureCopy_16_to_32 ( const SBlitJob * job ) +{ + const u16 *src = (u16*) job->src; + u32 *dst = (u32*) job->dst; + + for ( s32 dy = 0; dy != job->height; ++dy ) + { + for ( s32 dx = 0; dx != job->width; ++dx ) + { + dst[dx] = video::A1R5G5B5toA8R8G8B8 ( src[dx] ); + } + + src = (u16*) ( (u8*) (src) + job->srcPitch ); + dst = (u32*) ( (u8*) (dst) + job->dstPitch ); + } +} + +/*! +*/ +static void executeBlit_TextureCopy_24_to_32 ( const SBlitJob * job ) +{ + void *src = (void*) job->src; + u32 *dst = (u32*) job->dst; + + for ( s32 dy = 0; dy != job->height; ++dy ) + { + u8 * s = (u8*) src; + + for ( s32 dx = 0; dx != job->width; ++dx ) + { + dst[dx] = 0xFF000000 | s[0] << 16 | s[1] << 8 | s[2]; + s += 3; + } + + src = (void*) ( (u8*) (src) + job->srcPitch ); + dst = (u32*) ( (u8*) (dst) + job->dstPitch ); + } +} + + +/*! +*/ +static void executeBlit_TextureBlend_16_to_16 ( const SBlitJob * job ) +{ + u32 dx; + s32 dy; + + u32 *src = (u32*) job->src; + u32 *dst = (u32*) job->dst; + + + const u32 rdx = job->width >> 1; + const u32 off = core::if_c_a_else_b ( job->width & 1 ,job->width - 1, 0 ); + + + if ( 0 == off ) + { + for ( dy = 0; dy != job->height; ++dy ) + { + for ( dx = 0; dx != rdx; ++dx ) + { + dst[dx] = PixelBlend16_simd ( dst[dx], src[dx] ); + } + + src = (u32*) ( (u8*) (src) + job->srcPitch ); + dst = (u32*) ( (u8*) (dst) + job->dstPitch ); + } + + } + else + { + for ( dy = 0; dy != job->height; ++dy ) + { + for ( dx = 0; dx != rdx; ++dx ) + { + dst[dx] = PixelBlend16_simd ( dst[dx], src[dx] ); + } + + ((u16*) dst)[off] = PixelBlend16 ( ((u16*) dst)[off], ((u16*) src)[off] ); + + src = (u32*) ( (u8*) (src) + job->srcPitch ); + dst = (u32*) ( (u8*) (dst) + job->dstPitch ); + } + + } +} + +/*! +*/ +static void executeBlit_TextureBlend_32_to_32 ( const SBlitJob * job ) +{ + u32 *src = (u32*) job->src; + u32 *dst = (u32*) job->dst; + + for ( s32 dy = 0; dy != job->height; ++dy ) + { + for ( s32 dx = 0; dx != job->width; ++dx ) + { + dst[dx] = PixelBlend32 ( dst[dx], src[dx] ); + } + src = (u32*) ( (u8*) (src) + job->srcPitch ); + dst = (u32*) ( (u8*) (dst) + job->dstPitch ); + } +} + +/*! +*/ +static void executeBlit_TextureBlendColor_16_to_16 ( const SBlitJob * job ) +{ + u16 *src = (u16*) job->src; + u16 *dst = (u16*) job->dst; + + u16 blend = video::A8R8G8B8toA1R5G5B5 ( job->argb ); + for ( s32 dy = 0; dy != job->height; ++dy ) + { + for ( s32 dx = 0; dx != job->width; ++dx ) + { + dst[dx] = PixelBlend16 ( dst[dx], PixelMul16_2 ( src[dx], blend ) ); + } + src = (u16*) ( (u8*) (src) + job->srcPitch ); + dst = (u16*) ( (u8*) (dst) + job->dstPitch ); + } +} + + +/*! +*/ +static void executeBlit_TextureBlendColor_32_to_32 ( const SBlitJob * job ) +{ + u32 *src = (u32*) job->src; + u32 *dst = (u32*) job->dst; + + for ( s32 dy = 0; dy != job->height; ++dy ) + { + for ( s32 dx = 0; dx != job->width; ++dx ) + { + dst[dx] = PixelBlend32 ( dst[dx], PixelMul32_2 ( src[dx], job->argb ) ); + } + src = (u32*) ( (u8*) (src) + job->srcPitch ); + dst = (u32*) ( (u8*) (dst) + job->dstPitch ); + } +} + +/*! +*/ +static void executeBlit_Color_16_to_16 ( const SBlitJob * job ) +{ + u16 *dst = (u16*) job->dst; + + u16 c0 = video::A8R8G8B8toA1R5G5B5 ( job->argb ); + u32 c = c0 | c0 << 16; + + if ( 0 == (job->srcPitch & 3 ) ) + { + for ( s32 dy = 0; dy != job->height; ++dy ) + { + memset32 ( dst, c, job->srcPitch ); + dst = (u16*) ( (u8*) (dst) + job->dstPitch ); + } + } + else + { + s32 dx = job->width - 1; + + for ( s32 dy = 0; dy != job->height; ++dy ) + { + memset32 ( dst, c, job->srcPitch ); + dst[dx] = c0; + dst = (u16*) ( (u8*) (dst) + job->dstPitch ); + } + + } +} + +/*! +*/ +static void executeBlit_Color_32_to_32 ( const SBlitJob * job ) +{ + u32 *dst = (u32*) job->dst; + + for ( s32 dy = 0; dy != job->height; ++dy ) + { + memset32 ( dst, job->argb, job->srcPitch ); + dst = (u32*) ( (u8*) (dst) + job->dstPitch ); + } +} + +/*! +*/ +static void executeBlit_ColorAlpha_16_to_16 ( const SBlitJob * job ) +{ + u16 *dst = (u16*) job->dst; + + const u32 alpha = extractAlpha ( job->argb ) >> 3; + const u32 src = video::A8R8G8B8toA1R5G5B5 ( job->argb ); + + for ( s32 dy = 0; dy != job->height; ++dy ) + { + for ( s32 dx = 0; dx != job->width; ++dx ) + { + dst[dx] = PixelBlend16 ( dst[dx], src, alpha ); + } + dst = (u16*) ( (u8*) (dst) + job->dstPitch ); + } +} + +/*! +*/ +static void executeBlit_ColorAlpha_32_to_32 ( const SBlitJob * job ) +{ + u32 *dst = (u32*) job->dst; + + const u32 alpha = extractAlpha ( job->argb ); + const u32 src = job->argb; + + for ( s32 dy = 0; dy != job->height; ++dy ) + { + for ( s32 dx = 0; dx != job->width; ++dx ) + { + dst[dx] = PixelBlend32 ( dst[dx], src, alpha ); + } + dst = (u32*) ( (u8*) (dst) + job->dstPitch ); + } +} + +/*! +*/ +static tExecuteBlit getBlitter ( eBlitter operation,const video::IImage * dest,const video::IImage * source ) +{ + video::ECOLOR_FORMAT sourceFormat = (video::ECOLOR_FORMAT) -1; + video::ECOLOR_FORMAT destFormat = (video::ECOLOR_FORMAT) -1; + + if ( source ) + sourceFormat = source->getColorFormat (); + + if ( dest ) + destFormat = dest->getColorFormat (); + + switch ( operation ) + { + case BLITTER_TEXTURE: + { + if ( sourceFormat == destFormat ) + return executeBlit_TextureCopy_x_to_x; + + if ( destFormat == video::ECF_A1R5G5B5 && sourceFormat == video::ECF_A8R8G8B8 ) + return executeBlit_TextureCopy_32_to_16; + + if ( destFormat == video::ECF_A1R5G5B5 && sourceFormat == video::ECF_R8G8B8 ) + return executeBlit_TextureCopy_24_to_16; + + if ( destFormat == video::ECF_A8R8G8B8 && sourceFormat == video::ECF_A1R5G5B5 ) + return executeBlit_TextureCopy_16_to_32; + + if ( destFormat == video::ECF_A8R8G8B8 && sourceFormat == video::ECF_R8G8B8 ) + return executeBlit_TextureCopy_24_to_32; + + } break; + + case BLITTER_TEXTURE_ALPHA_BLEND: + { + if ( destFormat == video::ECF_A1R5G5B5 && sourceFormat == video::ECF_A1R5G5B5 ) + return executeBlit_TextureBlend_16_to_16; + + if ( destFormat == video::ECF_A8R8G8B8 && sourceFormat == video::ECF_A8R8G8B8 ) + return executeBlit_TextureBlend_32_to_32; + + } break; + + case BLITTER_TEXTURE_ALPHA_COLOR_BLEND: + { + if ( destFormat == video::ECF_A1R5G5B5 && sourceFormat == video::ECF_A1R5G5B5 ) + return executeBlit_TextureBlendColor_16_to_16; + + if ( destFormat == video::ECF_A8R8G8B8 && sourceFormat == video::ECF_A8R8G8B8 ) + return executeBlit_TextureBlendColor_32_to_32; + } break; + + case BLITTER_COLOR: + { + if ( destFormat == video::ECF_A1R5G5B5 ) + return executeBlit_Color_16_to_16; + + if ( destFormat == video::ECF_A8R8G8B8 ) + return executeBlit_Color_32_to_32; + } break; + + case BLITTER_COLOR_ALPHA: + { + if ( destFormat == video::ECF_A1R5G5B5 ) + return executeBlit_ColorAlpha_16_to_16; + + if ( destFormat == video::ECF_A8R8G8B8 ) + return executeBlit_ColorAlpha_32_to_32; + + } break; + + case BLITTER_INVALID: + break; + } +/* + char buf[64]; + sprintf ( buf, "Blit: %d %d->%d unsupported",operation,sourceFormat,destFormat ); + os::Printer::log (buf ); +*/ + return 0; + +} + + + +/*! + a generic 2D Blitter +*/ +static s32 Blit ( eBlitter operation, + video::IImage * dest, + const core::rect *destClipping, + const core::position2d *destPos, + video::IImage * source, + const core::rect *sourceClipping, + u32 argb + ) +{ + tExecuteBlit blitter = getBlitter ( operation, dest, source ); + if ( 0 == blitter ) + { + return 0; + } + + // Clipping + AbsRectangle sourceClip; + AbsRectangle destClip; + AbsRectangle v; + + SBlitJob job; + + if ( sourceClipping ) + { + sourceClip.x0 = sourceClipping->UpperLeftCorner.X; + sourceClip.y0 = sourceClipping->UpperLeftCorner.Y; + sourceClip.x1 = sourceClipping->LowerRightCorner.X; + sourceClip.y1 = sourceClipping->LowerRightCorner.Y; + } + else + { + sourceClip.x0 = 0; + sourceClip.y0 = 0; + sourceClip.x1 = source ? source->getDimension().Width : 0; + sourceClip.y1 = source ? source->getDimension().Height : 0; + } + + if ( destClipping ) + { + destClip.x0 = destClipping->UpperLeftCorner.X; + destClip.y0 = destClipping->UpperLeftCorner.Y; + destClip.x1 = destClipping->LowerRightCorner.X; + destClip.y1 = destClipping->LowerRightCorner.Y; + } + else + { + destClip.x0 = 0; + destClip.y0 = 0; + destClip.x1 = dest ? dest->getDimension().Width : 0; + destClip.y1 = dest ? dest->getDimension().Height : 0; + } + + v.x0 = destPos ? destPos->X : 0; + v.y0 = destPos ? destPos->Y : 0; + v.x1 = v.x0 + ( sourceClip.x1 - sourceClip.x0 ); + v.y1 = v.y0 + ( sourceClip.y1 - sourceClip.y0 ); + + intersect ( job.Dest, destClip, v ); + if ( !isValid ( job.Dest ) ) + return 0; + + job.width = job.Dest.x1 - job.Dest.x0; + job.height = job.Dest.y1 - job.Dest.y0; + + + job.Source.x0 = sourceClip.x0 + ( job.Dest.x0 - v.x0 ); + job.Source.x1 = job.Source.x0 + job.width; + + job.Source.y0 = sourceClip.y0 + ( job.Dest.y0 - v.y0 ); + job.Source.y1 = job.Source.y0 + job.height; + + job.argb = argb; + + if ( source ) + { + job.srcPitch = source->getPitch(); + job.srcPixelMul = source->getBytesPerPixel(); + job.src = (void*) ( (u8*) source->lock() + ( job.Source.y0 * job.srcPitch ) + ( job.Source.x0 * job.srcPixelMul ) ); + } + else + { + // use srcPitch for color operation on dest + job.srcPitch = job.width * dest->getBytesPerPixel(); + } + + job.dstPitch = dest->getPitch(); + job.dstPixelMul = dest->getBytesPerPixel(); + job.dst = (void*) ( (u8*) dest->lock() + ( job.Dest.y0 * job.dstPitch ) + ( job.Dest.x0 * job.dstPixelMul ) ); + + blitter ( &job ); + + if ( source ) + source->unlock (); + + if ( dest ) + dest->unlock(); + + return 1; +} + +} + +namespace irr +{ +namespace video +{ + +//! constructor +CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d& size) +:Data(0), Size(size), Format(format), DeleteMemory(true) +{ + initData(); +} + + +//! constructor +CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d& size, void* data, + bool ownForeignMemory, bool deleteForeignMemory) +: Data(0), Size(size), Format(format), DeleteMemory(deleteForeignMemory) +{ + if (ownForeignMemory) + { + Data = (void*)0xbadf00d; + initData(); + Data = data; + } + else + { + Data = 0; + initData(); + memcpy(Data, data, Size.Height * Size.Width * BytesPerPixel); + } +} + + + +//! constructor +CImage::CImage(ECOLOR_FORMAT format, IImage* imageToCopy) +: Data(0), Format(format), DeleteMemory(true) +{ + if (!imageToCopy) + return; + + Size = imageToCopy->getDimension(); + initData(); + + // now copy data from other image + + Blit ( BLITTER_TEXTURE, this, 0, 0, imageToCopy, 0,0 ); +} + + + +//! constructor +CImage::CImage(IImage* imageToCopy, const core::position2d& pos, + const core::dimension2d& size) + : Data(0), Size(0,0), DeleteMemory(true) +{ + if (!imageToCopy) + return; + + Format = imageToCopy->getColorFormat(); + Size = size; + + initData(); + + core::rect sClip( pos.X, pos.Y, pos.X + size.Width,pos.Y + size.Height ); + Blit ( BLITTER_TEXTURE, this, 0, 0, imageToCopy, &sClip,0 ); +} + + + +//! assumes format and size has been set and creates the rest +void CImage::initData() +{ + BitsPerPixel = getBitsPerPixelFromFormat(); + BytesPerPixel = BitsPerPixel / 8; + + // Pitch should be aligned... + Pitch = BytesPerPixel * Size.Width; + + if (!Data) + Data = new s8[Size.Height * Pitch]; +} + + +//! destructor +CImage::~CImage() +{ + if ( DeleteMemory ) + delete [] (s8*)Data; +} + + +//! Returns width and height of image data. +const core::dimension2d& CImage::getDimension() +{ + return Size; +} + + + +//! Returns bits per pixel. +s32 CImage::getBitsPerPixel() +{ + return BitsPerPixel; +} + + +//! Returns bytes per pixel +s32 CImage::getBytesPerPixel() +{ + return BytesPerPixel; +} + + + +//! Returns image data size in bytes +s32 CImage::getImageDataSizeInBytes() +{ + return Pitch * Size.Height; +} + + + +//! Returns image data size in pixels +s32 CImage::getImageDataSizeInPixels() +{ + return Size.Width * Size.Height; +} + + + +//! returns mask for red value of a pixel +u32 CImage::getRedMask() +{ + return RedMask; +} + + + +//! returns mask for green value of a pixel +u32 CImage::getGreenMask() +{ + return GreenMask; +} + + + +//! returns mask for blue value of a pixel +u32 CImage::getBlueMask() +{ + return BlueMask; +} + + + +//! returns mask for alpha value of a pixel +u32 CImage::getAlphaMask() +{ + return AlphaMask; +} + + +s32 CImage::getBitsPerPixelFromFormat() +{ + switch(Format) + { + case ECF_A1R5G5B5: + AlphaMask = 0x1<<15; + RedMask = 0x1F<<10; + GreenMask = 0x1F<<5; + BlueMask = 0x1F; + return 16; + case ECF_R5G6B5: + AlphaMask = 0x0; + RedMask = 0x1F<<11; + GreenMask = 0x3F<<5; + BlueMask = 0x1F; + return 16; + case ECF_R8G8B8: + AlphaMask = 0x0; + RedMask = 0xFF<<16; + GreenMask = 0xFF<<8; + BlueMask = 0xFF; + return 24; + case ECF_A8R8G8B8: + AlphaMask = 0xFF<<24; + RedMask = 0xFF<<16; + GreenMask = 0xFF<<8; + BlueMask = 0xFF; + return 32; + } + +// os::Printer::log("CImage: Unknown color format.", ELL_ERROR); + return 0; +} + +//! sets a pixel +void CImage::setPixel(s32 x, s32 y, const SColor &color ) +{ + if (x < 0 || y < 0 || x >= Size.Width || y >= Size.Height) + return; + + switch(Format) + { + case ECF_A1R5G5B5: + { + u16 * dest = (u16*) ((u8*) Data + ( y * Pitch ) + ( x << 1 )); + *dest = video::A8R8G8B8toA1R5G5B5 ( color.color ); + } break; + + case ECF_A8R8G8B8: + { + u32 * dest = (u32*) ((u8*) Data + ( y * Pitch ) + ( x << 2 )); + *dest = color.color; + } break; + + } +} + + +//! returns a pixel +SColor CImage::getPixel(s32 x, s32 y) +{ + if (x < 0 || y < 0 || x >= Size.Width || y >= Size.Height) + return SColor(0); + + switch(Format) + { + case ECF_A1R5G5B5: + return A1R5G5B5toA8R8G8B8(((u16*)Data)[y*Size.Width + x]); + case ECF_R5G6B5: + return R5G6B5toA8R8G8B8(((u16*)Data)[y*Size.Width + x]); + case ECF_A8R8G8B8: + return ((u32*)Data)[y*Size.Width + x]; + case ECF_R8G8B8: + { + u8* p = &((u8*)Data)[(y*3)*Size.Width + (x*3)]; + return SColor(255,p[0],p[1],p[2]); + } + } + + return SColor(0); +} + + +//! returns the color format +ECOLOR_FORMAT CImage::getColorFormat() const +{ + return Format; +} + +//! draws a rectangle +void CImage::drawRectangle(const core::rect& rect, const SColor &color) +{ + Blit ( color.getAlpha() == 0xFF ? BLITTER_COLOR : BLITTER_COLOR_ALPHA, + this, 0, &rect.UpperLeftCorner, 0, &rect, color.color ); +} + + +//! copies this surface into another +void CImage::copyTo(CImage* target, const core::position2d& pos) +{ + Blit ( BLITTER_TEXTURE, target, 0, &pos, this, 0, 0 ); +} + + +//! copies this surface into another +void CImage::copyTo(CImage* target, const core::position2d& pos, const core::rect& sourceRect, const core::rect* clipRect) +{ + Blit ( BLITTER_TEXTURE, target, clipRect, &pos, this, &sourceRect, 0 ); +} + + + +//! copies this surface into another, using the alpha mask, an cliprect and a color to add with +void CImage::copyToWithAlpha(CImage* target, const core::position2d& pos, const core::rect& sourceRect, const SColor &color, const core::rect* clipRect) +{ + // color blend only necessary on not full spectrum aka. color.color != 0xFFFFFFFF + Blit ( color.color == 0xFFFFFFFF ? BLITTER_TEXTURE_ALPHA_BLEND: BLITTER_TEXTURE_ALPHA_COLOR_BLEND, + target, clipRect, &pos, this, &sourceRect, color.color ); +} + + + +//! draws a line from to with color +void CImage::drawLine(const core::position2d& from, const core::position2d& to, const SColor &color) +{ + AbsRectangle clip; + GetClip ( clip, this ); + + core::position2d p[2]; + + if ( ClipLine ( clip, p[0], p[1], from, to ) ) + { + u32 alpha = extractAlpha ( color.color ); + + switch ( Format ) + { + case ECF_A1R5G5B5: + if ( alpha == 256 ) + { + RenderLine16_Decal ( this, p[0], p[1], video::A8R8G8B8toA1R5G5B5 ( color.color ) ); + } + else + { + RenderLine16_Blend ( this, p[0], p[1], video::A8R8G8B8toA1R5G5B5 ( color.color ), alpha >> 3 ); + } + break; + case ECF_A8R8G8B8: + if ( alpha == 256 ) + { + RenderLine32_Decal ( this, p[0], p[1], color.color ); + } + else + { + RenderLine32_Blend ( this, p[0], p[1], color.color, alpha ); + } + break; + } + } +} + + + +//! copies this surface into another, scaling it to the target image size +// note: this is very very slow. (i didn't want to write a fast version. +// but hopefully, nobody wants to scale surfaces every frame. +void CImage::copyToScaling(CImage* target) +{ + if (Format != target->getColorFormat() ) + { +// os::Printer::log("Format not equal", ELL_ERROR); + return; + } + + core::dimension2d targetSize = target->getDimension(); + + if (!targetSize.Width || !targetSize.Height) + return; + + f32 sourceXStep = (f32)Size.Width / (f32)targetSize.Width; + f32 sourceYStep = (f32)Size.Height / (f32)targetSize.Height; + f32 sx,sy; + s32 bpp=target->getBytesPerPixel(); + + u8* nData = (u8*)target->lock(); + + if (targetSize==Size) + { + memcpy(nData,Data,targetSize.Width*targetSize.Height*bpp); + target->unlock(); + return; + } + + sy = 0.0f; + for (s32 y=0; yunlock(); +} + + +//! fills the surface with given color +void CImage::fill(const SColor &color) +{ + u32 c; + + switch ( Format ) + { + case ECF_A1R5G5B5: + c = video::A8R8G8B8toA1R5G5B5 ( color.color ); + c |= c << 16; + break; + case ECF_A8R8G8B8: + c = color.color; + break; + default: +// os::Printer::log("CImage::Format not supported", ELL_ERROR); + return; + } + + memset32 ( Data, c, getImageDataSizeInBytes () ); +} + + +//! get a filtered pixel +inline SColor CImage::getPixelBox ( s32 x, s32 y, s32 fx, s32 fy, s32 bias ) +{ + SColor c; + s32 a = 0, r = 0, g = 0, b = 0; + + for ( s32 dx = 0; dx != fx; ++dx ) + { + for ( s32 dy = 0; dy != fy; ++dy ) + { + c = getPixel ( x + dx , y + dy ); + + a += c.getAlpha (); + r += c.getRed(); + g += c.getGreen(); + b += c.getBlue(); + } + } + + s32 sdiv = s32_log2_s32(fx * fy); + + a = core::s32_clamp ( ( a >> sdiv ) + bias, 0, 255 ); + r = core::s32_clamp ( ( r >> sdiv ) + bias, 0, 255 ); + g = core::s32_clamp ( ( g >> sdiv ) + bias, 0, 255 ); + b = core::s32_clamp ( ( b >> sdiv ) + bias, 0, 255 ); + + c.set ( a, r, g, b ); + return c; +} + + +//! copies this surface into another, scaling it to fit it. +void CImage::copyToScalingBoxFilter(CImage* target, s32 bias) +{ + video::ECOLOR_FORMAT destFormat = target->getColorFormat(); + + if (Format != destFormat ) + { + //os::Printer::log("Format not equal", ELL_ERROR); + return; + } + + core::dimension2d destSize = target->getDimension(); + + f32 sourceXStep = (f32) Size.Width; + f32 sourceYStep = (f32) Size.Height; + + sourceXStep /= (f32) ( destSize.Width - 0 ); + sourceYStep /= (f32) ( destSize.Height - 0 ); + + s32 fx = irr::core::ceil32 ( sourceXStep ); + s32 fy = irr::core::ceil32 ( sourceYStep ); + f32 sx; + f32 sy; + SColor p; + + sy = 0.f; + + for ( s32 y = 0; y != destSize.Height; ++y ) + { + sx = 0.f; + for ( s32 x = 0; x != destSize.Width; ++x ) + { + target->setPixel ( x, y,getPixelBox ( core::floor32 ( sx ), core::floor32 ( sy ), fx, fy, bias ) ); + + sx += sourceXStep; + } + sy += sourceYStep; + } + + target->unlock (); + +} + + + +} // end namespace video +} // end namespace irr diff --git a/src/dep/src/irrlicht/CImage.h b/src/dep/src/irrlicht/CImage.h index f8a771e..a929fda 100644 --- a/src/dep/src/irrlicht/CImage.h +++ b/src/dep/src/irrlicht/CImage.h @@ -1,147 +1,147 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IMAGE_H_INCLUDED__ -#define __C_IMAGE_H_INCLUDED__ - -#include "IImage.h" -#include "rect.h" - -namespace irr -{ -namespace video -{ - -//! IImage implementation with a lot of special image operations for -//! 16 bit A1R5G5B5/32 Bit A8R8G8B8 images, which are used by the SoftwareDevice. -class CImage : public IImage -{ -public: - - //! constructor - CImage(ECOLOR_FORMAT format, IImage* imageToCopy); - - //! constructor - //! \param useForeignMemory: If true, the image will use the data pointer - //! directly and own it from now on, which means it will also try to delete [] the - //! data when the image will be destructed. If false, the memory will by copied. - CImage(ECOLOR_FORMAT format, const core::dimension2d& size, - void* data, bool ownForeignMemory=true, bool deleteMemory = true); - - //! constructor - CImage(ECOLOR_FORMAT format, const core::dimension2d& size); - - //! constructor - CImage(IImage* imageToCopy, - const core::position2d& pos, const core::dimension2d& size); - - //! destructor - virtual ~CImage(); - - //! Lock function. - virtual void* lock() - { - return Data; - }; - - //! Unlock function. - virtual void unlock() {}; - - //! Returns width and height of image data. - virtual const core::dimension2d& getDimension(); - - //! Returns bits per pixel. - virtual s32 getBitsPerPixel(); - - //! Returns bytes per pixel - virtual s32 getBytesPerPixel(); - - //! Returns image data size in bytes - virtual s32 getImageDataSizeInBytes(); - - //! Returns image data size in pixels - virtual s32 getImageDataSizeInPixels(); - - //! returns mask for red value of a pixel - virtual u32 getRedMask(); - - //! returns mask for green value of a pixel - virtual u32 getGreenMask(); - - //! returns mask for blue value of a pixel - virtual u32 getBlueMask(); - - //! returns mask for alpha value of a pixel - virtual u32 getAlphaMask(); - - //! returns a pixel - virtual SColor getPixel(s32 x, s32 y); - - //! sets a pixel - virtual void setPixel(s32 x, s32 y, const SColor &color ); - - //! returns the color format - virtual ECOLOR_FORMAT getColorFormat() const; - - //! draws a rectangle - void drawRectangle(const core::rect& rect, const SColor &color); - - //! copies this surface into another - void copyTo(CImage* target, const core::position2d& pos); - - //! copies this surface into another - void copyTo(CImage* target, const core::position2d& pos, const core::rect& sourceRect, const core::rect* clipRect=0); - - //! copies this surface into another, using the alpha mask, an cliprect and a color to add with - void copyToWithAlpha(CImage* target, const core::position2d& pos, const core::rect& sourceRect, const SColor &color, const core::rect* clipRect = 0); - - //! copies this surface into another, scaling it to fit it. - void copyToScaling(CImage* target); - - //! copies this surface into another, scaling it to fit it, appyling a box filter - void copyToScalingBoxFilter(CImage* target, s32 bias = 0); - - //! draws a line from to - void drawLine(const core::position2d& from, const core::position2d& to, const SColor &color); - - //! fills the surface with black or white - void fill(const SColor &color); - - //! returns pitch of image - virtual u32 getPitch() const - { - return Pitch; - } - - -private: - - //! assumes format and size has been set and creates the rest - void initData(); - - s32 getBitsPerPixelFromFormat(); - - inline SColor getPixelBox ( s32 x, s32 y, s32 fx, s32 fy, s32 bias ); - - void* Data; - core::dimension2d Size; - s32 BitsPerPixel; - s32 BytesPerPixel; - u32 Pitch; - ECOLOR_FORMAT Format; - - bool DeleteMemory; - - u32 RedMask; - u32 GreenMask; - u32 BlueMask; - u32 AlphaMask; -}; - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_IMAGE_H_INCLUDED__ +#define __C_IMAGE_H_INCLUDED__ + +#include "IImage.h" +#include "rect.h" + +namespace irr +{ +namespace video +{ + +//! IImage implementation with a lot of special image operations for +//! 16 bit A1R5G5B5/32 Bit A8R8G8B8 images, which are used by the SoftwareDevice. +class CImage : public IImage +{ +public: + + //! constructor + CImage(ECOLOR_FORMAT format, IImage* imageToCopy); + + //! constructor + //! \param useForeignMemory: If true, the image will use the data pointer + //! directly and own it from now on, which means it will also try to delete [] the + //! data when the image will be destructed. If false, the memory will by copied. + CImage(ECOLOR_FORMAT format, const core::dimension2d& size, + void* data, bool ownForeignMemory=true, bool deleteMemory = true); + + //! constructor + CImage(ECOLOR_FORMAT format, const core::dimension2d& size); + + //! constructor + CImage(IImage* imageToCopy, + const core::position2d& pos, const core::dimension2d& size); + + //! destructor + virtual ~CImage(); + + //! Lock function. + virtual void* lock() + { + return Data; + }; + + //! Unlock function. + virtual void unlock() {}; + + //! Returns width and height of image data. + virtual const core::dimension2d& getDimension(); + + //! Returns bits per pixel. + virtual s32 getBitsPerPixel(); + + //! Returns bytes per pixel + virtual s32 getBytesPerPixel(); + + //! Returns image data size in bytes + virtual s32 getImageDataSizeInBytes(); + + //! Returns image data size in pixels + virtual s32 getImageDataSizeInPixels(); + + //! returns mask for red value of a pixel + virtual u32 getRedMask(); + + //! returns mask for green value of a pixel + virtual u32 getGreenMask(); + + //! returns mask for blue value of a pixel + virtual u32 getBlueMask(); + + //! returns mask for alpha value of a pixel + virtual u32 getAlphaMask(); + + //! returns a pixel + virtual SColor getPixel(s32 x, s32 y); + + //! sets a pixel + virtual void setPixel(s32 x, s32 y, const SColor &color ); + + //! returns the color format + virtual ECOLOR_FORMAT getColorFormat() const; + + //! draws a rectangle + void drawRectangle(const core::rect& rect, const SColor &color); + + //! copies this surface into another + void copyTo(CImage* target, const core::position2d& pos); + + //! copies this surface into another + void copyTo(CImage* target, const core::position2d& pos, const core::rect& sourceRect, const core::rect* clipRect=0); + + //! copies this surface into another, using the alpha mask, an cliprect and a color to add with + void copyToWithAlpha(CImage* target, const core::position2d& pos, const core::rect& sourceRect, const SColor &color, const core::rect* clipRect = 0); + + //! copies this surface into another, scaling it to fit it. + void copyToScaling(CImage* target); + + //! copies this surface into another, scaling it to fit it, appyling a box filter + void copyToScalingBoxFilter(CImage* target, s32 bias = 0); + + //! draws a line from to + void drawLine(const core::position2d& from, const core::position2d& to, const SColor &color); + + //! fills the surface with black or white + void fill(const SColor &color); + + //! returns pitch of image + virtual u32 getPitch() const + { + return Pitch; + } + + +private: + + //! assumes format and size has been set and creates the rest + void initData(); + + s32 getBitsPerPixelFromFormat(); + + inline SColor getPixelBox ( s32 x, s32 y, s32 fx, s32 fy, s32 bias ); + + void* Data; + core::dimension2d Size; + s32 BitsPerPixel; + s32 BytesPerPixel; + u32 Pitch; + ECOLOR_FORMAT Format; + + bool DeleteMemory; + + u32 RedMask; + u32 GreenMask; + u32 BlueMask; + u32 AlphaMask; +}; + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CImageLoaderBMP.cpp b/src/dep/src/irrlicht/CImageLoaderBMP.cpp index 629d90d..e51235c 100644 --- a/src/dep/src/irrlicht/CImageLoaderBMP.cpp +++ b/src/dep/src/irrlicht/CImageLoaderBMP.cpp @@ -1,378 +1,378 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageLoaderBMP.h" -#include "SColor.h" -#include "CColorConverter.h" -#include "CImage.h" -#include "os.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - - -//! constructor -CImageLoaderBMP::CImageLoaderBMP() -: BmpData(0), PaletteData(0) -{ - #ifdef _DEBUG - setDebugName("CImageLoaderBMP"); - #endif -} - - - -//! destructor -CImageLoaderBMP::~CImageLoaderBMP() -{ - if (PaletteData) - delete [] PaletteData; - - if (BmpData) - delete [] BmpData; -} - - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".tga") -bool CImageLoaderBMP::isALoadableFileExtension(const c8* fileName) -{ - return strstr(fileName, ".bmp") != 0; -} - - - -//! returns true if the file maybe is able to be loaded by this class -bool CImageLoaderBMP::isALoadableFileFormat(irr::io::IReadFile* file) -{ - u16 headerID; - file->read(&headerID, sizeof(u16)); -#ifdef __BIG_ENDIAN__ - headerID = os::Byteswap::byteswap(headerID); -#endif - return headerID == 0x4d42; -} - - -void CImageLoaderBMP::decompress8BitRLE(u8*& BmpData, s32 size, s32 width, s32 height, s32 pitch) -{ - u8* p = BmpData; - u8* newBmp = new u8[(width+pitch)*height]; - u8* d = newBmp; - u8* destEnd = newBmp + (width+pitch)*height; - s32 line = 0; - - while (BmpData - p < size && d < destEnd) - { - if (*p == 0) - { - ++p; - - switch(*p) - { - case 0: // end of line - ++p; - ++line; - d = newBmp + (line*(width+pitch)); - break; - case 1: // end of bmp - delete [] BmpData; - BmpData = newBmp; - return; - case 2: - ++p; d +=(u8)*p; // delta - ++p; d += ((u8)*p)*(width+pitch); - ++p; - break; - default: - { - // absolute mode - s32 count = (u8)*p; ++p; - s32 readAdditional = ((2-(count%2))%2); - s32 i; - - for (i=0; i> readShift) & 0x0f; - readShift -= 4; - if (readShift < 0) - { - ++*p; - readShift = 4; - } - - u8 mask = 0x0f << shift; - *d = (*d & (~mask)) | ((color << shift) & mask); - - shift -= 4; - if (shift < 0) - { - shift = 4; - ++d; - } - - } - - for (i=0; i> 4) & 0x0f; - ++p; - - for (s32 i=0; iread(&header, sizeof(header)); - -#ifdef __BIG_ENDIAN__ - header.Id = os::Byteswap::byteswap(header.Id); - header.FileSize = os::Byteswap::byteswap(header.FileSize); - header.BitmapDataOffset = os::Byteswap::byteswap(header.BitmapDataOffset); - header.BitmapHeaderSize = os::Byteswap::byteswap(header.BitmapHeaderSize); - header.Width = os::Byteswap::byteswap(header.Width); - header.Height = os::Byteswap::byteswap(header.Height); - header.Planes = os::Byteswap::byteswap(header.Planes); - header.BPP = os::Byteswap::byteswap(header.BPP); - header.Compression = os::Byteswap::byteswap(header.Compression); - header.BitmapDataSize = os::Byteswap::byteswap(header.BitmapDataSize); - header.PixelPerMeterX = os::Byteswap::byteswap(header.PixelPerMeterX); - header.PixelPerMeterY = os::Byteswap::byteswap(header.PixelPerMeterY); - header.Colors = os::Byteswap::byteswap(header.Colors); - header.ImportantColors = os::Byteswap::byteswap(header.ImportantColors); -#endif - - s32 pitch = 0; - - //! return if the header is false - - if (header.Id != 0x4d42) - return 0; - - if (header.Compression > 2) // we'll only handle RLE-Compression - { - os::Printer::log("Compression mode not supported.", ELL_ERROR); - return 0; - } - - // adjust bitmap data size to dword boundary - header.BitmapDataSize += (4-(header.BitmapDataSize%4))%4; - - // read palette - - s32 pos = file->getPos(); - s32 paletteSize = (header.BitmapDataOffset - pos) / 4; - - if (paletteSize) - { - PaletteData = new s32[paletteSize]; - file->read(PaletteData, paletteSize * sizeof(s32)); -#ifdef __BIG_ENDIAN__ - for (int i=0; igetSize() - header.BitmapDataOffset; - } - - file->seek(header.BitmapDataOffset); - - f32 t = (header.Width) * (header.BPP / 8.0f); - s32 widthInBytes = (s32)t; - t -= widthInBytes; - if (t!=0.0f) - ++widthInBytes; - - s32 lineData = widthInBytes + ((4-(widthInBytes%4)))%4; - pitch = lineData - widthInBytes; - - BmpData = new u8[header.BitmapDataSize]; - file->read(BmpData, header.BitmapDataSize); - - // decompress data if needed - switch(header.Compression) - { - case 1: // 8 bit rle - decompress8BitRLE(BmpData, header.BitmapDataSize, header.Width, header.Height, pitch); - break; - case 2: // 4 bit rle - decompress4BitRLE(BmpData, header.BitmapDataSize, header.Width, header.Height, pitch); - break; - } - - // create surface - - IImage* image = 0; - switch(header.BPP) - { - case 1: - image = new CImage(ECF_A1R5G5B5, core::dimension2d(header.Width, header.Height)); - if (image) - CColorConverter::convert1BitTo16Bit(BmpData, (s16*)image->lock(), header.Width, header.Height, pitch, true); - break; - case 4: - image = new CImage(ECF_A1R5G5B5, core::dimension2d(header.Width, header.Height)); - if (image) - CColorConverter::convert4BitTo16Bit(BmpData, (s16*)image->lock(), header.Width, header.Height, PaletteData, pitch, true); - break; - case 8: - image = new CImage(ECF_A1R5G5B5, core::dimension2d(header.Width, header.Height)); - if (image) - CColorConverter::convert8BitTo16Bit(BmpData, (s16*)image->lock(), header.Width, header.Height, PaletteData, pitch, true); - break; - case 16: - image = new CImage(ECF_A1R5G5B5, core::dimension2d(header.Width, header.Height)); - if (image) - CColorConverter::convert16BitTo16Bit((s16*)BmpData, (s16*)image->lock(), header.Width, header.Height, pitch, true); - break; - case 24: - image = new CImage(ECF_R8G8B8, core::dimension2d(header.Width, header.Height)); - if (image) - CColorConverter::convert24BitTo24Bit(BmpData, (u8*)image->lock(), header.Width, header.Height, pitch, true, true); - break; - case 32: // thx to Reinhard Ostermeier - image = new CImage(ECF_A8R8G8B8, core::dimension2d(header.Width, header.Height)); - if (image) - CColorConverter::convert32BitTo32Bit((s32*)BmpData, (s32*)image->lock(), header.Width, header.Height, pitch, true); - break; - }; - if (image) - image->unlock(); - - // clean up - - delete [] PaletteData; - PaletteData = 0; - - delete [] BmpData; - BmpData = 0; - - return image; -} - - - -//! creates a loader which is able to load windows bitmaps -IImageLoader* createImageLoaderBMP() -{ - return new CImageLoaderBMP; -} - - -} // end namespace video -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CImageLoaderBMP.h" +#include "SColor.h" +#include "CColorConverter.h" +#include "CImage.h" +#include "os.h" +#include "irrString.h" + +namespace irr +{ +namespace video +{ + + +//! constructor +CImageLoaderBMP::CImageLoaderBMP() +: BmpData(0), PaletteData(0) +{ + #ifdef _DEBUG + setDebugName("CImageLoaderBMP"); + #endif +} + + + +//! destructor +CImageLoaderBMP::~CImageLoaderBMP() +{ + if (PaletteData) + delete [] PaletteData; + + if (BmpData) + delete [] BmpData; +} + + + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".tga") +bool CImageLoaderBMP::isALoadableFileExtension(const c8* fileName) +{ + return strstr(fileName, ".bmp") != 0; +} + + + +//! returns true if the file maybe is able to be loaded by this class +bool CImageLoaderBMP::isALoadableFileFormat(irr::io::IReadFile* file) +{ + u16 headerID; + file->read(&headerID, sizeof(u16)); +#ifdef __BIG_ENDIAN__ + headerID = os::Byteswap::byteswap(headerID); +#endif + return headerID == 0x4d42; +} + + +void CImageLoaderBMP::decompress8BitRLE(u8*& BmpData, s32 size, s32 width, s32 height, s32 pitch) +{ + u8* p = BmpData; + u8* newBmp = new u8[(width+pitch)*height]; + u8* d = newBmp; + u8* destEnd = newBmp + (width+pitch)*height; + s32 line = 0; + + while (BmpData - p < size && d < destEnd) + { + if (*p == 0) + { + ++p; + + switch(*p) + { + case 0: // end of line + ++p; + ++line; + d = newBmp + (line*(width+pitch)); + break; + case 1: // end of bmp + delete [] BmpData; + BmpData = newBmp; + return; + case 2: + ++p; d +=(u8)*p; // delta + ++p; d += ((u8)*p)*(width+pitch); + ++p; + break; + default: + { + // absolute mode + s32 count = (u8)*p; ++p; + s32 readAdditional = ((2-(count%2))%2); + s32 i; + + for (i=0; i> readShift) & 0x0f; + readShift -= 4; + if (readShift < 0) + { + ++*p; + readShift = 4; + } + + u8 mask = 0x0f << shift; + *d = (*d & (~mask)) | ((color << shift) & mask); + + shift -= 4; + if (shift < 0) + { + shift = 4; + ++d; + } + + } + + for (i=0; i> 4) & 0x0f; + ++p; + + for (s32 i=0; iread(&header, sizeof(header)); + +#ifdef __BIG_ENDIAN__ + header.Id = os::Byteswap::byteswap(header.Id); + header.FileSize = os::Byteswap::byteswap(header.FileSize); + header.BitmapDataOffset = os::Byteswap::byteswap(header.BitmapDataOffset); + header.BitmapHeaderSize = os::Byteswap::byteswap(header.BitmapHeaderSize); + header.Width = os::Byteswap::byteswap(header.Width); + header.Height = os::Byteswap::byteswap(header.Height); + header.Planes = os::Byteswap::byteswap(header.Planes); + header.BPP = os::Byteswap::byteswap(header.BPP); + header.Compression = os::Byteswap::byteswap(header.Compression); + header.BitmapDataSize = os::Byteswap::byteswap(header.BitmapDataSize); + header.PixelPerMeterX = os::Byteswap::byteswap(header.PixelPerMeterX); + header.PixelPerMeterY = os::Byteswap::byteswap(header.PixelPerMeterY); + header.Colors = os::Byteswap::byteswap(header.Colors); + header.ImportantColors = os::Byteswap::byteswap(header.ImportantColors); +#endif + + s32 pitch = 0; + + //! return if the header is false + + if (header.Id != 0x4d42) + return 0; + + if (header.Compression > 2) // we'll only handle RLE-Compression + { + os::Printer::log("Compression mode not supported.", ELL_ERROR); + return 0; + } + + // adjust bitmap data size to dword boundary + header.BitmapDataSize += (4-(header.BitmapDataSize%4))%4; + + // read palette + + s32 pos = file->getPos(); + s32 paletteSize = (header.BitmapDataOffset - pos) / 4; + + if (paletteSize) + { + PaletteData = new s32[paletteSize]; + file->read(PaletteData, paletteSize * sizeof(s32)); +#ifdef __BIG_ENDIAN__ + for (int i=0; igetSize() - header.BitmapDataOffset; + } + + file->seek(header.BitmapDataOffset); + + f32 t = (header.Width) * (header.BPP / 8.0f); + s32 widthInBytes = (s32)t; + t -= widthInBytes; + if (t!=0.0f) + ++widthInBytes; + + s32 lineData = widthInBytes + ((4-(widthInBytes%4)))%4; + pitch = lineData - widthInBytes; + + BmpData = new u8[header.BitmapDataSize]; + file->read(BmpData, header.BitmapDataSize); + + // decompress data if needed + switch(header.Compression) + { + case 1: // 8 bit rle + decompress8BitRLE(BmpData, header.BitmapDataSize, header.Width, header.Height, pitch); + break; + case 2: // 4 bit rle + decompress4BitRLE(BmpData, header.BitmapDataSize, header.Width, header.Height, pitch); + break; + } + + // create surface + + IImage* image = 0; + switch(header.BPP) + { + case 1: + image = new CImage(ECF_A1R5G5B5, core::dimension2d(header.Width, header.Height)); + if (image) + CColorConverter::convert1BitTo16Bit(BmpData, (s16*)image->lock(), header.Width, header.Height, pitch, true); + break; + case 4: + image = new CImage(ECF_A1R5G5B5, core::dimension2d(header.Width, header.Height)); + if (image) + CColorConverter::convert4BitTo16Bit(BmpData, (s16*)image->lock(), header.Width, header.Height, PaletteData, pitch, true); + break; + case 8: + image = new CImage(ECF_A1R5G5B5, core::dimension2d(header.Width, header.Height)); + if (image) + CColorConverter::convert8BitTo16Bit(BmpData, (s16*)image->lock(), header.Width, header.Height, PaletteData, pitch, true); + break; + case 16: + image = new CImage(ECF_A1R5G5B5, core::dimension2d(header.Width, header.Height)); + if (image) + CColorConverter::convert16BitTo16Bit((s16*)BmpData, (s16*)image->lock(), header.Width, header.Height, pitch, true); + break; + case 24: + image = new CImage(ECF_R8G8B8, core::dimension2d(header.Width, header.Height)); + if (image) + CColorConverter::convert24BitTo24Bit(BmpData, (u8*)image->lock(), header.Width, header.Height, pitch, true, true); + break; + case 32: // thx to Reinhard Ostermeier + image = new CImage(ECF_A8R8G8B8, core::dimension2d(header.Width, header.Height)); + if (image) + CColorConverter::convert32BitTo32Bit((s32*)BmpData, (s32*)image->lock(), header.Width, header.Height, pitch, true); + break; + }; + if (image) + image->unlock(); + + // clean up + + delete [] PaletteData; + PaletteData = 0; + + delete [] BmpData; + BmpData = 0; + + return image; +} + + + +//! creates a loader which is able to load windows bitmaps +IImageLoader* createImageLoaderBMP() +{ + return new CImageLoaderBMP; +} + + +} // end namespace video +} // end namespace irr diff --git a/src/dep/src/irrlicht/CImageLoaderBMP.h b/src/dep/src/irrlicht/CImageLoaderBMP.h index 26d2615..13628e6 100644 --- a/src/dep/src/irrlicht/CImageLoaderBMP.h +++ b/src/dep/src/irrlicht/CImageLoaderBMP.h @@ -1,112 +1,112 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IMAGE_LOADER_BMP_H_INCLUDED__ -#define __C_IMAGE_LOADER_BMP_H_INCLUDED__ - -#include "IImageLoader.h" - - -namespace irr -{ -namespace video -{ - - - // byte-align structures -#ifdef _MSC_VER -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - struct SBMPHeader - { - u16 Id; // BM - Windows 3.1x, 95, NT, 98, 2000, ME, XP - // BA - OS/2 Bitmap Array - // CI - OS/2 Color Icon - // CP - OS/2 Color Pointer - // IC - OS/2 Icon - // PT - OS/2 Pointer - u32 FileSize; - u32 Reserved; - u32 BitmapDataOffset; - u32 BitmapHeaderSize; // should be 28h for windows bitmaps or - // 0Ch for OS/2 1.x or F0h for OS/2 2.x - u32 Width; - u32 Height; - u16 Planes; - u16 BPP; // 1: Monochrome bitmap - // 4: 16 color bitmap - // 8: 256 color bitmap - // 16: 16bit (high color) bitmap - // 24: 24bit (true color) bitmap - // 32: 32bit (true color) bitmap - - u32 Compression; // 0: none (Also identified by BI_RGB) - // 1: RLE 8-bit / pixel (Also identified by BI_RLE4) - // 2: RLE 4-bit / pixel (Also identified by BI_RLE8) - // 3: Bitfields (Also identified by BI_BITFIELDS) - - u32 BitmapDataSize; // Size of the bitmap data in bytes. This number must be rounded to the next 4 byte boundary. - u32 PixelPerMeterX; - u32 PixelPerMeterY; - u32 Colors; - u32 ImportantColors; - } PACK_STRUCT; - - -// Default alignment -#ifdef _MSC_VER -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - - -/*! - Surface Loader for Windows bitmaps -*/ -class CImageLoaderBMP : public IImageLoader -{ -public: - - //! constructor - CImageLoaderBMP(); - - //! destructor - virtual ~CImageLoaderBMP(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".tga") - virtual bool isALoadableFileExtension(const c8* fileName); - - //! returns true if the file maybe is able to be loaded by this class - virtual bool isALoadableFileFormat(irr::io::IReadFile* file); - - //! creates a surface from the file - virtual IImage* loadImage(irr::io::IReadFile* file); - -private: - - void decompress8BitRLE(u8*& BmpData, s32 size, s32 width, s32 height, s32 pitch); - - void decompress4BitRLE(u8*& BmpData, s32 size, s32 width, s32 height, s32 pitch); - - u8* BmpData; - s32* PaletteData; - -}; - - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_IMAGE_LOADER_BMP_H_INCLUDED__ +#define __C_IMAGE_LOADER_BMP_H_INCLUDED__ + +#include "IImageLoader.h" + + +namespace irr +{ +namespace video +{ + + + // byte-align structures +#ifdef _MSC_VER +# pragma pack( push, packing ) +# pragma pack( 1 ) +# define PACK_STRUCT +#elif defined( __GNUC__ ) +# define PACK_STRUCT __attribute__((packed)) +#else +# error compiler not supported +#endif + + struct SBMPHeader + { + u16 Id; // BM - Windows 3.1x, 95, NT, 98, 2000, ME, XP + // BA - OS/2 Bitmap Array + // CI - OS/2 Color Icon + // CP - OS/2 Color Pointer + // IC - OS/2 Icon + // PT - OS/2 Pointer + u32 FileSize; + u32 Reserved; + u32 BitmapDataOffset; + u32 BitmapHeaderSize; // should be 28h for windows bitmaps or + // 0Ch for OS/2 1.x or F0h for OS/2 2.x + u32 Width; + u32 Height; + u16 Planes; + u16 BPP; // 1: Monochrome bitmap + // 4: 16 color bitmap + // 8: 256 color bitmap + // 16: 16bit (high color) bitmap + // 24: 24bit (true color) bitmap + // 32: 32bit (true color) bitmap + + u32 Compression; // 0: none (Also identified by BI_RGB) + // 1: RLE 8-bit / pixel (Also identified by BI_RLE4) + // 2: RLE 4-bit / pixel (Also identified by BI_RLE8) + // 3: Bitfields (Also identified by BI_BITFIELDS) + + u32 BitmapDataSize; // Size of the bitmap data in bytes. This number must be rounded to the next 4 byte boundary. + u32 PixelPerMeterX; + u32 PixelPerMeterY; + u32 Colors; + u32 ImportantColors; + } PACK_STRUCT; + + +// Default alignment +#ifdef _MSC_VER +# pragma pack( pop, packing ) +#endif + +#undef PACK_STRUCT + + +/*! + Surface Loader for Windows bitmaps +*/ +class CImageLoaderBMP : public IImageLoader +{ +public: + + //! constructor + CImageLoaderBMP(); + + //! destructor + virtual ~CImageLoaderBMP(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".tga") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! returns true if the file maybe is able to be loaded by this class + virtual bool isALoadableFileFormat(irr::io::IReadFile* file); + + //! creates a surface from the file + virtual IImage* loadImage(irr::io::IReadFile* file); + +private: + + void decompress8BitRLE(u8*& BmpData, s32 size, s32 width, s32 height, s32 pitch); + + void decompress4BitRLE(u8*& BmpData, s32 size, s32 width, s32 height, s32 pitch); + + u8* BmpData; + s32* PaletteData; + +}; + + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CImageLoaderJPG.cpp b/src/dep/src/irrlicht/CImageLoaderJPG.cpp index cfab575..6664eff 100644 --- a/src/dep/src/irrlicht/CImageLoaderJPG.cpp +++ b/src/dep/src/irrlicht/CImageLoaderJPG.cpp @@ -1,254 +1,254 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageLoaderJPG.h" -#include "CImage.h" -#include "os.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -//! constructor -CImageLoaderJPG::CImageLoaderJPG() -{ - #ifdef _DEBUG - setDebugName("CImageLoaderJPG"); - #endif -} - - - -//! destructor -CImageLoaderJPG::~CImageLoaderJPG() -{ -} - - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".tga") -bool CImageLoaderJPG::isALoadableFileExtension(const c8* fileName) -{ - return strstr(fileName, ".jpg") != 0; -} - - -#ifdef _IRR_COMPILE_WITH_LIBJPEG_ - - // struct for handling jpeg errors - struct irr_jpeg_error_mgr - { - // public jpeg error fields - struct jpeg_error_mgr pub; - - // for longjmp, to return to caller on a fatal error - jmp_buf setjmp_buffer; - }; - -void CImageLoaderJPG::init_source (j_decompress_ptr cinfo) -{ - // DO NOTHING -} - - - -boolean CImageLoaderJPG::fill_input_buffer (j_decompress_ptr cinfo) -{ - // DO NOTHING - return 1; -} - - - -void CImageLoaderJPG::skip_input_data (j_decompress_ptr cinfo, long count) -{ - jpeg_source_mgr * src = cinfo->src; - if(count > 0) - { - src->bytes_in_buffer -= count; - src->next_input_byte += count; - } -} - - - -void CImageLoaderJPG::term_source (j_decompress_ptr cinfo) -{ - // DO NOTHING -} - - -void CImageLoaderJPG::error_exit (j_common_ptr cinfo) -{ - // unfortunately we need to use a goto rather than throwing an exception - // as gcc crashes under linux crashes when using throw from within - // extern c code - - // Always display the message - (*cinfo->err->output_message) (cinfo); - - // cinfo->err really points to a irr_error_mgr struct - irr_jpeg_error_mgr *myerr = (irr_jpeg_error_mgr*) cinfo->err; - - longjmp(myerr->setjmp_buffer, 1); -} - - -void CImageLoaderJPG::output_message(j_common_ptr cinfo) -{ - // display the error message. - c8 temp1[JMSG_LENGTH_MAX]; - (*cinfo->err->format_message)(cinfo, temp1); - os::Printer::log("JPEG FATAL ERROR",temp1, ELL_ERROR); -} -#endif // _IRR_COMPILE_WITH_LIBJPEG_ - -//! returns true if the file maybe is able to be loaded by this class -bool CImageLoaderJPG::isALoadableFileFormat(irr::io::IReadFile* file) -{ - #ifndef _IRR_COMPILE_WITH_LIBJPEG_ - return false; - #else - - if (!file) - return false; - - s32 jfif = 0; - file->seek(6); - file->read(&jfif, sizeof(s32)); - return (jfif == 0x4a464946 || jfif == 0x4649464a); - - #endif -} - -//! creates a surface from the file -IImage* CImageLoaderJPG::loadImage(irr::io::IReadFile* file) -{ - #ifndef _IRR_COMPILE_WITH_LIBJPEG_ - return 0; - #else - - u8 **rowPtr=0; - u8* input = new u8[file->getSize()]; - file->read(input, file->getSize()); - - // allocate and initialize JPEG decompression object - struct jpeg_decompress_struct cinfo; - struct irr_jpeg_error_mgr jerr; - - //We have to set up the error handler first, in case the initialization - //step fails. (Unlikely, but it could happen if you are out of memory.) - //This routine fills in the contents of struct jerr, and returns jerr's - //address which we place into the link field in cinfo. - - cinfo.err = jpeg_std_error(&jerr.pub); - cinfo.err->error_exit = error_exit; - cinfo.err->output_message = output_message; - - // compatibility fudge: - // we need to use setjmp/longjmp for error handling as gcc-linux - // crashes when throwing within external c code - if (setjmp(jerr.setjmp_buffer)) - { - // If we get here, the JPEG code has signaled an error. - // We need to clean up the JPEG object and return. - - jpeg_destroy_decompress(&cinfo); - - delete [] input; - // if the row pointer was created, we delete it. - if (rowPtr) - delete [] rowPtr; - - // return null pointer - return 0; - } - - // Now we can initialize the JPEG decompression object. - jpeg_create_decompress(&cinfo); - - // specify data source - jpeg_source_mgr jsrc; - - // Set up data pointer - jsrc.bytes_in_buffer = file->getSize(); - jsrc.next_input_byte = (JOCTET*)input; - cinfo.src = &jsrc; - - jsrc.init_source = init_source; - jsrc.fill_input_buffer = fill_input_buffer; - jsrc.skip_input_data = skip_input_data; - jsrc.resync_to_restart = jpeg_resync_to_restart; - jsrc.term_source = term_source; - - // Decodes JPG input from whatever source - // Does everything AFTER jpeg_create_decompress - // and BEFORE jpeg_destroy_decompress - // Caller is responsible for arranging these + setting up cinfo - - // read file parameters with jpeg_read_header() - jpeg_read_header(&cinfo, TRUE); - - cinfo.out_color_space=JCS_RGB; - cinfo.out_color_components=3; - cinfo.do_fancy_upsampling=FALSE; - - // Start decompressor - jpeg_start_decompress(&cinfo); - - // Get image data - u16 rowspan = cinfo.image_width * cinfo.out_color_components; - u32 width = cinfo.image_width; - u32 height = cinfo.image_height; - - // Allocate memory for buffer - u8* output = new u8[rowspan * height]; - - // Here we use the library's state variable cinfo.output_scanline as the - // loop counter, so that we don't have to keep track ourselves. - // Create array of row pointers for lib - rowPtr = new u8* [height]; - - for( u32 i = 0; i < height; i++ ) - rowPtr[i] = &output[ i * rowspan ]; - - u32 rowsRead = 0; - - while( cinfo.output_scanline < cinfo.output_height ) - rowsRead += jpeg_read_scanlines( &cinfo, &rowPtr[rowsRead], cinfo.output_height - rowsRead ); - - delete [] rowPtr; - // Finish decompression - - jpeg_finish_decompress(&cinfo); - - // Release JPEG decompression object - // This is an important step since it will release a good deal of memory. - jpeg_destroy_decompress(&cinfo); - - // convert image - IImage* image = new CImage(ECF_R8G8B8, - core::dimension2d(width, height), output); - - delete [] input; - - return image; - - #endif -} - - - -//! creates a loader which is able to load jpeg images -IImageLoader* createImageLoaderJPG() -{ - return new CImageLoaderJPG(); -} - -} // end namespace video -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CImageLoaderJPG.h" +#include "CImage.h" +#include "os.h" +#include "irrString.h" + +namespace irr +{ +namespace video +{ + +//! constructor +CImageLoaderJPG::CImageLoaderJPG() +{ + #ifdef _DEBUG + setDebugName("CImageLoaderJPG"); + #endif +} + + + +//! destructor +CImageLoaderJPG::~CImageLoaderJPG() +{ +} + + + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".tga") +bool CImageLoaderJPG::isALoadableFileExtension(const c8* fileName) +{ + return strstr(fileName, ".jpg") != 0; +} + + +#ifdef _IRR_COMPILE_WITH_LIBJPEG_ + + // struct for handling jpeg errors + struct irr_jpeg_error_mgr + { + // public jpeg error fields + struct jpeg_error_mgr pub; + + // for longjmp, to return to caller on a fatal error + jmp_buf setjmp_buffer; + }; + +void CImageLoaderJPG::init_source (j_decompress_ptr cinfo) +{ + // DO NOTHING +} + + + +boolean CImageLoaderJPG::fill_input_buffer (j_decompress_ptr cinfo) +{ + // DO NOTHING + return 1; +} + + + +void CImageLoaderJPG::skip_input_data (j_decompress_ptr cinfo, long count) +{ + jpeg_source_mgr * src = cinfo->src; + if(count > 0) + { + src->bytes_in_buffer -= count; + src->next_input_byte += count; + } +} + + + +void CImageLoaderJPG::term_source (j_decompress_ptr cinfo) +{ + // DO NOTHING +} + + +void CImageLoaderJPG::error_exit (j_common_ptr cinfo) +{ + // unfortunately we need to use a goto rather than throwing an exception + // as gcc crashes under linux crashes when using throw from within + // extern c code + + // Always display the message + (*cinfo->err->output_message) (cinfo); + + // cinfo->err really points to a irr_error_mgr struct + irr_jpeg_error_mgr *myerr = (irr_jpeg_error_mgr*) cinfo->err; + + longjmp(myerr->setjmp_buffer, 1); +} + + +void CImageLoaderJPG::output_message(j_common_ptr cinfo) +{ + // display the error message. + c8 temp1[JMSG_LENGTH_MAX]; + (*cinfo->err->format_message)(cinfo, temp1); + os::Printer::log("JPEG FATAL ERROR",temp1, ELL_ERROR); +} +#endif // _IRR_COMPILE_WITH_LIBJPEG_ + +//! returns true if the file maybe is able to be loaded by this class +bool CImageLoaderJPG::isALoadableFileFormat(irr::io::IReadFile* file) +{ + #ifndef _IRR_COMPILE_WITH_LIBJPEG_ + return false; + #else + + if (!file) + return false; + + s32 jfif = 0; + file->seek(6); + file->read(&jfif, sizeof(s32)); + return (jfif == 0x4a464946 || jfif == 0x4649464a); + + #endif +} + +//! creates a surface from the file +IImage* CImageLoaderJPG::loadImage(irr::io::IReadFile* file) +{ + #ifndef _IRR_COMPILE_WITH_LIBJPEG_ + return 0; + #else + + u8 **rowPtr=0; + u8* input = new u8[file->getSize()]; + file->read(input, file->getSize()); + + // allocate and initialize JPEG decompression object + struct jpeg_decompress_struct cinfo; + struct irr_jpeg_error_mgr jerr; + + //We have to set up the error handler first, in case the initialization + //step fails. (Unlikely, but it could happen if you are out of memory.) + //This routine fills in the contents of struct jerr, and returns jerr's + //address which we place into the link field in cinfo. + + cinfo.err = jpeg_std_error(&jerr.pub); + cinfo.err->error_exit = error_exit; + cinfo.err->output_message = output_message; + + // compatibility fudge: + // we need to use setjmp/longjmp for error handling as gcc-linux + // crashes when throwing within external c code + if (setjmp(jerr.setjmp_buffer)) + { + // If we get here, the JPEG code has signaled an error. + // We need to clean up the JPEG object and return. + + jpeg_destroy_decompress(&cinfo); + + delete [] input; + // if the row pointer was created, we delete it. + if (rowPtr) + delete [] rowPtr; + + // return null pointer + return 0; + } + + // Now we can initialize the JPEG decompression object. + jpeg_create_decompress(&cinfo); + + // specify data source + jpeg_source_mgr jsrc; + + // Set up data pointer + jsrc.bytes_in_buffer = file->getSize(); + jsrc.next_input_byte = (JOCTET*)input; + cinfo.src = &jsrc; + + jsrc.init_source = init_source; + jsrc.fill_input_buffer = fill_input_buffer; + jsrc.skip_input_data = skip_input_data; + jsrc.resync_to_restart = jpeg_resync_to_restart; + jsrc.term_source = term_source; + + // Decodes JPG input from whatever source + // Does everything AFTER jpeg_create_decompress + // and BEFORE jpeg_destroy_decompress + // Caller is responsible for arranging these + setting up cinfo + + // read file parameters with jpeg_read_header() + jpeg_read_header(&cinfo, TRUE); + + cinfo.out_color_space=JCS_RGB; + cinfo.out_color_components=3; + cinfo.do_fancy_upsampling=FALSE; + + // Start decompressor + jpeg_start_decompress(&cinfo); + + // Get image data + u16 rowspan = cinfo.image_width * cinfo.out_color_components; + u32 width = cinfo.image_width; + u32 height = cinfo.image_height; + + // Allocate memory for buffer + u8* output = new u8[rowspan * height]; + + // Here we use the library's state variable cinfo.output_scanline as the + // loop counter, so that we don't have to keep track ourselves. + // Create array of row pointers for lib + rowPtr = new u8* [height]; + + for( u32 i = 0; i < height; i++ ) + rowPtr[i] = &output[ i * rowspan ]; + + u32 rowsRead = 0; + + while( cinfo.output_scanline < cinfo.output_height ) + rowsRead += jpeg_read_scanlines( &cinfo, &rowPtr[rowsRead], cinfo.output_height - rowsRead ); + + delete [] rowPtr; + // Finish decompression + + jpeg_finish_decompress(&cinfo); + + // Release JPEG decompression object + // This is an important step since it will release a good deal of memory. + jpeg_destroy_decompress(&cinfo); + + // convert image + IImage* image = new CImage(ECF_R8G8B8, + core::dimension2d(width, height), output); + + delete [] input; + + return image; + + #endif +} + + + +//! creates a loader which is able to load jpeg images +IImageLoader* createImageLoaderJPG() +{ + return new CImageLoaderJPG(); +} + +} // end namespace video +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CImageLoaderJPG.h b/src/dep/src/irrlicht/CImageLoaderJPG.h index 24f043a..d04fa91 100644 --- a/src/dep/src/irrlicht/CImageLoaderJPG.h +++ b/src/dep/src/irrlicht/CImageLoaderJPG.h @@ -1,110 +1,110 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IMAGE_LOADER_JPG_H_INCLUDED__ -#define __C_IMAGE_LOADER_JPG_H_INCLUDED__ - -#include "IImageLoader.h" - - -#include "IrrCompileConfig.h" -#include // required for jpeglib.h -#ifdef _IRR_COMPILE_WITH_LIBJPEG_ -extern "C" { - #ifndef _IRR_USE_NON_SYSTEM_JPEG_LIB_ - #include // use system lib - #else - #include "jpeglib/jpeglib.h" // use irrlicht jpeglib - #endif - #include -} -#endif // _IRR_COMPILE_WITH_LIBJPEG_ - - -namespace irr -{ -namespace video -{ - - -//! Surface Loader for JPG images -class CImageLoaderJPG : public IImageLoader -{ -public: - - //! constructor - CImageLoaderJPG(); - - //! destructor - virtual ~CImageLoaderJPG(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".tga") - virtual bool isALoadableFileExtension(const c8* fileName); - - //! returns true if the file maybe is able to be loaded by this class - virtual bool isALoadableFileFormat(irr::io::IReadFile* file); - - //! creates a surface from the file - virtual IImage* loadImage(irr::io::IReadFile* file); - -private: - - #ifdef _IRR_COMPILE_WITH_LIBJPEG_ - // several methods used via function pointers by jpeglib - - /* Receives control for a fatal error. Information sufficient to - generate the error message has been stored in cinfo->err; call - output_message to display it. Control must NOT return to the caller; - generally this routine will exit() or longjmp() somewhere. - Typically you would override this routine to get rid of the exit() - default behavior. Note that if you continue processing, you should - clean up the JPEG object with jpeg_abort() or jpeg_destroy(). - */ - static void error_exit (j_common_ptr cinfo); - - /* output error messages via Irrlicht logger. */ - static void output_message(j_common_ptr cinfo); - - /* Initialize source. This is called by jpeg_read_header() before any - data is actually read. Unlike init_destination(), it may leave - bytes_in_buffer set to 0 (in which case a fill_input_buffer() call - will occur immediately). */ - static void init_source (j_decompress_ptr cinfo); - - /* This is called whenever bytes_in_buffer has reached zero and more - data is wanted. In typical applications, it should read fresh data - into the buffer (ignoring the current state of next_input_byte and - bytes_in_buffer), reset the pointer & count to the start of the - buffer, and return TRUE indicating that the buffer has been reloaded. - It is not necessary to fill the buffer entirely, only to obtain at - least one more byte. bytes_in_buffer MUST be set to a positive value - if TRUE is returned. A FALSE return should only be used when I/O - suspension is desired (this mode is discussed in the next section). */ - static boolean fill_input_buffer (j_decompress_ptr cinfo); - - /* Skip num_bytes worth of data. The buffer pointer and count should - be advanced over num_bytes input bytes, refilling the buffer as - needed. This is used to skip over a potentially large amount of - uninteresting data (such as an APPn marker). In some applications - it may be possible to optimize away the reading of the skipped data, - but it's not clear that being smart is worth much trouble; large - skips are uncommon. bytes_in_buffer may be zero on return. - A zero or negative skip count should be treated as a no-op. */ - static void skip_input_data (j_decompress_ptr cinfo, long num_bytes); - - /* Terminate source --- called by jpeg_finish_decompress() after all - data has been read. Often a no-op. */ - static void term_source (j_decompress_ptr cinfo); - - #endif // _IRR_COMPILE_WITH_LIBJPEG_ -}; - - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_IMAGE_LOADER_JPG_H_INCLUDED__ +#define __C_IMAGE_LOADER_JPG_H_INCLUDED__ + +#include "IImageLoader.h" + + +#include "IrrCompileConfig.h" +#include // required for jpeglib.h +#ifdef _IRR_COMPILE_WITH_LIBJPEG_ +extern "C" { + #ifndef _IRR_USE_NON_SYSTEM_JPEG_LIB_ + #include // use system lib + #else + #include "jpeglib/jpeglib.h" // use irrlicht jpeglib + #endif + #include +} +#endif // _IRR_COMPILE_WITH_LIBJPEG_ + + +namespace irr +{ +namespace video +{ + + +//! Surface Loader for JPG images +class CImageLoaderJPG : public IImageLoader +{ +public: + + //! constructor + CImageLoaderJPG(); + + //! destructor + virtual ~CImageLoaderJPG(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".tga") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! returns true if the file maybe is able to be loaded by this class + virtual bool isALoadableFileFormat(irr::io::IReadFile* file); + + //! creates a surface from the file + virtual IImage* loadImage(irr::io::IReadFile* file); + +private: + + #ifdef _IRR_COMPILE_WITH_LIBJPEG_ + // several methods used via function pointers by jpeglib + + /* Receives control for a fatal error. Information sufficient to + generate the error message has been stored in cinfo->err; call + output_message to display it. Control must NOT return to the caller; + generally this routine will exit() or longjmp() somewhere. + Typically you would override this routine to get rid of the exit() + default behavior. Note that if you continue processing, you should + clean up the JPEG object with jpeg_abort() or jpeg_destroy(). + */ + static void error_exit (j_common_ptr cinfo); + + /* output error messages via Irrlicht logger. */ + static void output_message(j_common_ptr cinfo); + + /* Initialize source. This is called by jpeg_read_header() before any + data is actually read. Unlike init_destination(), it may leave + bytes_in_buffer set to 0 (in which case a fill_input_buffer() call + will occur immediately). */ + static void init_source (j_decompress_ptr cinfo); + + /* This is called whenever bytes_in_buffer has reached zero and more + data is wanted. In typical applications, it should read fresh data + into the buffer (ignoring the current state of next_input_byte and + bytes_in_buffer), reset the pointer & count to the start of the + buffer, and return TRUE indicating that the buffer has been reloaded. + It is not necessary to fill the buffer entirely, only to obtain at + least one more byte. bytes_in_buffer MUST be set to a positive value + if TRUE is returned. A FALSE return should only be used when I/O + suspension is desired (this mode is discussed in the next section). */ + static boolean fill_input_buffer (j_decompress_ptr cinfo); + + /* Skip num_bytes worth of data. The buffer pointer and count should + be advanced over num_bytes input bytes, refilling the buffer as + needed. This is used to skip over a potentially large amount of + uninteresting data (such as an APPn marker). In some applications + it may be possible to optimize away the reading of the skipped data, + but it's not clear that being smart is worth much trouble; large + skips are uncommon. bytes_in_buffer may be zero on return. + A zero or negative skip count should be treated as a no-op. */ + static void skip_input_data (j_decompress_ptr cinfo, long num_bytes); + + /* Terminate source --- called by jpeg_finish_decompress() after all + data has been read. Often a no-op. */ + static void term_source (j_decompress_ptr cinfo); + + #endif // _IRR_COMPILE_WITH_LIBJPEG_ +}; + + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CImageLoaderPCX.cpp b/src/dep/src/irrlicht/CImageLoaderPCX.cpp index fabc145..9c6e9b2 100644 --- a/src/dep/src/irrlicht/CImageLoaderPCX.cpp +++ b/src/dep/src/irrlicht/CImageLoaderPCX.cpp @@ -1,199 +1,199 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageLoaderPCX.h" -#include "SColor.h" -#include "CColorConverter.h" -#include "CImage.h" -#include "os.h" -#include "irrString.h" - - -namespace irr -{ -namespace video -{ - - -//! constructor -CImageLoaderPCX::CImageLoaderPCX() -: PCXData(0), PaletteData(0) -{ - #ifdef _DEBUG - setDebugName("CImageLoaderPCX"); - #endif -} - - - -//! destructor -CImageLoaderPCX::~CImageLoaderPCX() -{ - if (PaletteData) - delete [] PaletteData; - - if (PCXData) - delete [] PCXData; -} - - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".tga") -bool CImageLoaderPCX::isALoadableFileExtension(const c8* fileName) -{ - return (strstr(fileName, ".PCX") != 0) || (strstr(fileName, ".pcx") != 0); -} - - - -//! returns true if the file maybe is able to be loaded by this class -bool CImageLoaderPCX::isALoadableFileFormat(irr::io::IReadFile* file) -{ - u8 headerID; - file->read(&headerID, sizeof(headerID)); - return headerID == 0x0a; -} - - -//! creates a image from the file -IImage* CImageLoaderPCX::loadImage(irr::io::IReadFile* file) -{ - SPCXHeader header; - - file->read(&header, sizeof(header)); - #ifdef __BIG_ENDIAN__ - header.XMin = os::Byteswap::byteswap(header.XMin); - header.YMin = os::Byteswap::byteswap(header.YMin); - header.XMax = os::Byteswap::byteswap(header.XMax); - header.YMax = os::Byteswap::byteswap(header.YMax); - header.HorizDPI = os::Byteswap::byteswap(header.HorizDPI); - header.VertDPI = os::Byteswap::byteswap(header.VertDPI); - header.BytesPerLine = os::Byteswap::byteswap(header.BytesPerLine); - header.PaletteType = os::Byteswap::byteswap(header.PaletteType); - header.HScrSize = os::Byteswap::byteswap(header.HScrSize); - header.VScrSize = os::Byteswap::byteswap(header.VScrSize); - #endif - - //! return if the header is wrong - if (header.Manufacturer != 0x0a && header.Encoding != 0x01) - return 0; - - // return if this isn't a supported type - if( (header.BitsPerPixel != 8) && (header.BitsPerPixel != 24) ) - { - os::Printer::log("Unsupported bits per pixel in PCX file.", - file->getFileName(), irr::ELL_WARNING); - return 0; - } - - // read palette - if( header.BitsPerPixel == 8 ) - { - // the palette indicator (usually a 0x0c is found infront of the actual palette data) - // is ignored because some exporters seem to forget to write it. This would result in - // no image loaded before, now only wrong colors will be set. - s32 pos = file->getPos(); - file->seek( file->getSize()-256*3, false ); - - u8 *tempPalette = new u8[768]; - PaletteData = new s32[256]; - memset(PaletteData, 0, 256*sizeof(s32)); - file->read( tempPalette, 768 ); - - for( s32 i=0; i<256; i++ ) - { - PaletteData[i] = (tempPalette[i*3+0] << 16) | - (tempPalette[i*3+1] << 8) | - (tempPalette[i*3+2] ); - } - - delete [] tempPalette; - - file->seek( pos ); - } - else if( header.BitsPerPixel == 4 ) - { - PaletteData = new s32[16]; - memset(PaletteData, 0, 16*sizeof(s32)); - for( s32 i=0; i<256; i++ ) - { - PaletteData[i] = (header.Palette[i*3+0] << 16) | - (header.Palette[i*3+1] << 8) | - (header.Palette[i*3+2]); - } - } - - // read image data - s32 width, height, imagebytes; - width = header.XMax - header.XMin + 1; - height = header.YMax - header.YMin + 1; - imagebytes = header.BytesPerLine * height * header.Planes * header.BitsPerPixel / 8; - PCXData = new u8[imagebytes]; - - u8 cnt, value; - for( s32 offset = 0; offset < imagebytes; ) - { - file->read( &cnt, 1 ); - if( !((cnt & 0xc0) == 0xc0) ) - { - value = cnt; - cnt = 1; - } - else - { - cnt &= 0x3f; - file->read( &value, 1 ); - } - memset(PCXData+offset, value, cnt); - offset += cnt; - } - - // create image - video::IImage* image = 0; - s32 pitch = header.BytesPerLine - width * header.Planes * header.BitsPerPixel / 8; - - if (pitch < 0) - pitch = -pitch; - - switch(header.BitsPerPixel) // TODO: Other formats - { - case 8: - image = new CImage(ECF_A1R5G5B5, core::dimension2d(width, height)); - if (image) - CColorConverter::convert8BitTo16Bit(PCXData, (s16*)image->lock(), width, height, PaletteData, pitch); - break; - case 24: - image = new CImage(ECF_R8G8B8, core::dimension2d(width, height)); - if (image) - CColorConverter::convert24BitTo24Bit(PCXData, (u8*)image->lock(), width, height, pitch); - break; - }; - if (image) - image->unlock(); - - // clean up - - if( PaletteData ) - delete [] PaletteData; - PaletteData = 0; - - if( PCXData ) - delete [] PCXData; - PCXData = 0; - - return image; -} - - -//! creates a loader which is able to load pcx images -IImageLoader* createImageLoaderPCX() -{ - return new CImageLoaderPCX(); -} - - - -} // end namespace video -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CImageLoaderPCX.h" +#include "SColor.h" +#include "CColorConverter.h" +#include "CImage.h" +#include "os.h" +#include "irrString.h" + + +namespace irr +{ +namespace video +{ + + +//! constructor +CImageLoaderPCX::CImageLoaderPCX() +: PCXData(0), PaletteData(0) +{ + #ifdef _DEBUG + setDebugName("CImageLoaderPCX"); + #endif +} + + + +//! destructor +CImageLoaderPCX::~CImageLoaderPCX() +{ + if (PaletteData) + delete [] PaletteData; + + if (PCXData) + delete [] PCXData; +} + + + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".tga") +bool CImageLoaderPCX::isALoadableFileExtension(const c8* fileName) +{ + return (strstr(fileName, ".PCX") != 0) || (strstr(fileName, ".pcx") != 0); +} + + + +//! returns true if the file maybe is able to be loaded by this class +bool CImageLoaderPCX::isALoadableFileFormat(irr::io::IReadFile* file) +{ + u8 headerID; + file->read(&headerID, sizeof(headerID)); + return headerID == 0x0a; +} + + +//! creates a image from the file +IImage* CImageLoaderPCX::loadImage(irr::io::IReadFile* file) +{ + SPCXHeader header; + + file->read(&header, sizeof(header)); + #ifdef __BIG_ENDIAN__ + header.XMin = os::Byteswap::byteswap(header.XMin); + header.YMin = os::Byteswap::byteswap(header.YMin); + header.XMax = os::Byteswap::byteswap(header.XMax); + header.YMax = os::Byteswap::byteswap(header.YMax); + header.HorizDPI = os::Byteswap::byteswap(header.HorizDPI); + header.VertDPI = os::Byteswap::byteswap(header.VertDPI); + header.BytesPerLine = os::Byteswap::byteswap(header.BytesPerLine); + header.PaletteType = os::Byteswap::byteswap(header.PaletteType); + header.HScrSize = os::Byteswap::byteswap(header.HScrSize); + header.VScrSize = os::Byteswap::byteswap(header.VScrSize); + #endif + + //! return if the header is wrong + if (header.Manufacturer != 0x0a && header.Encoding != 0x01) + return 0; + + // return if this isn't a supported type + if( (header.BitsPerPixel != 8) && (header.BitsPerPixel != 24) ) + { + os::Printer::log("Unsupported bits per pixel in PCX file.", + file->getFileName(), irr::ELL_WARNING); + return 0; + } + + // read palette + if( header.BitsPerPixel == 8 ) + { + // the palette indicator (usually a 0x0c is found infront of the actual palette data) + // is ignored because some exporters seem to forget to write it. This would result in + // no image loaded before, now only wrong colors will be set. + s32 pos = file->getPos(); + file->seek( file->getSize()-256*3, false ); + + u8 *tempPalette = new u8[768]; + PaletteData = new s32[256]; + memset(PaletteData, 0, 256*sizeof(s32)); + file->read( tempPalette, 768 ); + + for( s32 i=0; i<256; i++ ) + { + PaletteData[i] = (tempPalette[i*3+0] << 16) | + (tempPalette[i*3+1] << 8) | + (tempPalette[i*3+2] ); + } + + delete [] tempPalette; + + file->seek( pos ); + } + else if( header.BitsPerPixel == 4 ) + { + PaletteData = new s32[16]; + memset(PaletteData, 0, 16*sizeof(s32)); + for( s32 i=0; i<256; i++ ) + { + PaletteData[i] = (header.Palette[i*3+0] << 16) | + (header.Palette[i*3+1] << 8) | + (header.Palette[i*3+2]); + } + } + + // read image data + s32 width, height, imagebytes; + width = header.XMax - header.XMin + 1; + height = header.YMax - header.YMin + 1; + imagebytes = header.BytesPerLine * height * header.Planes * header.BitsPerPixel / 8; + PCXData = new u8[imagebytes]; + + u8 cnt, value; + for( s32 offset = 0; offset < imagebytes; ) + { + file->read( &cnt, 1 ); + if( !((cnt & 0xc0) == 0xc0) ) + { + value = cnt; + cnt = 1; + } + else + { + cnt &= 0x3f; + file->read( &value, 1 ); + } + memset(PCXData+offset, value, cnt); + offset += cnt; + } + + // create image + video::IImage* image = 0; + s32 pitch = header.BytesPerLine - width * header.Planes * header.BitsPerPixel / 8; + + if (pitch < 0) + pitch = -pitch; + + switch(header.BitsPerPixel) // TODO: Other formats + { + case 8: + image = new CImage(ECF_A1R5G5B5, core::dimension2d(width, height)); + if (image) + CColorConverter::convert8BitTo16Bit(PCXData, (s16*)image->lock(), width, height, PaletteData, pitch); + break; + case 24: + image = new CImage(ECF_R8G8B8, core::dimension2d(width, height)); + if (image) + CColorConverter::convert24BitTo24Bit(PCXData, (u8*)image->lock(), width, height, pitch); + break; + }; + if (image) + image->unlock(); + + // clean up + + if( PaletteData ) + delete [] PaletteData; + PaletteData = 0; + + if( PCXData ) + delete [] PCXData; + PCXData = 0; + + return image; +} + + +//! creates a loader which is able to load pcx images +IImageLoader* createImageLoaderPCX() +{ + return new CImageLoaderPCX(); +} + + + +} // end namespace video +} // end namespace irr diff --git a/src/dep/src/irrlicht/CImageLoaderPCX.h b/src/dep/src/irrlicht/CImageLoaderPCX.h index 9f21de8..e72e4b5 100644 --- a/src/dep/src/irrlicht/CImageLoaderPCX.h +++ b/src/dep/src/irrlicht/CImageLoaderPCX.h @@ -1,95 +1,95 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IMAGE_LOADER_PCX_H_INCLUDED__ -#define __C_IMAGE_LOADER_PCX_H_INCLUDED__ - -#include "IImageLoader.h" - -namespace irr -{ -namespace video -{ - - -// byte-align structures -#ifdef _MSC_VER -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - struct SPCXHeader - { - u8 Manufacturer; - u8 Version; - u8 Encoding; - u8 BitsPerPixel; - u16 XMin; - u16 YMin; - u16 XMax; - u16 YMax; - u16 HorizDPI; - u16 VertDPI; - u8 Palette[48]; - u8 Reserved; - u8 Planes; - u16 BytesPerLine; - u16 PaletteType; - u16 HScrSize; - u16 VScrSize; - u8 Filler[54]; - } PACK_STRUCT; - - -// Default alignment -#ifdef _MSC_VER -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - - -/*! - Image Loader for Windows PCX bitmaps. - This loader was written and sent in by Dean P. Macri. I modified - only some small bits of it. -*/ -class CImageLoaderPCX : public IImageLoader -{ -public: - - //! constructor - CImageLoaderPCX(); - - //! destructor - virtual ~CImageLoaderPCX(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".tga") - virtual bool isALoadableFileExtension(const c8* fileName); - - //! returns true if the file maybe is able to be loaded by this class - virtual bool isALoadableFileFormat(irr::io::IReadFile* file); - - //! creates a surface from the file - virtual IImage* loadImage(irr::io::IReadFile* file); - -private: - - u8* PCXData; - s32* PaletteData; -}; - - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_IMAGE_LOADER_PCX_H_INCLUDED__ +#define __C_IMAGE_LOADER_PCX_H_INCLUDED__ + +#include "IImageLoader.h" + +namespace irr +{ +namespace video +{ + + +// byte-align structures +#ifdef _MSC_VER +# pragma pack( push, packing ) +# pragma pack( 1 ) +# define PACK_STRUCT +#elif defined( __GNUC__ ) +# define PACK_STRUCT __attribute__((packed)) +#else +# error compiler not supported +#endif + + struct SPCXHeader + { + u8 Manufacturer; + u8 Version; + u8 Encoding; + u8 BitsPerPixel; + u16 XMin; + u16 YMin; + u16 XMax; + u16 YMax; + u16 HorizDPI; + u16 VertDPI; + u8 Palette[48]; + u8 Reserved; + u8 Planes; + u16 BytesPerLine; + u16 PaletteType; + u16 HScrSize; + u16 VScrSize; + u8 Filler[54]; + } PACK_STRUCT; + + +// Default alignment +#ifdef _MSC_VER +# pragma pack( pop, packing ) +#endif + +#undef PACK_STRUCT + + +/*! + Image Loader for Windows PCX bitmaps. + This loader was written and sent in by Dean P. Macri. I modified + only some small bits of it. +*/ +class CImageLoaderPCX : public IImageLoader +{ +public: + + //! constructor + CImageLoaderPCX(); + + //! destructor + virtual ~CImageLoaderPCX(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".tga") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! returns true if the file maybe is able to be loaded by this class + virtual bool isALoadableFileFormat(irr::io::IReadFile* file); + + //! creates a surface from the file + virtual IImage* loadImage(irr::io::IReadFile* file); + +private: + + u8* PCXData; + s32* PaletteData; +}; + + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CImageLoaderPNG.cpp b/src/dep/src/irrlicht/CImageLoaderPNG.cpp index a2a2495..2ac6a9d 100644 --- a/src/dep/src/irrlicht/CImageLoaderPNG.cpp +++ b/src/dep/src/irrlicht/CImageLoaderPNG.cpp @@ -1,267 +1,267 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_LIBPNG_ - #ifndef _IRR_USE_NON_SYSTEM_LIB_PNG_ - #include // use system lib png - #else // _IRR_USE_NON_SYSTEM_LIB_PNG_ - #include "libpng/png.h" // use irrlicht included lib png - #endif // _IRR_USE_NON_SYSTEM_LIB_PNG_ -#endif // _IRR_COMPILE_WITH_LIBPNG_ - -#include "CImageLoaderPNG.h" -#include "CImage.h" -#include "CReadFile.h" -#include "os.h" - -namespace irr -{ -namespace video -{ - -#ifdef _IRR_COMPILE_WITH_LIBPNG_ -// PNG function for error handling -static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg) -{ - os::Printer::log("PNG FATAL ERROR", msg, ELL_ERROR); - longjmp(png_ptr->jmpbuf, 1); -} - -// PNG function for file reading -void PNGAPI user_read_data_fcn(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - // changed by zola { - irr::io::IReadFile* file=(irr::io::IReadFile*)png_ptr->io_ptr; - check=(png_size_t) file->read((void*)data,length); - // } - - if (check != length) - png_error(png_ptr, "Read Error"); -} -#endif // _IRR_COMPILE_WITH_LIBPNG_ - -CImageLoaderPng::CImageLoaderPng() -{ - // do something? -} - -CImageLoaderPng::~CImageLoaderPng() -{ - // do something? -} - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".tga") -bool CImageLoaderPng::isALoadableFileExtension(const c8* fileName) -{ -#ifdef _IRR_COMPILE_WITH_LIBPNG_ - // added fix for file extension check by jox - const c8* ext = strrchr(fileName, '.'); - if (ext == 0) - return false; - return (strcmp(ext, ".PNG") == 0) || (strcmp(ext, ".png") == 0); -#else - return false; -#endif // _IRR_COMPILE_WITH_LIBPNG_ -} - - -//! returns true if the file maybe is able to be loaded by this class -bool CImageLoaderPng::isALoadableFileFormat(irr::io::IReadFile* file) -{ -#ifdef _IRR_COMPILE_WITH_LIBPNG_ - if (!file) - return false; - - png_byte buffer[8]; - // Read the first few bytes of the PNG file - if (file->read(buffer, 8) != 8) - return false; - - // Check if it really is a PNG file - return !png_sig_cmp(buffer, 0, 8); -#else - return false; -#endif // _IRR_COMPILE_WITH_LIBPNG_ -} - - -// load in the image data -IImage* CImageLoaderPng::loadImage(irr::io::IReadFile* file) -{ -#ifdef _IRR_COMPILE_WITH_LIBPNG_ - if (!file) - return 0; - - Image = 0; - RowPointers = 0; - - png_byte buffer[8]; - // Read the first few bytes of the PNG file - if( file->read(buffer, 8) != 8 ) - { - os::Printer::log("LOAD PNG: can't read file\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // Check if it really is a PNG file - if( png_sig_cmp(buffer, 0, 8) ) - { - os::Printer::log("LOAD PNG: not really a png\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // Allocate the png read struct - png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, - NULL, (png_error_ptr)png_cpexcept_error, NULL); - if (!png_ptr) - { - os::Printer::log("LOAD PNG: Internal PNG create read struct failure\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // Allocate the png info struct - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - os::Printer::log("LOAD PNG: Internal PNG create info struct failure\n", file->getFileName(), ELL_ERROR); - png_destroy_read_struct(&png_ptr, NULL, NULL); - return 0; - } - - // for proper error handling - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - if (RowPointers) - delete [] RowPointers; - return 0; - } - - // changed by zola so we don't need to have public FILE pointers - png_set_read_fn(png_ptr, file, user_read_data_fcn); - - png_set_sig_bytes(png_ptr, 8); // Tell png that we read the signature - - png_read_info(png_ptr, info_ptr); // Read the info section of the png file - - // Extract info - png_get_IHDR(png_ptr, info_ptr, - (png_uint_32*)&Width, (png_uint_32*)&Height, - &BitDepth, &ColorType, NULL, NULL, NULL); - - // Convert palette color to true color - if (ColorType==PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - // Convert low bit colors to 8 bit colors - if (BitDepth < 8) - { - if (ColorType==PNG_COLOR_TYPE_GRAY || ColorType==PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_1_2_4_to_8(png_ptr); - else - png_set_packing(png_ptr); - } - - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_tRNS_to_alpha(png_ptr); - - // Convert high bit colors to 8 bit colors - if (BitDepth == 16) - png_set_strip_16(png_ptr); - - // Convert gray color to true color - if (ColorType==PNG_COLOR_TYPE_GRAY || ColorType==PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - - // Update the changes - png_read_update_info(png_ptr, info_ptr); - png_get_IHDR(png_ptr, info_ptr, - (png_uint_32*)&Width, (png_uint_32*)&Height, - &BitDepth, &ColorType, NULL, NULL, NULL); - - // Convert RGBA to BGRA - if (ColorType==PNG_COLOR_TYPE_RGB_ALPHA) - { -#ifdef __BIG_ENDIAN__ - png_set_swap_alpha(png_ptr); -#else - png_set_bgr(png_ptr); -#endif - } - - // Update the changes - png_get_IHDR(png_ptr, info_ptr, - (png_uint_32*)&Width, (png_uint_32*)&Height, - &BitDepth, &ColorType, NULL, NULL, NULL); - - // Create the image structure to be filled by png data - if (ColorType==PNG_COLOR_TYPE_RGB_ALPHA) - Image = new CImage(ECF_A8R8G8B8, core::dimension2d(Width, Height)); - else - Image = new CImage(ECF_R8G8B8, core::dimension2d(Width, Height)); - if (!Image) - { - os::Printer::log("LOAD PNG: Internal PNG create image struct failure\n", file->getFileName(), ELL_ERROR); - png_destroy_read_struct(&png_ptr, NULL, NULL); - return 0; - } - - // Create array of pointers to rows in image data - RowPointers = new png_bytep[Height]; - if (!RowPointers) - { - os::Printer::log("LOAD PNG: Internal PNG create row pointers failure\n", file->getFileName(), ELL_ERROR); - png_destroy_read_struct(&png_ptr, NULL, NULL); - delete Image; - return 0; - } - - // Fill array of pointers to rows in image data - unsigned char* data = (unsigned char*)Image->lock(); - for (u32 i=0; igetPitch(); - } - - // for proper error handling - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - delete [] RowPointers; - Image->unlock(); - delete [] Image; - return 0; - } - - // Read data using the library function that handles all transformations including interlacing - png_read_image(png_ptr, RowPointers); - - png_read_end(png_ptr, NULL); - delete [] RowPointers; - Image->unlock(); - png_destroy_read_struct(&png_ptr,&info_ptr, 0); // Clean up memory - - return Image; -#else - return 0; -#endif // _IRR_COMPILE_WITH_LIBPNG_ -} - - - -IImageLoader* createImageLoaderPNG() -{ - return new CImageLoaderPng(); -} - - -}// end namespace irr -}//end namespace video - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" + +#ifdef _IRR_COMPILE_WITH_LIBPNG_ + #ifndef _IRR_USE_NON_SYSTEM_LIB_PNG_ + #include // use system lib png + #else // _IRR_USE_NON_SYSTEM_LIB_PNG_ + #include "libpng/png.h" // use irrlicht included lib png + #endif // _IRR_USE_NON_SYSTEM_LIB_PNG_ +#endif // _IRR_COMPILE_WITH_LIBPNG_ + +#include "CImageLoaderPNG.h" +#include "CImage.h" +#include "CReadFile.h" +#include "os.h" + +namespace irr +{ +namespace video +{ + +#ifdef _IRR_COMPILE_WITH_LIBPNG_ +// PNG function for error handling +static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg) +{ + os::Printer::log("PNG FATAL ERROR", msg, ELL_ERROR); + longjmp(png_ptr->jmpbuf, 1); +} + +// PNG function for file reading +void PNGAPI user_read_data_fcn(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_size_t check; + + // changed by zola { + irr::io::IReadFile* file=(irr::io::IReadFile*)png_ptr->io_ptr; + check=(png_size_t) file->read((void*)data,length); + // } + + if (check != length) + png_error(png_ptr, "Read Error"); +} +#endif // _IRR_COMPILE_WITH_LIBPNG_ + +CImageLoaderPng::CImageLoaderPng() +{ + // do something? +} + +CImageLoaderPng::~CImageLoaderPng() +{ + // do something? +} + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".tga") +bool CImageLoaderPng::isALoadableFileExtension(const c8* fileName) +{ +#ifdef _IRR_COMPILE_WITH_LIBPNG_ + // added fix for file extension check by jox + const c8* ext = strrchr(fileName, '.'); + if (ext == 0) + return false; + return (strcmp(ext, ".PNG") == 0) || (strcmp(ext, ".png") == 0); +#else + return false; +#endif // _IRR_COMPILE_WITH_LIBPNG_ +} + + +//! returns true if the file maybe is able to be loaded by this class +bool CImageLoaderPng::isALoadableFileFormat(irr::io::IReadFile* file) +{ +#ifdef _IRR_COMPILE_WITH_LIBPNG_ + if (!file) + return false; + + png_byte buffer[8]; + // Read the first few bytes of the PNG file + if (file->read(buffer, 8) != 8) + return false; + + // Check if it really is a PNG file + return !png_sig_cmp(buffer, 0, 8); +#else + return false; +#endif // _IRR_COMPILE_WITH_LIBPNG_ +} + + +// load in the image data +IImage* CImageLoaderPng::loadImage(irr::io::IReadFile* file) +{ +#ifdef _IRR_COMPILE_WITH_LIBPNG_ + if (!file) + return 0; + + Image = 0; + RowPointers = 0; + + png_byte buffer[8]; + // Read the first few bytes of the PNG file + if( file->read(buffer, 8) != 8 ) + { + os::Printer::log("LOAD PNG: can't read file\n", file->getFileName(), ELL_ERROR); + return 0; + } + + // Check if it really is a PNG file + if( png_sig_cmp(buffer, 0, 8) ) + { + os::Printer::log("LOAD PNG: not really a png\n", file->getFileName(), ELL_ERROR); + return 0; + } + + // Allocate the png read struct + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, + NULL, (png_error_ptr)png_cpexcept_error, NULL); + if (!png_ptr) + { + os::Printer::log("LOAD PNG: Internal PNG create read struct failure\n", file->getFileName(), ELL_ERROR); + return 0; + } + + // Allocate the png info struct + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + os::Printer::log("LOAD PNG: Internal PNG create info struct failure\n", file->getFileName(), ELL_ERROR); + png_destroy_read_struct(&png_ptr, NULL, NULL); + return 0; + } + + // for proper error handling + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + if (RowPointers) + delete [] RowPointers; + return 0; + } + + // changed by zola so we don't need to have public FILE pointers + png_set_read_fn(png_ptr, file, user_read_data_fcn); + + png_set_sig_bytes(png_ptr, 8); // Tell png that we read the signature + + png_read_info(png_ptr, info_ptr); // Read the info section of the png file + + // Extract info + png_get_IHDR(png_ptr, info_ptr, + (png_uint_32*)&Width, (png_uint_32*)&Height, + &BitDepth, &ColorType, NULL, NULL, NULL); + + // Convert palette color to true color + if (ColorType==PNG_COLOR_TYPE_PALETTE) + png_set_palette_to_rgb(png_ptr); + + // Convert low bit colors to 8 bit colors + if (BitDepth < 8) + { + if (ColorType==PNG_COLOR_TYPE_GRAY || ColorType==PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_1_2_4_to_8(png_ptr); + else + png_set_packing(png_ptr); + } + + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) + png_set_tRNS_to_alpha(png_ptr); + + // Convert high bit colors to 8 bit colors + if (BitDepth == 16) + png_set_strip_16(png_ptr); + + // Convert gray color to true color + if (ColorType==PNG_COLOR_TYPE_GRAY || ColorType==PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png_ptr); + + // Update the changes + png_read_update_info(png_ptr, info_ptr); + png_get_IHDR(png_ptr, info_ptr, + (png_uint_32*)&Width, (png_uint_32*)&Height, + &BitDepth, &ColorType, NULL, NULL, NULL); + + // Convert RGBA to BGRA + if (ColorType==PNG_COLOR_TYPE_RGB_ALPHA) + { +#ifdef __BIG_ENDIAN__ + png_set_swap_alpha(png_ptr); +#else + png_set_bgr(png_ptr); +#endif + } + + // Update the changes + png_get_IHDR(png_ptr, info_ptr, + (png_uint_32*)&Width, (png_uint_32*)&Height, + &BitDepth, &ColorType, NULL, NULL, NULL); + + // Create the image structure to be filled by png data + if (ColorType==PNG_COLOR_TYPE_RGB_ALPHA) + Image = new CImage(ECF_A8R8G8B8, core::dimension2d(Width, Height)); + else + Image = new CImage(ECF_R8G8B8, core::dimension2d(Width, Height)); + if (!Image) + { + os::Printer::log("LOAD PNG: Internal PNG create image struct failure\n", file->getFileName(), ELL_ERROR); + png_destroy_read_struct(&png_ptr, NULL, NULL); + return 0; + } + + // Create array of pointers to rows in image data + RowPointers = new png_bytep[Height]; + if (!RowPointers) + { + os::Printer::log("LOAD PNG: Internal PNG create row pointers failure\n", file->getFileName(), ELL_ERROR); + png_destroy_read_struct(&png_ptr, NULL, NULL); + delete Image; + return 0; + } + + // Fill array of pointers to rows in image data + unsigned char* data = (unsigned char*)Image->lock(); + for (u32 i=0; igetPitch(); + } + + // for proper error handling + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + delete [] RowPointers; + Image->unlock(); + delete [] Image; + return 0; + } + + // Read data using the library function that handles all transformations including interlacing + png_read_image(png_ptr, RowPointers); + + png_read_end(png_ptr, NULL); + delete [] RowPointers; + Image->unlock(); + png_destroy_read_struct(&png_ptr,&info_ptr, 0); // Clean up memory + + return Image; +#else + return 0; +#endif // _IRR_COMPILE_WITH_LIBPNG_ +} + + + +IImageLoader* createImageLoaderPNG() +{ + return new CImageLoaderPng(); +} + + +}// end namespace irr +}//end namespace video + diff --git a/src/dep/src/irrlicht/CImageLoaderPNG.h b/src/dep/src/irrlicht/CImageLoaderPNG.h index c24d188..33dc17e 100644 --- a/src/dep/src/irrlicht/CImageLoaderPNG.h +++ b/src/dep/src/irrlicht/CImageLoaderPNG.h @@ -1,54 +1,54 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// this file was created by rt (www.tomkorp.com), based on ttk's png-reader -// i wanted to be able to read in PNG images with irrlicht :) -// why? lossless compression with 8-bit alpha channel! - -#ifndef __C_IMAGE_LOADER_PNG_H_INCLUDED__ -#define __C_IMAGE_LOADER_PNG_H_INCLUDED__ - -#include "IImageLoader.h" - -namespace irr -{ -namespace video -{ - -//! Surface Loader for PNG files -class CImageLoaderPng : public IImageLoader -{ -public: - - //! constructor - CImageLoaderPng(); - - //! destructor - virtual ~CImageLoaderPng(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".png") - virtual bool isALoadableFileExtension(const c8* fileName); - - //! returns true if the file maybe is able to be loaded by this class - virtual bool isALoadableFileFormat(irr::io::IReadFile* file); - - //! creates a surface from the file - virtual IImage* loadImage(irr::io::IReadFile* file); - -private: - //some variables - u32 Width; - u32 Height; - s32 BitDepth; - s32 ColorType; - video::IImage* Image; - u8** RowPointers; //Used to point to image rows -}; - - -} // end namespace video -} // end namespace irr - -#endif +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// this file was created by rt (www.tomkorp.com), based on ttk's png-reader +// i wanted to be able to read in PNG images with irrlicht :) +// why? lossless compression with 8-bit alpha channel! + +#ifndef __C_IMAGE_LOADER_PNG_H_INCLUDED__ +#define __C_IMAGE_LOADER_PNG_H_INCLUDED__ + +#include "IImageLoader.h" + +namespace irr +{ +namespace video +{ + +//! Surface Loader for PNG files +class CImageLoaderPng : public IImageLoader +{ +public: + + //! constructor + CImageLoaderPng(); + + //! destructor + virtual ~CImageLoaderPng(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".png") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! returns true if the file maybe is able to be loaded by this class + virtual bool isALoadableFileFormat(irr::io::IReadFile* file); + + //! creates a surface from the file + virtual IImage* loadImage(irr::io::IReadFile* file); + +private: + //some variables + u32 Width; + u32 Height; + s32 BitDepth; + s32 ColorType; + video::IImage* Image; + u8** RowPointers; //Used to point to image rows +}; + + +} // end namespace video +} // end namespace irr + +#endif diff --git a/src/dep/src/irrlicht/CImageLoaderPSD.cpp b/src/dep/src/irrlicht/CImageLoaderPSD.cpp index a5ab413..d24a1ec 100644 --- a/src/dep/src/irrlicht/CImageLoaderPSD.cpp +++ b/src/dep/src/irrlicht/CImageLoaderPSD.cpp @@ -1,378 +1,378 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageLoaderPSD.h" -#include "os.h" -#include "CImage.h" -#include "irrString.h" - - -namespace irr -{ -namespace video -{ - - -//! constructor -CImageLoaderPSD::CImageLoaderPSD() -: imageData(0) -{ - #ifdef _DEBUG - setDebugName("CImageLoaderPSD"); - #endif -} - - - -//! destructor -CImageLoaderPSD::~CImageLoaderPSD() -{ - delete [] imageData; -} - - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".tga") -bool CImageLoaderPSD::isALoadableFileExtension(const c8* fileName) -{ - return strstr(fileName, ".psd") != 0; -} - - - -//! returns true if the file maybe is able to be loaded by this class -bool CImageLoaderPSD::isALoadableFileFormat(irr::io::IReadFile* file) -{ - if (!file) - return false; - - u8 type[3]; - file->read(&type, sizeof(u8)*3); - return (type[2]==2); // we currently only handle tgas of type 2. -} - - - -//! creates a surface from the file -IImage* CImageLoaderPSD::loadImage(irr::io::IReadFile* file) -{ - delete [] imageData; - imageData = 0; - - file->read(&header, sizeof(PsdHeader)); - -#ifndef __BIG_ENDIAN__ - header.version = os::Byteswap::byteswap(header.version); - header.channels = os::Byteswap::byteswap(header.channels); - header.height = os::Byteswap::byteswap(header.height); - header.width = os::Byteswap::byteswap(header.width); - header.depth = os::Byteswap::byteswap(header.depth); - header.mode = os::Byteswap::byteswap(header.mode); -#endif - - if (header.signature[0] != '8' || - header.signature[1] != 'B' || - header.signature[2] != 'P' || - header.signature[3] != 'S') - return 0; - - if (header.version != 1) - { - os::Printer::log("Unsupported PSD file version", file->getFileName(), ELL_ERROR); - return 0; - } - - if (header.mode != 3 || header.depth != 8) - { - os::Printer::log("Unsupported PSD color mode or depth.\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // skip color mode data - - u32 l; - file->read(&l, sizeof(u32)); -#ifndef __BIG_ENDIAN__ - l = os::Byteswap::byteswap(l); -#endif - if (!file->seek(l, true)) - { - os::Printer::log("Error seeking file pos to image resources.\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // skip image resources - - file->read(&l, sizeof(u32)); -#ifndef __BIG_ENDIAN__ - l = os::Byteswap::byteswap(l); -#endif - if (!file->seek(l, true)) - { - os::Printer::log("Error seeking file pos to layer and mask.\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // skip layer & mask - - file->read(&l, sizeof(u32)); -#ifndef __BIG_ENDIAN__ - l = os::Byteswap::byteswap(l); -#endif - if (!file->seek(l, true)) - { - os::Printer::log("Error seeking file pos to image data section.\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // read image data - - u16 compressionType; - file->read(&compressionType, sizeof(u16)); -#ifndef __BIG_ENDIAN__ - compressionType = os::Byteswap::byteswap(compressionType); -#endif - - if (compressionType != 1 && compressionType != 0) - { - os::Printer::log("Unsupported psd compression mode.\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // create image data block - - imageData = new u32[header.width * header.height]; - - bool res = false; - - if (compressionType == 0) - res = readRawImageData(file); // RAW image data - else - res = readRLEImageData(file); // RLE compressed data - - video::IImage* image = 0; - - if (res) - { - // create surface - image = new CImage(ECF_A8R8G8B8, - core::dimension2d(header.width, header.height), imageData); - } - - if (!image) - delete [] imageData; - imageData = 0; - - return image; -} - - - -bool CImageLoaderPSD::readRawImageData(irr::io::IReadFile* file) -{ - u8* tmpData = new u8[header.width * header.height]; - - for (s32 channel=0; channelread(tmpData, sizeof(c8) * header.width * header.height)) - { - os::Printer::log("Error reading color channel\n", file->getFileName(), ELL_ERROR); - break; - } - - s16 shift = getShiftFromChannel(channel); - if (shift != -1) - { - u32 mask = 0xff << shift; - - for (u32 x=0; xread(&rleCount[y], sizeof(u16))) - { - delete [] tmpData; - delete [] rleCount; - os::Printer::log("Error reading rle rows\n", file->getFileName(), ELL_ERROR); - return false; - } - -#ifndef __BIG_ENDIAN__ - rleCount[y] = os::Byteswap::byteswap(rleCount[y]); -#endif - size += rleCount[y]; - } - - s8 *buf = new s8[size]; - if (!file->read(buf, size)) - { - delete [] rleCount; - delete [] buf; - delete [] tmpData; - os::Printer::log("Error reading rle rows\n", file->getFileName(), ELL_ERROR); - return false; - } - - u16 *rcount=rleCount; - - s8 rh; - u16 bytesRead; - u8 *dest; - s8 *pBuf = buf; - - // decompress packbit rle - - for (s32 channel=0; channel= 0) - { - ++rh; - - while (rh--) - { - *dest = *pBuf++; - ++bytesRead; - ++dest; - } - } - else - if (rh > -128) - { - rh = -rh +1; - - while (rh--) - { - *dest = *pBuf; - ++dest; - } - - ++pBuf; - ++bytesRead; - } - } - } - - s16 shift = getShiftFromChannel(channel); - - if (shift != -1) - { - u32 mask = 0xff << shift; - - for (u32 x=0; xread(&type, sizeof(u8)*3); + return (type[2]==2); // we currently only handle tgas of type 2. +} + + + +//! creates a surface from the file +IImage* CImageLoaderPSD::loadImage(irr::io::IReadFile* file) +{ + delete [] imageData; + imageData = 0; + + file->read(&header, sizeof(PsdHeader)); + +#ifndef __BIG_ENDIAN__ + header.version = os::Byteswap::byteswap(header.version); + header.channels = os::Byteswap::byteswap(header.channels); + header.height = os::Byteswap::byteswap(header.height); + header.width = os::Byteswap::byteswap(header.width); + header.depth = os::Byteswap::byteswap(header.depth); + header.mode = os::Byteswap::byteswap(header.mode); +#endif + + if (header.signature[0] != '8' || + header.signature[1] != 'B' || + header.signature[2] != 'P' || + header.signature[3] != 'S') + return 0; + + if (header.version != 1) + { + os::Printer::log("Unsupported PSD file version", file->getFileName(), ELL_ERROR); + return 0; + } + + if (header.mode != 3 || header.depth != 8) + { + os::Printer::log("Unsupported PSD color mode or depth.\n", file->getFileName(), ELL_ERROR); + return 0; + } + + // skip color mode data + + u32 l; + file->read(&l, sizeof(u32)); +#ifndef __BIG_ENDIAN__ + l = os::Byteswap::byteswap(l); +#endif + if (!file->seek(l, true)) + { + os::Printer::log("Error seeking file pos to image resources.\n", file->getFileName(), ELL_ERROR); + return 0; + } + + // skip image resources + + file->read(&l, sizeof(u32)); +#ifndef __BIG_ENDIAN__ + l = os::Byteswap::byteswap(l); +#endif + if (!file->seek(l, true)) + { + os::Printer::log("Error seeking file pos to layer and mask.\n", file->getFileName(), ELL_ERROR); + return 0; + } + + // skip layer & mask + + file->read(&l, sizeof(u32)); +#ifndef __BIG_ENDIAN__ + l = os::Byteswap::byteswap(l); +#endif + if (!file->seek(l, true)) + { + os::Printer::log("Error seeking file pos to image data section.\n", file->getFileName(), ELL_ERROR); + return 0; + } + + // read image data + + u16 compressionType; + file->read(&compressionType, sizeof(u16)); +#ifndef __BIG_ENDIAN__ + compressionType = os::Byteswap::byteswap(compressionType); +#endif + + if (compressionType != 1 && compressionType != 0) + { + os::Printer::log("Unsupported psd compression mode.\n", file->getFileName(), ELL_ERROR); + return 0; + } + + // create image data block + + imageData = new u32[header.width * header.height]; + + bool res = false; + + if (compressionType == 0) + res = readRawImageData(file); // RAW image data + else + res = readRLEImageData(file); // RLE compressed data + + video::IImage* image = 0; + + if (res) + { + // create surface + image = new CImage(ECF_A8R8G8B8, + core::dimension2d(header.width, header.height), imageData); + } + + if (!image) + delete [] imageData; + imageData = 0; + + return image; +} + + + +bool CImageLoaderPSD::readRawImageData(irr::io::IReadFile* file) +{ + u8* tmpData = new u8[header.width * header.height]; + + for (s32 channel=0; channelread(tmpData, sizeof(c8) * header.width * header.height)) + { + os::Printer::log("Error reading color channel\n", file->getFileName(), ELL_ERROR); + break; + } + + s16 shift = getShiftFromChannel(channel); + if (shift != -1) + { + u32 mask = 0xff << shift; + + for (u32 x=0; xread(&rleCount[y], sizeof(u16))) + { + delete [] tmpData; + delete [] rleCount; + os::Printer::log("Error reading rle rows\n", file->getFileName(), ELL_ERROR); + return false; + } + +#ifndef __BIG_ENDIAN__ + rleCount[y] = os::Byteswap::byteswap(rleCount[y]); +#endif + size += rleCount[y]; + } + + s8 *buf = new s8[size]; + if (!file->read(buf, size)) + { + delete [] rleCount; + delete [] buf; + delete [] tmpData; + os::Printer::log("Error reading rle rows\n", file->getFileName(), ELL_ERROR); + return false; + } + + u16 *rcount=rleCount; + + s8 rh; + u16 bytesRead; + u8 *dest; + s8 *pBuf = buf; + + // decompress packbit rle + + for (s32 channel=0; channel= 0) + { + ++rh; + + while (rh--) + { + *dest = *pBuf++; + ++bytesRead; + ++dest; + } + } + else + if (rh > -128) + { + rh = -rh +1; + + while (rh--) + { + *dest = *pBuf; + ++dest; + } + + ++pBuf; + ++bytesRead; + } + } + } + + s16 shift = getShiftFromChannel(channel); + + if (shift != -1) + { + u32 mask = 0xff << shift; + + for (u32 x=0; xread(&chunkheader, sizeof(u8)); // Read The Chunk's Header - - if(chunkheader < 128) // If The Chunk Is A 'RAW' Chunk - { - chunkheader++; // Add 1 To The Value To Get Total Number Of Raw Pixels - - file->read(&data[currentByte], bytesPerPixel * chunkheader); - currentByte += bytesPerPixel * chunkheader; - } - else - { - // thnx to neojzs for some fixes with this code - - // If It's An RLE Header - chunkheader -= 127; // Subtract 127 To Get Rid Of The ID Bit - - s32 dataOffset = currentByte; - file->read(&data[dataOffset], bytesPerPixel); - - currentByte += bytesPerPixel; - - for(s32 counter = 1; counter < chunkheader; counter++) - { - for(s32 elementCounter=0; elementCounter < bytesPerPixel; elementCounter++) - data[currentByte + elementCounter] = data[dataOffset + elementCounter]; - - currentByte += bytesPerPixel; - } - } - } - - return data; -} - - - -//! returns true if the file maybe is able to be loaded by this class -bool CImageLoaderTGA::isALoadableFileFormat(irr::io::IReadFile* file) -{ - if (!file) - return false; - - STGAFooter footer; - memset(&footer, 0, sizeof(STGAFooter)); - file->seek(file->getSize()-sizeof(STGAFooter)); - file->read(&footer, sizeof(STGAFooter)); - return (!strcmp(footer.Signature,"TRUEVISION-XFILE.")); // very old tgas are refused. -} - - - -//! creates a surface from the file -IImage* CImageLoaderTGA::loadImage(irr::io::IReadFile* file) -{ - STGAHeader header; - u8* colorMap = 0; - - file->read(&header, sizeof(STGAHeader)); - -#ifdef __BIG_ENDIAN__ - header.ColorMapLength = os::Byteswap::byteswap(header.ColorMapLength); - header.ImageWidth = os::Byteswap::byteswap(header.ImageWidth); - header.ImageHeight = os::Byteswap::byteswap(header.ImageHeight); -#endif - - // skip image identification field - if (header.IdLength) - file->seek(header.IdLength, true); - - if (header.ColorMapType) - { - // read color map - colorMap = new u8[header.ColorMapEntrySize/8 * header.ColorMapLength]; - file->read(colorMap,header.ColorMapEntrySize/8 * header.ColorMapLength); - } - - // read image - - u8* data = 0; - - if (header.ImageType == 2) - { - const s32 imageSize = header.ImageHeight * header.ImageWidth * header.PixelDepth/8; - data = new u8[imageSize]; - file->read(data, imageSize); - } - else - if(header.ImageType == 10) - data = loadCompressedImage(file, header); - else - { - os::Printer::log("Unsupported TGA file type", file->getFileName(), ELL_ERROR); - if (colorMap) - delete [] colorMap; - return 0; - } - - IImage* image = 0; - - switch(header.PixelDepth) - { - case 16: - { - image = new CImage(ECF_A1R5G5B5, - core::dimension2d(header.ImageWidth, header.ImageHeight)); - if (image) - CColorConverter::convert16BitTo16Bit((s16*)data, - (s16*)image->lock(), header.ImageWidth, header.ImageHeight, 0, (header.ImageDescriptor&0x20)==0); - } - break; - case 24: - { - image = new CImage(ECF_R8G8B8, - core::dimension2d(header.ImageWidth, header.ImageHeight)); - if (image) - CColorConverter::convert24BitTo24Bit( - (u8*)data, (u8*)image->lock(), header.ImageWidth, header.ImageHeight, 0, (header.ImageDescriptor&0x20)==0, true); - } - break; - case 32: - { - image = new CImage(ECF_A8R8G8B8, - core::dimension2d(header.ImageWidth, header.ImageHeight)); - if (image) - CColorConverter::convert32BitTo32Bit((s32*)data, - (s32*)image->lock(), header.ImageWidth, header.ImageHeight, 0, (header.ImageDescriptor&0x20)==0); - } - break; - default: - os::Printer::log("Unsupported TGA format", file->getFileName(), ELL_ERROR); - break; - } - if (image) - image->unlock(); - delete [] data; - if (colorMap) - delete [] colorMap; - - return image; -} - - - -//! creates a loader which is able to load tgas -IImageLoader* createImageLoaderTGA() -{ - return new CImageLoaderTGA(); -} - - -} // end namespace video -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CImageLoaderTGA.h" +#include "os.h" +#include "CColorConverter.h" +#include "CImage.h" +#include "irrString.h" + + +namespace irr +{ +namespace video +{ + + +//! constructor +CImageLoaderTGA::CImageLoaderTGA() +{ +} + + + +//! destructor +CImageLoaderTGA::~CImageLoaderTGA() +{ +} + + + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".tga") +bool CImageLoaderTGA::isALoadableFileExtension(const c8* fileName) +{ + return strstr(fileName, ".tga") != 0; +} + + +//! loads a compressed tga. +u8 *CImageLoaderTGA::loadCompressedImage(irr::io::IReadFile *file, const STGAHeader& header) +{ + // This was written and sent in by Jon Pry, thank you very much! + // I only changed the formatting a little bit. + + s32 bytesPerPixel = header.PixelDepth/8; + s32 imageSize = header.ImageHeight * header.ImageWidth * bytesPerPixel; + u8* data = new u8[imageSize]; + s32 currentByte = 0; + + while(currentByte < imageSize) + { + u8 chunkheader = 0; + file->read(&chunkheader, sizeof(u8)); // Read The Chunk's Header + + if(chunkheader < 128) // If The Chunk Is A 'RAW' Chunk + { + chunkheader++; // Add 1 To The Value To Get Total Number Of Raw Pixels + + file->read(&data[currentByte], bytesPerPixel * chunkheader); + currentByte += bytesPerPixel * chunkheader; + } + else + { + // thnx to neojzs for some fixes with this code + + // If It's An RLE Header + chunkheader -= 127; // Subtract 127 To Get Rid Of The ID Bit + + s32 dataOffset = currentByte; + file->read(&data[dataOffset], bytesPerPixel); + + currentByte += bytesPerPixel; + + for(s32 counter = 1; counter < chunkheader; counter++) + { + for(s32 elementCounter=0; elementCounter < bytesPerPixel; elementCounter++) + data[currentByte + elementCounter] = data[dataOffset + elementCounter]; + + currentByte += bytesPerPixel; + } + } + } + + return data; +} + + + +//! returns true if the file maybe is able to be loaded by this class +bool CImageLoaderTGA::isALoadableFileFormat(irr::io::IReadFile* file) +{ + if (!file) + return false; + + STGAFooter footer; + memset(&footer, 0, sizeof(STGAFooter)); + file->seek(file->getSize()-sizeof(STGAFooter)); + file->read(&footer, sizeof(STGAFooter)); + return (!strcmp(footer.Signature,"TRUEVISION-XFILE.")); // very old tgas are refused. +} + + + +//! creates a surface from the file +IImage* CImageLoaderTGA::loadImage(irr::io::IReadFile* file) +{ + STGAHeader header; + u8* colorMap = 0; + + file->read(&header, sizeof(STGAHeader)); + +#ifdef __BIG_ENDIAN__ + header.ColorMapLength = os::Byteswap::byteswap(header.ColorMapLength); + header.ImageWidth = os::Byteswap::byteswap(header.ImageWidth); + header.ImageHeight = os::Byteswap::byteswap(header.ImageHeight); +#endif + + // skip image identification field + if (header.IdLength) + file->seek(header.IdLength, true); + + if (header.ColorMapType) + { + // read color map + colorMap = new u8[header.ColorMapEntrySize/8 * header.ColorMapLength]; + file->read(colorMap,header.ColorMapEntrySize/8 * header.ColorMapLength); + } + + // read image + + u8* data = 0; + + if (header.ImageType == 2) + { + const s32 imageSize = header.ImageHeight * header.ImageWidth * header.PixelDepth/8; + data = new u8[imageSize]; + file->read(data, imageSize); + } + else + if(header.ImageType == 10) + data = loadCompressedImage(file, header); + else + { + os::Printer::log("Unsupported TGA file type", file->getFileName(), ELL_ERROR); + if (colorMap) + delete [] colorMap; + return 0; + } + + IImage* image = 0; + + switch(header.PixelDepth) + { + case 16: + { + image = new CImage(ECF_A1R5G5B5, + core::dimension2d(header.ImageWidth, header.ImageHeight)); + if (image) + CColorConverter::convert16BitTo16Bit((s16*)data, + (s16*)image->lock(), header.ImageWidth, header.ImageHeight, 0, (header.ImageDescriptor&0x20)==0); + } + break; + case 24: + { + image = new CImage(ECF_R8G8B8, + core::dimension2d(header.ImageWidth, header.ImageHeight)); + if (image) + CColorConverter::convert24BitTo24Bit( + (u8*)data, (u8*)image->lock(), header.ImageWidth, header.ImageHeight, 0, (header.ImageDescriptor&0x20)==0, true); + } + break; + case 32: + { + image = new CImage(ECF_A8R8G8B8, + core::dimension2d(header.ImageWidth, header.ImageHeight)); + if (image) + CColorConverter::convert32BitTo32Bit((s32*)data, + (s32*)image->lock(), header.ImageWidth, header.ImageHeight, 0, (header.ImageDescriptor&0x20)==0); + } + break; + default: + os::Printer::log("Unsupported TGA format", file->getFileName(), ELL_ERROR); + break; + } + if (image) + image->unlock(); + delete [] data; + if (colorMap) + delete [] colorMap; + + return image; +} + + + +//! creates a loader which is able to load tgas +IImageLoader* createImageLoaderTGA() +{ + return new CImageLoaderTGA(); +} + + +} // end namespace video +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CImageLoaderTGA.h b/src/dep/src/irrlicht/CImageLoaderTGA.h index 2d772ab..d83af4a 100644 --- a/src/dep/src/irrlicht/CImageLoaderTGA.h +++ b/src/dep/src/irrlicht/CImageLoaderTGA.h @@ -1,94 +1,94 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IMAGE_LOADER_TGA_H_INCLUDED__ -#define __C_IMAGE_LOADER_TGA_H_INCLUDED__ - -#include "IImageLoader.h" - - -namespace irr -{ -namespace video -{ - - -// byte-align structures -#ifdef _MSC_VER -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# define PACK_STRUCT -#endif - - // these structs are also used in the TGA writer - struct STGAHeader{ - u8 IdLength; - u8 ColorMapType; - u8 ImageType; - u8 FirstEntryIndex[2]; - u16 ColorMapLength; - u8 ColorMapEntrySize; - u8 XOrigin[2]; - u8 YOrigin[2]; - u16 ImageWidth; - u16 ImageHeight; - u8 PixelDepth; - u8 ImageDescriptor; - } PACK_STRUCT; - - struct STGAFooter - { - u32 ExtensionOffset; - u32 DeveloperOffset; - c8 Signature[18]; - } PACK_STRUCT; - -// Default alignment -#ifdef _MSC_VER -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - -/*! - Surface Loader for targa images -*/ -class CImageLoaderTGA : public IImageLoader -{ -public: - - //! constructor - CImageLoaderTGA(); - - //! destructor - virtual ~CImageLoaderTGA(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".tga") - virtual bool isALoadableFileExtension(const c8* fileName); - - //! returns true if the file maybe is able to be loaded by this class - virtual bool isALoadableFileFormat(irr::io::IReadFile* file); - - //! creates a surface from the file - virtual IImage* loadImage(irr::io::IReadFile* file); - -private: - - //! loads a compressed tga. Was written and sent in by Jon Pry, thank you very much! - u8* loadCompressedImage(irr::io::IReadFile *file, const STGAHeader& header); - -}; - - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_IMAGE_LOADER_TGA_H_INCLUDED__ +#define __C_IMAGE_LOADER_TGA_H_INCLUDED__ + +#include "IImageLoader.h" + + +namespace irr +{ +namespace video +{ + + +// byte-align structures +#ifdef _MSC_VER +# pragma pack( push, packing ) +# pragma pack( 1 ) +# define PACK_STRUCT +#elif defined( __GNUC__ ) +# define PACK_STRUCT __attribute__((packed)) +#else +# define PACK_STRUCT +#endif + + // these structs are also used in the TGA writer + struct STGAHeader{ + u8 IdLength; + u8 ColorMapType; + u8 ImageType; + u8 FirstEntryIndex[2]; + u16 ColorMapLength; + u8 ColorMapEntrySize; + u8 XOrigin[2]; + u8 YOrigin[2]; + u16 ImageWidth; + u16 ImageHeight; + u8 PixelDepth; + u8 ImageDescriptor; + } PACK_STRUCT; + + struct STGAFooter + { + u32 ExtensionOffset; + u32 DeveloperOffset; + c8 Signature[18]; + } PACK_STRUCT; + +// Default alignment +#ifdef _MSC_VER +# pragma pack( pop, packing ) +#endif + +#undef PACK_STRUCT + +/*! + Surface Loader for targa images +*/ +class CImageLoaderTGA : public IImageLoader +{ +public: + + //! constructor + CImageLoaderTGA(); + + //! destructor + virtual ~CImageLoaderTGA(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".tga") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! returns true if the file maybe is able to be loaded by this class + virtual bool isALoadableFileFormat(irr::io::IReadFile* file); + + //! creates a surface from the file + virtual IImage* loadImage(irr::io::IReadFile* file); + +private: + + //! loads a compressed tga. Was written and sent in by Jon Pry, thank you very much! + u8* loadCompressedImage(irr::io::IReadFile *file, const STGAHeader& header); + +}; + + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CImageWriterBMP.cpp b/src/dep/src/irrlicht/CImageWriterBMP.cpp index 11ec3e6..8a04368 100644 --- a/src/dep/src/irrlicht/CImageWriterBMP.cpp +++ b/src/dep/src/irrlicht/CImageWriterBMP.cpp @@ -1,127 +1,127 @@ - -#include "CImageWriterBMP.h" -#include "CImageLoaderBMP.h" -#include "IWriteFile.h" -#include "CColorConverter.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -IImageWriter* createImageWriterBMP() -{ - return new CImageWriterBMP; -} - -CImageWriterBMP::CImageWriterBMP() -{ -#ifdef _DEBUG - setDebugName("CImageWriterBMP"); -#endif -} - -bool CImageWriterBMP::isAWriteableFileExtension(const c8* fileName) -{ - return strstr(fileName, ".bmp") != 0; -} - -bool CImageWriterBMP::writeImage(io::IWriteFile* file, IImage* image, u32 param) -{ - // we always write 24-bit color because nothing really reads 32-bit - - SBMPHeader imageHeader; - imageHeader.Id = 0x4d42; - imageHeader.Reserved = 0; - imageHeader.BitmapDataOffset = sizeof(imageHeader); - imageHeader.BitmapHeaderSize = 0x28; - imageHeader.Width = image->getDimension().Width; - imageHeader.Height = image->getDimension().Height; - imageHeader.Planes = 1; - imageHeader.BPP = 24; - imageHeader.Compression = 0; - imageHeader.PixelPerMeterX = 0; - imageHeader.PixelPerMeterY = 0; - imageHeader.Colors = 0; - imageHeader.ImportantColors = 0; - - // data size is rounded up to next larger 4 bytes boundary - imageHeader.BitmapDataSize = imageHeader.Width * imageHeader.BPP / 8; - imageHeader.BitmapDataSize = (imageHeader.BitmapDataSize + 3) & ~3; - imageHeader.BitmapDataSize *= imageHeader.Height; - - // file size is data size plus offset to data - imageHeader.FileSize = imageHeader.BitmapDataOffset + imageHeader.BitmapDataSize; - - // bitmaps are stored upside down and padded so we always do this - void (*CColorConverter_convertFORMATtoFORMAT)(const void*, s32, void*) = 0; - switch(image->getColorFormat()) - { - case ECF_R8G8B8: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_R8G8B8toR8G8B8; - break; - case ECF_A8R8G8B8: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_A8R8G8B8toR8G8B8; - break; - case ECF_A1R5G5B5: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_A1R5G5B5toR8G8B8; - break; - case ECF_R5G6B5: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_R5G6B5toR8G8B8; - break; - } - - // couldn't find a color converter - if (!CColorConverter_convertFORMATtoFORMAT) - return false; - - // write the bitmap header - if (file->write(&imageHeader, sizeof(imageHeader)) != sizeof(imageHeader)) - return false; - - u8* scan_lines = (u8*)image->lock(); - if (!scan_lines) - return false; - - // size of one pixel in bytes - u32 pixel_size = image->getBytesPerPixel(); - - // length of one row of the source image in bytes - u32 row_stride = (pixel_size * imageHeader.Width); - - // length of one row in bytes, rounded up to nearest 4-byte boundary - s32 row_size = ((3 * imageHeader.Width) + 3) & ~3; - - // allocate and clear memory for our scan line - u8* row_pointer = new u8[row_size]; - memset(row_pointer, 0, row_size); - - // convert the image to 24-bit BGR and flip it over - s32 y; - for (y = imageHeader.Height - 1; 0 <= y; --y) - { - if (image->getColorFormat()==ECF_R8G8B8) - CColorConverter::convert24BitTo24Bit(&scan_lines[y * row_stride], row_pointer, imageHeader.Width, 1, 0, false, true); - else - // source, length [pixels], destination - CColorConverter_convertFORMATtoFORMAT(&scan_lines[y * row_stride], imageHeader.Width, row_pointer); - if (file->write(row_pointer, row_size) < row_size) - break; - } - - // clean up our scratch area - delete [] row_pointer; - - // give back image handle - image->unlock(); - - return y < 0; -} - -} // namespace video -} // namespace irr + +#include "CImageWriterBMP.h" +#include "CImageLoaderBMP.h" +#include "IWriteFile.h" +#include "CColorConverter.h" +#include "irrString.h" + +namespace irr +{ +namespace video +{ + +IImageWriter* createImageWriterBMP() +{ + return new CImageWriterBMP; +} + +CImageWriterBMP::CImageWriterBMP() +{ +#ifdef _DEBUG + setDebugName("CImageWriterBMP"); +#endif +} + +bool CImageWriterBMP::isAWriteableFileExtension(const c8* fileName) +{ + return strstr(fileName, ".bmp") != 0; +} + +bool CImageWriterBMP::writeImage(io::IWriteFile* file, IImage* image, u32 param) +{ + // we always write 24-bit color because nothing really reads 32-bit + + SBMPHeader imageHeader; + imageHeader.Id = 0x4d42; + imageHeader.Reserved = 0; + imageHeader.BitmapDataOffset = sizeof(imageHeader); + imageHeader.BitmapHeaderSize = 0x28; + imageHeader.Width = image->getDimension().Width; + imageHeader.Height = image->getDimension().Height; + imageHeader.Planes = 1; + imageHeader.BPP = 24; + imageHeader.Compression = 0; + imageHeader.PixelPerMeterX = 0; + imageHeader.PixelPerMeterY = 0; + imageHeader.Colors = 0; + imageHeader.ImportantColors = 0; + + // data size is rounded up to next larger 4 bytes boundary + imageHeader.BitmapDataSize = imageHeader.Width * imageHeader.BPP / 8; + imageHeader.BitmapDataSize = (imageHeader.BitmapDataSize + 3) & ~3; + imageHeader.BitmapDataSize *= imageHeader.Height; + + // file size is data size plus offset to data + imageHeader.FileSize = imageHeader.BitmapDataOffset + imageHeader.BitmapDataSize; + + // bitmaps are stored upside down and padded so we always do this + void (*CColorConverter_convertFORMATtoFORMAT)(const void*, s32, void*) = 0; + switch(image->getColorFormat()) + { + case ECF_R8G8B8: + CColorConverter_convertFORMATtoFORMAT + = CColorConverter::convert_R8G8B8toR8G8B8; + break; + case ECF_A8R8G8B8: + CColorConverter_convertFORMATtoFORMAT + = CColorConverter::convert_A8R8G8B8toR8G8B8; + break; + case ECF_A1R5G5B5: + CColorConverter_convertFORMATtoFORMAT + = CColorConverter::convert_A1R5G5B5toR8G8B8; + break; + case ECF_R5G6B5: + CColorConverter_convertFORMATtoFORMAT + = CColorConverter::convert_R5G6B5toR8G8B8; + break; + } + + // couldn't find a color converter + if (!CColorConverter_convertFORMATtoFORMAT) + return false; + + // write the bitmap header + if (file->write(&imageHeader, sizeof(imageHeader)) != sizeof(imageHeader)) + return false; + + u8* scan_lines = (u8*)image->lock(); + if (!scan_lines) + return false; + + // size of one pixel in bytes + u32 pixel_size = image->getBytesPerPixel(); + + // length of one row of the source image in bytes + u32 row_stride = (pixel_size * imageHeader.Width); + + // length of one row in bytes, rounded up to nearest 4-byte boundary + s32 row_size = ((3 * imageHeader.Width) + 3) & ~3; + + // allocate and clear memory for our scan line + u8* row_pointer = new u8[row_size]; + memset(row_pointer, 0, row_size); + + // convert the image to 24-bit BGR and flip it over + s32 y; + for (y = imageHeader.Height - 1; 0 <= y; --y) + { + if (image->getColorFormat()==ECF_R8G8B8) + CColorConverter::convert24BitTo24Bit(&scan_lines[y * row_stride], row_pointer, imageHeader.Width, 1, 0, false, true); + else + // source, length [pixels], destination + CColorConverter_convertFORMATtoFORMAT(&scan_lines[y * row_stride], imageHeader.Width, row_pointer); + if (file->write(row_pointer, row_size) < row_size) + break; + } + + // clean up our scratch area + delete [] row_pointer; + + // give back image handle + image->unlock(); + + return y < 0; +} + +} // namespace video +} // namespace irr diff --git a/src/dep/src/irrlicht/CImageWriterBMP.h b/src/dep/src/irrlicht/CImageWriterBMP.h index 672fae4..c9be5ab 100644 --- a/src/dep/src/irrlicht/CImageWriterBMP.h +++ b/src/dep/src/irrlicht/CImageWriterBMP.h @@ -1,27 +1,27 @@ -#ifndef _C_IMAGE_WRITER_BMP_H_INCLUDED__ -#define _C_IMAGE_WRITER_BMP_H_INCLUDED__ - -#include "IImageWriter.h" - -namespace irr -{ -namespace video -{ - -class CImageWriterBMP : public IImageWriter -{ -public: - //! constructor - CImageWriterBMP(); - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const c8* fileName); - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param); -}; - -} // namespace video -} // namespace irr - -#endif // _C_IMAGE_WRITER_BMP_H_INCLUDED__ +#ifndef _C_IMAGE_WRITER_BMP_H_INCLUDED__ +#define _C_IMAGE_WRITER_BMP_H_INCLUDED__ + +#include "IImageWriter.h" + +namespace irr +{ +namespace video +{ + +class CImageWriterBMP : public IImageWriter +{ +public: + //! constructor + CImageWriterBMP(); + + //! return true if this writer can write a file with the given extension + virtual bool isAWriteableFileExtension(const c8* fileName); + + //! write image to file + virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param); +}; + +} // namespace video +} // namespace irr + +#endif // _C_IMAGE_WRITER_BMP_H_INCLUDED__ diff --git a/src/dep/src/irrlicht/CImageWriterJPG.cpp b/src/dep/src/irrlicht/CImageWriterJPG.cpp index e37b120..707d854 100644 --- a/src/dep/src/irrlicht/CImageWriterJPG.cpp +++ b/src/dep/src/irrlicht/CImageWriterJPG.cpp @@ -1,232 +1,232 @@ - -#include "CImageWriterJPG.h" -#include "CColorConverter.h" -#include "IWriteFile.h" -#include "CImage.h" -#include "CColorConverter.h" -#include "irrString.h" - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_LIBJPEG_ -#include // required for jpeglib.h -extern "C" -{ -#ifndef _IRR_USE_NON_SYSTEM_JPEG_LIB_ - #include - #include -#else - #include "jpeglib/jpeglib.h" - #include "jpeglib/jerror.h" -#endif -#include -} - - -namespace irr -{ -namespace video -{ - - -typedef struct -{ - struct jpeg_destination_mgr pub; /* public fields */ - - JOCTET * buffer; /* image buffer */ - u32 buffer_size; /* image buffer size */ -} mem_destination_mgr; - - -typedef mem_destination_mgr * mem_dest_ptr; - -void init_destination (j_compress_ptr cinfo) -{ - mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest; - - /* image buffer must be allocated before mem_dest routines are called. */ - if(dest->buffer == NULL) { - //fprintf(stderr, "jmem_dest: init_destination: buffer not allocated\n"); - } - - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = dest->buffer_size; -} - - -boolean empty_output_buffer (j_compress_ptr cinfo) -{ - /* - mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest; - */ - // empty_output_buffer: buffer should not ever be full\n"); - return FALSE; -} - - -void term_destination (j_compress_ptr cinfo) -{ - mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest; - size_t datacount = dest->buffer_size - dest->pub.free_in_buffer; -} - -void jpeg_memory_dest (j_compress_ptr cinfo, u8 *jfif_buffer, - s32 buf_size) -{ - mem_dest_ptr dest; - - if(jfif_buffer == NULL) { - //fprintf(stderr, "jpeg_memory_dest: memory buffer needs to be allocated\n"); - //ERREXIT(cinfo, JERR_BUFFER_SIZE); - return; - } - - if (cinfo->dest == NULL) { /* first time for this JPEG object? */ - cinfo->dest = (struct jpeg_destination_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - (size_t) sizeof(mem_destination_mgr)); - } - - dest = (mem_dest_ptr) cinfo->dest; /* for casting */ - - /* Initialize method pointers */ - dest->pub.init_destination = init_destination; - dest->pub.empty_output_buffer = empty_output_buffer; - dest->pub.term_destination = term_destination; - - /* Initialize private member */ - dest->buffer = (JOCTET*)jfif_buffer; - dest->buffer_size = buf_size; -} - -/* write_JPEG_memory: store JPEG compressed image into memory. -*/ -void write_JPEG_memory (void *img_buf, s32 width, s32 height, u32 bpp, u32 pitch, - u8 *jpeg_buffer, u32 jpeg_buffer_size, - s32 quality, u32 *jpeg_comp_size - ) -{ - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; - - /* More stuff */ - JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ - - - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - jpeg_memory_dest(&cinfo, jpeg_buffer, jpeg_buffer_size); - cinfo.image_width = width; - cinfo.image_height = height; - cinfo.input_components = bpp; - cinfo.in_color_space = JCS_RGB; - - jpeg_set_defaults(&cinfo); - jpeg_set_quality(&cinfo, quality, TRUE); - jpeg_start_compress(&cinfo, TRUE); - - while (cinfo.next_scanline < cinfo.image_height) - { - row_pointer[0] = (u8*) img_buf + (cinfo.next_scanline * pitch ); - jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - - /* Step 6: Finish compression */ - jpeg_finish_compress(&cinfo); - - { - mem_dest_ptr dest = (mem_dest_ptr) cinfo.dest; - *jpeg_comp_size = dest->buffer_size - dest->pub.free_in_buffer; - } - - jpeg_destroy_compress(&cinfo); -} - -} // namespace video -} // namespace irr - -#endif // _IRR_COMPILE_WITH_LIBJPEG_ - -namespace irr -{ -namespace video -{ - -IImageWriter* createImageWriterJPG() -{ - return new CImageWriterJPG; -} - -CImageWriterJPG::CImageWriterJPG() -{ -#ifdef _DEBUG - setDebugName("CImageWriterJPG"); -#endif -} - - -bool CImageWriterJPG::isAWriteableFileExtension(const c8* fileName) -{ - return strstr(fileName, ".jpg") != 0 || strstr(fileName, ".jpeg") != 0; -} - - -bool CImageWriterJPG::writeImage(io::IWriteFile *file, IImage *input,u32 quality ) -{ -#ifndef _IRR_COMPILE_WITH_LIBJPEG_ - return false; -#else - - core::dimension2di dim = input->getDimension(); - IImage * image = new CImage(ECF_R8G8B8, dim ); - - void (*format)(const void*, s32, void*) = 0; - switch( input->getColorFormat () ) - { - case ECF_R8G8B8: format = CColorConverter::convert_R8G8B8toR8G8B8; break; - case ECF_A8R8G8B8: format = CColorConverter::convert_A8R8G8B8toB8G8R8; break; - case ECF_A1R5G5B5: format = CColorConverter::convert_A1R5G5B5toB8G8R8; break; - case ECF_R5G6B5: format = CColorConverter::convert_R5G6B5toR8G8B8; break; - } - - // couldn't find a color converter - if ( 0 == format ) - return false; - - s32 y; - void *src = input->lock(); - void *dst = image->lock(); - for ( y = 0; y!= dim.Height; ++y ) - { - format ( src, dim.Width, dst ); - src = (void*) ( (u8*) src + input->getPitch () ); - dst = (void*) ( (u8*) dst + image->getPitch () ); - } - input->unlock (); - image->unlock (); - - // temp buffer - u32 destSize = image->getImageDataSizeInBytes (); - u8 * dest = new u8 [ destSize ]; - - if ( 0 == quality ) - quality = 75; - - write_JPEG_memory ( image->lock (), dim.Width, dim.Height, - image->getBytesPerPixel(), image->getPitch (), - dest, destSize, - quality, - &destSize - ); - - file->write ( dest, destSize ); - - image->drop (); - delete [] dest; - - return true; -#endif -} - -} // namespace video -} // namespace irr - + +#include "CImageWriterJPG.h" +#include "CColorConverter.h" +#include "IWriteFile.h" +#include "CImage.h" +#include "CColorConverter.h" +#include "irrString.h" + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_LIBJPEG_ +#include // required for jpeglib.h +extern "C" +{ +#ifndef _IRR_USE_NON_SYSTEM_JPEG_LIB_ + #include + #include +#else + #include "jpeglib/jpeglib.h" + #include "jpeglib/jerror.h" +#endif +#include +} + + +namespace irr +{ +namespace video +{ + + +typedef struct +{ + struct jpeg_destination_mgr pub; /* public fields */ + + JOCTET * buffer; /* image buffer */ + u32 buffer_size; /* image buffer size */ +} mem_destination_mgr; + + +typedef mem_destination_mgr * mem_dest_ptr; + +void init_destination (j_compress_ptr cinfo) +{ + mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest; + + /* image buffer must be allocated before mem_dest routines are called. */ + if(dest->buffer == NULL) { + //fprintf(stderr, "jmem_dest: init_destination: buffer not allocated\n"); + } + + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = dest->buffer_size; +} + + +boolean empty_output_buffer (j_compress_ptr cinfo) +{ + /* + mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest; + */ + // empty_output_buffer: buffer should not ever be full\n"); + return FALSE; +} + + +void term_destination (j_compress_ptr cinfo) +{ + mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest; + size_t datacount = dest->buffer_size - dest->pub.free_in_buffer; +} + +void jpeg_memory_dest (j_compress_ptr cinfo, u8 *jfif_buffer, + s32 buf_size) +{ + mem_dest_ptr dest; + + if(jfif_buffer == NULL) { + //fprintf(stderr, "jpeg_memory_dest: memory buffer needs to be allocated\n"); + //ERREXIT(cinfo, JERR_BUFFER_SIZE); + return; + } + + if (cinfo->dest == NULL) { /* first time for this JPEG object? */ + cinfo->dest = (struct jpeg_destination_mgr *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + (size_t) sizeof(mem_destination_mgr)); + } + + dest = (mem_dest_ptr) cinfo->dest; /* for casting */ + + /* Initialize method pointers */ + dest->pub.init_destination = init_destination; + dest->pub.empty_output_buffer = empty_output_buffer; + dest->pub.term_destination = term_destination; + + /* Initialize private member */ + dest->buffer = (JOCTET*)jfif_buffer; + dest->buffer_size = buf_size; +} + +/* write_JPEG_memory: store JPEG compressed image into memory. +*/ +void write_JPEG_memory (void *img_buf, s32 width, s32 height, u32 bpp, u32 pitch, + u8 *jpeg_buffer, u32 jpeg_buffer_size, + s32 quality, u32 *jpeg_comp_size + ) +{ + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + + /* More stuff */ + JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ + + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + jpeg_memory_dest(&cinfo, jpeg_buffer, jpeg_buffer_size); + cinfo.image_width = width; + cinfo.image_height = height; + cinfo.input_components = bpp; + cinfo.in_color_space = JCS_RGB; + + jpeg_set_defaults(&cinfo); + jpeg_set_quality(&cinfo, quality, TRUE); + jpeg_start_compress(&cinfo, TRUE); + + while (cinfo.next_scanline < cinfo.image_height) + { + row_pointer[0] = (u8*) img_buf + (cinfo.next_scanline * pitch ); + jpeg_write_scanlines(&cinfo, row_pointer, 1); + } + + /* Step 6: Finish compression */ + jpeg_finish_compress(&cinfo); + + { + mem_dest_ptr dest = (mem_dest_ptr) cinfo.dest; + *jpeg_comp_size = dest->buffer_size - dest->pub.free_in_buffer; + } + + jpeg_destroy_compress(&cinfo); +} + +} // namespace video +} // namespace irr + +#endif // _IRR_COMPILE_WITH_LIBJPEG_ + +namespace irr +{ +namespace video +{ + +IImageWriter* createImageWriterJPG() +{ + return new CImageWriterJPG; +} + +CImageWriterJPG::CImageWriterJPG() +{ +#ifdef _DEBUG + setDebugName("CImageWriterJPG"); +#endif +} + + +bool CImageWriterJPG::isAWriteableFileExtension(const c8* fileName) +{ + return strstr(fileName, ".jpg") != 0 || strstr(fileName, ".jpeg") != 0; +} + + +bool CImageWriterJPG::writeImage(io::IWriteFile *file, IImage *input,u32 quality ) +{ +#ifndef _IRR_COMPILE_WITH_LIBJPEG_ + return false; +#else + + core::dimension2di dim = input->getDimension(); + IImage * image = new CImage(ECF_R8G8B8, dim ); + + void (*format)(const void*, s32, void*) = 0; + switch( input->getColorFormat () ) + { + case ECF_R8G8B8: format = CColorConverter::convert_R8G8B8toR8G8B8; break; + case ECF_A8R8G8B8: format = CColorConverter::convert_A8R8G8B8toB8G8R8; break; + case ECF_A1R5G5B5: format = CColorConverter::convert_A1R5G5B5toB8G8R8; break; + case ECF_R5G6B5: format = CColorConverter::convert_R5G6B5toR8G8B8; break; + } + + // couldn't find a color converter + if ( 0 == format ) + return false; + + s32 y; + void *src = input->lock(); + void *dst = image->lock(); + for ( y = 0; y!= dim.Height; ++y ) + { + format ( src, dim.Width, dst ); + src = (void*) ( (u8*) src + input->getPitch () ); + dst = (void*) ( (u8*) dst + image->getPitch () ); + } + input->unlock (); + image->unlock (); + + // temp buffer + u32 destSize = image->getImageDataSizeInBytes (); + u8 * dest = new u8 [ destSize ]; + + if ( 0 == quality ) + quality = 75; + + write_JPEG_memory ( image->lock (), dim.Width, dim.Height, + image->getBytesPerPixel(), image->getPitch (), + dest, destSize, + quality, + &destSize + ); + + file->write ( dest, destSize ); + + image->drop (); + delete [] dest; + + return true; +#endif +} + +} // namespace video +} // namespace irr + diff --git a/src/dep/src/irrlicht/CImageWriterJPG.h b/src/dep/src/irrlicht/CImageWriterJPG.h index ce1c2b6..8bed571 100644 --- a/src/dep/src/irrlicht/CImageWriterJPG.h +++ b/src/dep/src/irrlicht/CImageWriterJPG.h @@ -1,28 +1,28 @@ -#ifndef _C_IMAGE_WRITER_JPG_H_INCLUDED__ -#define _C_IMAGE_WRITER_JPG_H_INCLUDED__ - -#include "IImageWriter.h" - -namespace irr -{ -namespace video -{ - -class CImageWriterJPG : public IImageWriter -{ -public: - //! constructor - CImageWriterJPG(); - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const c8* fileName); - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param); -}; - -} -} - -#endif // _C_IMAGE_WRITER_JPG_H_INCLUDED__ - +#ifndef _C_IMAGE_WRITER_JPG_H_INCLUDED__ +#define _C_IMAGE_WRITER_JPG_H_INCLUDED__ + +#include "IImageWriter.h" + +namespace irr +{ +namespace video +{ + +class CImageWriterJPG : public IImageWriter +{ +public: + //! constructor + CImageWriterJPG(); + + //! return true if this writer can write a file with the given extension + virtual bool isAWriteableFileExtension(const c8* fileName); + + //! write image to file + virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param); +}; + +} +} + +#endif // _C_IMAGE_WRITER_JPG_H_INCLUDED__ + diff --git a/src/dep/src/irrlicht/CImageWriterPCX.cpp b/src/dep/src/irrlicht/CImageWriterPCX.cpp index 8b248c3..09a1a78 100644 --- a/src/dep/src/irrlicht/CImageWriterPCX.cpp +++ b/src/dep/src/irrlicht/CImageWriterPCX.cpp @@ -1,37 +1,37 @@ - -#include "CImageWriterPCX.h" -#include "CImageLoaderPCX.h" -#include "IWriteFile.h" -#include "os.h" // for logging -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -IImageWriter* createImageWriterPCX() -{ - return new CImageWriterPCX; -} - -CImageWriterPCX::CImageWriterPCX() -{ -#ifdef _DEBUG - setDebugName("CImageWriterPCX"); -#endif -} - -bool CImageWriterPCX::isAWriteableFileExtension(const c8* fileName) -{ - return strstr(fileName, ".pcx") != 0; -} - -bool CImageWriterPCX::writeImage(io::IWriteFile *file, IImage *image,u32 param) -{ - os::Printer::log("PCX writer not yet implemented. Image not written.", ELL_WARNING); - return false; -} - -} // namespace video -} // namespace irr + +#include "CImageWriterPCX.h" +#include "CImageLoaderPCX.h" +#include "IWriteFile.h" +#include "os.h" // for logging +#include "irrString.h" + +namespace irr +{ +namespace video +{ + +IImageWriter* createImageWriterPCX() +{ + return new CImageWriterPCX; +} + +CImageWriterPCX::CImageWriterPCX() +{ +#ifdef _DEBUG + setDebugName("CImageWriterPCX"); +#endif +} + +bool CImageWriterPCX::isAWriteableFileExtension(const c8* fileName) +{ + return strstr(fileName, ".pcx") != 0; +} + +bool CImageWriterPCX::writeImage(io::IWriteFile *file, IImage *image,u32 param) +{ + os::Printer::log("PCX writer not yet implemented. Image not written.", ELL_WARNING); + return false; +} + +} // namespace video +} // namespace irr diff --git a/src/dep/src/irrlicht/CImageWriterPCX.h b/src/dep/src/irrlicht/CImageWriterPCX.h index 58b6568..bdabf97 100644 --- a/src/dep/src/irrlicht/CImageWriterPCX.h +++ b/src/dep/src/irrlicht/CImageWriterPCX.h @@ -1,27 +1,27 @@ -#ifndef _C_IMAGE_WRITER_PCX_H_INCLUDED__ -#define _C_IMAGE_WRITER_PCX_H_INCLUDED__ - -#include "IImageWriter.h" - -namespace irr -{ -namespace video -{ - -class CImageWriterPCX : public IImageWriter -{ -public: - //! constructor - CImageWriterPCX(); - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const c8* fileName); - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param); -}; - -} // namespace video -} // namespace irr - -#endif // _C_IMAGE_WRITER_PCX_H_INCLUDED__ +#ifndef _C_IMAGE_WRITER_PCX_H_INCLUDED__ +#define _C_IMAGE_WRITER_PCX_H_INCLUDED__ + +#include "IImageWriter.h" + +namespace irr +{ +namespace video +{ + +class CImageWriterPCX : public IImageWriter +{ +public: + //! constructor + CImageWriterPCX(); + + //! return true if this writer can write a file with the given extension + virtual bool isAWriteableFileExtension(const c8* fileName); + + //! write image to file + virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param); +}; + +} // namespace video +} // namespace irr + +#endif // _C_IMAGE_WRITER_PCX_H_INCLUDED__ diff --git a/src/dep/src/irrlicht/CImageWriterPNG.cpp b/src/dep/src/irrlicht/CImageWriterPNG.cpp index 84109c9..f6ab8b7 100644 --- a/src/dep/src/irrlicht/CImageWriterPNG.cpp +++ b/src/dep/src/irrlicht/CImageWriterPNG.cpp @@ -1,192 +1,192 @@ - -#include "CImageWriterPNG.h" -#include "CImageLoaderPNG.h" -#include "CColorConverter.h" -#include "IWriteFile.h" -#include "irrString.h" -#include "os.h" // for logging - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_LIBPNG_ -#ifndef _IRR_USE_NON_SYSTEM_LIB_PNG_ - #include // use system lib png -#else // _IRR_USE_NON_SYSTEM_LIB_PNG_ - #include "libpng/png.h" // use irrlicht included lib png -#endif // _IRR_USE_NON_SYSTEM_LIB_PNG_ -#endif // _IRR_COMPILE_WITH_LIBPNG_ - -namespace irr -{ -namespace video -{ - -IImageWriter* createImageWriterPNG() -{ - return new CImageWriterPNG; -} - -#ifdef _IRR_COMPILE_WITH_LIBPNG_ -// PNG function for error handling -static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg) -{ - os::Printer::log("PNG FATAL ERROR", msg, ELL_ERROR); - longjmp(png_ptr->jmpbuf, 1); -} - -// PNG function for file writing -void PNGAPI user_write_data_fcn(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - irr::io::IWriteFile* file=(irr::io::IWriteFile*)png_ptr->io_ptr; - check=(png_size_t) file->write((void*)data,length); - - if (check != length) - png_error(png_ptr, "Write Error"); -} -#endif // _IRR_COMPILE_WITH_LIBPNG_ - -CImageWriterPNG::CImageWriterPNG() -{ -#ifdef _DEBUG - setDebugName("CImageWriterPNG"); -#endif -} - -bool CImageWriterPNG::isAWriteableFileExtension(const c8* fileName) -{ -#ifdef _IRR_COMPILE_WITH_LIBPNG_ - return strstr(fileName, ".png") != 0; -#else - return false; -#endif -} - -bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param) -{ -#ifdef _IRR_COMPILE_WITH_LIBPNG_ - if (!file || !image) - return false; - - // Allocate the png write struct - png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, - NULL, (png_error_ptr)png_cpexcept_error, NULL); - if (!png_ptr) - { - os::Printer::log("LOAD PNG: Internal PNG create write struct failure\n", file->getFileName(), ELL_ERROR); - return false; - } - - // Allocate the png info struct - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - os::Printer::log("LOAD PNG: Internal PNG create info struct failure\n", file->getFileName(), ELL_ERROR); - png_destroy_write_struct(&png_ptr, NULL); - return false; - } - - // for proper error handling - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, &info_ptr); - return false; - } - - png_set_write_fn(png_ptr, file, user_write_data_fcn, NULL); - - // Set info - if ((image->getColorFormat()==ECF_A8R8G8B8) || (image->getColorFormat()==ECF_A1R5G5B5)) - png_set_IHDR(png_ptr, info_ptr, - image->getDimension().Width, image->getDimension().Height, - 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - else - png_set_IHDR(png_ptr, info_ptr, - image->getDimension().Width, image->getDimension().Height, - 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - - s32 lineWidth=image->getDimension().Width; - switch(image->getColorFormat()) - { - case ECF_R8G8B8: - case ECF_R5G6B5: - lineWidth*=3; - break; - case ECF_A8R8G8B8: - case ECF_A1R5G5B5: - lineWidth*=4; - break; - } - u8* tmpImage = new u8[image->getDimension().Height*lineWidth]; - if (!tmpImage) - { - os::Printer::log("LOAD PNG: Internal PNG create image failure\n", file->getFileName(), ELL_ERROR); - png_destroy_write_struct(&png_ptr, &info_ptr); - return false; - } - - u8* data = (u8*)image->lock(); - switch(image->getColorFormat()) - { - case ECF_R8G8B8: - CColorConverter::convert_R8G8B8toR8G8B8(data,image->getDimension().Height*image->getDimension().Width,tmpImage); - break; - case ECF_A8R8G8B8: - CColorConverter::convert_A8R8G8B8toA8R8G8B8(data,image->getDimension().Height*image->getDimension().Width,tmpImage); - break; - case ECF_R5G6B5: - CColorConverter::convert_R5G6B5toR8G8B8(data,image->getDimension().Height*image->getDimension().Width,tmpImage); - break; - case ECF_A1R5G5B5: - CColorConverter::convert_A1R5G5B5toA8R8G8B8(data,image->getDimension().Height*image->getDimension().Width,tmpImage); - break; - } - image->unlock(); - // Create array of pointers to rows in image data - RowPointers = new png_bytep[image->getDimension().Height]; - if (!RowPointers) - { - os::Printer::log("LOAD PNG: Internal PNG create row pointers failure\n", file->getFileName(), ELL_ERROR); - png_destroy_write_struct(&png_ptr, &info_ptr); - delete [] tmpImage; - return false; - } - - data=tmpImage; - // Fill array of pointers to rows in image data - for (s32 i=0; igetDimension().Height; ++i) - { - RowPointers[i]=data; - data += lineWidth; - } - // for proper error handling - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, &info_ptr); - delete [] RowPointers; - delete [] tmpImage; - return false; - } - - png_set_rows(png_ptr, info_ptr, RowPointers); - - if (image->getColorFormat()==ECF_A8R8G8B8 || image->getColorFormat()==ECF_A1R5G5B5) - png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_BGR, NULL); - else - { - png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); - } - - delete [] RowPointers; - delete [] tmpImage; - png_destroy_write_struct(&png_ptr, &info_ptr); - return true; -#else - return false; -#endif -} - -} // namespace video -} // namespace irr + +#include "CImageWriterPNG.h" +#include "CImageLoaderPNG.h" +#include "CColorConverter.h" +#include "IWriteFile.h" +#include "irrString.h" +#include "os.h" // for logging + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_LIBPNG_ +#ifndef _IRR_USE_NON_SYSTEM_LIB_PNG_ + #include // use system lib png +#else // _IRR_USE_NON_SYSTEM_LIB_PNG_ + #include "libpng/png.h" // use irrlicht included lib png +#endif // _IRR_USE_NON_SYSTEM_LIB_PNG_ +#endif // _IRR_COMPILE_WITH_LIBPNG_ + +namespace irr +{ +namespace video +{ + +IImageWriter* createImageWriterPNG() +{ + return new CImageWriterPNG; +} + +#ifdef _IRR_COMPILE_WITH_LIBPNG_ +// PNG function for error handling +static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg) +{ + os::Printer::log("PNG FATAL ERROR", msg, ELL_ERROR); + longjmp(png_ptr->jmpbuf, 1); +} + +// PNG function for file writing +void PNGAPI user_write_data_fcn(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_size_t check; + + irr::io::IWriteFile* file=(irr::io::IWriteFile*)png_ptr->io_ptr; + check=(png_size_t) file->write((void*)data,length); + + if (check != length) + png_error(png_ptr, "Write Error"); +} +#endif // _IRR_COMPILE_WITH_LIBPNG_ + +CImageWriterPNG::CImageWriterPNG() +{ +#ifdef _DEBUG + setDebugName("CImageWriterPNG"); +#endif +} + +bool CImageWriterPNG::isAWriteableFileExtension(const c8* fileName) +{ +#ifdef _IRR_COMPILE_WITH_LIBPNG_ + return strstr(fileName, ".png") != 0; +#else + return false; +#endif +} + +bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param) +{ +#ifdef _IRR_COMPILE_WITH_LIBPNG_ + if (!file || !image) + return false; + + // Allocate the png write struct + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, + NULL, (png_error_ptr)png_cpexcept_error, NULL); + if (!png_ptr) + { + os::Printer::log("LOAD PNG: Internal PNG create write struct failure\n", file->getFileName(), ELL_ERROR); + return false; + } + + // Allocate the png info struct + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + os::Printer::log("LOAD PNG: Internal PNG create info struct failure\n", file->getFileName(), ELL_ERROR); + png_destroy_write_struct(&png_ptr, NULL); + return false; + } + + // for proper error handling + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_write_struct(&png_ptr, &info_ptr); + return false; + } + + png_set_write_fn(png_ptr, file, user_write_data_fcn, NULL); + + // Set info + if ((image->getColorFormat()==ECF_A8R8G8B8) || (image->getColorFormat()==ECF_A1R5G5B5)) + png_set_IHDR(png_ptr, info_ptr, + image->getDimension().Width, image->getDimension().Height, + 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + else + png_set_IHDR(png_ptr, info_ptr, + image->getDimension().Width, image->getDimension().Height, + 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + + s32 lineWidth=image->getDimension().Width; + switch(image->getColorFormat()) + { + case ECF_R8G8B8: + case ECF_R5G6B5: + lineWidth*=3; + break; + case ECF_A8R8G8B8: + case ECF_A1R5G5B5: + lineWidth*=4; + break; + } + u8* tmpImage = new u8[image->getDimension().Height*lineWidth]; + if (!tmpImage) + { + os::Printer::log("LOAD PNG: Internal PNG create image failure\n", file->getFileName(), ELL_ERROR); + png_destroy_write_struct(&png_ptr, &info_ptr); + return false; + } + + u8* data = (u8*)image->lock(); + switch(image->getColorFormat()) + { + case ECF_R8G8B8: + CColorConverter::convert_R8G8B8toR8G8B8(data,image->getDimension().Height*image->getDimension().Width,tmpImage); + break; + case ECF_A8R8G8B8: + CColorConverter::convert_A8R8G8B8toA8R8G8B8(data,image->getDimension().Height*image->getDimension().Width,tmpImage); + break; + case ECF_R5G6B5: + CColorConverter::convert_R5G6B5toR8G8B8(data,image->getDimension().Height*image->getDimension().Width,tmpImage); + break; + case ECF_A1R5G5B5: + CColorConverter::convert_A1R5G5B5toA8R8G8B8(data,image->getDimension().Height*image->getDimension().Width,tmpImage); + break; + } + image->unlock(); + // Create array of pointers to rows in image data + RowPointers = new png_bytep[image->getDimension().Height]; + if (!RowPointers) + { + os::Printer::log("LOAD PNG: Internal PNG create row pointers failure\n", file->getFileName(), ELL_ERROR); + png_destroy_write_struct(&png_ptr, &info_ptr); + delete [] tmpImage; + return false; + } + + data=tmpImage; + // Fill array of pointers to rows in image data + for (s32 i=0; igetDimension().Height; ++i) + { + RowPointers[i]=data; + data += lineWidth; + } + // for proper error handling + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_write_struct(&png_ptr, &info_ptr); + delete [] RowPointers; + delete [] tmpImage; + return false; + } + + png_set_rows(png_ptr, info_ptr, RowPointers); + + if (image->getColorFormat()==ECF_A8R8G8B8 || image->getColorFormat()==ECF_A1R5G5B5) + png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_BGR, NULL); + else + { + png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); + } + + delete [] RowPointers; + delete [] tmpImage; + png_destroy_write_struct(&png_ptr, &info_ptr); + return true; +#else + return false; +#endif +} + +} // namespace video +} // namespace irr diff --git a/src/dep/src/irrlicht/CImageWriterPNG.h b/src/dep/src/irrlicht/CImageWriterPNG.h index 441820b..63d5814 100644 --- a/src/dep/src/irrlicht/CImageWriterPNG.h +++ b/src/dep/src/irrlicht/CImageWriterPNG.h @@ -1,29 +1,29 @@ -#ifndef _C_IMAGE_WRITER_PNG_H_INCLUDED__ -#define _C_IMAGE_WRITER_PNG_H_INCLUDED__ - -#include "IImageWriter.h" - -namespace irr -{ -namespace video -{ - -class CImageWriterPNG : public IImageWriter -{ -public: - //! constructor - CImageWriterPNG(); - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const c8* fileName); - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param); -private: - u8** RowPointers; //Used to point to image rows -}; - -} // namespace video -} // namespace irr - -#endif // _C_IMAGE_WRITER_PNG_H_INCLUDED__ +#ifndef _C_IMAGE_WRITER_PNG_H_INCLUDED__ +#define _C_IMAGE_WRITER_PNG_H_INCLUDED__ + +#include "IImageWriter.h" + +namespace irr +{ +namespace video +{ + +class CImageWriterPNG : public IImageWriter +{ +public: + //! constructor + CImageWriterPNG(); + + //! return true if this writer can write a file with the given extension + virtual bool isAWriteableFileExtension(const c8* fileName); + + //! write image to file + virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param); +private: + u8** RowPointers; //Used to point to image rows +}; + +} // namespace video +} // namespace irr + +#endif // _C_IMAGE_WRITER_PNG_H_INCLUDED__ diff --git a/src/dep/src/irrlicht/CImageWriterPPM.cpp b/src/dep/src/irrlicht/CImageWriterPPM.cpp index 86a2104..9357188 100644 --- a/src/dep/src/irrlicht/CImageWriterPPM.cpp +++ b/src/dep/src/irrlicht/CImageWriterPPM.cpp @@ -1,68 +1,68 @@ - -#include "CImageWriterPPM.h" -#include "IWriteFile.h" -#include "IImage.h" -#include "dimension2d.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -IImageWriter* createImageWriterPPM() -{ - return new CImageWriterPPM; -} - -CImageWriterPPM::CImageWriterPPM() -{ -#ifdef _DEBUG - setDebugName("CImageWriterPPM"); -#endif -} - -bool CImageWriterPPM::isAWriteableFileExtension(const c8* fileName) -{ - return strstr(fileName, ".ppm") != 0; -} - -bool CImageWriterPPM::writeImage(io::IWriteFile *file, IImage *image,u32 param) -{ - char cache[70]; - char size; - - const core::dimension2d& imageSize = image->getDimension(); - - size = snprintf(cache, 70, "P3\n"); - if (file->write(cache, size) != size) - return false; - - size = snprintf(cache, 70, "%d %d\n", imageSize.Width, imageSize.Height); - if (file->write(cache, size) != size) - return false; - - size = snprintf(cache, 70, "255\n"); - if (file->write(cache, size) != size) - return false; - - s32 n = 0; - - s32 r; - for (r = 0; r < imageSize.Height; ++r) - { - s32 c; - for (c = 0; c < imageSize.Width; ++c, ++n) - { - const video::SColor& pixel = image->getPixel(c, r); - size = snprintf(cache, 70, "%.3d %.3d %.3d%s", pixel.getRed(), pixel.getGreen(), pixel.getBlue(), n % 5 == 4 ? "\n" : " "); - if (file->write(cache, size) != size) - return false; - } - } - - return true; -} - -} // namespace video -} // namespace irr + +#include "CImageWriterPPM.h" +#include "IWriteFile.h" +#include "IImage.h" +#include "dimension2d.h" +#include "irrString.h" + +namespace irr +{ +namespace video +{ + +IImageWriter* createImageWriterPPM() +{ + return new CImageWriterPPM; +} + +CImageWriterPPM::CImageWriterPPM() +{ +#ifdef _DEBUG + setDebugName("CImageWriterPPM"); +#endif +} + +bool CImageWriterPPM::isAWriteableFileExtension(const c8* fileName) +{ + return strstr(fileName, ".ppm") != 0; +} + +bool CImageWriterPPM::writeImage(io::IWriteFile *file, IImage *image,u32 param) +{ + char cache[70]; + char size; + + const core::dimension2d& imageSize = image->getDimension(); + + size = snprintf(cache, 70, "P3\n"); + if (file->write(cache, size) != size) + return false; + + size = snprintf(cache, 70, "%d %d\n", imageSize.Width, imageSize.Height); + if (file->write(cache, size) != size) + return false; + + size = snprintf(cache, 70, "255\n"); + if (file->write(cache, size) != size) + return false; + + s32 n = 0; + + s32 r; + for (r = 0; r < imageSize.Height; ++r) + { + s32 c; + for (c = 0; c < imageSize.Width; ++c, ++n) + { + const video::SColor& pixel = image->getPixel(c, r); + size = snprintf(cache, 70, "%.3d %.3d %.3d%s", pixel.getRed(), pixel.getGreen(), pixel.getBlue(), n % 5 == 4 ? "\n" : " "); + if (file->write(cache, size) != size) + return false; + } + } + + return true; +} + +} // namespace video +} // namespace irr diff --git a/src/dep/src/irrlicht/CImageWriterPPM.h b/src/dep/src/irrlicht/CImageWriterPPM.h index b3f91c5..21c02d4 100644 --- a/src/dep/src/irrlicht/CImageWriterPPM.h +++ b/src/dep/src/irrlicht/CImageWriterPPM.h @@ -1,27 +1,27 @@ -#ifndef _C_IMAGE_WRITER_PPM_H_INCLUDED__ -#define _C_IMAGE_WRITER_PPM_H_INCLUDED__ - -#include "IImageWriter.h" - -namespace irr -{ -namespace video -{ - -class CImageWriterPPM : public IImageWriter -{ -public: - //! constructor - CImageWriterPPM(); - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const c8* fileName); - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param); -}; - -} // namespace video -} // namespace irr - -#endif // _C_IMAGE_WRITER_PPM_H_INCLUDED__ +#ifndef _C_IMAGE_WRITER_PPM_H_INCLUDED__ +#define _C_IMAGE_WRITER_PPM_H_INCLUDED__ + +#include "IImageWriter.h" + +namespace irr +{ +namespace video +{ + +class CImageWriterPPM : public IImageWriter +{ +public: + //! constructor + CImageWriterPPM(); + + //! return true if this writer can write a file with the given extension + virtual bool isAWriteableFileExtension(const c8* fileName); + + //! write image to file + virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param); +}; + +} // namespace video +} // namespace irr + +#endif // _C_IMAGE_WRITER_PPM_H_INCLUDED__ diff --git a/src/dep/src/irrlicht/CImageWriterPSD.cpp b/src/dep/src/irrlicht/CImageWriterPSD.cpp index d43b84e..9790042 100644 --- a/src/dep/src/irrlicht/CImageWriterPSD.cpp +++ b/src/dep/src/irrlicht/CImageWriterPSD.cpp @@ -1,37 +1,37 @@ - -#include "CImageWriterPSD.h" -#include "CImageLoaderPSD.h" -#include "IWriteFile.h" -#include "os.h" // for logging -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -IImageWriter* createImageWriterPSD() -{ - return new CImageWriterPSD; -} - -CImageWriterPSD::CImageWriterPSD() -{ -#ifdef _DEBUG - setDebugName("CImageWriterPSD"); -#endif -} - -bool CImageWriterPSD::isAWriteableFileExtension(const c8* fileName) -{ - return strstr(fileName, ".psd") != 0; -} - -bool CImageWriterPSD::writeImage(io::IWriteFile *file, IImage *image,u32 param) -{ - os::Printer::log("PSD writer not yet implemented. Image not written.", ELL_WARNING); - return false; -} - -} // namespace video -} // namespace irr + +#include "CImageWriterPSD.h" +#include "CImageLoaderPSD.h" +#include "IWriteFile.h" +#include "os.h" // for logging +#include "irrString.h" + +namespace irr +{ +namespace video +{ + +IImageWriter* createImageWriterPSD() +{ + return new CImageWriterPSD; +} + +CImageWriterPSD::CImageWriterPSD() +{ +#ifdef _DEBUG + setDebugName("CImageWriterPSD"); +#endif +} + +bool CImageWriterPSD::isAWriteableFileExtension(const c8* fileName) +{ + return strstr(fileName, ".psd") != 0; +} + +bool CImageWriterPSD::writeImage(io::IWriteFile *file, IImage *image,u32 param) +{ + os::Printer::log("PSD writer not yet implemented. Image not written.", ELL_WARNING); + return false; +} + +} // namespace video +} // namespace irr diff --git a/src/dep/src/irrlicht/CImageWriterPSD.h b/src/dep/src/irrlicht/CImageWriterPSD.h index 3a42f06..9926c4a 100644 --- a/src/dep/src/irrlicht/CImageWriterPSD.h +++ b/src/dep/src/irrlicht/CImageWriterPSD.h @@ -1,27 +1,27 @@ -#ifndef _C_IMAGE_WRITER_PSD_H_INCLUDED__ -#define _C_IMAGE_WRITER_PSD_H_INCLUDED__ - -#include "IImageWriter.h" - -namespace irr -{ -namespace video -{ - -class CImageWriterPSD : public IImageWriter -{ -public: - //! constructor - CImageWriterPSD(); - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const c8* fileName); - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image,u32 param); -}; - -} // namespace video -} // namespace irr - -#endif // _I_IMAGE_WRITER_PSD_H_INCLUDED__ +#ifndef _C_IMAGE_WRITER_PSD_H_INCLUDED__ +#define _C_IMAGE_WRITER_PSD_H_INCLUDED__ + +#include "IImageWriter.h" + +namespace irr +{ +namespace video +{ + +class CImageWriterPSD : public IImageWriter +{ +public: + //! constructor + CImageWriterPSD(); + + //! return true if this writer can write a file with the given extension + virtual bool isAWriteableFileExtension(const c8* fileName); + + //! write image to file + virtual bool writeImage(io::IWriteFile *file, IImage *image,u32 param); +}; + +} // namespace video +} // namespace irr + +#endif // _I_IMAGE_WRITER_PSD_H_INCLUDED__ diff --git a/src/dep/src/irrlicht/CImageWriterTGA.cpp b/src/dep/src/irrlicht/CImageWriterTGA.cpp index a655ed9..c1db746 100644 --- a/src/dep/src/irrlicht/CImageWriterTGA.cpp +++ b/src/dep/src/irrlicht/CImageWriterTGA.cpp @@ -1,134 +1,134 @@ - -#include "CImageWriterTGA.h" -#include "CImageLoaderTGA.h" -#include "IWriteFile.h" -#include "CColorConverter.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -IImageWriter* createImageWriterTGA() -{ - return new CImageWriterTGA; -} - -CImageWriterTGA::CImageWriterTGA() -{ -#ifdef _DEBUG - setDebugName("CImageWriterTGA"); -#endif -} - -bool CImageWriterTGA::isAWriteableFileExtension(const c8* fileName) -{ - return strstr(fileName, ".tga") != 0; -} - -bool CImageWriterTGA::writeImage(io::IWriteFile *file, IImage *image,u32 param) -{ - STGAHeader imageHeader; - imageHeader.IdLength = 0; - imageHeader.ColorMapType = 0; - imageHeader.ImageType = 2; - imageHeader.FirstEntryIndex[0] = 0; - imageHeader.FirstEntryIndex[1] = 0; - imageHeader.ColorMapLength = 0; - imageHeader.ColorMapEntrySize = 0; - imageHeader.XOrigin[0] = 0; - imageHeader.XOrigin[1] = 0; - imageHeader.YOrigin[0] = 0; - imageHeader.YOrigin[1] = 0; - imageHeader.ImageWidth = image->getDimension().Width; - imageHeader.ImageHeight = image->getDimension().Height; - - // top left of image is the top. the image loader needs to - // be fixed to only swap/flip - imageHeader.ImageDescriptor = (1 << 5); - - // chances are good we'll need to swizzle data, so i'm going - // to convert and write one scan line at a time. it's also - // a bit cleaner this way - void (*CColorConverter_convertFORMATtoFORMAT)(const void*, s32, void*) = 0; - switch(image->getColorFormat()) - { - case ECF_A8R8G8B8: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_A8R8G8B8toA8R8G8B8; - imageHeader.PixelDepth = 32; - imageHeader.ImageDescriptor |= 8; - break; - case ECF_A1R5G5B5: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_A1R5G5B5toA1R5G5B5; - imageHeader.PixelDepth = 16; - imageHeader.ImageDescriptor |= 1; - break; - case ECF_R5G6B5: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_R5G6B5toA1R5G5B5; - imageHeader.PixelDepth = 16; - imageHeader.ImageDescriptor |= 1; - break; - case ECF_R8G8B8: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_R8G8B8toR8G8B8; - imageHeader.PixelDepth = 24; - imageHeader.ImageDescriptor |= 0; - break; - } - - // couldn't find a color converter - if (!CColorConverter_convertFORMATtoFORMAT) - return false; - - if (file->write(&imageHeader, sizeof(imageHeader)) != sizeof(imageHeader)) - return false; - - u8* scan_lines = (u8*)image->lock(); - if (!scan_lines) - return false; - - // size of one pixel in bytes - u32 pixel_size = image->getBytesPerPixel(); - - // length of one row of the source image in bytes - u32 row_stride = (pixel_size * imageHeader.ImageWidth); - - // length of one output row in bytes - s32 row_size = ((imageHeader.PixelDepth / 8) * imageHeader.ImageWidth); - - // allocate a row do translate data into - u8* row_pointer = new u8[row_size]; - - u32 y; - for (y = 0; y < imageHeader.ImageHeight; ++y) - { - // source, length [pixels], destination - if (image->getColorFormat()==ECF_R8G8B8) - CColorConverter::convert24BitTo24Bit(&scan_lines[y * row_stride], row_pointer, imageHeader.ImageWidth, 1, 0, 0, true); - else - CColorConverter_convertFORMATtoFORMAT(&scan_lines[y * row_stride], imageHeader.ImageWidth, row_pointer); - if (file->write(row_pointer, row_size) != row_size) - break; - } - - delete [] row_pointer; - - image->unlock(); - - STGAFooter imageFooter; - imageFooter.ExtensionOffset = 0; - imageFooter.DeveloperOffset = 0; - strncpy(imageFooter.Signature, "TRUEVISION-XFILE.", 18); - - if (file->write(&imageFooter, sizeof(imageFooter)) < (s32)sizeof(imageFooter)) - return false; - - return imageHeader.ImageHeight < y; -} - -} // namespace video -} // namespace irr + +#include "CImageWriterTGA.h" +#include "CImageLoaderTGA.h" +#include "IWriteFile.h" +#include "CColorConverter.h" +#include "irrString.h" + +namespace irr +{ +namespace video +{ + +IImageWriter* createImageWriterTGA() +{ + return new CImageWriterTGA; +} + +CImageWriterTGA::CImageWriterTGA() +{ +#ifdef _DEBUG + setDebugName("CImageWriterTGA"); +#endif +} + +bool CImageWriterTGA::isAWriteableFileExtension(const c8* fileName) +{ + return strstr(fileName, ".tga") != 0; +} + +bool CImageWriterTGA::writeImage(io::IWriteFile *file, IImage *image,u32 param) +{ + STGAHeader imageHeader; + imageHeader.IdLength = 0; + imageHeader.ColorMapType = 0; + imageHeader.ImageType = 2; + imageHeader.FirstEntryIndex[0] = 0; + imageHeader.FirstEntryIndex[1] = 0; + imageHeader.ColorMapLength = 0; + imageHeader.ColorMapEntrySize = 0; + imageHeader.XOrigin[0] = 0; + imageHeader.XOrigin[1] = 0; + imageHeader.YOrigin[0] = 0; + imageHeader.YOrigin[1] = 0; + imageHeader.ImageWidth = image->getDimension().Width; + imageHeader.ImageHeight = image->getDimension().Height; + + // top left of image is the top. the image loader needs to + // be fixed to only swap/flip + imageHeader.ImageDescriptor = (1 << 5); + + // chances are good we'll need to swizzle data, so i'm going + // to convert and write one scan line at a time. it's also + // a bit cleaner this way + void (*CColorConverter_convertFORMATtoFORMAT)(const void*, s32, void*) = 0; + switch(image->getColorFormat()) + { + case ECF_A8R8G8B8: + CColorConverter_convertFORMATtoFORMAT + = CColorConverter::convert_A8R8G8B8toA8R8G8B8; + imageHeader.PixelDepth = 32; + imageHeader.ImageDescriptor |= 8; + break; + case ECF_A1R5G5B5: + CColorConverter_convertFORMATtoFORMAT + = CColorConverter::convert_A1R5G5B5toA1R5G5B5; + imageHeader.PixelDepth = 16; + imageHeader.ImageDescriptor |= 1; + break; + case ECF_R5G6B5: + CColorConverter_convertFORMATtoFORMAT + = CColorConverter::convert_R5G6B5toA1R5G5B5; + imageHeader.PixelDepth = 16; + imageHeader.ImageDescriptor |= 1; + break; + case ECF_R8G8B8: + CColorConverter_convertFORMATtoFORMAT + = CColorConverter::convert_R8G8B8toR8G8B8; + imageHeader.PixelDepth = 24; + imageHeader.ImageDescriptor |= 0; + break; + } + + // couldn't find a color converter + if (!CColorConverter_convertFORMATtoFORMAT) + return false; + + if (file->write(&imageHeader, sizeof(imageHeader)) != sizeof(imageHeader)) + return false; + + u8* scan_lines = (u8*)image->lock(); + if (!scan_lines) + return false; + + // size of one pixel in bytes + u32 pixel_size = image->getBytesPerPixel(); + + // length of one row of the source image in bytes + u32 row_stride = (pixel_size * imageHeader.ImageWidth); + + // length of one output row in bytes + s32 row_size = ((imageHeader.PixelDepth / 8) * imageHeader.ImageWidth); + + // allocate a row do translate data into + u8* row_pointer = new u8[row_size]; + + u32 y; + for (y = 0; y < imageHeader.ImageHeight; ++y) + { + // source, length [pixels], destination + if (image->getColorFormat()==ECF_R8G8B8) + CColorConverter::convert24BitTo24Bit(&scan_lines[y * row_stride], row_pointer, imageHeader.ImageWidth, 1, 0, 0, true); + else + CColorConverter_convertFORMATtoFORMAT(&scan_lines[y * row_stride], imageHeader.ImageWidth, row_pointer); + if (file->write(row_pointer, row_size) != row_size) + break; + } + + delete [] row_pointer; + + image->unlock(); + + STGAFooter imageFooter; + imageFooter.ExtensionOffset = 0; + imageFooter.DeveloperOffset = 0; + strncpy(imageFooter.Signature, "TRUEVISION-XFILE.", 18); + + if (file->write(&imageFooter, sizeof(imageFooter)) < (s32)sizeof(imageFooter)) + return false; + + return imageHeader.ImageHeight < y; +} + +} // namespace video +} // namespace irr diff --git a/src/dep/src/irrlicht/CImageWriterTGA.h b/src/dep/src/irrlicht/CImageWriterTGA.h index 965cfc1..99cd570 100644 --- a/src/dep/src/irrlicht/CImageWriterTGA.h +++ b/src/dep/src/irrlicht/CImageWriterTGA.h @@ -1,27 +1,27 @@ -#ifndef _C_IMAGE_WRITER_TGA_H_INCLUDED__ -#define _C_IMAGE_WRITER_TGA_H_INCLUDED__ - -#include "IImageWriter.h" - -namespace irr -{ -namespace video -{ - -class CImageWriterTGA : public IImageWriter -{ -public: - //! constructor - CImageWriterTGA(); - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const c8* fileName); - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image,u32 param); -}; - -} // namespace video -} // namespace irr - -#endif // _C_IMAGE_WRITER_TGA_H_INCLUDED__ +#ifndef _C_IMAGE_WRITER_TGA_H_INCLUDED__ +#define _C_IMAGE_WRITER_TGA_H_INCLUDED__ + +#include "IImageWriter.h" + +namespace irr +{ +namespace video +{ + +class CImageWriterTGA : public IImageWriter +{ +public: + //! constructor + CImageWriterTGA(); + + //! return true if this writer can write a file with the given extension + virtual bool isAWriteableFileExtension(const c8* fileName); + + //! write image to file + virtual bool writeImage(io::IWriteFile *file, IImage *image,u32 param); +}; + +} // namespace video +} // namespace irr + +#endif // _C_IMAGE_WRITER_TGA_H_INCLUDED__ diff --git a/src/dep/src/irrlicht/CIrrDeviceLinux.cpp b/src/dep/src/irrlicht/CIrrDeviceLinux.cpp index 3db8d7a..9aa918a 100644 --- a/src/dep/src/irrlicht/CIrrDeviceLinux.cpp +++ b/src/dep/src/irrlicht/CIrrDeviceLinux.cpp @@ -1,1190 +1,1190 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CIrrDeviceLinux.h" - -#ifdef LINUX - -#include -#include -#include -#include -#include "IEventReceiver.h" -#include "irrList.h" -#include "os.h" -#include "CTimer.h" -#include "irrString.h" -#include "Keycodes.h" -#include "COSOperator.h" -#include "CColorConverter.h" -#include "SIrrCreationParameters.h" - -namespace irr -{ - namespace video - { - IVideoDriver* createOpenGLDriver(const core::dimension2d& screenSize, - bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias); - } -} // end namespace irr - - - -namespace irr -{ - -const char* wmDeleteWindow = "WM_DELETE_WINDOW"; - -//! constructor -CIrrDeviceLinux::CIrrDeviceLinux(video::E_DRIVER_TYPE driverType, - const core::dimension2d& windowSize, - u32 bits, bool fullscreen, - bool sbuffer, bool vsync, bool antiAlias, - IEventReceiver* receiver, - const char* version) - : CIrrDeviceStub(version, receiver), -#ifdef _IRR_COMPILE_WITH_X11_ - display(0), screennr(0), window(0), SoftwareImage(0), -#endif - Fullscreen(fullscreen), StencilBuffer(sbuffer), AntiAlias(antiAlias), DriverType(driverType), - Width(windowSize.Width), Height(windowSize.Height), Depth(24), - Close(false), WindowActive(false), WindowMinimized(false), UseXVidMode(false), UseXRandR(false), UseGLXWindow(false) -{ - #ifdef _DEBUG - setDebugName("CIrrDeviceLinux"); - #endif - - // print version, distribution etc. - // thx to LynxLuna for pointing me to the uname function - core::stringc linuxversion; - struct utsname LinuxInfo; - uname(&LinuxInfo); - - linuxversion += LinuxInfo.sysname; - linuxversion += " "; - linuxversion += LinuxInfo.release; - linuxversion += " "; - linuxversion += LinuxInfo.version; - linuxversion += " "; - linuxversion += LinuxInfo.machine; - - Operator = new COSOperator(linuxversion.c_str()); - os::Printer::log(linuxversion.c_str(), ELL_INFORMATION); - - // create keymap - createKeyMap(); - - // create window - if (driverType != video::EDT_NULL) - { - // create the window, only if we do not use the null device - if (!createWindow(windowSize, bits)) - return; - } - - // create cursor control - CursorControl = new CCursorControl(this, driverType == video::EDT_NULL); - - // create driver - createDriver(windowSize, bits, vsync); - - if (!VideoDriver) - return; - - createGUIAndScene(); -} - - - -//! destructor -CIrrDeviceLinux::~CIrrDeviceLinux() -{ -#ifdef _IRR_COMPILE_WITH_X11_ - if (display) - { - //os::Printer::log("Deleting window...", ELL_INFORMATION); - - #ifdef _IRR_COMPILE_WITH_OPENGL_ - if (Context) - { - if (!glXMakeCurrent(display, None, NULL)) - os::Printer::log("Could not release glx context.", ELL_WARNING); - glXDestroyContext(display, Context); - if (UseGLXWindow) - glXDestroyWindow(display, glxWin); - Context = 0; - } - #endif // #ifdef _IRR_COMPILE_WITH_OPENGL_ - - #ifdef _IRR_LINUX_X11_VIDMODE_ - if (UseXVidMode && Fullscreen) - { - XF86VidModeSwitchToMode(display, screennr, &oldVideoMode); - XF86VidModeSetViewPort(display, screennr, 0, 0); - } - #endif - #ifdef _IRR_LINUX_X11_RANDR_ - if (UseXRandR && Fullscreen) - { - XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display)); - XRRSetScreenConfig(display,config,DefaultRootWindow(display),oldRandrMode,oldRandrRotation,CurrentTime); - XRRFreeScreenConfigInfo(config); - } - #endif - - if (DriverType == video::EDT_SOFTWARE || DriverType == video::EDT_BURNINGSVIDEO) - XDestroyImage(SoftwareImage); - XDestroyWindow(display,window); - XCloseDisplay(display); - } -#endif // #ifdef _IRR_COMPILE_WITH_X11_ -} - - - -#if defined(_IRR_COMPILE_WITH_X11_) && defined(_DEBUG) -int IrrPrintXError(Display *display, XErrorEvent *event) -{ - char msg[256]; - - XGetErrorText(display, event->error_code, msg, 256); - os::Printer::log("XErrorEvent", msg, ELL_WARNING); - return 0; -} -#endif - - - -bool CIrrDeviceLinux::createWindow(const core::dimension2d& windowSize, - u32 bits) -{ - Width = windowSize.Width; - Height = windowSize.Height; - -#ifdef _IRR_COMPILE_WITH_X11_ -#ifdef _DEBUG - os::Printer::log("Creating X window...", ELL_INFORMATION); - XSetErrorHandler(IrrPrintXError); -#endif - - display = XOpenDisplay(0); - if (!display) - { - os::Printer::log("Error: Need running XServer to start Irrlicht Engine.", ELL_ERROR); - return false; - } - - screennr = DefaultScreen(display); - - // query extension - - if (Fullscreen) - { - s32 eventbase, errorbase; - s32 bestMode = -1; - s32 defaultDepth=DefaultDepth(display,screennr); - - #ifdef _IRR_LINUX_X11_VIDMODE_ - if (XF86VidModeQueryExtension(display, &eventbase, &errorbase)) - { - // enumerate video modes - s32 modeCount; - XF86VidModeModeInfo** modes; - - XF86VidModeGetAllModeLines(display, screennr, &modeCount, &modes); - - // save current video mode - oldVideoMode = *modes[0]; - - // find fitting mode - - VideoModeList.setDesktop(defaultDepth, core::dimension2d( - modes[0]->hdisplay, modes[0]->vdisplay)); - for (s32 i = 0; ihdisplay >= Width && modes[i]->vdisplay >= Height) - bestMode = i; - else if (bestMode!=-1 && modes[i]->hdisplay >= Width && modes[i]->vdisplay >= Height && modes[i]->hdisplay < modes[bestMode]->hdisplay && modes[i]->vdisplay < modes[bestMode]->vdisplay) - bestMode = i; - VideoModeList.addMode(core::dimension2d( - modes[i]->hdisplay, modes[i]->vdisplay), defaultDepth); - } - if (bestMode != -1) - { - os::Printer::log("Starting fullscreen mode...", ELL_INFORMATION); - XF86VidModeSwitchToMode(display, screennr, modes[bestMode]); - XF86VidModeSetViewPort(display, screennr, 0, 0); - UseXVidMode=true; - } - else - { - os::Printer::log("Could not find specified video mode, running windowed.", ELL_WARNING); - Fullscreen = false; - } - - XFree(modes); - } - else - #endif - #ifdef _IRR_LINUX_X11_RANDR_ - if (XRRQueryExtension(display, &eventbase, &errorbase)) - { - s32 modeCount; - XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display)); - oldRandrMode=XRRConfigCurrentConfiguration(config,&oldRandrRotation); - XRRScreenSize *modes=XRRConfigSizes(config,&modeCount); - VideoModeList.setDesktop(defaultDepth, core::dimension2d( - modes[oldRandrMode].width, modes[oldRandrMode].height)); - for (s32 i = 0; i= Width && modes[i].height >= Height) - bestMode = i; - VideoModeList.addMode(core::dimension2d( - modes[i].width, modes[i].height), defaultDepth); - } - if (bestMode != -1) - { - XRRSetScreenConfig(display,config,DefaultRootWindow(display),bestMode,oldRandrRotation,CurrentTime); - UseXRandR=true; - } - XRRFreeScreenConfigInfo(config); - } - else - #endif - { - os::Printer::log("VidMode extension must be installed to allow Irrlicht " - "to switch to fullscreen mode. Running in windowed mode instead.", ELL_WARNING); - Fullscreen = false; - } - } - - // get visual - XVisualInfo* visual = 0; - -#ifdef _IRR_COMPILE_WITH_OPENGL_ - - Context=0; - GLXFBConfig glxFBConfig; - int major, minor; - bool isAvailableGLX=false; - if (DriverType==video::EDT_OPENGL) - { - isAvailableGLX=glXQueryExtension(display,&major,&minor); - if (isAvailableGLX && glXQueryVersion(display, &major, &minor)) - { - if (major==1 && minor>2) - { - const int MAX_SAMPLES = 16; - // attribute array for the draw buffer - int visualAttrBuffer[] = - { - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_RED_SIZE, 4, - GLX_GREEN_SIZE, 4, - GLX_BLUE_SIZE, 4, - GLX_ALPHA_SIZE, 4, - GLX_DEPTH_SIZE, 16, - GLX_DOUBLEBUFFER, GL_TRUE, - GLX_STENCIL_SIZE, 1, - GLX_SAMPLE_BUFFERS_ARB, GL_TRUE, - GLX_SAMPLES_ARB, MAX_SAMPLES, - None - }; - - GLXFBConfig *configList=0; - int nitems=0; - if (!AntiAlias) - { - visualAttrBuffer[17] = GL_FALSE; - visualAttrBuffer[19] = 0; - } - if (StencilBuffer) - { - configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - if (!configList && AntiAlias) - { - while (!configList && (visualAttrBuffer[19]>1)) - { - visualAttrBuffer[19] >>= 1; - configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - } - if (!configList) - { - visualAttrBuffer[17] = GL_FALSE; - visualAttrBuffer[19] = 0; - configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - if (configList) - { - os::Printer::log("No FSAA available.", ELL_WARNING); - AntiAlias=false; - } - else - { - //reenable multisampling - visualAttrBuffer[17] = GL_TRUE; - visualAttrBuffer[19] = MAX_SAMPLES; - } - } - } - } - // Next try without stencil buffer - if (!configList) - { - if (StencilBuffer) - os::Printer::log("No stencilbuffer available, disabling stencil shadows.", ELL_WARNING); - StencilBuffer = false; - visualAttrBuffer[15]=0; - - configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - if (!configList && AntiAlias) - { - while (!configList && (visualAttrBuffer[19]>1)) - { - visualAttrBuffer[19] >>= 1; - configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - } - if (!configList) - { - visualAttrBuffer[17] = GL_FALSE; - visualAttrBuffer[19] = 0; - configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - if (configList) - { - os::Printer::log("No FSAA available.", ELL_WARNING); - AntiAlias=false; - } - else - { - //reenable multisampling - visualAttrBuffer[17] = GL_TRUE; - visualAttrBuffer[19] = MAX_SAMPLES; - } - } - } - } - // Next try without double buffer - if (!configList) - { - os::Printer::log("No doublebuffering available.", ELL_WARNING); - visualAttrBuffer[13] = GL_FALSE; - configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - if (!configList && AntiAlias) - { - while (!configList && (visualAttrBuffer[19]>1)) - { - visualAttrBuffer[19] >>= 1; - configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - } - if (!configList) - { - visualAttrBuffer[17] = GL_FALSE; - visualAttrBuffer[19] = 0; - configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - if (configList) - { - os::Printer::log("No FSAA available.", ELL_WARNING); - AntiAlias=false; - } - else - { - //reenable multisampling - visualAttrBuffer[17] = GL_TRUE; - visualAttrBuffer[19] = MAX_SAMPLES; - } - } - } - } - if (configList) - { - glxFBConfig=configList[0]; - XFree(configList); - UseGLXWindow=true; - visual = glXGetVisualFromFBConfig(display,glxFBConfig); - } - } - else - { - // attribute array for the draw buffer - int visualAttrBuffer[] = - { - GLX_RGBA, GL_TRUE, - GLX_RED_SIZE, 4, - GLX_GREEN_SIZE, 4, - GLX_BLUE_SIZE, 4, - GLX_ALPHA_SIZE, 4, - GLX_DEPTH_SIZE, 16, - GLX_DOUBLEBUFFER, GL_TRUE, - GLX_STENCIL_SIZE, 1, - None - }; - - if (StencilBuffer) - visual=glXChooseVisual(display, screennr, visualAttrBuffer); - if (!visual) - { - if (StencilBuffer) - { - os::Printer::log("No stencilbuffer available, disabling stencil shadows.", ELL_WARNING); - StencilBuffer = false; - } - visualAttrBuffer[15]=0; - - visual=glXChooseVisual(display, screennr, visualAttrBuffer); - if (!visual) - { - os::Printer::log("No doublebuffering available.", ELL_WARNING); - visualAttrBuffer[13] = GL_FALSE; - visual=glXChooseVisual(display, screennr, visualAttrBuffer); - } - } - } - } - else - os::Printer::log("No GLX support available. OpenGL driver will not work.", ELL_WARNING); - } - -#endif // _IRR_COMPILE_WITH_OPENGL_ - - // create visual with standard X methods - if (!visual) - { - XVisualInfo visTempl; //Template to hold requested values - int visNumber; // Return value of available visuals - - visTempl.screen = screennr; - visTempl.depth = 16; - while ((!visual) && (visTempl.depth<=32)) - { - visual = XGetVisualInfo(display, VisualScreenMask|VisualDepthMask, - &visTempl, &visNumber); - visTempl.depth+=8; - } - } - - if (!visual) - { - os::Printer::log("Fatal error, could not get visual.", ELL_ERROR); - XCloseDisplay(display); - display=0; - return false; - } - - // create color map - Colormap colormap; - colormap = XCreateColormap(display, - RootWindow(display, visual->screen), - visual->visual, AllocNone); - - attributes.colormap = colormap; - attributes.border_pixel = 0; - attributes.event_mask = KeyPressMask | ButtonPressMask | - StructureNotifyMask | PointerMotionMask | - ButtonReleaseMask | KeyReleaseMask; - - // create Window, either for Fullscreen or windowed mode - if (Fullscreen) - { - attributes.override_redirect = True; - - window = XCreateWindow(display, - RootWindow(display, visual->screen), - 0, 0, Width, Height, 0, visual->depth, - InputOutput, visual->visual, - CWBorderPixel | CWColormap | CWEventMask | - CWOverrideRedirect, &attributes); - - XWarpPointer(display, None, window, 0, 0, 0, 0, 0, 0); - XMapRaised(display, window); - XGrabKeyboard(display, window, True, GrabModeAsync, - GrabModeAsync, CurrentTime); - XGrabPointer(display, window, True, ButtonPressMask, - GrabModeAsync, GrabModeAsync, window, None, CurrentTime); - } - else - { // we want windowed mode - attributes.event_mask |= ExposureMask; - attributes.event_mask |= FocusChangeMask; - - window = XCreateWindow(display, - RootWindow(display, visual->screen), - 0, 0, Width, Height, 0, visual->depth, - InputOutput, visual->visual, - CWBorderPixel | CWColormap | CWEventMask, - &attributes); - - Atom wmDelete; - wmDelete = XInternAtom(display, wmDeleteWindow, True); - XSetWMProtocols(display, window, &wmDelete, 1); - XMapRaised(display, window); - } - WindowActive=true; - -#ifdef _IRR_COMPILE_WITH_OPENGL_ - - // connect glx context to window - if (isAvailableGLX && DriverType==video::EDT_OPENGL) - { - if (UseGLXWindow) - { - glxWin=glXCreateWindow(display,glxFBConfig,window,NULL); - if (glxWin) - { - // create glx context - Context = glXCreateNewContext(display, glxFBConfig, GLX_RGBA_TYPE, NULL, True); - if (Context) - { - if (!glXMakeContextCurrent(display, glxWin, glxWin, Context)) - { - os::Printer::log("Could not make context current.", ELL_WARNING); - glXDestroyContext(display, Context); - } - } - else - { - os::Printer::log("Could not create GLX rendering context.", ELL_WARNING); - } - } - else - { - os::Printer::log("Could not create GLX window.", ELL_WARNING); - } - } - else - { - Context = glXCreateContext(display, visual, NULL, True); - if (Context) - { - if (!glXMakeCurrent(display, window, Context)) - { - os::Printer::log("Could not make context current.", ELL_WARNING); - glXDestroyContext(display, Context); - } - } - else - { - os::Printer::log("Could not create GLX rendering context.", ELL_WARNING); - } - } - } -#endif // _IRR_COMPILE_WITH_OPENGL_ - - Window tmp; - u32 borderWidth; - int x,y; - - XGetGeometry(display, window, &tmp, &x, &y, &Width, &Height, &borderWidth, &Depth); - - // create an XImage for the software renderer - //(thx to Nadav for some clues on how to do that!) - - if (DriverType == video::EDT_SOFTWARE || DriverType == video::EDT_BURNINGSVIDEO) - { - SoftwareImage = XCreateImage(display, - visual->visual, visual->depth, - ZPixmap, 0, 0, Width, Height, - BitmapPad(display), 0); - - SoftwareImage->data = new char[SoftwareImage->bytes_per_line * SoftwareImage->height]; - } - - XFree(visual); -#endif // #ifdef _IRR_COMPILE_WITH_X11_ - return true; -} - - -//! create the driver -void CIrrDeviceLinux::createDriver(const core::dimension2d& windowSize, - u32 bits, bool vsync) -{ - switch(DriverType) - { -#ifdef _IRR_COMPILE_WITH_X11_ - - case video::EDT_SOFTWARE: - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - VideoDriver = video::createSoftwareDriver(windowSize, Fullscreen, FileSystem, this); - #else - os::Printer::log("No Software driver support compiled in.", ELL_WARNING); - #endif - break; - - case video::EDT_BURNINGSVIDEO: - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - VideoDriver = video::createSoftwareDriver2(windowSize, Fullscreen, FileSystem, this); - #else - os::Printer::log("Burning's video driver was not compiled in.", ELL_WARNING); - #endif - break; - - case video::EDT_OPENGL: - #ifdef _IRR_COMPILE_WITH_OPENGL_ - if (Context) - VideoDriver = video::createOpenGLDriver(windowSize, Fullscreen, StencilBuffer, FileSystem, vsync, AntiAlias); - #else - os::Printer::log("No OpenGL support compiled in.", ELL_WARNING); - #endif - break; - - case video::EDT_DIRECT3D8: - case video::EDT_DIRECT3D9: - os::Printer::log("This driver is not available in Linux. Try OpenGL or Software renderer.", - ELL_WARNING); - break; - - default: - VideoDriver = video::createNullDriver(FileSystem, windowSize); - break; -#else - case video::EDT_NULL: - VideoDriver = video::createNullDriver(FileSystem, windowSize); - break; - default: - os::Printer::log("No X11 support compiled in. Only Null driver available.", ELL_WARNING); - break; -#endif - } -} - - - -//! runs the device. Returns false if device wants to be deleted -bool CIrrDeviceLinux::run() -{ - os::Timer::tick(); - -#ifdef _IRR_COMPILE_WITH_X11_ - if (DriverType != video::EDT_NULL) - { - irr::SEvent irrevent; - - while (XPending(display) > 0 && !Close) - { - XNextEvent(display, &event); - - switch (event.type) - { - case ConfigureNotify: - // check for changed window size - if ((event.xconfigure.width != (int) Width) || - (event.xconfigure.height != (int) Height)) - { - Width = event.xconfigure.width; - Height = event.xconfigure.height; - if (VideoDriver) - VideoDriver->OnResize(core::dimension2d(Width, Height)); - } - break; - - case MapNotify: - WindowMinimized=false; - break; - - case UnmapNotify: - WindowMinimized=true; - break; - - case FocusIn: - WindowActive=true; - break; - - case FocusOut: - WindowActive=false; - break; - - case MotionNotify: - irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; - irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; - irrevent.MouseInput.X = event.xbutton.x; - irrevent.MouseInput.Y = event.xbutton.y; - - postEventFromUser(irrevent); - break; - - case ButtonPress: - case ButtonRelease: - - irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; - irrevent.MouseInput.X = event.xbutton.x; - irrevent.MouseInput.Y = event.xbutton.y; - - irrevent.MouseInput.Event = irr::EMIE_COUNT; - - switch(event.xbutton.button) - { - case Button1: - irrevent.MouseInput.Event = - (event.type == ButtonPress) ? irr::EMIE_LMOUSE_PRESSED_DOWN : irr::EMIE_LMOUSE_LEFT_UP; - break; - - case Button3: - irrevent.MouseInput.Event = - (event.type == ButtonPress) ? irr::EMIE_RMOUSE_PRESSED_DOWN : irr::EMIE_RMOUSE_LEFT_UP; - break; - - case Button2: - irrevent.MouseInput.Event = - (event.type == ButtonPress) ? irr::EMIE_MMOUSE_PRESSED_DOWN : irr::EMIE_MMOUSE_LEFT_UP; - break; - - case Button4: - irrevent.MouseInput.Event = EMIE_MOUSE_WHEEL; - irrevent.MouseInput.Wheel = 1.0f; - break; - - case Button5: - irrevent.MouseInput.Event = EMIE_MOUSE_WHEEL; - irrevent.MouseInput.Wheel = -1.0f; - break; - } - - if (irrevent.MouseInput.Event != irr::EMIE_COUNT) - postEventFromUser(irrevent); - break; - - case MappingNotify: - XRefreshKeyboardMapping (&event.xmapping) ; - break; - - case KeyRelease: - case KeyPress: - { - SKeyMap mp; - //mp.X11Key = XLookupKeysym(&event.xkey, 0); - char buf[5]="\0\0\0\0"; - XLookupString (&event.xkey, buf, 4, &mp.X11Key, NULL) ; - - s32 idx = KeyMap.binary_search(mp); - - if (idx != -1) - irrevent.KeyInput.Key = (EKEY_CODE)KeyMap[idx].Win32Key; - else - { - irrevent.KeyInput.Key = (EKEY_CODE)0; - os::Printer::log("Could not find win32 key for x11 key.", ELL_WARNING); - } - irrevent.EventType = irr::EET_KEY_INPUT_EVENT; - irrevent.KeyInput.PressedDown = (event.type == KeyPress); - mbtowc(&irrevent.KeyInput.Char, buf, 4); - irrevent.KeyInput.Control = (event.xkey.state & ControlMask) != 0; - irrevent.KeyInput.Shift = (event.xkey.state & ShiftMask) != 0; - postEventFromUser(irrevent); - } - break; - - case ClientMessage: - { - char *atom = XGetAtomName(display, event.xclient.message_type); - if (*atom == *wmDeleteWindow) - { - os::Printer::log("Quit message received.", ELL_INFORMATION); - Close = true; - } - XFree(atom); - } - break; - - default: - break; - } // end switch - - } // end while - } -#endif //_IRR_COMPILE_WITH_X11_ - - return !Close; -} - - -//! Pause the current process for the minimum time allowed only to allow other processes to execute -void CIrrDeviceLinux::yield() -{ - struct timespec ts = {0,0}; - nanosleep(&ts, NULL); -} - -//! Pause execution and let other processes to run for a specified amount of time. -void CIrrDeviceLinux::sleep(u32 timeMs, bool pauseTimer=false) -{ - bool wasStopped = Timer ? Timer->isStopped() : true; - - struct timespec ts; - ts.tv_sec = (time_t) (timeMs / 1000); - ts.tv_nsec = (long) (timeMs % 1000) * 1000000; - - if (pauseTimer && !wasStopped) - Timer->stop(); - - nanosleep(&ts, NULL); - - if (pauseTimer && !wasStopped) - Timer->start(); -} - -//! sets the caption of the window -void CIrrDeviceLinux::setWindowCaption(const wchar_t* text) -{ - if (DriverType == video::EDT_NULL) - return; - -#ifdef _IRR_COMPILE_WITH_X11_ - core::stringc textc = text; - XSetStandardProperties(display, window, textc.c_str(), textc.c_str(), - None, NULL, 0, NULL); -#endif -} - - - -//! presents a surface in the client area -void CIrrDeviceLinux::present(video::IImage* image, s32 windowId, core::rect* src ) -{ -#ifdef _IRR_COMPILE_WITH_X11_ - // this is only necessary for software drivers. - if (DriverType != video::EDT_SOFTWARE && DriverType != video::EDT_BURNINGSVIDEO) - return; - - // thx to Nadav, who send me some clues of how to display the image - // to the X Server. - - if (image->getColorFormat() != video::ECF_A1R5G5B5 && - image->getColorFormat() != video::ECF_A8R8G8B8) - { - os::Printer::log("Internal error, can only present A1R5G5B5 and A8R8G8B8 pictures."); - return; - } - - int destwidth = SoftwareImage->width; - int destheight = SoftwareImage->height; - int srcwidth = image->getDimension().Width; - int srcheight = image->getDimension().Height; - // clip images - srcheight = srcheight < destheight ? srcheight : destheight; - - if ( image->getColorFormat() == video::ECF_A8R8G8B8 ) - { - // display 24/32 bit image - - s32* srcdata = (s32*)image->lock(); - - if ((Depth == 32)||(Depth == 24)) - { - int destPitch = SoftwareImage->bytes_per_line; - u8* destData = reinterpret_cast(SoftwareImage->data); - - for (int y=0; ybytes_per_line; - u8* destData = reinterpret_cast(SoftwareImage->data); - - for (int y=0; yunlock(); - } - else - { - // display 16 bit image - - s16* srcdata = (s16*)image->lock(); - - if (Depth == 16) - { - // convert from A1R5G5B5 to R5G6B6 - - int destPitch = SoftwareImage->bytes_per_line; - u8* destData = reinterpret_cast(SoftwareImage->data); - - for (int y=0; ybytes_per_line; - u8* destData = reinterpret_cast(SoftwareImage->data); - - for (int y=0; yunlock(); - } - - GC gc = DefaultGC(display, DefaultScreen(display)); - XPutImage(display, window, gc, SoftwareImage, 0, 0, 0, 0, destwidth, destheight); -#endif -} - - - -//! notifies the device that it should close itself -void CIrrDeviceLinux::closeDevice() -{ - Close = true; -} - - - -//! returns if window is active. if not, nothing need to be drawn -bool CIrrDeviceLinux::isWindowActive() -{ - return WindowActive; -} - - -void CIrrDeviceLinux::createKeyMap() -{ - // I don't know if this is the best method to create - // the lookuptable, but I'll leave it like that until - // I find a better version. - -#ifdef _IRR_COMPILE_WITH_X11_ - KeyMap.push_back(SKeyMap(XK_BackSpace, KEY_BACK)); - KeyMap.push_back(SKeyMap(XK_Tab, KEY_TAB)); - KeyMap.push_back(SKeyMap(XK_Linefeed, 0)); // ??? - KeyMap.push_back(SKeyMap(XK_Clear, KEY_CLEAR)); - KeyMap.push_back(SKeyMap(XK_Return, KEY_RETURN)); - KeyMap.push_back(SKeyMap(XK_Pause, KEY_PAUSE)); - KeyMap.push_back(SKeyMap(XK_Scroll_Lock, KEY_SCROLL)); - KeyMap.push_back(SKeyMap(XK_Sys_Req, 0)); // ??? - KeyMap.push_back(SKeyMap(XK_Escape, KEY_ESCAPE)); - KeyMap.push_back(SKeyMap(XK_Delete, KEY_DELETE)); - KeyMap.push_back(SKeyMap(XK_Home, KEY_HOME)); - KeyMap.push_back(SKeyMap(XK_Left, KEY_LEFT)); - KeyMap.push_back(SKeyMap(XK_Up, KEY_UP)); - KeyMap.push_back(SKeyMap(XK_Right, KEY_RIGHT)); - KeyMap.push_back(SKeyMap(XK_Down, KEY_DOWN)); - KeyMap.push_back(SKeyMap(XK_Prior, KEY_PRIOR)); - KeyMap.push_back(SKeyMap(XK_Page_Up, KEY_PRIOR)); - KeyMap.push_back(SKeyMap(XK_Next, KEY_NEXT)); - KeyMap.push_back(SKeyMap(XK_Page_Down, KEY_NEXT)); - KeyMap.push_back(SKeyMap(XK_End, KEY_END)); - KeyMap.push_back(SKeyMap(XK_Begin, KEY_HOME)); - KeyMap.push_back(SKeyMap(XK_KP_Space, KEY_SPACE)); - KeyMap.push_back(SKeyMap(XK_KP_Tab, KEY_TAB)); - KeyMap.push_back(SKeyMap(XK_KP_Enter, KEY_RETURN)); - KeyMap.push_back(SKeyMap(XK_KP_F1, KEY_F1)); - KeyMap.push_back(SKeyMap(XK_KP_F2, KEY_F2)); - KeyMap.push_back(SKeyMap(XK_KP_F3, KEY_F3)); - KeyMap.push_back(SKeyMap(XK_KP_F4, KEY_F4)); - KeyMap.push_back(SKeyMap(XK_KP_Left, KEY_LEFT)); - KeyMap.push_back(SKeyMap(XK_KP_Up, KEY_UP)); - KeyMap.push_back(SKeyMap(XK_KP_Right, KEY_RIGHT)); - KeyMap.push_back(SKeyMap(XK_KP_Down, KEY_DOWN)); - KeyMap.push_back(SKeyMap(XK_KP_Prior, KEY_PRIOR)); - KeyMap.push_back(SKeyMap(XK_KP_Page_Up, KEY_PRIOR)); - KeyMap.push_back(SKeyMap(XK_KP_Next, KEY_NEXT)); - KeyMap.push_back(SKeyMap(XK_KP_Page_Down, KEY_NEXT)); - KeyMap.push_back(SKeyMap(XK_KP_End, KEY_END)); - KeyMap.push_back(SKeyMap(XK_KP_Begin, KEY_HOME)); - KeyMap.push_back(SKeyMap(XK_KP_Insert, KEY_INSERT)); - KeyMap.push_back(SKeyMap(XK_KP_Delete, KEY_DELETE)); - KeyMap.push_back(SKeyMap(XK_KP_Equal, 0)); // ??? - KeyMap.push_back(SKeyMap(XK_KP_Multiply, KEY_MULTIPLY)); - KeyMap.push_back(SKeyMap(XK_KP_Add, KEY_ADD)); - KeyMap.push_back(SKeyMap(XK_KP_Separator, KEY_SEPARATOR)); - KeyMap.push_back(SKeyMap(XK_KP_Subtract, KEY_SUBTRACT)); - KeyMap.push_back(SKeyMap(XK_KP_Decimal, KEY_DECIMAL)); - KeyMap.push_back(SKeyMap(XK_KP_Divide, KEY_DIVIDE)); - KeyMap.push_back(SKeyMap(XK_KP_0, KEY_KEY_0)); - KeyMap.push_back(SKeyMap(XK_KP_1, KEY_KEY_1)); - KeyMap.push_back(SKeyMap(XK_KP_2, KEY_KEY_2)); - KeyMap.push_back(SKeyMap(XK_KP_3, KEY_KEY_3)); - KeyMap.push_back(SKeyMap(XK_KP_4, KEY_KEY_4)); - KeyMap.push_back(SKeyMap(XK_KP_5, KEY_KEY_5)); - KeyMap.push_back(SKeyMap(XK_KP_6, KEY_KEY_6)); - KeyMap.push_back(SKeyMap(XK_KP_7, KEY_KEY_7)); - KeyMap.push_back(SKeyMap(XK_KP_8, KEY_KEY_8)); - KeyMap.push_back(SKeyMap(XK_KP_9, KEY_KEY_9)); - KeyMap.push_back(SKeyMap(XK_F1, KEY_F1)); - KeyMap.push_back(SKeyMap(XK_F2, KEY_F2)); - KeyMap.push_back(SKeyMap(XK_F3, KEY_F3)); - KeyMap.push_back(SKeyMap(XK_F4, KEY_F4)); - KeyMap.push_back(SKeyMap(XK_F5, KEY_F5)); - KeyMap.push_back(SKeyMap(XK_F6, KEY_F6)); - KeyMap.push_back(SKeyMap(XK_F7, KEY_F7)); - KeyMap.push_back(SKeyMap(XK_F8, KEY_F8)); - KeyMap.push_back(SKeyMap(XK_F9, KEY_F9)); - KeyMap.push_back(SKeyMap(XK_F10, KEY_F10)); - KeyMap.push_back(SKeyMap(XK_F11, KEY_F11)); - KeyMap.push_back(SKeyMap(XK_F12, KEY_F12)); - KeyMap.push_back(SKeyMap(XK_Shift_L, KEY_LSHIFT)); - KeyMap.push_back(SKeyMap(XK_Shift_R, KEY_RSHIFT)); - KeyMap.push_back(SKeyMap(XK_Control_L, KEY_LCONTROL)); - KeyMap.push_back(SKeyMap(XK_Control_R, KEY_RCONTROL)); - KeyMap.push_back(SKeyMap(XK_Caps_Lock, KEY_CAPITAL)); - KeyMap.push_back(SKeyMap(XK_Shift_Lock, KEY_CAPITAL)); - KeyMap.push_back(SKeyMap(XK_Meta_L, KEY_LWIN)); - KeyMap.push_back(SKeyMap(XK_Meta_R, KEY_RWIN)); - KeyMap.push_back(SKeyMap(XK_Alt_L, KEY_LMENU)); - KeyMap.push_back(SKeyMap(XK_Alt_R, KEY_RMENU)); - KeyMap.push_back(SKeyMap(XK_ISO_Level3_Shift, KEY_RMENU)); - KeyMap.push_back(SKeyMap(XK_Menu, KEY_MENU)); - KeyMap.push_back(SKeyMap(XK_space, KEY_SPACE)); - KeyMap.push_back(SKeyMap(XK_exclam, 0)); //? - KeyMap.push_back(SKeyMap(XK_quotedbl, 0)); //? - KeyMap.push_back(SKeyMap(XK_section, 0)); //? - KeyMap.push_back(SKeyMap(XK_numbersign, 0)); //? - KeyMap.push_back(SKeyMap(XK_dollar, 0)); //? - KeyMap.push_back(SKeyMap(XK_percent, 0)); //? - KeyMap.push_back(SKeyMap(XK_ampersand, 0)); //? - KeyMap.push_back(SKeyMap(XK_apostrophe, 0)); //? - KeyMap.push_back(SKeyMap(XK_parenleft, 0)); //? - KeyMap.push_back(SKeyMap(XK_parenright, 0)); //? - KeyMap.push_back(SKeyMap(XK_asterisk, 0)); //? - KeyMap.push_back(SKeyMap(XK_plus, KEY_PLUS)); //? - KeyMap.push_back(SKeyMap(XK_comma, KEY_COMMA)); //? - KeyMap.push_back(SKeyMap(XK_minus, KEY_MINUS)); //? - KeyMap.push_back(SKeyMap(XK_period, KEY_PERIOD)); //? - KeyMap.push_back(SKeyMap(XK_slash, 0)); //? - KeyMap.push_back(SKeyMap(XK_0, KEY_KEY_0)); - KeyMap.push_back(SKeyMap(XK_1, KEY_KEY_1)); - KeyMap.push_back(SKeyMap(XK_2, KEY_KEY_2)); - KeyMap.push_back(SKeyMap(XK_3, KEY_KEY_3)); - KeyMap.push_back(SKeyMap(XK_4, KEY_KEY_4)); - KeyMap.push_back(SKeyMap(XK_5, KEY_KEY_5)); - KeyMap.push_back(SKeyMap(XK_6, KEY_KEY_6)); - KeyMap.push_back(SKeyMap(XK_7, KEY_KEY_7)); - KeyMap.push_back(SKeyMap(XK_8, KEY_KEY_8)); - KeyMap.push_back(SKeyMap(XK_9, KEY_KEY_9)); - KeyMap.push_back(SKeyMap(XK_colon, 0)); //? - KeyMap.push_back(SKeyMap(XK_semicolon, 0)); //? - KeyMap.push_back(SKeyMap(XK_less, 0)); //? - KeyMap.push_back(SKeyMap(XK_equal, 0)); //? - KeyMap.push_back(SKeyMap(XK_greater, 0)); //? - KeyMap.push_back(SKeyMap(XK_question, 0)); //? - KeyMap.push_back(SKeyMap(XK_at, 0)); //? - KeyMap.push_back(SKeyMap(XK_mu, 0)); //? - KeyMap.push_back(SKeyMap(XK_EuroSign, 0)); //? - KeyMap.push_back(SKeyMap(XK_A, KEY_KEY_A)); - KeyMap.push_back(SKeyMap(XK_B, KEY_KEY_B)); - KeyMap.push_back(SKeyMap(XK_C, KEY_KEY_C)); - KeyMap.push_back(SKeyMap(XK_D, KEY_KEY_D)); - KeyMap.push_back(SKeyMap(XK_E, KEY_KEY_E)); - KeyMap.push_back(SKeyMap(XK_F, KEY_KEY_F)); - KeyMap.push_back(SKeyMap(XK_G, KEY_KEY_G)); - KeyMap.push_back(SKeyMap(XK_H, KEY_KEY_H)); - KeyMap.push_back(SKeyMap(XK_I, KEY_KEY_I)); - KeyMap.push_back(SKeyMap(XK_J, KEY_KEY_J)); - KeyMap.push_back(SKeyMap(XK_K, KEY_KEY_K)); - KeyMap.push_back(SKeyMap(XK_L, KEY_KEY_L)); - KeyMap.push_back(SKeyMap(XK_M, KEY_KEY_M)); - KeyMap.push_back(SKeyMap(XK_N, KEY_KEY_N)); - KeyMap.push_back(SKeyMap(XK_O, KEY_KEY_O)); - KeyMap.push_back(SKeyMap(XK_P, KEY_KEY_P)); - KeyMap.push_back(SKeyMap(XK_Q, KEY_KEY_Q)); - KeyMap.push_back(SKeyMap(XK_R, KEY_KEY_R)); - KeyMap.push_back(SKeyMap(XK_S, KEY_KEY_S)); - KeyMap.push_back(SKeyMap(XK_T, KEY_KEY_T)); - KeyMap.push_back(SKeyMap(XK_U, KEY_KEY_U)); - KeyMap.push_back(SKeyMap(XK_V, KEY_KEY_V)); - KeyMap.push_back(SKeyMap(XK_W, KEY_KEY_W)); - KeyMap.push_back(SKeyMap(XK_X, KEY_KEY_X)); - KeyMap.push_back(SKeyMap(XK_Y, KEY_KEY_Y)); - KeyMap.push_back(SKeyMap(XK_Z, KEY_KEY_Z)); - KeyMap.push_back(SKeyMap(XK_Adiaeresis, 0)); //? - KeyMap.push_back(SKeyMap(XK_Odiaeresis, 0)); //? - KeyMap.push_back(SKeyMap(XK_Udiaeresis, 0)); //? - KeyMap.push_back(SKeyMap(XK_bracketleft, 0)); //? - KeyMap.push_back(SKeyMap(XK_backslash, 0)); //? - KeyMap.push_back(SKeyMap(XK_bracketright, 0)); //? - KeyMap.push_back(SKeyMap(XK_asciicircum, 0)); //? - KeyMap.push_back(SKeyMap(XK_degree, 0)); //? - KeyMap.push_back(SKeyMap(XK_underscore, 0)); //? - KeyMap.push_back(SKeyMap(XK_grave, 0)); //? - KeyMap.push_back(SKeyMap(XK_acute, 0)); //? - KeyMap.push_back(SKeyMap(XK_quoteleft, 0)); //? - KeyMap.push_back(SKeyMap(XK_a, KEY_KEY_A)); - KeyMap.push_back(SKeyMap(XK_b, KEY_KEY_B)); - KeyMap.push_back(SKeyMap(XK_c, KEY_KEY_C)); - KeyMap.push_back(SKeyMap(XK_d, KEY_KEY_D)); - KeyMap.push_back(SKeyMap(XK_e, KEY_KEY_E)); - KeyMap.push_back(SKeyMap(XK_f, KEY_KEY_F)); - KeyMap.push_back(SKeyMap(XK_g, KEY_KEY_G)); - KeyMap.push_back(SKeyMap(XK_h, KEY_KEY_H)); - KeyMap.push_back(SKeyMap(XK_i, KEY_KEY_I)); - KeyMap.push_back(SKeyMap(XK_j, KEY_KEY_J)); - KeyMap.push_back(SKeyMap(XK_k, KEY_KEY_K)); - KeyMap.push_back(SKeyMap(XK_l, KEY_KEY_L)); - KeyMap.push_back(SKeyMap(XK_m, KEY_KEY_M)); - KeyMap.push_back(SKeyMap(XK_n, KEY_KEY_N)); - KeyMap.push_back(SKeyMap(XK_o, KEY_KEY_O)); - KeyMap.push_back(SKeyMap(XK_p, KEY_KEY_P)); - KeyMap.push_back(SKeyMap(XK_q, KEY_KEY_Q)); - KeyMap.push_back(SKeyMap(XK_r, KEY_KEY_R)); - KeyMap.push_back(SKeyMap(XK_s, KEY_KEY_S)); - KeyMap.push_back(SKeyMap(XK_t, KEY_KEY_T)); - KeyMap.push_back(SKeyMap(XK_u, KEY_KEY_U)); - KeyMap.push_back(SKeyMap(XK_v, KEY_KEY_V)); - KeyMap.push_back(SKeyMap(XK_w, KEY_KEY_W)); - KeyMap.push_back(SKeyMap(XK_x, KEY_KEY_X)); - KeyMap.push_back(SKeyMap(XK_y, KEY_KEY_Y)); - KeyMap.push_back(SKeyMap(XK_z, KEY_KEY_Z)); - KeyMap.push_back(SKeyMap(XK_ssharp, 0)); //? - KeyMap.push_back(SKeyMap(XK_adiaeresis, 0)); //? - KeyMap.push_back(SKeyMap(XK_odiaeresis, 0)); //? - KeyMap.push_back(SKeyMap(XK_udiaeresis, 0)); //? - - KeyMap.sort(); -#endif -} - - -IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& param) -{ - CIrrDeviceLinux* dev = new CIrrDeviceLinux( - param.DriverType, - param.WindowSize, - param.Bits, - param.Fullscreen, - param.Stencilbuffer, - param.Vsync, - param.AntiAlias, - param.EventReceiver, - param.SDK_version_do_not_use); - - if (dev && !dev->getVideoDriver() && param.DriverType != video::EDT_NULL) - { - dev->drop(); - dev = 0; - } - - return dev; -} - - -} // end namespace - -#endif // LINUX - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CIrrDeviceLinux.h" + +#ifdef LINUX + +#include +#include +#include +#include +#include "IEventReceiver.h" +#include "irrList.h" +#include "os.h" +#include "CTimer.h" +#include "irrString.h" +#include "Keycodes.h" +#include "COSOperator.h" +#include "CColorConverter.h" +#include "SIrrCreationParameters.h" + +namespace irr +{ + namespace video + { + IVideoDriver* createOpenGLDriver(const core::dimension2d& screenSize, + bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias); + } +} // end namespace irr + + + +namespace irr +{ + +const char* wmDeleteWindow = "WM_DELETE_WINDOW"; + +//! constructor +CIrrDeviceLinux::CIrrDeviceLinux(video::E_DRIVER_TYPE driverType, + const core::dimension2d& windowSize, + u32 bits, bool fullscreen, + bool sbuffer, bool vsync, bool antiAlias, + IEventReceiver* receiver, + const char* version) + : CIrrDeviceStub(version, receiver), +#ifdef _IRR_COMPILE_WITH_X11_ + display(0), screennr(0), window(0), SoftwareImage(0), +#endif + Fullscreen(fullscreen), StencilBuffer(sbuffer), AntiAlias(antiAlias), DriverType(driverType), + Width(windowSize.Width), Height(windowSize.Height), Depth(24), + Close(false), WindowActive(false), WindowMinimized(false), UseXVidMode(false), UseXRandR(false), UseGLXWindow(false) +{ + #ifdef _DEBUG + setDebugName("CIrrDeviceLinux"); + #endif + + // print version, distribution etc. + // thx to LynxLuna for pointing me to the uname function + core::stringc linuxversion; + struct utsname LinuxInfo; + uname(&LinuxInfo); + + linuxversion += LinuxInfo.sysname; + linuxversion += " "; + linuxversion += LinuxInfo.release; + linuxversion += " "; + linuxversion += LinuxInfo.version; + linuxversion += " "; + linuxversion += LinuxInfo.machine; + + Operator = new COSOperator(linuxversion.c_str()); + os::Printer::log(linuxversion.c_str(), ELL_INFORMATION); + + // create keymap + createKeyMap(); + + // create window + if (driverType != video::EDT_NULL) + { + // create the window, only if we do not use the null device + if (!createWindow(windowSize, bits)) + return; + } + + // create cursor control + CursorControl = new CCursorControl(this, driverType == video::EDT_NULL); + + // create driver + createDriver(windowSize, bits, vsync); + + if (!VideoDriver) + return; + + createGUIAndScene(); +} + + + +//! destructor +CIrrDeviceLinux::~CIrrDeviceLinux() +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (display) + { + //os::Printer::log("Deleting window...", ELL_INFORMATION); + + #ifdef _IRR_COMPILE_WITH_OPENGL_ + if (Context) + { + if (!glXMakeCurrent(display, None, NULL)) + os::Printer::log("Could not release glx context.", ELL_WARNING); + glXDestroyContext(display, Context); + if (UseGLXWindow) + glXDestroyWindow(display, glxWin); + Context = 0; + } + #endif // #ifdef _IRR_COMPILE_WITH_OPENGL_ + + #ifdef _IRR_LINUX_X11_VIDMODE_ + if (UseXVidMode && Fullscreen) + { + XF86VidModeSwitchToMode(display, screennr, &oldVideoMode); + XF86VidModeSetViewPort(display, screennr, 0, 0); + } + #endif + #ifdef _IRR_LINUX_X11_RANDR_ + if (UseXRandR && Fullscreen) + { + XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display)); + XRRSetScreenConfig(display,config,DefaultRootWindow(display),oldRandrMode,oldRandrRotation,CurrentTime); + XRRFreeScreenConfigInfo(config); + } + #endif + + if (DriverType == video::EDT_SOFTWARE || DriverType == video::EDT_BURNINGSVIDEO) + XDestroyImage(SoftwareImage); + XDestroyWindow(display,window); + XCloseDisplay(display); + } +#endif // #ifdef _IRR_COMPILE_WITH_X11_ +} + + + +#if defined(_IRR_COMPILE_WITH_X11_) && defined(_DEBUG) +int IrrPrintXError(Display *display, XErrorEvent *event) +{ + char msg[256]; + + XGetErrorText(display, event->error_code, msg, 256); + os::Printer::log("XErrorEvent", msg, ELL_WARNING); + return 0; +} +#endif + + + +bool CIrrDeviceLinux::createWindow(const core::dimension2d& windowSize, + u32 bits) +{ + Width = windowSize.Width; + Height = windowSize.Height; + +#ifdef _IRR_COMPILE_WITH_X11_ +#ifdef _DEBUG + os::Printer::log("Creating X window...", ELL_INFORMATION); + XSetErrorHandler(IrrPrintXError); +#endif + + display = XOpenDisplay(0); + if (!display) + { + os::Printer::log("Error: Need running XServer to start Irrlicht Engine.", ELL_ERROR); + return false; + } + + screennr = DefaultScreen(display); + + // query extension + + if (Fullscreen) + { + s32 eventbase, errorbase; + s32 bestMode = -1; + s32 defaultDepth=DefaultDepth(display,screennr); + + #ifdef _IRR_LINUX_X11_VIDMODE_ + if (XF86VidModeQueryExtension(display, &eventbase, &errorbase)) + { + // enumerate video modes + s32 modeCount; + XF86VidModeModeInfo** modes; + + XF86VidModeGetAllModeLines(display, screennr, &modeCount, &modes); + + // save current video mode + oldVideoMode = *modes[0]; + + // find fitting mode + + VideoModeList.setDesktop(defaultDepth, core::dimension2d( + modes[0]->hdisplay, modes[0]->vdisplay)); + for (s32 i = 0; ihdisplay >= Width && modes[i]->vdisplay >= Height) + bestMode = i; + else if (bestMode!=-1 && modes[i]->hdisplay >= Width && modes[i]->vdisplay >= Height && modes[i]->hdisplay < modes[bestMode]->hdisplay && modes[i]->vdisplay < modes[bestMode]->vdisplay) + bestMode = i; + VideoModeList.addMode(core::dimension2d( + modes[i]->hdisplay, modes[i]->vdisplay), defaultDepth); + } + if (bestMode != -1) + { + os::Printer::log("Starting fullscreen mode...", ELL_INFORMATION); + XF86VidModeSwitchToMode(display, screennr, modes[bestMode]); + XF86VidModeSetViewPort(display, screennr, 0, 0); + UseXVidMode=true; + } + else + { + os::Printer::log("Could not find specified video mode, running windowed.", ELL_WARNING); + Fullscreen = false; + } + + XFree(modes); + } + else + #endif + #ifdef _IRR_LINUX_X11_RANDR_ + if (XRRQueryExtension(display, &eventbase, &errorbase)) + { + s32 modeCount; + XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display)); + oldRandrMode=XRRConfigCurrentConfiguration(config,&oldRandrRotation); + XRRScreenSize *modes=XRRConfigSizes(config,&modeCount); + VideoModeList.setDesktop(defaultDepth, core::dimension2d( + modes[oldRandrMode].width, modes[oldRandrMode].height)); + for (s32 i = 0; i= Width && modes[i].height >= Height) + bestMode = i; + VideoModeList.addMode(core::dimension2d( + modes[i].width, modes[i].height), defaultDepth); + } + if (bestMode != -1) + { + XRRSetScreenConfig(display,config,DefaultRootWindow(display),bestMode,oldRandrRotation,CurrentTime); + UseXRandR=true; + } + XRRFreeScreenConfigInfo(config); + } + else + #endif + { + os::Printer::log("VidMode extension must be installed to allow Irrlicht " + "to switch to fullscreen mode. Running in windowed mode instead.", ELL_WARNING); + Fullscreen = false; + } + } + + // get visual + XVisualInfo* visual = 0; + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + + Context=0; + GLXFBConfig glxFBConfig; + int major, minor; + bool isAvailableGLX=false; + if (DriverType==video::EDT_OPENGL) + { + isAvailableGLX=glXQueryExtension(display,&major,&minor); + if (isAvailableGLX && glXQueryVersion(display, &major, &minor)) + { + if (major==1 && minor>2) + { + const int MAX_SAMPLES = 16; + // attribute array for the draw buffer + int visualAttrBuffer[] = + { + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_RED_SIZE, 4, + GLX_GREEN_SIZE, 4, + GLX_BLUE_SIZE, 4, + GLX_ALPHA_SIZE, 4, + GLX_DEPTH_SIZE, 16, + GLX_DOUBLEBUFFER, GL_TRUE, + GLX_STENCIL_SIZE, 1, + GLX_SAMPLE_BUFFERS_ARB, GL_TRUE, + GLX_SAMPLES_ARB, MAX_SAMPLES, + None + }; + + GLXFBConfig *configList=0; + int nitems=0; + if (!AntiAlias) + { + visualAttrBuffer[17] = GL_FALSE; + visualAttrBuffer[19] = 0; + } + if (StencilBuffer) + { + configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); + if (!configList && AntiAlias) + { + while (!configList && (visualAttrBuffer[19]>1)) + { + visualAttrBuffer[19] >>= 1; + configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); + } + if (!configList) + { + visualAttrBuffer[17] = GL_FALSE; + visualAttrBuffer[19] = 0; + configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); + if (configList) + { + os::Printer::log("No FSAA available.", ELL_WARNING); + AntiAlias=false; + } + else + { + //reenable multisampling + visualAttrBuffer[17] = GL_TRUE; + visualAttrBuffer[19] = MAX_SAMPLES; + } + } + } + } + // Next try without stencil buffer + if (!configList) + { + if (StencilBuffer) + os::Printer::log("No stencilbuffer available, disabling stencil shadows.", ELL_WARNING); + StencilBuffer = false; + visualAttrBuffer[15]=0; + + configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); + if (!configList && AntiAlias) + { + while (!configList && (visualAttrBuffer[19]>1)) + { + visualAttrBuffer[19] >>= 1; + configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); + } + if (!configList) + { + visualAttrBuffer[17] = GL_FALSE; + visualAttrBuffer[19] = 0; + configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); + if (configList) + { + os::Printer::log("No FSAA available.", ELL_WARNING); + AntiAlias=false; + } + else + { + //reenable multisampling + visualAttrBuffer[17] = GL_TRUE; + visualAttrBuffer[19] = MAX_SAMPLES; + } + } + } + } + // Next try without double buffer + if (!configList) + { + os::Printer::log("No doublebuffering available.", ELL_WARNING); + visualAttrBuffer[13] = GL_FALSE; + configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); + if (!configList && AntiAlias) + { + while (!configList && (visualAttrBuffer[19]>1)) + { + visualAttrBuffer[19] >>= 1; + configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); + } + if (!configList) + { + visualAttrBuffer[17] = GL_FALSE; + visualAttrBuffer[19] = 0; + configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); + if (configList) + { + os::Printer::log("No FSAA available.", ELL_WARNING); + AntiAlias=false; + } + else + { + //reenable multisampling + visualAttrBuffer[17] = GL_TRUE; + visualAttrBuffer[19] = MAX_SAMPLES; + } + } + } + } + if (configList) + { + glxFBConfig=configList[0]; + XFree(configList); + UseGLXWindow=true; + visual = glXGetVisualFromFBConfig(display,glxFBConfig); + } + } + else + { + // attribute array for the draw buffer + int visualAttrBuffer[] = + { + GLX_RGBA, GL_TRUE, + GLX_RED_SIZE, 4, + GLX_GREEN_SIZE, 4, + GLX_BLUE_SIZE, 4, + GLX_ALPHA_SIZE, 4, + GLX_DEPTH_SIZE, 16, + GLX_DOUBLEBUFFER, GL_TRUE, + GLX_STENCIL_SIZE, 1, + None + }; + + if (StencilBuffer) + visual=glXChooseVisual(display, screennr, visualAttrBuffer); + if (!visual) + { + if (StencilBuffer) + { + os::Printer::log("No stencilbuffer available, disabling stencil shadows.", ELL_WARNING); + StencilBuffer = false; + } + visualAttrBuffer[15]=0; + + visual=glXChooseVisual(display, screennr, visualAttrBuffer); + if (!visual) + { + os::Printer::log("No doublebuffering available.", ELL_WARNING); + visualAttrBuffer[13] = GL_FALSE; + visual=glXChooseVisual(display, screennr, visualAttrBuffer); + } + } + } + } + else + os::Printer::log("No GLX support available. OpenGL driver will not work.", ELL_WARNING); + } + +#endif // _IRR_COMPILE_WITH_OPENGL_ + + // create visual with standard X methods + if (!visual) + { + XVisualInfo visTempl; //Template to hold requested values + int visNumber; // Return value of available visuals + + visTempl.screen = screennr; + visTempl.depth = 16; + while ((!visual) && (visTempl.depth<=32)) + { + visual = XGetVisualInfo(display, VisualScreenMask|VisualDepthMask, + &visTempl, &visNumber); + visTempl.depth+=8; + } + } + + if (!visual) + { + os::Printer::log("Fatal error, could not get visual.", ELL_ERROR); + XCloseDisplay(display); + display=0; + return false; + } + + // create color map + Colormap colormap; + colormap = XCreateColormap(display, + RootWindow(display, visual->screen), + visual->visual, AllocNone); + + attributes.colormap = colormap; + attributes.border_pixel = 0; + attributes.event_mask = KeyPressMask | ButtonPressMask | + StructureNotifyMask | PointerMotionMask | + ButtonReleaseMask | KeyReleaseMask; + + // create Window, either for Fullscreen or windowed mode + if (Fullscreen) + { + attributes.override_redirect = True; + + window = XCreateWindow(display, + RootWindow(display, visual->screen), + 0, 0, Width, Height, 0, visual->depth, + InputOutput, visual->visual, + CWBorderPixel | CWColormap | CWEventMask | + CWOverrideRedirect, &attributes); + + XWarpPointer(display, None, window, 0, 0, 0, 0, 0, 0); + XMapRaised(display, window); + XGrabKeyboard(display, window, True, GrabModeAsync, + GrabModeAsync, CurrentTime); + XGrabPointer(display, window, True, ButtonPressMask, + GrabModeAsync, GrabModeAsync, window, None, CurrentTime); + } + else + { // we want windowed mode + attributes.event_mask |= ExposureMask; + attributes.event_mask |= FocusChangeMask; + + window = XCreateWindow(display, + RootWindow(display, visual->screen), + 0, 0, Width, Height, 0, visual->depth, + InputOutput, visual->visual, + CWBorderPixel | CWColormap | CWEventMask, + &attributes); + + Atom wmDelete; + wmDelete = XInternAtom(display, wmDeleteWindow, True); + XSetWMProtocols(display, window, &wmDelete, 1); + XMapRaised(display, window); + } + WindowActive=true; + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + + // connect glx context to window + if (isAvailableGLX && DriverType==video::EDT_OPENGL) + { + if (UseGLXWindow) + { + glxWin=glXCreateWindow(display,glxFBConfig,window,NULL); + if (glxWin) + { + // create glx context + Context = glXCreateNewContext(display, glxFBConfig, GLX_RGBA_TYPE, NULL, True); + if (Context) + { + if (!glXMakeContextCurrent(display, glxWin, glxWin, Context)) + { + os::Printer::log("Could not make context current.", ELL_WARNING); + glXDestroyContext(display, Context); + } + } + else + { + os::Printer::log("Could not create GLX rendering context.", ELL_WARNING); + } + } + else + { + os::Printer::log("Could not create GLX window.", ELL_WARNING); + } + } + else + { + Context = glXCreateContext(display, visual, NULL, True); + if (Context) + { + if (!glXMakeCurrent(display, window, Context)) + { + os::Printer::log("Could not make context current.", ELL_WARNING); + glXDestroyContext(display, Context); + } + } + else + { + os::Printer::log("Could not create GLX rendering context.", ELL_WARNING); + } + } + } +#endif // _IRR_COMPILE_WITH_OPENGL_ + + Window tmp; + u32 borderWidth; + int x,y; + + XGetGeometry(display, window, &tmp, &x, &y, &Width, &Height, &borderWidth, &Depth); + + // create an XImage for the software renderer + //(thx to Nadav for some clues on how to do that!) + + if (DriverType == video::EDT_SOFTWARE || DriverType == video::EDT_BURNINGSVIDEO) + { + SoftwareImage = XCreateImage(display, + visual->visual, visual->depth, + ZPixmap, 0, 0, Width, Height, + BitmapPad(display), 0); + + SoftwareImage->data = new char[SoftwareImage->bytes_per_line * SoftwareImage->height]; + } + + XFree(visual); +#endif // #ifdef _IRR_COMPILE_WITH_X11_ + return true; +} + + +//! create the driver +void CIrrDeviceLinux::createDriver(const core::dimension2d& windowSize, + u32 bits, bool vsync) +{ + switch(DriverType) + { +#ifdef _IRR_COMPILE_WITH_X11_ + + case video::EDT_SOFTWARE: + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + VideoDriver = video::createSoftwareDriver(windowSize, Fullscreen, FileSystem, this); + #else + os::Printer::log("No Software driver support compiled in.", ELL_WARNING); + #endif + break; + + case video::EDT_BURNINGSVIDEO: + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + VideoDriver = video::createSoftwareDriver2(windowSize, Fullscreen, FileSystem, this); + #else + os::Printer::log("Burning's video driver was not compiled in.", ELL_WARNING); + #endif + break; + + case video::EDT_OPENGL: + #ifdef _IRR_COMPILE_WITH_OPENGL_ + if (Context) + VideoDriver = video::createOpenGLDriver(windowSize, Fullscreen, StencilBuffer, FileSystem, vsync, AntiAlias); + #else + os::Printer::log("No OpenGL support compiled in.", ELL_WARNING); + #endif + break; + + case video::EDT_DIRECT3D8: + case video::EDT_DIRECT3D9: + os::Printer::log("This driver is not available in Linux. Try OpenGL or Software renderer.", + ELL_WARNING); + break; + + default: + VideoDriver = video::createNullDriver(FileSystem, windowSize); + break; +#else + case video::EDT_NULL: + VideoDriver = video::createNullDriver(FileSystem, windowSize); + break; + default: + os::Printer::log("No X11 support compiled in. Only Null driver available.", ELL_WARNING); + break; +#endif + } +} + + + +//! runs the device. Returns false if device wants to be deleted +bool CIrrDeviceLinux::run() +{ + os::Timer::tick(); + +#ifdef _IRR_COMPILE_WITH_X11_ + if (DriverType != video::EDT_NULL) + { + irr::SEvent irrevent; + + while (XPending(display) > 0 && !Close) + { + XNextEvent(display, &event); + + switch (event.type) + { + case ConfigureNotify: + // check for changed window size + if ((event.xconfigure.width != (int) Width) || + (event.xconfigure.height != (int) Height)) + { + Width = event.xconfigure.width; + Height = event.xconfigure.height; + if (VideoDriver) + VideoDriver->OnResize(core::dimension2d(Width, Height)); + } + break; + + case MapNotify: + WindowMinimized=false; + break; + + case UnmapNotify: + WindowMinimized=true; + break; + + case FocusIn: + WindowActive=true; + break; + + case FocusOut: + WindowActive=false; + break; + + case MotionNotify: + irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; + irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; + irrevent.MouseInput.X = event.xbutton.x; + irrevent.MouseInput.Y = event.xbutton.y; + + postEventFromUser(irrevent); + break; + + case ButtonPress: + case ButtonRelease: + + irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; + irrevent.MouseInput.X = event.xbutton.x; + irrevent.MouseInput.Y = event.xbutton.y; + + irrevent.MouseInput.Event = irr::EMIE_COUNT; + + switch(event.xbutton.button) + { + case Button1: + irrevent.MouseInput.Event = + (event.type == ButtonPress) ? irr::EMIE_LMOUSE_PRESSED_DOWN : irr::EMIE_LMOUSE_LEFT_UP; + break; + + case Button3: + irrevent.MouseInput.Event = + (event.type == ButtonPress) ? irr::EMIE_RMOUSE_PRESSED_DOWN : irr::EMIE_RMOUSE_LEFT_UP; + break; + + case Button2: + irrevent.MouseInput.Event = + (event.type == ButtonPress) ? irr::EMIE_MMOUSE_PRESSED_DOWN : irr::EMIE_MMOUSE_LEFT_UP; + break; + + case Button4: + irrevent.MouseInput.Event = EMIE_MOUSE_WHEEL; + irrevent.MouseInput.Wheel = 1.0f; + break; + + case Button5: + irrevent.MouseInput.Event = EMIE_MOUSE_WHEEL; + irrevent.MouseInput.Wheel = -1.0f; + break; + } + + if (irrevent.MouseInput.Event != irr::EMIE_COUNT) + postEventFromUser(irrevent); + break; + + case MappingNotify: + XRefreshKeyboardMapping (&event.xmapping) ; + break; + + case KeyRelease: + case KeyPress: + { + SKeyMap mp; + //mp.X11Key = XLookupKeysym(&event.xkey, 0); + char buf[5]="\0\0\0\0"; + XLookupString (&event.xkey, buf, 4, &mp.X11Key, NULL) ; + + s32 idx = KeyMap.binary_search(mp); + + if (idx != -1) + irrevent.KeyInput.Key = (EKEY_CODE)KeyMap[idx].Win32Key; + else + { + irrevent.KeyInput.Key = (EKEY_CODE)0; + os::Printer::log("Could not find win32 key for x11 key.", ELL_WARNING); + } + irrevent.EventType = irr::EET_KEY_INPUT_EVENT; + irrevent.KeyInput.PressedDown = (event.type == KeyPress); + mbtowc(&irrevent.KeyInput.Char, buf, 4); + irrevent.KeyInput.Control = (event.xkey.state & ControlMask) != 0; + irrevent.KeyInput.Shift = (event.xkey.state & ShiftMask) != 0; + postEventFromUser(irrevent); + } + break; + + case ClientMessage: + { + char *atom = XGetAtomName(display, event.xclient.message_type); + if (*atom == *wmDeleteWindow) + { + os::Printer::log("Quit message received.", ELL_INFORMATION); + Close = true; + } + XFree(atom); + } + break; + + default: + break; + } // end switch + + } // end while + } +#endif //_IRR_COMPILE_WITH_X11_ + + return !Close; +} + + +//! Pause the current process for the minimum time allowed only to allow other processes to execute +void CIrrDeviceLinux::yield() +{ + struct timespec ts = {0,0}; + nanosleep(&ts, NULL); +} + +//! Pause execution and let other processes to run for a specified amount of time. +void CIrrDeviceLinux::sleep(u32 timeMs, bool pauseTimer=false) +{ + bool wasStopped = Timer ? Timer->isStopped() : true; + + struct timespec ts; + ts.tv_sec = (time_t) (timeMs / 1000); + ts.tv_nsec = (long) (timeMs % 1000) * 1000000; + + if (pauseTimer && !wasStopped) + Timer->stop(); + + nanosleep(&ts, NULL); + + if (pauseTimer && !wasStopped) + Timer->start(); +} + +//! sets the caption of the window +void CIrrDeviceLinux::setWindowCaption(const wchar_t* text) +{ + if (DriverType == video::EDT_NULL) + return; + +#ifdef _IRR_COMPILE_WITH_X11_ + core::stringc textc = text; + XSetStandardProperties(display, window, textc.c_str(), textc.c_str(), + None, NULL, 0, NULL); +#endif +} + + + +//! presents a surface in the client area +void CIrrDeviceLinux::present(video::IImage* image, s32 windowId, core::rect* src ) +{ +#ifdef _IRR_COMPILE_WITH_X11_ + // this is only necessary for software drivers. + if (DriverType != video::EDT_SOFTWARE && DriverType != video::EDT_BURNINGSVIDEO) + return; + + // thx to Nadav, who send me some clues of how to display the image + // to the X Server. + + if (image->getColorFormat() != video::ECF_A1R5G5B5 && + image->getColorFormat() != video::ECF_A8R8G8B8) + { + os::Printer::log("Internal error, can only present A1R5G5B5 and A8R8G8B8 pictures."); + return; + } + + int destwidth = SoftwareImage->width; + int destheight = SoftwareImage->height; + int srcwidth = image->getDimension().Width; + int srcheight = image->getDimension().Height; + // clip images + srcheight = srcheight < destheight ? srcheight : destheight; + + if ( image->getColorFormat() == video::ECF_A8R8G8B8 ) + { + // display 24/32 bit image + + s32* srcdata = (s32*)image->lock(); + + if ((Depth == 32)||(Depth == 24)) + { + int destPitch = SoftwareImage->bytes_per_line; + u8* destData = reinterpret_cast(SoftwareImage->data); + + for (int y=0; ybytes_per_line; + u8* destData = reinterpret_cast(SoftwareImage->data); + + for (int y=0; yunlock(); + } + else + { + // display 16 bit image + + s16* srcdata = (s16*)image->lock(); + + if (Depth == 16) + { + // convert from A1R5G5B5 to R5G6B6 + + int destPitch = SoftwareImage->bytes_per_line; + u8* destData = reinterpret_cast(SoftwareImage->data); + + for (int y=0; ybytes_per_line; + u8* destData = reinterpret_cast(SoftwareImage->data); + + for (int y=0; yunlock(); + } + + GC gc = DefaultGC(display, DefaultScreen(display)); + XPutImage(display, window, gc, SoftwareImage, 0, 0, 0, 0, destwidth, destheight); +#endif +} + + + +//! notifies the device that it should close itself +void CIrrDeviceLinux::closeDevice() +{ + Close = true; +} + + + +//! returns if window is active. if not, nothing need to be drawn +bool CIrrDeviceLinux::isWindowActive() +{ + return WindowActive; +} + + +void CIrrDeviceLinux::createKeyMap() +{ + // I don't know if this is the best method to create + // the lookuptable, but I'll leave it like that until + // I find a better version. + +#ifdef _IRR_COMPILE_WITH_X11_ + KeyMap.push_back(SKeyMap(XK_BackSpace, KEY_BACK)); + KeyMap.push_back(SKeyMap(XK_Tab, KEY_TAB)); + KeyMap.push_back(SKeyMap(XK_Linefeed, 0)); // ??? + KeyMap.push_back(SKeyMap(XK_Clear, KEY_CLEAR)); + KeyMap.push_back(SKeyMap(XK_Return, KEY_RETURN)); + KeyMap.push_back(SKeyMap(XK_Pause, KEY_PAUSE)); + KeyMap.push_back(SKeyMap(XK_Scroll_Lock, KEY_SCROLL)); + KeyMap.push_back(SKeyMap(XK_Sys_Req, 0)); // ??? + KeyMap.push_back(SKeyMap(XK_Escape, KEY_ESCAPE)); + KeyMap.push_back(SKeyMap(XK_Delete, KEY_DELETE)); + KeyMap.push_back(SKeyMap(XK_Home, KEY_HOME)); + KeyMap.push_back(SKeyMap(XK_Left, KEY_LEFT)); + KeyMap.push_back(SKeyMap(XK_Up, KEY_UP)); + KeyMap.push_back(SKeyMap(XK_Right, KEY_RIGHT)); + KeyMap.push_back(SKeyMap(XK_Down, KEY_DOWN)); + KeyMap.push_back(SKeyMap(XK_Prior, KEY_PRIOR)); + KeyMap.push_back(SKeyMap(XK_Page_Up, KEY_PRIOR)); + KeyMap.push_back(SKeyMap(XK_Next, KEY_NEXT)); + KeyMap.push_back(SKeyMap(XK_Page_Down, KEY_NEXT)); + KeyMap.push_back(SKeyMap(XK_End, KEY_END)); + KeyMap.push_back(SKeyMap(XK_Begin, KEY_HOME)); + KeyMap.push_back(SKeyMap(XK_KP_Space, KEY_SPACE)); + KeyMap.push_back(SKeyMap(XK_KP_Tab, KEY_TAB)); + KeyMap.push_back(SKeyMap(XK_KP_Enter, KEY_RETURN)); + KeyMap.push_back(SKeyMap(XK_KP_F1, KEY_F1)); + KeyMap.push_back(SKeyMap(XK_KP_F2, KEY_F2)); + KeyMap.push_back(SKeyMap(XK_KP_F3, KEY_F3)); + KeyMap.push_back(SKeyMap(XK_KP_F4, KEY_F4)); + KeyMap.push_back(SKeyMap(XK_KP_Left, KEY_LEFT)); + KeyMap.push_back(SKeyMap(XK_KP_Up, KEY_UP)); + KeyMap.push_back(SKeyMap(XK_KP_Right, KEY_RIGHT)); + KeyMap.push_back(SKeyMap(XK_KP_Down, KEY_DOWN)); + KeyMap.push_back(SKeyMap(XK_KP_Prior, KEY_PRIOR)); + KeyMap.push_back(SKeyMap(XK_KP_Page_Up, KEY_PRIOR)); + KeyMap.push_back(SKeyMap(XK_KP_Next, KEY_NEXT)); + KeyMap.push_back(SKeyMap(XK_KP_Page_Down, KEY_NEXT)); + KeyMap.push_back(SKeyMap(XK_KP_End, KEY_END)); + KeyMap.push_back(SKeyMap(XK_KP_Begin, KEY_HOME)); + KeyMap.push_back(SKeyMap(XK_KP_Insert, KEY_INSERT)); + KeyMap.push_back(SKeyMap(XK_KP_Delete, KEY_DELETE)); + KeyMap.push_back(SKeyMap(XK_KP_Equal, 0)); // ??? + KeyMap.push_back(SKeyMap(XK_KP_Multiply, KEY_MULTIPLY)); + KeyMap.push_back(SKeyMap(XK_KP_Add, KEY_ADD)); + KeyMap.push_back(SKeyMap(XK_KP_Separator, KEY_SEPARATOR)); + KeyMap.push_back(SKeyMap(XK_KP_Subtract, KEY_SUBTRACT)); + KeyMap.push_back(SKeyMap(XK_KP_Decimal, KEY_DECIMAL)); + KeyMap.push_back(SKeyMap(XK_KP_Divide, KEY_DIVIDE)); + KeyMap.push_back(SKeyMap(XK_KP_0, KEY_KEY_0)); + KeyMap.push_back(SKeyMap(XK_KP_1, KEY_KEY_1)); + KeyMap.push_back(SKeyMap(XK_KP_2, KEY_KEY_2)); + KeyMap.push_back(SKeyMap(XK_KP_3, KEY_KEY_3)); + KeyMap.push_back(SKeyMap(XK_KP_4, KEY_KEY_4)); + KeyMap.push_back(SKeyMap(XK_KP_5, KEY_KEY_5)); + KeyMap.push_back(SKeyMap(XK_KP_6, KEY_KEY_6)); + KeyMap.push_back(SKeyMap(XK_KP_7, KEY_KEY_7)); + KeyMap.push_back(SKeyMap(XK_KP_8, KEY_KEY_8)); + KeyMap.push_back(SKeyMap(XK_KP_9, KEY_KEY_9)); + KeyMap.push_back(SKeyMap(XK_F1, KEY_F1)); + KeyMap.push_back(SKeyMap(XK_F2, KEY_F2)); + KeyMap.push_back(SKeyMap(XK_F3, KEY_F3)); + KeyMap.push_back(SKeyMap(XK_F4, KEY_F4)); + KeyMap.push_back(SKeyMap(XK_F5, KEY_F5)); + KeyMap.push_back(SKeyMap(XK_F6, KEY_F6)); + KeyMap.push_back(SKeyMap(XK_F7, KEY_F7)); + KeyMap.push_back(SKeyMap(XK_F8, KEY_F8)); + KeyMap.push_back(SKeyMap(XK_F9, KEY_F9)); + KeyMap.push_back(SKeyMap(XK_F10, KEY_F10)); + KeyMap.push_back(SKeyMap(XK_F11, KEY_F11)); + KeyMap.push_back(SKeyMap(XK_F12, KEY_F12)); + KeyMap.push_back(SKeyMap(XK_Shift_L, KEY_LSHIFT)); + KeyMap.push_back(SKeyMap(XK_Shift_R, KEY_RSHIFT)); + KeyMap.push_back(SKeyMap(XK_Control_L, KEY_LCONTROL)); + KeyMap.push_back(SKeyMap(XK_Control_R, KEY_RCONTROL)); + KeyMap.push_back(SKeyMap(XK_Caps_Lock, KEY_CAPITAL)); + KeyMap.push_back(SKeyMap(XK_Shift_Lock, KEY_CAPITAL)); + KeyMap.push_back(SKeyMap(XK_Meta_L, KEY_LWIN)); + KeyMap.push_back(SKeyMap(XK_Meta_R, KEY_RWIN)); + KeyMap.push_back(SKeyMap(XK_Alt_L, KEY_LMENU)); + KeyMap.push_back(SKeyMap(XK_Alt_R, KEY_RMENU)); + KeyMap.push_back(SKeyMap(XK_ISO_Level3_Shift, KEY_RMENU)); + KeyMap.push_back(SKeyMap(XK_Menu, KEY_MENU)); + KeyMap.push_back(SKeyMap(XK_space, KEY_SPACE)); + KeyMap.push_back(SKeyMap(XK_exclam, 0)); //? + KeyMap.push_back(SKeyMap(XK_quotedbl, 0)); //? + KeyMap.push_back(SKeyMap(XK_section, 0)); //? + KeyMap.push_back(SKeyMap(XK_numbersign, 0)); //? + KeyMap.push_back(SKeyMap(XK_dollar, 0)); //? + KeyMap.push_back(SKeyMap(XK_percent, 0)); //? + KeyMap.push_back(SKeyMap(XK_ampersand, 0)); //? + KeyMap.push_back(SKeyMap(XK_apostrophe, 0)); //? + KeyMap.push_back(SKeyMap(XK_parenleft, 0)); //? + KeyMap.push_back(SKeyMap(XK_parenright, 0)); //? + KeyMap.push_back(SKeyMap(XK_asterisk, 0)); //? + KeyMap.push_back(SKeyMap(XK_plus, KEY_PLUS)); //? + KeyMap.push_back(SKeyMap(XK_comma, KEY_COMMA)); //? + KeyMap.push_back(SKeyMap(XK_minus, KEY_MINUS)); //? + KeyMap.push_back(SKeyMap(XK_period, KEY_PERIOD)); //? + KeyMap.push_back(SKeyMap(XK_slash, 0)); //? + KeyMap.push_back(SKeyMap(XK_0, KEY_KEY_0)); + KeyMap.push_back(SKeyMap(XK_1, KEY_KEY_1)); + KeyMap.push_back(SKeyMap(XK_2, KEY_KEY_2)); + KeyMap.push_back(SKeyMap(XK_3, KEY_KEY_3)); + KeyMap.push_back(SKeyMap(XK_4, KEY_KEY_4)); + KeyMap.push_back(SKeyMap(XK_5, KEY_KEY_5)); + KeyMap.push_back(SKeyMap(XK_6, KEY_KEY_6)); + KeyMap.push_back(SKeyMap(XK_7, KEY_KEY_7)); + KeyMap.push_back(SKeyMap(XK_8, KEY_KEY_8)); + KeyMap.push_back(SKeyMap(XK_9, KEY_KEY_9)); + KeyMap.push_back(SKeyMap(XK_colon, 0)); //? + KeyMap.push_back(SKeyMap(XK_semicolon, 0)); //? + KeyMap.push_back(SKeyMap(XK_less, 0)); //? + KeyMap.push_back(SKeyMap(XK_equal, 0)); //? + KeyMap.push_back(SKeyMap(XK_greater, 0)); //? + KeyMap.push_back(SKeyMap(XK_question, 0)); //? + KeyMap.push_back(SKeyMap(XK_at, 0)); //? + KeyMap.push_back(SKeyMap(XK_mu, 0)); //? + KeyMap.push_back(SKeyMap(XK_EuroSign, 0)); //? + KeyMap.push_back(SKeyMap(XK_A, KEY_KEY_A)); + KeyMap.push_back(SKeyMap(XK_B, KEY_KEY_B)); + KeyMap.push_back(SKeyMap(XK_C, KEY_KEY_C)); + KeyMap.push_back(SKeyMap(XK_D, KEY_KEY_D)); + KeyMap.push_back(SKeyMap(XK_E, KEY_KEY_E)); + KeyMap.push_back(SKeyMap(XK_F, KEY_KEY_F)); + KeyMap.push_back(SKeyMap(XK_G, KEY_KEY_G)); + KeyMap.push_back(SKeyMap(XK_H, KEY_KEY_H)); + KeyMap.push_back(SKeyMap(XK_I, KEY_KEY_I)); + KeyMap.push_back(SKeyMap(XK_J, KEY_KEY_J)); + KeyMap.push_back(SKeyMap(XK_K, KEY_KEY_K)); + KeyMap.push_back(SKeyMap(XK_L, KEY_KEY_L)); + KeyMap.push_back(SKeyMap(XK_M, KEY_KEY_M)); + KeyMap.push_back(SKeyMap(XK_N, KEY_KEY_N)); + KeyMap.push_back(SKeyMap(XK_O, KEY_KEY_O)); + KeyMap.push_back(SKeyMap(XK_P, KEY_KEY_P)); + KeyMap.push_back(SKeyMap(XK_Q, KEY_KEY_Q)); + KeyMap.push_back(SKeyMap(XK_R, KEY_KEY_R)); + KeyMap.push_back(SKeyMap(XK_S, KEY_KEY_S)); + KeyMap.push_back(SKeyMap(XK_T, KEY_KEY_T)); + KeyMap.push_back(SKeyMap(XK_U, KEY_KEY_U)); + KeyMap.push_back(SKeyMap(XK_V, KEY_KEY_V)); + KeyMap.push_back(SKeyMap(XK_W, KEY_KEY_W)); + KeyMap.push_back(SKeyMap(XK_X, KEY_KEY_X)); + KeyMap.push_back(SKeyMap(XK_Y, KEY_KEY_Y)); + KeyMap.push_back(SKeyMap(XK_Z, KEY_KEY_Z)); + KeyMap.push_back(SKeyMap(XK_Adiaeresis, 0)); //? + KeyMap.push_back(SKeyMap(XK_Odiaeresis, 0)); //? + KeyMap.push_back(SKeyMap(XK_Udiaeresis, 0)); //? + KeyMap.push_back(SKeyMap(XK_bracketleft, 0)); //? + KeyMap.push_back(SKeyMap(XK_backslash, 0)); //? + KeyMap.push_back(SKeyMap(XK_bracketright, 0)); //? + KeyMap.push_back(SKeyMap(XK_asciicircum, 0)); //? + KeyMap.push_back(SKeyMap(XK_degree, 0)); //? + KeyMap.push_back(SKeyMap(XK_underscore, 0)); //? + KeyMap.push_back(SKeyMap(XK_grave, 0)); //? + KeyMap.push_back(SKeyMap(XK_acute, 0)); //? + KeyMap.push_back(SKeyMap(XK_quoteleft, 0)); //? + KeyMap.push_back(SKeyMap(XK_a, KEY_KEY_A)); + KeyMap.push_back(SKeyMap(XK_b, KEY_KEY_B)); + KeyMap.push_back(SKeyMap(XK_c, KEY_KEY_C)); + KeyMap.push_back(SKeyMap(XK_d, KEY_KEY_D)); + KeyMap.push_back(SKeyMap(XK_e, KEY_KEY_E)); + KeyMap.push_back(SKeyMap(XK_f, KEY_KEY_F)); + KeyMap.push_back(SKeyMap(XK_g, KEY_KEY_G)); + KeyMap.push_back(SKeyMap(XK_h, KEY_KEY_H)); + KeyMap.push_back(SKeyMap(XK_i, KEY_KEY_I)); + KeyMap.push_back(SKeyMap(XK_j, KEY_KEY_J)); + KeyMap.push_back(SKeyMap(XK_k, KEY_KEY_K)); + KeyMap.push_back(SKeyMap(XK_l, KEY_KEY_L)); + KeyMap.push_back(SKeyMap(XK_m, KEY_KEY_M)); + KeyMap.push_back(SKeyMap(XK_n, KEY_KEY_N)); + KeyMap.push_back(SKeyMap(XK_o, KEY_KEY_O)); + KeyMap.push_back(SKeyMap(XK_p, KEY_KEY_P)); + KeyMap.push_back(SKeyMap(XK_q, KEY_KEY_Q)); + KeyMap.push_back(SKeyMap(XK_r, KEY_KEY_R)); + KeyMap.push_back(SKeyMap(XK_s, KEY_KEY_S)); + KeyMap.push_back(SKeyMap(XK_t, KEY_KEY_T)); + KeyMap.push_back(SKeyMap(XK_u, KEY_KEY_U)); + KeyMap.push_back(SKeyMap(XK_v, KEY_KEY_V)); + KeyMap.push_back(SKeyMap(XK_w, KEY_KEY_W)); + KeyMap.push_back(SKeyMap(XK_x, KEY_KEY_X)); + KeyMap.push_back(SKeyMap(XK_y, KEY_KEY_Y)); + KeyMap.push_back(SKeyMap(XK_z, KEY_KEY_Z)); + KeyMap.push_back(SKeyMap(XK_ssharp, 0)); //? + KeyMap.push_back(SKeyMap(XK_adiaeresis, 0)); //? + KeyMap.push_back(SKeyMap(XK_odiaeresis, 0)); //? + KeyMap.push_back(SKeyMap(XK_udiaeresis, 0)); //? + + KeyMap.sort(); +#endif +} + + +IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& param) +{ + CIrrDeviceLinux* dev = new CIrrDeviceLinux( + param.DriverType, + param.WindowSize, + param.Bits, + param.Fullscreen, + param.Stencilbuffer, + param.Vsync, + param.AntiAlias, + param.EventReceiver, + param.SDK_version_do_not_use); + + if (dev && !dev->getVideoDriver() && param.DriverType != video::EDT_NULL) + { + dev->drop(); + dev = 0; + } + + return dev; +} + + +} // end namespace + +#endif // LINUX + diff --git a/src/dep/src/irrlicht/CIrrDeviceLinux.h b/src/dep/src/irrlicht/CIrrDeviceLinux.h index 7ca75dc..0c3a911 100644 --- a/src/dep/src/irrlicht/CIrrDeviceLinux.h +++ b/src/dep/src/irrlicht/CIrrDeviceLinux.h @@ -1,306 +1,306 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IRR_DEVICE_LINUX_H_INCLUDED__ -#define __C_IRR_DEVICE_LINUX_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef LINUX - -#include "CIrrDeviceStub.h" -#include "IrrlichtDevice.h" -#include "IImagePresenter.h" -#include "IGUIEnvironment.h" -#include "ICursorControl.h" - -#ifdef _IRR_COMPILE_WITH_X11_ - -#ifdef _IRR_COMPILE_WITH_OPENGL_ -#include -#define GLX_GLXEXT_LEGACY 1 -#include -#ifndef __sun__ -#include "glxext.h" -#endif -#endif - -#include -#include -#ifdef _IRR_LINUX_X11_VIDMODE_ -#include -#endif -#ifdef _IRR_LINUX_X11_RANDR_ -#include -#endif -#include - -#else -#define KeySym s32 -#endif - -namespace irr -{ - - class CIrrDeviceLinux : public CIrrDeviceStub, public video::IImagePresenter - { - public: - - //! constructor - CIrrDeviceLinux(video::E_DRIVER_TYPE deviceType, - const core::dimension2d& windowSize, u32 bits, - bool fullscreen, bool stencilbuffer, bool vsync, bool antiAlias, IEventReceiver* receiver, - const char* version); - - //! destructor - virtual ~CIrrDeviceLinux(); - - //! runs the device. Returns false if device wants to be deleted - virtual bool run(); - - //! Cause the device to temporarily pause execution and let other processes to run - // This should bring down processor usage without major performance loss for Irrlicht - virtual void yield(); - - //! Pause execution and let other processes to run for a specified amount of time. - virtual void sleep(u32 timeMs, bool pauseTimer); - - //! sets the caption of the window - virtual void setWindowCaption(const wchar_t* text); - - //! returns if window is active. if not, nothing need to be drawn - virtual bool isWindowActive(); - - //! presents a surface in the client area - virtual void present(video::IImage* surface, s32 windowId = 0, core::rect* src=0 ); - - //! notifies the device that it should close itself - virtual void closeDevice(); - - private: - - //! create the driver - void createDriver(const core::dimension2d& windowSize, - u32 bits, bool vsync); - - bool createWindow(const core::dimension2d& windowSize, u32 bits); - - void createKeyMap(); - - //! Implementation of the linux cursor control - class CCursorControl : public gui::ICursorControl - { - public: - - CCursorControl(CIrrDeviceLinux* dev, bool null) - : Device(dev), IsVisible(true), Null(null) - { -#ifdef _IRR_COMPILE_WITH_X11_ - Device->grab(); - if (!null) - { - XGCValues values; - unsigned long valuemask = 0; - - XColor fg, bg; - int depth = 1; - - // this code, for making the cursor invisible was sent in by - // Sirshane, thank your very much! - - Colormap screen_colormap; - - invisBitmap = XCreatePixmap( Device->display, Device->window, 32, 32, depth ); - maskBitmap = XCreatePixmap( Device->display, Device->window, 32, 32, depth ); - - screen_colormap = DefaultColormap( Device->display, DefaultScreen( Device->display ) ); - XAllocNamedColor( Device->display, screen_colormap, "black", &fg, &fg ); - XAllocNamedColor( Device->display, screen_colormap, "white", &bg, &bg ); - - gc = XCreateGC( Device->display, invisBitmap, valuemask, &values ); - - XSetForeground( Device->display, gc, BlackPixel( Device->display, DefaultScreen( Device->display ) ) ); - XFillRectangle( Device->display, invisBitmap, gc, 0, 0, 32, 32 ); - XFillRectangle( Device->display, maskBitmap, gc, 0, 0, 32, 32 ); - - invisCursor = XCreatePixmapCursor( Device->display, invisBitmap, maskBitmap, &fg, &bg, 1, 1 ); - } -#endif - } - - ~CCursorControl() - { - XFreeGC(Device->display, gc); - Device->drop(); - } - - //! Changes the visible state of the mouse cursor. - virtual void setVisible(bool visible) - { - IsVisible = visible; -#ifdef _IRR_COMPILE_WITH_X11_ - if (!Null) - { - if ( !IsVisible ) - XDefineCursor( Device->display, Device->window, invisCursor ); - else - XUndefineCursor( Device->display, Device->window ); - } -#endif - } - - //! Returns if the cursor is currently visible. - virtual bool isVisible() - { - return IsVisible; - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(f32 x, f32 y) - { - setPosition((s32)(x*Device->Width), (s32)(y*Device->Height)); - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(s32 x, s32 y) - { -#ifdef _IRR_COMPILE_WITH_X11_ - if (!Null) - { - XWarpPointer(Device->display, - None, - Device->window, 0, 0, - Device->Width, - Device->Height, x, y); - XFlush(Device->display); - } -#endif - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d getPosition() - { - updateCursorPos(); - return CursorPos; - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d getRelativePosition() - { - updateCursorPos(); - return core::position2d(CursorPos.X / (f32)Device->Width, - CursorPos.Y / (f32)Device->Height); - } - - private: - - void updateCursorPos() - { -#ifdef _IRR_COMPILE_WITH_X11_ - if (Null) - return; - - Window tmp; - int itmp1, itmp2; - unsigned int maskreturn; - XQueryPointer(Device->display, Device->window, - &tmp, &tmp, - &itmp1, &itmp2, - &CursorPos.X, &CursorPos.Y, &maskreturn); - - if (CursorPos.X < 0) - CursorPos.X = 0; - if (CursorPos.X > (s32) Device->Width) - CursorPos.X = Device->Width; - if (CursorPos.Y < 0) - CursorPos.Y = 0; - if (CursorPos.Y > (s32) Device->Height) - CursorPos.Y = Device->Height; -#endif - } - - core::position2d CursorPos; - CIrrDeviceLinux* Device; - bool IsVisible; - bool Null; -#ifdef _IRR_COMPILE_WITH_X11_ - GC gc; - Cursor invisCursor; - Pixmap invisBitmap; - Pixmap maskBitmap; -#endif - }; - - friend class CCursorControl; - -#ifdef _IRR_COMPILE_WITH_X11_ - Display *display; - int screennr; - Window window; - XSetWindowAttributes attributes; - XEvent event; - XImage* SoftwareImage; - #ifdef _IRR_LINUX_X11_VIDMODE_ - XF86VidModeModeInfo oldVideoMode; - #endif - #ifdef _IRR_LINUX_X11_RANDR_ - SizeID oldRandrMode; - Rotation oldRandrRotation; - #endif - #ifdef _IRR_COMPILE_WITH_OPENGL_ - GLXWindow glxWin; - GLXContext Context; - #endif -#endif - bool Fullscreen; - bool StencilBuffer; - bool AntiAlias; - video::E_DRIVER_TYPE DriverType; - - u32 Width, Height, Depth; - bool Close; - bool WindowActive; - bool WindowMinimized; - bool UseXVidMode; - bool UseXRandR; - bool UseGLXWindow; - - struct SKeyMap - { - SKeyMap() {} - SKeyMap(s32 x11, s32 win32) - : X11Key(x11), Win32Key(win32) - { - } - - KeySym X11Key; - s32 Win32Key; - - bool operator<(const SKeyMap& o) const - { - return X11Key KeyMap; - }; - - -} // end namespace irr - -#endif // LINUX -#endif // __C_IRR_DEVICE_LINUX_H_INCLUDED__ - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_IRR_DEVICE_LINUX_H_INCLUDED__ +#define __C_IRR_DEVICE_LINUX_H_INCLUDED__ + +#include "IrrCompileConfig.h" + +#ifdef LINUX + +#include "CIrrDeviceStub.h" +#include "IrrlichtDevice.h" +#include "IImagePresenter.h" +#include "IGUIEnvironment.h" +#include "ICursorControl.h" + +#ifdef _IRR_COMPILE_WITH_X11_ + +#ifdef _IRR_COMPILE_WITH_OPENGL_ +#include +#define GLX_GLXEXT_LEGACY 1 +#include +#ifndef __sun__ +#include "glxext.h" +#endif +#endif + +#include +#include +#ifdef _IRR_LINUX_X11_VIDMODE_ +#include +#endif +#ifdef _IRR_LINUX_X11_RANDR_ +#include +#endif +#include + +#else +#define KeySym s32 +#endif + +namespace irr +{ + + class CIrrDeviceLinux : public CIrrDeviceStub, public video::IImagePresenter + { + public: + + //! constructor + CIrrDeviceLinux(video::E_DRIVER_TYPE deviceType, + const core::dimension2d& windowSize, u32 bits, + bool fullscreen, bool stencilbuffer, bool vsync, bool antiAlias, IEventReceiver* receiver, + const char* version); + + //! destructor + virtual ~CIrrDeviceLinux(); + + //! runs the device. Returns false if device wants to be deleted + virtual bool run(); + + //! Cause the device to temporarily pause execution and let other processes to run + // This should bring down processor usage without major performance loss for Irrlicht + virtual void yield(); + + //! Pause execution and let other processes to run for a specified amount of time. + virtual void sleep(u32 timeMs, bool pauseTimer); + + //! sets the caption of the window + virtual void setWindowCaption(const wchar_t* text); + + //! returns if window is active. if not, nothing need to be drawn + virtual bool isWindowActive(); + + //! presents a surface in the client area + virtual void present(video::IImage* surface, s32 windowId = 0, core::rect* src=0 ); + + //! notifies the device that it should close itself + virtual void closeDevice(); + + private: + + //! create the driver + void createDriver(const core::dimension2d& windowSize, + u32 bits, bool vsync); + + bool createWindow(const core::dimension2d& windowSize, u32 bits); + + void createKeyMap(); + + //! Implementation of the linux cursor control + class CCursorControl : public gui::ICursorControl + { + public: + + CCursorControl(CIrrDeviceLinux* dev, bool null) + : Device(dev), IsVisible(true), Null(null) + { +#ifdef _IRR_COMPILE_WITH_X11_ + Device->grab(); + if (!null) + { + XGCValues values; + unsigned long valuemask = 0; + + XColor fg, bg; + int depth = 1; + + // this code, for making the cursor invisible was sent in by + // Sirshane, thank your very much! + + Colormap screen_colormap; + + invisBitmap = XCreatePixmap( Device->display, Device->window, 32, 32, depth ); + maskBitmap = XCreatePixmap( Device->display, Device->window, 32, 32, depth ); + + screen_colormap = DefaultColormap( Device->display, DefaultScreen( Device->display ) ); + XAllocNamedColor( Device->display, screen_colormap, "black", &fg, &fg ); + XAllocNamedColor( Device->display, screen_colormap, "white", &bg, &bg ); + + gc = XCreateGC( Device->display, invisBitmap, valuemask, &values ); + + XSetForeground( Device->display, gc, BlackPixel( Device->display, DefaultScreen( Device->display ) ) ); + XFillRectangle( Device->display, invisBitmap, gc, 0, 0, 32, 32 ); + XFillRectangle( Device->display, maskBitmap, gc, 0, 0, 32, 32 ); + + invisCursor = XCreatePixmapCursor( Device->display, invisBitmap, maskBitmap, &fg, &bg, 1, 1 ); + } +#endif + } + + ~CCursorControl() + { + XFreeGC(Device->display, gc); + Device->drop(); + } + + //! Changes the visible state of the mouse cursor. + virtual void setVisible(bool visible) + { + IsVisible = visible; +#ifdef _IRR_COMPILE_WITH_X11_ + if (!Null) + { + if ( !IsVisible ) + XDefineCursor( Device->display, Device->window, invisCursor ); + else + XUndefineCursor( Device->display, Device->window ); + } +#endif + } + + //! Returns if the cursor is currently visible. + virtual bool isVisible() + { + return IsVisible; + } + + //! Sets the new position of the cursor. + virtual void setPosition(const core::position2d &pos) + { + setPosition(pos.X, pos.Y); + } + + //! Sets the new position of the cursor. + virtual void setPosition(f32 x, f32 y) + { + setPosition((s32)(x*Device->Width), (s32)(y*Device->Height)); + } + + //! Sets the new position of the cursor. + virtual void setPosition(const core::position2d &pos) + { + setPosition(pos.X, pos.Y); + } + + //! Sets the new position of the cursor. + virtual void setPosition(s32 x, s32 y) + { +#ifdef _IRR_COMPILE_WITH_X11_ + if (!Null) + { + XWarpPointer(Device->display, + None, + Device->window, 0, 0, + Device->Width, + Device->Height, x, y); + XFlush(Device->display); + } +#endif + } + + //! Returns the current position of the mouse cursor. + virtual core::position2d getPosition() + { + updateCursorPos(); + return CursorPos; + } + + //! Returns the current position of the mouse cursor. + virtual core::position2d getRelativePosition() + { + updateCursorPos(); + return core::position2d(CursorPos.X / (f32)Device->Width, + CursorPos.Y / (f32)Device->Height); + } + + private: + + void updateCursorPos() + { +#ifdef _IRR_COMPILE_WITH_X11_ + if (Null) + return; + + Window tmp; + int itmp1, itmp2; + unsigned int maskreturn; + XQueryPointer(Device->display, Device->window, + &tmp, &tmp, + &itmp1, &itmp2, + &CursorPos.X, &CursorPos.Y, &maskreturn); + + if (CursorPos.X < 0) + CursorPos.X = 0; + if (CursorPos.X > (s32) Device->Width) + CursorPos.X = Device->Width; + if (CursorPos.Y < 0) + CursorPos.Y = 0; + if (CursorPos.Y > (s32) Device->Height) + CursorPos.Y = Device->Height; +#endif + } + + core::position2d CursorPos; + CIrrDeviceLinux* Device; + bool IsVisible; + bool Null; +#ifdef _IRR_COMPILE_WITH_X11_ + GC gc; + Cursor invisCursor; + Pixmap invisBitmap; + Pixmap maskBitmap; +#endif + }; + + friend class CCursorControl; + +#ifdef _IRR_COMPILE_WITH_X11_ + Display *display; + int screennr; + Window window; + XSetWindowAttributes attributes; + XEvent event; + XImage* SoftwareImage; + #ifdef _IRR_LINUX_X11_VIDMODE_ + XF86VidModeModeInfo oldVideoMode; + #endif + #ifdef _IRR_LINUX_X11_RANDR_ + SizeID oldRandrMode; + Rotation oldRandrRotation; + #endif + #ifdef _IRR_COMPILE_WITH_OPENGL_ + GLXWindow glxWin; + GLXContext Context; + #endif +#endif + bool Fullscreen; + bool StencilBuffer; + bool AntiAlias; + video::E_DRIVER_TYPE DriverType; + + u32 Width, Height, Depth; + bool Close; + bool WindowActive; + bool WindowMinimized; + bool UseXVidMode; + bool UseXRandR; + bool UseGLXWindow; + + struct SKeyMap + { + SKeyMap() {} + SKeyMap(s32 x11, s32 win32) + : X11Key(x11), Win32Key(win32) + { + } + + KeySym X11Key; + s32 Win32Key; + + bool operator<(const SKeyMap& o) const + { + return X11Key KeyMap; + }; + + +} // end namespace irr + +#endif // LINUX +#endif // __C_IRR_DEVICE_LINUX_H_INCLUDED__ + diff --git a/src/dep/src/irrlicht/CIrrDeviceStub.cpp b/src/dep/src/irrlicht/CIrrDeviceStub.cpp index 61519a5..09987f5 100644 --- a/src/dep/src/irrlicht/CIrrDeviceStub.cpp +++ b/src/dep/src/irrlicht/CIrrDeviceStub.cpp @@ -1,205 +1,205 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CIrrDeviceStub.h" -#include "IEventReceiver.h" -#include "irrList.h" -#include "os.h" -#include "IrrCompileConfig.h" -#include "CTimer.h" -#include "CLogger.h" -#include "irrString.h" -#include "irrlicht.h" - -namespace irr -{ - -//! constructor -CIrrDeviceStub::CIrrDeviceStub(const char* version, irr::IEventReceiver* recv) -: IrrlichtDevice(), VideoDriver(0), GUIEnvironment(0), SceneManager(0), Timer(new irr::CTimer()), CursorControl(0), UserReceiver(recv), Logger(new CLogger(UserReceiver)), Operator(0), FileSystem(io::createFileSystem()) -{ - os::Printer::Logger = Logger; - - core::stringc s = "Irrlicht Engine version "; - s.append(getVersion()); - os::Printer::log(s.c_str(), ELL_NONE); - - checkVersion(version); -} - - -CIrrDeviceStub::~CIrrDeviceStub() -{ - FileSystem->drop(); - - if (GUIEnvironment) - GUIEnvironment->drop(); - - if (VideoDriver) - VideoDriver->drop(); - - if (SceneManager) - SceneManager->drop(); - - if (CursorControl) - CursorControl->drop(); - - if (Operator) - Operator->drop(); - - CursorControl = 0; - - Timer->drop(); - - Logger->drop(); -} - - -void CIrrDeviceStub::createGUIAndScene() -{ - // create gui environment - GUIEnvironment = gui::createGUIEnvironment(FileSystem, VideoDriver, Operator); - - // create Scene manager - SceneManager = scene::createSceneManager(VideoDriver, FileSystem, CursorControl, GUIEnvironment); - - setEventReceiver(UserReceiver); -} - - -//! returns the video driver -video::IVideoDriver* CIrrDeviceStub::getVideoDriver() -{ - return VideoDriver; -} - - - -//! return file system -io::IFileSystem* CIrrDeviceStub::getFileSystem() -{ - return FileSystem; -} - - - -//! returns the gui environment -gui::IGUIEnvironment* CIrrDeviceStub::getGUIEnvironment() -{ - return GUIEnvironment; -} - - - -//! returns the scene manager -scene::ISceneManager* CIrrDeviceStub::getSceneManager() -{ - return SceneManager; -} - - -//! \return Returns a pointer to the ITimer object. With it the -//! current Time can be received. -ITimer* CIrrDeviceStub::getTimer() -{ - return Timer; -} - - -//! Returns the version of the engine. -const char* CIrrDeviceStub::getVersion() -{ - return IRRLICHT_SDK_VERSION; -} - -//! \return Returns a pointer to the mouse cursor control interface. -gui::ICursorControl* CIrrDeviceStub::getCursorControl() -{ - return CursorControl; -} - - -//! \return Returns a pointer to a list with all video modes supported -//! by the gfx adapter. -video::IVideoModeList* CIrrDeviceStub::getVideoModeList() -{ - return &VideoModeList; -} - - -//! checks version of sdk and prints warning if there might be a problem -bool CIrrDeviceStub::checkVersion(const char* version) -{ - if (strcmp(getVersion(), version)) - { - core::stringc w; - w = "Warning: The library version of the Irrlicht Engine ("; - w += getVersion(); - w += ") does not match the version the application was compiled with ("; - w += version; - w += "). This may cause problems."; - os::Printer::log(w.c_str(), ELL_WARNING); - return false; - } - - return true; -} - - -//! send the event to the right receiver -void CIrrDeviceStub::postEventFromUser(SEvent event) -{ - bool absorbed = false; - - if (UserReceiver) - absorbed = UserReceiver->OnEvent(event); - - if (!absorbed && GUIEnvironment) - absorbed = GUIEnvironment->postEventFromUser(event); - - if (!absorbed && SceneManager) - absorbed = SceneManager->postEventFromUser(event); -} - - -//! Sets a new event receiver to receive events -void CIrrDeviceStub::setEventReceiver(IEventReceiver* receiver) -{ - UserReceiver = receiver; - Logger->setReceiver(receiver); - if (GUIEnvironment) - GUIEnvironment->setUserEventReceiver(receiver); -} - - -//! Returns poinhter to the current event receiver. Returns 0 if there is none. -IEventReceiver* CIrrDeviceStub::getEventReceiver() -{ - return UserReceiver; -} - - -//! \return Returns a pointer to the logger. -ILogger* CIrrDeviceStub::getLogger() -{ - return Logger; -} - - -//! Returns the operation system opertator object. -IOSOperator* CIrrDeviceStub::getOSOperator() -{ - return Operator; -} - - -//! Sets if the window should be resizeable in windowed mode. -void CIrrDeviceStub::setResizeAble(bool resize) -{ - -} - - -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CIrrDeviceStub.h" +#include "IEventReceiver.h" +#include "irrList.h" +#include "os.h" +#include "IrrCompileConfig.h" +#include "CTimer.h" +#include "CLogger.h" +#include "irrString.h" +#include "irrlicht.h" + +namespace irr +{ + +//! constructor +CIrrDeviceStub::CIrrDeviceStub(const char* version, irr::IEventReceiver* recv) +: IrrlichtDevice(), VideoDriver(0), GUIEnvironment(0), SceneManager(0), Timer(new irr::CTimer()), CursorControl(0), UserReceiver(recv), Logger(new CLogger(UserReceiver)), Operator(0), FileSystem(io::createFileSystem()) +{ + os::Printer::Logger = Logger; + + core::stringc s = "Irrlicht Engine version "; + s.append(getVersion()); + os::Printer::log(s.c_str(), ELL_NONE); + + checkVersion(version); +} + + +CIrrDeviceStub::~CIrrDeviceStub() +{ + FileSystem->drop(); + + if (GUIEnvironment) + GUIEnvironment->drop(); + + if (VideoDriver) + VideoDriver->drop(); + + if (SceneManager) + SceneManager->drop(); + + if (CursorControl) + CursorControl->drop(); + + if (Operator) + Operator->drop(); + + CursorControl = 0; + + Timer->drop(); + + Logger->drop(); +} + + +void CIrrDeviceStub::createGUIAndScene() +{ + // create gui environment + GUIEnvironment = gui::createGUIEnvironment(FileSystem, VideoDriver, Operator); + + // create Scene manager + SceneManager = scene::createSceneManager(VideoDriver, FileSystem, CursorControl, GUIEnvironment); + + setEventReceiver(UserReceiver); +} + + +//! returns the video driver +video::IVideoDriver* CIrrDeviceStub::getVideoDriver() +{ + return VideoDriver; +} + + + +//! return file system +io::IFileSystem* CIrrDeviceStub::getFileSystem() +{ + return FileSystem; +} + + + +//! returns the gui environment +gui::IGUIEnvironment* CIrrDeviceStub::getGUIEnvironment() +{ + return GUIEnvironment; +} + + + +//! returns the scene manager +scene::ISceneManager* CIrrDeviceStub::getSceneManager() +{ + return SceneManager; +} + + +//! \return Returns a pointer to the ITimer object. With it the +//! current Time can be received. +ITimer* CIrrDeviceStub::getTimer() +{ + return Timer; +} + + +//! Returns the version of the engine. +const char* CIrrDeviceStub::getVersion() +{ + return IRRLICHT_SDK_VERSION; +} + +//! \return Returns a pointer to the mouse cursor control interface. +gui::ICursorControl* CIrrDeviceStub::getCursorControl() +{ + return CursorControl; +} + + +//! \return Returns a pointer to a list with all video modes supported +//! by the gfx adapter. +video::IVideoModeList* CIrrDeviceStub::getVideoModeList() +{ + return &VideoModeList; +} + + +//! checks version of sdk and prints warning if there might be a problem +bool CIrrDeviceStub::checkVersion(const char* version) +{ + if (strcmp(getVersion(), version)) + { + core::stringc w; + w = "Warning: The library version of the Irrlicht Engine ("; + w += getVersion(); + w += ") does not match the version the application was compiled with ("; + w += version; + w += "). This may cause problems."; + os::Printer::log(w.c_str(), ELL_WARNING); + return false; + } + + return true; +} + + +//! send the event to the right receiver +void CIrrDeviceStub::postEventFromUser(SEvent event) +{ + bool absorbed = false; + + if (UserReceiver) + absorbed = UserReceiver->OnEvent(event); + + if (!absorbed && GUIEnvironment) + absorbed = GUIEnvironment->postEventFromUser(event); + + if (!absorbed && SceneManager) + absorbed = SceneManager->postEventFromUser(event); +} + + +//! Sets a new event receiver to receive events +void CIrrDeviceStub::setEventReceiver(IEventReceiver* receiver) +{ + UserReceiver = receiver; + Logger->setReceiver(receiver); + if (GUIEnvironment) + GUIEnvironment->setUserEventReceiver(receiver); +} + + +//! Returns poinhter to the current event receiver. Returns 0 if there is none. +IEventReceiver* CIrrDeviceStub::getEventReceiver() +{ + return UserReceiver; +} + + +//! \return Returns a pointer to the logger. +ILogger* CIrrDeviceStub::getLogger() +{ + return Logger; +} + + +//! Returns the operation system opertator object. +IOSOperator* CIrrDeviceStub::getOSOperator() +{ + return Operator; +} + + +//! Sets if the window should be resizeable in windowed mode. +void CIrrDeviceStub::setResizeAble(bool resize) +{ + +} + + +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CIrrDeviceStub.h b/src/dep/src/irrlicht/CIrrDeviceStub.h index 46e8ddd..f8db7f9 100644 --- a/src/dep/src/irrlicht/CIrrDeviceStub.h +++ b/src/dep/src/irrlicht/CIrrDeviceStub.h @@ -1,123 +1,123 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IRR_DEVICE_STUB_H_INCLUDED__ -#define __C_IRR_DEVICE_STUB_H_INCLUDED__ - -#include "IrrlichtDevice.h" -#include "IImagePresenter.h" -#include "IGUIEnvironment.h" -#include "CVideoModeList.h" - -namespace irr -{ - // lots of prototypes: - class ILogger; - class CLogger; - - namespace scene - { - ISceneManager* createSceneManager(video::IVideoDriver* driver, - io::IFileSystem* fs, gui::ICursorControl* cc, gui::IGUIEnvironment *gui); - } - - namespace io - { - IFileSystem* createFileSystem(); - } - - namespace gui - { - IGUIEnvironment* createGUIEnvironment(io::IFileSystem* fs, - video::IVideoDriver* Driver, IOSOperator* op); - } - - namespace video - { - IVideoDriver* createSoftwareDriver(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter); - IVideoDriver* createSoftwareDriver2(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter); - IVideoDriver* createNullDriver(io::IFileSystem* io, const core::dimension2d& screenSize); - } - - - - //! Stub for an Irrlicht Device implementation - class CIrrDeviceStub : public IrrlichtDevice - { - public: - - //! constructor - CIrrDeviceStub(const char* version, irr::IEventReceiver* resv); - - //! destructor - virtual ~CIrrDeviceStub(); - - //! returns the video driver - virtual video::IVideoDriver* getVideoDriver(); - - //! return file system - virtual io::IFileSystem* getFileSystem(); - - //! returns the gui environment - virtual gui::IGUIEnvironment* getGUIEnvironment(); - - //! returns the scene manager - virtual scene::ISceneManager* getSceneManager(); - - //! \return Returns a pointer to the mouse cursor control interface. - virtual gui::ICursorControl* getCursorControl(); - - //! \return Returns a pointer to a list with all video modes supported - //! by the gfx adapter. - virtual video::IVideoModeList* getVideoModeList(); - - //! \return Returns a pointer to the ITimer object. With it the - //! current Time can be received. - virtual ITimer* getTimer(); - - //! Returns the version of the engine. - virtual const char* getVersion(); - - //! send the event to the right receiver - virtual void postEventFromUser(SEvent event); - - //! Sets a new event receiver to receive events - virtual void setEventReceiver(IEventReceiver* receiver); - - //! Returns poinhter to the current event receiver. Returns 0 if there is none. - virtual IEventReceiver* getEventReceiver(); - - //! \return Returns a pointer to the logger. - virtual ILogger* getLogger(); - - //! Returns the operation system opertator object. - virtual IOSOperator* getOSOperator(); - - //! Sets if the window should be resizeable in windowed mode. The default - //! is false. - virtual void setResizeAble(bool resize=false); - - protected: - - void createGUIAndScene(); - - //! checks version of sdk and prints warning if there might be a problem - bool checkVersion(const char* version); - - video::IVideoDriver* VideoDriver; - gui::IGUIEnvironment* GUIEnvironment; - scene::ISceneManager* SceneManager; - ITimer* Timer; - gui::ICursorControl* CursorControl; - video::CVideoModeList VideoModeList; - IEventReceiver* UserReceiver; - CLogger* Logger; - IOSOperator* Operator; - io::IFileSystem* FileSystem; - }; - -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_IRR_DEVICE_STUB_H_INCLUDED__ +#define __C_IRR_DEVICE_STUB_H_INCLUDED__ + +#include "IrrlichtDevice.h" +#include "IImagePresenter.h" +#include "IGUIEnvironment.h" +#include "CVideoModeList.h" + +namespace irr +{ + // lots of prototypes: + class ILogger; + class CLogger; + + namespace scene + { + ISceneManager* createSceneManager(video::IVideoDriver* driver, + io::IFileSystem* fs, gui::ICursorControl* cc, gui::IGUIEnvironment *gui); + } + + namespace io + { + IFileSystem* createFileSystem(); + } + + namespace gui + { + IGUIEnvironment* createGUIEnvironment(io::IFileSystem* fs, + video::IVideoDriver* Driver, IOSOperator* op); + } + + namespace video + { + IVideoDriver* createSoftwareDriver(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter); + IVideoDriver* createSoftwareDriver2(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter); + IVideoDriver* createNullDriver(io::IFileSystem* io, const core::dimension2d& screenSize); + } + + + + //! Stub for an Irrlicht Device implementation + class CIrrDeviceStub : public IrrlichtDevice + { + public: + + //! constructor + CIrrDeviceStub(const char* version, irr::IEventReceiver* resv); + + //! destructor + virtual ~CIrrDeviceStub(); + + //! returns the video driver + virtual video::IVideoDriver* getVideoDriver(); + + //! return file system + virtual io::IFileSystem* getFileSystem(); + + //! returns the gui environment + virtual gui::IGUIEnvironment* getGUIEnvironment(); + + //! returns the scene manager + virtual scene::ISceneManager* getSceneManager(); + + //! \return Returns a pointer to the mouse cursor control interface. + virtual gui::ICursorControl* getCursorControl(); + + //! \return Returns a pointer to a list with all video modes supported + //! by the gfx adapter. + virtual video::IVideoModeList* getVideoModeList(); + + //! \return Returns a pointer to the ITimer object. With it the + //! current Time can be received. + virtual ITimer* getTimer(); + + //! Returns the version of the engine. + virtual const char* getVersion(); + + //! send the event to the right receiver + virtual void postEventFromUser(SEvent event); + + //! Sets a new event receiver to receive events + virtual void setEventReceiver(IEventReceiver* receiver); + + //! Returns poinhter to the current event receiver. Returns 0 if there is none. + virtual IEventReceiver* getEventReceiver(); + + //! \return Returns a pointer to the logger. + virtual ILogger* getLogger(); + + //! Returns the operation system opertator object. + virtual IOSOperator* getOSOperator(); + + //! Sets if the window should be resizeable in windowed mode. The default + //! is false. + virtual void setResizeAble(bool resize=false); + + protected: + + void createGUIAndScene(); + + //! checks version of sdk and prints warning if there might be a problem + bool checkVersion(const char* version); + + video::IVideoDriver* VideoDriver; + gui::IGUIEnvironment* GUIEnvironment; + scene::ISceneManager* SceneManager; + ITimer* Timer; + gui::ICursorControl* CursorControl; + video::CVideoModeList VideoModeList; + IEventReceiver* UserReceiver; + CLogger* Logger; + IOSOperator* Operator; + io::IFileSystem* FileSystem; + }; + +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CIrrDeviceWin32.cpp b/src/dep/src/irrlicht/CIrrDeviceWin32.cpp index d46b609..044125f 100644 --- a/src/dep/src/irrlicht/CIrrDeviceWin32.cpp +++ b/src/dep/src/irrlicht/CIrrDeviceWin32.cpp @@ -1,953 +1,953 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" - -#ifdef _IRR_WINDOWS_ - -#include "CIrrDeviceWin32.h" -#include "IEventReceiver.h" -#include "irrList.h" -#include "os.h" - -#include "CTimer.h" -#include "irrString.h" -#include "COSOperator.h" -#include "dimension2d.h" -#include -#include "irrlicht.h" - - -namespace irr -{ - namespace video - { - IVideoDriver* createDirectX8Driver(const core::dimension2d& screenSize, HWND window, - u32 bits, bool fullscreen, bool stencilbuffer, io::IFileSystem* io, - bool pureSoftware, bool highPrecisionFPU, bool vsync, bool antiAlias); - - IVideoDriver* createDirectX9Driver(const core::dimension2d& screenSize, HWND window, - u32 bits, bool fullscreen, bool stencilbuffer, io::IFileSystem* io, - bool pureSoftware, bool highPrecisionFPU, bool vsync, bool antiAlias); - - IVideoDriver* createOpenGLDriver(const core::dimension2d& screenSize, HWND window, - u32 bits, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, - bool vsync, bool antiAlias); - } -} // end namespace irr - - - -struct SEnvMapper -{ - HWND hWnd; - irr::CIrrDeviceWin32* irrDev; -}; - -irr::core::list EnvMap; - -SEnvMapper* getEnvMapperFromHWnd(HWND hWnd) -{ - irr::core::list::Iterator it = EnvMap.begin(); - for (; it!= EnvMap.end(); ++it) - if ((*it).hWnd == hWnd) - return &(*it); - - return 0; -} - -irr::CIrrDeviceWin32* getDeviceFromHWnd(HWND hWnd) -{ - irr::core::list::Iterator it = EnvMap.begin(); - for (; it!= EnvMap.end(); ++it) - if ((*it).hWnd == hWnd) - return (*it).irrDev; - - return 0; -} - - -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - #ifndef WM_MOUSEWHEEL - #define WM_MOUSEWHEEL 0x020A - #endif - #ifndef WHEEL_DELTA - #define WHEEL_DELTA 120 - #endif - - irr::CIrrDeviceWin32* dev = 0; - irr::SEvent event; - SEnvMapper* envm = 0; - - BYTE allKeys[256]; - - static irr::s32 ClickCount=0; - if (GetCapture() != hWnd && ClickCount > 0) - ClickCount = 0; - - switch (message) - { - case WM_PAINT: - { - PAINTSTRUCT ps; - BeginPaint(hWnd, &ps); - EndPaint(hWnd, &ps); - } - return 0; - - case WM_ERASEBKGND: - return 0; - - case WM_SETCURSOR: - envm = getEnvMapperFromHWnd(hWnd); - if (envm && !envm->irrDev->getWin32CursorControl()->isVisible()) - { - SetCursor(NULL); - return 0; - } - break; - - case WM_MOUSEWHEEL: - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Wheel = ((irr::f32)((short)HIWORD(wParam))) / (irr::f32)WHEEL_DELTA; - event.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; - - POINT p; // fixed by jox - p.x = 0; p.y = 0; - ClientToScreen(hWnd, &p); - event.MouseInput.X = LOWORD(lParam) - p.x; - event.MouseInput.Y = HIWORD(lParam) - p.y; - - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - break; - - case WM_LBUTTONDOWN: - ClickCount++; - SetCapture(hWnd); - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - return 0; - - case WM_LBUTTONUP: - ClickCount--; - if (ClickCount<1) - { - ClickCount=0; - ReleaseCapture(); - } - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - return 0; - - case WM_RBUTTONDOWN: - ClickCount++; - SetCapture(hWnd); - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - return 0; - - case WM_RBUTTONUP: - ClickCount--; - if (ClickCount<1) - { - ClickCount=0; - ReleaseCapture(); - } - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - return 0; - - case WM_MBUTTONDOWN: - ClickCount++; - SetCapture(hWnd); - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - return 0; - - case WM_MBUTTONUP: - ClickCount--; - if (ClickCount<1) - { - ClickCount=0; - ReleaseCapture(); - } - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - return 0; - - case WM_MOUSEMOVE: - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = irr::EMIE_MOUSE_MOVED; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - return 0; - - case WM_KEYDOWN: - { - event.EventType = irr::EET_KEY_INPUT_EVENT; - event.KeyInput.Key = (irr::EKEY_CODE)wParam; - event.KeyInput.PressedDown = true; - dev = getDeviceFromHWnd(hWnd); - - WORD KeyAsc=0; - GetKeyboardState(allKeys); - ToAscii(wParam,lParam,allKeys,&KeyAsc,0); - - event.KeyInput.Shift = ((allKeys[VK_SHIFT] & 0x80)!=0); - event.KeyInput.Control = ((allKeys[VK_CONTROL] & 0x80)!=0); - event.KeyInput.Char = KeyAsc; //KeyAsc >= 0 ? KeyAsc : 0; - - if (dev) - dev->postEventFromUser(event); - - return 0; - } - case WM_KEYUP: - { - event.EventType = irr::EET_KEY_INPUT_EVENT; - event.KeyInput.Key = (irr::EKEY_CODE)wParam; - event.KeyInput.PressedDown = false; - dev = getDeviceFromHWnd(hWnd); - - WORD KeyAsc=0; - GetKeyboardState(allKeys); - ToAscii(wParam,lParam,allKeys,&KeyAsc,0); - - event.KeyInput.Shift = ((allKeys[VK_SHIFT] & 0x80)!=0); - event.KeyInput.Control = ((allKeys[VK_CONTROL] & 0x80)!=0); - event.KeyInput.Char = KeyAsc; //KeyAsc >= 0 ? KeyAsc : 0; - - if (dev) - dev->postEventFromUser(event); - - return 0; - } - - case WM_SIZE: - { - // resize - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->OnResized(); - } - return 0; - - case WM_DESTROY: - PostQuitMessage(0); - return 0; - - case WM_SYSCOMMAND: - // prevent screensaver or monitor powersave mode from starting - if ((wParam & 0xFFF0) == SC_SCREENSAVE || - (wParam & 0xFFF0) == SC_MONITORPOWER) - return 0; - break; - } - - return DefWindowProc(hWnd, message, wParam, lParam); -} - -namespace irr -{ - -//! constructor -CIrrDeviceWin32::CIrrDeviceWin32(video::E_DRIVER_TYPE driverType, - core::dimension2d windowSize, - u32 bits, bool fullscreen, - bool stencilbuffer, bool vsync, - bool antiAlias, - bool highPrecisionFPU, - IEventReceiver* receiver, - HWND externalWindow, - const char* version) -: CIrrDeviceStub(version, receiver), HWnd(0), ChangedToFullScreen(false), - FullScreen(fullscreen), IsNonNTWindows(false), Resized(false), - ExternalWindow(false), Win32CursorControl(0) -{ - core::stringc winversion; - getWindowsVersion(winversion); - Operator = new COSOperator(winversion.c_str()); - os::Printer::log(winversion.c_str(), ELL_INFORMATION); - - // create window - - HINSTANCE hInstance = GetModuleHandle(0); - - #ifdef _DEBUG - setDebugName("CIrrDeviceWin32"); - #endif - - // create the window, only if we do not use the null device - if (driverType != video::EDT_NULL && externalWindow==0) - { - const c8* ClassName = "CIrrDeviceWin32"; - - // Register Class - WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = (WNDPROC)WndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = NULL; - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wcex.lpszMenuName = 0; - wcex.lpszClassName = ClassName; - wcex.hIconSm = 0; - - // if there is an icon, load it - wcex.hIcon = (HICON)LoadImage(hInstance, "irrlicht.ico", IMAGE_ICON, 0,0, LR_LOADFROMFILE); - - RegisterClassEx(&wcex); - - // calculate client size - - RECT clientSize; - clientSize.top = 0; - clientSize.left = 0; - clientSize.right = windowSize.Width; - clientSize.bottom = windowSize.Height; - - DWORD style = WS_POPUP; - - if (!fullscreen) - style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; - - AdjustWindowRect(&clientSize, style, FALSE); - - s32 realWidth = clientSize.right - clientSize.left; - s32 realHeight = clientSize.bottom - clientSize.top; - - s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; - s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; - - if (fullscreen) - { - windowLeft = 0; - windowTop = 0; - } - - // create window - - HWnd = CreateWindow( ClassName, "", style, windowLeft, windowTop, - realWidth, realHeight, NULL, NULL, hInstance, NULL); - - ShowWindow(HWnd , SW_SHOW); - UpdateWindow(HWnd); - - // fix ugly ATI driver bugs. Thanks to ariaci - MoveWindow(HWnd, windowLeft, windowTop, realWidth, realHeight, TRUE); - } - - // attach external window - if (externalWindow) - { - HWnd = externalWindow; - RECT r; - GetWindowRect(HWnd, &r); - windowSize.Width = r.right - r.left; - windowSize.Height = r.bottom - r.top; - fullscreen = false; - ExternalWindow = true; - } - - // create cursor control - - Win32CursorControl = new CCursorControl(windowSize, HWnd, fullscreen); - CursorControl = Win32CursorControl; - - // create driver - - createDriver(driverType, windowSize, bits, fullscreen, stencilbuffer, vsync, antiAlias, highPrecisionFPU); - - if (VideoDriver) - createGUIAndScene(); - - // register environment - - SEnvMapper em; - em.irrDev = this; - em.hWnd = HWnd; - EnvMap.push_back(em); - - // set this as active window - SetActiveWindow(HWnd); - SetForegroundWindow(HWnd); -} - - - -//! destructor -CIrrDeviceWin32::~CIrrDeviceWin32() -{ - // unregister environment - - irr::core::list::Iterator it = EnvMap.begin(); - for (; it!= EnvMap.end(); ++it) - if ((*it).hWnd == HWnd) - { - EnvMap.erase(it); - break; - } - - if (ChangedToFullScreen) - ChangeDisplaySettings(NULL,0); -} - - - -//! create the driver -void CIrrDeviceWin32::createDriver(video::E_DRIVER_TYPE driverType, - const core::dimension2d& windowSize, - u32 bits, - bool fullscreen, - bool stencilbuffer, - bool vsync, - bool antiAlias, - bool highPrecisionFPU) -{ - switch(driverType) - { - case video::EDT_DIRECT3D8: - #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - VideoDriver = video::createDirectX8Driver(windowSize, HWnd, bits, fullscreen, - stencilbuffer, FileSystem, false, highPrecisionFPU, vsync, antiAlias); - if (!VideoDriver) - { - os::Printer::log("Could not create DIRECT3D8 Driver.", ELL_ERROR); - } - #else - os::Printer::log("DIRECT3D8 Driver was not compiled into this dll. Try another one.", ELL_ERROR); - #endif - - break; - - case video::EDT_DIRECT3D9: - #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - VideoDriver = video::createDirectX9Driver(windowSize, HWnd, bits, fullscreen, - stencilbuffer, FileSystem, false, highPrecisionFPU, vsync, antiAlias); - if (!VideoDriver) - { - os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR); - } - #else - os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR); - #endif - - break; - - case video::EDT_OPENGL: - - #ifdef _IRR_COMPILE_WITH_OPENGL_ - if (fullscreen) switchToFullScreen(windowSize.Width, windowSize.Height, bits); - VideoDriver = video::createOpenGLDriver(windowSize, HWnd, bits, fullscreen, stencilbuffer, FileSystem, - vsync, antiAlias); - if (!VideoDriver) - { - os::Printer::log("Could not create OpenGL driver.", ELL_ERROR); - } - #else - os::Printer::log("OpenGL driver was not compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_SOFTWARE: - - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - if (fullscreen) switchToFullScreen(windowSize.Width, windowSize.Height, bits); - VideoDriver = video::createSoftwareDriver(windowSize, fullscreen, FileSystem, this); - #else - os::Printer::log("Software driver was not compiled in.", ELL_ERROR); - #endif - - break; - - case video::EDT_BURNINGSVIDEO: - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - if (fullscreen) switchToFullScreen(windowSize.Width, windowSize.Height, bits); - VideoDriver = video::createSoftwareDriver2(windowSize, fullscreen, FileSystem, this); - #else - os::Printer::log("Burning's Video driver was not compiled in.", ELL_ERROR); - #endif - break; - - default: - // create null driver - VideoDriver = video::createNullDriver(FileSystem, windowSize); - break; - } -} - - - -//! runs the device. Returns false if device wants to be deleted -bool CIrrDeviceWin32::run() -{ - os::Timer::tick(); - - MSG msg; - - bool quit = false; - - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - - if (ExternalWindow && msg.hwnd == HWnd) - WndProc(HWnd, msg.message, msg.wParam, msg.lParam); - else - DispatchMessage(&msg); - - if (msg.message == WM_QUIT) - quit = true; - } - - if (!quit) - resizeIfNecessary(); - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return !quit; -} - - -//! Pause the current process for the minimum time allowed only to allow other processes to execute -void CIrrDeviceWin32::yield() -{ - Sleep(1); - -} - -//! Pause execution and let other processes to run for a specified amount of time. -void CIrrDeviceWin32::sleep(u32 timeMs, bool pauseTimer) -{ - bool wasStopped = Timer ? Timer->isStopped() : true; - if (pauseTimer && !wasStopped) - Timer->stop(); - - Sleep(timeMs); - - if (pauseTimer && !wasStopped) - Timer->start(); -} - - -void CIrrDeviceWin32::resizeIfNecessary() -{ - if (!Resized) - return; - - RECT r; - GetClientRect(HWnd, &r); - - char tmp[255]; - - if (r.right < 2 || r.bottom < 2) - { - sprintf(tmp, "Ignoring resize operation to (%ld %ld)", r.right, r.bottom); - os::Printer::log(tmp); - } - else - { - sprintf(tmp, "Resizing window (%ld %ld)", r.right, r.bottom); - os::Printer::log(tmp); - - if ( r.right % 2 ) - r.right += 1; - - if ( r.bottom % 2 ) - r.bottom += 1; - - getVideoDriver()->OnResize(irr::core::dimension2d(r.right, r.bottom)); - } - - Resized = false; -} - - - -//! sets the caption of the window -void CIrrDeviceWin32::setWindowCaption(const wchar_t* text) -{ - if (IsNonNTWindows) - { - core::stringc s = text; - SetWindowTextA(HWnd, s.c_str()); - } - else - SetWindowTextW(HWnd, text); -} - - - -//! presents a surface in the client area -void CIrrDeviceWin32::present(video::IImage* image, s32 windowId, core::rect* src ) -{ - HWND hwnd = HWnd; - if ( windowId ) - hwnd = (HWND)windowId; - - HDC dc = GetDC(hwnd); - - if ( dc ) - { - RECT rect; - GetClientRect(hwnd, &rect); - const void* memory = (const void *)image->lock(); - - BITMAPV4HEADER bi; - ZeroMemory (&bi, sizeof(bi)); - bi.bV4Size = sizeof(BITMAPINFOHEADER); - bi.bV4BitCount = image->getBitsPerPixel(); - bi.bV4Planes = 1; - bi.bV4Width = image->getDimension().Width; - bi.bV4Height = -image->getDimension().Height; - bi.bV4V4Compression = BI_BITFIELDS; - bi.bV4AlphaMask = image->getAlphaMask (); - bi.bV4RedMask = image->getRedMask (); - bi.bV4GreenMask = image->getGreenMask(); - bi.bV4BlueMask = image->getBlueMask(); - - if ( src ) - { - StretchDIBits(dc, 0,0, rect.right, rect.bottom, - src->UpperLeftCorner.X, src->UpperLeftCorner.Y, - src->getWidth(), src->getHeight(), - memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY); - } - else - { - StretchDIBits(dc, 0,0, rect.right, rect.bottom, - 0, 0, image->getDimension().Width, image->getDimension().Height, - memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY); - } - - image->unlock(); - - ReleaseDC(hwnd, dc); - } -} - - - -//! notifies the device that it should close itself -void CIrrDeviceWin32::closeDevice() -{ - DestroyWindow(HWnd); -} - - - -//! returns if window is active. if not, nothing need to be drawn -bool CIrrDeviceWin32::isWindowActive() -{ - bool ret = (GetActiveWindow() == HWnd); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - - -//! switchs to fullscreen -bool CIrrDeviceWin32::switchToFullScreen(s32 width, s32 height, s32 bits) -{ - DEVMODE dm; - memset(&dm, 0, sizeof(dm)); - dm.dmSize = sizeof(dm); - dm.dmPelsWidth = width; - dm.dmPelsHeight = height; - dm.dmBitsPerPel = bits; - dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - - LONG ret = ChangeDisplaySettings(&dm, CDS_FULLSCREEN); - - switch(ret) - { - case DISP_CHANGE_SUCCESSFUL: - ChangedToFullScreen = true; - return true; - case DISP_CHANGE_RESTART: - os::Printer::log("Switch to fullscreen: The computer must be restarted in order for the graphics mode to work.", ELL_ERROR); - return false; - case DISP_CHANGE_BADFLAGS: - os::Printer::log("Switch to fullscreen: An invalid set of flags was passed in.", ELL_ERROR); - return false; - case DISP_CHANGE_BADPARAM: - os::Printer::log("Switch to fullscreen: An invalid parameter was passed in. This can include an invalid flag or combination of flags.", ELL_ERROR); - return false; - case DISP_CHANGE_FAILED: - os::Printer::log("Switch to fullscreen: The display driver failed the specified graphics mode.", ELL_ERROR); - return false; - case DISP_CHANGE_BADMODE: - os::Printer::log("Switch to fullscreen: The graphics mode is not supported.", ELL_ERROR); - return false; - } - - os::Printer::log("An unknown error occured while changing to fullscreen.", ELL_ERROR); - return false; -} - - -//! returns the win32 cursor control -CIrrDeviceWin32::CCursorControl* CIrrDeviceWin32::getWin32CursorControl() -{ - return Win32CursorControl; -} - - -//! \return Returns a pointer to a list with all video modes supported -//! by the gfx adapter. -video::IVideoModeList* CIrrDeviceWin32::getVideoModeList() -{ - if (!VideoModeList.getVideoModeCount()) - { - // enumerate video modes. - DWORD i=0; - DEVMODE mode; - - while (EnumDisplaySettings(NULL, i, &mode)) - { - VideoModeList.addMode(core::dimension2d(mode.dmPelsWidth, mode.dmPelsHeight), - mode.dmBitsPerPel); - - ++i; - } - - if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &mode)) - VideoModeList.setDesktop(mode.dmBitsPerPel, core::dimension2d(mode.dmPelsWidth, mode.dmPelsHeight)); - } - - return &VideoModeList; -} - - -void CIrrDeviceWin32::getWindowsVersion(core::stringc& out) -{ - OSVERSIONINFOEX osvi; - BOOL bOsVersionInfoEx; - - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - - if(!(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO*) &osvi))) - { - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) - return; - } - - switch (osvi.dwPlatformId) - { - case VER_PLATFORM_WIN32_NT: - if (osvi.dwMajorVersion <= 4) - out.append("Microsoft Windows NT "); - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) - out.append("Microsoft Windows 2000 "); - if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) - out.append("Microsoft Windows XP "); - - if( bOsVersionInfoEx ) - { - #ifdef VER_SUITE_ENTERPRISE - if (osvi.wProductType == VER_NT_WORKSTATION) - { - if( osvi.wSuiteMask & VER_SUITE_PERSONAL ) - out.append("Personal "); - else - out.append("Professional "); - } - else if (osvi.wProductType == VER_NT_SERVER) - { - if( osvi.wSuiteMask & VER_SUITE_DATACENTER ) - out.append("DataCenter Server "); - else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) - out.append("Advanced Server "); - else - out.append("Server "); - } - #endif - } - else - { - HKEY hKey; - char szProductType[80]; - DWORD dwBufLen; - - RegOpenKeyEx( HKEY_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\ProductOptions", - 0, KEY_QUERY_VALUE, &hKey ); - RegQueryValueEx( hKey, "ProductType", NULL, NULL, - (LPBYTE) szProductType, &dwBufLen); - RegCloseKey( hKey ); - - if (lstrcmpi( "WINNT", szProductType) == 0 ) - out.append("Professional "); - if ( lstrcmpi( "LANMANNT", szProductType) == 0 ) - out.append("Server " ); - if ( lstrcmpi( "SERVERNT", szProductType) == 0 ) - out.append("Advanced Server "); - } - - // Display version, service pack (if any), and build number. - - char tmp[255]; - - if (osvi.dwMajorVersion <= 4 ) - { - sprintf (tmp, "version %ld.%ld %s (Build %ld)", - osvi.dwMajorVersion, - osvi.dwMinorVersion, - osvi.szCSDVersion, - osvi.dwBuildNumber & 0xFFFF); - } - else - { - sprintf (tmp, "%s (Build %ld)", osvi.szCSDVersion, - osvi.dwBuildNumber & 0xFFFF); - } - - out.append(tmp); - break; - - case VER_PLATFORM_WIN32_WINDOWS: - - IsNonNTWindows = true; - - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) - { - out.append("Microsoft Windows 95 "); - if ( osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B' ) - out.append("OSR2 " ); - } - - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) - { - out.append("Microsoft Windows 98 "); - if ( osvi.szCSDVersion[1] == 'A' ) - out.append( "SE " ); - } - - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) - out.append("Microsoft Windows Me "); - - break; - - case VER_PLATFORM_WIN32s: - - IsNonNTWindows = true; - out.append("Microsoft Win32s "); - break; - } -} - -//! Notifies the device, that it has been resized -void CIrrDeviceWin32::OnResized() -{ - Resized = true; -} - -//! Sets if the window should be resizeable in windowed mode. -void CIrrDeviceWin32::setResizeAble(bool resize) -{ - if (ExternalWindow || !getVideoDriver() || FullScreen) - return; - - LONG style = WS_POPUP; - - if (!resize) - style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; - else - style = WS_THICKFRAME | WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MAXIMIZEBOX; - - if (!SetWindowLong(HWnd, GWL_STYLE, style)) - os::Printer::log("Could not change window style."); - - RECT clientSize; - clientSize.top = 0; - clientSize.left = 0; - clientSize.right = getVideoDriver()->getScreenSize().Width; - clientSize.bottom = getVideoDriver()->getScreenSize().Height; - - AdjustWindowRect(&clientSize, style, FALSE); - - s32 realWidth = clientSize.right - clientSize.left; - s32 realHeight = clientSize.bottom - clientSize.top; - - s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; - s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; - - SetWindowPos(HWnd, HWND_TOP, windowLeft, windowTop, realWidth, realHeight, - SWP_FRAMECHANGED | SWP_NOMOVE | SWP_SHOWWINDOW); -} - - -IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx( - const SIrrlichtCreationParameters& parameters) -{ - CIrrDeviceWin32* dev = new CIrrDeviceWin32( - parameters.DriverType, - parameters.WindowSize, - parameters.Bits, - parameters.Fullscreen, - parameters.Stencilbuffer, - parameters.Vsync, - parameters.AntiAlias, - parameters.HighPrecisionFPU, - parameters.EventReceiver, - reinterpret_cast(parameters.WindowId), - parameters.SDK_version_do_not_use); - - if (dev && !dev->getVideoDriver() && parameters.DriverType != video::EDT_NULL) - { - dev->closeDevice(); // destroy window - dev->run(); // consume quit message - dev->drop(); - dev = 0; - } - - return dev; -} - - -} // end namespace - -#endif // _IRR_WINDOWS_ - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" + +#ifdef _IRR_WINDOWS_ + +#include "CIrrDeviceWin32.h" +#include "IEventReceiver.h" +#include "irrList.h" +#include "os.h" + +#include "CTimer.h" +#include "irrString.h" +#include "COSOperator.h" +#include "dimension2d.h" +#include +#include "irrlicht.h" + + +namespace irr +{ + namespace video + { + IVideoDriver* createDirectX8Driver(const core::dimension2d& screenSize, HWND window, + u32 bits, bool fullscreen, bool stencilbuffer, io::IFileSystem* io, + bool pureSoftware, bool highPrecisionFPU, bool vsync, bool antiAlias); + + IVideoDriver* createDirectX9Driver(const core::dimension2d& screenSize, HWND window, + u32 bits, bool fullscreen, bool stencilbuffer, io::IFileSystem* io, + bool pureSoftware, bool highPrecisionFPU, bool vsync, bool antiAlias); + + IVideoDriver* createOpenGLDriver(const core::dimension2d& screenSize, HWND window, + u32 bits, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, + bool vsync, bool antiAlias); + } +} // end namespace irr + + + +struct SEnvMapper +{ + HWND hWnd; + irr::CIrrDeviceWin32* irrDev; +}; + +irr::core::list EnvMap; + +SEnvMapper* getEnvMapperFromHWnd(HWND hWnd) +{ + irr::core::list::Iterator it = EnvMap.begin(); + for (; it!= EnvMap.end(); ++it) + if ((*it).hWnd == hWnd) + return &(*it); + + return 0; +} + +irr::CIrrDeviceWin32* getDeviceFromHWnd(HWND hWnd) +{ + irr::core::list::Iterator it = EnvMap.begin(); + for (; it!= EnvMap.end(); ++it) + if ((*it).hWnd == hWnd) + return (*it).irrDev; + + return 0; +} + + +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + #ifndef WM_MOUSEWHEEL + #define WM_MOUSEWHEEL 0x020A + #endif + #ifndef WHEEL_DELTA + #define WHEEL_DELTA 120 + #endif + + irr::CIrrDeviceWin32* dev = 0; + irr::SEvent event; + SEnvMapper* envm = 0; + + BYTE allKeys[256]; + + static irr::s32 ClickCount=0; + if (GetCapture() != hWnd && ClickCount > 0) + ClickCount = 0; + + switch (message) + { + case WM_PAINT: + { + PAINTSTRUCT ps; + BeginPaint(hWnd, &ps); + EndPaint(hWnd, &ps); + } + return 0; + + case WM_ERASEBKGND: + return 0; + + case WM_SETCURSOR: + envm = getEnvMapperFromHWnd(hWnd); + if (envm && !envm->irrDev->getWin32CursorControl()->isVisible()) + { + SetCursor(NULL); + return 0; + } + break; + + case WM_MOUSEWHEEL: + event.EventType = irr::EET_MOUSE_INPUT_EVENT; + event.MouseInput.Wheel = ((irr::f32)((short)HIWORD(wParam))) / (irr::f32)WHEEL_DELTA; + event.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; + + POINT p; // fixed by jox + p.x = 0; p.y = 0; + ClientToScreen(hWnd, &p); + event.MouseInput.X = LOWORD(lParam) - p.x; + event.MouseInput.Y = HIWORD(lParam) - p.y; + + dev = getDeviceFromHWnd(hWnd); + if (dev) + dev->postEventFromUser(event); + break; + + case WM_LBUTTONDOWN: + ClickCount++; + SetCapture(hWnd); + event.EventType = irr::EET_MOUSE_INPUT_EVENT; + event.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN; + event.MouseInput.X = (short)LOWORD(lParam); + event.MouseInput.Y = (short)HIWORD(lParam); + dev = getDeviceFromHWnd(hWnd); + if (dev) + dev->postEventFromUser(event); + return 0; + + case WM_LBUTTONUP: + ClickCount--; + if (ClickCount<1) + { + ClickCount=0; + ReleaseCapture(); + } + event.EventType = irr::EET_MOUSE_INPUT_EVENT; + event.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP; + event.MouseInput.X = (short)LOWORD(lParam); + event.MouseInput.Y = (short)HIWORD(lParam); + dev = getDeviceFromHWnd(hWnd); + if (dev) + dev->postEventFromUser(event); + return 0; + + case WM_RBUTTONDOWN: + ClickCount++; + SetCapture(hWnd); + event.EventType = irr::EET_MOUSE_INPUT_EVENT; + event.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN; + event.MouseInput.X = (short)LOWORD(lParam); + event.MouseInput.Y = (short)HIWORD(lParam); + dev = getDeviceFromHWnd(hWnd); + if (dev) + dev->postEventFromUser(event); + return 0; + + case WM_RBUTTONUP: + ClickCount--; + if (ClickCount<1) + { + ClickCount=0; + ReleaseCapture(); + } + event.EventType = irr::EET_MOUSE_INPUT_EVENT; + event.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP; + event.MouseInput.X = (short)LOWORD(lParam); + event.MouseInput.Y = (short)HIWORD(lParam); + dev = getDeviceFromHWnd(hWnd); + if (dev) + dev->postEventFromUser(event); + return 0; + + case WM_MBUTTONDOWN: + ClickCount++; + SetCapture(hWnd); + event.EventType = irr::EET_MOUSE_INPUT_EVENT; + event.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN; + event.MouseInput.X = (short)LOWORD(lParam); + event.MouseInput.Y = (short)HIWORD(lParam); + dev = getDeviceFromHWnd(hWnd); + if (dev) + dev->postEventFromUser(event); + return 0; + + case WM_MBUTTONUP: + ClickCount--; + if (ClickCount<1) + { + ClickCount=0; + ReleaseCapture(); + } + event.EventType = irr::EET_MOUSE_INPUT_EVENT; + event.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP; + event.MouseInput.X = (short)LOWORD(lParam); + event.MouseInput.Y = (short)HIWORD(lParam); + dev = getDeviceFromHWnd(hWnd); + if (dev) + dev->postEventFromUser(event); + return 0; + + case WM_MOUSEMOVE: + event.EventType = irr::EET_MOUSE_INPUT_EVENT; + event.MouseInput.Event = irr::EMIE_MOUSE_MOVED; + event.MouseInput.X = (short)LOWORD(lParam); + event.MouseInput.Y = (short)HIWORD(lParam); + dev = getDeviceFromHWnd(hWnd); + if (dev) + dev->postEventFromUser(event); + return 0; + + case WM_KEYDOWN: + { + event.EventType = irr::EET_KEY_INPUT_EVENT; + event.KeyInput.Key = (irr::EKEY_CODE)wParam; + event.KeyInput.PressedDown = true; + dev = getDeviceFromHWnd(hWnd); + + WORD KeyAsc=0; + GetKeyboardState(allKeys); + ToAscii(wParam,lParam,allKeys,&KeyAsc,0); + + event.KeyInput.Shift = ((allKeys[VK_SHIFT] & 0x80)!=0); + event.KeyInput.Control = ((allKeys[VK_CONTROL] & 0x80)!=0); + event.KeyInput.Char = KeyAsc; //KeyAsc >= 0 ? KeyAsc : 0; + + if (dev) + dev->postEventFromUser(event); + + return 0; + } + case WM_KEYUP: + { + event.EventType = irr::EET_KEY_INPUT_EVENT; + event.KeyInput.Key = (irr::EKEY_CODE)wParam; + event.KeyInput.PressedDown = false; + dev = getDeviceFromHWnd(hWnd); + + WORD KeyAsc=0; + GetKeyboardState(allKeys); + ToAscii(wParam,lParam,allKeys,&KeyAsc,0); + + event.KeyInput.Shift = ((allKeys[VK_SHIFT] & 0x80)!=0); + event.KeyInput.Control = ((allKeys[VK_CONTROL] & 0x80)!=0); + event.KeyInput.Char = KeyAsc; //KeyAsc >= 0 ? KeyAsc : 0; + + if (dev) + dev->postEventFromUser(event); + + return 0; + } + + case WM_SIZE: + { + // resize + dev = getDeviceFromHWnd(hWnd); + if (dev) + dev->OnResized(); + } + return 0; + + case WM_DESTROY: + PostQuitMessage(0); + return 0; + + case WM_SYSCOMMAND: + // prevent screensaver or monitor powersave mode from starting + if ((wParam & 0xFFF0) == SC_SCREENSAVE || + (wParam & 0xFFF0) == SC_MONITORPOWER) + return 0; + break; + } + + return DefWindowProc(hWnd, message, wParam, lParam); +} + +namespace irr +{ + +//! constructor +CIrrDeviceWin32::CIrrDeviceWin32(video::E_DRIVER_TYPE driverType, + core::dimension2d windowSize, + u32 bits, bool fullscreen, + bool stencilbuffer, bool vsync, + bool antiAlias, + bool highPrecisionFPU, + IEventReceiver* receiver, + HWND externalWindow, + const char* version) +: CIrrDeviceStub(version, receiver), HWnd(0), ChangedToFullScreen(false), + FullScreen(fullscreen), IsNonNTWindows(false), Resized(false), + ExternalWindow(false), Win32CursorControl(0) +{ + core::stringc winversion; + getWindowsVersion(winversion); + Operator = new COSOperator(winversion.c_str()); + os::Printer::log(winversion.c_str(), ELL_INFORMATION); + + // create window + + HINSTANCE hInstance = GetModuleHandle(0); + + #ifdef _DEBUG + setDebugName("CIrrDeviceWin32"); + #endif + + // create the window, only if we do not use the null device + if (driverType != video::EDT_NULL && externalWindow==0) + { + const c8* ClassName = "CIrrDeviceWin32"; + + // Register Class + WNDCLASSEX wcex; + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = (WNDPROC)WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = NULL; + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = 0; + wcex.lpszClassName = ClassName; + wcex.hIconSm = 0; + + // if there is an icon, load it + wcex.hIcon = (HICON)LoadImage(hInstance, "irrlicht.ico", IMAGE_ICON, 0,0, LR_LOADFROMFILE); + + RegisterClassEx(&wcex); + + // calculate client size + + RECT clientSize; + clientSize.top = 0; + clientSize.left = 0; + clientSize.right = windowSize.Width; + clientSize.bottom = windowSize.Height; + + DWORD style = WS_POPUP; + + if (!fullscreen) + style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; + + AdjustWindowRect(&clientSize, style, FALSE); + + s32 realWidth = clientSize.right - clientSize.left; + s32 realHeight = clientSize.bottom - clientSize.top; + + s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; + s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; + + if (fullscreen) + { + windowLeft = 0; + windowTop = 0; + } + + // create window + + HWnd = CreateWindow( ClassName, "", style, windowLeft, windowTop, + realWidth, realHeight, NULL, NULL, hInstance, NULL); + + ShowWindow(HWnd , SW_SHOW); + UpdateWindow(HWnd); + + // fix ugly ATI driver bugs. Thanks to ariaci + MoveWindow(HWnd, windowLeft, windowTop, realWidth, realHeight, TRUE); + } + + // attach external window + if (externalWindow) + { + HWnd = externalWindow; + RECT r; + GetWindowRect(HWnd, &r); + windowSize.Width = r.right - r.left; + windowSize.Height = r.bottom - r.top; + fullscreen = false; + ExternalWindow = true; + } + + // create cursor control + + Win32CursorControl = new CCursorControl(windowSize, HWnd, fullscreen); + CursorControl = Win32CursorControl; + + // create driver + + createDriver(driverType, windowSize, bits, fullscreen, stencilbuffer, vsync, antiAlias, highPrecisionFPU); + + if (VideoDriver) + createGUIAndScene(); + + // register environment + + SEnvMapper em; + em.irrDev = this; + em.hWnd = HWnd; + EnvMap.push_back(em); + + // set this as active window + SetActiveWindow(HWnd); + SetForegroundWindow(HWnd); +} + + + +//! destructor +CIrrDeviceWin32::~CIrrDeviceWin32() +{ + // unregister environment + + irr::core::list::Iterator it = EnvMap.begin(); + for (; it!= EnvMap.end(); ++it) + if ((*it).hWnd == HWnd) + { + EnvMap.erase(it); + break; + } + + if (ChangedToFullScreen) + ChangeDisplaySettings(NULL,0); +} + + + +//! create the driver +void CIrrDeviceWin32::createDriver(video::E_DRIVER_TYPE driverType, + const core::dimension2d& windowSize, + u32 bits, + bool fullscreen, + bool stencilbuffer, + bool vsync, + bool antiAlias, + bool highPrecisionFPU) +{ + switch(driverType) + { + case video::EDT_DIRECT3D8: + #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ + VideoDriver = video::createDirectX8Driver(windowSize, HWnd, bits, fullscreen, + stencilbuffer, FileSystem, false, highPrecisionFPU, vsync, antiAlias); + if (!VideoDriver) + { + os::Printer::log("Could not create DIRECT3D8 Driver.", ELL_ERROR); + } + #else + os::Printer::log("DIRECT3D8 Driver was not compiled into this dll. Try another one.", ELL_ERROR); + #endif + + break; + + case video::EDT_DIRECT3D9: + #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + VideoDriver = video::createDirectX9Driver(windowSize, HWnd, bits, fullscreen, + stencilbuffer, FileSystem, false, highPrecisionFPU, vsync, antiAlias); + if (!VideoDriver) + { + os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR); + } + #else + os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR); + #endif + + break; + + case video::EDT_OPENGL: + + #ifdef _IRR_COMPILE_WITH_OPENGL_ + if (fullscreen) switchToFullScreen(windowSize.Width, windowSize.Height, bits); + VideoDriver = video::createOpenGLDriver(windowSize, HWnd, bits, fullscreen, stencilbuffer, FileSystem, + vsync, antiAlias); + if (!VideoDriver) + { + os::Printer::log("Could not create OpenGL driver.", ELL_ERROR); + } + #else + os::Printer::log("OpenGL driver was not compiled in.", ELL_ERROR); + #endif + break; + + case video::EDT_SOFTWARE: + + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + if (fullscreen) switchToFullScreen(windowSize.Width, windowSize.Height, bits); + VideoDriver = video::createSoftwareDriver(windowSize, fullscreen, FileSystem, this); + #else + os::Printer::log("Software driver was not compiled in.", ELL_ERROR); + #endif + + break; + + case video::EDT_BURNINGSVIDEO: + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + if (fullscreen) switchToFullScreen(windowSize.Width, windowSize.Height, bits); + VideoDriver = video::createSoftwareDriver2(windowSize, fullscreen, FileSystem, this); + #else + os::Printer::log("Burning's Video driver was not compiled in.", ELL_ERROR); + #endif + break; + + default: + // create null driver + VideoDriver = video::createNullDriver(FileSystem, windowSize); + break; + } +} + + + +//! runs the device. Returns false if device wants to be deleted +bool CIrrDeviceWin32::run() +{ + os::Timer::tick(); + + MSG msg; + + bool quit = false; + + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + + if (ExternalWindow && msg.hwnd == HWnd) + WndProc(HWnd, msg.message, msg.wParam, msg.lParam); + else + DispatchMessage(&msg); + + if (msg.message == WM_QUIT) + quit = true; + } + + if (!quit) + resizeIfNecessary(); + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return !quit; +} + + +//! Pause the current process for the minimum time allowed only to allow other processes to execute +void CIrrDeviceWin32::yield() +{ + Sleep(1); + +} + +//! Pause execution and let other processes to run for a specified amount of time. +void CIrrDeviceWin32::sleep(u32 timeMs, bool pauseTimer) +{ + bool wasStopped = Timer ? Timer->isStopped() : true; + if (pauseTimer && !wasStopped) + Timer->stop(); + + Sleep(timeMs); + + if (pauseTimer && !wasStopped) + Timer->start(); +} + + +void CIrrDeviceWin32::resizeIfNecessary() +{ + if (!Resized) + return; + + RECT r; + GetClientRect(HWnd, &r); + + char tmp[255]; + + if (r.right < 2 || r.bottom < 2) + { + sprintf(tmp, "Ignoring resize operation to (%ld %ld)", r.right, r.bottom); + os::Printer::log(tmp); + } + else + { + sprintf(tmp, "Resizing window (%ld %ld)", r.right, r.bottom); + os::Printer::log(tmp); + + if ( r.right % 2 ) + r.right += 1; + + if ( r.bottom % 2 ) + r.bottom += 1; + + getVideoDriver()->OnResize(irr::core::dimension2d(r.right, r.bottom)); + } + + Resized = false; +} + + + +//! sets the caption of the window +void CIrrDeviceWin32::setWindowCaption(const wchar_t* text) +{ + if (IsNonNTWindows) + { + core::stringc s = text; + SetWindowTextA(HWnd, s.c_str()); + } + else + SetWindowTextW(HWnd, text); +} + + + +//! presents a surface in the client area +void CIrrDeviceWin32::present(video::IImage* image, s32 windowId, core::rect* src ) +{ + HWND hwnd = HWnd; + if ( windowId ) + hwnd = (HWND)windowId; + + HDC dc = GetDC(hwnd); + + if ( dc ) + { + RECT rect; + GetClientRect(hwnd, &rect); + const void* memory = (const void *)image->lock(); + + BITMAPV4HEADER bi; + ZeroMemory (&bi, sizeof(bi)); + bi.bV4Size = sizeof(BITMAPINFOHEADER); + bi.bV4BitCount = image->getBitsPerPixel(); + bi.bV4Planes = 1; + bi.bV4Width = image->getDimension().Width; + bi.bV4Height = -image->getDimension().Height; + bi.bV4V4Compression = BI_BITFIELDS; + bi.bV4AlphaMask = image->getAlphaMask (); + bi.bV4RedMask = image->getRedMask (); + bi.bV4GreenMask = image->getGreenMask(); + bi.bV4BlueMask = image->getBlueMask(); + + if ( src ) + { + StretchDIBits(dc, 0,0, rect.right, rect.bottom, + src->UpperLeftCorner.X, src->UpperLeftCorner.Y, + src->getWidth(), src->getHeight(), + memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY); + } + else + { + StretchDIBits(dc, 0,0, rect.right, rect.bottom, + 0, 0, image->getDimension().Width, image->getDimension().Height, + memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY); + } + + image->unlock(); + + ReleaseDC(hwnd, dc); + } +} + + + +//! notifies the device that it should close itself +void CIrrDeviceWin32::closeDevice() +{ + DestroyWindow(HWnd); +} + + + +//! returns if window is active. if not, nothing need to be drawn +bool CIrrDeviceWin32::isWindowActive() +{ + bool ret = (GetActiveWindow() == HWnd); + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return ret; +} + + + +//! switchs to fullscreen +bool CIrrDeviceWin32::switchToFullScreen(s32 width, s32 height, s32 bits) +{ + DEVMODE dm; + memset(&dm, 0, sizeof(dm)); + dm.dmSize = sizeof(dm); + dm.dmPelsWidth = width; + dm.dmPelsHeight = height; + dm.dmBitsPerPel = bits; + dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; + + LONG ret = ChangeDisplaySettings(&dm, CDS_FULLSCREEN); + + switch(ret) + { + case DISP_CHANGE_SUCCESSFUL: + ChangedToFullScreen = true; + return true; + case DISP_CHANGE_RESTART: + os::Printer::log("Switch to fullscreen: The computer must be restarted in order for the graphics mode to work.", ELL_ERROR); + return false; + case DISP_CHANGE_BADFLAGS: + os::Printer::log("Switch to fullscreen: An invalid set of flags was passed in.", ELL_ERROR); + return false; + case DISP_CHANGE_BADPARAM: + os::Printer::log("Switch to fullscreen: An invalid parameter was passed in. This can include an invalid flag or combination of flags.", ELL_ERROR); + return false; + case DISP_CHANGE_FAILED: + os::Printer::log("Switch to fullscreen: The display driver failed the specified graphics mode.", ELL_ERROR); + return false; + case DISP_CHANGE_BADMODE: + os::Printer::log("Switch to fullscreen: The graphics mode is not supported.", ELL_ERROR); + return false; + } + + os::Printer::log("An unknown error occured while changing to fullscreen.", ELL_ERROR); + return false; +} + + +//! returns the win32 cursor control +CIrrDeviceWin32::CCursorControl* CIrrDeviceWin32::getWin32CursorControl() +{ + return Win32CursorControl; +} + + +//! \return Returns a pointer to a list with all video modes supported +//! by the gfx adapter. +video::IVideoModeList* CIrrDeviceWin32::getVideoModeList() +{ + if (!VideoModeList.getVideoModeCount()) + { + // enumerate video modes. + DWORD i=0; + DEVMODE mode; + + while (EnumDisplaySettings(NULL, i, &mode)) + { + VideoModeList.addMode(core::dimension2d(mode.dmPelsWidth, mode.dmPelsHeight), + mode.dmBitsPerPel); + + ++i; + } + + if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &mode)) + VideoModeList.setDesktop(mode.dmBitsPerPel, core::dimension2d(mode.dmPelsWidth, mode.dmPelsHeight)); + } + + return &VideoModeList; +} + + +void CIrrDeviceWin32::getWindowsVersion(core::stringc& out) +{ + OSVERSIONINFOEX osvi; + BOOL bOsVersionInfoEx; + + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + + if(!(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO*) &osvi))) + { + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) + return; + } + + switch (osvi.dwPlatformId) + { + case VER_PLATFORM_WIN32_NT: + if (osvi.dwMajorVersion <= 4) + out.append("Microsoft Windows NT "); + if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) + out.append("Microsoft Windows 2000 "); + if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) + out.append("Microsoft Windows XP "); + + if( bOsVersionInfoEx ) + { + #ifdef VER_SUITE_ENTERPRISE + if (osvi.wProductType == VER_NT_WORKSTATION) + { + if( osvi.wSuiteMask & VER_SUITE_PERSONAL ) + out.append("Personal "); + else + out.append("Professional "); + } + else if (osvi.wProductType == VER_NT_SERVER) + { + if( osvi.wSuiteMask & VER_SUITE_DATACENTER ) + out.append("DataCenter Server "); + else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) + out.append("Advanced Server "); + else + out.append("Server "); + } + #endif + } + else + { + HKEY hKey; + char szProductType[80]; + DWORD dwBufLen; + + RegOpenKeyEx( HKEY_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Control\\ProductOptions", + 0, KEY_QUERY_VALUE, &hKey ); + RegQueryValueEx( hKey, "ProductType", NULL, NULL, + (LPBYTE) szProductType, &dwBufLen); + RegCloseKey( hKey ); + + if (lstrcmpi( "WINNT", szProductType) == 0 ) + out.append("Professional "); + if ( lstrcmpi( "LANMANNT", szProductType) == 0 ) + out.append("Server " ); + if ( lstrcmpi( "SERVERNT", szProductType) == 0 ) + out.append("Advanced Server "); + } + + // Display version, service pack (if any), and build number. + + char tmp[255]; + + if (osvi.dwMajorVersion <= 4 ) + { + sprintf (tmp, "version %ld.%ld %s (Build %ld)", + osvi.dwMajorVersion, + osvi.dwMinorVersion, + osvi.szCSDVersion, + osvi.dwBuildNumber & 0xFFFF); + } + else + { + sprintf (tmp, "%s (Build %ld)", osvi.szCSDVersion, + osvi.dwBuildNumber & 0xFFFF); + } + + out.append(tmp); + break; + + case VER_PLATFORM_WIN32_WINDOWS: + + IsNonNTWindows = true; + + if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) + { + out.append("Microsoft Windows 95 "); + if ( osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B' ) + out.append("OSR2 " ); + } + + if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) + { + out.append("Microsoft Windows 98 "); + if ( osvi.szCSDVersion[1] == 'A' ) + out.append( "SE " ); + } + + if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) + out.append("Microsoft Windows Me "); + + break; + + case VER_PLATFORM_WIN32s: + + IsNonNTWindows = true; + out.append("Microsoft Win32s "); + break; + } +} + +//! Notifies the device, that it has been resized +void CIrrDeviceWin32::OnResized() +{ + Resized = true; +} + +//! Sets if the window should be resizeable in windowed mode. +void CIrrDeviceWin32::setResizeAble(bool resize) +{ + if (ExternalWindow || !getVideoDriver() || FullScreen) + return; + + LONG style = WS_POPUP; + + if (!resize) + style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; + else + style = WS_THICKFRAME | WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MAXIMIZEBOX; + + if (!SetWindowLong(HWnd, GWL_STYLE, style)) + os::Printer::log("Could not change window style."); + + RECT clientSize; + clientSize.top = 0; + clientSize.left = 0; + clientSize.right = getVideoDriver()->getScreenSize().Width; + clientSize.bottom = getVideoDriver()->getScreenSize().Height; + + AdjustWindowRect(&clientSize, style, FALSE); + + s32 realWidth = clientSize.right - clientSize.left; + s32 realHeight = clientSize.bottom - clientSize.top; + + s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; + s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; + + SetWindowPos(HWnd, HWND_TOP, windowLeft, windowTop, realWidth, realHeight, + SWP_FRAMECHANGED | SWP_NOMOVE | SWP_SHOWWINDOW); +} + + +IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx( + const SIrrlichtCreationParameters& parameters) +{ + CIrrDeviceWin32* dev = new CIrrDeviceWin32( + parameters.DriverType, + parameters.WindowSize, + parameters.Bits, + parameters.Fullscreen, + parameters.Stencilbuffer, + parameters.Vsync, + parameters.AntiAlias, + parameters.HighPrecisionFPU, + parameters.EventReceiver, + reinterpret_cast(parameters.WindowId), + parameters.SDK_version_do_not_use); + + if (dev && !dev->getVideoDriver() && parameters.DriverType != video::EDT_NULL) + { + dev->closeDevice(); // destroy window + dev->run(); // consume quit message + dev->drop(); + dev = 0; + } + + return dev; +} + + +} // end namespace + +#endif // _IRR_WINDOWS_ + diff --git a/src/dep/src/irrlicht/CIrrDeviceWin32.h b/src/dep/src/irrlicht/CIrrDeviceWin32.h index 54e9348..791acf2 100644 --- a/src/dep/src/irrlicht/CIrrDeviceWin32.h +++ b/src/dep/src/irrlicht/CIrrDeviceWin32.h @@ -1,203 +1,203 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IRR_DEVICE_WIN32_H_INCLUDED__ -#define __C_IRR_DEVICE_WIN32_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#include "CIrrDeviceStub.h" -#include "IrrlichtDevice.h" -#include "IImagePresenter.h" -#include "IGUIEnvironment.h" - -#define WIN32_LEAN_AND_MEAN -#include - -namespace irr -{ - class CIrrDeviceWin32 : public CIrrDeviceStub, video::IImagePresenter - { - public: - - //! constructor - CIrrDeviceWin32(video::E_DRIVER_TYPE deviceType, - const core::dimension2d windowSize, u32 bits, - bool fullscreen, bool stencilbuffer, bool vsync, - bool antiAlias, bool highPrecisionFPU, - IEventReceiver* receiver, - HWND window, - const char* version); - - //! destructor - virtual ~CIrrDeviceWin32(); - - //! runs the device. Returns false if device wants to be deleted - virtual bool run(); - - //! Cause the device to temporarily pause execution and let other processes to run - // This should bring down processor usage without major performance loss for Irrlicht - virtual void yield(); - - //! Pause execution and let other processes to run for a specified amount of time. - virtual void sleep(u32 timeMs, bool pauseTimer); - - //! sets the caption of the window - virtual void setWindowCaption(const wchar_t* text); - - //! returns if window is active. if not, nothing need to be drawn - virtual bool isWindowActive(); - - //! presents a surface in the client area - virtual void present(video::IImage* surface, s32 windowId = 0, core::rect* src=0 ); - - //! notifies the device that it should close itself - virtual void closeDevice(); - - //! \return Returns a pointer to a list with all video modes supported - //! by the gfx adapter. - video::IVideoModeList* getVideoModeList(); - - //! Notifies the device, that it has been resized - void OnResized(); - - //! Sets if the window should be resizeable in windowed mode. - virtual void setResizeAble(bool resize=false); - - //! Implementation of the win32 cursor control - class CCursorControl : public gui::ICursorControl - { - public: - - CCursorControl(const core::dimension2d& wsize, HWND hwnd, bool fullscreen) - : WindowSize(wsize), InvWindowSize(0.0f, 0.0f), IsVisible(true), - HWnd(hwnd), BorderX(0), BorderY(0) - { - if (WindowSize.Width!=0) - InvWindowSize.Width = 1.0f / WindowSize.Width; - - if (WindowSize.Height!=0) - InvWindowSize.Height = 1.0f / WindowSize.Height; - - if (!fullscreen) - { - BorderX = GetSystemMetrics(SM_CXDLGFRAME); - BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYDLGFRAME); - } - } - - //! Changes the visible state of the mouse cursor. - virtual void setVisible(bool visible) - { - IsVisible = visible; - } - - //! Returns if the cursor is currently visible. - virtual bool isVisible() - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsVisible; - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(f32 x, f32 y) - { - setPosition((s32)(x*WindowSize.Width), (s32)(y*WindowSize.Height)); - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(s32 x, s32 y) - { - RECT rect; - if (GetWindowRect(HWnd, &rect)) - SetCursorPos(x + rect.left + BorderX, y + rect.top + BorderY); - - CursorPos.X = x; - CursorPos.Y = y; - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d getPosition() - { - updateInternalCursorPosition(); - return CursorPos; - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d getRelativePosition() - { - updateInternalCursorPosition(); - return core::position2d(CursorPos.X * InvWindowSize.Width, - CursorPos.Y * InvWindowSize.Height); - } - - private: - - //! Updates the internal cursor position - void updateInternalCursorPosition() - { - POINT p; - GetCursorPos(&p); - RECT rect; - GetWindowRect(HWnd, &rect); - CursorPos.X = p.x-rect.left-BorderX; - CursorPos.Y = p.y-rect.top-BorderY; - } - - core::position2d CursorPos; - core::dimension2d WindowSize; - core::dimension2d InvWindowSize; - bool IsVisible; - HWND HWnd; - - s32 BorderX, BorderY; - }; - - - //! returns the win32 cursor control - CCursorControl* getWin32CursorControl(); - - private: - - //! create the driver - void createDriver(video::E_DRIVER_TYPE driverType, - const core::dimension2d& windowSize, u32 bits, bool fullscreen, - bool stencilbuffer, bool vsync, bool antiAlias, bool highPrecisionFPU); - - //! switchs to fullscreen - bool switchToFullScreen(s32 width, s32 height, s32 bits); - - void getWindowsVersion(core::stringc& version); - - void resizeIfNecessary(); - - HWND HWnd; - - bool ChangedToFullScreen; - bool FullScreen; - bool IsNonNTWindows; - bool Resized; - bool ExternalWindow; - CCursorControl* Win32CursorControl; - }; - - -} // end namespace irr - -#endif -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_IRR_DEVICE_WIN32_H_INCLUDED__ +#define __C_IRR_DEVICE_WIN32_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_WINDOWS_ + +#include "CIrrDeviceStub.h" +#include "IrrlichtDevice.h" +#include "IImagePresenter.h" +#include "IGUIEnvironment.h" + +#define WIN32_LEAN_AND_MEAN +#include + +namespace irr +{ + class CIrrDeviceWin32 : public CIrrDeviceStub, video::IImagePresenter + { + public: + + //! constructor + CIrrDeviceWin32(video::E_DRIVER_TYPE deviceType, + const core::dimension2d windowSize, u32 bits, + bool fullscreen, bool stencilbuffer, bool vsync, + bool antiAlias, bool highPrecisionFPU, + IEventReceiver* receiver, + HWND window, + const char* version); + + //! destructor + virtual ~CIrrDeviceWin32(); + + //! runs the device. Returns false if device wants to be deleted + virtual bool run(); + + //! Cause the device to temporarily pause execution and let other processes to run + // This should bring down processor usage without major performance loss for Irrlicht + virtual void yield(); + + //! Pause execution and let other processes to run for a specified amount of time. + virtual void sleep(u32 timeMs, bool pauseTimer); + + //! sets the caption of the window + virtual void setWindowCaption(const wchar_t* text); + + //! returns if window is active. if not, nothing need to be drawn + virtual bool isWindowActive(); + + //! presents a surface in the client area + virtual void present(video::IImage* surface, s32 windowId = 0, core::rect* src=0 ); + + //! notifies the device that it should close itself + virtual void closeDevice(); + + //! \return Returns a pointer to a list with all video modes supported + //! by the gfx adapter. + video::IVideoModeList* getVideoModeList(); + + //! Notifies the device, that it has been resized + void OnResized(); + + //! Sets if the window should be resizeable in windowed mode. + virtual void setResizeAble(bool resize=false); + + //! Implementation of the win32 cursor control + class CCursorControl : public gui::ICursorControl + { + public: + + CCursorControl(const core::dimension2d& wsize, HWND hwnd, bool fullscreen) + : WindowSize(wsize), InvWindowSize(0.0f, 0.0f), IsVisible(true), + HWnd(hwnd), BorderX(0), BorderY(0) + { + if (WindowSize.Width!=0) + InvWindowSize.Width = 1.0f / WindowSize.Width; + + if (WindowSize.Height!=0) + InvWindowSize.Height = 1.0f / WindowSize.Height; + + if (!fullscreen) + { + BorderX = GetSystemMetrics(SM_CXDLGFRAME); + BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYDLGFRAME); + } + } + + //! Changes the visible state of the mouse cursor. + virtual void setVisible(bool visible) + { + IsVisible = visible; + } + + //! Returns if the cursor is currently visible. + virtual bool isVisible() + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return IsVisible; + } + + //! Sets the new position of the cursor. + virtual void setPosition(const core::position2d &pos) + { + setPosition(pos.X, pos.Y); + } + + //! Sets the new position of the cursor. + virtual void setPosition(f32 x, f32 y) + { + setPosition((s32)(x*WindowSize.Width), (s32)(y*WindowSize.Height)); + } + + //! Sets the new position of the cursor. + virtual void setPosition(const core::position2d &pos) + { + setPosition(pos.X, pos.Y); + } + + //! Sets the new position of the cursor. + virtual void setPosition(s32 x, s32 y) + { + RECT rect; + if (GetWindowRect(HWnd, &rect)) + SetCursorPos(x + rect.left + BorderX, y + rect.top + BorderY); + + CursorPos.X = x; + CursorPos.Y = y; + } + + //! Returns the current position of the mouse cursor. + virtual core::position2d getPosition() + { + updateInternalCursorPosition(); + return CursorPos; + } + + //! Returns the current position of the mouse cursor. + virtual core::position2d getRelativePosition() + { + updateInternalCursorPosition(); + return core::position2d(CursorPos.X * InvWindowSize.Width, + CursorPos.Y * InvWindowSize.Height); + } + + private: + + //! Updates the internal cursor position + void updateInternalCursorPosition() + { + POINT p; + GetCursorPos(&p); + RECT rect; + GetWindowRect(HWnd, &rect); + CursorPos.X = p.x-rect.left-BorderX; + CursorPos.Y = p.y-rect.top-BorderY; + } + + core::position2d CursorPos; + core::dimension2d WindowSize; + core::dimension2d InvWindowSize; + bool IsVisible; + HWND HWnd; + + s32 BorderX, BorderY; + }; + + + //! returns the win32 cursor control + CCursorControl* getWin32CursorControl(); + + private: + + //! create the driver + void createDriver(video::E_DRIVER_TYPE driverType, + const core::dimension2d& windowSize, u32 bits, bool fullscreen, + bool stencilbuffer, bool vsync, bool antiAlias, bool highPrecisionFPU); + + //! switchs to fullscreen + bool switchToFullScreen(s32 width, s32 height, s32 bits); + + void getWindowsVersion(core::stringc& version); + + void resizeIfNecessary(); + + HWND HWnd; + + bool ChangedToFullScreen; + bool FullScreen; + bool IsNonNTWindows; + bool Resized; + bool ExternalWindow; + CCursorControl* Win32CursorControl; + }; + + +} // end namespace irr + +#endif +#endif + diff --git a/src/dep/src/irrlicht/CLMTSMeshFileLoader.cpp b/src/dep/src/irrlicht/CLMTSMeshFileLoader.cpp index 8ebd1f2..d11619e 100644 --- a/src/dep/src/irrlicht/CLMTSMeshFileLoader.cpp +++ b/src/dep/src/irrlicht/CLMTSMeshFileLoader.cpp @@ -1,356 +1,356 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// This file was written by Jonas Petersen and modified by Nikolaus Gebhardt. -// See CLMTSMeshFileLoder.h for details. -/* - -CLMTSMeshFileLoader.cpp - -LMTSMeshFileLoader -Written by Jonas Petersen (a.k.a. jox) - -Version 1.5 - 15 March 2005 - -Get the latest version here: http://development.mindfloaters.de/ - -This is an addon class for the Irrlicht engine by Nikolaus Gebhardt (http://irrlicht.sourceforge.net). -With this release the Irrlicht engine is at version 0.6 - -This class allows loading meshes with lightmaps (*.lmts + *.tga files) that were created -using Pulsar LMTools by Lord Trancos (http://www.geocities.com/dxlab/index_en.html) - -Notes: -- This version does not recognice/support user data in the *.lmts files. -- The lightmap TGA's generated by LMTools doesn't work in Irrlicht for some reason (the - lightmaps look messed up). Opening and resaving them in a graphics app will solve - the problem (tested only with Photoshop). - - -License: --------- - -It's free. You are encouraged to give me credit if you use it in your software. - -Version History: ----------------- - -Version 1.5 - 15 March 2005 -- Added the switch LMTS_INTEGRATED_IN_IRRLICHT. This was needed because - of access problems to the irrlicht Logger. -- Did a better cleanup. No memory leaks in case of an loading error. -- Added "#include " for sprintf. - -Version 1.4 - 12 March 2005 -- Fixed bug in texture and subset loading code that would possibly cause crash. -- Fixed memory cleanup to avoid leak when loading more then one mesh -- Used the irrlicht Logger instead of cerr to output warnings and errors. - For this I had to change the constructor - from: - CLMTSMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver) - to: - CLMTSMeshFileLoader(IrrlichtDevice* device) - -Version 1.3 - 15 February 2005 -- Fixed bug that prevented loading more than one different lmts files. -- Removed unnecessary "#include ". -- Added "std::" in front of "cerr". This was necessary for Visual Studio .NET, - I hope it's not disturbing other compilers. -- Added warning message when a texture can not be loaded. -- Changed the documentation a bit (minor). - -Version 1.2 -- To avoid confusion I skipped version 1.2 because the website was offering -version 1.2 even though it was only version 1.1. Sorry about that. - -Version 1.1 - 29 July 2004 -- Added setTexturePath() function -- Minor improvements - -Version 1.0 - 29 July 2004 -- Initial release - - -*/ -////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include -#include -#include "CLMTSMeshFileLoader.h" -#if LMTS_INTEGRATED_IN_IRRLICHT -#include "os.h" -#endif - -namespace irr -{ -namespace scene -{ - -#if LMTS_INTEGRATED_IN_IRRLICHT - -CLMTSMeshFileLoader::CLMTSMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver, - io::IAttributes* parameters) - : Textures(0), TextureIDs(0), Subsets(0), Triangles(0), Mesh(0), - NumTextures(0), NumLightMaps(0), Parameters(parameters), Driver(driver), FileSystem(fs) -{ - if (Driver) - Driver->grab(); - - if (FileSystem) - FileSystem->grab(); -} - -#else - -CLMTSMeshFileLoader::CLMTSMeshFileLoader(IrrlichtDevice* device) -: Textures(0), TextureIDs(0), Subsets(0), Triangles(0), Mesh(0), - NumTextures(0), NumLightMaps(0), Parameters(0), Logger(0) -{ - FileSystem = device->getFileSystem(); - FileSystem->grab(); - - Driver = device->getVideoDriver(); - Driver->grab(); - - Logger = device->getLogger(); - Parameters = device->getSceneManager()->getParameters(); -} - -#endif - -CLMTSMeshFileLoader::~CLMTSMeshFileLoader() -{ - if (Mesh) - Mesh->drop(); - - if (Driver) - Driver->drop(); - - if (FileSystem) - FileSystem->drop(); -} - -void CLMTSMeshFileLoader::cleanup() { - delete [] Textures; - delete [] TextureIDs; - delete [] Subsets; - delete [] Triangles; -} - -bool CLMTSMeshFileLoader::isALoadableFileExtension(const c8* filename) { - return strstr(filename, ".lmts") != 0; -} - -IAnimatedMesh* CLMTSMeshFileLoader::createMesh(irr::io::IReadFile* file) { - - u32 i; - u32 id; - - // HEADER - - file->read(&Header, sizeof(SLMTSHeader)); - if (Header.MagicID != 0x53544D4C) { // "LMTS" - LMTS_LOG("LMTS ERROR: wrong header magic id!", ELL_ERROR); - return 0; - } - - // TEXTURES - - file->read(&id, sizeof(u32)); - if (id != 0x54584554) { // "TEXT" - LMTS_LOG("LMTS ERROR: wrong texture magic id!", ELL_ERROR); - return 0; - } - - Textures = new SLMTSTextureInfoEntry[Header.TextureCount]; - TextureIDs = new u16[Header.TextureCount]; - - NumLightMaps = NumTextures = 0; - - for (i=0; iread(&Textures[i], sizeof(SLMTSTextureInfoEntry)); - if (Textures[i].Flags & 1) { - TextureIDs[i] = NumLightMaps; - NumLightMaps++; - } else { - TextureIDs[i] = NumTextures; - NumTextures++; - } - - } - - // SUBSETS - - file->read(&id, sizeof(u32)); - if (id != 0x53425553) { // "SUBS" - LMTS_LOG("LMTS ERROR: wrong subset magic id!", ELL_ERROR); - cleanup(); - return 0; - } - - Subsets = new SLMTSSubsetInfoEntry[Header.SubsetCount]; - - for (i=0; iread(&Subsets[i], sizeof(SLMTSSubsetInfoEntry)); - } - - // TRIANGLES - - file->read(&id, sizeof(u32)); - if (id != 0x53495254) { // "TRIS" - LMTS_LOG("LMTS ERROR: wrong triangle magic id!", ELL_ERROR); - cleanup(); - return 0; - } - - Triangles = new SLMTSTriangleDataEntry[(Header.TriangleCount*3)]; - - for (i=0; i<(Header.TriangleCount*3); i++) { - file->read(&Triangles[i], sizeof(SLMTSTriangleDataEntry)); - } - - ///////////////////////////////////////////////////////////////// - - constructMesh(); - - loadTextures(); - - cleanup(); - - SAnimatedMesh* am = new SAnimatedMesh(); - am->Type = EAMT_LMTS; // not unknown to irrlicht anymore - - am->addMesh(Mesh); - am->recalculateBoundingBox(); - Mesh->drop(); - Mesh = 0; - return am; -} - -void CLMTSMeshFileLoader::constructMesh() -{ - s32 i; - - if (Mesh) - Mesh->drop(); - - Mesh = new SMesh(); - - for (i=0; iMaterial.MaterialType = video::EMT_LIGHTMAP; // EMT_LIGHTMAP_M2/EMT_LIGHTMAP_M4 also possible - meshBuffer->Material.Wireframe = false; - meshBuffer->Material.Lighting = false; - meshBuffer->Material.BilinearFilter = true; - - Mesh->addMeshBuffer(meshBuffer); - - meshBuffer->drop(); - - u32 offs = Subsets[i].Offset * 3; - - for (u32 sc=0; scgetVertexCount(); - - for (s32 vu=0; vu<3; ++vu) - { - video::S3DVertex2TCoords currentVertex; - SLMTSTriangleDataEntry *v = &Triangles[offs+(3*sc)+vu]; - - currentVertex.Color.set(255,255,255,255); - - currentVertex.Pos.X = v->X; - currentVertex.Pos.Y = v->Y; - currentVertex.Pos.Z = v->Z; - currentVertex.TCoords.X = v->U1; - currentVertex.TCoords.Y = v->V1; - currentVertex.TCoords2.X = v->U2; - currentVertex.TCoords2.Y = v->V2; - - meshBuffer->Vertices.push_back(currentVertex); - } - - meshBuffer->Indices.push_back(idx); - meshBuffer->Indices.push_back(idx+1); - meshBuffer->Indices.push_back(idx+2); - } - } - - for (u32 j=0; jMeshBuffers.size(); ++j) - ((SMeshBufferLightMap*)Mesh->MeshBuffers[j])->recalculateBoundingBox(); - - Mesh->recalculateBoundingBox(); -} - -void CLMTSMeshFileLoader::loadTextures() -{ - if (!Driver || !FileSystem) - return; - - core::stringc s; - - // load textures - - core::array tex; - tex.set_used(NumTextures); - - core::array lig; - lig.set_used(NumLightMaps); - - s32 t; - s32 tx_count = 0; - s32 lm_count = 0; - core::stringc Path = Parameters->getAttributeAsString(LMTS_TEXTURE_PATH); - - for (t=0; texistFile(s.c_str())) - tmptex = Driver->getTexture(s.c_str()); - else - { - char buf[300]; // filenames may be 256 bytes long - sprintf(buf, "LMTS WARNING: Texture does not exist: %s", s.c_str()); - LMTS_LOG(buf, ELL_WARNING); - } - - - if (Textures[t].Flags & 1) { - lig[lm_count++] = tmptex; - } else { - tex[tx_count++] = tmptex; - } - - } - - // attach textures to materials. - - s32 i; - for (i=0; igetMeshBuffer(i); - - if (Subsets[i].TextID1 < Header.TextureCount) - b->Material.Textures[0] = tex[TextureIDs[Subsets[i].TextID1]]; - if (Subsets[i].TextID2 < Header.TextureCount) - b->Material.Textures[1] = lig[TextureIDs[Subsets[i].TextID2]]; - - if (!b->Material.Textures[1]) - b->Material.MaterialType = video::EMT_SOLID; - } - -} - - -} // end namespace scene -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// This file was written by Jonas Petersen and modified by Nikolaus Gebhardt. +// See CLMTSMeshFileLoder.h for details. +/* + +CLMTSMeshFileLoader.cpp + +LMTSMeshFileLoader +Written by Jonas Petersen (a.k.a. jox) + +Version 1.5 - 15 March 2005 + +Get the latest version here: http://development.mindfloaters.de/ + +This is an addon class for the Irrlicht engine by Nikolaus Gebhardt (http://irrlicht.sourceforge.net). +With this release the Irrlicht engine is at version 0.6 + +This class allows loading meshes with lightmaps (*.lmts + *.tga files) that were created +using Pulsar LMTools by Lord Trancos (http://www.geocities.com/dxlab/index_en.html) + +Notes: +- This version does not recognice/support user data in the *.lmts files. +- The lightmap TGA's generated by LMTools doesn't work in Irrlicht for some reason (the + lightmaps look messed up). Opening and resaving them in a graphics app will solve + the problem (tested only with Photoshop). + + +License: +-------- + +It's free. You are encouraged to give me credit if you use it in your software. + +Version History: +---------------- + +Version 1.5 - 15 March 2005 +- Added the switch LMTS_INTEGRATED_IN_IRRLICHT. This was needed because + of access problems to the irrlicht Logger. +- Did a better cleanup. No memory leaks in case of an loading error. +- Added "#include " for sprintf. + +Version 1.4 - 12 March 2005 +- Fixed bug in texture and subset loading code that would possibly cause crash. +- Fixed memory cleanup to avoid leak when loading more then one mesh +- Used the irrlicht Logger instead of cerr to output warnings and errors. + For this I had to change the constructor + from: + CLMTSMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver) + to: + CLMTSMeshFileLoader(IrrlichtDevice* device) + +Version 1.3 - 15 February 2005 +- Fixed bug that prevented loading more than one different lmts files. +- Removed unnecessary "#include ". +- Added "std::" in front of "cerr". This was necessary for Visual Studio .NET, + I hope it's not disturbing other compilers. +- Added warning message when a texture can not be loaded. +- Changed the documentation a bit (minor). + +Version 1.2 +- To avoid confusion I skipped version 1.2 because the website was offering +version 1.2 even though it was only version 1.1. Sorry about that. + +Version 1.1 - 29 July 2004 +- Added setTexturePath() function +- Minor improvements + +Version 1.0 - 29 July 2004 +- Initial release + + +*/ +////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include "CLMTSMeshFileLoader.h" +#if LMTS_INTEGRATED_IN_IRRLICHT +#include "os.h" +#endif + +namespace irr +{ +namespace scene +{ + +#if LMTS_INTEGRATED_IN_IRRLICHT + +CLMTSMeshFileLoader::CLMTSMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver, + io::IAttributes* parameters) + : Textures(0), TextureIDs(0), Subsets(0), Triangles(0), Mesh(0), + NumTextures(0), NumLightMaps(0), Parameters(parameters), Driver(driver), FileSystem(fs) +{ + if (Driver) + Driver->grab(); + + if (FileSystem) + FileSystem->grab(); +} + +#else + +CLMTSMeshFileLoader::CLMTSMeshFileLoader(IrrlichtDevice* device) +: Textures(0), TextureIDs(0), Subsets(0), Triangles(0), Mesh(0), + NumTextures(0), NumLightMaps(0), Parameters(0), Logger(0) +{ + FileSystem = device->getFileSystem(); + FileSystem->grab(); + + Driver = device->getVideoDriver(); + Driver->grab(); + + Logger = device->getLogger(); + Parameters = device->getSceneManager()->getParameters(); +} + +#endif + +CLMTSMeshFileLoader::~CLMTSMeshFileLoader() +{ + if (Mesh) + Mesh->drop(); + + if (Driver) + Driver->drop(); + + if (FileSystem) + FileSystem->drop(); +} + +void CLMTSMeshFileLoader::cleanup() { + delete [] Textures; + delete [] TextureIDs; + delete [] Subsets; + delete [] Triangles; +} + +bool CLMTSMeshFileLoader::isALoadableFileExtension(const c8* filename) { + return strstr(filename, ".lmts") != 0; +} + +IAnimatedMesh* CLMTSMeshFileLoader::createMesh(irr::io::IReadFile* file) { + + u32 i; + u32 id; + + // HEADER + + file->read(&Header, sizeof(SLMTSHeader)); + if (Header.MagicID != 0x53544D4C) { // "LMTS" + LMTS_LOG("LMTS ERROR: wrong header magic id!", ELL_ERROR); + return 0; + } + + // TEXTURES + + file->read(&id, sizeof(u32)); + if (id != 0x54584554) { // "TEXT" + LMTS_LOG("LMTS ERROR: wrong texture magic id!", ELL_ERROR); + return 0; + } + + Textures = new SLMTSTextureInfoEntry[Header.TextureCount]; + TextureIDs = new u16[Header.TextureCount]; + + NumLightMaps = NumTextures = 0; + + for (i=0; iread(&Textures[i], sizeof(SLMTSTextureInfoEntry)); + if (Textures[i].Flags & 1) { + TextureIDs[i] = NumLightMaps; + NumLightMaps++; + } else { + TextureIDs[i] = NumTextures; + NumTextures++; + } + + } + + // SUBSETS + + file->read(&id, sizeof(u32)); + if (id != 0x53425553) { // "SUBS" + LMTS_LOG("LMTS ERROR: wrong subset magic id!", ELL_ERROR); + cleanup(); + return 0; + } + + Subsets = new SLMTSSubsetInfoEntry[Header.SubsetCount]; + + for (i=0; iread(&Subsets[i], sizeof(SLMTSSubsetInfoEntry)); + } + + // TRIANGLES + + file->read(&id, sizeof(u32)); + if (id != 0x53495254) { // "TRIS" + LMTS_LOG("LMTS ERROR: wrong triangle magic id!", ELL_ERROR); + cleanup(); + return 0; + } + + Triangles = new SLMTSTriangleDataEntry[(Header.TriangleCount*3)]; + + for (i=0; i<(Header.TriangleCount*3); i++) { + file->read(&Triangles[i], sizeof(SLMTSTriangleDataEntry)); + } + + ///////////////////////////////////////////////////////////////// + + constructMesh(); + + loadTextures(); + + cleanup(); + + SAnimatedMesh* am = new SAnimatedMesh(); + am->Type = EAMT_LMTS; // not unknown to irrlicht anymore + + am->addMesh(Mesh); + am->recalculateBoundingBox(); + Mesh->drop(); + Mesh = 0; + return am; +} + +void CLMTSMeshFileLoader::constructMesh() +{ + s32 i; + + if (Mesh) + Mesh->drop(); + + Mesh = new SMesh(); + + for (i=0; iMaterial.MaterialType = video::EMT_LIGHTMAP; // EMT_LIGHTMAP_M2/EMT_LIGHTMAP_M4 also possible + meshBuffer->Material.Wireframe = false; + meshBuffer->Material.Lighting = false; + meshBuffer->Material.BilinearFilter = true; + + Mesh->addMeshBuffer(meshBuffer); + + meshBuffer->drop(); + + u32 offs = Subsets[i].Offset * 3; + + for (u32 sc=0; scgetVertexCount(); + + for (s32 vu=0; vu<3; ++vu) + { + video::S3DVertex2TCoords currentVertex; + SLMTSTriangleDataEntry *v = &Triangles[offs+(3*sc)+vu]; + + currentVertex.Color.set(255,255,255,255); + + currentVertex.Pos.X = v->X; + currentVertex.Pos.Y = v->Y; + currentVertex.Pos.Z = v->Z; + currentVertex.TCoords.X = v->U1; + currentVertex.TCoords.Y = v->V1; + currentVertex.TCoords2.X = v->U2; + currentVertex.TCoords2.Y = v->V2; + + meshBuffer->Vertices.push_back(currentVertex); + } + + meshBuffer->Indices.push_back(idx); + meshBuffer->Indices.push_back(idx+1); + meshBuffer->Indices.push_back(idx+2); + } + } + + for (u32 j=0; jMeshBuffers.size(); ++j) + ((SMeshBufferLightMap*)Mesh->MeshBuffers[j])->recalculateBoundingBox(); + + Mesh->recalculateBoundingBox(); +} + +void CLMTSMeshFileLoader::loadTextures() +{ + if (!Driver || !FileSystem) + return; + + core::stringc s; + + // load textures + + core::array tex; + tex.set_used(NumTextures); + + core::array lig; + lig.set_used(NumLightMaps); + + s32 t; + s32 tx_count = 0; + s32 lm_count = 0; + core::stringc Path = Parameters->getAttributeAsString(LMTS_TEXTURE_PATH); + + for (t=0; texistFile(s.c_str())) + tmptex = Driver->getTexture(s.c_str()); + else + { + char buf[300]; // filenames may be 256 bytes long + sprintf(buf, "LMTS WARNING: Texture does not exist: %s", s.c_str()); + LMTS_LOG(buf, ELL_WARNING); + } + + + if (Textures[t].Flags & 1) { + lig[lm_count++] = tmptex; + } else { + tex[tx_count++] = tmptex; + } + + } + + // attach textures to materials. + + s32 i; + for (i=0; igetMeshBuffer(i); + + if (Subsets[i].TextID1 < Header.TextureCount) + b->Material.Textures[0] = tex[TextureIDs[Subsets[i].TextID1]]; + if (Subsets[i].TextID2 < Header.TextureCount) + b->Material.Textures[1] = lig[TextureIDs[Subsets[i].TextID2]]; + + if (!b->Material.Textures[1]) + b->Material.MaterialType = video::EMT_SOLID; + } + +} + + +} // end namespace scene +} // end namespace irr diff --git a/src/dep/src/irrlicht/CLMTSMeshFileLoader.h b/src/dep/src/irrlicht/CLMTSMeshFileLoader.h index e54a8c7..8c98713 100644 --- a/src/dep/src/irrlicht/CLMTSMeshFileLoader.h +++ b/src/dep/src/irrlicht/CLMTSMeshFileLoader.h @@ -1,161 +1,161 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// I (Nikolaus Gebhardt) did some few changes to Jonas Petersen's original loader: -// - removed setTexturePath() and replaced with the ISceneManager::getStringParameter()-stuff. -// - added EAMT_LMTS enumeration value -// Thanks a lot to Jonas Petersen for his work -// on this and that he gave me his permission to add it into Irrlicht. -/* - -CLMTSMeshFileLoader.h - -LMTSMeshFileLoader -Written by Jonas Petersen (a.k.a. jox) - -Version 1.5 - 15 March 2005 - -*/ - -// set this to 1 if you want to integrate the loader directly into the engine -#define LMTS_INTEGRATED_IN_IRRLICHT 1 - - - -#if !defined(__C_LMTS_MESH_FILE_LOADER_H_INCLUDED__) -#define __C_LMTS_MESH_FILE_LOADER_H_INCLUDED__ - -#if LMTS_INTEGRATED_IN_IRRLICHT -#define LMTS_LOG os::Printer::log -#else -#define LMTS_LOG Logger->log -#endif - -#ifdef _MSC_VER -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -#endif - -#include -#include -#include -#include - -#if !LMTS_INTEGRATED_IN_IRRLICHT -#include -#endif - -namespace irr -{ -namespace scene -{ - -class CLMTSMeshFileLoader : public IMeshLoader -{ -public: - -#if LMTS_INTEGRATED_IN_IRRLICHT - CLMTSMeshFileLoader(io::IFileSystem* fs, - video::IVideoDriver* driver, io::IAttributes* parameters); -#else - CLMTSMeshFileLoader(IrrlichtDevice* device); -#endif - - virtual ~CLMTSMeshFileLoader(); - - void cleanup(); - - virtual bool isALoadableFileExtension(const c8* fileName); - - virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); - -private: - void constructMesh(); - void loadTextures(); - - -// byte-align structures -#ifdef _MSC_VER -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - - struct SLMTSMagigID { - u32 ID; - } PACK_STRUCT; - - struct SLMTSHeader - { - u32 MagicID; - u32 Version; - u32 HeaderSize; - u16 TextureCount; - u16 SubsetCount; - u32 TriangleCount; - u16 SubsetSize; - u16 VertexSize; - } PACK_STRUCT; - - struct SLMTSTextureInfoEntry - { - c8 Filename[256]; - u16 Flags; - } PACK_STRUCT; - - struct SLMTSSubsetInfoEntry - { - u32 Offset; - u32 Count; - u16 TextID1; - u16 TextID2; - } PACK_STRUCT; - - struct SLMTSTriangleDataEntry - { - f32 X; - f32 Y; - f32 Z; - f32 U1; - f32 V1; - f32 U2; - f32 V2; - } PACK_STRUCT; - -// Default alignment -#ifdef _MSC_VER -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - - SLMTSHeader Header; - SLMTSTextureInfoEntry* Textures; - u16* TextureIDs; - SLMTSSubsetInfoEntry* Subsets; - SLMTSTriangleDataEntry* Triangles; - - scene::SMesh* Mesh; - s32 NumTextures; - s32 NumLightMaps; - - io::IAttributes* Parameters; - video::IVideoDriver* Driver; - io::IFileSystem* FileSystem; - -#if !LMTS_INTEGRATED_IN_IRRLICHT - ILogger* Logger; -#endif -}; - -} // end namespace scene -} // end namespace irr - -#endif // !defined(__C_LMTS_MESH_FILE_LOADER_H_INCLUDED__) +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// +// I (Nikolaus Gebhardt) did some few changes to Jonas Petersen's original loader: +// - removed setTexturePath() and replaced with the ISceneManager::getStringParameter()-stuff. +// - added EAMT_LMTS enumeration value +// Thanks a lot to Jonas Petersen for his work +// on this and that he gave me his permission to add it into Irrlicht. +/* + +CLMTSMeshFileLoader.h + +LMTSMeshFileLoader +Written by Jonas Petersen (a.k.a. jox) + +Version 1.5 - 15 March 2005 + +*/ + +// set this to 1 if you want to integrate the loader directly into the engine +#define LMTS_INTEGRATED_IN_IRRLICHT 1 + + + +#if !defined(__C_LMTS_MESH_FILE_LOADER_H_INCLUDED__) +#define __C_LMTS_MESH_FILE_LOADER_H_INCLUDED__ + +#if LMTS_INTEGRATED_IN_IRRLICHT +#define LMTS_LOG os::Printer::log +#else +#define LMTS_LOG Logger->log +#endif + +#ifdef _MSC_VER +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#endif + +#include +#include +#include +#include + +#if !LMTS_INTEGRATED_IN_IRRLICHT +#include +#endif + +namespace irr +{ +namespace scene +{ + +class CLMTSMeshFileLoader : public IMeshLoader +{ +public: + +#if LMTS_INTEGRATED_IN_IRRLICHT + CLMTSMeshFileLoader(io::IFileSystem* fs, + video::IVideoDriver* driver, io::IAttributes* parameters); +#else + CLMTSMeshFileLoader(IrrlichtDevice* device); +#endif + + virtual ~CLMTSMeshFileLoader(); + + void cleanup(); + + virtual bool isALoadableFileExtension(const c8* fileName); + + virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); + +private: + void constructMesh(); + void loadTextures(); + + +// byte-align structures +#ifdef _MSC_VER +# pragma pack( push, packing ) +# pragma pack( 1 ) +# define PACK_STRUCT +#elif defined( __GNUC__ ) +# define PACK_STRUCT __attribute__((packed)) +#else +# error compiler not supported +#endif + + + struct SLMTSMagigID { + u32 ID; + } PACK_STRUCT; + + struct SLMTSHeader + { + u32 MagicID; + u32 Version; + u32 HeaderSize; + u16 TextureCount; + u16 SubsetCount; + u32 TriangleCount; + u16 SubsetSize; + u16 VertexSize; + } PACK_STRUCT; + + struct SLMTSTextureInfoEntry + { + c8 Filename[256]; + u16 Flags; + } PACK_STRUCT; + + struct SLMTSSubsetInfoEntry + { + u32 Offset; + u32 Count; + u16 TextID1; + u16 TextID2; + } PACK_STRUCT; + + struct SLMTSTriangleDataEntry + { + f32 X; + f32 Y; + f32 Z; + f32 U1; + f32 V1; + f32 U2; + f32 V2; + } PACK_STRUCT; + +// Default alignment +#ifdef _MSC_VER +# pragma pack( pop, packing ) +#endif + +#undef PACK_STRUCT + + SLMTSHeader Header; + SLMTSTextureInfoEntry* Textures; + u16* TextureIDs; + SLMTSSubsetInfoEntry* Subsets; + SLMTSTriangleDataEntry* Triangles; + + scene::SMesh* Mesh; + s32 NumTextures; + s32 NumLightMaps; + + io::IAttributes* Parameters; + video::IVideoDriver* Driver; + io::IFileSystem* FileSystem; + +#if !LMTS_INTEGRATED_IN_IRRLICHT + ILogger* Logger; +#endif +}; + +} // end namespace scene +} // end namespace irr + +#endif // !defined(__C_LMTS_MESH_FILE_LOADER_H_INCLUDED__) diff --git a/src/dep/src/irrlicht/CLightSceneNode.cpp b/src/dep/src/irrlicht/CLightSceneNode.cpp index 2314def..d49da5c 100644 --- a/src/dep/src/irrlicht/CLightSceneNode.cpp +++ b/src/dep/src/irrlicht/CLightSceneNode.cpp @@ -1,170 +1,170 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CLightSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "ICameraSceneNode.h" - -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CLightSceneNode::CLightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, video::SColorf color,f32 radius) -: ILightSceneNode(parent, mgr, id, position) -{ - #ifdef _DEBUG - setDebugName("CLightSceneNode"); - #endif - - LightData.Radius = radius; - LightData.DiffuseColor = color; - - // set some useful specular color - LightData.SpecularColor = color.getInterpolated(video::SColor(255,255,255,255),0.7f); -} - -CLightSceneNode::~CLightSceneNode() -{ -} - - -//! pre render event -void CLightSceneNode::OnRegisterSceneNode() -{ - doLightRecalc (); - - if (IsVisible ) - { - SceneManager->registerNodeForRendering(this, ESNRP_LIGHT); - ISceneNode::OnRegisterSceneNode(); - } -} - - -//! render -void CLightSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - if (!driver) - return; - - if (DebugDataVisible) - { - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - - switch ( LightData.Type ) - { - case video::ELT_POINT: - driver->draw3DBox( BBox, LightData.DiffuseColor.toSColor()); - break; - - case video::ELT_DIRECTIONAL: - driver->draw3DLine ( core::vector3df ( 0.f, 0.f, 0.f ), - core::vector3df ( 0.f, 0.f, 0.f ) + (LightData.Position * 10.f ), - LightData.DiffuseColor.toSColor() - ); - break; - } - } - - driver->addDynamicLight(LightData); -} - - -//! returns the light data -void CLightSceneNode::setLightData(const video::SLight& light) -{ - LightData = light; - ISceneNode::setPosition(light.Position); - ISceneNode::updateAbsolutePosition (); -} - - -//! \return Returns the light data. -video::SLight& CLightSceneNode::getLightData() -{ - return LightData; -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CLightSceneNode::getBoundingBox() const -{ - return BBox; -} - - -void CLightSceneNode::doLightRecalc() -{ - switch ( LightData.Type ) - { - case video::ELT_POINT: - { - f32 r = LightData.Radius * LightData.Radius * 0.5f; - BBox.MaxEdge.set ( r, r, r ); - BBox.MinEdge.set ( -r, -r, -r ); - setAutomaticCulling ( scene::EAC_BOX ); - - LightData.Position = getAbsolutePosition(); - } break; - - case video::ELT_DIRECTIONAL: - BBox.reset ( 0, 0, 0 ); - setAutomaticCulling ( scene::EAC_OFF ); - - // misuse Position as direction.. - LightData.Position = getAbsolutePosition(); - LightData.Position.invert(); - if ( LightData.Position.getLengthSQ() == 0.0 ) - { - LightData.Position.set ( 0.f, -1.f, 0.f ); - os::Printer::log ( "Invalid Directional Light Direction" ); - } - else - { - LightData.Position.normalize(); - } - break; - } - -} - -//! Writes attributes of the scene node. -void CLightSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - ILightSceneNode::serializeAttributes(out, options); - - out->addColorf ("AmbientColor", LightData.AmbientColor); - out->addColorf ("DiffuseColor", LightData.DiffuseColor); - out->addColorf ("SpecularColor", LightData.SpecularColor); - out->addFloat ("Radius", LightData.Radius); - out->addBool ("CastShadows", LightData.CastShadows); - out->addEnum ("LightType", LightData.Type, video::LightTypeNames); -} - -//! Reads attributes of the scene node. -void CLightSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - LightData.AmbientColor = in->getAttributeAsColorf("AmbientColor"); - LightData.DiffuseColor = in->getAttributeAsColorf("DiffuseColor"); - LightData.SpecularColor = in->getAttributeAsColorf("SpecularColor"); - LightData.Radius = in->getAttributeAsFloat("Radius"); - LightData.CastShadows = in->getAttributeAsBool("CastShadows"); - LightData.Type = (video::E_LIGHT_TYPE)in->getAttributeAsEnumeration("LightType", video::LightTypeNames); - - ILightSceneNode::deserializeAttributes(in, options); -} - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CLightSceneNode.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" +#include "ICameraSceneNode.h" + +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CLightSceneNode::CLightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position, video::SColorf color,f32 radius) +: ILightSceneNode(parent, mgr, id, position) +{ + #ifdef _DEBUG + setDebugName("CLightSceneNode"); + #endif + + LightData.Radius = radius; + LightData.DiffuseColor = color; + + // set some useful specular color + LightData.SpecularColor = color.getInterpolated(video::SColor(255,255,255,255),0.7f); +} + +CLightSceneNode::~CLightSceneNode() +{ +} + + +//! pre render event +void CLightSceneNode::OnRegisterSceneNode() +{ + doLightRecalc (); + + if (IsVisible ) + { + SceneManager->registerNodeForRendering(this, ESNRP_LIGHT); + ISceneNode::OnRegisterSceneNode(); + } +} + + +//! render +void CLightSceneNode::render() +{ + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + if (!driver) + return; + + if (DebugDataVisible) + { + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + video::SMaterial m; + m.Lighting = false; + driver->setMaterial(m); + + switch ( LightData.Type ) + { + case video::ELT_POINT: + driver->draw3DBox( BBox, LightData.DiffuseColor.toSColor()); + break; + + case video::ELT_DIRECTIONAL: + driver->draw3DLine ( core::vector3df ( 0.f, 0.f, 0.f ), + core::vector3df ( 0.f, 0.f, 0.f ) + (LightData.Position * 10.f ), + LightData.DiffuseColor.toSColor() + ); + break; + } + } + + driver->addDynamicLight(LightData); +} + + +//! returns the light data +void CLightSceneNode::setLightData(const video::SLight& light) +{ + LightData = light; + ISceneNode::setPosition(light.Position); + ISceneNode::updateAbsolutePosition (); +} + + +//! \return Returns the light data. +video::SLight& CLightSceneNode::getLightData() +{ + return LightData; +} + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CLightSceneNode::getBoundingBox() const +{ + return BBox; +} + + +void CLightSceneNode::doLightRecalc() +{ + switch ( LightData.Type ) + { + case video::ELT_POINT: + { + f32 r = LightData.Radius * LightData.Radius * 0.5f; + BBox.MaxEdge.set ( r, r, r ); + BBox.MinEdge.set ( -r, -r, -r ); + setAutomaticCulling ( scene::EAC_BOX ); + + LightData.Position = getAbsolutePosition(); + } break; + + case video::ELT_DIRECTIONAL: + BBox.reset ( 0, 0, 0 ); + setAutomaticCulling ( scene::EAC_OFF ); + + // misuse Position as direction.. + LightData.Position = getAbsolutePosition(); + LightData.Position.invert(); + if ( LightData.Position.getLengthSQ() == 0.0 ) + { + LightData.Position.set ( 0.f, -1.f, 0.f ); + os::Printer::log ( "Invalid Directional Light Direction" ); + } + else + { + LightData.Position.normalize(); + } + break; + } + +} + +//! Writes attributes of the scene node. +void CLightSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + ILightSceneNode::serializeAttributes(out, options); + + out->addColorf ("AmbientColor", LightData.AmbientColor); + out->addColorf ("DiffuseColor", LightData.DiffuseColor); + out->addColorf ("SpecularColor", LightData.SpecularColor); + out->addFloat ("Radius", LightData.Radius); + out->addBool ("CastShadows", LightData.CastShadows); + out->addEnum ("LightType", LightData.Type, video::LightTypeNames); +} + +//! Reads attributes of the scene node. +void CLightSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + LightData.AmbientColor = in->getAttributeAsColorf("AmbientColor"); + LightData.DiffuseColor = in->getAttributeAsColorf("DiffuseColor"); + LightData.SpecularColor = in->getAttributeAsColorf("SpecularColor"); + LightData.Radius = in->getAttributeAsFloat("Radius"); + LightData.CastShadows = in->getAttributeAsBool("CastShadows"); + LightData.Type = (video::E_LIGHT_TYPE)in->getAttributeAsEnumeration("LightType", video::LightTypeNames); + + ILightSceneNode::deserializeAttributes(in, options); +} + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CLightSceneNode.h b/src/dep/src/irrlicht/CLightSceneNode.h index e4a8759..dc1f92c 100644 --- a/src/dep/src/irrlicht/CLightSceneNode.h +++ b/src/dep/src/irrlicht/CLightSceneNode.h @@ -1,63 +1,63 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_LIGHT_SCENE_NODE_H_INCLUDED__ -#define __C_LIGHT_SCENE_NODE_H_INCLUDED__ - -#include "ILightSceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! Scene node which is a dynamic light. You can switch the light on and off by -//! making it visible or not, and let it be animated by ordinary scene node animators. -class CLightSceneNode : public ILightSceneNode -{ -public: - - //! constructor - CLightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, video::SColorf color, f32 range); - - virtual ~CLightSceneNode(); - - //! pre render event - virtual void OnRegisterSceneNode(); - - //! render - virtual void render(); - - //! set node light data from light info - virtual void setLightData( const video::SLight& light); - - //! \return Returns the light data. - virtual video::SLight& getLightData(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_LIGHT; } - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - -private: - - video::SLight LightData; - core::aabbox3d BBox; - void doLightRecalc(); -}; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_LIGHT_SCENE_NODE_H_INCLUDED__ +#define __C_LIGHT_SCENE_NODE_H_INCLUDED__ + +#include "ILightSceneNode.h" + +namespace irr +{ +namespace scene +{ + +//! Scene node which is a dynamic light. You can switch the light on and off by +//! making it visible or not, and let it be animated by ordinary scene node animators. +class CLightSceneNode : public ILightSceneNode +{ +public: + + //! constructor + CLightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position, video::SColorf color, f32 range); + + virtual ~CLightSceneNode(); + + //! pre render event + virtual void OnRegisterSceneNode(); + + //! render + virtual void render(); + + //! set node light data from light info + virtual void setLightData( const video::SLight& light); + + //! \return Returns the light data. + virtual video::SLight& getLightData(); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_LIGHT; } + + //! Writes attributes of the scene node. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + +private: + + video::SLight LightData; + core::aabbox3d BBox; + void doLightRecalc(); +}; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CLimitReadFile.cpp b/src/dep/src/irrlicht/CLimitReadFile.cpp index 6c04917..ed5de00 100644 --- a/src/dep/src/irrlicht/CLimitReadFile.cpp +++ b/src/dep/src/irrlicht/CLimitReadFile.cpp @@ -1,117 +1,117 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CLimitReadFile.h" -#include "irrString.h" - -namespace irr -{ -namespace io -{ - - -CLimitReadFile::CLimitReadFile(IReadFile* alreadyOpenedFile, s32 areaSize, const c8* name) -: Filename(name), AreaSize(areaSize), AreaStart(0), AreaEnd(0), File(alreadyOpenedFile) -{ - #ifdef _DEBUG - setDebugName("CLimitReadFile"); - #endif - - if (File) - File->grab(); - - init(); -} - - -void CLimitReadFile::init() -{ - if (!File) - return; - - AreaStart = File->getPos(); - AreaEnd = AreaStart + AreaSize; -} - - - -CLimitReadFile::~CLimitReadFile() -{ - if (File) - File->drop(); -} - - - -//! returns how much was read -s32 CLimitReadFile::read(void* buffer, u32 sizeToRead) -{ - s32 pos = File->getPos(); - - if (pos >= AreaEnd) - return 0; - - if (pos + (s32)sizeToRead >= AreaEnd) - sizeToRead = AreaEnd - pos; - - return File->read(buffer, sizeToRead); -} - - - -//! changes position in file, returns true if successful -//! if relativeMovement==true, the pos is changed relative to current pos, -//! otherwise from begin of file -bool CLimitReadFile::seek(s32 finalPos, bool relativeMovement) -{ - s32 pos = File->getPos(); - - if (relativeMovement) - { - if (pos + finalPos > AreaEnd) - finalPos = AreaEnd - pos; - } - else - { - finalPos += AreaStart; - if ((s32)finalPos > AreaEnd) - return false; - } - - return File->seek(finalPos, relativeMovement); -} - - - -//! returns size of file -s32 CLimitReadFile::getSize() -{ - return AreaSize; -} - - - -//! returns where in the file we are. -s32 CLimitReadFile::getPos() -{ - return File->getPos() - AreaStart; -} - - - -//! returns name of file -const c8* CLimitReadFile::getFileName() -{ - return Filename.c_str(); -} - - -IReadFile* createLimitReadFile(const c8* fileName, IReadFile* alreadyOpenedFile, s32 areaSize) -{ - return new CLimitReadFile(alreadyOpenedFile, areaSize, fileName); -} - - -} // end namespace io -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CLimitReadFile.h" +#include "irrString.h" + +namespace irr +{ +namespace io +{ + + +CLimitReadFile::CLimitReadFile(IReadFile* alreadyOpenedFile, s32 areaSize, const c8* name) +: Filename(name), AreaSize(areaSize), AreaStart(0), AreaEnd(0), File(alreadyOpenedFile) +{ + #ifdef _DEBUG + setDebugName("CLimitReadFile"); + #endif + + if (File) + File->grab(); + + init(); +} + + +void CLimitReadFile::init() +{ + if (!File) + return; + + AreaStart = File->getPos(); + AreaEnd = AreaStart + AreaSize; +} + + + +CLimitReadFile::~CLimitReadFile() +{ + if (File) + File->drop(); +} + + + +//! returns how much was read +s32 CLimitReadFile::read(void* buffer, u32 sizeToRead) +{ + s32 pos = File->getPos(); + + if (pos >= AreaEnd) + return 0; + + if (pos + (s32)sizeToRead >= AreaEnd) + sizeToRead = AreaEnd - pos; + + return File->read(buffer, sizeToRead); +} + + + +//! changes position in file, returns true if successful +//! if relativeMovement==true, the pos is changed relative to current pos, +//! otherwise from begin of file +bool CLimitReadFile::seek(s32 finalPos, bool relativeMovement) +{ + s32 pos = File->getPos(); + + if (relativeMovement) + { + if (pos + finalPos > AreaEnd) + finalPos = AreaEnd - pos; + } + else + { + finalPos += AreaStart; + if ((s32)finalPos > AreaEnd) + return false; + } + + return File->seek(finalPos, relativeMovement); +} + + + +//! returns size of file +s32 CLimitReadFile::getSize() +{ + return AreaSize; +} + + + +//! returns where in the file we are. +s32 CLimitReadFile::getPos() +{ + return File->getPos() - AreaStart; +} + + + +//! returns name of file +const c8* CLimitReadFile::getFileName() +{ + return Filename.c_str(); +} + + +IReadFile* createLimitReadFile(const c8* fileName, IReadFile* alreadyOpenedFile, s32 areaSize) +{ + return new CLimitReadFile(alreadyOpenedFile, areaSize, fileName); +} + + +} // end namespace io +} // end namespace irr diff --git a/src/dep/src/irrlicht/CLimitReadFile.h b/src/dep/src/irrlicht/CLimitReadFile.h index ae74ca8..c90b523 100644 --- a/src/dep/src/irrlicht/CLimitReadFile.h +++ b/src/dep/src/irrlicht/CLimitReadFile.h @@ -1,64 +1,64 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_LIMIT_READ_FILE_H_INCLUDED__ -#define __C_LIMIT_READ_FILE_H_INCLUDED__ - -#include "IReadFile.h" -#include "irrString.h" - -namespace irr -{ - class CUnicodeConverter; - -namespace io -{ - - /*! this is a read file, which is limited to some boundaries, - so that it may only start from a certain file position - and may only read until a certain file position. - This can be useful, for example for reading uncompressed files - in an archive (zip). - !*/ - class CLimitReadFile : public IReadFile - { - public: - - CLimitReadFile(IReadFile* alreadyOpenedFile, s32 areaSize, const c8* name); - - virtual ~CLimitReadFile(); - - //! returns how much was read - virtual s32 read(void* buffer, u32 sizeToRead); - - //! changes position in file, returns true if successful - //! if relativeMovement==true, the pos is changed relative to current pos, - //! otherwise from begin of file - virtual bool seek(s32 finalPos, bool relativeMovement = false); - - //! returns size of file - virtual s32 getSize(); - - //! returns where in the file we are. - virtual s32 getPos(); - - //! returns name of file - virtual const c8* getFileName(); - - private: - - void init(); - - core::stringc Filename; - s32 AreaSize; - s32 AreaStart; - s32 AreaEnd; - IReadFile* File; - }; - -} // end namespace io -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_LIMIT_READ_FILE_H_INCLUDED__ +#define __C_LIMIT_READ_FILE_H_INCLUDED__ + +#include "IReadFile.h" +#include "irrString.h" + +namespace irr +{ + class CUnicodeConverter; + +namespace io +{ + + /*! this is a read file, which is limited to some boundaries, + so that it may only start from a certain file position + and may only read until a certain file position. + This can be useful, for example for reading uncompressed files + in an archive (zip). + !*/ + class CLimitReadFile : public IReadFile + { + public: + + CLimitReadFile(IReadFile* alreadyOpenedFile, s32 areaSize, const c8* name); + + virtual ~CLimitReadFile(); + + //! returns how much was read + virtual s32 read(void* buffer, u32 sizeToRead); + + //! changes position in file, returns true if successful + //! if relativeMovement==true, the pos is changed relative to current pos, + //! otherwise from begin of file + virtual bool seek(s32 finalPos, bool relativeMovement = false); + + //! returns size of file + virtual s32 getSize(); + + //! returns where in the file we are. + virtual s32 getPos(); + + //! returns name of file + virtual const c8* getFileName(); + + private: + + void init(); + + core::stringc Filename; + s32 AreaSize; + s32 AreaStart; + s32 AreaEnd; + IReadFile* File; + }; + +} // end namespace io +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CLogger.cpp b/src/dep/src/irrlicht/CLogger.cpp index d0ac68f..95e1764 100644 --- a/src/dep/src/irrlicht/CLogger.cpp +++ b/src/dep/src/irrlicht/CLogger.cpp @@ -1,89 +1,89 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CLogger.h" - -namespace irr -{ - - CLogger::CLogger(IEventReceiver* r) - : LogLevel(ELL_INFORMATION), Receiver(r) - { - } - - //! Returns the current set log level. - ELOG_LEVEL CLogger::getLogLevel() - { - return LogLevel; - } - - //! Sets a new log level. virtual void setLogLevel(ELOG_LEVEL ll); - void CLogger::setLogLevel(ELOG_LEVEL ll) - { - LogLevel = ll; - } - - //! Prints out a text into the log - void CLogger::log(const c8* text, ELOG_LEVEL ll) - { - if (ll < LogLevel) - return; - - if (Receiver) - { - SEvent event; - event.EventType = EET_LOG_TEXT_EVENT; - event.LogEvent.Text = text; - event.LogEvent.Level = ll; - if (Receiver->OnEvent(event)) - return; - } - - os::Printer::print(text); - } - - - //! Prints out a text into the log - void CLogger::log(const c8* text, const c8* hint, ELOG_LEVEL ll) - { - if (ll < LogLevel) - return; - - core::stringc s = text; - s += ": "; - s += hint; - log (s.c_str(), ll); - } - - //! Prints out a text into the log - void CLogger::log(const wchar_t* text, ELOG_LEVEL ll) - { - if (ll < LogLevel) - return; - - core::stringc s = text; - log(s.c_str(), ll); - } - - - //! Prints out a text into the log - void CLogger::log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll) - { - if (ll < LogLevel) - return; - - core::stringc s1 = text; - core::stringc s2 = hint; - log(s1.c_str(), s2.c_str(), ll); - } - - //! Sets a new event receiver - void CLogger::setReceiver(IEventReceiver* r) - { - Receiver = r; - } - - -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CLogger.h" + +namespace irr +{ + + CLogger::CLogger(IEventReceiver* r) + : LogLevel(ELL_INFORMATION), Receiver(r) + { + } + + //! Returns the current set log level. + ELOG_LEVEL CLogger::getLogLevel() + { + return LogLevel; + } + + //! Sets a new log level. virtual void setLogLevel(ELOG_LEVEL ll); + void CLogger::setLogLevel(ELOG_LEVEL ll) + { + LogLevel = ll; + } + + //! Prints out a text into the log + void CLogger::log(const c8* text, ELOG_LEVEL ll) + { + if (ll < LogLevel) + return; + + if (Receiver) + { + SEvent event; + event.EventType = EET_LOG_TEXT_EVENT; + event.LogEvent.Text = text; + event.LogEvent.Level = ll; + if (Receiver->OnEvent(event)) + return; + } + + os::Printer::print(text); + } + + + //! Prints out a text into the log + void CLogger::log(const c8* text, const c8* hint, ELOG_LEVEL ll) + { + if (ll < LogLevel) + return; + + core::stringc s = text; + s += ": "; + s += hint; + log (s.c_str(), ll); + } + + //! Prints out a text into the log + void CLogger::log(const wchar_t* text, ELOG_LEVEL ll) + { + if (ll < LogLevel) + return; + + core::stringc s = text; + log(s.c_str(), ll); + } + + + //! Prints out a text into the log + void CLogger::log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll) + { + if (ll < LogLevel) + return; + + core::stringc s1 = text; + core::stringc s2 = hint; + log(s1.c_str(), s2.c_str(), ll); + } + + //! Sets a new event receiver + void CLogger::setReceiver(IEventReceiver* r) + { + Receiver = r; + } + + +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CLogger.h b/src/dep/src/irrlicht/CLogger.h index 3133210..93bbeca 100644 --- a/src/dep/src/irrlicht/CLogger.h +++ b/src/dep/src/irrlicht/CLogger.h @@ -1,53 +1,53 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_LOGGER_H_INCLUDED__ -#define __C_LOGGER_H_INCLUDED__ - -#include "ILogger.h" -#include "os.h" -#include "irrString.h" -#include "IEventReceiver.h" - -namespace irr -{ - -//! Interface for logging messages, warnings and errors -class CLogger : public ILogger -{ -public: - - CLogger(IEventReceiver* r); - - //! Returns the current set log level. - virtual ELOG_LEVEL getLogLevel(); - - //! Sets a new log level. virtual void setLogLevel(ELOG_LEVEL ll); - virtual void setLogLevel(ELOG_LEVEL ll); - - //! Prints out a text into the log - virtual void log(const c8* text, ELOG_LEVEL ll=ELL_INFORMATION); - - //! Prints out a text into the log - virtual void log(const wchar_t* text, ELOG_LEVEL ll=ELL_INFORMATION); - - //! Prints out a text into the log - virtual void log(const c8* text, const c8* hint, ELOG_LEVEL ll=ELL_INFORMATION); - - //! Prints out a text into the log - virtual void log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION); - - //! Sets a new event receiver - void setReceiver(IEventReceiver* r); - -private: - - ELOG_LEVEL LogLevel; - IEventReceiver* Receiver; -}; - -} // end namespace - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_LOGGER_H_INCLUDED__ +#define __C_LOGGER_H_INCLUDED__ + +#include "ILogger.h" +#include "os.h" +#include "irrString.h" +#include "IEventReceiver.h" + +namespace irr +{ + +//! Interface for logging messages, warnings and errors +class CLogger : public ILogger +{ +public: + + CLogger(IEventReceiver* r); + + //! Returns the current set log level. + virtual ELOG_LEVEL getLogLevel(); + + //! Sets a new log level. virtual void setLogLevel(ELOG_LEVEL ll); + virtual void setLogLevel(ELOG_LEVEL ll); + + //! Prints out a text into the log + virtual void log(const c8* text, ELOG_LEVEL ll=ELL_INFORMATION); + + //! Prints out a text into the log + virtual void log(const wchar_t* text, ELOG_LEVEL ll=ELL_INFORMATION); + + //! Prints out a text into the log + virtual void log(const c8* text, const c8* hint, ELOG_LEVEL ll=ELL_INFORMATION); + + //! Prints out a text into the log + virtual void log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION); + + //! Sets a new event receiver + void setReceiver(IEventReceiver* r); + +private: + + ELOG_LEVEL LogLevel; + IEventReceiver* Receiver; +}; + +} // end namespace + +#endif + diff --git a/src/dep/src/irrlicht/CMD3MeshFileLoader.cpp b/src/dep/src/irrlicht/CMD3MeshFileLoader.cpp index 5fcbf45..bbddd9f 100644 --- a/src/dep/src/irrlicht/CMD3MeshFileLoader.cpp +++ b/src/dep/src/irrlicht/CMD3MeshFileLoader.cpp @@ -1,49 +1,49 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CMD3MeshFileLoader.h" -#include "CAnimatedMeshMD3.h" -#include "irrString.h" - -namespace irr -{ -namespace scene -{ - -//! Constructor -CMD3MeshFileLoader::CMD3MeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver) -{ -} - - - -//! destructor -CMD3MeshFileLoader::~CMD3MeshFileLoader() -{ -} - - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool CMD3MeshFileLoader::isALoadableFileExtension(const c8* filename) -{ - return strstr(filename, ".md3") != 0; -} - -IAnimatedMesh* CMD3MeshFileLoader::createMesh(irr::io::IReadFile* file) -{ - CAnimatedMeshMD3 * mesh = new CAnimatedMeshMD3(); - - if ( mesh->loadModelFile ( 0, file ) ) - return mesh; - - mesh->drop (); - return 0; -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CMD3MeshFileLoader.h" +#include "CAnimatedMeshMD3.h" +#include "irrString.h" + +namespace irr +{ +namespace scene +{ + +//! Constructor +CMD3MeshFileLoader::CMD3MeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver) +{ +} + + + +//! destructor +CMD3MeshFileLoader::~CMD3MeshFileLoader() +{ +} + + + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".bsp") +bool CMD3MeshFileLoader::isALoadableFileExtension(const c8* filename) +{ + return strstr(filename, ".md3") != 0; +} + +IAnimatedMesh* CMD3MeshFileLoader::createMesh(irr::io::IReadFile* file) +{ + CAnimatedMeshMD3 * mesh = new CAnimatedMeshMD3(); + + if ( mesh->loadModelFile ( 0, file ) ) + return mesh; + + mesh->drop (); + return 0; +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CMD3MeshFileLoader.h b/src/dep/src/irrlicht/CMD3MeshFileLoader.h index c2c4f23..eb1aec6 100644 --- a/src/dep/src/irrlicht/CMD3MeshFileLoader.h +++ b/src/dep/src/irrlicht/CMD3MeshFileLoader.h @@ -1,48 +1,48 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_MD3_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_MD3_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "IAnimatedMeshMD3.h" -#include "IQ3Shader.h" - -namespace irr -{ -namespace scene -{ - -//! Meshloader capable of loading md3 files. -class CMD3MeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - CMD3MeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver); - - //! destructor - virtual ~CMD3MeshFileLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".bsp") - virtual bool isALoadableFileExtension(const c8* fileName); - - //! creates/loads an animated mesh from the file. - //! \return Pointer to the created mesh. Returns 0 if loading failed. - //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). - //! See IUnknown::drop() for more information. - virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); - -private: - -}; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_MD3_MESH_FILE_LOADER_H_INCLUDED__ +#define __C_MD3_MESH_FILE_LOADER_H_INCLUDED__ + +#include "IMeshLoader.h" +#include "IFileSystem.h" +#include "IVideoDriver.h" +#include "IAnimatedMeshMD3.h" +#include "IQ3Shader.h" + +namespace irr +{ +namespace scene +{ + +//! Meshloader capable of loading md3 files. +class CMD3MeshFileLoader : public IMeshLoader +{ +public: + + //! Constructor + CMD3MeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver); + + //! destructor + virtual ~CMD3MeshFileLoader(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".bsp") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! creates/loads an animated mesh from the file. + //! \return Pointer to the created mesh. Returns 0 if loading failed. + //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). + //! See IUnknown::drop() for more information. + virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); + +private: + +}; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CMY3DHelper.h b/src/dep/src/irrlicht/CMY3DHelper.h index 10fc753..9c422f3 100644 --- a/src/dep/src/irrlicht/CMY3DHelper.h +++ b/src/dep/src/irrlicht/CMY3DHelper.h @@ -1,436 +1,436 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This file was originally written by ZDimitor. - -//---------------------------------------------------------------------- -// somefuncs.h - part of the My3D Tools -// -// This tool was created by Zhuck Dmitry (ZDimitor). -// Everyone can use it as wants ( i'll be happy if it helps to someone :) ). -//---------------------------------------------------------------------- - -//********************************************************************** -// some usefull functions -//********************************************************************** - -#ifndef __C_MY3D_HELPER_H_INCLUDED__ -#define __C_MY3D_HELPER_H_INCLUDED__ - -//-------------------------------------------------------------------------------- -namespace irr -{ -namespace core -{ - -//--------------------------------------------------------------------- -inline f32 fmax(f32 v1, f32 v2) -{ return (v1>v2)?v1:v2; -} -//---------------------------------------------------------------------------- -template -s32 strlen(T* str) -{ int len = 0; - while(true) - { if (*(str+len)==0) - break; - len++; - } - return len; -} -//---------------------------------------------------------------------------- -template -T* strcpy (T* src, T* dst) -{ if (src&&dst) - { s32 len = strlen(src); - for (s32 i=0; i -T* strcpy (T* src, T* dst, s32 startPos, s32 endPos) -{ if (src&&dst) - { s32 len = strlen(src); - - s32 charIndex=0; - for (s32 i=startPos; i<=endPos && endPos -s32 findLast(T* Str, c8 ch) -{ - s32 lenSrc = strlen(Str); - s32 n=lenSrc-1; - s32 lastCharInStringPos = -1; - while(true) - { if (Str[n] == ch) - { lastCharInStringPos = n; - break; - } - if (n==0) break; - n--; - } - return lastCharInStringPos; -} -//---------------------------------------------------------------------------- -template -s32 findLastDelimiter(T* Str) -{ - s32 lenSrc = strlen(Str); - s32 n=lenSrc-1; - s32 lastDelimiterInStringPos = -1; - while(true) - { if (Str[n] == '\\' || Str[n] == '/') - { lastDelimiterInStringPos = n; - break; - } - if (n==0) break; - n--; - } - return lastDelimiterInStringPos; -} -//---------------------------------------------------------------------------- -template -T* extractFilePath(T* sourceStr, T* buffer, s32 bufSize) -{ - s32 lastDelimiterInStringPos = findLastDelimiter(sourceStr); - - if (lastDelimiterInStringPos>=0 && lastDelimiterInStringPos -T* extractFileName(T* sourceStr, T* buffer, s32 bufSize) -{ s32 lastDelimiterInStringPos = findLastDelimiter(sourceStr); - s32 lenSrc = strlen(sourceStr); - - if (lastDelimiterInStringPos>=-1 && (lenSrc-lastDelimiterInStringPos) 128, or EOD, or non-match. -// return values: LIMIT, EOD_FOUND, NON_MATCH -// Prior to ANY return, it writes out the 2 byte compressed code. -// If a NON_MATCH was found, this returns with the non-matching char -// residing in tmpbuf[0]. -// Inputs: tmpbuf[0], input file -// Outputs: tmpbuf[0] (sometimes), output file, and return code -//------------------------------------------------------------------ -unsigned long process_comp( - unsigned char *buf, int buf_size, - unsigned char *out_buf, int out_buf_size) -{ - // we start out with 3 repeating bytes - register int len = 3; - - unsigned char ch; - - // we're starting a repeating chunk - end the non-repeaters - flush_outbuf(out_buf, out_buf_size); - - - while (get_byte(&ch, buf, buf_size, out_buf, out_buf_size) != (int)EOD) - { - if (ch != tmpbuf[1]) - { - // send no. of repeated bytes to be encoded - put_byte((unsigned char)((--len) | 0x80), out_buf, out_buf_size); - // send the byte's value being repeated - put_byte((unsigned char)tmpbuf[1], out_buf, out_buf_size); - /* save the non-matching character just read */ - tmpbuf[1]=(unsigned char) ch; - return NON_MATCH; - } - /* we know the new byte is part of the repeating seq */ - len++; - if (len == 128) - { - // send no. of repeated bytes to be encoded - put_byte((unsigned char)((--len) | 0x80), out_buf, out_buf_size); - // send the byte's value being repeated - put_byte((unsigned char)tmpbuf[1], out_buf, out_buf_size); - return LIMIT; - } - } // end while - - // if flow comes here, we just read an EOD - // send no. of repeated bytes to be encoded - put_byte((unsigned char)((--len) | 0x80), out_buf, out_buf_size); - // send the byte's value being repeated - put_byte((unsigned char)tmpbuf[1], out_buf, out_buf_size); - return EOD_FOUND; -} - - -//---------------------------------------------------------------- -// This adds 1 non-repeating byte to outbuf. If outbuf becomes full -// with 128 bytes, it flushes outbuf. -// There are no return codes and no bytes are read from the input. -//---------------------------------------------------------------- -void process_uncomp( - unsigned char char1, unsigned char *out_buf, int out_buf_size - ) -{ - outbuf[outbuf_cnt++] = char1; - if (outbuf_cnt == 128) - flush_outbuf(out_buf, out_buf_size); -} -//----------------------------------------------------------- -// This flushes any non-compressed data not yet sent. -// On exit, outbuf_cnt will equal zero. -//----------------------------------------------------------- -void flush_outbuf(unsigned char *out_buf, int out_buf_size) -{ - register int pos=0; - - if(!outbuf_cnt) - return; // nothing to do */ - - // send no. of unencoded bytes to be sent - put_byte((unsigned char)(outbuf_cnt - 1), out_buf, out_buf_size); - - for ( ; outbuf_cnt; outbuf_cnt--) - put_byte((unsigned char)outbuf[pos++], out_buf, out_buf_size); -} -//--------------------------------------------------- -void put_byte(unsigned char ch, unsigned char *out_buf, int out_buf_size) -{ - if (nCodedBytes<=(out_buf_size-1)) - { out_buf[nCodedBytes++]=ch; - out_buf[nCodedBytes]=0; - } -} -//--------------------------------------------------- -// This reads the next byte into ch. It returns EOD -// at end-of-data -//--------------------------------------------------- -unsigned long get_byte( - unsigned char *ch, - unsigned char *in_buf, int in_buf_size, - unsigned char *out_buf, int out_buf_size - ) -{ - if (nReadedBytes>=in_buf_size) - { - // there are either 0, 1, or 2 char's to write before we quit - if (tmpbuf_cnt == 1) - process_uncomp(tmpbuf[1], out_buf, out_buf_size); - else - { - if (tmpbuf_cnt == 2) - { - process_uncomp(tmpbuf[1], out_buf, out_buf_size); - process_uncomp(tmpbuf[2], out_buf, out_buf_size); - } - } - nReadedBytes =0; - - return EOD; - } - - (*ch) = (unsigned char)in_buf[nReadedBytes++]; - - return 0; -} -//----------------------------------------------------------- -int rle_decode ( - unsigned char *in_buf, int in_buf_size, - unsigned char *out_buf, int out_buf_size - ) -{ - nDecodedBytes=0; - nReadedBytes=0; - - int ch, i; - while (1) - { - - if (nReadedBytes>=in_buf_size) - break; - else - ch=in_buf[nReadedBytes]; - nReadedBytes++; - - if (ch > 127) - { - i = ch - 127; // i is the number of repetitions - // get the byte to be repeated - if (nReadedBytes>=in_buf_size) - break; - else - ch=in_buf[nReadedBytes]; - nReadedBytes++; - - // uncompress a chunk - for ( ; i ; i--) - { - if (nDecodedBytes=in_buf_size) - break; - else - ch=in_buf[nReadedBytes]; - nReadedBytes++; - - if (nDecodedBytesv2)?v1:v2; +} +//---------------------------------------------------------------------------- +template +s32 strlen(T* str) +{ int len = 0; + while(true) + { if (*(str+len)==0) + break; + len++; + } + return len; +} +//---------------------------------------------------------------------------- +template +T* strcpy (T* src, T* dst) +{ if (src&&dst) + { s32 len = strlen(src); + for (s32 i=0; i +T* strcpy (T* src, T* dst, s32 startPos, s32 endPos) +{ if (src&&dst) + { s32 len = strlen(src); + + s32 charIndex=0; + for (s32 i=startPos; i<=endPos && endPos +s32 findLast(T* Str, c8 ch) +{ + s32 lenSrc = strlen(Str); + s32 n=lenSrc-1; + s32 lastCharInStringPos = -1; + while(true) + { if (Str[n] == ch) + { lastCharInStringPos = n; + break; + } + if (n==0) break; + n--; + } + return lastCharInStringPos; +} +//---------------------------------------------------------------------------- +template +s32 findLastDelimiter(T* Str) +{ + s32 lenSrc = strlen(Str); + s32 n=lenSrc-1; + s32 lastDelimiterInStringPos = -1; + while(true) + { if (Str[n] == '\\' || Str[n] == '/') + { lastDelimiterInStringPos = n; + break; + } + if (n==0) break; + n--; + } + return lastDelimiterInStringPos; +} +//---------------------------------------------------------------------------- +template +T* extractFilePath(T* sourceStr, T* buffer, s32 bufSize) +{ + s32 lastDelimiterInStringPos = findLastDelimiter(sourceStr); + + if (lastDelimiterInStringPos>=0 && lastDelimiterInStringPos +T* extractFileName(T* sourceStr, T* buffer, s32 bufSize) +{ s32 lastDelimiterInStringPos = findLastDelimiter(sourceStr); + s32 lenSrc = strlen(sourceStr); + + if (lastDelimiterInStringPos>=-1 && (lenSrc-lastDelimiterInStringPos) 128, or EOD, or non-match. +// return values: LIMIT, EOD_FOUND, NON_MATCH +// Prior to ANY return, it writes out the 2 byte compressed code. +// If a NON_MATCH was found, this returns with the non-matching char +// residing in tmpbuf[0]. +// Inputs: tmpbuf[0], input file +// Outputs: tmpbuf[0] (sometimes), output file, and return code +//------------------------------------------------------------------ +unsigned long process_comp( + unsigned char *buf, int buf_size, + unsigned char *out_buf, int out_buf_size) +{ + // we start out with 3 repeating bytes + register int len = 3; + + unsigned char ch; + + // we're starting a repeating chunk - end the non-repeaters + flush_outbuf(out_buf, out_buf_size); + + + while (get_byte(&ch, buf, buf_size, out_buf, out_buf_size) != (int)EOD) + { + if (ch != tmpbuf[1]) + { + // send no. of repeated bytes to be encoded + put_byte((unsigned char)((--len) | 0x80), out_buf, out_buf_size); + // send the byte's value being repeated + put_byte((unsigned char)tmpbuf[1], out_buf, out_buf_size); + /* save the non-matching character just read */ + tmpbuf[1]=(unsigned char) ch; + return NON_MATCH; + } + /* we know the new byte is part of the repeating seq */ + len++; + if (len == 128) + { + // send no. of repeated bytes to be encoded + put_byte((unsigned char)((--len) | 0x80), out_buf, out_buf_size); + // send the byte's value being repeated + put_byte((unsigned char)tmpbuf[1], out_buf, out_buf_size); + return LIMIT; + } + } // end while + + // if flow comes here, we just read an EOD + // send no. of repeated bytes to be encoded + put_byte((unsigned char)((--len) | 0x80), out_buf, out_buf_size); + // send the byte's value being repeated + put_byte((unsigned char)tmpbuf[1], out_buf, out_buf_size); + return EOD_FOUND; +} + + +//---------------------------------------------------------------- +// This adds 1 non-repeating byte to outbuf. If outbuf becomes full +// with 128 bytes, it flushes outbuf. +// There are no return codes and no bytes are read from the input. +//---------------------------------------------------------------- +void process_uncomp( + unsigned char char1, unsigned char *out_buf, int out_buf_size + ) +{ + outbuf[outbuf_cnt++] = char1; + if (outbuf_cnt == 128) + flush_outbuf(out_buf, out_buf_size); +} +//----------------------------------------------------------- +// This flushes any non-compressed data not yet sent. +// On exit, outbuf_cnt will equal zero. +//----------------------------------------------------------- +void flush_outbuf(unsigned char *out_buf, int out_buf_size) +{ + register int pos=0; + + if(!outbuf_cnt) + return; // nothing to do */ + + // send no. of unencoded bytes to be sent + put_byte((unsigned char)(outbuf_cnt - 1), out_buf, out_buf_size); + + for ( ; outbuf_cnt; outbuf_cnt--) + put_byte((unsigned char)outbuf[pos++], out_buf, out_buf_size); +} +//--------------------------------------------------- +void put_byte(unsigned char ch, unsigned char *out_buf, int out_buf_size) +{ + if (nCodedBytes<=(out_buf_size-1)) + { out_buf[nCodedBytes++]=ch; + out_buf[nCodedBytes]=0; + } +} +//--------------------------------------------------- +// This reads the next byte into ch. It returns EOD +// at end-of-data +//--------------------------------------------------- +unsigned long get_byte( + unsigned char *ch, + unsigned char *in_buf, int in_buf_size, + unsigned char *out_buf, int out_buf_size + ) +{ + if (nReadedBytes>=in_buf_size) + { + // there are either 0, 1, or 2 char's to write before we quit + if (tmpbuf_cnt == 1) + process_uncomp(tmpbuf[1], out_buf, out_buf_size); + else + { + if (tmpbuf_cnt == 2) + { + process_uncomp(tmpbuf[1], out_buf, out_buf_size); + process_uncomp(tmpbuf[2], out_buf, out_buf_size); + } + } + nReadedBytes =0; + + return EOD; + } + + (*ch) = (unsigned char)in_buf[nReadedBytes++]; + + return 0; +} +//----------------------------------------------------------- +int rle_decode ( + unsigned char *in_buf, int in_buf_size, + unsigned char *out_buf, int out_buf_size + ) +{ + nDecodedBytes=0; + nReadedBytes=0; + + int ch, i; + while (1) + { + + if (nReadedBytes>=in_buf_size) + break; + else + ch=in_buf[nReadedBytes]; + nReadedBytes++; + + if (ch > 127) + { + i = ch - 127; // i is the number of repetitions + // get the byte to be repeated + if (nReadedBytes>=in_buf_size) + break; + else + ch=in_buf[nReadedBytes]; + nReadedBytes++; + + // uncompress a chunk + for ( ; i ; i--) + { + if (nDecodedBytes=in_buf_size) + break; + else + ch=in_buf[nReadedBytes]; + nReadedBytes++; + + if (nDecodedBytesgrab(); - - if (FileSystem) - FileSystem->grab(); -} - - - -CMY3DMeshFileLoader::~CMY3DMeshFileLoader() -{ - if (Mesh) - Mesh->drop(); - - if (Driver) - Driver->drop(); - - if (FileSystem) - FileSystem->drop(); -} - - - -bool CMY3DMeshFileLoader::isALoadableFileExtension(const c8* filename) -{ - return strstr(filename, ".my3d") != 0; -} - - -IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file) -{ - MaterialEntry.clear(); - MeshBufferEntry.clear(); - ChildNodes.clear(); - - core::stringc file_name = file->getFileName(); - - // working directory (from wich we loading the scene) - c8 WorkDir[1024]; - core::extractFilePath((c8*)file_name.c_str(), (c8*)WorkDir, 1024); - - core::stringc msg=""; - - //msg="Loading 3d data from "; - //msg.append(file_name); - //os::Printer::log(msg.c_str(), ELL_INFORMATION); - - // read file into memory - u16 id; - c8 name[256]; - - SMyFileHeader fileHeader; - file->read(&fileHeader, sizeof(SMyFileHeader)); - - if (fileHeader.MyId!=MY_ID || fileHeader.Ver!=MY_VER) - { - os::Printer::log("Bad MY3D file header, loading failed!", ELL_ERROR); - return 0; - } - - file->read(&id, sizeof(id)); - - if (id!=MY_SCENE_HEADER_ID) - { - os::Printer::log("Can not find MY_SCENE_HEADER_ID, loading failed!", ELL_ERROR); - return 0; - } - - SMySceneHeader sceneHeader; - file->read(&sceneHeader, sizeof(SMySceneHeader)); - - SceneBackgrColor = video::SColor( - sceneHeader.BackgrColor.R, sceneHeader.BackgrColor.G, - sceneHeader.BackgrColor.B, sceneHeader.BackgrColor.A); - - SceneAmbientColor = video::SColor( - sceneHeader.AmbientColor.R, sceneHeader.AmbientColor.G, - sceneHeader.AmbientColor.B, sceneHeader.AmbientColor.A); - - file->read(&id, sizeof(id)); - - if (id!=MY_MAT_LIST_ID) - { - os::Printer::log("Can not find MY_MAT_LIST_ID, loading failed!", ELL_ERROR); - return 0; - } - - - // loading materials and textures - //c8 ch[255]; - //sprintf(ch, "Loading materials (%d to go) and textures...", sceneHeader.MaterialCount); - //os::Printer::log(ch, ELL_INFORMATION); - - core::stringc texturePath = - SceneManager->getParameters()->getAttributeAsString(MY3D_TEXTURE_PATH); - - s32 texCount=0, ligCount=0, matCount=0; - - file->read(&id, sizeof(id)); - - int m; - for (m=0; mread(&materialHeader, sizeof(SMyMaterialHeader)); - me.Header = materialHeader; - - // read next identificator - file->read(&id, sizeof(id)); - - bool GetLightMap=false, GetMainMap=false; - static int LightMapIndex=0; - - for (int t=0; tread(name, 256); - else - { - file->read(&id, sizeof(id)); - if (id!=MY_TEXDATA_HEADER_ID) - { os::Printer::log("Can not find MY_TEXDATA_HEADER_ID, loading failed!", ELL_ERROR); - return 0; - } - - SMyTexDataHeader texDataHeader; - - file->read(&texDataHeader, sizeof(SMyTexDataHeader)); - - core::strcpy(texDataHeader.Name, name); - - char LightMapName[255]; - sprintf(LightMapName,"My3D.Lightmap.%d",++LightMapIndex); - - core::stringc pixFormatStr; - if (texDataHeader.PixelFormat == MY_PIXEL_FORMAT_24) - pixFormatStr = "24bit,"; - else - if (texDataHeader.PixelFormat == MY_PIXEL_FORMAT_16) - pixFormatStr = "16bit,"; - else - { - msg="Unknown format of image data ("; - msg.append(LightMapName); - msg.append("), loading failed!"); - os::Printer::log(msg.c_str(), ELL_ERROR); - return 0; - } - - if (texDataHeader.ComprMode != MY_TEXDATA_COMPR_NONE_ID && - texDataHeader.ComprMode != MY_TEXDATA_COMPR_RLE_ID && - texDataHeader.ComprMode != MY_TEXDATA_COMPR_SIMPLE_ID ) - { - os::Printer::log("Unknown method of compression image data, loading failed!", ELL_ERROR); - return 0; - } - - - s32 num_pixels = texDataHeader.Width*texDataHeader.Height; - - void* data = 0; - - if (texDataHeader.ComprMode==MY_TEXDATA_COMPR_NONE_ID) - { - // none compressed image data - if (texDataHeader.PixelFormat == MY_PIXEL_FORMAT_24) - { - data = (void*) new SMyPixelColor24[num_pixels]; - file->read(data, sizeof(SMyPixelColor24)*num_pixels); - } - else - { - data = (void*) new SMyPixelColor16[num_pixels]; - file->read(data, sizeof(SMyPixelColor16)*num_pixels); - } - } - else - if (texDataHeader.ComprMode==MY_TEXDATA_COMPR_RLE_ID) - { - // read RLE header identificator - file->read(&id, sizeof(id)); - if (id!=MY_TEXDATA_RLE_HEADER_ID) - { - os::Printer::log("Can not find MY_TEXDATA_RLE_HEADER_ID, loading failed!", ELL_ERROR); - return 0; - } - - // read RLE header - SMyRLEHeader rleHeader; - file->read(&rleHeader, sizeof(SMyRLEHeader)); - - //allocate memory for input and output buffers - void *input_buffer = (void*) new unsigned char[rleHeader.nEncodedBytes]; - void *output_buffer = (void*) new unsigned char[rleHeader.nDecodedBytes]; - - // read encoded data - file->read(input_buffer, rleHeader.nEncodedBytes); - - // decode data - data = 0;//(void*) new unsigned char[rleHeader.nDecodedBytes]; - s32 decodedBytes = core::rle_decode( - (unsigned char*)input_buffer, rleHeader.nEncodedBytes, - (unsigned char*)output_buffer, rleHeader.nDecodedBytes); - - if (decodedBytes!=(s32)rleHeader.nDecodedBytes) - { - os::Printer::log("Error extracting data from RLE compression, loading failed!", ELL_ERROR); - return 0; - } - - // free input buffer - delete [] (unsigned char*)input_buffer; - - // here decoded data - data = output_buffer; - - } - else if (texDataHeader.ComprMode==MY_TEXDATA_COMPR_SIMPLE_ID) - { - // simple compressed image data - if (texDataHeader.PixelFormat == MY_PIXEL_FORMAT_24) - data = (void*) new SMyPixelColor24[num_pixels]; - else - data = (void*) new SMyPixelColor16[num_pixels]; - - u32 nReadedPixels =0, nToRead =0; - while (true) - { - file->read(&nToRead, sizeof(nToRead)); - - if ((s32)(nReadedPixels+nToRead)>(s32)num_pixels) break; - - if (texDataHeader.PixelFormat == MY_PIXEL_FORMAT_24) - { - SMyPixelColor24 col24; - file->read(&col24, sizeof(SMyPixelColor24)); -for (u32 p=0; pread(&col16, sizeof(SMyPixelColor16)); - for (u32 p=0; p=(s32)num_pixels) break; - } - - if ((s32)nReadedPixels!=(s32)num_pixels) - { - os::Printer::log("Image data seems to be corrupted, loading failed!", ELL_ERROR); - return 0; - } - } - - //! Creates a software image from a byte array. - video::IImage* light_img = 0; - - if (texDataHeader.PixelFormat == MY_PIXEL_FORMAT_24) - { - // 24 bit lightmap format - light_img = Driver->createImageFromData( - video::ECF_R8G8B8, - core::dimension2d(texDataHeader.Width, texDataHeader.Height), - data, true); - } - else - { - // 16 bit lightmap format - light_img = Driver->createImageFromData( - video::ECF_A1R5G5B5, - core::dimension2d(texDataHeader.Width, texDataHeader.Height), - data, true); - } - - bool oldMipMapState = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); - - me.Texture2 = Driver->addTexture(LightMapName, light_img); - ligCount++; - - Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); - - light_img->drop(); - - GetLightMap = true; - } - - core::stringc Name = name; - int pos2 = Name.findLast('.'); - core::stringc LightingMapStr = "LightingMap"; - int ls = LightingMapStr.size(); - core::stringc sub = Name.subString((s32)core::fmax((f32)0, (f32)(pos2 - ls)), ls); - core::stringc texFName; - - if ((sub == LightingMapStr || (Name[pos2-1]=='m' && - Name[pos2-2]=='l' && Name[pos2-3]=='_')) && - !GetLightMap) - { - bool oldMipMapState = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); - - texFName = texturePath.size() ? texturePath : WorkDir; - texFName.append("Lightmaps/"); - texFName.append(Name); - me.Texture2FileName = texFName; - - if (Name.size()>0) - { - me.Texture2 = Driver->getTexture(texFName.c_str()); - ligCount++; - } - - GetLightMap = true; - - me.MaterialType = video::EMT_LIGHTMAP_M2; - - Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); - } - else - if (!GetLightMap&&GetMainMap) - { - texFName = texturePath.size() ? texturePath : WorkDir; - texFName.append(Name); - me.Texture2FileName = texFName; - - if (Name.size()>0) - { - me.Texture2 = Driver->getTexture(texFName.c_str()); - ligCount++; - } - - me.MaterialType = video::EMT_REFLECTION_2_LAYER; - } - else - if (!GetMainMap && !GetLightMap ) - { - texFName = WorkDir; - texFName.append(Name); - me.Texture1FileName = texFName; - if (Name.size()>0) - { - me.Texture1 = Driver->getTexture(texFName.c_str()); - texCount++; - } - - GetMainMap = true; - me.MaterialType = video::EMT_SOLID; - } - else - if (GetLightMap) - { - me.MaterialType = video::EMT_LIGHTMAP_M2; - } - - file->read(&id, sizeof(id)); - } - - // override materials types from they names - - if (me.Header.Name[0] =='A' && - me.Header.Name[1] =='l' && - me.Header.Name[2] =='p' && - me.Header.Name[3] =='h' && - me.Header.Name[4] =='a' && - me.Header.Name[5] =='C' && - me.Header.Name[6] =='h' && - me.Header.Name[7] =='a' && - me.Header.Name[8] =='n' && - me.Header.Name[9] =='n' && - me.Header.Name[10]=='e' && - me.Header.Name[11]=='l' && - me.Header.Name[12]=='-' - ) - { - me.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - } - else - if (me.Header.Name[0] =='S' && - me.Header.Name[1] =='p' && - me.Header.Name[2] =='h' && - me.Header.Name[3] =='e' && - me.Header.Name[4] =='r' && - me.Header.Name[5] =='e' && - me.Header.Name[6] =='M' && - me.Header.Name[7] =='a' && - me.Header.Name[8] =='p' && - me.Header.Name[9] =='-' - ) - { - me.MaterialType = video::EMT_SPHERE_MAP; - } - - MaterialEntry.push_back(me); - } - - // loading meshes - - //sprintf(ch, " Loaded: materials (%d), textures (%d), lightmaps (%d).", matCount, texCount, ligCount); - // os::Printer::log(ch, ELL_INFORMATION); - - if (Mesh) - Mesh->drop(); - - Mesh = new SMesh(); - - //sprintf(ch, "Loading meshes (%d to go) ...", sceneHeader.MeshCount); - //os::Printer::log(ch, ELL_INFORMATION); - - if (id!=MY_MESH_LIST_ID) - { - os::Printer::log("Can not find MY_MESH_LIST_ID, loading failed!", ELL_ERROR); - return 0; - } - - file->read(&id, sizeof(id)); - - for (s32 mesh_id=0; mesh_idread(&meshHeader, sizeof(SMyMeshHeader)); - - core::array Vertex; - core::array Face; - core::array TVertex1, TVertex2; - core::array TFace1, TFace2; - - s32 vertsNum=0; - s32 facesNum=0; - - // verticies - file->read(&id, sizeof(id)); - if (id!=MY_VERTS_ID) - { - os::Printer::log("Can not find MY_VERTS_ID, loading failed!", ELL_ERROR); - return 0; - } - - file->read(&vertsNum, sizeof(vertsNum)); - Vertex.reallocate(vertsNum); - file->read(Vertex.pointer(), sizeof(SMyVertex)*vertsNum); - Vertex.set_used(vertsNum); - - // faces - file->read(&id, sizeof(id)); - if (id!=MY_FACES_ID) - { - os::Printer::log("Can not find MY_FACES_ID, loading failed!", ELL_ERROR); - return 0; - } - - file->read(&facesNum, sizeof(facesNum)); - Face.reallocate(facesNum); - file->read(Face.pointer(), sizeof(SMyFace)*facesNum); - Face.set_used(facesNum); - - // reading texture channels - for (s32 tex=0; tex<(s32)meshHeader.TChannelCnt; tex++) - { - // Max 2 texture channels allowed (but in format .my3d can be more) - s32 tVertsNum=0, tFacesNum=0; - - // reading texture coords - file->read(&id, sizeof(id)); - - if (id!=MY_TVERTS_ID) - { msg="Can not find MY_TVERTS_ID ("; - msg.append(tex); - msg.append("texture channel), loading failed!"); - os::Printer::log(msg.c_str(), ELL_ERROR); - return 0; - } - - file->read(&tVertsNum, sizeof(tVertsNum)); - - if (tex==0) - { - // 1st texture channel - TVertex1.reallocate(tVertsNum); - file->read(TVertex1.pointer(), sizeof(SMyTVertex)*tVertsNum); - TVertex1.set_used(tVertsNum); - } - else - if (tex==1) - { - // 2nd texture channel - TVertex2.reallocate(tVertsNum); - file->read(TVertex2.pointer(), sizeof(SMyTVertex)*tVertsNum); - TVertex2.set_used(tVertsNum); - } - else - { - // skip other texture channels - u32 pos = file->getPos(); - file->seek(pos+sizeof(SMyTVertex)*tVertsNum); - } - - // reading texture faces - file->read(&id, sizeof(id)); - - if (id!=MY_TFACES_ID) - { msg="Can not find MY_TFACES_ID ("; - msg.append(tex); - msg.append("texture channel), loading failed!"); - os::Printer::log(msg.c_str(), ELL_ERROR); - return 0; - } - - file->read(&tFacesNum, sizeof(tFacesNum)); - - if (tex==0) - { - // 1st texture channel - TFace1.reallocate(tFacesNum); - file->read(TFace1.pointer(), sizeof(SMyFace)*tFacesNum); - TFace1.set_used(tFacesNum); - } - else if (tex==1) - { - // 2nd texture channel - TFace2.reallocate(tFacesNum); - file->read(TFace2.pointer(), sizeof(SMyFace)*tFacesNum); - TFace2.set_used(tFacesNum); - } - else - { - // skip other texture channels - u32 pos = file->getPos(); - file->seek(pos+sizeof(SMyFace)*tFacesNum); - } - } - - // trying to find material - - SMyMaterialEntry* matEnt = getMaterialEntryByIndex(meshHeader.MatIndex); - - // creating geometry for the mesh - - // trying to find mesh buffer for this material - SMeshBufferLightMap* buffer = getMeshBufferByMaterialIndex(meshHeader.MatIndex); - - if (!buffer || - (buffer->Vertices.size()+vertsNum) > Driver->getMaximalPrimitiveCount()) - { - // creating new mesh buffer for this material - buffer = new scene::SMeshBufferLightMap(); - - buffer->Material.MaterialType = video::EMT_LIGHTMAP_M2; // EMT_LIGHTMAP_M4 also possible - buffer->Material.Wireframe = false; - buffer->Material.Lighting = false; - buffer->Material.BilinearFilter = true; - - if (matEnt) - { - buffer->Material.MaterialType = matEnt->MaterialType; - - if (buffer->Material.MaterialType == video::EMT_REFLECTION_2_LAYER) - { - buffer->Material.Lighting = true; - buffer->Material.Textures[1] = matEnt->Texture1; - buffer->Material.Textures[0] = matEnt->Texture2; - } - else - { - buffer->Material.Textures[0] = matEnt->Texture1; - buffer->Material.Textures[1] = matEnt->Texture2; - } - - if (buffer->Material.MaterialType == video::EMT_TRANSPARENT_ALPHA_CHANNEL) - { - buffer->Material.BackfaceCulling = true; - buffer->Material.Lighting = true; - } - else - if (buffer->Material.MaterialType == video::EMT_SPHERE_MAP) - { - buffer->Material.Lighting = true; - } - - buffer->Material.AmbientColor = video::SColor( - matEnt->Header.AmbientColor.A, matEnt->Header.AmbientColor.R, - matEnt->Header.AmbientColor.G, matEnt->Header.AmbientColor.B - ); - buffer->Material.DiffuseColor = video::SColor( - matEnt->Header.DiffuseColor.A, matEnt->Header.DiffuseColor.R, - matEnt->Header.DiffuseColor.G, matEnt->Header.DiffuseColor.B - ); - buffer->Material.EmissiveColor = video::SColor( - matEnt->Header.EmissiveColor.A, matEnt->Header.EmissiveColor.R, - matEnt->Header.EmissiveColor.G, matEnt->Header.EmissiveColor.B - ); - buffer->Material.SpecularColor = video::SColor( - matEnt->Header.SpecularColor.A, matEnt->Header.SpecularColor.R, - matEnt->Header.SpecularColor.G, matEnt->Header.SpecularColor.B - ); - } - else - { - buffer->Material.Textures[0] = 0; - buffer->Material.Textures[1] = 0; - - buffer->Material.AmbientColor = video::SColor(255, 255, 255, 255); - buffer->Material.DiffuseColor = video::SColor(255, 255, 255, 255); - buffer->Material.EmissiveColor = video::SColor(0, 0, 0, 0); - buffer->Material.SpecularColor = video::SColor(0, 0, 0, 0); - } - - if (matEnt && matEnt->Header.Transparency!=0) - { - if (buffer->Material.MaterialType == video::EMT_REFLECTION_2_LAYER ) - { - buffer->Material.MaterialType = video::EMT_TRANSPARENT_REFLECTION_2_LAYER; - buffer->Material.Lighting = true; - buffer->Material.BackfaceCulling = true; - } - else - { - buffer->Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - buffer->Material.Lighting = false; - buffer->Material.BackfaceCulling = false; - } - } - else if ( - !buffer->Material.Textures[1] && - buffer->Material.MaterialType != video::EMT_TRANSPARENT_ALPHA_CHANNEL && - buffer->Material.MaterialType != video::EMT_SPHERE_MAP - ) - { - buffer->Material.MaterialType = video::EMT_SOLID; - buffer->Material.Lighting = true; - } - - MeshBufferEntry.push_back( - SMyMeshBufferEntry(meshHeader.MatIndex, buffer)); - } - - video::S3DVertex2TCoords VertexA, VertexB, VertexC; - video::SColor vert_color; - core::triangle3df face; - - for (int f=0; fMaterial.MaterialType == video::EMT_TRANSPARENT_VERTEX_ALPHA || - buffer->Material.MaterialType == video::EMT_TRANSPARENT_REFLECTION_2_LAYER)) - { - video::SColor color( - matEnt->Header.DiffuseColor.A, matEnt->Header.DiffuseColor.R, - matEnt->Header.DiffuseColor.G, matEnt->Header.DiffuseColor.B); - - vert_color = color.getInterpolated(video::SColor(0,0,0,0), - 1-matEnt->Header.Transparency); - } - else - { - vert_color = buffer->Material.DiffuseColor; - } - - VertexA.Color = VertexB.Color = VertexC.Color = vert_color; - - // vertex A - - VertexA.Pos.X = Vertex[Face[f].C].Coord.X; - VertexA.Pos.Y = Vertex[Face[f].C].Coord.Y; - VertexA.Pos.Z = Vertex[Face[f].C].Coord.Z; - - VertexA.Normal.X = Vertex[Face[f].C].Normal.X; - VertexA.Normal.Y = Vertex[Face[f].C].Normal.Y; - VertexA.Normal.Z = Vertex[Face[f].C].Normal.Z; - - if (meshHeader.TChannelCnt>0) - { - VertexA.TCoords.X = TVertex1[TFace1[f].C].TCoord.X; - VertexA.TCoords.Y = TVertex1[TFace1[f].C].TCoord.Y; - } - - if (meshHeader.TChannelCnt>1) - { - VertexA.TCoords2.X = TVertex2[TFace2[f].C].TCoord.X; - VertexA.TCoords2.Y = TVertex2[TFace2[f].C].TCoord.Y; - } - - // vertex B - - VertexB.Pos.X = Vertex[Face[f].B].Coord.X; - VertexB.Pos.Y = Vertex[Face[f].B].Coord.Y; - VertexB.Pos.Z = Vertex[Face[f].B].Coord.Z; - - VertexB.Normal.X = Vertex[Face[f].B].Normal.X; - VertexB.Normal.Y = Vertex[Face[f].B].Normal.Y; - VertexB.Normal.Z = Vertex[Face[f].B].Normal.Z; - - if (meshHeader.TChannelCnt>0) - { - VertexB.TCoords.X = TVertex1[TFace1[f].B].TCoord.X; - VertexB.TCoords.Y = TVertex1[TFace1[f].B].TCoord.Y; - } - - if (meshHeader.TChannelCnt>1) - { - VertexB.TCoords2.X = TVertex2[TFace2[f].B].TCoord.X; - VertexB.TCoords2.Y = TVertex2[TFace2[f].B].TCoord.Y; - } - - // vertex C - - VertexC.Pos.X = Vertex[Face[f].A].Coord.X; - VertexC.Pos.Y = Vertex[Face[f].A].Coord.Y; - VertexC.Pos.Z = Vertex[Face[f].A].Coord.Z; - - VertexC.Normal.X = Vertex[Face[f].A].Normal.X; - VertexC.Normal.Y = Vertex[Face[f].A].Normal.Y; - VertexC.Normal.Z = Vertex[Face[f].A].Normal.Z; - - if (meshHeader.TChannelCnt>0) - { - VertexC.TCoords.X = TVertex1[TFace1[f].A].TCoord.X; - VertexC.TCoords.Y = TVertex1[TFace1[f].A].TCoord.Y; - } - if (meshHeader.TChannelCnt>1) - { - VertexC.TCoords2.X = TVertex2[TFace2[f].A].TCoord.X; - VertexC.TCoords2.Y = TVertex2[TFace2[f].A].TCoord.Y; - } - - // store 3d data in mesh buffer - - buffer->Indices.push_back(buffer->Vertices.size()); - buffer->Vertices.push_back(VertexA); - - buffer->Indices.push_back(buffer->Vertices.size()); - buffer->Vertices.push_back(VertexB); - - buffer->Indices.push_back(buffer->Vertices.size()); - buffer->Vertices.push_back(VertexC); - - //***************************************************************** - // !!!!!! W A R N I N G !!!!!!! - //***************************************************************** - // For materials with alpha channel we duplicate all faces. - // This has be done for proper lighting calculation of the back faces. - // So you must remember this while you creating your models !!!!! - //***************************************************************** - // !!!!!! W A R N I N G !!!!!!! - //***************************************************************** - - if (buffer->Material.MaterialType == video::EMT_TRANSPARENT_ALPHA_CHANNEL) - { - VertexA.Normal = core::vector3df(-VertexA.Normal.X, -VertexA.Normal.Y, -VertexA.Normal.Z); - VertexB.Normal = core::vector3df(-VertexB.Normal.X, -VertexB.Normal.Y, -VertexB.Normal.Z); - VertexC.Normal = core::vector3df(-VertexC.Normal.X, -VertexC.Normal.Y, -VertexC.Normal.Z); - - buffer->Indices.push_back(buffer->Vertices.size()); - buffer->Vertices.push_back(VertexC); - - buffer->Indices.push_back(buffer->Vertices.size()); - buffer->Vertices.push_back(VertexB); - - buffer->Indices.push_back(buffer->Vertices.size()); - buffer->Vertices.push_back(VertexA); - } - } - file->read(&id, sizeof(id)); - } - - // creating mesh - - for (m=0; m<(s32)MeshBufferEntry.size(); m++) - { - SMeshBufferLightMap* buffer = MeshBufferEntry[m].MeshBuffer; - - if (!buffer) - continue; - - Mesh->addMeshBuffer(buffer); - - buffer->recalculateBoundingBox(); - buffer->drop(); - } - - Mesh->recalculateBoundingBox(); - - //sprintf(ch, "Loaded: meshes (%d).", MeshBufferEntry.size()); - //os::Printer::log(ch, ELL_INFORMATION); - - if (id != MY_FILE_END_ID) - os::Printer::log("Loading finished, but can not find MY_FILE_END_ID token.", ELL_WARNING); - - SAnimatedMesh* am = new SAnimatedMesh(); - - // you have to add this type in IAnimatedMesh.h - //am->Type = EAMT_MY3D; - - am->addMesh(Mesh); - am->recalculateBoundingBox(); - - Mesh->drop(); - Mesh = 0; - - //msg="3D data successfully loaded from "; - //msg.append(file_name); - //os::Printer::log(msg.c_str(), ELL_INFORMATION); - - return am; -} - - -CMY3DMeshFileLoader::SMyMaterialEntry* CMY3DMeshFileLoader::getMaterialEntryByIndex(u32 matInd) -{ - for (int m=0; m<(s32)MaterialEntry.size(); m++) - if (MaterialEntry[m].Header.Index == matInd) - return &MaterialEntry[m]; - - return NULL; -} - - - -SMeshBufferLightMap* CMY3DMeshFileLoader::getMeshBufferByMaterialIndex(u32 matInd) -{ - for (int m=0; m<(s32)MeshBufferEntry.size(); m++) - { - if (MeshBufferEntry[m].MaterialIndex == (s32)matInd) - return MeshBufferEntry[m].MeshBuffer; - } - return NULL; -} - - - -core::array& CMY3DMeshFileLoader::getChildNodes() -{ - return ChildNodes; -} - - -} // end namespace scnene -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// +// This file was originally written by ZDimitor. + +//-------------------------------------------------------------------------------- +// This tool created by ZDimitor everyone can use it as wants +//-------------------------------------------------------------------------------- + +#include "CMY3DMeshFileLoader.h" + +#include "SAnimatedMesh.h" +#include "SMeshBuffer.h" +#include "IAttributes.h" + + +#include "CMY3DStuff.h" +#include "CMY3DHelper.h" +#include "os.h" + +// v3.15 - May 16, 2005 + +namespace irr +{ +namespace scene +{ + + +CMY3DMeshFileLoader::CMY3DMeshFileLoader( + io::IFileSystem* fs, video::IVideoDriver* driver, ISceneManager *scmgr) + : Mesh(0), Driver(driver), FileSystem(fs), SceneManager(scmgr) +{ + if (Driver) + Driver->grab(); + + if (FileSystem) + FileSystem->grab(); +} + + + +CMY3DMeshFileLoader::~CMY3DMeshFileLoader() +{ + if (Mesh) + Mesh->drop(); + + if (Driver) + Driver->drop(); + + if (FileSystem) + FileSystem->drop(); +} + + + +bool CMY3DMeshFileLoader::isALoadableFileExtension(const c8* filename) +{ + return strstr(filename, ".my3d") != 0; +} + + +IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file) +{ + MaterialEntry.clear(); + MeshBufferEntry.clear(); + ChildNodes.clear(); + + core::stringc file_name = file->getFileName(); + + // working directory (from wich we loading the scene) + c8 WorkDir[1024]; + core::extractFilePath((c8*)file_name.c_str(), (c8*)WorkDir, 1024); + + core::stringc msg=""; + + //msg="Loading 3d data from "; + //msg.append(file_name); + //os::Printer::log(msg.c_str(), ELL_INFORMATION); + + // read file into memory + u16 id; + c8 name[256]; + + SMyFileHeader fileHeader; + file->read(&fileHeader, sizeof(SMyFileHeader)); + + if (fileHeader.MyId!=MY_ID || fileHeader.Ver!=MY_VER) + { + os::Printer::log("Bad MY3D file header, loading failed!", ELL_ERROR); + return 0; + } + + file->read(&id, sizeof(id)); + + if (id!=MY_SCENE_HEADER_ID) + { + os::Printer::log("Can not find MY_SCENE_HEADER_ID, loading failed!", ELL_ERROR); + return 0; + } + + SMySceneHeader sceneHeader; + file->read(&sceneHeader, sizeof(SMySceneHeader)); + + SceneBackgrColor = video::SColor( + sceneHeader.BackgrColor.R, sceneHeader.BackgrColor.G, + sceneHeader.BackgrColor.B, sceneHeader.BackgrColor.A); + + SceneAmbientColor = video::SColor( + sceneHeader.AmbientColor.R, sceneHeader.AmbientColor.G, + sceneHeader.AmbientColor.B, sceneHeader.AmbientColor.A); + + file->read(&id, sizeof(id)); + + if (id!=MY_MAT_LIST_ID) + { + os::Printer::log("Can not find MY_MAT_LIST_ID, loading failed!", ELL_ERROR); + return 0; + } + + + // loading materials and textures + //c8 ch[255]; + //sprintf(ch, "Loading materials (%d to go) and textures...", sceneHeader.MaterialCount); + //os::Printer::log(ch, ELL_INFORMATION); + + core::stringc texturePath = + SceneManager->getParameters()->getAttributeAsString(MY3D_TEXTURE_PATH); + + s32 texCount=0, ligCount=0, matCount=0; + + file->read(&id, sizeof(id)); + + int m; + for (m=0; mread(&materialHeader, sizeof(SMyMaterialHeader)); + me.Header = materialHeader; + + // read next identificator + file->read(&id, sizeof(id)); + + bool GetLightMap=false, GetMainMap=false; + static int LightMapIndex=0; + + for (int t=0; tread(name, 256); + else + { + file->read(&id, sizeof(id)); + if (id!=MY_TEXDATA_HEADER_ID) + { os::Printer::log("Can not find MY_TEXDATA_HEADER_ID, loading failed!", ELL_ERROR); + return 0; + } + + SMyTexDataHeader texDataHeader; + + file->read(&texDataHeader, sizeof(SMyTexDataHeader)); + + core::strcpy(texDataHeader.Name, name); + + char LightMapName[255]; + sprintf(LightMapName,"My3D.Lightmap.%d",++LightMapIndex); + + core::stringc pixFormatStr; + if (texDataHeader.PixelFormat == MY_PIXEL_FORMAT_24) + pixFormatStr = "24bit,"; + else + if (texDataHeader.PixelFormat == MY_PIXEL_FORMAT_16) + pixFormatStr = "16bit,"; + else + { + msg="Unknown format of image data ("; + msg.append(LightMapName); + msg.append("), loading failed!"); + os::Printer::log(msg.c_str(), ELL_ERROR); + return 0; + } + + if (texDataHeader.ComprMode != MY_TEXDATA_COMPR_NONE_ID && + texDataHeader.ComprMode != MY_TEXDATA_COMPR_RLE_ID && + texDataHeader.ComprMode != MY_TEXDATA_COMPR_SIMPLE_ID ) + { + os::Printer::log("Unknown method of compression image data, loading failed!", ELL_ERROR); + return 0; + } + + + s32 num_pixels = texDataHeader.Width*texDataHeader.Height; + + void* data = 0; + + if (texDataHeader.ComprMode==MY_TEXDATA_COMPR_NONE_ID) + { + // none compressed image data + if (texDataHeader.PixelFormat == MY_PIXEL_FORMAT_24) + { + data = (void*) new SMyPixelColor24[num_pixels]; + file->read(data, sizeof(SMyPixelColor24)*num_pixels); + } + else + { + data = (void*) new SMyPixelColor16[num_pixels]; + file->read(data, sizeof(SMyPixelColor16)*num_pixels); + } + } + else + if (texDataHeader.ComprMode==MY_TEXDATA_COMPR_RLE_ID) + { + // read RLE header identificator + file->read(&id, sizeof(id)); + if (id!=MY_TEXDATA_RLE_HEADER_ID) + { + os::Printer::log("Can not find MY_TEXDATA_RLE_HEADER_ID, loading failed!", ELL_ERROR); + return 0; + } + + // read RLE header + SMyRLEHeader rleHeader; + file->read(&rleHeader, sizeof(SMyRLEHeader)); + + //allocate memory for input and output buffers + void *input_buffer = (void*) new unsigned char[rleHeader.nEncodedBytes]; + void *output_buffer = (void*) new unsigned char[rleHeader.nDecodedBytes]; + + // read encoded data + file->read(input_buffer, rleHeader.nEncodedBytes); + + // decode data + data = 0;//(void*) new unsigned char[rleHeader.nDecodedBytes]; + s32 decodedBytes = core::rle_decode( + (unsigned char*)input_buffer, rleHeader.nEncodedBytes, + (unsigned char*)output_buffer, rleHeader.nDecodedBytes); + + if (decodedBytes!=(s32)rleHeader.nDecodedBytes) + { + os::Printer::log("Error extracting data from RLE compression, loading failed!", ELL_ERROR); + return 0; + } + + // free input buffer + delete [] (unsigned char*)input_buffer; + + // here decoded data + data = output_buffer; + + } + else if (texDataHeader.ComprMode==MY_TEXDATA_COMPR_SIMPLE_ID) + { + // simple compressed image data + if (texDataHeader.PixelFormat == MY_PIXEL_FORMAT_24) + data = (void*) new SMyPixelColor24[num_pixels]; + else + data = (void*) new SMyPixelColor16[num_pixels]; + + u32 nReadedPixels =0, nToRead =0; + while (true) + { + file->read(&nToRead, sizeof(nToRead)); + + if ((s32)(nReadedPixels+nToRead)>(s32)num_pixels) break; + + if (texDataHeader.PixelFormat == MY_PIXEL_FORMAT_24) + { + SMyPixelColor24 col24; + file->read(&col24, sizeof(SMyPixelColor24)); +for (u32 p=0; pread(&col16, sizeof(SMyPixelColor16)); + for (u32 p=0; p=(s32)num_pixels) break; + } + + if ((s32)nReadedPixels!=(s32)num_pixels) + { + os::Printer::log("Image data seems to be corrupted, loading failed!", ELL_ERROR); + return 0; + } + } + + //! Creates a software image from a byte array. + video::IImage* light_img = 0; + + if (texDataHeader.PixelFormat == MY_PIXEL_FORMAT_24) + { + // 24 bit lightmap format + light_img = Driver->createImageFromData( + video::ECF_R8G8B8, + core::dimension2d(texDataHeader.Width, texDataHeader.Height), + data, true); + } + else + { + // 16 bit lightmap format + light_img = Driver->createImageFromData( + video::ECF_A1R5G5B5, + core::dimension2d(texDataHeader.Width, texDataHeader.Height), + data, true); + } + + bool oldMipMapState = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); + Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); + + me.Texture2 = Driver->addTexture(LightMapName, light_img); + ligCount++; + + Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); + + light_img->drop(); + + GetLightMap = true; + } + + core::stringc Name = name; + int pos2 = Name.findLast('.'); + core::stringc LightingMapStr = "LightingMap"; + int ls = LightingMapStr.size(); + core::stringc sub = Name.subString((s32)core::fmax((f32)0, (f32)(pos2 - ls)), ls); + core::stringc texFName; + + if ((sub == LightingMapStr || (Name[pos2-1]=='m' && + Name[pos2-2]=='l' && Name[pos2-3]=='_')) && + !GetLightMap) + { + bool oldMipMapState = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); + Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); + + texFName = texturePath.size() ? texturePath : WorkDir; + texFName.append("Lightmaps/"); + texFName.append(Name); + me.Texture2FileName = texFName; + + if (Name.size()>0) + { + me.Texture2 = Driver->getTexture(texFName.c_str()); + ligCount++; + } + + GetLightMap = true; + + me.MaterialType = video::EMT_LIGHTMAP_M2; + + Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); + } + else + if (!GetLightMap&&GetMainMap) + { + texFName = texturePath.size() ? texturePath : WorkDir; + texFName.append(Name); + me.Texture2FileName = texFName; + + if (Name.size()>0) + { + me.Texture2 = Driver->getTexture(texFName.c_str()); + ligCount++; + } + + me.MaterialType = video::EMT_REFLECTION_2_LAYER; + } + else + if (!GetMainMap && !GetLightMap ) + { + texFName = WorkDir; + texFName.append(Name); + me.Texture1FileName = texFName; + if (Name.size()>0) + { + me.Texture1 = Driver->getTexture(texFName.c_str()); + texCount++; + } + + GetMainMap = true; + me.MaterialType = video::EMT_SOLID; + } + else + if (GetLightMap) + { + me.MaterialType = video::EMT_LIGHTMAP_M2; + } + + file->read(&id, sizeof(id)); + } + + // override materials types from they names + + if (me.Header.Name[0] =='A' && + me.Header.Name[1] =='l' && + me.Header.Name[2] =='p' && + me.Header.Name[3] =='h' && + me.Header.Name[4] =='a' && + me.Header.Name[5] =='C' && + me.Header.Name[6] =='h' && + me.Header.Name[7] =='a' && + me.Header.Name[8] =='n' && + me.Header.Name[9] =='n' && + me.Header.Name[10]=='e' && + me.Header.Name[11]=='l' && + me.Header.Name[12]=='-' + ) + { + me.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; + } + else + if (me.Header.Name[0] =='S' && + me.Header.Name[1] =='p' && + me.Header.Name[2] =='h' && + me.Header.Name[3] =='e' && + me.Header.Name[4] =='r' && + me.Header.Name[5] =='e' && + me.Header.Name[6] =='M' && + me.Header.Name[7] =='a' && + me.Header.Name[8] =='p' && + me.Header.Name[9] =='-' + ) + { + me.MaterialType = video::EMT_SPHERE_MAP; + } + + MaterialEntry.push_back(me); + } + + // loading meshes + + //sprintf(ch, " Loaded: materials (%d), textures (%d), lightmaps (%d).", matCount, texCount, ligCount); + // os::Printer::log(ch, ELL_INFORMATION); + + if (Mesh) + Mesh->drop(); + + Mesh = new SMesh(); + + //sprintf(ch, "Loading meshes (%d to go) ...", sceneHeader.MeshCount); + //os::Printer::log(ch, ELL_INFORMATION); + + if (id!=MY_MESH_LIST_ID) + { + os::Printer::log("Can not find MY_MESH_LIST_ID, loading failed!", ELL_ERROR); + return 0; + } + + file->read(&id, sizeof(id)); + + for (s32 mesh_id=0; mesh_idread(&meshHeader, sizeof(SMyMeshHeader)); + + core::array Vertex; + core::array Face; + core::array TVertex1, TVertex2; + core::array TFace1, TFace2; + + s32 vertsNum=0; + s32 facesNum=0; + + // verticies + file->read(&id, sizeof(id)); + if (id!=MY_VERTS_ID) + { + os::Printer::log("Can not find MY_VERTS_ID, loading failed!", ELL_ERROR); + return 0; + } + + file->read(&vertsNum, sizeof(vertsNum)); + Vertex.reallocate(vertsNum); + file->read(Vertex.pointer(), sizeof(SMyVertex)*vertsNum); + Vertex.set_used(vertsNum); + + // faces + file->read(&id, sizeof(id)); + if (id!=MY_FACES_ID) + { + os::Printer::log("Can not find MY_FACES_ID, loading failed!", ELL_ERROR); + return 0; + } + + file->read(&facesNum, sizeof(facesNum)); + Face.reallocate(facesNum); + file->read(Face.pointer(), sizeof(SMyFace)*facesNum); + Face.set_used(facesNum); + + // reading texture channels + for (s32 tex=0; tex<(s32)meshHeader.TChannelCnt; tex++) + { + // Max 2 texture channels allowed (but in format .my3d can be more) + s32 tVertsNum=0, tFacesNum=0; + + // reading texture coords + file->read(&id, sizeof(id)); + + if (id!=MY_TVERTS_ID) + { msg="Can not find MY_TVERTS_ID ("; + msg.append(tex); + msg.append("texture channel), loading failed!"); + os::Printer::log(msg.c_str(), ELL_ERROR); + return 0; + } + + file->read(&tVertsNum, sizeof(tVertsNum)); + + if (tex==0) + { + // 1st texture channel + TVertex1.reallocate(tVertsNum); + file->read(TVertex1.pointer(), sizeof(SMyTVertex)*tVertsNum); + TVertex1.set_used(tVertsNum); + } + else + if (tex==1) + { + // 2nd texture channel + TVertex2.reallocate(tVertsNum); + file->read(TVertex2.pointer(), sizeof(SMyTVertex)*tVertsNum); + TVertex2.set_used(tVertsNum); + } + else + { + // skip other texture channels + u32 pos = file->getPos(); + file->seek(pos+sizeof(SMyTVertex)*tVertsNum); + } + + // reading texture faces + file->read(&id, sizeof(id)); + + if (id!=MY_TFACES_ID) + { msg="Can not find MY_TFACES_ID ("; + msg.append(tex); + msg.append("texture channel), loading failed!"); + os::Printer::log(msg.c_str(), ELL_ERROR); + return 0; + } + + file->read(&tFacesNum, sizeof(tFacesNum)); + + if (tex==0) + { + // 1st texture channel + TFace1.reallocate(tFacesNum); + file->read(TFace1.pointer(), sizeof(SMyFace)*tFacesNum); + TFace1.set_used(tFacesNum); + } + else if (tex==1) + { + // 2nd texture channel + TFace2.reallocate(tFacesNum); + file->read(TFace2.pointer(), sizeof(SMyFace)*tFacesNum); + TFace2.set_used(tFacesNum); + } + else + { + // skip other texture channels + u32 pos = file->getPos(); + file->seek(pos+sizeof(SMyFace)*tFacesNum); + } + } + + // trying to find material + + SMyMaterialEntry* matEnt = getMaterialEntryByIndex(meshHeader.MatIndex); + + // creating geometry for the mesh + + // trying to find mesh buffer for this material + SMeshBufferLightMap* buffer = getMeshBufferByMaterialIndex(meshHeader.MatIndex); + + if (!buffer || + (buffer->Vertices.size()+vertsNum) > Driver->getMaximalPrimitiveCount()) + { + // creating new mesh buffer for this material + buffer = new scene::SMeshBufferLightMap(); + + buffer->Material.MaterialType = video::EMT_LIGHTMAP_M2; // EMT_LIGHTMAP_M4 also possible + buffer->Material.Wireframe = false; + buffer->Material.Lighting = false; + buffer->Material.BilinearFilter = true; + + if (matEnt) + { + buffer->Material.MaterialType = matEnt->MaterialType; + + if (buffer->Material.MaterialType == video::EMT_REFLECTION_2_LAYER) + { + buffer->Material.Lighting = true; + buffer->Material.Textures[1] = matEnt->Texture1; + buffer->Material.Textures[0] = matEnt->Texture2; + } + else + { + buffer->Material.Textures[0] = matEnt->Texture1; + buffer->Material.Textures[1] = matEnt->Texture2; + } + + if (buffer->Material.MaterialType == video::EMT_TRANSPARENT_ALPHA_CHANNEL) + { + buffer->Material.BackfaceCulling = true; + buffer->Material.Lighting = true; + } + else + if (buffer->Material.MaterialType == video::EMT_SPHERE_MAP) + { + buffer->Material.Lighting = true; + } + + buffer->Material.AmbientColor = video::SColor( + matEnt->Header.AmbientColor.A, matEnt->Header.AmbientColor.R, + matEnt->Header.AmbientColor.G, matEnt->Header.AmbientColor.B + ); + buffer->Material.DiffuseColor = video::SColor( + matEnt->Header.DiffuseColor.A, matEnt->Header.DiffuseColor.R, + matEnt->Header.DiffuseColor.G, matEnt->Header.DiffuseColor.B + ); + buffer->Material.EmissiveColor = video::SColor( + matEnt->Header.EmissiveColor.A, matEnt->Header.EmissiveColor.R, + matEnt->Header.EmissiveColor.G, matEnt->Header.EmissiveColor.B + ); + buffer->Material.SpecularColor = video::SColor( + matEnt->Header.SpecularColor.A, matEnt->Header.SpecularColor.R, + matEnt->Header.SpecularColor.G, matEnt->Header.SpecularColor.B + ); + } + else + { + buffer->Material.Textures[0] = 0; + buffer->Material.Textures[1] = 0; + + buffer->Material.AmbientColor = video::SColor(255, 255, 255, 255); + buffer->Material.DiffuseColor = video::SColor(255, 255, 255, 255); + buffer->Material.EmissiveColor = video::SColor(0, 0, 0, 0); + buffer->Material.SpecularColor = video::SColor(0, 0, 0, 0); + } + + if (matEnt && matEnt->Header.Transparency!=0) + { + if (buffer->Material.MaterialType == video::EMT_REFLECTION_2_LAYER ) + { + buffer->Material.MaterialType = video::EMT_TRANSPARENT_REFLECTION_2_LAYER; + buffer->Material.Lighting = true; + buffer->Material.BackfaceCulling = true; + } + else + { + buffer->Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; + buffer->Material.Lighting = false; + buffer->Material.BackfaceCulling = false; + } + } + else if ( + !buffer->Material.Textures[1] && + buffer->Material.MaterialType != video::EMT_TRANSPARENT_ALPHA_CHANNEL && + buffer->Material.MaterialType != video::EMT_SPHERE_MAP + ) + { + buffer->Material.MaterialType = video::EMT_SOLID; + buffer->Material.Lighting = true; + } + + MeshBufferEntry.push_back( + SMyMeshBufferEntry(meshHeader.MatIndex, buffer)); + } + + video::S3DVertex2TCoords VertexA, VertexB, VertexC; + video::SColor vert_color; + core::triangle3df face; + + for (int f=0; fMaterial.MaterialType == video::EMT_TRANSPARENT_VERTEX_ALPHA || + buffer->Material.MaterialType == video::EMT_TRANSPARENT_REFLECTION_2_LAYER)) + { + video::SColor color( + matEnt->Header.DiffuseColor.A, matEnt->Header.DiffuseColor.R, + matEnt->Header.DiffuseColor.G, matEnt->Header.DiffuseColor.B); + + vert_color = color.getInterpolated(video::SColor(0,0,0,0), + 1-matEnt->Header.Transparency); + } + else + { + vert_color = buffer->Material.DiffuseColor; + } + + VertexA.Color = VertexB.Color = VertexC.Color = vert_color; + + // vertex A + + VertexA.Pos.X = Vertex[Face[f].C].Coord.X; + VertexA.Pos.Y = Vertex[Face[f].C].Coord.Y; + VertexA.Pos.Z = Vertex[Face[f].C].Coord.Z; + + VertexA.Normal.X = Vertex[Face[f].C].Normal.X; + VertexA.Normal.Y = Vertex[Face[f].C].Normal.Y; + VertexA.Normal.Z = Vertex[Face[f].C].Normal.Z; + + if (meshHeader.TChannelCnt>0) + { + VertexA.TCoords.X = TVertex1[TFace1[f].C].TCoord.X; + VertexA.TCoords.Y = TVertex1[TFace1[f].C].TCoord.Y; + } + + if (meshHeader.TChannelCnt>1) + { + VertexA.TCoords2.X = TVertex2[TFace2[f].C].TCoord.X; + VertexA.TCoords2.Y = TVertex2[TFace2[f].C].TCoord.Y; + } + + // vertex B + + VertexB.Pos.X = Vertex[Face[f].B].Coord.X; + VertexB.Pos.Y = Vertex[Face[f].B].Coord.Y; + VertexB.Pos.Z = Vertex[Face[f].B].Coord.Z; + + VertexB.Normal.X = Vertex[Face[f].B].Normal.X; + VertexB.Normal.Y = Vertex[Face[f].B].Normal.Y; + VertexB.Normal.Z = Vertex[Face[f].B].Normal.Z; + + if (meshHeader.TChannelCnt>0) + { + VertexB.TCoords.X = TVertex1[TFace1[f].B].TCoord.X; + VertexB.TCoords.Y = TVertex1[TFace1[f].B].TCoord.Y; + } + + if (meshHeader.TChannelCnt>1) + { + VertexB.TCoords2.X = TVertex2[TFace2[f].B].TCoord.X; + VertexB.TCoords2.Y = TVertex2[TFace2[f].B].TCoord.Y; + } + + // vertex C + + VertexC.Pos.X = Vertex[Face[f].A].Coord.X; + VertexC.Pos.Y = Vertex[Face[f].A].Coord.Y; + VertexC.Pos.Z = Vertex[Face[f].A].Coord.Z; + + VertexC.Normal.X = Vertex[Face[f].A].Normal.X; + VertexC.Normal.Y = Vertex[Face[f].A].Normal.Y; + VertexC.Normal.Z = Vertex[Face[f].A].Normal.Z; + + if (meshHeader.TChannelCnt>0) + { + VertexC.TCoords.X = TVertex1[TFace1[f].A].TCoord.X; + VertexC.TCoords.Y = TVertex1[TFace1[f].A].TCoord.Y; + } + if (meshHeader.TChannelCnt>1) + { + VertexC.TCoords2.X = TVertex2[TFace2[f].A].TCoord.X; + VertexC.TCoords2.Y = TVertex2[TFace2[f].A].TCoord.Y; + } + + // store 3d data in mesh buffer + + buffer->Indices.push_back(buffer->Vertices.size()); + buffer->Vertices.push_back(VertexA); + + buffer->Indices.push_back(buffer->Vertices.size()); + buffer->Vertices.push_back(VertexB); + + buffer->Indices.push_back(buffer->Vertices.size()); + buffer->Vertices.push_back(VertexC); + + //***************************************************************** + // !!!!!! W A R N I N G !!!!!!! + //***************************************************************** + // For materials with alpha channel we duplicate all faces. + // This has be done for proper lighting calculation of the back faces. + // So you must remember this while you creating your models !!!!! + //***************************************************************** + // !!!!!! W A R N I N G !!!!!!! + //***************************************************************** + + if (buffer->Material.MaterialType == video::EMT_TRANSPARENT_ALPHA_CHANNEL) + { + VertexA.Normal = core::vector3df(-VertexA.Normal.X, -VertexA.Normal.Y, -VertexA.Normal.Z); + VertexB.Normal = core::vector3df(-VertexB.Normal.X, -VertexB.Normal.Y, -VertexB.Normal.Z); + VertexC.Normal = core::vector3df(-VertexC.Normal.X, -VertexC.Normal.Y, -VertexC.Normal.Z); + + buffer->Indices.push_back(buffer->Vertices.size()); + buffer->Vertices.push_back(VertexC); + + buffer->Indices.push_back(buffer->Vertices.size()); + buffer->Vertices.push_back(VertexB); + + buffer->Indices.push_back(buffer->Vertices.size()); + buffer->Vertices.push_back(VertexA); + } + } + file->read(&id, sizeof(id)); + } + + // creating mesh + + for (m=0; m<(s32)MeshBufferEntry.size(); m++) + { + SMeshBufferLightMap* buffer = MeshBufferEntry[m].MeshBuffer; + + if (!buffer) + continue; + + Mesh->addMeshBuffer(buffer); + + buffer->recalculateBoundingBox(); + buffer->drop(); + } + + Mesh->recalculateBoundingBox(); + + //sprintf(ch, "Loaded: meshes (%d).", MeshBufferEntry.size()); + //os::Printer::log(ch, ELL_INFORMATION); + + if (id != MY_FILE_END_ID) + os::Printer::log("Loading finished, but can not find MY_FILE_END_ID token.", ELL_WARNING); + + SAnimatedMesh* am = new SAnimatedMesh(); + + // you have to add this type in IAnimatedMesh.h + //am->Type = EAMT_MY3D; + + am->addMesh(Mesh); + am->recalculateBoundingBox(); + + Mesh->drop(); + Mesh = 0; + + //msg="3D data successfully loaded from "; + //msg.append(file_name); + //os::Printer::log(msg.c_str(), ELL_INFORMATION); + + return am; +} + + +CMY3DMeshFileLoader::SMyMaterialEntry* CMY3DMeshFileLoader::getMaterialEntryByIndex(u32 matInd) +{ + for (int m=0; m<(s32)MaterialEntry.size(); m++) + if (MaterialEntry[m].Header.Index == matInd) + return &MaterialEntry[m]; + + return NULL; +} + + + +SMeshBufferLightMap* CMY3DMeshFileLoader::getMeshBufferByMaterialIndex(u32 matInd) +{ + for (int m=0; m<(s32)MeshBufferEntry.size(); m++) + { + if (MeshBufferEntry[m].MaterialIndex == (s32)matInd) + return MeshBufferEntry[m].MeshBuffer; + } + return NULL; +} + + + +core::array& CMY3DMeshFileLoader::getChildNodes() +{ + return ChildNodes; +} + + +} // end namespace scnene +} // end namespace irr diff --git a/src/dep/src/irrlicht/CMY3DMeshFileLoader.h b/src/dep/src/irrlicht/CMY3DMeshFileLoader.h index aef8eb1..4805c03 100644 --- a/src/dep/src/irrlicht/CMY3DMeshFileLoader.h +++ b/src/dep/src/irrlicht/CMY3DMeshFileLoader.h @@ -1,114 +1,114 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This file was originally written by ZDimitor. -// I (Nikolaus Gebhardt) did some few changes to this: -// - replaced logging calls to their os:: counterparts -// - removed some logging calls -// - enabled image dropping of CImage again, because that bug has been fixed now -// - removed setTexture path and replaced it with the directory of the mesh -// - added EAMT_MY3D file type -// - fixed a memory leak when decompressing RLE data. -// - cleaned multi character constant problems with gcc -// - removed octree child scene node generation because irrlicht is now able to draw -// scene nodes with transparent and sold materials in them at the same time. (see changes.txt) -// Thanks a lot to ZDimitor for his work on this and that he gave me -// his permission to add it into Irrlicht. - -//-------------------------------------------------------------------------------- -// This tool created by ZDimitor everyone can use it as wants -//-------------------------------------------------------------------------------- - -#ifndef __CMY3D_MESH_FILE_LOADER_H_INCLUDED__ -#define __CMY3D_MESH_FILE_LOADER_H_INCLUDED__ - - -#ifdef _MSC_VER -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -#endif - - -#include "IMeshLoader.h" -#include "SMesh.h" -#include "SMeshBufferLightMap.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "irrString.h" -#include "ISceneManager.h" - -#include "CMY3DStuff.h" - -namespace irr -{ -namespace scene -{ - - -class CMY3DMeshFileLoader : public IMeshLoader -{ -public: - CMY3DMeshFileLoader( - io::IFileSystem* fs, video::IVideoDriver* driver, ISceneManager *scmgr); - virtual ~CMY3DMeshFileLoader(); - - virtual bool isALoadableFileExtension(const c8* fileName); - - virtual IAnimatedMesh* createMesh(io::IReadFile* file); - - //! getting access to the nodes (with transparent material), creating - //! while loading .my3d file - core::array& getChildNodes(); - -private: - - scene::SMesh* Mesh; - - video::IVideoDriver* Driver; - io::IFileSystem* FileSystem; - ISceneManager *SceneManager; - - video::SColor SceneBackgrColor; - video::SColor SceneAmbientColor; - - struct SMyMaterialEntry - { - SMyMaterialEntry () - : Texture1FileName("null"), Texture2FileName("null"), - Texture1(0), Texture2(0), MaterialType(video::EMT_SOLID) {;} - - SMyMaterialHeader Header; - core::stringc Texture1FileName; - core::stringc Texture2FileName; - video::ITexture *Texture1; - video::ITexture *Texture2; - video::E_MATERIAL_TYPE MaterialType; - }; - - struct SMyMeshBufferEntry - { - SMyMeshBufferEntry() : MaterialIndex(-1), MeshBuffer(0) {} - SMyMeshBufferEntry(s32 mi, SMeshBufferLightMap* mb) - : MaterialIndex(mi), MeshBuffer(mb) {;} - - s32 MaterialIndex; - SMeshBufferLightMap* MeshBuffer; - }; - - core::array MaterialEntry; - core::array MeshBufferEntry; - - SMyMaterialEntry* getMaterialEntryByIndex (u32 matInd); - SMeshBufferLightMap* getMeshBufferByMaterialIndex(u32 matInd); - - core::array ChildNodes; -}; - - -} // end namespace scene -} // end namespace irr - - -#endif // __CMY3D_MESH_FILE_LOADER_H_INCLUDED__ +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// +// This file was originally written by ZDimitor. +// I (Nikolaus Gebhardt) did some few changes to this: +// - replaced logging calls to their os:: counterparts +// - removed some logging calls +// - enabled image dropping of CImage again, because that bug has been fixed now +// - removed setTexture path and replaced it with the directory of the mesh +// - added EAMT_MY3D file type +// - fixed a memory leak when decompressing RLE data. +// - cleaned multi character constant problems with gcc +// - removed octree child scene node generation because irrlicht is now able to draw +// scene nodes with transparent and sold materials in them at the same time. (see changes.txt) +// Thanks a lot to ZDimitor for his work on this and that he gave me +// his permission to add it into Irrlicht. + +//-------------------------------------------------------------------------------- +// This tool created by ZDimitor everyone can use it as wants +//-------------------------------------------------------------------------------- + +#ifndef __CMY3D_MESH_FILE_LOADER_H_INCLUDED__ +#define __CMY3D_MESH_FILE_LOADER_H_INCLUDED__ + + +#ifdef _MSC_VER +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#endif + + +#include "IMeshLoader.h" +#include "SMesh.h" +#include "SMeshBufferLightMap.h" +#include "IFileSystem.h" +#include "IVideoDriver.h" +#include "irrString.h" +#include "ISceneManager.h" + +#include "CMY3DStuff.h" + +namespace irr +{ +namespace scene +{ + + +class CMY3DMeshFileLoader : public IMeshLoader +{ +public: + CMY3DMeshFileLoader( + io::IFileSystem* fs, video::IVideoDriver* driver, ISceneManager *scmgr); + virtual ~CMY3DMeshFileLoader(); + + virtual bool isALoadableFileExtension(const c8* fileName); + + virtual IAnimatedMesh* createMesh(io::IReadFile* file); + + //! getting access to the nodes (with transparent material), creating + //! while loading .my3d file + core::array& getChildNodes(); + +private: + + scene::SMesh* Mesh; + + video::IVideoDriver* Driver; + io::IFileSystem* FileSystem; + ISceneManager *SceneManager; + + video::SColor SceneBackgrColor; + video::SColor SceneAmbientColor; + + struct SMyMaterialEntry + { + SMyMaterialEntry () + : Texture1FileName("null"), Texture2FileName("null"), + Texture1(0), Texture2(0), MaterialType(video::EMT_SOLID) {;} + + SMyMaterialHeader Header; + core::stringc Texture1FileName; + core::stringc Texture2FileName; + video::ITexture *Texture1; + video::ITexture *Texture2; + video::E_MATERIAL_TYPE MaterialType; + }; + + struct SMyMeshBufferEntry + { + SMyMeshBufferEntry() : MaterialIndex(-1), MeshBuffer(0) {} + SMyMeshBufferEntry(s32 mi, SMeshBufferLightMap* mb) + : MaterialIndex(mi), MeshBuffer(mb) {;} + + s32 MaterialIndex; + SMeshBufferLightMap* MeshBuffer; + }; + + core::array MaterialEntry; + core::array MeshBufferEntry; + + SMyMaterialEntry* getMaterialEntryByIndex (u32 matInd); + SMeshBufferLightMap* getMeshBufferByMaterialIndex(u32 matInd); + + core::array ChildNodes; +}; + + +} // end namespace scene +} // end namespace irr + + +#endif // __CMY3D_MESH_FILE_LOADER_H_INCLUDED__ diff --git a/src/dep/src/irrlicht/CMY3DStuff.h b/src/dep/src/irrlicht/CMY3DStuff.h index 7c82142..94cf66f 100644 --- a/src/dep/src/irrlicht/CMY3DStuff.h +++ b/src/dep/src/irrlicht/CMY3DStuff.h @@ -1,188 +1,188 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This file was originally written by ZDimitor. - -//---------------------------------------------------------------------- -// my3d-stuff.h - part of the My3D Tools -// -// This tool was created by Zhuck Dmitry (ZDimitor). -// Everyone can use it as wants ( i'll be happy if it helps to someone :) ). -//---------------------------------------------------------------------- - -#ifndef __C_MY_3D_STUFF_H_INCLUDED__ -#define __C_MY_3D_STUFF_H_INCLUDED__ - -#include - -namespace irr -{ -namespace scene -{ - -//********************************************************************** -// MY3D stuff -//********************************************************************** - -const unsigned long MY_ID = 0x4d593344; // was: #define MY_ID 'MY3D' -#define MY_VER 0x0003 - -#define MY_SCENE_HEADER_ID 0x1000 - -#define MY_MAT_LIST_ID 0x2000 -#define MY_MAT_HEADER_ID 0x2100 -#define MY_TEX_FNAME_ID 0x2101 -#define MY_TEXDATA_ID 0x2500 -#define MY_TEXDATA_HEADER_ID 0x2501 -#define MY_TEXDATA_RLE_HEADER_ID 0x2502 - -#define MY_MESH_LIST_ID 0x3000 -#define MY_MESH_HEADER_ID 0x3100 -#define MY_VERTS_ID 0x3101 -#define MY_FACES_ID 0x3102 -#define MY_TVERTS_ID 0x3103 -#define MY_TFACES_ID 0x3104 - -#define MY_FILE_END_ID 0xFFFF - -const unsigned long MY_TEXDATA_COMPR_NONE_ID = 0x4e4f4e45; // was: MY_TEXDATA_COMPR_NONE_ID 'NONE' -const unsigned long MY_TEXDATA_COMPR_SIMPLE_ID = 0x53494d50; // was: #define MY_TEXDATA_COMPR_SIMPLE_ID 'SIMP' -const unsigned long MY_TEXDATA_COMPR_RLE_ID = 0x20524c45; // was: #define MY_TEXDATA_COMPR_RLE_ID ' RLE' - -const unsigned long MY_PIXEL_FORMAT_24 = 0x5f32345f; // was: #define MY_PIXEL_FORMAT_24 '_24_' -const unsigned long MY_PIXEL_FORMAT_16 = 0x5f31365f; // was: #define MY_PIXEL_FORMAT_16 '_16_' -//-------------------------------------------------------------------- -// byte-align structures -#ifdef _MSC_VER -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif -//---------------------------------------------------------------------- -struct SMyColor -{ SMyColor () {;} - SMyColor (s32 __R, s32 __G, s32 __B, s32 __A) - : R(__R), G(__G), B(__B), A(__A) {} - s32 R, G, B, A; -} PACK_STRUCT; - -struct SMyVector3 -{ SMyVector3 () {;} - SMyVector3 (f32 __X, f32 __Y, f32 __Z) - : X(__X), Y(__Y), Z(__Z) {} - f32 X, Y, Z; -} PACK_STRUCT; - -struct SMyVector2 -{ SMyVector2 () {;} - SMyVector2(f32 __X, f32 __Y) - : X(__X), Y(__Y) {} - f32 X, Y; -} PACK_STRUCT; - -struct SMyVertex -{ SMyVertex () {;} - SMyVertex (SMyVector3 _Coord, SMyColor _Color, SMyVector3 _Normal) - :Coord(_Coord), Color(_Color), Normal(_Normal) {;} - SMyVector3 Coord; - SMyColor Color; - SMyVector3 Normal; -} PACK_STRUCT; - -struct SMyTVertex -{ SMyTVertex () {;} - SMyTVertex (SMyVector2 _TCoord) - : TCoord(_TCoord) {;} - SMyVector2 TCoord; -} PACK_STRUCT; - -struct SMyFace -{ SMyFace() {;} - SMyFace(u32 __A, u32 __B, u32 __C) - : A(__A), B(__B), C(__C) {} - u32 A, B, C; -} PACK_STRUCT; - -// file header (6 bytes) -struct SMyFileHeader -{ u32 MyId; // MY3D - u16 Ver; // Version -} PACK_STRUCT; - -// scene header -struct SMySceneHeader -{ SMyColor BackgrColor; // background color - SMyColor AmbientColor; // ambient color - s32 MaterialCount; // material count - s32 MeshCount; // mesh count -} PACK_STRUCT; - -// material header -struct SMyMaterialHeader -{ c8 Name[256]; // material name - u32 Index; - SMyColor AmbientColor; - SMyColor DiffuseColor; - SMyColor EmissiveColor; - SMyColor SpecularColor; - f32 Shininess; - f32 Transparency; - s32 TextureCount; // texture count -} PACK_STRUCT; - -// mesh header -struct SMyMeshHeader -{ c8 Name[256]; // material name - u32 MatIndex; // index of the mesh material - u32 TChannelCnt; // mesh mapping channels count -} PACK_STRUCT; - -// texture data header -struct SMyTexDataHeader -{ c8 Name[256]; // texture name - u32 ComprMode; //compression mode - u32 PixelFormat; - u32 Width; // image width - u32 Height; // image height -} PACK_STRUCT; - -// pixel color 24bit (R8G8B8) -struct SMyPixelColor24 -{ SMyPixelColor24() {;} - SMyPixelColor24(u8 __r, u8 __g, u8 __b) - : r(__r), g(__g), b(__b) {} - u8 r, g, b; -} PACK_STRUCT; - -// pixel color 16bit (A1R5G5B5) -struct SMyPixelColor16 -{ SMyPixelColor16() {;} - SMyPixelColor16(s16 _argb): argb(_argb) {;} - SMyPixelColor16(u8 r, u8 g, u8 b) - { argb = ((r&0x1F)<<10) | ((g&0x1F)<<5) | (b&0x1F); - } - s16 argb; -} PACK_STRUCT; - -// RLE Header -struct SMyRLEHeader -{ SMyRLEHeader() {;} - u32 nEncodedBytes; - u32 nDecodedBytes; -} PACK_STRUCT; - -// Default alignment -#ifdef _MSC_VER -# pragma pack( pop, packing ) -#endif - -} // end namespace -} // end namespace - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// +// This file was originally written by ZDimitor. + +//---------------------------------------------------------------------- +// my3d-stuff.h - part of the My3D Tools +// +// This tool was created by Zhuck Dmitry (ZDimitor). +// Everyone can use it as wants ( i'll be happy if it helps to someone :) ). +//---------------------------------------------------------------------- + +#ifndef __C_MY_3D_STUFF_H_INCLUDED__ +#define __C_MY_3D_STUFF_H_INCLUDED__ + +#include + +namespace irr +{ +namespace scene +{ + +//********************************************************************** +// MY3D stuff +//********************************************************************** + +const unsigned long MY_ID = 0x4d593344; // was: #define MY_ID 'MY3D' +#define MY_VER 0x0003 + +#define MY_SCENE_HEADER_ID 0x1000 + +#define MY_MAT_LIST_ID 0x2000 +#define MY_MAT_HEADER_ID 0x2100 +#define MY_TEX_FNAME_ID 0x2101 +#define MY_TEXDATA_ID 0x2500 +#define MY_TEXDATA_HEADER_ID 0x2501 +#define MY_TEXDATA_RLE_HEADER_ID 0x2502 + +#define MY_MESH_LIST_ID 0x3000 +#define MY_MESH_HEADER_ID 0x3100 +#define MY_VERTS_ID 0x3101 +#define MY_FACES_ID 0x3102 +#define MY_TVERTS_ID 0x3103 +#define MY_TFACES_ID 0x3104 + +#define MY_FILE_END_ID 0xFFFF + +const unsigned long MY_TEXDATA_COMPR_NONE_ID = 0x4e4f4e45; // was: MY_TEXDATA_COMPR_NONE_ID 'NONE' +const unsigned long MY_TEXDATA_COMPR_SIMPLE_ID = 0x53494d50; // was: #define MY_TEXDATA_COMPR_SIMPLE_ID 'SIMP' +const unsigned long MY_TEXDATA_COMPR_RLE_ID = 0x20524c45; // was: #define MY_TEXDATA_COMPR_RLE_ID ' RLE' + +const unsigned long MY_PIXEL_FORMAT_24 = 0x5f32345f; // was: #define MY_PIXEL_FORMAT_24 '_24_' +const unsigned long MY_PIXEL_FORMAT_16 = 0x5f31365f; // was: #define MY_PIXEL_FORMAT_16 '_16_' +//-------------------------------------------------------------------- +// byte-align structures +#ifdef _MSC_VER +# pragma pack( push, packing ) +# pragma pack( 1 ) +# define PACK_STRUCT +#elif defined( __GNUC__ ) +# define PACK_STRUCT __attribute__((packed)) +#else +# error compiler not supported +#endif +//---------------------------------------------------------------------- +struct SMyColor +{ SMyColor () {;} + SMyColor (s32 __R, s32 __G, s32 __B, s32 __A) + : R(__R), G(__G), B(__B), A(__A) {} + s32 R, G, B, A; +} PACK_STRUCT; + +struct SMyVector3 +{ SMyVector3 () {;} + SMyVector3 (f32 __X, f32 __Y, f32 __Z) + : X(__X), Y(__Y), Z(__Z) {} + f32 X, Y, Z; +} PACK_STRUCT; + +struct SMyVector2 +{ SMyVector2 () {;} + SMyVector2(f32 __X, f32 __Y) + : X(__X), Y(__Y) {} + f32 X, Y; +} PACK_STRUCT; + +struct SMyVertex +{ SMyVertex () {;} + SMyVertex (SMyVector3 _Coord, SMyColor _Color, SMyVector3 _Normal) + :Coord(_Coord), Color(_Color), Normal(_Normal) {;} + SMyVector3 Coord; + SMyColor Color; + SMyVector3 Normal; +} PACK_STRUCT; + +struct SMyTVertex +{ SMyTVertex () {;} + SMyTVertex (SMyVector2 _TCoord) + : TCoord(_TCoord) {;} + SMyVector2 TCoord; +} PACK_STRUCT; + +struct SMyFace +{ SMyFace() {;} + SMyFace(u32 __A, u32 __B, u32 __C) + : A(__A), B(__B), C(__C) {} + u32 A, B, C; +} PACK_STRUCT; + +// file header (6 bytes) +struct SMyFileHeader +{ u32 MyId; // MY3D + u16 Ver; // Version +} PACK_STRUCT; + +// scene header +struct SMySceneHeader +{ SMyColor BackgrColor; // background color + SMyColor AmbientColor; // ambient color + s32 MaterialCount; // material count + s32 MeshCount; // mesh count +} PACK_STRUCT; + +// material header +struct SMyMaterialHeader +{ c8 Name[256]; // material name + u32 Index; + SMyColor AmbientColor; + SMyColor DiffuseColor; + SMyColor EmissiveColor; + SMyColor SpecularColor; + f32 Shininess; + f32 Transparency; + s32 TextureCount; // texture count +} PACK_STRUCT; + +// mesh header +struct SMyMeshHeader +{ c8 Name[256]; // material name + u32 MatIndex; // index of the mesh material + u32 TChannelCnt; // mesh mapping channels count +} PACK_STRUCT; + +// texture data header +struct SMyTexDataHeader +{ c8 Name[256]; // texture name + u32 ComprMode; //compression mode + u32 PixelFormat; + u32 Width; // image width + u32 Height; // image height +} PACK_STRUCT; + +// pixel color 24bit (R8G8B8) +struct SMyPixelColor24 +{ SMyPixelColor24() {;} + SMyPixelColor24(u8 __r, u8 __g, u8 __b) + : r(__r), g(__g), b(__b) {} + u8 r, g, b; +} PACK_STRUCT; + +// pixel color 16bit (A1R5G5B5) +struct SMyPixelColor16 +{ SMyPixelColor16() {;} + SMyPixelColor16(s16 _argb): argb(_argb) {;} + SMyPixelColor16(u8 r, u8 g, u8 b) + { argb = ((r&0x1F)<<10) | ((g&0x1F)<<5) | (b&0x1F); + } + s16 argb; +} PACK_STRUCT; + +// RLE Header +struct SMyRLEHeader +{ SMyRLEHeader() {;} + u32 nEncodedBytes; + u32 nDecodedBytes; +} PACK_STRUCT; + +// Default alignment +#ifdef _MSC_VER +# pragma pack( pop, packing ) +#endif + +} // end namespace +} // end namespace + +#endif + diff --git a/src/dep/src/irrlicht/CMemoryReadFile.cpp b/src/dep/src/irrlicht/CMemoryReadFile.cpp index 263d0a5..6b064e1 100644 --- a/src/dep/src/irrlicht/CMemoryReadFile.cpp +++ b/src/dep/src/irrlicht/CMemoryReadFile.cpp @@ -1,112 +1,112 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CMemoryReadFile.h" -#include "irrString.h" - -namespace irr -{ -namespace io -{ - - -CMemoryReadFile::CMemoryReadFile(void* memory, s32 len, const c8* fileName, bool d) -: Buffer(memory), Len(len), Pos(0), deleteMemoryWhenDropped(d) -{ - #ifdef _DEBUG - setDebugName("CReadFile"); - #endif - - Filename = fileName; -} - - - -CMemoryReadFile::~CMemoryReadFile() -{ - if (deleteMemoryWhenDropped) - delete [] (c8*)Buffer; -} - - - -//! returns how much was read -s32 CMemoryReadFile::read(void* buffer, u32 sizeToRead) -{ - s32 amount = sizeToRead; - if (Pos + amount > Len) - amount -= Pos + amount - Len; - - if (amount < 0) - amount = 0; - - c8* p = (c8*)Buffer; - memcpy(buffer, p + Pos, amount); - - Pos += static_cast ( amount ); - - return amount; -} - - - -//! changes position in file, returns true if successful -//! if relativeMovement==true, the pos is changed relative to current pos, -//! otherwise from begin of file -bool CMemoryReadFile::seek(s32 finalPos, bool relativeMovement) -{ - if (relativeMovement) - { - if (Pos + finalPos > Len) - return false; - - Pos += finalPos; - } - else - { - if ( (unsigned) finalPos > Len) - return false; - - Pos = finalPos; - } - - return true; -} - - - -//! returns size of file -s32 CMemoryReadFile::getSize() -{ - return Len; -} - - - -//! returns where in the file we are. -s32 CMemoryReadFile::getPos() -{ - return Pos; -} - - - -//! returns name of file -const c8* CMemoryReadFile::getFileName() -{ - return Filename.c_str(); -} - - - -IReadFile* createMemoryReadFile(void* memory, s32 size, const c8* fileName, bool deleteMemoryWhenDropped) -{ - CMemoryReadFile* file = new CMemoryReadFile(memory, size, fileName, deleteMemoryWhenDropped); - return file; -} - - -} // end namespace io -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CMemoryReadFile.h" +#include "irrString.h" + +namespace irr +{ +namespace io +{ + + +CMemoryReadFile::CMemoryReadFile(void* memory, s32 len, const c8* fileName, bool d) +: Buffer(memory), Len(len), Pos(0), deleteMemoryWhenDropped(d) +{ + #ifdef _DEBUG + setDebugName("CReadFile"); + #endif + + Filename = fileName; +} + + + +CMemoryReadFile::~CMemoryReadFile() +{ + if (deleteMemoryWhenDropped) + delete [] (c8*)Buffer; +} + + + +//! returns how much was read +s32 CMemoryReadFile::read(void* buffer, u32 sizeToRead) +{ + s32 amount = sizeToRead; + if (Pos + amount > Len) + amount -= Pos + amount - Len; + + if (amount < 0) + amount = 0; + + c8* p = (c8*)Buffer; + memcpy(buffer, p + Pos, amount); + + Pos += static_cast ( amount ); + + return amount; +} + + + +//! changes position in file, returns true if successful +//! if relativeMovement==true, the pos is changed relative to current pos, +//! otherwise from begin of file +bool CMemoryReadFile::seek(s32 finalPos, bool relativeMovement) +{ + if (relativeMovement) + { + if (Pos + finalPos > Len) + return false; + + Pos += finalPos; + } + else + { + if ( (unsigned) finalPos > Len) + return false; + + Pos = finalPos; + } + + return true; +} + + + +//! returns size of file +s32 CMemoryReadFile::getSize() +{ + return Len; +} + + + +//! returns where in the file we are. +s32 CMemoryReadFile::getPos() +{ + return Pos; +} + + + +//! returns name of file +const c8* CMemoryReadFile::getFileName() +{ + return Filename.c_str(); +} + + + +IReadFile* createMemoryReadFile(void* memory, s32 size, const c8* fileName, bool deleteMemoryWhenDropped) +{ + CMemoryReadFile* file = new CMemoryReadFile(memory, size, fileName, deleteMemoryWhenDropped); + return file; +} + + +} // end namespace io +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CMemoryReadFile.h b/src/dep/src/irrlicht/CMemoryReadFile.h index 450be05..c16c476 100644 --- a/src/dep/src/irrlicht/CMemoryReadFile.h +++ b/src/dep/src/irrlicht/CMemoryReadFile.h @@ -1,58 +1,58 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_MEMORY_READ_FILE_H_INCLUDED__ -#define __C_MEMORY_READ_FILE_H_INCLUDED__ - -#include "IReadFile.h" -#include "irrString.h" - -namespace irr -{ - -namespace io -{ - - /*! - Class for reading from memory. - */ - class CMemoryReadFile : public IReadFile - { - public: - - CMemoryReadFile(void* memory, s32 len, const c8* fileName, bool deleteMemoryWhenDropped); - - virtual ~CMemoryReadFile(); - - //! returns how much was read - virtual s32 read(void* buffer, u32 sizeToRead); - - //! changes position in file, returns true if successful - //! if relativeMovement==true, the pos is changed relative to current pos, - //! otherwise from begin of file - virtual bool seek(s32 finalPos, bool relativeMovement = false); - - //! returns size of file - virtual s32 getSize(); - - //! returns where in the file we are. - virtual s32 getPos(); - - //! returns name of file - virtual const c8* getFileName(); - - private: - - core::stringc Filename; - void *Buffer; - u32 Len; - u32 Pos; - bool deleteMemoryWhenDropped; - }; - -} // end namespace io -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_MEMORY_READ_FILE_H_INCLUDED__ +#define __C_MEMORY_READ_FILE_H_INCLUDED__ + +#include "IReadFile.h" +#include "irrString.h" + +namespace irr +{ + +namespace io +{ + + /*! + Class for reading from memory. + */ + class CMemoryReadFile : public IReadFile + { + public: + + CMemoryReadFile(void* memory, s32 len, const c8* fileName, bool deleteMemoryWhenDropped); + + virtual ~CMemoryReadFile(); + + //! returns how much was read + virtual s32 read(void* buffer, u32 sizeToRead); + + //! changes position in file, returns true if successful + //! if relativeMovement==true, the pos is changed relative to current pos, + //! otherwise from begin of file + virtual bool seek(s32 finalPos, bool relativeMovement = false); + + //! returns size of file + virtual s32 getSize(); + + //! returns where in the file we are. + virtual s32 getPos(); + + //! returns name of file + virtual const c8* getFileName(); + + private: + + core::stringc Filename; + void *Buffer; + u32 Len; + u32 Pos; + bool deleteMemoryWhenDropped; + }; + +} // end namespace io +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CMeshCache.cpp b/src/dep/src/irrlicht/CMeshCache.cpp index 38a0cfb..39b503e 100644 --- a/src/dep/src/irrlicht/CMeshCache.cpp +++ b/src/dep/src/irrlicht/CMeshCache.cpp @@ -1,141 +1,141 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CMeshCache.h" -#include "IAnimatedMesh.h" -#include "IMesh.h" - -namespace irr -{ -namespace scene -{ - - -CMeshCache::~CMeshCache() -{ - for (u32 i=0; idrop(); -} - - -//! adds a mesh to the list -void CMeshCache::addMesh(const c8* filename, IAnimatedMesh* mesh) -{ - mesh->grab(); - - MeshEntry e; - e.Mesh = mesh; - e.Name = filename; - e.Name.make_lower(); - - Meshes.push_back(e); -} - - -//! Returns amount of loaded meshes -s32 CMeshCache::getMeshCount() -{ - return Meshes.size(); -} - - -//! Returns a mesh based on its index number -IAnimatedMesh* CMeshCache::getMeshByIndex(s32 number) -{ - if (number < 0 || number >= (s32)Meshes.size()) - return 0; - - return Meshes[number].Mesh; -} - - - -//! Returns current number of the mesh -s32 CMeshCache::getMeshIndex(IAnimatedMesh* mesh) -{ - for (int i=0; i<(int)Meshes.size(); ++i) - if (Meshes[i].Mesh == mesh) - return i; - - return -1; -} - - - -//! Returns name of a mesh based on its index number -const c8* CMeshCache::getMeshFilename(s32 number) -{ - if (number < 0 || number >= (s32)Meshes.size()) - return 0; - - return Meshes[number].Name.c_str(); -} - - - -//! Returns the filename of a loaded mesh, if there is any. Returns 0 if there is none. -const c8* CMeshCache::getMeshFilename(IAnimatedMesh* mesh) -{ - for (s32 i=0; i<(s32)Meshes.size(); ++i) - { - if (Meshes[i].Mesh == mesh) - return Meshes[i].Name.c_str(); - } - - return 0; -} - - -//! Returns the filename of a loaded mesh, if there is any. Returns 0 if there is none. -const c8* CMeshCache::getMeshFilename(IMesh* mesh) -{ - for (s32 i=0; i<(s32)Meshes.size(); ++i) - { - if (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh) - return Meshes[i].Name.c_str(); - } - - return 0; -} - - - -//! returns if a mesh already was loaded -bool CMeshCache::isMeshLoaded(const c8* filename) -{ - core::stringc name = filename; - name.make_lower(); - return findMesh(name.c_str()) != 0; -} - - -//! returns an already loaded mesh -IAnimatedMesh* CMeshCache::findMesh(const c8* lowerMadeFilename) -{ - MeshEntry e; - e.Name = lowerMadeFilename; - s32 id = Meshes.binary_search(e); - return (id != -1) ? Meshes[id].Mesh : 0; -} - - -//! Removes a mesh from the cache. -void CMeshCache::removeMesh(IAnimatedMesh* mesh) -{ - if ( mesh ) - for (int i=0; i<(int)Meshes.size(); ++i) - { - if (Meshes[i].Mesh == mesh) - { - Meshes[i].Mesh->drop(); - Meshes.erase(i); - return; - } - } -} - -} // end namespace scene -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CMeshCache.h" +#include "IAnimatedMesh.h" +#include "IMesh.h" + +namespace irr +{ +namespace scene +{ + + +CMeshCache::~CMeshCache() +{ + for (u32 i=0; idrop(); +} + + +//! adds a mesh to the list +void CMeshCache::addMesh(const c8* filename, IAnimatedMesh* mesh) +{ + mesh->grab(); + + MeshEntry e; + e.Mesh = mesh; + e.Name = filename; + e.Name.make_lower(); + + Meshes.push_back(e); +} + + +//! Returns amount of loaded meshes +s32 CMeshCache::getMeshCount() +{ + return Meshes.size(); +} + + +//! Returns a mesh based on its index number +IAnimatedMesh* CMeshCache::getMeshByIndex(s32 number) +{ + if (number < 0 || number >= (s32)Meshes.size()) + return 0; + + return Meshes[number].Mesh; +} + + + +//! Returns current number of the mesh +s32 CMeshCache::getMeshIndex(IAnimatedMesh* mesh) +{ + for (int i=0; i<(int)Meshes.size(); ++i) + if (Meshes[i].Mesh == mesh) + return i; + + return -1; +} + + + +//! Returns name of a mesh based on its index number +const c8* CMeshCache::getMeshFilename(s32 number) +{ + if (number < 0 || number >= (s32)Meshes.size()) + return 0; + + return Meshes[number].Name.c_str(); +} + + + +//! Returns the filename of a loaded mesh, if there is any. Returns 0 if there is none. +const c8* CMeshCache::getMeshFilename(IAnimatedMesh* mesh) +{ + for (s32 i=0; i<(s32)Meshes.size(); ++i) + { + if (Meshes[i].Mesh == mesh) + return Meshes[i].Name.c_str(); + } + + return 0; +} + + +//! Returns the filename of a loaded mesh, if there is any. Returns 0 if there is none. +const c8* CMeshCache::getMeshFilename(IMesh* mesh) +{ + for (s32 i=0; i<(s32)Meshes.size(); ++i) + { + if (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh) + return Meshes[i].Name.c_str(); + } + + return 0; +} + + + +//! returns if a mesh already was loaded +bool CMeshCache::isMeshLoaded(const c8* filename) +{ + core::stringc name = filename; + name.make_lower(); + return findMesh(name.c_str()) != 0; +} + + +//! returns an already loaded mesh +IAnimatedMesh* CMeshCache::findMesh(const c8* lowerMadeFilename) +{ + MeshEntry e; + e.Name = lowerMadeFilename; + s32 id = Meshes.binary_search(e); + return (id != -1) ? Meshes[id].Mesh : 0; +} + + +//! Removes a mesh from the cache. +void CMeshCache::removeMesh(IAnimatedMesh* mesh) +{ + if ( mesh ) + for (int i=0; i<(int)Meshes.size(); ++i) + { + if (Meshes[i].Mesh == mesh) + { + Meshes[i].Mesh->drop(); + Meshes.erase(i); + return; + } + } +} + +} // end namespace scene +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CMeshCache.h b/src/dep/src/irrlicht/CMeshCache.h index 03e3f3e..d495c0c 100644 --- a/src/dep/src/irrlicht/CMeshCache.h +++ b/src/dep/src/irrlicht/CMeshCache.h @@ -1,97 +1,97 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_MESH_CACHE_H_INCLUDED__ -#define __C_MESH_CACHE_H_INCLUDED__ - -#include "IMeshCache.h" -#include "irrString.h" -#include "irrArray.h" - -namespace irr -{ - -namespace scene -{ - class CMeshCache : public IMeshCache - { - public: - - virtual ~CMeshCache(); - - //! Adds a mesh to the internal list of loaded meshes. - /** Usually, ISceneManager::getMesh() is called to load a mesh from file. - That method searches the list of loaded meshes if a mesh has already been loaded and - returns a pointer to if it is in that list and already in memory. Otherwise it loads - the mesh. With IMeshCache::addMesh(), it is possible to pretend that a mesh already - has been loaded. This method can be used for example by mesh loaders who need to - load more than one mesh with one call. They can add additional meshes with this - method to the scene manager. The COLLADA loader for example uses this method. - \param filename: Filename of the mesh. When called ISceneManager::getMesh() with this - parameter, the method will return the mesh parameter given with this method. - \param mesh: Pointer to a mesh which will now be referenced by this name. */ - virtual void addMesh(const c8* filename, IAnimatedMesh* mesh); - - //! Removes a mesh from the cache. - /** After loading a mesh with getMesh(), the mesh can be removed from the cache - using this method, freeing a lot of memory. */ - virtual void removeMesh(IAnimatedMesh* mesh); - - //! Returns amount of loaded meshes in the cache. - /** You can load new meshes into the cache using getMesh() and addMesh(). - If you ever need to access the internal mesh cache, you can do this using - removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename() */ - virtual s32 getMeshCount(); - - //! Returns current index number of the mesh, and -1 if it is not in the cache. - virtual s32 getMeshIndex(IAnimatedMesh* mesh); - - //! Returns a mesh based on its index number. - /** \param index: Index of the mesh, number between 0 and getMeshCount()-1. - Note that this number is only valid until a new mesh is loaded or removed * - \return Returns pointer to the mesh or 0 if there is none with this number. */ - virtual IAnimatedMesh* getMeshByIndex(s32 index); - - //! Returns name of a mesh based on its index number. - /** \param index: Index of the mesh, number between 0 and getMeshCount()-1. - Note that this is only valid until a new mesh is loaded */ - virtual const c8* getMeshFilename(s32 index); - - //! Returns the filename of a loaded mesh, if there is any. - /** Returns 0 if there is none. */ - virtual const c8* getMeshFilename(IAnimatedMesh* mesh); - - //! Returns the filename of a loaded mesh, if there is any. - /* Returns 0 if there is none.*/ - virtual const c8* getMeshFilename(IMesh* mesh); - - //! returns if a mesh already was loaded - virtual bool isMeshLoaded(const c8* filename); - - //! returns an already loaded mesh - IAnimatedMesh* findMesh(const c8* lowerMadeFilename); - - protected: - - struct MeshEntry - { - core::stringc Name; - IAnimatedMesh* Mesh; - - bool operator < (const MeshEntry& other) const - { - return (Name < other.Name); - } - }; - - //! loaded meshes - core::array Meshes; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_MESH_CACHE_H_INCLUDED__ +#define __C_MESH_CACHE_H_INCLUDED__ + +#include "IMeshCache.h" +#include "irrString.h" +#include "irrArray.h" + +namespace irr +{ + +namespace scene +{ + class CMeshCache : public IMeshCache + { + public: + + virtual ~CMeshCache(); + + //! Adds a mesh to the internal list of loaded meshes. + /** Usually, ISceneManager::getMesh() is called to load a mesh from file. + That method searches the list of loaded meshes if a mesh has already been loaded and + returns a pointer to if it is in that list and already in memory. Otherwise it loads + the mesh. With IMeshCache::addMesh(), it is possible to pretend that a mesh already + has been loaded. This method can be used for example by mesh loaders who need to + load more than one mesh with one call. They can add additional meshes with this + method to the scene manager. The COLLADA loader for example uses this method. + \param filename: Filename of the mesh. When called ISceneManager::getMesh() with this + parameter, the method will return the mesh parameter given with this method. + \param mesh: Pointer to a mesh which will now be referenced by this name. */ + virtual void addMesh(const c8* filename, IAnimatedMesh* mesh); + + //! Removes a mesh from the cache. + /** After loading a mesh with getMesh(), the mesh can be removed from the cache + using this method, freeing a lot of memory. */ + virtual void removeMesh(IAnimatedMesh* mesh); + + //! Returns amount of loaded meshes in the cache. + /** You can load new meshes into the cache using getMesh() and addMesh(). + If you ever need to access the internal mesh cache, you can do this using + removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename() */ + virtual s32 getMeshCount(); + + //! Returns current index number of the mesh, and -1 if it is not in the cache. + virtual s32 getMeshIndex(IAnimatedMesh* mesh); + + //! Returns a mesh based on its index number. + /** \param index: Index of the mesh, number between 0 and getMeshCount()-1. + Note that this number is only valid until a new mesh is loaded or removed * + \return Returns pointer to the mesh or 0 if there is none with this number. */ + virtual IAnimatedMesh* getMeshByIndex(s32 index); + + //! Returns name of a mesh based on its index number. + /** \param index: Index of the mesh, number between 0 and getMeshCount()-1. + Note that this is only valid until a new mesh is loaded */ + virtual const c8* getMeshFilename(s32 index); + + //! Returns the filename of a loaded mesh, if there is any. + /** Returns 0 if there is none. */ + virtual const c8* getMeshFilename(IAnimatedMesh* mesh); + + //! Returns the filename of a loaded mesh, if there is any. + /* Returns 0 if there is none.*/ + virtual const c8* getMeshFilename(IMesh* mesh); + + //! returns if a mesh already was loaded + virtual bool isMeshLoaded(const c8* filename); + + //! returns an already loaded mesh + IAnimatedMesh* findMesh(const c8* lowerMadeFilename); + + protected: + + struct MeshEntry + { + core::stringc Name; + IAnimatedMesh* Mesh; + + bool operator < (const MeshEntry& other) const + { + return (Name < other.Name); + } + }; + + //! loaded meshes + core::array Meshes; + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CMeshManipulator.cpp b/src/dep/src/irrlicht/CMeshManipulator.cpp index 2ec4a9d..ba0429d 100644 --- a/src/dep/src/irrlicht/CMeshManipulator.cpp +++ b/src/dep/src/irrlicht/CMeshManipulator.cpp @@ -1,945 +1,945 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CMeshManipulator.h" -#include "IMesh.h" -#include "SMesh.h" -#include "SMeshBuffer.h" -#include "SMeshBufferLightMap.h" -#include "SMeshBufferTangents.h" -#include "IAnimatedMesh.h" -#include "SAnimatedMesh.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! Recalculates the normals in vertex array. -//! This template function was a member of the CMeshManipulator class, but -//! visual studio 6.0 didn't like it. -template -inline void recalculateNormalsT_Flat(VTXTYPE* v, int vtxcnt, - u16* idx, int idxcnt) -{ - for (int i=0; i p(v[idx[i+0]].Pos, v[idx[i+1]].Pos, v[idx[i+2]].Pos); - v[idx[i+0]].Normal = p.Normal; - v[idx[i+1]].Normal = p.Normal; - v[idx[i+2]].Normal = p.Normal; - } -} - -template -inline void recalculateNormalsT_Smooth(VTXTYPE* v, int vtxcnt, - u16* idx, int idxcnt) -{ - s32 i; - - for ( i = 0; i!= vtxcnt; ++i ) - { - v[i].Normal.set ( 0.f, 0.f, 0.f ); - } - - for ( i=0; i p(v[idx[i+0]].Pos, v[idx[i+1]].Pos, v[idx[i+2]].Pos); - v[idx[i+0]].Normal += p.Normal; - v[idx[i+1]].Normal += p.Normal; - v[idx[i+2]].Normal += p.Normal; - } - - for ( i = 0; i!= vtxcnt; ++i ) - { - v[i].Normal.normalize (); - } - -} - - -//! Recalculates normals in a vertex array. -//! This template function was a member of the CMeshManipulator class, but -//! visual studio 6.0 didn't like it. -template -inline void makePlanarMappingT(VERTEXTYPE *v, - int vtxcnt, - u16* idx, int idxcnt, f32 resolution) -{ - for (int i=0; i p(v[idx[i+0]].Pos, v[idx[i+1]].Pos, v[idx[i+2]].Pos); - p.Normal.X = (f32)(fabs(p.Normal.X)); - p.Normal.Y = (f32)(fabs(p.Normal.Y)); - p.Normal.Z = (f32)(fabs(p.Normal.Z)); - // calculate planar mapping worldspace coordinates - - if (p.Normal.X > p.Normal.Y && p.Normal.X > p.Normal.Z) - { - for (s32 o=0; o<3; ++o) - { - v[idx[i+o]].TCoords.X = v[idx[i+o]].Pos.Y * resolution; - v[idx[i+o]].TCoords.Y = v[idx[i+o]].Pos.Z * resolution; - } - } - else - if (p.Normal.Y > p.Normal.X && p.Normal.Y > p.Normal.Z) - { - for (s32 o=0; o<3; ++o) - { - v[idx[i+o]].TCoords.X = v[idx[i+o]].Pos.X * resolution; - v[idx[i+o]].TCoords.Y = v[idx[i+o]].Pos.Z * resolution; - } - } - else - { - for (s32 o=0; o<3; ++o) - { - v[idx[i+o]].TCoords.X = v[idx[i+o]].Pos.X * resolution; - v[idx[i+o]].TCoords.Y = v[idx[i+o]].Pos.Y * resolution; - } - } - } -} - -//! Constructor -CMeshManipulator::CMeshManipulator() -{ -} - - -//! destructor -CMeshManipulator::~CMeshManipulator() -{ -} - -//! Flips the direction of surfaces. Changes backfacing triangles to frontfacing -//! triangles and vice versa. -//! \param mesh: Mesh on which the operation is performed. -void CMeshManipulator::flipSurfaces(scene::IMesh* mesh) const -{ - if (!mesh) - return; - - const u32 bcount = mesh->getMeshBufferCount(); - for (u32 b=0; bgetMeshBuffer(b); - u32 idxcnt = buffer->getIndexCount(); - u16* idx = buffer->getIndices(); - s32 tmp; - - for (u32 i=0; igetMeshBufferCount(); - for ( u32 b=0; bgetMeshBuffer(b); - void* v = buffer->getVertices(); - u32 vtxcnt = buffer->getVertexCount(); - - switch(buffer->getVertexType()) - { - case video::EVT_STANDARD: - { - for ( i=0; igetMeshBufferCount(); - for (u32 b=0; bgetMeshBuffer(b); - void* v = buffer->getVertices(); - const u32 vtxcnt = buffer->getVertexCount(); - u32 i; - - switch(buffer->getVertexType()) - { - case video::EVT_STANDARD: - { - for ( i=0; igetVertexCount(); - u32 idxcnt = buffer->getIndexCount(); - u16* idx = buffer->getIndices(); - - switch(buffer->getVertexType()) - { - case video::EVT_STANDARD: - { - video::S3DVertex* v = (video::S3DVertex*)buffer->getVertices(); - - if (!smooth) - recalculateNormalsT_Flat(v, vtxcnt, idx, idxcnt); - else - recalculateNormalsT_Smooth(v, vtxcnt, idx, idxcnt); - } - break; - case video::EVT_2TCOORDS: - { - video::S3DVertex2TCoords* v = (video::S3DVertex2TCoords*)buffer->getVertices(); - - if (!smooth) - recalculateNormalsT_Flat(v, vtxcnt, idx, idxcnt); - else - recalculateNormalsT_Smooth(v, vtxcnt, idx, idxcnt); - } - break; - case video::EVT_TANGENTS: - { - // TODO: recalculate tangent and binormal - video::S3DVertexTangents* v = (video::S3DVertexTangents*)buffer->getVertices(); - if (!smooth) - recalculateNormalsT_Flat(v, vtxcnt, idx, idxcnt); - else - recalculateNormalsT_Smooth(v, vtxcnt, idx, idxcnt); - } - } -} - - - -//! Recalculates all normals of the mesh. -//! \param mesh: Mesh on which the operation is performed. -void CMeshManipulator::recalculateNormals(scene::IMesh* mesh, bool smooth) const -{ - if (!mesh) - return; - - const u32 bcount = mesh->getMeshBufferCount(); - for ( u32 b=0; bgetMeshBuffer(b), smooth); -} - - -//! Applies a transformation -/** \param mesh: Mesh on which the operation is performed. - \param m: matrix. */ -void CMeshManipulator::transformMesh(scene::IMesh* mesh, const core::matrix4& m) const -{ - if (!mesh) - return; - - core::aabbox3df meshbox; - core::aabbox3df bufferbox; - u32 i; - - const u32 bcount = mesh->getMeshBufferCount(); - for ( u32 b=0; bgetMeshBuffer(b); - - const u32 vtxcnt = buffer->getVertexCount(); - const u32 vtxPitch = buffer->getVertexPitch (); - - video::S3DVertex* v = (video::S3DVertex*) buffer->getVertices(); - - for ( i=0; i < 1; ++i) - { - m.transformVect ( v->Pos); - m.rotateVect ( v->Normal ); - v->Normal.normalize(); - - bufferbox.reset( v->Pos); - v = (video::S3DVertex*) ((u8*) v + vtxPitch); - } - - for ( ;i < vtxcnt; ++i) - { - m.transformVect ( v->Pos); - m.rotateVect ( v->Normal ); - v->Normal.normalize(); - - bufferbox.addInternalPoint( v->Pos); - v = (video::S3DVertex*) ((u8*) v + vtxPitch); - } - - buffer->setBoundingBox(bufferbox); - - if (b == 0) - meshbox.reset(buffer->getBoundingBox()); - else - meshbox.addInternalBox(buffer->getBoundingBox()); - } - - - mesh->setBoundingBox( meshbox ); - -} - - -//! Scales the whole mesh. -//! \param mesh: Mesh on which the operation is performed. -void CMeshManipulator::scaleMesh(scene::IMesh* mesh, const core::vector3df& scale) const -{ - if (!mesh) - return; - - core::aabbox3df meshbox; - - const u32 bcount = mesh->getMeshBufferCount(); - for ( u32 b=0; bgetMeshBuffer(b); - void* v = buffer->getVertices(); - const u32 vtxcnt = buffer->getVertexCount(); - core::aabbox3df bufferbox; - u32 i; - - switch(buffer->getVertexType()) - { - case video::EVT_STANDARD: - { - if (vtxcnt != 0) - bufferbox.reset(((video::S3DVertex*)v)[0].Pos * scale); - - for ( i=0; isetBoundingBox( bufferbox ); - - if (b == 0) - meshbox.reset(buffer->getBoundingBox()); - else - meshbox.addInternalBox(buffer->getBoundingBox()); - } - - mesh->setBoundingBox( meshbox ); -} - - - -//! Recalculates the bounding box for a meshbuffer -void CMeshManipulator::recalculateBoundingBox(scene::IMeshBuffer* buffer) const -{ - core::aabbox3df box; - - const u32 vtxcnt = buffer->getVertexCount(); - if ( 0 == vtxcnt ) - { - buffer->setBoundingBox( box ); - return; - } - - void* v = buffer->getVertices(); - u32 i; - - switch(buffer->getVertexType()) - { - case video::EVT_STANDARD: - { - box.reset(((video::S3DVertex*)v)[0].Pos); - - for ( i=1; isetBoundingBox( box ); -} - - - -//! Clones a static IMesh into a modifyable SMesh. -SMesh* CMeshManipulator::createMeshCopy(scene::IMesh* mesh) const -{ - if (!mesh) - return 0; - - SMesh* clone = new SMesh(); - - const u32 meshBufferCount = mesh->getMeshBufferCount(); - - for ( u32 b=0; bgetMeshBuffer(b)->getVertexCount(); - const u32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount(); - const u16* idx = mesh->getMeshBuffer(b)->getIndices(); - u32 i; - - switch(mesh->getMeshBuffer(b)->getVertexType()) - { - case video::EVT_STANDARD: - { - SMeshBuffer* buffer = new SMeshBuffer(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - - video::S3DVertex* v = - (video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices(); - - for (i=0; iVertices.push_back(v[i]); - - for (i=0; iIndices.push_back(idx[i]); - - clone->addMeshBuffer(buffer); - buffer->drop(); - } - break; - case video::EVT_2TCOORDS: - { - SMeshBufferLightMap* buffer = new SMeshBufferLightMap(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - - video::S3DVertex2TCoords* v = - (video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices(); - - for (i=0; iVertices.push_back(v[i]); - - for (i=0; iIndices.push_back(idx[i]); - - clone->addMeshBuffer(buffer); - buffer->drop(); - } - break; - case video::EVT_TANGENTS: - { - SMeshBufferTangents* buffer = new SMeshBufferTangents(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - - video::S3DVertexTangents* v = - (video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices(); - - for (i=0; iVertices.push_back(v[i]); - - for (i=0; iIndices.push_back(idx[i]); - - clone->addMeshBuffer(buffer); - buffer->drop(); - } - break; - }// end switch - - }// end for all mesh buffers - - clone->BoundingBox = mesh->getBoundingBox(); - return clone; -} - - - -//! Creates a planar texture mapping on the mesh -//! \param mesh: Mesh on which the operation is performed. -//! \param resolution: resolution of the planar mapping. This is the value -//! specifying which is the releation between world space and -//! texture coordinate space. -void CMeshManipulator::makePlanarTextureMapping(scene::IMesh* mesh, f32 resolution=0.01f) const -{ - if (!mesh) - return; - - const u32 bcount = mesh->getMeshBufferCount(); - for ( u32 b=0; bgetMeshBuffer(b); - u32 vtxcnt = buffer->getVertexCount(); - u32 idxcnt = buffer->getIndexCount(); - u16* idx = buffer->getIndices(); - - switch(buffer->getVertexType()) - { - case video::EVT_STANDARD: - { - video::S3DVertex* v = (video::S3DVertex*)buffer->getVertices(); - makePlanarMappingT(v, vtxcnt, idx, idxcnt, resolution); - } - break; - case video::EVT_2TCOORDS: - { - video::S3DVertex2TCoords* v = (video::S3DVertex2TCoords*)buffer->getVertices(); - makePlanarMappingT(v, vtxcnt, idx, idxcnt, resolution); - } - break; - case video::EVT_TANGENTS: - { - video::S3DVertexTangents* v = (video::S3DVertexTangents*)buffer->getVertices(); - makePlanarMappingT(v, vtxcnt, idx, idxcnt, resolution); - } - break; - } - } -} - - - -//! Creates a copy of the mesh, which will only consist of unique primitives -IMesh* CMeshManipulator::createMeshUniquePrimitives(IMesh* mesh) const -{ - if (!mesh) - return 0; - - SMesh* clone = new SMesh(); - - const u32 meshBufferCount = mesh->getMeshBufferCount(); - - for ( u32 b=0; bgetMeshBuffer(b)->getIndexCount(); - const u16* idx = mesh->getMeshBuffer(b)->getIndices(); - - switch(mesh->getMeshBuffer(b)->getVertexType()) - { - case video::EVT_STANDARD: - { - SMeshBuffer* buffer = new SMeshBuffer(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - - video::S3DVertex* v = - (video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices(); - - for (s32 i=0; iVertices.push_back( v[idx[i + 0 ]] ); - buffer->Vertices.push_back( v[idx[i + 1 ]] ); - buffer->Vertices.push_back( v[idx[i + 2 ]] ); - - buffer->Indices.push_back( i + 0 ); - buffer->Indices.push_back( i + 1 ); - buffer->Indices.push_back( i + 2 ); - } - - clone->addMeshBuffer(buffer); - buffer->drop(); - } - break; - case video::EVT_2TCOORDS: - { - SMeshBufferLightMap* buffer = new SMeshBufferLightMap(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - - video::S3DVertex2TCoords* v = - (video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices(); - - for (s32 i=0; iVertices.push_back( v[idx[i + 0 ]] ); - buffer->Vertices.push_back( v[idx[i + 1 ]] ); - buffer->Vertices.push_back( v[idx[i + 2 ]] ); - - buffer->Indices.push_back( i + 0 ); - buffer->Indices.push_back( i + 1 ); - buffer->Indices.push_back( i + 2 ); - } - clone->addMeshBuffer(buffer); - buffer->drop(); - } - break; - case video::EVT_TANGENTS: - { - SMeshBufferTangents* buffer = new SMeshBufferTangents(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - - video::S3DVertexTangents* v = - (video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices(); - - for (s32 i=0; iVertices.push_back( v[idx[i + 0 ]] ); - buffer->Vertices.push_back( v[idx[i + 1 ]] ); - buffer->Vertices.push_back( v[idx[i + 2 ]] ); - - buffer->Indices.push_back( i + 0 ); - buffer->Indices.push_back( i + 1 ); - buffer->Indices.push_back( i + 2 ); - } - - clone->addMeshBuffer(buffer); - buffer->drop(); - } - break; - }// end switch - - }// end for all mesh buffers - - clone->BoundingBox = mesh->getBoundingBox(); - return clone; -} - - -//! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices. -IMesh* CMeshManipulator::createMeshWithTangents(IMesh* mesh) const -{ - if (!mesh) - return 0; - - // copy mesh and fill data into SMeshBufferTangents - - SMesh* clone = new SMesh(); - const u32 meshBufferCount = mesh->getMeshBufferCount(); - u32 b; - - for (b=0; bgetMeshBuffer(b)->getIndexCount(); - const u16* idx = mesh->getMeshBuffer(b)->getIndices(); - - SMeshBufferTangents* buffer = new SMeshBufferTangents(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - - // copy vertices - - switch(mesh->getMeshBuffer(b)->getVertexType()) - { - case video::EVT_STANDARD: - { - video::S3DVertex* v = - (video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices(); - - for (s32 i=0; iVertices.push_back( - video::S3DVertexTangents( - v[idx[i]].Pos, v[idx[i]].TCoords, v[idx[i]].Color)); - } - break; - case video::EVT_2TCOORDS: - { - video::S3DVertex2TCoords* v = - (video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices(); - - for (s32 i=0; iVertices.push_back(video::S3DVertexTangents( - v[idx[i]].Pos, v[idx[i]].TCoords, v[idx[i]].Color)); - } - break; - case video::EVT_TANGENTS: - { - video::S3DVertexTangents* v = - (video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices(); - - for (s32 i=0; iVertices.push_back(v[idx[i]]); - } - break; - } - - // create new indices - - buffer->Indices.set_used(idxCnt); - for (s32 i=0; iIndices[i] = i; - - // add new buffer - clone->addMeshBuffer(buffer); - buffer->drop(); - } - - clone->BoundingBox = mesh->getBoundingBox(); - - // now calculate tangents - for (b=0; bgetMeshBuffer(b)->getIndexCount(); - - u16* idx = clone->getMeshBuffer(b)->getIndices(); - video::S3DVertexTangents* v = - (video::S3DVertexTangents*)clone->getMeshBuffer(b)->getVertices(); - - for (s32 i=0; i pl(vt1, vt2, vt3); - - if(normal.dotProduct(pl.Normal) < 0.0f ) - normal *= -1.0f; - -#endif // USE_NVIDIA_GLH_VERSION -} - - - -//! Returns amount of polygons in mesh. -s32 CMeshManipulator::getPolyCount(scene::IMesh* mesh) const -{ - if (!mesh) - return 0; - - s32 trianglecount = 0; - - for (u32 g=0; ggetMeshBufferCount(); ++g) - trianglecount += mesh->getMeshBuffer(g)->getIndexCount() / 3; - - return trianglecount; -} - - - -//! Returns amount of polygons in mesh. -s32 CMeshManipulator::getPolyCount(scene::IAnimatedMesh* mesh) const -{ - if (mesh && mesh->getFrameCount() != 0) - return getPolyCount(mesh->getMesh(0)); - - return 0; -} - -//! create a new AnimatedMesh and adds the mesh to it -IAnimatedMesh * CMeshManipulator::createAnimatedMesh(scene::IMesh* mesh,scene::E_ANIMATED_MESH_TYPE type) const -{ - SAnimatedMesh* animatedMesh = new SAnimatedMesh(); - - animatedMesh->Type = type; - animatedMesh->addMesh(mesh); - animatedMesh->recalculateBoundingBox(); - - //mesh->drop (); - - return animatedMesh; - -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CMeshManipulator.h" +#include "IMesh.h" +#include "SMesh.h" +#include "SMeshBuffer.h" +#include "SMeshBufferLightMap.h" +#include "SMeshBufferTangents.h" +#include "IAnimatedMesh.h" +#include "SAnimatedMesh.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! Recalculates the normals in vertex array. +//! This template function was a member of the CMeshManipulator class, but +//! visual studio 6.0 didn't like it. +template +inline void recalculateNormalsT_Flat(VTXTYPE* v, int vtxcnt, + u16* idx, int idxcnt) +{ + for (int i=0; i p(v[idx[i+0]].Pos, v[idx[i+1]].Pos, v[idx[i+2]].Pos); + v[idx[i+0]].Normal = p.Normal; + v[idx[i+1]].Normal = p.Normal; + v[idx[i+2]].Normal = p.Normal; + } +} + +template +inline void recalculateNormalsT_Smooth(VTXTYPE* v, int vtxcnt, + u16* idx, int idxcnt) +{ + s32 i; + + for ( i = 0; i!= vtxcnt; ++i ) + { + v[i].Normal.set ( 0.f, 0.f, 0.f ); + } + + for ( i=0; i p(v[idx[i+0]].Pos, v[idx[i+1]].Pos, v[idx[i+2]].Pos); + v[idx[i+0]].Normal += p.Normal; + v[idx[i+1]].Normal += p.Normal; + v[idx[i+2]].Normal += p.Normal; + } + + for ( i = 0; i!= vtxcnt; ++i ) + { + v[i].Normal.normalize (); + } + +} + + +//! Recalculates normals in a vertex array. +//! This template function was a member of the CMeshManipulator class, but +//! visual studio 6.0 didn't like it. +template +inline void makePlanarMappingT(VERTEXTYPE *v, + int vtxcnt, + u16* idx, int idxcnt, f32 resolution) +{ + for (int i=0; i p(v[idx[i+0]].Pos, v[idx[i+1]].Pos, v[idx[i+2]].Pos); + p.Normal.X = (f32)(fabs(p.Normal.X)); + p.Normal.Y = (f32)(fabs(p.Normal.Y)); + p.Normal.Z = (f32)(fabs(p.Normal.Z)); + // calculate planar mapping worldspace coordinates + + if (p.Normal.X > p.Normal.Y && p.Normal.X > p.Normal.Z) + { + for (s32 o=0; o<3; ++o) + { + v[idx[i+o]].TCoords.X = v[idx[i+o]].Pos.Y * resolution; + v[idx[i+o]].TCoords.Y = v[idx[i+o]].Pos.Z * resolution; + } + } + else + if (p.Normal.Y > p.Normal.X && p.Normal.Y > p.Normal.Z) + { + for (s32 o=0; o<3; ++o) + { + v[idx[i+o]].TCoords.X = v[idx[i+o]].Pos.X * resolution; + v[idx[i+o]].TCoords.Y = v[idx[i+o]].Pos.Z * resolution; + } + } + else + { + for (s32 o=0; o<3; ++o) + { + v[idx[i+o]].TCoords.X = v[idx[i+o]].Pos.X * resolution; + v[idx[i+o]].TCoords.Y = v[idx[i+o]].Pos.Y * resolution; + } + } + } +} + +//! Constructor +CMeshManipulator::CMeshManipulator() +{ +} + + +//! destructor +CMeshManipulator::~CMeshManipulator() +{ +} + +//! Flips the direction of surfaces. Changes backfacing triangles to frontfacing +//! triangles and vice versa. +//! \param mesh: Mesh on which the operation is performed. +void CMeshManipulator::flipSurfaces(scene::IMesh* mesh) const +{ + if (!mesh) + return; + + const u32 bcount = mesh->getMeshBufferCount(); + for (u32 b=0; bgetMeshBuffer(b); + u32 idxcnt = buffer->getIndexCount(); + u16* idx = buffer->getIndices(); + s32 tmp; + + for (u32 i=0; igetMeshBufferCount(); + for ( u32 b=0; bgetMeshBuffer(b); + void* v = buffer->getVertices(); + u32 vtxcnt = buffer->getVertexCount(); + + switch(buffer->getVertexType()) + { + case video::EVT_STANDARD: + { + for ( i=0; igetMeshBufferCount(); + for (u32 b=0; bgetMeshBuffer(b); + void* v = buffer->getVertices(); + const u32 vtxcnt = buffer->getVertexCount(); + u32 i; + + switch(buffer->getVertexType()) + { + case video::EVT_STANDARD: + { + for ( i=0; igetVertexCount(); + u32 idxcnt = buffer->getIndexCount(); + u16* idx = buffer->getIndices(); + + switch(buffer->getVertexType()) + { + case video::EVT_STANDARD: + { + video::S3DVertex* v = (video::S3DVertex*)buffer->getVertices(); + + if (!smooth) + recalculateNormalsT_Flat(v, vtxcnt, idx, idxcnt); + else + recalculateNormalsT_Smooth(v, vtxcnt, idx, idxcnt); + } + break; + case video::EVT_2TCOORDS: + { + video::S3DVertex2TCoords* v = (video::S3DVertex2TCoords*)buffer->getVertices(); + + if (!smooth) + recalculateNormalsT_Flat(v, vtxcnt, idx, idxcnt); + else + recalculateNormalsT_Smooth(v, vtxcnt, idx, idxcnt); + } + break; + case video::EVT_TANGENTS: + { + // TODO: recalculate tangent and binormal + video::S3DVertexTangents* v = (video::S3DVertexTangents*)buffer->getVertices(); + if (!smooth) + recalculateNormalsT_Flat(v, vtxcnt, idx, idxcnt); + else + recalculateNormalsT_Smooth(v, vtxcnt, idx, idxcnt); + } + } +} + + + +//! Recalculates all normals of the mesh. +//! \param mesh: Mesh on which the operation is performed. +void CMeshManipulator::recalculateNormals(scene::IMesh* mesh, bool smooth) const +{ + if (!mesh) + return; + + const u32 bcount = mesh->getMeshBufferCount(); + for ( u32 b=0; bgetMeshBuffer(b), smooth); +} + + +//! Applies a transformation +/** \param mesh: Mesh on which the operation is performed. + \param m: matrix. */ +void CMeshManipulator::transformMesh(scene::IMesh* mesh, const core::matrix4& m) const +{ + if (!mesh) + return; + + core::aabbox3df meshbox; + core::aabbox3df bufferbox; + u32 i; + + const u32 bcount = mesh->getMeshBufferCount(); + for ( u32 b=0; bgetMeshBuffer(b); + + const u32 vtxcnt = buffer->getVertexCount(); + const u32 vtxPitch = buffer->getVertexPitch (); + + video::S3DVertex* v = (video::S3DVertex*) buffer->getVertices(); + + for ( i=0; i < 1; ++i) + { + m.transformVect ( v->Pos); + m.rotateVect ( v->Normal ); + v->Normal.normalize(); + + bufferbox.reset( v->Pos); + v = (video::S3DVertex*) ((u8*) v + vtxPitch); + } + + for ( ;i < vtxcnt; ++i) + { + m.transformVect ( v->Pos); + m.rotateVect ( v->Normal ); + v->Normal.normalize(); + + bufferbox.addInternalPoint( v->Pos); + v = (video::S3DVertex*) ((u8*) v + vtxPitch); + } + + buffer->setBoundingBox(bufferbox); + + if (b == 0) + meshbox.reset(buffer->getBoundingBox()); + else + meshbox.addInternalBox(buffer->getBoundingBox()); + } + + + mesh->setBoundingBox( meshbox ); + +} + + +//! Scales the whole mesh. +//! \param mesh: Mesh on which the operation is performed. +void CMeshManipulator::scaleMesh(scene::IMesh* mesh, const core::vector3df& scale) const +{ + if (!mesh) + return; + + core::aabbox3df meshbox; + + const u32 bcount = mesh->getMeshBufferCount(); + for ( u32 b=0; bgetMeshBuffer(b); + void* v = buffer->getVertices(); + const u32 vtxcnt = buffer->getVertexCount(); + core::aabbox3df bufferbox; + u32 i; + + switch(buffer->getVertexType()) + { + case video::EVT_STANDARD: + { + if (vtxcnt != 0) + bufferbox.reset(((video::S3DVertex*)v)[0].Pos * scale); + + for ( i=0; isetBoundingBox( bufferbox ); + + if (b == 0) + meshbox.reset(buffer->getBoundingBox()); + else + meshbox.addInternalBox(buffer->getBoundingBox()); + } + + mesh->setBoundingBox( meshbox ); +} + + + +//! Recalculates the bounding box for a meshbuffer +void CMeshManipulator::recalculateBoundingBox(scene::IMeshBuffer* buffer) const +{ + core::aabbox3df box; + + const u32 vtxcnt = buffer->getVertexCount(); + if ( 0 == vtxcnt ) + { + buffer->setBoundingBox( box ); + return; + } + + void* v = buffer->getVertices(); + u32 i; + + switch(buffer->getVertexType()) + { + case video::EVT_STANDARD: + { + box.reset(((video::S3DVertex*)v)[0].Pos); + + for ( i=1; isetBoundingBox( box ); +} + + + +//! Clones a static IMesh into a modifyable SMesh. +SMesh* CMeshManipulator::createMeshCopy(scene::IMesh* mesh) const +{ + if (!mesh) + return 0; + + SMesh* clone = new SMesh(); + + const u32 meshBufferCount = mesh->getMeshBufferCount(); + + for ( u32 b=0; bgetMeshBuffer(b)->getVertexCount(); + const u32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount(); + const u16* idx = mesh->getMeshBuffer(b)->getIndices(); + u32 i; + + switch(mesh->getMeshBuffer(b)->getVertexType()) + { + case video::EVT_STANDARD: + { + SMeshBuffer* buffer = new SMeshBuffer(); + buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); + + video::S3DVertex* v = + (video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices(); + + for (i=0; iVertices.push_back(v[i]); + + for (i=0; iIndices.push_back(idx[i]); + + clone->addMeshBuffer(buffer); + buffer->drop(); + } + break; + case video::EVT_2TCOORDS: + { + SMeshBufferLightMap* buffer = new SMeshBufferLightMap(); + buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); + + video::S3DVertex2TCoords* v = + (video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices(); + + for (i=0; iVertices.push_back(v[i]); + + for (i=0; iIndices.push_back(idx[i]); + + clone->addMeshBuffer(buffer); + buffer->drop(); + } + break; + case video::EVT_TANGENTS: + { + SMeshBufferTangents* buffer = new SMeshBufferTangents(); + buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); + + video::S3DVertexTangents* v = + (video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices(); + + for (i=0; iVertices.push_back(v[i]); + + for (i=0; iIndices.push_back(idx[i]); + + clone->addMeshBuffer(buffer); + buffer->drop(); + } + break; + }// end switch + + }// end for all mesh buffers + + clone->BoundingBox = mesh->getBoundingBox(); + return clone; +} + + + +//! Creates a planar texture mapping on the mesh +//! \param mesh: Mesh on which the operation is performed. +//! \param resolution: resolution of the planar mapping. This is the value +//! specifying which is the releation between world space and +//! texture coordinate space. +void CMeshManipulator::makePlanarTextureMapping(scene::IMesh* mesh, f32 resolution=0.01f) const +{ + if (!mesh) + return; + + const u32 bcount = mesh->getMeshBufferCount(); + for ( u32 b=0; bgetMeshBuffer(b); + u32 vtxcnt = buffer->getVertexCount(); + u32 idxcnt = buffer->getIndexCount(); + u16* idx = buffer->getIndices(); + + switch(buffer->getVertexType()) + { + case video::EVT_STANDARD: + { + video::S3DVertex* v = (video::S3DVertex*)buffer->getVertices(); + makePlanarMappingT(v, vtxcnt, idx, idxcnt, resolution); + } + break; + case video::EVT_2TCOORDS: + { + video::S3DVertex2TCoords* v = (video::S3DVertex2TCoords*)buffer->getVertices(); + makePlanarMappingT(v, vtxcnt, idx, idxcnt, resolution); + } + break; + case video::EVT_TANGENTS: + { + video::S3DVertexTangents* v = (video::S3DVertexTangents*)buffer->getVertices(); + makePlanarMappingT(v, vtxcnt, idx, idxcnt, resolution); + } + break; + } + } +} + + + +//! Creates a copy of the mesh, which will only consist of unique primitives +IMesh* CMeshManipulator::createMeshUniquePrimitives(IMesh* mesh) const +{ + if (!mesh) + return 0; + + SMesh* clone = new SMesh(); + + const u32 meshBufferCount = mesh->getMeshBufferCount(); + + for ( u32 b=0; bgetMeshBuffer(b)->getIndexCount(); + const u16* idx = mesh->getMeshBuffer(b)->getIndices(); + + switch(mesh->getMeshBuffer(b)->getVertexType()) + { + case video::EVT_STANDARD: + { + SMeshBuffer* buffer = new SMeshBuffer(); + buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); + + video::S3DVertex* v = + (video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices(); + + for (s32 i=0; iVertices.push_back( v[idx[i + 0 ]] ); + buffer->Vertices.push_back( v[idx[i + 1 ]] ); + buffer->Vertices.push_back( v[idx[i + 2 ]] ); + + buffer->Indices.push_back( i + 0 ); + buffer->Indices.push_back( i + 1 ); + buffer->Indices.push_back( i + 2 ); + } + + clone->addMeshBuffer(buffer); + buffer->drop(); + } + break; + case video::EVT_2TCOORDS: + { + SMeshBufferLightMap* buffer = new SMeshBufferLightMap(); + buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); + + video::S3DVertex2TCoords* v = + (video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices(); + + for (s32 i=0; iVertices.push_back( v[idx[i + 0 ]] ); + buffer->Vertices.push_back( v[idx[i + 1 ]] ); + buffer->Vertices.push_back( v[idx[i + 2 ]] ); + + buffer->Indices.push_back( i + 0 ); + buffer->Indices.push_back( i + 1 ); + buffer->Indices.push_back( i + 2 ); + } + clone->addMeshBuffer(buffer); + buffer->drop(); + } + break; + case video::EVT_TANGENTS: + { + SMeshBufferTangents* buffer = new SMeshBufferTangents(); + buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); + + video::S3DVertexTangents* v = + (video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices(); + + for (s32 i=0; iVertices.push_back( v[idx[i + 0 ]] ); + buffer->Vertices.push_back( v[idx[i + 1 ]] ); + buffer->Vertices.push_back( v[idx[i + 2 ]] ); + + buffer->Indices.push_back( i + 0 ); + buffer->Indices.push_back( i + 1 ); + buffer->Indices.push_back( i + 2 ); + } + + clone->addMeshBuffer(buffer); + buffer->drop(); + } + break; + }// end switch + + }// end for all mesh buffers + + clone->BoundingBox = mesh->getBoundingBox(); + return clone; +} + + +//! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices. +IMesh* CMeshManipulator::createMeshWithTangents(IMesh* mesh) const +{ + if (!mesh) + return 0; + + // copy mesh and fill data into SMeshBufferTangents + + SMesh* clone = new SMesh(); + const u32 meshBufferCount = mesh->getMeshBufferCount(); + u32 b; + + for (b=0; bgetMeshBuffer(b)->getIndexCount(); + const u16* idx = mesh->getMeshBuffer(b)->getIndices(); + + SMeshBufferTangents* buffer = new SMeshBufferTangents(); + buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); + + // copy vertices + + switch(mesh->getMeshBuffer(b)->getVertexType()) + { + case video::EVT_STANDARD: + { + video::S3DVertex* v = + (video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices(); + + for (s32 i=0; iVertices.push_back( + video::S3DVertexTangents( + v[idx[i]].Pos, v[idx[i]].TCoords, v[idx[i]].Color)); + } + break; + case video::EVT_2TCOORDS: + { + video::S3DVertex2TCoords* v = + (video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices(); + + for (s32 i=0; iVertices.push_back(video::S3DVertexTangents( + v[idx[i]].Pos, v[idx[i]].TCoords, v[idx[i]].Color)); + } + break; + case video::EVT_TANGENTS: + { + video::S3DVertexTangents* v = + (video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices(); + + for (s32 i=0; iVertices.push_back(v[idx[i]]); + } + break; + } + + // create new indices + + buffer->Indices.set_used(idxCnt); + for (s32 i=0; iIndices[i] = i; + + // add new buffer + clone->addMeshBuffer(buffer); + buffer->drop(); + } + + clone->BoundingBox = mesh->getBoundingBox(); + + // now calculate tangents + for (b=0; bgetMeshBuffer(b)->getIndexCount(); + + u16* idx = clone->getMeshBuffer(b)->getIndices(); + video::S3DVertexTangents* v = + (video::S3DVertexTangents*)clone->getMeshBuffer(b)->getVertices(); + + for (s32 i=0; i pl(vt1, vt2, vt3); + + if(normal.dotProduct(pl.Normal) < 0.0f ) + normal *= -1.0f; + +#endif // USE_NVIDIA_GLH_VERSION +} + + + +//! Returns amount of polygons in mesh. +s32 CMeshManipulator::getPolyCount(scene::IMesh* mesh) const +{ + if (!mesh) + return 0; + + s32 trianglecount = 0; + + for (u32 g=0; ggetMeshBufferCount(); ++g) + trianglecount += mesh->getMeshBuffer(g)->getIndexCount() / 3; + + return trianglecount; +} + + + +//! Returns amount of polygons in mesh. +s32 CMeshManipulator::getPolyCount(scene::IAnimatedMesh* mesh) const +{ + if (mesh && mesh->getFrameCount() != 0) + return getPolyCount(mesh->getMesh(0)); + + return 0; +} + +//! create a new AnimatedMesh and adds the mesh to it +IAnimatedMesh * CMeshManipulator::createAnimatedMesh(scene::IMesh* mesh,scene::E_ANIMATED_MESH_TYPE type) const +{ + SAnimatedMesh* animatedMesh = new SAnimatedMesh(); + + animatedMesh->Type = type; + animatedMesh->addMesh(mesh); + animatedMesh->recalculateBoundingBox(); + + //mesh->drop (); + + return animatedMesh; + +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CMeshManipulator.h b/src/dep/src/irrlicht/CMeshManipulator.h index bcf6385..85a5377 100644 --- a/src/dep/src/irrlicht/CMeshManipulator.h +++ b/src/dep/src/irrlicht/CMeshManipulator.h @@ -1,110 +1,110 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_MESH_MANIPULATOR_H_INCLUDED__ -#define __C_MESH_MANIPULATOR_H_INCLUDED__ - -#include "IMeshManipulator.h" - -namespace irr -{ -namespace scene -{ - -//! An interface for easily manipulate meshes. -/** Scale, set alpha value, flip surfaces, and so on. This exists for fixing problems - with wrong imported or exported meshes quickly after loading. It is not intended for doing mesh - modifications and/or animations during runtime. -*/ -class CMeshManipulator : public IMeshManipulator -{ -public: - - //! Constructor - CMeshManipulator(); - - //! destructor - virtual ~CMeshManipulator(); - - //! Flips the direction of surfaces. Changes backfacing triangles to frontfacing - //! triangles and vice versa. - //! \param mesh: Mesh on which the operation is performed. - virtual void flipSurfaces(scene::IMesh* mesh) const; - - //! Sets the alpha vertex color value of the whole mesh to a new value - //! \param mesh: Mesh on which the operation is performed. - //! \param alpha: New alpha for the vertex color. - virtual void setVertexColorAlpha(scene::IMesh* mesh, s32 alpha) const; - - //! Sets the colors of all vertices to one color - virtual void setVertexColors(IMesh* mesh, video::SColor color) const; - - //! Recalculates all normals of the mesh. - /** \param mesh: Mesh on which the operation is performed. - \param smooth: Whether to use smoothed normals. */ - virtual void recalculateNormals(scene::IMesh* mesh, bool smooth = false) const; - - //! Recalculates all normals of the mesh buffer. - /** \param buffer: Mesh buffer on which the operation is performed. - \param smooth: Whether to use smoothed normals. */ - virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false) const; - - //! Scales the whole mesh. - //! \param mesh: Mesh on which the operation is performed. - //! \param scale: 3D Vector, defining the value, for each axis, to scale the mesh by. - virtual void scaleMesh(scene::IMesh* mesh, const core::vector3df& scale) const; - - //! Applies a transformation - /** \param mesh: Mesh on which the operation is performed. - \param m: transformation matrix. */ - virtual void transformMesh(scene::IMesh* mesh, const core::matrix4& m) const; - - //! Clones a static IMesh into a modifiable SMesh. - virtual SMesh* createMeshCopy(scene::IMesh* mesh) const; - - //! Creates a planar texture mapping on the mesh - //! \param mesh: Mesh on which the operation is performed. - //! \param resolution: resolution of the planar mapping. This is the value - //! specifying which is the relation between world space and - //! texture coordinate space. - virtual void makePlanarTextureMapping(scene::IMesh* mesh, f32 resolution) const; - - //! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices. - //! This is useful if you want to draw tangent space normal mapped geometry because - //! it calculates the tangent and binormal data which is needed there. - //! \param mesh: Input mesh - //! \return Mesh consiting only of S3DVertexNormalMapped vertices. - //! If you no longer need the cloned mesh, you should call IMesh::drop(). - //! See IUnknown::drop() for more information. - virtual IMesh* createMeshWithTangents(IMesh* mesh) const; - - virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const; - - //! Recalculates the bounding box for a meshbuffer - virtual void recalculateBoundingBox(scene::IMeshBuffer* buffer) const; - - //! Returns amount of polygons in mesh. - virtual s32 getPolyCount(scene::IMesh* mesh) const; - - //! Returns amount of polygons in mesh. - virtual s32 getPolyCount(scene::IAnimatedMesh* mesh) const; - - //! create a new AnimatedMesh and adds the mesh to it - virtual IAnimatedMesh * createAnimatedMesh(scene::IMesh* mesh,scene::E_ANIMATED_MESH_TYPE type) const; - -private: - - static void calculateTangents(core::vector3df& normal, - core::vector3df& tangent, - core::vector3df& binormal, - core::vector3df& vt1, core::vector3df& vt2, core::vector3df& vt3, - core::vector2df& tc1, core::vector2df& tc2, core::vector2df& tc3); -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_MESH_MANIPULATOR_H_INCLUDED__ +#define __C_MESH_MANIPULATOR_H_INCLUDED__ + +#include "IMeshManipulator.h" + +namespace irr +{ +namespace scene +{ + +//! An interface for easily manipulate meshes. +/** Scale, set alpha value, flip surfaces, and so on. This exists for fixing problems + with wrong imported or exported meshes quickly after loading. It is not intended for doing mesh + modifications and/or animations during runtime. +*/ +class CMeshManipulator : public IMeshManipulator +{ +public: + + //! Constructor + CMeshManipulator(); + + //! destructor + virtual ~CMeshManipulator(); + + //! Flips the direction of surfaces. Changes backfacing triangles to frontfacing + //! triangles and vice versa. + //! \param mesh: Mesh on which the operation is performed. + virtual void flipSurfaces(scene::IMesh* mesh) const; + + //! Sets the alpha vertex color value of the whole mesh to a new value + //! \param mesh: Mesh on which the operation is performed. + //! \param alpha: New alpha for the vertex color. + virtual void setVertexColorAlpha(scene::IMesh* mesh, s32 alpha) const; + + //! Sets the colors of all vertices to one color + virtual void setVertexColors(IMesh* mesh, video::SColor color) const; + + //! Recalculates all normals of the mesh. + /** \param mesh: Mesh on which the operation is performed. + \param smooth: Whether to use smoothed normals. */ + virtual void recalculateNormals(scene::IMesh* mesh, bool smooth = false) const; + + //! Recalculates all normals of the mesh buffer. + /** \param buffer: Mesh buffer on which the operation is performed. + \param smooth: Whether to use smoothed normals. */ + virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false) const; + + //! Scales the whole mesh. + //! \param mesh: Mesh on which the operation is performed. + //! \param scale: 3D Vector, defining the value, for each axis, to scale the mesh by. + virtual void scaleMesh(scene::IMesh* mesh, const core::vector3df& scale) const; + + //! Applies a transformation + /** \param mesh: Mesh on which the operation is performed. + \param m: transformation matrix. */ + virtual void transformMesh(scene::IMesh* mesh, const core::matrix4& m) const; + + //! Clones a static IMesh into a modifiable SMesh. + virtual SMesh* createMeshCopy(scene::IMesh* mesh) const; + + //! Creates a planar texture mapping on the mesh + //! \param mesh: Mesh on which the operation is performed. + //! \param resolution: resolution of the planar mapping. This is the value + //! specifying which is the relation between world space and + //! texture coordinate space. + virtual void makePlanarTextureMapping(scene::IMesh* mesh, f32 resolution) const; + + //! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices. + //! This is useful if you want to draw tangent space normal mapped geometry because + //! it calculates the tangent and binormal data which is needed there. + //! \param mesh: Input mesh + //! \return Mesh consiting only of S3DVertexNormalMapped vertices. + //! If you no longer need the cloned mesh, you should call IMesh::drop(). + //! See IUnknown::drop() for more information. + virtual IMesh* createMeshWithTangents(IMesh* mesh) const; + + virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const; + + //! Recalculates the bounding box for a meshbuffer + virtual void recalculateBoundingBox(scene::IMeshBuffer* buffer) const; + + //! Returns amount of polygons in mesh. + virtual s32 getPolyCount(scene::IMesh* mesh) const; + + //! Returns amount of polygons in mesh. + virtual s32 getPolyCount(scene::IAnimatedMesh* mesh) const; + + //! create a new AnimatedMesh and adds the mesh to it + virtual IAnimatedMesh * createAnimatedMesh(scene::IMesh* mesh,scene::E_ANIMATED_MESH_TYPE type) const; + +private: + + static void calculateTangents(core::vector3df& normal, + core::vector3df& tangent, + core::vector3df& binormal, + core::vector3df& vt1, core::vector3df& vt2, core::vector3df& vt3, + core::vector2df& tc1, core::vector2df& tc2, core::vector2df& tc3); +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CMeshSceneNode.cpp b/src/dep/src/irrlicht/CMeshSceneNode.cpp index 96fd500..7ffdd58 100644 --- a/src/dep/src/irrlicht/CMeshSceneNode.cpp +++ b/src/dep/src/irrlicht/CMeshSceneNode.cpp @@ -1,310 +1,310 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CMeshSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "S3DVertex.h" -#include "ICameraSceneNode.h" -#include "IMeshCache.h" -#include "IAnimatedMesh.h" - -namespace irr -{ -namespace scene -{ - - - -//! constructor -CMeshSceneNode::CMeshSceneNode(IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::vector3df& rotation, - const core::vector3df& scale) -: IMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0), PassCount(0), - ReadOnlyMaterials(false) -{ - #ifdef _DEBUG - setDebugName("CMeshSceneNode"); - #endif - - setMesh(mesh); -} - - - -//! destructor -CMeshSceneNode::~CMeshSceneNode() -{ - if (Mesh) - Mesh->drop(); -} - - - -//! frame -void CMeshSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - // because this node supports rendering of mixed mode meshes consisting of - // transparent and solid material at the same time, we need to go through all - // materials, check of what type they are and register this node for the right - // render pass according to that. - - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - PassCount = 0; - int transparentCount = 0; - int solidCount = 0; - - // count transparent and solid materials in this scene node - if (ReadOnlyMaterials && Mesh) - { - // count mesh materials - - for (u32 i=0; igetMeshBufferCount(); ++i) - { - scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i); - video::IMaterialRenderer* rnd = mb ? driver->getMaterialRenderer(mb->getMaterial().MaterialType) : 0; - - if (rnd && rnd->isTransparent()) - ++transparentCount; - else - ++solidCount; - - if (solidCount && transparentCount) - break; - } - } - else - { - // count copied materials - - for (u32 i=0; igetMaterialRenderer(Materials[i].MaterialType); - - if (rnd && rnd->isTransparent()) - ++transparentCount; - else - ++solidCount; - - if (solidCount && transparentCount) - break; - } - } - - // register according to material types counted - - if (solidCount) - SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID); - - if (transparentCount) - SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT); - - ISceneNode::OnRegisterSceneNode(); - } -} - - - -//! renders the node. -void CMeshSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - if (!Mesh || !driver) - return; - - bool isTransparentPass = - SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; - - ++PassCount; - - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - Box = Mesh->getBoundingBox(); - - // for debug purposes only: - if (DebugDataVisible && PassCount==1) - { - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - driver->draw3DBox(Box, video::SColor(0,255,255,255)); - -#if 0 // draw normals - for (u32 g=0; ggetMeshBufferCount(); ++g) - { - scene::IMeshBuffer* mb = Mesh->getMeshBuffer(g); - - u32 vSize; - u32 i; - vSize = mb->getVertexPitch (); - - const video::S3DVertex* v = ( const video::S3DVertex*)mb->getVertices(); - video::SColor c ( 255, 128 ,0, 0 ); - video::SColor c1 ( 255, 255 ,0, 0 ); - for ( i = 0; i != mb->getVertexCount(); ++i ) - { - core::vector3df h = v->Normal * 5.f; - core::vector3df h1 = h.crossProduct ( core::vector3df ( 0.f, 1.f, 0.f ) ); - - driver->draw3DLine ( v->Pos, v->Pos + h, c ); - driver->draw3DLine ( v->Pos + h, v->Pos + h + h1, c1 ); - v = (const video::S3DVertex*) ( (u8*) v + vSize ); - } - - } -#endif // Draw normals - } - - for (u32 i=0; igetMeshBufferCount(); ++i) - { - scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i); - if (mb) - { - const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i]; - - video::IMaterialRenderer* rnd = driver->getMaterialRenderer(material.MaterialType); - bool transparent = (rnd && rnd->isTransparent()); - - // only render transparent buffer if this is the transparent render pass - // and solid only in solid pass - if (transparent == isTransparentPass) - { - driver->setMaterial(material); - driver->drawMeshBuffer(mb); - } - } - } -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CMeshSceneNode::getBoundingBox() const -{ - return Mesh ? Mesh->getBoundingBox() : Box; -} - - -//! returns the material based on the zero based index i. To get the amount -//! of materials used by this scene node, use getMaterialCount(). -//! This function is needed for inserting the node into the scene hirachy on a -//! optimal position for minimizing renderstate changes, but can also be used -//! to directly modify the material of a scene node. -video::SMaterial& CMeshSceneNode::getMaterial(u32 i) -{ - if (Mesh && ReadOnlyMaterials && igetMeshBufferCount()) - { - tmpReadOnlyMaterial = Mesh->getMeshBuffer(i)->getMaterial(); - return tmpReadOnlyMaterial; - } - - if ( i >= Materials.size()) - return ISceneNode::getMaterial(i); - - return Materials[i]; -} - - - -//! returns amount of materials used by this scene node. -u32 CMeshSceneNode::getMaterialCount() -{ - if (Mesh && ReadOnlyMaterials) - return Mesh->getMeshBufferCount(); - - return Materials.size(); -} - - - -//! Sets a new mesh -void CMeshSceneNode::setMesh(IMesh* mesh) -{ - if (!mesh) - return; // won't set null mesh - - if (Mesh) - Mesh->drop(); - - Mesh = mesh; - copyMaterials(); - - if (Mesh) - Mesh->grab(); -} - - -void CMeshSceneNode::copyMaterials() -{ - Materials.clear(); - - if (Mesh) - { - video::SMaterial mat; - - for (u32 i=0; igetMeshBufferCount(); ++i) - { - IMeshBuffer* mb = Mesh->getMeshBuffer(i); - if (mb) - mat = mb->getMaterial(); - - Materials.push_back(mat); - } - } -} - - -//! Writes attributes of the scene node. -void CMeshSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - IMeshSceneNode::serializeAttributes(out, options); - - out->addString("Mesh", SceneManager->getMeshCache()->getMeshFilename(Mesh)); - out->addBool("ReadOnlyMaterials", ReadOnlyMaterials); -} - -//! Reads attributes of the scene node. -void CMeshSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - core::stringc oldMeshStr = SceneManager->getMeshCache()->getMeshFilename(Mesh); - core::stringc newMeshStr = in->getAttributeAsString("Mesh"); - ReadOnlyMaterials = in->getAttributeAsBool("ReadOnlyMaterials"); - - if (newMeshStr != "" && oldMeshStr != newMeshStr) - { - IMesh* newMesh = 0; - IAnimatedMesh* newAnimatedMesh = SceneManager->getMesh(newMeshStr.c_str()); - - if (newAnimatedMesh) - newMesh = newAnimatedMesh->getMesh(0); - - if (newMesh) - setMesh(newMesh); - } - - IMeshSceneNode::deserializeAttributes(in, options); -} - -//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. -/* In this way it is possible to change the materials a mesh causing all mesh scene nodes -referencing this mesh to change too. */ -void CMeshSceneNode::setReadOnlyMaterials(bool readonly) -{ - ReadOnlyMaterials = readonly; -} - -//! Returns if the scene node should not copy the materials of the mesh but use them in a read only style -bool CMeshSceneNode::isReadOnlyMaterials() -{ - return ReadOnlyMaterials; -} - - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CMeshSceneNode.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" +#include "S3DVertex.h" +#include "ICameraSceneNode.h" +#include "IMeshCache.h" +#include "IAnimatedMesh.h" + +namespace irr +{ +namespace scene +{ + + + +//! constructor +CMeshSceneNode::CMeshSceneNode(IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position, const core::vector3df& rotation, + const core::vector3df& scale) +: IMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0), PassCount(0), + ReadOnlyMaterials(false) +{ + #ifdef _DEBUG + setDebugName("CMeshSceneNode"); + #endif + + setMesh(mesh); +} + + + +//! destructor +CMeshSceneNode::~CMeshSceneNode() +{ + if (Mesh) + Mesh->drop(); +} + + + +//! frame +void CMeshSceneNode::OnRegisterSceneNode() +{ + if (IsVisible) + { + // because this node supports rendering of mixed mode meshes consisting of + // transparent and solid material at the same time, we need to go through all + // materials, check of what type they are and register this node for the right + // render pass according to that. + + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + + PassCount = 0; + int transparentCount = 0; + int solidCount = 0; + + // count transparent and solid materials in this scene node + if (ReadOnlyMaterials && Mesh) + { + // count mesh materials + + for (u32 i=0; igetMeshBufferCount(); ++i) + { + scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i); + video::IMaterialRenderer* rnd = mb ? driver->getMaterialRenderer(mb->getMaterial().MaterialType) : 0; + + if (rnd && rnd->isTransparent()) + ++transparentCount; + else + ++solidCount; + + if (solidCount && transparentCount) + break; + } + } + else + { + // count copied materials + + for (u32 i=0; igetMaterialRenderer(Materials[i].MaterialType); + + if (rnd && rnd->isTransparent()) + ++transparentCount; + else + ++solidCount; + + if (solidCount && transparentCount) + break; + } + } + + // register according to material types counted + + if (solidCount) + SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID); + + if (transparentCount) + SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT); + + ISceneNode::OnRegisterSceneNode(); + } +} + + + +//! renders the node. +void CMeshSceneNode::render() +{ + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + + if (!Mesh || !driver) + return; + + bool isTransparentPass = + SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; + + ++PassCount; + + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + Box = Mesh->getBoundingBox(); + + // for debug purposes only: + if (DebugDataVisible && PassCount==1) + { + video::SMaterial m; + m.Lighting = false; + driver->setMaterial(m); + driver->draw3DBox(Box, video::SColor(0,255,255,255)); + +#if 0 // draw normals + for (u32 g=0; ggetMeshBufferCount(); ++g) + { + scene::IMeshBuffer* mb = Mesh->getMeshBuffer(g); + + u32 vSize; + u32 i; + vSize = mb->getVertexPitch (); + + const video::S3DVertex* v = ( const video::S3DVertex*)mb->getVertices(); + video::SColor c ( 255, 128 ,0, 0 ); + video::SColor c1 ( 255, 255 ,0, 0 ); + for ( i = 0; i != mb->getVertexCount(); ++i ) + { + core::vector3df h = v->Normal * 5.f; + core::vector3df h1 = h.crossProduct ( core::vector3df ( 0.f, 1.f, 0.f ) ); + + driver->draw3DLine ( v->Pos, v->Pos + h, c ); + driver->draw3DLine ( v->Pos + h, v->Pos + h + h1, c1 ); + v = (const video::S3DVertex*) ( (u8*) v + vSize ); + } + + } +#endif // Draw normals + } + + for (u32 i=0; igetMeshBufferCount(); ++i) + { + scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i); + if (mb) + { + const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i]; + + video::IMaterialRenderer* rnd = driver->getMaterialRenderer(material.MaterialType); + bool transparent = (rnd && rnd->isTransparent()); + + // only render transparent buffer if this is the transparent render pass + // and solid only in solid pass + if (transparent == isTransparentPass) + { + driver->setMaterial(material); + driver->drawMeshBuffer(mb); + } + } + } +} + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CMeshSceneNode::getBoundingBox() const +{ + return Mesh ? Mesh->getBoundingBox() : Box; +} + + +//! returns the material based on the zero based index i. To get the amount +//! of materials used by this scene node, use getMaterialCount(). +//! This function is needed for inserting the node into the scene hirachy on a +//! optimal position for minimizing renderstate changes, but can also be used +//! to directly modify the material of a scene node. +video::SMaterial& CMeshSceneNode::getMaterial(u32 i) +{ + if (Mesh && ReadOnlyMaterials && igetMeshBufferCount()) + { + tmpReadOnlyMaterial = Mesh->getMeshBuffer(i)->getMaterial(); + return tmpReadOnlyMaterial; + } + + if ( i >= Materials.size()) + return ISceneNode::getMaterial(i); + + return Materials[i]; +} + + + +//! returns amount of materials used by this scene node. +u32 CMeshSceneNode::getMaterialCount() +{ + if (Mesh && ReadOnlyMaterials) + return Mesh->getMeshBufferCount(); + + return Materials.size(); +} + + + +//! Sets a new mesh +void CMeshSceneNode::setMesh(IMesh* mesh) +{ + if (!mesh) + return; // won't set null mesh + + if (Mesh) + Mesh->drop(); + + Mesh = mesh; + copyMaterials(); + + if (Mesh) + Mesh->grab(); +} + + +void CMeshSceneNode::copyMaterials() +{ + Materials.clear(); + + if (Mesh) + { + video::SMaterial mat; + + for (u32 i=0; igetMeshBufferCount(); ++i) + { + IMeshBuffer* mb = Mesh->getMeshBuffer(i); + if (mb) + mat = mb->getMaterial(); + + Materials.push_back(mat); + } + } +} + + +//! Writes attributes of the scene node. +void CMeshSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + IMeshSceneNode::serializeAttributes(out, options); + + out->addString("Mesh", SceneManager->getMeshCache()->getMeshFilename(Mesh)); + out->addBool("ReadOnlyMaterials", ReadOnlyMaterials); +} + +//! Reads attributes of the scene node. +void CMeshSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + core::stringc oldMeshStr = SceneManager->getMeshCache()->getMeshFilename(Mesh); + core::stringc newMeshStr = in->getAttributeAsString("Mesh"); + ReadOnlyMaterials = in->getAttributeAsBool("ReadOnlyMaterials"); + + if (newMeshStr != "" && oldMeshStr != newMeshStr) + { + IMesh* newMesh = 0; + IAnimatedMesh* newAnimatedMesh = SceneManager->getMesh(newMeshStr.c_str()); + + if (newAnimatedMesh) + newMesh = newAnimatedMesh->getMesh(0); + + if (newMesh) + setMesh(newMesh); + } + + IMeshSceneNode::deserializeAttributes(in, options); +} + +//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. +/* In this way it is possible to change the materials a mesh causing all mesh scene nodes +referencing this mesh to change too. */ +void CMeshSceneNode::setReadOnlyMaterials(bool readonly) +{ + ReadOnlyMaterials = readonly; +} + +//! Returns if the scene node should not copy the materials of the mesh but use them in a read only style +bool CMeshSceneNode::isReadOnlyMaterials() +{ + return ReadOnlyMaterials; +} + + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CMeshSceneNode.h b/src/dep/src/irrlicht/CMeshSceneNode.h index 39ca2ae..d4b78fe 100644 --- a/src/dep/src/irrlicht/CMeshSceneNode.h +++ b/src/dep/src/irrlicht/CMeshSceneNode.h @@ -1,89 +1,89 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_MESH_SCENE_NODE_H_INCLUDED__ -#define __C_MESH_SCENE_NODE_H_INCLUDED__ - -#include "IMeshSceneNode.h" -#include "IMesh.h" - -namespace irr -{ -namespace scene -{ - - class CMeshSceneNode : public IMeshSceneNode - { - public: - - //! constructor - CMeshSceneNode(IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! destructor - virtual ~CMeshSceneNode(); - - //! frame - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! returns the material based on the zero based index i. To get the amount - //! of materials used by this scene node, use getMaterialCount(). - //! This function is needed for inserting the node into the scene hirachy on a - //! optimal position for minimizing renderstate changes, but can also be used - //! to directly modify the material of a scene node. - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount(); - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_MESH; } - - //! Sets a new mesh - virtual void setMesh(IMesh* mesh); - - //! Returns the current mesh - virtual IMesh* getMesh(void) { return Mesh; } - - //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. - /* In this way it is possible to change the materials a mesh causing all mesh scene nodes - referencing this mesh to change too. */ - virtual void setReadOnlyMaterials(bool readonly); - - //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style - virtual bool isReadOnlyMaterials(); - - protected: - - void copyMaterials(); - - core::array Materials; - core::aabbox3d Box; - video::SMaterial tmpReadOnlyMaterial; - - IMesh* Mesh; - - s32 PassCount; - bool ReadOnlyMaterials; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_MESH_SCENE_NODE_H_INCLUDED__ +#define __C_MESH_SCENE_NODE_H_INCLUDED__ + +#include "IMeshSceneNode.h" +#include "IMesh.h" + +namespace irr +{ +namespace scene +{ + + class CMeshSceneNode : public IMeshSceneNode + { + public: + + //! constructor + CMeshSceneNode(IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); + + //! destructor + virtual ~CMeshSceneNode(); + + //! frame + virtual void OnRegisterSceneNode(); + + //! renders the node. + virtual void render(); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! returns the material based on the zero based index i. To get the amount + //! of materials used by this scene node, use getMaterialCount(). + //! This function is needed for inserting the node into the scene hirachy on a + //! optimal position for minimizing renderstate changes, but can also be used + //! to directly modify the material of a scene node. + virtual video::SMaterial& getMaterial(u32 i); + + //! returns amount of materials used by this scene node. + virtual u32 getMaterialCount(); + + //! Writes attributes of the scene node. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_MESH; } + + //! Sets a new mesh + virtual void setMesh(IMesh* mesh); + + //! Returns the current mesh + virtual IMesh* getMesh(void) { return Mesh; } + + //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. + /* In this way it is possible to change the materials a mesh causing all mesh scene nodes + referencing this mesh to change too. */ + virtual void setReadOnlyMaterials(bool readonly); + + //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style + virtual bool isReadOnlyMaterials(); + + protected: + + void copyMaterials(); + + core::array Materials; + core::aabbox3d Box; + video::SMaterial tmpReadOnlyMaterial; + + IMesh* Mesh; + + s32 PassCount; + bool ReadOnlyMaterials; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CMetaTriangleSelector.cpp b/src/dep/src/irrlicht/CMetaTriangleSelector.cpp index 57c3565..ba4c872 100644 --- a/src/dep/src/irrlicht/CMetaTriangleSelector.cpp +++ b/src/dep/src/irrlicht/CMetaTriangleSelector.cpp @@ -1,140 +1,140 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CMetaTriangleSelector.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CMetaTriangleSelector::CMetaTriangleSelector() -{ - #ifdef _DEBUG - setDebugName("CMetaTriangleSelector"); - #endif -} - -//! destructor -CMetaTriangleSelector::~CMetaTriangleSelector() -{ - removeAllTriangleSelectors(); -} - - - -//! Returns amount of all available triangles in this selector -s32 CMetaTriangleSelector::getTriangleCount() const -{ - s32 count = 0; - for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i) - count += TriangleSelectors[i]->getTriangleCount(); - - return count; -} - - - -//! Gets all triangles. -void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::matrix4* transform) -{ - s32 outWritten = 0; - - for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i) - { - s32 t = 0; - TriangleSelectors[i]->getTriangles(triangles + outWritten, arraySize - outWritten, t, transform); - outWritten += t; - } - - outTriangleCount = outWritten; -} - - - -//! Gets all triangles which lie within a specific bounding box. -void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::aabbox3d& box, - const core::matrix4* transform) -{ - s32 outWritten = 0; - - for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i) - { - s32 t = 0; - TriangleSelectors[i]->getTriangles(triangles + outWritten, arraySize - outWritten, t, - box, transform); - outWritten += t; - } - - outTriangleCount = outWritten; -} - - - -//! Gets all triangles which have or may have contact with a 3d line. -void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d& line, - const core::matrix4* transform) -{ - s32 outWritten = 0; - - for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i) - { - s32 t = 0; - TriangleSelectors[i]->getTriangles(triangles + outWritten, arraySize - outWritten, t, - line, transform); - outWritten += t; - } - - outTriangleCount = outWritten; -} - - - -//! Adds a triangle selector to the collection of triangle selectors -//! in this metaTriangleSelector. -void CMetaTriangleSelector::addTriangleSelector(ITriangleSelector* toAdd) -{ - if (!toAdd) - return; - - TriangleSelectors.push_back(toAdd); - toAdd->grab(); -} - - - -//! Removes a specific triangle selector which was added before from the collection. -bool CMetaTriangleSelector::removeTriangleSelector(ITriangleSelector* toRemove) -{ - for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i) - if (toRemove == TriangleSelectors[i]) - { - TriangleSelectors[i]->drop(); - TriangleSelectors.erase(i); - return true; - } - - return false; -} - - - -//! Removes all triangle selectors from the collection. -void CMetaTriangleSelector::removeAllTriangleSelectors() -{ - for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i) - TriangleSelectors[i]->drop(); - - TriangleSelectors.clear(); -} - - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CMetaTriangleSelector.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CMetaTriangleSelector::CMetaTriangleSelector() +{ + #ifdef _DEBUG + setDebugName("CMetaTriangleSelector"); + #endif +} + +//! destructor +CMetaTriangleSelector::~CMetaTriangleSelector() +{ + removeAllTriangleSelectors(); +} + + + +//! Returns amount of all available triangles in this selector +s32 CMetaTriangleSelector::getTriangleCount() const +{ + s32 count = 0; + for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i) + count += TriangleSelectors[i]->getTriangleCount(); + + return count; +} + + + +//! Gets all triangles. +void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::matrix4* transform) +{ + s32 outWritten = 0; + + for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i) + { + s32 t = 0; + TriangleSelectors[i]->getTriangles(triangles + outWritten, arraySize - outWritten, t, transform); + outWritten += t; + } + + outTriangleCount = outWritten; +} + + + +//! Gets all triangles which lie within a specific bounding box. +void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::aabbox3d& box, + const core::matrix4* transform) +{ + s32 outWritten = 0; + + for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i) + { + s32 t = 0; + TriangleSelectors[i]->getTriangles(triangles + outWritten, arraySize - outWritten, t, + box, transform); + outWritten += t; + } + + outTriangleCount = outWritten; +} + + + +//! Gets all triangles which have or may have contact with a 3d line. +void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::line3d& line, + const core::matrix4* transform) +{ + s32 outWritten = 0; + + for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i) + { + s32 t = 0; + TriangleSelectors[i]->getTriangles(triangles + outWritten, arraySize - outWritten, t, + line, transform); + outWritten += t; + } + + outTriangleCount = outWritten; +} + + + +//! Adds a triangle selector to the collection of triangle selectors +//! in this metaTriangleSelector. +void CMetaTriangleSelector::addTriangleSelector(ITriangleSelector* toAdd) +{ + if (!toAdd) + return; + + TriangleSelectors.push_back(toAdd); + toAdd->grab(); +} + + + +//! Removes a specific triangle selector which was added before from the collection. +bool CMetaTriangleSelector::removeTriangleSelector(ITriangleSelector* toRemove) +{ + for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i) + if (toRemove == TriangleSelectors[i]) + { + TriangleSelectors[i]->drop(); + TriangleSelectors.erase(i); + return true; + } + + return false; +} + + + +//! Removes all triangle selectors from the collection. +void CMetaTriangleSelector::removeAllTriangleSelectors() +{ + for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i) + TriangleSelectors[i]->drop(); + + TriangleSelectors.clear(); +} + + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CMetaTriangleSelector.h b/src/dep/src/irrlicht/CMetaTriangleSelector.h index 3d95ada..19ab2ca 100644 --- a/src/dep/src/irrlicht/CMetaTriangleSelector.h +++ b/src/dep/src/irrlicht/CMetaTriangleSelector.h @@ -1,64 +1,64 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_META_TRIANGLE_SELECTOR_H_INCLUDED__ -#define __C_META_TRIANGLE_SELECTOR_H_INCLUDED__ - -#include "IMetaTriangleSelector.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - -//! Interface for making multiple triangle selectors work as one big selector. -class CMetaTriangleSelector : public IMetaTriangleSelector -{ -public: - - //! constructor - CMetaTriangleSelector(); - - //! destructor - virtual ~CMetaTriangleSelector(); - - //! Returns amount of all available triangles in this selector - virtual s32 getTriangleCount() const; - - //! Gets all triangles. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::matrix4* transform=0); - - //! Gets all triangles which lie within a specific bounding box. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::aabbox3d& box, - const core::matrix4* transform=0); - - //! Gets all triangles which have or may have contact with a 3d line. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d& line, - const core::matrix4* transform=0); - - //! Adds a triangle selector to the collection of triangle selectors - //! in this metaTriangleSelector. - virtual void addTriangleSelector(ITriangleSelector* toAdd); - - //! Removes a specific triangle selector which was added before from the collection. - virtual bool removeTriangleSelector(ITriangleSelector* toRemove); - - //! Removes all triangle selectors from the collection. - virtual void removeAllTriangleSelectors(); - -private: - - core::array TriangleSelectors; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_META_TRIANGLE_SELECTOR_H_INCLUDED__ +#define __C_META_TRIANGLE_SELECTOR_H_INCLUDED__ + +#include "IMetaTriangleSelector.h" +#include "irrArray.h" + +namespace irr +{ +namespace scene +{ + +//! Interface for making multiple triangle selectors work as one big selector. +class CMetaTriangleSelector : public IMetaTriangleSelector +{ +public: + + //! constructor + CMetaTriangleSelector(); + + //! destructor + virtual ~CMetaTriangleSelector(); + + //! Returns amount of all available triangles in this selector + virtual s32 getTriangleCount() const; + + //! Gets all triangles. + virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::matrix4* transform=0); + + //! Gets all triangles which lie within a specific bounding box. + virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::aabbox3d& box, + const core::matrix4* transform=0); + + //! Gets all triangles which have or may have contact with a 3d line. + virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::line3d& line, + const core::matrix4* transform=0); + + //! Adds a triangle selector to the collection of triangle selectors + //! in this metaTriangleSelector. + virtual void addTriangleSelector(ITriangleSelector* toAdd); + + //! Removes a specific triangle selector which was added before from the collection. + virtual bool removeTriangleSelector(ITriangleSelector* toRemove); + + //! Removes all triangle selectors from the collection. + virtual void removeAllTriangleSelectors(); + +private: + + core::array TriangleSelectors; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CNullDriver.cpp b/src/dep/src/irrlicht/CNullDriver.cpp index 294e502..a67df37 100644 --- a/src/dep/src/irrlicht/CNullDriver.cpp +++ b/src/dep/src/irrlicht/CNullDriver.cpp @@ -1,1693 +1,1693 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CNullDriver.h" -#include "CSoftwareTexture.h" -#include "os.h" -#include "CImage.h" -#include "CAttributes.h" -#include "IWriteFile.h" - - -namespace irr -{ -namespace video -{ - -//! creates a loader which is able to load windows bitmaps -IImageLoader* createImageLoaderBMP(); - -//! creates a loader which is able to load jpeg images -IImageLoader* createImageLoaderJPG(); - -//! creates a loader which is able to load targa images -IImageLoader* createImageLoaderTGA(); - -//! creates a loader which is able to load psd images -IImageLoader* createImageLoaderPSD(); - -//! creates a loader which is able to load pcx images -IImageLoader* createImageLoaderPCX(); - -//! creates a loader which is able to load png images -IImageLoader* createImageLoaderPNG(); - - -//! creates a loader which is able to load bmp images -IImageWriter* createImageWriterBMP(); - -//! creates a loader which is able to load jpg images -IImageWriter* createImageWriterJPG(); - -//! creates a loader which is able to load tga images -IImageWriter* createImageWriterTGA(); - -//! creates a loader which is able to load psd images -IImageWriter* createImageWriterPSD(); - -//! creates a loader which is able to load pcx images -IImageWriter* createImageWriterPCX(); - -//! creates a loader which is able to load png images -IImageWriter* createImageWriterPNG(); - -//! creates a loader which is able to load ppm images -IImageWriter* createImageWriterPPM(); - - - -//! Array holding the built in material type names -const char* const sBuiltInMaterialTypeNames[] = -{ - "solid", - "solid_2layer", - "lightmap", - "lightmap_add", - "lightmap_m2", - "lightmap_m4", - "lightmap_light", - "lightmap_light_m2", - "lightmap_light_m4", - "detail_map", - "sphere_map", - "reflection_2layer", - "trans_add", - "trans_alphach", - "trans_alphach_ref", - "trans_vertex_alpha", - "trans_reflection_2layer", - "normalmap_solid", - "normalmap_trans_add", - "normalmap_trans_vertexalpha", - "parallaxmap_solid", - "parallaxmap_trans_add", - "parallaxmap_trans_vertexalpha" -}; - - -//! constructor -CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d& screenSize) -: FileSystem(io), ViewPort(0,0,0,0), ScreenSize(screenSize), - PrimitivesDrawn(0), TextureCreationFlags(0) -{ - #ifdef _DEBUG - setDebugName("CNullDriver"); - #endif - - setFog(); - - setTextureCreationFlag(ETCF_ALWAYS_32_BIT, true); - setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, true); - - ViewPort = core::rect(core::position2d(0,0), screenSize); - - if (FileSystem) - FileSystem->grab(); - - // create surface loader - - SurfaceLoader.push_back(video::createImageLoaderBMP()); - SurfaceLoader.push_back(video::createImageLoaderJPG()); - SurfaceLoader.push_back(video::createImageLoaderTGA()); - SurfaceLoader.push_back(video::createImageLoaderPSD()); - SurfaceLoader.push_back(video::createImageLoaderPCX()); - SurfaceLoader.push_back(video::createImageLoaderPNG()); - - SurfaceWriter.push_back(video::createImageWriterBMP()); - SurfaceWriter.push_back(video::createImageWriterJPG()); - SurfaceWriter.push_back(video::createImageWriterTGA()); - SurfaceWriter.push_back(video::createImageWriterPSD()); - SurfaceWriter.push_back(video::createImageWriterPCX()); - SurfaceWriter.push_back(video::createImageWriterPNG()); - SurfaceWriter.push_back(video::createImageWriterPPM()); - - // set ExposedData to 0 - memset(&ExposedData, 0, sizeof(ExposedData)); -} - - - -//! destructor -CNullDriver::~CNullDriver() -{ - // delete file system - - if (FileSystem) - FileSystem->drop(); - - // delete textures - - deleteAllTextures(); - - // delete surface loader - - u32 i; - for (i=0; idrop(); - - // delete surface writer - - for (i=0; idrop(); - - deleteMaterialRenders(); -} - - -//! Adds an external surface loader to the engine. -void CNullDriver::addExternalImageLoader(IImageLoader* loader) -{ - if (!loader) - return; - - loader->grab(); - SurfaceLoader.push_back(loader); -} - - -//! Adds an external surface writer to the engine. -void CNullDriver::addExternalImageWriter(IImageWriter* writer) -{ - if (!writer) - return; - - writer->grab(); - SurfaceWriter.push_back(writer); -} - - -//! deletes all textures -void CNullDriver::deleteAllTextures() -{ - for (u32 i=0; idrop(); - - Textures.clear(); -} - - - -//! applications must call this method before performing any rendering. returns false if failed. -bool CNullDriver::beginScene(bool backBuffer, bool zBuffer, SColor color) -{ - core::clearFPUException (); - PrimitivesDrawn = 0; - return true; -} - - - -//! applications must call this method after performing any rendering. returns false if failed. -bool CNullDriver::endScene( s32 windowId, core::rect* sourceRect ) -{ - FPSCounter.registerFrame(os::Timer::getRealTime(), PrimitivesDrawn); - return true; -} - - - -//! queries the features of the driver, returns true if feature is available -bool CNullDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) -{ - return false; -} - - - -//! sets transformation -void CNullDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) -{ -} - - -//! Returns the transformation set by setTransform -const core::matrix4& CNullDriver::getTransform(E_TRANSFORMATION_STATE state) -{ - return TransformationMatrix; -} - - - -//! sets a material -void CNullDriver::setMaterial(const SMaterial& material) -{ -} - - - -//! Removes a texture from the texture cache and deletes it, freeing lot of -//! memory. -void CNullDriver::removeTexture(ITexture* texture) -{ - for (u32 i=0; idrop(); - Textures.erase(i); - } -} - - -//! Removes all texture from the texture cache and deletes them, freeing lot of -//! memory. -void CNullDriver::removeAllTextures() -{ - deleteAllTextures(); -} - - -//! Returns a texture by index -ITexture* CNullDriver::getTextureByIndex(u32 i) -{ - if ( i < Textures.size() ) - return Textures[i].Surface; - - return 0; -} - - -//! Returns amount of textures currently loaded -s32 CNullDriver::getTextureCount() -{ - return Textures.size(); -} - - -//! loads a Texture -ITexture* CNullDriver::getTexture(const c8* filename) -{ - ITexture* texture = findTexture(filename); - - if (texture) - return texture; - - io::IReadFile* file = FileSystem->createAndOpenFile(filename); - bool errorReported = false; - - if (file) - { - texture = loadTextureFromFile(file, filename); - file->drop(); - - if (texture) - { - addTexture(texture); - texture->drop(); // drop it becaus we created it, one grab too much - } - } - else - { - errorReported = true; - os::Printer::log("Could not open file of texture", filename, ELL_ERROR); - } - - if (!texture && !errorReported) - os::Printer::log("Could not load texture", filename, ELL_ERROR); - - return texture; -} - - - -//! loads a Texture -ITexture* CNullDriver::getTexture(io::IReadFile* file) -{ - ITexture* texture = 0; - - if (file) - { - texture = findTexture(file->getFileName()); - - if (texture) - return texture; - - texture = loadTextureFromFile(file ); - - if (texture) - { - addTexture(texture); - texture->drop(); // drop it because we created it, one grab too much - } - } - - if (!texture) - os::Printer::log("Could not load texture", file->getFileName(), ELL_ERROR); - - return texture; -} - - - -//! opens the file and loads it into the surface -video::ITexture* CNullDriver::loadTextureFromFile(io::IReadFile* file, const c8 *hashName ) -{ - ITexture* texture = 0; - IImage* image = createImageFromFile(file); - - if (image) - { - // create texture from surface - texture = createDeviceDependentTexture(image, hashName ? hashName : file->getFileName() ); - os::Printer::log("Loaded texture", file->getFileName()); - image->drop(); - } - - return texture; -} - - - -//! adds a surface, not loaded or created by the Irrlicht Engine -void CNullDriver::addTexture(video::ITexture* texture) -{ - if (texture) - { - SSurface s; - s.Surface = texture; - texture->grab(); - - Textures.push_back(s); - - // the new texture is now at the end of the texture list. when searching for - // the next new texture, the texture array will be sorted and the index of this texture - // will be changed. to let the order be more consistent to the user, sort - // the textures now already although this isn't necessary: - - Textures.sort(); - } -} - - - -//! looks if the image is already loaded -video::ITexture* CNullDriver::findTexture(const c8* filename) -{ - if (!filename) - filename = ""; - - SSurface s; - SDummyTexture dummy(filename); - s.Surface = &dummy; - - s32 index = Textures.binary_search(s); - if (index != -1) - return Textures[index].Surface; - - return 0; -} - - - -//! Creates a texture from a loaded IImage. -ITexture* CNullDriver::addTexture(const c8* name, IImage* image) -{ - if (!name || !image) - return 0; - - ITexture* t = createDeviceDependentTexture(image, name); - addTexture(t); - t->drop(); - return t; -} - - - -//! creates a Texture -ITexture* CNullDriver::addTexture(const core::dimension2d& size, - const c8* name, ECOLOR_FORMAT format) -{ - if (!name) - return 0; - - IImage* image = new CImage(format, size); - ITexture* t = createDeviceDependentTexture(image, name); - image->drop(); - addTexture(t); - - if (t) - t->drop(); - - return t; -} - - - -//! returns a device dependent texture from a software surface (IImage) -//! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES -ITexture* CNullDriver::createDeviceDependentTexture(IImage* surface, const char* name) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CSoftwareTexture(surface, name); - #else - return 0; - #endif -} - - - -//! sets a render target -bool CNullDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color) -{ - return false; -} - - - -//! sets a viewport -void CNullDriver::setViewPort(const core::rect& area) -{ -} - - - -//! gets the area of the current viewport -const core::rect& CNullDriver::getViewPort() const -{ - return ViewPort; -} - - - -//! draws a vertex primitive list -void CNullDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) -{ - PrimitivesDrawn += primitiveCount; -} - - - -//! draws an indexed triangle list -inline void CNullDriver::drawIndexedTriangleList(const S3DVertex* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLES); -} - - - -//! draws an indexed triangle list -inline void CNullDriver::drawIndexedTriangleList(const S3DVertex2TCoords* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLES); -} - - -//! Draws an indexed triangle list. -inline void CNullDriver::drawIndexedTriangleList(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLES); -} - - - -//! Draws an indexed triangle fan. -inline void CNullDriver::drawIndexedTriangleFan(const S3DVertex* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLE_FAN); -} - - - -//! Draws an indexed triangle fan. -inline void CNullDriver::drawIndexedTriangleFan(const S3DVertex2TCoords* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLE_FAN); -} - - - -//! Draws an indexed triangle fan. -inline void CNullDriver::drawIndexedTriangleFan(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLE_FAN); -} - - - -//! Draws a 3d line. -void CNullDriver::draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color) -{ -} - - - -//! Draws a 3d triangle. -void CNullDriver::draw3DTriangle(const core::triangle3df& triangle, SColor color) -{ - draw3DLine(triangle.pointA, triangle.pointB, color); - draw3DLine(triangle.pointB, triangle.pointC, color); - draw3DLine(triangle.pointC, triangle.pointA, color); -} - - - -//! Draws a 3d axis aligned box. -void CNullDriver::draw3DBox(const core::aabbox3d box, SColor color) -{ - core::vector3df edges[8]; - box.getEdges(edges); - - // TODO: optimize into one big drawIndexPrimitive call. - - draw3DLine(edges[5], edges[1], color); - draw3DLine(edges[1], edges[3], color); - draw3DLine(edges[3], edges[7], color); - draw3DLine(edges[7], edges[5], color); - draw3DLine(edges[0], edges[2], color); - draw3DLine(edges[2], edges[6], color); - draw3DLine(edges[6], edges[4], color); - draw3DLine(edges[4], edges[0], color); - draw3DLine(edges[1], edges[0], color); - draw3DLine(edges[3], edges[2], color); - draw3DLine(edges[7], edges[6], color); - draw3DLine(edges[5], edges[4], color); -} - - - -//! draws an 2d image -void CNullDriver::draw2DImage(video::ITexture* texture, const core::position2d& destPos) -{ - if (!texture) - return; - - draw2DImage(texture,destPos, core::rect(core::position2d(0,0), texture->getOriginalSize())); -} - - - -//! draws a set of 2d images, using a color and the alpha channel of the -//! texture if desired. The images are drawn beginning at pos and concatenated -//! in one line. All drawings are clipped against clipRect (if != 0). -//! The subtextures are defined by the array of sourceRects and are chosen -//! by the indices given. -void CNullDriver::draw2DImage(video::ITexture* texture, - const core::position2d& pos, - const core::array >& sourceRects, - const core::array& indices, - s32 kerningWidth, - const core::rect* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - core::position2d target(pos); - - for (u32 i=0; i& destRect, - const core::rect& sourceRect, const core::rect* clipRect, - video::SColor* colors, bool useAlphaChannelOfTexture) -{ -} - - - -//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. -void CNullDriver::draw2DImage(video::ITexture* texture, const core::position2d& destPos, - const core::rect& sourceRect, - const core::rect* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ -} - - - -//! draw an 2d rectangle -void CNullDriver::draw2DRectangle(SColor color, const core::rect& pos, const core::rect* clip) -{ - draw2DRectangle(pos, color, color, color, color, clip); -} - - - -//!Draws an 2d rectangle with a gradient. -void CNullDriver::draw2DRectangle(const core::rect& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect* clip) -{ -} - - - -//! Draws a 2d line. -void CNullDriver::draw2DLine(const core::position2d& start, - const core::position2d& end, SColor color) -{ -} - - - -//! Draws a non filled concyclic regular 2d polyon. -void CNullDriver::draw2DPolygon(core::position2d center, - f32 radius, video::SColor color, s32 count) -{ - if (count < 2) - return; - - core::position2d first; - core::position2d a,b; - - for (s32 j=0; j((s32)(sin(p)*radius), (s32)(cos(p)*radius)); - - if (j==0) - first = a; - else - draw2DLine(a, b, color); - } - - draw2DLine(a, first, color); -} - - - - -//! returns screen size -core::dimension2d CNullDriver::getScreenSize() -{ - return ScreenSize; -} - -//! returns the current render target size, -//! or the screen size if render targets are not implemented -core::dimension2d CNullDriver::getCurrentRenderTargetSize() -{ - return ScreenSize; -} - - -// returns current frames per second value -s32 CNullDriver::getFPS() -{ - return FPSCounter.getFPS(); -} - - - -//! returns amount of primitives (mostly triangles) were drawn in the last frame. -//! very useful method for statistics. -u32 CNullDriver::getPrimitiveCountDrawn( u32 param ) -{ - return 0 == param ? FPSCounter.getPrimitive() : FPSCounter.getPrimitiveAverage(); -} - - - -//! Sets the dynamic ambient light color. The default color is -//! (0,0,0,0) which means it is dark. -//! \param color: New color of the ambient light. -void CNullDriver::setAmbientLight(const SColorf& color) -{ -} - - - -//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 -//! driver, it would return "Direct3D8". -const wchar_t* CNullDriver::getName() -{ - return L"Irrlicht NullDevice"; -} - - - -//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do -//! this: Frist, draw all geometry. Then use this method, to draw the shadow -//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. -void CNullDriver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail) -{ -} - - -//! Fills the stencil shadow with color. After the shadow volume has been drawn -//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this -//! to draw the color of the shadow. -void CNullDriver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge, - video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge) -{ -} - - -//! deletes all dynamic lights there are -void CNullDriver::deleteAllDynamicLights() -{ - Lights.set_used(0); -} - - - -//! adds a dynamic light -void CNullDriver::addDynamicLight(const SLight& light) -{ - Lights.push_back(light); -} - - - -//! returns the maximal amount of dynamic lights the device can handle -u32 CNullDriver::getMaximalDynamicLightAmount() -{ - return 0; -} - -//! Returns current amount of dynamic lights set -//! \return Current amount of dynamic lights set -u32 CNullDriver::getDynamicLightCount() -{ - return Lights.size(); -} - -//! Returns light data which was previously set with IVideDriver::addDynamicLight(). -//! \param idx: Zero based index of the light. Must be greater than 0 and smaller -//! than IVideoDriver()::getDynamicLightCount. -//! \return Light data. -const SLight& CNullDriver::getDynamicLight(u32 idx) -{ - if ( idx < Lights.size() ) - return Lights[idx]; - - return *((SLight*)0); -} - - -//! Creates an 1bit alpha channel of the texture based of an color key. -void CNullDriver::makeColorKeyTexture(video::ITexture* texture, video::SColor color) -{ - if (!texture) - return; - - if (texture->getColorFormat() != ECF_A1R5G5B5 && - texture->getColorFormat() != ECF_A8R8G8B8 ) - { - os::Printer::log("Error: Unsupported texture color format for making color key channel.", ELL_ERROR); - return; - } - - if (texture->getColorFormat() == ECF_A1R5G5B5) - { - s16 *p = (s16*)texture->lock(); - - if (!p) - { - os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); - return; - } - - core::dimension2d dim = texture->getSize(); - s32 pitch = texture->getPitch() / 2; - - // color with alpha enabled (color opaque) - s16 ref = (0x1<<15) | (0x7fff & color.toA1R5G5B5()); - - for (s32 y=0; yunlock(); - } - else - { - s32 *p = (s32*)texture->lock(); - - if (!p) - { - os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); - return; - } - - core::dimension2d dim = texture->getSize(); - s32 pitch = texture->getPitch() / 4; - - // color with alpha enabled (color opaque) - s32 ref = (0xff<<24) | (0x00ffffff & color.color); - - for (s32 y=0; yunlock(); - } -} - - - -//! Creates an 1bit alpha channel of the texture based of an color key position. -void CNullDriver::makeColorKeyTexture(video::ITexture* texture, - core::position2d colorKeyPixelPos) -{ - if (!texture) - return; - - if (texture->getColorFormat() != ECF_A1R5G5B5 && - texture->getColorFormat() != ECF_A8R8G8B8 ) - { - os::Printer::log("Error: Unsupported texture color format for making color key channel.", ELL_ERROR); - return; - } - - if (texture->getColorFormat() == ECF_A1R5G5B5) - { - s16 *p = (s16*)texture->lock(); - - if (!p) - { - os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); - return; - } - - core::dimension2d dim = texture->getSize(); - s32 pitch = texture->getPitch() / 2; - - s16 ref = (0x1<<15) | (0x7fff & p[colorKeyPixelPos.Y*dim.Width + colorKeyPixelPos.X]); - - for (s32 y=0; yunlock(); - } - else - { - s32 *p = (s32*)texture->lock(); - - if (!p) - { - os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); - return; - } - - core::dimension2d dim = texture->getSize(); - s32 pitch = texture->getPitch() / 4; - - s32 ref = (0xff<<24) | (0x00ffffff & p[colorKeyPixelPos.Y*dim.Width + colorKeyPixelPos.X]); - - for (s32 y=0; yunlock(); - } -} - - - -//! Creates a normal map from a height map texture. -//! \param amplitude: Constant value by which the height information is multiplied. -void CNullDriver::makeNormalMapTexture(video::ITexture* texture, f32 amplitude) -{ - if (!texture) - return; - - if (texture->getColorFormat() != ECF_A1R5G5B5 && - texture->getColorFormat() != ECF_A8R8G8B8 ) - { - os::Printer::log("Error: Unsupported texture color format for making normal map.", ELL_ERROR); - return; - } - - core::dimension2d dim = texture->getSize(); - amplitude = amplitude / 255.0f; - f32 vh = dim.Height / (f32)dim.Width; - f32 hh = dim.Width / (f32)dim.Height; - - if (texture->getColorFormat() == ECF_A8R8G8B8) - { - // ECF_A8R8G8B8 version - - s32 *p = (s32*)texture->lock(); - - if (!p) - { - os::Printer::log("Could not lock texture for making normal map.", ELL_ERROR); - return; - } - - // copy texture - - s32 pitch = texture->getPitch() / 4; - - s32* in = new s32[dim.Height * pitch]; - memcpy(in, p, dim.Height * pitch * 4); - - for (s32 x=0; xunlock(); - } - else - { - // ECF_A1R5G5B5 version - - s16 *p = (s16*)texture->lock(); - - if (!p) - { - os::Printer::log("Could not lock texture for making normal map.", ELL_ERROR); - return; - } - - s32 pitch = texture->getPitch() / 2; - - // copy texture - - s16* in = new s16[dim.Height * pitch]; - memcpy(in, p, dim.Height * pitch * 2); - - for (s32 x=0; xunlock(); - } - - texture->regenerateMipMapLevels(); -} - - -//! Returns the maximum amount of primitives (mostly vertices) which -//! the device is able to render with one drawIndexedTriangleList -//! call. -u32 CNullDriver::getMaximalPrimitiveCount() -{ - return 0xFFFFFFFF; -} - - -//! checks triangle count and print warning if wrong -bool CNullDriver::checkPrimitiveCount(s32 prmCount) -{ - s32 m = getMaximalPrimitiveCount(); - - if ((prmCount-1) > m) - { - char tmp[1024]; - sprintf(tmp,"Could not draw triangles, too many primitives(%d), maxium is %d.", prmCount, m); - os::Printer::log(tmp, ELL_ERROR); - return false; - } - - return true; -} - -//! Enables or disables a texture creation flag. -void CNullDriver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) -{ - if (enabled && ((flag == ETCF_ALWAYS_16_BIT) || (flag == ETCF_ALWAYS_32_BIT) - || (flag == ETCF_OPTIMIZED_FOR_QUALITY) || (flag == ETCF_OPTIMIZED_FOR_SPEED))) - { - // disable other formats - setTextureCreationFlag(ETCF_ALWAYS_16_BIT, false); - setTextureCreationFlag(ETCF_ALWAYS_32_BIT, false); - setTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY, false); - setTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED, false); - } - - // set flag - TextureCreationFlags = (TextureCreationFlags & (~flag)) | - ((((u32)!enabled)-1) & flag); -} - - -//! Returns if a texture creation flag is enabled or disabled. -bool CNullDriver::getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) -{ - return (TextureCreationFlags & flag)!=0; -} - - -//! Creates a software image from a file. -IImage* CNullDriver::createImageFromFile(const char* filename) -{ - if (!filename) - return 0; - - IImage* image = 0; - io::IReadFile* file = FileSystem->createAndOpenFile(filename); - - if (file) - { - image = createImageFromFile(file); - file->drop(); - } - else - os::Printer::log("Could not open file of image", filename, ELL_ERROR); - - return image; -} - - -//! Creates a software image from a file. -IImage* CNullDriver::createImageFromFile(io::IReadFile* file) -{ - if (!file) - return 0; - - IImage* image = 0; - - u32 i; - - // try to load file based on file extension - for (i=0; iisALoadableFileExtension(file->getFileName())) - { - // reset file position which might have changed due to previous loadImage calls - file->seek(0); - image = SurfaceLoader[i]->loadImage(file); - if (image) - return image; - } - } - - // try to load file based on what is in it - for (i=0; iseek(0); - if (SurfaceLoader[i]->isALoadableFileFormat(file)) - { - file->seek(0); - image = SurfaceLoader[i]->loadImage(file); - if (image) - return image; - } - } - - return 0; // failed to load -} - - - -//! Writes the provided image to disk file -bool CNullDriver::writeImageToFile(IImage* image, const char* filename,u32 param) -{ - for (u32 i=0; iisAWriteableFileExtension(filename)) - { - io::IWriteFile* file = FileSystem->createAndWriteFile(filename); - if (file) - { - bool written = SurfaceWriter[i]->writeImage(file, image, param); - file->drop(); - if (written) - return true; - } - } - } - return false; // failed to write -} - - - -//! Creates a software image from a byte array. -IImage* CNullDriver::createImageFromData(ECOLOR_FORMAT format, - const core::dimension2d& size, void *data, - bool ownForeignMemory, - bool deleteMemory) -{ - return new CImage(format, size, data, ownForeignMemory, deleteMemory); -} - - -//! Sets the fog mode. -void CNullDriver::setFog(SColor color, bool linearFog, f32 start, f32 end, f32 density, - bool pixelFog, bool rangeFog) -{ - FogColor = color; - LinearFog = linearFog; - FogStart = start; - FogEnd = end; - FogDensity = density; - PixelFog = pixelFog; - RangeFog = rangeFog; -} - - -//! Draws a mesh buffer -void CNullDriver::drawMeshBuffer( const scene::IMeshBuffer* mb) -{ - if (!mb) - return; - - drawVertexPrimitiveList(mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getIndexCount()/3, mb->getVertexType(), scene::EPT_TRIANGLES); -} - - - -//! Only used by the internal engine. Used to notify the driver that -//! the window was resized. -void CNullDriver::OnResize(const core::dimension2d& size) -{ - if (ViewPort.getWidth() == ScreenSize.Width && - ViewPort.getHeight() == ScreenSize.Height) - ViewPort = core::rect(core::position2d(0,0), size); - - ScreenSize = size; -} - -// adds a material renderer and drops it afterwards. To be used for internal creation -s32 CNullDriver::addAndDropMaterialRenderer(IMaterialRenderer* m) -{ - s32 i = addMaterialRenderer(m); - - if (m) - m->drop(); - - return i; -} - - -//! Adds a new material renderer to the video device. -s32 CNullDriver::addMaterialRenderer(IMaterialRenderer* renderer, const char* name) -{ - if (!renderer) - return -1; - - SMaterialRenderer r; - r.Renderer = renderer; - r.Name = name; - - if (name == 0 && (MaterialRenderers.size() < sizeof(sBuiltInMaterialTypeNames) / sizeof(char*))) - { - // set name of built in renderer so that we don't have to implement name - // setting in all 5 available renderers. - r.Name = sBuiltInMaterialTypeNames[MaterialRenderers.size()]; - } - - MaterialRenderers.push_back(r); - renderer->grab(); - - return MaterialRenderers.size()-1; -} - - -//! Sets the name of a material renderer. -void CNullDriver::setMaterialRendererName(s32 idx, const char* name) -{ - if (idx < s32(sizeof(sBuiltInMaterialTypeNames) / sizeof(char*)) || - idx >= (s32)MaterialRenderers.size()) - return; - - MaterialRenderers[idx].Name = name; -} - - -//! Creates material attributes list from a material, usable for serialization and more. -io::IAttributes* CNullDriver::createAttributesFromMaterial(const video::SMaterial& material) -{ - io::CAttributes* attr = new io::CAttributes(this); - - const char** materialNames = new const char*[MaterialRenderers.size()+1]; - for (u32 i=0; i < MaterialRenderers.size(); ++i) - materialNames[i] = MaterialRenderers[i].Name.c_str(); - - materialNames[MaterialRenderers.size()] = 0; - - attr->addEnum("Type", material.MaterialType, materialNames); - - delete [] materialNames; - - attr->addColorf("Ambient", material.AmbientColor); - attr->addColorf("Diffuse", material.DiffuseColor); - attr->addColorf("Emissive", material.EmissiveColor); - attr->addColorf("Specular", material.SpecularColor); - - attr->addFloat("Shininess", material.Shininess); - attr->addFloat("Param1", material.MaterialTypeParam); - attr->addFloat("Param2", material.MaterialTypeParam2); - - attr->addTexture("Texture1", material.Textures[0]); - attr->addTexture("Texture2", material.Textures[1]); - attr->addTexture("Texture3", material.Textures[2]); - attr->addTexture("Texture4", material.Textures[3]); - - attr->addBool("Wireframe", material.Wireframe); - attr->addBool("GouraudShading", material.GouraudShading); - attr->addBool("Lighting", material.Lighting); - attr->addBool("ZWriteEnable", material.ZWriteEnable); - attr->addBool("BackfaceCulling", material.BackfaceCulling); - attr->addBool("BilinearFilter", material.BilinearFilter); - attr->addBool("TrilinearFilter", material.TrilinearFilter); - attr->addBool("AnisotropicFilter", material.AnisotropicFilter); - attr->addBool("FogEnable", material.FogEnable); - attr->addBool("NormalizeNormals", material.NormalizeNormals); - - attr->addInt("ZBuffer", material.ZBuffer); - attr->addEnum("TextureWrap1", material.TextureWrap[0], aTextureClampNames); - attr->addEnum("TextureWrap2", material.TextureWrap[1], aTextureClampNames); - attr->addEnum("TextureWrap3", material.TextureWrap[2], aTextureClampNames); - attr->addEnum("TextureWrap4", material.TextureWrap[3], aTextureClampNames); - - return attr; -} - - -//! Fills an SMaterial structure from attributes. -void CNullDriver::fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attr) -{ - outMaterial.MaterialType = video::EMT_SOLID; - - core::stringc name = attr->getAttributeAsString("Type"); - - u32 i; - - for ( i=0; i < MaterialRenderers.size(); ++i) - if ( name == MaterialRenderers[i].Name ) - { - outMaterial.MaterialType = (video::E_MATERIAL_TYPE)i; - break; - } - - outMaterial.AmbientColor = attr->getAttributeAsColor("Ambient"); - outMaterial.DiffuseColor = attr->getAttributeAsColor("Diffuse"); - outMaterial.EmissiveColor = attr->getAttributeAsColor("Emissive"); - outMaterial.SpecularColor = attr->getAttributeAsColor("Specular"); - - outMaterial.Shininess = attr->getAttributeAsFloat("Shininess"); - outMaterial.MaterialTypeParam = attr->getAttributeAsFloat("Param1"); - outMaterial.MaterialTypeParam2 = attr->getAttributeAsFloat("Param2"); - - outMaterial.Textures[0] = attr->getAttributeAsTexture("Texture1"); - outMaterial.Textures[1] = attr->getAttributeAsTexture("Texture2"); - outMaterial.Textures[2] = attr->getAttributeAsTexture("Texture3"); - outMaterial.Textures[3] = attr->getAttributeAsTexture("Texture4"); - - outMaterial.Wireframe = attr->getAttributeAsBool("Wireframe"); - outMaterial.GouraudShading = attr->getAttributeAsBool("GouraudShading"); - outMaterial.Lighting = attr->getAttributeAsBool("Lighting"); - outMaterial.ZWriteEnable = attr->getAttributeAsBool("ZWriteEnable"); - outMaterial.BackfaceCulling = attr->getAttributeAsBool("BackfaceCulling"); - outMaterial.BilinearFilter = attr->getAttributeAsBool("BilinearFilter"); - outMaterial.TrilinearFilter = attr->getAttributeAsBool("TrilinearFilter"); - outMaterial.AnisotropicFilter = attr->getAttributeAsBool("AnisotropicFilter"); - outMaterial.FogEnable = attr->getAttributeAsBool("FogEnable"); - outMaterial.NormalizeNormals = attr->getAttributeAsBool("NormalizeNormals"); - - outMaterial.ZBuffer = attr->getAttributeAsInt("ZBuffer"); - outMaterial.TextureWrap[0] = (E_TEXTURE_CLAMP)attr->getAttributeAsEnumeration("TextureWrap1", aTextureClampNames); - outMaterial.TextureWrap[1] = (E_TEXTURE_CLAMP)attr->getAttributeAsEnumeration("TextureWrap2", aTextureClampNames); - outMaterial.TextureWrap[2] = (E_TEXTURE_CLAMP)attr->getAttributeAsEnumeration("TextureWrap3", aTextureClampNames); - outMaterial.TextureWrap[3] = (E_TEXTURE_CLAMP)attr->getAttributeAsEnumeration("TextureWrap4", aTextureClampNames); -} - - -//! Returns driver and operating system specific data about the IVideoDriver. -SExposedVideoData CNullDriver::getExposedVideoData() -{ - return ExposedData; -} - - -//! Returns type of video driver -E_DRIVER_TYPE CNullDriver::getDriverType() -{ - return EDT_NULL; -} - -//! deletes all material renderers -void CNullDriver::deleteMaterialRenders() -{ - // delete material renderers - for (int i=0; i<(int)MaterialRenderers.size(); ++i) - if (MaterialRenderers[i].Renderer) - MaterialRenderers[i].Renderer->drop(); - - MaterialRenderers.clear(); -} - -//! Returns pointer to material renderer or null -IMaterialRenderer* CNullDriver::getMaterialRenderer(u32 idx) -{ - if ( idx < MaterialRenderers.size() ) - return MaterialRenderers[idx].Renderer; - - return 0; -} - - - -//! Returns amount of currently available material renderers. -u32 CNullDriver::getMaterialRendererCount() -{ - return MaterialRenderers.size(); -} - - -//! Returns name of the material renderer -const char* CNullDriver::getMaterialRendererName(u32 idx) -{ - if ( idx < MaterialRenderers.size() ) - return MaterialRenderers[idx].Name.c_str(); - - return 0; -} - - -//! Returns pointer to the IGPUProgrammingServices interface. -IGPUProgrammingServices* CNullDriver::getGPUProgrammingServices() -{ - return 0; -} - -//! Adds a new material renderer to the VideoDriver, based on a high level shading -//! language. Currently only HLSL in D3D9 is supported. -s32 CNullDriver::addHighLevelShaderMaterial( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - os::Printer::log("High level shader materials not available (yet) in this driver, sorry"); - return -1; -} - -//! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), -//! but tries to load the programs from files. -s32 CNullDriver::addHighLevelShaderMaterialFromFiles( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - io::IReadFile* vsfile = 0; - io::IReadFile* psfile = 0; - - if (vertexShaderProgram) - { - vsfile = FileSystem->createAndOpenFile(vertexShaderProgram); - if (!vsfile) - { - os::Printer::log("Could not open vertex shader program file", - vertexShaderProgram, ELL_WARNING); - return -1; - } - } - - if (pixelShaderProgram) - { - psfile = FileSystem->createAndOpenFile(pixelShaderProgram); - if (!psfile) - { - os::Printer::log("Could not open pixel shader program file", - pixelShaderProgram, ELL_WARNING); - if (vsfile) - vsfile->drop(); - return -1; - } - } - - s32 result = addHighLevelShaderMaterialFromFiles( - vsfile, vertexShaderEntryPointName, vsCompileTarget, - psfile, pixelShaderEntryPointName, psCompileTarget, - callback, baseMaterial, userData); - - if (psfile) - psfile->drop(); - - if (vsfile) - vsfile->drop(); - - return result; -} - -//! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), -//! but tries to load the programs from files. -s32 CNullDriver::addHighLevelShaderMaterialFromFiles( - io::IReadFile* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - io::IReadFile* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - c8* vs = 0; - c8* ps = 0; - - if (vertexShaderProgram) - { - s32 size = vertexShaderProgram->getSize(); - if (size) - { - vs = new c8[size+1]; - vertexShaderProgram->read(vs, size); - vs[size] = 0; - } - } - - if (pixelShaderProgram) - { - s32 size = pixelShaderProgram->getSize(); - if (size) - { - ps = new c8[size+1]; - pixelShaderProgram->read(ps, size); - ps[size] = 0; - } - } - - s32 result = this->addHighLevelShaderMaterial( - vs, vertexShaderEntryPointName, vsCompileTarget, - ps, pixelShaderEntryPointName, psCompileTarget, - callback, baseMaterial, userData); - - delete [] vs; - delete [] ps; - - return result; -} - -//! Adds a new material renderer to the VideoDriver, using pixel and/or -//! vertex shaders to render geometry. -s32 CNullDriver::addShaderMaterial(const c8* vertexShaderProgram, - const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - os::Printer::log("Shader materials not implemented yet in this driver, sorry."); - return -1; -} - -//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the -//! programs from files. -s32 CNullDriver::addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram, - io::IReadFile* pixelShaderProgram, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - c8* vs = 0; - c8* ps = 0; - - if (vertexShaderProgram) - { - s32 size = vertexShaderProgram->getSize(); - if (size) - { - vs = new c8[size+1]; - vertexShaderProgram->read(vs, size); - vs[size] = 0; - } - } - - if (pixelShaderProgram) - { - s32 size = pixelShaderProgram->getSize(); - if (size) - { - ps = new c8[size+1]; - pixelShaderProgram->read(ps, size); - ps[size] = 0; - } - } - - s32 result = addShaderMaterial(vs, ps, callback, baseMaterial, userData); - - delete [] vs; - delete [] ps; - - return result; -} - - - -//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the -//! programs from files. -s32 CNullDriver::addShaderMaterialFromFiles(const c8* vertexShaderProgramFileName, - const c8* pixelShaderProgramFileName, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - io::IReadFile* vsfile = 0; - io::IReadFile* psfile = 0; - - if (vertexShaderProgramFileName) - { - vsfile = FileSystem->createAndOpenFile(vertexShaderProgramFileName); - if (!vsfile) - { - os::Printer::log("Could not open vertex shader program file", - vertexShaderProgramFileName, ELL_WARNING); - return -1; - } - } - - if (pixelShaderProgramFileName) - { - psfile = FileSystem->createAndOpenFile(pixelShaderProgramFileName); - if (!psfile) - { - os::Printer::log("Could not open pixel shader program file", - pixelShaderProgramFileName, ELL_WARNING); - if (vsfile) - vsfile->drop(); - return -1; - } - } - - s32 result = addShaderMaterialFromFiles(vsfile, psfile, callback, - baseMaterial, userData); - - if (psfile) - psfile->drop(); - - if (vsfile) - vsfile->drop(); - - return result; -} - -//! Creates a render target texture. -ITexture* CNullDriver::createRenderTargetTexture(const core::dimension2d& size) -{ - return 0; -} - -//! Clears the ZBuffer. -void CNullDriver::clearZBuffer() -{ -} - -//! Returns an image created from the last rendered frame. -IImage* CNullDriver::createScreenShot() -{ - return 0; -} - -// prints renderer version -void CNullDriver::printVersion() -{ - core::stringw namePrint = L"Using renderer: "; - namePrint += getName(); - os::Printer::log(namePrint.c_str(), ELL_INFORMATION); -} - - -//! creates a video driver -IVideoDriver* createNullDriver(io::IFileSystem* io, const core::dimension2d& screenSize) -{ - return new CNullDriver(io, screenSize); -} - - -} // end namespace -} // end namespace - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CNullDriver.h" +#include "CSoftwareTexture.h" +#include "os.h" +#include "CImage.h" +#include "CAttributes.h" +#include "IWriteFile.h" + + +namespace irr +{ +namespace video +{ + +//! creates a loader which is able to load windows bitmaps +IImageLoader* createImageLoaderBMP(); + +//! creates a loader which is able to load jpeg images +IImageLoader* createImageLoaderJPG(); + +//! creates a loader which is able to load targa images +IImageLoader* createImageLoaderTGA(); + +//! creates a loader which is able to load psd images +IImageLoader* createImageLoaderPSD(); + +//! creates a loader which is able to load pcx images +IImageLoader* createImageLoaderPCX(); + +//! creates a loader which is able to load png images +IImageLoader* createImageLoaderPNG(); + + +//! creates a loader which is able to load bmp images +IImageWriter* createImageWriterBMP(); + +//! creates a loader which is able to load jpg images +IImageWriter* createImageWriterJPG(); + +//! creates a loader which is able to load tga images +IImageWriter* createImageWriterTGA(); + +//! creates a loader which is able to load psd images +IImageWriter* createImageWriterPSD(); + +//! creates a loader which is able to load pcx images +IImageWriter* createImageWriterPCX(); + +//! creates a loader which is able to load png images +IImageWriter* createImageWriterPNG(); + +//! creates a loader which is able to load ppm images +IImageWriter* createImageWriterPPM(); + + + +//! Array holding the built in material type names +const char* const sBuiltInMaterialTypeNames[] = +{ + "solid", + "solid_2layer", + "lightmap", + "lightmap_add", + "lightmap_m2", + "lightmap_m4", + "lightmap_light", + "lightmap_light_m2", + "lightmap_light_m4", + "detail_map", + "sphere_map", + "reflection_2layer", + "trans_add", + "trans_alphach", + "trans_alphach_ref", + "trans_vertex_alpha", + "trans_reflection_2layer", + "normalmap_solid", + "normalmap_trans_add", + "normalmap_trans_vertexalpha", + "parallaxmap_solid", + "parallaxmap_trans_add", + "parallaxmap_trans_vertexalpha" +}; + + +//! constructor +CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d& screenSize) +: FileSystem(io), ViewPort(0,0,0,0), ScreenSize(screenSize), + PrimitivesDrawn(0), TextureCreationFlags(0) +{ + #ifdef _DEBUG + setDebugName("CNullDriver"); + #endif + + setFog(); + + setTextureCreationFlag(ETCF_ALWAYS_32_BIT, true); + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, true); + + ViewPort = core::rect(core::position2d(0,0), screenSize); + + if (FileSystem) + FileSystem->grab(); + + // create surface loader + + SurfaceLoader.push_back(video::createImageLoaderBMP()); + SurfaceLoader.push_back(video::createImageLoaderJPG()); + SurfaceLoader.push_back(video::createImageLoaderTGA()); + SurfaceLoader.push_back(video::createImageLoaderPSD()); + SurfaceLoader.push_back(video::createImageLoaderPCX()); + SurfaceLoader.push_back(video::createImageLoaderPNG()); + + SurfaceWriter.push_back(video::createImageWriterBMP()); + SurfaceWriter.push_back(video::createImageWriterJPG()); + SurfaceWriter.push_back(video::createImageWriterTGA()); + SurfaceWriter.push_back(video::createImageWriterPSD()); + SurfaceWriter.push_back(video::createImageWriterPCX()); + SurfaceWriter.push_back(video::createImageWriterPNG()); + SurfaceWriter.push_back(video::createImageWriterPPM()); + + // set ExposedData to 0 + memset(&ExposedData, 0, sizeof(ExposedData)); +} + + + +//! destructor +CNullDriver::~CNullDriver() +{ + // delete file system + + if (FileSystem) + FileSystem->drop(); + + // delete textures + + deleteAllTextures(); + + // delete surface loader + + u32 i; + for (i=0; idrop(); + + // delete surface writer + + for (i=0; idrop(); + + deleteMaterialRenders(); +} + + +//! Adds an external surface loader to the engine. +void CNullDriver::addExternalImageLoader(IImageLoader* loader) +{ + if (!loader) + return; + + loader->grab(); + SurfaceLoader.push_back(loader); +} + + +//! Adds an external surface writer to the engine. +void CNullDriver::addExternalImageWriter(IImageWriter* writer) +{ + if (!writer) + return; + + writer->grab(); + SurfaceWriter.push_back(writer); +} + + +//! deletes all textures +void CNullDriver::deleteAllTextures() +{ + for (u32 i=0; idrop(); + + Textures.clear(); +} + + + +//! applications must call this method before performing any rendering. returns false if failed. +bool CNullDriver::beginScene(bool backBuffer, bool zBuffer, SColor color) +{ + core::clearFPUException (); + PrimitivesDrawn = 0; + return true; +} + + + +//! applications must call this method after performing any rendering. returns false if failed. +bool CNullDriver::endScene( s32 windowId, core::rect* sourceRect ) +{ + FPSCounter.registerFrame(os::Timer::getRealTime(), PrimitivesDrawn); + return true; +} + + + +//! queries the features of the driver, returns true if feature is available +bool CNullDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) +{ + return false; +} + + + +//! sets transformation +void CNullDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) +{ +} + + +//! Returns the transformation set by setTransform +const core::matrix4& CNullDriver::getTransform(E_TRANSFORMATION_STATE state) +{ + return TransformationMatrix; +} + + + +//! sets a material +void CNullDriver::setMaterial(const SMaterial& material) +{ +} + + + +//! Removes a texture from the texture cache and deletes it, freeing lot of +//! memory. +void CNullDriver::removeTexture(ITexture* texture) +{ + for (u32 i=0; idrop(); + Textures.erase(i); + } +} + + +//! Removes all texture from the texture cache and deletes them, freeing lot of +//! memory. +void CNullDriver::removeAllTextures() +{ + deleteAllTextures(); +} + + +//! Returns a texture by index +ITexture* CNullDriver::getTextureByIndex(u32 i) +{ + if ( i < Textures.size() ) + return Textures[i].Surface; + + return 0; +} + + +//! Returns amount of textures currently loaded +s32 CNullDriver::getTextureCount() +{ + return Textures.size(); +} + + +//! loads a Texture +ITexture* CNullDriver::getTexture(const c8* filename) +{ + ITexture* texture = findTexture(filename); + + if (texture) + return texture; + + io::IReadFile* file = FileSystem->createAndOpenFile(filename); + bool errorReported = false; + + if (file) + { + texture = loadTextureFromFile(file, filename); + file->drop(); + + if (texture) + { + addTexture(texture); + texture->drop(); // drop it becaus we created it, one grab too much + } + } + else + { + errorReported = true; + os::Printer::log("Could not open file of texture", filename, ELL_ERROR); + } + + if (!texture && !errorReported) + os::Printer::log("Could not load texture", filename, ELL_ERROR); + + return texture; +} + + + +//! loads a Texture +ITexture* CNullDriver::getTexture(io::IReadFile* file) +{ + ITexture* texture = 0; + + if (file) + { + texture = findTexture(file->getFileName()); + + if (texture) + return texture; + + texture = loadTextureFromFile(file ); + + if (texture) + { + addTexture(texture); + texture->drop(); // drop it because we created it, one grab too much + } + } + + if (!texture) + os::Printer::log("Could not load texture", file->getFileName(), ELL_ERROR); + + return texture; +} + + + +//! opens the file and loads it into the surface +video::ITexture* CNullDriver::loadTextureFromFile(io::IReadFile* file, const c8 *hashName ) +{ + ITexture* texture = 0; + IImage* image = createImageFromFile(file); + + if (image) + { + // create texture from surface + texture = createDeviceDependentTexture(image, hashName ? hashName : file->getFileName() ); + os::Printer::log("Loaded texture", file->getFileName()); + image->drop(); + } + + return texture; +} + + + +//! adds a surface, not loaded or created by the Irrlicht Engine +void CNullDriver::addTexture(video::ITexture* texture) +{ + if (texture) + { + SSurface s; + s.Surface = texture; + texture->grab(); + + Textures.push_back(s); + + // the new texture is now at the end of the texture list. when searching for + // the next new texture, the texture array will be sorted and the index of this texture + // will be changed. to let the order be more consistent to the user, sort + // the textures now already although this isn't necessary: + + Textures.sort(); + } +} + + + +//! looks if the image is already loaded +video::ITexture* CNullDriver::findTexture(const c8* filename) +{ + if (!filename) + filename = ""; + + SSurface s; + SDummyTexture dummy(filename); + s.Surface = &dummy; + + s32 index = Textures.binary_search(s); + if (index != -1) + return Textures[index].Surface; + + return 0; +} + + + +//! Creates a texture from a loaded IImage. +ITexture* CNullDriver::addTexture(const c8* name, IImage* image) +{ + if (!name || !image) + return 0; + + ITexture* t = createDeviceDependentTexture(image, name); + addTexture(t); + t->drop(); + return t; +} + + + +//! creates a Texture +ITexture* CNullDriver::addTexture(const core::dimension2d& size, + const c8* name, ECOLOR_FORMAT format) +{ + if (!name) + return 0; + + IImage* image = new CImage(format, size); + ITexture* t = createDeviceDependentTexture(image, name); + image->drop(); + addTexture(t); + + if (t) + t->drop(); + + return t; +} + + + +//! returns a device dependent texture from a software surface (IImage) +//! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES +ITexture* CNullDriver::createDeviceDependentTexture(IImage* surface, const char* name) +{ + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + return new CSoftwareTexture(surface, name); + #else + return 0; + #endif +} + + + +//! sets a render target +bool CNullDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, + bool clearZBuffer, SColor color) +{ + return false; +} + + + +//! sets a viewport +void CNullDriver::setViewPort(const core::rect& area) +{ +} + + + +//! gets the area of the current viewport +const core::rect& CNullDriver::getViewPort() const +{ + return ViewPort; +} + + + +//! draws a vertex primitive list +void CNullDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) +{ + PrimitivesDrawn += primitiveCount; +} + + + +//! draws an indexed triangle list +inline void CNullDriver::drawIndexedTriangleList(const S3DVertex* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount) +{ + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLES); +} + + + +//! draws an indexed triangle list +inline void CNullDriver::drawIndexedTriangleList(const S3DVertex2TCoords* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount) +{ + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLES); +} + + +//! Draws an indexed triangle list. +inline void CNullDriver::drawIndexedTriangleList(const S3DVertexTangents* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) +{ + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLES); +} + + + +//! Draws an indexed triangle fan. +inline void CNullDriver::drawIndexedTriangleFan(const S3DVertex* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) +{ + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLE_FAN); +} + + + +//! Draws an indexed triangle fan. +inline void CNullDriver::drawIndexedTriangleFan(const S3DVertex2TCoords* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) +{ + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLE_FAN); +} + + + +//! Draws an indexed triangle fan. +inline void CNullDriver::drawIndexedTriangleFan(const S3DVertexTangents* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) +{ + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLE_FAN); +} + + + +//! Draws a 3d line. +void CNullDriver::draw3DLine(const core::vector3df& start, + const core::vector3df& end, SColor color) +{ +} + + + +//! Draws a 3d triangle. +void CNullDriver::draw3DTriangle(const core::triangle3df& triangle, SColor color) +{ + draw3DLine(triangle.pointA, triangle.pointB, color); + draw3DLine(triangle.pointB, triangle.pointC, color); + draw3DLine(triangle.pointC, triangle.pointA, color); +} + + + +//! Draws a 3d axis aligned box. +void CNullDriver::draw3DBox(const core::aabbox3d box, SColor color) +{ + core::vector3df edges[8]; + box.getEdges(edges); + + // TODO: optimize into one big drawIndexPrimitive call. + + draw3DLine(edges[5], edges[1], color); + draw3DLine(edges[1], edges[3], color); + draw3DLine(edges[3], edges[7], color); + draw3DLine(edges[7], edges[5], color); + draw3DLine(edges[0], edges[2], color); + draw3DLine(edges[2], edges[6], color); + draw3DLine(edges[6], edges[4], color); + draw3DLine(edges[4], edges[0], color); + draw3DLine(edges[1], edges[0], color); + draw3DLine(edges[3], edges[2], color); + draw3DLine(edges[7], edges[6], color); + draw3DLine(edges[5], edges[4], color); +} + + + +//! draws an 2d image +void CNullDriver::draw2DImage(video::ITexture* texture, const core::position2d& destPos) +{ + if (!texture) + return; + + draw2DImage(texture,destPos, core::rect(core::position2d(0,0), texture->getOriginalSize())); +} + + + +//! draws a set of 2d images, using a color and the alpha channel of the +//! texture if desired. The images are drawn beginning at pos and concatenated +//! in one line. All drawings are clipped against clipRect (if != 0). +//! The subtextures are defined by the array of sourceRects and are chosen +//! by the indices given. +void CNullDriver::draw2DImage(video::ITexture* texture, + const core::position2d& pos, + const core::array >& sourceRects, + const core::array& indices, + s32 kerningWidth, + const core::rect* clipRect, SColor color, + bool useAlphaChannelOfTexture) +{ + core::position2d target(pos); + + for (u32 i=0; i& destRect, + const core::rect& sourceRect, const core::rect* clipRect, + video::SColor* colors, bool useAlphaChannelOfTexture) +{ +} + + + +//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. +void CNullDriver::draw2DImage(video::ITexture* texture, const core::position2d& destPos, + const core::rect& sourceRect, + const core::rect* clipRect, SColor color, + bool useAlphaChannelOfTexture) +{ +} + + + +//! draw an 2d rectangle +void CNullDriver::draw2DRectangle(SColor color, const core::rect& pos, const core::rect* clip) +{ + draw2DRectangle(pos, color, color, color, color, clip); +} + + + +//!Draws an 2d rectangle with a gradient. +void CNullDriver::draw2DRectangle(const core::rect& pos, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect* clip) +{ +} + + + +//! Draws a 2d line. +void CNullDriver::draw2DLine(const core::position2d& start, + const core::position2d& end, SColor color) +{ +} + + + +//! Draws a non filled concyclic regular 2d polyon. +void CNullDriver::draw2DPolygon(core::position2d center, + f32 radius, video::SColor color, s32 count) +{ + if (count < 2) + return; + + core::position2d first; + core::position2d a,b; + + for (s32 j=0; j((s32)(sin(p)*radius), (s32)(cos(p)*radius)); + + if (j==0) + first = a; + else + draw2DLine(a, b, color); + } + + draw2DLine(a, first, color); +} + + + + +//! returns screen size +core::dimension2d CNullDriver::getScreenSize() +{ + return ScreenSize; +} + +//! returns the current render target size, +//! or the screen size if render targets are not implemented +core::dimension2d CNullDriver::getCurrentRenderTargetSize() +{ + return ScreenSize; +} + + +// returns current frames per second value +s32 CNullDriver::getFPS() +{ + return FPSCounter.getFPS(); +} + + + +//! returns amount of primitives (mostly triangles) were drawn in the last frame. +//! very useful method for statistics. +u32 CNullDriver::getPrimitiveCountDrawn( u32 param ) +{ + return 0 == param ? FPSCounter.getPrimitive() : FPSCounter.getPrimitiveAverage(); +} + + + +//! Sets the dynamic ambient light color. The default color is +//! (0,0,0,0) which means it is dark. +//! \param color: New color of the ambient light. +void CNullDriver::setAmbientLight(const SColorf& color) +{ +} + + + +//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 +//! driver, it would return "Direct3D8". +const wchar_t* CNullDriver::getName() +{ + return L"Irrlicht NullDevice"; +} + + + +//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do +//! this: Frist, draw all geometry. Then use this method, to draw the shadow +//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. +void CNullDriver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail) +{ +} + + +//! Fills the stencil shadow with color. After the shadow volume has been drawn +//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this +//! to draw the color of the shadow. +void CNullDriver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge, + video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge) +{ +} + + +//! deletes all dynamic lights there are +void CNullDriver::deleteAllDynamicLights() +{ + Lights.set_used(0); +} + + + +//! adds a dynamic light +void CNullDriver::addDynamicLight(const SLight& light) +{ + Lights.push_back(light); +} + + + +//! returns the maximal amount of dynamic lights the device can handle +u32 CNullDriver::getMaximalDynamicLightAmount() +{ + return 0; +} + +//! Returns current amount of dynamic lights set +//! \return Current amount of dynamic lights set +u32 CNullDriver::getDynamicLightCount() +{ + return Lights.size(); +} + +//! Returns light data which was previously set with IVideDriver::addDynamicLight(). +//! \param idx: Zero based index of the light. Must be greater than 0 and smaller +//! than IVideoDriver()::getDynamicLightCount. +//! \return Light data. +const SLight& CNullDriver::getDynamicLight(u32 idx) +{ + if ( idx < Lights.size() ) + return Lights[idx]; + + return *((SLight*)0); +} + + +//! Creates an 1bit alpha channel of the texture based of an color key. +void CNullDriver::makeColorKeyTexture(video::ITexture* texture, video::SColor color) +{ + if (!texture) + return; + + if (texture->getColorFormat() != ECF_A1R5G5B5 && + texture->getColorFormat() != ECF_A8R8G8B8 ) + { + os::Printer::log("Error: Unsupported texture color format for making color key channel.", ELL_ERROR); + return; + } + + if (texture->getColorFormat() == ECF_A1R5G5B5) + { + s16 *p = (s16*)texture->lock(); + + if (!p) + { + os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); + return; + } + + core::dimension2d dim = texture->getSize(); + s32 pitch = texture->getPitch() / 2; + + // color with alpha enabled (color opaque) + s16 ref = (0x1<<15) | (0x7fff & color.toA1R5G5B5()); + + for (s32 y=0; yunlock(); + } + else + { + s32 *p = (s32*)texture->lock(); + + if (!p) + { + os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); + return; + } + + core::dimension2d dim = texture->getSize(); + s32 pitch = texture->getPitch() / 4; + + // color with alpha enabled (color opaque) + s32 ref = (0xff<<24) | (0x00ffffff & color.color); + + for (s32 y=0; yunlock(); + } +} + + + +//! Creates an 1bit alpha channel of the texture based of an color key position. +void CNullDriver::makeColorKeyTexture(video::ITexture* texture, + core::position2d colorKeyPixelPos) +{ + if (!texture) + return; + + if (texture->getColorFormat() != ECF_A1R5G5B5 && + texture->getColorFormat() != ECF_A8R8G8B8 ) + { + os::Printer::log("Error: Unsupported texture color format for making color key channel.", ELL_ERROR); + return; + } + + if (texture->getColorFormat() == ECF_A1R5G5B5) + { + s16 *p = (s16*)texture->lock(); + + if (!p) + { + os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); + return; + } + + core::dimension2d dim = texture->getSize(); + s32 pitch = texture->getPitch() / 2; + + s16 ref = (0x1<<15) | (0x7fff & p[colorKeyPixelPos.Y*dim.Width + colorKeyPixelPos.X]); + + for (s32 y=0; yunlock(); + } + else + { + s32 *p = (s32*)texture->lock(); + + if (!p) + { + os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); + return; + } + + core::dimension2d dim = texture->getSize(); + s32 pitch = texture->getPitch() / 4; + + s32 ref = (0xff<<24) | (0x00ffffff & p[colorKeyPixelPos.Y*dim.Width + colorKeyPixelPos.X]); + + for (s32 y=0; yunlock(); + } +} + + + +//! Creates a normal map from a height map texture. +//! \param amplitude: Constant value by which the height information is multiplied. +void CNullDriver::makeNormalMapTexture(video::ITexture* texture, f32 amplitude) +{ + if (!texture) + return; + + if (texture->getColorFormat() != ECF_A1R5G5B5 && + texture->getColorFormat() != ECF_A8R8G8B8 ) + { + os::Printer::log("Error: Unsupported texture color format for making normal map.", ELL_ERROR); + return; + } + + core::dimension2d dim = texture->getSize(); + amplitude = amplitude / 255.0f; + f32 vh = dim.Height / (f32)dim.Width; + f32 hh = dim.Width / (f32)dim.Height; + + if (texture->getColorFormat() == ECF_A8R8G8B8) + { + // ECF_A8R8G8B8 version + + s32 *p = (s32*)texture->lock(); + + if (!p) + { + os::Printer::log("Could not lock texture for making normal map.", ELL_ERROR); + return; + } + + // copy texture + + s32 pitch = texture->getPitch() / 4; + + s32* in = new s32[dim.Height * pitch]; + memcpy(in, p, dim.Height * pitch * 4); + + for (s32 x=0; xunlock(); + } + else + { + // ECF_A1R5G5B5 version + + s16 *p = (s16*)texture->lock(); + + if (!p) + { + os::Printer::log("Could not lock texture for making normal map.", ELL_ERROR); + return; + } + + s32 pitch = texture->getPitch() / 2; + + // copy texture + + s16* in = new s16[dim.Height * pitch]; + memcpy(in, p, dim.Height * pitch * 2); + + for (s32 x=0; xunlock(); + } + + texture->regenerateMipMapLevels(); +} + + +//! Returns the maximum amount of primitives (mostly vertices) which +//! the device is able to render with one drawIndexedTriangleList +//! call. +u32 CNullDriver::getMaximalPrimitiveCount() +{ + return 0xFFFFFFFF; +} + + +//! checks triangle count and print warning if wrong +bool CNullDriver::checkPrimitiveCount(s32 prmCount) +{ + s32 m = getMaximalPrimitiveCount(); + + if ((prmCount-1) > m) + { + char tmp[1024]; + sprintf(tmp,"Could not draw triangles, too many primitives(%d), maxium is %d.", prmCount, m); + os::Printer::log(tmp, ELL_ERROR); + return false; + } + + return true; +} + +//! Enables or disables a texture creation flag. +void CNullDriver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) +{ + if (enabled && ((flag == ETCF_ALWAYS_16_BIT) || (flag == ETCF_ALWAYS_32_BIT) + || (flag == ETCF_OPTIMIZED_FOR_QUALITY) || (flag == ETCF_OPTIMIZED_FOR_SPEED))) + { + // disable other formats + setTextureCreationFlag(ETCF_ALWAYS_16_BIT, false); + setTextureCreationFlag(ETCF_ALWAYS_32_BIT, false); + setTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY, false); + setTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED, false); + } + + // set flag + TextureCreationFlags = (TextureCreationFlags & (~flag)) | + ((((u32)!enabled)-1) & flag); +} + + +//! Returns if a texture creation flag is enabled or disabled. +bool CNullDriver::getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) +{ + return (TextureCreationFlags & flag)!=0; +} + + +//! Creates a software image from a file. +IImage* CNullDriver::createImageFromFile(const char* filename) +{ + if (!filename) + return 0; + + IImage* image = 0; + io::IReadFile* file = FileSystem->createAndOpenFile(filename); + + if (file) + { + image = createImageFromFile(file); + file->drop(); + } + else + os::Printer::log("Could not open file of image", filename, ELL_ERROR); + + return image; +} + + +//! Creates a software image from a file. +IImage* CNullDriver::createImageFromFile(io::IReadFile* file) +{ + if (!file) + return 0; + + IImage* image = 0; + + u32 i; + + // try to load file based on file extension + for (i=0; iisALoadableFileExtension(file->getFileName())) + { + // reset file position which might have changed due to previous loadImage calls + file->seek(0); + image = SurfaceLoader[i]->loadImage(file); + if (image) + return image; + } + } + + // try to load file based on what is in it + for (i=0; iseek(0); + if (SurfaceLoader[i]->isALoadableFileFormat(file)) + { + file->seek(0); + image = SurfaceLoader[i]->loadImage(file); + if (image) + return image; + } + } + + return 0; // failed to load +} + + + +//! Writes the provided image to disk file +bool CNullDriver::writeImageToFile(IImage* image, const char* filename,u32 param) +{ + for (u32 i=0; iisAWriteableFileExtension(filename)) + { + io::IWriteFile* file = FileSystem->createAndWriteFile(filename); + if (file) + { + bool written = SurfaceWriter[i]->writeImage(file, image, param); + file->drop(); + if (written) + return true; + } + } + } + return false; // failed to write +} + + + +//! Creates a software image from a byte array. +IImage* CNullDriver::createImageFromData(ECOLOR_FORMAT format, + const core::dimension2d& size, void *data, + bool ownForeignMemory, + bool deleteMemory) +{ + return new CImage(format, size, data, ownForeignMemory, deleteMemory); +} + + +//! Sets the fog mode. +void CNullDriver::setFog(SColor color, bool linearFog, f32 start, f32 end, f32 density, + bool pixelFog, bool rangeFog) +{ + FogColor = color; + LinearFog = linearFog; + FogStart = start; + FogEnd = end; + FogDensity = density; + PixelFog = pixelFog; + RangeFog = rangeFog; +} + + +//! Draws a mesh buffer +void CNullDriver::drawMeshBuffer( const scene::IMeshBuffer* mb) +{ + if (!mb) + return; + + drawVertexPrimitiveList(mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getIndexCount()/3, mb->getVertexType(), scene::EPT_TRIANGLES); +} + + + +//! Only used by the internal engine. Used to notify the driver that +//! the window was resized. +void CNullDriver::OnResize(const core::dimension2d& size) +{ + if (ViewPort.getWidth() == ScreenSize.Width && + ViewPort.getHeight() == ScreenSize.Height) + ViewPort = core::rect(core::position2d(0,0), size); + + ScreenSize = size; +} + +// adds a material renderer and drops it afterwards. To be used for internal creation +s32 CNullDriver::addAndDropMaterialRenderer(IMaterialRenderer* m) +{ + s32 i = addMaterialRenderer(m); + + if (m) + m->drop(); + + return i; +} + + +//! Adds a new material renderer to the video device. +s32 CNullDriver::addMaterialRenderer(IMaterialRenderer* renderer, const char* name) +{ + if (!renderer) + return -1; + + SMaterialRenderer r; + r.Renderer = renderer; + r.Name = name; + + if (name == 0 && (MaterialRenderers.size() < sizeof(sBuiltInMaterialTypeNames) / sizeof(char*))) + { + // set name of built in renderer so that we don't have to implement name + // setting in all 5 available renderers. + r.Name = sBuiltInMaterialTypeNames[MaterialRenderers.size()]; + } + + MaterialRenderers.push_back(r); + renderer->grab(); + + return MaterialRenderers.size()-1; +} + + +//! Sets the name of a material renderer. +void CNullDriver::setMaterialRendererName(s32 idx, const char* name) +{ + if (idx < s32(sizeof(sBuiltInMaterialTypeNames) / sizeof(char*)) || + idx >= (s32)MaterialRenderers.size()) + return; + + MaterialRenderers[idx].Name = name; +} + + +//! Creates material attributes list from a material, usable for serialization and more. +io::IAttributes* CNullDriver::createAttributesFromMaterial(const video::SMaterial& material) +{ + io::CAttributes* attr = new io::CAttributes(this); + + const char** materialNames = new const char*[MaterialRenderers.size()+1]; + for (u32 i=0; i < MaterialRenderers.size(); ++i) + materialNames[i] = MaterialRenderers[i].Name.c_str(); + + materialNames[MaterialRenderers.size()] = 0; + + attr->addEnum("Type", material.MaterialType, materialNames); + + delete [] materialNames; + + attr->addColorf("Ambient", material.AmbientColor); + attr->addColorf("Diffuse", material.DiffuseColor); + attr->addColorf("Emissive", material.EmissiveColor); + attr->addColorf("Specular", material.SpecularColor); + + attr->addFloat("Shininess", material.Shininess); + attr->addFloat("Param1", material.MaterialTypeParam); + attr->addFloat("Param2", material.MaterialTypeParam2); + + attr->addTexture("Texture1", material.Textures[0]); + attr->addTexture("Texture2", material.Textures[1]); + attr->addTexture("Texture3", material.Textures[2]); + attr->addTexture("Texture4", material.Textures[3]); + + attr->addBool("Wireframe", material.Wireframe); + attr->addBool("GouraudShading", material.GouraudShading); + attr->addBool("Lighting", material.Lighting); + attr->addBool("ZWriteEnable", material.ZWriteEnable); + attr->addBool("BackfaceCulling", material.BackfaceCulling); + attr->addBool("BilinearFilter", material.BilinearFilter); + attr->addBool("TrilinearFilter", material.TrilinearFilter); + attr->addBool("AnisotropicFilter", material.AnisotropicFilter); + attr->addBool("FogEnable", material.FogEnable); + attr->addBool("NormalizeNormals", material.NormalizeNormals); + + attr->addInt("ZBuffer", material.ZBuffer); + attr->addEnum("TextureWrap1", material.TextureWrap[0], aTextureClampNames); + attr->addEnum("TextureWrap2", material.TextureWrap[1], aTextureClampNames); + attr->addEnum("TextureWrap3", material.TextureWrap[2], aTextureClampNames); + attr->addEnum("TextureWrap4", material.TextureWrap[3], aTextureClampNames); + + return attr; +} + + +//! Fills an SMaterial structure from attributes. +void CNullDriver::fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attr) +{ + outMaterial.MaterialType = video::EMT_SOLID; + + core::stringc name = attr->getAttributeAsString("Type"); + + u32 i; + + for ( i=0; i < MaterialRenderers.size(); ++i) + if ( name == MaterialRenderers[i].Name ) + { + outMaterial.MaterialType = (video::E_MATERIAL_TYPE)i; + break; + } + + outMaterial.AmbientColor = attr->getAttributeAsColor("Ambient"); + outMaterial.DiffuseColor = attr->getAttributeAsColor("Diffuse"); + outMaterial.EmissiveColor = attr->getAttributeAsColor("Emissive"); + outMaterial.SpecularColor = attr->getAttributeAsColor("Specular"); + + outMaterial.Shininess = attr->getAttributeAsFloat("Shininess"); + outMaterial.MaterialTypeParam = attr->getAttributeAsFloat("Param1"); + outMaterial.MaterialTypeParam2 = attr->getAttributeAsFloat("Param2"); + + outMaterial.Textures[0] = attr->getAttributeAsTexture("Texture1"); + outMaterial.Textures[1] = attr->getAttributeAsTexture("Texture2"); + outMaterial.Textures[2] = attr->getAttributeAsTexture("Texture3"); + outMaterial.Textures[3] = attr->getAttributeAsTexture("Texture4"); + + outMaterial.Wireframe = attr->getAttributeAsBool("Wireframe"); + outMaterial.GouraudShading = attr->getAttributeAsBool("GouraudShading"); + outMaterial.Lighting = attr->getAttributeAsBool("Lighting"); + outMaterial.ZWriteEnable = attr->getAttributeAsBool("ZWriteEnable"); + outMaterial.BackfaceCulling = attr->getAttributeAsBool("BackfaceCulling"); + outMaterial.BilinearFilter = attr->getAttributeAsBool("BilinearFilter"); + outMaterial.TrilinearFilter = attr->getAttributeAsBool("TrilinearFilter"); + outMaterial.AnisotropicFilter = attr->getAttributeAsBool("AnisotropicFilter"); + outMaterial.FogEnable = attr->getAttributeAsBool("FogEnable"); + outMaterial.NormalizeNormals = attr->getAttributeAsBool("NormalizeNormals"); + + outMaterial.ZBuffer = attr->getAttributeAsInt("ZBuffer"); + outMaterial.TextureWrap[0] = (E_TEXTURE_CLAMP)attr->getAttributeAsEnumeration("TextureWrap1", aTextureClampNames); + outMaterial.TextureWrap[1] = (E_TEXTURE_CLAMP)attr->getAttributeAsEnumeration("TextureWrap2", aTextureClampNames); + outMaterial.TextureWrap[2] = (E_TEXTURE_CLAMP)attr->getAttributeAsEnumeration("TextureWrap3", aTextureClampNames); + outMaterial.TextureWrap[3] = (E_TEXTURE_CLAMP)attr->getAttributeAsEnumeration("TextureWrap4", aTextureClampNames); +} + + +//! Returns driver and operating system specific data about the IVideoDriver. +SExposedVideoData CNullDriver::getExposedVideoData() +{ + return ExposedData; +} + + +//! Returns type of video driver +E_DRIVER_TYPE CNullDriver::getDriverType() +{ + return EDT_NULL; +} + +//! deletes all material renderers +void CNullDriver::deleteMaterialRenders() +{ + // delete material renderers + for (int i=0; i<(int)MaterialRenderers.size(); ++i) + if (MaterialRenderers[i].Renderer) + MaterialRenderers[i].Renderer->drop(); + + MaterialRenderers.clear(); +} + +//! Returns pointer to material renderer or null +IMaterialRenderer* CNullDriver::getMaterialRenderer(u32 idx) +{ + if ( idx < MaterialRenderers.size() ) + return MaterialRenderers[idx].Renderer; + + return 0; +} + + + +//! Returns amount of currently available material renderers. +u32 CNullDriver::getMaterialRendererCount() +{ + return MaterialRenderers.size(); +} + + +//! Returns name of the material renderer +const char* CNullDriver::getMaterialRendererName(u32 idx) +{ + if ( idx < MaterialRenderers.size() ) + return MaterialRenderers[idx].Name.c_str(); + + return 0; +} + + +//! Returns pointer to the IGPUProgrammingServices interface. +IGPUProgrammingServices* CNullDriver::getGPUProgrammingServices() +{ + return 0; +} + +//! Adds a new material renderer to the VideoDriver, based on a high level shading +//! language. Currently only HLSL in D3D9 is supported. +s32 CNullDriver::addHighLevelShaderMaterial( + const c8* vertexShaderProgram, + const c8* vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8* pixelShaderProgram, + const c8* pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + IShaderConstantSetCallBack* callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) +{ + os::Printer::log("High level shader materials not available (yet) in this driver, sorry"); + return -1; +} + +//! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), +//! but tries to load the programs from files. +s32 CNullDriver::addHighLevelShaderMaterialFromFiles( + const c8* vertexShaderProgram, + const c8* vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8* pixelShaderProgram, + const c8* pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + IShaderConstantSetCallBack* callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) +{ + io::IReadFile* vsfile = 0; + io::IReadFile* psfile = 0; + + if (vertexShaderProgram) + { + vsfile = FileSystem->createAndOpenFile(vertexShaderProgram); + if (!vsfile) + { + os::Printer::log("Could not open vertex shader program file", + vertexShaderProgram, ELL_WARNING); + return -1; + } + } + + if (pixelShaderProgram) + { + psfile = FileSystem->createAndOpenFile(pixelShaderProgram); + if (!psfile) + { + os::Printer::log("Could not open pixel shader program file", + pixelShaderProgram, ELL_WARNING); + if (vsfile) + vsfile->drop(); + return -1; + } + } + + s32 result = addHighLevelShaderMaterialFromFiles( + vsfile, vertexShaderEntryPointName, vsCompileTarget, + psfile, pixelShaderEntryPointName, psCompileTarget, + callback, baseMaterial, userData); + + if (psfile) + psfile->drop(); + + if (vsfile) + vsfile->drop(); + + return result; +} + +//! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), +//! but tries to load the programs from files. +s32 CNullDriver::addHighLevelShaderMaterialFromFiles( + io::IReadFile* vertexShaderProgram, + const c8* vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + io::IReadFile* pixelShaderProgram, + const c8* pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + IShaderConstantSetCallBack* callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) +{ + c8* vs = 0; + c8* ps = 0; + + if (vertexShaderProgram) + { + s32 size = vertexShaderProgram->getSize(); + if (size) + { + vs = new c8[size+1]; + vertexShaderProgram->read(vs, size); + vs[size] = 0; + } + } + + if (pixelShaderProgram) + { + s32 size = pixelShaderProgram->getSize(); + if (size) + { + ps = new c8[size+1]; + pixelShaderProgram->read(ps, size); + ps[size] = 0; + } + } + + s32 result = this->addHighLevelShaderMaterial( + vs, vertexShaderEntryPointName, vsCompileTarget, + ps, pixelShaderEntryPointName, psCompileTarget, + callback, baseMaterial, userData); + + delete [] vs; + delete [] ps; + + return result; +} + +//! Adds a new material renderer to the VideoDriver, using pixel and/or +//! vertex shaders to render geometry. +s32 CNullDriver::addShaderMaterial(const c8* vertexShaderProgram, + const c8* pixelShaderProgram, + IShaderConstantSetCallBack* callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) +{ + os::Printer::log("Shader materials not implemented yet in this driver, sorry."); + return -1; +} + +//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the +//! programs from files. +s32 CNullDriver::addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram, + io::IReadFile* pixelShaderProgram, + IShaderConstantSetCallBack* callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) +{ + c8* vs = 0; + c8* ps = 0; + + if (vertexShaderProgram) + { + s32 size = vertexShaderProgram->getSize(); + if (size) + { + vs = new c8[size+1]; + vertexShaderProgram->read(vs, size); + vs[size] = 0; + } + } + + if (pixelShaderProgram) + { + s32 size = pixelShaderProgram->getSize(); + if (size) + { + ps = new c8[size+1]; + pixelShaderProgram->read(ps, size); + ps[size] = 0; + } + } + + s32 result = addShaderMaterial(vs, ps, callback, baseMaterial, userData); + + delete [] vs; + delete [] ps; + + return result; +} + + + +//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the +//! programs from files. +s32 CNullDriver::addShaderMaterialFromFiles(const c8* vertexShaderProgramFileName, + const c8* pixelShaderProgramFileName, + IShaderConstantSetCallBack* callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) +{ + io::IReadFile* vsfile = 0; + io::IReadFile* psfile = 0; + + if (vertexShaderProgramFileName) + { + vsfile = FileSystem->createAndOpenFile(vertexShaderProgramFileName); + if (!vsfile) + { + os::Printer::log("Could not open vertex shader program file", + vertexShaderProgramFileName, ELL_WARNING); + return -1; + } + } + + if (pixelShaderProgramFileName) + { + psfile = FileSystem->createAndOpenFile(pixelShaderProgramFileName); + if (!psfile) + { + os::Printer::log("Could not open pixel shader program file", + pixelShaderProgramFileName, ELL_WARNING); + if (vsfile) + vsfile->drop(); + return -1; + } + } + + s32 result = addShaderMaterialFromFiles(vsfile, psfile, callback, + baseMaterial, userData); + + if (psfile) + psfile->drop(); + + if (vsfile) + vsfile->drop(); + + return result; +} + +//! Creates a render target texture. +ITexture* CNullDriver::createRenderTargetTexture(const core::dimension2d& size) +{ + return 0; +} + +//! Clears the ZBuffer. +void CNullDriver::clearZBuffer() +{ +} + +//! Returns an image created from the last rendered frame. +IImage* CNullDriver::createScreenShot() +{ + return 0; +} + +// prints renderer version +void CNullDriver::printVersion() +{ + core::stringw namePrint = L"Using renderer: "; + namePrint += getName(); + os::Printer::log(namePrint.c_str(), ELL_INFORMATION); +} + + +//! creates a video driver +IVideoDriver* createNullDriver(io::IFileSystem* io, const core::dimension2d& screenSize) +{ + return new CNullDriver(io, screenSize); +} + + +} // end namespace +} // end namespace + diff --git a/src/dep/src/irrlicht/CNullDriver.h b/src/dep/src/irrlicht/CNullDriver.h index 02e6218..75f0aa5 100644 --- a/src/dep/src/irrlicht/CNullDriver.h +++ b/src/dep/src/irrlicht/CNullDriver.h @@ -1,503 +1,503 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_VIDEO_NULL_H_INCLUDED__ -#define __C_VIDEO_NULL_H_INCLUDED__ - -#include "IVideoDriver.h" -#include "IFileSystem.h" -#include "IImagePresenter.h" -#include "irrArray.h" -#include "irrString.h" -#include "IAttributes.h" -#include "IImageLoader.h" -#include "IImageWriter.h" -#include "IMeshBuffer.h" -#include "CFPSCounter.h" -#include "S3DVertex.h" -#include "SLight.h" - -namespace irr -{ -namespace video -{ - class CNullDriver : public IVideoDriver, public IGPUProgrammingServices - { - public: - - //! constructor - CNullDriver(io::IFileSystem* io, const core::dimension2d& screenSize); - - //! destructor - virtual ~CNullDriver(); - - virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color); - - virtual bool endScene( s32 windowId = 0, core::rect* sourceRect=0 ); - - //! queries the features of the driver, returns true if feature is available - virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature); - - //! sets transformation - virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); - - //! sets a material - virtual void setMaterial(const SMaterial& material); - - //! loads a Texture - virtual ITexture* getTexture(const c8* filename); - - //! loads a Texture - virtual ITexture* getTexture(io::IReadFile* file); - - //! Returns a texture by index - virtual ITexture* getTextureByIndex(u32 index); - - //! Returns amount of textures currently loaded - virtual s32 getTextureCount(); - - //! creates a Texture - virtual ITexture* addTexture(const core::dimension2d& size, const c8* name, ECOLOR_FORMAT format = ECF_A8R8G8B8); - - //! sets a render target - virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color); - - //! sets a viewport - virtual void setViewPort(const core::rect& area); - - //! gets the area of the current viewport - virtual const core::rect& getViewPort() const; - - //! draws a vertex primitive list - virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(const S3DVertex* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(const S3DVertex2TCoords* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! Draws an indexed triangle list. - virtual void drawIndexedTriangleList(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! Draws an indexed triangle fan. - virtual void drawIndexedTriangleFan(const S3DVertex* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! Draws an indexed triangle list. - virtual void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! Draws an indexed triangle fan. - inline void drawIndexedTriangleFan(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! Draws a 3d line. - virtual void draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color = SColor(255,255,255,255)); - - //! Draws a 3d triangle. - virtual void draw3DTriangle(const core::triangle3df& triangle, - SColor color = SColor(255,255,255,255)); - - //! Draws a 3d axis aligned box. - virtual void draw3DBox(const core::aabbox3d box, - SColor color = SColor(255,255,255,255)); - - //! draws an 2d image - virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos); - - //! draws a set of 2d images, using a color and the alpha - /** channel of the texture if desired. The images are drawn - beginning at pos and concatenated in one line. All drawings - are clipped against clipRect (if != 0). - The subtextures are defined by the array of sourceRects - and are chosen by the indices given. - \param texture: Texture to be drawn. - \param pos: Upper left 2d destination position where the image will be drawn. - \param sourceRects: Source rectangles of the image. - \param indices: List of indices which choose the actual rectangle used each time. - \param kerningWidth: offset on position - \param clipRect: Pointer to rectangle on the screen where the image is clipped to. - This pointer can be 0. Then the image is not clipped. - \param color: Color with which the image is colored. - Note that the alpha component is used: If alpha is other than 255, the image will be transparent. - \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is - used to draw the image. */ - virtual void draw2DImage(video::ITexture* texture, - const core::position2d& pos, - const core::array >& sourceRects, - const core::array& indices, - s32 kerningWidth, - const core::rect* clipRect, SColor color, - bool useAlphaChannelOfTexture); - - //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. - virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos, - const core::rect& sourceRect, const core::rect* clipRect = 0, - SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); - - //! Draws a part of the texture into the rectangle. - virtual void draw2DImage(video::ITexture* texture, const core::rect& destRect, - const core::rect& sourceRect, const core::rect* clipRect = 0, - video::SColor* colors=0, bool useAlphaChannelOfTexture=false); - - //! draw an 2d rectangle - virtual void draw2DRectangle(SColor color, const core::rect& pos, const core::rect* clip = 0); - - //!Draws an 2d rectangle with a gradient. - virtual void draw2DRectangle(const core::rect& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect* clip = 0); - - //! Draws a 2d line. - virtual void draw2DLine(const core::position2d& start, - const core::position2d& end, - SColor color=SColor(255,255,255,255)); - - //! Draws a non filled concyclic reqular 2d polyon. - virtual void draw2DPolygon(core::position2d center, - f32 radius, video::SColor Color, s32 vertexCount); - - virtual void setFog(SColor color=SColor(0,255,255,255), bool linearFog=true, - f32 start=50.0f, f32 end=100.0f, - f32 density=0.01f, bool pixelFog=false, bool rangeFog=false); - - //! returns screen size - virtual core::dimension2d getScreenSize(); - - //! returns screen size - virtual core::dimension2d getCurrentRenderTargetSize(); - - // returns current frames per second value - virtual s32 getFPS(); - - //! returns amount of primitives (mostly triangles) were drawn in the last frame. - //! very useful method for statistics. - virtual u32 getPrimitiveCountDrawn( u32 param ); - - //! deletes all dynamic lights there are - virtual void deleteAllDynamicLights(); - - //! adds a dynamic light - virtual void addDynamicLight(const SLight& light); - - //! returns the maximal amount of dynamic lights the device can handle - virtual u32 getMaximalDynamicLightAmount(); - - //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 - //! driver, it would return "Direct3D8.1". - virtual const wchar_t* getName(); - - //! Sets the dynamic ambient light color. The default color is - //! (0,0,0,0) which means it is dark. - //! \param color: New color of the ambient light. - virtual void setAmbientLight(const SColorf& color); - - //! Adds an external image loader to the engine. - virtual void addExternalImageLoader(IImageLoader* loader); - - //! Adds an external image writer to the engine. - virtual void addExternalImageWriter(IImageWriter* writer); - - //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do - //! this: Frist, draw all geometry. Then use this method, to draw the shadow - //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. - virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail=true); - - //! Fills the stencil shadow with color. After the shadow volume has been drawn - //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this - //! to draw the color of the shadow. - virtual void drawStencilShadow(bool clearStencilBuffer=false, - video::SColor leftUpEdge = video::SColor(0,0,0,0), - video::SColor rightUpEdge = video::SColor(0,0,0,0), - video::SColor leftDownEdge = video::SColor(0,0,0,0), - video::SColor rightDownEdge = video::SColor(0,0,0,0)); - - //! Returns current amount of dynamic lights set - //! \return Current amount of dynamic lights set - virtual u32 getDynamicLightCount(); - - //! Returns light data which was previously set with IVideDriver::addDynamicLight(). - //! \param idx: Zero based index of the light. Must be greater than 0 and smaller - //! than IVideoDriver()::getDynamicLightCount. - //! \return Light data. - virtual const SLight& getDynamicLight(u32 idx); - - //! Removes a texture from the texture cache and deletes it, freeing lot of - //! memory. - virtual void removeTexture(ITexture* texture); - - //! Removes all texture from the texture cache and deletes them, freeing lot of - //! memory. - virtual void removeAllTextures(); - - //! Creates a render target texture. - virtual ITexture* createRenderTargetTexture(const core::dimension2d& size); - - //! Creates an 1bit alpha channel of the texture based of an color key. - virtual void makeColorKeyTexture(video::ITexture* texture, video::SColor color); - - //! Creates an 1bit alpha channel of the texture based of an color key position. - virtual void makeColorKeyTexture(video::ITexture* texture, core::position2d colorKeyPixelPos); - - //! Creates a normal map from a height map texture. - //! \param amplitude: Constant value by which the height information is multiplied. - virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f); - - //! Returns the maximum amount of primitives (mostly vertices) which - //! the device is able to render with one drawIndexedTriangleList - //! call. - virtual u32 getMaximalPrimitiveCount(); - - //! Enables or disables a texture creation flag. - virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled); - - //! Returns if a texture creation flag is enabled or disabled. - virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag); - - //! Creates a software image from a file. - virtual IImage* createImageFromFile(const char* filename); - - //! Creates a software image from a file. - virtual IImage* createImageFromFile(io::IReadFile* file); - - //! Creates a software image from a byte array. - //! \param useForeignMemory: If true, the image will use the data pointer - //! directly and own it from now on, which means it will also try to delete [] the - //! data when the image will be destructed. If false, the memory will by copied. - virtual IImage* createImageFromData(ECOLOR_FORMAT format, - const core::dimension2d& size, void *data, - bool ownForeignMemory=true, bool deleteForeignMemory = true); - - //! Draws a mesh buffer - virtual void drawMeshBuffer(const scene::IMeshBuffer* mb); - - //! Only used by the internal engine. Used to notify the driver that - //! the window was resized. - virtual void OnResize(const core::dimension2d& size); - - //! Adds a new material renderer to the video device. - virtual s32 addMaterialRenderer(IMaterialRenderer* renderer, const char* name = 0); - - //! Returns driver and operating system specific data about the IVideoDriver. - virtual SExposedVideoData getExposedVideoData(); - - //! Returns type of video driver - virtual E_DRIVER_TYPE getDriverType(); - - //! Returns the transformation set by setTransform - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state); - - //! Returns pointer to the IGPUProgrammingServices interface. - virtual IGPUProgrammingServices* getGPUProgrammingServices(); - - //! Adds a new material renderer to the VideoDriver, using pixel and/or - //! vertex shaders to render geometry. - virtual s32 addShaderMaterial(const c8* vertexShaderProgram = 0, - const c8* pixelShaderProgram = 0, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData=0); - - //! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the - //! programs from files. - virtual s32 addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram = 0, - io::IReadFile* pixelShaderProgram = 0, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData=0); - - //! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the - //! programs from files. - virtual s32 addShaderMaterialFromFiles(const c8* vertexShaderProgramFileName = 0, - const c8* pixelShaderProgramFileName = 0, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData=0); - - //! Returns pointer to material renderer or null - virtual IMaterialRenderer* getMaterialRenderer(u32 idx); - - //! Returns amount of currently available material renderers. - virtual u32 getMaterialRendererCount(); - - //! Returns name of the material renderer - virtual const char* getMaterialRendererName(u32 idx); - - //! Adds a new material renderer to the VideoDriver, based on a high level shading - //! language. Currently only HLSL in D3D9 is supported. - virtual s32 addHighLevelShaderMaterial( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName = 0, - E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, - const c8* pixelShaderProgram = 0, - const c8* pixelShaderEntryPointName = 0, - E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData=0); - - //! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), - //! but tries to load the programs from files. - virtual s32 addHighLevelShaderMaterialFromFiles( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName = "main", - E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, - const c8* pixelShaderProgram = 0, - const c8* pixelShaderEntryPointName = "main", - E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData=0); - - //! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), - //! but tries to load the programs from files. - virtual s32 addHighLevelShaderMaterialFromFiles( - io::IReadFile* vertexShaderProgram, - const c8* vertexShaderEntryPointName = "main", - E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, - io::IReadFile* pixelShaderProgram = 0, - const c8* pixelShaderEntryPointName = "main", - E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData=0); - - //! Clears the ZBuffer. - virtual void clearZBuffer(); - - //! Returns an image created from the last rendered frame. - virtual IImage* createScreenShot(); - - //! Writes the provided image to disk file - virtual bool writeImageToFile(IImage* image, const char* filename, u32 param = 0); - - //! Sets the name of a material renderer. - virtual void setMaterialRendererName(s32 idx, const char* name); - - //! Creates material attributes list from a material, usable for serialization and more. - virtual io::IAttributes* createAttributesFromMaterial(const video::SMaterial& material); - - //! Fills an SMaterial structure from attributes. - virtual void fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attributes); - - protected: - - //! deletes all textures - void deleteAllTextures(); - - //! looks if the image is already loaded - video::ITexture* findTexture(const c8* filename); - - //! opens the file and loads it into the surface - video::ITexture* loadTextureFromFile(io::IReadFile* file, const c8* hashName = 0); - - //! adds a surface, not loaded or created by the Irrlicht Engine - void addTexture(video::ITexture* surface); - - //! Creates a texture from a loaded IImage. - virtual ITexture* addTexture(const c8* name, IImage* image); - - //! returns a device dependent texture from a software surface (IImage) - //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES - virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const char* name); - - //! checks triangle count and print warning if wrong - bool checkPrimitiveCount(s32 prmcnt); - - // adds a material renderer and drops it afterwards. To be used for internal creation - s32 addAndDropMaterialRenderer(IMaterialRenderer* m); - - //! deletes all material renderers - void deleteMaterialRenders(); - - // prints renderer version - void printVersion(); - - //! normal map lookup 32 bit version - inline f32 nml32(int x, int y, int pitch, int height, s32 *p) - { - if (x < 0) x = pitch-1; if (x >= pitch) x = 0; - if (y < 0) y = height-1; if (y >= height) y = 0; - return (f32)(((p[(y * pitch) + x])>>16) & 0xff); - } - - //! normal map lookup 16 bit version - inline f32 nml16(int x, int y, int pitch, int height, s16 *p) - { - if (x < 0) x = pitch-1; if (x >= pitch) x = 0; - if (y < 0) y = height-1; if (y >= height) y = 0; - - return (f32) getAverage ( p[(y * pitch) + x] ); - } - - struct SSurface - { - video::ITexture* Surface; - - bool operator < (const SSurface& other) const - { - return Surface->getName() < other.Surface->getName(); - } - }; - - struct SMaterialRenderer - { - core::stringc Name; - IMaterialRenderer* Renderer; - }; - - struct SDummyTexture : public ITexture - { - SDummyTexture(const char* name) : ITexture(name), size(0,0) {}; - - virtual void* lock() { return 0; }; - virtual void unlock(){} - virtual const core::dimension2d& getOriginalSize() { return size; } - virtual const core::dimension2d& getSize() { return size; } - virtual E_DRIVER_TYPE getDriverType() { return video::EDT_NULL; } - virtual ECOLOR_FORMAT getColorFormat() const { return video::ECF_R5G6B5; }; - virtual u32 getPitch() const { return 0; } - virtual void regenerateMipMapLevels() {}; - core::dimension2d size; - }; - - core::array Textures; - core::array SurfaceLoader; - core::array SurfaceWriter; - core::array Lights; - core::array MaterialRenderers; - - io::IFileSystem* FileSystem; - - core::rect ViewPort; - core::dimension2d ScreenSize; - core::matrix4 TransformationMatrix; - - CFPSCounter FPSCounter; - - u32 PrimitivesDrawn; - - u32 TextureCreationFlags; - - bool LinearFog; - f32 FogStart; - f32 FogEnd; - f32 FogDensity; - bool PixelFog; - bool RangeFog; - SColor FogColor; - - SExposedVideoData ExposedData; - }; - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_VIDEO_NULL_H_INCLUDED__ +#define __C_VIDEO_NULL_H_INCLUDED__ + +#include "IVideoDriver.h" +#include "IFileSystem.h" +#include "IImagePresenter.h" +#include "irrArray.h" +#include "irrString.h" +#include "IAttributes.h" +#include "IImageLoader.h" +#include "IImageWriter.h" +#include "IMeshBuffer.h" +#include "CFPSCounter.h" +#include "S3DVertex.h" +#include "SLight.h" + +namespace irr +{ +namespace video +{ + class CNullDriver : public IVideoDriver, public IGPUProgrammingServices + { + public: + + //! constructor + CNullDriver(io::IFileSystem* io, const core::dimension2d& screenSize); + + //! destructor + virtual ~CNullDriver(); + + virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color); + + virtual bool endScene( s32 windowId = 0, core::rect* sourceRect=0 ); + + //! queries the features of the driver, returns true if feature is available + virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature); + + //! sets transformation + virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); + + //! sets a material + virtual void setMaterial(const SMaterial& material); + + //! loads a Texture + virtual ITexture* getTexture(const c8* filename); + + //! loads a Texture + virtual ITexture* getTexture(io::IReadFile* file); + + //! Returns a texture by index + virtual ITexture* getTextureByIndex(u32 index); + + //! Returns amount of textures currently loaded + virtual s32 getTextureCount(); + + //! creates a Texture + virtual ITexture* addTexture(const core::dimension2d& size, const c8* name, ECOLOR_FORMAT format = ECF_A8R8G8B8); + + //! sets a render target + virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, + bool clearZBuffer, SColor color); + + //! sets a viewport + virtual void setViewPort(const core::rect& area); + + //! gets the area of the current viewport + virtual const core::rect& getViewPort() const; + + //! draws a vertex primitive list + virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); + + //! draws an indexed triangle list + virtual void drawIndexedTriangleList(const S3DVertex* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount); + + //! draws an indexed triangle list + virtual void drawIndexedTriangleList(const S3DVertex2TCoords* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount); + + //! Draws an indexed triangle list. + virtual void drawIndexedTriangleList(const S3DVertexTangents* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount); + + //! Draws an indexed triangle fan. + virtual void drawIndexedTriangleFan(const S3DVertex* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount); + + //! Draws an indexed triangle list. + virtual void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount); + + //! Draws an indexed triangle fan. + inline void drawIndexedTriangleFan(const S3DVertexTangents* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount); + + //! Draws a 3d line. + virtual void draw3DLine(const core::vector3df& start, + const core::vector3df& end, SColor color = SColor(255,255,255,255)); + + //! Draws a 3d triangle. + virtual void draw3DTriangle(const core::triangle3df& triangle, + SColor color = SColor(255,255,255,255)); + + //! Draws a 3d axis aligned box. + virtual void draw3DBox(const core::aabbox3d box, + SColor color = SColor(255,255,255,255)); + + //! draws an 2d image + virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos); + + //! draws a set of 2d images, using a color and the alpha + /** channel of the texture if desired. The images are drawn + beginning at pos and concatenated in one line. All drawings + are clipped against clipRect (if != 0). + The subtextures are defined by the array of sourceRects + and are chosen by the indices given. + \param texture: Texture to be drawn. + \param pos: Upper left 2d destination position where the image will be drawn. + \param sourceRects: Source rectangles of the image. + \param indices: List of indices which choose the actual rectangle used each time. + \param kerningWidth: offset on position + \param clipRect: Pointer to rectangle on the screen where the image is clipped to. + This pointer can be 0. Then the image is not clipped. + \param color: Color with which the image is colored. + Note that the alpha component is used: If alpha is other than 255, the image will be transparent. + \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is + used to draw the image. */ + virtual void draw2DImage(video::ITexture* texture, + const core::position2d& pos, + const core::array >& sourceRects, + const core::array& indices, + s32 kerningWidth, + const core::rect* clipRect, SColor color, + bool useAlphaChannelOfTexture); + + //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. + virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos, + const core::rect& sourceRect, const core::rect* clipRect = 0, + SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); + + //! Draws a part of the texture into the rectangle. + virtual void draw2DImage(video::ITexture* texture, const core::rect& destRect, + const core::rect& sourceRect, const core::rect* clipRect = 0, + video::SColor* colors=0, bool useAlphaChannelOfTexture=false); + + //! draw an 2d rectangle + virtual void draw2DRectangle(SColor color, const core::rect& pos, const core::rect* clip = 0); + + //!Draws an 2d rectangle with a gradient. + virtual void draw2DRectangle(const core::rect& pos, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect* clip = 0); + + //! Draws a 2d line. + virtual void draw2DLine(const core::position2d& start, + const core::position2d& end, + SColor color=SColor(255,255,255,255)); + + //! Draws a non filled concyclic reqular 2d polyon. + virtual void draw2DPolygon(core::position2d center, + f32 radius, video::SColor Color, s32 vertexCount); + + virtual void setFog(SColor color=SColor(0,255,255,255), bool linearFog=true, + f32 start=50.0f, f32 end=100.0f, + f32 density=0.01f, bool pixelFog=false, bool rangeFog=false); + + //! returns screen size + virtual core::dimension2d getScreenSize(); + + //! returns screen size + virtual core::dimension2d getCurrentRenderTargetSize(); + + // returns current frames per second value + virtual s32 getFPS(); + + //! returns amount of primitives (mostly triangles) were drawn in the last frame. + //! very useful method for statistics. + virtual u32 getPrimitiveCountDrawn( u32 param ); + + //! deletes all dynamic lights there are + virtual void deleteAllDynamicLights(); + + //! adds a dynamic light + virtual void addDynamicLight(const SLight& light); + + //! returns the maximal amount of dynamic lights the device can handle + virtual u32 getMaximalDynamicLightAmount(); + + //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 + //! driver, it would return "Direct3D8.1". + virtual const wchar_t* getName(); + + //! Sets the dynamic ambient light color. The default color is + //! (0,0,0,0) which means it is dark. + //! \param color: New color of the ambient light. + virtual void setAmbientLight(const SColorf& color); + + //! Adds an external image loader to the engine. + virtual void addExternalImageLoader(IImageLoader* loader); + + //! Adds an external image writer to the engine. + virtual void addExternalImageWriter(IImageWriter* writer); + + //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do + //! this: Frist, draw all geometry. Then use this method, to draw the shadow + //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. + virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail=true); + + //! Fills the stencil shadow with color. After the shadow volume has been drawn + //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this + //! to draw the color of the shadow. + virtual void drawStencilShadow(bool clearStencilBuffer=false, + video::SColor leftUpEdge = video::SColor(0,0,0,0), + video::SColor rightUpEdge = video::SColor(0,0,0,0), + video::SColor leftDownEdge = video::SColor(0,0,0,0), + video::SColor rightDownEdge = video::SColor(0,0,0,0)); + + //! Returns current amount of dynamic lights set + //! \return Current amount of dynamic lights set + virtual u32 getDynamicLightCount(); + + //! Returns light data which was previously set with IVideDriver::addDynamicLight(). + //! \param idx: Zero based index of the light. Must be greater than 0 and smaller + //! than IVideoDriver()::getDynamicLightCount. + //! \return Light data. + virtual const SLight& getDynamicLight(u32 idx); + + //! Removes a texture from the texture cache and deletes it, freeing lot of + //! memory. + virtual void removeTexture(ITexture* texture); + + //! Removes all texture from the texture cache and deletes them, freeing lot of + //! memory. + virtual void removeAllTextures(); + + //! Creates a render target texture. + virtual ITexture* createRenderTargetTexture(const core::dimension2d& size); + + //! Creates an 1bit alpha channel of the texture based of an color key. + virtual void makeColorKeyTexture(video::ITexture* texture, video::SColor color); + + //! Creates an 1bit alpha channel of the texture based of an color key position. + virtual void makeColorKeyTexture(video::ITexture* texture, core::position2d colorKeyPixelPos); + + //! Creates a normal map from a height map texture. + //! \param amplitude: Constant value by which the height information is multiplied. + virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f); + + //! Returns the maximum amount of primitives (mostly vertices) which + //! the device is able to render with one drawIndexedTriangleList + //! call. + virtual u32 getMaximalPrimitiveCount(); + + //! Enables or disables a texture creation flag. + virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled); + + //! Returns if a texture creation flag is enabled or disabled. + virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag); + + //! Creates a software image from a file. + virtual IImage* createImageFromFile(const char* filename); + + //! Creates a software image from a file. + virtual IImage* createImageFromFile(io::IReadFile* file); + + //! Creates a software image from a byte array. + //! \param useForeignMemory: If true, the image will use the data pointer + //! directly and own it from now on, which means it will also try to delete [] the + //! data when the image will be destructed. If false, the memory will by copied. + virtual IImage* createImageFromData(ECOLOR_FORMAT format, + const core::dimension2d& size, void *data, + bool ownForeignMemory=true, bool deleteForeignMemory = true); + + //! Draws a mesh buffer + virtual void drawMeshBuffer(const scene::IMeshBuffer* mb); + + //! Only used by the internal engine. Used to notify the driver that + //! the window was resized. + virtual void OnResize(const core::dimension2d& size); + + //! Adds a new material renderer to the video device. + virtual s32 addMaterialRenderer(IMaterialRenderer* renderer, const char* name = 0); + + //! Returns driver and operating system specific data about the IVideoDriver. + virtual SExposedVideoData getExposedVideoData(); + + //! Returns type of video driver + virtual E_DRIVER_TYPE getDriverType(); + + //! Returns the transformation set by setTransform + virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state); + + //! Returns pointer to the IGPUProgrammingServices interface. + virtual IGPUProgrammingServices* getGPUProgrammingServices(); + + //! Adds a new material renderer to the VideoDriver, using pixel and/or + //! vertex shaders to render geometry. + virtual s32 addShaderMaterial(const c8* vertexShaderProgram = 0, + const c8* pixelShaderProgram = 0, + IShaderConstantSetCallBack* callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData=0); + + //! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the + //! programs from files. + virtual s32 addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram = 0, + io::IReadFile* pixelShaderProgram = 0, + IShaderConstantSetCallBack* callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData=0); + + //! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the + //! programs from files. + virtual s32 addShaderMaterialFromFiles(const c8* vertexShaderProgramFileName = 0, + const c8* pixelShaderProgramFileName = 0, + IShaderConstantSetCallBack* callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData=0); + + //! Returns pointer to material renderer or null + virtual IMaterialRenderer* getMaterialRenderer(u32 idx); + + //! Returns amount of currently available material renderers. + virtual u32 getMaterialRendererCount(); + + //! Returns name of the material renderer + virtual const char* getMaterialRendererName(u32 idx); + + //! Adds a new material renderer to the VideoDriver, based on a high level shading + //! language. Currently only HLSL in D3D9 is supported. + virtual s32 addHighLevelShaderMaterial( + const c8* vertexShaderProgram, + const c8* vertexShaderEntryPointName = 0, + E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, + const c8* pixelShaderProgram = 0, + const c8* pixelShaderEntryPointName = 0, + E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, + IShaderConstantSetCallBack* callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData=0); + + //! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), + //! but tries to load the programs from files. + virtual s32 addHighLevelShaderMaterialFromFiles( + const c8* vertexShaderProgram, + const c8* vertexShaderEntryPointName = "main", + E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, + const c8* pixelShaderProgram = 0, + const c8* pixelShaderEntryPointName = "main", + E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, + IShaderConstantSetCallBack* callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData=0); + + //! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), + //! but tries to load the programs from files. + virtual s32 addHighLevelShaderMaterialFromFiles( + io::IReadFile* vertexShaderProgram, + const c8* vertexShaderEntryPointName = "main", + E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, + io::IReadFile* pixelShaderProgram = 0, + const c8* pixelShaderEntryPointName = "main", + E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, + IShaderConstantSetCallBack* callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData=0); + + //! Clears the ZBuffer. + virtual void clearZBuffer(); + + //! Returns an image created from the last rendered frame. + virtual IImage* createScreenShot(); + + //! Writes the provided image to disk file + virtual bool writeImageToFile(IImage* image, const char* filename, u32 param = 0); + + //! Sets the name of a material renderer. + virtual void setMaterialRendererName(s32 idx, const char* name); + + //! Creates material attributes list from a material, usable for serialization and more. + virtual io::IAttributes* createAttributesFromMaterial(const video::SMaterial& material); + + //! Fills an SMaterial structure from attributes. + virtual void fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attributes); + + protected: + + //! deletes all textures + void deleteAllTextures(); + + //! looks if the image is already loaded + video::ITexture* findTexture(const c8* filename); + + //! opens the file and loads it into the surface + video::ITexture* loadTextureFromFile(io::IReadFile* file, const c8* hashName = 0); + + //! adds a surface, not loaded or created by the Irrlicht Engine + void addTexture(video::ITexture* surface); + + //! Creates a texture from a loaded IImage. + virtual ITexture* addTexture(const c8* name, IImage* image); + + //! returns a device dependent texture from a software surface (IImage) + //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES + virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const char* name); + + //! checks triangle count and print warning if wrong + bool checkPrimitiveCount(s32 prmcnt); + + // adds a material renderer and drops it afterwards. To be used for internal creation + s32 addAndDropMaterialRenderer(IMaterialRenderer* m); + + //! deletes all material renderers + void deleteMaterialRenders(); + + // prints renderer version + void printVersion(); + + //! normal map lookup 32 bit version + inline f32 nml32(int x, int y, int pitch, int height, s32 *p) + { + if (x < 0) x = pitch-1; if (x >= pitch) x = 0; + if (y < 0) y = height-1; if (y >= height) y = 0; + return (f32)(((p[(y * pitch) + x])>>16) & 0xff); + } + + //! normal map lookup 16 bit version + inline f32 nml16(int x, int y, int pitch, int height, s16 *p) + { + if (x < 0) x = pitch-1; if (x >= pitch) x = 0; + if (y < 0) y = height-1; if (y >= height) y = 0; + + return (f32) getAverage ( p[(y * pitch) + x] ); + } + + struct SSurface + { + video::ITexture* Surface; + + bool operator < (const SSurface& other) const + { + return Surface->getName() < other.Surface->getName(); + } + }; + + struct SMaterialRenderer + { + core::stringc Name; + IMaterialRenderer* Renderer; + }; + + struct SDummyTexture : public ITexture + { + SDummyTexture(const char* name) : ITexture(name), size(0,0) {}; + + virtual void* lock() { return 0; }; + virtual void unlock(){} + virtual const core::dimension2d& getOriginalSize() { return size; } + virtual const core::dimension2d& getSize() { return size; } + virtual E_DRIVER_TYPE getDriverType() { return video::EDT_NULL; } + virtual ECOLOR_FORMAT getColorFormat() const { return video::ECF_R5G6B5; }; + virtual u32 getPitch() const { return 0; } + virtual void regenerateMipMapLevels() {}; + core::dimension2d size; + }; + + core::array Textures; + core::array SurfaceLoader; + core::array SurfaceWriter; + core::array Lights; + core::array MaterialRenderers; + + io::IFileSystem* FileSystem; + + core::rect ViewPort; + core::dimension2d ScreenSize; + core::matrix4 TransformationMatrix; + + CFPSCounter FPSCounter; + + u32 PrimitivesDrawn; + + u32 TextureCreationFlags; + + bool LinearFog; + f32 FogStart; + f32 FogEnd; + f32 FogDensity; + bool PixelFog; + bool RangeFog; + SColor FogColor; + + SExposedVideoData ExposedData; + }; + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/COBJMeshFileLoader.cpp b/src/dep/src/irrlicht/COBJMeshFileLoader.cpp index 2fd8d65..2ba3fd6 100644 --- a/src/dep/src/irrlicht/COBJMeshFileLoader.cpp +++ b/src/dep/src/irrlicht/COBJMeshFileLoader.cpp @@ -1,816 +1,816 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "COBJMeshFileLoader.h" -#include "SMeshBuffer.h" -#include "SAnimatedMesh.h" -#include "fast_atof.h" -#include "irrString.h" -#include "coreutil.h" - -namespace irr -{ -namespace scene -{ - -//! Constructor -COBJMeshFileLoader::COBJMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver) -: FileSystem(fs), Driver(driver), Mesh(0) -{ - if (FileSystem) - FileSystem->grab(); - - if (Driver) - Driver->grab(); -} - - - -//! destructor -COBJMeshFileLoader::~COBJMeshFileLoader() -{ - if (FileSystem) - FileSystem->drop(); - - if (Driver) - Driver->drop(); - - if (Mesh) - Mesh->drop(); -} - - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool COBJMeshFileLoader::isALoadableFileExtension(const c8* filename) -{ - return strstr(filename, ".obj")!=0; -} - - - -//! creates/loads an animated mesh from the file. -//! \return Pointer to the created mesh. Returns 0 if loading failed. -//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). -//! See IUnknown::drop() for more information. -IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file) -{ - const u32 WORD_BUFFER_LENGTH = 512; - c8 wordBuffer[WORD_BUFFER_LENGTH]; - - if (Mesh) - Mesh->drop(); - Mesh = new SMesh(); - - core::array vertexBuffer; - core::array textureCoordBuffer; - core::array normalsBuffer; - SObjGroup * pCurrGroup = 0; - SObjMtl * pCurrMtl = new SObjMtl(); - pCurrMtl->name=""; - materials.push_back(pCurrMtl); - - u32 filesize = file->getSize(); - if (!filesize) - return false; - - // ******************************************************************** - // Patch to locate the file in the same folder as the .obj. - // If you load the file as "data/some.obj" and mtllib contains - // "mtlname test.mtl" (as usual), the loading will fail. Instead it - // must look for data/test.tml. This patch does exactly that. - // - // patch by mandrav@codeblocks.org - // ******************************************************************** - core::stringc obj_fullname = file->getFileName(); - core::stringc obj_relpath = ""; - s32 pathend = obj_fullname.findLast('/'); - if (pathend == -1) - pathend = obj_fullname.findLast('\\'); - if (pathend != -1) - obj_relpath = obj_fullname.subString(0, pathend + 1); - // ******************************************************************** - // end of mtl folder patch - // ******************************************************************** - - c8* pBuf = new c8[filesize]; - memset(pBuf, 0, filesize); - file->read((void*)pBuf, filesize); - const c8* const pBufEnd = pBuf+filesize; - - // Process obj information - const c8* pBufPtr = pBuf; - SObjMtl *pUseMtl=0; - while(pBufPtr != pBufEnd) - { - switch(pBufPtr[0]) - { - case 'm': // mtllib (material) - { - c8 name[WORD_BUFFER_LENGTH]; - pBufPtr = goAndCopyNextWord(name, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - readMTL(name, obj_relpath); - } - break; - - case 'v': // v, vn, vt - switch(pBufPtr[1]) - { - case ' ': // vertex - { - core::vector3df vec; - pBufPtr = readVec3(pBufPtr, vec, pBufEnd); - vertexBuffer.push_back(vec); - } - break; - - case 'n': // normal - { - core::vector3df vec; - pBufPtr = readVec3(pBufPtr, vec, pBufEnd); - normalsBuffer.push_back(vec); - } - break; - - case 't': // texcoord - { - core::vector2df vec; - pBufPtr = readVec2(pBufPtr, vec, pBufEnd); - textureCoordBuffer.push_back(vec); - } - break; - } - break; - - case 'g': // group - // get name of group - { - c8 groupName[WORD_BUFFER_LENGTH]; - pBufPtr = goAndCopyNextWord(groupName, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - pCurrGroup = findOrAddGroup(groupName); - } - break; - - case 's': // smoothing can be on or off - { - c8 smooth[WORD_BUFFER_LENGTH]; - pBufPtr = goAndCopyNextWord(smooth, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - } - break; - - case 'u': // usemtl - // get name of material - { - c8 matName[WORD_BUFFER_LENGTH]; - pBufPtr = goAndCopyNextWord(matName, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - // retrieve the material - pUseMtl = findMtl(matName); - // only change material if we found it - if (pUseMtl) - pCurrMtl = pUseMtl; - } - break; - - case 'f': // face - { - c8 vertexWord[WORD_BUFFER_LENGTH]; // for retrieving vertex data - video::S3DVertex v; - u32 currentVertexCount = pCurrMtl->pMeshbuffer->Vertices.size(); - u32 facePointCount = 0; // number of vertices in this face - - // Assign vertex color from currently active material's diffuse colour - if (pCurrMtl) - v.Color = pCurrMtl->pMeshbuffer->Material.DiffuseColor; - - // get all vertices data in this face (current line of obj file) - u32 length = copyLine(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - const c8* pLinePtr = wordBuffer; - const c8* const pEndPtr = wordBuffer+length; - - // read in all vertices - pLinePtr = goNextWord(pLinePtr, pEndPtr); - while (0 != pLinePtr[0]) - { - // Array to communicate with retrieveVertexIndices() - // sends the buffer sizes and gets the actual indices - // if index not set returns -1 - s32 Idx[3]; - Idx[0] = Idx[1] = Idx[2] = -1; - - // read in next vertex's data - u32 wlength = copyWord(vertexWord, pLinePtr, WORD_BUFFER_LENGTH, pBufEnd); - // this function will also convert obj's 1-based index to c++'s 0-based index - retrieveVertexIndices(vertexWord, Idx, vertexWord+wlength+1); - if ( -1 != Idx[0] ) - { - v.Pos = vertexBuffer[Idx[0]]; - } - if ( -1 != Idx[1] ) - { - v.TCoords = textureCoordBuffer[Idx[1]]; - } - if ( -1 != Idx[2] ) - { - v.Normal = normalsBuffer[Idx[2]]; - } - pCurrMtl->pMeshbuffer->Vertices.push_back(v); - ++facePointCount; - - // go to next vertex - pLinePtr = goNextWord(pLinePtr, pEndPtr); - } - - // Add indices for first 3 vertices - pCurrMtl->pMeshbuffer->Indices.push_back( currentVertexCount ); - pCurrMtl->pMeshbuffer->Indices.push_back( ( facePointCount - 1 ) + currentVertexCount ); - pCurrMtl->pMeshbuffer->Indices.push_back( ( facePointCount - 2 ) + currentVertexCount ); - // Add indices for subsequent vertices - for ( u32 i = 0; i < facePointCount - 3; ++i ) - { - pCurrMtl->pMeshbuffer->Indices.push_back( currentVertexCount ); - pCurrMtl->pMeshbuffer->Indices.push_back( ( facePointCount - 2 - i ) + currentVertexCount ); - pCurrMtl->pMeshbuffer->Indices.push_back( ( facePointCount - 3 - i ) + currentVertexCount ); - } - } - break; - - case '#': // comment - default: - break; - } // end switch(pBufPtr[0]) - // eat up rest of line - pBufPtr = goNextLine(pBufPtr, pBufEnd); - } // end while(pBufPtr && (pBufPtr-pBufpMeshbuffer->getIndexCount() > 0 ) - { - materials[m]->pMeshbuffer->recalculateBoundingBox(); - Mesh->addMeshBuffer( materials[m]->pMeshbuffer ); - } - } - - // Create the Animated mesh if there's anything in the mesh - SAnimatedMesh* pAM = 0; - if ( 0 != Mesh->getMeshBufferCount() ) - { - Mesh->recalculateBoundingBox(); - pAM = new SAnimatedMesh(); - pAM->Type = EAMT_OBJ; - pAM->addMesh(Mesh); - pAM->recalculateBoundingBox(); - } - - // Clean up the allocate obj file contents - delete [] pBuf; - // more cleaning up - cleanUp(); - Mesh->drop(); - Mesh = 0; - - return pAM; -} - - -void COBJMeshFileLoader::readMTL(const c8* pFileName, core::stringc relPath) -{ - const u32 WORD_BUFFER_LENGTH = 512; - - io::IReadFile * pMtlReader; - if (FileSystem->existFile(pFileName)) - pMtlReader = FileSystem->createAndOpenFile(pFileName); - else - // try to read in the relative path, the .obj is loaded from - pMtlReader = FileSystem->createAndOpenFile((relPath + pFileName).c_str()); - if (!pMtlReader) // fail to open and read file - return; - - u32 filesize = pMtlReader->getSize(); - if (!filesize) - return; - - c8* pBuf = new c8[filesize]; - pMtlReader->read((void*)pBuf, filesize); - const c8* pBufEnd = pBuf+filesize; - - SObjMtl* pCurrMaterial = 0; - - const c8* pBufPtr = pBuf; - while(pBufPtr != pBufEnd) - { - switch(*pBufPtr) - { - case 'n': // newmtl - { - // if there's an existing material, store it first - if ( pCurrMaterial ) - materials.push_back( pCurrMaterial ); - - // extract new material's name - c8 mtlNameBuf[WORD_BUFFER_LENGTH]; - pBufPtr = goAndCopyNextWord(mtlNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - - pCurrMaterial = new SObjMtl; - pCurrMaterial->name = mtlNameBuf; - } - break; - case 'i': // illum - illumination - if ( pCurrMaterial ) - { - const u32 COLOR_BUFFER_LENGTH = 16; - c8 illumStr[COLOR_BUFFER_LENGTH]; - - pBufPtr = goAndCopyNextWord(illumStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); - pCurrMaterial->illumination = (c8)atol(illumStr); - } - break; - case 'N': // Ns - shininess - if ( pCurrMaterial ) - { - const u32 COLOR_BUFFER_LENGTH = 16; - c8 nsStr[COLOR_BUFFER_LENGTH]; - - pBufPtr = goAndCopyNextWord(nsStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); - f32 shininessValue = core::fast_atof(nsStr); - - // wavefront shininess is from [0, 1000], so scale for OpenGL - shininessValue *= 0.128f; - pCurrMaterial->pMeshbuffer->Material.Shininess = shininessValue; - } - break; - case 'K': - if ( pCurrMaterial ) - { - switch(pBufPtr[1]) - { - case 'd': // Kd = diffuse - { - pBufPtr = readColor(pBufPtr, pCurrMaterial->pMeshbuffer->Material.DiffuseColor, pBufEnd); - - } - break; - - case 's': // Ks = specular - { - pBufPtr = readColor(pBufPtr, pCurrMaterial->pMeshbuffer->Material.SpecularColor, pBufEnd); - } - break; - - case 'a': // Ka = ambience - { - pBufPtr=readColor(pBufPtr, pCurrMaterial->pMeshbuffer->Material.AmbientColor, pBufEnd); - } - break; - case 'e': // Ke = emissive - { - pBufPtr=readColor(pBufPtr, pCurrMaterial->pMeshbuffer->Material.EmissiveColor, pBufEnd); - } - break; - } // end switch(pBufPtr[1]) - } // end case 'K': if ( 0 != pCurrMaterial )... - break; - case 'm': // texture maps - if (pCurrMaterial) - { - char type=0; // map_Kd - diffuse texture map - if (!strncmp(pBufPtr,"map_bump",8)) - type=1; - else if (!strncmp(pBufPtr,"map_d",5)) - type=2; - else if (!strncmp(pBufPtr,"map_refl",8)) - type=3; - // extract new material's name - c8 textureNameBuf[WORD_BUFFER_LENGTH]; - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - // handle options - while (textureNameBuf[0]=='-') - { - if (!strncmp(pBufPtr,"-blendu",7)) - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - if (!strncmp(pBufPtr,"-blendv",7)) - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - if (!strncmp(pBufPtr,"-cc",3)) - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - if (!strncmp(pBufPtr,"-clamp",6)) - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - if (!strncmp(pBufPtr,"-texres",7)) - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - if (!strncmp(pBufPtr,"-mm",3)) - { - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - } - if (!strncmp(pBufPtr,"-o",2)) - { - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - // next parameters are optional, so skip rest of loop if no number is found - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - if (!core::isdigit(textureNameBuf[0])) - continue; - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - if (!core::isdigit(textureNameBuf[0])) - continue; - } - if (!strncmp(pBufPtr,"-s",2)) - { - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - // next parameters are optional, so skip rest of loop if no number is found - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - if (!core::isdigit(textureNameBuf[0])) - continue; - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - if (!core::isdigit(textureNameBuf[0])) - continue; - } - if (!strncmp(pBufPtr,"-t",2)) - { - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - // next parameters are optional, so skip rest of loop if no number is found - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - if (!core::isdigit(textureNameBuf[0])) - continue; - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - if (!core::isdigit(textureNameBuf[0])) - continue; - } - // get next word - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - } - if (type==1) - { - pCurrMaterial->pMeshbuffer->Material.MaterialTypeParam=core::fast_atof(textureNameBuf); - pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - } - - video::ITexture * pTexture = 0; - if (FileSystem->existFile(textureNameBuf)) - pTexture = Driver->getTexture( textureNameBuf ); - else - // try to read in the relative path, the .obj is loaded from - pTexture = Driver->getTexture( (relPath + textureNameBuf).c_str() ); - if ( pTexture ) - { - if (type==0) - pCurrMaterial->pMeshbuffer->Material.Textures[0] = pTexture; - else if (type==1) - { - Driver->makeNormalMapTexture(pTexture); - pCurrMaterial->pMeshbuffer->Material.Textures[1] = pTexture; - pCurrMaterial->pMeshbuffer->Material.MaterialType=video::EMT_PARALLAX_MAP_SOLID; - } - else if (type==2) - { - pCurrMaterial->pMeshbuffer->Material.Textures[0] = pTexture; - pCurrMaterial->pMeshbuffer->Material.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR; - } - else if (type==3) - { -// pCurrMaterial->pMeshbuffer->Material.Textures[1] = pTexture; -// pCurrMaterial->pMeshbuffer->Material.MaterialType=video::EMT_REFLECTION_2_LAYER; - } - // Set diffuse material colour to white so as not to affect texture colour - // Because Maya set diffuse colour Kd to black when you use a diffuse colour map - // But is this the right thing to do? - pCurrMaterial->pMeshbuffer->Material.DiffuseColor.set( - pCurrMaterial->pMeshbuffer->Material.DiffuseColor.getAlpha(), 255, 255, 255 ); - } - } - break; - case 'd': // d - transparency - if ( pCurrMaterial ) - { - const u32 COLOR_BUFFER_LENGTH = 16; - c8 dStr[COLOR_BUFFER_LENGTH]; - - pBufPtr = goAndCopyNextWord(dStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); - f32 dValue = core::fast_atof(dStr); - - pCurrMaterial->pMeshbuffer->Material.DiffuseColor.setAlpha( (s32)(dValue * 255) ); - if (dValue<1.0f) - pCurrMaterial->pMeshbuffer->Material.MaterialType = irr::video::EMT_TRANSPARENT_VERTEX_ALPHA; - } - break; - case 'T': - if ( pCurrMaterial ) - { - switch ( pBufPtr[1] ) - { - case 'f': // Tf - Transmitivity - const u32 COLOR_BUFFER_LENGTH = 16; - c8 redStr[COLOR_BUFFER_LENGTH]; - c8 greenStr[COLOR_BUFFER_LENGTH]; - c8 blueStr[COLOR_BUFFER_LENGTH]; - - pBufPtr = goAndCopyNextWord(redStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); - pBufPtr = goAndCopyNextWord(greenStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); - pBufPtr = goAndCopyNextWord(blueStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); - - f32 transparency = ( core::fast_atof(redStr) + core::fast_atof(greenStr) + core::fast_atof(blueStr) ) / 3; - - pCurrMaterial->pMeshbuffer->Material.DiffuseColor.setAlpha( (s32)(transparency * 255) ); - if (transparency < 1.0f) - pCurrMaterial->pMeshbuffer->Material.MaterialType = irr::video::EMT_TRANSPARENT_VERTEX_ALPHA; - } - } - break; - default: // comments or not recognised - break; - } // end switch(pBufPtr[0]) - // go to next line - pBufPtr = goNextLine(pBufPtr, pBufEnd); - } // end while (pBufPtr) - - // end of file. if there's an existing material, store it - if ( pCurrMaterial ) - { - materials.push_back( pCurrMaterial ); - pCurrMaterial = 0; - } - - delete [] pBuf; - pMtlReader->drop(); -} - -//! Read RGB color -const c8* COBJMeshFileLoader::readColor(const c8* pBufPtr, video::SColor& color, const c8* const pBufEnd) -{ - const u32 COLOR_BUFFER_LENGTH = 16; - c8 colStr[COLOR_BUFFER_LENGTH]; - - color.setAlpha(255); - pBufPtr = goAndCopyNextWord(colStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); - color.setRed((s32)(core::fast_atof(colStr) * 255.0f)); - pBufPtr = goAndCopyNextWord(colStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); - color.setGreen((s32)(core::fast_atof(colStr) * 255.0f)); - pBufPtr = goAndCopyNextWord(colStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); - color.setBlue((s32)(core::fast_atof(colStr) * 255.0f)); - return pBufPtr; -} - - -//! Read 3d vector of floats -const c8* COBJMeshFileLoader::readVec3(const c8* pBufPtr, core::vector3df& vec, const c8* const pBufEnd) -{ - const u32 WORD_BUFFER_LENGTH = 256; - c8 wordBuffer[WORD_BUFFER_LENGTH]; - - pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - vec.X=-core::fast_atof(wordBuffer); // change handedness - pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - vec.Y=core::fast_atof(wordBuffer); - pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - vec.Z=core::fast_atof(wordBuffer); - return pBufPtr; -} - - -//! Read 2d vector of floats -const c8* COBJMeshFileLoader::readVec2(const c8* pBufPtr, core::vector2df& vec, const c8* const pBufEnd) -{ - const u32 WORD_BUFFER_LENGTH = 256; - c8 wordBuffer[WORD_BUFFER_LENGTH]; - - pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - vec.X=core::fast_atof(wordBuffer); - pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); - vec.Y=-core::fast_atof(wordBuffer); // change handedness - return pBufPtr; -} - - -//! Read boolean value represented as 'on' or 'off' -const c8* COBJMeshFileLoader::readBool(const c8* pBufPtr, bool& tf, const c8* const pBufEnd) -{ - const u32 BUFFER_LENGTH = 8; - c8 tfStr[BUFFER_LENGTH]; - - pBufPtr = goAndCopyNextWord(tfStr, pBufPtr, BUFFER_LENGTH, pBufEnd); - tf = strcmp(tfStr, "off") != 0; - return pBufPtr; -} - - -COBJMeshFileLoader::SObjMtl* COBJMeshFileLoader::findMtl(const c8* pMtlName) -{ - for (u32 i = 0; i < materials.size(); ++i) - { - if ( materials[i]->name == pMtlName ) - return materials[i]; - } - return 0; -} - - - -COBJMeshFileLoader::SObjGroup * COBJMeshFileLoader::findGroup(const c8* pGroupName) -{ - for (u32 i = 0; i < groups.size(); ++i) - { - if ( groups[i]->name == pGroupName ) - return groups[i]; - } - return 0; -} - - -COBJMeshFileLoader::SObjGroup * COBJMeshFileLoader::findOrAddGroup(const c8* pGroupName) -{ - SObjGroup * pGroup = findGroup( pGroupName ); - if ( 0 != pGroup ) - { - // group found, return it - return pGroup; - } - // group not found, create a new group - SObjGroup* group = new SObjGroup(); - group->name = pGroupName; - groups.push_back(group); - return group; -} - - -//! skip space characters and stop on first non-space -const c8* COBJMeshFileLoader::goFirstWord(const c8* buf, const c8* const pBufEnd) -{ - // skip space characters - while((buf != pBufEnd) && core::isspace(*buf)) - ++buf; - - return buf; -} - - -//! skip current word and stop at beginning of next one -const c8* COBJMeshFileLoader::goNextWord(const c8* buf, const c8* const pBufEnd) -{ - // skip current word - while(( buf != pBufEnd ) && !core::isspace(*buf)) - ++buf; - - return goFirstWord(buf, pBufEnd); -} - - -//! Read until line break is reached and stop at the next non-space character -const c8* COBJMeshFileLoader::goNextLine(const c8* buf, const c8* const pBufEnd) -{ - // look for newline characters - while(buf != pBufEnd) - { - // found it, so leave - if (*buf=='\n' || *buf=='\r') - break; - ++buf; - } - return goFirstWord(buf, pBufEnd); -} - - -u32 COBJMeshFileLoader::copyWord(c8* outBuf, const c8* const inBuf, u32 outBufLength, const c8* const pBufEnd) -{ - if (!outBufLength) - return 0; - if (!inBuf) - { - *outBuf = 0; - return 0; - } - - u32 i = 0; - while(inBuf[i]) - { - if (core::isspace(inBuf[i]) || &(inBuf[i]) == pBufEnd) - break; - ++i; - } - - u32 length = core::min_(i, outBufLength-1); - for (u32 j=0; j 2 ) - { - // error checking, shouldn't reach here unless file is wrong - idxType = 0; - } - } - else if (*pChar == '\0') - { - // set all missing values to disable (=-1) - while (++idxType < 3) - pIdx[idxType]=-1; - ++pChar; - break; // while - } - } - - // go to the next char - ++pChar; - } - - return true; -} - - -void COBJMeshFileLoader::cleanUp() -{ - u32 i; - - for (i = 0; i < materials.size(); ++i ) - { - materials[i]->pMeshbuffer->drop(); - delete materials[i]; - } - - materials.clear(); - - for (i = 0; i < groups.size(); ++i ) - { - delete groups[i]; - } - - groups.clear(); -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "COBJMeshFileLoader.h" +#include "SMeshBuffer.h" +#include "SAnimatedMesh.h" +#include "fast_atof.h" +#include "irrString.h" +#include "coreutil.h" + +namespace irr +{ +namespace scene +{ + +//! Constructor +COBJMeshFileLoader::COBJMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver) +: FileSystem(fs), Driver(driver), Mesh(0) +{ + if (FileSystem) + FileSystem->grab(); + + if (Driver) + Driver->grab(); +} + + + +//! destructor +COBJMeshFileLoader::~COBJMeshFileLoader() +{ + if (FileSystem) + FileSystem->drop(); + + if (Driver) + Driver->drop(); + + if (Mesh) + Mesh->drop(); +} + + + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".bsp") +bool COBJMeshFileLoader::isALoadableFileExtension(const c8* filename) +{ + return strstr(filename, ".obj")!=0; +} + + + +//! creates/loads an animated mesh from the file. +//! \return Pointer to the created mesh. Returns 0 if loading failed. +//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). +//! See IUnknown::drop() for more information. +IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file) +{ + const u32 WORD_BUFFER_LENGTH = 512; + c8 wordBuffer[WORD_BUFFER_LENGTH]; + + if (Mesh) + Mesh->drop(); + Mesh = new SMesh(); + + core::array vertexBuffer; + core::array textureCoordBuffer; + core::array normalsBuffer; + SObjGroup * pCurrGroup = 0; + SObjMtl * pCurrMtl = new SObjMtl(); + pCurrMtl->name=""; + materials.push_back(pCurrMtl); + + u32 filesize = file->getSize(); + if (!filesize) + return false; + + // ******************************************************************** + // Patch to locate the file in the same folder as the .obj. + // If you load the file as "data/some.obj" and mtllib contains + // "mtlname test.mtl" (as usual), the loading will fail. Instead it + // must look for data/test.tml. This patch does exactly that. + // + // patch by mandrav@codeblocks.org + // ******************************************************************** + core::stringc obj_fullname = file->getFileName(); + core::stringc obj_relpath = ""; + s32 pathend = obj_fullname.findLast('/'); + if (pathend == -1) + pathend = obj_fullname.findLast('\\'); + if (pathend != -1) + obj_relpath = obj_fullname.subString(0, pathend + 1); + // ******************************************************************** + // end of mtl folder patch + // ******************************************************************** + + c8* pBuf = new c8[filesize]; + memset(pBuf, 0, filesize); + file->read((void*)pBuf, filesize); + const c8* const pBufEnd = pBuf+filesize; + + // Process obj information + const c8* pBufPtr = pBuf; + SObjMtl *pUseMtl=0; + while(pBufPtr != pBufEnd) + { + switch(pBufPtr[0]) + { + case 'm': // mtllib (material) + { + c8 name[WORD_BUFFER_LENGTH]; + pBufPtr = goAndCopyNextWord(name, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + readMTL(name, obj_relpath); + } + break; + + case 'v': // v, vn, vt + switch(pBufPtr[1]) + { + case ' ': // vertex + { + core::vector3df vec; + pBufPtr = readVec3(pBufPtr, vec, pBufEnd); + vertexBuffer.push_back(vec); + } + break; + + case 'n': // normal + { + core::vector3df vec; + pBufPtr = readVec3(pBufPtr, vec, pBufEnd); + normalsBuffer.push_back(vec); + } + break; + + case 't': // texcoord + { + core::vector2df vec; + pBufPtr = readVec2(pBufPtr, vec, pBufEnd); + textureCoordBuffer.push_back(vec); + } + break; + } + break; + + case 'g': // group + // get name of group + { + c8 groupName[WORD_BUFFER_LENGTH]; + pBufPtr = goAndCopyNextWord(groupName, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + pCurrGroup = findOrAddGroup(groupName); + } + break; + + case 's': // smoothing can be on or off + { + c8 smooth[WORD_BUFFER_LENGTH]; + pBufPtr = goAndCopyNextWord(smooth, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + } + break; + + case 'u': // usemtl + // get name of material + { + c8 matName[WORD_BUFFER_LENGTH]; + pBufPtr = goAndCopyNextWord(matName, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + // retrieve the material + pUseMtl = findMtl(matName); + // only change material if we found it + if (pUseMtl) + pCurrMtl = pUseMtl; + } + break; + + case 'f': // face + { + c8 vertexWord[WORD_BUFFER_LENGTH]; // for retrieving vertex data + video::S3DVertex v; + u32 currentVertexCount = pCurrMtl->pMeshbuffer->Vertices.size(); + u32 facePointCount = 0; // number of vertices in this face + + // Assign vertex color from currently active material's diffuse colour + if (pCurrMtl) + v.Color = pCurrMtl->pMeshbuffer->Material.DiffuseColor; + + // get all vertices data in this face (current line of obj file) + u32 length = copyLine(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + const c8* pLinePtr = wordBuffer; + const c8* const pEndPtr = wordBuffer+length; + + // read in all vertices + pLinePtr = goNextWord(pLinePtr, pEndPtr); + while (0 != pLinePtr[0]) + { + // Array to communicate with retrieveVertexIndices() + // sends the buffer sizes and gets the actual indices + // if index not set returns -1 + s32 Idx[3]; + Idx[0] = Idx[1] = Idx[2] = -1; + + // read in next vertex's data + u32 wlength = copyWord(vertexWord, pLinePtr, WORD_BUFFER_LENGTH, pBufEnd); + // this function will also convert obj's 1-based index to c++'s 0-based index + retrieveVertexIndices(vertexWord, Idx, vertexWord+wlength+1); + if ( -1 != Idx[0] ) + { + v.Pos = vertexBuffer[Idx[0]]; + } + if ( -1 != Idx[1] ) + { + v.TCoords = textureCoordBuffer[Idx[1]]; + } + if ( -1 != Idx[2] ) + { + v.Normal = normalsBuffer[Idx[2]]; + } + pCurrMtl->pMeshbuffer->Vertices.push_back(v); + ++facePointCount; + + // go to next vertex + pLinePtr = goNextWord(pLinePtr, pEndPtr); + } + + // Add indices for first 3 vertices + pCurrMtl->pMeshbuffer->Indices.push_back( currentVertexCount ); + pCurrMtl->pMeshbuffer->Indices.push_back( ( facePointCount - 1 ) + currentVertexCount ); + pCurrMtl->pMeshbuffer->Indices.push_back( ( facePointCount - 2 ) + currentVertexCount ); + // Add indices for subsequent vertices + for ( u32 i = 0; i < facePointCount - 3; ++i ) + { + pCurrMtl->pMeshbuffer->Indices.push_back( currentVertexCount ); + pCurrMtl->pMeshbuffer->Indices.push_back( ( facePointCount - 2 - i ) + currentVertexCount ); + pCurrMtl->pMeshbuffer->Indices.push_back( ( facePointCount - 3 - i ) + currentVertexCount ); + } + } + break; + + case '#': // comment + default: + break; + } // end switch(pBufPtr[0]) + // eat up rest of line + pBufPtr = goNextLine(pBufPtr, pBufEnd); + } // end while(pBufPtr && (pBufPtr-pBufpMeshbuffer->getIndexCount() > 0 ) + { + materials[m]->pMeshbuffer->recalculateBoundingBox(); + Mesh->addMeshBuffer( materials[m]->pMeshbuffer ); + } + } + + // Create the Animated mesh if there's anything in the mesh + SAnimatedMesh* pAM = 0; + if ( 0 != Mesh->getMeshBufferCount() ) + { + Mesh->recalculateBoundingBox(); + pAM = new SAnimatedMesh(); + pAM->Type = EAMT_OBJ; + pAM->addMesh(Mesh); + pAM->recalculateBoundingBox(); + } + + // Clean up the allocate obj file contents + delete [] pBuf; + // more cleaning up + cleanUp(); + Mesh->drop(); + Mesh = 0; + + return pAM; +} + + +void COBJMeshFileLoader::readMTL(const c8* pFileName, core::stringc relPath) +{ + const u32 WORD_BUFFER_LENGTH = 512; + + io::IReadFile * pMtlReader; + if (FileSystem->existFile(pFileName)) + pMtlReader = FileSystem->createAndOpenFile(pFileName); + else + // try to read in the relative path, the .obj is loaded from + pMtlReader = FileSystem->createAndOpenFile((relPath + pFileName).c_str()); + if (!pMtlReader) // fail to open and read file + return; + + u32 filesize = pMtlReader->getSize(); + if (!filesize) + return; + + c8* pBuf = new c8[filesize]; + pMtlReader->read((void*)pBuf, filesize); + const c8* pBufEnd = pBuf+filesize; + + SObjMtl* pCurrMaterial = 0; + + const c8* pBufPtr = pBuf; + while(pBufPtr != pBufEnd) + { + switch(*pBufPtr) + { + case 'n': // newmtl + { + // if there's an existing material, store it first + if ( pCurrMaterial ) + materials.push_back( pCurrMaterial ); + + // extract new material's name + c8 mtlNameBuf[WORD_BUFFER_LENGTH]; + pBufPtr = goAndCopyNextWord(mtlNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + + pCurrMaterial = new SObjMtl; + pCurrMaterial->name = mtlNameBuf; + } + break; + case 'i': // illum - illumination + if ( pCurrMaterial ) + { + const u32 COLOR_BUFFER_LENGTH = 16; + c8 illumStr[COLOR_BUFFER_LENGTH]; + + pBufPtr = goAndCopyNextWord(illumStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); + pCurrMaterial->illumination = (c8)atol(illumStr); + } + break; + case 'N': // Ns - shininess + if ( pCurrMaterial ) + { + const u32 COLOR_BUFFER_LENGTH = 16; + c8 nsStr[COLOR_BUFFER_LENGTH]; + + pBufPtr = goAndCopyNextWord(nsStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); + f32 shininessValue = core::fast_atof(nsStr); + + // wavefront shininess is from [0, 1000], so scale for OpenGL + shininessValue *= 0.128f; + pCurrMaterial->pMeshbuffer->Material.Shininess = shininessValue; + } + break; + case 'K': + if ( pCurrMaterial ) + { + switch(pBufPtr[1]) + { + case 'd': // Kd = diffuse + { + pBufPtr = readColor(pBufPtr, pCurrMaterial->pMeshbuffer->Material.DiffuseColor, pBufEnd); + + } + break; + + case 's': // Ks = specular + { + pBufPtr = readColor(pBufPtr, pCurrMaterial->pMeshbuffer->Material.SpecularColor, pBufEnd); + } + break; + + case 'a': // Ka = ambience + { + pBufPtr=readColor(pBufPtr, pCurrMaterial->pMeshbuffer->Material.AmbientColor, pBufEnd); + } + break; + case 'e': // Ke = emissive + { + pBufPtr=readColor(pBufPtr, pCurrMaterial->pMeshbuffer->Material.EmissiveColor, pBufEnd); + } + break; + } // end switch(pBufPtr[1]) + } // end case 'K': if ( 0 != pCurrMaterial )... + break; + case 'm': // texture maps + if (pCurrMaterial) + { + char type=0; // map_Kd - diffuse texture map + if (!strncmp(pBufPtr,"map_bump",8)) + type=1; + else if (!strncmp(pBufPtr,"map_d",5)) + type=2; + else if (!strncmp(pBufPtr,"map_refl",8)) + type=3; + // extract new material's name + c8 textureNameBuf[WORD_BUFFER_LENGTH]; + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + // handle options + while (textureNameBuf[0]=='-') + { + if (!strncmp(pBufPtr,"-blendu",7)) + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + if (!strncmp(pBufPtr,"-blendv",7)) + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + if (!strncmp(pBufPtr,"-cc",3)) + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + if (!strncmp(pBufPtr,"-clamp",6)) + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + if (!strncmp(pBufPtr,"-texres",7)) + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + if (!strncmp(pBufPtr,"-mm",3)) + { + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + } + if (!strncmp(pBufPtr,"-o",2)) + { + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + // next parameters are optional, so skip rest of loop if no number is found + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + if (!core::isdigit(textureNameBuf[0])) + continue; + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + if (!core::isdigit(textureNameBuf[0])) + continue; + } + if (!strncmp(pBufPtr,"-s",2)) + { + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + // next parameters are optional, so skip rest of loop if no number is found + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + if (!core::isdigit(textureNameBuf[0])) + continue; + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + if (!core::isdigit(textureNameBuf[0])) + continue; + } + if (!strncmp(pBufPtr,"-t",2)) + { + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + // next parameters are optional, so skip rest of loop if no number is found + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + if (!core::isdigit(textureNameBuf[0])) + continue; + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + if (!core::isdigit(textureNameBuf[0])) + continue; + } + // get next word + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + } + if (type==1) + { + pCurrMaterial->pMeshbuffer->Material.MaterialTypeParam=core::fast_atof(textureNameBuf); + pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + } + + video::ITexture * pTexture = 0; + if (FileSystem->existFile(textureNameBuf)) + pTexture = Driver->getTexture( textureNameBuf ); + else + // try to read in the relative path, the .obj is loaded from + pTexture = Driver->getTexture( (relPath + textureNameBuf).c_str() ); + if ( pTexture ) + { + if (type==0) + pCurrMaterial->pMeshbuffer->Material.Textures[0] = pTexture; + else if (type==1) + { + Driver->makeNormalMapTexture(pTexture); + pCurrMaterial->pMeshbuffer->Material.Textures[1] = pTexture; + pCurrMaterial->pMeshbuffer->Material.MaterialType=video::EMT_PARALLAX_MAP_SOLID; + } + else if (type==2) + { + pCurrMaterial->pMeshbuffer->Material.Textures[0] = pTexture; + pCurrMaterial->pMeshbuffer->Material.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR; + } + else if (type==3) + { +// pCurrMaterial->pMeshbuffer->Material.Textures[1] = pTexture; +// pCurrMaterial->pMeshbuffer->Material.MaterialType=video::EMT_REFLECTION_2_LAYER; + } + // Set diffuse material colour to white so as not to affect texture colour + // Because Maya set diffuse colour Kd to black when you use a diffuse colour map + // But is this the right thing to do? + pCurrMaterial->pMeshbuffer->Material.DiffuseColor.set( + pCurrMaterial->pMeshbuffer->Material.DiffuseColor.getAlpha(), 255, 255, 255 ); + } + } + break; + case 'd': // d - transparency + if ( pCurrMaterial ) + { + const u32 COLOR_BUFFER_LENGTH = 16; + c8 dStr[COLOR_BUFFER_LENGTH]; + + pBufPtr = goAndCopyNextWord(dStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); + f32 dValue = core::fast_atof(dStr); + + pCurrMaterial->pMeshbuffer->Material.DiffuseColor.setAlpha( (s32)(dValue * 255) ); + if (dValue<1.0f) + pCurrMaterial->pMeshbuffer->Material.MaterialType = irr::video::EMT_TRANSPARENT_VERTEX_ALPHA; + } + break; + case 'T': + if ( pCurrMaterial ) + { + switch ( pBufPtr[1] ) + { + case 'f': // Tf - Transmitivity + const u32 COLOR_BUFFER_LENGTH = 16; + c8 redStr[COLOR_BUFFER_LENGTH]; + c8 greenStr[COLOR_BUFFER_LENGTH]; + c8 blueStr[COLOR_BUFFER_LENGTH]; + + pBufPtr = goAndCopyNextWord(redStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); + pBufPtr = goAndCopyNextWord(greenStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); + pBufPtr = goAndCopyNextWord(blueStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); + + f32 transparency = ( core::fast_atof(redStr) + core::fast_atof(greenStr) + core::fast_atof(blueStr) ) / 3; + + pCurrMaterial->pMeshbuffer->Material.DiffuseColor.setAlpha( (s32)(transparency * 255) ); + if (transparency < 1.0f) + pCurrMaterial->pMeshbuffer->Material.MaterialType = irr::video::EMT_TRANSPARENT_VERTEX_ALPHA; + } + } + break; + default: // comments or not recognised + break; + } // end switch(pBufPtr[0]) + // go to next line + pBufPtr = goNextLine(pBufPtr, pBufEnd); + } // end while (pBufPtr) + + // end of file. if there's an existing material, store it + if ( pCurrMaterial ) + { + materials.push_back( pCurrMaterial ); + pCurrMaterial = 0; + } + + delete [] pBuf; + pMtlReader->drop(); +} + +//! Read RGB color +const c8* COBJMeshFileLoader::readColor(const c8* pBufPtr, video::SColor& color, const c8* const pBufEnd) +{ + const u32 COLOR_BUFFER_LENGTH = 16; + c8 colStr[COLOR_BUFFER_LENGTH]; + + color.setAlpha(255); + pBufPtr = goAndCopyNextWord(colStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); + color.setRed((s32)(core::fast_atof(colStr) * 255.0f)); + pBufPtr = goAndCopyNextWord(colStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); + color.setGreen((s32)(core::fast_atof(colStr) * 255.0f)); + pBufPtr = goAndCopyNextWord(colStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd); + color.setBlue((s32)(core::fast_atof(colStr) * 255.0f)); + return pBufPtr; +} + + +//! Read 3d vector of floats +const c8* COBJMeshFileLoader::readVec3(const c8* pBufPtr, core::vector3df& vec, const c8* const pBufEnd) +{ + const u32 WORD_BUFFER_LENGTH = 256; + c8 wordBuffer[WORD_BUFFER_LENGTH]; + + pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + vec.X=-core::fast_atof(wordBuffer); // change handedness + pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + vec.Y=core::fast_atof(wordBuffer); + pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + vec.Z=core::fast_atof(wordBuffer); + return pBufPtr; +} + + +//! Read 2d vector of floats +const c8* COBJMeshFileLoader::readVec2(const c8* pBufPtr, core::vector2df& vec, const c8* const pBufEnd) +{ + const u32 WORD_BUFFER_LENGTH = 256; + c8 wordBuffer[WORD_BUFFER_LENGTH]; + + pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + vec.X=core::fast_atof(wordBuffer); + pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd); + vec.Y=-core::fast_atof(wordBuffer); // change handedness + return pBufPtr; +} + + +//! Read boolean value represented as 'on' or 'off' +const c8* COBJMeshFileLoader::readBool(const c8* pBufPtr, bool& tf, const c8* const pBufEnd) +{ + const u32 BUFFER_LENGTH = 8; + c8 tfStr[BUFFER_LENGTH]; + + pBufPtr = goAndCopyNextWord(tfStr, pBufPtr, BUFFER_LENGTH, pBufEnd); + tf = strcmp(tfStr, "off") != 0; + return pBufPtr; +} + + +COBJMeshFileLoader::SObjMtl* COBJMeshFileLoader::findMtl(const c8* pMtlName) +{ + for (u32 i = 0; i < materials.size(); ++i) + { + if ( materials[i]->name == pMtlName ) + return materials[i]; + } + return 0; +} + + + +COBJMeshFileLoader::SObjGroup * COBJMeshFileLoader::findGroup(const c8* pGroupName) +{ + for (u32 i = 0; i < groups.size(); ++i) + { + if ( groups[i]->name == pGroupName ) + return groups[i]; + } + return 0; +} + + +COBJMeshFileLoader::SObjGroup * COBJMeshFileLoader::findOrAddGroup(const c8* pGroupName) +{ + SObjGroup * pGroup = findGroup( pGroupName ); + if ( 0 != pGroup ) + { + // group found, return it + return pGroup; + } + // group not found, create a new group + SObjGroup* group = new SObjGroup(); + group->name = pGroupName; + groups.push_back(group); + return group; +} + + +//! skip space characters and stop on first non-space +const c8* COBJMeshFileLoader::goFirstWord(const c8* buf, const c8* const pBufEnd) +{ + // skip space characters + while((buf != pBufEnd) && core::isspace(*buf)) + ++buf; + + return buf; +} + + +//! skip current word and stop at beginning of next one +const c8* COBJMeshFileLoader::goNextWord(const c8* buf, const c8* const pBufEnd) +{ + // skip current word + while(( buf != pBufEnd ) && !core::isspace(*buf)) + ++buf; + + return goFirstWord(buf, pBufEnd); +} + + +//! Read until line break is reached and stop at the next non-space character +const c8* COBJMeshFileLoader::goNextLine(const c8* buf, const c8* const pBufEnd) +{ + // look for newline characters + while(buf != pBufEnd) + { + // found it, so leave + if (*buf=='\n' || *buf=='\r') + break; + ++buf; + } + return goFirstWord(buf, pBufEnd); +} + + +u32 COBJMeshFileLoader::copyWord(c8* outBuf, const c8* const inBuf, u32 outBufLength, const c8* const pBufEnd) +{ + if (!outBufLength) + return 0; + if (!inBuf) + { + *outBuf = 0; + return 0; + } + + u32 i = 0; + while(inBuf[i]) + { + if (core::isspace(inBuf[i]) || &(inBuf[i]) == pBufEnd) + break; + ++i; + } + + u32 length = core::min_(i, outBufLength-1); + for (u32 j=0; j 2 ) + { + // error checking, shouldn't reach here unless file is wrong + idxType = 0; + } + } + else if (*pChar == '\0') + { + // set all missing values to disable (=-1) + while (++idxType < 3) + pIdx[idxType]=-1; + ++pChar; + break; // while + } + } + + // go to the next char + ++pChar; + } + + return true; +} + + +void COBJMeshFileLoader::cleanUp() +{ + u32 i; + + for (i = 0; i < materials.size(); ++i ) + { + materials[i]->pMeshbuffer->drop(); + delete materials[i]; + } + + materials.clear(); + + for (i = 0; i < groups.size(); ++i ) + { + delete groups[i]; + } + + groups.clear(); +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/COBJMeshFileLoader.h b/src/dep/src/irrlicht/COBJMeshFileLoader.h index fd2ba57..87a53d5 100644 --- a/src/dep/src/irrlicht/COBJMeshFileLoader.h +++ b/src/dep/src/irrlicht/COBJMeshFileLoader.h @@ -1,115 +1,115 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OBJ_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_OBJ_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "irrString.h" -#include "SMesh.h" -#include "SMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - -//! Meshloader capable of loading 3ds meshes. -class COBJMeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - COBJMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver); - - //! destructor - virtual ~COBJMeshFileLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".cob") - virtual bool isALoadableFileExtension(const c8* fileName); - - //! creates/loads an animated mesh from the file. - //! \return Pointer to the created mesh. Returns 0 if loading failed. - //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). - //! See IUnknown::drop() for more information. - virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); - -private: - - struct SObjMtl - { - SObjMtl() : pMeshbuffer(0), illumination(0) { - this->pMeshbuffer = new SMeshBuffer(); - this->pMeshbuffer->Material.Shininess = 0.0f; - this->pMeshbuffer->Material.AmbientColor = video::SColorf(0.2f, 0.2f, 0.2f, 1.0f).toSColor(); - this->pMeshbuffer->Material.DiffuseColor = video::SColorf(0.8f, 0.8f, 0.8f, 1.0f).toSColor(); - this->pMeshbuffer->Material.SpecularColor = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f).toSColor(); - }; - SObjMtl(SObjMtl& o) : pMeshbuffer(o.pMeshbuffer) { o.pMeshbuffer->grab(); }; - - ~SObjMtl() { }; - - scene::SMeshBuffer *pMeshbuffer; - core::stringc name; - c8 illumination; - }; - - struct SObjGroup - { - SObjGroup() {}; - SObjGroup(SObjGroup& o) {}; - ~SObjGroup() { }; - - core::stringc name; - }; - - // returns a pointer to the first printable character available in the buffer - const c8* goFirstWord(const c8* buf, const c8* const pBufEnd); - // returns a pointer to the first printable character after the first non-printable - const c8* goNextWord(const c8* buf, const c8* const pBufEnd); - // returns a pointer to the next printable character after the first line break - const c8* goNextLine(const c8* buf, const c8* const pBufEnd); - // copies the current word from the inBuf to the outBuf - u32 copyWord(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd); - // copies the current line from the inBuf to the outBuf - u32 copyLine(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd); - // combination of goNextWord followed by copyWord - const c8* goAndCopyNextWord(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd); - - void readMTL(const c8* pFileName, core::stringc relPath); - //! Read RGB color - const c8* readColor(const c8* pBufPtr, video::SColor& color, const c8* const pBufEnd); - //! Read 3d vector of floats - const c8* readVec3(const c8* pBufPtr, core::vector3df& vec, const c8* const pBufEnd); - //! Read 2d vector of floats - const c8* readVec2(const c8* pBufPtr, core::vector2df& vec, const c8* const pBufEnd); - //! Read boolean value represented as 'on' or 'off' - const c8* readBool(const c8* pBufPtr, bool& tf, const c8* const pBufEnd); - SObjMtl * findMtl(const c8* pMtlName); - SObjGroup * findGroup(const c8* pGroupName); - SObjGroup * findOrAddGroup(const c8* pGroupName); - - // reads and convert to integer the vertex indices in a line of obj file's face statement - // -1 for the index if it doesn't exist - // indices are changed to 0-based index instead of 1-based from the obj file - bool retrieveVertexIndices(c8* pVertexData, s32* Idx, const c8* pBufEnd); - - void cleanUp(); - - io::IFileSystem* FileSystem; - video::IVideoDriver* Driver; - - core::array materials; - core::array groups; - SMesh* Mesh; -}; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_OBJ_MESH_FILE_LOADER_H_INCLUDED__ +#define __C_OBJ_MESH_FILE_LOADER_H_INCLUDED__ + +#include "IMeshLoader.h" +#include "IFileSystem.h" +#include "IVideoDriver.h" +#include "irrString.h" +#include "SMesh.h" +#include "SMeshBuffer.h" + +namespace irr +{ +namespace scene +{ + +//! Meshloader capable of loading 3ds meshes. +class COBJMeshFileLoader : public IMeshLoader +{ +public: + + //! Constructor + COBJMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver); + + //! destructor + virtual ~COBJMeshFileLoader(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".cob") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! creates/loads an animated mesh from the file. + //! \return Pointer to the created mesh. Returns 0 if loading failed. + //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). + //! See IUnknown::drop() for more information. + virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); + +private: + + struct SObjMtl + { + SObjMtl() : pMeshbuffer(0), illumination(0) { + this->pMeshbuffer = new SMeshBuffer(); + this->pMeshbuffer->Material.Shininess = 0.0f; + this->pMeshbuffer->Material.AmbientColor = video::SColorf(0.2f, 0.2f, 0.2f, 1.0f).toSColor(); + this->pMeshbuffer->Material.DiffuseColor = video::SColorf(0.8f, 0.8f, 0.8f, 1.0f).toSColor(); + this->pMeshbuffer->Material.SpecularColor = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f).toSColor(); + }; + SObjMtl(SObjMtl& o) : pMeshbuffer(o.pMeshbuffer) { o.pMeshbuffer->grab(); }; + + ~SObjMtl() { }; + + scene::SMeshBuffer *pMeshbuffer; + core::stringc name; + c8 illumination; + }; + + struct SObjGroup + { + SObjGroup() {}; + SObjGroup(SObjGroup& o) {}; + ~SObjGroup() { }; + + core::stringc name; + }; + + // returns a pointer to the first printable character available in the buffer + const c8* goFirstWord(const c8* buf, const c8* const pBufEnd); + // returns a pointer to the first printable character after the first non-printable + const c8* goNextWord(const c8* buf, const c8* const pBufEnd); + // returns a pointer to the next printable character after the first line break + const c8* goNextLine(const c8* buf, const c8* const pBufEnd); + // copies the current word from the inBuf to the outBuf + u32 copyWord(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd); + // copies the current line from the inBuf to the outBuf + u32 copyLine(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd); + // combination of goNextWord followed by copyWord + const c8* goAndCopyNextWord(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd); + + void readMTL(const c8* pFileName, core::stringc relPath); + //! Read RGB color + const c8* readColor(const c8* pBufPtr, video::SColor& color, const c8* const pBufEnd); + //! Read 3d vector of floats + const c8* readVec3(const c8* pBufPtr, core::vector3df& vec, const c8* const pBufEnd); + //! Read 2d vector of floats + const c8* readVec2(const c8* pBufPtr, core::vector2df& vec, const c8* const pBufEnd); + //! Read boolean value represented as 'on' or 'off' + const c8* readBool(const c8* pBufPtr, bool& tf, const c8* const pBufEnd); + SObjMtl * findMtl(const c8* pMtlName); + SObjGroup * findGroup(const c8* pGroupName); + SObjGroup * findOrAddGroup(const c8* pGroupName); + + // reads and convert to integer the vertex indices in a line of obj file's face statement + // -1 for the index if it doesn't exist + // indices are changed to 0-based index instead of 1-based from the obj file + bool retrieveVertexIndices(c8* pVertexData, s32* Idx, const c8* pBufEnd); + + void cleanUp(); + + io::IFileSystem* FileSystem; + video::IVideoDriver* Driver; + + core::array materials; + core::array groups; + SMesh* Mesh; +}; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/COCTLoader.cpp b/src/dep/src/irrlicht/COCTLoader.cpp index 8ddf878..841ae4d 100644 --- a/src/dep/src/irrlicht/COCTLoader.cpp +++ b/src/dep/src/irrlicht/COCTLoader.cpp @@ -1,384 +1,384 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// originally written by Murphy McCauley, see COCTLoader.h for details. -// -// COCTLoader by Murphy McCauley (February 2005) -// An Irrlicht loader for OCT files -// -// See the header file for additional information including use and distribution rights. - -#include "COCTLoader.h" -#include "ISceneManager.h" -#include "os.h" -#include "SAnimatedMesh.h" -#include "SMeshBufferLightMap.h" -#include "irrString.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -COCTLoader::COCTLoader(video::IVideoDriver* driver) -: Driver(driver) -{ - #ifdef _DEBUG - IUnknown::setDebugName("COCTLoader"); - #endif - - if (Driver) - Driver->grab(); -} - - -//! destructor -COCTLoader::~COCTLoader() -{ - if (Driver) - Driver->drop(); -} - - - -// Doesn't really belong here, but it's jammed in for now. -void COCTLoader::OCTLoadLights(irr::io::IReadFile* file, irr::scene::ISceneManager * scene, irr::scene::ISceneNode * parent, f32 radius, f32 intensityScale, bool rewind) -{ - if (rewind) file->seek(0); - - octHeader header; - file->read(&header, sizeof(octHeader)); - - file->seek(sizeof(octVert)*header.numVerts, true); - file->seek(sizeof(octFace)*header.numFaces, true); - file->seek(sizeof(octTexture)*header.numTextures, true); - file->seek(sizeof(octLightmap)*header.numLightmaps, true); - - octLight * lights = new octLight[header.numLights]; - file->read(lights, header.numLights * sizeof(octLight)); - - //TODO: Skip past my extended data just for good form - - u32 i; - for (i = 0; i < header.numLights; i++) - { - f32 intensity; - intensity = lights[i].intensity * intensityScale; - - //irr::scene::ISceneNode* node = scene->addCubeSceneNode(30,parent,-1, core::vector3df(lights[i].pos[0], lights[i].pos[2], lights[i].pos[1])); - //node->getMaterial(0).AmbientColor = video::SColorf(lights[i].color[0] * intensity, lights[i].color[1] * intensity, lights[i].color[2] * intensity).toSColor(); - - scene->addLightSceneNode(parent, core::vector3df(lights[i].pos[0], lights[i].pos[2], lights[i].pos[1]), - video::SColorf(lights[i].color[0] * intensity, lights[i].color[1] * intensity, lights[i].color[2] * intensity, 1.0f), - radius); - } -} - - -//! given three points representing a face, return a face normal -void COCTLoader::GetFaceNormal(f32 a[3], f32 b[3], f32 c[3], f32 out[3]) { - f32 v1[3], v2[3]; - - v1[0] = a[0] - b[0]; - v1[1] = a[1] - b[1]; - v1[2] = a[2] - b[2]; - - v2[0] = b[0] - c[0]; - v2[1] = b[1] - c[1]; - v2[2] = b[2] - c[2]; - - out[0] = (v1[1] * v2[2]) - (v1[2] * v2[1]); - out[1] = (v1[2] * v2[0]) - (v1[0] * v2[2]); - out[2] = (v1[0] * v2[1]) - (v1[1] * v2[0]); - - f32 dist = (f32)sqrt((out[0] * out[0]) + (out[1] * out[1]) + (out[2] * out[2])); - if (dist == 0.0f) dist = 0.001f; - - out[0] /= dist; - out[1] /= dist; - out[2] /= dist; -} - - -//! creates/loads an animated mesh from the file. -//! \return Pointer to the created mesh. Returns 0 if loading failed. -//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). -//! See IUnknown::drop() for more information. -IAnimatedMesh* COCTLoader::createMesh(irr::io::IReadFile* file) -{ - SMesh * Mesh = new SMesh(); - - u32 i; - - if (!file) return false; - - octHeader header; - file->read(&header, sizeof(octHeader)); - - octVert * verts = new octVert[header.numVerts]; - octFace * faces = new octFace[header.numFaces]; - octTexture * textures = new octTexture[header.numTextures]; - octLightmap * lightmaps = new octLightmap[header.numLightmaps]; - octLight * lights = new octLight[header.numLights]; - - file->read(verts, sizeof(octVert) * header.numVerts); - file->read(faces, sizeof(octFace) * header.numFaces); - //TODO: Make sure id is in the legal range for Textures and Lightmaps - for (i = 0; i < header.numTextures; i++) { - octTexture t; - file->read(&t, sizeof(octTexture)); - textures[t.id] = t; - } - for (i = 0; i < header.numLightmaps; i++) { - octLightmap t; - file->read(&t, sizeof(octLightmap)); - lightmaps[t.id] = t; - } - file->read(lights, sizeof(octLight) * header.numLights); - - //TODO: Now read in my extended OCT header (flexible lightmaps and vertex normals) - - - // This is the method Nikolaus Gebhardt used in the Q3 loader -- create a - // meshbuffer for every possible combination of lightmap and texture including - // a "null" texture and "null" lightmap. Ones that end up with nothing in them - // will be removed later. - for (i=0; i<(header.numTextures+1) * (header.numLightmaps+1); ++i) - { - scene::SMeshBufferLightMap* buffer = new scene::SMeshBufferLightMap(); - - buffer->Material.MaterialType = video::EMT_LIGHTMAP; - buffer->Material.Wireframe = false; - buffer->Material.Lighting = false; - buffer->Material.BilinearFilter = true; - - Mesh->addMeshBuffer(buffer); - - buffer->drop(); - } - - - // Build the mesh buffers - for (i = 0; i < header.numFaces; i++) { - if (faces[i].numVerts < 3) continue; - - f32 normal[3]; - GetFaceNormal(verts[faces[i].firstVert].pos,verts[faces[i].firstVert+1].pos,verts[faces[i].firstVert+2].pos, normal); - - u32 textureID = core::min_(s32(faces[i].textureID), s32(header.numTextures - 1)) + 1; - u32 lightmapID = core::min_(s32(faces[i].lightmapID),s32(header.numLightmaps - 1)) + 1; - SMeshBufferLightMap * meshBuffer = (SMeshBufferLightMap*)Mesh->getMeshBuffer(lightmapID * (header.numTextures + 1) + textureID); - u32 base = meshBuffer->Vertices.size(); - - // Add this face's verts - u32 v; - for (v = 0; v < faces[i].numVerts; v++) - { - octVert * vv = &verts[faces[i].firstVert + v]; - video::S3DVertex2TCoords vert = video::S3DVertex2TCoords(); - vert.Pos.set(vv->pos[0], vv->pos[1], vv->pos[2]); - vert.Color = irr::video::SColor(0,255,255,255); - vert.Normal.set(normal[0], normal[1], normal[2]); - - if (textureID == 0) - { - // No texure -- just a lightmap. Thus, use lightmap coords for texture 1. - // (the actual texture will be swapped later) - vert.TCoords.set(vv->lc[0], vv->lc[1]); - } - else - { - vert.TCoords.set(vv->tc[0], vv->tc[1]); - vert.TCoords2.set(vv->lc[0], vv->lc[1]); - } - - meshBuffer->Vertices.push_back(vert); - } - - // Now add the indices - // This weird loop turns convex polygons into triangle strips. - // I do it this way instead of a simple fan because it usually looks a lot better in wireframe, for example. - u32 h = faces[i].numVerts - 1, l = 0, c; // High, Low, Center - for (v = 0; v < faces[i].numVerts - 2; v++) - { - if (v & 1) c = h - 1; else c = l + 1; - - meshBuffer->Indices.push_back(base + h); - meshBuffer->Indices.push_back(base + l); - meshBuffer->Indices.push_back(base + c); - - if (v & 1) h--; else l++; - } - } - - - // load textures - core::array tex; - tex.set_used(header.numTextures + 1); - tex[0] = 0; - - for (i = 1; i < (header.numTextures + 1); i++) - { - tex[i] = Driver->getTexture(textures[i-1].fileName); - } - - - // prepare lightmaps - core::array lig; - lig.set_used(header.numLightmaps + 1); - - u32 lightmapWidth = 128, lightmapHeight = 128; - lig[0] = 0; - core::dimension2d lmapsize(lightmapWidth, lightmapHeight); - - bool oldMipMapState = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); - - for (i = 1; i < (header.numLightmaps + 1); i++) - { - core::stringc lightmapname = file->getFileName(); - lightmapname += ".lightmap."; - lightmapname += (int)i; - lig[i] = Driver->addTexture(lmapsize, lightmapname.c_str()); - - if (lig[i]->getSize() != lmapsize) - os::Printer::log("OCTLoader: Created lightmap is not of the requested size", ELL_ERROR); - - if (lig[i]) - { - void* pp = lig[i]->lock(); - - if (pp) - { - video::ECOLOR_FORMAT format = lig[i]->getColorFormat(); - if (format == video::ECF_A1R5G5B5) - { - s16* p = (s16*)pp; - - octLightmap * lm; - lm = &lightmaps[i-1]; - - for (u32 x=0; xdata[x][y][2], - lm->data[x][y][1], - lm->data[x][y][0]); - } - } - else - if (format == video::ECF_A8R8G8B8) - { - s32* p = (s32*)pp; - - octLightmap* lm; - lm = &lightmaps[i-1]; - - for (u32 x=0; xdata[x][y][2], - lm->data[x][y][1], - lm->data[x][y][0]).color; - } - } - else - os::Printer::log( - "OCTLoader: Could not create lightmap, unsupported texture format.", ELL_ERROR); - } - - lig[i]->unlock(); - } - else - os::Printer::log("OCTLoader: Could not create lightmap, driver created no texture.", ELL_ERROR); - } - Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); - - - // Free stuff - delete [] verts; - delete [] faces; - delete [] textures; - delete [] lightmaps; - delete [] lights; - - - // attach materials - u32 j; - for (i = 0; i < header.numLightmaps + 1; i++) - { - for (j = 0; j < header.numTextures + 1; j++) - { - u32 mb = i * (header.numTextures + 1) + j; - SMeshBufferLightMap * meshBuffer = (SMeshBufferLightMap*)Mesh->getMeshBuffer(mb); - meshBuffer->Material.Textures[0] = tex[j]; - meshBuffer->Material.Textures[1] = lig[i]; - - if (meshBuffer->Material.Textures[0] == 0) { - // This material has no texture, so we'll just show the lightmap if there is one. - // We swapped the texture coordinates earlier. - meshBuffer->Material.Textures[0] = meshBuffer->Material.Textures[1]; - meshBuffer->Material.Textures[1] = 0; - } - if (meshBuffer->Material.Textures[1] == 0) - { - // If there is only one texture, it should be solid and lit. - // Among other things, this way you can preview OCT lights. - meshBuffer->Material.MaterialType = video::EMT_SOLID; - meshBuffer->Material.Lighting = true; - } - } - } - - - // delete all buffers without geometry in it. - i = 0; - while(i < Mesh->MeshBuffers.size()) - { - if (Mesh->MeshBuffers[i]->getVertexCount() == 0 || - Mesh->MeshBuffers[i]->getIndexCount() == 0 || - Mesh->MeshBuffers[i]->getMaterial().Textures[0] == 0) - { - // Meshbuffer is empty -- drop it - Mesh->MeshBuffers[i]->drop(); - Mesh->MeshBuffers.erase(i); - } - else - { - i++; - } - } - - - // create bounding box - for (i = 0; i < Mesh->MeshBuffers.size(); i++) { - ((SMeshBufferLightMap*)Mesh->MeshBuffers[i])->recalculateBoundingBox(); - } - Mesh->recalculateBoundingBox(); - - - // Set up an animated mesh to hold the mesh - SAnimatedMesh* AMesh = new SAnimatedMesh(); - AMesh->Type = EAMT_OCT; - AMesh->addMesh(Mesh); - AMesh->recalculateBoundingBox(); - Mesh->drop(); - - return AMesh; -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool COCTLoader::isALoadableFileExtension(const c8* filename) -{ - return strstr(filename, ".oct")!=0; -} - - -} // end namespace scene -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// +// originally written by Murphy McCauley, see COCTLoader.h for details. +// +// COCTLoader by Murphy McCauley (February 2005) +// An Irrlicht loader for OCT files +// +// See the header file for additional information including use and distribution rights. + +#include "COCTLoader.h" +#include "ISceneManager.h" +#include "os.h" +#include "SAnimatedMesh.h" +#include "SMeshBufferLightMap.h" +#include "irrString.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +COCTLoader::COCTLoader(video::IVideoDriver* driver) +: Driver(driver) +{ + #ifdef _DEBUG + IUnknown::setDebugName("COCTLoader"); + #endif + + if (Driver) + Driver->grab(); +} + + +//! destructor +COCTLoader::~COCTLoader() +{ + if (Driver) + Driver->drop(); +} + + + +// Doesn't really belong here, but it's jammed in for now. +void COCTLoader::OCTLoadLights(irr::io::IReadFile* file, irr::scene::ISceneManager * scene, irr::scene::ISceneNode * parent, f32 radius, f32 intensityScale, bool rewind) +{ + if (rewind) file->seek(0); + + octHeader header; + file->read(&header, sizeof(octHeader)); + + file->seek(sizeof(octVert)*header.numVerts, true); + file->seek(sizeof(octFace)*header.numFaces, true); + file->seek(sizeof(octTexture)*header.numTextures, true); + file->seek(sizeof(octLightmap)*header.numLightmaps, true); + + octLight * lights = new octLight[header.numLights]; + file->read(lights, header.numLights * sizeof(octLight)); + + //TODO: Skip past my extended data just for good form + + u32 i; + for (i = 0; i < header.numLights; i++) + { + f32 intensity; + intensity = lights[i].intensity * intensityScale; + + //irr::scene::ISceneNode* node = scene->addCubeSceneNode(30,parent,-1, core::vector3df(lights[i].pos[0], lights[i].pos[2], lights[i].pos[1])); + //node->getMaterial(0).AmbientColor = video::SColorf(lights[i].color[0] * intensity, lights[i].color[1] * intensity, lights[i].color[2] * intensity).toSColor(); + + scene->addLightSceneNode(parent, core::vector3df(lights[i].pos[0], lights[i].pos[2], lights[i].pos[1]), + video::SColorf(lights[i].color[0] * intensity, lights[i].color[1] * intensity, lights[i].color[2] * intensity, 1.0f), + radius); + } +} + + +//! given three points representing a face, return a face normal +void COCTLoader::GetFaceNormal(f32 a[3], f32 b[3], f32 c[3], f32 out[3]) { + f32 v1[3], v2[3]; + + v1[0] = a[0] - b[0]; + v1[1] = a[1] - b[1]; + v1[2] = a[2] - b[2]; + + v2[0] = b[0] - c[0]; + v2[1] = b[1] - c[1]; + v2[2] = b[2] - c[2]; + + out[0] = (v1[1] * v2[2]) - (v1[2] * v2[1]); + out[1] = (v1[2] * v2[0]) - (v1[0] * v2[2]); + out[2] = (v1[0] * v2[1]) - (v1[1] * v2[0]); + + f32 dist = (f32)sqrt((out[0] * out[0]) + (out[1] * out[1]) + (out[2] * out[2])); + if (dist == 0.0f) dist = 0.001f; + + out[0] /= dist; + out[1] /= dist; + out[2] /= dist; +} + + +//! creates/loads an animated mesh from the file. +//! \return Pointer to the created mesh. Returns 0 if loading failed. +//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). +//! See IUnknown::drop() for more information. +IAnimatedMesh* COCTLoader::createMesh(irr::io::IReadFile* file) +{ + SMesh * Mesh = new SMesh(); + + u32 i; + + if (!file) return false; + + octHeader header; + file->read(&header, sizeof(octHeader)); + + octVert * verts = new octVert[header.numVerts]; + octFace * faces = new octFace[header.numFaces]; + octTexture * textures = new octTexture[header.numTextures]; + octLightmap * lightmaps = new octLightmap[header.numLightmaps]; + octLight * lights = new octLight[header.numLights]; + + file->read(verts, sizeof(octVert) * header.numVerts); + file->read(faces, sizeof(octFace) * header.numFaces); + //TODO: Make sure id is in the legal range for Textures and Lightmaps + for (i = 0; i < header.numTextures; i++) { + octTexture t; + file->read(&t, sizeof(octTexture)); + textures[t.id] = t; + } + for (i = 0; i < header.numLightmaps; i++) { + octLightmap t; + file->read(&t, sizeof(octLightmap)); + lightmaps[t.id] = t; + } + file->read(lights, sizeof(octLight) * header.numLights); + + //TODO: Now read in my extended OCT header (flexible lightmaps and vertex normals) + + + // This is the method Nikolaus Gebhardt used in the Q3 loader -- create a + // meshbuffer for every possible combination of lightmap and texture including + // a "null" texture and "null" lightmap. Ones that end up with nothing in them + // will be removed later. + for (i=0; i<(header.numTextures+1) * (header.numLightmaps+1); ++i) + { + scene::SMeshBufferLightMap* buffer = new scene::SMeshBufferLightMap(); + + buffer->Material.MaterialType = video::EMT_LIGHTMAP; + buffer->Material.Wireframe = false; + buffer->Material.Lighting = false; + buffer->Material.BilinearFilter = true; + + Mesh->addMeshBuffer(buffer); + + buffer->drop(); + } + + + // Build the mesh buffers + for (i = 0; i < header.numFaces; i++) { + if (faces[i].numVerts < 3) continue; + + f32 normal[3]; + GetFaceNormal(verts[faces[i].firstVert].pos,verts[faces[i].firstVert+1].pos,verts[faces[i].firstVert+2].pos, normal); + + u32 textureID = core::min_(s32(faces[i].textureID), s32(header.numTextures - 1)) + 1; + u32 lightmapID = core::min_(s32(faces[i].lightmapID),s32(header.numLightmaps - 1)) + 1; + SMeshBufferLightMap * meshBuffer = (SMeshBufferLightMap*)Mesh->getMeshBuffer(lightmapID * (header.numTextures + 1) + textureID); + u32 base = meshBuffer->Vertices.size(); + + // Add this face's verts + u32 v; + for (v = 0; v < faces[i].numVerts; v++) + { + octVert * vv = &verts[faces[i].firstVert + v]; + video::S3DVertex2TCoords vert = video::S3DVertex2TCoords(); + vert.Pos.set(vv->pos[0], vv->pos[1], vv->pos[2]); + vert.Color = irr::video::SColor(0,255,255,255); + vert.Normal.set(normal[0], normal[1], normal[2]); + + if (textureID == 0) + { + // No texure -- just a lightmap. Thus, use lightmap coords for texture 1. + // (the actual texture will be swapped later) + vert.TCoords.set(vv->lc[0], vv->lc[1]); + } + else + { + vert.TCoords.set(vv->tc[0], vv->tc[1]); + vert.TCoords2.set(vv->lc[0], vv->lc[1]); + } + + meshBuffer->Vertices.push_back(vert); + } + + // Now add the indices + // This weird loop turns convex polygons into triangle strips. + // I do it this way instead of a simple fan because it usually looks a lot better in wireframe, for example. + u32 h = faces[i].numVerts - 1, l = 0, c; // High, Low, Center + for (v = 0; v < faces[i].numVerts - 2; v++) + { + if (v & 1) c = h - 1; else c = l + 1; + + meshBuffer->Indices.push_back(base + h); + meshBuffer->Indices.push_back(base + l); + meshBuffer->Indices.push_back(base + c); + + if (v & 1) h--; else l++; + } + } + + + // load textures + core::array tex; + tex.set_used(header.numTextures + 1); + tex[0] = 0; + + for (i = 1; i < (header.numTextures + 1); i++) + { + tex[i] = Driver->getTexture(textures[i-1].fileName); + } + + + // prepare lightmaps + core::array lig; + lig.set_used(header.numLightmaps + 1); + + u32 lightmapWidth = 128, lightmapHeight = 128; + lig[0] = 0; + core::dimension2d lmapsize(lightmapWidth, lightmapHeight); + + bool oldMipMapState = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); + Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); + + for (i = 1; i < (header.numLightmaps + 1); i++) + { + core::stringc lightmapname = file->getFileName(); + lightmapname += ".lightmap."; + lightmapname += (int)i; + lig[i] = Driver->addTexture(lmapsize, lightmapname.c_str()); + + if (lig[i]->getSize() != lmapsize) + os::Printer::log("OCTLoader: Created lightmap is not of the requested size", ELL_ERROR); + + if (lig[i]) + { + void* pp = lig[i]->lock(); + + if (pp) + { + video::ECOLOR_FORMAT format = lig[i]->getColorFormat(); + if (format == video::ECF_A1R5G5B5) + { + s16* p = (s16*)pp; + + octLightmap * lm; + lm = &lightmaps[i-1]; + + for (u32 x=0; xdata[x][y][2], + lm->data[x][y][1], + lm->data[x][y][0]); + } + } + else + if (format == video::ECF_A8R8G8B8) + { + s32* p = (s32*)pp; + + octLightmap* lm; + lm = &lightmaps[i-1]; + + for (u32 x=0; xdata[x][y][2], + lm->data[x][y][1], + lm->data[x][y][0]).color; + } + } + else + os::Printer::log( + "OCTLoader: Could not create lightmap, unsupported texture format.", ELL_ERROR); + } + + lig[i]->unlock(); + } + else + os::Printer::log("OCTLoader: Could not create lightmap, driver created no texture.", ELL_ERROR); + } + Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); + + + // Free stuff + delete [] verts; + delete [] faces; + delete [] textures; + delete [] lightmaps; + delete [] lights; + + + // attach materials + u32 j; + for (i = 0; i < header.numLightmaps + 1; i++) + { + for (j = 0; j < header.numTextures + 1; j++) + { + u32 mb = i * (header.numTextures + 1) + j; + SMeshBufferLightMap * meshBuffer = (SMeshBufferLightMap*)Mesh->getMeshBuffer(mb); + meshBuffer->Material.Textures[0] = tex[j]; + meshBuffer->Material.Textures[1] = lig[i]; + + if (meshBuffer->Material.Textures[0] == 0) { + // This material has no texture, so we'll just show the lightmap if there is one. + // We swapped the texture coordinates earlier. + meshBuffer->Material.Textures[0] = meshBuffer->Material.Textures[1]; + meshBuffer->Material.Textures[1] = 0; + } + if (meshBuffer->Material.Textures[1] == 0) + { + // If there is only one texture, it should be solid and lit. + // Among other things, this way you can preview OCT lights. + meshBuffer->Material.MaterialType = video::EMT_SOLID; + meshBuffer->Material.Lighting = true; + } + } + } + + + // delete all buffers without geometry in it. + i = 0; + while(i < Mesh->MeshBuffers.size()) + { + if (Mesh->MeshBuffers[i]->getVertexCount() == 0 || + Mesh->MeshBuffers[i]->getIndexCount() == 0 || + Mesh->MeshBuffers[i]->getMaterial().Textures[0] == 0) + { + // Meshbuffer is empty -- drop it + Mesh->MeshBuffers[i]->drop(); + Mesh->MeshBuffers.erase(i); + } + else + { + i++; + } + } + + + // create bounding box + for (i = 0; i < Mesh->MeshBuffers.size(); i++) { + ((SMeshBufferLightMap*)Mesh->MeshBuffers[i])->recalculateBoundingBox(); + } + Mesh->recalculateBoundingBox(); + + + // Set up an animated mesh to hold the mesh + SAnimatedMesh* AMesh = new SAnimatedMesh(); + AMesh->Type = EAMT_OCT; + AMesh->addMesh(Mesh); + AMesh->recalculateBoundingBox(); + Mesh->drop(); + + return AMesh; +} + + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".bsp") +bool COCTLoader::isALoadableFileExtension(const c8* filename) +{ + return strstr(filename, ".oct")!=0; +} + + +} // end namespace scene +} // end namespace irr diff --git a/src/dep/src/irrlicht/COCTLoader.h b/src/dep/src/irrlicht/COCTLoader.h index 354e06d..0c3e277 100644 --- a/src/dep/src/irrlicht/COCTLoader.h +++ b/src/dep/src/irrlicht/COCTLoader.h @@ -1,136 +1,136 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// Because I (Nikolaus Gebhardt) did some changes to Murphy McCauley's loader, -// I'm writing this down here: -// - Replaced all dependencies to STL and stdio with irr:: methods/constructs -// - Disabled logging define -// - Changed some minor things (Don't remember what exactly.) -// Thanks a lot to Murphy McCauley for writing this loader. - -// -// COCTLoader by Murphy McCauley (February 2005) -// An Irrlicht loader for OCT files -// -// OCT file format information comes from the sourcecode of the Fluid Studios -// Radiosity Processor by Paul Nettle. You can get that sourcecode from -// http://www.fluidstudios.com . -// -// Parts of this code are from Irrlicht's CQ3LevelMesh and C3DSMeshFileLoader, -// and are Copyright (C) 2002-2004 Nikolaus Gebhardt. -// -// Use of this code is subject to the following: -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. -// 4. You may not use this software to directly or indirectly cause harm to others. - - -#ifndef __C_OCT_LOADER_H_INCLUDED__ -#define __C_OCT_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IReadFile.h" -#include "SMesh.h" -#include "IVideoDriver.h" -#include "irrString.h" - -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - - class COCTLoader : public IMeshLoader - { - public: - void OCTLoadLights(irr::io::IReadFile* file, irr::scene::ISceneManager * scene, irr::scene::ISceneNode * parent = 0, f32 radius = 500.0f, f32 intensityScale = 0.0000001f*2.5, bool rewind = true); - - //! constructor - COCTLoader(video::IVideoDriver* driver); - - //! destructor - virtual ~COCTLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".cob") - virtual bool isALoadableFileExtension(const c8* fileName); - - //! creates/loads an animated mesh from the file. - //! \return Pointer to the created mesh. Returns 0 if loading failed. - //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). - //! See IUnknown::drop() for more information. - virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); - - private: - void GetFaceNormal(f32 a[3], f32 b[3], f32 c[3], f32 out[3]); - - struct octHeader { - u32 numVerts; - u32 numFaces; - u32 numTextures; - u32 numLightmaps; - u32 numLights; - }; - - struct octHeaderEx { - u32 magic; // 'OCTX' - 0x4F435458L - u32 numLightmaps; - u32 lightmapWidth; - u32 lightmapHeight; - u32 containsVertexNormals; - }; - - struct octFace { - u32 firstVert; - u32 numVerts; - u32 textureID; - u32 lightmapID; - f32 plane[4]; - }; - - struct octVert { - f32 tc[2]; - f32 lc[2]; - f32 pos[3]; - }; - - struct octTexture { - u32 id; - char fileName[64]; - }; - - struct octLightmap { - u32 id; - u8 data[128][128][3]; - }; - - struct octLight { - f32 pos[3]; - f32 color[3]; - u32 intensity; - }; - - video::IVideoDriver* Driver; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// +// Because I (Nikolaus Gebhardt) did some changes to Murphy McCauley's loader, +// I'm writing this down here: +// - Replaced all dependencies to STL and stdio with irr:: methods/constructs +// - Disabled logging define +// - Changed some minor things (Don't remember what exactly.) +// Thanks a lot to Murphy McCauley for writing this loader. + +// +// COCTLoader by Murphy McCauley (February 2005) +// An Irrlicht loader for OCT files +// +// OCT file format information comes from the sourcecode of the Fluid Studios +// Radiosity Processor by Paul Nettle. You can get that sourcecode from +// http://www.fluidstudios.com . +// +// Parts of this code are from Irrlicht's CQ3LevelMesh and C3DSMeshFileLoader, +// and are Copyright (C) 2002-2004 Nikolaus Gebhardt. +// +// Use of this code is subject to the following: +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. +// 4. You may not use this software to directly or indirectly cause harm to others. + + +#ifndef __C_OCT_LOADER_H_INCLUDED__ +#define __C_OCT_LOADER_H_INCLUDED__ + +#include "IMeshLoader.h" +#include "IReadFile.h" +#include "SMesh.h" +#include "IVideoDriver.h" +#include "irrString.h" + +#include "ISceneManager.h" + +namespace irr +{ +namespace scene +{ + + class COCTLoader : public IMeshLoader + { + public: + void OCTLoadLights(irr::io::IReadFile* file, irr::scene::ISceneManager * scene, irr::scene::ISceneNode * parent = 0, f32 radius = 500.0f, f32 intensityScale = 0.0000001f*2.5, bool rewind = true); + + //! constructor + COCTLoader(video::IVideoDriver* driver); + + //! destructor + virtual ~COCTLoader(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".cob") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! creates/loads an animated mesh from the file. + //! \return Pointer to the created mesh. Returns 0 if loading failed. + //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). + //! See IUnknown::drop() for more information. + virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); + + private: + void GetFaceNormal(f32 a[3], f32 b[3], f32 c[3], f32 out[3]); + + struct octHeader { + u32 numVerts; + u32 numFaces; + u32 numTextures; + u32 numLightmaps; + u32 numLights; + }; + + struct octHeaderEx { + u32 magic; // 'OCTX' - 0x4F435458L + u32 numLightmaps; + u32 lightmapWidth; + u32 lightmapHeight; + u32 containsVertexNormals; + }; + + struct octFace { + u32 firstVert; + u32 numVerts; + u32 textureID; + u32 lightmapID; + f32 plane[4]; + }; + + struct octVert { + f32 tc[2]; + f32 lc[2]; + f32 pos[3]; + }; + + struct octTexture { + u32 id; + char fileName[64]; + }; + + struct octLightmap { + u32 id; + u8 data[128][128][3]; + }; + + struct octLight { + f32 pos[3]; + f32 color[3]; + u32 intensity; + }; + + video::IVideoDriver* Driver; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/COSOperator.cpp b/src/dep/src/irrlicht/COSOperator.cpp index fa21a6c..42ce4fb 100644 --- a/src/dep/src/irrlicht/COSOperator.cpp +++ b/src/dep/src/irrlicht/COSOperator.cpp @@ -1,190 +1,190 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "COSOperator.h" -#include "IrrCompileConfig.h" - -#ifdef _IRR_WINDOWS_ -#include -#else -#include -#endif - -#ifdef LINUX -#include -#endif - -#ifdef MACOSX -#include "OSXClipboard.h" -#include -#include -#include -#endif - -namespace irr -{ - - -// constructor -COSOperator::COSOperator(const c8* osVersion) -{ - OperationSystem = osVersion; -} - - -//! destructor -COSOperator::~COSOperator() -{ -} - - -//! returns the current operation system version as string. -const wchar_t* COSOperator::getOperationSystemVersion() -{ - return OperationSystem.c_str(); -} - - -//! copies text to the clipboard -void COSOperator::copyToClipboard(const c8* text) -{ - if (strlen(text)==0) - return; - -// Windows version -#if defined(_IRR_WINDOWS_) - if (!OpenClipboard(0) || text == 0) - return; - - EmptyClipboard(); - - HGLOBAL clipbuffer; - char * buffer; - - clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(text)+1); - buffer = (char*)GlobalLock(clipbuffer); - - strcpy(buffer, text); - - GlobalUnlock(clipbuffer); - SetClipboardData(CF_TEXT, clipbuffer); - CloseClipboard(); - -// MacOSX version -#elif defined(MACOSX) - - OSXCopyToClipboard(text); - -// todo: Linux version -#endif -} - - -//! gets text from the clipboard -//! \return Returns 0 if no string is in there. -c8* COSOperator::getTextFromClipboard() -{ -#if defined(_IRR_WINDOWS_) - if (!OpenClipboard(NULL)) - return 0; - - char * buffer = 0; - - HANDLE hData = GetClipboardData( CF_TEXT ); - buffer = (char*)GlobalLock( hData ); - GlobalUnlock( hData ); - CloseClipboard(); - return buffer; - -#elif defined(MACOSX) - return (OSXCopyFromClipboard()); -#else - -// todo: Linux version - - return 0; -#endif -} - - -bool COSOperator::getProcessorSpeedMHz(irr::u32* MHz) -{ -#if defined(_IRR_WINDOWS_) - LONG Error; - - HKEY Key; - Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", - 0, KEY_READ, &Key); - - if(Error != ERROR_SUCCESS) - return false; - - DWORD Speed = 0; - DWORD Size = sizeof(Speed); - Error = RegQueryValueEx(Key, "~MHz", NULL, NULL, (LPBYTE)&Speed, &Size); - - RegCloseKey(Key); - - if (Error != ERROR_SUCCESS) - return false; - else if (MHz) - *MHz = Speed; - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return true; - -#elif defined(MACOSX) - struct clockinfo CpuClock; - size_t Size = sizeof(clockinfo); - - if (!sysctlbyname("kern.clockrate", &CpuClock, &Size, NULL, 0)) - return false; - else if (MHz) - *MHz = CpuClock.hz; - return true; -#else - // could probably be read from "/proc/cpuinfo" or "/proc/cpufreq" - - return false; -#endif -} - -bool COSOperator::getSystemMemory(irr::u32* Total, irr::u32* Avail) -{ -#if defined(_IRR_WINDOWS_) - MEMORYSTATUS MemoryStatus; - MemoryStatus.dwLength = sizeof(MEMORYSTATUS); - - // cannot fail - GlobalMemoryStatus(&MemoryStatus); - - if (Total) - *Total = (irr::u32)(MemoryStatus.dwTotalPhys>>10); - if (Avail) - *Avail = (irr::u32)(MemoryStatus.dwAvailPhys>>10); - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return true; - -#elif defined(LINUX) // || defined(MACOSX) - long ps = sysconf(_SC_PAGESIZE); - long pp = sysconf(_SC_PHYS_PAGES); - long ap = sysconf(_SC_AVPHYS_PAGES); - - if ((ps==-1)||(pp==-1)||(ap==-1)) - return false; - - if (Total) - *Total = ((ps*(long long)pp)>>10); - if (Avail) - *Avail = ((ps*(long long)ap)>>10); - return true; -#endif - // TODO: implement for OSX - return false; -} - - -} // end namespace - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "COSOperator.h" +#include "IrrCompileConfig.h" + +#ifdef _IRR_WINDOWS_ +#include +#else +#include +#endif + +#ifdef LINUX +#include +#endif + +#ifdef MACOSX +#include "OSXClipboard.h" +#include +#include +#include +#endif + +namespace irr +{ + + +// constructor +COSOperator::COSOperator(const c8* osVersion) +{ + OperationSystem = osVersion; +} + + +//! destructor +COSOperator::~COSOperator() +{ +} + + +//! returns the current operation system version as string. +const wchar_t* COSOperator::getOperationSystemVersion() +{ + return OperationSystem.c_str(); +} + + +//! copies text to the clipboard +void COSOperator::copyToClipboard(const c8* text) +{ + if (strlen(text)==0) + return; + +// Windows version +#if defined(_IRR_WINDOWS_) + if (!OpenClipboard(0) || text == 0) + return; + + EmptyClipboard(); + + HGLOBAL clipbuffer; + char * buffer; + + clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(text)+1); + buffer = (char*)GlobalLock(clipbuffer); + + strcpy(buffer, text); + + GlobalUnlock(clipbuffer); + SetClipboardData(CF_TEXT, clipbuffer); + CloseClipboard(); + +// MacOSX version +#elif defined(MACOSX) + + OSXCopyToClipboard(text); + +// todo: Linux version +#endif +} + + +//! gets text from the clipboard +//! \return Returns 0 if no string is in there. +c8* COSOperator::getTextFromClipboard() +{ +#if defined(_IRR_WINDOWS_) + if (!OpenClipboard(NULL)) + return 0; + + char * buffer = 0; + + HANDLE hData = GetClipboardData( CF_TEXT ); + buffer = (char*)GlobalLock( hData ); + GlobalUnlock( hData ); + CloseClipboard(); + return buffer; + +#elif defined(MACOSX) + return (OSXCopyFromClipboard()); +#else + +// todo: Linux version + + return 0; +#endif +} + + +bool COSOperator::getProcessorSpeedMHz(irr::u32* MHz) +{ +#if defined(_IRR_WINDOWS_) + LONG Error; + + HKEY Key; + Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", + 0, KEY_READ, &Key); + + if(Error != ERROR_SUCCESS) + return false; + + DWORD Speed = 0; + DWORD Size = sizeof(Speed); + Error = RegQueryValueEx(Key, "~MHz", NULL, NULL, (LPBYTE)&Speed, &Size); + + RegCloseKey(Key); + + if (Error != ERROR_SUCCESS) + return false; + else if (MHz) + *MHz = Speed; + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return true; + +#elif defined(MACOSX) + struct clockinfo CpuClock; + size_t Size = sizeof(clockinfo); + + if (!sysctlbyname("kern.clockrate", &CpuClock, &Size, NULL, 0)) + return false; + else if (MHz) + *MHz = CpuClock.hz; + return true; +#else + // could probably be read from "/proc/cpuinfo" or "/proc/cpufreq" + + return false; +#endif +} + +bool COSOperator::getSystemMemory(irr::u32* Total, irr::u32* Avail) +{ +#if defined(_IRR_WINDOWS_) + MEMORYSTATUS MemoryStatus; + MemoryStatus.dwLength = sizeof(MEMORYSTATUS); + + // cannot fail + GlobalMemoryStatus(&MemoryStatus); + + if (Total) + *Total = (irr::u32)(MemoryStatus.dwTotalPhys>>10); + if (Avail) + *Avail = (irr::u32)(MemoryStatus.dwAvailPhys>>10); + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return true; + +#elif defined(LINUX) // || defined(MACOSX) + long ps = sysconf(_SC_PAGESIZE); + long pp = sysconf(_SC_PHYS_PAGES); + long ap = sysconf(_SC_AVPHYS_PAGES); + + if ((ps==-1)||(pp==-1)||(ap==-1)) + return false; + + if (Total) + *Total = ((ps*(long long)pp)>>10); + if (Avail) + *Avail = ((ps*(long long)ap)>>10); + return true; +#endif + // TODO: implement for OSX + return false; +} + + +} // end namespace + diff --git a/src/dep/src/irrlicht/COSOperator.h b/src/dep/src/irrlicht/COSOperator.h index ea9d307..d51af71 100644 --- a/src/dep/src/irrlicht/COSOperator.h +++ b/src/dep/src/irrlicht/COSOperator.h @@ -1,54 +1,54 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OS_OPERATOR_H_INCLUDED__ -#define __C_OS_OPERATOR_H_INCLUDED__ - -#include "IOSOperator.h" -#include "irrString.h" - -namespace irr -{ - -//! The Operating system operator provides operation system specific methods and informations. -class COSOperator : public IOSOperator -{ -public: - - // constructor - COSOperator(const c8* osversion); - - //! destructor - virtual ~COSOperator(); - - //! returns the current operation system version as string. - virtual const wchar_t* getOperationSystemVersion(); - - //! copies text to the clipboard - virtual void copyToClipboard(const c8* text); - - //! gets text from the clipboard - //! \return Returns 0 if no string is in there. - virtual c8* getTextFromClipboard(); - - //! gets the processor speed in megahertz - //! \param Mhz: - //! \return Returns true if successful, false if not - virtual bool getProcessorSpeedMHz(irr::u32* MHz); - - //! gets the total and available system RAM in kB - //! \param Total: will contain the total system memory - //! \param Avail: will contain the available memory - //! \return Returns true if successful, false if not - virtual bool getSystemMemory(irr::u32* Total, irr::u32* Avail); - -private: - - core::stringw OperationSystem; -}; - -} // end namespace - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_OS_OPERATOR_H_INCLUDED__ +#define __C_OS_OPERATOR_H_INCLUDED__ + +#include "IOSOperator.h" +#include "irrString.h" + +namespace irr +{ + +//! The Operating system operator provides operation system specific methods and informations. +class COSOperator : public IOSOperator +{ +public: + + // constructor + COSOperator(const c8* osversion); + + //! destructor + virtual ~COSOperator(); + + //! returns the current operation system version as string. + virtual const wchar_t* getOperationSystemVersion(); + + //! copies text to the clipboard + virtual void copyToClipboard(const c8* text); + + //! gets text from the clipboard + //! \return Returns 0 if no string is in there. + virtual c8* getTextFromClipboard(); + + //! gets the processor speed in megahertz + //! \param Mhz: + //! \return Returns true if successful, false if not + virtual bool getProcessorSpeedMHz(irr::u32* MHz); + + //! gets the total and available system RAM in kB + //! \param Total: will contain the total system memory + //! \param Avail: will contain the available memory + //! \return Returns true if successful, false if not + virtual bool getSystemMemory(irr::u32* Total, irr::u32* Avail); + +private: + + core::stringw OperationSystem; +}; + +} // end namespace + +#endif + diff --git a/src/dep/src/irrlicht/COctTreeSceneNode.cpp b/src/dep/src/irrlicht/COctTreeSceneNode.cpp index 56d74c7..1ad5bbe 100644 --- a/src/dep/src/irrlicht/COctTreeSceneNode.cpp +++ b/src/dep/src/irrlicht/COctTreeSceneNode.cpp @@ -1,410 +1,410 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "COctTreeSceneNode.h" -#include "OctTree.h" -#include "ISceneManager.h" -#include "IVideoDriver.h" -#include "ICameraSceneNode.h" -#include "IMeshCache.h" -#include "IAnimatedMesh.h" - -#include "os.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -COctTreeSceneNode::COctTreeSceneNode(ISceneNode* parent, ISceneManager* mgr, - s32 id, s32 minimalPolysPerNode) -: ISceneNode(parent, mgr, id), StdOctTree(0), LightMapOctTree(0), - MinimalPolysPerNode(minimalPolysPerNode) - //,Mesh(0) -{ -#ifdef _DEBUG - setDebugName("COctTreeSceneNode"); -#endif - - vertexType = (video::E_VERTEX_TYPE)-1; -} - - - -//! destructor -COctTreeSceneNode::~COctTreeSceneNode() -{ - //if (Mesh) - // Mesh->drop(); - - deleteTree(); -} - - - -void COctTreeSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - // because this node supports rendering of mixed mode meshes consisting of - // transparent and solid material at the same time, we need to go through all - // materials, check of what type they are and register this node for the right - // render pass according to that. - - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - PassCount = 0; - int transparentCount = 0; - int solidCount = 0; - - // count transparent and solid materials in this scene node - for (u32 i=0; igetMaterialRenderer(Materials[i].MaterialType); - - if (rnd && rnd->isTransparent()) - ++transparentCount; - else - ++solidCount; - - if (solidCount && transparentCount) - break; - } - - // register according to material types counted - - if (solidCount) - SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID); - - if (transparentCount) - SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT); - - ISceneNode::OnRegisterSceneNode(); - } -} - - - -//! renders the node. -void COctTreeSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - if (vertexType == -1 || !driver) - return; - - ICameraSceneNode* camera = SceneManager->getActiveCamera(); - if (!camera) - return; - - bool isTransparentPass = - SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; - ++PassCount; - - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - - SViewFrustum frust = *camera->getViewFrustum(); - - //transform the frustum to the current absolute transformation - core::matrix4 invTrans(AbsoluteTransformation); - invTrans.makeInverse(); - frust.transform(invTrans); - - const core::aabbox3d &box = frust.getBoundingBox(); - - switch(vertexType) - { - case video::EVT_STANDARD: - { - StdOctTree->calculatePolys(box); - //StdOctTree->calculatePolys(frust); - - OctTree::SIndexData* d = StdOctTree->getIndexData(); - - for (u32 i=0; igetMaterialRenderer(Materials[i].MaterialType); - bool transparent = (rnd && rnd->isTransparent()); - - // only render transparent buffer if this is the transparent render pass - // and solid only in solid pass - if (transparent == isTransparentPass) - { - driver->setMaterial(Materials[i]); - driver->drawIndexedTriangleList( - &StdMeshes[i].Vertices[0], StdMeshes[i].Vertices.size(), - d[i].Indices, d[i].CurrentSize / 3); - } - } - - // for debug purposes only - if (DebugDataVisible && !Materials.empty() && PassCount==1) - { - const core::aabbox3d &box = frust.getBoundingBox(); - core::array< core::aabbox3d > boxes; - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - StdOctTree->renderBoundingBoxes(box, boxes); - for (u32 b=0; bdraw3DBox(boxes[b], video::SColor(0,255,255,255)); - - driver->draw3DBox(Box,video::SColor(0,255,0,0)); - } - break; - - } - case video::EVT_2TCOORDS: - { - LightMapOctTree->calculatePolys(box); - //LightMapOctTree->calculatePolys(frust); - - OctTree::SIndexData* d = LightMapOctTree->getIndexData(); - - for (u32 i=0; igetMaterialRenderer(Materials[i].MaterialType); - bool transparent = (rnd && rnd->isTransparent()); - - // only render transparent buffer if this is the transparent render pass - // and solid only in solid pass - if (transparent == isTransparentPass) - { - driver->setMaterial(Materials[i]); - driver->drawIndexedTriangleList( - &LightMapMeshes[i].Vertices[0], LightMapMeshes[i].Vertices.size(), - d[i].Indices, d[i].CurrentSize / 3); - } - } - - // for debug purposes only - if (DebugDataVisible && !Materials.empty() && PassCount==1) - { - const core::aabbox3d &box = frust.getBoundingBox(); - core::array< core::aabbox3d > boxes; - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - LightMapOctTree->renderBoundingBoxes(box, boxes); - for (u32 b=0; bdraw3DBox(boxes[b], video::SColor(0,255,255,255)); - - driver->draw3DBox(Box,video::SColor(0,255,0,0)); - } - } - break; - }; -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& COctTreeSceneNode::getBoundingBox() const -{ - return Box; -} - - -//! creates the tree -bool COctTreeSceneNode::createTree(IMesh* mesh) -{ - if (!mesh) - return false; - - //if (Mesh) -// Mesh->drop(); - - MeshName = SceneManager->getMeshCache()->getMeshFilename( mesh ); -// Mesh = mesh; -// Mesh->grab(); - - deleteTree(); - - u32 beginTime = os::Timer::getRealTime(); - - u32 nodeCount = 0; - u32 polyCount = 0; - - Box = mesh->getBoundingBox(); - - if (mesh->getMeshBufferCount()) - { - vertexType = mesh->getMeshBuffer(0)->getVertexType(); - - switch(vertexType) - { - case video::EVT_STANDARD: - { - for (u32 i=0; igetMeshBufferCount(); ++i) - { - IMeshBuffer* b = mesh->getMeshBuffer(i); - if (b->getVertexCount() && b->getIndexCount()) - { - Materials.push_back(b->getMaterial()); - - OctTree::SMeshChunk chunk; - chunk.MaterialId = Materials.size() - 1; - StdMeshes.push_back(chunk); - OctTree::SMeshChunk &nchunk = StdMeshes[StdMeshes.size()-1]; - - u32 v; - - for (v=0; vgetVertexCount(); ++v) - nchunk.Vertices.push_back(((video::S3DVertex*)b->getVertices())[v]); - - polyCount += b->getIndexCount(); - - for (v=0; vgetIndexCount(); ++v) - nchunk.Indices.push_back(b->getIndices()[v]); - } - } - - StdOctTree = new OctTree(StdMeshes, MinimalPolysPerNode); - nodeCount = StdOctTree->nodeCount; - } - break; - case video::EVT_2TCOORDS: - { - for (u32 i=0; igetMeshBufferCount(); ++i) - { - IMeshBuffer* b = mesh->getMeshBuffer(i); - - if (b->getVertexCount() && b->getIndexCount()) - { - Materials.push_back(b->getMaterial()); - - OctTree::SMeshChunk chunk; - chunk.MaterialId = Materials.size() - 1; - LightMapMeshes.push_back(chunk); - OctTree::SMeshChunk& nchunk = - LightMapMeshes[LightMapMeshes.size()-1]; - - u32 v; - - for (v=0; vgetVertexCount(); ++v) - nchunk.Vertices.push_back(((video::S3DVertex2TCoords*)b->getVertices())[v]); - - polyCount += b->getIndexCount(); - - for (v=0; vgetIndexCount(); ++v) - nchunk.Indices.push_back(b->getIndices()[v]); - } - } - - LightMapOctTree = new OctTree(LightMapMeshes, MinimalPolysPerNode); - nodeCount = LightMapOctTree->nodeCount; - } - break; - } - } - - u32 endTime = os::Timer::getRealTime(); - c8 tmp[255]; - sprintf(tmp, "Needed %ums to create OctTree SceneNode.(%d nodes, %d polys)", - endTime - beginTime, nodeCount, polyCount/3); - os::Printer::log(tmp, ELL_INFORMATION); - - return true; -} - - -//! returns the material based on the zero based index i. To get the amount -//! of materials used by this scene node, use getMaterialCount(). -//! This function is needed for inserting the node into the scene hirachy on a -//! optimal position for minimizing renderstate changes, but can also be used -//! to directly modify the material of a scene node. -video::SMaterial& COctTreeSceneNode::getMaterial(u32 i) -{ - if ( i >= Materials.size() ) - return ISceneNode::getMaterial(i); - - return Materials[i]; -} - -//! returns amount of materials used by this scene node. -u32 COctTreeSceneNode::getMaterialCount() -{ - return Materials.size(); -} - - -//! Writes attributes of the scene node. -void COctTreeSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - ISceneNode::serializeAttributes(out, options); - - out->addInt ("MinimalPolysPerNode", MinimalPolysPerNode); - //out->addString("Mesh", SceneManager->getMeshCache()->getMeshFilename(Mesh)); - out->addString("Mesh", MeshName.c_str()); -} - -//! Reads attributes of the scene node. -void COctTreeSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - int oldMinimal = MinimalPolysPerNode; - //core::stringc oldMeshStr = SceneManager->getMeshCache()->getMeshFilename(Mesh); - core::stringc oldMeshStr = MeshName; - - MinimalPolysPerNode = in->getAttributeAsInt("MinimalPolysPerNode"); - core::stringc newMeshStr = in->getAttributeAsString("Mesh"); - - bool loadedNewMesh = false; - - IMesh* newMesh = 0; - - if (newMeshStr != "" && oldMeshStr != newMeshStr) - { - IAnimatedMesh* newAnimatedMesh = SceneManager->getMesh(newMeshStr.c_str()); - - if (newAnimatedMesh) - newMesh = newAnimatedMesh->getMesh(0); - - if (newMesh) - { -/* - if (Mesh) - Mesh->drop(); - - Mesh = newMesh; - Mesh->grab(); -*/ - loadedNewMesh = true; - } - } - - if (loadedNewMesh || MinimalPolysPerNode != oldMinimal) - { - // recalculate tree - //createTree(Mesh); - createTree ( newMesh ); - newMesh->drop (); - } - - ISceneNode::deserializeAttributes(in, options); -} - - -void COctTreeSceneNode::deleteTree() -{ - delete StdOctTree; - StdOctTree = 0; - StdMeshes.clear(); - - delete LightMapOctTree; - LightMapOctTree = 0; - LightMapMeshes.clear(); - - Materials.clear(); -} - -} // end namespace scene -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "COctTreeSceneNode.h" +#include "OctTree.h" +#include "ISceneManager.h" +#include "IVideoDriver.h" +#include "ICameraSceneNode.h" +#include "IMeshCache.h" +#include "IAnimatedMesh.h" + +#include "os.h" + +namespace irr +{ +namespace scene +{ + + +//! constructor +COctTreeSceneNode::COctTreeSceneNode(ISceneNode* parent, ISceneManager* mgr, + s32 id, s32 minimalPolysPerNode) +: ISceneNode(parent, mgr, id), StdOctTree(0), LightMapOctTree(0), + MinimalPolysPerNode(minimalPolysPerNode) + //,Mesh(0) +{ +#ifdef _DEBUG + setDebugName("COctTreeSceneNode"); +#endif + + vertexType = (video::E_VERTEX_TYPE)-1; +} + + + +//! destructor +COctTreeSceneNode::~COctTreeSceneNode() +{ + //if (Mesh) + // Mesh->drop(); + + deleteTree(); +} + + + +void COctTreeSceneNode::OnRegisterSceneNode() +{ + if (IsVisible) + { + // because this node supports rendering of mixed mode meshes consisting of + // transparent and solid material at the same time, we need to go through all + // materials, check of what type they are and register this node for the right + // render pass according to that. + + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + + PassCount = 0; + int transparentCount = 0; + int solidCount = 0; + + // count transparent and solid materials in this scene node + for (u32 i=0; igetMaterialRenderer(Materials[i].MaterialType); + + if (rnd && rnd->isTransparent()) + ++transparentCount; + else + ++solidCount; + + if (solidCount && transparentCount) + break; + } + + // register according to material types counted + + if (solidCount) + SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID); + + if (transparentCount) + SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT); + + ISceneNode::OnRegisterSceneNode(); + } +} + + + +//! renders the node. +void COctTreeSceneNode::render() +{ + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + + if (vertexType == -1 || !driver) + return; + + ICameraSceneNode* camera = SceneManager->getActiveCamera(); + if (!camera) + return; + + bool isTransparentPass = + SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; + ++PassCount; + + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + + SViewFrustum frust = *camera->getViewFrustum(); + + //transform the frustum to the current absolute transformation + core::matrix4 invTrans(AbsoluteTransformation); + invTrans.makeInverse(); + frust.transform(invTrans); + + const core::aabbox3d &box = frust.getBoundingBox(); + + switch(vertexType) + { + case video::EVT_STANDARD: + { + StdOctTree->calculatePolys(box); + //StdOctTree->calculatePolys(frust); + + OctTree::SIndexData* d = StdOctTree->getIndexData(); + + for (u32 i=0; igetMaterialRenderer(Materials[i].MaterialType); + bool transparent = (rnd && rnd->isTransparent()); + + // only render transparent buffer if this is the transparent render pass + // and solid only in solid pass + if (transparent == isTransparentPass) + { + driver->setMaterial(Materials[i]); + driver->drawIndexedTriangleList( + &StdMeshes[i].Vertices[0], StdMeshes[i].Vertices.size(), + d[i].Indices, d[i].CurrentSize / 3); + } + } + + // for debug purposes only + if (DebugDataVisible && !Materials.empty() && PassCount==1) + { + const core::aabbox3d &box = frust.getBoundingBox(); + core::array< core::aabbox3d > boxes; + video::SMaterial m; + m.Lighting = false; + driver->setMaterial(m); + StdOctTree->renderBoundingBoxes(box, boxes); + for (u32 b=0; bdraw3DBox(boxes[b], video::SColor(0,255,255,255)); + + driver->draw3DBox(Box,video::SColor(0,255,0,0)); + } + break; + + } + case video::EVT_2TCOORDS: + { + LightMapOctTree->calculatePolys(box); + //LightMapOctTree->calculatePolys(frust); + + OctTree::SIndexData* d = LightMapOctTree->getIndexData(); + + for (u32 i=0; igetMaterialRenderer(Materials[i].MaterialType); + bool transparent = (rnd && rnd->isTransparent()); + + // only render transparent buffer if this is the transparent render pass + // and solid only in solid pass + if (transparent == isTransparentPass) + { + driver->setMaterial(Materials[i]); + driver->drawIndexedTriangleList( + &LightMapMeshes[i].Vertices[0], LightMapMeshes[i].Vertices.size(), + d[i].Indices, d[i].CurrentSize / 3); + } + } + + // for debug purposes only + if (DebugDataVisible && !Materials.empty() && PassCount==1) + { + const core::aabbox3d &box = frust.getBoundingBox(); + core::array< core::aabbox3d > boxes; + video::SMaterial m; + m.Lighting = false; + driver->setMaterial(m); + LightMapOctTree->renderBoundingBoxes(box, boxes); + for (u32 b=0; bdraw3DBox(boxes[b], video::SColor(0,255,255,255)); + + driver->draw3DBox(Box,video::SColor(0,255,0,0)); + } + } + break; + }; +} + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& COctTreeSceneNode::getBoundingBox() const +{ + return Box; +} + + +//! creates the tree +bool COctTreeSceneNode::createTree(IMesh* mesh) +{ + if (!mesh) + return false; + + //if (Mesh) +// Mesh->drop(); + + MeshName = SceneManager->getMeshCache()->getMeshFilename( mesh ); +// Mesh = mesh; +// Mesh->grab(); + + deleteTree(); + + u32 beginTime = os::Timer::getRealTime(); + + u32 nodeCount = 0; + u32 polyCount = 0; + + Box = mesh->getBoundingBox(); + + if (mesh->getMeshBufferCount()) + { + vertexType = mesh->getMeshBuffer(0)->getVertexType(); + + switch(vertexType) + { + case video::EVT_STANDARD: + { + for (u32 i=0; igetMeshBufferCount(); ++i) + { + IMeshBuffer* b = mesh->getMeshBuffer(i); + if (b->getVertexCount() && b->getIndexCount()) + { + Materials.push_back(b->getMaterial()); + + OctTree::SMeshChunk chunk; + chunk.MaterialId = Materials.size() - 1; + StdMeshes.push_back(chunk); + OctTree::SMeshChunk &nchunk = StdMeshes[StdMeshes.size()-1]; + + u32 v; + + for (v=0; vgetVertexCount(); ++v) + nchunk.Vertices.push_back(((video::S3DVertex*)b->getVertices())[v]); + + polyCount += b->getIndexCount(); + + for (v=0; vgetIndexCount(); ++v) + nchunk.Indices.push_back(b->getIndices()[v]); + } + } + + StdOctTree = new OctTree(StdMeshes, MinimalPolysPerNode); + nodeCount = StdOctTree->nodeCount; + } + break; + case video::EVT_2TCOORDS: + { + for (u32 i=0; igetMeshBufferCount(); ++i) + { + IMeshBuffer* b = mesh->getMeshBuffer(i); + + if (b->getVertexCount() && b->getIndexCount()) + { + Materials.push_back(b->getMaterial()); + + OctTree::SMeshChunk chunk; + chunk.MaterialId = Materials.size() - 1; + LightMapMeshes.push_back(chunk); + OctTree::SMeshChunk& nchunk = + LightMapMeshes[LightMapMeshes.size()-1]; + + u32 v; + + for (v=0; vgetVertexCount(); ++v) + nchunk.Vertices.push_back(((video::S3DVertex2TCoords*)b->getVertices())[v]); + + polyCount += b->getIndexCount(); + + for (v=0; vgetIndexCount(); ++v) + nchunk.Indices.push_back(b->getIndices()[v]); + } + } + + LightMapOctTree = new OctTree(LightMapMeshes, MinimalPolysPerNode); + nodeCount = LightMapOctTree->nodeCount; + } + break; + } + } + + u32 endTime = os::Timer::getRealTime(); + c8 tmp[255]; + sprintf(tmp, "Needed %ums to create OctTree SceneNode.(%d nodes, %d polys)", + endTime - beginTime, nodeCount, polyCount/3); + os::Printer::log(tmp, ELL_INFORMATION); + + return true; +} + + +//! returns the material based on the zero based index i. To get the amount +//! of materials used by this scene node, use getMaterialCount(). +//! This function is needed for inserting the node into the scene hirachy on a +//! optimal position for minimizing renderstate changes, but can also be used +//! to directly modify the material of a scene node. +video::SMaterial& COctTreeSceneNode::getMaterial(u32 i) +{ + if ( i >= Materials.size() ) + return ISceneNode::getMaterial(i); + + return Materials[i]; +} + +//! returns amount of materials used by this scene node. +u32 COctTreeSceneNode::getMaterialCount() +{ + return Materials.size(); +} + + +//! Writes attributes of the scene node. +void COctTreeSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + ISceneNode::serializeAttributes(out, options); + + out->addInt ("MinimalPolysPerNode", MinimalPolysPerNode); + //out->addString("Mesh", SceneManager->getMeshCache()->getMeshFilename(Mesh)); + out->addString("Mesh", MeshName.c_str()); +} + +//! Reads attributes of the scene node. +void COctTreeSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + int oldMinimal = MinimalPolysPerNode; + //core::stringc oldMeshStr = SceneManager->getMeshCache()->getMeshFilename(Mesh); + core::stringc oldMeshStr = MeshName; + + MinimalPolysPerNode = in->getAttributeAsInt("MinimalPolysPerNode"); + core::stringc newMeshStr = in->getAttributeAsString("Mesh"); + + bool loadedNewMesh = false; + + IMesh* newMesh = 0; + + if (newMeshStr != "" && oldMeshStr != newMeshStr) + { + IAnimatedMesh* newAnimatedMesh = SceneManager->getMesh(newMeshStr.c_str()); + + if (newAnimatedMesh) + newMesh = newAnimatedMesh->getMesh(0); + + if (newMesh) + { +/* + if (Mesh) + Mesh->drop(); + + Mesh = newMesh; + Mesh->grab(); +*/ + loadedNewMesh = true; + } + } + + if (loadedNewMesh || MinimalPolysPerNode != oldMinimal) + { + // recalculate tree + //createTree(Mesh); + createTree ( newMesh ); + newMesh->drop (); + } + + ISceneNode::deserializeAttributes(in, options); +} + + +void COctTreeSceneNode::deleteTree() +{ + delete StdOctTree; + StdOctTree = 0; + StdMeshes.clear(); + + delete LightMapOctTree; + LightMapOctTree = 0; + LightMapMeshes.clear(); + + Materials.clear(); +} + +} // end namespace scene +} // end namespace irr diff --git a/src/dep/src/irrlicht/COctTreeSceneNode.h b/src/dep/src/irrlicht/COctTreeSceneNode.h index 878e329..7f28315 100644 --- a/src/dep/src/irrlicht/COctTreeSceneNode.h +++ b/src/dep/src/irrlicht/COctTreeSceneNode.h @@ -1,83 +1,83 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OCT_TREE_SCENE_NODE_H_INCLUDED__ -#define __C_OCT_TREE_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "IMesh.h" -#include "OctTree.h" - -namespace irr -{ -namespace scene -{ - //! implementation of the IBspTreeSceneNode - class COctTreeSceneNode : public ISceneNode - { - public: - - //! constructor - COctTreeSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - s32 minimalPolysPerNode=128); - - //! destructor - virtual ~COctTreeSceneNode(); - - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! creates the tree - bool createTree(IMesh* mesh); - - //! returns the material based on the zero based index i. To get the amount - //! of materials used by this scene node, use getMaterialCount(). - //! This function is needed for inserting the node into the scene hirachy on a - //! optimal position for minimizing renderstate changes, but can also be used - //! to directly modify the material of a scene node. - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount(); - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_OCT_TREE; } - - private: - - void deleteTree(); - - core::aabbox3d Box; - - OctTree* StdOctTree; - core::array< OctTree::SMeshChunk > StdMeshes; - - OctTree* LightMapOctTree; - core::array< OctTree::SMeshChunk > LightMapMeshes; - - video::E_VERTEX_TYPE vertexType; - core::array< video::SMaterial > Materials; - - //IMesh* Mesh; - core::stringc MeshName; - s32 MinimalPolysPerNode; - s32 PassCount; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_OCT_TREE_SCENE_NODE_H_INCLUDED__ +#define __C_OCT_TREE_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" +#include "IMesh.h" +#include "OctTree.h" + +namespace irr +{ +namespace scene +{ + //! implementation of the IBspTreeSceneNode + class COctTreeSceneNode : public ISceneNode + { + public: + + //! constructor + COctTreeSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + s32 minimalPolysPerNode=128); + + //! destructor + virtual ~COctTreeSceneNode(); + + virtual void OnRegisterSceneNode(); + + //! renders the node. + virtual void render(); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! creates the tree + bool createTree(IMesh* mesh); + + //! returns the material based on the zero based index i. To get the amount + //! of materials used by this scene node, use getMaterialCount(). + //! This function is needed for inserting the node into the scene hirachy on a + //! optimal position for minimizing renderstate changes, but can also be used + //! to directly modify the material of a scene node. + virtual video::SMaterial& getMaterial(u32 i); + + //! returns amount of materials used by this scene node. + virtual u32 getMaterialCount(); + + //! Writes attributes of the scene node. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_OCT_TREE; } + + private: + + void deleteTree(); + + core::aabbox3d Box; + + OctTree* StdOctTree; + core::array< OctTree::SMeshChunk > StdMeshes; + + OctTree* LightMapOctTree; + core::array< OctTree::SMeshChunk > LightMapMeshes; + + video::E_VERTEX_TYPE vertexType; + core::array< video::SMaterial > Materials; + + //IMesh* Mesh; + core::stringc MeshName; + s32 MinimalPolysPerNode; + s32 PassCount; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/COctTreeTriangleSelector.cpp b/src/dep/src/irrlicht/COctTreeTriangleSelector.cpp index d9a22c1..ed5494d 100644 --- a/src/dep/src/irrlicht/COctTreeTriangleSelector.cpp +++ b/src/dep/src/irrlicht/COctTreeTriangleSelector.cpp @@ -1,185 +1,185 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "COctTreeTriangleSelector.h" -#include "ISceneNode.h" - -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -COctTreeTriangleSelector::COctTreeTriangleSelector(IMesh* mesh, ISceneNode* node, - s32 minimalPolysPerNode) -: CTriangleSelector(mesh, node), Root(0), NodeCount(0), - MinimalPolysPerNode(minimalPolysPerNode) -{ - #ifdef _DEBUG - setDebugName("COctTreeTriangleSelector"); - #endif - - - if (!Triangles.empty()) - { - u32 start = os::Timer::getRealTime(); - - // create the triangle octtree - Root = new SOctTreeNode(); - Root->Triangles = Triangles; - constructOctTree(Root); - - u32 end = os::Timer::getRealTime(); - c8 tmp[255]; - sprintf(tmp, "Needed %ums to create OctTreeTriangleSelector.(%d nodes, %u polys)", - end - start, NodeCount, Triangles.size()); - os::Printer::log(tmp, ELL_INFORMATION); - } -} - - - -//! destructor -COctTreeTriangleSelector::~COctTreeTriangleSelector() -{ - delete Root; -} - - - -void COctTreeTriangleSelector::constructOctTree(SOctTreeNode* node) -{ - ++NodeCount; - - node->Box.reset(node->Triangles[0].pointA); - - // get bounding box - s32 cnt = node->Triangles.size(); - for (s32 i=0; iBox.addInternalPoint(node->Triangles[i].pointA); - node->Box.addInternalPoint(node->Triangles[i].pointB); - node->Box.addInternalPoint(node->Triangles[i].pointC); - } - - core::vector3df middle = node->Box.getCenter(); - core::vector3df edges[8]; - node->Box.getEdges(edges); - - core::aabbox3d box; - - // calculate children - - if (!node->Box.isEmpty() && (s32)node->Triangles.size() > MinimalPolysPerNode) - for (s32 ch=0; ch<8; ++ch) - { - box.reset(middle); - box.addInternalPoint(edges[ch]); - node->Child[ch] = new SOctTreeNode(); - - for (s32 i=0; i<(s32)node->Triangles.size(); ++i) - { - if (node->Triangles[i].isTotalInsideBox(box)) - { - node->Child[ch]->Triangles.push_back(node->Triangles[i]); - node->Triangles.erase(i); - --i; - } - } - - if (node->Child[ch]->Triangles.empty()) - { - delete node->Child[ch]; - node->Child[ch] = 0; - } - else - constructOctTree(node->Child[ch]); - } -} - - - -//! Gets all triangles which lie within a specific bounding box. -void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, - s32 arraySize, s32& outTriangleCount, - const core::aabbox3d& box, - const core::matrix4* transform) -{ - core::matrix4 mat; - core::aabbox3d invbox = box; - - if (SceneNode) - { - mat = SceneNode->getAbsoluteTransformation(); - mat.makeInverse(); - mat.transformBox(invbox); - } - - mat.makeIdentity(); - - if (transform) - mat = (*transform); - - if (SceneNode) - mat *= SceneNode->getAbsoluteTransformation(); - - s32 trianglesWritten = 0; - - if (Root) - getTrianglesFromOctTree(Root, trianglesWritten, - arraySize, invbox, &mat, triangles); - - outTriangleCount = trianglesWritten; -} - - -void COctTreeTriangleSelector::getTrianglesFromOctTree( - SOctTreeNode* node, s32& trianglesWritten, - s32 maximumSize, const core::aabbox3d& box, - const core::matrix4* mat, core::triangle3df* triangles) -{ - if (!box.intersectsWithBox(node->Box)) - return; - - s32 cnt = node->Triangles.size(); - if (cnt + trianglesWritten > maximumSize) - cnt -= cnt + trianglesWritten - maximumSize; - - s32 i; - - for (i=0; iTriangles[i]; - mat->transformVect(triangles[trianglesWritten].pointA); - mat->transformVect(triangles[trianglesWritten].pointB); - mat->transformVect(triangles[trianglesWritten].pointC); - ++trianglesWritten; - } - - for (i=0; i<8; ++i) - if (node->Child[i]) - getTrianglesFromOctTree(node->Child[i], trianglesWritten, - maximumSize, box, mat, triangles); -} - - -//! Gets all triangles which have or may have contact with a 3d line. -void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d& line, - const core::matrix4* transform) -{ - core::aabbox3d box(line.start); - box.addInternalPoint(line.end); - - // TODO: Could be optimized for line a little bit more. - COctTreeTriangleSelector::getTriangles(triangles, arraySize, outTriangleCount, - box, transform); -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "COctTreeTriangleSelector.h" +#include "ISceneNode.h" + +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +COctTreeTriangleSelector::COctTreeTriangleSelector(IMesh* mesh, ISceneNode* node, + s32 minimalPolysPerNode) +: CTriangleSelector(mesh, node), Root(0), NodeCount(0), + MinimalPolysPerNode(minimalPolysPerNode) +{ + #ifdef _DEBUG + setDebugName("COctTreeTriangleSelector"); + #endif + + + if (!Triangles.empty()) + { + u32 start = os::Timer::getRealTime(); + + // create the triangle octtree + Root = new SOctTreeNode(); + Root->Triangles = Triangles; + constructOctTree(Root); + + u32 end = os::Timer::getRealTime(); + c8 tmp[255]; + sprintf(tmp, "Needed %ums to create OctTreeTriangleSelector.(%d nodes, %u polys)", + end - start, NodeCount, Triangles.size()); + os::Printer::log(tmp, ELL_INFORMATION); + } +} + + + +//! destructor +COctTreeTriangleSelector::~COctTreeTriangleSelector() +{ + delete Root; +} + + + +void COctTreeTriangleSelector::constructOctTree(SOctTreeNode* node) +{ + ++NodeCount; + + node->Box.reset(node->Triangles[0].pointA); + + // get bounding box + s32 cnt = node->Triangles.size(); + for (s32 i=0; iBox.addInternalPoint(node->Triangles[i].pointA); + node->Box.addInternalPoint(node->Triangles[i].pointB); + node->Box.addInternalPoint(node->Triangles[i].pointC); + } + + core::vector3df middle = node->Box.getCenter(); + core::vector3df edges[8]; + node->Box.getEdges(edges); + + core::aabbox3d box; + + // calculate children + + if (!node->Box.isEmpty() && (s32)node->Triangles.size() > MinimalPolysPerNode) + for (s32 ch=0; ch<8; ++ch) + { + box.reset(middle); + box.addInternalPoint(edges[ch]); + node->Child[ch] = new SOctTreeNode(); + + for (s32 i=0; i<(s32)node->Triangles.size(); ++i) + { + if (node->Triangles[i].isTotalInsideBox(box)) + { + node->Child[ch]->Triangles.push_back(node->Triangles[i]); + node->Triangles.erase(i); + --i; + } + } + + if (node->Child[ch]->Triangles.empty()) + { + delete node->Child[ch]; + node->Child[ch] = 0; + } + else + constructOctTree(node->Child[ch]); + } +} + + + +//! Gets all triangles which lie within a specific bounding box. +void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, + s32 arraySize, s32& outTriangleCount, + const core::aabbox3d& box, + const core::matrix4* transform) +{ + core::matrix4 mat; + core::aabbox3d invbox = box; + + if (SceneNode) + { + mat = SceneNode->getAbsoluteTransformation(); + mat.makeInverse(); + mat.transformBox(invbox); + } + + mat.makeIdentity(); + + if (transform) + mat = (*transform); + + if (SceneNode) + mat *= SceneNode->getAbsoluteTransformation(); + + s32 trianglesWritten = 0; + + if (Root) + getTrianglesFromOctTree(Root, trianglesWritten, + arraySize, invbox, &mat, triangles); + + outTriangleCount = trianglesWritten; +} + + +void COctTreeTriangleSelector::getTrianglesFromOctTree( + SOctTreeNode* node, s32& trianglesWritten, + s32 maximumSize, const core::aabbox3d& box, + const core::matrix4* mat, core::triangle3df* triangles) +{ + if (!box.intersectsWithBox(node->Box)) + return; + + s32 cnt = node->Triangles.size(); + if (cnt + trianglesWritten > maximumSize) + cnt -= cnt + trianglesWritten - maximumSize; + + s32 i; + + for (i=0; iTriangles[i]; + mat->transformVect(triangles[trianglesWritten].pointA); + mat->transformVect(triangles[trianglesWritten].pointB); + mat->transformVect(triangles[trianglesWritten].pointC); + ++trianglesWritten; + } + + for (i=0; i<8; ++i) + if (node->Child[i]) + getTrianglesFromOctTree(node->Child[i], trianglesWritten, + maximumSize, box, mat, triangles); +} + + +//! Gets all triangles which have or may have contact with a 3d line. +void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::line3d& line, + const core::matrix4* transform) +{ + core::aabbox3d box(line.start); + box.addInternalPoint(line.end); + + // TODO: Could be optimized for line a little bit more. + COctTreeTriangleSelector::getTriangles(triangles, arraySize, outTriangleCount, + box, transform); +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/COctTreeTriangleSelector.h b/src/dep/src/irrlicht/COctTreeTriangleSelector.h index ed66da3..cb35af7 100644 --- a/src/dep/src/irrlicht/COctTreeTriangleSelector.h +++ b/src/dep/src/irrlicht/COctTreeTriangleSelector.h @@ -1,75 +1,75 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OCT_TREE_TRIANGLE_SELECTOR_H_INCLUDED__ -#define __C_OCT_TREE_TRIANGLE_SELECTOR_H_INCLUDED__ - -#include "CTriangleSelector.h" - -namespace irr -{ -namespace scene -{ - -class ISceneNode; - -//! Stupid triangle selector without optimization -class COctTreeTriangleSelector : public CTriangleSelector -{ -public: - - //! Constructs a selector based on a mesh - COctTreeTriangleSelector(IMesh* mesh, ISceneNode* node, s32 minimalPolysPerNode); - - ~COctTreeTriangleSelector(); - - //! Gets all triangles which lie within a specific bounding box. - void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, - const core::aabbox3d& box, const core::matrix4* transform=0); - - //! Gets all triangles which have or may have contact with a 3d line. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d& line, - const core::matrix4* transform=0); - -private: - - struct SOctTreeNode - { - SOctTreeNode() - { - for (s32 i=0; i<8; ++i) - Child[i] = 0; - } - - ~SOctTreeNode() - { - for (s32 i=0; i<8; ++i) - delete Child[i]; - } - - core::array Triangles; - SOctTreeNode* Child[8]; - core::aabbox3d Box; - }; - - - void constructOctTree(SOctTreeNode* node); - void deleteEmptyNodes(SOctTreeNode* node); - void getTrianglesFromOctTree(SOctTreeNode* node, s32& trianglesWritten, s32 maximumSize, - const core::aabbox3d& box, const core::matrix4* transform, - core::triangle3df* triangles); - - SOctTreeNode* Root; - s32 NodeCount; - s32 MinimalPolysPerNode; - -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_OCT_TREE_TRIANGLE_SELECTOR_H_INCLUDED__ +#define __C_OCT_TREE_TRIANGLE_SELECTOR_H_INCLUDED__ + +#include "CTriangleSelector.h" + +namespace irr +{ +namespace scene +{ + +class ISceneNode; + +//! Stupid triangle selector without optimization +class COctTreeTriangleSelector : public CTriangleSelector +{ +public: + + //! Constructs a selector based on a mesh + COctTreeTriangleSelector(IMesh* mesh, ISceneNode* node, s32 minimalPolysPerNode); + + ~COctTreeTriangleSelector(); + + //! Gets all triangles which lie within a specific bounding box. + void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, + const core::aabbox3d& box, const core::matrix4* transform=0); + + //! Gets all triangles which have or may have contact with a 3d line. + virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::line3d& line, + const core::matrix4* transform=0); + +private: + + struct SOctTreeNode + { + SOctTreeNode() + { + for (s32 i=0; i<8; ++i) + Child[i] = 0; + } + + ~SOctTreeNode() + { + for (s32 i=0; i<8; ++i) + delete Child[i]; + } + + core::array Triangles; + SOctTreeNode* Child[8]; + core::aabbox3d Box; + }; + + + void constructOctTree(SOctTreeNode* node); + void deleteEmptyNodes(SOctTreeNode* node); + void getTrianglesFromOctTree(SOctTreeNode* node, s32& trianglesWritten, s32 maximumSize, + const core::aabbox3d& box, const core::matrix4* transform, + core::triangle3df* triangles); + + SOctTreeNode* Root; + s32 NodeCount; + s32 MinimalPolysPerNode; + +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/COgreMeshFileLoader.cpp b/src/dep/src/irrlicht/COgreMeshFileLoader.cpp index e262123..913e263 100644 --- a/src/dep/src/irrlicht/COgreMeshFileLoader.cpp +++ b/src/dep/src/irrlicht/COgreMeshFileLoader.cpp @@ -1,1029 +1,1029 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// orginally written by Christian Stehno, modified by Nikolaus Gebhardt - -#include "COgreMeshFileLoader.h" -#include "os.h" -#include "SMeshBuffer.h" -#include "SAnimatedMesh.h" -#include "fast_atof.h" -#include "coreutil.h" - -namespace irr -{ -namespace scene -{ - -// Main Chunks -const u16 COGRE_HEADER= 0x1000; -const u16 COGRE_MESH= 0x3000; - -// sub chunks of COGRE_MESH -const u16 COGRE_SUBMESH= 0x4000; -const u16 COGRE_GEOMETRY= 0x5000; -const u16 COGRE_SKELETON_LINK= 0x6000; -const u16 COGRE_BONE_ASSIGNMENT= 0x7000; -const u16 COGRE_MESH_LOD= 0x8000; -const u16 COGRE_MESH_BOUNDS= 0x9000; -const u16 COGRE_MESH_SUBMESH_NAME_TABLE= 0xA000; -const u16 COGRE_MESH_EDGE_LISTS= 0xB000; - -// sub chunks of COGRE_GEOMETRY -const u16 COGRE_GEOMETRY_VERTEX_DECLARATION= 0x5100; -const u16 COGRE_GEOMETRY_VERTEX_ELEMENT= 0x5110; -const u16 COGRE_GEOMETRY_VERTEX_BUFFER= 0x5200; -const u16 COGRE_GEOMETRY_VERTEX_BUFFER_DATA= 0x5210; - -// sub chunks of COGRE_SUBMESH -const u16 COGRE_SUBMESH_OPERATION= 0x4010; -const u16 COGRE_SUBMESH_BONE_ASSIGNMENT= 0x4100; -const u16 COGRE_SUBMESH_TEXTURE_ALIAS= 0x4200; - -//! Constructor -COgreMeshFileLoader::COgreMeshFileLoader(IMeshManipulator* manip,io::IFileSystem* fs, video::IVideoDriver* driver) -: FileSystem(fs), Driver(driver), SwapEndian(false), Mesh(0), Manipulator(manip), NumUV(0) -{ - if (FileSystem) - FileSystem->grab(); - - if (Driver) - Driver->grab(); -} - - - -//! destructor -COgreMeshFileLoader::~COgreMeshFileLoader() -{ - clearMeshes(); - - if (FileSystem) - FileSystem->drop(); - - if (Driver) - Driver->drop(); - - if (Mesh) - Mesh->drop(); -} - - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool COgreMeshFileLoader::isALoadableFileExtension(const c8* filename) -{ - return strstr(filename, ".mesh")!=0; -} - - - -//! creates/loads an animated mesh from the file. -//! \return Pointer to the created mesh. Returns 0 if loading failed. -//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). -//! See IUnknown::drop() for more information. -IAnimatedMesh* COgreMeshFileLoader::createMesh(io::IReadFile* file) -{ - s16 id; - - file->read(&id, 2); - - if (id == COGRE_HEADER) - SwapEndian=false; - else if (id == 0x0010) - SwapEndian=true; - else - return false; - ChunkData data; - readString(file, data, Version); - if (Version != "[MeshSerializer_v1.30]") - return false; - - clearMeshes(); - if (Mesh) - Mesh->drop(); - - Mesh = new SMesh(); - setCurrentlyLoadingPath(file); - loadMaterials(file); - - if (readChunk(file)) - { - // success - SAnimatedMesh* am = new SAnimatedMesh(); - am->Type = EAMT_3DS; - - for (u32 i=0; igetMeshBufferCount(); ++i) - ((SMeshBuffer*)Mesh->getMeshBuffer(i))->recalculateBoundingBox(); - - Mesh->recalculateBoundingBox(); - - am->addMesh(Mesh); - am->recalculateBoundingBox(); - Mesh->drop(); - Mesh = 0; - return am; - } - - Mesh->drop(); - Mesh = 0; - - return 0; -} - - -bool COgreMeshFileLoader::readChunk(io::IReadFile* file) -{ - while(file->getPos() < file->getSize()) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case COGRE_MESH: - { - Meshes.push_back(OgreMesh()); - readObjectChunk(file, data, Meshes.getLast()); - composeObject(); - } - break; - default: - return true; - } - } - - return true; -} - - -bool COgreMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData& parent, OgreMesh& mesh) -{ - readBool(file, parent, mesh.SkeletalAnimation); - while ((parent.read < parent.header.length)&&(file->getPos() < file->getSize())) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case COGRE_GEOMETRY: - { - readGeometry(file, data, mesh.Geometry); - } - break; - case COGRE_SUBMESH: - mesh.SubMeshes.push_back(OgreSubMesh()); - readSubMesh(file, data, mesh.SubMeshes.getLast()); - break; - case COGRE_MESH_BOUNDS: - { - readVector(file, data, mesh.BBoxMinEdge); - readVector(file, data, mesh.BBoxMaxEdge); - readFloat(file, data, mesh.BBoxRadius); - } - break; - case COGRE_SKELETON_LINK: - case COGRE_BONE_ASSIGNMENT: - case COGRE_MESH_LOD: - case COGRE_MESH_SUBMESH_NAME_TABLE: - case COGRE_MESH_EDGE_LISTS: - // ignore chunk - file->seek(data.header.length-data.read, true); - data.read += data.header.length-data.read; - break; - default: - parent.read=parent.header.length; - file->seek(-(int)sizeof(ChunkHeader), true); - return true; - } - parent.read += data.read; - } - return true; -} - - -bool COgreMeshFileLoader::readGeometry(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry) -{ - readInt(file, parent, geometry.NumVertex); - while(parent.read < parent.header.length) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case COGRE_GEOMETRY_VERTEX_DECLARATION: - readVertexDeclaration(file, data, geometry); - break; - case COGRE_GEOMETRY_VERTEX_BUFFER: - readVertexBuffer(file, data, geometry); - break; - default: - // ignore chunk - file->seek(data.header.length-data.read, true); - data.read += data.header.length-data.read; - } - parent.read += data.read; - } - return true; -} - - -bool COgreMeshFileLoader::readVertexDeclaration(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry) -{ - NumUV = 0; - while(parent.read < parent.header.length) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case COGRE_GEOMETRY_VERTEX_ELEMENT: - { - OgreVertexElement elem; - readShort(file, data, elem.Source); - readShort(file, data, elem.Type); - readShort(file, data, elem.Semantic); - if (elem.Semantic == 7) //Tex coords - { - ++NumUV; - } - readShort(file, data, elem.Offset); - elem.Offset /= sizeof(f32); - readShort(file, data, elem.Index); - geometry.Elements.push_back(elem); - } - break; - default: - // ignore chunk - file->seek(data.header.length-data.read, true); - data.read += data.header.length-data.read; - } - parent.read += data.read; - } - return true; -} - - -bool COgreMeshFileLoader::readVertexBuffer(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry) -{ - OgreVertexBuffer buf; - readShort(file, parent, buf.BindIndex); - readShort(file, parent, buf.VertexSize); - buf.VertexSize /= sizeof(f32); - ChunkData data; - readChunkData(file, data); - - if (data.header.id == COGRE_GEOMETRY_VERTEX_BUFFER_DATA) - { - buf.Data = new f32[geometry.NumVertex*buf.VertexSize]; - for (s32 i=0; iseek(data.header.length-data.read, true); - data.read += data.header.length-data.read; - break; - default: - parent.read=parent.header.length; - file->seek(-(int)sizeof(ChunkHeader), true); - return true; - } - parent.read += data.read; - } - return true; -} - - - -void COgreMeshFileLoader::composeMeshBufferMaterial(scene::IMeshBuffer* mb, const core::stringc& materialName) -{ - video::SMaterial& material=mb->getMaterial(); - for (u32 k=0; kgetTexture(Materials[k].Techniques[0].Passes[0].Texture.Filename.c_str()); - if (!material.Textures[0]) - { - // retry with relative path - core::stringc relative = CurrentlyLoadingFromPath; - relative += '/'; - relative += Materials[k].Techniques[0].Passes[0].Texture.Filename; - material.Textures[0] = Driver->getTexture(relative.c_str()); - } - } - break; - } - } -} - - - -scene::SMeshBuffer* COgreMeshFileLoader::composeMeshBuffer(const core::array& indices, const OgreGeometry& geom) -{ - scene::SMeshBuffer *mb=new scene::SMeshBuffer(); - - u32 i; - mb->Indices.set_used(indices.size()); - for (i=0; iIndices[i]=indices[i]; - - mb->Vertices.set_used(geom.NumVertex); - for (i=0; iVertices[k].Color=mb->Material.DiffuseColor; - mb->Vertices[k].Pos.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1],geom.Buffers[j].Data[ePos+2]); - ePos += eSize; - } - } - } - } - - if (geom.Elements[i].Semantic==4) //Normal - { - for (u32 j=0; jVertices[k].Normal.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1],geom.Buffers[j].Data[ePos+2]); - ePos += eSize; - } - } - } - } - - if (geom.Elements[i].Semantic==7) //TexCoord - { - for (u32 j=0; jVertices[k].TCoords.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1]); - ePos += eSize; - } - } - } - } - } - return mb; -} - - - -scene::SMeshBufferLightMap* COgreMeshFileLoader::composeMeshBufferLightMap(const core::array& indices, const OgreGeometry& geom) -{ - scene::SMeshBufferLightMap *mb=new scene::SMeshBufferLightMap(); - - u32 i; - mb->Indices.set_used(indices.size()); - for (i=0; iIndices[i]=indices[i]; - - mb->Vertices.set_used(geom.NumVertex); - - for (i=0; iVertices[k].Color=mb->Material.DiffuseColor; - mb->Vertices[k].Pos.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1],geom.Buffers[j].Data[ePos+2]); - ePos += eSize; - } - } - } - } - - if (geom.Elements[i].Semantic==4) //Normal - { - for (u32 j=0; jVertices[k].Normal.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1],geom.Buffers[j].Data[ePos+2]); - ePos += eSize; - } - } - } - } - - if (geom.Elements[i].Semantic==7) //TexCoord - { - for (u32 j=0; jVertices[k].TCoords.set( geom.Buffers[j].Data[ePos] ,geom.Buffers[j].Data[ePos+1]); - mb->Vertices[k].TCoords2.set(geom.Buffers[j].Data[ePos+2],geom.Buffers[j].Data[ePos+3]); - - ePos += eSize; - } - } - } - } - } - - return mb; -} - - - -void COgreMeshFileLoader::composeObject(void) -{ - for (u32 i=0; iaddMeshBuffer(mb); - mb->drop(); - } - } - } -} - - -core::stringc COgreMeshFileLoader::getTextureFileName(const core::stringc& texture, - core::stringc& model) -{ - s32 idx = -1; - idx = model.findLast('/'); - - if (idx == -1) - idx = model.findLast('\\'); - - if (idx == -1) - return core::stringc(); - - core::stringc p = model.subString(0, idx+1); - p.append(texture); - return p; -} - - -void COgreMeshFileLoader::getMaterialToken(io::IReadFile* file, core::stringc& token, bool noNewLine) -{ - c8 c=0; - token = ""; - - file->read(&c, sizeof(c8)); - while ( core::isspace(c) && (file->getPos() < file->getSize())) - { - if (noNewLine && c=='\n') - { - file->seek(-1, true); - return; - } - file->read(&c, sizeof(c8)); - } - do - { - if (c=='/') - { - file->read(&c, sizeof(c8)); - if (c=='/') - { // skip comments - while(c!='\n') - file->read(&c, sizeof(c8)); - } - else - { - token.append('/'); - if (core::isspace(c)) - return; - } - } - token.append(c); - file->read(&c, sizeof(c8)); - } - while ((!core::isspace(c)) && (file->getPos() < file->getSize())); - if (c == '\n' && noNewLine) - file->seek(-1, true); -} - - - -bool COgreMeshFileLoader::readColor(io::IReadFile* file, video::SColor& col) -{ - core::stringc token; - - getMaterialToken(file, token); - if (token!="vertexcolour") - { - video::SColorf col_f; - col_f.r=core::fast_atof(token.c_str()); - getMaterialToken(file, token); - col_f.g=core::fast_atof(token.c_str()); - getMaterialToken(file, token); - col_f.b=core::fast_atof(token.c_str()); - getMaterialToken(file, token, true); - if (token.size()) - col_f.a=core::fast_atof(token.c_str()); - else - col_f.a=1.0f; - if ((col_f.r==0.0f)&&(col_f.g==0.0f)&&(col_f.b==0.0f)) - col.set(255,255,255,255); - else - col=col_f.toSColor(); - return false; - } - return true; -} - - -void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique) -{ - core::stringc token; - technique.Passes.push_back(OgrePass()); - OgrePass& pass=technique.Passes.getLast(); - - getMaterialToken(file, token); //open brace or name - if (token != "{") - getMaterialToken(file, token); //open brace - - getMaterialToken(file, token); - u32 inBlocks=1; - while(inBlocks) - { - if (token=="ambient") - pass.AmbientTokenColor=readColor(file, pass.Material.AmbientColor); - else if (token=="diffuse") - pass.DiffuseTokenColor=readColor(file, pass.Material.AmbientColor); - else if (token=="specular") - { - pass.SpecularTokenColor=readColor(file, pass.Material.AmbientColor); - getMaterialToken(file, token); - pass.Material.Shininess=core::fast_atof(token.c_str()); - } - else if (token=="emissive") - pass.EmissiveTokenColor=readColor(file, pass.Material.AmbientColor); - else if (token=="scene_blend") - { // TODO: Choose correct values - getMaterialToken(file, token); - if (token=="add") - pass.Material.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR; - else if (token=="modulate") - pass.Material.MaterialType=video::EMT_SOLID; - else if (token=="alpha_blend") - pass.Material.MaterialType=video::EMT_TRANSPARENT_ALPHA_CHANNEL; - else if (token=="colour_blend") - pass.Material.MaterialType=video::EMT_TRANSPARENT_VERTEX_ALPHA; - else - getMaterialToken(file, token); - } - else if (token=="depth_check") - { - getMaterialToken(file, token); - pass.Material.ZBuffer=(token=="on"); - } - else if (token=="depth_write") - { - getMaterialToken(file, token); - pass.Material.ZWriteEnable=(token=="on"); - } - else if (token=="depth_func") - { - getMaterialToken(file, token); // Function name - } - else if (token=="depth_bias") - { - getMaterialToken(file, token); // bias value - } - else if (token=="alpha_rejection") - { - getMaterialToken(file, token); // function name - getMaterialToken(file, token); // value - } - else if (token=="cull_hardware") - { - getMaterialToken(file, token); // rotation name - } - else if (token=="cull_software") - { - getMaterialToken(file, token); // culling side - } - else if (token=="lighting") - { - getMaterialToken(file, token); - pass.Material.Lighting=(token=="on"); - } - else if (token=="shading") - { - getMaterialToken(file, token); - // We take phong as gouraud - pass.Material.GouraudShading=(token!="flat"); - } - else if (token=="polygon_mode") - { - getMaterialToken(file, token); - // We take points as wireframe - pass.Material.Wireframe=(token!="solid"); - } - else if (token=="colour_write") - { - getMaterialToken(file, token); - pass.ColorWrite=(token=="on"); - } - else if (token=="max_lights") - { - getMaterialToken(file, token); - pass.MaxLights=strtol(token.c_str(),NULL,10); - } - else if (token=="point_size") - { - getMaterialToken(file, token); - pass.PointSize=core::fast_atof(token.c_str()); - } - else if (token=="point_sprites") - { - getMaterialToken(file, token); - pass.PointSprites=(token=="on"); - } - else if (token=="point_size_min") - { - getMaterialToken(file, token); - pass.PointSizeMin=strtol(token.c_str(),NULL,10); - } - else if (token=="point_size_max") - { - getMaterialToken(file, token); - pass.PointSizeMax=strtol(token.c_str(),NULL,10); - } - else if (token=="texture_unit") - { - getMaterialToken(file, token); //open brace - getMaterialToken(file, token); - while(token != "}") - { - if (token=="texture") - { - getMaterialToken(file, pass.Texture.Filename); - getMaterialToken(file, pass.Texture.CoordsType, true); - getMaterialToken(file, pass.Texture.MipMaps, true); - getMaterialToken(file, pass.Texture.Alpha, true); - } - else if (token=="texture_alias") - getMaterialToken(file, pass.Texture.Alias); - else if (token=="colour_op") - { // TODO: Choose correct values - getMaterialToken(file, token); - if (token=="add") - pass.Material.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR; - else if (token=="modulate") - pass.Material.MaterialType=video::EMT_SOLID; - else if (token=="alpha_blend") - pass.Material.MaterialType=video::EMT_TRANSPARENT_ALPHA_CHANNEL; - else if (token=="colour_blend") - pass.Material.MaterialType=video::EMT_TRANSPARENT_VERTEX_ALPHA; - else - getMaterialToken(file, token); - } - getMaterialToken(file, token); - } - } - //fog_override, iteration, point_size_attenuation - //not considered yet! - getMaterialToken(file, token); - if (token=="{") - ++inBlocks; - else if (token=="}") - --inBlocks; - } -} - - - -void COgreMeshFileLoader::readTechnique(io::IReadFile* file, OgreMaterial& mat) -{ - core::stringc token; - mat.Techniques.push_back(OgreTechnique()); - OgreTechnique& technique=mat.Techniques.getLast(); - - getMaterialToken(file, technique.Name); //open brace or name - if (technique.Name != "{") - getMaterialToken(file, token); //open brace - else - technique.Name=core::stringc((int)mat.Techniques.size()); - - getMaterialToken(file, token); - while (token != "}") - { - if (token == "pass") - readPass(file, technique); - else if (token == "scheme") - getMaterialToken(file, token); - else if (token == "lod_index") - getMaterialToken(file, token); - getMaterialToken(file, token); - } -} - - - -void COgreMeshFileLoader::loadMaterials(io::IReadFile* meshFile) -{ - core::stringc token,filename=meshFile->getFileName(); - core::stringc material = filename.subString(0, filename.size()-4) + "material"; - io::IReadFile* file = FileSystem->createAndOpenFile(material.c_str()); - - if (!file) - { - os::Printer::log("Could not load OGRE material", material.c_str()); - return; - } - - getMaterialToken(file, token); - - while (file->getPos() < file->getSize()) - { - Materials.push_back(OgreMaterial()); - OgreMaterial& mat = Materials.getLast(); - - if (token != "material") - return; - getMaterialToken(file, mat.Name); - getMaterialToken(file, token); //open brace - getMaterialToken(file, token); - while(token != "}") - { - if (token=="lod_distances") // can have several items - getMaterialToken(file, token); - else if (token=="receive_shadows") - { - getMaterialToken(file, token); - mat.ReceiveShadows=(token=="on"); - } - else if (token=="transparency_casts_shadows") - { - getMaterialToken(file, token); - mat.TransparencyCastsShadows=(token=="on"); - } - else if (token=="set_texture_alias") - { - getMaterialToken(file, token); - getMaterialToken(file, token); - } - else if (token=="technique") - readTechnique(file, mat); - getMaterialToken(file, token); - } - getMaterialToken(file, token); - } - - file->drop(); -} - - - -void COgreMeshFileLoader::readChunkData(io::IReadFile* file, ChunkData& data) -{ - file->read(&data.header, sizeof(ChunkHeader)); - if (SwapEndian) - { - data.header.id = os::Byteswap::byteswap(data.header.id); - data.header.length = os::Byteswap::byteswap(data.header.length); - } - data.read += sizeof(ChunkHeader); -} - - -void COgreMeshFileLoader::readString(io::IReadFile* file, ChunkData& data, core::stringc& out) -{ - c8 c = 0; - out = ""; - - while (c!='\n') - { - file->read(&c, sizeof(c8)); - if (c!='\n') - out.append(c); - - } - data.read+=out.size()+1; -} - - -void COgreMeshFileLoader::readBool(io::IReadFile* file, ChunkData& data, bool& out) -{ - // normal C type because we read a bit string - char c = 0; - file->read(&c, sizeof(char)); - out=(c!=0); - ++data.read; -} - - -void COgreMeshFileLoader::readInt(io::IReadFile* file, ChunkData& data, s32& out) -{ - // normal C type because we read a bit string - int tmp; - file->read(&tmp, sizeof(int)); - if (SwapEndian) - { - tmp = os::Byteswap::byteswap(tmp); - } - out=tmp; - data.read+=sizeof(int); -} - - -void COgreMeshFileLoader::readShort(io::IReadFile* file, ChunkData& data, u16& out) -{ - // normal C type because we read a bit string - short tmp; - file->read(&tmp, sizeof(short)); - if (SwapEndian) - { - tmp = os::Byteswap::byteswap(tmp); - } - out=tmp; - data.read+=sizeof(short); -} - - -void COgreMeshFileLoader::readFloat(io::IReadFile* file, ChunkData& data, f32& out) -{ - // normal C type because we read a bit string - float tmp; - file->read(&tmp, sizeof(float)); - if (SwapEndian) - { - tmp = os::Byteswap::byteswap(tmp); - } - out=tmp; - data.read+=sizeof(float); -} - - -void COgreMeshFileLoader::readVector(io::IReadFile* file, ChunkData& data, core::vector3df& out) -{ - readFloat(file, data, out.X); - readFloat(file, data, out.Y); - readFloat(file, data, out.Z); -} - -void COgreMeshFileLoader::setCurrentlyLoadingPath(io::IReadFile* file) -{ - CurrentlyLoadingFromPath = file->getFileName(); - int idx = CurrentlyLoadingFromPath.findLast('/'); - - if (idx != -1) - { - CurrentlyLoadingFromPath = CurrentlyLoadingFromPath.subString(0, idx); - } - else - { - idx = CurrentlyLoadingFromPath.findLast('\\'); - - if (idx != -1) - CurrentlyLoadingFromPath = CurrentlyLoadingFromPath.subString(0, idx); - } -} - -void COgreMeshFileLoader::clearMeshes() -{ - for (u32 i=0; igrab(); + + if (Driver) + Driver->grab(); +} + + + +//! destructor +COgreMeshFileLoader::~COgreMeshFileLoader() +{ + clearMeshes(); + + if (FileSystem) + FileSystem->drop(); + + if (Driver) + Driver->drop(); + + if (Mesh) + Mesh->drop(); +} + + + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".bsp") +bool COgreMeshFileLoader::isALoadableFileExtension(const c8* filename) +{ + return strstr(filename, ".mesh")!=0; +} + + + +//! creates/loads an animated mesh from the file. +//! \return Pointer to the created mesh. Returns 0 if loading failed. +//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). +//! See IUnknown::drop() for more information. +IAnimatedMesh* COgreMeshFileLoader::createMesh(io::IReadFile* file) +{ + s16 id; + + file->read(&id, 2); + + if (id == COGRE_HEADER) + SwapEndian=false; + else if (id == 0x0010) + SwapEndian=true; + else + return false; + ChunkData data; + readString(file, data, Version); + if (Version != "[MeshSerializer_v1.30]") + return false; + + clearMeshes(); + if (Mesh) + Mesh->drop(); + + Mesh = new SMesh(); + setCurrentlyLoadingPath(file); + loadMaterials(file); + + if (readChunk(file)) + { + // success + SAnimatedMesh* am = new SAnimatedMesh(); + am->Type = EAMT_3DS; + + for (u32 i=0; igetMeshBufferCount(); ++i) + ((SMeshBuffer*)Mesh->getMeshBuffer(i))->recalculateBoundingBox(); + + Mesh->recalculateBoundingBox(); + + am->addMesh(Mesh); + am->recalculateBoundingBox(); + Mesh->drop(); + Mesh = 0; + return am; + } + + Mesh->drop(); + Mesh = 0; + + return 0; +} + + +bool COgreMeshFileLoader::readChunk(io::IReadFile* file) +{ + while(file->getPos() < file->getSize()) + { + ChunkData data; + readChunkData(file, data); + + switch(data.header.id) + { + case COGRE_MESH: + { + Meshes.push_back(OgreMesh()); + readObjectChunk(file, data, Meshes.getLast()); + composeObject(); + } + break; + default: + return true; + } + } + + return true; +} + + +bool COgreMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData& parent, OgreMesh& mesh) +{ + readBool(file, parent, mesh.SkeletalAnimation); + while ((parent.read < parent.header.length)&&(file->getPos() < file->getSize())) + { + ChunkData data; + readChunkData(file, data); + + switch(data.header.id) + { + case COGRE_GEOMETRY: + { + readGeometry(file, data, mesh.Geometry); + } + break; + case COGRE_SUBMESH: + mesh.SubMeshes.push_back(OgreSubMesh()); + readSubMesh(file, data, mesh.SubMeshes.getLast()); + break; + case COGRE_MESH_BOUNDS: + { + readVector(file, data, mesh.BBoxMinEdge); + readVector(file, data, mesh.BBoxMaxEdge); + readFloat(file, data, mesh.BBoxRadius); + } + break; + case COGRE_SKELETON_LINK: + case COGRE_BONE_ASSIGNMENT: + case COGRE_MESH_LOD: + case COGRE_MESH_SUBMESH_NAME_TABLE: + case COGRE_MESH_EDGE_LISTS: + // ignore chunk + file->seek(data.header.length-data.read, true); + data.read += data.header.length-data.read; + break; + default: + parent.read=parent.header.length; + file->seek(-(int)sizeof(ChunkHeader), true); + return true; + } + parent.read += data.read; + } + return true; +} + + +bool COgreMeshFileLoader::readGeometry(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry) +{ + readInt(file, parent, geometry.NumVertex); + while(parent.read < parent.header.length) + { + ChunkData data; + readChunkData(file, data); + + switch(data.header.id) + { + case COGRE_GEOMETRY_VERTEX_DECLARATION: + readVertexDeclaration(file, data, geometry); + break; + case COGRE_GEOMETRY_VERTEX_BUFFER: + readVertexBuffer(file, data, geometry); + break; + default: + // ignore chunk + file->seek(data.header.length-data.read, true); + data.read += data.header.length-data.read; + } + parent.read += data.read; + } + return true; +} + + +bool COgreMeshFileLoader::readVertexDeclaration(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry) +{ + NumUV = 0; + while(parent.read < parent.header.length) + { + ChunkData data; + readChunkData(file, data); + + switch(data.header.id) + { + case COGRE_GEOMETRY_VERTEX_ELEMENT: + { + OgreVertexElement elem; + readShort(file, data, elem.Source); + readShort(file, data, elem.Type); + readShort(file, data, elem.Semantic); + if (elem.Semantic == 7) //Tex coords + { + ++NumUV; + } + readShort(file, data, elem.Offset); + elem.Offset /= sizeof(f32); + readShort(file, data, elem.Index); + geometry.Elements.push_back(elem); + } + break; + default: + // ignore chunk + file->seek(data.header.length-data.read, true); + data.read += data.header.length-data.read; + } + parent.read += data.read; + } + return true; +} + + +bool COgreMeshFileLoader::readVertexBuffer(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry) +{ + OgreVertexBuffer buf; + readShort(file, parent, buf.BindIndex); + readShort(file, parent, buf.VertexSize); + buf.VertexSize /= sizeof(f32); + ChunkData data; + readChunkData(file, data); + + if (data.header.id == COGRE_GEOMETRY_VERTEX_BUFFER_DATA) + { + buf.Data = new f32[geometry.NumVertex*buf.VertexSize]; + for (s32 i=0; iseek(data.header.length-data.read, true); + data.read += data.header.length-data.read; + break; + default: + parent.read=parent.header.length; + file->seek(-(int)sizeof(ChunkHeader), true); + return true; + } + parent.read += data.read; + } + return true; +} + + + +void COgreMeshFileLoader::composeMeshBufferMaterial(scene::IMeshBuffer* mb, const core::stringc& materialName) +{ + video::SMaterial& material=mb->getMaterial(); + for (u32 k=0; kgetTexture(Materials[k].Techniques[0].Passes[0].Texture.Filename.c_str()); + if (!material.Textures[0]) + { + // retry with relative path + core::stringc relative = CurrentlyLoadingFromPath; + relative += '/'; + relative += Materials[k].Techniques[0].Passes[0].Texture.Filename; + material.Textures[0] = Driver->getTexture(relative.c_str()); + } + } + break; + } + } +} + + + +scene::SMeshBuffer* COgreMeshFileLoader::composeMeshBuffer(const core::array& indices, const OgreGeometry& geom) +{ + scene::SMeshBuffer *mb=new scene::SMeshBuffer(); + + u32 i; + mb->Indices.set_used(indices.size()); + for (i=0; iIndices[i]=indices[i]; + + mb->Vertices.set_used(geom.NumVertex); + for (i=0; iVertices[k].Color=mb->Material.DiffuseColor; + mb->Vertices[k].Pos.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1],geom.Buffers[j].Data[ePos+2]); + ePos += eSize; + } + } + } + } + + if (geom.Elements[i].Semantic==4) //Normal + { + for (u32 j=0; jVertices[k].Normal.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1],geom.Buffers[j].Data[ePos+2]); + ePos += eSize; + } + } + } + } + + if (geom.Elements[i].Semantic==7) //TexCoord + { + for (u32 j=0; jVertices[k].TCoords.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1]); + ePos += eSize; + } + } + } + } + } + return mb; +} + + + +scene::SMeshBufferLightMap* COgreMeshFileLoader::composeMeshBufferLightMap(const core::array& indices, const OgreGeometry& geom) +{ + scene::SMeshBufferLightMap *mb=new scene::SMeshBufferLightMap(); + + u32 i; + mb->Indices.set_used(indices.size()); + for (i=0; iIndices[i]=indices[i]; + + mb->Vertices.set_used(geom.NumVertex); + + for (i=0; iVertices[k].Color=mb->Material.DiffuseColor; + mb->Vertices[k].Pos.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1],geom.Buffers[j].Data[ePos+2]); + ePos += eSize; + } + } + } + } + + if (geom.Elements[i].Semantic==4) //Normal + { + for (u32 j=0; jVertices[k].Normal.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1],geom.Buffers[j].Data[ePos+2]); + ePos += eSize; + } + } + } + } + + if (geom.Elements[i].Semantic==7) //TexCoord + { + for (u32 j=0; jVertices[k].TCoords.set( geom.Buffers[j].Data[ePos] ,geom.Buffers[j].Data[ePos+1]); + mb->Vertices[k].TCoords2.set(geom.Buffers[j].Data[ePos+2],geom.Buffers[j].Data[ePos+3]); + + ePos += eSize; + } + } + } + } + } + + return mb; +} + + + +void COgreMeshFileLoader::composeObject(void) +{ + for (u32 i=0; iaddMeshBuffer(mb); + mb->drop(); + } + } + } +} + + +core::stringc COgreMeshFileLoader::getTextureFileName(const core::stringc& texture, + core::stringc& model) +{ + s32 idx = -1; + idx = model.findLast('/'); + + if (idx == -1) + idx = model.findLast('\\'); + + if (idx == -1) + return core::stringc(); + + core::stringc p = model.subString(0, idx+1); + p.append(texture); + return p; +} + + +void COgreMeshFileLoader::getMaterialToken(io::IReadFile* file, core::stringc& token, bool noNewLine) +{ + c8 c=0; + token = ""; + + file->read(&c, sizeof(c8)); + while ( core::isspace(c) && (file->getPos() < file->getSize())) + { + if (noNewLine && c=='\n') + { + file->seek(-1, true); + return; + } + file->read(&c, sizeof(c8)); + } + do + { + if (c=='/') + { + file->read(&c, sizeof(c8)); + if (c=='/') + { // skip comments + while(c!='\n') + file->read(&c, sizeof(c8)); + } + else + { + token.append('/'); + if (core::isspace(c)) + return; + } + } + token.append(c); + file->read(&c, sizeof(c8)); + } + while ((!core::isspace(c)) && (file->getPos() < file->getSize())); + if (c == '\n' && noNewLine) + file->seek(-1, true); +} + + + +bool COgreMeshFileLoader::readColor(io::IReadFile* file, video::SColor& col) +{ + core::stringc token; + + getMaterialToken(file, token); + if (token!="vertexcolour") + { + video::SColorf col_f; + col_f.r=core::fast_atof(token.c_str()); + getMaterialToken(file, token); + col_f.g=core::fast_atof(token.c_str()); + getMaterialToken(file, token); + col_f.b=core::fast_atof(token.c_str()); + getMaterialToken(file, token, true); + if (token.size()) + col_f.a=core::fast_atof(token.c_str()); + else + col_f.a=1.0f; + if ((col_f.r==0.0f)&&(col_f.g==0.0f)&&(col_f.b==0.0f)) + col.set(255,255,255,255); + else + col=col_f.toSColor(); + return false; + } + return true; +} + + +void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique) +{ + core::stringc token; + technique.Passes.push_back(OgrePass()); + OgrePass& pass=technique.Passes.getLast(); + + getMaterialToken(file, token); //open brace or name + if (token != "{") + getMaterialToken(file, token); //open brace + + getMaterialToken(file, token); + u32 inBlocks=1; + while(inBlocks) + { + if (token=="ambient") + pass.AmbientTokenColor=readColor(file, pass.Material.AmbientColor); + else if (token=="diffuse") + pass.DiffuseTokenColor=readColor(file, pass.Material.AmbientColor); + else if (token=="specular") + { + pass.SpecularTokenColor=readColor(file, pass.Material.AmbientColor); + getMaterialToken(file, token); + pass.Material.Shininess=core::fast_atof(token.c_str()); + } + else if (token=="emissive") + pass.EmissiveTokenColor=readColor(file, pass.Material.AmbientColor); + else if (token=="scene_blend") + { // TODO: Choose correct values + getMaterialToken(file, token); + if (token=="add") + pass.Material.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR; + else if (token=="modulate") + pass.Material.MaterialType=video::EMT_SOLID; + else if (token=="alpha_blend") + pass.Material.MaterialType=video::EMT_TRANSPARENT_ALPHA_CHANNEL; + else if (token=="colour_blend") + pass.Material.MaterialType=video::EMT_TRANSPARENT_VERTEX_ALPHA; + else + getMaterialToken(file, token); + } + else if (token=="depth_check") + { + getMaterialToken(file, token); + pass.Material.ZBuffer=(token=="on"); + } + else if (token=="depth_write") + { + getMaterialToken(file, token); + pass.Material.ZWriteEnable=(token=="on"); + } + else if (token=="depth_func") + { + getMaterialToken(file, token); // Function name + } + else if (token=="depth_bias") + { + getMaterialToken(file, token); // bias value + } + else if (token=="alpha_rejection") + { + getMaterialToken(file, token); // function name + getMaterialToken(file, token); // value + } + else if (token=="cull_hardware") + { + getMaterialToken(file, token); // rotation name + } + else if (token=="cull_software") + { + getMaterialToken(file, token); // culling side + } + else if (token=="lighting") + { + getMaterialToken(file, token); + pass.Material.Lighting=(token=="on"); + } + else if (token=="shading") + { + getMaterialToken(file, token); + // We take phong as gouraud + pass.Material.GouraudShading=(token!="flat"); + } + else if (token=="polygon_mode") + { + getMaterialToken(file, token); + // We take points as wireframe + pass.Material.Wireframe=(token!="solid"); + } + else if (token=="colour_write") + { + getMaterialToken(file, token); + pass.ColorWrite=(token=="on"); + } + else if (token=="max_lights") + { + getMaterialToken(file, token); + pass.MaxLights=strtol(token.c_str(),NULL,10); + } + else if (token=="point_size") + { + getMaterialToken(file, token); + pass.PointSize=core::fast_atof(token.c_str()); + } + else if (token=="point_sprites") + { + getMaterialToken(file, token); + pass.PointSprites=(token=="on"); + } + else if (token=="point_size_min") + { + getMaterialToken(file, token); + pass.PointSizeMin=strtol(token.c_str(),NULL,10); + } + else if (token=="point_size_max") + { + getMaterialToken(file, token); + pass.PointSizeMax=strtol(token.c_str(),NULL,10); + } + else if (token=="texture_unit") + { + getMaterialToken(file, token); //open brace + getMaterialToken(file, token); + while(token != "}") + { + if (token=="texture") + { + getMaterialToken(file, pass.Texture.Filename); + getMaterialToken(file, pass.Texture.CoordsType, true); + getMaterialToken(file, pass.Texture.MipMaps, true); + getMaterialToken(file, pass.Texture.Alpha, true); + } + else if (token=="texture_alias") + getMaterialToken(file, pass.Texture.Alias); + else if (token=="colour_op") + { // TODO: Choose correct values + getMaterialToken(file, token); + if (token=="add") + pass.Material.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR; + else if (token=="modulate") + pass.Material.MaterialType=video::EMT_SOLID; + else if (token=="alpha_blend") + pass.Material.MaterialType=video::EMT_TRANSPARENT_ALPHA_CHANNEL; + else if (token=="colour_blend") + pass.Material.MaterialType=video::EMT_TRANSPARENT_VERTEX_ALPHA; + else + getMaterialToken(file, token); + } + getMaterialToken(file, token); + } + } + //fog_override, iteration, point_size_attenuation + //not considered yet! + getMaterialToken(file, token); + if (token=="{") + ++inBlocks; + else if (token=="}") + --inBlocks; + } +} + + + +void COgreMeshFileLoader::readTechnique(io::IReadFile* file, OgreMaterial& mat) +{ + core::stringc token; + mat.Techniques.push_back(OgreTechnique()); + OgreTechnique& technique=mat.Techniques.getLast(); + + getMaterialToken(file, technique.Name); //open brace or name + if (technique.Name != "{") + getMaterialToken(file, token); //open brace + else + technique.Name=core::stringc((int)mat.Techniques.size()); + + getMaterialToken(file, token); + while (token != "}") + { + if (token == "pass") + readPass(file, technique); + else if (token == "scheme") + getMaterialToken(file, token); + else if (token == "lod_index") + getMaterialToken(file, token); + getMaterialToken(file, token); + } +} + + + +void COgreMeshFileLoader::loadMaterials(io::IReadFile* meshFile) +{ + core::stringc token,filename=meshFile->getFileName(); + core::stringc material = filename.subString(0, filename.size()-4) + "material"; + io::IReadFile* file = FileSystem->createAndOpenFile(material.c_str()); + + if (!file) + { + os::Printer::log("Could not load OGRE material", material.c_str()); + return; + } + + getMaterialToken(file, token); + + while (file->getPos() < file->getSize()) + { + Materials.push_back(OgreMaterial()); + OgreMaterial& mat = Materials.getLast(); + + if (token != "material") + return; + getMaterialToken(file, mat.Name); + getMaterialToken(file, token); //open brace + getMaterialToken(file, token); + while(token != "}") + { + if (token=="lod_distances") // can have several items + getMaterialToken(file, token); + else if (token=="receive_shadows") + { + getMaterialToken(file, token); + mat.ReceiveShadows=(token=="on"); + } + else if (token=="transparency_casts_shadows") + { + getMaterialToken(file, token); + mat.TransparencyCastsShadows=(token=="on"); + } + else if (token=="set_texture_alias") + { + getMaterialToken(file, token); + getMaterialToken(file, token); + } + else if (token=="technique") + readTechnique(file, mat); + getMaterialToken(file, token); + } + getMaterialToken(file, token); + } + + file->drop(); +} + + + +void COgreMeshFileLoader::readChunkData(io::IReadFile* file, ChunkData& data) +{ + file->read(&data.header, sizeof(ChunkHeader)); + if (SwapEndian) + { + data.header.id = os::Byteswap::byteswap(data.header.id); + data.header.length = os::Byteswap::byteswap(data.header.length); + } + data.read += sizeof(ChunkHeader); +} + + +void COgreMeshFileLoader::readString(io::IReadFile* file, ChunkData& data, core::stringc& out) +{ + c8 c = 0; + out = ""; + + while (c!='\n') + { + file->read(&c, sizeof(c8)); + if (c!='\n') + out.append(c); + + } + data.read+=out.size()+1; +} + + +void COgreMeshFileLoader::readBool(io::IReadFile* file, ChunkData& data, bool& out) +{ + // normal C type because we read a bit string + char c = 0; + file->read(&c, sizeof(char)); + out=(c!=0); + ++data.read; +} + + +void COgreMeshFileLoader::readInt(io::IReadFile* file, ChunkData& data, s32& out) +{ + // normal C type because we read a bit string + int tmp; + file->read(&tmp, sizeof(int)); + if (SwapEndian) + { + tmp = os::Byteswap::byteswap(tmp); + } + out=tmp; + data.read+=sizeof(int); +} + + +void COgreMeshFileLoader::readShort(io::IReadFile* file, ChunkData& data, u16& out) +{ + // normal C type because we read a bit string + short tmp; + file->read(&tmp, sizeof(short)); + if (SwapEndian) + { + tmp = os::Byteswap::byteswap(tmp); + } + out=tmp; + data.read+=sizeof(short); +} + + +void COgreMeshFileLoader::readFloat(io::IReadFile* file, ChunkData& data, f32& out) +{ + // normal C type because we read a bit string + float tmp; + file->read(&tmp, sizeof(float)); + if (SwapEndian) + { + tmp = os::Byteswap::byteswap(tmp); + } + out=tmp; + data.read+=sizeof(float); +} + + +void COgreMeshFileLoader::readVector(io::IReadFile* file, ChunkData& data, core::vector3df& out) +{ + readFloat(file, data, out.X); + readFloat(file, data, out.Y); + readFloat(file, data, out.Z); +} + +void COgreMeshFileLoader::setCurrentlyLoadingPath(io::IReadFile* file) +{ + CurrentlyLoadingFromPath = file->getFileName(); + int idx = CurrentlyLoadingFromPath.findLast('/'); + + if (idx != -1) + { + CurrentlyLoadingFromPath = CurrentlyLoadingFromPath.subString(0, idx); + } + else + { + idx = CurrentlyLoadingFromPath.findLast('\\'); + + if (idx != -1) + CurrentlyLoadingFromPath = CurrentlyLoadingFromPath.subString(0, idx); + } +} + +void COgreMeshFileLoader::clearMeshes() +{ + for (u32 i=0; i Passes; - }; - - struct OgreMaterial - { - OgreMaterial() : Name(""), ReceiveShadows(true), - TransparencyCastsShadows(false) {} - - core::stringc Name; - bool ReceiveShadows; - bool TransparencyCastsShadows; - core::array LODDistances; - core::array Techniques; - }; - - struct OgreVertexBuffer - { - OgreVertexBuffer() : BindIndex(0), VertexSize(0), Data(0) {} - void destroy() { delete [] Data; Data = 0; }; - - u16 BindIndex, - VertexSize; - f32 *Data; - }; - - struct OgreVertexElement - { - u16 Source, - Type, - Semantic, - Offset, - Index; - }; - - struct OgreGeometry - { - s32 NumVertex; - core::array Elements; - core::array Buffers; - core::array Vertices; - core::array Normals; - core::array Colors; - core::array TexCoords; - }; - - struct OgreTextureAlias - { - OgreTextureAlias() {}; - OgreTextureAlias(const core::stringc& a, const core::stringc& b) : Texture(a), Alias(b) {}; - core::stringc Texture; - core::stringc Alias; - }; - - struct OgreSubMesh - { - core::stringc Material; - bool SharedVertices; - core::array Indices; - OgreGeometry Geometry; - u16 Operation; - core::array TextureAliases; - bool Indices32Bit; - }; - - struct OgreMesh - { - bool SkeletalAnimation; - OgreGeometry Geometry; - core::array SubMeshes; - core::vector3df BBoxMinEdge; - core::vector3df BBoxMaxEdge; - f32 BBoxRadius; - }; - - bool readChunk(io::IReadFile* file); - bool readObjectChunk(io::IReadFile* file, ChunkData& parent, OgreMesh& mesh); - bool readGeometry(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); - bool readVertexDeclaration(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); - bool readVertexBuffer(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); - bool readSubMesh(io::IReadFile* file, ChunkData& parent, OgreSubMesh& subMesh); - - void readChunkData(io::IReadFile* file, ChunkData& data); - void readString(io::IReadFile* file, ChunkData& data, core::stringc& out); - void readBool(io::IReadFile* file, ChunkData& data, bool& out); - void readInt(io::IReadFile* file, ChunkData& data, s32& out); - void readShort(io::IReadFile* file, ChunkData& data, u16& out); - void readFloat(io::IReadFile* file, ChunkData& data, f32& out); - void readVector(io::IReadFile* file, ChunkData& data, core::vector3df& out); - - void composeMeshBufferMaterial(scene::IMeshBuffer* mb, const core::stringc& materialName); - scene::SMeshBuffer* composeMeshBuffer(const core::array& indices, const OgreGeometry& geom); - scene::SMeshBufferLightMap* composeMeshBufferLightMap(const core::array& indices, const OgreGeometry& geom); - void composeObject(void); - bool readColor(io::IReadFile* meshFile, video::SColor& col); - void getMaterialToken(io::IReadFile* file, core::stringc& token, bool noNewLine=false); - void readTechnique(io::IReadFile* meshFile, OgreMaterial& mat); - void readPass(io::IReadFile* file, OgreTechnique& technique); - void loadMaterials(io::IReadFile* file); - core::stringc getTextureFileName(const core::stringc& texture, core::stringc& model); - void setCurrentlyLoadingPath(io::IReadFile* file); - void clearMeshes(); - - io::IFileSystem* FileSystem; - video::IVideoDriver* Driver; - - core::stringc Version; - bool SwapEndian; - core::array Meshes; - core::stringc CurrentlyLoadingFromPath; - - core::array Materials; - - SMesh* Mesh; - IMeshManipulator* Manipulator; - u32 NumUV; -}; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// orginally written by Christian Stehno, modified by Nikolaus Gebhardt + +#ifndef __C_OGRE_MESH_FILE_LOADER_H_INCLUDED__ +#define __C_OGRE_MESH_FILE_LOADER_H_INCLUDED__ + +#include "IMeshLoader.h" +#include "IFileSystem.h" +#include "IVideoDriver.h" +#include "irrString.h" +#include "SMesh.h" +#include "SMeshBuffer.h" +#include "SMeshBufferLightMap.h" +#include "IMeshManipulator.h" +#include "matrix4.h" + +namespace irr +{ +namespace scene +{ + +//! Meshloader capable of loading ogre meshes. +class COgreMeshFileLoader : public IMeshLoader +{ +public: + + //! Constructor + COgreMeshFileLoader(IMeshManipulator* manip,io::IFileSystem* fs, video::IVideoDriver* driver); + + //! destructor + virtual ~COgreMeshFileLoader(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".cob") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! creates/loads an animated mesh from the file. + //! \return Pointer to the created mesh. Returns 0 if loading failed. + //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). + //! See IUnknown::drop() for more information. + virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); + +private: + + // byte-align structures + #ifdef _MSC_VER + # pragma pack( push, packing ) + # pragma pack( 1 ) + # define PACK_STRUCT + #elif defined( __GNUC__ ) + # define PACK_STRUCT __attribute__((packed)) + #else + # error compiler not supported + #endif + + struct ChunkHeader + { + u16 id; + u32 length; + } PACK_STRUCT; + + // Default alignment + #ifdef _MSC_VER + # pragma pack( pop, packing ) + #endif + + #undef PACK_STRUCT + + + struct ChunkData + { + ChunkData() : read(0) {} + + ChunkHeader header; + u32 read; + }; + + struct OgreTexture + { + OgreTexture() : Filename("") {} + + core::stringc Filename; + core::stringc Alias; + core::stringc CoordsType; + core::stringc MipMaps; + core::stringc Alpha; + }; + + struct OgrePass + { + OgrePass() : AmbientTokenColor(false), + DiffuseTokenColor(false), SpecularTokenColor(false), + EmissiveTokenColor(false), ColorWrite(true), + MaxLights(8), PointSize(1.0f), PointSprites(false), + PointSizeMin(0), PointSizeMax(0) {} + + video::SMaterial Material; + OgreTexture Texture; + bool AmbientTokenColor; + bool DiffuseTokenColor; + bool SpecularTokenColor; + bool EmissiveTokenColor; + bool ColorWrite; + u32 MaxLights; + f32 PointSize; + bool PointSprites; + u32 PointSizeMin; + u32 PointSizeMax; + }; + + struct OgreTechnique + { + OgreTechnique() : Name(""), LODIndex(0) {} + + core::stringc Name; + core::stringc Scheme; + u16 LODIndex; + core::array Passes; + }; + + struct OgreMaterial + { + OgreMaterial() : Name(""), ReceiveShadows(true), + TransparencyCastsShadows(false) {} + + core::stringc Name; + bool ReceiveShadows; + bool TransparencyCastsShadows; + core::array LODDistances; + core::array Techniques; + }; + + struct OgreVertexBuffer + { + OgreVertexBuffer() : BindIndex(0), VertexSize(0), Data(0) {} + void destroy() { delete [] Data; Data = 0; }; + + u16 BindIndex, + VertexSize; + f32 *Data; + }; + + struct OgreVertexElement + { + u16 Source, + Type, + Semantic, + Offset, + Index; + }; + + struct OgreGeometry + { + s32 NumVertex; + core::array Elements; + core::array Buffers; + core::array Vertices; + core::array Normals; + core::array Colors; + core::array TexCoords; + }; + + struct OgreTextureAlias + { + OgreTextureAlias() {}; + OgreTextureAlias(const core::stringc& a, const core::stringc& b) : Texture(a), Alias(b) {}; + core::stringc Texture; + core::stringc Alias; + }; + + struct OgreSubMesh + { + core::stringc Material; + bool SharedVertices; + core::array Indices; + OgreGeometry Geometry; + u16 Operation; + core::array TextureAliases; + bool Indices32Bit; + }; + + struct OgreMesh + { + bool SkeletalAnimation; + OgreGeometry Geometry; + core::array SubMeshes; + core::vector3df BBoxMinEdge; + core::vector3df BBoxMaxEdge; + f32 BBoxRadius; + }; + + bool readChunk(io::IReadFile* file); + bool readObjectChunk(io::IReadFile* file, ChunkData& parent, OgreMesh& mesh); + bool readGeometry(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); + bool readVertexDeclaration(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); + bool readVertexBuffer(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); + bool readSubMesh(io::IReadFile* file, ChunkData& parent, OgreSubMesh& subMesh); + + void readChunkData(io::IReadFile* file, ChunkData& data); + void readString(io::IReadFile* file, ChunkData& data, core::stringc& out); + void readBool(io::IReadFile* file, ChunkData& data, bool& out); + void readInt(io::IReadFile* file, ChunkData& data, s32& out); + void readShort(io::IReadFile* file, ChunkData& data, u16& out); + void readFloat(io::IReadFile* file, ChunkData& data, f32& out); + void readVector(io::IReadFile* file, ChunkData& data, core::vector3df& out); + + void composeMeshBufferMaterial(scene::IMeshBuffer* mb, const core::stringc& materialName); + scene::SMeshBuffer* composeMeshBuffer(const core::array& indices, const OgreGeometry& geom); + scene::SMeshBufferLightMap* composeMeshBufferLightMap(const core::array& indices, const OgreGeometry& geom); + void composeObject(void); + bool readColor(io::IReadFile* meshFile, video::SColor& col); + void getMaterialToken(io::IReadFile* file, core::stringc& token, bool noNewLine=false); + void readTechnique(io::IReadFile* meshFile, OgreMaterial& mat); + void readPass(io::IReadFile* file, OgreTechnique& technique); + void loadMaterials(io::IReadFile* file); + core::stringc getTextureFileName(const core::stringc& texture, core::stringc& model); + void setCurrentlyLoadingPath(io::IReadFile* file); + void clearMeshes(); + + io::IFileSystem* FileSystem; + video::IVideoDriver* Driver; + + core::stringc Version; + bool SwapEndian; + core::array Meshes; + core::stringc CurrentlyLoadingFromPath; + + core::array Materials; + + SMesh* Mesh; + IMeshManipulator* Manipulator; + u32 NumUV; +}; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/COpenGLDriver.cpp b/src/dep/src/irrlicht/COpenGLDriver.cpp index 0a1eec5..582086a 100644 --- a/src/dep/src/irrlicht/COpenGLDriver.cpp +++ b/src/dep/src/irrlicht/COpenGLDriver.cpp @@ -1,3084 +1,3084 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "COpenGLDriver.h" - -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "COpenGLTexture.h" -#include "COpenGLMaterialRenderer.h" -#include "COpenGLShaderMaterialRenderer.h" -#include "COpenGLSLMaterialRenderer.h" -#include "COpenGLNormalMapRenderer.h" -#include "COpenGLParallaxMapRenderer.h" -#include "CImage.h" -#include "os.h" - -namespace irr -{ -namespace video -{ - -// ----------------------------------------------------------------------- -// WINDOWS CONSTRUCTOR -// ----------------------------------------------------------------------- -#ifdef _IRR_WINDOWS_ -//! Windows constructor and init code -COpenGLDriver::COpenGLDriver(const core::dimension2d& screenSize, HWND window, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool antiAlias) -: CNullDriver(io, screenSize), - CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), - StencilBuffer(stencilBuffer), AntiAlias(antiAlias), - MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false), - ARBVertexProgramExtension(false), ARBFragmentProgramExtension(false), - ARBShadingLanguage100Extension(false), SeparateStencilExtension(false), - GenerateMipmapExtension(false), TextureCompressionExtension(false), - TextureNPOTExtension(false), FramebufferObjectExtension(false), EXTPackedDepthStencil(false), - RenderTargetTexture(0), LastSetLight(-1), MaxAnisotropy(1), - MaxTextureUnits(1), MaxLights(1), CurrentRendertargetSize(0,0), -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - pGlActiveTextureARB(0), pGlClientActiveTextureARB(0), - pGlGenProgramsARB(0), pGlBindProgramARB(0), pGlProgramStringARB(0), - pGlDeleteProgramsARB(0), pGlProgramLocalParameter4fvARB(0), - pGlCreateShaderObjectARB(0), pGlShaderSourceARB(0), - pGlCompileShaderARB(0), pGlCreateProgramObjectARB(0), pGlAttachObjectARB(0), - pGlLinkProgramARB(0), pGlUseProgramObjectARB(0), pGlDeleteObjectARB(0), - pGlGetObjectParameterivARB(0), pGlGetUniformLocationARB(0), - pGlUniform1ivARB(0), pGlUniform1fvARB(0), pGlUniform2fvARB(0), pGlUniform3fvARB(0), pGlUniform4fvARB(0), pGlUniformMatrix2fvARB(0), - pGlUniformMatrix3fvARB(0), pGlUniformMatrix4fvARB(0), pGlGetActiveUniformARB(0), pGlPointParameterfARB(0), pGlPointParameterfvARB(0), - pGlStencilFuncSeparate(0), pGlStencilOpSeparate(0), - pGlStencilFuncSeparateATI(0), pGlStencilOpSeparateATI(0), - #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC - pGlCompressedTexImage2D(0), - #endif // PFNGLCOMPRESSEDTEXIMAGE2DPROC -#endif // _IRR_OPENGL_USE_EXTPOINTER_ - wglSwapIntervalEXT(0), - pGlBindFramebufferEXT(0), pGlDeleteFramebuffersEXT(0), pGlGenFramebuffersEXT(0), - pGlCheckFramebufferStatusEXT(0), pGlFramebufferTexture2DEXT(0), - pGlBindRenderbufferEXT(0), pGlDeleteRenderbuffersEXT(0), pGlGenRenderbuffersEXT(0), - pGlRenderbufferStorageEXT(0), pGlFramebufferRenderbufferEXT(0), - HDc(0), Window(window), HRc(0) -{ - #ifdef _DEBUG - setDebugName("COpenGLDriver"); - #endif -} - -//! inits the open gl driver -bool COpenGLDriver::initDriver(const core::dimension2d& screenSize, - HWND window, u32 bits, bool fullscreen, bool vsync) -{ - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor - 1, // Version Number - PFD_DRAW_TO_WINDOW | // Format Must Support Window - PFD_SUPPORT_OPENGL | // Format Must Support OpenGL - PFD_DOUBLEBUFFER, // Must Support Double Buffering - PFD_TYPE_RGBA, // Request An RGBA Format - bits, // Select Our Color Depth - 0, 0, 0, 0, 0, 0, // Color Bits Ignored - 0, // No Alpha Buffer - 0, // Shift Bit Ignored - 0, // No Accumulation Buffer - 0, 0, 0, 0, // Accumulation Bits Ignored - 24, // Z-Buffer (Depth Buffer) - StencilBuffer ? 1 : 0, // Stencil Buffer Depth - 0, // No Auxiliary Buffer - PFD_MAIN_PLANE, // Main Drawing Layer - 0, // Reserved - 0, 0, 0 // Layer Masks Ignored - }; - - for (int i=0; i<5; ++i) - { - if (i == 1) - { - if (StencilBuffer) - os::Printer::log("Cannot create a GL device with stencil buffer, disabling stencil shadows.", ELL_WARNING); - StencilBuffer = false; - pfd.cStencilBits = 0; - } - else - if (i == 2) - { - pfd.cDepthBits = 24; - } - if (i == 3) // might be checked twice, but shouldn't matter - { - pfd.cDepthBits = 16; - } - else - if (i == 4) - { - os::Printer::log("Cannot create a GL device context.", ELL_ERROR); - return false; - } - - // get hdc - if (!(HDc=GetDC(window))) - { - os::Printer::log("Cannot create a GL device context.", ELL_ERROR); - continue; - } - - GLuint PixelFormat; - - // choose pixelformat - if (!(PixelFormat = ChoosePixelFormat(HDc, &pfd))) - { - os::Printer::log("Cannot find a suitable pixelformat.", ELL_ERROR); - continue; - } - - // set pixel format - if(!SetPixelFormat(HDc, PixelFormat, &pfd)) - { - os::Printer::log("Cannot set the pixel format.", ELL_ERROR); - continue; - } - - // create rendering context - if (!(HRc=wglCreateContext(HDc))) - { - os::Printer::log("Cannot create a GL rendering context.", ELL_ERROR); - continue; - } - - // activate rendering context - if(!wglMakeCurrent(HDc, HRc)) - { - os::Printer::log("Cannot activate GL rendering context", ELL_ERROR); - continue; - } - - break; - } - - genericDriverInit(screenSize); - - // set vsync - if (wglSwapIntervalEXT) - wglSwapIntervalEXT(vsync ? 1 : 0); - - // set exposed data - ExposedData.OpenGLWin32.HDc = reinterpret_cast(HDc); - ExposedData.OpenGLWin32.HRc = reinterpret_cast(HRc); - ExposedData.OpenGLWin32.HWnd = reinterpret_cast(Window); - - return true; -} - - - -//! win32 destructor -COpenGLDriver::~COpenGLDriver() -{ - deleteMaterialRenders(); - - // I get a blue screen on my laptop, when I do not delete the - // textures manually before releasing the dc. Oh how I love this. - - deleteAllTextures(); - - if (HRc) - { - if (!wglMakeCurrent(0, 0)) - os::Printer::log("Release of dc and rc failed.", ELL_WARNING); - - if (!wglDeleteContext(HRc)) - os::Printer::log("Release of rendering context failed.", ELL_WARNING); - - HRc = 0; - } - - if (HDc) - ReleaseDC(Window, HDc); - - HDc = 0; -} -#endif //IRR_WINDOWS - -// ----------------------------------------------------------------------- -// MACOSX CONSTRUCTOR -// ----------------------------------------------------------------------- -#ifdef MACOSX -//! Windows constructor and init code -COpenGLDriver::COpenGLDriver(const core::dimension2d& screenSize, bool fullscreen, bool stencilBuffer, CIrrDeviceMacOSX *device, io::IFileSystem* io, bool vsync, bool antiAlias) -: CNullDriver(io, screenSize), - CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), - StencilBuffer(stencilBuffer), AntiAlias(antiAlias), - MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false), - ARBVertexProgramExtension(false), ARBFragmentProgramExtension(false), - ARBShadingLanguage100Extension(false), SeparateStencilExtension(false), - GenerateMipmapExtension(false), TextureCompressionExtension(false), - TextureNPOTExtension(false), FramebufferObjectExtension(false), EXTPackedDepthStencil(false), - RenderTargetTexture(0), LastSetLight(-1), MaxAnisotropy(1), - MaxTextureUnits(1), MaxLights(1), - CurrentRendertargetSize(0,0), _device(device) -{ - #ifdef _DEBUG - setDebugName("COpenGLDriver"); - #endif - genericDriverInit(screenSize); -} - -COpenGLDriver::~COpenGLDriver() -{ - deleteAllTextures(); -} - -#endif - -// ----------------------------------------------------------------------- -// LINUX CONSTRUCTOR -// ----------------------------------------------------------------------- -#ifdef LINUX -//! Linux constructor and init code -COpenGLDriver::COpenGLDriver(const core::dimension2d& screenSize, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias) -: CNullDriver(io, screenSize), - CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), - StencilBuffer(stencilBuffer), AntiAlias(antiAlias), - MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false), - ARBVertexProgramExtension(false), ARBFragmentProgramExtension(false), - ARBShadingLanguage100Extension(false), SeparateStencilExtension(false), - GenerateMipmapExtension(false), TextureCompressionExtension(false), - TextureNPOTExtension(false), FramebufferObjectExtension(false), EXTPackedDepthStencil(false), - RenderTargetTexture(0), LastSetLight(-1), MaxAnisotropy(1), - MaxTextureUnits(1), MaxLights(1), CurrentRendertargetSize(0,0) -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - ,pGlActiveTextureARB(0), pGlClientActiveTextureARB(0), - pGlGenProgramsARB(0), pGlBindProgramARB(0), pGlProgramStringARB(0), - pGlDeleteProgramsARB(0), pGlProgramLocalParameter4fvARB(0) - #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC - ,pGlCompressedTexImage2D(0) - #endif // PFNGLCOMPRESSEDTEXIMAGE2DPROC -#ifdef GLX_SGI_swap_control - ,glxSwapIntervalSGI(0) -#endif - ,pGlBindFramebufferEXT(0), pGlDeleteFramebuffersEXT(0), pGlGenFramebuffersEXT(0), - pGlCheckFramebufferStatusEXT(0), pGlFramebufferTexture2DEXT(0), - pGlBindRenderbufferEXT(0), pGlDeleteRenderbuffersEXT(0), pGlGenRenderbuffersEXT(0), - pGlRenderbufferStorageEXT(0), pGlFramebufferRenderbufferEXT(0) -#endif -{ - #ifdef _DEBUG - setDebugName("COpenGLDriver"); - #endif - XWindow = glXGetCurrentDrawable(); - XDisplay = glXGetCurrentDisplay(); - ExposedData.OpenGLLinux.Window = XWindow; - genericDriverInit(screenSize); - - // set vsync -#ifdef GLX_SGI_swap_control -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (vsync && glxSwapIntervalSGI) - glxSwapIntervalSGI(1); -#else - if (vsync) - glXSwapIntervalSGI(1); -#endif -#endif -} - -//! linux destructor -COpenGLDriver::~COpenGLDriver() -{ - deleteAllTextures(); -} - -#endif // LINUX - - - -// ----------------------------------------------------------------------- -// METHODS -// ----------------------------------------------------------------------- - -bool COpenGLDriver::genericDriverInit(const core::dimension2d& screenSize) -{ - Name=L"OpenGL "; - Name.append(glGetString(GL_VERSION)); - s32 pos=Name.findNext(L' ', 7); - if (pos != -1) - Name=Name.subString(0, pos); - printVersion(); - - // print renderer information - const GLubyte* renderer = glGetString(GL_RENDERER); - const GLubyte* vendor = glGetString(GL_VENDOR); - if (renderer && vendor) - { - os::Printer::log((const c8*)renderer, (const c8*)vendor, ELL_INFORMATION); - } - - for (u32 i=0; idrop(); - - // add remaining material renderer - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_DETAIL_MAP( this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SPHERE_MAP( this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_REFLECTION_2_LAYER( this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR( this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL( this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF( this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA( this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER( this)); - - // add normal map renderers - s32 tmp = 0; - video::IMaterialRenderer* renderer = 0; - renderer = new COpenGLNormalMapRenderer(this, tmp, MaterialRenderers[EMT_SOLID].Renderer); - renderer->drop(); - renderer = new COpenGLNormalMapRenderer(this, tmp, MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); - renderer->drop(); - renderer = new COpenGLNormalMapRenderer(this, tmp, MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); - renderer->drop(); - - // add parallax map renderers - renderer = new COpenGLParallaxMapRenderer(this, tmp, MaterialRenderers[EMT_SOLID].Renderer); - renderer->drop(); - renderer = new COpenGLParallaxMapRenderer(this, tmp, MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); - renderer->drop(); - renderer = new COpenGLParallaxMapRenderer(this, tmp, MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); - renderer->drop(); - - // add basic 1 texture blending - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_ONETEXTURE_BLEND(this)); -} - -void COpenGLDriver::loadExtensions() -{ - if (atof((c8*)glGetString(GL_VERSION)) >= 1.2) - os::Printer::log("OpenGL driver version is 1.2 or better.", ELL_INFORMATION); - else - os::Printer::log("OpenGL driver version is not 1.2 or better.", ELL_WARNING); - - const GLubyte* t = glGetString(GL_EXTENSIONS); -// os::Printer::log((const c8*)t, ELL_INFORMATION); - #ifdef GLU_VERSION_1_3 - const GLubyte* gluVersion = gluGetString(GLU_VERSION); - - if (gluVersion[0]>1 || gluVersion[3]>2) - { - MultiTextureExtension = gluCheckExtension((const GLubyte*)"GL_ARB_multitexture", t); - MultiSamplingExtension = gluCheckExtension((const GLubyte*)"GL_ARB_multisample", t); - ARBVertexProgramExtension = gluCheckExtension((const GLubyte*)"GL_ARB_vertex_program", t); - ARBFragmentProgramExtension = gluCheckExtension((const GLubyte*)"GL_ARB_fragment_program", t); - ARBShadingLanguage100Extension = gluCheckExtension((const GLubyte*)"GL_ARB_shading_language_100", t); - AnisotropyExtension = gluCheckExtension((const GLubyte*)"GL_EXT_texture_filter_anisotropic", t); - SeparateStencilExtension = gluCheckExtension((const GLubyte*)"GL_ATI_separate_stencil", t); - SeparateStencilExtension = SeparateStencilExtension || gluCheckExtension((const GLubyte*)"GL_ARB_separate_stencil", t); - GenerateMipmapExtension = gluCheckExtension((const GLubyte*)"GL_SGIS_generate_mipmap", t); - TextureCompressionExtension = gluCheckExtension((const GLubyte*)"GL_ARB_texture_compression", t); - TextureNPOTExtension = gluCheckExtension((const GLubyte*)"GL_ARB_texture_non_power_of_two", t); - FramebufferObjectExtension = gluCheckExtension((const GLubyte*)"GL_EXT_framebuffer_object", t); - EXTPackedDepthStencil = gluCheckExtension((const GLubyte*)"GL_EXT_packed_depth_stencil", t); - EXTSeparateSpecularColor = gluCheckExtension((const GLubyte*)"GL_EXT_separate_specular_color", t); - } - else - #endif - { - s32 len = (s32)strlen((const char*)t); - c8 *str = new c8[len+1]; - c8* p = str; - - for (s32 i=0; i1) || (minor>3)) - IRR_OGL_LOAD_EXTENSION=glXGetProcAddress; - else - #endif - IRR_OGL_LOAD_EXTENSION=glXGetProcAddressARB; - #else - #define IRR_OGL_LOAD_EXTENSION glXGetProcAddressARB - #endif - - pGlActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glActiveTextureARB")); - - pGlClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glClientActiveTextureARB")); - - // get fragment and vertex program function pointers - pGlGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGenProgramsARB")); - - pGlBindProgramARB = (PFNGLBINDPROGRAMARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glBindProgramARB")); - - pGlProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glProgramStringARB")); - - pGlDeleteProgramsARB = (PFNGLDELETEPROGRAMSNVPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteProgramsARB")); - - pGlProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glProgramLocalParameter4fvARB")); - - pGlCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCreateShaderObjectARB")); - - pGlShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glShaderSourceARB")); - - pGlCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCompileShaderARB")); - - pGlCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCreateProgramObjectARB")); - - pGlAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glAttachObjectARB")); - - pGlLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glLinkProgramARB")); - - pGlUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUseProgramObjectARB")); - - pGlDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteObjectARB")); - - pGlGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetInfoLogARB")); - - pGlGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetObjectParameterivARB")); - - pGlGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetUniformLocationARB")); - - pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform4fvARB")); - - pGlUniform1ivARB = (PFNGLUNIFORM1IVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform1ivARB")); - - pGlUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform1fvARB")); - - pGlUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform2fvARB")); - - pGlUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform3fvARB")); - - pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform4fvARB")); - - pGlUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniformMatrix2fvARB")); - - pGlUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniformMatrix3fvARB")); - - pGlUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniformMatrix4fvARB")); - - pGlGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetActiveUniformARB")); - - // get point parameter extension - pGlPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glPointParameterfARB")); - pGlPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glPointParameterfvARB")); - - // get stencil extension - pGlStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilFuncSeparate")); - pGlStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilOpSeparate")); - pGlStencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilFuncSeparateATI")); - pGlStencilOpSeparateATI = (PFNGLSTENCILOPSEPARATEATIPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilOpSeparateATI")); - - #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC - pGlCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCompressedTexImage2D")); - #endif // PFNGLCOMPRESSEDTEXIMAGE2DPROC - -#ifdef GLX_SGI_swap_control - // get vsync extension - glxSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glXSwapIntervalSGI")); -#endif - - // FrameBufferObjects - pGlBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glBindFramebufferEXT")); - - pGlDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteFramebuffersEXT")); - - pGlGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGenFramebuffersEXT")); - - pGlCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCheckFramebufferStatusEXT")); - - pGlFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glFramebufferTexture2DEXT")); - - pGlBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glBindRenderbufferEXT")); - - pGlDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteRenderbuffersEXT")); - - pGlGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGenRenderbuffersEXT")); - - pGlRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glRenderbufferStorageEXT")); - - pGlFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glFramebufferRenderbufferEXT")); - - #endif // _IRR_OPENGL_USE_EXTPOINTER_ - #endif // _IRR_WINDOWS_ - - // load common extensions - - glGetIntegerv(GL_MAX_TEXTURE_UNITS, &MaxTextureUnits); - glGetIntegerv(GL_MAX_LIGHTS, &MaxLights); - glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &MaxAnisotropy); - } - -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (!pGlActiveTextureARB || !pGlClientActiveTextureARB) - { - MultiTextureExtension = false; - os::Printer::log("Failed to load OpenGL's multitexture extension, proceeding without.", ELL_WARNING); - } - else -#endif - if (MaxTextureUnits < 2) - { - MultiTextureExtension = false; - os::Printer::log("Warning: OpenGL device only has one texture unit. Disabling multitexturing.", ELL_WARNING); - } - MaxTextureUnits = core::min_((u32)MaxTextureUnits,MATERIAL_MAX_TEXTURES); - glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &MaxIndices); -} - - - -//! presents the rendered scene on the screen, returns false if failed -bool COpenGLDriver::endScene( s32 windowId, core::rect* sourceRect ) -{ - CNullDriver::endScene( windowId ); - -#ifdef _IRR_WINDOWS_ - return SwapBuffers(HDc) == TRUE; -#endif - -#ifdef LINUX - glXSwapBuffers(XDisplay, XWindow); - return true; -#endif - -#ifdef MACOSX - _device->flush(); - return true; -#endif -} - - - -//! clears the zbuffer -bool COpenGLDriver::beginScene(bool backBuffer, bool zBuffer, SColor color) -{ - CNullDriver::beginScene(backBuffer, zBuffer, color); - - GLbitfield mask = 0; - - if (backBuffer) - { - f32 inv = 1.0f / 255.0f; - glClearColor(color.getRed() * inv, color.getGreen() * inv, - color.getBlue() * inv, color.getAlpha() * inv); - - mask |= GL_COLOR_BUFFER_BIT; - } - - if (zBuffer) - { - glDepthMask(GL_TRUE); - mask |= GL_DEPTH_BUFFER_BIT; - } - - glClear(mask); - return true; -} - - - -//! Returns the transformation set by setTransform -const core::matrix4& COpenGLDriver::getTransform(E_TRANSFORMATION_STATE state) -{ - return Matrices[state]; -} - - - -//! sets transformation -void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) -{ - GLfloat glmat[16]; - Matrices[state] = mat; - Transformation3DChanged = true; - - switch(state) - { - case ETS_VIEW: - case ETS_WORLD: - // OpenGL only has a model matrix, view and world is not existent. so lets fake these two. - createGLMatrix(glmat, Matrices[ETS_VIEW] * Matrices[ETS_WORLD]); - glMatrixMode(GL_MODELVIEW); - glLoadMatrixf(glmat); - break; - case ETS_PROJECTION: - createGLMatrix(glmat, mat); - // flip z to compensate OpenGLs right-hand coordinate system - glmat[12] *= -1.0f; - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(glmat); - break; - case ETS_TEXTURE_0: - case ETS_TEXTURE_1: - case ETS_TEXTURE_2: - case ETS_TEXTURE_3: - if (mat.isIdentity()) - return; - - if (MultiTextureExtension) - extGlActiveTextureARB(GL_TEXTURE0_ARB + ( state - ETS_TEXTURE_0 )); - - glMatrixMode(GL_TEXTURE); - createGLTextureMatrix(glmat, mat ); - glLoadMatrixf(glmat); - break; - default: - break; - } -} - - - -//! draws a vertex primitive list -void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) -{ - if (!primitiveCount || !vertexCount) - return; - - if (!checkPrimitiveCount(primitiveCount)) - return; - - CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType); - - // convert colors to gl color format. - vertexCount *= 4; //reused as color component count - ColorBuffer.set_used(vertexCount); - u32 i; - - switch (vType) - { - case EVT_STANDARD: - { - const S3DVertex* p = (const S3DVertex*)vertices; - for ( i=0; iColor.toOpenGLColor(&ColorBuffer[i]); - ++p; - } - } - break; - case EVT_2TCOORDS: - { - const S3DVertex2TCoords* p = (const S3DVertex2TCoords*)vertices; - for ( i=0; iColor.toOpenGLColor(&ColorBuffer[i]); - ++p; - } - } - break; - case EVT_TANGENTS: - { - const S3DVertexTangents* p = (const S3DVertexTangents*)vertices; - for ( i=0; iColor.toOpenGLColor(&ColorBuffer[i]); - ++p; - } - } - break; - } - - // draw everything - - setRenderStates3DMode(); - - if (MultiTextureExtension) - extGlClientActiveTextureARB(GL_TEXTURE0_ARB); - - glEnableClientState(GL_COLOR_ARRAY); - glEnableClientState(GL_VERTEX_ARRAY); - if (pType!=scene::EPT_POINTS) - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - if (pType!=scene::EPT_POINTS) - glEnableClientState(GL_NORMAL_ARRAY); - - glColorPointer(4, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); - switch (vType) - { - case EVT_STANDARD: - glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), &((S3DVertex*)vertices)[0].Pos); - glNormalPointer(GL_FLOAT, sizeof(S3DVertex), &((S3DVertex*)vertices)[0].Normal); - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &((S3DVertex*)vertices)[0].TCoords); - break; - case EVT_2TCOORDS: - glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].Pos); - glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].Normal); - // texture coordinates - if (MultiTextureExtension) - { - extGlClientActiveTextureARB(GL_TEXTURE1_ARB); - glEnableClientState ( GL_TEXTURE_COORD_ARRAY ); - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].TCoords2); - extGlClientActiveTextureARB(GL_TEXTURE0_ARB); - } - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].TCoords); - break; - case EVT_TANGENTS: - glVertexPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Pos); - glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Normal); - // texture coordinates - if (MultiTextureExtension) - { - extGlClientActiveTextureARB(GL_TEXTURE1_ARB); - glEnableClientState ( GL_TEXTURE_COORD_ARRAY ); - glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Tangent); - - extGlClientActiveTextureARB(GL_TEXTURE2_ARB); - glEnableClientState ( GL_TEXTURE_COORD_ARRAY ); - glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Binormal); - - extGlClientActiveTextureARB(GL_TEXTURE0_ARB); - } - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].TCoords); - break; - } - - switch (pType) - { - case scene::EPT_POINTS: - glDrawArrays(GL_POINTS, 0, primitiveCount); - break; - case scene::EPT_LINE_STRIP: - glDrawElements(GL_LINE_STRIP, primitiveCount+1, GL_UNSIGNED_SHORT, indexList); - break; - case scene::EPT_LINE_LOOP: - glDrawElements(GL_LINE_LOOP, primitiveCount, GL_UNSIGNED_SHORT, indexList); - break; - case scene::EPT_LINES: - glDrawElements(GL_LINES, primitiveCount*2, GL_UNSIGNED_SHORT, indexList); - break; - case scene::EPT_TRIANGLE_STRIP: - glDrawElements(GL_TRIANGLE_STRIP, primitiveCount+2, GL_UNSIGNED_SHORT, indexList); - break; - case scene::EPT_TRIANGLE_FAN: - glDrawElements(GL_TRIANGLE_FAN, primitiveCount+2, GL_UNSIGNED_SHORT, indexList); - break; - case scene::EPT_TRIANGLES: - glDrawElements(GL_TRIANGLES, primitiveCount*3, GL_UNSIGNED_SHORT, indexList); - break; - case scene::EPT_QUAD_STRIP: - glDrawElements(GL_QUAD_STRIP, primitiveCount*2+2, GL_UNSIGNED_SHORT, indexList); - break; - case scene::EPT_QUADS: - glDrawElements(GL_QUADS, primitiveCount*4, GL_UNSIGNED_SHORT, indexList); - break; - case scene::EPT_POLYGON: - glDrawElements(GL_POLYGON, primitiveCount, GL_UNSIGNED_SHORT, indexList); - break; - } - - glFlush(); - - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - if (MultiTextureExtension) - { - if (vType==EVT_TANGENTS) - { - extGlClientActiveTextureARB(GL_TEXTURE2_ARB); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } - if (vType!=EVT_STANDARD && MultiTextureExtension) - { - extGlClientActiveTextureARB(GL_TEXTURE1_ARB); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } - extGlClientActiveTextureARB(GL_TEXTURE0_ARB); - } - glDisableClientState(GL_TEXTURE_COORD_ARRAY); -} - - - -//! draws a 2d image, using a color and the alpha channel of the texture if -//! desired. The image is drawn at pos, clipped against clipRect (if != 0). -//! Only the subtexture defined by sourceRect is used. -void COpenGLDriver::draw2DImage(video::ITexture* texture, - const core::position2d& pos, - const core::rect& sourceRect, - const core::rect* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - if (!texture) - return; - - if (!sourceRect.isValid()) - return; - - disableTextures(1); - if (!setTexture(0, texture)) - return; - - core::position2d targetPos(pos); - core::position2d sourcePos(sourceRect.UpperLeftCorner); - core::dimension2d sourceSize(sourceRect.getSize()); - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - if (clipRect) - { - if (targetPos.X < clipRect->UpperLeftCorner.X) - { - sourceSize.Width += targetPos.X - clipRect->UpperLeftCorner.X; - if (sourceSize.Width <= 0) - return; - - sourcePos.X -= targetPos.X - clipRect->UpperLeftCorner.X; - targetPos.X = clipRect->UpperLeftCorner.X; - } - - if (targetPos.X + sourceSize.Width > clipRect->LowerRightCorner.X) - { - sourceSize.Width -= (targetPos.X + sourceSize.Width) - clipRect->LowerRightCorner.X; - if (sourceSize.Width <= 0) - return; - } - - if (targetPos.Y < clipRect->UpperLeftCorner.Y) - { - sourceSize.Height += targetPos.Y - clipRect->UpperLeftCorner.Y; - if (sourceSize.Height <= 0) - return; - - sourcePos.Y -= targetPos.Y - clipRect->UpperLeftCorner.Y; - targetPos.Y = clipRect->UpperLeftCorner.Y; - } - - if (targetPos.Y + sourceSize.Height > clipRect->LowerRightCorner.Y) - { - sourceSize.Height -= (targetPos.Y + sourceSize.Height) - clipRect->LowerRightCorner.Y; - if (sourceSize.Height <= 0) - return; - } - } - - // clip these coordinates - - if (targetPos.X<0) - { - sourceSize.Width += targetPos.X; - if (sourceSize.Width <= 0) - return; - - sourcePos.X -= targetPos.X; - targetPos.X = 0; - } - - if (targetPos.X + sourceSize.Width > renderTargetSize.Width) - { - sourceSize.Width -= (targetPos.X + sourceSize.Width) - renderTargetSize.Width; - if (sourceSize.Width <= 0) - return; - } - - if (targetPos.Y<0) - { - sourceSize.Height += targetPos.Y; - if (sourceSize.Height <= 0) - return; - - sourcePos.Y -= targetPos.Y; - targetPos.Y = 0; - } - - if (targetPos.Y + sourceSize.Height > renderTargetSize.Height) - { - sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height; - if (sourceSize.Height <= 0) - return; - } - - // ok, we've clipped everything. - // now draw it. - - const core::dimension2d& ss = texture->getOriginalSize(); - core::rect tcoords; - - tcoords.UpperLeftCorner.X = (f32)sourcePos.X / (f32)ss.Width; - tcoords.UpperLeftCorner.Y = (f32)sourcePos.Y / (f32)ss.Height; - tcoords.LowerRightCorner.X = ((f32)sourcePos.X +(f32)sourceSize.Width) / (f32)ss.Width; - tcoords.LowerRightCorner.Y = ((f32)sourcePos.Y + (f32)sourceSize.Height) / (f32)ss.Height; - - core::rect poss(targetPos, sourceSize); - core::rect npos; - f32 xFact = 2.0f / ( renderTargetSize.Width ); - f32 yFact = 2.0f / ( renderTargetSize.Height ); - - npos.UpperLeftCorner.X = ( poss.UpperLeftCorner.X * xFact ) - 1.0f; - npos.UpperLeftCorner.Y = 1.0f - ( poss.UpperLeftCorner.Y * yFact ); - npos.LowerRightCorner.X = ( poss.LowerRightCorner.X * xFact ) - 1.0f; - npos.LowerRightCorner.Y = 1.0f - ( poss.LowerRightCorner.Y * yFact ); - - setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); - - glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); - glBegin(GL_QUADS); - - glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); - glVertex2f(npos.UpperLeftCorner.X, npos.UpperLeftCorner.Y); - - glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); - glVertex2f(npos.LowerRightCorner.X, npos.UpperLeftCorner.Y); - - glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); - glVertex2f(npos.LowerRightCorner.X, npos.LowerRightCorner.Y); - - glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - glVertex2f(npos.UpperLeftCorner.X, npos.LowerRightCorner.Y); - - glEnd(); -} - - - -//! draws a set of 2d images, using a color and the alpha channel of the -//! texture if desired. The images are drawn beginning at pos and concatenated -//! in one line. All drawings are clipped against clipRect (if != 0). -//! The subtextures are defined by the array of sourceRects and are chosen -//! by the indices given. -void COpenGLDriver::draw2DImage(video::ITexture* texture, - const core::position2d& pos, - const core::array >& sourceRects, - const core::array& indices, - const core::rect* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - if (!texture) - return; - - disableTextures(1); - if (!setTexture(0, texture)) - return; - - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); - glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); - if (clipRect) - { - glEnable(GL_SCISSOR_TEST); - glScissor(clipRect->UpperLeftCorner.X,renderTargetSize.Height-clipRect->LowerRightCorner.Y, - clipRect->getWidth(),clipRect->getHeight()); - } - - const core::dimension2d& ss = texture->getOriginalSize(); - core::position2d targetPos(pos); - core::position2d sourcePos; - core::dimension2d sourceSize; - core::rect tcoords; - f32 xFact = 2.0f / ( renderTargetSize.Width ); - f32 yFact = 2.0f / ( renderTargetSize.Height ); - - for (u32 i=0; i poss(targetPos, sourceSize); - core::rect npos; - - npos.UpperLeftCorner.X = ( poss.UpperLeftCorner.X * xFact ) - 1.0f; - npos.UpperLeftCorner.Y = 1.0f - ( poss.UpperLeftCorner.Y * yFact ); - - npos.LowerRightCorner.X = ( poss.LowerRightCorner.X * xFact ) - 1.0f; - npos.LowerRightCorner.Y = 1.0f - ( poss.LowerRightCorner.Y * yFact ); - - glBegin(GL_QUADS); - - glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); - glVertex2f(npos.UpperLeftCorner.X, npos.UpperLeftCorner.Y); - - glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); - glVertex2f(npos.LowerRightCorner.X, npos.UpperLeftCorner.Y); - - glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); - glVertex2f(npos.LowerRightCorner.X, npos.LowerRightCorner.Y); - - glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - glVertex2f(npos.UpperLeftCorner.X, npos.LowerRightCorner.Y); - - glEnd(); - targetPos.X += sourceRects[currentIndex].getWidth(); - } - if (clipRect) - glDisable(GL_SCISSOR_TEST); -} - - - -void COpenGLDriver::draw2DImage(video::ITexture* texture, const core::rect& destRect, - const core::rect& sourceRect, const core::rect* clipRect, - video::SColor* colors, bool useAlphaChannelOfTexture) -{ - if (!texture) - return; - - const core::dimension2d& ss = texture->getOriginalSize(); - core::rect tcoords; - tcoords.UpperLeftCorner.X = (f32)sourceRect.UpperLeftCorner.X / (f32)ss.Width; - tcoords.UpperLeftCorner.Y = (f32)sourceRect.UpperLeftCorner.Y / (f32)ss.Height; - tcoords.LowerRightCorner.X = (f32)sourceRect.LowerRightCorner.X / (f32)ss.Width; - tcoords.LowerRightCorner.Y = (f32)sourceRect.LowerRightCorner.Y / (f32)ss.Height; - - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - core::rect npos; - f32 xFact = 2.0f / ( renderTargetSize.Width ); - f32 yFact = 2.0f / ( renderTargetSize.Height ); - npos.UpperLeftCorner.X = ( destRect.UpperLeftCorner.X * xFact ) - 1.0f; - npos.UpperLeftCorner.Y = 1.0f - ( destRect.UpperLeftCorner.Y * yFact ); - npos.LowerRightCorner.X = ( destRect.LowerRightCorner.X * xFact ) - 1.0f; - npos.LowerRightCorner.Y = 1.0f - ( destRect.LowerRightCorner.Y * yFact ); - - video::SColor temp[4] = - { - 0xFFFFFFFF, - 0xFFFFFFFF, - 0xFFFFFFFF, - 0xFFFFFFFF - }; - - video::SColor* useColor = colors ? colors : temp; - - setRenderStates2DMode(useColor[0].getAlpha()<255 || useColor[1].getAlpha()<255 || useColor[2].getAlpha()<255 || useColor[3].getAlpha()<255, true, useAlphaChannelOfTexture); - - disableTextures(1); - setTexture(0, texture); - - glBegin(GL_QUADS); - - glColor4ub(useColor[0].getRed(), useColor[0].getGreen(), useColor[0].getBlue(), useColor[0].getAlpha()); - glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); - glVertex2f(npos.UpperLeftCorner.X, npos.UpperLeftCorner.Y); - - glColor4ub(useColor[3].getRed(), useColor[3].getGreen(), useColor[3].getBlue(), useColor[3].getAlpha()); - glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); - glVertex2f(npos.LowerRightCorner.X, npos.UpperLeftCorner.Y); - - glColor4ub(useColor[2].getRed(), useColor[2].getGreen(), useColor[2].getBlue(), useColor[2].getAlpha()); - glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); - glVertex2f(npos.LowerRightCorner.X, npos.LowerRightCorner.Y); - - glColor4ub(useColor[1].getRed(), useColor[1].getGreen(), useColor[1].getBlue(), useColor[1].getAlpha()); - glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - glVertex2f(npos.UpperLeftCorner.X, npos.LowerRightCorner.Y); - - glEnd(); -} - - - -//! draw a 2d rectangle -void COpenGLDriver::draw2DRectangle(SColor color, const core::rect& position, - const core::rect* clip) -{ - setRenderStates2DMode(color.getAlpha() < 255, false, false); - disableTextures(); - - core::rect pos = position; - - if (clip) - pos.clipAgainst(*clip); - - if (!pos.isValid()) - return; - - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - s32 xPlus = renderTargetSize.Width>>1; - f32 xFact = 1.0f / (renderTargetSize.Width>>1); - - s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); - f32 yFact = 1.0f / (renderTargetSize.Height>>1); - - glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); - glRectf((pos.UpperLeftCorner.X-xPlus) * xFact, - (yPlus-pos.UpperLeftCorner.Y) * yFact, - (pos.LowerRightCorner.X-xPlus) * xFact, - (yPlus-pos.LowerRightCorner.Y) * yFact); -} - - - -//! draw an 2d rectangle -void COpenGLDriver::draw2DRectangle(const core::rect& position, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect* clip) -{ - core::rect pos = position; - - if (clip) - pos.clipAgainst(*clip); - - if (!pos.isValid()) - return; - - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - s32 xPlus = renderTargetSize.Width>>1; - f32 xFact = 1.0f / (renderTargetSize.Width>>1); - - s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); - f32 yFact = 1.0f / (renderTargetSize.Height>>1); - - core::rect npos; - npos.UpperLeftCorner.X = (f32)(pos.UpperLeftCorner.X-xPlus) * xFact; - npos.UpperLeftCorner.Y = (f32)(yPlus-pos.UpperLeftCorner.Y) * yFact; - npos.LowerRightCorner.X = (f32)(pos.LowerRightCorner.X-xPlus) * xFact; - npos.LowerRightCorner.Y = (f32)(yPlus-pos.LowerRightCorner.Y) * yFact; - - setRenderStates2DMode(colorLeftUp.getAlpha() < 255 || - colorRightUp.getAlpha() < 255 || - colorLeftDown.getAlpha() < 255 || - colorRightDown.getAlpha() < 255, false, false); - - disableTextures(); - - glBegin(GL_QUADS); - glColor4ub(colorLeftUp.getRed(), colorLeftUp.getGreen(), - colorLeftUp.getBlue(), colorLeftUp.getAlpha()); - glVertex2f(npos.UpperLeftCorner.X, npos.UpperLeftCorner.Y); - - glColor4ub(colorRightUp.getRed(), colorRightUp.getGreen(), - colorRightUp.getBlue(), colorRightUp.getAlpha()); - glVertex2f(npos.LowerRightCorner.X, npos.UpperLeftCorner.Y); - - glColor4ub(colorRightDown.getRed(), colorRightDown.getGreen(), - colorRightDown.getBlue(), colorRightDown.getAlpha()); - glVertex2f(npos.LowerRightCorner.X, npos.LowerRightCorner.Y); - - glColor4ub(colorLeftDown.getRed(), colorLeftDown.getGreen(), - colorLeftDown.getBlue(), colorLeftDown.getAlpha()); - glVertex2f(npos.UpperLeftCorner.X, npos.LowerRightCorner.Y); - - glEnd(); -} - - - -//! Draws a 2d line. -void COpenGLDriver::draw2DLine(const core::position2d& start, - const core::position2d& end, - SColor color) -{ - // thanks to Vash TheStampede who sent in his implementation - - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - const s32 xPlus = renderTargetSize.Width>>1; - const f32 xFact = 1.0f / (renderTargetSize.Width>>1); - - const s32 yPlus = - renderTargetSize.Height-(renderTargetSize.Height>>1); - const f32 yFact = 1.0f / (renderTargetSize.Height>>1); - - core::position2d npos_start; - npos_start.X = (f32)(start.X - xPlus) * xFact; - npos_start.Y = (f32)(yPlus - start.Y) * yFact; - - core::position2d npos_end; - npos_end.X = (f32)(end.X - xPlus) * xFact; - npos_end.Y = (f32)(yPlus - end.Y) * yFact; - - setRenderStates2DMode(color.getAlpha() < 255, false, false); - disableTextures(); - - glBegin(GL_LINES); - glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); - glVertex2f(npos_start.X, npos_start.Y); - glVertex2f(npos_end.X, npos_end.Y); - glEnd(); -} - - - -//! queries the features of the driver, returns true if feature is available -bool COpenGLDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) -{ - switch (feature) - { - case EVDF_RENDER_TO_TARGET: - return true; - case EVDF_MULTITEXTURE: - return MultiTextureExtension; - case EVDF_BILINEAR_FILTER: - return true; - case EVDF_MIP_MAP: - return true; - case EVDF_MIP_MAP_AUTO_UPDATE: - return GenerateMipmapExtension; - case EVDF_STENCIL_BUFFER: - return StencilBuffer; - case EVDF_ARB_VERTEX_PROGRAM_1: - return ARBVertexProgramExtension; - case EVDF_ARB_FRAGMENT_PROGRAM_1: - return ARBFragmentProgramExtension; - case EVDF_ARB_GLSL: - return ARBShadingLanguage100Extension; - case EVDF_TEXTURE_NPOT: - return TextureNPOTExtension; - case EVDF_FRAMEBUFFER_OBJECT: - return FramebufferObjectExtension; - default: - return false; - }; -} - - - -//! sets the current Texture -bool COpenGLDriver::setTexture(s32 stage, video::ITexture* texture) -{ - if (stage >= MaxTextureUnits) - return false; - -// Not working, texture confusion in menu of Meshviewer. - if (CurrentTexture[stage]==texture) - return true; - - if (MultiTextureExtension) - extGlActiveTextureARB(GL_TEXTURE0_ARB + stage); - - CurrentTexture[stage]=texture; - - if (texture == 0) - { - glDisable(GL_TEXTURE_2D); - return true; - } - else - { - if (texture->getDriverType() != EDT_OPENGL) - { - glDisable(GL_TEXTURE_2D); - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, - ((COpenGLTexture*)texture)->getOpenGLTextureName()); - } - return true; -} - - - -//! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled. -//! Returns whether disabling was successful or not. -bool COpenGLDriver::disableTextures(s32 fromStage) -{ - bool result=true; - for (s32 i=fromStage; i= 0 && LastMaterial.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); - - // set new material. - if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial( - Material, LastMaterial, ResetRenderStates, this); - - LastMaterial = Material; - ResetRenderStates = false; - } - - if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, video::EVT_STANDARD); - - CurrentRenderMode = ERM_3D; -} - - -//! Can be called by an IMaterialRenderer to make its work easier. -void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, - bool resetAllRenderStates) -{ - if (resetAllRenderStates || - lastmaterial.AmbientColor != material.AmbientColor || - lastmaterial.DiffuseColor != material.DiffuseColor || - lastmaterial.SpecularColor != material.SpecularColor || - lastmaterial.EmissiveColor != material.EmissiveColor || - lastmaterial.Shininess != material.Shininess) - { - GLfloat color[4]; - - const f32 inv = 1.0f / 255.0f; - - color[0] = material.AmbientColor.getRed() * inv; - color[1] = material.AmbientColor.getGreen() * inv; - color[2] = material.AmbientColor.getBlue() * inv; - color[3] = material.AmbientColor.getAlpha() * inv; - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color); - - color[0] = material.DiffuseColor.getRed() * inv; - color[1] = material.DiffuseColor.getGreen() * inv; - color[2] = material.DiffuseColor.getBlue() * inv; - color[3] = material.DiffuseColor.getAlpha() * inv; - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color); - - // disable Specular colors if no shininess is set - if (material.Shininess != 0.0f) - { -#ifdef GL_EXT_separate_specular_color - if (EXTSeparateSpecularColor) - glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); -#endif - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess); - color[0] = material.SpecularColor.getRed() * inv; - color[1] = material.SpecularColor.getGreen() * inv; - color[2] = material.SpecularColor.getBlue() * inv; - color[3] = material.SpecularColor.getAlpha() * inv; - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color); - } -#ifdef GL_EXT_separate_specular_color - else - if (EXTSeparateSpecularColor) - glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); -#endif - - color[0] = material.EmissiveColor.getRed() * inv; - color[1] = material.EmissiveColor.getGreen() * inv; - color[2] = material.EmissiveColor.getBlue() * inv; - color[3] = material.EmissiveColor.getAlpha() * inv; - glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color); - } - - // Texture filter - // Has to be checked always because it depends on the textures - // Filtering has to be set for each texture layer - for (s32 i=0; i0) - break; - - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - (material.BilinearFilter || material.TrilinearFilter) ? GL_LINEAR : GL_NEAREST); - - if (material.Textures[i] && material.Textures[i]->hasMipMaps()) - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - material.TrilinearFilter ? GL_LINEAR_MIPMAP_LINEAR : material.BilinearFilter ? GL_LINEAR_MIPMAP_NEAREST : GL_NEAREST_MIPMAP_NEAREST ); - else - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - (material.BilinearFilter || material.TrilinearFilter) ? GL_LINEAR : GL_NEAREST); - - if (AnisotropyExtension) - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, - material.AnisotropicFilter ? MaxAnisotropy : 1.0f ); - } - - // fillmode - if (resetAllRenderStates || lastmaterial.Wireframe != material.Wireframe || lastmaterial.PointCloud != material.PointCloud) - glPolygonMode(GL_FRONT_AND_BACK, material.Wireframe ? GL_LINE : material.PointCloud? GL_POINT : GL_FILL); - - // shademode - - if (resetAllRenderStates || lastmaterial.GouraudShading != material.GouraudShading) - { - if (material.GouraudShading) - glShadeModel(GL_SMOOTH); - else - glShadeModel(GL_FLAT); - } - - // lighting - - if (resetAllRenderStates || lastmaterial.Lighting != material.Lighting) - { - if (material.Lighting) - glEnable(GL_LIGHTING); - else - glDisable(GL_LIGHTING); - } - - // zbuffer - if (resetAllRenderStates || lastmaterial.ZBuffer != material.ZBuffer) - { - switch (material.ZBuffer) - { - case 0: - glDisable(GL_DEPTH_TEST); - break; - case 1: - glEnable(GL_DEPTH_TEST); - glDepthFunc ( GL_LEQUAL ); - break; - case 2: - glEnable(GL_DEPTH_TEST); - glDepthFunc ( GL_EQUAL ); - break; - } - } - - // zwrite - if (resetAllRenderStates || lastmaterial.ZWriteEnable != material.ZWriteEnable) - { - if (material.ZWriteEnable) - { - glDepthMask(GL_TRUE); - } - else - glDepthMask(GL_FALSE); - } - - // back face culling - - if (resetAllRenderStates || lastmaterial.BackfaceCulling != material.BackfaceCulling) - { - if (material.BackfaceCulling) - glEnable(GL_CULL_FACE); - else - glDisable(GL_CULL_FACE); - } - - // fog - if (resetAllRenderStates || lastmaterial.FogEnable != material.FogEnable) - { - if (material.FogEnable) - glEnable(GL_FOG); - else - glDisable(GL_FOG); - } - - // normalization - if (resetAllRenderStates || lastmaterial.NormalizeNormals != material.NormalizeNormals) - { - if (material.NormalizeNormals) - glEnable(GL_NORMALIZE); - else - glDisable(GL_NORMALIZE); - } - - // thickness - if (resetAllRenderStates || lastmaterial.Thickness != material.Thickness) - { - glPointSize(material.Thickness); - glLineWidth(material.Thickness); - } - - // texture address mode - for (s32 u=0; u0) - break; - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mode); - } - } -} - - - -//! sets the needed renderstates -void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) -{ - if (CurrentRenderMode != ERM_2D || Transformation3DChanged) - { - // unset last 3d material - if (CurrentRenderMode == ERM_3D && Material.MaterialType >= 0 && - Material.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - - Transformation3DChanged = false; - - glDisable(GL_DEPTH_TEST); - glDisable(GL_FOG); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glDisable(GL_LIGHTING); - - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - - glDisable(GL_ALPHA_TEST); - glCullFace(GL_BACK); - } - - if (texture) - { - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - - if (alphaChannel) - { - if (alpha) - { - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PRIMARY_COLOR_EXT); - } - else - { - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); - } - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); - } - else - { - if (alpha) - { - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT); - glDisable(GL_ALPHA_TEST); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - } - else - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glDisable(GL_ALPHA_TEST); - glDisable(GL_BLEND); - } - } - - } - else - { - if (alpha) - { - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glDisable(GL_ALPHA_TEST); - } - else - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - } - } - - CurrentRenderMode = ERM_2D; -} - - -//! \return Returns the name of the video driver. Example: In case of the Direct3D8 -//! driver, it would return "Direct3D8.1". -const wchar_t* COpenGLDriver::getName() -{ - return Name.c_str(); -} - - -//! deletes all dynamic lights there are -void COpenGLDriver::deleteAllDynamicLights() -{ - for (s32 i=0; i& area) -{ - core::rect vp = area; - core::rect rendert(0,0, getCurrentRenderTargetSize().Width, getCurrentRenderTargetSize().Height); - vp.clipAgainst(rendert); - - if (vp.getHeight()>0 && vp.getWidth()>0) - glViewport(vp.UpperLeftCorner.X, - getCurrentRenderTargetSize().Height - vp.UpperLeftCorner.Y - vp.getHeight(), - vp.getWidth(), vp.getHeight()); - - ViewPort = vp; -} - -//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do -//! this: First, draw all geometry. Then use this method, to draw the shadow -//! volume. Next use IVideoDriver::drawStencilShadow() to visualize the shadow. -void COpenGLDriver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail) -{ - if (!StencilBuffer || !count) - return; - - // unset last 3d material - if (CurrentRenderMode == ERM_3D && - Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - { - MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); - ResetRenderStates = true; - } - - // store current OpenGL state - glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | - GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT); - - glDisable(GL_LIGHTING); - glDisable(GL_FOG); - glDepthMask(GL_FALSE); // no depth buffer writing - glDepthFunc(GL_LEQUAL); - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); // no color buffer drawing - glEnable(GL_STENCIL_TEST); - glStencilFunc(GL_ALWAYS, 0, 0); - glEnable(GL_CULL_FACE); - - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3,GL_FLOAT,sizeof(core::vector3df),&triangles[0]); - - if (!zfail) - { - // ZPASS Method - - glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); - glCullFace(GL_BACK); - glDrawArrays(GL_TRIANGLES,0,count); - - glStencilOp(GL_KEEP, GL_KEEP, GL_DECR); - glCullFace(GL_FRONT); - glDrawArrays(GL_TRIANGLES,0,count); - } - else - { - // ZFAIL Method - - glStencilOp(GL_KEEP, GL_INCR, GL_KEEP); - glCullFace(GL_FRONT); - glDrawArrays(GL_TRIANGLES,0,count); - - glStencilOp(GL_KEEP, GL_DECR, GL_KEEP); - glCullFace(GL_BACK); - glDrawArrays(GL_TRIANGLES,0,count); - } - - glDisableClientState(GL_VERTEX_ARRAY); //not stored on stack - glPopAttrib(); -} - - - -void COpenGLDriver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge, - video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge) -{ - if (!StencilBuffer) - return; - - disableTextures(); - - // store attributes - glPushAttrib( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT ); - - glDisable( GL_LIGHTING ); - glDisable(GL_FOG); - glDepthMask(GL_FALSE); - glDepthFunc( GL_LEQUAL ); - - glFrontFace( GL_CCW ); - glShadeModel( GL_FLAT ); - glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glEnable( GL_STENCIL_TEST ); - glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFFL); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - - // draw a shadow rectangle covering the entire screen using stencil buffer - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - glBegin(GL_TRIANGLE_STRIP); - - glColor4ub (leftUpEdge.getRed(), leftUpEdge.getGreen(), leftUpEdge.getBlue(), leftUpEdge.getAlpha() ); - glVertex3f(-1.1f, 1.1f,0.9f); - - glColor4ub (leftDownEdge.getRed(), leftDownEdge.getGreen(), leftDownEdge.getBlue(), leftDownEdge.getAlpha() ); - glVertex3f(-1.1f,-1.1f,0.9f); - - glColor4ub (rightUpEdge.getRed(), rightUpEdge.getGreen(), rightUpEdge.getBlue(), rightUpEdge.getAlpha() ); - glVertex3f( 1.1f, 1.1f,0.9f); - - glColor4ub (rightDownEdge.getRed(), rightDownEdge.getGreen(), rightDownEdge.getBlue(), rightDownEdge.getAlpha() ); - glVertex3f( 1.1f,-1.1f,0.9f); - - glEnd(); - - if (clearStencilBuffer) - glClear(GL_STENCIL_BUFFER_BIT); - - // restore settings - glPopMatrix(); - glPopAttrib(); -} - - -//! Sets the fog mode. -void COpenGLDriver::setFog(SColor c, bool linearFog, f32 start, - f32 end, f32 density, bool pixelFog, bool rangeFog) -{ - CNullDriver::setFog(c, linearFog, start, end, density, pixelFog, rangeFog); - - glFogi(GL_FOG_MODE, linearFog ? GL_LINEAR : GL_EXP); -#ifdef GL_EXT_fog_coord - glFogi(GL_FOG_COORDINATE_SOURCE, GL_FRAGMENT_DEPTH); -#endif - - if(linearFog) - { - glFogf(GL_FOG_START, start); - glFogf(GL_FOG_END, end); - } - else - glFogf(GL_FOG_DENSITY, density); - - SColorf color(c); - GLfloat data[4] = {color.r, color.g, color.b, color.a}; - glFogfv(GL_FOG_COLOR, data); -} - - - -//! Draws a 3d line. -void COpenGLDriver::draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color) -{ - setRenderStates3DMode(); - - glBegin(GL_LINES); - glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); - glVertex3f(start.X, start.Y, start.Z); - - glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); - glVertex3f(end.X, end.Y, end.Z); - glEnd(); -} - - - -//! Only used by the internal engine. Used to notify the driver that -//! the window was resized. -void COpenGLDriver::OnResize(const core::dimension2d& size) -{ - CNullDriver::OnResize(size); - glViewport(0, 0, size.Width, size.Height); -} - - - -//! Returns type of video driver -E_DRIVER_TYPE COpenGLDriver::getDriverType() -{ - return EDT_OPENGL; -} - - - -void COpenGLDriver::extGlActiveTextureARB(GLenum texture) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (MultiTextureExtension && pGlActiveTextureARB) - pGlActiveTextureARB(texture); -#else - if (MultiTextureExtension) glActiveTextureARB(texture); -#endif -} - -void COpenGLDriver::extGlClientActiveTextureARB(GLenum texture) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (MultiTextureExtension && pGlClientActiveTextureARB) - pGlClientActiveTextureARB(texture); -#else - if (MultiTextureExtension) glClientActiveTextureARB(texture); -#endif -} - -void COpenGLDriver::extGlGenProgramsARB(GLsizei n, GLuint *programs) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGenProgramsARB) - pGlGenProgramsARB(n, programs); -#elif defined(GL_ARB_vertex_program) - glGenProgramsARB(n,programs); -#else - os::Printer::log("glGenProgramsARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlBindProgramARB(GLenum target, GLuint program) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlBindProgramARB) - pGlBindProgramARB(target, program); -#elif defined(GL_ARB_vertex_program) - glBindProgramARB(target, program); -#else - os::Printer::log("glBindProgramARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid *string) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlProgramStringARB) - pGlProgramStringARB(target, format, len, string); -#elif defined(GL_ARB_vertex_program) - glProgramStringARB(target,format,len,string); -#else - os::Printer::log("glProgramStringARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlDeleteProgramsARB(GLsizei n, const GLuint *programs) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlDeleteProgramsARB) - pGlDeleteProgramsARB(n, programs); -#elif defined(GL_ARB_vertex_program) - glDeleteProgramsARB(n,programs); -#else - os::Printer::log("glDeleteProgramsARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlProgramLocalParameter4fvARB(GLenum n, GLuint i, const GLfloat * f) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlProgramLocalParameter4fvARB) - pGlProgramLocalParameter4fvARB(n,i,f); -#elif defined(GL_ARB_vertex_program) - glProgramLocalParameter4fvARB(n,i,f); -#else - os::Printer::log("glProgramLocalParameter4fvARB not supported", ELL_ERROR); -#endif -} - -GLhandleARB COpenGLDriver::extGlCreateShaderObjectARB(GLenum shaderType) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlCreateShaderObjectARB) - return pGlCreateShaderObjectARB(shaderType); -#elif defined(GL_ARB_shader_objects) - return glCreateShaderObjectARB(shaderType); -#else - os::Printer::log("glCreateShaderObjectARB not supported", ELL_ERROR); -#endif - return 0; -} - -void COpenGLDriver::extGlShaderSourceARB(GLhandleARB shader, int numOfStrings, const char **strings, int *lenOfStrings) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlShaderSourceARB) - pGlShaderSourceARB(shader, numOfStrings, strings, lenOfStrings); -#elif defined(GL_ARB_shader_objects) - glShaderSourceARB(shader, numOfStrings, strings, (GLint *)lenOfStrings); -#else - os::Printer::log("glShaderSourceARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlCompileShaderARB(GLhandleARB shader) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlCompileShaderARB) - pGlCompileShaderARB(shader); -#elif defined(GL_ARB_shader_objects) - glCompileShaderARB(shader); -#else - os::Printer::log("glCompileShaderARB not supported", ELL_ERROR); -#endif -} - -GLhandleARB COpenGLDriver::extGlCreateProgramObjectARB(void) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlCreateProgramObjectARB) - return pGlCreateProgramObjectARB(); -#elif defined(GL_ARB_shader_objects) - return glCreateProgramObjectARB(); -#else - os::Printer::log("glCreateProgramObjectARB not supported", ELL_ERROR); -#endif - return 0; -} - -void COpenGLDriver::extGlAttachObjectARB(GLhandleARB program, GLhandleARB shader) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlAttachObjectARB) - pGlAttachObjectARB(program, shader); -#elif defined(GL_ARB_shader_objects) - glAttachObjectARB(program, shader); -#else - os::Printer::log("glAttachObjectARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlLinkProgramARB(GLhandleARB program) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlLinkProgramARB) - pGlLinkProgramARB(program); -#elif defined(GL_ARB_shader_objects) - glLinkProgramARB(program); -#else - os::Printer::log("glLinkProgramARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUseProgramObjectARB(GLhandleARB prog) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUseProgramObjectARB) - pGlUseProgramObjectARB(prog); -#elif defined(GL_ARB_shader_objects) - glUseProgramObjectARB(prog); -#else - os::Printer::log("glUseProgramObjectARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlDeleteObjectARB(GLhandleARB object) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlDeleteObjectARB) - pGlDeleteObjectARB(object); -#elif defined(GL_ARB_shader_objects) - glDeleteObjectARB(object); -#else - os::Printer::log("gldeleteObjectARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlGetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetInfoLogARB) - pGlGetInfoLogARB(object, maxLength, length, infoLog); -#elif defined(GL_ARB_shader_objects) - glGetInfoLogARB(object, maxLength, length, infoLog); -#else - os::Printer::log("glGetInfoLogARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlGetObjectParameterivARB(GLhandleARB object, GLenum type, int *param) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetObjectParameterivARB) - pGlGetObjectParameterivARB(object, type, param); -#elif defined(GL_ARB_shader_objects) - glGetObjectParameterivARB(object, type, (GLint *)param); -#else - os::Printer::log("glGetObjectParameterivARB not supported", ELL_ERROR); -#endif -} - -GLint COpenGLDriver::extGlGetUniformLocationARB(GLhandleARB program, const char *name) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetUniformLocationARB) - return pGlGetUniformLocationARB(program, name); -#elif defined(GL_ARB_shader_objects) - return glGetUniformLocationARB(program, name); -#else - os::Printer::log("glGetUniformLocationARB not supported", ELL_ERROR); -#endif - return 0; -} - -void COpenGLDriver::extGlUniform4fvARB(GLint location, GLsizei count, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform4fvARB) - pGlUniform4fvARB(location, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform4fvARB(location, count, v); -#else - os::Printer::log("glUniform4fvARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUniform1ivARB (GLint loc, GLsizei count, const GLint *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform1ivARB) - pGlUniform1ivARB(loc, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform1ivARB(loc, count, v); -#else - os::Printer::log("glUniform1ivARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUniform1fvARB (GLint loc, GLsizei count, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform1fvARB) - pGlUniform1fvARB(loc, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform1fvARB(loc, count, v); -#else - os::Printer::log("glUniform1fvARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUniform2fvARB (GLint loc, GLsizei count, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform2fvARB) - pGlUniform2fvARB(loc, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform2fvARB(loc, count, v); -#else - os::Printer::log("glUniform2fvARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUniform3fvARB (GLint loc, GLsizei count, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform3fvARB) - pGlUniform3fvARB(loc, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform3fvARB(loc, count, v); -#else - os::Printer::log("glUniform3fvARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUniformMatrix2fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniformMatrix2fvARB) - pGlUniformMatrix2fvARB(loc, count, transpose, v); -#elif defined(GL_ARB_shader_objects) - glUniformMatrix2fvARB(loc, count, transpose, v); -#else - os::Printer::log("glUniformMatrix2fvARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUniformMatrix3fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniformMatrix3fvARB) - pGlUniformMatrix3fvARB(loc, count, transpose, v); -#elif defined(GL_ARB_shader_objects) - glUniformMatrix3fvARB(loc, count, transpose, v); -#else - os::Printer::log("glUniformMatrix3fvARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUniformMatrix4fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniformMatrix4fvARB) - pGlUniformMatrix4fvARB(loc, count, transpose, v); -#elif defined(GL_ARB_shader_objects) - glUniformMatrix4fvARB(loc, count, transpose, v); -#else - os::Printer::log("glUniformMatrix4fvARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlGetActiveUniformARB (GLhandleARB program, GLuint index, GLsizei maxlength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetActiveUniformARB) - pGlGetActiveUniformARB(program, index, maxlength, length, size, type, name); -#elif defined(GL_ARB_shader_objects) - glGetActiveUniformARB(program, index, maxlength, length, size, type, name); -#else - os::Printer::log("glGetActiveUniformARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlPointParameterfARB (GLint loc, GLfloat f) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlPointParameterfARB) - pGlPointParameterfARB(loc, f); -#else - glPointParameterfARB(loc, f); -#endif -} - -void COpenGLDriver::extGlPointParameterfvARB (GLint loc, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlPointParameterfvARB) - pGlPointParameterfvARB(loc, v); -#else - glPointParameterfvARB(loc, v); -#endif -} - -void COpenGLDriver::extGlStencilFuncSeparate (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlStencilFuncSeparate) - pGlStencilFuncSeparate(frontfunc, backfunc, ref, mask); - else if (pGlStencilFuncSeparateATI) - pGlStencilFuncSeparateATI(frontfunc, backfunc, ref, mask); -#elif defined(GL_VERSION_2_0) - glStencilFuncSeparate(frontfunc, backfunc, ref, mask); -#elif defined(GL_ATI_separate_stencil) - glStencilFuncSeparateATI(frontfunc, backfunc, ref, mask); -#else - os::Printer::log("glStencilFuncSeparate not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlStencilOpSeparate) - pGlStencilOpSeparate(face, fail, zfail, zpass); - else if (pGlStencilOpSeparateATI) - pGlStencilOpSeparateATI(face, fail, zfail, zpass); -#elif defined(GL_VERSION_2_0) - glStencilOpSeparate(face, fail, zfail, zpass); -#elif defined(GL_ATI_separate_stencil) - glStencilOpSeparateATI(face, fail, zfail, zpass); -#else - os::Printer::log("glStencilOpSeparate not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, - GLsizei height, GLint border, GLsizei imageSize, const void* data) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC - if (pGlCompressedTexImage2D) - pGlCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); - #endif // PFNGLCOMPRESSEDTEXIMAGE2DPROC -#else - glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); -#endif -} - -void COpenGLDriver::extGlBindFramebufferEXT (GLenum target, GLuint framebuffer) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlBindFramebufferEXT) - pGlBindFramebufferEXT(target, framebuffer); -#elif defined(GL_EXT_framebuffer_object) - glBindFramebufferEXT(target, framebuffer); -#endif -} - -void COpenGLDriver::extGlDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlDeleteFramebuffersEXT) - pGlDeleteFramebuffersEXT(n, framebuffers); -#elif defined(GL_EXT_framebuffer_object) - glDeleteFramebuffersEXT(n, framebuffers); -#endif -} - -void COpenGLDriver::extGlGenFramebuffersEXT (GLsizei n, GLuint *framebuffers) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGenFramebuffersEXT) - pGlGenFramebuffersEXT(n, framebuffers); -#elif defined(GL_EXT_framebuffer_object) - glGenFramebuffersEXT(n, framebuffers); -#endif -} - -GLenum COpenGLDriver::extGlCheckFramebufferStatusEXT (GLenum target) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlCheckFramebufferStatusEXT) - return pGlCheckFramebufferStatusEXT(target); - else - return 0; -#elif defined(GL_EXT_framebuffer_object) - return glCheckFramebufferStatusEXT(target); -#else - return 0; -#endif -} - -void COpenGLDriver::extGlFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlFramebufferTexture2DEXT) - pGlFramebufferTexture2DEXT(target, attachment, textarget, texture, level); -#elif defined(GL_EXT_framebuffer_object) - glFramebufferTexture2DEXT(target, attachment, textarget, texture, level); -#endif -} - -void COpenGLDriver::extGlBindRenderbufferEXT (GLenum target, GLuint renderbuffer) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlBindRenderbufferEXT) - pGlBindRenderbufferEXT(target, renderbuffer); -#elif defined(GL_EXT_framebuffer_object) - glBindRenderbufferEXT(target, renderbuffer); -#endif -} - -void COpenGLDriver::extGlDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlDeleteRenderbuffersEXT) - pGlDeleteRenderbuffersEXT(n, renderbuffers); -#elif defined(GL_EXT_framebuffer_object) - glDeleteRenderbuffersEXT(n, renderbuffers); -#endif -} - -void COpenGLDriver::extGlGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGenRenderbuffersEXT) - pGlGenRenderbuffersEXT(n, renderbuffers); -#elif defined(GL_EXT_framebuffer_object) - glGenRenderbuffersEXT(n, renderbuffers); -#endif -} - -void COpenGLDriver::extGlRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlRenderbufferStorageEXT) - pGlRenderbufferStorageEXT(target, internalformat, width, height); -#elif defined(GL_EXT_framebuffer_object) - glRenderbufferStorageEXT(target, internalformat, width, height); -#endif -} - -void COpenGLDriver::extGlFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlFramebufferRenderbufferEXT) - pGlFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); -#elif defined(GL_EXT_framebuffer_object) - glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); -#endif -} - -//! Sets a vertex shader constant. -void COpenGLDriver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ -#ifdef GL_ARB_vertex_program - for (int i=0; isetPixelShaderConstant(), not VideoDriver->setPixelShaderConstant()."); - return false; -} - - -//! Adds a new material renderer to the VideoDriver, using pixel and/or -//! vertex shaders to render geometry. -s32 COpenGLDriver::addShaderMaterial(const c8* vertexShaderProgram, - const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, s32 userData) -{ - s32 nr = -1; - COpenGLShaderMaterialRenderer* r = new COpenGLShaderMaterialRenderer( - this, nr, vertexShaderProgram, pixelShaderProgram, - callback, getMaterialRenderer(baseMaterial), userData); - - r->drop(); - return nr; -} - -//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry. -s32 COpenGLDriver::addHighLevelShaderMaterial( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - s32 nr = -1; - - COpenGLSLMaterialRenderer* r = new COpenGLSLMaterialRenderer( - this, nr, vertexShaderProgram, vertexShaderEntryPointName, - vsCompileTarget, pixelShaderProgram, pixelShaderEntryPointName, psCompileTarget, - callback,getMaterialRenderer(baseMaterial), userData); - - r->drop(); - return nr; -} - -//! Returns a pointer to the IVideoDriver interface. (Implementation for -//! IMaterialRendererServices) -IVideoDriver* COpenGLDriver::getVideoDriver() -{ - return this; -} - - -//! Returns pointer to the IGPUProgrammingServices interface. -IGPUProgrammingServices* COpenGLDriver::getGPUProgrammingServices() -{ - return this; -} - -ITexture* COpenGLDriver::createRenderTargetTexture(const core::dimension2d& size) -{ - //disable mip-mapping - bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); - setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false); - - video::ITexture* rtt = 0; -#if defined(GL_EXT_framebuffer_object) - // if driver supports FrameBufferObjects, use them - if (FramebufferObjectExtension) - rtt = new COpenGLTexture(size, EXTPackedDepthStencil, "rt", this); - else -#endif - { - rtt = addTexture(size, "rt"); - if (rtt) - rtt->grab(); - } - - //restore mip-mapping - setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, generateMipLevels); - - return rtt; -} - - -//! Returns the maximum amount of primitives (mostly vertices) which -//! the device is able to render with one drawIndexedTriangleList -//! call. -u32 COpenGLDriver::getMaximalPrimitiveCount() -{ - return 65535;// TODO: Fix all loaders to auto-split and then return the correct value: MaxIndices; -} - - -//! checks triangle count and print warning if wrong -bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color) -{ - // check for right driver type - - if (texture && texture->getDriverType() != EDT_OPENGL) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - // check if we should set the previous RT back - - bool ret = true; - - setTexture(0, 0); - ResetRenderStates=true; - if (RenderTargetTexture!=0) - { - if (RenderTargetTexture->isFrameBufferObject()) - { - RenderTargetTexture->unbindFrameBufferObject(); - } - else - { - glBindTexture(GL_TEXTURE_2D, RenderTargetTexture->getOpenGLTextureName()); - - // Copy Our ViewPort To The Texture - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, - RenderTargetTexture->getSize().Width, RenderTargetTexture->getSize().Height); - } - } - - if (texture) - { - // we want to set a new target. so do this. - glViewport(0, 0, texture->getSize().Width, texture->getSize().Height); - RenderTargetTexture = (COpenGLTexture*)texture; - CurrentRendertargetSize = texture->getSize(); - - if (RenderTargetTexture->isFrameBufferObject()) - { - RenderTargetTexture->bindFrameBufferObject(); - } - } - else - { - glViewport(0,0,ScreenSize.Width,ScreenSize.Height); - RenderTargetTexture = 0; - CurrentRendertargetSize = core::dimension2d(0,0); - } - - GLbitfield mask = 0; - if (clearBackBuffer) - { - f32 inv = 1.0f / 255.0f; - glClearColor(color.getRed() * inv, color.getGreen() * inv, - color.getBlue() * inv, color.getAlpha() * inv); - - mask |= GL_COLOR_BUFFER_BIT; - } - if (clearZBuffer) - { - glDepthMask(GL_TRUE); - mask |= GL_DEPTH_BUFFER_BIT; - } - - glClear(mask); - - return ret; -} - - -// returns the current size of the screen or rendertarget -core::dimension2d COpenGLDriver::getCurrentRenderTargetSize() -{ - if ( CurrentRendertargetSize.Width == 0 ) - return ScreenSize; - else - return CurrentRendertargetSize; -} - -//! Clears the ZBuffer. -void COpenGLDriver::clearZBuffer() -{ - GLboolean enabled = GL_TRUE; - glGetBooleanv(GL_DEPTH_WRITEMASK, &enabled); - - glDepthMask(GL_TRUE); - glClear(GL_DEPTH_BUFFER_BIT); - - glDepthMask(enabled); -} - -//! Returns an image created from the last rendered frame. -IImage* COpenGLDriver::createScreenShot() -{ - IImage* newImage = new CImage(ECF_R8G8B8, ScreenSize); - - u8* pPixels = (u8*)newImage->lock(); - if (!pPixels) - { - newImage->drop(); - return 0; - } - - glReadPixels(0, 0, ScreenSize.Width, ScreenSize.Height, GL_RGB, GL_UNSIGNED_BYTE, pPixels); - - // opengl images are inverted, so we have to fix that here. - s32 pitch=newImage->getPitch(); - u8* p2 = pPixels + (ScreenSize.Height - 1) * pitch; - u8* tmpBuffer = new u8[pitch]; - for (s32 i=0; i < ScreenSize.Height; i += 2) - { - memcpy(tmpBuffer, pPixels, pitch); - memcpy(pPixels, p2, pitch); - memcpy(p2, tmpBuffer, pitch); - pPixels += pitch; - p2 -= pitch; - } - delete [] tmpBuffer; - - newImage->unlock(); - - if (testGLError()) - { - newImage->drop(); - return 0; - } - - return newImage; -} - - -} // end namespace -} // end namespace - - -namespace irr -{ -namespace video -{ - - -// ----------------------------------- -// WINDOWS VERSION -// ----------------------------------- -#ifdef _IRR_WINDOWS_ -IVideoDriver* createOpenGLDriver(const core::dimension2d& screenSize, - HWND window, u32 bits, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias) -{ -#ifdef _IRR_COMPILE_WITH_OPENGL_ - COpenGLDriver* ogl = new COpenGLDriver(screenSize, window, fullscreen, stencilBuffer, io, antiAlias); - if (!ogl->initDriver(screenSize, window, bits, fullscreen, vsync)) - { - ogl->drop(); - ogl = 0; - } - return ogl; -#else - return 0; -#endif // _IRR_COMPILE_WITH_OPENGL_ -} -#endif // _IRR_WINDOWS_ - -// ----------------------------------- -// MACOSX VERSION -// ----------------------------------- -#ifdef MACOSX -IVideoDriver* createOpenGLDriver(const core::dimension2d& screenSize, - CIrrDeviceMacOSX *device, bool fullscreen, bool stencilBuffer, - io::IFileSystem* io, bool vsync, bool antiAlias) -{ -#ifdef _IRR_COMPILE_WITH_OPENGL_ - return new COpenGLDriver(screenSize, fullscreen, stencilBuffer, - device, io, vsync, antiAlias); -#else - return 0; -#endif // _IRR_COMPILE_WITH_OPENGL_ -} -#endif // MACOSX - -// ----------------------------------- -// LINUX VERSION -// ----------------------------------- -#ifdef LINUX -IVideoDriver* createOpenGLDriver(const core::dimension2d& screenSize, - bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias) -{ -#ifdef _IRR_COMPILE_WITH_OPENGL_ - return new COpenGLDriver(screenSize, fullscreen, stencilBuffer, - io, vsync, antiAlias); -#else - return 0; -#endif // _IRR_COMPILE_WITH_OPENGL_ -} -#endif // LINUX - -} // end namespace -} // end namespace - - -#endif // _IRR_COMPILE_WITH_OPENGL_ - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "COpenGLDriver.h" + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "COpenGLTexture.h" +#include "COpenGLMaterialRenderer.h" +#include "COpenGLShaderMaterialRenderer.h" +#include "COpenGLSLMaterialRenderer.h" +#include "COpenGLNormalMapRenderer.h" +#include "COpenGLParallaxMapRenderer.h" +#include "CImage.h" +#include "os.h" + +namespace irr +{ +namespace video +{ + +// ----------------------------------------------------------------------- +// WINDOWS CONSTRUCTOR +// ----------------------------------------------------------------------- +#ifdef _IRR_WINDOWS_ +//! Windows constructor and init code +COpenGLDriver::COpenGLDriver(const core::dimension2d& screenSize, HWND window, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool antiAlias) +: CNullDriver(io, screenSize), + CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), + StencilBuffer(stencilBuffer), AntiAlias(antiAlias), + MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false), + ARBVertexProgramExtension(false), ARBFragmentProgramExtension(false), + ARBShadingLanguage100Extension(false), SeparateStencilExtension(false), + GenerateMipmapExtension(false), TextureCompressionExtension(false), + TextureNPOTExtension(false), FramebufferObjectExtension(false), EXTPackedDepthStencil(false), + RenderTargetTexture(0), LastSetLight(-1), MaxAnisotropy(1), + MaxTextureUnits(1), MaxLights(1), CurrentRendertargetSize(0,0), +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + pGlActiveTextureARB(0), pGlClientActiveTextureARB(0), + pGlGenProgramsARB(0), pGlBindProgramARB(0), pGlProgramStringARB(0), + pGlDeleteProgramsARB(0), pGlProgramLocalParameter4fvARB(0), + pGlCreateShaderObjectARB(0), pGlShaderSourceARB(0), + pGlCompileShaderARB(0), pGlCreateProgramObjectARB(0), pGlAttachObjectARB(0), + pGlLinkProgramARB(0), pGlUseProgramObjectARB(0), pGlDeleteObjectARB(0), + pGlGetObjectParameterivARB(0), pGlGetUniformLocationARB(0), + pGlUniform1ivARB(0), pGlUniform1fvARB(0), pGlUniform2fvARB(0), pGlUniform3fvARB(0), pGlUniform4fvARB(0), pGlUniformMatrix2fvARB(0), + pGlUniformMatrix3fvARB(0), pGlUniformMatrix4fvARB(0), pGlGetActiveUniformARB(0), pGlPointParameterfARB(0), pGlPointParameterfvARB(0), + pGlStencilFuncSeparate(0), pGlStencilOpSeparate(0), + pGlStencilFuncSeparateATI(0), pGlStencilOpSeparateATI(0), + #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC + pGlCompressedTexImage2D(0), + #endif // PFNGLCOMPRESSEDTEXIMAGE2DPROC +#endif // _IRR_OPENGL_USE_EXTPOINTER_ + wglSwapIntervalEXT(0), + pGlBindFramebufferEXT(0), pGlDeleteFramebuffersEXT(0), pGlGenFramebuffersEXT(0), + pGlCheckFramebufferStatusEXT(0), pGlFramebufferTexture2DEXT(0), + pGlBindRenderbufferEXT(0), pGlDeleteRenderbuffersEXT(0), pGlGenRenderbuffersEXT(0), + pGlRenderbufferStorageEXT(0), pGlFramebufferRenderbufferEXT(0), + HDc(0), Window(window), HRc(0) +{ + #ifdef _DEBUG + setDebugName("COpenGLDriver"); + #endif +} + +//! inits the open gl driver +bool COpenGLDriver::initDriver(const core::dimension2d& screenSize, + HWND window, u32 bits, bool fullscreen, bool vsync) +{ + static PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor + 1, // Version Number + PFD_DRAW_TO_WINDOW | // Format Must Support Window + PFD_SUPPORT_OPENGL | // Format Must Support OpenGL + PFD_DOUBLEBUFFER, // Must Support Double Buffering + PFD_TYPE_RGBA, // Request An RGBA Format + bits, // Select Our Color Depth + 0, 0, 0, 0, 0, 0, // Color Bits Ignored + 0, // No Alpha Buffer + 0, // Shift Bit Ignored + 0, // No Accumulation Buffer + 0, 0, 0, 0, // Accumulation Bits Ignored + 24, // Z-Buffer (Depth Buffer) + StencilBuffer ? 1 : 0, // Stencil Buffer Depth + 0, // No Auxiliary Buffer + PFD_MAIN_PLANE, // Main Drawing Layer + 0, // Reserved + 0, 0, 0 // Layer Masks Ignored + }; + + for (int i=0; i<5; ++i) + { + if (i == 1) + { + if (StencilBuffer) + os::Printer::log("Cannot create a GL device with stencil buffer, disabling stencil shadows.", ELL_WARNING); + StencilBuffer = false; + pfd.cStencilBits = 0; + } + else + if (i == 2) + { + pfd.cDepthBits = 24; + } + if (i == 3) // might be checked twice, but shouldn't matter + { + pfd.cDepthBits = 16; + } + else + if (i == 4) + { + os::Printer::log("Cannot create a GL device context.", ELL_ERROR); + return false; + } + + // get hdc + if (!(HDc=GetDC(window))) + { + os::Printer::log("Cannot create a GL device context.", ELL_ERROR); + continue; + } + + GLuint PixelFormat; + + // choose pixelformat + if (!(PixelFormat = ChoosePixelFormat(HDc, &pfd))) + { + os::Printer::log("Cannot find a suitable pixelformat.", ELL_ERROR); + continue; + } + + // set pixel format + if(!SetPixelFormat(HDc, PixelFormat, &pfd)) + { + os::Printer::log("Cannot set the pixel format.", ELL_ERROR); + continue; + } + + // create rendering context + if (!(HRc=wglCreateContext(HDc))) + { + os::Printer::log("Cannot create a GL rendering context.", ELL_ERROR); + continue; + } + + // activate rendering context + if(!wglMakeCurrent(HDc, HRc)) + { + os::Printer::log("Cannot activate GL rendering context", ELL_ERROR); + continue; + } + + break; + } + + genericDriverInit(screenSize); + + // set vsync + if (wglSwapIntervalEXT) + wglSwapIntervalEXT(vsync ? 1 : 0); + + // set exposed data + ExposedData.OpenGLWin32.HDc = reinterpret_cast(HDc); + ExposedData.OpenGLWin32.HRc = reinterpret_cast(HRc); + ExposedData.OpenGLWin32.HWnd = reinterpret_cast(Window); + + return true; +} + + + +//! win32 destructor +COpenGLDriver::~COpenGLDriver() +{ + deleteMaterialRenders(); + + // I get a blue screen on my laptop, when I do not delete the + // textures manually before releasing the dc. Oh how I love this. + + deleteAllTextures(); + + if (HRc) + { + if (!wglMakeCurrent(0, 0)) + os::Printer::log("Release of dc and rc failed.", ELL_WARNING); + + if (!wglDeleteContext(HRc)) + os::Printer::log("Release of rendering context failed.", ELL_WARNING); + + HRc = 0; + } + + if (HDc) + ReleaseDC(Window, HDc); + + HDc = 0; +} +#endif //IRR_WINDOWS + +// ----------------------------------------------------------------------- +// MACOSX CONSTRUCTOR +// ----------------------------------------------------------------------- +#ifdef MACOSX +//! Windows constructor and init code +COpenGLDriver::COpenGLDriver(const core::dimension2d& screenSize, bool fullscreen, bool stencilBuffer, CIrrDeviceMacOSX *device, io::IFileSystem* io, bool vsync, bool antiAlias) +: CNullDriver(io, screenSize), + CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), + StencilBuffer(stencilBuffer), AntiAlias(antiAlias), + MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false), + ARBVertexProgramExtension(false), ARBFragmentProgramExtension(false), + ARBShadingLanguage100Extension(false), SeparateStencilExtension(false), + GenerateMipmapExtension(false), TextureCompressionExtension(false), + TextureNPOTExtension(false), FramebufferObjectExtension(false), EXTPackedDepthStencil(false), + RenderTargetTexture(0), LastSetLight(-1), MaxAnisotropy(1), + MaxTextureUnits(1), MaxLights(1), + CurrentRendertargetSize(0,0), _device(device) +{ + #ifdef _DEBUG + setDebugName("COpenGLDriver"); + #endif + genericDriverInit(screenSize); +} + +COpenGLDriver::~COpenGLDriver() +{ + deleteAllTextures(); +} + +#endif + +// ----------------------------------------------------------------------- +// LINUX CONSTRUCTOR +// ----------------------------------------------------------------------- +#ifdef LINUX +//! Linux constructor and init code +COpenGLDriver::COpenGLDriver(const core::dimension2d& screenSize, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias) +: CNullDriver(io, screenSize), + CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), + StencilBuffer(stencilBuffer), AntiAlias(antiAlias), + MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false), + ARBVertexProgramExtension(false), ARBFragmentProgramExtension(false), + ARBShadingLanguage100Extension(false), SeparateStencilExtension(false), + GenerateMipmapExtension(false), TextureCompressionExtension(false), + TextureNPOTExtension(false), FramebufferObjectExtension(false), EXTPackedDepthStencil(false), + RenderTargetTexture(0), LastSetLight(-1), MaxAnisotropy(1), + MaxTextureUnits(1), MaxLights(1), CurrentRendertargetSize(0,0) +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + ,pGlActiveTextureARB(0), pGlClientActiveTextureARB(0), + pGlGenProgramsARB(0), pGlBindProgramARB(0), pGlProgramStringARB(0), + pGlDeleteProgramsARB(0), pGlProgramLocalParameter4fvARB(0) + #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC + ,pGlCompressedTexImage2D(0) + #endif // PFNGLCOMPRESSEDTEXIMAGE2DPROC +#ifdef GLX_SGI_swap_control + ,glxSwapIntervalSGI(0) +#endif + ,pGlBindFramebufferEXT(0), pGlDeleteFramebuffersEXT(0), pGlGenFramebuffersEXT(0), + pGlCheckFramebufferStatusEXT(0), pGlFramebufferTexture2DEXT(0), + pGlBindRenderbufferEXT(0), pGlDeleteRenderbuffersEXT(0), pGlGenRenderbuffersEXT(0), + pGlRenderbufferStorageEXT(0), pGlFramebufferRenderbufferEXT(0) +#endif +{ + #ifdef _DEBUG + setDebugName("COpenGLDriver"); + #endif + XWindow = glXGetCurrentDrawable(); + XDisplay = glXGetCurrentDisplay(); + ExposedData.OpenGLLinux.Window = XWindow; + genericDriverInit(screenSize); + + // set vsync +#ifdef GLX_SGI_swap_control +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (vsync && glxSwapIntervalSGI) + glxSwapIntervalSGI(1); +#else + if (vsync) + glXSwapIntervalSGI(1); +#endif +#endif +} + +//! linux destructor +COpenGLDriver::~COpenGLDriver() +{ + deleteAllTextures(); +} + +#endif // LINUX + + + +// ----------------------------------------------------------------------- +// METHODS +// ----------------------------------------------------------------------- + +bool COpenGLDriver::genericDriverInit(const core::dimension2d& screenSize) +{ + Name=L"OpenGL "; + Name.append(glGetString(GL_VERSION)); + s32 pos=Name.findNext(L' ', 7); + if (pos != -1) + Name=Name.subString(0, pos); + printVersion(); + + // print renderer information + const GLubyte* renderer = glGetString(GL_RENDERER); + const GLubyte* vendor = glGetString(GL_VENDOR); + if (renderer && vendor) + { + os::Printer::log((const c8*)renderer, (const c8*)vendor, ELL_INFORMATION); + } + + for (u32 i=0; idrop(); + + // add remaining material renderer + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_DETAIL_MAP( this)); + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SPHERE_MAP( this)); + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_REFLECTION_2_LAYER( this)); + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR( this)); + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL( this)); + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF( this)); + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA( this)); + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER( this)); + + // add normal map renderers + s32 tmp = 0; + video::IMaterialRenderer* renderer = 0; + renderer = new COpenGLNormalMapRenderer(this, tmp, MaterialRenderers[EMT_SOLID].Renderer); + renderer->drop(); + renderer = new COpenGLNormalMapRenderer(this, tmp, MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); + renderer->drop(); + renderer = new COpenGLNormalMapRenderer(this, tmp, MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); + renderer->drop(); + + // add parallax map renderers + renderer = new COpenGLParallaxMapRenderer(this, tmp, MaterialRenderers[EMT_SOLID].Renderer); + renderer->drop(); + renderer = new COpenGLParallaxMapRenderer(this, tmp, MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); + renderer->drop(); + renderer = new COpenGLParallaxMapRenderer(this, tmp, MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); + renderer->drop(); + + // add basic 1 texture blending + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_ONETEXTURE_BLEND(this)); +} + +void COpenGLDriver::loadExtensions() +{ + if (atof((c8*)glGetString(GL_VERSION)) >= 1.2) + os::Printer::log("OpenGL driver version is 1.2 or better.", ELL_INFORMATION); + else + os::Printer::log("OpenGL driver version is not 1.2 or better.", ELL_WARNING); + + const GLubyte* t = glGetString(GL_EXTENSIONS); +// os::Printer::log((const c8*)t, ELL_INFORMATION); + #ifdef GLU_VERSION_1_3 + const GLubyte* gluVersion = gluGetString(GLU_VERSION); + + if (gluVersion[0]>1 || gluVersion[3]>2) + { + MultiTextureExtension = gluCheckExtension((const GLubyte*)"GL_ARB_multitexture", t); + MultiSamplingExtension = gluCheckExtension((const GLubyte*)"GL_ARB_multisample", t); + ARBVertexProgramExtension = gluCheckExtension((const GLubyte*)"GL_ARB_vertex_program", t); + ARBFragmentProgramExtension = gluCheckExtension((const GLubyte*)"GL_ARB_fragment_program", t); + ARBShadingLanguage100Extension = gluCheckExtension((const GLubyte*)"GL_ARB_shading_language_100", t); + AnisotropyExtension = gluCheckExtension((const GLubyte*)"GL_EXT_texture_filter_anisotropic", t); + SeparateStencilExtension = gluCheckExtension((const GLubyte*)"GL_ATI_separate_stencil", t); + SeparateStencilExtension = SeparateStencilExtension || gluCheckExtension((const GLubyte*)"GL_ARB_separate_stencil", t); + GenerateMipmapExtension = gluCheckExtension((const GLubyte*)"GL_SGIS_generate_mipmap", t); + TextureCompressionExtension = gluCheckExtension((const GLubyte*)"GL_ARB_texture_compression", t); + TextureNPOTExtension = gluCheckExtension((const GLubyte*)"GL_ARB_texture_non_power_of_two", t); + FramebufferObjectExtension = gluCheckExtension((const GLubyte*)"GL_EXT_framebuffer_object", t); + EXTPackedDepthStencil = gluCheckExtension((const GLubyte*)"GL_EXT_packed_depth_stencil", t); + EXTSeparateSpecularColor = gluCheckExtension((const GLubyte*)"GL_EXT_separate_specular_color", t); + } + else + #endif + { + s32 len = (s32)strlen((const char*)t); + c8 *str = new c8[len+1]; + c8* p = str; + + for (s32 i=0; i1) || (minor>3)) + IRR_OGL_LOAD_EXTENSION=glXGetProcAddress; + else + #endif + IRR_OGL_LOAD_EXTENSION=glXGetProcAddressARB; + #else + #define IRR_OGL_LOAD_EXTENSION glXGetProcAddressARB + #endif + + pGlActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glActiveTextureARB")); + + pGlClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glClientActiveTextureARB")); + + // get fragment and vertex program function pointers + pGlGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGenProgramsARB")); + + pGlBindProgramARB = (PFNGLBINDPROGRAMARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glBindProgramARB")); + + pGlProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glProgramStringARB")); + + pGlDeleteProgramsARB = (PFNGLDELETEPROGRAMSNVPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteProgramsARB")); + + pGlProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glProgramLocalParameter4fvARB")); + + pGlCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCreateShaderObjectARB")); + + pGlShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glShaderSourceARB")); + + pGlCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCompileShaderARB")); + + pGlCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCreateProgramObjectARB")); + + pGlAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glAttachObjectARB")); + + pGlLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glLinkProgramARB")); + + pGlUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUseProgramObjectARB")); + + pGlDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteObjectARB")); + + pGlGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetInfoLogARB")); + + pGlGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetObjectParameterivARB")); + + pGlGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetUniformLocationARB")); + + pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform4fvARB")); + + pGlUniform1ivARB = (PFNGLUNIFORM1IVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform1ivARB")); + + pGlUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform1fvARB")); + + pGlUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform2fvARB")); + + pGlUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform3fvARB")); + + pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform4fvARB")); + + pGlUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniformMatrix2fvARB")); + + pGlUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniformMatrix3fvARB")); + + pGlUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniformMatrix4fvARB")); + + pGlGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetActiveUniformARB")); + + // get point parameter extension + pGlPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glPointParameterfARB")); + pGlPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glPointParameterfvARB")); + + // get stencil extension + pGlStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilFuncSeparate")); + pGlStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilOpSeparate")); + pGlStencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilFuncSeparateATI")); + pGlStencilOpSeparateATI = (PFNGLSTENCILOPSEPARATEATIPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilOpSeparateATI")); + + #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC + pGlCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCompressedTexImage2D")); + #endif // PFNGLCOMPRESSEDTEXIMAGE2DPROC + +#ifdef GLX_SGI_swap_control + // get vsync extension + glxSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glXSwapIntervalSGI")); +#endif + + // FrameBufferObjects + pGlBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glBindFramebufferEXT")); + + pGlDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteFramebuffersEXT")); + + pGlGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGenFramebuffersEXT")); + + pGlCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCheckFramebufferStatusEXT")); + + pGlFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glFramebufferTexture2DEXT")); + + pGlBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glBindRenderbufferEXT")); + + pGlDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteRenderbuffersEXT")); + + pGlGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGenRenderbuffersEXT")); + + pGlRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glRenderbufferStorageEXT")); + + pGlFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glFramebufferRenderbufferEXT")); + + #endif // _IRR_OPENGL_USE_EXTPOINTER_ + #endif // _IRR_WINDOWS_ + + // load common extensions + + glGetIntegerv(GL_MAX_TEXTURE_UNITS, &MaxTextureUnits); + glGetIntegerv(GL_MAX_LIGHTS, &MaxLights); + glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &MaxAnisotropy); + } + +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (!pGlActiveTextureARB || !pGlClientActiveTextureARB) + { + MultiTextureExtension = false; + os::Printer::log("Failed to load OpenGL's multitexture extension, proceeding without.", ELL_WARNING); + } + else +#endif + if (MaxTextureUnits < 2) + { + MultiTextureExtension = false; + os::Printer::log("Warning: OpenGL device only has one texture unit. Disabling multitexturing.", ELL_WARNING); + } + MaxTextureUnits = core::min_((u32)MaxTextureUnits,MATERIAL_MAX_TEXTURES); + glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &MaxIndices); +} + + + +//! presents the rendered scene on the screen, returns false if failed +bool COpenGLDriver::endScene( s32 windowId, core::rect* sourceRect ) +{ + CNullDriver::endScene( windowId ); + +#ifdef _IRR_WINDOWS_ + return SwapBuffers(HDc) == TRUE; +#endif + +#ifdef LINUX + glXSwapBuffers(XDisplay, XWindow); + return true; +#endif + +#ifdef MACOSX + _device->flush(); + return true; +#endif +} + + + +//! clears the zbuffer +bool COpenGLDriver::beginScene(bool backBuffer, bool zBuffer, SColor color) +{ + CNullDriver::beginScene(backBuffer, zBuffer, color); + + GLbitfield mask = 0; + + if (backBuffer) + { + f32 inv = 1.0f / 255.0f; + glClearColor(color.getRed() * inv, color.getGreen() * inv, + color.getBlue() * inv, color.getAlpha() * inv); + + mask |= GL_COLOR_BUFFER_BIT; + } + + if (zBuffer) + { + glDepthMask(GL_TRUE); + mask |= GL_DEPTH_BUFFER_BIT; + } + + glClear(mask); + return true; +} + + + +//! Returns the transformation set by setTransform +const core::matrix4& COpenGLDriver::getTransform(E_TRANSFORMATION_STATE state) +{ + return Matrices[state]; +} + + + +//! sets transformation +void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) +{ + GLfloat glmat[16]; + Matrices[state] = mat; + Transformation3DChanged = true; + + switch(state) + { + case ETS_VIEW: + case ETS_WORLD: + // OpenGL only has a model matrix, view and world is not existent. so lets fake these two. + createGLMatrix(glmat, Matrices[ETS_VIEW] * Matrices[ETS_WORLD]); + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(glmat); + break; + case ETS_PROJECTION: + createGLMatrix(glmat, mat); + // flip z to compensate OpenGLs right-hand coordinate system + glmat[12] *= -1.0f; + glMatrixMode(GL_PROJECTION); + glLoadMatrixf(glmat); + break; + case ETS_TEXTURE_0: + case ETS_TEXTURE_1: + case ETS_TEXTURE_2: + case ETS_TEXTURE_3: + if (mat.isIdentity()) + return; + + if (MultiTextureExtension) + extGlActiveTextureARB(GL_TEXTURE0_ARB + ( state - ETS_TEXTURE_0 )); + + glMatrixMode(GL_TEXTURE); + createGLTextureMatrix(glmat, mat ); + glLoadMatrixf(glmat); + break; + default: + break; + } +} + + + +//! draws a vertex primitive list +void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) +{ + if (!primitiveCount || !vertexCount) + return; + + if (!checkPrimitiveCount(primitiveCount)) + return; + + CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType); + + // convert colors to gl color format. + vertexCount *= 4; //reused as color component count + ColorBuffer.set_used(vertexCount); + u32 i; + + switch (vType) + { + case EVT_STANDARD: + { + const S3DVertex* p = (const S3DVertex*)vertices; + for ( i=0; iColor.toOpenGLColor(&ColorBuffer[i]); + ++p; + } + } + break; + case EVT_2TCOORDS: + { + const S3DVertex2TCoords* p = (const S3DVertex2TCoords*)vertices; + for ( i=0; iColor.toOpenGLColor(&ColorBuffer[i]); + ++p; + } + } + break; + case EVT_TANGENTS: + { + const S3DVertexTangents* p = (const S3DVertexTangents*)vertices; + for ( i=0; iColor.toOpenGLColor(&ColorBuffer[i]); + ++p; + } + } + break; + } + + // draw everything + + setRenderStates3DMode(); + + if (MultiTextureExtension) + extGlClientActiveTextureARB(GL_TEXTURE0_ARB); + + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); + if (pType!=scene::EPT_POINTS) + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + if (pType!=scene::EPT_POINTS) + glEnableClientState(GL_NORMAL_ARRAY); + + glColorPointer(4, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); + switch (vType) + { + case EVT_STANDARD: + glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), &((S3DVertex*)vertices)[0].Pos); + glNormalPointer(GL_FLOAT, sizeof(S3DVertex), &((S3DVertex*)vertices)[0].Normal); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &((S3DVertex*)vertices)[0].TCoords); + break; + case EVT_2TCOORDS: + glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].Pos); + glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].Normal); + // texture coordinates + if (MultiTextureExtension) + { + extGlClientActiveTextureARB(GL_TEXTURE1_ARB); + glEnableClientState ( GL_TEXTURE_COORD_ARRAY ); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].TCoords2); + extGlClientActiveTextureARB(GL_TEXTURE0_ARB); + } + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].TCoords); + break; + case EVT_TANGENTS: + glVertexPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Pos); + glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Normal); + // texture coordinates + if (MultiTextureExtension) + { + extGlClientActiveTextureARB(GL_TEXTURE1_ARB); + glEnableClientState ( GL_TEXTURE_COORD_ARRAY ); + glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Tangent); + + extGlClientActiveTextureARB(GL_TEXTURE2_ARB); + glEnableClientState ( GL_TEXTURE_COORD_ARRAY ); + glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Binormal); + + extGlClientActiveTextureARB(GL_TEXTURE0_ARB); + } + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].TCoords); + break; + } + + switch (pType) + { + case scene::EPT_POINTS: + glDrawArrays(GL_POINTS, 0, primitiveCount); + break; + case scene::EPT_LINE_STRIP: + glDrawElements(GL_LINE_STRIP, primitiveCount+1, GL_UNSIGNED_SHORT, indexList); + break; + case scene::EPT_LINE_LOOP: + glDrawElements(GL_LINE_LOOP, primitiveCount, GL_UNSIGNED_SHORT, indexList); + break; + case scene::EPT_LINES: + glDrawElements(GL_LINES, primitiveCount*2, GL_UNSIGNED_SHORT, indexList); + break; + case scene::EPT_TRIANGLE_STRIP: + glDrawElements(GL_TRIANGLE_STRIP, primitiveCount+2, GL_UNSIGNED_SHORT, indexList); + break; + case scene::EPT_TRIANGLE_FAN: + glDrawElements(GL_TRIANGLE_FAN, primitiveCount+2, GL_UNSIGNED_SHORT, indexList); + break; + case scene::EPT_TRIANGLES: + glDrawElements(GL_TRIANGLES, primitiveCount*3, GL_UNSIGNED_SHORT, indexList); + break; + case scene::EPT_QUAD_STRIP: + glDrawElements(GL_QUAD_STRIP, primitiveCount*2+2, GL_UNSIGNED_SHORT, indexList); + break; + case scene::EPT_QUADS: + glDrawElements(GL_QUADS, primitiveCount*4, GL_UNSIGNED_SHORT, indexList); + break; + case scene::EPT_POLYGON: + glDrawElements(GL_POLYGON, primitiveCount, GL_UNSIGNED_SHORT, indexList); + break; + } + + glFlush(); + + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + if (MultiTextureExtension) + { + if (vType==EVT_TANGENTS) + { + extGlClientActiveTextureARB(GL_TEXTURE2_ARB); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + if (vType!=EVT_STANDARD && MultiTextureExtension) + { + extGlClientActiveTextureARB(GL_TEXTURE1_ARB); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + extGlClientActiveTextureARB(GL_TEXTURE0_ARB); + } + glDisableClientState(GL_TEXTURE_COORD_ARRAY); +} + + + +//! draws a 2d image, using a color and the alpha channel of the texture if +//! desired. The image is drawn at pos, clipped against clipRect (if != 0). +//! Only the subtexture defined by sourceRect is used. +void COpenGLDriver::draw2DImage(video::ITexture* texture, + const core::position2d& pos, + const core::rect& sourceRect, + const core::rect* clipRect, SColor color, + bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + if (!sourceRect.isValid()) + return; + + disableTextures(1); + if (!setTexture(0, texture)) + return; + + core::position2d targetPos(pos); + core::position2d sourcePos(sourceRect.UpperLeftCorner); + core::dimension2d sourceSize(sourceRect.getSize()); + const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); + if (clipRect) + { + if (targetPos.X < clipRect->UpperLeftCorner.X) + { + sourceSize.Width += targetPos.X - clipRect->UpperLeftCorner.X; + if (sourceSize.Width <= 0) + return; + + sourcePos.X -= targetPos.X - clipRect->UpperLeftCorner.X; + targetPos.X = clipRect->UpperLeftCorner.X; + } + + if (targetPos.X + sourceSize.Width > clipRect->LowerRightCorner.X) + { + sourceSize.Width -= (targetPos.X + sourceSize.Width) - clipRect->LowerRightCorner.X; + if (sourceSize.Width <= 0) + return; + } + + if (targetPos.Y < clipRect->UpperLeftCorner.Y) + { + sourceSize.Height += targetPos.Y - clipRect->UpperLeftCorner.Y; + if (sourceSize.Height <= 0) + return; + + sourcePos.Y -= targetPos.Y - clipRect->UpperLeftCorner.Y; + targetPos.Y = clipRect->UpperLeftCorner.Y; + } + + if (targetPos.Y + sourceSize.Height > clipRect->LowerRightCorner.Y) + { + sourceSize.Height -= (targetPos.Y + sourceSize.Height) - clipRect->LowerRightCorner.Y; + if (sourceSize.Height <= 0) + return; + } + } + + // clip these coordinates + + if (targetPos.X<0) + { + sourceSize.Width += targetPos.X; + if (sourceSize.Width <= 0) + return; + + sourcePos.X -= targetPos.X; + targetPos.X = 0; + } + + if (targetPos.X + sourceSize.Width > renderTargetSize.Width) + { + sourceSize.Width -= (targetPos.X + sourceSize.Width) - renderTargetSize.Width; + if (sourceSize.Width <= 0) + return; + } + + if (targetPos.Y<0) + { + sourceSize.Height += targetPos.Y; + if (sourceSize.Height <= 0) + return; + + sourcePos.Y -= targetPos.Y; + targetPos.Y = 0; + } + + if (targetPos.Y + sourceSize.Height > renderTargetSize.Height) + { + sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height; + if (sourceSize.Height <= 0) + return; + } + + // ok, we've clipped everything. + // now draw it. + + const core::dimension2d& ss = texture->getOriginalSize(); + core::rect tcoords; + + tcoords.UpperLeftCorner.X = (f32)sourcePos.X / (f32)ss.Width; + tcoords.UpperLeftCorner.Y = (f32)sourcePos.Y / (f32)ss.Height; + tcoords.LowerRightCorner.X = ((f32)sourcePos.X +(f32)sourceSize.Width) / (f32)ss.Width; + tcoords.LowerRightCorner.Y = ((f32)sourcePos.Y + (f32)sourceSize.Height) / (f32)ss.Height; + + core::rect poss(targetPos, sourceSize); + core::rect npos; + f32 xFact = 2.0f / ( renderTargetSize.Width ); + f32 yFact = 2.0f / ( renderTargetSize.Height ); + + npos.UpperLeftCorner.X = ( poss.UpperLeftCorner.X * xFact ) - 1.0f; + npos.UpperLeftCorner.Y = 1.0f - ( poss.UpperLeftCorner.Y * yFact ); + npos.LowerRightCorner.X = ( poss.LowerRightCorner.X * xFact ) - 1.0f; + npos.LowerRightCorner.Y = 1.0f - ( poss.LowerRightCorner.Y * yFact ); + + setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); + + glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); + glBegin(GL_QUADS); + + glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); + glVertex2f(npos.UpperLeftCorner.X, npos.UpperLeftCorner.Y); + + glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); + glVertex2f(npos.LowerRightCorner.X, npos.UpperLeftCorner.Y); + + glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); + glVertex2f(npos.LowerRightCorner.X, npos.LowerRightCorner.Y); + + glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); + glVertex2f(npos.UpperLeftCorner.X, npos.LowerRightCorner.Y); + + glEnd(); +} + + + +//! draws a set of 2d images, using a color and the alpha channel of the +//! texture if desired. The images are drawn beginning at pos and concatenated +//! in one line. All drawings are clipped against clipRect (if != 0). +//! The subtextures are defined by the array of sourceRects and are chosen +//! by the indices given. +void COpenGLDriver::draw2DImage(video::ITexture* texture, + const core::position2d& pos, + const core::array >& sourceRects, + const core::array& indices, + const core::rect* clipRect, SColor color, + bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + disableTextures(1); + if (!setTexture(0, texture)) + return; + + const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); + setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); + glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); + if (clipRect) + { + glEnable(GL_SCISSOR_TEST); + glScissor(clipRect->UpperLeftCorner.X,renderTargetSize.Height-clipRect->LowerRightCorner.Y, + clipRect->getWidth(),clipRect->getHeight()); + } + + const core::dimension2d& ss = texture->getOriginalSize(); + core::position2d targetPos(pos); + core::position2d sourcePos; + core::dimension2d sourceSize; + core::rect tcoords; + f32 xFact = 2.0f / ( renderTargetSize.Width ); + f32 yFact = 2.0f / ( renderTargetSize.Height ); + + for (u32 i=0; i poss(targetPos, sourceSize); + core::rect npos; + + npos.UpperLeftCorner.X = ( poss.UpperLeftCorner.X * xFact ) - 1.0f; + npos.UpperLeftCorner.Y = 1.0f - ( poss.UpperLeftCorner.Y * yFact ); + + npos.LowerRightCorner.X = ( poss.LowerRightCorner.X * xFact ) - 1.0f; + npos.LowerRightCorner.Y = 1.0f - ( poss.LowerRightCorner.Y * yFact ); + + glBegin(GL_QUADS); + + glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); + glVertex2f(npos.UpperLeftCorner.X, npos.UpperLeftCorner.Y); + + glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); + glVertex2f(npos.LowerRightCorner.X, npos.UpperLeftCorner.Y); + + glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); + glVertex2f(npos.LowerRightCorner.X, npos.LowerRightCorner.Y); + + glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); + glVertex2f(npos.UpperLeftCorner.X, npos.LowerRightCorner.Y); + + glEnd(); + targetPos.X += sourceRects[currentIndex].getWidth(); + } + if (clipRect) + glDisable(GL_SCISSOR_TEST); +} + + + +void COpenGLDriver::draw2DImage(video::ITexture* texture, const core::rect& destRect, + const core::rect& sourceRect, const core::rect* clipRect, + video::SColor* colors, bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + const core::dimension2d& ss = texture->getOriginalSize(); + core::rect tcoords; + tcoords.UpperLeftCorner.X = (f32)sourceRect.UpperLeftCorner.X / (f32)ss.Width; + tcoords.UpperLeftCorner.Y = (f32)sourceRect.UpperLeftCorner.Y / (f32)ss.Height; + tcoords.LowerRightCorner.X = (f32)sourceRect.LowerRightCorner.X / (f32)ss.Width; + tcoords.LowerRightCorner.Y = (f32)sourceRect.LowerRightCorner.Y / (f32)ss.Height; + + const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); + core::rect npos; + f32 xFact = 2.0f / ( renderTargetSize.Width ); + f32 yFact = 2.0f / ( renderTargetSize.Height ); + npos.UpperLeftCorner.X = ( destRect.UpperLeftCorner.X * xFact ) - 1.0f; + npos.UpperLeftCorner.Y = 1.0f - ( destRect.UpperLeftCorner.Y * yFact ); + npos.LowerRightCorner.X = ( destRect.LowerRightCorner.X * xFact ) - 1.0f; + npos.LowerRightCorner.Y = 1.0f - ( destRect.LowerRightCorner.Y * yFact ); + + video::SColor temp[4] = + { + 0xFFFFFFFF, + 0xFFFFFFFF, + 0xFFFFFFFF, + 0xFFFFFFFF + }; + + video::SColor* useColor = colors ? colors : temp; + + setRenderStates2DMode(useColor[0].getAlpha()<255 || useColor[1].getAlpha()<255 || useColor[2].getAlpha()<255 || useColor[3].getAlpha()<255, true, useAlphaChannelOfTexture); + + disableTextures(1); + setTexture(0, texture); + + glBegin(GL_QUADS); + + glColor4ub(useColor[0].getRed(), useColor[0].getGreen(), useColor[0].getBlue(), useColor[0].getAlpha()); + glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); + glVertex2f(npos.UpperLeftCorner.X, npos.UpperLeftCorner.Y); + + glColor4ub(useColor[3].getRed(), useColor[3].getGreen(), useColor[3].getBlue(), useColor[3].getAlpha()); + glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); + glVertex2f(npos.LowerRightCorner.X, npos.UpperLeftCorner.Y); + + glColor4ub(useColor[2].getRed(), useColor[2].getGreen(), useColor[2].getBlue(), useColor[2].getAlpha()); + glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); + glVertex2f(npos.LowerRightCorner.X, npos.LowerRightCorner.Y); + + glColor4ub(useColor[1].getRed(), useColor[1].getGreen(), useColor[1].getBlue(), useColor[1].getAlpha()); + glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); + glVertex2f(npos.UpperLeftCorner.X, npos.LowerRightCorner.Y); + + glEnd(); +} + + + +//! draw a 2d rectangle +void COpenGLDriver::draw2DRectangle(SColor color, const core::rect& position, + const core::rect* clip) +{ + setRenderStates2DMode(color.getAlpha() < 255, false, false); + disableTextures(); + + core::rect pos = position; + + if (clip) + pos.clipAgainst(*clip); + + if (!pos.isValid()) + return; + + const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); + s32 xPlus = renderTargetSize.Width>>1; + f32 xFact = 1.0f / (renderTargetSize.Width>>1); + + s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); + f32 yFact = 1.0f / (renderTargetSize.Height>>1); + + glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); + glRectf((pos.UpperLeftCorner.X-xPlus) * xFact, + (yPlus-pos.UpperLeftCorner.Y) * yFact, + (pos.LowerRightCorner.X-xPlus) * xFact, + (yPlus-pos.LowerRightCorner.Y) * yFact); +} + + + +//! draw an 2d rectangle +void COpenGLDriver::draw2DRectangle(const core::rect& position, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect* clip) +{ + core::rect pos = position; + + if (clip) + pos.clipAgainst(*clip); + + if (!pos.isValid()) + return; + + const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); + s32 xPlus = renderTargetSize.Width>>1; + f32 xFact = 1.0f / (renderTargetSize.Width>>1); + + s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); + f32 yFact = 1.0f / (renderTargetSize.Height>>1); + + core::rect npos; + npos.UpperLeftCorner.X = (f32)(pos.UpperLeftCorner.X-xPlus) * xFact; + npos.UpperLeftCorner.Y = (f32)(yPlus-pos.UpperLeftCorner.Y) * yFact; + npos.LowerRightCorner.X = (f32)(pos.LowerRightCorner.X-xPlus) * xFact; + npos.LowerRightCorner.Y = (f32)(yPlus-pos.LowerRightCorner.Y) * yFact; + + setRenderStates2DMode(colorLeftUp.getAlpha() < 255 || + colorRightUp.getAlpha() < 255 || + colorLeftDown.getAlpha() < 255 || + colorRightDown.getAlpha() < 255, false, false); + + disableTextures(); + + glBegin(GL_QUADS); + glColor4ub(colorLeftUp.getRed(), colorLeftUp.getGreen(), + colorLeftUp.getBlue(), colorLeftUp.getAlpha()); + glVertex2f(npos.UpperLeftCorner.X, npos.UpperLeftCorner.Y); + + glColor4ub(colorRightUp.getRed(), colorRightUp.getGreen(), + colorRightUp.getBlue(), colorRightUp.getAlpha()); + glVertex2f(npos.LowerRightCorner.X, npos.UpperLeftCorner.Y); + + glColor4ub(colorRightDown.getRed(), colorRightDown.getGreen(), + colorRightDown.getBlue(), colorRightDown.getAlpha()); + glVertex2f(npos.LowerRightCorner.X, npos.LowerRightCorner.Y); + + glColor4ub(colorLeftDown.getRed(), colorLeftDown.getGreen(), + colorLeftDown.getBlue(), colorLeftDown.getAlpha()); + glVertex2f(npos.UpperLeftCorner.X, npos.LowerRightCorner.Y); + + glEnd(); +} + + + +//! Draws a 2d line. +void COpenGLDriver::draw2DLine(const core::position2d& start, + const core::position2d& end, + SColor color) +{ + // thanks to Vash TheStampede who sent in his implementation + + const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); + const s32 xPlus = renderTargetSize.Width>>1; + const f32 xFact = 1.0f / (renderTargetSize.Width>>1); + + const s32 yPlus = + renderTargetSize.Height-(renderTargetSize.Height>>1); + const f32 yFact = 1.0f / (renderTargetSize.Height>>1); + + core::position2d npos_start; + npos_start.X = (f32)(start.X - xPlus) * xFact; + npos_start.Y = (f32)(yPlus - start.Y) * yFact; + + core::position2d npos_end; + npos_end.X = (f32)(end.X - xPlus) * xFact; + npos_end.Y = (f32)(yPlus - end.Y) * yFact; + + setRenderStates2DMode(color.getAlpha() < 255, false, false); + disableTextures(); + + glBegin(GL_LINES); + glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); + glVertex2f(npos_start.X, npos_start.Y); + glVertex2f(npos_end.X, npos_end.Y); + glEnd(); +} + + + +//! queries the features of the driver, returns true if feature is available +bool COpenGLDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) +{ + switch (feature) + { + case EVDF_RENDER_TO_TARGET: + return true; + case EVDF_MULTITEXTURE: + return MultiTextureExtension; + case EVDF_BILINEAR_FILTER: + return true; + case EVDF_MIP_MAP: + return true; + case EVDF_MIP_MAP_AUTO_UPDATE: + return GenerateMipmapExtension; + case EVDF_STENCIL_BUFFER: + return StencilBuffer; + case EVDF_ARB_VERTEX_PROGRAM_1: + return ARBVertexProgramExtension; + case EVDF_ARB_FRAGMENT_PROGRAM_1: + return ARBFragmentProgramExtension; + case EVDF_ARB_GLSL: + return ARBShadingLanguage100Extension; + case EVDF_TEXTURE_NPOT: + return TextureNPOTExtension; + case EVDF_FRAMEBUFFER_OBJECT: + return FramebufferObjectExtension; + default: + return false; + }; +} + + + +//! sets the current Texture +bool COpenGLDriver::setTexture(s32 stage, video::ITexture* texture) +{ + if (stage >= MaxTextureUnits) + return false; + +// Not working, texture confusion in menu of Meshviewer. + if (CurrentTexture[stage]==texture) + return true; + + if (MultiTextureExtension) + extGlActiveTextureARB(GL_TEXTURE0_ARB + stage); + + CurrentTexture[stage]=texture; + + if (texture == 0) + { + glDisable(GL_TEXTURE_2D); + return true; + } + else + { + if (texture->getDriverType() != EDT_OPENGL) + { + glDisable(GL_TEXTURE_2D); + os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); + return false; + } + + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, + ((COpenGLTexture*)texture)->getOpenGLTextureName()); + } + return true; +} + + + +//! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled. +//! Returns whether disabling was successful or not. +bool COpenGLDriver::disableTextures(s32 fromStage) +{ + bool result=true; + for (s32 i=fromStage; i= 0 && LastMaterial.MaterialType < (s32)MaterialRenderers.size()) + MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); + + // set new material. + if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial( + Material, LastMaterial, ResetRenderStates, this); + + LastMaterial = Material; + ResetRenderStates = false; + } + + if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, video::EVT_STANDARD); + + CurrentRenderMode = ERM_3D; +} + + +//! Can be called by an IMaterialRenderer to make its work easier. +void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, + bool resetAllRenderStates) +{ + if (resetAllRenderStates || + lastmaterial.AmbientColor != material.AmbientColor || + lastmaterial.DiffuseColor != material.DiffuseColor || + lastmaterial.SpecularColor != material.SpecularColor || + lastmaterial.EmissiveColor != material.EmissiveColor || + lastmaterial.Shininess != material.Shininess) + { + GLfloat color[4]; + + const f32 inv = 1.0f / 255.0f; + + color[0] = material.AmbientColor.getRed() * inv; + color[1] = material.AmbientColor.getGreen() * inv; + color[2] = material.AmbientColor.getBlue() * inv; + color[3] = material.AmbientColor.getAlpha() * inv; + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color); + + color[0] = material.DiffuseColor.getRed() * inv; + color[1] = material.DiffuseColor.getGreen() * inv; + color[2] = material.DiffuseColor.getBlue() * inv; + color[3] = material.DiffuseColor.getAlpha() * inv; + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color); + + // disable Specular colors if no shininess is set + if (material.Shininess != 0.0f) + { +#ifdef GL_EXT_separate_specular_color + if (EXTSeparateSpecularColor) + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); +#endif + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess); + color[0] = material.SpecularColor.getRed() * inv; + color[1] = material.SpecularColor.getGreen() * inv; + color[2] = material.SpecularColor.getBlue() * inv; + color[3] = material.SpecularColor.getAlpha() * inv; + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color); + } +#ifdef GL_EXT_separate_specular_color + else + if (EXTSeparateSpecularColor) + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); +#endif + + color[0] = material.EmissiveColor.getRed() * inv; + color[1] = material.EmissiveColor.getGreen() * inv; + color[2] = material.EmissiveColor.getBlue() * inv; + color[3] = material.EmissiveColor.getAlpha() * inv; + glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color); + } + + // Texture filter + // Has to be checked always because it depends on the textures + // Filtering has to be set for each texture layer + for (s32 i=0; i0) + break; + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + (material.BilinearFilter || material.TrilinearFilter) ? GL_LINEAR : GL_NEAREST); + + if (material.Textures[i] && material.Textures[i]->hasMipMaps()) + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + material.TrilinearFilter ? GL_LINEAR_MIPMAP_LINEAR : material.BilinearFilter ? GL_LINEAR_MIPMAP_NEAREST : GL_NEAREST_MIPMAP_NEAREST ); + else + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + (material.BilinearFilter || material.TrilinearFilter) ? GL_LINEAR : GL_NEAREST); + + if (AnisotropyExtension) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, + material.AnisotropicFilter ? MaxAnisotropy : 1.0f ); + } + + // fillmode + if (resetAllRenderStates || lastmaterial.Wireframe != material.Wireframe || lastmaterial.PointCloud != material.PointCloud) + glPolygonMode(GL_FRONT_AND_BACK, material.Wireframe ? GL_LINE : material.PointCloud? GL_POINT : GL_FILL); + + // shademode + + if (resetAllRenderStates || lastmaterial.GouraudShading != material.GouraudShading) + { + if (material.GouraudShading) + glShadeModel(GL_SMOOTH); + else + glShadeModel(GL_FLAT); + } + + // lighting + + if (resetAllRenderStates || lastmaterial.Lighting != material.Lighting) + { + if (material.Lighting) + glEnable(GL_LIGHTING); + else + glDisable(GL_LIGHTING); + } + + // zbuffer + if (resetAllRenderStates || lastmaterial.ZBuffer != material.ZBuffer) + { + switch (material.ZBuffer) + { + case 0: + glDisable(GL_DEPTH_TEST); + break; + case 1: + glEnable(GL_DEPTH_TEST); + glDepthFunc ( GL_LEQUAL ); + break; + case 2: + glEnable(GL_DEPTH_TEST); + glDepthFunc ( GL_EQUAL ); + break; + } + } + + // zwrite + if (resetAllRenderStates || lastmaterial.ZWriteEnable != material.ZWriteEnable) + { + if (material.ZWriteEnable) + { + glDepthMask(GL_TRUE); + } + else + glDepthMask(GL_FALSE); + } + + // back face culling + + if (resetAllRenderStates || lastmaterial.BackfaceCulling != material.BackfaceCulling) + { + if (material.BackfaceCulling) + glEnable(GL_CULL_FACE); + else + glDisable(GL_CULL_FACE); + } + + // fog + if (resetAllRenderStates || lastmaterial.FogEnable != material.FogEnable) + { + if (material.FogEnable) + glEnable(GL_FOG); + else + glDisable(GL_FOG); + } + + // normalization + if (resetAllRenderStates || lastmaterial.NormalizeNormals != material.NormalizeNormals) + { + if (material.NormalizeNormals) + glEnable(GL_NORMALIZE); + else + glDisable(GL_NORMALIZE); + } + + // thickness + if (resetAllRenderStates || lastmaterial.Thickness != material.Thickness) + { + glPointSize(material.Thickness); + glLineWidth(material.Thickness); + } + + // texture address mode + for (s32 u=0; u0) + break; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mode); + } + } +} + + + +//! sets the needed renderstates +void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) +{ + if (CurrentRenderMode != ERM_2D || Transformation3DChanged) + { + // unset last 3d material + if (CurrentRenderMode == ERM_3D && Material.MaterialType >= 0 && + Material.MaterialType < (s32)MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + + Transformation3DChanged = false; + + glDisable(GL_DEPTH_TEST); + glDisable(GL_FOG); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glDisable(GL_LIGHTING); + + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + + glDisable(GL_ALPHA_TEST); + glCullFace(GL_BACK); + } + + if (texture) + { + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + + if (alphaChannel) + { + if (alpha) + { + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PRIMARY_COLOR_EXT); + } + else + { + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); + } + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); + } + else + { + if (alpha) + { + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT); + glDisable(GL_ALPHA_TEST); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + } + else + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glDisable(GL_ALPHA_TEST); + glDisable(GL_BLEND); + } + } + + } + else + { + if (alpha) + { + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glDisable(GL_ALPHA_TEST); + } + else + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + } + } + + CurrentRenderMode = ERM_2D; +} + + +//! \return Returns the name of the video driver. Example: In case of the Direct3D8 +//! driver, it would return "Direct3D8.1". +const wchar_t* COpenGLDriver::getName() +{ + return Name.c_str(); +} + + +//! deletes all dynamic lights there are +void COpenGLDriver::deleteAllDynamicLights() +{ + for (s32 i=0; i& area) +{ + core::rect vp = area; + core::rect rendert(0,0, getCurrentRenderTargetSize().Width, getCurrentRenderTargetSize().Height); + vp.clipAgainst(rendert); + + if (vp.getHeight()>0 && vp.getWidth()>0) + glViewport(vp.UpperLeftCorner.X, + getCurrentRenderTargetSize().Height - vp.UpperLeftCorner.Y - vp.getHeight(), + vp.getWidth(), vp.getHeight()); + + ViewPort = vp; +} + +//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do +//! this: First, draw all geometry. Then use this method, to draw the shadow +//! volume. Next use IVideoDriver::drawStencilShadow() to visualize the shadow. +void COpenGLDriver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail) +{ + if (!StencilBuffer || !count) + return; + + // unset last 3d material + if (CurrentRenderMode == ERM_3D && + Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) + { + MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); + ResetRenderStates = true; + } + + // store current OpenGL state + glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | + GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT); + + glDisable(GL_LIGHTING); + glDisable(GL_FOG); + glDepthMask(GL_FALSE); // no depth buffer writing + glDepthFunc(GL_LEQUAL); + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); // no color buffer drawing + glEnable(GL_STENCIL_TEST); + glStencilFunc(GL_ALWAYS, 0, 0); + glEnable(GL_CULL_FACE); + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3,GL_FLOAT,sizeof(core::vector3df),&triangles[0]); + + if (!zfail) + { + // ZPASS Method + + glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); + glCullFace(GL_BACK); + glDrawArrays(GL_TRIANGLES,0,count); + + glStencilOp(GL_KEEP, GL_KEEP, GL_DECR); + glCullFace(GL_FRONT); + glDrawArrays(GL_TRIANGLES,0,count); + } + else + { + // ZFAIL Method + + glStencilOp(GL_KEEP, GL_INCR, GL_KEEP); + glCullFace(GL_FRONT); + glDrawArrays(GL_TRIANGLES,0,count); + + glStencilOp(GL_KEEP, GL_DECR, GL_KEEP); + glCullFace(GL_BACK); + glDrawArrays(GL_TRIANGLES,0,count); + } + + glDisableClientState(GL_VERTEX_ARRAY); //not stored on stack + glPopAttrib(); +} + + + +void COpenGLDriver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge, + video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge) +{ + if (!StencilBuffer) + return; + + disableTextures(); + + // store attributes + glPushAttrib( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT ); + + glDisable( GL_LIGHTING ); + glDisable(GL_FOG); + glDepthMask(GL_FALSE); + glDepthFunc( GL_LEQUAL ); + + glFrontFace( GL_CCW ); + glShadeModel( GL_FLAT ); + glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glEnable( GL_STENCIL_TEST ); + glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFFL); + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + + // draw a shadow rectangle covering the entire screen using stencil buffer + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + glBegin(GL_TRIANGLE_STRIP); + + glColor4ub (leftUpEdge.getRed(), leftUpEdge.getGreen(), leftUpEdge.getBlue(), leftUpEdge.getAlpha() ); + glVertex3f(-1.1f, 1.1f,0.9f); + + glColor4ub (leftDownEdge.getRed(), leftDownEdge.getGreen(), leftDownEdge.getBlue(), leftDownEdge.getAlpha() ); + glVertex3f(-1.1f,-1.1f,0.9f); + + glColor4ub (rightUpEdge.getRed(), rightUpEdge.getGreen(), rightUpEdge.getBlue(), rightUpEdge.getAlpha() ); + glVertex3f( 1.1f, 1.1f,0.9f); + + glColor4ub (rightDownEdge.getRed(), rightDownEdge.getGreen(), rightDownEdge.getBlue(), rightDownEdge.getAlpha() ); + glVertex3f( 1.1f,-1.1f,0.9f); + + glEnd(); + + if (clearStencilBuffer) + glClear(GL_STENCIL_BUFFER_BIT); + + // restore settings + glPopMatrix(); + glPopAttrib(); +} + + +//! Sets the fog mode. +void COpenGLDriver::setFog(SColor c, bool linearFog, f32 start, + f32 end, f32 density, bool pixelFog, bool rangeFog) +{ + CNullDriver::setFog(c, linearFog, start, end, density, pixelFog, rangeFog); + + glFogi(GL_FOG_MODE, linearFog ? GL_LINEAR : GL_EXP); +#ifdef GL_EXT_fog_coord + glFogi(GL_FOG_COORDINATE_SOURCE, GL_FRAGMENT_DEPTH); +#endif + + if(linearFog) + { + glFogf(GL_FOG_START, start); + glFogf(GL_FOG_END, end); + } + else + glFogf(GL_FOG_DENSITY, density); + + SColorf color(c); + GLfloat data[4] = {color.r, color.g, color.b, color.a}; + glFogfv(GL_FOG_COLOR, data); +} + + + +//! Draws a 3d line. +void COpenGLDriver::draw3DLine(const core::vector3df& start, + const core::vector3df& end, SColor color) +{ + setRenderStates3DMode(); + + glBegin(GL_LINES); + glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); + glVertex3f(start.X, start.Y, start.Z); + + glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); + glVertex3f(end.X, end.Y, end.Z); + glEnd(); +} + + + +//! Only used by the internal engine. Used to notify the driver that +//! the window was resized. +void COpenGLDriver::OnResize(const core::dimension2d& size) +{ + CNullDriver::OnResize(size); + glViewport(0, 0, size.Width, size.Height); +} + + + +//! Returns type of video driver +E_DRIVER_TYPE COpenGLDriver::getDriverType() +{ + return EDT_OPENGL; +} + + + +void COpenGLDriver::extGlActiveTextureARB(GLenum texture) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (MultiTextureExtension && pGlActiveTextureARB) + pGlActiveTextureARB(texture); +#else + if (MultiTextureExtension) glActiveTextureARB(texture); +#endif +} + +void COpenGLDriver::extGlClientActiveTextureARB(GLenum texture) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (MultiTextureExtension && pGlClientActiveTextureARB) + pGlClientActiveTextureARB(texture); +#else + if (MultiTextureExtension) glClientActiveTextureARB(texture); +#endif +} + +void COpenGLDriver::extGlGenProgramsARB(GLsizei n, GLuint *programs) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlGenProgramsARB) + pGlGenProgramsARB(n, programs); +#elif defined(GL_ARB_vertex_program) + glGenProgramsARB(n,programs); +#else + os::Printer::log("glGenProgramsARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlBindProgramARB(GLenum target, GLuint program) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlBindProgramARB) + pGlBindProgramARB(target, program); +#elif defined(GL_ARB_vertex_program) + glBindProgramARB(target, program); +#else + os::Printer::log("glBindProgramARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid *string) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlProgramStringARB) + pGlProgramStringARB(target, format, len, string); +#elif defined(GL_ARB_vertex_program) + glProgramStringARB(target,format,len,string); +#else + os::Printer::log("glProgramStringARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlDeleteProgramsARB(GLsizei n, const GLuint *programs) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlDeleteProgramsARB) + pGlDeleteProgramsARB(n, programs); +#elif defined(GL_ARB_vertex_program) + glDeleteProgramsARB(n,programs); +#else + os::Printer::log("glDeleteProgramsARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlProgramLocalParameter4fvARB(GLenum n, GLuint i, const GLfloat * f) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlProgramLocalParameter4fvARB) + pGlProgramLocalParameter4fvARB(n,i,f); +#elif defined(GL_ARB_vertex_program) + glProgramLocalParameter4fvARB(n,i,f); +#else + os::Printer::log("glProgramLocalParameter4fvARB not supported", ELL_ERROR); +#endif +} + +GLhandleARB COpenGLDriver::extGlCreateShaderObjectARB(GLenum shaderType) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlCreateShaderObjectARB) + return pGlCreateShaderObjectARB(shaderType); +#elif defined(GL_ARB_shader_objects) + return glCreateShaderObjectARB(shaderType); +#else + os::Printer::log("glCreateShaderObjectARB not supported", ELL_ERROR); +#endif + return 0; +} + +void COpenGLDriver::extGlShaderSourceARB(GLhandleARB shader, int numOfStrings, const char **strings, int *lenOfStrings) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlShaderSourceARB) + pGlShaderSourceARB(shader, numOfStrings, strings, lenOfStrings); +#elif defined(GL_ARB_shader_objects) + glShaderSourceARB(shader, numOfStrings, strings, (GLint *)lenOfStrings); +#else + os::Printer::log("glShaderSourceARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlCompileShaderARB(GLhandleARB shader) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlCompileShaderARB) + pGlCompileShaderARB(shader); +#elif defined(GL_ARB_shader_objects) + glCompileShaderARB(shader); +#else + os::Printer::log("glCompileShaderARB not supported", ELL_ERROR); +#endif +} + +GLhandleARB COpenGLDriver::extGlCreateProgramObjectARB(void) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlCreateProgramObjectARB) + return pGlCreateProgramObjectARB(); +#elif defined(GL_ARB_shader_objects) + return glCreateProgramObjectARB(); +#else + os::Printer::log("glCreateProgramObjectARB not supported", ELL_ERROR); +#endif + return 0; +} + +void COpenGLDriver::extGlAttachObjectARB(GLhandleARB program, GLhandleARB shader) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlAttachObjectARB) + pGlAttachObjectARB(program, shader); +#elif defined(GL_ARB_shader_objects) + glAttachObjectARB(program, shader); +#else + os::Printer::log("glAttachObjectARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlLinkProgramARB(GLhandleARB program) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlLinkProgramARB) + pGlLinkProgramARB(program); +#elif defined(GL_ARB_shader_objects) + glLinkProgramARB(program); +#else + os::Printer::log("glLinkProgramARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlUseProgramObjectARB(GLhandleARB prog) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUseProgramObjectARB) + pGlUseProgramObjectARB(prog); +#elif defined(GL_ARB_shader_objects) + glUseProgramObjectARB(prog); +#else + os::Printer::log("glUseProgramObjectARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlDeleteObjectARB(GLhandleARB object) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlDeleteObjectARB) + pGlDeleteObjectARB(object); +#elif defined(GL_ARB_shader_objects) + glDeleteObjectARB(object); +#else + os::Printer::log("gldeleteObjectARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlGetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlGetInfoLogARB) + pGlGetInfoLogARB(object, maxLength, length, infoLog); +#elif defined(GL_ARB_shader_objects) + glGetInfoLogARB(object, maxLength, length, infoLog); +#else + os::Printer::log("glGetInfoLogARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlGetObjectParameterivARB(GLhandleARB object, GLenum type, int *param) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlGetObjectParameterivARB) + pGlGetObjectParameterivARB(object, type, param); +#elif defined(GL_ARB_shader_objects) + glGetObjectParameterivARB(object, type, (GLint *)param); +#else + os::Printer::log("glGetObjectParameterivARB not supported", ELL_ERROR); +#endif +} + +GLint COpenGLDriver::extGlGetUniformLocationARB(GLhandleARB program, const char *name) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlGetUniformLocationARB) + return pGlGetUniformLocationARB(program, name); +#elif defined(GL_ARB_shader_objects) + return glGetUniformLocationARB(program, name); +#else + os::Printer::log("glGetUniformLocationARB not supported", ELL_ERROR); +#endif + return 0; +} + +void COpenGLDriver::extGlUniform4fvARB(GLint location, GLsizei count, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniform4fvARB) + pGlUniform4fvARB(location, count, v); +#elif defined(GL_ARB_shader_objects) + glUniform4fvARB(location, count, v); +#else + os::Printer::log("glUniform4fvARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlUniform1ivARB (GLint loc, GLsizei count, const GLint *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniform1ivARB) + pGlUniform1ivARB(loc, count, v); +#elif defined(GL_ARB_shader_objects) + glUniform1ivARB(loc, count, v); +#else + os::Printer::log("glUniform1ivARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlUniform1fvARB (GLint loc, GLsizei count, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniform1fvARB) + pGlUniform1fvARB(loc, count, v); +#elif defined(GL_ARB_shader_objects) + glUniform1fvARB(loc, count, v); +#else + os::Printer::log("glUniform1fvARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlUniform2fvARB (GLint loc, GLsizei count, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniform2fvARB) + pGlUniform2fvARB(loc, count, v); +#elif defined(GL_ARB_shader_objects) + glUniform2fvARB(loc, count, v); +#else + os::Printer::log("glUniform2fvARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlUniform3fvARB (GLint loc, GLsizei count, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniform3fvARB) + pGlUniform3fvARB(loc, count, v); +#elif defined(GL_ARB_shader_objects) + glUniform3fvARB(loc, count, v); +#else + os::Printer::log("glUniform3fvARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlUniformMatrix2fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniformMatrix2fvARB) + pGlUniformMatrix2fvARB(loc, count, transpose, v); +#elif defined(GL_ARB_shader_objects) + glUniformMatrix2fvARB(loc, count, transpose, v); +#else + os::Printer::log("glUniformMatrix2fvARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlUniformMatrix3fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniformMatrix3fvARB) + pGlUniformMatrix3fvARB(loc, count, transpose, v); +#elif defined(GL_ARB_shader_objects) + glUniformMatrix3fvARB(loc, count, transpose, v); +#else + os::Printer::log("glUniformMatrix3fvARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlUniformMatrix4fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniformMatrix4fvARB) + pGlUniformMatrix4fvARB(loc, count, transpose, v); +#elif defined(GL_ARB_shader_objects) + glUniformMatrix4fvARB(loc, count, transpose, v); +#else + os::Printer::log("glUniformMatrix4fvARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlGetActiveUniformARB (GLhandleARB program, GLuint index, GLsizei maxlength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlGetActiveUniformARB) + pGlGetActiveUniformARB(program, index, maxlength, length, size, type, name); +#elif defined(GL_ARB_shader_objects) + glGetActiveUniformARB(program, index, maxlength, length, size, type, name); +#else + os::Printer::log("glGetActiveUniformARB not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlPointParameterfARB (GLint loc, GLfloat f) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlPointParameterfARB) + pGlPointParameterfARB(loc, f); +#else + glPointParameterfARB(loc, f); +#endif +} + +void COpenGLDriver::extGlPointParameterfvARB (GLint loc, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlPointParameterfvARB) + pGlPointParameterfvARB(loc, v); +#else + glPointParameterfvARB(loc, v); +#endif +} + +void COpenGLDriver::extGlStencilFuncSeparate (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlStencilFuncSeparate) + pGlStencilFuncSeparate(frontfunc, backfunc, ref, mask); + else if (pGlStencilFuncSeparateATI) + pGlStencilFuncSeparateATI(frontfunc, backfunc, ref, mask); +#elif defined(GL_VERSION_2_0) + glStencilFuncSeparate(frontfunc, backfunc, ref, mask); +#elif defined(GL_ATI_separate_stencil) + glStencilFuncSeparateATI(frontfunc, backfunc, ref, mask); +#else + os::Printer::log("glStencilFuncSeparate not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlStencilOpSeparate) + pGlStencilOpSeparate(face, fail, zfail, zpass); + else if (pGlStencilOpSeparateATI) + pGlStencilOpSeparateATI(face, fail, zfail, zpass); +#elif defined(GL_VERSION_2_0) + glStencilOpSeparate(face, fail, zfail, zpass); +#elif defined(GL_ATI_separate_stencil) + glStencilOpSeparateATI(face, fail, zfail, zpass); +#else + os::Printer::log("glStencilOpSeparate not supported", ELL_ERROR); +#endif +} + +void COpenGLDriver::extGlCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, const void* data) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC + if (pGlCompressedTexImage2D) + pGlCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); + #endif // PFNGLCOMPRESSEDTEXIMAGE2DPROC +#else + glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); +#endif +} + +void COpenGLDriver::extGlBindFramebufferEXT (GLenum target, GLuint framebuffer) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlBindFramebufferEXT) + pGlBindFramebufferEXT(target, framebuffer); +#elif defined(GL_EXT_framebuffer_object) + glBindFramebufferEXT(target, framebuffer); +#endif +} + +void COpenGLDriver::extGlDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlDeleteFramebuffersEXT) + pGlDeleteFramebuffersEXT(n, framebuffers); +#elif defined(GL_EXT_framebuffer_object) + glDeleteFramebuffersEXT(n, framebuffers); +#endif +} + +void COpenGLDriver::extGlGenFramebuffersEXT (GLsizei n, GLuint *framebuffers) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlGenFramebuffersEXT) + pGlGenFramebuffersEXT(n, framebuffers); +#elif defined(GL_EXT_framebuffer_object) + glGenFramebuffersEXT(n, framebuffers); +#endif +} + +GLenum COpenGLDriver::extGlCheckFramebufferStatusEXT (GLenum target) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlCheckFramebufferStatusEXT) + return pGlCheckFramebufferStatusEXT(target); + else + return 0; +#elif defined(GL_EXT_framebuffer_object) + return glCheckFramebufferStatusEXT(target); +#else + return 0; +#endif +} + +void COpenGLDriver::extGlFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlFramebufferTexture2DEXT) + pGlFramebufferTexture2DEXT(target, attachment, textarget, texture, level); +#elif defined(GL_EXT_framebuffer_object) + glFramebufferTexture2DEXT(target, attachment, textarget, texture, level); +#endif +} + +void COpenGLDriver::extGlBindRenderbufferEXT (GLenum target, GLuint renderbuffer) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlBindRenderbufferEXT) + pGlBindRenderbufferEXT(target, renderbuffer); +#elif defined(GL_EXT_framebuffer_object) + glBindRenderbufferEXT(target, renderbuffer); +#endif +} + +void COpenGLDriver::extGlDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlDeleteRenderbuffersEXT) + pGlDeleteRenderbuffersEXT(n, renderbuffers); +#elif defined(GL_EXT_framebuffer_object) + glDeleteRenderbuffersEXT(n, renderbuffers); +#endif +} + +void COpenGLDriver::extGlGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlGenRenderbuffersEXT) + pGlGenRenderbuffersEXT(n, renderbuffers); +#elif defined(GL_EXT_framebuffer_object) + glGenRenderbuffersEXT(n, renderbuffers); +#endif +} + +void COpenGLDriver::extGlRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlRenderbufferStorageEXT) + pGlRenderbufferStorageEXT(target, internalformat, width, height); +#elif defined(GL_EXT_framebuffer_object) + glRenderbufferStorageEXT(target, internalformat, width, height); +#endif +} + +void COpenGLDriver::extGlFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlFramebufferRenderbufferEXT) + pGlFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); +#elif defined(GL_EXT_framebuffer_object) + glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); +#endif +} + +//! Sets a vertex shader constant. +void COpenGLDriver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) +{ +#ifdef GL_ARB_vertex_program + for (int i=0; isetPixelShaderConstant(), not VideoDriver->setPixelShaderConstant()."); + return false; +} + + +//! Adds a new material renderer to the VideoDriver, using pixel and/or +//! vertex shaders to render geometry. +s32 COpenGLDriver::addShaderMaterial(const c8* vertexShaderProgram, + const c8* pixelShaderProgram, + IShaderConstantSetCallBack* callback, + E_MATERIAL_TYPE baseMaterial, s32 userData) +{ + s32 nr = -1; + COpenGLShaderMaterialRenderer* r = new COpenGLShaderMaterialRenderer( + this, nr, vertexShaderProgram, pixelShaderProgram, + callback, getMaterialRenderer(baseMaterial), userData); + + r->drop(); + return nr; +} + +//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry. +s32 COpenGLDriver::addHighLevelShaderMaterial( + const c8* vertexShaderProgram, + const c8* vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8* pixelShaderProgram, + const c8* pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + IShaderConstantSetCallBack* callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) +{ + s32 nr = -1; + + COpenGLSLMaterialRenderer* r = new COpenGLSLMaterialRenderer( + this, nr, vertexShaderProgram, vertexShaderEntryPointName, + vsCompileTarget, pixelShaderProgram, pixelShaderEntryPointName, psCompileTarget, + callback,getMaterialRenderer(baseMaterial), userData); + + r->drop(); + return nr; +} + +//! Returns a pointer to the IVideoDriver interface. (Implementation for +//! IMaterialRendererServices) +IVideoDriver* COpenGLDriver::getVideoDriver() +{ + return this; +} + + +//! Returns pointer to the IGPUProgrammingServices interface. +IGPUProgrammingServices* COpenGLDriver::getGPUProgrammingServices() +{ + return this; +} + +ITexture* COpenGLDriver::createRenderTargetTexture(const core::dimension2d& size) +{ + //disable mip-mapping + bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false); + + video::ITexture* rtt = 0; +#if defined(GL_EXT_framebuffer_object) + // if driver supports FrameBufferObjects, use them + if (FramebufferObjectExtension) + rtt = new COpenGLTexture(size, EXTPackedDepthStencil, "rt", this); + else +#endif + { + rtt = addTexture(size, "rt"); + if (rtt) + rtt->grab(); + } + + //restore mip-mapping + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, generateMipLevels); + + return rtt; +} + + +//! Returns the maximum amount of primitives (mostly vertices) which +//! the device is able to render with one drawIndexedTriangleList +//! call. +u32 COpenGLDriver::getMaximalPrimitiveCount() +{ + return 65535;// TODO: Fix all loaders to auto-split and then return the correct value: MaxIndices; +} + + +//! checks triangle count and print warning if wrong +bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, + bool clearZBuffer, SColor color) +{ + // check for right driver type + + if (texture && texture->getDriverType() != EDT_OPENGL) + { + os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); + return false; + } + + // check if we should set the previous RT back + + bool ret = true; + + setTexture(0, 0); + ResetRenderStates=true; + if (RenderTargetTexture!=0) + { + if (RenderTargetTexture->isFrameBufferObject()) + { + RenderTargetTexture->unbindFrameBufferObject(); + } + else + { + glBindTexture(GL_TEXTURE_2D, RenderTargetTexture->getOpenGLTextureName()); + + // Copy Our ViewPort To The Texture + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, + RenderTargetTexture->getSize().Width, RenderTargetTexture->getSize().Height); + } + } + + if (texture) + { + // we want to set a new target. so do this. + glViewport(0, 0, texture->getSize().Width, texture->getSize().Height); + RenderTargetTexture = (COpenGLTexture*)texture; + CurrentRendertargetSize = texture->getSize(); + + if (RenderTargetTexture->isFrameBufferObject()) + { + RenderTargetTexture->bindFrameBufferObject(); + } + } + else + { + glViewport(0,0,ScreenSize.Width,ScreenSize.Height); + RenderTargetTexture = 0; + CurrentRendertargetSize = core::dimension2d(0,0); + } + + GLbitfield mask = 0; + if (clearBackBuffer) + { + f32 inv = 1.0f / 255.0f; + glClearColor(color.getRed() * inv, color.getGreen() * inv, + color.getBlue() * inv, color.getAlpha() * inv); + + mask |= GL_COLOR_BUFFER_BIT; + } + if (clearZBuffer) + { + glDepthMask(GL_TRUE); + mask |= GL_DEPTH_BUFFER_BIT; + } + + glClear(mask); + + return ret; +} + + +// returns the current size of the screen or rendertarget +core::dimension2d COpenGLDriver::getCurrentRenderTargetSize() +{ + if ( CurrentRendertargetSize.Width == 0 ) + return ScreenSize; + else + return CurrentRendertargetSize; +} + +//! Clears the ZBuffer. +void COpenGLDriver::clearZBuffer() +{ + GLboolean enabled = GL_TRUE; + glGetBooleanv(GL_DEPTH_WRITEMASK, &enabled); + + glDepthMask(GL_TRUE); + glClear(GL_DEPTH_BUFFER_BIT); + + glDepthMask(enabled); +} + +//! Returns an image created from the last rendered frame. +IImage* COpenGLDriver::createScreenShot() +{ + IImage* newImage = new CImage(ECF_R8G8B8, ScreenSize); + + u8* pPixels = (u8*)newImage->lock(); + if (!pPixels) + { + newImage->drop(); + return 0; + } + + glReadPixels(0, 0, ScreenSize.Width, ScreenSize.Height, GL_RGB, GL_UNSIGNED_BYTE, pPixels); + + // opengl images are inverted, so we have to fix that here. + s32 pitch=newImage->getPitch(); + u8* p2 = pPixels + (ScreenSize.Height - 1) * pitch; + u8* tmpBuffer = new u8[pitch]; + for (s32 i=0; i < ScreenSize.Height; i += 2) + { + memcpy(tmpBuffer, pPixels, pitch); + memcpy(pPixels, p2, pitch); + memcpy(p2, tmpBuffer, pitch); + pPixels += pitch; + p2 -= pitch; + } + delete [] tmpBuffer; + + newImage->unlock(); + + if (testGLError()) + { + newImage->drop(); + return 0; + } + + return newImage; +} + + +} // end namespace +} // end namespace + + +namespace irr +{ +namespace video +{ + + +// ----------------------------------- +// WINDOWS VERSION +// ----------------------------------- +#ifdef _IRR_WINDOWS_ +IVideoDriver* createOpenGLDriver(const core::dimension2d& screenSize, + HWND window, u32 bits, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias) +{ +#ifdef _IRR_COMPILE_WITH_OPENGL_ + COpenGLDriver* ogl = new COpenGLDriver(screenSize, window, fullscreen, stencilBuffer, io, antiAlias); + if (!ogl->initDriver(screenSize, window, bits, fullscreen, vsync)) + { + ogl->drop(); + ogl = 0; + } + return ogl; +#else + return 0; +#endif // _IRR_COMPILE_WITH_OPENGL_ +} +#endif // _IRR_WINDOWS_ + +// ----------------------------------- +// MACOSX VERSION +// ----------------------------------- +#ifdef MACOSX +IVideoDriver* createOpenGLDriver(const core::dimension2d& screenSize, + CIrrDeviceMacOSX *device, bool fullscreen, bool stencilBuffer, + io::IFileSystem* io, bool vsync, bool antiAlias) +{ +#ifdef _IRR_COMPILE_WITH_OPENGL_ + return new COpenGLDriver(screenSize, fullscreen, stencilBuffer, + device, io, vsync, antiAlias); +#else + return 0; +#endif // _IRR_COMPILE_WITH_OPENGL_ +} +#endif // MACOSX + +// ----------------------------------- +// LINUX VERSION +// ----------------------------------- +#ifdef LINUX +IVideoDriver* createOpenGLDriver(const core::dimension2d& screenSize, + bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias) +{ +#ifdef _IRR_COMPILE_WITH_OPENGL_ + return new COpenGLDriver(screenSize, fullscreen, stencilBuffer, + io, vsync, antiAlias); +#else + return 0; +#endif // _IRR_COMPILE_WITH_OPENGL_ +} +#endif // LINUX + +} // end namespace +} // end namespace + + +#endif // _IRR_COMPILE_WITH_OPENGL_ + diff --git a/src/dep/src/irrlicht/COpenGLDriver.h b/src/dep/src/irrlicht/COpenGLDriver.h index 3537fe8..108a933 100644 --- a/src/dep/src/irrlicht/COpenGLDriver.h +++ b/src/dep/src/irrlicht/COpenGLDriver.h @@ -1,454 +1,454 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in Irrlicht.h - -#ifndef __C_VIDEO_OPEN_GL_H_INCLUDED__ -#define __C_VIDEO_OPEN_GL_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#include "CNullDriver.h" -#include "IMaterialRendererServices.h" - -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#ifdef _IRR_WINDOWS_ - // include windows headers for HWND - #define WIN32_LEAN_AND_MEAN - #include - #include - #include - #include "glext.h" -#ifdef _MSC_VER - #pragma comment(lib, "OpenGL32.lib") - #pragma comment(lib, "GLu32.lib") -#endif -#elif defined(MACOSX) - #define GL_EXT_texture_env_combine 1 - #include "CIrrDeviceMacOSX.h" - #include - #include - #include -#else - #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #define GL_GLEXT_LEGACY 1 - #define GLX_GLXEXT_LEGACY 1 - #else - #define GL_GLEXT_PROTOTYPES 1 - #define GLX_GLXEXT_PROTOTYPES 1 - #endif - #include - #include - #include - #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #include "glext.h" - #undef GLX_ARB_get_proc_address // avoid problems with local glxext.h - #include "glxext.h" - #endif -#endif - -namespace irr -{ -namespace video -{ - class COpenGLTexture; - - class COpenGLDriver : public CNullDriver, public IMaterialRendererServices - { - public: - - #ifdef _IRR_WINDOWS_ - //! win32 constructor - COpenGLDriver(const core::dimension2d& screenSize, HWND window, bool fullscreen, - bool stencilBuffer, io::IFileSystem* io, bool antiAlias); - - //! inits the windows specific parts of the open gl driver - bool initDriver(const core::dimension2d& screenSize, HWND window, - u32 bits, bool fullscreen, bool vsync); - #endif - - #ifdef LINUX - COpenGLDriver(const core::dimension2d& screenSize, bool fullscreen, - bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias); - #endif - - #ifdef MACOSX - COpenGLDriver(const core::dimension2d& screenSize, bool fullscreen, - bool stencilBuffer, CIrrDeviceMacOSX *device,io::IFileSystem* io, bool vsync, bool antiAlias); - #endif - - //! destructor - virtual ~COpenGLDriver(); - - //! presents the rendered scene on the screen, returns false if failed - virtual bool endScene( s32 windowId, core::rect* sourceRect=0 ); - - //! clears the zbuffer - virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color); - - //! sets transformation - virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); - - //! draws a vertex primitive list - void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); - - //! queries the features of the driver, returns true if feature is available - bool queryFeature(E_VIDEO_DRIVER_FEATURE feature); - - //! Sets a material. All 3d drawing functions draw geometry now - //! using this material. - //! \param material: Material to be used from now on. - virtual void setMaterial(const SMaterial& material); - - //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. - virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos, - const core::rect& sourceRect, const core::rect* clipRect = 0, - SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); - - //! draws a set of 2d images, using a color and the alpha - /** channel of the texture if desired. The images are drawn - beginning at pos and concatenated in one line. All drawings - are clipped against clipRect (if != 0). - The subtextures are defined by the array of sourceRects - and are chosen by the indices given. - \param texture: Texture to be drawn. - \param pos: Upper left 2d destination position where the image will be drawn. - \param sourceRects: Source rectangles of the image. - \param indices: List of indices which choose the actual rectangle used each time. - \param clipRect: Pointer to rectangle on the screen where the image is clipped to. - This pointer can be 0. Then the image is not clipped. - \param color: Color with which the image is colored. - Note that the alpha component is used: If alpha is other than 255, the image will be transparent. - \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is - used to draw the image. */ - virtual void draw2DImage(video::ITexture* texture, - const core::position2d& pos, - const core::array >& sourceRects, - const core::array& indices, - const core::rect* clipRect, SColor color, - bool useAlphaChannelOfTexture); - - //! Draws a part of the texture into the rectangle. - virtual void draw2DImage(video::ITexture* texture, const core::rect& destRect, - const core::rect& sourceRect, const core::rect* clipRect = 0, - video::SColor* colors=0, bool useAlphaChannelOfTexture=false); - - //! draw an 2d rectangle - virtual void draw2DRectangle(SColor color, const core::rect& pos, - const core::rect* clip = 0); - - //!Draws an 2d rectangle with a gradient. - virtual void draw2DRectangle(const core::rect& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect* clip = 0); - - //! Draws a 2d line. - virtual void draw2DLine(const core::position2d& start, - const core::position2d& end, - SColor color=SColor(255,255,255,255)); - - //! Draws a 3d line. - virtual void draw3DLine(const core::vector3df& start, - const core::vector3df& end, - SColor color = SColor(255,255,255,255)); - - //! \return Returns the name of the video driver. Example: In case of the Direct3D8 - //! driver, it would return "Direct3D8.1". - virtual const wchar_t* getName(); - - //! deletes all dynamic lights there are - virtual void deleteAllDynamicLights(); - - //! adds a dynamic light - virtual void addDynamicLight(const SLight& light); - - //! returns the maximal amount of dynamic lights the device can handle - virtual u32 getMaximalDynamicLightAmount(); - - //! Sets the dynamic ambient light color. The default color is - //! (0,0,0,0) which means it is dark. - //! \param color: New color of the ambient light. - virtual void setAmbientLight(const SColorf& color); - - //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do - //! this: First, draw all geometry. Then use this method, to draw the shadow - //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. - virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail); - - //! Fills the stencil shadow with color. After the shadow volume has been drawn - //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this - //! to draw the color of the shadow. - virtual void drawStencilShadow(bool clearStencilBuffer=false, - video::SColor leftUpEdge = video::SColor(0,0,0,0), - video::SColor rightUpEdge = video::SColor(0,0,0,0), - video::SColor leftDownEdge = video::SColor(0,0,0,0), - video::SColor rightDownEdge = video::SColor(0,0,0,0)); - - //! sets a viewport - virtual void setViewPort(const core::rect& area); - - //! Sets the fog mode. - virtual void setFog(SColor color, bool linearFog, f32 start, - f32 end, f32 density, bool pixelFog, bool rangeFog); - - //! Only used by the internal engine. Used to notify the driver that - //! the window was resized. - virtual void OnResize(const core::dimension2d& size); - - //! Returns type of video driver - virtual E_DRIVER_TYPE getDriverType(); - - //! Returns the transformation set by setTransform - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state); - - // public access to the (loaded) extensions. - void extGlActiveTextureARB(GLenum texture); - void extGlClientActiveTextureARB(GLenum texture); - void extGlGenProgramsARB(GLsizei n, GLuint *programs); - void extGlBindProgramARB(GLenum target, GLuint program); - void extGlProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid *string); - void extGlDeleteProgramsARB(GLsizei n, const GLuint *programs); - void extGlProgramLocalParameter4fvARB(GLenum, GLuint, const GLfloat *); - GLhandleARB extGlCreateShaderObjectARB(GLenum shaderType); - void extGlShaderSourceARB(GLhandleARB shader, int numOfStrings, const char **strings, int *lenOfStrings); - void extGlCompileShaderARB(GLhandleARB shader); - GLhandleARB extGlCreateProgramObjectARB(void); - void extGlAttachObjectARB(GLhandleARB program, GLhandleARB shader); - void extGlLinkProgramARB(GLhandleARB program); - void extGlUseProgramObjectARB(GLhandleARB prog); - void extGlDeleteObjectARB(GLhandleARB object); - void extGlGetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); - void extGlGetObjectParameterivARB(GLhandleARB object, GLenum type, int *param); - GLint extGlGetUniformLocationARB(GLhandleARB program, const char *name); - void extGlUniform4fvARB(GLint location, GLsizei count, const GLfloat *v); - - void extGlUniform1ivARB (GLint loc, GLsizei count, const GLint *v); - void extGlUniform1fvARB (GLint loc, GLsizei count, const GLfloat *v); - void extGlUniform2fvARB (GLint loc, GLsizei count, const GLfloat *v); - void extGlUniform3fvARB (GLint loc, GLsizei count, const GLfloat *v); - void extGlUniformMatrix2fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); - void extGlUniformMatrix3fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); - void extGlUniformMatrix4fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); - void extGlGetActiveUniformARB (GLhandleARB program, GLuint index, GLsizei maxlength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); - void extGlPointParameterfARB (GLint loc, GLfloat f); - void extGlPointParameterfvARB (GLint loc, const GLfloat *v); - void extGlStencilFuncSeparate (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); - void extGlStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); - void extGlCompressedTexImage2D(GLenum target, GLint level, - GLenum internalformat, GLsizei width, GLsizei height, - GLint border, GLsizei imageSize, const void* data); - - void extGlBindFramebufferEXT (GLenum target, GLuint framebuffer); - void extGlDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); - void extGlGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); - GLenum extGlCheckFramebufferStatusEXT (GLenum target); - void extGlFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); - void extGlBindRenderbufferEXT (GLenum target, GLuint renderbuffer); - void extGlDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); - void extGlGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); - void extGlRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); - void extGlFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); - - //! Can be called by an IMaterialRenderer to make its work easier. - void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, - bool resetAllRenderstates); - - //! Sets a vertex shader constant. - virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - - //! Sets a pixel shader constant. - virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - - //! Sets a constant for the vertex shader based on a name. - virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); - - //! Sets a constant for the pixel shader based on a name. - virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); - - //! sets the current Texture - //! Returns whether setting was a success or not. - bool setTexture(s32 stage, video::ITexture* texture); - - //! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled. - //! Returns whether disabling was successful or not. - bool disableTextures(s32 fromStage=0); - - //! Adds a new material renderer to the VideoDriver, using extGLGetObjectParameterivARB(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status) pixel and/or - //! vertex shaders to render geometry. - s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData); - - //! Adds a new material renderer to the VideoDriver, using GLSL to render geometry. - s32 addHighLevelShaderMaterial(const c8* vertexShaderProgram, const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, const c8* pixelShaderProgram, const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, - s32 userData); - - //! Returns pointer to the IGPUProgrammingServices interface. - IGPUProgrammingServices* getGPUProgrammingServices(); - - //! Returns a pointer to the IVideoDriver interface. (Implementation for - //! IMaterialRendererServices) - virtual IVideoDriver* getVideoDriver(); - - //! Returns the maximum amount of primitives (mostly vertices) which - //! the device is able to render with one drawIndexedTriangleList - //! call. - virtual u32 getMaximalPrimitiveCount(); - - ITexture* createRenderTargetTexture(const core::dimension2d& size); - - bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color); - - //! Clears the ZBuffer. - virtual void clearZBuffer(); - - //! Returns an image created from the last rendered frame. - virtual IImage* createScreenShot(); - - //! checks if an OpenGL error has happend and prints it - //! for performance reasons only available in debug mode - bool testGLError(); - - private: - - //! inits the parts of the open gl driver used on all platforms - bool genericDriverInit(const core::dimension2d& screenSize); - //! returns a device dependent texture from a software surface (IImage) - virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const char* name); - - //! creates a transposed matrix in supplied GLfloat array to pass to OpenGL - void createGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m); - void createGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4& m); - - - //! sets the needed renderstates - void setRenderStates3DMode(); - - //! sets the needed renderstates - void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); - - // returns the current size of the screen or rendertarget - core::dimension2d getCurrentRenderTargetSize(); - - void loadExtensions(); - void createMaterialRenderers(); - - core::stringw Name; - core::matrix4 Matrices[ETS_COUNT]; - core::array ColorBuffer; - - // enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. - enum E_RENDER_MODE - { - ERM_NONE = 0, // no render state has been set yet. - ERM_2D, // 2d drawing rendermode - ERM_3D // 3d rendering mode - }; - - E_RENDER_MODE CurrentRenderMode; - bool ResetRenderStates; // bool to make all renderstates be reseted if set. - bool Transformation3DChanged; - bool StencilBuffer; - bool AntiAlias; - bool MultiTextureExtension; - bool MultiSamplingExtension; - bool AnisotropyExtension; - bool ARBVertexProgramExtension; //GL_ARB_vertex_program - bool ARBFragmentProgramExtension; //GL_ARB_fragment_program - bool ARBShadingLanguage100Extension; - bool SeparateStencilExtension; - bool GenerateMipmapExtension; - bool TextureCompressionExtension; - bool TextureNPOTExtension; - bool FramebufferObjectExtension; - bool EXTPackedDepthStencil; - bool EXTSeparateSpecularColor; - - SMaterial Material, LastMaterial; - COpenGLTexture* RenderTargetTexture; - ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES]; - s32 LastSetLight; - f32 MaxAnisotropy; - - GLint MaxTextureUnits; - GLint MaxLights; - GLint MaxIndices; - - core::dimension2d CurrentRendertargetSize; - - #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - PFNGLACTIVETEXTUREARBPROC pGlActiveTextureARB; - PFNGLCLIENTACTIVETEXTUREARBPROC pGlClientActiveTextureARB; - PFNGLGENPROGRAMSARBPROC pGlGenProgramsARB; - PFNGLBINDPROGRAMARBPROC pGlBindProgramARB; - PFNGLPROGRAMSTRINGARBPROC pGlProgramStringARB; - PFNGLDELETEPROGRAMSNVPROC pGlDeleteProgramsARB; - PFNGLPROGRAMLOCALPARAMETER4FVARBPROC pGlProgramLocalParameter4fvARB; - PFNGLCREATESHADEROBJECTARBPROC pGlCreateShaderObjectARB; - PFNGLSHADERSOURCEARBPROC pGlShaderSourceARB; - PFNGLCOMPILESHADERARBPROC pGlCompileShaderARB; - PFNGLCREATEPROGRAMOBJECTARBPROC pGlCreateProgramObjectARB; - PFNGLATTACHOBJECTARBPROC pGlAttachObjectARB; - PFNGLLINKPROGRAMARBPROC pGlLinkProgramARB; - PFNGLUSEPROGRAMOBJECTARBPROC pGlUseProgramObjectARB; - PFNGLDELETEOBJECTARBPROC pGlDeleteObjectARB; - PFNGLGETINFOLOGARBPROC pGlGetInfoLogARB; - PFNGLGETOBJECTPARAMETERIVARBPROC pGlGetObjectParameterivARB; - PFNGLGETUNIFORMLOCATIONARBPROC pGlGetUniformLocationARB; - PFNGLUNIFORM1IVARBPROC pGlUniform1ivARB; - PFNGLUNIFORM1FVARBPROC pGlUniform1fvARB; - PFNGLUNIFORM2FVARBPROC pGlUniform2fvARB; - PFNGLUNIFORM3FVARBPROC pGlUniform3fvARB; - PFNGLUNIFORM4FVARBPROC pGlUniform4fvARB; - PFNGLUNIFORMMATRIX2FVARBPROC pGlUniformMatrix2fvARB; - PFNGLUNIFORMMATRIX3FVARBPROC pGlUniformMatrix3fvARB; - PFNGLUNIFORMMATRIX4FVARBPROC pGlUniformMatrix4fvARB; - PFNGLGETACTIVEUNIFORMARBPROC pGlGetActiveUniformARB; - PFNGLPOINTPARAMETERFARBPROC pGlPointParameterfARB; - PFNGLPOINTPARAMETERFVARBPROC pGlPointParameterfvARB; - PFNGLSTENCILFUNCSEPARATEPROC pGlStencilFuncSeparate; - PFNGLSTENCILOPSEPARATEPROC pGlStencilOpSeparate; - PFNGLSTENCILFUNCSEPARATEATIPROC pGlStencilFuncSeparateATI; - PFNGLSTENCILOPSEPARATEATIPROC pGlStencilOpSeparateATI; - #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC - PFNGLCOMPRESSEDTEXIMAGE2DPROC pGlCompressedTexImage2D; - #endif // PFNGLCOMPRESSEDTEXIMAGE2DPROC - #ifdef _IRR_WINDOWS_ - typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int); - PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT; - #elif defined(LINUX) && defined(GLX_SGI_swap_control) - PFNGLXSWAPINTERVALSGIPROC glxSwapIntervalSGI; - #endif - PFNGLBINDFRAMEBUFFEREXTPROC pGlBindFramebufferEXT; - PFNGLDELETEFRAMEBUFFERSEXTPROC pGlDeleteFramebuffersEXT; - PFNGLGENFRAMEBUFFERSEXTPROC pGlGenFramebuffersEXT; - PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC pGlCheckFramebufferStatusEXT; - PFNGLFRAMEBUFFERTEXTURE2DEXTPROC pGlFramebufferTexture2DEXT; - PFNGLBINDRENDERBUFFEREXTPROC pGlBindRenderbufferEXT; - PFNGLDELETERENDERBUFFERSEXTPROC pGlDeleteRenderbuffersEXT; - PFNGLGENRENDERBUFFERSEXTPROC pGlGenRenderbuffersEXT; - PFNGLRENDERBUFFERSTORAGEEXTPROC pGlRenderbufferStorageEXT; - PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC pGlFramebufferRenderbufferEXT; - #endif - - #ifdef _IRR_WINDOWS_ - HDC HDc; // Private GDI Device Context - HWND Window; - HGLRC HRc; // Permanent Rendering Context - #elif defined(LINUX) - GLXDrawable XWindow; - Display* XDisplay; - #elif defined(MACOSX) - CIrrDeviceMacOSX *_device; - #endif - }; - -} // end namespace video -} // end namespace irr - - -#endif // _IRR_COMPILE_WITH_OPENGL_ -#endif - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#ifndef __C_VIDEO_OPEN_GL_H_INCLUDED__ +#define __C_VIDEO_OPEN_GL_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#include "CNullDriver.h" +#include "IMaterialRendererServices.h" + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#ifdef _IRR_WINDOWS_ + // include windows headers for HWND + #define WIN32_LEAN_AND_MEAN + #include + #include + #include + #include "glext.h" +#ifdef _MSC_VER + #pragma comment(lib, "OpenGL32.lib") + #pragma comment(lib, "GLu32.lib") +#endif +#elif defined(MACOSX) + #define GL_EXT_texture_env_combine 1 + #include "CIrrDeviceMacOSX.h" + #include + #include + #include +#else + #if defined(_IRR_OPENGL_USE_EXTPOINTER_) + #define GL_GLEXT_LEGACY 1 + #define GLX_GLXEXT_LEGACY 1 + #else + #define GL_GLEXT_PROTOTYPES 1 + #define GLX_GLXEXT_PROTOTYPES 1 + #endif + #include + #include + #include + #if defined(_IRR_OPENGL_USE_EXTPOINTER_) + #include "glext.h" + #undef GLX_ARB_get_proc_address // avoid problems with local glxext.h + #include "glxext.h" + #endif +#endif + +namespace irr +{ +namespace video +{ + class COpenGLTexture; + + class COpenGLDriver : public CNullDriver, public IMaterialRendererServices + { + public: + + #ifdef _IRR_WINDOWS_ + //! win32 constructor + COpenGLDriver(const core::dimension2d& screenSize, HWND window, bool fullscreen, + bool stencilBuffer, io::IFileSystem* io, bool antiAlias); + + //! inits the windows specific parts of the open gl driver + bool initDriver(const core::dimension2d& screenSize, HWND window, + u32 bits, bool fullscreen, bool vsync); + #endif + + #ifdef LINUX + COpenGLDriver(const core::dimension2d& screenSize, bool fullscreen, + bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias); + #endif + + #ifdef MACOSX + COpenGLDriver(const core::dimension2d& screenSize, bool fullscreen, + bool stencilBuffer, CIrrDeviceMacOSX *device,io::IFileSystem* io, bool vsync, bool antiAlias); + #endif + + //! destructor + virtual ~COpenGLDriver(); + + //! presents the rendered scene on the screen, returns false if failed + virtual bool endScene( s32 windowId, core::rect* sourceRect=0 ); + + //! clears the zbuffer + virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color); + + //! sets transformation + virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); + + //! draws a vertex primitive list + void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); + + //! queries the features of the driver, returns true if feature is available + bool queryFeature(E_VIDEO_DRIVER_FEATURE feature); + + //! Sets a material. All 3d drawing functions draw geometry now + //! using this material. + //! \param material: Material to be used from now on. + virtual void setMaterial(const SMaterial& material); + + //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. + virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos, + const core::rect& sourceRect, const core::rect* clipRect = 0, + SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); + + //! draws a set of 2d images, using a color and the alpha + /** channel of the texture if desired. The images are drawn + beginning at pos and concatenated in one line. All drawings + are clipped against clipRect (if != 0). + The subtextures are defined by the array of sourceRects + and are chosen by the indices given. + \param texture: Texture to be drawn. + \param pos: Upper left 2d destination position where the image will be drawn. + \param sourceRects: Source rectangles of the image. + \param indices: List of indices which choose the actual rectangle used each time. + \param clipRect: Pointer to rectangle on the screen where the image is clipped to. + This pointer can be 0. Then the image is not clipped. + \param color: Color with which the image is colored. + Note that the alpha component is used: If alpha is other than 255, the image will be transparent. + \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is + used to draw the image. */ + virtual void draw2DImage(video::ITexture* texture, + const core::position2d& pos, + const core::array >& sourceRects, + const core::array& indices, + const core::rect* clipRect, SColor color, + bool useAlphaChannelOfTexture); + + //! Draws a part of the texture into the rectangle. + virtual void draw2DImage(video::ITexture* texture, const core::rect& destRect, + const core::rect& sourceRect, const core::rect* clipRect = 0, + video::SColor* colors=0, bool useAlphaChannelOfTexture=false); + + //! draw an 2d rectangle + virtual void draw2DRectangle(SColor color, const core::rect& pos, + const core::rect* clip = 0); + + //!Draws an 2d rectangle with a gradient. + virtual void draw2DRectangle(const core::rect& pos, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect* clip = 0); + + //! Draws a 2d line. + virtual void draw2DLine(const core::position2d& start, + const core::position2d& end, + SColor color=SColor(255,255,255,255)); + + //! Draws a 3d line. + virtual void draw3DLine(const core::vector3df& start, + const core::vector3df& end, + SColor color = SColor(255,255,255,255)); + + //! \return Returns the name of the video driver. Example: In case of the Direct3D8 + //! driver, it would return "Direct3D8.1". + virtual const wchar_t* getName(); + + //! deletes all dynamic lights there are + virtual void deleteAllDynamicLights(); + + //! adds a dynamic light + virtual void addDynamicLight(const SLight& light); + + //! returns the maximal amount of dynamic lights the device can handle + virtual u32 getMaximalDynamicLightAmount(); + + //! Sets the dynamic ambient light color. The default color is + //! (0,0,0,0) which means it is dark. + //! \param color: New color of the ambient light. + virtual void setAmbientLight(const SColorf& color); + + //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do + //! this: First, draw all geometry. Then use this method, to draw the shadow + //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. + virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail); + + //! Fills the stencil shadow with color. After the shadow volume has been drawn + //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this + //! to draw the color of the shadow. + virtual void drawStencilShadow(bool clearStencilBuffer=false, + video::SColor leftUpEdge = video::SColor(0,0,0,0), + video::SColor rightUpEdge = video::SColor(0,0,0,0), + video::SColor leftDownEdge = video::SColor(0,0,0,0), + video::SColor rightDownEdge = video::SColor(0,0,0,0)); + + //! sets a viewport + virtual void setViewPort(const core::rect& area); + + //! Sets the fog mode. + virtual void setFog(SColor color, bool linearFog, f32 start, + f32 end, f32 density, bool pixelFog, bool rangeFog); + + //! Only used by the internal engine. Used to notify the driver that + //! the window was resized. + virtual void OnResize(const core::dimension2d& size); + + //! Returns type of video driver + virtual E_DRIVER_TYPE getDriverType(); + + //! Returns the transformation set by setTransform + virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state); + + // public access to the (loaded) extensions. + void extGlActiveTextureARB(GLenum texture); + void extGlClientActiveTextureARB(GLenum texture); + void extGlGenProgramsARB(GLsizei n, GLuint *programs); + void extGlBindProgramARB(GLenum target, GLuint program); + void extGlProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid *string); + void extGlDeleteProgramsARB(GLsizei n, const GLuint *programs); + void extGlProgramLocalParameter4fvARB(GLenum, GLuint, const GLfloat *); + GLhandleARB extGlCreateShaderObjectARB(GLenum shaderType); + void extGlShaderSourceARB(GLhandleARB shader, int numOfStrings, const char **strings, int *lenOfStrings); + void extGlCompileShaderARB(GLhandleARB shader); + GLhandleARB extGlCreateProgramObjectARB(void); + void extGlAttachObjectARB(GLhandleARB program, GLhandleARB shader); + void extGlLinkProgramARB(GLhandleARB program); + void extGlUseProgramObjectARB(GLhandleARB prog); + void extGlDeleteObjectARB(GLhandleARB object); + void extGlGetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); + void extGlGetObjectParameterivARB(GLhandleARB object, GLenum type, int *param); + GLint extGlGetUniformLocationARB(GLhandleARB program, const char *name); + void extGlUniform4fvARB(GLint location, GLsizei count, const GLfloat *v); + + void extGlUniform1ivARB (GLint loc, GLsizei count, const GLint *v); + void extGlUniform1fvARB (GLint loc, GLsizei count, const GLfloat *v); + void extGlUniform2fvARB (GLint loc, GLsizei count, const GLfloat *v); + void extGlUniform3fvARB (GLint loc, GLsizei count, const GLfloat *v); + void extGlUniformMatrix2fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlUniformMatrix3fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlUniformMatrix4fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlGetActiveUniformARB (GLhandleARB program, GLuint index, GLsizei maxlength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); + void extGlPointParameterfARB (GLint loc, GLfloat f); + void extGlPointParameterfvARB (GLint loc, const GLfloat *v); + void extGlStencilFuncSeparate (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); + void extGlStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); + void extGlCompressedTexImage2D(GLenum target, GLint level, + GLenum internalformat, GLsizei width, GLsizei height, + GLint border, GLsizei imageSize, const void* data); + + void extGlBindFramebufferEXT (GLenum target, GLuint framebuffer); + void extGlDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); + void extGlGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); + GLenum extGlCheckFramebufferStatusEXT (GLenum target); + void extGlFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + void extGlBindRenderbufferEXT (GLenum target, GLuint renderbuffer); + void extGlDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); + void extGlGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); + void extGlRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + void extGlFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + + //! Can be called by an IMaterialRenderer to make its work easier. + void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, + bool resetAllRenderstates); + + //! Sets a vertex shader constant. + virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); + + //! Sets a pixel shader constant. + virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); + + //! Sets a constant for the vertex shader based on a name. + virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); + + //! Sets a constant for the pixel shader based on a name. + virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); + + //! sets the current Texture + //! Returns whether setting was a success or not. + bool setTexture(s32 stage, video::ITexture* texture); + + //! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled. + //! Returns whether disabling was successful or not. + bool disableTextures(s32 fromStage=0); + + //! Adds a new material renderer to the VideoDriver, using extGLGetObjectParameterivARB(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status) pixel and/or + //! vertex shaders to render geometry. + s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram, + IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData); + + //! Adds a new material renderer to the VideoDriver, using GLSL to render geometry. + s32 addHighLevelShaderMaterial(const c8* vertexShaderProgram, const c8* vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, const c8* pixelShaderProgram, const c8* pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, + s32 userData); + + //! Returns pointer to the IGPUProgrammingServices interface. + IGPUProgrammingServices* getGPUProgrammingServices(); + + //! Returns a pointer to the IVideoDriver interface. (Implementation for + //! IMaterialRendererServices) + virtual IVideoDriver* getVideoDriver(); + + //! Returns the maximum amount of primitives (mostly vertices) which + //! the device is able to render with one drawIndexedTriangleList + //! call. + virtual u32 getMaximalPrimitiveCount(); + + ITexture* createRenderTargetTexture(const core::dimension2d& size); + + bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, + bool clearZBuffer, SColor color); + + //! Clears the ZBuffer. + virtual void clearZBuffer(); + + //! Returns an image created from the last rendered frame. + virtual IImage* createScreenShot(); + + //! checks if an OpenGL error has happend and prints it + //! for performance reasons only available in debug mode + bool testGLError(); + + private: + + //! inits the parts of the open gl driver used on all platforms + bool genericDriverInit(const core::dimension2d& screenSize); + //! returns a device dependent texture from a software surface (IImage) + virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const char* name); + + //! creates a transposed matrix in supplied GLfloat array to pass to OpenGL + void createGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m); + void createGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4& m); + + + //! sets the needed renderstates + void setRenderStates3DMode(); + + //! sets the needed renderstates + void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); + + // returns the current size of the screen or rendertarget + core::dimension2d getCurrentRenderTargetSize(); + + void loadExtensions(); + void createMaterialRenderers(); + + core::stringw Name; + core::matrix4 Matrices[ETS_COUNT]; + core::array ColorBuffer; + + // enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. + enum E_RENDER_MODE + { + ERM_NONE = 0, // no render state has been set yet. + ERM_2D, // 2d drawing rendermode + ERM_3D // 3d rendering mode + }; + + E_RENDER_MODE CurrentRenderMode; + bool ResetRenderStates; // bool to make all renderstates be reseted if set. + bool Transformation3DChanged; + bool StencilBuffer; + bool AntiAlias; + bool MultiTextureExtension; + bool MultiSamplingExtension; + bool AnisotropyExtension; + bool ARBVertexProgramExtension; //GL_ARB_vertex_program + bool ARBFragmentProgramExtension; //GL_ARB_fragment_program + bool ARBShadingLanguage100Extension; + bool SeparateStencilExtension; + bool GenerateMipmapExtension; + bool TextureCompressionExtension; + bool TextureNPOTExtension; + bool FramebufferObjectExtension; + bool EXTPackedDepthStencil; + bool EXTSeparateSpecularColor; + + SMaterial Material, LastMaterial; + COpenGLTexture* RenderTargetTexture; + ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES]; + s32 LastSetLight; + f32 MaxAnisotropy; + + GLint MaxTextureUnits; + GLint MaxLights; + GLint MaxIndices; + + core::dimension2d CurrentRendertargetSize; + + #if defined(_IRR_OPENGL_USE_EXTPOINTER_) + PFNGLACTIVETEXTUREARBPROC pGlActiveTextureARB; + PFNGLCLIENTACTIVETEXTUREARBPROC pGlClientActiveTextureARB; + PFNGLGENPROGRAMSARBPROC pGlGenProgramsARB; + PFNGLBINDPROGRAMARBPROC pGlBindProgramARB; + PFNGLPROGRAMSTRINGARBPROC pGlProgramStringARB; + PFNGLDELETEPROGRAMSNVPROC pGlDeleteProgramsARB; + PFNGLPROGRAMLOCALPARAMETER4FVARBPROC pGlProgramLocalParameter4fvARB; + PFNGLCREATESHADEROBJECTARBPROC pGlCreateShaderObjectARB; + PFNGLSHADERSOURCEARBPROC pGlShaderSourceARB; + PFNGLCOMPILESHADERARBPROC pGlCompileShaderARB; + PFNGLCREATEPROGRAMOBJECTARBPROC pGlCreateProgramObjectARB; + PFNGLATTACHOBJECTARBPROC pGlAttachObjectARB; + PFNGLLINKPROGRAMARBPROC pGlLinkProgramARB; + PFNGLUSEPROGRAMOBJECTARBPROC pGlUseProgramObjectARB; + PFNGLDELETEOBJECTARBPROC pGlDeleteObjectARB; + PFNGLGETINFOLOGARBPROC pGlGetInfoLogARB; + PFNGLGETOBJECTPARAMETERIVARBPROC pGlGetObjectParameterivARB; + PFNGLGETUNIFORMLOCATIONARBPROC pGlGetUniformLocationARB; + PFNGLUNIFORM1IVARBPROC pGlUniform1ivARB; + PFNGLUNIFORM1FVARBPROC pGlUniform1fvARB; + PFNGLUNIFORM2FVARBPROC pGlUniform2fvARB; + PFNGLUNIFORM3FVARBPROC pGlUniform3fvARB; + PFNGLUNIFORM4FVARBPROC pGlUniform4fvARB; + PFNGLUNIFORMMATRIX2FVARBPROC pGlUniformMatrix2fvARB; + PFNGLUNIFORMMATRIX3FVARBPROC pGlUniformMatrix3fvARB; + PFNGLUNIFORMMATRIX4FVARBPROC pGlUniformMatrix4fvARB; + PFNGLGETACTIVEUNIFORMARBPROC pGlGetActiveUniformARB; + PFNGLPOINTPARAMETERFARBPROC pGlPointParameterfARB; + PFNGLPOINTPARAMETERFVARBPROC pGlPointParameterfvARB; + PFNGLSTENCILFUNCSEPARATEPROC pGlStencilFuncSeparate; + PFNGLSTENCILOPSEPARATEPROC pGlStencilOpSeparate; + PFNGLSTENCILFUNCSEPARATEATIPROC pGlStencilFuncSeparateATI; + PFNGLSTENCILOPSEPARATEATIPROC pGlStencilOpSeparateATI; + #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC + PFNGLCOMPRESSEDTEXIMAGE2DPROC pGlCompressedTexImage2D; + #endif // PFNGLCOMPRESSEDTEXIMAGE2DPROC + #ifdef _IRR_WINDOWS_ + typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int); + PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT; + #elif defined(LINUX) && defined(GLX_SGI_swap_control) + PFNGLXSWAPINTERVALSGIPROC glxSwapIntervalSGI; + #endif + PFNGLBINDFRAMEBUFFEREXTPROC pGlBindFramebufferEXT; + PFNGLDELETEFRAMEBUFFERSEXTPROC pGlDeleteFramebuffersEXT; + PFNGLGENFRAMEBUFFERSEXTPROC pGlGenFramebuffersEXT; + PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC pGlCheckFramebufferStatusEXT; + PFNGLFRAMEBUFFERTEXTURE2DEXTPROC pGlFramebufferTexture2DEXT; + PFNGLBINDRENDERBUFFEREXTPROC pGlBindRenderbufferEXT; + PFNGLDELETERENDERBUFFERSEXTPROC pGlDeleteRenderbuffersEXT; + PFNGLGENRENDERBUFFERSEXTPROC pGlGenRenderbuffersEXT; + PFNGLRENDERBUFFERSTORAGEEXTPROC pGlRenderbufferStorageEXT; + PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC pGlFramebufferRenderbufferEXT; + #endif + + #ifdef _IRR_WINDOWS_ + HDC HDc; // Private GDI Device Context + HWND Window; + HGLRC HRc; // Permanent Rendering Context + #elif defined(LINUX) + GLXDrawable XWindow; + Display* XDisplay; + #elif defined(MACOSX) + CIrrDeviceMacOSX *_device; + #endif + }; + +} // end namespace video +} // end namespace irr + + +#endif // _IRR_COMPILE_WITH_OPENGL_ +#endif + + diff --git a/src/dep/src/irrlicht/COpenGLMaterialRenderer.h b/src/dep/src/irrlicht/COpenGLMaterialRenderer.h index 51f87df..e584546 100644 --- a/src/dep/src/irrlicht/COpenGLMaterialRenderer.h +++ b/src/dep/src/irrlicht/COpenGLMaterialRenderer.h @@ -1,719 +1,719 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OPENGL_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_OPENGL_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "COpenGLDriver.h" -#include "IMaterialRenderer.h" - -namespace irr -{ -namespace video -{ - -//! Base class for all internal OpenGL material renderers -class COpenGLMaterialRenderer : public IMaterialRenderer -{ -public: - - //! Constructor - COpenGLMaterialRenderer(video::COpenGLDriver* driver) - : Driver(driver) - { - } - -protected: - - video::COpenGLDriver* Driver; -}; - - -//! Solid material renderer -class COpenGLMaterialRenderer_SOLID : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_SOLID(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(1); - Driver->setTexture(0, material.Textures[0]); - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - // thanks to Murphy, the following line removed some - // bugs with several OpenGL implementations. - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - } - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - - -//! Generic Texture Blend -class COpenGLMaterialRenderer_ONETEXTURE_BLEND : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_ONETEXTURE_BLEND(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(1); - Driver->setTexture(0, material.Textures[0]); - - -// if (material.MaterialType != lastMaterial.MaterialType || -// material.MaterialTypeParam != lastMaterial.MaterialTypeParam || -// resetAllRenderstates) - { - - E_BLEND_FACTOR srcFact,dstFact; - E_MODULATE_FUNC modulate; - unpack_texureBlendFunc ( srcFact, dstFact, modulate, material.MaterialTypeParam ); - - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); - - glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, (f32) modulate ); - - glBlendFunc( getGLBlend(srcFact), getGLBlend(dstFact) ); - glEnable(GL_BLEND); - - if ( getTexelAlpha ( srcFact ) + getTexelAlpha ( dstFact ) ) - { - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); - - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); - - } - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - - } - - virtual void OnUnsetMaterial() - { - glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.f ); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); - - glDisable(GL_BLEND); - } - - - private: - - u32 getGLBlend ( E_BLEND_FACTOR factor ) const - { - u32 r = 0; - switch ( factor ) - { - case EBF_ZERO: r = GL_ZERO; break; - case EBF_ONE: r = GL_ONE; break; - case EBF_DST_COLOR: r = GL_DST_COLOR; break; - case EBF_ONE_MINUS_DST_COLOR: r = GL_ONE_MINUS_DST_COLOR; break; - case EBF_SRC_COLOR: r = GL_SRC_COLOR; break; - case EBF_ONE_MINUS_SRC_COLOR: r = GL_ONE_MINUS_SRC_COLOR; break; - case EBF_SRC_ALPHA: r = GL_SRC_ALPHA; break; - case EBF_ONE_MINUS_SRC_ALPHA: r = GL_ONE_MINUS_SRC_ALPHA; break; - case EBF_DST_ALPHA: r = GL_DST_ALPHA; break; - case EBF_ONE_MINUS_DST_ALPHA: r = GL_ONE_MINUS_DST_ALPHA; break; - case EBF_SRC_ALPHA_SATURATE: r = GL_SRC_ALPHA_SATURATE; break; - } - return r; - } - - u32 getTexelAlpha ( E_BLEND_FACTOR factor ) const - { - u32 r; - switch ( factor ) - { - case EBF_SRC_ALPHA: r = 1; break; - case EBF_ONE_MINUS_SRC_ALPHA: r = 1; break; - case EBF_DST_ALPHA: r = 1; break; - case EBF_ONE_MINUS_DST_ALPHA: r = 1; break; - case EBF_SRC_ALPHA_SATURATE: r = 1; break; - default: r = 0; break; - } - return r; - } - - -}; - - -//! Solid 2 layer material renderer -class COpenGLMaterialRenderer_SOLID_2_LAYER : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_SOLID_2_LAYER(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(2); - Driver->setTexture(1, material.Textures[1]); - Driver->setTexture(0, material.Textures[0]); - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - Driver->extGlActiveTextureARB(GL_TEXTURE0_ARB); - } - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - } - - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - } -}; - - -//! Transparent add color material renderer -class COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(1); - Driver->setTexture(0, material.Textures[0]); - //if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - glDisable(GL_ALPHA_TEST); - - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glEnable(GL_BLEND); - } - - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() - { - return true; - } -}; - - -//! Transparent vertex alpha material renderer -class COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(1); - Driver->setTexture(0, material.Textures[0]); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - glDisable(GL_ALPHA_TEST); - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT ); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_EXT ); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); - - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - } - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - glDepthMask(GL_FALSE); - } - - virtual void OnUnsetMaterial() - { - // default values - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE ); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE ); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_EXT ); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE ); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); - - glDisable(GL_BLEND); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() - { - return true; - } -}; - - -//! Transparent alpha channel material renderer -class COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(1); - Driver->setTexture(0, material.Textures[0]); - - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates - || material.MaterialTypeParam != lastMaterial.MaterialTypeParam ) - { - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glEnable(GL_ALPHA_TEST); - - f32 refValue = material.MaterialTypeParam; - if ( refValue == 0.0f ) - refValue = 0.5f; - - glAlphaFunc(GL_GREATER, refValue); - } - } - - virtual void OnUnsetMaterial() - { - glDisable(GL_ALPHA_TEST); - glDisable(GL_BLEND); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() - { - return true; - } -}; - - - -//! Transparent alpha channel material renderer -class COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(1); - Driver->setTexture(0, material.Textures[0]); - - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - glEnable(GL_ALPHA_TEST); - glDisable(GL_BLEND); - - glAlphaFunc(GL_GREATER, 0.5); - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - } - } - - virtual void OnUnsetMaterial() - { - glDisable(GL_ALPHA_TEST); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() - { - return false; // this material is not really transparent because it does no blending. - } -}; - - -//! material renderer for all kinds of lightmaps -class COpenGLMaterialRenderer_LIGHTMAP : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_LIGHTMAP(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(2); - Driver->setTexture(1, material.Textures[1]); - Driver->setTexture(0, material.Textures[0]); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - - // diffuse map - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - switch (material.MaterialType) - { - case EMT_LIGHTMAP_LIGHTING: - case EMT_LIGHTMAP_LIGHTING_M2: - case EMT_LIGHTMAP_LIGHTING_M4: - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - break; - case EMT_LIGHTMAP_ADD: - case EMT_LIGHTMAP: - case EMT_LIGHTMAP_M2: - case EMT_LIGHTMAP_M4: - default: - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE); - break; - } - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR ); - - // lightmap - - Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - - if (material.MaterialType == EMT_LIGHTMAP_ADD) - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD_SIGNED_ARB); - else - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA); - - switch (material.MaterialType) - { - case EMT_LIGHTMAP_M4: - case EMT_LIGHTMAP_LIGHTING_M4: - glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 4.0f); - break; - case EMT_LIGHTMAP_M2: - case EMT_LIGHTMAP_LIGHTING_M2: - glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f); - break; - default: - glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.0f); - } - } - } - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - - - -//! detail map material renderer -class COpenGLMaterialRenderer_DETAIL_MAP : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_DETAIL_MAP(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(2); - Driver->setTexture(1, material.Textures[1]); - Driver->setTexture(0, material.Textures[0]); - - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - - // diffuse map - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE); - - // detailmap - - Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD_SIGNED_EXT); - - glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_EXT,GL_PREVIOUS_EXT); - glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND0_RGB_EXT,GL_SRC_COLOR); - - glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_EXT, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND1_RGB_EXT,GL_SRC_COLOR); - } - } - } -}; - - -//! sphere map material renderer -class COpenGLMaterialRenderer_SPHERE_MAP : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_SPHERE_MAP(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(1); - Driver->setTexture(0, material.Textures[0]); - - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); - - Driver->extGlActiveTextureARB(GL_TEXTURE0_ARB); - } - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); - } - } - - virtual void OnUnsetMaterial() - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - Driver->extGlActiveTextureARB(GL_TEXTURE0_ARB); - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - } -}; - - -//! reflection 2 layer material renderer -class COpenGLMaterialRenderer_REFLECTION_2_LAYER : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_REFLECTION_2_LAYER(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(2); - Driver->setTexture(1, material.Textures[1]); - Driver->setTexture(0, material.Textures[0]); - - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - glDisable(GL_ALPHA_TEST); - glDisable(GL_BLEND); - - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE ); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT ); - - Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); - - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); - } - else - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); - } - } - } - - virtual void OnUnsetMaterial() - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTextureARB(GL_TEXTURE0_ARB); - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // default value - Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - } - else - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - } - } -}; - - -//! reflection 2 layer material renderer -class COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(2); - Driver->setTexture(1, material.Textures[1]); - Driver->setTexture(0, material.Textures[0]); - - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTextureARB(GL_TEXTURE0_ARB); - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE ); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT ); - - Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); - } - - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glEnable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); - } - glDepthMask(GL_FALSE); - } - - virtual void OnUnsetMaterial() - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - Driver->extGlActiveTextureARB(GL_TEXTURE0_ARB); - } - } - - //! Returns if the material is transparent. - virtual bool isTransparent() - { - return true; - } -}; - -} // end namespace video -} // end namespace irr - -#endif -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_OPENGL_MATERIAL_RENDERER_H_INCLUDED__ +#define __C_OPENGL_MATERIAL_RENDERER_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "COpenGLDriver.h" +#include "IMaterialRenderer.h" + +namespace irr +{ +namespace video +{ + +//! Base class for all internal OpenGL material renderers +class COpenGLMaterialRenderer : public IMaterialRenderer +{ +public: + + //! Constructor + COpenGLMaterialRenderer(video::COpenGLDriver* driver) + : Driver(driver) + { + } + +protected: + + video::COpenGLDriver* Driver; +}; + + +//! Solid material renderer +class COpenGLMaterialRenderer_SOLID : public COpenGLMaterialRenderer +{ +public: + + COpenGLMaterialRenderer_SOLID(video::COpenGLDriver* d) + : COpenGLMaterialRenderer(d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + Driver->disableTextures(1); + Driver->setTexture(0, material.Textures[0]); + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + // thanks to Murphy, the following line removed some + // bugs with several OpenGL implementations. + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + } + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } +}; + + +//! Generic Texture Blend +class COpenGLMaterialRenderer_ONETEXTURE_BLEND : public COpenGLMaterialRenderer +{ +public: + + COpenGLMaterialRenderer_ONETEXTURE_BLEND(video::COpenGLDriver* d) + : COpenGLMaterialRenderer(d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + Driver->disableTextures(1); + Driver->setTexture(0, material.Textures[0]); + + +// if (material.MaterialType != lastMaterial.MaterialType || +// material.MaterialTypeParam != lastMaterial.MaterialTypeParam || +// resetAllRenderstates) + { + + E_BLEND_FACTOR srcFact,dstFact; + E_MODULATE_FUNC modulate; + unpack_texureBlendFunc ( srcFact, dstFact, modulate, material.MaterialTypeParam ); + + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); + + glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, (f32) modulate ); + + glBlendFunc( getGLBlend(srcFact), getGLBlend(dstFact) ); + glEnable(GL_BLEND); + + if ( getTexelAlpha ( srcFact ) + getTexelAlpha ( dstFact ) ) + { + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); + + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); + + } + } + + services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + + } + + virtual void OnUnsetMaterial() + { + glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.f ); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); + + glDisable(GL_BLEND); + } + + + private: + + u32 getGLBlend ( E_BLEND_FACTOR factor ) const + { + u32 r = 0; + switch ( factor ) + { + case EBF_ZERO: r = GL_ZERO; break; + case EBF_ONE: r = GL_ONE; break; + case EBF_DST_COLOR: r = GL_DST_COLOR; break; + case EBF_ONE_MINUS_DST_COLOR: r = GL_ONE_MINUS_DST_COLOR; break; + case EBF_SRC_COLOR: r = GL_SRC_COLOR; break; + case EBF_ONE_MINUS_SRC_COLOR: r = GL_ONE_MINUS_SRC_COLOR; break; + case EBF_SRC_ALPHA: r = GL_SRC_ALPHA; break; + case EBF_ONE_MINUS_SRC_ALPHA: r = GL_ONE_MINUS_SRC_ALPHA; break; + case EBF_DST_ALPHA: r = GL_DST_ALPHA; break; + case EBF_ONE_MINUS_DST_ALPHA: r = GL_ONE_MINUS_DST_ALPHA; break; + case EBF_SRC_ALPHA_SATURATE: r = GL_SRC_ALPHA_SATURATE; break; + } + return r; + } + + u32 getTexelAlpha ( E_BLEND_FACTOR factor ) const + { + u32 r; + switch ( factor ) + { + case EBF_SRC_ALPHA: r = 1; break; + case EBF_ONE_MINUS_SRC_ALPHA: r = 1; break; + case EBF_DST_ALPHA: r = 1; break; + case EBF_ONE_MINUS_DST_ALPHA: r = 1; break; + case EBF_SRC_ALPHA_SATURATE: r = 1; break; + default: r = 0; break; + } + return r; + } + + +}; + + +//! Solid 2 layer material renderer +class COpenGLMaterialRenderer_SOLID_2_LAYER : public COpenGLMaterialRenderer +{ +public: + + COpenGLMaterialRenderer_SOLID_2_LAYER(video::COpenGLDriver* d) + : COpenGLMaterialRenderer(d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + Driver->disableTextures(2); + Driver->setTexture(1, material.Textures[1]); + Driver->setTexture(0, material.Textures[0]); + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + if (Driver->queryFeature(EVDF_MULTITEXTURE)) + { + Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + Driver->extGlActiveTextureARB(GL_TEXTURE0_ARB); + } + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + } + + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + } +}; + + +//! Transparent add color material renderer +class COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR : public COpenGLMaterialRenderer +{ +public: + + COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR(video::COpenGLDriver* d) + : COpenGLMaterialRenderer(d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + Driver->disableTextures(1); + Driver->setTexture(0, material.Textures[0]); + //if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + glDisable(GL_ALPHA_TEST); + + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glEnable(GL_BLEND); + } + + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + + //! Returns if the material is transparent. + virtual bool isTransparent() + { + return true; + } +}; + + +//! Transparent vertex alpha material renderer +class COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public COpenGLMaterialRenderer +{ +public: + + COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA(video::COpenGLDriver* d) + : COpenGLMaterialRenderer(d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + Driver->disableTextures(1); + Driver->setTexture(0, material.Textures[0]); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + glDisable(GL_ALPHA_TEST); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT ); + + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_EXT ); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); + + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + } + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + glDepthMask(GL_FALSE); + } + + virtual void OnUnsetMaterial() + { + // default values + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE ); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE ); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_EXT ); + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE ); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); + + glDisable(GL_BLEND); + } + + //! Returns if the material is transparent. + virtual bool isTransparent() + { + return true; + } +}; + + +//! Transparent alpha channel material renderer +class COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL : public COpenGLMaterialRenderer +{ +public: + + COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(video::COpenGLDriver* d) + : COpenGLMaterialRenderer(d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + Driver->disableTextures(1); + Driver->setTexture(0, material.Textures[0]); + + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates + || material.MaterialTypeParam != lastMaterial.MaterialTypeParam ) + { + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); + + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_ALPHA_TEST); + + f32 refValue = material.MaterialTypeParam; + if ( refValue == 0.0f ) + refValue = 0.5f; + + glAlphaFunc(GL_GREATER, refValue); + } + } + + virtual void OnUnsetMaterial() + { + glDisable(GL_ALPHA_TEST); + glDisable(GL_BLEND); + } + + //! Returns if the material is transparent. + virtual bool isTransparent() + { + return true; + } +}; + + + +//! Transparent alpha channel material renderer +class COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF : public COpenGLMaterialRenderer +{ +public: + + COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(video::COpenGLDriver* d) + : COpenGLMaterialRenderer(d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + Driver->disableTextures(1); + Driver->setTexture(0, material.Textures[0]); + + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + glEnable(GL_ALPHA_TEST); + glDisable(GL_BLEND); + + glAlphaFunc(GL_GREATER, 0.5); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + } + } + + virtual void OnUnsetMaterial() + { + glDisable(GL_ALPHA_TEST); + } + + //! Returns if the material is transparent. + virtual bool isTransparent() + { + return false; // this material is not really transparent because it does no blending. + } +}; + + +//! material renderer for all kinds of lightmaps +class COpenGLMaterialRenderer_LIGHTMAP : public COpenGLMaterialRenderer +{ +public: + + COpenGLMaterialRenderer_LIGHTMAP(video::COpenGLDriver* d) + : COpenGLMaterialRenderer(d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + Driver->disableTextures(2); + Driver->setTexture(1, material.Textures[1]); + Driver->setTexture(0, material.Textures[0]); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + if (Driver->queryFeature(EVDF_MULTITEXTURE)) + { + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + + // diffuse map + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + switch (material.MaterialType) + { + case EMT_LIGHTMAP_LIGHTING: + case EMT_LIGHTMAP_LIGHTING_M2: + case EMT_LIGHTMAP_LIGHTING_M4: + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + break; + case EMT_LIGHTMAP_ADD: + case EMT_LIGHTMAP: + case EMT_LIGHTMAP_M2: + case EMT_LIGHTMAP_M4: + default: + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE); + break; + } + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR ); + + // lightmap + + Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + + if (material.MaterialType == EMT_LIGHTMAP_ADD) + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD_SIGNED_ARB); + else + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); + + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA); + + switch (material.MaterialType) + { + case EMT_LIGHTMAP_M4: + case EMT_LIGHTMAP_LIGHTING_M4: + glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 4.0f); + break; + case EMT_LIGHTMAP_M2: + case EMT_LIGHTMAP_LIGHTING_M2: + glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f); + break; + default: + glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.0f); + } + } + } + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } +}; + + + +//! detail map material renderer +class COpenGLMaterialRenderer_DETAIL_MAP : public COpenGLMaterialRenderer +{ +public: + + COpenGLMaterialRenderer_DETAIL_MAP(video::COpenGLDriver* d) + : COpenGLMaterialRenderer(d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + Driver->disableTextures(2); + Driver->setTexture(1, material.Textures[1]); + Driver->setTexture(0, material.Textures[0]); + + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + if (Driver->queryFeature(EVDF_MULTITEXTURE)) + { + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + + // diffuse map + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE); + + // detailmap + + Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD_SIGNED_EXT); + + glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_EXT,GL_PREVIOUS_EXT); + glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND0_RGB_EXT,GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_EXT, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND1_RGB_EXT,GL_SRC_COLOR); + } + } + } +}; + + +//! sphere map material renderer +class COpenGLMaterialRenderer_SPHERE_MAP : public COpenGLMaterialRenderer +{ +public: + + COpenGLMaterialRenderer_SPHERE_MAP(video::COpenGLDriver* d) + : COpenGLMaterialRenderer(d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + Driver->disableTextures(1); + Driver->setTexture(0, material.Textures[0]); + + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + if (Driver->queryFeature(EVDF_MULTITEXTURE)) + { + Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + + Driver->extGlActiveTextureARB(GL_TEXTURE0_ARB); + } + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + } + } + + virtual void OnUnsetMaterial() + { + if (Driver->queryFeature(EVDF_MULTITEXTURE)) + Driver->extGlActiveTextureARB(GL_TEXTURE0_ARB); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + } +}; + + +//! reflection 2 layer material renderer +class COpenGLMaterialRenderer_REFLECTION_2_LAYER : public COpenGLMaterialRenderer +{ +public: + + COpenGLMaterialRenderer_REFLECTION_2_LAYER(video::COpenGLDriver* d) + : COpenGLMaterialRenderer(d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + Driver->disableTextures(2); + Driver->setTexture(1, material.Textures[1]); + Driver->setTexture(0, material.Textures[0]); + + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + glDisable(GL_ALPHA_TEST); + glDisable(GL_BLEND); + + if (Driver->queryFeature(EVDF_MULTITEXTURE)) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE ); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT ); + + Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); + + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + } + else + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + } + } + } + + virtual void OnUnsetMaterial() + { + if (Driver->queryFeature(EVDF_MULTITEXTURE)) + { + Driver->extGlActiveTextureARB(GL_TEXTURE0_ARB); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // default value + Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + } + else + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + } + } +}; + + +//! reflection 2 layer material renderer +class COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER : public COpenGLMaterialRenderer +{ +public: + + COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(video::COpenGLDriver* d) + : COpenGLMaterialRenderer(d) {} + + virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices* services) + { + Driver->disableTextures(2); + Driver->setTexture(1, material.Textures[1]); + Driver->setTexture(0, material.Textures[0]); + + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + if (Driver->queryFeature(EVDF_MULTITEXTURE)) + { + Driver->extGlActiveTextureARB(GL_TEXTURE0_ARB); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE ); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT ); + + Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); + } + + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glEnable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + } + glDepthMask(GL_FALSE); + } + + virtual void OnUnsetMaterial() + { + if (Driver->queryFeature(EVDF_MULTITEXTURE)) + { + Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + Driver->extGlActiveTextureARB(GL_TEXTURE0_ARB); + } + } + + //! Returns if the material is transparent. + virtual bool isTransparent() + { + return true; + } +}; + +} // end namespace video +} // end namespace irr + +#endif +#endif + diff --git a/src/dep/src/irrlicht/COpenGLNormalMapRenderer.cpp b/src/dep/src/irrlicht/COpenGLNormalMapRenderer.cpp index 979641a..6334c2f 100644 --- a/src/dep/src/irrlicht/COpenGLNormalMapRenderer.cpp +++ b/src/dep/src/irrlicht/COpenGLNormalMapRenderer.cpp @@ -1,296 +1,296 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "COpenGLNormalMapRenderer.h" -#include "IGPUProgrammingServices.h" -#include "IShaderConstantSetCallBack.h" -#include "IVideoDriver.h" -#include "os.h" -#include "COpenGLDriver.h" - -namespace irr -{ -namespace video -{ - -// Irrlicht Engine OpenGL render path normal map vertex shader -// I guess it could be optimized a lot, because I wrote it in D3D ASM and -// transfered it 1:1 to OpenGL -const char OPENGL_NORMAL_MAP_VSH[] = - "!!ARBvp1.0\n"\ - "#input\n"\ - "# 0-3: transposed world matrix;\n"\ - "#;12: Light01 position \n"\ - "#;13: x,y,z: Light01 color; .w: 1/LightRadius² \n"\ - "#;14: Light02 position \n"\ - "#;15: x,y,z: Light02 color; .w: 1/LightRadius² \n"\ - "\n"\ - "ATTRIB InPos = vertex.position;\n"\ - "ATTRIB InColor = vertex.color;\n"\ - "ATTRIB InNormal = vertex.normal;\n"\ - "ATTRIB InTexCoord = vertex.texcoord[0];\n"\ - "ATTRIB InTangent = vertex.texcoord[1];\n"\ - "ATTRIB InBinormal = vertex.texcoord[2];\n"\ - "\n"\ - "#output\n"\ - "OUTPUT OutPos = result.position;\n"\ - "OUTPUT OutLightColor1 = result.color.primary;\n"\ - "OUTPUT OutLightColor2 = result.color.secondary;\n"\ - "OUTPUT OutTexCoord = result.texcoord[0];\n"\ - "OUTPUT OutLightVector1 = result.texcoord[1];\n"\ - "OUTPUT OutLightVector2 = result.texcoord[2];\n"\ - "\n"\ - "PARAM MVP[4] = { state.matrix.mvp }; # modelViewProjection matrix.\n"\ - "TEMP Temp;\n"\ - "TEMP TempColor;\n"\ - "TEMP TempNormal;\n"\ - "TEMP TempTangent;\n"\ - "TEMP TempBinormal;\n"\ - "TEMP TempLightVector1;\n"\ - "TEMP TempLightVector2;\n"\ - "TEMP TempTransLightV1;\n"\ - "TEMP TempTransLightV2;\n"\ - "\n"\ - "# transform position to clip space \n"\ - "DP4 OutPos.x, MVP[0], InPos;\n"\ - "DP4 OutPos.y, MVP[1], InPos;\n"\ - "DP4 OutPos.z, MVP[2], InPos;\n"\ - "DP4 OutPos.w, MVP[3], InPos;\n"\ - "\n"\ - "# transform normal \n"\ - "DP3 TempNormal.x, InNormal.x, program.local[0];\n"\ - "DP3 TempNormal.y, InNormal.y, program.local[1]; \n"\ - "DP3 TempNormal.z, InNormal.z, program.local[2];\n"\ - "\n"\ - "# transform tangent \n"\ - "DP3 TempTangent.x, InTangent.x, program.local[0];\n"\ - "DP3 TempTangent.y, InTangent.y, program.local[1]; \n"\ - "DP3 TempTangent.z, InTangent.z, program.local[2];\n"\ - "\n"\ - "# transform binormal \n"\ - "DP3 TempBinormal.x, InBinormal.x, program.local[0];\n"\ - "DP3 TempBinormal.y, InBinormal.y, program.local[1]; \n"\ - "DP3 TempBinormal.z, InBinormal.z, program.local[2];\n"\ - "\n"\ - "# vertex into world position \n"\ - "DP4 Temp.x, InPos, program.local[0];\n"\ - "DP4 Temp.y, InPos, program.local[1];\n"\ - "DP4 Temp.z, InPos, program.local[2];\n"\ - "DP4 Temp.w, InPos, program.local[3];\n"\ - "\n"\ - "# vertex - lightpositions \n"\ - "SUB TempLightVector1, program.local[12], Temp; \n"\ - "SUB TempLightVector2, program.local[14], Temp; \n"\ - "\n"\ - "# transform the light vector 1 with U, V, W \n"\ - "DP3 TempTransLightV1.x, TempTangent, TempLightVector1; \n"\ - "DP3 TempTransLightV1.y, TempBinormal, TempLightVector1; \n"\ - "DP3 TempTransLightV1.z, TempNormal, TempLightVector1; \n"\ - "\n"\ - "# transform the light vector 2 with U, V, W \n"\ - "DP3 TempTransLightV2.x, TempTangent, TempLightVector2; \n"\ - "DP3 TempTransLightV2.y, TempBinormal, TempLightVector2; \n"\ - "DP3 TempTransLightV2.z, TempNormal, TempLightVector2; \n"\ - "\n"\ - "# normalize light vector 1 \n"\ - "DP3 TempTransLightV1.w, TempTransLightV1, TempTransLightV1; \n"\ - "RSQ TempTransLightV1.w, TempTransLightV1.w; \n"\ - "MUL TempTransLightV1, TempTransLightV1, TempTransLightV1.w;\n"\ - "\n"\ - "# normalize light vector 2 \n"\ - "DP3 TempTransLightV2.w, TempTransLightV2, TempTransLightV2; \n"\ - "RSQ TempTransLightV2.w, TempTransLightV2.w; \n"\ - "MUL TempTransLightV2, TempTransLightV2, TempTransLightV2.w;\n"\ - "\n"\ - "\n"\ - "# move light vectors out\n"\ - "MAD OutLightVector1, TempTransLightV1, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ - "MAD OutLightVector2, TempTransLightV2, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ - "\n"\ - "# calculate attenuation of light 1\n"\ - "MOV TempLightVector1.w, {0,0,0,0}; \n"\ - "DP3 TempLightVector1.x, TempLightVector1, TempLightVector1; \n"\ - "MUL TempLightVector1.x, TempLightVector1.x, program.local[13].w; \n"\ - "RSQ TempLightVector1, TempLightVector1.x; \n"\ - "MUL OutLightColor1, TempLightVector1, program.local[13]; # resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "# calculate attenuation of light 2\n"\ - "MOV TempLightVector2.w, {0,0,0,0}; \n"\ - "DP3 TempLightVector2.x, TempLightVector2, TempLightVector2; \n"\ - "MUL TempLightVector2.x, TempLightVector2.x, program.local[15].w; \n"\ - "RSQ TempLightVector2, TempLightVector2.x; \n"\ - "MUL OutLightColor2, TempLightVector2, program.local[15]; # resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "# move out texture coordinates and original alpha value\n"\ - "MOV OutTexCoord, InTexCoord; \n"\ - "MOV OutLightColor1.w, InColor.w; \n"\ - "\n"\ - "END\n"; - -// Irrlicht Engine OpenGL render path normal map pixel shader -// I guess it could be optimized a bit, because I wrote it in D3D ASM and -// transfered it 1:1 to OpenGL -const char OPENGL_NORMAL_MAP_PSH[] = - "!!ARBfp1.0\n"\ - "\n"\ - "#Input\n"\ - "ATTRIB inTexCoord = fragment.texcoord[0]; \n"\ - "ATTRIB light1Vector = fragment.texcoord[1]; \n"\ - "ATTRIB light2Vector = fragment.texcoord[2]; \n"\ - "ATTRIB light1Color = fragment.color.primary; \n"\ - "ATTRIB light2Color = fragment.color.secondary; \n"\ - "\n"\ - "#Output\n"\ - "OUTPUT outColor = result.color;\n"\ - "TEMP temp;\n"\ - "TEMP temp2;\n"\ - "TEMP colorMapColor;\n"\ - "TEMP normalMapColor;\n"\ - "\n"\ - "# fetch color and normal map; \n"\ - "TXP colorMapColor, inTexCoord, texture[0], 2D; \n"\ - "TXP normalMapColor, inTexCoord, texture[1], 2D; \n"\ - "\n"\ - "# calculate color of light1; \n"\ - "MAD normalMapColor, normalMapColor, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ - "MAD temp, light1Vector, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ - "DP3_SAT temp, normalMapColor, temp; \n"\ - "MUL temp, light1Color, temp; \n"\ - "\n"\ - "# calculate color of light2; \n"\ - "MAD temp2, light2Vector, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ - "DP3_SAT temp2, normalMapColor, light2Vector; \n"\ - "MAD temp, light2Color, temp2, temp; \n"\ - "\n"\ - "# luminance * base color; \n"\ - "MUL outColor, temp, colorMapColor; \n"\ - "MOV outColor.a, light1Color.a; #write interpolated vertex alpha value\n"\ - "\n"\ - "END\n"; - -//! Constructor -COpenGLNormalMapRenderer::COpenGLNormalMapRenderer(video::COpenGLDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) - : COpenGLShaderMaterialRenderer(driver, 0, baseMaterial), CompiledShaders(true) -{ - // set this as callback. We could have done this in - // the initialization list, but some compilers don't like it. - - CallBack = this; - - // basicly, this thing simply compiles these hardcoded shaders if the - // hardware is able to do them, otherwise it maps to the base material - - if (!driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) || - !driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1)) - { - // this hardware is not able to do shaders. Fall back to - // base material. - outMaterialTypeNr = driver->addMaterialRenderer(this); - return; - } - - // check if already compiled normal map shaders are there. - - video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_NORMAL_MAP_SOLID); - - if (renderer) - { - // use the already compiled shaders - video::COpenGLNormalMapRenderer* nmr = (video::COpenGLNormalMapRenderer*)renderer; - CompiledShaders = false; - - VertexShader = nmr->VertexShader; - PixelShader = nmr->PixelShader; - - outMaterialTypeNr = driver->addMaterialRenderer(this); - } - else - { - // compile shaders on our own - init(outMaterialTypeNr, OPENGL_NORMAL_MAP_VSH, OPENGL_NORMAL_MAP_PSH, EVT_TANGENTS); - } -} - - -//! Destructor -COpenGLNormalMapRenderer::~COpenGLNormalMapRenderer() -{ - if (CallBack == this) - CallBack = 0; - - if (!CompiledShaders) - { - // prevent this from deleting shaders we did not create - VertexShader = 0; - PixelShader = 0; - } -} - - -//! Returns the render capability of the material. -s32 COpenGLNormalMapRenderer::getRenderCapability() -{ - if (Driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) && - Driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1)) - return 0; - - return 1; -} - - -//! Called by the engine when the vertex and/or pixel shader constants for an -//! material renderer should be set. -void COpenGLNormalMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) -{ - video::IVideoDriver* driver = services->getVideoDriver(); - - // set transposed world matrix - const core::matrix4& tWorld = driver->getTransform(video::ETS_WORLD).getTransposed(); - services->setVertexShaderConstant(tWorld.pointer(), 0, 4); - - // set transposed worldViewProj matrix - core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - core::matrix4 tr(worldViewProj.getTransposed()); - services->setVertexShaderConstant(tr.pointer(), 8, 4); - - // here we've got to fetch the fixed function lights from the driver - // and set them as constants - - u32 cnt = driver->getDynamicLightCount(); - - for (u32 i=0; i<2; ++i) - { - video::SLight light; - - if (igetDynamicLight(i); - else - { - light.DiffuseColor.set(0,0,0); // make light dark - light.Radius = 1.0f; - } - - light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation - - services->setVertexShaderConstant( - reinterpret_cast(&light.Position), 12+(i*2), 1); - - services->setVertexShaderConstant( - reinterpret_cast(&light.DiffuseColor), 13+(i*2), 1); - } -} - - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "COpenGLNormalMapRenderer.h" +#include "IGPUProgrammingServices.h" +#include "IShaderConstantSetCallBack.h" +#include "IVideoDriver.h" +#include "os.h" +#include "COpenGLDriver.h" + +namespace irr +{ +namespace video +{ + +// Irrlicht Engine OpenGL render path normal map vertex shader +// I guess it could be optimized a lot, because I wrote it in D3D ASM and +// transfered it 1:1 to OpenGL +const char OPENGL_NORMAL_MAP_VSH[] = + "!!ARBvp1.0\n"\ + "#input\n"\ + "# 0-3: transposed world matrix;\n"\ + "#;12: Light01 position \n"\ + "#;13: x,y,z: Light01 color; .w: 1/LightRadius² \n"\ + "#;14: Light02 position \n"\ + "#;15: x,y,z: Light02 color; .w: 1/LightRadius² \n"\ + "\n"\ + "ATTRIB InPos = vertex.position;\n"\ + "ATTRIB InColor = vertex.color;\n"\ + "ATTRIB InNormal = vertex.normal;\n"\ + "ATTRIB InTexCoord = vertex.texcoord[0];\n"\ + "ATTRIB InTangent = vertex.texcoord[1];\n"\ + "ATTRIB InBinormal = vertex.texcoord[2];\n"\ + "\n"\ + "#output\n"\ + "OUTPUT OutPos = result.position;\n"\ + "OUTPUT OutLightColor1 = result.color.primary;\n"\ + "OUTPUT OutLightColor2 = result.color.secondary;\n"\ + "OUTPUT OutTexCoord = result.texcoord[0];\n"\ + "OUTPUT OutLightVector1 = result.texcoord[1];\n"\ + "OUTPUT OutLightVector2 = result.texcoord[2];\n"\ + "\n"\ + "PARAM MVP[4] = { state.matrix.mvp }; # modelViewProjection matrix.\n"\ + "TEMP Temp;\n"\ + "TEMP TempColor;\n"\ + "TEMP TempNormal;\n"\ + "TEMP TempTangent;\n"\ + "TEMP TempBinormal;\n"\ + "TEMP TempLightVector1;\n"\ + "TEMP TempLightVector2;\n"\ + "TEMP TempTransLightV1;\n"\ + "TEMP TempTransLightV2;\n"\ + "\n"\ + "# transform position to clip space \n"\ + "DP4 OutPos.x, MVP[0], InPos;\n"\ + "DP4 OutPos.y, MVP[1], InPos;\n"\ + "DP4 OutPos.z, MVP[2], InPos;\n"\ + "DP4 OutPos.w, MVP[3], InPos;\n"\ + "\n"\ + "# transform normal \n"\ + "DP3 TempNormal.x, InNormal.x, program.local[0];\n"\ + "DP3 TempNormal.y, InNormal.y, program.local[1]; \n"\ + "DP3 TempNormal.z, InNormal.z, program.local[2];\n"\ + "\n"\ + "# transform tangent \n"\ + "DP3 TempTangent.x, InTangent.x, program.local[0];\n"\ + "DP3 TempTangent.y, InTangent.y, program.local[1]; \n"\ + "DP3 TempTangent.z, InTangent.z, program.local[2];\n"\ + "\n"\ + "# transform binormal \n"\ + "DP3 TempBinormal.x, InBinormal.x, program.local[0];\n"\ + "DP3 TempBinormal.y, InBinormal.y, program.local[1]; \n"\ + "DP3 TempBinormal.z, InBinormal.z, program.local[2];\n"\ + "\n"\ + "# vertex into world position \n"\ + "DP4 Temp.x, InPos, program.local[0];\n"\ + "DP4 Temp.y, InPos, program.local[1];\n"\ + "DP4 Temp.z, InPos, program.local[2];\n"\ + "DP4 Temp.w, InPos, program.local[3];\n"\ + "\n"\ + "# vertex - lightpositions \n"\ + "SUB TempLightVector1, program.local[12], Temp; \n"\ + "SUB TempLightVector2, program.local[14], Temp; \n"\ + "\n"\ + "# transform the light vector 1 with U, V, W \n"\ + "DP3 TempTransLightV1.x, TempTangent, TempLightVector1; \n"\ + "DP3 TempTransLightV1.y, TempBinormal, TempLightVector1; \n"\ + "DP3 TempTransLightV1.z, TempNormal, TempLightVector1; \n"\ + "\n"\ + "# transform the light vector 2 with U, V, W \n"\ + "DP3 TempTransLightV2.x, TempTangent, TempLightVector2; \n"\ + "DP3 TempTransLightV2.y, TempBinormal, TempLightVector2; \n"\ + "DP3 TempTransLightV2.z, TempNormal, TempLightVector2; \n"\ + "\n"\ + "# normalize light vector 1 \n"\ + "DP3 TempTransLightV1.w, TempTransLightV1, TempTransLightV1; \n"\ + "RSQ TempTransLightV1.w, TempTransLightV1.w; \n"\ + "MUL TempTransLightV1, TempTransLightV1, TempTransLightV1.w;\n"\ + "\n"\ + "# normalize light vector 2 \n"\ + "DP3 TempTransLightV2.w, TempTransLightV2, TempTransLightV2; \n"\ + "RSQ TempTransLightV2.w, TempTransLightV2.w; \n"\ + "MUL TempTransLightV2, TempTransLightV2, TempTransLightV2.w;\n"\ + "\n"\ + "\n"\ + "# move light vectors out\n"\ + "MAD OutLightVector1, TempTransLightV1, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ + "MAD OutLightVector2, TempTransLightV2, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ + "\n"\ + "# calculate attenuation of light 1\n"\ + "MOV TempLightVector1.w, {0,0,0,0}; \n"\ + "DP3 TempLightVector1.x, TempLightVector1, TempLightVector1; \n"\ + "MUL TempLightVector1.x, TempLightVector1.x, program.local[13].w; \n"\ + "RSQ TempLightVector1, TempLightVector1.x; \n"\ + "MUL OutLightColor1, TempLightVector1, program.local[13]; # resulting light color = lightcolor * attenuation \n"\ + "\n"\ + "# calculate attenuation of light 2\n"\ + "MOV TempLightVector2.w, {0,0,0,0}; \n"\ + "DP3 TempLightVector2.x, TempLightVector2, TempLightVector2; \n"\ + "MUL TempLightVector2.x, TempLightVector2.x, program.local[15].w; \n"\ + "RSQ TempLightVector2, TempLightVector2.x; \n"\ + "MUL OutLightColor2, TempLightVector2, program.local[15]; # resulting light color = lightcolor * attenuation \n"\ + "\n"\ + "# move out texture coordinates and original alpha value\n"\ + "MOV OutTexCoord, InTexCoord; \n"\ + "MOV OutLightColor1.w, InColor.w; \n"\ + "\n"\ + "END\n"; + +// Irrlicht Engine OpenGL render path normal map pixel shader +// I guess it could be optimized a bit, because I wrote it in D3D ASM and +// transfered it 1:1 to OpenGL +const char OPENGL_NORMAL_MAP_PSH[] = + "!!ARBfp1.0\n"\ + "\n"\ + "#Input\n"\ + "ATTRIB inTexCoord = fragment.texcoord[0]; \n"\ + "ATTRIB light1Vector = fragment.texcoord[1]; \n"\ + "ATTRIB light2Vector = fragment.texcoord[2]; \n"\ + "ATTRIB light1Color = fragment.color.primary; \n"\ + "ATTRIB light2Color = fragment.color.secondary; \n"\ + "\n"\ + "#Output\n"\ + "OUTPUT outColor = result.color;\n"\ + "TEMP temp;\n"\ + "TEMP temp2;\n"\ + "TEMP colorMapColor;\n"\ + "TEMP normalMapColor;\n"\ + "\n"\ + "# fetch color and normal map; \n"\ + "TXP colorMapColor, inTexCoord, texture[0], 2D; \n"\ + "TXP normalMapColor, inTexCoord, texture[1], 2D; \n"\ + "\n"\ + "# calculate color of light1; \n"\ + "MAD normalMapColor, normalMapColor, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ + "MAD temp, light1Vector, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ + "DP3_SAT temp, normalMapColor, temp; \n"\ + "MUL temp, light1Color, temp; \n"\ + "\n"\ + "# calculate color of light2; \n"\ + "MAD temp2, light2Vector, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ + "DP3_SAT temp2, normalMapColor, light2Vector; \n"\ + "MAD temp, light2Color, temp2, temp; \n"\ + "\n"\ + "# luminance * base color; \n"\ + "MUL outColor, temp, colorMapColor; \n"\ + "MOV outColor.a, light1Color.a; #write interpolated vertex alpha value\n"\ + "\n"\ + "END\n"; + +//! Constructor +COpenGLNormalMapRenderer::COpenGLNormalMapRenderer(video::COpenGLDriver* driver, + s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) + : COpenGLShaderMaterialRenderer(driver, 0, baseMaterial), CompiledShaders(true) +{ + // set this as callback. We could have done this in + // the initialization list, but some compilers don't like it. + + CallBack = this; + + // basicly, this thing simply compiles these hardcoded shaders if the + // hardware is able to do them, otherwise it maps to the base material + + if (!driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) || + !driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1)) + { + // this hardware is not able to do shaders. Fall back to + // base material. + outMaterialTypeNr = driver->addMaterialRenderer(this); + return; + } + + // check if already compiled normal map shaders are there. + + video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_NORMAL_MAP_SOLID); + + if (renderer) + { + // use the already compiled shaders + video::COpenGLNormalMapRenderer* nmr = (video::COpenGLNormalMapRenderer*)renderer; + CompiledShaders = false; + + VertexShader = nmr->VertexShader; + PixelShader = nmr->PixelShader; + + outMaterialTypeNr = driver->addMaterialRenderer(this); + } + else + { + // compile shaders on our own + init(outMaterialTypeNr, OPENGL_NORMAL_MAP_VSH, OPENGL_NORMAL_MAP_PSH, EVT_TANGENTS); + } +} + + +//! Destructor +COpenGLNormalMapRenderer::~COpenGLNormalMapRenderer() +{ + if (CallBack == this) + CallBack = 0; + + if (!CompiledShaders) + { + // prevent this from deleting shaders we did not create + VertexShader = 0; + PixelShader = 0; + } +} + + +//! Returns the render capability of the material. +s32 COpenGLNormalMapRenderer::getRenderCapability() +{ + if (Driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) && + Driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1)) + return 0; + + return 1; +} + + +//! Called by the engine when the vertex and/or pixel shader constants for an +//! material renderer should be set. +void COpenGLNormalMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) +{ + video::IVideoDriver* driver = services->getVideoDriver(); + + // set transposed world matrix + const core::matrix4& tWorld = driver->getTransform(video::ETS_WORLD).getTransposed(); + services->setVertexShaderConstant(tWorld.pointer(), 0, 4); + + // set transposed worldViewProj matrix + core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); + worldViewProj *= driver->getTransform(video::ETS_VIEW); + worldViewProj *= driver->getTransform(video::ETS_WORLD); + core::matrix4 tr(worldViewProj.getTransposed()); + services->setVertexShaderConstant(tr.pointer(), 8, 4); + + // here we've got to fetch the fixed function lights from the driver + // and set them as constants + + u32 cnt = driver->getDynamicLightCount(); + + for (u32 i=0; i<2; ++i) + { + video::SLight light; + + if (igetDynamicLight(i); + else + { + light.DiffuseColor.set(0,0,0); // make light dark + light.Radius = 1.0f; + } + + light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation + + services->setVertexShaderConstant( + reinterpret_cast(&light.Position), 12+(i*2), 1); + + services->setVertexShaderConstant( + reinterpret_cast(&light.DiffuseColor), 13+(i*2), 1); + } +} + + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/COpenGLNormalMapRenderer.h b/src/dep/src/irrlicht/COpenGLNormalMapRenderer.h index c54a37c..c84a206 100644 --- a/src/dep/src/irrlicht/COpenGLNormalMapRenderer.h +++ b/src/dep/src/irrlicht/COpenGLNormalMapRenderer.h @@ -1,49 +1,49 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OPENGL_NORMAL_MAP_RENDERER_H_INCLUDED__ -#define __C_OPENGL_NORMAL_MAP_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "COpenGLShaderMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" - -namespace irr -{ -namespace video -{ - -//! Class for rendering normal maps with OpenGL -class COpenGLNormalMapRenderer : public COpenGLShaderMaterialRenderer, public IShaderConstantSetCallBack -{ -public: - - //! Constructor - COpenGLNormalMapRenderer(video::COpenGLDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); - - //! Destructor - ~COpenGLNormalMapRenderer(); - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); - - //! Returns the render capability of the material. - virtual s32 getRenderCapability(); - -protected: - - bool CompiledShaders; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_OPENGL_NORMAL_MAP_RENDERER_H_INCLUDED__ +#define __C_OPENGL_NORMAL_MAP_RENDERER_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "COpenGLShaderMaterialRenderer.h" +#include "IShaderConstantSetCallBack.h" + +namespace irr +{ +namespace video +{ + +//! Class for rendering normal maps with OpenGL +class COpenGLNormalMapRenderer : public COpenGLShaderMaterialRenderer, public IShaderConstantSetCallBack +{ +public: + + //! Constructor + COpenGLNormalMapRenderer(video::COpenGLDriver* driver, + s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); + + //! Destructor + ~COpenGLNormalMapRenderer(); + + //! Called by the engine when the vertex and/or pixel shader constants for an + //! material renderer should be set. + virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); + + //! Returns the render capability of the material. + virtual s32 getRenderCapability(); + +protected: + + bool CompiledShaders; +}; + + +} // end namespace video +} // end namespace irr + +#endif +#endif + diff --git a/src/dep/src/irrlicht/COpenGLParallaxMapRenderer.cpp b/src/dep/src/irrlicht/COpenGLParallaxMapRenderer.cpp index 148a562..bd7b57e 100644 --- a/src/dep/src/irrlicht/COpenGLParallaxMapRenderer.cpp +++ b/src/dep/src/irrlicht/COpenGLParallaxMapRenderer.cpp @@ -1,361 +1,361 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "COpenGLParallaxMapRenderer.h" -#include "COpenGLDriver.h" -#include "IGPUProgrammingServices.h" -#include "IShaderConstantSetCallBack.h" -#include "IVideoDriver.h" -#include "os.h" - -namespace irr -{ -namespace video -{ - -// Irrlicht Engine OpenGL render path parallax map vertex shader -// I guess it could be optimized a lot, because I wrote it in D3D ASM and -// transfered it 1:1 to OpenGL -const char OPENGL_PARALLAX_MAP_VSH[] = - "!!ARBvp1.0\n"\ - "#input\n"\ - "# 0-3: transposed world matrix;\n"\ - "#;12: Light01 position \n"\ - "#;13: x,y,z: Light01 color; .w: 1/LightRadius² \n"\ - "#;14: Light02 position \n"\ - "#;15: x,y,z: Light02 color; .w: 1/LightRadius² \n"\ - "#;16: Eye position \n"\ - "\n"\ - "ATTRIB InPos = vertex.position;\n"\ - "ATTRIB InColor = vertex.color;\n"\ - "ATTRIB InNormal = vertex.normal;\n"\ - "ATTRIB InTexCoord = vertex.texcoord[0];\n"\ - "ATTRIB InTangent = vertex.texcoord[1];\n"\ - "ATTRIB InBinormal = vertex.texcoord[2];\n"\ - "\n"\ - "#output\n"\ - "OUTPUT OutPos = result.position;\n"\ - "OUTPUT OutLightColor1 = result.color.primary;\n"\ - "OUTPUT OutLightColor2 = result.color.secondary;\n"\ - "OUTPUT OutTexCoord = result.texcoord[0];\n"\ - "OUTPUT OutLightVector1 = result.texcoord[1];\n"\ - "OUTPUT OutLightVector2 = result.texcoord[2];\n"\ - "OUTPUT OutEyeVector = result.texcoord[3];\n"\ - "\n"\ - "PARAM MVP[4] = { state.matrix.mvp }; # modelViewProjection matrix.\n"\ - "TEMP Temp;\n"\ - "TEMP TempColor;\n"\ - "TEMP TempNormal;\n"\ - "TEMP TempTangent;\n"\ - "TEMP TempBinormal;\n"\ - "TEMP TempLightVector1;\n"\ - "TEMP TempLightVector2;\n"\ - "TEMP TempEyeVector;\n"\ - "TEMP TempTransLightV1;\n"\ - "TEMP TempTransLightV2;\n"\ - "\n"\ - "# transform position to clip space \n"\ - "DP4 OutPos.x, MVP[0], InPos;\n"\ - "DP4 OutPos.y, MVP[1], InPos;\n"\ - "DP4 OutPos.z, MVP[2], InPos;\n"\ - "DP4 OutPos.w, MVP[3], InPos;\n"\ - "\n"\ - "# transform normal \n"\ - "DP3 TempNormal.x, InNormal.x, program.local[0];\n"\ - "DP3 TempNormal.y, InNormal.y, program.local[1]; \n"\ - "DP3 TempNormal.z, InNormal.z, program.local[2];\n"\ - "\n"\ - "# transform tangent \n"\ - "DP3 TempTangent.x, InTangent.x, program.local[0];\n"\ - "DP3 TempTangent.y, InTangent.y, program.local[1]; \n"\ - "DP3 TempTangent.z, InTangent.z, program.local[2];\n"\ - "\n"\ - "# transform binormal \n"\ - "DP3 TempBinormal.x, InBinormal.x, program.local[0];\n"\ - "DP3 TempBinormal.y, InBinormal.y, program.local[1]; \n"\ - "DP3 TempBinormal.z, InBinormal.z, program.local[2];\n"\ - "\n"\ - "# vertex into world position \n"\ - "DP4 Temp.x, InPos, program.local[0];\n"\ - "DP4 Temp.y, InPos, program.local[1];\n"\ - "DP4 Temp.z, InPos, program.local[2];\n"\ - "DP4 Temp.w, InPos, program.local[3];\n"\ - "\n"\ - "# vertex - lightpositions \n"\ - "SUB TempLightVector1, program.local[12], Temp; \n"\ - "SUB TempLightVector2, program.local[14], Temp; \n"\ - "\n"\ - "# eye vector \n"\ - "SUB Temp, program.local[16], Temp; \n"\ - "\n"\ - "# transform the light vector 1 with U, V, W \n"\ - "DP3 TempTransLightV1.x, TempTangent, TempLightVector1; \n"\ - "DP3 TempTransLightV1.y, TempBinormal, TempLightVector1; \n"\ - "DP3 TempTransLightV1.z, TempNormal, TempLightVector1; \n"\ - "\n"\ - "# transform the light vector 2 with U, V, W \n"\ - "DP3 TempTransLightV2.x, TempTangent, TempLightVector2; \n"\ - "DP3 TempTransLightV2.y, TempBinormal, TempLightVector2; \n"\ - "DP3 TempTransLightV2.z, TempNormal, TempLightVector2; \n"\ - "\n"\ - "# transform the eye vector with U, V, W \n"\ - "DP3 TempEyeVector.x, TempTangent, Temp; \n"\ - "DP3 TempEyeVector.y, TempBinormal, Temp; \n"\ - "DP3 TempEyeVector.z, TempNormal, Temp; \n"\ - "\n"\ - "# normalize light vector 1 \n"\ - "DP3 TempTransLightV1.w, TempTransLightV1, TempTransLightV1; \n"\ - "RSQ TempTransLightV1.w, TempTransLightV1.w; \n"\ - "MUL TempTransLightV1, TempTransLightV1, TempTransLightV1.w;\n"\ - "\n"\ - "# normalize light vector 2 \n"\ - "DP3 TempTransLightV2.w, TempTransLightV2, TempTransLightV2; \n"\ - "RSQ TempTransLightV2.w, TempTransLightV2.w; \n"\ - "MUL TempTransLightV2, TempTransLightV2, TempTransLightV2.w;\n"\ - "\n"\ - "# normalize eye vector \n"\ - "DP3 TempEyeVector.w, TempEyeVector, TempEyeVector; \n"\ - "RSQ TempEyeVector.w, TempEyeVector.w; \n"\ - "MUL TempEyeVector, TempEyeVector, TempEyeVector.w;\n"\ - "MUL TempEyeVector, TempEyeVector, {1,-1,-1,1}; # flip x \n"\ - "\n"\ - "\n"\ - "# move light and eye vectors out\n"\ - "MAD OutLightVector1, TempTransLightV1, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ - "MAD OutLightVector2, TempTransLightV2, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ - "MAD OutEyeVector, TempEyeVector, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ - "\n"\ - "# calculate attenuation of light 1\n"\ - "MOV TempLightVector1.w, {0,0,0,0}; \n"\ - "DP3 TempLightVector1.x, TempLightVector1, TempLightVector1; \n"\ - "MUL TempLightVector1.x, TempLightVector1.x, program.local[13].w; \n"\ - "RSQ TempLightVector1, TempLightVector1.x; \n"\ - "MUL OutLightColor1, TempLightVector1, program.local[13]; # resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "# calculate attenuation of light 2\n"\ - "MOV TempLightVector2.w, {0,0,0,0}; \n"\ - "DP3 TempLightVector2.x, TempLightVector2, TempLightVector2; \n"\ - "MUL TempLightVector2.x, TempLightVector2.x, program.local[15].w; \n"\ - "RSQ TempLightVector2, TempLightVector2.x; \n"\ - "MUL OutLightColor2, TempLightVector2, program.local[15]; # resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "# move out texture coordinates and original alpha value\n"\ - "MOV OutTexCoord, InTexCoord; \n"\ - "MOV OutLightColor1.w, InColor.w; \n"\ - "\n"\ - "END\n"; - -// Irrlicht Engine OpenGL render path parallax map pixel shader -// I guess it could be optimized a bit, because I wrote it in D3D ASM and -// transfered it 1:1 to OpenGL -const char OPENGL_PARALLAX_MAP_PSH[] = - "!!ARBfp1.0\n"\ - "\n"\ - "#Input\n"\ - "ATTRIB inTexCoord = fragment.texcoord[0]; \n"\ - "ATTRIB light1Vector = fragment.texcoord[1]; \n"\ - "ATTRIB light2Vector = fragment.texcoord[2]; \n"\ - "ATTRIB eyeVector = fragment.texcoord[3]; \n"\ - "ATTRIB light1Color = fragment.color.primary; \n"\ - "ATTRIB light2Color = fragment.color.secondary; \n"\ - "\n"\ - "#Output\n"\ - "OUTPUT outColor = result.color;\n"\ - "TEMP temp;\n"\ - "TEMP temp2;\n"\ - "TEMP colorMapColor;\n"\ - "TEMP normalMapColor;\n"\ - "\n"\ - "PARAM height_scale = program.local[0]; \n"\ - "# fetch color and normal map; \n"\ - "TXP normalMapColor, inTexCoord, texture[1], 2D; \n"\ - "MAD normalMapColor, normalMapColor, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ - "\n"\ - "\n"\ - "# extract eye vector (so substract 0.5f and multiply by 2)\n"\ - "MAD temp, eyeVector, {2,2,2,2}, {-1,-1,-1,-1};\n"\ - "\n"\ - "# height = height * scale \n"\ - "MUL normalMapColor, normalMapColor, height_scale;\n"\ - "\n"\ - "# calculate new texture coord: height * eye + oldTexCoord\n"\ - "MAD temp, temp, normalMapColor.wwww, inTexCoord;\n"\ - "\n"\ - "# fetch new textures \n"\ - "TXP colorMapColor, temp, texture[0], 2D; \n"\ - "TXP normalMapColor, temp, texture[1], 2D; \n"\ - "\n"\ - "# calculate color of light1; \n"\ - "MAD normalMapColor, normalMapColor, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ - "MAD temp, light1Vector, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ - "DP3_SAT temp, normalMapColor, temp; \n"\ - "MUL temp, light1Color, temp; \n"\ - "\n"\ - "# calculate color of light2; \n"\ - "MAD temp2, light2Vector, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ - "DP3_SAT temp2, normalMapColor, light2Vector; \n"\ - "MAD temp, light2Color, temp2, temp; \n"\ - "\n"\ - "# luminance * base color; \n"\ - "MUL outColor, temp, colorMapColor; \n"\ - "MOV outColor.a, light1Color.a; #write interpolated vertex alpha value\n"\ - "\n"\ - "END\n"; - -//! Constructor -COpenGLParallaxMapRenderer::COpenGLParallaxMapRenderer(video::COpenGLDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) - : COpenGLShaderMaterialRenderer(driver, 0, baseMaterial), CompiledShaders(true) -{ - // set this as callback. We could have done this in - // the initialization list, but some compilers don't like it. - - CallBack = this; - - // basicly, this thing simply compiles these hardcoded shaders if the - // hardware is able to do them, otherwise it maps to the base material - - if (!driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) || - !driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1)) - { - // this hardware is not able to do shaders. Fall back to - // base material. - outMaterialTypeNr = driver->addMaterialRenderer(this); - return; - } - - // check if already compiled normal map shaders are there. - - video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_PARALLAX_MAP_SOLID); - - if (renderer) - { - // use the already compiled shaders - video::COpenGLParallaxMapRenderer* nmr = (video::COpenGLParallaxMapRenderer*)renderer; - CompiledShaders = false; - - VertexShader = nmr->VertexShader; - PixelShader = nmr->PixelShader; - - outMaterialTypeNr = driver->addMaterialRenderer(this); - } - else - { - // compile shaders on our own - init(outMaterialTypeNr, OPENGL_PARALLAX_MAP_VSH, OPENGL_PARALLAX_MAP_PSH, EVT_TANGENTS); - } -} - - -//! Destructor -COpenGLParallaxMapRenderer::~COpenGLParallaxMapRenderer() -{ - if (CallBack == this) - CallBack = 0; - - if (!CompiledShaders) - { - // prevent this from deleting shaders we did not create - VertexShader = 0; - PixelShader = 0; - } -} - - -void COpenGLParallaxMapRenderer::OnSetMaterial(video::SMaterial& material, - const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services) -{ - COpenGLShaderMaterialRenderer::OnSetMaterial(material, lastMaterial, - resetAllRenderstates, services); - - CurrentScale = material.MaterialTypeParam; -} - - - -//! Returns the render capability of the material. -s32 COpenGLParallaxMapRenderer::getRenderCapability() -{ - if (Driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) && - Driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1)) - return 0; - - return 1; -} - - -//! Called by the engine when the vertex and/or pixel shader constants for an -//! material renderer should be set. -void COpenGLParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) -{ - video::IVideoDriver* driver = services->getVideoDriver(); - - // set transposed world matrix - const core::matrix4& tWorld = driver->getTransform(video::ETS_WORLD).getTransposed(); - services->setVertexShaderConstant(tWorld.pointer(), 0, 4); - - // The viewpoint is at (0., 0., 0.) in eye space. - // Turning this into a vector [0 0 0 1] and multiply it by - // the inverse of the view matrix, the resulting vector is the - // object space location of the camera. - - f32 floats[4] = {0.0f,0.0f,0.0f,1.0f}; - core::matrix4 minv(driver->getTransform(video::ETS_VIEW)); - minv.makeInverse(); - minv.multiplyWith1x4Matrix(floats); - services->setVertexShaderConstant(floats, 16, 1); - - // set transposed worldViewProj matrix - core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - core::matrix4 tr(worldViewProj.getTransposed()); - services->setVertexShaderConstant(tr.pointer(), 8, 4); - - // here we've got to fetch the fixed function lights from the driver - // and set them as constants - - u32 cnt = driver->getDynamicLightCount(); - - for (u32 i=0; i<2; ++i) - { - video::SLight light; - - if (igetDynamicLight(i); - else - { - light.DiffuseColor.set(0,0,0); // make light dark - light.Radius = 1.0f; - } - - light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation - - services->setVertexShaderConstant( - reinterpret_cast(&light.Position), 12+(i*2), 1); - - services->setVertexShaderConstant( - reinterpret_cast(&light.DiffuseColor), 13+(i*2), 1); - } - - // set scale factor - f32 factor = 0.02f; // default value - if (CurrentScale != 0.0f) - factor = CurrentScale; - - f32 c6[] = {factor, factor, factor, factor}; - services->setPixelShaderConstant(c6, 0, 1); -} - - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "COpenGLParallaxMapRenderer.h" +#include "COpenGLDriver.h" +#include "IGPUProgrammingServices.h" +#include "IShaderConstantSetCallBack.h" +#include "IVideoDriver.h" +#include "os.h" + +namespace irr +{ +namespace video +{ + +// Irrlicht Engine OpenGL render path parallax map vertex shader +// I guess it could be optimized a lot, because I wrote it in D3D ASM and +// transfered it 1:1 to OpenGL +const char OPENGL_PARALLAX_MAP_VSH[] = + "!!ARBvp1.0\n"\ + "#input\n"\ + "# 0-3: transposed world matrix;\n"\ + "#;12: Light01 position \n"\ + "#;13: x,y,z: Light01 color; .w: 1/LightRadius² \n"\ + "#;14: Light02 position \n"\ + "#;15: x,y,z: Light02 color; .w: 1/LightRadius² \n"\ + "#;16: Eye position \n"\ + "\n"\ + "ATTRIB InPos = vertex.position;\n"\ + "ATTRIB InColor = vertex.color;\n"\ + "ATTRIB InNormal = vertex.normal;\n"\ + "ATTRIB InTexCoord = vertex.texcoord[0];\n"\ + "ATTRIB InTangent = vertex.texcoord[1];\n"\ + "ATTRIB InBinormal = vertex.texcoord[2];\n"\ + "\n"\ + "#output\n"\ + "OUTPUT OutPos = result.position;\n"\ + "OUTPUT OutLightColor1 = result.color.primary;\n"\ + "OUTPUT OutLightColor2 = result.color.secondary;\n"\ + "OUTPUT OutTexCoord = result.texcoord[0];\n"\ + "OUTPUT OutLightVector1 = result.texcoord[1];\n"\ + "OUTPUT OutLightVector2 = result.texcoord[2];\n"\ + "OUTPUT OutEyeVector = result.texcoord[3];\n"\ + "\n"\ + "PARAM MVP[4] = { state.matrix.mvp }; # modelViewProjection matrix.\n"\ + "TEMP Temp;\n"\ + "TEMP TempColor;\n"\ + "TEMP TempNormal;\n"\ + "TEMP TempTangent;\n"\ + "TEMP TempBinormal;\n"\ + "TEMP TempLightVector1;\n"\ + "TEMP TempLightVector2;\n"\ + "TEMP TempEyeVector;\n"\ + "TEMP TempTransLightV1;\n"\ + "TEMP TempTransLightV2;\n"\ + "\n"\ + "# transform position to clip space \n"\ + "DP4 OutPos.x, MVP[0], InPos;\n"\ + "DP4 OutPos.y, MVP[1], InPos;\n"\ + "DP4 OutPos.z, MVP[2], InPos;\n"\ + "DP4 OutPos.w, MVP[3], InPos;\n"\ + "\n"\ + "# transform normal \n"\ + "DP3 TempNormal.x, InNormal.x, program.local[0];\n"\ + "DP3 TempNormal.y, InNormal.y, program.local[1]; \n"\ + "DP3 TempNormal.z, InNormal.z, program.local[2];\n"\ + "\n"\ + "# transform tangent \n"\ + "DP3 TempTangent.x, InTangent.x, program.local[0];\n"\ + "DP3 TempTangent.y, InTangent.y, program.local[1]; \n"\ + "DP3 TempTangent.z, InTangent.z, program.local[2];\n"\ + "\n"\ + "# transform binormal \n"\ + "DP3 TempBinormal.x, InBinormal.x, program.local[0];\n"\ + "DP3 TempBinormal.y, InBinormal.y, program.local[1]; \n"\ + "DP3 TempBinormal.z, InBinormal.z, program.local[2];\n"\ + "\n"\ + "# vertex into world position \n"\ + "DP4 Temp.x, InPos, program.local[0];\n"\ + "DP4 Temp.y, InPos, program.local[1];\n"\ + "DP4 Temp.z, InPos, program.local[2];\n"\ + "DP4 Temp.w, InPos, program.local[3];\n"\ + "\n"\ + "# vertex - lightpositions \n"\ + "SUB TempLightVector1, program.local[12], Temp; \n"\ + "SUB TempLightVector2, program.local[14], Temp; \n"\ + "\n"\ + "# eye vector \n"\ + "SUB Temp, program.local[16], Temp; \n"\ + "\n"\ + "# transform the light vector 1 with U, V, W \n"\ + "DP3 TempTransLightV1.x, TempTangent, TempLightVector1; \n"\ + "DP3 TempTransLightV1.y, TempBinormal, TempLightVector1; \n"\ + "DP3 TempTransLightV1.z, TempNormal, TempLightVector1; \n"\ + "\n"\ + "# transform the light vector 2 with U, V, W \n"\ + "DP3 TempTransLightV2.x, TempTangent, TempLightVector2; \n"\ + "DP3 TempTransLightV2.y, TempBinormal, TempLightVector2; \n"\ + "DP3 TempTransLightV2.z, TempNormal, TempLightVector2; \n"\ + "\n"\ + "# transform the eye vector with U, V, W \n"\ + "DP3 TempEyeVector.x, TempTangent, Temp; \n"\ + "DP3 TempEyeVector.y, TempBinormal, Temp; \n"\ + "DP3 TempEyeVector.z, TempNormal, Temp; \n"\ + "\n"\ + "# normalize light vector 1 \n"\ + "DP3 TempTransLightV1.w, TempTransLightV1, TempTransLightV1; \n"\ + "RSQ TempTransLightV1.w, TempTransLightV1.w; \n"\ + "MUL TempTransLightV1, TempTransLightV1, TempTransLightV1.w;\n"\ + "\n"\ + "# normalize light vector 2 \n"\ + "DP3 TempTransLightV2.w, TempTransLightV2, TempTransLightV2; \n"\ + "RSQ TempTransLightV2.w, TempTransLightV2.w; \n"\ + "MUL TempTransLightV2, TempTransLightV2, TempTransLightV2.w;\n"\ + "\n"\ + "# normalize eye vector \n"\ + "DP3 TempEyeVector.w, TempEyeVector, TempEyeVector; \n"\ + "RSQ TempEyeVector.w, TempEyeVector.w; \n"\ + "MUL TempEyeVector, TempEyeVector, TempEyeVector.w;\n"\ + "MUL TempEyeVector, TempEyeVector, {1,-1,-1,1}; # flip x \n"\ + "\n"\ + "\n"\ + "# move light and eye vectors out\n"\ + "MAD OutLightVector1, TempTransLightV1, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ + "MAD OutLightVector2, TempTransLightV2, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ + "MAD OutEyeVector, TempEyeVector, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ + "\n"\ + "# calculate attenuation of light 1\n"\ + "MOV TempLightVector1.w, {0,0,0,0}; \n"\ + "DP3 TempLightVector1.x, TempLightVector1, TempLightVector1; \n"\ + "MUL TempLightVector1.x, TempLightVector1.x, program.local[13].w; \n"\ + "RSQ TempLightVector1, TempLightVector1.x; \n"\ + "MUL OutLightColor1, TempLightVector1, program.local[13]; # resulting light color = lightcolor * attenuation \n"\ + "\n"\ + "# calculate attenuation of light 2\n"\ + "MOV TempLightVector2.w, {0,0,0,0}; \n"\ + "DP3 TempLightVector2.x, TempLightVector2, TempLightVector2; \n"\ + "MUL TempLightVector2.x, TempLightVector2.x, program.local[15].w; \n"\ + "RSQ TempLightVector2, TempLightVector2.x; \n"\ + "MUL OutLightColor2, TempLightVector2, program.local[15]; # resulting light color = lightcolor * attenuation \n"\ + "\n"\ + "# move out texture coordinates and original alpha value\n"\ + "MOV OutTexCoord, InTexCoord; \n"\ + "MOV OutLightColor1.w, InColor.w; \n"\ + "\n"\ + "END\n"; + +// Irrlicht Engine OpenGL render path parallax map pixel shader +// I guess it could be optimized a bit, because I wrote it in D3D ASM and +// transfered it 1:1 to OpenGL +const char OPENGL_PARALLAX_MAP_PSH[] = + "!!ARBfp1.0\n"\ + "\n"\ + "#Input\n"\ + "ATTRIB inTexCoord = fragment.texcoord[0]; \n"\ + "ATTRIB light1Vector = fragment.texcoord[1]; \n"\ + "ATTRIB light2Vector = fragment.texcoord[2]; \n"\ + "ATTRIB eyeVector = fragment.texcoord[3]; \n"\ + "ATTRIB light1Color = fragment.color.primary; \n"\ + "ATTRIB light2Color = fragment.color.secondary; \n"\ + "\n"\ + "#Output\n"\ + "OUTPUT outColor = result.color;\n"\ + "TEMP temp;\n"\ + "TEMP temp2;\n"\ + "TEMP colorMapColor;\n"\ + "TEMP normalMapColor;\n"\ + "\n"\ + "PARAM height_scale = program.local[0]; \n"\ + "# fetch color and normal map; \n"\ + "TXP normalMapColor, inTexCoord, texture[1], 2D; \n"\ + "MAD normalMapColor, normalMapColor, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ + "\n"\ + "\n"\ + "# extract eye vector (so substract 0.5f and multiply by 2)\n"\ + "MAD temp, eyeVector, {2,2,2,2}, {-1,-1,-1,-1};\n"\ + "\n"\ + "# height = height * scale \n"\ + "MUL normalMapColor, normalMapColor, height_scale;\n"\ + "\n"\ + "# calculate new texture coord: height * eye + oldTexCoord\n"\ + "MAD temp, temp, normalMapColor.wwww, inTexCoord;\n"\ + "\n"\ + "# fetch new textures \n"\ + "TXP colorMapColor, temp, texture[0], 2D; \n"\ + "TXP normalMapColor, temp, texture[1], 2D; \n"\ + "\n"\ + "# calculate color of light1; \n"\ + "MAD normalMapColor, normalMapColor, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ + "MAD temp, light1Vector, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ + "DP3_SAT temp, normalMapColor, temp; \n"\ + "MUL temp, light1Color, temp; \n"\ + "\n"\ + "# calculate color of light2; \n"\ + "MAD temp2, light2Vector, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ + "DP3_SAT temp2, normalMapColor, light2Vector; \n"\ + "MAD temp, light2Color, temp2, temp; \n"\ + "\n"\ + "# luminance * base color; \n"\ + "MUL outColor, temp, colorMapColor; \n"\ + "MOV outColor.a, light1Color.a; #write interpolated vertex alpha value\n"\ + "\n"\ + "END\n"; + +//! Constructor +COpenGLParallaxMapRenderer::COpenGLParallaxMapRenderer(video::COpenGLDriver* driver, + s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) + : COpenGLShaderMaterialRenderer(driver, 0, baseMaterial), CompiledShaders(true) +{ + // set this as callback. We could have done this in + // the initialization list, but some compilers don't like it. + + CallBack = this; + + // basicly, this thing simply compiles these hardcoded shaders if the + // hardware is able to do them, otherwise it maps to the base material + + if (!driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) || + !driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1)) + { + // this hardware is not able to do shaders. Fall back to + // base material. + outMaterialTypeNr = driver->addMaterialRenderer(this); + return; + } + + // check if already compiled normal map shaders are there. + + video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_PARALLAX_MAP_SOLID); + + if (renderer) + { + // use the already compiled shaders + video::COpenGLParallaxMapRenderer* nmr = (video::COpenGLParallaxMapRenderer*)renderer; + CompiledShaders = false; + + VertexShader = nmr->VertexShader; + PixelShader = nmr->PixelShader; + + outMaterialTypeNr = driver->addMaterialRenderer(this); + } + else + { + // compile shaders on our own + init(outMaterialTypeNr, OPENGL_PARALLAX_MAP_VSH, OPENGL_PARALLAX_MAP_PSH, EVT_TANGENTS); + } +} + + +//! Destructor +COpenGLParallaxMapRenderer::~COpenGLParallaxMapRenderer() +{ + if (CallBack == this) + CallBack = 0; + + if (!CompiledShaders) + { + // prevent this from deleting shaders we did not create + VertexShader = 0; + PixelShader = 0; + } +} + + +void COpenGLParallaxMapRenderer::OnSetMaterial(video::SMaterial& material, + const video::SMaterial& lastMaterial, + bool resetAllRenderstates, video::IMaterialRendererServices* services) +{ + COpenGLShaderMaterialRenderer::OnSetMaterial(material, lastMaterial, + resetAllRenderstates, services); + + CurrentScale = material.MaterialTypeParam; +} + + + +//! Returns the render capability of the material. +s32 COpenGLParallaxMapRenderer::getRenderCapability() +{ + if (Driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) && + Driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1)) + return 0; + + return 1; +} + + +//! Called by the engine when the vertex and/or pixel shader constants for an +//! material renderer should be set. +void COpenGLParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) +{ + video::IVideoDriver* driver = services->getVideoDriver(); + + // set transposed world matrix + const core::matrix4& tWorld = driver->getTransform(video::ETS_WORLD).getTransposed(); + services->setVertexShaderConstant(tWorld.pointer(), 0, 4); + + // The viewpoint is at (0., 0., 0.) in eye space. + // Turning this into a vector [0 0 0 1] and multiply it by + // the inverse of the view matrix, the resulting vector is the + // object space location of the camera. + + f32 floats[4] = {0.0f,0.0f,0.0f,1.0f}; + core::matrix4 minv(driver->getTransform(video::ETS_VIEW)); + minv.makeInverse(); + minv.multiplyWith1x4Matrix(floats); + services->setVertexShaderConstant(floats, 16, 1); + + // set transposed worldViewProj matrix + core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); + worldViewProj *= driver->getTransform(video::ETS_VIEW); + worldViewProj *= driver->getTransform(video::ETS_WORLD); + core::matrix4 tr(worldViewProj.getTransposed()); + services->setVertexShaderConstant(tr.pointer(), 8, 4); + + // here we've got to fetch the fixed function lights from the driver + // and set them as constants + + u32 cnt = driver->getDynamicLightCount(); + + for (u32 i=0; i<2; ++i) + { + video::SLight light; + + if (igetDynamicLight(i); + else + { + light.DiffuseColor.set(0,0,0); // make light dark + light.Radius = 1.0f; + } + + light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation + + services->setVertexShaderConstant( + reinterpret_cast(&light.Position), 12+(i*2), 1); + + services->setVertexShaderConstant( + reinterpret_cast(&light.DiffuseColor), 13+(i*2), 1); + } + + // set scale factor + f32 factor = 0.02f; // default value + if (CurrentScale != 0.0f) + factor = CurrentScale; + + f32 c6[] = {factor, factor, factor, factor}; + services->setPixelShaderConstant(c6, 0, 1); +} + + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/COpenGLParallaxMapRenderer.h b/src/dep/src/irrlicht/COpenGLParallaxMapRenderer.h index 336e9fa..d7dca9d 100644 --- a/src/dep/src/irrlicht/COpenGLParallaxMapRenderer.h +++ b/src/dep/src/irrlicht/COpenGLParallaxMapRenderer.h @@ -1,54 +1,54 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OPENGL_PARALLAX_MAP_RENDERER_H_INCLUDED__ -#define __C_OPENGL_PARALLAX_MAP_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "COpenGLShaderMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" - -namespace irr -{ -namespace video -{ - -//! Class for rendering normal maps with OpenGL -class COpenGLParallaxMapRenderer : public COpenGLShaderMaterialRenderer, public IShaderConstantSetCallBack -{ -public: - - //! Constructor - COpenGLParallaxMapRenderer(video::COpenGLDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); - - //! Destructor - ~COpenGLParallaxMapRenderer(); - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); - - //! Returns the render capability of the material. - virtual s32 getRenderCapability(); - - virtual void OnSetMaterial(video::SMaterial& material, - const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services); - -protected: - - bool CompiledShaders; - f32 CurrentScale; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_OPENGL_PARALLAX_MAP_RENDERER_H_INCLUDED__ +#define __C_OPENGL_PARALLAX_MAP_RENDERER_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "COpenGLShaderMaterialRenderer.h" +#include "IShaderConstantSetCallBack.h" + +namespace irr +{ +namespace video +{ + +//! Class for rendering normal maps with OpenGL +class COpenGLParallaxMapRenderer : public COpenGLShaderMaterialRenderer, public IShaderConstantSetCallBack +{ +public: + + //! Constructor + COpenGLParallaxMapRenderer(video::COpenGLDriver* driver, + s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); + + //! Destructor + ~COpenGLParallaxMapRenderer(); + + //! Called by the engine when the vertex and/or pixel shader constants for an + //! material renderer should be set. + virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); + + //! Returns the render capability of the material. + virtual s32 getRenderCapability(); + + virtual void OnSetMaterial(video::SMaterial& material, + const video::SMaterial& lastMaterial, + bool resetAllRenderstates, video::IMaterialRendererServices* services); + +protected: + + bool CompiledShaders; + f32 CurrentScale; +}; + + +} // end namespace video +} // end namespace irr + +#endif +#endif + diff --git a/src/dep/src/irrlicht/COpenGLSLMaterialRenderer.cpp b/src/dep/src/irrlicht/COpenGLSLMaterialRenderer.cpp index 3a73499..200a2f8 100644 --- a/src/dep/src/irrlicht/COpenGLSLMaterialRenderer.cpp +++ b/src/dep/src/irrlicht/COpenGLSLMaterialRenderer.cpp @@ -1,367 +1,367 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// This file was originally written by William Finlayson. -// I (Nikolaus Gebhardt) did some minor modifications and changes to it and integrated -// it into Irrlicht. Thanks a lot to William for his work on this and that he gave me -// his permission to add it into Irrlicht using the zlib license. - -// After Irrlicht 0.12, Michael Zoech did some improvements to this renderer, I merged this -// into Irrlicht0.14, thanks to him for his work. - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "COpenGLSLMaterialRenderer.h" -#include "IGPUProgrammingServices.h" -#include "IShaderConstantSetCallBack.h" -#include "IMaterialRendererServices.h" -#include "IVideoDriver.h" -#include "os.h" -#include "COpenGLDriver.h" - -namespace irr -{ -namespace video -{ - - -//! Constructor -COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(video::COpenGLDriver* driver, - s32& outMaterialTypeNr, const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - video::IMaterialRenderer* baseMaterial, - s32 userData) - : Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), - Program(0), UserData(userData) -{ - //entry points must always be main, and the compile target isn't selectable - //it is fine to ignore what has been asked for, as the compiler should spot anything wrong - //just check that GLSL is available - - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); - - if (!Driver->queryFeature(EVDF_ARB_GLSL)) - return; - - init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram); -} - - -//! constructor only for use by derived classes who want to -//! create a fall back material for example. -COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(COpenGLDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, s32 userData) -: Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), - Program(0), UserData(userData) -{ - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); -} - - -//! Destructor -COpenGLSLMaterialRenderer::~COpenGLSLMaterialRenderer() -{ - if (CallBack) - CallBack->drop(); - - if(Program) - { - Driver->extGlDeleteObjectARB(Program); - Program = 0; - } - - UniformInfo.clear(); - - if (BaseMaterial) - BaseMaterial->drop(); -} - -void COpenGLSLMaterialRenderer::init(s32& outMaterialTypeNr, - const c8* vertexShaderProgram, - const c8* pixelShaderProgram) -{ - outMaterialTypeNr = -1; - - if (!createProgram()) - return; - -#if defined(GL_ARB_vertex_shader) && defined (GL_ARB_fragment_shader) - if (!createShader(GL_VERTEX_SHADER_ARB, vertexShaderProgram)) - return; - - if (!createShader(GL_FRAGMENT_SHADER_ARB, pixelShaderProgram)) - return; -#endif - - if (!linkProgram()) - return; - - // register myself as new material - outMaterialTypeNr = Driver->addMaterialRenderer(this); -} - -bool COpenGLSLMaterialRenderer::OnRender(IMaterialRendererServices* service, - E_VERTEX_TYPE vtxtype) -{ - // call callback to set shader constants - if (CallBack && (Program)) - CallBack->OnSetConstants(this, UserData); - - return true; -} - - -void COpenGLSLMaterialRenderer::OnSetMaterial(video::SMaterial& material, - const video::SMaterial& lastMaterial, - bool resetAllRenderstates, - video::IMaterialRendererServices* services) -{ - Driver->setTexture(3, material.Textures[3]); - Driver->setTexture(2, material.Textures[2]); - Driver->setTexture(1, material.Textures[1]); - Driver->setTexture(0, material.Textures[0]); - - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if(Program) - Driver->extGlUseProgramObjectARB(Program); - - if (BaseMaterial) - BaseMaterial->OnSetMaterial(material, material, true, this); - } - - setBasicRenderStates(material, lastMaterial, resetAllRenderstates); -} - - -void COpenGLSLMaterialRenderer::OnUnsetMaterial() -{ - Driver->extGlUseProgramObjectARB(0); - - if (BaseMaterial) - BaseMaterial->OnUnsetMaterial(); -} - -//! Returns if the material is transparent. -bool COpenGLSLMaterialRenderer::isTransparent() -{ - return BaseMaterial ? BaseMaterial->isTransparent() : false; -} - -bool COpenGLSLMaterialRenderer::createProgram() -{ - Program = Driver->extGlCreateProgramObjectARB(); - return true; -} - -bool COpenGLSLMaterialRenderer::createShader(GLenum shaderType, const char* shader) -{ - GLhandleARB shaderHandle = Driver->extGlCreateShaderObjectARB(shaderType); - - Driver->extGlShaderSourceARB(shaderHandle, 1, &shader, NULL); - Driver->extGlCompileShaderARB(shaderHandle); - - int status = 0; - -#ifdef GL_ARB_shader_objects - Driver->extGlGetObjectParameterivARB(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status); -#endif - - if (!status) - { - os::Printer::log("GLSL shader failed to compile"); - // check error message and log it - int maxLength=0; - GLsizei length; -#ifdef GL_ARB_shader_objects - Driver->extGlGetObjectParameterivARB(shaderHandle, - GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength); -#endif - GLcharARB *pInfoLog = new GLcharARB[maxLength]; - Driver->extGlGetInfoLogARB(shaderHandle, maxLength, &length, pInfoLog); - os::Printer::log((const c8*)pInfoLog); - delete [] pInfoLog; - - return false; - } - - Driver->extGlAttachObjectARB(Program, shaderHandle); - - return true; -} - -bool COpenGLSLMaterialRenderer::linkProgram() -{ - Driver->extGlLinkProgramARB(Program); - - int status = 0; - -#ifdef GL_ARB_shader_objects - Driver->extGlGetObjectParameterivARB(Program, GL_OBJECT_LINK_STATUS_ARB, &status); -#endif - - if (!status) - { - os::Printer::log("GLSL shader program failed to link"); - // check error message and log it - int maxLength=0; - GLsizei length; -#ifdef GL_ARB_shader_objects - Driver->extGlGetObjectParameterivARB(Program, - GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength); -#endif - GLcharARB *pInfoLog = new GLcharARB[maxLength]; - Driver->extGlGetInfoLogARB(Program, maxLength, &length, pInfoLog); - os::Printer::log((const c8*)pInfoLog); - delete [] pInfoLog; - - return false; - } - - // get uniforms information - - int num = 0; -#ifdef GL_ARB_shader_objects - Driver->extGlGetObjectParameterivARB(Program, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &num); -#endif - - if (num == 0) - { - // no uniforms - return true; - } - - int maxlen = 0; -#ifdef GL_ARB_shader_objects - Driver->extGlGetObjectParameterivARB(Program, GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB, &maxlen); -#endif - - if (maxlen == 0) - { - os::Printer::log("GLSL: failed to retrieve uniform information"); - return false; - } - - c8 *buf = new c8[maxlen]; - - UniformInfo.clear(); - UniformInfo.reallocate(num); - - for (int i=0; i < num; ++i) - { - SUniformInfo ui; - memset(buf, 0, maxlen); - - GLint size; - Driver->extGlGetActiveUniformARB(Program, i, maxlen, 0, &size, &ui.type, (GLcharARB*)buf); - ui.name = buf; - - UniformInfo.push_back(ui); - } - - delete [] buf; - - return true; -} - - - -void COpenGLSLMaterialRenderer::setBasicRenderStates(const SMaterial& material, - const SMaterial& lastMaterial, - bool resetAllRenderstates) -{ - // forward - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); -} - - -bool COpenGLSLMaterialRenderer::setVertexShaderConstant(const c8* name, const f32* floats, int count) -{ - return setPixelShaderConstant(name, floats, count); -} - - -void COpenGLSLMaterialRenderer::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ - os::Printer::log("Cannot set constant, please use high level shader call instead."); -} - -bool COpenGLSLMaterialRenderer::setPixelShaderConstant(const c8* name, const f32* floats, int count) -{ - int i = 0, num = (int)UniformInfo.size(); - - for (; i < num; i++) - { - if (UniformInfo[i].name == name) - break; - } - - if (i == num) return false; - -#ifdef GL_ARB_shader_objects - switch (UniformInfo[i].type) - { - case GL_FLOAT: - Driver->extGlUniform1fvARB(i, count, floats); - break; - case GL_FLOAT_VEC2_ARB: - Driver->extGlUniform2fvARB(i, count/2, floats); - break; - case GL_FLOAT_VEC3_ARB: - Driver->extGlUniform3fvARB(i, count/3, floats); - break; - case GL_FLOAT_VEC4_ARB: - Driver->extGlUniform4fvARB(i, count/4, floats); - break; - case GL_FLOAT_MAT2_ARB: - Driver->extGlUniformMatrix2fvARB(i, count/4, false, floats); - break; - case GL_FLOAT_MAT3_ARB: - Driver->extGlUniformMatrix3fvARB(i, count/9, false, floats); - break; - case GL_FLOAT_MAT4_ARB: - Driver->extGlUniformMatrix4fvARB(i, count/16, false, floats); - break; - default: - Driver->extGlUniform1ivARB(i, count, (GLint*)floats); - break; - } -#endif - - return true; -} - -void COpenGLSLMaterialRenderer::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ - os::Printer::log("Cannot set constant, use high level shader call."); -} - -IVideoDriver* COpenGLSLMaterialRenderer::getVideoDriver() -{ - return Driver; -} - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// This file was originally written by William Finlayson. +// I (Nikolaus Gebhardt) did some minor modifications and changes to it and integrated +// it into Irrlicht. Thanks a lot to William for his work on this and that he gave me +// his permission to add it into Irrlicht using the zlib license. + +// After Irrlicht 0.12, Michael Zoech did some improvements to this renderer, I merged this +// into Irrlicht0.14, thanks to him for his work. + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "COpenGLSLMaterialRenderer.h" +#include "IGPUProgrammingServices.h" +#include "IShaderConstantSetCallBack.h" +#include "IMaterialRendererServices.h" +#include "IVideoDriver.h" +#include "os.h" +#include "COpenGLDriver.h" + +namespace irr +{ +namespace video +{ + + +//! Constructor +COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(video::COpenGLDriver* driver, + s32& outMaterialTypeNr, const c8* vertexShaderProgram, + const c8* vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8* pixelShaderProgram, + const c8* pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + IShaderConstantSetCallBack* callback, + video::IMaterialRenderer* baseMaterial, + s32 userData) + : Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), + Program(0), UserData(userData) +{ + //entry points must always be main, and the compile target isn't selectable + //it is fine to ignore what has been asked for, as the compiler should spot anything wrong + //just check that GLSL is available + + if (BaseMaterial) + BaseMaterial->grab(); + + if (CallBack) + CallBack->grab(); + + if (!Driver->queryFeature(EVDF_ARB_GLSL)) + return; + + init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram); +} + + +//! constructor only for use by derived classes who want to +//! create a fall back material for example. +COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(COpenGLDriver* driver, + IShaderConstantSetCallBack* callback, + IMaterialRenderer* baseMaterial, s32 userData) +: Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), + Program(0), UserData(userData) +{ + if (BaseMaterial) + BaseMaterial->grab(); + + if (CallBack) + CallBack->grab(); +} + + +//! Destructor +COpenGLSLMaterialRenderer::~COpenGLSLMaterialRenderer() +{ + if (CallBack) + CallBack->drop(); + + if(Program) + { + Driver->extGlDeleteObjectARB(Program); + Program = 0; + } + + UniformInfo.clear(); + + if (BaseMaterial) + BaseMaterial->drop(); +} + +void COpenGLSLMaterialRenderer::init(s32& outMaterialTypeNr, + const c8* vertexShaderProgram, + const c8* pixelShaderProgram) +{ + outMaterialTypeNr = -1; + + if (!createProgram()) + return; + +#if defined(GL_ARB_vertex_shader) && defined (GL_ARB_fragment_shader) + if (!createShader(GL_VERTEX_SHADER_ARB, vertexShaderProgram)) + return; + + if (!createShader(GL_FRAGMENT_SHADER_ARB, pixelShaderProgram)) + return; +#endif + + if (!linkProgram()) + return; + + // register myself as new material + outMaterialTypeNr = Driver->addMaterialRenderer(this); +} + +bool COpenGLSLMaterialRenderer::OnRender(IMaterialRendererServices* service, + E_VERTEX_TYPE vtxtype) +{ + // call callback to set shader constants + if (CallBack && (Program)) + CallBack->OnSetConstants(this, UserData); + + return true; +} + + +void COpenGLSLMaterialRenderer::OnSetMaterial(video::SMaterial& material, + const video::SMaterial& lastMaterial, + bool resetAllRenderstates, + video::IMaterialRendererServices* services) +{ + Driver->setTexture(3, material.Textures[3]); + Driver->setTexture(2, material.Textures[2]); + Driver->setTexture(1, material.Textures[1]); + Driver->setTexture(0, material.Textures[0]); + + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { + if(Program) + Driver->extGlUseProgramObjectARB(Program); + + if (BaseMaterial) + BaseMaterial->OnSetMaterial(material, material, true, this); + } + + setBasicRenderStates(material, lastMaterial, resetAllRenderstates); +} + + +void COpenGLSLMaterialRenderer::OnUnsetMaterial() +{ + Driver->extGlUseProgramObjectARB(0); + + if (BaseMaterial) + BaseMaterial->OnUnsetMaterial(); +} + +//! Returns if the material is transparent. +bool COpenGLSLMaterialRenderer::isTransparent() +{ + return BaseMaterial ? BaseMaterial->isTransparent() : false; +} + +bool COpenGLSLMaterialRenderer::createProgram() +{ + Program = Driver->extGlCreateProgramObjectARB(); + return true; +} + +bool COpenGLSLMaterialRenderer::createShader(GLenum shaderType, const char* shader) +{ + GLhandleARB shaderHandle = Driver->extGlCreateShaderObjectARB(shaderType); + + Driver->extGlShaderSourceARB(shaderHandle, 1, &shader, NULL); + Driver->extGlCompileShaderARB(shaderHandle); + + int status = 0; + +#ifdef GL_ARB_shader_objects + Driver->extGlGetObjectParameterivARB(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status); +#endif + + if (!status) + { + os::Printer::log("GLSL shader failed to compile"); + // check error message and log it + int maxLength=0; + GLsizei length; +#ifdef GL_ARB_shader_objects + Driver->extGlGetObjectParameterivARB(shaderHandle, + GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength); +#endif + GLcharARB *pInfoLog = new GLcharARB[maxLength]; + Driver->extGlGetInfoLogARB(shaderHandle, maxLength, &length, pInfoLog); + os::Printer::log((const c8*)pInfoLog); + delete [] pInfoLog; + + return false; + } + + Driver->extGlAttachObjectARB(Program, shaderHandle); + + return true; +} + +bool COpenGLSLMaterialRenderer::linkProgram() +{ + Driver->extGlLinkProgramARB(Program); + + int status = 0; + +#ifdef GL_ARB_shader_objects + Driver->extGlGetObjectParameterivARB(Program, GL_OBJECT_LINK_STATUS_ARB, &status); +#endif + + if (!status) + { + os::Printer::log("GLSL shader program failed to link"); + // check error message and log it + int maxLength=0; + GLsizei length; +#ifdef GL_ARB_shader_objects + Driver->extGlGetObjectParameterivARB(Program, + GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength); +#endif + GLcharARB *pInfoLog = new GLcharARB[maxLength]; + Driver->extGlGetInfoLogARB(Program, maxLength, &length, pInfoLog); + os::Printer::log((const c8*)pInfoLog); + delete [] pInfoLog; + + return false; + } + + // get uniforms information + + int num = 0; +#ifdef GL_ARB_shader_objects + Driver->extGlGetObjectParameterivARB(Program, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &num); +#endif + + if (num == 0) + { + // no uniforms + return true; + } + + int maxlen = 0; +#ifdef GL_ARB_shader_objects + Driver->extGlGetObjectParameterivARB(Program, GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB, &maxlen); +#endif + + if (maxlen == 0) + { + os::Printer::log("GLSL: failed to retrieve uniform information"); + return false; + } + + c8 *buf = new c8[maxlen]; + + UniformInfo.clear(); + UniformInfo.reallocate(num); + + for (int i=0; i < num; ++i) + { + SUniformInfo ui; + memset(buf, 0, maxlen); + + GLint size; + Driver->extGlGetActiveUniformARB(Program, i, maxlen, 0, &size, &ui.type, (GLcharARB*)buf); + ui.name = buf; + + UniformInfo.push_back(ui); + } + + delete [] buf; + + return true; +} + + + +void COpenGLSLMaterialRenderer::setBasicRenderStates(const SMaterial& material, + const SMaterial& lastMaterial, + bool resetAllRenderstates) +{ + // forward + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); +} + + +bool COpenGLSLMaterialRenderer::setVertexShaderConstant(const c8* name, const f32* floats, int count) +{ + return setPixelShaderConstant(name, floats, count); +} + + +void COpenGLSLMaterialRenderer::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) +{ + os::Printer::log("Cannot set constant, please use high level shader call instead."); +} + +bool COpenGLSLMaterialRenderer::setPixelShaderConstant(const c8* name, const f32* floats, int count) +{ + int i = 0, num = (int)UniformInfo.size(); + + for (; i < num; i++) + { + if (UniformInfo[i].name == name) + break; + } + + if (i == num) return false; + +#ifdef GL_ARB_shader_objects + switch (UniformInfo[i].type) + { + case GL_FLOAT: + Driver->extGlUniform1fvARB(i, count, floats); + break; + case GL_FLOAT_VEC2_ARB: + Driver->extGlUniform2fvARB(i, count/2, floats); + break; + case GL_FLOAT_VEC3_ARB: + Driver->extGlUniform3fvARB(i, count/3, floats); + break; + case GL_FLOAT_VEC4_ARB: + Driver->extGlUniform4fvARB(i, count/4, floats); + break; + case GL_FLOAT_MAT2_ARB: + Driver->extGlUniformMatrix2fvARB(i, count/4, false, floats); + break; + case GL_FLOAT_MAT3_ARB: + Driver->extGlUniformMatrix3fvARB(i, count/9, false, floats); + break; + case GL_FLOAT_MAT4_ARB: + Driver->extGlUniformMatrix4fvARB(i, count/16, false, floats); + break; + default: + Driver->extGlUniform1ivARB(i, count, (GLint*)floats); + break; + } +#endif + + return true; +} + +void COpenGLSLMaterialRenderer::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) +{ + os::Printer::log("Cannot set constant, use high level shader call."); +} + +IVideoDriver* COpenGLSLMaterialRenderer::getVideoDriver() +{ + return Driver; +} + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/COpenGLSLMaterialRenderer.h b/src/dep/src/irrlicht/COpenGLSLMaterialRenderer.h index 965d6fd..bb40e50 100644 --- a/src/dep/src/irrlicht/COpenGLSLMaterialRenderer.h +++ b/src/dep/src/irrlicht/COpenGLSLMaterialRenderer.h @@ -1,127 +1,127 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OPENGL_SHADER_LANGUAGE_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_OPENGL_SHADER_LANGUAGE_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#ifdef _IRR_WINDOWS_ -#define WIN32_LEAN_AND_MEAN -#include -#include -#include "glext.h" -#endif - -#ifdef LINUX -#if defined(_IRR_OPENGL_USE_EXTPOINTER_) -#define GL_GLEXT_LEGACY 1 -#endif -#include -#if defined(_IRR_OPENGL_USE_EXTPOINTER_) -#include "glext.h" -#endif -#endif - -#ifdef MACOSX -#include -#include -#endif - -#include "IMaterialRenderer.h" -#include "IMaterialRendererServices.h" -#include "IGPUProgrammingServices.h" -#include "irrArray.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -class COpenGLDriver; -class IShaderConstantSetCallBack; -class IMaterialRenderer; - -//! Class for using GLSL shaders with OpenGL -//! Please note: This renderer implements its own IMaterialRendererServices -class COpenGLSLMaterialRenderer : public IMaterialRenderer, public IMaterialRendererServices -{ -public: - - //! Constructor - COpenGLSLMaterialRenderer( - video::COpenGLDriver* driver, - s32& outMaterialTypeNr, - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - video::IMaterialRenderer* baseMaterial, - s32 userData); - - //! Destructor - ~COpenGLSLMaterialRenderer(); - - virtual void OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services); - - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - virtual void OnUnsetMaterial(); - - //! Returns if the material is transparent. - virtual bool isTransparent(); - - // implementations for the render services - virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates); - virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); - virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); - virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - virtual IVideoDriver* getVideoDriver(); - -protected: - - //! constructor only for use by derived classes who want to - //! create a fall back material for example. - COpenGLSLMaterialRenderer(COpenGLDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, - s32 userData=0); - - void init(s32& outMaterialTypeNr, - const c8* vertexShaderProgram, - const c8* pixelShaderProgram); - - bool createProgram(); - bool createShader(GLenum shaderType, const char* shader); - bool linkProgram(); - - video::COpenGLDriver* Driver; - IShaderConstantSetCallBack* CallBack; - IMaterialRenderer* BaseMaterial; - - struct SUniformInfo - { - core::stringc name; - GLenum type; - }; - - GLhandleARB Program; - core::array UniformInfo; - s32 UserData; -}; - - -} // end namespace video -} // end namespace irr - -#endif // compile with OpenGL -#endif // if included - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_OPENGL_SHADER_LANGUAGE_MATERIAL_RENDERER_H_INCLUDED__ +#define __C_OPENGL_SHADER_LANGUAGE_MATERIAL_RENDERER_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#ifdef _IRR_WINDOWS_ +#define WIN32_LEAN_AND_MEAN +#include +#include +#include "glext.h" +#endif + +#ifdef LINUX +#if defined(_IRR_OPENGL_USE_EXTPOINTER_) +#define GL_GLEXT_LEGACY 1 +#endif +#include +#if defined(_IRR_OPENGL_USE_EXTPOINTER_) +#include "glext.h" +#endif +#endif + +#ifdef MACOSX +#include +#include +#endif + +#include "IMaterialRenderer.h" +#include "IMaterialRendererServices.h" +#include "IGPUProgrammingServices.h" +#include "irrArray.h" +#include "irrString.h" + +namespace irr +{ +namespace video +{ + +class COpenGLDriver; +class IShaderConstantSetCallBack; +class IMaterialRenderer; + +//! Class for using GLSL shaders with OpenGL +//! Please note: This renderer implements its own IMaterialRendererServices +class COpenGLSLMaterialRenderer : public IMaterialRenderer, public IMaterialRendererServices +{ +public: + + //! Constructor + COpenGLSLMaterialRenderer( + video::COpenGLDriver* driver, + s32& outMaterialTypeNr, + const c8* vertexShaderProgram, + const c8* vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8* pixelShaderProgram, + const c8* pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + IShaderConstantSetCallBack* callback, + video::IMaterialRenderer* baseMaterial, + s32 userData); + + //! Destructor + ~COpenGLSLMaterialRenderer(); + + virtual void OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, + bool resetAllRenderstates, video::IMaterialRendererServices* services); + + virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); + + virtual void OnUnsetMaterial(); + + //! Returns if the material is transparent. + virtual bool isTransparent(); + + // implementations for the render services + virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates); + virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); + virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); + virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); + virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); + virtual IVideoDriver* getVideoDriver(); + +protected: + + //! constructor only for use by derived classes who want to + //! create a fall back material for example. + COpenGLSLMaterialRenderer(COpenGLDriver* driver, + IShaderConstantSetCallBack* callback, + IMaterialRenderer* baseMaterial, + s32 userData=0); + + void init(s32& outMaterialTypeNr, + const c8* vertexShaderProgram, + const c8* pixelShaderProgram); + + bool createProgram(); + bool createShader(GLenum shaderType, const char* shader); + bool linkProgram(); + + video::COpenGLDriver* Driver; + IShaderConstantSetCallBack* CallBack; + IMaterialRenderer* BaseMaterial; + + struct SUniformInfo + { + core::stringc name; + GLenum type; + }; + + GLhandleARB Program; + core::array UniformInfo; + s32 UserData; +}; + + +} // end namespace video +} // end namespace irr + +#endif // compile with OpenGL +#endif // if included + diff --git a/src/dep/src/irrlicht/COpenGLShaderMaterialRenderer.cpp b/src/dep/src/irrlicht/COpenGLShaderMaterialRenderer.cpp index 6da5503..04a9b3e 100644 --- a/src/dep/src/irrlicht/COpenGLShaderMaterialRenderer.cpp +++ b/src/dep/src/irrlicht/COpenGLShaderMaterialRenderer.cpp @@ -1,238 +1,238 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "COpenGLShaderMaterialRenderer.h" -#include "IGPUProgrammingServices.h" -#include "IShaderConstantSetCallBack.h" -#include "IVideoDriver.h" -#include "os.h" -#include "COpenGLDriver.h" - -namespace irr -{ -namespace video -{ - - -//! Constructor -COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(video::COpenGLDriver* driver, - s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData) - : Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), - VertexShader(0), PixelShader(0), UserData(userData) -{ - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); - - init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram, EVT_STANDARD); -} - - -//! constructor only for use by derived classes who want to -//! create a fall back material for example. -COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(COpenGLDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, s32 userData) -: Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), - VertexShader(0), PixelShader(0), UserData(userData) -{ - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); -} - - -//! Destructor -COpenGLShaderMaterialRenderer::~COpenGLShaderMaterialRenderer() -{ - if (CallBack) - CallBack->drop(); - - if (VertexShader) - Driver->extGlDeleteProgramsARB(1, &VertexShader); - - if (PixelShader) - Driver->extGlDeleteProgramsARB(1, &PixelShader); - - if (BaseMaterial) - BaseMaterial->drop (); -} - -void COpenGLShaderMaterialRenderer::init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, - const c8* pixelShaderProgram, E_VERTEX_TYPE type) -{ - outMaterialTypeNr = -1; - - // create vertex shader - if (!createVertexShader(vertexShaderProgram)) - return; - - // create pixel shader - if (!createPixelShader(pixelShaderProgram)) - return; - - // register myself as new material - outMaterialTypeNr = Driver->addMaterialRenderer(this); -} - -bool COpenGLShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) -{ - // call callback to set shader constants - if (CallBack && (VertexShader || PixelShader)) - CallBack->OnSetConstants(service, UserData); - - return true; -} - - -void COpenGLShaderMaterialRenderer::OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services) -{ - Driver->setTexture(3, material.Textures[3]); - Driver->setTexture(2, material.Textures[2]); - Driver->setTexture(1, material.Textures[1]); - Driver->setTexture(0, material.Textures[0]); - - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { -#ifdef GL_ARB_vertex_program - if (VertexShader) - { - // set new vertex shader - Driver->extGlBindProgramARB(GL_VERTEX_PROGRAM_ARB, VertexShader); - glEnable(GL_VERTEX_PROGRAM_ARB); - } -#endif - - // set new pixel shader -#ifdef GL_ARB_fragment_program - if (PixelShader) - { - Driver->extGlBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, PixelShader); - glEnable(GL_FRAGMENT_PROGRAM_ARB); - } -#endif - - if (BaseMaterial) - BaseMaterial->OnSetMaterial(material, material, true, services); - } -} - - -void COpenGLShaderMaterialRenderer::OnUnsetMaterial() -{ - // disable vertex shader -#ifdef GL_ARB_vertex_program - if (VertexShader) - glDisable(GL_VERTEX_PROGRAM_ARB); -#endif - -#ifdef GL_ARB_fragment_program - if (PixelShader) - glDisable(GL_FRAGMENT_PROGRAM_ARB); -#endif - - if (BaseMaterial) - BaseMaterial->OnUnsetMaterial(); -} - -//! Returns if the material is transparent. -bool COpenGLShaderMaterialRenderer::isTransparent() -{ - return BaseMaterial ? BaseMaterial->isTransparent() : false; -} - -bool COpenGLShaderMaterialRenderer::createPixelShader(const c8* pxsh) -{ - if (!pxsh) - return true; - - Driver->extGlGenProgramsARB(1, &PixelShader); -#ifdef GL_ARB_fragment_program - Driver->extGlBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, PixelShader); - - // clear error buffer - while(glGetError() != GL_NO_ERROR) {} - - // compile - Driver->extGlProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, - strlen(pxsh), pxsh); -#endif - -#ifdef GL_ARB_vertex_program - GLenum g = glGetError(); - if (g != GL_NO_ERROR) - { - GLint errPos; - glGetIntegerv( GL_PROGRAM_ERROR_POSITION_ARB, &errPos ); - - const GLubyte* errString = glGetString(GL_PROGRAM_ERROR_STRING_ARB); - - char tmp[2048]; - sprintf(tmp, "Pixel shader compilation failed at position %d:\n%s", errPos, errString); - os::Printer::log(tmp); - - return false; - } -#else - return false; -#endif - - return true; -} - -bool COpenGLShaderMaterialRenderer::createVertexShader(const char* vtxsh) -{ - if (!vtxsh) - return true; - -#ifdef GL_ARB_vertex_program - Driver->extGlGenProgramsARB(1, &VertexShader); - Driver->extGlBindProgramARB(GL_VERTEX_PROGRAM_ARB, VertexShader); - - // clear error buffer - while(glGetError() != GL_NO_ERROR) {} - - // compile - Driver->extGlProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, - strlen(vtxsh), vtxsh); - - GLenum g = glGetError(); - if (g != GL_NO_ERROR) - { - GLint errPos; - glGetIntegerv( GL_PROGRAM_ERROR_POSITION_ARB, &errPos ); - - const GLubyte* errString = glGetString(GL_PROGRAM_ERROR_STRING_ARB); - - char tmp[2048]; - sprintf(tmp, "Vertex shader compilation failed at position %d:\n%s", errPos, errString); - os::Printer::log(tmp); - - return false; - } -#else - return false; -#endif - - return true; -} - - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "COpenGLShaderMaterialRenderer.h" +#include "IGPUProgrammingServices.h" +#include "IShaderConstantSetCallBack.h" +#include "IVideoDriver.h" +#include "os.h" +#include "COpenGLDriver.h" + +namespace irr +{ +namespace video +{ + + +//! Constructor +COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(video::COpenGLDriver* driver, + s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, + IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData) + : Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), + VertexShader(0), PixelShader(0), UserData(userData) +{ + if (BaseMaterial) + BaseMaterial->grab(); + + if (CallBack) + CallBack->grab(); + + init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram, EVT_STANDARD); +} + + +//! constructor only for use by derived classes who want to +//! create a fall back material for example. +COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(COpenGLDriver* driver, + IShaderConstantSetCallBack* callback, + IMaterialRenderer* baseMaterial, s32 userData) +: Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), + VertexShader(0), PixelShader(0), UserData(userData) +{ + if (BaseMaterial) + BaseMaterial->grab(); + + if (CallBack) + CallBack->grab(); +} + + +//! Destructor +COpenGLShaderMaterialRenderer::~COpenGLShaderMaterialRenderer() +{ + if (CallBack) + CallBack->drop(); + + if (VertexShader) + Driver->extGlDeleteProgramsARB(1, &VertexShader); + + if (PixelShader) + Driver->extGlDeleteProgramsARB(1, &PixelShader); + + if (BaseMaterial) + BaseMaterial->drop (); +} + +void COpenGLShaderMaterialRenderer::init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, + const c8* pixelShaderProgram, E_VERTEX_TYPE type) +{ + outMaterialTypeNr = -1; + + // create vertex shader + if (!createVertexShader(vertexShaderProgram)) + return; + + // create pixel shader + if (!createPixelShader(pixelShaderProgram)) + return; + + // register myself as new material + outMaterialTypeNr = Driver->addMaterialRenderer(this); +} + +bool COpenGLShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) +{ + // call callback to set shader constants + if (CallBack && (VertexShader || PixelShader)) + CallBack->OnSetConstants(service, UserData); + + return true; +} + + +void COpenGLShaderMaterialRenderer::OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, + bool resetAllRenderstates, video::IMaterialRendererServices* services) +{ + Driver->setTexture(3, material.Textures[3]); + Driver->setTexture(2, material.Textures[2]); + Driver->setTexture(1, material.Textures[1]); + Driver->setTexture(0, material.Textures[0]); + + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) + { +#ifdef GL_ARB_vertex_program + if (VertexShader) + { + // set new vertex shader + Driver->extGlBindProgramARB(GL_VERTEX_PROGRAM_ARB, VertexShader); + glEnable(GL_VERTEX_PROGRAM_ARB); + } +#endif + + // set new pixel shader +#ifdef GL_ARB_fragment_program + if (PixelShader) + { + Driver->extGlBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, PixelShader); + glEnable(GL_FRAGMENT_PROGRAM_ARB); + } +#endif + + if (BaseMaterial) + BaseMaterial->OnSetMaterial(material, material, true, services); + } +} + + +void COpenGLShaderMaterialRenderer::OnUnsetMaterial() +{ + // disable vertex shader +#ifdef GL_ARB_vertex_program + if (VertexShader) + glDisable(GL_VERTEX_PROGRAM_ARB); +#endif + +#ifdef GL_ARB_fragment_program + if (PixelShader) + glDisable(GL_FRAGMENT_PROGRAM_ARB); +#endif + + if (BaseMaterial) + BaseMaterial->OnUnsetMaterial(); +} + +//! Returns if the material is transparent. +bool COpenGLShaderMaterialRenderer::isTransparent() +{ + return BaseMaterial ? BaseMaterial->isTransparent() : false; +} + +bool COpenGLShaderMaterialRenderer::createPixelShader(const c8* pxsh) +{ + if (!pxsh) + return true; + + Driver->extGlGenProgramsARB(1, &PixelShader); +#ifdef GL_ARB_fragment_program + Driver->extGlBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, PixelShader); + + // clear error buffer + while(glGetError() != GL_NO_ERROR) {} + + // compile + Driver->extGlProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(pxsh), pxsh); +#endif + +#ifdef GL_ARB_vertex_program + GLenum g = glGetError(); + if (g != GL_NO_ERROR) + { + GLint errPos; + glGetIntegerv( GL_PROGRAM_ERROR_POSITION_ARB, &errPos ); + + const GLubyte* errString = glGetString(GL_PROGRAM_ERROR_STRING_ARB); + + char tmp[2048]; + sprintf(tmp, "Pixel shader compilation failed at position %d:\n%s", errPos, errString); + os::Printer::log(tmp); + + return false; + } +#else + return false; +#endif + + return true; +} + +bool COpenGLShaderMaterialRenderer::createVertexShader(const char* vtxsh) +{ + if (!vtxsh) + return true; + +#ifdef GL_ARB_vertex_program + Driver->extGlGenProgramsARB(1, &VertexShader); + Driver->extGlBindProgramARB(GL_VERTEX_PROGRAM_ARB, VertexShader); + + // clear error buffer + while(glGetError() != GL_NO_ERROR) {} + + // compile + Driver->extGlProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(vtxsh), vtxsh); + + GLenum g = glGetError(); + if (g != GL_NO_ERROR) + { + GLint errPos; + glGetIntegerv( GL_PROGRAM_ERROR_POSITION_ARB, &errPos ); + + const GLubyte* errString = glGetString(GL_PROGRAM_ERROR_STRING_ARB); + + char tmp[2048]; + sprintf(tmp, "Vertex shader compilation failed at position %d:\n%s", errPos, errString); + os::Printer::log(tmp); + + return false; + } +#else + return false; +#endif + + return true; +} + + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/COpenGLShaderMaterialRenderer.h b/src/dep/src/irrlicht/COpenGLShaderMaterialRenderer.h index dedc334..1b1215f 100644 --- a/src/dep/src/irrlicht/COpenGLShaderMaterialRenderer.h +++ b/src/dep/src/irrlicht/COpenGLShaderMaterialRenderer.h @@ -1,91 +1,91 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OPENGL_SHADER_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_OPENGL_SHADER_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#ifdef _IRR_WINDOWS_ -#define WIN32_LEAN_AND_MEAN -#include -#include -#elif defined(LINUX) -#if defined(_IRR_OPENGL_USE_EXTPOINTER_) -#define GL_GLEXT_LEGACY 1 -#endif -#include -#if defined(_IRR_OPENGL_USE_EXTPOINTER_) -#include "glext.h" -#endif -#elif defined(MACOSX) -#include -#include -#endif - -#include "IMaterialRenderer.h" - -namespace irr -{ -namespace video -{ - -class COpenGLDriver; -class IShaderConstantSetCallBack; -class IMaterialRenderer; - -//! Class for using vertex and pixel shaders with OpenGL -class COpenGLShaderMaterialRenderer : public IMaterialRenderer -{ -public: - - //! Constructor - COpenGLShaderMaterialRenderer(video::COpenGLDriver* driver, - s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData); - - //! Destructor - ~COpenGLShaderMaterialRenderer(); - - virtual void OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services); - - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - virtual void OnUnsetMaterial(); - - //! Returns if the material is transparent. - virtual bool isTransparent(); - -protected: - - //! constructor only for use by derived classes who want to - //! create a fall back material for example. - COpenGLShaderMaterialRenderer(COpenGLDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, s32 userData=0); - - void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, - const c8* pixelShaderProgram, E_VERTEX_TYPE type); - - bool createPixelShader(const c8* pxsh); - bool createVertexShader(const char* vtxsh); - - video::COpenGLDriver* Driver; - IShaderConstantSetCallBack* CallBack; - IMaterialRenderer* BaseMaterial; - - GLuint VertexShader; - GLuint PixelShader; - s32 UserData; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_OPENGL_SHADER_MATERIAL_RENDERER_H_INCLUDED__ +#define __C_OPENGL_SHADER_MATERIAL_RENDERER_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#ifdef _IRR_WINDOWS_ +#define WIN32_LEAN_AND_MEAN +#include +#include +#elif defined(LINUX) +#if defined(_IRR_OPENGL_USE_EXTPOINTER_) +#define GL_GLEXT_LEGACY 1 +#endif +#include +#if defined(_IRR_OPENGL_USE_EXTPOINTER_) +#include "glext.h" +#endif +#elif defined(MACOSX) +#include +#include +#endif + +#include "IMaterialRenderer.h" + +namespace irr +{ +namespace video +{ + +class COpenGLDriver; +class IShaderConstantSetCallBack; +class IMaterialRenderer; + +//! Class for using vertex and pixel shaders with OpenGL +class COpenGLShaderMaterialRenderer : public IMaterialRenderer +{ +public: + + //! Constructor + COpenGLShaderMaterialRenderer(video::COpenGLDriver* driver, + s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, + IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData); + + //! Destructor + ~COpenGLShaderMaterialRenderer(); + + virtual void OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, + bool resetAllRenderstates, video::IMaterialRendererServices* services); + + virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); + + virtual void OnUnsetMaterial(); + + //! Returns if the material is transparent. + virtual bool isTransparent(); + +protected: + + //! constructor only for use by derived classes who want to + //! create a fall back material for example. + COpenGLShaderMaterialRenderer(COpenGLDriver* driver, + IShaderConstantSetCallBack* callback, + IMaterialRenderer* baseMaterial, s32 userData=0); + + void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, + const c8* pixelShaderProgram, E_VERTEX_TYPE type); + + bool createPixelShader(const c8* pxsh); + bool createVertexShader(const char* vtxsh); + + video::COpenGLDriver* Driver; + IShaderConstantSetCallBack* CallBack; + IMaterialRenderer* BaseMaterial; + + GLuint VertexShader; + GLuint PixelShader; + s32 UserData; +}; + + +} // end namespace video +} // end namespace irr + +#endif +#endif + diff --git a/src/dep/src/irrlicht/COpenGLTexture.cpp b/src/dep/src/irrlicht/COpenGLTexture.cpp index 73dbaea..d6c9f7a 100644 --- a/src/dep/src/irrlicht/COpenGLTexture.cpp +++ b/src/dep/src/irrlicht/COpenGLTexture.cpp @@ -1,531 +1,531 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "irrTypes.h" -#include "COpenGLTexture.h" -#include "COpenGLDriver.h" -#include "os.h" -#include "CColorConverter.h" - -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -const bool checkFBOStatus(COpenGLDriver* Driver) -{ -#ifdef GL_EXT_framebuffer_object - GLenum status = Driver->extGlCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); - - switch (status) - { - //Our FBO is perfect, return true - case GL_FRAMEBUFFER_COMPLETE_EXT: - return true; - - case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: - os::Printer::log("FBO has invalid read buffer", ELL_ERROR); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: - os::Printer::log("FBO has invalid draw buffer", ELL_ERROR); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: - os::Printer::log("FBO has one or several incomplete image attachments", ELL_ERROR); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: - os::Printer::log("FBO has one or several image attachments with different internal formats", ELL_ERROR); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: - os::Printer::log("FBO has one or several image attachments with different dimensions", ELL_ERROR); - break; - -// not part of fbo_object anymore, but won't harm as it is just a return value -#ifdef GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT - case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: - os::Printer::log("FBO has a duplicate image attachment", ELL_ERROR); - break; -#endif - - case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: - os::Printer::log("FBO missing an image attachment", ELL_ERROR); - break; - - case GL_FRAMEBUFFER_UNSUPPORTED_EXT: - os::Printer::log("FBO format unsupported", ELL_ERROR); - break; - - default: - break; - } - os::Printer::log("FBO error", ELL_ERROR); -#endif - return false; -} - -//! constructor -COpenGLTexture::COpenGLTexture(IImage* image, bool generateMipLevels, const char* name, COpenGLDriver* driver) - : ITexture(name), Pitch(0), SurfaceHasSameSize(false), ImageData(0), - ColorFormat(ECF_A8R8G8B8), Driver(driver), TextureName(0), - InternalFormat(GL_RGBA), PixelFormat(GL_BGRA_EXT), - PixelType(GL_UNSIGNED_BYTE), HasMipMaps(generateMipLevels), - ColorFrameBuffer(0), DepthRenderBuffer(0), StencilRenderBuffer(0) -{ - #ifdef _DEBUG - setDebugName("COpenGLTexture"); - #endif - - getImageData(image); - - if (ImageData) - { - glGenTextures(1, &TextureName); - copyTexture(); - } -} - -//! ColorFrameBuffer constructor -COpenGLTexture::COpenGLTexture(const core::dimension2d& size, - bool extPackedDepthStencilSupported, - const char* name, - COpenGLDriver* driver) - : ITexture(name), ImageSize(size), Pitch(0), SurfaceHasSameSize(false), - ImageData(0), ColorFormat(ECF_A8R8G8B8), Driver(driver), TextureName(0), - InternalFormat(GL_RGBA), PixelFormat(GL_BGRA_EXT), - PixelType(GL_UNSIGNED_BYTE), HasMipMaps(false), - ColorFrameBuffer(0), DepthRenderBuffer(0), StencilRenderBuffer(0) -{ - #ifdef _DEBUG - setDebugName("COpenGLTexture_FBO"); - #endif - - // generate color texture - glGenTextures(1, &TextureName); - glBindTexture(GL_TEXTURE_2D, TextureName); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, ImageSize.Width, - ImageSize.Height, 0, GL_RGBA, GL_INT, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - -#ifdef GL_EXT_packed_depth_stencil - if (extPackedDepthStencilSupported) - { - // generate packed depth stencil texture - glGenTextures(1, &DepthRenderBuffer); - glBindTexture(GL_TEXTURE_2D, DepthRenderBuffer); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_EXT, ImageSize.Width, - ImageSize.Height, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - StencilRenderBuffer = DepthRenderBuffer; // stencil is packed with depth - } - else // generate separate stencil and depth textures -#endif - { - // generate depth texture - glGenTextures(1, &DepthRenderBuffer); - glBindTexture(GL_TEXTURE_2D, DepthRenderBuffer); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, ImageSize.Width, - ImageSize.Height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - // we 're in trouble! the code below does not complete the FBO currently... - // stencil buffer is only supported with EXT_packed_depth_stencil extension (above) - -// // generate stencil texture -// glGenTextures(1, &StencilRenderBuffer); -// glBindTexture(GL_TEXTURE_2D, StencilRenderBuffer); -// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); -// glTexImage2D(GL_TEXTURE_2D, 0, GL_STENCIL_INDEX, ImageSize.Width, -// ImageSize.Height, 0, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, 0); -// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); -// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - } - -#ifdef GL_EXT_framebuffer_object - // generate frame buffer - Driver->extGlGenFramebuffersEXT(1, &ColorFrameBuffer); - Driver->extGlBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ColorFrameBuffer); - - // attach color texture to frame buffer - Driver->extGlFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, - GL_COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, - TextureName, - 0); - // attach depth texture to depth buffer - Driver->extGlFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, - GL_DEPTH_ATTACHMENT_EXT, - GL_TEXTURE_2D, - DepthRenderBuffer, - 0); - // attach stencil texture to stencil buffer - Driver->extGlFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, - GL_STENCIL_ATTACHMENT_EXT, - GL_TEXTURE_2D, - StencilRenderBuffer, - 0); - glGetError(); - - // check the status - if (!checkFBOStatus(Driver)) - { - printf("FBO=%d, Color=%d, Depth=%d, Stencil=%d\n", - ColorFrameBuffer, TextureName, DepthRenderBuffer, StencilRenderBuffer); - if (ColorFrameBuffer) - Driver->extGlDeleteFramebuffersEXT(1, &ColorFrameBuffer); - if (DepthRenderBuffer) - glDeleteTextures(1, &DepthRenderBuffer); - if (StencilRenderBuffer && StencilRenderBuffer != DepthRenderBuffer) - glDeleteTextures(1, &StencilRenderBuffer); - ColorFrameBuffer = 0; - DepthRenderBuffer = 0; - StencilRenderBuffer = 0; - } - Driver->extGlBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); -#endif -} - -//! destructor -COpenGLTexture::~COpenGLTexture() -{ - if (ColorFrameBuffer) - Driver->extGlDeleteFramebuffersEXT(1, &ColorFrameBuffer); - if (DepthRenderBuffer) - glDeleteTextures(1, &DepthRenderBuffer); - if (StencilRenderBuffer && StencilRenderBuffer != DepthRenderBuffer) - glDeleteTextures(1, &StencilRenderBuffer); - ColorFrameBuffer = 0; - DepthRenderBuffer = 0; - StencilRenderBuffer = 0; - - glDeleteTextures(1, &TextureName); - if (ImageData) - { - delete [] ImageData; - ImageData=0; - } -} - - -void COpenGLTexture::getImageData(IImage* image) -{ - if (!image) - { - os::Printer::log("No image for OpenGL texture.", ELL_ERROR); - return; - } - - ImageSize = image->getDimension(); - OriginalSize = ImageSize; - - if ( !ImageSize.Width || !ImageSize.Height) - { - os::Printer::log("Invalid size of image for OpenGL Texture.", ELL_ERROR); - return; - } - - core::dimension2d nImageSize; - if (Driver && Driver->queryFeature(EVDF_TEXTURE_NPOT)) - nImageSize=ImageSize; - else - { - nImageSize.Width = getTextureSizeFromSurfaceSize(ImageSize.Width); - nImageSize.Height = getTextureSizeFromSurfaceSize(ImageSize.Height); - } - SurfaceHasSameSize=ImageSize==nImageSize; - - s32 bpp=0; - if (image->getColorFormat()==ECF_R8G8B8) - { - bpp=4; - ColorFormat = ECF_A8R8G8B8; - } - else - { - bpp=image->getBytesPerPixel(); - ColorFormat = image->getColorFormat(); - } - - Pitch = nImageSize.Width*bpp; - ImageData = new u8[Pitch * nImageSize.Height]; - - if (nImageSize == ImageSize) - { - void* source = image->lock(); - if (image->getColorFormat()==ECF_R8G8B8) - CColorConverter::convert_R8G8B8toA8R8G8B8(source,ImageSize.Width*ImageSize.Height,ImageData); - else - memcpy(ImageData,source,Pitch*nImageSize.Height); - } - else - { - u8* source = (u8*)image->lock(); - // scale texture - - f32 sourceXStep = (f32)ImageSize.Width / (f32)nImageSize.Width; - f32 sourceYStep = (f32)ImageSize.Height / (f32)nImageSize.Height; - f32 sx,sy; - - // copy texture scaling - sy = 0.0f; - for (s32 y=0; ygetColorFormat()==ECF_R8G8B8) - { - i*=3; - ((s32*)ImageData)[y*nImageSize.Width + x]=SColor(255,source[i],source[i+1],source[i+2]).color; - } - else - memcpy(&ImageData[(y*nImageSize.Width + x)*bpp],&source[i*bpp],bpp); - sx+=sourceXStep; - } - sy+=sourceYStep; - } - } - image->unlock(); - ImageSize = nImageSize; -} - - - -//! copies the the texture into an open gl texture. -void COpenGLTexture::copyTexture(bool newTexture) -{ - glBindTexture(GL_TEXTURE_2D, TextureName); - if (Driver->testGLError()) - os::Printer::log("Could not bind Texture", ELL_ERROR); - - switch (ColorFormat) - { - case ECF_A1R5G5B5: - InternalFormat=GL_RGBA; - PixelFormat=GL_BGRA_EXT; - PixelType=GL_UNSIGNED_SHORT_1_5_5_5_REV; - break; - case ECF_R5G6B5: - InternalFormat=GL_RGB; - PixelFormat=GL_RGB; - PixelType=GL_UNSIGNED_SHORT_5_6_5; - break; - case ECF_R8G8B8: - InternalFormat=GL_RGB8; - PixelFormat=GL_RGB; - PixelType=GL_UNSIGNED_BYTE; - break; - case ECF_A8R8G8B8: - InternalFormat=GL_RGBA; - PixelFormat=GL_BGRA_EXT; - PixelType=GL_UNSIGNED_INT_8_8_8_8_REV; - break; - default: - os::Printer::log("Unsupported texture format", ELL_ERROR); - break; - } - - #ifndef DISABLE_MIPMAPPING - if (HasMipMaps && Driver && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE)) - { - // automatically generate and update mipmaps - glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE ); - AutomaticMipmapUpdate=true; - } - else - { - AutomaticMipmapUpdate=false; - regenerateMipMapLevels(); - } - if (HasMipMaps) // might have changed in regenerateMipMapLevels - { - // enable bilinear mipmap filter - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } - else - #else - HasMipMaps=false; - os::Printer::log("Did not create OpenGL texture mip maps.", ELL_ERROR); - #endif - { - // enable bilinear filter without mipmaps - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } - if (newTexture) - glTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, ImageSize.Width, - ImageSize.Height, 0, PixelFormat, PixelType, ImageData); - else - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, ImageSize.Width, - ImageSize.Height, PixelFormat, PixelType, ImageData); - - if (Driver->testGLError()) - os::Printer::log("Could not glTexImage2D", ELL_ERROR); -} - - - -//! returns the size of a texture which would be the optimal size for rendering it -inline s32 COpenGLTexture::getTextureSizeFromSurfaceSize(s32 size) -{ - s32 ts = 0x01; - while(ts < size) - ts <<= 1; - - return ts; -} - - -//! lock function -void* COpenGLTexture::lock() -{ - return ImageData; -} - - - -//! unlock function -void COpenGLTexture::unlock() -{ - copyTexture(false); -} - - - -//! Returns original size of the texture. -const core::dimension2d& COpenGLTexture::getOriginalSize() -{ - return OriginalSize; -} - - - -//! Returns (=size) of the texture. -const core::dimension2d& COpenGLTexture::getSize() -{ - return ImageSize; -} - - - -//! returns driver type of texture (=the driver, who created the texture) -E_DRIVER_TYPE COpenGLTexture::getDriverType() -{ - return EDT_OPENGL; -} - - - -//! returns color format of texture -ECOLOR_FORMAT COpenGLTexture::getColorFormat() const -{ - return ColorFormat; -} - - - -//! returns pitch of texture (in bytes) -u32 COpenGLTexture::getPitch() const -{ - return Pitch; -} - - - -//! return open gl texture name -GLuint COpenGLTexture::getOpenGLTextureName() -{ - return TextureName; -} - - - -//! Returns whether this texture has mipmaps -//! return true if texture has mipmaps -bool COpenGLTexture::hasMipMaps() -{ - return HasMipMaps; -} - - - -//! Regenerates the mip map levels of the texture. Useful after locking and -//! modifying the texture -//! MipMap updates are automatically performed by OpenGL. -void COpenGLTexture::regenerateMipMapLevels() -{ - if (AutomaticMipmapUpdate || !HasMipMaps) - return; - HasMipMaps=false; - return; - if (gluBuild2DMipmaps(GL_TEXTURE_2D, InternalFormat, - ImageSize.Width, ImageSize.Height, - PixelFormat, PixelType, ImageData)) - return; - else - HasMipMaps=false; - return; - - // This code is wrong as it does not take into account the image scaling - // Therefore it is currently disabled - u32 width=ImageSize.Width>>1; - u32 height=ImageSize.Height>>1; - u32 i=1; - while (width>1 || height>1) - { - //TODO: Add image scaling - glTexImage2D(GL_TEXTURE_2D, i, InternalFormat, ImageSize.Width, - ImageSize.Height, 0, PixelFormat, PixelType, ImageData); - if (width>1) - width>>=1; - if (height>1) - height>>=1; - ++i; - } -} - -bool COpenGLTexture::isFrameBufferObject() -{ - return ColorFrameBuffer != 0; -} - -//! Bind ColorFrameBuffer (valid only if isFrameBufferObject() returns true). -void COpenGLTexture::bindFrameBufferObject() -{ -#ifdef GL_EXT_framebuffer_object - if (ColorFrameBuffer != 0) - Driver->extGlBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ColorFrameBuffer); -#endif -} - -//! Unbind ColorFrameBuffer (valid only if isFrameBufferObject() returns true). -void COpenGLTexture::unbindFrameBufferObject() -{ -#ifdef GL_EXT_framebuffer_object - if (ColorFrameBuffer != 0) - Driver->extGlBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); -#endif -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_OPENGL_ +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "irrTypes.h" +#include "COpenGLTexture.h" +#include "COpenGLDriver.h" +#include "os.h" +#include "CColorConverter.h" + +#include "irrString.h" + +namespace irr +{ +namespace video +{ + +const bool checkFBOStatus(COpenGLDriver* Driver) +{ +#ifdef GL_EXT_framebuffer_object + GLenum status = Driver->extGlCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + + switch (status) + { + //Our FBO is perfect, return true + case GL_FRAMEBUFFER_COMPLETE_EXT: + return true; + + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: + os::Printer::log("FBO has invalid read buffer", ELL_ERROR); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: + os::Printer::log("FBO has invalid draw buffer", ELL_ERROR); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: + os::Printer::log("FBO has one or several incomplete image attachments", ELL_ERROR); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: + os::Printer::log("FBO has one or several image attachments with different internal formats", ELL_ERROR); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: + os::Printer::log("FBO has one or several image attachments with different dimensions", ELL_ERROR); + break; + +// not part of fbo_object anymore, but won't harm as it is just a return value +#ifdef GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT + case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: + os::Printer::log("FBO has a duplicate image attachment", ELL_ERROR); + break; +#endif + + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: + os::Printer::log("FBO missing an image attachment", ELL_ERROR); + break; + + case GL_FRAMEBUFFER_UNSUPPORTED_EXT: + os::Printer::log("FBO format unsupported", ELL_ERROR); + break; + + default: + break; + } + os::Printer::log("FBO error", ELL_ERROR); +#endif + return false; +} + +//! constructor +COpenGLTexture::COpenGLTexture(IImage* image, bool generateMipLevels, const char* name, COpenGLDriver* driver) + : ITexture(name), Pitch(0), SurfaceHasSameSize(false), ImageData(0), + ColorFormat(ECF_A8R8G8B8), Driver(driver), TextureName(0), + InternalFormat(GL_RGBA), PixelFormat(GL_BGRA_EXT), + PixelType(GL_UNSIGNED_BYTE), HasMipMaps(generateMipLevels), + ColorFrameBuffer(0), DepthRenderBuffer(0), StencilRenderBuffer(0) +{ + #ifdef _DEBUG + setDebugName("COpenGLTexture"); + #endif + + getImageData(image); + + if (ImageData) + { + glGenTextures(1, &TextureName); + copyTexture(); + } +} + +//! ColorFrameBuffer constructor +COpenGLTexture::COpenGLTexture(const core::dimension2d& size, + bool extPackedDepthStencilSupported, + const char* name, + COpenGLDriver* driver) + : ITexture(name), ImageSize(size), Pitch(0), SurfaceHasSameSize(false), + ImageData(0), ColorFormat(ECF_A8R8G8B8), Driver(driver), TextureName(0), + InternalFormat(GL_RGBA), PixelFormat(GL_BGRA_EXT), + PixelType(GL_UNSIGNED_BYTE), HasMipMaps(false), + ColorFrameBuffer(0), DepthRenderBuffer(0), StencilRenderBuffer(0) +{ + #ifdef _DEBUG + setDebugName("COpenGLTexture_FBO"); + #endif + + // generate color texture + glGenTextures(1, &TextureName); + glBindTexture(GL_TEXTURE_2D, TextureName); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, ImageSize.Width, + ImageSize.Height, 0, GL_RGBA, GL_INT, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + +#ifdef GL_EXT_packed_depth_stencil + if (extPackedDepthStencilSupported) + { + // generate packed depth stencil texture + glGenTextures(1, &DepthRenderBuffer); + glBindTexture(GL_TEXTURE_2D, DepthRenderBuffer); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_EXT, ImageSize.Width, + ImageSize.Height, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + StencilRenderBuffer = DepthRenderBuffer; // stencil is packed with depth + } + else // generate separate stencil and depth textures +#endif + { + // generate depth texture + glGenTextures(1, &DepthRenderBuffer); + glBindTexture(GL_TEXTURE_2D, DepthRenderBuffer); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, ImageSize.Width, + ImageSize.Height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + // we 're in trouble! the code below does not complete the FBO currently... + // stencil buffer is only supported with EXT_packed_depth_stencil extension (above) + +// // generate stencil texture +// glGenTextures(1, &StencilRenderBuffer); +// glBindTexture(GL_TEXTURE_2D, StencilRenderBuffer); +// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); +// glTexImage2D(GL_TEXTURE_2D, 0, GL_STENCIL_INDEX, ImageSize.Width, +// ImageSize.Height, 0, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, 0); +// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); +// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } + +#ifdef GL_EXT_framebuffer_object + // generate frame buffer + Driver->extGlGenFramebuffersEXT(1, &ColorFrameBuffer); + Driver->extGlBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ColorFrameBuffer); + + // attach color texture to frame buffer + Driver->extGlFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, + GL_COLOR_ATTACHMENT0_EXT, + GL_TEXTURE_2D, + TextureName, + 0); + // attach depth texture to depth buffer + Driver->extGlFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, + GL_DEPTH_ATTACHMENT_EXT, + GL_TEXTURE_2D, + DepthRenderBuffer, + 0); + // attach stencil texture to stencil buffer + Driver->extGlFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, + GL_STENCIL_ATTACHMENT_EXT, + GL_TEXTURE_2D, + StencilRenderBuffer, + 0); + glGetError(); + + // check the status + if (!checkFBOStatus(Driver)) + { + printf("FBO=%d, Color=%d, Depth=%d, Stencil=%d\n", + ColorFrameBuffer, TextureName, DepthRenderBuffer, StencilRenderBuffer); + if (ColorFrameBuffer) + Driver->extGlDeleteFramebuffersEXT(1, &ColorFrameBuffer); + if (DepthRenderBuffer) + glDeleteTextures(1, &DepthRenderBuffer); + if (StencilRenderBuffer && StencilRenderBuffer != DepthRenderBuffer) + glDeleteTextures(1, &StencilRenderBuffer); + ColorFrameBuffer = 0; + DepthRenderBuffer = 0; + StencilRenderBuffer = 0; + } + Driver->extGlBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); +#endif +} + +//! destructor +COpenGLTexture::~COpenGLTexture() +{ + if (ColorFrameBuffer) + Driver->extGlDeleteFramebuffersEXT(1, &ColorFrameBuffer); + if (DepthRenderBuffer) + glDeleteTextures(1, &DepthRenderBuffer); + if (StencilRenderBuffer && StencilRenderBuffer != DepthRenderBuffer) + glDeleteTextures(1, &StencilRenderBuffer); + ColorFrameBuffer = 0; + DepthRenderBuffer = 0; + StencilRenderBuffer = 0; + + glDeleteTextures(1, &TextureName); + if (ImageData) + { + delete [] ImageData; + ImageData=0; + } +} + + +void COpenGLTexture::getImageData(IImage* image) +{ + if (!image) + { + os::Printer::log("No image for OpenGL texture.", ELL_ERROR); + return; + } + + ImageSize = image->getDimension(); + OriginalSize = ImageSize; + + if ( !ImageSize.Width || !ImageSize.Height) + { + os::Printer::log("Invalid size of image for OpenGL Texture.", ELL_ERROR); + return; + } + + core::dimension2d nImageSize; + if (Driver && Driver->queryFeature(EVDF_TEXTURE_NPOT)) + nImageSize=ImageSize; + else + { + nImageSize.Width = getTextureSizeFromSurfaceSize(ImageSize.Width); + nImageSize.Height = getTextureSizeFromSurfaceSize(ImageSize.Height); + } + SurfaceHasSameSize=ImageSize==nImageSize; + + s32 bpp=0; + if (image->getColorFormat()==ECF_R8G8B8) + { + bpp=4; + ColorFormat = ECF_A8R8G8B8; + } + else + { + bpp=image->getBytesPerPixel(); + ColorFormat = image->getColorFormat(); + } + + Pitch = nImageSize.Width*bpp; + ImageData = new u8[Pitch * nImageSize.Height]; + + if (nImageSize == ImageSize) + { + void* source = image->lock(); + if (image->getColorFormat()==ECF_R8G8B8) + CColorConverter::convert_R8G8B8toA8R8G8B8(source,ImageSize.Width*ImageSize.Height,ImageData); + else + memcpy(ImageData,source,Pitch*nImageSize.Height); + } + else + { + u8* source = (u8*)image->lock(); + // scale texture + + f32 sourceXStep = (f32)ImageSize.Width / (f32)nImageSize.Width; + f32 sourceYStep = (f32)ImageSize.Height / (f32)nImageSize.Height; + f32 sx,sy; + + // copy texture scaling + sy = 0.0f; + for (s32 y=0; ygetColorFormat()==ECF_R8G8B8) + { + i*=3; + ((s32*)ImageData)[y*nImageSize.Width + x]=SColor(255,source[i],source[i+1],source[i+2]).color; + } + else + memcpy(&ImageData[(y*nImageSize.Width + x)*bpp],&source[i*bpp],bpp); + sx+=sourceXStep; + } + sy+=sourceYStep; + } + } + image->unlock(); + ImageSize = nImageSize; +} + + + +//! copies the the texture into an open gl texture. +void COpenGLTexture::copyTexture(bool newTexture) +{ + glBindTexture(GL_TEXTURE_2D, TextureName); + if (Driver->testGLError()) + os::Printer::log("Could not bind Texture", ELL_ERROR); + + switch (ColorFormat) + { + case ECF_A1R5G5B5: + InternalFormat=GL_RGBA; + PixelFormat=GL_BGRA_EXT; + PixelType=GL_UNSIGNED_SHORT_1_5_5_5_REV; + break; + case ECF_R5G6B5: + InternalFormat=GL_RGB; + PixelFormat=GL_RGB; + PixelType=GL_UNSIGNED_SHORT_5_6_5; + break; + case ECF_R8G8B8: + InternalFormat=GL_RGB8; + PixelFormat=GL_RGB; + PixelType=GL_UNSIGNED_BYTE; + break; + case ECF_A8R8G8B8: + InternalFormat=GL_RGBA; + PixelFormat=GL_BGRA_EXT; + PixelType=GL_UNSIGNED_INT_8_8_8_8_REV; + break; + default: + os::Printer::log("Unsupported texture format", ELL_ERROR); + break; + } + + #ifndef DISABLE_MIPMAPPING + if (HasMipMaps && Driver && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE)) + { + // automatically generate and update mipmaps + glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE ); + AutomaticMipmapUpdate=true; + } + else + { + AutomaticMipmapUpdate=false; + regenerateMipMapLevels(); + } + if (HasMipMaps) // might have changed in regenerateMipMapLevels + { + // enable bilinear mipmap filter + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } + else + #else + HasMipMaps=false; + os::Printer::log("Did not create OpenGL texture mip maps.", ELL_ERROR); + #endif + { + // enable bilinear filter without mipmaps + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } + if (newTexture) + glTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, ImageSize.Width, + ImageSize.Height, 0, PixelFormat, PixelType, ImageData); + else + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, ImageSize.Width, + ImageSize.Height, PixelFormat, PixelType, ImageData); + + if (Driver->testGLError()) + os::Printer::log("Could not glTexImage2D", ELL_ERROR); +} + + + +//! returns the size of a texture which would be the optimal size for rendering it +inline s32 COpenGLTexture::getTextureSizeFromSurfaceSize(s32 size) +{ + s32 ts = 0x01; + while(ts < size) + ts <<= 1; + + return ts; +} + + +//! lock function +void* COpenGLTexture::lock() +{ + return ImageData; +} + + + +//! unlock function +void COpenGLTexture::unlock() +{ + copyTexture(false); +} + + + +//! Returns original size of the texture. +const core::dimension2d& COpenGLTexture::getOriginalSize() +{ + return OriginalSize; +} + + + +//! Returns (=size) of the texture. +const core::dimension2d& COpenGLTexture::getSize() +{ + return ImageSize; +} + + + +//! returns driver type of texture (=the driver, who created the texture) +E_DRIVER_TYPE COpenGLTexture::getDriverType() +{ + return EDT_OPENGL; +} + + + +//! returns color format of texture +ECOLOR_FORMAT COpenGLTexture::getColorFormat() const +{ + return ColorFormat; +} + + + +//! returns pitch of texture (in bytes) +u32 COpenGLTexture::getPitch() const +{ + return Pitch; +} + + + +//! return open gl texture name +GLuint COpenGLTexture::getOpenGLTextureName() +{ + return TextureName; +} + + + +//! Returns whether this texture has mipmaps +//! return true if texture has mipmaps +bool COpenGLTexture::hasMipMaps() +{ + return HasMipMaps; +} + + + +//! Regenerates the mip map levels of the texture. Useful after locking and +//! modifying the texture +//! MipMap updates are automatically performed by OpenGL. +void COpenGLTexture::regenerateMipMapLevels() +{ + if (AutomaticMipmapUpdate || !HasMipMaps) + return; + HasMipMaps=false; + return; + if (gluBuild2DMipmaps(GL_TEXTURE_2D, InternalFormat, + ImageSize.Width, ImageSize.Height, + PixelFormat, PixelType, ImageData)) + return; + else + HasMipMaps=false; + return; + + // This code is wrong as it does not take into account the image scaling + // Therefore it is currently disabled + u32 width=ImageSize.Width>>1; + u32 height=ImageSize.Height>>1; + u32 i=1; + while (width>1 || height>1) + { + //TODO: Add image scaling + glTexImage2D(GL_TEXTURE_2D, i, InternalFormat, ImageSize.Width, + ImageSize.Height, 0, PixelFormat, PixelType, ImageData); + if (width>1) + width>>=1; + if (height>1) + height>>=1; + ++i; + } +} + +bool COpenGLTexture::isFrameBufferObject() +{ + return ColorFrameBuffer != 0; +} + +//! Bind ColorFrameBuffer (valid only if isFrameBufferObject() returns true). +void COpenGLTexture::bindFrameBufferObject() +{ +#ifdef GL_EXT_framebuffer_object + if (ColorFrameBuffer != 0) + Driver->extGlBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ColorFrameBuffer); +#endif +} + +//! Unbind ColorFrameBuffer (valid only if isFrameBufferObject() returns true). +void COpenGLTexture::unbindFrameBufferObject() +{ +#ifdef GL_EXT_framebuffer_object + if (ColorFrameBuffer != 0) + Driver->extGlBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); +#endif +} + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_OPENGL_ diff --git a/src/dep/src/irrlicht/COpenGLTexture.h b/src/dep/src/irrlicht/COpenGLTexture.h index a797c1c..61336a7 100644 --- a/src/dep/src/irrlicht/COpenGLTexture.h +++ b/src/dep/src/irrlicht/COpenGLTexture.h @@ -1,137 +1,137 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OPEN_GL_TEXTURE_H_INCLUDED__ -#define __C_OPEN_GL_TEXTURE_H_INCLUDED__ - -#include "ITexture.h" -#include "IImage.h" - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#ifdef _IRR_WINDOWS_ - // include windows headers for HWND - #define WIN32_LEAN_AND_MEAN - #include - #include - #include - #include "glext.h" -#ifdef _MSC_VER - #pragma comment(lib, "OpenGL32.lib") - #pragma comment(lib, "GLu32.lib") -#endif -#elif defined(MACOSX) - #include - #include - #include -#else - #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #define GL_GLEXT_LEGACY 1 - #endif - #include - #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #include "glext.h" - #endif - #include -#endif - - -namespace irr -{ -namespace video -{ - -class COpenGLDriver; -//! OpenGL texture. -class COpenGLTexture : public ITexture -{ -public: - - //! constructor - COpenGLTexture(IImage* surface, bool generateMipLevels, const char* name, COpenGLDriver* driver=0); - //! FrameBufferObject constructor - COpenGLTexture(const core::dimension2d& size, bool extPackedDepthStencilSupported, const char* name, COpenGLDriver* driver=0); - - //! destructor - virtual ~COpenGLTexture(); - - //! lock function - virtual void* lock(); - - //! unlock function - virtual void unlock(); - - //! Returns original size of the texture. - virtual const core::dimension2d& getOriginalSize(); - - //! Returns size of the texture. - virtual const core::dimension2d& getSize(); - - //! returns driver type of texture (=the driver, who created the texture) - virtual E_DRIVER_TYPE getDriverType(); - - //! returns color format of texture - virtual ECOLOR_FORMAT getColorFormat() const; - - //! returns pitch of texture (in bytes) - virtual u32 getPitch() const; - - //! return open gl texture name - GLuint getOpenGLTextureName(); - - //! return whether this texture has mipmaps - virtual bool hasMipMaps(); - - //! Regenerates the mip map levels of the texture. Useful after - //! locking and modifying the texture - virtual void regenerateMipMapLevels(); - - //! Is it a FrameBufferObject? - bool isFrameBufferObject(); - - //! Bind FrameBufferObject (valid only if isFrameBufferObject() returns true). - void bindFrameBufferObject(); - - //! Unbind FrameBufferObject (valid only if isFrameBufferObject() returns true). - void unbindFrameBufferObject(); - -private: - - void getImageData(IImage* image); - - //! copies the the texture into an open gl texture. - //! \param: newTexture is true if method is called from a newly created texture for the first time. Otherwise call with false to improve memory handling. - void copyTexture(bool newTexture=true); - - //! returns the size of a texture which would be the optimize size for rendering it - inline s32 getTextureSizeFromSurfaceSize(s32 size); - - core::dimension2d ImageSize; - core::dimension2d OriginalSize; - s32 Pitch; - bool SurfaceHasSameSize; // true if Surface has the same dimension as texture. - u8* ImageData; - ECOLOR_FORMAT ColorFormat; - COpenGLDriver* Driver; - - GLuint TextureName; - GLint InternalFormat; - GLenum PixelFormat; - GLenum PixelType; - bool HasMipMaps; - bool AutomaticMipmapUpdate; - - GLuint ColorFrameBuffer; // for FBO path - GLuint DepthRenderBuffer; // for FBO path - GLuint StencilRenderBuffer; // for FBO path -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif // _IRR_COMPILE_WITH_OPENGL_ - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_OPEN_GL_TEXTURE_H_INCLUDED__ +#define __C_OPEN_GL_TEXTURE_H_INCLUDED__ + +#include "ITexture.h" +#include "IImage.h" + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#ifdef _IRR_WINDOWS_ + // include windows headers for HWND + #define WIN32_LEAN_AND_MEAN + #include + #include + #include + #include "glext.h" +#ifdef _MSC_VER + #pragma comment(lib, "OpenGL32.lib") + #pragma comment(lib, "GLu32.lib") +#endif +#elif defined(MACOSX) + #include + #include + #include +#else + #if defined(_IRR_OPENGL_USE_EXTPOINTER_) + #define GL_GLEXT_LEGACY 1 + #endif + #include + #if defined(_IRR_OPENGL_USE_EXTPOINTER_) + #include "glext.h" + #endif + #include +#endif + + +namespace irr +{ +namespace video +{ + +class COpenGLDriver; +//! OpenGL texture. +class COpenGLTexture : public ITexture +{ +public: + + //! constructor + COpenGLTexture(IImage* surface, bool generateMipLevels, const char* name, COpenGLDriver* driver=0); + //! FrameBufferObject constructor + COpenGLTexture(const core::dimension2d& size, bool extPackedDepthStencilSupported, const char* name, COpenGLDriver* driver=0); + + //! destructor + virtual ~COpenGLTexture(); + + //! lock function + virtual void* lock(); + + //! unlock function + virtual void unlock(); + + //! Returns original size of the texture. + virtual const core::dimension2d& getOriginalSize(); + + //! Returns size of the texture. + virtual const core::dimension2d& getSize(); + + //! returns driver type of texture (=the driver, who created the texture) + virtual E_DRIVER_TYPE getDriverType(); + + //! returns color format of texture + virtual ECOLOR_FORMAT getColorFormat() const; + + //! returns pitch of texture (in bytes) + virtual u32 getPitch() const; + + //! return open gl texture name + GLuint getOpenGLTextureName(); + + //! return whether this texture has mipmaps + virtual bool hasMipMaps(); + + //! Regenerates the mip map levels of the texture. Useful after + //! locking and modifying the texture + virtual void regenerateMipMapLevels(); + + //! Is it a FrameBufferObject? + bool isFrameBufferObject(); + + //! Bind FrameBufferObject (valid only if isFrameBufferObject() returns true). + void bindFrameBufferObject(); + + //! Unbind FrameBufferObject (valid only if isFrameBufferObject() returns true). + void unbindFrameBufferObject(); + +private: + + void getImageData(IImage* image); + + //! copies the the texture into an open gl texture. + //! \param: newTexture is true if method is called from a newly created texture for the first time. Otherwise call with false to improve memory handling. + void copyTexture(bool newTexture=true); + + //! returns the size of a texture which would be the optimize size for rendering it + inline s32 getTextureSizeFromSurfaceSize(s32 size); + + core::dimension2d ImageSize; + core::dimension2d OriginalSize; + s32 Pitch; + bool SurfaceHasSameSize; // true if Surface has the same dimension as texture. + u8* ImageData; + ECOLOR_FORMAT ColorFormat; + COpenGLDriver* Driver; + + GLuint TextureName; + GLint InternalFormat; + GLenum PixelFormat; + GLenum PixelType; + bool HasMipMaps; + bool AutomaticMipmapUpdate; + + GLuint ColorFrameBuffer; // for FBO path + GLuint DepthRenderBuffer; // for FBO path + GLuint StencilRenderBuffer; // for FBO path +}; + + +} // end namespace video +} // end namespace irr + +#endif +#endif // _IRR_COMPILE_WITH_OPENGL_ + diff --git a/src/dep/src/irrlicht/CPakReader.cpp b/src/dep/src/irrlicht/CPakReader.cpp index af0a900..04eee55 100644 --- a/src/dep/src/irrlicht/CPakReader.cpp +++ b/src/dep/src/irrlicht/CPakReader.cpp @@ -1,226 +1,226 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// Code contributed by skreamz - -#include "CPakReader.h" -#include "os.h" - -#include "IrrCompileConfig.h" - -namespace irr -{ -namespace io -{ - - -CPakReader::CPakReader(IReadFile* file, bool ignoreCase, bool ignorePaths) -: File(file), IgnoreCase(ignoreCase), IgnorePaths(ignorePaths) -{ - #ifdef _DEBUG - setDebugName("CPakReader"); - #endif - - if (File) - { - File->grab(); - - // scan local headers - scanLocalHeader(); - - // prepare file index for binary search - FileList.sort(); - } -} - -CPakReader::~CPakReader() -{ - if (File) - File->drop(); -} - - - -//! splits filename from zip file into useful filenames and paths -void CPakReader::extractFilename(SPakFileEntry* entry) -{ - s32 lorfn = 56; // length of real file name - - if (!lorfn) - return; - - if (IgnoreCase) - entry->pakFileName.make_lower(); - - const c8* p = entry->pakFileName.c_str() + lorfn; - - // suche ein slash oder den anfang. - - while (*p!='/' && p!=entry->pakFileName.c_str()) - { - --p; - --lorfn; - } - - bool thereIsAPath = p != entry->pakFileName.c_str(); - - if (thereIsAPath) - { - // there is a path - ++p; - ++lorfn; - } - - entry->simpleFileName = p; - entry->path = ""; - - // pfad auch kopieren - if (thereIsAPath) - { - lorfn = (s32)(p - entry->pakFileName.c_str()); - entry->path.append(entry->pakFileName, lorfn); - } - - if (!IgnorePaths) - entry->simpleFileName = entry->pakFileName; // thanks to Pr3t3nd3r for this fix -} - - - -//! scans for a local header, returns false if there is no more local file header. -bool CPakReader::scanLocalHeader() -{ - c8 tmp[1024]; - - SPakFileEntry entry; - entry.pos = 0; - - memset(&header, 0, sizeof(SPAKFileHeader)); - File->read(&header, sizeof(SPAKFileHeader)); - - - if (header.tag[0] != 'P' && header.tag[1] != 'A') - return false; // local file headers end here. - - File->seek(header.offset); - - int count = header.length / ((sizeof(u32) * 2) + 56); - - for(int i = 0; i < count; i++) - { - // read filename - entry.pakFileName.reserve(56+2); - File->read(tmp, 56); - tmp[56] = 0x0; - entry.pakFileName = tmp; - - #ifdef _DEBUG - os::Printer::log(entry.pakFileName.c_str()); - #endif - - extractFilename(&entry); - - File->read(&entry.pos, sizeof(u32)); - File->read(&entry.length, sizeof(u32)); - FileList.push_back(entry); - } - - return true; -} - - - -//! opens a file by file name -IReadFile* CPakReader::openFile(const c8* filename) -{ - s32 index = findFile(filename); - - if (index != -1) - return openFile(index); - - return 0; -} - - - -//! opens a file by index -IReadFile* CPakReader::openFile(s32 index) -{ - File->seek(FileList[index].pos); - return createLimitReadFile(FileList[index].simpleFileName.c_str(), File, FileList[index].length); -} - - - -//! returns count of files in archive -s32 CPakReader::getFileCount() -{ - return FileList.size(); -} - - - -//! returns data of file -const SPakFileEntry* CPakReader::getFileInfo(s32 index) const -{ - return &FileList[index]; -} - - - -//! deletes the path from a filename -void CPakReader::deletePathFromFilename(core::stringc& filename) -{ - // delete path from filename - const c8* p = filename.c_str() + filename.size(); - - // suche ein slash oder den anfang. - - while (*p!='/' && *p!='\\' && p!=filename.c_str()) - --p; - - core::stringc newName; - - if (p != filename.c_str()) - { - ++p; - filename = p; - } -} - - - -//! returns fileindex -s32 CPakReader::findFile(const c8* simpleFilename) -{ - SPakFileEntry entry; - entry.simpleFileName = simpleFilename; - - if (IgnoreCase) - entry.simpleFileName.make_lower(); - - if (IgnorePaths) - deletePathFromFilename(entry.simpleFileName); - - s32 res = FileList.binary_search(entry); - - #ifdef _DEBUG - if (res == -1) - { - for (u32 i=0; igrab(); + + // scan local headers + scanLocalHeader(); + + // prepare file index for binary search + FileList.sort(); + } +} + +CPakReader::~CPakReader() +{ + if (File) + File->drop(); +} + + + +//! splits filename from zip file into useful filenames and paths +void CPakReader::extractFilename(SPakFileEntry* entry) +{ + s32 lorfn = 56; // length of real file name + + if (!lorfn) + return; + + if (IgnoreCase) + entry->pakFileName.make_lower(); + + const c8* p = entry->pakFileName.c_str() + lorfn; + + // suche ein slash oder den anfang. + + while (*p!='/' && p!=entry->pakFileName.c_str()) + { + --p; + --lorfn; + } + + bool thereIsAPath = p != entry->pakFileName.c_str(); + + if (thereIsAPath) + { + // there is a path + ++p; + ++lorfn; + } + + entry->simpleFileName = p; + entry->path = ""; + + // pfad auch kopieren + if (thereIsAPath) + { + lorfn = (s32)(p - entry->pakFileName.c_str()); + entry->path.append(entry->pakFileName, lorfn); + } + + if (!IgnorePaths) + entry->simpleFileName = entry->pakFileName; // thanks to Pr3t3nd3r for this fix +} + + + +//! scans for a local header, returns false if there is no more local file header. +bool CPakReader::scanLocalHeader() +{ + c8 tmp[1024]; + + SPakFileEntry entry; + entry.pos = 0; + + memset(&header, 0, sizeof(SPAKFileHeader)); + File->read(&header, sizeof(SPAKFileHeader)); + + + if (header.tag[0] != 'P' && header.tag[1] != 'A') + return false; // local file headers end here. + + File->seek(header.offset); + + int count = header.length / ((sizeof(u32) * 2) + 56); + + for(int i = 0; i < count; i++) + { + // read filename + entry.pakFileName.reserve(56+2); + File->read(tmp, 56); + tmp[56] = 0x0; + entry.pakFileName = tmp; + + #ifdef _DEBUG + os::Printer::log(entry.pakFileName.c_str()); + #endif + + extractFilename(&entry); + + File->read(&entry.pos, sizeof(u32)); + File->read(&entry.length, sizeof(u32)); + FileList.push_back(entry); + } + + return true; +} + + + +//! opens a file by file name +IReadFile* CPakReader::openFile(const c8* filename) +{ + s32 index = findFile(filename); + + if (index != -1) + return openFile(index); + + return 0; +} + + + +//! opens a file by index +IReadFile* CPakReader::openFile(s32 index) +{ + File->seek(FileList[index].pos); + return createLimitReadFile(FileList[index].simpleFileName.c_str(), File, FileList[index].length); +} + + + +//! returns count of files in archive +s32 CPakReader::getFileCount() +{ + return FileList.size(); +} + + + +//! returns data of file +const SPakFileEntry* CPakReader::getFileInfo(s32 index) const +{ + return &FileList[index]; +} + + + +//! deletes the path from a filename +void CPakReader::deletePathFromFilename(core::stringc& filename) +{ + // delete path from filename + const c8* p = filename.c_str() + filename.size(); + + // suche ein slash oder den anfang. + + while (*p!='/' && *p!='\\' && p!=filename.c_str()) + --p; + + core::stringc newName; + + if (p != filename.c_str()) + { + ++p; + filename = p; + } +} + + + +//! returns fileindex +s32 CPakReader::findFile(const c8* simpleFilename) +{ + SPakFileEntry entry; + entry.simpleFileName = simpleFilename; + + if (IgnoreCase) + entry.simpleFileName.make_lower(); + + if (IgnorePaths) + deletePathFromFilename(entry.simpleFileName); + + s32 res = FileList.binary_search(entry); + + #ifdef _DEBUG + if (res == -1) + { + for (u32 i=0; i FileList; - - bool IgnoreCase; - bool IgnorePaths; - }; - -} // end namespace io -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_PAK_READER_H_INCLUDED__ +#define __C_PAK_READER_H_INCLUDED__ + +#include "IUnknown.h" +#include "IReadFile.h" +#include "irrArray.h" +#include "irrString.h" + +namespace irr +{ +namespace io +{ + struct SPAKFileHeader + { + c8 tag[4]; + u32 offset; + u32 length; + }; + + + struct SPakFileEntry + { + core::stringc pakFileName; + core::stringc simpleFileName; + core::stringc path; + u32 pos; + u32 length; + + bool operator < (const SPakFileEntry& other) const + { + return simpleFileName < other.simpleFileName; + } + + + bool operator == (const SPakFileEntry& other) const + { + return simpleFileName == other.simpleFileName; + } + }; + + + class CPakReader : public IUnknown + { + public: + + CPakReader(IReadFile* file, bool ignoreCase, bool ignorePaths); + virtual ~CPakReader(); + + //! opens a file by file name + virtual IReadFile* openFile(const c8* filename); + + //! opens a file by index + IReadFile* openFile(s32 index); + + //! returns count of files in archive + s32 getFileCount(); + + //! returns data of file + const SPakFileEntry* getFileInfo(s32 index) const; + + //! returns fileindex + s32 findFile(const c8* filename); + + private: + + //! scans for a local header, returns false if there is no more local file header. + bool scanLocalHeader(); + + //! splits filename from zip file into useful filenames and paths + void extractFilename(SPakFileEntry* entry); + + //! deletes the path from a filename + void deletePathFromFilename(core::stringc& filename); + + IReadFile* File; + + SPAKFileHeader header; + + core::array FileList; + + bool IgnoreCase; + bool IgnorePaths; + }; + +} // end namespace io +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CParticleBoxEmitter.cpp b/src/dep/src/irrlicht/CParticleBoxEmitter.cpp index e5f9acb..fb540f9 100644 --- a/src/dep/src/irrlicht/CParticleBoxEmitter.cpp +++ b/src/dep/src/irrlicht/CParticleBoxEmitter.cpp @@ -1,160 +1,160 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticleBoxEmitter.h" -#include "os.h" -#include "IAttributes.h" -#include "irrMath.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleBoxEmitter::CParticleBoxEmitter( - const core::aabbox3df& box, - const core::vector3df& direction, u32 minParticlesPerSecond, - u32 maxParticlesPerSecond, video::SColor minStartColor, - video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, - s32 maxAngleDegrees) - : Box(box), Direction(direction), MinParticlesPerSecond(minParticlesPerSecond), - MaxParticlesPerSecond(maxParticlesPerSecond), - MinStartColor(minStartColor), MaxStartColor(maxStartColor), - MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0), - MaxAngleDegrees(maxAngleDegrees) -{ -} - - - -//! Prepares an array with new particles to emitt into the system -//! and returns how much new particles there are. -s32 CParticleBoxEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) -{ - Time += timeSinceLastCall; - - u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); - f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; - f32 everyWhatMillisecond = 1000.0f / perSecond; - - if (Time > everyWhatMillisecond) - { - Particles.set_used(0); - s32 amount = (s32)((Time / everyWhatMillisecond) + 0.5f); - Time = 0; - SParticle p; - const core::vector3df& extent = Box.getExtent(); - - if (amount > (s32)MaxParticlesPerSecond*2) - amount = MaxParticlesPerSecond * 2; - - for (s32 i=0; iaddVector3d("Box", b); - out->addVector3d("Direction", Direction); - out->addInt("MinParticlesPerSecond", MinParticlesPerSecond); - out->addInt("MaxParticlesPerSecond", MaxParticlesPerSecond); - out->addColor("MinStartColor", MinStartColor); - out->addColor("MaxStartColor", MaxStartColor); - out->addInt("MinLifeTime", MinLifeTime); - out->addInt("MaxLifeTime", MaxLifeTime); - out->addInt("MaxAngleDegrees", MaxAngleDegrees); -} - - -//! Reads attributes of the object. -s32 CParticleBoxEmitter::deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - // read data and correct input values here - - core::vector3df b = in->getAttributeAsVector3d("Box"); - - if (b.X <= 0) - b.X = 1.0f; - if (b.Y <= 0) - b.Y = 1.0f; - if (b.Z <= 0) - b.Z = 1.0f; - - Box.MinEdge.X = -b.X; - Box.MinEdge.Y = -b.Y; - Box.MinEdge.Z = -b.Z; - Box.MaxEdge.X = b.X; - Box.MaxEdge.Y = b.Y; - Box.MaxEdge.Z = b.Z; - - Direction = in->getAttributeAsVector3d("Direction"); - if (Direction.getLength() == 0) - Direction.set(0,0.01f,0); - - MinParticlesPerSecond = in->getAttributeAsInt("MinParticlesPerSecond"); - MaxParticlesPerSecond = in->getAttributeAsInt("MaxParticlesPerSecond"); - - MinParticlesPerSecond = core::max_(1, MinParticlesPerSecond); - MaxParticlesPerSecond = core::max_(MaxParticlesPerSecond, 1); - MaxParticlesPerSecond = core::min_(MaxParticlesPerSecond, 200); - MinParticlesPerSecond = core::min_(MinParticlesPerSecond, MaxParticlesPerSecond); - - MinStartColor = in->getAttributeAsColor("MinStartColor"); - MaxStartColor = in->getAttributeAsColor("MaxStartColor"); - MinLifeTime = in->getAttributeAsInt("MinLifeTime"); - MaxLifeTime = in->getAttributeAsInt("MaxLifeTime"); - MaxAngleDegrees = in->getAttributeAsInt("MaxAngleDegrees"); - - MinLifeTime = core::max_(0, MinLifeTime); - MaxLifeTime = core::max_(MaxLifeTime, MinLifeTime); - MinLifeTime = core::min_(MinLifeTime, MaxLifeTime); - - return in->findAttribute("MaxAngleDegrees"); -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CParticleBoxEmitter.h" +#include "os.h" +#include "IAttributes.h" +#include "irrMath.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticleBoxEmitter::CParticleBoxEmitter( + const core::aabbox3df& box, + const core::vector3df& direction, u32 minParticlesPerSecond, + u32 maxParticlesPerSecond, video::SColor minStartColor, + video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, + s32 maxAngleDegrees) + : Box(box), Direction(direction), MinParticlesPerSecond(minParticlesPerSecond), + MaxParticlesPerSecond(maxParticlesPerSecond), + MinStartColor(minStartColor), MaxStartColor(maxStartColor), + MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0), + MaxAngleDegrees(maxAngleDegrees) +{ +} + + + +//! Prepares an array with new particles to emitt into the system +//! and returns how much new particles there are. +s32 CParticleBoxEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) +{ + Time += timeSinceLastCall; + + u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); + f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; + f32 everyWhatMillisecond = 1000.0f / perSecond; + + if (Time > everyWhatMillisecond) + { + Particles.set_used(0); + s32 amount = (s32)((Time / everyWhatMillisecond) + 0.5f); + Time = 0; + SParticle p; + const core::vector3df& extent = Box.getExtent(); + + if (amount > (s32)MaxParticlesPerSecond*2) + amount = MaxParticlesPerSecond * 2; + + for (s32 i=0; iaddVector3d("Box", b); + out->addVector3d("Direction", Direction); + out->addInt("MinParticlesPerSecond", MinParticlesPerSecond); + out->addInt("MaxParticlesPerSecond", MaxParticlesPerSecond); + out->addColor("MinStartColor", MinStartColor); + out->addColor("MaxStartColor", MaxStartColor); + out->addInt("MinLifeTime", MinLifeTime); + out->addInt("MaxLifeTime", MaxLifeTime); + out->addInt("MaxAngleDegrees", MaxAngleDegrees); +} + + +//! Reads attributes of the object. +s32 CParticleBoxEmitter::deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + // read data and correct input values here + + core::vector3df b = in->getAttributeAsVector3d("Box"); + + if (b.X <= 0) + b.X = 1.0f; + if (b.Y <= 0) + b.Y = 1.0f; + if (b.Z <= 0) + b.Z = 1.0f; + + Box.MinEdge.X = -b.X; + Box.MinEdge.Y = -b.Y; + Box.MinEdge.Z = -b.Z; + Box.MaxEdge.X = b.X; + Box.MaxEdge.Y = b.Y; + Box.MaxEdge.Z = b.Z; + + Direction = in->getAttributeAsVector3d("Direction"); + if (Direction.getLength() == 0) + Direction.set(0,0.01f,0); + + MinParticlesPerSecond = in->getAttributeAsInt("MinParticlesPerSecond"); + MaxParticlesPerSecond = in->getAttributeAsInt("MaxParticlesPerSecond"); + + MinParticlesPerSecond = core::max_(1, MinParticlesPerSecond); + MaxParticlesPerSecond = core::max_(MaxParticlesPerSecond, 1); + MaxParticlesPerSecond = core::min_(MaxParticlesPerSecond, 200); + MinParticlesPerSecond = core::min_(MinParticlesPerSecond, MaxParticlesPerSecond); + + MinStartColor = in->getAttributeAsColor("MinStartColor"); + MaxStartColor = in->getAttributeAsColor("MaxStartColor"); + MinLifeTime = in->getAttributeAsInt("MinLifeTime"); + MaxLifeTime = in->getAttributeAsInt("MaxLifeTime"); + MaxAngleDegrees = in->getAttributeAsInt("MaxAngleDegrees"); + + MinLifeTime = core::max_(0, MinLifeTime); + MaxLifeTime = core::max_(MaxLifeTime, MinLifeTime); + MinLifeTime = core::min_(MinLifeTime, MaxLifeTime); + + return in->findAttribute("MaxAngleDegrees"); +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CParticleBoxEmitter.h b/src/dep/src/irrlicht/CParticleBoxEmitter.h index cf78f4f..ba91299 100644 --- a/src/dep/src/irrlicht/CParticleBoxEmitter.h +++ b/src/dep/src/irrlicht/CParticleBoxEmitter.h @@ -1,66 +1,66 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_BOX_EMITTER_H_INCLUDED__ -#define __C_PARTICLE_BOX_EMITTER_H_INCLUDED__ - -#include "IParticleEmitter.h" -#include "irrArray.h" -#include "aabbox3d.h" - -namespace irr -{ -namespace scene -{ - -//! A default box emitter -class CParticleBoxEmitter : public IParticleEmitter -{ -public: - - //! constructor - CParticleBoxEmitter( - const core::aabbox3df& box, - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 20, - u32 maxParticlesPerSecond = 40, - video::SColor minStartColor = video::SColor(255,0,0,0), - video::SColor maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, - u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0); - - //! Prepares an array with new particles to emitt into the system - //! and returns how much new particles there are. - virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray); - - //! Writes attributes of the object. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the object. - virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - //! Get emitter type - virtual E_PARTICLE_EMITTER_TYPE getType() { return EPET_BOX; } - -private: - - core::array Particles; - core::aabbox3df Box; - core::vector3df Direction; - s32 MinParticlesPerSecond, MaxParticlesPerSecond; - video::SColor MinStartColor, MaxStartColor; - s32 MinLifeTime, MaxLifeTime; - - u32 Time; - u32 Emitted; - s32 MaxAngleDegrees; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_PARTICLE_BOX_EMITTER_H_INCLUDED__ +#define __C_PARTICLE_BOX_EMITTER_H_INCLUDED__ + +#include "IParticleEmitter.h" +#include "irrArray.h" +#include "aabbox3d.h" + +namespace irr +{ +namespace scene +{ + +//! A default box emitter +class CParticleBoxEmitter : public IParticleEmitter +{ +public: + + //! constructor + CParticleBoxEmitter( + const core::aabbox3df& box, + const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), + u32 minParticlesPerSecond = 20, + u32 maxParticlesPerSecond = 40, + video::SColor minStartColor = video::SColor(255,0,0,0), + video::SColor maxStartColor = video::SColor(255,255,255,255), + u32 lifeTimeMin=2000, + u32 lifeTimeMax=4000, + s32 maxAngleDegrees=0); + + //! Prepares an array with new particles to emitt into the system + //! and returns how much new particles there are. + virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray); + + //! Writes attributes of the object. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the object. + virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + //! Get emitter type + virtual E_PARTICLE_EMITTER_TYPE getType() { return EPET_BOX; } + +private: + + core::array Particles; + core::aabbox3df Box; + core::vector3df Direction; + s32 MinParticlesPerSecond, MaxParticlesPerSecond; + video::SColor MinStartColor, MaxStartColor; + s32 MinLifeTime, MaxLifeTime; + + u32 Time; + u32 Emitted; + s32 MaxAngleDegrees; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CParticleFadeOutAffector.cpp b/src/dep/src/irrlicht/CParticleFadeOutAffector.cpp index 5170a5d..4dbe48b 100644 --- a/src/dep/src/irrlicht/CParticleFadeOutAffector.cpp +++ b/src/dep/src/irrlicht/CParticleFadeOutAffector.cpp @@ -1,79 +1,79 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticleFadeOutAffector.h" -#include "IAttributes.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleFadeOutAffector::CParticleFadeOutAffector( - video::SColor targetColor, u32 fadeOutTime) - : IParticleAffector(), TargetColor(targetColor) -{ - FadeOutTime = fadeOutTime ? (f32)fadeOutTime : 1.0f; -} - - -//! Affects an array of particles. -void CParticleFadeOutAffector::affect(u32 now, SParticle* particlearray, u32 count) -{ - if (!Enabled) - return; - f32 d; - - for (u32 i=0; iaddColor("TargetColor", TargetColor); - out->addFloat("FadeOutTime", FadeOutTime); -} - -//! Reads attributes of the object. -//! Implement this to set the attributes of your scene node animator for -//! scripting languages, editors, debuggers or xml deserialization purposes. -//! \param startIndex: start index where to start reading attributes. -//! \return: returns last index of an attribute read by this affector -s32 CParticleFadeOutAffector::deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - const char* name = in->getAttributeName(startIndex); - - if (!name || strcmp(name, "TargetColor")) - return startIndex; // attribute not valid - - TargetColor = in->getAttributeAsColor(startIndex); - ++startIndex; - - in->getAttributeName(startIndex); - if (!name || strcmp(name, "FadeOutTime")) - return startIndex; // attribute not valid - - FadeOutTime = in->getAttributeAsFloat(startIndex); - - ++startIndex; - return startIndex; -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CParticleFadeOutAffector.h" +#include "IAttributes.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticleFadeOutAffector::CParticleFadeOutAffector( + video::SColor targetColor, u32 fadeOutTime) + : IParticleAffector(), TargetColor(targetColor) +{ + FadeOutTime = fadeOutTime ? (f32)fadeOutTime : 1.0f; +} + + +//! Affects an array of particles. +void CParticleFadeOutAffector::affect(u32 now, SParticle* particlearray, u32 count) +{ + if (!Enabled) + return; + f32 d; + + for (u32 i=0; iaddColor("TargetColor", TargetColor); + out->addFloat("FadeOutTime", FadeOutTime); +} + +//! Reads attributes of the object. +//! Implement this to set the attributes of your scene node animator for +//! scripting languages, editors, debuggers or xml deserialization purposes. +//! \param startIndex: start index where to start reading attributes. +//! \return: returns last index of an attribute read by this affector +s32 CParticleFadeOutAffector::deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + const char* name = in->getAttributeName(startIndex); + + if (!name || strcmp(name, "TargetColor")) + return startIndex; // attribute not valid + + TargetColor = in->getAttributeAsColor(startIndex); + ++startIndex; + + in->getAttributeName(startIndex); + if (!name || strcmp(name, "FadeOutTime")) + return startIndex; // attribute not valid + + FadeOutTime = in->getAttributeAsFloat(startIndex); + + ++startIndex; + return startIndex; +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CParticleFadeOutAffector.h b/src/dep/src/irrlicht/CParticleFadeOutAffector.h index 960b700..d6794f9 100644 --- a/src/dep/src/irrlicht/CParticleFadeOutAffector.h +++ b/src/dep/src/irrlicht/CParticleFadeOutAffector.h @@ -1,52 +1,52 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ -#define __C_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ - -#include "IParticleAffector.h" -#include "SColor.h" - -namespace irr -{ -namespace scene -{ - -//! Particle Affector for fading out a color -class CParticleFadeOutAffector : public IParticleAffector -{ -public: - - CParticleFadeOutAffector(video::SColor targetColor, u32 fadeOutTime); - - //! Affects a particle. - virtual void affect(u32 now, SParticle* particlearray, u32 count); - - //! Writes attributes of the object. - //! Implement this to expose the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the object. - //! Implement this to set the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml deserialization purposes. - //! \param startIndex: start index where to start reading attributes. - //! \return: returns last index of an attribute read by this affector - virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - //! Get emitter type - virtual E_PARTICLE_AFFECTOR_TYPE getType() { return EPAT_FADE_OUT; } - -private: - - video::SColor TargetColor; - f32 FadeOutTime; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ +#define __C_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ + +#include "IParticleAffector.h" +#include "SColor.h" + +namespace irr +{ +namespace scene +{ + +//! Particle Affector for fading out a color +class CParticleFadeOutAffector : public IParticleAffector +{ +public: + + CParticleFadeOutAffector(video::SColor targetColor, u32 fadeOutTime); + + //! Affects a particle. + virtual void affect(u32 now, SParticle* particlearray, u32 count); + + //! Writes attributes of the object. + //! Implement this to expose the attributes of your scene node animator for + //! scripting languages, editors, debuggers or xml serialization purposes. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the object. + //! Implement this to set the attributes of your scene node animator for + //! scripting languages, editors, debuggers or xml deserialization purposes. + //! \param startIndex: start index where to start reading attributes. + //! \return: returns last index of an attribute read by this affector + virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + //! Get emitter type + virtual E_PARTICLE_AFFECTOR_TYPE getType() { return EPAT_FADE_OUT; } + +private: + + video::SColor TargetColor; + f32 FadeOutTime; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CParticleGravityAffector.cpp b/src/dep/src/irrlicht/CParticleGravityAffector.cpp index 9b52899..b69f8e2 100644 --- a/src/dep/src/irrlicht/CParticleGravityAffector.cpp +++ b/src/dep/src/irrlicht/CParticleGravityAffector.cpp @@ -1,75 +1,75 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticleGravityAffector.h" -#include "os.h" -#include "IAttributes.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleGravityAffector::CParticleGravityAffector( - const core::vector3df& gravity, u32 timeForceLost) - : IParticleAffector(), TimeForceLost((f32)timeForceLost), Gravity(gravity) -{ -} - - -//! Affects an array of particles. -void CParticleGravityAffector::affect(u32 now, SParticle* particlearray, u32 count) -{ - if (!Enabled) - return; - f32 d; - - for (u32 i=0; i 1.0f) - d = 1.0f; - if (d < 0.0f) - d = 0.0f; - d = 1.0f - d; - - particlearray[i].vector = particlearray[i].startVector.getInterpolated(Gravity, d); - } -} - -//! Writes attributes of the object. -void CParticleGravityAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - out->addVector3d("Gravity", Gravity); - out->addFloat("TimeForceLost", TimeForceLost); -} - - -//! Reads attributes of the object. -s32 CParticleGravityAffector::deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - const char* name = in->getAttributeName(startIndex); - - if (!name || strcmp(name, "Gravity")) - return startIndex; // attribute not valid - - Gravity = in->getAttributeAsVector3d(startIndex); - ++startIndex; - - name = in->getAttributeName(startIndex); - if (!name || strcmp(name, "TimeForceLost")) - return startIndex; // attribute not valid - - TimeForceLost = in->getAttributeAsFloat(startIndex); - - ++startIndex; - return startIndex; -} - - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CParticleGravityAffector.h" +#include "os.h" +#include "IAttributes.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticleGravityAffector::CParticleGravityAffector( + const core::vector3df& gravity, u32 timeForceLost) + : IParticleAffector(), TimeForceLost((f32)timeForceLost), Gravity(gravity) +{ +} + + +//! Affects an array of particles. +void CParticleGravityAffector::affect(u32 now, SParticle* particlearray, u32 count) +{ + if (!Enabled) + return; + f32 d; + + for (u32 i=0; i 1.0f) + d = 1.0f; + if (d < 0.0f) + d = 0.0f; + d = 1.0f - d; + + particlearray[i].vector = particlearray[i].startVector.getInterpolated(Gravity, d); + } +} + +//! Writes attributes of the object. +void CParticleGravityAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + out->addVector3d("Gravity", Gravity); + out->addFloat("TimeForceLost", TimeForceLost); +} + + +//! Reads attributes of the object. +s32 CParticleGravityAffector::deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + const char* name = in->getAttributeName(startIndex); + + if (!name || strcmp(name, "Gravity")) + return startIndex; // attribute not valid + + Gravity = in->getAttributeAsVector3d(startIndex); + ++startIndex; + + name = in->getAttributeName(startIndex); + if (!name || strcmp(name, "TimeForceLost")) + return startIndex; // attribute not valid + + TimeForceLost = in->getAttributeAsFloat(startIndex); + + ++startIndex; + return startIndex; +} + + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CParticleGravityAffector.h b/src/dep/src/irrlicht/CParticleGravityAffector.h index 855c75a..e5d4898 100644 --- a/src/dep/src/irrlicht/CParticleGravityAffector.h +++ b/src/dep/src/irrlicht/CParticleGravityAffector.h @@ -1,54 +1,54 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ -#define __C_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ - -#include "IParticleAffector.h" -#include "SColor.h" - -namespace irr -{ -namespace scene -{ - -//! Particle Affector for affecting direction of particle -class CParticleGravityAffector : public IParticleAffector -{ -public: - - CParticleGravityAffector( - const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), - u32 timeForceLost = 1000); - - //! Affects a particle. - virtual void affect(u32 now, SParticle* particlearray, u32 count); - - //! Writes attributes of the object. - //! Implement this to expose the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the object. - //! Implement this to set the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml deserialization purposes. - //! \param startIndex: start index where to start reading attributes. - //! \return: returns last index of an attribute read by this affector - virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - //! Get emitter type - virtual E_PARTICLE_AFFECTOR_TYPE getType() { return EPAT_GRAVITY; } - -private: - - f32 TimeForceLost; - core::vector3df Gravity; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ +#define __C_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ + +#include "IParticleAffector.h" +#include "SColor.h" + +namespace irr +{ +namespace scene +{ + +//! Particle Affector for affecting direction of particle +class CParticleGravityAffector : public IParticleAffector +{ +public: + + CParticleGravityAffector( + const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), + u32 timeForceLost = 1000); + + //! Affects a particle. + virtual void affect(u32 now, SParticle* particlearray, u32 count); + + //! Writes attributes of the object. + //! Implement this to expose the attributes of your scene node animator for + //! scripting languages, editors, debuggers or xml serialization purposes. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the object. + //! Implement this to set the attributes of your scene node animator for + //! scripting languages, editors, debuggers or xml deserialization purposes. + //! \param startIndex: start index where to start reading attributes. + //! \return: returns last index of an attribute read by this affector + virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + //! Get emitter type + virtual E_PARTICLE_AFFECTOR_TYPE getType() { return EPAT_GRAVITY; } + +private: + + f32 TimeForceLost; + core::vector3df Gravity; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CParticlePointEmitter.cpp b/src/dep/src/irrlicht/CParticlePointEmitter.cpp index d017cdd..e531bb0 100644 --- a/src/dep/src/irrlicht/CParticlePointEmitter.cpp +++ b/src/dep/src/irrlicht/CParticlePointEmitter.cpp @@ -1,119 +1,119 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticlePointEmitter.h" -#include "os.h" -#include "IAttributes.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticlePointEmitter::CParticlePointEmitter( - const core::vector3df& direction, u32 minParticlesPerSecond, - u32 maxParticlesPerSecond, video::SColor minStartColor, - video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, - s32 maxAngleDegrees) - : Direction(direction), MinParticlesPerSecond(minParticlesPerSecond), - MaxParticlesPerSecond(maxParticlesPerSecond), - MinStartColor(minStartColor), MaxStartColor(maxStartColor), - MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), - MaxAngleDegrees(maxAngleDegrees), Time(0), Emitted(0) -{ - -} - - - -//! Prepares an array with new particles to emitt into the system -//! and returns how much new particles there are. -s32 CParticlePointEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) -{ - Time += timeSinceLastCall; - - u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); - f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; - f32 everyWhatMillisecond = 1000.0f / perSecond; - - if (Time > everyWhatMillisecond) - { - Time = 0; - Particle.startTime = now; - Particle.vector = Direction; - - if (MaxAngleDegrees) - { - core::vector3df tgt = Direction; - tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); - tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); - tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); - Particle.vector = tgt; - } - - if (MaxLifeTime - MinLifeTime == 0) - Particle.endTime = now + MinLifeTime; - else - Particle.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime)); - - Particle.color = MinStartColor.getInterpolated( - MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f); - - Particle.startColor = Particle.color; - Particle.startVector = Particle.vector; - outArray = &Particle; - return 1; - } - - return 0; -} - - -//! Writes attributes of the object. -void CParticlePointEmitter::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - out->addVector3d("Direction", Direction); - out->addInt("MinParticlesPerSecond", MinParticlesPerSecond); - out->addInt("MaxParticlesPerSecond", MaxParticlesPerSecond); - out->addColor("MinStartColor", MinStartColor); - out->addColor("MaxStartColor", MaxStartColor); - out->addInt("MinLifeTime", MinLifeTime); - out->addInt("MaxLifeTime", MaxLifeTime); - out->addInt("MaxAngleDegrees", MaxAngleDegrees); -} - - -//! Reads attributes of the object. -s32 CParticlePointEmitter::deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Direction = in->getAttributeAsVector3d("Direction"); - if (Direction.getLength() == 0) - Direction.set(0,0.01f,0); - - MinParticlesPerSecond = in->getAttributeAsInt("MinParticlesPerSecond"); - MaxParticlesPerSecond = in->getAttributeAsInt("MaxParticlesPerSecond"); - - MinParticlesPerSecond = core::max_(1, MinParticlesPerSecond); - MaxParticlesPerSecond = core::max_(MaxParticlesPerSecond, 1); - MaxParticlesPerSecond = core::min_(MaxParticlesPerSecond, 200); - MinParticlesPerSecond = core::min_(MinParticlesPerSecond, MaxParticlesPerSecond); - - MinStartColor = in->getAttributeAsColor("MinStartColor"); - MaxStartColor = in->getAttributeAsColor("MaxStartColor"); - MinLifeTime = in->getAttributeAsInt("MinLifeTime"); - MaxLifeTime = in->getAttributeAsInt("MaxLifeTime"); - MaxAngleDegrees = in->getAttributeAsInt("MaxAngleDegrees"); - - MinLifeTime = core::max_(0, MinLifeTime); - MaxLifeTime = core::max_(MaxLifeTime, MinLifeTime); - MinLifeTime = core::min_(MinLifeTime, MaxLifeTime); - - return in->findAttribute("MaxAngleDegrees"); -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CParticlePointEmitter.h" +#include "os.h" +#include "IAttributes.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticlePointEmitter::CParticlePointEmitter( + const core::vector3df& direction, u32 minParticlesPerSecond, + u32 maxParticlesPerSecond, video::SColor minStartColor, + video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, + s32 maxAngleDegrees) + : Direction(direction), MinParticlesPerSecond(minParticlesPerSecond), + MaxParticlesPerSecond(maxParticlesPerSecond), + MinStartColor(minStartColor), MaxStartColor(maxStartColor), + MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), + MaxAngleDegrees(maxAngleDegrees), Time(0), Emitted(0) +{ + +} + + + +//! Prepares an array with new particles to emitt into the system +//! and returns how much new particles there are. +s32 CParticlePointEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) +{ + Time += timeSinceLastCall; + + u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); + f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; + f32 everyWhatMillisecond = 1000.0f / perSecond; + + if (Time > everyWhatMillisecond) + { + Time = 0; + Particle.startTime = now; + Particle.vector = Direction; + + if (MaxAngleDegrees) + { + core::vector3df tgt = Direction; + tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); + tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); + tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); + Particle.vector = tgt; + } + + if (MaxLifeTime - MinLifeTime == 0) + Particle.endTime = now + MinLifeTime; + else + Particle.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime)); + + Particle.color = MinStartColor.getInterpolated( + MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f); + + Particle.startColor = Particle.color; + Particle.startVector = Particle.vector; + outArray = &Particle; + return 1; + } + + return 0; +} + + +//! Writes attributes of the object. +void CParticlePointEmitter::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + out->addVector3d("Direction", Direction); + out->addInt("MinParticlesPerSecond", MinParticlesPerSecond); + out->addInt("MaxParticlesPerSecond", MaxParticlesPerSecond); + out->addColor("MinStartColor", MinStartColor); + out->addColor("MaxStartColor", MaxStartColor); + out->addInt("MinLifeTime", MinLifeTime); + out->addInt("MaxLifeTime", MaxLifeTime); + out->addInt("MaxAngleDegrees", MaxAngleDegrees); +} + + +//! Reads attributes of the object. +s32 CParticlePointEmitter::deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + Direction = in->getAttributeAsVector3d("Direction"); + if (Direction.getLength() == 0) + Direction.set(0,0.01f,0); + + MinParticlesPerSecond = in->getAttributeAsInt("MinParticlesPerSecond"); + MaxParticlesPerSecond = in->getAttributeAsInt("MaxParticlesPerSecond"); + + MinParticlesPerSecond = core::max_(1, MinParticlesPerSecond); + MaxParticlesPerSecond = core::max_(MaxParticlesPerSecond, 1); + MaxParticlesPerSecond = core::min_(MaxParticlesPerSecond, 200); + MinParticlesPerSecond = core::min_(MinParticlesPerSecond, MaxParticlesPerSecond); + + MinStartColor = in->getAttributeAsColor("MinStartColor"); + MaxStartColor = in->getAttributeAsColor("MaxStartColor"); + MinLifeTime = in->getAttributeAsInt("MinLifeTime"); + MaxLifeTime = in->getAttributeAsInt("MaxLifeTime"); + MaxAngleDegrees = in->getAttributeAsInt("MaxAngleDegrees"); + + MinLifeTime = core::max_(0, MinLifeTime); + MaxLifeTime = core::max_(MaxLifeTime, MinLifeTime); + MinLifeTime = core::min_(MinLifeTime, MaxLifeTime); + + return in->findAttribute("MaxAngleDegrees"); +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CParticlePointEmitter.h b/src/dep/src/irrlicht/CParticlePointEmitter.h index c2a1930..12cf3e6 100644 --- a/src/dep/src/irrlicht/CParticlePointEmitter.h +++ b/src/dep/src/irrlicht/CParticlePointEmitter.h @@ -1,63 +1,63 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_POINT_EMITTER_H_INCLUDED__ -#define __C_PARTICLE_POINT_EMITTER_H_INCLUDED__ - -#include "IParticleEmitter.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - -//! A default point emitter -class CParticlePointEmitter : public IParticleEmitter -{ -public: - - //! constructor - CParticlePointEmitter( - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - video::SColor minStartColor = video::SColor(255,0,0,0), - video::SColor maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, - u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0); - - //! Prepares an array with new particles to emitt into the system - //! and returns how much new particles there are. - virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray); - - //! Writes attributes of the object. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - - //! Reads attributes of the object. - virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - //! Get emitter type - virtual E_PARTICLE_EMITTER_TYPE getType() { return EPET_POINT; } - -private: - - SParticle Particle; - core::vector3df Direction; - s32 MinParticlesPerSecond, MaxParticlesPerSecond; - video::SColor MinStartColor, MaxStartColor; - s32 MinLifeTime, MaxLifeTime; - s32 MaxAngleDegrees; - - u32 Time; - u32 Emitted; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_PARTICLE_POINT_EMITTER_H_INCLUDED__ +#define __C_PARTICLE_POINT_EMITTER_H_INCLUDED__ + +#include "IParticleEmitter.h" +#include "irrArray.h" + +namespace irr +{ +namespace scene +{ + +//! A default point emitter +class CParticlePointEmitter : public IParticleEmitter +{ +public: + + //! constructor + CParticlePointEmitter( + const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), + u32 minParticlesPerSecond = 5, + u32 maxParticlesPerSecond = 10, + video::SColor minStartColor = video::SColor(255,0,0,0), + video::SColor maxStartColor = video::SColor(255,255,255,255), + u32 lifeTimeMin=2000, + u32 lifeTimeMax=4000, + s32 maxAngleDegrees=0); + + //! Prepares an array with new particles to emitt into the system + //! and returns how much new particles there are. + virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray); + + //! Writes attributes of the object. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the object. + virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + //! Get emitter type + virtual E_PARTICLE_EMITTER_TYPE getType() { return EPET_POINT; } + +private: + + SParticle Particle; + core::vector3df Direction; + s32 MinParticlesPerSecond, MaxParticlesPerSecond; + video::SColor MinStartColor, MaxStartColor; + s32 MinLifeTime, MaxLifeTime; + s32 MaxAngleDegrees; + + u32 Time; + u32 Emitted; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CParticleSystemSceneNode.cpp b/src/dep/src/irrlicht/CParticleSystemSceneNode.cpp index 60f2b91..5437ab5 100644 --- a/src/dep/src/irrlicht/CParticleSystemSceneNode.cpp +++ b/src/dep/src/irrlicht/CParticleSystemSceneNode.cpp @@ -1,529 +1,529 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticleSystemSceneNode.h" -#include "os.h" -#include "ISceneManager.h" -#include "ICameraSceneNode.h" -#include "IVideoDriver.h" - -#include "CParticlePointEmitter.h" -#include "CParticleBoxEmitter.h" -#include "CParticleFadeOutAffector.h" -#include "CParticleGravityAffector.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleSystemSceneNode::CParticleSystemSceneNode(bool createDefaultEmitter, - ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::vector3df& rotation, - const core::vector3df& scale) - : IParticleSystemSceneNode(parent, mgr, id, position, rotation, scale), - Emitter(0), LastEmitTime(0), ParticlesAreGlobal(true) -{ - #ifdef _DEBUG - setDebugName("CParticleSystemSceneNode"); - #endif - - if (createDefaultEmitter) - { - IParticleEmitter* e = createBoxEmitter(); - setEmitter(e); - e->drop(); - } - - setParticleSize(); -} - - - -//! destructor -CParticleSystemSceneNode::~CParticleSystemSceneNode() -{ - if (Emitter) - Emitter->drop(); - - removeAllAffectors(); -} - - - -//! Sets the particle emitter, which creates the particles. -void CParticleSystemSceneNode::setEmitter(IParticleEmitter* emitter) -{ - if (Emitter) - Emitter->drop(); - - Emitter = emitter; - - if (Emitter) - Emitter->grab(); -} - - - -//! Adds new particle effector to the particle system. -void CParticleSystemSceneNode::addAffector(IParticleAffector* affector) -{ - affector->grab(); - AffectorList.push_back(affector); -} - - - -//! Removes all particle affectors in the particle system. -void CParticleSystemSceneNode::removeAllAffectors() -{ - core::list::Iterator it = AffectorList.begin(); - while (it != AffectorList.end()) - { - (*it)->drop(); - it = AffectorList.erase(it); - } -} - - -//! Returns the material based on the zero based index i. -video::SMaterial& CParticleSystemSceneNode::getMaterial(u32 i) -{ - return Buffer.Material; -} - - - -//! Returns amount of materials used by this scene node. -u32 CParticleSystemSceneNode::getMaterialCount() -{ - return 1; -} - - - -//! Creates a point particle emitter. -IParticleEmitter* CParticleSystemSceneNode::createPointEmitter( - const core::vector3df& direction, u32 minParticlesPerSecond, - u32 maxParticlePerSecond, video::SColor minStartColor, - video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, - s32 maxAngleDegrees) -{ - return new CParticlePointEmitter(direction, minParticlesPerSecond, - maxParticlePerSecond, minStartColor, maxStartColor, - lifeTimeMin, lifeTimeMax, maxAngleDegrees); -} - - -//! Creates a box particle emitter. -IParticleEmitter* CParticleSystemSceneNode::createBoxEmitter( - const core::aabbox3df& box, const core::vector3df& direction, - u32 minParticlesPerSecond, u32 maxParticlePerSecond, - video::SColor minStartColor, video::SColor maxStartColor, - u32 lifeTimeMin, u32 lifeTimeMax, - s32 maxAngleDegrees) -{ - return new CParticleBoxEmitter(box, direction, minParticlesPerSecond, - maxParticlePerSecond, minStartColor, maxStartColor, - lifeTimeMin, lifeTimeMax, maxAngleDegrees); -} - - - -//! Creates a fade out particle affector. -IParticleAffector* CParticleSystemSceneNode::createFadeOutParticleAffector( - video::SColor targetColor, u32 timeNeededToFadeOut) -{ - return new CParticleFadeOutAffector(targetColor, timeNeededToFadeOut); -} - - -//! Creates a gravity affector. -IParticleAffector* CParticleSystemSceneNode::createGravityAffector( - const core::vector3df& gravity, u32 timeForceLost) -{ - return new CParticleGravityAffector(gravity, timeForceLost); -} - - -//! pre render event -void CParticleSystemSceneNode::OnRegisterSceneNode() -{ - doParticleSystem(os::Timer::getTime()); - - if (IsVisible && (Particles.size() != 0)) - { - SceneManager->registerNodeForRendering(this); - ISceneNode::OnRegisterSceneNode(); - } -} - - - -//! render -void CParticleSystemSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - ICameraSceneNode* camera = SceneManager->getActiveCamera(); - - if (!camera || !driver) - return; - - -#if 0 - // calculate vectors for letting particles look to camera - core::vector3df view(camera->getTarget() - camera->getAbsolutePosition()); - view.normalize(); - - core::vector3df horizontal = camera->getUpVector().crossProduct(view); - horizontal.normalize(); - horizontal *= 0.5f * ParticleSize.Width; - - core::vector3df vertical = horizontal.crossProduct(view); - vertical.normalize(); - vertical *= 0.5f * ParticleSize.Height; - - view *= -1.0f; - -#else - - const core::matrix4 &m = camera->getViewFrustum()->Matrices [ video::ETS_VIEW ]; - - f32 f; - - f = 0.5f * ParticleSize.Width; - const core::vector3df horizontal ( m[0] * f, m[4] * f, m[8] * f ); - - f = -0.5f * ParticleSize.Height; - const core::vector3df vertical ( m[1] * f, m[5] * f, m[9] * f ); - - const core::vector3df view ( -m[2], -m[6] , -m[10] ); - -#endif - - // reallocate arrays, if they are too small - reallocateBuffers(); - - // create particle vertex data - s32 idx = 0; - for (u32 i=0; isetTransform(video::ETS_WORLD, mat); - - driver->setMaterial(Buffer.Material); - - driver->drawVertexPrimitiveList(Buffer.getVertices(), Particles.size()*4, - Buffer.getIndices(), Particles.size()*2, video::EVT_STANDARD, EPT_TRIANGLES); - - // for debug purposes only: - if (DebugDataVisible) - { - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - driver->draw3DBox(Buffer.BoundingBox, video::SColor(0,255,255,255)); - } -} - - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CParticleSystemSceneNode::getBoundingBox() const -{ - return Buffer.getBoundingBox(); -} - - - -void CParticleSystemSceneNode::doParticleSystem(u32 time) -{ - if (LastEmitTime==0) - { - LastEmitTime = time; - return; - } - - u32 now = time; - u32 timediff = time - LastEmitTime; - LastEmitTime = time; - - // run emitter - - if (Emitter && IsVisible) - { - SParticle* array = 0; - s32 newParticles = Emitter->emitt(now, timediff, array); - - if (newParticles && array) - { - s32 j=Particles.size(); - if (newParticles > 16250-j) - newParticles=16250-j; - Particles.set_used(j+newParticles); - for (s32 i=0; i::Iterator ait = AffectorList.begin(); - for (; ait != AffectorList.end(); ++ait) - (*ait)->affect(now, Particles.pointer(), Particles.size()); - - if (ParticlesAreGlobal) - Buffer.BoundingBox.reset(AbsoluteTransformation.getTranslation()); - else - Buffer.BoundingBox.reset(core::vector3df(0,0,0)); - - // animate all particles - f32 scale = (f32)timediff; - - for (s32 i=0; i<(s32)Particles.size();) - { - if (now > Particles[i].endTime) - Particles.erase(i); - else - { - Particles[i].pos += (Particles[i].vector * scale); - Buffer.BoundingBox.addInternalPoint(Particles[i].pos); - ++i; - } - } - - f32 m = ParticleSize.Width > ParticleSize.Height ? ParticleSize.Width : ParticleSize.Height; - m *= 0.5f; - Buffer.BoundingBox.MaxEdge.X += m; - Buffer.BoundingBox.MaxEdge.Y += m; - Buffer.BoundingBox.MaxEdge.Z += m; - - Buffer.BoundingBox.MinEdge.X -= m; - Buffer.BoundingBox.MinEdge.Y -= m; - Buffer.BoundingBox.MinEdge.Z -= m; - - if (ParticlesAreGlobal) - { - core::matrix4 absinv = AbsoluteTransformation; - absinv.makeInverse(); - absinv.transformBox(Buffer.BoundingBox); - } -} - - -//! Sets if the particles should be global. If it is, the particles are affected by -//! the movement of the particle system scene node too, otherwise they completely -//! ignore it. Default is true. -void CParticleSystemSceneNode::setParticlesAreGlobal(bool global) -{ - ParticlesAreGlobal = global; -} - - - -//! Sets the size of all particles. -void CParticleSystemSceneNode::setParticleSize(const core::dimension2d &size) -{ - ParticleSize = size; -} - - -void CParticleSystemSceneNode::reallocateBuffers() -{ - if (Particles.size() * 4 > Buffer.getVertexCount() || - Particles.size() * 6 > Buffer.getIndexCount()) - { - u32 oldSize = Buffer.getVertexCount(); - Buffer.Vertices.set_used(Particles.size() * 4); - - u32 i; - - // fill remaining vertices - for (i=oldSize; iaddBool("GlobalParticles", ParticlesAreGlobal); - out->addFloat("ParticleWidth", ParticleSize.Width); - out->addFloat("ParticleHeight", ParticleSize.Height); - - // write emitter - - E_PARTICLE_EMITTER_TYPE type = EPET_COUNT; - if (Emitter) - type = Emitter->getType(); - - out->addEnum("Emitter", (s32)type, ParticleEmitterTypeNames); - - if (Emitter) - Emitter->serializeAttributes(out, options); - - // write affectors - - E_PARTICLE_AFFECTOR_TYPE atype = EPAT_NONE; - - for (core::list::Iterator it = AffectorList.begin(); - it != AffectorList.end(); ++it) - { - atype = (*it)->getType(); - - out->addEnum("Affector", (s32)atype, ParticleAffectorTypeNames); - - (*it)->serializeAttributes(out); - } - - // add empty affector to make it possible to add further affectors - - if (options && options->Flags & io::EARWF_FOR_EDITOR) - out->addEnum("Affector", EPAT_NONE, ParticleAffectorTypeNames); -} - - -//! Reads attributes of the scene node. -void CParticleSystemSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - IParticleSystemSceneNode::deserializeAttributes(in, options); - - ParticlesAreGlobal = in->getAttributeAsBool("GlobalParticles"); - ParticleSize.Width = in->getAttributeAsFloat("ParticleWidth"); - ParticleSize.Height = in->getAttributeAsFloat("ParticleHeight"); - - // read emitter - - int emitterIdx = in->findAttribute("Emitter"); - if (emitterIdx == -1) - return; - - if (Emitter) - Emitter->drop(); - Emitter = 0; - - E_PARTICLE_EMITTER_TYPE type = (E_PARTICLE_EMITTER_TYPE) - in->getAttributeAsEnumeration("Emitter", ParticleEmitterTypeNames); - - switch(type) - { - case EPET_POINT: - Emitter = createPointEmitter(); - break; - case EPET_BOX: - Emitter = createBoxEmitter(); - break; - default: - break; - } - - s32 idx = 0; - - if (Emitter) - idx = Emitter->deserializeAttributes(idx, in); - - ++idx; - - // read affectors - - removeAllAffectors(); - s32 cnt = in->getAttributeCount(); - - while(idx < cnt) - { - const char* name = in->getAttributeName(idx); - - if (!name || strcmp("Affector", name)) - return; - - E_PARTICLE_AFFECTOR_TYPE atype = - (E_PARTICLE_AFFECTOR_TYPE)in->getAttributeAsEnumeration(idx, ParticleAffectorTypeNames); - - IParticleAffector* aff = 0; - - switch(atype) - { - case EPAT_FADE_OUT: - aff = createFadeOutParticleAffector(); - break; - case EPAT_GRAVITY: - aff = createGravityAffector(); - break; - case EPAT_NONE: - default: - break; - } - - ++idx; - - if (aff) - { - idx = aff->deserializeAttributes(idx, in, options); - ++idx; - addAffector(aff); - aff->drop(); - } - } -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CParticleSystemSceneNode.h" +#include "os.h" +#include "ISceneManager.h" +#include "ICameraSceneNode.h" +#include "IVideoDriver.h" + +#include "CParticlePointEmitter.h" +#include "CParticleBoxEmitter.h" +#include "CParticleFadeOutAffector.h" +#include "CParticleGravityAffector.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticleSystemSceneNode::CParticleSystemSceneNode(bool createDefaultEmitter, + ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position, const core::vector3df& rotation, + const core::vector3df& scale) + : IParticleSystemSceneNode(parent, mgr, id, position, rotation, scale), + Emitter(0), LastEmitTime(0), ParticlesAreGlobal(true) +{ + #ifdef _DEBUG + setDebugName("CParticleSystemSceneNode"); + #endif + + if (createDefaultEmitter) + { + IParticleEmitter* e = createBoxEmitter(); + setEmitter(e); + e->drop(); + } + + setParticleSize(); +} + + + +//! destructor +CParticleSystemSceneNode::~CParticleSystemSceneNode() +{ + if (Emitter) + Emitter->drop(); + + removeAllAffectors(); +} + + + +//! Sets the particle emitter, which creates the particles. +void CParticleSystemSceneNode::setEmitter(IParticleEmitter* emitter) +{ + if (Emitter) + Emitter->drop(); + + Emitter = emitter; + + if (Emitter) + Emitter->grab(); +} + + + +//! Adds new particle effector to the particle system. +void CParticleSystemSceneNode::addAffector(IParticleAffector* affector) +{ + affector->grab(); + AffectorList.push_back(affector); +} + + + +//! Removes all particle affectors in the particle system. +void CParticleSystemSceneNode::removeAllAffectors() +{ + core::list::Iterator it = AffectorList.begin(); + while (it != AffectorList.end()) + { + (*it)->drop(); + it = AffectorList.erase(it); + } +} + + +//! Returns the material based on the zero based index i. +video::SMaterial& CParticleSystemSceneNode::getMaterial(u32 i) +{ + return Buffer.Material; +} + + + +//! Returns amount of materials used by this scene node. +u32 CParticleSystemSceneNode::getMaterialCount() +{ + return 1; +} + + + +//! Creates a point particle emitter. +IParticleEmitter* CParticleSystemSceneNode::createPointEmitter( + const core::vector3df& direction, u32 minParticlesPerSecond, + u32 maxParticlePerSecond, video::SColor minStartColor, + video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, + s32 maxAngleDegrees) +{ + return new CParticlePointEmitter(direction, minParticlesPerSecond, + maxParticlePerSecond, minStartColor, maxStartColor, + lifeTimeMin, lifeTimeMax, maxAngleDegrees); +} + + +//! Creates a box particle emitter. +IParticleEmitter* CParticleSystemSceneNode::createBoxEmitter( + const core::aabbox3df& box, const core::vector3df& direction, + u32 minParticlesPerSecond, u32 maxParticlePerSecond, + video::SColor minStartColor, video::SColor maxStartColor, + u32 lifeTimeMin, u32 lifeTimeMax, + s32 maxAngleDegrees) +{ + return new CParticleBoxEmitter(box, direction, minParticlesPerSecond, + maxParticlePerSecond, minStartColor, maxStartColor, + lifeTimeMin, lifeTimeMax, maxAngleDegrees); +} + + + +//! Creates a fade out particle affector. +IParticleAffector* CParticleSystemSceneNode::createFadeOutParticleAffector( + video::SColor targetColor, u32 timeNeededToFadeOut) +{ + return new CParticleFadeOutAffector(targetColor, timeNeededToFadeOut); +} + + +//! Creates a gravity affector. +IParticleAffector* CParticleSystemSceneNode::createGravityAffector( + const core::vector3df& gravity, u32 timeForceLost) +{ + return new CParticleGravityAffector(gravity, timeForceLost); +} + + +//! pre render event +void CParticleSystemSceneNode::OnRegisterSceneNode() +{ + doParticleSystem(os::Timer::getTime()); + + if (IsVisible && (Particles.size() != 0)) + { + SceneManager->registerNodeForRendering(this); + ISceneNode::OnRegisterSceneNode(); + } +} + + + +//! render +void CParticleSystemSceneNode::render() +{ + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + ICameraSceneNode* camera = SceneManager->getActiveCamera(); + + if (!camera || !driver) + return; + + +#if 0 + // calculate vectors for letting particles look to camera + core::vector3df view(camera->getTarget() - camera->getAbsolutePosition()); + view.normalize(); + + core::vector3df horizontal = camera->getUpVector().crossProduct(view); + horizontal.normalize(); + horizontal *= 0.5f * ParticleSize.Width; + + core::vector3df vertical = horizontal.crossProduct(view); + vertical.normalize(); + vertical *= 0.5f * ParticleSize.Height; + + view *= -1.0f; + +#else + + const core::matrix4 &m = camera->getViewFrustum()->Matrices [ video::ETS_VIEW ]; + + f32 f; + + f = 0.5f * ParticleSize.Width; + const core::vector3df horizontal ( m[0] * f, m[4] * f, m[8] * f ); + + f = -0.5f * ParticleSize.Height; + const core::vector3df vertical ( m[1] * f, m[5] * f, m[9] * f ); + + const core::vector3df view ( -m[2], -m[6] , -m[10] ); + +#endif + + // reallocate arrays, if they are too small + reallocateBuffers(); + + // create particle vertex data + s32 idx = 0; + for (u32 i=0; isetTransform(video::ETS_WORLD, mat); + + driver->setMaterial(Buffer.Material); + + driver->drawVertexPrimitiveList(Buffer.getVertices(), Particles.size()*4, + Buffer.getIndices(), Particles.size()*2, video::EVT_STANDARD, EPT_TRIANGLES); + + // for debug purposes only: + if (DebugDataVisible) + { + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + video::SMaterial m; + m.Lighting = false; + driver->setMaterial(m); + driver->draw3DBox(Buffer.BoundingBox, video::SColor(0,255,255,255)); + } +} + + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CParticleSystemSceneNode::getBoundingBox() const +{ + return Buffer.getBoundingBox(); +} + + + +void CParticleSystemSceneNode::doParticleSystem(u32 time) +{ + if (LastEmitTime==0) + { + LastEmitTime = time; + return; + } + + u32 now = time; + u32 timediff = time - LastEmitTime; + LastEmitTime = time; + + // run emitter + + if (Emitter && IsVisible) + { + SParticle* array = 0; + s32 newParticles = Emitter->emitt(now, timediff, array); + + if (newParticles && array) + { + s32 j=Particles.size(); + if (newParticles > 16250-j) + newParticles=16250-j; + Particles.set_used(j+newParticles); + for (s32 i=0; i::Iterator ait = AffectorList.begin(); + for (; ait != AffectorList.end(); ++ait) + (*ait)->affect(now, Particles.pointer(), Particles.size()); + + if (ParticlesAreGlobal) + Buffer.BoundingBox.reset(AbsoluteTransformation.getTranslation()); + else + Buffer.BoundingBox.reset(core::vector3df(0,0,0)); + + // animate all particles + f32 scale = (f32)timediff; + + for (s32 i=0; i<(s32)Particles.size();) + { + if (now > Particles[i].endTime) + Particles.erase(i); + else + { + Particles[i].pos += (Particles[i].vector * scale); + Buffer.BoundingBox.addInternalPoint(Particles[i].pos); + ++i; + } + } + + f32 m = ParticleSize.Width > ParticleSize.Height ? ParticleSize.Width : ParticleSize.Height; + m *= 0.5f; + Buffer.BoundingBox.MaxEdge.X += m; + Buffer.BoundingBox.MaxEdge.Y += m; + Buffer.BoundingBox.MaxEdge.Z += m; + + Buffer.BoundingBox.MinEdge.X -= m; + Buffer.BoundingBox.MinEdge.Y -= m; + Buffer.BoundingBox.MinEdge.Z -= m; + + if (ParticlesAreGlobal) + { + core::matrix4 absinv = AbsoluteTransformation; + absinv.makeInverse(); + absinv.transformBox(Buffer.BoundingBox); + } +} + + +//! Sets if the particles should be global. If it is, the particles are affected by +//! the movement of the particle system scene node too, otherwise they completely +//! ignore it. Default is true. +void CParticleSystemSceneNode::setParticlesAreGlobal(bool global) +{ + ParticlesAreGlobal = global; +} + + + +//! Sets the size of all particles. +void CParticleSystemSceneNode::setParticleSize(const core::dimension2d &size) +{ + ParticleSize = size; +} + + +void CParticleSystemSceneNode::reallocateBuffers() +{ + if (Particles.size() * 4 > Buffer.getVertexCount() || + Particles.size() * 6 > Buffer.getIndexCount()) + { + u32 oldSize = Buffer.getVertexCount(); + Buffer.Vertices.set_used(Particles.size() * 4); + + u32 i; + + // fill remaining vertices + for (i=oldSize; iaddBool("GlobalParticles", ParticlesAreGlobal); + out->addFloat("ParticleWidth", ParticleSize.Width); + out->addFloat("ParticleHeight", ParticleSize.Height); + + // write emitter + + E_PARTICLE_EMITTER_TYPE type = EPET_COUNT; + if (Emitter) + type = Emitter->getType(); + + out->addEnum("Emitter", (s32)type, ParticleEmitterTypeNames); + + if (Emitter) + Emitter->serializeAttributes(out, options); + + // write affectors + + E_PARTICLE_AFFECTOR_TYPE atype = EPAT_NONE; + + for (core::list::Iterator it = AffectorList.begin(); + it != AffectorList.end(); ++it) + { + atype = (*it)->getType(); + + out->addEnum("Affector", (s32)atype, ParticleAffectorTypeNames); + + (*it)->serializeAttributes(out); + } + + // add empty affector to make it possible to add further affectors + + if (options && options->Flags & io::EARWF_FOR_EDITOR) + out->addEnum("Affector", EPAT_NONE, ParticleAffectorTypeNames); +} + + +//! Reads attributes of the scene node. +void CParticleSystemSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + IParticleSystemSceneNode::deserializeAttributes(in, options); + + ParticlesAreGlobal = in->getAttributeAsBool("GlobalParticles"); + ParticleSize.Width = in->getAttributeAsFloat("ParticleWidth"); + ParticleSize.Height = in->getAttributeAsFloat("ParticleHeight"); + + // read emitter + + int emitterIdx = in->findAttribute("Emitter"); + if (emitterIdx == -1) + return; + + if (Emitter) + Emitter->drop(); + Emitter = 0; + + E_PARTICLE_EMITTER_TYPE type = (E_PARTICLE_EMITTER_TYPE) + in->getAttributeAsEnumeration("Emitter", ParticleEmitterTypeNames); + + switch(type) + { + case EPET_POINT: + Emitter = createPointEmitter(); + break; + case EPET_BOX: + Emitter = createBoxEmitter(); + break; + default: + break; + } + + s32 idx = 0; + + if (Emitter) + idx = Emitter->deserializeAttributes(idx, in); + + ++idx; + + // read affectors + + removeAllAffectors(); + s32 cnt = in->getAttributeCount(); + + while(idx < cnt) + { + const char* name = in->getAttributeName(idx); + + if (!name || strcmp("Affector", name)) + return; + + E_PARTICLE_AFFECTOR_TYPE atype = + (E_PARTICLE_AFFECTOR_TYPE)in->getAttributeAsEnumeration(idx, ParticleAffectorTypeNames); + + IParticleAffector* aff = 0; + + switch(atype) + { + case EPAT_FADE_OUT: + aff = createFadeOutParticleAffector(); + break; + case EPAT_GRAVITY: + aff = createGravityAffector(); + break; + case EPAT_NONE: + default: + break; + } + + ++idx; + + if (aff) + { + idx = aff->deserializeAttributes(idx, in, options); + ++idx; + addAffector(aff); + aff->drop(); + } + } +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CParticleSystemSceneNode.h b/src/dep/src/irrlicht/CParticleSystemSceneNode.h index fc0dbe3..f4bc281 100644 --- a/src/dep/src/irrlicht/CParticleSystemSceneNode.h +++ b/src/dep/src/irrlicht/CParticleSystemSceneNode.h @@ -1,139 +1,139 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ -#define __C_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ - -#include "IParticleSystemSceneNode.h" -#include "irrArray.h" -#include "irrList.h" -#include "SMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - -//! A particle system scene node. -/** A scene node controlling a particle system. The behavior of the particles -can be controlled by setting the right particle emitters and affectors. -*/ -class CParticleSystemSceneNode : public IParticleSystemSceneNode -{ -public: - - //! constructor - CParticleSystemSceneNode(bool createDefaultEmitter, - ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, - const core::vector3df& rotation, - const core::vector3df& scale); - - //! destructor - virtual ~CParticleSystemSceneNode(); - - //! Sets the particle emitter, which creates the particles. - virtual void setEmitter(IParticleEmitter* emitter); - - //! Adds new particle affector to the particle system. - virtual void addAffector(IParticleAffector* affector); - - //! Removes all particle affectors in the particle system. - virtual void removeAllAffectors(); - - //! Returns the material based on the zero based index i. - virtual video::SMaterial& getMaterial(u32 i); - - //! Returns amount of materials used by this scene node. - virtual u32 getMaterialCount(); - - //! pre render event - virtual void OnRegisterSceneNode(); - - //! render - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! Creates a point particle emitter. - virtual IParticleEmitter* createPointEmitter( - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlePerSecond = 10, - video::SColor minStartColor = video::SColor(255,0,0,0), - video::SColor maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0); - - //! Creates a box particle emitter. - virtual IParticleEmitter* createBoxEmitter( - const core::aabbox3df& box = core::aabbox3d(-10,0,-10,5,30,10), - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlePerSecond = 10, - video::SColor minStartColor = video::SColor(255,0,0,0), - video::SColor maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0); - - //! Creates a fade out particle affector. - virtual IParticleAffector* createFadeOutParticleAffector( - video::SColor targetColor = video::SColor(0,0,0,0), - u32 timeNeededToFadeOut = 1000); - - //! Creates a gravity affector. - virtual IParticleAffector* createGravityAffector( - const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), - u32 timeForceLost = 1000); - - //! Sets the size of all particles. - virtual void setParticleSize( - const core::dimension2d &size = core::dimension2d(5.0f, 5.0f)); - - //! Sets if the particles should be global. If they are, the particles are affected by - //! the movement of the particle system scene node too, otherwise they completely - //! ignore it. Default is true. - virtual void setParticlesAreGlobal(bool global); - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_PARTICLE_SYSTEM; } - -private: - - void doParticleSystem(u32 time); - void reallocateBuffers(); - - core::list AffectorList; - IParticleEmitter* Emitter; - core::array Particles; - core::dimension2d ParticleSize; - u32 LastEmitTime; - s32 MaxParticles; - - SMeshBuffer Buffer; - - enum E_PARTICLES_PRIMITIVE - { - EPP_POINT=0, - EPP_BILLBOARD, - EPP_POINTSPRITE - }; - E_PARTICLES_PRIMITIVE ParticlePrimitive; - - bool ParticlesAreGlobal; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ +#define __C_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ + +#include "IParticleSystemSceneNode.h" +#include "irrArray.h" +#include "irrList.h" +#include "SMeshBuffer.h" + +namespace irr +{ +namespace scene +{ + +//! A particle system scene node. +/** A scene node controlling a particle system. The behavior of the particles +can be controlled by setting the right particle emitters and affectors. +*/ +class CParticleSystemSceneNode : public IParticleSystemSceneNode +{ +public: + + //! constructor + CParticleSystemSceneNode(bool createDefaultEmitter, + ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position, + const core::vector3df& rotation, + const core::vector3df& scale); + + //! destructor + virtual ~CParticleSystemSceneNode(); + + //! Sets the particle emitter, which creates the particles. + virtual void setEmitter(IParticleEmitter* emitter); + + //! Adds new particle affector to the particle system. + virtual void addAffector(IParticleAffector* affector); + + //! Removes all particle affectors in the particle system. + virtual void removeAllAffectors(); + + //! Returns the material based on the zero based index i. + virtual video::SMaterial& getMaterial(u32 i); + + //! Returns amount of materials used by this scene node. + virtual u32 getMaterialCount(); + + //! pre render event + virtual void OnRegisterSceneNode(); + + //! render + virtual void render(); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! Creates a point particle emitter. + virtual IParticleEmitter* createPointEmitter( + const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), + u32 minParticlesPerSecond = 5, + u32 maxParticlePerSecond = 10, + video::SColor minStartColor = video::SColor(255,0,0,0), + video::SColor maxStartColor = video::SColor(255,255,255,255), + u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, + s32 maxAngleDegrees=0); + + //! Creates a box particle emitter. + virtual IParticleEmitter* createBoxEmitter( + const core::aabbox3df& box = core::aabbox3d(-10,0,-10,5,30,10), + const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), + u32 minParticlesPerSecond = 5, + u32 maxParticlePerSecond = 10, + video::SColor minStartColor = video::SColor(255,0,0,0), + video::SColor maxStartColor = video::SColor(255,255,255,255), + u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, + s32 maxAngleDegrees=0); + + //! Creates a fade out particle affector. + virtual IParticleAffector* createFadeOutParticleAffector( + video::SColor targetColor = video::SColor(0,0,0,0), + u32 timeNeededToFadeOut = 1000); + + //! Creates a gravity affector. + virtual IParticleAffector* createGravityAffector( + const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), + u32 timeForceLost = 1000); + + //! Sets the size of all particles. + virtual void setParticleSize( + const core::dimension2d &size = core::dimension2d(5.0f, 5.0f)); + + //! Sets if the particles should be global. If they are, the particles are affected by + //! the movement of the particle system scene node too, otherwise they completely + //! ignore it. Default is true. + virtual void setParticlesAreGlobal(bool global); + + //! Writes attributes of the scene node. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_PARTICLE_SYSTEM; } + +private: + + void doParticleSystem(u32 time); + void reallocateBuffers(); + + core::list AffectorList; + IParticleEmitter* Emitter; + core::array Particles; + core::dimension2d ParticleSize; + u32 LastEmitTime; + s32 MaxParticles; + + SMeshBuffer Buffer; + + enum E_PARTICLES_PRIMITIVE + { + EPP_POINT=0, + EPP_BILLBOARD, + EPP_POINTSPRITE + }; + E_PARTICLES_PRIMITIVE ParticlePrimitive; + + bool ParticlesAreGlobal; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CQ3LevelMesh.cpp b/src/dep/src/irrlicht/CQ3LevelMesh.cpp index 30b8ac7..158c962 100644 --- a/src/dep/src/irrlicht/CQ3LevelMesh.cpp +++ b/src/dep/src/irrlicht/CQ3LevelMesh.cpp @@ -1,1885 +1,1885 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CQ3LevelMesh.h" -#include "ISceneManager.h" -#include "os.h" -#include "SMeshBufferLightMap.h" -#include "irrString.h" -#include "ILightSceneNode.h" -#include "IQ3Shader.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CQ3LevelMesh::CQ3LevelMesh(io::IFileSystem* fs, video::IVideoDriver* driver, scene::ISceneManager* smgr) -: Textures(0), LightMaps(0), - Vertices(0), Faces(0), Planes(0), Nodes(0), Leafs(0), LeafFaces(0), - MeshVerts(0), Brushes(0), Driver(driver), FileSystem(fs), SceneManager ( smgr ) -{ - #ifdef _DEBUG - IUnknown::setDebugName("CQ3LevelMesh"); - #endif - - s32 i; - for ( i = 0; i!= quake3::E_Q3_MESH_SIZE; ++i ) - { - Mesh[i] = 0; - } - - if (Driver) - Driver->grab(); - - if (FileSystem) - FileSystem->grab(); - - // load default shaders - InitShader (); - - -} - - -//! destructor -CQ3LevelMesh::~CQ3LevelMesh() -{ - if (Textures) - delete [] Textures; - - if (LightMaps) - delete [] LightMaps; - - if (Vertices) - delete [] Vertices; - - if (Faces) - delete [] Faces; - - if (Planes) - delete [] Planes; - - if (Nodes) - delete [] Nodes; - - if (Leafs) - delete [] Leafs; - - if (LeafFaces) - delete [] LeafFaces; - - if (MeshVerts) - delete [] MeshVerts; - - if (Brushes) - delete [] Brushes; - - if (Driver) - Driver->drop(); - - if (FileSystem) - FileSystem->drop(); - - s32 i; - for ( i = 0; i!= quake3::E_Q3_MESH_SIZE; ++i ) - { - if (Mesh[i]) - Mesh[i]->drop(); - } - - ReleaseShader (); - ReleaseEntity (); -} - - - -//! loads a level from a .bsp-File. Also tries to load all needed textures. Returns true if successful. -bool CQ3LevelMesh::loadFile(io::IReadFile* file) -{ - if (!file) - return false; - - LevelName = file->getFileName(); - - tBSPHeader header; - file->read(&header, sizeof(tBSPHeader)); - - #ifdef __BIG_ENDIAN__ - header.strID = os::Byteswap::byteswap(header.strID); - header.version = os::Byteswap::byteswap(header.version); - #endif - - if (header.strID != 0x50534249 || header.version != 0x2e) - { - os::Printer::log("Could not load .bsp file, unknown header.", file->getFileName(), ELL_ERROR); - return false; - } - - // now read lumps - - file->read(&Lumps[0], sizeof(tBSPLump)*kMaxLumps); - - #ifdef __BIG_ENDIAN__ - for (int i=0;idrop (); - Mesh [index] = 0; - } -} - -//! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. -IMesh* CQ3LevelMesh::getMesh(s32 frameInMs, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) -{ - return Mesh[ frameInMs ]; -} - - -void CQ3LevelMesh::loadTextures(tBSPLump* l, io::IReadFile* file) -{ - NumTextures = l->length / sizeof(tBSPTexture); - Textures = new tBSPTexture[NumTextures]; - - file->seek(l->offset); - file->read(Textures, l->length); - - #ifdef __BIG_ENDIAN__ - for (int i=0;ilength / sizeof(tBSPLightmap); - LightMaps = new tBSPLightmap[NumLightMaps]; - - file->seek(l->offset); - file->read(LightMaps, l->length); -} - - -void CQ3LevelMesh::loadVerts(tBSPLump* l, io::IReadFile* file) -{ - NumVertices = l->length / sizeof(tBSPVertex); - Vertices = new tBSPVertex[NumVertices]; - - file->seek(l->offset); - file->read(Vertices, l->length); - - #ifdef __BIG_ENDIAN__ - for (int i=0;ilength / sizeof(tBSPFace); - Faces = new tBSPFace[NumFaces]; - - file->seek(l->offset); - file->read(Faces, l->length); - - #ifdef __BIG_ENDIAN__ - for ( u32 i=0;i entity; - entity.set_used ( l->length + 2 ); - entity[l->length + 1 ] = 0; - - file->seek(l->offset); - file->read ( entity.pointer(), l->length); - - parser_parse ( entity.pointer(), l->length, &CQ3LevelMesh::scriptcallback_entity ); -} - -// load shaders named in bsp -void CQ3LevelMesh::loadShaders(tBSPLump* l, io::IReadFile* file) -{ - u32 files = l->length / sizeof(tBSPShader); - - file->seek ( l->offset ); - - tBSPShader def; - for ( u32 i = 0; i!= files; ++i ) - { - file->read ( &def, sizeof ( def ) ); - getShader ( def.strName, 1 ); - } -} - - -void CQ3LevelMesh::loadModels(tBSPLump* l, io::IReadFile* file) -{ - // ignore -} - - -void CQ3LevelMesh::loadMeshVerts(tBSPLump* l, io::IReadFile* file) -{ - NumMeshVerts = l->length / sizeof(s32); - MeshVerts = new s32[NumMeshVerts]; - - file->seek(l->offset); - file->read(MeshVerts, l->length); - - #ifdef __BIG_ENDIAN__ - for (int i=0;i= Parser.sourcesize ) - { - Parser.tokenresult = Q3_TOKEN_EOF; - return; - } - - symbol = Parser.source [ Parser.index ]; - Parser.index += 1; - } while ( isQ3WhiteSpace ( symbol ) ); - - // first symbol, one symbol - switch ( symbol ) - { - case 0: - Parser.tokenresult = Q3_TOKEN_EOF; - return; - - case '/': - // comment or divide - if ( Parser.index >= Parser.sourcesize ) - { - Parser.tokenresult = Q3_TOKEN_EOF; - return; - } - symbol = Parser.source [ Parser.index ]; - Parser.index += 1; - if ( isQ3WhiteSpace ( symbol ) ) - { - Parser.tokenresult = Q3_TOKEN_MATH_DIVIDE; - return; - } - else - if ( symbol == '*' ) - { - // C-style comment in quake? - } - else - if ( symbol == '/' ) - { - // skip to eol - do - { - if ( Parser.index >= Parser.sourcesize ) - { - Parser.tokenresult = Q3_TOKEN_EOF; - return; - } - symbol = Parser.source [ Parser.index ]; - Parser.index += 1; - } while ( symbol != '\n' ); - Parser.tokenresult = Q3_TOKEN_COMMENT; - return; - } - // take /[name] as valid token..?!?!?. mhmm, maybe - break; - - case '\n': - Parser.tokenresult = Q3_TOKEN_EOL; - return; - case '{': - Parser.tokenresult = Q3_TOKEN_START_LIST; - return; - case '}': - Parser.tokenresult = Q3_TOKEN_END_LIST; - return; - - case '"': - // string literal - do - { - if ( Parser.index >= Parser.sourcesize ) - { - Parser.tokenresult = Q3_TOKEN_EOF; - return; - } - symbol = Parser.source [ Parser.index ]; - Parser.index += 1; - if ( symbol != '"' ) - Parser.token.append ( symbol ); - } while ( symbol != '"' ); - Parser.tokenresult = Q3_TOKEN_ENTITY; - return; - } - - - // user identity - Parser.token.append ( symbol ); - - // continue till whitespace - bool notisWhite = true; - do - { - if ( Parser.index >= Parser.sourcesize ) - { - Parser.tokenresult = Q3_TOKEN_EOF; - return; - } - symbol = Parser.source [ Parser.index ]; - - notisWhite = ! isQ3WhiteSpace ( symbol ); - if ( notisWhite ) - { - Parser.token.append ( symbol ); - } - - Parser.index += 1; - - } while ( notisWhite ); - - Parser.tokenresult = Q3_TOKEN_TOKEN; - return; -} - -/* - parse entity & shader - calls callback on content in {} -*/ -void CQ3LevelMesh::parser_parse ( const void * data, const u32 size, CQ3LevelMesh::tParserCallback callback ) -{ - Parser.source = (const c8*) data; - Parser.sourcesize = size; - Parser.index = 0; - - quake3::SVarGroupList *groupList; - - s32 active; - s32 last; - - quake3::SVariable entity; - - groupList = new quake3::SVarGroupList (); - - groupList->VariableGroup.push_back ( quake3::SVarGroup () ); - active = last = 0; - - do - { - parser_nextToken (); - - switch ( Parser.tokenresult ) - { - case Q3_TOKEN_START_LIST: - { - //stack = core::min_ ( stack + 1, 7 ); - - groupList->VariableGroup.push_back ( quake3::SVarGroup () ); - last = active; - active = groupList->VariableGroup.size() - 1; - entity.clear (); - } break; - - // a unregisterd variable is finished - case Q3_TOKEN_EOL: - { - if ( entity.isValid() ) - { - groupList->VariableGroup[active].Variable.push_back ( entity ); - entity.clear (); - } - } break; - - case Q3_TOKEN_TOKEN: - case Q3_TOKEN_ENTITY: - { - Parser.token.make_lower(); - - // store content based on line-delemiter - if ( 0 == entity.isValid() ) - { - entity.name = Parser.token; - entity.content = ""; - - } - else - { - if ( entity.content.size() ) - { - entity.content += " "; - } - entity.content += Parser.token; - } - } break; - - case Q3_TOKEN_END_LIST: - { - //stack = core::max_ ( stack - 1, 0 ); - - // close tag for first - if ( active == 1 ) - { - (this->*callback) ( groupList ); - - // new group - groupList->drop (); - groupList = new quake3::SVarGroupList (); - groupList->VariableGroup.push_back ( quake3::SVarGroup () ); - last = 0; - } - - active = last; - entity.clear(); - - } break; - - } - - } while ( Parser.tokenresult != Q3_TOKEN_EOF ); - - groupList->drop (); -} - - - -/* - this loader applies only textures for stage 1 & 2 -*/ -s32 CQ3LevelMesh::setShaderMaterial ( video::SMaterial &material, const tBSPFace * face ) const -{ - material.MaterialType = video::EMT_SOLID; - material.Wireframe = false; - material.Lighting = false; - material.BilinearFilter = true; - material.BackfaceCulling = true; - material.Textures[0] = 0; - material.Textures[1] = 0; - material.Textures[2] = 0; - material.Textures[3] = 0; - material.ZBuffer = true; - material.ZWriteEnable = true; - material.MaterialTypeParam = 0.f; - - s32 shaderState = -1; - - if ( face->textureID >= 0 ) - { - material.Textures[0] = Tex [ face->textureID ].Texture; - shaderState = Tex [ face->textureID ].ShaderID; - } - - if ( face->lightmapID >= 0 ) - { - material.Textures[1] = Lightmap [ face->lightmapID ]; - material.MaterialType = quake3::defaultLightMap; - } - - // store shader ID - material.MaterialTypeParam2 = (f32) shaderState; - - const quake3::SShader *shader = getShader ( shaderState ); - if ( 0 == shader ) - return shaderState; - - - const quake3::SVarGroup *group; - - s32 index; - - // generic - group = shader->getGroup ( 1 ); - if ( group ) - { - material.BackfaceCulling = quake3::getBackfaceCulling ( group->get ( "cull" ) ); - - if ( group->isDefined ( "surfaceparm", "nolightmap" ) ) - { - material.MaterialType = video::EMT_SOLID; - material.Textures[1] = 0; - } - - } - - // try to get the best of the 8 texture stages.. - - // texture 1, texture 2 - u32 startPos; - for ( s32 g = 2; g <= 3; ++g ) - { - group = shader->getGroup ( g ); - if ( 0 == group ) - continue; - - startPos = 0; - - - index = group->getIndex ( "depthwrite" ); - if ( index >= 0 ) - { - material.ZBuffer = true; - } - - quake3::SBlendFunc blendfunc; - quake3::getBlendFunc ( group->get ( "blendfunc" ), blendfunc ); - quake3::getBlendFunc ( group->get ( "alphafunc" ), blendfunc ); - - material.MaterialType = blendfunc.type; - material.MaterialTypeParam = blendfunc.param; - - // try if we can match better - shaderState |= (material.MaterialType == video::EMT_SOLID ) ? 0x00020000 : 0; - - } - - - //material.BackfaceCulling = false; - - if ( shader->VarGroup->VariableGroup.size () <= 4 ) - { - shaderState |= 0x00010000; - } - - material.MaterialTypeParam2 = (f32) shaderState; - return shaderState; -} - -//! constructs a mesh from the quake 3 level file. -void CQ3LevelMesh::constructMesh2() -{ - s32 i, j, k; - - s32 *index; - - video::S3DVertex2TCoords temp[3]; - - video::SMaterial material; - - SToBuffer item; - - core::array < SToBuffer > toBuffer; - - const s32 mesh0size = (NumTextures+1) * (NumLightMaps+1); - for ( i=0; i < mesh0size; ++i) - { - scene::SMeshBufferLightMap* buffer = new scene::SMeshBufferLightMap(); - - Mesh[quake3::E_Q3_MESH_GEOMETRY]->addMeshBuffer(buffer); - buffer->drop(); - } - - for ( i=0; i NumLightMaps-1) - { - Faces[i].lightmapID = -1; - } - - // there are lightmapsids and textureid with -1 - s32 index = ((Faces[i].lightmapID+1) * (NumTextures+1)) + (Faces[i].textureID+1); - buffer = (SMeshBufferLightMap*) Mesh[quake3::E_Q3_MESH_GEOMETRY]->getMeshBuffer(index); - buffer->getMaterial() = material; - } - else - { - buffer = (SMeshBufferLightMap*) Mesh[ toBuffer[g].index ]->getMeshBuffer ( material ); - //buffer = 0; - if ( 0 == buffer ) - { - buffer = new scene::SMeshBufferLightMap(); - Mesh[ toBuffer[g].index ]->addMeshBuffer ( buffer ); - buffer->drop (); - buffer->getMaterial() = material; - } - } - - - switch(Faces[i].type) - { - case 4: // billboards - break; - case 2: // patches - createCurvedSurface2(buffer, i, PatchTesselation,toBuffer[g].takeVertexColor); - break; - - case 1: // normal polygons - case 3: // mesh vertices - - index = MeshVerts + face->meshVertIndex; - k = buffer->getVertexCount(); - - for ( j = 0; j < face->numMeshVerts; j += 1 ) - { - buffer->Indices.push_back( k + index [j] ); - } - - for ( j = 0; j != face->numOfVerts; ++j ) - { - copy ( &temp[0], &Vertices[ j + face->vertexIndex ], toBuffer[g].takeVertexColor ); - buffer->Vertices.push_back( temp[0] ); - } - break; - - } // end switch - } - } - - -} - -//! constructs a mesh from the quake 3 level file. -void CQ3LevelMesh::constructMesh() -{ - // reserve buffer. - s32 i; // new ISO for scoping problem with some compilers - - for (i=0; i<(NumTextures+1) * (NumLightMaps+1); ++i) - { - scene::SMeshBufferLightMap* buffer = new scene::SMeshBufferLightMap(); - - buffer->Material.MaterialType = video::EMT_LIGHTMAP_M4; - buffer->Material.Wireframe = false; - buffer->Material.Lighting = false; - buffer->Material.BilinearFilter = true; - - Mesh[0]->addMeshBuffer(buffer); - - buffer->drop(); - } - - // go through all faces and add them to the buffer. - - video::S3DVertex2TCoords temp[3]; - - for (i=0; i NumLightMaps-1) - Faces[i].lightmapID = -1; - - // there are lightmapsids and textureid with -1 - s32 meshBufferIndex = ((Faces[i].lightmapID+1) * (NumTextures+1)) + (Faces[i].textureID+1); - SMeshBufferLightMap* meshBuffer = ((SMeshBufferLightMap*)Mesh[0]->getMeshBuffer(meshBufferIndex)); - - switch(Faces[i].type) - { - //case 3: // mesh vertices - case 1: // normal polygons - { - for (s32 tf=0; tfgetVertexCount(); - s32 vidxes[3]; - - vidxes[0] = MeshVerts[Faces[i].meshVertIndex + tf +0] - + Faces[i].vertexIndex; - vidxes[1] = MeshVerts[Faces[i].meshVertIndex + tf +1] - + Faces[i].vertexIndex; - vidxes[2] = MeshVerts[Faces[i].meshVertIndex + tf +2] - + Faces[i].vertexIndex; - - // add all three vertices - copy ( &temp[0], &Vertices[ vidxes[0] ], 0 ); - copy ( &temp[1], &Vertices[ vidxes[1] ], 0 ); - copy ( &temp[2], &Vertices[ vidxes[2] ], 0 ); - - meshBuffer->Vertices.push_back( temp[0] ); - meshBuffer->Vertices.push_back( temp[1] ); - meshBuffer->Vertices.push_back( temp[2] ); - - // add indexes - - meshBuffer->Indices.push_back(idx); - meshBuffer->Indices.push_back(idx+1); - meshBuffer->Indices.push_back(idx+2); - } - } - break; - case 2: // curved surfaces - createCurvedSurface(meshBuffer, i); - break; - - case 4: // billboards - break; - } // end switch - } - -} - -// helper method for creating curved surfaces, sent in by Dean P. Macri. -inline f32 CQ3LevelMesh::Blend( const f64 s[3], const f64 t[3], const tBSPVertex *v[9], int offset) -{ - f64 res = 0.0; - f32 *ptr; - - for( int i=0; i<3; i++ ) - for( int j=0; j<3; j++ ) - { - ptr = (f32 *)( (char*)v[i*3+j] + offset ); - res += s[i] * t[j] * (*ptr); - } - - return (f32) res; -} - -//!helper function -inline s32 s32_min ( s32 a, s32 b) -{ - s32 mask = (a - b) >> 31; - return (a & mask) | (b & ~mask); -} - -void CQ3LevelMesh::S3DVertex2TCoords_64::copyto ( video::S3DVertex2TCoords &dest ) const -{ - dest.Pos.X = core::round ( (f32) Pos.X ); - dest.Pos.Y = core::round ( (f32) Pos.Y ); - dest.Pos.Z = core::round ( (f32) Pos.Z ); - //dest.Pos.X = (f32) Pos.X; - //dest.Pos.Y = (f32) Pos.Y; - //dest.Pos.Z = (f32) Pos.Z; - - dest.Normal.X = (f32) Normal.X; - dest.Normal.Y = (f32) Normal.Y; - dest.Normal.Z = (f32) Normal.Z; - dest.Normal.normalize(); - - dest.Color = Color.toSColor(); - - dest.TCoords.X = (f32) TCoords.X; - dest.TCoords.Y = (f32) TCoords.Y; - - dest.TCoords2.X = (f32) TCoords2.X; - dest.TCoords2.Y = (f32) TCoords2.Y; -} - - -void CQ3LevelMesh::copy ( S3DVertex2TCoords_64 * dest, const tBSPVertex * source, s32 vertexcolor ) const -{ - //dest->Pos.X = core::round ( source->vPosition[0] ); - //dest->Pos.Y = core::round ( source->vPosition[2] ); - //dest->Pos.Z = core::round ( source->vPosition[1] ); - dest->Pos.X = source->vPosition[0]; - dest->Pos.Y = source->vPosition[2]; - dest->Pos.Z = source->vPosition[1]; - - dest->Normal.X = source->vNormal[0]; - dest->Normal.Y = source->vNormal[2]; - dest->Normal.Z = source->vNormal[1]; - dest->Normal.normalize (); - - dest->TCoords.X = source->vTextureCoord[0]; - dest->TCoords.Y = source->vTextureCoord[1]; - dest->TCoords2.X = source->vLightmapCoord[0]; - dest->TCoords2.Y = source->vLightmapCoord[1]; - - if ( vertexcolor ) - { - u32 a = s32_min ( source->color[3] * quake3::defaultModulate, 255 ); - u32 r = s32_min ( source->color[0] * quake3::defaultModulate, 255 ); - u32 g = s32_min ( source->color[1] * quake3::defaultModulate, 255 ); - u32 b = s32_min ( source->color[2] * quake3::defaultModulate, 255 ); - - dest->Color.set ( a * 1.f/255.f, - r * 1.f/255.f, - g * 1.f/255.f, - b * 1.f/255.f - ); - } - else - { - dest->Color.set ( 1.f, 1.f, 1.f, 1.f ); - } - -} - - -inline void CQ3LevelMesh::copy ( video::S3DVertex2TCoords * dest, const tBSPVertex * source, s32 vertexcolor ) const -{ - dest->Pos.X = core::round ( source->vPosition[0] ); - dest->Pos.Y = core::round ( source->vPosition[2] ); - dest->Pos.Z = core::round ( source->vPosition[1] ); - - //dest->Pos.X = source->vPosition[0]; - //dest->Pos.Y = source->vPosition[2]; - //dest->Pos.Z = source->vPosition[1]; - - dest->Normal.X = source->vNormal[0]; - dest->Normal.Y = source->vNormal[2]; - dest->Normal.Z = source->vNormal[1]; - dest->Normal.normalize(); - - dest->TCoords.X = source->vTextureCoord[0]; - dest->TCoords.Y = source->vTextureCoord[1]; - dest->TCoords2.X = source->vLightmapCoord[0]; - dest->TCoords2.Y = source->vLightmapCoord[1]; - - if ( vertexcolor ) - { - u32 a = s32_min ( source->color[3] * quake3::defaultModulate, 255 ); - u32 r = s32_min ( source->color[0] * quake3::defaultModulate, 255 ); - u32 g = s32_min ( source->color[1] * quake3::defaultModulate, 255 ); - u32 b = s32_min ( source->color[2] * quake3::defaultModulate, 255 ); - - dest->Color.color = a << 24 | r << 16 | g << 8 | b; - } - else - { - dest->Color.color = 0xFFFFFFFF; - } -} - -void CQ3LevelMesh::SBezier::tesselate ( s32 level ) -{ - //Calculate how many vertices across/down there are - s32 j, k; - - u32 idx = Patch->Vertices.size(); - - column[0].set_used ( level + 1 ); - column[1].set_used ( level + 1 ); - column[2].set_used ( level + 1 ); - - const f64 w = 0.0 + core::reciprocal ( (f32) level ); - - //Tesselate along the columns - for( j = 0; j <= level; ++j) - { - const f64 f = w * (f64) j; - - column[0][j] = control[0].getInterpolated_quadratic(control[3], control[6], f ); - column[1][j] = control[1].getInterpolated_quadratic(control[4], control[7], f ); - column[2][j] = control[2].getInterpolated_quadratic(control[5], control[8], f ); - } - - //Tesselate across the rows to get final vertices - video::S3DVertex2TCoords v; - S3DVertex2TCoords_64 f; - for( j = 0; j <= level; ++j) - { - for( k = 0; k <= level; ++k) - { - f = column[0][j].getInterpolated_quadratic( column[1][j], column[2][j], w * (f64) k ); - f.copyto ( v ); - Patch->Vertices.push_back ( v ); - } - } - - // connect - for( j = 0; j < level; ++j) - { - for( k = 0; k < level; ++k) - { - const s32 inx = idx + ( k * ( level + 1 ) ) + j; - - Patch->Indices.push_back ( inx + 0 ); - Patch->Indices.push_back ( inx + (level + 1 ) + 0 ); - Patch->Indices.push_back ( inx + (level + 1 ) + 1 ); - - Patch->Indices.push_back ( inx + 0 ); - Patch->Indices.push_back ( inx + (level + 1 ) + 1 ); - Patch->Indices.push_back ( inx + 1 ); - } - } -} - - -/*! - no subdivision -*/ -void CQ3LevelMesh::createCurvedSurface3 ( SMeshBufferLightMap* meshBuffer, - s32 faceIndex, - s32 patchTesselation, - s32 storevertexcolor - ) -{ - tBSPFace * face = &Faces[faceIndex]; - u32 j,k,m; - - // number of control points across & up - const u32 controlWidth = face->size[0]; - const u32 controlHeight = face->size[1]; - - video::S3DVertex2TCoords v; - - m = meshBuffer->Vertices.size (); - for ( j = 0; j!= controlHeight * controlWidth; ++j ) - { - copy ( &v, &Vertices [ face->vertexIndex + j ], storevertexcolor ); - meshBuffer->Vertices.push_back ( v ); - } - - for ( j = 0; j!= controlHeight - 1; ++j ) - { - for ( k = 0; k!= controlWidth - 1; ++k ) - { - meshBuffer->Indices.push_back ( m + k + 0 ); - meshBuffer->Indices.push_back ( m + k + controlWidth + 0 ); - meshBuffer->Indices.push_back ( m + k + controlWidth + 1 ); - - meshBuffer->Indices.push_back ( m + k + 0 ); - meshBuffer->Indices.push_back ( m + k + controlWidth + 1 ); - meshBuffer->Indices.push_back ( m + k + 1 ); - } - m += controlWidth; - } -} - -/*! -*/ -void CQ3LevelMesh::createCurvedSurface2 ( SMeshBufferLightMap* meshBuffer, - s32 faceIndex, - s32 patchTesselation, - s32 storevertexcolor - ) -{ - tBSPFace * face = &Faces[faceIndex]; - u32 j,k; - - // number of control points across & up - const u32 controlWidth = face->size[0]; - const u32 controlHeight = face->size[1]; - - - // number of biquadratic patches - const u32 biquadWidth = (controlWidth - 1)/2; - const u32 biquadHeight = (controlHeight -1)/2; - - - // Create space for a temporary array of the patch's control points - core::array controlPoint; - controlPoint.set_used ( controlWidth * controlHeight ); - - for( j = 0; j < controlPoint.size(); ++j) - { - copy ( &controlPoint[j], &Vertices [ face->vertexIndex + j ], storevertexcolor ); - } - - // create a temporary patch - Bezier.Patch = new scene::SMeshBufferLightMap(); - - //Loop through the biquadratic patches - for( j = 0; j < biquadHeight; ++j) - { - for( k = 0; k < biquadWidth; ++k) - { - // set up this patch - const s32 inx = j*controlWidth*2 + k*2; - - // setup bezier control points for this patch - Bezier.control[0] = controlPoint[ inx + 0]; - Bezier.control[1] = controlPoint[ inx + 1]; - Bezier.control[2] = controlPoint[ inx + 2]; - Bezier.control[3] = controlPoint[ inx + controlWidth + 0 ]; - Bezier.control[4] = controlPoint[ inx + controlWidth + 1 ]; - Bezier.control[5] = controlPoint[ inx + controlWidth + 2 ]; - Bezier.control[6] = controlPoint[ inx + controlWidth * 2 + 0]; - Bezier.control[7] = controlPoint[ inx + controlWidth * 2 + 1]; - Bezier.control[8] = controlPoint[ inx + controlWidth * 2 + 2]; - - Bezier.tesselate ( patchTesselation ); - } - } - - - // stitch together with existing geometry - // TODO: only border needs to be checked - const u32 bsize = Bezier.Patch->getVertexCount(); - const u32 msize = meshBuffer->getVertexCount(); -/* - for ( j = 0; j!= bsize; ++j ) - { - const core::vector3df &v = Bezier.Patch->Vertices[j].Pos; - - for ( k = 0; k!= msize; ++k ) - { - const core::vector3df &m = meshBuffer->Vertices[k].Pos; - - if ( !v.equals ( m, tolerance ) ) - continue; - - meshBuffer->Vertices[k].Pos = v; - //Bezier.Patch->Vertices[j].Pos = m; - } - } -*/ - - - // add Patch to meshbuffer - for ( j = 0; j!= bsize; ++j ) - { - meshBuffer->Vertices.push_back ( Bezier.Patch->Vertices[j] ); - } - - // add indices to meshbuffer - for ( j = 0; j!= Bezier.Patch->getIndexCount(); ++j ) - { - meshBuffer->Indices.push_back ( msize + Bezier.Patch->Indices[j] ); - } - - delete Bezier.Patch; - -} - -void CQ3LevelMesh::createCurvedSurface(SMeshBufferLightMap* meshBuffer, s32 i) -{ - // this implementation for loading curved surfaces was - // sent in by Dean P. Macri. It was a little bit modified - // by me afterwards. - s32 idx; - s32 cpidx[9]; - - const tBSPVertex *v[9]; - video::S3DVertex2TCoords currentVertex[4]; - - for( s32 row=0; rowgetVertexCount(); - ct[0] = (1.0-t)*(1.0-t); - ct[1] = 2.0 * (1.0 - t) * t; - ct[2] = t * t; - nxt[0] = (1.0-t-tstep)*(1.0-t-tstep); - nxt[1] = 2.0 * (1.0 - t - tstep) * (t+tstep); - nxt[2] = (t+tstep) * (t+tstep); - - // Vert 1 - currentVertex[0].Color.set(255,255,255,255); - currentVertex[0].Pos.X = floorf( Blend( cs, ct, v, (char*)&v[0]->vPosition[0] - (char*)v[0])+ 0.5f); - currentVertex[0].Pos.Y = floorf( Blend( cs, ct, v, (char*)&v[0]->vPosition[2] - (char*)v[0])+ 0.5f); - currentVertex[0].Pos.Z = floorf( Blend( cs, ct, v, (char*)&v[0]->vPosition[1] - (char*)v[0])+ 0.5f); - currentVertex[0].Normal.X = Blend( cs, ct, v, (char*)&v[0]->vNormal[0] - (char*)v[0]); - currentVertex[0].Normal.Y = Blend( cs, ct, v, (char*)&v[0]->vNormal[2] - (char*)v[0]); - currentVertex[0].Normal.Z = Blend( cs, ct, v, (char*)&v[0]->vNormal[1] - (char*)v[0]); - currentVertex[0].TCoords.X = Blend( cs, ct, v, (char*)&v[0]->vTextureCoord[0] - (char*)v[0]); - currentVertex[0].TCoords.Y = Blend( cs, ct, v, (char*)&v[0]->vTextureCoord[1] - (char*)v[0]); - currentVertex[0].TCoords2.X = Blend( cs, ct, v, (char*)&v[0]->vLightmapCoord[0] - (char*)v[0]); - currentVertex[0].TCoords2.Y = Blend( cs, ct, v, (char*)&v[0]->vLightmapCoord[1] - (char*)v[0]); - // Vert 2 - currentVertex[1].Color.set(255,255,255,255); - currentVertex[1].Pos.X = floorf( Blend( cs, nxt, v, (char*)&v[0]->vPosition[0] - (char*)v[0])+ 0.5f); - currentVertex[1].Pos.Y = floorf( Blend( cs, nxt, v, (char*)&v[0]->vPosition[2] - (char*)v[0])+ 0.5f); - currentVertex[1].Pos.Z = floorf( Blend( cs, nxt, v, (char*)&v[0]->vPosition[1] - (char*)v[0])+ 0.5f); - currentVertex[1].Normal.X = Blend( cs, nxt, v, (char*)&v[0]->vNormal[0] - (char*)v[0]); - currentVertex[1].Normal.Y = Blend( cs, nxt, v, (char*)&v[0]->vNormal[2] - (char*)v[0]); - currentVertex[1].Normal.Z = Blend( cs, nxt, v, (char*)&v[0]->vNormal[1] - (char*)v[0]); - currentVertex[1].TCoords.X = Blend( cs, nxt, v, (char*)&v[0]->vTextureCoord[0] - (char*)v[0]); - currentVertex[1].TCoords.Y = Blend( cs, nxt, v, (char*)&v[0]->vTextureCoord[1] - (char*)v[0]); - currentVertex[1].TCoords2.X = Blend( cs, nxt, v, (char*)&v[0]->vLightmapCoord[0] - (char*)v[0]); - currentVertex[1].TCoords2.Y = Blend( cs, nxt, v, (char*)&v[0]->vLightmapCoord[1] - (char*)v[0]); - // Vert 3 - currentVertex[2].Color.set(255,255,255,255); - currentVertex[2].Pos.X = floorf( Blend( nxs, ct, v, (char*)&v[0]->vPosition[0] - (char*)v[0])+ 0.5f); - currentVertex[2].Pos.Y = floorf( Blend( nxs, ct, v, (char*)&v[0]->vPosition[2] - (char*)v[0])+ 0.5f); - currentVertex[2].Pos.Z = floorf( Blend( nxs, ct, v, (char*)&v[0]->vPosition[1] - (char*)v[0])+ 0.5f); - currentVertex[2].Normal.X = Blend( nxs, ct, v, (char*)&v[0]->vNormal[0] - (char*)v[0]); - currentVertex[2].Normal.Y = Blend( nxs, ct, v, (char*)&v[0]->vNormal[2] - (char*)v[0]); - currentVertex[2].Normal.Z = Blend( nxs, ct, v, (char*)&v[0]->vNormal[1] - (char*)v[0]); - currentVertex[2].TCoords.X = Blend( nxs, ct, v, (char*)&v[0]->vTextureCoord[0] - (char*)v[0]); - currentVertex[2].TCoords.Y = Blend( nxs, ct, v, (char*)&v[0]->vTextureCoord[1] - (char*)v[0]); - currentVertex[2].TCoords2.X = Blend( nxs, ct, v, (char*)&v[0]->vLightmapCoord[0] - (char*)v[0]); - currentVertex[2].TCoords2.Y = Blend( nxs, ct, v, (char*)&v[0]->vLightmapCoord[1] - (char*)v[0]); - // Vert 4 - currentVertex[3].Color.set(255,255,255,255); - currentVertex[3].Pos.X = floorf(Blend( nxs, nxt, v, (char*)&v[0]->vPosition[0] - (char*)v[0])+ 0.5f); - currentVertex[3].Pos.Y = floorf(Blend( nxs, nxt, v, (char*)&v[0]->vPosition[2] - (char*)v[0])+ 0.5f); - currentVertex[3].Pos.Z = floorf(Blend( nxs, nxt, v, (char*)&v[0]->vPosition[1] - (char*)v[0])+ 0.5f); - currentVertex[3].Normal.X = Blend( nxs, nxt, v, (char*)&v[0]->vNormal[0] - (char*)v[0]); - currentVertex[3].Normal.Y = Blend( nxs, nxt, v, (char*)&v[0]->vNormal[2] - (char*)v[0]); - currentVertex[3].Normal.Z = Blend( nxs, nxt, v, (char*)&v[0]->vNormal[1] - (char*)v[0]); - currentVertex[3].TCoords.X = Blend( nxs, nxt, v, (char*)&v[0]->vTextureCoord[0] - (char*)v[0]); - currentVertex[3].TCoords.Y = Blend( nxs, nxt, v, (char*)&v[0]->vTextureCoord[1] - (char*)v[0]); - currentVertex[3].TCoords2.X = Blend( nxs, nxt, v, (char*)&v[0]->vLightmapCoord[0] - (char*)v[0]); - currentVertex[3].TCoords2.Y = Blend( nxs, nxt, v, (char*)&v[0]->vLightmapCoord[1] - (char*)v[0]); - // Put the vertices in the mesh buffer - meshBuffer->Vertices.push_back(currentVertex[0]); - meshBuffer->Vertices.push_back(currentVertex[2]); - meshBuffer->Vertices.push_back(currentVertex[1]); - - meshBuffer->Vertices.push_back(currentVertex[1]); - meshBuffer->Vertices.push_back(currentVertex[2]); - meshBuffer->Vertices.push_back(currentVertex[3]); - - // add indexes - meshBuffer->Indices.push_back(idx); - meshBuffer->Indices.push_back(idx+1); - meshBuffer->Indices.push_back(idx+2); - // add indexes - meshBuffer->Indices.push_back(idx+3); - meshBuffer->Indices.push_back(idx+4); - meshBuffer->Indices.push_back(idx+5); - } - } - } - } -} - -//! get's an interface to the entities -const quake3::tQ3EntityList & CQ3LevelMesh::getEntityList () -{ - Entity.sort(); - return Entity; -} - - -/*! -*/ -const quake3::SShader * CQ3LevelMesh::getShader ( u32 index ) const -{ - index &= 0xFFFF; - - if ( index < Shader.size () ) - { - return &Shader[index]; - } - - return 0; -} - -//! loads the shader definition -// either from file ( we assume /scripts on fileNameIsValid == 0 ) -const quake3::SShader * CQ3LevelMesh::getShader ( const c8 * filename, s32 fileNameIsValid ) -{ - quake3::SShader search; - search.name = filename; - - s32 index; - - //! is Shader already in cache? - index = Shader.linear_search ( search ); - if ( index >= 0 ) - { - return &Shader[index]; - } - - core::stringc loadFile; - - if ( 0 == fileNameIsValid ) - { - // extract the shader name from the last path component in filename - // "scripts/[name].shader" - core::stringc cut ( filename ); - - s32 end = cut.findLast ( '/' ); - s32 start = cut.findLast ( '/', end - 1 ); - - loadFile = "scripts"; - loadFile.append ( cut.subString ( start, end - start ) ); - loadFile.append ( ".shader" ); - } - else - { - loadFile = filename; - } - - // already loaded the file ? - index = ShaderFile.binary_search ( loadFile ); - if ( index >= 0 ) - return 0; - -#if 0 - core::stringc message; - message = loadFile + " for " + core::stringc ( filename ); - os::Printer::log("Q3: Loading shader file ", message.c_str(), ELL_INFORMATION); - io::IReadFile *file = FileSystem->createAndOpenFile ( loadFile.c_str () ); - if ( 0 == file ) - { - os::Printer::log("Q3: could not load shader ", loadFile.c_str(), ELL_INFORMATION); - return 0; - } -#endif - - if ( !FileSystem->existFile ( loadFile.c_str () ) ) - return 0; - - io::IReadFile *file = FileSystem->createAndOpenFile ( loadFile.c_str () ); - if ( 0 == file ) - return 0; - - core::stringc message; - message = loadFile + " for " + core::stringc ( filename ); - os::Printer::log("Loaded shader", message.c_str(), ELL_INFORMATION); - - // add file to loaded files - ShaderFile.push_back ( loadFile ); - - // load script - core::array script; - u32 len = file->getSize (); - - script.set_used ( len + 2 ); - script[ len + 1 ] = 0; - - file->seek( 0 ); - file->read ( script.pointer(), len ); - file->drop (); - - // start a parser instance - parser_parse ( script.pointer(), len, &CQ3LevelMesh::scriptcallback_shader ); - - // search again - index = Shader.linear_search ( search ); - if ( index >= 0 ) - return &Shader[index]; - - return 0; -} - -//! adding default shaders -void CQ3LevelMesh::InitShader () -{ - ReleaseShader (); - - quake3::SShader element; - - quake3::SVarGroup group; - quake3::SVariable variable; - - variable.name = "noshader"; - group.Variable.push_back ( variable ); - - element.VarGroup = new quake3::SVarGroupList (); - element.VarGroup->VariableGroup.push_back ( group ); - element.name = element.VarGroup->VariableGroup[0].Variable[0].name.c_str (); - Shader.push_back ( element ); - - // load common named shader - getShader ( "scripts/common.shader", 1 ); -} - -//!. script callback for shaders -//! i'm having troubles with the reference counting, during callback.. resorting.. -void CQ3LevelMesh::ReleaseShader () -{ - for ( u32 i = 0; i!= Shader.size(); ++i ) - { - Shader[i].VarGroup->drop (); - } - Shader.clear (); - ShaderFile.clear(); -} - -void CQ3LevelMesh::ReleaseEntity () -{ - for ( u32 i = 0; i!= Entity.size(); ++i ) - { - Entity[i].VarGroup->drop (); - } - Entity.clear (); - -} - - -// entity only has only one valid level.. and no assoziative name.. -void CQ3LevelMesh::scriptcallback_entity ( quake3::SVarGroupList *& grouplist ) -{ - quake3::SEntity element; - - if ( grouplist->VariableGroup.size () != 2 ) - return; - - - element.name = grouplist->VariableGroup[1].get ( "classname" ); - - grouplist->grab (); - element.VarGroup = grouplist; - element.id = Shader.size(); - - Entity.push_back ( element ); -} - - -//!. script callback for shaders -void CQ3LevelMesh::scriptcallback_shader ( quake3::SVarGroupList *& grouplist ) -{ - quake3::SShader element; - - grouplist->grab (); - - element.VarGroup = grouplist; - element.name = element.VarGroup->VariableGroup[0].Variable[0].name.c_str (); - element.id = Shader.size(); - - Shader.push_back ( element ); -} - - -//! loads the textures -void CQ3LevelMesh::loadTextures() -{ - if (!Driver) - return; - - core::stringc s; - core::stringc extensions[2]; - extensions[0] = ".jpg"; - extensions[1] = ".tga"; - - // load textures - - core::array tex; - tex.set_used(NumTextures+1); - - tex[0] = 0; - - s32 t;// new ISO for scoping problem with some compilers - - for (t=1; t<(NumTextures+1); ++t) - { - tex[t] = 0; - - if ( !tex[t] ) - { - for (s32 e=0; e<2; ++e) - { - s = Textures[t-1].strName; - s.append(extensions[e]); - if (FileSystem->existFile(s.c_str())) - { - tex[t] = Driver->getTexture(s.c_str()); - break; - } - } - } - if (!tex[t]) - { - os::Printer::log("Q3: no texmap for texturename ", Textures[t-1].strName, ELL_WARNING); - } - } - - // load lightmaps. - core::array lig; - lig.set_used(NumLightMaps+1); - - lig[0] = 0; - c8 lightmapname[255]; - core::dimension2d lmapsize(128,128); - - //bool oldMipMapState = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - //Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); - - video::IImage* lmapImg; - for (t=1; t<(NumLightMaps+1); ++t) - { - sprintf(lightmapname, "%s.lightmap.%d", LevelName.c_str(), t); - - // lightmap is a CTexture::R8G8B8 format - lmapImg = Driver->createImageFromData( - video::ECF_R8G8B8, - lmapsize, - LightMaps[t-1].imageBits, true, false ); - - lig[t] = Driver->addTexture ( lightmapname, lmapImg ); - lmapImg->drop (); - - } - //Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); - - - // attach textures to materials. - for (s32 l=0; lgetMeshBuffer(l*(NumTextures+1) + t); - b->Material.Textures[1] = lig[l]; - b->Material.Textures[0] = tex[t]; - - if (!b->Material.Textures[1]) - b->Material.MaterialType = video::EMT_SOLID; - - if ( !b->Material.Textures[0] ) - b->Material.MaterialType = video::EMT_SOLID; - - } - -} - -// delete all buffers without geometry in it. -void CQ3LevelMesh::cleanMeshes () -{ - // delete all buffers without geometry in it. - for ( u32 g = 0; g < quake3::E_Q3_MESH_SIZE; ++g ) - { - u32 i = 0; - bool texture0important = ( g == 0 ); - while(i < Mesh[g]->MeshBuffers.size()) - { - if (Mesh[g]->MeshBuffers[i]->getVertexCount() == 0 || - Mesh[g]->MeshBuffers[i]->getIndexCount() == 0 || - ( texture0important && Mesh[g]->MeshBuffers[i]->getMaterial().Textures[0] == 0 ) - ) - { - // delete Meshbuffer - Mesh[g]->MeshBuffers[i]->drop(); - Mesh[g]->MeshBuffers.erase(i); - } - else - ++i; - } - } - -} - -// recalculate bounding boxes -void CQ3LevelMesh::calcBoundingBoxes () -{ - // create bounding box - for ( u32 g = 0; g != quake3::E_Q3_MESH_SIZE; ++g ) - { - for ( u32 j=0; j < Mesh[g]->MeshBuffers.size(); ++j) - { - ((SMeshBufferLightMap*)Mesh[g]->MeshBuffers[j])->recalculateBoundingBox(); - } - - Mesh[g]->recalculateBoundingBox(); - } - -} - -/* -//! loads a texture -video::ITexture* CQ3LevelMesh::loadTexture ( const tStringList &stringList ) -{ - static const char * extension[2] = - { - ".jpg", - ".tga" - }; - - core::stringc loadFile; - for ( u32 i = 0; i!= stringList.size (); ++i ) - { - for ( u32 g = 0; g != 2 ; ++g ) - { - cutFilenameExtension ( loadFile, stringList[i] ).append ( extension[g] ); - - if ( FileSystem->existFile ( loadFile.c_str() ) ) - { - video::ITexture* t = Driver->getTexture( loadFile.c_str() ); - if ( t ) - return t; - } - } - } - return 0; -} -*/ - -//! loads the textures -void CQ3LevelMesh::loadTextures2() -{ - if (!Driver) - return; - - s32 t; - - // load lightmaps. - Lightmap.set_used(NumLightMaps+1); - - c8 lightmapname[255]; - core::dimension2d lmapsize(128,128); - - video::IImage* lmapImg; - for ( t = 0; t < NumLightMaps ; ++t) - { - sprintf(lightmapname, "%s.lightmap.%d", LevelName.c_str(), t); - - // lightmap is a CTexture::R8G8B8 format - lmapImg = Driver->createImageFromData( - video::ECF_R8G8B8, - lmapsize, - LightMaps[t].imageBits, true, false ); - - Lightmap[t] = Driver->addTexture ( lightmapname, lmapImg ); - lmapImg->drop (); - - } - - // load textures - Tex.set_used( NumTextures+1 ); - - const quake3::SShader * shader; - - core::stringc list; - core::stringc check; - quake3::tTexArray textureArray; - - for ( t=0; t< NumTextures; ++t) - { - Tex[t].ShaderID = -1; - Tex[t].Texture = 0; - - list = ""; - - // get a shader ( if one exists ) - shader = getShader ( Textures[t].strName, 0 ); - if ( shader ) - { - Tex[t].ShaderID = shader->id; - - // if texture name == stage1 Texture map - const quake3::SVarGroup * group; - - group = shader->getGroup ( 2 ); - if ( group ) - { - if ( core::cutFilenameExtension ( check, group->get ( "map" ) ) == Textures[t].strName ) - { - list += check; - } - else - if ( check == "$lightmap" ) - { - // we check if lightmap is in stage 1 and texture in stage 2 - group = shader->getGroup ( 3 ); - if ( group ) - list += group->get ( "map" ); - } - } - } - else - { - // no shader, take it - list += Textures[t].strName; - } - - u32 pos = 0; - quake3::getTextures ( textureArray, list, pos, FileSystem, Driver ); - - Tex[t].Texture = textureArray[0]; - } -} - - -//! Returns an axis aligned bounding box of the mesh. -//! \return A bounding box of this mesh is returned. -const core::aabbox3d& CQ3LevelMesh::getBoundingBox() const -{ - return Mesh[0]->getBoundingBox(); -} - - -//! Returns the type of the animated mesh. -E_ANIMATED_MESH_TYPE CQ3LevelMesh::getMeshType() const -{ - return scene::EAMT_BSP; -} - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CQ3LevelMesh.h" +#include "ISceneManager.h" +#include "os.h" +#include "SMeshBufferLightMap.h" +#include "irrString.h" +#include "ILightSceneNode.h" +#include "IQ3Shader.h" + +namespace irr +{ +namespace scene +{ + + +//! constructor +CQ3LevelMesh::CQ3LevelMesh(io::IFileSystem* fs, video::IVideoDriver* driver, scene::ISceneManager* smgr) +: Textures(0), LightMaps(0), + Vertices(0), Faces(0), Planes(0), Nodes(0), Leafs(0), LeafFaces(0), + MeshVerts(0), Brushes(0), Driver(driver), FileSystem(fs), SceneManager ( smgr ) +{ + #ifdef _DEBUG + IUnknown::setDebugName("CQ3LevelMesh"); + #endif + + s32 i; + for ( i = 0; i!= quake3::E_Q3_MESH_SIZE; ++i ) + { + Mesh[i] = 0; + } + + if (Driver) + Driver->grab(); + + if (FileSystem) + FileSystem->grab(); + + // load default shaders + InitShader (); + + +} + + +//! destructor +CQ3LevelMesh::~CQ3LevelMesh() +{ + if (Textures) + delete [] Textures; + + if (LightMaps) + delete [] LightMaps; + + if (Vertices) + delete [] Vertices; + + if (Faces) + delete [] Faces; + + if (Planes) + delete [] Planes; + + if (Nodes) + delete [] Nodes; + + if (Leafs) + delete [] Leafs; + + if (LeafFaces) + delete [] LeafFaces; + + if (MeshVerts) + delete [] MeshVerts; + + if (Brushes) + delete [] Brushes; + + if (Driver) + Driver->drop(); + + if (FileSystem) + FileSystem->drop(); + + s32 i; + for ( i = 0; i!= quake3::E_Q3_MESH_SIZE; ++i ) + { + if (Mesh[i]) + Mesh[i]->drop(); + } + + ReleaseShader (); + ReleaseEntity (); +} + + + +//! loads a level from a .bsp-File. Also tries to load all needed textures. Returns true if successful. +bool CQ3LevelMesh::loadFile(io::IReadFile* file) +{ + if (!file) + return false; + + LevelName = file->getFileName(); + + tBSPHeader header; + file->read(&header, sizeof(tBSPHeader)); + + #ifdef __BIG_ENDIAN__ + header.strID = os::Byteswap::byteswap(header.strID); + header.version = os::Byteswap::byteswap(header.version); + #endif + + if (header.strID != 0x50534249 || header.version != 0x2e) + { + os::Printer::log("Could not load .bsp file, unknown header.", file->getFileName(), ELL_ERROR); + return false; + } + + // now read lumps + + file->read(&Lumps[0], sizeof(tBSPLump)*kMaxLumps); + + #ifdef __BIG_ENDIAN__ + for (int i=0;idrop (); + Mesh [index] = 0; + } +} + +//! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. +IMesh* CQ3LevelMesh::getMesh(s32 frameInMs, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) +{ + return Mesh[ frameInMs ]; +} + + +void CQ3LevelMesh::loadTextures(tBSPLump* l, io::IReadFile* file) +{ + NumTextures = l->length / sizeof(tBSPTexture); + Textures = new tBSPTexture[NumTextures]; + + file->seek(l->offset); + file->read(Textures, l->length); + + #ifdef __BIG_ENDIAN__ + for (int i=0;ilength / sizeof(tBSPLightmap); + LightMaps = new tBSPLightmap[NumLightMaps]; + + file->seek(l->offset); + file->read(LightMaps, l->length); +} + + +void CQ3LevelMesh::loadVerts(tBSPLump* l, io::IReadFile* file) +{ + NumVertices = l->length / sizeof(tBSPVertex); + Vertices = new tBSPVertex[NumVertices]; + + file->seek(l->offset); + file->read(Vertices, l->length); + + #ifdef __BIG_ENDIAN__ + for (int i=0;ilength / sizeof(tBSPFace); + Faces = new tBSPFace[NumFaces]; + + file->seek(l->offset); + file->read(Faces, l->length); + + #ifdef __BIG_ENDIAN__ + for ( u32 i=0;i entity; + entity.set_used ( l->length + 2 ); + entity[l->length + 1 ] = 0; + + file->seek(l->offset); + file->read ( entity.pointer(), l->length); + + parser_parse ( entity.pointer(), l->length, &CQ3LevelMesh::scriptcallback_entity ); +} + +// load shaders named in bsp +void CQ3LevelMesh::loadShaders(tBSPLump* l, io::IReadFile* file) +{ + u32 files = l->length / sizeof(tBSPShader); + + file->seek ( l->offset ); + + tBSPShader def; + for ( u32 i = 0; i!= files; ++i ) + { + file->read ( &def, sizeof ( def ) ); + getShader ( def.strName, 1 ); + } +} + + +void CQ3LevelMesh::loadModels(tBSPLump* l, io::IReadFile* file) +{ + // ignore +} + + +void CQ3LevelMesh::loadMeshVerts(tBSPLump* l, io::IReadFile* file) +{ + NumMeshVerts = l->length / sizeof(s32); + MeshVerts = new s32[NumMeshVerts]; + + file->seek(l->offset); + file->read(MeshVerts, l->length); + + #ifdef __BIG_ENDIAN__ + for (int i=0;i= Parser.sourcesize ) + { + Parser.tokenresult = Q3_TOKEN_EOF; + return; + } + + symbol = Parser.source [ Parser.index ]; + Parser.index += 1; + } while ( isQ3WhiteSpace ( symbol ) ); + + // first symbol, one symbol + switch ( symbol ) + { + case 0: + Parser.tokenresult = Q3_TOKEN_EOF; + return; + + case '/': + // comment or divide + if ( Parser.index >= Parser.sourcesize ) + { + Parser.tokenresult = Q3_TOKEN_EOF; + return; + } + symbol = Parser.source [ Parser.index ]; + Parser.index += 1; + if ( isQ3WhiteSpace ( symbol ) ) + { + Parser.tokenresult = Q3_TOKEN_MATH_DIVIDE; + return; + } + else + if ( symbol == '*' ) + { + // C-style comment in quake? + } + else + if ( symbol == '/' ) + { + // skip to eol + do + { + if ( Parser.index >= Parser.sourcesize ) + { + Parser.tokenresult = Q3_TOKEN_EOF; + return; + } + symbol = Parser.source [ Parser.index ]; + Parser.index += 1; + } while ( symbol != '\n' ); + Parser.tokenresult = Q3_TOKEN_COMMENT; + return; + } + // take /[name] as valid token..?!?!?. mhmm, maybe + break; + + case '\n': + Parser.tokenresult = Q3_TOKEN_EOL; + return; + case '{': + Parser.tokenresult = Q3_TOKEN_START_LIST; + return; + case '}': + Parser.tokenresult = Q3_TOKEN_END_LIST; + return; + + case '"': + // string literal + do + { + if ( Parser.index >= Parser.sourcesize ) + { + Parser.tokenresult = Q3_TOKEN_EOF; + return; + } + symbol = Parser.source [ Parser.index ]; + Parser.index += 1; + if ( symbol != '"' ) + Parser.token.append ( symbol ); + } while ( symbol != '"' ); + Parser.tokenresult = Q3_TOKEN_ENTITY; + return; + } + + + // user identity + Parser.token.append ( symbol ); + + // continue till whitespace + bool notisWhite = true; + do + { + if ( Parser.index >= Parser.sourcesize ) + { + Parser.tokenresult = Q3_TOKEN_EOF; + return; + } + symbol = Parser.source [ Parser.index ]; + + notisWhite = ! isQ3WhiteSpace ( symbol ); + if ( notisWhite ) + { + Parser.token.append ( symbol ); + } + + Parser.index += 1; + + } while ( notisWhite ); + + Parser.tokenresult = Q3_TOKEN_TOKEN; + return; +} + +/* + parse entity & shader + calls callback on content in {} +*/ +void CQ3LevelMesh::parser_parse ( const void * data, const u32 size, CQ3LevelMesh::tParserCallback callback ) +{ + Parser.source = (const c8*) data; + Parser.sourcesize = size; + Parser.index = 0; + + quake3::SVarGroupList *groupList; + + s32 active; + s32 last; + + quake3::SVariable entity; + + groupList = new quake3::SVarGroupList (); + + groupList->VariableGroup.push_back ( quake3::SVarGroup () ); + active = last = 0; + + do + { + parser_nextToken (); + + switch ( Parser.tokenresult ) + { + case Q3_TOKEN_START_LIST: + { + //stack = core::min_ ( stack + 1, 7 ); + + groupList->VariableGroup.push_back ( quake3::SVarGroup () ); + last = active; + active = groupList->VariableGroup.size() - 1; + entity.clear (); + } break; + + // a unregisterd variable is finished + case Q3_TOKEN_EOL: + { + if ( entity.isValid() ) + { + groupList->VariableGroup[active].Variable.push_back ( entity ); + entity.clear (); + } + } break; + + case Q3_TOKEN_TOKEN: + case Q3_TOKEN_ENTITY: + { + Parser.token.make_lower(); + + // store content based on line-delemiter + if ( 0 == entity.isValid() ) + { + entity.name = Parser.token; + entity.content = ""; + + } + else + { + if ( entity.content.size() ) + { + entity.content += " "; + } + entity.content += Parser.token; + } + } break; + + case Q3_TOKEN_END_LIST: + { + //stack = core::max_ ( stack - 1, 0 ); + + // close tag for first + if ( active == 1 ) + { + (this->*callback) ( groupList ); + + // new group + groupList->drop (); + groupList = new quake3::SVarGroupList (); + groupList->VariableGroup.push_back ( quake3::SVarGroup () ); + last = 0; + } + + active = last; + entity.clear(); + + } break; + + } + + } while ( Parser.tokenresult != Q3_TOKEN_EOF ); + + groupList->drop (); +} + + + +/* + this loader applies only textures for stage 1 & 2 +*/ +s32 CQ3LevelMesh::setShaderMaterial ( video::SMaterial &material, const tBSPFace * face ) const +{ + material.MaterialType = video::EMT_SOLID; + material.Wireframe = false; + material.Lighting = false; + material.BilinearFilter = true; + material.BackfaceCulling = true; + material.Textures[0] = 0; + material.Textures[1] = 0; + material.Textures[2] = 0; + material.Textures[3] = 0; + material.ZBuffer = true; + material.ZWriteEnable = true; + material.MaterialTypeParam = 0.f; + + s32 shaderState = -1; + + if ( face->textureID >= 0 ) + { + material.Textures[0] = Tex [ face->textureID ].Texture; + shaderState = Tex [ face->textureID ].ShaderID; + } + + if ( face->lightmapID >= 0 ) + { + material.Textures[1] = Lightmap [ face->lightmapID ]; + material.MaterialType = quake3::defaultLightMap; + } + + // store shader ID + material.MaterialTypeParam2 = (f32) shaderState; + + const quake3::SShader *shader = getShader ( shaderState ); + if ( 0 == shader ) + return shaderState; + + + const quake3::SVarGroup *group; + + s32 index; + + // generic + group = shader->getGroup ( 1 ); + if ( group ) + { + material.BackfaceCulling = quake3::getBackfaceCulling ( group->get ( "cull" ) ); + + if ( group->isDefined ( "surfaceparm", "nolightmap" ) ) + { + material.MaterialType = video::EMT_SOLID; + material.Textures[1] = 0; + } + + } + + // try to get the best of the 8 texture stages.. + + // texture 1, texture 2 + u32 startPos; + for ( s32 g = 2; g <= 3; ++g ) + { + group = shader->getGroup ( g ); + if ( 0 == group ) + continue; + + startPos = 0; + + + index = group->getIndex ( "depthwrite" ); + if ( index >= 0 ) + { + material.ZBuffer = true; + } + + quake3::SBlendFunc blendfunc; + quake3::getBlendFunc ( group->get ( "blendfunc" ), blendfunc ); + quake3::getBlendFunc ( group->get ( "alphafunc" ), blendfunc ); + + material.MaterialType = blendfunc.type; + material.MaterialTypeParam = blendfunc.param; + + // try if we can match better + shaderState |= (material.MaterialType == video::EMT_SOLID ) ? 0x00020000 : 0; + + } + + + //material.BackfaceCulling = false; + + if ( shader->VarGroup->VariableGroup.size () <= 4 ) + { + shaderState |= 0x00010000; + } + + material.MaterialTypeParam2 = (f32) shaderState; + return shaderState; +} + +//! constructs a mesh from the quake 3 level file. +void CQ3LevelMesh::constructMesh2() +{ + s32 i, j, k; + + s32 *index; + + video::S3DVertex2TCoords temp[3]; + + video::SMaterial material; + + SToBuffer item; + + core::array < SToBuffer > toBuffer; + + const s32 mesh0size = (NumTextures+1) * (NumLightMaps+1); + for ( i=0; i < mesh0size; ++i) + { + scene::SMeshBufferLightMap* buffer = new scene::SMeshBufferLightMap(); + + Mesh[quake3::E_Q3_MESH_GEOMETRY]->addMeshBuffer(buffer); + buffer->drop(); + } + + for ( i=0; i NumLightMaps-1) + { + Faces[i].lightmapID = -1; + } + + // there are lightmapsids and textureid with -1 + s32 index = ((Faces[i].lightmapID+1) * (NumTextures+1)) + (Faces[i].textureID+1); + buffer = (SMeshBufferLightMap*) Mesh[quake3::E_Q3_MESH_GEOMETRY]->getMeshBuffer(index); + buffer->getMaterial() = material; + } + else + { + buffer = (SMeshBufferLightMap*) Mesh[ toBuffer[g].index ]->getMeshBuffer ( material ); + //buffer = 0; + if ( 0 == buffer ) + { + buffer = new scene::SMeshBufferLightMap(); + Mesh[ toBuffer[g].index ]->addMeshBuffer ( buffer ); + buffer->drop (); + buffer->getMaterial() = material; + } + } + + + switch(Faces[i].type) + { + case 4: // billboards + break; + case 2: // patches + createCurvedSurface2(buffer, i, PatchTesselation,toBuffer[g].takeVertexColor); + break; + + case 1: // normal polygons + case 3: // mesh vertices + + index = MeshVerts + face->meshVertIndex; + k = buffer->getVertexCount(); + + for ( j = 0; j < face->numMeshVerts; j += 1 ) + { + buffer->Indices.push_back( k + index [j] ); + } + + for ( j = 0; j != face->numOfVerts; ++j ) + { + copy ( &temp[0], &Vertices[ j + face->vertexIndex ], toBuffer[g].takeVertexColor ); + buffer->Vertices.push_back( temp[0] ); + } + break; + + } // end switch + } + } + + +} + +//! constructs a mesh from the quake 3 level file. +void CQ3LevelMesh::constructMesh() +{ + // reserve buffer. + s32 i; // new ISO for scoping problem with some compilers + + for (i=0; i<(NumTextures+1) * (NumLightMaps+1); ++i) + { + scene::SMeshBufferLightMap* buffer = new scene::SMeshBufferLightMap(); + + buffer->Material.MaterialType = video::EMT_LIGHTMAP_M4; + buffer->Material.Wireframe = false; + buffer->Material.Lighting = false; + buffer->Material.BilinearFilter = true; + + Mesh[0]->addMeshBuffer(buffer); + + buffer->drop(); + } + + // go through all faces and add them to the buffer. + + video::S3DVertex2TCoords temp[3]; + + for (i=0; i NumLightMaps-1) + Faces[i].lightmapID = -1; + + // there are lightmapsids and textureid with -1 + s32 meshBufferIndex = ((Faces[i].lightmapID+1) * (NumTextures+1)) + (Faces[i].textureID+1); + SMeshBufferLightMap* meshBuffer = ((SMeshBufferLightMap*)Mesh[0]->getMeshBuffer(meshBufferIndex)); + + switch(Faces[i].type) + { + //case 3: // mesh vertices + case 1: // normal polygons + { + for (s32 tf=0; tfgetVertexCount(); + s32 vidxes[3]; + + vidxes[0] = MeshVerts[Faces[i].meshVertIndex + tf +0] + + Faces[i].vertexIndex; + vidxes[1] = MeshVerts[Faces[i].meshVertIndex + tf +1] + + Faces[i].vertexIndex; + vidxes[2] = MeshVerts[Faces[i].meshVertIndex + tf +2] + + Faces[i].vertexIndex; + + // add all three vertices + copy ( &temp[0], &Vertices[ vidxes[0] ], 0 ); + copy ( &temp[1], &Vertices[ vidxes[1] ], 0 ); + copy ( &temp[2], &Vertices[ vidxes[2] ], 0 ); + + meshBuffer->Vertices.push_back( temp[0] ); + meshBuffer->Vertices.push_back( temp[1] ); + meshBuffer->Vertices.push_back( temp[2] ); + + // add indexes + + meshBuffer->Indices.push_back(idx); + meshBuffer->Indices.push_back(idx+1); + meshBuffer->Indices.push_back(idx+2); + } + } + break; + case 2: // curved surfaces + createCurvedSurface(meshBuffer, i); + break; + + case 4: // billboards + break; + } // end switch + } + +} + +// helper method for creating curved surfaces, sent in by Dean P. Macri. +inline f32 CQ3LevelMesh::Blend( const f64 s[3], const f64 t[3], const tBSPVertex *v[9], int offset) +{ + f64 res = 0.0; + f32 *ptr; + + for( int i=0; i<3; i++ ) + for( int j=0; j<3; j++ ) + { + ptr = (f32 *)( (char*)v[i*3+j] + offset ); + res += s[i] * t[j] * (*ptr); + } + + return (f32) res; +} + +//!helper function +inline s32 s32_min ( s32 a, s32 b) +{ + s32 mask = (a - b) >> 31; + return (a & mask) | (b & ~mask); +} + +void CQ3LevelMesh::S3DVertex2TCoords_64::copyto ( video::S3DVertex2TCoords &dest ) const +{ + dest.Pos.X = core::round ( (f32) Pos.X ); + dest.Pos.Y = core::round ( (f32) Pos.Y ); + dest.Pos.Z = core::round ( (f32) Pos.Z ); + //dest.Pos.X = (f32) Pos.X; + //dest.Pos.Y = (f32) Pos.Y; + //dest.Pos.Z = (f32) Pos.Z; + + dest.Normal.X = (f32) Normal.X; + dest.Normal.Y = (f32) Normal.Y; + dest.Normal.Z = (f32) Normal.Z; + dest.Normal.normalize(); + + dest.Color = Color.toSColor(); + + dest.TCoords.X = (f32) TCoords.X; + dest.TCoords.Y = (f32) TCoords.Y; + + dest.TCoords2.X = (f32) TCoords2.X; + dest.TCoords2.Y = (f32) TCoords2.Y; +} + + +void CQ3LevelMesh::copy ( S3DVertex2TCoords_64 * dest, const tBSPVertex * source, s32 vertexcolor ) const +{ + //dest->Pos.X = core::round ( source->vPosition[0] ); + //dest->Pos.Y = core::round ( source->vPosition[2] ); + //dest->Pos.Z = core::round ( source->vPosition[1] ); + dest->Pos.X = source->vPosition[0]; + dest->Pos.Y = source->vPosition[2]; + dest->Pos.Z = source->vPosition[1]; + + dest->Normal.X = source->vNormal[0]; + dest->Normal.Y = source->vNormal[2]; + dest->Normal.Z = source->vNormal[1]; + dest->Normal.normalize (); + + dest->TCoords.X = source->vTextureCoord[0]; + dest->TCoords.Y = source->vTextureCoord[1]; + dest->TCoords2.X = source->vLightmapCoord[0]; + dest->TCoords2.Y = source->vLightmapCoord[1]; + + if ( vertexcolor ) + { + u32 a = s32_min ( source->color[3] * quake3::defaultModulate, 255 ); + u32 r = s32_min ( source->color[0] * quake3::defaultModulate, 255 ); + u32 g = s32_min ( source->color[1] * quake3::defaultModulate, 255 ); + u32 b = s32_min ( source->color[2] * quake3::defaultModulate, 255 ); + + dest->Color.set ( a * 1.f/255.f, + r * 1.f/255.f, + g * 1.f/255.f, + b * 1.f/255.f + ); + } + else + { + dest->Color.set ( 1.f, 1.f, 1.f, 1.f ); + } + +} + + +inline void CQ3LevelMesh::copy ( video::S3DVertex2TCoords * dest, const tBSPVertex * source, s32 vertexcolor ) const +{ + dest->Pos.X = core::round ( source->vPosition[0] ); + dest->Pos.Y = core::round ( source->vPosition[2] ); + dest->Pos.Z = core::round ( source->vPosition[1] ); + + //dest->Pos.X = source->vPosition[0]; + //dest->Pos.Y = source->vPosition[2]; + //dest->Pos.Z = source->vPosition[1]; + + dest->Normal.X = source->vNormal[0]; + dest->Normal.Y = source->vNormal[2]; + dest->Normal.Z = source->vNormal[1]; + dest->Normal.normalize(); + + dest->TCoords.X = source->vTextureCoord[0]; + dest->TCoords.Y = source->vTextureCoord[1]; + dest->TCoords2.X = source->vLightmapCoord[0]; + dest->TCoords2.Y = source->vLightmapCoord[1]; + + if ( vertexcolor ) + { + u32 a = s32_min ( source->color[3] * quake3::defaultModulate, 255 ); + u32 r = s32_min ( source->color[0] * quake3::defaultModulate, 255 ); + u32 g = s32_min ( source->color[1] * quake3::defaultModulate, 255 ); + u32 b = s32_min ( source->color[2] * quake3::defaultModulate, 255 ); + + dest->Color.color = a << 24 | r << 16 | g << 8 | b; + } + else + { + dest->Color.color = 0xFFFFFFFF; + } +} + +void CQ3LevelMesh::SBezier::tesselate ( s32 level ) +{ + //Calculate how many vertices across/down there are + s32 j, k; + + u32 idx = Patch->Vertices.size(); + + column[0].set_used ( level + 1 ); + column[1].set_used ( level + 1 ); + column[2].set_used ( level + 1 ); + + const f64 w = 0.0 + core::reciprocal ( (f32) level ); + + //Tesselate along the columns + for( j = 0; j <= level; ++j) + { + const f64 f = w * (f64) j; + + column[0][j] = control[0].getInterpolated_quadratic(control[3], control[6], f ); + column[1][j] = control[1].getInterpolated_quadratic(control[4], control[7], f ); + column[2][j] = control[2].getInterpolated_quadratic(control[5], control[8], f ); + } + + //Tesselate across the rows to get final vertices + video::S3DVertex2TCoords v; + S3DVertex2TCoords_64 f; + for( j = 0; j <= level; ++j) + { + for( k = 0; k <= level; ++k) + { + f = column[0][j].getInterpolated_quadratic( column[1][j], column[2][j], w * (f64) k ); + f.copyto ( v ); + Patch->Vertices.push_back ( v ); + } + } + + // connect + for( j = 0; j < level; ++j) + { + for( k = 0; k < level; ++k) + { + const s32 inx = idx + ( k * ( level + 1 ) ) + j; + + Patch->Indices.push_back ( inx + 0 ); + Patch->Indices.push_back ( inx + (level + 1 ) + 0 ); + Patch->Indices.push_back ( inx + (level + 1 ) + 1 ); + + Patch->Indices.push_back ( inx + 0 ); + Patch->Indices.push_back ( inx + (level + 1 ) + 1 ); + Patch->Indices.push_back ( inx + 1 ); + } + } +} + + +/*! + no subdivision +*/ +void CQ3LevelMesh::createCurvedSurface3 ( SMeshBufferLightMap* meshBuffer, + s32 faceIndex, + s32 patchTesselation, + s32 storevertexcolor + ) +{ + tBSPFace * face = &Faces[faceIndex]; + u32 j,k,m; + + // number of control points across & up + const u32 controlWidth = face->size[0]; + const u32 controlHeight = face->size[1]; + + video::S3DVertex2TCoords v; + + m = meshBuffer->Vertices.size (); + for ( j = 0; j!= controlHeight * controlWidth; ++j ) + { + copy ( &v, &Vertices [ face->vertexIndex + j ], storevertexcolor ); + meshBuffer->Vertices.push_back ( v ); + } + + for ( j = 0; j!= controlHeight - 1; ++j ) + { + for ( k = 0; k!= controlWidth - 1; ++k ) + { + meshBuffer->Indices.push_back ( m + k + 0 ); + meshBuffer->Indices.push_back ( m + k + controlWidth + 0 ); + meshBuffer->Indices.push_back ( m + k + controlWidth + 1 ); + + meshBuffer->Indices.push_back ( m + k + 0 ); + meshBuffer->Indices.push_back ( m + k + controlWidth + 1 ); + meshBuffer->Indices.push_back ( m + k + 1 ); + } + m += controlWidth; + } +} + +/*! +*/ +void CQ3LevelMesh::createCurvedSurface2 ( SMeshBufferLightMap* meshBuffer, + s32 faceIndex, + s32 patchTesselation, + s32 storevertexcolor + ) +{ + tBSPFace * face = &Faces[faceIndex]; + u32 j,k; + + // number of control points across & up + const u32 controlWidth = face->size[0]; + const u32 controlHeight = face->size[1]; + + + // number of biquadratic patches + const u32 biquadWidth = (controlWidth - 1)/2; + const u32 biquadHeight = (controlHeight -1)/2; + + + // Create space for a temporary array of the patch's control points + core::array controlPoint; + controlPoint.set_used ( controlWidth * controlHeight ); + + for( j = 0; j < controlPoint.size(); ++j) + { + copy ( &controlPoint[j], &Vertices [ face->vertexIndex + j ], storevertexcolor ); + } + + // create a temporary patch + Bezier.Patch = new scene::SMeshBufferLightMap(); + + //Loop through the biquadratic patches + for( j = 0; j < biquadHeight; ++j) + { + for( k = 0; k < biquadWidth; ++k) + { + // set up this patch + const s32 inx = j*controlWidth*2 + k*2; + + // setup bezier control points for this patch + Bezier.control[0] = controlPoint[ inx + 0]; + Bezier.control[1] = controlPoint[ inx + 1]; + Bezier.control[2] = controlPoint[ inx + 2]; + Bezier.control[3] = controlPoint[ inx + controlWidth + 0 ]; + Bezier.control[4] = controlPoint[ inx + controlWidth + 1 ]; + Bezier.control[5] = controlPoint[ inx + controlWidth + 2 ]; + Bezier.control[6] = controlPoint[ inx + controlWidth * 2 + 0]; + Bezier.control[7] = controlPoint[ inx + controlWidth * 2 + 1]; + Bezier.control[8] = controlPoint[ inx + controlWidth * 2 + 2]; + + Bezier.tesselate ( patchTesselation ); + } + } + + + // stitch together with existing geometry + // TODO: only border needs to be checked + const u32 bsize = Bezier.Patch->getVertexCount(); + const u32 msize = meshBuffer->getVertexCount(); +/* + for ( j = 0; j!= bsize; ++j ) + { + const core::vector3df &v = Bezier.Patch->Vertices[j].Pos; + + for ( k = 0; k!= msize; ++k ) + { + const core::vector3df &m = meshBuffer->Vertices[k].Pos; + + if ( !v.equals ( m, tolerance ) ) + continue; + + meshBuffer->Vertices[k].Pos = v; + //Bezier.Patch->Vertices[j].Pos = m; + } + } +*/ + + + // add Patch to meshbuffer + for ( j = 0; j!= bsize; ++j ) + { + meshBuffer->Vertices.push_back ( Bezier.Patch->Vertices[j] ); + } + + // add indices to meshbuffer + for ( j = 0; j!= Bezier.Patch->getIndexCount(); ++j ) + { + meshBuffer->Indices.push_back ( msize + Bezier.Patch->Indices[j] ); + } + + delete Bezier.Patch; + +} + +void CQ3LevelMesh::createCurvedSurface(SMeshBufferLightMap* meshBuffer, s32 i) +{ + // this implementation for loading curved surfaces was + // sent in by Dean P. Macri. It was a little bit modified + // by me afterwards. + s32 idx; + s32 cpidx[9]; + + const tBSPVertex *v[9]; + video::S3DVertex2TCoords currentVertex[4]; + + for( s32 row=0; rowgetVertexCount(); + ct[0] = (1.0-t)*(1.0-t); + ct[1] = 2.0 * (1.0 - t) * t; + ct[2] = t * t; + nxt[0] = (1.0-t-tstep)*(1.0-t-tstep); + nxt[1] = 2.0 * (1.0 - t - tstep) * (t+tstep); + nxt[2] = (t+tstep) * (t+tstep); + + // Vert 1 + currentVertex[0].Color.set(255,255,255,255); + currentVertex[0].Pos.X = floorf( Blend( cs, ct, v, (char*)&v[0]->vPosition[0] - (char*)v[0])+ 0.5f); + currentVertex[0].Pos.Y = floorf( Blend( cs, ct, v, (char*)&v[0]->vPosition[2] - (char*)v[0])+ 0.5f); + currentVertex[0].Pos.Z = floorf( Blend( cs, ct, v, (char*)&v[0]->vPosition[1] - (char*)v[0])+ 0.5f); + currentVertex[0].Normal.X = Blend( cs, ct, v, (char*)&v[0]->vNormal[0] - (char*)v[0]); + currentVertex[0].Normal.Y = Blend( cs, ct, v, (char*)&v[0]->vNormal[2] - (char*)v[0]); + currentVertex[0].Normal.Z = Blend( cs, ct, v, (char*)&v[0]->vNormal[1] - (char*)v[0]); + currentVertex[0].TCoords.X = Blend( cs, ct, v, (char*)&v[0]->vTextureCoord[0] - (char*)v[0]); + currentVertex[0].TCoords.Y = Blend( cs, ct, v, (char*)&v[0]->vTextureCoord[1] - (char*)v[0]); + currentVertex[0].TCoords2.X = Blend( cs, ct, v, (char*)&v[0]->vLightmapCoord[0] - (char*)v[0]); + currentVertex[0].TCoords2.Y = Blend( cs, ct, v, (char*)&v[0]->vLightmapCoord[1] - (char*)v[0]); + // Vert 2 + currentVertex[1].Color.set(255,255,255,255); + currentVertex[1].Pos.X = floorf( Blend( cs, nxt, v, (char*)&v[0]->vPosition[0] - (char*)v[0])+ 0.5f); + currentVertex[1].Pos.Y = floorf( Blend( cs, nxt, v, (char*)&v[0]->vPosition[2] - (char*)v[0])+ 0.5f); + currentVertex[1].Pos.Z = floorf( Blend( cs, nxt, v, (char*)&v[0]->vPosition[1] - (char*)v[0])+ 0.5f); + currentVertex[1].Normal.X = Blend( cs, nxt, v, (char*)&v[0]->vNormal[0] - (char*)v[0]); + currentVertex[1].Normal.Y = Blend( cs, nxt, v, (char*)&v[0]->vNormal[2] - (char*)v[0]); + currentVertex[1].Normal.Z = Blend( cs, nxt, v, (char*)&v[0]->vNormal[1] - (char*)v[0]); + currentVertex[1].TCoords.X = Blend( cs, nxt, v, (char*)&v[0]->vTextureCoord[0] - (char*)v[0]); + currentVertex[1].TCoords.Y = Blend( cs, nxt, v, (char*)&v[0]->vTextureCoord[1] - (char*)v[0]); + currentVertex[1].TCoords2.X = Blend( cs, nxt, v, (char*)&v[0]->vLightmapCoord[0] - (char*)v[0]); + currentVertex[1].TCoords2.Y = Blend( cs, nxt, v, (char*)&v[0]->vLightmapCoord[1] - (char*)v[0]); + // Vert 3 + currentVertex[2].Color.set(255,255,255,255); + currentVertex[2].Pos.X = floorf( Blend( nxs, ct, v, (char*)&v[0]->vPosition[0] - (char*)v[0])+ 0.5f); + currentVertex[2].Pos.Y = floorf( Blend( nxs, ct, v, (char*)&v[0]->vPosition[2] - (char*)v[0])+ 0.5f); + currentVertex[2].Pos.Z = floorf( Blend( nxs, ct, v, (char*)&v[0]->vPosition[1] - (char*)v[0])+ 0.5f); + currentVertex[2].Normal.X = Blend( nxs, ct, v, (char*)&v[0]->vNormal[0] - (char*)v[0]); + currentVertex[2].Normal.Y = Blend( nxs, ct, v, (char*)&v[0]->vNormal[2] - (char*)v[0]); + currentVertex[2].Normal.Z = Blend( nxs, ct, v, (char*)&v[0]->vNormal[1] - (char*)v[0]); + currentVertex[2].TCoords.X = Blend( nxs, ct, v, (char*)&v[0]->vTextureCoord[0] - (char*)v[0]); + currentVertex[2].TCoords.Y = Blend( nxs, ct, v, (char*)&v[0]->vTextureCoord[1] - (char*)v[0]); + currentVertex[2].TCoords2.X = Blend( nxs, ct, v, (char*)&v[0]->vLightmapCoord[0] - (char*)v[0]); + currentVertex[2].TCoords2.Y = Blend( nxs, ct, v, (char*)&v[0]->vLightmapCoord[1] - (char*)v[0]); + // Vert 4 + currentVertex[3].Color.set(255,255,255,255); + currentVertex[3].Pos.X = floorf(Blend( nxs, nxt, v, (char*)&v[0]->vPosition[0] - (char*)v[0])+ 0.5f); + currentVertex[3].Pos.Y = floorf(Blend( nxs, nxt, v, (char*)&v[0]->vPosition[2] - (char*)v[0])+ 0.5f); + currentVertex[3].Pos.Z = floorf(Blend( nxs, nxt, v, (char*)&v[0]->vPosition[1] - (char*)v[0])+ 0.5f); + currentVertex[3].Normal.X = Blend( nxs, nxt, v, (char*)&v[0]->vNormal[0] - (char*)v[0]); + currentVertex[3].Normal.Y = Blend( nxs, nxt, v, (char*)&v[0]->vNormal[2] - (char*)v[0]); + currentVertex[3].Normal.Z = Blend( nxs, nxt, v, (char*)&v[0]->vNormal[1] - (char*)v[0]); + currentVertex[3].TCoords.X = Blend( nxs, nxt, v, (char*)&v[0]->vTextureCoord[0] - (char*)v[0]); + currentVertex[3].TCoords.Y = Blend( nxs, nxt, v, (char*)&v[0]->vTextureCoord[1] - (char*)v[0]); + currentVertex[3].TCoords2.X = Blend( nxs, nxt, v, (char*)&v[0]->vLightmapCoord[0] - (char*)v[0]); + currentVertex[3].TCoords2.Y = Blend( nxs, nxt, v, (char*)&v[0]->vLightmapCoord[1] - (char*)v[0]); + // Put the vertices in the mesh buffer + meshBuffer->Vertices.push_back(currentVertex[0]); + meshBuffer->Vertices.push_back(currentVertex[2]); + meshBuffer->Vertices.push_back(currentVertex[1]); + + meshBuffer->Vertices.push_back(currentVertex[1]); + meshBuffer->Vertices.push_back(currentVertex[2]); + meshBuffer->Vertices.push_back(currentVertex[3]); + + // add indexes + meshBuffer->Indices.push_back(idx); + meshBuffer->Indices.push_back(idx+1); + meshBuffer->Indices.push_back(idx+2); + // add indexes + meshBuffer->Indices.push_back(idx+3); + meshBuffer->Indices.push_back(idx+4); + meshBuffer->Indices.push_back(idx+5); + } + } + } + } +} + +//! get's an interface to the entities +const quake3::tQ3EntityList & CQ3LevelMesh::getEntityList () +{ + Entity.sort(); + return Entity; +} + + +/*! +*/ +const quake3::SShader * CQ3LevelMesh::getShader ( u32 index ) const +{ + index &= 0xFFFF; + + if ( index < Shader.size () ) + { + return &Shader[index]; + } + + return 0; +} + +//! loads the shader definition +// either from file ( we assume /scripts on fileNameIsValid == 0 ) +const quake3::SShader * CQ3LevelMesh::getShader ( const c8 * filename, s32 fileNameIsValid ) +{ + quake3::SShader search; + search.name = filename; + + s32 index; + + //! is Shader already in cache? + index = Shader.linear_search ( search ); + if ( index >= 0 ) + { + return &Shader[index]; + } + + core::stringc loadFile; + + if ( 0 == fileNameIsValid ) + { + // extract the shader name from the last path component in filename + // "scripts/[name].shader" + core::stringc cut ( filename ); + + s32 end = cut.findLast ( '/' ); + s32 start = cut.findLast ( '/', end - 1 ); + + loadFile = "scripts"; + loadFile.append ( cut.subString ( start, end - start ) ); + loadFile.append ( ".shader" ); + } + else + { + loadFile = filename; + } + + // already loaded the file ? + index = ShaderFile.binary_search ( loadFile ); + if ( index >= 0 ) + return 0; + +#if 0 + core::stringc message; + message = loadFile + " for " + core::stringc ( filename ); + os::Printer::log("Q3: Loading shader file ", message.c_str(), ELL_INFORMATION); + io::IReadFile *file = FileSystem->createAndOpenFile ( loadFile.c_str () ); + if ( 0 == file ) + { + os::Printer::log("Q3: could not load shader ", loadFile.c_str(), ELL_INFORMATION); + return 0; + } +#endif + + if ( !FileSystem->existFile ( loadFile.c_str () ) ) + return 0; + + io::IReadFile *file = FileSystem->createAndOpenFile ( loadFile.c_str () ); + if ( 0 == file ) + return 0; + + core::stringc message; + message = loadFile + " for " + core::stringc ( filename ); + os::Printer::log("Loaded shader", message.c_str(), ELL_INFORMATION); + + // add file to loaded files + ShaderFile.push_back ( loadFile ); + + // load script + core::array script; + u32 len = file->getSize (); + + script.set_used ( len + 2 ); + script[ len + 1 ] = 0; + + file->seek( 0 ); + file->read ( script.pointer(), len ); + file->drop (); + + // start a parser instance + parser_parse ( script.pointer(), len, &CQ3LevelMesh::scriptcallback_shader ); + + // search again + index = Shader.linear_search ( search ); + if ( index >= 0 ) + return &Shader[index]; + + return 0; +} + +//! adding default shaders +void CQ3LevelMesh::InitShader () +{ + ReleaseShader (); + + quake3::SShader element; + + quake3::SVarGroup group; + quake3::SVariable variable; + + variable.name = "noshader"; + group.Variable.push_back ( variable ); + + element.VarGroup = new quake3::SVarGroupList (); + element.VarGroup->VariableGroup.push_back ( group ); + element.name = element.VarGroup->VariableGroup[0].Variable[0].name.c_str (); + Shader.push_back ( element ); + + // load common named shader + getShader ( "scripts/common.shader", 1 ); +} + +//!. script callback for shaders +//! i'm having troubles with the reference counting, during callback.. resorting.. +void CQ3LevelMesh::ReleaseShader () +{ + for ( u32 i = 0; i!= Shader.size(); ++i ) + { + Shader[i].VarGroup->drop (); + } + Shader.clear (); + ShaderFile.clear(); +} + +void CQ3LevelMesh::ReleaseEntity () +{ + for ( u32 i = 0; i!= Entity.size(); ++i ) + { + Entity[i].VarGroup->drop (); + } + Entity.clear (); + +} + + +// entity only has only one valid level.. and no assoziative name.. +void CQ3LevelMesh::scriptcallback_entity ( quake3::SVarGroupList *& grouplist ) +{ + quake3::SEntity element; + + if ( grouplist->VariableGroup.size () != 2 ) + return; + + + element.name = grouplist->VariableGroup[1].get ( "classname" ); + + grouplist->grab (); + element.VarGroup = grouplist; + element.id = Shader.size(); + + Entity.push_back ( element ); +} + + +//!. script callback for shaders +void CQ3LevelMesh::scriptcallback_shader ( quake3::SVarGroupList *& grouplist ) +{ + quake3::SShader element; + + grouplist->grab (); + + element.VarGroup = grouplist; + element.name = element.VarGroup->VariableGroup[0].Variable[0].name.c_str (); + element.id = Shader.size(); + + Shader.push_back ( element ); +} + + +//! loads the textures +void CQ3LevelMesh::loadTextures() +{ + if (!Driver) + return; + + core::stringc s; + core::stringc extensions[2]; + extensions[0] = ".jpg"; + extensions[1] = ".tga"; + + // load textures + + core::array tex; + tex.set_used(NumTextures+1); + + tex[0] = 0; + + s32 t;// new ISO for scoping problem with some compilers + + for (t=1; t<(NumTextures+1); ++t) + { + tex[t] = 0; + + if ( !tex[t] ) + { + for (s32 e=0; e<2; ++e) + { + s = Textures[t-1].strName; + s.append(extensions[e]); + if (FileSystem->existFile(s.c_str())) + { + tex[t] = Driver->getTexture(s.c_str()); + break; + } + } + } + if (!tex[t]) + { + os::Printer::log("Q3: no texmap for texturename ", Textures[t-1].strName, ELL_WARNING); + } + } + + // load lightmaps. + core::array lig; + lig.set_used(NumLightMaps+1); + + lig[0] = 0; + c8 lightmapname[255]; + core::dimension2d lmapsize(128,128); + + //bool oldMipMapState = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); + //Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); + + video::IImage* lmapImg; + for (t=1; t<(NumLightMaps+1); ++t) + { + sprintf(lightmapname, "%s.lightmap.%d", LevelName.c_str(), t); + + // lightmap is a CTexture::R8G8B8 format + lmapImg = Driver->createImageFromData( + video::ECF_R8G8B8, + lmapsize, + LightMaps[t-1].imageBits, true, false ); + + lig[t] = Driver->addTexture ( lightmapname, lmapImg ); + lmapImg->drop (); + + } + //Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); + + + // attach textures to materials. + for (s32 l=0; lgetMeshBuffer(l*(NumTextures+1) + t); + b->Material.Textures[1] = lig[l]; + b->Material.Textures[0] = tex[t]; + + if (!b->Material.Textures[1]) + b->Material.MaterialType = video::EMT_SOLID; + + if ( !b->Material.Textures[0] ) + b->Material.MaterialType = video::EMT_SOLID; + + } + +} + +// delete all buffers without geometry in it. +void CQ3LevelMesh::cleanMeshes () +{ + // delete all buffers without geometry in it. + for ( u32 g = 0; g < quake3::E_Q3_MESH_SIZE; ++g ) + { + u32 i = 0; + bool texture0important = ( g == 0 ); + while(i < Mesh[g]->MeshBuffers.size()) + { + if (Mesh[g]->MeshBuffers[i]->getVertexCount() == 0 || + Mesh[g]->MeshBuffers[i]->getIndexCount() == 0 || + ( texture0important && Mesh[g]->MeshBuffers[i]->getMaterial().Textures[0] == 0 ) + ) + { + // delete Meshbuffer + Mesh[g]->MeshBuffers[i]->drop(); + Mesh[g]->MeshBuffers.erase(i); + } + else + ++i; + } + } + +} + +// recalculate bounding boxes +void CQ3LevelMesh::calcBoundingBoxes () +{ + // create bounding box + for ( u32 g = 0; g != quake3::E_Q3_MESH_SIZE; ++g ) + { + for ( u32 j=0; j < Mesh[g]->MeshBuffers.size(); ++j) + { + ((SMeshBufferLightMap*)Mesh[g]->MeshBuffers[j])->recalculateBoundingBox(); + } + + Mesh[g]->recalculateBoundingBox(); + } + +} + +/* +//! loads a texture +video::ITexture* CQ3LevelMesh::loadTexture ( const tStringList &stringList ) +{ + static const char * extension[2] = + { + ".jpg", + ".tga" + }; + + core::stringc loadFile; + for ( u32 i = 0; i!= stringList.size (); ++i ) + { + for ( u32 g = 0; g != 2 ; ++g ) + { + cutFilenameExtension ( loadFile, stringList[i] ).append ( extension[g] ); + + if ( FileSystem->existFile ( loadFile.c_str() ) ) + { + video::ITexture* t = Driver->getTexture( loadFile.c_str() ); + if ( t ) + return t; + } + } + } + return 0; +} +*/ + +//! loads the textures +void CQ3LevelMesh::loadTextures2() +{ + if (!Driver) + return; + + s32 t; + + // load lightmaps. + Lightmap.set_used(NumLightMaps+1); + + c8 lightmapname[255]; + core::dimension2d lmapsize(128,128); + + video::IImage* lmapImg; + for ( t = 0; t < NumLightMaps ; ++t) + { + sprintf(lightmapname, "%s.lightmap.%d", LevelName.c_str(), t); + + // lightmap is a CTexture::R8G8B8 format + lmapImg = Driver->createImageFromData( + video::ECF_R8G8B8, + lmapsize, + LightMaps[t].imageBits, true, false ); + + Lightmap[t] = Driver->addTexture ( lightmapname, lmapImg ); + lmapImg->drop (); + + } + + // load textures + Tex.set_used( NumTextures+1 ); + + const quake3::SShader * shader; + + core::stringc list; + core::stringc check; + quake3::tTexArray textureArray; + + for ( t=0; t< NumTextures; ++t) + { + Tex[t].ShaderID = -1; + Tex[t].Texture = 0; + + list = ""; + + // get a shader ( if one exists ) + shader = getShader ( Textures[t].strName, 0 ); + if ( shader ) + { + Tex[t].ShaderID = shader->id; + + // if texture name == stage1 Texture map + const quake3::SVarGroup * group; + + group = shader->getGroup ( 2 ); + if ( group ) + { + if ( core::cutFilenameExtension ( check, group->get ( "map" ) ) == Textures[t].strName ) + { + list += check; + } + else + if ( check == "$lightmap" ) + { + // we check if lightmap is in stage 1 and texture in stage 2 + group = shader->getGroup ( 3 ); + if ( group ) + list += group->get ( "map" ); + } + } + } + else + { + // no shader, take it + list += Textures[t].strName; + } + + u32 pos = 0; + quake3::getTextures ( textureArray, list, pos, FileSystem, Driver ); + + Tex[t].Texture = textureArray[0]; + } +} + + +//! Returns an axis aligned bounding box of the mesh. +//! \return A bounding box of this mesh is returned. +const core::aabbox3d& CQ3LevelMesh::getBoundingBox() const +{ + return Mesh[0]->getBoundingBox(); +} + + +//! Returns the type of the animated mesh. +E_ANIMATED_MESH_TYPE CQ3LevelMesh::getMeshType() const +{ + return scene::EAMT_BSP; +} + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CQ3LevelMesh.h b/src/dep/src/irrlicht/CQ3LevelMesh.h index 36c1ce3..8743aad 100644 --- a/src/dep/src/irrlicht/CQ3LevelMesh.h +++ b/src/dep/src/irrlicht/CQ3LevelMesh.h @@ -1,407 +1,407 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_Q3_LEVEL_MESH_H_INCLUDED__ -#define __C_Q3_LEVEL_MESH_H_INCLUDED__ - -#include "IQ3LevelMesh.h" -#include "IReadFile.h" -#include "IFileSystem.h" -#include "SMesh.h" -#include "IVideoDriver.h" -#include "irrString.h" -#include "ISceneManager.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - struct SMeshBufferLightMap; - - class CQ3LevelMesh : public IQ3LevelMesh - { - public: - - //! constructor - CQ3LevelMesh(io::IFileSystem* fs, video::IVideoDriver* driver, scene::ISceneManager* smgr); - - //! destructor - virtual ~CQ3LevelMesh(); - - //! loads a level from a .bsp-File. Also tries to load all needed textures. Returns true if successful. - bool loadFile(io::IReadFile* file); - - //! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. - virtual s32 getFrameCount(); - - //! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. - virtual IMesh* getMesh(s32 frameInMs, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1); - - virtual void releaseMesh ( s32 index ); - - //! Returns an axis aligned bounding box of the mesh. - //! \return A bounding box of this mesh is returned. - virtual const core::aabbox3d& getBoundingBox() const; - - //! Returns the type of the animated mesh. - virtual E_ANIMATED_MESH_TYPE getMeshType() const; - - //! loads the shader definition - virtual const quake3::SShader * getShader ( const c8 * filename, s32 fileNameIsValid ); - - //! returns a already loaded Shader - virtual const quake3::SShader * getShader ( u32 index ) const; - - - //! get's an interface to the entities - virtual const quake3::tQ3EntityList & getEntityList (); - - private: - - //! constructs a mesh from the quake 3 level file. - void constructMesh(); - - //! loads the textures - void loadTextures(); - - void constructMesh2(); - - void loadTextures2(); - - struct STexShader - { - video::ITexture* Texture; - s32 ShaderID; - }; - - core::array< STexShader > Tex; - core::array Lightmap; - - enum eLumps - { - kEntities = 0, // Stores player/object positions, etc... - kTextures, // Stores texture information - kPlanes, // Stores the splitting planes - kNodes, // Stores the BSP nodes - kLeafs, // Stores the leafs of the nodes - kLeafFaces, // Stores the leaf's indices into the faces - kLeafBrushes, // Stores the leaf's indices into the brushes - kModels, // Stores the info of world models - kBrushes, // Stores the brushes info (for collision) - kBrushSides, // Stores the brush surfaces info - kVertices, // Stores the level vertices - kMeshVerts, // Stores the model vertices offsets - kShaders, // Stores the shader files (blending, anims..) - kFaces, // Stores the faces for the level - kLightmaps, // Stores the lightmaps for the level - kLightVolumes, // Stores extra world lighting information - kVisData, // Stores PVS and cluster info (visibility) - kMaxLumps // A constant to store the number of lumps - }; - - struct tBSPLump - { - s32 offset; - s32 length; - }; - - struct tBSPHeader - { - s32 strID; // This should always be 'IBSP' - s32 version; // This should be 0x2e for Quake 3 files - }; - - struct tBSPVertex - { - f32 vPosition[3]; // (x, y, z) position. - f32 vTextureCoord[2]; // (u, v) texture coordinate - f32 vLightmapCoord[2]; // (u, v) lightmap coordinate - f32 vNormal[3]; // (x, y, z) normal vector - u8 color[4]; // RGBA color for the vertex - }; - - struct tBSPFace - { - s32 textureID; // The index into the texture array - s32 effect; // The index for the effects (or -1 = n/a) - s32 type; // 1=polygon, 2=patch, 3=mesh, 4=billboard - s32 vertexIndex; // The index into this face's first vertex - s32 numOfVerts; // The number of vertices for this face - s32 meshVertIndex; // The index into the first meshvertex - s32 numMeshVerts; // The number of mesh vertices - s32 lightmapID; // The texture index for the lightmap - s32 lMapCorner[2]; // The face's lightmap corner in the image - s32 lMapSize[2]; // The size of the lightmap section - f32 lMapPos[3]; // The 3D origin of lightmap. - f32 lMapBitsets[2][3]; // The 3D space for s and t unit vectors. - f32 vNormal[3]; // The face normal. - s32 size[2]; // The bezier patch dimensions. - }; - - struct tBSPTexture - { - c8 strName[64]; // The name of the texture w/o the extension - u32 flags; // The surface flags (unknown) - u32 contents; // The content flags (unknown) - }; - - struct tBSPLightmap - { - u8 imageBits[128][128][3]; // The RGB data in a 128x128 image - }; - - struct tBSPNode - { - s32 plane; // The index into the planes array - s32 front; // The child index for the front node - s32 back; // The child index for the back node - s32 mins[3]; // The bounding box min position. - s32 maxs[3]; // The bounding box max position. - }; - - struct tBSPLeaf - { - s32 cluster; // The visibility cluster - s32 area; // The area portal - s32 mins[3]; // The bounding box min position - s32 maxs[3]; // The bounding box max position - s32 leafface; // The first index into the face array - s32 numOfLeafFaces; // The number of faces for this leaf - s32 leafBrush; // The first index for into the brushes - s32 numOfLeafBrushes; // The number of brushes for this leaf - }; - - struct tBSPPlane - { - f32 vNormal[3]; // Plane normal. - f32 d; // The plane distance from origin - }; - - struct tBSPVisData - { - s32 numOfClusters; // The number of clusters - s32 bytesPerCluster; // Bytes (8 bits) in the cluster's bitset - c8 *pBitsets; // Array of bytes holding the cluster vis. - }; - - struct tBSPBrush - { - s32 brushSide; // The starting brush side for the brush - s32 numOfBrushSides; // Number of brush sides for the brush - s32 textureID; // The texture index for the brush - }; - - struct tBSPBrushSide - { - s32 plane; // The plane index - s32 textureID; // The texture index - }; - - struct tBSPModel - { - f32 min[3]; // The min position for the bounding box - f32 max[3]; // The max position for the bounding box. - s32 faceIndex; // The first face index in the model - s32 numOfFaces; // The number of faces in the model - s32 brushIndex; // The first brush index in the model - s32 numOfBrushes; // The number brushes for the model - }; - - struct tBSPShader - { - c8 strName[64]; // The name of the shader file - s32 brushIndex; // The brush index for this shader - s32 unknown; // This is 99% of the time 5 - }; - - struct tBSPLights - { - u8 ambient[3]; // This is the ambient color in RGB - u8 directional[3]; // This is the directional color in RGB - u8 direction[2]; // The direction of the light: [phi,theta] - }; - - void loadTextures (tBSPLump* l, io::IReadFile* file); // Load the textures - void loadLightmaps (tBSPLump* l, io::IReadFile* file); // Load the lightmaps - void loadVerts (tBSPLump* l, io::IReadFile* file); // Load the vertices - void loadFaces (tBSPLump* l, io::IReadFile* file); // Load the faces - void loadPlanes (tBSPLump* l, io::IReadFile* file); // Load the Planes of the BSP - void loadNodes (tBSPLump* l, io::IReadFile* file); // load the Nodes of the BSP - void loadLeafs (tBSPLump* l, io::IReadFile* file); // load the Leafs of the BSP - void loadLeafFaces (tBSPLump* l, io::IReadFile* file); // load the Faces of the Leafs of the BSP - void loadVisData (tBSPLump* l, io::IReadFile* file); // load the visibility data of the clusters - void loadEntities (tBSPLump* l, io::IReadFile* file); // load the entities - void loadModels (tBSPLump* l, io::IReadFile* file); // load the models - void loadMeshVerts (tBSPLump* l, io::IReadFile* file); // load the mesh vertices - void loadBrushes (tBSPLump* l, io::IReadFile* file); // load the brushes of the BSP - void loadBrushSides (tBSPLump* l, io::IReadFile* file); // load the brushsides of the BSP - void loadLeafBrushes(tBSPLump* l, io::IReadFile* file); // load the brushes of the leaf - void loadShaders (tBSPLump* l, io::IReadFile* file); // load the shaders - - // second parameter i is the zero based index of the current face. - void createCurvedSurface(SMeshBufferLightMap* meshBuffer, s32 i); - - //bi-quadratic bezier patches - void createCurvedSurface2 ( SMeshBufferLightMap* meshBuffer, - s32 faceIndex, - s32 patchTesselation, - s32 storevertexcolor - ); - - void createCurvedSurface3 ( SMeshBufferLightMap* meshBuffer, - s32 faceIndex, - s32 patchTesselation, - s32 storevertexcolor - ); - - f32 Blend( const f64 s[3], const f64 t[3], const tBSPVertex *v[9], int offset); - - struct S3DVertex2TCoords_64 - { - core::vector3d Pos; - core::vector3d Normal; - video::SColorf Color; - core::vector2d TCoords; - core::vector2d TCoords2; - - void copyto ( video::S3DVertex2TCoords &dest ) const; - - S3DVertex2TCoords_64() {} - S3DVertex2TCoords_64(const core::vector3d& pos, const core::vector3d& normal, const video::SColorf& color, - const core::vector2d& tcoords, const core::vector2d& tcoords2) - : Pos(pos), Normal(normal), Color(color), TCoords(tcoords), TCoords2(tcoords2) {} - - S3DVertex2TCoords_64 getInterpolated_quadratic(const S3DVertex2TCoords_64& v2, const S3DVertex2TCoords_64& v3, const f64 d) const - { - return S3DVertex2TCoords_64 ( - Pos.getInterpolated_quadratic ( v2.Pos, v3.Pos, d ), - Normal.getInterpolated_quadratic ( v2.Normal, v3.Normal, d ), - Color.getInterpolated_quadratic ( v2.Color, v3.Color, (f32) d ), - TCoords.getInterpolated_quadratic ( v2.TCoords, v3.TCoords, d ), - TCoords2.getInterpolated_quadratic ( v2.TCoords2, v3.TCoords2, d ) - ); - } - }; - - void copy ( video::S3DVertex2TCoords * dest, const tBSPVertex * source, s32 vertexcolor ) const; - void copy ( S3DVertex2TCoords_64 * dest, const tBSPVertex * source, s32 vertexcolor ) const; - - - struct SBezier - { - SMeshBufferLightMap *Patch; - S3DVertex2TCoords_64 control[9]; - - void tesselate(s32 level); - - private: - s32 Level; - - core::array column[3]; - - }; - SBezier Bezier; - - s32 PatchTesselation; - - tBSPLump Lumps[kMaxLumps]; - - tBSPTexture* Textures; - s32 NumTextures; - - tBSPLightmap* LightMaps; - s32 NumLightMaps; - - tBSPVertex* Vertices; - s32 NumVertices; - - tBSPFace* Faces; - s32 NumFaces; - - tBSPPlane* Planes; - s32 NumPlanes; - - tBSPNode* Nodes; - s32 NumNodes; - - tBSPLeaf* Leafs; - s32 NumLeafs; - - s32 *LeafFaces; - s32 NumLeafFaces; - - s32 *MeshVerts; // The vertex offsets for a mesh - s32 NumMeshVerts; - - tBSPBrush* Brushes; - s32 NumBrushes; - - scene::SMesh* Mesh[quake3::E_Q3_MESH_SIZE]; - video::IVideoDriver* Driver; - core::stringc LevelName; - io::IFileSystem* FileSystem; // needs because there are no file extenstions stored in .bsp files. - - // Additional content - scene::ISceneManager* SceneManager; - enum eToken - { - Q3_TOKEN_UNRESOLVED = 0, - Q3_TOKEN_EOF = 1, - Q3_TOKEN_START_LIST, - Q3_TOKEN_END_LIST, - Q3_TOKEN_ENTITY, - Q3_TOKEN_TOKEN, - Q3_TOKEN_EOL, - Q3_TOKEN_COMMENT, - Q3_TOKEN_MATH_DIVIDE, - Q3_TOKEN_MATH_ADD, - Q3_TOKEN_MATH_MULTIPY - }; - struct SQ3Parser - { - const c8 *source; - u32 sourcesize; - u32 index; - core::stringc token; - u32 tokenresult; - }; - SQ3Parser Parser; - - - typedef void ( CQ3LevelMesh::*tParserCallback ) ( quake3::SVarGroupList *& groupList ); - void parser_parse ( const void * data, u32 size, tParserCallback callback ); - void parser_nextToken (); - - void dumpVarGroup ( const quake3::SVarGroup * group, s32 stack ) const; - - void scriptcallback_entity ( quake3::SVarGroupList *& grouplist ); - quake3::tQ3EntityList Entity; - - void scriptcallback_shader ( quake3::SVarGroupList *& grouplist ); - core::array < quake3::SShader > Shader; - quake3::tStringList ShaderFile; - void InitShader (); - void ReleaseShader (); - void ReleaseEntity (); - - - s32 setShaderMaterial ( video::SMaterial & material, const tBSPFace * face ) const; - - struct SToBuffer - { - s32 takeVertexColor; - u32 index; - }; - - void cleanMeshes (); - void calcBoundingBoxes (); - - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_Q3_LEVEL_MESH_H_INCLUDED__ +#define __C_Q3_LEVEL_MESH_H_INCLUDED__ + +#include "IQ3LevelMesh.h" +#include "IReadFile.h" +#include "IFileSystem.h" +#include "SMesh.h" +#include "IVideoDriver.h" +#include "irrString.h" +#include "ISceneManager.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + struct SMeshBufferLightMap; + + class CQ3LevelMesh : public IQ3LevelMesh + { + public: + + //! constructor + CQ3LevelMesh(io::IFileSystem* fs, video::IVideoDriver* driver, scene::ISceneManager* smgr); + + //! destructor + virtual ~CQ3LevelMesh(); + + //! loads a level from a .bsp-File. Also tries to load all needed textures. Returns true if successful. + bool loadFile(io::IReadFile* file); + + //! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. + virtual s32 getFrameCount(); + + //! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. + virtual IMesh* getMesh(s32 frameInMs, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1); + + virtual void releaseMesh ( s32 index ); + + //! Returns an axis aligned bounding box of the mesh. + //! \return A bounding box of this mesh is returned. + virtual const core::aabbox3d& getBoundingBox() const; + + //! Returns the type of the animated mesh. + virtual E_ANIMATED_MESH_TYPE getMeshType() const; + + //! loads the shader definition + virtual const quake3::SShader * getShader ( const c8 * filename, s32 fileNameIsValid ); + + //! returns a already loaded Shader + virtual const quake3::SShader * getShader ( u32 index ) const; + + + //! get's an interface to the entities + virtual const quake3::tQ3EntityList & getEntityList (); + + private: + + //! constructs a mesh from the quake 3 level file. + void constructMesh(); + + //! loads the textures + void loadTextures(); + + void constructMesh2(); + + void loadTextures2(); + + struct STexShader + { + video::ITexture* Texture; + s32 ShaderID; + }; + + core::array< STexShader > Tex; + core::array Lightmap; + + enum eLumps + { + kEntities = 0, // Stores player/object positions, etc... + kTextures, // Stores texture information + kPlanes, // Stores the splitting planes + kNodes, // Stores the BSP nodes + kLeafs, // Stores the leafs of the nodes + kLeafFaces, // Stores the leaf's indices into the faces + kLeafBrushes, // Stores the leaf's indices into the brushes + kModels, // Stores the info of world models + kBrushes, // Stores the brushes info (for collision) + kBrushSides, // Stores the brush surfaces info + kVertices, // Stores the level vertices + kMeshVerts, // Stores the model vertices offsets + kShaders, // Stores the shader files (blending, anims..) + kFaces, // Stores the faces for the level + kLightmaps, // Stores the lightmaps for the level + kLightVolumes, // Stores extra world lighting information + kVisData, // Stores PVS and cluster info (visibility) + kMaxLumps // A constant to store the number of lumps + }; + + struct tBSPLump + { + s32 offset; + s32 length; + }; + + struct tBSPHeader + { + s32 strID; // This should always be 'IBSP' + s32 version; // This should be 0x2e for Quake 3 files + }; + + struct tBSPVertex + { + f32 vPosition[3]; // (x, y, z) position. + f32 vTextureCoord[2]; // (u, v) texture coordinate + f32 vLightmapCoord[2]; // (u, v) lightmap coordinate + f32 vNormal[3]; // (x, y, z) normal vector + u8 color[4]; // RGBA color for the vertex + }; + + struct tBSPFace + { + s32 textureID; // The index into the texture array + s32 effect; // The index for the effects (or -1 = n/a) + s32 type; // 1=polygon, 2=patch, 3=mesh, 4=billboard + s32 vertexIndex; // The index into this face's first vertex + s32 numOfVerts; // The number of vertices for this face + s32 meshVertIndex; // The index into the first meshvertex + s32 numMeshVerts; // The number of mesh vertices + s32 lightmapID; // The texture index for the lightmap + s32 lMapCorner[2]; // The face's lightmap corner in the image + s32 lMapSize[2]; // The size of the lightmap section + f32 lMapPos[3]; // The 3D origin of lightmap. + f32 lMapBitsets[2][3]; // The 3D space for s and t unit vectors. + f32 vNormal[3]; // The face normal. + s32 size[2]; // The bezier patch dimensions. + }; + + struct tBSPTexture + { + c8 strName[64]; // The name of the texture w/o the extension + u32 flags; // The surface flags (unknown) + u32 contents; // The content flags (unknown) + }; + + struct tBSPLightmap + { + u8 imageBits[128][128][3]; // The RGB data in a 128x128 image + }; + + struct tBSPNode + { + s32 plane; // The index into the planes array + s32 front; // The child index for the front node + s32 back; // The child index for the back node + s32 mins[3]; // The bounding box min position. + s32 maxs[3]; // The bounding box max position. + }; + + struct tBSPLeaf + { + s32 cluster; // The visibility cluster + s32 area; // The area portal + s32 mins[3]; // The bounding box min position + s32 maxs[3]; // The bounding box max position + s32 leafface; // The first index into the face array + s32 numOfLeafFaces; // The number of faces for this leaf + s32 leafBrush; // The first index for into the brushes + s32 numOfLeafBrushes; // The number of brushes for this leaf + }; + + struct tBSPPlane + { + f32 vNormal[3]; // Plane normal. + f32 d; // The plane distance from origin + }; + + struct tBSPVisData + { + s32 numOfClusters; // The number of clusters + s32 bytesPerCluster; // Bytes (8 bits) in the cluster's bitset + c8 *pBitsets; // Array of bytes holding the cluster vis. + }; + + struct tBSPBrush + { + s32 brushSide; // The starting brush side for the brush + s32 numOfBrushSides; // Number of brush sides for the brush + s32 textureID; // The texture index for the brush + }; + + struct tBSPBrushSide + { + s32 plane; // The plane index + s32 textureID; // The texture index + }; + + struct tBSPModel + { + f32 min[3]; // The min position for the bounding box + f32 max[3]; // The max position for the bounding box. + s32 faceIndex; // The first face index in the model + s32 numOfFaces; // The number of faces in the model + s32 brushIndex; // The first brush index in the model + s32 numOfBrushes; // The number brushes for the model + }; + + struct tBSPShader + { + c8 strName[64]; // The name of the shader file + s32 brushIndex; // The brush index for this shader + s32 unknown; // This is 99% of the time 5 + }; + + struct tBSPLights + { + u8 ambient[3]; // This is the ambient color in RGB + u8 directional[3]; // This is the directional color in RGB + u8 direction[2]; // The direction of the light: [phi,theta] + }; + + void loadTextures (tBSPLump* l, io::IReadFile* file); // Load the textures + void loadLightmaps (tBSPLump* l, io::IReadFile* file); // Load the lightmaps + void loadVerts (tBSPLump* l, io::IReadFile* file); // Load the vertices + void loadFaces (tBSPLump* l, io::IReadFile* file); // Load the faces + void loadPlanes (tBSPLump* l, io::IReadFile* file); // Load the Planes of the BSP + void loadNodes (tBSPLump* l, io::IReadFile* file); // load the Nodes of the BSP + void loadLeafs (tBSPLump* l, io::IReadFile* file); // load the Leafs of the BSP + void loadLeafFaces (tBSPLump* l, io::IReadFile* file); // load the Faces of the Leafs of the BSP + void loadVisData (tBSPLump* l, io::IReadFile* file); // load the visibility data of the clusters + void loadEntities (tBSPLump* l, io::IReadFile* file); // load the entities + void loadModels (tBSPLump* l, io::IReadFile* file); // load the models + void loadMeshVerts (tBSPLump* l, io::IReadFile* file); // load the mesh vertices + void loadBrushes (tBSPLump* l, io::IReadFile* file); // load the brushes of the BSP + void loadBrushSides (tBSPLump* l, io::IReadFile* file); // load the brushsides of the BSP + void loadLeafBrushes(tBSPLump* l, io::IReadFile* file); // load the brushes of the leaf + void loadShaders (tBSPLump* l, io::IReadFile* file); // load the shaders + + // second parameter i is the zero based index of the current face. + void createCurvedSurface(SMeshBufferLightMap* meshBuffer, s32 i); + + //bi-quadratic bezier patches + void createCurvedSurface2 ( SMeshBufferLightMap* meshBuffer, + s32 faceIndex, + s32 patchTesselation, + s32 storevertexcolor + ); + + void createCurvedSurface3 ( SMeshBufferLightMap* meshBuffer, + s32 faceIndex, + s32 patchTesselation, + s32 storevertexcolor + ); + + f32 Blend( const f64 s[3], const f64 t[3], const tBSPVertex *v[9], int offset); + + struct S3DVertex2TCoords_64 + { + core::vector3d Pos; + core::vector3d Normal; + video::SColorf Color; + core::vector2d TCoords; + core::vector2d TCoords2; + + void copyto ( video::S3DVertex2TCoords &dest ) const; + + S3DVertex2TCoords_64() {} + S3DVertex2TCoords_64(const core::vector3d& pos, const core::vector3d& normal, const video::SColorf& color, + const core::vector2d& tcoords, const core::vector2d& tcoords2) + : Pos(pos), Normal(normal), Color(color), TCoords(tcoords), TCoords2(tcoords2) {} + + S3DVertex2TCoords_64 getInterpolated_quadratic(const S3DVertex2TCoords_64& v2, const S3DVertex2TCoords_64& v3, const f64 d) const + { + return S3DVertex2TCoords_64 ( + Pos.getInterpolated_quadratic ( v2.Pos, v3.Pos, d ), + Normal.getInterpolated_quadratic ( v2.Normal, v3.Normal, d ), + Color.getInterpolated_quadratic ( v2.Color, v3.Color, (f32) d ), + TCoords.getInterpolated_quadratic ( v2.TCoords, v3.TCoords, d ), + TCoords2.getInterpolated_quadratic ( v2.TCoords2, v3.TCoords2, d ) + ); + } + }; + + void copy ( video::S3DVertex2TCoords * dest, const tBSPVertex * source, s32 vertexcolor ) const; + void copy ( S3DVertex2TCoords_64 * dest, const tBSPVertex * source, s32 vertexcolor ) const; + + + struct SBezier + { + SMeshBufferLightMap *Patch; + S3DVertex2TCoords_64 control[9]; + + void tesselate(s32 level); + + private: + s32 Level; + + core::array column[3]; + + }; + SBezier Bezier; + + s32 PatchTesselation; + + tBSPLump Lumps[kMaxLumps]; + + tBSPTexture* Textures; + s32 NumTextures; + + tBSPLightmap* LightMaps; + s32 NumLightMaps; + + tBSPVertex* Vertices; + s32 NumVertices; + + tBSPFace* Faces; + s32 NumFaces; + + tBSPPlane* Planes; + s32 NumPlanes; + + tBSPNode* Nodes; + s32 NumNodes; + + tBSPLeaf* Leafs; + s32 NumLeafs; + + s32 *LeafFaces; + s32 NumLeafFaces; + + s32 *MeshVerts; // The vertex offsets for a mesh + s32 NumMeshVerts; + + tBSPBrush* Brushes; + s32 NumBrushes; + + scene::SMesh* Mesh[quake3::E_Q3_MESH_SIZE]; + video::IVideoDriver* Driver; + core::stringc LevelName; + io::IFileSystem* FileSystem; // needs because there are no file extenstions stored in .bsp files. + + // Additional content + scene::ISceneManager* SceneManager; + enum eToken + { + Q3_TOKEN_UNRESOLVED = 0, + Q3_TOKEN_EOF = 1, + Q3_TOKEN_START_LIST, + Q3_TOKEN_END_LIST, + Q3_TOKEN_ENTITY, + Q3_TOKEN_TOKEN, + Q3_TOKEN_EOL, + Q3_TOKEN_COMMENT, + Q3_TOKEN_MATH_DIVIDE, + Q3_TOKEN_MATH_ADD, + Q3_TOKEN_MATH_MULTIPY + }; + struct SQ3Parser + { + const c8 *source; + u32 sourcesize; + u32 index; + core::stringc token; + u32 tokenresult; + }; + SQ3Parser Parser; + + + typedef void ( CQ3LevelMesh::*tParserCallback ) ( quake3::SVarGroupList *& groupList ); + void parser_parse ( const void * data, u32 size, tParserCallback callback ); + void parser_nextToken (); + + void dumpVarGroup ( const quake3::SVarGroup * group, s32 stack ) const; + + void scriptcallback_entity ( quake3::SVarGroupList *& grouplist ); + quake3::tQ3EntityList Entity; + + void scriptcallback_shader ( quake3::SVarGroupList *& grouplist ); + core::array < quake3::SShader > Shader; + quake3::tStringList ShaderFile; + void InitShader (); + void ReleaseShader (); + void ReleaseEntity (); + + + s32 setShaderMaterial ( video::SMaterial & material, const tBSPFace * face ) const; + + struct SToBuffer + { + s32 takeVertexColor; + u32 index; + }; + + void cleanMeshes (); + void calcBoundingBoxes (); + + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CQuake3ShaderSceneNode.cpp b/src/dep/src/irrlicht/CQuake3ShaderSceneNode.cpp index 00eacaf..1e155f9 100644 --- a/src/dep/src/irrlicht/CQuake3ShaderSceneNode.cpp +++ b/src/dep/src/irrlicht/CQuake3ShaderSceneNode.cpp @@ -1,706 +1,706 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CQuake3ShaderSceneNode.h" -#include "IVideoDriver.h" -#include "ICameraSceneNode.h" - -namespace irr -{ -namespace scene -{ - - -CQuake3ShaderSceneNode::CQuake3ShaderSceneNode(scene::ISceneNode* parent, scene::ISceneManager* mgr,s32 id, - io::IFileSystem *fileSystem, - scene::IMeshBuffer *buffer, const quake3::SShader * shader - ) -: scene::ISceneNode(parent, mgr, id), Shader ( shader ),TimeAbs ( 0.f ) -{ - - #ifdef _DEBUG - core::stringc dName = "CQuake3ShaderSceneNode "; - dName += Shader->name; - - setDebugName( dName.c_str() ); - #endif - - // name the Scene Node - this->Name = Shader->name; - - // clone meshbuffer to modifiable buffer - clone ( static_cast< scene::SMeshBufferLightMap *> ( buffer ) ); - - // load all Textures in all stages - loadTextures ( fileSystem ); -} - -/* -*/ -CQuake3ShaderSceneNode::~CQuake3ShaderSceneNode () -{ -} - -/* - create single copies -*/ -void CQuake3ShaderSceneNode::clone ( scene::SMeshBufferLightMap * buffer ) -{ - Original.Material = buffer->Material; - MeshBuffer.Material = buffer->Material; - - Original.Indices = buffer->Indices; - MeshBuffer.Indices = buffer->Indices; - - const u32 vsize = buffer->Vertices.size (); - - Original.Vertices.set_used ( vsize ); - MeshBuffer.Vertices.set_used ( vsize ); - for ( u32 i = 0; i!= vsize; ++i ) - { - const video::S3DVertex2TCoords * src = &buffer->Vertices[i]; - Original.Vertices[i] = *src; - - video::S3DVertex * d = &MeshBuffer.Vertices[i]; - - d->Pos = src->Pos; - d->Color = 0xFFFFFFFF; //src->Color; - d->Normal = src->Normal; - d->TCoords = src->TCoords; - } - - MeshBuffer.recalculateBoundingBox (); - // used for sorting - MeshBuffer.Material.Textures[0] = (video::ITexture*) Shader; -} - - - -/* - load the textures for all stages -*/ -void CQuake3ShaderSceneNode::loadTextures ( io::IFileSystem * fileSystem ) -{ - const quake3::SVarGroup *group; - u32 i; - - // clear all stages and prefill empty - Q3Texture.clear (); - for ( i = 0; i != Shader->VarGroup->VariableGroup.size (); ++i ) - { - Q3Texture.push_back ( SQ3Texture() ); - } - - u32 pos; - - // get texture map - for ( i = 0; i < Shader->VarGroup->VariableGroup.size (); ++i ) - { - group = Shader->getGroup ( i ); - - const core::stringc &mapname = group->get ( "map" ); - if ( 0 == mapname.size () ) - continue; - - // our lightmap is passed in material.Texture[2] - if ( mapname == "$lightmap" ) - { - Q3Texture [i].Texture.push_back ( Original.getMaterial().Textures[1] ); - } - else - { - pos = 0; - quake3::getTextures ( Q3Texture [i].Texture, mapname, pos, fileSystem, SceneManager->getVideoDriver() ); - } - } - - // get anim map - for ( i = 0; i < Shader->VarGroup->VariableGroup.size (); ++i ) - { - if ( Q3Texture [i].Texture.size() ) - continue; - - group = Shader->getGroup ( i ); - - const core::stringc &animmap = group->get ( "animmap" ); - if ( 0 == animmap.size () ) - continue; - - // first parameter is frequency - pos = 0; - Q3Texture [i].TextureFrequency = core::max_ ( 0.0001f, quake3::getAsFloat ( animmap, pos ) ); - - quake3::getTextures ( Q3Texture [i].Texture, animmap, pos,fileSystem, SceneManager->getVideoDriver() ); - } - - // get clamp map - for ( i = 0; i < Shader->VarGroup->VariableGroup.size (); ++i ) - { - if ( Q3Texture [i].Texture.size() ) - continue; - - group = Shader->getGroup ( i ); - - const core::stringc &clampmap = group->get ( "clampmap" ); - if ( 0 == clampmap.size () ) - continue; - - Q3Texture [i].TextureAddressMode = video::ETC_CLAMP; - pos = 0; - quake3::getTextures ( Q3Texture [i].Texture, clampmap, pos,fileSystem, SceneManager->getVideoDriver() ); - } -} - -/* - Register each texture stage, if first is visible -*/ -void CQuake3ShaderSceneNode::OnRegisterSceneNode() -{ - PassedCulling = 0; - StageCall = 0; - if ( !IsVisible) - return; - - u32 first = 1; - for ( u32 i = 1; i < Q3Texture.size(); ++i ) - { - if ( 0 == Q3Texture [ i ].Texture.size() && i >= 2 ) - continue; - - scene::E_SCENE_NODE_RENDER_PASS time = (scene::E_SCENE_NODE_RENDER_PASS) ( scene::ESNRP_SHADER_0 + i ); - if ( first ) - { - setAutomaticCulling ( scene::EAC_BOX ); - PassedCulling = SceneManager->registerNodeForRendering(this, time ); - setAutomaticCulling ( scene::EAC_OFF ); - first = 0; - } - else - if ( PassedCulling ) - { - SceneManager->registerNodeForRendering(this, time ); - } - } -} - -/* - render in multipass technique -*/ -void CQuake3ShaderSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - const u32 stage = SceneManager->getSceneNodeRenderPass() - scene::ESNRP_SHADER_0; - - video::SMaterial material; - - const quake3::SVarGroup *group; - - // generic stage - group = Shader->getGroup ( 1 ); - material.BackfaceCulling = quake3::getBackfaceCulling ( group->get ( "cull" ) ); - - // advance current stage - core::matrix4 texture; - animate ( stage, texture ); - - // stage 1 finished, no drawing stage ( vertex transform only ) - if ( stage == 1 ) - return; - - // current stage - group = Shader->getGroup ( stage ); - - - SQ3Texture &q = Q3Texture [ stage]; - - material.Lighting = false; - material.Textures[0] = q.Texture [ q.TextureIndex ]; - material.Textures[1] = 0; - material.ZBuffer = quake3::getDepthFunction ( group->get ( "depthfunc" ) ); - material.ZWriteEnable = (0 == StageCall ); - material.NormalizeNormals = false; - - quake3::SBlendFunc blendfunc; - quake3::getBlendFunc ( group->get ( "blendfunc" ), blendfunc ); - quake3::getBlendFunc ( group->get ( "alphafunc" ), blendfunc ); - - material.MaterialType = blendfunc.type; - material.MaterialTypeParam = blendfunc.param; - -/* - if ( textureTransform ) - { - transformtex ( texture, q.TextureAddressMode ); - } -*/ - material.TextureWrap[0] = q.TextureAddressMode; - material.TextureWrap[1] = material.TextureWrap[0]; - driver->setTransform ( video::ETS_TEXTURE_0, texture ); - - driver->setMaterial( material ); - - if ( 0 == StageCall ) - { - driver->setTransform(video::ETS_WORLD, core::matrix4() ); - } - - driver->drawMeshBuffer( &MeshBuffer ); - - StageCall += 1; -} - - -/*! -*/ -void CQuake3ShaderSceneNode::vertextransform_wave ( f32 dt, quake3::SModifierFunction &function ) -{ - function.wave = core::reciprocal ( function.wave ); - - const f32 phase = function.phase; - - const u32 vsize = MeshBuffer.Vertices.size(); - for ( u32 i = 0; i != vsize; ++i ) - { - const video::S3DVertex2TCoords &src = Original.Vertices[i]; - video::S3DVertex &dst = MeshBuffer.Vertices[i]; - - f32 wavephase = (src.Pos.X + src.Pos.Y + src.Pos.Z) * function.wave; - function.phase = phase + wavephase; - - const f32 f = function.evaluate ( dt ); - - dst.Pos.X = src.Pos.X + f * src.Normal.X; - dst.Pos.Y = src.Pos.Y + f * src.Normal.Y; - dst.Pos.Z = src.Pos.Z + f * src.Normal.Z; - } -} - -/*! -*/ -void CQuake3ShaderSceneNode::vertextransform_bulge ( f32 dt, quake3::SModifierFunction &function ) -{ - function.func = 0; - function.wave = core::reciprocal ( function.bulgewidth ); - - dt *= function.bulgespeed * 0.1f; - const f32 phase = function.phase; - - const u32 vsize = MeshBuffer.Vertices.size(); - for ( u32 i = 0; i != vsize; ++i ) - { - const video::S3DVertex2TCoords &src = Original.Vertices[i]; - video::S3DVertex &dst = MeshBuffer.Vertices[i]; - - f32 wavephase = (Original.Vertices[i].TCoords.X ) * function.wave; - function.phase = phase + wavephase; - - const f32 f = function.evaluate ( dt ); - - dst.Pos.X = src.Pos.X + f * src.Normal.X; - dst.Pos.Y = src.Pos.Y + f * src.Normal.Y; - dst.Pos.Z = src.Pos.Z + f * src.Normal.Z; - } -} - -/*! -*/ -void CQuake3ShaderSceneNode::vertextransform_autosprite ( f32 dt, quake3::SModifierFunction &function ) -{ - const core::matrix4 &m = SceneManager->getActiveCamera()->getViewFrustum()->Matrices [ video::ETS_VIEW ]; - const core::vector3df view ( -m[2], -m[6] , -m[10] ); - - const u32 vsize = MeshBuffer.Vertices.size(); - - core::aabbox3df box; - u32 g; - - for ( u32 i = 0; i < vsize; i += 4 ) - { - // in pairs of 4 - box.reset ( Original.Vertices[i].Pos ); - for ( g = 1; g != 4; ++g ) - { - box.addInternalPoint ( Original.Vertices[i + g].Pos ); - } - - core::vector3df c = box.getCenter (); - f32 sh = 0.5f * ( box.MaxEdge.Z - box.MinEdge.Z ); - f32 sv = 0.5f * ( box.MaxEdge.Y - box.MinEdge.Y ); - - const core::vector3df h ( m[0] * sh, m[4] * sh, m[8] * sh ); - const core::vector3df v ( m[1] * sv, m[5] * sv, m[9] * sv ); - - MeshBuffer.Vertices[ i + 0 ].Pos = c + h + v; - MeshBuffer.Vertices[ i + 1 ].Pos = c - h - v; - MeshBuffer.Vertices[ i + 2 ].Pos = c + h - v; - MeshBuffer.Vertices[ i + 3 ].Pos = c - h + v; - - MeshBuffer.Vertices[ i + 0 ].Normal = view; - MeshBuffer.Vertices[ i + 1 ].Normal = view; - MeshBuffer.Vertices[ i + 2 ].Normal = view; - MeshBuffer.Vertices[ i + 3 ].Normal = view; - } -} - -/* - Generate Vertex Color -*/ -void CQuake3ShaderSceneNode::rgbgen ( f32 dt, quake3::SModifierFunction &function ) -{ - u32 i; - const u32 vsize = MeshBuffer.Vertices.size(); - - switch ( function.masterfunc1 ) - { - case 6: - //identity - for ( i = 0; i != vsize; ++i ) - MeshBuffer.Vertices[i].Color = 0xFFFFFFFF; - break; - case 7: - // vertex - for ( i = 0; i != vsize; ++i ) - MeshBuffer.Vertices[i].Color = Original.Vertices[i].Color; - break; - case 5: - { - // wave - f32 f = function.evaluate ( dt ) * 255.f; - s32 value = core::clamp ( core::floor32 ( f ), 0, 255 ); - value |= value << 8; - value |= value << 16; - - for ( i = 0; i != vsize; ++i ) - MeshBuffer.Vertices[i].Color = value; - } break; - } -} - -/* - Generate Texture Coordinates -*/ -u32 CQuake3ShaderSceneNode::tcgen ( f32 dt, quake3::SModifierFunction &function, core::matrix4 &texture ) -{ - u32 ret = 0; - u32 i; - const u32 vsize = MeshBuffer.Vertices.size(); - - switch ( function.tcgen ) - { - case 8: - // tcgen texture - for ( i = 0; i != vsize; ++i ) - MeshBuffer.Vertices[i].TCoords = Original.Vertices[i].TCoords; - break; - case 9: - // tcgen lightmap - for ( i = 0; i != vsize; ++i ) - MeshBuffer.Vertices[i].TCoords = Original.Vertices[i].TCoords2; - break; - case 10: - { - // tcgen environment ( D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR ) - - // using eye linear, sphere map may be cooler;-) - // modelmatrix is identity - const core::matrix4 &view = SceneManager->getActiveCamera()->getViewFrustum()->Matrices [ video::ETS_VIEW ]; - const core::matrix4 &viewinverse = SceneManager->getActiveCamera()->getViewFrustum()->Matrices [ SViewFrustum::ETS_VIEW_MODEL_INVERSE_3 ]; - - // eyePlane - core::vector3df eyePlaneS; - core::vector3df eyePlaneT; - - viewinverse.transformVect ( eyePlaneS, core::vector3df ( 1.f, 0.f, 0.f ) ); - viewinverse.transformVect ( eyePlaneT, core::vector3df ( 0.f, 1.f, 0.f ) ); - - eyePlaneS.normalize (); - eyePlaneT.normalize (); - - core::vector3df v; - for ( i = 0; i != vsize; ++i ) - { - // vertex in eye space - view.transformVect ( v, Original.Vertices[i].Pos ); - v.normalize(); - - MeshBuffer.Vertices[i].TCoords.X = (1.f + eyePlaneS.dotProduct ( v ) ) * 0.5f; - MeshBuffer.Vertices[i].TCoords.Y = 1.f - ( (1.f + eyePlaneT.dotProduct ( v ) ) * 0.5f ); - } - - ret = 0; - - } break; - } - - return ret; -} - - - -/* - Transform Texture Coordinates -*/ -void CQuake3ShaderSceneNode::transformtex ( const core::matrix4 &m, const u32 addressMode ) -{ - u32 i; - const u32 vsize = MeshBuffer.Vertices.size(); - - f32 tx1; - f32 ty1; - - if ( addressMode ) - { - for ( i = 0; i != vsize; ++i ) - { - core::vector2df &tx = MeshBuffer.Vertices[i].TCoords; - - tx1 = m[0] * tx.X + m[4] * tx.Y + m[8]; - ty1 = m[1] * tx.X + m[5] * tx.Y + m[9]; - - tx.X = tx1; - tx.Y = ty1; - } - } - else - { - - for ( i = 0; i != vsize; ++i ) - { - core::vector2df &tx = MeshBuffer.Vertices[i].TCoords; - - tx1 = m[0] * tx.X + m[4] * tx.Y + m[8]; - ty1 = m[1] * tx.X + m[5] * tx.Y + m[9]; - - tx.X = tx1 <= 0.f ? 0.f : tx1 >= 1.f ? 1.f : tx1; - tx.Y = ty1 <= 0.f ? 0.f : ty1 >= 1.f ? 1.f : ty1; - - //tx.X = core::clamp ( tx1, 0.f, 1.f ); - //tx.Y = core::clamp ( ty1, 0.f, 1.f ); - } - } -} - - - - -/* - Texture & Vertex Transform Animator - - Return a Texture Transformation for this stage - Vertex transformation are called if found - -*/ -u32 CQuake3ShaderSceneNode::animate( u32 stage,core::matrix4 &texture ) -{ - const f32 dt = TimeAbs; - - const quake3::SVarGroup *group = Shader->getGroup ( stage ); - - - // select current texture - if ( Q3Texture [ stage ].TextureFrequency != 0.f ) - { - s32 v = core::floor32 ( dt * Q3Texture [ stage ].TextureFrequency ); - Q3Texture [ stage ].TextureIndex = v % Q3Texture [ stage ].Texture.size(); - } - - - core::matrix4 texturem; - core::matrix4 m2; - quake3::SModifierFunction function; - - - f32 f0; - f32 f1; - u32 textureMatrixFound = 0; - - // walk group for all modifiers - for ( u32 g = 0; g != group->Variable.size (); ++g ) - { - const quake3::SVariable &v = group->Variable[g]; - - // get the modifier - static const c8 * modifierList[] = - { - "tcmod","deformvertexes","rgbgen","tcgen","map" - }; - - u32 pos = 0; - function.masterfunc0 = quake3::isEqual ( v.name, pos, modifierList, 5 ); - - if ( -2 == function.masterfunc0 ) - continue; - - switch ( function.masterfunc0 ) - { - //tcmod - case 0: - if ( 0 == textureMatrixFound ) - { - texturem.makeIdentity (); - textureMatrixFound = 1; - } - m2.makeIdentity (); - break; - } - - // get the modifier function - static const c8 * funclist[] = - { - "scroll","scale","rotate","stretch","turb", - "wave","identity","vertex", - "texture","lightmap","environment","$lightmap", - "bulge","autosprite","autosprite2" - }; - - pos = 0; - function.masterfunc1 = quake3::isEqual ( v.content, pos, funclist, 14 ); - - switch ( function.masterfunc1 ) - { - case 0: - // scroll - f0 = quake3::getAsFloat ( v.content, pos ) * dt; - f1 = quake3::getAsFloat ( v.content, pos ) * dt; - m2.setTextureTranslate ( f0, f1 ); - break; - case 1: - // scale - f0 = quake3::getAsFloat ( v.content, pos ); - f1 = quake3::getAsFloat ( v.content, pos ); - m2.setTextureScale ( f0, f1 ); - break; - case 2: - //rotate - m2.setTextureRotationCenter ( quake3::getAsFloat ( v.content, pos ) * core::DEGTORAD * dt ); - break; - case 3: - case 4: - case 5: - case 6: - case 7: - { - // turb == sin, default == sin - function.func = 0; - - if ( function.masterfunc1 == 5 && function.masterfunc0 == 1) - { - // deformvertexes, wave - function.wave = quake3::getAsFloat ( v.content, pos ); - } - - if ( function.masterfunc1 == 3 || - function.masterfunc1 == 4 || - function.masterfunc1 == 5 - ) - { - // stretch, wave, tub - quake3::getModifierFunc ( function, v.content, pos ); - } - - switch ( function.masterfunc1 ) - { - case 3: - // stretch - f0 = core::reciprocal ( function.evaluate ( dt ) ); - m2.setTextureScaleCenter ( f0, f0 ); - break; - case 4: - // turb - f0 = function.evaluate ( dt ); - function.freq *= 2.f; - f1 = function.evaluate ( dt ); - m2.setTextureTranslate ( f1, f0 ); - break; - case 5: - if ( function.masterfunc0 == 1 ) - vertextransform_wave ( dt, function ); - else - rgbgen ( dt, function ); - break; - case 6: - case 7: - rgbgen ( dt, function ); - break; - } - - } break; - case 8: - case 9: - case 10: - // "texture","lightmap","environment" - function.tcgen = function.masterfunc1; - break; - case 11: - // map == lightmap, tcgen == lightmap - function.tcgen = 9; - break; - case 12: - // deformvertexes bulge - function.bulgewidth = quake3::getAsFloat ( v.content, pos ); - function.bulgeheight = quake3::getAsFloat ( v.content, pos ); - function.bulgespeed = quake3::getAsFloat ( v.content, pos ); - - vertextransform_bulge ( dt, function ); - break; - - case 13: - case 14: - // deformvertexes autosprite - vertextransform_autosprite ( dt, function); - break; - - } // func - - switch ( function.masterfunc0 ) - { - case 0: - texturem *= m2; - break; - } - - } // group - - // texture coordinate modifier - textureMatrixFound += tcgen ( dt, function, texturem ); - - if ( textureMatrixFound ) - { - texturem.getTransposed ( texture ); - } - - return textureMatrixFound; -} - - -void CQuake3ShaderSceneNode::OnAnimate(u32 timeMs) -{ - TimeAbs = f32( timeMs ) * ( 1.f/1000.f); -} - -const core::aabbox3d& CQuake3ShaderSceneNode::getBoundingBox() const -{ - return MeshBuffer.getBoundingBox (); -} - - -u32 CQuake3ShaderSceneNode::getMaterialCount() -{ - return Q3Texture.size(); -} - -video::SMaterial& CQuake3ShaderSceneNode::getMaterial(u32 i) -{ - video::SMaterial& m = MeshBuffer.getMaterial(); - m.Textures[0] = 0; - if ( Q3Texture [ i ].TextureIndex ) - m.Textures[0] = Q3Texture [ i ].Texture [ Q3Texture [ i ].TextureIndex ]; - return m; -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CQuake3ShaderSceneNode.h" +#include "IVideoDriver.h" +#include "ICameraSceneNode.h" + +namespace irr +{ +namespace scene +{ + + +CQuake3ShaderSceneNode::CQuake3ShaderSceneNode(scene::ISceneNode* parent, scene::ISceneManager* mgr,s32 id, + io::IFileSystem *fileSystem, + scene::IMeshBuffer *buffer, const quake3::SShader * shader + ) +: scene::ISceneNode(parent, mgr, id), Shader ( shader ),TimeAbs ( 0.f ) +{ + + #ifdef _DEBUG + core::stringc dName = "CQuake3ShaderSceneNode "; + dName += Shader->name; + + setDebugName( dName.c_str() ); + #endif + + // name the Scene Node + this->Name = Shader->name; + + // clone meshbuffer to modifiable buffer + clone ( static_cast< scene::SMeshBufferLightMap *> ( buffer ) ); + + // load all Textures in all stages + loadTextures ( fileSystem ); +} + +/* +*/ +CQuake3ShaderSceneNode::~CQuake3ShaderSceneNode () +{ +} + +/* + create single copies +*/ +void CQuake3ShaderSceneNode::clone ( scene::SMeshBufferLightMap * buffer ) +{ + Original.Material = buffer->Material; + MeshBuffer.Material = buffer->Material; + + Original.Indices = buffer->Indices; + MeshBuffer.Indices = buffer->Indices; + + const u32 vsize = buffer->Vertices.size (); + + Original.Vertices.set_used ( vsize ); + MeshBuffer.Vertices.set_used ( vsize ); + for ( u32 i = 0; i!= vsize; ++i ) + { + const video::S3DVertex2TCoords * src = &buffer->Vertices[i]; + Original.Vertices[i] = *src; + + video::S3DVertex * d = &MeshBuffer.Vertices[i]; + + d->Pos = src->Pos; + d->Color = 0xFFFFFFFF; //src->Color; + d->Normal = src->Normal; + d->TCoords = src->TCoords; + } + + MeshBuffer.recalculateBoundingBox (); + // used for sorting + MeshBuffer.Material.Textures[0] = (video::ITexture*) Shader; +} + + + +/* + load the textures for all stages +*/ +void CQuake3ShaderSceneNode::loadTextures ( io::IFileSystem * fileSystem ) +{ + const quake3::SVarGroup *group; + u32 i; + + // clear all stages and prefill empty + Q3Texture.clear (); + for ( i = 0; i != Shader->VarGroup->VariableGroup.size (); ++i ) + { + Q3Texture.push_back ( SQ3Texture() ); + } + + u32 pos; + + // get texture map + for ( i = 0; i < Shader->VarGroup->VariableGroup.size (); ++i ) + { + group = Shader->getGroup ( i ); + + const core::stringc &mapname = group->get ( "map" ); + if ( 0 == mapname.size () ) + continue; + + // our lightmap is passed in material.Texture[2] + if ( mapname == "$lightmap" ) + { + Q3Texture [i].Texture.push_back ( Original.getMaterial().Textures[1] ); + } + else + { + pos = 0; + quake3::getTextures ( Q3Texture [i].Texture, mapname, pos, fileSystem, SceneManager->getVideoDriver() ); + } + } + + // get anim map + for ( i = 0; i < Shader->VarGroup->VariableGroup.size (); ++i ) + { + if ( Q3Texture [i].Texture.size() ) + continue; + + group = Shader->getGroup ( i ); + + const core::stringc &animmap = group->get ( "animmap" ); + if ( 0 == animmap.size () ) + continue; + + // first parameter is frequency + pos = 0; + Q3Texture [i].TextureFrequency = core::max_ ( 0.0001f, quake3::getAsFloat ( animmap, pos ) ); + + quake3::getTextures ( Q3Texture [i].Texture, animmap, pos,fileSystem, SceneManager->getVideoDriver() ); + } + + // get clamp map + for ( i = 0; i < Shader->VarGroup->VariableGroup.size (); ++i ) + { + if ( Q3Texture [i].Texture.size() ) + continue; + + group = Shader->getGroup ( i ); + + const core::stringc &clampmap = group->get ( "clampmap" ); + if ( 0 == clampmap.size () ) + continue; + + Q3Texture [i].TextureAddressMode = video::ETC_CLAMP; + pos = 0; + quake3::getTextures ( Q3Texture [i].Texture, clampmap, pos,fileSystem, SceneManager->getVideoDriver() ); + } +} + +/* + Register each texture stage, if first is visible +*/ +void CQuake3ShaderSceneNode::OnRegisterSceneNode() +{ + PassedCulling = 0; + StageCall = 0; + if ( !IsVisible) + return; + + u32 first = 1; + for ( u32 i = 1; i < Q3Texture.size(); ++i ) + { + if ( 0 == Q3Texture [ i ].Texture.size() && i >= 2 ) + continue; + + scene::E_SCENE_NODE_RENDER_PASS time = (scene::E_SCENE_NODE_RENDER_PASS) ( scene::ESNRP_SHADER_0 + i ); + if ( first ) + { + setAutomaticCulling ( scene::EAC_BOX ); + PassedCulling = SceneManager->registerNodeForRendering(this, time ); + setAutomaticCulling ( scene::EAC_OFF ); + first = 0; + } + else + if ( PassedCulling ) + { + SceneManager->registerNodeForRendering(this, time ); + } + } +} + +/* + render in multipass technique +*/ +void CQuake3ShaderSceneNode::render() +{ + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + + const u32 stage = SceneManager->getSceneNodeRenderPass() - scene::ESNRP_SHADER_0; + + video::SMaterial material; + + const quake3::SVarGroup *group; + + // generic stage + group = Shader->getGroup ( 1 ); + material.BackfaceCulling = quake3::getBackfaceCulling ( group->get ( "cull" ) ); + + // advance current stage + core::matrix4 texture; + animate ( stage, texture ); + + // stage 1 finished, no drawing stage ( vertex transform only ) + if ( stage == 1 ) + return; + + // current stage + group = Shader->getGroup ( stage ); + + + SQ3Texture &q = Q3Texture [ stage]; + + material.Lighting = false; + material.Textures[0] = q.Texture [ q.TextureIndex ]; + material.Textures[1] = 0; + material.ZBuffer = quake3::getDepthFunction ( group->get ( "depthfunc" ) ); + material.ZWriteEnable = (0 == StageCall ); + material.NormalizeNormals = false; + + quake3::SBlendFunc blendfunc; + quake3::getBlendFunc ( group->get ( "blendfunc" ), blendfunc ); + quake3::getBlendFunc ( group->get ( "alphafunc" ), blendfunc ); + + material.MaterialType = blendfunc.type; + material.MaterialTypeParam = blendfunc.param; + +/* + if ( textureTransform ) + { + transformtex ( texture, q.TextureAddressMode ); + } +*/ + material.TextureWrap[0] = q.TextureAddressMode; + material.TextureWrap[1] = material.TextureWrap[0]; + driver->setTransform ( video::ETS_TEXTURE_0, texture ); + + driver->setMaterial( material ); + + if ( 0 == StageCall ) + { + driver->setTransform(video::ETS_WORLD, core::matrix4() ); + } + + driver->drawMeshBuffer( &MeshBuffer ); + + StageCall += 1; +} + + +/*! +*/ +void CQuake3ShaderSceneNode::vertextransform_wave ( f32 dt, quake3::SModifierFunction &function ) +{ + function.wave = core::reciprocal ( function.wave ); + + const f32 phase = function.phase; + + const u32 vsize = MeshBuffer.Vertices.size(); + for ( u32 i = 0; i != vsize; ++i ) + { + const video::S3DVertex2TCoords &src = Original.Vertices[i]; + video::S3DVertex &dst = MeshBuffer.Vertices[i]; + + f32 wavephase = (src.Pos.X + src.Pos.Y + src.Pos.Z) * function.wave; + function.phase = phase + wavephase; + + const f32 f = function.evaluate ( dt ); + + dst.Pos.X = src.Pos.X + f * src.Normal.X; + dst.Pos.Y = src.Pos.Y + f * src.Normal.Y; + dst.Pos.Z = src.Pos.Z + f * src.Normal.Z; + } +} + +/*! +*/ +void CQuake3ShaderSceneNode::vertextransform_bulge ( f32 dt, quake3::SModifierFunction &function ) +{ + function.func = 0; + function.wave = core::reciprocal ( function.bulgewidth ); + + dt *= function.bulgespeed * 0.1f; + const f32 phase = function.phase; + + const u32 vsize = MeshBuffer.Vertices.size(); + for ( u32 i = 0; i != vsize; ++i ) + { + const video::S3DVertex2TCoords &src = Original.Vertices[i]; + video::S3DVertex &dst = MeshBuffer.Vertices[i]; + + f32 wavephase = (Original.Vertices[i].TCoords.X ) * function.wave; + function.phase = phase + wavephase; + + const f32 f = function.evaluate ( dt ); + + dst.Pos.X = src.Pos.X + f * src.Normal.X; + dst.Pos.Y = src.Pos.Y + f * src.Normal.Y; + dst.Pos.Z = src.Pos.Z + f * src.Normal.Z; + } +} + +/*! +*/ +void CQuake3ShaderSceneNode::vertextransform_autosprite ( f32 dt, quake3::SModifierFunction &function ) +{ + const core::matrix4 &m = SceneManager->getActiveCamera()->getViewFrustum()->Matrices [ video::ETS_VIEW ]; + const core::vector3df view ( -m[2], -m[6] , -m[10] ); + + const u32 vsize = MeshBuffer.Vertices.size(); + + core::aabbox3df box; + u32 g; + + for ( u32 i = 0; i < vsize; i += 4 ) + { + // in pairs of 4 + box.reset ( Original.Vertices[i].Pos ); + for ( g = 1; g != 4; ++g ) + { + box.addInternalPoint ( Original.Vertices[i + g].Pos ); + } + + core::vector3df c = box.getCenter (); + f32 sh = 0.5f * ( box.MaxEdge.Z - box.MinEdge.Z ); + f32 sv = 0.5f * ( box.MaxEdge.Y - box.MinEdge.Y ); + + const core::vector3df h ( m[0] * sh, m[4] * sh, m[8] * sh ); + const core::vector3df v ( m[1] * sv, m[5] * sv, m[9] * sv ); + + MeshBuffer.Vertices[ i + 0 ].Pos = c + h + v; + MeshBuffer.Vertices[ i + 1 ].Pos = c - h - v; + MeshBuffer.Vertices[ i + 2 ].Pos = c + h - v; + MeshBuffer.Vertices[ i + 3 ].Pos = c - h + v; + + MeshBuffer.Vertices[ i + 0 ].Normal = view; + MeshBuffer.Vertices[ i + 1 ].Normal = view; + MeshBuffer.Vertices[ i + 2 ].Normal = view; + MeshBuffer.Vertices[ i + 3 ].Normal = view; + } +} + +/* + Generate Vertex Color +*/ +void CQuake3ShaderSceneNode::rgbgen ( f32 dt, quake3::SModifierFunction &function ) +{ + u32 i; + const u32 vsize = MeshBuffer.Vertices.size(); + + switch ( function.masterfunc1 ) + { + case 6: + //identity + for ( i = 0; i != vsize; ++i ) + MeshBuffer.Vertices[i].Color = 0xFFFFFFFF; + break; + case 7: + // vertex + for ( i = 0; i != vsize; ++i ) + MeshBuffer.Vertices[i].Color = Original.Vertices[i].Color; + break; + case 5: + { + // wave + f32 f = function.evaluate ( dt ) * 255.f; + s32 value = core::clamp ( core::floor32 ( f ), 0, 255 ); + value |= value << 8; + value |= value << 16; + + for ( i = 0; i != vsize; ++i ) + MeshBuffer.Vertices[i].Color = value; + } break; + } +} + +/* + Generate Texture Coordinates +*/ +u32 CQuake3ShaderSceneNode::tcgen ( f32 dt, quake3::SModifierFunction &function, core::matrix4 &texture ) +{ + u32 ret = 0; + u32 i; + const u32 vsize = MeshBuffer.Vertices.size(); + + switch ( function.tcgen ) + { + case 8: + // tcgen texture + for ( i = 0; i != vsize; ++i ) + MeshBuffer.Vertices[i].TCoords = Original.Vertices[i].TCoords; + break; + case 9: + // tcgen lightmap + for ( i = 0; i != vsize; ++i ) + MeshBuffer.Vertices[i].TCoords = Original.Vertices[i].TCoords2; + break; + case 10: + { + // tcgen environment ( D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR ) + + // using eye linear, sphere map may be cooler;-) + // modelmatrix is identity + const core::matrix4 &view = SceneManager->getActiveCamera()->getViewFrustum()->Matrices [ video::ETS_VIEW ]; + const core::matrix4 &viewinverse = SceneManager->getActiveCamera()->getViewFrustum()->Matrices [ SViewFrustum::ETS_VIEW_MODEL_INVERSE_3 ]; + + // eyePlane + core::vector3df eyePlaneS; + core::vector3df eyePlaneT; + + viewinverse.transformVect ( eyePlaneS, core::vector3df ( 1.f, 0.f, 0.f ) ); + viewinverse.transformVect ( eyePlaneT, core::vector3df ( 0.f, 1.f, 0.f ) ); + + eyePlaneS.normalize (); + eyePlaneT.normalize (); + + core::vector3df v; + for ( i = 0; i != vsize; ++i ) + { + // vertex in eye space + view.transformVect ( v, Original.Vertices[i].Pos ); + v.normalize(); + + MeshBuffer.Vertices[i].TCoords.X = (1.f + eyePlaneS.dotProduct ( v ) ) * 0.5f; + MeshBuffer.Vertices[i].TCoords.Y = 1.f - ( (1.f + eyePlaneT.dotProduct ( v ) ) * 0.5f ); + } + + ret = 0; + + } break; + } + + return ret; +} + + + +/* + Transform Texture Coordinates +*/ +void CQuake3ShaderSceneNode::transformtex ( const core::matrix4 &m, const u32 addressMode ) +{ + u32 i; + const u32 vsize = MeshBuffer.Vertices.size(); + + f32 tx1; + f32 ty1; + + if ( addressMode ) + { + for ( i = 0; i != vsize; ++i ) + { + core::vector2df &tx = MeshBuffer.Vertices[i].TCoords; + + tx1 = m[0] * tx.X + m[4] * tx.Y + m[8]; + ty1 = m[1] * tx.X + m[5] * tx.Y + m[9]; + + tx.X = tx1; + tx.Y = ty1; + } + } + else + { + + for ( i = 0; i != vsize; ++i ) + { + core::vector2df &tx = MeshBuffer.Vertices[i].TCoords; + + tx1 = m[0] * tx.X + m[4] * tx.Y + m[8]; + ty1 = m[1] * tx.X + m[5] * tx.Y + m[9]; + + tx.X = tx1 <= 0.f ? 0.f : tx1 >= 1.f ? 1.f : tx1; + tx.Y = ty1 <= 0.f ? 0.f : ty1 >= 1.f ? 1.f : ty1; + + //tx.X = core::clamp ( tx1, 0.f, 1.f ); + //tx.Y = core::clamp ( ty1, 0.f, 1.f ); + } + } +} + + + + +/* + Texture & Vertex Transform Animator + + Return a Texture Transformation for this stage + Vertex transformation are called if found + +*/ +u32 CQuake3ShaderSceneNode::animate( u32 stage,core::matrix4 &texture ) +{ + const f32 dt = TimeAbs; + + const quake3::SVarGroup *group = Shader->getGroup ( stage ); + + + // select current texture + if ( Q3Texture [ stage ].TextureFrequency != 0.f ) + { + s32 v = core::floor32 ( dt * Q3Texture [ stage ].TextureFrequency ); + Q3Texture [ stage ].TextureIndex = v % Q3Texture [ stage ].Texture.size(); + } + + + core::matrix4 texturem; + core::matrix4 m2; + quake3::SModifierFunction function; + + + f32 f0; + f32 f1; + u32 textureMatrixFound = 0; + + // walk group for all modifiers + for ( u32 g = 0; g != group->Variable.size (); ++g ) + { + const quake3::SVariable &v = group->Variable[g]; + + // get the modifier + static const c8 * modifierList[] = + { + "tcmod","deformvertexes","rgbgen","tcgen","map" + }; + + u32 pos = 0; + function.masterfunc0 = quake3::isEqual ( v.name, pos, modifierList, 5 ); + + if ( -2 == function.masterfunc0 ) + continue; + + switch ( function.masterfunc0 ) + { + //tcmod + case 0: + if ( 0 == textureMatrixFound ) + { + texturem.makeIdentity (); + textureMatrixFound = 1; + } + m2.makeIdentity (); + break; + } + + // get the modifier function + static const c8 * funclist[] = + { + "scroll","scale","rotate","stretch","turb", + "wave","identity","vertex", + "texture","lightmap","environment","$lightmap", + "bulge","autosprite","autosprite2" + }; + + pos = 0; + function.masterfunc1 = quake3::isEqual ( v.content, pos, funclist, 14 ); + + switch ( function.masterfunc1 ) + { + case 0: + // scroll + f0 = quake3::getAsFloat ( v.content, pos ) * dt; + f1 = quake3::getAsFloat ( v.content, pos ) * dt; + m2.setTextureTranslate ( f0, f1 ); + break; + case 1: + // scale + f0 = quake3::getAsFloat ( v.content, pos ); + f1 = quake3::getAsFloat ( v.content, pos ); + m2.setTextureScale ( f0, f1 ); + break; + case 2: + //rotate + m2.setTextureRotationCenter ( quake3::getAsFloat ( v.content, pos ) * core::DEGTORAD * dt ); + break; + case 3: + case 4: + case 5: + case 6: + case 7: + { + // turb == sin, default == sin + function.func = 0; + + if ( function.masterfunc1 == 5 && function.masterfunc0 == 1) + { + // deformvertexes, wave + function.wave = quake3::getAsFloat ( v.content, pos ); + } + + if ( function.masterfunc1 == 3 || + function.masterfunc1 == 4 || + function.masterfunc1 == 5 + ) + { + // stretch, wave, tub + quake3::getModifierFunc ( function, v.content, pos ); + } + + switch ( function.masterfunc1 ) + { + case 3: + // stretch + f0 = core::reciprocal ( function.evaluate ( dt ) ); + m2.setTextureScaleCenter ( f0, f0 ); + break; + case 4: + // turb + f0 = function.evaluate ( dt ); + function.freq *= 2.f; + f1 = function.evaluate ( dt ); + m2.setTextureTranslate ( f1, f0 ); + break; + case 5: + if ( function.masterfunc0 == 1 ) + vertextransform_wave ( dt, function ); + else + rgbgen ( dt, function ); + break; + case 6: + case 7: + rgbgen ( dt, function ); + break; + } + + } break; + case 8: + case 9: + case 10: + // "texture","lightmap","environment" + function.tcgen = function.masterfunc1; + break; + case 11: + // map == lightmap, tcgen == lightmap + function.tcgen = 9; + break; + case 12: + // deformvertexes bulge + function.bulgewidth = quake3::getAsFloat ( v.content, pos ); + function.bulgeheight = quake3::getAsFloat ( v.content, pos ); + function.bulgespeed = quake3::getAsFloat ( v.content, pos ); + + vertextransform_bulge ( dt, function ); + break; + + case 13: + case 14: + // deformvertexes autosprite + vertextransform_autosprite ( dt, function); + break; + + } // func + + switch ( function.masterfunc0 ) + { + case 0: + texturem *= m2; + break; + } + + } // group + + // texture coordinate modifier + textureMatrixFound += tcgen ( dt, function, texturem ); + + if ( textureMatrixFound ) + { + texturem.getTransposed ( texture ); + } + + return textureMatrixFound; +} + + +void CQuake3ShaderSceneNode::OnAnimate(u32 timeMs) +{ + TimeAbs = f32( timeMs ) * ( 1.f/1000.f); +} + +const core::aabbox3d& CQuake3ShaderSceneNode::getBoundingBox() const +{ + return MeshBuffer.getBoundingBox (); +} + + +u32 CQuake3ShaderSceneNode::getMaterialCount() +{ + return Q3Texture.size(); +} + +video::SMaterial& CQuake3ShaderSceneNode::getMaterial(u32 i) +{ + video::SMaterial& m = MeshBuffer.getMaterial(); + m.Textures[0] = 0; + if ( Q3Texture [ i ].TextureIndex ) + m.Textures[0] = Q3Texture [ i ].Texture [ Q3Texture [ i ].TextureIndex ]; + return m; +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CQuake3ShaderSceneNode.h b/src/dep/src/irrlicht/CQuake3ShaderSceneNode.h index 44bf766..d98ad73 100644 --- a/src/dep/src/irrlicht/CQuake3ShaderSceneNode.h +++ b/src/dep/src/irrlicht/CQuake3ShaderSceneNode.h @@ -1,87 +1,87 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_QUAKE3_SCENE_NODE_H_INCLUDED__ -#define __C_QUAKE3_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "IQ3Shader.h" -#include "IFileSystem.h" -#include "SMeshBuffer.h" -#include "SMeshBufferLightMap.h" - -namespace irr -{ -namespace scene -{ - -//! Scene node which is a quake3 shader. -class CQuake3ShaderSceneNode : public scene::ISceneNode -{ -public: - - CQuake3ShaderSceneNode( ISceneNode* parent, ISceneManager* mgr,s32 id, - io::IFileSystem *fileSystem,IMeshBuffer *buffer, - const quake3::SShader * shader - ); - - virtual ~CQuake3ShaderSceneNode (); - - virtual void OnRegisterSceneNode(); - virtual void render(); - virtual void OnAnimate(u32 timeMs); - virtual const core::aabbox3d& getBoundingBox() const; - - virtual u32 getMaterialCount(); - virtual video::SMaterial& getMaterial(u32 i); - -private: - SMeshBuffer MeshBuffer; - SMeshBufferLightMap Original; - const quake3::SShader * Shader; - - struct SQ3Texture - { - SQ3Texture () : - TextureIndex ( 0 ), - TextureFrequency(0.f), - TextureAddressMode( video::ETC_REPEAT ) {} - - quake3::tTexArray Texture; - - u32 TextureIndex; - f32 TextureFrequency; - video::E_TEXTURE_CLAMP TextureAddressMode; // Wrapping/Clamping - }; - - core::array< SQ3Texture > Q3Texture; - - void loadTextures ( io::IFileSystem * fileSystem ); - void clone ( scene::SMeshBufferLightMap * buffer ); - - void vertextransform_wave ( f32 dt, quake3::SModifierFunction &function ); - void vertextransform_bulge( f32 dt, quake3::SModifierFunction &function ); - void vertextransform_autosprite( f32 dt, quake3::SModifierFunction &function ); - - void rgbgen ( f32 dt, quake3::SModifierFunction &function ); - u32 tcgen ( f32 dt, quake3::SModifierFunction &function, core::matrix4 &texture ); - - void transformtex ( const core::matrix4 &m, const u32 clamp ); - - f32 TimeAbs; - u32 animate( u32 stage, core::matrix4 &texture ); - - - s32 PassedCulling; - s32 StageCall; - -}; - - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_QUAKE3_SCENE_NODE_H_INCLUDED__ +#define __C_QUAKE3_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" +#include "IQ3Shader.h" +#include "IFileSystem.h" +#include "SMeshBuffer.h" +#include "SMeshBufferLightMap.h" + +namespace irr +{ +namespace scene +{ + +//! Scene node which is a quake3 shader. +class CQuake3ShaderSceneNode : public scene::ISceneNode +{ +public: + + CQuake3ShaderSceneNode( ISceneNode* parent, ISceneManager* mgr,s32 id, + io::IFileSystem *fileSystem,IMeshBuffer *buffer, + const quake3::SShader * shader + ); + + virtual ~CQuake3ShaderSceneNode (); + + virtual void OnRegisterSceneNode(); + virtual void render(); + virtual void OnAnimate(u32 timeMs); + virtual const core::aabbox3d& getBoundingBox() const; + + virtual u32 getMaterialCount(); + virtual video::SMaterial& getMaterial(u32 i); + +private: + SMeshBuffer MeshBuffer; + SMeshBufferLightMap Original; + const quake3::SShader * Shader; + + struct SQ3Texture + { + SQ3Texture () : + TextureIndex ( 0 ), + TextureFrequency(0.f), + TextureAddressMode( video::ETC_REPEAT ) {} + + quake3::tTexArray Texture; + + u32 TextureIndex; + f32 TextureFrequency; + video::E_TEXTURE_CLAMP TextureAddressMode; // Wrapping/Clamping + }; + + core::array< SQ3Texture > Q3Texture; + + void loadTextures ( io::IFileSystem * fileSystem ); + void clone ( scene::SMeshBufferLightMap * buffer ); + + void vertextransform_wave ( f32 dt, quake3::SModifierFunction &function ); + void vertextransform_bulge( f32 dt, quake3::SModifierFunction &function ); + void vertextransform_autosprite( f32 dt, quake3::SModifierFunction &function ); + + void rgbgen ( f32 dt, quake3::SModifierFunction &function ); + u32 tcgen ( f32 dt, quake3::SModifierFunction &function, core::matrix4 &texture ); + + void transformtex ( const core::matrix4 &m, const u32 clamp ); + + f32 TimeAbs; + u32 animate( u32 stage, core::matrix4 &texture ); + + + s32 PassedCulling; + s32 StageCall; + +}; + + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CReadFile.cpp b/src/dep/src/irrlicht/CReadFile.cpp index 45ca570..4f95fb8 100644 --- a/src/dep/src/irrlicht/CReadFile.cpp +++ b/src/dep/src/irrlicht/CReadFile.cpp @@ -1,118 +1,118 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CReadFile.h" - -namespace irr -{ -namespace io -{ - - -CReadFile::CReadFile(const c8* fileName) -: File(0), FileSize(0) -{ - #ifdef _DEBUG - setDebugName("CReadFile"); - #endif - - Filename = fileName; - openFile(); -} - - - -CReadFile::~CReadFile() -{ - if (File) - fclose(File); -} - - - -//! returns how much was read -s32 CReadFile::read(void* buffer, u32 sizeToRead) -{ - if (!isOpen()) - return 0; - - return fread(buffer, 1, sizeToRead, File); -} - - - -//! changes position in file, returns true if successful -//! if relativeMovement==true, the pos is changed relative to current pos, -//! otherwise from begin of file -bool CReadFile::seek(s32 finalPos, bool relativeMovement) -{ - if (!isOpen()) - return false; - - return fseek(File, finalPos, relativeMovement ? SEEK_CUR : SEEK_SET) == 0; -} - - - -//! returns size of file -s32 CReadFile::getSize() -{ - return FileSize; -} - - - -//! returns where in the file we are. -s32 CReadFile::getPos() -{ - return ftell(File); -} - - - -//! opens the file -void CReadFile::openFile() -{ - if (Filename.size() == 0) // bugfix posted by rt - { - File = 0; - return; - } - - File = fopen(Filename.c_str(), "rb"); - - if (File) - { - // get FileSize - - fseek(File, 0, SEEK_END); - FileSize = ftell(File); - fseek(File, 0, SEEK_SET); - } -} - - - -//! returns name of file -const c8* CReadFile::getFileName() -{ - return Filename.c_str(); -} - - - -IReadFile* createReadFile(const c8* fileName) -{ - CReadFile* file = new CReadFile(fileName); - if (file->isOpen()) - return file; - - file->drop(); - return 0; -} - - -} // end namespace io -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CReadFile.h" + +namespace irr +{ +namespace io +{ + + +CReadFile::CReadFile(const c8* fileName) +: File(0), FileSize(0) +{ + #ifdef _DEBUG + setDebugName("CReadFile"); + #endif + + Filename = fileName; + openFile(); +} + + + +CReadFile::~CReadFile() +{ + if (File) + fclose(File); +} + + + +//! returns how much was read +s32 CReadFile::read(void* buffer, u32 sizeToRead) +{ + if (!isOpen()) + return 0; + + return fread(buffer, 1, sizeToRead, File); +} + + + +//! changes position in file, returns true if successful +//! if relativeMovement==true, the pos is changed relative to current pos, +//! otherwise from begin of file +bool CReadFile::seek(s32 finalPos, bool relativeMovement) +{ + if (!isOpen()) + return false; + + return fseek(File, finalPos, relativeMovement ? SEEK_CUR : SEEK_SET) == 0; +} + + + +//! returns size of file +s32 CReadFile::getSize() +{ + return FileSize; +} + + + +//! returns where in the file we are. +s32 CReadFile::getPos() +{ + return ftell(File); +} + + + +//! opens the file +void CReadFile::openFile() +{ + if (Filename.size() == 0) // bugfix posted by rt + { + File = 0; + return; + } + + File = fopen(Filename.c_str(), "rb"); + + if (File) + { + // get FileSize + + fseek(File, 0, SEEK_END); + FileSize = ftell(File); + fseek(File, 0, SEEK_SET); + } +} + + + +//! returns name of file +const c8* CReadFile::getFileName() +{ + return Filename.c_str(); +} + + + +IReadFile* createReadFile(const c8* fileName) +{ + CReadFile* file = new CReadFile(fileName); + if (file->isOpen()) + return file; + + file->drop(); + return 0; +} + + +} // end namespace io +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CReadFile.h b/src/dep/src/irrlicht/CReadFile.h index 37abcb7..c1d20ee 100644 --- a/src/dep/src/irrlicht/CReadFile.h +++ b/src/dep/src/irrlicht/CReadFile.h @@ -1,67 +1,67 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_READ_FILE_H_INCLUDED__ -#define __C_READ_FILE_H_INCLUDED__ - -#include -#include "IReadFile.h" -#include "irrString.h" - -namespace irr -{ - -namespace io -{ - - /*! - Class for reading a real file from disk. - */ - class CReadFile : public IReadFile - { - public: - - CReadFile(const wchar_t* fileName); - CReadFile(const c8* fileName); - - virtual ~CReadFile(); - - //! returns how much was read - virtual s32 read(void* buffer, u32 sizeToRead); - - //! changes position in file, returns true if successful - //! if relativeMovement==true, the pos is changed relative to current pos, - //! otherwise from begin of file - virtual bool seek(s32 finalPos, bool relativeMovement = false); - - //! returns size of file - virtual s32 getSize(); - - //! returns if file is open - virtual bool isOpen() const - { - return File != 0; - } - - //! returns where in the file we are. - virtual s32 getPos(); - - //! returns name of file - virtual const c8* getFileName(); - - private: - - //! opens the file - void openFile(); - - core::stringc Filename; - FILE* File; - s32 FileSize; - }; - -} // end namespace io -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_READ_FILE_H_INCLUDED__ +#define __C_READ_FILE_H_INCLUDED__ + +#include +#include "IReadFile.h" +#include "irrString.h" + +namespace irr +{ + +namespace io +{ + + /*! + Class for reading a real file from disk. + */ + class CReadFile : public IReadFile + { + public: + + CReadFile(const wchar_t* fileName); + CReadFile(const c8* fileName); + + virtual ~CReadFile(); + + //! returns how much was read + virtual s32 read(void* buffer, u32 sizeToRead); + + //! changes position in file, returns true if successful + //! if relativeMovement==true, the pos is changed relative to current pos, + //! otherwise from begin of file + virtual bool seek(s32 finalPos, bool relativeMovement = false); + + //! returns size of file + virtual s32 getSize(); + + //! returns if file is open + virtual bool isOpen() const + { + return File != 0; + } + + //! returns where in the file we are. + virtual s32 getPos(); + + //! returns name of file + virtual const c8* getFileName(); + + private: + + //! opens the file + void openFile(); + + core::stringc Filename; + FILE* File; + s32 FileSize; + }; + +} // end namespace io +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CSceneCollisionManager.cpp b/src/dep/src/irrlicht/CSceneCollisionManager.cpp index ba047f6..3ee9fef 100644 --- a/src/dep/src/irrlicht/CSceneCollisionManager.cpp +++ b/src/dep/src/irrlicht/CSceneCollisionManager.cpp @@ -1,739 +1,739 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneCollisionManager.h" -#include "ISceneNode.h" -#include "ICameraSceneNode.h" -#include "ITriangleSelector.h" -#include "SViewFrustum.h" - -#include "os.h" -#include "irrMath.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CSceneCollisionManager::CSceneCollisionManager(ISceneManager* smanager, video::IVideoDriver* driver) -: SceneManager(smanager), Driver(driver) -{ - #ifdef _DEBUG - setDebugName("CSceneCollisionManager"); - #endif - - if (Driver) - Driver->grab(); -} - - - -//! destructor -CSceneCollisionManager::~CSceneCollisionManager() -{ - if (Driver) - Driver->drop(); -} - - - -//! Returns the scene node, which is currently visible under the overgiven -//! screencoordinates, viewed from the currently active camera. -ISceneNode* CSceneCollisionManager::getSceneNodeFromScreenCoordinatesBB( - core::position2d pos, s32 idBitMask, bool bNoDebugObjects) -{ - core::line3d ln = getRayFromScreenCoordinates(pos, 0); - - if ( ln.start == ln.end ) - return 0; - - return getSceneNodeFromRayBB(ln, idBitMask, bNoDebugObjects); -} - - - -//! Returns the nearest scene node which collides with a 3d ray and -//! which id matches a bitmask. -ISceneNode* CSceneCollisionManager::getSceneNodeFromRayBB(core::line3d ray, - s32 idBitMask, - bool bNoDebugObjects) -{ - ISceneNode* best = 0; - f32 dist = 9999999999.0f; - - getPickedNodeBB(SceneManager->getRootSceneNode(), ray, - idBitMask, bNoDebugObjects, dist, best); - - return best; -} - - -//! recursive method for going through all scene nodes -void CSceneCollisionManager::getPickedNodeBB(ISceneNode* root, - const core::line3df& ray, - s32 bits, - bool bNoDebugObjects, - f32& outbestdistance, - ISceneNode*& outbestnode) -{ - core::vector3df edges[8]; - - const core::list& children = root->getChildren(); - - core::list::Iterator it = children.begin(); - for (; it != children.end(); ++it) - { - ISceneNode* current = *it; - - if (current->isVisible() && - (bNoDebugObjects ? !current->isDebugObject() : true) && - (bits==0 || (bits != 0 && (current->getID() & bits)))) - { - // get world to object space transform - core::matrix4 mat; - if (!current->getAbsoluteTransformation().getInverse(mat)) - continue; - - // transform vector from world space to object space - core::line3df line(ray); - mat.transformVect(line.start); - mat.transformVect(line.end); - - const core::aabbox3df& box = current->getBoundingBox(); - - // do intersection test in object space - if (box.intersectsWithLine(line)) - { - box.getEdges(edges); - f32 distance = 0.0f; - - for (s32 e=0; e<8; ++e) - { - f32 t = edges[e].getDistanceFromSQ(line.start); - if (t > distance) - distance = t; - } - - if (distance < outbestdistance) - { - outbestnode = current; - outbestdistance = distance; - } - } - } - - getPickedNodeBB(current, ray, bits, bNoDebugObjects, outbestdistance, outbestnode); - } -} - - - -//! Returns the scene node, at which the overgiven camera is looking at and -//! which id matches the bitmask. -ISceneNode* CSceneCollisionManager::getSceneNodeFromCameraBB( - ICameraSceneNode* camera, s32 idBitMask, bool bNoDebugObjects) -{ - if (!camera) - return 0; - - core::vector3df start = camera->getAbsolutePosition(); - core::vector3df end = camera->getTarget(); - - end = start + ((end - start).normalize() * camera->getFarValue()); - core::line3d line(start, end); - - return getSceneNodeFromRayBB(line, idBitMask, bNoDebugObjects); -} - - - -//! Finds the collision point of a line and lots of triangles, if there is one. -bool CSceneCollisionManager::getCollisionPoint(const core::line3d& ray, - ITriangleSelector* selector, core::vector3df& outIntersection, - core::triangle3df& outTriangle) -{ - if (!selector) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - s32 totalcnt = selector->getTriangleCount(); - Triangles.set_used(totalcnt); - - s32 cnt = 0; - selector->getTriangles(Triangles.pointer(), totalcnt, cnt, ray); - - core::vector3df linevect = ray.getVector().normalize(); - core::vector3df intersection; - f32 nearest = 9999999999999.0f; - bool found = false; - f32 tmp, tmp2; - f32 raylength = (f32)ray.getLengthSQ(); - - for (s32 i=0; i trianglePlane = triangle.getPlane(); - - // only check front facing polygons - if ( !trianglePlane.isFrontFacing(colData->normalizedVelocity) ) - return; - - // get interval of plane intersection - - f32 t1, t0; - bool embeddedInPlane = false; - - // calculate signed distance from sphere position to triangle plane - f32 signedDistToTrianglePlane = trianglePlane.getDistanceTo( - colData->basePoint); - - f32 normalDotVelocity = - trianglePlane.Normal.dotProduct(colData->velocity); - - if ( core::iszero ( normalDotVelocity ) ) - { - // sphere is traveling parallel to plane - - if (fabs(signedDistToTrianglePlane) >= 1.0f) - return; // no collision possible - else - { - // sphere is embedded in plane - embeddedInPlane = true; - t0 = 0.0; - t1 = 1.0; - } - } - else - { - normalDotVelocity = core::reciprocal ( normalDotVelocity ); - - // N.D is not 0. Calculate intersection interval - t0 = (-1.f - signedDistToTrianglePlane) * normalDotVelocity; - t1 = (1.f - signedDistToTrianglePlane) * normalDotVelocity; - - // Swap so t0 < t1 - if (t0 > t1) { f32 tmp = t1; t1 = t0; t0 = tmp; } - - // check if at least one value is within the range - if (t0 > 1.0f || t1 < 0.0f) - return; // both t values are outside 1 and 0, no collision possible - - // clamp to 0 and 1 - t0 = core::clamp ( t0, 0.f, 1.f ); - t1 = core::clamp ( t1, 0.f, 1.f ); - } - - // at this point we have t0 and t1, if there is any intersection, it - // is between this interval - core::vector3df collisionPoint; - bool foundCollision = false; - f32 t = 1.0f; - - // first check the easy case: Collision within the triangle; - // if this happens, it must be at t0 and this is when the sphere - // rests on the front side of the triangle plane. This can only happen - // if the sphere is not embedded in the triangle plane. - - if (!embeddedInPlane) - { - core::vector3df planeIntersectionPoint = - (colData->basePoint - trianglePlane.Normal) - + (colData->velocity * t0); - - if (triangle.isPointInsideFast(planeIntersectionPoint)) - { - foundCollision = true; - t = t0; - collisionPoint = planeIntersectionPoint; - } - } - - // if we havent found a collision already we will have to sweep - // the sphere against points and edges of the triangle. Note: A - // collision inside the triangle will always happen before a - // vertex or edge collision. - - if (!foundCollision) - { - core::vector3df velocity = colData->velocity; - core::vector3df base = colData->basePoint; - - f32 velocitySqaredLength = velocity.getLengthSQ(); - f32 a,b,c; - f32 newT; - - // for each edge or vertex a quadratic equation has to be solved: - // a*t^2 + b*t + c = 0. We calculate a,b, and c for each test. - - // check against points - a = velocitySqaredLength; - - // p1 - b = 2.0f * (velocity.dotProduct(base - triangle.pointA)); - c = (triangle.pointA-base).getLengthSQ() - 1.f; - if (getLowestRoot(a,b,c,t, &newT)) - { - t = newT; - foundCollision = true; - collisionPoint = triangle.pointA; - } - - // p2 - if (!foundCollision) - { - b = 2.0f * (velocity.dotProduct(base - triangle.pointB)); - c = (triangle.pointB-base).getLengthSQ() - 1.f; - if (getLowestRoot(a,b,c,t, &newT)) - { - t = newT; - foundCollision = true; - collisionPoint = triangle.pointB; - } - } - - // p3 - if (!foundCollision) - { - b = 2.0f * (velocity.dotProduct(base - triangle.pointC)); - c = (triangle.pointC-base).getLengthSQ() - 1.f; - if (getLowestRoot(a,b,c,t, &newT)) - { - t = newT; - foundCollision = true; - collisionPoint = triangle.pointC; - } - } - - // check against edges: - - // p1 --- p2 - core::vector3df edge = triangle.pointB - triangle.pointA; - core::vector3df baseToVertex = triangle.pointA - base; - f32 edgeSqaredLength = edge.getLengthSQ(); - f32 edgeDotVelocity = edge.dotProduct(velocity); - f32 edgeDotBaseToVertex = edge.dotProduct(baseToVertex); - - // calculate parameters for equation - a = edgeSqaredLength* -velocitySqaredLength + - edgeDotVelocity*edgeDotVelocity; - b = edgeSqaredLength* (2.f *velocity.dotProduct(baseToVertex)) - - 2.0f*edgeDotVelocity*edgeDotBaseToVertex; - c = edgeSqaredLength* (1.f -baseToVertex.getLengthSQ()) + - edgeDotBaseToVertex*edgeDotBaseToVertex; - - // does the swept sphere collide against infinite edge? - if (getLowestRoot(a,b,c,t,&newT)) - { - f32 f = (edgeDotVelocity*newT - edgeDotBaseToVertex) / edgeSqaredLength; - if (f >=0.0f && f <= 1.0f) - { - // intersection took place within segment - t = newT; - foundCollision = true; - collisionPoint = triangle.pointA + (edge*f); - } - } - - // p2 --- p3 - edge = triangle.pointC-triangle.pointB; - baseToVertex = triangle.pointB - base; - edgeSqaredLength = edge.getLengthSQ(); - edgeDotVelocity = edge.dotProduct(velocity); - edgeDotBaseToVertex = edge.dotProduct(baseToVertex); - - // calculate parameters for equation - a = edgeSqaredLength* -velocitySqaredLength + - edgeDotVelocity*edgeDotVelocity; - b = edgeSqaredLength* (2*velocity.dotProduct(baseToVertex)) - - 2.0f*edgeDotVelocity*edgeDotBaseToVertex; - c = edgeSqaredLength* (1-baseToVertex.getLengthSQ()) + - edgeDotBaseToVertex*edgeDotBaseToVertex; - - // does the swept sphere collide against infinite edge? - if (getLowestRoot(a,b,c,t,&newT)) - { - f32 f = (edgeDotVelocity*newT-edgeDotBaseToVertex) / - edgeSqaredLength; - if (f >=0.0f && f <= 1.0f) - { - // intersection took place within segment - t = newT; - foundCollision = true; - collisionPoint = triangle.pointB + (edge*f); - } - } - - - // p3 --- p1 - edge = triangle.pointA-triangle.pointC; - baseToVertex = triangle.pointC - base; - edgeSqaredLength = edge.getLengthSQ(); - edgeDotVelocity = edge.dotProduct(velocity); - edgeDotBaseToVertex = edge.dotProduct(baseToVertex); - - // calculate parameters for equation - a = edgeSqaredLength* -velocitySqaredLength + - edgeDotVelocity*edgeDotVelocity; - b = edgeSqaredLength* (2*velocity.dotProduct(baseToVertex)) - - 2.0f*edgeDotVelocity*edgeDotBaseToVertex; - c = edgeSqaredLength* (1-baseToVertex.getLengthSQ()) + - edgeDotBaseToVertex*edgeDotBaseToVertex; - - // does the swept sphere collide against infinite edge? - if (getLowestRoot(a,b,c,t,&newT)) - { - f32 f = (edgeDotVelocity*newT-edgeDotBaseToVertex) / - edgeSqaredLength; - if (f >=0.0f && f <= 1.0f) - { - // intersection took place within segment - t = newT; - foundCollision = true; - collisionPoint = triangle.pointC + (edge*f); - } - } - }// end no collision found - - // set result: - if (foundCollision) - { - // distance to collision is t - f32 distToCollision = t*colData->velocity.getLength(); - - // does this triangle qualify for closest hit? - if (!colData->foundCollision || - distToCollision < colData->nearestDistance) - { - colData->nearestDistance = distToCollision; - colData->intersectionPoint = collisionPoint; - colData->foundCollision = true; - colData->intersectionTriangle = triangle; - ++colData->triangleHits; - } - - }// end found collision -} - - - -//! Collides a moving ellipsoid with a 3d world with gravity and returns -//! the resulting new position of the ellipsoid. -core::vector3df CSceneCollisionManager::collideEllipsoidWithWorld( - ITriangleSelector* selector, const core::vector3df &position, - const core::vector3df& radius, const core::vector3df& velocity, - f32 slidingSpeed, - const core::vector3df& gravity, - core::triangle3df& triout, bool& outFalling) -{ - if (!selector || radius.X == 0.0f || radius.Y == 0.0f || radius.Z == 0.0f) - return position; - - // This code is based on the paper "Improved Collision detection and Response" - // by Kasper Fauerby, but some parts are modified. - - SCollisionData colData; - colData.R3Position = position; - colData.R3Velocity = velocity; - colData.eRadius = radius; - colData.nearestDistance = 9999999999999.0f; - colData.selector = selector; - colData.slidingSpeed = slidingSpeed; - colData.triangleHits = 0; - - core::vector3df eSpacePosition = colData.R3Position / colData.eRadius; - core::vector3df eSpaceVelocity = colData.R3Velocity / colData.eRadius; - - // iterate until we have our final position - - core::vector3df finalPos = collideWithWorld( - 0, colData, eSpacePosition, eSpaceVelocity); - - outFalling = false; - - // add gravity - - if (gravity != core::vector3df(0,0,0)) - { - colData.R3Position = finalPos * colData.eRadius; - colData.R3Velocity = gravity; - colData.triangleHits = 0; - - eSpaceVelocity = gravity/colData.eRadius; - - finalPos = collideWithWorld(0, colData, - finalPos, eSpaceVelocity); - - outFalling = (colData.triangleHits == 0); - } - - if (colData.triangleHits) - { - triout = colData.intersectionTriangle; - triout.pointA *= colData.eRadius; - triout.pointB *= colData.eRadius; - triout.pointC *= colData.eRadius; - } - - finalPos *= colData.eRadius; - return finalPos; -} - -core::vector3df CSceneCollisionManager::collideWithWorld(s32 recursionDepth, - SCollisionData &colData, core::vector3df pos, core::vector3df vel) -{ - f32 veryCloseDistance = colData.slidingSpeed; - - if (recursionDepth > 5) - return pos; - - colData.velocity = vel; - colData.normalizedVelocity = vel; - colData.normalizedVelocity.normalize(); - colData.basePoint = pos; - colData.foundCollision = false; - colData.nearestDistance = 9999999999999.0f; - - //------------------ collide with world - - // get all triangles with which we might collide - core::aabbox3d box(colData.R3Position); - box.addInternalPoint(colData.R3Position + colData.R3Velocity); - box.MinEdge -= colData.eRadius; - box.MaxEdge += colData.eRadius; - - s32 totalTriangleCnt = colData.selector->getTriangleCount(); - Triangles.set_used(totalTriangleCnt); - - core::matrix4 scaleMatrix; - scaleMatrix.setScale( - core::vector3df(1.0f / colData.eRadius.X, - 1.0f / colData.eRadius.Y, - 1.0f / colData.eRadius.Z) - ); - - s32 triangleCnt = 0; - colData.selector->getTriangles(Triangles.pointer(), totalTriangleCnt, triangleCnt, box, &scaleMatrix); - //colData.selector->getTriangles(Triangles.pointer(), totalTriangleCnt, triangleCnt, &scaleMatrix); - - for (s32 i=0; i= veryCloseDistance) - { - core::vector3df v = vel; - v.setLength( colData.nearestDistance - veryCloseDistance ); - newBasePoint = colData.basePoint + v; - - v.normalize(); - colData.intersectionPoint -= (v * veryCloseDistance); - } - - // calculate sliding plane - - core::vector3df slidePlaneOrigin = colData.intersectionPoint; - core::vector3df slidePlaneNormal = newBasePoint - colData.intersectionPoint; - slidePlaneNormal.normalize(); - core::plane3d slidingPlane(slidePlaneOrigin, slidePlaneNormal); - - core::vector3df newDestinationPoint = - destinationPoint - - (slidePlaneNormal * slidingPlane.getDistanceTo(destinationPoint)); - - // generate slide vector - - core::vector3df newVelocityVector = newDestinationPoint - - colData.intersectionPoint; - - if (newVelocityVector.getLength() < veryCloseDistance) - return newBasePoint; - - return collideWithWorld(recursionDepth+1, colData, - newBasePoint, newVelocityVector); -} - - -//! Returns a 3d ray which would go through the 2d screen coodinates. -core::line3d CSceneCollisionManager::getRayFromScreenCoordinates( - core::position2d pos, ICameraSceneNode* camera) -{ - core::line3d ln(0,0,0,0,0,0); - - if (!SceneManager) - return ln; - - if (!camera) - camera = SceneManager->getActiveCamera(); - - if (!camera) - return ln; - - const scene::SViewFrustum* f = camera->getViewFrustum(); - - core::vector3df farLeftUp = f->getFarLeftUp(); - core::vector3df lefttoright = f->getFarRightUp() - farLeftUp; - core::vector3df uptodown = f->getFarLeftDown() - farLeftUp; - - core::rect viewPort = Driver->getViewPort(); - core::dimension2d screenSize(viewPort.getWidth(), viewPort.getHeight()); - - f32 dx = pos.X / (f32)screenSize.Width; - f32 dy = pos.Y / (f32)screenSize.Height; - - if (camera->isOrthogonal()) - ln.start = f->cameraPosition + (lefttoright * (dx-0.5f)) + (uptodown * (dy-0.5f)); - else - ln.start = f->cameraPosition; - - ln.end = farLeftUp + (lefttoright * dx) + (uptodown * dy); - - return ln; -} - - - -//! Calculates 2d screen position from a 3d position. -core::position2d CSceneCollisionManager::getScreenCoordinatesFrom3DPosition( - core::vector3df pos3d, ICameraSceneNode* camera) -{ - core::position2d pos2d(-1000,-1000); - - if (!SceneManager || !Driver) - return pos2d; - - if (!camera) - camera = SceneManager->getActiveCamera(); - - if (!camera) - return pos2d; - - core::rect viewPort = Driver->getViewPort(); - core::dimension2d dim(viewPort.getWidth(), viewPort.getHeight()); - - dim.Width /= 2; - dim.Height /= 2; - - f32 transformedPos[4]; - - core::matrix4 trans = camera->getProjectionMatrix(); - trans *= camera->getViewMatrix(); - - transformedPos[0] = pos3d.X; - transformedPos[1] = pos3d.Y; - transformedPos[2] = pos3d.Z; - transformedPos[3] = 1.0f; - - trans.multiplyWith1x4Matrix(transformedPos); - - if (transformedPos[3] < 0) - return core::position2d(-10000,-10000); - - f32 zDiv = transformedPos[3] == 0.0f ? 1.0f : - (1.0f / transformedPos[3]); - - pos2d.X = (s32)(dim.Width * transformedPos[0] * zDiv) + dim.Width; - pos2d.Y = ((s32)(dim.Height - (dim.Height * (transformedPos[1] * zDiv)))); - - return pos2d; -} - -inline bool CSceneCollisionManager::getLowestRoot(f32 a, f32 b, f32 c, f32 maxR, f32* root) -{ - // check if solution exists - f32 determinant = b*b - 4.0f*a*c; - - // if determinant is negative, no solution - if (determinant < 0.0f) return false; - - // calculate two roots: (if det==0 then x1==x2 - // but lets disregard that slight optimization) - // burningwater: sqrt( 0) is an illegal operation.... smth should be done... - - f32 sqrtD = (f32)sqrt(determinant); - - f32 r1 = (-b - sqrtD) / (2*a); - f32 r2 = (-b + sqrtD) / (2*a); - - // sort so x1 <= x2 - if (r1 > r2) { f32 tmp=r2; r2=r1; r1=tmp; } - - // get lowest root - if (r1 > 0 && r1 < maxR) - { - *root = r1; - return true; - } - - // its possible that we want x2, this can happen if x1 < 0 - if (r2 > 0 && r2 < maxR) - { - *root = r2; - return true; - } - - return false; -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSceneCollisionManager.h" +#include "ISceneNode.h" +#include "ICameraSceneNode.h" +#include "ITriangleSelector.h" +#include "SViewFrustum.h" + +#include "os.h" +#include "irrMath.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CSceneCollisionManager::CSceneCollisionManager(ISceneManager* smanager, video::IVideoDriver* driver) +: SceneManager(smanager), Driver(driver) +{ + #ifdef _DEBUG + setDebugName("CSceneCollisionManager"); + #endif + + if (Driver) + Driver->grab(); +} + + + +//! destructor +CSceneCollisionManager::~CSceneCollisionManager() +{ + if (Driver) + Driver->drop(); +} + + + +//! Returns the scene node, which is currently visible under the overgiven +//! screencoordinates, viewed from the currently active camera. +ISceneNode* CSceneCollisionManager::getSceneNodeFromScreenCoordinatesBB( + core::position2d pos, s32 idBitMask, bool bNoDebugObjects) +{ + core::line3d ln = getRayFromScreenCoordinates(pos, 0); + + if ( ln.start == ln.end ) + return 0; + + return getSceneNodeFromRayBB(ln, idBitMask, bNoDebugObjects); +} + + + +//! Returns the nearest scene node which collides with a 3d ray and +//! which id matches a bitmask. +ISceneNode* CSceneCollisionManager::getSceneNodeFromRayBB(core::line3d ray, + s32 idBitMask, + bool bNoDebugObjects) +{ + ISceneNode* best = 0; + f32 dist = 9999999999.0f; + + getPickedNodeBB(SceneManager->getRootSceneNode(), ray, + idBitMask, bNoDebugObjects, dist, best); + + return best; +} + + +//! recursive method for going through all scene nodes +void CSceneCollisionManager::getPickedNodeBB(ISceneNode* root, + const core::line3df& ray, + s32 bits, + bool bNoDebugObjects, + f32& outbestdistance, + ISceneNode*& outbestnode) +{ + core::vector3df edges[8]; + + const core::list& children = root->getChildren(); + + core::list::Iterator it = children.begin(); + for (; it != children.end(); ++it) + { + ISceneNode* current = *it; + + if (current->isVisible() && + (bNoDebugObjects ? !current->isDebugObject() : true) && + (bits==0 || (bits != 0 && (current->getID() & bits)))) + { + // get world to object space transform + core::matrix4 mat; + if (!current->getAbsoluteTransformation().getInverse(mat)) + continue; + + // transform vector from world space to object space + core::line3df line(ray); + mat.transformVect(line.start); + mat.transformVect(line.end); + + const core::aabbox3df& box = current->getBoundingBox(); + + // do intersection test in object space + if (box.intersectsWithLine(line)) + { + box.getEdges(edges); + f32 distance = 0.0f; + + for (s32 e=0; e<8; ++e) + { + f32 t = edges[e].getDistanceFromSQ(line.start); + if (t > distance) + distance = t; + } + + if (distance < outbestdistance) + { + outbestnode = current; + outbestdistance = distance; + } + } + } + + getPickedNodeBB(current, ray, bits, bNoDebugObjects, outbestdistance, outbestnode); + } +} + + + +//! Returns the scene node, at which the overgiven camera is looking at and +//! which id matches the bitmask. +ISceneNode* CSceneCollisionManager::getSceneNodeFromCameraBB( + ICameraSceneNode* camera, s32 idBitMask, bool bNoDebugObjects) +{ + if (!camera) + return 0; + + core::vector3df start = camera->getAbsolutePosition(); + core::vector3df end = camera->getTarget(); + + end = start + ((end - start).normalize() * camera->getFarValue()); + core::line3d line(start, end); + + return getSceneNodeFromRayBB(line, idBitMask, bNoDebugObjects); +} + + + +//! Finds the collision point of a line and lots of triangles, if there is one. +bool CSceneCollisionManager::getCollisionPoint(const core::line3d& ray, + ITriangleSelector* selector, core::vector3df& outIntersection, + core::triangle3df& outTriangle) +{ + if (!selector) + { + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return false; + } + + s32 totalcnt = selector->getTriangleCount(); + Triangles.set_used(totalcnt); + + s32 cnt = 0; + selector->getTriangles(Triangles.pointer(), totalcnt, cnt, ray); + + core::vector3df linevect = ray.getVector().normalize(); + core::vector3df intersection; + f32 nearest = 9999999999999.0f; + bool found = false; + f32 tmp, tmp2; + f32 raylength = (f32)ray.getLengthSQ(); + + for (s32 i=0; i trianglePlane = triangle.getPlane(); + + // only check front facing polygons + if ( !trianglePlane.isFrontFacing(colData->normalizedVelocity) ) + return; + + // get interval of plane intersection + + f32 t1, t0; + bool embeddedInPlane = false; + + // calculate signed distance from sphere position to triangle plane + f32 signedDistToTrianglePlane = trianglePlane.getDistanceTo( + colData->basePoint); + + f32 normalDotVelocity = + trianglePlane.Normal.dotProduct(colData->velocity); + + if ( core::iszero ( normalDotVelocity ) ) + { + // sphere is traveling parallel to plane + + if (fabs(signedDistToTrianglePlane) >= 1.0f) + return; // no collision possible + else + { + // sphere is embedded in plane + embeddedInPlane = true; + t0 = 0.0; + t1 = 1.0; + } + } + else + { + normalDotVelocity = core::reciprocal ( normalDotVelocity ); + + // N.D is not 0. Calculate intersection interval + t0 = (-1.f - signedDistToTrianglePlane) * normalDotVelocity; + t1 = (1.f - signedDistToTrianglePlane) * normalDotVelocity; + + // Swap so t0 < t1 + if (t0 > t1) { f32 tmp = t1; t1 = t0; t0 = tmp; } + + // check if at least one value is within the range + if (t0 > 1.0f || t1 < 0.0f) + return; // both t values are outside 1 and 0, no collision possible + + // clamp to 0 and 1 + t0 = core::clamp ( t0, 0.f, 1.f ); + t1 = core::clamp ( t1, 0.f, 1.f ); + } + + // at this point we have t0 and t1, if there is any intersection, it + // is between this interval + core::vector3df collisionPoint; + bool foundCollision = false; + f32 t = 1.0f; + + // first check the easy case: Collision within the triangle; + // if this happens, it must be at t0 and this is when the sphere + // rests on the front side of the triangle plane. This can only happen + // if the sphere is not embedded in the triangle plane. + + if (!embeddedInPlane) + { + core::vector3df planeIntersectionPoint = + (colData->basePoint - trianglePlane.Normal) + + (colData->velocity * t0); + + if (triangle.isPointInsideFast(planeIntersectionPoint)) + { + foundCollision = true; + t = t0; + collisionPoint = planeIntersectionPoint; + } + } + + // if we havent found a collision already we will have to sweep + // the sphere against points and edges of the triangle. Note: A + // collision inside the triangle will always happen before a + // vertex or edge collision. + + if (!foundCollision) + { + core::vector3df velocity = colData->velocity; + core::vector3df base = colData->basePoint; + + f32 velocitySqaredLength = velocity.getLengthSQ(); + f32 a,b,c; + f32 newT; + + // for each edge or vertex a quadratic equation has to be solved: + // a*t^2 + b*t + c = 0. We calculate a,b, and c for each test. + + // check against points + a = velocitySqaredLength; + + // p1 + b = 2.0f * (velocity.dotProduct(base - triangle.pointA)); + c = (triangle.pointA-base).getLengthSQ() - 1.f; + if (getLowestRoot(a,b,c,t, &newT)) + { + t = newT; + foundCollision = true; + collisionPoint = triangle.pointA; + } + + // p2 + if (!foundCollision) + { + b = 2.0f * (velocity.dotProduct(base - triangle.pointB)); + c = (triangle.pointB-base).getLengthSQ() - 1.f; + if (getLowestRoot(a,b,c,t, &newT)) + { + t = newT; + foundCollision = true; + collisionPoint = triangle.pointB; + } + } + + // p3 + if (!foundCollision) + { + b = 2.0f * (velocity.dotProduct(base - triangle.pointC)); + c = (triangle.pointC-base).getLengthSQ() - 1.f; + if (getLowestRoot(a,b,c,t, &newT)) + { + t = newT; + foundCollision = true; + collisionPoint = triangle.pointC; + } + } + + // check against edges: + + // p1 --- p2 + core::vector3df edge = triangle.pointB - triangle.pointA; + core::vector3df baseToVertex = triangle.pointA - base; + f32 edgeSqaredLength = edge.getLengthSQ(); + f32 edgeDotVelocity = edge.dotProduct(velocity); + f32 edgeDotBaseToVertex = edge.dotProduct(baseToVertex); + + // calculate parameters for equation + a = edgeSqaredLength* -velocitySqaredLength + + edgeDotVelocity*edgeDotVelocity; + b = edgeSqaredLength* (2.f *velocity.dotProduct(baseToVertex)) - + 2.0f*edgeDotVelocity*edgeDotBaseToVertex; + c = edgeSqaredLength* (1.f -baseToVertex.getLengthSQ()) + + edgeDotBaseToVertex*edgeDotBaseToVertex; + + // does the swept sphere collide against infinite edge? + if (getLowestRoot(a,b,c,t,&newT)) + { + f32 f = (edgeDotVelocity*newT - edgeDotBaseToVertex) / edgeSqaredLength; + if (f >=0.0f && f <= 1.0f) + { + // intersection took place within segment + t = newT; + foundCollision = true; + collisionPoint = triangle.pointA + (edge*f); + } + } + + // p2 --- p3 + edge = triangle.pointC-triangle.pointB; + baseToVertex = triangle.pointB - base; + edgeSqaredLength = edge.getLengthSQ(); + edgeDotVelocity = edge.dotProduct(velocity); + edgeDotBaseToVertex = edge.dotProduct(baseToVertex); + + // calculate parameters for equation + a = edgeSqaredLength* -velocitySqaredLength + + edgeDotVelocity*edgeDotVelocity; + b = edgeSqaredLength* (2*velocity.dotProduct(baseToVertex)) - + 2.0f*edgeDotVelocity*edgeDotBaseToVertex; + c = edgeSqaredLength* (1-baseToVertex.getLengthSQ()) + + edgeDotBaseToVertex*edgeDotBaseToVertex; + + // does the swept sphere collide against infinite edge? + if (getLowestRoot(a,b,c,t,&newT)) + { + f32 f = (edgeDotVelocity*newT-edgeDotBaseToVertex) / + edgeSqaredLength; + if (f >=0.0f && f <= 1.0f) + { + // intersection took place within segment + t = newT; + foundCollision = true; + collisionPoint = triangle.pointB + (edge*f); + } + } + + + // p3 --- p1 + edge = triangle.pointA-triangle.pointC; + baseToVertex = triangle.pointC - base; + edgeSqaredLength = edge.getLengthSQ(); + edgeDotVelocity = edge.dotProduct(velocity); + edgeDotBaseToVertex = edge.dotProduct(baseToVertex); + + // calculate parameters for equation + a = edgeSqaredLength* -velocitySqaredLength + + edgeDotVelocity*edgeDotVelocity; + b = edgeSqaredLength* (2*velocity.dotProduct(baseToVertex)) - + 2.0f*edgeDotVelocity*edgeDotBaseToVertex; + c = edgeSqaredLength* (1-baseToVertex.getLengthSQ()) + + edgeDotBaseToVertex*edgeDotBaseToVertex; + + // does the swept sphere collide against infinite edge? + if (getLowestRoot(a,b,c,t,&newT)) + { + f32 f = (edgeDotVelocity*newT-edgeDotBaseToVertex) / + edgeSqaredLength; + if (f >=0.0f && f <= 1.0f) + { + // intersection took place within segment + t = newT; + foundCollision = true; + collisionPoint = triangle.pointC + (edge*f); + } + } + }// end no collision found + + // set result: + if (foundCollision) + { + // distance to collision is t + f32 distToCollision = t*colData->velocity.getLength(); + + // does this triangle qualify for closest hit? + if (!colData->foundCollision || + distToCollision < colData->nearestDistance) + { + colData->nearestDistance = distToCollision; + colData->intersectionPoint = collisionPoint; + colData->foundCollision = true; + colData->intersectionTriangle = triangle; + ++colData->triangleHits; + } + + }// end found collision +} + + + +//! Collides a moving ellipsoid with a 3d world with gravity and returns +//! the resulting new position of the ellipsoid. +core::vector3df CSceneCollisionManager::collideEllipsoidWithWorld( + ITriangleSelector* selector, const core::vector3df &position, + const core::vector3df& radius, const core::vector3df& velocity, + f32 slidingSpeed, + const core::vector3df& gravity, + core::triangle3df& triout, bool& outFalling) +{ + if (!selector || radius.X == 0.0f || radius.Y == 0.0f || radius.Z == 0.0f) + return position; + + // This code is based on the paper "Improved Collision detection and Response" + // by Kasper Fauerby, but some parts are modified. + + SCollisionData colData; + colData.R3Position = position; + colData.R3Velocity = velocity; + colData.eRadius = radius; + colData.nearestDistance = 9999999999999.0f; + colData.selector = selector; + colData.slidingSpeed = slidingSpeed; + colData.triangleHits = 0; + + core::vector3df eSpacePosition = colData.R3Position / colData.eRadius; + core::vector3df eSpaceVelocity = colData.R3Velocity / colData.eRadius; + + // iterate until we have our final position + + core::vector3df finalPos = collideWithWorld( + 0, colData, eSpacePosition, eSpaceVelocity); + + outFalling = false; + + // add gravity + + if (gravity != core::vector3df(0,0,0)) + { + colData.R3Position = finalPos * colData.eRadius; + colData.R3Velocity = gravity; + colData.triangleHits = 0; + + eSpaceVelocity = gravity/colData.eRadius; + + finalPos = collideWithWorld(0, colData, + finalPos, eSpaceVelocity); + + outFalling = (colData.triangleHits == 0); + } + + if (colData.triangleHits) + { + triout = colData.intersectionTriangle; + triout.pointA *= colData.eRadius; + triout.pointB *= colData.eRadius; + triout.pointC *= colData.eRadius; + } + + finalPos *= colData.eRadius; + return finalPos; +} + +core::vector3df CSceneCollisionManager::collideWithWorld(s32 recursionDepth, + SCollisionData &colData, core::vector3df pos, core::vector3df vel) +{ + f32 veryCloseDistance = colData.slidingSpeed; + + if (recursionDepth > 5) + return pos; + + colData.velocity = vel; + colData.normalizedVelocity = vel; + colData.normalizedVelocity.normalize(); + colData.basePoint = pos; + colData.foundCollision = false; + colData.nearestDistance = 9999999999999.0f; + + //------------------ collide with world + + // get all triangles with which we might collide + core::aabbox3d box(colData.R3Position); + box.addInternalPoint(colData.R3Position + colData.R3Velocity); + box.MinEdge -= colData.eRadius; + box.MaxEdge += colData.eRadius; + + s32 totalTriangleCnt = colData.selector->getTriangleCount(); + Triangles.set_used(totalTriangleCnt); + + core::matrix4 scaleMatrix; + scaleMatrix.setScale( + core::vector3df(1.0f / colData.eRadius.X, + 1.0f / colData.eRadius.Y, + 1.0f / colData.eRadius.Z) + ); + + s32 triangleCnt = 0; + colData.selector->getTriangles(Triangles.pointer(), totalTriangleCnt, triangleCnt, box, &scaleMatrix); + //colData.selector->getTriangles(Triangles.pointer(), totalTriangleCnt, triangleCnt, &scaleMatrix); + + for (s32 i=0; i= veryCloseDistance) + { + core::vector3df v = vel; + v.setLength( colData.nearestDistance - veryCloseDistance ); + newBasePoint = colData.basePoint + v; + + v.normalize(); + colData.intersectionPoint -= (v * veryCloseDistance); + } + + // calculate sliding plane + + core::vector3df slidePlaneOrigin = colData.intersectionPoint; + core::vector3df slidePlaneNormal = newBasePoint - colData.intersectionPoint; + slidePlaneNormal.normalize(); + core::plane3d slidingPlane(slidePlaneOrigin, slidePlaneNormal); + + core::vector3df newDestinationPoint = + destinationPoint - + (slidePlaneNormal * slidingPlane.getDistanceTo(destinationPoint)); + + // generate slide vector + + core::vector3df newVelocityVector = newDestinationPoint - + colData.intersectionPoint; + + if (newVelocityVector.getLength() < veryCloseDistance) + return newBasePoint; + + return collideWithWorld(recursionDepth+1, colData, + newBasePoint, newVelocityVector); +} + + +//! Returns a 3d ray which would go through the 2d screen coodinates. +core::line3d CSceneCollisionManager::getRayFromScreenCoordinates( + core::position2d pos, ICameraSceneNode* camera) +{ + core::line3d ln(0,0,0,0,0,0); + + if (!SceneManager) + return ln; + + if (!camera) + camera = SceneManager->getActiveCamera(); + + if (!camera) + return ln; + + const scene::SViewFrustum* f = camera->getViewFrustum(); + + core::vector3df farLeftUp = f->getFarLeftUp(); + core::vector3df lefttoright = f->getFarRightUp() - farLeftUp; + core::vector3df uptodown = f->getFarLeftDown() - farLeftUp; + + core::rect viewPort = Driver->getViewPort(); + core::dimension2d screenSize(viewPort.getWidth(), viewPort.getHeight()); + + f32 dx = pos.X / (f32)screenSize.Width; + f32 dy = pos.Y / (f32)screenSize.Height; + + if (camera->isOrthogonal()) + ln.start = f->cameraPosition + (lefttoright * (dx-0.5f)) + (uptodown * (dy-0.5f)); + else + ln.start = f->cameraPosition; + + ln.end = farLeftUp + (lefttoright * dx) + (uptodown * dy); + + return ln; +} + + + +//! Calculates 2d screen position from a 3d position. +core::position2d CSceneCollisionManager::getScreenCoordinatesFrom3DPosition( + core::vector3df pos3d, ICameraSceneNode* camera) +{ + core::position2d pos2d(-1000,-1000); + + if (!SceneManager || !Driver) + return pos2d; + + if (!camera) + camera = SceneManager->getActiveCamera(); + + if (!camera) + return pos2d; + + core::rect viewPort = Driver->getViewPort(); + core::dimension2d dim(viewPort.getWidth(), viewPort.getHeight()); + + dim.Width /= 2; + dim.Height /= 2; + + f32 transformedPos[4]; + + core::matrix4 trans = camera->getProjectionMatrix(); + trans *= camera->getViewMatrix(); + + transformedPos[0] = pos3d.X; + transformedPos[1] = pos3d.Y; + transformedPos[2] = pos3d.Z; + transformedPos[3] = 1.0f; + + trans.multiplyWith1x4Matrix(transformedPos); + + if (transformedPos[3] < 0) + return core::position2d(-10000,-10000); + + f32 zDiv = transformedPos[3] == 0.0f ? 1.0f : + (1.0f / transformedPos[3]); + + pos2d.X = (s32)(dim.Width * transformedPos[0] * zDiv) + dim.Width; + pos2d.Y = ((s32)(dim.Height - (dim.Height * (transformedPos[1] * zDiv)))); + + return pos2d; +} + +inline bool CSceneCollisionManager::getLowestRoot(f32 a, f32 b, f32 c, f32 maxR, f32* root) +{ + // check if solution exists + f32 determinant = b*b - 4.0f*a*c; + + // if determinant is negative, no solution + if (determinant < 0.0f) return false; + + // calculate two roots: (if det==0 then x1==x2 + // but lets disregard that slight optimization) + // burningwater: sqrt( 0) is an illegal operation.... smth should be done... + + f32 sqrtD = (f32)sqrt(determinant); + + f32 r1 = (-b - sqrtD) / (2*a); + f32 r2 = (-b + sqrtD) / (2*a); + + // sort so x1 <= x2 + if (r1 > r2) { f32 tmp=r2; r2=r1; r1=tmp; } + + // get lowest root + if (r1 > 0 && r1 < maxR) + { + *root = r1; + return true; + } + + // its possible that we want x2, this can happen if x1 < 0 + if (r2 > 0 && r2 < maxR) + { + *root = r2; + return true; + } + + return false; +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CSceneCollisionManager.h b/src/dep/src/irrlicht/CSceneCollisionManager.h index 0194914..288e411 100644 --- a/src/dep/src/irrlicht/CSceneCollisionManager.h +++ b/src/dep/src/irrlicht/CSceneCollisionManager.h @@ -1,126 +1,126 @@ -#ifndef __C_SCENE_COLLISION_MANAGER_H_INCLUDED__ -#define __C_SCENE_COLLISION_MANAGER_H_INCLUDED__ - -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "ISceneCollisionManager.h" -#include "ISceneManager.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace scene -{ - - //! The Scene Collision Manager provides methods for performing collision tests and picking on scene nodes. - class CSceneCollisionManager : public ISceneCollisionManager - { - public: - - //! constructor - CSceneCollisionManager(ISceneManager* smanager, video::IVideoDriver* driver); - - //! destructor - virtual ~CSceneCollisionManager(); - - //! Returns the scene node, which is currently visible under the overgiven - //! screencoordinates, viewed from the currently active camera. - virtual ISceneNode* getSceneNodeFromScreenCoordinatesBB(core::position2d pos, - s32 idBitMask=0, bool bNoDebugObjects = false); - - //! Returns the nearest scene node which collides with a 3d ray and - //! which id matches a bitmask. - virtual ISceneNode* getSceneNodeFromRayBB(core::line3d ray, s32 idBitMask=0, - bool bNoDebugObjects = false); - - //! Returns the scene node, at which the overgiven camera is looking at and - //! which id matches the bitmask. - virtual ISceneNode* getSceneNodeFromCameraBB(ICameraSceneNode* camera, s32 idBitMask=0, - bool bNoDebugObjects = false); - - //! Finds the collision point of a line and lots of triangles, if there is one. - virtual bool getCollisionPoint(const core::line3d& ray, - ITriangleSelector* selector, core::vector3df& outCollisionPoint, - core::triangle3df& outTriangle); - - //! Collides a moving ellipsoid with a 3d world with gravity and returns - //! the resulting new position of the ellipsoid. - virtual core::vector3df getCollisionResultPosition( - ITriangleSelector* selector, - const core::vector3df &ellipsoidPosition, const core::vector3df& ellipsoidRadius, - const core::vector3df& ellipsoidDirectionAndSpeed, - core::triangle3df& triout, - bool& outFalling, - f32 slidingSpeed, - const core::vector3df& gravityDirectionAndSpeed); - - //! Returns a 3d ray which would go through the 2d screen coodinates. - virtual core::line3d getRayFromScreenCoordinates( - core::position2d pos, ICameraSceneNode* camera = 0); - - //! Calculates 2d screen position from a 3d position. - virtual core::position2d getScreenCoordinatesFrom3DPosition( - core::vector3df pos, ICameraSceneNode* camera=0); - - private: - - //! recursive method for going through all scene nodes - void getPickedNodeBB(ISceneNode* root, - const core::line3df& ray, - s32 bits, - bool bNoDebugObjects, - f32& outbestdistance, - ISceneNode*& outbestnode); - - struct SCollisionData - { - core::vector3df eRadius; - - core::vector3df R3Velocity; - core::vector3df R3Position; - - core::vector3df velocity; - core::vector3df normalizedVelocity; - core::vector3df basePoint; - - bool foundCollision; - f32 nearestDistance; - core::vector3df intersectionPoint; - - core::triangle3df intersectionTriangle; - s32 triangleHits; - - f32 slidingSpeed; - - ITriangleSelector* selector; - }; - - void testTriangleIntersection(SCollisionData* colData, - const core::triangle3df& triangle); - - //! recursive method for doing collision response - core::vector3df collideEllipsoidWithWorld(ITriangleSelector* selector, - const core::vector3df &position, - const core::vector3df& radius, const core::vector3df& velocity, - f32 slidingSpeed, - const core::vector3df& gravity, core::triangle3df& triout, - bool& outFalling); - - core::vector3df collideWithWorld(s32 recursionDepth, SCollisionData &colData, - core::vector3df pos, core::vector3df vel); - - inline bool getLowestRoot(f32 a, f32 b, f32 c, f32 maxR, f32* root); - - ISceneManager* SceneManager; - video::IVideoDriver* Driver; - core::array Triangles; // triangle buffer - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +#ifndef __C_SCENE_COLLISION_MANAGER_H_INCLUDED__ +#define __C_SCENE_COLLISION_MANAGER_H_INCLUDED__ + +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "ISceneCollisionManager.h" +#include "ISceneManager.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace scene +{ + + //! The Scene Collision Manager provides methods for performing collision tests and picking on scene nodes. + class CSceneCollisionManager : public ISceneCollisionManager + { + public: + + //! constructor + CSceneCollisionManager(ISceneManager* smanager, video::IVideoDriver* driver); + + //! destructor + virtual ~CSceneCollisionManager(); + + //! Returns the scene node, which is currently visible under the overgiven + //! screencoordinates, viewed from the currently active camera. + virtual ISceneNode* getSceneNodeFromScreenCoordinatesBB(core::position2d pos, + s32 idBitMask=0, bool bNoDebugObjects = false); + + //! Returns the nearest scene node which collides with a 3d ray and + //! which id matches a bitmask. + virtual ISceneNode* getSceneNodeFromRayBB(core::line3d ray, s32 idBitMask=0, + bool bNoDebugObjects = false); + + //! Returns the scene node, at which the overgiven camera is looking at and + //! which id matches the bitmask. + virtual ISceneNode* getSceneNodeFromCameraBB(ICameraSceneNode* camera, s32 idBitMask=0, + bool bNoDebugObjects = false); + + //! Finds the collision point of a line and lots of triangles, if there is one. + virtual bool getCollisionPoint(const core::line3d& ray, + ITriangleSelector* selector, core::vector3df& outCollisionPoint, + core::triangle3df& outTriangle); + + //! Collides a moving ellipsoid with a 3d world with gravity and returns + //! the resulting new position of the ellipsoid. + virtual core::vector3df getCollisionResultPosition( + ITriangleSelector* selector, + const core::vector3df &ellipsoidPosition, const core::vector3df& ellipsoidRadius, + const core::vector3df& ellipsoidDirectionAndSpeed, + core::triangle3df& triout, + bool& outFalling, + f32 slidingSpeed, + const core::vector3df& gravityDirectionAndSpeed); + + //! Returns a 3d ray which would go through the 2d screen coodinates. + virtual core::line3d getRayFromScreenCoordinates( + core::position2d pos, ICameraSceneNode* camera = 0); + + //! Calculates 2d screen position from a 3d position. + virtual core::position2d getScreenCoordinatesFrom3DPosition( + core::vector3df pos, ICameraSceneNode* camera=0); + + private: + + //! recursive method for going through all scene nodes + void getPickedNodeBB(ISceneNode* root, + const core::line3df& ray, + s32 bits, + bool bNoDebugObjects, + f32& outbestdistance, + ISceneNode*& outbestnode); + + struct SCollisionData + { + core::vector3df eRadius; + + core::vector3df R3Velocity; + core::vector3df R3Position; + + core::vector3df velocity; + core::vector3df normalizedVelocity; + core::vector3df basePoint; + + bool foundCollision; + f32 nearestDistance; + core::vector3df intersectionPoint; + + core::triangle3df intersectionTriangle; + s32 triangleHits; + + f32 slidingSpeed; + + ITriangleSelector* selector; + }; + + void testTriangleIntersection(SCollisionData* colData, + const core::triangle3df& triangle); + + //! recursive method for doing collision response + core::vector3df collideEllipsoidWithWorld(ITriangleSelector* selector, + const core::vector3df &position, + const core::vector3df& radius, const core::vector3df& velocity, + f32 slidingSpeed, + const core::vector3df& gravity, core::triangle3df& triout, + bool& outFalling); + + core::vector3df collideWithWorld(s32 recursionDepth, SCollisionData &colData, + core::vector3df pos, core::vector3df vel); + + inline bool getLowestRoot(f32 a, f32 b, f32 c, f32 maxR, f32* root); + + ISceneManager* SceneManager; + video::IVideoDriver* Driver; + core::array Triangles; // triangle buffer + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CSceneManager.cpp b/src/dep/src/irrlicht/CSceneManager.cpp index 45033d7..2da12b2 100644 --- a/src/dep/src/irrlicht/CSceneManager.cpp +++ b/src/dep/src/irrlicht/CSceneManager.cpp @@ -1,1995 +1,1995 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneManager.h" -#include "IVideoDriver.h" -#include "IFileSystem.h" -#include "IAnimatedMesh.h" -#include "CMeshCache.h" -#include "IWriteFile.h" -#include "IXMLWriter.h" -#include "ISceneUserDataSerializer.h" - -#include "os.h" - -#include "CGeometryCreator.h" - -#include "CDefaultMeshFormatLoader.h" -#include "C3DSMeshFileLoader.h" -#include "CXMeshFileLoader.h" -#include "COCTLoader.h" -#include "CCSMLoader.h" -#include "CLMTSMeshFileLoader.h" -#include "CMY3DMeshFileLoader.h" -#include "CColladaFileLoader.h" -#include "CDMFLoader.h" -#include "COgreMeshFileLoader.h" -#include "COBJMeshFileLoader.h" -#include "CMD3MeshFileLoader.h" - -#include "CCubeSceneNode.h" -#include "CSphereSceneNode.h" -#include "CAnimatedMeshSceneNode.h" -#include "COctTreeSceneNode.h" -#include "CCameraSceneNode.h" -#include "CCameraMayaSceneNode.h" -#include "CCameraFPSSceneNode.h" -#include "CLightSceneNode.h" -#include "CBillboardSceneNode.h" -#include "CMeshSceneNode.h" -#include "CSkyBoxSceneNode.h" -#include "CSkyDomeSceneNode.h" -#include "CParticleSystemSceneNode.h" -#include "CDummyTransformationSceneNode.h" -#include "CWaterSurfaceSceneNode.h" -#include "CTerrainSceneNode.h" -#include "CEmptySceneNode.h" -#include "CTextSceneNode.h" -#include "CDefaultSceneNodeFactory.h" - -#include "CSceneCollisionManager.h" -#include "CMeshManipulator.h" -#include "CTriangleSelector.h" -#include "COctTreeTriangleSelector.h" -#include "CTriangleBBSelector.h" -#include "CMetaTriangleSelector.h" -#include "CTerrainTriangleSelector.h" - -#include "CSceneNodeAnimatorRotation.h" -#include "CSceneNodeAnimatorFlyCircle.h" -#include "CSceneNodeAnimatorFlyStraight.h" -#include "CSceneNodeAnimatorTexture.h" -#include "CSceneNodeAnimatorCollisionResponse.h" -#include "CSceneNodeAnimatorDelete.h" -#include "CSceneNodeAnimatorFollowSpline.h" -#include "CDefaultSceneNodeAnimatorFactory.h" - -#include "CQuake3ShaderSceneNode.h" - -//! Enable debug features -#define SCENEMANAGER_DEBUG - -namespace irr -{ -namespace scene -{ - -//! constructor -CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, - gui::ICursorControl* cursorControl, CMeshCache* cache, - gui::IGUIEnvironment * gui) -: ISceneNode(0, 0), Driver(driver), FileSystem(fs), GUIEnvironment(gui), - CursorControl(cursorControl), CollisionManager(0), MeshManipulator(0), - ActiveCamera(0), ShadowColor(150,0,0,0), AmbientLight(0,0,0,0), - MeshCache(cache), CurrentRendertime(ESNRP_COUNT), - IRR_XML_FORMAT_SCENE(L"irr_scene"), IRR_XML_FORMAT_NODE(L"node"), IRR_XML_FORMAT_NODE_ATTR_TYPE(L"type") -{ - #ifdef _DEBUG - ISceneManager::setDebugName("CSceneManager ISceneManager"); - ISceneNode::setDebugName("CSceneManager ISceneNode"); - #endif - - if (Driver) - Driver->grab(); - - if (FileSystem) - FileSystem->grab(); - - if (CursorControl) - CursorControl->grab(); - - if ( GUIEnvironment ) - GUIEnvironment->grab (); - - // create mesh cache if not there already - if (!MeshCache) - MeshCache = new CMeshCache(); - else - MeshCache->grab(); - - // create collision manager - CollisionManager = new CSceneCollisionManager(this, Driver); - - // create manipulator - MeshManipulator = new CMeshManipulator(); - - // add default format loader - - MeshLoaderList.push_back(new CDefaultMeshFormatLoader(FileSystem, Driver, this)); - MeshLoaderList.push_back(new C3DSMeshFileLoader(MeshManipulator,FileSystem, Driver)); - MeshLoaderList.push_back(new CXMeshFileLoader(MeshManipulator, Driver)); - MeshLoaderList.push_back(new COCTLoader(Driver)); - MeshLoaderList.push_back(new CCSMLoader(this, FileSystem)); - MeshLoaderList.push_back(new CLMTSMeshFileLoader(FileSystem, Driver, &Parameters)); - MeshLoaderList.push_back(new CMY3DMeshFileLoader(FileSystem, Driver, this)); - MeshLoaderList.push_back(new CColladaFileLoader(Driver, this, FileSystem)); - MeshLoaderList.push_back(new CDMFLoader(Driver, this)); - MeshLoaderList.push_back(new COgreMeshFileLoader(MeshManipulator, FileSystem, Driver)); - MeshLoaderList.push_back(new COBJMeshFileLoader(FileSystem, Driver)); - MeshLoaderList.push_back(new CMD3MeshFileLoader(FileSystem, Driver)); - // factories - - ISceneNodeFactory* factory = new CDefaultSceneNodeFactory(this); - registerSceneNodeFactory(factory); - factory->drop(); - - ISceneNodeAnimatorFactory* animatorFactory = new CDefaultSceneNodeAnimatorFactory(this); - registerSceneNodeAnimatorFactory(animatorFactory); - animatorFactory->drop(); -} - - - -//! destructor -CSceneManager::~CSceneManager() -{ - clearDeletionList(); - - if (Driver) - Driver->drop(); - - if (FileSystem) - FileSystem->drop(); - - if (CursorControl) - CursorControl->drop(); - - if (CollisionManager) - CollisionManager->drop(); - - if (MeshManipulator) - MeshManipulator->drop(); - - if ( GUIEnvironment ) - GUIEnvironment->drop (); - - u32 i; - - for (i=0; idrop(); - - if (ActiveCamera) - ActiveCamera->drop(); - - if (MeshCache) - MeshCache->drop(); - - for (i=0; idrop(); - - for (i=0; idrop(); -} - - -//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped. -IAnimatedMesh* CSceneManager::getMesh(const c8* filename) -{ - IAnimatedMesh* msh = 0; - - core::stringc name = filename; - name.make_lower(); - - msh = MeshCache->findMesh(name.c_str()); - if (msh) - return msh; - - io::IReadFile* file = FileSystem->createAndOpenFile(filename); - if (!file) - { - os::Printer::log("Could not load mesh, because file could not be opened.", filename, ELL_ERROR); - return 0; - } - - s32 count = MeshLoaderList.size(); - for (s32 i=count-1; i>=0; --i) - { - if (MeshLoaderList[i]->isALoadableFileExtension(name.c_str())) - { - // reset file to avoid side effects of previous calls to createMesh - file->seek(0); - msh = MeshLoaderList[i]->createMesh(file); - if (msh) - { - MeshCache->addMesh(filename, msh); - msh->drop(); - break; - } - } - } - - file->drop(); - - if (!msh) - os::Printer::log("Could not load mesh, file format seems to be unsupported", filename, ELL_ERROR); - else - os::Printer::log("Loaded mesh", filename, ELL_INFORMATION); - - return msh; -} - - -//! returns the video driver -video::IVideoDriver* CSceneManager::getVideoDriver() -{ - return Driver; -} - -//! returns the GUI Environment -gui::IGUIEnvironment* CSceneManager::getGUIEnvironment () -{ - return GUIEnvironment; -} -//! Adds a text scene node, which is able to display -//! 2d text at a position in three dimensional space -ITextSceneNode* CSceneManager::addTextSceneNode(gui::IGUIFont* font, const wchar_t* text, - video::SColor color, - ISceneNode* parent, const core::vector3df& position, - s32 id) -{ - if (!font) - return 0; - - if (!parent) - parent = this; - - ITextSceneNode* t = new CTextSceneNode(parent, this, id, font, - getSceneCollisionManager(), position, text, color); - t->drop(); - - return t; -} - -//! Adds a text scene node, which uses billboards -ITextSceneNode* CSceneManager::addBillboardTextSceneNode(gui::IGUIFont* font, const wchar_t* text, - ISceneNode* parent, - const core::dimension2d& size, - const core::vector3df& position, s32 id, - video::SColor shade_top, video::SColor shade_down) -{ - if (!font) - return 0; - - if (!parent) - parent = this; - - ITextSceneNode* node = new CBillboardTextSceneNode(parent, this, id, font, text, position, size, - shade_top, shade_down); - node->drop(); - - return node; - -} - - -//! Adds a scene node, which can render a quake3 shader -ISceneNode* CSceneManager::addQuake3SceneNode( IMeshBuffer* meshBuffer, - const quake3::SShader * shader, - ISceneNode* parent, - s32 id - ) - -{ - if ( 0 == shader ) - return 0; - - if (!parent) - parent = this; - - CQuake3ShaderSceneNode* node = new CQuake3ShaderSceneNode ( parent, this, id, FileSystem, meshBuffer, shader ); - node->drop(); - - return node; - -} - - -//! adds a test scene node for test purposes to the scene. It is a simple cube of (1,1,1) size. -//! the returned pointer must not be dropped. -ISceneNode* CSceneManager::addCubeSceneNode(f32 size, ISceneNode* parent, s32 id, - const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) -{ - if (!parent) - parent = this; - - ISceneNode* node = new CCubeSceneNode(size, parent, this, id, position, rotation, scale); - node->drop(); - - return node; -} - -//! Adds a sphere scene node for test purposes to the scene. -ISceneNode* CSceneManager::addSphereSceneNode(f32 radius, s32 polyCount, ISceneNode* parent, s32 id, - const core::vector3df& position, - const core::vector3df& rotation, - const core::vector3df& scale) -{ - if (!parent) - parent = this; - - ISceneNode* node = new CSphereSceneNode(radius, polyCount, parent, this, id, position, rotation, scale); - node->drop(); - - return node; -} - - -//! adds a scene node for rendering a static mesh -//! the returned pointer must not be dropped. -IMeshSceneNode* CSceneManager::addMeshSceneNode(IMesh* mesh, ISceneNode* parent, s32 id, - const core::vector3df& position, const core::vector3df& rotation, - const core::vector3df& scale, bool alsoAddIfMeshPointerZero) -{ - if (!alsoAddIfMeshPointerZero && !mesh) - return 0; - - if (!parent) - parent = this; - - IMeshSceneNode* node = new CMeshSceneNode(mesh, parent, this, id, position, rotation, scale); - node->drop(); - - return node; -} - - -//! Adds a scene node for rendering a animated water surface mesh. -ISceneNode* CSceneManager::addWaterSurfaceSceneNode(IMesh* mesh, f32 waveHeight, f32 waveSpeed, f32 waveLength, - ISceneNode* parent, s32 id, const core::vector3df& position, - const core::vector3df& rotation, const core::vector3df& scale) -{ - if (!mesh) - return 0; - - if (!parent) - parent = this; - - ISceneNode* node = new CWaterSurfaceSceneNode(waveHeight, waveSpeed, waveLength, - mesh, parent, this, id, position, rotation, scale); - - node->drop(); - - return node; -} - - - -//! adds a scene node for rendering an animated mesh model -IAnimatedMeshSceneNode* CSceneManager::addAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, s32 id, - const core::vector3df& position, const core::vector3df& rotation, - const core::vector3df& scale, bool alsoAddIfMeshPointerZero) -{ - if (!alsoAddIfMeshPointerZero && !mesh) - return 0; - - if (!parent) - parent = this; - - IAnimatedMeshSceneNode* node = - new CAnimatedMeshSceneNode(mesh, parent, this, id, position, rotation, scale); - node->drop(); - - return node; -} - - -//! Adds a scene node for rendering using a octtree to the scene graph. This a good method for rendering -//! scenes with lots of geometry. The Octree is built on the fly from the mesh, much -//! faster then a bsp tree. -ISceneNode* CSceneManager::addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, - s32 id, s32 minimalPolysPerNode, bool alsoAddIfMeshPointerZero) -{ - if (!alsoAddIfMeshPointerZero && (!mesh || !mesh->getFrameCount())) - return 0; - - return addOctTreeSceneNode(mesh ? mesh->getMesh(0) : 0, - parent, id, minimalPolysPerNode, - alsoAddIfMeshPointerZero); -} - - - -//! Adss a scene node for rendering using a octtree. This a good method for rendering -//! scenes with lots of geometry. The Octree is built on the fly from the mesh, much -//! faster then a bsp tree. -ISceneNode* CSceneManager::addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent, - s32 id, s32 minimalPolysPerNode, - bool alsoAddIfMeshPointerZero) -{ - if (!alsoAddIfMeshPointerZero && !mesh) - return 0; - - if (!parent) - parent = this; - - COctTreeSceneNode* node = new COctTreeSceneNode(parent, this, id, minimalPolysPerNode); - - if (mesh) - node->createTree(mesh); - - node->drop(); - - return node; -} - - -//! Adds a camera scene node to the tree and sets it as active camera. -//! \param position: Position of the space relative to its parent where the camera will be placed. -//! \param lookat: Position where the camera will look at. Also known as target. -//! \param parent: Parent scene node of the camera. Can be null. If the parent moves, -//! the camera will move too. -//! \return Returns pointer to interface to camera -ICameraSceneNode* CSceneManager::addCameraSceneNode(ISceneNode* parent, - const core::vector3df& position, const core::vector3df& lookat, s32 id) -{ - if (!parent) - parent = this; - - ICameraSceneNode* node = new CCameraSceneNode(parent, this, id, position, lookat); - node->drop(); - - setActiveCamera(node); - - return node; -} - - - -//! Adds a camera scene node which is able to be controlle with the mouse similar -//! like in the 3D Software Maya by Alias Wavefront. -//! The returned pointer must not be dropped. -ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent, - f32 rotateSpeed, f32 zoomSpeed, f32 translationSpeed, s32 id) -{ - if (!parent) - parent = this; - - ICameraSceneNode* node = new CCameraMayaSceneNode(parent, this, id, rotateSpeed, - zoomSpeed, translationSpeed); - node->drop(); - - setActiveCamera(node); - - return node; -} - - - -//! Adds a camera scene node which is able to be controled with the mouse and keys -//! like in most first person shooters (FPS): -ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent, - f32 rotateSpeed, f32 moveSpeed, s32 id, - SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement,f32 jumpSpeed) -{ - if (!parent) - parent = this; - - ICameraSceneNode* node = new CCameraFPSSceneNode(parent, this, CursorControl, - id, rotateSpeed, moveSpeed, jumpSpeed, keyMapArray, keyMapSize, noVerticalMovement); - node->drop(); - - setActiveCamera(node); - - return node; -} - - - -//! Adds a dynamic light scene node. The light will cast dynamic light on all -//! other scene nodes in the scene, which have the material flag video::MTF_LIGHTING -//! turned on. (This is the default setting in most scene nodes). -ILightSceneNode* CSceneManager::addLightSceneNode(ISceneNode* parent, - const core::vector3df& position, video::SColorf color, f32 range, s32 id) -{ - if (!parent) - parent = this; - - ILightSceneNode* node = new CLightSceneNode(parent, this, id, position, color, range); - node->drop(); - - return node; -} - - - -//! Adds a billboard scene node to the scene. A billboard is like a 3d sprite: A 2d element, -//! which always looks to the camera. It is usually used for things like explosions, fire, -//! lensflares and things like that. -IBillboardSceneNode* CSceneManager::addBillboardSceneNode(ISceneNode* parent, - const core::dimension2d& size, const core::vector3df& position, s32 id, - video::SColor shade_top, video::SColor shade_down - ) -{ - if (!parent) - parent = this; - - IBillboardSceneNode* node = new CBillboardSceneNode(parent, this, id, position, size, - shade_top, shade_down); - node->drop(); - - return node; -} - - - -//! Adds a skybox scene node. A skybox is a big cube with 6 textures on it and -//! is drawn around the camera position. -ISceneNode* CSceneManager::addSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, - video::ITexture* left, video::ITexture* right, video::ITexture* front, - video::ITexture* back, ISceneNode* parent, s32 id) -{ - if (!parent) - parent = this; - - ISceneNode* node = new CSkyBoxSceneNode(top, bottom, left, right, - front, back, parent, this, id); - - node->drop(); - return node; -} - - -//! Adds a skydome scene node. A skydome is a large (half-) sphere with a -//! panoramic texture on it and is drawn around the camera position. -ISceneNode* CSceneManager::addSkyDomeSceneNode(video::ITexture* texture, - u32 horiRes, u32 vertRes, f64 texturePercentage, - f64 spherePercentage, ISceneNode* parent, s32 id) -{ - if (!parent) - parent = this; - - ISceneNode* node = new CSkyDomeSceneNode(texture, horiRes, vertRes, - texturePercentage, spherePercentage, parent, this, id); - - node->drop(); - return node; -} - - -//! Adds a particle system scene node. -IParticleSystemSceneNode* CSceneManager::addParticleSystemSceneNode( - bool withDefaultEmitter, ISceneNode* parent, s32 id, - const core::vector3df& position, const core::vector3df& rotation, - const core::vector3df& scale) -{ - if (!parent) - parent = this; - - IParticleSystemSceneNode* node = new CParticleSystemSceneNode(withDefaultEmitter, - parent, this, id, position, rotation, scale); - node->drop(); - - return node; -} - - -//! Adds a terrain scene node to the scene graph. -ITerrainSceneNode* CSceneManager::addTerrainSceneNode( - const char* heightMapFileName, - ISceneNode* parent, s32 id, - const core::vector3df& position, - const core::vector3df& rotation, - const core::vector3df& scale, - video::SColor vertexColor, - s32 maxLOD, E_TERRAIN_PATCH_SIZE patchSize, s32 smoothFactor) -{ - io::IReadFile* file = FileSystem->createAndOpenFile(heightMapFileName); - if (!file) - { - os::Printer::log("Could not load terrain, because file could not be opened.", - heightMapFileName, ELL_ERROR); - return 0; - } - - ITerrainSceneNode* terrain = addTerrainSceneNode(file, parent, id, - position, rotation, scale, vertexColor, maxLOD, patchSize, smoothFactor); - file->drop(); - - return terrain; -} - -//! Adds a terrain scene node to the scene graph. -ITerrainSceneNode* CSceneManager::addTerrainSceneNode( - io::IReadFile* heightMapFile, - ISceneNode* parent, s32 id, - const core::vector3df& position, - const core::vector3df& rotation, - const core::vector3df& scale, - video::SColor vertexColor, - s32 maxLOD, E_TERRAIN_PATCH_SIZE patchSize, - s32 smoothFactor) -{ - if (!parent) - parent = this; - - CTerrainSceneNode* node = new CTerrainSceneNode(parent, this, id, - maxLOD, patchSize, position, rotation, scale); - - if (!node->loadHeightMap(heightMapFile, vertexColor, smoothFactor)) - { - node->remove(); - node->drop(); - return 0; - } - - node->drop(); - return node; -} - - -//! Adds an empty scene node. -ISceneNode* CSceneManager::addEmptySceneNode(ISceneNode* parent, s32 id) -{ - if (!parent) - parent = this; - - ISceneNode* node = new CEmptySceneNode(parent, this, id); - node->drop(); - - return node; -} - - -//! Adds a dummy transformation scene node to the scene graph. -IDummyTransformationSceneNode* CSceneManager::addDummyTransformationSceneNode( - ISceneNode* parent, s32 id) -{ - if (!parent) - parent = this; - - IDummyTransformationSceneNode* node = new CDummyTransformationSceneNode( - parent, this, id); - node->drop(); - - return node; -} - -//! Adds a Hill Plane mesh to the mesh pool. The mesh is generated on the fly -//! and looks like a plane with some hills on it. It is uses mostly for quick -//! tests of the engine only. You can specify how many hills there should be -//! on the plane and how high they should be. Also you must specify a name for -//! the mesh, because the mesh is added to the mesh pool, and can be retieved -//! again using ISceneManager::getMesh with the name as parameter. -IAnimatedMesh* CSceneManager::addHillPlaneMesh(const c8* name, - const core::dimension2d& tileSize, const core::dimension2d& tileCount, - video::SMaterial* material, f32 hillHeight, const core::dimension2d& countHills, - const core::dimension2d& textureRepeatCount) -{ - if (!name || MeshCache->isMeshLoaded(name)) - return 0; - - IAnimatedMesh* animatedMesh = CGeometryCreator::createHillPlaneMesh(tileSize, - tileCount, material, hillHeight, countHills, textureRepeatCount); - - MeshCache->addMesh(name, animatedMesh); - - animatedMesh->drop(); - - return animatedMesh; -} - - -//! Adds a terrain mesh to the mesh pool. -IAnimatedMesh* CSceneManager::addTerrainMesh(const c8* name, - video::IImage* texture, video::IImage* heightmap, - const core::dimension2d& stretchSize, - f32 maxHeight, - const core::dimension2d& defaultVertexBlockSize) -{ - if (!name || MeshCache->isMeshLoaded(name)) - return 0; - - IAnimatedMesh* animatedMesh = CGeometryCreator::createTerrainMesh(texture, - heightmap, stretchSize, maxHeight, getVideoDriver(), defaultVertexBlockSize); - - if (!animatedMesh) - return 0; - - MeshCache->addMesh(name, animatedMesh); - - animatedMesh->drop(); - - return animatedMesh; -} - -//! Adds an arrow mesh to the mesh pool. -IAnimatedMesh* CSceneManager::addArrowMesh(const c8* name,u32 tesselationCylinder, u32 tesselationCone, f32 height, f32 cylinderHeight, f32 width0,f32 width1, video::SColor vtxColor0, video::SColor vtxColor1) -{ - - if (!name || MeshCache->isMeshLoaded(name)) - return 0; - - IAnimatedMesh* animatedMesh = CGeometryCreator::createArrowMesh( - tesselationCylinder, tesselationCone, height, cylinderHeight, width0,width1, vtxColor0, vtxColor1); - - if (!animatedMesh) - return 0; - - MeshCache->addMesh(name, animatedMesh); - - animatedMesh->drop(); - - return animatedMesh; -} - - - -//! Returns the root scene node. This is the scene node wich is parent -//! of all scene nodes. The root scene node is a special scene node which -//! only exists to manage all scene nodes. It is not rendered and cannot -//! be removed from the scene. -//! \return Returns a pointer to the root scene node. -ISceneNode* CSceneManager::getRootSceneNode() -{ - return this; -} - - - -//! Returns the current active camera. -//! \return The active camera is returned. Note that this can be NULL, if there -//! was no camera created yet. -ICameraSceneNode* CSceneManager::getActiveCamera() -{ - return ActiveCamera; -} - - - -//! Sets the active camera. The previous active camera will be deactivated. -//! \param camera: The new camera which should be active. -void CSceneManager::setActiveCamera(ICameraSceneNode* camera) -{ - if (ActiveCamera) - ActiveCamera->drop(); - - ActiveCamera = camera; - - if (ActiveCamera) - ActiveCamera->grab(); -} - - - - -//! renders the node. -void CSceneManager::render() -{ -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CSceneManager::getBoundingBox() const -{ - _IRR_DEBUG_BREAK_IF(true) // Bounding Box of Scene Manager wanted. - - // should never be used. - return *((core::aabbox3d*)0); -} - - - -//! returns if node is culled -bool CSceneManager::isCulled(ISceneNode* node) -{ - ICameraSceneNode* cam = getActiveCamera(); - if (!cam) - return false; - - switch ( node->getAutomaticCulling() ) - { - // can be seen by a bounding box ? - case scene::EAC_BOX: - { - core::aabbox3d tbox = node->getBoundingBox(); - node->getAbsoluteTransformation().transformBox(tbox); - return !(tbox.intersectsWithBox(cam->getViewFrustum()->getBoundingBox() )); - }; - break; - - // can be seen by a bounding sphere - case scene::EAC_FRUSTUM_SPHERE: - { - }; - break; - - // can be seen by cam pyramid planes ? - case scene::EAC_FRUSTUM_BOX: - { - - SViewFrustum frust = *cam->getViewFrustum(); - - //transform the frustum to the node's current absolute transformation - core::matrix4 invTrans(node->getAbsoluteTransformation()); - invTrans.makeInverse(); - frust.transform(invTrans); - - core::vector3df edges[8]; - node->getBoundingBox().getEdges(edges); - - bool visible = true; - for (s32 i=0; igetMaterialCount(); - - taken = 0; - for (u32 i=0; igetMaterialRenderer(node->getMaterial(i).MaterialType); - if (rnd && rnd->isTransparent()) - { - // register as transparent node - TransparentNodeEntry e(node, camWorldPos); - TransparentNodeList.push_back(e); - taken = 1; - break; - } - } - - // not transparent, register as solid - if ( 0 == taken ) - { - SolidNodeList.push_back( node ); - taken = 1; - } - } - break; - case ESNRP_SHADOW: - if (!isCulled(node)) - { - ShadowNodeList.push_back(node); - taken = 1; - } - break; - case ESNRP_SHADER_0: - case ESNRP_SHADER_1: - case ESNRP_SHADER_2: - case ESNRP_SHADER_3: - case ESNRP_SHADER_4: - case ESNRP_SHADER_5: - case ESNRP_SHADER_6: - case ESNRP_SHADER_7: - case ESNRP_SHADER_8: - case ESNRP_SHADER_9: - case ESNRP_SHADER_10: - if ( !isCulled(node) ) - { - ShaderNodeList[ time - ESNRP_SHADER_0].push_back( ShaderNodeEntry ( node,time - ESNRP_SHADER_0 )); - taken = 1; - } break; - - case ESNRP_COUNT: // ignore this one - break; - } - -#ifdef SCENEMANAGER_DEBUG - s32 index = Parameters.findAttribute ( "calls" ); - Parameters.setAttribute ( index, Parameters.getAttributeAsInt ( index ) + 1 ); - - if ( 0 == taken ) - { - index = Parameters.findAttribute ( "culled" ); - Parameters.setAttribute ( index, Parameters.getAttributeAsInt ( index ) + 1 ); - } -#endif - - return taken; -} - -//! This method is called just before the rendering process of the whole scene. -//! draws all scene nodes -void CSceneManager::drawAll() -{ - if (!Driver) - return; - - // reset attributes - Parameters.setAttribute ( "culled", 0 ); - Parameters.setAttribute ( "calls", 0 ); - Parameters.setAttribute ( "drawn", 0 ); - - // reset all transforms - video::IVideoDriver* driver = getVideoDriver(); - if ( driver ) - { - core::matrix4 identity; - driver->setTransform ( video::ETS_PROJECTION, identity ); - driver->setTransform ( video::ETS_VIEW, identity ); - driver->setTransform ( video::ETS_WORLD, identity ); - driver->setTransform ( video::ETS_TEXTURE_0, identity ); - driver->setTransform ( video::ETS_TEXTURE_1, identity ); - driver->setTransform ( video::ETS_TEXTURE_2, identity ); - driver->setTransform ( video::ETS_TEXTURE_3, identity ); - } - - // do animations and other stuff. - OnAnimate(os::Timer::getTime()); - - /*! - First Scene Node for prerendering should be the active camera - consistent Camera is needed for culling - */ - camWorldPos.set(0,0,0); - if ( ActiveCamera ) - { - ActiveCamera->OnRegisterSceneNode(); - camWorldPos = ActiveCamera->getAbsolutePosition(); - } - - // let all nodes register themselves - OnRegisterSceneNode(); - - u32 i; // new ISO for scoping problem in some compilers - - //render camera scenes - { - CurrentRendertime = ESNRP_CAMERA; - for (i=0; irender(); - - CameraList.clear(); - } - - //render lights scenes - { - CurrentRendertime = ESNRP_LIGHT; - - Driver->deleteAllDynamicLights(); - - Driver->setAmbientLight(AmbientLight); - - LightList.sort (); // on distance to camera - - u32 maxLights = irr::core::min_ ( Driver->getMaximalDynamicLightAmount (), LightList.size () ); - for (i=0; i< maxLights; ++i) - LightList[i].node->render(); - - LightList.clear(); - } - - // render skyboxes - { - CurrentRendertime = ESNRP_SKY_BOX; - - for (i=0; irender(); - - SkyBoxList.clear(); - } - - - // render default objects - { - CurrentRendertime = ESNRP_SOLID; - SolidNodeList.sort(); // sort by textures - - for (i=0; irender(); - - Parameters.setAttribute ( "drawn", (s32) SolidNodeList.size () ); - - SolidNodeList.clear(); - } - - // render shadows - { - CurrentRendertime = ESNRP_SHADOW; - for (i=0; irender(); - - if (!ShadowNodeList.empty()) - Driver->drawStencilShadow(true,ShadowColor, ShadowColor, - ShadowColor, ShadowColor); - - ShadowNodeList.clear(); - } - - // render transparent objects. - { - CurrentRendertime = ESNRP_TRANSPARENT; - TransparentNodeList.sort(); // sort by distance from camera - - for (i=0; irender(); - - TransparentNodeList.clear(); - } - - // render shader objects. - { - for ( u32 g = 0; g!= ESNRP_SHADER_10 - ESNRP_SHADER_0 + 1; ++g ) - { - CurrentRendertime = (scene::E_SCENE_NODE_RENDER_PASS) (ESNRP_SHADER_0 + g); - - const u32 size = ShaderNodeList[g].size (); - if ( 0 == size ) - continue; - - ShaderNodeList[g].sort(); // sort by textures - for (i=0; i< size; ++i) - ShaderNodeList[g][i].node->render(); - - ShaderNodeList[g].clear(); - } - } - - clearDeletionList(); - - CurrentRendertime = ESNRP_COUNT; -} - - -//! Sets the color of stencil buffers shadows drawn by the scene manager. -void CSceneManager::setShadowColor(video::SColor color) -{ - ShadowColor = color; -} - - -//! Returns the current color of shadows. -video::SColor CSceneManager::getShadowColor() const -{ - return ShadowColor; -} - - - -//! creates a rotation animator, which rotates the attached scene node around itself. -ISceneNodeAnimator* CSceneManager::createRotationAnimator(const core::vector3df& rotationPerSecond) -{ - ISceneNodeAnimator* anim = new CSceneNodeAnimatorRotation(os::Timer::getTime(), - rotationPerSecond); - - return anim; -} - - - -//! creates a fly circle animator, which lets the attached scene node fly around a center. -ISceneNodeAnimator* CSceneManager::createFlyCircleAnimator(const core::vector3df& normal, - f32 radius, f32 speed, - const core::vector3df& direction) -{ - ISceneNodeAnimator* anim = new CSceneNodeAnimatorFlyCircle(os::Timer::getTime(), normal, - radius, speed, direction); - return anim; -} - - -//! Creates a fly straight animator, which lets the attached scene node -//! fly or move along a line between two points. -ISceneNodeAnimator* CSceneManager::createFlyStraightAnimator(const core::vector3df& startPoint, - const core::vector3df& endPoint, u32 timeForWay, bool loop) -{ - ISceneNodeAnimator* anim = new CSceneNodeAnimatorFlyStraight(startPoint, - endPoint, timeForWay, loop, os::Timer::getTime()); - - return anim; -} - - -//! Creates a texture animator, which switches the textures of the target scene -//! node based on a list of textures. -ISceneNodeAnimator* CSceneManager::createTextureAnimator(const core::array& textures, - s32 timePerFrame, bool loop) -{ - ISceneNodeAnimator* anim = new CSceneNodeAnimatorTexture(textures, - timePerFrame, loop, os::Timer::getTime()); - - return anim; -} - - -//! Creates a scene node animator, which deletes the scene node after -//! some time automaticly. -ISceneNodeAnimator* CSceneManager::createDeleteAnimator(u32 when) -{ - return new CSceneNodeAnimatorDelete(this, os::Timer::getTime() + when); -} - - - - -//! Creates a special scene node animator for doing automatic collision detection -//! and response. -ISceneNodeAnimatorCollisionResponse* CSceneManager::createCollisionResponseAnimator( - ITriangleSelector* world, ISceneNode* sceneNode, const core::vector3df& ellipsoidRadius, - const core::vector3df& gravityPerSecond, - const core::vector3df& ellipsoidTranslation, f32 slidingValue) -{ - ISceneNodeAnimatorCollisionResponse* anim = new - CSceneNodeAnimatorCollisionResponse(this, world, sceneNode, - ellipsoidRadius, gravityPerSecond, - ellipsoidTranslation, slidingValue); - - return anim; -} - - -//! Creates a follow spline animator. -ISceneNodeAnimator* CSceneManager::createFollowSplineAnimator(s32 startTime, - const core::array< core::vector3df >& points, - f32 speed, f32 tightness) -{ - ISceneNodeAnimator* a = new CSceneNodeAnimatorFollowSpline(startTime, points, - speed, tightness); - return a; -} - - - -//! Adds an external mesh loader. -void CSceneManager::addExternalMeshLoader(IMeshLoader* externalLoader) -{ - if (!externalLoader) - return; - - externalLoader->grab(); - MeshLoaderList.push_back(externalLoader); -} - - - -//! Returns a pointer to the scene collision manager. -ISceneCollisionManager* CSceneManager::getSceneCollisionManager() -{ - return CollisionManager; -} - - -//! Returns a pointer to the mesh manipulator. -IMeshManipulator* CSceneManager::getMeshManipulator() -{ - return MeshManipulator; -} - - -//! Creates a simple ITriangleSelector, based on a mesh. -ITriangleSelector* CSceneManager::createTriangleSelector(IMesh* mesh, ISceneNode* node) -{ - if (!mesh || !node) - return 0; - - return new CTriangleSelector(mesh, node); -} - - -//! Creates a simple dynamic ITriangleSelector, based on a axis aligned bounding box. -ITriangleSelector* CSceneManager::createTriangleSelectorFromBoundingBox(ISceneNode* node) -{ - if (!node) - return 0; - - return new CTriangleBBSelector(node); -} - - -//! Creates a simple ITriangleSelector, based on a mesh. -ITriangleSelector* CSceneManager::createOctTreeTriangleSelector(IMesh* mesh, - ISceneNode* node, - s32 minimalPolysPerNode) -{ - if (!mesh || !node) - return 0; - - return new COctTreeTriangleSelector(mesh, node, minimalPolysPerNode); -} - - - -//! Creates a meta triangle selector. -IMetaTriangleSelector* CSceneManager::createMetaTriangleSelector() -{ - return new CMetaTriangleSelector(); -} - - - -//! Creates a triangle selector which can select triangles from a terrain scene node -ITriangleSelector* CSceneManager::createTerrainTriangleSelector( - ITerrainSceneNode* node, s32 LOD) -{ - return new CTerrainTriangleSelector(node, LOD); -} - - - -//! Adds a scene node to the deletion queue. -void CSceneManager::addToDeletionQueue(ISceneNode* node) -{ - if (!node) - return; - - node->grab(); - DeletionList.push_back(node); -} - - -//! clears the deletion list -void CSceneManager::clearDeletionList() -{ - if (DeletionList.empty()) - return; - - for (s32 i=0; i<(s32)DeletionList.size(); ++i) - { - DeletionList[i]->remove(); - DeletionList[i]->drop(); - } - - DeletionList.clear(); -} - - -//! Returns the first scene node with the specified name. -ISceneNode* CSceneManager::getSceneNodeFromName(const char* name, ISceneNode* start) -{ - if (start == 0) - start = getRootSceneNode(); - - if (!strcmp(start->getName(),name)) - return start; - - ISceneNode* node = 0; - - const core::list& list = start->getChildren(); - core::list::Iterator it = list.begin(); - for (; it!=list.end(); ++it) - { - node = getSceneNodeFromName(name, *it); - if (node) - return node; - } - - return 0; -} - - -//! Returns the first scene node with the specified id. -ISceneNode* CSceneManager::getSceneNodeFromId(s32 id, ISceneNode* start) -{ - if (start == 0) - start = getRootSceneNode(); - - if (start->getID() == id) - return start; - - ISceneNode* node = 0; - - const core::list& list = start->getChildren(); - core::list::Iterator it = list.begin(); - for (; it!=list.end(); ++it) - { - node = getSceneNodeFromId(id, *it); - if (node) - return node; - } - - return 0; -} - - -//! Posts an input event to the environment. Usually you do not have to -//! use this method, it is used by the internal engine. -bool CSceneManager::postEventFromUser(SEvent event) -{ - bool ret = false; - ICameraSceneNode* cam = getActiveCamera(); - if (cam) - ret = cam->OnEvent(event); - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! Removes all children of this scene node -void CSceneManager::removeAll() -{ - ISceneNode::removeAll(); - setActiveCamera(0); -} - - -//! Clears the whole scene. All scene nodes are removed. -void CSceneManager::clear() -{ - removeAll(); -} - - -//! Returns interface to the parameters set in this scene. -io::IAttributes* CSceneManager::getParameters() -{ - return &Parameters; -} - - -//! Returns current render pass. -E_SCENE_NODE_RENDER_PASS CSceneManager::getSceneNodeRenderPass() -{ - return CurrentRendertime; -} - - - -//! Returns an interface to the mesh cache which is shared beween all existing scene managers. -IMeshCache* CSceneManager::getMeshCache() -{ - return MeshCache; -} - - -//! Creates a new scene manager. -ISceneManager* CSceneManager::createNewSceneManager() -{ - return new CSceneManager(Driver, FileSystem, CursorControl, MeshCache); -} - - -//! Returns the default scene node factory which can create all built in scene nodes -ISceneNodeFactory* CSceneManager::getDefaultSceneNodeFactory() -{ - return getSceneNodeFactory(0); -} - - -//! Adds a scene node factory to the scene manager. -void CSceneManager::registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd) -{ - if (factoryToAdd) - { - factoryToAdd->grab(); - SceneNodeFactoryList.push_back(factoryToAdd); - } -} - - -//! Returns amount of registered scene node factories. -s32 CSceneManager::getRegisteredSceneNodeFactoryCount() -{ - return SceneNodeFactoryList.size(); -} - - -//! Returns a scene node factory by index -ISceneNodeFactory* CSceneManager::getSceneNodeFactory(s32 index) -{ - if (index>=0 && index<(int)SceneNodeFactoryList.size()) - return SceneNodeFactoryList[index]; - - return 0; -} - - -//! Returns the default scene node animator factory which can create all built-in scene node animators -ISceneNodeAnimatorFactory* CSceneManager::getDefaultSceneNodeAnimatorFactory() -{ - return getSceneNodeAnimatorFactory(0); -} - -//! Adds a scene node animator factory to the scene manager. -void CSceneManager::registerSceneNodeAnimatorFactory(ISceneNodeAnimatorFactory* factoryToAdd) -{ - if (factoryToAdd) - { - factoryToAdd->grab(); - SceneNodeAnimatorFactoryList.push_back(factoryToAdd); - } -} - - -//! Returns amount of registered scene node animator factories. -s32 CSceneManager::getRegisteredSceneNodeAnimatorFactoryCount() -{ - return SceneNodeAnimatorFactoryList.size(); -} - - -//! Returns a scene node animator factory by index -ISceneNodeAnimatorFactory* CSceneManager::getSceneNodeAnimatorFactory(s32 index) -{ - if (index>=0 && index<(int)SceneNodeAnimatorFactoryList.size()) - return SceneNodeAnimatorFactoryList[index]; - - return 0; -} - - -//! Saves the current scene into a file. -//! \param filename: Name of the file . -bool CSceneManager::saveScene(const c8* filename, ISceneUserDataSerializer* userDataSerializer) -{ - io::IWriteFile* file = FileSystem->createAndWriteFile(filename); - if (!file) - return false; - - bool ret = saveScene(file, userDataSerializer); - file->drop(); - return ret; -} - - -//! Saves the current scene into a file. -bool CSceneManager::saveScene(io::IWriteFile* file, ISceneUserDataSerializer* userDataSerializer) -{ - if (!file) - return false; - - io::IXMLWriter* writer = FileSystem->createXMLWriter(file); - if (!writer) - return false; - - writer->writeXMLHeader(); - writeSceneNode(writer, this, userDataSerializer); - writer->drop(); - - return true; -} - - -//! Loads a scene. Note that the current scene is not cleared before. -//! \param filename: Name of the file . -bool CSceneManager::loadScene(const c8* filename, ISceneUserDataSerializer* userDataSerializer) -{ - io::IReadFile* read = FileSystem->createAndOpenFile(filename); - if (!read) - { - os::Printer::log("Unable to open scene file", filename, ELL_ERROR); - return false; - } - - bool ret = loadScene(read, userDataSerializer); - read->drop(); - - return ret; -} - - -//! Loads a scene. Note that the current scene is not cleared before. -bool CSceneManager::loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer) -{ - if (!file) - { - os::Printer::log("Unable to open scene file", ELL_ERROR); - return false; - } - - io::IXMLReader* reader = FileSystem->createXMLReader(file); - if (!reader) - { - os::Printer::log("Scene is not a valid XML file", file->getFileName(), ELL_ERROR); - return false; - } - - // for mesh loading, set collada loading attributes - - bool bOldColladaSingleMesh = getParameters()->getAttributeAsBool(COLLADA_CREATE_SCENE_INSTANCES); - getParameters()->setAttribute(COLLADA_CREATE_SCENE_INSTANCES, false); - - // read file - - while(reader->read()) - { - readSceneNode(reader, 0, userDataSerializer); - } - - // restore old collada parameters - - getParameters()->setAttribute(COLLADA_CREATE_SCENE_INSTANCES, bOldColladaSingleMesh); - - // finish up - - reader->drop(); - return true; - -} - - -//! reads a scene node -void CSceneManager::readSceneNode(io::IXMLReader* reader, ISceneNode* parent, ISceneUserDataSerializer* userDataSerializer) -{ - if (!reader) - return; - - scene::ISceneNode* node = 0; - - if ((!parent && IRR_XML_FORMAT_SCENE==reader->getNodeName()) || - ( parent && IRR_XML_FORMAT_NODE==reader->getNodeName())) - { - if (parent) - { - // find node type and create it - core::stringc attrName = reader->getAttributeValue(IRR_XML_FORMAT_NODE_ATTR_TYPE.c_str()); - - for (int i=0; i<(int)SceneNodeFactoryList.size() && !node; ++i) - node = SceneNodeFactoryList[i]->addSceneNode(attrName.c_str(), parent); - - if (!node) - os::Printer::log("Could not create scene node of unknown type", attrName.c_str()); - } - else - node = this; // root - } - - // read attributes - - while(reader->read()) - { - bool endreached = false; - - switch (reader->getNodeType()) - { - case io::EXN_ELEMENT_END: - if ((IRR_XML_FORMAT_NODE==reader->getNodeName()) || - (IRR_XML_FORMAT_SCENE==reader->getNodeName())) - { - endreached = true; - } - break; - case io::EXN_ELEMENT: - if (core::stringw(L"attributes")==reader->getNodeName()) - { - // read attributes - io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); - attr->read(reader, true); - - if (node) - node->deserializeAttributes(attr); - - attr->drop(); - } - else - if (core::stringw(L"materials")==reader->getNodeName()) - readMaterials(reader, node); - else - if (core::stringw(L"animators")==reader->getNodeName()) - readAnimators(reader, node); - else - if (core::stringw(L"userData")==reader->getNodeName()) - readUserData(reader, node, userDataSerializer); - else - if ((IRR_XML_FORMAT_NODE==reader->getNodeName()) || - (IRR_XML_FORMAT_SCENE==reader->getNodeName())) - { - readSceneNode(reader, node, userDataSerializer); - } - else - { - os::Printer::log("Found unknown element in irrlicht scene file", - core::stringc(reader->getNodeName()).c_str()); - } - break; - default: - break; - } - - if (endreached) - break; - } -} - - -//! reads materials of a node -void CSceneManager::readMaterials(io::IXMLReader* reader, ISceneNode* node) -{ - u32 nr = 0; - - while(reader->read()) - { - const wchar_t* name = reader->getNodeName(); - - switch(reader->getNodeType()) - { - case io::EXN_ELEMENT_END: - if (core::stringw(L"materials")==name) - return; - break; - case io::EXN_ELEMENT: - if (core::stringw(L"attributes")==name) - { - // read materials from attribute list - io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); - attr->read(reader); - - if (node && node->getMaterialCount() > nr) - { - getVideoDriver()->fillMaterialStructureFromAttributes( - node->getMaterial(nr), attr); - } - - attr->drop(); - ++nr; - } - break; - default: - break; - } - } -} - - -//! reads animators of a node -void CSceneManager::readAnimators(io::IXMLReader* reader, ISceneNode* node) -{ - s32 cnt = 0; - - while(reader->read()) - { - const wchar_t* name = reader->getNodeName(); - - switch(reader->getNodeType()) - { - case io::EXN_ELEMENT_END: - if (core::stringw(L"animators")==name) - return; - break; - case io::EXN_ELEMENT: - if (core::stringw(L"attributes")==name) - { - // read animator data from attribute list - io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); - attr->read(reader); - - if (node) - { - core::stringc typeName = attr->getAttributeAsString("Type"); - ISceneNodeAnimator* anim = 0; - - for (int i=0; i<(int)SceneNodeAnimatorFactoryList.size() && !anim; ++i) - anim = SceneNodeAnimatorFactoryList[i]->createSceneNodeAnimator(typeName.c_str(), node); - - if (anim) - { - anim->deserializeAttributes(attr); - anim->drop(); - } - } - - attr->drop(); - ++cnt; - } - break; - default: - break; - } - } -} - - -//! reads user data of a node -void CSceneManager::readUserData(io::IXMLReader* reader, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer) -{ - while(reader->read()) - { - const wchar_t* name = reader->getNodeName(); - - switch(reader->getNodeType()) - { - case io::EXN_ELEMENT_END: - if (core::stringw(L"userData")==name) - return; - break; - case io::EXN_ELEMENT: - if (core::stringw(L"attributes")==name) - { - // read user data from attribute list - io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); - attr->read(reader); - - if (node && userDataSerializer) - { - userDataSerializer->OnReadUserData(node, attr); - } - - attr->drop(); - } - break; - default: - break; - } - } -} - - -//! writes a scene node -void CSceneManager::writeSceneNode(io::IXMLWriter* writer, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer) -{ - if (!writer || !node || node->isDebugObject()) - return; - - const wchar_t* name = 0; - - if (node == this) - { - name = IRR_XML_FORMAT_SCENE.c_str(); - writer->writeElement(name, false); - } - else - { - name = IRR_XML_FORMAT_NODE.c_str(); - writer->writeElement(name, false, IRR_XML_FORMAT_NODE_ATTR_TYPE.c_str(), - core::stringw(getSceneNodeTypeName(node->getType())).c_str()); - } - - writer->writeLineBreak(); - writer->writeLineBreak(); - - // write properties - - io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); - node->serializeAttributes(attr); - - if (attr->getAttributeCount() > 0) - { - attr->write(writer); - writer->writeLineBreak(); - } - - // write materials - - if (node->getMaterialCount() && getVideoDriver()) - { - const wchar_t* materialElement = L"materials"; - - writer->writeElement(materialElement); - writer->writeLineBreak(); - - for (u32 i=0; i < node->getMaterialCount(); ++i) - { - io::IAttributes* attr = - getVideoDriver()->createAttributesFromMaterial(node->getMaterial(i)); - attr->write(writer); - attr->drop(); - } - - writer->writeClosingTag(materialElement); - writer->writeLineBreak(); - } - - // write animators - - if (!node->getAnimators().empty()) - { - const wchar_t* animatorElement = L"animators"; - writer->writeElement(animatorElement); - writer->writeLineBreak(); - - core::list::Iterator it = node->getAnimators().begin(); - for (; it != node->getAnimators().end(); ++it) - { - attr->clear(); - attr->addString("Type", getAnimatorTypeName((*it)->getType())); - - (*it)->serializeAttributes(attr); - - attr->write(writer); - } - - writer->writeClosingTag(animatorElement); - writer->writeLineBreak(); - } - - // write possible user data - - if ( userDataSerializer ) - { - io::IAttributes* userData = userDataSerializer->createUserData(node); - if (userData) - { - const wchar_t* userDataElement = L"userData"; - - writer->writeLineBreak(); - writer->writeElement(userDataElement); - writer->writeLineBreak(); - - userData->write(writer); - - writer->writeClosingTag(userDataElement); - writer->writeLineBreak(); - writer->writeLineBreak(); - - userData->drop(); - } - } - - // write children - - core::list::Iterator it = node->getChildren().begin(); - for (; it != node->getChildren().end(); ++it) - writeSceneNode(writer, (*it), userDataSerializer); - - attr->drop(); - - writer->writeClosingTag(name); - writer->writeLineBreak(); - writer->writeLineBreak(); -} - - -//! Returns a typename from a scene node type or null if not found -const c8* CSceneManager::getSceneNodeTypeName(ESCENE_NODE_TYPE type) -{ - const char* name = 0; - - for (int i=0; !name && i<(int)SceneNodeFactoryList.size(); ++i) - name = SceneNodeFactoryList[i]->getCreateableSceneNodeTypeName(type); - - return name; -} - -//! Returns a typename from a scene node animator type or null if not found -const c8* CSceneManager::getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type) -{ - const char* name = 0; - - for (int i=0; !name && i<(int)SceneNodeAnimatorFactoryList.size(); ++i) - name = SceneNodeAnimatorFactoryList[i]->getCreateableSceneNodeAnimatorTypeName(type); - - return name; -} -//! Writes attributes of the scene node. -void CSceneManager::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - out->addString ("Name", Name.c_str()); - out->addInt ("Id", ID ); - out->addColorf ("AmbientLight", AmbientLight); -} - -//! Reads attributes of the scene node. -void CSceneManager::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Name = in->getAttributeAsString("Name"); - ID = in->getAttributeAsInt("Id"); - AmbientLight = in->getAttributeAsColorf("AmbientLight"); - - RelativeTranslation.set(0,0,0); - RelativeRotation.set(0,0,0); - RelativeScale.set(1,1,1); - IsVisible = true; - AutomaticCullingState = scene::EAC_BOX; - DebugDataVisible = scene::EDS_OFF; - IsDebugObject = false; - - updateAbsolutePosition(); -} - - -//! Sets ambient color of the scene -void CSceneManager::setAmbientLight(const video::SColorf &ambientColor) -{ - AmbientLight = ambientColor; -} - - -//! Returns ambient color of the scene -video::SColorf CSceneManager::getAmbientLight() -{ - return AmbientLight; -} - - -// creates a scenemanager -ISceneManager* createSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, - gui::ICursorControl* cursorcontrol, - gui::IGUIEnvironment *guiEnvironment ) -{ - return new CSceneManager(driver, fs, cursorcontrol, 0, guiEnvironment ); -} - - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSceneManager.h" +#include "IVideoDriver.h" +#include "IFileSystem.h" +#include "IAnimatedMesh.h" +#include "CMeshCache.h" +#include "IWriteFile.h" +#include "IXMLWriter.h" +#include "ISceneUserDataSerializer.h" + +#include "os.h" + +#include "CGeometryCreator.h" + +#include "CDefaultMeshFormatLoader.h" +#include "C3DSMeshFileLoader.h" +#include "CXMeshFileLoader.h" +#include "COCTLoader.h" +#include "CCSMLoader.h" +#include "CLMTSMeshFileLoader.h" +#include "CMY3DMeshFileLoader.h" +#include "CColladaFileLoader.h" +#include "CDMFLoader.h" +#include "COgreMeshFileLoader.h" +#include "COBJMeshFileLoader.h" +#include "CMD3MeshFileLoader.h" + +#include "CCubeSceneNode.h" +#include "CSphereSceneNode.h" +#include "CAnimatedMeshSceneNode.h" +#include "COctTreeSceneNode.h" +#include "CCameraSceneNode.h" +#include "CCameraMayaSceneNode.h" +#include "CCameraFPSSceneNode.h" +#include "CLightSceneNode.h" +#include "CBillboardSceneNode.h" +#include "CMeshSceneNode.h" +#include "CSkyBoxSceneNode.h" +#include "CSkyDomeSceneNode.h" +#include "CParticleSystemSceneNode.h" +#include "CDummyTransformationSceneNode.h" +#include "CWaterSurfaceSceneNode.h" +#include "CTerrainSceneNode.h" +#include "CEmptySceneNode.h" +#include "CTextSceneNode.h" +#include "CDefaultSceneNodeFactory.h" + +#include "CSceneCollisionManager.h" +#include "CMeshManipulator.h" +#include "CTriangleSelector.h" +#include "COctTreeTriangleSelector.h" +#include "CTriangleBBSelector.h" +#include "CMetaTriangleSelector.h" +#include "CTerrainTriangleSelector.h" + +#include "CSceneNodeAnimatorRotation.h" +#include "CSceneNodeAnimatorFlyCircle.h" +#include "CSceneNodeAnimatorFlyStraight.h" +#include "CSceneNodeAnimatorTexture.h" +#include "CSceneNodeAnimatorCollisionResponse.h" +#include "CSceneNodeAnimatorDelete.h" +#include "CSceneNodeAnimatorFollowSpline.h" +#include "CDefaultSceneNodeAnimatorFactory.h" + +#include "CQuake3ShaderSceneNode.h" + +//! Enable debug features +#define SCENEMANAGER_DEBUG + +namespace irr +{ +namespace scene +{ + +//! constructor +CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, + gui::ICursorControl* cursorControl, CMeshCache* cache, + gui::IGUIEnvironment * gui) +: ISceneNode(0, 0), Driver(driver), FileSystem(fs), GUIEnvironment(gui), + CursorControl(cursorControl), CollisionManager(0), MeshManipulator(0), + ActiveCamera(0), ShadowColor(150,0,0,0), AmbientLight(0,0,0,0), + MeshCache(cache), CurrentRendertime(ESNRP_COUNT), + IRR_XML_FORMAT_SCENE(L"irr_scene"), IRR_XML_FORMAT_NODE(L"node"), IRR_XML_FORMAT_NODE_ATTR_TYPE(L"type") +{ + #ifdef _DEBUG + ISceneManager::setDebugName("CSceneManager ISceneManager"); + ISceneNode::setDebugName("CSceneManager ISceneNode"); + #endif + + if (Driver) + Driver->grab(); + + if (FileSystem) + FileSystem->grab(); + + if (CursorControl) + CursorControl->grab(); + + if ( GUIEnvironment ) + GUIEnvironment->grab (); + + // create mesh cache if not there already + if (!MeshCache) + MeshCache = new CMeshCache(); + else + MeshCache->grab(); + + // create collision manager + CollisionManager = new CSceneCollisionManager(this, Driver); + + // create manipulator + MeshManipulator = new CMeshManipulator(); + + // add default format loader + + MeshLoaderList.push_back(new CDefaultMeshFormatLoader(FileSystem, Driver, this)); + MeshLoaderList.push_back(new C3DSMeshFileLoader(MeshManipulator,FileSystem, Driver)); + MeshLoaderList.push_back(new CXMeshFileLoader(MeshManipulator, Driver)); + MeshLoaderList.push_back(new COCTLoader(Driver)); + MeshLoaderList.push_back(new CCSMLoader(this, FileSystem)); + MeshLoaderList.push_back(new CLMTSMeshFileLoader(FileSystem, Driver, &Parameters)); + MeshLoaderList.push_back(new CMY3DMeshFileLoader(FileSystem, Driver, this)); + MeshLoaderList.push_back(new CColladaFileLoader(Driver, this, FileSystem)); + MeshLoaderList.push_back(new CDMFLoader(Driver, this)); + MeshLoaderList.push_back(new COgreMeshFileLoader(MeshManipulator, FileSystem, Driver)); + MeshLoaderList.push_back(new COBJMeshFileLoader(FileSystem, Driver)); + MeshLoaderList.push_back(new CMD3MeshFileLoader(FileSystem, Driver)); + // factories + + ISceneNodeFactory* factory = new CDefaultSceneNodeFactory(this); + registerSceneNodeFactory(factory); + factory->drop(); + + ISceneNodeAnimatorFactory* animatorFactory = new CDefaultSceneNodeAnimatorFactory(this); + registerSceneNodeAnimatorFactory(animatorFactory); + animatorFactory->drop(); +} + + + +//! destructor +CSceneManager::~CSceneManager() +{ + clearDeletionList(); + + if (Driver) + Driver->drop(); + + if (FileSystem) + FileSystem->drop(); + + if (CursorControl) + CursorControl->drop(); + + if (CollisionManager) + CollisionManager->drop(); + + if (MeshManipulator) + MeshManipulator->drop(); + + if ( GUIEnvironment ) + GUIEnvironment->drop (); + + u32 i; + + for (i=0; idrop(); + + if (ActiveCamera) + ActiveCamera->drop(); + + if (MeshCache) + MeshCache->drop(); + + for (i=0; idrop(); + + for (i=0; idrop(); +} + + +//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped. +IAnimatedMesh* CSceneManager::getMesh(const c8* filename) +{ + IAnimatedMesh* msh = 0; + + core::stringc name = filename; + name.make_lower(); + + msh = MeshCache->findMesh(name.c_str()); + if (msh) + return msh; + + io::IReadFile* file = FileSystem->createAndOpenFile(filename); + if (!file) + { + os::Printer::log("Could not load mesh, because file could not be opened.", filename, ELL_ERROR); + return 0; + } + + s32 count = MeshLoaderList.size(); + for (s32 i=count-1; i>=0; --i) + { + if (MeshLoaderList[i]->isALoadableFileExtension(name.c_str())) + { + // reset file to avoid side effects of previous calls to createMesh + file->seek(0); + msh = MeshLoaderList[i]->createMesh(file); + if (msh) + { + MeshCache->addMesh(filename, msh); + msh->drop(); + break; + } + } + } + + file->drop(); + + if (!msh) + os::Printer::log("Could not load mesh, file format seems to be unsupported", filename, ELL_ERROR); + else + os::Printer::log("Loaded mesh", filename, ELL_INFORMATION); + + return msh; +} + + +//! returns the video driver +video::IVideoDriver* CSceneManager::getVideoDriver() +{ + return Driver; +} + +//! returns the GUI Environment +gui::IGUIEnvironment* CSceneManager::getGUIEnvironment () +{ + return GUIEnvironment; +} +//! Adds a text scene node, which is able to display +//! 2d text at a position in three dimensional space +ITextSceneNode* CSceneManager::addTextSceneNode(gui::IGUIFont* font, const wchar_t* text, + video::SColor color, + ISceneNode* parent, const core::vector3df& position, + s32 id) +{ + if (!font) + return 0; + + if (!parent) + parent = this; + + ITextSceneNode* t = new CTextSceneNode(parent, this, id, font, + getSceneCollisionManager(), position, text, color); + t->drop(); + + return t; +} + +//! Adds a text scene node, which uses billboards +ITextSceneNode* CSceneManager::addBillboardTextSceneNode(gui::IGUIFont* font, const wchar_t* text, + ISceneNode* parent, + const core::dimension2d& size, + const core::vector3df& position, s32 id, + video::SColor shade_top, video::SColor shade_down) +{ + if (!font) + return 0; + + if (!parent) + parent = this; + + ITextSceneNode* node = new CBillboardTextSceneNode(parent, this, id, font, text, position, size, + shade_top, shade_down); + node->drop(); + + return node; + +} + + +//! Adds a scene node, which can render a quake3 shader +ISceneNode* CSceneManager::addQuake3SceneNode( IMeshBuffer* meshBuffer, + const quake3::SShader * shader, + ISceneNode* parent, + s32 id + ) + +{ + if ( 0 == shader ) + return 0; + + if (!parent) + parent = this; + + CQuake3ShaderSceneNode* node = new CQuake3ShaderSceneNode ( parent, this, id, FileSystem, meshBuffer, shader ); + node->drop(); + + return node; + +} + + +//! adds a test scene node for test purposes to the scene. It is a simple cube of (1,1,1) size. +//! the returned pointer must not be dropped. +ISceneNode* CSceneManager::addCubeSceneNode(f32 size, ISceneNode* parent, s32 id, + const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) +{ + if (!parent) + parent = this; + + ISceneNode* node = new CCubeSceneNode(size, parent, this, id, position, rotation, scale); + node->drop(); + + return node; +} + +//! Adds a sphere scene node for test purposes to the scene. +ISceneNode* CSceneManager::addSphereSceneNode(f32 radius, s32 polyCount, ISceneNode* parent, s32 id, + const core::vector3df& position, + const core::vector3df& rotation, + const core::vector3df& scale) +{ + if (!parent) + parent = this; + + ISceneNode* node = new CSphereSceneNode(radius, polyCount, parent, this, id, position, rotation, scale); + node->drop(); + + return node; +} + + +//! adds a scene node for rendering a static mesh +//! the returned pointer must not be dropped. +IMeshSceneNode* CSceneManager::addMeshSceneNode(IMesh* mesh, ISceneNode* parent, s32 id, + const core::vector3df& position, const core::vector3df& rotation, + const core::vector3df& scale, bool alsoAddIfMeshPointerZero) +{ + if (!alsoAddIfMeshPointerZero && !mesh) + return 0; + + if (!parent) + parent = this; + + IMeshSceneNode* node = new CMeshSceneNode(mesh, parent, this, id, position, rotation, scale); + node->drop(); + + return node; +} + + +//! Adds a scene node for rendering a animated water surface mesh. +ISceneNode* CSceneManager::addWaterSurfaceSceneNode(IMesh* mesh, f32 waveHeight, f32 waveSpeed, f32 waveLength, + ISceneNode* parent, s32 id, const core::vector3df& position, + const core::vector3df& rotation, const core::vector3df& scale) +{ + if (!mesh) + return 0; + + if (!parent) + parent = this; + + ISceneNode* node = new CWaterSurfaceSceneNode(waveHeight, waveSpeed, waveLength, + mesh, parent, this, id, position, rotation, scale); + + node->drop(); + + return node; +} + + + +//! adds a scene node for rendering an animated mesh model +IAnimatedMeshSceneNode* CSceneManager::addAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, s32 id, + const core::vector3df& position, const core::vector3df& rotation, + const core::vector3df& scale, bool alsoAddIfMeshPointerZero) +{ + if (!alsoAddIfMeshPointerZero && !mesh) + return 0; + + if (!parent) + parent = this; + + IAnimatedMeshSceneNode* node = + new CAnimatedMeshSceneNode(mesh, parent, this, id, position, rotation, scale); + node->drop(); + + return node; +} + + +//! Adds a scene node for rendering using a octtree to the scene graph. This a good method for rendering +//! scenes with lots of geometry. The Octree is built on the fly from the mesh, much +//! faster then a bsp tree. +ISceneNode* CSceneManager::addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, + s32 id, s32 minimalPolysPerNode, bool alsoAddIfMeshPointerZero) +{ + if (!alsoAddIfMeshPointerZero && (!mesh || !mesh->getFrameCount())) + return 0; + + return addOctTreeSceneNode(mesh ? mesh->getMesh(0) : 0, + parent, id, minimalPolysPerNode, + alsoAddIfMeshPointerZero); +} + + + +//! Adss a scene node for rendering using a octtree. This a good method for rendering +//! scenes with lots of geometry. The Octree is built on the fly from the mesh, much +//! faster then a bsp tree. +ISceneNode* CSceneManager::addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent, + s32 id, s32 minimalPolysPerNode, + bool alsoAddIfMeshPointerZero) +{ + if (!alsoAddIfMeshPointerZero && !mesh) + return 0; + + if (!parent) + parent = this; + + COctTreeSceneNode* node = new COctTreeSceneNode(parent, this, id, minimalPolysPerNode); + + if (mesh) + node->createTree(mesh); + + node->drop(); + + return node; +} + + +//! Adds a camera scene node to the tree and sets it as active camera. +//! \param position: Position of the space relative to its parent where the camera will be placed. +//! \param lookat: Position where the camera will look at. Also known as target. +//! \param parent: Parent scene node of the camera. Can be null. If the parent moves, +//! the camera will move too. +//! \return Returns pointer to interface to camera +ICameraSceneNode* CSceneManager::addCameraSceneNode(ISceneNode* parent, + const core::vector3df& position, const core::vector3df& lookat, s32 id) +{ + if (!parent) + parent = this; + + ICameraSceneNode* node = new CCameraSceneNode(parent, this, id, position, lookat); + node->drop(); + + setActiveCamera(node); + + return node; +} + + + +//! Adds a camera scene node which is able to be controlle with the mouse similar +//! like in the 3D Software Maya by Alias Wavefront. +//! The returned pointer must not be dropped. +ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent, + f32 rotateSpeed, f32 zoomSpeed, f32 translationSpeed, s32 id) +{ + if (!parent) + parent = this; + + ICameraSceneNode* node = new CCameraMayaSceneNode(parent, this, id, rotateSpeed, + zoomSpeed, translationSpeed); + node->drop(); + + setActiveCamera(node); + + return node; +} + + + +//! Adds a camera scene node which is able to be controled with the mouse and keys +//! like in most first person shooters (FPS): +ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent, + f32 rotateSpeed, f32 moveSpeed, s32 id, + SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement,f32 jumpSpeed) +{ + if (!parent) + parent = this; + + ICameraSceneNode* node = new CCameraFPSSceneNode(parent, this, CursorControl, + id, rotateSpeed, moveSpeed, jumpSpeed, keyMapArray, keyMapSize, noVerticalMovement); + node->drop(); + + setActiveCamera(node); + + return node; +} + + + +//! Adds a dynamic light scene node. The light will cast dynamic light on all +//! other scene nodes in the scene, which have the material flag video::MTF_LIGHTING +//! turned on. (This is the default setting in most scene nodes). +ILightSceneNode* CSceneManager::addLightSceneNode(ISceneNode* parent, + const core::vector3df& position, video::SColorf color, f32 range, s32 id) +{ + if (!parent) + parent = this; + + ILightSceneNode* node = new CLightSceneNode(parent, this, id, position, color, range); + node->drop(); + + return node; +} + + + +//! Adds a billboard scene node to the scene. A billboard is like a 3d sprite: A 2d element, +//! which always looks to the camera. It is usually used for things like explosions, fire, +//! lensflares and things like that. +IBillboardSceneNode* CSceneManager::addBillboardSceneNode(ISceneNode* parent, + const core::dimension2d& size, const core::vector3df& position, s32 id, + video::SColor shade_top, video::SColor shade_down + ) +{ + if (!parent) + parent = this; + + IBillboardSceneNode* node = new CBillboardSceneNode(parent, this, id, position, size, + shade_top, shade_down); + node->drop(); + + return node; +} + + + +//! Adds a skybox scene node. A skybox is a big cube with 6 textures on it and +//! is drawn around the camera position. +ISceneNode* CSceneManager::addSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, + video::ITexture* left, video::ITexture* right, video::ITexture* front, + video::ITexture* back, ISceneNode* parent, s32 id) +{ + if (!parent) + parent = this; + + ISceneNode* node = new CSkyBoxSceneNode(top, bottom, left, right, + front, back, parent, this, id); + + node->drop(); + return node; +} + + +//! Adds a skydome scene node. A skydome is a large (half-) sphere with a +//! panoramic texture on it and is drawn around the camera position. +ISceneNode* CSceneManager::addSkyDomeSceneNode(video::ITexture* texture, + u32 horiRes, u32 vertRes, f64 texturePercentage, + f64 spherePercentage, ISceneNode* parent, s32 id) +{ + if (!parent) + parent = this; + + ISceneNode* node = new CSkyDomeSceneNode(texture, horiRes, vertRes, + texturePercentage, spherePercentage, parent, this, id); + + node->drop(); + return node; +} + + +//! Adds a particle system scene node. +IParticleSystemSceneNode* CSceneManager::addParticleSystemSceneNode( + bool withDefaultEmitter, ISceneNode* parent, s32 id, + const core::vector3df& position, const core::vector3df& rotation, + const core::vector3df& scale) +{ + if (!parent) + parent = this; + + IParticleSystemSceneNode* node = new CParticleSystemSceneNode(withDefaultEmitter, + parent, this, id, position, rotation, scale); + node->drop(); + + return node; +} + + +//! Adds a terrain scene node to the scene graph. +ITerrainSceneNode* CSceneManager::addTerrainSceneNode( + const char* heightMapFileName, + ISceneNode* parent, s32 id, + const core::vector3df& position, + const core::vector3df& rotation, + const core::vector3df& scale, + video::SColor vertexColor, + s32 maxLOD, E_TERRAIN_PATCH_SIZE patchSize, s32 smoothFactor) +{ + io::IReadFile* file = FileSystem->createAndOpenFile(heightMapFileName); + if (!file) + { + os::Printer::log("Could not load terrain, because file could not be opened.", + heightMapFileName, ELL_ERROR); + return 0; + } + + ITerrainSceneNode* terrain = addTerrainSceneNode(file, parent, id, + position, rotation, scale, vertexColor, maxLOD, patchSize, smoothFactor); + file->drop(); + + return terrain; +} + +//! Adds a terrain scene node to the scene graph. +ITerrainSceneNode* CSceneManager::addTerrainSceneNode( + io::IReadFile* heightMapFile, + ISceneNode* parent, s32 id, + const core::vector3df& position, + const core::vector3df& rotation, + const core::vector3df& scale, + video::SColor vertexColor, + s32 maxLOD, E_TERRAIN_PATCH_SIZE patchSize, + s32 smoothFactor) +{ + if (!parent) + parent = this; + + CTerrainSceneNode* node = new CTerrainSceneNode(parent, this, id, + maxLOD, patchSize, position, rotation, scale); + + if (!node->loadHeightMap(heightMapFile, vertexColor, smoothFactor)) + { + node->remove(); + node->drop(); + return 0; + } + + node->drop(); + return node; +} + + +//! Adds an empty scene node. +ISceneNode* CSceneManager::addEmptySceneNode(ISceneNode* parent, s32 id) +{ + if (!parent) + parent = this; + + ISceneNode* node = new CEmptySceneNode(parent, this, id); + node->drop(); + + return node; +} + + +//! Adds a dummy transformation scene node to the scene graph. +IDummyTransformationSceneNode* CSceneManager::addDummyTransformationSceneNode( + ISceneNode* parent, s32 id) +{ + if (!parent) + parent = this; + + IDummyTransformationSceneNode* node = new CDummyTransformationSceneNode( + parent, this, id); + node->drop(); + + return node; +} + +//! Adds a Hill Plane mesh to the mesh pool. The mesh is generated on the fly +//! and looks like a plane with some hills on it. It is uses mostly for quick +//! tests of the engine only. You can specify how many hills there should be +//! on the plane and how high they should be. Also you must specify a name for +//! the mesh, because the mesh is added to the mesh pool, and can be retieved +//! again using ISceneManager::getMesh with the name as parameter. +IAnimatedMesh* CSceneManager::addHillPlaneMesh(const c8* name, + const core::dimension2d& tileSize, const core::dimension2d& tileCount, + video::SMaterial* material, f32 hillHeight, const core::dimension2d& countHills, + const core::dimension2d& textureRepeatCount) +{ + if (!name || MeshCache->isMeshLoaded(name)) + return 0; + + IAnimatedMesh* animatedMesh = CGeometryCreator::createHillPlaneMesh(tileSize, + tileCount, material, hillHeight, countHills, textureRepeatCount); + + MeshCache->addMesh(name, animatedMesh); + + animatedMesh->drop(); + + return animatedMesh; +} + + +//! Adds a terrain mesh to the mesh pool. +IAnimatedMesh* CSceneManager::addTerrainMesh(const c8* name, + video::IImage* texture, video::IImage* heightmap, + const core::dimension2d& stretchSize, + f32 maxHeight, + const core::dimension2d& defaultVertexBlockSize) +{ + if (!name || MeshCache->isMeshLoaded(name)) + return 0; + + IAnimatedMesh* animatedMesh = CGeometryCreator::createTerrainMesh(texture, + heightmap, stretchSize, maxHeight, getVideoDriver(), defaultVertexBlockSize); + + if (!animatedMesh) + return 0; + + MeshCache->addMesh(name, animatedMesh); + + animatedMesh->drop(); + + return animatedMesh; +} + +//! Adds an arrow mesh to the mesh pool. +IAnimatedMesh* CSceneManager::addArrowMesh(const c8* name,u32 tesselationCylinder, u32 tesselationCone, f32 height, f32 cylinderHeight, f32 width0,f32 width1, video::SColor vtxColor0, video::SColor vtxColor1) +{ + + if (!name || MeshCache->isMeshLoaded(name)) + return 0; + + IAnimatedMesh* animatedMesh = CGeometryCreator::createArrowMesh( + tesselationCylinder, tesselationCone, height, cylinderHeight, width0,width1, vtxColor0, vtxColor1); + + if (!animatedMesh) + return 0; + + MeshCache->addMesh(name, animatedMesh); + + animatedMesh->drop(); + + return animatedMesh; +} + + + +//! Returns the root scene node. This is the scene node wich is parent +//! of all scene nodes. The root scene node is a special scene node which +//! only exists to manage all scene nodes. It is not rendered and cannot +//! be removed from the scene. +//! \return Returns a pointer to the root scene node. +ISceneNode* CSceneManager::getRootSceneNode() +{ + return this; +} + + + +//! Returns the current active camera. +//! \return The active camera is returned. Note that this can be NULL, if there +//! was no camera created yet. +ICameraSceneNode* CSceneManager::getActiveCamera() +{ + return ActiveCamera; +} + + + +//! Sets the active camera. The previous active camera will be deactivated. +//! \param camera: The new camera which should be active. +void CSceneManager::setActiveCamera(ICameraSceneNode* camera) +{ + if (ActiveCamera) + ActiveCamera->drop(); + + ActiveCamera = camera; + + if (ActiveCamera) + ActiveCamera->grab(); +} + + + + +//! renders the node. +void CSceneManager::render() +{ +} + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CSceneManager::getBoundingBox() const +{ + _IRR_DEBUG_BREAK_IF(true) // Bounding Box of Scene Manager wanted. + + // should never be used. + return *((core::aabbox3d*)0); +} + + + +//! returns if node is culled +bool CSceneManager::isCulled(ISceneNode* node) +{ + ICameraSceneNode* cam = getActiveCamera(); + if (!cam) + return false; + + switch ( node->getAutomaticCulling() ) + { + // can be seen by a bounding box ? + case scene::EAC_BOX: + { + core::aabbox3d tbox = node->getBoundingBox(); + node->getAbsoluteTransformation().transformBox(tbox); + return !(tbox.intersectsWithBox(cam->getViewFrustum()->getBoundingBox() )); + }; + break; + + // can be seen by a bounding sphere + case scene::EAC_FRUSTUM_SPHERE: + { + }; + break; + + // can be seen by cam pyramid planes ? + case scene::EAC_FRUSTUM_BOX: + { + + SViewFrustum frust = *cam->getViewFrustum(); + + //transform the frustum to the node's current absolute transformation + core::matrix4 invTrans(node->getAbsoluteTransformation()); + invTrans.makeInverse(); + frust.transform(invTrans); + + core::vector3df edges[8]; + node->getBoundingBox().getEdges(edges); + + bool visible = true; + for (s32 i=0; igetMaterialCount(); + + taken = 0; + for (u32 i=0; igetMaterialRenderer(node->getMaterial(i).MaterialType); + if (rnd && rnd->isTransparent()) + { + // register as transparent node + TransparentNodeEntry e(node, camWorldPos); + TransparentNodeList.push_back(e); + taken = 1; + break; + } + } + + // not transparent, register as solid + if ( 0 == taken ) + { + SolidNodeList.push_back( node ); + taken = 1; + } + } + break; + case ESNRP_SHADOW: + if (!isCulled(node)) + { + ShadowNodeList.push_back(node); + taken = 1; + } + break; + case ESNRP_SHADER_0: + case ESNRP_SHADER_1: + case ESNRP_SHADER_2: + case ESNRP_SHADER_3: + case ESNRP_SHADER_4: + case ESNRP_SHADER_5: + case ESNRP_SHADER_6: + case ESNRP_SHADER_7: + case ESNRP_SHADER_8: + case ESNRP_SHADER_9: + case ESNRP_SHADER_10: + if ( !isCulled(node) ) + { + ShaderNodeList[ time - ESNRP_SHADER_0].push_back( ShaderNodeEntry ( node,time - ESNRP_SHADER_0 )); + taken = 1; + } break; + + case ESNRP_COUNT: // ignore this one + break; + } + +#ifdef SCENEMANAGER_DEBUG + s32 index = Parameters.findAttribute ( "calls" ); + Parameters.setAttribute ( index, Parameters.getAttributeAsInt ( index ) + 1 ); + + if ( 0 == taken ) + { + index = Parameters.findAttribute ( "culled" ); + Parameters.setAttribute ( index, Parameters.getAttributeAsInt ( index ) + 1 ); + } +#endif + + return taken; +} + +//! This method is called just before the rendering process of the whole scene. +//! draws all scene nodes +void CSceneManager::drawAll() +{ + if (!Driver) + return; + + // reset attributes + Parameters.setAttribute ( "culled", 0 ); + Parameters.setAttribute ( "calls", 0 ); + Parameters.setAttribute ( "drawn", 0 ); + + // reset all transforms + video::IVideoDriver* driver = getVideoDriver(); + if ( driver ) + { + core::matrix4 identity; + driver->setTransform ( video::ETS_PROJECTION, identity ); + driver->setTransform ( video::ETS_VIEW, identity ); + driver->setTransform ( video::ETS_WORLD, identity ); + driver->setTransform ( video::ETS_TEXTURE_0, identity ); + driver->setTransform ( video::ETS_TEXTURE_1, identity ); + driver->setTransform ( video::ETS_TEXTURE_2, identity ); + driver->setTransform ( video::ETS_TEXTURE_3, identity ); + } + + // do animations and other stuff. + OnAnimate(os::Timer::getTime()); + + /*! + First Scene Node for prerendering should be the active camera + consistent Camera is needed for culling + */ + camWorldPos.set(0,0,0); + if ( ActiveCamera ) + { + ActiveCamera->OnRegisterSceneNode(); + camWorldPos = ActiveCamera->getAbsolutePosition(); + } + + // let all nodes register themselves + OnRegisterSceneNode(); + + u32 i; // new ISO for scoping problem in some compilers + + //render camera scenes + { + CurrentRendertime = ESNRP_CAMERA; + for (i=0; irender(); + + CameraList.clear(); + } + + //render lights scenes + { + CurrentRendertime = ESNRP_LIGHT; + + Driver->deleteAllDynamicLights(); + + Driver->setAmbientLight(AmbientLight); + + LightList.sort (); // on distance to camera + + u32 maxLights = irr::core::min_ ( Driver->getMaximalDynamicLightAmount (), LightList.size () ); + for (i=0; i< maxLights; ++i) + LightList[i].node->render(); + + LightList.clear(); + } + + // render skyboxes + { + CurrentRendertime = ESNRP_SKY_BOX; + + for (i=0; irender(); + + SkyBoxList.clear(); + } + + + // render default objects + { + CurrentRendertime = ESNRP_SOLID; + SolidNodeList.sort(); // sort by textures + + for (i=0; irender(); + + Parameters.setAttribute ( "drawn", (s32) SolidNodeList.size () ); + + SolidNodeList.clear(); + } + + // render shadows + { + CurrentRendertime = ESNRP_SHADOW; + for (i=0; irender(); + + if (!ShadowNodeList.empty()) + Driver->drawStencilShadow(true,ShadowColor, ShadowColor, + ShadowColor, ShadowColor); + + ShadowNodeList.clear(); + } + + // render transparent objects. + { + CurrentRendertime = ESNRP_TRANSPARENT; + TransparentNodeList.sort(); // sort by distance from camera + + for (i=0; irender(); + + TransparentNodeList.clear(); + } + + // render shader objects. + { + for ( u32 g = 0; g!= ESNRP_SHADER_10 - ESNRP_SHADER_0 + 1; ++g ) + { + CurrentRendertime = (scene::E_SCENE_NODE_RENDER_PASS) (ESNRP_SHADER_0 + g); + + const u32 size = ShaderNodeList[g].size (); + if ( 0 == size ) + continue; + + ShaderNodeList[g].sort(); // sort by textures + for (i=0; i< size; ++i) + ShaderNodeList[g][i].node->render(); + + ShaderNodeList[g].clear(); + } + } + + clearDeletionList(); + + CurrentRendertime = ESNRP_COUNT; +} + + +//! Sets the color of stencil buffers shadows drawn by the scene manager. +void CSceneManager::setShadowColor(video::SColor color) +{ + ShadowColor = color; +} + + +//! Returns the current color of shadows. +video::SColor CSceneManager::getShadowColor() const +{ + return ShadowColor; +} + + + +//! creates a rotation animator, which rotates the attached scene node around itself. +ISceneNodeAnimator* CSceneManager::createRotationAnimator(const core::vector3df& rotationPerSecond) +{ + ISceneNodeAnimator* anim = new CSceneNodeAnimatorRotation(os::Timer::getTime(), + rotationPerSecond); + + return anim; +} + + + +//! creates a fly circle animator, which lets the attached scene node fly around a center. +ISceneNodeAnimator* CSceneManager::createFlyCircleAnimator(const core::vector3df& normal, + f32 radius, f32 speed, + const core::vector3df& direction) +{ + ISceneNodeAnimator* anim = new CSceneNodeAnimatorFlyCircle(os::Timer::getTime(), normal, + radius, speed, direction); + return anim; +} + + +//! Creates a fly straight animator, which lets the attached scene node +//! fly or move along a line between two points. +ISceneNodeAnimator* CSceneManager::createFlyStraightAnimator(const core::vector3df& startPoint, + const core::vector3df& endPoint, u32 timeForWay, bool loop) +{ + ISceneNodeAnimator* anim = new CSceneNodeAnimatorFlyStraight(startPoint, + endPoint, timeForWay, loop, os::Timer::getTime()); + + return anim; +} + + +//! Creates a texture animator, which switches the textures of the target scene +//! node based on a list of textures. +ISceneNodeAnimator* CSceneManager::createTextureAnimator(const core::array& textures, + s32 timePerFrame, bool loop) +{ + ISceneNodeAnimator* anim = new CSceneNodeAnimatorTexture(textures, + timePerFrame, loop, os::Timer::getTime()); + + return anim; +} + + +//! Creates a scene node animator, which deletes the scene node after +//! some time automaticly. +ISceneNodeAnimator* CSceneManager::createDeleteAnimator(u32 when) +{ + return new CSceneNodeAnimatorDelete(this, os::Timer::getTime() + when); +} + + + + +//! Creates a special scene node animator for doing automatic collision detection +//! and response. +ISceneNodeAnimatorCollisionResponse* CSceneManager::createCollisionResponseAnimator( + ITriangleSelector* world, ISceneNode* sceneNode, const core::vector3df& ellipsoidRadius, + const core::vector3df& gravityPerSecond, + const core::vector3df& ellipsoidTranslation, f32 slidingValue) +{ + ISceneNodeAnimatorCollisionResponse* anim = new + CSceneNodeAnimatorCollisionResponse(this, world, sceneNode, + ellipsoidRadius, gravityPerSecond, + ellipsoidTranslation, slidingValue); + + return anim; +} + + +//! Creates a follow spline animator. +ISceneNodeAnimator* CSceneManager::createFollowSplineAnimator(s32 startTime, + const core::array< core::vector3df >& points, + f32 speed, f32 tightness) +{ + ISceneNodeAnimator* a = new CSceneNodeAnimatorFollowSpline(startTime, points, + speed, tightness); + return a; +} + + + +//! Adds an external mesh loader. +void CSceneManager::addExternalMeshLoader(IMeshLoader* externalLoader) +{ + if (!externalLoader) + return; + + externalLoader->grab(); + MeshLoaderList.push_back(externalLoader); +} + + + +//! Returns a pointer to the scene collision manager. +ISceneCollisionManager* CSceneManager::getSceneCollisionManager() +{ + return CollisionManager; +} + + +//! Returns a pointer to the mesh manipulator. +IMeshManipulator* CSceneManager::getMeshManipulator() +{ + return MeshManipulator; +} + + +//! Creates a simple ITriangleSelector, based on a mesh. +ITriangleSelector* CSceneManager::createTriangleSelector(IMesh* mesh, ISceneNode* node) +{ + if (!mesh || !node) + return 0; + + return new CTriangleSelector(mesh, node); +} + + +//! Creates a simple dynamic ITriangleSelector, based on a axis aligned bounding box. +ITriangleSelector* CSceneManager::createTriangleSelectorFromBoundingBox(ISceneNode* node) +{ + if (!node) + return 0; + + return new CTriangleBBSelector(node); +} + + +//! Creates a simple ITriangleSelector, based on a mesh. +ITriangleSelector* CSceneManager::createOctTreeTriangleSelector(IMesh* mesh, + ISceneNode* node, + s32 minimalPolysPerNode) +{ + if (!mesh || !node) + return 0; + + return new COctTreeTriangleSelector(mesh, node, minimalPolysPerNode); +} + + + +//! Creates a meta triangle selector. +IMetaTriangleSelector* CSceneManager::createMetaTriangleSelector() +{ + return new CMetaTriangleSelector(); +} + + + +//! Creates a triangle selector which can select triangles from a terrain scene node +ITriangleSelector* CSceneManager::createTerrainTriangleSelector( + ITerrainSceneNode* node, s32 LOD) +{ + return new CTerrainTriangleSelector(node, LOD); +} + + + +//! Adds a scene node to the deletion queue. +void CSceneManager::addToDeletionQueue(ISceneNode* node) +{ + if (!node) + return; + + node->grab(); + DeletionList.push_back(node); +} + + +//! clears the deletion list +void CSceneManager::clearDeletionList() +{ + if (DeletionList.empty()) + return; + + for (s32 i=0; i<(s32)DeletionList.size(); ++i) + { + DeletionList[i]->remove(); + DeletionList[i]->drop(); + } + + DeletionList.clear(); +} + + +//! Returns the first scene node with the specified name. +ISceneNode* CSceneManager::getSceneNodeFromName(const char* name, ISceneNode* start) +{ + if (start == 0) + start = getRootSceneNode(); + + if (!strcmp(start->getName(),name)) + return start; + + ISceneNode* node = 0; + + const core::list& list = start->getChildren(); + core::list::Iterator it = list.begin(); + for (; it!=list.end(); ++it) + { + node = getSceneNodeFromName(name, *it); + if (node) + return node; + } + + return 0; +} + + +//! Returns the first scene node with the specified id. +ISceneNode* CSceneManager::getSceneNodeFromId(s32 id, ISceneNode* start) +{ + if (start == 0) + start = getRootSceneNode(); + + if (start->getID() == id) + return start; + + ISceneNode* node = 0; + + const core::list& list = start->getChildren(); + core::list::Iterator it = list.begin(); + for (; it!=list.end(); ++it) + { + node = getSceneNodeFromId(id, *it); + if (node) + return node; + } + + return 0; +} + + +//! Posts an input event to the environment. Usually you do not have to +//! use this method, it is used by the internal engine. +bool CSceneManager::postEventFromUser(SEvent event) +{ + bool ret = false; + ICameraSceneNode* cam = getActiveCamera(); + if (cam) + ret = cam->OnEvent(event); + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return ret; +} + + +//! Removes all children of this scene node +void CSceneManager::removeAll() +{ + ISceneNode::removeAll(); + setActiveCamera(0); +} + + +//! Clears the whole scene. All scene nodes are removed. +void CSceneManager::clear() +{ + removeAll(); +} + + +//! Returns interface to the parameters set in this scene. +io::IAttributes* CSceneManager::getParameters() +{ + return &Parameters; +} + + +//! Returns current render pass. +E_SCENE_NODE_RENDER_PASS CSceneManager::getSceneNodeRenderPass() +{ + return CurrentRendertime; +} + + + +//! Returns an interface to the mesh cache which is shared beween all existing scene managers. +IMeshCache* CSceneManager::getMeshCache() +{ + return MeshCache; +} + + +//! Creates a new scene manager. +ISceneManager* CSceneManager::createNewSceneManager() +{ + return new CSceneManager(Driver, FileSystem, CursorControl, MeshCache); +} + + +//! Returns the default scene node factory which can create all built in scene nodes +ISceneNodeFactory* CSceneManager::getDefaultSceneNodeFactory() +{ + return getSceneNodeFactory(0); +} + + +//! Adds a scene node factory to the scene manager. +void CSceneManager::registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd) +{ + if (factoryToAdd) + { + factoryToAdd->grab(); + SceneNodeFactoryList.push_back(factoryToAdd); + } +} + + +//! Returns amount of registered scene node factories. +s32 CSceneManager::getRegisteredSceneNodeFactoryCount() +{ + return SceneNodeFactoryList.size(); +} + + +//! Returns a scene node factory by index +ISceneNodeFactory* CSceneManager::getSceneNodeFactory(s32 index) +{ + if (index>=0 && index<(int)SceneNodeFactoryList.size()) + return SceneNodeFactoryList[index]; + + return 0; +} + + +//! Returns the default scene node animator factory which can create all built-in scene node animators +ISceneNodeAnimatorFactory* CSceneManager::getDefaultSceneNodeAnimatorFactory() +{ + return getSceneNodeAnimatorFactory(0); +} + +//! Adds a scene node animator factory to the scene manager. +void CSceneManager::registerSceneNodeAnimatorFactory(ISceneNodeAnimatorFactory* factoryToAdd) +{ + if (factoryToAdd) + { + factoryToAdd->grab(); + SceneNodeAnimatorFactoryList.push_back(factoryToAdd); + } +} + + +//! Returns amount of registered scene node animator factories. +s32 CSceneManager::getRegisteredSceneNodeAnimatorFactoryCount() +{ + return SceneNodeAnimatorFactoryList.size(); +} + + +//! Returns a scene node animator factory by index +ISceneNodeAnimatorFactory* CSceneManager::getSceneNodeAnimatorFactory(s32 index) +{ + if (index>=0 && index<(int)SceneNodeAnimatorFactoryList.size()) + return SceneNodeAnimatorFactoryList[index]; + + return 0; +} + + +//! Saves the current scene into a file. +//! \param filename: Name of the file . +bool CSceneManager::saveScene(const c8* filename, ISceneUserDataSerializer* userDataSerializer) +{ + io::IWriteFile* file = FileSystem->createAndWriteFile(filename); + if (!file) + return false; + + bool ret = saveScene(file, userDataSerializer); + file->drop(); + return ret; +} + + +//! Saves the current scene into a file. +bool CSceneManager::saveScene(io::IWriteFile* file, ISceneUserDataSerializer* userDataSerializer) +{ + if (!file) + return false; + + io::IXMLWriter* writer = FileSystem->createXMLWriter(file); + if (!writer) + return false; + + writer->writeXMLHeader(); + writeSceneNode(writer, this, userDataSerializer); + writer->drop(); + + return true; +} + + +//! Loads a scene. Note that the current scene is not cleared before. +//! \param filename: Name of the file . +bool CSceneManager::loadScene(const c8* filename, ISceneUserDataSerializer* userDataSerializer) +{ + io::IReadFile* read = FileSystem->createAndOpenFile(filename); + if (!read) + { + os::Printer::log("Unable to open scene file", filename, ELL_ERROR); + return false; + } + + bool ret = loadScene(read, userDataSerializer); + read->drop(); + + return ret; +} + + +//! Loads a scene. Note that the current scene is not cleared before. +bool CSceneManager::loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer) +{ + if (!file) + { + os::Printer::log("Unable to open scene file", ELL_ERROR); + return false; + } + + io::IXMLReader* reader = FileSystem->createXMLReader(file); + if (!reader) + { + os::Printer::log("Scene is not a valid XML file", file->getFileName(), ELL_ERROR); + return false; + } + + // for mesh loading, set collada loading attributes + + bool bOldColladaSingleMesh = getParameters()->getAttributeAsBool(COLLADA_CREATE_SCENE_INSTANCES); + getParameters()->setAttribute(COLLADA_CREATE_SCENE_INSTANCES, false); + + // read file + + while(reader->read()) + { + readSceneNode(reader, 0, userDataSerializer); + } + + // restore old collada parameters + + getParameters()->setAttribute(COLLADA_CREATE_SCENE_INSTANCES, bOldColladaSingleMesh); + + // finish up + + reader->drop(); + return true; + +} + + +//! reads a scene node +void CSceneManager::readSceneNode(io::IXMLReader* reader, ISceneNode* parent, ISceneUserDataSerializer* userDataSerializer) +{ + if (!reader) + return; + + scene::ISceneNode* node = 0; + + if ((!parent && IRR_XML_FORMAT_SCENE==reader->getNodeName()) || + ( parent && IRR_XML_FORMAT_NODE==reader->getNodeName())) + { + if (parent) + { + // find node type and create it + core::stringc attrName = reader->getAttributeValue(IRR_XML_FORMAT_NODE_ATTR_TYPE.c_str()); + + for (int i=0; i<(int)SceneNodeFactoryList.size() && !node; ++i) + node = SceneNodeFactoryList[i]->addSceneNode(attrName.c_str(), parent); + + if (!node) + os::Printer::log("Could not create scene node of unknown type", attrName.c_str()); + } + else + node = this; // root + } + + // read attributes + + while(reader->read()) + { + bool endreached = false; + + switch (reader->getNodeType()) + { + case io::EXN_ELEMENT_END: + if ((IRR_XML_FORMAT_NODE==reader->getNodeName()) || + (IRR_XML_FORMAT_SCENE==reader->getNodeName())) + { + endreached = true; + } + break; + case io::EXN_ELEMENT: + if (core::stringw(L"attributes")==reader->getNodeName()) + { + // read attributes + io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); + attr->read(reader, true); + + if (node) + node->deserializeAttributes(attr); + + attr->drop(); + } + else + if (core::stringw(L"materials")==reader->getNodeName()) + readMaterials(reader, node); + else + if (core::stringw(L"animators")==reader->getNodeName()) + readAnimators(reader, node); + else + if (core::stringw(L"userData")==reader->getNodeName()) + readUserData(reader, node, userDataSerializer); + else + if ((IRR_XML_FORMAT_NODE==reader->getNodeName()) || + (IRR_XML_FORMAT_SCENE==reader->getNodeName())) + { + readSceneNode(reader, node, userDataSerializer); + } + else + { + os::Printer::log("Found unknown element in irrlicht scene file", + core::stringc(reader->getNodeName()).c_str()); + } + break; + default: + break; + } + + if (endreached) + break; + } +} + + +//! reads materials of a node +void CSceneManager::readMaterials(io::IXMLReader* reader, ISceneNode* node) +{ + u32 nr = 0; + + while(reader->read()) + { + const wchar_t* name = reader->getNodeName(); + + switch(reader->getNodeType()) + { + case io::EXN_ELEMENT_END: + if (core::stringw(L"materials")==name) + return; + break; + case io::EXN_ELEMENT: + if (core::stringw(L"attributes")==name) + { + // read materials from attribute list + io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); + attr->read(reader); + + if (node && node->getMaterialCount() > nr) + { + getVideoDriver()->fillMaterialStructureFromAttributes( + node->getMaterial(nr), attr); + } + + attr->drop(); + ++nr; + } + break; + default: + break; + } + } +} + + +//! reads animators of a node +void CSceneManager::readAnimators(io::IXMLReader* reader, ISceneNode* node) +{ + s32 cnt = 0; + + while(reader->read()) + { + const wchar_t* name = reader->getNodeName(); + + switch(reader->getNodeType()) + { + case io::EXN_ELEMENT_END: + if (core::stringw(L"animators")==name) + return; + break; + case io::EXN_ELEMENT: + if (core::stringw(L"attributes")==name) + { + // read animator data from attribute list + io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); + attr->read(reader); + + if (node) + { + core::stringc typeName = attr->getAttributeAsString("Type"); + ISceneNodeAnimator* anim = 0; + + for (int i=0; i<(int)SceneNodeAnimatorFactoryList.size() && !anim; ++i) + anim = SceneNodeAnimatorFactoryList[i]->createSceneNodeAnimator(typeName.c_str(), node); + + if (anim) + { + anim->deserializeAttributes(attr); + anim->drop(); + } + } + + attr->drop(); + ++cnt; + } + break; + default: + break; + } + } +} + + +//! reads user data of a node +void CSceneManager::readUserData(io::IXMLReader* reader, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer) +{ + while(reader->read()) + { + const wchar_t* name = reader->getNodeName(); + + switch(reader->getNodeType()) + { + case io::EXN_ELEMENT_END: + if (core::stringw(L"userData")==name) + return; + break; + case io::EXN_ELEMENT: + if (core::stringw(L"attributes")==name) + { + // read user data from attribute list + io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); + attr->read(reader); + + if (node && userDataSerializer) + { + userDataSerializer->OnReadUserData(node, attr); + } + + attr->drop(); + } + break; + default: + break; + } + } +} + + +//! writes a scene node +void CSceneManager::writeSceneNode(io::IXMLWriter* writer, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer) +{ + if (!writer || !node || node->isDebugObject()) + return; + + const wchar_t* name = 0; + + if (node == this) + { + name = IRR_XML_FORMAT_SCENE.c_str(); + writer->writeElement(name, false); + } + else + { + name = IRR_XML_FORMAT_NODE.c_str(); + writer->writeElement(name, false, IRR_XML_FORMAT_NODE_ATTR_TYPE.c_str(), + core::stringw(getSceneNodeTypeName(node->getType())).c_str()); + } + + writer->writeLineBreak(); + writer->writeLineBreak(); + + // write properties + + io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); + node->serializeAttributes(attr); + + if (attr->getAttributeCount() > 0) + { + attr->write(writer); + writer->writeLineBreak(); + } + + // write materials + + if (node->getMaterialCount() && getVideoDriver()) + { + const wchar_t* materialElement = L"materials"; + + writer->writeElement(materialElement); + writer->writeLineBreak(); + + for (u32 i=0; i < node->getMaterialCount(); ++i) + { + io::IAttributes* attr = + getVideoDriver()->createAttributesFromMaterial(node->getMaterial(i)); + attr->write(writer); + attr->drop(); + } + + writer->writeClosingTag(materialElement); + writer->writeLineBreak(); + } + + // write animators + + if (!node->getAnimators().empty()) + { + const wchar_t* animatorElement = L"animators"; + writer->writeElement(animatorElement); + writer->writeLineBreak(); + + core::list::Iterator it = node->getAnimators().begin(); + for (; it != node->getAnimators().end(); ++it) + { + attr->clear(); + attr->addString("Type", getAnimatorTypeName((*it)->getType())); + + (*it)->serializeAttributes(attr); + + attr->write(writer); + } + + writer->writeClosingTag(animatorElement); + writer->writeLineBreak(); + } + + // write possible user data + + if ( userDataSerializer ) + { + io::IAttributes* userData = userDataSerializer->createUserData(node); + if (userData) + { + const wchar_t* userDataElement = L"userData"; + + writer->writeLineBreak(); + writer->writeElement(userDataElement); + writer->writeLineBreak(); + + userData->write(writer); + + writer->writeClosingTag(userDataElement); + writer->writeLineBreak(); + writer->writeLineBreak(); + + userData->drop(); + } + } + + // write children + + core::list::Iterator it = node->getChildren().begin(); + for (; it != node->getChildren().end(); ++it) + writeSceneNode(writer, (*it), userDataSerializer); + + attr->drop(); + + writer->writeClosingTag(name); + writer->writeLineBreak(); + writer->writeLineBreak(); +} + + +//! Returns a typename from a scene node type or null if not found +const c8* CSceneManager::getSceneNodeTypeName(ESCENE_NODE_TYPE type) +{ + const char* name = 0; + + for (int i=0; !name && i<(int)SceneNodeFactoryList.size(); ++i) + name = SceneNodeFactoryList[i]->getCreateableSceneNodeTypeName(type); + + return name; +} + +//! Returns a typename from a scene node animator type or null if not found +const c8* CSceneManager::getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type) +{ + const char* name = 0; + + for (int i=0; !name && i<(int)SceneNodeAnimatorFactoryList.size(); ++i) + name = SceneNodeAnimatorFactoryList[i]->getCreateableSceneNodeAnimatorTypeName(type); + + return name; +} +//! Writes attributes of the scene node. +void CSceneManager::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + out->addString ("Name", Name.c_str()); + out->addInt ("Id", ID ); + out->addColorf ("AmbientLight", AmbientLight); +} + +//! Reads attributes of the scene node. +void CSceneManager::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + Name = in->getAttributeAsString("Name"); + ID = in->getAttributeAsInt("Id"); + AmbientLight = in->getAttributeAsColorf("AmbientLight"); + + RelativeTranslation.set(0,0,0); + RelativeRotation.set(0,0,0); + RelativeScale.set(1,1,1); + IsVisible = true; + AutomaticCullingState = scene::EAC_BOX; + DebugDataVisible = scene::EDS_OFF; + IsDebugObject = false; + + updateAbsolutePosition(); +} + + +//! Sets ambient color of the scene +void CSceneManager::setAmbientLight(const video::SColorf &ambientColor) +{ + AmbientLight = ambientColor; +} + + +//! Returns ambient color of the scene +video::SColorf CSceneManager::getAmbientLight() +{ + return AmbientLight; +} + + +// creates a scenemanager +ISceneManager* createSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, + gui::ICursorControl* cursorcontrol, + gui::IGUIEnvironment *guiEnvironment ) +{ + return new CSceneManager(driver, fs, cursorcontrol, 0, guiEnvironment ); +} + + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CSceneManager.h b/src/dep/src/irrlicht/CSceneManager.h index 84d3b05..ce9ebdc 100644 --- a/src/dep/src/irrlicht/CSceneManager.h +++ b/src/dep/src/irrlicht/CSceneManager.h @@ -1,593 +1,593 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_MANAGER_H_INCLUDED__ -#define __C_SCENE_MANAGER_H_INCLUDED__ - -#include "ISceneManager.h" -#include "ISceneNode.h" -#include "ICursorControl.h" -#include "irrString.h" -#include "irrArray.h" -#include "IMeshLoader.h" -#include "CAttributes.h" - -namespace irr -{ -namespace io -{ - class IXMLWriter; -} -namespace scene -{ - class CMeshCache; - - /*! - The Scene Manager manages scene nodes, mesh recources, cameras and all the other stuff. - */ - class CSceneManager : public ISceneManager, public ISceneNode - { - public: - - //! constructor - CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, - gui::ICursorControl* cursorControl, CMeshCache* cache = 0, - gui::IGUIEnvironment *guiEnvironment = 0); - - //! destructor - virtual ~CSceneManager(); - - //! gets an animateable mesh. loads it if needed. returned pointer must not be dropped. - virtual IAnimatedMesh* getMesh(const c8* filename); - - //! Returns an interface to the mesh cache which is shared beween all existing scene managers. - virtual IMeshCache* getMeshCache(); - - //! returns the video driver - virtual video::IVideoDriver* getVideoDriver(); - - virtual gui::IGUIEnvironment* getGUIEnvironment(); - - //! adds a cube scene node to the scene. It is a simple cube of (1,1,1) size. - //! the returned pointer must not be dropped. - virtual ISceneNode* addCubeSceneNode(f32 size=10.0f, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& rotation = core::vector3df(0,0,0), const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! Adds a sphere scene node for test purposes to the scene. - virtual ISceneNode* addSphereSceneNode(f32 radius=5.0f, s32 polyCount=16, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! adds a scene node for rendering an animated mesh model - virtual IAnimatedMeshSceneNode* addAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), - bool alsoAddIfMeshPointerZero=false); - - //! adds a scene node for rendering a static mesh - //! the returned pointer must not be dropped. - virtual IMeshSceneNode* addMeshSceneNode(IMesh* mesh, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), - bool alsoAddIfMeshPointerZero=false); - - //! Adds a scene node for rendering a animated water surface mesh. - virtual ISceneNode* addWaterSurfaceSceneNode(IMesh* mesh, f32 waveHeight, f32 waveSpeed, f32 wlenght, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! registers a node for rendering it at a specific time. - virtual u32 registerNodeForRendering(ISceneNode* node, E_SCENE_NODE_RENDER_PASS = ESNRP_AUTOMATIC); - - //! draws all scene nodes - virtual void drawAll(); - - //! Adds a scene node for rendering using a octtree to the scene graph. This a good method for rendering - //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much - //! faster then a bsp tree. - virtual ISceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, - s32 id=-1, s32 minimalPolysPerNode=128, bool alsoAddIfMeshPointerZero=false); - - //! Adss a scene node for rendering using a octtree. This a good method for rendering - //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much - //! faster then a bsp tree. - virtual ISceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0, - s32 id=-1, s32 minimalPolysPerNode=128, bool alsoAddIfMeshPointerZero=false); - - //! Adds a camera scene node to the tree and sets it as active camera. - //! \param position: Position of the space relative to its parent where the camera will be placed. - //! \param lookat: Position where the camera will look at. Also known as target. - //! \param parent: Parent scene node of the camera. Can be null. If the parent moves, - //! the camera will move too. - //! \return Returns pointer to interface to camera - virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& lookat = core::vector3df(0,0,0), s32 id=-1); - - //! Adds a camera scene node which is able to be controlle with the mouse similar - //! like in the 3D Software Maya by Alias Wavefront. - //! The returned pointer must not be dropped. - virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent = 0, - f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 translationSpeed = 100.0f, s32 id=-1); - - //! Adds a camera scene node which is able to be controled with the mouse and keys - //! like in most first person shooters (FPS): - virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, - f32 rotateSpeed = 1500.0f, f32 moveSpeed = 200.0f, s32 id=-1, - SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false, - f32 jumpSpeed = 0.f); - - //! Adds a dynamic light scene node. The light will cast dynamic light on all - //! other scene nodes in the scene, which have the material flag video::MTF_LIGHTING - //! turned on. (This is the default setting in most scene nodes). - virtual ILightSceneNode* addLightSceneNode(ISceneNode* parent = 0, - const core::vector3df& position = core::vector3df(0,0,0), - video::SColorf color = video::SColorf(1.0f, 1.0f, 1.0f), f32 range=100.0f, s32 id=-1); - - //! Adds a billboard scene node to the scene. A billboard is like a 3d sprite: A 2d element, - //! which always looks to the camera. It is usually used for things like explosions, fire, - //! lensflares and things like that. - virtual IBillboardSceneNode* addBillboardSceneNode(ISceneNode* parent = 0, - const core::dimension2d& size = core::dimension2d(10.0f, 10.0f), - const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, - video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF); - - //! Adds a skybox scene node. A skybox is a big cube with 6 textures on it and - //! is drawn around the camera position. - virtual ISceneNode* addSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, - video::ITexture* left, video::ITexture* right, video::ITexture* front, - video::ITexture* back, ISceneNode* parent = 0, s32 id=-1); - - //! Adds a skydome scene node. A skydome is a large (half-) sphere with a - //! panoramic texture on it and is drawn around the camera position. - virtual ISceneNode* addSkyDomeSceneNode(video::ITexture* texture, - u32 horiRes, u32 vertRes, f64 texturePercentage, - f64 spherePercentage, ISceneNode* parent=0, s32 id=-1); - - //! Adds a text scene node, which is able to display - //! 2d text at a position in three dimensional space - virtual ITextSceneNode* addTextSceneNode(gui::IGUIFont* font, const wchar_t* text, - video::SColor color=video::SColor(100,255,255,255), - ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0), - s32 id=-1); - - //! Adds a text scene node, which uses billboards - virtual ITextSceneNode* addBillboardTextSceneNode(gui::IGUIFont* font, const wchar_t* text, - ISceneNode* parent = 0, - const core::dimension2d& size = core::dimension2d(10.0f, 10.0f), - const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, - video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF); - - //! Adds a scene node, which can render a quake3 shader - virtual ISceneNode* addQuake3SceneNode(IMeshBuffer* meshBuffer, const quake3::SShader * shader, - ISceneNode* parent=0, s32 id=-1 - ); - - - //! Adds a Hill Plane mesh to the mesh pool. The mesh is generated on the fly - //! and looks like a plane with some hills on it. It is uses mostly for quick - //! tests of the engine only. You can specify how many hills there should be - //! on the plane and how high they should be. Also you must specify a name for - //! the mesh, because the mesh is added to the mesh pool, and can be retieved - //! again using ISceneManager::getMesh with the name as parameter. - virtual IAnimatedMesh* addHillPlaneMesh(const c8* name, - const core::dimension2d& tileSize, const core::dimension2d& tileCount, - video::SMaterial* material = 0, f32 hillHeight = 0.0f, - const core::dimension2d& countHills = core::dimension2d(0.0f, 0.0f), - const core::dimension2d& textureRepeatCount = core::dimension2d(1.0f, 1.0f)); - - //! Adds a terrain mesh to the mesh pool. - virtual IAnimatedMesh* addTerrainMesh(const c8* meshname, video::IImage* texture, video::IImage* heightmap, - const core::dimension2d& stretchSize, - f32 maxHeight, const core::dimension2d& defaultVertexBlockSize); - - //! Add a arrow mesh to the mesh pool - virtual IAnimatedMesh* addArrowMesh(const c8* name, u32 tesselationCylinder, u32 tesselationCone, f32 height, - f32 cylinderHeight, f32 width0,f32 width1, - video::SColor vtxColor0, video::SColor vtxColor1); - - //! Adds a particle system scene node. - virtual IParticleSystemSceneNode* addParticleSystemSceneNode( - bool withDefaultEmitter=true, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! Adds a terrain scene node to the scene graph. - virtual ITerrainSceneNode* addTerrainSceneNode( - const c8* heightMapFileName, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), - video::SColor vertexColor = video::SColor(255,255,255,255), - s32 maxLOD=4, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17,s32 smoothFactor=0); - - //! Adds a terrain scene node to the scene graph. - virtual ITerrainSceneNode* addTerrainSceneNode( - io::IReadFile* heightMap, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), - video::SColor vertexColor = video::SColor(255,255,255,255), - s32 maxLOD=4, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17,s32 smoothFactor=0); - - //! Adds a dummy transformation scene node to the scene graph. - virtual IDummyTransformationSceneNode* addDummyTransformationSceneNode( - ISceneNode* parent=0, s32 id=-1); - - //! Adds an empty scene node. - virtual ISceneNode* addEmptySceneNode(ISceneNode* parent, s32 id=-1); - - //! Returns the root scene node. This is the scene node wich is parent - //! of all scene nodes. The root scene node is a special scene node which - //! only exists to manage all scene nodes. It is not rendered and cannot - //! be removed from the scene. - //! \return Returns a pointer to the root scene node. - virtual ISceneNode* getRootSceneNode(); - - //! Returns the current active camera. - //! \return The active camera is returned. Note that this can be NULL, if there - //! was no camera created yet. - virtual ICameraSceneNode* getActiveCamera(); - - //! Sets the active camera. The previous active camera will be deactivated. - //! \param camera: The new camera which should be active. - virtual void setActiveCamera(ICameraSceneNode* camera); - - //! creates a rotation animator, which rotates the attached scene node around itself. - //! \param rotationPerSecond: Specifies the speed of the animation - //! \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() - //! and the animator will animate it. - virtual ISceneNodeAnimator* createRotationAnimator(const core::vector3df& rotationPerSecond); - - //! creates a fly circle animator, which lets the attached scene node fly - //! around a center. The center is the position of the scene node. - //! \param rotationSpeed: - //! \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() - //! and the animator will animate it. - virtual ISceneNodeAnimator* createFlyCircleAnimator(const core::vector3df& normal, f32 radius, f32 speed, - const core::vector3df& direction); - - //! Creates a fly straight animator, which lets the attached scene node - //! fly or move along a line between two points. - virtual ISceneNodeAnimator* createFlyStraightAnimator(const core::vector3df& startPoint, - const core::vector3df& endPoint, u32 timeForWay, bool loop=false); - - //! Creates a texture animator, which switches the textures of the target scene - //! node based on a list of textures. - virtual ISceneNodeAnimator* createTextureAnimator(const core::array& textures, - s32 timePerFrame, bool loop); - - //! Creates a scene node animator, which deletes the scene node after - //! some time automaticly. - virtual ISceneNodeAnimator* createDeleteAnimator(u32 timeMS); - - - //! Creates a special scene node animator for doing automatic collision detection - //! and response. - virtual ISceneNodeAnimatorCollisionResponse* createCollisionResponseAnimator( - ITriangleSelector* world, ISceneNode* sceneNode, - const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30), - const core::vector3df& gravityPerSecond = core::vector3df(0,-1.0f,0), - const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0), - f32 slidingValue = 0.0005f); - - //! Creates a follow spline animator. - virtual ISceneNodeAnimator* createFollowSplineAnimator(s32 startTime, - const core::array< core::vector3df >& points, - f32 speed = 1.0f, f32 tightness = 0.5f); - - - //! Creates a simple ITriangleSelector, based on a mesh. - virtual ITriangleSelector* createTriangleSelector(IMesh* mesh, ISceneNode* node); - - //! Creates a simple ITriangleSelector, based on a mesh. - virtual ITriangleSelector* createOctTreeTriangleSelector(IMesh* mesh, - ISceneNode* node, s32 minimalPolysPerNode); - - //! Creates a simple dynamic ITriangleSelector, based on a axis aligned bounding box. - virtual ITriangleSelector* createTriangleSelectorFromBoundingBox( - ISceneNode* node); - - //! Creates a meta triangle selector. - virtual IMetaTriangleSelector* createMetaTriangleSelector(); - - //! Creates a triangle selector which can select triangles from a terrain scene node - //! \param: Pointer to the created terrain scene node - //! \param: Level of detail, 0 for highest detail. - virtual ITriangleSelector* createTerrainTriangleSelector( - ITerrainSceneNode* node, s32 LOD=0); - - //! Adds an external mesh loader. - virtual void addExternalMeshLoader(IMeshLoader* externalLoader); - - //! Returns a pointer to the scene collision manager. - virtual ISceneCollisionManager* getSceneCollisionManager(); - - //! Returns a pointer to the mesh manipulator. - virtual IMeshManipulator* getMeshManipulator(); - - //! Sets the color of stencil buffers shadows drawn by the scene manager. - virtual void setShadowColor(video::SColor color); - - //! Returns the current color of shadows. - virtual video::SColor getShadowColor() const; - - //! Adds a scene node to the deletion queue. - virtual void addToDeletionQueue(ISceneNode* node); - - //! Returns the first scene node with the specified id. - virtual ISceneNode* getSceneNodeFromId(s32 id, ISceneNode* start=0); - - //! Returns the first scene node with the specified name. - virtual ISceneNode* getSceneNodeFromName(const c8* name, ISceneNode* start=0); - - //! Posts an input event to the environment. Usually you do not have to - //! use this method, it is used by the internal engine. - virtual bool postEventFromUser(SEvent event); - - //! Clears the whole scene. All scene nodes are removed. - virtual void clear(); - - //! Removes all children of this scene node - virtual void removeAll(); - - //! Returns interface to the parameters set in this scene. - virtual io::IAttributes* getParameters(); - - //! Returns current render pass. - virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass(); - - //! Creates a new scene manager. - virtual ISceneManager* createNewSceneManager(); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_UNKNOWN; } - - //! Returns the default scene node factory which can create all built in scene nodes - virtual ISceneNodeFactory* getDefaultSceneNodeFactory(); - - //! Adds a scene node factory to the scene manager. - /** Use this to extend the scene manager with new scene node types which it should be - able to create automaticly, for example when loading data from xml files. */ - virtual void registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd); - - //! Returns amount of registered scene node factories. - virtual s32 getRegisteredSceneNodeFactoryCount(); - - //! Returns a scene node factory by index - virtual ISceneNodeFactory* getSceneNodeFactory(s32 index); - - //! Returns a typename from a scene node type or null if not found - virtual const c8* getSceneNodeTypeName(ESCENE_NODE_TYPE type); - - //! Returns the default scene node animator factory which can create all built-in scene node animators - virtual ISceneNodeAnimatorFactory* getDefaultSceneNodeAnimatorFactory(); - - //! Adds a scene node animator factory to the scene manager. - virtual void registerSceneNodeAnimatorFactory(ISceneNodeAnimatorFactory* factoryToAdd); - - //! Returns amount of registered scene node animator factories. - virtual s32 getRegisteredSceneNodeAnimatorFactoryCount(); - - //! Returns a scene node animator factory by index - virtual ISceneNodeAnimatorFactory* getSceneNodeAnimatorFactory(s32 index); - - //! Saves the current scene into a file. - //! \param filename: Name of the file . - virtual bool saveScene(const c8* filename, ISceneUserDataSerializer* userDataSerializer=0); - - //! Saves the current scene into a file. - virtual bool saveScene(io::IWriteFile* file, ISceneUserDataSerializer* userDataSerializer=0); - - //! Loads a scene. Note that the current scene is not cleared before. - //! \param filename: Name of the file . - virtual bool loadScene(const c8* filename, ISceneUserDataSerializer* userDataSerializer=0); - - //! Loads a scene. Note that the current scene is not cleared before. - virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0); - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Sets ambient color of the scene - virtual void setAmbientLight(const video::SColorf &ambientColor); - - //! Returns ambient color of the scene - virtual video::SColorf getAmbientLight(); - - private: - - //! Returns a typename from a scene node animator type or null if not found - virtual const c8* getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type); - - //! returns if node is culled - bool isCulled(ISceneNode* node); - - //! clears the deletion list - void clearDeletionList(); - - //! writes a scene node - void writeSceneNode(io::IXMLWriter* writer, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer); - - //! reads a scene node - void readSceneNode(io::IXMLReader* reader, ISceneNode* parent, ISceneUserDataSerializer* userDataSerializer); - - //! read materials - void readMaterials(io::IXMLReader* reader, ISceneNode* node); - - //! reads animators of a node - void readAnimators(io::IXMLReader* reader, ISceneNode* node); - - //! reads user data of a node - void readUserData(io::IXMLReader* reader, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer); - - struct DefaultNodeEntry - { - DefaultNodeEntry() {}; - - DefaultNodeEntry(ISceneNode* n) - { - textureValue = 0; - - if (n->getMaterialCount()) - textureValue = (n->getMaterial(0).Textures[0]); - - node = n; - } - - ISceneNode* node; - void* textureValue; - - bool operator < (const DefaultNodeEntry& other) const - { - return (textureValue < other.textureValue); - } - }; - - struct ShaderNodeEntry - { - ShaderNodeEntry() {}; - - ShaderNodeEntry(ISceneNode* n, u32 sceneTime ) - { - textureValue = n->getMaterial( sceneTime ).Textures[0]; - - node = n; - } - - ISceneNode* node; - void* textureValue; - - bool operator < (const ShaderNodeEntry& other) const - { - return (textureValue < other.textureValue); - } - }; - - - struct TransparentNodeEntry - { - TransparentNodeEntry() {}; - - TransparentNodeEntry(ISceneNode* n, const core::vector3df &camera) - { - node = n; - - // TODO: this could be optimized, by not using sqrt - distance = (f32)(node->getAbsoluteTransformation().getTranslation().getDistanceFrom(camera)); - } - - ISceneNode* node; - f32 distance; - - bool operator < (const TransparentNodeEntry& other) const - { - return (distance > other.distance); - } - }; - - //! sort on distance (sphere) to camera - struct DistanceNodeEntry - { - DistanceNodeEntry() {}; - - DistanceNodeEntry(ISceneNode* n, f64 d) - { - node = n; - distance = d; - } - - DistanceNodeEntry(ISceneNode* n, const core::vector3df &cameraPos) - { - node = n; - - distance = (node->getAbsoluteTransformation().getTranslation().getDistanceFromSQ(cameraPos)); - distance -= node->getBoundingBox().getExtent().getLengthSQ() / 2.0; - } - - ISceneNode* node; - - f64 distance; - - bool operator < (const DistanceNodeEntry& other) const - { - return distance < other.distance; - } - }; - - //! video driver - video::IVideoDriver* Driver; - - //! file system - io::IFileSystem* FileSystem; - - //! GUI Enviroment ( Debug Purpose ) - gui::IGUIEnvironment* GUIEnvironment; - - //! cursor control - gui::ICursorControl* CursorControl; - - //! collision manager - ISceneCollisionManager* CollisionManager; - - //! mesh manipulator - IMeshManipulator* MeshManipulator; - - //! render pass lists - core::array CameraList; - core::array LightList; - core::array ShadowNodeList; - core::array SkyBoxList; - core::array SolidNodeList; - core::array TransparentNodeList; - core::array ShaderNodeList[ ESNRP_SHADER_10 - ESNRP_SHADER_0 + 1]; - - core::array MeshLoaderList; - core::array DeletionList; - core::array SceneNodeFactoryList; - core::array SceneNodeAnimatorFactoryList; - - //! current active camera - ICameraSceneNode* ActiveCamera; - core::vector3df camWorldPos; // Position of camera for transparent nodes. - - video::SColor ShadowColor; - video::SColorf AmbientLight; - - //! String parameters - io::CAttributes Parameters; - - //! Mesh cache - CMeshCache* MeshCache; - - E_SCENE_NODE_RENDER_PASS CurrentRendertime; - - //! constants for reading and writing XML. - //! Not made static due to portability problems. - const core::stringw IRR_XML_FORMAT_SCENE; - const core::stringw IRR_XML_FORMAT_NODE; - const core::stringw IRR_XML_FORMAT_NODE_ATTR_TYPE; - }; - -} // end namespace video -} // end namespace scene - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_SCENE_MANAGER_H_INCLUDED__ +#define __C_SCENE_MANAGER_H_INCLUDED__ + +#include "ISceneManager.h" +#include "ISceneNode.h" +#include "ICursorControl.h" +#include "irrString.h" +#include "irrArray.h" +#include "IMeshLoader.h" +#include "CAttributes.h" + +namespace irr +{ +namespace io +{ + class IXMLWriter; +} +namespace scene +{ + class CMeshCache; + + /*! + The Scene Manager manages scene nodes, mesh recources, cameras and all the other stuff. + */ + class CSceneManager : public ISceneManager, public ISceneNode + { + public: + + //! constructor + CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, + gui::ICursorControl* cursorControl, CMeshCache* cache = 0, + gui::IGUIEnvironment *guiEnvironment = 0); + + //! destructor + virtual ~CSceneManager(); + + //! gets an animateable mesh. loads it if needed. returned pointer must not be dropped. + virtual IAnimatedMesh* getMesh(const c8* filename); + + //! Returns an interface to the mesh cache which is shared beween all existing scene managers. + virtual IMeshCache* getMeshCache(); + + //! returns the video driver + virtual video::IVideoDriver* getVideoDriver(); + + virtual gui::IGUIEnvironment* getGUIEnvironment(); + + //! adds a cube scene node to the scene. It is a simple cube of (1,1,1) size. + //! the returned pointer must not be dropped. + virtual ISceneNode* addCubeSceneNode(f32 size=10.0f, ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& rotation = core::vector3df(0,0,0), const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); + + //! Adds a sphere scene node for test purposes to the scene. + virtual ISceneNode* addSphereSceneNode(f32 radius=5.0f, s32 polyCount=16, ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); + + //! adds a scene node for rendering an animated mesh model + virtual IAnimatedMeshSceneNode* addAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), + bool alsoAddIfMeshPointerZero=false); + + //! adds a scene node for rendering a static mesh + //! the returned pointer must not be dropped. + virtual IMeshSceneNode* addMeshSceneNode(IMesh* mesh, ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), + bool alsoAddIfMeshPointerZero=false); + + //! Adds a scene node for rendering a animated water surface mesh. + virtual ISceneNode* addWaterSurfaceSceneNode(IMesh* mesh, f32 waveHeight, f32 waveSpeed, f32 wlenght, ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); + + //! renders the node. + virtual void render(); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! registers a node for rendering it at a specific time. + virtual u32 registerNodeForRendering(ISceneNode* node, E_SCENE_NODE_RENDER_PASS = ESNRP_AUTOMATIC); + + //! draws all scene nodes + virtual void drawAll(); + + //! Adds a scene node for rendering using a octtree to the scene graph. This a good method for rendering + //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much + //! faster then a bsp tree. + virtual ISceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, + s32 id=-1, s32 minimalPolysPerNode=128, bool alsoAddIfMeshPointerZero=false); + + //! Adss a scene node for rendering using a octtree. This a good method for rendering + //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much + //! faster then a bsp tree. + virtual ISceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0, + s32 id=-1, s32 minimalPolysPerNode=128, bool alsoAddIfMeshPointerZero=false); + + //! Adds a camera scene node to the tree and sets it as active camera. + //! \param position: Position of the space relative to its parent where the camera will be placed. + //! \param lookat: Position where the camera will look at. Also known as target. + //! \param parent: Parent scene node of the camera. Can be null. If the parent moves, + //! the camera will move too. + //! \return Returns pointer to interface to camera + virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& lookat = core::vector3df(0,0,0), s32 id=-1); + + //! Adds a camera scene node which is able to be controlle with the mouse similar + //! like in the 3D Software Maya by Alias Wavefront. + //! The returned pointer must not be dropped. + virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent = 0, + f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 translationSpeed = 100.0f, s32 id=-1); + + //! Adds a camera scene node which is able to be controled with the mouse and keys + //! like in most first person shooters (FPS): + virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, + f32 rotateSpeed = 1500.0f, f32 moveSpeed = 200.0f, s32 id=-1, + SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false, + f32 jumpSpeed = 0.f); + + //! Adds a dynamic light scene node. The light will cast dynamic light on all + //! other scene nodes in the scene, which have the material flag video::MTF_LIGHTING + //! turned on. (This is the default setting in most scene nodes). + virtual ILightSceneNode* addLightSceneNode(ISceneNode* parent = 0, + const core::vector3df& position = core::vector3df(0,0,0), + video::SColorf color = video::SColorf(1.0f, 1.0f, 1.0f), f32 range=100.0f, s32 id=-1); + + //! Adds a billboard scene node to the scene. A billboard is like a 3d sprite: A 2d element, + //! which always looks to the camera. It is usually used for things like explosions, fire, + //! lensflares and things like that. + virtual IBillboardSceneNode* addBillboardSceneNode(ISceneNode* parent = 0, + const core::dimension2d& size = core::dimension2d(10.0f, 10.0f), + const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, + video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF); + + //! Adds a skybox scene node. A skybox is a big cube with 6 textures on it and + //! is drawn around the camera position. + virtual ISceneNode* addSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, + video::ITexture* left, video::ITexture* right, video::ITexture* front, + video::ITexture* back, ISceneNode* parent = 0, s32 id=-1); + + //! Adds a skydome scene node. A skydome is a large (half-) sphere with a + //! panoramic texture on it and is drawn around the camera position. + virtual ISceneNode* addSkyDomeSceneNode(video::ITexture* texture, + u32 horiRes, u32 vertRes, f64 texturePercentage, + f64 spherePercentage, ISceneNode* parent=0, s32 id=-1); + + //! Adds a text scene node, which is able to display + //! 2d text at a position in three dimensional space + virtual ITextSceneNode* addTextSceneNode(gui::IGUIFont* font, const wchar_t* text, + video::SColor color=video::SColor(100,255,255,255), + ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0), + s32 id=-1); + + //! Adds a text scene node, which uses billboards + virtual ITextSceneNode* addBillboardTextSceneNode(gui::IGUIFont* font, const wchar_t* text, + ISceneNode* parent = 0, + const core::dimension2d& size = core::dimension2d(10.0f, 10.0f), + const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, + video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF); + + //! Adds a scene node, which can render a quake3 shader + virtual ISceneNode* addQuake3SceneNode(IMeshBuffer* meshBuffer, const quake3::SShader * shader, + ISceneNode* parent=0, s32 id=-1 + ); + + + //! Adds a Hill Plane mesh to the mesh pool. The mesh is generated on the fly + //! and looks like a plane with some hills on it. It is uses mostly for quick + //! tests of the engine only. You can specify how many hills there should be + //! on the plane and how high they should be. Also you must specify a name for + //! the mesh, because the mesh is added to the mesh pool, and can be retieved + //! again using ISceneManager::getMesh with the name as parameter. + virtual IAnimatedMesh* addHillPlaneMesh(const c8* name, + const core::dimension2d& tileSize, const core::dimension2d& tileCount, + video::SMaterial* material = 0, f32 hillHeight = 0.0f, + const core::dimension2d& countHills = core::dimension2d(0.0f, 0.0f), + const core::dimension2d& textureRepeatCount = core::dimension2d(1.0f, 1.0f)); + + //! Adds a terrain mesh to the mesh pool. + virtual IAnimatedMesh* addTerrainMesh(const c8* meshname, video::IImage* texture, video::IImage* heightmap, + const core::dimension2d& stretchSize, + f32 maxHeight, const core::dimension2d& defaultVertexBlockSize); + + //! Add a arrow mesh to the mesh pool + virtual IAnimatedMesh* addArrowMesh(const c8* name, u32 tesselationCylinder, u32 tesselationCone, f32 height, + f32 cylinderHeight, f32 width0,f32 width1, + video::SColor vtxColor0, video::SColor vtxColor1); + + //! Adds a particle system scene node. + virtual IParticleSystemSceneNode* addParticleSystemSceneNode( + bool withDefaultEmitter=true, ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); + + //! Adds a terrain scene node to the scene graph. + virtual ITerrainSceneNode* addTerrainSceneNode( + const c8* heightMapFileName, + ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), + const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), + const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), + video::SColor vertexColor = video::SColor(255,255,255,255), + s32 maxLOD=4, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17,s32 smoothFactor=0); + + //! Adds a terrain scene node to the scene graph. + virtual ITerrainSceneNode* addTerrainSceneNode( + io::IReadFile* heightMap, + ISceneNode* parent=0, s32 id=-1, + const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), + const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), + const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), + video::SColor vertexColor = video::SColor(255,255,255,255), + s32 maxLOD=4, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17,s32 smoothFactor=0); + + //! Adds a dummy transformation scene node to the scene graph. + virtual IDummyTransformationSceneNode* addDummyTransformationSceneNode( + ISceneNode* parent=0, s32 id=-1); + + //! Adds an empty scene node. + virtual ISceneNode* addEmptySceneNode(ISceneNode* parent, s32 id=-1); + + //! Returns the root scene node. This is the scene node wich is parent + //! of all scene nodes. The root scene node is a special scene node which + //! only exists to manage all scene nodes. It is not rendered and cannot + //! be removed from the scene. + //! \return Returns a pointer to the root scene node. + virtual ISceneNode* getRootSceneNode(); + + //! Returns the current active camera. + //! \return The active camera is returned. Note that this can be NULL, if there + //! was no camera created yet. + virtual ICameraSceneNode* getActiveCamera(); + + //! Sets the active camera. The previous active camera will be deactivated. + //! \param camera: The new camera which should be active. + virtual void setActiveCamera(ICameraSceneNode* camera); + + //! creates a rotation animator, which rotates the attached scene node around itself. + //! \param rotationPerSecond: Specifies the speed of the animation + //! \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() + //! and the animator will animate it. + virtual ISceneNodeAnimator* createRotationAnimator(const core::vector3df& rotationPerSecond); + + //! creates a fly circle animator, which lets the attached scene node fly + //! around a center. The center is the position of the scene node. + //! \param rotationSpeed: + //! \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() + //! and the animator will animate it. + virtual ISceneNodeAnimator* createFlyCircleAnimator(const core::vector3df& normal, f32 radius, f32 speed, + const core::vector3df& direction); + + //! Creates a fly straight animator, which lets the attached scene node + //! fly or move along a line between two points. + virtual ISceneNodeAnimator* createFlyStraightAnimator(const core::vector3df& startPoint, + const core::vector3df& endPoint, u32 timeForWay, bool loop=false); + + //! Creates a texture animator, which switches the textures of the target scene + //! node based on a list of textures. + virtual ISceneNodeAnimator* createTextureAnimator(const core::array& textures, + s32 timePerFrame, bool loop); + + //! Creates a scene node animator, which deletes the scene node after + //! some time automaticly. + virtual ISceneNodeAnimator* createDeleteAnimator(u32 timeMS); + + + //! Creates a special scene node animator for doing automatic collision detection + //! and response. + virtual ISceneNodeAnimatorCollisionResponse* createCollisionResponseAnimator( + ITriangleSelector* world, ISceneNode* sceneNode, + const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30), + const core::vector3df& gravityPerSecond = core::vector3df(0,-1.0f,0), + const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0), + f32 slidingValue = 0.0005f); + + //! Creates a follow spline animator. + virtual ISceneNodeAnimator* createFollowSplineAnimator(s32 startTime, + const core::array< core::vector3df >& points, + f32 speed = 1.0f, f32 tightness = 0.5f); + + + //! Creates a simple ITriangleSelector, based on a mesh. + virtual ITriangleSelector* createTriangleSelector(IMesh* mesh, ISceneNode* node); + + //! Creates a simple ITriangleSelector, based on a mesh. + virtual ITriangleSelector* createOctTreeTriangleSelector(IMesh* mesh, + ISceneNode* node, s32 minimalPolysPerNode); + + //! Creates a simple dynamic ITriangleSelector, based on a axis aligned bounding box. + virtual ITriangleSelector* createTriangleSelectorFromBoundingBox( + ISceneNode* node); + + //! Creates a meta triangle selector. + virtual IMetaTriangleSelector* createMetaTriangleSelector(); + + //! Creates a triangle selector which can select triangles from a terrain scene node + //! \param: Pointer to the created terrain scene node + //! \param: Level of detail, 0 for highest detail. + virtual ITriangleSelector* createTerrainTriangleSelector( + ITerrainSceneNode* node, s32 LOD=0); + + //! Adds an external mesh loader. + virtual void addExternalMeshLoader(IMeshLoader* externalLoader); + + //! Returns a pointer to the scene collision manager. + virtual ISceneCollisionManager* getSceneCollisionManager(); + + //! Returns a pointer to the mesh manipulator. + virtual IMeshManipulator* getMeshManipulator(); + + //! Sets the color of stencil buffers shadows drawn by the scene manager. + virtual void setShadowColor(video::SColor color); + + //! Returns the current color of shadows. + virtual video::SColor getShadowColor() const; + + //! Adds a scene node to the deletion queue. + virtual void addToDeletionQueue(ISceneNode* node); + + //! Returns the first scene node with the specified id. + virtual ISceneNode* getSceneNodeFromId(s32 id, ISceneNode* start=0); + + //! Returns the first scene node with the specified name. + virtual ISceneNode* getSceneNodeFromName(const c8* name, ISceneNode* start=0); + + //! Posts an input event to the environment. Usually you do not have to + //! use this method, it is used by the internal engine. + virtual bool postEventFromUser(SEvent event); + + //! Clears the whole scene. All scene nodes are removed. + virtual void clear(); + + //! Removes all children of this scene node + virtual void removeAll(); + + //! Returns interface to the parameters set in this scene. + virtual io::IAttributes* getParameters(); + + //! Returns current render pass. + virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass(); + + //! Creates a new scene manager. + virtual ISceneManager* createNewSceneManager(); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_UNKNOWN; } + + //! Returns the default scene node factory which can create all built in scene nodes + virtual ISceneNodeFactory* getDefaultSceneNodeFactory(); + + //! Adds a scene node factory to the scene manager. + /** Use this to extend the scene manager with new scene node types which it should be + able to create automaticly, for example when loading data from xml files. */ + virtual void registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd); + + //! Returns amount of registered scene node factories. + virtual s32 getRegisteredSceneNodeFactoryCount(); + + //! Returns a scene node factory by index + virtual ISceneNodeFactory* getSceneNodeFactory(s32 index); + + //! Returns a typename from a scene node type or null if not found + virtual const c8* getSceneNodeTypeName(ESCENE_NODE_TYPE type); + + //! Returns the default scene node animator factory which can create all built-in scene node animators + virtual ISceneNodeAnimatorFactory* getDefaultSceneNodeAnimatorFactory(); + + //! Adds a scene node animator factory to the scene manager. + virtual void registerSceneNodeAnimatorFactory(ISceneNodeAnimatorFactory* factoryToAdd); + + //! Returns amount of registered scene node animator factories. + virtual s32 getRegisteredSceneNodeAnimatorFactoryCount(); + + //! Returns a scene node animator factory by index + virtual ISceneNodeAnimatorFactory* getSceneNodeAnimatorFactory(s32 index); + + //! Saves the current scene into a file. + //! \param filename: Name of the file . + virtual bool saveScene(const c8* filename, ISceneUserDataSerializer* userDataSerializer=0); + + //! Saves the current scene into a file. + virtual bool saveScene(io::IWriteFile* file, ISceneUserDataSerializer* userDataSerializer=0); + + //! Loads a scene. Note that the current scene is not cleared before. + //! \param filename: Name of the file . + virtual bool loadScene(const c8* filename, ISceneUserDataSerializer* userDataSerializer=0); + + //! Loads a scene. Note that the current scene is not cleared before. + virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0); + + //! Writes attributes of the scene node. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + //! Sets ambient color of the scene + virtual void setAmbientLight(const video::SColorf &ambientColor); + + //! Returns ambient color of the scene + virtual video::SColorf getAmbientLight(); + + private: + + //! Returns a typename from a scene node animator type or null if not found + virtual const c8* getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type); + + //! returns if node is culled + bool isCulled(ISceneNode* node); + + //! clears the deletion list + void clearDeletionList(); + + //! writes a scene node + void writeSceneNode(io::IXMLWriter* writer, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer); + + //! reads a scene node + void readSceneNode(io::IXMLReader* reader, ISceneNode* parent, ISceneUserDataSerializer* userDataSerializer); + + //! read materials + void readMaterials(io::IXMLReader* reader, ISceneNode* node); + + //! reads animators of a node + void readAnimators(io::IXMLReader* reader, ISceneNode* node); + + //! reads user data of a node + void readUserData(io::IXMLReader* reader, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer); + + struct DefaultNodeEntry + { + DefaultNodeEntry() {}; + + DefaultNodeEntry(ISceneNode* n) + { + textureValue = 0; + + if (n->getMaterialCount()) + textureValue = (n->getMaterial(0).Textures[0]); + + node = n; + } + + ISceneNode* node; + void* textureValue; + + bool operator < (const DefaultNodeEntry& other) const + { + return (textureValue < other.textureValue); + } + }; + + struct ShaderNodeEntry + { + ShaderNodeEntry() {}; + + ShaderNodeEntry(ISceneNode* n, u32 sceneTime ) + { + textureValue = n->getMaterial( sceneTime ).Textures[0]; + + node = n; + } + + ISceneNode* node; + void* textureValue; + + bool operator < (const ShaderNodeEntry& other) const + { + return (textureValue < other.textureValue); + } + }; + + + struct TransparentNodeEntry + { + TransparentNodeEntry() {}; + + TransparentNodeEntry(ISceneNode* n, const core::vector3df &camera) + { + node = n; + + // TODO: this could be optimized, by not using sqrt + distance = (f32)(node->getAbsoluteTransformation().getTranslation().getDistanceFrom(camera)); + } + + ISceneNode* node; + f32 distance; + + bool operator < (const TransparentNodeEntry& other) const + { + return (distance > other.distance); + } + }; + + //! sort on distance (sphere) to camera + struct DistanceNodeEntry + { + DistanceNodeEntry() {}; + + DistanceNodeEntry(ISceneNode* n, f64 d) + { + node = n; + distance = d; + } + + DistanceNodeEntry(ISceneNode* n, const core::vector3df &cameraPos) + { + node = n; + + distance = (node->getAbsoluteTransformation().getTranslation().getDistanceFromSQ(cameraPos)); + distance -= node->getBoundingBox().getExtent().getLengthSQ() / 2.0; + } + + ISceneNode* node; + + f64 distance; + + bool operator < (const DistanceNodeEntry& other) const + { + return distance < other.distance; + } + }; + + //! video driver + video::IVideoDriver* Driver; + + //! file system + io::IFileSystem* FileSystem; + + //! GUI Enviroment ( Debug Purpose ) + gui::IGUIEnvironment* GUIEnvironment; + + //! cursor control + gui::ICursorControl* CursorControl; + + //! collision manager + ISceneCollisionManager* CollisionManager; + + //! mesh manipulator + IMeshManipulator* MeshManipulator; + + //! render pass lists + core::array CameraList; + core::array LightList; + core::array ShadowNodeList; + core::array SkyBoxList; + core::array SolidNodeList; + core::array TransparentNodeList; + core::array ShaderNodeList[ ESNRP_SHADER_10 - ESNRP_SHADER_0 + 1]; + + core::array MeshLoaderList; + core::array DeletionList; + core::array SceneNodeFactoryList; + core::array SceneNodeAnimatorFactoryList; + + //! current active camera + ICameraSceneNode* ActiveCamera; + core::vector3df camWorldPos; // Position of camera for transparent nodes. + + video::SColor ShadowColor; + video::SColorf AmbientLight; + + //! String parameters + io::CAttributes Parameters; + + //! Mesh cache + CMeshCache* MeshCache; + + E_SCENE_NODE_RENDER_PASS CurrentRendertime; + + //! constants for reading and writing XML. + //! Not made static due to portability problems. + const core::stringw IRR_XML_FORMAT_SCENE; + const core::stringw IRR_XML_FORMAT_NODE; + const core::stringw IRR_XML_FORMAT_NODE_ATTR_TYPE; + }; + +} // end namespace video +} // end namespace scene + +#endif + diff --git a/src/dep/src/irrlicht/CSceneNodeAnimatorCollisionResponse.cpp b/src/dep/src/irrlicht/CSceneNodeAnimatorCollisionResponse.cpp index 4c1f410..f332f7d 100644 --- a/src/dep/src/irrlicht/CSceneNodeAnimatorCollisionResponse.cpp +++ b/src/dep/src/irrlicht/CSceneNodeAnimatorCollisionResponse.cpp @@ -1,211 +1,211 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorCollisionResponse.h" -#include "ISceneCollisionManager.h" -#include "ISceneManager.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CSceneNodeAnimatorCollisionResponse::CSceneNodeAnimatorCollisionResponse( - ISceneManager* scenemanager, - ITriangleSelector* world, ISceneNode* object, - const core::vector3df& ellipsoidRadius, - const core::vector3df& gravityPerSecond, - const core::vector3df& ellipsoidTranslation, - f32 slidingSpeed) -: Radius(ellipsoidRadius), Gravity(gravityPerSecond / 1000.0f), Translation(ellipsoidTranslation), - World(world), Object(object), SceneManager(scenemanager), - SlidingSpeed(slidingSpeed), Falling(false) -{ - if (World) - World->grab(); - - if (Object) - LastPosition = Object->getPosition(); - - LastTime = os::Timer::getTime(); - FallStartTime = LastTime; -} - - - -//! destructor -CSceneNodeAnimatorCollisionResponse::~CSceneNodeAnimatorCollisionResponse() -{ - if (World) - World->drop(); -} - - -//! Returns if the attached scene node is falling, which means that -//! there is no blocking wall from the scene node in the direction of -//! the gravity. -bool CSceneNodeAnimatorCollisionResponse::isFalling() -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Falling; -} - - -//! Sets the radius of the ellipsoid with which collision detection and -//! response is done. -void CSceneNodeAnimatorCollisionResponse::setEllipsoidRadius( - const core::vector3df& radius) -{ - Radius = radius; -} - -//! Returns the radius of the ellipsoid with wich the collision detection and -//! response is done. -core::vector3df CSceneNodeAnimatorCollisionResponse::getEllipsoidRadius() const -{ - return Radius; -} - - -//! Sets the gravity of the environment. -void CSceneNodeAnimatorCollisionResponse::setGravity(const core::vector3df& gravity) -{ - Gravity = gravity; -} - - -//! Returns current vector of gravity. -core::vector3df CSceneNodeAnimatorCollisionResponse::getGravity() const -{ - return Gravity; -} - - -//! Sets the translation of the ellipsoid for collision detection. -void CSceneNodeAnimatorCollisionResponse::setEllipsoidTranslation(const core::vector3df &translation) -{ - Translation = translation; -} - - - -//! Returns the translation of the ellipsoid for collision detection. -core::vector3df CSceneNodeAnimatorCollisionResponse::getEllipsoidTranslation() const -{ - return Translation; -} - - -//! Sets a triangle selector holding all triangles of the world with which -//! the scene node may collide. -void CSceneNodeAnimatorCollisionResponse::setWorld(ITriangleSelector* newWorld) -{ - Falling = false; - - LastTime = os::Timer::getTime(); - FallStartTime = LastTime; - - - if (World) - World->drop(); - - World = newWorld; - if (World) - World->grab(); - -} - - - -//! Returns the current triangle selector containing all triangles for -//! collision detection. -ITriangleSelector* CSceneNodeAnimatorCollisionResponse::getWorld() const -{ - return World; -} - - - -void CSceneNodeAnimatorCollisionResponse::animateNode(ISceneNode* node, u32 timeMs) -{ - if (node != Object) - { - os::Printer::log("CollisionResponseAnimator only works with same scene node as set as object during creation", ELL_ERROR); - return; - } - - if (!World) - return; - - u32 diff = timeMs - LastTime; - LastTime = timeMs; - - core::vector3df pos = Object->getPosition(); - core::vector3df vel = pos - LastPosition; - - //g = Gravity * (f32)((timeMs - FallStartTime) * diff); - - f32 dt = 1.f; - if (Falling) - { - dt = f32 ( ( timeMs - FallStartTime ) * diff ); - } - core::vector3df g = Gravity * dt; - - core::triangle3df triangle = RefTriangle; - - core::vector3df force = vel + g; - - const core::vector3df nullVector ( 0.f, 0.f, 0.f ); - - if ( force != nullVector ) - { - // TODO: divide SlidingSpeed by frame time - - bool f = false; - pos = SceneManager->getSceneCollisionManager()->getCollisionResultPosition( - World, LastPosition-Translation, - Radius, vel, triangle, f, SlidingSpeed, g); - - pos += Translation; - - if (f)//triangle == RefTriangle) - { - if (!Falling) - FallStartTime = timeMs; - - Falling = true; - } - else - Falling = false; - - Object->setPosition(pos); - } - - LastPosition = Object->getPosition(); -} - -//! Writes attributes of the scene node animator. -void CSceneNodeAnimatorCollisionResponse::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - out->addVector3d("Radius", Radius); - out->addVector3d("Gravity", Gravity); - out->addVector3d("Translation", Translation); -} - -//! Reads attributes of the scene node animator. -void CSceneNodeAnimatorCollisionResponse::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Radius = in->getAttributeAsVector3d("Radius"); - Gravity = in->getAttributeAsVector3d("Gravity"); - Translation = in->getAttributeAsVector3d("Translation"); -} - - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSceneNodeAnimatorCollisionResponse.h" +#include "ISceneCollisionManager.h" +#include "ISceneManager.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CSceneNodeAnimatorCollisionResponse::CSceneNodeAnimatorCollisionResponse( + ISceneManager* scenemanager, + ITriangleSelector* world, ISceneNode* object, + const core::vector3df& ellipsoidRadius, + const core::vector3df& gravityPerSecond, + const core::vector3df& ellipsoidTranslation, + f32 slidingSpeed) +: Radius(ellipsoidRadius), Gravity(gravityPerSecond / 1000.0f), Translation(ellipsoidTranslation), + World(world), Object(object), SceneManager(scenemanager), + SlidingSpeed(slidingSpeed), Falling(false) +{ + if (World) + World->grab(); + + if (Object) + LastPosition = Object->getPosition(); + + LastTime = os::Timer::getTime(); + FallStartTime = LastTime; +} + + + +//! destructor +CSceneNodeAnimatorCollisionResponse::~CSceneNodeAnimatorCollisionResponse() +{ + if (World) + World->drop(); +} + + +//! Returns if the attached scene node is falling, which means that +//! there is no blocking wall from the scene node in the direction of +//! the gravity. +bool CSceneNodeAnimatorCollisionResponse::isFalling() +{ + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return Falling; +} + + +//! Sets the radius of the ellipsoid with which collision detection and +//! response is done. +void CSceneNodeAnimatorCollisionResponse::setEllipsoidRadius( + const core::vector3df& radius) +{ + Radius = radius; +} + +//! Returns the radius of the ellipsoid with wich the collision detection and +//! response is done. +core::vector3df CSceneNodeAnimatorCollisionResponse::getEllipsoidRadius() const +{ + return Radius; +} + + +//! Sets the gravity of the environment. +void CSceneNodeAnimatorCollisionResponse::setGravity(const core::vector3df& gravity) +{ + Gravity = gravity; +} + + +//! Returns current vector of gravity. +core::vector3df CSceneNodeAnimatorCollisionResponse::getGravity() const +{ + return Gravity; +} + + +//! Sets the translation of the ellipsoid for collision detection. +void CSceneNodeAnimatorCollisionResponse::setEllipsoidTranslation(const core::vector3df &translation) +{ + Translation = translation; +} + + + +//! Returns the translation of the ellipsoid for collision detection. +core::vector3df CSceneNodeAnimatorCollisionResponse::getEllipsoidTranslation() const +{ + return Translation; +} + + +//! Sets a triangle selector holding all triangles of the world with which +//! the scene node may collide. +void CSceneNodeAnimatorCollisionResponse::setWorld(ITriangleSelector* newWorld) +{ + Falling = false; + + LastTime = os::Timer::getTime(); + FallStartTime = LastTime; + + + if (World) + World->drop(); + + World = newWorld; + if (World) + World->grab(); + +} + + + +//! Returns the current triangle selector containing all triangles for +//! collision detection. +ITriangleSelector* CSceneNodeAnimatorCollisionResponse::getWorld() const +{ + return World; +} + + + +void CSceneNodeAnimatorCollisionResponse::animateNode(ISceneNode* node, u32 timeMs) +{ + if (node != Object) + { + os::Printer::log("CollisionResponseAnimator only works with same scene node as set as object during creation", ELL_ERROR); + return; + } + + if (!World) + return; + + u32 diff = timeMs - LastTime; + LastTime = timeMs; + + core::vector3df pos = Object->getPosition(); + core::vector3df vel = pos - LastPosition; + + //g = Gravity * (f32)((timeMs - FallStartTime) * diff); + + f32 dt = 1.f; + if (Falling) + { + dt = f32 ( ( timeMs - FallStartTime ) * diff ); + } + core::vector3df g = Gravity * dt; + + core::triangle3df triangle = RefTriangle; + + core::vector3df force = vel + g; + + const core::vector3df nullVector ( 0.f, 0.f, 0.f ); + + if ( force != nullVector ) + { + // TODO: divide SlidingSpeed by frame time + + bool f = false; + pos = SceneManager->getSceneCollisionManager()->getCollisionResultPosition( + World, LastPosition-Translation, + Radius, vel, triangle, f, SlidingSpeed, g); + + pos += Translation; + + if (f)//triangle == RefTriangle) + { + if (!Falling) + FallStartTime = timeMs; + + Falling = true; + } + else + Falling = false; + + Object->setPosition(pos); + } + + LastPosition = Object->getPosition(); +} + +//! Writes attributes of the scene node animator. +void CSceneNodeAnimatorCollisionResponse::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + out->addVector3d("Radius", Radius); + out->addVector3d("Gravity", Gravity); + out->addVector3d("Translation", Translation); +} + +//! Reads attributes of the scene node animator. +void CSceneNodeAnimatorCollisionResponse::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + Radius = in->getAttributeAsVector3d("Radius"); + Gravity = in->getAttributeAsVector3d("Gravity"); + Translation = in->getAttributeAsVector3d("Translation"); +} + + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CSceneNodeAnimatorCollisionResponse.h b/src/dep/src/irrlicht/CSceneNodeAnimatorCollisionResponse.h index 4ffc754..99e91bf 100644 --- a/src/dep/src/irrlicht/CSceneNodeAnimatorCollisionResponse.h +++ b/src/dep/src/irrlicht/CSceneNodeAnimatorCollisionResponse.h @@ -1,104 +1,104 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ - -#include "ISceneNodeAnimatorCollisionResponse.h" - -namespace irr -{ -namespace scene -{ - - //! Special scene node animator for doing automatic collision detection and response. - /** This scene node animator can be attached to any scene node modifying it in that - way, that it cannot move through walls of the world, is influenced by gravity and - acceleration. This animator is useful for example for first person shooter - games. Attach it for example to a first person shooter camera, and the camera will - behave as the player control in a first person shooter game: The camera stops and - slides at walls, walks up stairs, falls down if there is no floor under it, and so on. - */ - class CSceneNodeAnimatorCollisionResponse : public ISceneNodeAnimatorCollisionResponse - { - public: - - //! constructor - CSceneNodeAnimatorCollisionResponse(ISceneManager* scenemanager, - ITriangleSelector* world, ISceneNode* object, - const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30), - const core::vector3df& gravityPerSecond = core::vector3df(0,-100.0f,0), - const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0), - f32 slidingSpeed = 0.0005f); - - //! destructor - virtual ~CSceneNodeAnimatorCollisionResponse(); - - //! Returns if the attached scene node is falling, which means that - //! there is no blocking wall from the scene node in the direction of - //! the gravity. - virtual bool isFalling(); - - //! Sets the radius of the ellipsoid with which collision detection and - //! response is done. - virtual void setEllipsoidRadius(const core::vector3df& radius); - - //! Returns the radius of the ellipsoid with wich the collision detection and - //! response is done. - virtual core::vector3df getEllipsoidRadius() const; - - //! Sets the gravity of the environment. - virtual void setGravity(const core::vector3df& gravity); - - //! Returns current vector of gravity. - virtual core::vector3df getGravity() const; - - //! Sets the translation of the ellipsoid for collision detection. - virtual void setEllipsoidTranslation(const core::vector3df &translation); - - //! Returns the translation of the ellipsoid for collision detection. - virtual core::vector3df getEllipsoidTranslation() const; - - //! Sets a triangle selector holding all triangles of the world with which - //! the scene node may collide. - virtual void setWorld(ITriangleSelector* newWorld); - - //! Returns the current triangle selector containing all triangles for - //! collision detection. - virtual ITriangleSelector* getWorld() const; - - //! animates a scene node - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Writes attributes of the scene node animator. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node animator. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() { return ESNAT_COLLISION_RESPONSE; } - - private: - core::vector3df LastPosition; - core::vector3df Radius; - core::vector3df Gravity; - core::vector3df Translation; - - ITriangleSelector* World; - ISceneNode* Object; - ISceneManager* SceneManager; - u32 LastTime; - u32 FallStartTime; - f32 SlidingSpeed; - bool Falling; - - core::triangle3df RefTriangle; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ +#define __C_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ + +#include "ISceneNodeAnimatorCollisionResponse.h" + +namespace irr +{ +namespace scene +{ + + //! Special scene node animator for doing automatic collision detection and response. + /** This scene node animator can be attached to any scene node modifying it in that + way, that it cannot move through walls of the world, is influenced by gravity and + acceleration. This animator is useful for example for first person shooter + games. Attach it for example to a first person shooter camera, and the camera will + behave as the player control in a first person shooter game: The camera stops and + slides at walls, walks up stairs, falls down if there is no floor under it, and so on. + */ + class CSceneNodeAnimatorCollisionResponse : public ISceneNodeAnimatorCollisionResponse + { + public: + + //! constructor + CSceneNodeAnimatorCollisionResponse(ISceneManager* scenemanager, + ITriangleSelector* world, ISceneNode* object, + const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30), + const core::vector3df& gravityPerSecond = core::vector3df(0,-100.0f,0), + const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0), + f32 slidingSpeed = 0.0005f); + + //! destructor + virtual ~CSceneNodeAnimatorCollisionResponse(); + + //! Returns if the attached scene node is falling, which means that + //! there is no blocking wall from the scene node in the direction of + //! the gravity. + virtual bool isFalling(); + + //! Sets the radius of the ellipsoid with which collision detection and + //! response is done. + virtual void setEllipsoidRadius(const core::vector3df& radius); + + //! Returns the radius of the ellipsoid with wich the collision detection and + //! response is done. + virtual core::vector3df getEllipsoidRadius() const; + + //! Sets the gravity of the environment. + virtual void setGravity(const core::vector3df& gravity); + + //! Returns current vector of gravity. + virtual core::vector3df getGravity() const; + + //! Sets the translation of the ellipsoid for collision detection. + virtual void setEllipsoidTranslation(const core::vector3df &translation); + + //! Returns the translation of the ellipsoid for collision detection. + virtual core::vector3df getEllipsoidTranslation() const; + + //! Sets a triangle selector holding all triangles of the world with which + //! the scene node may collide. + virtual void setWorld(ITriangleSelector* newWorld); + + //! Returns the current triangle selector containing all triangles for + //! collision detection. + virtual ITriangleSelector* getWorld() const; + + //! animates a scene node + virtual void animateNode(ISceneNode* node, u32 timeMs); + + //! Writes attributes of the scene node animator. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node animator. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + //! Returns type of the scene node animator + virtual ESCENE_NODE_ANIMATOR_TYPE getType() { return ESNAT_COLLISION_RESPONSE; } + + private: + core::vector3df LastPosition; + core::vector3df Radius; + core::vector3df Gravity; + core::vector3df Translation; + + ITriangleSelector* World; + ISceneNode* Object; + ISceneManager* SceneManager; + u32 LastTime; + u32 FallStartTime; + f32 SlidingSpeed; + bool Falling; + + core::triangle3df RefTriangle; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CSceneNodeAnimatorDelete.cpp b/src/dep/src/irrlicht/CSceneNodeAnimatorDelete.cpp index cffbdf3..8026e2b 100644 --- a/src/dep/src/irrlicht/CSceneNodeAnimatorDelete.cpp +++ b/src/dep/src/irrlicht/CSceneNodeAnimatorDelete.cpp @@ -1,46 +1,46 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorDelete.h" -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CSceneNodeAnimatorDelete::CSceneNodeAnimatorDelete(ISceneManager* manager, u32 time) -: DeleteTime(time), SceneManager(manager) -{ - #ifdef _DEBUG - setDebugName("CSceneNodeAnimatorDelete"); - #endif -} - - - -//! destructor -CSceneNodeAnimatorDelete::~CSceneNodeAnimatorDelete() -{ -} - - - -//! animates a scene node -void CSceneNodeAnimatorDelete::animateNode(ISceneNode* node, u32 timeMs) -{ - if (timeMs > DeleteTime && node && SceneManager) - { - // don't delete if scene manager is attached to an editor - if (!SceneManager->getParameters()->getAttributeAsBool(IRR_SCENE_MANAGER_IS_EDITOR)) - SceneManager->addToDeletionQueue(node); - } -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSceneNodeAnimatorDelete.h" +#include "ISceneManager.h" + +namespace irr +{ +namespace scene +{ + + +//! constructor +CSceneNodeAnimatorDelete::CSceneNodeAnimatorDelete(ISceneManager* manager, u32 time) +: DeleteTime(time), SceneManager(manager) +{ + #ifdef _DEBUG + setDebugName("CSceneNodeAnimatorDelete"); + #endif +} + + + +//! destructor +CSceneNodeAnimatorDelete::~CSceneNodeAnimatorDelete() +{ +} + + + +//! animates a scene node +void CSceneNodeAnimatorDelete::animateNode(ISceneNode* node, u32 timeMs) +{ + if (timeMs > DeleteTime && node && SceneManager) + { + // don't delete if scene manager is attached to an editor + if (!SceneManager->getParameters()->getAttributeAsBool(IRR_SCENE_MANAGER_IS_EDITOR)) + SceneManager->addToDeletionQueue(node); + } +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CSceneNodeAnimatorDelete.h b/src/dep/src/irrlicht/CSceneNodeAnimatorDelete.h index d580188..46f8500 100644 --- a/src/dep/src/irrlicht/CSceneNodeAnimatorDelete.h +++ b/src/dep/src/irrlicht/CSceneNodeAnimatorDelete.h @@ -1,44 +1,44 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_DELETE_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_DELETE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - class CSceneNodeAnimatorDelete : public ISceneNodeAnimator - { - public: - - //! constructor - CSceneNodeAnimatorDelete(ISceneManager* manager, u32 when); - - //! destructor - virtual ~CSceneNodeAnimatorDelete(); - - //! animates a scene node - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() - { - return ESNAT_DELETION; - } - - private: - - u32 DeleteTime; - ISceneManager* SceneManager; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_SCENE_NODE_ANIMATOR_DELETE_H_INCLUDED__ +#define __C_SCENE_NODE_ANIMATOR_DELETE_H_INCLUDED__ + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + class CSceneNodeAnimatorDelete : public ISceneNodeAnimator + { + public: + + //! constructor + CSceneNodeAnimatorDelete(ISceneManager* manager, u32 when); + + //! destructor + virtual ~CSceneNodeAnimatorDelete(); + + //! animates a scene node + virtual void animateNode(ISceneNode* node, u32 timeMs); + + //! Returns type of the scene node animator + virtual ESCENE_NODE_ANIMATOR_TYPE getType() + { + return ESNAT_DELETION; + } + + private: + + u32 DeleteTime; + ISceneManager* SceneManager; + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CSceneNodeAnimatorFlyCircle.cpp b/src/dep/src/irrlicht/CSceneNodeAnimatorFlyCircle.cpp index 4921ede..b11749a 100644 --- a/src/dep/src/irrlicht/CSceneNodeAnimatorFlyCircle.cpp +++ b/src/dep/src/irrlicht/CSceneNodeAnimatorFlyCircle.cpp @@ -1,74 +1,74 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorFlyCircle.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CSceneNodeAnimatorFlyCircle::CSceneNodeAnimatorFlyCircle(u32 time, const core::vector3df& center, f32 radius, f32 speed, const core::vector3df& direction) -: Center(center), Direction(direction), Radius(radius), Speed(speed), StartTime(time) -{ - #ifdef _DEBUG - setDebugName("CSceneNodeAnimatorFlyCircle"); - #endif - Direction.normalize(); -} - - - -//! destructor -CSceneNodeAnimatorFlyCircle::~CSceneNodeAnimatorFlyCircle() -{ -} - - - -//! animates a scene node -void CSceneNodeAnimatorFlyCircle::animateNode(ISceneNode* node, u32 timeMs) -{ - if ( 0 == node ) - return; - - const f32 t = (timeMs-StartTime) * Speed; - - core::vector3df circle(Radius * sinf(t), 0, Radius * cosf(t)); - circle = circle.crossProduct ( Direction ); - - node->setPosition(Center + circle); -} - - -//! Writes attributes of the scene node animator. -void CSceneNodeAnimatorFlyCircle::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - out->addVector3d("Center", Center); - out->addFloat("Radius", Radius); - out->addFloat("Speed", Speed); - out->addVector3d("Direction", Direction); -} - - -//! Reads attributes of the scene node animator. -void CSceneNodeAnimatorFlyCircle::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Center = in->getAttributeAsVector3d("Center"); - Radius = in->getAttributeAsFloat("Radius"); - Speed = in->getAttributeAsFloat("Speed"); - Direction = in->getAttributeAsVector3d("Direction"); - - if (Direction.equals(core::vector3df(0,0,0))) - Direction.set(0,1,0); // irrlicht 1.1 backwards compatibility - else - Direction.normalize(); -} - - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSceneNodeAnimatorFlyCircle.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CSceneNodeAnimatorFlyCircle::CSceneNodeAnimatorFlyCircle(u32 time, const core::vector3df& center, f32 radius, f32 speed, const core::vector3df& direction) +: Center(center), Direction(direction), Radius(radius), Speed(speed), StartTime(time) +{ + #ifdef _DEBUG + setDebugName("CSceneNodeAnimatorFlyCircle"); + #endif + Direction.normalize(); +} + + + +//! destructor +CSceneNodeAnimatorFlyCircle::~CSceneNodeAnimatorFlyCircle() +{ +} + + + +//! animates a scene node +void CSceneNodeAnimatorFlyCircle::animateNode(ISceneNode* node, u32 timeMs) +{ + if ( 0 == node ) + return; + + const f32 t = (timeMs-StartTime) * Speed; + + core::vector3df circle(Radius * sinf(t), 0, Radius * cosf(t)); + circle = circle.crossProduct ( Direction ); + + node->setPosition(Center + circle); +} + + +//! Writes attributes of the scene node animator. +void CSceneNodeAnimatorFlyCircle::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + out->addVector3d("Center", Center); + out->addFloat("Radius", Radius); + out->addFloat("Speed", Speed); + out->addVector3d("Direction", Direction); +} + + +//! Reads attributes of the scene node animator. +void CSceneNodeAnimatorFlyCircle::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + Center = in->getAttributeAsVector3d("Center"); + Radius = in->getAttributeAsFloat("Radius"); + Speed = in->getAttributeAsFloat("Speed"); + Direction = in->getAttributeAsVector3d("Direction"); + + if (Direction.equals(core::vector3df(0,0,0))) + Direction.set(0,1,0); // irrlicht 1.1 backwards compatibility + else + Direction.normalize(); +} + + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CSceneNodeAnimatorFlyCircle.h b/src/dep/src/irrlicht/CSceneNodeAnimatorFlyCircle.h index b565452..9c1c9f8 100644 --- a/src/dep/src/irrlicht/CSceneNodeAnimatorFlyCircle.h +++ b/src/dep/src/irrlicht/CSceneNodeAnimatorFlyCircle.h @@ -1,51 +1,51 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_FLY_CIRCLE_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_FLY_CIRCLE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - class CSceneNodeAnimatorFlyCircle : public ISceneNodeAnimator - { - public: - - //! constructor - CSceneNodeAnimatorFlyCircle(u32 time, const core::vector3df& center, f32 radius, f32 speed, - const core::vector3df& direction); - - //! destructor - virtual ~CSceneNodeAnimatorFlyCircle(); - - //! animates a scene node - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Writes attributes of the scene node animator. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node animator. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() { return ESNAT_FLY_CIRCLE; } - - private: - - core::vector3df Center; - core::vector3df Direction; - f32 Radius; - f32 Speed; - u32 StartTime; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_SCENE_NODE_ANIMATOR_FLY_CIRCLE_H_INCLUDED__ +#define __C_SCENE_NODE_ANIMATOR_FLY_CIRCLE_H_INCLUDED__ + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + class CSceneNodeAnimatorFlyCircle : public ISceneNodeAnimator + { + public: + + //! constructor + CSceneNodeAnimatorFlyCircle(u32 time, const core::vector3df& center, f32 radius, f32 speed, + const core::vector3df& direction); + + //! destructor + virtual ~CSceneNodeAnimatorFlyCircle(); + + //! animates a scene node + virtual void animateNode(ISceneNode* node, u32 timeMs); + + //! Writes attributes of the scene node animator. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node animator. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + //! Returns type of the scene node animator + virtual ESCENE_NODE_ANIMATOR_TYPE getType() { return ESNAT_FLY_CIRCLE; } + + private: + + core::vector3df Center; + core::vector3df Direction; + f32 Radius; + f32 Speed; + u32 StartTime; + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CSceneNodeAnimatorFlyStraight.cpp b/src/dep/src/irrlicht/CSceneNodeAnimatorFlyStraight.cpp index 9e2289e..fb5db31 100644 --- a/src/dep/src/irrlicht/CSceneNodeAnimatorFlyStraight.cpp +++ b/src/dep/src/irrlicht/CSceneNodeAnimatorFlyStraight.cpp @@ -1,87 +1,87 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorFlyStraight.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CSceneNodeAnimatorFlyStraight::CSceneNodeAnimatorFlyStraight(const core::vector3df& startPoint, - const core::vector3df& endPoint, u32 timeForWay, - bool loop, u32 now) -: Start(startPoint), End(endPoint), WayLength(0.0f), TimeFactor(0.0f), StartTime(now), TimeForWay(timeForWay), Loop(loop) -{ - #ifdef _DEBUG - setDebugName("CSceneNodeAnimatorFlyStraight"); - #endif - - recalculateImidiateValues(); -} - - -void CSceneNodeAnimatorFlyStraight::recalculateImidiateValues() -{ - Vector = End - Start; - WayLength = (f32)Vector.getLength(); - Vector.normalize(); - - TimeFactor = WayLength / TimeForWay; -} - - - -//! destructor -CSceneNodeAnimatorFlyStraight::~CSceneNodeAnimatorFlyStraight() -{ -} - - - -//! animates a scene node -void CSceneNodeAnimatorFlyStraight::animateNode(ISceneNode* node, u32 timeMs) -{ - if (!node) - return; - - u32 t = (timeMs-StartTime); - - core::vector3df pos = Start; - - if (!Loop && t >= TimeForWay) - pos = End; - else - pos += Vector * (f32)fmod((f32)t, (f32)TimeForWay) * TimeFactor; - node->setPosition(pos); -} - - -//! Writes attributes of the scene node animator. -void CSceneNodeAnimatorFlyStraight::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - out->addVector3d("Start", Start); - out->addVector3d("End", End); - out->addInt("TimeForWay", TimeForWay); - out->addBool("Loop", Loop); -} - - -//! Reads attributes of the scene node animator. -void CSceneNodeAnimatorFlyStraight::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Start = in->getAttributeAsVector3d("Start"); - End = in->getAttributeAsVector3d("End"); - TimeForWay = in->getAttributeAsInt("TimeForWay"); - Loop = in->getAttributeAsBool("Loop"); - - recalculateImidiateValues(); -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSceneNodeAnimatorFlyStraight.h" + +namespace irr +{ +namespace scene +{ + + +//! constructor +CSceneNodeAnimatorFlyStraight::CSceneNodeAnimatorFlyStraight(const core::vector3df& startPoint, + const core::vector3df& endPoint, u32 timeForWay, + bool loop, u32 now) +: Start(startPoint), End(endPoint), WayLength(0.0f), TimeFactor(0.0f), StartTime(now), TimeForWay(timeForWay), Loop(loop) +{ + #ifdef _DEBUG + setDebugName("CSceneNodeAnimatorFlyStraight"); + #endif + + recalculateImidiateValues(); +} + + +void CSceneNodeAnimatorFlyStraight::recalculateImidiateValues() +{ + Vector = End - Start; + WayLength = (f32)Vector.getLength(); + Vector.normalize(); + + TimeFactor = WayLength / TimeForWay; +} + + + +//! destructor +CSceneNodeAnimatorFlyStraight::~CSceneNodeAnimatorFlyStraight() +{ +} + + + +//! animates a scene node +void CSceneNodeAnimatorFlyStraight::animateNode(ISceneNode* node, u32 timeMs) +{ + if (!node) + return; + + u32 t = (timeMs-StartTime); + + core::vector3df pos = Start; + + if (!Loop && t >= TimeForWay) + pos = End; + else + pos += Vector * (f32)fmod((f32)t, (f32)TimeForWay) * TimeFactor; + node->setPosition(pos); +} + + +//! Writes attributes of the scene node animator. +void CSceneNodeAnimatorFlyStraight::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + out->addVector3d("Start", Start); + out->addVector3d("End", End); + out->addInt("TimeForWay", TimeForWay); + out->addBool("Loop", Loop); +} + + +//! Reads attributes of the scene node animator. +void CSceneNodeAnimatorFlyStraight::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + Start = in->getAttributeAsVector3d("Start"); + End = in->getAttributeAsVector3d("End"); + TimeForWay = in->getAttributeAsInt("TimeForWay"); + Loop = in->getAttributeAsBool("Loop"); + + recalculateImidiateValues(); +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CSceneNodeAnimatorFlyStraight.h b/src/dep/src/irrlicht/CSceneNodeAnimatorFlyStraight.h index 79c8d74..b8661e9 100644 --- a/src/dep/src/irrlicht/CSceneNodeAnimatorFlyStraight.h +++ b/src/dep/src/irrlicht/CSceneNodeAnimatorFlyStraight.h @@ -1,57 +1,57 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_FLY_STRAIGHT_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_FLY_STRAIGHT_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - class CSceneNodeAnimatorFlyStraight : public ISceneNodeAnimator - { - public: - - //! constructor - CSceneNodeAnimatorFlyStraight(const core::vector3df& startPoint, - const core::vector3df& endPoint, u32 timeForWay, - bool loop, u32 now); - - //! destructor - virtual ~CSceneNodeAnimatorFlyStraight(); - - //! animates a scene node - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Writes attributes of the scene node animator. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node animator. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() { return ESNAT_FLY_STRAIGHT; } - - private: - - void recalculateImidiateValues(); - - core::vector3df Start; - core::vector3df End; - core::vector3df Vector; - f32 WayLength; - f32 TimeFactor; - u32 StartTime; - u32 TimeForWay; - bool Loop; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_SCENE_NODE_ANIMATOR_FLY_STRAIGHT_H_INCLUDED__ +#define __C_SCENE_NODE_ANIMATOR_FLY_STRAIGHT_H_INCLUDED__ + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + class CSceneNodeAnimatorFlyStraight : public ISceneNodeAnimator + { + public: + + //! constructor + CSceneNodeAnimatorFlyStraight(const core::vector3df& startPoint, + const core::vector3df& endPoint, u32 timeForWay, + bool loop, u32 now); + + //! destructor + virtual ~CSceneNodeAnimatorFlyStraight(); + + //! animates a scene node + virtual void animateNode(ISceneNode* node, u32 timeMs); + + //! Writes attributes of the scene node animator. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node animator. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + //! Returns type of the scene node animator + virtual ESCENE_NODE_ANIMATOR_TYPE getType() { return ESNAT_FLY_STRAIGHT; } + + private: + + void recalculateImidiateValues(); + + core::vector3df Start; + core::vector3df End; + core::vector3df Vector; + f32 WayLength; + f32 TimeFactor; + u32 StartTime; + u32 TimeForWay; + bool Loop; + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CSceneNodeAnimatorFollowSpline.cpp b/src/dep/src/irrlicht/CSceneNodeAnimatorFollowSpline.cpp index d9e37ef..5c60bad 100644 --- a/src/dep/src/irrlicht/CSceneNodeAnimatorFollowSpline.cpp +++ b/src/dep/src/irrlicht/CSceneNodeAnimatorFollowSpline.cpp @@ -1,133 +1,133 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorFollowSpline.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CSceneNodeAnimatorFollowSpline::CSceneNodeAnimatorFollowSpline(u32 time, - const core::array< core::vector3df >& points, f32 speed, - f32 tightness) -: Points(points), Speed(speed), Tightness(tightness), StartTime(time) -{ - #ifdef _DEBUG - setDebugName("CSceneNodeAnimatorFollowSpline"); - #endif -} - - - -//! destructor -CSceneNodeAnimatorFollowSpline::~CSceneNodeAnimatorFollowSpline() -{ -} - - - -inline s32 CSceneNodeAnimatorFollowSpline::clamp(s32 idx, s32 size) -{ - return ( idx<0 ? size+idx : ( idx>=size ? idx-size : idx ) ); -} - - -//! animates a scene node -void CSceneNodeAnimatorFollowSpline::animateNode(ISceneNode* node, u32 timeMs) -{ - core::vector3df p, p0, p1, p2, p3; - core::vector3df t1, t2; - - const u32 pSize = Points.size(); - - const f32 dt = ( (timeMs-StartTime) * Speed * 0.001f ); - const f32 u = core::fract ( dt ); - s32 idx = core::floor32( dt ) % pSize; - //f32 u = 0.001f * fmodf( dt, 1000.0f ); - - - p0 = Points[ clamp( idx - 1, pSize ) ]; - p1 = Points[ clamp( idx + 0, pSize ) ]; - p2 = Points[ clamp( idx + 1, pSize ) ]; - p3 = Points[ clamp( idx + 2, pSize ) ]; - - // hermite polynomials - f32 h1 = 2.0f * u * u * u - 3.0f * u * u + 1.0f; - f32 h2 = -2.0f * u * u * u + 3.0f * u * u; - f32 h3 = u * u * u - 2.0f * u * u + u; - f32 h4 = u * u * u - u * u; - - // tangents - t1 = ( p2 - p0 ) * Tightness; - t2 = ( p3 - p1 ) * Tightness; - - // interpolated point - p = p1 * h1 + p2 * h2 + t1 * h3 + t2 * h4; - - node->setPosition(p); -} - - -//! Writes attributes of the scene node animator. -void CSceneNodeAnimatorFollowSpline::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - out->addFloat("Speed", Speed); - out->addFloat("Tightness", Tightness); - - u32 count = Points.size(); - - if ( options && (options->Flags & io::EARWF_FOR_EDITOR)) - { - // add one point in addition when serializing for editors - // to make it easier to add points quickly - count += 1; - } - - for (u32 i=0; iaddVector3d(tname.c_str(), igetAttributeAsFloat("Speed"); - Tightness = in->getAttributeAsFloat("Tightness"); - Points.clear(); - - for(u32 i=1; true; ++i) - { - core::stringc pname = "Point"; - pname += (int)i; - - if (in->existsAttribute(pname.c_str())) - { - core::vector3df pos = in->getAttributeAsVector3d(pname.c_str()); - Points.push_back(pos); - } - else - break; - } - - // remove last point if double entry from editor - if ( options && (options->Flags & io::EARWF_FOR_EDITOR) && - Points.size() > 2 && Points.getLast() == core::vector3df(0,0,0)) - { - Points.erase(Points.size()-1); - - if (Points.size() > 2 && Points.getLast() == core::vector3df(0,0,0)) - Points.erase(Points.size()-1); - } -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSceneNodeAnimatorFollowSpline.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CSceneNodeAnimatorFollowSpline::CSceneNodeAnimatorFollowSpline(u32 time, + const core::array< core::vector3df >& points, f32 speed, + f32 tightness) +: Points(points), Speed(speed), Tightness(tightness), StartTime(time) +{ + #ifdef _DEBUG + setDebugName("CSceneNodeAnimatorFollowSpline"); + #endif +} + + + +//! destructor +CSceneNodeAnimatorFollowSpline::~CSceneNodeAnimatorFollowSpline() +{ +} + + + +inline s32 CSceneNodeAnimatorFollowSpline::clamp(s32 idx, s32 size) +{ + return ( idx<0 ? size+idx : ( idx>=size ? idx-size : idx ) ); +} + + +//! animates a scene node +void CSceneNodeAnimatorFollowSpline::animateNode(ISceneNode* node, u32 timeMs) +{ + core::vector3df p, p0, p1, p2, p3; + core::vector3df t1, t2; + + const u32 pSize = Points.size(); + + const f32 dt = ( (timeMs-StartTime) * Speed * 0.001f ); + const f32 u = core::fract ( dt ); + s32 idx = core::floor32( dt ) % pSize; + //f32 u = 0.001f * fmodf( dt, 1000.0f ); + + + p0 = Points[ clamp( idx - 1, pSize ) ]; + p1 = Points[ clamp( idx + 0, pSize ) ]; + p2 = Points[ clamp( idx + 1, pSize ) ]; + p3 = Points[ clamp( idx + 2, pSize ) ]; + + // hermite polynomials + f32 h1 = 2.0f * u * u * u - 3.0f * u * u + 1.0f; + f32 h2 = -2.0f * u * u * u + 3.0f * u * u; + f32 h3 = u * u * u - 2.0f * u * u + u; + f32 h4 = u * u * u - u * u; + + // tangents + t1 = ( p2 - p0 ) * Tightness; + t2 = ( p3 - p1 ) * Tightness; + + // interpolated point + p = p1 * h1 + p2 * h2 + t1 * h3 + t2 * h4; + + node->setPosition(p); +} + + +//! Writes attributes of the scene node animator. +void CSceneNodeAnimatorFollowSpline::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + out->addFloat("Speed", Speed); + out->addFloat("Tightness", Tightness); + + u32 count = Points.size(); + + if ( options && (options->Flags & io::EARWF_FOR_EDITOR)) + { + // add one point in addition when serializing for editors + // to make it easier to add points quickly + count += 1; + } + + for (u32 i=0; iaddVector3d(tname.c_str(), igetAttributeAsFloat("Speed"); + Tightness = in->getAttributeAsFloat("Tightness"); + Points.clear(); + + for(u32 i=1; true; ++i) + { + core::stringc pname = "Point"; + pname += (int)i; + + if (in->existsAttribute(pname.c_str())) + { + core::vector3df pos = in->getAttributeAsVector3d(pname.c_str()); + Points.push_back(pos); + } + else + break; + } + + // remove last point if double entry from editor + if ( options && (options->Flags & io::EARWF_FOR_EDITOR) && + Points.size() > 2 && Points.getLast() == core::vector3df(0,0,0)) + { + Points.erase(Points.size()-1); + + if (Points.size() > 2 && Points.getLast() == core::vector3df(0,0,0)) + Points.erase(Points.size()-1); + } +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CSceneNodeAnimatorFollowSpline.h b/src/dep/src/irrlicht/CSceneNodeAnimatorFollowSpline.h index 6a6300b..fea9792 100644 --- a/src/dep/src/irrlicht/CSceneNodeAnimatorFollowSpline.h +++ b/src/dep/src/irrlicht/CSceneNodeAnimatorFollowSpline.h @@ -1,57 +1,57 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_FOLLOW_SPLINE_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_FOLLOW_SPLINE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - //! Scene node animator based free code Matthias Gall wrote and sent in. (Most of - //! this code is written by him, I only modified bits.) - class CSceneNodeAnimatorFollowSpline : public ISceneNodeAnimator - { - public: - - //! constructor - CSceneNodeAnimatorFollowSpline(u32 startTime, - const core::array< core::vector3df >& points, - f32 speed = 1.0f, f32 tightness = 0.5f); - - //! destructor - virtual ~CSceneNodeAnimatorFollowSpline(); - - //! animates a scene node - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Writes attributes of the scene node animator. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node animator. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() { return ESNAT_FOLLOW_SPLINE; } - - protected: - - //! clamps a the value idx to fit into range 0..size-1 - s32 clamp(s32 idx, s32 size); - - core::array< core::vector3df > Points; - f32 Speed; - f32 Tightness; - u32 StartTime; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_SCENE_NODE_ANIMATOR_FOLLOW_SPLINE_H_INCLUDED__ +#define __C_SCENE_NODE_ANIMATOR_FOLLOW_SPLINE_H_INCLUDED__ + +#include "ISceneNode.h" +#include "irrArray.h" + +namespace irr +{ +namespace scene +{ + //! Scene node animator based free code Matthias Gall wrote and sent in. (Most of + //! this code is written by him, I only modified bits.) + class CSceneNodeAnimatorFollowSpline : public ISceneNodeAnimator + { + public: + + //! constructor + CSceneNodeAnimatorFollowSpline(u32 startTime, + const core::array< core::vector3df >& points, + f32 speed = 1.0f, f32 tightness = 0.5f); + + //! destructor + virtual ~CSceneNodeAnimatorFollowSpline(); + + //! animates a scene node + virtual void animateNode(ISceneNode* node, u32 timeMs); + + //! Writes attributes of the scene node animator. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node animator. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + //! Returns type of the scene node animator + virtual ESCENE_NODE_ANIMATOR_TYPE getType() { return ESNAT_FOLLOW_SPLINE; } + + protected: + + //! clamps a the value idx to fit into range 0..size-1 + s32 clamp(s32 idx, s32 size); + + core::array< core::vector3df > Points; + f32 Speed; + f32 Tightness; + u32 StartTime; + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CSceneNodeAnimatorRotation.cpp b/src/dep/src/irrlicht/CSceneNodeAnimatorRotation.cpp index 5b59bb8..1d759d4 100644 --- a/src/dep/src/irrlicht/CSceneNodeAnimatorRotation.cpp +++ b/src/dep/src/irrlicht/CSceneNodeAnimatorRotation.cpp @@ -1,59 +1,59 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorRotation.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CSceneNodeAnimatorRotation::CSceneNodeAnimatorRotation(u32 time, const core::vector3df& rotation) -: Rotation(rotation), StartTime(time), DiffTime(0) -{ - #ifdef _DEBUG - setDebugName("CSceneNodeAnimatorRotation"); - #endif -} - - -//! destructor -CSceneNodeAnimatorRotation::~CSceneNodeAnimatorRotation() -{ -} - - - -//! animates a scene node -void CSceneNodeAnimatorRotation::animateNode(ISceneNode* node, u32 timeMs) -{ - if (node) // thanks to warui for this fix - { - if ((timeMs-StartTime) != 0) - DiffTime=timeMs-StartTime; - core::vector3df NewRotation = node->getRotation(); - NewRotation += Rotation* ((f32)DiffTime/10.0f); - node->setRotation(NewRotation); - StartTime=timeMs; - } -} - - -//! Writes attributes of the scene node animator. -void CSceneNodeAnimatorRotation::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - out->addVector3d("Rotation", Rotation); -} - -//! Reads attributes of the scene node animator. -void CSceneNodeAnimatorRotation::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Rotation = in->getAttributeAsVector3d("Rotation"); -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSceneNodeAnimatorRotation.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CSceneNodeAnimatorRotation::CSceneNodeAnimatorRotation(u32 time, const core::vector3df& rotation) +: Rotation(rotation), StartTime(time), DiffTime(0) +{ + #ifdef _DEBUG + setDebugName("CSceneNodeAnimatorRotation"); + #endif +} + + +//! destructor +CSceneNodeAnimatorRotation::~CSceneNodeAnimatorRotation() +{ +} + + + +//! animates a scene node +void CSceneNodeAnimatorRotation::animateNode(ISceneNode* node, u32 timeMs) +{ + if (node) // thanks to warui for this fix + { + if ((timeMs-StartTime) != 0) + DiffTime=timeMs-StartTime; + core::vector3df NewRotation = node->getRotation(); + NewRotation += Rotation* ((f32)DiffTime/10.0f); + node->setRotation(NewRotation); + StartTime=timeMs; + } +} + + +//! Writes attributes of the scene node animator. +void CSceneNodeAnimatorRotation::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + out->addVector3d("Rotation", Rotation); +} + +//! Reads attributes of the scene node animator. +void CSceneNodeAnimatorRotation::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + Rotation = in->getAttributeAsVector3d("Rotation"); +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CSceneNodeAnimatorRotation.h b/src/dep/src/irrlicht/CSceneNodeAnimatorRotation.h index d5006f2..8376404 100644 --- a/src/dep/src/irrlicht/CSceneNodeAnimatorRotation.h +++ b/src/dep/src/irrlicht/CSceneNodeAnimatorRotation.h @@ -1,48 +1,48 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_ROTATION_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_ROTATION_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - class CSceneNodeAnimatorRotation : public ISceneNodeAnimator - { - public: - - //! constructor - CSceneNodeAnimatorRotation(u32 time, const core::vector3df& rotation); - - //! destructor - virtual ~CSceneNodeAnimatorRotation(); - - //! animates a scene node - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Writes attributes of the scene node animator. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node animator. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() { return ESNAT_ROTATION; } - - private: - - core::vector3df Rotation; - u32 StartTime; - u32 DiffTime; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_SCENE_NODE_ANIMATOR_ROTATION_H_INCLUDED__ +#define __C_SCENE_NODE_ANIMATOR_ROTATION_H_INCLUDED__ + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + class CSceneNodeAnimatorRotation : public ISceneNodeAnimator + { + public: + + //! constructor + CSceneNodeAnimatorRotation(u32 time, const core::vector3df& rotation); + + //! destructor + virtual ~CSceneNodeAnimatorRotation(); + + //! animates a scene node + virtual void animateNode(ISceneNode* node, u32 timeMs); + + //! Writes attributes of the scene node animator. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node animator. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + //! Returns type of the scene node animator + virtual ESCENE_NODE_ANIMATOR_TYPE getType() { return ESNAT_ROTATION; } + + private: + + core::vector3df Rotation; + u32 StartTime; + u32 DiffTime; + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CSceneNodeAnimatorTexture.cpp b/src/dep/src/irrlicht/CSceneNodeAnimatorTexture.cpp index 7e60757..8a57059 100644 --- a/src/dep/src/irrlicht/CSceneNodeAnimatorTexture.cpp +++ b/src/dep/src/irrlicht/CSceneNodeAnimatorTexture.cpp @@ -1,124 +1,124 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorTexture.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CSceneNodeAnimatorTexture::CSceneNodeAnimatorTexture(const core::array& textures, - s32 timePerFrame, bool loop, u32 now) -: TimePerFrame(timePerFrame), StartTime(now), Loop(loop) -{ - #ifdef _DEBUG - setDebugName("CSceneNodeAnimatorTexture"); - #endif - - for (u32 i=0; igrab(); - - Textures.push_back(textures[i]); - } - - EndTime = now + (timePerFrame * Textures.size()); -} - - - -//! destructor -CSceneNodeAnimatorTexture::~CSceneNodeAnimatorTexture() -{ - clearTextures(); -} - - - -void CSceneNodeAnimatorTexture::clearTextures() -{ - for (u32 i=0; idrop(); -} - - - -//! animates a scene node -void CSceneNodeAnimatorTexture::animateNode(ISceneNode* node, u32 timeMs) -{ - if (Textures.size()) - { - u32 t = (timeMs-StartTime); - - s32 idx = 0; - - if (!Loop && timeMs >= EndTime) - idx = Textures.size() - 1; - else - idx = (t/TimePerFrame) % Textures.size(); - - if (idx < (s32)Textures.size()) - node->setMaterialTexture(0, Textures[idx]); - } -} - - -//! Writes attributes of the scene node animator. -void CSceneNodeAnimatorTexture::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - out->addInt("TimePerFrame", TimePerFrame); - out->addBool("Loop", Loop); - - // add one texture in addition when serializing for editors - // to make it easier to add textures quickly - - u32 count = Textures.size(); - if ( options && (options->Flags & io::EARWF_FOR_EDITOR)) - count += 1; - - for (u32 i=0; iaddTexture(tname.c_str(), igetAttributeAsInt("TimePerFrame"); - Loop = in->getAttributeAsBool("Loop"); - - clearTextures(); - - for(u32 i=1; true; ++i) - { - core::stringc tname = "Texture"; - tname += (int)i; - - if (in->existsAttribute(tname.c_str())) - { - video::ITexture* tex = in->getAttributeAsTexture(tname.c_str()); - if (tex) - { - tex->grab(); - Textures.push_back(tex); - } - } - else - break; - } -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSceneNodeAnimatorTexture.h" + +namespace irr +{ +namespace scene +{ + + +//! constructor +CSceneNodeAnimatorTexture::CSceneNodeAnimatorTexture(const core::array& textures, + s32 timePerFrame, bool loop, u32 now) +: TimePerFrame(timePerFrame), StartTime(now), Loop(loop) +{ + #ifdef _DEBUG + setDebugName("CSceneNodeAnimatorTexture"); + #endif + + for (u32 i=0; igrab(); + + Textures.push_back(textures[i]); + } + + EndTime = now + (timePerFrame * Textures.size()); +} + + + +//! destructor +CSceneNodeAnimatorTexture::~CSceneNodeAnimatorTexture() +{ + clearTextures(); +} + + + +void CSceneNodeAnimatorTexture::clearTextures() +{ + for (u32 i=0; idrop(); +} + + + +//! animates a scene node +void CSceneNodeAnimatorTexture::animateNode(ISceneNode* node, u32 timeMs) +{ + if (Textures.size()) + { + u32 t = (timeMs-StartTime); + + s32 idx = 0; + + if (!Loop && timeMs >= EndTime) + idx = Textures.size() - 1; + else + idx = (t/TimePerFrame) % Textures.size(); + + if (idx < (s32)Textures.size()) + node->setMaterialTexture(0, Textures[idx]); + } +} + + +//! Writes attributes of the scene node animator. +void CSceneNodeAnimatorTexture::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + out->addInt("TimePerFrame", TimePerFrame); + out->addBool("Loop", Loop); + + // add one texture in addition when serializing for editors + // to make it easier to add textures quickly + + u32 count = Textures.size(); + if ( options && (options->Flags & io::EARWF_FOR_EDITOR)) + count += 1; + + for (u32 i=0; iaddTexture(tname.c_str(), igetAttributeAsInt("TimePerFrame"); + Loop = in->getAttributeAsBool("Loop"); + + clearTextures(); + + for(u32 i=1; true; ++i) + { + core::stringc tname = "Texture"; + tname += (int)i; + + if (in->existsAttribute(tname.c_str())) + { + video::ITexture* tex = in->getAttributeAsTexture(tname.c_str()); + if (tex) + { + tex->grab(); + Textures.push_back(tex); + } + } + else + break; + } +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CSceneNodeAnimatorTexture.h b/src/dep/src/irrlicht/CSceneNodeAnimatorTexture.h index 30d941e..edfb138 100644 --- a/src/dep/src/irrlicht/CSceneNodeAnimatorTexture.h +++ b/src/dep/src/irrlicht/CSceneNodeAnimatorTexture.h @@ -1,54 +1,54 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_TEXTURE_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_TEXTURE_H_INCLUDED__ - -#include "irrArray.h" -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - class CSceneNodeAnimatorTexture : public ISceneNodeAnimator - { - public: - - //! constructor - CSceneNodeAnimatorTexture(const core::array& textures, - s32 timePerFrame, bool loop, u32 now); - - //! destructor - virtual ~CSceneNodeAnimatorTexture(); - - //! animates a scene node - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Writes attributes of the scene node animator. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node animator. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() { return ESNAT_TEXTURE; } - - private: - - void clearTextures(); - - core::array Textures; - u32 TimePerFrame; - u32 StartTime; - u32 EndTime; - bool Loop; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_SCENE_NODE_ANIMATOR_TEXTURE_H_INCLUDED__ +#define __C_SCENE_NODE_ANIMATOR_TEXTURE_H_INCLUDED__ + +#include "irrArray.h" +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + class CSceneNodeAnimatorTexture : public ISceneNodeAnimator + { + public: + + //! constructor + CSceneNodeAnimatorTexture(const core::array& textures, + s32 timePerFrame, bool loop, u32 now); + + //! destructor + virtual ~CSceneNodeAnimatorTexture(); + + //! animates a scene node + virtual void animateNode(ISceneNode* node, u32 timeMs); + + //! Writes attributes of the scene node animator. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node animator. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + //! Returns type of the scene node animator + virtual ESCENE_NODE_ANIMATOR_TYPE getType() { return ESNAT_TEXTURE; } + + private: + + void clearTextures(); + + core::array Textures; + u32 TimePerFrame; + u32 StartTime; + u32 EndTime; + bool Loop; + }; + + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CShadowVolumeSceneNode.cpp b/src/dep/src/irrlicht/CShadowVolumeSceneNode.cpp index c653d94..172e23b 100644 --- a/src/dep/src/irrlicht/CShadowVolumeSceneNode.cpp +++ b/src/dep/src/irrlicht/CShadowVolumeSceneNode.cpp @@ -1,504 +1,504 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CShadowVolumeSceneNode.h" -#include "ISceneManager.h" -#include "IVideoDriver.h" -#include "SLight.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CShadowVolumeSceneNode::CShadowVolumeSceneNode(ISceneNode* parent, - ISceneManager* mgr, s32 id, - bool zfailmethod, f32 infinity) -: IShadowVolumeSceneNode(parent, mgr, id), Indices(0), Vertices(0), - Adjacency(0), FaceData(0), UseZFailMethod(zfailmethod), - IndexCountAllocated(0), VertexCountAllocated(0), - IndexCount(0), VertexCount(0), ShadowVolumesUsed(0), - Edges(0), EdgeCount(0), Infinity(infinity) -{ - #ifdef _DEBUG - setDebugName("CShadowVolumeSceneNode"); - #endif - - setAutomaticCulling(scene::EAC_OFF); -} - - - -//! destructor -CShadowVolumeSceneNode::~CShadowVolumeSceneNode() -{ - if (Edges) - delete [] Edges; - - for (u32 i=0; i (u32)ShadowVolumesUsed) - { - // get the next unused buffer - svp = &ShadowVolumes[ShadowVolumesUsed]; - if (svp->size >= IndexCount*5) - svp->count = 0; - else - { - svp->size = IndexCount*5; - svp->count = 0; - delete [] svp->vertices; - svp->vertices = new core::vector3df[svp->size]; - } - - ++ShadowVolumesUsed; - } - else - { - // add a buffer - SShadowVolume tmp; - ShadowVolumes.push_back(tmp); - svp = &ShadowVolumes[ShadowVolumes.size()-1]; - ++ShadowVolumesUsed; - - // lets make a rather large shadowbuffer - svp->size = IndexCount*5; - svp->count = 0; - svp->vertices = new core::vector3df[svp->size]; - } - - s32 faceCount = (int)(IndexCount / 3); - - if (faceCount * 6 > EdgeCount || !Edges) - { - delete [] Edges; - EdgeCount = faceCount * 6; - Edges = new u16[EdgeCount]; - } - - s32 numEdges = 0; - core::vector3df ls = light * Infinity; // light scaled - - //if (!UseZFailMethod) - // createZPassVolume(faceCount, numEdges, light, svp); - //else - // createZFailVolume(faceCount, numEdges, light, svp); - - // the createZFailVolume does currently not work 100% correctly, - // so we create createZPassVolume with caps if the zfail method - // is used - createZPassVolume(faceCount, numEdges, light, svp, UseZFailMethod); - - - for (s32 i=0; ivertices && svp->count < svp->size-5) - { - svp->vertices[svp->count++] = v1; - svp->vertices[svp->count++] = v2; - svp->vertices[svp->count++] = v3; - - svp->vertices[svp->count++] = v2; - svp->vertices[svp->count++] = v4; - svp->vertices[svp->count++] = v3; - } - } -} - -void CShadowVolumeSceneNode::createZFailVolume(s32 faceCount, s32& numEdges, - const core::vector3df& light, - SShadowVolume* svp) -{ - u16 wFace0, wFace1, wFace2; - s32 i; - core::vector3df ls = light * Infinity; - - // Check every face if it is front or back facing the light. - for (i=0; i= 0.0f ) - { - FaceData[i] = false; // it's a back facing face - - if (svp->vertices && svp->count < svp->size-5) - { - // add front cap - svp->vertices[svp->count++] = v0; - svp->vertices[svp->count++] = v2; - svp->vertices[svp->count++] = v1; - - // add back cap - svp->vertices[svp->count++] = v0 - ls; - svp->vertices[svp->count++] = v1 - ls; - svp->vertices[svp->count++] = v2 - ls; - } - } - else - FaceData[i] = true; // it's a front facing face - } - - - for(i=0; i= 0.0f) - { - Edges[2*numEdges+0] = wFace0; - Edges[2*numEdges+1] = wFace1; - ++numEdges; - - Edges[2*numEdges+0] = wFace1; - Edges[2*numEdges+1] = wFace2; - ++numEdges; - - Edges[2*numEdges+0] = wFace2; - Edges[2*numEdges+1] = wFace0; - ++numEdges; - - if (caps && svp->vertices && svp->count < svp->size-5) - { - svp->vertices[svp->count++] = Vertices[wFace0]; - svp->vertices[svp->count++] = Vertices[wFace2]; - svp->vertices[svp->count++] = Vertices[wFace1]; - - svp->vertices[svp->count++] = Vertices[wFace0] - light; - svp->vertices[svp->count++] = Vertices[wFace1] - light; - svp->vertices[svp->count++] = Vertices[wFace2] - light; - } - } - } -} - -//! sets the mesh from which the shadow volume should be generated. -void CShadowVolumeSceneNode::setMeshToRenderFrom(IMesh* mesh) -{ - ShadowVolumesUsed = 0; - - s32 oldIndexCount = IndexCount; - s32 oldVertexCount = VertexCount; - - VertexCount = 0; - IndexCount = 0; - - if (!mesh) - return; - - // calculate total amount of vertices and indices - - u32 i; - s32 totalVertices = 0; - s32 totalIndices = 0; - u32 bufcnt = mesh->getMeshBufferCount(); - IMeshBuffer* b; - - for (i=0; igetMeshBuffer(i); - totalIndices += b->getIndexCount(); - totalVertices += b->getVertexCount(); - } - - // allocate memory if nececcary - - if (totalVertices > VertexCountAllocated) - { - delete [] Vertices; - Vertices = new core::vector3df[totalVertices]; - VertexCountAllocated = totalVertices; - } - - if (totalIndices > IndexCountAllocated) - { - delete [] Indices; - Indices = new u16[totalIndices]; - IndexCountAllocated = totalIndices; - - if (UseZFailMethod) - { - delete [] FaceData; - FaceData = new bool[totalIndices / 3]; - } - } - - // copy mesh - - for (i=0; igetMeshBuffer(i); - - s32 idxcnt = b->getIndexCount(); - s32 vtxnow = VertexCount; - - const u16* idxp = b->getIndices(); - const u16* idxpend = idxp + idxcnt; - - for (; idxp!=idxpend; ++idxp) - Indices[IndexCount++] = *idxp + vtxnow; - - s32 vtxcnt = b->getVertexCount(); - - switch(b->getVertexType()) - { - case video::EVT_STANDARD: - { - const video::S3DVertex* vp = (video::S3DVertex*)b->getVertices(); - const video::S3DVertex* vpend = vp + vtxcnt; - - for (; vp!=vpend; ++vp) - Vertices[VertexCount++] = (*vp).Pos; - } - break; - case video::EVT_2TCOORDS: - { - const video::S3DVertex2TCoords* vp = (video::S3DVertex2TCoords*)b->getVertices(); - const video::S3DVertex2TCoords* vpend = vp + vtxcnt; - - for (; vp!=vpend; ++vp) - Vertices[VertexCount++] = (*vp).Pos; - } - break; - case video::EVT_TANGENTS: - { - const video::S3DVertexTangents* vp = (video::S3DVertexTangents*)b->getVertices(); - const video::S3DVertexTangents* vpend = vp + vtxcnt; - - for (; vp!=vpend; ++vp) - Vertices[VertexCount++] = (*vp).Pos; - } - break; - } - } - - // recalculate adjacency if neccessarry - if (oldVertexCount != VertexCount && - oldIndexCount != IndexCount && UseZFailMethod) - calculateAdjacency(); - - // create as much shadow volumes as there are lights but - // do not ignore the max light settings. - - u32 lights = SceneManager->getVideoDriver()->getDynamicLightCount(); - core::matrix4 mat = Parent->getAbsoluteTransformation(); - core::vector3df parentpos = Parent->getAbsolutePosition(); - core::vector3df lpos; - mat.makeInverse(); - - for (i=0; igetVideoDriver()->getDynamicLight(i); - lpos = dl.Position; - if (dl.CastShadows && - fabs((lpos - parentpos).getLengthSQ()) <= (dl.Radius*dl.Radius*4.0f)) - { - mat.transformVect(lpos); - createShadowVolume(lpos); - } - } -} - - - -//! pre render method -void CShadowVolumeSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - SceneManager->registerNodeForRendering(this, scene::ESNRP_SHADOW); - ISceneNode::OnRegisterSceneNode(); - } -} - - - -//! renders the node. -void CShadowVolumeSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - if (!ShadowVolumesUsed || !driver) - return; - - driver->setTransform(video::ETS_WORLD, Parent->getAbsoluteTransformation()); - - for (s32 i=0; idrawStencilShadowVolume(ShadowVolumes[i].vertices, - ShadowVolumes[i].count, UseZFailMethod); -} - - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CShadowVolumeSceneNode::getBoundingBox() const -{ - return Box; -} - - - -//! returns the material based on the zero based index i. -video::SMaterial& CShadowVolumeSceneNode::getMaterial(u32 i) -{ - // this should never be called, because a shadow volume has got no - // material - return *((video::SMaterial*)(0)); - -} - - - -//! returns amount of materials used by this scene node. -u32 CShadowVolumeSceneNode::getMaterialCount() -{ - return 0; -} - - -//! Generates adjacency information based on mesh indices. -void CShadowVolumeSceneNode::calculateAdjacency(f32 epsilon) -{ - delete [] Adjacency; - Adjacency = new u16[IndexCount]; - - epsilon *= epsilon; - - f32 t = 0; - - // go through all faces and fetch their three neighbours - for (s32 f=0; f= -epsilon) - ++cnt1; - - t = v2.getDistanceFromSQ(Vertices[Indices[of+e]]); - if (t <= epsilon && t >= -epsilon) - ++cnt2; - } - - if (cnt1 == 1 && cnt2 == 1) - break; - } - - if (of == IndexCount) - Adjacency[f + edge] = f; - else - Adjacency[f + edge] = of / 3; - } - } -} - - -} // end namespace scene -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CShadowVolumeSceneNode.h" +#include "ISceneManager.h" +#include "IVideoDriver.h" +#include "SLight.h" + +namespace irr +{ +namespace scene +{ + + +//! constructor +CShadowVolumeSceneNode::CShadowVolumeSceneNode(ISceneNode* parent, + ISceneManager* mgr, s32 id, + bool zfailmethod, f32 infinity) +: IShadowVolumeSceneNode(parent, mgr, id), Indices(0), Vertices(0), + Adjacency(0), FaceData(0), UseZFailMethod(zfailmethod), + IndexCountAllocated(0), VertexCountAllocated(0), + IndexCount(0), VertexCount(0), ShadowVolumesUsed(0), + Edges(0), EdgeCount(0), Infinity(infinity) +{ + #ifdef _DEBUG + setDebugName("CShadowVolumeSceneNode"); + #endif + + setAutomaticCulling(scene::EAC_OFF); +} + + + +//! destructor +CShadowVolumeSceneNode::~CShadowVolumeSceneNode() +{ + if (Edges) + delete [] Edges; + + for (u32 i=0; i (u32)ShadowVolumesUsed) + { + // get the next unused buffer + svp = &ShadowVolumes[ShadowVolumesUsed]; + if (svp->size >= IndexCount*5) + svp->count = 0; + else + { + svp->size = IndexCount*5; + svp->count = 0; + delete [] svp->vertices; + svp->vertices = new core::vector3df[svp->size]; + } + + ++ShadowVolumesUsed; + } + else + { + // add a buffer + SShadowVolume tmp; + ShadowVolumes.push_back(tmp); + svp = &ShadowVolumes[ShadowVolumes.size()-1]; + ++ShadowVolumesUsed; + + // lets make a rather large shadowbuffer + svp->size = IndexCount*5; + svp->count = 0; + svp->vertices = new core::vector3df[svp->size]; + } + + s32 faceCount = (int)(IndexCount / 3); + + if (faceCount * 6 > EdgeCount || !Edges) + { + delete [] Edges; + EdgeCount = faceCount * 6; + Edges = new u16[EdgeCount]; + } + + s32 numEdges = 0; + core::vector3df ls = light * Infinity; // light scaled + + //if (!UseZFailMethod) + // createZPassVolume(faceCount, numEdges, light, svp); + //else + // createZFailVolume(faceCount, numEdges, light, svp); + + // the createZFailVolume does currently not work 100% correctly, + // so we create createZPassVolume with caps if the zfail method + // is used + createZPassVolume(faceCount, numEdges, light, svp, UseZFailMethod); + + + for (s32 i=0; ivertices && svp->count < svp->size-5) + { + svp->vertices[svp->count++] = v1; + svp->vertices[svp->count++] = v2; + svp->vertices[svp->count++] = v3; + + svp->vertices[svp->count++] = v2; + svp->vertices[svp->count++] = v4; + svp->vertices[svp->count++] = v3; + } + } +} + +void CShadowVolumeSceneNode::createZFailVolume(s32 faceCount, s32& numEdges, + const core::vector3df& light, + SShadowVolume* svp) +{ + u16 wFace0, wFace1, wFace2; + s32 i; + core::vector3df ls = light * Infinity; + + // Check every face if it is front or back facing the light. + for (i=0; i= 0.0f ) + { + FaceData[i] = false; // it's a back facing face + + if (svp->vertices && svp->count < svp->size-5) + { + // add front cap + svp->vertices[svp->count++] = v0; + svp->vertices[svp->count++] = v2; + svp->vertices[svp->count++] = v1; + + // add back cap + svp->vertices[svp->count++] = v0 - ls; + svp->vertices[svp->count++] = v1 - ls; + svp->vertices[svp->count++] = v2 - ls; + } + } + else + FaceData[i] = true; // it's a front facing face + } + + + for(i=0; i= 0.0f) + { + Edges[2*numEdges+0] = wFace0; + Edges[2*numEdges+1] = wFace1; + ++numEdges; + + Edges[2*numEdges+0] = wFace1; + Edges[2*numEdges+1] = wFace2; + ++numEdges; + + Edges[2*numEdges+0] = wFace2; + Edges[2*numEdges+1] = wFace0; + ++numEdges; + + if (caps && svp->vertices && svp->count < svp->size-5) + { + svp->vertices[svp->count++] = Vertices[wFace0]; + svp->vertices[svp->count++] = Vertices[wFace2]; + svp->vertices[svp->count++] = Vertices[wFace1]; + + svp->vertices[svp->count++] = Vertices[wFace0] - light; + svp->vertices[svp->count++] = Vertices[wFace1] - light; + svp->vertices[svp->count++] = Vertices[wFace2] - light; + } + } + } +} + +//! sets the mesh from which the shadow volume should be generated. +void CShadowVolumeSceneNode::setMeshToRenderFrom(IMesh* mesh) +{ + ShadowVolumesUsed = 0; + + s32 oldIndexCount = IndexCount; + s32 oldVertexCount = VertexCount; + + VertexCount = 0; + IndexCount = 0; + + if (!mesh) + return; + + // calculate total amount of vertices and indices + + u32 i; + s32 totalVertices = 0; + s32 totalIndices = 0; + u32 bufcnt = mesh->getMeshBufferCount(); + IMeshBuffer* b; + + for (i=0; igetMeshBuffer(i); + totalIndices += b->getIndexCount(); + totalVertices += b->getVertexCount(); + } + + // allocate memory if nececcary + + if (totalVertices > VertexCountAllocated) + { + delete [] Vertices; + Vertices = new core::vector3df[totalVertices]; + VertexCountAllocated = totalVertices; + } + + if (totalIndices > IndexCountAllocated) + { + delete [] Indices; + Indices = new u16[totalIndices]; + IndexCountAllocated = totalIndices; + + if (UseZFailMethod) + { + delete [] FaceData; + FaceData = new bool[totalIndices / 3]; + } + } + + // copy mesh + + for (i=0; igetMeshBuffer(i); + + s32 idxcnt = b->getIndexCount(); + s32 vtxnow = VertexCount; + + const u16* idxp = b->getIndices(); + const u16* idxpend = idxp + idxcnt; + + for (; idxp!=idxpend; ++idxp) + Indices[IndexCount++] = *idxp + vtxnow; + + s32 vtxcnt = b->getVertexCount(); + + switch(b->getVertexType()) + { + case video::EVT_STANDARD: + { + const video::S3DVertex* vp = (video::S3DVertex*)b->getVertices(); + const video::S3DVertex* vpend = vp + vtxcnt; + + for (; vp!=vpend; ++vp) + Vertices[VertexCount++] = (*vp).Pos; + } + break; + case video::EVT_2TCOORDS: + { + const video::S3DVertex2TCoords* vp = (video::S3DVertex2TCoords*)b->getVertices(); + const video::S3DVertex2TCoords* vpend = vp + vtxcnt; + + for (; vp!=vpend; ++vp) + Vertices[VertexCount++] = (*vp).Pos; + } + break; + case video::EVT_TANGENTS: + { + const video::S3DVertexTangents* vp = (video::S3DVertexTangents*)b->getVertices(); + const video::S3DVertexTangents* vpend = vp + vtxcnt; + + for (; vp!=vpend; ++vp) + Vertices[VertexCount++] = (*vp).Pos; + } + break; + } + } + + // recalculate adjacency if neccessarry + if (oldVertexCount != VertexCount && + oldIndexCount != IndexCount && UseZFailMethod) + calculateAdjacency(); + + // create as much shadow volumes as there are lights but + // do not ignore the max light settings. + + u32 lights = SceneManager->getVideoDriver()->getDynamicLightCount(); + core::matrix4 mat = Parent->getAbsoluteTransformation(); + core::vector3df parentpos = Parent->getAbsolutePosition(); + core::vector3df lpos; + mat.makeInverse(); + + for (i=0; igetVideoDriver()->getDynamicLight(i); + lpos = dl.Position; + if (dl.CastShadows && + fabs((lpos - parentpos).getLengthSQ()) <= (dl.Radius*dl.Radius*4.0f)) + { + mat.transformVect(lpos); + createShadowVolume(lpos); + } + } +} + + + +//! pre render method +void CShadowVolumeSceneNode::OnRegisterSceneNode() +{ + if (IsVisible) + { + SceneManager->registerNodeForRendering(this, scene::ESNRP_SHADOW); + ISceneNode::OnRegisterSceneNode(); + } +} + + + +//! renders the node. +void CShadowVolumeSceneNode::render() +{ + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + + if (!ShadowVolumesUsed || !driver) + return; + + driver->setTransform(video::ETS_WORLD, Parent->getAbsoluteTransformation()); + + for (s32 i=0; idrawStencilShadowVolume(ShadowVolumes[i].vertices, + ShadowVolumes[i].count, UseZFailMethod); +} + + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CShadowVolumeSceneNode::getBoundingBox() const +{ + return Box; +} + + + +//! returns the material based on the zero based index i. +video::SMaterial& CShadowVolumeSceneNode::getMaterial(u32 i) +{ + // this should never be called, because a shadow volume has got no + // material + return *((video::SMaterial*)(0)); + +} + + + +//! returns amount of materials used by this scene node. +u32 CShadowVolumeSceneNode::getMaterialCount() +{ + return 0; +} + + +//! Generates adjacency information based on mesh indices. +void CShadowVolumeSceneNode::calculateAdjacency(f32 epsilon) +{ + delete [] Adjacency; + Adjacency = new u16[IndexCount]; + + epsilon *= epsilon; + + f32 t = 0; + + // go through all faces and fetch their three neighbours + for (s32 f=0; f= -epsilon) + ++cnt1; + + t = v2.getDistanceFromSQ(Vertices[Indices[of+e]]); + if (t <= epsilon && t >= -epsilon) + ++cnt2; + } + + if (cnt1 == 1 && cnt2 == 1) + break; + } + + if (of == IndexCount) + Adjacency[f + edge] = f; + else + Adjacency[f + edge] = of / 3; + } + } +} + + +} // end namespace scene +} // end namespace irr diff --git a/src/dep/src/irrlicht/CShadowVolumeSceneNode.h b/src/dep/src/irrlicht/CShadowVolumeSceneNode.h index 44a262a..b9dd23b 100644 --- a/src/dep/src/irrlicht/CShadowVolumeSceneNode.h +++ b/src/dep/src/irrlicht/CShadowVolumeSceneNode.h @@ -1,91 +1,91 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__ -#define __C_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__ - -#include "IShadowVolumeSceneNode.h" - -namespace irr -{ -namespace scene -{ - - //! Scene node for rendering a shadow volume into a stencil buffer. - class CShadowVolumeSceneNode : public IShadowVolumeSceneNode - { - public: - - //! constructor - CShadowVolumeSceneNode(ISceneNode* parent, ISceneManager* mgr, - s32 id, bool zfailmethod=true, f32 infinity=10000.0f); - - //! destructor - virtual ~CShadowVolumeSceneNode(); - - //! sets the mesh from which the shadow volume should be generated. - virtual void setMeshToRenderFrom(IMesh* mesh); - - //! pre render method - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! returns the material based on the zero based index i. - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount(); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_SHADOW_VOLUME; } - - private: - - struct SShadowVolume - { - core::vector3df* vertices; - s32 count; - s32 size; - }; - - void createShadowVolume(const core::vector3df& pos); - void createZPassVolume(s32 faceCount, s32& numEdges, const core::vector3df& light, SShadowVolume* svp, bool caps); - void createZFailVolume(s32 faceCount, s32& numEdges, const core::vector3df& light, SShadowVolume* svp); - void addEdge(s32& numEdges, u16 v0, u16 v1); - - //! Generates adjacency information based on mesh indices. - void calculateAdjacency(f32 epsilon=0.0001f); - - core::aabbox3d Box; - - u16* Indices; - core::vector3df* Vertices; - u16* Adjacency; - bool* FaceData; // used for zfail method, if face is front facing - bool UseZFailMethod; - - s32 IndexCountAllocated; - s32 VertexCountAllocated; - s32 IndexCount; - s32 VertexCount; - - core::array ShadowVolumes; // a shadow volume for every light - s32 ShadowVolumesUsed; - - u16* Edges; - s32 EdgeCount; - - f32 Infinity; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__ +#define __C_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__ + +#include "IShadowVolumeSceneNode.h" + +namespace irr +{ +namespace scene +{ + + //! Scene node for rendering a shadow volume into a stencil buffer. + class CShadowVolumeSceneNode : public IShadowVolumeSceneNode + { + public: + + //! constructor + CShadowVolumeSceneNode(ISceneNode* parent, ISceneManager* mgr, + s32 id, bool zfailmethod=true, f32 infinity=10000.0f); + + //! destructor + virtual ~CShadowVolumeSceneNode(); + + //! sets the mesh from which the shadow volume should be generated. + virtual void setMeshToRenderFrom(IMesh* mesh); + + //! pre render method + virtual void OnRegisterSceneNode(); + + //! renders the node. + virtual void render(); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! returns the material based on the zero based index i. + virtual video::SMaterial& getMaterial(u32 i); + + //! returns amount of materials used by this scene node. + virtual u32 getMaterialCount(); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_SHADOW_VOLUME; } + + private: + + struct SShadowVolume + { + core::vector3df* vertices; + s32 count; + s32 size; + }; + + void createShadowVolume(const core::vector3df& pos); + void createZPassVolume(s32 faceCount, s32& numEdges, const core::vector3df& light, SShadowVolume* svp, bool caps); + void createZFailVolume(s32 faceCount, s32& numEdges, const core::vector3df& light, SShadowVolume* svp); + void addEdge(s32& numEdges, u16 v0, u16 v1); + + //! Generates adjacency information based on mesh indices. + void calculateAdjacency(f32 epsilon=0.0001f); + + core::aabbox3d Box; + + u16* Indices; + core::vector3df* Vertices; + u16* Adjacency; + bool* FaceData; // used for zfail method, if face is front facing + bool UseZFailMethod; + + s32 IndexCountAllocated; + s32 VertexCountAllocated; + s32 IndexCount; + s32 VertexCount; + + core::array ShadowVolumes; // a shadow volume for every light + s32 ShadowVolumesUsed; + + u16* Edges; + s32 EdgeCount; + + f32 Infinity; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CSkyBoxSceneNode.cpp b/src/dep/src/irrlicht/CSkyBoxSceneNode.cpp index 27904a7..19ab974 100644 --- a/src/dep/src/irrlicht/CSkyBoxSceneNode.cpp +++ b/src/dep/src/irrlicht/CSkyBoxSceneNode.cpp @@ -1,247 +1,247 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSkyBoxSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "ICameraSceneNode.h" -#include "S3DVertex.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CSkyBoxSceneNode::CSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, video::ITexture* left, - video::ITexture* right, video::ITexture* front, video::ITexture* back, ISceneNode* parent, ISceneManager* mgr, s32 id) -: ISceneNode(parent, mgr, id) -{ - #ifdef _DEBUG - setDebugName("CSkyBoxSceneNode"); - #endif - - setAutomaticCulling(scene::EAC_OFF); - Box.MaxEdge.set(0,0,0); - Box.MinEdge.set(0,0,0); - - // create indices - - Indices[0] = 0; - Indices[1] = 1; - Indices[2] = 2; - Indices[3] = 3; - - // create material - - video::SMaterial mat; - mat.Lighting = false; - mat.ZBuffer = false; - mat.ZWriteEnable = false; - - /* Hey, I am no artist, but look at that - cool ASCII art I made! ;) - - -111 111 - /6--------/5 y - / | / | ^ z - / | 11-1 | | / - -11-1 3---------2 | |/ - | 7- - -| -4 1-11 *---->x - | -1-11 | / 3-------|2 - |/ | / | //| - 0---------1/ | // | - -1-1-1 1-1-1 |// | - 0--------1 - */ - - f32 onepixel = 0.0f; - - video::ITexture* tex = front; - if (!tex) tex = left; - if (!tex) tex = back; - if (!tex) tex = right; - if (!tex) tex = top; - if (!tex) tex = bottom; - - if (tex) - { - core::dimension2d dim = tex->getSize(); - onepixel = 1.0f / (dim.Width * 1.5f); - } - - f32 l = 10.0f; - f32 t = 1.0f - onepixel; - f32 o = 0.0f + onepixel; - - Material[0] = mat; - Material[0].Textures[0] = front; - Vertices[0] = video::S3DVertex(-l,-l,-l, 0,0,1, video::SColor(255,255,255,255), o, t); - Vertices[1] = video::S3DVertex( l,-l,-l, 0,0,1, video::SColor(255,255,255,255), t, t); - Vertices[2] = video::S3DVertex( l, l,-l, 0,0,1, video::SColor(255,255,255,255), t, o); - Vertices[3] = video::S3DVertex(-l, l,-l, 0,0,1, video::SColor(255,255,255,255), o, o); - - // create left side - - Material[1] = mat; - Material[1].Textures[0] = left; - Vertices[4] = video::S3DVertex( l,-l,-l, -1,0,0, video::SColor(255,255,255,255), o, t); - Vertices[5] = video::S3DVertex( l,-l, l, -1,0,0, video::SColor(255,255,255,255), t, t); - Vertices[6] = video::S3DVertex( l, l, l, -1,0,0, video::SColor(255,255,255,255), t, o); - Vertices[7] = video::S3DVertex( l, l,-l, -1,0,0, video::SColor(255,255,255,255), o, o); - - // create back side - - Material[2] = mat; - Material[2].Textures[0] = back; - Vertices[8] = video::S3DVertex( l,-l, l, 0,0,-1, video::SColor(255,255,255,255), o, t); - Vertices[9] = video::S3DVertex(-l,-l, l, 0,0,-1, video::SColor(255,255,255,255), t, t); - Vertices[10] = video::S3DVertex(-l, l, l, 0,0,-1, video::SColor(255,255,255,255), t, o); - Vertices[11] = video::S3DVertex( l, l, l, 0,0,-1, video::SColor(255,255,255,255), o, o); - - // create right side - - Material[3] = mat; - Material[3].Textures[0] = right; - Vertices[12] = video::S3DVertex(-l,-l, l, 1,0,0, video::SColor(255,255,255,255), o, t); - Vertices[13] = video::S3DVertex(-l,-l,-l, 1,0,0, video::SColor(255,255,255,255), t, t); - Vertices[14] = video::S3DVertex(-l, l,-l, 1,0,0, video::SColor(255,255,255,255), t, o); - Vertices[15] = video::S3DVertex(-l, l, l, 1,0,0, video::SColor(255,255,255,255), o, o); - - // create top side - - Material[4] = mat; - Material[4].Textures[0] = top; - Vertices[16] = video::S3DVertex( l, l, l, 0,-1,0, video::SColor(255,255,255,255), o, o); - Vertices[17] = video::S3DVertex(-l, l, l, 0,-1,0, video::SColor(255,255,255,255), o, t); - Vertices[18] = video::S3DVertex(-l, l,-l, 0,-1,0, video::SColor(255,255,255,255), t, t); - Vertices[19] = video::S3DVertex( l, l,-l, 0,-1,0, video::SColor(255,255,255,255), t, o); - - // create bottom side - - Material[5] = mat; - Material[5].Textures[0] = bottom; - Vertices[20] = video::S3DVertex(-l,-l, l, 0,1,0, video::SColor(255,255,255,255), o, o); - Vertices[21] = video::S3DVertex( l,-l, l, 0,1,0, video::SColor(255,255,255,255), o, t); - Vertices[22] = video::S3DVertex( l,-l,-l, 0,1,0, video::SColor(255,255,255,255), t, t); - Vertices[23] = video::S3DVertex(-l,-l,-l, 0,1,0, video::SColor(255,255,255,255), t, o); -} - - - -//! destructor -CSkyBoxSceneNode::~CSkyBoxSceneNode() -{ -} - - -//! renders the node. -void CSkyBoxSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - scene::ICameraSceneNode* camera = SceneManager->getActiveCamera(); - - if (!camera || !driver) - return; - - if ( !camera->isOrthogonal() ) - { - // draw perspective skybox - - core::matrix4 mat(AbsoluteTransformation); - mat.setTranslation(camera->getAbsolutePosition()); - - driver->setTransform(video::ETS_WORLD, mat); - - for (s32 i=0; i<6; ++i) - { - driver->setMaterial(Material[i]); - driver->drawIndexedTriangleFan(&Vertices[i*4], 4, Indices, 2); - } - } - else - { - // draw orthogonal skybox, - // simply choose one texture and draw it as 2d picture. - // there could be better ways to do this, but currently I think this is ok. - - core::vector3df lookVect = camera->getTarget() - camera->getAbsolutePosition(); - lookVect.normalize(); - core::vector3df absVect( core::abs_(lookVect.X), - core::abs_(lookVect.Y), - core::abs_(lookVect.Z)); - - int idx = 0; - - if ( absVect.X >= absVect.Y && absVect.X >= absVect.Z ) - { - // x direction - idx = lookVect.X > 0 ? 0 : 2; - } - else - if ( absVect.Y >= absVect.X && absVect.Y >= absVect.Z ) - { - // y direction - idx = lookVect.Y > 0 ? 4 : 5; - } - else - if ( absVect.Z >= absVect.X && absVect.Z >= absVect.Y ) - { - // z direction - idx = lookVect.Z > 0 ? 1 : 3; - } - - video::ITexture* tex = Material[idx].Textures[0]; - - if ( tex ) - { - core::rect rctDest(core::position2d(-1,0), driver->getCurrentRenderTargetSize()); - core::rect rctSrc(core::position2d(0,0), tex->getSize()); - - driver->draw2DImage(tex, rctDest, rctSrc); - } - } -} - - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CSkyBoxSceneNode::getBoundingBox() const -{ - return Box; -} - - -void CSkyBoxSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - SceneManager->registerNodeForRendering(this, ESNRP_SKY_BOX); - ISceneNode::OnRegisterSceneNode(); - } -} - - -//! returns the material based on the zero based index i. To get the amount -//! of materials used by this scene node, use getMaterialCount(). -//! This function is needed for inserting the node into the scene hirachy on a -//! optimal position for minimizing renderstate changes, but can also be used -//! to directly modify the material of a scene node. -video::SMaterial& CSkyBoxSceneNode::getMaterial(u32 i) -{ - return Material[i]; -} - - -//! returns amount of materials used by this scene node. -u32 CSkyBoxSceneNode::getMaterialCount() -{ - return 6; -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSkyBoxSceneNode.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" +#include "ICameraSceneNode.h" +#include "S3DVertex.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CSkyBoxSceneNode::CSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, video::ITexture* left, + video::ITexture* right, video::ITexture* front, video::ITexture* back, ISceneNode* parent, ISceneManager* mgr, s32 id) +: ISceneNode(parent, mgr, id) +{ + #ifdef _DEBUG + setDebugName("CSkyBoxSceneNode"); + #endif + + setAutomaticCulling(scene::EAC_OFF); + Box.MaxEdge.set(0,0,0); + Box.MinEdge.set(0,0,0); + + // create indices + + Indices[0] = 0; + Indices[1] = 1; + Indices[2] = 2; + Indices[3] = 3; + + // create material + + video::SMaterial mat; + mat.Lighting = false; + mat.ZBuffer = false; + mat.ZWriteEnable = false; + + /* Hey, I am no artist, but look at that + cool ASCII art I made! ;) + + -111 111 + /6--------/5 y + / | / | ^ z + / | 11-1 | | / + -11-1 3---------2 | |/ + | 7- - -| -4 1-11 *---->x + | -1-11 | / 3-------|2 + |/ | / | //| + 0---------1/ | // | + -1-1-1 1-1-1 |// | + 0--------1 + */ + + f32 onepixel = 0.0f; + + video::ITexture* tex = front; + if (!tex) tex = left; + if (!tex) tex = back; + if (!tex) tex = right; + if (!tex) tex = top; + if (!tex) tex = bottom; + + if (tex) + { + core::dimension2d dim = tex->getSize(); + onepixel = 1.0f / (dim.Width * 1.5f); + } + + f32 l = 10.0f; + f32 t = 1.0f - onepixel; + f32 o = 0.0f + onepixel; + + Material[0] = mat; + Material[0].Textures[0] = front; + Vertices[0] = video::S3DVertex(-l,-l,-l, 0,0,1, video::SColor(255,255,255,255), o, t); + Vertices[1] = video::S3DVertex( l,-l,-l, 0,0,1, video::SColor(255,255,255,255), t, t); + Vertices[2] = video::S3DVertex( l, l,-l, 0,0,1, video::SColor(255,255,255,255), t, o); + Vertices[3] = video::S3DVertex(-l, l,-l, 0,0,1, video::SColor(255,255,255,255), o, o); + + // create left side + + Material[1] = mat; + Material[1].Textures[0] = left; + Vertices[4] = video::S3DVertex( l,-l,-l, -1,0,0, video::SColor(255,255,255,255), o, t); + Vertices[5] = video::S3DVertex( l,-l, l, -1,0,0, video::SColor(255,255,255,255), t, t); + Vertices[6] = video::S3DVertex( l, l, l, -1,0,0, video::SColor(255,255,255,255), t, o); + Vertices[7] = video::S3DVertex( l, l,-l, -1,0,0, video::SColor(255,255,255,255), o, o); + + // create back side + + Material[2] = mat; + Material[2].Textures[0] = back; + Vertices[8] = video::S3DVertex( l,-l, l, 0,0,-1, video::SColor(255,255,255,255), o, t); + Vertices[9] = video::S3DVertex(-l,-l, l, 0,0,-1, video::SColor(255,255,255,255), t, t); + Vertices[10] = video::S3DVertex(-l, l, l, 0,0,-1, video::SColor(255,255,255,255), t, o); + Vertices[11] = video::S3DVertex( l, l, l, 0,0,-1, video::SColor(255,255,255,255), o, o); + + // create right side + + Material[3] = mat; + Material[3].Textures[0] = right; + Vertices[12] = video::S3DVertex(-l,-l, l, 1,0,0, video::SColor(255,255,255,255), o, t); + Vertices[13] = video::S3DVertex(-l,-l,-l, 1,0,0, video::SColor(255,255,255,255), t, t); + Vertices[14] = video::S3DVertex(-l, l,-l, 1,0,0, video::SColor(255,255,255,255), t, o); + Vertices[15] = video::S3DVertex(-l, l, l, 1,0,0, video::SColor(255,255,255,255), o, o); + + // create top side + + Material[4] = mat; + Material[4].Textures[0] = top; + Vertices[16] = video::S3DVertex( l, l, l, 0,-1,0, video::SColor(255,255,255,255), o, o); + Vertices[17] = video::S3DVertex(-l, l, l, 0,-1,0, video::SColor(255,255,255,255), o, t); + Vertices[18] = video::S3DVertex(-l, l,-l, 0,-1,0, video::SColor(255,255,255,255), t, t); + Vertices[19] = video::S3DVertex( l, l,-l, 0,-1,0, video::SColor(255,255,255,255), t, o); + + // create bottom side + + Material[5] = mat; + Material[5].Textures[0] = bottom; + Vertices[20] = video::S3DVertex(-l,-l, l, 0,1,0, video::SColor(255,255,255,255), o, o); + Vertices[21] = video::S3DVertex( l,-l, l, 0,1,0, video::SColor(255,255,255,255), o, t); + Vertices[22] = video::S3DVertex( l,-l,-l, 0,1,0, video::SColor(255,255,255,255), t, t); + Vertices[23] = video::S3DVertex(-l,-l,-l, 0,1,0, video::SColor(255,255,255,255), t, o); +} + + + +//! destructor +CSkyBoxSceneNode::~CSkyBoxSceneNode() +{ +} + + +//! renders the node. +void CSkyBoxSceneNode::render() +{ + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + scene::ICameraSceneNode* camera = SceneManager->getActiveCamera(); + + if (!camera || !driver) + return; + + if ( !camera->isOrthogonal() ) + { + // draw perspective skybox + + core::matrix4 mat(AbsoluteTransformation); + mat.setTranslation(camera->getAbsolutePosition()); + + driver->setTransform(video::ETS_WORLD, mat); + + for (s32 i=0; i<6; ++i) + { + driver->setMaterial(Material[i]); + driver->drawIndexedTriangleFan(&Vertices[i*4], 4, Indices, 2); + } + } + else + { + // draw orthogonal skybox, + // simply choose one texture and draw it as 2d picture. + // there could be better ways to do this, but currently I think this is ok. + + core::vector3df lookVect = camera->getTarget() - camera->getAbsolutePosition(); + lookVect.normalize(); + core::vector3df absVect( core::abs_(lookVect.X), + core::abs_(lookVect.Y), + core::abs_(lookVect.Z)); + + int idx = 0; + + if ( absVect.X >= absVect.Y && absVect.X >= absVect.Z ) + { + // x direction + idx = lookVect.X > 0 ? 0 : 2; + } + else + if ( absVect.Y >= absVect.X && absVect.Y >= absVect.Z ) + { + // y direction + idx = lookVect.Y > 0 ? 4 : 5; + } + else + if ( absVect.Z >= absVect.X && absVect.Z >= absVect.Y ) + { + // z direction + idx = lookVect.Z > 0 ? 1 : 3; + } + + video::ITexture* tex = Material[idx].Textures[0]; + + if ( tex ) + { + core::rect rctDest(core::position2d(-1,0), driver->getCurrentRenderTargetSize()); + core::rect rctSrc(core::position2d(0,0), tex->getSize()); + + driver->draw2DImage(tex, rctDest, rctSrc); + } + } +} + + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CSkyBoxSceneNode::getBoundingBox() const +{ + return Box; +} + + +void CSkyBoxSceneNode::OnRegisterSceneNode() +{ + if (IsVisible) + { + SceneManager->registerNodeForRendering(this, ESNRP_SKY_BOX); + ISceneNode::OnRegisterSceneNode(); + } +} + + +//! returns the material based on the zero based index i. To get the amount +//! of materials used by this scene node, use getMaterialCount(). +//! This function is needed for inserting the node into the scene hirachy on a +//! optimal position for minimizing renderstate changes, but can also be used +//! to directly modify the material of a scene node. +video::SMaterial& CSkyBoxSceneNode::getMaterial(u32 i) +{ + return Material[i]; +} + + +//! returns amount of materials used by this scene node. +u32 CSkyBoxSceneNode::getMaterialCount() +{ + return 6; +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CSkyBoxSceneNode.h b/src/dep/src/irrlicht/CSkyBoxSceneNode.h index d846f00..ddeddd1 100644 --- a/src/dep/src/irrlicht/CSkyBoxSceneNode.h +++ b/src/dep/src/irrlicht/CSkyBoxSceneNode.h @@ -1,62 +1,62 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SKY_BOX_SCENE_NODE_H_INCLUDED__ -#define __C_SKY_BOX_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "S3DVertex.h" - -namespace irr -{ -namespace scene -{ - - // Skybox, rendererd with zbuffer turned off, before all other nodes. - class CSkyBoxSceneNode : public ISceneNode - { - public: - - //! constructor - CSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, video::ITexture* left, - video::ITexture* right, video::ITexture* front, video::ITexture* back, - ISceneNode* parent, ISceneManager* mgr, s32 id); - - //! destructor - virtual ~CSkyBoxSceneNode(); - - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! returns the material based on the zero based index i. To get the amount - //! of materials used by this scene node, use getMaterialCount(). - //! This function is needed for inserting the node into the scene hirachy on a - //! optimal position for minimizing renderstate changes, but can also be used - //! to directly modify the material of a scene node. - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount(); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_SKY_BOX; } - - private: - - core::aabbox3d Box; - u16 Indices[4]; - video::S3DVertex Vertices[4*6]; - video::SMaterial Material[6]; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_SKY_BOX_SCENE_NODE_H_INCLUDED__ +#define __C_SKY_BOX_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" +#include "S3DVertex.h" + +namespace irr +{ +namespace scene +{ + + // Skybox, rendererd with zbuffer turned off, before all other nodes. + class CSkyBoxSceneNode : public ISceneNode + { + public: + + //! constructor + CSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, video::ITexture* left, + video::ITexture* right, video::ITexture* front, video::ITexture* back, + ISceneNode* parent, ISceneManager* mgr, s32 id); + + //! destructor + virtual ~CSkyBoxSceneNode(); + + virtual void OnRegisterSceneNode(); + + //! renders the node. + virtual void render(); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! returns the material based on the zero based index i. To get the amount + //! of materials used by this scene node, use getMaterialCount(). + //! This function is needed for inserting the node into the scene hirachy on a + //! optimal position for minimizing renderstate changes, but can also be used + //! to directly modify the material of a scene node. + virtual video::SMaterial& getMaterial(u32 i); + + //! returns amount of materials used by this scene node. + virtual u32 getMaterialCount(); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_SKY_BOX; } + + private: + + core::aabbox3d Box; + u16 Indices[4]; + video::S3DVertex Vertices[4*6]; + video::SMaterial Material[6]; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CSkyDomeSceneNode.cpp b/src/dep/src/irrlicht/CSkyDomeSceneNode.cpp index 4d6f659..6e6f1f1 100644 --- a/src/dep/src/irrlicht/CSkyDomeSceneNode.cpp +++ b/src/dep/src/irrlicht/CSkyDomeSceneNode.cpp @@ -1,172 +1,172 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// Code for this scene node has been contributed by Anders la Cour-Harbo (alc) - -#include "CSkyDomeSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "ICameraSceneNode.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -/* horiRes and vertRes: - Controls the number of faces along the horizontal axis (30 is a good value) - and the number of faces along the vertical axis (8 is a good value). - - texturePercentage: - Only the top texturePercentage of the image is used, e.g. 0.8 uses the top 80% of the image, - 1.0 uses the entire image. This is useful as some landscape images have a small banner - at the bottom that you don't want. - - spherePercentage: - This controls how far around the sphere the sky dome goes. For value 1.0 you get exactly the upper - hemisphere, for 1.1 you get slightly more, and for 2.0 you get a full sphere. It is sometimes useful - to use a value slightly bigger than 1 to avoid a gap between some ground place and the sky. This - parameters stretches the image to fit the chosen "sphere-size". */ - -CSkyDomeSceneNode::CSkyDomeSceneNode(video::ITexture* sky, u32 horiRes, u32 vertRes, - f64 texturePercentage, f64 spherePercentage, ISceneNode* parent, ISceneManager* mgr, s32 id) - : ISceneNode(parent, mgr, id) -{ - #ifdef _DEBUG - setDebugName("CSkyDomeSceneNode"); - #endif - - f64 radius = 1000.0; /* Adjust this to get more or less perspective distorsion. */ - f64 azimuth, azimuth_step; - f64 elevation, elevation_step; - u32 k, c; - - video::S3DVertex vtx; - - AutomaticCullingState = scene::EAC_OFF; - - Buffer.Material.Lighting = false; - Buffer.Material.ZBuffer = false; - Buffer.Material.ZWriteEnable = false; - Buffer.Material.Textures[0] = sky; - Buffer.BoundingBox.MaxEdge.set(0,0,0); - Buffer.BoundingBox.MinEdge.set(0,0,0); - - azimuth_step = 2.*core::PI64/(f64)horiRes; - if (spherePercentage<0.) - spherePercentage=-spherePercentage; - if (spherePercentage>2.) - spherePercentage=2.; - elevation_step = spherePercentage*core::PI64/2./(f64)vertRes; - - Buffer.Vertices.set_used((horiRes+1)*(vertRes+1)); - Buffer.Indices.set_used(3*(2*vertRes-1)*horiRes); - - vtx.Color.set(255,255,255,255); - vtx.Normal.set(0.0f,0.0f,0.0f); - - c = 0; - for (k = 0, azimuth = 0; k <= horiRes; ++k) - { - elevation = core::PI64/2.; - for (u32 j = 0; j <= vertRes; ++j) - { - vtx.Pos.set((f32) (radius*cos(elevation)*sin(azimuth)), - (f32) (radius*sin(elevation)+50.0f), - (f32) (radius*cos(elevation)*cos(azimuth))); - - vtx.TCoords.set((f32)k/(f32)horiRes, (f32)j/(f32)vertRes*(f32)texturePercentage); - - Buffer.Vertices[c++] = vtx; - elevation -= elevation_step; - } - azimuth += azimuth_step; - } - - c = 0; - for (k = 0; k < horiRes; ++k) - { - Buffer.Indices[c++] = vertRes+2+(vertRes+1)*k; - Buffer.Indices[c++] = 1+(vertRes+1)*k; - Buffer.Indices[c++] = 0+(vertRes+1)*k; - - for (u32 j = 1; j < vertRes; ++j) - { - Buffer.Indices[c++] = vertRes+2+(vertRes+1)*k+j; - Buffer.Indices[c++] = 1+(vertRes+1)*k+j; - Buffer.Indices[c++] = 0+(vertRes+1)*k+j; - - Buffer.Indices[c++] = vertRes+1+(vertRes+1)*k+j; - Buffer.Indices[c++] = vertRes+2+(vertRes+1)*k+j; - Buffer.Indices[c++] = 0+(vertRes+1)*k+j; - } - } -} - - -//! destructor -CSkyDomeSceneNode::~CSkyDomeSceneNode() -{ -} - - -//! renders the node. -void CSkyDomeSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - scene::ICameraSceneNode* camera = SceneManager->getActiveCamera(); - - if (!camera || !driver) - return; - - if ( !camera->isOrthogonal() ) - { - core::matrix4 mat(AbsoluteTransformation); - mat.setTranslation(camera->getAbsolutePosition()); - - driver->setTransform(video::ETS_WORLD, mat); - - driver->setMaterial(Buffer.Material); - driver->drawMeshBuffer(&Buffer); - } -} - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CSkyDomeSceneNode::getBoundingBox() const -{ - return Buffer.BoundingBox; -} - - -void CSkyDomeSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - SceneManager->registerNodeForRendering(this, ESNRP_SKY_BOX); - ISceneNode::OnRegisterSceneNode(); - } -} - - -//! returns the material based on the zero based index i. To get the amount -//! of materials used by this scene node, use getMaterialCount(). -//! This function is needed for inserting the node into the scene hirachy on a -//! optimal position for minimizing renderstate changes, but can also be used -//! to directly modify the material of a scene node. -video::SMaterial& CSkyDomeSceneNode::getMaterial(u32 i) -{ - return Buffer.Material; -} - - -//! returns amount of materials used by this scene node. -u32 CSkyDomeSceneNode::getMaterialCount() -{ - return 1; -} - - -} -} - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// Code for this scene node has been contributed by Anders la Cour-Harbo (alc) + +#include "CSkyDomeSceneNode.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" +#include "ICameraSceneNode.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +/* horiRes and vertRes: + Controls the number of faces along the horizontal axis (30 is a good value) + and the number of faces along the vertical axis (8 is a good value). + + texturePercentage: + Only the top texturePercentage of the image is used, e.g. 0.8 uses the top 80% of the image, + 1.0 uses the entire image. This is useful as some landscape images have a small banner + at the bottom that you don't want. + + spherePercentage: + This controls how far around the sphere the sky dome goes. For value 1.0 you get exactly the upper + hemisphere, for 1.1 you get slightly more, and for 2.0 you get a full sphere. It is sometimes useful + to use a value slightly bigger than 1 to avoid a gap between some ground place and the sky. This + parameters stretches the image to fit the chosen "sphere-size". */ + +CSkyDomeSceneNode::CSkyDomeSceneNode(video::ITexture* sky, u32 horiRes, u32 vertRes, + f64 texturePercentage, f64 spherePercentage, ISceneNode* parent, ISceneManager* mgr, s32 id) + : ISceneNode(parent, mgr, id) +{ + #ifdef _DEBUG + setDebugName("CSkyDomeSceneNode"); + #endif + + f64 radius = 1000.0; /* Adjust this to get more or less perspective distorsion. */ + f64 azimuth, azimuth_step; + f64 elevation, elevation_step; + u32 k, c; + + video::S3DVertex vtx; + + AutomaticCullingState = scene::EAC_OFF; + + Buffer.Material.Lighting = false; + Buffer.Material.ZBuffer = false; + Buffer.Material.ZWriteEnable = false; + Buffer.Material.Textures[0] = sky; + Buffer.BoundingBox.MaxEdge.set(0,0,0); + Buffer.BoundingBox.MinEdge.set(0,0,0); + + azimuth_step = 2.*core::PI64/(f64)horiRes; + if (spherePercentage<0.) + spherePercentage=-spherePercentage; + if (spherePercentage>2.) + spherePercentage=2.; + elevation_step = spherePercentage*core::PI64/2./(f64)vertRes; + + Buffer.Vertices.set_used((horiRes+1)*(vertRes+1)); + Buffer.Indices.set_used(3*(2*vertRes-1)*horiRes); + + vtx.Color.set(255,255,255,255); + vtx.Normal.set(0.0f,0.0f,0.0f); + + c = 0; + for (k = 0, azimuth = 0; k <= horiRes; ++k) + { + elevation = core::PI64/2.; + for (u32 j = 0; j <= vertRes; ++j) + { + vtx.Pos.set((f32) (radius*cos(elevation)*sin(azimuth)), + (f32) (radius*sin(elevation)+50.0f), + (f32) (radius*cos(elevation)*cos(azimuth))); + + vtx.TCoords.set((f32)k/(f32)horiRes, (f32)j/(f32)vertRes*(f32)texturePercentage); + + Buffer.Vertices[c++] = vtx; + elevation -= elevation_step; + } + azimuth += azimuth_step; + } + + c = 0; + for (k = 0; k < horiRes; ++k) + { + Buffer.Indices[c++] = vertRes+2+(vertRes+1)*k; + Buffer.Indices[c++] = 1+(vertRes+1)*k; + Buffer.Indices[c++] = 0+(vertRes+1)*k; + + for (u32 j = 1; j < vertRes; ++j) + { + Buffer.Indices[c++] = vertRes+2+(vertRes+1)*k+j; + Buffer.Indices[c++] = 1+(vertRes+1)*k+j; + Buffer.Indices[c++] = 0+(vertRes+1)*k+j; + + Buffer.Indices[c++] = vertRes+1+(vertRes+1)*k+j; + Buffer.Indices[c++] = vertRes+2+(vertRes+1)*k+j; + Buffer.Indices[c++] = 0+(vertRes+1)*k+j; + } + } +} + + +//! destructor +CSkyDomeSceneNode::~CSkyDomeSceneNode() +{ +} + + +//! renders the node. +void CSkyDomeSceneNode::render() +{ + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + scene::ICameraSceneNode* camera = SceneManager->getActiveCamera(); + + if (!camera || !driver) + return; + + if ( !camera->isOrthogonal() ) + { + core::matrix4 mat(AbsoluteTransformation); + mat.setTranslation(camera->getAbsolutePosition()); + + driver->setTransform(video::ETS_WORLD, mat); + + driver->setMaterial(Buffer.Material); + driver->drawMeshBuffer(&Buffer); + } +} + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CSkyDomeSceneNode::getBoundingBox() const +{ + return Buffer.BoundingBox; +} + + +void CSkyDomeSceneNode::OnRegisterSceneNode() +{ + if (IsVisible) + { + SceneManager->registerNodeForRendering(this, ESNRP_SKY_BOX); + ISceneNode::OnRegisterSceneNode(); + } +} + + +//! returns the material based on the zero based index i. To get the amount +//! of materials used by this scene node, use getMaterialCount(). +//! This function is needed for inserting the node into the scene hirachy on a +//! optimal position for minimizing renderstate changes, but can also be used +//! to directly modify the material of a scene node. +video::SMaterial& CSkyDomeSceneNode::getMaterial(u32 i) +{ + return Buffer.Material; +} + + +//! returns amount of materials used by this scene node. +u32 CSkyDomeSceneNode::getMaterialCount() +{ + return 1; +} + + +} +} + diff --git a/src/dep/src/irrlicht/CSkyDomeSceneNode.h b/src/dep/src/irrlicht/CSkyDomeSceneNode.h index 9f690f9..a0e127e 100644 --- a/src/dep/src/irrlicht/CSkyDomeSceneNode.h +++ b/src/dep/src/irrlicht/CSkyDomeSceneNode.h @@ -1,40 +1,40 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// Code for this scene node has been contributed by Anders la Cour-Harbo (alc) - -#ifndef __C_SKY_DOME_SCENE_NODE_H_INCLUDED__ -#define __C_SKY_DOME_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "SMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - -class CSkyDomeSceneNode : public ISceneNode -{ - public: - CSkyDomeSceneNode(video::ITexture* texture, u32 horiRes, u32 vertRes, - f64 texturePercentage, f64 spherePercentage, ISceneNode* root, - ISceneManager* smgr, s32 id); - virtual ~CSkyDomeSceneNode(); - virtual void OnRegisterSceneNode(); - virtual void render(); - virtual const core::aabbox3d& getBoundingBox() const; - virtual video::SMaterial& getMaterial(u32 i); - virtual u32 getMaterialCount(); - virtual ESCENE_NODE_TYPE getType() { return ESNT_SKY_BOX; } - - private: - SMeshBuffer Buffer; -}; - - -} -} - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// Code for this scene node has been contributed by Anders la Cour-Harbo (alc) + +#ifndef __C_SKY_DOME_SCENE_NODE_H_INCLUDED__ +#define __C_SKY_DOME_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" +#include "SMeshBuffer.h" + +namespace irr +{ +namespace scene +{ + +class CSkyDomeSceneNode : public ISceneNode +{ + public: + CSkyDomeSceneNode(video::ITexture* texture, u32 horiRes, u32 vertRes, + f64 texturePercentage, f64 spherePercentage, ISceneNode* root, + ISceneManager* smgr, s32 id); + virtual ~CSkyDomeSceneNode(); + virtual void OnRegisterSceneNode(); + virtual void render(); + virtual const core::aabbox3d& getBoundingBox() const; + virtual video::SMaterial& getMaterial(u32 i); + virtual u32 getMaterialCount(); + virtual ESCENE_NODE_TYPE getType() { return ESNT_SKY_BOX; } + + private: + SMeshBuffer Buffer; +}; + + +} +} + +#endif + diff --git a/src/dep/src/irrlicht/CSoftware2MaterialRenderer.h b/src/dep/src/irrlicht/CSoftware2MaterialRenderer.h index 6037f5e..e2b7427 100644 --- a/src/dep/src/irrlicht/CSoftware2MaterialRenderer.h +++ b/src/dep/src/irrlicht/CSoftware2MaterialRenderer.h @@ -1,83 +1,83 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SOFTWARE2_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_SOFTWARE2_MATERIAL_RENDERER_H_INCLUDED__ - -#include "SoftwareDriver2_compile_config.h" - -#include "IMaterialRenderer.h" -#include "CSoftwareDriver2.h" - -namespace irr -{ -namespace video -{ - -//! Base class for all internal Software2 material renderers -class CSoftware2MaterialRenderer : public IMaterialRenderer -{ -public: - - //! Constructor - CSoftware2MaterialRenderer(video::CSoftwareDriver2* driver) - : Driver(driver) - { - } - -protected: - - video::CSoftwareDriver2* Driver; -}; - -//! solid material renderer -class CSoftware2MaterialRenderer_SOLID : public CSoftware2MaterialRenderer -{ -public: - CSoftware2MaterialRenderer_SOLID ( video::CSoftwareDriver2* driver ) - :CSoftware2MaterialRenderer ( driver ) {} - - //! Returns if the material is transparent. - virtual bool isTransparent() - { - return false; - } - -}; - - - -//! Transparent material renderer -class CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR : public CSoftware2MaterialRenderer -{ -public: - CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR ( video::CSoftwareDriver2* driver ) - :CSoftware2MaterialRenderer ( driver ) {} - - - //! Returns if the material is transparent. - virtual bool isTransparent() - { - return true; - } - -}; - -//! unsupported material renderer -class CSoftware2MaterialRenderer_UNSUPPORTED : public CSoftware2MaterialRenderer -{ -public: - CSoftware2MaterialRenderer_UNSUPPORTED ( video::CSoftwareDriver2* driver ) - :CSoftware2MaterialRenderer ( driver ) {} - - virtual s32 getRenderCapability() { return 1; } - -}; - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_SOFTWARE2_MATERIAL_RENDERER_H_INCLUDED__ +#define __C_SOFTWARE2_MATERIAL_RENDERER_H_INCLUDED__ + +#include "SoftwareDriver2_compile_config.h" + +#include "IMaterialRenderer.h" +#include "CSoftwareDriver2.h" + +namespace irr +{ +namespace video +{ + +//! Base class for all internal Software2 material renderers +class CSoftware2MaterialRenderer : public IMaterialRenderer +{ +public: + + //! Constructor + CSoftware2MaterialRenderer(video::CSoftwareDriver2* driver) + : Driver(driver) + { + } + +protected: + + video::CSoftwareDriver2* Driver; +}; + +//! solid material renderer +class CSoftware2MaterialRenderer_SOLID : public CSoftware2MaterialRenderer +{ +public: + CSoftware2MaterialRenderer_SOLID ( video::CSoftwareDriver2* driver ) + :CSoftware2MaterialRenderer ( driver ) {} + + //! Returns if the material is transparent. + virtual bool isTransparent() + { + return false; + } + +}; + + + +//! Transparent material renderer +class CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR : public CSoftware2MaterialRenderer +{ +public: + CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR ( video::CSoftwareDriver2* driver ) + :CSoftware2MaterialRenderer ( driver ) {} + + + //! Returns if the material is transparent. + virtual bool isTransparent() + { + return true; + } + +}; + +//! unsupported material renderer +class CSoftware2MaterialRenderer_UNSUPPORTED : public CSoftware2MaterialRenderer +{ +public: + CSoftware2MaterialRenderer_UNSUPPORTED ( video::CSoftwareDriver2* driver ) + :CSoftware2MaterialRenderer ( driver ) {} + + virtual s32 getRenderCapability() { return 1; } + +}; + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CSoftwareDriver.cpp b/src/dep/src/irrlicht/CSoftwareDriver.cpp index 4328fba..ce52b7b 100644 --- a/src/dep/src/irrlicht/CSoftwareDriver.cpp +++ b/src/dep/src/irrlicht/CSoftwareDriver.cpp @@ -1,876 +1,876 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSoftwareDriver.h" - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -#include "CSoftwareTexture.h" -#include "os.h" -#include "S3DVertex.h" - -namespace irr -{ -namespace video -{ - - -//! constructor -CSoftwareDriver::CSoftwareDriver(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter) -: CNullDriver(io, windowSize), RenderTargetTexture(0), RenderTargetSurface(0), - CurrentTriangleRenderer(0), ZBuffer(0), Texture(0) -{ - #ifdef _DEBUG - setDebugName("CSoftwareDriver"); - #endif - - // create backbuffer - - BackBuffer = new CImage(ECF_A1R5G5B5, windowSize); - BackBuffer->fill(SColor(0)); - - // get presenter - - Presenter = presenter; - - // create z buffer - - ZBuffer = irr::video::createZBuffer(BackBuffer->getDimension()); - - // create triangle renderers - - TriangleRenderers[ETR_FLAT] = createTriangleRendererFlat(ZBuffer); - TriangleRenderers[ETR_FLAT_WIRE] = createTriangleRendererFlatWire(ZBuffer); - TriangleRenderers[ETR_GOURAUD] = createTriangleRendererGouraud(ZBuffer); - TriangleRenderers[ETR_GOURAUD_WIRE] = createTriangleRendererGouraudWire(ZBuffer); - TriangleRenderers[ETR_TEXTURE_FLAT] = createTriangleRendererTextureFlat(ZBuffer); - TriangleRenderers[ETR_TEXTURE_FLAT_WIRE] = createTriangleRendererTextureFlatWire(ZBuffer); - TriangleRenderers[ETR_TEXTURE_GOURAUD] = createTriangleRendererTextureGouraud(ZBuffer); - TriangleRenderers[ETR_TEXTURE_GOURAUD_WIRE] = createTriangleRendererTextureGouraudWire(ZBuffer); - TriangleRenderers[ETR_TEXTURE_GOURAUD_NOZ] = createTriangleRendererTextureGouraudNoZ(); - TriangleRenderers[ETR_TEXTURE_GOURAUD_ADD] = createTriangleRendererTextureGouraudAdd(ZBuffer); - - // select render target - - setRenderTarget(BackBuffer); - - // select the right renderer - - selectRightTriangleRenderer(); -} - - - -//! destructor -CSoftwareDriver::~CSoftwareDriver() -{ - // delete Backbuffer - BackBuffer->drop(); - - // delete triangle renderers - - for (s32 i=0; idrop(); - - // delete zbuffer - - if (ZBuffer) - ZBuffer->drop(); - - // delete current texture - - if (Texture) - Texture->drop(); - - if (RenderTargetTexture) - RenderTargetTexture->drop(); - - if (RenderTargetSurface) - RenderTargetSurface->drop(); -} - - - -//! switches to a triangle renderer -void CSoftwareDriver::switchToTriangleRenderer(ETriangleRenderer renderer) -{ - video::IImage* s = 0; - if (Texture) - s = ((CSoftwareTexture*)Texture)->getTexture(); - - CurrentTriangleRenderer = TriangleRenderers[renderer]; - CurrentTriangleRenderer->setBackfaceCulling(Material.BackfaceCulling == true); - CurrentTriangleRenderer->setTexture(s); - CurrentTriangleRenderer->setRenderTarget(RenderTargetSurface, ViewPort); -} - - -//! void selects the right triangle renderer based on the render states. -void CSoftwareDriver::selectRightTriangleRenderer() -{ - - ETriangleRenderer renderer = ETR_FLAT; - - if (Texture) - { - if (!Material.GouraudShading) - renderer = (!Material.Wireframe) ? ETR_TEXTURE_FLAT : ETR_TEXTURE_FLAT_WIRE; - else - { - if (Material.Wireframe) - renderer = ETR_TEXTURE_GOURAUD_WIRE; - else - { - if (Material.MaterialType == EMT_TRANSPARENT_ADD_COLOR || - Material.MaterialType == EMT_TRANSPARENT_ALPHA_CHANNEL || - Material.MaterialType == EMT_TRANSPARENT_VERTEX_ALPHA) - { - // simply draw all transparent stuff with the same renderer. at - // least it is transparent then. - renderer = ETR_TEXTURE_GOURAUD_ADD; - } - else - if (!Material.ZBuffer && !Material.ZWriteEnable) - renderer = ETR_TEXTURE_GOURAUD_NOZ; - else - { - renderer = ETR_TEXTURE_GOURAUD; - } - } - } - } - else - { - if (!Material.GouraudShading) - renderer = (!Material.Wireframe) ? ETR_FLAT : ETR_FLAT_WIRE; - else - renderer = (!Material.Wireframe) ? ETR_GOURAUD : ETR_GOURAUD_WIRE; - } - - switchToTriangleRenderer(renderer); -} - - - - -//! presents the rendered scene on the screen, returns false if failed -bool CSoftwareDriver::endScene( s32 windowId, core::rect* sourceRect ) -{ - CNullDriver::endScene(); - - Presenter->present(BackBuffer, windowId, sourceRect ); - return true; -} - - - -//! queries the features of the driver, returns true if feature is available -bool CSoftwareDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) -{ - switch (feature) - { - case EVDF_RENDER_TO_TARGET: - return true; - default: - return false; - }; -} - - - -//! sets transformation -void CSoftwareDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) -{ - TransformationMatrix[state] = mat; -} - - - - -//! sets the current Texture -bool CSoftwareDriver::setTexture(video::ITexture* texture) -{ - if (texture && texture->getDriverType() != EDT_SOFTWARE) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - if (Texture) - Texture->drop(); - - Texture = texture; - - if (Texture) - Texture->grab(); - - selectRightTriangleRenderer(); - return true; -} - - - -//! sets a material -void CSoftwareDriver::setMaterial(const SMaterial& material) -{ - Material = material; - - for (u32 i = 0; i < 1; ++i) - { - setTexture(Material.Textures[i]); - setTransform ((E_TRANSFORMATION_STATE) ( ETS_TEXTURE_0 + i ), - material.getTextureMatrix(i)); - } -} - - -//! clears the zbuffer -bool CSoftwareDriver::beginScene(bool backBuffer, bool zBuffer, SColor color) -{ - CNullDriver::beginScene(backBuffer, zBuffer, color); - - if (backBuffer) - BackBuffer->fill( color ); - - if (ZBuffer && zBuffer) - ZBuffer->clear(); - - return true; -} - - -//! sets a render target -bool CSoftwareDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color) -{ - if (texture && texture->getDriverType() != EDT_SOFTWARE) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - if (RenderTargetTexture) - RenderTargetTexture->drop(); - - RenderTargetTexture = texture; - - if (RenderTargetTexture) - { - RenderTargetTexture->grab(); - setRenderTarget(((CSoftwareTexture*)RenderTargetTexture)->getTexture()); - } - else - { - setRenderTarget(BackBuffer); - } - - if (RenderTargetSurface && (clearBackBuffer || clearZBuffer)) - { - if (clearZBuffer) - ZBuffer->clear(); - - if (clearBackBuffer) - ((video::CImage*)RenderTargetSurface)->fill( color ); - } - - return true; -} - - -//! sets a render target -void CSoftwareDriver::setRenderTarget(video::CImage* image) -{ - if (RenderTargetSurface) - RenderTargetSurface->drop(); - - RenderTargetSurface = image; - RenderTargetSize.Width = 0; - RenderTargetSize.Height = 0; - Render2DTranslation.X = 0; - Render2DTranslation.Y = 0; - - if (RenderTargetSurface) - { - RenderTargetSurface->grab(); - RenderTargetSize = RenderTargetSurface->getDimension(); - } - - setViewPort(core::rect(0,0,RenderTargetSize.Width,RenderTargetSize.Height)); - - if (ZBuffer) - ZBuffer->setSize(RenderTargetSize); -} - - - -//! sets a viewport -void CSoftwareDriver::setViewPort(const core::rect& area) -{ - ViewPort = area; - - //TODO: the clipping is not correct, because the projection is affected. - // to correct this, ViewPortSize and Render2DTranslation will have to be corrected. - core::rect rendert(0,0,RenderTargetSize.Width,RenderTargetSize.Height); - ViewPort.clipAgainst(rendert); - - ViewPortSize = ViewPort.getSize(); - Render2DTranslation.X = (ViewPortSize.Width / 2) + ViewPort.UpperLeftCorner.X; - Render2DTranslation.Y = ViewPort.UpperLeftCorner.Y + ViewPortSize.Height - (ViewPortSize.Height / 2);// + ViewPort.UpperLeftCorner.Y; - - if (CurrentTriangleRenderer) - CurrentTriangleRenderer->setRenderTarget(RenderTargetSurface, ViewPort); -} - - -//! draws a vertex primitive list -void CSoftwareDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) -{ - const u16* indexPointer=0; - core::array newBuffer; - switch (pType) - { - case scene::EPT_LINE_STRIP: - { - switch (vType) - { - case EVT_STANDARD: - { - for (u32 i=0; i < primitiveCount-1; ++i) - draw3DLine(((S3DVertex*)vertices)[indexList[i]].Pos, - ((S3DVertex*)vertices)[indexList[i+1]].Pos, - ((S3DVertex*)vertices)[indexList[i]].Color); - } - break; - case EVT_2TCOORDS: - { - for (u32 i=0; i < primitiveCount-1; ++i) - draw3DLine(((S3DVertex2TCoords*)vertices)[indexList[i]].Pos, - ((S3DVertex2TCoords*)vertices)[indexList[i+1]].Pos, - ((S3DVertex2TCoords*)vertices)[indexList[i]].Color); - } - break; - case EVT_TANGENTS: - { - for (u32 i=0; i < primitiveCount-1; ++i) - draw3DLine(((S3DVertexTangents*)vertices)[indexList[i]].Pos, - ((S3DVertexTangents*)vertices)[indexList[i+1]].Pos, - ((S3DVertexTangents*)vertices)[indexList[i]].Color); - } - break; - } - } - return; - case scene::EPT_LINE_LOOP: - drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount-1, vType, scene::EPT_LINE_STRIP); - switch (vType) - { - case EVT_STANDARD: - draw3DLine(((S3DVertex*)vertices)[indexList[primitiveCount-1]].Pos, - ((S3DVertex*)vertices)[indexList[0]].Pos, - ((S3DVertex*)vertices)[indexList[primitiveCount-1]].Color); - break; - case EVT_2TCOORDS: - draw3DLine(((S3DVertex2TCoords*)vertices)[indexList[primitiveCount-1]].Pos, - ((S3DVertex2TCoords*)vertices)[indexList[0]].Pos, - ((S3DVertex2TCoords*)vertices)[indexList[primitiveCount-1]].Color); - break; - case EVT_TANGENTS: - draw3DLine(((S3DVertexTangents*)vertices)[indexList[primitiveCount-1]].Pos, - ((S3DVertexTangents*)vertices)[indexList[0]].Pos, - ((S3DVertexTangents*)vertices)[indexList[primitiveCount-1]].Color); - break; - } - return; - case scene::EPT_LINES: - { - switch (vType) - { - case EVT_STANDARD: - { - for (u32 i=0; i < 2*primitiveCount; i+=2) - draw3DLine(((S3DVertex*)vertices)[indexList[i]].Pos, - ((S3DVertex*)vertices)[indexList[i+1]].Pos, - ((S3DVertex*)vertices)[indexList[i]].Color); - } - break; - case EVT_2TCOORDS: - { - for (u32 i=0; i < 2*primitiveCount; i+=2) - draw3DLine(((S3DVertex2TCoords*)vertices)[indexList[i]].Pos, - ((S3DVertex2TCoords*)vertices)[indexList[i+1]].Pos, - ((S3DVertex2TCoords*)vertices)[indexList[i]].Color); - } - break; - case EVT_TANGENTS: - { - for (u32 i=0; i < 2*primitiveCount; i+=2) - draw3DLine(((S3DVertexTangents*)vertices)[indexList[i]].Pos, - ((S3DVertexTangents*)vertices)[indexList[i+1]].Pos, - ((S3DVertexTangents*)vertices)[indexList[i]].Color); - } - break; - } - } - return; - case scene::EPT_TRIANGLE_FAN: - { - // TODO: don't convert fan to list - newBuffer.reallocate(primitiveCount*3); - for( u32 t=0; t -void CSoftwareDriver::drawClippedIndexedTriangleListT(const VERTEXTYPE* vertices, - s32 vertexCount, const u16* indexList, s32 triangleCount) -{ - if (!RenderTargetSurface || !ZBuffer || !triangleCount) - return; - - if (!checkPrimitiveCount(triangleCount)) - return; - - // arrays for storing clipped vertices - core::array clippedVertices; - core::array clippedIndices; - - // calculate inverse world transformation - core::matrix4 worldinv(TransformationMatrix[ETS_WORLD]); - worldinv.makeInverse(); - - // calculate view frustum planes - scene::SViewFrustum frustum(TransformationMatrix[ETS_PROJECTION] * TransformationMatrix[ETS_VIEW]); - - // copy and transform clipping planes ignoring far plane - core::plane3df planes[5]; // ordered by near, left, right, bottom, top - for (int p=0; p<5; ++p) - worldinv.transformPlane(frustum.planes[p+1], planes[p]); - - core::EIntersectionRelation3D inout[3]; // is point in front or back of plane? - - // temporary buffer for vertices to be clipped by all planes - core::array tClpBuf; - int t; - - int i; - for (i=0; i textureSize(0,0); - f32 zDiv; - - if (Texture) - textureSize = ((CSoftwareTexture*)Texture)->getTexture()->getDimension(); - - f32 transformedPos[4]; // transform all points in the list - - core::matrix4 matrix(TransformationMatrix[ETS_PROJECTION]); - matrix *= TransformationMatrix[ETS_VIEW]; - matrix *= TransformationMatrix[ETS_WORLD]; - - s32 ViewTransformWidth = (ViewPortSize.Width>>1); - s32 ViewTransformHeight = (ViewPortSize.Height>>1); - - for (i=0; i<(int)clippedVertices.size(); ++i) - { - transformedPos[0] = currentVertex->Pos.X; - transformedPos[1] = currentVertex->Pos.Y; - transformedPos[2] = currentVertex->Pos.Z; - transformedPos[3] = 1.0f; - - matrix.multiplyWith1x4Matrix(transformedPos); - zDiv = transformedPos[3] == 0.0f ? 1.0f : (1.0f / transformedPos[3]); - - tp->Pos.X = (s32)(ViewTransformWidth * (transformedPos[0] * zDiv) + (Render2DTranslation.X)); - tp->Pos.Y = (Render2DTranslation.Y - (s32)(ViewTransformHeight * (transformedPos[1] * zDiv))); - tp->Color = currentVertex->Color.toA1R5G5B5(); - tp->ZValue = (TZBufferType)(32767.0f * zDiv); - - tp->TCoords.X = (s32)(currentVertex->TCoords.X * textureSize.Width); - tp->TCoords.X <<= 8; - tp->TCoords.Y = (s32)(currentVertex->TCoords.Y * textureSize.Height); - tp->TCoords.Y <<= 8; - - ++currentVertex; - ++tp; - } - - // draw all transformed points from the index list - CurrentTriangleRenderer->drawIndexedTriangleList(&TransformedPoints[0], - clippedVertices.size(), clippedIndices.pointer(), clippedIndices.size()/3); -} - - - -//! Draws a 3d line. -void CSoftwareDriver::draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color) -{ - core::vector3df vect = start.crossProduct(end); - vect.normalize(); - vect *= Material.Thickness*0.3f; - - S3DVertex vtx[4]; - - vtx[0].Color = color; - vtx[1].Color = color; - vtx[2].Color = color; - vtx[3].Color = color; - - vtx[0].Pos = start; - vtx[1].Pos = end; - - vtx[2].Pos = start + vect; - vtx[3].Pos = end + vect; - - u16 idx[12] = {0,1,2, 0,2,1, 0,1,3, 0,3,1}; - - drawIndexedTriangleList(vtx, 4, idx, 4); -} - - - -//! clips a triangle against the viewing frustum -void CSoftwareDriver::clipTriangle(f32* transformedPos) -{ -} - - - -//! creates the clipping planes from the matrix -void CSoftwareDriver::createPlanes(const core::matrix4& mat) -{ - Frustum = scene::SViewFrustum(mat); -} - - - -//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. -void CSoftwareDriver::draw2DImage(video::ITexture* texture, const core::position2d& destPos, - const core::rect& sourceRect, - const core::rect* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - if (texture) - { - if (texture->getDriverType() != EDT_SOFTWARE) - { - os::Printer::log("Fatal Error: Tried to copy from a surface not owned by this driver.", ELL_ERROR); - return; - } - - if (useAlphaChannelOfTexture) - ((CSoftwareTexture*)texture)->getImage()->copyToWithAlpha( - ((CImage*)RenderTargetSurface), destPos, sourceRect, color, clipRect); - else - ((CSoftwareTexture*)texture)->getImage()->copyTo( - ((CImage*)RenderTargetSurface), destPos, sourceRect, clipRect); - } -} - - - -//! Draws a 2d line. -void CSoftwareDriver::draw2DLine(const core::position2d& start, - const core::position2d& end, - SColor color) -{ - ((CImage*)RenderTargetSurface)->drawLine(start, end, color ); -} - - - -//! draw a 2d rectangle -void CSoftwareDriver::draw2DRectangle(SColor color, const core::rect& pos, - const core::rect* clip) -{ - if (clip) - { - core::rect p(pos); - - p.clipAgainst(*clip); - - if(!p.isValid()) - return; - - ((CImage*)RenderTargetSurface)->drawRectangle(p, color); - } - else - { - if(!pos.isValid()) - return; - - ((CImage*)RenderTargetSurface)->drawRectangle(pos, color); - } -} - - -//!Draws an 2d rectangle with a gradient. -void CSoftwareDriver::draw2DRectangle(const core::rect& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect* clip) -{ - // TODO: implement - draw2DRectangle(colorLeftUp, pos, clip); -} - - -//! \return Returns the name of the video driver. Example: In case of the Direct3D8 -//! driver, it would return "Direct3D8.1". -const wchar_t* CSoftwareDriver::getName() -{ - return L"Irrlicht Software Device 1.0"; -} - -//! Returns type of video driver -E_DRIVER_TYPE CSoftwareDriver::getDriverType() -{ - return EDT_SOFTWARE; -} - -//! Returns the transformation set by setTransform -const core::matrix4& CSoftwareDriver::getTransform(E_TRANSFORMATION_STATE state) -{ - return TransformationMatrix[state]; -} - -//! Creates a render target texture. -ITexture* CSoftwareDriver::createRenderTargetTexture(const core::dimension2d& size) -{ - CImage* img = new CImage(video::ECF_A1R5G5B5, size); - ITexture* tex = new CSoftwareTexture(img, 0); - img->drop(); - return tex; -} - - -//! Clears the ZBuffer. -void CSoftwareDriver::clearZBuffer() -{ - if (ZBuffer) - ZBuffer->clear(); -} - - -//! Returns an image created from the last rendered frame. -IImage* CSoftwareDriver::createScreenShot() -{ - return new CImage(BackBuffer->getColorFormat(), BackBuffer); -} - - -//! Returns the maximum amount of primitives (mostly vertices) which -//! the device is able to render with one drawIndexedTriangleList -//! call. -u32 CSoftwareDriver::getMaximalPrimitiveCount() -{ - return 0x00800000; -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - - -//! creates a video driver -IVideoDriver* createSoftwareDriver(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CSoftwareDriver(windowSize, fullscreen, io, presenter); - #else - return 0; - #endif -} - - -} // end namespace video -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSoftwareDriver.h" + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_SOFTWARE_ + +#include "CSoftwareTexture.h" +#include "os.h" +#include "S3DVertex.h" + +namespace irr +{ +namespace video +{ + + +//! constructor +CSoftwareDriver::CSoftwareDriver(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter) +: CNullDriver(io, windowSize), RenderTargetTexture(0), RenderTargetSurface(0), + CurrentTriangleRenderer(0), ZBuffer(0), Texture(0) +{ + #ifdef _DEBUG + setDebugName("CSoftwareDriver"); + #endif + + // create backbuffer + + BackBuffer = new CImage(ECF_A1R5G5B5, windowSize); + BackBuffer->fill(SColor(0)); + + // get presenter + + Presenter = presenter; + + // create z buffer + + ZBuffer = irr::video::createZBuffer(BackBuffer->getDimension()); + + // create triangle renderers + + TriangleRenderers[ETR_FLAT] = createTriangleRendererFlat(ZBuffer); + TriangleRenderers[ETR_FLAT_WIRE] = createTriangleRendererFlatWire(ZBuffer); + TriangleRenderers[ETR_GOURAUD] = createTriangleRendererGouraud(ZBuffer); + TriangleRenderers[ETR_GOURAUD_WIRE] = createTriangleRendererGouraudWire(ZBuffer); + TriangleRenderers[ETR_TEXTURE_FLAT] = createTriangleRendererTextureFlat(ZBuffer); + TriangleRenderers[ETR_TEXTURE_FLAT_WIRE] = createTriangleRendererTextureFlatWire(ZBuffer); + TriangleRenderers[ETR_TEXTURE_GOURAUD] = createTriangleRendererTextureGouraud(ZBuffer); + TriangleRenderers[ETR_TEXTURE_GOURAUD_WIRE] = createTriangleRendererTextureGouraudWire(ZBuffer); + TriangleRenderers[ETR_TEXTURE_GOURAUD_NOZ] = createTriangleRendererTextureGouraudNoZ(); + TriangleRenderers[ETR_TEXTURE_GOURAUD_ADD] = createTriangleRendererTextureGouraudAdd(ZBuffer); + + // select render target + + setRenderTarget(BackBuffer); + + // select the right renderer + + selectRightTriangleRenderer(); +} + + + +//! destructor +CSoftwareDriver::~CSoftwareDriver() +{ + // delete Backbuffer + BackBuffer->drop(); + + // delete triangle renderers + + for (s32 i=0; idrop(); + + // delete zbuffer + + if (ZBuffer) + ZBuffer->drop(); + + // delete current texture + + if (Texture) + Texture->drop(); + + if (RenderTargetTexture) + RenderTargetTexture->drop(); + + if (RenderTargetSurface) + RenderTargetSurface->drop(); +} + + + +//! switches to a triangle renderer +void CSoftwareDriver::switchToTriangleRenderer(ETriangleRenderer renderer) +{ + video::IImage* s = 0; + if (Texture) + s = ((CSoftwareTexture*)Texture)->getTexture(); + + CurrentTriangleRenderer = TriangleRenderers[renderer]; + CurrentTriangleRenderer->setBackfaceCulling(Material.BackfaceCulling == true); + CurrentTriangleRenderer->setTexture(s); + CurrentTriangleRenderer->setRenderTarget(RenderTargetSurface, ViewPort); +} + + +//! void selects the right triangle renderer based on the render states. +void CSoftwareDriver::selectRightTriangleRenderer() +{ + + ETriangleRenderer renderer = ETR_FLAT; + + if (Texture) + { + if (!Material.GouraudShading) + renderer = (!Material.Wireframe) ? ETR_TEXTURE_FLAT : ETR_TEXTURE_FLAT_WIRE; + else + { + if (Material.Wireframe) + renderer = ETR_TEXTURE_GOURAUD_WIRE; + else + { + if (Material.MaterialType == EMT_TRANSPARENT_ADD_COLOR || + Material.MaterialType == EMT_TRANSPARENT_ALPHA_CHANNEL || + Material.MaterialType == EMT_TRANSPARENT_VERTEX_ALPHA) + { + // simply draw all transparent stuff with the same renderer. at + // least it is transparent then. + renderer = ETR_TEXTURE_GOURAUD_ADD; + } + else + if (!Material.ZBuffer && !Material.ZWriteEnable) + renderer = ETR_TEXTURE_GOURAUD_NOZ; + else + { + renderer = ETR_TEXTURE_GOURAUD; + } + } + } + } + else + { + if (!Material.GouraudShading) + renderer = (!Material.Wireframe) ? ETR_FLAT : ETR_FLAT_WIRE; + else + renderer = (!Material.Wireframe) ? ETR_GOURAUD : ETR_GOURAUD_WIRE; + } + + switchToTriangleRenderer(renderer); +} + + + + +//! presents the rendered scene on the screen, returns false if failed +bool CSoftwareDriver::endScene( s32 windowId, core::rect* sourceRect ) +{ + CNullDriver::endScene(); + + Presenter->present(BackBuffer, windowId, sourceRect ); + return true; +} + + + +//! queries the features of the driver, returns true if feature is available +bool CSoftwareDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) +{ + switch (feature) + { + case EVDF_RENDER_TO_TARGET: + return true; + default: + return false; + }; +} + + + +//! sets transformation +void CSoftwareDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) +{ + TransformationMatrix[state] = mat; +} + + + + +//! sets the current Texture +bool CSoftwareDriver::setTexture(video::ITexture* texture) +{ + if (texture && texture->getDriverType() != EDT_SOFTWARE) + { + os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); + return false; + } + + if (Texture) + Texture->drop(); + + Texture = texture; + + if (Texture) + Texture->grab(); + + selectRightTriangleRenderer(); + return true; +} + + + +//! sets a material +void CSoftwareDriver::setMaterial(const SMaterial& material) +{ + Material = material; + + for (u32 i = 0; i < 1; ++i) + { + setTexture(Material.Textures[i]); + setTransform ((E_TRANSFORMATION_STATE) ( ETS_TEXTURE_0 + i ), + material.getTextureMatrix(i)); + } +} + + +//! clears the zbuffer +bool CSoftwareDriver::beginScene(bool backBuffer, bool zBuffer, SColor color) +{ + CNullDriver::beginScene(backBuffer, zBuffer, color); + + if (backBuffer) + BackBuffer->fill( color ); + + if (ZBuffer && zBuffer) + ZBuffer->clear(); + + return true; +} + + +//! sets a render target +bool CSoftwareDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, + bool clearZBuffer, SColor color) +{ + if (texture && texture->getDriverType() != EDT_SOFTWARE) + { + os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); + return false; + } + + if (RenderTargetTexture) + RenderTargetTexture->drop(); + + RenderTargetTexture = texture; + + if (RenderTargetTexture) + { + RenderTargetTexture->grab(); + setRenderTarget(((CSoftwareTexture*)RenderTargetTexture)->getTexture()); + } + else + { + setRenderTarget(BackBuffer); + } + + if (RenderTargetSurface && (clearBackBuffer || clearZBuffer)) + { + if (clearZBuffer) + ZBuffer->clear(); + + if (clearBackBuffer) + ((video::CImage*)RenderTargetSurface)->fill( color ); + } + + return true; +} + + +//! sets a render target +void CSoftwareDriver::setRenderTarget(video::CImage* image) +{ + if (RenderTargetSurface) + RenderTargetSurface->drop(); + + RenderTargetSurface = image; + RenderTargetSize.Width = 0; + RenderTargetSize.Height = 0; + Render2DTranslation.X = 0; + Render2DTranslation.Y = 0; + + if (RenderTargetSurface) + { + RenderTargetSurface->grab(); + RenderTargetSize = RenderTargetSurface->getDimension(); + } + + setViewPort(core::rect(0,0,RenderTargetSize.Width,RenderTargetSize.Height)); + + if (ZBuffer) + ZBuffer->setSize(RenderTargetSize); +} + + + +//! sets a viewport +void CSoftwareDriver::setViewPort(const core::rect& area) +{ + ViewPort = area; + + //TODO: the clipping is not correct, because the projection is affected. + // to correct this, ViewPortSize and Render2DTranslation will have to be corrected. + core::rect rendert(0,0,RenderTargetSize.Width,RenderTargetSize.Height); + ViewPort.clipAgainst(rendert); + + ViewPortSize = ViewPort.getSize(); + Render2DTranslation.X = (ViewPortSize.Width / 2) + ViewPort.UpperLeftCorner.X; + Render2DTranslation.Y = ViewPort.UpperLeftCorner.Y + ViewPortSize.Height - (ViewPortSize.Height / 2);// + ViewPort.UpperLeftCorner.Y; + + if (CurrentTriangleRenderer) + CurrentTriangleRenderer->setRenderTarget(RenderTargetSurface, ViewPort); +} + + +//! draws a vertex primitive list +void CSoftwareDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) +{ + const u16* indexPointer=0; + core::array newBuffer; + switch (pType) + { + case scene::EPT_LINE_STRIP: + { + switch (vType) + { + case EVT_STANDARD: + { + for (u32 i=0; i < primitiveCount-1; ++i) + draw3DLine(((S3DVertex*)vertices)[indexList[i]].Pos, + ((S3DVertex*)vertices)[indexList[i+1]].Pos, + ((S3DVertex*)vertices)[indexList[i]].Color); + } + break; + case EVT_2TCOORDS: + { + for (u32 i=0; i < primitiveCount-1; ++i) + draw3DLine(((S3DVertex2TCoords*)vertices)[indexList[i]].Pos, + ((S3DVertex2TCoords*)vertices)[indexList[i+1]].Pos, + ((S3DVertex2TCoords*)vertices)[indexList[i]].Color); + } + break; + case EVT_TANGENTS: + { + for (u32 i=0; i < primitiveCount-1; ++i) + draw3DLine(((S3DVertexTangents*)vertices)[indexList[i]].Pos, + ((S3DVertexTangents*)vertices)[indexList[i+1]].Pos, + ((S3DVertexTangents*)vertices)[indexList[i]].Color); + } + break; + } + } + return; + case scene::EPT_LINE_LOOP: + drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount-1, vType, scene::EPT_LINE_STRIP); + switch (vType) + { + case EVT_STANDARD: + draw3DLine(((S3DVertex*)vertices)[indexList[primitiveCount-1]].Pos, + ((S3DVertex*)vertices)[indexList[0]].Pos, + ((S3DVertex*)vertices)[indexList[primitiveCount-1]].Color); + break; + case EVT_2TCOORDS: + draw3DLine(((S3DVertex2TCoords*)vertices)[indexList[primitiveCount-1]].Pos, + ((S3DVertex2TCoords*)vertices)[indexList[0]].Pos, + ((S3DVertex2TCoords*)vertices)[indexList[primitiveCount-1]].Color); + break; + case EVT_TANGENTS: + draw3DLine(((S3DVertexTangents*)vertices)[indexList[primitiveCount-1]].Pos, + ((S3DVertexTangents*)vertices)[indexList[0]].Pos, + ((S3DVertexTangents*)vertices)[indexList[primitiveCount-1]].Color); + break; + } + return; + case scene::EPT_LINES: + { + switch (vType) + { + case EVT_STANDARD: + { + for (u32 i=0; i < 2*primitiveCount; i+=2) + draw3DLine(((S3DVertex*)vertices)[indexList[i]].Pos, + ((S3DVertex*)vertices)[indexList[i+1]].Pos, + ((S3DVertex*)vertices)[indexList[i]].Color); + } + break; + case EVT_2TCOORDS: + { + for (u32 i=0; i < 2*primitiveCount; i+=2) + draw3DLine(((S3DVertex2TCoords*)vertices)[indexList[i]].Pos, + ((S3DVertex2TCoords*)vertices)[indexList[i+1]].Pos, + ((S3DVertex2TCoords*)vertices)[indexList[i]].Color); + } + break; + case EVT_TANGENTS: + { + for (u32 i=0; i < 2*primitiveCount; i+=2) + draw3DLine(((S3DVertexTangents*)vertices)[indexList[i]].Pos, + ((S3DVertexTangents*)vertices)[indexList[i+1]].Pos, + ((S3DVertexTangents*)vertices)[indexList[i]].Color); + } + break; + } + } + return; + case scene::EPT_TRIANGLE_FAN: + { + // TODO: don't convert fan to list + newBuffer.reallocate(primitiveCount*3); + for( u32 t=0; t +void CSoftwareDriver::drawClippedIndexedTriangleListT(const VERTEXTYPE* vertices, + s32 vertexCount, const u16* indexList, s32 triangleCount) +{ + if (!RenderTargetSurface || !ZBuffer || !triangleCount) + return; + + if (!checkPrimitiveCount(triangleCount)) + return; + + // arrays for storing clipped vertices + core::array clippedVertices; + core::array clippedIndices; + + // calculate inverse world transformation + core::matrix4 worldinv(TransformationMatrix[ETS_WORLD]); + worldinv.makeInverse(); + + // calculate view frustum planes + scene::SViewFrustum frustum(TransformationMatrix[ETS_PROJECTION] * TransformationMatrix[ETS_VIEW]); + + // copy and transform clipping planes ignoring far plane + core::plane3df planes[5]; // ordered by near, left, right, bottom, top + for (int p=0; p<5; ++p) + worldinv.transformPlane(frustum.planes[p+1], planes[p]); + + core::EIntersectionRelation3D inout[3]; // is point in front or back of plane? + + // temporary buffer for vertices to be clipped by all planes + core::array tClpBuf; + int t; + + int i; + for (i=0; i textureSize(0,0); + f32 zDiv; + + if (Texture) + textureSize = ((CSoftwareTexture*)Texture)->getTexture()->getDimension(); + + f32 transformedPos[4]; // transform all points in the list + + core::matrix4 matrix(TransformationMatrix[ETS_PROJECTION]); + matrix *= TransformationMatrix[ETS_VIEW]; + matrix *= TransformationMatrix[ETS_WORLD]; + + s32 ViewTransformWidth = (ViewPortSize.Width>>1); + s32 ViewTransformHeight = (ViewPortSize.Height>>1); + + for (i=0; i<(int)clippedVertices.size(); ++i) + { + transformedPos[0] = currentVertex->Pos.X; + transformedPos[1] = currentVertex->Pos.Y; + transformedPos[2] = currentVertex->Pos.Z; + transformedPos[3] = 1.0f; + + matrix.multiplyWith1x4Matrix(transformedPos); + zDiv = transformedPos[3] == 0.0f ? 1.0f : (1.0f / transformedPos[3]); + + tp->Pos.X = (s32)(ViewTransformWidth * (transformedPos[0] * zDiv) + (Render2DTranslation.X)); + tp->Pos.Y = (Render2DTranslation.Y - (s32)(ViewTransformHeight * (transformedPos[1] * zDiv))); + tp->Color = currentVertex->Color.toA1R5G5B5(); + tp->ZValue = (TZBufferType)(32767.0f * zDiv); + + tp->TCoords.X = (s32)(currentVertex->TCoords.X * textureSize.Width); + tp->TCoords.X <<= 8; + tp->TCoords.Y = (s32)(currentVertex->TCoords.Y * textureSize.Height); + tp->TCoords.Y <<= 8; + + ++currentVertex; + ++tp; + } + + // draw all transformed points from the index list + CurrentTriangleRenderer->drawIndexedTriangleList(&TransformedPoints[0], + clippedVertices.size(), clippedIndices.pointer(), clippedIndices.size()/3); +} + + + +//! Draws a 3d line. +void CSoftwareDriver::draw3DLine(const core::vector3df& start, + const core::vector3df& end, SColor color) +{ + core::vector3df vect = start.crossProduct(end); + vect.normalize(); + vect *= Material.Thickness*0.3f; + + S3DVertex vtx[4]; + + vtx[0].Color = color; + vtx[1].Color = color; + vtx[2].Color = color; + vtx[3].Color = color; + + vtx[0].Pos = start; + vtx[1].Pos = end; + + vtx[2].Pos = start + vect; + vtx[3].Pos = end + vect; + + u16 idx[12] = {0,1,2, 0,2,1, 0,1,3, 0,3,1}; + + drawIndexedTriangleList(vtx, 4, idx, 4); +} + + + +//! clips a triangle against the viewing frustum +void CSoftwareDriver::clipTriangle(f32* transformedPos) +{ +} + + + +//! creates the clipping planes from the matrix +void CSoftwareDriver::createPlanes(const core::matrix4& mat) +{ + Frustum = scene::SViewFrustum(mat); +} + + + +//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. +void CSoftwareDriver::draw2DImage(video::ITexture* texture, const core::position2d& destPos, + const core::rect& sourceRect, + const core::rect* clipRect, SColor color, + bool useAlphaChannelOfTexture) +{ + if (texture) + { + if (texture->getDriverType() != EDT_SOFTWARE) + { + os::Printer::log("Fatal Error: Tried to copy from a surface not owned by this driver.", ELL_ERROR); + return; + } + + if (useAlphaChannelOfTexture) + ((CSoftwareTexture*)texture)->getImage()->copyToWithAlpha( + ((CImage*)RenderTargetSurface), destPos, sourceRect, color, clipRect); + else + ((CSoftwareTexture*)texture)->getImage()->copyTo( + ((CImage*)RenderTargetSurface), destPos, sourceRect, clipRect); + } +} + + + +//! Draws a 2d line. +void CSoftwareDriver::draw2DLine(const core::position2d& start, + const core::position2d& end, + SColor color) +{ + ((CImage*)RenderTargetSurface)->drawLine(start, end, color ); +} + + + +//! draw a 2d rectangle +void CSoftwareDriver::draw2DRectangle(SColor color, const core::rect& pos, + const core::rect* clip) +{ + if (clip) + { + core::rect p(pos); + + p.clipAgainst(*clip); + + if(!p.isValid()) + return; + + ((CImage*)RenderTargetSurface)->drawRectangle(p, color); + } + else + { + if(!pos.isValid()) + return; + + ((CImage*)RenderTargetSurface)->drawRectangle(pos, color); + } +} + + +//!Draws an 2d rectangle with a gradient. +void CSoftwareDriver::draw2DRectangle(const core::rect& pos, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect* clip) +{ + // TODO: implement + draw2DRectangle(colorLeftUp, pos, clip); +} + + +//! \return Returns the name of the video driver. Example: In case of the Direct3D8 +//! driver, it would return "Direct3D8.1". +const wchar_t* CSoftwareDriver::getName() +{ + return L"Irrlicht Software Device 1.0"; +} + +//! Returns type of video driver +E_DRIVER_TYPE CSoftwareDriver::getDriverType() +{ + return EDT_SOFTWARE; +} + +//! Returns the transformation set by setTransform +const core::matrix4& CSoftwareDriver::getTransform(E_TRANSFORMATION_STATE state) +{ + return TransformationMatrix[state]; +} + +//! Creates a render target texture. +ITexture* CSoftwareDriver::createRenderTargetTexture(const core::dimension2d& size) +{ + CImage* img = new CImage(video::ECF_A1R5G5B5, size); + ITexture* tex = new CSoftwareTexture(img, 0); + img->drop(); + return tex; +} + + +//! Clears the ZBuffer. +void CSoftwareDriver::clearZBuffer() +{ + if (ZBuffer) + ZBuffer->clear(); +} + + +//! Returns an image created from the last rendered frame. +IImage* CSoftwareDriver::createScreenShot() +{ + return new CImage(BackBuffer->getColorFormat(), BackBuffer); +} + + +//! Returns the maximum amount of primitives (mostly vertices) which +//! the device is able to render with one drawIndexedTriangleList +//! call. +u32 CSoftwareDriver::getMaximalPrimitiveCount() +{ + return 0x00800000; +} + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + + +//! creates a video driver +IVideoDriver* createSoftwareDriver(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter) +{ + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + return new CSoftwareDriver(windowSize, fullscreen, io, presenter); + #else + return 0; + #endif +} + + +} // end namespace video +} // end namespace irr diff --git a/src/dep/src/irrlicht/CSoftwareDriver.h b/src/dep/src/irrlicht/CSoftwareDriver.h index c836f90..d32e28b 100644 --- a/src/dep/src/irrlicht/CSoftwareDriver.h +++ b/src/dep/src/irrlicht/CSoftwareDriver.h @@ -1,160 +1,160 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_VIDEO_SOFTWARE_H_INCLUDED__ -#define __C_VIDEO_SOFTWARE_H_INCLUDED__ - -#include "ITriangleRenderer.h" -#include "CNullDriver.h" -#include "SViewFrustum.h" -#include "CImage.h" - -namespace irr -{ -namespace video -{ - class CSoftwareDriver : public CNullDriver - { - public: - - //! constructor - CSoftwareDriver(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter); - - //! destructor - virtual ~CSoftwareDriver(); - - //! presents the rendered scene on the screen, returns false if failed - virtual bool endScene( s32 windowId = 0, core::rect* sourceRect=0 ); - - //! queries the features of the driver, returns true if feature is available - virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature); - - //! sets transformation - virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); - - //! sets a material - virtual void setMaterial(const SMaterial& material); - - virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color); - - //! sets a viewport - virtual void setViewPort(const core::rect& area); - - //! clears the zbuffer - virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color); - - //! draws a vertex primitive list - void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); - - //! Draws a 3d line. - virtual void draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color = SColor(255,255,255,255)); - - //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. - virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos, - const core::rect& sourceRect, const core::rect* clipRect = 0, - SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); - - //! draw an 2d rectangle - virtual void draw2DRectangle(SColor color, const core::rect& pos, - const core::rect* clip = 0); - - //!Draws an 2d rectangle with a gradient. - virtual void draw2DRectangle(const core::rect& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect* clip = 0); - - //! Draws a 2d line. - virtual void draw2DLine(const core::position2d& start, - const core::position2d& end, - SColor color=SColor(255,255,255,255)); - - //! \return Returns the name of the video driver. Example: In case of the Direct3D8 - //! driver, it would return "Direct3D8.1". - virtual const wchar_t* getName(); - - //! Returns type of video driver - virtual E_DRIVER_TYPE getDriverType(); - - //! Returns the transformation set by setTransform - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state); - - //! Creates a render target texture. - virtual ITexture* createRenderTargetTexture(const core::dimension2d& size); - - //! Clears the ZBuffer. - virtual void clearZBuffer(); - - //! Returns an image created from the last rendered frame. - virtual IImage* createScreenShot(); - - //! Returns the maximum amount of primitives (mostly vertices) which - //! the device is able to render with one drawIndexedTriangleList - //! call. - virtual u32 getMaximalPrimitiveCount(); - - protected: - - struct splane - { - core::vector3df Normal; - f32 Dist; - }; - - //! sets a render target - void setRenderTarget(video::CImage* image); - - //! sets the current Texture - bool setTexture(video::ITexture* texture); - - video::CImage* BackBuffer; - video::IImagePresenter* Presenter; - - //! switches to a triangle renderer - void switchToTriangleRenderer(ETriangleRenderer renderer); - - //! void selects the right triangle renderer based on the render states. - void selectRightTriangleRenderer(); - - //! clips a triangle agains the viewing frustum - void clipTriangle(f32* transformedPos); - - //! creates the clipping planes from the view matrix - void createPlanes(const core::matrix4& mat); - - template - void drawClippedIndexedTriangleListT(const VERTEXTYPE* vertices, - s32 vertexCount, const u16* indexList, s32 triangleCount); - - core::array TransformedPoints; - - video::ITexture* RenderTargetTexture; - video::IImage* RenderTargetSurface; - core::position2d Render2DTranslation; - core::dimension2d RenderTargetSize; - core::dimension2d ViewPortSize; - - core::matrix4 TransformationMatrix[ETS_COUNT]; - - ITriangleRenderer* CurrentTriangleRenderer; - ITriangleRenderer* TriangleRenderers[ETR_COUNT]; - ETriangleRenderer CurrentRenderer; - - IZBuffer* ZBuffer; - - video::ITexture* Texture; - scene::SViewFrustum Frustum; - - SMaterial Material; - - splane planes[6]; // current planes of the view frustum - }; - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_VIDEO_SOFTWARE_H_INCLUDED__ +#define __C_VIDEO_SOFTWARE_H_INCLUDED__ + +#include "ITriangleRenderer.h" +#include "CNullDriver.h" +#include "SViewFrustum.h" +#include "CImage.h" + +namespace irr +{ +namespace video +{ + class CSoftwareDriver : public CNullDriver + { + public: + + //! constructor + CSoftwareDriver(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter); + + //! destructor + virtual ~CSoftwareDriver(); + + //! presents the rendered scene on the screen, returns false if failed + virtual bool endScene( s32 windowId = 0, core::rect* sourceRect=0 ); + + //! queries the features of the driver, returns true if feature is available + virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature); + + //! sets transformation + virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); + + //! sets a material + virtual void setMaterial(const SMaterial& material); + + virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, + bool clearZBuffer, SColor color); + + //! sets a viewport + virtual void setViewPort(const core::rect& area); + + //! clears the zbuffer + virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color); + + //! draws a vertex primitive list + void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); + + //! Draws a 3d line. + virtual void draw3DLine(const core::vector3df& start, + const core::vector3df& end, SColor color = SColor(255,255,255,255)); + + //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. + virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos, + const core::rect& sourceRect, const core::rect* clipRect = 0, + SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); + + //! draw an 2d rectangle + virtual void draw2DRectangle(SColor color, const core::rect& pos, + const core::rect* clip = 0); + + //!Draws an 2d rectangle with a gradient. + virtual void draw2DRectangle(const core::rect& pos, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect* clip = 0); + + //! Draws a 2d line. + virtual void draw2DLine(const core::position2d& start, + const core::position2d& end, + SColor color=SColor(255,255,255,255)); + + //! \return Returns the name of the video driver. Example: In case of the Direct3D8 + //! driver, it would return "Direct3D8.1". + virtual const wchar_t* getName(); + + //! Returns type of video driver + virtual E_DRIVER_TYPE getDriverType(); + + //! Returns the transformation set by setTransform + virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state); + + //! Creates a render target texture. + virtual ITexture* createRenderTargetTexture(const core::dimension2d& size); + + //! Clears the ZBuffer. + virtual void clearZBuffer(); + + //! Returns an image created from the last rendered frame. + virtual IImage* createScreenShot(); + + //! Returns the maximum amount of primitives (mostly vertices) which + //! the device is able to render with one drawIndexedTriangleList + //! call. + virtual u32 getMaximalPrimitiveCount(); + + protected: + + struct splane + { + core::vector3df Normal; + f32 Dist; + }; + + //! sets a render target + void setRenderTarget(video::CImage* image); + + //! sets the current Texture + bool setTexture(video::ITexture* texture); + + video::CImage* BackBuffer; + video::IImagePresenter* Presenter; + + //! switches to a triangle renderer + void switchToTriangleRenderer(ETriangleRenderer renderer); + + //! void selects the right triangle renderer based on the render states. + void selectRightTriangleRenderer(); + + //! clips a triangle agains the viewing frustum + void clipTriangle(f32* transformedPos); + + //! creates the clipping planes from the view matrix + void createPlanes(const core::matrix4& mat); + + template + void drawClippedIndexedTriangleListT(const VERTEXTYPE* vertices, + s32 vertexCount, const u16* indexList, s32 triangleCount); + + core::array TransformedPoints; + + video::ITexture* RenderTargetTexture; + video::IImage* RenderTargetSurface; + core::position2d Render2DTranslation; + core::dimension2d RenderTargetSize; + core::dimension2d ViewPortSize; + + core::matrix4 TransformationMatrix[ETS_COUNT]; + + ITriangleRenderer* CurrentTriangleRenderer; + ITriangleRenderer* TriangleRenderers[ETR_COUNT]; + ETriangleRenderer CurrentRenderer; + + IZBuffer* ZBuffer; + + video::ITexture* Texture; + scene::SViewFrustum Frustum; + + SMaterial Material; + + splane planes[6]; // current planes of the view frustum + }; + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CSoftwareDriver2.cpp b/src/dep/src/irrlicht/CSoftwareDriver2.cpp index 9ebf255..0f0dac3 100644 --- a/src/dep/src/irrlicht/CSoftwareDriver2.cpp +++ b/src/dep/src/irrlicht/CSoftwareDriver2.cpp @@ -1,1890 +1,1890 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSoftwareDriver2.h" - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -#include "CSoftwareTexture2.h" -#include "CSoftware2MaterialRenderer.h" -#include "S3DVertex.h" -#include "S4DVertex.h" - - -namespace irr -{ -namespace video -{ - - -//! constructor -CSoftwareDriver2::CSoftwareDriver2(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter) -: CNullDriver(io, windowSize), BackBuffer(0), Presenter(presenter), - RenderTargetTexture(0), RenderTargetSurface(0), CurrentShader(0), - DepthBuffer(0), CurrentOut ( 12 * 2, 128 ), Temp ( 12 * 2, 128 ) -{ - #ifdef _DEBUG - setDebugName("CSoftwareDriver2"); - #endif - - Texture[0] = 0; - Texture[1] = 0; - Texmap[0].Texture = 0; - Texmap[1].Texture = 0; - - // create backbuffer - BackBuffer = new CImage(ECF_SOFTWARE2, windowSize); - BackBuffer->fill(SColor(0)); - - // create z buffer - - DepthBuffer = irr::video::createDepthBuffer(BackBuffer->getDimension()); - - // create triangle renderers - - memset32 ( BurningShader, 0, sizeof ( BurningShader ) ); - //BurningShader[ETR_FLAT] = createTRFlat2(DepthBuffer); - //BurningShader[ETR_FLAT_WIRE] = createTRFlatWire2(DepthBuffer); - BurningShader[ETR_GOURAUD] = createTriangleRendererGouraud2(DepthBuffer); - BurningShader[ETR_GOURAUD_ALPHA] = createTriangleRendererGouraudAlpha2(DepthBuffer ); - BurningShader[ETR_GOURAUD_ALPHA_NOZ] = createTRGouraudAlphaNoZ2(DepthBuffer ); - //BurningShader[ETR_GOURAUD_WIRE] = createTriangleRendererGouraudWire2(DepthBuffer); - //BurningShader[ETR_TEXTURE_FLAT] = createTriangleRendererTextureFlat2(DepthBuffer); - //BurningShader[ETR_TEXTURE_FLAT_WIRE] = createTriangleRendererTextureFlatWire2(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD] = createTriangleRendererTextureGouraud2(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_LIGHTMAP] = createTriangleRendererTextureLightMap2_M1(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_LIGHTMAP_M2] = createTriangleRendererTextureLightMap2_M2(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_LIGHTMAP_M4] = createTriangleRendererGTextureLightMap2_M4(DepthBuffer); - BurningShader[ETR_TEXTURE_LIGHTMAP_M4] = createTriangleRendererTextureLightMap2_M4(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_LIGHTMAP_ADD] = createTriangleRendererTextureLightMap2_Add(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_DETAIL_MAP] = createTriangleRendererTextureDetailMap2(DepthBuffer); - - BurningShader[ETR_TEXTURE_GOURAUD_WIRE] = createTriangleRendererTextureGouraudWire2(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_NOZ] = createTRTextureGouraudNoZ2(); - BurningShader[ETR_TEXTURE_GOURAUD_ADD] = createTRTextureGouraudAdd2(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_ADD_NO_Z] = createTRTextureGouraudAddNoZ2(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_VERTEX_ALPHA] = createTriangleRendererTextureVertexAlpha2 ( DepthBuffer ); - - BurningShader[ETR_TEXTURE_GOURAUD_ALPHA] = createTRTextureGouraudAlpha(DepthBuffer ); - BurningShader[ETR_TEXTURE_GOURAUD_ALPHA_NOZ] = createTRTextureGouraudAlphaNoZ( DepthBuffer ); - - BurningShader[ETR_TEXTURE_BLEND] = createTRTextureBlend( DepthBuffer ); - - - // add the same renderer for all solid types - CSoftware2MaterialRenderer_SOLID* smr = new CSoftware2MaterialRenderer_SOLID( this); - CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR* tmr = new CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR( this); - CSoftware2MaterialRenderer_UNSUPPORTED * umr = new CSoftware2MaterialRenderer_UNSUPPORTED ( this ); - - //!TODO: addMaterialRenderer depends on pushing order.... - addMaterialRenderer ( smr ); // EMT_SOLID - addMaterialRenderer ( smr ); // EMT_SOLID_2_LAYER, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP, - addMaterialRenderer ( tmr ); // EMT_LIGHTMAP_ADD, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_M2, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_M4, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_LIGHTING, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_LIGHTING_M2, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_LIGHTING_M4, - addMaterialRenderer ( smr ); // EMT_DETAIL_MAP, - addMaterialRenderer ( umr ); // EMT_SPHERE_MAP, - addMaterialRenderer ( smr ); // EMT_REFLECTION_2_LAYER, - addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_ADD_COLOR, - addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_ALPHA_CHANNEL, - addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_ALPHA_CHANNEL_REF, - addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_VERTEX_ALPHA, - addMaterialRenderer ( smr ); // EMT_TRANSPARENT_REFLECTION_2_LAYER, - addMaterialRenderer ( umr ); // EMT_NORMAL_MAP_SOLID, - addMaterialRenderer ( umr ); // EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR, - addMaterialRenderer ( umr ); // EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA, - addMaterialRenderer ( umr ); // EMT_PARALLAX_MAP_SOLID, - addMaterialRenderer ( umr ); // EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR, - addMaterialRenderer ( umr ); // EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA, - addMaterialRenderer ( tmr ); // EMT_ONETEXTURE_BLEND - - smr->drop (); - tmr->drop (); - umr->drop (); - - - // select render target - - setRenderTarget(BackBuffer); - - - Global_AmbientLight.set ( 0.f, 0.f, 0.f, 0.f ); - - // select the right renderer - setCurrentShader(); - -} - - - -//! destructor -CSoftwareDriver2::~CSoftwareDriver2() -{ - // delete Backbuffer - BackBuffer->drop(); - - // delete triangle renderers - - for (s32 i=0; idrop(); - - // delete zbuffer - - if (DepthBuffer) - DepthBuffer->drop(); - - // delete current texture - - if ( Texture[0] ) - Texture[0]->drop(); - - if ( Texture[1] ) - Texture[1]->drop(); - - if (RenderTargetTexture) - RenderTargetTexture->drop(); - - if (RenderTargetSurface) - RenderTargetSurface->drop(); -} - - - -//! void selects the right triangle renderer based on the render states. -void CSoftwareDriver2::setCurrentShader() -{ - EBurningFFShader shader = ETR_TEXTURE_GOURAUD; - - bool zMaterialTest = true; - switch ( Material.org.MaterialType ) - { - case EMT_ONETEXTURE_BLEND: - shader = ETR_TEXTURE_BLEND; - zMaterialTest = false; - break; - - case EMT_TRANSPARENT_ALPHA_CHANNEL_REF: - case EMT_TRANSPARENT_ALPHA_CHANNEL: - if ( Material.org.ZBuffer ) - { - shader = ETR_TEXTURE_GOURAUD_ALPHA; - } - else - { - shader = ETR_TEXTURE_GOURAUD_ALPHA_NOZ; - } - zMaterialTest = false; - break; - - case EMT_TRANSPARENT_ADD_COLOR: - if ( Material.org.ZBuffer ) - { - shader = ETR_TEXTURE_GOURAUD_ADD; - } - else - { - shader = ETR_TEXTURE_GOURAUD_ADD_NO_Z; - } - zMaterialTest = false; - break; - - case EMT_TRANSPARENT_VERTEX_ALPHA: - shader = ETR_TEXTURE_GOURAUD_VERTEX_ALPHA; - break; - - case EMT_LIGHTMAP: - case EMT_LIGHTMAP_LIGHTING: - shader = ETR_TEXTURE_GOURAUD_LIGHTMAP; - break; - - case EMT_LIGHTMAP_M2: - case EMT_LIGHTMAP_LIGHTING_M2: - shader = ETR_TEXTURE_GOURAUD_LIGHTMAP_M2; - break; - - case EMT_LIGHTMAP_LIGHTING_M4: - if ( Material.org.Textures[1] ) - shader = ETR_TEXTURE_GOURAUD_LIGHTMAP_M4; - break; - case EMT_LIGHTMAP_M4: - if ( Material.org.Textures[1] ) - shader = ETR_TEXTURE_LIGHTMAP_M4; - break; - - case EMT_LIGHTMAP_ADD: - if ( Material.org.Textures[1] ) - shader = ETR_TEXTURE_GOURAUD_LIGHTMAP_ADD; - break; - - case EMT_DETAIL_MAP: - shader = ETR_TEXTURE_GOURAUD_DETAIL_MAP; - break; - - default: - break; - - } - - if ( zMaterialTest && !Material.org.ZBuffer && !Material.org.ZWriteEnable) - { - shader = ETR_TEXTURE_GOURAUD_NOZ; - } - - if ( 0 == Material.org.Textures[0] ) - { - shader = ETR_GOURAUD; - } - - if ( Material.org.Wireframe ) - { - shader = ETR_TEXTURE_GOURAUD_WIRE; - } - - // switchToTriangleRenderer - CurrentShader = BurningShader[shader]; - if ( CurrentShader ) - { - CurrentShader->setZCompareFunc ( Material.org.ZBuffer ); - switch ( shader ) - { - case ETR_TEXTURE_GOURAUD_ALPHA: - case ETR_TEXTURE_GOURAUD_ALPHA_NOZ: - CurrentShader->setParam ( 0, Material.org.MaterialTypeParam ); - break; - - case EMT_ONETEXTURE_BLEND: - { - E_BLEND_FACTOR srcFact,dstFact; - E_MODULATE_FUNC modulate; - unpack_texureBlendFunc ( srcFact, dstFact, modulate, Material.org.MaterialTypeParam ); - CurrentShader->setParam ( 0, Material.org.MaterialTypeParam ); - } - break; - default: - break; - } - - CurrentShader->setRenderTarget(RenderTargetSurface, ViewPort); - } -} - - - -//! queries the features of the driver, returns true if feature is available -bool CSoftwareDriver2::queryFeature(E_VIDEO_DRIVER_FEATURE feature) -{ - switch (feature) - { -#ifdef SOFTWARE_DRIVER_2_BILINEAR - case EVDF_BILINEAR_FILTER: - return true; -#endif -#ifdef SOFTWARE_DRIVER_2_MIPMAPPING - case EVDF_MIP_MAP: - return true; -#endif - case EVDF_RENDER_TO_TARGET: - case EVDF_MULTITEXTURE: - case EVDF_HARDWARE_TL: - return true; - - default: - return false; - }; -} - - - -//! sets transformation -void CSoftwareDriver2::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) -{ - Transformation[state].m = mat; - Transformation[state].isIdentity = mat.isIdentity(); - - switch ( state ) - { - case ETS_VIEW: - Transformation[ETS_VIEW_PROJECTION].m.setbyproduct_nocheck ( - Transformation[ETS_PROJECTION].m, - Transformation[ETS_VIEW].m - ); - break; - - case ETS_WORLD: - if ( Transformation[state].isIdentity ) - { - Transformation[ETS_CURRENT] = Transformation[ETS_VIEW_PROJECTION]; - } - else - { - Transformation[ETS_CURRENT].m.setbyproduct_nocheck ( - Transformation[ETS_VIEW_PROJECTION].m, - Transformation[ETS_WORLD].m - ); - } - Transformation[ETS_CURRENT].isIdentity = 0; - -#ifdef SOFTWARE_DRIVER_2_LIGHTING - if ( Material.org.Lighting ) - { - if ( Transformation[state].isIdentity ) - { - Transformation[ETS_WORLD_VIEW] = Transformation[ETS_VIEW]; - } - else - { - Transformation[ETS_WORLD_VIEW].m.setbyproduct_nocheck ( - Transformation[ETS_VIEW].m, - Transformation[ETS_WORLD].m - ); - } - - core::matrix4 m2 ( Transformation[ETS_WORLD_VIEW].m ); - m2.makeInverse (); - m2.getTransposed ( Transformation[ETS_WORLD_VIEW_INVERSE_TRANSPOSED].m ); - } -#endif - break; - default: - break; - } -} - - - -//! sets the current Texture -bool CSoftwareDriver2::setTexture(u32 stage, video::ITexture* texture) -{ - if (texture && texture->getDriverType() != EDT_BURNINGSVIDEO) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - if (Texture[stage]) - Texture[stage]->drop(); - - Texture[stage] = texture; - - if (Texture[stage]) - Texture[stage]->grab(); - - if ( Texture[stage] ) - { - Texmap[stage].Texture = (video::CSoftwareTexture2*) Texture[stage]; - } - - setCurrentShader(); - return true; -} - - - -//! sets a material -void CSoftwareDriver2::setMaterial(const SMaterial& material) -{ - Material.org = material; - - Material.AmbientColor.setA8R8G8B8 ( Material.org.AmbientColor.color ); - Material.DiffuseColor.setA8R8G8B8 ( Material.org.DiffuseColor.color ); - Material.EmissiveColor.setA8R8G8B8 ( Material.org.EmissiveColor.color ); - Material.SpecularColor.setA8R8G8B8 ( Material.org.SpecularColor.color ); - - Material.SpecularEnabled = Material.org.Shininess != 0.f; - if (Material.SpecularEnabled) - Material.org.NormalizeNormals = true; - - for (u32 i = 0; i < 2; ++i) - { - setTexture( i, Material.org.Textures[i] ); - setTransform((E_TRANSFORMATION_STATE) (ETS_TEXTURE_0 + i), - material.getTextureMatrix(i)); - } -} - - - -//! clears the zbuffer -bool CSoftwareDriver2::beginScene(bool backBuffer, bool zBuffer, SColor color) -{ - - CNullDriver::beginScene(backBuffer, zBuffer, color); - - if (backBuffer) - BackBuffer->fill( color ); - - if (DepthBuffer && zBuffer) - DepthBuffer->clear(); - - return true; -} - -//! presents the rendered scene on the screen, returns false if failed -bool CSoftwareDriver2::endScene( s32 windowId, core::rect* sourceRect ) -{ - CNullDriver::endScene(); - - Presenter->present(BackBuffer, windowId, sourceRect ); - - return true; -} - - - - -//! sets a render target -bool CSoftwareDriver2::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color) -{ - if (texture && texture->getDriverType() != EDT_BURNINGSVIDEO) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - if (RenderTargetTexture) - RenderTargetTexture->drop(); - - RenderTargetTexture = texture; - - if (RenderTargetTexture) - { - RenderTargetTexture->grab(); - setRenderTarget(((CSoftwareTexture2*)RenderTargetTexture)->getTexture()); - } - else - { - setRenderTarget(BackBuffer); - //setRenderTarget((video::CImage*)0); - } - - if (RenderTargetSurface && (clearBackBuffer || clearZBuffer)) - { - if (clearZBuffer) - DepthBuffer->clear(); - - if (clearBackBuffer) - ((video::CImage*)RenderTargetSurface)->fill( color ); - } - - return true; -} - - -//! sets a render target -void CSoftwareDriver2::setRenderTarget(video::CImage* image) -{ - if (RenderTargetSurface) - RenderTargetSurface->drop(); - - RenderTargetSurface = image; - RenderTargetSize.Width = 0; - RenderTargetSize.Height = 0; - - if (RenderTargetSurface) - { - RenderTargetSurface->grab(); - RenderTargetSize = RenderTargetSurface->getDimension(); - } - - setViewPort(core::rect(0,0,RenderTargetSize.Width,RenderTargetSize.Height)); - - if (DepthBuffer) - DepthBuffer->setSize(RenderTargetSize); -} - - - -//! sets a viewport -void CSoftwareDriver2::setViewPort(const core::rect& area) -{ - ViewPort = area; - - core::rect rendert(0,0,RenderTargetSize.Width,RenderTargetSize.Height); - ViewPort.clipAgainst(rendert); - - Transformation [ ETS_CLIPSCALE ].m.buildNDCToDCMatrix ( ViewPort, 1 ); - - - if (CurrentShader) - CurrentShader->setRenderTarget(RenderTargetSurface, ViewPort); -} - -/* - generic plane clipping in homogenous coordinates - special case ndc frustum <-w,w>,<-w,w>,<-w,w> - can be rewritten with compares e.q near plane, a.z < -a.w and b.z < -b.w -*/ - -const sVec4 CSoftwareDriver2::NDCPlane[6] = -{ - sVec4( 0.f, 0.f, -1.f, -1.f ), // near - sVec4( 0.f, 0.f, 1.f, -1.f ), // far - sVec4( 1.f, 0.f, 0.f, -1.f ), // left - sVec4( -1.f, 0.f, 0.f, -1.f ), // right - sVec4( 0.f, 1.f, 0.f, -1.f ), // bottom - sVec4( 0.f, -1.f, 0.f, -1.f ) // top -}; - - - -/* - test a vertex if it's inside the standard frustum - - this is the generic one.. - - f32 dotPlane; - for ( u32 i = 0; i!= 6; ++i ) - { - dotPlane = v->Pos.dotProduct ( NDCPlane[i] ); - setbit ( flag, dotPlane <= 0.f, 1 << i ); - } - - // this is the base for ndc frustum <-w,w>,<-w,w>,<-w,w> - setbits ( flag, ( v->Pos.z - v->Pos.w ) <= 0.f, 1 ); - setbits ( flag, (-v->Pos.z - v->Pos.w ) <= 0.f, 2 ); - setbits ( flag, ( v->Pos.x - v->Pos.w ) <= 0.f, 4 ); - setbits ( flag, (-v->Pos.x - v->Pos.w ) <= 0.f, 8 ); - setbits ( flag, ( v->Pos.y - v->Pos.w ) <= 0.f, 16 ); - setbits ( flag, (-v->Pos.y - v->Pos.w ) <= 0.f, 32 ); - -*/ -#ifdef _MSC_VER - -REALINLINE u32 CSoftwareDriver2::clipToFrustumTest ( const s4DVertex * v ) const -{ - f32 test[6]; - u32 flag; - const f32 w = - v->Pos.w; - - // a conditional move is needed....FCOMI ( but we don't have it ) - // so let the fpu calculate and write it back. - // cpu makes the compare, interleaving - - test[0] = v->Pos.z + w; - test[1] = -v->Pos.z + w; - test[2] = v->Pos.x + w; - test[3] = -v->Pos.x + w; - test[4] = v->Pos.y + w; - test[5] = -v->Pos.y + w; - - flag = (IR ( test[0] ) ) >> 31; - flag |= (IR ( test[1] ) & 0x80000000 ) >> 30; - flag |= (IR ( test[2] ) & 0x80000000 ) >> 29; - flag |= (IR ( test[3] ) & 0x80000000 ) >> 28; - flag |= (IR ( test[4] ) & 0x80000000 ) >> 27; - flag |= (IR ( test[5] ) & 0x80000000 ) >> 26; - -/* - flag = F32_LOWER_EQUAL_0 ( test[0] ); - flag |= F32_LOWER_EQUAL_0 ( test[1] ) << 1; - flag |= F32_LOWER_EQUAL_0 ( test[2] ) << 2; - flag |= F32_LOWER_EQUAL_0 ( test[3] ) << 3; - flag |= F32_LOWER_EQUAL_0 ( test[4] ) << 4; - flag |= F32_LOWER_EQUAL_0 ( test[5] ) << 5; -*/ - return flag; -} - -#else - - -REALINLINE u32 CSoftwareDriver2::clipToFrustumTest ( const s4DVertex * v ) const -{ - u32 flag = 0; - for ( u32 i = 0; i!= 6; ++i ) - { - core::setbit ( flag, v->Pos.dotProduct ( NDCPlane[i] ) <= 0.f, 1 << i ); - } - return flag; -} - -#endif // _MSC_VER - -u32 CSoftwareDriver2::clipToHyperPlane ( s4DVertex * dest, const s4DVertex * source, u32 inCount, const sVec4 &plane ) -{ - u32 outCount = 0; - s4DVertex * out = dest; - - const s4DVertex * a; - const s4DVertex * b = source; - - f32 bDotPlane; - - bDotPlane = b->Pos.dotProduct ( plane ); - - for( u32 i = 1; i < inCount + 1; ++i) - { - const s32 condition = i - inCount; - const s32 index = (( ( condition >> 31 ) & ( i ^ condition ) ) ^ condition ) << 1; - - a = &source[ index ]; - - // current point inside - if ( a->Pos.dotProduct ( plane ) <= 0.f ) - { - // last point outside - if ( F32_GREATER_0 ( bDotPlane ) ) - { - // intersect line segment with plane - out->interpolate ( *b, *a, bDotPlane / (b->Pos - a->Pos).dotProduct ( plane ) ); - out += 2; - outCount += 1; - } - - // copy current to out - //*out = *a; - memcpy32_small ( out, a, SIZEOF_SVERTEX * 2 ); - b = out; - - out += 2; - outCount += 1; - } - else - { - // current point outside - - if ( F32_LOWER_EQUAL_0 ( bDotPlane ) ) - { - // previous was inside - // intersect line segment with plane - out->interpolate ( *b, *a, bDotPlane / (b->Pos - a->Pos).dotProduct ( plane ) ); - out += 2; - outCount += 1; - } - // pointer - b = a; - } - - bDotPlane = b->Pos.dotProduct ( plane ); - - } - - return outCount; -} - - -u32 CSoftwareDriver2::clipToFrustum ( s4DVertex *v0, s4DVertex * v1, const u32 vIn ) -{ - u32 vOut = vIn; - - vOut = clipToHyperPlane ( v1, v0, vOut, NDCPlane[0] ); if ( vOut < vIn ) return vOut; - vOut = clipToHyperPlane ( v0, v1, vOut, NDCPlane[1] ); if ( vOut < vIn ) return vOut; - vOut = clipToHyperPlane ( v1, v0, vOut, NDCPlane[2] ); if ( vOut < vIn ) return vOut; - vOut = clipToHyperPlane ( v0, v1, vOut, NDCPlane[3] ); if ( vOut < vIn ) return vOut; - vOut = clipToHyperPlane ( v1, v0, vOut, NDCPlane[4] ); if ( vOut < vIn ) return vOut; - vOut = clipToHyperPlane ( v0, v1, vOut, NDCPlane[5] ); - return vOut; -} - -/*! - Part I: - apply Clip Scale matrix - From Normalized Device Coordiante ( NDC ) Space to Device Coordinate Space ( DC ) - - Part II: - Project homogeneous vector - homogeneous to non-homogenous coordinates ( dividebyW ) - - Incoming: ( xw, yw, zw, w, u, v, 1, R, G, B, A ) - Outgoing: ( xw/w, yw/w, zw/w, w/w, u/w, v/w, 1/w, R/w, G/w, B/w, A/w ) - - - replace w/w by 1/w -*/ -inline void CSoftwareDriver2::ndc_2_dc_and_project ( s4DVertex *dest,s4DVertex *source, u32 vIn ) const -{ - u32 g; - - for ( g = 0; g != vIn; g += 2 ) - { - if ( (dest[g].flag & VERTEX4D_PROJECTED ) == VERTEX4D_PROJECTED ) - continue; - - dest[g].flag = source[g].flag | VERTEX4D_PROJECTED; - - const f32 w = source[g].Pos.w; - const f32 iw = core::reciprocal ( w ); - - // to device coordinates - dest[g].Pos.x = iw * ( source[g].Pos.x * Transformation [ ETS_CLIPSCALE ].m[ 0] + w * Transformation [ ETS_CLIPSCALE ].m[12] ); - dest[g].Pos.y = iw * ( source[g].Pos.y * Transformation [ ETS_CLIPSCALE ].m[ 5] + w * Transformation [ ETS_CLIPSCALE ].m[13] ); - -#ifndef SOFTWARE_DRIVER_2_USE_WBUFFER - dest[g].Pos.z = iw * source[g].Pos.z; -#endif - - #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - dest[g].Color[0] = source[g].Color[0] * iw; - #else - dest[g].Color[0] = source[g].Color[0]; - #endif - - #endif - - dest[g].Pos.w = iw; - - } - -} - - -inline void CSoftwareDriver2::ndc_2_dc_and_project2 ( const s4DVertex **v, const u32 size ) const -{ - u32 g; - - for ( g = 0; g != size; g += 1 ) - { - s4DVertex * a = (s4DVertex*) v[g]; - - if ( (a[1].flag & VERTEX4D_PROJECTED ) == VERTEX4D_PROJECTED ) - continue; - - a[1].flag = a->flag | VERTEX4D_PROJECTED; - - // project homogenous vertex, store 1/w - const f32 w = a->Pos.w; - const f32 iw = core::reciprocal ( w ); - - // to device coordinates - a[1].Pos.x = iw * ( a->Pos.x * Transformation [ ETS_CLIPSCALE ].m[ 0] + w * Transformation [ ETS_CLIPSCALE ].m[12] ); - a[1].Pos.y = iw * ( a->Pos.y * Transformation [ ETS_CLIPSCALE ].m[ 5] + w * Transformation [ ETS_CLIPSCALE ].m[13] ); - -#ifndef SOFTWARE_DRIVER_2_USE_WBUFFER - a[1].Pos.z = a->Pos.z * iw; -#endif - - #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - a[1].Color[0] = a->Color[0] * iw; - #else - a[1].Color[0] = a->Color[0]; - #endif - #endif - - a[1].Pos.w = iw; - - } - -} - - -/*! - crossproduct in projected 2D -> screen area triangle -*/ -inline f32 CSoftwareDriver2::screenarea ( const s4DVertex *v ) const -{ - return ( ( v[3].Pos.x - v[1].Pos.x ) * ( v[5].Pos.y - v[1].Pos.y ) ) - - ( ( v[3].Pos.y - v[1].Pos.y ) * ( v[5].Pos.x - v[1].Pos.x ) ); -} - - -/*! -*/ -inline f32 CSoftwareDriver2::texelarea ( const s4DVertex *v, int tex ) const -{ - f32 x0,y0, x1,y1, z; - - x0 = v[2].Tex[tex].x - v[0].Tex[tex].x; - y0 = v[2].Tex[tex].y - v[0].Tex[tex].y; - x1 = v[4].Tex[tex].x - v[0].Tex[tex].x; - y1 = v[4].Tex[tex].y - v[0].Tex[tex].y; - - z = x0*y1 - x1*y0; - - const core::dimension2d &d = Texmap[tex].Texture->getOriginalSize(); - z *= d.Height; - z *= d.Width; - return z; -} - -/*! - crossproduct in projected 2D -*/ -inline f32 CSoftwareDriver2::screenarea2 ( const s4DVertex **v ) const -{ - return ( (( v[1] + 1 )->Pos.x - (v[0] + 1 )->Pos.x ) * ( (v[2] + 1 )->Pos.y - (v[0] + 1 )->Pos.y ) ) - - ( (( v[1] + 1 )->Pos.y - (v[0] + 1 )->Pos.y ) * ( (v[2] + 1 )->Pos.x - (v[0] + 1 )->Pos.x ) ); -} - -/*! -*/ -inline f32 CSoftwareDriver2::texelarea2 ( const s4DVertex **v, s32 tex ) const -{ - f32 z; - - z = (v[1]->Tex[tex].x - v[0]->Tex[tex].x ) * - (v[2]->Tex[tex].y - v[0]->Tex[tex].y ) - - (v[2]->Tex[tex].x - v[0]->Tex[tex].x ) * - (v[1]->Tex[tex].y - v[0]->Tex[tex].y ) - ; - - const core::dimension2d &d = Texmap[tex].Texture->getOriginalSize(); - z *= d.Height; - z *= d.Width; - return z; -} - - - - -/*! -*/ -inline void CSoftwareDriver2::select_polygon_mipmap ( s4DVertex *v, u32 vIn, s32 tex ) -{ - f32 f[2]; - const core::dimension2d& dim = Texmap[tex].Texture->getSize(); - - f[0] = (f32) dim.Width; - f[1] = (f32) dim.Height; - -#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - for ( u32 g = 0; g != vIn; g += 2 ) - { - (v + g + 1 )->Tex[tex].x = (v + g + 0)->Tex[tex].x * ( v + g + 1 )->Pos.w * f[0]; - (v + g + 1 )->Tex[tex].y = (v + g + 0)->Tex[tex].y * ( v + g + 1 )->Pos.w * f[1]; - } -#else - for ( u32 g = 0; g != vIn; g += 2 ) - { - (v + g + 1 )->Tex[tex].x = (v + g + 0)->Tex[tex].x * f[0]; - (v + g + 1 )->Tex[tex].y = (v + g + 0)->Tex[tex].y * f[1]; - } -#endif -} - -inline void CSoftwareDriver2::select_polygon_mipmap2 ( s4DVertex **v, s32 tex ) const -{ - f32 f[2]; - const core::dimension2d& dim = Texmap[tex].Texture->getSize(); - - f[0] = (f32) dim.Width; - f[1] = (f32) dim.Height; - -#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - (v[0] + 1 )->Tex[tex].x = v[0]->Tex[tex].x * ( v[0] + 1 )->Pos.w * f[0]; - (v[0] + 1 )->Tex[tex].y = v[0]->Tex[tex].y * ( v[0] + 1 )->Pos.w * f[1]; - - (v[1] + 1 )->Tex[tex].x = v[1]->Tex[tex].x * ( v[1] + 1 )->Pos.w * f[0]; - (v[1] + 1 )->Tex[tex].y = v[1]->Tex[tex].y * ( v[1] + 1 )->Pos.w * f[1]; - - (v[2] + 1 )->Tex[tex].x = v[2]->Tex[tex].x * ( v[2] + 1 )->Pos.w * f[0]; - (v[2] + 1 )->Tex[tex].y = v[2]->Tex[tex].y * ( v[2] + 1 )->Pos.w * f[1]; - -#else - (v[0] + 1 )->Tex[tex].x = v[0]->Tex[tex].x * f[0]; - (v[0] + 1 )->Tex[tex].y = v[0]->Tex[tex].y * f[1]; - - (v[1] + 1 )->Tex[tex].x = v[1]->Tex[tex].x * f[0]; - (v[1] + 1 )->Tex[tex].y = v[1]->Tex[tex].y * f[1]; - - (v[2] + 1 )->Tex[tex].x = v[2]->Tex[tex].x * f[0]; - (v[2] + 1 )->Tex[tex].y = v[2]->Tex[tex].y * f[1]; -#endif -} - -// Vertex Cache -const SVSize CSoftwareDriver2::vSize[] = -{ - { VERTEX4D_FORMAT_0, sizeof(S3DVertex),1 }, - { VERTEX4D_FORMAT_1, sizeof(S3DVertex2TCoords),2 }, - { VERTEX4D_FORMAT_2, sizeof(S3DVertexTangents),2 } -}; - - - -/*! - fill a cache line with transformed, light and clipp test triangles -*/ -void CSoftwareDriver2::VertexCache_fill(const u32 sourceIndex, - const u32 destIndex) -{ - u8 * source; - s4DVertex *dest; - - source = (u8*) VertexCache.vertices + ( sourceIndex * vSize[VertexCache.vType].Pitch ); - - // it's a look ahead so we never hit it.. - // but give priority... - //VertexCache.info[ destIndex ].hit = hitCount; - - // store info - VertexCache.info[ destIndex ].index = sourceIndex; - VertexCache.info[ destIndex ].hit = 0; - - // destination Vertex - dest = (s4DVertex *) ( (u8*) VertexCache.mem.data + ( destIndex << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); - - // transform Model * World * Camera * Projection * NDCSpace matrix - Transformation [ ETS_CURRENT].m.transformVect ( &dest->Pos.x, ((S3DVertex*) source )->Pos ); - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - - // light Vertex - #ifdef SOFTWARE_DRIVER_2_LIGHTING - lightVertex ( dest, ((S3DVertex*) source ) ); - #else - dest->Color[0].setA8R8G8B8 ( ((S3DVertex*) source )->Color.color ); - #endif -#endif - - // transfer texture coordinates - if ( Transformation [ ETS_TEXTURE_0 ].isIdentity ) - { - // only look on first transform - memcpy32_small ( &dest->Tex[0], - &((S3DVertex*) source )->TCoords, - vSize[VertexCache.vType].TexSize * ( sizeof ( f32 ) * 2 ) - ); - } - else - { - /* - Generate texture coordinates as linear functions so that: - u = Ux*x + Uy*y + Uz*z + Uw - v = Vx*x + Vy*y + Vz*z + Vw - The matrix M for this case is: - Ux Vx 0 0 - Uy Vy 0 0 - Uz Vz 0 0 - Uw Vw 0 0 - */ - - const core::vector2d *src = &((S3DVertex*) source )->TCoords; - u32 t; - - for ( t = 0; t != vSize[VertexCache.vType].TexSize; ++t ) - { - const core::matrix4& M = Transformation [ ETS_TEXTURE_0 + t ].m; - if ( Material.org.TextureWrap[0]==ETC_REPEAT ) - { - dest->Tex[t].x = M[0] * src[t].X + M[4] * src[t].Y + M[8]; - dest->Tex[t].y = M[1] * src[t].X + M[5] * src[t].Y + M[9]; - } - else - { - f32 tx1, ty1; - - tx1 = M[0] * src[t].X + M[4] * src[t].Y + M[8]; - ty1 = M[1] * src[t].X + M[5] * src[t].Y + M[9]; - - dest->Tex[t].x = tx1 <= 0.f ? 0.f : tx1 >= 1.f ? 1.f : tx1; - dest->Tex[t].y = ty1 <= 0.f ? 0.f : ty1 >= 1.f ? 1.f : ty1; - - //dest->Tex[t].x = core::clamp ( M[0] * src[t].X + M[4] * src[t].Y + M[8], 0.f, 1.f ); - //dest->Tex[t].y = core::clamp ( M[1] * src[t].X + M[5] * src[t].Y + M[9], 0.f, 1.f ); - } - } - - } - - dest[0].flag = dest[1].flag = vSize[VertexCache.vType].Format; - - // test vertex - dest[0].flag |= clipToFrustumTest ( dest); - - // to DC Space, project homogenous vertex - if ( (dest[0].flag & VERTEX4D_CLIPMASK ) == VERTEX4D_INSIDE ) - { - ndc_2_dc_and_project2 ( (const s4DVertex**) &dest, 1 ); - } - - //return dest; -} - -// - -REALINLINE s4DVertex * CSoftwareDriver2::VertexCache_getVertex ( const u32 sourceIndex ) -{ - for ( s32 i = 0; i < VERTEXCACHE_ELEMENT; ++i ) - { - if ( VertexCache.info[ i ].index == sourceIndex ) - { - return (s4DVertex *) ( (u8*) VertexCache.mem.data + ( i << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); - } - } - return 0; -} - - -/* - Cache based on linear walk indices - fill blockwise on the next 16(Cache_Size) unique vertices in indexlist - merge the next 16 vertices with the current -*/ -REALINLINE void CSoftwareDriver2::VertexCache_get ( s4DVertex ** face ) -{ - SCacheInfo info[VERTEXCACHE_ELEMENT]; - - // next primitive must be complete in cache - if ( VertexCache.indicesIndex - VertexCache.indicesRun < 3 && - VertexCache.indicesIndex < VertexCache.indexCount - ) - { - // rewind to start of primitive - VertexCache.indicesIndex = VertexCache.indicesRun; - - memset32 ( info, VERTEXCACHE_MISS, sizeof ( info ) ); - - // get the next unique vertices cache line - u32 fillIndex = 0; - u32 dIndex; - u32 i; - - while ( VertexCache.indicesIndex < VertexCache.indexCount && - fillIndex < VERTEXCACHE_ELEMENT - ) - { - u32 sourceIndex = VertexCache.indices [ VertexCache.indicesIndex++ ]; - - // if not exist, push back - s32 exist = 0; - for ( dIndex = 0; dIndex < fillIndex; ++dIndex ) - { - if ( info[ dIndex ].index == sourceIndex ) - { - exist = 1; - break; - } - } - - if ( 0 == exist ) - { - info[fillIndex++].index = sourceIndex; - } - } - - // clear marks - for ( i = 0; i!= VERTEXCACHE_ELEMENT; ++i ) - { - VertexCache.info[i].hit = 0; - } - - // mark all exisiting - for ( i = 0; i!= fillIndex; ++i ) - { - for ( dIndex = 0; dIndex < VERTEXCACHE_ELEMENT; ++dIndex ) - { - if ( VertexCache.info[ dIndex ].index == info[i].index ) - { - info[i].hit = dIndex; - VertexCache.info[ dIndex ].hit = 1; - break; - } - } - } - - // fill new - for ( i = 0; i!= fillIndex; ++i ) - { - if ( info[i].hit != VERTEXCACHE_MISS ) - continue; - - for ( dIndex = 0; dIndex < VERTEXCACHE_ELEMENT; ++dIndex ) - { - if ( 0 == VertexCache.info[dIndex].hit ) - { - VertexCache_fill ( info[i].index, dIndex ); - VertexCache.info[dIndex].hit += 1; - info[i].hit = dIndex; - break; - } - } - } - } - - const u32 i0 = core::if_c_a_else_0 ( VertexCache.pType != scene::EPT_TRIANGLE_FAN, VertexCache.indicesRun ); - - face[0] = VertexCache_getVertex ( VertexCache.indices[ i0 ] ); - face[1] = VertexCache_getVertex ( VertexCache.indices[ VertexCache.indicesRun + 1] ); - face[2] = VertexCache_getVertex ( VertexCache.indices[ VertexCache.indicesRun + 2] ); - - VertexCache.indicesRun += VertexCache.primitivePitch; -} - -REALINLINE void CSoftwareDriver2::VertexCache_get2 ( s4DVertex ** face ) -{ - const u32 i0 = core::if_c_a_else_0 ( VertexCache.pType != scene::EPT_TRIANGLE_FAN, VertexCache.indicesRun ); - - VertexCache_fill ( VertexCache.indices[ i0 ], 0 ); - VertexCache_fill ( VertexCache.indices[ VertexCache.indicesRun + 1], 1 ); - VertexCache_fill ( VertexCache.indices[ VertexCache.indicesRun + 2], 2 ); - - VertexCache.indicesRun += VertexCache.primitivePitch; - - face[0] = (s4DVertex *) ( (u8*) VertexCache.mem.data + ( 0 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); - face[1] = (s4DVertex *) ( (u8*) VertexCache.mem.data + ( 1 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); - face[2] = (s4DVertex *) ( (u8*) VertexCache.mem.data + ( 2 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); - -} - -void CSoftwareDriver2::VertexCache_reset ( const void* vertices, u32 vertexCount, - const u16* indices, u32 primitiveCount, - E_VERTEX_TYPE vType,scene::E_PRIMITIVE_TYPE pType ) -{ - VertexCache.vertices = vertices; - VertexCache.vertexCount = vertexCount; - - VertexCache.indices = indices; - VertexCache.indicesIndex = 0; - VertexCache.indicesRun = 0; - - VertexCache.vType = vType; - VertexCache.pType = pType; - - switch ( VertexCache.pType ) - { - case scene::EPT_TRIANGLES: - VertexCache.indexCount = primitiveCount + primitiveCount + primitiveCount; - VertexCache.primitivePitch = 3; - break; - case scene::EPT_TRIANGLE_FAN: - VertexCache.indexCount = primitiveCount + 2; - VertexCache.primitivePitch = 1; - break; - } - - memset32 ( VertexCache.info, VERTEXCACHE_MISS, sizeof ( VertexCache.info ) ); - -} - - -//! draws a vertex primitive list -void CSoftwareDriver2::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) -{ - if (!checkPrimitiveCount(primitiveCount)) - return; - - CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType); - - if ( 0 == CurrentShader ) - return; - - - VertexCache_reset ( vertices, vertexCount, indexList, primitiveCount, vType, pType ); - - const s4DVertex * face[3]; - - f32 dc_area; - s32 lodLevel; - u32 i; - u32 g; - - for ( i = 0; i < (u32) primitiveCount; ++i ) - { - VertexCache_get ( (s4DVertex**) face ); - - // if fully outside or outside on same side - if ( ( (face[0]->flag | face[1]->flag | face[2]->flag) & VERTEX4D_CLIPMASK ) - != VERTEX4D_INSIDE - ) - continue; - - // if fully inside - if ( ( face[0]->flag & face[1]->flag & face[2]->flag & VERTEX4D_CLIPMASK ) == VERTEX4D_INSIDE ) - { - dc_area = screenarea2 ( face ); - if ( Material.org.BackfaceCulling && F32_LOWER_EQUAL_0 ( dc_area ) ) - { - continue; - } - - dc_area = core::reciprocal ( dc_area ); - // select mipmap - for ( g = 0; g != 2; ++g ) - { - if ( 0 == Texmap[g].Texture ) - { - CurrentShader->setTexture(g, 0, 0); - continue; - } - - lodLevel = s32_log2_f32 ( texelarea2 ( face, g ) * dc_area ); - - CurrentShader->setTexture(g, Texmap[g].Texture, lodLevel); - select_polygon_mipmap2 ( (s4DVertex**) face, g ); - - } - - // rasterize - CurrentShader->drawTriangle ( face[0] + 1, face[1] + 1, face[2] + 1 ); - continue; - } - - // else if not complete inside clipping necessary - memcpy32_small ( ( (u8*) CurrentOut.data + ( 0 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ), face[0], SIZEOF_SVERTEX * 2 ); - memcpy32_small ( ( (u8*) CurrentOut.data + ( 1 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ), face[1], SIZEOF_SVERTEX * 2 ); - memcpy32_small ( ( (u8*) CurrentOut.data + ( 2 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ), face[2], SIZEOF_SVERTEX * 2 ); - - u32 flag = CurrentOut.data->flag & VERTEX4D_FORMAT_MASK; - - for ( g = 0; g != CurrentOut.ElementSize; ++g ) - { - CurrentOut.data[g].flag = flag; - Temp.data[g].flag = flag; - } - - u32 vOut; - vOut = clipToFrustum ( CurrentOut.data, Temp.data, 3 ); -/* - if ( vOut < 3 ) - { - char buf[256]; - struct SCheck - { - u32 flag; - const char * name; - }; - - SCheck check[5]; - check[0].flag = face[0]->flag; - check[0].name = "face0"; - check[1].flag = face[1]->flag; - check[1].name = "face1"; - check[2].flag = face[2]->flag; - check[2].name = "face2"; - check[3].flag = (face[0]->flag & face[1]->flag & face[2]->flag); - check[3].name = "AND "; - check[4].flag = (face[0]->flag | face[1]->flag | face[2]->flag); - check[4].name = "OR "; - - for ( s32 h = 0; h!= 5; ++h ) - { - sprintf ( buf, "%s: %d %d %d %d %d %d", - check[h].name, - ( check[h].flag & 1 ), - ( check[h].flag & 2 ) >> 1, - ( check[h].flag & 4 ) >> 2, - ( check[h].flag & 8 ) >> 3, - ( check[h].flag & 16 ) >> 4, - ( check[h].flag & 32 ) >> 5 - ); - os::Printer::print ( buf ); - } - - sprintf ( buf, "Vout: %d\n", vOut ); - os::Printer::print ( buf ); - - int hold = 1; - } -*/ - if ( vOut < 3 ) - continue; - - vOut <<= 1; - - // to DC Space, project homogenous vertex - ndc_2_dc_and_project ( CurrentOut.data + 1, CurrentOut.data, vOut ); - -/* - // if not complete inside clipping necessary - if ( ( test & VERTEX4D_INSIDE ) != VERTEX4D_INSIDE ) - { - u32 v[2] = { PointerAsValue ( Temp ) , PointerAsValue ( CurrentOut ) }; - for ( g = 0; g != 6; ++g ) - { - vOut = clipToHyperPlane ( (s4DVertex*) v[0], (s4DVertex*) v[1], vOut, NDCPlane[g] ); - if ( vOut < 3 ) - break; - - v[0] ^= v[1]; - v[1] ^= v[0]; - v[0] ^= v[1]; - - } - - if ( vOut < 3 ) - continue; - - } -*/ - - // check 2d backface culling on first - dc_area = screenarea ( CurrentOut.data ); - if ( Material.org.BackfaceCulling && F32_LOWER_EQUAL_0 ( dc_area ) ) - continue; - - // select mipmap - for ( g = 0; g != 2; ++g ) - { - if ( 0 == Texmap[g].Texture ) - { - CurrentShader->setTexture(g, 0, 0); - continue; - } - - lodLevel = s32_log2_f32 ( texelarea ( CurrentOut.data, g ) / dc_area ); - - CurrentShader->setTexture(g, Texmap[g].Texture, lodLevel); - select_polygon_mipmap ( CurrentOut.data, vOut, g ); - } - - // re-tesselate ( triangle-fan, 0-1-2,0-2-3.. ) - for ( g = 0; g <= vOut - 6; g += 2 ) - { - // rasterize - CurrentShader->drawTriangle ( CurrentOut.data + 0 + 1, - CurrentOut.data + g + 3, - CurrentOut.data + g + 5 - ); - } - - } - - // dump statistics -/* - char buf [64]; - sprintf ( buf,"VCount:%d PCount:%d CacheMiss: %d", - vertexCount, primitiveCount, - VertexCache.CacheMiss - ); - os::Printer::print ( buf ); -*/ -} - -//! Sets the dynamic ambient light color. The default color is -//! (0,0,0,0) which means it is dark. -//! \param color: New color of the ambient light. -void CSoftwareDriver2::setAmbientLight(const SColorf& color) -{ - Global_AmbientLight.setColorf ( color ); -} - - -//! adds a dynamic light -void CSoftwareDriver2::addDynamicLight(const SLight& dl) -{ - if ( Light.size () >= getMaximalDynamicLightAmount () ) - return; - - SInternalLight l; - l.org = dl; - - // light in eye space - Transformation[ETS_VIEW].m.transformVect ( &l.posEyeSpace.x, l.org.Position ); - - l.constantAttenuation = 0.f; - l.linearAttenuation = core::reciprocal ( l.org.Radius ); - l.quadraticAttenuation = 0.f; - - l.AmbientColor.setColorf ( l.org.AmbientColor ); - l.DiffuseColor.setColorf ( l.org.DiffuseColor ); - l.SpecularColor.setColorf ( l.org.SpecularColor ); - - switch ( dl.Type ) - { - case video::ELT_DIRECTIONAL: - { - l.posEyeSpace.normalize_xyz (); - } break; - } - - Light.push_back ( l ); - CNullDriver::addDynamicLight( l.org ); -} - -//! deletes all dynamic lights there are -void CSoftwareDriver2::deleteAllDynamicLights() -{ - Light.set_used ( 0 ); - CNullDriver::deleteAllDynamicLights(); - -} - -//! returns the maximal amount of dynamic lights the device can handle -u32 CSoftwareDriver2::getMaximalDynamicLightAmount() -{ - return 8; -} - - - -#ifdef SOFTWARE_DRIVER_2_LIGHTING - -/*! -*/ -void CSoftwareDriver2::lightVertex ( s4DVertex *dest, const S3DVertex *source ) -{ - // apply lighting model - if ( false == Material.org.Lighting ) - { - // should use the DiffuseColor but using pre-lit vertex color - dest->Color[0].setA8R8G8B8 ( source->Color.color ); - return; - } - - if ( Lights.size () == 0 ) - { - dest->Color[0] = Material.EmissiveColor; - return; - } - - // eyespace -/* - core::matrix4 modelview = Transformation[ETS_WORLD].m * Transformation[ETS_VIEW].m; - - core::matrix4 m2 ( modelview ); - m2.makeInverse (); - core::matrix4 modelviewinversetransposed ( m2.getTransposed() ); -*/ - - sVec4 vertexEyeSpace; - sVec4 normalEyeSpace; - sVec4 vertexEyeSpaceUnit; - - // vertex in eye space - Transformation[ETS_WORLD_VIEW].m.transformVect ( &vertexEyeSpace.x, source->Pos ); - vertexEyeSpace.project_xyz (); - - vertexEyeSpaceUnit = vertexEyeSpace; - vertexEyeSpaceUnit.normalize_xyz(); - - // vertex normal in eye-space - //modelviewinversetransposed.transformVect ( &normalEyeSpace.x, source->Normal ); - Transformation[ETS_WORLD_VIEW_INVERSE_TRANSPOSED].m.rotateVect ( &normalEyeSpace.x, source->Normal ); - if ( Material.org.NormalizeNormals ) - { - normalEyeSpace.normalize_xyz(); - } - - - sVec4 ambient; - sVec4 diffuse; - sVec4 specular; - - - // the universe started in darkness.. - ambient.set ( 0.f, 0.f, 0.f, 0.f ); - diffuse.set ( 0.f, 0.f, 0.f, 0.f ); - specular.set ( 0.f, 0.f, 0.f, 0.f ); - - f32 attenuation = 1.f; - - u32 i; - for ( i = 0; i!= Light.size (); ++i ) - { - const SInternalLight &light = Light[i]; - - sVec4 vp; // unit vector vertex to light - sVec4 lightHalf; // blinn-phong reflection - - - switch ( light.org.Type ) - { - case video::ELT_POINT: - { - // surface to light - vp.x = light.posEyeSpace.x - vertexEyeSpace.x; - vp.y = light.posEyeSpace.y - vertexEyeSpace.y; - vp.z = light.posEyeSpace.z - vertexEyeSpace.z; - - // irrlicht attenuation model -#if 1 - const f32 d = vp.get_inverse_length_xyz(); - - vp.x *= d; - vp.y *= d; - vp.z *= d; - attenuation = light.org.Radius * d; - -#else - const f32 d = vp.get_length_xyz(); - attenuation = 1.f / (light.constantAttenuation + - light.linearAttenuation * d + - light.quadraticAttenuation * d * d - ); - - // normalize surface to light - vp.normalize_xyz(); -#endif - - lightHalf.x = vp.x - vertexEyeSpaceUnit.x; - lightHalf.y = vp.y - vertexEyeSpaceUnit.y; - lightHalf.z = vp.z - vertexEyeSpaceUnit.z; - lightHalf.normalize_xyz(); - - } break; - - case video::ELT_DIRECTIONAL: - { - attenuation = 1.f; - vp = light.posEyeSpace; - - // half angle = lightvector + eye vector ( 0, 0, 1 ) - lightHalf.x = vp.x; - lightHalf.y = vp.y; - lightHalf.z = vp.z - 1.f; - lightHalf.normalize_xyz(); - } break; - } - - // build diffuse reflection - - //angle between normal and light vector - f32 dotVP = core::max_ ( 0.f, normalEyeSpace.dot_xyz ( vp ) ); - f32 dotHV = core::max_ ( 0.f, normalEyeSpace.dot_xyz ( lightHalf ) ); - - f32 pf; - if ( dotVP == 0.0 ) - { - pf = 0.f; - } - else - { - pf = powf(dotHV, Material.org.Shininess ); - } - - // accumulate ambient - ambient += light.AmbientColor * attenuation; - diffuse += light.DiffuseColor * ( dotVP * attenuation ); - specular += light.SpecularColor * ( pf * attenuation ); - - } - - sVec4 dColor; - - dColor = Global_AmbientLight; - dColor += Material.EmissiveColor; - dColor += ambient * Material.AmbientColor; - dColor += diffuse * Material.DiffuseColor; - dColor += specular * Material.SpecularColor; - dColor.saturate(); - - dest->Color[0] = dColor; -} - -#endif - - -//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. -void CSoftwareDriver2::draw2DImage(video::ITexture* texture, const core::position2d& destPos, - const core::rect& sourceRect, - const core::rect* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - if (texture) - { - if (texture->getDriverType() != EDT_BURNINGSVIDEO) - { - os::Printer::log("Fatal Error: Tried to copy from a surface not owned by this driver.", ELL_ERROR); - return; - } - - if (useAlphaChannelOfTexture) - ((CSoftwareTexture2*)texture)->getImage()->copyToWithAlpha( - BackBuffer, destPos, sourceRect, color, clipRect); - else - ((CSoftwareTexture2*)texture)->getImage()->copyTo( - BackBuffer, destPos, sourceRect, clipRect); - } -} - - - -//! Draws a 2d line. -void CSoftwareDriver2::draw2DLine(const core::position2d& start, - const core::position2d& end, - SColor color) -{ - ((CImage*)BackBuffer)->drawLine(start, end, color ); -} - - - -//! draw an 2d rectangle -void CSoftwareDriver2::draw2DRectangle(SColor color, const core::rect& pos, - const core::rect* clip) -{ - if (clip) - { - core::rect p(pos); - - p.clipAgainst(*clip); - - if(!p.isValid()) - return; - - BackBuffer->drawRectangle(p, color); - } - else - { - if(!pos.isValid()) - return; - - BackBuffer->drawRectangle(pos, color); - } -} - - - -//!Draws an 2d rectangle with a gradient. -void CSoftwareDriver2::draw2DRectangle(const core::rect& position, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect* clip) -{ -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - - core::rect pos = position; - - if (clip) - pos.clipAgainst(*clip); - - if (!pos.isValid()) - return; - - const core::dimension2d renderTargetSize ( ViewPort.getSize() ); - - const s32 xPlus = -(renderTargetSize.Width>>1); - const f32 xFact = 1.0f / (renderTargetSize.Width>>1); - - const s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); - const f32 yFact = 1.0f / (renderTargetSize.Height>>1); - - // fill VertexCache direct - s4DVertex *v; - - VertexCache.vertexCount = 4; - - VertexCache.info[0].index = 0; - VertexCache.info[1].index = 1; - VertexCache.info[2].index = 2; - VertexCache.info[3].index = 3; - - v = &VertexCache.mem.data [ 0 ]; - - v[0].Pos.set ( (f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.UpperLeftCorner.Y) * yFact, 0.f, 1.f ); - v[0].Color[0].setA8R8G8B8 ( colorLeftUp.color ); - - v[2].Pos.set ( (f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus- pos.UpperLeftCorner.Y) * yFact, 0.f, 1.f ); - v[2].Color[0].setA8R8G8B8 ( colorRightUp.color ); - - v[4].Pos.set ( (f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.f ,1.f ); - v[4].Color[0].setA8R8G8B8 ( colorRightDown.color ); - - v[6].Pos.set ( (f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.f, 1.f ); - v[6].Color[0].setA8R8G8B8 ( colorLeftDown.color ); - - s32 i; - u32 g; - - for ( i = 0; i!= 8; i += 2 ) - { - v[i + 0].flag = clipToFrustumTest ( v + i ); - v[i + 1].flag = 0; - if ( (v[i].flag & VERTEX4D_INSIDE ) == VERTEX4D_INSIDE ) - { - ndc_2_dc_and_project ( v + i + 1, v + i, 2 ); - } - } - - - IBurningShader * render; - - render = BurningShader [ ETR_GOURAUD_ALPHA_NOZ ]; - render->setRenderTarget(RenderTargetSurface, ViewPort); - - static const s16 indexList[6] = {0,1,2,0,2,3}; - - s4DVertex * face[3]; - - for ( i = 0; i!= 6; i += 3 ) - { - face[0] = VertexCache_getVertex ( indexList [ i + 0 ] ); - face[1] = VertexCache_getVertex ( indexList [ i + 1 ] ); - face[2] = VertexCache_getVertex ( indexList [ i + 2 ] ); - - // test clipping - u32 test = face[0]->flag & face[1]->flag & face[2]->flag & VERTEX4D_INSIDE; - - if ( test == VERTEX4D_INSIDE ) - { - render->drawTriangle ( face[0] + 1, face[1] + 1, face[2] + 1 ); - continue; - } - // Todo: all vertices are clipped in 2d.. - // is this true ? - u32 vOut = 6; - memcpy ( CurrentOut.data + 0, face[0], sizeof ( s4DVertex ) * 2 ); - memcpy ( CurrentOut.data + 2, face[1], sizeof ( s4DVertex ) * 2 ); - memcpy ( CurrentOut.data + 4, face[2], sizeof ( s4DVertex ) * 2 ); - - vOut = clipToFrustum ( CurrentOut.data, Temp.data, 3 ); - if ( vOut < 3 ) - continue; - - vOut <<= 1; - // to DC Space, project homogenous vertex - ndc_2_dc_and_project ( CurrentOut.data + 1, CurrentOut.data, vOut ); - - // re-tesselate ( triangle-fan, 0-1-2,0-2-3.. ) - for ( g = 0; g <= vOut - 6; g += 2 ) - { - // rasterize - render->drawTriangle ( CurrentOut.data + 1, &CurrentOut.data[g + 3], &CurrentOut.data[g + 5] ); - } - - } -#else - draw2DRectangle ( colorLeftUp, position, clip ); -#endif -} - - - -//! Draws a 3d line. -void CSoftwareDriver2::draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color) -{ - Transformation [ ETS_CURRENT].m.transformVect ( &CurrentOut.data[0].Pos.x, start ); - Transformation [ ETS_CURRENT].m.transformVect ( &CurrentOut.data[2].Pos.x, end ); - - u32 g; - u32 vOut; - - // no clipping flags - for ( g = 0; g != CurrentOut.ElementSize; ++g ) - { - CurrentOut.data[g].flag = 0; - Temp.data[g].flag = 0; - } - - // vertices count per line - vOut = clipToFrustum ( CurrentOut.data, Temp.data, 2 ); - if ( vOut < 2 ) - return; - - vOut <<= 1; - - IBurningShader * line; - line = BurningShader [ ETR_TEXTURE_GOURAUD_WIRE ]; - line->setRenderTarget(RenderTargetSurface, ViewPort); - - // to DC Space, project homogenous vertex - ndc_2_dc_and_project ( CurrentOut.data + 1, CurrentOut.data, vOut ); - - // unproject vertex color -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - for ( g = 0; g != vOut; g+= 2 ) - { - CurrentOut.data[ g + 1].Color[0].setA8R8G8B8 ( color.color ); - } -#endif - - - for ( g = 0; g <= vOut - 4; g += 2 ) - { - // rasterize - line->drawLine ( CurrentOut.data + 1, CurrentOut.data + g + 3 ); - } -} - - - -//! \return Returns the name of the video driver. Example: In case of the DirectX8 -//! driver, it would return "Direct3D8.1". -const wchar_t* CSoftwareDriver2::getName() -{ -#ifdef BURNINGVIDEO_RENDERER_BEAUTIFUL - return L"burnings video 0.38b"; -#elif defined ( BURNINGVIDEO_RENDERER_ULTRA_FAST ) - return L"burnings video 0.38uf"; -#elif defined ( BURNINGVIDEO_RENDERER_FAST ) - return L"burnings video 0.38f"; -#else - return L"burnings video 0.38"; -#endif -} - -//! Returns type of video driver -E_DRIVER_TYPE CSoftwareDriver2::getDriverType() -{ - return EDT_BURNINGSVIDEO; -} - -//! Returns the transformation set by setTransform -const core::matrix4& CSoftwareDriver2::getTransform(E_TRANSFORMATION_STATE state) -{ - return Transformation[state].m; -} - -//! Creates a render target texture. -ITexture* CSoftwareDriver2::createRenderTargetTexture(const core::dimension2d& size) -{ - CImage* img = new CImage(ECF_SOFTWARE2, size); - - ITexture* tex = new CSoftwareTexture2(img, 0, false); - img->drop(); - return tex; -} - - -//! Clears the DepthBuffer. -void CSoftwareDriver2::clearZBuffer() -{ - if (DepthBuffer) - DepthBuffer->clear(); -} - - -//! Returns an image created from the last rendered frame. -IImage* CSoftwareDriver2::createScreenShot() -{ - return new CImage(BackBuffer->getColorFormat(), BackBuffer); -} - -//! Enables or disables a texture creation flag. -void CSoftwareDriver2::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) -{ - CNullDriver::setTextureCreationFlag(flag,enabled); -} - - -//! returns a device dependent texture from a software surface (IImage) -//! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES -ITexture* CSoftwareDriver2::createDeviceDependentTexture(IImage* surface, const char* name) -{ - return new CSoftwareTexture2(surface, name, getTextureCreationFlag(ETCF_CREATE_MIP_MAPS)); - -} - -//! Returns the maximum amount of primitives (mostly vertices) which -//! the device is able to render with one drawIndexedTriangleList -//! call. -u32 CSoftwareDriver2::getMaximalPrimitiveCount() -{ - return 0x00800000; -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a video driver -IVideoDriver* createSoftwareDriver2(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CSoftwareDriver2(windowSize, fullscreen, io, presenter); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - - -} // end namespace video -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSoftwareDriver2.h" + +#include "IrrCompileConfig.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +#include "CSoftwareTexture2.h" +#include "CSoftware2MaterialRenderer.h" +#include "S3DVertex.h" +#include "S4DVertex.h" + + +namespace irr +{ +namespace video +{ + + +//! constructor +CSoftwareDriver2::CSoftwareDriver2(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter) +: CNullDriver(io, windowSize), BackBuffer(0), Presenter(presenter), + RenderTargetTexture(0), RenderTargetSurface(0), CurrentShader(0), + DepthBuffer(0), CurrentOut ( 12 * 2, 128 ), Temp ( 12 * 2, 128 ) +{ + #ifdef _DEBUG + setDebugName("CSoftwareDriver2"); + #endif + + Texture[0] = 0; + Texture[1] = 0; + Texmap[0].Texture = 0; + Texmap[1].Texture = 0; + + // create backbuffer + BackBuffer = new CImage(ECF_SOFTWARE2, windowSize); + BackBuffer->fill(SColor(0)); + + // create z buffer + + DepthBuffer = irr::video::createDepthBuffer(BackBuffer->getDimension()); + + // create triangle renderers + + memset32 ( BurningShader, 0, sizeof ( BurningShader ) ); + //BurningShader[ETR_FLAT] = createTRFlat2(DepthBuffer); + //BurningShader[ETR_FLAT_WIRE] = createTRFlatWire2(DepthBuffer); + BurningShader[ETR_GOURAUD] = createTriangleRendererGouraud2(DepthBuffer); + BurningShader[ETR_GOURAUD_ALPHA] = createTriangleRendererGouraudAlpha2(DepthBuffer ); + BurningShader[ETR_GOURAUD_ALPHA_NOZ] = createTRGouraudAlphaNoZ2(DepthBuffer ); + //BurningShader[ETR_GOURAUD_WIRE] = createTriangleRendererGouraudWire2(DepthBuffer); + //BurningShader[ETR_TEXTURE_FLAT] = createTriangleRendererTextureFlat2(DepthBuffer); + //BurningShader[ETR_TEXTURE_FLAT_WIRE] = createTriangleRendererTextureFlatWire2(DepthBuffer); + BurningShader[ETR_TEXTURE_GOURAUD] = createTriangleRendererTextureGouraud2(DepthBuffer); + BurningShader[ETR_TEXTURE_GOURAUD_LIGHTMAP] = createTriangleRendererTextureLightMap2_M1(DepthBuffer); + BurningShader[ETR_TEXTURE_GOURAUD_LIGHTMAP_M2] = createTriangleRendererTextureLightMap2_M2(DepthBuffer); + BurningShader[ETR_TEXTURE_GOURAUD_LIGHTMAP_M4] = createTriangleRendererGTextureLightMap2_M4(DepthBuffer); + BurningShader[ETR_TEXTURE_LIGHTMAP_M4] = createTriangleRendererTextureLightMap2_M4(DepthBuffer); + BurningShader[ETR_TEXTURE_GOURAUD_LIGHTMAP_ADD] = createTriangleRendererTextureLightMap2_Add(DepthBuffer); + BurningShader[ETR_TEXTURE_GOURAUD_DETAIL_MAP] = createTriangleRendererTextureDetailMap2(DepthBuffer); + + BurningShader[ETR_TEXTURE_GOURAUD_WIRE] = createTriangleRendererTextureGouraudWire2(DepthBuffer); + BurningShader[ETR_TEXTURE_GOURAUD_NOZ] = createTRTextureGouraudNoZ2(); + BurningShader[ETR_TEXTURE_GOURAUD_ADD] = createTRTextureGouraudAdd2(DepthBuffer); + BurningShader[ETR_TEXTURE_GOURAUD_ADD_NO_Z] = createTRTextureGouraudAddNoZ2(DepthBuffer); + BurningShader[ETR_TEXTURE_GOURAUD_VERTEX_ALPHA] = createTriangleRendererTextureVertexAlpha2 ( DepthBuffer ); + + BurningShader[ETR_TEXTURE_GOURAUD_ALPHA] = createTRTextureGouraudAlpha(DepthBuffer ); + BurningShader[ETR_TEXTURE_GOURAUD_ALPHA_NOZ] = createTRTextureGouraudAlphaNoZ( DepthBuffer ); + + BurningShader[ETR_TEXTURE_BLEND] = createTRTextureBlend( DepthBuffer ); + + + // add the same renderer for all solid types + CSoftware2MaterialRenderer_SOLID* smr = new CSoftware2MaterialRenderer_SOLID( this); + CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR* tmr = new CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR( this); + CSoftware2MaterialRenderer_UNSUPPORTED * umr = new CSoftware2MaterialRenderer_UNSUPPORTED ( this ); + + //!TODO: addMaterialRenderer depends on pushing order.... + addMaterialRenderer ( smr ); // EMT_SOLID + addMaterialRenderer ( smr ); // EMT_SOLID_2_LAYER, + addMaterialRenderer ( smr ); // EMT_LIGHTMAP, + addMaterialRenderer ( tmr ); // EMT_LIGHTMAP_ADD, + addMaterialRenderer ( smr ); // EMT_LIGHTMAP_M2, + addMaterialRenderer ( smr ); // EMT_LIGHTMAP_M4, + addMaterialRenderer ( smr ); // EMT_LIGHTMAP_LIGHTING, + addMaterialRenderer ( smr ); // EMT_LIGHTMAP_LIGHTING_M2, + addMaterialRenderer ( smr ); // EMT_LIGHTMAP_LIGHTING_M4, + addMaterialRenderer ( smr ); // EMT_DETAIL_MAP, + addMaterialRenderer ( umr ); // EMT_SPHERE_MAP, + addMaterialRenderer ( smr ); // EMT_REFLECTION_2_LAYER, + addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_ADD_COLOR, + addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_ALPHA_CHANNEL, + addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_ALPHA_CHANNEL_REF, + addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_VERTEX_ALPHA, + addMaterialRenderer ( smr ); // EMT_TRANSPARENT_REFLECTION_2_LAYER, + addMaterialRenderer ( umr ); // EMT_NORMAL_MAP_SOLID, + addMaterialRenderer ( umr ); // EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR, + addMaterialRenderer ( umr ); // EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA, + addMaterialRenderer ( umr ); // EMT_PARALLAX_MAP_SOLID, + addMaterialRenderer ( umr ); // EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR, + addMaterialRenderer ( umr ); // EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA, + addMaterialRenderer ( tmr ); // EMT_ONETEXTURE_BLEND + + smr->drop (); + tmr->drop (); + umr->drop (); + + + // select render target + + setRenderTarget(BackBuffer); + + + Global_AmbientLight.set ( 0.f, 0.f, 0.f, 0.f ); + + // select the right renderer + setCurrentShader(); + +} + + + +//! destructor +CSoftwareDriver2::~CSoftwareDriver2() +{ + // delete Backbuffer + BackBuffer->drop(); + + // delete triangle renderers + + for (s32 i=0; idrop(); + + // delete zbuffer + + if (DepthBuffer) + DepthBuffer->drop(); + + // delete current texture + + if ( Texture[0] ) + Texture[0]->drop(); + + if ( Texture[1] ) + Texture[1]->drop(); + + if (RenderTargetTexture) + RenderTargetTexture->drop(); + + if (RenderTargetSurface) + RenderTargetSurface->drop(); +} + + + +//! void selects the right triangle renderer based on the render states. +void CSoftwareDriver2::setCurrentShader() +{ + EBurningFFShader shader = ETR_TEXTURE_GOURAUD; + + bool zMaterialTest = true; + switch ( Material.org.MaterialType ) + { + case EMT_ONETEXTURE_BLEND: + shader = ETR_TEXTURE_BLEND; + zMaterialTest = false; + break; + + case EMT_TRANSPARENT_ALPHA_CHANNEL_REF: + case EMT_TRANSPARENT_ALPHA_CHANNEL: + if ( Material.org.ZBuffer ) + { + shader = ETR_TEXTURE_GOURAUD_ALPHA; + } + else + { + shader = ETR_TEXTURE_GOURAUD_ALPHA_NOZ; + } + zMaterialTest = false; + break; + + case EMT_TRANSPARENT_ADD_COLOR: + if ( Material.org.ZBuffer ) + { + shader = ETR_TEXTURE_GOURAUD_ADD; + } + else + { + shader = ETR_TEXTURE_GOURAUD_ADD_NO_Z; + } + zMaterialTest = false; + break; + + case EMT_TRANSPARENT_VERTEX_ALPHA: + shader = ETR_TEXTURE_GOURAUD_VERTEX_ALPHA; + break; + + case EMT_LIGHTMAP: + case EMT_LIGHTMAP_LIGHTING: + shader = ETR_TEXTURE_GOURAUD_LIGHTMAP; + break; + + case EMT_LIGHTMAP_M2: + case EMT_LIGHTMAP_LIGHTING_M2: + shader = ETR_TEXTURE_GOURAUD_LIGHTMAP_M2; + break; + + case EMT_LIGHTMAP_LIGHTING_M4: + if ( Material.org.Textures[1] ) + shader = ETR_TEXTURE_GOURAUD_LIGHTMAP_M4; + break; + case EMT_LIGHTMAP_M4: + if ( Material.org.Textures[1] ) + shader = ETR_TEXTURE_LIGHTMAP_M4; + break; + + case EMT_LIGHTMAP_ADD: + if ( Material.org.Textures[1] ) + shader = ETR_TEXTURE_GOURAUD_LIGHTMAP_ADD; + break; + + case EMT_DETAIL_MAP: + shader = ETR_TEXTURE_GOURAUD_DETAIL_MAP; + break; + + default: + break; + + } + + if ( zMaterialTest && !Material.org.ZBuffer && !Material.org.ZWriteEnable) + { + shader = ETR_TEXTURE_GOURAUD_NOZ; + } + + if ( 0 == Material.org.Textures[0] ) + { + shader = ETR_GOURAUD; + } + + if ( Material.org.Wireframe ) + { + shader = ETR_TEXTURE_GOURAUD_WIRE; + } + + // switchToTriangleRenderer + CurrentShader = BurningShader[shader]; + if ( CurrentShader ) + { + CurrentShader->setZCompareFunc ( Material.org.ZBuffer ); + switch ( shader ) + { + case ETR_TEXTURE_GOURAUD_ALPHA: + case ETR_TEXTURE_GOURAUD_ALPHA_NOZ: + CurrentShader->setParam ( 0, Material.org.MaterialTypeParam ); + break; + + case EMT_ONETEXTURE_BLEND: + { + E_BLEND_FACTOR srcFact,dstFact; + E_MODULATE_FUNC modulate; + unpack_texureBlendFunc ( srcFact, dstFact, modulate, Material.org.MaterialTypeParam ); + CurrentShader->setParam ( 0, Material.org.MaterialTypeParam ); + } + break; + default: + break; + } + + CurrentShader->setRenderTarget(RenderTargetSurface, ViewPort); + } +} + + + +//! queries the features of the driver, returns true if feature is available +bool CSoftwareDriver2::queryFeature(E_VIDEO_DRIVER_FEATURE feature) +{ + switch (feature) + { +#ifdef SOFTWARE_DRIVER_2_BILINEAR + case EVDF_BILINEAR_FILTER: + return true; +#endif +#ifdef SOFTWARE_DRIVER_2_MIPMAPPING + case EVDF_MIP_MAP: + return true; +#endif + case EVDF_RENDER_TO_TARGET: + case EVDF_MULTITEXTURE: + case EVDF_HARDWARE_TL: + return true; + + default: + return false; + }; +} + + + +//! sets transformation +void CSoftwareDriver2::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) +{ + Transformation[state].m = mat; + Transformation[state].isIdentity = mat.isIdentity(); + + switch ( state ) + { + case ETS_VIEW: + Transformation[ETS_VIEW_PROJECTION].m.setbyproduct_nocheck ( + Transformation[ETS_PROJECTION].m, + Transformation[ETS_VIEW].m + ); + break; + + case ETS_WORLD: + if ( Transformation[state].isIdentity ) + { + Transformation[ETS_CURRENT] = Transformation[ETS_VIEW_PROJECTION]; + } + else + { + Transformation[ETS_CURRENT].m.setbyproduct_nocheck ( + Transformation[ETS_VIEW_PROJECTION].m, + Transformation[ETS_WORLD].m + ); + } + Transformation[ETS_CURRENT].isIdentity = 0; + +#ifdef SOFTWARE_DRIVER_2_LIGHTING + if ( Material.org.Lighting ) + { + if ( Transformation[state].isIdentity ) + { + Transformation[ETS_WORLD_VIEW] = Transformation[ETS_VIEW]; + } + else + { + Transformation[ETS_WORLD_VIEW].m.setbyproduct_nocheck ( + Transformation[ETS_VIEW].m, + Transformation[ETS_WORLD].m + ); + } + + core::matrix4 m2 ( Transformation[ETS_WORLD_VIEW].m ); + m2.makeInverse (); + m2.getTransposed ( Transformation[ETS_WORLD_VIEW_INVERSE_TRANSPOSED].m ); + } +#endif + break; + default: + break; + } +} + + + +//! sets the current Texture +bool CSoftwareDriver2::setTexture(u32 stage, video::ITexture* texture) +{ + if (texture && texture->getDriverType() != EDT_BURNINGSVIDEO) + { + os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); + return false; + } + + if (Texture[stage]) + Texture[stage]->drop(); + + Texture[stage] = texture; + + if (Texture[stage]) + Texture[stage]->grab(); + + if ( Texture[stage] ) + { + Texmap[stage].Texture = (video::CSoftwareTexture2*) Texture[stage]; + } + + setCurrentShader(); + return true; +} + + + +//! sets a material +void CSoftwareDriver2::setMaterial(const SMaterial& material) +{ + Material.org = material; + + Material.AmbientColor.setA8R8G8B8 ( Material.org.AmbientColor.color ); + Material.DiffuseColor.setA8R8G8B8 ( Material.org.DiffuseColor.color ); + Material.EmissiveColor.setA8R8G8B8 ( Material.org.EmissiveColor.color ); + Material.SpecularColor.setA8R8G8B8 ( Material.org.SpecularColor.color ); + + Material.SpecularEnabled = Material.org.Shininess != 0.f; + if (Material.SpecularEnabled) + Material.org.NormalizeNormals = true; + + for (u32 i = 0; i < 2; ++i) + { + setTexture( i, Material.org.Textures[i] ); + setTransform((E_TRANSFORMATION_STATE) (ETS_TEXTURE_0 + i), + material.getTextureMatrix(i)); + } +} + + + +//! clears the zbuffer +bool CSoftwareDriver2::beginScene(bool backBuffer, bool zBuffer, SColor color) +{ + + CNullDriver::beginScene(backBuffer, zBuffer, color); + + if (backBuffer) + BackBuffer->fill( color ); + + if (DepthBuffer && zBuffer) + DepthBuffer->clear(); + + return true; +} + +//! presents the rendered scene on the screen, returns false if failed +bool CSoftwareDriver2::endScene( s32 windowId, core::rect* sourceRect ) +{ + CNullDriver::endScene(); + + Presenter->present(BackBuffer, windowId, sourceRect ); + + return true; +} + + + + +//! sets a render target +bool CSoftwareDriver2::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, + bool clearZBuffer, SColor color) +{ + if (texture && texture->getDriverType() != EDT_BURNINGSVIDEO) + { + os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); + return false; + } + + if (RenderTargetTexture) + RenderTargetTexture->drop(); + + RenderTargetTexture = texture; + + if (RenderTargetTexture) + { + RenderTargetTexture->grab(); + setRenderTarget(((CSoftwareTexture2*)RenderTargetTexture)->getTexture()); + } + else + { + setRenderTarget(BackBuffer); + //setRenderTarget((video::CImage*)0); + } + + if (RenderTargetSurface && (clearBackBuffer || clearZBuffer)) + { + if (clearZBuffer) + DepthBuffer->clear(); + + if (clearBackBuffer) + ((video::CImage*)RenderTargetSurface)->fill( color ); + } + + return true; +} + + +//! sets a render target +void CSoftwareDriver2::setRenderTarget(video::CImage* image) +{ + if (RenderTargetSurface) + RenderTargetSurface->drop(); + + RenderTargetSurface = image; + RenderTargetSize.Width = 0; + RenderTargetSize.Height = 0; + + if (RenderTargetSurface) + { + RenderTargetSurface->grab(); + RenderTargetSize = RenderTargetSurface->getDimension(); + } + + setViewPort(core::rect(0,0,RenderTargetSize.Width,RenderTargetSize.Height)); + + if (DepthBuffer) + DepthBuffer->setSize(RenderTargetSize); +} + + + +//! sets a viewport +void CSoftwareDriver2::setViewPort(const core::rect& area) +{ + ViewPort = area; + + core::rect rendert(0,0,RenderTargetSize.Width,RenderTargetSize.Height); + ViewPort.clipAgainst(rendert); + + Transformation [ ETS_CLIPSCALE ].m.buildNDCToDCMatrix ( ViewPort, 1 ); + + + if (CurrentShader) + CurrentShader->setRenderTarget(RenderTargetSurface, ViewPort); +} + +/* + generic plane clipping in homogenous coordinates + special case ndc frustum <-w,w>,<-w,w>,<-w,w> + can be rewritten with compares e.q near plane, a.z < -a.w and b.z < -b.w +*/ + +const sVec4 CSoftwareDriver2::NDCPlane[6] = +{ + sVec4( 0.f, 0.f, -1.f, -1.f ), // near + sVec4( 0.f, 0.f, 1.f, -1.f ), // far + sVec4( 1.f, 0.f, 0.f, -1.f ), // left + sVec4( -1.f, 0.f, 0.f, -1.f ), // right + sVec4( 0.f, 1.f, 0.f, -1.f ), // bottom + sVec4( 0.f, -1.f, 0.f, -1.f ) // top +}; + + + +/* + test a vertex if it's inside the standard frustum + + this is the generic one.. + + f32 dotPlane; + for ( u32 i = 0; i!= 6; ++i ) + { + dotPlane = v->Pos.dotProduct ( NDCPlane[i] ); + setbit ( flag, dotPlane <= 0.f, 1 << i ); + } + + // this is the base for ndc frustum <-w,w>,<-w,w>,<-w,w> + setbits ( flag, ( v->Pos.z - v->Pos.w ) <= 0.f, 1 ); + setbits ( flag, (-v->Pos.z - v->Pos.w ) <= 0.f, 2 ); + setbits ( flag, ( v->Pos.x - v->Pos.w ) <= 0.f, 4 ); + setbits ( flag, (-v->Pos.x - v->Pos.w ) <= 0.f, 8 ); + setbits ( flag, ( v->Pos.y - v->Pos.w ) <= 0.f, 16 ); + setbits ( flag, (-v->Pos.y - v->Pos.w ) <= 0.f, 32 ); + +*/ +#ifdef _MSC_VER + +REALINLINE u32 CSoftwareDriver2::clipToFrustumTest ( const s4DVertex * v ) const +{ + f32 test[6]; + u32 flag; + const f32 w = - v->Pos.w; + + // a conditional move is needed....FCOMI ( but we don't have it ) + // so let the fpu calculate and write it back. + // cpu makes the compare, interleaving + + test[0] = v->Pos.z + w; + test[1] = -v->Pos.z + w; + test[2] = v->Pos.x + w; + test[3] = -v->Pos.x + w; + test[4] = v->Pos.y + w; + test[5] = -v->Pos.y + w; + + flag = (IR ( test[0] ) ) >> 31; + flag |= (IR ( test[1] ) & 0x80000000 ) >> 30; + flag |= (IR ( test[2] ) & 0x80000000 ) >> 29; + flag |= (IR ( test[3] ) & 0x80000000 ) >> 28; + flag |= (IR ( test[4] ) & 0x80000000 ) >> 27; + flag |= (IR ( test[5] ) & 0x80000000 ) >> 26; + +/* + flag = F32_LOWER_EQUAL_0 ( test[0] ); + flag |= F32_LOWER_EQUAL_0 ( test[1] ) << 1; + flag |= F32_LOWER_EQUAL_0 ( test[2] ) << 2; + flag |= F32_LOWER_EQUAL_0 ( test[3] ) << 3; + flag |= F32_LOWER_EQUAL_0 ( test[4] ) << 4; + flag |= F32_LOWER_EQUAL_0 ( test[5] ) << 5; +*/ + return flag; +} + +#else + + +REALINLINE u32 CSoftwareDriver2::clipToFrustumTest ( const s4DVertex * v ) const +{ + u32 flag = 0; + for ( u32 i = 0; i!= 6; ++i ) + { + core::setbit ( flag, v->Pos.dotProduct ( NDCPlane[i] ) <= 0.f, 1 << i ); + } + return flag; +} + +#endif // _MSC_VER + +u32 CSoftwareDriver2::clipToHyperPlane ( s4DVertex * dest, const s4DVertex * source, u32 inCount, const sVec4 &plane ) +{ + u32 outCount = 0; + s4DVertex * out = dest; + + const s4DVertex * a; + const s4DVertex * b = source; + + f32 bDotPlane; + + bDotPlane = b->Pos.dotProduct ( plane ); + + for( u32 i = 1; i < inCount + 1; ++i) + { + const s32 condition = i - inCount; + const s32 index = (( ( condition >> 31 ) & ( i ^ condition ) ) ^ condition ) << 1; + + a = &source[ index ]; + + // current point inside + if ( a->Pos.dotProduct ( plane ) <= 0.f ) + { + // last point outside + if ( F32_GREATER_0 ( bDotPlane ) ) + { + // intersect line segment with plane + out->interpolate ( *b, *a, bDotPlane / (b->Pos - a->Pos).dotProduct ( plane ) ); + out += 2; + outCount += 1; + } + + // copy current to out + //*out = *a; + memcpy32_small ( out, a, SIZEOF_SVERTEX * 2 ); + b = out; + + out += 2; + outCount += 1; + } + else + { + // current point outside + + if ( F32_LOWER_EQUAL_0 ( bDotPlane ) ) + { + // previous was inside + // intersect line segment with plane + out->interpolate ( *b, *a, bDotPlane / (b->Pos - a->Pos).dotProduct ( plane ) ); + out += 2; + outCount += 1; + } + // pointer + b = a; + } + + bDotPlane = b->Pos.dotProduct ( plane ); + + } + + return outCount; +} + + +u32 CSoftwareDriver2::clipToFrustum ( s4DVertex *v0, s4DVertex * v1, const u32 vIn ) +{ + u32 vOut = vIn; + + vOut = clipToHyperPlane ( v1, v0, vOut, NDCPlane[0] ); if ( vOut < vIn ) return vOut; + vOut = clipToHyperPlane ( v0, v1, vOut, NDCPlane[1] ); if ( vOut < vIn ) return vOut; + vOut = clipToHyperPlane ( v1, v0, vOut, NDCPlane[2] ); if ( vOut < vIn ) return vOut; + vOut = clipToHyperPlane ( v0, v1, vOut, NDCPlane[3] ); if ( vOut < vIn ) return vOut; + vOut = clipToHyperPlane ( v1, v0, vOut, NDCPlane[4] ); if ( vOut < vIn ) return vOut; + vOut = clipToHyperPlane ( v0, v1, vOut, NDCPlane[5] ); + return vOut; +} + +/*! + Part I: + apply Clip Scale matrix + From Normalized Device Coordiante ( NDC ) Space to Device Coordinate Space ( DC ) + + Part II: + Project homogeneous vector + homogeneous to non-homogenous coordinates ( dividebyW ) + + Incoming: ( xw, yw, zw, w, u, v, 1, R, G, B, A ) + Outgoing: ( xw/w, yw/w, zw/w, w/w, u/w, v/w, 1/w, R/w, G/w, B/w, A/w ) + + + replace w/w by 1/w +*/ +inline void CSoftwareDriver2::ndc_2_dc_and_project ( s4DVertex *dest,s4DVertex *source, u32 vIn ) const +{ + u32 g; + + for ( g = 0; g != vIn; g += 2 ) + { + if ( (dest[g].flag & VERTEX4D_PROJECTED ) == VERTEX4D_PROJECTED ) + continue; + + dest[g].flag = source[g].flag | VERTEX4D_PROJECTED; + + const f32 w = source[g].Pos.w; + const f32 iw = core::reciprocal ( w ); + + // to device coordinates + dest[g].Pos.x = iw * ( source[g].Pos.x * Transformation [ ETS_CLIPSCALE ].m[ 0] + w * Transformation [ ETS_CLIPSCALE ].m[12] ); + dest[g].Pos.y = iw * ( source[g].Pos.y * Transformation [ ETS_CLIPSCALE ].m[ 5] + w * Transformation [ ETS_CLIPSCALE ].m[13] ); + +#ifndef SOFTWARE_DRIVER_2_USE_WBUFFER + dest[g].Pos.z = iw * source[g].Pos.z; +#endif + + #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + dest[g].Color[0] = source[g].Color[0] * iw; + #else + dest[g].Color[0] = source[g].Color[0]; + #endif + + #endif + + dest[g].Pos.w = iw; + + } + +} + + +inline void CSoftwareDriver2::ndc_2_dc_and_project2 ( const s4DVertex **v, const u32 size ) const +{ + u32 g; + + for ( g = 0; g != size; g += 1 ) + { + s4DVertex * a = (s4DVertex*) v[g]; + + if ( (a[1].flag & VERTEX4D_PROJECTED ) == VERTEX4D_PROJECTED ) + continue; + + a[1].flag = a->flag | VERTEX4D_PROJECTED; + + // project homogenous vertex, store 1/w + const f32 w = a->Pos.w; + const f32 iw = core::reciprocal ( w ); + + // to device coordinates + a[1].Pos.x = iw * ( a->Pos.x * Transformation [ ETS_CLIPSCALE ].m[ 0] + w * Transformation [ ETS_CLIPSCALE ].m[12] ); + a[1].Pos.y = iw * ( a->Pos.y * Transformation [ ETS_CLIPSCALE ].m[ 5] + w * Transformation [ ETS_CLIPSCALE ].m[13] ); + +#ifndef SOFTWARE_DRIVER_2_USE_WBUFFER + a[1].Pos.z = a->Pos.z * iw; +#endif + + #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + a[1].Color[0] = a->Color[0] * iw; + #else + a[1].Color[0] = a->Color[0]; + #endif + #endif + + a[1].Pos.w = iw; + + } + +} + + +/*! + crossproduct in projected 2D -> screen area triangle +*/ +inline f32 CSoftwareDriver2::screenarea ( const s4DVertex *v ) const +{ + return ( ( v[3].Pos.x - v[1].Pos.x ) * ( v[5].Pos.y - v[1].Pos.y ) ) - + ( ( v[3].Pos.y - v[1].Pos.y ) * ( v[5].Pos.x - v[1].Pos.x ) ); +} + + +/*! +*/ +inline f32 CSoftwareDriver2::texelarea ( const s4DVertex *v, int tex ) const +{ + f32 x0,y0, x1,y1, z; + + x0 = v[2].Tex[tex].x - v[0].Tex[tex].x; + y0 = v[2].Tex[tex].y - v[0].Tex[tex].y; + x1 = v[4].Tex[tex].x - v[0].Tex[tex].x; + y1 = v[4].Tex[tex].y - v[0].Tex[tex].y; + + z = x0*y1 - x1*y0; + + const core::dimension2d &d = Texmap[tex].Texture->getOriginalSize(); + z *= d.Height; + z *= d.Width; + return z; +} + +/*! + crossproduct in projected 2D +*/ +inline f32 CSoftwareDriver2::screenarea2 ( const s4DVertex **v ) const +{ + return ( (( v[1] + 1 )->Pos.x - (v[0] + 1 )->Pos.x ) * ( (v[2] + 1 )->Pos.y - (v[0] + 1 )->Pos.y ) ) - + ( (( v[1] + 1 )->Pos.y - (v[0] + 1 )->Pos.y ) * ( (v[2] + 1 )->Pos.x - (v[0] + 1 )->Pos.x ) ); +} + +/*! +*/ +inline f32 CSoftwareDriver2::texelarea2 ( const s4DVertex **v, s32 tex ) const +{ + f32 z; + + z = (v[1]->Tex[tex].x - v[0]->Tex[tex].x ) * + (v[2]->Tex[tex].y - v[0]->Tex[tex].y ) + - (v[2]->Tex[tex].x - v[0]->Tex[tex].x ) * + (v[1]->Tex[tex].y - v[0]->Tex[tex].y ) + ; + + const core::dimension2d &d = Texmap[tex].Texture->getOriginalSize(); + z *= d.Height; + z *= d.Width; + return z; +} + + + + +/*! +*/ +inline void CSoftwareDriver2::select_polygon_mipmap ( s4DVertex *v, u32 vIn, s32 tex ) +{ + f32 f[2]; + const core::dimension2d& dim = Texmap[tex].Texture->getSize(); + + f[0] = (f32) dim.Width; + f[1] = (f32) dim.Height; + +#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + for ( u32 g = 0; g != vIn; g += 2 ) + { + (v + g + 1 )->Tex[tex].x = (v + g + 0)->Tex[tex].x * ( v + g + 1 )->Pos.w * f[0]; + (v + g + 1 )->Tex[tex].y = (v + g + 0)->Tex[tex].y * ( v + g + 1 )->Pos.w * f[1]; + } +#else + for ( u32 g = 0; g != vIn; g += 2 ) + { + (v + g + 1 )->Tex[tex].x = (v + g + 0)->Tex[tex].x * f[0]; + (v + g + 1 )->Tex[tex].y = (v + g + 0)->Tex[tex].y * f[1]; + } +#endif +} + +inline void CSoftwareDriver2::select_polygon_mipmap2 ( s4DVertex **v, s32 tex ) const +{ + f32 f[2]; + const core::dimension2d& dim = Texmap[tex].Texture->getSize(); + + f[0] = (f32) dim.Width; + f[1] = (f32) dim.Height; + +#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + (v[0] + 1 )->Tex[tex].x = v[0]->Tex[tex].x * ( v[0] + 1 )->Pos.w * f[0]; + (v[0] + 1 )->Tex[tex].y = v[0]->Tex[tex].y * ( v[0] + 1 )->Pos.w * f[1]; + + (v[1] + 1 )->Tex[tex].x = v[1]->Tex[tex].x * ( v[1] + 1 )->Pos.w * f[0]; + (v[1] + 1 )->Tex[tex].y = v[1]->Tex[tex].y * ( v[1] + 1 )->Pos.w * f[1]; + + (v[2] + 1 )->Tex[tex].x = v[2]->Tex[tex].x * ( v[2] + 1 )->Pos.w * f[0]; + (v[2] + 1 )->Tex[tex].y = v[2]->Tex[tex].y * ( v[2] + 1 )->Pos.w * f[1]; + +#else + (v[0] + 1 )->Tex[tex].x = v[0]->Tex[tex].x * f[0]; + (v[0] + 1 )->Tex[tex].y = v[0]->Tex[tex].y * f[1]; + + (v[1] + 1 )->Tex[tex].x = v[1]->Tex[tex].x * f[0]; + (v[1] + 1 )->Tex[tex].y = v[1]->Tex[tex].y * f[1]; + + (v[2] + 1 )->Tex[tex].x = v[2]->Tex[tex].x * f[0]; + (v[2] + 1 )->Tex[tex].y = v[2]->Tex[tex].y * f[1]; +#endif +} + +// Vertex Cache +const SVSize CSoftwareDriver2::vSize[] = +{ + { VERTEX4D_FORMAT_0, sizeof(S3DVertex),1 }, + { VERTEX4D_FORMAT_1, sizeof(S3DVertex2TCoords),2 }, + { VERTEX4D_FORMAT_2, sizeof(S3DVertexTangents),2 } +}; + + + +/*! + fill a cache line with transformed, light and clipp test triangles +*/ +void CSoftwareDriver2::VertexCache_fill(const u32 sourceIndex, + const u32 destIndex) +{ + u8 * source; + s4DVertex *dest; + + source = (u8*) VertexCache.vertices + ( sourceIndex * vSize[VertexCache.vType].Pitch ); + + // it's a look ahead so we never hit it.. + // but give priority... + //VertexCache.info[ destIndex ].hit = hitCount; + + // store info + VertexCache.info[ destIndex ].index = sourceIndex; + VertexCache.info[ destIndex ].hit = 0; + + // destination Vertex + dest = (s4DVertex *) ( (u8*) VertexCache.mem.data + ( destIndex << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); + + // transform Model * World * Camera * Projection * NDCSpace matrix + Transformation [ ETS_CURRENT].m.transformVect ( &dest->Pos.x, ((S3DVertex*) source )->Pos ); + +#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + + // light Vertex + #ifdef SOFTWARE_DRIVER_2_LIGHTING + lightVertex ( dest, ((S3DVertex*) source ) ); + #else + dest->Color[0].setA8R8G8B8 ( ((S3DVertex*) source )->Color.color ); + #endif +#endif + + // transfer texture coordinates + if ( Transformation [ ETS_TEXTURE_0 ].isIdentity ) + { + // only look on first transform + memcpy32_small ( &dest->Tex[0], + &((S3DVertex*) source )->TCoords, + vSize[VertexCache.vType].TexSize * ( sizeof ( f32 ) * 2 ) + ); + } + else + { + /* + Generate texture coordinates as linear functions so that: + u = Ux*x + Uy*y + Uz*z + Uw + v = Vx*x + Vy*y + Vz*z + Vw + The matrix M for this case is: + Ux Vx 0 0 + Uy Vy 0 0 + Uz Vz 0 0 + Uw Vw 0 0 + */ + + const core::vector2d *src = &((S3DVertex*) source )->TCoords; + u32 t; + + for ( t = 0; t != vSize[VertexCache.vType].TexSize; ++t ) + { + const core::matrix4& M = Transformation [ ETS_TEXTURE_0 + t ].m; + if ( Material.org.TextureWrap[0]==ETC_REPEAT ) + { + dest->Tex[t].x = M[0] * src[t].X + M[4] * src[t].Y + M[8]; + dest->Tex[t].y = M[1] * src[t].X + M[5] * src[t].Y + M[9]; + } + else + { + f32 tx1, ty1; + + tx1 = M[0] * src[t].X + M[4] * src[t].Y + M[8]; + ty1 = M[1] * src[t].X + M[5] * src[t].Y + M[9]; + + dest->Tex[t].x = tx1 <= 0.f ? 0.f : tx1 >= 1.f ? 1.f : tx1; + dest->Tex[t].y = ty1 <= 0.f ? 0.f : ty1 >= 1.f ? 1.f : ty1; + + //dest->Tex[t].x = core::clamp ( M[0] * src[t].X + M[4] * src[t].Y + M[8], 0.f, 1.f ); + //dest->Tex[t].y = core::clamp ( M[1] * src[t].X + M[5] * src[t].Y + M[9], 0.f, 1.f ); + } + } + + } + + dest[0].flag = dest[1].flag = vSize[VertexCache.vType].Format; + + // test vertex + dest[0].flag |= clipToFrustumTest ( dest); + + // to DC Space, project homogenous vertex + if ( (dest[0].flag & VERTEX4D_CLIPMASK ) == VERTEX4D_INSIDE ) + { + ndc_2_dc_and_project2 ( (const s4DVertex**) &dest, 1 ); + } + + //return dest; +} + +// + +REALINLINE s4DVertex * CSoftwareDriver2::VertexCache_getVertex ( const u32 sourceIndex ) +{ + for ( s32 i = 0; i < VERTEXCACHE_ELEMENT; ++i ) + { + if ( VertexCache.info[ i ].index == sourceIndex ) + { + return (s4DVertex *) ( (u8*) VertexCache.mem.data + ( i << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); + } + } + return 0; +} + + +/* + Cache based on linear walk indices + fill blockwise on the next 16(Cache_Size) unique vertices in indexlist + merge the next 16 vertices with the current +*/ +REALINLINE void CSoftwareDriver2::VertexCache_get ( s4DVertex ** face ) +{ + SCacheInfo info[VERTEXCACHE_ELEMENT]; + + // next primitive must be complete in cache + if ( VertexCache.indicesIndex - VertexCache.indicesRun < 3 && + VertexCache.indicesIndex < VertexCache.indexCount + ) + { + // rewind to start of primitive + VertexCache.indicesIndex = VertexCache.indicesRun; + + memset32 ( info, VERTEXCACHE_MISS, sizeof ( info ) ); + + // get the next unique vertices cache line + u32 fillIndex = 0; + u32 dIndex; + u32 i; + + while ( VertexCache.indicesIndex < VertexCache.indexCount && + fillIndex < VERTEXCACHE_ELEMENT + ) + { + u32 sourceIndex = VertexCache.indices [ VertexCache.indicesIndex++ ]; + + // if not exist, push back + s32 exist = 0; + for ( dIndex = 0; dIndex < fillIndex; ++dIndex ) + { + if ( info[ dIndex ].index == sourceIndex ) + { + exist = 1; + break; + } + } + + if ( 0 == exist ) + { + info[fillIndex++].index = sourceIndex; + } + } + + // clear marks + for ( i = 0; i!= VERTEXCACHE_ELEMENT; ++i ) + { + VertexCache.info[i].hit = 0; + } + + // mark all exisiting + for ( i = 0; i!= fillIndex; ++i ) + { + for ( dIndex = 0; dIndex < VERTEXCACHE_ELEMENT; ++dIndex ) + { + if ( VertexCache.info[ dIndex ].index == info[i].index ) + { + info[i].hit = dIndex; + VertexCache.info[ dIndex ].hit = 1; + break; + } + } + } + + // fill new + for ( i = 0; i!= fillIndex; ++i ) + { + if ( info[i].hit != VERTEXCACHE_MISS ) + continue; + + for ( dIndex = 0; dIndex < VERTEXCACHE_ELEMENT; ++dIndex ) + { + if ( 0 == VertexCache.info[dIndex].hit ) + { + VertexCache_fill ( info[i].index, dIndex ); + VertexCache.info[dIndex].hit += 1; + info[i].hit = dIndex; + break; + } + } + } + } + + const u32 i0 = core::if_c_a_else_0 ( VertexCache.pType != scene::EPT_TRIANGLE_FAN, VertexCache.indicesRun ); + + face[0] = VertexCache_getVertex ( VertexCache.indices[ i0 ] ); + face[1] = VertexCache_getVertex ( VertexCache.indices[ VertexCache.indicesRun + 1] ); + face[2] = VertexCache_getVertex ( VertexCache.indices[ VertexCache.indicesRun + 2] ); + + VertexCache.indicesRun += VertexCache.primitivePitch; +} + +REALINLINE void CSoftwareDriver2::VertexCache_get2 ( s4DVertex ** face ) +{ + const u32 i0 = core::if_c_a_else_0 ( VertexCache.pType != scene::EPT_TRIANGLE_FAN, VertexCache.indicesRun ); + + VertexCache_fill ( VertexCache.indices[ i0 ], 0 ); + VertexCache_fill ( VertexCache.indices[ VertexCache.indicesRun + 1], 1 ); + VertexCache_fill ( VertexCache.indices[ VertexCache.indicesRun + 2], 2 ); + + VertexCache.indicesRun += VertexCache.primitivePitch; + + face[0] = (s4DVertex *) ( (u8*) VertexCache.mem.data + ( 0 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); + face[1] = (s4DVertex *) ( (u8*) VertexCache.mem.data + ( 1 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); + face[2] = (s4DVertex *) ( (u8*) VertexCache.mem.data + ( 2 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); + +} + +void CSoftwareDriver2::VertexCache_reset ( const void* vertices, u32 vertexCount, + const u16* indices, u32 primitiveCount, + E_VERTEX_TYPE vType,scene::E_PRIMITIVE_TYPE pType ) +{ + VertexCache.vertices = vertices; + VertexCache.vertexCount = vertexCount; + + VertexCache.indices = indices; + VertexCache.indicesIndex = 0; + VertexCache.indicesRun = 0; + + VertexCache.vType = vType; + VertexCache.pType = pType; + + switch ( VertexCache.pType ) + { + case scene::EPT_TRIANGLES: + VertexCache.indexCount = primitiveCount + primitiveCount + primitiveCount; + VertexCache.primitivePitch = 3; + break; + case scene::EPT_TRIANGLE_FAN: + VertexCache.indexCount = primitiveCount + 2; + VertexCache.primitivePitch = 1; + break; + } + + memset32 ( VertexCache.info, VERTEXCACHE_MISS, sizeof ( VertexCache.info ) ); + +} + + +//! draws a vertex primitive list +void CSoftwareDriver2::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) +{ + if (!checkPrimitiveCount(primitiveCount)) + return; + + CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType); + + if ( 0 == CurrentShader ) + return; + + + VertexCache_reset ( vertices, vertexCount, indexList, primitiveCount, vType, pType ); + + const s4DVertex * face[3]; + + f32 dc_area; + s32 lodLevel; + u32 i; + u32 g; + + for ( i = 0; i < (u32) primitiveCount; ++i ) + { + VertexCache_get ( (s4DVertex**) face ); + + // if fully outside or outside on same side + if ( ( (face[0]->flag | face[1]->flag | face[2]->flag) & VERTEX4D_CLIPMASK ) + != VERTEX4D_INSIDE + ) + continue; + + // if fully inside + if ( ( face[0]->flag & face[1]->flag & face[2]->flag & VERTEX4D_CLIPMASK ) == VERTEX4D_INSIDE ) + { + dc_area = screenarea2 ( face ); + if ( Material.org.BackfaceCulling && F32_LOWER_EQUAL_0 ( dc_area ) ) + { + continue; + } + + dc_area = core::reciprocal ( dc_area ); + // select mipmap + for ( g = 0; g != 2; ++g ) + { + if ( 0 == Texmap[g].Texture ) + { + CurrentShader->setTexture(g, 0, 0); + continue; + } + + lodLevel = s32_log2_f32 ( texelarea2 ( face, g ) * dc_area ); + + CurrentShader->setTexture(g, Texmap[g].Texture, lodLevel); + select_polygon_mipmap2 ( (s4DVertex**) face, g ); + + } + + // rasterize + CurrentShader->drawTriangle ( face[0] + 1, face[1] + 1, face[2] + 1 ); + continue; + } + + // else if not complete inside clipping necessary + memcpy32_small ( ( (u8*) CurrentOut.data + ( 0 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ), face[0], SIZEOF_SVERTEX * 2 ); + memcpy32_small ( ( (u8*) CurrentOut.data + ( 1 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ), face[1], SIZEOF_SVERTEX * 2 ); + memcpy32_small ( ( (u8*) CurrentOut.data + ( 2 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ), face[2], SIZEOF_SVERTEX * 2 ); + + u32 flag = CurrentOut.data->flag & VERTEX4D_FORMAT_MASK; + + for ( g = 0; g != CurrentOut.ElementSize; ++g ) + { + CurrentOut.data[g].flag = flag; + Temp.data[g].flag = flag; + } + + u32 vOut; + vOut = clipToFrustum ( CurrentOut.data, Temp.data, 3 ); +/* + if ( vOut < 3 ) + { + char buf[256]; + struct SCheck + { + u32 flag; + const char * name; + }; + + SCheck check[5]; + check[0].flag = face[0]->flag; + check[0].name = "face0"; + check[1].flag = face[1]->flag; + check[1].name = "face1"; + check[2].flag = face[2]->flag; + check[2].name = "face2"; + check[3].flag = (face[0]->flag & face[1]->flag & face[2]->flag); + check[3].name = "AND "; + check[4].flag = (face[0]->flag | face[1]->flag | face[2]->flag); + check[4].name = "OR "; + + for ( s32 h = 0; h!= 5; ++h ) + { + sprintf ( buf, "%s: %d %d %d %d %d %d", + check[h].name, + ( check[h].flag & 1 ), + ( check[h].flag & 2 ) >> 1, + ( check[h].flag & 4 ) >> 2, + ( check[h].flag & 8 ) >> 3, + ( check[h].flag & 16 ) >> 4, + ( check[h].flag & 32 ) >> 5 + ); + os::Printer::print ( buf ); + } + + sprintf ( buf, "Vout: %d\n", vOut ); + os::Printer::print ( buf ); + + int hold = 1; + } +*/ + if ( vOut < 3 ) + continue; + + vOut <<= 1; + + // to DC Space, project homogenous vertex + ndc_2_dc_and_project ( CurrentOut.data + 1, CurrentOut.data, vOut ); + +/* + // if not complete inside clipping necessary + if ( ( test & VERTEX4D_INSIDE ) != VERTEX4D_INSIDE ) + { + u32 v[2] = { PointerAsValue ( Temp ) , PointerAsValue ( CurrentOut ) }; + for ( g = 0; g != 6; ++g ) + { + vOut = clipToHyperPlane ( (s4DVertex*) v[0], (s4DVertex*) v[1], vOut, NDCPlane[g] ); + if ( vOut < 3 ) + break; + + v[0] ^= v[1]; + v[1] ^= v[0]; + v[0] ^= v[1]; + + } + + if ( vOut < 3 ) + continue; + + } +*/ + + // check 2d backface culling on first + dc_area = screenarea ( CurrentOut.data ); + if ( Material.org.BackfaceCulling && F32_LOWER_EQUAL_0 ( dc_area ) ) + continue; + + // select mipmap + for ( g = 0; g != 2; ++g ) + { + if ( 0 == Texmap[g].Texture ) + { + CurrentShader->setTexture(g, 0, 0); + continue; + } + + lodLevel = s32_log2_f32 ( texelarea ( CurrentOut.data, g ) / dc_area ); + + CurrentShader->setTexture(g, Texmap[g].Texture, lodLevel); + select_polygon_mipmap ( CurrentOut.data, vOut, g ); + } + + // re-tesselate ( triangle-fan, 0-1-2,0-2-3.. ) + for ( g = 0; g <= vOut - 6; g += 2 ) + { + // rasterize + CurrentShader->drawTriangle ( CurrentOut.data + 0 + 1, + CurrentOut.data + g + 3, + CurrentOut.data + g + 5 + ); + } + + } + + // dump statistics +/* + char buf [64]; + sprintf ( buf,"VCount:%d PCount:%d CacheMiss: %d", + vertexCount, primitiveCount, + VertexCache.CacheMiss + ); + os::Printer::print ( buf ); +*/ +} + +//! Sets the dynamic ambient light color. The default color is +//! (0,0,0,0) which means it is dark. +//! \param color: New color of the ambient light. +void CSoftwareDriver2::setAmbientLight(const SColorf& color) +{ + Global_AmbientLight.setColorf ( color ); +} + + +//! adds a dynamic light +void CSoftwareDriver2::addDynamicLight(const SLight& dl) +{ + if ( Light.size () >= getMaximalDynamicLightAmount () ) + return; + + SInternalLight l; + l.org = dl; + + // light in eye space + Transformation[ETS_VIEW].m.transformVect ( &l.posEyeSpace.x, l.org.Position ); + + l.constantAttenuation = 0.f; + l.linearAttenuation = core::reciprocal ( l.org.Radius ); + l.quadraticAttenuation = 0.f; + + l.AmbientColor.setColorf ( l.org.AmbientColor ); + l.DiffuseColor.setColorf ( l.org.DiffuseColor ); + l.SpecularColor.setColorf ( l.org.SpecularColor ); + + switch ( dl.Type ) + { + case video::ELT_DIRECTIONAL: + { + l.posEyeSpace.normalize_xyz (); + } break; + } + + Light.push_back ( l ); + CNullDriver::addDynamicLight( l.org ); +} + +//! deletes all dynamic lights there are +void CSoftwareDriver2::deleteAllDynamicLights() +{ + Light.set_used ( 0 ); + CNullDriver::deleteAllDynamicLights(); + +} + +//! returns the maximal amount of dynamic lights the device can handle +u32 CSoftwareDriver2::getMaximalDynamicLightAmount() +{ + return 8; +} + + + +#ifdef SOFTWARE_DRIVER_2_LIGHTING + +/*! +*/ +void CSoftwareDriver2::lightVertex ( s4DVertex *dest, const S3DVertex *source ) +{ + // apply lighting model + if ( false == Material.org.Lighting ) + { + // should use the DiffuseColor but using pre-lit vertex color + dest->Color[0].setA8R8G8B8 ( source->Color.color ); + return; + } + + if ( Lights.size () == 0 ) + { + dest->Color[0] = Material.EmissiveColor; + return; + } + + // eyespace +/* + core::matrix4 modelview = Transformation[ETS_WORLD].m * Transformation[ETS_VIEW].m; + + core::matrix4 m2 ( modelview ); + m2.makeInverse (); + core::matrix4 modelviewinversetransposed ( m2.getTransposed() ); +*/ + + sVec4 vertexEyeSpace; + sVec4 normalEyeSpace; + sVec4 vertexEyeSpaceUnit; + + // vertex in eye space + Transformation[ETS_WORLD_VIEW].m.transformVect ( &vertexEyeSpace.x, source->Pos ); + vertexEyeSpace.project_xyz (); + + vertexEyeSpaceUnit = vertexEyeSpace; + vertexEyeSpaceUnit.normalize_xyz(); + + // vertex normal in eye-space + //modelviewinversetransposed.transformVect ( &normalEyeSpace.x, source->Normal ); + Transformation[ETS_WORLD_VIEW_INVERSE_TRANSPOSED].m.rotateVect ( &normalEyeSpace.x, source->Normal ); + if ( Material.org.NormalizeNormals ) + { + normalEyeSpace.normalize_xyz(); + } + + + sVec4 ambient; + sVec4 diffuse; + sVec4 specular; + + + // the universe started in darkness.. + ambient.set ( 0.f, 0.f, 0.f, 0.f ); + diffuse.set ( 0.f, 0.f, 0.f, 0.f ); + specular.set ( 0.f, 0.f, 0.f, 0.f ); + + f32 attenuation = 1.f; + + u32 i; + for ( i = 0; i!= Light.size (); ++i ) + { + const SInternalLight &light = Light[i]; + + sVec4 vp; // unit vector vertex to light + sVec4 lightHalf; // blinn-phong reflection + + + switch ( light.org.Type ) + { + case video::ELT_POINT: + { + // surface to light + vp.x = light.posEyeSpace.x - vertexEyeSpace.x; + vp.y = light.posEyeSpace.y - vertexEyeSpace.y; + vp.z = light.posEyeSpace.z - vertexEyeSpace.z; + + // irrlicht attenuation model +#if 1 + const f32 d = vp.get_inverse_length_xyz(); + + vp.x *= d; + vp.y *= d; + vp.z *= d; + attenuation = light.org.Radius * d; + +#else + const f32 d = vp.get_length_xyz(); + attenuation = 1.f / (light.constantAttenuation + + light.linearAttenuation * d + + light.quadraticAttenuation * d * d + ); + + // normalize surface to light + vp.normalize_xyz(); +#endif + + lightHalf.x = vp.x - vertexEyeSpaceUnit.x; + lightHalf.y = vp.y - vertexEyeSpaceUnit.y; + lightHalf.z = vp.z - vertexEyeSpaceUnit.z; + lightHalf.normalize_xyz(); + + } break; + + case video::ELT_DIRECTIONAL: + { + attenuation = 1.f; + vp = light.posEyeSpace; + + // half angle = lightvector + eye vector ( 0, 0, 1 ) + lightHalf.x = vp.x; + lightHalf.y = vp.y; + lightHalf.z = vp.z - 1.f; + lightHalf.normalize_xyz(); + } break; + } + + // build diffuse reflection + + //angle between normal and light vector + f32 dotVP = core::max_ ( 0.f, normalEyeSpace.dot_xyz ( vp ) ); + f32 dotHV = core::max_ ( 0.f, normalEyeSpace.dot_xyz ( lightHalf ) ); + + f32 pf; + if ( dotVP == 0.0 ) + { + pf = 0.f; + } + else + { + pf = powf(dotHV, Material.org.Shininess ); + } + + // accumulate ambient + ambient += light.AmbientColor * attenuation; + diffuse += light.DiffuseColor * ( dotVP * attenuation ); + specular += light.SpecularColor * ( pf * attenuation ); + + } + + sVec4 dColor; + + dColor = Global_AmbientLight; + dColor += Material.EmissiveColor; + dColor += ambient * Material.AmbientColor; + dColor += diffuse * Material.DiffuseColor; + dColor += specular * Material.SpecularColor; + dColor.saturate(); + + dest->Color[0] = dColor; +} + +#endif + + +//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. +void CSoftwareDriver2::draw2DImage(video::ITexture* texture, const core::position2d& destPos, + const core::rect& sourceRect, + const core::rect* clipRect, SColor color, + bool useAlphaChannelOfTexture) +{ + if (texture) + { + if (texture->getDriverType() != EDT_BURNINGSVIDEO) + { + os::Printer::log("Fatal Error: Tried to copy from a surface not owned by this driver.", ELL_ERROR); + return; + } + + if (useAlphaChannelOfTexture) + ((CSoftwareTexture2*)texture)->getImage()->copyToWithAlpha( + BackBuffer, destPos, sourceRect, color, clipRect); + else + ((CSoftwareTexture2*)texture)->getImage()->copyTo( + BackBuffer, destPos, sourceRect, clipRect); + } +} + + + +//! Draws a 2d line. +void CSoftwareDriver2::draw2DLine(const core::position2d& start, + const core::position2d& end, + SColor color) +{ + ((CImage*)BackBuffer)->drawLine(start, end, color ); +} + + + +//! draw an 2d rectangle +void CSoftwareDriver2::draw2DRectangle(SColor color, const core::rect& pos, + const core::rect* clip) +{ + if (clip) + { + core::rect p(pos); + + p.clipAgainst(*clip); + + if(!p.isValid()) + return; + + BackBuffer->drawRectangle(p, color); + } + else + { + if(!pos.isValid()) + return; + + BackBuffer->drawRectangle(pos, color); + } +} + + + +//!Draws an 2d rectangle with a gradient. +void CSoftwareDriver2::draw2DRectangle(const core::rect& position, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect* clip) +{ +#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + + core::rect pos = position; + + if (clip) + pos.clipAgainst(*clip); + + if (!pos.isValid()) + return; + + const core::dimension2d renderTargetSize ( ViewPort.getSize() ); + + const s32 xPlus = -(renderTargetSize.Width>>1); + const f32 xFact = 1.0f / (renderTargetSize.Width>>1); + + const s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); + const f32 yFact = 1.0f / (renderTargetSize.Height>>1); + + // fill VertexCache direct + s4DVertex *v; + + VertexCache.vertexCount = 4; + + VertexCache.info[0].index = 0; + VertexCache.info[1].index = 1; + VertexCache.info[2].index = 2; + VertexCache.info[3].index = 3; + + v = &VertexCache.mem.data [ 0 ]; + + v[0].Pos.set ( (f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.UpperLeftCorner.Y) * yFact, 0.f, 1.f ); + v[0].Color[0].setA8R8G8B8 ( colorLeftUp.color ); + + v[2].Pos.set ( (f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus- pos.UpperLeftCorner.Y) * yFact, 0.f, 1.f ); + v[2].Color[0].setA8R8G8B8 ( colorRightUp.color ); + + v[4].Pos.set ( (f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.f ,1.f ); + v[4].Color[0].setA8R8G8B8 ( colorRightDown.color ); + + v[6].Pos.set ( (f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.f, 1.f ); + v[6].Color[0].setA8R8G8B8 ( colorLeftDown.color ); + + s32 i; + u32 g; + + for ( i = 0; i!= 8; i += 2 ) + { + v[i + 0].flag = clipToFrustumTest ( v + i ); + v[i + 1].flag = 0; + if ( (v[i].flag & VERTEX4D_INSIDE ) == VERTEX4D_INSIDE ) + { + ndc_2_dc_and_project ( v + i + 1, v + i, 2 ); + } + } + + + IBurningShader * render; + + render = BurningShader [ ETR_GOURAUD_ALPHA_NOZ ]; + render->setRenderTarget(RenderTargetSurface, ViewPort); + + static const s16 indexList[6] = {0,1,2,0,2,3}; + + s4DVertex * face[3]; + + for ( i = 0; i!= 6; i += 3 ) + { + face[0] = VertexCache_getVertex ( indexList [ i + 0 ] ); + face[1] = VertexCache_getVertex ( indexList [ i + 1 ] ); + face[2] = VertexCache_getVertex ( indexList [ i + 2 ] ); + + // test clipping + u32 test = face[0]->flag & face[1]->flag & face[2]->flag & VERTEX4D_INSIDE; + + if ( test == VERTEX4D_INSIDE ) + { + render->drawTriangle ( face[0] + 1, face[1] + 1, face[2] + 1 ); + continue; + } + // Todo: all vertices are clipped in 2d.. + // is this true ? + u32 vOut = 6; + memcpy ( CurrentOut.data + 0, face[0], sizeof ( s4DVertex ) * 2 ); + memcpy ( CurrentOut.data + 2, face[1], sizeof ( s4DVertex ) * 2 ); + memcpy ( CurrentOut.data + 4, face[2], sizeof ( s4DVertex ) * 2 ); + + vOut = clipToFrustum ( CurrentOut.data, Temp.data, 3 ); + if ( vOut < 3 ) + continue; + + vOut <<= 1; + // to DC Space, project homogenous vertex + ndc_2_dc_and_project ( CurrentOut.data + 1, CurrentOut.data, vOut ); + + // re-tesselate ( triangle-fan, 0-1-2,0-2-3.. ) + for ( g = 0; g <= vOut - 6; g += 2 ) + { + // rasterize + render->drawTriangle ( CurrentOut.data + 1, &CurrentOut.data[g + 3], &CurrentOut.data[g + 5] ); + } + + } +#else + draw2DRectangle ( colorLeftUp, position, clip ); +#endif +} + + + +//! Draws a 3d line. +void CSoftwareDriver2::draw3DLine(const core::vector3df& start, + const core::vector3df& end, SColor color) +{ + Transformation [ ETS_CURRENT].m.transformVect ( &CurrentOut.data[0].Pos.x, start ); + Transformation [ ETS_CURRENT].m.transformVect ( &CurrentOut.data[2].Pos.x, end ); + + u32 g; + u32 vOut; + + // no clipping flags + for ( g = 0; g != CurrentOut.ElementSize; ++g ) + { + CurrentOut.data[g].flag = 0; + Temp.data[g].flag = 0; + } + + // vertices count per line + vOut = clipToFrustum ( CurrentOut.data, Temp.data, 2 ); + if ( vOut < 2 ) + return; + + vOut <<= 1; + + IBurningShader * line; + line = BurningShader [ ETR_TEXTURE_GOURAUD_WIRE ]; + line->setRenderTarget(RenderTargetSurface, ViewPort); + + // to DC Space, project homogenous vertex + ndc_2_dc_and_project ( CurrentOut.data + 1, CurrentOut.data, vOut ); + + // unproject vertex color +#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + for ( g = 0; g != vOut; g+= 2 ) + { + CurrentOut.data[ g + 1].Color[0].setA8R8G8B8 ( color.color ); + } +#endif + + + for ( g = 0; g <= vOut - 4; g += 2 ) + { + // rasterize + line->drawLine ( CurrentOut.data + 1, CurrentOut.data + g + 3 ); + } +} + + + +//! \return Returns the name of the video driver. Example: In case of the DirectX8 +//! driver, it would return "Direct3D8.1". +const wchar_t* CSoftwareDriver2::getName() +{ +#ifdef BURNINGVIDEO_RENDERER_BEAUTIFUL + return L"burnings video 0.38b"; +#elif defined ( BURNINGVIDEO_RENDERER_ULTRA_FAST ) + return L"burnings video 0.38uf"; +#elif defined ( BURNINGVIDEO_RENDERER_FAST ) + return L"burnings video 0.38f"; +#else + return L"burnings video 0.38"; +#endif +} + +//! Returns type of video driver +E_DRIVER_TYPE CSoftwareDriver2::getDriverType() +{ + return EDT_BURNINGSVIDEO; +} + +//! Returns the transformation set by setTransform +const core::matrix4& CSoftwareDriver2::getTransform(E_TRANSFORMATION_STATE state) +{ + return Transformation[state].m; +} + +//! Creates a render target texture. +ITexture* CSoftwareDriver2::createRenderTargetTexture(const core::dimension2d& size) +{ + CImage* img = new CImage(ECF_SOFTWARE2, size); + + ITexture* tex = new CSoftwareTexture2(img, 0, false); + img->drop(); + return tex; +} + + +//! Clears the DepthBuffer. +void CSoftwareDriver2::clearZBuffer() +{ + if (DepthBuffer) + DepthBuffer->clear(); +} + + +//! Returns an image created from the last rendered frame. +IImage* CSoftwareDriver2::createScreenShot() +{ + return new CImage(BackBuffer->getColorFormat(), BackBuffer); +} + +//! Enables or disables a texture creation flag. +void CSoftwareDriver2::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) +{ + CNullDriver::setTextureCreationFlag(flag,enabled); +} + + +//! returns a device dependent texture from a software surface (IImage) +//! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES +ITexture* CSoftwareDriver2::createDeviceDependentTexture(IImage* surface, const char* name) +{ + return new CSoftwareTexture2(surface, name, getTextureCreationFlag(ETCF_CREATE_MIP_MAPS)); + +} + +//! Returns the maximum amount of primitives (mostly vertices) which +//! the device is able to render with one drawIndexedTriangleList +//! call. +u32 CSoftwareDriver2::getMaximalPrimitiveCount() +{ + return 0x00800000; +} + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a video driver +IVideoDriver* createSoftwareDriver2(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CSoftwareDriver2(windowSize, fullscreen, io, presenter); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + + +} // end namespace video +} // end namespace irr diff --git a/src/dep/src/irrlicht/CSoftwareDriver2.h b/src/dep/src/irrlicht/CSoftwareDriver2.h index dd7913d..5c21149 100644 --- a/src/dep/src/irrlicht/CSoftwareDriver2.h +++ b/src/dep/src/irrlicht/CSoftwareDriver2.h @@ -1,255 +1,255 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_VIDEO_2_SOFTWARE_H_INCLUDED__ -#define __C_VIDEO_2_SOFTWARE_H_INCLUDED__ - -#include "SoftwareDriver2_compile_config.h" -#include "IBurningShader.h" -#include "CNullDriver.h" -#include "CImage.h" -#include "os.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - class CSoftwareDriver2 : public CNullDriver - { - public: - - //! constructor - CSoftwareDriver2(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter); - - //! destructor - virtual ~CSoftwareDriver2(); - - //! presents the rendered scene on the screen, returns false if failed - virtual bool endScene( s32 windowId = 0, core::rect* sourceRect=0 ); - - //! queries the features of the driver, returns true if feature is available - virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature); - - //! sets transformation - virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); - - //! sets a material - virtual void setMaterial(const SMaterial& material); - - virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color); - - //! sets a viewport - virtual void setViewPort(const core::rect& area); - - //! clears the zbuffer - virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color); - - //! deletes all dynamic lights there are - virtual void deleteAllDynamicLights(); - - //! adds a dynamic light - virtual void addDynamicLight(const SLight& light); - - //! returns the maximal amount of dynamic lights the device can handle - virtual u32 getMaximalDynamicLightAmount(); - - //! Sets the dynamic ambient light color. The default color is - //! (0,0,0,0) which means it is dark. - //! \param color: New color of the ambient light. - virtual void setAmbientLight(const SColorf& color); - - //! draws a vertex primitive list - void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); - - //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. - virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos, - const core::rect& sourceRect, const core::rect* clipRect = 0, - SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); - - //! Draws a 3d line. - virtual void draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color = SColor(255,255,255,255)); - - //! draw an 2d rectangle - virtual void draw2DRectangle(SColor color, const core::rect& pos, - const core::rect* clip = 0); - - //!Draws an 2d rectangle with a gradient. - virtual void draw2DRectangle(const core::rect& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect* clip = 0); - - //! Draws a 2d line. - virtual void draw2DLine(const core::position2d& start, - const core::position2d& end, - SColor color=SColor(255,255,255,255)); - - //! \return Returns the name of the video driver. Example: In case of the DirectX8 - //! driver, it would return "Direct3D8.1". - virtual const wchar_t* getName(); - - //! Returns type of video driver - virtual E_DRIVER_TYPE getDriverType(); - - //! Returns the transformation set by setTransform - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state); - - //! Creates a render target texture. - virtual ITexture* createRenderTargetTexture(const core::dimension2d& size); - - //! Clears the DepthBuffer. - virtual void clearZBuffer(); - - //! Returns an image created from the last rendered frame. - virtual IImage* createScreenShot(); - - //! Enables or disables a texture creation flag. - virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled); - - //! Returns the maximum amount of primitives (mostly vertices) which - //! the device is able to render with one drawIndexedTriangleList - //! call. - virtual u32 getMaximalPrimitiveCount(); - - protected: - - //! sets a render target - void setRenderTarget(video::CImage* image); - - //! sets the current Texture - bool setTexture(u32 stage, video::ITexture* texture); - - //! returns a device dependent texture from a software surface (IImage) - //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES - virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const char* name); - - video::CImage* BackBuffer; - video::IImagePresenter* Presenter; - - video::ITexture* RenderTargetTexture; - video::IImage* RenderTargetSurface; - core::dimension2d RenderTargetSize; - - //! selects the right triangle renderer based on the render states. - void setCurrentShader(); - - IBurningShader* CurrentShader; - IBurningShader* BurningShader[ETR2_COUNT]; - - IDepthBuffer* DepthBuffer; - - video::ITexture* Texture[2]; - sInternalTexture Texmap[2]; - - /* - extend Matrix Stack - -> combined CameraProjection - -> combined CameraProjectionWorld - -> ClipScale from NDC to DC Space - */ - enum E_TRANSFORMATION_STATE_2 - { - ETS_VIEW_PROJECTION = ETS_COUNT, - ETS_WORLD_VIEW, - ETS_WORLD_VIEW_INVERSE_TRANSPOSED, - ETS_CURRENT, - ETS_CLIPSCALE, - - ETS2_COUNT - }; - - struct SMatrixStack - { - s32 isIdentity; - core::matrix4 m; - }; - - SMatrixStack Transformation[ETS2_COUNT]; - - // Vertex Cache - static const SVSize vSize[]; - - SVertexCache VertexCache; - - void VertexCache_reset (const void* vertices, u32 vertexCount, - const u16* indices, u32 indexCount, - E_VERTEX_TYPE vType,scene::E_PRIMITIVE_TYPE pType); - void VertexCache_get ( s4DVertex ** face ); - void VertexCache_get2 ( s4DVertex ** face ); - - void VertexCache_fill ( const u32 sourceIndex,const u32 destIndex ); - s4DVertex * VertexCache_getVertex ( const u32 sourceIndex ); - - - // culling & clipping - u32 clipToHyperPlane ( s4DVertex * dest, const s4DVertex * source, u32 inCount, const sVec4 &plane ); - u32 clipToFrustumTest ( const s4DVertex * v ) const; - u32 clipToFrustum ( s4DVertex *source, s4DVertex * temp, const u32 vIn ); - - -#ifdef SOFTWARE_DRIVER_2_LIGHTING - void lightVertex ( s4DVertex *dest, const S3DVertex *source ); -#endif - - - // holds transformed, clipped vertices - SAlignedVertex CurrentOut; - SAlignedVertex Temp; - - void ndc_2_dc_and_project ( s4DVertex *dest,s4DVertex *source, u32 vIn ) const; - f32 screenarea ( const s4DVertex *v0 ) const; - void select_polygon_mipmap ( s4DVertex *source, u32 vIn, s32 tex ); - f32 texelarea ( const s4DVertex *v0, int tex ) const; - - - void ndc_2_dc_and_project2 ( const s4DVertex **v, const u32 size ) const; - f32 screenarea2 ( const s4DVertex **v ) const; - f32 texelarea2 ( const s4DVertex **v, int tex ) const; - void select_polygon_mipmap2 ( s4DVertex **source, s32 tex ) const; - - - sVec4 Global_AmbientLight; - - struct SInternalLight - { - SLight org; - - sVec4 posEyeSpace; - - f32 constantAttenuation; - f32 linearAttenuation; - f32 quadraticAttenuation; - - sVec4 AmbientColor; - sVec4 DiffuseColor; - sVec4 SpecularColor; - }; - core::array Light; - - struct SInternalMaterial - { - SMaterial org; - - sVec4 AmbientColor; - sVec4 DiffuseColor; - sVec4 SpecularColor; - sVec4 EmissiveColor; - - u32 SpecularEnabled; // == Power2 - }; - - SInternalMaterial Material; - - static const sVec4 NDCPlane[6]; - - }; - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_VIDEO_2_SOFTWARE_H_INCLUDED__ +#define __C_VIDEO_2_SOFTWARE_H_INCLUDED__ + +#include "SoftwareDriver2_compile_config.h" +#include "IBurningShader.h" +#include "CNullDriver.h" +#include "CImage.h" +#include "os.h" +#include "irrString.h" + +namespace irr +{ +namespace video +{ + class CSoftwareDriver2 : public CNullDriver + { + public: + + //! constructor + CSoftwareDriver2(const core::dimension2d& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter); + + //! destructor + virtual ~CSoftwareDriver2(); + + //! presents the rendered scene on the screen, returns false if failed + virtual bool endScene( s32 windowId = 0, core::rect* sourceRect=0 ); + + //! queries the features of the driver, returns true if feature is available + virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature); + + //! sets transformation + virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); + + //! sets a material + virtual void setMaterial(const SMaterial& material); + + virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, + bool clearZBuffer, SColor color); + + //! sets a viewport + virtual void setViewPort(const core::rect& area); + + //! clears the zbuffer + virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color); + + //! deletes all dynamic lights there are + virtual void deleteAllDynamicLights(); + + //! adds a dynamic light + virtual void addDynamicLight(const SLight& light); + + //! returns the maximal amount of dynamic lights the device can handle + virtual u32 getMaximalDynamicLightAmount(); + + //! Sets the dynamic ambient light color. The default color is + //! (0,0,0,0) which means it is dark. + //! \param color: New color of the ambient light. + virtual void setAmbientLight(const SColorf& color); + + //! draws a vertex primitive list + void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); + + //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. + virtual void draw2DImage(video::ITexture* texture, const core::position2d& destPos, + const core::rect& sourceRect, const core::rect* clipRect = 0, + SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); + + //! Draws a 3d line. + virtual void draw3DLine(const core::vector3df& start, + const core::vector3df& end, SColor color = SColor(255,255,255,255)); + + //! draw an 2d rectangle + virtual void draw2DRectangle(SColor color, const core::rect& pos, + const core::rect* clip = 0); + + //!Draws an 2d rectangle with a gradient. + virtual void draw2DRectangle(const core::rect& pos, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect* clip = 0); + + //! Draws a 2d line. + virtual void draw2DLine(const core::position2d& start, + const core::position2d& end, + SColor color=SColor(255,255,255,255)); + + //! \return Returns the name of the video driver. Example: In case of the DirectX8 + //! driver, it would return "Direct3D8.1". + virtual const wchar_t* getName(); + + //! Returns type of video driver + virtual E_DRIVER_TYPE getDriverType(); + + //! Returns the transformation set by setTransform + virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state); + + //! Creates a render target texture. + virtual ITexture* createRenderTargetTexture(const core::dimension2d& size); + + //! Clears the DepthBuffer. + virtual void clearZBuffer(); + + //! Returns an image created from the last rendered frame. + virtual IImage* createScreenShot(); + + //! Enables or disables a texture creation flag. + virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled); + + //! Returns the maximum amount of primitives (mostly vertices) which + //! the device is able to render with one drawIndexedTriangleList + //! call. + virtual u32 getMaximalPrimitiveCount(); + + protected: + + //! sets a render target + void setRenderTarget(video::CImage* image); + + //! sets the current Texture + bool setTexture(u32 stage, video::ITexture* texture); + + //! returns a device dependent texture from a software surface (IImage) + //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES + virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const char* name); + + video::CImage* BackBuffer; + video::IImagePresenter* Presenter; + + video::ITexture* RenderTargetTexture; + video::IImage* RenderTargetSurface; + core::dimension2d RenderTargetSize; + + //! selects the right triangle renderer based on the render states. + void setCurrentShader(); + + IBurningShader* CurrentShader; + IBurningShader* BurningShader[ETR2_COUNT]; + + IDepthBuffer* DepthBuffer; + + video::ITexture* Texture[2]; + sInternalTexture Texmap[2]; + + /* + extend Matrix Stack + -> combined CameraProjection + -> combined CameraProjectionWorld + -> ClipScale from NDC to DC Space + */ + enum E_TRANSFORMATION_STATE_2 + { + ETS_VIEW_PROJECTION = ETS_COUNT, + ETS_WORLD_VIEW, + ETS_WORLD_VIEW_INVERSE_TRANSPOSED, + ETS_CURRENT, + ETS_CLIPSCALE, + + ETS2_COUNT + }; + + struct SMatrixStack + { + s32 isIdentity; + core::matrix4 m; + }; + + SMatrixStack Transformation[ETS2_COUNT]; + + // Vertex Cache + static const SVSize vSize[]; + + SVertexCache VertexCache; + + void VertexCache_reset (const void* vertices, u32 vertexCount, + const u16* indices, u32 indexCount, + E_VERTEX_TYPE vType,scene::E_PRIMITIVE_TYPE pType); + void VertexCache_get ( s4DVertex ** face ); + void VertexCache_get2 ( s4DVertex ** face ); + + void VertexCache_fill ( const u32 sourceIndex,const u32 destIndex ); + s4DVertex * VertexCache_getVertex ( const u32 sourceIndex ); + + + // culling & clipping + u32 clipToHyperPlane ( s4DVertex * dest, const s4DVertex * source, u32 inCount, const sVec4 &plane ); + u32 clipToFrustumTest ( const s4DVertex * v ) const; + u32 clipToFrustum ( s4DVertex *source, s4DVertex * temp, const u32 vIn ); + + +#ifdef SOFTWARE_DRIVER_2_LIGHTING + void lightVertex ( s4DVertex *dest, const S3DVertex *source ); +#endif + + + // holds transformed, clipped vertices + SAlignedVertex CurrentOut; + SAlignedVertex Temp; + + void ndc_2_dc_and_project ( s4DVertex *dest,s4DVertex *source, u32 vIn ) const; + f32 screenarea ( const s4DVertex *v0 ) const; + void select_polygon_mipmap ( s4DVertex *source, u32 vIn, s32 tex ); + f32 texelarea ( const s4DVertex *v0, int tex ) const; + + + void ndc_2_dc_and_project2 ( const s4DVertex **v, const u32 size ) const; + f32 screenarea2 ( const s4DVertex **v ) const; + f32 texelarea2 ( const s4DVertex **v, int tex ) const; + void select_polygon_mipmap2 ( s4DVertex **source, s32 tex ) const; + + + sVec4 Global_AmbientLight; + + struct SInternalLight + { + SLight org; + + sVec4 posEyeSpace; + + f32 constantAttenuation; + f32 linearAttenuation; + f32 quadraticAttenuation; + + sVec4 AmbientColor; + sVec4 DiffuseColor; + sVec4 SpecularColor; + }; + core::array Light; + + struct SInternalMaterial + { + SMaterial org; + + sVec4 AmbientColor; + sVec4 DiffuseColor; + sVec4 SpecularColor; + sVec4 EmissiveColor; + + u32 SpecularEnabled; // == Power2 + }; + + SInternalMaterial Material; + + static const sVec4 NDCPlane[6]; + + }; + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CSoftwareTexture.cpp b/src/dep/src/irrlicht/CSoftwareTexture.cpp index cac02d8..3cf5cd3 100644 --- a/src/dep/src/irrlicht/CSoftwareTexture.cpp +++ b/src/dep/src/irrlicht/CSoftwareTexture.cpp @@ -1,161 +1,161 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -#include "CSoftwareTexture.h" -#include "os.h" - -namespace irr -{ -namespace video -{ - -//! constructor -CSoftwareTexture::CSoftwareTexture(IImage* image, const char* name) -: ITexture(name), Texture(0) -{ - #ifdef _DEBUG - setDebugName("CSoftwareTexture"); - #endif - - if (image) - { - core::dimension2d optSize; - core::dimension2d origSize = image->getDimension(); - OrigSize = origSize; - - optSize.Width = getTextureSizeFromSurfaceSize(origSize.Width); - optSize.Height = getTextureSizeFromSurfaceSize(origSize.Height); - - Image = new CImage(ECF_A1R5G5B5, image); - - if (optSize == origSize) - { - Texture = Image; - Texture->grab(); - } - else - { - Texture = new CImage(ECF_A1R5G5B5, optSize); - Image->copyToScaling(Texture); - } - } -} - - - -//! destructor -CSoftwareTexture::~CSoftwareTexture() -{ - if (Image) - Image->drop(); - - if (Texture) - Texture->drop(); -} - - - -//! lock function -void* CSoftwareTexture::lock() -{ - return Image->lock(); -} - - - -//! unlock function -void CSoftwareTexture::unlock() -{ - if (Image != Texture) - { - os::Printer::log("Performance warning, slow unlock of non power of 2 texture.", ELL_WARNING); - Image->copyToScaling(Texture); - } - - Image->unlock(); -} - - -//! Returns original size of the texture. -const core::dimension2d& CSoftwareTexture::getOriginalSize() -{ - return OrigSize; -} - - -//! Returns (=size) of the texture. -const core::dimension2d& CSoftwareTexture::getSize() -{ - return Image->getDimension(); -} - - -//! returns unoptimized surface -CImage* CSoftwareTexture::getImage() -{ - return Image; -} - - - -//! returns texture surface -CImage* CSoftwareTexture::getTexture() -{ - return Texture; -} - - - -//! returns the size of a texture which would be the optimize size for rendering it -inline s32 CSoftwareTexture::getTextureSizeFromSurfaceSize(s32 size) -{ - s32 ts = 0x01; - while(ts < size) - ts <<= 1; - - return ts; -} - - - -//! returns driver type of texture (=the driver, who created the texture) -E_DRIVER_TYPE CSoftwareTexture::getDriverType() -{ - return EDT_SOFTWARE; -} - - - -//! returns color format of texture -ECOLOR_FORMAT CSoftwareTexture::getColorFormat() const -{ - return ECF_A1R5G5B5; -} - - - -//! returns pitch of texture (in bytes) -u32 CSoftwareTexture::getPitch() const -{ - return Image->getDimension().Width * 2; -} - - -//! Regenerates the mip map levels of the texture. Useful after locking and -//! modifying the texture -void CSoftwareTexture::regenerateMipMapLevels() -{ - // our software textures don't have mip maps -} - - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_SOFTWARE_ + +#include "CSoftwareTexture.h" +#include "os.h" + +namespace irr +{ +namespace video +{ + +//! constructor +CSoftwareTexture::CSoftwareTexture(IImage* image, const char* name) +: ITexture(name), Texture(0) +{ + #ifdef _DEBUG + setDebugName("CSoftwareTexture"); + #endif + + if (image) + { + core::dimension2d optSize; + core::dimension2d origSize = image->getDimension(); + OrigSize = origSize; + + optSize.Width = getTextureSizeFromSurfaceSize(origSize.Width); + optSize.Height = getTextureSizeFromSurfaceSize(origSize.Height); + + Image = new CImage(ECF_A1R5G5B5, image); + + if (optSize == origSize) + { + Texture = Image; + Texture->grab(); + } + else + { + Texture = new CImage(ECF_A1R5G5B5, optSize); + Image->copyToScaling(Texture); + } + } +} + + + +//! destructor +CSoftwareTexture::~CSoftwareTexture() +{ + if (Image) + Image->drop(); + + if (Texture) + Texture->drop(); +} + + + +//! lock function +void* CSoftwareTexture::lock() +{ + return Image->lock(); +} + + + +//! unlock function +void CSoftwareTexture::unlock() +{ + if (Image != Texture) + { + os::Printer::log("Performance warning, slow unlock of non power of 2 texture.", ELL_WARNING); + Image->copyToScaling(Texture); + } + + Image->unlock(); +} + + +//! Returns original size of the texture. +const core::dimension2d& CSoftwareTexture::getOriginalSize() +{ + return OrigSize; +} + + +//! Returns (=size) of the texture. +const core::dimension2d& CSoftwareTexture::getSize() +{ + return Image->getDimension(); +} + + +//! returns unoptimized surface +CImage* CSoftwareTexture::getImage() +{ + return Image; +} + + + +//! returns texture surface +CImage* CSoftwareTexture::getTexture() +{ + return Texture; +} + + + +//! returns the size of a texture which would be the optimize size for rendering it +inline s32 CSoftwareTexture::getTextureSizeFromSurfaceSize(s32 size) +{ + s32 ts = 0x01; + while(ts < size) + ts <<= 1; + + return ts; +} + + + +//! returns driver type of texture (=the driver, who created the texture) +E_DRIVER_TYPE CSoftwareTexture::getDriverType() +{ + return EDT_SOFTWARE; +} + + + +//! returns color format of texture +ECOLOR_FORMAT CSoftwareTexture::getColorFormat() const +{ + return ECF_A1R5G5B5; +} + + + +//! returns pitch of texture (in bytes) +u32 CSoftwareTexture::getPitch() const +{ + return Image->getDimension().Width * 2; +} + + +//! Regenerates the mip map levels of the texture. Useful after locking and +//! modifying the texture +void CSoftwareTexture::regenerateMipMapLevels() +{ + // our software textures don't have mip maps +} + + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SOFTWARE_ + diff --git a/src/dep/src/irrlicht/CSoftwareTexture.h b/src/dep/src/irrlicht/CSoftwareTexture.h index a792c32..68ade2d 100644 --- a/src/dep/src/irrlicht/CSoftwareTexture.h +++ b/src/dep/src/irrlicht/CSoftwareTexture.h @@ -1,76 +1,76 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SOFTWARE_TEXTURE_H_INCLUDED__ -#define __C_SOFTWARE_TEXTURE_H_INCLUDED__ - -#include "ITexture.h" -#include "CImage.h" - -namespace irr -{ -namespace video -{ - -/*! - interface for a Video Driver dependent Texture. -*/ -class CSoftwareTexture : public ITexture -{ -public: - - //! constructor - CSoftwareTexture(IImage* surface, const char* name); - - //! destructor - virtual ~CSoftwareTexture(); - - //! lock function - virtual void* lock(); - - //! unlock function - virtual void unlock(); - - //! Returns original size of the texture. - virtual const core::dimension2d& getOriginalSize(); - - //! Returns (=size) of the texture. - virtual const core::dimension2d& getSize(); - - //! returns unoptimized surface - virtual CImage* getImage(); - - //! returns texture surface - virtual CImage* getTexture(); - - //! returns driver type of texture (=the driver, who created the texture) - virtual E_DRIVER_TYPE getDriverType(); - - //! returns color format of texture - virtual ECOLOR_FORMAT getColorFormat() const; - - //! returns pitch of texture (in bytes) - virtual u32 getPitch() const; - - //! Regenerates the mip map levels of the texture. Useful after locking and - //! modifying the texture - virtual void regenerateMipMapLevels(); - -private: - - //! returns the size of a texture which would be the optimize size for rendering it - inline s32 getTextureSizeFromSurfaceSize(s32 size); - - CImage* Image; - CImage* Texture; - core::dimension2d OrigSize; - -}; - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_SOFTWARE_TEXTURE_H_INCLUDED__ +#define __C_SOFTWARE_TEXTURE_H_INCLUDED__ + +#include "ITexture.h" +#include "CImage.h" + +namespace irr +{ +namespace video +{ + +/*! + interface for a Video Driver dependent Texture. +*/ +class CSoftwareTexture : public ITexture +{ +public: + + //! constructor + CSoftwareTexture(IImage* surface, const char* name); + + //! destructor + virtual ~CSoftwareTexture(); + + //! lock function + virtual void* lock(); + + //! unlock function + virtual void unlock(); + + //! Returns original size of the texture. + virtual const core::dimension2d& getOriginalSize(); + + //! Returns (=size) of the texture. + virtual const core::dimension2d& getSize(); + + //! returns unoptimized surface + virtual CImage* getImage(); + + //! returns texture surface + virtual CImage* getTexture(); + + //! returns driver type of texture (=the driver, who created the texture) + virtual E_DRIVER_TYPE getDriverType(); + + //! returns color format of texture + virtual ECOLOR_FORMAT getColorFormat() const; + + //! returns pitch of texture (in bytes) + virtual u32 getPitch() const; + + //! Regenerates the mip map levels of the texture. Useful after locking and + //! modifying the texture + virtual void regenerateMipMapLevels(); + +private: + + //! returns the size of a texture which would be the optimize size for rendering it + inline s32 getTextureSizeFromSurfaceSize(s32 size); + + CImage* Image; + CImage* Texture; + core::dimension2d OrigSize; + +}; + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CSoftwareTexture2.cpp b/src/dep/src/irrlicht/CSoftwareTexture2.cpp index 03328b4..c335ccd 100644 --- a/src/dep/src/irrlicht/CSoftwareTexture2.cpp +++ b/src/dep/src/irrlicht/CSoftwareTexture2.cpp @@ -1,126 +1,126 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -#include "SoftwareDriver2_compile_config.h" -#include "SoftwareDriver2_helper.h" -#include "CSoftwareTexture2.h" -#include "os.h" - -namespace irr -{ -namespace video -{ - -//! constructor -CSoftwareTexture2::CSoftwareTexture2(IImage* image, const char* name, bool generateMipLevels) -: ITexture(name), MipMapLOD(0), HasMipMaps(generateMipLevels) -{ - #ifndef SOFTWARE_DRIVER_2_MIPMAPPING - HasMipMaps = 0; - #endif - - memset32 ( MipMap, 0, sizeof ( MipMap ) ); - - if (image) - { - - core::dimension2d optSize; - core::dimension2d origSize = image->getDimension(); - OrigSize = origSize; - - optSize.Width = getTextureSizeFromSurfaceSize(origSize.Width); - optSize.Height = getTextureSizeFromSurfaceSize(origSize.Height); - - if ( origSize == optSize ) - { - MipMap[0] = new CImage(ECF_SOFTWARE2, image); - } - else - { - MipMap[0] = new CImage(ECF_SOFTWARE2, optSize); - - // temporary CImage needed - CImage * temp = new CImage ( ECF_SOFTWARE2, image ); - temp->copyToScaling(MipMap[0]); - temp->drop (); - } - - - } - - regenerateMipMapLevels (); - setCurrentMipMapLOD ( 0 ); -} - - - -//! destructor -CSoftwareTexture2::~CSoftwareTexture2() -{ - for ( s32 i = 0; i!= SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) - { - if ( MipMap[i] ) - MipMap[i]->drop (); - } -} - - -//! returns the size of a texture which would be the optimize size for rendering it -inline s32 CSoftwareTexture2::getTextureSizeFromSurfaceSize(s32 size) -{ - s32 ts = 0x01; - while(ts < size) - ts <<= 1; - -/* - if (ts > size && ts > 256 ) - ts >>= 1; -*/ - return ts; -} - - - -//! Regenerates the mip map levels of the texture. Useful after locking and -//! modifying the texture -void CSoftwareTexture2::regenerateMipMapLevels() -{ - if ( 0 == HasMipMaps ) - return; - - s32 i; - - // release - for ( i = 1; i!= SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) - { - if ( MipMap[i] ) - MipMap[i]->drop (); - } - - core::dimension2d newSize; - core::dimension2d currentSize; - - i = 1; - CImage * c = MipMap[0]; - while ( i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX ) - { - currentSize = c->getDimension(); - newSize.Width = core::s32_max ( 1, currentSize.Width >> 1 ); - newSize.Height = core::s32_max ( 1, currentSize.Height >> 1 ); - - MipMap[i] = new CImage(ECF_SOFTWARE2, newSize); - MipMap[0]->copyToScalingBoxFilter ( MipMap[i], 0 ); - c = MipMap[i]; - i += 1; - } -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +#include "SoftwareDriver2_compile_config.h" +#include "SoftwareDriver2_helper.h" +#include "CSoftwareTexture2.h" +#include "os.h" + +namespace irr +{ +namespace video +{ + +//! constructor +CSoftwareTexture2::CSoftwareTexture2(IImage* image, const char* name, bool generateMipLevels) +: ITexture(name), MipMapLOD(0), HasMipMaps(generateMipLevels) +{ + #ifndef SOFTWARE_DRIVER_2_MIPMAPPING + HasMipMaps = 0; + #endif + + memset32 ( MipMap, 0, sizeof ( MipMap ) ); + + if (image) + { + + core::dimension2d optSize; + core::dimension2d origSize = image->getDimension(); + OrigSize = origSize; + + optSize.Width = getTextureSizeFromSurfaceSize(origSize.Width); + optSize.Height = getTextureSizeFromSurfaceSize(origSize.Height); + + if ( origSize == optSize ) + { + MipMap[0] = new CImage(ECF_SOFTWARE2, image); + } + else + { + MipMap[0] = new CImage(ECF_SOFTWARE2, optSize); + + // temporary CImage needed + CImage * temp = new CImage ( ECF_SOFTWARE2, image ); + temp->copyToScaling(MipMap[0]); + temp->drop (); + } + + + } + + regenerateMipMapLevels (); + setCurrentMipMapLOD ( 0 ); +} + + + +//! destructor +CSoftwareTexture2::~CSoftwareTexture2() +{ + for ( s32 i = 0; i!= SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) + { + if ( MipMap[i] ) + MipMap[i]->drop (); + } +} + + +//! returns the size of a texture which would be the optimize size for rendering it +inline s32 CSoftwareTexture2::getTextureSizeFromSurfaceSize(s32 size) +{ + s32 ts = 0x01; + while(ts < size) + ts <<= 1; + +/* + if (ts > size && ts > 256 ) + ts >>= 1; +*/ + return ts; +} + + + +//! Regenerates the mip map levels of the texture. Useful after locking and +//! modifying the texture +void CSoftwareTexture2::regenerateMipMapLevels() +{ + if ( 0 == HasMipMaps ) + return; + + s32 i; + + // release + for ( i = 1; i!= SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) + { + if ( MipMap[i] ) + MipMap[i]->drop (); + } + + core::dimension2d newSize; + core::dimension2d currentSize; + + i = 1; + CImage * c = MipMap[0]; + while ( i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX ) + { + currentSize = c->getDimension(); + newSize.Width = core::s32_max ( 1, currentSize.Width >> 1 ); + newSize.Height = core::s32_max ( 1, currentSize.Height >> 1 ); + + MipMap[i] = new CImage(ECF_SOFTWARE2, newSize); + MipMap[0]->copyToScalingBoxFilter ( MipMap[i], 0 ); + c = MipMap[i]; + i += 1; + } +} + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ diff --git a/src/dep/src/irrlicht/CSoftwareTexture2.h b/src/dep/src/irrlicht/CSoftwareTexture2.h index 862559f..7034e60 100644 --- a/src/dep/src/irrlicht/CSoftwareTexture2.h +++ b/src/dep/src/irrlicht/CSoftwareTexture2.h @@ -1,123 +1,123 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SOFTWARE_2_TEXTURE_H_INCLUDED__ -#define __C_SOFTWARE_2_TEXTURE_H_INCLUDED__ - -#include "SoftwareDriver2_compile_config.h" - -#include "ITexture.h" -#include "CImage.h" - -namespace irr -{ -namespace video -{ - -/*! - interface for a Video Driver dependent Texture. -*/ -class CSoftwareTexture2 : public ITexture -{ -public: - - //! constructor - CSoftwareTexture2(IImage* surface, const char* name,bool generateMipLevels); - - //! destructor - virtual ~CSoftwareTexture2(); - - //! lock function - virtual void* lock() - { - return MipMap[MipMapLOD]->lock(); - } - - //! unlock function - virtual void unlock() - { - MipMap[MipMapLOD]->unlock(); - } - - //! Returns original size of the texture. - virtual const core::dimension2d& getOriginalSize() - { - return MipMap[0]->getDimension(); - //return OrigSize; - } - - //! Returns (=size) of the texture. - virtual const core::dimension2d& getSize() - { - return MipMap[MipMapLOD]->getDimension(); - } - - //! returns unoptimized surface - virtual CImage* getImage() const - { - return MipMap[0]; - } - - //! returns texture surface - virtual CImage* getTexture() const - { - return MipMap[MipMapLOD]; - } - - - //! returns driver type of texture (=the driver, who created the texture) - virtual E_DRIVER_TYPE getDriverType() - { - return EDT_BURNINGSVIDEO; - } - - //! returns color format of texture - virtual ECOLOR_FORMAT getColorFormat() const - { - return ECF_SOFTWARE2; - } - - //! returns pitch of texture (in bytes) - virtual u32 getPitch() const - { - return MipMap[MipMapLOD]->getPitch(); - } - - //! Regenerates the mip map levels of the texture. Useful after locking and - //! modifying the texture - virtual void regenerateMipMapLevels(); - - //! Select a Mipmap Level - virtual void setCurrentMipMapLOD ( s32 lod ) - { - if ( HasMipMaps ) - MipMapLOD = lod; - } - - //! support mipmaps - virtual s32 hasMipMaps() const - { - return HasMipMaps; - } - -private: - - //! returns the size of a texture which would be the optimize size for rendering it - inline s32 getTextureSizeFromSurfaceSize(s32 size); - - core::dimension2d OrigSize; - - CImage * MipMap[SOFTWARE_DRIVER_2_MIPMAPPING_MAX]; - - s32 MipMapLOD; - s32 HasMipMaps; - -}; - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_SOFTWARE_2_TEXTURE_H_INCLUDED__ +#define __C_SOFTWARE_2_TEXTURE_H_INCLUDED__ + +#include "SoftwareDriver2_compile_config.h" + +#include "ITexture.h" +#include "CImage.h" + +namespace irr +{ +namespace video +{ + +/*! + interface for a Video Driver dependent Texture. +*/ +class CSoftwareTexture2 : public ITexture +{ +public: + + //! constructor + CSoftwareTexture2(IImage* surface, const char* name,bool generateMipLevels); + + //! destructor + virtual ~CSoftwareTexture2(); + + //! lock function + virtual void* lock() + { + return MipMap[MipMapLOD]->lock(); + } + + //! unlock function + virtual void unlock() + { + MipMap[MipMapLOD]->unlock(); + } + + //! Returns original size of the texture. + virtual const core::dimension2d& getOriginalSize() + { + return MipMap[0]->getDimension(); + //return OrigSize; + } + + //! Returns (=size) of the texture. + virtual const core::dimension2d& getSize() + { + return MipMap[MipMapLOD]->getDimension(); + } + + //! returns unoptimized surface + virtual CImage* getImage() const + { + return MipMap[0]; + } + + //! returns texture surface + virtual CImage* getTexture() const + { + return MipMap[MipMapLOD]; + } + + + //! returns driver type of texture (=the driver, who created the texture) + virtual E_DRIVER_TYPE getDriverType() + { + return EDT_BURNINGSVIDEO; + } + + //! returns color format of texture + virtual ECOLOR_FORMAT getColorFormat() const + { + return ECF_SOFTWARE2; + } + + //! returns pitch of texture (in bytes) + virtual u32 getPitch() const + { + return MipMap[MipMapLOD]->getPitch(); + } + + //! Regenerates the mip map levels of the texture. Useful after locking and + //! modifying the texture + virtual void regenerateMipMapLevels(); + + //! Select a Mipmap Level + virtual void setCurrentMipMapLOD ( s32 lod ) + { + if ( HasMipMaps ) + MipMapLOD = lod; + } + + //! support mipmaps + virtual s32 hasMipMaps() const + { + return HasMipMaps; + } + +private: + + //! returns the size of a texture which would be the optimize size for rendering it + inline s32 getTextureSizeFromSurfaceSize(s32 size); + + core::dimension2d OrigSize; + + CImage * MipMap[SOFTWARE_DRIVER_2_MIPMAPPING_MAX]; + + s32 MipMapLOD; + s32 HasMipMaps; + +}; + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CSphereSceneNode.cpp b/src/dep/src/irrlicht/CSphereSceneNode.cpp index 64f98fa..f831d40 100644 --- a/src/dep/src/irrlicht/CSphereSceneNode.cpp +++ b/src/dep/src/irrlicht/CSphereSceneNode.cpp @@ -1,273 +1,273 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSphereSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "S3DVertex.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CSphereSceneNode::CSphereSceneNode(f32 Radius, s32 polyCount, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) -: ISceneNode(parent, mgr, id, position, rotation, scale), Radius(Radius), - PolyCount(polyCount) -{ - #ifdef _DEBUG - setDebugName("CSphereSceneNode"); - #endif - - setSizeAndPolys(); -} - - - -//! destructor -CSphereSceneNode::~CSphereSceneNode() -{ -} - - -void CSphereSceneNode::setSizeAndPolys() -{ - // thanks to Alfaz93 who made his code available for Irrlicht on which - // this one is based! - - // we are creating the sphere mesh here. - - if (PolyCount < 2) - PolyCount = 2; - else - if (PolyCount > 181) // prevent u16 overflow - PolyCount = 181; - - Buffer.Vertices.set_used((PolyCount * PolyCount) + 2); - Buffer.Indices.set_used((PolyCount * PolyCount) * 6); - - video::SColor clr(100, 255,255,255); - - int i=0; - int level = 0; - - for (int p1=0; p1getVideoDriver(); - - if (Buffer.Vertices.size() && Buffer.Indices.size()) - { - driver->setMaterial(Buffer.Material); - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - driver->drawMeshBuffer(&Buffer); - if (DebugDataVisible) - { - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - driver->draw3DBox(Buffer.BoundingBox, video::SColor(255,255,255,255)); - } - } -} - - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CSphereSceneNode::getBoundingBox() const -{ - return Buffer.BoundingBox; -} - - -void CSphereSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - SceneManager->registerNodeForRendering(this); - - ISceneNode::OnRegisterSceneNode(); -} - - -//! returns the material based on the zero based index i. To get the amount -//! of materials used by this scene node, use getMaterialCount(). -//! This function is needed for inserting the node into the scene hirachy on a -//! optimal position for minimizing renderstate changes, but can also be used -//! to directly modify the material of a scene node. -video::SMaterial& CSphereSceneNode::getMaterial(u32 i) -{ - return Buffer.Material; -} - - -//! returns amount of materials used by this scene node. -u32 CSphereSceneNode::getMaterialCount() -{ - return 1; -} - - -//! Writes attributes of the scene node. -void CSphereSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - ISceneNode::serializeAttributes(out, options); - - out->addFloat("Radius", Radius); - out->addInt("PolyCount", PolyCount); -} - - -//! Reads attributes of the scene node. -void CSphereSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - f32 oldRadius = Radius; - s32 oldPolyCount = PolyCount; - - Radius = in->getAttributeAsFloat("Radius"); - PolyCount = in->getAttributeAsInt("PolyCount"); - - Radius = irr::core::max_(Radius, 0.0001f); - - if ( !core::equals(Radius, oldRadius) || PolyCount != oldPolyCount) - setSizeAndPolys(); - - ISceneNode::deserializeAttributes(in, options); -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSphereSceneNode.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" +#include "S3DVertex.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CSphereSceneNode::CSphereSceneNode(f32 Radius, s32 polyCount, ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) +: ISceneNode(parent, mgr, id, position, rotation, scale), Radius(Radius), + PolyCount(polyCount) +{ + #ifdef _DEBUG + setDebugName("CSphereSceneNode"); + #endif + + setSizeAndPolys(); +} + + + +//! destructor +CSphereSceneNode::~CSphereSceneNode() +{ +} + + +void CSphereSceneNode::setSizeAndPolys() +{ + // thanks to Alfaz93 who made his code available for Irrlicht on which + // this one is based! + + // we are creating the sphere mesh here. + + if (PolyCount < 2) + PolyCount = 2; + else + if (PolyCount > 181) // prevent u16 overflow + PolyCount = 181; + + Buffer.Vertices.set_used((PolyCount * PolyCount) + 2); + Buffer.Indices.set_used((PolyCount * PolyCount) * 6); + + video::SColor clr(100, 255,255,255); + + int i=0; + int level = 0; + + for (int p1=0; p1getVideoDriver(); + + if (Buffer.Vertices.size() && Buffer.Indices.size()) + { + driver->setMaterial(Buffer.Material); + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + driver->drawMeshBuffer(&Buffer); + if (DebugDataVisible) + { + video::SMaterial m; + m.Lighting = false; + driver->setMaterial(m); + driver->draw3DBox(Buffer.BoundingBox, video::SColor(255,255,255,255)); + } + } +} + + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CSphereSceneNode::getBoundingBox() const +{ + return Buffer.BoundingBox; +} + + +void CSphereSceneNode::OnRegisterSceneNode() +{ + if (IsVisible) + SceneManager->registerNodeForRendering(this); + + ISceneNode::OnRegisterSceneNode(); +} + + +//! returns the material based on the zero based index i. To get the amount +//! of materials used by this scene node, use getMaterialCount(). +//! This function is needed for inserting the node into the scene hirachy on a +//! optimal position for minimizing renderstate changes, but can also be used +//! to directly modify the material of a scene node. +video::SMaterial& CSphereSceneNode::getMaterial(u32 i) +{ + return Buffer.Material; +} + + +//! returns amount of materials used by this scene node. +u32 CSphereSceneNode::getMaterialCount() +{ + return 1; +} + + +//! Writes attributes of the scene node. +void CSphereSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + ISceneNode::serializeAttributes(out, options); + + out->addFloat("Radius", Radius); + out->addInt("PolyCount", PolyCount); +} + + +//! Reads attributes of the scene node. +void CSphereSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + f32 oldRadius = Radius; + s32 oldPolyCount = PolyCount; + + Radius = in->getAttributeAsFloat("Radius"); + PolyCount = in->getAttributeAsInt("PolyCount"); + + Radius = irr::core::max_(Radius, 0.0001f); + + if ( !core::equals(Radius, oldRadius) || PolyCount != oldPolyCount) + setSizeAndPolys(); + + ISceneNode::deserializeAttributes(in, options); +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CSphereSceneNode.h b/src/dep/src/irrlicht/CSphereSceneNode.h index b17e830..3d32161 100644 --- a/src/dep/src/irrlicht/CSphereSceneNode.h +++ b/src/dep/src/irrlicht/CSphereSceneNode.h @@ -1,68 +1,68 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SHPERE_SCENE_NODE_H_INCLUDED__ -#define __C_SHPERE_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "SMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - class CSphereSceneNode : public ISceneNode - { - public: - - //! constructor - CSphereSceneNode(f32 size, s32 polyCount, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! destructor - virtual ~CSphereSceneNode(); - - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! returns the material based on the zero based index i. To get the amount - //! of materials used by this scene node, use getMaterialCount(). - //! This function is needed for inserting the node into the scene hirachy on a - //! optimal position for minimizing renderstate changes, but can also be used - //! to directly modify the material of a scene node. - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount(); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_SPHERE; } - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - private: - - void setSizeAndPolys(); - - SMeshBuffer Buffer; - f32 Radius; - s32 PolyCount; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_SHPERE_SCENE_NODE_H_INCLUDED__ +#define __C_SHPERE_SCENE_NODE_H_INCLUDED__ + +#include "ISceneNode.h" +#include "SMeshBuffer.h" + +namespace irr +{ +namespace scene +{ + class CSphereSceneNode : public ISceneNode + { + public: + + //! constructor + CSphereSceneNode(f32 size, s32 polyCount, ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); + + //! destructor + virtual ~CSphereSceneNode(); + + virtual void OnRegisterSceneNode(); + + //! renders the node. + virtual void render(); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! returns the material based on the zero based index i. To get the amount + //! of materials used by this scene node, use getMaterialCount(). + //! This function is needed for inserting the node into the scene hirachy on a + //! optimal position for minimizing renderstate changes, but can also be used + //! to directly modify the material of a scene node. + virtual video::SMaterial& getMaterial(u32 i); + + //! returns amount of materials used by this scene node. + virtual u32 getMaterialCount(); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_SPHERE; } + + //! Writes attributes of the scene node. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + + //! Reads attributes of the scene node. + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + private: + + void setSizeAndPolys(); + + SMeshBuffer Buffer; + f32 Radius; + s32 PolyCount; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CTRFlat.cpp b/src/dep/src/irrlicht/CTRFlat.cpp index c1113f7..34d4199 100644 --- a/src/dep/src/irrlicht/CTRFlat.cpp +++ b/src/dep/src/irrlicht/CTRFlat.cpp @@ -1,301 +1,301 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRFlat : public CTRTextureGouraud -{ -public: - - CTRFlat(IZBuffer* zbuffer) - : CTRTextureGouraud(zbuffer) - { - #ifdef _DEBUG - setDebugName("CTRFlat"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - u16 color; - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels - core::rect TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - s32 spanZValue, spanZStep; // ZValues when drawing a span - TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - - for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - - // höhe des dreiecks berechnen - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - color = v1->Color; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - - // TODO: clipping is not correct when leftx is clipped. - - if (leftxViewPortRect.LowerRightCorner.X) - leftx = ViewPortRect.LowerRightCorner.X; - - if (rightxViewPortRect.LowerRightCorner.X) - rightx = ViewPortRect.LowerRightCorner.X; - - // draw the span - - if (rightx - leftx != 0) - { - tmpDiv = 1.0f / (rightx - leftx); - spanZValue = leftZValue; - spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); - - hSpanBegin = targetSurface + leftx; - spanZTarget = zTarget + leftx; - hSpanEnd = targetSurface + rightx; - - while (hSpanBegin < hSpanEnd) - { - if (spanZValue > *spanZTarget) - { - *spanZTarget = spanZValue; - *hSpanBegin = color; - } - - spanZValue += spanZStep; - ++hSpanBegin; - ++spanZTarget; - } - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - } -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererFlat(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRFlat(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "CTRTextureGouraud.h" + +#ifdef _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +class CTRFlat : public CTRTextureGouraud +{ +public: + + CTRFlat(IZBuffer* zbuffer) + : CTRTextureGouraud(zbuffer) + { + #ifdef _DEBUG + setDebugName("CTRFlat"); + #endif + } + + //! draws an indexed triangle list + virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) + { + const S2DVertex *v1, *v2, *v3; + + u16 color; + f32 tmpDiv; // temporary division factor + f32 longest; // saves the longest span + s32 height; // saves height of triangle + u16* targetSurface; // target pointer where to plot pixels + s32 spanEnd; // saves end of spans + f32 leftdeltaxf; // amount of pixels to increase on left side of triangle + f32 rightdeltaxf; // amount of pixels to increase on right side of triangle + s32 leftx, rightx; // position where we are + f32 leftxf, rightxf; // same as above, but as f32 values + s32 span; // current span + u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels + core::rect TriangleRect; + + s32 leftZValue, rightZValue; + s32 leftZStep, rightZStep; + s32 spanZValue, spanZStep; // ZValues when drawing a span + TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; + + lockedSurface = (u16*)RenderTarget->lock(); + lockedZBuffer = ZBuffer->lock(); + + for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - + ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); + + if (z < 0) + continue; + } + + //near plane clipping + + if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) + continue; + + // sort for width for inscreen clipping + + if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); + if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); + if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); + + if ((v1->Pos.X - v3->Pos.X) == 0) + continue; + + TriangleRect.UpperLeftCorner.X = v1->Pos.X; + TriangleRect.LowerRightCorner.X = v3->Pos.X; + + // sort for height for faster drawing. + + if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); + if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); + if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); + + TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; + TriangleRect.LowerRightCorner.Y = v3->Pos.Y; + + if (!TriangleRect.isRectCollided(ViewPortRect)) + continue; + + + // höhe des dreiecks berechnen + height = v3->Pos.Y - v1->Pos.Y; + if (!height) + continue; + + // calculate longest span + + longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); + + spanEnd = v2->Pos.Y; + span = v1->Pos.Y; + leftxf = (f32)v1->Pos.X; + rightxf = (f32)v1->Pos.X; + + leftZValue = v1->ZValue; + rightZValue = v1->ZValue; + + color = v1->Color; + + targetSurface = lockedSurface + span * SurfaceWidth; + zTarget = lockedZBuffer + span * SurfaceWidth; + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + + tmpDiv = 1.0f / (f32)height; + leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (f32)height; + rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + } + + + // do it twice, once for the first half of the triangle, + // end then for the second half. + + for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) + { + if (spanEnd > ViewPortRect.LowerRightCorner.Y) + spanEnd = ViewPortRect.LowerRightCorner.Y; + + // if the span <0, than we can skip these spans, + // and proceed to the next spans which are really on the screen. + if (span < ViewPortRect.UpperLeftCorner.Y) + { + // we'll use leftx as temp variable + if (spanEnd < ViewPortRect.UpperLeftCorner.Y) + { + leftx = spanEnd - span; + span = spanEnd; + } + else + { + leftx = ViewPortRect.UpperLeftCorner.Y - span; + span = ViewPortRect.UpperLeftCorner.Y; + } + + leftxf += leftdeltaxf*leftx; + rightxf += rightdeltaxf*leftx; + targetSurface += SurfaceWidth*leftx; + zTarget += SurfaceWidth*leftx; + leftZValue += leftZStep*leftx; + rightZValue += rightZStep*leftx; + } + + + // the main loop. Go through every span and draw it. + + while (span < spanEnd) + { + leftx = (s32)(leftxf); + rightx = (s32)(rightxf + 0.5f); + + // perform some clipping + + // TODO: clipping is not correct when leftx is clipped. + + if (leftxViewPortRect.LowerRightCorner.X) + leftx = ViewPortRect.LowerRightCorner.X; + + if (rightxViewPortRect.LowerRightCorner.X) + rightx = ViewPortRect.LowerRightCorner.X; + + // draw the span + + if (rightx - leftx != 0) + { + tmpDiv = 1.0f / (rightx - leftx); + spanZValue = leftZValue; + spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); + + hSpanBegin = targetSurface + leftx; + spanZTarget = zTarget + leftx; + hSpanEnd = targetSurface + rightx; + + while (hSpanBegin < hSpanEnd) + { + if (spanZValue > *spanZTarget) + { + *spanZTarget = spanZValue; + *hSpanBegin = color; + } + + spanZValue += spanZStep; + ++hSpanBegin; + ++spanZTarget; + } + } + + leftxf += leftdeltaxf; + rightxf += rightdeltaxf; + ++span; + targetSurface += SurfaceWidth; + zTarget += SurfaceWidth; + leftZValue += leftZStep; + rightZValue += rightZStep; + } + + if (triangleHalf>0) // break, we've gout only two halves + break; + + + // setup variables for second half of the triangle. + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + rightxf = (f32)v2->Pos.X; + + rightZValue = v2->ZValue; + rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + leftxf = (f32)v2->Pos.X; + + leftZValue = v2->ZValue; + leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + } + + + spanEnd = v3->Pos.Y; + } + + } + + RenderTarget->unlock(); + ZBuffer->unlock(); + } +}; + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +ITriangleRenderer* createTriangleRendererFlat(IZBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + return new CTRFlat(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_SOFTWARE_ +} + +} // end namespace video +} // end namespace irr + + + diff --git a/src/dep/src/irrlicht/CTRFlatWire.cpp b/src/dep/src/irrlicht/CTRFlatWire.cpp index 9cf2cb1..f3fda1f 100644 --- a/src/dep/src/irrlicht/CTRFlatWire.cpp +++ b/src/dep/src/irrlicht/CTRFlatWire.cpp @@ -1,282 +1,282 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRFlatWire : public CTRTextureGouraud -{ -public: - - CTRFlatWire(IZBuffer* zbuffer) - : CTRTextureGouraud(zbuffer) - { - #ifdef _DEBUG - setDebugName("CTRWire"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - u16 color; - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - core::rect TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - TZBufferType* zTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - - for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - - // höhe des dreiecks berechnen - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - color = v1->Color; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - - if (leftx>=ViewPortRect.UpperLeftCorner.X && - leftx<=ViewPortRect.LowerRightCorner.X) - { - if (leftZValue > *(zTarget + leftx)) - { - *(zTarget + leftx) = leftZValue; - *(targetSurface + leftx) = color; - } - } - - - if (rightx>=ViewPortRect.UpperLeftCorner.X && - rightx<=ViewPortRect.LowerRightCorner.X) - { - if (rightZValue > *(zTarget + rightx)) - { - *(zTarget + rightx) = rightZValue; - *(targetSurface + rightx) = color; - } - - } - - // draw the span - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - } -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererFlatWire(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRFlatWire(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "CTRTextureGouraud.h" + +#ifdef _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +class CTRFlatWire : public CTRTextureGouraud +{ +public: + + CTRFlatWire(IZBuffer* zbuffer) + : CTRTextureGouraud(zbuffer) + { + #ifdef _DEBUG + setDebugName("CTRWire"); + #endif + } + + //! draws an indexed triangle list + virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) + { + const S2DVertex *v1, *v2, *v3; + + u16 color; + f32 tmpDiv; // temporary division factor + f32 longest; // saves the longest span + s32 height; // saves height of triangle + u16* targetSurface; // target pointer where to plot pixels + s32 spanEnd; // saves end of spans + f32 leftdeltaxf; // amount of pixels to increase on left side of triangle + f32 rightdeltaxf; // amount of pixels to increase on right side of triangle + s32 leftx, rightx; // position where we are + f32 leftxf, rightxf; // same as above, but as f32 values + s32 span; // current span + core::rect TriangleRect; + + s32 leftZValue, rightZValue; + s32 leftZStep, rightZStep; + TZBufferType* zTarget; // target of ZBuffer; + + lockedSurface = (u16*)RenderTarget->lock(); + lockedZBuffer = ZBuffer->lock(); + + for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - + ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); + + if (z < 0) + continue; + } + + //near plane clipping + + if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) + continue; + + // sort for width for inscreen clipping + + if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); + if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); + if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); + + if ((v1->Pos.X - v3->Pos.X) == 0) + continue; + + TriangleRect.UpperLeftCorner.X = v1->Pos.X; + TriangleRect.LowerRightCorner.X = v3->Pos.X; + + // sort for height for faster drawing. + + if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); + if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); + if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); + + TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; + TriangleRect.LowerRightCorner.Y = v3->Pos.Y; + + if (!TriangleRect.isRectCollided(ViewPortRect)) + continue; + + + // höhe des dreiecks berechnen + height = v3->Pos.Y - v1->Pos.Y; + if (!height) + continue; + + // calculate longest span + + longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); + + spanEnd = v2->Pos.Y; + span = v1->Pos.Y; + leftxf = (f32)v1->Pos.X; + rightxf = (f32)v1->Pos.X; + + leftZValue = v1->ZValue; + rightZValue = v1->ZValue; + + color = v1->Color; + + targetSurface = lockedSurface + span * SurfaceWidth; + zTarget = lockedZBuffer + span * SurfaceWidth; + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + + tmpDiv = 1.0f / (f32)height; + leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (f32)height; + rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + } + + + // do it twice, once for the first half of the triangle, + // end then for the second half. + + for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) + { + if (spanEnd > ViewPortRect.LowerRightCorner.Y) + spanEnd = ViewPortRect.LowerRightCorner.Y; + + // if the span <0, than we can skip these spans, + // and proceed to the next spans which are really on the screen. + if (span < ViewPortRect.UpperLeftCorner.Y) + { + // we'll use leftx as temp variable + if (spanEnd < ViewPortRect.UpperLeftCorner.Y) + { + leftx = spanEnd - span; + span = spanEnd; + } + else + { + leftx = ViewPortRect.UpperLeftCorner.Y - span; + span = ViewPortRect.UpperLeftCorner.Y; + } + + leftxf += leftdeltaxf*leftx; + rightxf += rightdeltaxf*leftx; + targetSurface += SurfaceWidth*leftx; + zTarget += SurfaceWidth*leftx; + leftZValue += leftZStep*leftx; + rightZValue += rightZStep*leftx; + } + + + // the main loop. Go through every span and draw it. + + while (span < spanEnd) + { + leftx = (s32)(leftxf); + rightx = (s32)(rightxf + 0.5f); + + // perform some clipping + + if (leftx>=ViewPortRect.UpperLeftCorner.X && + leftx<=ViewPortRect.LowerRightCorner.X) + { + if (leftZValue > *(zTarget + leftx)) + { + *(zTarget + leftx) = leftZValue; + *(targetSurface + leftx) = color; + } + } + + + if (rightx>=ViewPortRect.UpperLeftCorner.X && + rightx<=ViewPortRect.LowerRightCorner.X) + { + if (rightZValue > *(zTarget + rightx)) + { + *(zTarget + rightx) = rightZValue; + *(targetSurface + rightx) = color; + } + + } + + // draw the span + + leftxf += leftdeltaxf; + rightxf += rightdeltaxf; + ++span; + targetSurface += SurfaceWidth; + zTarget += SurfaceWidth; + leftZValue += leftZStep; + rightZValue += rightZStep; + } + + if (triangleHalf>0) // break, we've gout only two halves + break; + + + // setup variables for second half of the triangle. + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + rightxf = (f32)v2->Pos.X; + + rightZValue = v2->ZValue; + rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + leftxf = (f32)v2->Pos.X; + + leftZValue = v2->ZValue; + leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + } + + + spanEnd = v3->Pos.Y; + } + + } + + RenderTarget->unlock(); + ZBuffer->unlock(); + } +}; + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +ITriangleRenderer* createTriangleRendererFlatWire(IZBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + return new CTRFlatWire(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_SOFTWARE_ +} + +} // end namespace video +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CTRGouraud.cpp b/src/dep/src/irrlicht/CTRGouraud.cpp index 90514aa..5a2b0c2 100644 --- a/src/dep/src/irrlicht/CTRGouraud.cpp +++ b/src/dep/src/irrlicht/CTRGouraud.cpp @@ -1,359 +1,359 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - - -class CTRGouraud : public CTRTextureGouraud -{ -public: - - CTRGouraud(IZBuffer* zbuffer) - : CTRTextureGouraud(zbuffer) - { - #ifdef _DEBUG - setDebugName("CTRGouraud"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels - s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values - s32 leftStepR, leftStepG, leftStepB, - rightStepR, rightStepG, rightStepB; // color steps - s32 spanR, spanG, spanB, spanStepR, spanStepG, spanStepB; // color interpolating values while drawing a span. - - core::rect TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - s32 spanZValue, spanZStep; // ZValues when drawing a span - TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - - for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - - // höhe des dreiecks berechnen - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - leftR = rightR = video::getRedSigned(v1->Color)<<3; - leftG = rightG = video::getGreenSigned(v1->Color)<<3; - leftB = rightB = video::getBlueSigned(v1->Color)<<3; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((video::getRedSigned(v2->Color)<<3) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreenSigned(v2->Color)<<3) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlueSigned(v2->Color)<<3) - rightB) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((video::getRedSigned(v3->Color)<<3) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreenSigned(v3->Color)<<3) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlueSigned(v3->Color)<<3) - leftB) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((video::getRedSigned(v3->Color)<<3) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreenSigned(v3->Color)<<3) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlueSigned(v3->Color)<<3) - rightB) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((video::getRedSigned(v2->Color)<<3) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreenSigned(v2->Color)<<3) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlueSigned(v2->Color)<<3) - leftB) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - - leftR += leftStepR*leftx; - leftG += leftStepG*leftx; - leftB += leftStepB*leftx; - rightR += rightStepR*leftx; - rightG += rightStepG*leftx; - rightB += rightStepB*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - - // TODO: clipping is not correct when leftx is clipped. - - if (leftxViewPortRect.LowerRightCorner.X) - leftx = ViewPortRect.LowerRightCorner.X; - - if (rightxViewPortRect.LowerRightCorner.X) - rightx = ViewPortRect.LowerRightCorner.X; - - // draw the span - - if (rightx - leftx != 0) - { - tmpDiv = 1.0f / (rightx - leftx); - spanZValue = leftZValue; - spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); - - hSpanBegin = targetSurface + leftx; - spanZTarget = zTarget + leftx; - hSpanEnd = targetSurface + rightx; - - spanR = leftR; - spanG = leftG; - spanB = leftB; - spanStepR = (s32)((rightR - leftR) * tmpDiv); - spanStepG = (s32)((rightG - leftG) * tmpDiv); - spanStepB = (s32)((rightB - leftB) * tmpDiv); - - while (hSpanBegin < hSpanEnd) - { - if (spanZValue > *spanZTarget) - { - *spanZTarget = spanZValue; - *hSpanBegin = video::RGB16(spanR, spanG, spanB); - } - - spanR += spanStepR; - spanG += spanStepG; - spanB += spanStepB; - - spanZValue += spanZStep; - ++hSpanBegin; - ++spanZTarget; - } - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - - leftR += leftStepR; - leftG += leftStepG; - leftB += leftStepB; - rightR += rightStepR; - rightG += rightStepG; - rightB += rightStepB; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - rightR = video::getRedSigned(v2->Color)<<3; - rightG = video::getGreenSigned(v2->Color)<<3; - rightB = video::getBlueSigned(v2->Color)<<3; - rightStepR = (s32)(((video::getRedSigned(v3->Color)<<3) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreenSigned(v3->Color)<<3) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlueSigned(v3->Color)<<3) - rightB) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - leftR = video::getRedSigned(v2->Color)<<3; - leftG = video::getGreenSigned(v2->Color)<<3; - leftB = video::getBlueSigned(v2->Color)<<3; - leftStepR = (s32)(((video::getRedSigned(v3->Color)<<3) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreenSigned(v3->Color)<<3) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlueSigned(v3->Color)<<3) - leftB) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - } - -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererGouraud(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRGouraud(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "CTRTextureGouraud.h" + +#ifdef _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + + +class CTRGouraud : public CTRTextureGouraud +{ +public: + + CTRGouraud(IZBuffer* zbuffer) + : CTRTextureGouraud(zbuffer) + { + #ifdef _DEBUG + setDebugName("CTRGouraud"); + #endif + } + + //! draws an indexed triangle list + virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) + { + const S2DVertex *v1, *v2, *v3; + + f32 tmpDiv; // temporary division factor + f32 longest; // saves the longest span + s32 height; // saves height of triangle + u16* targetSurface; // target pointer where to plot pixels + s32 spanEnd; // saves end of spans + f32 leftdeltaxf; // amount of pixels to increase on left side of triangle + f32 rightdeltaxf; // amount of pixels to increase on right side of triangle + s32 leftx, rightx; // position where we are + f32 leftxf, rightxf; // same as above, but as f32 values + s32 span; // current span + u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels + s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values + s32 leftStepR, leftStepG, leftStepB, + rightStepR, rightStepG, rightStepB; // color steps + s32 spanR, spanG, spanB, spanStepR, spanStepG, spanStepB; // color interpolating values while drawing a span. + + core::rect TriangleRect; + + s32 leftZValue, rightZValue; + s32 leftZStep, rightZStep; + s32 spanZValue, spanZStep; // ZValues when drawing a span + TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; + + lockedSurface = (u16*)RenderTarget->lock(); + lockedZBuffer = ZBuffer->lock(); + + for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - + ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); + + if (z < 0) + continue; + } + + //near plane clipping + + if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) + continue; + + // sort for width for inscreen clipping + + if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); + if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); + if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); + + if ((v1->Pos.X - v3->Pos.X) == 0) + continue; + + TriangleRect.UpperLeftCorner.X = v1->Pos.X; + TriangleRect.LowerRightCorner.X = v3->Pos.X; + + // sort for height for faster drawing. + + if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); + if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); + if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); + + TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; + TriangleRect.LowerRightCorner.Y = v3->Pos.Y; + + if (!TriangleRect.isRectCollided(ViewPortRect)) + continue; + + + // höhe des dreiecks berechnen + height = v3->Pos.Y - v1->Pos.Y; + if (!height) + continue; + + // calculate longest span + + longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); + + spanEnd = v2->Pos.Y; + span = v1->Pos.Y; + leftxf = (f32)v1->Pos.X; + rightxf = (f32)v1->Pos.X; + + leftZValue = v1->ZValue; + rightZValue = v1->ZValue; + + leftR = rightR = video::getRedSigned(v1->Color)<<3; + leftG = rightG = video::getGreenSigned(v1->Color)<<3; + leftB = rightB = video::getBlueSigned(v1->Color)<<3; + + targetSurface = lockedSurface + span * SurfaceWidth; + zTarget = lockedZBuffer + span * SurfaceWidth; + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + rightStepR = (s32)(((video::getRedSigned(v2->Color)<<3) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreenSigned(v2->Color)<<3) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlueSigned(v2->Color)<<3) - rightB) * tmpDiv); + + tmpDiv = 1.0f / (f32)height; + leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + leftStepR = (s32)(((video::getRedSigned(v3->Color)<<3) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreenSigned(v3->Color)<<3) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlueSigned(v3->Color)<<3) - leftB) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (f32)height; + rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + rightStepR = (s32)(((video::getRedSigned(v3->Color)<<3) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreenSigned(v3->Color)<<3) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlueSigned(v3->Color)<<3) - rightB) * tmpDiv); + + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + leftStepR = (s32)(((video::getRedSigned(v2->Color)<<3) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreenSigned(v2->Color)<<3) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlueSigned(v2->Color)<<3) - leftB) * tmpDiv); + } + + + // do it twice, once for the first half of the triangle, + // end then for the second half. + + for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) + { + if (spanEnd > ViewPortRect.LowerRightCorner.Y) + spanEnd = ViewPortRect.LowerRightCorner.Y; + + // if the span <0, than we can skip these spans, + // and proceed to the next spans which are really on the screen. + if (span < ViewPortRect.UpperLeftCorner.Y) + { + // we'll use leftx as temp variable + if (spanEnd < ViewPortRect.UpperLeftCorner.Y) + { + leftx = spanEnd - span; + span = spanEnd; + } + else + { + leftx = ViewPortRect.UpperLeftCorner.Y - span; + span = ViewPortRect.UpperLeftCorner.Y; + } + + leftxf += leftdeltaxf*leftx; + rightxf += rightdeltaxf*leftx; + targetSurface += SurfaceWidth*leftx; + zTarget += SurfaceWidth*leftx; + leftZValue += leftZStep*leftx; + rightZValue += rightZStep*leftx; + + leftR += leftStepR*leftx; + leftG += leftStepG*leftx; + leftB += leftStepB*leftx; + rightR += rightStepR*leftx; + rightG += rightStepG*leftx; + rightB += rightStepB*leftx; + } + + + // the main loop. Go through every span and draw it. + + while (span < spanEnd) + { + leftx = (s32)(leftxf); + rightx = (s32)(rightxf + 0.5f); + + // perform some clipping + + // TODO: clipping is not correct when leftx is clipped. + + if (leftxViewPortRect.LowerRightCorner.X) + leftx = ViewPortRect.LowerRightCorner.X; + + if (rightxViewPortRect.LowerRightCorner.X) + rightx = ViewPortRect.LowerRightCorner.X; + + // draw the span + + if (rightx - leftx != 0) + { + tmpDiv = 1.0f / (rightx - leftx); + spanZValue = leftZValue; + spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); + + hSpanBegin = targetSurface + leftx; + spanZTarget = zTarget + leftx; + hSpanEnd = targetSurface + rightx; + + spanR = leftR; + spanG = leftG; + spanB = leftB; + spanStepR = (s32)((rightR - leftR) * tmpDiv); + spanStepG = (s32)((rightG - leftG) * tmpDiv); + spanStepB = (s32)((rightB - leftB) * tmpDiv); + + while (hSpanBegin < hSpanEnd) + { + if (spanZValue > *spanZTarget) + { + *spanZTarget = spanZValue; + *hSpanBegin = video::RGB16(spanR, spanG, spanB); + } + + spanR += spanStepR; + spanG += spanStepG; + spanB += spanStepB; + + spanZValue += spanZStep; + ++hSpanBegin; + ++spanZTarget; + } + } + + leftxf += leftdeltaxf; + rightxf += rightdeltaxf; + ++span; + targetSurface += SurfaceWidth; + zTarget += SurfaceWidth; + leftZValue += leftZStep; + rightZValue += rightZStep; + + leftR += leftStepR; + leftG += leftStepG; + leftB += leftStepB; + rightR += rightStepR; + rightG += rightStepG; + rightB += rightStepB; + } + + if (triangleHalf>0) // break, we've gout only two halves + break; + + + // setup variables for second half of the triangle. + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + rightxf = (f32)v2->Pos.X; + + rightZValue = v2->ZValue; + rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + + rightR = video::getRedSigned(v2->Color)<<3; + rightG = video::getGreenSigned(v2->Color)<<3; + rightB = video::getBlueSigned(v2->Color)<<3; + rightStepR = (s32)(((video::getRedSigned(v3->Color)<<3) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreenSigned(v3->Color)<<3) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlueSigned(v3->Color)<<3) - rightB) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + leftxf = (f32)v2->Pos.X; + + leftZValue = v2->ZValue; + leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + + leftR = video::getRedSigned(v2->Color)<<3; + leftG = video::getGreenSigned(v2->Color)<<3; + leftB = video::getBlueSigned(v2->Color)<<3; + leftStepR = (s32)(((video::getRedSigned(v3->Color)<<3) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreenSigned(v3->Color)<<3) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlueSigned(v3->Color)<<3) - leftB) * tmpDiv); + } + + + spanEnd = v3->Pos.Y; + } + + } + + RenderTarget->unlock(); + ZBuffer->unlock(); + } + +}; + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +ITriangleRenderer* createTriangleRendererGouraud(IZBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + return new CTRGouraud(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_SOFTWARE_ +} + +} // end namespace video +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CTRGouraud2.cpp b/src/dep/src/irrlicht/CTRGouraud2.cpp index 96697e7..70fc15b 100644 --- a/src/dep/src/irrlicht/CTRGouraud2.cpp +++ b/src/dep/src/irrlicht/CTRGouraud2.cpp @@ -1,672 +1,672 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -#define IPOL_C0 -//#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - -namespace irr -{ - -namespace video -{ - -class CTRGouraud2 : public IBurningShader -{ -public: - - //! constructor - CTRGouraud2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRGouraud2::CTRGouraud2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRGouraud2"); - #endif -} - - - -/*! -*/ -void CTRGouraud2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef USE_ZBUFFER - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - - -#ifdef IPOL_C0 - tFixPoint r0, g0, b0; - -#ifdef INVERSE_W - f32 inversew; -#endif - -#endif - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { -#ifdef IPOL_C0 -#ifdef INVERSE_W - inversew = core::reciprocal ( line.w[0] ); - - getSample_color ( r0, g0, b0, line.c[0] * inversew ); -#else - getSample_color ( r0, g0, b0, line.c[0] ); -#endif - - dst[i] = fix_to_color ( r0, g0, b0 ); -#else - dst[i] = COLOR_BRIGHT_WHITE; -#endif - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1; -#endif - } - -} - -void CTRGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( a->Pos.y > b->Pos.y ) swapVertexPointer(&a, &b); - if ( a->Pos.y > c->Pos.y ) swapVertexPointer(&a, &c); - if ( b->Pos.y > c->Pos.y ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererGouraud2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRGouraud2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +#define WRITE_W + +#define IPOL_C0 +//#define IPOL_T0 +//#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + + +namespace irr +{ + +namespace video +{ + +class CTRGouraud2 : public IBurningShader +{ +public: + + //! constructor + CTRGouraud2(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + +private: + void scanline_bilinear (); + sScanConvertData scan; + sScanLineData line; + +}; + +//! constructor +CTRGouraud2::CTRGouraud2(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRGouraud2"); + #endif +} + + + +/*! +*/ +void CTRGouraud2::scanline_bilinear () +{ + tVideoSample *dst; + +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef USE_ZBUFFER + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + + +#ifdef IPOL_C0 + tFixPoint r0, g0, b0; + +#ifdef INVERSE_W + f32 inversew; +#endif + +#endif + + for ( s32 i = 0; i <= dx; ++i ) + { +#ifdef CMP_Z + if ( line.z[0] < z[i] ) +#endif +#ifdef CMP_W + if ( line.w[0] >= z[i] ) +#endif + + { +#ifdef IPOL_C0 +#ifdef INVERSE_W + inversew = core::reciprocal ( line.w[0] ); + + getSample_color ( r0, g0, b0, line.c[0] * inversew ); +#else + getSample_color ( r0, g0, b0, line.c[0] ); +#endif + + dst[i] = fix_to_color ( r0, g0, b0 ); +#else + dst[i] = COLOR_BRIGHT_WHITE; +#endif + +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1; +#endif + } + +} + +void CTRGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + // sort on height, y + if ( a->Pos.y > b->Pos.y ) swapVertexPointer(&a, &b); + if ( a->Pos.y > c->Pos.y ) swapVertexPointer(&a, &c); + if ( b->Pos.y > c->Pos.y ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + // rasterize upper sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[1] ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[2] ) + { + // advance to middle point + if( (f32) 0.0 != scan.invDeltaY[1] ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +IBurningShader* createTriangleRendererGouraud2(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRGouraud2(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + + diff --git a/src/dep/src/irrlicht/CTRGouraudAlpha2.cpp b/src/dep/src/irrlicht/CTRGouraudAlpha2.cpp index 0e290c1..1e783f9 100644 --- a/src/dep/src/irrlicht/CTRGouraudAlpha2.cpp +++ b/src/dep/src/irrlicht/CTRGouraudAlpha2.cpp @@ -1,683 +1,683 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -#define IPOL_C0 -//#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - - -namespace irr -{ - -namespace video -{ - -class CTRGouraudAlpha2 : public IBurningShader -{ -public: - - //! constructor - CTRGouraudAlpha2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRGouraudAlpha2::CTRGouraudAlpha2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRGouraudAlpha2"); - #endif -} - - - -/*! -*/ -void CTRGouraudAlpha2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef USE_ZBUFFER - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - - -#ifdef IPOL_C0 - -#ifdef INVERSE_W - f32 inversew; -#endif - - tFixPoint a0; - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; -#endif - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { -#ifdef IPOL_C0 -#ifdef INVERSE_W - inversew = core::reciprocal ( line.w[0] ); - - getSample_color ( a0, r0, g0, b0, line.c[0] * inversew ); -#else - getSample_color ( a0, r0, g0, b0, line.c[0] ); -#endif - - color_to_fix ( r1, g1, b1, dst[i] ); - - r2 = r1 + imulFix ( a0, r0 - r1 ); - g2 = g1 + imulFix ( a0, g0 - g1 ); - b2 = b1 + imulFix ( a0, b0 - b1 ); - - dst[i] = fix_to_color ( r2, g2, b2 ); -#else - dst[i] = COLOR_BRIGHT_WHITE; -#endif -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1; -#endif - } - -} - -void CTRGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererGouraudAlpha2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRGouraudAlpha2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +#define WRITE_W + +#define IPOL_C0 +//#define IPOL_T0 +//#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + + + +namespace irr +{ + +namespace video +{ + +class CTRGouraudAlpha2 : public IBurningShader +{ +public: + + //! constructor + CTRGouraudAlpha2(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + +private: + void scanline_bilinear (); + + sScanConvertData scan; + sScanLineData line; + +}; + +//! constructor +CTRGouraudAlpha2::CTRGouraudAlpha2(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRGouraudAlpha2"); + #endif +} + + + +/*! +*/ +void CTRGouraudAlpha2::scanline_bilinear () +{ + tVideoSample *dst; + +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef USE_ZBUFFER + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + + +#ifdef IPOL_C0 + +#ifdef INVERSE_W + f32 inversew; +#endif + + tFixPoint a0; + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; + tFixPoint r2, g2, b2; +#endif + + for ( s32 i = 0; i <= dx; ++i ) + { +#ifdef CMP_Z + if ( line.z[0] < z[i] ) +#endif +#ifdef CMP_W + if ( line.w[0] >= z[i] ) +#endif + + { +#ifdef IPOL_C0 +#ifdef INVERSE_W + inversew = core::reciprocal ( line.w[0] ); + + getSample_color ( a0, r0, g0, b0, line.c[0] * inversew ); +#else + getSample_color ( a0, r0, g0, b0, line.c[0] ); +#endif + + color_to_fix ( r1, g1, b1, dst[i] ); + + r2 = r1 + imulFix ( a0, r0 - r1 ); + g2 = g1 + imulFix ( a0, g0 - g1 ); + b2 = b1 + imulFix ( a0, b0 - b1 ); + + dst[i] = fix_to_color ( r2, g2, b2 ); +#else + dst[i] = COLOR_BRIGHT_WHITE; +#endif +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1; +#endif + } + +} + +void CTRGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + // rasterize upper sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[1] ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear ( ); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[2] ) + { + // advance to middle point + if( (f32) 0.0 != scan.invDeltaY[1] ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear ( ); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +IBurningShader* createTriangleRendererGouraudAlpha2(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRGouraudAlpha2(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + + diff --git a/src/dep/src/irrlicht/CTRGouraudAlphaNoZ2.cpp b/src/dep/src/irrlicht/CTRGouraudAlphaNoZ2.cpp index ae9fa4b..25774c9 100644 --- a/src/dep/src/irrlicht/CTRGouraudAlphaNoZ2.cpp +++ b/src/dep/src/irrlicht/CTRGouraudAlphaNoZ2.cpp @@ -1,684 +1,684 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -//#define INVERSE_W - -//#define USE_ZBUFFER -//#define IPOL_W -//#define CMP_W -//#define WRITE_W - -#define IPOL_C0 -//#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - //#define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - - -namespace irr -{ - -namespace video -{ - -class CTRGouraudAlphaNoZ2 : public IBurningShader -{ -public: - - //! constructor - CTRGouraudAlphaNoZ2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRGouraudAlphaNoZ2::CTRGouraudAlphaNoZ2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRGouraudAlphaNoZ2"); - #endif -} - - - -/*! -*/ -void CTRGouraudAlphaNoZ2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef USE_ZBUFFER - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - - -#ifdef IPOL_C0 - -#ifdef INVERSE_W - f32 inversew; -#endif - - tFixPoint a0; - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; -#endif - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - { - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef IPOL_C0 -#ifdef IPOL_W - inversew = core::reciprocal ( line.w[0] ); - - getSample_color ( a0, r0, g0, b0, line.c[0] * inversew ); -#else - getSample_color ( a0, r0, g0, b0, line.c[0] ); -#endif - - color_to_fix ( r1, g1, b1, dst[i] ); - - r2 = r1 + imulFix ( a0, r0 - r1 ); - g2 = g1 + imulFix ( a0, g0 - g1 ); - b2 = b1 + imulFix ( a0, b0 - b1 ); - - dst[i] = fix_to_color ( r2, g2, b2 ); -#else - dst[i] = COLOR_BRIGHT_WHITE; -#endif - - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1; -#endif - } - -} - -void CTRGouraudAlphaNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTRGouraudAlphaNoZ2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRGouraudAlphaNoZ2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +//#define INVERSE_W + +//#define USE_ZBUFFER +//#define IPOL_W +//#define CMP_W +//#define WRITE_W + +#define IPOL_C0 +//#define IPOL_T0 +//#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + //#define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + + + +namespace irr +{ + +namespace video +{ + +class CTRGouraudAlphaNoZ2 : public IBurningShader +{ +public: + + //! constructor + CTRGouraudAlphaNoZ2(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + +private: + void scanline_bilinear (); + sScanConvertData scan; + sScanLineData line; + +}; + +//! constructor +CTRGouraudAlphaNoZ2::CTRGouraudAlphaNoZ2(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRGouraudAlphaNoZ2"); + #endif +} + + + +/*! +*/ +void CTRGouraudAlphaNoZ2::scanline_bilinear () +{ + tVideoSample *dst; + +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef USE_ZBUFFER + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + + +#ifdef IPOL_C0 + +#ifdef INVERSE_W + f32 inversew; +#endif + + tFixPoint a0; + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; + tFixPoint r2, g2, b2; +#endif + + for ( s32 i = 0; i <= dx; ++i ) + { +#ifdef CMP_Z + if ( line.z[0] < z[i] ) +#endif +#ifdef CMP_W + if ( line.w[0] >= z[i] ) +#endif + { + +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif + +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + +#ifdef IPOL_C0 +#ifdef IPOL_W + inversew = core::reciprocal ( line.w[0] ); + + getSample_color ( a0, r0, g0, b0, line.c[0] * inversew ); +#else + getSample_color ( a0, r0, g0, b0, line.c[0] ); +#endif + + color_to_fix ( r1, g1, b1, dst[i] ); + + r2 = r1 + imulFix ( a0, r0 - r1 ); + g2 = g1 + imulFix ( a0, g0 - g1 ); + b2 = b1 + imulFix ( a0, b0 - b1 ); + + dst[i] = fix_to_color ( r2, g2, b2 ); +#else + dst[i] = COLOR_BRIGHT_WHITE; +#endif + + + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1; +#endif + } + +} + +void CTRGouraudAlphaNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + // rasterize upper sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[1] ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[2] ) + { + // advance to middle point + if( (f32) 0.0 != scan.invDeltaY[1] ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +IBurningShader* createTRGouraudAlphaNoZ2(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRGouraudAlphaNoZ2(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CTRGouraudWire.cpp b/src/dep/src/irrlicht/CTRGouraudWire.cpp index fd0f1e4..be1c1dd 100644 --- a/src/dep/src/irrlicht/CTRGouraudWire.cpp +++ b/src/dep/src/irrlicht/CTRGouraudWire.cpp @@ -1,327 +1,327 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRGouraudWire : public CTRTextureGouraud -{ -public: - - CTRGouraudWire(IZBuffer* zbuffer) - : CTRTextureGouraud(zbuffer) - { - #ifdef _DEBUG - setDebugName("CTRGouraudWire"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values - s32 leftStepR, leftStepG, leftStepB, - rightStepR, rightStepG, rightStepB; // color steps - - core::rect TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - TZBufferType* zTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - - for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - - // höhe des dreiecks berechnen - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - leftR = rightR = video::getRed(v1->Color)<<8; - leftG = rightG = video::getGreen(v1->Color)<<8; - leftB = rightB = video::getBlue(v1->Color)<<8; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((video::getRed(v2->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreen(v2->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlue(v2->Color)<<8) - rightB) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((video::getRed(v2->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreen(v2->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlue(v2->Color)<<8) - leftB) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - - leftR += leftStepR*leftx; - leftG += leftStepG*leftx; - leftB += leftStepB*leftx; - rightR += rightStepR*leftx; - rightG += rightStepG*leftx; - rightB += rightStepB*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - - if (leftx>=ViewPortRect.UpperLeftCorner.X && - leftx<=ViewPortRect.LowerRightCorner.X) - { - if (leftZValue > *(zTarget + leftx)) - { - *(zTarget + leftx) = leftZValue; - *(targetSurface + leftx) = (((leftR>>8) & 0x1F)<<10) | (((leftG>>8) & 0x1F)<<5) | ((leftB>>8) & 0x1F); - } - } - - - if (rightx>=ViewPortRect.UpperLeftCorner.X && - rightx<=ViewPortRect.LowerRightCorner.X) - { - if (rightZValue > *(zTarget + rightx)) - { - *(zTarget + rightx) = rightZValue; - *(targetSurface + rightx) = (((rightR>>8) & 0x1F)<<10) | (((rightG>>8) & 0x1F)<<5) | ((rightB>>8) & 0x1F); - } - - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - - leftR += leftStepR; - leftG += leftStepG; - leftB += leftStepB; - rightR += rightStepR; - rightG += rightStepG; - rightB += rightStepB; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - rightR = video::getRed(v2->Color)<<8; - rightG = video::getGreen(v2->Color)<<8; - rightB = video::getBlue(v2->Color)<<8; - rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - leftR = video::getRed(v2->Color)<<8; - leftG = video::getGreen(v2->Color)<<8; - leftB = video::getBlue(v2->Color)<<8; - leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - } - -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererGouraudWire(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRGouraudWire(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "CTRTextureGouraud.h" + +#ifdef _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +class CTRGouraudWire : public CTRTextureGouraud +{ +public: + + CTRGouraudWire(IZBuffer* zbuffer) + : CTRTextureGouraud(zbuffer) + { + #ifdef _DEBUG + setDebugName("CTRGouraudWire"); + #endif + } + + //! draws an indexed triangle list + virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) + { + const S2DVertex *v1, *v2, *v3; + + f32 tmpDiv; // temporary division factor + f32 longest; // saves the longest span + s32 height; // saves height of triangle + u16* targetSurface; // target pointer where to plot pixels + s32 spanEnd; // saves end of spans + f32 leftdeltaxf; // amount of pixels to increase on left side of triangle + f32 rightdeltaxf; // amount of pixels to increase on right side of triangle + s32 leftx, rightx; // position where we are + f32 leftxf, rightxf; // same as above, but as f32 values + s32 span; // current span + s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values + s32 leftStepR, leftStepG, leftStepB, + rightStepR, rightStepG, rightStepB; // color steps + + core::rect TriangleRect; + + s32 leftZValue, rightZValue; + s32 leftZStep, rightZStep; + TZBufferType* zTarget; // target of ZBuffer; + + lockedSurface = (u16*)RenderTarget->lock(); + lockedZBuffer = ZBuffer->lock(); + + for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - + ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); + + if (z < 0) + continue; + } + + //near plane clipping + + if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) + continue; + + // sort for width for inscreen clipping + + if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); + if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); + if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); + + if ((v1->Pos.X - v3->Pos.X) == 0) + continue; + + TriangleRect.UpperLeftCorner.X = v1->Pos.X; + TriangleRect.LowerRightCorner.X = v3->Pos.X; + + // sort for height for faster drawing. + + if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); + if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); + if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); + + TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; + TriangleRect.LowerRightCorner.Y = v3->Pos.Y; + + if (!TriangleRect.isRectCollided(ViewPortRect)) + continue; + + + // höhe des dreiecks berechnen + height = v3->Pos.Y - v1->Pos.Y; + if (!height) + continue; + + // calculate longest span + + longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); + + spanEnd = v2->Pos.Y; + span = v1->Pos.Y; + leftxf = (f32)v1->Pos.X; + rightxf = (f32)v1->Pos.X; + + leftZValue = v1->ZValue; + rightZValue = v1->ZValue; + + leftR = rightR = video::getRed(v1->Color)<<8; + leftG = rightG = video::getGreen(v1->Color)<<8; + leftB = rightB = video::getBlue(v1->Color)<<8; + + targetSurface = lockedSurface + span * SurfaceWidth; + zTarget = lockedZBuffer + span * SurfaceWidth; + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + rightStepR = (s32)(((video::getRed(v2->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreen(v2->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlue(v2->Color)<<8) - rightB) * tmpDiv); + + tmpDiv = 1.0f / (f32)height; + leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (f32)height; + rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); + + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + leftStepR = (s32)(((video::getRed(v2->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreen(v2->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlue(v2->Color)<<8) - leftB) * tmpDiv); + } + + + // do it twice, once for the first half of the triangle, + // end then for the second half. + + for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) + { + if (spanEnd > ViewPortRect.LowerRightCorner.Y) + spanEnd = ViewPortRect.LowerRightCorner.Y; + + // if the span <0, than we can skip these spans, + // and proceed to the next spans which are really on the screen. + if (span < ViewPortRect.UpperLeftCorner.Y) + { + // we'll use leftx as temp variable + if (spanEnd < ViewPortRect.UpperLeftCorner.Y) + { + leftx = spanEnd - span; + span = spanEnd; + } + else + { + leftx = ViewPortRect.UpperLeftCorner.Y - span; + span = ViewPortRect.UpperLeftCorner.Y; + } + + leftxf += leftdeltaxf*leftx; + rightxf += rightdeltaxf*leftx; + targetSurface += SurfaceWidth*leftx; + zTarget += SurfaceWidth*leftx; + leftZValue += leftZStep*leftx; + rightZValue += rightZStep*leftx; + + leftR += leftStepR*leftx; + leftG += leftStepG*leftx; + leftB += leftStepB*leftx; + rightR += rightStepR*leftx; + rightG += rightStepG*leftx; + rightB += rightStepB*leftx; + } + + + // the main loop. Go through every span and draw it. + + while (span < spanEnd) + { + leftx = (s32)(leftxf); + rightx = (s32)(rightxf + 0.5f); + + // perform some clipping + + if (leftx>=ViewPortRect.UpperLeftCorner.X && + leftx<=ViewPortRect.LowerRightCorner.X) + { + if (leftZValue > *(zTarget + leftx)) + { + *(zTarget + leftx) = leftZValue; + *(targetSurface + leftx) = (((leftR>>8) & 0x1F)<<10) | (((leftG>>8) & 0x1F)<<5) | ((leftB>>8) & 0x1F); + } + } + + + if (rightx>=ViewPortRect.UpperLeftCorner.X && + rightx<=ViewPortRect.LowerRightCorner.X) + { + if (rightZValue > *(zTarget + rightx)) + { + *(zTarget + rightx) = rightZValue; + *(targetSurface + rightx) = (((rightR>>8) & 0x1F)<<10) | (((rightG>>8) & 0x1F)<<5) | ((rightB>>8) & 0x1F); + } + + } + + leftxf += leftdeltaxf; + rightxf += rightdeltaxf; + ++span; + targetSurface += SurfaceWidth; + zTarget += SurfaceWidth; + leftZValue += leftZStep; + rightZValue += rightZStep; + + leftR += leftStepR; + leftG += leftStepG; + leftB += leftStepB; + rightR += rightStepR; + rightG += rightStepG; + rightB += rightStepB; + } + + if (triangleHalf>0) // break, we've gout only two halves + break; + + + // setup variables for second half of the triangle. + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + rightxf = (f32)v2->Pos.X; + + rightZValue = v2->ZValue; + rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + + rightR = video::getRed(v2->Color)<<8; + rightG = video::getGreen(v2->Color)<<8; + rightB = video::getBlue(v2->Color)<<8; + rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + leftxf = (f32)v2->Pos.X; + + leftZValue = v2->ZValue; + leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + + leftR = video::getRed(v2->Color)<<8; + leftG = video::getGreen(v2->Color)<<8; + leftB = video::getBlue(v2->Color)<<8; + leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); + } + + + spanEnd = v3->Pos.Y; + } + + } + + RenderTarget->unlock(); + ZBuffer->unlock(); + } + +}; + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + + +//! creates a flat triangle renderer +ITriangleRenderer* createTriangleRendererGouraudWire(IZBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + return new CTRGouraudWire(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_SOFTWARE_ +} + +} // end namespace video +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CTRTextureBlend.cpp b/src/dep/src/irrlicht/CTRTextureBlend.cpp index bf960b8..56019cc 100644 --- a/src/dep/src/irrlicht/CTRTextureBlend.cpp +++ b/src/dep/src/irrlicht/CTRTextureBlend.cpp @@ -1,712 +1,712 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - - -namespace irr -{ - -namespace video -{ - -class CTRTextureBlend : public IBurningShader -{ -public: - - //! constructor - CTRTextureBlend(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - virtual void setZCompareFunc ( u32 func); - -private: - void scanline_bilinear (); - - sScanConvertData scan; - sScanLineData line; - - u32 ZCompare; - -}; - -//! constructor -CTRTextureBlend::CTRTextureBlend(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureBlend"); - #endif - - ZCompare = 1; -} - - -void CTRTextureBlend::setZCompareFunc ( u32 func) -{ - ZCompare = func; -} - -/*! -*/ -void CTRTextureBlend::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef USE_ZBUFFER - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - - f32 inversew = FIX_POINT_F32_MUL; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - - s32 i; - - switch ( ZCompare ) - { - case 1: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSEW - inversew = fix_inverse32 ( line.w[0] ); -#endif - - getSample_texture ( r0, g0, b0, - &IT[0], - f32_to_fixPoint ( line.t0[0].x,inversew), - f32_to_fixPoint ( line.t0[0].y,inversew) - ); - - color_to_fix ( r1, g1, b1, dst[i] ); - - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ), - clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ), - clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ) - ); - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif - } - break; - - case 2: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] == z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSEW - inversew = fix_inverse32 ( line.w[0] ); -#endif - getSample_texture ( r0, g0, b0, - &IT[0], - f32_to_fixPoint ( line.t0[0].x,inversew), - f32_to_fixPoint ( line.t0[0].y,inversew) - ); - - color_to_fix ( r1, g1, b1, dst[i] ); - - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ), - clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ), - clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ) - ); - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif - }break; - } // zcompare - -} - -void CTRTextureBlend::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTRTextureBlend(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureBlend(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +#define WRITE_W + +//#define IPOL_C0 +#define IPOL_T0 +//#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + + + +namespace irr +{ + +namespace video +{ + +class CTRTextureBlend : public IBurningShader +{ +public: + + //! constructor + CTRTextureBlend(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + virtual void setZCompareFunc ( u32 func); + +private: + void scanline_bilinear (); + + sScanConvertData scan; + sScanLineData line; + + u32 ZCompare; + +}; + +//! constructor +CTRTextureBlend::CTRTextureBlend(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureBlend"); + #endif + + ZCompare = 1; +} + + +void CTRTextureBlend::setZCompareFunc ( u32 func) +{ + ZCompare = func; +} + +/*! +*/ +void CTRTextureBlend::scanline_bilinear () +{ + tVideoSample *dst; + +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef USE_ZBUFFER + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + + f32 inversew = FIX_POINT_F32_MUL; + + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; + + s32 i; + + switch ( ZCompare ) + { + case 1: + for ( i = 0; i <= dx; ++i ) + { +#ifdef CMP_W + if ( line.w[0] >= z[i] ) +#endif + + { + +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + +#ifdef INVERSEW + inversew = fix_inverse32 ( line.w[0] ); +#endif + + getSample_texture ( r0, g0, b0, + &IT[0], + f32_to_fixPoint ( line.t0[0].x,inversew), + f32_to_fixPoint ( line.t0[0].y,inversew) + ); + + color_to_fix ( r1, g1, b1, dst[i] ); + + dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ), + clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ), + clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ) + ); + } + +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif + } + break; + + case 2: + for ( i = 0; i <= dx; ++i ) + { +#ifdef CMP_W + if ( line.w[0] == z[i] ) +#endif + + { + +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + +#ifdef INVERSEW + inversew = fix_inverse32 ( line.w[0] ); +#endif + getSample_texture ( r0, g0, b0, + &IT[0], + f32_to_fixPoint ( line.t0[0].x,inversew), + f32_to_fixPoint ( line.t0[0].y,inversew) + ); + + color_to_fix ( r1, g1, b1, dst[i] ); + + dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ), + clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ), + clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ) + ); + } + +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif + }break; + } // zcompare + +} + +void CTRTextureBlend::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + // rasterize upper sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[1] ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear ( ); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[2] ) + { + // advance to middle point + if( (f32) 0.0 != scan.invDeltaY[1] ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear ( ); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +IBurningShader* createTRTextureBlend(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRTextureBlend(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CTRTextureDetailMap2.cpp b/src/dep/src/irrlicht/CTRTextureDetailMap2.cpp index a0fb461..839534d 100644 --- a/src/dep/src/irrlicht/CTRTextureDetailMap2.cpp +++ b/src/dep/src/irrlicht/CTRTextureDetailMap2.cpp @@ -1,690 +1,690 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -#define IPOL_C0 -#define IPOL_T0 -#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - -namespace irr -{ - -namespace video -{ - -class CTRTextureDetailMap2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureDetailMap2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRTextureDetailMap2::CTRTextureDetailMap2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureDetailMap2"); - #endif -} - - - -/*! -*/ -void CTRTextureDetailMap2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef USE_ZBUFFER - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - - tFixPoint tx0, tx1; - tFixPoint ty0, ty1; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; - - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - - tx0 = f32_to_fixPoint ( line.t0[0].x,inversew); - ty0 = f32_to_fixPoint ( line.t0[0].y,inversew); - tx1 = f32_to_fixPoint ( line.t1[0].x,inversew); - ty1 = f32_to_fixPoint ( line.t1[0].y,inversew); - -#else - tx0 = f32_to_fixPoint ( line.t0[0].x ); - ty0 = f32_to_fixPoint ( line.t0[0].y ); - tx1 = f32_to_fixPoint ( line.t1[0].x ); - ty1 = f32_to_fixPoint ( line.t1[0].y ); -#endif - getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); - getSample_texture ( r1, g1, b1, &IT[1], tx1,ty1 ); - -#define FIX_POINT_HALF_COLOR ( (tFixPoint) ( ((f32) COLOR_MAX / 2.f * FIX_POINT_F32_MUL ) ) ) - - // bias half color - r1 += -FIX_POINT_HALF_COLOR; - g1 += -FIX_POINT_HALF_COLOR; - b1 += -FIX_POINT_HALF_COLOR; - - r2 = clampfix_mincolor ( clampfix_maxcolor ( r0 + r1 ) ); - g2 = clampfix_mincolor ( clampfix_maxcolor ( g0 + g1 ) ); - b2 = clampfix_mincolor ( clampfix_maxcolor ( b0 + b1 ) ); - - dst[i] = fix_to_color ( r2, g2, b2 ); - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1; -#endif - } - -} - -void CTRTextureDetailMap2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureDetailMap2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureDetailMap2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +#define WRITE_W + +#define IPOL_C0 +#define IPOL_T0 +#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + + +namespace irr +{ + +namespace video +{ + +class CTRTextureDetailMap2 : public IBurningShader +{ +public: + + //! constructor + CTRTextureDetailMap2(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + +private: + void scanline_bilinear (); + sScanConvertData scan; + sScanLineData line; + +}; + +//! constructor +CTRTextureDetailMap2::CTRTextureDetailMap2(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureDetailMap2"); + #endif +} + + + +/*! +*/ +void CTRTextureDetailMap2::scanline_bilinear () +{ + tVideoSample *dst; + +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef USE_ZBUFFER + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + +#ifdef INVERSE_W + f32 inversew; +#endif + + tFixPoint tx0, tx1; + tFixPoint ty0, ty1; + + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; + tFixPoint r2, g2, b2; + + + for ( s32 i = 0; i <= dx; ++i ) + { +#ifdef CMP_Z + if ( line.z[0] < z[i] ) +#endif +#ifdef CMP_W + if ( line.w[0] >= z[i] ) +#endif + + { +#ifdef INVERSE_W + inversew = fix_inverse32 ( line.w[0] ); + + tx0 = f32_to_fixPoint ( line.t0[0].x,inversew); + ty0 = f32_to_fixPoint ( line.t0[0].y,inversew); + tx1 = f32_to_fixPoint ( line.t1[0].x,inversew); + ty1 = f32_to_fixPoint ( line.t1[0].y,inversew); + +#else + tx0 = f32_to_fixPoint ( line.t0[0].x ); + ty0 = f32_to_fixPoint ( line.t0[0].y ); + tx1 = f32_to_fixPoint ( line.t1[0].x ); + ty1 = f32_to_fixPoint ( line.t1[0].y ); +#endif + getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); + getSample_texture ( r1, g1, b1, &IT[1], tx1,ty1 ); + +#define FIX_POINT_HALF_COLOR ( (tFixPoint) ( ((f32) COLOR_MAX / 2.f * FIX_POINT_F32_MUL ) ) ) + + // bias half color + r1 += -FIX_POINT_HALF_COLOR; + g1 += -FIX_POINT_HALF_COLOR; + b1 += -FIX_POINT_HALF_COLOR; + + r2 = clampfix_mincolor ( clampfix_maxcolor ( r0 + r1 ) ); + g2 = clampfix_mincolor ( clampfix_maxcolor ( g0 + g1 ) ); + b2 = clampfix_mincolor ( clampfix_maxcolor ( b0 + b1 ) ); + + dst[i] = fix_to_color ( r2, g2, b2 ); + +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1; +#endif + } + +} + +void CTRTextureDetailMap2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + // rasterize upper sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[1] ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[2] ) + { + // advance to middle point + if( (f32) 0.0 != scan.invDeltaY[1] ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +IBurningShader* createTriangleRendererTextureDetailMap2(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRTextureDetailMap2(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CTRTextureFlat.cpp b/src/dep/src/irrlicht/CTRTextureFlat.cpp index f104c02..6c3554d 100644 --- a/src/dep/src/irrlicht/CTRTextureFlat.cpp +++ b/src/dep/src/irrlicht/CTRTextureFlat.cpp @@ -1,340 +1,340 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRTextureFlat : public CTRTextureGouraud -{ -public: - - CTRTextureFlat(IZBuffer* zbuffer) - : CTRTextureGouraud(zbuffer) - { - #ifdef _DEBUG - setDebugName("CTRTextureFlat"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels - s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values - s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values - s32 spanTx, spanTy, spanTxStep, spanTyStep; // values of Texturecoords when drawing a span - core::rect TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - s32 spanZValue, spanZStep; // ZValues when drawing a span - TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - lockedTexture = (u16*)Texture->lock(); - - for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - - // höhe des dreiecks berechnen - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - leftTx = rightTx = v1->TCoords.X; - leftTy = rightTy = v1->TCoords.Y; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - - leftTx += leftTxStep*leftx; - leftTy += leftTyStep*leftx; - rightTx += rightTxStep*leftx; - rightTy += rightTyStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - - // TODO: clipping is not correct when leftx is clipped. - - if (leftxViewPortRect.LowerRightCorner.X) - leftx = ViewPortRect.LowerRightCorner.X; - - if (rightxViewPortRect.LowerRightCorner.X) - rightx = ViewPortRect.LowerRightCorner.X; - - // draw the span - - if (rightx - leftx != 0) - { - tmpDiv = 1.0f / (rightx - leftx); - spanZValue = leftZValue; - spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); - - hSpanBegin = targetSurface + leftx; - spanZTarget = zTarget + leftx; - hSpanEnd = targetSurface + rightx; - - spanTx = leftTx; - spanTy = leftTy; - spanTxStep = (s32)((rightTx - leftTx) * tmpDiv); - spanTyStep = (s32)((rightTy - leftTy) * tmpDiv); - - while (hSpanBegin < hSpanEnd) - { - if (spanZValue > *spanZTarget) - { - *spanZTarget = spanZValue; - *hSpanBegin = lockedTexture[((spanTy>>8)&textureYMask) * lockedTextureWidth + ((spanTx>>8)&textureXMask)]; - } - - spanTx += spanTxStep; - spanTy += spanTyStep; - - spanZValue += spanZStep; - ++hSpanBegin; - ++spanZTarget; - } - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - - leftTx += leftTxStep; - leftTy += leftTyStep; - rightTx += rightTxStep; - rightTy += rightTyStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - rightTx = v2->TCoords.X; - rightTy = v2->TCoords.Y; - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - leftTx = v2->TCoords.X; - leftTy = v2->TCoords.Y; - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - Texture->unlock(); - - } -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererTextureFlat(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRTextureFlat(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "CTRTextureGouraud.h" + +#ifdef _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +class CTRTextureFlat : public CTRTextureGouraud +{ +public: + + CTRTextureFlat(IZBuffer* zbuffer) + : CTRTextureGouraud(zbuffer) + { + #ifdef _DEBUG + setDebugName("CTRTextureFlat"); + #endif + } + + //! draws an indexed triangle list + virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) + { + const S2DVertex *v1, *v2, *v3; + + f32 tmpDiv; // temporary division factor + f32 longest; // saves the longest span + s32 height; // saves height of triangle + u16* targetSurface; // target pointer where to plot pixels + s32 spanEnd; // saves end of spans + f32 leftdeltaxf; // amount of pixels to increase on left side of triangle + f32 rightdeltaxf; // amount of pixels to increase on right side of triangle + s32 leftx, rightx; // position where we are + f32 leftxf, rightxf; // same as above, but as f32 values + s32 span; // current span + u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels + s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values + s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values + s32 spanTx, spanTy, spanTxStep, spanTyStep; // values of Texturecoords when drawing a span + core::rect TriangleRect; + + s32 leftZValue, rightZValue; + s32 leftZStep, rightZStep; + s32 spanZValue, spanZStep; // ZValues when drawing a span + TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; + + lockedSurface = (u16*)RenderTarget->lock(); + lockedZBuffer = ZBuffer->lock(); + lockedTexture = (u16*)Texture->lock(); + + for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - + ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); + + if (z < 0) + continue; + } + + //near plane clipping + + if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) + continue; + + // sort for width for inscreen clipping + + if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); + if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); + if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); + + if ((v1->Pos.X - v3->Pos.X) == 0) + continue; + + TriangleRect.UpperLeftCorner.X = v1->Pos.X; + TriangleRect.LowerRightCorner.X = v3->Pos.X; + + // sort for height for faster drawing. + + if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); + if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); + if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); + + TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; + TriangleRect.LowerRightCorner.Y = v3->Pos.Y; + + if (!TriangleRect.isRectCollided(ViewPortRect)) + continue; + + + // höhe des dreiecks berechnen + height = v3->Pos.Y - v1->Pos.Y; + if (!height) + continue; + + // calculate longest span + + longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); + + spanEnd = v2->Pos.Y; + span = v1->Pos.Y; + leftxf = (f32)v1->Pos.X; + rightxf = (f32)v1->Pos.X; + + leftZValue = v1->ZValue; + rightZValue = v1->ZValue; + + leftTx = rightTx = v1->TCoords.X; + leftTy = rightTy = v1->TCoords.Y; + + targetSurface = lockedSurface + span * SurfaceWidth; + zTarget = lockedZBuffer + span * SurfaceWidth; + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); + + tmpDiv = 1.0f / (f32)height; + leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (f32)height; + rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); + + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); + } + + + // do it twice, once for the first half of the triangle, + // end then for the second half. + + for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) + { + if (spanEnd > ViewPortRect.LowerRightCorner.Y) + spanEnd = ViewPortRect.LowerRightCorner.Y; + + // if the span <0, than we can skip these spans, + // and proceed to the next spans which are really on the screen. + if (span < ViewPortRect.UpperLeftCorner.Y) + { + // we'll use leftx as temp variable + if (spanEnd < ViewPortRect.UpperLeftCorner.Y) + { + leftx = spanEnd - span; + span = spanEnd; + } + else + { + leftx = ViewPortRect.UpperLeftCorner.Y - span; + span = ViewPortRect.UpperLeftCorner.Y; + } + + leftxf += leftdeltaxf*leftx; + rightxf += rightdeltaxf*leftx; + targetSurface += SurfaceWidth*leftx; + zTarget += SurfaceWidth*leftx; + leftZValue += leftZStep*leftx; + rightZValue += rightZStep*leftx; + + leftTx += leftTxStep*leftx; + leftTy += leftTyStep*leftx; + rightTx += rightTxStep*leftx; + rightTy += rightTyStep*leftx; + } + + + // the main loop. Go through every span and draw it. + + while (span < spanEnd) + { + leftx = (s32)(leftxf); + rightx = (s32)(rightxf + 0.5f); + + // perform some clipping + + // TODO: clipping is not correct when leftx is clipped. + + if (leftxViewPortRect.LowerRightCorner.X) + leftx = ViewPortRect.LowerRightCorner.X; + + if (rightxViewPortRect.LowerRightCorner.X) + rightx = ViewPortRect.LowerRightCorner.X; + + // draw the span + + if (rightx - leftx != 0) + { + tmpDiv = 1.0f / (rightx - leftx); + spanZValue = leftZValue; + spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); + + hSpanBegin = targetSurface + leftx; + spanZTarget = zTarget + leftx; + hSpanEnd = targetSurface + rightx; + + spanTx = leftTx; + spanTy = leftTy; + spanTxStep = (s32)((rightTx - leftTx) * tmpDiv); + spanTyStep = (s32)((rightTy - leftTy) * tmpDiv); + + while (hSpanBegin < hSpanEnd) + { + if (spanZValue > *spanZTarget) + { + *spanZTarget = spanZValue; + *hSpanBegin = lockedTexture[((spanTy>>8)&textureYMask) * lockedTextureWidth + ((spanTx>>8)&textureXMask)]; + } + + spanTx += spanTxStep; + spanTy += spanTyStep; + + spanZValue += spanZStep; + ++hSpanBegin; + ++spanZTarget; + } + } + + leftxf += leftdeltaxf; + rightxf += rightdeltaxf; + ++span; + targetSurface += SurfaceWidth; + zTarget += SurfaceWidth; + leftZValue += leftZStep; + rightZValue += rightZStep; + + leftTx += leftTxStep; + leftTy += leftTyStep; + rightTx += rightTxStep; + rightTy += rightTyStep; + } + + if (triangleHalf>0) // break, we've gout only two halves + break; + + + // setup variables for second half of the triangle. + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + rightxf = (f32)v2->Pos.X; + + rightZValue = v2->ZValue; + rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + + rightTx = v2->TCoords.X; + rightTy = v2->TCoords.Y; + rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + leftxf = (f32)v2->Pos.X; + + leftZValue = v2->ZValue; + leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + + leftTx = v2->TCoords.X; + leftTy = v2->TCoords.Y; + leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); + } + + + spanEnd = v3->Pos.Y; + } + + } + + RenderTarget->unlock(); + ZBuffer->unlock(); + Texture->unlock(); + + } +}; + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +ITriangleRenderer* createTriangleRendererTextureFlat(IZBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + return new CTRTextureFlat(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_SOFTWARE_ +} + +} // end namespace video +} // end namespace irr diff --git a/src/dep/src/irrlicht/CTRTextureFlatWire.cpp b/src/dep/src/irrlicht/CTRTextureFlatWire.cpp index 5c51c2f..2ef4763 100644 --- a/src/dep/src/irrlicht/CTRTextureFlatWire.cpp +++ b/src/dep/src/irrlicht/CTRTextureFlatWire.cpp @@ -1,314 +1,314 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRTextureFlatWire : public CTRTextureGouraud -{ -public: - - CTRTextureFlatWire(IZBuffer* zbuffer) - : CTRTextureGouraud(zbuffer) - { - #ifdef _DEBUG - setDebugName("CTRTextureFlatWire"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values - s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values - core::rect TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - TZBufferType* zTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - lockedTexture = (u16*)Texture->lock(); - - for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - - // höhe des dreiecks berechnen - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - leftTx = rightTx = v1->TCoords.X; - leftTy = rightTy = v1->TCoords.Y; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - - leftTx += leftTxStep*leftx; - leftTy += leftTyStep*leftx; - rightTx += rightTxStep*leftx; - rightTy += rightTyStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - - if (leftx>=ViewPortRect.UpperLeftCorner.X && - leftx<=ViewPortRect.LowerRightCorner.X) - { - if (leftZValue > *(zTarget + leftx)) - { - *(zTarget + leftx) = leftZValue; - *(targetSurface + leftx) = lockedTexture[((leftTy>>8)&textureYMask) * lockedTextureWidth + ((rightTx>>8)&textureXMask)]; - } - } - - - if (rightx>=ViewPortRect.UpperLeftCorner.X && - rightx<=ViewPortRect.LowerRightCorner.X) - { - if (rightZValue > *(zTarget + rightx)) - { - *(zTarget + rightx) = rightZValue; - *(targetSurface + rightx) = lockedTexture[((rightTy>>8)&textureYMask) * lockedTextureWidth + ((rightTx>>8)&textureXMask)]; - } - - } - - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - - leftTx += leftTxStep; - leftTy += leftTyStep; - rightTx += rightTxStep; - rightTy += rightTyStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - rightTx = v2->TCoords.X; - rightTy = v2->TCoords.Y; - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - leftTx = v2->TCoords.X; - leftTy = v2->TCoords.Y; - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - Texture->unlock(); - - } -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererTextureFlatWire(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRTextureFlatWire(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "CTRTextureGouraud.h" + +#ifdef _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +class CTRTextureFlatWire : public CTRTextureGouraud +{ +public: + + CTRTextureFlatWire(IZBuffer* zbuffer) + : CTRTextureGouraud(zbuffer) + { + #ifdef _DEBUG + setDebugName("CTRTextureFlatWire"); + #endif + } + + //! draws an indexed triangle list + virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) + { + const S2DVertex *v1, *v2, *v3; + + f32 tmpDiv; // temporary division factor + f32 longest; // saves the longest span + s32 height; // saves height of triangle + u16* targetSurface; // target pointer where to plot pixels + s32 spanEnd; // saves end of spans + f32 leftdeltaxf; // amount of pixels to increase on left side of triangle + f32 rightdeltaxf; // amount of pixels to increase on right side of triangle + s32 leftx, rightx; // position where we are + f32 leftxf, rightxf; // same as above, but as f32 values + s32 span; // current span + s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values + s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values + core::rect TriangleRect; + + s32 leftZValue, rightZValue; + s32 leftZStep, rightZStep; + TZBufferType* zTarget; // target of ZBuffer; + + lockedSurface = (u16*)RenderTarget->lock(); + lockedZBuffer = ZBuffer->lock(); + lockedTexture = (u16*)Texture->lock(); + + for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - + ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); + + if (z < 0) + continue; + } + + //near plane clipping + + if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) + continue; + + // sort for width for inscreen clipping + + if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); + if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); + if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); + + if ((v1->Pos.X - v3->Pos.X) == 0) + continue; + + TriangleRect.UpperLeftCorner.X = v1->Pos.X; + TriangleRect.LowerRightCorner.X = v3->Pos.X; + + // sort for height for faster drawing. + + if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); + if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); + if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); + + TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; + TriangleRect.LowerRightCorner.Y = v3->Pos.Y; + + if (!TriangleRect.isRectCollided(ViewPortRect)) + continue; + + + // höhe des dreiecks berechnen + height = v3->Pos.Y - v1->Pos.Y; + if (!height) + continue; + + // calculate longest span + + longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); + + spanEnd = v2->Pos.Y; + span = v1->Pos.Y; + leftxf = (f32)v1->Pos.X; + rightxf = (f32)v1->Pos.X; + + leftZValue = v1->ZValue; + rightZValue = v1->ZValue; + + leftTx = rightTx = v1->TCoords.X; + leftTy = rightTy = v1->TCoords.Y; + + targetSurface = lockedSurface + span * SurfaceWidth; + zTarget = lockedZBuffer + span * SurfaceWidth; + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); + + tmpDiv = 1.0f / (f32)height; + leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (f32)height; + rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); + + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); + } + + + // do it twice, once for the first half of the triangle, + // end then for the second half. + + for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) + { + if (spanEnd > ViewPortRect.LowerRightCorner.Y) + spanEnd = ViewPortRect.LowerRightCorner.Y; + + // if the span <0, than we can skip these spans, + // and proceed to the next spans which are really on the screen. + if (span < ViewPortRect.UpperLeftCorner.Y) + { + // we'll use leftx as temp variable + if (spanEnd < ViewPortRect.UpperLeftCorner.Y) + { + leftx = spanEnd - span; + span = spanEnd; + } + else + { + leftx = ViewPortRect.UpperLeftCorner.Y - span; + span = ViewPortRect.UpperLeftCorner.Y; + } + + leftxf += leftdeltaxf*leftx; + rightxf += rightdeltaxf*leftx; + targetSurface += SurfaceWidth*leftx; + zTarget += SurfaceWidth*leftx; + leftZValue += leftZStep*leftx; + rightZValue += rightZStep*leftx; + + leftTx += leftTxStep*leftx; + leftTy += leftTyStep*leftx; + rightTx += rightTxStep*leftx; + rightTy += rightTyStep*leftx; + } + + + // the main loop. Go through every span and draw it. + + while (span < spanEnd) + { + leftx = (s32)(leftxf); + rightx = (s32)(rightxf + 0.5f); + + // perform some clipping + + if (leftx>=ViewPortRect.UpperLeftCorner.X && + leftx<=ViewPortRect.LowerRightCorner.X) + { + if (leftZValue > *(zTarget + leftx)) + { + *(zTarget + leftx) = leftZValue; + *(targetSurface + leftx) = lockedTexture[((leftTy>>8)&textureYMask) * lockedTextureWidth + ((rightTx>>8)&textureXMask)]; + } + } + + + if (rightx>=ViewPortRect.UpperLeftCorner.X && + rightx<=ViewPortRect.LowerRightCorner.X) + { + if (rightZValue > *(zTarget + rightx)) + { + *(zTarget + rightx) = rightZValue; + *(targetSurface + rightx) = lockedTexture[((rightTy>>8)&textureYMask) * lockedTextureWidth + ((rightTx>>8)&textureXMask)]; + } + + } + + + leftxf += leftdeltaxf; + rightxf += rightdeltaxf; + ++span; + targetSurface += SurfaceWidth; + zTarget += SurfaceWidth; + leftZValue += leftZStep; + rightZValue += rightZStep; + + leftTx += leftTxStep; + leftTy += leftTyStep; + rightTx += rightTxStep; + rightTy += rightTyStep; + } + + if (triangleHalf>0) // break, we've gout only two halves + break; + + + // setup variables for second half of the triangle. + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + rightxf = (f32)v2->Pos.X; + + rightZValue = v2->ZValue; + rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + + rightTx = v2->TCoords.X; + rightTy = v2->TCoords.Y; + rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + leftxf = (f32)v2->Pos.X; + + leftZValue = v2->ZValue; + leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + + leftTx = v2->TCoords.X; + leftTy = v2->TCoords.Y; + leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); + } + + + spanEnd = v3->Pos.Y; + } + + } + + RenderTarget->unlock(); + ZBuffer->unlock(); + Texture->unlock(); + + } +}; + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +ITriangleRenderer* createTriangleRendererTextureFlatWire(IZBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + return new CTRTextureFlatWire(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_SOFTWARE_ +} + +} // end namespace video +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CTRTextureGouraud.cpp b/src/dep/src/irrlicht/CTRTextureGouraud.cpp index 6850e12..435bcb9 100644 --- a/src/dep/src/irrlicht/CTRTextureGouraud.cpp +++ b/src/dep/src/irrlicht/CTRTextureGouraud.cpp @@ -1,467 +1,467 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "CTRTextureGouraud.h" -#include "os.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! constructor -CTRTextureGouraud::CTRTextureGouraud(IZBuffer* zbuffer) -: RenderTarget(0), BackFaceCullingEnabled(true), SurfaceHeight(0), SurfaceWidth(0), - Texture(0), ZBuffer(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraud"); - #endif - - if (ZBuffer) - zbuffer->grab(); -} - - - -//! destructor -CTRTextureGouraud::~CTRTextureGouraud() -{ - if (RenderTarget) - RenderTarget->drop(); - - if (ZBuffer) - ZBuffer->drop(); - - if (Texture) - Texture->drop(); -} - - - -//! sets the Texture -void CTRTextureGouraud::setTexture(video::IImage* texture) -{ - if (Texture) - Texture->drop(); - - Texture = texture; - - if (Texture) - { - Texture->grab(); - lockedTextureWidth = Texture->getDimension().Width; - - textureXMask = lockedTextureWidth-1; - textureYMask = Texture->getDimension().Height-1; - } -} - - - - -//! en or disables the backface culling -void CTRTextureGouraud::setBackfaceCulling(bool enabled) -{ - BackFaceCullingEnabled = enabled; -} - - - -//! sets a render target -void CTRTextureGouraud::setRenderTarget(video::IImage* surface, const core::rect& viewPort) -{ - if (RenderTarget) - RenderTarget->drop(); - - RenderTarget = surface; - - if (RenderTarget) - { - SurfaceWidth = RenderTarget->getDimension().Width; - SurfaceHeight = RenderTarget->getDimension().Height; - RenderTarget->grab(); - ViewPortRect = viewPort; - } -} - - - -//! draws an indexed triangle list -void CTRTextureGouraud::drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) -{ - const S2DVertex *v1, *v2, *v3; - - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels - s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values - s32 leftStepR, leftStepG, leftStepB, - rightStepR, rightStepG, rightStepB; // color steps - s32 spanR, spanG, spanB, spanStepR, spanStepG, spanStepB; // color interpolating values while drawing a span. - s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values - s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values - s32 spanTx, spanTy, spanTxStep, spanTyStep; // values of Texturecoords when drawing a span - core::rect TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - s32 spanZValue, spanZStep; // ZValues when drawing a span - TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - lockedTexture = (u16*)Texture->lock(); - - for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - - // höhe des dreiecks berechnen - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - leftR = rightR = video::getRedSigned(v1->Color)<<8; - leftG = rightG = video::getGreenSigned(v1->Color)<<8; - leftB = rightB = video::getBlueSigned(v1->Color)<<8; - leftTx = rightTx = v1->TCoords.X; - leftTy = rightTy = v1->TCoords.Y; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((video::getRedSigned(v2->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreenSigned(v2->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlueSigned(v2->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((video::getRedSigned(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreenSigned(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlueSigned(v3->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((video::getRedSigned(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreenSigned(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlueSigned(v3->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((video::getRedSigned(v2->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreenSigned(v2->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlueSigned(v2->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - - leftR += leftStepR*leftx; - leftG += leftStepG*leftx; - leftB += leftStepB*leftx; - rightR += rightStepR*leftx; - rightG += rightStepG*leftx; - rightB += rightStepB*leftx; - - leftTx += leftTxStep*leftx; - leftTy += leftTyStep*leftx; - rightTx += rightTxStep*leftx; - rightTy += rightTyStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - // thanks to a correction by hybrid - // calculations delayed to correctly propagate to textures etc. - s32 tDiffLeft=0, tDiffRight=0; - if (leftxViewPortRect.LowerRightCorner.X) - tDiffLeft=ViewPortRect.LowerRightCorner.X-leftx; - - if (rightxViewPortRect.LowerRightCorner.X) - tDiffRight=ViewPortRect.LowerRightCorner.X-rightx; - - // draw the span - if (rightx + tDiffRight - leftx - tDiffLeft) - { - f32 tmpDiv = 1.0f / (f32)(rightx - leftx); - spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); - spanZValue = leftZValue+tDiffLeft*spanZStep; - - spanStepR = (s32)((rightR - leftR) * tmpDiv); - spanR = leftR+tDiffLeft*spanStepR; - spanStepG = (s32)((rightG - leftG) * tmpDiv); - spanG = leftG+tDiffLeft*spanStepG; - spanStepB = (s32)((rightB - leftB) * tmpDiv); - spanB = leftB+tDiffLeft*spanStepB; - - spanTxStep = (s32)((rightTx - leftTx) * tmpDiv); - spanTx = leftTx + tDiffLeft*spanTxStep; - spanTyStep = (s32)((rightTy - leftTy) * tmpDiv); - spanTy = leftTy+tDiffLeft*spanTyStep; - - hSpanBegin = targetSurface + leftx+tDiffLeft; - spanZTarget = zTarget + leftx+tDiffLeft; - hSpanEnd = targetSurface + rightx+tDiffRight; - - while (hSpanBegin < hSpanEnd) - { - if (spanZValue > *spanZTarget) - { - *spanZTarget = spanZValue; - u16 color = lockedTexture[((spanTy>>8)&textureYMask) * lockedTextureWidth + ((spanTx>>8)&textureXMask)]; - *hSpanBegin = video::RGB16(video::getRedSigned(color) * (spanR>>8) >>2, video::getGreenSigned(color) * (spanG>>8) >>2, video::getBlueSigned(color) * (spanB>>8) >>2); - } - - spanR += spanStepR; - spanG += spanStepG; - spanB += spanStepB; - - spanTx += spanTxStep; - spanTy += spanTyStep; - - spanZValue += spanZStep; - ++hSpanBegin; - ++spanZTarget; - } - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - - leftR += leftStepR; - leftG += leftStepG; - leftB += leftStepB; - rightR += rightStepR; - rightG += rightStepG; - rightB += rightStepB; - - leftTx += leftTxStep; - leftTy += leftTyStep; - rightTx += rightTxStep; - rightTy += rightTyStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - rightR = video::getRedSigned(v2->Color)<<8; - rightG = video::getGreenSigned(v2->Color)<<8; - rightB = video::getBlueSigned(v2->Color)<<8; - rightStepR = (s32)(((video::getRedSigned(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreenSigned(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlueSigned(v3->Color)<<8) - rightB) * tmpDiv); - - rightTx = v2->TCoords.X; - rightTy = v2->TCoords.Y; - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - leftR = video::getRedSigned(v2->Color)<<8; - leftG = video::getGreenSigned(v2->Color)<<8; - leftB = video::getBlueSigned(v2->Color)<<8; - leftStepR = (s32)(((video::getRedSigned(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreenSigned(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlueSigned(v3->Color)<<8) - leftB) * tmpDiv); - - leftTx = v2->TCoords.X; - leftTy = v2->TCoords.Y; - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - Texture->unlock(); -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererTextureGouraud(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRTextureGouraud(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - - -} // end namespace video -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "CTRTextureGouraud.h" +#include "os.h" + +#ifdef _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +//! constructor +CTRTextureGouraud::CTRTextureGouraud(IZBuffer* zbuffer) +: RenderTarget(0), BackFaceCullingEnabled(true), SurfaceHeight(0), SurfaceWidth(0), + Texture(0), ZBuffer(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureGouraud"); + #endif + + if (ZBuffer) + zbuffer->grab(); +} + + + +//! destructor +CTRTextureGouraud::~CTRTextureGouraud() +{ + if (RenderTarget) + RenderTarget->drop(); + + if (ZBuffer) + ZBuffer->drop(); + + if (Texture) + Texture->drop(); +} + + + +//! sets the Texture +void CTRTextureGouraud::setTexture(video::IImage* texture) +{ + if (Texture) + Texture->drop(); + + Texture = texture; + + if (Texture) + { + Texture->grab(); + lockedTextureWidth = Texture->getDimension().Width; + + textureXMask = lockedTextureWidth-1; + textureYMask = Texture->getDimension().Height-1; + } +} + + + + +//! en or disables the backface culling +void CTRTextureGouraud::setBackfaceCulling(bool enabled) +{ + BackFaceCullingEnabled = enabled; +} + + + +//! sets a render target +void CTRTextureGouraud::setRenderTarget(video::IImage* surface, const core::rect& viewPort) +{ + if (RenderTarget) + RenderTarget->drop(); + + RenderTarget = surface; + + if (RenderTarget) + { + SurfaceWidth = RenderTarget->getDimension().Width; + SurfaceHeight = RenderTarget->getDimension().Height; + RenderTarget->grab(); + ViewPortRect = viewPort; + } +} + + + +//! draws an indexed triangle list +void CTRTextureGouraud::drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) +{ + const S2DVertex *v1, *v2, *v3; + + f32 tmpDiv; // temporary division factor + f32 longest; // saves the longest span + s32 height; // saves height of triangle + u16* targetSurface; // target pointer where to plot pixels + s32 spanEnd; // saves end of spans + f32 leftdeltaxf; // amount of pixels to increase on left side of triangle + f32 rightdeltaxf; // amount of pixels to increase on right side of triangle + s32 leftx, rightx; // position where we are + f32 leftxf, rightxf; // same as above, but as f32 values + s32 span; // current span + u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels + s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values + s32 leftStepR, leftStepG, leftStepB, + rightStepR, rightStepG, rightStepB; // color steps + s32 spanR, spanG, spanB, spanStepR, spanStepG, spanStepB; // color interpolating values while drawing a span. + s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values + s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values + s32 spanTx, spanTy, spanTxStep, spanTyStep; // values of Texturecoords when drawing a span + core::rect TriangleRect; + + s32 leftZValue, rightZValue; + s32 leftZStep, rightZStep; + s32 spanZValue, spanZStep; // ZValues when drawing a span + TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; + + lockedSurface = (u16*)RenderTarget->lock(); + lockedZBuffer = ZBuffer->lock(); + lockedTexture = (u16*)Texture->lock(); + + for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - + ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); + + if (z < 0) + continue; + } + + //near plane clipping + + if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) + continue; + + // sort for width for inscreen clipping + + if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); + if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); + if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); + + if ((v1->Pos.X - v3->Pos.X) == 0) + continue; + + TriangleRect.UpperLeftCorner.X = v1->Pos.X; + TriangleRect.LowerRightCorner.X = v3->Pos.X; + + // sort for height for faster drawing. + + if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); + if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); + if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); + + TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; + TriangleRect.LowerRightCorner.Y = v3->Pos.Y; + + if (!TriangleRect.isRectCollided(ViewPortRect)) + continue; + + + // höhe des dreiecks berechnen + height = v3->Pos.Y - v1->Pos.Y; + if (!height) + continue; + + // calculate longest span + + longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); + + spanEnd = v2->Pos.Y; + span = v1->Pos.Y; + leftxf = (f32)v1->Pos.X; + rightxf = (f32)v1->Pos.X; + + leftZValue = v1->ZValue; + rightZValue = v1->ZValue; + + leftR = rightR = video::getRedSigned(v1->Color)<<8; + leftG = rightG = video::getGreenSigned(v1->Color)<<8; + leftB = rightB = video::getBlueSigned(v1->Color)<<8; + leftTx = rightTx = v1->TCoords.X; + leftTy = rightTy = v1->TCoords.Y; + + targetSurface = lockedSurface + span * SurfaceWidth; + zTarget = lockedZBuffer + span * SurfaceWidth; + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + rightStepR = (s32)(((video::getRedSigned(v2->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreenSigned(v2->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlueSigned(v2->Color)<<8) - rightB) * tmpDiv); + rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); + + tmpDiv = 1.0f / (f32)height; + leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + leftStepR = (s32)(((video::getRedSigned(v3->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreenSigned(v3->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlueSigned(v3->Color)<<8) - leftB) * tmpDiv); + leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (f32)height; + rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + rightStepR = (s32)(((video::getRedSigned(v3->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreenSigned(v3->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlueSigned(v3->Color)<<8) - rightB) * tmpDiv); + rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); + + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + leftStepR = (s32)(((video::getRedSigned(v2->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreenSigned(v2->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlueSigned(v2->Color)<<8) - leftB) * tmpDiv); + leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); + } + + + // do it twice, once for the first half of the triangle, + // end then for the second half. + + for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) + { + if (spanEnd > ViewPortRect.LowerRightCorner.Y) + spanEnd = ViewPortRect.LowerRightCorner.Y; + + // if the span <0, than we can skip these spans, + // and proceed to the next spans which are really on the screen. + if (span < ViewPortRect.UpperLeftCorner.Y) + { + // we'll use leftx as temp variable + if (spanEnd < ViewPortRect.UpperLeftCorner.Y) + { + leftx = spanEnd - span; + span = spanEnd; + } + else + { + leftx = ViewPortRect.UpperLeftCorner.Y - span; + span = ViewPortRect.UpperLeftCorner.Y; + } + + leftxf += leftdeltaxf*leftx; + rightxf += rightdeltaxf*leftx; + targetSurface += SurfaceWidth*leftx; + zTarget += SurfaceWidth*leftx; + leftZValue += leftZStep*leftx; + rightZValue += rightZStep*leftx; + + leftR += leftStepR*leftx; + leftG += leftStepG*leftx; + leftB += leftStepB*leftx; + rightR += rightStepR*leftx; + rightG += rightStepG*leftx; + rightB += rightStepB*leftx; + + leftTx += leftTxStep*leftx; + leftTy += leftTyStep*leftx; + rightTx += rightTxStep*leftx; + rightTy += rightTyStep*leftx; + } + + + // the main loop. Go through every span and draw it. + + while (span < spanEnd) + { + leftx = (s32)(leftxf); + rightx = (s32)(rightxf + 0.5f); + + // perform some clipping + // thanks to a correction by hybrid + // calculations delayed to correctly propagate to textures etc. + s32 tDiffLeft=0, tDiffRight=0; + if (leftxViewPortRect.LowerRightCorner.X) + tDiffLeft=ViewPortRect.LowerRightCorner.X-leftx; + + if (rightxViewPortRect.LowerRightCorner.X) + tDiffRight=ViewPortRect.LowerRightCorner.X-rightx; + + // draw the span + if (rightx + tDiffRight - leftx - tDiffLeft) + { + f32 tmpDiv = 1.0f / (f32)(rightx - leftx); + spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); + spanZValue = leftZValue+tDiffLeft*spanZStep; + + spanStepR = (s32)((rightR - leftR) * tmpDiv); + spanR = leftR+tDiffLeft*spanStepR; + spanStepG = (s32)((rightG - leftG) * tmpDiv); + spanG = leftG+tDiffLeft*spanStepG; + spanStepB = (s32)((rightB - leftB) * tmpDiv); + spanB = leftB+tDiffLeft*spanStepB; + + spanTxStep = (s32)((rightTx - leftTx) * tmpDiv); + spanTx = leftTx + tDiffLeft*spanTxStep; + spanTyStep = (s32)((rightTy - leftTy) * tmpDiv); + spanTy = leftTy+tDiffLeft*spanTyStep; + + hSpanBegin = targetSurface + leftx+tDiffLeft; + spanZTarget = zTarget + leftx+tDiffLeft; + hSpanEnd = targetSurface + rightx+tDiffRight; + + while (hSpanBegin < hSpanEnd) + { + if (spanZValue > *spanZTarget) + { + *spanZTarget = spanZValue; + u16 color = lockedTexture[((spanTy>>8)&textureYMask) * lockedTextureWidth + ((spanTx>>8)&textureXMask)]; + *hSpanBegin = video::RGB16(video::getRedSigned(color) * (spanR>>8) >>2, video::getGreenSigned(color) * (spanG>>8) >>2, video::getBlueSigned(color) * (spanB>>8) >>2); + } + + spanR += spanStepR; + spanG += spanStepG; + spanB += spanStepB; + + spanTx += spanTxStep; + spanTy += spanTyStep; + + spanZValue += spanZStep; + ++hSpanBegin; + ++spanZTarget; + } + } + + leftxf += leftdeltaxf; + rightxf += rightdeltaxf; + ++span; + targetSurface += SurfaceWidth; + zTarget += SurfaceWidth; + leftZValue += leftZStep; + rightZValue += rightZStep; + + leftR += leftStepR; + leftG += leftStepG; + leftB += leftStepB; + rightR += rightStepR; + rightG += rightStepG; + rightB += rightStepB; + + leftTx += leftTxStep; + leftTy += leftTyStep; + rightTx += rightTxStep; + rightTy += rightTyStep; + } + + if (triangleHalf>0) // break, we've gout only two halves + break; + + + // setup variables for second half of the triangle. + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + rightxf = (f32)v2->Pos.X; + + rightZValue = v2->ZValue; + rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + + rightR = video::getRedSigned(v2->Color)<<8; + rightG = video::getGreenSigned(v2->Color)<<8; + rightB = video::getBlueSigned(v2->Color)<<8; + rightStepR = (s32)(((video::getRedSigned(v3->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreenSigned(v3->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlueSigned(v3->Color)<<8) - rightB) * tmpDiv); + + rightTx = v2->TCoords.X; + rightTy = v2->TCoords.Y; + rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + leftxf = (f32)v2->Pos.X; + + leftZValue = v2->ZValue; + leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + + leftR = video::getRedSigned(v2->Color)<<8; + leftG = video::getGreenSigned(v2->Color)<<8; + leftB = video::getBlueSigned(v2->Color)<<8; + leftStepR = (s32)(((video::getRedSigned(v3->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreenSigned(v3->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlueSigned(v3->Color)<<8) - leftB) * tmpDiv); + + leftTx = v2->TCoords.X; + leftTy = v2->TCoords.Y; + leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); + } + + + spanEnd = v3->Pos.Y; + } + + } + + RenderTarget->unlock(); + ZBuffer->unlock(); + Texture->unlock(); +} + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +ITriangleRenderer* createTriangleRendererTextureGouraud(IZBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + return new CTRTextureGouraud(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_SOFTWARE_ +} + + +} // end namespace video +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CTRTextureGouraud.h b/src/dep/src/irrlicht/CTRTextureGouraud.h index 8a3f042..83f1654 100644 --- a/src/dep/src/irrlicht/CTRTextureGouraud.h +++ b/src/dep/src/irrlicht/CTRTextureGouraud.h @@ -1,68 +1,68 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_TRIANGLE_RENDERER_TEXTURE_GOURAUD_H_INCLUDED__ -#define __C_TRIANGLE_RENDERER_TEXTURE_GOURAUD_H_INCLUDED__ - -#include "ITriangleRenderer.h" -#include "rect.h" - -namespace irr -{ -namespace video -{ - //! CTRTextureGouraud class - class CTRTextureGouraud : public ITriangleRenderer - { - public: - - //! constructor - CTRTextureGouraud(IZBuffer* zbuffer); - - //! destructor - virtual ~CTRTextureGouraud(); - - //! sets a render target - virtual void setRenderTarget(video::IImage* surface, const core::rect& viewPort); - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount); - - //! en or disables the backface culling - virtual void setBackfaceCulling(bool enabled = true); - - //! sets the Texture - virtual void setTexture(video::IImage* texture); - - protected: - - //! vertauscht zwei vertizen - inline void swapVertices(const S2DVertex** v1, const S2DVertex** v2) - { - const S2DVertex* b = *v1; - *v1 = *v2; - *v2 = b; - } - - video::IImage* RenderTarget; - core::rect ViewPortRect; - - IZBuffer* ZBuffer; - - s32 SurfaceWidth; - s32 SurfaceHeight; - bool BackFaceCullingEnabled; - TZBufferType* lockedZBuffer; - u16* lockedSurface; - u16* lockedTexture; - s32 lockedTextureWidth; - s32 textureXMask, textureYMask; - video::IImage* Texture; - }; - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_TRIANGLE_RENDERER_TEXTURE_GOURAUD_H_INCLUDED__ +#define __C_TRIANGLE_RENDERER_TEXTURE_GOURAUD_H_INCLUDED__ + +#include "ITriangleRenderer.h" +#include "rect.h" + +namespace irr +{ +namespace video +{ + //! CTRTextureGouraud class + class CTRTextureGouraud : public ITriangleRenderer + { + public: + + //! constructor + CTRTextureGouraud(IZBuffer* zbuffer); + + //! destructor + virtual ~CTRTextureGouraud(); + + //! sets a render target + virtual void setRenderTarget(video::IImage* surface, const core::rect& viewPort); + + //! draws an indexed triangle list + virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount); + + //! en or disables the backface culling + virtual void setBackfaceCulling(bool enabled = true); + + //! sets the Texture + virtual void setTexture(video::IImage* texture); + + protected: + + //! vertauscht zwei vertizen + inline void swapVertices(const S2DVertex** v1, const S2DVertex** v2) + { + const S2DVertex* b = *v1; + *v1 = *v2; + *v2 = b; + } + + video::IImage* RenderTarget; + core::rect ViewPortRect; + + IZBuffer* ZBuffer; + + s32 SurfaceWidth; + s32 SurfaceHeight; + bool BackFaceCullingEnabled; + TZBufferType* lockedZBuffer; + u16* lockedSurface; + u16* lockedTexture; + s32 lockedTextureWidth; + s32 textureXMask, textureYMask; + video::IImage* Texture; + }; + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CTRTextureGouraud2.cpp b/src/dep/src/irrlicht/CTRTextureGouraud2.cpp index e447068..29604a8 100644 --- a/src/dep/src/irrlicht/CTRTextureGouraud2.cpp +++ b/src/dep/src/irrlicht/CTRTextureGouraud2.cpp @@ -1,703 +1,703 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - -namespace irr -{ - -namespace video -{ - -class CTRTextureGouraud2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureGouraud2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRTextureGouraud2::CTRTextureGouraud2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraud2"); - #endif -} - - - -/*! -*/ -void CTRTextureGouraud2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef USE_ZBUFFER - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - - tFixPoint tx0; - tFixPoint ty0; - -#ifdef IPOL_C0 - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; -#endif - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; -#endif - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - { -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - tx0 = f32_to_fixPoint ( line.t0[0].x, inversew); - ty0 = f32_to_fixPoint ( line.t0[0].y, inversew); - -#ifdef IPOL_C0 - r1 = f32_to_fixPoint ( line.c[0].y ,inversew ); - g1 = f32_to_fixPoint ( line.c[0].z ,inversew ); - b1 = f32_to_fixPoint ( line.c[0].w ,inversew ); -#endif - -#else - tx0 = f32_to_fixPoint ( line.t0[0].x ); - ty0 = f32_to_fixPoint ( line.t0[0].y ); -#ifdef IPOL_C0 - getTexel_plain ( r1, g1, b1, line.c[0] ); -#endif -#endif - -#ifdef IPOL_C0 - getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); - - dst[i] = fix_to_color ( imulFix ( r0, r1 ), - imulFix ( g0, g1 ), - imulFix ( b0, b1 ) - ); -#else - -#ifdef BURNINGVIDEO_RENDERER_FAST - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - dst[i] = getTexel_plain ( &IT[0], d + tx0, d + ty0 ); -#else - getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); - dst[i] = fix_to_color ( r0, g0, b0 ); -#endif - -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1; -#endif - } - -} - -void CTRTextureGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureGouraud2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureGouraud2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +#define WRITE_W + +#define IPOL_C0 +#define IPOL_T0 +//#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + + +namespace irr +{ + +namespace video +{ + +class CTRTextureGouraud2 : public IBurningShader +{ +public: + + //! constructor + CTRTextureGouraud2(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + +private: + void scanline_bilinear (); + sScanConvertData scan; + sScanLineData line; + +}; + +//! constructor +CTRTextureGouraud2::CTRTextureGouraud2(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureGouraud2"); + #endif +} + + + +/*! +*/ +void CTRTextureGouraud2::scanline_bilinear () +{ + tVideoSample *dst; + +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef USE_ZBUFFER + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + +#ifdef INVERSE_W + f32 inversew; +#endif + + tFixPoint tx0; + tFixPoint ty0; + +#ifdef IPOL_C0 + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; +#endif + +#ifdef BURNINGVIDEO_RENDERER_FAST + u32 dIndex = ( line.y & 3 ) << 2; +#endif + + for ( s32 i = 0; i <= dx; ++i ) + { +#ifdef CMP_Z + if ( line.z[0] < z[i] ) +#endif +#ifdef CMP_W + if ( line.w[0] >= z[i] ) +#endif + { +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + + +#ifdef INVERSE_W + inversew = fix_inverse32 ( line.w[0] ); + tx0 = f32_to_fixPoint ( line.t0[0].x, inversew); + ty0 = f32_to_fixPoint ( line.t0[0].y, inversew); + +#ifdef IPOL_C0 + r1 = f32_to_fixPoint ( line.c[0].y ,inversew ); + g1 = f32_to_fixPoint ( line.c[0].z ,inversew ); + b1 = f32_to_fixPoint ( line.c[0].w ,inversew ); +#endif + +#else + tx0 = f32_to_fixPoint ( line.t0[0].x ); + ty0 = f32_to_fixPoint ( line.t0[0].y ); +#ifdef IPOL_C0 + getTexel_plain ( r1, g1, b1, line.c[0] ); +#endif +#endif + +#ifdef IPOL_C0 + getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); + + dst[i] = fix_to_color ( imulFix ( r0, r1 ), + imulFix ( g0, g1 ), + imulFix ( b0, b1 ) + ); +#else + +#ifdef BURNINGVIDEO_RENDERER_FAST + const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; + dst[i] = getTexel_plain ( &IT[0], d + tx0, d + ty0 ); +#else + getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); + dst[i] = fix_to_color ( r0, g0, b0 ); +#endif + +#endif + + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1; +#endif + } + +} + +void CTRTextureGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + // rasterize upper sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[1] ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[2] ) + { + // advance to middle point + if( (f32) 0.0 != scan.invDeltaY[1] ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear ( ); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +IBurningShader* createTriangleRendererTextureGouraud2(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRTextureGouraud2(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + + diff --git a/src/dep/src/irrlicht/CTRTextureGouraudAdd.cpp b/src/dep/src/irrlicht/CTRTextureGouraudAdd.cpp index 904f749..4aec47e 100644 --- a/src/dep/src/irrlicht/CTRTextureGouraudAdd.cpp +++ b/src/dep/src/irrlicht/CTRTextureGouraudAdd.cpp @@ -1,421 +1,421 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "CTRTextureGouraud.h" -#include "os.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRTextureGouraudAdd : public CTRTextureGouraud -{ -public: - - //! constructor - CTRTextureGouraudAdd(IZBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount); - -protected: - -}; - -//! constructor -CTRTextureGouraudAdd::CTRTextureGouraudAdd(IZBuffer* zbuffer) -: CTRTextureGouraud(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraudAdd"); - #endif -} - - -//! draws an indexed triangle list -void CTRTextureGouraudAdd::drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) -{ - const S2DVertex *v1, *v2, *v3; - - u16 color; - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels - s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values - s32 leftStepR, leftStepG, leftStepB, - rightStepR, rightStepG, rightStepB; // color steps - s32 spanR, spanG, spanB, spanStepR, spanStepG, spanStepB; // color interpolating values while drawing a span. - s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values - s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values - s32 spanTx, spanTy, spanTxStep, spanTyStep; // values of Texturecoords when drawing a span - core::rect TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - s32 spanZValue, spanZStep; // ZValues when drawing a span - TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - lockedTexture = (u16*)Texture->lock(); - - for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - - // höhe des dreiecks berechnen - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - leftR = rightR = video::getRed(v1->Color)<<8; - leftG = rightG = video::getGreen(v1->Color)<<8; - leftB = rightB = video::getBlue(v1->Color)<<8; - leftTx = rightTx = v1->TCoords.X; - leftTy = rightTy = v1->TCoords.Y; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((video::getRed(v2->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreen(v2->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlue(v2->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((video::getRed(v2->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreen(v2->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlue(v2->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - - leftR += leftStepR*leftx; - leftG += leftStepG*leftx; - leftB += leftStepB*leftx; - rightR += rightStepR*leftx; - rightG += rightStepG*leftx; - rightB += rightStepB*leftx; - - leftTx += leftTxStep*leftx; - leftTy += leftTyStep*leftx; - rightTx += rightTxStep*leftx; - rightTy += rightTyStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - // thanks to a correction by hybrid - // calculations delayed to correctly propagate to textures etc. - s32 tDiffLeft=0, tDiffRight=0; - if (leftxViewPortRect.LowerRightCorner.X) - tDiffLeft=ViewPortRect.LowerRightCorner.X-leftx; - - if (rightxViewPortRect.LowerRightCorner.X) - tDiffRight=ViewPortRect.LowerRightCorner.X-rightx; - - // draw the span - if (rightx + tDiffRight - leftx - tDiffLeft) - { - f32 tmpDiv = 1.0f / (f32)(rightx - leftx); - spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); - spanZValue = leftZValue+tDiffLeft*spanZStep; - - spanStepR = (s32)((rightR - leftR) * tmpDiv); - spanR = leftR+tDiffLeft*spanStepR; - spanStepG = (s32)((rightG - leftG) * tmpDiv); - spanG = leftG+tDiffLeft*spanStepG; - spanStepB = (s32)((rightB - leftB) * tmpDiv); - spanB = leftB+tDiffLeft*spanStepB; - - spanTxStep = (s32)((rightTx - leftTx) * tmpDiv); - spanTx = leftTx + tDiffLeft*spanTxStep; - spanTyStep = (s32)((rightTy - leftTy) * tmpDiv); - spanTy = leftTy+tDiffLeft*spanTyStep; - - hSpanBegin = targetSurface + leftx+tDiffLeft; - spanZTarget = zTarget + leftx+tDiffLeft; - hSpanEnd = targetSurface + rightx+tDiffRight; - - while (hSpanBegin < hSpanEnd) - { - if (spanZValue > *spanZTarget) - { - //*spanZTarget = spanZValue; - color = lockedTexture[((spanTy>>8)&textureYMask) * lockedTextureWidth + ((spanTx>>8)&textureXMask)]; - - int basis = *hSpanBegin; - int r = (video::getRed(basis)<<3) + (video::getRed(color)<<3); - if (r > 255) r = 255; - int g = (video::getGreen(basis)<<3) + (video::getGreen(color)<<3); - if (g > 255) g = 255; - int b = (video::getBlue(basis)<<3) + (video::getBlue(color)<<3); - if (b > 255) b = 255; - - *hSpanBegin = video::RGB16(r, g, b); - } - - spanR += spanStepR; - spanG += spanStepG; - spanB += spanStepB; - - spanTx += spanTxStep; - spanTy += spanTyStep; - - spanZValue += spanZStep; - ++hSpanBegin; - ++spanZTarget; - } - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - - leftR += leftStepR; - leftG += leftStepG; - leftB += leftStepB; - rightR += rightStepR; - rightG += rightStepG; - rightB += rightStepB; - - leftTx += leftTxStep; - leftTy += leftTyStep; - rightTx += rightTxStep; - rightTy += rightTyStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - rightR = video::getRed(v2->Color)<<8; - rightG = video::getGreen(v2->Color)<<8; - rightB = video::getBlue(v2->Color)<<8; - rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - - rightTx = v2->TCoords.X; - rightTy = v2->TCoords.Y; - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - leftR = video::getRed(v2->Color)<<8; - leftG = video::getGreen(v2->Color)<<8; - leftB = video::getBlue(v2->Color)<<8; - leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - - leftTx = v2->TCoords.X; - leftTy = v2->TCoords.Y; - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - Texture->unlock(); -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -ITriangleRenderer* createTriangleRendererTextureGouraudAdd(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRTextureGouraudAdd(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "CTRTextureGouraud.h" +#include "os.h" + +#ifdef _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +class CTRTextureGouraudAdd : public CTRTextureGouraud +{ +public: + + //! constructor + CTRTextureGouraudAdd(IZBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount); + +protected: + +}; + +//! constructor +CTRTextureGouraudAdd::CTRTextureGouraudAdd(IZBuffer* zbuffer) +: CTRTextureGouraud(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureGouraudAdd"); + #endif +} + + +//! draws an indexed triangle list +void CTRTextureGouraudAdd::drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) +{ + const S2DVertex *v1, *v2, *v3; + + u16 color; + f32 tmpDiv; // temporary division factor + f32 longest; // saves the longest span + s32 height; // saves height of triangle + u16* targetSurface; // target pointer where to plot pixels + s32 spanEnd; // saves end of spans + f32 leftdeltaxf; // amount of pixels to increase on left side of triangle + f32 rightdeltaxf; // amount of pixels to increase on right side of triangle + s32 leftx, rightx; // position where we are + f32 leftxf, rightxf; // same as above, but as f32 values + s32 span; // current span + u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels + s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values + s32 leftStepR, leftStepG, leftStepB, + rightStepR, rightStepG, rightStepB; // color steps + s32 spanR, spanG, spanB, spanStepR, spanStepG, spanStepB; // color interpolating values while drawing a span. + s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values + s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values + s32 spanTx, spanTy, spanTxStep, spanTyStep; // values of Texturecoords when drawing a span + core::rect TriangleRect; + + s32 leftZValue, rightZValue; + s32 leftZStep, rightZStep; + s32 spanZValue, spanZStep; // ZValues when drawing a span + TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; + + lockedSurface = (u16*)RenderTarget->lock(); + lockedZBuffer = ZBuffer->lock(); + lockedTexture = (u16*)Texture->lock(); + + for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - + ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); + + if (z < 0) + continue; + } + + //near plane clipping + + if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) + continue; + + // sort for width for inscreen clipping + + if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); + if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); + if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); + + if ((v1->Pos.X - v3->Pos.X) == 0) + continue; + + TriangleRect.UpperLeftCorner.X = v1->Pos.X; + TriangleRect.LowerRightCorner.X = v3->Pos.X; + + // sort for height for faster drawing. + + if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); + if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); + if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); + + TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; + TriangleRect.LowerRightCorner.Y = v3->Pos.Y; + + if (!TriangleRect.isRectCollided(ViewPortRect)) + continue; + + + // höhe des dreiecks berechnen + height = v3->Pos.Y - v1->Pos.Y; + if (!height) + continue; + + // calculate longest span + + longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); + + spanEnd = v2->Pos.Y; + span = v1->Pos.Y; + leftxf = (f32)v1->Pos.X; + rightxf = (f32)v1->Pos.X; + + leftZValue = v1->ZValue; + rightZValue = v1->ZValue; + + leftR = rightR = video::getRed(v1->Color)<<8; + leftG = rightG = video::getGreen(v1->Color)<<8; + leftB = rightB = video::getBlue(v1->Color)<<8; + leftTx = rightTx = v1->TCoords.X; + leftTy = rightTy = v1->TCoords.Y; + + targetSurface = lockedSurface + span * SurfaceWidth; + zTarget = lockedZBuffer + span * SurfaceWidth; + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + rightStepR = (s32)(((video::getRed(v2->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreen(v2->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlue(v2->Color)<<8) - rightB) * tmpDiv); + rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); + + tmpDiv = 1.0f / (f32)height; + leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); + leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (f32)height; + rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); + rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); + + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + leftStepR = (s32)(((video::getRed(v2->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreen(v2->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlue(v2->Color)<<8) - leftB) * tmpDiv); + leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); + } + + + // do it twice, once for the first half of the triangle, + // end then for the second half. + + for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) + { + if (spanEnd > ViewPortRect.LowerRightCorner.Y) + spanEnd = ViewPortRect.LowerRightCorner.Y; + + // if the span <0, than we can skip these spans, + // and proceed to the next spans which are really on the screen. + if (span < ViewPortRect.UpperLeftCorner.Y) + { + // we'll use leftx as temp variable + if (spanEnd < ViewPortRect.UpperLeftCorner.Y) + { + leftx = spanEnd - span; + span = spanEnd; + } + else + { + leftx = ViewPortRect.UpperLeftCorner.Y - span; + span = ViewPortRect.UpperLeftCorner.Y; + } + + leftxf += leftdeltaxf*leftx; + rightxf += rightdeltaxf*leftx; + targetSurface += SurfaceWidth*leftx; + zTarget += SurfaceWidth*leftx; + leftZValue += leftZStep*leftx; + rightZValue += rightZStep*leftx; + + leftR += leftStepR*leftx; + leftG += leftStepG*leftx; + leftB += leftStepB*leftx; + rightR += rightStepR*leftx; + rightG += rightStepG*leftx; + rightB += rightStepB*leftx; + + leftTx += leftTxStep*leftx; + leftTy += leftTyStep*leftx; + rightTx += rightTxStep*leftx; + rightTy += rightTyStep*leftx; + } + + + // the main loop. Go through every span and draw it. + + while (span < spanEnd) + { + leftx = (s32)(leftxf); + rightx = (s32)(rightxf + 0.5f); + + // perform some clipping + // thanks to a correction by hybrid + // calculations delayed to correctly propagate to textures etc. + s32 tDiffLeft=0, tDiffRight=0; + if (leftxViewPortRect.LowerRightCorner.X) + tDiffLeft=ViewPortRect.LowerRightCorner.X-leftx; + + if (rightxViewPortRect.LowerRightCorner.X) + tDiffRight=ViewPortRect.LowerRightCorner.X-rightx; + + // draw the span + if (rightx + tDiffRight - leftx - tDiffLeft) + { + f32 tmpDiv = 1.0f / (f32)(rightx - leftx); + spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); + spanZValue = leftZValue+tDiffLeft*spanZStep; + + spanStepR = (s32)((rightR - leftR) * tmpDiv); + spanR = leftR+tDiffLeft*spanStepR; + spanStepG = (s32)((rightG - leftG) * tmpDiv); + spanG = leftG+tDiffLeft*spanStepG; + spanStepB = (s32)((rightB - leftB) * tmpDiv); + spanB = leftB+tDiffLeft*spanStepB; + + spanTxStep = (s32)((rightTx - leftTx) * tmpDiv); + spanTx = leftTx + tDiffLeft*spanTxStep; + spanTyStep = (s32)((rightTy - leftTy) * tmpDiv); + spanTy = leftTy+tDiffLeft*spanTyStep; + + hSpanBegin = targetSurface + leftx+tDiffLeft; + spanZTarget = zTarget + leftx+tDiffLeft; + hSpanEnd = targetSurface + rightx+tDiffRight; + + while (hSpanBegin < hSpanEnd) + { + if (spanZValue > *spanZTarget) + { + //*spanZTarget = spanZValue; + color = lockedTexture[((spanTy>>8)&textureYMask) * lockedTextureWidth + ((spanTx>>8)&textureXMask)]; + + int basis = *hSpanBegin; + int r = (video::getRed(basis)<<3) + (video::getRed(color)<<3); + if (r > 255) r = 255; + int g = (video::getGreen(basis)<<3) + (video::getGreen(color)<<3); + if (g > 255) g = 255; + int b = (video::getBlue(basis)<<3) + (video::getBlue(color)<<3); + if (b > 255) b = 255; + + *hSpanBegin = video::RGB16(r, g, b); + } + + spanR += spanStepR; + spanG += spanStepG; + spanB += spanStepB; + + spanTx += spanTxStep; + spanTy += spanTyStep; + + spanZValue += spanZStep; + ++hSpanBegin; + ++spanZTarget; + } + } + + leftxf += leftdeltaxf; + rightxf += rightdeltaxf; + ++span; + targetSurface += SurfaceWidth; + zTarget += SurfaceWidth; + leftZValue += leftZStep; + rightZValue += rightZStep; + + leftR += leftStepR; + leftG += leftStepG; + leftB += leftStepB; + rightR += rightStepR; + rightG += rightStepG; + rightB += rightStepB; + + leftTx += leftTxStep; + leftTy += leftTyStep; + rightTx += rightTxStep; + rightTy += rightTyStep; + } + + if (triangleHalf>0) // break, we've gout only two halves + break; + + + // setup variables for second half of the triangle. + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + rightxf = (f32)v2->Pos.X; + + rightZValue = v2->ZValue; + rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + + rightR = video::getRed(v2->Color)<<8; + rightG = video::getGreen(v2->Color)<<8; + rightB = video::getBlue(v2->Color)<<8; + rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); + + rightTx = v2->TCoords.X; + rightTy = v2->TCoords.Y; + rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + leftxf = (f32)v2->Pos.X; + + leftZValue = v2->ZValue; + leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + + leftR = video::getRed(v2->Color)<<8; + leftG = video::getGreen(v2->Color)<<8; + leftB = video::getBlue(v2->Color)<<8; + leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); + + leftTx = v2->TCoords.X; + leftTy = v2->TCoords.Y; + leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); + } + + + spanEnd = v3->Pos.Y; + } + + } + + RenderTarget->unlock(); + ZBuffer->unlock(); + Texture->unlock(); +} + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +ITriangleRenderer* createTriangleRendererTextureGouraudAdd(IZBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + return new CTRTextureGouraudAdd(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_SOFTWARE_ +} + +} // end namespace video +} // end namespace irr + + + diff --git a/src/dep/src/irrlicht/CTRTextureGouraudAdd2.cpp b/src/dep/src/irrlicht/CTRTextureGouraudAdd2.cpp index 57a1021..f5043ac 100644 --- a/src/dep/src/irrlicht/CTRTextureGouraudAdd2.cpp +++ b/src/dep/src/irrlicht/CTRTextureGouraudAdd2.cpp @@ -1,711 +1,711 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - - -namespace irr -{ - -namespace video -{ - -class CTRTextureGouraudAdd2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureGouraudAdd2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanLineData line; - -}; - -//! constructor -CTRTextureGouraudAdd2::CTRTextureGouraudAdd2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraudAdd2"); - #endif -} - - - -/*! -*/ -void CTRTextureGouraudAdd2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef USE_ZBUFFER - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; - -#else - tFixPoint tx0; - tFixPoint ty0; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; -#endif - - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - -#ifdef BURNINGVIDEO_RENDERER_FAST - - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - - -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - - dst[i] = PixelAdd32 ( - dst[i], - getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x,inversew), - d + f32_to_fixPoint ( line.t0[0].y,inversew) ) - ); -#else - dst[i] = PixelAdd32 ( - dst[i], - getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x), - d + f32_to_fixPoint ( line.t0[0].y) ) - ); - -#endif -#else - -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - - tx0 = f32_to_fixPoint ( line.t0[0].x,inversew); - ty0 = f32_to_fixPoint ( line.t0[0].y,inversew); -#else - tx0 = f32_to_fixPoint ( line.t0[0].x ); - ty0 = f32_to_fixPoint ( line.t0[0].y ); -#endif - getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); - - color_to_fix ( r1, g1, b1, dst[i] ); - - r2 = clampfix_maxcolor ( r1 + r0 ); - g2 = clampfix_maxcolor ( g1 + g0 ); - b2 = clampfix_maxcolor ( b1 + b0 ); - - dst[i] = fix_to_color ( r2, g2, b2 ); -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1; -#endif - } - -} - -void CTRTextureGouraudAdd2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - sScanConvertData scan; - - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - // rasterize upper sub-triangle - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTRTextureGouraudAdd2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureGouraudAdd2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +#define WRITE_W + +//#define IPOL_C0 +#define IPOL_T0 +//#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + + + +namespace irr +{ + +namespace video +{ + +class CTRTextureGouraudAdd2 : public IBurningShader +{ +public: + + //! constructor + CTRTextureGouraudAdd2(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + +private: + void scanline_bilinear (); + sScanLineData line; + +}; + +//! constructor +CTRTextureGouraudAdd2::CTRTextureGouraudAdd2(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureGouraudAdd2"); + #endif +} + + + +/*! +*/ +void CTRTextureGouraudAdd2::scanline_bilinear () +{ + tVideoSample *dst; + +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef USE_ZBUFFER + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + +#ifdef INVERSE_W + f32 inversew; +#endif + + +#ifdef BURNINGVIDEO_RENDERER_FAST + u32 dIndex = ( line.y & 3 ) << 2; + +#else + tFixPoint tx0; + tFixPoint ty0; + + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; + tFixPoint r2, g2, b2; +#endif + + + for ( s32 i = 0; i <= dx; ++i ) + { +#ifdef CMP_Z + if ( line.z[0] < z[i] ) +#endif +#ifdef CMP_W + if ( line.w[0] >= z[i] ) +#endif + + { + +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + + +#ifdef BURNINGVIDEO_RENDERER_FAST + + const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; + + +#ifdef INVERSE_W + inversew = fix_inverse32 ( line.w[0] ); + + dst[i] = PixelAdd32 ( + dst[i], + getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x,inversew), + d + f32_to_fixPoint ( line.t0[0].y,inversew) ) + ); +#else + dst[i] = PixelAdd32 ( + dst[i], + getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x), + d + f32_to_fixPoint ( line.t0[0].y) ) + ); + +#endif +#else + +#ifdef INVERSE_W + inversew = fix_inverse32 ( line.w[0] ); + + tx0 = f32_to_fixPoint ( line.t0[0].x,inversew); + ty0 = f32_to_fixPoint ( line.t0[0].y,inversew); +#else + tx0 = f32_to_fixPoint ( line.t0[0].x ); + ty0 = f32_to_fixPoint ( line.t0[0].y ); +#endif + getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); + + color_to_fix ( r1, g1, b1, dst[i] ); + + r2 = clampfix_maxcolor ( r1 + r0 ); + g2 = clampfix_maxcolor ( g1 + g0 ); + b2 = clampfix_maxcolor ( b1 + b0 ); + + dst[i] = fix_to_color ( r2, g2, b2 ); +#endif + + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1; +#endif + } + +} + +void CTRTextureGouraudAdd2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + sScanConvertData scan; + + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + // rasterize upper sub-triangle + if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[2] ) + { + // advance to middle point + if( (f32) 0.0 != scan.invDeltaY[1] ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +IBurningShader* createTRTextureGouraudAdd2(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRTextureGouraudAdd2(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + + diff --git a/src/dep/src/irrlicht/CTRTextureGouraudAddNoZ2.cpp b/src/dep/src/irrlicht/CTRTextureGouraudAddNoZ2.cpp index a187a4f..4f1282e 100644 --- a/src/dep/src/irrlicht/CTRTextureGouraudAddNoZ2.cpp +++ b/src/dep/src/irrlicht/CTRTextureGouraudAddNoZ2.cpp @@ -1,672 +1,672 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -//#define USE_ZBUFFER -#define IPOL_W -//#define CMP_W -//#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - -namespace irr -{ - -namespace video -{ - -class CTRTextureGouraudAddNoZ2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRTextureGouraudAddNoZ2::CTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraudAddNoZ2"); - #endif -} - - - -/*! -*/ -void CTRTextureGouraudAddNoZ2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef IPOL_Z - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef IPOL_Z - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - -#ifdef IPOL_W - f32 inversew; -#endif - - tFixPoint tx0; - tFixPoint ty0; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; - - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif - { -#ifdef IPOL_W - inversew = fix_inverse32 ( line.w[0] ); - - tx0 = f32_to_fixPoint ( line.t0[0].x,inversew); - ty0 = f32_to_fixPoint ( line.t0[0].y,inversew); -#else - tx0 = f32_to_fixPoint ( line.t0[0].x ); - ty0 = f32_to_fixPoint ( line.t0[0].y ); -#endif - - getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); - - color_to_fix ( r1, g1, b1, dst[i] ); - - r2 = clampfix_maxcolor ( r1 + r0 ); - g2 = clampfix_maxcolor ( g1 + g0 ); - b2 = clampfix_maxcolor ( b1 + b0 ); - - - dst[i] = fix_to_color ( r2, g2, b2 ); - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1; -#endif - } - -} - -void CTRTextureGouraudAddNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef IPOL_Z - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef IPOL_Z - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureGouraudAddNoZ2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +//#define USE_ZBUFFER +#define IPOL_W +//#define CMP_W +//#define WRITE_W + +//#define IPOL_C0 +#define IPOL_T0 +//#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + + +namespace irr +{ + +namespace video +{ + +class CTRTextureGouraudAddNoZ2 : public IBurningShader +{ +public: + + //! constructor + CTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + +private: + void scanline_bilinear (); + sScanConvertData scan; + sScanLineData line; + +}; + +//! constructor +CTRTextureGouraudAddNoZ2::CTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureGouraudAddNoZ2"); + #endif +} + + + +/*! +*/ +void CTRTextureGouraudAddNoZ2::scanline_bilinear () +{ + tVideoSample *dst; + +#ifdef IPOL_Z + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef IPOL_Z + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + +#ifdef IPOL_W + f32 inversew; +#endif + + tFixPoint tx0; + tFixPoint ty0; + + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; + tFixPoint r2, g2, b2; + + + for ( s32 i = 0; i <= dx; ++i ) + { +#ifdef CMP_Z + if ( line.z[0] < z[i] ) +#endif + { +#ifdef IPOL_W + inversew = fix_inverse32 ( line.w[0] ); + + tx0 = f32_to_fixPoint ( line.t0[0].x,inversew); + ty0 = f32_to_fixPoint ( line.t0[0].y,inversew); +#else + tx0 = f32_to_fixPoint ( line.t0[0].x ); + ty0 = f32_to_fixPoint ( line.t0[0].y ); +#endif + + getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); + + color_to_fix ( r1, g1, b1, dst[i] ); + + r2 = clampfix_maxcolor ( r1 + r0 ); + g2 = clampfix_maxcolor ( g1 + g0 ); + b2 = clampfix_maxcolor ( b1 + b0 ); + + + dst[i] = fix_to_color ( r2, g2, b2 ); + +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1; +#endif + } + +} + +void CTRTextureGouraudAddNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef IPOL_Z + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + // rasterize upper sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[1] ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[2] ) + { + // advance to middle point + if( (f32) 0.0 != scan.invDeltaY[1] ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear ( ); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef IPOL_Z + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +IBurningShader* createTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRTextureGouraudAddNoZ2(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CTRTextureGouraudAlpha.cpp b/src/dep/src/irrlicht/CTRTextureGouraudAlpha.cpp index 58da23b..ab271a6 100644 --- a/src/dep/src/irrlicht/CTRTextureGouraudAlpha.cpp +++ b/src/dep/src/irrlicht/CTRTextureGouraudAlpha.cpp @@ -1,734 +1,734 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - - -namespace irr -{ - -namespace video -{ - -class CTRTextureGouraudAlpha2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureGouraudAlpha2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - virtual void setParam ( u32 index, f32 value); - - -private: - void scanline_bilinear (); - - sScanConvertData scan; - sScanLineData line; - - u32 AlphaRef; -}; - -//! constructor -CTRTextureGouraudAlpha2::CTRTextureGouraudAlpha2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraudAlpha2"); - #endif - - AlphaRef = 0; -} - - -/*! -*/ -void CTRTextureGouraudAlpha2::setParam ( u32 index, f32 value) -{ -#ifdef BURNINGVIDEO_RENDERER_FAST - AlphaRef = core::floor32 ( value * 256.f ); -#else - AlphaRef = u32_to_fixPoint ( core::floor32 ( value * 256.f ) ); -#endif -} - -/*! -*/ -void CTRTextureGouraudAlpha2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef USE_ZBUFFER - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; - -#else - tFixPointu a0; - tFixPointu r0, g0, b0; -#endif - - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - -#ifdef BURNINGVIDEO_RENDERER_FAST - - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - -#ifdef INVERSE_W - - inversew = fix_inverse32 ( line.w[0] ); - - u32 argb = getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x,inversew), - d + f32_to_fixPoint ( line.t0[0].y,inversew) - ); - -#else - - u32 argb = getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x), - d + f32_to_fixPoint ( line.t0[0].y) - ); - -#endif - - const u32 alpha = ( argb >> 24 ); - if ( alpha >= AlphaRef ) - { -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - dst[i] = PixelBlend32 ( dst[i], argb, alpha ); - } - - -#else - - inversew = fix_inverse32 ( line.w[0] ); - - getSample_texture ( a0, r0, g0, b0, - &IT[0], - f32_to_fixPoint ( line.t0[0].x,inversew), - f32_to_fixPoint ( line.t0[0].y,inversew) - ); - - if ( a0 >= AlphaRef ) - { -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - dst[i] = PixelBlend32 ( dst[i], - fix_to_color ( r0,g0, b0 ), - fixPointu_to_u32 ( a0 ) - ); - } -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1; -#endif - } - -} - -void CTRTextureGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - - -//! creates a flat triangle renderer -IBurningShader* createTRTextureGouraudAlpha(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureGouraudAlpha2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +#define WRITE_W + +//#define IPOL_C0 +#define IPOL_T0 +//#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + + + +namespace irr +{ + +namespace video +{ + +class CTRTextureGouraudAlpha2 : public IBurningShader +{ +public: + + //! constructor + CTRTextureGouraudAlpha2(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + virtual void setParam ( u32 index, f32 value); + + +private: + void scanline_bilinear (); + + sScanConvertData scan; + sScanLineData line; + + u32 AlphaRef; +}; + +//! constructor +CTRTextureGouraudAlpha2::CTRTextureGouraudAlpha2(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureGouraudAlpha2"); + #endif + + AlphaRef = 0; +} + + +/*! +*/ +void CTRTextureGouraudAlpha2::setParam ( u32 index, f32 value) +{ +#ifdef BURNINGVIDEO_RENDERER_FAST + AlphaRef = core::floor32 ( value * 256.f ); +#else + AlphaRef = u32_to_fixPoint ( core::floor32 ( value * 256.f ) ); +#endif +} + +/*! +*/ +void CTRTextureGouraudAlpha2::scanline_bilinear () +{ + tVideoSample *dst; + +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef USE_ZBUFFER + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + +#ifdef INVERSE_W + f32 inversew; +#endif + +#ifdef BURNINGVIDEO_RENDERER_FAST + u32 dIndex = ( line.y & 3 ) << 2; + +#else + tFixPointu a0; + tFixPointu r0, g0, b0; +#endif + + + for ( s32 i = 0; i <= dx; ++i ) + { +#ifdef CMP_Z + if ( line.z[0] < z[i] ) +#endif +#ifdef CMP_W + if ( line.w[0] >= z[i] ) +#endif + + { + +#ifdef BURNINGVIDEO_RENDERER_FAST + + const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; + +#ifdef INVERSE_W + + inversew = fix_inverse32 ( line.w[0] ); + + u32 argb = getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x,inversew), + d + f32_to_fixPoint ( line.t0[0].y,inversew) + ); + +#else + + u32 argb = getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x), + d + f32_to_fixPoint ( line.t0[0].y) + ); + +#endif + + const u32 alpha = ( argb >> 24 ); + if ( alpha >= AlphaRef ) + { +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + + dst[i] = PixelBlend32 ( dst[i], argb, alpha ); + } + + +#else + + inversew = fix_inverse32 ( line.w[0] ); + + getSample_texture ( a0, r0, g0, b0, + &IT[0], + f32_to_fixPoint ( line.t0[0].x,inversew), + f32_to_fixPoint ( line.t0[0].y,inversew) + ); + + if ( a0 >= AlphaRef ) + { +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + + dst[i] = PixelBlend32 ( dst[i], + fix_to_color ( r0,g0, b0 ), + fixPointu_to_u32 ( a0 ) + ); + } +#endif + + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1; +#endif + } + +} + +void CTRTextureGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + // rasterize upper sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[1] ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear ( ); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[2] ) + { + // advance to middle point + if( (f32) 0.0 != scan.invDeltaY[1] ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear ( ); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + + +//! creates a flat triangle renderer +IBurningShader* createTRTextureGouraudAlpha(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRTextureGouraudAlpha2(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CTRTextureGouraudAlphaNoZ.cpp b/src/dep/src/irrlicht/CTRTextureGouraudAlphaNoZ.cpp index 9ca6b32..0daee10 100644 --- a/src/dep/src/irrlicht/CTRTextureGouraudAlphaNoZ.cpp +++ b/src/dep/src/irrlicht/CTRTextureGouraudAlphaNoZ.cpp @@ -1,732 +1,732 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -//#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - - -namespace irr -{ - -namespace video -{ - -class CTRTextureGouraudAlphaNoZ : public IBurningShader -{ -public: - - //! constructor - CTRTextureGouraudAlphaNoZ(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - virtual void setParam ( u32 index, f32 value); - - -private: - void scanline_bilinear (); - - sScanConvertData scan; - sScanLineData line; - - u32 AlphaRef; -}; - -//! constructor -CTRTextureGouraudAlphaNoZ::CTRTextureGouraudAlphaNoZ(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraudAlphaNoZ"); - #endif - - AlphaRef = 0; -} - - -/*! -*/ -void CTRTextureGouraudAlphaNoZ::setParam ( u32 index, f32 value) -{ -#ifdef BURNINGVIDEO_RENDERER_FAST - AlphaRef = core::floor32 ( value * 256.f ); -#else - AlphaRef = u32_to_fixPoint ( core::floor32 ( value * 256.f ) ); -#endif -} - -/*! -*/ -void CTRTextureGouraudAlphaNoZ::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef USE_ZBUFFER - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; - -#else - tFixPointu a0; - tFixPointu r0, g0, b0; -#endif - - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - -#ifdef BURNINGVIDEO_RENDERER_FAST - - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - -#ifdef INVERSE_W - - inversew = fix_inverse32 ( line.w[0] ); - - u32 argb = getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x,inversew), - d + f32_to_fixPoint ( line.t0[0].y,inversew) - ); - -#else - - u32 argb = getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x), - d + f32_to_fixPoint ( line.t0[0].y) - ); - -#endif - - const u32 alpha = ( argb >> 24 ); - if ( alpha >= AlphaRef ) - { -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - dst[i] = PixelBlend32 ( dst[i], argb, alpha ); - } - - -#else - - inversew = fix_inverse32 ( line.w[0] ); - - getSample_texture ( a0, r0, g0, b0, - &IT[0], - f32_to_fixPoint ( line.t0[0].x,inversew), - f32_to_fixPoint ( line.t0[0].y,inversew) - ); - - if ( a0 >= AlphaRef ) - { -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - dst[i] = PixelBlend32 ( dst[i], - fix_to_color ( r0,g0, b0 ), - fixPointu_to_u32 ( a0 ) - ); - } -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1; -#endif - } - -} - -void CTRTextureGouraudAlphaNoZ::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTRTextureGouraudAlphaNoZ(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureGouraudAlphaNoZ(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +//#define WRITE_W + +//#define IPOL_C0 +#define IPOL_T0 +//#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + + + +namespace irr +{ + +namespace video +{ + +class CTRTextureGouraudAlphaNoZ : public IBurningShader +{ +public: + + //! constructor + CTRTextureGouraudAlphaNoZ(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + virtual void setParam ( u32 index, f32 value); + + +private: + void scanline_bilinear (); + + sScanConvertData scan; + sScanLineData line; + + u32 AlphaRef; +}; + +//! constructor +CTRTextureGouraudAlphaNoZ::CTRTextureGouraudAlphaNoZ(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureGouraudAlphaNoZ"); + #endif + + AlphaRef = 0; +} + + +/*! +*/ +void CTRTextureGouraudAlphaNoZ::setParam ( u32 index, f32 value) +{ +#ifdef BURNINGVIDEO_RENDERER_FAST + AlphaRef = core::floor32 ( value * 256.f ); +#else + AlphaRef = u32_to_fixPoint ( core::floor32 ( value * 256.f ) ); +#endif +} + +/*! +*/ +void CTRTextureGouraudAlphaNoZ::scanline_bilinear () +{ + tVideoSample *dst; + +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef USE_ZBUFFER + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + +#ifdef INVERSE_W + f32 inversew; +#endif + +#ifdef BURNINGVIDEO_RENDERER_FAST + u32 dIndex = ( line.y & 3 ) << 2; + +#else + tFixPointu a0; + tFixPointu r0, g0, b0; +#endif + + + for ( s32 i = 0; i <= dx; ++i ) + { +#ifdef CMP_Z + if ( line.z[0] < z[i] ) +#endif +#ifdef CMP_W + if ( line.w[0] >= z[i] ) +#endif + + { + +#ifdef BURNINGVIDEO_RENDERER_FAST + + const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; + +#ifdef INVERSE_W + + inversew = fix_inverse32 ( line.w[0] ); + + u32 argb = getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x,inversew), + d + f32_to_fixPoint ( line.t0[0].y,inversew) + ); + +#else + + u32 argb = getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x), + d + f32_to_fixPoint ( line.t0[0].y) + ); + +#endif + + const u32 alpha = ( argb >> 24 ); + if ( alpha >= AlphaRef ) + { +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + + dst[i] = PixelBlend32 ( dst[i], argb, alpha ); + } + + +#else + + inversew = fix_inverse32 ( line.w[0] ); + + getSample_texture ( a0, r0, g0, b0, + &IT[0], + f32_to_fixPoint ( line.t0[0].x,inversew), + f32_to_fixPoint ( line.t0[0].y,inversew) + ); + + if ( a0 >= AlphaRef ) + { +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + + dst[i] = PixelBlend32 ( dst[i], + fix_to_color ( r0,g0, b0 ), + fixPointu_to_u32 ( a0 ) + ); + } +#endif + + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1; +#endif + } + +} + +void CTRTextureGouraudAlphaNoZ::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + // rasterize upper sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[1] ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear ( ); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[2] ) + { + // advance to middle point + if( (f32) 0.0 != scan.invDeltaY[1] ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear ( ); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +IBurningShader* createTRTextureGouraudAlphaNoZ(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRTextureGouraudAlphaNoZ(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CTRTextureGouraudNoZ.cpp b/src/dep/src/irrlicht/CTRTextureGouraudNoZ.cpp index 8da890c..61f9e1e 100644 --- a/src/dep/src/irrlicht/CTRTextureGouraudNoZ.cpp +++ b/src/dep/src/irrlicht/CTRTextureGouraudNoZ.cpp @@ -1,366 +1,366 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "CTRTextureGouraud.h" -#include "SColor.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRTextureGouraudNoZ : public CTRTextureGouraud -{ -public: - - CTRTextureGouraudNoZ() - : CTRTextureGouraud(0) - { - #ifdef _DEBUG - setDebugName("CTRGouraudWireNoZ"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - u16 color; - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels - s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values - s32 leftStepR, leftStepG, leftStepB, - rightStepR, rightStepG, rightStepB; // color steps - s32 spanR, spanG, spanB, spanStepR, spanStepG, spanStepB; // color interpolating values while drawing a span. - s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values - s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values - s32 spanTx, spanTy, spanTxStep, spanTyStep; // values of Texturecoords when drawing a span - core::rect TriangleRect; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedTexture = (u16*)Texture->lock(); - - for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - - // höhe des dreiecks berechnen - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftR = rightR = video::getRed(v1->Color)<<8; - leftG = rightG = video::getGreen(v1->Color)<<8; - leftB = rightB = video::getBlue(v1->Color)<<8; - leftTx = rightTx = v1->TCoords.X; - leftTy = rightTy = v1->TCoords.Y; - - targetSurface = lockedSurface + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightStepR = (s32)(((video::getRed(v2->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreen(v2->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlue(v2->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftStepR = (s32)(((video::getRed(v2->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreen(v2->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlue(v2->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - - leftR += leftStepR*leftx; - leftG += leftStepG*leftx; - leftB += leftStepB*leftx; - rightR += rightStepR*leftx; - rightG += rightStepG*leftx; - rightB += rightStepB*leftx; - - leftTx += leftTxStep*leftx; - leftTy += leftTyStep*leftx; - rightTx += rightTxStep*leftx; - rightTy += rightTyStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - // thanks to a correction by hybrid - // calculations delayed to correctly propagate to textures etc. - s32 tDiffLeft=0, tDiffRight=0; - if (leftxViewPortRect.LowerRightCorner.X) - tDiffLeft=ViewPortRect.LowerRightCorner.X-leftx; - - if (rightxViewPortRect.LowerRightCorner.X) - tDiffRight=ViewPortRect.LowerRightCorner.X-rightx; - - // draw the span - if (rightx + tDiffRight - leftx - tDiffLeft) - { - f32 tmpDiv = 1.0f / (f32)(rightx - leftx); - - spanStepR = (s32)((rightR - leftR) * tmpDiv); - spanR = leftR+tDiffLeft*spanStepR; - spanStepG = (s32)((rightG - leftG) * tmpDiv); - spanG = leftG+tDiffLeft*spanStepG; - spanStepB = (s32)((rightB - leftB) * tmpDiv); - spanB = leftB+tDiffLeft*spanStepB; - - spanTxStep = (s32)((rightTx - leftTx) * tmpDiv); - spanTx = leftTx + tDiffLeft*spanTxStep; - spanTyStep = (s32)((rightTy - leftTy) * tmpDiv); - spanTy = leftTy+tDiffLeft*spanTyStep; - - hSpanBegin = targetSurface + leftx+tDiffLeft; - hSpanEnd = targetSurface + rightx+tDiffRight; - - while (hSpanBegin < hSpanEnd) - { - color = lockedTexture[((spanTy>>8)&textureYMask) * lockedTextureWidth + ((spanTx>>8)&textureXMask)]; - *hSpanBegin = video::RGB16(video::getRed(color) * (spanR>>8) >>2, video::getGreen(color) * (spanG>>8) >>2, video::getBlue(color) * (spanB>>8) >>2); - - spanR += spanStepR; - spanG += spanStepG; - spanB += spanStepB; - - spanTx += spanTxStep; - spanTy += spanTyStep; - - ++hSpanBegin; - } - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - - leftR += leftStepR; - leftG += leftStepG; - leftB += leftStepB; - rightR += rightStepR; - rightG += rightStepG; - rightB += rightStepB; - - leftTx += leftTxStep; - leftTy += leftTyStep; - rightTx += rightTxStep; - rightTy += rightTyStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightR = video::getRed(v2->Color)<<8; - rightG = video::getGreen(v2->Color)<<8; - rightB = video::getBlue(v2->Color)<<8; - rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - - rightTx = v2->TCoords.X; - rightTy = v2->TCoords.Y; - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftR = video::getRed(v2->Color)<<8; - leftG = video::getGreen(v2->Color)<<8; - leftB = video::getBlue(v2->Color)<<8; - leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - - leftTx = v2->TCoords.X; - leftTy = v2->TCoords.Y; - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - Texture->unlock(); - } - -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererTextureGouraudNoZ() -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRTextureGouraudNoZ(); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "CTRTextureGouraud.h" +#include "SColor.h" + +#ifdef _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +class CTRTextureGouraudNoZ : public CTRTextureGouraud +{ +public: + + CTRTextureGouraudNoZ() + : CTRTextureGouraud(0) + { + #ifdef _DEBUG + setDebugName("CTRGouraudWireNoZ"); + #endif + } + + //! draws an indexed triangle list + virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) + { + const S2DVertex *v1, *v2, *v3; + + u16 color; + f32 tmpDiv; // temporary division factor + f32 longest; // saves the longest span + s32 height; // saves height of triangle + u16* targetSurface; // target pointer where to plot pixels + s32 spanEnd; // saves end of spans + f32 leftdeltaxf; // amount of pixels to increase on left side of triangle + f32 rightdeltaxf; // amount of pixels to increase on right side of triangle + s32 leftx, rightx; // position where we are + f32 leftxf, rightxf; // same as above, but as f32 values + s32 span; // current span + u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels + s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values + s32 leftStepR, leftStepG, leftStepB, + rightStepR, rightStepG, rightStepB; // color steps + s32 spanR, spanG, spanB, spanStepR, spanStepG, spanStepB; // color interpolating values while drawing a span. + s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values + s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values + s32 spanTx, spanTy, spanTxStep, spanTyStep; // values of Texturecoords when drawing a span + core::rect TriangleRect; + + lockedSurface = (u16*)RenderTarget->lock(); + lockedTexture = (u16*)Texture->lock(); + + for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - + ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); + + if (z < 0) + continue; + } + + //near plane clipping + + if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) + continue; + + // sort for width for inscreen clipping + + if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); + if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); + if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); + + if ((v1->Pos.X - v3->Pos.X) == 0) + continue; + + TriangleRect.UpperLeftCorner.X = v1->Pos.X; + TriangleRect.LowerRightCorner.X = v3->Pos.X; + + // sort for height for faster drawing. + + if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); + if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); + if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); + + TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; + TriangleRect.LowerRightCorner.Y = v3->Pos.Y; + + if (!TriangleRect.isRectCollided(ViewPortRect)) + continue; + + + // höhe des dreiecks berechnen + height = v3->Pos.Y - v1->Pos.Y; + if (!height) + continue; + + // calculate longest span + + longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); + + spanEnd = v2->Pos.Y; + span = v1->Pos.Y; + leftxf = (f32)v1->Pos.X; + rightxf = (f32)v1->Pos.X; + + leftR = rightR = video::getRed(v1->Color)<<8; + leftG = rightG = video::getGreen(v1->Color)<<8; + leftB = rightB = video::getBlue(v1->Color)<<8; + leftTx = rightTx = v1->TCoords.X; + leftTy = rightTy = v1->TCoords.Y; + + targetSurface = lockedSurface + span * SurfaceWidth; + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + rightStepR = (s32)(((video::getRed(v2->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreen(v2->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlue(v2->Color)<<8) - rightB) * tmpDiv); + rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); + + tmpDiv = 1.0f / (f32)height; + leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); + leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (f32)height; + rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); + rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); + + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + leftStepR = (s32)(((video::getRed(v2->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreen(v2->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlue(v2->Color)<<8) - leftB) * tmpDiv); + leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); + } + + + // do it twice, once for the first half of the triangle, + // end then for the second half. + + for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) + { + if (spanEnd > ViewPortRect.LowerRightCorner.Y) + spanEnd = ViewPortRect.LowerRightCorner.Y; + + // if the span <0, than we can skip these spans, + // and proceed to the next spans which are really on the screen. + if (span < ViewPortRect.UpperLeftCorner.Y) + { + // we'll use leftx as temp variable + if (spanEnd < ViewPortRect.UpperLeftCorner.Y) + { + leftx = spanEnd - span; + span = spanEnd; + } + else + { + leftx = ViewPortRect.UpperLeftCorner.Y - span; + span = ViewPortRect.UpperLeftCorner.Y; + } + + leftxf += leftdeltaxf*leftx; + rightxf += rightdeltaxf*leftx; + targetSurface += SurfaceWidth*leftx; + + leftR += leftStepR*leftx; + leftG += leftStepG*leftx; + leftB += leftStepB*leftx; + rightR += rightStepR*leftx; + rightG += rightStepG*leftx; + rightB += rightStepB*leftx; + + leftTx += leftTxStep*leftx; + leftTy += leftTyStep*leftx; + rightTx += rightTxStep*leftx; + rightTy += rightTyStep*leftx; + } + + + // the main loop. Go through every span and draw it. + + while (span < spanEnd) + { + leftx = (s32)(leftxf); + rightx = (s32)(rightxf + 0.5f); + + // perform some clipping + // thanks to a correction by hybrid + // calculations delayed to correctly propagate to textures etc. + s32 tDiffLeft=0, tDiffRight=0; + if (leftxViewPortRect.LowerRightCorner.X) + tDiffLeft=ViewPortRect.LowerRightCorner.X-leftx; + + if (rightxViewPortRect.LowerRightCorner.X) + tDiffRight=ViewPortRect.LowerRightCorner.X-rightx; + + // draw the span + if (rightx + tDiffRight - leftx - tDiffLeft) + { + f32 tmpDiv = 1.0f / (f32)(rightx - leftx); + + spanStepR = (s32)((rightR - leftR) * tmpDiv); + spanR = leftR+tDiffLeft*spanStepR; + spanStepG = (s32)((rightG - leftG) * tmpDiv); + spanG = leftG+tDiffLeft*spanStepG; + spanStepB = (s32)((rightB - leftB) * tmpDiv); + spanB = leftB+tDiffLeft*spanStepB; + + spanTxStep = (s32)((rightTx - leftTx) * tmpDiv); + spanTx = leftTx + tDiffLeft*spanTxStep; + spanTyStep = (s32)((rightTy - leftTy) * tmpDiv); + spanTy = leftTy+tDiffLeft*spanTyStep; + + hSpanBegin = targetSurface + leftx+tDiffLeft; + hSpanEnd = targetSurface + rightx+tDiffRight; + + while (hSpanBegin < hSpanEnd) + { + color = lockedTexture[((spanTy>>8)&textureYMask) * lockedTextureWidth + ((spanTx>>8)&textureXMask)]; + *hSpanBegin = video::RGB16(video::getRed(color) * (spanR>>8) >>2, video::getGreen(color) * (spanG>>8) >>2, video::getBlue(color) * (spanB>>8) >>2); + + spanR += spanStepR; + spanG += spanStepG; + spanB += spanStepB; + + spanTx += spanTxStep; + spanTy += spanTyStep; + + ++hSpanBegin; + } + } + + leftxf += leftdeltaxf; + rightxf += rightdeltaxf; + ++span; + targetSurface += SurfaceWidth; + + leftR += leftStepR; + leftG += leftStepG; + leftB += leftStepB; + rightR += rightStepR; + rightG += rightStepG; + rightB += rightStepB; + + leftTx += leftTxStep; + leftTy += leftTyStep; + rightTx += rightTxStep; + rightTy += rightTyStep; + } + + if (triangleHalf>0) // break, we've gout only two halves + break; + + + // setup variables for second half of the triangle. + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + rightxf = (f32)v2->Pos.X; + + rightR = video::getRed(v2->Color)<<8; + rightG = video::getGreen(v2->Color)<<8; + rightB = video::getBlue(v2->Color)<<8; + rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); + + rightTx = v2->TCoords.X; + rightTy = v2->TCoords.Y; + rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + leftxf = (f32)v2->Pos.X; + + leftR = video::getRed(v2->Color)<<8; + leftG = video::getGreen(v2->Color)<<8; + leftB = video::getBlue(v2->Color)<<8; + leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); + + leftTx = v2->TCoords.X; + leftTy = v2->TCoords.Y; + leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); + } + + + spanEnd = v3->Pos.Y; + } + + } + + RenderTarget->unlock(); + Texture->unlock(); + } + +}; + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +ITriangleRenderer* createTriangleRendererTextureGouraudNoZ() +{ + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + return new CTRTextureGouraudNoZ(); + #else + return 0; + #endif // _IRR_COMPILE_WITH_SOFTWARE_ +} + +} // end namespace video +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CTRTextureGouraudNoZ2.cpp b/src/dep/src/irrlicht/CTRTextureGouraudNoZ2.cpp index 2e4c767..39594c2 100644 --- a/src/dep/src/irrlicht/CTRTextureGouraudNoZ2.cpp +++ b/src/dep/src/irrlicht/CTRTextureGouraudNoZ2.cpp @@ -1,677 +1,677 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#ifdef BURNINGVIDEO_RENDERER_FAST - #define SUBTEXEL - #define INVERSE_W -#else - #define SUBTEXEL - #define INVERSE_W -#endif - -//#define USE_ZBUFFER -#define IPOL_W -//#define CMP_W -//#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - -namespace irr -{ - -namespace video -{ - -class CTRTextureGouraudNoZ2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureGouraudNoZ2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRTextureGouraudNoZ2::CTRTextureGouraudNoZ2(IDepthBuffer* zbuffer) -: IBurningShader(0) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraudNoZ2"); - #endif -} - - - -/*! -*/ -void CTRTextureGouraudNoZ2::scanline_bilinear ( ) -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef USE_ZBUFFER - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - - tFixPoint tx0; - tFixPoint ty0; - - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - - tx0 = f32_to_fixPoint ( line.t0[0].x,inversew); - ty0 = f32_to_fixPoint ( line.t0[0].y,inversew); -#else - tx0 = f32_to_fixPoint ( line.t0[0].x ); - ty0 = f32_to_fixPoint ( line.t0[0].y ); -#endif - dst[i] = irr::getTexel_plain ( &IT[0], tx0, ty0 ); - -/* - getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); - dst[i] = fix_to_color ( r0, g0, b0 ); -*/ -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1; -#endif - } - -} - -void CTRTextureGouraudNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTRTextureGouraudNoZ2() -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureGouraudNoZ2( 0 ); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#ifdef BURNINGVIDEO_RENDERER_FAST + #define SUBTEXEL + #define INVERSE_W +#else + #define SUBTEXEL + #define INVERSE_W +#endif + +//#define USE_ZBUFFER +#define IPOL_W +//#define CMP_W +//#define WRITE_W + +//#define IPOL_C0 +#define IPOL_T0 +//#define IPOL_T1 + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + + +namespace irr +{ + +namespace video +{ + +class CTRTextureGouraudNoZ2 : public IBurningShader +{ +public: + + //! constructor + CTRTextureGouraudNoZ2(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + +private: + void scanline_bilinear (); + sScanConvertData scan; + sScanLineData line; + +}; + +//! constructor +CTRTextureGouraudNoZ2::CTRTextureGouraudNoZ2(IDepthBuffer* zbuffer) +: IBurningShader(0) +{ + #ifdef _DEBUG + setDebugName("CTRTextureGouraudNoZ2"); + #endif +} + + + +/*! +*/ +void CTRTextureGouraudNoZ2::scanline_bilinear ( ) +{ + tVideoSample *dst; + +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef USE_ZBUFFER + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + +#ifdef INVERSE_W + f32 inversew; +#endif + + tFixPoint tx0; + tFixPoint ty0; + + + for ( s32 i = 0; i <= dx; ++i ) + { +#ifdef CMP_Z + if ( line.z[0] < z[i] ) +#endif +#ifdef CMP_W + if ( line.w[0] >= z[i] ) +#endif + + { +#ifdef INVERSE_W + inversew = fix_inverse32 ( line.w[0] ); + + tx0 = f32_to_fixPoint ( line.t0[0].x,inversew); + ty0 = f32_to_fixPoint ( line.t0[0].y,inversew); +#else + tx0 = f32_to_fixPoint ( line.t0[0].x ); + ty0 = f32_to_fixPoint ( line.t0[0].y ); +#endif + dst[i] = irr::getTexel_plain ( &IT[0], tx0, ty0 ); + +/* + getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); + dst[i] = fix_to_color ( r0, g0, b0 ); +*/ +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1; +#endif + } + +} + +void CTRTextureGouraudNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + // rasterize upper sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[1] ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear ( ); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[2] ) + { + // advance to middle point + if( (f32) 0.0 != scan.invDeltaY[1] ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +IBurningShader* createTRTextureGouraudNoZ2() +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRTextureGouraudNoZ2( 0 ); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + + diff --git a/src/dep/src/irrlicht/CTRTextureGouraudVertexAlpha2.cpp b/src/dep/src/irrlicht/CTRTextureGouraudVertexAlpha2.cpp index 4b9482c..19e6a8a 100644 --- a/src/dep/src/irrlicht/CTRTextureGouraudVertexAlpha2.cpp +++ b/src/dep/src/irrlicht/CTRTextureGouraudVertexAlpha2.cpp @@ -1,720 +1,720 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -//#define WRITE_W - -#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - -namespace irr -{ - -namespace video -{ - -class CTRTextureVertexAlpha2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureVertexAlpha2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRTextureVertexAlpha2::CTRTextureVertexAlpha2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureVertexAlpha2"); - #endif -} - - - -/*! -*/ -void CTRTextureVertexAlpha2::scanline_bilinear ( ) -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef USE_ZBUFFER - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - -//#define __TEST_THIS - -#ifdef __TEST_THIS - -#else - tFixPoint tx0; - tFixPoint ty0; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; -#endif - - -#ifdef IPOL_C0 - tFixPoint a3; -#endif - - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { -#ifdef __TEST_THIS - - inversew = fix_inverse32 ( line.w[0] ); - - dst[i] = PixelAdd32 ( - dst[i], - getTexel_plain ( &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), - f32_to_fixPoint ( line.t0[0].y,inversew) ) - ); - -#else - -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - - tx0 = f32_to_fixPoint ( line.t0[0].x,inversew); - ty0 = f32_to_fixPoint ( line.t0[0].y,inversew); - -#ifdef IPOL_C0 - a3 = f32_to_fixPoint ( line.c[0].y,inversew ); -#endif - -#else - tx0 = f32_to_fixPoint ( line.t0[0].x ); - ty0 = f32_to_fixPoint ( line.t0[0].y ); - -#ifdef IPOL_C0 - a3 = f32_to_fixPoint ( line.c[0].y ); -#endif - - -#endif - - getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); - color_to_fix ( r1, g1, b1, dst[i] ); - -#ifdef IPOL_C0 - r2 = clampfix_maxcolor ( r1 + imulFix ( r0, a3 ) ); - g2 = clampfix_maxcolor ( g1 + imulFix ( g0, a3 ) ); - b2 = clampfix_maxcolor ( b1 + imulFix ( b0, a3 ) ); -#else - r2 = clampfix_maxcolor ( r1 + r0 ); - g2 = clampfix_maxcolor ( g1 + g0 ); - b2 = clampfix_maxcolor ( b1 + b0 ); -#endif - - dst[i] = fix_to_color ( r2, g2, b2 ); - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif -#endif - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1; -#endif - } - -} - -void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureVertexAlpha2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureVertexAlpha2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +//#define WRITE_W + +#define IPOL_C0 +#define IPOL_T0 +//#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + +namespace irr +{ + +namespace video +{ + +class CTRTextureVertexAlpha2 : public IBurningShader +{ +public: + + //! constructor + CTRTextureVertexAlpha2(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + +private: + void scanline_bilinear (); + sScanConvertData scan; + sScanLineData line; + +}; + +//! constructor +CTRTextureVertexAlpha2::CTRTextureVertexAlpha2(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureVertexAlpha2"); + #endif +} + + + +/*! +*/ +void CTRTextureVertexAlpha2::scanline_bilinear ( ) +{ + tVideoSample *dst; + +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef USE_ZBUFFER + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + +#ifdef INVERSE_W + f32 inversew; +#endif + +//#define __TEST_THIS + +#ifdef __TEST_THIS + +#else + tFixPoint tx0; + tFixPoint ty0; + + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; + tFixPoint r2, g2, b2; +#endif + + +#ifdef IPOL_C0 + tFixPoint a3; +#endif + + + for ( s32 i = 0; i <= dx; ++i ) + { +#ifdef CMP_Z + if ( line.z[0] < z[i] ) +#endif +#ifdef CMP_W + if ( line.w[0] >= z[i] ) +#endif + + { +#ifdef __TEST_THIS + + inversew = fix_inverse32 ( line.w[0] ); + + dst[i] = PixelAdd32 ( + dst[i], + getTexel_plain ( &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), + f32_to_fixPoint ( line.t0[0].y,inversew) ) + ); + +#else + +#ifdef INVERSE_W + inversew = fix_inverse32 ( line.w[0] ); + + tx0 = f32_to_fixPoint ( line.t0[0].x,inversew); + ty0 = f32_to_fixPoint ( line.t0[0].y,inversew); + +#ifdef IPOL_C0 + a3 = f32_to_fixPoint ( line.c[0].y,inversew ); +#endif + +#else + tx0 = f32_to_fixPoint ( line.t0[0].x ); + ty0 = f32_to_fixPoint ( line.t0[0].y ); + +#ifdef IPOL_C0 + a3 = f32_to_fixPoint ( line.c[0].y ); +#endif + + +#endif + + getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); + color_to_fix ( r1, g1, b1, dst[i] ); + +#ifdef IPOL_C0 + r2 = clampfix_maxcolor ( r1 + imulFix ( r0, a3 ) ); + g2 = clampfix_maxcolor ( g1 + imulFix ( g0, a3 ) ); + b2 = clampfix_maxcolor ( b1 + imulFix ( b0, a3 ) ); +#else + r2 = clampfix_maxcolor ( r1 + r0 ); + g2 = clampfix_maxcolor ( g1 + g0 ); + b2 = clampfix_maxcolor ( b1 + b0 ); +#endif + + dst[i] = fix_to_color ( r2, g2, b2 ); + +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif +#ifdef WRITE_W + z[i] = line.w[0]; +#endif +#endif + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1; +#endif + } + +} + +void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + // rasterize upper sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[1] ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[2] ) + { + // advance to middle point + if( (f32) 0.0 != scan.invDeltaY[1] ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +IBurningShader* createTriangleRendererTextureVertexAlpha2(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRTextureVertexAlpha2(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + + diff --git a/src/dep/src/irrlicht/CTRTextureGouraudWire.cpp b/src/dep/src/irrlicht/CTRTextureGouraudWire.cpp index f57210b..5156da3 100644 --- a/src/dep/src/irrlicht/CTRTextureGouraudWire.cpp +++ b/src/dep/src/irrlicht/CTRTextureGouraudWire.cpp @@ -1,361 +1,361 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRTextureGouraudWire : public CTRTextureGouraud -{ -public: - - CTRTextureGouraudWire(IZBuffer* zbuffer) - : CTRTextureGouraud(zbuffer) - { - #ifdef _DEBUG - setDebugName("CTRGouraudWire"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - u16 color; - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values - s32 leftStepR, leftStepG, leftStepB, - rightStepR, rightStepG, rightStepB; // color steps - s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values - s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values - core::rect TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - TZBufferType* zTarget;//, *spanZTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - lockedTexture = (u16*)Texture->lock(); - - for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - - // höhe des dreiecks berechnen - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - leftR = rightR = video::getRed(v1->Color)<<8; - leftG = rightG = video::getGreen(v1->Color)<<8; - leftB = rightB = video::getBlue(v1->Color)<<8; - leftTx = rightTx = v1->TCoords.X; - leftTy = rightTy = v1->TCoords.Y; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((video::getRed(v2->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreen(v2->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlue(v2->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((video::getRed(v2->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreen(v2->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlue(v2->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - - leftR += leftStepR*leftx; - leftG += leftStepG*leftx; - leftB += leftStepB*leftx; - rightR += rightStepR*leftx; - rightG += rightStepG*leftx; - rightB += rightStepB*leftx; - - leftTx += leftTxStep*leftx; - leftTy += leftTyStep*leftx; - rightTx += rightTxStep*leftx; - rightTy += rightTyStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - - if (leftx>=ViewPortRect.UpperLeftCorner.X && - leftx<=ViewPortRect.LowerRightCorner.X) - { - if (leftZValue > *(zTarget + leftx)) - { - *(zTarget + leftx) = leftZValue; - color = lockedTexture[((leftTy>>8)&textureYMask) * lockedTextureWidth + ((leftTx>>8)&textureXMask)]; - *(targetSurface + leftx) = video::RGB16(video::getRed(color) * (leftR>>8) >>2, video::getGreen(color) * (leftG>>8) >>2, video::getBlue(color) * (leftR>>8) >>2); - } - } - - - if (rightx>=ViewPortRect.UpperLeftCorner.X && - rightx<=ViewPortRect.LowerRightCorner.X) - { - if (rightZValue > *(zTarget + rightx)) - { - *(zTarget + rightx) = rightZValue; - color = lockedTexture[((rightTy>>8)&textureYMask) * lockedTextureWidth + ((rightTx>>8)&textureXMask)]; - *(targetSurface + rightx) = video::RGB16(video::getRed(color) * (rightR>>8) >>2, video::getGreen(color) * (rightG>>8) >>2, video::getBlue(color) * (rightR>>8) >>2); - } - - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - - leftR += leftStepR; - leftG += leftStepG; - leftB += leftStepB; - rightR += rightStepR; - rightG += rightStepG; - rightB += rightStepB; - - leftTx += leftTxStep; - leftTy += leftTyStep; - rightTx += rightTxStep; - rightTy += rightTyStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - rightR = video::getRed(v2->Color)<<8; - rightG = video::getGreen(v2->Color)<<8; - rightB = video::getBlue(v2->Color)<<8; - rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - - rightTx = v2->TCoords.X; - rightTy = v2->TCoords.Y; - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - leftR = video::getRed(v2->Color)<<8; - leftG = video::getGreen(v2->Color)<<8; - leftB = video::getBlue(v2->Color)<<8; - leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - - leftTx = v2->TCoords.X; - leftTy = v2->TCoords.Y; - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - Texture->unlock(); - - } - -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererTextureGouraudWire(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRTextureGouraudWire(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "CTRTextureGouraud.h" + +#ifdef _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +class CTRTextureGouraudWire : public CTRTextureGouraud +{ +public: + + CTRTextureGouraudWire(IZBuffer* zbuffer) + : CTRTextureGouraud(zbuffer) + { + #ifdef _DEBUG + setDebugName("CTRGouraudWire"); + #endif + } + + //! draws an indexed triangle list + virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) + { + const S2DVertex *v1, *v2, *v3; + + u16 color; + f32 tmpDiv; // temporary division factor + f32 longest; // saves the longest span + s32 height; // saves height of triangle + u16* targetSurface; // target pointer where to plot pixels + s32 spanEnd; // saves end of spans + f32 leftdeltaxf; // amount of pixels to increase on left side of triangle + f32 rightdeltaxf; // amount of pixels to increase on right side of triangle + s32 leftx, rightx; // position where we are + f32 leftxf, rightxf; // same as above, but as f32 values + s32 span; // current span + s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values + s32 leftStepR, leftStepG, leftStepB, + rightStepR, rightStepG, rightStepB; // color steps + s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values + s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values + core::rect TriangleRect; + + s32 leftZValue, rightZValue; + s32 leftZStep, rightZStep; + TZBufferType* zTarget;//, *spanZTarget; // target of ZBuffer; + + lockedSurface = (u16*)RenderTarget->lock(); + lockedZBuffer = ZBuffer->lock(); + lockedTexture = (u16*)Texture->lock(); + + for (s32 i=0; iPos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - + ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); + + if (z < 0) + continue; + } + + //near plane clipping + + if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) + continue; + + // sort for width for inscreen clipping + + if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); + if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); + if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); + + if ((v1->Pos.X - v3->Pos.X) == 0) + continue; + + TriangleRect.UpperLeftCorner.X = v1->Pos.X; + TriangleRect.LowerRightCorner.X = v3->Pos.X; + + // sort for height for faster drawing. + + if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); + if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); + if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); + + TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; + TriangleRect.LowerRightCorner.Y = v3->Pos.Y; + + if (!TriangleRect.isRectCollided(ViewPortRect)) + continue; + + + // höhe des dreiecks berechnen + height = v3->Pos.Y - v1->Pos.Y; + if (!height) + continue; + + // calculate longest span + + longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); + + spanEnd = v2->Pos.Y; + span = v1->Pos.Y; + leftxf = (f32)v1->Pos.X; + rightxf = (f32)v1->Pos.X; + + leftZValue = v1->ZValue; + rightZValue = v1->ZValue; + + leftR = rightR = video::getRed(v1->Color)<<8; + leftG = rightG = video::getGreen(v1->Color)<<8; + leftB = rightB = video::getBlue(v1->Color)<<8; + leftTx = rightTx = v1->TCoords.X; + leftTy = rightTy = v1->TCoords.Y; + + targetSurface = lockedSurface + span * SurfaceWidth; + zTarget = lockedZBuffer + span * SurfaceWidth; + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + rightStepR = (s32)(((video::getRed(v2->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreen(v2->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlue(v2->Color)<<8) - rightB) * tmpDiv); + rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); + + tmpDiv = 1.0f / (f32)height; + leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); + leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (f32)height; + rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; + rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); + rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); + rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); + + tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); + leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; + leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); + leftStepR = (s32)(((video::getRed(v2->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreen(v2->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlue(v2->Color)<<8) - leftB) * tmpDiv); + leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); + } + + + // do it twice, once for the first half of the triangle, + // end then for the second half. + + for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) + { + if (spanEnd > ViewPortRect.LowerRightCorner.Y) + spanEnd = ViewPortRect.LowerRightCorner.Y; + + // if the span <0, than we can skip these spans, + // and proceed to the next spans which are really on the screen. + if (span < ViewPortRect.UpperLeftCorner.Y) + { + // we'll use leftx as temp variable + if (spanEnd < ViewPortRect.UpperLeftCorner.Y) + { + leftx = spanEnd - span; + span = spanEnd; + } + else + { + leftx = ViewPortRect.UpperLeftCorner.Y - span; + span = ViewPortRect.UpperLeftCorner.Y; + } + + leftxf += leftdeltaxf*leftx; + rightxf += rightdeltaxf*leftx; + targetSurface += SurfaceWidth*leftx; + zTarget += SurfaceWidth*leftx; + leftZValue += leftZStep*leftx; + rightZValue += rightZStep*leftx; + + leftR += leftStepR*leftx; + leftG += leftStepG*leftx; + leftB += leftStepB*leftx; + rightR += rightStepR*leftx; + rightG += rightStepG*leftx; + rightB += rightStepB*leftx; + + leftTx += leftTxStep*leftx; + leftTy += leftTyStep*leftx; + rightTx += rightTxStep*leftx; + rightTy += rightTyStep*leftx; + } + + + // the main loop. Go through every span and draw it. + + while (span < spanEnd) + { + leftx = (s32)(leftxf); + rightx = (s32)(rightxf + 0.5f); + + // perform some clipping + + if (leftx>=ViewPortRect.UpperLeftCorner.X && + leftx<=ViewPortRect.LowerRightCorner.X) + { + if (leftZValue > *(zTarget + leftx)) + { + *(zTarget + leftx) = leftZValue; + color = lockedTexture[((leftTy>>8)&textureYMask) * lockedTextureWidth + ((leftTx>>8)&textureXMask)]; + *(targetSurface + leftx) = video::RGB16(video::getRed(color) * (leftR>>8) >>2, video::getGreen(color) * (leftG>>8) >>2, video::getBlue(color) * (leftR>>8) >>2); + } + } + + + if (rightx>=ViewPortRect.UpperLeftCorner.X && + rightx<=ViewPortRect.LowerRightCorner.X) + { + if (rightZValue > *(zTarget + rightx)) + { + *(zTarget + rightx) = rightZValue; + color = lockedTexture[((rightTy>>8)&textureYMask) * lockedTextureWidth + ((rightTx>>8)&textureXMask)]; + *(targetSurface + rightx) = video::RGB16(video::getRed(color) * (rightR>>8) >>2, video::getGreen(color) * (rightG>>8) >>2, video::getBlue(color) * (rightR>>8) >>2); + } + + } + + leftxf += leftdeltaxf; + rightxf += rightdeltaxf; + ++span; + targetSurface += SurfaceWidth; + zTarget += SurfaceWidth; + leftZValue += leftZStep; + rightZValue += rightZStep; + + leftR += leftStepR; + leftG += leftStepG; + leftB += leftStepB; + rightR += rightStepR; + rightG += rightStepG; + rightB += rightStepB; + + leftTx += leftTxStep; + leftTy += leftTyStep; + rightTx += rightTxStep; + rightTy += rightTyStep; + } + + if (triangleHalf>0) // break, we've gout only two halves + break; + + + // setup variables for second half of the triangle. + + if (longest < 0.0f) + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + rightxf = (f32)v2->Pos.X; + + rightZValue = v2->ZValue; + rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + + rightR = video::getRed(v2->Color)<<8; + rightG = video::getGreen(v2->Color)<<8; + rightB = video::getBlue(v2->Color)<<8; + rightStepR = (s32)(((video::getRed(v3->Color)<<8) - rightR) * tmpDiv); + rightStepG = (s32)(((video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); + rightStepB = (s32)(((video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); + + rightTx = v2->TCoords.X; + rightTy = v2->TCoords.Y; + rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); + rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); + } + else + { + tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); + + leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; + leftxf = (f32)v2->Pos.X; + + leftZValue = v2->ZValue; + leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); + + leftR = video::getRed(v2->Color)<<8; + leftG = video::getGreen(v2->Color)<<8; + leftB = video::getBlue(v2->Color)<<8; + leftStepR = (s32)(((video::getRed(v3->Color)<<8) - leftR) * tmpDiv); + leftStepG = (s32)(((video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); + leftStepB = (s32)(((video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); + + leftTx = v2->TCoords.X; + leftTy = v2->TCoords.Y; + leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); + leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); + } + + + spanEnd = v3->Pos.Y; + } + + } + + RenderTarget->unlock(); + ZBuffer->unlock(); + Texture->unlock(); + + } + +}; + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +ITriangleRenderer* createTriangleRendererTextureGouraudWire(IZBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + return new CTRTextureGouraudWire(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_SOFTWARE_ +} + +} // end namespace video +} // end namespace irr diff --git a/src/dep/src/irrlicht/CTRTextureLightMap2_Add.cpp b/src/dep/src/irrlicht/CTRTextureLightMap2_Add.cpp index ef73289..3931766 100644 --- a/src/dep/src/irrlicht/CTRTextureLightMap2_Add.cpp +++ b/src/dep/src/irrlicht/CTRTextureLightMap2_Add.cpp @@ -1,705 +1,705 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - -namespace irr -{ - -namespace video -{ - -class CTRTextureLightMap2_Add : public IBurningShader -{ -public: - - //! constructor - CTRTextureLightMap2_Add(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRTextureLightMap2_Add::CTRTextureLightMap2_Add(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureLightMap2_Add"); - #endif -} - - - -/*! -*/ -REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef USE_ZBUFFER - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - - - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; - - -#else - // - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; -#endif - - - for ( s32 i = 0; i <= dx; i++ ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - { - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef BURNINGVIDEO_RENDERER_FAST - -#ifdef INVERSE_W - - const f32 inversew = fix_inverse32 ( line.w[0] ); - - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - - dst[i] = PixelAdd32 ( - getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x,inversew), - d + f32_to_fixPoint ( line.t0[0].y,inversew) ), - getTexel_plain ( &IT[1], d + f32_to_fixPoint ( line.t1[0].x,inversew), - d + f32_to_fixPoint ( line.t1[0].y,inversew) ) - ); -#else - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - - dst[i] = PixelAdd32 ( - getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x), - d + f32_to_fixPoint ( line.t0[0].y) ), - getTexel_plain ( &IT[1], d + f32_to_fixPoint ( line.t1[0].x), - d + f32_to_fixPoint ( line.t1[0].y) ) - ); - -#endif - -#else - const f32 inversew = fix_inverse32 ( line.w[0] ); - - getSample_texture ( r0, g0, b0, &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), f32_to_fixPoint ( line.t0[0].y,inversew) ); - getSample_texture ( r1, g1, b1, &IT[1], f32_to_fixPoint ( line.t0[1].x,inversew), f32_to_fixPoint ( line.t0[1].y,inversew) ); - - dst[i] = fix_to_color ( clampfix_maxcolor ( r0 + r1 ), - clampfix_maxcolor ( g0 + g1 ), - clampfix_maxcolor ( b0 + b1 ) - ); -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1; -#endif - } - -} - -void CTRTextureLightMap2_Add::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // query access to TexMaps - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureLightMap2_Add(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureLightMap2_Add(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +#define WRITE_W + +//#define IPOL_C0 +#define IPOL_T0 +#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + +namespace irr +{ + +namespace video +{ + +class CTRTextureLightMap2_Add : public IBurningShader +{ +public: + + //! constructor + CTRTextureLightMap2_Add(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + +private: + void scanline_bilinear (); + + sScanConvertData scan; + sScanLineData line; + +}; + +//! constructor +CTRTextureLightMap2_Add::CTRTextureLightMap2_Add(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureLightMap2_Add"); + #endif +} + + + +/*! +*/ +REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear () +{ + tVideoSample *dst; + +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef USE_ZBUFFER + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + + + +#ifdef BURNINGVIDEO_RENDERER_FAST + u32 dIndex = ( line.y & 3 ) << 2; + + +#else + // + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; +#endif + + + for ( s32 i = 0; i <= dx; i++ ) + { +#ifdef CMP_Z + if ( line.z[0] < z[i] ) +#endif +#ifdef CMP_W + if ( line.w[0] >= z[i] ) +#endif + { + +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + +#ifdef BURNINGVIDEO_RENDERER_FAST + +#ifdef INVERSE_W + + const f32 inversew = fix_inverse32 ( line.w[0] ); + + const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; + + dst[i] = PixelAdd32 ( + getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x,inversew), + d + f32_to_fixPoint ( line.t0[0].y,inversew) ), + getTexel_plain ( &IT[1], d + f32_to_fixPoint ( line.t1[0].x,inversew), + d + f32_to_fixPoint ( line.t1[0].y,inversew) ) + ); +#else + const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; + + dst[i] = PixelAdd32 ( + getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x), + d + f32_to_fixPoint ( line.t0[0].y) ), + getTexel_plain ( &IT[1], d + f32_to_fixPoint ( line.t1[0].x), + d + f32_to_fixPoint ( line.t1[0].y) ) + ); + +#endif + +#else + const f32 inversew = fix_inverse32 ( line.w[0] ); + + getSample_texture ( r0, g0, b0, &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), f32_to_fixPoint ( line.t0[0].y,inversew) ); + getSample_texture ( r1, g1, b1, &IT[1], f32_to_fixPoint ( line.t0[1].x,inversew), f32_to_fixPoint ( line.t0[1].y,inversew) ); + + dst[i] = fix_to_color ( clampfix_maxcolor ( r0 + r1 ), + clampfix_maxcolor ( g0 + g1 ), + clampfix_maxcolor ( b0 + b1 ) + ); +#endif + + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1; +#endif + } + +} + +void CTRTextureLightMap2_Add::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + // query access to TexMaps + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + + + // rasterize upper sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[1] ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + if ( (f32) 0.0 != scan.invDeltaY[2] ) + { + // advance to middle point + if( (f32) 0.0 != scan.invDeltaY[1] ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +IBurningShader* createTriangleRendererTextureLightMap2_Add(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRTextureLightMap2_Add(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + + diff --git a/src/dep/src/irrlicht/CTRTextureLightMap2_M1.cpp b/src/dep/src/irrlicht/CTRTextureLightMap2_M1.cpp index 9a3d038..7a4896e 100644 --- a/src/dep/src/irrlicht/CTRTextureLightMap2_M1.cpp +++ b/src/dep/src/irrlicht/CTRTextureLightMap2_M1.cpp @@ -1,678 +1,678 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - -namespace irr -{ - -namespace video -{ - -class CTRTextureLightMap2_M1 : public IBurningShader -{ -public: - - //! constructor - CTRTextureLightMap2_M1(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear2 (); - - sScanLineData line; - -}; - -//! constructor -CTRTextureLightMap2_M1::CTRTextureLightMap2_M1(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureLightMap2_M1"); - #endif -} - -/*! -*/ -REALINLINE void CTRTextureLightMap2_M1::scanline_bilinear2 () -{ - tVideoSample *dst; - fp24 *z; - - s32 xStart; - s32 xEnd; - s32 dx; - s32 i; - - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - - // search z-buffer for first not occulled pixel - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; - - // subTexel - const f32 subPixel = ( (f32) xStart ) - line.x[0]; - -#ifdef IPOL_W - const f32 b = (line.w[1] - line.w[0]) * invDeltaX; - f32 a = line.w[0] + ( b * subPixel ); - - i = 0; - - while ( a <= z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.w[0] = a; - line.w[1] = b; -#else - const f32 b = (line.z[1] - line.z[0]) * invDeltaX; - f32 a = line.z[0] + ( b * subPixel ); - - i = 0; - - while ( a > z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.z[0] = a; - line.z[1] = b; -#endif - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - - a = (f32) i + subPixel; - - line.t0[1] = (line.t0[1] - line.t0[0]) * invDeltaX; - line.t1[1] = (line.t1[1] - line.t1[0]) * invDeltaX; - - line.t0[0] += line.t0[1] * a; - line.t1[0] += line.t1[1] * a; - - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; - -#else - // - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; -#endif - - - for ( ;i <= dx; i++ ) - { -#ifdef IPOL_W - if ( line.w[0] >= z[i] ) - { - z[i] = line.w[0]; -#else - if ( line.z[0] < z[i] ) - { - z[i] = line.z[0]; -#endif - -#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - f32 inversew = fix_inverse32 ( line.w[0] ); -#else - f32 inversew = FIX_POINT_F32_MUL; -#endif - - - -#ifdef BURNINGVIDEO_RENDERER_FAST - - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - - dst[i] = PixelMul32 ( - getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x,inversew), - d + f32_to_fixPoint ( line.t0[0].y,inversew) ), - getTexel_plain ( &IT[1], d + f32_to_fixPoint ( line.t1[0].x,inversew), - d + f32_to_fixPoint ( line.t1[0].y,inversew) ) - ); - - -#else - - - getSample_texture ( r0, g0, b0, &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), f32_to_fixPoint ( line.t0[0].y,inversew) ); - getSample_texture ( r1, g1, b1, &IT[1], f32_to_fixPoint ( line.t1[0].x,inversew), f32_to_fixPoint ( line.t1[0].y,inversew) ); - - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1 ( r0, r1 ) ), - clampfix_maxcolor ( imulFix_tex1 ( g0, g1 ) ), - clampfix_maxcolor ( imulFix_tex1 ( b0, b1 ) ) - ); -#endif - - } - -#ifdef IPOL_W - line.w[0] += line.w[1]; -#else - line.z[0] += line.z[1]; -#endif - line.t0[0] += line.t0[1]; - line.t1[0] += line.t1[1]; - } - -} - - - - - -void CTRTextureLightMap2_M1::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - sScanConvertData scan; - - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // query access to TexMaps - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - - // rasterize upper sub-triangle - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear2 (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - //if ( (f32) 0.0 != scan.invDeltaY[2] ) - if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) - { - // advance to middle point - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear2 (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureLightMap2_M1(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureLightMap2_M1(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +#define WRITE_W + +//#define IPOL_C0 +#define IPOL_T0 +#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + +namespace irr +{ + +namespace video +{ + +class CTRTextureLightMap2_M1 : public IBurningShader +{ +public: + + //! constructor + CTRTextureLightMap2_M1(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + +private: + void scanline_bilinear2 (); + + sScanLineData line; + +}; + +//! constructor +CTRTextureLightMap2_M1::CTRTextureLightMap2_M1(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureLightMap2_M1"); + #endif +} + +/*! +*/ +REALINLINE void CTRTextureLightMap2_M1::scanline_bilinear2 () +{ + tVideoSample *dst; + fp24 *z; + + s32 xStart; + s32 xEnd; + s32 dx; + s32 i; + + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + + // search z-buffer for first not occulled pixel + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; + + // subTexel + const f32 subPixel = ( (f32) xStart ) - line.x[0]; + +#ifdef IPOL_W + const f32 b = (line.w[1] - line.w[0]) * invDeltaX; + f32 a = line.w[0] + ( b * subPixel ); + + i = 0; + + while ( a <= z[i] ) + { + a += b; + + i += 1; + if ( i > dx ) + return; + + } + + // lazy setup rest of scanline + + line.w[0] = a; + line.w[1] = b; +#else + const f32 b = (line.z[1] - line.z[0]) * invDeltaX; + f32 a = line.z[0] + ( b * subPixel ); + + i = 0; + + while ( a > z[i] ) + { + a += b; + + i += 1; + if ( i > dx ) + return; + + } + + // lazy setup rest of scanline + + line.z[0] = a; + line.z[1] = b; +#endif + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + + a = (f32) i + subPixel; + + line.t0[1] = (line.t0[1] - line.t0[0]) * invDeltaX; + line.t1[1] = (line.t1[1] - line.t1[0]) * invDeltaX; + + line.t0[0] += line.t0[1] * a; + line.t1[0] += line.t1[1] * a; + + +#ifdef BURNINGVIDEO_RENDERER_FAST + u32 dIndex = ( line.y & 3 ) << 2; + +#else + // + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; +#endif + + + for ( ;i <= dx; i++ ) + { +#ifdef IPOL_W + if ( line.w[0] >= z[i] ) + { + z[i] = line.w[0]; +#else + if ( line.z[0] < z[i] ) + { + z[i] = line.z[0]; +#endif + +#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + f32 inversew = fix_inverse32 ( line.w[0] ); +#else + f32 inversew = FIX_POINT_F32_MUL; +#endif + + + +#ifdef BURNINGVIDEO_RENDERER_FAST + + const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; + + dst[i] = PixelMul32 ( + getTexel_plain ( &IT[0], d + f32_to_fixPoint ( line.t0[0].x,inversew), + d + f32_to_fixPoint ( line.t0[0].y,inversew) ), + getTexel_plain ( &IT[1], d + f32_to_fixPoint ( line.t1[0].x,inversew), + d + f32_to_fixPoint ( line.t1[0].y,inversew) ) + ); + + +#else + + + getSample_texture ( r0, g0, b0, &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), f32_to_fixPoint ( line.t0[0].y,inversew) ); + getSample_texture ( r1, g1, b1, &IT[1], f32_to_fixPoint ( line.t1[0].x,inversew), f32_to_fixPoint ( line.t1[0].y,inversew) ); + + dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1 ( r0, r1 ) ), + clampfix_maxcolor ( imulFix_tex1 ( g0, g1 ) ), + clampfix_maxcolor ( imulFix_tex1 ( b0, b1 ) ) + ); +#endif + + } + +#ifdef IPOL_W + line.w[0] += line.w[1]; +#else + line.z[0] += line.z[1]; +#endif + line.t0[0] += line.t0[1]; + line.t1[0] += line.t1[1]; + } + +} + + + + + +void CTRTextureLightMap2_M1::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + sScanConvertData scan; + + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + // query access to TexMaps + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + + // rasterize upper sub-triangle + if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear2 (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + //if ( (f32) 0.0 != scan.invDeltaY[2] ) + if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) + { + // advance to middle point + if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear2 (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + +//! creates a flat triangle renderer +IBurningShader* createTriangleRendererTextureLightMap2_M1(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRTextureLightMap2_M1(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CTRTextureLightMap2_M2.cpp b/src/dep/src/irrlicht/CTRTextureLightMap2_M2.cpp index 0668815..390d940 100644 --- a/src/dep/src/irrlicht/CTRTextureLightMap2_M2.cpp +++ b/src/dep/src/irrlicht/CTRTextureLightMap2_M2.cpp @@ -1,674 +1,674 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - -namespace irr -{ - -namespace video -{ - -class CTRTextureLightMap2_M2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureLightMap2_M2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear2 (); - - sScanLineData line; - -}; - -//! constructor -CTRTextureLightMap2_M2::CTRTextureLightMap2_M2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureLightMap2_M2"); - #endif -} - -/*! -*/ -REALINLINE void CTRTextureLightMap2_M2::scanline_bilinear2 () -{ - tVideoSample *dst; - fp24 *z; - - s32 xStart; - s32 xEnd; - s32 dx; - s32 i; - - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - - // search z-buffer for first not occulled pixel - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; - - // subTexel - const f32 subPixel = ( (f32) xStart ) - line.x[0]; - -#ifdef IPOL_W - const f32 b = (line.w[1] - line.w[0]) * invDeltaX; - f32 a = line.w[0] + ( b * subPixel ); - - i = 0; - - while ( a <= z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.w[0] = a; - line.w[1] = b; -#else - const f32 b = (line.z[1] - line.z[0]) * invDeltaX; - f32 a = line.z[0] + ( b * subPixel ); - - i = 0; - - while ( a > z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.z[0] = a; - line.z[1] = b; -#endif - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - - a = (f32) i + subPixel; - - line.t0[1] = (line.t0[1] - line.t0[0]) * invDeltaX; - line.t1[1] = (line.t1[1] - line.t1[0]) * invDeltaX; - - line.t0[0] += line.t0[1] * a; - line.t1[0] += line.t1[1] * a; - - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - -#else - // - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; -#endif - - - for ( ;i <= dx; i++ ) - { -#ifdef IPOL_W - if ( line.w[0] >= z[i] ) - { - z[i] = line.w[0]; -#else - if ( line.z[0] < z[i] ) - { - z[i] = line.z[0]; -#endif - -#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - f32 inversew = fix_inverse32 ( line.w[0] ); -#else - f32 inversew = FIX_POINT_F32_MUL; -#endif - - - -#ifdef BURNINGVIDEO_RENDERER_FAST - - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - - getSample_texture ( r0, g0, b0, &IT[0], d + f32_to_fixPoint ( line.t0[0].x,inversew), d + f32_to_fixPoint ( line.t0[0].y,inversew) ); - getSample_texture ( r1, g1, b1, &IT[1], d + f32_to_fixPoint ( line.t1[0].x,inversew), d + f32_to_fixPoint ( line.t1[0].y,inversew) ); -#else - getSample_texture ( r0, g0, b0, &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), f32_to_fixPoint ( line.t0[0].y,inversew) ); - getSample_texture ( r1, g1, b1, &IT[1], f32_to_fixPoint ( line.t1[0].x,inversew), f32_to_fixPoint ( line.t1[0].y,inversew) ); - -#endif - - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ), - clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ), - clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) ) - ); - } - -#ifdef IPOL_W - line.w[0] += line.w[1]; -#else - line.z[0] += line.z[1]; -#endif - line.t0[0] += line.t0[1]; - line.t1[0] += line.t1[1]; - } - -} - - - -void CTRTextureLightMap2_M2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - sScanConvertData scan; - - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // query access to TexMaps - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - - // rasterize upper sub-triangle - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear2 (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - //if ( (f32) 0.0 != scan.invDeltaY[2] ) - if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) - { - // advance to middle point - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear2 (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - - - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureLightMap2_M2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureLightMap2_M2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +#define WRITE_W + +//#define IPOL_C0 +#define IPOL_T0 +#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + +namespace irr +{ + +namespace video +{ + +class CTRTextureLightMap2_M2 : public IBurningShader +{ +public: + + //! constructor + CTRTextureLightMap2_M2(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + +private: + void scanline_bilinear2 (); + + sScanLineData line; + +}; + +//! constructor +CTRTextureLightMap2_M2::CTRTextureLightMap2_M2(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureLightMap2_M2"); + #endif +} + +/*! +*/ +REALINLINE void CTRTextureLightMap2_M2::scanline_bilinear2 () +{ + tVideoSample *dst; + fp24 *z; + + s32 xStart; + s32 xEnd; + s32 dx; + s32 i; + + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + + // search z-buffer for first not occulled pixel + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; + + // subTexel + const f32 subPixel = ( (f32) xStart ) - line.x[0]; + +#ifdef IPOL_W + const f32 b = (line.w[1] - line.w[0]) * invDeltaX; + f32 a = line.w[0] + ( b * subPixel ); + + i = 0; + + while ( a <= z[i] ) + { + a += b; + + i += 1; + if ( i > dx ) + return; + + } + + // lazy setup rest of scanline + + line.w[0] = a; + line.w[1] = b; +#else + const f32 b = (line.z[1] - line.z[0]) * invDeltaX; + f32 a = line.z[0] + ( b * subPixel ); + + i = 0; + + while ( a > z[i] ) + { + a += b; + + i += 1; + if ( i > dx ) + return; + + } + + // lazy setup rest of scanline + + line.z[0] = a; + line.z[1] = b; +#endif + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + + a = (f32) i + subPixel; + + line.t0[1] = (line.t0[1] - line.t0[0]) * invDeltaX; + line.t1[1] = (line.t1[1] - line.t1[0]) * invDeltaX; + + line.t0[0] += line.t0[1] * a; + line.t1[0] += line.t1[1] * a; + + +#ifdef BURNINGVIDEO_RENDERER_FAST + u32 dIndex = ( line.y & 3 ) << 2; + + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; + +#else + // + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; +#endif + + + for ( ;i <= dx; i++ ) + { +#ifdef IPOL_W + if ( line.w[0] >= z[i] ) + { + z[i] = line.w[0]; +#else + if ( line.z[0] < z[i] ) + { + z[i] = line.z[0]; +#endif + +#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + f32 inversew = fix_inverse32 ( line.w[0] ); +#else + f32 inversew = FIX_POINT_F32_MUL; +#endif + + + +#ifdef BURNINGVIDEO_RENDERER_FAST + + const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; + + getSample_texture ( r0, g0, b0, &IT[0], d + f32_to_fixPoint ( line.t0[0].x,inversew), d + f32_to_fixPoint ( line.t0[0].y,inversew) ); + getSample_texture ( r1, g1, b1, &IT[1], d + f32_to_fixPoint ( line.t1[0].x,inversew), d + f32_to_fixPoint ( line.t1[0].y,inversew) ); +#else + getSample_texture ( r0, g0, b0, &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), f32_to_fixPoint ( line.t0[0].y,inversew) ); + getSample_texture ( r1, g1, b1, &IT[1], f32_to_fixPoint ( line.t1[0].x,inversew), f32_to_fixPoint ( line.t1[0].y,inversew) ); + +#endif + + dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ), + clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ), + clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) ) + ); + } + +#ifdef IPOL_W + line.w[0] += line.w[1]; +#else + line.z[0] += line.z[1]; +#endif + line.t0[0] += line.t0[1]; + line.t1[0] += line.t1[1]; + } + +} + + + +void CTRTextureLightMap2_M2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + sScanConvertData scan; + + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + // query access to TexMaps + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + + // rasterize upper sub-triangle + if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear2 (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + //if ( (f32) 0.0 != scan.invDeltaY[2] ) + if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) + { + // advance to middle point + if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear2 (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + + + +//! creates a flat triangle renderer +IBurningShader* createTriangleRendererTextureLightMap2_M2(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRTextureLightMap2_M2(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + + diff --git a/src/dep/src/irrlicht/CTRTextureLightMap2_M4.cpp b/src/dep/src/irrlicht/CTRTextureLightMap2_M4.cpp index 714082c..e8e6f6d 100644 --- a/src/dep/src/irrlicht/CTRTextureLightMap2_M4.cpp +++ b/src/dep/src/irrlicht/CTRTextureLightMap2_M4.cpp @@ -1,1404 +1,1404 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - -namespace irr -{ - -namespace video -{ - -class CTRTextureLightMap2_M4 : public IBurningShader -{ -public: - - //! constructor - CTRTextureLightMap2_M4(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - - void drawTriangle_Min ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - void drawTriangle_Mag ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - void scanline_bilinear (); - void scanline_bilinear2_mag (); - void scanline_bilinear2_min (); - - sScanLineData line; - -}; - -//! constructor -CTRTextureLightMap2_M4::CTRTextureLightMap2_M4(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureLightMap2_M4"); - #endif -} - -/*! -*/ -REALINLINE void CTRTextureLightMap2_M4::scanline_bilinear2_mag () -{ - tVideoSample *dst; - fp24 *z; - - s32 xStart; - s32 xEnd; - s32 dx; - s32 i; - - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - - // search z-buffer for first not occulled pixel - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; - - // subTexel - const f32 subPixel = ( (f32) xStart ) - line.x[0]; - -#ifdef IPOL_W - const fp24 b = (line.w[1] - line.w[0]) * invDeltaX; - fp24 a = line.w[0] + ( b * subPixel ); - - i = 0; - - while ( a <= z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.w[0] = a; - line.w[1] = b; -#else - const f32 b = (line.z[1] - line.z[0]) * invDeltaX; - f32 a = line.z[0] + ( b * subPixel ); - - i = 0; - - while ( a > z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.z[0] = a; - line.z[1] = b; -#endif - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - - a = (f32) i + subPixel; - - line.t0[1] = (line.t0[1] - line.t0[0]) * invDeltaX; - line.t1[1] = (line.t1[1] - line.t1[0]) * invDeltaX; - - line.t0[0] += line.t0[1] * a; - line.t1[0] += line.t1[1] * a; - - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - -#else - // - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; -#endif - - - for ( ;i <= dx; i++ ) - { -#ifdef IPOL_W - if ( line.w[0] >= z[i] ) - { - z[i] = line.w[0]; -#else - if ( line.z[0] < z[i] ) - { - z[i] = line.z[0]; -#endif - -#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - f32 inversew = fix_inverse32 ( line.w[0] ); -#else - f32 inversew = FIX_POINT_F32_MUL; -#endif - - - -#ifdef BURNINGVIDEO_RENDERER_FAST - - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - - getSample_texture ( r0, g0, b0, &IT[0], d + f32_to_fixPoint ( line.t0[0].x,inversew), d + f32_to_fixPoint ( line.t0[0].y,inversew) ); - getSample_texture ( r1, g1, b1, &IT[1], d + f32_to_fixPoint ( line.t1[0].x,inversew), d + f32_to_fixPoint ( line.t1[0].y,inversew) ); -#else - getSample_texture ( r0, g0, b0, &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), f32_to_fixPoint ( line.t0[0].y,inversew) ); - getSample_texture ( r1, g1, b1, &IT[1], f32_to_fixPoint ( line.t1[0].x,inversew), f32_to_fixPoint ( line.t1[0].y,inversew) ); - -#endif - - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ), - clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ), - clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ) - ); - } - -#ifdef IPOL_W - line.w[0] += line.w[1]; -#else - line.z[0] += line.z[1]; -#endif - line.t0[0] += line.t0[1]; - line.t1[0] += line.t1[1]; - } - -} - -/*! -*/ -REALINLINE void CTRTextureLightMap2_M4::scanline_bilinear2_min () -{ - tVideoSample *dst; - fp24 *z; - - s32 xStart; - s32 xEnd; - s32 dx; - s32 i; - - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - - // search z-buffer for first not occulled pixel - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; - - // subTexel - const f32 subPixel = ( (f32) xStart ) - line.x[0]; - -#ifdef IPOL_W - const f32 b = (line.w[1] - line.w[0]) * invDeltaX; - f32 a = line.w[0] + ( b * subPixel ); - - i = 0; - - while ( a <= z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.w[0] = a; - line.w[1] = b; -#else - const f32 b = (line.z[1] - line.z[0]) * invDeltaX; - f32 a = line.z[0] + ( b * subPixel ); - - i = 0; - - while ( a > z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.z[0] = a; - line.z[1] = b; -#endif - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - - a = (f32) i + subPixel; - - line.t0[1] = (line.t0[1] - line.t0[0]) * invDeltaX; - line.t1[1] = (line.t1[1] - line.t1[0]) * invDeltaX; - - line.t0[0] += line.t0[1] * a; - line.t1[0] += line.t1[1] * a; - - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - - - for ( ;i <= dx; i++ ) - { -#ifdef IPOL_W - if ( line.w[0] >= z[i] ) - { - z[i] = line.w[0]; -#else - if ( line.z[0] < z[i] ) - { - z[i] = line.z[0]; -#endif - -#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - f32 inversew = fix_inverse32 ( line.w[0] ); -#else - f32 inversew = FIX_POINT_F32_MUL; -#endif - - - getTexel_fix ( r0, g0, b0, &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), f32_to_fixPoint ( line.t0[0].y,inversew) ); - getTexel_fix ( r1, g1, b1, &IT[1], f32_to_fixPoint ( line.t1[0].x,inversew), f32_to_fixPoint ( line.t1[0].y,inversew) ); - - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ), - clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ), - clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ) - ); - } - -#ifdef IPOL_W - line.w[0] += line.w[1]; -#else - line.z[0] += line.z[1]; -#endif - line.t0[0] += line.t0[1]; - line.t1[0] += line.t1[1]; - } - -} - - -#if 0 -/*! -*/ -REALINLINE void CTRTextureLightMap2_M4::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef USE_ZBUFFER - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - - tFixPointu tx0, tx1; - tFixPointu ty0, ty1; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; - -#ifdef IPOL_C0 - tFixPoint r3, g3, b3; -#endif - - for ( s32 i = 0; i <= dx; i++ ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - { -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - - tx0 = f32_to_fixPoint ( line.t0[0].x,inversew); - ty0 = f32_to_fixPoint ( line.t0[0].y,inversew); - tx1 = f32_to_fixPoint ( line.t1[0].x,inversew); - ty1 = f32_to_fixPoint ( line.t1[0].y,inversew); - -#ifdef IPOL_C0 - r3 = f32_to_fixPoint ( line.c[0].y ,inversew ); - g3 = f32_to_fixPoint ( line.c[0].z ,inversew ); - b3 = f32_to_fixPoint ( line.c[0].w ,inversew ); -#endif - -#else - tx0 = f32_to_fixPoint ( line.t0[0].x ); - ty0 = f32_to_fixPoint ( line.t0[0].y ); - tx1 = f32_to_fixPoint ( line.t1[0].x ); - ty1 = f32_to_fixPoint ( line.t1[0].y ); - -#endif - getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); - getSample_texture ( r1, g1, b1, &IT[1], tx1, ty1 ); - -#ifdef IPOL_C0 - r2 = imulFix ( r0, r3 ); - g2 = imulFix ( g0, g3 ); - b2 = imulFix ( b0, b3 ); - - r2 = clampfix_maxcolor ( imulFix_tex4 ( r2, r1 ) ); - g2 = clampfix_maxcolor ( imulFix_tex4 ( g2, g1 ) ); - b2 = clampfix_maxcolor ( imulFix_tex4 ( b2, b1 ) ); -/* - r2 = r3 << 8; - g2 = g3 << 8; - b2 = b3 << 8; -*/ -#else - r2 = clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ); - g2 = clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ); - b2 = clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ); -#endif - - - dst[i] = fix_to_color ( r2, g2, b2 ); - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1; -#endif - } - -} -#endif - - -#ifdef BURNINGVIDEO_RENDERER_FAST - -void CTRTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - if ( IT[0].lodLevel <= 2 ) - drawTriangle_Mag ( a, b, c ); - else - drawTriangle_Min ( a, b, c ); -} - -void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - sScanConvertData scan; - - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // query access to TexMaps - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - - // rasterize upper sub-triangle - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear2_min (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - //if ( (f32) 0.0 != scan.invDeltaY[2] ) - if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) - { - // advance to middle point - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear2_min (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - -void CTRTextureLightMap2_M4::drawTriangle_Mag ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) - -#else - -void CTRTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) - -#endif - -{ - sScanConvertData scan; - - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // query access to TexMaps - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - - // rasterize upper sub-triangle - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear2_mag (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - //if ( (f32) 0.0 != scan.invDeltaY[2] ) - if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) - { - // advance to middle point - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear2_mag (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureLightMap2_M4(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureLightMap2_M4(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +#define WRITE_W + +//#define IPOL_C0 +#define IPOL_T0 +#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + +namespace irr +{ + +namespace video +{ + +class CTRTextureLightMap2_M4 : public IBurningShader +{ +public: + + //! constructor + CTRTextureLightMap2_M4(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + +private: + + void drawTriangle_Min ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + void drawTriangle_Mag ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + void scanline_bilinear (); + void scanline_bilinear2_mag (); + void scanline_bilinear2_min (); + + sScanLineData line; + +}; + +//! constructor +CTRTextureLightMap2_M4::CTRTextureLightMap2_M4(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureLightMap2_M4"); + #endif +} + +/*! +*/ +REALINLINE void CTRTextureLightMap2_M4::scanline_bilinear2_mag () +{ + tVideoSample *dst; + fp24 *z; + + s32 xStart; + s32 xEnd; + s32 dx; + s32 i; + + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + + // search z-buffer for first not occulled pixel + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; + + // subTexel + const f32 subPixel = ( (f32) xStart ) - line.x[0]; + +#ifdef IPOL_W + const fp24 b = (line.w[1] - line.w[0]) * invDeltaX; + fp24 a = line.w[0] + ( b * subPixel ); + + i = 0; + + while ( a <= z[i] ) + { + a += b; + + i += 1; + if ( i > dx ) + return; + + } + + // lazy setup rest of scanline + + line.w[0] = a; + line.w[1] = b; +#else + const f32 b = (line.z[1] - line.z[0]) * invDeltaX; + f32 a = line.z[0] + ( b * subPixel ); + + i = 0; + + while ( a > z[i] ) + { + a += b; + + i += 1; + if ( i > dx ) + return; + + } + + // lazy setup rest of scanline + + line.z[0] = a; + line.z[1] = b; +#endif + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + + a = (f32) i + subPixel; + + line.t0[1] = (line.t0[1] - line.t0[0]) * invDeltaX; + line.t1[1] = (line.t1[1] - line.t1[0]) * invDeltaX; + + line.t0[0] += line.t0[1] * a; + line.t1[0] += line.t1[1] * a; + + +#ifdef BURNINGVIDEO_RENDERER_FAST + u32 dIndex = ( line.y & 3 ) << 2; + + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; + +#else + // + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; +#endif + + + for ( ;i <= dx; i++ ) + { +#ifdef IPOL_W + if ( line.w[0] >= z[i] ) + { + z[i] = line.w[0]; +#else + if ( line.z[0] < z[i] ) + { + z[i] = line.z[0]; +#endif + +#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + f32 inversew = fix_inverse32 ( line.w[0] ); +#else + f32 inversew = FIX_POINT_F32_MUL; +#endif + + + +#ifdef BURNINGVIDEO_RENDERER_FAST + + const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; + + getSample_texture ( r0, g0, b0, &IT[0], d + f32_to_fixPoint ( line.t0[0].x,inversew), d + f32_to_fixPoint ( line.t0[0].y,inversew) ); + getSample_texture ( r1, g1, b1, &IT[1], d + f32_to_fixPoint ( line.t1[0].x,inversew), d + f32_to_fixPoint ( line.t1[0].y,inversew) ); +#else + getSample_texture ( r0, g0, b0, &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), f32_to_fixPoint ( line.t0[0].y,inversew) ); + getSample_texture ( r1, g1, b1, &IT[1], f32_to_fixPoint ( line.t1[0].x,inversew), f32_to_fixPoint ( line.t1[0].y,inversew) ); + +#endif + + dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ), + clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ), + clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ) + ); + } + +#ifdef IPOL_W + line.w[0] += line.w[1]; +#else + line.z[0] += line.z[1]; +#endif + line.t0[0] += line.t0[1]; + line.t1[0] += line.t1[1]; + } + +} + +/*! +*/ +REALINLINE void CTRTextureLightMap2_M4::scanline_bilinear2_min () +{ + tVideoSample *dst; + fp24 *z; + + s32 xStart; + s32 xEnd; + s32 dx; + s32 i; + + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + + // search z-buffer for first not occulled pixel + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; + + // subTexel + const f32 subPixel = ( (f32) xStart ) - line.x[0]; + +#ifdef IPOL_W + const f32 b = (line.w[1] - line.w[0]) * invDeltaX; + f32 a = line.w[0] + ( b * subPixel ); + + i = 0; + + while ( a <= z[i] ) + { + a += b; + + i += 1; + if ( i > dx ) + return; + + } + + // lazy setup rest of scanline + + line.w[0] = a; + line.w[1] = b; +#else + const f32 b = (line.z[1] - line.z[0]) * invDeltaX; + f32 a = line.z[0] + ( b * subPixel ); + + i = 0; + + while ( a > z[i] ) + { + a += b; + + i += 1; + if ( i > dx ) + return; + + } + + // lazy setup rest of scanline + + line.z[0] = a; + line.z[1] = b; +#endif + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + + a = (f32) i + subPixel; + + line.t0[1] = (line.t0[1] - line.t0[0]) * invDeltaX; + line.t1[1] = (line.t1[1] - line.t1[0]) * invDeltaX; + + line.t0[0] += line.t0[1] * a; + line.t1[0] += line.t1[1] * a; + + + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; + + + for ( ;i <= dx; i++ ) + { +#ifdef IPOL_W + if ( line.w[0] >= z[i] ) + { + z[i] = line.w[0]; +#else + if ( line.z[0] < z[i] ) + { + z[i] = line.z[0]; +#endif + +#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + f32 inversew = fix_inverse32 ( line.w[0] ); +#else + f32 inversew = FIX_POINT_F32_MUL; +#endif + + + getTexel_fix ( r0, g0, b0, &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), f32_to_fixPoint ( line.t0[0].y,inversew) ); + getTexel_fix ( r1, g1, b1, &IT[1], f32_to_fixPoint ( line.t1[0].x,inversew), f32_to_fixPoint ( line.t1[0].y,inversew) ); + + dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ), + clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ), + clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ) + ); + } + +#ifdef IPOL_W + line.w[0] += line.w[1]; +#else + line.z[0] += line.z[1]; +#endif + line.t0[0] += line.t0[1]; + line.t1[0] += line.t1[1]; + } + +} + + +#if 0 +/*! +*/ +REALINLINE void CTRTextureLightMap2_M4::scanline_bilinear () +{ + tVideoSample *dst; + +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef USE_ZBUFFER + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + +#ifdef INVERSE_W + f32 inversew; +#endif + + tFixPointu tx0, tx1; + tFixPointu ty0, ty1; + + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; + tFixPoint r2, g2, b2; + +#ifdef IPOL_C0 + tFixPoint r3, g3, b3; +#endif + + for ( s32 i = 0; i <= dx; i++ ) + { +#ifdef CMP_Z + if ( line.z[0] < z[i] ) +#endif +#ifdef CMP_W + if ( line.w[0] >= z[i] ) +#endif + { +#ifdef INVERSE_W + inversew = fix_inverse32 ( line.w[0] ); + + tx0 = f32_to_fixPoint ( line.t0[0].x,inversew); + ty0 = f32_to_fixPoint ( line.t0[0].y,inversew); + tx1 = f32_to_fixPoint ( line.t1[0].x,inversew); + ty1 = f32_to_fixPoint ( line.t1[0].y,inversew); + +#ifdef IPOL_C0 + r3 = f32_to_fixPoint ( line.c[0].y ,inversew ); + g3 = f32_to_fixPoint ( line.c[0].z ,inversew ); + b3 = f32_to_fixPoint ( line.c[0].w ,inversew ); +#endif + +#else + tx0 = f32_to_fixPoint ( line.t0[0].x ); + ty0 = f32_to_fixPoint ( line.t0[0].y ); + tx1 = f32_to_fixPoint ( line.t1[0].x ); + ty1 = f32_to_fixPoint ( line.t1[0].y ); + +#endif + getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); + getSample_texture ( r1, g1, b1, &IT[1], tx1, ty1 ); + +#ifdef IPOL_C0 + r2 = imulFix ( r0, r3 ); + g2 = imulFix ( g0, g3 ); + b2 = imulFix ( b0, b3 ); + + r2 = clampfix_maxcolor ( imulFix_tex4 ( r2, r1 ) ); + g2 = clampfix_maxcolor ( imulFix_tex4 ( g2, g1 ) ); + b2 = clampfix_maxcolor ( imulFix_tex4 ( b2, b1 ) ); +/* + r2 = r3 << 8; + g2 = g3 << 8; + b2 = b3 << 8; +*/ +#else + r2 = clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ); + g2 = clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ); + b2 = clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ); +#endif + + + dst[i] = fix_to_color ( r2, g2, b2 ); + +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1; +#endif + } + +} +#endif + + +#ifdef BURNINGVIDEO_RENDERER_FAST + +void CTRTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + if ( IT[0].lodLevel <= 2 ) + drawTriangle_Mag ( a, b, c ); + else + drawTriangle_Min ( a, b, c ); +} + +void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + sScanConvertData scan; + + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + // query access to TexMaps + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + + // rasterize upper sub-triangle + if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear2_min (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + //if ( (f32) 0.0 != scan.invDeltaY[2] ) + if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) + { + // advance to middle point + if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear2_min (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + +void CTRTextureLightMap2_M4::drawTriangle_Mag ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) + +#else + +void CTRTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) + +#endif + +{ + sScanConvertData scan; + + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) + return; + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + // query access to TexMaps + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + + // rasterize upper sub-triangle + if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear2_mag (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + //if ( (f32) 0.0 != scan.invDeltaY[2] ) + if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) + { + // advance to middle point + if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear2_mag (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + + +//! creates a flat triangle renderer +IBurningShader* createTriangleRendererTextureLightMap2_M4(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRTextureLightMap2_M4(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + + diff --git a/src/dep/src/irrlicht/CTRTextureLightMapGouraud2_M4.cpp b/src/dep/src/irrlicht/CTRTextureLightMapGouraud2_M4.cpp index 8e20b09..ebf3659 100644 --- a/src/dep/src/irrlicht/CTRTextureLightMapGouraud2_M4.cpp +++ b/src/dep/src/irrlicht/CTRTextureLightMapGouraud2_M4.cpp @@ -1,718 +1,718 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -#define IPOL_C0 -#define IPOL_T0 -#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - -namespace irr -{ - -namespace video -{ - -class CTRGTextureLightMap2_M4 : public IBurningShader -{ -public: - - //! constructor - CTRGTextureLightMap2_M4(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRGTextureLightMap2_M4::CTRGTextureLightMap2_M4(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRGTextureLightMap2_M4"); - #endif -} - - - -/*! -*/ -void CTRGTextureLightMap2_M4::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT0; -#endif -#ifdef IPOL_T1 - sVec2 slopeT1; -#endif - - // apply top-left fill-convention, left - xStart = irr::core::ceil32( line.x[0] ); - xEnd = irr::core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0 * subPixel; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1 * subPixel; -#endif -#endif - - dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; - -#ifdef USE_ZBUFFER - z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - - tFixPoint tx0, tx1; - tFixPoint ty0, ty1; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; - -#ifdef IPOL_C0 - tFixPoint r3, g3, b3; -#endif - - for ( s32 i = 0; i <= dx; i++ ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - { -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - - tx0 = f32_to_fixPoint ( line.t0[0].x,inversew); - ty0 = f32_to_fixPoint ( line.t0[0].y,inversew); - tx1 = f32_to_fixPoint ( line.t1[0].x,inversew); - ty1 = f32_to_fixPoint ( line.t1[0].y,inversew); - -#ifdef IPOL_C0 - r3 = f32_to_fixPoint ( line.c[0].y ,inversew ); - g3 = f32_to_fixPoint ( line.c[0].z ,inversew ); - b3 = f32_to_fixPoint ( line.c[0].w ,inversew ); -#endif - -#else - tx0 = f32_to_fixPoint ( line.t0[0].x ); - ty0 = f32_to_fixPoint ( line.t0[0].y ); - tx1 = f32_to_fixPoint ( line.t1[0].x ); - ty1 = f32_to_fixPoint ( line.t1[0].y ); - -#endif - getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); - getSample_texture ( r1, g1, b1, &IT[1], tx1, ty1 ); - -#ifdef IPOL_C0 - r2 = imulFix ( r0, r3 ); - g2 = imulFix ( g0, g3 ); - b2 = imulFix ( b0, b3 ); - - r2 = clampfix_maxcolor ( imulFix_tex4 ( r2, r1 ) ); - g2 = clampfix_maxcolor ( imulFix_tex4 ( g2, g1 ) ); - b2 = clampfix_maxcolor ( imulFix_tex4 ( b2, b1 ) ); -/* - r2 = r3 << 8; - g2 = g3 << 8; - b2 = b3 << 8; -*/ -#else - r2 = clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ); - g2 = clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ); - b2 = clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ); -#endif - - - dst[i] = fix_to_color ( r2, g2, b2 ); - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t0[0] += slopeT0; -#endif -#ifdef IPOL_T1 - line.t1[0] += slopeT1; -#endif - } - -} - -void CTRGTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - - if ( F32_LOWER_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t0[0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t1[0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // query access to TexMaps - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - -#ifdef IPOL_T0 - IT[0].data = (tVideoSample*)IT[0].Texture->lock(); -#endif - -#ifdef IPOL_T1 - IT[1].data = (tVideoSample*)IT[1].Texture->lock(); -#endif - - - - // rasterize upper sub-triangle - //if ( (f32) 0.0 != scan.invDeltaY[1] ) - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t0[1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t1[1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( a->Pos.y ); - yEnd = irr::core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - // rasterize lower sub-triangle - //if ( (f32) 0.0 != scan.invDeltaY[2] ) - if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) - { - // advance to middle point - //if( (f32) 0.0 != scan.invDeltaY[1] ) - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t0[1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t1[1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = irr::core::ceil32( b->Pos.y ); - yEnd = irr::core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0] * subPixel; - scan.t0[1] += scan.slopeT0[1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0] * subPixel; - scan.t1[1] += scan.slopeT1[1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t0[scan.left] = scan.t0[0]; - line.t0[scan.right] = scan.t0[1]; -#endif - -#ifdef IPOL_T1 - line.t1[scan.left] = scan.t1[0]; - line.t1[scan.right] = scan.t1[1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t0[0] += scan.slopeT0[0]; - scan.t0[1] += scan.slopeT0[1]; -#endif - -#ifdef IPOL_T1 - scan.t1[0] += scan.slopeT1[0]; - scan.t1[1] += scan.slopeT1[1]; -#endif - - } - } - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -#ifdef IPOL_T0 - IT[0].Texture->unlock(); -#endif - -#ifdef IPOL_T1 - IT[1].Texture->unlock(); -#endif - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererGTextureLightMap2_M4(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRGTextureLightMap2_M4(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +#define WRITE_W + +#define IPOL_C0 +#define IPOL_T0 +#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #undef IPOL_C0 +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + +namespace irr +{ + +namespace video +{ + +class CTRGTextureLightMap2_M4 : public IBurningShader +{ +public: + + //! constructor + CTRGTextureLightMap2_M4(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + + +private: + void scanline_bilinear (); + + sScanConvertData scan; + sScanLineData line; + +}; + +//! constructor +CTRGTextureLightMap2_M4::CTRGTextureLightMap2_M4(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRGTextureLightMap2_M4"); + #endif +} + + + +/*! +*/ +void CTRGTextureLightMap2_M4::scanline_bilinear () +{ + tVideoSample *dst; + +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT0; +#endif +#ifdef IPOL_T1 + sVec2 slopeT1; +#endif + + // apply top-left fill-convention, left + xStart = irr::core::ceil32( line.x[0] ); + xEnd = irr::core::ceil32( line.x[1] ) - 1; + + dx = xEnd - xStart; + + if ( dx < 0 ) + return; + + // slopes + const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ( (f32) xStart ) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0 * subPixel; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1 * subPixel; +#endif +#endif + + dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; + +#ifdef USE_ZBUFFER + z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; +#endif + + +#ifdef INVERSE_W + f32 inversew; +#endif + + tFixPoint tx0, tx1; + tFixPoint ty0, ty1; + + tFixPoint r0, g0, b0; + tFixPoint r1, g1, b1; + tFixPoint r2, g2, b2; + +#ifdef IPOL_C0 + tFixPoint r3, g3, b3; +#endif + + for ( s32 i = 0; i <= dx; i++ ) + { +#ifdef CMP_Z + if ( line.z[0] < z[i] ) +#endif +#ifdef CMP_W + if ( line.w[0] >= z[i] ) +#endif + { +#ifdef INVERSE_W + inversew = fix_inverse32 ( line.w[0] ); + + tx0 = f32_to_fixPoint ( line.t0[0].x,inversew); + ty0 = f32_to_fixPoint ( line.t0[0].y,inversew); + tx1 = f32_to_fixPoint ( line.t1[0].x,inversew); + ty1 = f32_to_fixPoint ( line.t1[0].y,inversew); + +#ifdef IPOL_C0 + r3 = f32_to_fixPoint ( line.c[0].y ,inversew ); + g3 = f32_to_fixPoint ( line.c[0].z ,inversew ); + b3 = f32_to_fixPoint ( line.c[0].w ,inversew ); +#endif + +#else + tx0 = f32_to_fixPoint ( line.t0[0].x ); + ty0 = f32_to_fixPoint ( line.t0[0].y ); + tx1 = f32_to_fixPoint ( line.t1[0].x ); + ty1 = f32_to_fixPoint ( line.t1[0].y ); + +#endif + getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); + getSample_texture ( r1, g1, b1, &IT[1], tx1, ty1 ); + +#ifdef IPOL_C0 + r2 = imulFix ( r0, r3 ); + g2 = imulFix ( g0, g3 ); + b2 = imulFix ( b0, b3 ); + + r2 = clampfix_maxcolor ( imulFix_tex4 ( r2, r1 ) ); + g2 = clampfix_maxcolor ( imulFix_tex4 ( g2, g1 ) ); + b2 = clampfix_maxcolor ( imulFix_tex4 ( b2, b1 ) ); +/* + r2 = r3 << 8; + g2 = g3 << 8; + b2 = b3 << 8; +*/ +#else + r2 = clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ); + g2 = clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ); + b2 = clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ); +#endif + + + dst[i] = fix_to_color ( r2, g2, b2 ); + +#ifdef WRITE_Z + z[i] = line.z[0]; +#endif +#ifdef WRITE_W + z[i] = line.w[0]; +#endif + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t0[0] += slopeT0; +#endif +#ifdef IPOL_T1 + line.t1[0] += slopeT1; +#endif + } + +} + +void CTRGTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + // calculate delta y of the edges + scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); + + + if ( F32_LOWER_0 ( scan.invDeltaY[0] ) ) + return; + + + // find if the major edge is left or right aligned + f32 temp[4]; + + temp[0] = a->Pos.x - c->Pos.x; + temp[1] = a->Pos.y - c->Pos.y; + temp[2] = b->Pos.x - a->Pos.x; + temp[3] = b->Pos.y - a->Pos.y; + + scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; + scan.right = 1 - scan.left; + + // calculate slopes for the major edge + scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; + scan.x[0] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; + scan.z[0] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; + scan.w[0] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; + scan.c[0] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; + scan.t0[0] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; + scan.t1[0] = a->Tex[1]; +#endif + + // top left fill convention y run + s32 yStart; + s32 yEnd; + +#ifdef SUBTEXEL + f32 subPixel; +#endif + + // query access to TexMaps + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + +#ifdef IPOL_T0 + IT[0].data = (tVideoSample*)IT[0].Texture->lock(); +#endif + +#ifdef IPOL_T1 + IT[1].data = (tVideoSample*)IT[1].Texture->lock(); +#endif + + + + // rasterize upper sub-triangle + //if ( (f32) 0.0 != scan.invDeltaY[1] ) + if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) + { + // calculate slopes for top edge + scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; + scan.x[1] = a->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; + scan.z[1] = a->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; + scan.w[1] = a->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; + scan.c[1] = a->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; + scan.t0[1] = a->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; + scan.t1[1] = a->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( a->Pos.y ); + yEnd = irr::core::ceil32( b->Pos.y ) - 1; + +#ifdef SUBTEXEL + subPixel = ( (f32) yStart ) - a->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + // rasterize lower sub-triangle + //if ( (f32) 0.0 != scan.invDeltaY[2] ) + if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) + { + // advance to middle point + //if( (f32) 0.0 != scan.invDeltaY[1] ) + if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) + { + temp[0] = b->Pos.y - a->Pos.y; // dy + + scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; +#ifdef IPOL_Z + scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; +#endif +#ifdef IPOL_W + scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; +#endif +#ifdef IPOL_C0 + scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; +#endif +#ifdef IPOL_T0 + scan.t0[0] = a->Tex[0] + scan.slopeT0[0] * temp[0]; +#endif +#ifdef IPOL_T1 + scan.t1[0] = a->Tex[1] + scan.slopeT1[0] * temp[0]; +#endif + + } + + // calculate slopes for bottom edge + scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; + scan.x[1] = b->Pos.x; + +#ifdef IPOL_Z + scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; + scan.z[1] = b->Pos.z; +#endif + +#ifdef IPOL_W + scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; + scan.w[1] = b->Pos.w; +#endif + +#ifdef IPOL_C0 + scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; + scan.c[1] = b->Color[0]; +#endif + +#ifdef IPOL_T0 + scan.slopeT0[1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; + scan.t0[1] = b->Tex[0]; +#endif + +#ifdef IPOL_T1 + scan.slopeT1[1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; + scan.t1[1] = b->Tex[1]; +#endif + + // apply top-left fill convention, top part + yStart = irr::core::ceil32( b->Pos.y ); + yEnd = irr::core::ceil32( c->Pos.y ) - 1; + +#ifdef SUBTEXEL + + subPixel = ( (f32) yStart ) - b->Pos.y; + + // correct to pixel center + scan.x[0] += scan.slopeX[0] * subPixel; + scan.x[1] += scan.slopeX[1] * subPixel; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0] * subPixel; + scan.z[1] += scan.slopeZ[1] * subPixel; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0] * subPixel; + scan.w[1] += scan.slopeW[1] * subPixel; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0] * subPixel; + scan.c[1] += scan.slopeC[1] * subPixel; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0] * subPixel; + scan.t0[1] += scan.slopeT0[1] * subPixel; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0] * subPixel; + scan.t1[1] += scan.slopeT1[1] * subPixel; +#endif + +#endif + + // rasterize the edge scanlines + for( line.y = yStart; line.y <= yEnd; ++line.y) + { + line.x[scan.left] = scan.x[0]; + line.x[scan.right] = scan.x[1]; + +#ifdef IPOL_Z + line.z[scan.left] = scan.z[0]; + line.z[scan.right] = scan.z[1]; +#endif + +#ifdef IPOL_W + line.w[scan.left] = scan.w[0]; + line.w[scan.right] = scan.w[1]; +#endif + +#ifdef IPOL_C0 + line.c[scan.left] = scan.c[0]; + line.c[scan.right] = scan.c[1]; +#endif + +#ifdef IPOL_T0 + line.t0[scan.left] = scan.t0[0]; + line.t0[scan.right] = scan.t0[1]; +#endif + +#ifdef IPOL_T1 + line.t1[scan.left] = scan.t1[0]; + line.t1[scan.right] = scan.t1[1]; +#endif + + // render a scanline + scanline_bilinear (); + + scan.x[0] += scan.slopeX[0]; + scan.x[1] += scan.slopeX[1]; + +#ifdef IPOL_Z + scan.z[0] += scan.slopeZ[0]; + scan.z[1] += scan.slopeZ[1]; +#endif + +#ifdef IPOL_W + scan.w[0] += scan.slopeW[0]; + scan.w[1] += scan.slopeW[1]; +#endif + +#ifdef IPOL_C0 + scan.c[0] += scan.slopeC[0]; + scan.c[1] += scan.slopeC[1]; +#endif + +#ifdef IPOL_T0 + scan.t0[0] += scan.slopeT0[0]; + scan.t0[1] += scan.slopeT0[1]; +#endif + +#ifdef IPOL_T1 + scan.t1[0] += scan.slopeT1[0]; + scan.t1[1] += scan.slopeT1[1]; +#endif + + } + } + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +#ifdef IPOL_T0 + IT[0].Texture->unlock(); +#endif + +#ifdef IPOL_T1 + IT[1].Texture->unlock(); +#endif + +} + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + + +//! creates a flat triangle renderer +IBurningShader* createTriangleRendererGTextureLightMap2_M4(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRGTextureLightMap2_M4(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + + diff --git a/src/dep/src/irrlicht/CTRTextureWire2.cpp b/src/dep/src/irrlicht/CTRTextureWire2.cpp index 18c647f..534b01c 100644 --- a/src/dep/src/irrlicht/CTRTextureWire2.cpp +++ b/src/dep/src/irrlicht/CTRTextureWire2.cpp @@ -1,322 +1,322 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - - -//#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - -namespace irr -{ - -namespace video -{ - -class CTRTextureWire2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureWire2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - virtual void drawLine ( const s4DVertex *a,const s4DVertex *b); - - - -private: - void renderAlphaLine ( const s4DVertex *a,const s4DVertex *b ) const; - void renderLine ( const s4DVertex *a,const s4DVertex *b ) const; - -}; - -//! constructor -CTRTextureWire2::CTRTextureWire2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureWire2"); - #endif -} - - -// swap integer with xor -static inline void swap_xor ( s32 &a, s32 &b ) -{ - a ^= b; - b ^= a; - a ^= b; -} - - -/*! -*/ -void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b ) const -{ - - int pitch0 = SurfaceWidth << VIDEO_SAMPLE_GRANULARITY; - int pitch1 = SurfaceWidth << 2; - - int aposx = (int) a->Pos.x; - int aposy = (int) a->Pos.y; - int bposx = (int) b->Pos.x; - int bposy = (int) b->Pos.y; - - int dx = bposx - aposx; - int dy = bposy - aposy; - - int c; - int m; - int d = 0; - int run; - - tVideoSample *dst; -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - int xInc0 = 1 << VIDEO_SAMPLE_GRANULARITY; - int yInc0 = pitch0; - - int xInc1 = 4; - int yInc1 = pitch1; - - tVideoSample color; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - tFixPoint r0, g0, b0; - getSample_color ( r0, g0, b0, a->Color[0] ); - color = fix_to_color ( r0, g0, b0 ); -#else - color = (tVideoSample) 0xFFFFFFFF; -#endif - - if ( dx < 0 ) - { - xInc0 = - ( 1 << VIDEO_SAMPLE_GRANULARITY); - xInc1 = -4; - dx = -dx; - } - - if ( dy > dx ) - { - swap_xor ( dx, dy ); - swap_xor ( xInc0, yInc0 ); - swap_xor ( xInc1, yInc1 ); - } - - if ( 0 == dx ) - return; - - dst = (tVideoSample*) ( (u8*) lockedSurface + ( aposy * pitch0 ) + (aposx << VIDEO_SAMPLE_GRANULARITY ) ); -#ifdef USE_ZBUFFER - z = (fp24*) ( (u8*) lockedZBuffer + ( aposy * pitch1 ) + (aposx << 2 ) ); -#endif - - c = dx << 1; - m = dy << 1; - -#ifdef IPOL_Z - f32 slopeZ = (b->Pos.z - a->Pos.z) / f32(dx); - f32 dataZ = a->Pos.z; -#endif - -#ifdef IPOL_W - fp24 slopeW = (b->Pos.w - a->Pos.w) / f32( dx ); - fp24 dataW = a->Pos.w; -#endif - - run = dx; - while ( run ) - { -#ifdef CMP_Z - if ( *z >= dataZ ) -#endif -#ifdef CMP_W - if ( dataW >= *z ) -#endif - { -#ifdef WRITE_Z - *z = dataZ; -#endif -#ifdef WRITE_W - *z = dataW; -#endif - - *dst = color; - - } - - dst = (tVideoSample*) ( (u8*) dst + xInc0 ); // x += xInc -#ifdef IPOL_Z - z = (fp24*) ( (u8*) z + xInc1 ); -#endif -#ifdef IPOL_W - z = (fp24*) ( (u8*) z + xInc1 ); -#endif - - d += m; - if ( d > dx ) - { - dst = (tVideoSample*) ( (u8*) dst + yInc0 ); // y += yInc -#ifdef IPOL_Z - z = (fp24*) ( (u8*) z + yInc1 ); -#endif -#ifdef IPOL_W - z = (fp24*) ( (u8*) z + yInc1 ); -#endif - - d -= c; - } - run -= 1; -#ifdef IPOL_Z - dataZ += slopeZ; -#endif -#ifdef IPOL_W - dataW += slopeW; -#endif - - } - -} - -void CTRTextureWire2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - sScanLineData line; - - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - - renderLine ( a, b ); - renderLine ( b, c ); - renderLine ( a, c ); - - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -} - - -void CTRTextureWire2::drawLine ( const s4DVertex *a,const s4DVertex *b) -{ - - // query access to TexMaps - - // sort on height, y - if ( a->Pos.y > b->Pos.y ) swapVertexPointer(&a, &b); - - lockedSurface = (tVideoSample*)RenderTarget->lock(); - -#ifdef USE_ZBUFFER - lockedZBuffer = ZBuffer->lock(); -#endif - - renderLine ( a, b ); - RenderTarget->unlock(); - -#ifdef USE_ZBUFFER - ZBuffer->unlock(); -#endif - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureGouraudWire2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureWire2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "IBurningShader.h" + +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +// compile flag for this file +#undef USE_ZBUFFER +#undef IPOL_Z +#undef CMP_Z +#undef WRITE_Z + +#undef IPOL_W +#undef CMP_W +#undef WRITE_W + +#undef SUBTEXEL +#undef INVERSE_W + +#undef IPOL_C0 +#undef IPOL_T0 +#undef IPOL_T1 + +// define render case +#define SUBTEXEL +#define INVERSE_W + +#define USE_ZBUFFER +#define IPOL_W +#define CMP_W +#define WRITE_W + + +//#define IPOL_C0 +#define IPOL_T0 +//#define IPOL_T1 + +// apply global override +#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef INVERSE_W +#endif + +#ifndef SOFTWARE_DRIVER_2_SUBTEXEL + #undef SUBTEXEL +#endif + +#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) + #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #undef IPOL_W + #endif + #define IPOL_Z + + #ifdef CMP_W + #undef CMP_W + #define CMP_Z + #endif + + #ifdef WRITE_W + #undef WRITE_W + #define WRITE_Z + #endif + +#endif + + +namespace irr +{ + +namespace video +{ + +class CTRTextureWire2 : public IBurningShader +{ +public: + + //! constructor + CTRTextureWire2(IDepthBuffer* zbuffer); + + //! draws an indexed triangle list + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); + virtual void drawLine ( const s4DVertex *a,const s4DVertex *b); + + + +private: + void renderAlphaLine ( const s4DVertex *a,const s4DVertex *b ) const; + void renderLine ( const s4DVertex *a,const s4DVertex *b ) const; + +}; + +//! constructor +CTRTextureWire2::CTRTextureWire2(IDepthBuffer* zbuffer) +: IBurningShader(zbuffer) +{ + #ifdef _DEBUG + setDebugName("CTRTextureWire2"); + #endif +} + + +// swap integer with xor +static inline void swap_xor ( s32 &a, s32 &b ) +{ + a ^= b; + b ^= a; + a ^= b; +} + + +/*! +*/ +void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b ) const +{ + + int pitch0 = SurfaceWidth << VIDEO_SAMPLE_GRANULARITY; + int pitch1 = SurfaceWidth << 2; + + int aposx = (int) a->Pos.x; + int aposy = (int) a->Pos.y; + int bposx = (int) b->Pos.x; + int bposy = (int) b->Pos.y; + + int dx = bposx - aposx; + int dy = bposy - aposy; + + int c; + int m; + int d = 0; + int run; + + tVideoSample *dst; +#ifdef USE_ZBUFFER + fp24 *z; +#endif + + int xInc0 = 1 << VIDEO_SAMPLE_GRANULARITY; + int yInc0 = pitch0; + + int xInc1 = 4; + int yInc1 = pitch1; + + tVideoSample color; + +#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + tFixPoint r0, g0, b0; + getSample_color ( r0, g0, b0, a->Color[0] ); + color = fix_to_color ( r0, g0, b0 ); +#else + color = (tVideoSample) 0xFFFFFFFF; +#endif + + if ( dx < 0 ) + { + xInc0 = - ( 1 << VIDEO_SAMPLE_GRANULARITY); + xInc1 = -4; + dx = -dx; + } + + if ( dy > dx ) + { + swap_xor ( dx, dy ); + swap_xor ( xInc0, yInc0 ); + swap_xor ( xInc1, yInc1 ); + } + + if ( 0 == dx ) + return; + + dst = (tVideoSample*) ( (u8*) lockedSurface + ( aposy * pitch0 ) + (aposx << VIDEO_SAMPLE_GRANULARITY ) ); +#ifdef USE_ZBUFFER + z = (fp24*) ( (u8*) lockedZBuffer + ( aposy * pitch1 ) + (aposx << 2 ) ); +#endif + + c = dx << 1; + m = dy << 1; + +#ifdef IPOL_Z + f32 slopeZ = (b->Pos.z - a->Pos.z) / f32(dx); + f32 dataZ = a->Pos.z; +#endif + +#ifdef IPOL_W + fp24 slopeW = (b->Pos.w - a->Pos.w) / f32( dx ); + fp24 dataW = a->Pos.w; +#endif + + run = dx; + while ( run ) + { +#ifdef CMP_Z + if ( *z >= dataZ ) +#endif +#ifdef CMP_W + if ( dataW >= *z ) +#endif + { +#ifdef WRITE_Z + *z = dataZ; +#endif +#ifdef WRITE_W + *z = dataW; +#endif + + *dst = color; + + } + + dst = (tVideoSample*) ( (u8*) dst + xInc0 ); // x += xInc +#ifdef IPOL_Z + z = (fp24*) ( (u8*) z + xInc1 ); +#endif +#ifdef IPOL_W + z = (fp24*) ( (u8*) z + xInc1 ); +#endif + + d += m; + if ( d > dx ) + { + dst = (tVideoSample*) ( (u8*) dst + yInc0 ); // y += yInc +#ifdef IPOL_Z + z = (fp24*) ( (u8*) z + yInc1 ); +#endif +#ifdef IPOL_W + z = (fp24*) ( (u8*) z + yInc1 ); +#endif + + d -= c; + } + run -= 1; +#ifdef IPOL_Z + dataZ += slopeZ; +#endif +#ifdef IPOL_W + dataW += slopeW; +#endif + + } + +} + +void CTRTextureWire2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +{ + sScanLineData line; + + // sort on height, y + if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); + if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); + if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); + + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + + renderLine ( a, b ); + renderLine ( b, c ); + renderLine ( a, c ); + + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +} + + +void CTRTextureWire2::drawLine ( const s4DVertex *a,const s4DVertex *b) +{ + + // query access to TexMaps + + // sort on height, y + if ( a->Pos.y > b->Pos.y ) swapVertexPointer(&a, &b); + + lockedSurface = (tVideoSample*)RenderTarget->lock(); + +#ifdef USE_ZBUFFER + lockedZBuffer = ZBuffer->lock(); +#endif + + renderLine ( a, b ); + RenderTarget->unlock(); + +#ifdef USE_ZBUFFER + ZBuffer->unlock(); +#endif + +} + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +namespace irr +{ +namespace video +{ + + +//! creates a flat triangle renderer +IBurningShader* createTriangleRendererTextureGouraudWire2(IDepthBuffer* zbuffer) +{ + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CTRTextureWire2(zbuffer); + #else + return 0; + #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +} + + +} // end namespace video +} // end namespace irr + + diff --git a/src/dep/src/irrlicht/CTerrainSceneNode.cpp b/src/dep/src/irrlicht/CTerrainSceneNode.cpp index bf59925..40bf697 100644 --- a/src/dep/src/irrlicht/CTerrainSceneNode.cpp +++ b/src/dep/src/irrlicht/CTerrainSceneNode.cpp @@ -1,1265 +1,1265 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// The code for the TerrainSceneNode is based on the GeoMipMapSceneNode -// developed by Spintz. He made it available for Irrlicht and allowed it to be -// distributed under this licence. I only modified some parts. A lot of thanks go to him. - -#include "CTerrainSceneNode.h" -#include "CTerrainTriangleSelector.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "ICameraSceneNode.h" -#include "SMeshBufferLightMap.h" -#include "SViewFrustum.h" -#include "irrMath.h" -#include "os.h" -#include "IGUIFont.h" - -namespace irr -{ -namespace scene -{ - - //! constructor - CTerrainSceneNode::CTerrainSceneNode(ISceneNode* parent, ISceneManager* mgr, - s32 id, s32 maxLOD, E_TERRAIN_PATCH_SIZE patchSize, const core::vector3df& position, - const core::vector3df& rotation, const core::vector3df& scale) - : ITerrainSceneNode(parent, mgr, id, position, rotation, scale), - TerrainData(patchSize, maxLOD, position, rotation, scale), - VerticesToRender(0), IndicesToRender(0), DynamicSelectorUpdate(false), - OverrideDistanceThreshold(false), UseDefaultRotationPivot(true), - OldCameraPosition(core::vector3df(-99999.9f, -99999.9f, -99999.9f)), - OldCameraRotation(core::vector3df(-99999.9f, -99999.9f, -99999.9f)), - CameraMovementDelta(10.0f), CameraRotationDelta(1.0f) - { - #ifdef _DEBUG - setDebugName("CTerrainSceneNode"); - #endif - - setAutomaticCulling( scene::EAC_OFF ); - } - - //! destructor - CTerrainSceneNode::~CTerrainSceneNode ( ) - { - if (TerrainData.LODDistanceThreshold) - delete [] TerrainData.LODDistanceThreshold; - - if (TerrainData.Patches) - delete [] TerrainData.Patches; - } - - //! Initializes the terrain data. Loads the vertices from the heightMapFile - bool CTerrainSceneNode::loadHeightMap( io::IReadFile* file, video::SColor vertexColor, s32 smoothFactor ) - { - if( !file ) - return false; - - u32 startTime = os::Timer::getRealTime(); - video::IImage* heightMap = SceneManager->getVideoDriver()->createImageFromFile( file ); - - if( !heightMap ) - { - os::Printer::print( "Was not able to load heightmap." ); - return false; - } - - // Get the dimension of the heightmap data - TerrainData.Size = heightMap->getDimension().Width; - - switch( TerrainData.PatchSize ) - { - case ETPS_9: - if( TerrainData.MaxLOD > 3 ) - { - TerrainData.MaxLOD = 3; - } - break; - case ETPS_17: - if( TerrainData.MaxLOD > 4 ) - { - TerrainData.MaxLOD = 4; - } - break; - case ETPS_33: - if( TerrainData.MaxLOD > 5 ) - { - TerrainData.MaxLOD = 5; - } - break; - case ETPS_65: - if( TerrainData.MaxLOD > 6 ) - { - TerrainData.MaxLOD = 6; - } - break; - case ETPS_129: - if( TerrainData.MaxLOD > 7 ) - { - TerrainData.MaxLOD = 7; - } - break; - } - - // --- Generate vertex data from heightmap ---- - // resize the vertex array for the mesh buffer one time ( makes loading faster ) - SMeshBufferLightMap* pMeshBuffer = new SMeshBufferLightMap(); - pMeshBuffer->Vertices.set_used( TerrainData.Size * TerrainData.Size ); - - video::S3DVertex2TCoords vertex; - vertex.Normal.set( 0.0f, 1.0f, 0.0f ); - vertex.Color = vertexColor; - - // Read the heightmap to get the vertex data - // Apply positions changes, scaling changes - const f32 tdSize = 1.0f/(f32)(TerrainData.Size-1); - s32 index = 0; - for( s32 x = 0; x < TerrainData.Size; ++x ) - { - for( s32 z = 0; z < TerrainData.Size; ++z ) - { - vertex.Pos.X = (f32)x; - video::SColor pixelColor(heightMap->getPixel(x,z)); - vertex.Pos.Y = (f32) pixelColor.getLuminance(); - vertex.Pos.Z = (f32)z; - - vertex.TCoords.X = vertex.TCoords2.X = x * tdSize; - vertex.TCoords.Y = vertex.TCoords2.Y = z * tdSize; - - pMeshBuffer->Vertices[index] = vertex; - ++index; - } - } - - // drop heightMap, no longer needed - heightMap->drop(); - - //! Terrain smoothing. Applause to DeusXL! - // http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?p=91272#91272 - - s32 run; - - for( run = 0; run < smoothFactor; ++run ) - { - for( index = 2; index < (TerrainData.Size * TerrainData.Size - 2); ++index) - { - pMeshBuffer->Vertices[index].Pos.Y = - (pMeshBuffer->Vertices[index - 2].Pos.Y + pMeshBuffer->Vertices[index - 1].Pos.Y + - pMeshBuffer->Vertices[index + 1].Pos.Y + pMeshBuffer->Vertices[index + 2].Pos.Y) / 4.0f; - } - } - - for( run = 0; run < smoothFactor; ++run) - { - for( index = TerrainData.Size; index < (TerrainData.Size * (TerrainData.Size - 1)); ++index) - { - pMeshBuffer->Vertices[index].Pos.Y = - (pMeshBuffer->Vertices[index - TerrainData.Size].Pos.Y + - pMeshBuffer->Vertices[index + TerrainData.Size].Pos.Y ) / 2.0f; - } - } - - - // calculate smooth normals for the vertices - calculateNormals( pMeshBuffer ); - - // add the MeshBuffer to the mesh - Mesh.addMeshBuffer( pMeshBuffer ); - s32 vertexCount = pMeshBuffer->getVertexCount(); - - // We copy the data to the renderBuffer, after the normals have been calculated. - RenderBuffer.Vertices.set_used( vertexCount ); - - for( s32 i = 0; i < vertexCount; ++i ) - { - RenderBuffer.Vertices[i] = pMeshBuffer->Vertices[i]; - RenderBuffer.Vertices[i].Pos *= TerrainData.Scale; - RenderBuffer.Vertices[i].Pos += TerrainData.Position; - } - - // We no longer need the pMeshBuffer - pMeshBuffer->drop(); - - // calculate all the necessary data for the patches and the terrain - calculateDistanceThresholds(); - createPatches(); - calculatePatchData(); - - // set the default rotation pivot point to the terrain nodes center - TerrainData.RotationPivot = TerrainData.Center; - - // Rotate the vertices of the terrain by the rotation specified. Must be done - // after calculating the terrain data, so we know what the current center of the - // terrain is. - setRotation( TerrainData.Rotation ); - - // Pre-allocate memory for indices - RenderBuffer.Indices.set_used( TerrainData.PatchCount * TerrainData.PatchCount * - TerrainData.CalcPatchSize * TerrainData.CalcPatchSize * 6 ); - - u32 endTime = os::Timer::getRealTime(); - - c8 tmp[255]; - sprintf(tmp, "Generated terrain data (%dx%d) in %.4f seconds", - TerrainData.Size, TerrainData.Size, ( endTime - startTime ) / 1000.0f ); - os::Printer::log( tmp ); - - return true; - } - - //! Initializes the terrain data. Loads the vertices from the heightMapFile - bool CTerrainSceneNode::loadHeightMapRAW( io::IReadFile* file, s32 bitsPerPixel, video::SColor vertexColor, s32 smoothFactor ) - { - if( !file ) - return false; - - // start reading - u32 startTime = os::Timer::getTime(); - - // get file size - s32 fileSize = file->getSize(); - s32 bytesPerPixel = bitsPerPixel / 8; - s32 heightMapSize = (s32)sqrt( (f64)( fileSize / bytesPerPixel ) ); - - // Get the dimension of the heightmap data - TerrainData.Size = heightMapSize; - - switch( TerrainData.PatchSize ) - { - case ETPS_9: - if( TerrainData.MaxLOD > 3 ) - { - TerrainData.MaxLOD = 3; - } - break; - case ETPS_17: - if( TerrainData.MaxLOD > 4 ) - { - TerrainData.MaxLOD = 4; - } - break; - case ETPS_33: - if( TerrainData.MaxLOD > 5 ) - { - TerrainData.MaxLOD = 5; - } - break; - case ETPS_65: - if( TerrainData.MaxLOD > 6 ) - { - TerrainData.MaxLOD = 6; - } - break; - case ETPS_129: - if( TerrainData.MaxLOD > 7 ) - { - TerrainData.MaxLOD = 7; - } - break; - } - - // --- Generate vertex data from heightmap ---- - // resize the vertex array for the mesh buffer one time ( makes loading faster ) - SMeshBufferLightMap* pMeshBuffer = new SMeshBufferLightMap(); - pMeshBuffer->Vertices.reallocate( TerrainData.Size * TerrainData.Size ); - - video::S3DVertex2TCoords vertex; - vertex.Normal.set( 0.0f, 1.0f, 0.0f ); - vertex.Color = vertexColor; - - // Read the heightmap to get the vertex data - // Apply positions changes, scaling changes - const f32 tdSize = 1.0f/(f32)(TerrainData.Size-1); - for( s32 x = 0; x < TerrainData.Size; ++x ) - { - for( s32 z = 0; z < TerrainData.Size; ++z ) - { - vertex.Pos.X = (f32)x; - - if( file->read( &vertex.Pos.Y, bytesPerPixel ) != bytesPerPixel ) - { - os::Printer::print("Error reading heightmap RAW file."); - pMeshBuffer->drop(); - return false; - } - - vertex.Pos.Z = (f32)z; - - vertex.TCoords.X = vertex.TCoords2.X = x * tdSize; - vertex.TCoords.Y = vertex.TCoords2.Y = z * tdSize; - - pMeshBuffer->Vertices.push_back( vertex ); - } - } - - //! Terrain smoothing. Applause to DeusXL! - // http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?p=91272#91272 - - s32 run; - s32 index; - - for( run = 0; run < smoothFactor; ++run ) - { - for( index = 2; index < (TerrainData.Size * TerrainData.Size - 2); ++index) - { - pMeshBuffer->Vertices[index].Pos.Y = - (pMeshBuffer->Vertices[index - 2].Pos.Y + pMeshBuffer->Vertices[index - 1].Pos.Y + - pMeshBuffer->Vertices[index + 1].Pos.Y + pMeshBuffer->Vertices[index + 2].Pos.Y) / 4.0f; - } - } - - for( run = 0; run < smoothFactor; ++run) - { - for( index = TerrainData.Size; index < (TerrainData.Size * (TerrainData.Size - 1)); ++index) - { - pMeshBuffer->Vertices[index].Pos.Y = - (pMeshBuffer->Vertices[index - TerrainData.Size].Pos.Y + - pMeshBuffer->Vertices[index + TerrainData.Size].Pos.Y ) / 2.0f; - } - } - - // calculate smooth normals for the vertices - calculateNormals( pMeshBuffer ); - - // add the MeshBuffer to the mesh - Mesh.addMeshBuffer( pMeshBuffer ); - s32 vertexCount = pMeshBuffer->getVertexCount(); - - // We copy the data to the renderBuffer, after the normals have been calculated. - RenderBuffer.Vertices.set_used( vertexCount ); - - for( s32 i = 0; i < vertexCount; i++ ) - { - RenderBuffer.Vertices[i] = pMeshBuffer->Vertices[i]; - RenderBuffer.Vertices[i].Pos *= TerrainData.Scale; - RenderBuffer.Vertices[i].Pos += TerrainData.Position; - } - - // We no longer need the pMeshBuffer - pMeshBuffer->drop(); - - // calculate all the necessary data for the patches and the terrain - calculateDistanceThresholds(); - createPatches(); - calculatePatchData(); - - // set the default rotation pivot point to the terrain nodes center - TerrainData.RotationPivot = TerrainData.Center; - - // Rotate the vertices of the terrain by the rotation specified. Must be done - // after calculating the terrain data, so we know what the current center of the - // terrain is. - setRotation( TerrainData.Rotation ); - - // Pre-allocate memory for indices - RenderBuffer.Indices.set_used( TerrainData.PatchCount * TerrainData.PatchCount * - TerrainData.CalcPatchSize * TerrainData.CalcPatchSize * 6 ); - - u32 endTime = os::Timer::getTime(); - - c8 tmp[255]; - sprintf( tmp, "Generated terrain data (%dx%d) in %.4f seconds", - TerrainData.Size, TerrainData.Size, (endTime - startTime) / 1000.0f ); - os::Printer::print( tmp ); - - return true; - } - - //! Sets the scale of the scene node. - //! \param scale: New scale of the node - void CTerrainSceneNode::setScale(const core::vector3df& scale) - { - TerrainData.Scale = scale; - applyTransformation(); - } - - //! Sets the rotation of the node. This only modifies - //! the relative rotation of the node. - //! \param rotation: New rotation of the node in degrees. - void CTerrainSceneNode::setRotation(const core::vector3df& rotation) - { - TerrainData.Rotation = rotation; - applyTransformation(); - } - - //! Sets the pivot point for rotation of this node. This is useful for the TiledTerrainManager to - //! rotate all terrain tiles around a global world point. - //! NOTE: The default for the RotationPivot will be the center of the individual tile. - void CTerrainSceneNode::setRotationPivot( const core::vector3df& pivot ) - { - UseDefaultRotationPivot = false; - TerrainData.RotationPivot = pivot; - } - - //! Sets the position of the node. - //! \param newpos: New postition of the scene node. - void CTerrainSceneNode::setPosition ( const core::vector3df& newpos ) - { - TerrainData.Position = newpos; - applyTransformation(); - } - - //! Apply transformation changes( scale, position, rotation ) - void CTerrainSceneNode::applyTransformation() - { - if( !Mesh.getMeshBufferCount() ) - return; - - TerrainData.Position = TerrainData.Position; - video::S3DVertex2TCoords* meshVertices = (video::S3DVertex2TCoords*)Mesh.getMeshBuffer( 0 )->getVertices(); - s32 vtxCount = Mesh.getMeshBuffer( 0 )->getVertexCount(); - core::matrix4 rotMatrix; - rotMatrix.setRotationDegrees( TerrainData.Rotation ); - - for( s32 i = 0; i < vtxCount; ++i ) - { - RenderBuffer.Vertices[i].Pos = meshVertices[i].Pos * TerrainData.Scale + TerrainData.Position; - - RenderBuffer.Vertices[i].Pos -= TerrainData.RotationPivot; - rotMatrix.inverseRotateVect( RenderBuffer.Vertices[i].Pos ); - RenderBuffer.Vertices[i].Pos += TerrainData.RotationPivot; - } - - calculateDistanceThresholds( true ); - calculatePatchData(); - } - - //! Updates the scene nodes indices if the camera has moved or rotated by a certain - //! threshold, which can be changed using the SetCameraMovementDeltaThreshold and - //! SetCameraRotationDeltaThreshold functions. This also determines if a given patch - //! for the scene node is within the view frustum and if it's not the indices are not - //! generated for that patch. - void CTerrainSceneNode::OnRegisterSceneNode() - { - if (!IsVisible || !SceneManager->getActiveCamera()) - return; - - preRenderLODCalculations(); - preRenderIndicesCalculations(); - ISceneNode::OnRegisterSceneNode(); - } - - void CTerrainSceneNode::preRenderLODCalculations() - { - SceneManager->registerNodeForRendering( this ); - // Do Not call ISceneNode::OnRegisterSceneNode ( ), this node should have no children - - // Determine the camera rotation, based on the camera direction. - core::line3d line; - line.start = SceneManager->getActiveCamera()->getAbsolutePosition(); - line.end = SceneManager->getActiveCamera()->getTarget(); - core::vector3df cameraRotation = line.getVector().getHorizontalAngle(); - core::vector3df cameraPosition = SceneManager->getActiveCamera()->getPosition ( ); - - // Only check on the Camera's Y Rotation - if (( fabs(cameraRotation.X - OldCameraRotation.X) < CameraRotationDelta) && - ( fabs(cameraRotation.Y - OldCameraRotation.Y) < CameraRotationDelta)) - { - if ((fabs(cameraPosition.X - OldCameraPosition.X) < CameraMovementDelta) && - (fabs(cameraPosition.Y - OldCameraPosition.Y) < CameraMovementDelta) && - (fabs(cameraPosition.Z - OldCameraPosition.Z) < CameraMovementDelta)) - { - return; - } - } - - OldCameraPosition = cameraPosition; - OldCameraRotation = cameraRotation; - const SViewFrustum* frustum = SceneManager->getActiveCamera()->getViewFrustum(); - - // Determine each patches LOD based on distance from camera ( and whether or not they are in - // the view frustum ). - for( s32 j = 0; j < TerrainData.PatchCount * TerrainData.PatchCount; ++j ) - { - if( frustum->getBoundingBox().intersectsWithBox( TerrainData.Patches[j].BoundingBox ) ) - { - f32 distance = (cameraPosition.X - TerrainData.Patches[j].Center.X) * (cameraPosition.X - TerrainData.Patches[j].Center.X) + - (cameraPosition.Y - TerrainData.Patches[j].Center.Y) * (cameraPosition.Y - TerrainData.Patches[j].Center.Y) + - (cameraPosition.Z - TerrainData.Patches[j].Center.Z) * (cameraPosition.Z - TerrainData.Patches[j].Center.Z); - - for( s32 i = TerrainData.MaxLOD - 1; i >= 0; --i ) - { - if( distance >= TerrainData.LODDistanceThreshold[i] ) - { - TerrainData.Patches[j].CurrentLOD = i; - break; - } - //else if( i == 0 ) - { - // If we've turned off a patch from viewing, because of the frustum, and now we turn around and it's - // too close, we need to turn it back on, at the highest LOD. The if above doesn't catch this. - TerrainData.Patches[j].CurrentLOD = 0; - } - } - } - else - { - TerrainData.Patches[j].CurrentLOD = -1; - } - } - } - - void CTerrainSceneNode::preRenderLODCalculations_old() - { - SceneManager->registerNodeForRendering( this ); - // Do Not call ISceneNode::OnRegisterSceneNode ( ), this node should have no children - - // Determine the camera rotation, based on the camera direction. - core::line3d line; - line.start = SceneManager->getActiveCamera()->getAbsolutePosition(); - line.end = SceneManager->getActiveCamera()->getTarget(); - core::vector3df cameraRotation = line.getVector().getHorizontalAngle(); - core::vector3df cameraPosition = SceneManager->getActiveCamera()->getPosition ( ); - - // Only check on the Camera's Y Rotation - if (( fabs(cameraRotation.X - OldCameraRotation.X) < CameraRotationDelta) && - ( fabs(cameraRotation.Y - OldCameraRotation.Y) < CameraRotationDelta)) - { - if ((fabs(cameraPosition.X - OldCameraPosition.X) < CameraMovementDelta) && - (fabs(cameraPosition.Y - OldCameraPosition.Y) < CameraMovementDelta) && - (fabs(cameraPosition.Z - OldCameraPosition.Z) < CameraMovementDelta)) - { - return; - } - } - - OldCameraPosition = cameraPosition; - OldCameraRotation = cameraRotation; - const SViewFrustum* frustum = SceneManager->getActiveCamera()->getViewFrustum(); - - // Determine each patches LOD based on distance from camera ( and whether or not they are in - // the view frustum ). - for( s32 j = 0; j < TerrainData.PatchCount * TerrainData.PatchCount; ++j ) - { - if( frustum->getBoundingBox().intersectsWithBox( TerrainData.Patches[j].BoundingBox ) ) - { - f32 distance = (cameraPosition.X - TerrainData.Patches[j].Center.X) * (cameraPosition.X - TerrainData.Patches[j].Center.X) + - (cameraPosition.Y - TerrainData.Patches[j].Center.Y) * (cameraPosition.Y - TerrainData.Patches[j].Center.Y) + - (cameraPosition.Z - TerrainData.Patches[j].Center.Z) * (cameraPosition.Z - TerrainData.Patches[j].Center.Z); - - for( s32 i = TerrainData.MaxLOD - 1; i >= 0; --i ) - { - if( distance >= TerrainData.LODDistanceThreshold[i] ) - { - TerrainData.Patches[j].CurrentLOD = i; - break; - } - //else if( i == 0 ) - { - // If we've turned off a patch from viewing, because of the frustum, and now we turn around and it's - // too close, we need to turn it back on, at the highest LOD. The if above doesn't catch this. - TerrainData.Patches[j].CurrentLOD = 0; - } - } - } - else - { - TerrainData.Patches[j].CurrentLOD = -1; - } - } - } - - - void CTerrainSceneNode::preRenderIndicesCalculations() - { - IndicesToRender = 0; - s32 index11; - s32 index21; - s32 index12; - s32 index22; - - // Then generate the indices for all patches that are visible. - for( s32 i = 0; i < TerrainData.PatchCount; ++i ) - { - for( s32 j = 0; j < TerrainData.PatchCount; ++j ) - { - s32 index = i * TerrainData.PatchCount + j; - if( TerrainData.Patches[index].CurrentLOD >= 0 ) - { - s32 x = 0; - s32 z = 0; - - // calculate the step we take this patch, based on the patches current LOD - s32 step = 1 << TerrainData.Patches[index].CurrentLOD; - - // Loop through patch and generate indices - while( z < TerrainData.CalcPatchSize ) - { - index11 = getIndex( j, i, index, x, z ); - index21 = getIndex( j, i, index, x + step, z ); - index12 = getIndex( j, i, index, x, z + step ); - index22 = getIndex( j, i, index, x + step, z + step ); - - RenderBuffer.Indices[IndicesToRender++] = index12; - RenderBuffer.Indices[IndicesToRender++] = index11; - RenderBuffer.Indices[IndicesToRender++] = index22; - RenderBuffer.Indices[IndicesToRender++] = index22; - RenderBuffer.Indices[IndicesToRender++] = index11; - RenderBuffer.Indices[IndicesToRender++] = index21; - - // increment index position horizontally - x += step; - - if ( x >= TerrainData.CalcPatchSize ) // we've hit an edge - { - x = 0; - z += step; - } - } - } - } - } - - if ( DynamicSelectorUpdate && TriangleSelector ) - { - CTerrainTriangleSelector* selector = (CTerrainTriangleSelector*)TriangleSelector; - selector->setTriangleData ( this, -1 ); - } - } - - - //! Render the scene node - void CTerrainSceneNode::render() - { - if (!IsVisible || !SceneManager->getActiveCamera()) - return; - - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - core::matrix4 identity; - driver->setTransform (video::ETS_WORLD, identity); - - driver->setMaterial(Mesh.getMeshBuffer(0)->getMaterial()); - - // For use with geomorphing - driver->drawVertexPrimitiveList( - RenderBuffer.getVertices(), RenderBuffer.getVertexCount(), - RenderBuffer.getIndices(), IndicesToRender / 3, - video::EVT_2TCOORDS, EPT_TRIANGLES); - - // for debug purposes only: - if (DebugDataVisible ) - { - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - driver->draw3DBox( TerrainData.BoundingBox, video::SColor(0,255,255,255)); - - s32 count = TerrainData.PatchCount * TerrainData.PatchCount; - s32 visible = 0; - for( s32 j = 0; j < count; ++j ) - { - driver->draw3DBox( TerrainData.Patches[j].BoundingBox, video::SColor(0,255,0,0)); - visible += ( TerrainData.Patches[j].CurrentLOD >= 0 ); - } - - static u32 lastTime = 0; - - u32 now = os::Timer::getRealTime (); - if ( now - lastTime > 1000 ) - { - char buf[64]; - sprintf ( buf, "Count: %d, Visible: %d", count, visible ); - os::Printer::print ( buf ); - - lastTime = now; - } - - } - - } - - //! Return the bounding box of the entire terrain. - const core::aabbox3d& CTerrainSceneNode::getBoundingBox() const - { - return TerrainData.BoundingBox; - } - - //! Return the bounding box of a patch - const core::aabbox3d& CTerrainSceneNode::getBoundingBox( s32 patchX, s32 patchZ ) const - { - return TerrainData.Patches[patchX * TerrainData.PatchCount + patchZ].BoundingBox; - } - - //! Gets the meshbuffer data based on a specified Level of Detail. - //! \param mb: A reference to an SMeshBuffer object - //! \param LOD: The Level Of Detail you want the indices from. - void CTerrainSceneNode::getMeshBufferForLOD(SMeshBufferLightMap& mb, s32 LOD ) - { - if ( LOD < 0 ) - LOD = 0; - else if ( LOD > TerrainData.MaxLOD - 1 ) - LOD = TerrainData.MaxLOD - 1; - - s32 numVertices = Mesh.getMeshBuffer( 0 )->getVertexCount ( ); - mb.Vertices.reallocate ( numVertices ); - video::S3DVertex2TCoords* vertices = (video::S3DVertex2TCoords*)Mesh.getMeshBuffer ( 0 )->getVertices ( ); - - s32 i; - for (i=0; i= TerrainData.CalcPatchSize) // we've hit an edge - { - x = 0; - z += step; - } - } - } - } - } - - //! Gets the indices for a specified patch at a specified Level of Detail. - //! \param mb: A reference to an array of u32 indices. - //! \param patchX: Patch x coordinate. - //! \param patchZ: Patch z coordinate. - //! \param LOD: The level of detail to get for that patch. If -1, then get - //! the CurrentLOD. If the CurrentLOD is set to -1, meaning it's not shown, - //! then it will retrieve the triangles at the highest LOD ( 0 ). - //! \return: Number if indices put into the buffer. - s32 CTerrainSceneNode::getIndicesForPatch(core::array& indices, s32 patchX, s32 patchZ, s32 LOD ) - { - if ( patchX < 0 || patchX > TerrainData.PatchCount - 1 || patchZ < 0 || patchZ > TerrainData.PatchCount - 1 ) - return -1; - - if ( LOD < -1 || LOD > TerrainData.MaxLOD - 1 ) - return -1; - - s32 rv = 0; - core::array cLODs; - bool setLODs = false; - - // If LOD of -1 was passed in, use the CurrentLOD of the patch specified - if ( LOD == -1 ) - { - LOD = TerrainData.Patches[patchX * TerrainData.PatchCount + patchZ].CurrentLOD; - } - else - { - getCurrentLODOfPatches(cLODs); - setCurrentLODOfPatches(LOD); - setLODs = true; - } - - if ( LOD < 0 ) - return -2; // Patch not visible, don't generate indices. - - // calculate the step we take for this LOD - s32 step = 1 << LOD; - - // Generate the indices for the specified patch at the specified LOD - s32 index = patchX * TerrainData.PatchCount + patchZ; - - s32 x = 0; - s32 z = 0; - s32 index11; - s32 index21; - s32 index12; - s32 index22; - - indices.set_used ( TerrainData.PatchSize * TerrainData.PatchSize * 6 ); - - // Loop through patch and generate indices - while (z= TerrainData.CalcPatchSize) // we've hit an edge - { - x = 0; - z += step; - } - } - - if ( setLODs ) - setCurrentLODOfPatches (cLODs); - - return rv; - } - - //! Populates an array with the CurrentLOD of each patch. - //! \param LODs: A reference to a core::array to hold the values - //! \return Returns the number of elements in the array - s32 CTerrainSceneNode::getCurrentLODOfPatches(core::array& LODs) - { - s32 numLODs; - LODs.clear ( ); - - for ( numLODs = 0; numLODs < TerrainData.PatchCount * TerrainData.PatchCount; numLODs++ ) - LODs.push_back ( TerrainData.Patches[numLODs].CurrentLOD ); - - return LODs.size(); - } - - - //! Manually sets the LOD of a patch - //! \param patchX: Patch x coordinate. - //! \param patchZ: Patch z coordinate. - //! \param LOD: The level of detail to set the patch to. - void CTerrainSceneNode::setLODOfPatch( s32 patchX, s32 patchZ, s32 LOD ) - { - TerrainData.Patches[patchX * TerrainData.PatchCount + patchZ].CurrentLOD = LOD; - } - - - //! Override the default generation of distance thresholds for determining the LOD a patch - //! is rendered at. - bool CTerrainSceneNode::overrideLODDistance(s32 LOD, f64 newDistance) - { - OverrideDistanceThreshold = true; - - if ( LOD < 0 || LOD > TerrainData.MaxLOD - 1 ) - return false; - - TerrainData.LODDistanceThreshold[LOD] = newDistance * newDistance; - - return true; - } - - //! Creates a planar texture mapping on the terrain - //! \param resolution: resolution of the planar mapping. This is the value - //! specifying the relation between world space and texture coordinate space. - void CTerrainSceneNode::scaleTexture(f32 resolution, f32 resolution2) - { - const f32 resBySize = resolution / (f32)(TerrainData.Size-1); - const f32 res2BySize = resolution2 / (f32)(TerrainData.Size-1); - u32 index = 0; - f32 xval = 0, zval; - f32 x2val = 0, z2val=0; - for (s32 x=0; xCurrentLOD && - (vX % ( 1 << TerrainData.Patches[PatchIndex].Top->CurrentLOD)) != 0 ) - { - vX = vX - vX % ( 1 << TerrainData.Patches[PatchIndex].Top->CurrentLOD ); - } - } - else - if ( vZ == (u32)TerrainData.CalcPatchSize ) // bottom border - { - if (TerrainData.Patches[PatchIndex].Bottom && - TerrainData.Patches[PatchIndex].CurrentLOD < TerrainData.Patches[PatchIndex].Bottom->CurrentLOD && - (vX % ( 1 << TerrainData.Patches[PatchIndex].Bottom->CurrentLOD)) != 0) - { - vX = vX - vX % ( 1 << TerrainData.Patches[PatchIndex].Bottom->CurrentLOD ); - } - } - - // left border - if ( vX == 0 ) - { - if (TerrainData.Patches[PatchIndex].Left && - TerrainData.Patches[PatchIndex].CurrentLOD < TerrainData.Patches[PatchIndex].Left->CurrentLOD && - ( vZ % ( 1 << TerrainData.Patches[PatchIndex].Left->CurrentLOD ) ) != 0) - { - vZ = vZ - vZ % ( 1 << TerrainData.Patches[PatchIndex].Left->CurrentLOD ); - } - } - else - if ( vX == (u32)TerrainData.CalcPatchSize ) // right border - { - if (TerrainData.Patches[PatchIndex].Right && - TerrainData.Patches[PatchIndex].CurrentLOD < TerrainData.Patches[PatchIndex].Right->CurrentLOD && - ( vZ % ( 1 << TerrainData.Patches[PatchIndex].Right->CurrentLOD ) ) != 0) - { - vZ = vZ - vZ % ( 1 << TerrainData.Patches[PatchIndex].Right->CurrentLOD ); - } - } - - if ( vZ >= (u32)TerrainData.PatchSize ) - vZ = TerrainData.CalcPatchSize; - - if ( vX >= (u32)TerrainData.PatchSize ) - vX = TerrainData.CalcPatchSize; - - return (vZ + ((TerrainData.CalcPatchSize) * PatchZ)) * TerrainData.Size + - (vX + ((TerrainData.CalcPatchSize) * PatchX)); - } - - //! calculate smooth normals - void CTerrainSceneNode::calculateNormals ( SMeshBufferLightMap* pMeshBuffer ) - { - s32 count; - core::vector3df a, b, c, t; - - for (s32 x=0; x0 && z>0) - { - a = pMeshBuffer->Vertices[(x-1)*TerrainData.Size+z-1].Pos; - b = pMeshBuffer->Vertices[(x-1)*TerrainData.Size+z].Pos; - c = pMeshBuffer->Vertices[x*TerrainData.Size+z].Pos; - b -= a; - c -= a; - t = b.crossProduct ( c ); - t.normalize ( ); - normal += t; - - a = pMeshBuffer->Vertices[(x-1)*TerrainData.Size+z-1].Pos; - b = pMeshBuffer->Vertices[x*TerrainData.Size+z-1].Pos; - c = pMeshBuffer->Vertices[x*TerrainData.Size+z].Pos; - b -= a; - c -= a; - t = b.crossProduct ( c ); - t.normalize ( ); - normal += t; - - count += 2; - } - - // top right - if (x>0 && zVertices[(x-1)*TerrainData.Size+z].Pos; - b = pMeshBuffer->Vertices[(x-1)*TerrainData.Size+z+1].Pos; - c = pMeshBuffer->Vertices[x*TerrainData.Size+z+1].Pos; - b -= a; - c -= a; - t = b.crossProduct ( c ); - t.normalize ( ); - normal += t; - - a = pMeshBuffer->Vertices[(x-1)*TerrainData.Size+z].Pos; - b = pMeshBuffer->Vertices[x*TerrainData.Size+z+1].Pos; - c = pMeshBuffer->Vertices[x*TerrainData.Size+z].Pos; - b -= a; - c -= a; - t = b.crossProduct ( c ); - t.normalize ( ); - normal += t; - - count += 2; - } - - // bottom right - if (xVertices[x*TerrainData.Size+z+1].Pos; - b = pMeshBuffer->Vertices[x*TerrainData.Size+z].Pos; - c = pMeshBuffer->Vertices[(x+1)*TerrainData.Size+z+1].Pos; - b -= a; - c -= a; - t = b.crossProduct ( c ); - t.normalize ( ); - normal += t; - - a = pMeshBuffer->Vertices[x*TerrainData.Size+z+1].Pos; - b = pMeshBuffer->Vertices[(x+1)*TerrainData.Size+z+1].Pos; - c = pMeshBuffer->Vertices[(x+1)*TerrainData.Size+z].Pos; - b -= a; - c -= a; - t = b.crossProduct ( c ); - t.normalize ( ); - normal += t; - - count += 2; - } - - // bottom left - if (x0) - { - a = pMeshBuffer->Vertices[x*TerrainData.Size+z-1].Pos; - b = pMeshBuffer->Vertices[x*TerrainData.Size+z].Pos; - c = pMeshBuffer->Vertices[(x+1)*TerrainData.Size+z].Pos; - b -= a; - c -= a; - t = b.crossProduct ( c ); - t.normalize ( ); - normal += t; - - a = pMeshBuffer->Vertices[x*TerrainData.Size+z-1].Pos; - b = pMeshBuffer->Vertices[(x+1)*TerrainData.Size+z].Pos; - c = pMeshBuffer->Vertices[(x+1)*TerrainData.Size+z-1].Pos; - b -= a; - c -= a; - t = b.crossProduct ( c ); - t.normalize ( ); - normal += t; - - count += 2; - } - - if ( count != 0 ) - { - normal.normalize ( ); - } - else - { - normal.set( 0.0f, 1.0f, 0.0f ); - } - - pMeshBuffer->Vertices[x * TerrainData.Size + z].Normal = normal; - } - } - - //! create patches, stuff that needs to be done only once for patches goes here. - void CTerrainSceneNode::createPatches() - { - TerrainData.PatchCount = (TerrainData.Size - 1) / ( TerrainData.CalcPatchSize ); - - if (TerrainData.Patches) - delete [] TerrainData.Patches; - - TerrainData.Patches = new SPatch[TerrainData.PatchCount * TerrainData.PatchCount]; - -#if 0 - gui::IGUIFont* font = SceneManager->getGUIEnvironment()->getFont("../../media/bigfont.png"); - font->setKerning ( -2 ); - for( s32 j = 0; j < TerrainData.PatchCount * TerrainData.PatchCount; ++j ) - { - const core::stringw buf(j); - TerrainData.Patches[j].DebugText = SceneManager->addTextSceneNode ( - font, - buf.c_str(), - 0xFFFFFFFF, - 0 - ); - } -#endif - - - } - - //! used to calculate the internal STerrainData structure both at creation and after scaling/position calls. - void CTerrainSceneNode::calculatePatchData() - { - // Reset the Terrains Bounding Box for re-calculation - TerrainData.BoundingBox = core::aabbox3df ( 999999.9f, 999999.9f, 999999.9f, -999999.9f, -999999.9f, -999999.9f ); - - for( s32 x = 0; x < TerrainData.PatchCount; ++x ) - { - for( s32 z = 0; z < TerrainData.PatchCount; ++z ) - { - s32 index = x * TerrainData.PatchCount + z; - TerrainData.Patches[index].CurrentLOD = 0; - - // For each patch, calculate the bounding box ( mins and maxes ) - TerrainData.Patches[index].BoundingBox = core::aabbox3df (999999.9f, 999999.9f, 999999.9f, - -999999.9f, -999999.9f, -999999.9f ); - - for( s32 xx = x*(TerrainData.CalcPatchSize); xx <= ( x + 1 ) * TerrainData.CalcPatchSize; ++xx ) - for( s32 zz = z*(TerrainData.CalcPatchSize); zz <= ( z + 1 ) * TerrainData.CalcPatchSize; ++zz ) - TerrainData.Patches[index].BoundingBox.addInternalPoint( RenderBuffer.Vertices[xx * TerrainData.Size + zz].Pos ); - - // Reconfigure the bounding box of the terrain as a whole - TerrainData.BoundingBox.addInternalBox( TerrainData.Patches[index].BoundingBox ); - - // get center of Patch - TerrainData.Patches[index].Center = TerrainData.Patches[index].BoundingBox.getCenter(); - - // Assign Neighbours - // Top - if( x > 0 ) - TerrainData.Patches[index].Top = &TerrainData.Patches[(x-1) * TerrainData.PatchCount + z]; - else - TerrainData.Patches[index].Top = 0; - - // Bottom - if( x < TerrainData.PatchCount - 1 ) - TerrainData.Patches[index].Bottom = &TerrainData.Patches[(x+1) * TerrainData.PatchCount + z]; - else - TerrainData.Patches[index].Bottom = 0; - - // Left - if( z > 0 ) - TerrainData.Patches[index].Left = &TerrainData.Patches[x * TerrainData.PatchCount + z - 1]; - else - TerrainData.Patches[index].Left = 0; - - // Right - if( z < TerrainData.PatchCount - 1 ) - TerrainData.Patches[index].Right = &TerrainData.Patches[x * TerrainData.PatchCount + z + 1]; - else - TerrainData.Patches[index].Right = 0; - - if ( TerrainData.Patches[index].DebugText ) - { - TerrainData.Patches[index].DebugText->setPosition ( TerrainData.Patches[index].Center ); - } - - } - } - - // get center of Terrain - TerrainData.Center = TerrainData.BoundingBox.getCenter(); - - // if the default rotation pivot is still being used, update it. - if( UseDefaultRotationPivot ) - { - TerrainData.RotationPivot = TerrainData.Center; - } - } - - - //! used to calculate or recalculate the distance thresholds - void CTerrainSceneNode::calculateDistanceThresholds(bool scalechanged) - { - // Only update the LODDistanceThreshold if it's not manually changed - if (!OverrideDistanceThreshold) - { - if( TerrainData.LODDistanceThreshold ) - { - delete [] TerrainData.LODDistanceThreshold; - } - - // Determine new distance threshold for determining what LOD to draw patches at - TerrainData.LODDistanceThreshold = new f64[TerrainData.MaxLOD]; - - for (s32 i=0; i& lodarray) - { - for (s32 i=0; i= 0 && X < TerrainData.Size && Z >= 0 && Z <= TerrainData.Size ) - { - video::S3DVertex2TCoords* Vertices = (video::S3DVertex2TCoords*)Mesh.getMeshBuffer( 0 )->getVertices(); - core::vector3df a = Vertices[ X * TerrainData.Size + Z ].Pos; - core::vector3df b = Vertices[ (X + 1) * TerrainData.Size + Z ].Pos; - core::vector3df c = Vertices[ X * TerrainData.Size + ( Z + 1 ) ].Pos; - core::vector3df d = Vertices[ (X + 1) * TerrainData.Size + ( Z + 1 ) ].Pos; - - f32 dx = pos.X - X; - f32 dz = pos.Z - Z; - f32 invDX = 1.0f - dx; - - if( dz < invDX ) - { - f32 uy = a.Y - c.Y; - f32 vy = d.Y - c.Y; - height = c.Y + core::lerp( 0.0f, uy, dx ) + core::lerp( 0.0f, vy, dz ); - } - else - { - f32 uy = a.Y - b.Y; - f32 vy = d.Y - b.Y; - height = b.Y + core::lerp( 0.0f, uy, invDX ) + core::lerp( 0.0f, vy, 1.0f - dz ); - } - height *= TerrainData.Scale.Y; - height += TerrainData.Position.Y; - } - - return height; - } - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// The code for the TerrainSceneNode is based on the GeoMipMapSceneNode +// developed by Spintz. He made it available for Irrlicht and allowed it to be +// distributed under this licence. I only modified some parts. A lot of thanks go to him. + +#include "CTerrainSceneNode.h" +#include "CTerrainTriangleSelector.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" +#include "ICameraSceneNode.h" +#include "SMeshBufferLightMap.h" +#include "SViewFrustum.h" +#include "irrMath.h" +#include "os.h" +#include "IGUIFont.h" + +namespace irr +{ +namespace scene +{ + + //! constructor + CTerrainSceneNode::CTerrainSceneNode(ISceneNode* parent, ISceneManager* mgr, + s32 id, s32 maxLOD, E_TERRAIN_PATCH_SIZE patchSize, const core::vector3df& position, + const core::vector3df& rotation, const core::vector3df& scale) + : ITerrainSceneNode(parent, mgr, id, position, rotation, scale), + TerrainData(patchSize, maxLOD, position, rotation, scale), + VerticesToRender(0), IndicesToRender(0), DynamicSelectorUpdate(false), + OverrideDistanceThreshold(false), UseDefaultRotationPivot(true), + OldCameraPosition(core::vector3df(-99999.9f, -99999.9f, -99999.9f)), + OldCameraRotation(core::vector3df(-99999.9f, -99999.9f, -99999.9f)), + CameraMovementDelta(10.0f), CameraRotationDelta(1.0f) + { + #ifdef _DEBUG + setDebugName("CTerrainSceneNode"); + #endif + + setAutomaticCulling( scene::EAC_OFF ); + } + + //! destructor + CTerrainSceneNode::~CTerrainSceneNode ( ) + { + if (TerrainData.LODDistanceThreshold) + delete [] TerrainData.LODDistanceThreshold; + + if (TerrainData.Patches) + delete [] TerrainData.Patches; + } + + //! Initializes the terrain data. Loads the vertices from the heightMapFile + bool CTerrainSceneNode::loadHeightMap( io::IReadFile* file, video::SColor vertexColor, s32 smoothFactor ) + { + if( !file ) + return false; + + u32 startTime = os::Timer::getRealTime(); + video::IImage* heightMap = SceneManager->getVideoDriver()->createImageFromFile( file ); + + if( !heightMap ) + { + os::Printer::print( "Was not able to load heightmap." ); + return false; + } + + // Get the dimension of the heightmap data + TerrainData.Size = heightMap->getDimension().Width; + + switch( TerrainData.PatchSize ) + { + case ETPS_9: + if( TerrainData.MaxLOD > 3 ) + { + TerrainData.MaxLOD = 3; + } + break; + case ETPS_17: + if( TerrainData.MaxLOD > 4 ) + { + TerrainData.MaxLOD = 4; + } + break; + case ETPS_33: + if( TerrainData.MaxLOD > 5 ) + { + TerrainData.MaxLOD = 5; + } + break; + case ETPS_65: + if( TerrainData.MaxLOD > 6 ) + { + TerrainData.MaxLOD = 6; + } + break; + case ETPS_129: + if( TerrainData.MaxLOD > 7 ) + { + TerrainData.MaxLOD = 7; + } + break; + } + + // --- Generate vertex data from heightmap ---- + // resize the vertex array for the mesh buffer one time ( makes loading faster ) + SMeshBufferLightMap* pMeshBuffer = new SMeshBufferLightMap(); + pMeshBuffer->Vertices.set_used( TerrainData.Size * TerrainData.Size ); + + video::S3DVertex2TCoords vertex; + vertex.Normal.set( 0.0f, 1.0f, 0.0f ); + vertex.Color = vertexColor; + + // Read the heightmap to get the vertex data + // Apply positions changes, scaling changes + const f32 tdSize = 1.0f/(f32)(TerrainData.Size-1); + s32 index = 0; + for( s32 x = 0; x < TerrainData.Size; ++x ) + { + for( s32 z = 0; z < TerrainData.Size; ++z ) + { + vertex.Pos.X = (f32)x; + video::SColor pixelColor(heightMap->getPixel(x,z)); + vertex.Pos.Y = (f32) pixelColor.getLuminance(); + vertex.Pos.Z = (f32)z; + + vertex.TCoords.X = vertex.TCoords2.X = x * tdSize; + vertex.TCoords.Y = vertex.TCoords2.Y = z * tdSize; + + pMeshBuffer->Vertices[index] = vertex; + ++index; + } + } + + // drop heightMap, no longer needed + heightMap->drop(); + + //! Terrain smoothing. Applause to DeusXL! + // http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?p=91272#91272 + + s32 run; + + for( run = 0; run < smoothFactor; ++run ) + { + for( index = 2; index < (TerrainData.Size * TerrainData.Size - 2); ++index) + { + pMeshBuffer->Vertices[index].Pos.Y = + (pMeshBuffer->Vertices[index - 2].Pos.Y + pMeshBuffer->Vertices[index - 1].Pos.Y + + pMeshBuffer->Vertices[index + 1].Pos.Y + pMeshBuffer->Vertices[index + 2].Pos.Y) / 4.0f; + } + } + + for( run = 0; run < smoothFactor; ++run) + { + for( index = TerrainData.Size; index < (TerrainData.Size * (TerrainData.Size - 1)); ++index) + { + pMeshBuffer->Vertices[index].Pos.Y = + (pMeshBuffer->Vertices[index - TerrainData.Size].Pos.Y + + pMeshBuffer->Vertices[index + TerrainData.Size].Pos.Y ) / 2.0f; + } + } + + + // calculate smooth normals for the vertices + calculateNormals( pMeshBuffer ); + + // add the MeshBuffer to the mesh + Mesh.addMeshBuffer( pMeshBuffer ); + s32 vertexCount = pMeshBuffer->getVertexCount(); + + // We copy the data to the renderBuffer, after the normals have been calculated. + RenderBuffer.Vertices.set_used( vertexCount ); + + for( s32 i = 0; i < vertexCount; ++i ) + { + RenderBuffer.Vertices[i] = pMeshBuffer->Vertices[i]; + RenderBuffer.Vertices[i].Pos *= TerrainData.Scale; + RenderBuffer.Vertices[i].Pos += TerrainData.Position; + } + + // We no longer need the pMeshBuffer + pMeshBuffer->drop(); + + // calculate all the necessary data for the patches and the terrain + calculateDistanceThresholds(); + createPatches(); + calculatePatchData(); + + // set the default rotation pivot point to the terrain nodes center + TerrainData.RotationPivot = TerrainData.Center; + + // Rotate the vertices of the terrain by the rotation specified. Must be done + // after calculating the terrain data, so we know what the current center of the + // terrain is. + setRotation( TerrainData.Rotation ); + + // Pre-allocate memory for indices + RenderBuffer.Indices.set_used( TerrainData.PatchCount * TerrainData.PatchCount * + TerrainData.CalcPatchSize * TerrainData.CalcPatchSize * 6 ); + + u32 endTime = os::Timer::getRealTime(); + + c8 tmp[255]; + sprintf(tmp, "Generated terrain data (%dx%d) in %.4f seconds", + TerrainData.Size, TerrainData.Size, ( endTime - startTime ) / 1000.0f ); + os::Printer::log( tmp ); + + return true; + } + + //! Initializes the terrain data. Loads the vertices from the heightMapFile + bool CTerrainSceneNode::loadHeightMapRAW( io::IReadFile* file, s32 bitsPerPixel, video::SColor vertexColor, s32 smoothFactor ) + { + if( !file ) + return false; + + // start reading + u32 startTime = os::Timer::getTime(); + + // get file size + s32 fileSize = file->getSize(); + s32 bytesPerPixel = bitsPerPixel / 8; + s32 heightMapSize = (s32)sqrt( (f64)( fileSize / bytesPerPixel ) ); + + // Get the dimension of the heightmap data + TerrainData.Size = heightMapSize; + + switch( TerrainData.PatchSize ) + { + case ETPS_9: + if( TerrainData.MaxLOD > 3 ) + { + TerrainData.MaxLOD = 3; + } + break; + case ETPS_17: + if( TerrainData.MaxLOD > 4 ) + { + TerrainData.MaxLOD = 4; + } + break; + case ETPS_33: + if( TerrainData.MaxLOD > 5 ) + { + TerrainData.MaxLOD = 5; + } + break; + case ETPS_65: + if( TerrainData.MaxLOD > 6 ) + { + TerrainData.MaxLOD = 6; + } + break; + case ETPS_129: + if( TerrainData.MaxLOD > 7 ) + { + TerrainData.MaxLOD = 7; + } + break; + } + + // --- Generate vertex data from heightmap ---- + // resize the vertex array for the mesh buffer one time ( makes loading faster ) + SMeshBufferLightMap* pMeshBuffer = new SMeshBufferLightMap(); + pMeshBuffer->Vertices.reallocate( TerrainData.Size * TerrainData.Size ); + + video::S3DVertex2TCoords vertex; + vertex.Normal.set( 0.0f, 1.0f, 0.0f ); + vertex.Color = vertexColor; + + // Read the heightmap to get the vertex data + // Apply positions changes, scaling changes + const f32 tdSize = 1.0f/(f32)(TerrainData.Size-1); + for( s32 x = 0; x < TerrainData.Size; ++x ) + { + for( s32 z = 0; z < TerrainData.Size; ++z ) + { + vertex.Pos.X = (f32)x; + + if( file->read( &vertex.Pos.Y, bytesPerPixel ) != bytesPerPixel ) + { + os::Printer::print("Error reading heightmap RAW file."); + pMeshBuffer->drop(); + return false; + } + + vertex.Pos.Z = (f32)z; + + vertex.TCoords.X = vertex.TCoords2.X = x * tdSize; + vertex.TCoords.Y = vertex.TCoords2.Y = z * tdSize; + + pMeshBuffer->Vertices.push_back( vertex ); + } + } + + //! Terrain smoothing. Applause to DeusXL! + // http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?p=91272#91272 + + s32 run; + s32 index; + + for( run = 0; run < smoothFactor; ++run ) + { + for( index = 2; index < (TerrainData.Size * TerrainData.Size - 2); ++index) + { + pMeshBuffer->Vertices[index].Pos.Y = + (pMeshBuffer->Vertices[index - 2].Pos.Y + pMeshBuffer->Vertices[index - 1].Pos.Y + + pMeshBuffer->Vertices[index + 1].Pos.Y + pMeshBuffer->Vertices[index + 2].Pos.Y) / 4.0f; + } + } + + for( run = 0; run < smoothFactor; ++run) + { + for( index = TerrainData.Size; index < (TerrainData.Size * (TerrainData.Size - 1)); ++index) + { + pMeshBuffer->Vertices[index].Pos.Y = + (pMeshBuffer->Vertices[index - TerrainData.Size].Pos.Y + + pMeshBuffer->Vertices[index + TerrainData.Size].Pos.Y ) / 2.0f; + } + } + + // calculate smooth normals for the vertices + calculateNormals( pMeshBuffer ); + + // add the MeshBuffer to the mesh + Mesh.addMeshBuffer( pMeshBuffer ); + s32 vertexCount = pMeshBuffer->getVertexCount(); + + // We copy the data to the renderBuffer, after the normals have been calculated. + RenderBuffer.Vertices.set_used( vertexCount ); + + for( s32 i = 0; i < vertexCount; i++ ) + { + RenderBuffer.Vertices[i] = pMeshBuffer->Vertices[i]; + RenderBuffer.Vertices[i].Pos *= TerrainData.Scale; + RenderBuffer.Vertices[i].Pos += TerrainData.Position; + } + + // We no longer need the pMeshBuffer + pMeshBuffer->drop(); + + // calculate all the necessary data for the patches and the terrain + calculateDistanceThresholds(); + createPatches(); + calculatePatchData(); + + // set the default rotation pivot point to the terrain nodes center + TerrainData.RotationPivot = TerrainData.Center; + + // Rotate the vertices of the terrain by the rotation specified. Must be done + // after calculating the terrain data, so we know what the current center of the + // terrain is. + setRotation( TerrainData.Rotation ); + + // Pre-allocate memory for indices + RenderBuffer.Indices.set_used( TerrainData.PatchCount * TerrainData.PatchCount * + TerrainData.CalcPatchSize * TerrainData.CalcPatchSize * 6 ); + + u32 endTime = os::Timer::getTime(); + + c8 tmp[255]; + sprintf( tmp, "Generated terrain data (%dx%d) in %.4f seconds", + TerrainData.Size, TerrainData.Size, (endTime - startTime) / 1000.0f ); + os::Printer::print( tmp ); + + return true; + } + + //! Sets the scale of the scene node. + //! \param scale: New scale of the node + void CTerrainSceneNode::setScale(const core::vector3df& scale) + { + TerrainData.Scale = scale; + applyTransformation(); + } + + //! Sets the rotation of the node. This only modifies + //! the relative rotation of the node. + //! \param rotation: New rotation of the node in degrees. + void CTerrainSceneNode::setRotation(const core::vector3df& rotation) + { + TerrainData.Rotation = rotation; + applyTransformation(); + } + + //! Sets the pivot point for rotation of this node. This is useful for the TiledTerrainManager to + //! rotate all terrain tiles around a global world point. + //! NOTE: The default for the RotationPivot will be the center of the individual tile. + void CTerrainSceneNode::setRotationPivot( const core::vector3df& pivot ) + { + UseDefaultRotationPivot = false; + TerrainData.RotationPivot = pivot; + } + + //! Sets the position of the node. + //! \param newpos: New postition of the scene node. + void CTerrainSceneNode::setPosition ( const core::vector3df& newpos ) + { + TerrainData.Position = newpos; + applyTransformation(); + } + + //! Apply transformation changes( scale, position, rotation ) + void CTerrainSceneNode::applyTransformation() + { + if( !Mesh.getMeshBufferCount() ) + return; + + TerrainData.Position = TerrainData.Position; + video::S3DVertex2TCoords* meshVertices = (video::S3DVertex2TCoords*)Mesh.getMeshBuffer( 0 )->getVertices(); + s32 vtxCount = Mesh.getMeshBuffer( 0 )->getVertexCount(); + core::matrix4 rotMatrix; + rotMatrix.setRotationDegrees( TerrainData.Rotation ); + + for( s32 i = 0; i < vtxCount; ++i ) + { + RenderBuffer.Vertices[i].Pos = meshVertices[i].Pos * TerrainData.Scale + TerrainData.Position; + + RenderBuffer.Vertices[i].Pos -= TerrainData.RotationPivot; + rotMatrix.inverseRotateVect( RenderBuffer.Vertices[i].Pos ); + RenderBuffer.Vertices[i].Pos += TerrainData.RotationPivot; + } + + calculateDistanceThresholds( true ); + calculatePatchData(); + } + + //! Updates the scene nodes indices if the camera has moved or rotated by a certain + //! threshold, which can be changed using the SetCameraMovementDeltaThreshold and + //! SetCameraRotationDeltaThreshold functions. This also determines if a given patch + //! for the scene node is within the view frustum and if it's not the indices are not + //! generated for that patch. + void CTerrainSceneNode::OnRegisterSceneNode() + { + if (!IsVisible || !SceneManager->getActiveCamera()) + return; + + preRenderLODCalculations(); + preRenderIndicesCalculations(); + ISceneNode::OnRegisterSceneNode(); + } + + void CTerrainSceneNode::preRenderLODCalculations() + { + SceneManager->registerNodeForRendering( this ); + // Do Not call ISceneNode::OnRegisterSceneNode ( ), this node should have no children + + // Determine the camera rotation, based on the camera direction. + core::line3d line; + line.start = SceneManager->getActiveCamera()->getAbsolutePosition(); + line.end = SceneManager->getActiveCamera()->getTarget(); + core::vector3df cameraRotation = line.getVector().getHorizontalAngle(); + core::vector3df cameraPosition = SceneManager->getActiveCamera()->getPosition ( ); + + // Only check on the Camera's Y Rotation + if (( fabs(cameraRotation.X - OldCameraRotation.X) < CameraRotationDelta) && + ( fabs(cameraRotation.Y - OldCameraRotation.Y) < CameraRotationDelta)) + { + if ((fabs(cameraPosition.X - OldCameraPosition.X) < CameraMovementDelta) && + (fabs(cameraPosition.Y - OldCameraPosition.Y) < CameraMovementDelta) && + (fabs(cameraPosition.Z - OldCameraPosition.Z) < CameraMovementDelta)) + { + return; + } + } + + OldCameraPosition = cameraPosition; + OldCameraRotation = cameraRotation; + const SViewFrustum* frustum = SceneManager->getActiveCamera()->getViewFrustum(); + + // Determine each patches LOD based on distance from camera ( and whether or not they are in + // the view frustum ). + for( s32 j = 0; j < TerrainData.PatchCount * TerrainData.PatchCount; ++j ) + { + if( frustum->getBoundingBox().intersectsWithBox( TerrainData.Patches[j].BoundingBox ) ) + { + f32 distance = (cameraPosition.X - TerrainData.Patches[j].Center.X) * (cameraPosition.X - TerrainData.Patches[j].Center.X) + + (cameraPosition.Y - TerrainData.Patches[j].Center.Y) * (cameraPosition.Y - TerrainData.Patches[j].Center.Y) + + (cameraPosition.Z - TerrainData.Patches[j].Center.Z) * (cameraPosition.Z - TerrainData.Patches[j].Center.Z); + + for( s32 i = TerrainData.MaxLOD - 1; i >= 0; --i ) + { + if( distance >= TerrainData.LODDistanceThreshold[i] ) + { + TerrainData.Patches[j].CurrentLOD = i; + break; + } + //else if( i == 0 ) + { + // If we've turned off a patch from viewing, because of the frustum, and now we turn around and it's + // too close, we need to turn it back on, at the highest LOD. The if above doesn't catch this. + TerrainData.Patches[j].CurrentLOD = 0; + } + } + } + else + { + TerrainData.Patches[j].CurrentLOD = -1; + } + } + } + + void CTerrainSceneNode::preRenderLODCalculations_old() + { + SceneManager->registerNodeForRendering( this ); + // Do Not call ISceneNode::OnRegisterSceneNode ( ), this node should have no children + + // Determine the camera rotation, based on the camera direction. + core::line3d line; + line.start = SceneManager->getActiveCamera()->getAbsolutePosition(); + line.end = SceneManager->getActiveCamera()->getTarget(); + core::vector3df cameraRotation = line.getVector().getHorizontalAngle(); + core::vector3df cameraPosition = SceneManager->getActiveCamera()->getPosition ( ); + + // Only check on the Camera's Y Rotation + if (( fabs(cameraRotation.X - OldCameraRotation.X) < CameraRotationDelta) && + ( fabs(cameraRotation.Y - OldCameraRotation.Y) < CameraRotationDelta)) + { + if ((fabs(cameraPosition.X - OldCameraPosition.X) < CameraMovementDelta) && + (fabs(cameraPosition.Y - OldCameraPosition.Y) < CameraMovementDelta) && + (fabs(cameraPosition.Z - OldCameraPosition.Z) < CameraMovementDelta)) + { + return; + } + } + + OldCameraPosition = cameraPosition; + OldCameraRotation = cameraRotation; + const SViewFrustum* frustum = SceneManager->getActiveCamera()->getViewFrustum(); + + // Determine each patches LOD based on distance from camera ( and whether or not they are in + // the view frustum ). + for( s32 j = 0; j < TerrainData.PatchCount * TerrainData.PatchCount; ++j ) + { + if( frustum->getBoundingBox().intersectsWithBox( TerrainData.Patches[j].BoundingBox ) ) + { + f32 distance = (cameraPosition.X - TerrainData.Patches[j].Center.X) * (cameraPosition.X - TerrainData.Patches[j].Center.X) + + (cameraPosition.Y - TerrainData.Patches[j].Center.Y) * (cameraPosition.Y - TerrainData.Patches[j].Center.Y) + + (cameraPosition.Z - TerrainData.Patches[j].Center.Z) * (cameraPosition.Z - TerrainData.Patches[j].Center.Z); + + for( s32 i = TerrainData.MaxLOD - 1; i >= 0; --i ) + { + if( distance >= TerrainData.LODDistanceThreshold[i] ) + { + TerrainData.Patches[j].CurrentLOD = i; + break; + } + //else if( i == 0 ) + { + // If we've turned off a patch from viewing, because of the frustum, and now we turn around and it's + // too close, we need to turn it back on, at the highest LOD. The if above doesn't catch this. + TerrainData.Patches[j].CurrentLOD = 0; + } + } + } + else + { + TerrainData.Patches[j].CurrentLOD = -1; + } + } + } + + + void CTerrainSceneNode::preRenderIndicesCalculations() + { + IndicesToRender = 0; + s32 index11; + s32 index21; + s32 index12; + s32 index22; + + // Then generate the indices for all patches that are visible. + for( s32 i = 0; i < TerrainData.PatchCount; ++i ) + { + for( s32 j = 0; j < TerrainData.PatchCount; ++j ) + { + s32 index = i * TerrainData.PatchCount + j; + if( TerrainData.Patches[index].CurrentLOD >= 0 ) + { + s32 x = 0; + s32 z = 0; + + // calculate the step we take this patch, based on the patches current LOD + s32 step = 1 << TerrainData.Patches[index].CurrentLOD; + + // Loop through patch and generate indices + while( z < TerrainData.CalcPatchSize ) + { + index11 = getIndex( j, i, index, x, z ); + index21 = getIndex( j, i, index, x + step, z ); + index12 = getIndex( j, i, index, x, z + step ); + index22 = getIndex( j, i, index, x + step, z + step ); + + RenderBuffer.Indices[IndicesToRender++] = index12; + RenderBuffer.Indices[IndicesToRender++] = index11; + RenderBuffer.Indices[IndicesToRender++] = index22; + RenderBuffer.Indices[IndicesToRender++] = index22; + RenderBuffer.Indices[IndicesToRender++] = index11; + RenderBuffer.Indices[IndicesToRender++] = index21; + + // increment index position horizontally + x += step; + + if ( x >= TerrainData.CalcPatchSize ) // we've hit an edge + { + x = 0; + z += step; + } + } + } + } + } + + if ( DynamicSelectorUpdate && TriangleSelector ) + { + CTerrainTriangleSelector* selector = (CTerrainTriangleSelector*)TriangleSelector; + selector->setTriangleData ( this, -1 ); + } + } + + + //! Render the scene node + void CTerrainSceneNode::render() + { + if (!IsVisible || !SceneManager->getActiveCamera()) + return; + + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + + core::matrix4 identity; + driver->setTransform (video::ETS_WORLD, identity); + + driver->setMaterial(Mesh.getMeshBuffer(0)->getMaterial()); + + // For use with geomorphing + driver->drawVertexPrimitiveList( + RenderBuffer.getVertices(), RenderBuffer.getVertexCount(), + RenderBuffer.getIndices(), IndicesToRender / 3, + video::EVT_2TCOORDS, EPT_TRIANGLES); + + // for debug purposes only: + if (DebugDataVisible ) + { + video::SMaterial m; + m.Lighting = false; + driver->setMaterial(m); + driver->draw3DBox( TerrainData.BoundingBox, video::SColor(0,255,255,255)); + + s32 count = TerrainData.PatchCount * TerrainData.PatchCount; + s32 visible = 0; + for( s32 j = 0; j < count; ++j ) + { + driver->draw3DBox( TerrainData.Patches[j].BoundingBox, video::SColor(0,255,0,0)); + visible += ( TerrainData.Patches[j].CurrentLOD >= 0 ); + } + + static u32 lastTime = 0; + + u32 now = os::Timer::getRealTime (); + if ( now - lastTime > 1000 ) + { + char buf[64]; + sprintf ( buf, "Count: %d, Visible: %d", count, visible ); + os::Printer::print ( buf ); + + lastTime = now; + } + + } + + } + + //! Return the bounding box of the entire terrain. + const core::aabbox3d& CTerrainSceneNode::getBoundingBox() const + { + return TerrainData.BoundingBox; + } + + //! Return the bounding box of a patch + const core::aabbox3d& CTerrainSceneNode::getBoundingBox( s32 patchX, s32 patchZ ) const + { + return TerrainData.Patches[patchX * TerrainData.PatchCount + patchZ].BoundingBox; + } + + //! Gets the meshbuffer data based on a specified Level of Detail. + //! \param mb: A reference to an SMeshBuffer object + //! \param LOD: The Level Of Detail you want the indices from. + void CTerrainSceneNode::getMeshBufferForLOD(SMeshBufferLightMap& mb, s32 LOD ) + { + if ( LOD < 0 ) + LOD = 0; + else if ( LOD > TerrainData.MaxLOD - 1 ) + LOD = TerrainData.MaxLOD - 1; + + s32 numVertices = Mesh.getMeshBuffer( 0 )->getVertexCount ( ); + mb.Vertices.reallocate ( numVertices ); + video::S3DVertex2TCoords* vertices = (video::S3DVertex2TCoords*)Mesh.getMeshBuffer ( 0 )->getVertices ( ); + + s32 i; + for (i=0; i= TerrainData.CalcPatchSize) // we've hit an edge + { + x = 0; + z += step; + } + } + } + } + } + + //! Gets the indices for a specified patch at a specified Level of Detail. + //! \param mb: A reference to an array of u32 indices. + //! \param patchX: Patch x coordinate. + //! \param patchZ: Patch z coordinate. + //! \param LOD: The level of detail to get for that patch. If -1, then get + //! the CurrentLOD. If the CurrentLOD is set to -1, meaning it's not shown, + //! then it will retrieve the triangles at the highest LOD ( 0 ). + //! \return: Number if indices put into the buffer. + s32 CTerrainSceneNode::getIndicesForPatch(core::array& indices, s32 patchX, s32 patchZ, s32 LOD ) + { + if ( patchX < 0 || patchX > TerrainData.PatchCount - 1 || patchZ < 0 || patchZ > TerrainData.PatchCount - 1 ) + return -1; + + if ( LOD < -1 || LOD > TerrainData.MaxLOD - 1 ) + return -1; + + s32 rv = 0; + core::array cLODs; + bool setLODs = false; + + // If LOD of -1 was passed in, use the CurrentLOD of the patch specified + if ( LOD == -1 ) + { + LOD = TerrainData.Patches[patchX * TerrainData.PatchCount + patchZ].CurrentLOD; + } + else + { + getCurrentLODOfPatches(cLODs); + setCurrentLODOfPatches(LOD); + setLODs = true; + } + + if ( LOD < 0 ) + return -2; // Patch not visible, don't generate indices. + + // calculate the step we take for this LOD + s32 step = 1 << LOD; + + // Generate the indices for the specified patch at the specified LOD + s32 index = patchX * TerrainData.PatchCount + patchZ; + + s32 x = 0; + s32 z = 0; + s32 index11; + s32 index21; + s32 index12; + s32 index22; + + indices.set_used ( TerrainData.PatchSize * TerrainData.PatchSize * 6 ); + + // Loop through patch and generate indices + while (z= TerrainData.CalcPatchSize) // we've hit an edge + { + x = 0; + z += step; + } + } + + if ( setLODs ) + setCurrentLODOfPatches (cLODs); + + return rv; + } + + //! Populates an array with the CurrentLOD of each patch. + //! \param LODs: A reference to a core::array to hold the values + //! \return Returns the number of elements in the array + s32 CTerrainSceneNode::getCurrentLODOfPatches(core::array& LODs) + { + s32 numLODs; + LODs.clear ( ); + + for ( numLODs = 0; numLODs < TerrainData.PatchCount * TerrainData.PatchCount; numLODs++ ) + LODs.push_back ( TerrainData.Patches[numLODs].CurrentLOD ); + + return LODs.size(); + } + + + //! Manually sets the LOD of a patch + //! \param patchX: Patch x coordinate. + //! \param patchZ: Patch z coordinate. + //! \param LOD: The level of detail to set the patch to. + void CTerrainSceneNode::setLODOfPatch( s32 patchX, s32 patchZ, s32 LOD ) + { + TerrainData.Patches[patchX * TerrainData.PatchCount + patchZ].CurrentLOD = LOD; + } + + + //! Override the default generation of distance thresholds for determining the LOD a patch + //! is rendered at. + bool CTerrainSceneNode::overrideLODDistance(s32 LOD, f64 newDistance) + { + OverrideDistanceThreshold = true; + + if ( LOD < 0 || LOD > TerrainData.MaxLOD - 1 ) + return false; + + TerrainData.LODDistanceThreshold[LOD] = newDistance * newDistance; + + return true; + } + + //! Creates a planar texture mapping on the terrain + //! \param resolution: resolution of the planar mapping. This is the value + //! specifying the relation between world space and texture coordinate space. + void CTerrainSceneNode::scaleTexture(f32 resolution, f32 resolution2) + { + const f32 resBySize = resolution / (f32)(TerrainData.Size-1); + const f32 res2BySize = resolution2 / (f32)(TerrainData.Size-1); + u32 index = 0; + f32 xval = 0, zval; + f32 x2val = 0, z2val=0; + for (s32 x=0; xCurrentLOD && + (vX % ( 1 << TerrainData.Patches[PatchIndex].Top->CurrentLOD)) != 0 ) + { + vX = vX - vX % ( 1 << TerrainData.Patches[PatchIndex].Top->CurrentLOD ); + } + } + else + if ( vZ == (u32)TerrainData.CalcPatchSize ) // bottom border + { + if (TerrainData.Patches[PatchIndex].Bottom && + TerrainData.Patches[PatchIndex].CurrentLOD < TerrainData.Patches[PatchIndex].Bottom->CurrentLOD && + (vX % ( 1 << TerrainData.Patches[PatchIndex].Bottom->CurrentLOD)) != 0) + { + vX = vX - vX % ( 1 << TerrainData.Patches[PatchIndex].Bottom->CurrentLOD ); + } + } + + // left border + if ( vX == 0 ) + { + if (TerrainData.Patches[PatchIndex].Left && + TerrainData.Patches[PatchIndex].CurrentLOD < TerrainData.Patches[PatchIndex].Left->CurrentLOD && + ( vZ % ( 1 << TerrainData.Patches[PatchIndex].Left->CurrentLOD ) ) != 0) + { + vZ = vZ - vZ % ( 1 << TerrainData.Patches[PatchIndex].Left->CurrentLOD ); + } + } + else + if ( vX == (u32)TerrainData.CalcPatchSize ) // right border + { + if (TerrainData.Patches[PatchIndex].Right && + TerrainData.Patches[PatchIndex].CurrentLOD < TerrainData.Patches[PatchIndex].Right->CurrentLOD && + ( vZ % ( 1 << TerrainData.Patches[PatchIndex].Right->CurrentLOD ) ) != 0) + { + vZ = vZ - vZ % ( 1 << TerrainData.Patches[PatchIndex].Right->CurrentLOD ); + } + } + + if ( vZ >= (u32)TerrainData.PatchSize ) + vZ = TerrainData.CalcPatchSize; + + if ( vX >= (u32)TerrainData.PatchSize ) + vX = TerrainData.CalcPatchSize; + + return (vZ + ((TerrainData.CalcPatchSize) * PatchZ)) * TerrainData.Size + + (vX + ((TerrainData.CalcPatchSize) * PatchX)); + } + + //! calculate smooth normals + void CTerrainSceneNode::calculateNormals ( SMeshBufferLightMap* pMeshBuffer ) + { + s32 count; + core::vector3df a, b, c, t; + + for (s32 x=0; x0 && z>0) + { + a = pMeshBuffer->Vertices[(x-1)*TerrainData.Size+z-1].Pos; + b = pMeshBuffer->Vertices[(x-1)*TerrainData.Size+z].Pos; + c = pMeshBuffer->Vertices[x*TerrainData.Size+z].Pos; + b -= a; + c -= a; + t = b.crossProduct ( c ); + t.normalize ( ); + normal += t; + + a = pMeshBuffer->Vertices[(x-1)*TerrainData.Size+z-1].Pos; + b = pMeshBuffer->Vertices[x*TerrainData.Size+z-1].Pos; + c = pMeshBuffer->Vertices[x*TerrainData.Size+z].Pos; + b -= a; + c -= a; + t = b.crossProduct ( c ); + t.normalize ( ); + normal += t; + + count += 2; + } + + // top right + if (x>0 && zVertices[(x-1)*TerrainData.Size+z].Pos; + b = pMeshBuffer->Vertices[(x-1)*TerrainData.Size+z+1].Pos; + c = pMeshBuffer->Vertices[x*TerrainData.Size+z+1].Pos; + b -= a; + c -= a; + t = b.crossProduct ( c ); + t.normalize ( ); + normal += t; + + a = pMeshBuffer->Vertices[(x-1)*TerrainData.Size+z].Pos; + b = pMeshBuffer->Vertices[x*TerrainData.Size+z+1].Pos; + c = pMeshBuffer->Vertices[x*TerrainData.Size+z].Pos; + b -= a; + c -= a; + t = b.crossProduct ( c ); + t.normalize ( ); + normal += t; + + count += 2; + } + + // bottom right + if (xVertices[x*TerrainData.Size+z+1].Pos; + b = pMeshBuffer->Vertices[x*TerrainData.Size+z].Pos; + c = pMeshBuffer->Vertices[(x+1)*TerrainData.Size+z+1].Pos; + b -= a; + c -= a; + t = b.crossProduct ( c ); + t.normalize ( ); + normal += t; + + a = pMeshBuffer->Vertices[x*TerrainData.Size+z+1].Pos; + b = pMeshBuffer->Vertices[(x+1)*TerrainData.Size+z+1].Pos; + c = pMeshBuffer->Vertices[(x+1)*TerrainData.Size+z].Pos; + b -= a; + c -= a; + t = b.crossProduct ( c ); + t.normalize ( ); + normal += t; + + count += 2; + } + + // bottom left + if (x0) + { + a = pMeshBuffer->Vertices[x*TerrainData.Size+z-1].Pos; + b = pMeshBuffer->Vertices[x*TerrainData.Size+z].Pos; + c = pMeshBuffer->Vertices[(x+1)*TerrainData.Size+z].Pos; + b -= a; + c -= a; + t = b.crossProduct ( c ); + t.normalize ( ); + normal += t; + + a = pMeshBuffer->Vertices[x*TerrainData.Size+z-1].Pos; + b = pMeshBuffer->Vertices[(x+1)*TerrainData.Size+z].Pos; + c = pMeshBuffer->Vertices[(x+1)*TerrainData.Size+z-1].Pos; + b -= a; + c -= a; + t = b.crossProduct ( c ); + t.normalize ( ); + normal += t; + + count += 2; + } + + if ( count != 0 ) + { + normal.normalize ( ); + } + else + { + normal.set( 0.0f, 1.0f, 0.0f ); + } + + pMeshBuffer->Vertices[x * TerrainData.Size + z].Normal = normal; + } + } + + //! create patches, stuff that needs to be done only once for patches goes here. + void CTerrainSceneNode::createPatches() + { + TerrainData.PatchCount = (TerrainData.Size - 1) / ( TerrainData.CalcPatchSize ); + + if (TerrainData.Patches) + delete [] TerrainData.Patches; + + TerrainData.Patches = new SPatch[TerrainData.PatchCount * TerrainData.PatchCount]; + +#if 0 + gui::IGUIFont* font = SceneManager->getGUIEnvironment()->getFont("../../media/bigfont.png"); + font->setKerning ( -2 ); + for( s32 j = 0; j < TerrainData.PatchCount * TerrainData.PatchCount; ++j ) + { + const core::stringw buf(j); + TerrainData.Patches[j].DebugText = SceneManager->addTextSceneNode ( + font, + buf.c_str(), + 0xFFFFFFFF, + 0 + ); + } +#endif + + + } + + //! used to calculate the internal STerrainData structure both at creation and after scaling/position calls. + void CTerrainSceneNode::calculatePatchData() + { + // Reset the Terrains Bounding Box for re-calculation + TerrainData.BoundingBox = core::aabbox3df ( 999999.9f, 999999.9f, 999999.9f, -999999.9f, -999999.9f, -999999.9f ); + + for( s32 x = 0; x < TerrainData.PatchCount; ++x ) + { + for( s32 z = 0; z < TerrainData.PatchCount; ++z ) + { + s32 index = x * TerrainData.PatchCount + z; + TerrainData.Patches[index].CurrentLOD = 0; + + // For each patch, calculate the bounding box ( mins and maxes ) + TerrainData.Patches[index].BoundingBox = core::aabbox3df (999999.9f, 999999.9f, 999999.9f, + -999999.9f, -999999.9f, -999999.9f ); + + for( s32 xx = x*(TerrainData.CalcPatchSize); xx <= ( x + 1 ) * TerrainData.CalcPatchSize; ++xx ) + for( s32 zz = z*(TerrainData.CalcPatchSize); zz <= ( z + 1 ) * TerrainData.CalcPatchSize; ++zz ) + TerrainData.Patches[index].BoundingBox.addInternalPoint( RenderBuffer.Vertices[xx * TerrainData.Size + zz].Pos ); + + // Reconfigure the bounding box of the terrain as a whole + TerrainData.BoundingBox.addInternalBox( TerrainData.Patches[index].BoundingBox ); + + // get center of Patch + TerrainData.Patches[index].Center = TerrainData.Patches[index].BoundingBox.getCenter(); + + // Assign Neighbours + // Top + if( x > 0 ) + TerrainData.Patches[index].Top = &TerrainData.Patches[(x-1) * TerrainData.PatchCount + z]; + else + TerrainData.Patches[index].Top = 0; + + // Bottom + if( x < TerrainData.PatchCount - 1 ) + TerrainData.Patches[index].Bottom = &TerrainData.Patches[(x+1) * TerrainData.PatchCount + z]; + else + TerrainData.Patches[index].Bottom = 0; + + // Left + if( z > 0 ) + TerrainData.Patches[index].Left = &TerrainData.Patches[x * TerrainData.PatchCount + z - 1]; + else + TerrainData.Patches[index].Left = 0; + + // Right + if( z < TerrainData.PatchCount - 1 ) + TerrainData.Patches[index].Right = &TerrainData.Patches[x * TerrainData.PatchCount + z + 1]; + else + TerrainData.Patches[index].Right = 0; + + if ( TerrainData.Patches[index].DebugText ) + { + TerrainData.Patches[index].DebugText->setPosition ( TerrainData.Patches[index].Center ); + } + + } + } + + // get center of Terrain + TerrainData.Center = TerrainData.BoundingBox.getCenter(); + + // if the default rotation pivot is still being used, update it. + if( UseDefaultRotationPivot ) + { + TerrainData.RotationPivot = TerrainData.Center; + } + } + + + //! used to calculate or recalculate the distance thresholds + void CTerrainSceneNode::calculateDistanceThresholds(bool scalechanged) + { + // Only update the LODDistanceThreshold if it's not manually changed + if (!OverrideDistanceThreshold) + { + if( TerrainData.LODDistanceThreshold ) + { + delete [] TerrainData.LODDistanceThreshold; + } + + // Determine new distance threshold for determining what LOD to draw patches at + TerrainData.LODDistanceThreshold = new f64[TerrainData.MaxLOD]; + + for (s32 i=0; i& lodarray) + { + for (s32 i=0; i= 0 && X < TerrainData.Size && Z >= 0 && Z <= TerrainData.Size ) + { + video::S3DVertex2TCoords* Vertices = (video::S3DVertex2TCoords*)Mesh.getMeshBuffer( 0 )->getVertices(); + core::vector3df a = Vertices[ X * TerrainData.Size + Z ].Pos; + core::vector3df b = Vertices[ (X + 1) * TerrainData.Size + Z ].Pos; + core::vector3df c = Vertices[ X * TerrainData.Size + ( Z + 1 ) ].Pos; + core::vector3df d = Vertices[ (X + 1) * TerrainData.Size + ( Z + 1 ) ].Pos; + + f32 dx = pos.X - X; + f32 dz = pos.Z - Z; + f32 invDX = 1.0f - dx; + + if( dz < invDX ) + { + f32 uy = a.Y - c.Y; + f32 vy = d.Y - c.Y; + height = c.Y + core::lerp( 0.0f, uy, dx ) + core::lerp( 0.0f, vy, dz ); + } + else + { + f32 uy = a.Y - b.Y; + f32 vy = d.Y - b.Y; + height = b.Y + core::lerp( 0.0f, uy, invDX ) + core::lerp( 0.0f, vy, 1.0f - dz ); + } + height *= TerrainData.Scale.Y; + height += TerrainData.Position.Y; + } + + return height; + } + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CTerrainSceneNode.h b/src/dep/src/irrlicht/CTerrainSceneNode.h index ee2b6dd..5eab771 100644 --- a/src/dep/src/irrlicht/CTerrainSceneNode.h +++ b/src/dep/src/irrlicht/CTerrainSceneNode.h @@ -1,316 +1,316 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// The code for the TerrainSceneNode is based on the GeoMipMapSceneNode -// developed by Spintz. He made it available for Irrlicht and allowed it to be -// distributed under this licence. I only modified some parts. A lot of thanks go to him. - -#ifndef __C_TERRAIN_SCENE_NODE_H__ -#define __C_TERRAIN_SCENE_NODE_H__ - -#include "ITerrainSceneNode.h" -#include "SMesh.h" -#include "IReadFile.h" -#include "ITextSceneNode.h" - -namespace irr -{ -namespace scene -{ - //! A scene node for displaying terrain using the geo mip map algorithm. - /** The code for the TerrainSceneNode is based on the GeoMipMapSceneNode - * developed by Spintz. He made it available for Irrlicht and allowed it to be - * distributed under this licence. I only modified some parts. A lot of thanks go to him. - **/ - class CTerrainSceneNode : public ITerrainSceneNode - { - public: - - //! constructor - //! \param parent: The node which this node is a child of. Making this node a child of another node, or - //! making it a parent of another node is yet untested and most likely does not work properly. - //! \param mgr: Pointer to the scene manager. - //! \param id: The id of the node - //! \param maxLOD: The maximum LOD ( Level of Detail ) for the node. - //! \param patchSize: An E_GEOMIPMAP_PATCH_SIZE enumeration defining the size of each patch of the terrain. - //! \param position: The absolute position of this node. - //! \param rotation: The absolute rotation of this node. ( NOT YET IMPLEMENTED ) - //! \param scale: The scale factor for the terrain. If you're using a heightmap of size 128x128 and would like - //! your terrain to be 12800x12800 in game units, then use a scale factor of ( core::vector ( 100.0f, 100.0f, 100.0f ). - //! If you use a Y scaling factor of 0.0f, then your terrain will be flat. - CTerrainSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - s32 maxLOD = 4, E_TERRAIN_PATCH_SIZE patchSize = ETPS_17, - const core::vector3df& position = core::vector3df(0.0f, 0.0f, 0.0f), - const core::vector3df& rotation = core::vector3df(0.0f, 0.0f, 0.0f), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - ~CTerrainSceneNode(); - - //! Initializes the terrain data. Loads the vertices from the heightMapFile. - virtual bool loadHeightMap(io::IReadFile* file, - video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 ); - - //! Initializes the terrain data. Loads the vertices from the heightMapFile. - virtual bool loadHeightMapRAW(io::IReadFile* file, s32 bitsPerPixel = 16, - video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 ); - - //! Returns the material based on the zero based index i. This scene node only uses - //! 1 material. - //! \param i: Zero based index i. UNUSED, left in for virtual purposes. - //! \return Returns the single material this scene node uses. - virtual video::SMaterial& getMaterial ( u32 i ) - { - return Mesh.getMeshBuffer(i)->getMaterial(); - } - - //! Returns amount of materials used by this scene node ( always 1 ) - //! \return Returns current count of materials used by this scene node ( always 1 ) - virtual u32 getMaterialCount() - { - return Mesh.getMeshBufferCount(); - } - - //! Gets the last scaling factor applied to the scene node. This value only represents the - //! last scaling factor presented to the node. For instance, if you make create the node - //! with a scale factor of ( 1.0f, 1.0f, 1.0f ) then call setScale ( 50.0f, 5.0f, 50.0f ), - //! then make another call to setScale with the values ( 2.0f, 2.0f, 2.0f ), this will return - //! core::vector3df ( 2.0f, 2.0f, 2.0f ), although the total scaling of the scene node is - //! core::vector3df ( 100.0f, 10.0f, 100.0f ). - //! \return Returns the last scaling factor passed to the scene node. - virtual core::vector3df getScale() const - { - return TerrainData.Scale; - } - - //! Scales the scene nodes vertices by the vector specified. - //! \param scale: Scaling factor to apply to the node. - virtual void setScale(const core::vector3df& scale); - - //! Gets the last rotation factor applied to the scene node. - //! \return Returns the last rotation factor applied to the scene node. - virtual const core::vector3df& getRotation() const - { - return TerrainData.Rotation; - } - - //! Rotates the node. This only modifies the relative rotation of the node. - //! \param rotation: New rotation of the node in degrees. - virtual void setRotation(const core::vector3df& rotation); - - //! Sets the pivot point for rotation of this node. This is useful for the TiledTerrainManager to - //! rotate all terrain tiles around a global world point. - //! NOTE: The default for the RotationPivot will be the center of the individual tile. - virtual void setRotationPivot( const core::vector3df& pivot ); - - //! Gets the last positioning vector applied to the scene node. - //! \return Returns the last position vector applied to the scene node. - virtual const core::vector3df getPosition() const - { - return TerrainData.Position; - } - - //! Moves the scene nodes vertices by the vector specified. - //! \param newpos: Vector specifying how much to move each vertex of the scene node. - virtual void setPosition(const core::vector3df& newpos); - - //! Updates the scene nodes indices if the camera has moved or rotated by a certain - //! threshold, which can be changed using the SetCameraMovementDeltaThreshold and - //! SetCameraRotationDeltaThreshold functions. This also determines if a given patch - //! for the scene node is within the view frustum and if it's not the indices are not - //! generated for that patch. - virtual void OnRegisterSceneNode(); - - //! Render the scene node - virtual void render(); - - //! Return the bounding box of the entire terrain. - virtual const core::aabbox3d& getBoundingBox() const; - - //! Return the bounding box of a patch - virtual const core::aabbox3d& getBoundingBox(s32 patchX, s32 patchZ) const; - - //! Return the number of indices currently used to draw the scene node. - virtual u32 getIndexCount() { return IndicesToRender; } - - //! Returns the mesh - virtual IMesh* getMesh() { return &Mesh; } - - //! Gets the meshbuffer data based on a specified Level of Detail. - //! \param mb: A reference to an SMeshBufferLightMap object - //! \param LOD: The Level Of Detail you want the indices from. - virtual void getMeshBufferForLOD(SMeshBufferLightMap& mb, s32 LOD ); - - //! Gets the indices for a specified patch at a specified Level of Detail. - //! \param indices: A reference to an array of u32 indices. - //! \param patchX: Patch x coordinate. - //! \param patchZ: Patch z coordinate. - //! \param LOD: The level of detail to get for that patch. If -1, then get - //! the CurrentLOD. If the CurrentLOD is set to -1, meaning it's not shown, - //! then it will retrieve the triangles at the highest LOD ( 0 ). - //! \return: Number if indices put into the buffer. - virtual s32 getIndicesForPatch(core::array& indices, - s32 patchX, s32 patchZ, s32 LOD = 0 ); - - //! Populates an array with the CurrentLOD of each patch. - //! \param LODs: A reference to a core::array to hold the values - //! \return Returns the number of elements in the array - virtual s32 getCurrentLODOfPatches(core::array& LODs); - - //! Manually sets the LOD of a patch - //! \param patchX: Patch x coordinate. - //! \param patchZ: Patch z coordinate. - //! \param LOD: The level of detail to set the patch to. - virtual void setLODOfPatch( s32 patchX, s32 patchZ, s32 LOD ); - - //! Returns center of terrain. - virtual core::vector3df getTerrainCenter() - { - return TerrainData.Center; - } - - //! Returns center of terrain. - virtual f32 getHeight( f32 x, f32 y ); - - //! Sets the movement camera threshold which is used to determine when to recalculate - //! indices for the scene node. The default value is 10.0f. - virtual void setCameraMovementDelta(f32 delta) - { - CameraMovementDelta = delta; - } - - //! Sets the rotation camera threshold which is used to determine when to recalculate - //! indices for the scene node. The default value is 1.0f. - virtual void setCameraRotationDelta(f32 delta) - { - CameraRotationDelta = delta; - } - - //! Sets whether or not the node should dynamically update it's associated selector when - //! the geomipmap data changes. - //! param bVal: Boolean value representing whether or not to update selector dynamically. - //! NOTE: Temporarily disabled while working out issues with DynamicSelectorUpdate - virtual void setDynamicSelectorUpdate(bool bVal ) { DynamicSelectorUpdate = false; } - //virtual void setDynamicSelectorUpdate ( bool bVal ) { DynamicSelectorUpdate = bVal; } - - //! Override the default generation of distance thresholds for determining the LOD a patch - //! is rendered at. If any LOD is overridden, then the scene node will no longer apply - //! scaling factors to these values. If you override these distances, and then apply - //! a scale to the scene node, it is your responsibility to update the new distances to - //! work best with your new terrain size. - virtual bool overrideLODDistance( s32 LOD, f64 newDistance ); - - //! Scales the base texture, similar to makePlanarTextureMapping - virtual void scaleTexture(f32 scale = 1.0f, f32 scale2=0.0f ); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_TERRAIN; } - - private: - - friend class CTerrainTriangleSelector; - friend class CTiledTerrainSceneNodeManager; - - struct SPatch - { - SPatch() - : CurrentLOD(-1), DebugText(0), - Top(0), Bottom(0), Right(0), Left(0) - { - } - - s32 CurrentLOD; - core::aabbox3df BoundingBox; - core::vector3df Center; - scene::ITextSceneNode* DebugText; - SPatch* Top; - SPatch* Bottom; - SPatch* Right; - SPatch* Left; - }; - - struct STerrainData - { - STerrainData() - : Size(0), PatchSize(0), CalcPatchSize(0), - PatchCount(0), MaxLOD(0), - BoundingBox(core::aabbox3df( 99999.9f, 99999.9f, 99999.9f, -99999.9f, -99999.9f, -99999.9f)), - LODDistanceThreshold(0), Patches(0) - { - } - - STerrainData(s32 patchSize, s32 maxLOD, const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) - : Size(0), Position(position), Rotation(rotation), Scale(scale), - PatchSize(patchSize), CalcPatchSize(patchSize-1), - PatchCount(0), MaxLOD(maxLOD), - BoundingBox(core::aabbox3df( 99999.9f, 99999.9f, 99999.9f, -99999.9f, -99999.9f, -99999.9f)), - LODDistanceThreshold(0), Patches(0) - { - } - - s32 Size; - core::vector3df Position; - core::vector3df Rotation; - core::vector3df RotationPivot; - core::vector3df Scale; - core::vector3df Center; - s32 PatchSize; - s32 CalcPatchSize; - s32 PatchCount; - s32 MaxLOD; - core::aabbox3df BoundingBox; - f64* LODDistanceThreshold; - SPatch* Patches; - }; - - virtual void preRenderLODCalculations(); - virtual void preRenderLODCalculations_old(); - virtual void preRenderIndicesCalculations(); - - //! get indices when generating index data for patches at varying levels of detail. - u32 getIndex(const s32& PatchX, const s32& PatchZ, const s32& PatchIndex, u32 vX, u32 vZ); - - //! calculate smooth normals - void calculateNormals(SMeshBufferLightMap* pMeshBuffer ); - - //! create patches, stuff that needs to only be done once for patches goes here. - void createPatches(); - - //! calculate the internal STerrainData structure - void calculatePatchData(); - - //! calculate or recalculate the distance thresholds - void calculateDistanceThresholds(bool scalechanged = false); - - //! sets the CurrentLOD of all patches to the specified LOD - void setCurrentLODOfPatches(s32 i); - - //! sets the CurrentLOD of TerrainData patches to the LODs specified in the array - void setCurrentLODOfPatches(core::array& lodarray); - - //! Apply transformation changes( scale, position, rotation ) - void applyTransformation(); - - STerrainData TerrainData; - SMesh Mesh; - SMeshBufferLightMap RenderBuffer; - u32 VerticesToRender; - u32 IndicesToRender; - - bool DynamicSelectorUpdate; - bool OverrideDistanceThreshold; - bool UseDefaultRotationPivot; - - core::vector3df OldCameraPosition; - core::vector3df OldCameraRotation; - f32 CameraMovementDelta; - f32 CameraRotationDelta; - - }; - -} // end namespace scene -} // end namespace irr - - -#endif // __C_TERRAIN_SCENE_NODE_H__ - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// The code for the TerrainSceneNode is based on the GeoMipMapSceneNode +// developed by Spintz. He made it available for Irrlicht and allowed it to be +// distributed under this licence. I only modified some parts. A lot of thanks go to him. + +#ifndef __C_TERRAIN_SCENE_NODE_H__ +#define __C_TERRAIN_SCENE_NODE_H__ + +#include "ITerrainSceneNode.h" +#include "SMesh.h" +#include "IReadFile.h" +#include "ITextSceneNode.h" + +namespace irr +{ +namespace scene +{ + //! A scene node for displaying terrain using the geo mip map algorithm. + /** The code for the TerrainSceneNode is based on the GeoMipMapSceneNode + * developed by Spintz. He made it available for Irrlicht and allowed it to be + * distributed under this licence. I only modified some parts. A lot of thanks go to him. + **/ + class CTerrainSceneNode : public ITerrainSceneNode + { + public: + + //! constructor + //! \param parent: The node which this node is a child of. Making this node a child of another node, or + //! making it a parent of another node is yet untested and most likely does not work properly. + //! \param mgr: Pointer to the scene manager. + //! \param id: The id of the node + //! \param maxLOD: The maximum LOD ( Level of Detail ) for the node. + //! \param patchSize: An E_GEOMIPMAP_PATCH_SIZE enumeration defining the size of each patch of the terrain. + //! \param position: The absolute position of this node. + //! \param rotation: The absolute rotation of this node. ( NOT YET IMPLEMENTED ) + //! \param scale: The scale factor for the terrain. If you're using a heightmap of size 128x128 and would like + //! your terrain to be 12800x12800 in game units, then use a scale factor of ( core::vector ( 100.0f, 100.0f, 100.0f ). + //! If you use a Y scaling factor of 0.0f, then your terrain will be flat. + CTerrainSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + s32 maxLOD = 4, E_TERRAIN_PATCH_SIZE patchSize = ETPS_17, + const core::vector3df& position = core::vector3df(0.0f, 0.0f, 0.0f), + const core::vector3df& rotation = core::vector3df(0.0f, 0.0f, 0.0f), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); + + ~CTerrainSceneNode(); + + //! Initializes the terrain data. Loads the vertices from the heightMapFile. + virtual bool loadHeightMap(io::IReadFile* file, + video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 ); + + //! Initializes the terrain data. Loads the vertices from the heightMapFile. + virtual bool loadHeightMapRAW(io::IReadFile* file, s32 bitsPerPixel = 16, + video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 ); + + //! Returns the material based on the zero based index i. This scene node only uses + //! 1 material. + //! \param i: Zero based index i. UNUSED, left in for virtual purposes. + //! \return Returns the single material this scene node uses. + virtual video::SMaterial& getMaterial ( u32 i ) + { + return Mesh.getMeshBuffer(i)->getMaterial(); + } + + //! Returns amount of materials used by this scene node ( always 1 ) + //! \return Returns current count of materials used by this scene node ( always 1 ) + virtual u32 getMaterialCount() + { + return Mesh.getMeshBufferCount(); + } + + //! Gets the last scaling factor applied to the scene node. This value only represents the + //! last scaling factor presented to the node. For instance, if you make create the node + //! with a scale factor of ( 1.0f, 1.0f, 1.0f ) then call setScale ( 50.0f, 5.0f, 50.0f ), + //! then make another call to setScale with the values ( 2.0f, 2.0f, 2.0f ), this will return + //! core::vector3df ( 2.0f, 2.0f, 2.0f ), although the total scaling of the scene node is + //! core::vector3df ( 100.0f, 10.0f, 100.0f ). + //! \return Returns the last scaling factor passed to the scene node. + virtual core::vector3df getScale() const + { + return TerrainData.Scale; + } + + //! Scales the scene nodes vertices by the vector specified. + //! \param scale: Scaling factor to apply to the node. + virtual void setScale(const core::vector3df& scale); + + //! Gets the last rotation factor applied to the scene node. + //! \return Returns the last rotation factor applied to the scene node. + virtual const core::vector3df& getRotation() const + { + return TerrainData.Rotation; + } + + //! Rotates the node. This only modifies the relative rotation of the node. + //! \param rotation: New rotation of the node in degrees. + virtual void setRotation(const core::vector3df& rotation); + + //! Sets the pivot point for rotation of this node. This is useful for the TiledTerrainManager to + //! rotate all terrain tiles around a global world point. + //! NOTE: The default for the RotationPivot will be the center of the individual tile. + virtual void setRotationPivot( const core::vector3df& pivot ); + + //! Gets the last positioning vector applied to the scene node. + //! \return Returns the last position vector applied to the scene node. + virtual const core::vector3df getPosition() const + { + return TerrainData.Position; + } + + //! Moves the scene nodes vertices by the vector specified. + //! \param newpos: Vector specifying how much to move each vertex of the scene node. + virtual void setPosition(const core::vector3df& newpos); + + //! Updates the scene nodes indices if the camera has moved or rotated by a certain + //! threshold, which can be changed using the SetCameraMovementDeltaThreshold and + //! SetCameraRotationDeltaThreshold functions. This also determines if a given patch + //! for the scene node is within the view frustum and if it's not the indices are not + //! generated for that patch. + virtual void OnRegisterSceneNode(); + + //! Render the scene node + virtual void render(); + + //! Return the bounding box of the entire terrain. + virtual const core::aabbox3d& getBoundingBox() const; + + //! Return the bounding box of a patch + virtual const core::aabbox3d& getBoundingBox(s32 patchX, s32 patchZ) const; + + //! Return the number of indices currently used to draw the scene node. + virtual u32 getIndexCount() { return IndicesToRender; } + + //! Returns the mesh + virtual IMesh* getMesh() { return &Mesh; } + + //! Gets the meshbuffer data based on a specified Level of Detail. + //! \param mb: A reference to an SMeshBufferLightMap object + //! \param LOD: The Level Of Detail you want the indices from. + virtual void getMeshBufferForLOD(SMeshBufferLightMap& mb, s32 LOD ); + + //! Gets the indices for a specified patch at a specified Level of Detail. + //! \param indices: A reference to an array of u32 indices. + //! \param patchX: Patch x coordinate. + //! \param patchZ: Patch z coordinate. + //! \param LOD: The level of detail to get for that patch. If -1, then get + //! the CurrentLOD. If the CurrentLOD is set to -1, meaning it's not shown, + //! then it will retrieve the triangles at the highest LOD ( 0 ). + //! \return: Number if indices put into the buffer. + virtual s32 getIndicesForPatch(core::array& indices, + s32 patchX, s32 patchZ, s32 LOD = 0 ); + + //! Populates an array with the CurrentLOD of each patch. + //! \param LODs: A reference to a core::array to hold the values + //! \return Returns the number of elements in the array + virtual s32 getCurrentLODOfPatches(core::array& LODs); + + //! Manually sets the LOD of a patch + //! \param patchX: Patch x coordinate. + //! \param patchZ: Patch z coordinate. + //! \param LOD: The level of detail to set the patch to. + virtual void setLODOfPatch( s32 patchX, s32 patchZ, s32 LOD ); + + //! Returns center of terrain. + virtual core::vector3df getTerrainCenter() + { + return TerrainData.Center; + } + + //! Returns center of terrain. + virtual f32 getHeight( f32 x, f32 y ); + + //! Sets the movement camera threshold which is used to determine when to recalculate + //! indices for the scene node. The default value is 10.0f. + virtual void setCameraMovementDelta(f32 delta) + { + CameraMovementDelta = delta; + } + + //! Sets the rotation camera threshold which is used to determine when to recalculate + //! indices for the scene node. The default value is 1.0f. + virtual void setCameraRotationDelta(f32 delta) + { + CameraRotationDelta = delta; + } + + //! Sets whether or not the node should dynamically update it's associated selector when + //! the geomipmap data changes. + //! param bVal: Boolean value representing whether or not to update selector dynamically. + //! NOTE: Temporarily disabled while working out issues with DynamicSelectorUpdate + virtual void setDynamicSelectorUpdate(bool bVal ) { DynamicSelectorUpdate = false; } + //virtual void setDynamicSelectorUpdate ( bool bVal ) { DynamicSelectorUpdate = bVal; } + + //! Override the default generation of distance thresholds for determining the LOD a patch + //! is rendered at. If any LOD is overridden, then the scene node will no longer apply + //! scaling factors to these values. If you override these distances, and then apply + //! a scale to the scene node, it is your responsibility to update the new distances to + //! work best with your new terrain size. + virtual bool overrideLODDistance( s32 LOD, f64 newDistance ); + + //! Scales the base texture, similar to makePlanarTextureMapping + virtual void scaleTexture(f32 scale = 1.0f, f32 scale2=0.0f ); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_TERRAIN; } + + private: + + friend class CTerrainTriangleSelector; + friend class CTiledTerrainSceneNodeManager; + + struct SPatch + { + SPatch() + : CurrentLOD(-1), DebugText(0), + Top(0), Bottom(0), Right(0), Left(0) + { + } + + s32 CurrentLOD; + core::aabbox3df BoundingBox; + core::vector3df Center; + scene::ITextSceneNode* DebugText; + SPatch* Top; + SPatch* Bottom; + SPatch* Right; + SPatch* Left; + }; + + struct STerrainData + { + STerrainData() + : Size(0), PatchSize(0), CalcPatchSize(0), + PatchCount(0), MaxLOD(0), + BoundingBox(core::aabbox3df( 99999.9f, 99999.9f, 99999.9f, -99999.9f, -99999.9f, -99999.9f)), + LODDistanceThreshold(0), Patches(0) + { + } + + STerrainData(s32 patchSize, s32 maxLOD, const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) + : Size(0), Position(position), Rotation(rotation), Scale(scale), + PatchSize(patchSize), CalcPatchSize(patchSize-1), + PatchCount(0), MaxLOD(maxLOD), + BoundingBox(core::aabbox3df( 99999.9f, 99999.9f, 99999.9f, -99999.9f, -99999.9f, -99999.9f)), + LODDistanceThreshold(0), Patches(0) + { + } + + s32 Size; + core::vector3df Position; + core::vector3df Rotation; + core::vector3df RotationPivot; + core::vector3df Scale; + core::vector3df Center; + s32 PatchSize; + s32 CalcPatchSize; + s32 PatchCount; + s32 MaxLOD; + core::aabbox3df BoundingBox; + f64* LODDistanceThreshold; + SPatch* Patches; + }; + + virtual void preRenderLODCalculations(); + virtual void preRenderLODCalculations_old(); + virtual void preRenderIndicesCalculations(); + + //! get indices when generating index data for patches at varying levels of detail. + u32 getIndex(const s32& PatchX, const s32& PatchZ, const s32& PatchIndex, u32 vX, u32 vZ); + + //! calculate smooth normals + void calculateNormals(SMeshBufferLightMap* pMeshBuffer ); + + //! create patches, stuff that needs to only be done once for patches goes here. + void createPatches(); + + //! calculate the internal STerrainData structure + void calculatePatchData(); + + //! calculate or recalculate the distance thresholds + void calculateDistanceThresholds(bool scalechanged = false); + + //! sets the CurrentLOD of all patches to the specified LOD + void setCurrentLODOfPatches(s32 i); + + //! sets the CurrentLOD of TerrainData patches to the LODs specified in the array + void setCurrentLODOfPatches(core::array& lodarray); + + //! Apply transformation changes( scale, position, rotation ) + void applyTransformation(); + + STerrainData TerrainData; + SMesh Mesh; + SMeshBufferLightMap RenderBuffer; + u32 VerticesToRender; + u32 IndicesToRender; + + bool DynamicSelectorUpdate; + bool OverrideDistanceThreshold; + bool UseDefaultRotationPivot; + + core::vector3df OldCameraPosition; + core::vector3df OldCameraRotation; + f32 CameraMovementDelta; + f32 CameraRotationDelta; + + }; + +} // end namespace scene +} // end namespace irr + + +#endif // __C_TERRAIN_SCENE_NODE_H__ + diff --git a/src/dep/src/irrlicht/CTerrainTriangleSelector.cpp b/src/dep/src/irrlicht/CTerrainTriangleSelector.cpp index bb8a5d9..e6f6703 100644 --- a/src/dep/src/irrlicht/CTerrainTriangleSelector.cpp +++ b/src/dep/src/irrlicht/CTerrainTriangleSelector.cpp @@ -1,190 +1,190 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CTerrainTriangleSelector.h" -#include "CTerrainSceneNode.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CTerrainTriangleSelector::CTerrainTriangleSelector ( ITerrainSceneNode* node, s32 LOD ) -: SceneNode ( node ) -{ - #ifdef _DEBUG - setDebugName ("CTerrainTriangleSelector"); - #endif - - setTriangleData ( node, LOD ); -} - -//! destructor -CTerrainTriangleSelector::~CTerrainTriangleSelector() -{ - TrianglePatches.TrianglePatchArray.clear ( ); -} - -//! Clears and sets triangle data -void CTerrainTriangleSelector::setTriangleData(ITerrainSceneNode* node, s32 LOD) -{ - core::triangle3df tri; - core::array indices; - CTerrainSceneNode* terrainNode = (CTerrainSceneNode*)node; - - // Get pointer to the GeoMipMaps vertices - video::S3DVertex2TCoords* vertices = (video::S3DVertex2TCoords*)terrainNode->RenderBuffer.getVertices(); - - // Clear current data - TrianglePatches.TotalTriangles = 0; - TrianglePatches.NumPatches = terrainNode->TerrainData.PatchCount * terrainNode->TerrainData.PatchCount; - - TrianglePatches.TrianglePatchArray.reallocate(TrianglePatches.NumPatches); - for (int o=0; oTerrainData.PatchCount; ++x ) - { - for(s32 z = 0; z < terrainNode->TerrainData.PatchCount; ++z ) - { - s32 tIndex = x * terrainNode->TerrainData.PatchCount + z; - TrianglePatches.TrianglePatchArray[tIndex].NumTriangles = 0; - TrianglePatches.TrianglePatchArray[tIndex].Box = terrainNode->getBoundingBox( x, z ); - u32 indexCount = terrainNode->getIndicesForPatch( indices, x, z, LOD ); - - TrianglePatches.TrianglePatchArray[tIndex].Triangles.reallocate(indexCount/3); - for(u32 i = 0; i < indexCount; i += 3 ) - { - tri.pointA = vertices[indices[i+0]].Pos; - tri.pointB = vertices[indices[i+1]].Pos; - tri.pointC = vertices[indices[i+2]].Pos; - TrianglePatches.TrianglePatchArray[tIndex].Triangles.push_back(tri); - ++TrianglePatches.TrianglePatchArray[tIndex].NumTriangles; - } - - TrianglePatches.TotalTriangles += TrianglePatches.TrianglePatchArray[tIndex].NumTriangles; - } - } -} - -//! Gets all triangles. -void CTerrainTriangleSelector::getTriangles ( core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::matrix4* transform ) -{ - s32 count = TrianglePatches.TotalTriangles; - - if (count > arraySize) - count = arraySize; - - core::matrix4 mat; - - if (transform) - mat = (*transform); - - s32 tIndex = 0; - - for (s32 i=0; i& box, - const core::matrix4* transform) -{ - s32 count = TrianglePatches.TotalTriangles; - - if (count > arraySize) - count = arraySize; - - core::matrix4 mat; - - if (transform) - mat = (*transform); - - s32 tIndex = 0; - - for (s32 i=0; i& line, - const core::matrix4* transform) -{ - s32 count = TrianglePatches.TotalTriangles; - - if (count > arraySize) - count = arraySize; - - core::matrix4 mat; - - if (transform) - mat = (*transform); - - s32 tIndex = 0; - - for (s32 i=0; i indices; + CTerrainSceneNode* terrainNode = (CTerrainSceneNode*)node; + + // Get pointer to the GeoMipMaps vertices + video::S3DVertex2TCoords* vertices = (video::S3DVertex2TCoords*)terrainNode->RenderBuffer.getVertices(); + + // Clear current data + TrianglePatches.TotalTriangles = 0; + TrianglePatches.NumPatches = terrainNode->TerrainData.PatchCount * terrainNode->TerrainData.PatchCount; + + TrianglePatches.TrianglePatchArray.reallocate(TrianglePatches.NumPatches); + for (int o=0; oTerrainData.PatchCount; ++x ) + { + for(s32 z = 0; z < terrainNode->TerrainData.PatchCount; ++z ) + { + s32 tIndex = x * terrainNode->TerrainData.PatchCount + z; + TrianglePatches.TrianglePatchArray[tIndex].NumTriangles = 0; + TrianglePatches.TrianglePatchArray[tIndex].Box = terrainNode->getBoundingBox( x, z ); + u32 indexCount = terrainNode->getIndicesForPatch( indices, x, z, LOD ); + + TrianglePatches.TrianglePatchArray[tIndex].Triangles.reallocate(indexCount/3); + for(u32 i = 0; i < indexCount; i += 3 ) + { + tri.pointA = vertices[indices[i+0]].Pos; + tri.pointB = vertices[indices[i+1]].Pos; + tri.pointC = vertices[indices[i+2]].Pos; + TrianglePatches.TrianglePatchArray[tIndex].Triangles.push_back(tri); + ++TrianglePatches.TrianglePatchArray[tIndex].NumTriangles; + } + + TrianglePatches.TotalTriangles += TrianglePatches.TrianglePatchArray[tIndex].NumTriangles; + } + } +} + +//! Gets all triangles. +void CTerrainTriangleSelector::getTriangles ( core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::matrix4* transform ) +{ + s32 count = TrianglePatches.TotalTriangles; + + if (count > arraySize) + count = arraySize; + + core::matrix4 mat; + + if (transform) + mat = (*transform); + + s32 tIndex = 0; + + for (s32 i=0; i& box, + const core::matrix4* transform) +{ + s32 count = TrianglePatches.TotalTriangles; + + if (count > arraySize) + count = arraySize; + + core::matrix4 mat; + + if (transform) + mat = (*transform); + + s32 tIndex = 0; + + for (s32 i=0; i& line, + const core::matrix4* transform) +{ + s32 count = TrianglePatches.TotalTriangles; + + if (count > arraySize) + count = arraySize; + + core::matrix4 mat; + + if (transform) + mat = (*transform); + + s32 tIndex = 0; + + for (s32 i=0; i& box, const core::matrix4* transform = 0 ); - - //! Gets all triangles which have or may have contact with a 3d line. - virtual void getTriangles ( core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d& line, - const core::matrix4* transform = 0 ); - - //! Returns amount of all available triangles in this selector - virtual s32 getTriangleCount ( ) const; - -private: - - friend class CTerrainSceneNode; - - struct SGeoMipMapTrianglePatch - { - core::array Triangles; - s32 NumTriangles; - core::aabbox3df Box; - }; - - struct SGeoMipMapTrianglePatches - { - SGeoMipMapTrianglePatches ( ) - { - TotalTriangles = 0; - NumPatches = 0; - } - - core::array TrianglePatchArray; - s32 NumPatches; - u32 TotalTriangles; - }; - - ITerrainSceneNode* SceneNode; - SGeoMipMapTrianglePatches TrianglePatches; -}; - -} // end namespace scene -} // end namespace irr - - -#endif // __C_TERRAIN_TRIANGLE_SELECTOR_H__ - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// The code for the TerrainTriangleSelector is based on the GeoMipMapSelector +// developed by Spintz. He made it available for Irrlicht and allowed it to be +// distributed under this licence. I only modified some parts. A lot of thanks go to him. + +#ifndef __C_TERRAIN_TRIANGLE_SELECTOR_H__ +#define __C_TERRAIN_TRIANGLE_SELECTOR_H__ + +#include "ITriangleSelector.h" +#include "IMesh.h" +#include "irrArray.h" + +namespace irr +{ +namespace scene +{ + +class ITerrainSceneNode; + +//! Triangle Selector for the TerrainSceneNode +//! The code for the TerrainTriangleSelector is based on the GeoMipMapSelector +//! developed by Spintz. He made it available for Irrlicht and allowed it to be +//! distributed under this licence. I only modified some parts. A lot of thanks go to him. +class CTerrainTriangleSelector : public ITriangleSelector +{ +public: + + //! Constructs a selector based on an IGeoMipMapSceneNode + CTerrainTriangleSelector(ITerrainSceneNode* node, s32 LOD ); + + //! Destructor + ~CTerrainTriangleSelector(); + + //! Clears and sets triangle data + virtual void setTriangleData ( ITerrainSceneNode* node, s32 LOD ); + + //! Gets all triangles. + void getTriangles ( core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, + const core::matrix4* transform = 0 ); + + //! Gets all triangles which lie within a specific bounding box. + void getTriangles ( core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, + const core::aabbox3d& box, const core::matrix4* transform = 0 ); + + //! Gets all triangles which have or may have contact with a 3d line. + virtual void getTriangles ( core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::line3d& line, + const core::matrix4* transform = 0 ); + + //! Returns amount of all available triangles in this selector + virtual s32 getTriangleCount ( ) const; + +private: + + friend class CTerrainSceneNode; + + struct SGeoMipMapTrianglePatch + { + core::array Triangles; + s32 NumTriangles; + core::aabbox3df Box; + }; + + struct SGeoMipMapTrianglePatches + { + SGeoMipMapTrianglePatches ( ) + { + TotalTriangles = 0; + NumPatches = 0; + } + + core::array TrianglePatchArray; + s32 NumPatches; + u32 TotalTriangles; + }; + + ITerrainSceneNode* SceneNode; + SGeoMipMapTrianglePatches TrianglePatches; +}; + +} // end namespace scene +} // end namespace irr + + +#endif // __C_TERRAIN_TRIANGLE_SELECTOR_H__ + diff --git a/src/dep/src/irrlicht/CTextSceneNode.cpp b/src/dep/src/irrlicht/CTextSceneNode.cpp index d197817..ced9aba 100644 --- a/src/dep/src/irrlicht/CTextSceneNode.cpp +++ b/src/dep/src/irrlicht/CTextSceneNode.cpp @@ -1,416 +1,416 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CTextSceneNode.h" -#include "ISceneManager.h" -#include "IVideoDriver.h" -#include "ICameraSceneNode.h" -#include "SMeshBuffer.h" -#include "os.h" - - -namespace irr -{ -namespace scene -{ - - -//! constructor -CTextSceneNode::CTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - gui::IGUIFont* font, scene::ISceneCollisionManager* coll, - const core::vector3df& position, const wchar_t* text, - video::SColor color) - : ITextSceneNode(parent, mgr, id, position), Text(text), Color(color), - Font(font), Coll(coll) - -{ - #ifdef _DEBUG - setDebugName("CTextSceneNode"); - #endif - - if (Font) - Font->grab(); - - setAutomaticCulling(scene::EAC_OFF); -} - -//! destructor -CTextSceneNode::~CTextSceneNode() -{ - if (Font) - Font->drop(); -} - -void CTextSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - SceneManager->registerNodeForRendering(this, ESNRP_TRANSPARENT); - ISceneNode::OnRegisterSceneNode(); - } -} - -//! renders the node. -void CTextSceneNode::render() -{ - if (!Font || !Coll) - return; - - core::position2d pos = Coll->getScreenCoordinatesFrom3DPosition(getAbsolutePosition(), - SceneManager->getActiveCamera()); - - core::rect r(pos, core::dimension2d(1,1)); - Font->draw(Text.c_str(), r, Color, true, true); -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CTextSceneNode::getBoundingBox() const -{ - return Box; -} - -//! returns amount of materials used by this scene node. -u32 CTextSceneNode::getMaterialCount() -{ - return 0; -} - -//! sets the text string -void CTextSceneNode::setText(const wchar_t* text) -{ - Text = text; -} - - -//! sets the color of the text -void CTextSceneNode::setTextColor(video::SColor color) -{ - Color = color; -} - - -//!--------------------------------- CBillboardTextSceneNode ---------------------------------------------- - - -//! constructor -CBillboardTextSceneNode::CBillboardTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - gui::IGUIFont* font,const wchar_t* text, - const core::vector3df& position, const core::dimension2d& size, - video::SColor shade_top,video::SColor shade_bottom ) -: ITextSceneNode(parent, mgr, id, position), - Font(0), Shade_top(shade_top), Shade_bottom(shade_bottom), Mesh(0) -{ - #ifdef _DEBUG - setDebugName("CBillboardTextSceneNode"); - #endif - - Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; - Material.MaterialTypeParam = 0.5f; - Material.BackfaceCulling = false; - Material.Lighting = false; - Material.ZBuffer = false; - Material.ZWriteEnable = false; - - if (font) - { - // doesn't support other font types - if (font->getType() == gui::EGFT_BITMAP) - { - Font = (gui::IGUIFontBitmap*)font; - Font->grab(); - - // mesh with one buffer per texture - Mesh = new SMesh(); - for (u32 i=0; igetSpriteBank()->getTextureCount(); ++i) - { - SMeshBuffer *mb = new SMeshBuffer(); - mb->Material = Material; - mb->Material.Textures[0] = Font->getSpriteBank()->getTexture(i); - Mesh->addMeshBuffer(mb); - mb->drop(); - } - } - else - { - os::Printer::log("Sorry, CBillboardTextSceneNode does not support this font type", ELL_INFORMATION); - } - } - - setText(text); - setSize(size); - - setAutomaticCulling ( scene::EAC_BOX ); -} - - - -CBillboardTextSceneNode::~CBillboardTextSceneNode() -{ - if (Font) - Font->drop(); - - if (Mesh) - Mesh->drop(); - -} - - -//! sets the text string -void CBillboardTextSceneNode::setText(const wchar_t* text) -{ - Text = text; - - Symbol.clear(); - - if (!Font) - return; - - const core::array< core::rect > &sourceRects = Font->getSpriteBank()->getPositions(); - const core::array< gui::SGUISprite > &sprites = Font->getSpriteBank()->getSprites(); - - f32 dim[2]; - f32 tex[4]; - - u32 i; - for ( i = 0; i != Text.size (); ++i ) - { - SSymbolInfo info; - - u32 spriteno = Font->getSpriteNoFromChar( &text[i] ); - u32 rectno = sprites[spriteno].Frames[0].rectNumber; - u32 texno = sprites[spriteno].Frames[0].textureNumber; - - dim[0] = core::reciprocal ( (f32) Font->getSpriteBank()->getTexture(texno)->getSize().Width ); - dim[1] = core::reciprocal ( (f32) Font->getSpriteBank()->getTexture(texno)->getSize().Height ); - - const core::rect& s = sourceRects[rectno]; - - // add space for letter to buffer - SMeshBuffer* buf = (SMeshBuffer*)Mesh->getMeshBuffer(texno); - u32 firstInd = buf->Indices.size(); - u32 firstVert = buf->Vertices.size(); - buf->Indices.set_used(firstInd + 6); - buf->Vertices.set_used(firstVert + 4); - - tex[0] = (s.LowerRightCorner.X * dim[0]) + 0.5f*dim[0]; // half pixel - tex[1] = (s.LowerRightCorner.Y * dim[1]) + 0.5f*dim[1]; - tex[2] = (s.UpperLeftCorner.Y * dim[1]) - 0.5f*dim[1]; - tex[3] = (s.UpperLeftCorner.X * dim[0]) - 0.5f*dim[0]; - - buf->Vertices[firstVert+0].TCoords.set(tex[0], tex[1]); - buf->Vertices[firstVert+1].TCoords.set(tex[0], tex[2]); - buf->Vertices[firstVert+2].TCoords.set(tex[3], tex[2]); - buf->Vertices[firstVert+3].TCoords.set(tex[3], tex[1]); - - buf->Vertices[firstVert+0].Color = Shade_bottom; - buf->Vertices[firstVert+3].Color = Shade_bottom; - buf->Vertices[firstVert+1].Color = Shade_top; - buf->Vertices[firstVert+2].Color = Shade_top; - - buf->Indices[firstInd+0] = firstVert+0; - buf->Indices[firstInd+1] = firstVert+2; - buf->Indices[firstInd+2] = firstVert+1; - buf->Indices[firstInd+3] = firstVert+0; - buf->Indices[firstInd+4] = firstVert+3; - buf->Indices[firstInd+5] = firstVert+2; - - wchar_t *tp = 0; - if (i>0) - tp = &Text[i-1]; - - info.Width = (f32)s.getWidth(); - info.bufNo = texno; - info.Kerning = (f32)Font->getKerningWidth(&Text[i], tp); - info.firstInd = firstInd; - info.firstVert = firstVert; - - Symbol.push_back(info); - - } -} - - -//! pre render event -void CBillboardTextSceneNode::OnRegisterSceneNode() -{ - if (!IsVisible || !Font || !Mesh) - return; - - ICameraSceneNode* camera = SceneManager->getActiveCamera(); - if (!camera) - return; - - // get text width - f32 textLength = 0.f; - u32 i; - for(i=0; i!=Symbol.size(); ++i) - { - SSymbolInfo &info = Symbol[i]; - textLength += info.Kerning + info.Width; - } - if (textLength<0.0f) - textLength=1.0f; - -// const core::matrix4 &m = camera->getViewFrustum()->Matrices[ video::ETS_VIEW ]; - - // make billboard look to camera - core::vector3df pos = getAbsolutePosition(); - - core::vector3df campos = camera->getAbsolutePosition(); - core::vector3df target = camera->getTarget(); - core::vector3df up = camera->getUpVector(); - core::vector3df view = target - campos; - view.normalize(); - - core::vector3df horizontal = up.crossProduct(view); - if ( horizontal.getLength() == 0 ) - { - horizontal.set(up.Y,up.X,up.Z); - } - - horizontal.normalize(); - core::vector3df space = horizontal; - - horizontal *= 0.5f * Size.Width; - - core::vector3df vertical = horizontal.crossProduct(view); - vertical.normalize(); - vertical *= 0.5f * Size.Height; - - view *= -1.0f; - - // center text - pos += space * (Size.Width * -0.5f); - - for ( i = 0; i!= Symbol.size(); ++i ) - { - SSymbolInfo &info = Symbol[i]; - f32 infw = info.Width / textLength; - f32 infk = info.Kerning / textLength; - f32 w = (Size.Width * infw * 0.5f); - pos += space * w; - - SMeshBuffer* buf = (SMeshBuffer*)Mesh->getMeshBuffer(info.bufNo); - - buf->Vertices[info.firstVert+0].Normal = view; - buf->Vertices[info.firstVert+1].Normal = view; - buf->Vertices[info.firstVert+2].Normal = view; - buf->Vertices[info.firstVert+3].Normal = view; - - buf->Vertices[info.firstVert+0].Pos = pos + (space * w) + vertical; - buf->Vertices[info.firstVert+1].Pos = pos + (space * w) - vertical; - buf->Vertices[info.firstVert+2].Pos = pos - (space * w) - vertical; - buf->Vertices[info.firstVert+3].Pos = pos - (space * w) + vertical; - - pos += space * (Size.Width*infk + w); - } - - // make bounding box - - for (i=0; i< Mesh->getMeshBufferCount() ; ++i) - ((SMeshBuffer*)Mesh->getMeshBuffer(i))->recalculateBoundingBox(); - Mesh->recalculateBoundingBox(); - - BBox = Mesh->getBoundingBox(); - core::matrix4 mat = getAbsoluteTransformation(); - mat.makeInverse(); - mat.transformBox(BBox); - - SceneManager->registerNodeForRendering(this, ESNRP_TRANSPARENT); - ISceneNode::OnRegisterSceneNode(); -} - - -//! render -void CBillboardTextSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - // draw - core::matrix4 mat; - driver->setTransform(video::ETS_WORLD, mat); - - - - u32 i; - for ( i = 0; i < Mesh->getMeshBufferCount(); ++i ) - { - driver->setMaterial(Mesh->getMeshBuffer(i)->getMaterial()); - driver->drawMeshBuffer(Mesh->getMeshBuffer(i)); - } - - if (DebugDataVisible) - { - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - driver->draw3DBox(BBox, video::SColor(0,208,195,152)); - } - -} - -//! returns the axis aligned bounding box of this node -const core::aabbox3d& CBillboardTextSceneNode::getBoundingBox() const -{ - return BBox; -} - - -//! sets the size of the billboard -void CBillboardTextSceneNode::setSize(const core::dimension2d& size) -{ - Size = size; - - if (Size.Width == 0.0f) - Size.Width = 1.0f; - - if (Size.Height == 0.0f ) - Size.Height = 1.0f; - - //f32 avg = (size.Width + size.Height)/6; - //BBox.MinEdge.set(-avg,-avg,-avg); - //BBox.MaxEdge.set(avg,avg,avg); -} - - -video::SMaterial& CBillboardTextSceneNode::getMaterial(u32 i) -{ - if (Mesh && Mesh->getMeshBufferCount() > i ) - return Mesh->getMeshBuffer(i)->getMaterial(); - else - return Material; -} - - -//! returns amount of materials used by this scene node. -u32 CBillboardTextSceneNode::getMaterialCount() -{ - if (Mesh) - return Mesh->getMeshBufferCount(); - else - return 0; -} - - -//! gets the size of the billboard -const core::dimension2d& CBillboardTextSceneNode::getSize() -{ - return Size; -} - - - - -//! sets the color of the text -void CBillboardTextSceneNode::setTextColor(video::SColor color) -{ - Color = color; -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CTextSceneNode.h" +#include "ISceneManager.h" +#include "IVideoDriver.h" +#include "ICameraSceneNode.h" +#include "SMeshBuffer.h" +#include "os.h" + + +namespace irr +{ +namespace scene +{ + + +//! constructor +CTextSceneNode::CTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + gui::IGUIFont* font, scene::ISceneCollisionManager* coll, + const core::vector3df& position, const wchar_t* text, + video::SColor color) + : ITextSceneNode(parent, mgr, id, position), Text(text), Color(color), + Font(font), Coll(coll) + +{ + #ifdef _DEBUG + setDebugName("CTextSceneNode"); + #endif + + if (Font) + Font->grab(); + + setAutomaticCulling(scene::EAC_OFF); +} + +//! destructor +CTextSceneNode::~CTextSceneNode() +{ + if (Font) + Font->drop(); +} + +void CTextSceneNode::OnRegisterSceneNode() +{ + if (IsVisible) + { + SceneManager->registerNodeForRendering(this, ESNRP_TRANSPARENT); + ISceneNode::OnRegisterSceneNode(); + } +} + +//! renders the node. +void CTextSceneNode::render() +{ + if (!Font || !Coll) + return; + + core::position2d pos = Coll->getScreenCoordinatesFrom3DPosition(getAbsolutePosition(), + SceneManager->getActiveCamera()); + + core::rect r(pos, core::dimension2d(1,1)); + Font->draw(Text.c_str(), r, Color, true, true); +} + + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CTextSceneNode::getBoundingBox() const +{ + return Box; +} + +//! returns amount of materials used by this scene node. +u32 CTextSceneNode::getMaterialCount() +{ + return 0; +} + +//! sets the text string +void CTextSceneNode::setText(const wchar_t* text) +{ + Text = text; +} + + +//! sets the color of the text +void CTextSceneNode::setTextColor(video::SColor color) +{ + Color = color; +} + + +//!--------------------------------- CBillboardTextSceneNode ---------------------------------------------- + + +//! constructor +CBillboardTextSceneNode::CBillboardTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + gui::IGUIFont* font,const wchar_t* text, + const core::vector3df& position, const core::dimension2d& size, + video::SColor shade_top,video::SColor shade_bottom ) +: ITextSceneNode(parent, mgr, id, position), + Font(0), Shade_top(shade_top), Shade_bottom(shade_bottom), Mesh(0) +{ + #ifdef _DEBUG + setDebugName("CBillboardTextSceneNode"); + #endif + + Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + Material.MaterialTypeParam = 0.5f; + Material.BackfaceCulling = false; + Material.Lighting = false; + Material.ZBuffer = false; + Material.ZWriteEnable = false; + + if (font) + { + // doesn't support other font types + if (font->getType() == gui::EGFT_BITMAP) + { + Font = (gui::IGUIFontBitmap*)font; + Font->grab(); + + // mesh with one buffer per texture + Mesh = new SMesh(); + for (u32 i=0; igetSpriteBank()->getTextureCount(); ++i) + { + SMeshBuffer *mb = new SMeshBuffer(); + mb->Material = Material; + mb->Material.Textures[0] = Font->getSpriteBank()->getTexture(i); + Mesh->addMeshBuffer(mb); + mb->drop(); + } + } + else + { + os::Printer::log("Sorry, CBillboardTextSceneNode does not support this font type", ELL_INFORMATION); + } + } + + setText(text); + setSize(size); + + setAutomaticCulling ( scene::EAC_BOX ); +} + + + +CBillboardTextSceneNode::~CBillboardTextSceneNode() +{ + if (Font) + Font->drop(); + + if (Mesh) + Mesh->drop(); + +} + + +//! sets the text string +void CBillboardTextSceneNode::setText(const wchar_t* text) +{ + Text = text; + + Symbol.clear(); + + if (!Font) + return; + + const core::array< core::rect > &sourceRects = Font->getSpriteBank()->getPositions(); + const core::array< gui::SGUISprite > &sprites = Font->getSpriteBank()->getSprites(); + + f32 dim[2]; + f32 tex[4]; + + u32 i; + for ( i = 0; i != Text.size (); ++i ) + { + SSymbolInfo info; + + u32 spriteno = Font->getSpriteNoFromChar( &text[i] ); + u32 rectno = sprites[spriteno].Frames[0].rectNumber; + u32 texno = sprites[spriteno].Frames[0].textureNumber; + + dim[0] = core::reciprocal ( (f32) Font->getSpriteBank()->getTexture(texno)->getSize().Width ); + dim[1] = core::reciprocal ( (f32) Font->getSpriteBank()->getTexture(texno)->getSize().Height ); + + const core::rect& s = sourceRects[rectno]; + + // add space for letter to buffer + SMeshBuffer* buf = (SMeshBuffer*)Mesh->getMeshBuffer(texno); + u32 firstInd = buf->Indices.size(); + u32 firstVert = buf->Vertices.size(); + buf->Indices.set_used(firstInd + 6); + buf->Vertices.set_used(firstVert + 4); + + tex[0] = (s.LowerRightCorner.X * dim[0]) + 0.5f*dim[0]; // half pixel + tex[1] = (s.LowerRightCorner.Y * dim[1]) + 0.5f*dim[1]; + tex[2] = (s.UpperLeftCorner.Y * dim[1]) - 0.5f*dim[1]; + tex[3] = (s.UpperLeftCorner.X * dim[0]) - 0.5f*dim[0]; + + buf->Vertices[firstVert+0].TCoords.set(tex[0], tex[1]); + buf->Vertices[firstVert+1].TCoords.set(tex[0], tex[2]); + buf->Vertices[firstVert+2].TCoords.set(tex[3], tex[2]); + buf->Vertices[firstVert+3].TCoords.set(tex[3], tex[1]); + + buf->Vertices[firstVert+0].Color = Shade_bottom; + buf->Vertices[firstVert+3].Color = Shade_bottom; + buf->Vertices[firstVert+1].Color = Shade_top; + buf->Vertices[firstVert+2].Color = Shade_top; + + buf->Indices[firstInd+0] = firstVert+0; + buf->Indices[firstInd+1] = firstVert+2; + buf->Indices[firstInd+2] = firstVert+1; + buf->Indices[firstInd+3] = firstVert+0; + buf->Indices[firstInd+4] = firstVert+3; + buf->Indices[firstInd+5] = firstVert+2; + + wchar_t *tp = 0; + if (i>0) + tp = &Text[i-1]; + + info.Width = (f32)s.getWidth(); + info.bufNo = texno; + info.Kerning = (f32)Font->getKerningWidth(&Text[i], tp); + info.firstInd = firstInd; + info.firstVert = firstVert; + + Symbol.push_back(info); + + } +} + + +//! pre render event +void CBillboardTextSceneNode::OnRegisterSceneNode() +{ + if (!IsVisible || !Font || !Mesh) + return; + + ICameraSceneNode* camera = SceneManager->getActiveCamera(); + if (!camera) + return; + + // get text width + f32 textLength = 0.f; + u32 i; + for(i=0; i!=Symbol.size(); ++i) + { + SSymbolInfo &info = Symbol[i]; + textLength += info.Kerning + info.Width; + } + if (textLength<0.0f) + textLength=1.0f; + +// const core::matrix4 &m = camera->getViewFrustum()->Matrices[ video::ETS_VIEW ]; + + // make billboard look to camera + core::vector3df pos = getAbsolutePosition(); + + core::vector3df campos = camera->getAbsolutePosition(); + core::vector3df target = camera->getTarget(); + core::vector3df up = camera->getUpVector(); + core::vector3df view = target - campos; + view.normalize(); + + core::vector3df horizontal = up.crossProduct(view); + if ( horizontal.getLength() == 0 ) + { + horizontal.set(up.Y,up.X,up.Z); + } + + horizontal.normalize(); + core::vector3df space = horizontal; + + horizontal *= 0.5f * Size.Width; + + core::vector3df vertical = horizontal.crossProduct(view); + vertical.normalize(); + vertical *= 0.5f * Size.Height; + + view *= -1.0f; + + // center text + pos += space * (Size.Width * -0.5f); + + for ( i = 0; i!= Symbol.size(); ++i ) + { + SSymbolInfo &info = Symbol[i]; + f32 infw = info.Width / textLength; + f32 infk = info.Kerning / textLength; + f32 w = (Size.Width * infw * 0.5f); + pos += space * w; + + SMeshBuffer* buf = (SMeshBuffer*)Mesh->getMeshBuffer(info.bufNo); + + buf->Vertices[info.firstVert+0].Normal = view; + buf->Vertices[info.firstVert+1].Normal = view; + buf->Vertices[info.firstVert+2].Normal = view; + buf->Vertices[info.firstVert+3].Normal = view; + + buf->Vertices[info.firstVert+0].Pos = pos + (space * w) + vertical; + buf->Vertices[info.firstVert+1].Pos = pos + (space * w) - vertical; + buf->Vertices[info.firstVert+2].Pos = pos - (space * w) - vertical; + buf->Vertices[info.firstVert+3].Pos = pos - (space * w) + vertical; + + pos += space * (Size.Width*infk + w); + } + + // make bounding box + + for (i=0; i< Mesh->getMeshBufferCount() ; ++i) + ((SMeshBuffer*)Mesh->getMeshBuffer(i))->recalculateBoundingBox(); + Mesh->recalculateBoundingBox(); + + BBox = Mesh->getBoundingBox(); + core::matrix4 mat = getAbsoluteTransformation(); + mat.makeInverse(); + mat.transformBox(BBox); + + SceneManager->registerNodeForRendering(this, ESNRP_TRANSPARENT); + ISceneNode::OnRegisterSceneNode(); +} + + +//! render +void CBillboardTextSceneNode::render() +{ + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + + // draw + core::matrix4 mat; + driver->setTransform(video::ETS_WORLD, mat); + + + + u32 i; + for ( i = 0; i < Mesh->getMeshBufferCount(); ++i ) + { + driver->setMaterial(Mesh->getMeshBuffer(i)->getMaterial()); + driver->drawMeshBuffer(Mesh->getMeshBuffer(i)); + } + + if (DebugDataVisible) + { + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + video::SMaterial m; + m.Lighting = false; + driver->setMaterial(m); + driver->draw3DBox(BBox, video::SColor(0,208,195,152)); + } + +} + +//! returns the axis aligned bounding box of this node +const core::aabbox3d& CBillboardTextSceneNode::getBoundingBox() const +{ + return BBox; +} + + +//! sets the size of the billboard +void CBillboardTextSceneNode::setSize(const core::dimension2d& size) +{ + Size = size; + + if (Size.Width == 0.0f) + Size.Width = 1.0f; + + if (Size.Height == 0.0f ) + Size.Height = 1.0f; + + //f32 avg = (size.Width + size.Height)/6; + //BBox.MinEdge.set(-avg,-avg,-avg); + //BBox.MaxEdge.set(avg,avg,avg); +} + + +video::SMaterial& CBillboardTextSceneNode::getMaterial(u32 i) +{ + if (Mesh && Mesh->getMeshBufferCount() > i ) + return Mesh->getMeshBuffer(i)->getMaterial(); + else + return Material; +} + + +//! returns amount of materials used by this scene node. +u32 CBillboardTextSceneNode::getMaterialCount() +{ + if (Mesh) + return Mesh->getMeshBufferCount(); + else + return 0; +} + + +//! gets the size of the billboard +const core::dimension2d& CBillboardTextSceneNode::getSize() +{ + return Size; +} + + + + +//! sets the color of the text +void CBillboardTextSceneNode::setTextColor(video::SColor color) +{ + Color = color; +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CTextSceneNode.h b/src/dep/src/irrlicht/CTextSceneNode.h index d1d9173..68051cf 100644 --- a/src/dep/src/irrlicht/CTextSceneNode.h +++ b/src/dep/src/irrlicht/CTextSceneNode.h @@ -1,132 +1,132 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_TEXT_SCENE_NODE_H_INCLUDED__ -#define __C_TEXT_SCENE_NODE_H_INCLUDED__ - -#include "ITextSceneNode.h" -#include "IGUIFont.h" -#include "IGUIFontBitmap.h" -#include "ISceneCollisionManager.h" -#include "SMesh.h" - -namespace irr -{ -namespace scene -{ - - - class CTextSceneNode : public ITextSceneNode - { - public: - - //! constructor - CTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - gui::IGUIFont* font, scene::ISceneCollisionManager* coll, - const core::vector3df& position = core::vector3df(0,0,0), const wchar_t* text=0, - video::SColor color=video::SColor(100,0,0,0)); - - //! destructor - virtual ~CTextSceneNode(); - - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount(); - - //! sets the text string - virtual void setText(const wchar_t* text); - - //! sets the color of the text - virtual void setTextColor(video::SColor color); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_TEXT; } - - private: - - core::stringw Text; - video::SColor Color; - gui::IGUIFont* Font; - scene::ISceneCollisionManager* Coll; - core::aabbox3d Box; - }; - - class CBillboardTextSceneNode : public ITextSceneNode - { - public: - - CBillboardTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - gui::IGUIFont* font,const wchar_t* text, - const core::vector3df& position, const core::dimension2d& size, - video::SColor shade_top, video::SColor shade_bottom); - - //! destructor - virtual ~CBillboardTextSceneNode(); - - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d& getBoundingBox() const; - - //! sets the text string - virtual void setText(const wchar_t* text); - - //! sets the color of the text - virtual void setTextColor(video::SColor color); - - //! sets the size of the billboard - virtual void setSize(const core::dimension2d& size); - - //! gets the size of the billboard - virtual const core::dimension2d& getSize(); - - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount(); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_TEXT; } - - private: - - core::stringw Text; - video::SColor Color; - gui::IGUIFontBitmap* Font; - - core::dimension2d Size; - core::aabbox3d BBox; - video::SMaterial Material; - - video::SColor Shade_top; - video::SColor Shade_bottom; - struct SSymbolInfo - { - u32 bufNo; - f32 Width; - f32 Kerning; - u32 firstInd; - u32 firstVert; - }; - - core::array < SSymbolInfo > Symbol; - - SMesh *Mesh; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_TEXT_SCENE_NODE_H_INCLUDED__ +#define __C_TEXT_SCENE_NODE_H_INCLUDED__ + +#include "ITextSceneNode.h" +#include "IGUIFont.h" +#include "IGUIFontBitmap.h" +#include "ISceneCollisionManager.h" +#include "SMesh.h" + +namespace irr +{ +namespace scene +{ + + + class CTextSceneNode : public ITextSceneNode + { + public: + + //! constructor + CTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + gui::IGUIFont* font, scene::ISceneCollisionManager* coll, + const core::vector3df& position = core::vector3df(0,0,0), const wchar_t* text=0, + video::SColor color=video::SColor(100,0,0,0)); + + //! destructor + virtual ~CTextSceneNode(); + + virtual void OnRegisterSceneNode(); + + //! renders the node. + virtual void render(); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! returns amount of materials used by this scene node. + virtual u32 getMaterialCount(); + + //! sets the text string + virtual void setText(const wchar_t* text); + + //! sets the color of the text + virtual void setTextColor(video::SColor color); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_TEXT; } + + private: + + core::stringw Text; + video::SColor Color; + gui::IGUIFont* Font; + scene::ISceneCollisionManager* Coll; + core::aabbox3d Box; + }; + + class CBillboardTextSceneNode : public ITextSceneNode + { + public: + + CBillboardTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, + gui::IGUIFont* font,const wchar_t* text, + const core::vector3df& position, const core::dimension2d& size, + video::SColor shade_top, video::SColor shade_bottom); + + //! destructor + virtual ~CBillboardTextSceneNode(); + + virtual void OnRegisterSceneNode(); + + //! renders the node. + virtual void render(); + + //! returns the axis aligned bounding box of this node + virtual const core::aabbox3d& getBoundingBox() const; + + //! sets the text string + virtual void setText(const wchar_t* text); + + //! sets the color of the text + virtual void setTextColor(video::SColor color); + + //! sets the size of the billboard + virtual void setSize(const core::dimension2d& size); + + //! gets the size of the billboard + virtual const core::dimension2d& getSize(); + + virtual video::SMaterial& getMaterial(u32 i); + + //! returns amount of materials used by this scene node. + virtual u32 getMaterialCount(); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_TEXT; } + + private: + + core::stringw Text; + video::SColor Color; + gui::IGUIFontBitmap* Font; + + core::dimension2d Size; + core::aabbox3d BBox; + video::SMaterial Material; + + video::SColor Shade_top; + video::SColor Shade_bottom; + struct SSymbolInfo + { + u32 bufNo; + f32 Width; + f32 Kerning; + u32 firstInd; + u32 firstVert; + }; + + core::array < SSymbolInfo > Symbol; + + SMesh *Mesh; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CTimer.h b/src/dep/src/irrlicht/CTimer.h index f7d1953..04a5d09 100644 --- a/src/dep/src/irrlicht/CTimer.h +++ b/src/dep/src/irrlicht/CTimer.h @@ -1,101 +1,101 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IRR_C_TIMER_H_INCLUDED__ -#define __C_IRR_C_TIMER_H_INCLUDED__ - -#include "ITimer.h" -#include "os.h" - -namespace irr -{ - //! Device independent implementation of the timer - class CTimer : public ITimer - { - public: - - CTimer() - { - os::Timer::initTimer(); - } - - //! Returns current real time in milliseconds of the system. - /** This value does not start with 0 when the application starts. - For example in one implementation the value returned could be the - amount of milliseconds which have elapsed since the system was started. */ - virtual u32 getRealTime() - { - return os::Timer::getRealTime(); - } - - //! Returns current virtual time in milliseconds. - /** This value starts with 0 and can be manipulated using setTime(), stopTimer(), - startTimer(), etc. This value depends on the set speed of the timer if the timer - is stopped, etc. If you need the system time, use getRealTime() */ - virtual u32 getTime() - { - return os::Timer::getTime(); - } - - //! sets current virtual time - virtual void setTime(u32 time) - { - os::Timer::setTime(time); - } - - //! Stops the game timer. - /** The timer is reference counted, which means everything which calls - stopTimer() will also have to call startTimer(), otherwise the timer may not start/stop - corretly again. */ - virtual void stop() - { - os::Timer::stopTimer(); - } - - //! Starts the game timer. - /** The timer is reference counted, which means everything which calls - stopTimer() will also have to call startTimer(), otherwise the timer may not start/stop - corretly again. */ - virtual void start() - { - os::Timer::startTimer(); - } - - //! Sets the speed of the timer - /** The speed is the factor with which the time is running faster or slower then the - real system time. */ - virtual void setSpeed(f32 speed = 1.0f) - { - os::Timer::setSpeed(speed); - } - - //! Returns current speed of the timer - /** The speed is the factor with which the time is running faster or slower then the - real system time. */ - virtual f32 getSpeed() - { - return os::Timer::getSpeed(); - } - - //! Returns if game timer is currently stopped - virtual bool isStopped() - { - bool ret = os::Timer::isStopped(); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; - } - - //! Advances the virtual time - /** Makes the virtual timer update the time value based on the real time. This is - called automaticly when calling IrrlichtDevice::run(), but you can call it manually - if you don't use this method. */ - virtual void tick() - { - os::Timer::tick(); - } - }; - -} // end namespace - -#endif +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_IRR_C_TIMER_H_INCLUDED__ +#define __C_IRR_C_TIMER_H_INCLUDED__ + +#include "ITimer.h" +#include "os.h" + +namespace irr +{ + //! Device independent implementation of the timer + class CTimer : public ITimer + { + public: + + CTimer() + { + os::Timer::initTimer(); + } + + //! Returns current real time in milliseconds of the system. + /** This value does not start with 0 when the application starts. + For example in one implementation the value returned could be the + amount of milliseconds which have elapsed since the system was started. */ + virtual u32 getRealTime() + { + return os::Timer::getRealTime(); + } + + //! Returns current virtual time in milliseconds. + /** This value starts with 0 and can be manipulated using setTime(), stopTimer(), + startTimer(), etc. This value depends on the set speed of the timer if the timer + is stopped, etc. If you need the system time, use getRealTime() */ + virtual u32 getTime() + { + return os::Timer::getTime(); + } + + //! sets current virtual time + virtual void setTime(u32 time) + { + os::Timer::setTime(time); + } + + //! Stops the game timer. + /** The timer is reference counted, which means everything which calls + stopTimer() will also have to call startTimer(), otherwise the timer may not start/stop + corretly again. */ + virtual void stop() + { + os::Timer::stopTimer(); + } + + //! Starts the game timer. + /** The timer is reference counted, which means everything which calls + stopTimer() will also have to call startTimer(), otherwise the timer may not start/stop + corretly again. */ + virtual void start() + { + os::Timer::startTimer(); + } + + //! Sets the speed of the timer + /** The speed is the factor with which the time is running faster or slower then the + real system time. */ + virtual void setSpeed(f32 speed = 1.0f) + { + os::Timer::setSpeed(speed); + } + + //! Returns current speed of the timer + /** The speed is the factor with which the time is running faster or slower then the + real system time. */ + virtual f32 getSpeed() + { + return os::Timer::getSpeed(); + } + + //! Returns if game timer is currently stopped + virtual bool isStopped() + { + bool ret = os::Timer::isStopped(); + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return ret; + } + + //! Advances the virtual time + /** Makes the virtual timer update the time value based on the real time. This is + called automaticly when calling IrrlichtDevice::run(), but you can call it manually + if you don't use this method. */ + virtual void tick() + { + os::Timer::tick(); + } + }; + +} // end namespace + +#endif diff --git a/src/dep/src/irrlicht/CTriangleBBSelector.cpp b/src/dep/src/irrlicht/CTriangleBBSelector.cpp index 207fdbd..942323c 100644 --- a/src/dep/src/irrlicht/CTriangleBBSelector.cpp +++ b/src/dep/src/irrlicht/CTriangleBBSelector.cpp @@ -1,64 +1,64 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CTriangleBBSelector.h" -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CTriangleBBSelector::CTriangleBBSelector(ISceneNode* node) -: CTriangleSelector(node) -{ - #ifdef _DEBUG - setDebugName("CTriangleBBSelector"); - #endif - - Triangles.set_used(12); // a box has 12 triangles. -} - - - -//! Gets all triangles. -void CTriangleBBSelector::getTriangles(core::triangle3df* triangles, - s32 arraySize, s32& outTriangleCount, - const core::matrix4* transform) -{ - if (!SceneNode) - return; - - // construct triangles - core::aabbox3d box = SceneNode->getBoundingBox(); - core::vector3df edges[8]; - box.getEdges(edges); - - Triangles[0].set( edges[3], edges[0], edges[2]); - Triangles[1].set( edges[3], edges[1], edges[0]); - - Triangles[2].set( edges[3], edges[2], edges[7]); - Triangles[3].set( edges[7], edges[2], edges[6]); - - Triangles[4].set( edges[7], edges[6], edges[4]); - Triangles[5].set( edges[5], edges[7], edges[4]); - - Triangles[6].set( edges[5], edges[4], edges[0]); - Triangles[7].set( edges[5], edges[0], edges[1]); - - Triangles[8].set( edges[1], edges[3], edges[7]); - Triangles[9].set( edges[1], edges[7], edges[5]); - - Triangles[10].set(edges[0], edges[6], edges[2]); - Triangles[11].set(edges[0], edges[4], edges[6]); - - // call parent - CTriangleSelector::getTriangles(triangles, arraySize, outTriangleCount, transform); -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CTriangleBBSelector.h" +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CTriangleBBSelector::CTriangleBBSelector(ISceneNode* node) +: CTriangleSelector(node) +{ + #ifdef _DEBUG + setDebugName("CTriangleBBSelector"); + #endif + + Triangles.set_used(12); // a box has 12 triangles. +} + + + +//! Gets all triangles. +void CTriangleBBSelector::getTriangles(core::triangle3df* triangles, + s32 arraySize, s32& outTriangleCount, + const core::matrix4* transform) +{ + if (!SceneNode) + return; + + // construct triangles + core::aabbox3d box = SceneNode->getBoundingBox(); + core::vector3df edges[8]; + box.getEdges(edges); + + Triangles[0].set( edges[3], edges[0], edges[2]); + Triangles[1].set( edges[3], edges[1], edges[0]); + + Triangles[2].set( edges[3], edges[2], edges[7]); + Triangles[3].set( edges[7], edges[2], edges[6]); + + Triangles[4].set( edges[7], edges[6], edges[4]); + Triangles[5].set( edges[5], edges[7], edges[4]); + + Triangles[6].set( edges[5], edges[4], edges[0]); + Triangles[7].set( edges[5], edges[0], edges[1]); + + Triangles[8].set( edges[1], edges[3], edges[7]); + Triangles[9].set( edges[1], edges[7], edges[5]); + + Triangles[10].set(edges[0], edges[6], edges[2]); + Triangles[11].set(edges[0], edges[4], edges[6]); + + // call parent + CTriangleSelector::getTriangles(triangles, arraySize, outTriangleCount, transform); +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CTriangleBBSelector.h b/src/dep/src/irrlicht/CTriangleBBSelector.h index 925a5e6..b714159 100644 --- a/src/dep/src/irrlicht/CTriangleBBSelector.h +++ b/src/dep/src/irrlicht/CTriangleBBSelector.h @@ -1,35 +1,35 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_TRIANGLE_BB_SELECTOR_H_INCLUDED__ -#define __C_TRIANGLE_BB_SELECTOR_H_INCLUDED__ - -#include "CTriangleSelector.h" - -namespace irr -{ -namespace scene -{ - -//! Stupid triangle selector without optimization -class CTriangleBBSelector : public CTriangleSelector -{ -public: - - //! Constructs a selector based on a mesh - CTriangleBBSelector(ISceneNode* node); - - virtual ~CTriangleBBSelector() {}; - - //! Gets all triangles. - void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, - const core::matrix4* transform=0); -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_TRIANGLE_BB_SELECTOR_H_INCLUDED__ +#define __C_TRIANGLE_BB_SELECTOR_H_INCLUDED__ + +#include "CTriangleSelector.h" + +namespace irr +{ +namespace scene +{ + +//! Stupid triangle selector without optimization +class CTriangleBBSelector : public CTriangleSelector +{ +public: + + //! Constructs a selector based on a mesh + CTriangleBBSelector(ISceneNode* node); + + virtual ~CTriangleBBSelector() {}; + + //! Gets all triangles. + void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, + const core::matrix4* transform=0); +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CTriangleSelector.cpp b/src/dep/src/irrlicht/CTriangleSelector.cpp index 21274b9..bbe74a4 100644 --- a/src/dep/src/irrlicht/CTriangleSelector.cpp +++ b/src/dep/src/irrlicht/CTriangleSelector.cpp @@ -1,164 +1,164 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CTriangleSelector.h" -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CTriangleSelector::CTriangleSelector(ISceneNode* node) -: SceneNode(node) -{ - #ifdef _DEBUG - setDebugName("CTriangleSelector"); - #endif -} - - -//! constructor -CTriangleSelector::CTriangleSelector(IMesh* mesh, ISceneNode* node) -: SceneNode(node) -{ - #ifdef _DEBUG - setDebugName("CTriangleSelector"); - #endif - - u32 cnt = mesh->getMeshBufferCount(); - for (u32 i=0; igetMeshBuffer(i); - - s32 idxCnt = buf->getIndexCount(); - const u16* indices = buf->getIndices(); - core::triangle3df tri; - - switch (buf->getVertexType()) - { - case video::EVT_STANDARD: - { - video::S3DVertex* vtx = (video::S3DVertex*)buf->getVertices(); - for (s32 j=0; jgetVertices(); - for (s32 j=0; jgetVertices(); - for (s32 j=0; j box, ISceneNode* node) -: SceneNode(node) -{ - #ifdef _DEBUG - setDebugName("CTriangleSelector"); - #endif - - // TODO -} - - - -//! destructor -CTriangleSelector::~CTriangleSelector() -{ -} - - - -//! Gets all triangles. -void CTriangleSelector::getTriangles(core::triangle3df* triangles, - s32 arraySize, s32& outTriangleCount, - const core::matrix4* transform) -{ - s32 cnt = Triangles.size(); - if (cnt > arraySize) - cnt = arraySize; - - core::matrix4 mat; - - if (transform) - mat = (*transform); - - if (SceneNode) - mat *= SceneNode->getAbsoluteTransformation(); - - for (s32 i=0; i& box, - const core::matrix4* transform) -{ - // return all triangles - getTriangles(triangles, arraySize, outTriangleCount, transform); -} - - -//! Gets all triangles which have or may have contact with a 3d line. -void CTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d& line, - const core::matrix4* transform) -{ - // return all triangles - getTriangles(triangles, arraySize, outTriangleCount, transform); -} - - -//! Returns amount of all available triangles in this selector -s32 CTriangleSelector::getTriangleCount() const -{ - return Triangles.size(); -} - - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CTriangleSelector.h" +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CTriangleSelector::CTriangleSelector(ISceneNode* node) +: SceneNode(node) +{ + #ifdef _DEBUG + setDebugName("CTriangleSelector"); + #endif +} + + +//! constructor +CTriangleSelector::CTriangleSelector(IMesh* mesh, ISceneNode* node) +: SceneNode(node) +{ + #ifdef _DEBUG + setDebugName("CTriangleSelector"); + #endif + + u32 cnt = mesh->getMeshBufferCount(); + for (u32 i=0; igetMeshBuffer(i); + + s32 idxCnt = buf->getIndexCount(); + const u16* indices = buf->getIndices(); + core::triangle3df tri; + + switch (buf->getVertexType()) + { + case video::EVT_STANDARD: + { + video::S3DVertex* vtx = (video::S3DVertex*)buf->getVertices(); + for (s32 j=0; jgetVertices(); + for (s32 j=0; jgetVertices(); + for (s32 j=0; j box, ISceneNode* node) +: SceneNode(node) +{ + #ifdef _DEBUG + setDebugName("CTriangleSelector"); + #endif + + // TODO +} + + + +//! destructor +CTriangleSelector::~CTriangleSelector() +{ +} + + + +//! Gets all triangles. +void CTriangleSelector::getTriangles(core::triangle3df* triangles, + s32 arraySize, s32& outTriangleCount, + const core::matrix4* transform) +{ + s32 cnt = Triangles.size(); + if (cnt > arraySize) + cnt = arraySize; + + core::matrix4 mat; + + if (transform) + mat = (*transform); + + if (SceneNode) + mat *= SceneNode->getAbsoluteTransformation(); + + for (s32 i=0; i& box, + const core::matrix4* transform) +{ + // return all triangles + getTriangles(triangles, arraySize, outTriangleCount, transform); +} + + +//! Gets all triangles which have or may have contact with a 3d line. +void CTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::line3d& line, + const core::matrix4* transform) +{ + // return all triangles + getTriangles(triangles, arraySize, outTriangleCount, transform); +} + + +//! Returns amount of all available triangles in this selector +s32 CTriangleSelector::getTriangleCount() const +{ + return Triangles.size(); +} + + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CTriangleSelector.h b/src/dep/src/irrlicht/CTriangleSelector.h index a093759..05c8595 100644 --- a/src/dep/src/irrlicht/CTriangleSelector.h +++ b/src/dep/src/irrlicht/CTriangleSelector.h @@ -1,62 +1,62 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_TRIANGLE_SELECTOR_H_INCLUDED__ -#define __C_TRIANGLE_SELECTOR_H_INCLUDED__ - -#include "ITriangleSelector.h" -#include "IMesh.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - -class ISceneNode; - -//! Stupid triangle selector without optimization -class CTriangleSelector : public ITriangleSelector -{ -public: - - //! Constructs a selector based on a mesh - CTriangleSelector(ISceneNode* node); - - //! Constructs a selector based on a mesh - CTriangleSelector(IMesh* mesh, ISceneNode* node); - - //! Constructs a selector based on a bounding box - CTriangleSelector(core::aabbox3d box, ISceneNode* node); - - ~CTriangleSelector(); - - //! Gets all triangles. - void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, - const core::matrix4* transform=0); - - //! Gets all triangles which lie within a specific bounding box. - void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, - const core::aabbox3d& box, const core::matrix4* transform=0); - - //! Gets all triangles which have or may have contact with a 3d line. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d& line, - const core::matrix4* transform=0); - - //! Returns amount of all available triangles in this selector - virtual s32 getTriangleCount() const; - -protected: - - ISceneNode* SceneNode; - core::array Triangles; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_TRIANGLE_SELECTOR_H_INCLUDED__ +#define __C_TRIANGLE_SELECTOR_H_INCLUDED__ + +#include "ITriangleSelector.h" +#include "IMesh.h" +#include "irrArray.h" + +namespace irr +{ +namespace scene +{ + +class ISceneNode; + +//! Stupid triangle selector without optimization +class CTriangleSelector : public ITriangleSelector +{ +public: + + //! Constructs a selector based on a mesh + CTriangleSelector(ISceneNode* node); + + //! Constructs a selector based on a mesh + CTriangleSelector(IMesh* mesh, ISceneNode* node); + + //! Constructs a selector based on a bounding box + CTriangleSelector(core::aabbox3d box, ISceneNode* node); + + ~CTriangleSelector(); + + //! Gets all triangles. + void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, + const core::matrix4* transform=0); + + //! Gets all triangles which lie within a specific bounding box. + void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, + const core::aabbox3d& box, const core::matrix4* transform=0); + + //! Gets all triangles which have or may have contact with a 3d line. + virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, + s32& outTriangleCount, const core::line3d& line, + const core::matrix4* transform=0); + + //! Returns amount of all available triangles in this selector + virtual s32 getTriangleCount() const; + +protected: + + ISceneNode* SceneNode; + core::array Triangles; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CVideoModeList.cpp b/src/dep/src/irrlicht/CVideoModeList.cpp index 5067a5a..e7e9c95 100644 --- a/src/dep/src/irrlicht/CVideoModeList.cpp +++ b/src/dep/src/irrlicht/CVideoModeList.cpp @@ -1,98 +1,98 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CVideoModeList.h" - -namespace irr -{ -namespace video -{ - -//! constructor -CVideoModeList::CVideoModeList() -{ - Desktop.depth = 0; - Desktop.size = core::dimension2d(0,0); -} - - -//! destructor -CVideoModeList::~CVideoModeList() -{ -} - - - -void CVideoModeList::setDesktop(s32 desktopDepth, const core::dimension2d& desktopSize) -{ - Desktop.depth = desktopDepth; - Desktop.size = desktopSize; -} - - -//! Gets amount of video modes in the list. -s32 CVideoModeList::getVideoModeCount() const -{ - return (s32)VideoModes.size(); -} - - - -//! Returns the screen size of a video mode in pixels. -core::dimension2d CVideoModeList::getVideoModeResolution(s32 modeNumber) const -{ - if (modeNumber < 0 || modeNumber > (s32)VideoModes.size()) - return core::dimension2d(0,0); - - return VideoModes[modeNumber].size; -} - - - -//! Returns the pixel depth of a video mode in bits. -s32 CVideoModeList::getVideoModeDepth(s32 modeNumber) const -{ - if (modeNumber < 0 || modeNumber > (s32)VideoModes.size()) - return 0; - - return VideoModes[modeNumber].depth; -} - - -//! Returns current desktop screen resolution. -core::dimension2d CVideoModeList::getDesktopResolution() const -{ - return Desktop.size; -} - - -//! Returns the pixel depth of a video mode in bits. -s32 CVideoModeList::getDesktopDepth() const -{ - return Desktop.depth; -} - - - -//! adds a new mode to the list -void CVideoModeList::addMode(const core::dimension2d& size, s32 depth) -{ - SVideoMode m; - m.depth = depth; - m.size = size; - - for (u32 i=0; i(0,0); +} + + +//! destructor +CVideoModeList::~CVideoModeList() +{ +} + + + +void CVideoModeList::setDesktop(s32 desktopDepth, const core::dimension2d& desktopSize) +{ + Desktop.depth = desktopDepth; + Desktop.size = desktopSize; +} + + +//! Gets amount of video modes in the list. +s32 CVideoModeList::getVideoModeCount() const +{ + return (s32)VideoModes.size(); +} + + + +//! Returns the screen size of a video mode in pixels. +core::dimension2d CVideoModeList::getVideoModeResolution(s32 modeNumber) const +{ + if (modeNumber < 0 || modeNumber > (s32)VideoModes.size()) + return core::dimension2d(0,0); + + return VideoModes[modeNumber].size; +} + + + +//! Returns the pixel depth of a video mode in bits. +s32 CVideoModeList::getVideoModeDepth(s32 modeNumber) const +{ + if (modeNumber < 0 || modeNumber > (s32)VideoModes.size()) + return 0; + + return VideoModes[modeNumber].depth; +} + + +//! Returns current desktop screen resolution. +core::dimension2d CVideoModeList::getDesktopResolution() const +{ + return Desktop.size; +} + + +//! Returns the pixel depth of a video mode in bits. +s32 CVideoModeList::getDesktopDepth() const +{ + return Desktop.depth; +} + + + +//! adds a new mode to the list +void CVideoModeList::addMode(const core::dimension2d& size, s32 depth) +{ + SVideoMode m; + m.depth = depth; + m.size = size; + + for (u32 i=0; i getVideoModeResolution(s32 modeNumber) const; - - //! Returns the pixel depth of a video mode in bits. - virtual s32 getVideoModeDepth(s32 modeNumber) const; - - //! Returns current desktop screen resolution. - virtual core::dimension2d getDesktopResolution() const; - - //! Returns the pixel depth of a video mode in bits. - virtual s32 getDesktopDepth() const; - - //! adds a new mode to the list - void addMode(const core::dimension2d& size, s32 depth); - - void setDesktop(s32 desktopDepth, const core::dimension2d& desktopSize); - - private: - - struct SVideoMode - { - core::dimension2d size; - s32 depth; - - bool operator==(const SVideoMode& other) const - { - return size == other.size && depth == other.depth; - } - - bool operator <(const SVideoMode& other) const - { - return (size.Width < other.size.Width || - (size.Width == other.size.Width && - size.Height < other.size.Height) || - (size.Width == other.size.Width && - size.Height == other.size.Height && - depth < other.depth)); - } - }; - - core::array VideoModes; - SVideoMode Desktop; - }; - -} // end namespace video -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_C_VIDEO_MODE_LIST_H_INCLUDED__ +#define __IRR_C_VIDEO_MODE_LIST_H_INCLUDED__ + +#include "IVideoModeList.h" +#include "dimension2d.h" +#include "irrArray.h" + +namespace irr +{ +namespace video +{ + + class CVideoModeList : public IVideoModeList + { + public: + + //! constructor + CVideoModeList(); + + //! destructor + virtual ~CVideoModeList(); + + //! Gets amount of video modes in the list. + virtual s32 getVideoModeCount() const; + + //! Returns the screen size of a video mode in pixels. + virtual core::dimension2d getVideoModeResolution(s32 modeNumber) const; + + //! Returns the pixel depth of a video mode in bits. + virtual s32 getVideoModeDepth(s32 modeNumber) const; + + //! Returns current desktop screen resolution. + virtual core::dimension2d getDesktopResolution() const; + + //! Returns the pixel depth of a video mode in bits. + virtual s32 getDesktopDepth() const; + + //! adds a new mode to the list + void addMode(const core::dimension2d& size, s32 depth); + + void setDesktop(s32 desktopDepth, const core::dimension2d& desktopSize); + + private: + + struct SVideoMode + { + core::dimension2d size; + s32 depth; + + bool operator==(const SVideoMode& other) const + { + return size == other.size && depth == other.depth; + } + + bool operator <(const SVideoMode& other) const + { + return (size.Width < other.size.Width || + (size.Width == other.size.Width && + size.Height < other.size.Height) || + (size.Width == other.size.Width && + size.Height == other.size.Height && + depth < other.depth)); + } + }; + + core::array VideoModes; + SVideoMode Desktop; + }; + +} // end namespace video +} // end namespace irr + + +#endif + diff --git a/src/dep/src/irrlicht/CWaterSurfaceSceneNode.cpp b/src/dep/src/irrlicht/CWaterSurfaceSceneNode.cpp index d6f064b..a6d7662 100644 --- a/src/dep/src/irrlicht/CWaterSurfaceSceneNode.cpp +++ b/src/dep/src/irrlicht/CWaterSurfaceSceneNode.cpp @@ -1,186 +1,186 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CWaterSurfaceSceneNode.h" -#include "ISceneManager.h" -#include "IMeshManipulator.h" -#include "S3DVertex.h" -#include "SMesh.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CWaterSurfaceSceneNode::CWaterSurfaceSceneNode(f32 waveHeight, f32 waveSpeed, f32 waveLength, - IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::vector3df& rotation, - const core::vector3df& scale) -: CMeshSceneNode(mesh, parent, mgr, id, position, rotation, scale), WaveLength(waveLength), - WaveSpeed(waveSpeed), WaveHeight(waveHeight), OriginalMesh(0) -{ - #ifdef _DEBUG - setDebugName("CWaterSurfaceSceneNode"); - #endif - - // create copy of the mesh - if (!mesh) - return; - - IMesh* clone = SceneManager->getMeshManipulator()->createMeshCopy(mesh); - OriginalMesh = Mesh; - Mesh = clone; -} - - - -//! destructor -CWaterSurfaceSceneNode::~CWaterSurfaceSceneNode() -{ - if (OriginalMesh) - OriginalMesh->drop(); -} - - - -//! frame -void CWaterSurfaceSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - SceneManager->registerNodeForRendering(this); - - animateWaterSurface(); - - CMeshSceneNode::OnRegisterSceneNode(); - } -} - - - -void CWaterSurfaceSceneNode::animateWaterSurface() -{ - if (!Mesh) - return; - - u32 meshBufferCount = Mesh->getMeshBufferCount(); - f32 time = os::Timer::getTime() / WaveSpeed; - - for (u32 b=0; bgetMeshBuffer(b)->getVertexCount(); - - switch(Mesh->getMeshBuffer(b)->getVertexType()) - { - case video::EVT_STANDARD: - { - video::S3DVertex* v = - (video::S3DVertex*)Mesh->getMeshBuffer(b)->getVertices(); - - video::S3DVertex* v2 = - (video::S3DVertex*)OriginalMesh->getMeshBuffer(b)->getVertices(); - - for (u32 i=0; igetMeshBuffer(b)->getVertices(); - - video::S3DVertex2TCoords* v2 = - (video::S3DVertex2TCoords*)OriginalMesh->getMeshBuffer(b)->getVertices(); - - for (u32 i=0; igetMeshBuffer(b)->getVertices(); - - video::S3DVertexTangents* v2 = - (video::S3DVertexTangents*)OriginalMesh->getMeshBuffer(b)->getVertices(); - - for (u32 i=0; igetMeshManipulator()->recalculateNormals(Mesh); -} - - - -//! Writes attributes of the scene node. -void CWaterSurfaceSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - - out->addFloat("WaveLength", WaveLength); - out->addFloat("WaveSpeed", WaveSpeed); - out->addFloat("WaveHeight", WaveHeight); - - // serialize original mesh - scene::IMesh *swap = 0; - - if (Mesh) - { - swap = Mesh; - Mesh = OriginalMesh; - } - CMeshSceneNode::serializeAttributes(out, options); - if (swap) - { - Mesh = swap; - OriginalMesh = Mesh; - } -} - - -//! Reads attributes of the scene node. -void CWaterSurfaceSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - WaveLength = in->getAttributeAsFloat("WaveLength"); - WaveSpeed = in->getAttributeAsFloat("WaveSpeed"); - WaveHeight = in->getAttributeAsFloat("WaveHeight"); - - if (Mesh) - { - Mesh->drop(); - Mesh = OriginalMesh; - OriginalMesh = 0; - } - // deserialize original mesh - CMeshSceneNode::deserializeAttributes(in, options); - - if (Mesh) - { - IMesh* clone = SceneManager->getMeshManipulator()->createMeshCopy(Mesh); - OriginalMesh = Mesh; - Mesh = clone; - } -} - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CWaterSurfaceSceneNode.h" +#include "ISceneManager.h" +#include "IMeshManipulator.h" +#include "S3DVertex.h" +#include "SMesh.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CWaterSurfaceSceneNode::CWaterSurfaceSceneNode(f32 waveHeight, f32 waveSpeed, f32 waveLength, + IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position, const core::vector3df& rotation, + const core::vector3df& scale) +: CMeshSceneNode(mesh, parent, mgr, id, position, rotation, scale), WaveLength(waveLength), + WaveSpeed(waveSpeed), WaveHeight(waveHeight), OriginalMesh(0) +{ + #ifdef _DEBUG + setDebugName("CWaterSurfaceSceneNode"); + #endif + + // create copy of the mesh + if (!mesh) + return; + + IMesh* clone = SceneManager->getMeshManipulator()->createMeshCopy(mesh); + OriginalMesh = Mesh; + Mesh = clone; +} + + + +//! destructor +CWaterSurfaceSceneNode::~CWaterSurfaceSceneNode() +{ + if (OriginalMesh) + OriginalMesh->drop(); +} + + + +//! frame +void CWaterSurfaceSceneNode::OnRegisterSceneNode() +{ + if (IsVisible) + { + SceneManager->registerNodeForRendering(this); + + animateWaterSurface(); + + CMeshSceneNode::OnRegisterSceneNode(); + } +} + + + +void CWaterSurfaceSceneNode::animateWaterSurface() +{ + if (!Mesh) + return; + + u32 meshBufferCount = Mesh->getMeshBufferCount(); + f32 time = os::Timer::getTime() / WaveSpeed; + + for (u32 b=0; bgetMeshBuffer(b)->getVertexCount(); + + switch(Mesh->getMeshBuffer(b)->getVertexType()) + { + case video::EVT_STANDARD: + { + video::S3DVertex* v = + (video::S3DVertex*)Mesh->getMeshBuffer(b)->getVertices(); + + video::S3DVertex* v2 = + (video::S3DVertex*)OriginalMesh->getMeshBuffer(b)->getVertices(); + + for (u32 i=0; igetMeshBuffer(b)->getVertices(); + + video::S3DVertex2TCoords* v2 = + (video::S3DVertex2TCoords*)OriginalMesh->getMeshBuffer(b)->getVertices(); + + for (u32 i=0; igetMeshBuffer(b)->getVertices(); + + video::S3DVertexTangents* v2 = + (video::S3DVertexTangents*)OriginalMesh->getMeshBuffer(b)->getVertices(); + + for (u32 i=0; igetMeshManipulator()->recalculateNormals(Mesh); +} + + + +//! Writes attributes of the scene node. +void CWaterSurfaceSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + + out->addFloat("WaveLength", WaveLength); + out->addFloat("WaveSpeed", WaveSpeed); + out->addFloat("WaveHeight", WaveHeight); + + // serialize original mesh + scene::IMesh *swap = 0; + + if (Mesh) + { + swap = Mesh; + Mesh = OriginalMesh; + } + CMeshSceneNode::serializeAttributes(out, options); + if (swap) + { + Mesh = swap; + OriginalMesh = Mesh; + } +} + + +//! Reads attributes of the scene node. +void CWaterSurfaceSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + WaveLength = in->getAttributeAsFloat("WaveLength"); + WaveSpeed = in->getAttributeAsFloat("WaveSpeed"); + WaveHeight = in->getAttributeAsFloat("WaveHeight"); + + if (Mesh) + { + Mesh->drop(); + Mesh = OriginalMesh; + OriginalMesh = 0; + } + // deserialize original mesh + CMeshSceneNode::deserializeAttributes(in, options); + + if (Mesh) + { + IMesh* clone = SceneManager->getMeshManipulator()->createMeshCopy(Mesh); + OriginalMesh = Mesh; + Mesh = clone; + } +} + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CWaterSurfaceSceneNode.h b/src/dep/src/irrlicht/CWaterSurfaceSceneNode.h index 03d7d9c..f51ac98 100644 --- a/src/dep/src/irrlicht/CWaterSurfaceSceneNode.h +++ b/src/dep/src/irrlicht/CWaterSurfaceSceneNode.h @@ -1,51 +1,51 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_WATER_SURFACE_SCENE_NODE_H_INCLUDED__ -#define __C_WATER_SURFACE_SCENE_NODE_H_INCLUDED__ - -#include "CMeshSceneNode.h" - -namespace irr -{ -namespace scene -{ - - class CWaterSurfaceSceneNode : public CMeshSceneNode - { - public: - - //! constructor - CWaterSurfaceSceneNode(f32 waveHeight, f32 waveSpeed, f32 waveLength, - IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! destructor - virtual ~CWaterSurfaceSceneNode(); - - //! frame - virtual void OnRegisterSceneNode(); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() { return ESNT_WATER_SURFACE; } - - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - void animateWaterSurface(); - f32 WaveLength; - f32 WaveSpeed; - f32 WaveHeight; - IMesh* OriginalMesh; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_WATER_SURFACE_SCENE_NODE_H_INCLUDED__ +#define __C_WATER_SURFACE_SCENE_NODE_H_INCLUDED__ + +#include "CMeshSceneNode.h" + +namespace irr +{ +namespace scene +{ + + class CWaterSurfaceSceneNode : public CMeshSceneNode + { + public: + + //! constructor + CWaterSurfaceSceneNode(f32 waveHeight, f32 waveSpeed, f32 waveLength, + IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); + + //! destructor + virtual ~CWaterSurfaceSceneNode(); + + //! frame + virtual void OnRegisterSceneNode(); + + //! Returns type of the scene node + virtual ESCENE_NODE_TYPE getType() { return ESNT_WATER_SURFACE; } + + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + private: + + void animateWaterSurface(); + f32 WaveLength; + f32 WaveSpeed; + f32 WaveHeight; + IMesh* OriginalMesh; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CWriteFile.cpp b/src/dep/src/irrlicht/CWriteFile.cpp index e2e0174..05f72d6 100644 --- a/src/dep/src/irrlicht/CWriteFile.cpp +++ b/src/dep/src/irrlicht/CWriteFile.cpp @@ -1,119 +1,119 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CWriteFile.h" -#include - -namespace irr -{ -namespace io -{ - - -CWriteFile::CWriteFile(const c8* fileName, bool append) -: FileSize(0) -{ - #ifdef _DEBUG - setDebugName("CWriteFile"); - #endif - - Filename = fileName; - openFile(append); -} - - - -CWriteFile::~CWriteFile() -{ - if (File) - fclose(File); -} - - - -//! returns if file is open -inline bool CWriteFile::isOpen() const -{ - return File != 0; -} - - - -//! returns how much was read -s32 CWriteFile::write(const void* buffer, s32 sizeToWrite) -{ - if (!isOpen()) - return 0; - - return fwrite(buffer, 1, sizeToWrite, File); -} - - - -//! changes position in file, returns true if successful -//! if relativeMovement==true, the pos is changed relative to current pos, -//! otherwise from begin of file -bool CWriteFile::seek(s32 finalPos, bool relativeMovement) -{ - if (!isOpen()) - return false; - - return fseek(File, finalPos, relativeMovement ? SEEK_CUR : SEEK_SET) == 0; -} - - - -//! returns where in the file we are. -s32 CWriteFile::getPos() -{ - return ftell(File); -} - - - -//! opens the file -void CWriteFile::openFile(bool append) -{ - if (Filename.size() == 0) - { - File = 0; - return; - } - - File = fopen(Filename.c_str(), append ? "ab" : "wb"); - - if (File) - { - // get FileSize - - fseek(File, 0, SEEK_END); - FileSize = ftell(File); - fseek(File, 0, SEEK_SET); - } -} - - - -//! returns name of file -const c8* CWriteFile::getFileName() -{ - return Filename.c_str(); -} - - - -IWriteFile* createWriteFile(const c8* fileName, bool append) -{ - CWriteFile* file = new CWriteFile(fileName, append); - if (file->isOpen()) - return file; - - file->drop(); - return 0; -} - - -} // end namespace io -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CWriteFile.h" +#include + +namespace irr +{ +namespace io +{ + + +CWriteFile::CWriteFile(const c8* fileName, bool append) +: FileSize(0) +{ + #ifdef _DEBUG + setDebugName("CWriteFile"); + #endif + + Filename = fileName; + openFile(append); +} + + + +CWriteFile::~CWriteFile() +{ + if (File) + fclose(File); +} + + + +//! returns if file is open +inline bool CWriteFile::isOpen() const +{ + return File != 0; +} + + + +//! returns how much was read +s32 CWriteFile::write(const void* buffer, s32 sizeToWrite) +{ + if (!isOpen()) + return 0; + + return fwrite(buffer, 1, sizeToWrite, File); +} + + + +//! changes position in file, returns true if successful +//! if relativeMovement==true, the pos is changed relative to current pos, +//! otherwise from begin of file +bool CWriteFile::seek(s32 finalPos, bool relativeMovement) +{ + if (!isOpen()) + return false; + + return fseek(File, finalPos, relativeMovement ? SEEK_CUR : SEEK_SET) == 0; +} + + + +//! returns where in the file we are. +s32 CWriteFile::getPos() +{ + return ftell(File); +} + + + +//! opens the file +void CWriteFile::openFile(bool append) +{ + if (Filename.size() == 0) + { + File = 0; + return; + } + + File = fopen(Filename.c_str(), append ? "ab" : "wb"); + + if (File) + { + // get FileSize + + fseek(File, 0, SEEK_END); + FileSize = ftell(File); + fseek(File, 0, SEEK_SET); + } +} + + + +//! returns name of file +const c8* CWriteFile::getFileName() +{ + return Filename.c_str(); +} + + + +IWriteFile* createWriteFile(const c8* fileName, bool append) +{ + CWriteFile* file = new CWriteFile(fileName, append); + if (file->isOpen()) + return file; + + file->drop(); + return 0; +} + + +} // end namespace io +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CWriteFile.h b/src/dep/src/irrlicht/CWriteFile.h index 113b7f2..dfa3b3e 100644 --- a/src/dep/src/irrlicht/CWriteFile.h +++ b/src/dep/src/irrlicht/CWriteFile.h @@ -1,59 +1,59 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_WRITE_FILE_H_INCLUDED__ -#define __C_WRITE_FILE_H_INCLUDED__ - -#include -#include "IWriteFile.h" -#include "irrString.h" - -namespace irr -{ - -namespace io -{ - - /*! - Class for writing a real file to disk. - */ - class CWriteFile : public IWriteFile - { - public: - - CWriteFile(const wchar_t* fileName, bool append); - CWriteFile(const c8* fileName, bool append); - - virtual ~CWriteFile(); - - //! Reads an amount of bytes from the file. - virtual s32 write(const void* buffer, s32 sizeToWrite); - - //! Changes position in file, returns true if successful. - virtual bool seek(s32 finalPos, bool relativeMovement = false); - - //! Returns the current position in the file. - virtual s32 getPos(); - - //! Returns name of file. - virtual const c8* getFileName(); - - //! returns if file is open - bool isOpen() const; - - private: - - //! opens the file - void openFile(bool append); - - core::stringc Filename; - FILE* File; - s32 FileSize; - }; - -} // end namespace io -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_WRITE_FILE_H_INCLUDED__ +#define __C_WRITE_FILE_H_INCLUDED__ + +#include +#include "IWriteFile.h" +#include "irrString.h" + +namespace irr +{ + +namespace io +{ + + /*! + Class for writing a real file to disk. + */ + class CWriteFile : public IWriteFile + { + public: + + CWriteFile(const wchar_t* fileName, bool append); + CWriteFile(const c8* fileName, bool append); + + virtual ~CWriteFile(); + + //! Reads an amount of bytes from the file. + virtual s32 write(const void* buffer, s32 sizeToWrite); + + //! Changes position in file, returns true if successful. + virtual bool seek(s32 finalPos, bool relativeMovement = false); + + //! Returns the current position in the file. + virtual s32 getPos(); + + //! Returns name of file. + virtual const c8* getFileName(); + + //! returns if file is open + bool isOpen() const; + + private: + + //! opens the file + void openFile(bool append); + + core::stringc Filename; + FILE* File; + s32 FileSize; + }; + +} // end namespace io +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CXAnimationPlayer.cpp b/src/dep/src/irrlicht/CXAnimationPlayer.cpp index aa1aa65..f31896c 100644 --- a/src/dep/src/irrlicht/CXAnimationPlayer.cpp +++ b/src/dep/src/irrlicht/CXAnimationPlayer.cpp @@ -1,855 +1,855 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CXAnimationPlayer.h" -#include "ISceneNode.h" -#include "IVideoDriver.h" -#include "os.h" -#include "SMeshBuffer.h" -#include "IMeshManipulator.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CXAnimationPlayer::CXAnimationPlayer(CXFileReader* reader, - video::IVideoDriver* driver, - IMeshManipulator* manip, - const c8* filename) -: Reader(reader), Driver(driver), AnimatedMesh(0), - FileName(filename), Manipulator(manip), IsAnimatedSkinnedMesh(false), - CurrentAnimationTime(0.0f), LastAnimationTime(1.0f), - CurrentAnimationSet(0), DebugSkeletonCrossSize(1.0f) -{ - - if (!Reader) - return; - - if (Driver) - Driver->grab(); - - if (Manipulator) - Manipulator->grab(); - - Reader->grab(); - - createAnimationData(); -} - - - -//! destructor -CXAnimationPlayer::~CXAnimationPlayer() -{ - if (Reader) - Reader->drop(); - - if (Driver) - Driver->drop(); - - if (AnimatedMesh) - AnimatedMesh->drop(); - - if (Manipulator) - Manipulator->drop(); -} - - - -//! Gets the frame count of the animated mesh. -s32 CXAnimationPlayer::getFrameCount() -{ - return IsAnimatedSkinnedMesh ? (s32)LastAnimationTime : 1; -} - - - -//! Returns the IMesh interface for a frame. -IMesh* CXAnimationPlayer::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) -{ - if (!IsAnimatedSkinnedMesh) - return &OriginalMesh; - - CurrentAnimationTime = (f32)frame; - animateSkeleton(); - modifySkin(); - updateBoundingBoxFromAnimation(); - return AnimatedMesh; -} - - - -//! Returns an axis aligned bounding box of the mesh. -const core::aabbox3d& CXAnimationPlayer::getBoundingBox() const -{ - return Box; -} - - - -//! Returns the type of the animated mesh. -E_ANIMATED_MESH_TYPE CXAnimationPlayer::getMeshType() const -{ - return EAMT_X; -} - - - -void CXAnimationPlayer::createAnimationData() -{ - int i, iCnt; - // get joints from x-file - core::array& pgRootFrames = Reader->getRootFrames(); - iCnt = pgRootFrames.size(); - for( i = 0; i < iCnt; i++ ) - { - createJointData(pgRootFrames[i], -1); - - createMeshData(); - - if (IsAnimatedSkinnedMesh && AnimatedMesh) - { - animateSkeleton(); - modifySkin(); - updateBoundingBoxFromAnimation(); - DebugSkeletonCrossSize = AnimatedMesh->getBoundingBox().getExtent().X / 20.0f; - } - else - DebugSkeletonCrossSize = OriginalMesh.getBoundingBox().getExtent().X / 20.0f; - } -} - - -void CXAnimationPlayer::createMeshData() -{ - int i, iCnt; - core::array& pgRootFrames = Reader->getRootFrames(); - iCnt = pgRootFrames.size(); - for( i = 0; i < iCnt; i++ ) - { - // create mesh - addFrameToMesh(pgRootFrames[i]); - - // recalculate box - OriginalMesh.recalculateBoundingBox(); - - // store box (fix by jox, thnx) - Box = OriginalMesh.getBoundingBox(); - - // sort weights in joints - for (s32 j=0; j<(s32)Joints.size(); ++j) - Joints[j].Weights.sort(); - - // copy mesh - AnimatedMesh = Manipulator->createMeshCopy(&OriginalMesh); - - // create and link animation data - prepareAnimationData(); - - // first animation - animateSkeleton(); - modifySkin(); - } -} - - -void CXAnimationPlayer::addFrameToMesh(CXFileReader::SXFrame& frame) -{ - // go through all meshes - for (u32 m=0; mdrop(); - - // new weights buffer - Weights.push_back( core::array() ); - - // create material - buf->Material = getMaterialFromXMaterial( - frame.Meshes[m].MaterialList.Materials[mt]); - - // add all faces of this material - addFacesToBuffer(OriginalMesh.MeshBuffers.size()-1, - frame.Meshes[m], mt, frame); - buf->recalculateBoundingBox(); - } - } - - // add child frames - for (u32 c=0; cgetTexture(getTextureFileName(xmat.TextureFileName).c_str()); - if (mat.Textures[0] == 0) - mat.Textures[0] = Driver->getTexture(xmat.TextureFileName.c_str()); - } - - return mat; -} - - - -void CXAnimationPlayer::addFacesToBuffer(s32 meshbuffernr, CXFileReader::SXMesh& mesh, s32 matnr, const CXFileReader::SXFrame& frame) -{ - scene::SMeshBuffer* buf = (SMeshBuffer*)OriginalMesh.MeshBuffers[meshbuffernr]; - - u32 tcnt = mesh.TextureCoords.size(); - u32 ncnt = mesh.Normals.size(); - u32 ccnt = mesh.VertexColors.size(); - - // precompute which joint belongs to which weight array - core::array< s32 > jointNumberWeightNumberMap; - for (u32 w=0; wMaterial.DiffuseColor; - - s32 nidx = buf->Vertices.linear_reverse_search(v); - bool alreadyIn = (nidx != -1); - - if (!alreadyIn) - { - nidx = buf->Vertices.size(); - buf->Indices.push_back(nidx); - buf->Vertices.push_back(v); - Weights[meshbuffernr].push_back(SVertexWeight()); - } - else - buf->Indices.push_back(nidx); - - bool isWeighted = alreadyIn; - - // add weight data of this vertex to all joints - if (!alreadyIn) - for (s32 w=0; w<(s32)mesh.SkinWeights.size(); ++w) - { - s32 vertexinweights = mesh.SkinWeights[w].Weights.binary_search(CXFileReader::SXWeight(idx)); - - if (vertexinweights != -1) - { - s32 jnr = jointNumberWeightNumberMap[w]; - - if (jnr != -1) - { - // weight per joint - Joints[jnr].Weights.push_back(SWeightData( - meshbuffernr, - nidx, - mesh.SkinWeights[w].Weights[vertexinweights].Weight)); - - // weight per vertex - SVertexWeight& weight = Weights[meshbuffernr].pointer()[nidx]; - weight.add(mesh.SkinWeights[w].Weights[vertexinweights].Weight, jnr); - - isWeighted = true; - } - } - } // end for all weights - - // if this vertex does not have a weight, create a virtual new - // joint and attach it to this one - if (!isWeighted) - addVirtualWeight(meshbuffernr, nidx, mesh, frame); - - } // end for all faces - - } // end for all materials - } - - // generate missing normals - if (!ncnt) - { - // Using Mesh manipulator - Manipulator->recalculateNormals ( buf, true ); - } - - /*// transform vertices and normals - core::matrix4 mat = frame.LocalMatrix; - - s32 vcnt = buf->Vertices.size(); - for (s32 u=0; uVertices[u].Pos); - mat.rotateVect(buf->Vertices[u].Normal); - }*/ -} - - -void CXAnimationPlayer::addVirtualWeight(s32 meshbuffernr, s32 vtxidx, CXFileReader::SXMesh& mesh, - const CXFileReader::SXFrame& frame) -{ - // find original joint of vertex - s32 jnr = getJointNumberFromName(frame.Name); - if (jnr == -1) - return; - - // weight per joint - Joints[jnr].Weights.push_back(SWeightData( - meshbuffernr, - vtxidx, - 1.0f)); - - // weight per vertex - SVertexWeight& weight = Weights[meshbuffernr].pointer()[vtxidx]; - weight.add(1.0f, jnr); -} - - - -s32 CXAnimationPlayer::getJointNumberFromName(const core::stringc& name) const -{ - for (s32 i=0; i<(s32)Joints.size(); ++i) - if (Joints[i].Name == name) - return i; - - return -1; -} - - - -core::stringc CXAnimationPlayer::getTextureFileName(const core::stringc& texture) -{ - s32 idx = -1; - idx = FileName.findLast('/'); - - if (idx == -1) - idx = FileName.findLast('\\'); - - if (idx == -1) - return core::stringc(); - - core::stringc p = FileName.subString(0, idx+1); - p.append(texture); - return p; -} - - - -void CXAnimationPlayer::createJointData(const CXFileReader::SXFrame& f, s32 JointParent) -{ - // add joint - s32 index = Joints.size(); - Joints.push_back(SJoint()); - SJoint& j = Joints.getLast(); - - j.Parent = JointParent; - j.GlobalMatrix = f.GlobalMatrix; - j.LocalMatrix = f.LocalMatrix; - j.AnimatedMatrix = j.GlobalMatrix; - j.LocalAnimatedMatrix = j.LocalMatrix; - j.CombinedAnimationMatrix = j.AnimatedMatrix * j.MatrixOffset; - j.IsVirtualJoint = false; - - j.Name = f.Name; - - // add all children - for (s32 i=0; i<(s32)f.ChildFrames.size(); ++i) - createJointData(f.ChildFrames[i], index); -} - - -//! Returns a pointer to a transformation matrix -core::matrix4* CXAnimationPlayer::getMatrixOfJoint(s32 jointNumber, s32 frame) -{ - if (jointNumber < 0 || jointNumber >= (s32)Joints.size()) - return 0; - - return &Joints[jointNumber].AnimatedMatrix; -} - - -//! Gets joint count. -s32 CXAnimationPlayer::getJointCount() const -{ - return Joints.size(); -} - - -//! Gets the name of a joint. -const c8* CXAnimationPlayer::getJointName(s32 number) const -{ - if (number<0 || number>=(s32)Joints.size()) - return 0; - - return Joints[number].Name.c_str(); -} - - -//! Gets a joint number from its name -s32 CXAnimationPlayer::getJointNumber(const c8* name) const -{ - for (s32 i=0; i<(s32)Joints.size(); ++i) - if (Joints[i].Name == name) - return i; - - return -1; -} - - -//! Returns a pointer to list of points containing the skeleton. -const core::array* CXAnimationPlayer::getDrawableSkeleton(s32 frame) -{ - DebugSkeleton.clear(); - - f32 k = DebugSkeletonCrossSize; - f32 p = 0.0f; - - for (s32 i=0; i<(s32)Joints.size(); ++i) - { - core::vector3df start(p,p,p); - core::vector3df end(p,p,p); - - Joints[i].AnimatedMatrix.transformVect(start); - - DebugSkeleton.push_back(start); - DebugSkeleton.push_back(start + core::vector3df(0,k,0)); - DebugSkeleton.push_back(start); - DebugSkeleton.push_back(start + core::vector3df(0,-k,0)); - DebugSkeleton.push_back(start); - DebugSkeleton.push_back(start + core::vector3df(k,0,0)); - DebugSkeleton.push_back(start); - DebugSkeleton.push_back(start + core::vector3df(-k,0,0)); - DebugSkeleton.push_back(start); - DebugSkeleton.push_back(start + core::vector3df(0,0,k)); - DebugSkeleton.push_back(start); - DebugSkeleton.push_back(start + core::vector3df(0,0,-k)); - - if (Joints[i].Parent != -1) - { - Joints[Joints[i].Parent].AnimatedMatrix.transformVect(end); - - DebugSkeleton.push_back(end); - DebugSkeleton.push_back(start); - } - } - - return &DebugSkeleton; -} - - -//! animates the skeleton based on the animation data -void CXAnimationPlayer::animateSkeleton() -{ - if (!AnimationSets.empty()) - { - // reset joints - for (u32 jii=0; jii= CurrentAnimationTime) - { - idx1 = t; - idx2 = (t+1) % currentSet.Animations[i].Times.size(); - break; - } - } - - if (idx1 == -1) - continue; - - // calculate interpolation factor - f32 factor = (CurrentAnimationTime - currentSet.Animations[i].Times[idx1]) / - (currentSet.Animations[i].Times[idx2] - currentSet.Animations[i].Times[idx1]); - - // animate it - switch(currentSet.Animations[i].keyType) - { - case 0: // rotation - { - // with this code, rotations are not 100% ok, they are - // mirrored. - core::quaternion q; - q.slerp(currentSet.Animations[i].Quaternions[idx1], - currentSet.Animations[i].Quaternions[idx2], - factor); - - joint.LocalAnimatedMatrix *= q.getMatrix(); - joint.WasAnimatedThisFrame = true; - } - break; - case 1: // scale - { - core::matrix4 mat1, mat2; - mat1.setScale(currentSet.Animations[i].Vectors[idx1]); - mat2.setScale(currentSet.Animations[i].Vectors[idx2]); - - joint.LocalAnimatedMatrix *= mat1.interpolate(mat2, factor); - joint.WasAnimatedThisFrame = true; - } - break; - case 2: // position - { - core::matrix4 mat1, mat2; - mat1.setTranslation(currentSet.Animations[i].Vectors[idx1]); - mat2.setTranslation(currentSet.Animations[i].Vectors[idx2]); - - joint.LocalAnimatedMatrix *= mat1.interpolate(mat2, factor); - joint.WasAnimatedThisFrame = true; - } - break; - case 4: - case 3: // matrix - { - joint.LocalAnimatedMatrix = - currentSet.Animations[i].Matrices[idx1].interpolate( - currentSet.Animations[i].Matrices[idx2], factor); - - joint.WasAnimatedThisFrame = true; - } - break; - } - - } - } - - // update all joints - for (s32 ji=0; ji<(s32)Joints.size(); ++ji) - { - if (!Joints[ji].WasAnimatedThisFrame) - Joints[ji].LocalAnimatedMatrix = Joints[ji].LocalMatrix; - - Joints[ji].AnimatedMatrix = Joints[ji].LocalAnimatedMatrix; - - if (Joints[ji].Parent != -1) - Joints[ji].AnimatedMatrix = Joints[Joints[ji].Parent].AnimatedMatrix * Joints[ji].AnimatedMatrix; - - Joints[ji].CombinedAnimationMatrix = Joints[ji].AnimatedMatrix * - Joints[ji].MatrixOffset; - } -} - - -//! modifies the skin based on the animated skeleton -void CXAnimationPlayer::modifySkin() -{ - // set animated vertices to zero - for (s32 k=0; k<(s32)Joints.size(); ++k) - { - for (s32 w=0; w<(s32)Joints[k].Weights.size(); ++w) - { - SWeightData& wd = Joints[k].Weights[w]; - -#ifdef _XREADER_DEBUG - if (wd.buffer >= AnimatedMesh->getMeshBufferCount() || - wd.vertex >= AnimatedMesh->getMeshBuffer(wd.buffer)->getVertexCount()) - os::Printer::log("CXAnimationPlayer: Invalid Weights"); -#endif - - video::S3DVertex* nv = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(wd.buffer)->getVertices(); - nv[wd.vertex].Pos.set(0,0,0); - } - } - - -#ifdef _XREADER_DEBUG - bool somethingIsWrong = false; - - // check if all vertices are set to zero - for (u32 mb=0; mbgetMeshBufferCount(); ++mb) - { - video::S3DVertex* v = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(mb)->getVertices(); - s32 c = AnimatedMesh->getMeshBuffer(mb)->getVertexCount(); - for (s32 vt=0; vtgetMeshBufferCount()); - os::Printer::log(tmp); - - for (u32 mb=0; mbgetMeshBufferCount(); ++mb) - { - sprintf(tmp, "CXAnimationPlayer: Meshbuffer #%d: %d vertices", mb, AnimatedMesh->getMeshBuffer(mb)->getVertexCount()); - os::Printer::log(tmp); - } - } -#endif - - // transform vertices - for (u32 mb=0; mbgetMeshBufferCount(); ++mb) - { - video::S3DVertex* av = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(mb)->getVertices(); - video::S3DVertex* ov = (video::S3DVertex*)OriginalMesh.getMeshBuffer(mb)->getVertices(); - const u32 c = AnimatedMesh->getMeshBuffer(mb)->getVertexCount(); - for (u32 vt=0; vtgetAnimationSetCount(); - for (s32 i=0; igetAnimationSet(i); - mySet.AnimationName = readerSet.AnimationName; - - // through all animations - for (s32 a=0; a<(s32)readerSet.Animations.size(); ++a) - { - // through all keys - for (s32 k=0; k<(s32)readerSet.Animations[a].Keys.size(); ++k) - { - // link with joint - s32 jntnr = getJointNumberFromName(readerSet.Animations[a].FrameName); - - if (jntnr == -1) - { - os::Printer::log( - "CXAnimationPlayer: Animationtrack without corresponding joint found", - readerSet.Animations[a].FrameName.c_str()); - continue; - } - - // copy track - s32 keyCount = (s32)readerSet.Animations[a].Keys[k].numberOfKeys; - if (!keyCount) - { - os::Printer::log( - "CXAnimationPlayer: Skipping Animationtrack with zero key frames", - readerSet.Animations[a].FrameName.c_str()); - continue; - } - - // add new track - mySet.Animations.push_back(SXAnimationTrack()); - SXAnimationTrack& myTrack = mySet.Animations.getLast(); - myTrack.jointNr = jntnr; - IsAnimatedSkinnedMesh = true; - - s32 type = readerSet.Animations[a].Keys[k].keyType; - s32 l; - myTrack.keyType = type; - - #ifdef _XREADER_DEBUG - char tmp[255]; - sprintf(tmp, "adding track %s with %d keys, type:%d", readerSet.Animations[a].FrameName.c_str(), keyCount, type); - os::Printer::log(tmp); - #endif - - switch(type) - { - case 0: // quaternion - for (l=0; l LastAnimationTime) - LastAnimationTime = myTrack.Times.getLast(); - } - } - } - - // sort animation tracks - mySet.Animations.sort(); - } -} - -void CXAnimationPlayer::updateBoundingBoxFromAnimation() -{ - if (!Joints.size()) - return; - - bool first = true; - - for (u32 i=0; iBoundingBox = Box; -} - -//! Returns amount of animations in .X-file. -s32 CXAnimationPlayer::getAnimationCount() const -{ - return AnimationSets.size(); -} - -//! Returns the name of an animation. -const c8* CXAnimationPlayer::getAnimationName(s32 idx) const -{ - if (idx < 0 || idx >= (s32)AnimationSets.size()) - return 0; - - return AnimationSets[idx].AnimationName.c_str(); -} - - -//! Sets an animation as animation to play back. -void CXAnimationPlayer::setCurrentAnimation(s32 idx) -{ - if (idx < 0 || idx >= (s32)AnimationSets.size()) - return; - - CurrentAnimationSet = idx; -} - - -//! Sets an animation as animation to play back. -bool CXAnimationPlayer::setCurrentAnimation(const c8* name) -{ - for (s32 i=0; i<(s32)AnimationSets.size(); ++i) - if (AnimationSets[i].AnimationName == name) - { - CurrentAnimationSet = i; - return true; - } - - return false; -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CXAnimationPlayer.h" +#include "ISceneNode.h" +#include "IVideoDriver.h" +#include "os.h" +#include "SMeshBuffer.h" +#include "IMeshManipulator.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CXAnimationPlayer::CXAnimationPlayer(CXFileReader* reader, + video::IVideoDriver* driver, + IMeshManipulator* manip, + const c8* filename) +: Reader(reader), Driver(driver), AnimatedMesh(0), + FileName(filename), Manipulator(manip), IsAnimatedSkinnedMesh(false), + CurrentAnimationTime(0.0f), LastAnimationTime(1.0f), + CurrentAnimationSet(0), DebugSkeletonCrossSize(1.0f) +{ + + if (!Reader) + return; + + if (Driver) + Driver->grab(); + + if (Manipulator) + Manipulator->grab(); + + Reader->grab(); + + createAnimationData(); +} + + + +//! destructor +CXAnimationPlayer::~CXAnimationPlayer() +{ + if (Reader) + Reader->drop(); + + if (Driver) + Driver->drop(); + + if (AnimatedMesh) + AnimatedMesh->drop(); + + if (Manipulator) + Manipulator->drop(); +} + + + +//! Gets the frame count of the animated mesh. +s32 CXAnimationPlayer::getFrameCount() +{ + return IsAnimatedSkinnedMesh ? (s32)LastAnimationTime : 1; +} + + + +//! Returns the IMesh interface for a frame. +IMesh* CXAnimationPlayer::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) +{ + if (!IsAnimatedSkinnedMesh) + return &OriginalMesh; + + CurrentAnimationTime = (f32)frame; + animateSkeleton(); + modifySkin(); + updateBoundingBoxFromAnimation(); + return AnimatedMesh; +} + + + +//! Returns an axis aligned bounding box of the mesh. +const core::aabbox3d& CXAnimationPlayer::getBoundingBox() const +{ + return Box; +} + + + +//! Returns the type of the animated mesh. +E_ANIMATED_MESH_TYPE CXAnimationPlayer::getMeshType() const +{ + return EAMT_X; +} + + + +void CXAnimationPlayer::createAnimationData() +{ + int i, iCnt; + // get joints from x-file + core::array& pgRootFrames = Reader->getRootFrames(); + iCnt = pgRootFrames.size(); + for( i = 0; i < iCnt; i++ ) + { + createJointData(pgRootFrames[i], -1); + + createMeshData(); + + if (IsAnimatedSkinnedMesh && AnimatedMesh) + { + animateSkeleton(); + modifySkin(); + updateBoundingBoxFromAnimation(); + DebugSkeletonCrossSize = AnimatedMesh->getBoundingBox().getExtent().X / 20.0f; + } + else + DebugSkeletonCrossSize = OriginalMesh.getBoundingBox().getExtent().X / 20.0f; + } +} + + +void CXAnimationPlayer::createMeshData() +{ + int i, iCnt; + core::array& pgRootFrames = Reader->getRootFrames(); + iCnt = pgRootFrames.size(); + for( i = 0; i < iCnt; i++ ) + { + // create mesh + addFrameToMesh(pgRootFrames[i]); + + // recalculate box + OriginalMesh.recalculateBoundingBox(); + + // store box (fix by jox, thnx) + Box = OriginalMesh.getBoundingBox(); + + // sort weights in joints + for (s32 j=0; j<(s32)Joints.size(); ++j) + Joints[j].Weights.sort(); + + // copy mesh + AnimatedMesh = Manipulator->createMeshCopy(&OriginalMesh); + + // create and link animation data + prepareAnimationData(); + + // first animation + animateSkeleton(); + modifySkin(); + } +} + + +void CXAnimationPlayer::addFrameToMesh(CXFileReader::SXFrame& frame) +{ + // go through all meshes + for (u32 m=0; mdrop(); + + // new weights buffer + Weights.push_back( core::array() ); + + // create material + buf->Material = getMaterialFromXMaterial( + frame.Meshes[m].MaterialList.Materials[mt]); + + // add all faces of this material + addFacesToBuffer(OriginalMesh.MeshBuffers.size()-1, + frame.Meshes[m], mt, frame); + buf->recalculateBoundingBox(); + } + } + + // add child frames + for (u32 c=0; cgetTexture(getTextureFileName(xmat.TextureFileName).c_str()); + if (mat.Textures[0] == 0) + mat.Textures[0] = Driver->getTexture(xmat.TextureFileName.c_str()); + } + + return mat; +} + + + +void CXAnimationPlayer::addFacesToBuffer(s32 meshbuffernr, CXFileReader::SXMesh& mesh, s32 matnr, const CXFileReader::SXFrame& frame) +{ + scene::SMeshBuffer* buf = (SMeshBuffer*)OriginalMesh.MeshBuffers[meshbuffernr]; + + u32 tcnt = mesh.TextureCoords.size(); + u32 ncnt = mesh.Normals.size(); + u32 ccnt = mesh.VertexColors.size(); + + // precompute which joint belongs to which weight array + core::array< s32 > jointNumberWeightNumberMap; + for (u32 w=0; wMaterial.DiffuseColor; + + s32 nidx = buf->Vertices.linear_reverse_search(v); + bool alreadyIn = (nidx != -1); + + if (!alreadyIn) + { + nidx = buf->Vertices.size(); + buf->Indices.push_back(nidx); + buf->Vertices.push_back(v); + Weights[meshbuffernr].push_back(SVertexWeight()); + } + else + buf->Indices.push_back(nidx); + + bool isWeighted = alreadyIn; + + // add weight data of this vertex to all joints + if (!alreadyIn) + for (s32 w=0; w<(s32)mesh.SkinWeights.size(); ++w) + { + s32 vertexinweights = mesh.SkinWeights[w].Weights.binary_search(CXFileReader::SXWeight(idx)); + + if (vertexinweights != -1) + { + s32 jnr = jointNumberWeightNumberMap[w]; + + if (jnr != -1) + { + // weight per joint + Joints[jnr].Weights.push_back(SWeightData( + meshbuffernr, + nidx, + mesh.SkinWeights[w].Weights[vertexinweights].Weight)); + + // weight per vertex + SVertexWeight& weight = Weights[meshbuffernr].pointer()[nidx]; + weight.add(mesh.SkinWeights[w].Weights[vertexinweights].Weight, jnr); + + isWeighted = true; + } + } + } // end for all weights + + // if this vertex does not have a weight, create a virtual new + // joint and attach it to this one + if (!isWeighted) + addVirtualWeight(meshbuffernr, nidx, mesh, frame); + + } // end for all faces + + } // end for all materials + } + + // generate missing normals + if (!ncnt) + { + // Using Mesh manipulator + Manipulator->recalculateNormals ( buf, true ); + } + + /*// transform vertices and normals + core::matrix4 mat = frame.LocalMatrix; + + s32 vcnt = buf->Vertices.size(); + for (s32 u=0; uVertices[u].Pos); + mat.rotateVect(buf->Vertices[u].Normal); + }*/ +} + + +void CXAnimationPlayer::addVirtualWeight(s32 meshbuffernr, s32 vtxidx, CXFileReader::SXMesh& mesh, + const CXFileReader::SXFrame& frame) +{ + // find original joint of vertex + s32 jnr = getJointNumberFromName(frame.Name); + if (jnr == -1) + return; + + // weight per joint + Joints[jnr].Weights.push_back(SWeightData( + meshbuffernr, + vtxidx, + 1.0f)); + + // weight per vertex + SVertexWeight& weight = Weights[meshbuffernr].pointer()[vtxidx]; + weight.add(1.0f, jnr); +} + + + +s32 CXAnimationPlayer::getJointNumberFromName(const core::stringc& name) const +{ + for (s32 i=0; i<(s32)Joints.size(); ++i) + if (Joints[i].Name == name) + return i; + + return -1; +} + + + +core::stringc CXAnimationPlayer::getTextureFileName(const core::stringc& texture) +{ + s32 idx = -1; + idx = FileName.findLast('/'); + + if (idx == -1) + idx = FileName.findLast('\\'); + + if (idx == -1) + return core::stringc(); + + core::stringc p = FileName.subString(0, idx+1); + p.append(texture); + return p; +} + + + +void CXAnimationPlayer::createJointData(const CXFileReader::SXFrame& f, s32 JointParent) +{ + // add joint + s32 index = Joints.size(); + Joints.push_back(SJoint()); + SJoint& j = Joints.getLast(); + + j.Parent = JointParent; + j.GlobalMatrix = f.GlobalMatrix; + j.LocalMatrix = f.LocalMatrix; + j.AnimatedMatrix = j.GlobalMatrix; + j.LocalAnimatedMatrix = j.LocalMatrix; + j.CombinedAnimationMatrix = j.AnimatedMatrix * j.MatrixOffset; + j.IsVirtualJoint = false; + + j.Name = f.Name; + + // add all children + for (s32 i=0; i<(s32)f.ChildFrames.size(); ++i) + createJointData(f.ChildFrames[i], index); +} + + +//! Returns a pointer to a transformation matrix +core::matrix4* CXAnimationPlayer::getMatrixOfJoint(s32 jointNumber, s32 frame) +{ + if (jointNumber < 0 || jointNumber >= (s32)Joints.size()) + return 0; + + return &Joints[jointNumber].AnimatedMatrix; +} + + +//! Gets joint count. +s32 CXAnimationPlayer::getJointCount() const +{ + return Joints.size(); +} + + +//! Gets the name of a joint. +const c8* CXAnimationPlayer::getJointName(s32 number) const +{ + if (number<0 || number>=(s32)Joints.size()) + return 0; + + return Joints[number].Name.c_str(); +} + + +//! Gets a joint number from its name +s32 CXAnimationPlayer::getJointNumber(const c8* name) const +{ + for (s32 i=0; i<(s32)Joints.size(); ++i) + if (Joints[i].Name == name) + return i; + + return -1; +} + + +//! Returns a pointer to list of points containing the skeleton. +const core::array* CXAnimationPlayer::getDrawableSkeleton(s32 frame) +{ + DebugSkeleton.clear(); + + f32 k = DebugSkeletonCrossSize; + f32 p = 0.0f; + + for (s32 i=0; i<(s32)Joints.size(); ++i) + { + core::vector3df start(p,p,p); + core::vector3df end(p,p,p); + + Joints[i].AnimatedMatrix.transformVect(start); + + DebugSkeleton.push_back(start); + DebugSkeleton.push_back(start + core::vector3df(0,k,0)); + DebugSkeleton.push_back(start); + DebugSkeleton.push_back(start + core::vector3df(0,-k,0)); + DebugSkeleton.push_back(start); + DebugSkeleton.push_back(start + core::vector3df(k,0,0)); + DebugSkeleton.push_back(start); + DebugSkeleton.push_back(start + core::vector3df(-k,0,0)); + DebugSkeleton.push_back(start); + DebugSkeleton.push_back(start + core::vector3df(0,0,k)); + DebugSkeleton.push_back(start); + DebugSkeleton.push_back(start + core::vector3df(0,0,-k)); + + if (Joints[i].Parent != -1) + { + Joints[Joints[i].Parent].AnimatedMatrix.transformVect(end); + + DebugSkeleton.push_back(end); + DebugSkeleton.push_back(start); + } + } + + return &DebugSkeleton; +} + + +//! animates the skeleton based on the animation data +void CXAnimationPlayer::animateSkeleton() +{ + if (!AnimationSets.empty()) + { + // reset joints + for (u32 jii=0; jii= CurrentAnimationTime) + { + idx1 = t; + idx2 = (t+1) % currentSet.Animations[i].Times.size(); + break; + } + } + + if (idx1 == -1) + continue; + + // calculate interpolation factor + f32 factor = (CurrentAnimationTime - currentSet.Animations[i].Times[idx1]) / + (currentSet.Animations[i].Times[idx2] - currentSet.Animations[i].Times[idx1]); + + // animate it + switch(currentSet.Animations[i].keyType) + { + case 0: // rotation + { + // with this code, rotations are not 100% ok, they are + // mirrored. + core::quaternion q; + q.slerp(currentSet.Animations[i].Quaternions[idx1], + currentSet.Animations[i].Quaternions[idx2], + factor); + + joint.LocalAnimatedMatrix *= q.getMatrix(); + joint.WasAnimatedThisFrame = true; + } + break; + case 1: // scale + { + core::matrix4 mat1, mat2; + mat1.setScale(currentSet.Animations[i].Vectors[idx1]); + mat2.setScale(currentSet.Animations[i].Vectors[idx2]); + + joint.LocalAnimatedMatrix *= mat1.interpolate(mat2, factor); + joint.WasAnimatedThisFrame = true; + } + break; + case 2: // position + { + core::matrix4 mat1, mat2; + mat1.setTranslation(currentSet.Animations[i].Vectors[idx1]); + mat2.setTranslation(currentSet.Animations[i].Vectors[idx2]); + + joint.LocalAnimatedMatrix *= mat1.interpolate(mat2, factor); + joint.WasAnimatedThisFrame = true; + } + break; + case 4: + case 3: // matrix + { + joint.LocalAnimatedMatrix = + currentSet.Animations[i].Matrices[idx1].interpolate( + currentSet.Animations[i].Matrices[idx2], factor); + + joint.WasAnimatedThisFrame = true; + } + break; + } + + } + } + + // update all joints + for (s32 ji=0; ji<(s32)Joints.size(); ++ji) + { + if (!Joints[ji].WasAnimatedThisFrame) + Joints[ji].LocalAnimatedMatrix = Joints[ji].LocalMatrix; + + Joints[ji].AnimatedMatrix = Joints[ji].LocalAnimatedMatrix; + + if (Joints[ji].Parent != -1) + Joints[ji].AnimatedMatrix = Joints[Joints[ji].Parent].AnimatedMatrix * Joints[ji].AnimatedMatrix; + + Joints[ji].CombinedAnimationMatrix = Joints[ji].AnimatedMatrix * + Joints[ji].MatrixOffset; + } +} + + +//! modifies the skin based on the animated skeleton +void CXAnimationPlayer::modifySkin() +{ + // set animated vertices to zero + for (s32 k=0; k<(s32)Joints.size(); ++k) + { + for (s32 w=0; w<(s32)Joints[k].Weights.size(); ++w) + { + SWeightData& wd = Joints[k].Weights[w]; + +#ifdef _XREADER_DEBUG + if (wd.buffer >= AnimatedMesh->getMeshBufferCount() || + wd.vertex >= AnimatedMesh->getMeshBuffer(wd.buffer)->getVertexCount()) + os::Printer::log("CXAnimationPlayer: Invalid Weights"); +#endif + + video::S3DVertex* nv = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(wd.buffer)->getVertices(); + nv[wd.vertex].Pos.set(0,0,0); + } + } + + +#ifdef _XREADER_DEBUG + bool somethingIsWrong = false; + + // check if all vertices are set to zero + for (u32 mb=0; mbgetMeshBufferCount(); ++mb) + { + video::S3DVertex* v = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(mb)->getVertices(); + s32 c = AnimatedMesh->getMeshBuffer(mb)->getVertexCount(); + for (s32 vt=0; vtgetMeshBufferCount()); + os::Printer::log(tmp); + + for (u32 mb=0; mbgetMeshBufferCount(); ++mb) + { + sprintf(tmp, "CXAnimationPlayer: Meshbuffer #%d: %d vertices", mb, AnimatedMesh->getMeshBuffer(mb)->getVertexCount()); + os::Printer::log(tmp); + } + } +#endif + + // transform vertices + for (u32 mb=0; mbgetMeshBufferCount(); ++mb) + { + video::S3DVertex* av = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(mb)->getVertices(); + video::S3DVertex* ov = (video::S3DVertex*)OriginalMesh.getMeshBuffer(mb)->getVertices(); + const u32 c = AnimatedMesh->getMeshBuffer(mb)->getVertexCount(); + for (u32 vt=0; vtgetAnimationSetCount(); + for (s32 i=0; igetAnimationSet(i); + mySet.AnimationName = readerSet.AnimationName; + + // through all animations + for (s32 a=0; a<(s32)readerSet.Animations.size(); ++a) + { + // through all keys + for (s32 k=0; k<(s32)readerSet.Animations[a].Keys.size(); ++k) + { + // link with joint + s32 jntnr = getJointNumberFromName(readerSet.Animations[a].FrameName); + + if (jntnr == -1) + { + os::Printer::log( + "CXAnimationPlayer: Animationtrack without corresponding joint found", + readerSet.Animations[a].FrameName.c_str()); + continue; + } + + // copy track + s32 keyCount = (s32)readerSet.Animations[a].Keys[k].numberOfKeys; + if (!keyCount) + { + os::Printer::log( + "CXAnimationPlayer: Skipping Animationtrack with zero key frames", + readerSet.Animations[a].FrameName.c_str()); + continue; + } + + // add new track + mySet.Animations.push_back(SXAnimationTrack()); + SXAnimationTrack& myTrack = mySet.Animations.getLast(); + myTrack.jointNr = jntnr; + IsAnimatedSkinnedMesh = true; + + s32 type = readerSet.Animations[a].Keys[k].keyType; + s32 l; + myTrack.keyType = type; + + #ifdef _XREADER_DEBUG + char tmp[255]; + sprintf(tmp, "adding track %s with %d keys, type:%d", readerSet.Animations[a].FrameName.c_str(), keyCount, type); + os::Printer::log(tmp); + #endif + + switch(type) + { + case 0: // quaternion + for (l=0; l LastAnimationTime) + LastAnimationTime = myTrack.Times.getLast(); + } + } + } + + // sort animation tracks + mySet.Animations.sort(); + } +} + +void CXAnimationPlayer::updateBoundingBoxFromAnimation() +{ + if (!Joints.size()) + return; + + bool first = true; + + for (u32 i=0; iBoundingBox = Box; +} + +//! Returns amount of animations in .X-file. +s32 CXAnimationPlayer::getAnimationCount() const +{ + return AnimationSets.size(); +} + +//! Returns the name of an animation. +const c8* CXAnimationPlayer::getAnimationName(s32 idx) const +{ + if (idx < 0 || idx >= (s32)AnimationSets.size()) + return 0; + + return AnimationSets[idx].AnimationName.c_str(); +} + + +//! Sets an animation as animation to play back. +void CXAnimationPlayer::setCurrentAnimation(s32 idx) +{ + if (idx < 0 || idx >= (s32)AnimationSets.size()) + return; + + CurrentAnimationSet = idx; +} + + +//! Sets an animation as animation to play back. +bool CXAnimationPlayer::setCurrentAnimation(const c8* name) +{ + for (s32 i=0; i<(s32)AnimationSets.size(); ++i) + if (AnimationSets[i].AnimationName == name) + { + CurrentAnimationSet = i; + return true; + } + + return false; +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CXAnimationPlayer.h b/src/dep/src/irrlicht/CXAnimationPlayer.h index dd0eeb3..bf7977d 100644 --- a/src/dep/src/irrlicht/CXAnimationPlayer.h +++ b/src/dep/src/irrlicht/CXAnimationPlayer.h @@ -1,218 +1,218 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_X_ANIMATION_PLAYER_H_INCLUDED__ -#define __C_X_ANIMATION_PLAYER_H_INCLUDED__ - -#include "IAnimatedMeshX.h" -#include "CXFileReader.h" -#include "SMesh.h" -#include "SMeshBuffer.h" - -namespace irr -{ -namespace video -{ - class IVideoDriver; -} -namespace scene -{ - class IMeshManipulator; - - class CXAnimationPlayer : public IAnimatedMeshX - { - public: - - //! constructor - CXAnimationPlayer(CXFileReader* reader, - video::IVideoDriver* driver, - IMeshManipulator* manip, - const c8* filename); - - //! destructor - virtual ~CXAnimationPlayer(); - - //! Gets the frame count of the animated mesh. - virtual s32 getFrameCount(); - - //! Returns the IMesh interface for a frame. - virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1); - - //! Returns an axis aligned bounding box of the mesh. - virtual const core::aabbox3d& getBoundingBox() const; - - //! Returns the type of the animated mesh. - virtual E_ANIMATED_MESH_TYPE getMeshType() const; - - //! Returns a pointer to a transformation matrix - virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame); - - //! Gets joint count. - virtual s32 getJointCount() const; - - //! Gets the name of a joint. - virtual const c8* getJointName(s32 number) const; - - //! Gets a joint number from its name - virtual s32 getJointNumber(const c8* name) const; - - //! Returns a pointer to list of points containing the skeleton. - virtual const core::array* getDrawableSkeleton(s32 frame); - - //! Returns amount of animations in .X-file. - virtual s32 getAnimationCount() const; - - //! Returns the name of an animation. - virtual const c8* getAnimationName(s32 idx) const; - - //! Sets an animation as animation to play back. - virtual void setCurrentAnimation(s32 idx); - - //! Sets an animation as animation to play back. - virtual bool setCurrentAnimation(const c8* name); - - private: - - struct SWeightData - { - SWeightData() {}; - - SWeightData(const SWeightData& other) - : buffer(other.buffer), vertex(other.vertex), weight(other.weight) - {} - - SWeightData(s32 b, s32 v, f32 w) - : buffer(b), vertex(v), weight(w) - {} - - s32 buffer; - s32 vertex; - f32 weight; - - bool operator <(const SWeightData& other) const - { - return (buffer < other.buffer || - (buffer == other.buffer && - vertex < other.vertex) || - (buffer == other.buffer && - vertex == other.vertex && - weight < other.weight)); - } - }; - - struct SVertexWeight - { - SVertexWeight() : weightCount(0) {} - - // weight per vertex, at maximum, 4 joints per vertex - f32 weight[4]; - s32 joint[4]; - - s32 weightCount; - - void add(f32 _weight, s32 _joint) - { - if (weightCount == 4) - return; - - weight[weightCount] = _weight; - joint[weightCount] = _joint; - ++weightCount; - } - }; - - struct SJoint - { - s32 Parent; // index of parent - core::array Weights; - core::matrix4 MatrixOffset; - core::matrix4 LocalMatrix; - core::matrix4 GlobalMatrix; - core::matrix4 AnimatedMatrix; - core::matrix4 LocalAnimatedMatrix; - core::matrix4 CombinedAnimationMatrix; // for faster computing - core::stringc Name; - bool IsVirtualJoint; // for in .x file not weighted vertices - bool WasAnimatedThisFrame; // used by animateSkeleton() - }; - - void createAnimationData(); - void createJointData(const CXFileReader::SXFrame& f, s32 JointParent); - void createMeshData(); - void addFrameToMesh(CXFileReader::SXFrame& frame); - video::SMaterial getMaterialFromXMaterial(const CXFileReader::SXMaterial& xmat); - void addFacesToBuffer(s32 meshbuffernr, CXFileReader::SXMesh& mesh, s32 matnr, const CXFileReader::SXFrame& frame); - core::stringc getTextureFileName(const core::stringc& texture); - - s32 getJointNumberFromName(const core::stringc& name) const; - - //! prepares animation data which was read in from the .x file - void prepareAnimationData(); - - //! animates the skeleton based on the animation data - void animateSkeleton(); - - //! modifies the skin based on the animated skeleton - void modifySkin(); - - void updateBoundingBoxFromAnimation(); - - void addVirtualWeight(s32 meshbuffernr, s32 vtxidx, CXFileReader::SXMesh& mesh, - const CXFileReader::SXFrame& frame); - - CXFileReader* Reader; - video::IVideoDriver* Driver; - scene::SMesh OriginalMesh; - scene::SMesh *AnimatedMesh; - core::aabbox3df Box; - core::stringc FileName; - IMeshManipulator* Manipulator; - core::array DebugSkeleton; - bool IsAnimatedSkinnedMesh; - - core::array Joints; - - f32 CurrentAnimationTime; - f32 LastAnimationTime; - s32 CurrentAnimationSet; - f32 DebugSkeletonCrossSize; - - // one array of weights per mesh buffer - core::array< core::array > Weights; - - // data for animations - - struct SXAnimationTrack - { - s32 jointNr; - s32 keyType; // 0=rotation, 1=scale, 2=position, 3=matrix - - core::array Quaternions; - core::array Vectors; - core::array Matrices; - core::array Times; - - bool operator <(SXAnimationTrack& other) const - { - if (jointNr != other.jointNr) - return (jointNr < other.jointNr); - - return keyType > other.keyType; - } - }; - - struct SXAnimationSet - { - core::stringc AnimationName; - core::array Animations; - }; - - core::array AnimationSets; - }; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_X_ANIMATION_PLAYER_H_INCLUDED__ +#define __C_X_ANIMATION_PLAYER_H_INCLUDED__ + +#include "IAnimatedMeshX.h" +#include "CXFileReader.h" +#include "SMesh.h" +#include "SMeshBuffer.h" + +namespace irr +{ +namespace video +{ + class IVideoDriver; +} +namespace scene +{ + class IMeshManipulator; + + class CXAnimationPlayer : public IAnimatedMeshX + { + public: + + //! constructor + CXAnimationPlayer(CXFileReader* reader, + video::IVideoDriver* driver, + IMeshManipulator* manip, + const c8* filename); + + //! destructor + virtual ~CXAnimationPlayer(); + + //! Gets the frame count of the animated mesh. + virtual s32 getFrameCount(); + + //! Returns the IMesh interface for a frame. + virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1); + + //! Returns an axis aligned bounding box of the mesh. + virtual const core::aabbox3d& getBoundingBox() const; + + //! Returns the type of the animated mesh. + virtual E_ANIMATED_MESH_TYPE getMeshType() const; + + //! Returns a pointer to a transformation matrix + virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame); + + //! Gets joint count. + virtual s32 getJointCount() const; + + //! Gets the name of a joint. + virtual const c8* getJointName(s32 number) const; + + //! Gets a joint number from its name + virtual s32 getJointNumber(const c8* name) const; + + //! Returns a pointer to list of points containing the skeleton. + virtual const core::array* getDrawableSkeleton(s32 frame); + + //! Returns amount of animations in .X-file. + virtual s32 getAnimationCount() const; + + //! Returns the name of an animation. + virtual const c8* getAnimationName(s32 idx) const; + + //! Sets an animation as animation to play back. + virtual void setCurrentAnimation(s32 idx); + + //! Sets an animation as animation to play back. + virtual bool setCurrentAnimation(const c8* name); + + private: + + struct SWeightData + { + SWeightData() {}; + + SWeightData(const SWeightData& other) + : buffer(other.buffer), vertex(other.vertex), weight(other.weight) + {} + + SWeightData(s32 b, s32 v, f32 w) + : buffer(b), vertex(v), weight(w) + {} + + s32 buffer; + s32 vertex; + f32 weight; + + bool operator <(const SWeightData& other) const + { + return (buffer < other.buffer || + (buffer == other.buffer && + vertex < other.vertex) || + (buffer == other.buffer && + vertex == other.vertex && + weight < other.weight)); + } + }; + + struct SVertexWeight + { + SVertexWeight() : weightCount(0) {} + + // weight per vertex, at maximum, 4 joints per vertex + f32 weight[4]; + s32 joint[4]; + + s32 weightCount; + + void add(f32 _weight, s32 _joint) + { + if (weightCount == 4) + return; + + weight[weightCount] = _weight; + joint[weightCount] = _joint; + ++weightCount; + } + }; + + struct SJoint + { + s32 Parent; // index of parent + core::array Weights; + core::matrix4 MatrixOffset; + core::matrix4 LocalMatrix; + core::matrix4 GlobalMatrix; + core::matrix4 AnimatedMatrix; + core::matrix4 LocalAnimatedMatrix; + core::matrix4 CombinedAnimationMatrix; // for faster computing + core::stringc Name; + bool IsVirtualJoint; // for in .x file not weighted vertices + bool WasAnimatedThisFrame; // used by animateSkeleton() + }; + + void createAnimationData(); + void createJointData(const CXFileReader::SXFrame& f, s32 JointParent); + void createMeshData(); + void addFrameToMesh(CXFileReader::SXFrame& frame); + video::SMaterial getMaterialFromXMaterial(const CXFileReader::SXMaterial& xmat); + void addFacesToBuffer(s32 meshbuffernr, CXFileReader::SXMesh& mesh, s32 matnr, const CXFileReader::SXFrame& frame); + core::stringc getTextureFileName(const core::stringc& texture); + + s32 getJointNumberFromName(const core::stringc& name) const; + + //! prepares animation data which was read in from the .x file + void prepareAnimationData(); + + //! animates the skeleton based on the animation data + void animateSkeleton(); + + //! modifies the skin based on the animated skeleton + void modifySkin(); + + void updateBoundingBoxFromAnimation(); + + void addVirtualWeight(s32 meshbuffernr, s32 vtxidx, CXFileReader::SXMesh& mesh, + const CXFileReader::SXFrame& frame); + + CXFileReader* Reader; + video::IVideoDriver* Driver; + scene::SMesh OriginalMesh; + scene::SMesh *AnimatedMesh; + core::aabbox3df Box; + core::stringc FileName; + IMeshManipulator* Manipulator; + core::array DebugSkeleton; + bool IsAnimatedSkinnedMesh; + + core::array Joints; + + f32 CurrentAnimationTime; + f32 LastAnimationTime; + s32 CurrentAnimationSet; + f32 DebugSkeletonCrossSize; + + // one array of weights per mesh buffer + core::array< core::array > Weights; + + // data for animations + + struct SXAnimationTrack + { + s32 jointNr; + s32 keyType; // 0=rotation, 1=scale, 2=position, 3=matrix + + core::array Quaternions; + core::array Vectors; + core::array Matrices; + core::array Times; + + bool operator <(SXAnimationTrack& other) const + { + if (jointNr != other.jointNr) + return (jointNr < other.jointNr); + + return keyType > other.keyType; + } + }; + + struct SXAnimationSet + { + core::stringc AnimationName; + core::array Animations; + }; + + core::array AnimationSets; + }; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CXFileReader.cpp b/src/dep/src/irrlicht/CXFileReader.cpp index 620198b..9f12576 100644 --- a/src/dep/src/irrlicht/CXFileReader.cpp +++ b/src/dep/src/irrlicht/CXFileReader.cpp @@ -1,1927 +1,1927 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CXFileReader.h" -#include "os.h" -#include "fast_atof.h" -#include "coreutil.h" - -namespace irr -{ -namespace scene -{ - -CXFileReader::CXFileReader(io::IReadFile* file) -: MajorVersion(0), MinorVersion(0), binary(false), binaryNumCount(0), - Buffer(0), Size(0), FloatSize(0), P(0), End(0), ErrorHappened(false), - m_bFrameRemoved(false), m_pgCurFrame(0) -{ - if (!file) - { - ErrorHappened = true; - return; - } - - if (!readFileIntoMemory(file)) - { - ErrorHappened = true; - return; - } - - if (!parseFile()) - { - ErrorHappened = true; - return; - } - -#ifdef _XREADER_DEBUG - for( unsigned int i = 0; i < RootFrames.size(); i++ ) - validateMesh(&RootFrames[i]); -#endif - - for( unsigned int i = 0; i < RootFrames.size(); i++ ) - { - computeGlobalFrameMatrices(RootFrames[i], 0 ); - } -} - - -CXFileReader::~CXFileReader() -{ - if (Buffer) - delete [] Buffer; - - for (u32 i=0; iMeshes.size(); ++m) - { - s32 vcnt = frame->Meshes[m].Vertices.size(); - s32 icnt = frame->Meshes[m].Indices.size(); - s32 ncnt = frame->Meshes[m].Normals.size(); - s32 nicnt = frame->Meshes[m].NormalIndices.size(); - - // validate indices in mesh - s32 i; - - for (i=0; iMeshes[m].Indices[i] < 0) - { - sprintf(tmp, "XLoader error: index %d smaller than 0 in mesh %u: %d, frame '%s'", - i, m, frame->Meshes[m].Indices[i], frame->Name.c_str()); - os::Printer::log(tmp, ELL_ERROR); - error = true; - } - - if (frame->Meshes[m].Indices[i] > vcnt-1) - { - sprintf(tmp, "XLoader error: invalid index %d in mesh %u: %d, frame '%s'", - i, m, frame->Meshes[m].Indices[i], frame->Name.c_str()); - os::Printer::log(tmp, ELL_ERROR); - error = true; - } - } - - // validate normal indices - - for (i=0; iMeshes[m].NormalIndices[i] < 0) - { - sprintf(tmp, "XLoader error: normal index %d smaller than 0 in mesh %u: %d, frame '%s'", - i, m, frame->Meshes[m].NormalIndices[i], frame->Name.c_str()); - os::Printer::log(tmp, ELL_ERROR); - error = true; - } - - if (frame->Meshes[m].NormalIndices[i] > ncnt-1) - { - sprintf(tmp, "XLoader error: invalid normal index %d in mesh %u: %d, frame '%s'", - i, m, frame->Meshes[m].NormalIndices[i], frame->Name.c_str()); - os::Printer::log(tmp, ELL_ERROR); - error = true; - } - } - } - - - // validate child frames - for (u32 i=0; iChildFrames.size(); ++i) - if (!validateMesh(&frame->ChildFrames[i])) - error = true; - - return error; -} - - -//! Reads file into memory -bool CXFileReader::readFileIntoMemory(io::IReadFile* file) -{ - s32 Size = file->getSize(); - if (Size < 12) - { - os::Printer::log("X File is too small.", ELL_WARNING); - return false; - } - - Buffer = new c8[Size]; - - //! read all into memory - file->seek(0); // apparently sometimes files have been read already, so reset it - if (file->read(Buffer, Size) != Size) - { - os::Printer::log("Could not read from x file.", ELL_WARNING); - return false; - } - - End = Buffer + Size; - - //! check header "xof " - if (strncmp(Buffer, "xof ", 4)!=0) - { - os::Printer::log("Not an x file, wrong header.", ELL_WARNING); - return false; - } - - //! read minor and major version, e.g. 0302 or 0303 - c8 tmp[3]; - tmp[2] = 0x0; - tmp[0] = Buffer[4]; - tmp[1] = Buffer[5]; - MajorVersion = strtol(tmp, (char**) &P, 10); - - tmp[0] = Buffer[6]; - tmp[1] = Buffer[7]; - MinorVersion = strtol(tmp, (char**) &P, 10); - - //! read format - if (strncmp(&Buffer[8], "txt ", 4) ==0) - binary = false; - else if (strncmp(&Buffer[8], "bin ", 4) ==0) - binary = true; - else - { - os::Printer::log("Only uncompressed x files currently supported.", ELL_WARNING); - return false; - } - binaryNumCount=0; - - //! read float size - if (strncmp(&Buffer[12], "0032", 4) ==0) - FloatSize = 4; - else if (strncmp(&Buffer[12], "0064", 4) ==0) - FloatSize = 8; - else - { - os::Printer::log("Float size not supported.", ELL_WARNING); - return false; - } - - P = &Buffer[16]; - - readUntilEndOfLine(); - - return true; -} - -//! Parses the file -bool CXFileReader::parseFile() -{ - u32 u32Idx; - while(parseDataObject()) - { - // loop - } - // loop through hiearchy and combine frames that have no mesh - // and no name into its parent - - m_bFrameRemoved = false; - for( u32Idx = 0; u32Idx < RootFrames.size(); u32Idx++ ) - { - optimizeFrames( &RootFrames[ u32Idx ], 0 ); - } - while( m_bFrameRemoved ) - { - m_bFrameRemoved = false; - for( u32Idx = 0; u32Idx < RootFrames.size(); u32Idx++ ) - { - optimizeFrames( &RootFrames[ u32Idx ], 0 ); - } - } - return true; -} - -//! loop through hiearchy and combine frames that have no mesh or name into parent frame -void CXFileReader::optimizeFrames( SXFrame * pgFrame, SXFrame * pgParent ) -{ - if( pgParent ) - { - if( (0 == pgParent->Meshes.size()) && - (0 == strlen( pgFrame->Name.c_str() )) && - strlen( pgParent->Name.c_str() ) ) - { - // combine this frame with parent - // add child frames to parent - pgParent->LocalMatrix *= pgFrame->LocalMatrix; - - u32 c; - - for( c=0; cChildFrames.size(); ++c ) - { - // add child frames to parent - pgParent->ChildFrames.push_back(pgFrame->ChildFrames[c]); - } - - // add meshes to parent - - for( c=0; cMeshes.size(); ++c ) - { - // add meshes frames to parent - pgParent->Meshes.push_back( pgFrame->Meshes[c] ); - } - - // remove child frames in our list - pgFrame->ChildFrames.clear(); - - // remove meshes - pgFrame->Meshes.clear(); - - // find ourselve and remove from parent frame - for( c=0; c< pgParent->ChildFrames.size(); ++c ) - { - if( &pgParent->ChildFrames[c] == pgFrame ) - { - //found ourself - pgParent->ChildFrames.erase( c, 1 ); - m_bFrameRemoved = true; - return; - } - } - } - } - for (u32 c=0; cChildFrames.size(); ++c) - optimizeFrames( &pgFrame->ChildFrames[c], pgFrame ); -} - - -//! Parses the next Data object in the file -bool CXFileReader::parseDataObject() -{ - core::stringc objectName = getNextToken(); - - if (objectName.size() == 0) - return false; - - // parse specific object - - if (objectName == "template") - return parseDataObjectTemplate(); - else - if (objectName == "Frame") - { - if (!m_pgCurFrame) - { - RootFrames.push_back(SXFrame()); - m_pgCurFrame = &RootFrames.getLast(); - } - else - { - m_pgCurFrame->ChildFrames.push_back(SXFrame()); - m_pgCurFrame = &(m_pgCurFrame->ChildFrames.getLast()); - } - return parseDataObjectFrame( * m_pgCurFrame ); - } - else - if (objectName == "Mesh") - { - // some meshes have no frames at all - if (!m_pgCurFrame) - { - RootFrames.push_back(SXFrame()); - m_pgCurFrame = &RootFrames.getLast(); - } - m_pgCurFrame->Meshes.push_back(SXMesh()); - return parseDataObjectMesh(m_pgCurFrame->Meshes.getLast()); - } - else - if (objectName == "AnimationSet") - { - AnimationSets.push_back(SXAnimationSet()); - return parseDataObjectAnimationSet(AnimationSets.getLast()); - } - else - if (objectName == "Material") - { - // template materials now available thanks to joeWright - TemplateMaterials.push_back(SXTemplateMaterial()); - TemplateMaterials.getLast().Name = getNextToken(); - return parseDataObjectMaterial(TemplateMaterials.getLast().Material); - } - - os::Printer::log("Unknown data object in x file", objectName.c_str()); - - return parseUnknownDataObject(); -} - - -bool CXFileReader::parseDataObjectFrame(SXFrame& frame) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading frame"); -#endif - - // A coordinate frame, or "frame of reference." The Frame template - // is open and can contain any object. The Direct3D extensions (D3DX) - // mesh-loading functions recognize Mesh, FrameTransformMatrix, and - // Frame template instances as child objects when loading a Frame - // instance. - - if (!readHeadOfDataObject(&frame.Name)) - { - os::Printer::log("No opening brace in Frame found in x file", ELL_WARNING); - return false; - } - - // Now inside a frame. - // read tokens until closing brace is reached. - - while(true) - { - core::stringc objectName = getNextToken(); - - if (objectName.size() == 0) - { - os::Printer::log("Unexpected ending found in Frame in x file.", ELL_WARNING); - return false; - } - else - if (objectName == "}") - { - break; // frame finished - } - else - if (objectName == "Frame") - { - frame.ChildFrames.push_back(SXFrame()); - if (!parseDataObjectFrame(frame.ChildFrames.getLast())) - return false; - } - else - if (objectName == "FrameTransformMatrix") - { - if (!parseDataObjectTransformationMatrix(frame.LocalMatrix)) - return false; - } - else - if (objectName == "Mesh") - { - frame.Meshes.push_back(SXMesh()); - if (!parseDataObjectMesh(frame.Meshes.getLast())) - return false; - } - else - { - os::Printer::log("Unknown data object in frame in x file", objectName.c_str()); - if (!parseUnknownDataObject()) - return false; - } - - } - - return true; -} - - -bool CXFileReader::parseDataObjectTransformationMatrix(core::matrix4 &mat) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading Transformation Matrix"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Transformation Matrix found in x file", ELL_WARNING); - return false; - } - - if (binary) - { - // read matrix in binary format - if (readBinWord() != 7) - { - os::Printer::log("Binary X: Mesh: Expecting float list (for matrix)", ELL_WARNING); - return false; - } - - if (readBinDWord() != 0x10) - { - os::Printer::log("Binary X: Mesh: Should be 16 floats in matrix", ELL_WARNING); - return false; - } - } - - for (s32 i=0; i<4; ++i) - for (s32 j=0; j<4; ++j) - mat(i,j)=readFloat(); - - if (!checkForTwoFollowingSemicolons()) - { - os::Printer::log("No finishing semicolon in Transformation Matrix found in x file", ELL_WARNING); - return false; - } - - if (getNextToken() != "}") - { - os::Printer::log("No closing brace in Transformation Matrix found in x file", ELL_WARNING); - return false; - } - - return true; -} - - -bool CXFileReader::parseDataObjectTemplate() -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading template"); -#endif - - // parse a template data object. Currently not stored. - core::stringc name = getNextToken(); - - // ignore left delimiter - if (getNextToken() != "{") - { - os::Printer::log("Left delimiter in template data object missing.", - name.c_str(), ELL_ERROR); - return false; - } - - // read GUID - core::stringc guid = getNextToken(); - - // read and ignore data members - while(true) - { - core::stringc s = getNextToken(); - - if (s == "}") - break; - - if (s.size() == 0) - return false; - } - - return true; -} - - -bool CXFileReader::parseDataObjectMesh(SXMesh &mesh) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading mesh"); -#endif - - if (!readHeadOfDataObject(&mesh.Name)) - { - os::Printer::log("No opening brace in Mesh found in x file", ELL_WARNING); - return false; - } - - // read vertex count - s32 nVertices = readInt(); - - // read vertices - mesh.Vertices.set_used(nVertices); - - s32 count=0; - if (binary) - { - // read vertices in binary format - if (readBinWord() != 7) - { - os::Printer::log("Binary X: Mesh: Expecting float list (for vertices)", ELL_WARNING); - return false; - } - count = readBinDWord(); - if (count != (nVertices * 3)) - { - os::Printer::log("Binary X: Mesh: Value count not matching vertices count", ELL_WARNING); - return false; - } - } - - for (s32 n=0; n polygonfaces; - s32 currentIndex = 0; - - for (s32 k=0; k& indexCountPerFace) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading mesh material list"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Mesh Material List found in x file", ELL_WARNING); - return false; - } - - // read material count - readInt(); - - // read non triangulated face material index count - s32 nFaceIndices = readInt(); - - // read non triangulated face indices - - core::array nonTriFaceIndices; - nonTriFaceIndices.set_used(nFaceIndices); - - for (s32 i=0; i= End) - return false; - - if (P[0] != '"') - return false; - ++P; - - while(P < End && P[0]!='"') - { - out.append(P[0]); - ++P; - } - - if ( P[1] != ';' || P[0] != '"') - return false; - P+=2; - - return true; -} - - -bool CXFileReader::parseDataObjectAnimationSet(SXAnimationSet& set) -{ - #ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading animation set"); - #endif - - if (!readHeadOfDataObject(&set.AnimationName)) - { - os::Printer::log("No opening brace in Animation Set found in x file", ELL_WARNING); - return false; - } - - while(true) - { - core::stringc objectName = getNextToken(); - - if (objectName.size() == 0) - { - os::Printer::log("Unexpected ending found in Animation set in x file.", ELL_WARNING); - return false; - } - else - if (objectName == "}") - { - break; // animation set finished - } - else - if (objectName == "Animation") - { - set.Animations.push_back(SXAnimation()); - if (!parseDataObjectAnimation(set.Animations.getLast())) - return false; - } - else - { - os::Printer::log("Unknown data object in animation set in x file", objectName.c_str()); - if (!parseUnknownDataObject()) - return false; - } - } - return true; -} - - - -bool CXFileReader::parseDataObjectAnimation(SXAnimation& anim) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: reading animation"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Animation found in x file", ELL_WARNING); - return false; - } - - anim.closed = true; - anim.linearPositionQuality = true; - - while(true) - { - core::stringc objectName = getNextToken(); - - if (objectName.size() == 0) - { - os::Printer::log("Unexpected ending found in Animation in x file.", ELL_WARNING); - return false; - } - else - if (objectName == "}") - { - break; // animation finished - } - else - if (objectName == "AnimationKey") - { - anim.Keys.push_back(SXAnimationKey()); - if (!parseDataObjectAnimationKey(anim.Keys.getLast())) - return false; - } - else - if (objectName == "AnimationOptions") - { - //TODO: parse options. - if (!parseUnknownDataObject()) - return false; - } - else - if (objectName == "{") - { - // read frame name - anim.FrameName = getNextToken(); - core::stringc end = getNextToken(); - if (end.size() == 0 || end != "}") - { - os::Printer::log("Unexpected ending found in Animation in x file.", ELL_WARNING); - return false; - } - } - else - { - if (objectName.size()>2 && objectName[0] == '{' && - objectName[objectName.size()-1] == '}') - { - anim.FrameName = objectName.subString(1,objectName.size()-2); - } - else - { - os::Printer::log("Unknown data object in animation in x file", objectName.c_str()); - if (!parseUnknownDataObject()) - return false; - } - } - } - return true; -} - - - -bool CXFileReader::parseDataObjectAnimationKey(SXAnimationKey& animkey) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: reading animation key"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Animation Key found in x file", ELL_WARNING); - return false; - } - - // read key type - animkey.keyType = readInt(); - - if ((animkey.keyType < 0) || (animkey.keyType > 4)) - { - os::Printer::log("Unknown key type found in Animation Key in x file", ELL_WARNING); - return false; - } - - // read number of keys - animkey.numberOfKeys = readInt(); - - // eat the semicolon after the "0". if there are keys present, readInt() - // does this for us. If there aren't, we need to do it explicitly - if (!binary && animkey.numberOfKeys == 0) - getNextToken(); // skip semicolon - - animkey.init(); - - // read keys - switch(animkey.keyType) - { - case 0: - { - //read quaternions - for (s32 i=0; i& normals, - core::array< s32 >& normalIndices, - s32 triangulatedIndexCount, - core::array< s32 >& indexCountPerFace) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: reading mesh normals"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Mesh Normals found in x file", ELL_WARNING); - return false; - } - - // read count - s32 nNormals; - s32 count; - nNormals = readInt(); - normals.set_used(nNormals); - - // read normals - if (binary) - { - if (readBinWord() != 7) - { - os::Printer::log("Binary X: MeshNormals: Expecting float list", ELL_WARNING); - return false; - } - count = readBinDWord(); - if (count != nNormals * 3) - { - os::Printer::log("Binary X: MeshNormals: Value count not equal to normal count", ELL_WARNING); - return false; - } - } - for (s32 i=0; i polygonfaces; - for (s32 k=0; k& textureCoords) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: reading mesh texture coordinates"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Mesh Texture Coordinates found in x file", ELL_WARNING); - return false; - } - - s32 nCoords; - u32 count; - nCoords = readInt(); - if (binary) - { - if (readBinWord() != 7) - { - os::Printer::log("Binary X: MeshTextureCoords: Expecting float list", ELL_WARNING); - return false; - } - count = readBinDWord(); - } - textureCoords.set_used(nCoords); - - for (s32 i=0; i& vertexColors) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: reading mesh vertex colors"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace for Mesh Vertex Colors found in x file", ELL_WARNING); - return false; - } - - s32 nColors; - u32 count; - nColors = readInt(); - if (binary) - { - if (readBinWord() != 7) - { - os::Printer::log("Binary X: MeshVertexColors: Expecting float list", ELL_WARNING); - return false; - } - count = readBinDWord(); - } - vertexColors.set_used(nColors); - - for (s32 i=0; i"; - case 5: - // GUID token - P += 16; - return ""; - case 6: - len = readBinDWord(); - P += (len * 4); - return ""; - case 7: - len = readBinDWord(); - P += (len * FloatSize); - return ""; - case 0x0a: - return "{"; - case 0x0b: - return "}"; - case 0x0c: - return "("; - case 0x0d: - return ")"; - case 0x0e: - return "["; - case 0x0f: - return "]"; - case 0x10: - return "<"; - case 0x11: - return ">"; - case 0x12: - return "."; - case 0x13: - return ","; - case 0x14: - return ";"; - case 0x1f: - return "template"; - case 0x28: - return "WORD"; - case 0x29: - return "DWORD"; - case 0x2a: - return "FLOAT"; - case 0x2b: - return "DOUBLE"; - case 0x2c: - return "CHAR"; - case 0x2d: - return "UCHAR"; - case 0x2e: - return "SWORD"; - case 0x2f: - return "SDWORD"; - case 0x30: - return "void"; - case 0x31: - return "string"; - case 0x32: - return "unicode"; - case 0x34: - return "array"; - } - } - // process text-formatted file - else - { - findNextNoneWhiteSpace(); - - if (P >= End) - return s; - - while(P < End && !core::isspace(P[0])) - { - s.append(P[0]); - ++P; - } - } - return s; -} - - -//! places pointer to next begin of a token, which must be a number, -// and ignores comments -void CXFileReader::findNextNoneWhiteSpaceNumber() -{ - if (binary) - return; - - while(true) - { - while((P < End) && (P[0] != '-') && (P[0] != '.') && - !( core::isdigit(P[0]))) - ++P; - - if (P >= End) - return; - - // check if this is a comment - if ((P[0] == '/' && P[1] == '/') || P[0] == '#') - readUntilEndOfLine(); - else - break; - } - -} - -// places pointer to next begin of a token, and ignores comments -void CXFileReader::findNextNoneWhiteSpace() -{ - if (binary) - return; - - while(true) - { - while(P < End && (P[0]==' ' || P[0]=='\n' || P[0]=='\r' || P[0]=='\t')) - ++P; - - if (P >= End) - return; - - // check if this is a comment - if ((P[0] == '/' && P[1] == '/') || - P[0] == '#') - readUntilEndOfLine(); - else - break; - } -} - - -void CXFileReader::readUntilEndOfLine() -{ - if (binary) - return; - - while(P < End) - { - if (P[0] == '\n') - { - ++P; - return; - } - - ++P; - } -} - - -//! Returns if the loaded mesh is static -bool CXFileReader::isStaticMesh() const -{ - return AnimationSets.empty(); -} - -//! returns count of animations -s32 CXFileReader::getAnimationSetCount() const -{ - return AnimationSets.size(); -} - -//! returns a specific animation set -CXFileReader::SXAnimationSet& CXFileReader::getAnimationSet(s32 i) -{ - return AnimationSets[i]; -} - -//! returns the root frame of the mesh -core::array & CXFileReader::getRootFrames() -{ - return RootFrames; -} - - -void CXFileReader::computeGlobalFrameMatrices(SXFrame& frame, const SXFrame* const parent) -{ - if (!parent) - frame.GlobalMatrix = frame.LocalMatrix; - else - frame.GlobalMatrix = parent->GlobalMatrix * frame.LocalMatrix; - -#ifdef _XREADER_DEBUG - char tmp[255]; - sprintf(tmp, "CXFileReader: Frame %s ", frame.Name.c_str()); - os::Printer::log(tmp); - for (int i=0; i<4; ++i) - { - sprintf(tmp, " %f, %f, %f, %f", - frame.LocalMatrix(i,0), - frame.LocalMatrix(i,1), - frame.LocalMatrix(i,2), - frame.LocalMatrix(i,3)); - os::Printer::log(tmp); - } -#endif - for (u32 c=0; cMeshes.size(); ++m) + { + s32 vcnt = frame->Meshes[m].Vertices.size(); + s32 icnt = frame->Meshes[m].Indices.size(); + s32 ncnt = frame->Meshes[m].Normals.size(); + s32 nicnt = frame->Meshes[m].NormalIndices.size(); + + // validate indices in mesh + s32 i; + + for (i=0; iMeshes[m].Indices[i] < 0) + { + sprintf(tmp, "XLoader error: index %d smaller than 0 in mesh %u: %d, frame '%s'", + i, m, frame->Meshes[m].Indices[i], frame->Name.c_str()); + os::Printer::log(tmp, ELL_ERROR); + error = true; + } + + if (frame->Meshes[m].Indices[i] > vcnt-1) + { + sprintf(tmp, "XLoader error: invalid index %d in mesh %u: %d, frame '%s'", + i, m, frame->Meshes[m].Indices[i], frame->Name.c_str()); + os::Printer::log(tmp, ELL_ERROR); + error = true; + } + } + + // validate normal indices + + for (i=0; iMeshes[m].NormalIndices[i] < 0) + { + sprintf(tmp, "XLoader error: normal index %d smaller than 0 in mesh %u: %d, frame '%s'", + i, m, frame->Meshes[m].NormalIndices[i], frame->Name.c_str()); + os::Printer::log(tmp, ELL_ERROR); + error = true; + } + + if (frame->Meshes[m].NormalIndices[i] > ncnt-1) + { + sprintf(tmp, "XLoader error: invalid normal index %d in mesh %u: %d, frame '%s'", + i, m, frame->Meshes[m].NormalIndices[i], frame->Name.c_str()); + os::Printer::log(tmp, ELL_ERROR); + error = true; + } + } + } + + + // validate child frames + for (u32 i=0; iChildFrames.size(); ++i) + if (!validateMesh(&frame->ChildFrames[i])) + error = true; + + return error; +} + + +//! Reads file into memory +bool CXFileReader::readFileIntoMemory(io::IReadFile* file) +{ + s32 Size = file->getSize(); + if (Size < 12) + { + os::Printer::log("X File is too small.", ELL_WARNING); + return false; + } + + Buffer = new c8[Size]; + + //! read all into memory + file->seek(0); // apparently sometimes files have been read already, so reset it + if (file->read(Buffer, Size) != Size) + { + os::Printer::log("Could not read from x file.", ELL_WARNING); + return false; + } + + End = Buffer + Size; + + //! check header "xof " + if (strncmp(Buffer, "xof ", 4)!=0) + { + os::Printer::log("Not an x file, wrong header.", ELL_WARNING); + return false; + } + + //! read minor and major version, e.g. 0302 or 0303 + c8 tmp[3]; + tmp[2] = 0x0; + tmp[0] = Buffer[4]; + tmp[1] = Buffer[5]; + MajorVersion = strtol(tmp, (char**) &P, 10); + + tmp[0] = Buffer[6]; + tmp[1] = Buffer[7]; + MinorVersion = strtol(tmp, (char**) &P, 10); + + //! read format + if (strncmp(&Buffer[8], "txt ", 4) ==0) + binary = false; + else if (strncmp(&Buffer[8], "bin ", 4) ==0) + binary = true; + else + { + os::Printer::log("Only uncompressed x files currently supported.", ELL_WARNING); + return false; + } + binaryNumCount=0; + + //! read float size + if (strncmp(&Buffer[12], "0032", 4) ==0) + FloatSize = 4; + else if (strncmp(&Buffer[12], "0064", 4) ==0) + FloatSize = 8; + else + { + os::Printer::log("Float size not supported.", ELL_WARNING); + return false; + } + + P = &Buffer[16]; + + readUntilEndOfLine(); + + return true; +} + +//! Parses the file +bool CXFileReader::parseFile() +{ + u32 u32Idx; + while(parseDataObject()) + { + // loop + } + // loop through hiearchy and combine frames that have no mesh + // and no name into its parent + + m_bFrameRemoved = false; + for( u32Idx = 0; u32Idx < RootFrames.size(); u32Idx++ ) + { + optimizeFrames( &RootFrames[ u32Idx ], 0 ); + } + while( m_bFrameRemoved ) + { + m_bFrameRemoved = false; + for( u32Idx = 0; u32Idx < RootFrames.size(); u32Idx++ ) + { + optimizeFrames( &RootFrames[ u32Idx ], 0 ); + } + } + return true; +} + +//! loop through hiearchy and combine frames that have no mesh or name into parent frame +void CXFileReader::optimizeFrames( SXFrame * pgFrame, SXFrame * pgParent ) +{ + if( pgParent ) + { + if( (0 == pgParent->Meshes.size()) && + (0 == strlen( pgFrame->Name.c_str() )) && + strlen( pgParent->Name.c_str() ) ) + { + // combine this frame with parent + // add child frames to parent + pgParent->LocalMatrix *= pgFrame->LocalMatrix; + + u32 c; + + for( c=0; cChildFrames.size(); ++c ) + { + // add child frames to parent + pgParent->ChildFrames.push_back(pgFrame->ChildFrames[c]); + } + + // add meshes to parent + + for( c=0; cMeshes.size(); ++c ) + { + // add meshes frames to parent + pgParent->Meshes.push_back( pgFrame->Meshes[c] ); + } + + // remove child frames in our list + pgFrame->ChildFrames.clear(); + + // remove meshes + pgFrame->Meshes.clear(); + + // find ourselve and remove from parent frame + for( c=0; c< pgParent->ChildFrames.size(); ++c ) + { + if( &pgParent->ChildFrames[c] == pgFrame ) + { + //found ourself + pgParent->ChildFrames.erase( c, 1 ); + m_bFrameRemoved = true; + return; + } + } + } + } + for (u32 c=0; cChildFrames.size(); ++c) + optimizeFrames( &pgFrame->ChildFrames[c], pgFrame ); +} + + +//! Parses the next Data object in the file +bool CXFileReader::parseDataObject() +{ + core::stringc objectName = getNextToken(); + + if (objectName.size() == 0) + return false; + + // parse specific object + + if (objectName == "template") + return parseDataObjectTemplate(); + else + if (objectName == "Frame") + { + if (!m_pgCurFrame) + { + RootFrames.push_back(SXFrame()); + m_pgCurFrame = &RootFrames.getLast(); + } + else + { + m_pgCurFrame->ChildFrames.push_back(SXFrame()); + m_pgCurFrame = &(m_pgCurFrame->ChildFrames.getLast()); + } + return parseDataObjectFrame( * m_pgCurFrame ); + } + else + if (objectName == "Mesh") + { + // some meshes have no frames at all + if (!m_pgCurFrame) + { + RootFrames.push_back(SXFrame()); + m_pgCurFrame = &RootFrames.getLast(); + } + m_pgCurFrame->Meshes.push_back(SXMesh()); + return parseDataObjectMesh(m_pgCurFrame->Meshes.getLast()); + } + else + if (objectName == "AnimationSet") + { + AnimationSets.push_back(SXAnimationSet()); + return parseDataObjectAnimationSet(AnimationSets.getLast()); + } + else + if (objectName == "Material") + { + // template materials now available thanks to joeWright + TemplateMaterials.push_back(SXTemplateMaterial()); + TemplateMaterials.getLast().Name = getNextToken(); + return parseDataObjectMaterial(TemplateMaterials.getLast().Material); + } + + os::Printer::log("Unknown data object in x file", objectName.c_str()); + + return parseUnknownDataObject(); +} + + +bool CXFileReader::parseDataObjectFrame(SXFrame& frame) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading frame"); +#endif + + // A coordinate frame, or "frame of reference." The Frame template + // is open and can contain any object. The Direct3D extensions (D3DX) + // mesh-loading functions recognize Mesh, FrameTransformMatrix, and + // Frame template instances as child objects when loading a Frame + // instance. + + if (!readHeadOfDataObject(&frame.Name)) + { + os::Printer::log("No opening brace in Frame found in x file", ELL_WARNING); + return false; + } + + // Now inside a frame. + // read tokens until closing brace is reached. + + while(true) + { + core::stringc objectName = getNextToken(); + + if (objectName.size() == 0) + { + os::Printer::log("Unexpected ending found in Frame in x file.", ELL_WARNING); + return false; + } + else + if (objectName == "}") + { + break; // frame finished + } + else + if (objectName == "Frame") + { + frame.ChildFrames.push_back(SXFrame()); + if (!parseDataObjectFrame(frame.ChildFrames.getLast())) + return false; + } + else + if (objectName == "FrameTransformMatrix") + { + if (!parseDataObjectTransformationMatrix(frame.LocalMatrix)) + return false; + } + else + if (objectName == "Mesh") + { + frame.Meshes.push_back(SXMesh()); + if (!parseDataObjectMesh(frame.Meshes.getLast())) + return false; + } + else + { + os::Printer::log("Unknown data object in frame in x file", objectName.c_str()); + if (!parseUnknownDataObject()) + return false; + } + + } + + return true; +} + + +bool CXFileReader::parseDataObjectTransformationMatrix(core::matrix4 &mat) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading Transformation Matrix"); +#endif + + if (!readHeadOfDataObject()) + { + os::Printer::log("No opening brace in Transformation Matrix found in x file", ELL_WARNING); + return false; + } + + if (binary) + { + // read matrix in binary format + if (readBinWord() != 7) + { + os::Printer::log("Binary X: Mesh: Expecting float list (for matrix)", ELL_WARNING); + return false; + } + + if (readBinDWord() != 0x10) + { + os::Printer::log("Binary X: Mesh: Should be 16 floats in matrix", ELL_WARNING); + return false; + } + } + + for (s32 i=0; i<4; ++i) + for (s32 j=0; j<4; ++j) + mat(i,j)=readFloat(); + + if (!checkForTwoFollowingSemicolons()) + { + os::Printer::log("No finishing semicolon in Transformation Matrix found in x file", ELL_WARNING); + return false; + } + + if (getNextToken() != "}") + { + os::Printer::log("No closing brace in Transformation Matrix found in x file", ELL_WARNING); + return false; + } + + return true; +} + + +bool CXFileReader::parseDataObjectTemplate() +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading template"); +#endif + + // parse a template data object. Currently not stored. + core::stringc name = getNextToken(); + + // ignore left delimiter + if (getNextToken() != "{") + { + os::Printer::log("Left delimiter in template data object missing.", + name.c_str(), ELL_ERROR); + return false; + } + + // read GUID + core::stringc guid = getNextToken(); + + // read and ignore data members + while(true) + { + core::stringc s = getNextToken(); + + if (s == "}") + break; + + if (s.size() == 0) + return false; + } + + return true; +} + + +bool CXFileReader::parseDataObjectMesh(SXMesh &mesh) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading mesh"); +#endif + + if (!readHeadOfDataObject(&mesh.Name)) + { + os::Printer::log("No opening brace in Mesh found in x file", ELL_WARNING); + return false; + } + + // read vertex count + s32 nVertices = readInt(); + + // read vertices + mesh.Vertices.set_used(nVertices); + + s32 count=0; + if (binary) + { + // read vertices in binary format + if (readBinWord() != 7) + { + os::Printer::log("Binary X: Mesh: Expecting float list (for vertices)", ELL_WARNING); + return false; + } + count = readBinDWord(); + if (count != (nVertices * 3)) + { + os::Printer::log("Binary X: Mesh: Value count not matching vertices count", ELL_WARNING); + return false; + } + } + + for (s32 n=0; n polygonfaces; + s32 currentIndex = 0; + + for (s32 k=0; k& indexCountPerFace) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading mesh material list"); +#endif + + if (!readHeadOfDataObject()) + { + os::Printer::log("No opening brace in Mesh Material List found in x file", ELL_WARNING); + return false; + } + + // read material count + readInt(); + + // read non triangulated face material index count + s32 nFaceIndices = readInt(); + + // read non triangulated face indices + + core::array nonTriFaceIndices; + nonTriFaceIndices.set_used(nFaceIndices); + + for (s32 i=0; i= End) + return false; + + if (P[0] != '"') + return false; + ++P; + + while(P < End && P[0]!='"') + { + out.append(P[0]); + ++P; + } + + if ( P[1] != ';' || P[0] != '"') + return false; + P+=2; + + return true; +} + + +bool CXFileReader::parseDataObjectAnimationSet(SXAnimationSet& set) +{ + #ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading animation set"); + #endif + + if (!readHeadOfDataObject(&set.AnimationName)) + { + os::Printer::log("No opening brace in Animation Set found in x file", ELL_WARNING); + return false; + } + + while(true) + { + core::stringc objectName = getNextToken(); + + if (objectName.size() == 0) + { + os::Printer::log("Unexpected ending found in Animation set in x file.", ELL_WARNING); + return false; + } + else + if (objectName == "}") + { + break; // animation set finished + } + else + if (objectName == "Animation") + { + set.Animations.push_back(SXAnimation()); + if (!parseDataObjectAnimation(set.Animations.getLast())) + return false; + } + else + { + os::Printer::log("Unknown data object in animation set in x file", objectName.c_str()); + if (!parseUnknownDataObject()) + return false; + } + } + return true; +} + + + +bool CXFileReader::parseDataObjectAnimation(SXAnimation& anim) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: reading animation"); +#endif + + if (!readHeadOfDataObject()) + { + os::Printer::log("No opening brace in Animation found in x file", ELL_WARNING); + return false; + } + + anim.closed = true; + anim.linearPositionQuality = true; + + while(true) + { + core::stringc objectName = getNextToken(); + + if (objectName.size() == 0) + { + os::Printer::log("Unexpected ending found in Animation in x file.", ELL_WARNING); + return false; + } + else + if (objectName == "}") + { + break; // animation finished + } + else + if (objectName == "AnimationKey") + { + anim.Keys.push_back(SXAnimationKey()); + if (!parseDataObjectAnimationKey(anim.Keys.getLast())) + return false; + } + else + if (objectName == "AnimationOptions") + { + //TODO: parse options. + if (!parseUnknownDataObject()) + return false; + } + else + if (objectName == "{") + { + // read frame name + anim.FrameName = getNextToken(); + core::stringc end = getNextToken(); + if (end.size() == 0 || end != "}") + { + os::Printer::log("Unexpected ending found in Animation in x file.", ELL_WARNING); + return false; + } + } + else + { + if (objectName.size()>2 && objectName[0] == '{' && + objectName[objectName.size()-1] == '}') + { + anim.FrameName = objectName.subString(1,objectName.size()-2); + } + else + { + os::Printer::log("Unknown data object in animation in x file", objectName.c_str()); + if (!parseUnknownDataObject()) + return false; + } + } + } + return true; +} + + + +bool CXFileReader::parseDataObjectAnimationKey(SXAnimationKey& animkey) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: reading animation key"); +#endif + + if (!readHeadOfDataObject()) + { + os::Printer::log("No opening brace in Animation Key found in x file", ELL_WARNING); + return false; + } + + // read key type + animkey.keyType = readInt(); + + if ((animkey.keyType < 0) || (animkey.keyType > 4)) + { + os::Printer::log("Unknown key type found in Animation Key in x file", ELL_WARNING); + return false; + } + + // read number of keys + animkey.numberOfKeys = readInt(); + + // eat the semicolon after the "0". if there are keys present, readInt() + // does this for us. If there aren't, we need to do it explicitly + if (!binary && animkey.numberOfKeys == 0) + getNextToken(); // skip semicolon + + animkey.init(); + + // read keys + switch(animkey.keyType) + { + case 0: + { + //read quaternions + for (s32 i=0; i& normals, + core::array< s32 >& normalIndices, + s32 triangulatedIndexCount, + core::array< s32 >& indexCountPerFace) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: reading mesh normals"); +#endif + + if (!readHeadOfDataObject()) + { + os::Printer::log("No opening brace in Mesh Normals found in x file", ELL_WARNING); + return false; + } + + // read count + s32 nNormals; + s32 count; + nNormals = readInt(); + normals.set_used(nNormals); + + // read normals + if (binary) + { + if (readBinWord() != 7) + { + os::Printer::log("Binary X: MeshNormals: Expecting float list", ELL_WARNING); + return false; + } + count = readBinDWord(); + if (count != nNormals * 3) + { + os::Printer::log("Binary X: MeshNormals: Value count not equal to normal count", ELL_WARNING); + return false; + } + } + for (s32 i=0; i polygonfaces; + for (s32 k=0; k& textureCoords) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: reading mesh texture coordinates"); +#endif + + if (!readHeadOfDataObject()) + { + os::Printer::log("No opening brace in Mesh Texture Coordinates found in x file", ELL_WARNING); + return false; + } + + s32 nCoords; + u32 count; + nCoords = readInt(); + if (binary) + { + if (readBinWord() != 7) + { + os::Printer::log("Binary X: MeshTextureCoords: Expecting float list", ELL_WARNING); + return false; + } + count = readBinDWord(); + } + textureCoords.set_used(nCoords); + + for (s32 i=0; i& vertexColors) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: reading mesh vertex colors"); +#endif + + if (!readHeadOfDataObject()) + { + os::Printer::log("No opening brace for Mesh Vertex Colors found in x file", ELL_WARNING); + return false; + } + + s32 nColors; + u32 count; + nColors = readInt(); + if (binary) + { + if (readBinWord() != 7) + { + os::Printer::log("Binary X: MeshVertexColors: Expecting float list", ELL_WARNING); + return false; + } + count = readBinDWord(); + } + vertexColors.set_used(nColors); + + for (s32 i=0; i"; + case 5: + // GUID token + P += 16; + return ""; + case 6: + len = readBinDWord(); + P += (len * 4); + return ""; + case 7: + len = readBinDWord(); + P += (len * FloatSize); + return ""; + case 0x0a: + return "{"; + case 0x0b: + return "}"; + case 0x0c: + return "("; + case 0x0d: + return ")"; + case 0x0e: + return "["; + case 0x0f: + return "]"; + case 0x10: + return "<"; + case 0x11: + return ">"; + case 0x12: + return "."; + case 0x13: + return ","; + case 0x14: + return ";"; + case 0x1f: + return "template"; + case 0x28: + return "WORD"; + case 0x29: + return "DWORD"; + case 0x2a: + return "FLOAT"; + case 0x2b: + return "DOUBLE"; + case 0x2c: + return "CHAR"; + case 0x2d: + return "UCHAR"; + case 0x2e: + return "SWORD"; + case 0x2f: + return "SDWORD"; + case 0x30: + return "void"; + case 0x31: + return "string"; + case 0x32: + return "unicode"; + case 0x34: + return "array"; + } + } + // process text-formatted file + else + { + findNextNoneWhiteSpace(); + + if (P >= End) + return s; + + while(P < End && !core::isspace(P[0])) + { + s.append(P[0]); + ++P; + } + } + return s; +} + + +//! places pointer to next begin of a token, which must be a number, +// and ignores comments +void CXFileReader::findNextNoneWhiteSpaceNumber() +{ + if (binary) + return; + + while(true) + { + while((P < End) && (P[0] != '-') && (P[0] != '.') && + !( core::isdigit(P[0]))) + ++P; + + if (P >= End) + return; + + // check if this is a comment + if ((P[0] == '/' && P[1] == '/') || P[0] == '#') + readUntilEndOfLine(); + else + break; + } + +} + +// places pointer to next begin of a token, and ignores comments +void CXFileReader::findNextNoneWhiteSpace() +{ + if (binary) + return; + + while(true) + { + while(P < End && (P[0]==' ' || P[0]=='\n' || P[0]=='\r' || P[0]=='\t')) + ++P; + + if (P >= End) + return; + + // check if this is a comment + if ((P[0] == '/' && P[1] == '/') || + P[0] == '#') + readUntilEndOfLine(); + else + break; + } +} + + +void CXFileReader::readUntilEndOfLine() +{ + if (binary) + return; + + while(P < End) + { + if (P[0] == '\n') + { + ++P; + return; + } + + ++P; + } +} + + +//! Returns if the loaded mesh is static +bool CXFileReader::isStaticMesh() const +{ + return AnimationSets.empty(); +} + +//! returns count of animations +s32 CXFileReader::getAnimationSetCount() const +{ + return AnimationSets.size(); +} + +//! returns a specific animation set +CXFileReader::SXAnimationSet& CXFileReader::getAnimationSet(s32 i) +{ + return AnimationSets[i]; +} + +//! returns the root frame of the mesh +core::array & CXFileReader::getRootFrames() +{ + return RootFrames; +} + + +void CXFileReader::computeGlobalFrameMatrices(SXFrame& frame, const SXFrame* const parent) +{ + if (!parent) + frame.GlobalMatrix = frame.LocalMatrix; + else + frame.GlobalMatrix = parent->GlobalMatrix * frame.LocalMatrix; + +#ifdef _XREADER_DEBUG + char tmp[255]; + sprintf(tmp, "CXFileReader: Frame %s ", frame.Name.c_str()); + os::Printer::log(tmp); + for (int i=0; i<4; ++i) + { + sprintf(tmp, " %f, %f, %f, %f", + frame.LocalMatrix(i,0), + frame.LocalMatrix(i,1), + frame.LocalMatrix(i,2), + frame.LocalMatrix(i,3)); + os::Printer::log(tmp); + } +#endif + for (u32 c=0; c & getRootFrames(); - - struct SXMaterial - { - video::SColorf FaceColor; // note: RGBA - f32 Power; - video::SColorf Specular; // RGB - video::SColorf Emissive; // RGB - core::stringc TextureFileName; - }; - - struct SXMeshMaterialList - { - core::array FaceIndices; // index of material for each face - core::array Materials; // material array - }; - - struct SXTemplateMaterial - { - core::stringc Name; // template name from Xfile - SXMaterial Material; // material - }; - - struct SXIndexedColor - { - s32 Index; - video::SColorf Color; - }; - - struct SXSkinMeshHeader - { - s32 MaxSkinWeightsPerVertex; // Maximum number of transforms that affect a vertex in the mesh. - s32 MaxSkinWeightsPerFace; // Maximum number of unique transforms that affect the three vertices of any face. - s32 BoneCount; // Number of bones that affect vertices in this mesh. - }; - - struct SXWeight - { - SXWeight() {}; - SXWeight(s32 vtidx): VertexIndex(vtidx) {} - - s32 VertexIndex; - f32 Weight; - - bool operator <(const SXWeight& other) const - { - return VertexIndex < other.VertexIndex; - } - }; - - struct SXSkinWeight - { - core::stringc TransformNodeName; // name of the bone - core::array< SXWeight > Weights; - core::matrix4 MatrixOffset; // transforms the mesh vertices to the space of the bone - // When concatenated to the bone's transform, this provides the - // world space coordinates of the mesh as affected by the bone - }; - - struct SXMesh - { - // this mesh contains triangulated texture data. - // because in an .x file, faces can be made of more than 3 - // vertices, the indices data structure is triangulated during the - // loading process. The IndexCountPerFace array is filled during - // this triangulation process and stores how much indices belong to - // every face. This data structure can be ignored, because all data - // in this structure is triangulated. - - core::stringc Name; - core::array Vertices; - core::array< s32 > Indices; // triangle indices - - // optional: - - core::array TextureCoords; - core::array Normals; - core::array NormalIndices; // amount is equal to Indices amount - - core::array< s32 > IndexCountPerFace; // default 3, but could be more - core::array< SXIndexedColor > VertexColors; - core::array< SXSkinWeight > SkinWeights; - SXMeshMaterialList MaterialList; - SXSkinMeshHeader SkinMeshHeader; - }; - - struct SXFrame - { - SXFrame() : iLevel(0), pParent(0) { } - - int iLevel; - SXFrame * pParent; - core::stringc Name; - core::matrix4 LocalMatrix; - core::matrix4 GlobalMatrix; - - core::array Meshes; - core::array ChildFrames; - }; - - struct SXAnimationKey - { - SXAnimationKey() : keyType(-1), numberOfKeys(0), time(0), data(0) { } - - void del() - { - delete [] time; - - switch(keyType) - { - case -1: break; - case 0 : delete [] (core::quaternion*)data; break; - case 1 : - case 2 : delete [] (core::vector3df*)data; break; - case 3 : - case 4 : delete [] (core::matrix4*)data; break; - } - } - - void init() - { - time = new s32[numberOfKeys]; - - switch(keyType) - { - case 0 : data = new core::quaternion[numberOfKeys]; break; - case 1 : - case 2 : data = new core::vector3df[numberOfKeys]; break; - case 3 : - case 4 : data = new core::matrix4[numberOfKeys]; break; - } - - } - - core::matrix4& getMatrix(s32 nr) const - { - return ((core::matrix4*)data)[nr]; - } - - core::vector3df& getVector(s32 nr) const - { - return ((core::vector3df*)data)[nr]; - } - - core::quaternion& getQuaternion(s32 nr) const - { - return ((core::quaternion*)data)[nr]; - } - - s32 keyType; // 0=rotation, 1=scale, 2=position, 3=matrix - s32 numberOfKeys; - - s32* time; - void* data; - }; - - struct SXAnimation - { - core::stringc FrameName; - core::array Keys; - - // optional, from AnimationOptions: - bool closed; // default true - bool linearPositionQuality; // if false: spline position quality - }; - - struct SXAnimationSet - { - core::stringc AnimationName; - core::array Animations; - }; - -private: - - //! Parses the file - bool parseFile(); - - //! Reads file into memory - bool readFileIntoMemory(io::IReadFile* file); - - //! Parses the next Data object in the file - bool parseDataObject(); - - //! places pointer to next begin of a token, and ignores comments - void findNextNoneWhiteSpace(); - - //! places pointer to next begin of a token, which must be a number, - // and ignores comments - void findNextNoneWhiteSpaceNumber(); - - //! returns next parseable token. Returns empty string if no token there - core::stringc getNextToken(); - - //! reads header of dataobject including the opening brace. - //! returns false if error happened, and writes name of object - //! if there is one - bool readHeadOfDataObject(core::stringc* outname=0); - - //! checks for two following semicolons, returns false if they are not there - bool checkForTwoFollowingSemicolons(); - - //! reads a x file style string - bool getNextTokenAsString(core::stringc& out); - - inline u16 readBinWord(); - inline u32 readBinDWord(); - inline s32 readInt(); - inline f32 readFloat(); - inline bool readVector2(core::vector2df& vec); - inline bool readVector3(core::vector3df& vec); - inline bool readRGB(video::SColorf& color); - inline bool readRGBA(video::SColorf& color); - - bool parseDataObjectTemplate(); - bool parseDataObjectFrame(SXFrame &frame); - bool parseDataObjectTransformationMatrix(core::matrix4 &mat); - bool parseDataObjectMesh(SXMesh &mesh); - bool parseDataObjectMeshNormals(core::array& normals, - core::array< s32 >& normalIndices, s32 triangulatedIndexCount, - core::array< s32 >& indexCountPerFace); - bool parseDataObjectMeshTextureCoords(core::array& textureCoords); - bool parseDataObjectMeshVertexColors(core::array& vertexColors); - bool parseDataObjectMeshMaterialList(SXMeshMaterialList& materiallist, - s32 triangulatedIndexCount, core::array< s32 >& indexCountPerFace); - bool parseDataObjectMaterial(SXMaterial& material); - bool parseDataObjectTextureFilename(core::stringc& texturename); - bool parseDataObjectSkinMeshHeader(SXSkinMeshHeader& header); - bool parseDataObjectSkinWeights(SXSkinWeight& weights); - bool parseDataObjectAnimationSet(SXAnimationSet& set); - bool parseDataObjectAnimation(SXAnimation& anim); - bool parseDataObjectAnimationKey(SXAnimationKey& animkey); - bool parseUnknownDataObject(); - - void readUntilEndOfLine(); - - void computeGlobalFrameMatrices(SXFrame& frame, const SXFrame* const parent); - void optimizeFrames( SXFrame * pgFrame, SXFrame * pgParent ); - bool validateMesh(SXFrame* frame); - - s32 MajorVersion; - s32 MinorVersion; - bool binary; - s32 binaryNumCount; - - c8* Buffer; - s32 Size; - c8 FloatSize; - const c8* P; - c8* End; - - bool ErrorHappened; - - bool m_bFrameRemoved; - SXFrame * m_pgCurFrame; - core::arrayRootFrames; - core::array AnimationSets; - core::array TemplateMaterials; -}; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_X_FILE_READER_H_INCLUDED__ +#define __C_X_FILE_READER_H_INCLUDED__ + +#include "IReadFile.h" +#include "irrString.h" +#include "matrix4.h" +#include "SColor.h" +#include "irrArray.h" +#include "vector2d.h" +#include "quaternion.h" + +//#define _XREADER_DEBUG + +namespace irr +{ +namespace scene +{ + +//! This is a .x file reader. It only reads data from uncompressed .x files. +class CXFileReader : public virtual IUnknown +{ +public: + + struct SXAnimationSet; + struct SXFrame; + + CXFileReader(io::IReadFile* file); + ~CXFileReader(); + + //! Returns an error occured during reading the file + bool errorHappened() const; + + //! Returns if the loaded mesh is static + bool isStaticMesh() const; + + //! returns count of animations + s32 getAnimationSetCount() const; + + //! returns a specific animation set + SXAnimationSet& getAnimationSet(s32 i); + + //! returns array of root frames + core::array & getRootFrames(); + + struct SXMaterial + { + video::SColorf FaceColor; // note: RGBA + f32 Power; + video::SColorf Specular; // RGB + video::SColorf Emissive; // RGB + core::stringc TextureFileName; + }; + + struct SXMeshMaterialList + { + core::array FaceIndices; // index of material for each face + core::array Materials; // material array + }; + + struct SXTemplateMaterial + { + core::stringc Name; // template name from Xfile + SXMaterial Material; // material + }; + + struct SXIndexedColor + { + s32 Index; + video::SColorf Color; + }; + + struct SXSkinMeshHeader + { + s32 MaxSkinWeightsPerVertex; // Maximum number of transforms that affect a vertex in the mesh. + s32 MaxSkinWeightsPerFace; // Maximum number of unique transforms that affect the three vertices of any face. + s32 BoneCount; // Number of bones that affect vertices in this mesh. + }; + + struct SXWeight + { + SXWeight() {}; + SXWeight(s32 vtidx): VertexIndex(vtidx) {} + + s32 VertexIndex; + f32 Weight; + + bool operator <(const SXWeight& other) const + { + return VertexIndex < other.VertexIndex; + } + }; + + struct SXSkinWeight + { + core::stringc TransformNodeName; // name of the bone + core::array< SXWeight > Weights; + core::matrix4 MatrixOffset; // transforms the mesh vertices to the space of the bone + // When concatenated to the bone's transform, this provides the + // world space coordinates of the mesh as affected by the bone + }; + + struct SXMesh + { + // this mesh contains triangulated texture data. + // because in an .x file, faces can be made of more than 3 + // vertices, the indices data structure is triangulated during the + // loading process. The IndexCountPerFace array is filled during + // this triangulation process and stores how much indices belong to + // every face. This data structure can be ignored, because all data + // in this structure is triangulated. + + core::stringc Name; + core::array Vertices; + core::array< s32 > Indices; // triangle indices + + // optional: + + core::array TextureCoords; + core::array Normals; + core::array NormalIndices; // amount is equal to Indices amount + + core::array< s32 > IndexCountPerFace; // default 3, but could be more + core::array< SXIndexedColor > VertexColors; + core::array< SXSkinWeight > SkinWeights; + SXMeshMaterialList MaterialList; + SXSkinMeshHeader SkinMeshHeader; + }; + + struct SXFrame + { + SXFrame() : iLevel(0), pParent(0) { } + + int iLevel; + SXFrame * pParent; + core::stringc Name; + core::matrix4 LocalMatrix; + core::matrix4 GlobalMatrix; + + core::array Meshes; + core::array ChildFrames; + }; + + struct SXAnimationKey + { + SXAnimationKey() : keyType(-1), numberOfKeys(0), time(0), data(0) { } + + void del() + { + delete [] time; + + switch(keyType) + { + case -1: break; + case 0 : delete [] (core::quaternion*)data; break; + case 1 : + case 2 : delete [] (core::vector3df*)data; break; + case 3 : + case 4 : delete [] (core::matrix4*)data; break; + } + } + + void init() + { + time = new s32[numberOfKeys]; + + switch(keyType) + { + case 0 : data = new core::quaternion[numberOfKeys]; break; + case 1 : + case 2 : data = new core::vector3df[numberOfKeys]; break; + case 3 : + case 4 : data = new core::matrix4[numberOfKeys]; break; + } + + } + + core::matrix4& getMatrix(s32 nr) const + { + return ((core::matrix4*)data)[nr]; + } + + core::vector3df& getVector(s32 nr) const + { + return ((core::vector3df*)data)[nr]; + } + + core::quaternion& getQuaternion(s32 nr) const + { + return ((core::quaternion*)data)[nr]; + } + + s32 keyType; // 0=rotation, 1=scale, 2=position, 3=matrix + s32 numberOfKeys; + + s32* time; + void* data; + }; + + struct SXAnimation + { + core::stringc FrameName; + core::array Keys; + + // optional, from AnimationOptions: + bool closed; // default true + bool linearPositionQuality; // if false: spline position quality + }; + + struct SXAnimationSet + { + core::stringc AnimationName; + core::array Animations; + }; + +private: + + //! Parses the file + bool parseFile(); + + //! Reads file into memory + bool readFileIntoMemory(io::IReadFile* file); + + //! Parses the next Data object in the file + bool parseDataObject(); + + //! places pointer to next begin of a token, and ignores comments + void findNextNoneWhiteSpace(); + + //! places pointer to next begin of a token, which must be a number, + // and ignores comments + void findNextNoneWhiteSpaceNumber(); + + //! returns next parseable token. Returns empty string if no token there + core::stringc getNextToken(); + + //! reads header of dataobject including the opening brace. + //! returns false if error happened, and writes name of object + //! if there is one + bool readHeadOfDataObject(core::stringc* outname=0); + + //! checks for two following semicolons, returns false if they are not there + bool checkForTwoFollowingSemicolons(); + + //! reads a x file style string + bool getNextTokenAsString(core::stringc& out); + + inline u16 readBinWord(); + inline u32 readBinDWord(); + inline s32 readInt(); + inline f32 readFloat(); + inline bool readVector2(core::vector2df& vec); + inline bool readVector3(core::vector3df& vec); + inline bool readRGB(video::SColorf& color); + inline bool readRGBA(video::SColorf& color); + + bool parseDataObjectTemplate(); + bool parseDataObjectFrame(SXFrame &frame); + bool parseDataObjectTransformationMatrix(core::matrix4 &mat); + bool parseDataObjectMesh(SXMesh &mesh); + bool parseDataObjectMeshNormals(core::array& normals, + core::array< s32 >& normalIndices, s32 triangulatedIndexCount, + core::array< s32 >& indexCountPerFace); + bool parseDataObjectMeshTextureCoords(core::array& textureCoords); + bool parseDataObjectMeshVertexColors(core::array& vertexColors); + bool parseDataObjectMeshMaterialList(SXMeshMaterialList& materiallist, + s32 triangulatedIndexCount, core::array< s32 >& indexCountPerFace); + bool parseDataObjectMaterial(SXMaterial& material); + bool parseDataObjectTextureFilename(core::stringc& texturename); + bool parseDataObjectSkinMeshHeader(SXSkinMeshHeader& header); + bool parseDataObjectSkinWeights(SXSkinWeight& weights); + bool parseDataObjectAnimationSet(SXAnimationSet& set); + bool parseDataObjectAnimation(SXAnimation& anim); + bool parseDataObjectAnimationKey(SXAnimationKey& animkey); + bool parseUnknownDataObject(); + + void readUntilEndOfLine(); + + void computeGlobalFrameMatrices(SXFrame& frame, const SXFrame* const parent); + void optimizeFrames( SXFrame * pgFrame, SXFrame * pgParent ); + bool validateMesh(SXFrame* frame); + + s32 MajorVersion; + s32 MinorVersion; + bool binary; + s32 binaryNumCount; + + c8* Buffer; + s32 Size; + c8 FloatSize; + const c8* P; + c8* End; + + bool ErrorHappened; + + bool m_bFrameRemoved; + SXFrame * m_pgCurFrame; + core::arrayRootFrames; + core::array AnimationSets; + core::array TemplateMaterials; +}; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CXMLReader.cpp b/src/dep/src/irrlicht/CXMLReader.cpp index 484f996..85c00e7 100644 --- a/src/dep/src/irrlicht/CXMLReader.cpp +++ b/src/dep/src/irrlicht/CXMLReader.cpp @@ -1,70 +1,70 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CXMLReaderImpl.h" -#include "CXMLReader.h" -#include "IReadFile.h" - -namespace irr -{ -namespace io -{ - //! Irrlicht implementation of the file read callback for the xml parser - class CIrrXMLFileReadCallBack : public IFileReadCallBack - { - public: - - //! construct from FILE pointer - CIrrXMLFileReadCallBack(IReadFile* file) - : ReadFile(file) - { - ReadFile->grab(); - } - - //! destructor - virtual ~CIrrXMLFileReadCallBack() - { - ReadFile->drop(); - } - - //! Reads an amount of bytes from the file. - virtual int read(void* buffer, int sizeToRead) - { - return ReadFile->read(buffer, sizeToRead); - } - - //! Returns size of file in bytes - virtual int getSize() - { - return ReadFile->getSize(); - } - - private: - - IReadFile* ReadFile; - }; // end class CMyXMLFileReadCallBack - - - // now create an implementation for IXMLReader using irrXML. - - //! Creates an instance of a wide character xml parser. - IXMLReader* createIXMLReader(IReadFile* file) - { - if (!file) - return 0; - - return new CXMLReaderImpl(new CIrrXMLFileReadCallBack(file)); - } - - //! Creates an instance of an UFT-8 or ASCII character xml parser. - IXMLReaderUTF8* createIXMLReaderUTF8(IReadFile* file) - { - if (!file) - return 0; - - return new CXMLReaderImpl(new CIrrXMLFileReadCallBack(file)); - } - -} // end namespace -} // end namespace +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CXMLReaderImpl.h" +#include "CXMLReader.h" +#include "IReadFile.h" + +namespace irr +{ +namespace io +{ + //! Irrlicht implementation of the file read callback for the xml parser + class CIrrXMLFileReadCallBack : public IFileReadCallBack + { + public: + + //! construct from FILE pointer + CIrrXMLFileReadCallBack(IReadFile* file) + : ReadFile(file) + { + ReadFile->grab(); + } + + //! destructor + virtual ~CIrrXMLFileReadCallBack() + { + ReadFile->drop(); + } + + //! Reads an amount of bytes from the file. + virtual int read(void* buffer, int sizeToRead) + { + return ReadFile->read(buffer, sizeToRead); + } + + //! Returns size of file in bytes + virtual int getSize() + { + return ReadFile->getSize(); + } + + private: + + IReadFile* ReadFile; + }; // end class CMyXMLFileReadCallBack + + + // now create an implementation for IXMLReader using irrXML. + + //! Creates an instance of a wide character xml parser. + IXMLReader* createIXMLReader(IReadFile* file) + { + if (!file) + return 0; + + return new CXMLReaderImpl(new CIrrXMLFileReadCallBack(file)); + } + + //! Creates an instance of an UFT-8 or ASCII character xml parser. + IXMLReaderUTF8* createIXMLReaderUTF8(IReadFile* file) + { + if (!file) + return 0; + + return new CXMLReaderImpl(new CIrrXMLFileReadCallBack(file)); + } + +} // end namespace +} // end namespace diff --git a/src/dep/src/irrlicht/CXMLReader.h b/src/dep/src/irrlicht/CXMLReader.h index 67e98f8..44b48a2 100644 --- a/src/dep/src/irrlicht/CXMLReader.h +++ b/src/dep/src/irrlicht/CXMLReader.h @@ -1,26 +1,26 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_XML_READER_H_INCLUDED__ -#define __C_XML_READER_H_INCLUDED__ - -#include "IXMLReader.h" - -namespace irr -{ -namespace io -{ - class IReadFile; - - //! creates an IXMLReader - IXMLReader* createIXMLReader(IReadFile* file); - - //! creates an IXMLReader - IXMLReaderUTF8* createIXMLReaderUTF8(IReadFile* file); - -} // end namespace irr -} // end namespace io - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_XML_READER_H_INCLUDED__ +#define __C_XML_READER_H_INCLUDED__ + +#include "IXMLReader.h" + +namespace irr +{ +namespace io +{ + class IReadFile; + + //! creates an IXMLReader + IXMLReader* createIXMLReader(IReadFile* file); + + //! creates an IXMLReader + IXMLReaderUTF8* createIXMLReaderUTF8(IReadFile* file); + +} // end namespace irr +} // end namespace io + +#endif + diff --git a/src/dep/src/irrlicht/CXMLReaderImpl.h b/src/dep/src/irrlicht/CXMLReaderImpl.h index 1b87b93..3755c8e 100644 --- a/src/dep/src/irrlicht/CXMLReaderImpl.h +++ b/src/dep/src/irrlicht/CXMLReaderImpl.h @@ -1,797 +1,797 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h - -#ifndef __ICXML_READER_IMPL_H_INCLUDED__ -#define __ICXML_READER_IMPL_H_INCLUDED__ - -#include "irrXML.h" -#include "irrString.h" -#include "irrArray.h" -#include "fast_atof.h" - -#ifdef _DEBUG -#define IRR_DEBUGPRINT(x) printf((x)); -#else // _DEBUG -#define IRR_DEBUGPRINT(x) -#endif // _DEBUG - - -namespace irr -{ -namespace io -{ - - -//! implementation of the IrrXMLReader -template -class CXMLReaderImpl : public IIrrXMLReader -{ -public: - - //! Constructor - CXMLReaderImpl(IFileReadCallBack* callback, bool deleteCallBack = true) - : TextData(0), P(0), TextBegin(0), TextSize(0), CurrentNodeType(EXN_NONE), - SourceFormat(ETF_ASCII), TargetFormat(ETF_ASCII) - { - if (!callback) - return; - - storeTargetFormat(); - - // read whole xml file - - readFile(callback); - - // clean up - - if (deleteCallBack) - delete callback; - - // create list with special characters - - createSpecialCharacterList(); - - // set pointer to text begin - P = TextBegin; - } - - - //! Destructor - virtual ~CXMLReaderImpl() - { - delete [] TextData; - } - - - //! Reads forward to the next xml node. - //! \return Returns false, if there was no further node. - virtual bool read() - { - // if not end reached, parse the node - if (P && (unsigned int)(P - TextBegin) < TextSize - 1 && *P != 0) - { - parseCurrentNode(); - return true; - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - - //! Returns the type of the current XML node. - virtual EXML_NODE getNodeType() const - { - return CurrentNodeType; - } - - - //! Returns attribute count of the current XML node. - virtual int getAttributeCount() const - { - return Attributes.size(); - } - - - //! Returns name of an attribute. - virtual const char_type* getAttributeName(int idx) const - { - if (idx < 0 || idx >= (int)Attributes.size()) - return 0; - - return Attributes[idx].Name.c_str(); - } - - - //! Returns the value of an attribute. - virtual const char_type* getAttributeValue(int idx) const - { - if (idx < 0 || idx >= (int)Attributes.size()) - return 0; - - return Attributes[idx].Value.c_str(); - } - - - //! Returns the value of an attribute. - virtual const char_type* getAttributeValue(const char_type* name) const - { - const SAttribute* attr = getAttributeByName(name); - if (!attr) - return 0; - - return attr->Value.c_str(); - } - - - //! Returns the value of an attribute - virtual const char_type* getAttributeValueSafe(const char_type* name) const - { - const SAttribute* attr = getAttributeByName(name); - if (!attr) - return EmptyString.c_str(); - - return attr->Value.c_str(); - } - - - - //! Returns the value of an attribute as integer. - int getAttributeValueAsInt(const char_type* name) const - { - return (int)getAttributeValueAsFloat(name); - } - - - //! Returns the value of an attribute as integer. - int getAttributeValueAsInt(int idx) const - { - return (int)getAttributeValueAsFloat(idx); - } - - - //! Returns the value of an attribute as float. - float getAttributeValueAsFloat(const char_type* name) const - { - const SAttribute* attr = getAttributeByName(name); - if (!attr) - return 0; - - core::stringc c = attr->Value.c_str(); - return core::fast_atof(c.c_str()); - } - - - //! Returns the value of an attribute as float. - float getAttributeValueAsFloat(int idx) const - { - const char_type* attrvalue = getAttributeValue(idx); - if (!attrvalue) - return 0; - - core::stringc c = attrvalue; - return core::fast_atof(c.c_str()); - } - - - //! Returns the name of the current node. - virtual const char_type* getNodeName() const - { - return NodeName.c_str(); - } - - - //! Returns data of the current node. - virtual const char_type* getNodeData() const - { - return NodeName.c_str(); - } - - - //! Returns if an element is an empty element, like - virtual bool isEmptyElement() const - { - return IsEmptyElement; - } - - //! Returns format of the source xml file. - virtual ETEXT_FORMAT getSourceFormat() const - { - return SourceFormat; - } - - //! Returns format of the strings returned by the parser. - virtual ETEXT_FORMAT getParserFormat() const - { - return TargetFormat; - } - -private: - - // Reads the current xml node - void parseCurrentNode() - { - char_type* start = P; - - // more forward until '<' found - while(*P != L'<' && *P) - ++P; - - if (!*P) - return; - - if (P - start > 0) - { - // we found some text, store it - if (setText(start, P)) - return; - } - - ++P; - - // based on current token, parse and report next element - switch(*P) - { - case L'/': - parseClosingXMLElement(); - break; - case L'?': - ignoreDefinition(); - break; - case L'!': - if (!parseCDATA()) - parseComment(); - break; - default: - parseOpeningXMLElement(); - break; - } - } - - - //! sets the state that text was found. Returns true if set should be set - bool setText(char_type* start, char_type* end) - { - // check if text is more than 2 characters, and if not, check if there is - // only white space, so that this text won't be reported - if (end - start < 3) - { - char_type* p = start; - for(; p != end; ++p) - if (!isWhiteSpace(*p)) - break; - - if (p == end) - return false; - } - - // set current text to the parsed text, and replace xml special characters - core::string s(start, (int)(end - start)); - NodeName = replaceSpecialCharacters(s); - - // current XML node type is text - CurrentNodeType = EXN_TEXT; - - return true; - } - - - - //! ignores an xml definition like - void ignoreDefinition() - { - CurrentNodeType = EXN_UNKNOWN; - - // move until end marked with '>' reached - while(*P != L'>') - ++P; - - ++P; - } - - - //! parses a comment - void parseComment() - { - CurrentNodeType = EXN_COMMENT; - P += 1; - - char_type *pCommentBegin = P; - - int count = 1; - - // move until end of comment reached - while(count) - { - if (*P == L'>') - --count; - else - if (*P == L'<') - ++count; - - ++P; - } - - P -= 3; - NodeName = core::string(pCommentBegin+2, (int)(P - pCommentBegin-2)); - P += 3; - } - - - //! parses an opening xml element and reads attributes - void parseOpeningXMLElement() - { - CurrentNodeType = EXN_ELEMENT; - IsEmptyElement = false; - Attributes.clear(); - - // find name - const char_type* startName = P; - - // find end of element - while(*P != L'>' && !isWhiteSpace(*P)) - ++P; - - const char_type* endName = P; - - // find Attributes - while(*P != L'>') - { - if (isWhiteSpace(*P)) - ++P; - else - { - if (*P != L'/') - { - // we've got an attribute - - // read the attribute names - const char_type* attributeNameBegin = P; - - while(!isWhiteSpace(*P) && *P != L'=') - ++P; - - const char_type* attributeNameEnd = P; - ++P; - - // read the attribute value - // check for quotes and single quotes, thx to murphy - while( (*P != L'\"') && (*P != L'\'') && *P) - ++P; - - if (!*P) // malformatted xml file - return; - - const char_type attributeQuoteChar = *P; - - ++P; - const char_type* attributeValueBegin = P; - - while(*P != attributeQuoteChar && *P) - ++P; - - if (!*P) // malformatted xml file - return; - - const char_type* attributeValueEnd = P; - ++P; - - SAttribute attr; - attr.Name = core::string(attributeNameBegin, - (int)(attributeNameEnd - attributeNameBegin)); - - core::string s(attributeValueBegin, - (int)(attributeValueEnd - attributeValueBegin)); - - attr.Value = replaceSpecialCharacters(s); - Attributes.push_back(attr); - } - else - { - // tag is closed directly - ++P; - IsEmptyElement = true; - break; - } - } - } - - // check if this tag is closing directly - if (endName > startName && *(endName-1) == L'/') - { - // directly closing tag - IsEmptyElement = true; - endName--; - } - - NodeName = core::string(startName, (int)(endName - startName)); - - ++P; - } - - - //! parses an closing xml tag - void parseClosingXMLElement() - { - CurrentNodeType = EXN_ELEMENT_END; - IsEmptyElement = false; - Attributes.clear(); - - ++P; - const char_type* pBeginClose = P; - - while(*P != L'>') - ++P; - - NodeName = core::string(pBeginClose, (int)(P - pBeginClose)); - ++P; - } - - //! parses a possible CDATA section, returns false if begin was not a CDATA section - bool parseCDATA() - { - if (*(P+1) != L'[') - return false; - - CurrentNodeType = EXN_CDATA; - - // skip '' && - (*(P-1) == L']') && - (*(P-2) == L']')) - { - cDataEnd = P - 2; - } - - ++P; - } - - if ( cDataEnd ) - NodeName = core::string(cDataBegin, (int)(cDataEnd - cDataBegin)); - else - NodeName = ""; - - return true; - } - - - // structure for storing attribute-name pairs - struct SAttribute - { - core::string Name; - core::string Value; - }; - - // finds a current attribute by name, returns 0 if not found - const SAttribute* getAttributeByName(const char_type* name) const - { - if (!name) - return 0; - - core::string n = name; - - for (int i=0; i<(int)Attributes.size(); ++i) - if (Attributes[i].Name == n) - return &Attributes[i]; - - return 0; - } - - // replaces xml special characters in a string and creates a new one - core::string replaceSpecialCharacters( - core::string& origstr) - { - int pos = origstr.findFirst(L'&'); - int oldPos = 0; - - if (pos == -1) - return origstr; - - core::string newstr; - - while(pos != -1 && pos < (int)origstr.size()-2) - { - // check if it is one of the special characters - - int specialChar = -1; - for (int i=0; i<(int)SpecialCharacters.size(); ++i) - { - const char_type* p = &origstr.c_str()[pos]+1; - - if (equalsn(&SpecialCharacters[i][1], p, SpecialCharacters[i].size()-1)) - { - specialChar = i; - break; - } - } - - if (specialChar != -1) - { - newstr.append(origstr.subString(oldPos, pos - oldPos)); - newstr.append(SpecialCharacters[specialChar][0]); - pos += SpecialCharacters[specialChar].size(); - } - else - { - newstr.append(origstr.subString(oldPos, pos - oldPos + 1)); - pos += 1; - } - - // find next & - oldPos = pos; - pos = origstr.findNext(L'&', pos); - } - - if (oldPos < (int)origstr.size()-1) - newstr.append(origstr.subString(oldPos, origstr.size()-oldPos)); - - return newstr; - } - - - - //! reads the xml file and converts it into the wanted character format. - bool readFile(IFileReadCallBack* callback) - { - int size = callback->getSize(); - size += 4; // We need two terminating 0's at the end. - // For ASCII we need 1 0's, for UTF-16 2, for UTF-32 4. - - char* data8 = new char[size]; - - if (!callback->read(data8, size-4)) - { - delete [] data8; - return false; - } - - // add zeros at end - - data8[size-1] = 0; - data8[size-2] = 0; - data8[size-3] = 0; - data8[size-4] = 0; - - char16* data16 = reinterpret_cast(data8); - char32* data32 = reinterpret_cast(data8); - - // now we need to convert the data to the desired target format - // based on the byte order mark. - - const unsigned char UTF8[] = {0xEF, 0xBB, 0xBF}; // 0xEFBBBF; - const int UTF16_BE = 0xFFFE; - const int UTF16_LE = 0xFEFF; - const int UTF32_BE = 0xFFFE0000; - const int UTF32_LE = 0x0000FEFF; - - // check source for all utf versions and convert to target data format - - if (size >= 4 && data32[0] == (char32)UTF32_BE) - { - // UTF-32, big endian - SourceFormat = ETF_UTF32_BE; - convertTextData(data32+1, data8, (size/4)); // data32+1 because we need to skip the header - } - else - if (size >= 4 && data32[0] == (char32)UTF32_LE) - { - // UTF-32, little endian - SourceFormat = ETF_UTF32_LE; - convertTextData(data32+1, data8, (size/4)); // data32+1 because we need to skip the header - } - else - if (size >= 2 && data16[0] == UTF16_BE) - { - // UTF-16, big endian - SourceFormat = ETF_UTF16_BE; - convertTextData(data16+1, data8, (size/2)); // data16+1 because we need to skip the header - } - else - if (size >= 2 && data16[0] == UTF16_LE) - { - // UTF-16, little endian - SourceFormat = ETF_UTF16_LE; - convertTextData(data16+1, data8, (size/2)); // data16+1 because we need to skip the header - } - else - if (size >= 3 && data8[0] == UTF8[0] && data8[1] == UTF8[1] && data8[2] == UTF8[2]) - { - // UTF-8 - SourceFormat = ETF_UTF8; - convertTextData(data8+3, data8, size); // data8+3 because we need to skip the header - } - else - { - // ASCII - SourceFormat = ETF_ASCII; - convertTextData(data8, data8, size); - } - - return true; - } - - - //! converts the text file into the desired format. - //! \param source: begin of the text (without byte order mark) - //! \param pointerToStore: pointer to text data block which can be - //! stored or deleted based on the nesessary conversion. - //! \param sizeWithoutHeader: Text size in characters without header - template - void convertTextData(src_char_type* source, char* pointerToStore, int sizeWithoutHeader) - { - // convert little to big endian if necessary - if (sizeof(src_char_type) > 1 && - isLittleEndian(TargetFormat) != isLittleEndian(SourceFormat)) - convertToLittleEndian(source); - - // check if conversion is necessary: - if (sizeof(src_char_type) == sizeof(char_type)) - { - // no need to convert - TextBegin = (char_type*)source; - TextData = (char_type*)pointerToStore; - TextSize = sizeWithoutHeader; - } - else - { - // convert source into target data format. - // TODO: implement a real conversion. This one just - // copies bytes. This is a problem when there are - // unicode symbols using more than one character. - - TextData = new char_type[sizeWithoutHeader]; - - for (int i=0; i - void convertToLittleEndian(src_char_type* t) - { - if (sizeof(src_char_type) == 4) - { - // 32 bit - - while(*t) - { - *t = ((*t & 0xff000000) >> 24) | - ((*t & 0x00ff0000) >> 8) | - ((*t & 0x0000ff00) << 8) | - ((*t & 0x000000ff) << 24); - ++t; - } - } - else - { - // 16 bit - - while(*t) - { - *t = (*t >> 8) | (*t << 8); - ++t; - } - } - } - - //! returns if a format is little endian - inline bool isLittleEndian(ETEXT_FORMAT f) - { - return f == ETF_ASCII || - f == ETF_UTF8 || - f == ETF_UTF16_LE || - f == ETF_UTF32_LE; - } - - - //! returns true if a character is whitespace - inline bool isWhiteSpace(char_type c) - { - return (c==' ' || c=='\t' || c=='\n' || c=='\r'); - } - - - //! generates a list with xml special characters - void createSpecialCharacterList() - { - // list of strings containing special symbols, - // the first character is the special character, - // the following is the symbol string without trailing &. - - SpecialCharacters.push_back("&"); - SpecialCharacters.push_back("gt;"); - SpecialCharacters.push_back("\"quot;"); - SpecialCharacters.push_back("'apos;"); - - } - - - //! compares the first n characters of the strings - bool equalsn(const char_type* str1, const char_type* str2, int len) - { - int i; - for(i=0; str1[i] && str2[i] && i < len; ++i) - if (str1[i] != str2[i]) - return false; - - // if one (or both) of the strings was smaller then they - // are only equal if they have the same lenght - return (i == len) || (str1[i] == 0 && str2[i] == 0); - } - - - //! stores the target text format - void storeTargetFormat() - { - // get target format. We could have done this using template specialization, - // but VisualStudio 6 don't like it and we want to support it. - - switch(sizeof(char_type)) - { - case 1: - TargetFormat = ETF_UTF8; - break; - case 2: - TargetFormat = ETF_UTF16_LE; - break; - case 4: - TargetFormat = ETF_UTF32_LE; - break; - default: - TargetFormat = ETF_ASCII; // should never happen. - } - } - - - // instance variables: - - char_type* TextData; // data block of the text file - char_type* P; // current point in text to parse - char_type* TextBegin; // start of text to parse - unsigned int TextSize; // size of text to parse in characters, not bytes - - EXML_NODE CurrentNodeType; // type of the currently parsed node - ETEXT_FORMAT SourceFormat; // source format of the xml file - ETEXT_FORMAT TargetFormat; // output format of this parser - - core::string NodeName; // name of the node currently in - core::string EmptyString; // empty string to be returned by getSafe() methods - - bool IsEmptyElement; // is the currently parsed node empty? - - core::array< core::string > SpecialCharacters; // see createSpecialCharacterList() - - core::array Attributes; // attributes of current element - -}; // end CXMLReaderImpl - - -} // end namespace -} // end namespace - -#endif +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine" and the "irrXML" project. +// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h + +#ifndef __ICXML_READER_IMPL_H_INCLUDED__ +#define __ICXML_READER_IMPL_H_INCLUDED__ + +#include "irrXML.h" +#include "irrString.h" +#include "irrArray.h" +#include "fast_atof.h" + +#ifdef _DEBUG +#define IRR_DEBUGPRINT(x) printf((x)); +#else // _DEBUG +#define IRR_DEBUGPRINT(x) +#endif // _DEBUG + + +namespace irr +{ +namespace io +{ + + +//! implementation of the IrrXMLReader +template +class CXMLReaderImpl : public IIrrXMLReader +{ +public: + + //! Constructor + CXMLReaderImpl(IFileReadCallBack* callback, bool deleteCallBack = true) + : TextData(0), P(0), TextBegin(0), TextSize(0), CurrentNodeType(EXN_NONE), + SourceFormat(ETF_ASCII), TargetFormat(ETF_ASCII) + { + if (!callback) + return; + + storeTargetFormat(); + + // read whole xml file + + readFile(callback); + + // clean up + + if (deleteCallBack) + delete callback; + + // create list with special characters + + createSpecialCharacterList(); + + // set pointer to text begin + P = TextBegin; + } + + + //! Destructor + virtual ~CXMLReaderImpl() + { + delete [] TextData; + } + + + //! Reads forward to the next xml node. + //! \return Returns false, if there was no further node. + virtual bool read() + { + // if not end reached, parse the node + if (P && (unsigned int)(P - TextBegin) < TextSize - 1 && *P != 0) + { + parseCurrentNode(); + return true; + } + + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return false; + } + + + //! Returns the type of the current XML node. + virtual EXML_NODE getNodeType() const + { + return CurrentNodeType; + } + + + //! Returns attribute count of the current XML node. + virtual int getAttributeCount() const + { + return Attributes.size(); + } + + + //! Returns name of an attribute. + virtual const char_type* getAttributeName(int idx) const + { + if (idx < 0 || idx >= (int)Attributes.size()) + return 0; + + return Attributes[idx].Name.c_str(); + } + + + //! Returns the value of an attribute. + virtual const char_type* getAttributeValue(int idx) const + { + if (idx < 0 || idx >= (int)Attributes.size()) + return 0; + + return Attributes[idx].Value.c_str(); + } + + + //! Returns the value of an attribute. + virtual const char_type* getAttributeValue(const char_type* name) const + { + const SAttribute* attr = getAttributeByName(name); + if (!attr) + return 0; + + return attr->Value.c_str(); + } + + + //! Returns the value of an attribute + virtual const char_type* getAttributeValueSafe(const char_type* name) const + { + const SAttribute* attr = getAttributeByName(name); + if (!attr) + return EmptyString.c_str(); + + return attr->Value.c_str(); + } + + + + //! Returns the value of an attribute as integer. + int getAttributeValueAsInt(const char_type* name) const + { + return (int)getAttributeValueAsFloat(name); + } + + + //! Returns the value of an attribute as integer. + int getAttributeValueAsInt(int idx) const + { + return (int)getAttributeValueAsFloat(idx); + } + + + //! Returns the value of an attribute as float. + float getAttributeValueAsFloat(const char_type* name) const + { + const SAttribute* attr = getAttributeByName(name); + if (!attr) + return 0; + + core::stringc c = attr->Value.c_str(); + return core::fast_atof(c.c_str()); + } + + + //! Returns the value of an attribute as float. + float getAttributeValueAsFloat(int idx) const + { + const char_type* attrvalue = getAttributeValue(idx); + if (!attrvalue) + return 0; + + core::stringc c = attrvalue; + return core::fast_atof(c.c_str()); + } + + + //! Returns the name of the current node. + virtual const char_type* getNodeName() const + { + return NodeName.c_str(); + } + + + //! Returns data of the current node. + virtual const char_type* getNodeData() const + { + return NodeName.c_str(); + } + + + //! Returns if an element is an empty element, like + virtual bool isEmptyElement() const + { + return IsEmptyElement; + } + + //! Returns format of the source xml file. + virtual ETEXT_FORMAT getSourceFormat() const + { + return SourceFormat; + } + + //! Returns format of the strings returned by the parser. + virtual ETEXT_FORMAT getParserFormat() const + { + return TargetFormat; + } + +private: + + // Reads the current xml node + void parseCurrentNode() + { + char_type* start = P; + + // more forward until '<' found + while(*P != L'<' && *P) + ++P; + + if (!*P) + return; + + if (P - start > 0) + { + // we found some text, store it + if (setText(start, P)) + return; + } + + ++P; + + // based on current token, parse and report next element + switch(*P) + { + case L'/': + parseClosingXMLElement(); + break; + case L'?': + ignoreDefinition(); + break; + case L'!': + if (!parseCDATA()) + parseComment(); + break; + default: + parseOpeningXMLElement(); + break; + } + } + + + //! sets the state that text was found. Returns true if set should be set + bool setText(char_type* start, char_type* end) + { + // check if text is more than 2 characters, and if not, check if there is + // only white space, so that this text won't be reported + if (end - start < 3) + { + char_type* p = start; + for(; p != end; ++p) + if (!isWhiteSpace(*p)) + break; + + if (p == end) + return false; + } + + // set current text to the parsed text, and replace xml special characters + core::string s(start, (int)(end - start)); + NodeName = replaceSpecialCharacters(s); + + // current XML node type is text + CurrentNodeType = EXN_TEXT; + + return true; + } + + + + //! ignores an xml definition like + void ignoreDefinition() + { + CurrentNodeType = EXN_UNKNOWN; + + // move until end marked with '>' reached + while(*P != L'>') + ++P; + + ++P; + } + + + //! parses a comment + void parseComment() + { + CurrentNodeType = EXN_COMMENT; + P += 1; + + char_type *pCommentBegin = P; + + int count = 1; + + // move until end of comment reached + while(count) + { + if (*P == L'>') + --count; + else + if (*P == L'<') + ++count; + + ++P; + } + + P -= 3; + NodeName = core::string(pCommentBegin+2, (int)(P - pCommentBegin-2)); + P += 3; + } + + + //! parses an opening xml element and reads attributes + void parseOpeningXMLElement() + { + CurrentNodeType = EXN_ELEMENT; + IsEmptyElement = false; + Attributes.clear(); + + // find name + const char_type* startName = P; + + // find end of element + while(*P != L'>' && !isWhiteSpace(*P)) + ++P; + + const char_type* endName = P; + + // find Attributes + while(*P != L'>') + { + if (isWhiteSpace(*P)) + ++P; + else + { + if (*P != L'/') + { + // we've got an attribute + + // read the attribute names + const char_type* attributeNameBegin = P; + + while(!isWhiteSpace(*P) && *P != L'=') + ++P; + + const char_type* attributeNameEnd = P; + ++P; + + // read the attribute value + // check for quotes and single quotes, thx to murphy + while( (*P != L'\"') && (*P != L'\'') && *P) + ++P; + + if (!*P) // malformatted xml file + return; + + const char_type attributeQuoteChar = *P; + + ++P; + const char_type* attributeValueBegin = P; + + while(*P != attributeQuoteChar && *P) + ++P; + + if (!*P) // malformatted xml file + return; + + const char_type* attributeValueEnd = P; + ++P; + + SAttribute attr; + attr.Name = core::string(attributeNameBegin, + (int)(attributeNameEnd - attributeNameBegin)); + + core::string s(attributeValueBegin, + (int)(attributeValueEnd - attributeValueBegin)); + + attr.Value = replaceSpecialCharacters(s); + Attributes.push_back(attr); + } + else + { + // tag is closed directly + ++P; + IsEmptyElement = true; + break; + } + } + } + + // check if this tag is closing directly + if (endName > startName && *(endName-1) == L'/') + { + // directly closing tag + IsEmptyElement = true; + endName--; + } + + NodeName = core::string(startName, (int)(endName - startName)); + + ++P; + } + + + //! parses an closing xml tag + void parseClosingXMLElement() + { + CurrentNodeType = EXN_ELEMENT_END; + IsEmptyElement = false; + Attributes.clear(); + + ++P; + const char_type* pBeginClose = P; + + while(*P != L'>') + ++P; + + NodeName = core::string(pBeginClose, (int)(P - pBeginClose)); + ++P; + } + + //! parses a possible CDATA section, returns false if begin was not a CDATA section + bool parseCDATA() + { + if (*(P+1) != L'[') + return false; + + CurrentNodeType = EXN_CDATA; + + // skip '' && + (*(P-1) == L']') && + (*(P-2) == L']')) + { + cDataEnd = P - 2; + } + + ++P; + } + + if ( cDataEnd ) + NodeName = core::string(cDataBegin, (int)(cDataEnd - cDataBegin)); + else + NodeName = ""; + + return true; + } + + + // structure for storing attribute-name pairs + struct SAttribute + { + core::string Name; + core::string Value; + }; + + // finds a current attribute by name, returns 0 if not found + const SAttribute* getAttributeByName(const char_type* name) const + { + if (!name) + return 0; + + core::string n = name; + + for (int i=0; i<(int)Attributes.size(); ++i) + if (Attributes[i].Name == n) + return &Attributes[i]; + + return 0; + } + + // replaces xml special characters in a string and creates a new one + core::string replaceSpecialCharacters( + core::string& origstr) + { + int pos = origstr.findFirst(L'&'); + int oldPos = 0; + + if (pos == -1) + return origstr; + + core::string newstr; + + while(pos != -1 && pos < (int)origstr.size()-2) + { + // check if it is one of the special characters + + int specialChar = -1; + for (int i=0; i<(int)SpecialCharacters.size(); ++i) + { + const char_type* p = &origstr.c_str()[pos]+1; + + if (equalsn(&SpecialCharacters[i][1], p, SpecialCharacters[i].size()-1)) + { + specialChar = i; + break; + } + } + + if (specialChar != -1) + { + newstr.append(origstr.subString(oldPos, pos - oldPos)); + newstr.append(SpecialCharacters[specialChar][0]); + pos += SpecialCharacters[specialChar].size(); + } + else + { + newstr.append(origstr.subString(oldPos, pos - oldPos + 1)); + pos += 1; + } + + // find next & + oldPos = pos; + pos = origstr.findNext(L'&', pos); + } + + if (oldPos < (int)origstr.size()-1) + newstr.append(origstr.subString(oldPos, origstr.size()-oldPos)); + + return newstr; + } + + + + //! reads the xml file and converts it into the wanted character format. + bool readFile(IFileReadCallBack* callback) + { + int size = callback->getSize(); + size += 4; // We need two terminating 0's at the end. + // For ASCII we need 1 0's, for UTF-16 2, for UTF-32 4. + + char* data8 = new char[size]; + + if (!callback->read(data8, size-4)) + { + delete [] data8; + return false; + } + + // add zeros at end + + data8[size-1] = 0; + data8[size-2] = 0; + data8[size-3] = 0; + data8[size-4] = 0; + + char16* data16 = reinterpret_cast(data8); + char32* data32 = reinterpret_cast(data8); + + // now we need to convert the data to the desired target format + // based on the byte order mark. + + const unsigned char UTF8[] = {0xEF, 0xBB, 0xBF}; // 0xEFBBBF; + const int UTF16_BE = 0xFFFE; + const int UTF16_LE = 0xFEFF; + const int UTF32_BE = 0xFFFE0000; + const int UTF32_LE = 0x0000FEFF; + + // check source for all utf versions and convert to target data format + + if (size >= 4 && data32[0] == (char32)UTF32_BE) + { + // UTF-32, big endian + SourceFormat = ETF_UTF32_BE; + convertTextData(data32+1, data8, (size/4)); // data32+1 because we need to skip the header + } + else + if (size >= 4 && data32[0] == (char32)UTF32_LE) + { + // UTF-32, little endian + SourceFormat = ETF_UTF32_LE; + convertTextData(data32+1, data8, (size/4)); // data32+1 because we need to skip the header + } + else + if (size >= 2 && data16[0] == UTF16_BE) + { + // UTF-16, big endian + SourceFormat = ETF_UTF16_BE; + convertTextData(data16+1, data8, (size/2)); // data16+1 because we need to skip the header + } + else + if (size >= 2 && data16[0] == UTF16_LE) + { + // UTF-16, little endian + SourceFormat = ETF_UTF16_LE; + convertTextData(data16+1, data8, (size/2)); // data16+1 because we need to skip the header + } + else + if (size >= 3 && data8[0] == UTF8[0] && data8[1] == UTF8[1] && data8[2] == UTF8[2]) + { + // UTF-8 + SourceFormat = ETF_UTF8; + convertTextData(data8+3, data8, size); // data8+3 because we need to skip the header + } + else + { + // ASCII + SourceFormat = ETF_ASCII; + convertTextData(data8, data8, size); + } + + return true; + } + + + //! converts the text file into the desired format. + //! \param source: begin of the text (without byte order mark) + //! \param pointerToStore: pointer to text data block which can be + //! stored or deleted based on the nesessary conversion. + //! \param sizeWithoutHeader: Text size in characters without header + template + void convertTextData(src_char_type* source, char* pointerToStore, int sizeWithoutHeader) + { + // convert little to big endian if necessary + if (sizeof(src_char_type) > 1 && + isLittleEndian(TargetFormat) != isLittleEndian(SourceFormat)) + convertToLittleEndian(source); + + // check if conversion is necessary: + if (sizeof(src_char_type) == sizeof(char_type)) + { + // no need to convert + TextBegin = (char_type*)source; + TextData = (char_type*)pointerToStore; + TextSize = sizeWithoutHeader; + } + else + { + // convert source into target data format. + // TODO: implement a real conversion. This one just + // copies bytes. This is a problem when there are + // unicode symbols using more than one character. + + TextData = new char_type[sizeWithoutHeader]; + + for (int i=0; i + void convertToLittleEndian(src_char_type* t) + { + if (sizeof(src_char_type) == 4) + { + // 32 bit + + while(*t) + { + *t = ((*t & 0xff000000) >> 24) | + ((*t & 0x00ff0000) >> 8) | + ((*t & 0x0000ff00) << 8) | + ((*t & 0x000000ff) << 24); + ++t; + } + } + else + { + // 16 bit + + while(*t) + { + *t = (*t >> 8) | (*t << 8); + ++t; + } + } + } + + //! returns if a format is little endian + inline bool isLittleEndian(ETEXT_FORMAT f) + { + return f == ETF_ASCII || + f == ETF_UTF8 || + f == ETF_UTF16_LE || + f == ETF_UTF32_LE; + } + + + //! returns true if a character is whitespace + inline bool isWhiteSpace(char_type c) + { + return (c==' ' || c=='\t' || c=='\n' || c=='\r'); + } + + + //! generates a list with xml special characters + void createSpecialCharacterList() + { + // list of strings containing special symbols, + // the first character is the special character, + // the following is the symbol string without trailing &. + + SpecialCharacters.push_back("&"); + SpecialCharacters.push_back("gt;"); + SpecialCharacters.push_back("\"quot;"); + SpecialCharacters.push_back("'apos;"); + + } + + + //! compares the first n characters of the strings + bool equalsn(const char_type* str1, const char_type* str2, int len) + { + int i; + for(i=0; str1[i] && str2[i] && i < len; ++i) + if (str1[i] != str2[i]) + return false; + + // if one (or both) of the strings was smaller then they + // are only equal if they have the same lenght + return (i == len) || (str1[i] == 0 && str2[i] == 0); + } + + + //! stores the target text format + void storeTargetFormat() + { + // get target format. We could have done this using template specialization, + // but VisualStudio 6 don't like it and we want to support it. + + switch(sizeof(char_type)) + { + case 1: + TargetFormat = ETF_UTF8; + break; + case 2: + TargetFormat = ETF_UTF16_LE; + break; + case 4: + TargetFormat = ETF_UTF32_LE; + break; + default: + TargetFormat = ETF_ASCII; // should never happen. + } + } + + + // instance variables: + + char_type* TextData; // data block of the text file + char_type* P; // current point in text to parse + char_type* TextBegin; // start of text to parse + unsigned int TextSize; // size of text to parse in characters, not bytes + + EXML_NODE CurrentNodeType; // type of the currently parsed node + ETEXT_FORMAT SourceFormat; // source format of the xml file + ETEXT_FORMAT TargetFormat; // output format of this parser + + core::string NodeName; // name of the node currently in + core::string EmptyString; // empty string to be returned by getSafe() methods + + bool IsEmptyElement; // is the currently parsed node empty? + + core::array< core::string > SpecialCharacters; // see createSpecialCharacterList() + + core::array Attributes; // attributes of current element + +}; // end CXMLReaderImpl + + +} // end namespace +} // end namespace + +#endif diff --git a/src/dep/src/irrlicht/CXMLWriter.cpp b/src/dep/src/irrlicht/CXMLWriter.cpp index d4560a2..d16c58d 100644 --- a/src/dep/src/irrlicht/CXMLWriter.cpp +++ b/src/dep/src/irrlicht/CXMLWriter.cpp @@ -1,242 +1,242 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CXMLWriter.h" -#include -#include "irrString.h" -#include "IrrCompileConfig.h" - -namespace irr -{ -namespace io -{ - - -//! Constructor -CXMLWriter::CXMLWriter(IWriteFile* file) -: File(file), Tabs(0) -{ - if (File) - File->grab(); -} - - - -//! Destructor -CXMLWriter::~CXMLWriter() -{ - if (File) - File->drop(); -} - - - -//! Writes a xml 1.0 header like -void CXMLWriter::writeXMLHeader() -{ - if (!File) - return; - - if (sizeof(wchar_t)==2) - { - const u16 h = 0xFEFF; - File->write(&h, 2); - } - else - { - const u32 h = 0x0000FEFF; - File->write(&h, sizeof(wchar_t)); - } - - const wchar_t* const p = L""; - File->write(p, wcslen(p)*sizeof(wchar_t)); - - writeLineBreak(); -} - - - -//! Writes an xml element with maximal 5 attributes -void CXMLWriter::writeElement(const wchar_t* name, bool empty, - const wchar_t* attr1Name, const wchar_t* attr1Value, - const wchar_t* attr2Name, const wchar_t* attr2Value, - const wchar_t* attr3Name, const wchar_t* attr3Value, - const wchar_t* attr4Name, const wchar_t* attr4Value, - const wchar_t* attr5Name, const wchar_t* attr5Value) -{ - if (!File || !name) - return; - - if (Tabs > 0) - { - for (int i=0; iwrite(L"\t", sizeof(wchar_t)); - } - - // write name - - File->write(L"<", sizeof(wchar_t)); - File->write(name, wcslen(name)*sizeof(wchar_t)); - - // write attributes - - writeAttribute(attr1Name, attr1Value); - writeAttribute(attr2Name, attr2Value); - writeAttribute(attr3Name, attr3Value); - writeAttribute(attr4Name, attr4Value); - writeAttribute(attr5Name, attr5Value); - - // write closing tag - if (empty) - File->write(L" />", 3*sizeof(wchar_t)); - else - { - File->write(L">", sizeof(wchar_t)); - ++Tabs; - } -} - -//! Writes an xml element with any number of attributes -void CXMLWriter::writeElement(const wchar_t* name, bool empty, - core::array &names, - core::array &values) -{ - if (!File || !name) - return; - - if (Tabs > 0) - { - for (int i=0; iwrite(L"\t", sizeof(wchar_t)); - } - - // write name - - File->write(L"<", sizeof(wchar_t)); - File->write(name, wcslen(name)*sizeof(wchar_t)); - - // write attributes - u32 i=0; - for (; i < names.size() && i < values.size(); ++i) - writeAttribute(names[i].c_str(), values[i].c_str()); - - // write closing tag - if (empty) - File->write(L" />", 3*sizeof(wchar_t)); - else - { - File->write(L">", sizeof(wchar_t)); - ++Tabs; - } -} - - -void CXMLWriter::writeAttribute(const wchar_t* name, const wchar_t* value) -{ - if (!name || !value) - return; - - File->write(L" ", sizeof(wchar_t)); - File->write(name, wcslen(name)*sizeof(wchar_t)); - File->write(L"=\"", 2*sizeof(wchar_t)); - writeText(value); - File->write(L"\"", sizeof(wchar_t)); -} - - -//! Writes a comment into the xml file -void CXMLWriter::writeComment(const wchar_t* comment) -{ - if (!File || !comment) - return; - - File->write(L"", 3*sizeof(wchar_t)); -} - - -//! Writes the closing tag for an element. Like -void CXMLWriter::writeClosingTag(const wchar_t* name) -{ - if (!File || !name) - return; - - --Tabs; - - if (Tabs > 0) - { - for (int i=0; iwrite(L"\t", sizeof(wchar_t)); - } - - File->write(L"write(name, wcslen(name)*sizeof(wchar_t)); - File->write(L">", sizeof(wchar_t)); -} - - - -const CXMLWriter::XMLSpecialCharacters XMLWSChar[] = -{ - { L'&', L"&" }, - { L'<', L"<" }, - { L'>', L">" }, - { L'"', L""" }, - { L'\0', 0 } -}; - - -//! Writes a text into the file. All occurrences of special characters like -//! & (&), < (<), > (>), and " (") are automaticly replaced. -void CXMLWriter::writeText(const wchar_t* text) -{ - if (!File || !text) - return; - - core::stringw s; - const wchar_t* p = text; - - while(*p) - { - // check if it is matching - bool found = false; - for (s32 i=0; XMLWSChar[i].Character != '\0'; ++i) - if (*p == XMLWSChar[i].Character) - { - s.append(XMLWSChar[i].Symbol); - found = true; - break; - } - - if (!found) - s.append(*p); - ++p; - } - - // write new string - File->write(s.c_str(), s.size()*sizeof(wchar_t)); -} - - -//! Writes a line break -void CXMLWriter::writeLineBreak() -{ - if (!File) - return; - -#if defined(MACOSX) - File->write(L"\r", sizeof(wchar_t)); -#elif (defined(_IRR_WINDOWS_) || defined(_XBOX)) - File->write(L"\r\n", 2*sizeof(wchar_t)); -#else - File->write(L"\n", sizeof(wchar_t)); -#endif - -} - - -} // end namespace irr -} // end namespace io - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CXMLWriter.h" +#include +#include "irrString.h" +#include "IrrCompileConfig.h" + +namespace irr +{ +namespace io +{ + + +//! Constructor +CXMLWriter::CXMLWriter(IWriteFile* file) +: File(file), Tabs(0) +{ + if (File) + File->grab(); +} + + + +//! Destructor +CXMLWriter::~CXMLWriter() +{ + if (File) + File->drop(); +} + + + +//! Writes a xml 1.0 header like +void CXMLWriter::writeXMLHeader() +{ + if (!File) + return; + + if (sizeof(wchar_t)==2) + { + const u16 h = 0xFEFF; + File->write(&h, 2); + } + else + { + const u32 h = 0x0000FEFF; + File->write(&h, sizeof(wchar_t)); + } + + const wchar_t* const p = L""; + File->write(p, wcslen(p)*sizeof(wchar_t)); + + writeLineBreak(); +} + + + +//! Writes an xml element with maximal 5 attributes +void CXMLWriter::writeElement(const wchar_t* name, bool empty, + const wchar_t* attr1Name, const wchar_t* attr1Value, + const wchar_t* attr2Name, const wchar_t* attr2Value, + const wchar_t* attr3Name, const wchar_t* attr3Value, + const wchar_t* attr4Name, const wchar_t* attr4Value, + const wchar_t* attr5Name, const wchar_t* attr5Value) +{ + if (!File || !name) + return; + + if (Tabs > 0) + { + for (int i=0; iwrite(L"\t", sizeof(wchar_t)); + } + + // write name + + File->write(L"<", sizeof(wchar_t)); + File->write(name, wcslen(name)*sizeof(wchar_t)); + + // write attributes + + writeAttribute(attr1Name, attr1Value); + writeAttribute(attr2Name, attr2Value); + writeAttribute(attr3Name, attr3Value); + writeAttribute(attr4Name, attr4Value); + writeAttribute(attr5Name, attr5Value); + + // write closing tag + if (empty) + File->write(L" />", 3*sizeof(wchar_t)); + else + { + File->write(L">", sizeof(wchar_t)); + ++Tabs; + } +} + +//! Writes an xml element with any number of attributes +void CXMLWriter::writeElement(const wchar_t* name, bool empty, + core::array &names, + core::array &values) +{ + if (!File || !name) + return; + + if (Tabs > 0) + { + for (int i=0; iwrite(L"\t", sizeof(wchar_t)); + } + + // write name + + File->write(L"<", sizeof(wchar_t)); + File->write(name, wcslen(name)*sizeof(wchar_t)); + + // write attributes + u32 i=0; + for (; i < names.size() && i < values.size(); ++i) + writeAttribute(names[i].c_str(), values[i].c_str()); + + // write closing tag + if (empty) + File->write(L" />", 3*sizeof(wchar_t)); + else + { + File->write(L">", sizeof(wchar_t)); + ++Tabs; + } +} + + +void CXMLWriter::writeAttribute(const wchar_t* name, const wchar_t* value) +{ + if (!name || !value) + return; + + File->write(L" ", sizeof(wchar_t)); + File->write(name, wcslen(name)*sizeof(wchar_t)); + File->write(L"=\"", 2*sizeof(wchar_t)); + writeText(value); + File->write(L"\"", sizeof(wchar_t)); +} + + +//! Writes a comment into the xml file +void CXMLWriter::writeComment(const wchar_t* comment) +{ + if (!File || !comment) + return; + + File->write(L"", 3*sizeof(wchar_t)); +} + + +//! Writes the closing tag for an element. Like +void CXMLWriter::writeClosingTag(const wchar_t* name) +{ + if (!File || !name) + return; + + --Tabs; + + if (Tabs > 0) + { + for (int i=0; iwrite(L"\t", sizeof(wchar_t)); + } + + File->write(L"write(name, wcslen(name)*sizeof(wchar_t)); + File->write(L">", sizeof(wchar_t)); +} + + + +const CXMLWriter::XMLSpecialCharacters XMLWSChar[] = +{ + { L'&', L"&" }, + { L'<', L"<" }, + { L'>', L">" }, + { L'"', L""" }, + { L'\0', 0 } +}; + + +//! Writes a text into the file. All occurrences of special characters like +//! & (&), < (<), > (>), and " (") are automaticly replaced. +void CXMLWriter::writeText(const wchar_t* text) +{ + if (!File || !text) + return; + + core::stringw s; + const wchar_t* p = text; + + while(*p) + { + // check if it is matching + bool found = false; + for (s32 i=0; XMLWSChar[i].Character != '\0'; ++i) + if (*p == XMLWSChar[i].Character) + { + s.append(XMLWSChar[i].Symbol); + found = true; + break; + } + + if (!found) + s.append(*p); + ++p; + } + + // write new string + File->write(s.c_str(), s.size()*sizeof(wchar_t)); +} + + +//! Writes a line break +void CXMLWriter::writeLineBreak() +{ + if (!File) + return; + +#if defined(MACOSX) + File->write(L"\r", sizeof(wchar_t)); +#elif (defined(_IRR_WINDOWS_) || defined(_XBOX)) + File->write(L"\r\n", 2*sizeof(wchar_t)); +#else + File->write(L"\n", sizeof(wchar_t)); +#endif + +} + + +} // end namespace irr +} // end namespace io + diff --git a/src/dep/src/irrlicht/CXMLWriter.h b/src/dep/src/irrlicht/CXMLWriter.h index 04f1b26..ea0e963 100644 --- a/src/dep/src/irrlicht/CXMLWriter.h +++ b/src/dep/src/irrlicht/CXMLWriter.h @@ -1,74 +1,74 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_XML_WRITER_H_INCLUDED__ -#define __C_XML_WRITER_H_INCLUDED__ - -#include -#include "IXMLWriter.h" -#include "IWriteFile.h" - -namespace irr -{ -namespace io -{ - - //! Interface providing methods for making it easier to write XML files. - class CXMLWriter : public IXMLWriter - { - public: - - //! Constructor - CXMLWriter(IWriteFile* file); - - //! Destructor - virtual ~CXMLWriter(); - - //! Writes a xml 1.0 header like - virtual void writeXMLHeader(); - - //! Writes an xml element with maximal 5 attributes - virtual void writeElement(const wchar_t* name, bool empty=false, - const wchar_t* attr1Name = 0, const wchar_t* attr1Value = 0, - const wchar_t* attr2Name = 0, const wchar_t* attr2Value = 0, - const wchar_t* attr3Name = 0, const wchar_t* attr3Value = 0, - const wchar_t* attr4Name = 0, const wchar_t* attr4Value = 0, - const wchar_t* attr5Name = 0, const wchar_t* attr5Value = 0); - - //! Writes an xml element with any number of attributes - virtual void writeElement(const wchar_t* name, bool empty, - core::array &names, core::array &values); - - //! Writes a comment into the xml file - virtual void writeComment(const wchar_t* comment); - - //! Writes the closing tag for an element. Like
- virtual void writeClosingTag(const wchar_t* name); - - //! Writes a text into the file. All occurrences of special characters like - //! & (&), < (<), > (>), and " (") are automaticly replaced. - virtual void writeText(const wchar_t* text); - - //! Writes a line break - virtual void writeLineBreak(); - - struct XMLSpecialCharacters - { - wchar_t Character; - const wchar_t* Symbol; - }; - - private: - - void writeAttribute(const wchar_t* att, const wchar_t* name); - - IWriteFile* File; - s32 Tabs; - }; - -} // end namespace irr -} // end namespace io - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_XML_WRITER_H_INCLUDED__ +#define __C_XML_WRITER_H_INCLUDED__ + +#include +#include "IXMLWriter.h" +#include "IWriteFile.h" + +namespace irr +{ +namespace io +{ + + //! Interface providing methods for making it easier to write XML files. + class CXMLWriter : public IXMLWriter + { + public: + + //! Constructor + CXMLWriter(IWriteFile* file); + + //! Destructor + virtual ~CXMLWriter(); + + //! Writes a xml 1.0 header like + virtual void writeXMLHeader(); + + //! Writes an xml element with maximal 5 attributes + virtual void writeElement(const wchar_t* name, bool empty=false, + const wchar_t* attr1Name = 0, const wchar_t* attr1Value = 0, + const wchar_t* attr2Name = 0, const wchar_t* attr2Value = 0, + const wchar_t* attr3Name = 0, const wchar_t* attr3Value = 0, + const wchar_t* attr4Name = 0, const wchar_t* attr4Value = 0, + const wchar_t* attr5Name = 0, const wchar_t* attr5Value = 0); + + //! Writes an xml element with any number of attributes + virtual void writeElement(const wchar_t* name, bool empty, + core::array &names, core::array &values); + + //! Writes a comment into the xml file + virtual void writeComment(const wchar_t* comment); + + //! Writes the closing tag for an element. Like
+ virtual void writeClosingTag(const wchar_t* name); + + //! Writes a text into the file. All occurrences of special characters like + //! & (&), < (<), > (>), and " (") are automaticly replaced. + virtual void writeText(const wchar_t* text); + + //! Writes a line break + virtual void writeLineBreak(); + + struct XMLSpecialCharacters + { + wchar_t Character; + const wchar_t* Symbol; + }; + + private: + + void writeAttribute(const wchar_t* att, const wchar_t* name); + + IWriteFile* File; + s32 Tabs; + }; + +} // end namespace irr +} // end namespace io + +#endif + diff --git a/src/dep/src/irrlicht/CXMeshFileLoader.cpp b/src/dep/src/irrlicht/CXMeshFileLoader.cpp index 7b26310..335f714 100644 --- a/src/dep/src/irrlicht/CXMeshFileLoader.cpp +++ b/src/dep/src/irrlicht/CXMeshFileLoader.cpp @@ -1,81 +1,81 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CXMeshFileLoader.h" -#include "os.h" -#include "SMeshBuffer.h" -#include "SAnimatedMesh.h" -#include "CXFileReader.h" -#include "CXAnimationPlayer.h" -#include "IMeshManipulator.h" - -namespace irr -{ -namespace scene -{ - -//! Constructor -CXMeshFileLoader::CXMeshFileLoader(IMeshManipulator* manip, - video::IVideoDriver* driver) -: Manipulator(manip), Driver(driver) -{ - if (Manipulator) - Manipulator->grab(); - - if (Driver) - Driver->grab(); -} - - - -//! destructor -CXMeshFileLoader::~CXMeshFileLoader() -{ - if (Manipulator) - Manipulator->drop(); - - if (Driver) - Driver->drop(); -} - - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool CXMeshFileLoader::isALoadableFileExtension(const c8* filename) -{ - return strstr(filename, ".x")!=0; -} - - - -//! creates/loads an animated mesh from the file. -//! \return Pointer to the created mesh. Returns 0 if loading failed. -//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). -//! See IUnknown::drop() for more information. -IAnimatedMesh* CXMeshFileLoader::createMesh(io::IReadFile* file) -{ - if (!file) - return 0; - - IAnimatedMesh* mesh = 0; - CXFileReader *xreader = new CXFileReader(file); - - if (xreader->errorHappened()) - { - xreader->drop(); - return 0; - } - - mesh = new CXAnimationPlayer(xreader, Driver, Manipulator, - file->getFileName()); - - xreader->drop(); - return mesh; -} - - -} // end namespace scene -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CXMeshFileLoader.h" +#include "os.h" +#include "SMeshBuffer.h" +#include "SAnimatedMesh.h" +#include "CXFileReader.h" +#include "CXAnimationPlayer.h" +#include "IMeshManipulator.h" + +namespace irr +{ +namespace scene +{ + +//! Constructor +CXMeshFileLoader::CXMeshFileLoader(IMeshManipulator* manip, + video::IVideoDriver* driver) +: Manipulator(manip), Driver(driver) +{ + if (Manipulator) + Manipulator->grab(); + + if (Driver) + Driver->grab(); +} + + + +//! destructor +CXMeshFileLoader::~CXMeshFileLoader() +{ + if (Manipulator) + Manipulator->drop(); + + if (Driver) + Driver->drop(); +} + + + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".bsp") +bool CXMeshFileLoader::isALoadableFileExtension(const c8* filename) +{ + return strstr(filename, ".x")!=0; +} + + + +//! creates/loads an animated mesh from the file. +//! \return Pointer to the created mesh. Returns 0 if loading failed. +//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). +//! See IUnknown::drop() for more information. +IAnimatedMesh* CXMeshFileLoader::createMesh(io::IReadFile* file) +{ + if (!file) + return 0; + + IAnimatedMesh* mesh = 0; + CXFileReader *xreader = new CXFileReader(file); + + if (xreader->errorHappened()) + { + xreader->drop(); + return 0; + } + + mesh = new CXAnimationPlayer(xreader, Driver, Manipulator, + file->getFileName()); + + xreader->drop(); + return mesh; +} + + +} // end namespace scene +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CXMeshFileLoader.h b/src/dep/src/irrlicht/CXMeshFileLoader.h index 281bb61..3a0b32d 100644 --- a/src/dep/src/irrlicht/CXMeshFileLoader.h +++ b/src/dep/src/irrlicht/CXMeshFileLoader.h @@ -1,53 +1,53 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_X_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_X_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "irrString.h" -#include "SMesh.h" -#include "CXFileReader.h" -#include "SMeshBuffer.h" - -namespace irr -{ -namespace scene -{ -class IMeshManipulator; - -//! Meshloader capable of loading x meshes. -class CXMeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - CXMeshFileLoader(IMeshManipulator* manip, video::IVideoDriver* driver); - - //! destructor - virtual ~CXMeshFileLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".cob") - virtual bool isALoadableFileExtension(const c8* fileName); - - //! creates/loads an animated mesh from the file. - //! \return Pointer to the created mesh. Returns 0 if loading failed. - //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). - //! See IUnknown::drop() for more information. - virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); - -private: - - IMeshManipulator* Manipulator; - video::IVideoDriver* Driver; -}; - -} // end namespace scene -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_X_MESH_FILE_LOADER_H_INCLUDED__ +#define __C_X_MESH_FILE_LOADER_H_INCLUDED__ + +#include "IMeshLoader.h" +#include "IFileSystem.h" +#include "IVideoDriver.h" +#include "irrString.h" +#include "SMesh.h" +#include "CXFileReader.h" +#include "SMeshBuffer.h" + +namespace irr +{ +namespace scene +{ +class IMeshManipulator; + +//! Meshloader capable of loading x meshes. +class CXMeshFileLoader : public IMeshLoader +{ +public: + + //! Constructor + CXMeshFileLoader(IMeshManipulator* manip, video::IVideoDriver* driver); + + //! destructor + virtual ~CXMeshFileLoader(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".cob") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! creates/loads an animated mesh from the file. + //! \return Pointer to the created mesh. Returns 0 if loading failed. + //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). + //! See IUnknown::drop() for more information. + virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file); + +private: + + IMeshManipulator* Manipulator; + video::IVideoDriver* Driver; +}; + +} // end namespace scene +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CZBuffer.cpp b/src/dep/src/irrlicht/CZBuffer.cpp index 00a655c..ba64a97 100644 --- a/src/dep/src/irrlicht/CZBuffer.cpp +++ b/src/dep/src/irrlicht/CZBuffer.cpp @@ -1,112 +1,112 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "CZBuffer.h" -#include "irrString.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - - - -//! constructor -CZBuffer::CZBuffer(const core::dimension2d& size) -: Buffer(0), Size(0,0), TotalSize(0), BufferEnd(0) -{ - #ifdef _DEBUG - setDebugName("CZBuffer"); - #endif - - setSize(size); -} - - - -//! destructor -CZBuffer::~CZBuffer() -{ - if (Buffer) - delete [] Buffer; -} - - - -//! clears the zbuffer -void CZBuffer::clear() -{ - memset(Buffer, 0, (BufferEnd-Buffer)*sizeof(TZBufferType)); -} - - - -//! sets the new size of the zbuffer -void CZBuffer::setSize(const core::dimension2d& size) -{ - if (size == Size) - return; - - Size = size; - - if (Buffer) - delete [] Buffer; - - TotalSize = size.Width * size.Height; - Buffer = new TZBufferType[TotalSize]; - BufferEnd = Buffer + TotalSize; -} - - - -//! returns the size of the zbuffer -const core::dimension2d& CZBuffer::getSize() -{ - return Size; -} - - - -//! locks the zbuffer -TZBufferType* CZBuffer::lock() -{ - return Buffer; -} - - - -//! unlocks the zbuffer -void CZBuffer::unlock() -{ -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a ZBuffer -IZBuffer* createZBuffer(const core::dimension2d& size) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CZBuffer(size); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - - -} // end namespace video -} // end namespace irr - - - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#include "CZBuffer.h" +#include "irrString.h" + +#ifdef _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + + + +//! constructor +CZBuffer::CZBuffer(const core::dimension2d& size) +: Buffer(0), Size(0,0), TotalSize(0), BufferEnd(0) +{ + #ifdef _DEBUG + setDebugName("CZBuffer"); + #endif + + setSize(size); +} + + + +//! destructor +CZBuffer::~CZBuffer() +{ + if (Buffer) + delete [] Buffer; +} + + + +//! clears the zbuffer +void CZBuffer::clear() +{ + memset(Buffer, 0, (BufferEnd-Buffer)*sizeof(TZBufferType)); +} + + + +//! sets the new size of the zbuffer +void CZBuffer::setSize(const core::dimension2d& size) +{ + if (size == Size) + return; + + Size = size; + + if (Buffer) + delete [] Buffer; + + TotalSize = size.Width * size.Height; + Buffer = new TZBufferType[TotalSize]; + BufferEnd = Buffer + TotalSize; +} + + + +//! returns the size of the zbuffer +const core::dimension2d& CZBuffer::getSize() +{ + return Size; +} + + + +//! locks the zbuffer +TZBufferType* CZBuffer::lock() +{ + return Buffer; +} + + + +//! unlocks the zbuffer +void CZBuffer::unlock() +{ +} + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SOFTWARE_ + +namespace irr +{ +namespace video +{ + +//! creates a ZBuffer +IZBuffer* createZBuffer(const core::dimension2d& size) +{ + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + return new CZBuffer(size); + #else + return 0; + #endif // _IRR_COMPILE_WITH_SOFTWARE_ +} + + +} // end namespace video +} // end namespace irr + + + diff --git a/src/dep/src/irrlicht/CZBuffer.h b/src/dep/src/irrlicht/CZBuffer.h index 2240bcd..12ac8fb 100644 --- a/src/dep/src/irrlicht/CZBuffer.h +++ b/src/dep/src/irrlicht/CZBuffer.h @@ -1,52 +1,52 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_Z_BUFFER_H_INCLUDED__ -#define __C_Z_BUFFER_H_INCLUDED__ - -#include "IZBuffer.h" - -namespace irr -{ -namespace video -{ - - class CZBuffer : public IZBuffer - { - public: - - //! constructor - CZBuffer(const core::dimension2d& size); - - //! destructor - virtual ~CZBuffer(); - - //! clears the zbuffer - virtual void clear(); - - //! sets the new size of the zbuffer - virtual void setSize(const core::dimension2d& size); - - //! returns the size of the zbuffer - virtual const core::dimension2d& getSize(); - - //! locks the zbuffer - virtual TZBufferType* lock(); - - //! unlocks the zbuffer - virtual void unlock(); - - private: - - TZBufferType* Buffer; - TZBufferType* BufferEnd; - core::dimension2d Size; - s32 TotalSize; - }; - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_Z_BUFFER_H_INCLUDED__ +#define __C_Z_BUFFER_H_INCLUDED__ + +#include "IZBuffer.h" + +namespace irr +{ +namespace video +{ + + class CZBuffer : public IZBuffer + { + public: + + //! constructor + CZBuffer(const core::dimension2d& size); + + //! destructor + virtual ~CZBuffer(); + + //! clears the zbuffer + virtual void clear(); + + //! sets the new size of the zbuffer + virtual void setSize(const core::dimension2d& size); + + //! returns the size of the zbuffer + virtual const core::dimension2d& getSize(); + + //! locks the zbuffer + virtual TZBufferType* lock(); + + //! unlocks the zbuffer + virtual void unlock(); + + private: + + TZBufferType* Buffer; + TZBufferType* BufferEnd; + core::dimension2d Size; + s32 TotalSize; + }; + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/CZipReader.cpp b/src/dep/src/irrlicht/CZipReader.cpp index f34e149..4e7cdb6 100644 --- a/src/dep/src/irrlicht/CZipReader.cpp +++ b/src/dep/src/irrlicht/CZipReader.cpp @@ -1,500 +1,500 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CZipReader.h" -#include "CFileList.h" -#include "CReadFile.h" -#include "os.h" - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_ZLIB_ - #ifndef _IRR_USE_NON_SYSTEM_ZLIB_ - #include // use system lib - #else // _IRR_USE_NON_SYSTEM_ZLIB_ - #include "zlib/zlib.h" - #endif // _IRR_USE_NON_SYSTEM_ZLIB_ -#endif // _IRR_COMPILE_WITH_ZLIB_ - -namespace irr -{ -namespace io -{ - - -CZipReader::CZipReader(IReadFile* file, bool ignoreCase, bool ignorePaths) -: File(file), IgnoreCase(ignoreCase), IgnorePaths(ignorePaths) -{ - #ifdef _DEBUG - setDebugName("CZipReader"); - #endif - - if (File) - { - File->grab(); - - // scan local headers - while (scanLocalHeader()); - - // prepare file index for binary search - FileList.sort(); - } -} - -CZipReader::~CZipReader() -{ - if (File) - File->drop(); -} - - - -//! splits filename from zip file into useful filenames and paths -void CZipReader::extractFilename(SZipFileEntry* entry) -{ - s32 lorfn = entry->header.FilenameLength; // length of real file name - - if (!lorfn) - return; - - if (IgnoreCase) - entry->zipFileName.make_lower(); - - const c8* p = entry->zipFileName.c_str() + lorfn; - - // suche ein slash oder den anfang. - - while (*p!='/' && p!=entry->zipFileName.c_str()) - { - --p; - --lorfn; - } - - bool thereIsAPath = p != entry->zipFileName.c_str(); - - if (thereIsAPath) - { - // there is a path - ++p; - ++lorfn; - } - - entry->simpleFileName = p; - entry->path = ""; - - // pfad auch kopieren - if (thereIsAPath) - { - lorfn = (s32)(p - entry->zipFileName.c_str()); - - entry->path = entry->zipFileName.subString ( 0, lorfn ); - - //entry->path.append(entry->zipFileName, lorfn); - //entry->path.append ( "" ); - } - - if (!IgnorePaths) - entry->simpleFileName = entry->zipFileName; // thanks to Pr3t3nd3r for this fix -} - - - -//! scans for a local header, returns false if there is no more local file header. -bool CZipReader::scanLocalHeader() -{ - c8 tmp[1024]; - - SZipFileEntry entry; - entry.fileDataPosition = 0; - memset(&entry.header, 0, sizeof(SZIPFileHeader)); - - File->read(&entry.header, sizeof(SZIPFileHeader)); - -#ifdef __BIG_ENDIAN__ - entry.header.Sig = os::Byteswap::byteswap(entry.header.Sig); - entry.header.VersionToExtract = os::Byteswap::byteswap(entry.header.VersionToExtract); - entry.header.GeneralBitFlag = os::Byteswap::byteswap(entry.header.GeneralBitFlag); - entry.header.CompressionMethod = os::Byteswap::byteswap(entry.header.CompressionMethod); - entry.header.LastModFileTime = os::Byteswap::byteswap(entry.header.LastModFileTime); - entry.header.LastModFileDate = os::Byteswap::byteswap(entry.header.LastModFileDate); - entry.header.DataDescriptor.CRC32 = os::Byteswap::byteswap(entry.header.DataDescriptor.CRC32); - entry.header.DataDescriptor.CompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.CompressedSize); - entry.header.DataDescriptor.UncompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.UncompressedSize); - entry.header.FilenameLength = os::Byteswap::byteswap(entry.header.FilenameLength); - entry.header.ExtraFieldLength = os::Byteswap::byteswap(entry.header.ExtraFieldLength); -#endif - - if (entry.header.Sig != 0x04034b50) - return false; // local file headers end here. - - // read filename - entry.zipFileName.reserve(entry.header.FilenameLength+2); - File->read(tmp, entry.header.FilenameLength); - tmp[entry.header.FilenameLength] = 0x0; - entry.zipFileName = tmp; - - extractFilename(&entry); - - // move forward length of extra field. - - if (entry.header.ExtraFieldLength) - File->seek(entry.header.ExtraFieldLength, true); - - // if bit 3 was set, read DataDescriptor, following after the compressed data - if (entry.header.GeneralBitFlag & ZIP_INFO_IN_DATA_DESCRITOR) - { - // read data descriptor - File->read(&entry.header.DataDescriptor, sizeof(entry.header.DataDescriptor)); -#ifdef __BIG_ENDIAN__ - entry.header.DataDescriptor.CRC32 = os::Byteswap::byteswap(entry.header.DataDescriptor.CRC32); - entry.header.DataDescriptor.CompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.CompressedSize); - entry.header.DataDescriptor.UncompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.UncompressedSize); -#endif - } - - // store position in file - entry.fileDataPosition = File->getPos(); - - // move forward length of data - File->seek(entry.header.DataDescriptor.CompressedSize, true); - - #ifdef _DEBUG - //os::Debuginfo::print("added file from archive", entry.simpleFileName.c_str()); - #endif - - FileList.push_back(entry); - - return true; -} - - - -//! opens a file by file name -IReadFile* CZipReader::openFile(const c8* filename) -{ - s32 index = findFile(filename); - - if (index != -1) - return openFile(index); - - return 0; -} - - - -//! opens a file by index -IReadFile* CZipReader::openFile(s32 index) -{ - //0 - The file is stored (no compression) - //1 - The file is Shrunk - //2 - The file is Reduced with compression factor 1 - //3 - The file is Reduced with compression factor 2 - //4 - The file is Reduced with compression factor 3 - //5 - The file is Reduced with compression factor 4 - //6 - The file is Imploded - //7 - Reserved for Tokenizing compression algorithm - //8 - The file is Deflated - //9 - Reserved for enhanced Deflating - //10 - PKWARE Date Compression Library Imploding - - switch(FileList[index].header.CompressionMethod) - { - case 0: // no compression - { - File->seek(FileList[index].fileDataPosition); - return createLimitReadFile(FileList[index].simpleFileName.c_str(), File, FileList[index].header.DataDescriptor.UncompressedSize); - } - case 8: - { - #ifdef _IRR_COMPILE_WITH_ZLIB_ - - u32 uncompressedSize = FileList[index].header.DataDescriptor.UncompressedSize; - u32 compressedSize = FileList[index].header.DataDescriptor.CompressedSize; - - void* pBuf = new c8[ uncompressedSize ]; - if (!pBuf) - { - os::Printer::log("Not enough memory for decompressing", FileList[index].simpleFileName.c_str(), ELL_ERROR); - return 0; - } - - c8 *pcData = new c8[ compressedSize ]; - if (!pcData) - { - os::Printer::log("Not enough memory for decompressing", FileList[index].simpleFileName.c_str(), ELL_ERROR); - return 0; - } - - //memset(pcData, 0, compressedSize ); - File->seek(FileList[index].fileDataPosition); - File->read(pcData, compressedSize ); - - // Setup the inflate stream. - z_stream stream; - s32 err; - - stream.next_in = (Bytef*)pcData; - stream.avail_in = (uInt)compressedSize; - stream.next_out = (Bytef*)pBuf; - stream.avail_out = uncompressedSize; - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - - // Perform inflation. wbits < 0 indicates no zlib header inside the data. - err = inflateInit2(&stream, -MAX_WBITS); - if (err == Z_OK) - { - err = inflate(&stream, Z_FINISH); - inflateEnd(&stream); - if (err == Z_STREAM_END) - err = Z_OK; - - err = Z_OK; - inflateEnd(&stream); - } - - - delete[] pcData; - - if (err != Z_OK) - { - os::Printer::log("Error decompressing", FileList[index].simpleFileName.c_str(), ELL_ERROR); - delete [] (c8*)pBuf; - return 0; - } - else - return io::createMemoryReadFile ( pBuf, - uncompressedSize, - FileList[index].zipFileName.c_str(), - true - ); - - #else - return 0; // zlib not compiled, we cannot decompress the data. - #endif - } - default: - os::Printer::log("file has unsupported compression method.", FileList[index].simpleFileName.c_str(), ELL_ERROR); - return 0; - }; -} - - - -//! returns count of files in archive -s32 CZipReader::getFileCount() -{ - return FileList.size(); -} - - - -//! returns data of file -const SZipFileEntry* CZipReader::getFileInfo(s32 index) const -{ - return &FileList[index]; -} - - - -//! deletes the path from a filename -void CZipReader::deletePathFromFilename(core::stringc& filename) -{ - // delete path from filename - const c8* p = filename.c_str() + filename.size(); - - // suche ein slash oder den anfang. - - while (*p!='/' && *p!='\\' && p!=filename.c_str()) - --p; - - core::stringc newName; - - if (p != filename.c_str()) - { - ++p; - filename = p; - } -} - - - -//! returns fileindex -s32 CZipReader::findFile(const c8* simpleFilename) -{ - SZipFileEntry entry; - entry.simpleFileName = simpleFilename; - - if (IgnoreCase) - entry.simpleFileName.make_lower(); - - if (IgnorePaths) - deletePathFromFilename(entry.simpleFileName); - - s32 res = FileList.binary_search(entry); - - #ifdef _DEBUG - if (res == -1) - { - for (u32 i=0; iisOpen()) - return file; - - file->drop(); - return 0; - -} - -//! returns fileindex -s32 CUnZipReader::findFile(const c8* filename) -{ - IReadFile *file = openFile ( filename ); - if ( 0 == file ) - return -1; - file->drop (); - return 1; -} - -#else - -CUnZipReader::CUnZipReader( IFileSystem * parent, const c8* basename, bool ignoreCase, bool ignorePaths) -:CZipReader ( 0, ignoreCase, ignorePaths ), Parent ( parent ) -{ - strcpy ( Buf, Parent->getWorkingDirectory () ); - - Parent->changeWorkingDirectoryTo ( basename ); - buildDirectory ( ); - Parent->changeWorkingDirectoryTo ( Buf ); - - FileList.sort(); -} - -void CUnZipReader::buildDirectory ( ) -{ - s32 i; - s32 size; - const c8 * rel; - - IFileList * list; - list = new CFileList (); - - SZipFileEntry entry; - - size = list->getFileCount(); - for ( i = 0; i!= size; ++i ) - { - if ( false == list->isDirectory( i ) ) - { - entry.zipFileName = list->getFullFileName ( i ); - entry.header.FilenameLength = entry.zipFileName.size (); - extractFilename(&entry); - FileList.push_back(entry); - } - else - { - rel = list->getFileName ( i ); - - if ( strcmp ( rel, "." ) && - strcmp ( rel, ".." ) - ) - { - Parent->changeWorkingDirectoryTo ( rel ); - buildDirectory (); - Parent->changeWorkingDirectoryTo ( ".." ); - } - } - - } - - list->drop (); - -} - -//! opens a file by file name -IReadFile* CUnZipReader::openFile(const c8* filename) -{ - s32 index = -1; - - if ( IgnorePaths ) - { - index = findFile(filename); - } - else - if ( FileList.size () ) - { - core::stringc search = FileList[0].path + filename; - index = findFile( search.c_str() ); - } - - if (index == -1) - return 0; - - IReadFile *file; - file = createReadFile(FileList[index].zipFileName.c_str() ); - return file; -} -#endif - - -} // end namespace io -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CZipReader.h" +#include "CFileList.h" +#include "CReadFile.h" +#include "os.h" + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_ZLIB_ + #ifndef _IRR_USE_NON_SYSTEM_ZLIB_ + #include // use system lib + #else // _IRR_USE_NON_SYSTEM_ZLIB_ + #include "zlib/zlib.h" + #endif // _IRR_USE_NON_SYSTEM_ZLIB_ +#endif // _IRR_COMPILE_WITH_ZLIB_ + +namespace irr +{ +namespace io +{ + + +CZipReader::CZipReader(IReadFile* file, bool ignoreCase, bool ignorePaths) +: File(file), IgnoreCase(ignoreCase), IgnorePaths(ignorePaths) +{ + #ifdef _DEBUG + setDebugName("CZipReader"); + #endif + + if (File) + { + File->grab(); + + // scan local headers + while (scanLocalHeader()); + + // prepare file index for binary search + FileList.sort(); + } +} + +CZipReader::~CZipReader() +{ + if (File) + File->drop(); +} + + + +//! splits filename from zip file into useful filenames and paths +void CZipReader::extractFilename(SZipFileEntry* entry) +{ + s32 lorfn = entry->header.FilenameLength; // length of real file name + + if (!lorfn) + return; + + if (IgnoreCase) + entry->zipFileName.make_lower(); + + const c8* p = entry->zipFileName.c_str() + lorfn; + + // suche ein slash oder den anfang. + + while (*p!='/' && p!=entry->zipFileName.c_str()) + { + --p; + --lorfn; + } + + bool thereIsAPath = p != entry->zipFileName.c_str(); + + if (thereIsAPath) + { + // there is a path + ++p; + ++lorfn; + } + + entry->simpleFileName = p; + entry->path = ""; + + // pfad auch kopieren + if (thereIsAPath) + { + lorfn = (s32)(p - entry->zipFileName.c_str()); + + entry->path = entry->zipFileName.subString ( 0, lorfn ); + + //entry->path.append(entry->zipFileName, lorfn); + //entry->path.append ( "" ); + } + + if (!IgnorePaths) + entry->simpleFileName = entry->zipFileName; // thanks to Pr3t3nd3r for this fix +} + + + +//! scans for a local header, returns false if there is no more local file header. +bool CZipReader::scanLocalHeader() +{ + c8 tmp[1024]; + + SZipFileEntry entry; + entry.fileDataPosition = 0; + memset(&entry.header, 0, sizeof(SZIPFileHeader)); + + File->read(&entry.header, sizeof(SZIPFileHeader)); + +#ifdef __BIG_ENDIAN__ + entry.header.Sig = os::Byteswap::byteswap(entry.header.Sig); + entry.header.VersionToExtract = os::Byteswap::byteswap(entry.header.VersionToExtract); + entry.header.GeneralBitFlag = os::Byteswap::byteswap(entry.header.GeneralBitFlag); + entry.header.CompressionMethod = os::Byteswap::byteswap(entry.header.CompressionMethod); + entry.header.LastModFileTime = os::Byteswap::byteswap(entry.header.LastModFileTime); + entry.header.LastModFileDate = os::Byteswap::byteswap(entry.header.LastModFileDate); + entry.header.DataDescriptor.CRC32 = os::Byteswap::byteswap(entry.header.DataDescriptor.CRC32); + entry.header.DataDescriptor.CompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.CompressedSize); + entry.header.DataDescriptor.UncompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.UncompressedSize); + entry.header.FilenameLength = os::Byteswap::byteswap(entry.header.FilenameLength); + entry.header.ExtraFieldLength = os::Byteswap::byteswap(entry.header.ExtraFieldLength); +#endif + + if (entry.header.Sig != 0x04034b50) + return false; // local file headers end here. + + // read filename + entry.zipFileName.reserve(entry.header.FilenameLength+2); + File->read(tmp, entry.header.FilenameLength); + tmp[entry.header.FilenameLength] = 0x0; + entry.zipFileName = tmp; + + extractFilename(&entry); + + // move forward length of extra field. + + if (entry.header.ExtraFieldLength) + File->seek(entry.header.ExtraFieldLength, true); + + // if bit 3 was set, read DataDescriptor, following after the compressed data + if (entry.header.GeneralBitFlag & ZIP_INFO_IN_DATA_DESCRITOR) + { + // read data descriptor + File->read(&entry.header.DataDescriptor, sizeof(entry.header.DataDescriptor)); +#ifdef __BIG_ENDIAN__ + entry.header.DataDescriptor.CRC32 = os::Byteswap::byteswap(entry.header.DataDescriptor.CRC32); + entry.header.DataDescriptor.CompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.CompressedSize); + entry.header.DataDescriptor.UncompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.UncompressedSize); +#endif + } + + // store position in file + entry.fileDataPosition = File->getPos(); + + // move forward length of data + File->seek(entry.header.DataDescriptor.CompressedSize, true); + + #ifdef _DEBUG + //os::Debuginfo::print("added file from archive", entry.simpleFileName.c_str()); + #endif + + FileList.push_back(entry); + + return true; +} + + + +//! opens a file by file name +IReadFile* CZipReader::openFile(const c8* filename) +{ + s32 index = findFile(filename); + + if (index != -1) + return openFile(index); + + return 0; +} + + + +//! opens a file by index +IReadFile* CZipReader::openFile(s32 index) +{ + //0 - The file is stored (no compression) + //1 - The file is Shrunk + //2 - The file is Reduced with compression factor 1 + //3 - The file is Reduced with compression factor 2 + //4 - The file is Reduced with compression factor 3 + //5 - The file is Reduced with compression factor 4 + //6 - The file is Imploded + //7 - Reserved for Tokenizing compression algorithm + //8 - The file is Deflated + //9 - Reserved for enhanced Deflating + //10 - PKWARE Date Compression Library Imploding + + switch(FileList[index].header.CompressionMethod) + { + case 0: // no compression + { + File->seek(FileList[index].fileDataPosition); + return createLimitReadFile(FileList[index].simpleFileName.c_str(), File, FileList[index].header.DataDescriptor.UncompressedSize); + } + case 8: + { + #ifdef _IRR_COMPILE_WITH_ZLIB_ + + u32 uncompressedSize = FileList[index].header.DataDescriptor.UncompressedSize; + u32 compressedSize = FileList[index].header.DataDescriptor.CompressedSize; + + void* pBuf = new c8[ uncompressedSize ]; + if (!pBuf) + { + os::Printer::log("Not enough memory for decompressing", FileList[index].simpleFileName.c_str(), ELL_ERROR); + return 0; + } + + c8 *pcData = new c8[ compressedSize ]; + if (!pcData) + { + os::Printer::log("Not enough memory for decompressing", FileList[index].simpleFileName.c_str(), ELL_ERROR); + return 0; + } + + //memset(pcData, 0, compressedSize ); + File->seek(FileList[index].fileDataPosition); + File->read(pcData, compressedSize ); + + // Setup the inflate stream. + z_stream stream; + s32 err; + + stream.next_in = (Bytef*)pcData; + stream.avail_in = (uInt)compressedSize; + stream.next_out = (Bytef*)pBuf; + stream.avail_out = uncompressedSize; + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + + // Perform inflation. wbits < 0 indicates no zlib header inside the data. + err = inflateInit2(&stream, -MAX_WBITS); + if (err == Z_OK) + { + err = inflate(&stream, Z_FINISH); + inflateEnd(&stream); + if (err == Z_STREAM_END) + err = Z_OK; + + err = Z_OK; + inflateEnd(&stream); + } + + + delete[] pcData; + + if (err != Z_OK) + { + os::Printer::log("Error decompressing", FileList[index].simpleFileName.c_str(), ELL_ERROR); + delete [] (c8*)pBuf; + return 0; + } + else + return io::createMemoryReadFile ( pBuf, + uncompressedSize, + FileList[index].zipFileName.c_str(), + true + ); + + #else + return 0; // zlib not compiled, we cannot decompress the data. + #endif + } + default: + os::Printer::log("file has unsupported compression method.", FileList[index].simpleFileName.c_str(), ELL_ERROR); + return 0; + }; +} + + + +//! returns count of files in archive +s32 CZipReader::getFileCount() +{ + return FileList.size(); +} + + + +//! returns data of file +const SZipFileEntry* CZipReader::getFileInfo(s32 index) const +{ + return &FileList[index]; +} + + + +//! deletes the path from a filename +void CZipReader::deletePathFromFilename(core::stringc& filename) +{ + // delete path from filename + const c8* p = filename.c_str() + filename.size(); + + // suche ein slash oder den anfang. + + while (*p!='/' && *p!='\\' && p!=filename.c_str()) + --p; + + core::stringc newName; + + if (p != filename.c_str()) + { + ++p; + filename = p; + } +} + + + +//! returns fileindex +s32 CZipReader::findFile(const c8* simpleFilename) +{ + SZipFileEntry entry; + entry.simpleFileName = simpleFilename; + + if (IgnoreCase) + entry.simpleFileName.make_lower(); + + if (IgnorePaths) + deletePathFromFilename(entry.simpleFileName); + + s32 res = FileList.binary_search(entry); + + #ifdef _DEBUG + if (res == -1) + { + for (u32 i=0; iisOpen()) + return file; + + file->drop(); + return 0; + +} + +//! returns fileindex +s32 CUnZipReader::findFile(const c8* filename) +{ + IReadFile *file = openFile ( filename ); + if ( 0 == file ) + return -1; + file->drop (); + return 1; +} + +#else + +CUnZipReader::CUnZipReader( IFileSystem * parent, const c8* basename, bool ignoreCase, bool ignorePaths) +:CZipReader ( 0, ignoreCase, ignorePaths ), Parent ( parent ) +{ + strcpy ( Buf, Parent->getWorkingDirectory () ); + + Parent->changeWorkingDirectoryTo ( basename ); + buildDirectory ( ); + Parent->changeWorkingDirectoryTo ( Buf ); + + FileList.sort(); +} + +void CUnZipReader::buildDirectory ( ) +{ + s32 i; + s32 size; + const c8 * rel; + + IFileList * list; + list = new CFileList (); + + SZipFileEntry entry; + + size = list->getFileCount(); + for ( i = 0; i!= size; ++i ) + { + if ( false == list->isDirectory( i ) ) + { + entry.zipFileName = list->getFullFileName ( i ); + entry.header.FilenameLength = entry.zipFileName.size (); + extractFilename(&entry); + FileList.push_back(entry); + } + else + { + rel = list->getFileName ( i ); + + if ( strcmp ( rel, "." ) && + strcmp ( rel, ".." ) + ) + { + Parent->changeWorkingDirectoryTo ( rel ); + buildDirectory (); + Parent->changeWorkingDirectoryTo ( ".." ); + } + } + + } + + list->drop (); + +} + +//! opens a file by file name +IReadFile* CUnZipReader::openFile(const c8* filename) +{ + s32 index = -1; + + if ( IgnorePaths ) + { + index = findFile(filename); + } + else + if ( FileList.size () ) + { + core::stringc search = FileList[0].path + filename; + index = findFile( search.c_str() ); + } + + if (index == -1) + return 0; + + IReadFile *file; + file = createReadFile(FileList[index].zipFileName.c_str() ); + return file; +} +#endif + + +} // end namespace io +} // end namespace irr + diff --git a/src/dep/src/irrlicht/CZipReader.h b/src/dep/src/irrlicht/CZipReader.h index 82773cf..3329d52 100644 --- a/src/dep/src/irrlicht/CZipReader.h +++ b/src/dep/src/irrlicht/CZipReader.h @@ -1,157 +1,157 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_ZIP_READER_H_INCLUDED__ -#define __C_ZIP_READER_H_INCLUDED__ - -#include "IUnknown.h" -#include "IReadFile.h" -#include "irrArray.h" -#include "irrString.h" -#include "IFileSystem.h" - -namespace irr -{ -namespace io -{ - - const s16 ZIP_FILE_ENCRYPTED = 0x0001; // set if the file is encrypted - const s16 ZIP_INFO_IN_DATA_DESCRITOR = 0x0008; // the fields crc-32, compressed size - // and uncompressed size are set to zero in the local - // header - -#ifdef _MSC_VER -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - - struct SZIPFileDataDescriptor - { - s32 CRC32; - s32 CompressedSize; - s32 UncompressedSize; - } PACK_STRUCT; - - struct SZIPFileHeader - { - s32 Sig; - s16 VersionToExtract; - s16 GeneralBitFlag; - s16 CompressionMethod; - s16 LastModFileTime; - s16 LastModFileDate; - SZIPFileDataDescriptor DataDescriptor; - s16 FilenameLength; - s16 ExtraFieldLength; - } PACK_STRUCT; - -// Default alignment -#ifdef _MSC_VER -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - - - struct SZipFileEntry - { - core::stringc zipFileName; - core::stringc simpleFileName; - core::stringc path; - s32 fileDataPosition; // position of compressed data in file - SZIPFileHeader header; - - bool operator < (const SZipFileEntry& other) const - { - return simpleFileName < other.simpleFileName; - } - - - bool operator == (const SZipFileEntry& other) const - { - return simpleFileName == other.simpleFileName; - } - }; - - - -/*! - Zip file Reader written April 2002 by N.Gebhardt. - Doesn't decompress data, only reads the file and is able to - open uncompressed entries. -*/ - class CZipReader : public virtual IUnknown - { - public: - - CZipReader(IReadFile* file, bool ignoreCase, bool ignorePaths); - virtual ~CZipReader(); - - //! opens a file by file name - virtual IReadFile* openFile(const c8* filename); - - //! opens a file by index - IReadFile* openFile(s32 index); - - //! returns count of files in archive - s32 getFileCount(); - - //! returns data of file - const SZipFileEntry* getFileInfo(s32 index) const; - - //! returns fileindex - s32 findFile(const c8* filename); - - private: - - //! scans for a local header, returns false if there is no more local file header. - bool scanLocalHeader(); - IReadFile* File; - - protected: - - //! splits filename from zip file into useful filenames and paths - void extractFilename(SZipFileEntry* entry); - - //! deletes the path from a filename - void deletePathFromFilename(core::stringc& filename); - - - bool IgnoreCase; - bool IgnorePaths; - core::array FileList; - }; - - - class CUnZipReader : public CZipReader - { - public: - - CUnZipReader( IFileSystem *parent, const c8* basename, bool ignoreCase, bool ignorePaths); - - //! opens a file by file name - virtual IReadFile* openFile(const c8* filename); - - //! returns fileindex - s32 findFile(const c8* filename); - - private: - - IFileSystem *Parent; - void buildDirectory (); - - core::stringc Base; - }; - -} // end namespace io -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_ZIP_READER_H_INCLUDED__ +#define __C_ZIP_READER_H_INCLUDED__ + +#include "IUnknown.h" +#include "IReadFile.h" +#include "irrArray.h" +#include "irrString.h" +#include "IFileSystem.h" + +namespace irr +{ +namespace io +{ + + const s16 ZIP_FILE_ENCRYPTED = 0x0001; // set if the file is encrypted + const s16 ZIP_INFO_IN_DATA_DESCRITOR = 0x0008; // the fields crc-32, compressed size + // and uncompressed size are set to zero in the local + // header + +#ifdef _MSC_VER +# pragma pack( push, packing ) +# pragma pack( 1 ) +# define PACK_STRUCT +#elif defined( __GNUC__ ) +# define PACK_STRUCT __attribute__((packed)) +#else +# error compiler not supported +#endif + + + struct SZIPFileDataDescriptor + { + s32 CRC32; + s32 CompressedSize; + s32 UncompressedSize; + } PACK_STRUCT; + + struct SZIPFileHeader + { + s32 Sig; + s16 VersionToExtract; + s16 GeneralBitFlag; + s16 CompressionMethod; + s16 LastModFileTime; + s16 LastModFileDate; + SZIPFileDataDescriptor DataDescriptor; + s16 FilenameLength; + s16 ExtraFieldLength; + } PACK_STRUCT; + +// Default alignment +#ifdef _MSC_VER +# pragma pack( pop, packing ) +#endif + +#undef PACK_STRUCT + + + struct SZipFileEntry + { + core::stringc zipFileName; + core::stringc simpleFileName; + core::stringc path; + s32 fileDataPosition; // position of compressed data in file + SZIPFileHeader header; + + bool operator < (const SZipFileEntry& other) const + { + return simpleFileName < other.simpleFileName; + } + + + bool operator == (const SZipFileEntry& other) const + { + return simpleFileName == other.simpleFileName; + } + }; + + + +/*! + Zip file Reader written April 2002 by N.Gebhardt. + Doesn't decompress data, only reads the file and is able to + open uncompressed entries. +*/ + class CZipReader : public virtual IUnknown + { + public: + + CZipReader(IReadFile* file, bool ignoreCase, bool ignorePaths); + virtual ~CZipReader(); + + //! opens a file by file name + virtual IReadFile* openFile(const c8* filename); + + //! opens a file by index + IReadFile* openFile(s32 index); + + //! returns count of files in archive + s32 getFileCount(); + + //! returns data of file + const SZipFileEntry* getFileInfo(s32 index) const; + + //! returns fileindex + s32 findFile(const c8* filename); + + private: + + //! scans for a local header, returns false if there is no more local file header. + bool scanLocalHeader(); + IReadFile* File; + + protected: + + //! splits filename from zip file into useful filenames and paths + void extractFilename(SZipFileEntry* entry); + + //! deletes the path from a filename + void deletePathFromFilename(core::stringc& filename); + + + bool IgnoreCase; + bool IgnorePaths; + core::array FileList; + }; + + + class CUnZipReader : public CZipReader + { + public: + + CUnZipReader( IFileSystem *parent, const c8* basename, bool ignoreCase, bool ignorePaths); + + //! opens a file by file name + virtual IReadFile* openFile(const c8* filename); + + //! returns fileindex + s32 findFile(const c8* filename); + + private: + + IFileSystem *Parent; + void buildDirectory (); + + core::stringc Base; + }; + +} // end namespace io +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/IBurningShader.cpp b/src/dep/src/irrlicht/IBurningShader.cpp index c96ff9e..a885e75 100644 --- a/src/dep/src/irrlicht/IBurningShader.cpp +++ b/src/dep/src/irrlicht/IBurningShader.cpp @@ -1,105 +1,105 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -#include "SoftwareDriver2_compile_config.h" -#include "IBurningShader.h" - -namespace irr -{ - -namespace video -{ - - const tFixPointu IBurningShader::dithermask[ 4 * 4] = - { - 0x00,0x80,0x20,0xa0, - 0xc0,0x40,0xe0,0x60, - 0x30,0xb0,0x10,0x90, - 0xf0,0x70,0xd0,0x50 - }; - - IBurningShader::IBurningShader(IDepthBuffer* zbuffer) - :RenderTarget(0),ZBuffer(zbuffer) - { - IT[0].Texture = 0; - IT[1].Texture = 0; - - #ifdef _DEBUG - setDebugName("CTRTextureLightMap2_M1"); - #endif - - if (ZBuffer) - zbuffer->grab(); - } - - - //! destructor - IBurningShader::~IBurningShader() - { - if (RenderTarget) - RenderTarget->drop(); - - if (ZBuffer) - ZBuffer->drop(); - - if ( IT[0].Texture ) - IT[0].Texture->drop(); - - if ( IT[1].Texture ) - IT[1].Texture->drop(); - } - - //! sets a render target - void IBurningShader::setRenderTarget(video::IImage* surface, const core::rect& viewPort) - { - if (RenderTarget) - RenderTarget->drop(); - - RenderTarget = surface; - - if (RenderTarget) - { - SurfaceWidth = RenderTarget->getDimension().Width; - RenderTarget->grab(); - } - } - - - //! sets the Texture - void IBurningShader::setTexture( u32 stage, video::CSoftwareTexture2* texture, s32 lodLevel) - { - sInternalTexture *it = &IT[stage]; - - if ( it->Texture) - it->Texture->drop(); - - it->Texture = texture; - - if ( it->Texture) - { - it->Texture->grab(); - - // select mignify and magnify ( lodLevel ) - //SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS - it->lodLevel = lodLevel; - it->Texture->setCurrentMipMapLOD ( - core::s32_clamp ( lodLevel + SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS, 0, SOFTWARE_DRIVER_2_MIPMAPPING_MAX - 1 ) - ); - - // prepare for optimal fixpoint - it->pitchlog2 = s32_log2_s32 ( it->Texture->getPitch() ); - - it->textureXMask = s32_to_fixPoint ( it->Texture->getSize().Width - 1 ) & FIX_POINT_UNSIGNED_MASK; - it->textureYMask = s32_to_fixPoint ( it->Texture->getSize().Height - 1 ) & FIX_POINT_UNSIGNED_MASK; - } - } - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + +#include "SoftwareDriver2_compile_config.h" +#include "IBurningShader.h" + +namespace irr +{ + +namespace video +{ + + const tFixPointu IBurningShader::dithermask[ 4 * 4] = + { + 0x00,0x80,0x20,0xa0, + 0xc0,0x40,0xe0,0x60, + 0x30,0xb0,0x10,0x90, + 0xf0,0x70,0xd0,0x50 + }; + + IBurningShader::IBurningShader(IDepthBuffer* zbuffer) + :RenderTarget(0),ZBuffer(zbuffer) + { + IT[0].Texture = 0; + IT[1].Texture = 0; + + #ifdef _DEBUG + setDebugName("CTRTextureLightMap2_M1"); + #endif + + if (ZBuffer) + zbuffer->grab(); + } + + + //! destructor + IBurningShader::~IBurningShader() + { + if (RenderTarget) + RenderTarget->drop(); + + if (ZBuffer) + ZBuffer->drop(); + + if ( IT[0].Texture ) + IT[0].Texture->drop(); + + if ( IT[1].Texture ) + IT[1].Texture->drop(); + } + + //! sets a render target + void IBurningShader::setRenderTarget(video::IImage* surface, const core::rect& viewPort) + { + if (RenderTarget) + RenderTarget->drop(); + + RenderTarget = surface; + + if (RenderTarget) + { + SurfaceWidth = RenderTarget->getDimension().Width; + RenderTarget->grab(); + } + } + + + //! sets the Texture + void IBurningShader::setTexture( u32 stage, video::CSoftwareTexture2* texture, s32 lodLevel) + { + sInternalTexture *it = &IT[stage]; + + if ( it->Texture) + it->Texture->drop(); + + it->Texture = texture; + + if ( it->Texture) + { + it->Texture->grab(); + + // select mignify and magnify ( lodLevel ) + //SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS + it->lodLevel = lodLevel; + it->Texture->setCurrentMipMapLOD ( + core::s32_clamp ( lodLevel + SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS, 0, SOFTWARE_DRIVER_2_MIPMAPPING_MAX - 1 ) + ); + + // prepare for optimal fixpoint + it->pitchlog2 = s32_log2_s32 ( it->Texture->getPitch() ); + + it->textureXMask = s32_to_fixPoint ( it->Texture->getSize().Width - 1 ) & FIX_POINT_UNSIGNED_MASK; + it->textureYMask = s32_to_fixPoint ( it->Texture->getSize().Height - 1 ) & FIX_POINT_UNSIGNED_MASK; + } + } + + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ diff --git a/src/dep/src/irrlicht/IBurningShader.h b/src/dep/src/irrlicht/IBurningShader.h index 14149b7..014e599 100644 --- a/src/dep/src/irrlicht/IBurningShader.h +++ b/src/dep/src/irrlicht/IBurningShader.h @@ -1,129 +1,129 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_BURNING_SHADER_H_INCLUDED__ -#define __I_BURNING_SHADER_H_INCLUDED__ - -#include "SoftwareDriver2_compile_config.h" -#include "IUnknown.h" -#include "irrMath.h" -#include "IImage.h" -#include "S2DVertex.h" -#include "rect.h" -#include "IDepthBuffer.h" -#include "S4DVertex.h" - - -namespace irr -{ - -namespace video -{ - - enum EBurningFFShader - { - ETR_FLAT = 0, - ETR_FLAT_WIRE, - ETR_GOURAUD, - ETR_GOURAUD_WIRE, - ETR_TEXTURE_FLAT, - ETR_TEXTURE_FLAT_WIRE, - ETR_TEXTURE_GOURAUD, - ETR_TEXTURE_GOURAUD_WIRE, - ETR_TEXTURE_GOURAUD_NOZ, - ETR_TEXTURE_GOURAUD_ADD, - ETR_TEXTURE_GOURAUD_ADD_NO_Z, - - ETR_TEXTURE_GOURAUD_VERTEX_ALPHA, - - ETR_TEXTURE_GOURAUD_LIGHTMAP, - ETR_TEXTURE_GOURAUD_LIGHTMAP_M2, - ETR_TEXTURE_LIGHTMAP_M4, - ETR_TEXTURE_GOURAUD_LIGHTMAP_M4, - - ETR_TEXTURE_GOURAUD_LIGHTMAP_ADD, - - ETR_TEXTURE_GOURAUD_DETAIL_MAP, - - ETR_GOURAUD_ALPHA, - ETR_GOURAUD_ALPHA_NOZ, - - ETR_TEXTURE_GOURAUD_ALPHA, - ETR_TEXTURE_GOURAUD_ALPHA_NOZ, - - ETR_TEXTURE_BLEND, - ETR_INVALID, - - ETR2_COUNT - }; - - class IBurningShader : public virtual IUnknown - { - public: - IBurningShader(IDepthBuffer* zbuffer); - - //! destructor - virtual ~IBurningShader(); - - //! sets a render target - virtual void setRenderTarget(video::IImage* surface, const core::rect& viewPort); - - //! sets the Texture - virtual void setTexture( u32 stage, video::CSoftwareTexture2* texture, s32 lodLevel); - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) = 0; - virtual void drawLine ( const s4DVertex *a,const s4DVertex *b) {}; - - virtual void setParam ( u32 index, f32 value) {}; - virtual void setZCompareFunc ( u32 func) {}; - - protected: - - video::IImage* RenderTarget; - - IDepthBuffer* ZBuffer; - - s32 SurfaceWidth; - fp24* lockedZBuffer; - tVideoSample* lockedSurface; - - sInternalTexture IT[2]; - - static const tFixPointu dithermask[ 4 * 4]; - }; - - - IBurningShader* createTriangleRendererTextureGouraud2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureLightMap2_M1(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureLightMap2_M2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureLightMap2_M4(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererGTextureLightMap2_M4(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureLightMap2_Add(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureDetailMap2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureVertexAlpha2(IDepthBuffer* zbuffer); - - - IBurningShader* createTriangleRendererTextureGouraudWire2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererGouraud2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererGouraudAlpha2(IDepthBuffer* zbuffer); - IBurningShader* createTRGouraudAlphaNoZ2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererGouraudWire2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureFlat2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureFlatWire2(IDepthBuffer* zbuffer); - IBurningShader* createTRFlat2(IDepthBuffer* zbuffer); - IBurningShader* createTRFlatWire2(IDepthBuffer* zbuffer); - IBurningShader* createTRTextureGouraudNoZ2(); - IBurningShader* createTRTextureGouraudAdd2(IDepthBuffer* zbuffer); - IBurningShader* createTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer); - - IBurningShader* createTRTextureGouraudAlpha(IDepthBuffer* zbuffer); - IBurningShader* createTRTextureGouraudAlphaNoZ(IDepthBuffer* zbuffer); - IBurningShader* createTRTextureBlend(IDepthBuffer* zbuffer); - IBurningShader* createTRTextureInverseAlphaBlend(IDepthBuffer* zbuffer); - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_BURNING_SHADER_H_INCLUDED__ +#define __I_BURNING_SHADER_H_INCLUDED__ + +#include "SoftwareDriver2_compile_config.h" +#include "IUnknown.h" +#include "irrMath.h" +#include "IImage.h" +#include "S2DVertex.h" +#include "rect.h" +#include "IDepthBuffer.h" +#include "S4DVertex.h" + + +namespace irr +{ + +namespace video +{ + + enum EBurningFFShader + { + ETR_FLAT = 0, + ETR_FLAT_WIRE, + ETR_GOURAUD, + ETR_GOURAUD_WIRE, + ETR_TEXTURE_FLAT, + ETR_TEXTURE_FLAT_WIRE, + ETR_TEXTURE_GOURAUD, + ETR_TEXTURE_GOURAUD_WIRE, + ETR_TEXTURE_GOURAUD_NOZ, + ETR_TEXTURE_GOURAUD_ADD, + ETR_TEXTURE_GOURAUD_ADD_NO_Z, + + ETR_TEXTURE_GOURAUD_VERTEX_ALPHA, + + ETR_TEXTURE_GOURAUD_LIGHTMAP, + ETR_TEXTURE_GOURAUD_LIGHTMAP_M2, + ETR_TEXTURE_LIGHTMAP_M4, + ETR_TEXTURE_GOURAUD_LIGHTMAP_M4, + + ETR_TEXTURE_GOURAUD_LIGHTMAP_ADD, + + ETR_TEXTURE_GOURAUD_DETAIL_MAP, + + ETR_GOURAUD_ALPHA, + ETR_GOURAUD_ALPHA_NOZ, + + ETR_TEXTURE_GOURAUD_ALPHA, + ETR_TEXTURE_GOURAUD_ALPHA_NOZ, + + ETR_TEXTURE_BLEND, + ETR_INVALID, + + ETR2_COUNT + }; + + class IBurningShader : public virtual IUnknown + { + public: + IBurningShader(IDepthBuffer* zbuffer); + + //! destructor + virtual ~IBurningShader(); + + //! sets a render target + virtual void setRenderTarget(video::IImage* surface, const core::rect& viewPort); + + //! sets the Texture + virtual void setTexture( u32 stage, video::CSoftwareTexture2* texture, s32 lodLevel); + virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) = 0; + virtual void drawLine ( const s4DVertex *a,const s4DVertex *b) {}; + + virtual void setParam ( u32 index, f32 value) {}; + virtual void setZCompareFunc ( u32 func) {}; + + protected: + + video::IImage* RenderTarget; + + IDepthBuffer* ZBuffer; + + s32 SurfaceWidth; + fp24* lockedZBuffer; + tVideoSample* lockedSurface; + + sInternalTexture IT[2]; + + static const tFixPointu dithermask[ 4 * 4]; + }; + + + IBurningShader* createTriangleRendererTextureGouraud2(IDepthBuffer* zbuffer); + IBurningShader* createTriangleRendererTextureLightMap2_M1(IDepthBuffer* zbuffer); + IBurningShader* createTriangleRendererTextureLightMap2_M2(IDepthBuffer* zbuffer); + IBurningShader* createTriangleRendererTextureLightMap2_M4(IDepthBuffer* zbuffer); + IBurningShader* createTriangleRendererGTextureLightMap2_M4(IDepthBuffer* zbuffer); + IBurningShader* createTriangleRendererTextureLightMap2_Add(IDepthBuffer* zbuffer); + IBurningShader* createTriangleRendererTextureDetailMap2(IDepthBuffer* zbuffer); + IBurningShader* createTriangleRendererTextureVertexAlpha2(IDepthBuffer* zbuffer); + + + IBurningShader* createTriangleRendererTextureGouraudWire2(IDepthBuffer* zbuffer); + IBurningShader* createTriangleRendererGouraud2(IDepthBuffer* zbuffer); + IBurningShader* createTriangleRendererGouraudAlpha2(IDepthBuffer* zbuffer); + IBurningShader* createTRGouraudAlphaNoZ2(IDepthBuffer* zbuffer); + IBurningShader* createTriangleRendererGouraudWire2(IDepthBuffer* zbuffer); + IBurningShader* createTriangleRendererTextureFlat2(IDepthBuffer* zbuffer); + IBurningShader* createTriangleRendererTextureFlatWire2(IDepthBuffer* zbuffer); + IBurningShader* createTRFlat2(IDepthBuffer* zbuffer); + IBurningShader* createTRFlatWire2(IDepthBuffer* zbuffer); + IBurningShader* createTRTextureGouraudNoZ2(); + IBurningShader* createTRTextureGouraudAdd2(IDepthBuffer* zbuffer); + IBurningShader* createTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer); + + IBurningShader* createTRTextureGouraudAlpha(IDepthBuffer* zbuffer); + IBurningShader* createTRTextureGouraudAlphaNoZ(IDepthBuffer* zbuffer); + IBurningShader* createTRTextureBlend(IDepthBuffer* zbuffer); + IBurningShader* createTRTextureInverseAlphaBlend(IDepthBuffer* zbuffer); + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/IDepthBuffer.h b/src/dep/src/irrlicht/IDepthBuffer.h index 187ee61..1468f91 100644 --- a/src/dep/src/irrlicht/IDepthBuffer.h +++ b/src/dep/src/irrlicht/IDepthBuffer.h @@ -1,47 +1,47 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_Z2_BUFFER_H_INCLUDED__ -#define __I_Z2_BUFFER_H_INCLUDED__ - -#include "IUnknown.h" -#include "dimension2d.h" -#include "S4DVertex.h" - -namespace irr -{ -namespace video -{ - class IDepthBuffer : public virtual IUnknown - { - public: - - //! destructor - virtual ~IDepthBuffer() {}; - - //! clears the zbuffer - virtual void clear() = 0; - - //! sets the new size of the zbuffer - virtual void setSize(const core::dimension2d& size) = 0; - - //! returns the size of the zbuffer - virtual const core::dimension2d& getSize() = 0; - - //! locks the zbuffer - virtual fp24* lock() = 0; - - //! unlocks the zbuffer - virtual void unlock() = 0; - }; - - - //! creates a ZBuffer - IDepthBuffer* createDepthBuffer(const core::dimension2d& size); - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_Z2_BUFFER_H_INCLUDED__ +#define __I_Z2_BUFFER_H_INCLUDED__ + +#include "IUnknown.h" +#include "dimension2d.h" +#include "S4DVertex.h" + +namespace irr +{ +namespace video +{ + class IDepthBuffer : public virtual IUnknown + { + public: + + //! destructor + virtual ~IDepthBuffer() {}; + + //! clears the zbuffer + virtual void clear() = 0; + + //! sets the new size of the zbuffer + virtual void setSize(const core::dimension2d& size) = 0; + + //! returns the size of the zbuffer + virtual const core::dimension2d& getSize() = 0; + + //! locks the zbuffer + virtual fp24* lock() = 0; + + //! unlocks the zbuffer + virtual void unlock() = 0; + }; + + + //! creates a ZBuffer + IDepthBuffer* createDepthBuffer(const core::dimension2d& size); + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/IImagePresenter.h b/src/dep/src/irrlicht/IImagePresenter.h index 8a44b2b..f3fe855 100644 --- a/src/dep/src/irrlicht/IImagePresenter.h +++ b/src/dep/src/irrlicht/IImagePresenter.h @@ -1,36 +1,36 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_IMAGE_PRESENTER_H_INCLUDED__ -#define __I_IMAGE_PRESENTER_H_INCLUDED__ - -#include "IImage.h" - -namespace irr -{ -namespace video -{ - -/*! - Interface for a class which is able to present an IImage - an the Screen. Usually only implemented by an IrrDevice for - presenting Software Device Rendered images. - - This class should be used internal only. -*/ - - class IImagePresenter - { - public: - - virtual ~IImagePresenter() {}; - //! presents a surface in the client area - virtual void present(video::IImage* surface, s32 windowId=0, core::rect* src=0 ) = 0; - }; - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_IMAGE_PRESENTER_H_INCLUDED__ +#define __I_IMAGE_PRESENTER_H_INCLUDED__ + +#include "IImage.h" + +namespace irr +{ +namespace video +{ + +/*! + Interface for a class which is able to present an IImage + an the Screen. Usually only implemented by an IrrDevice for + presenting Software Device Rendered images. + + This class should be used internal only. +*/ + + class IImagePresenter + { + public: + + virtual ~IImagePresenter() {}; + //! presents a surface in the client area + virtual void present(video::IImage* surface, s32 windowId=0, core::rect* src=0 ) = 0; + }; + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/ITriangleRenderer.h b/src/dep/src/irrlicht/ITriangleRenderer.h index 550fb28..87b4878 100644 --- a/src/dep/src/irrlicht/ITriangleRenderer.h +++ b/src/dep/src/irrlicht/ITriangleRenderer.h @@ -1,72 +1,72 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_TRIANGLE_RENDERER_H_INCLUDED__ -#define __I_TRIANGLE_RENDERER_H_INCLUDED__ - -#include "IUnknown.h" -#include "IImage.h" -#include "S2DVertex.h" -#include "rect.h" -#include "IZBuffer.h" -#include "IImage.h" - -namespace irr -{ -namespace video -{ - - enum ETriangleRenderer - { - ETR_FLAT = 0, - ETR_FLAT_WIRE, - ETR_GOURAUD, - ETR_GOURAUD_WIRE, - ETR_TEXTURE_FLAT, - ETR_TEXTURE_FLAT_WIRE, - ETR_TEXTURE_GOURAUD, - ETR_TEXTURE_GOURAUD_WIRE, - ETR_TEXTURE_GOURAUD_NOZ, - ETR_TEXTURE_GOURAUD_ADD, - ETR_COUNT - }; - - class ITriangleRenderer : public virtual IUnknown - { - public: - - //! destructor - virtual ~ITriangleRenderer() {}; - - //! sets a render target - virtual void setRenderTarget(video::IImage* surface, const core::rect& viewPort) = 0; - - //! en or disables the backface culling - virtual void setBackfaceCulling(bool enabled = true) = 0; - - //! sets the Texture - virtual void setTexture(video::IImage* texture) = 0; - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) = 0; - }; - - - ITriangleRenderer* createTriangleRendererTextureGouraud(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererTextureGouraudWire(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererGouraud(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererGouraudWire(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererTextureFlat(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererTextureFlatWire(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererFlat(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererFlatWire(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererTextureGouraudNoZ(); - ITriangleRenderer* createTriangleRendererTextureGouraudAdd(IZBuffer* zbuffer); - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_TRIANGLE_RENDERER_H_INCLUDED__ +#define __I_TRIANGLE_RENDERER_H_INCLUDED__ + +#include "IUnknown.h" +#include "IImage.h" +#include "S2DVertex.h" +#include "rect.h" +#include "IZBuffer.h" +#include "IImage.h" + +namespace irr +{ +namespace video +{ + + enum ETriangleRenderer + { + ETR_FLAT = 0, + ETR_FLAT_WIRE, + ETR_GOURAUD, + ETR_GOURAUD_WIRE, + ETR_TEXTURE_FLAT, + ETR_TEXTURE_FLAT_WIRE, + ETR_TEXTURE_GOURAUD, + ETR_TEXTURE_GOURAUD_WIRE, + ETR_TEXTURE_GOURAUD_NOZ, + ETR_TEXTURE_GOURAUD_ADD, + ETR_COUNT + }; + + class ITriangleRenderer : public virtual IUnknown + { + public: + + //! destructor + virtual ~ITriangleRenderer() {}; + + //! sets a render target + virtual void setRenderTarget(video::IImage* surface, const core::rect& viewPort) = 0; + + //! en or disables the backface culling + virtual void setBackfaceCulling(bool enabled = true) = 0; + + //! sets the Texture + virtual void setTexture(video::IImage* texture) = 0; + + //! draws an indexed triangle list + virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) = 0; + }; + + + ITriangleRenderer* createTriangleRendererTextureGouraud(IZBuffer* zbuffer); + ITriangleRenderer* createTriangleRendererTextureGouraudWire(IZBuffer* zbuffer); + ITriangleRenderer* createTriangleRendererGouraud(IZBuffer* zbuffer); + ITriangleRenderer* createTriangleRendererGouraudWire(IZBuffer* zbuffer); + ITriangleRenderer* createTriangleRendererTextureFlat(IZBuffer* zbuffer); + ITriangleRenderer* createTriangleRendererTextureFlatWire(IZBuffer* zbuffer); + ITriangleRenderer* createTriangleRendererFlat(IZBuffer* zbuffer); + ITriangleRenderer* createTriangleRendererFlatWire(IZBuffer* zbuffer); + ITriangleRenderer* createTriangleRendererTextureGouraudNoZ(); + ITriangleRenderer* createTriangleRendererTextureGouraudAdd(IZBuffer* zbuffer); + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/IZBuffer.h b/src/dep/src/irrlicht/IZBuffer.h index 87b6aa6..ac84230 100644 --- a/src/dep/src/irrlicht/IZBuffer.h +++ b/src/dep/src/irrlicht/IZBuffer.h @@ -1,47 +1,47 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_Z_BUFFER_H_INCLUDED__ -#define __I_Z_BUFFER_H_INCLUDED__ - -#include "IUnknown.h" -#include "dimension2d.h" -#include "S2DVertex.h" - -namespace irr -{ -namespace video -{ - class IZBuffer : public virtual IUnknown - { - public: - - //! destructor - virtual ~IZBuffer() {}; - - //! clears the zbuffer - virtual void clear() = 0; - - //! sets the new size of the zbuffer - virtual void setSize(const core::dimension2d& size) = 0; - - //! returns the size of the zbuffer - virtual const core::dimension2d& getSize() = 0; - - //! locks the zbuffer - virtual TZBufferType* lock() = 0; - - //! unlocks the zbuffer - virtual void unlock() = 0; - }; - - - //! creates a ZBuffer - IZBuffer* createZBuffer(const core::dimension2d& size); - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_Z_BUFFER_H_INCLUDED__ +#define __I_Z_BUFFER_H_INCLUDED__ + +#include "IUnknown.h" +#include "dimension2d.h" +#include "S2DVertex.h" + +namespace irr +{ +namespace video +{ + class IZBuffer : public virtual IUnknown + { + public: + + //! destructor + virtual ~IZBuffer() {}; + + //! clears the zbuffer + virtual void clear() = 0; + + //! sets the new size of the zbuffer + virtual void setSize(const core::dimension2d& size) = 0; + + //! returns the size of the zbuffer + virtual const core::dimension2d& getSize() = 0; + + //! locks the zbuffer + virtual TZBufferType* lock() = 0; + + //! unlocks the zbuffer + virtual void unlock() = 0; + }; + + + //! creates a ZBuffer + IZBuffer* createZBuffer(const core::dimension2d& size); + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/Irrlicht.cpp b/src/dep/src/irrlicht/Irrlicht.cpp index a5c399c..9f64268 100644 --- a/src/dep/src/irrlicht/Irrlicht.cpp +++ b/src/dep/src/irrlicht/Irrlicht.cpp @@ -1,80 +1,80 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" - -#if defined(_IRR_WINDOWS_) || defined(_XBOX) - -#ifdef _IRR_WINDOWS_ - #include -#endif // _IRR_WINDOWS_ - -#ifdef _XBOX - #include -#endif // _XBOX - -#if defined(_DEBUG) && !defined(__GNUWIN32__) -#include -#endif // _DEBUG - -#endif // defined(_IRR_WINDOWS_) || defined(_XBOX) - - -#include "irrlicht.h" - -namespace irr -{ - //! stub for calling createDeviceEx - IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(video::E_DRIVER_TYPE driverType, - const core::dimension2d& windowSize, - u32 bits, bool fullscreen, - bool stencilbuffer, bool vsync, IEventReceiver* res, - const char* version) - { - irr::SIrrlichtCreationParameters p; - p.DriverType = driverType; - p.WindowSize = windowSize; - p.Bits = bits; - p.Fullscreen = fullscreen; - p.Stencilbuffer = stencilbuffer; - p.Vsync = vsync; - p.EventReceiver = res; - p.SDK_version_do_not_use = version; - - return createDeviceEx(p); - } - -} // end namespace irr - - - -#if defined(_IRR_WINDOWS_) || defined(_XBOX) - -#ifdef _MSC_VER -#pragma comment(exestr, "Irrlicht Engine (c) 2002-2007 Nikolaus Gebhardt") -#endif - -BOOL APIENTRY DllMain( HANDLE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - // _crtBreakAlloc = 139; - - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - #if defined(_DEBUG) && !defined(__GNUWIN32__) - _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF); - #endif - break; - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - -#endif // defined(_IRR_WINDOWS_) || defined(_XBOX) +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "IrrCompileConfig.h" + +#if defined(_IRR_WINDOWS_) || defined(_XBOX) + +#ifdef _IRR_WINDOWS_ + #include +#endif // _IRR_WINDOWS_ + +#ifdef _XBOX + #include +#endif // _XBOX + +#if defined(_DEBUG) && !defined(__GNUWIN32__) +#include +#endif // _DEBUG + +#endif // defined(_IRR_WINDOWS_) || defined(_XBOX) + + +#include "irrlicht.h" + +namespace irr +{ + //! stub for calling createDeviceEx + IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(video::E_DRIVER_TYPE driverType, + const core::dimension2d& windowSize, + u32 bits, bool fullscreen, + bool stencilbuffer, bool vsync, IEventReceiver* res, + const char* version) + { + irr::SIrrlichtCreationParameters p; + p.DriverType = driverType; + p.WindowSize = windowSize; + p.Bits = bits; + p.Fullscreen = fullscreen; + p.Stencilbuffer = stencilbuffer; + p.Vsync = vsync; + p.EventReceiver = res; + p.SDK_version_do_not_use = version; + + return createDeviceEx(p); + } + +} // end namespace irr + + + +#if defined(_IRR_WINDOWS_) || defined(_XBOX) + +#ifdef _MSC_VER +#pragma comment(exestr, "Irrlicht Engine (c) 2002-2007 Nikolaus Gebhardt") +#endif + +BOOL APIENTRY DllMain( HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + // _crtBreakAlloc = 139; + + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + #if defined(_DEBUG) && !defined(__GNUWIN32__) + _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF); + #endif + break; + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + +#endif // defined(_IRR_WINDOWS_) || defined(_XBOX) diff --git a/src/dep/src/irrlicht/Irrlicht.dev b/src/dep/src/irrlicht/Irrlicht.dev index ed4f798..96d1e54 100644 --- a/src/dep/src/irrlicht/Irrlicht.dev +++ b/src/dep/src/irrlicht/Irrlicht.dev @@ -1,5839 +1,5839 @@ -[Project] -FileName=Irrlicht.dev -Name=Irrlicht -Ver=1 -IsCpp=1 -Type=3 -Compiler=-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL -DIRRLICHT_EXPORTS_@@_ -CppCompiler=-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL -DIRRLICHT_EXPORTS_@@_ -Includes=..\..\include;zlib -Linker=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lglu32 -lopengl32_@@_ -Libs= -UnitCount=579 -Folders=doc,gui_impl,include,include/core,include/gui,include/io,include/scene,include/video,io_impl,other_impl,other_impl/extern,other_impl/extern/jpeglib,other_impl/extern/libpng,other_impl/extern/zlib,scene_impl,video_impl,"video_impl/Burning Video",video_impl/DirectX8,video_impl/DirectX9,video_impl/Null,video_impl/OpenGL,video_impl/Software -ObjFiles= -PrivateResource= -ResourceIncludes= -MakeIncludes= -Icon= -ExeOutput=..\..\bin\Win32-gcc -ObjectOutput=obj -OverrideOutput=1 -OverrideOutputName=Irrlicht.dll -HostApplication= -CommandLine= -UseCustomMakefile=0 -CustomMakefile= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=0000000001001000000100 - -[Unit1] -FileName=..\..\include\EDriverTypes.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit2] -FileName=..\..\include\ITexture.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit3] -FileName=..\..\include\IVideoDriver.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit4] -FileName=..\..\include\S3DVertex.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit5] -FileName=..\..\include\SColor.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit6] -FileName=..\..\include\SLight.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit7] -FileName=..\..\include\SMaterial.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit8] -FileName=..\..\include\aabbox3d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit9] -FileName=..\..\include\dimension2d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit10] -FileName=..\..\include\heapsort.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit11] -FileName=..\..\include\irrArray.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit12] -FileName=..\..\include\irrList.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit13] -FileName=..\..\include\irrMath.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit14] -FileName=..\..\include\irrString.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit15] -FileName=..\..\include\line2d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit16] -FileName=..\..\include\line3d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit17] -FileName=..\..\include\matrix4.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit18] -FileName=..\..\include\plane3d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit19] -FileName=..\..\include\position2d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit20] -FileName=..\..\include\rect.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit21] -FileName=..\..\include\vector2d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit22] -FileName=..\..\include\vector3d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit23] -FileName=..\..\include\IFileList.h -Folder=include/io -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit24] -FileName=..\..\include\IFileSystem.h -Folder=include/io -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit25] -FileName=..\..\include\IReadFile.H -Folder=include/io -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit26] -FileName=..\..\include\IAnimatedMesh.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit27] -FileName=..\..\include\IAnimatedMeshSceneNode.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit28] -FileName=..\..\include\IBillboardSceneNode.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit29] -FileName=..\..\include\ICameraSceneNode.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit30] -FileName=..\..\include\ILightSceneNode.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit31] -FileName=..\..\include\IMesh.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit32] -FileName=..\..\include\IMeshBuffer.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit33] -FileName=..\..\include\IQ3LevelMesh.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit34] -FileName=..\..\include\ISceneManager.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit35] -FileName=..\..\include\ISceneNode.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit36] -FileName=..\..\include\ISceneNodeAnimator.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit37] -FileName=..\..\include\SMesh.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit38] -FileName=..\..\include\SMeshBuffer.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit39] -FileName=..\..\include\SMeshBufferLightMap.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit40] -FileName=..\..\include\ICursorControl.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit41] -FileName=..\..\include\IGUIButton.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit42] -FileName=..\..\include\IGUICheckbox.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit43] -FileName=..\..\include\IGUIElement.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit44] -FileName=..\..\include\IGUIEnvironment.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit45] -FileName=..\..\include\IGUIFileOpenDialog.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit46] -FileName=..\..\include\IGUIFont.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit47] -FileName=..\..\include\IGUIImage.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit48] -FileName=..\..\include\IGUIListBox.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit49] -FileName=..\..\include\IGUIMeshViewer.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit50] -FileName=..\..\include\IGUIScrollBar.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit51] -FileName=..\..\include\IGUISkin.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit52] -FileName=..\..\include\IGUIWindow.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit53] -FileName=..\..\include\IEventReceiver.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit54] -FileName=..\..\include\Irrlicht.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit55] -FileName=..\..\include\IrrlichtDevice.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit56] -FileName=..\..\include\irrTypes.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit57] -FileName=..\..\include\IUnknown.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit58] -FileName=..\..\include\Keycodes.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit59] -FileName=..\..\include\SIrrCreationParameters.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit60] -FileName=BuiltInFont.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit61] -FileName=CGUIButton.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit62] -FileName=CGUIButton.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit63] -FileName=CGUICheckbox.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit64] -FileName=CGUICheckbox.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit65] -FileName=CGUIComboBox.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit66] -FileName=CGUIComboBox.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit67] -FileName=CGUIContextMenu.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit68] -FileName=CGUIContextMenu.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit69] -FileName=CGUIEditBox.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit70] -FileName=CGUIEditBox.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit71] -FileName=CGUIEnvironment.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit72] -FileName=CGUIEnvironment.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit73] -FileName=CGUIFileOpenDialog.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit74] -FileName=CGUIFileOpenDialog.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit75] -FileName=CGUIFont.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit76] -FileName=CGUIFont.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit77] -FileName=CGUIImage.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit78] -FileName=CGUIImage.H -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit79] -FileName=CGUIInOutFader.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit80] -FileName=CGUIInOutFader.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit81] -FileName=CGUIListBox.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit82] -FileName=CGUIListBox.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit83] -FileName=CGUIMenu.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit84] -FileName=CGUIMenu.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit85] -FileName=CGUIMeshViewer.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit86] -FileName=CGUIMeshViewer.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit87] -FileName=CGUIMessageBox.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit88] -FileName=CGUIMessageBox.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit89] -FileName=CGUIModalScreen.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit90] -FileName=CGUIModalScreen.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit91] -FileName=CGUIScrollBar.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit92] -FileName=CGUIScrollBar.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit93] -FileName=CGUISkin.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit94] -FileName=CGUISkin.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit95] -FileName=CGUIStaticText.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit96] -FileName=CGUIStaticText.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit97] -FileName=CGUITabControl.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit98] -FileName=CGUITabControl.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit99] -FileName=CGUIToolBar.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit100] -FileName=CGUIToolBar.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit101] -FileName=CGUIWindow.cpp -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit102] -FileName=CGUIWindow.h -Folder=gui_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit103] -FileName=CSoftwareDriver.cpp -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit104] -FileName=CSoftwareDriver.h -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit105] -FileName=CSoftwareTexture.cpp -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit106] -FileName=CSoftwareTexture.h -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit107] -FileName=CTRFlat.cpp -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit108] -FileName=CTRFlatWire.cpp -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit109] -FileName=CTRGouraud.cpp -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit110] -FileName=CTRGouraudWire.cpp -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit111] -FileName=CTRTextureFlat.cpp -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit112] -FileName=CTRTextureFlatWire.cpp -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit113] -FileName=CTRTextureGouraud.cpp -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit114] -FileName=CTRTextureGouraud.h -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit115] -FileName=CTRTextureGouraudAdd.cpp -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit116] -FileName=CTRTextureGouraudNoZ.cpp -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit117] -FileName=CTRTextureGouraudWire.cpp -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit118] -FileName=CZBuffer.cpp -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit119] -FileName=CZBuffer.h -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit120] -FileName=IZBuffer.h -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit121] -FileName=S2DVertex.h -Folder=video_impl/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit122] -FileName=COpenGLDriver.cpp -Folder=video_impl/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit123] -FileName=COpenGLDriver.h -Folder=video_impl/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit124] -FileName=COpenGLMaterialRenderer.h -Folder=video_impl/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit125] -FileName=COpenGLNormalMapRenderer.cpp -Folder=video_impl/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit126] -FileName=COpenGLNormalMapRenderer.h -Folder=video_impl/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit127] -FileName=COpenGLParallaxMapRenderer.cpp -Folder=video_impl/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit128] -FileName=COpenGLParallaxMapRenderer.h -Folder=video_impl/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit129] -FileName=COpenGLShaderMaterialRenderer.cpp -Folder=video_impl/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit130] -FileName=COpenGLShaderMaterialRenderer.h -Folder=video_impl/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit131] -FileName=COpenGLTexture.cpp -Folder=video_impl/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit132] -FileName=COpenGLTexture.h -Folder=video_impl/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit133] -FileName=glext.h -Folder=video_impl/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit134] -FileName=CD3D8Driver.cpp -Folder=video_impl/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit135] -FileName=CD3D8Driver.h -Folder=video_impl/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit136] -FileName=CD3D8MaterialRenderer.h -Folder=video_impl/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit137] -FileName=CD3D8NormalMapRenderer.cpp -Folder=video_impl/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit138] -FileName=CD3D8NormalMapRenderer.h -Folder=video_impl/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit139] -FileName=CD3D8ParallaxMapRenderer.cpp -Folder=video_impl/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit140] -FileName=CD3D8ParallaxMapRenderer.h -Folder=video_impl/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit141] -FileName=CD3D8ShaderMaterialRenderer.cpp -Folder=video_impl/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit142] -FileName=CD3D8ShaderMaterialRenderer.h -Folder=video_impl/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit143] -FileName=CD3D8Texture.cpp -Folder=video_impl/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit144] -FileName=CD3D8Texture.h -Folder=video_impl/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit145] -FileName=CColorConverter.cpp -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit146] -FileName=CColorConverter.h -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit147] -FileName=CFPSCounter.cpp -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit148] -FileName=CFPSCounter.h -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit149] -FileName=CImage.cpp -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit150] -FileName=CImage.h -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit151] -FileName=CImageLoaderBMP.cpp -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit152] -FileName=CImageLoaderBMP.h -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit153] -FileName=CImageLoaderJPG.cpp -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit154] -FileName=CImageLoaderJPG.h -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit155] -FileName=CImageLoaderPCX.cpp -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit156] -FileName=CImageLoaderPCX.h -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit157] -FileName=CImageLoaderPNG.cpp -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit158] -FileName=CImageLoaderPNG.h -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit159] -FileName=CImageLoaderPSD.cpp -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit160] -FileName=CImageLoaderPSD.h -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit161] -FileName=CImageLoaderTGA.cpp -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit162] -FileName=CImageLoaderTGA.h -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit163] -FileName=CNullDriver.cpp -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit164] -FileName=CNullDriver.h -Folder=video_impl/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit165] -FileName=CD3D9Driver.cpp -Folder=video_impl/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit166] -FileName=CD3D9Driver.h -Folder=video_impl/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit167] -FileName=CD3D9HLSLMaterialRenderer.cpp -Folder=video_impl/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit168] -FileName=CD3D9HLSLMaterialRenderer.h -Folder=video_impl/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit169] -FileName=CD3D9MaterialRenderer.h -Folder=video_impl/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit170] -FileName=CD3D9NormalMapRenderer.cpp -Folder=video_impl/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit171] -FileName=CD3D9NormalMapRenderer.h -Folder=video_impl/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit172] -FileName=CD3D9ParallaxMapRenderer.cpp -Folder=video_impl/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit173] -FileName=CD3D9ParallaxMapRenderer.h -Folder=video_impl/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit174] -FileName=CD3D9ShaderMaterialRenderer.cpp -Folder=video_impl/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit175] -FileName=CD3D9ShaderMaterialRenderer.h -Folder=video_impl/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit176] -FileName=CD3D9Texture.cpp -Folder=video_impl/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit177] -FileName=CD3D9Texture.h -Folder=video_impl/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit178] -FileName=CVideoModeList.cpp -Folder=video_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit179] -FileName=CVideoModeList.h -Folder=video_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit180] -FileName=C3DSMeshFileLoader.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit181] -FileName=C3DSMeshFileLoader.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit182] -FileName=CAnimatedMeshMD2.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit183] -FileName=CAnimatedMeshMD2.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit184] -FileName=CAnimatedMeshMS3D.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit185] -FileName=CAnimatedMeshMS3D.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit186] -FileName=CAnimatedMeshSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit187] -FileName=CAnimatedMeshSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit188] -FileName=CBillboardSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit189] -FileName=CBillboardSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit190] -FileName=CCameraFPSSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit191] -FileName=CCameraFPSSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit192] -FileName=CCameraMayaSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit193] -FileName=CCameraMayaSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit194] -FileName=CCameraSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit195] -FileName=CCameraSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit196] -FileName=CColladaFileLoader.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit197] -FileName=CColladaFileLoader.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit198] -FileName=CCSMLoader.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit199] -FileName=CCSMLoader.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit200] -FileName=CDefaultMeshFormatLoader.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit201] -FileName=CDefaultMeshFormatLoader.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit202] -FileName=CDMFLoader.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit203] -FileName=CDMFLoader.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit204] -FileName=CDummyTransformationSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit205] -FileName=CDummyTransformationSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit206] -FileName=CEmptySceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit207] -FileName=CEmptySceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit208] -FileName=CGeometryCreator.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit209] -FileName=CGeometryCreator.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit210] -FileName=CLightSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit211] -FileName=CLightSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit212] -FileName=CLMTSMeshFileLoader.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit213] -FileName=CLMTSMeshFileLoader.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit214] -FileName=CMeshManipulator.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit215] -FileName=CMeshManipulator.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit216] -FileName=CMeshSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit217] -FileName=CMeshSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit218] -FileName=CMetaTriangleSelector.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit219] -FileName=CMetaTriangleSelector.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit220] -FileName=CMY3DHelper.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit221] -FileName=CMY3DMeshFileLoader.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit222] -FileName=CMY3DMeshFileLoader.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit223] -FileName=CMY3DStuff.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit224] -FileName=COCTLoader.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit225] -FileName=COCTLoader.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit226] -FileName=COctTreeSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit227] -FileName=COctTreeSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit228] -FileName=COctTreeTriangleSelector.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit229] -FileName=COctTreeTriangleSelector.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit230] -FileName=CParticleBoxEmitter.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit231] -FileName=CParticleBoxEmitter.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit232] -FileName=CParticleFadeOutAffector.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit233] -FileName=CParticleFadeOutAffector.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit234] -FileName=CParticleGravityAffector.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit235] -FileName=CParticleGravityAffector.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit236] -FileName=CParticlePointEmitter.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit237] -FileName=CParticlePointEmitter.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit238] -FileName=CParticleSystemSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit239] -FileName=CParticleSystemSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit240] -FileName=CQ3LevelMesh.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit241] -FileName=CQ3LevelMesh.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit242] -FileName=CSceneCollisionManager.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit243] -FileName=CSceneCollisionManager.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit244] -FileName=CSceneManager.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit245] -FileName=CSceneManager.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit246] -FileName=CSceneNodeAnimatorCollisionResponse.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit247] -FileName=CSceneNodeAnimatorCollisionResponse.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit248] -FileName=CSceneNodeAnimatorDelete.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit249] -FileName=CSceneNodeAnimatorDelete.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit250] -FileName=CSceneNodeAnimatorFlyCircle.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit251] -FileName=CSceneNodeAnimatorFlyCircle.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit252] -FileName=CSceneNodeAnimatorFlyStraight.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit253] -FileName=CSceneNodeAnimatorFlyStraight.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit254] -FileName=CSceneNodeAnimatorFollowSpline.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit255] -FileName=CSceneNodeAnimatorFollowSpline.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit256] -FileName=CSceneNodeAnimatorRotation.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit257] -FileName=CSceneNodeAnimatorRotation.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit258] -FileName=CSceneNodeAnimatorTexture.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit259] -FileName=CSceneNodeAnimatorTexture.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit260] -FileName=CShadowVolumeSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit261] -FileName=CShadowVolumeSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit262] -FileName=CSkyBoxSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit263] -FileName=CSkyBoxSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit264] -FileName=COBJMeshFileLoader.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit265] -FileName=COBJMeshFileLoader.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit266] -FileName=CTerrainSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit267] -FileName=CTerrainSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit268] -FileName=CTerrainTriangleSelector.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit269] -FileName=CTerrainTriangleSelector.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit270] -FileName=CTextSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit271] -FileName=CTextSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit272] -FileName=CTriangleBBSelector.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit273] -FileName=CTriangleBBSelector.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit274] -FileName=CTriangleSelector.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit275] -FileName=CTriangleSelector.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit276] -FileName=CWaterSurfaceSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit277] -FileName=CWaterSurfaceSceneNode.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit278] -FileName=CXAnimationPlayer.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit279] -FileName=CXAnimationPlayer.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit280] -FileName=CXFileReader.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit281] -FileName=CXFileReader.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit282] -FileName=CXMeshFileLoader.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit283] -FileName=CXMeshFileLoader.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit284] -FileName=OctTree.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit285] -FileName=CFileList.cpp -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit286] -FileName=CFileList.h -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit287] -FileName=CFileSystem.cpp -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit288] -FileName=CFileSystem.h -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit289] -FileName=CLimitReadFile.cpp -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit290] -FileName=CLimitReadFile.h -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit291] -FileName=CMemoryReadFile.cpp -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit292] -FileName=CMemoryReadFile.h -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit293] -FileName=CReadFile.cpp -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit294] -FileName=CReadFile.h -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit295] -FileName=CWriteFile.cpp -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit296] -FileName=CWriteFile.h -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit297] -FileName=CXMLReader.cpp -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit298] -FileName=CXMLReader.h -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit299] -FileName=CXMLWriter.cpp -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit300] -FileName=CXMLWriter.h -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit301] -FileName=CZipReader.cpp -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit302] -FileName=CZipReader.h -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit303] -FileName=irrXML.cpp -Folder=io_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit304] -FileName=zlib\adler32.c -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit305] -FileName=zlib\compress.c -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit306] -FileName=zlib\crc32.c -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit307] -FileName=zlib\crc32.h -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit308] -FileName=zlib\deflate.c -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit309] -FileName=zlib\deflate.h -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit310] -FileName=zlib\inffast.c -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit311] -FileName=zlib\inffast.h -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit312] -FileName=zlib\inflate.c -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit313] -FileName=zlib\inftrees.c -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit314] -FileName=zlib\inftrees.h -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit315] -FileName=zlib\trees.c -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit316] -FileName=zlib\trees.h -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit317] -FileName=zlib\uncompr.c -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit318] -FileName=zlib\zconf.h -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit319] -FileName=zlib\zlib.h -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit320] -FileName=zlib\zutil.c -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit321] -FileName=zlib\zutil.h -Folder=other_impl/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit322] -FileName=jpeglib\cderror.h -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit323] -FileName=jpeglib\cdjpeg.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit324] -FileName=jpeglib\cdjpeg.h -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit325] -FileName=jpeglib\jcapimin.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit326] -FileName=jpeglib\jcapistd.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit327] -FileName=jpeglib\jccoefct.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit328] -FileName=jpeglib\jccolor.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit329] -FileName=jpeglib\jcdctmgr.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit330] -FileName=jpeglib\jchuff.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit331] -FileName=jpeglib\jchuff.h -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit332] -FileName=jpeglib\jcinit.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit333] -FileName=jpeglib\jcmainct.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit334] -FileName=jpeglib\jcmarker.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit335] -FileName=jpeglib\jcmaster.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit336] -FileName=jpeglib\jcomapi.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit337] -FileName=jpeglib\jconfig.h -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit338] -FileName=jpeglib\jcparam.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit339] -FileName=jpeglib\jcphuff.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit340] -FileName=jpeglib\jcprepct.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit341] -FileName=jpeglib\jcsample.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit342] -FileName=jpeglib\jctrans.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit343] -FileName=jpeglib\jdapimin.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit344] -FileName=jpeglib\jdapistd.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit345] -FileName=jpeglib\jdatadst.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit346] -FileName=jpeglib\jdatasrc.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit347] -FileName=jpeglib\jdcoefct.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit348] -FileName=jpeglib\jdcolor.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit349] -FileName=jpeglib\jdct.h -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit350] -FileName=jpeglib\jddctmgr.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit351] -FileName=jpeglib\jdhuff.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit352] -FileName=jpeglib\jdhuff.h -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit353] -FileName=jpeglib\jdinput.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit354] -FileName=jpeglib\jdmainct.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit355] -FileName=jpeglib\jdmarker.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit356] -FileName=jpeglib\jdmaster.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit357] -FileName=jpeglib\jdmerge.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit358] -FileName=jpeglib\jdphuff.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit359] -FileName=jpeglib\jdpostct.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit360] -FileName=jpeglib\jdsample.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit361] -FileName=jpeglib\jdtrans.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit362] -FileName=jpeglib\jerror.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit363] -FileName=jpeglib\jerror.h -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit364] -FileName=jpeglib\jfdctflt.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit365] -FileName=jpeglib\jfdctfst.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit366] -FileName=jpeglib\jfdctint.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit367] -FileName=jpeglib\jidctflt.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit368] -FileName=jpeglib\jidctfst.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit369] -FileName=jpeglib\jidctint.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit370] -FileName=jpeglib\jidctred.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit371] -FileName=jpeglib\jinclude.h -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit372] -FileName=jpeglib\jmemmgr.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit373] -FileName=jpeglib\jmemnobs.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit374] -FileName=jpeglib\jmemsys.h -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit375] -FileName=jpeglib\jmorecfg.h -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit376] -FileName=jpeglib\jpegint.h -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit377] -FileName=jpeglib\jpeglib.h -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit378] -FileName=jpeglib\jquant1.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit379] -FileName=jpeglib\jquant2.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit380] -FileName=jpeglib\jutils.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit381] -FileName=jpeglib\jversion.h -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit382] -FileName=jpeglib\rdbmp.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit383] -FileName=jpeglib\rdcolmap.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit384] -FileName=jpeglib\rdgif.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit385] -FileName=jpeglib\rdppm.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit386] -FileName=jpeglib\rdrle.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit387] -FileName=jpeglib\rdswitch.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit388] -FileName=jpeglib\rdtarga.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit389] -FileName=jpeglib\transupp.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit390] -FileName=jpeglib\transupp.h -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit391] -FileName=jpeglib\wrbmp.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit392] -FileName=jpeglib\wrgif.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit393] -FileName=jpeglib\wrppm.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit394] -FileName=jpeglib\wrrle.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit395] -FileName=jpeglib\wrtarga.c -Folder=other_impl/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit396] -FileName=libpng\png.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit397] -FileName=libpng\png.h -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit398] -FileName=libpng\pngconf.h -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit399] -FileName=libpng\pngerror.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit400] -FileName=libpng\pngget.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit401] -FileName=libpng\pngmem.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit402] -FileName=libpng\pngpread.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit403] -FileName=libpng\pngread.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit404] -FileName=libpng\pngrio.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit405] -FileName=libpng\pngrtran.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit406] -FileName=libpng\pngrutil.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit407] -FileName=libpng\pngset.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit408] -FileName=libpng\pngtrans.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit409] -FileName=libpng\pngwio.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit410] -FileName=libpng\pngwrite.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit411] -FileName=libpng\pngwtran.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit412] -FileName=libpng\pngwutil.c -Folder=other_impl/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit413] -FileName=CIrrDeviceLinux.cpp -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit414] -FileName=CIrrDeviceLinux.h -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit415] -FileName=CIrrDeviceStub.cpp -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit416] -FileName=CIrrDeviceStub.h -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit417] -FileName=CIrrDeviceWin32.cpp -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit418] -FileName=CIrrDeviceWin32.h -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit419] -FileName=CLogger.cpp -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit420] -FileName=CLogger.h -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit421] -FileName=COSOperator.cpp -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit422] -FileName=COSOperator.h -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit423] -FileName=CTimer.h -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit424] -FileName=IImagePresenter.h -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit425] -FileName=Irrlicht.cpp -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit426] -FileName=os.cpp -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit427] -FileName=os.h -Folder=other_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit428] -FileName=..\..\include\IrrCompileConfig.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit429] -FileName=CMeshCache.h -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit430] -FileName=CMeshCache.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit431] -FileName=COpenGLSLMaterialRenderer.h -Folder=video_impl/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit432] -FileName=COpenGLSLMaterialRenderer.cpp -Folder=video_impl/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit433] -FileName=CSoftwareTexture2.h -Folder=video_impl/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit434] -FileName=S4DVertex.h -Folder=video_impl/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit435] -FileName=SoftwareDriver2_compile_config.h -Folder=video_impl/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion=0.1 -FileDescription=Developed using the Dev-C++ IDE -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename=Irrlicht.dll -ProductName=Irrlicht -ProductVersion=0.1 -AutoIncBuildNr=0 - -[Unit436] -FileName=CSoftwareDriver2.h -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit437] -FileName=CTRTextureGouraudNoZ2.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit438] -FileName=CTRTextureLightMap2_M2.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit439] -FileName=CTRTextureLightMap2_M4.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit440] -FileName=CTRTextureLightMap2_M1.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit441] -FileName=SoftwareDriver2_helper.h -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit442] -FileName=CSoftwareDriver2.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit443] -FileName=CSoftwareTexture2.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit444] -FileName=CTRTextureGouraud2.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit445] -FileName=COgreMeshFileLoader.h -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit446] -FileName=COgreMeshFileLoader.cpp -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit447] -FileName=CDefaultSceneNodeFactory.h -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit448] -FileName=CDefaultSceneNodeAnimatorFactory.cpp -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit449] -FileName=CDefaultSceneNodeAnimatorFactory.h -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit450] -FileName=CDefaultSceneNodeFactory.cpp -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit451] -FileName=CAttributes.h -CompileCpp=1 -Folder=io_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit452] -FileName=CAttributeImpl.h -CompileCpp=1 -Folder=io_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit453] -FileName=CAttributes.cpp -CompileCpp=1 -Folder=io_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit454] -FileName=CCubeSceneNode.h -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit455] -FileName=CCubeSceneNode.cpp -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit456] -FileName=CTRTextureGouraudAddNoZ2.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit457] -FileName=CTRTextureGouraudAdd2.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit458] -FileName=CTRGouraud2.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit459] -FileName=CTRGouraudAlpha2.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit460] -FileName=CTRGouraudAlphaNoZ2.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit461] -FileName=CTRTextureDetailMap2.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit462] -FileName=CTRTextureLightMap2_Add.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit463] -FileName=CTRTextureWire2.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit464] -FileName=CTRTextureGouraudVertexAlpha2.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit465] -FileName=..\..\changes.txt -CompileCpp=1 -Folder=doc -Compile=0 -Link=0 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit466] -FileName=..\..\readme.txt -CompileCpp=1 -Folder=doc -Compile=0 -Link=0 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit467] -FileName=CSphereSceneNode.cpp -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit468] -FileName=CSphereSceneNode.h -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit469] -FileName=CPakReader.h -CompileCpp=1 -Folder=io_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit470] -FileName=CPakReader.cpp -CompileCpp=1 -Folder=io_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit471] -FileName=CAnimatedMeshB3d.h -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= -CompileCpp=1 - -[Unit472] -FileName=CAnimatedMeshB3d.cpp -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= -CompileCpp=1 - -[Unit473] -FileName=CSkyDomeSceneNode.h -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit474] -FileName=CSkyDomeSceneNode.cpp -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit475] -FileName=CImageWriterTGA.h -CompileCpp=1 -Folder=video_impl/Null -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit476] -FileName=CImageWriterBMP.cpp -CompileCpp=1 -Folder=video_impl/Null -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit477] -FileName=CImageWriterBMP.h -CompileCpp=1 -Folder=video_impl/Null -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit478] -FileName=CImageWriterJPG.cpp -CompileCpp=1 -Folder=video_impl/Null -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit479] -FileName=CImageWriterJPG.h -CompileCpp=1 -Folder=video_impl/Null -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit480] -FileName=CImageWriterPCX.cpp -CompileCpp=1 -Folder=video_impl/Null -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit481] -FileName=CImageWriterPCX.h -CompileCpp=1 -Folder=video_impl/Null -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit482] -FileName=CImageWriterPNG.cpp -CompileCpp=1 -Folder=video_impl/Null -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit483] -FileName=CImageWriterPNG.h -CompileCpp=1 -Folder=video_impl/Null -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit484] -FileName=CImageWriterPPM.cpp -CompileCpp=1 -Folder=video_impl/Null -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit485] -FileName=CImageWriterPPM.h -CompileCpp=1 -Folder=video_impl/Null -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit486] -FileName=CImageWriterPSD.cpp -CompileCpp=1 -Folder=video_impl/Null -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit487] -FileName=CImageWriterPSD.h -CompileCpp=1 -Folder=video_impl/Null -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit488] -FileName=CImageWriterTGA.cpp -CompileCpp=1 -Folder=video_impl/Null -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit489] -FileName=CTRTextureLightMapGouraud2_M4.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit490] -FileName=CGUIColorSelectDialog.cpp -CompileCpp=1 -Folder=gui_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit491] -FileName=IBurningShader.h -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit492] -FileName=IBurningShader.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit493] -FileName=IDepthBuffer.h -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit494] -FileName=CDepthBuffer.h -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit495] -FileName=CDepthBuffer.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit496] -FileName=CQuake3ShaderSceneNode.h -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit497] -FileName=CQuake3ShaderSceneNode.cpp -Folder=scene_impl -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit498] -FileName=..\..\include\fast_atof.h -CompileCpp=1 -Folder=include -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit499] -FileName=CTRTextureBlend.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit500] -FileName=CTRTextureGouraudAlpha.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit501] -FileName=CTRTextureGouraudAlphaNoZ.cpp -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit502] -FileName=CDefaultGUIElementFactory.cpp -CompileCpp=1 -Folder=gui_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit503] -FileName=CDefaultGUIElementFactory.h -CompileCpp=1 -Folder=gui_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit504] -FileName=CGUIColorSelectDialog.h -CompileCpp=1 -Folder=gui_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit505] -FileName=CSoftware2MaterialRenderer.h -CompileCpp=1 -Folder=video_impl/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit506] -FileName=CXMLReaderImpl.h -CompileCpp=1 -Folder=io_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit507] -FileName=ITriangleRenderer.h -CompileCpp=1 -Folder=video_impl/Software -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit508] -FileName=..\..\include\EGUIElementTypes.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit509] -FileName=..\..\include\ESceneNodeAnimatorTypes.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit510] -FileName=..\..\include\ESceneNodeTypes.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit511] -FileName=..\..\include\ETerrainElements.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit512] -FileName=..\..\include\IAnimatedMeshB3d.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit513] -FileName=..\..\include\IAnimatedMeshMD2.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit514] -FileName=..\..\include\IAnimatedMeshMS3D.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit515] -FileName=..\..\include\IAnimatedMeshX.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit516] -FileName=..\..\include\IAttributeExchangingObject.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit517] -FileName=..\..\include\IAttributes.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit518] -FileName=..\..\include\IDummyTransformationSceneNode.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit519] -FileName=..\..\include\IGPUProgrammingServices.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit520] -FileName=..\..\include\IGUIColorSelectDialog.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit521] -FileName=..\..\include\IGUIComboBox.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit522] -FileName=..\..\include\IGUIContextMenu.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit523] -FileName=..\..\include\IGUIEditBox.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit524] -FileName=..\..\include\IGUIElementFactory.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit525] -FileName=..\..\include\IGUIInOutFader.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit526] -FileName=..\..\include\IGUIStaticText.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit527] -FileName=..\..\include\IGUITabControl.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit528] -FileName=..\..\include\IGUIToolbar.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit529] -FileName=..\..\include\IImage.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit530] -FileName=..\..\include\IImageLoader.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit531] -FileName=..\..\include\IImageWriter.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit532] -FileName=..\..\include\ILogger.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit533] -FileName=..\..\include\IMaterialRenderer.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit534] -FileName=..\..\include\IMaterialRendererServices.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit535] -FileName=..\..\include\IMeshCache.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit536] -FileName=..\..\include\IMeshLoader.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit537] -FileName=..\..\include\IMeshManipulator.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit538] -FileName=..\..\include\IMeshSceneNode.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit539] -FileName=..\..\include\IMetaTriangleSelector.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit540] -FileName=..\..\include\IOSOperator.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit541] -FileName=..\..\include\IParticleAffector.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit542] -FileName=..\..\include\IParticleEmitter.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit543] -FileName=..\..\include\IParticleSystemSceneNode.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit544] -FileName=..\..\include\IQ3Shader.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit545] -FileName=..\..\include\irrAllocator.h -CompileCpp=1 -Folder=include/core -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit546] -FileName=..\..\include\irrMap.h -CompileCpp=1 -Folder=include/core -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit547] -FileName=..\..\include\irrXML.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit548] -FileName=..\..\include\ISceneCollisionManager.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit549] -FileName=..\..\include\ISceneNodeAnimatorCollisionResponse.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit550] -FileName=..\..\include\ISceneNodeAnimatorFactory.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit551] -FileName=..\..\include\ISceneNodeFactory.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit552] -FileName=..\..\include\ISceneUserDataSerializer.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit553] -FileName=..\..\include\IShaderConstantSetCallBack.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit554] -FileName=..\..\include\IShadowVolumeSceneNode.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit555] -FileName=..\..\include\ITerrainSceneNode.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit556] -FileName=..\..\include\ITextSceneNode.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit557] -FileName=..\..\include\ITimer.h -CompileCpp=1 -Folder=include -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit558] -FileName=..\..\include\ITriangleSelector.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit559] -FileName=..\..\include\IVideoModeList.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit560] -FileName=..\..\include\IWriteFile.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit561] -FileName=..\..\include\IXMLReader.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit562] -FileName=..\..\include\IXMLWriter.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit563] -FileName=..\..\include\quaternion.h -CompileCpp=1 -Folder=include/core -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit564] -FileName=..\..\include\SAnimatedMesh.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit565] -FileName=..\..\include\SceneParameters.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit566] -FileName=..\..\include\SExposedVideoData.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit567] -FileName=..\..\include\SKeyMap.h -CompileCpp=1 -Folder=include -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit568] -FileName=..\..\include\SMeshBufferTangents.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit569] -FileName=..\..\include\SParticle.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit570] -FileName=..\..\include\SViewFrustum.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit571] -FileName=..\..\include\triangle3d.h -CompileCpp=1 -Folder=include/core -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit572] -FileName=CMD3MeshFileLoader.h -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit573] -FileName=CMD3MeshFileLoader.cpp -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit574] -FileName=CAnimatedMeshMD3.h -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit575] -FileName=CAnimatedMeshMD3.cpp -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit576] -FileName=CGUISpriteBank.h -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit577] -FileName=CGUISpriteBank.cpp -CompileCpp=1 -Folder=scene_impl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit578] -FileName=..\..\include\IGUIFontBitmap.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit579] -FileName=..\..\include\IGUISpriteBank.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - +[Project] +FileName=Irrlicht.dev +Name=Irrlicht +Ver=1 +IsCpp=1 +Type=3 +Compiler=-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL -DIRRLICHT_EXPORTS_@@_ +CppCompiler=-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL -DIRRLICHT_EXPORTS_@@_ +Includes=..\..\include;zlib +Linker=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lglu32 -lopengl32_@@_ +Libs= +UnitCount=579 +Folders=doc,gui_impl,include,include/core,include/gui,include/io,include/scene,include/video,io_impl,other_impl,other_impl/extern,other_impl/extern/jpeglib,other_impl/extern/libpng,other_impl/extern/zlib,scene_impl,video_impl,"video_impl/Burning Video",video_impl/DirectX8,video_impl/DirectX9,video_impl/Null,video_impl/OpenGL,video_impl/Software +ObjFiles= +PrivateResource= +ResourceIncludes= +MakeIncludes= +Icon= +ExeOutput=..\..\bin\Win32-gcc +ObjectOutput=obj +OverrideOutput=1 +OverrideOutputName=Irrlicht.dll +HostApplication= +CommandLine= +UseCustomMakefile=0 +CustomMakefile= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=0000000001001000000100 + +[Unit1] +FileName=..\..\include\EDriverTypes.h +Folder=include/video +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit2] +FileName=..\..\include\ITexture.h +Folder=include/video +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit3] +FileName=..\..\include\IVideoDriver.h +Folder=include/video +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit4] +FileName=..\..\include\S3DVertex.h +Folder=include/video +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit5] +FileName=..\..\include\SColor.h +Folder=include/video +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit6] +FileName=..\..\include\SLight.h +Folder=include/video +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit7] +FileName=..\..\include\SMaterial.h +Folder=include/video +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit8] +FileName=..\..\include\aabbox3d.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit9] +FileName=..\..\include\dimension2d.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit10] +FileName=..\..\include\heapsort.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit11] +FileName=..\..\include\irrArray.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit12] +FileName=..\..\include\irrList.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit13] +FileName=..\..\include\irrMath.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit14] +FileName=..\..\include\irrString.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit15] +FileName=..\..\include\line2d.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit16] +FileName=..\..\include\line3d.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit17] +FileName=..\..\include\matrix4.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit18] +FileName=..\..\include\plane3d.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit19] +FileName=..\..\include\position2d.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit20] +FileName=..\..\include\rect.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit21] +FileName=..\..\include\vector2d.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit22] +FileName=..\..\include\vector3d.h +Folder=include/core +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit23] +FileName=..\..\include\IFileList.h +Folder=include/io +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit24] +FileName=..\..\include\IFileSystem.h +Folder=include/io +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit25] +FileName=..\..\include\IReadFile.H +Folder=include/io +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit26] +FileName=..\..\include\IAnimatedMesh.h +Folder=include/scene +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit27] +FileName=..\..\include\IAnimatedMeshSceneNode.h +Folder=include/scene +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit28] +FileName=..\..\include\IBillboardSceneNode.h +Folder=include/scene +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit29] +FileName=..\..\include\ICameraSceneNode.h +Folder=include/scene +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit30] +FileName=..\..\include\ILightSceneNode.h +Folder=include/scene +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit31] +FileName=..\..\include\IMesh.h +Folder=include/scene +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit32] +FileName=..\..\include\IMeshBuffer.h +Folder=include/scene +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit33] +FileName=..\..\include\IQ3LevelMesh.h +Folder=include/scene +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit34] +FileName=..\..\include\ISceneManager.h +Folder=include/scene +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit35] +FileName=..\..\include\ISceneNode.h +Folder=include/scene +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit36] +FileName=..\..\include\ISceneNodeAnimator.h +Folder=include/scene +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit37] +FileName=..\..\include\SMesh.h +Folder=include/scene +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit38] +FileName=..\..\include\SMeshBuffer.h +Folder=include/scene +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit39] +FileName=..\..\include\SMeshBufferLightMap.h +Folder=include/scene +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit40] +FileName=..\..\include\ICursorControl.h +Folder=include/gui +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit41] +FileName=..\..\include\IGUIButton.h +Folder=include/gui +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit42] +FileName=..\..\include\IGUICheckbox.h +Folder=include/gui +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit43] +FileName=..\..\include\IGUIElement.h +Folder=include/gui +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit44] +FileName=..\..\include\IGUIEnvironment.h +Folder=include/gui +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit45] +FileName=..\..\include\IGUIFileOpenDialog.h +Folder=include/gui +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit46] +FileName=..\..\include\IGUIFont.h +Folder=include/gui +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit47] +FileName=..\..\include\IGUIImage.h +Folder=include/gui +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit48] +FileName=..\..\include\IGUIListBox.h +Folder=include/gui +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit49] +FileName=..\..\include\IGUIMeshViewer.h +Folder=include/gui +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit50] +FileName=..\..\include\IGUIScrollBar.h +Folder=include/gui +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit51] +FileName=..\..\include\IGUISkin.h +Folder=include/gui +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit52] +FileName=..\..\include\IGUIWindow.h +Folder=include/gui +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit53] +FileName=..\..\include\IEventReceiver.h +Folder=include +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit54] +FileName=..\..\include\Irrlicht.h +Folder=include +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit55] +FileName=..\..\include\IrrlichtDevice.h +Folder=include +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit56] +FileName=..\..\include\irrTypes.h +Folder=include +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit57] +FileName=..\..\include\IUnknown.h +Folder=include +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit58] +FileName=..\..\include\Keycodes.h +Folder=include +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit59] +FileName=..\..\include\SIrrCreationParameters.h +Folder=include +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit60] +FileName=BuiltInFont.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit61] +FileName=CGUIButton.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit62] +FileName=CGUIButton.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit63] +FileName=CGUICheckbox.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit64] +FileName=CGUICheckbox.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit65] +FileName=CGUIComboBox.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit66] +FileName=CGUIComboBox.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit67] +FileName=CGUIContextMenu.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit68] +FileName=CGUIContextMenu.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit69] +FileName=CGUIEditBox.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit70] +FileName=CGUIEditBox.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit71] +FileName=CGUIEnvironment.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit72] +FileName=CGUIEnvironment.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit73] +FileName=CGUIFileOpenDialog.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit74] +FileName=CGUIFileOpenDialog.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit75] +FileName=CGUIFont.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit76] +FileName=CGUIFont.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit77] +FileName=CGUIImage.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit78] +FileName=CGUIImage.H +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit79] +FileName=CGUIInOutFader.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit80] +FileName=CGUIInOutFader.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit81] +FileName=CGUIListBox.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit82] +FileName=CGUIListBox.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit83] +FileName=CGUIMenu.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit84] +FileName=CGUIMenu.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit85] +FileName=CGUIMeshViewer.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit86] +FileName=CGUIMeshViewer.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit87] +FileName=CGUIMessageBox.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit88] +FileName=CGUIMessageBox.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit89] +FileName=CGUIModalScreen.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit90] +FileName=CGUIModalScreen.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit91] +FileName=CGUIScrollBar.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit92] +FileName=CGUIScrollBar.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit93] +FileName=CGUISkin.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit94] +FileName=CGUISkin.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit95] +FileName=CGUIStaticText.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit96] +FileName=CGUIStaticText.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit97] +FileName=CGUITabControl.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit98] +FileName=CGUITabControl.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit99] +FileName=CGUIToolBar.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit100] +FileName=CGUIToolBar.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit101] +FileName=CGUIWindow.cpp +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit102] +FileName=CGUIWindow.h +Folder=gui_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit103] +FileName=CSoftwareDriver.cpp +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit104] +FileName=CSoftwareDriver.h +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit105] +FileName=CSoftwareTexture.cpp +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit106] +FileName=CSoftwareTexture.h +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit107] +FileName=CTRFlat.cpp +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit108] +FileName=CTRFlatWire.cpp +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit109] +FileName=CTRGouraud.cpp +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit110] +FileName=CTRGouraudWire.cpp +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit111] +FileName=CTRTextureFlat.cpp +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit112] +FileName=CTRTextureFlatWire.cpp +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit113] +FileName=CTRTextureGouraud.cpp +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit114] +FileName=CTRTextureGouraud.h +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit115] +FileName=CTRTextureGouraudAdd.cpp +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit116] +FileName=CTRTextureGouraudNoZ.cpp +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit117] +FileName=CTRTextureGouraudWire.cpp +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit118] +FileName=CZBuffer.cpp +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit119] +FileName=CZBuffer.h +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit120] +FileName=IZBuffer.h +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit121] +FileName=S2DVertex.h +Folder=video_impl/Software +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit122] +FileName=COpenGLDriver.cpp +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit123] +FileName=COpenGLDriver.h +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit124] +FileName=COpenGLMaterialRenderer.h +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit125] +FileName=COpenGLNormalMapRenderer.cpp +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit126] +FileName=COpenGLNormalMapRenderer.h +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit127] +FileName=COpenGLParallaxMapRenderer.cpp +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit128] +FileName=COpenGLParallaxMapRenderer.h +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit129] +FileName=COpenGLShaderMaterialRenderer.cpp +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit130] +FileName=COpenGLShaderMaterialRenderer.h +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit131] +FileName=COpenGLTexture.cpp +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit132] +FileName=COpenGLTexture.h +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit133] +FileName=glext.h +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit134] +FileName=CD3D8Driver.cpp +Folder=video_impl/DirectX8 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit135] +FileName=CD3D8Driver.h +Folder=video_impl/DirectX8 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit136] +FileName=CD3D8MaterialRenderer.h +Folder=video_impl/DirectX8 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit137] +FileName=CD3D8NormalMapRenderer.cpp +Folder=video_impl/DirectX8 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit138] +FileName=CD3D8NormalMapRenderer.h +Folder=video_impl/DirectX8 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit139] +FileName=CD3D8ParallaxMapRenderer.cpp +Folder=video_impl/DirectX8 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit140] +FileName=CD3D8ParallaxMapRenderer.h +Folder=video_impl/DirectX8 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit141] +FileName=CD3D8ShaderMaterialRenderer.cpp +Folder=video_impl/DirectX8 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit142] +FileName=CD3D8ShaderMaterialRenderer.h +Folder=video_impl/DirectX8 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit143] +FileName=CD3D8Texture.cpp +Folder=video_impl/DirectX8 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit144] +FileName=CD3D8Texture.h +Folder=video_impl/DirectX8 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit145] +FileName=CColorConverter.cpp +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit146] +FileName=CColorConverter.h +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit147] +FileName=CFPSCounter.cpp +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit148] +FileName=CFPSCounter.h +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit149] +FileName=CImage.cpp +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit150] +FileName=CImage.h +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit151] +FileName=CImageLoaderBMP.cpp +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit152] +FileName=CImageLoaderBMP.h +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit153] +FileName=CImageLoaderJPG.cpp +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit154] +FileName=CImageLoaderJPG.h +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit155] +FileName=CImageLoaderPCX.cpp +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit156] +FileName=CImageLoaderPCX.h +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit157] +FileName=CImageLoaderPNG.cpp +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit158] +FileName=CImageLoaderPNG.h +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit159] +FileName=CImageLoaderPSD.cpp +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit160] +FileName=CImageLoaderPSD.h +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit161] +FileName=CImageLoaderTGA.cpp +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit162] +FileName=CImageLoaderTGA.h +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit163] +FileName=CNullDriver.cpp +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit164] +FileName=CNullDriver.h +Folder=video_impl/Null +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit165] +FileName=CD3D9Driver.cpp +Folder=video_impl/DirectX9 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit166] +FileName=CD3D9Driver.h +Folder=video_impl/DirectX9 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit167] +FileName=CD3D9HLSLMaterialRenderer.cpp +Folder=video_impl/DirectX9 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit168] +FileName=CD3D9HLSLMaterialRenderer.h +Folder=video_impl/DirectX9 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit169] +FileName=CD3D9MaterialRenderer.h +Folder=video_impl/DirectX9 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit170] +FileName=CD3D9NormalMapRenderer.cpp +Folder=video_impl/DirectX9 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit171] +FileName=CD3D9NormalMapRenderer.h +Folder=video_impl/DirectX9 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit172] +FileName=CD3D9ParallaxMapRenderer.cpp +Folder=video_impl/DirectX9 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit173] +FileName=CD3D9ParallaxMapRenderer.h +Folder=video_impl/DirectX9 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit174] +FileName=CD3D9ShaderMaterialRenderer.cpp +Folder=video_impl/DirectX9 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit175] +FileName=CD3D9ShaderMaterialRenderer.h +Folder=video_impl/DirectX9 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit176] +FileName=CD3D9Texture.cpp +Folder=video_impl/DirectX9 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit177] +FileName=CD3D9Texture.h +Folder=video_impl/DirectX9 +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit178] +FileName=CVideoModeList.cpp +Folder=video_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit179] +FileName=CVideoModeList.h +Folder=video_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit180] +FileName=C3DSMeshFileLoader.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit181] +FileName=C3DSMeshFileLoader.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit182] +FileName=CAnimatedMeshMD2.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit183] +FileName=CAnimatedMeshMD2.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit184] +FileName=CAnimatedMeshMS3D.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit185] +FileName=CAnimatedMeshMS3D.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit186] +FileName=CAnimatedMeshSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit187] +FileName=CAnimatedMeshSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit188] +FileName=CBillboardSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit189] +FileName=CBillboardSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit190] +FileName=CCameraFPSSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit191] +FileName=CCameraFPSSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit192] +FileName=CCameraMayaSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit193] +FileName=CCameraMayaSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit194] +FileName=CCameraSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit195] +FileName=CCameraSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit196] +FileName=CColladaFileLoader.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit197] +FileName=CColladaFileLoader.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit198] +FileName=CCSMLoader.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit199] +FileName=CCSMLoader.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit200] +FileName=CDefaultMeshFormatLoader.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit201] +FileName=CDefaultMeshFormatLoader.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit202] +FileName=CDMFLoader.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit203] +FileName=CDMFLoader.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit204] +FileName=CDummyTransformationSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit205] +FileName=CDummyTransformationSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit206] +FileName=CEmptySceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit207] +FileName=CEmptySceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit208] +FileName=CGeometryCreator.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit209] +FileName=CGeometryCreator.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit210] +FileName=CLightSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit211] +FileName=CLightSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit212] +FileName=CLMTSMeshFileLoader.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit213] +FileName=CLMTSMeshFileLoader.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit214] +FileName=CMeshManipulator.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit215] +FileName=CMeshManipulator.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit216] +FileName=CMeshSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit217] +FileName=CMeshSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit218] +FileName=CMetaTriangleSelector.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit219] +FileName=CMetaTriangleSelector.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit220] +FileName=CMY3DHelper.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit221] +FileName=CMY3DMeshFileLoader.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit222] +FileName=CMY3DMeshFileLoader.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit223] +FileName=CMY3DStuff.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit224] +FileName=COCTLoader.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit225] +FileName=COCTLoader.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit226] +FileName=COctTreeSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit227] +FileName=COctTreeSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit228] +FileName=COctTreeTriangleSelector.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit229] +FileName=COctTreeTriangleSelector.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit230] +FileName=CParticleBoxEmitter.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit231] +FileName=CParticleBoxEmitter.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit232] +FileName=CParticleFadeOutAffector.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit233] +FileName=CParticleFadeOutAffector.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit234] +FileName=CParticleGravityAffector.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit235] +FileName=CParticleGravityAffector.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit236] +FileName=CParticlePointEmitter.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit237] +FileName=CParticlePointEmitter.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit238] +FileName=CParticleSystemSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit239] +FileName=CParticleSystemSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit240] +FileName=CQ3LevelMesh.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit241] +FileName=CQ3LevelMesh.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit242] +FileName=CSceneCollisionManager.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit243] +FileName=CSceneCollisionManager.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit244] +FileName=CSceneManager.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit245] +FileName=CSceneManager.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit246] +FileName=CSceneNodeAnimatorCollisionResponse.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit247] +FileName=CSceneNodeAnimatorCollisionResponse.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit248] +FileName=CSceneNodeAnimatorDelete.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit249] +FileName=CSceneNodeAnimatorDelete.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit250] +FileName=CSceneNodeAnimatorFlyCircle.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit251] +FileName=CSceneNodeAnimatorFlyCircle.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit252] +FileName=CSceneNodeAnimatorFlyStraight.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit253] +FileName=CSceneNodeAnimatorFlyStraight.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit254] +FileName=CSceneNodeAnimatorFollowSpline.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit255] +FileName=CSceneNodeAnimatorFollowSpline.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit256] +FileName=CSceneNodeAnimatorRotation.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit257] +FileName=CSceneNodeAnimatorRotation.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit258] +FileName=CSceneNodeAnimatorTexture.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit259] +FileName=CSceneNodeAnimatorTexture.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit260] +FileName=CShadowVolumeSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit261] +FileName=CShadowVolumeSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit262] +FileName=CSkyBoxSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit263] +FileName=CSkyBoxSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit264] +FileName=COBJMeshFileLoader.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit265] +FileName=COBJMeshFileLoader.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit266] +FileName=CTerrainSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit267] +FileName=CTerrainSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit268] +FileName=CTerrainTriangleSelector.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit269] +FileName=CTerrainTriangleSelector.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit270] +FileName=CTextSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit271] +FileName=CTextSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit272] +FileName=CTriangleBBSelector.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit273] +FileName=CTriangleBBSelector.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit274] +FileName=CTriangleSelector.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit275] +FileName=CTriangleSelector.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit276] +FileName=CWaterSurfaceSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit277] +FileName=CWaterSurfaceSceneNode.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit278] +FileName=CXAnimationPlayer.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit279] +FileName=CXAnimationPlayer.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit280] +FileName=CXFileReader.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit281] +FileName=CXFileReader.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit282] +FileName=CXMeshFileLoader.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit283] +FileName=CXMeshFileLoader.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit284] +FileName=OctTree.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit285] +FileName=CFileList.cpp +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit286] +FileName=CFileList.h +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit287] +FileName=CFileSystem.cpp +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit288] +FileName=CFileSystem.h +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit289] +FileName=CLimitReadFile.cpp +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit290] +FileName=CLimitReadFile.h +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit291] +FileName=CMemoryReadFile.cpp +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit292] +FileName=CMemoryReadFile.h +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit293] +FileName=CReadFile.cpp +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit294] +FileName=CReadFile.h +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit295] +FileName=CWriteFile.cpp +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit296] +FileName=CWriteFile.h +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit297] +FileName=CXMLReader.cpp +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit298] +FileName=CXMLReader.h +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit299] +FileName=CXMLWriter.cpp +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit300] +FileName=CXMLWriter.h +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit301] +FileName=CZipReader.cpp +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit302] +FileName=CZipReader.h +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit303] +FileName=irrXML.cpp +Folder=io_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit304] +FileName=zlib\adler32.c +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit305] +FileName=zlib\compress.c +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit306] +FileName=zlib\crc32.c +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit307] +FileName=zlib\crc32.h +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit308] +FileName=zlib\deflate.c +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit309] +FileName=zlib\deflate.h +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit310] +FileName=zlib\inffast.c +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit311] +FileName=zlib\inffast.h +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit312] +FileName=zlib\inflate.c +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit313] +FileName=zlib\inftrees.c +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit314] +FileName=zlib\inftrees.h +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit315] +FileName=zlib\trees.c +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit316] +FileName=zlib\trees.h +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit317] +FileName=zlib\uncompr.c +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit318] +FileName=zlib\zconf.h +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit319] +FileName=zlib\zlib.h +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit320] +FileName=zlib\zutil.c +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit321] +FileName=zlib\zutil.h +Folder=other_impl/extern/zlib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit322] +FileName=jpeglib\cderror.h +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit323] +FileName=jpeglib\cdjpeg.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit324] +FileName=jpeglib\cdjpeg.h +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit325] +FileName=jpeglib\jcapimin.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit326] +FileName=jpeglib\jcapistd.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit327] +FileName=jpeglib\jccoefct.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit328] +FileName=jpeglib\jccolor.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit329] +FileName=jpeglib\jcdctmgr.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit330] +FileName=jpeglib\jchuff.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit331] +FileName=jpeglib\jchuff.h +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit332] +FileName=jpeglib\jcinit.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit333] +FileName=jpeglib\jcmainct.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit334] +FileName=jpeglib\jcmarker.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit335] +FileName=jpeglib\jcmaster.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit336] +FileName=jpeglib\jcomapi.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit337] +FileName=jpeglib\jconfig.h +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit338] +FileName=jpeglib\jcparam.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit339] +FileName=jpeglib\jcphuff.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit340] +FileName=jpeglib\jcprepct.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit341] +FileName=jpeglib\jcsample.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit342] +FileName=jpeglib\jctrans.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit343] +FileName=jpeglib\jdapimin.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit344] +FileName=jpeglib\jdapistd.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit345] +FileName=jpeglib\jdatadst.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit346] +FileName=jpeglib\jdatasrc.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit347] +FileName=jpeglib\jdcoefct.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit348] +FileName=jpeglib\jdcolor.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit349] +FileName=jpeglib\jdct.h +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit350] +FileName=jpeglib\jddctmgr.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit351] +FileName=jpeglib\jdhuff.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit352] +FileName=jpeglib\jdhuff.h +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit353] +FileName=jpeglib\jdinput.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit354] +FileName=jpeglib\jdmainct.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit355] +FileName=jpeglib\jdmarker.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit356] +FileName=jpeglib\jdmaster.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit357] +FileName=jpeglib\jdmerge.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit358] +FileName=jpeglib\jdphuff.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit359] +FileName=jpeglib\jdpostct.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit360] +FileName=jpeglib\jdsample.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit361] +FileName=jpeglib\jdtrans.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit362] +FileName=jpeglib\jerror.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit363] +FileName=jpeglib\jerror.h +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit364] +FileName=jpeglib\jfdctflt.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit365] +FileName=jpeglib\jfdctfst.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit366] +FileName=jpeglib\jfdctint.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit367] +FileName=jpeglib\jidctflt.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit368] +FileName=jpeglib\jidctfst.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit369] +FileName=jpeglib\jidctint.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit370] +FileName=jpeglib\jidctred.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit371] +FileName=jpeglib\jinclude.h +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit372] +FileName=jpeglib\jmemmgr.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit373] +FileName=jpeglib\jmemnobs.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit374] +FileName=jpeglib\jmemsys.h +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit375] +FileName=jpeglib\jmorecfg.h +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit376] +FileName=jpeglib\jpegint.h +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit377] +FileName=jpeglib\jpeglib.h +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit378] +FileName=jpeglib\jquant1.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit379] +FileName=jpeglib\jquant2.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit380] +FileName=jpeglib\jutils.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit381] +FileName=jpeglib\jversion.h +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit382] +FileName=jpeglib\rdbmp.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit383] +FileName=jpeglib\rdcolmap.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit384] +FileName=jpeglib\rdgif.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit385] +FileName=jpeglib\rdppm.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit386] +FileName=jpeglib\rdrle.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit387] +FileName=jpeglib\rdswitch.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit388] +FileName=jpeglib\rdtarga.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit389] +FileName=jpeglib\transupp.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit390] +FileName=jpeglib\transupp.h +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit391] +FileName=jpeglib\wrbmp.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit392] +FileName=jpeglib\wrgif.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit393] +FileName=jpeglib\wrppm.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit394] +FileName=jpeglib\wrrle.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit395] +FileName=jpeglib\wrtarga.c +Folder=other_impl/extern/jpeglib +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit396] +FileName=libpng\png.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit397] +FileName=libpng\png.h +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit398] +FileName=libpng\pngconf.h +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit399] +FileName=libpng\pngerror.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit400] +FileName=libpng\pngget.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit401] +FileName=libpng\pngmem.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit402] +FileName=libpng\pngpread.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit403] +FileName=libpng\pngread.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit404] +FileName=libpng\pngrio.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit405] +FileName=libpng\pngrtran.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit406] +FileName=libpng\pngrutil.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit407] +FileName=libpng\pngset.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit408] +FileName=libpng\pngtrans.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit409] +FileName=libpng\pngwio.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit410] +FileName=libpng\pngwrite.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit411] +FileName=libpng\pngwtran.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit412] +FileName=libpng\pngwutil.c +Folder=other_impl/extern/libpng +Compile=1 +CompileCpp=0 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit413] +FileName=CIrrDeviceLinux.cpp +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit414] +FileName=CIrrDeviceLinux.h +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit415] +FileName=CIrrDeviceStub.cpp +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit416] +FileName=CIrrDeviceStub.h +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit417] +FileName=CIrrDeviceWin32.cpp +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit418] +FileName=CIrrDeviceWin32.h +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit419] +FileName=CLogger.cpp +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit420] +FileName=CLogger.h +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit421] +FileName=COSOperator.cpp +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit422] +FileName=COSOperator.h +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit423] +FileName=CTimer.h +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit424] +FileName=IImagePresenter.h +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit425] +FileName=Irrlicht.cpp +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit426] +FileName=os.cpp +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit427] +FileName=os.h +Folder=other_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit428] +FileName=..\..\include\IrrCompileConfig.h +Folder=include +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit429] +FileName=CMeshCache.h +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit430] +FileName=CMeshCache.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit431] +FileName=COpenGLSLMaterialRenderer.h +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit432] +FileName=COpenGLSLMaterialRenderer.cpp +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit433] +FileName=CSoftwareTexture2.h +Folder=video_impl/Burning Video +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit434] +FileName=S4DVertex.h +Folder=video_impl/Burning Video +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit435] +FileName=SoftwareDriver2_compile_config.h +Folder=video_impl/Burning Video +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[VersionInfo] +Major=0 +Minor=1 +Release=1 +Build=1 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion=0.1 +FileDescription=Developed using the Dev-C++ IDE +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename=Irrlicht.dll +ProductName=Irrlicht +ProductVersion=0.1 +AutoIncBuildNr=0 + +[Unit436] +FileName=CSoftwareDriver2.h +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit437] +FileName=CTRTextureGouraudNoZ2.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit438] +FileName=CTRTextureLightMap2_M2.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit439] +FileName=CTRTextureLightMap2_M4.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit440] +FileName=CTRTextureLightMap2_M1.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit441] +FileName=SoftwareDriver2_helper.h +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit442] +FileName=CSoftwareDriver2.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit443] +FileName=CSoftwareTexture2.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit444] +FileName=CTRTextureGouraud2.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit445] +FileName=COgreMeshFileLoader.h +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit446] +FileName=COgreMeshFileLoader.cpp +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit447] +FileName=CDefaultSceneNodeFactory.h +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit448] +FileName=CDefaultSceneNodeAnimatorFactory.cpp +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit449] +FileName=CDefaultSceneNodeAnimatorFactory.h +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit450] +FileName=CDefaultSceneNodeFactory.cpp +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit451] +FileName=CAttributes.h +CompileCpp=1 +Folder=io_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit452] +FileName=CAttributeImpl.h +CompileCpp=1 +Folder=io_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit453] +FileName=CAttributes.cpp +CompileCpp=1 +Folder=io_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit454] +FileName=CCubeSceneNode.h +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit455] +FileName=CCubeSceneNode.cpp +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit456] +FileName=CTRTextureGouraudAddNoZ2.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit457] +FileName=CTRTextureGouraudAdd2.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit458] +FileName=CTRGouraud2.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit459] +FileName=CTRGouraudAlpha2.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit460] +FileName=CTRGouraudAlphaNoZ2.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit461] +FileName=CTRTextureDetailMap2.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit462] +FileName=CTRTextureLightMap2_Add.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit463] +FileName=CTRTextureWire2.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit464] +FileName=CTRTextureGouraudVertexAlpha2.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit465] +FileName=..\..\changes.txt +CompileCpp=1 +Folder=doc +Compile=0 +Link=0 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit466] +FileName=..\..\readme.txt +CompileCpp=1 +Folder=doc +Compile=0 +Link=0 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit467] +FileName=CSphereSceneNode.cpp +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit468] +FileName=CSphereSceneNode.h +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit469] +FileName=CPakReader.h +CompileCpp=1 +Folder=io_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit470] +FileName=CPakReader.cpp +CompileCpp=1 +Folder=io_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit471] +FileName=CAnimatedMeshB3d.h +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= +CompileCpp=1 + +[Unit472] +FileName=CAnimatedMeshB3d.cpp +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= +CompileCpp=1 + +[Unit473] +FileName=CSkyDomeSceneNode.h +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit474] +FileName=CSkyDomeSceneNode.cpp +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit475] +FileName=CImageWriterTGA.h +CompileCpp=1 +Folder=video_impl/Null +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit476] +FileName=CImageWriterBMP.cpp +CompileCpp=1 +Folder=video_impl/Null +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit477] +FileName=CImageWriterBMP.h +CompileCpp=1 +Folder=video_impl/Null +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit478] +FileName=CImageWriterJPG.cpp +CompileCpp=1 +Folder=video_impl/Null +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit479] +FileName=CImageWriterJPG.h +CompileCpp=1 +Folder=video_impl/Null +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit480] +FileName=CImageWriterPCX.cpp +CompileCpp=1 +Folder=video_impl/Null +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit481] +FileName=CImageWriterPCX.h +CompileCpp=1 +Folder=video_impl/Null +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit482] +FileName=CImageWriterPNG.cpp +CompileCpp=1 +Folder=video_impl/Null +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit483] +FileName=CImageWriterPNG.h +CompileCpp=1 +Folder=video_impl/Null +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit484] +FileName=CImageWriterPPM.cpp +CompileCpp=1 +Folder=video_impl/Null +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit485] +FileName=CImageWriterPPM.h +CompileCpp=1 +Folder=video_impl/Null +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit486] +FileName=CImageWriterPSD.cpp +CompileCpp=1 +Folder=video_impl/Null +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit487] +FileName=CImageWriterPSD.h +CompileCpp=1 +Folder=video_impl/Null +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit488] +FileName=CImageWriterTGA.cpp +CompileCpp=1 +Folder=video_impl/Null +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit489] +FileName=CTRTextureLightMapGouraud2_M4.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit490] +FileName=CGUIColorSelectDialog.cpp +CompileCpp=1 +Folder=gui_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit491] +FileName=IBurningShader.h +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit492] +FileName=IBurningShader.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit493] +FileName=IDepthBuffer.h +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit494] +FileName=CDepthBuffer.h +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit495] +FileName=CDepthBuffer.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit496] +FileName=CQuake3ShaderSceneNode.h +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit497] +FileName=CQuake3ShaderSceneNode.cpp +Folder=scene_impl +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit498] +FileName=..\..\include\fast_atof.h +CompileCpp=1 +Folder=include +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit499] +FileName=CTRTextureBlend.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit500] +FileName=CTRTextureGouraudAlpha.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit501] +FileName=CTRTextureGouraudAlphaNoZ.cpp +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit502] +FileName=CDefaultGUIElementFactory.cpp +CompileCpp=1 +Folder=gui_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit503] +FileName=CDefaultGUIElementFactory.h +CompileCpp=1 +Folder=gui_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit504] +FileName=CGUIColorSelectDialog.h +CompileCpp=1 +Folder=gui_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit505] +FileName=CSoftware2MaterialRenderer.h +CompileCpp=1 +Folder=video_impl/Burning Video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit506] +FileName=CXMLReaderImpl.h +CompileCpp=1 +Folder=io_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit507] +FileName=ITriangleRenderer.h +CompileCpp=1 +Folder=video_impl/Software +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit508] +FileName=..\..\include\EGUIElementTypes.h +CompileCpp=1 +Folder=include/gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit509] +FileName=..\..\include\ESceneNodeAnimatorTypes.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit510] +FileName=..\..\include\ESceneNodeTypes.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit511] +FileName=..\..\include\ETerrainElements.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit512] +FileName=..\..\include\IAnimatedMeshB3d.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit513] +FileName=..\..\include\IAnimatedMeshMD2.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit514] +FileName=..\..\include\IAnimatedMeshMS3D.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit515] +FileName=..\..\include\IAnimatedMeshX.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit516] +FileName=..\..\include\IAttributeExchangingObject.h +CompileCpp=1 +Folder=include/io +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit517] +FileName=..\..\include\IAttributes.h +CompileCpp=1 +Folder=include/io +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit518] +FileName=..\..\include\IDummyTransformationSceneNode.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit519] +FileName=..\..\include\IGPUProgrammingServices.h +CompileCpp=1 +Folder=include/video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit520] +FileName=..\..\include\IGUIColorSelectDialog.h +CompileCpp=1 +Folder=include/gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit521] +FileName=..\..\include\IGUIComboBox.h +CompileCpp=1 +Folder=include/gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit522] +FileName=..\..\include\IGUIContextMenu.h +CompileCpp=1 +Folder=include/gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit523] +FileName=..\..\include\IGUIEditBox.h +CompileCpp=1 +Folder=include/gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit524] +FileName=..\..\include\IGUIElementFactory.h +CompileCpp=1 +Folder=include/gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit525] +FileName=..\..\include\IGUIInOutFader.h +CompileCpp=1 +Folder=include/gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit526] +FileName=..\..\include\IGUIStaticText.h +CompileCpp=1 +Folder=include/gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit527] +FileName=..\..\include\IGUITabControl.h +CompileCpp=1 +Folder=include/gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit528] +FileName=..\..\include\IGUIToolbar.h +CompileCpp=1 +Folder=include/gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit529] +FileName=..\..\include\IImage.h +CompileCpp=1 +Folder=include/video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit530] +FileName=..\..\include\IImageLoader.h +CompileCpp=1 +Folder=include/video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit531] +FileName=..\..\include\IImageWriter.h +CompileCpp=1 +Folder=include/video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit532] +FileName=..\..\include\ILogger.h +CompileCpp=1 +Folder=include/io +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit533] +FileName=..\..\include\IMaterialRenderer.h +CompileCpp=1 +Folder=include/video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit534] +FileName=..\..\include\IMaterialRendererServices.h +CompileCpp=1 +Folder=include/video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit535] +FileName=..\..\include\IMeshCache.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit536] +FileName=..\..\include\IMeshLoader.h +CompileCpp=1 +Folder=include/io +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit537] +FileName=..\..\include\IMeshManipulator.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit538] +FileName=..\..\include\IMeshSceneNode.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit539] +FileName=..\..\include\IMetaTriangleSelector.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit540] +FileName=..\..\include\IOSOperator.h +CompileCpp=1 +Folder=include/io +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit541] +FileName=..\..\include\IParticleAffector.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit542] +FileName=..\..\include\IParticleEmitter.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit543] +FileName=..\..\include\IParticleSystemSceneNode.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit544] +FileName=..\..\include\IQ3Shader.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit545] +FileName=..\..\include\irrAllocator.h +CompileCpp=1 +Folder=include/core +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit546] +FileName=..\..\include\irrMap.h +CompileCpp=1 +Folder=include/core +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit547] +FileName=..\..\include\irrXML.h +CompileCpp=1 +Folder=include/io +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit548] +FileName=..\..\include\ISceneCollisionManager.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit549] +FileName=..\..\include\ISceneNodeAnimatorCollisionResponse.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit550] +FileName=..\..\include\ISceneNodeAnimatorFactory.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit551] +FileName=..\..\include\ISceneNodeFactory.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit552] +FileName=..\..\include\ISceneUserDataSerializer.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit553] +FileName=..\..\include\IShaderConstantSetCallBack.h +CompileCpp=1 +Folder=include/video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit554] +FileName=..\..\include\IShadowVolumeSceneNode.h +CompileCpp=1 +Folder=include/video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit555] +FileName=..\..\include\ITerrainSceneNode.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit556] +FileName=..\..\include\ITextSceneNode.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit557] +FileName=..\..\include\ITimer.h +CompileCpp=1 +Folder=include +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit558] +FileName=..\..\include\ITriangleSelector.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit559] +FileName=..\..\include\IVideoModeList.h +CompileCpp=1 +Folder=include/video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit560] +FileName=..\..\include\IWriteFile.h +CompileCpp=1 +Folder=include/io +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit561] +FileName=..\..\include\IXMLReader.h +CompileCpp=1 +Folder=include/io +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit562] +FileName=..\..\include\IXMLWriter.h +CompileCpp=1 +Folder=include/io +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit563] +FileName=..\..\include\quaternion.h +CompileCpp=1 +Folder=include/core +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit564] +FileName=..\..\include\SAnimatedMesh.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit565] +FileName=..\..\include\SceneParameters.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit566] +FileName=..\..\include\SExposedVideoData.h +CompileCpp=1 +Folder=include/video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit567] +FileName=..\..\include\SKeyMap.h +CompileCpp=1 +Folder=include +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit568] +FileName=..\..\include\SMeshBufferTangents.h +CompileCpp=1 +Folder=include/video +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit569] +FileName=..\..\include\SParticle.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit570] +FileName=..\..\include\SViewFrustum.h +CompileCpp=1 +Folder=include/scene +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit571] +FileName=..\..\include\triangle3d.h +CompileCpp=1 +Folder=include/core +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit572] +FileName=CMD3MeshFileLoader.h +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit573] +FileName=CMD3MeshFileLoader.cpp +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit574] +FileName=CAnimatedMeshMD3.h +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit575] +FileName=CAnimatedMeshMD3.cpp +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit576] +FileName=CGUISpriteBank.h +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit577] +FileName=CGUISpriteBank.cpp +CompileCpp=1 +Folder=scene_impl +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit578] +FileName=..\..\include\IGUIFontBitmap.h +CompileCpp=1 +Folder=include/gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit579] +FileName=..\..\include\IGUISpriteBank.h +CompileCpp=1 +Folder=include/gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/src/dep/src/irrlicht/Irrlicht.dsp b/src/dep/src/irrlicht/Irrlicht.dsp index c35215b..7892e7b 100644 --- a/src/dep/src/irrlicht/Irrlicht.dsp +++ b/src/dep/src/irrlicht/Irrlicht.dsp @@ -1,2253 +1,2253 @@ -# Microsoft Developer Studio Project File - Name="Irrlicht" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** NICHT BEARBEITEN ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=Irrlicht - Win32 Debug -!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE -!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl -!MESSAGE -!MESSAGE NMAKE /f "Irrlicht.mak". -!MESSAGE -!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben -!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: -!MESSAGE -!MESSAGE NMAKE /f "Irrlicht.mak" CFG="Irrlicht - Win32 Debug" -!MESSAGE -!MESSAGE Für die Konfiguration stehen zur Auswahl: -!MESSAGE -!MESSAGE "Irrlicht - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") -!MESSAGE "Irrlicht - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "Irrlicht - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\Release" -# PROP Intermediate_Dir "..\Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IRRLICHT_EXPORTS" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../include" /I "zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IRRLICHT_EXPORTS" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc07 /d "NDEBUG" -# ADD RSC /l 0xc07 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 - -!ELSEIF "$(CFG)" == "Irrlicht - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\Debug" -# PROP Intermediate_Dir "..\Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IRRLICHT_EXPORTS" /Yu"stdafx.h" /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /I "zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IRRLICHT_EXPORTS" /FD /GZ /c -# SUBTRACT CPP /YX /Yc /Yu -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc07 /d "_DEBUG" -# ADD RSC /l 0xc07 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "Irrlicht - Win32 Release" -# Name "Irrlicht - Win32 Debug" -# Begin Group "include" - -# PROP Default_Filter "" -# Begin Group "video" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\include\EDriverTypes.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGPUProgrammingServices.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\ITexture.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IVideoDriver.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\S3DVertex.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\SColor.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\SLight.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\SMaterial.h -# End Source File -# End Group -# Begin Group "core" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\include\aabbox3d.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\dimension2d.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\heapsort.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\irrAllocator.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\irrArray.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\irrList.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\irrMath.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\irrString.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\line2d.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\line3d.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\matrix4.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\plane3d.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\position2d.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\rect.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\vector2d.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\vector3d.h -# End Source File -# End Group -# Begin Group "io" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\include\IFileList.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IFileSystem.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IReadFile.H -# End Source File -# End Group -# Begin Group "scene" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\include\IAnimatedMesh.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IAnimatedMeshSceneNode.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IBillboardSceneNode.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\ICameraSceneNode.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\ILightSceneNode.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IMesh.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IMeshBuffer.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IQ3LevelMesh.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\ISceneManager.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\ISceneNode.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\ISceneNodeAnimator.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\SMesh.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\SMeshBuffer.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\SMeshBufferLightMap.h -# End Source File -# End Group -# Begin Group "gui" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\include\ICursorControl.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIButton.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUICheckbox.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIElement.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIEnvironment.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIFileOpenDialog.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIFont.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIImage.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIListBox.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIMeshViewer.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIScrollBar.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUISkin.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIWindow.h -# End Source File -# End Group -# Begin Source File - -SOURCE=..\..\include\IEventReceiver.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\Irrlicht.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IrrlichtDevice.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\irrTypes.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IUnknown.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\Keycodes.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\SIrrCreationParameters.h -# End Source File -# End Group -# Begin Group "gui_impl" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\BuiltInFont.h -# End Source File -# Begin Source File - -SOURCE=.\CDefaultGUIElementFactory.cpp -# End Source File -# Begin Source File - -SOURCE=.\CDefaultGUIElementFactory.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIButton.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIButton.h -# End Source File -# Begin Source File - -SOURCE=.\CGUICheckBox.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUICheckbox.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIColorSelectDialog.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIColorSelectDialog.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIComboBox.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIComboBox.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIContextMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIContextMenu.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIEditBox.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIEditBox.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIEnvironment.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIEnvironment.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIFileOpenDialog.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIFileOpenDialog.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIFont.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIFont.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIImage.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIImage.H -# End Source File -# Begin Source File - -SOURCE=.\CGUIInOutFader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIInOutFader.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIListBox.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIListBox.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIMenu.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIMeshViewer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIMeshViewer.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIMessageBox.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIMessageBox.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIModalScreen.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIModalScreen.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIScrollBar.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIScrollBar.h -# End Source File -# Begin Source File - -SOURCE=.\CGUISkin.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUISkin.h -# End Source File -# Begin Source File - -SOURCE=.\CGUISpriteBank.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUISpriteBank.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIStaticText.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIStaticText.h -# End Source File -# Begin Source File - -SOURCE=.\CGUITabControl.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUITabControl.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIToolBar.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIToolBar.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIWindow.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIWindow.h -# End Source File -# Begin Source File - -SOURCE=.\GUIIcons.h -# End Source File -# End Group -# Begin Group "video_impl" - -# PROP Default_Filter "" -# Begin Group "Software" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\CSoftwareDriver.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSoftwareDriver.h -# End Source File -# Begin Source File - -SOURCE=.\CSoftwareTexture.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSoftwareTexture.h -# End Source File -# Begin Source File - -SOURCE=.\CTRFlat.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRFlatWire.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRGouraud.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRGouraudWire.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureFlat.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureFlatWire.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraud.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraud.h -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudAdd.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudNoZ.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudWire.cpp -# End Source File -# Begin Source File - -SOURCE=.\CZBuffer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CZBuffer.h -# End Source File -# Begin Source File - -SOURCE=.\ITriangleRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\IZBuffer.h -# End Source File -# Begin Source File - -SOURCE=.\S2DVertex.h -# End Source File -# End Group -# Begin Group "OpenGL" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\COpenGLDriver.cpp -# End Source File -# Begin Source File - -SOURCE=.\COpenGLDriver.h -# End Source File -# Begin Source File - -SOURCE=.\COpenGLMaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\COpenGLNormalMapRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\COpenGLNormalMapRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\COpenGLParallaxMapRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\COpenGLParallaxMapRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\COpenGLShaderMaterialRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\COpenGLShaderMaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\COpenGLSLMaterialRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\COpenGLSLMaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\COpenGLTexture.cpp -# End Source File -# Begin Source File - -SOURCE=.\COpenGLTexture.h -# End Source File -# Begin Source File - -SOURCE=.\glext.h -# End Source File -# End Group -# Begin Group "DirectX8" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\CD3D8Driver.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D8Driver.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D8MaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D8NormalMapRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D8NormalMapRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D8ParallaxMapRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D8ParallaxMapRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D8ShaderMaterialRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D8ShaderMaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D8Texture.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D8Texture.h -# End Source File -# End Group -# Begin Group "Null" - -# PROP Default_Filter "" -# Begin Group "ImageWriter" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\CImageWriterBMP.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterBMP.h -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterJPG.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterJPG.h -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPCX.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPCX.h -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPNG.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPNG.h -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPPM.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPPM.h -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPSD.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPSD.h -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterTGA.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterTGA.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\CColorConverter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CColorConverter.h -# End Source File -# Begin Source File - -SOURCE=.\CFPSCounter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CFPSCounter.h -# End Source File -# Begin Source File - -SOURCE=.\CImage.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImage.h -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderBMP.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderBMP.h -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderJPG.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderJPG.h -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderPCX.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderPCX.h -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderPNG.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderPNG.h -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderPSD.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderPSD.h -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderTGA.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderTGA.h -# End Source File -# Begin Source File - -SOURCE=.\CNullDriver.cpp -# End Source File -# Begin Source File - -SOURCE=.\CNullDriver.h -# End Source File -# End Group -# Begin Group "DirectX9" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\CD3D9Driver.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D9Driver.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D9HLSLMaterialRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D9HLSLMaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D9MaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D9NormalMapRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D9NormalMapRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D9ParallaxMapRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D9ParallaxMapRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D9ShaderMaterialRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D9ShaderMaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D9Texture.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D9Texture.h -# End Source File -# End Group -# Begin Group "Software2" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\CDepthBuffer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CDepthBuffer.h -# End Source File -# Begin Source File - -SOURCE=.\CSoftware2MaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CSoftwareDriver2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSoftwareDriver2.h -# End Source File -# Begin Source File - -SOURCE=.\CSoftwareTexture2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSoftwareTexture2.h -# End Source File -# Begin Source File - -SOURCE=.\CTRGouraud2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRGouraudAlpha2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRGouraudAlphaNoZ2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureBlend.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureDetailMap2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraud2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudAdd2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudAddNoZ2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudAlpha.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudAlphaNoZ.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudNoZ2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudVertexAlpha2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureLightMap2_Add.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureLightMap2_M1.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureLightMap2_M1.h -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureLightMap2_M2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureLightMap2_M4.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureLightMapGouraud2_M4.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureWire2.cpp -# End Source File -# Begin Source File - -SOURCE=.\IBurningShader.cpp -# End Source File -# Begin Source File - -SOURCE=.\IBurningShader.h -# End Source File -# Begin Source File - -SOURCE=.\IDepthBuffer.h -# End Source File -# Begin Source File - -SOURCE=.\S4DVertex.h -# End Source File -# Begin Source File - -SOURCE=.\SoftwareDriver2_compile_config.h -# End Source File -# Begin Source File - -SOURCE=.\SoftwareDriver2_helper.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\CVideoModeList.cpp -# End Source File -# Begin Source File - -SOURCE=.\CVideoModeList.h -# End Source File -# End Group -# Begin Group "scene_impl" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\C3DSMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\C3DSMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshB3d.cpp -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshB3d.h -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshMD2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshMD2.h -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshMD3.cpp -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshMD3.h -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshMS3D.cpp -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshMS3D.h -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CBillboardSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CBillboardSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CCameraFPSSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CCameraFPSSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CCameraMayaSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CCameraMayaSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CCameraSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CCameraSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CColladaFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CColladaFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CCSMLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CCSMLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CCubeSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CCubeSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CDefaultMeshFormatLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CDefaultMeshFormatLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CDefaultSceneNodeAnimatorFactory.cpp -# End Source File -# Begin Source File - -SOURCE=.\CDefaultSceneNodeAnimatorFactory.h -# End Source File -# Begin Source File - -SOURCE=.\CDefaultSceneNodeFactory.cpp -# End Source File -# Begin Source File - -SOURCE=.\CDefaultSceneNodeFactory.h -# End Source File -# Begin Source File - -SOURCE=.\CDMFLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CDMFLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CDummyTransformationSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CDummyTransformationSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CEmptySceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CEmptySceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CGeometryCreator.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGeometryCreator.h -# End Source File -# Begin Source File - -SOURCE=.\CLightSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CLightSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CLMTSMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CLMTSMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CMD3MeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMD3MeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CMeshCache.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMeshCache.h -# End Source File -# Begin Source File - -SOURCE=.\CMeshManipulator.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMeshManipulator.h -# End Source File -# Begin Source File - -SOURCE=.\CMeshSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMeshSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CMetaTriangleSelector.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMetaTriangleSelector.h -# End Source File -# Begin Source File - -SOURCE=.\CMY3DHelper.h -# End Source File -# Begin Source File - -SOURCE=.\CMY3DMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMY3DMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CMY3DStuff.h -# End Source File -# Begin Source File - -SOURCE=.\COBJMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\COBJMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\COCTLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\COCTLoader.h -# End Source File -# Begin Source File - -SOURCE=.\COctTreeSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\COctTreeSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\COctTreeTriangleSelector.cpp -# End Source File -# Begin Source File - -SOURCE=.\COctTreeTriangleSelector.h -# End Source File -# Begin Source File - -SOURCE=.\COgreMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\COgreMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleBoxEmitter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleBoxEmitter.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleFadeOutAffector.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleFadeOutAffector.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleGravityAffector.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleGravityAffector.h -# End Source File -# Begin Source File - -SOURCE=.\CParticlePointEmitter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticlePointEmitter.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleSystemSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleSystemSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CQ3LevelMesh.cpp -# End Source File -# Begin Source File - -SOURCE=.\CQ3LevelMesh.h -# End Source File -# Begin Source File - -SOURCE=.\CQuake3ShaderSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CQuake3ShaderSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneCollisionManager.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneCollisionManager.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneManager.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneManager.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorCollisionResponse.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorCollisionResponse.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorDelete.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorDelete.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorFlyCircle.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorFlyCircle.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorFlyStraight.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorFlyStraight.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorFollowSpline.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorFollowSpline.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorRotation.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorRotation.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorTexture.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorTexture.h -# End Source File -# Begin Source File - -SOURCE=.\CShadowVolumeSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CShadowVolumeSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CSkyBoxSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSkyBoxSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CSkyDomeSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSkyDomeSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CSphereSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSphereSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CTerrainSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTerrainSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CTerrainTriangleSelector.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTerrainTriangleSelector.h -# End Source File -# Begin Source File - -SOURCE=.\CTextSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTextSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CTriangleBBSelector.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTriangleBBSelector.h -# End Source File -# Begin Source File - -SOURCE=.\CTriangleSelector.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTriangleSelector.h -# End Source File -# Begin Source File - -SOURCE=.\CWaterSurfaceSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CWaterSurfaceSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CXAnimationPlayer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CXAnimationPlayer.h -# End Source File -# Begin Source File - -SOURCE=.\CXFileReader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CXFileReader.h -# End Source File -# Begin Source File - -SOURCE=.\CXMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CXMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\dmfsupport.h -# End Source File -# Begin Source File - -SOURCE=.\OctTree.h -# End Source File -# End Group -# Begin Group "io_impl" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\CAttributeImpl.h -# End Source File -# Begin Source File - -SOURCE=.\CAttributes.cpp -# End Source File -# Begin Source File - -SOURCE=.\CAttributes.h -# End Source File -# Begin Source File - -SOURCE=.\CFileList.cpp -# End Source File -# Begin Source File - -SOURCE=.\CFileList.h -# End Source File -# Begin Source File - -SOURCE=.\CFileSystem.cpp -# End Source File -# Begin Source File - -SOURCE=.\CFileSystem.h -# End Source File -# Begin Source File - -SOURCE=.\CLimitReadFile.cpp -# End Source File -# Begin Source File - -SOURCE=.\CLimitReadFile.h -# End Source File -# Begin Source File - -SOURCE=.\CMemoryReadFile.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMemoryReadFile.h -# End Source File -# Begin Source File - -SOURCE=.\CPakReader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CPakReader.h -# End Source File -# Begin Source File - -SOURCE=.\CReadFile.cpp -# End Source File -# Begin Source File - -SOURCE=.\CReadFile.h -# End Source File -# Begin Source File - -SOURCE=.\CWriteFile.cpp -# End Source File -# Begin Source File - -SOURCE=.\CWriteFile.h -# End Source File -# Begin Source File - -SOURCE=.\CXMLReader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CXMLReader.h -# End Source File -# Begin Source File - -SOURCE=.\CXMLReaderImpl.h -# End Source File -# Begin Source File - -SOURCE=.\CXMLWriter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CXMLWriter.h -# End Source File -# Begin Source File - -SOURCE=.\CZipReader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CZipReader.h -# End Source File -# Begin Source File - -SOURCE=.\irrXML.cpp -# End Source File -# End Group -# Begin Group "other_impl" - -# PROP Default_Filter "" -# Begin Group "extern" - -# PROP Default_Filter "" -# Begin Group "zlib" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\zlib\adler32.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\compress.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\crc32.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\crc32.h -# End Source File -# Begin Source File - -SOURCE=.\zlib\deflate.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\deflate.h -# End Source File -# Begin Source File - -SOURCE=.\zlib\inffast.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\inffast.h -# End Source File -# Begin Source File - -SOURCE=.\zlib\inflate.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\inftrees.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\inftrees.h -# End Source File -# Begin Source File - -SOURCE=.\zlib\trees.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\trees.h -# End Source File -# Begin Source File - -SOURCE=.\zlib\uncompr.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\zconf.h -# End Source File -# Begin Source File - -SOURCE=.\zlib\zlib.h -# End Source File -# Begin Source File - -SOURCE=.\zlib\zutil.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\zutil.h -# End Source File -# End Group -# Begin Group "jpeglib" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\jpeglib\cderror.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\cdjpeg.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\cdjpeg.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcapimin.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcapistd.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jccoefct.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jccolor.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcdctmgr.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jchuff.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jchuff.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcinit.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcmainct.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcmarker.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcmaster.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcomapi.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jconfig.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcparam.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcphuff.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcprepct.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcsample.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jctrans.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdapimin.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdapistd.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdatadst.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdatasrc.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdcoefct.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdcolor.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdct.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jddctmgr.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdhuff.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdhuff.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdinput.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdmainct.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdmarker.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdmaster.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdmerge.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdphuff.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdpostct.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdsample.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdtrans.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jerror.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jerror.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jfdctflt.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jfdctfst.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jfdctint.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jidctflt.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jidctfst.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jidctint.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jidctred.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jinclude.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jmemmgr.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jmemnobs.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jmemsys.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jmorecfg.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jpegint.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jpeglib.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jquant1.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jquant2.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jutils.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jversion.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\rdbmp.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\rdcolmap.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\rdgif.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\rdppm.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\rdrle.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\rdswitch.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\rdtarga.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\transupp.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\transupp.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\wrbmp.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\wrgif.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\wrppm.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\wrrle.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\wrtarga.c -# End Source File -# End Group -# Begin Group "libpng" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\libpng\png.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\png.h -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngconf.h -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngerror.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngget.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngmem.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngpread.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngread.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngrio.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngrtran.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngrutil.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngset.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngtrans.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngwio.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngwrite.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngwtran.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngwutil.c -# End Source File -# End Group -# End Group -# Begin Source File - -SOURCE=.\CIrrDeviceLinux.cpp -# End Source File -# Begin Source File - -SOURCE=.\CIrrDeviceLinux.h -# End Source File -# Begin Source File - -SOURCE=.\CIrrDeviceStub.cpp -# End Source File -# Begin Source File - -SOURCE=.\CIrrDeviceStub.h -# End Source File -# Begin Source File - -SOURCE=.\CIrrDeviceWin32.cpp -# End Source File -# Begin Source File - -SOURCE=.\CIrrDeviceWin32.h -# End Source File -# Begin Source File - -SOURCE=.\CLogger.cpp -# End Source File -# Begin Source File - -SOURCE=.\CLogger.h -# End Source File -# Begin Source File - -SOURCE=.\COSOperator.cpp -# End Source File -# Begin Source File - -SOURCE=.\COSOperator.h -# End Source File -# Begin Source File - -SOURCE=.\CTimer.h -# End Source File -# Begin Source File - -SOURCE=.\fast_atof.h -# End Source File -# Begin Source File - -SOURCE=.\IImagePresenter.h -# End Source File -# Begin Source File - -SOURCE=.\Irrlicht.cpp -# End Source File -# Begin Source File - -SOURCE=.\os.cpp -# End Source File -# Begin Source File - -SOURCE=.\os.h -# End Source File -# End Group -# Begin Group "doc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\changes.txt -# End Source File -# End Group -# Begin Source File - -SOURCE=.\glxext.h -# End Source File -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="Irrlicht" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=Irrlicht - Win32 Debug +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "Irrlicht.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "Irrlicht.mak" CFG="Irrlicht - Win32 Debug" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "Irrlicht - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Irrlicht - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Irrlicht - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "..\Release" +# PROP Intermediate_Dir "..\Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IRRLICHT_EXPORTS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../include" /I "zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IRRLICHT_EXPORTS" /FD /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "NDEBUG" +# ADD RSC /l 0xc07 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 + +!ELSEIF "$(CFG)" == "Irrlicht - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "..\Debug" +# PROP Intermediate_Dir "..\Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IRRLICHT_EXPORTS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /I "zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IRRLICHT_EXPORTS" /FD /GZ /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "_DEBUG" +# ADD RSC /l 0xc07 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "Irrlicht - Win32 Release" +# Name "Irrlicht - Win32 Debug" +# Begin Group "include" + +# PROP Default_Filter "" +# Begin Group "video" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\include\EDriverTypes.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IGPUProgrammingServices.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\ITexture.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IVideoDriver.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\S3DVertex.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\SColor.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\SLight.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\SMaterial.h +# End Source File +# End Group +# Begin Group "core" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\include\aabbox3d.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\dimension2d.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\heapsort.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\irrAllocator.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\irrArray.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\irrList.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\irrMath.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\irrString.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\line2d.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\line3d.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\matrix4.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\plane3d.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\position2d.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\rect.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\vector2d.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\vector3d.h +# End Source File +# End Group +# Begin Group "io" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\include\IFileList.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IFileSystem.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IReadFile.H +# End Source File +# End Group +# Begin Group "scene" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\include\IAnimatedMesh.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IAnimatedMeshSceneNode.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IBillboardSceneNode.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\ICameraSceneNode.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\ILightSceneNode.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IMesh.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IMeshBuffer.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IQ3LevelMesh.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\ISceneManager.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\ISceneNode.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\ISceneNodeAnimator.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\SMesh.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\SMeshBuffer.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\SMeshBufferLightMap.h +# End Source File +# End Group +# Begin Group "gui" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\include\ICursorControl.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IGUIButton.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IGUICheckbox.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IGUIElement.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IGUIEnvironment.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IGUIFileOpenDialog.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IGUIFont.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IGUIImage.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IGUIListBox.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IGUIMeshViewer.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IGUIScrollBar.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IGUISkin.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IGUIWindow.h +# End Source File +# End Group +# Begin Source File + +SOURCE=..\..\include\IEventReceiver.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\Irrlicht.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IrrlichtDevice.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\irrTypes.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\IUnknown.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\Keycodes.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\SIrrCreationParameters.h +# End Source File +# End Group +# Begin Group "gui_impl" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\BuiltInFont.h +# End Source File +# Begin Source File + +SOURCE=.\CDefaultGUIElementFactory.cpp +# End Source File +# Begin Source File + +SOURCE=.\CDefaultGUIElementFactory.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIButton.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIButton.h +# End Source File +# Begin Source File + +SOURCE=.\CGUICheckBox.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUICheckbox.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIColorSelectDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIColorSelectDialog.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIComboBox.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIComboBox.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIContextMenu.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIContextMenu.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIEditBox.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIEditBox.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIEnvironment.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIEnvironment.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIFileOpenDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIFileOpenDialog.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIFont.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIFont.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIImage.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIImage.H +# End Source File +# Begin Source File + +SOURCE=.\CGUIInOutFader.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIInOutFader.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIListBox.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIListBox.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIMenu.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIMenu.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIMeshViewer.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIMeshViewer.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIMessageBox.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIMessageBox.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIModalScreen.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIModalScreen.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIScrollBar.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIScrollBar.h +# End Source File +# Begin Source File + +SOURCE=.\CGUISkin.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUISkin.h +# End Source File +# Begin Source File + +SOURCE=.\CGUISpriteBank.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUISpriteBank.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIStaticText.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIStaticText.h +# End Source File +# Begin Source File + +SOURCE=.\CGUITabControl.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUITabControl.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIToolBar.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIToolBar.h +# End Source File +# Begin Source File + +SOURCE=.\CGUIWindow.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGUIWindow.h +# End Source File +# Begin Source File + +SOURCE=.\GUIIcons.h +# End Source File +# End Group +# Begin Group "video_impl" + +# PROP Default_Filter "" +# Begin Group "Software" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\CSoftwareDriver.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSoftwareDriver.h +# End Source File +# Begin Source File + +SOURCE=.\CSoftwareTexture.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSoftwareTexture.h +# End Source File +# Begin Source File + +SOURCE=.\CTRFlat.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRFlatWire.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRGouraud.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRGouraudWire.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureFlat.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureFlatWire.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureGouraud.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureGouraud.h +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureGouraudAdd.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureGouraudNoZ.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureGouraudWire.cpp +# End Source File +# Begin Source File + +SOURCE=.\CZBuffer.cpp +# End Source File +# Begin Source File + +SOURCE=.\CZBuffer.h +# End Source File +# Begin Source File + +SOURCE=.\ITriangleRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\IZBuffer.h +# End Source File +# Begin Source File + +SOURCE=.\S2DVertex.h +# End Source File +# End Group +# Begin Group "OpenGL" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\COpenGLDriver.cpp +# End Source File +# Begin Source File + +SOURCE=.\COpenGLDriver.h +# End Source File +# Begin Source File + +SOURCE=.\COpenGLMaterialRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\COpenGLNormalMapRenderer.cpp +# End Source File +# Begin Source File + +SOURCE=.\COpenGLNormalMapRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\COpenGLParallaxMapRenderer.cpp +# End Source File +# Begin Source File + +SOURCE=.\COpenGLParallaxMapRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\COpenGLShaderMaterialRenderer.cpp +# End Source File +# Begin Source File + +SOURCE=.\COpenGLShaderMaterialRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\COpenGLSLMaterialRenderer.cpp +# End Source File +# Begin Source File + +SOURCE=.\COpenGLSLMaterialRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\COpenGLTexture.cpp +# End Source File +# Begin Source File + +SOURCE=.\COpenGLTexture.h +# End Source File +# Begin Source File + +SOURCE=.\glext.h +# End Source File +# End Group +# Begin Group "DirectX8" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\CD3D8Driver.cpp +# End Source File +# Begin Source File + +SOURCE=.\CD3D8Driver.h +# End Source File +# Begin Source File + +SOURCE=.\CD3D8MaterialRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\CD3D8NormalMapRenderer.cpp +# End Source File +# Begin Source File + +SOURCE=.\CD3D8NormalMapRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\CD3D8ParallaxMapRenderer.cpp +# End Source File +# Begin Source File + +SOURCE=.\CD3D8ParallaxMapRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\CD3D8ShaderMaterialRenderer.cpp +# End Source File +# Begin Source File + +SOURCE=.\CD3D8ShaderMaterialRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\CD3D8Texture.cpp +# End Source File +# Begin Source File + +SOURCE=.\CD3D8Texture.h +# End Source File +# End Group +# Begin Group "Null" + +# PROP Default_Filter "" +# Begin Group "ImageWriter" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\CImageWriterBMP.cpp +# End Source File +# Begin Source File + +SOURCE=.\CImageWriterBMP.h +# End Source File +# Begin Source File + +SOURCE=.\CImageWriterJPG.cpp +# End Source File +# Begin Source File + +SOURCE=.\CImageWriterJPG.h +# End Source File +# Begin Source File + +SOURCE=.\CImageWriterPCX.cpp +# End Source File +# Begin Source File + +SOURCE=.\CImageWriterPCX.h +# End Source File +# Begin Source File + +SOURCE=.\CImageWriterPNG.cpp +# End Source File +# Begin Source File + +SOURCE=.\CImageWriterPNG.h +# End Source File +# Begin Source File + +SOURCE=.\CImageWriterPPM.cpp +# End Source File +# Begin Source File + +SOURCE=.\CImageWriterPPM.h +# End Source File +# Begin Source File + +SOURCE=.\CImageWriterPSD.cpp +# End Source File +# Begin Source File + +SOURCE=.\CImageWriterPSD.h +# End Source File +# Begin Source File + +SOURCE=.\CImageWriterTGA.cpp +# End Source File +# Begin Source File + +SOURCE=.\CImageWriterTGA.h +# End Source File +# End Group +# Begin Source File + +SOURCE=.\CColorConverter.cpp +# End Source File +# Begin Source File + +SOURCE=.\CColorConverter.h +# End Source File +# Begin Source File + +SOURCE=.\CFPSCounter.cpp +# End Source File +# Begin Source File + +SOURCE=.\CFPSCounter.h +# End Source File +# Begin Source File + +SOURCE=.\CImage.cpp +# End Source File +# Begin Source File + +SOURCE=.\CImage.h +# End Source File +# Begin Source File + +SOURCE=.\CImageLoaderBMP.cpp +# End Source File +# Begin Source File + +SOURCE=.\CImageLoaderBMP.h +# End Source File +# Begin Source File + +SOURCE=.\CImageLoaderJPG.cpp +# End Source File +# Begin Source File + +SOURCE=.\CImageLoaderJPG.h +# End Source File +# Begin Source File + +SOURCE=.\CImageLoaderPCX.cpp +# End Source File +# Begin Source File + +SOURCE=.\CImageLoaderPCX.h +# End Source File +# Begin Source File + +SOURCE=.\CImageLoaderPNG.cpp +# End Source File +# Begin Source File + +SOURCE=.\CImageLoaderPNG.h +# End Source File +# Begin Source File + +SOURCE=.\CImageLoaderPSD.cpp +# End Source File +# Begin Source File + +SOURCE=.\CImageLoaderPSD.h +# End Source File +# Begin Source File + +SOURCE=.\CImageLoaderTGA.cpp +# End Source File +# Begin Source File + +SOURCE=.\CImageLoaderTGA.h +# End Source File +# Begin Source File + +SOURCE=.\CNullDriver.cpp +# End Source File +# Begin Source File + +SOURCE=.\CNullDriver.h +# End Source File +# End Group +# Begin Group "DirectX9" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\CD3D9Driver.cpp +# End Source File +# Begin Source File + +SOURCE=.\CD3D9Driver.h +# End Source File +# Begin Source File + +SOURCE=.\CD3D9HLSLMaterialRenderer.cpp +# End Source File +# Begin Source File + +SOURCE=.\CD3D9HLSLMaterialRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\CD3D9MaterialRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\CD3D9NormalMapRenderer.cpp +# End Source File +# Begin Source File + +SOURCE=.\CD3D9NormalMapRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\CD3D9ParallaxMapRenderer.cpp +# End Source File +# Begin Source File + +SOURCE=.\CD3D9ParallaxMapRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\CD3D9ShaderMaterialRenderer.cpp +# End Source File +# Begin Source File + +SOURCE=.\CD3D9ShaderMaterialRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\CD3D9Texture.cpp +# End Source File +# Begin Source File + +SOURCE=.\CD3D9Texture.h +# End Source File +# End Group +# Begin Group "Software2" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\CDepthBuffer.cpp +# End Source File +# Begin Source File + +SOURCE=.\CDepthBuffer.h +# End Source File +# Begin Source File + +SOURCE=.\CSoftware2MaterialRenderer.h +# End Source File +# Begin Source File + +SOURCE=.\CSoftwareDriver2.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSoftwareDriver2.h +# End Source File +# Begin Source File + +SOURCE=.\CSoftwareTexture2.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSoftwareTexture2.h +# End Source File +# Begin Source File + +SOURCE=.\CTRGouraud2.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRGouraudAlpha2.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRGouraudAlphaNoZ2.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureBlend.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureDetailMap2.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureGouraud2.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureGouraudAdd2.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureGouraudAddNoZ2.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureGouraudAlpha.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureGouraudAlphaNoZ.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureGouraudNoZ2.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureGouraudVertexAlpha2.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureLightMap2_Add.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureLightMap2_M1.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureLightMap2_M1.h +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureLightMap2_M2.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureLightMap2_M4.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureLightMapGouraud2_M4.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTRTextureWire2.cpp +# End Source File +# Begin Source File + +SOURCE=.\IBurningShader.cpp +# End Source File +# Begin Source File + +SOURCE=.\IBurningShader.h +# End Source File +# Begin Source File + +SOURCE=.\IDepthBuffer.h +# End Source File +# Begin Source File + +SOURCE=.\S4DVertex.h +# End Source File +# Begin Source File + +SOURCE=.\SoftwareDriver2_compile_config.h +# End Source File +# Begin Source File + +SOURCE=.\SoftwareDriver2_helper.h +# End Source File +# End Group +# Begin Source File + +SOURCE=.\CVideoModeList.cpp +# End Source File +# Begin Source File + +SOURCE=.\CVideoModeList.h +# End Source File +# End Group +# Begin Group "scene_impl" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\C3DSMeshFileLoader.cpp +# End Source File +# Begin Source File + +SOURCE=.\C3DSMeshFileLoader.h +# End Source File +# Begin Source File + +SOURCE=.\CAnimatedMeshB3d.cpp +# End Source File +# Begin Source File + +SOURCE=.\CAnimatedMeshB3d.h +# End Source File +# Begin Source File + +SOURCE=.\CAnimatedMeshMD2.cpp +# End Source File +# Begin Source File + +SOURCE=.\CAnimatedMeshMD2.h +# End Source File +# Begin Source File + +SOURCE=.\CAnimatedMeshMD3.cpp +# End Source File +# Begin Source File + +SOURCE=.\CAnimatedMeshMD3.h +# End Source File +# Begin Source File + +SOURCE=.\CAnimatedMeshMS3D.cpp +# End Source File +# Begin Source File + +SOURCE=.\CAnimatedMeshMS3D.h +# End Source File +# Begin Source File + +SOURCE=.\CAnimatedMeshSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CAnimatedMeshSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CBillboardSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CBillboardSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CCameraFPSSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CCameraFPSSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CCameraMayaSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CCameraMayaSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CCameraSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CCameraSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CColladaFileLoader.cpp +# End Source File +# Begin Source File + +SOURCE=.\CColladaFileLoader.h +# End Source File +# Begin Source File + +SOURCE=.\CCSMLoader.cpp +# End Source File +# Begin Source File + +SOURCE=.\CCSMLoader.h +# End Source File +# Begin Source File + +SOURCE=.\CCubeSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CCubeSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CDefaultMeshFormatLoader.cpp +# End Source File +# Begin Source File + +SOURCE=.\CDefaultMeshFormatLoader.h +# End Source File +# Begin Source File + +SOURCE=.\CDefaultSceneNodeAnimatorFactory.cpp +# End Source File +# Begin Source File + +SOURCE=.\CDefaultSceneNodeAnimatorFactory.h +# End Source File +# Begin Source File + +SOURCE=.\CDefaultSceneNodeFactory.cpp +# End Source File +# Begin Source File + +SOURCE=.\CDefaultSceneNodeFactory.h +# End Source File +# Begin Source File + +SOURCE=.\CDMFLoader.cpp +# End Source File +# Begin Source File + +SOURCE=.\CDMFLoader.h +# End Source File +# Begin Source File + +SOURCE=.\CDummyTransformationSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CDummyTransformationSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CEmptySceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CEmptySceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CGeometryCreator.cpp +# End Source File +# Begin Source File + +SOURCE=.\CGeometryCreator.h +# End Source File +# Begin Source File + +SOURCE=.\CLightSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CLightSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CLMTSMeshFileLoader.cpp +# End Source File +# Begin Source File + +SOURCE=.\CLMTSMeshFileLoader.h +# End Source File +# Begin Source File + +SOURCE=.\CMD3MeshFileLoader.cpp +# End Source File +# Begin Source File + +SOURCE=.\CMD3MeshFileLoader.h +# End Source File +# Begin Source File + +SOURCE=.\CMeshCache.cpp +# End Source File +# Begin Source File + +SOURCE=.\CMeshCache.h +# End Source File +# Begin Source File + +SOURCE=.\CMeshManipulator.cpp +# End Source File +# Begin Source File + +SOURCE=.\CMeshManipulator.h +# End Source File +# Begin Source File + +SOURCE=.\CMeshSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CMeshSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CMetaTriangleSelector.cpp +# End Source File +# Begin Source File + +SOURCE=.\CMetaTriangleSelector.h +# End Source File +# Begin Source File + +SOURCE=.\CMY3DHelper.h +# End Source File +# Begin Source File + +SOURCE=.\CMY3DMeshFileLoader.cpp +# End Source File +# Begin Source File + +SOURCE=.\CMY3DMeshFileLoader.h +# End Source File +# Begin Source File + +SOURCE=.\CMY3DStuff.h +# End Source File +# Begin Source File + +SOURCE=.\COBJMeshFileLoader.cpp +# End Source File +# Begin Source File + +SOURCE=.\COBJMeshFileLoader.h +# End Source File +# Begin Source File + +SOURCE=.\COCTLoader.cpp +# End Source File +# Begin Source File + +SOURCE=.\COCTLoader.h +# End Source File +# Begin Source File + +SOURCE=.\COctTreeSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\COctTreeSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\COctTreeTriangleSelector.cpp +# End Source File +# Begin Source File + +SOURCE=.\COctTreeTriangleSelector.h +# End Source File +# Begin Source File + +SOURCE=.\COgreMeshFileLoader.cpp +# End Source File +# Begin Source File + +SOURCE=.\COgreMeshFileLoader.h +# End Source File +# Begin Source File + +SOURCE=.\CParticleBoxEmitter.cpp +# End Source File +# Begin Source File + +SOURCE=.\CParticleBoxEmitter.h +# End Source File +# Begin Source File + +SOURCE=.\CParticleFadeOutAffector.cpp +# End Source File +# Begin Source File + +SOURCE=.\CParticleFadeOutAffector.h +# End Source File +# Begin Source File + +SOURCE=.\CParticleGravityAffector.cpp +# End Source File +# Begin Source File + +SOURCE=.\CParticleGravityAffector.h +# End Source File +# Begin Source File + +SOURCE=.\CParticlePointEmitter.cpp +# End Source File +# Begin Source File + +SOURCE=.\CParticlePointEmitter.h +# End Source File +# Begin Source File + +SOURCE=.\CParticleSystemSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CParticleSystemSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CQ3LevelMesh.cpp +# End Source File +# Begin Source File + +SOURCE=.\CQ3LevelMesh.h +# End Source File +# Begin Source File + +SOURCE=.\CQuake3ShaderSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CQuake3ShaderSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CSceneCollisionManager.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSceneCollisionManager.h +# End Source File +# Begin Source File + +SOURCE=.\CSceneManager.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSceneManager.h +# End Source File +# Begin Source File + +SOURCE=.\CSceneNodeAnimatorCollisionResponse.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSceneNodeAnimatorCollisionResponse.h +# End Source File +# Begin Source File + +SOURCE=.\CSceneNodeAnimatorDelete.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSceneNodeAnimatorDelete.h +# End Source File +# Begin Source File + +SOURCE=.\CSceneNodeAnimatorFlyCircle.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSceneNodeAnimatorFlyCircle.h +# End Source File +# Begin Source File + +SOURCE=.\CSceneNodeAnimatorFlyStraight.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSceneNodeAnimatorFlyStraight.h +# End Source File +# Begin Source File + +SOURCE=.\CSceneNodeAnimatorFollowSpline.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSceneNodeAnimatorFollowSpline.h +# End Source File +# Begin Source File + +SOURCE=.\CSceneNodeAnimatorRotation.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSceneNodeAnimatorRotation.h +# End Source File +# Begin Source File + +SOURCE=.\CSceneNodeAnimatorTexture.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSceneNodeAnimatorTexture.h +# End Source File +# Begin Source File + +SOURCE=.\CShadowVolumeSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CShadowVolumeSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CSkyBoxSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSkyBoxSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CSkyDomeSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSkyDomeSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CSphereSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CSphereSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CTerrainSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTerrainSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CTerrainTriangleSelector.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTerrainTriangleSelector.h +# End Source File +# Begin Source File + +SOURCE=.\CTextSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTextSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CTriangleBBSelector.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTriangleBBSelector.h +# End Source File +# Begin Source File + +SOURCE=.\CTriangleSelector.cpp +# End Source File +# Begin Source File + +SOURCE=.\CTriangleSelector.h +# End Source File +# Begin Source File + +SOURCE=.\CWaterSurfaceSceneNode.cpp +# End Source File +# Begin Source File + +SOURCE=.\CWaterSurfaceSceneNode.h +# End Source File +# Begin Source File + +SOURCE=.\CXAnimationPlayer.cpp +# End Source File +# Begin Source File + +SOURCE=.\CXAnimationPlayer.h +# End Source File +# Begin Source File + +SOURCE=.\CXFileReader.cpp +# End Source File +# Begin Source File + +SOURCE=.\CXFileReader.h +# End Source File +# Begin Source File + +SOURCE=.\CXMeshFileLoader.cpp +# End Source File +# Begin Source File + +SOURCE=.\CXMeshFileLoader.h +# End Source File +# Begin Source File + +SOURCE=.\dmfsupport.h +# End Source File +# Begin Source File + +SOURCE=.\OctTree.h +# End Source File +# End Group +# Begin Group "io_impl" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\CAttributeImpl.h +# End Source File +# Begin Source File + +SOURCE=.\CAttributes.cpp +# End Source File +# Begin Source File + +SOURCE=.\CAttributes.h +# End Source File +# Begin Source File + +SOURCE=.\CFileList.cpp +# End Source File +# Begin Source File + +SOURCE=.\CFileList.h +# End Source File +# Begin Source File + +SOURCE=.\CFileSystem.cpp +# End Source File +# Begin Source File + +SOURCE=.\CFileSystem.h +# End Source File +# Begin Source File + +SOURCE=.\CLimitReadFile.cpp +# End Source File +# Begin Source File + +SOURCE=.\CLimitReadFile.h +# End Source File +# Begin Source File + +SOURCE=.\CMemoryReadFile.cpp +# End Source File +# Begin Source File + +SOURCE=.\CMemoryReadFile.h +# End Source File +# Begin Source File + +SOURCE=.\CPakReader.cpp +# End Source File +# Begin Source File + +SOURCE=.\CPakReader.h +# End Source File +# Begin Source File + +SOURCE=.\CReadFile.cpp +# End Source File +# Begin Source File + +SOURCE=.\CReadFile.h +# End Source File +# Begin Source File + +SOURCE=.\CWriteFile.cpp +# End Source File +# Begin Source File + +SOURCE=.\CWriteFile.h +# End Source File +# Begin Source File + +SOURCE=.\CXMLReader.cpp +# End Source File +# Begin Source File + +SOURCE=.\CXMLReader.h +# End Source File +# Begin Source File + +SOURCE=.\CXMLReaderImpl.h +# End Source File +# Begin Source File + +SOURCE=.\CXMLWriter.cpp +# End Source File +# Begin Source File + +SOURCE=.\CXMLWriter.h +# End Source File +# Begin Source File + +SOURCE=.\CZipReader.cpp +# End Source File +# Begin Source File + +SOURCE=.\CZipReader.h +# End Source File +# Begin Source File + +SOURCE=.\irrXML.cpp +# End Source File +# End Group +# Begin Group "other_impl" + +# PROP Default_Filter "" +# Begin Group "extern" + +# PROP Default_Filter "" +# Begin Group "zlib" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\zlib\adler32.c +# End Source File +# Begin Source File + +SOURCE=.\zlib\compress.c +# End Source File +# Begin Source File + +SOURCE=.\zlib\crc32.c +# End Source File +# Begin Source File + +SOURCE=.\zlib\crc32.h +# End Source File +# Begin Source File + +SOURCE=.\zlib\deflate.c +# End Source File +# Begin Source File + +SOURCE=.\zlib\deflate.h +# End Source File +# Begin Source File + +SOURCE=.\zlib\inffast.c +# End Source File +# Begin Source File + +SOURCE=.\zlib\inffast.h +# End Source File +# Begin Source File + +SOURCE=.\zlib\inflate.c +# End Source File +# Begin Source File + +SOURCE=.\zlib\inftrees.c +# End Source File +# Begin Source File + +SOURCE=.\zlib\inftrees.h +# End Source File +# Begin Source File + +SOURCE=.\zlib\trees.c +# End Source File +# Begin Source File + +SOURCE=.\zlib\trees.h +# End Source File +# Begin Source File + +SOURCE=.\zlib\uncompr.c +# End Source File +# Begin Source File + +SOURCE=.\zlib\zconf.h +# End Source File +# Begin Source File + +SOURCE=.\zlib\zlib.h +# End Source File +# Begin Source File + +SOURCE=.\zlib\zutil.c +# End Source File +# Begin Source File + +SOURCE=.\zlib\zutil.h +# End Source File +# End Group +# Begin Group "jpeglib" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\jpeglib\cderror.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\cdjpeg.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\cdjpeg.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jcapimin.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jcapistd.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jccoefct.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jccolor.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jcdctmgr.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jchuff.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jchuff.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jcinit.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jcmainct.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jcmarker.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jcmaster.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jcomapi.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jconfig.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jcparam.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jcphuff.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jcprepct.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jcsample.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jctrans.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdapimin.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdapistd.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdatadst.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdatasrc.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdcoefct.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdcolor.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdct.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jddctmgr.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdhuff.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdhuff.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdinput.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdmainct.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdmarker.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdmaster.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdmerge.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdphuff.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdpostct.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdsample.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jdtrans.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jerror.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jerror.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jfdctflt.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jfdctfst.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jfdctint.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jidctflt.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jidctfst.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jidctint.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jidctred.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jinclude.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jmemmgr.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jmemnobs.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jmemsys.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jmorecfg.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jpegint.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jpeglib.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jquant1.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jquant2.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jutils.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\jversion.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\rdbmp.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\rdcolmap.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\rdgif.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\rdppm.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\rdrle.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\rdswitch.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\rdtarga.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\transupp.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\transupp.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\wrbmp.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\wrgif.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\wrppm.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\wrrle.c +# End Source File +# Begin Source File + +SOURCE=.\jpeglib\wrtarga.c +# End Source File +# End Group +# Begin Group "libpng" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\libpng\png.c +# End Source File +# Begin Source File + +SOURCE=.\libpng\png.h +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngconf.h +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngerror.c +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngget.c +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngmem.c +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngpread.c +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngread.c +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngrio.c +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngrtran.c +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngrutil.c +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngset.c +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngtrans.c +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngwio.c +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngwrite.c +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngwtran.c +# End Source File +# Begin Source File + +SOURCE=.\libpng\pngwutil.c +# End Source File +# End Group +# End Group +# Begin Source File + +SOURCE=.\CIrrDeviceLinux.cpp +# End Source File +# Begin Source File + +SOURCE=.\CIrrDeviceLinux.h +# End Source File +# Begin Source File + +SOURCE=.\CIrrDeviceStub.cpp +# End Source File +# Begin Source File + +SOURCE=.\CIrrDeviceStub.h +# End Source File +# Begin Source File + +SOURCE=.\CIrrDeviceWin32.cpp +# End Source File +# Begin Source File + +SOURCE=.\CIrrDeviceWin32.h +# End Source File +# Begin Source File + +SOURCE=.\CLogger.cpp +# End Source File +# Begin Source File + +SOURCE=.\CLogger.h +# End Source File +# Begin Source File + +SOURCE=.\COSOperator.cpp +# End Source File +# Begin Source File + +SOURCE=.\COSOperator.h +# End Source File +# Begin Source File + +SOURCE=.\CTimer.h +# End Source File +# Begin Source File + +SOURCE=.\fast_atof.h +# End Source File +# Begin Source File + +SOURCE=.\IImagePresenter.h +# End Source File +# Begin Source File + +SOURCE=.\Irrlicht.cpp +# End Source File +# Begin Source File + +SOURCE=.\os.cpp +# End Source File +# Begin Source File + +SOURCE=.\os.h +# End Source File +# End Group +# Begin Group "doc" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\changes.txt +# End Source File +# End Group +# Begin Source File + +SOURCE=.\glxext.h +# End Source File +# End Target +# End Project diff --git a/src/dep/src/irrlicht/Irrlicht.dsw b/src/dep/src/irrlicht/Irrlicht.dsw index 99cd376..4569e8f 100644 --- a/src/dep/src/irrlicht/Irrlicht.dsw +++ b/src/dep/src/irrlicht/Irrlicht.dsw @@ -1,29 +1,29 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN! - -############################################################################### - -Project: "Irrlicht"=.\Irrlicht.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN! + +############################################################################### + +Project: "Irrlicht"=.\Irrlicht.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/src/dep/src/irrlicht/Irrlicht7.1.sln b/src/dep/src/irrlicht/Irrlicht7.1.sln index 7c17761..05f62a2 100644 --- a/src/dep/src/irrlicht/Irrlicht7.1.sln +++ b/src/dep/src/irrlicht/Irrlicht7.1.sln @@ -1,24 +1,24 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "Irrlicht7.1.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - Release - Fast FPU = Release - Fast FPU - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.ActiveCfg = Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.Build.0 = Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release.ActiveCfg = Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release.Build.0 = Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU.ActiveCfg = Relase - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU.Build.0 = Relase - Fast FPU|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "Irrlicht7.1.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + Release - Fast FPU = Release - Fast FPU + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.ActiveCfg = Debug|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.Build.0 = Debug|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Release.ActiveCfg = Release|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Release.Build.0 = Release|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU.ActiveCfg = Relase - Fast FPU|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU.Build.0 = Relase - Fast FPU|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/src/dep/src/irrlicht/Irrlicht7.1.vcproj b/src/dep/src/irrlicht/Irrlicht7.1.vcproj index 468e5e9..c131e4d 100644 --- a/src/dep/src/irrlicht/Irrlicht7.1.vcproj +++ b/src/dep/src/irrlicht/Irrlicht7.1.vcproj @@ -1,2798 +1,2798 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/dep/src/irrlicht/Irrlicht8.0.sln b/src/dep/src/irrlicht/Irrlicht8.0.sln index e7ed80f..ffc47d4 100644 --- a/src/dep/src/irrlicht/Irrlicht8.0.sln +++ b/src/dep/src/irrlicht/Irrlicht8.0.sln @@ -1,20 +1,20 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht8", "Irrlicht8.0.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.ActiveCfg = Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.Build.0 = Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.ActiveCfg = Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht8", "Irrlicht8.0.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.ActiveCfg = Debug|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.Build.0 = Debug|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.ActiveCfg = Release|Win32 + {E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/dep/src/irrlicht/Irrlicht8.0.vcproj b/src/dep/src/irrlicht/Irrlicht8.0.vcproj index 24fd85c..39acbeb 100644 --- a/src/dep/src/irrlicht/Irrlicht8.0.vcproj +++ b/src/dep/src/irrlicht/Irrlicht8.0.vcproj @@ -1,2823 +1,2823 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/dep/src/irrlicht/MacOSX/CIrrDeviceMacOSX.mm b/src/dep/src/irrlicht/MacOSX/CIrrDeviceMacOSX.mm index ee335ed..93a724d 100644 --- a/src/dep/src/irrlicht/MacOSX/CIrrDeviceMacOSX.mm +++ b/src/dep/src/irrlicht/MacOSX/CIrrDeviceMacOSX.mm @@ -1 +1,618 @@ -// Copyright (C) 2005 Etienne Petitjean // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in Irrlicht.h #ifdef MACOSX #import #import #include "CIrrDeviceMacOSX.h" #include "IEventReceiver.h" #include "irrList.h" #include "os.h" #include "CTimer.h" #include "irrString.h" #include "Keycodes.h" #include #include #include "COSOperator.h" #include "irrlicht.h" #import #import #import "AppDelegate.h" namespace irr { namespace video { IVideoDriver* createOpenGLDriver(const core::dimension2d& screenSize, CIrrDeviceMacOSX *device, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias); } } // end namespace irr static bool firstLaunch = true; namespace irr { //! constructor CIrrDeviceMacOSX::CIrrDeviceMacOSX(video::E_DRIVER_TYPE driverType, const core::dimension2d& windowSize, u32 bits, bool fullscreen, bool sbuffer, bool vsync, bool antiAlias, IEventReceiver* receiver, const char* version) : CIrrDeviceStub(version, receiver), DriverType(driverType), stencilbuffer(sbuffer) { struct utsname name; NSString *path; #ifdef _DEBUG setDebugName("CIrrDeviceMacOSX"); #endif if (firstLaunch) { firstLaunch = false; [[NSAutoreleasePool alloc] init]; [NSApplication sharedApplication]; [NSApp setDelegate:[[[AppDelegate alloc] initWithDevice:this] autorelease]]; [NSBundle loadNibNamed:@"MainMenu" owner:[NSApp delegate]]; [NSApp finishLaunching]; path = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent]; chdir([path cString]); } _window = NULL; _active = true; _oglcontext = NULL; _cglcontext = NULL; uname(&name); Operator = new COSOperator(name.version); os::Printer::log(name.version,ELL_INFORMATION); initKeycodes(); if (driverType != video::EDT_NULL) createWindow(windowSize,bits,fullscreen,vsync,stencilbuffer); CursorControl = new CCursorControl(windowSize, this); createDriver(driverType,windowSize,bits,fullscreen,stencilbuffer,vsync,antiAlias); createGUIAndScene(); } CIrrDeviceMacOSX::~CIrrDeviceMacOSX() { closeDevice(); } void CIrrDeviceMacOSX::closeDevice() { if (_window != NULL) { [_window setIsVisible:FALSE]; if (_oglcontext != NULL) { [_oglcontext clearDrawable]; [_oglcontext release]; _oglcontext = NULL; } [_window setReleasedWhenClosed:TRUE]; [_window release]; _window = NULL; } else { if (_cglcontext != NULL) { CGLSetCurrentContext(NULL); CGLClearDrawable(_cglcontext); CGLDestroyContext(_cglcontext); } } _active = FALSE; _cglcontext = NULL; } bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d& windowSize, irr::u32 bits, bool fullscreen, bool vsync, bool stencilBuffer) { int index; CGDisplayErr error; bool result; NSOpenGLPixelFormat *format; CGDirectDisplayID display; CGLPixelFormatObj pixelFormat; CGRect displayRect; CGLPixelFormatAttribute fullattribs[32]; NSOpenGLPixelFormatAttribute windowattribs[32]; CFDictionaryRef displaymode,olddisplaymode; long numPixelFormats,newSwapInterval; result = false; display = CGMainDisplayID(); _screenWidth = (int) CGDisplayPixelsWide(display); _screenHeight = (int) CGDisplayPixelsHigh(display); if (!fullscreen) { _window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,windowSize.Width,windowSize.Height) styleMask:NSTitledWindowMask+NSClosableWindowMask+NSResizableWindowMask backing:NSBackingStoreBuffered defer:FALSE]; if (_window != NULL) { index = 0; windowattribs[index++] = NSOpenGLPFANoRecovery; windowattribs[index++] = NSOpenGLPFADoubleBuffer; windowattribs[index++] = NSOpenGLPFAAccelerated; windowattribs[index++] = NSOpenGLPFADepthSize; windowattribs[index++] = (NSOpenGLPixelFormatAttribute)16; windowattribs[index++] = NSOpenGLPFAColorSize; windowattribs[index++] = (NSOpenGLPixelFormatAttribute)bits; if (stencilBuffer) { windowattribs[index++] = NSOpenGLPFAStencilSize; windowattribs[index++] = (NSOpenGLPixelFormatAttribute)1; } windowattribs[index++] = (NSOpenGLPixelFormatAttribute)NULL; format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs]; if (format != NULL) { _oglcontext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:NULL]; [format release]; } if (_oglcontext != NULL) { [_window center]; [_window setDelegate:[NSApp delegate]]; [_oglcontext setView:[_window contentView]]; [_window setAcceptsMouseMovedEvents:TRUE]; [_window setIsVisible:TRUE]; [_window makeKeyAndOrderFront:nil]; _cglcontext = (CGLContextObj) [_oglcontext CGLContextObj]; _width = windowSize.Width; _height = windowSize.Height; result = true; } } } else { displaymode = CGDisplayBestModeForParameters(display,bits,windowSize.Width,windowSize.Height,NULL); if (displaymode != NULL) { olddisplaymode = CGDisplayCurrentMode(display); error = CGCaptureAllDisplays(); if (error == CGDisplayNoErr) { error = CGDisplaySwitchToMode(display,displaymode); if (error == CGDisplayNoErr) { pixelFormat = NULL; numPixelFormats = 0; index = 0; fullattribs[index++] = kCGLPFAFullScreen; fullattribs[index++] = kCGLPFADisplayMask; fullattribs[index++] = (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display); fullattribs[index++] = kCGLPFADoubleBuffer; fullattribs[index++] = kCGLPFAAccelerated; fullattribs[index++] = kCGLPFADepthSize; fullattribs[index++] = (CGLPixelFormatAttribute)16; fullattribs[index++] = kCGLPFAColorSize; fullattribs[index++] = (CGLPixelFormatAttribute)bits; if (stencilBuffer) { fullattribs[index++] = kCGLPFAStencilSize; fullattribs[index++] = (CGLPixelFormatAttribute)1; } fullattribs[index++] = (CGLPixelFormatAttribute)NULL; CGLChoosePixelFormat(fullattribs,&pixelFormat,&numPixelFormats); if (pixelFormat != NULL) { CGLCreateContext(pixelFormat,NULL,&_cglcontext); CGLDestroyPixelFormat(pixelFormat); } if (_cglcontext != NULL) { CGLSetFullScreen(_cglcontext); displayRect = CGDisplayBounds(display); _width = (int)displayRect.size.width; _height = (int)displayRect.size.height; result = true; } } } } } if (result) { CGLSetCurrentContext(_cglcontext); newSwapInterval = (vsync) ? 1 : 0; CGLSetParameter(_cglcontext,kCGLCPSwapInterval,&newSwapInterval); glViewport(0,0,_width,_height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } return (result); } void CIrrDeviceMacOSX::setResize(int width,int height) { _width = width; _height = height; [_oglcontext update]; getVideoDriver()->OnResize(core::dimension2d(width, height)); } void CIrrDeviceMacOSX::createDriver(video::E_DRIVER_TYPE driverType,const core::dimension2d& windowSize,u32 bits,bool fullscreen,bool stencilbuffer, bool vsync, bool antiAlias) { switch (driverType) { case video::EDT_SOFTWARE: #ifdef _IRR_COMPILE_WITH_SOFTWARE_ VideoDriver = video::createSoftwareDriver(windowSize, fullscreen, FileSystem, this); #else os::Printer::log("No Software driver support compiled in.", ELL_WARNING); #endif break; case video::EDT_BURNINGSVIDEO: #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ VideoDriver = video::createSoftwareDriver2(windowSize, fullscreen, FileSystem, this); #else os::Printer::log("Burning's video driver was not compiled in.", ELL_WARNING); #endif break; case video::EDT_OPENGL: #ifdef _IRR_COMPILE_WITH_OPENGL_ VideoDriver = video::createOpenGLDriver(windowSize, this, fullscreen, stencilbuffer, FileSystem, vsync, antiAlias); #else os::Printer::log("No OpenGL support compiled in.", ELL_WARNING); #endif break; case video::EDT_NULL: VideoDriver = video::createNullDriver(FileSystem, windowSize); break; default: os::Printer::log("This driver is not available in Linux. Trying OpenGL.", ELL_WARNING); } } void CIrrDeviceMacOSX::flush() { if (_cglcontext != NULL) { glFinish(); CGLFlushDrawable(_cglcontext); } } bool CIrrDeviceMacOSX::run() { NSEvent *event; irr::SEvent ievent; os::Timer::tick(); storeMouseLocation(); event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]; if (event != nil) { bzero(&ievent,sizeof(ievent)); switch([event type]) { case NSKeyDown: postKeyEvent(event,ievent,true); break; case NSKeyUp: postKeyEvent(event,ievent,false); break; case NSLeftMouseDown: ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; ievent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN; postMouseEvent(event,ievent); break; case NSLeftMouseUp: ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; ievent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP; postMouseEvent(event,ievent); break; case NSMouseMoved: case NSLeftMouseDragged: case NSRightMouseDragged: ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; ievent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; postMouseEvent(event,ievent); break; case NSRightMouseDown: ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; ievent.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN; postMouseEvent(event,ievent); break; case NSRightMouseUp: ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; ievent.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP; postMouseEvent(event,ievent); break; case NSScrollWheel: ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; ievent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; ievent.MouseInput.Wheel = [event deltaY]; if (ievent.MouseInput.Wheel < 1.0f) ievent.MouseInput.Wheel *= 10.0f; else ievent.MouseInput.Wheel *= 5.0f; postMouseEvent(event,ievent); break; default: [NSApp sendEvent:event]; break; } } return (![[NSApp delegate] isQuit] && _active); } //! Pause the current process for the minimum time allowed only to allow other processes to execute void CIrrDeviceMacOSX::yield() { // TODO: Does this work or maybe is there a better way? struct timespec ts = {0,0}; nanosleep(&ts, NULL); } //! Pause execution and let other processes to run for a specified amount of time. void CIrrDeviceMacOSX::sleep(u32 timeMs, bool pauseTimer=false) { // TODO: Does this work or maybe is there a better way? bool wasStopped = Timer ? Timer->isStopped() : true; struct timespec ts; ts.tv_sec = (time_t) (timeMs / 1000); ts.tv_nsec = (long) (timeMs % 1000) * 1000000; if (pauseTimer && !wasStopped) Timer->stop(); nanosleep(&ts, NULL); if (pauseTimer && !wasStopped) Timer->start(); } void CIrrDeviceMacOSX::present(video::IImage* image, s32 windowId, core::rect* src ) { } void CIrrDeviceMacOSX::setWindowCaption(const wchar_t* text) { size_t size; char title[1024]; if (_window != NULL) { size = wcstombs(title,text,1024); if (size == 1024) title[1023] = 0; [_window setTitle:[NSString stringWithCString:title length:size]]; } } bool CIrrDeviceMacOSX::isWindowActive() { return (_active); } void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed) { NSString *str; std::map::const_iterator iter; unsigned int result,c,mkey,mchar; const unsigned char *cStr; BOOL skipCommand; str = [event characters]; if (str != nil && [str length] > 0) { mkey = mchar = 0; skipCommand = false; c = [str characterAtIndex:0]; iter = _keycodes.find(c); if (iter != _keycodes.end()) mkey = (*iter).second; else { cStr = (unsigned char *)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding]; if (cStr != NULL && strlen((char*)cStr) > 0) { mchar = cStr[0]; mkey = toupper(mchar); if ([event modifierFlags] & NSCommandKeyMask) { if (mkey == 'C' || mkey == 'V' || mkey == 'X') { mchar = 0; skipCommand = true; } } } } ievent.EventType = irr::EET_KEY_INPUT_EVENT; ievent.KeyInput.Key = (irr::EKEY_CODE)mkey; ievent.KeyInput.PressedDown = pressed; ievent.KeyInput.Shift = ([event modifierFlags] & NSShiftKeyMask) != 0; ievent.KeyInput.Control = ([event modifierFlags] & NSControlKeyMask) != 0; ievent.KeyInput.Char = (irr::EKEY_CODE)mchar; if (skipCommand) ievent.KeyInput.Control = true; else if ([event modifierFlags] & NSCommandKeyMask) [NSApp sendEvent:(NSEvent *)event]; postEventFromUser(ievent); } } void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent) { BOOL post = true; if (_window != NULL) { ievent.MouseInput.X = (int)[event locationInWindow].x; ievent.MouseInput.Y = _height - (int)[event locationInWindow].y; if (ievent.MouseInput.Y < 0) post = false; } else { ievent.MouseInput.X = (int)[NSEvent mouseLocation].x; ievent.MouseInput.Y = _height - (int)[NSEvent mouseLocation].y; } if (post) postEventFromUser(ievent); [NSApp sendEvent:(NSEvent *)event]; } void CIrrDeviceMacOSX::storeMouseLocation() { NSPoint p; int x,y; p = [NSEvent mouseLocation]; if (_window != NULL) { p = [_window convertScreenToBase:p]; x = (int)p.x; y = _height - (int)p.y; } else { x = (int)p.x; y = _screenHeight - (int)p.y; } ((CCursorControl *)CursorControl)->updateInternalCursorPosition(x,y); } void CIrrDeviceMacOSX::setMouseLocation(int x,int y) { NSPoint p; CGPoint c; if (_window != NULL) { p.x = (float) x; p.y = (float) (_height - y); p = [_window convertBaseToScreen:p]; p.y = _screenHeight - p.y; } else { p.x = (float) x; p.y = (float) (_height - y); } c.x = p.x; c.y = p.y; CGSetLocalEventsSuppressionInterval(0); CGWarpMouseCursorPosition(c); } void CIrrDeviceMacOSX::setCursorVisible(bool visible) { CGDirectDisplayID display; display = CGMainDisplayID(); if (visible) CGDisplayShowCursor(display); else CGDisplayHideCursor(display); } void CIrrDeviceMacOSX::initKeycodes() { _keycodes[NSUpArrowFunctionKey] = irr::KEY_UP; _keycodes[NSDownArrowFunctionKey] = irr::KEY_DOWN; _keycodes[NSLeftArrowFunctionKey] = irr::KEY_LEFT; _keycodes[NSRightArrowFunctionKey] = irr::KEY_RIGHT; _keycodes[NSF1FunctionKey] = irr::KEY_F1; _keycodes[NSF2FunctionKey] = irr::KEY_F2; _keycodes[NSF3FunctionKey] = irr::KEY_F3; _keycodes[NSF4FunctionKey] = irr::KEY_F4; _keycodes[NSF5FunctionKey] = irr::KEY_F5; _keycodes[NSF6FunctionKey] = irr::KEY_F6; _keycodes[NSF7FunctionKey] = irr::KEY_F7; _keycodes[NSF8FunctionKey] = irr::KEY_F8; _keycodes[NSF9FunctionKey] = irr::KEY_F9; _keycodes[NSF10FunctionKey] = irr::KEY_F10; _keycodes[NSF11FunctionKey] = irr::KEY_F11; _keycodes[NSF12FunctionKey] = irr::KEY_F12; _keycodes[NSF13FunctionKey] = irr::KEY_F13; _keycodes[NSF14FunctionKey] = irr::KEY_F14; _keycodes[NSF15FunctionKey] = irr::KEY_F15; _keycodes[NSF16FunctionKey] = irr::KEY_F16; _keycodes[NSHomeFunctionKey] = irr::KEY_HOME; _keycodes[NSEndFunctionKey] = irr::KEY_END; _keycodes[NSInsertFunctionKey] = irr::KEY_INSERT; _keycodes[NSDeleteFunctionKey] = irr::KEY_DELETE; _keycodes[NSHelpFunctionKey] = irr::KEY_HELP; _keycodes[NSSelectFunctionKey] = irr::KEY_SELECT; _keycodes[NSPrintFunctionKey] = irr::KEY_PRINT; _keycodes[NSExecuteFunctionKey] = irr::KEY_EXECUT; _keycodes[NSPrintScreenFunctionKey] = irr::KEY_SNAPSHOT; _keycodes[NSPauseFunctionKey] = irr::KEY_PAUSE; _keycodes[NSScrollLockFunctionKey] = irr::KEY_SCROLL; _keycodes[0x7F] = irr::KEY_BACK; _keycodes[0x09] = irr::KEY_TAB; _keycodes[0x0D] = irr::KEY_RETURN; _keycodes[0x03] = irr::KEY_RETURN; _keycodes[0x1B] = irr::KEY_ESCAPE; } IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& param) { CIrrDeviceMacOSX* dev = new CIrrDeviceMacOSX( param.DriverType, param.WindowSize, param.Bits, param.Fullscreen, param.Stencilbuffer, param.Vsync, param.AntiAlias, param.EventReceiver, param.SDK_version_do_not_use); if (dev && !dev->getVideoDriver() && param.DriverType != video::EDT_NULL) { dev->drop(); dev = 0; } return dev; } } #endif \ No newline at end of file +// Copyright (C) 2005 Etienne Petitjean +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#ifdef MACOSX + +#import +#import + +#include "CIrrDeviceMacOSX.h" +#include "IEventReceiver.h" +#include "irrList.h" +#include "os.h" +#include "CTimer.h" +#include "irrString.h" +#include "Keycodes.h" +#include +#include +#include "COSOperator.h" +#include "irrlicht.h" +#import +#import +#import "AppDelegate.h" + +namespace irr +{ + namespace video + { + IVideoDriver* createOpenGLDriver(const core::dimension2d& screenSize, CIrrDeviceMacOSX *device, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias); + } +} // end namespace irr + +static bool firstLaunch = true; + +namespace irr +{ +//! constructor +CIrrDeviceMacOSX::CIrrDeviceMacOSX(video::E_DRIVER_TYPE driverType, + const core::dimension2d& windowSize, + u32 bits, bool fullscreen, + bool sbuffer, bool vsync, + bool antiAlias, IEventReceiver* receiver, + const char* version) + : CIrrDeviceStub(version, receiver), DriverType(driverType), stencilbuffer(sbuffer) +{ + struct utsname name; + NSString *path; + + #ifdef _DEBUG + setDebugName("CIrrDeviceMacOSX"); + #endif + + if (firstLaunch) + { + firstLaunch = false; + + [[NSAutoreleasePool alloc] init]; + [NSApplication sharedApplication]; + [NSApp setDelegate:[[[AppDelegate alloc] initWithDevice:this] autorelease]]; + [NSBundle loadNibNamed:@"MainMenu" owner:[NSApp delegate]]; + [NSApp finishLaunching]; + + path = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent]; + chdir([path cString]); + } + + _window = NULL; + _active = true; + _oglcontext = NULL; + _cglcontext = NULL; + + uname(&name); + Operator = new COSOperator(name.version); + os::Printer::log(name.version,ELL_INFORMATION); + + initKeycodes(); + if (driverType != video::EDT_NULL) createWindow(windowSize,bits,fullscreen,vsync,stencilbuffer); + CursorControl = new CCursorControl(windowSize, this); + createDriver(driverType,windowSize,bits,fullscreen,stencilbuffer,vsync,antiAlias); + createGUIAndScene(); +} + +CIrrDeviceMacOSX::~CIrrDeviceMacOSX() +{ + closeDevice(); +} + +void CIrrDeviceMacOSX::closeDevice() +{ + if (_window != NULL) + { + [_window setIsVisible:FALSE]; + + if (_oglcontext != NULL) + { + [_oglcontext clearDrawable]; + [_oglcontext release]; + _oglcontext = NULL; + } + + [_window setReleasedWhenClosed:TRUE]; + [_window release]; + _window = NULL; + } + else + { + if (_cglcontext != NULL) + { + CGLSetCurrentContext(NULL); + CGLClearDrawable(_cglcontext); + CGLDestroyContext(_cglcontext); + } + } + + _active = FALSE; + _cglcontext = NULL; +} + +bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d& windowSize, irr::u32 bits, bool fullscreen, bool vsync, bool stencilBuffer) +{ + int index; + CGDisplayErr error; + bool result; + NSOpenGLPixelFormat *format; + CGDirectDisplayID display; + CGLPixelFormatObj pixelFormat; + CGRect displayRect; + CGLPixelFormatAttribute fullattribs[32]; + NSOpenGLPixelFormatAttribute windowattribs[32]; + CFDictionaryRef displaymode,olddisplaymode; + long numPixelFormats,newSwapInterval; + + result = false; + display = CGMainDisplayID(); + _screenWidth = (int) CGDisplayPixelsWide(display); + _screenHeight = (int) CGDisplayPixelsHigh(display); + + if (!fullscreen) + { + _window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,windowSize.Width,windowSize.Height) styleMask:NSTitledWindowMask+NSClosableWindowMask+NSResizableWindowMask backing:NSBackingStoreBuffered defer:FALSE]; + if (_window != NULL) + { + index = 0; + windowattribs[index++] = NSOpenGLPFANoRecovery; + windowattribs[index++] = NSOpenGLPFADoubleBuffer; + windowattribs[index++] = NSOpenGLPFAAccelerated; + windowattribs[index++] = NSOpenGLPFADepthSize; + windowattribs[index++] = (NSOpenGLPixelFormatAttribute)16; + windowattribs[index++] = NSOpenGLPFAColorSize; + windowattribs[index++] = (NSOpenGLPixelFormatAttribute)bits; + + if (stencilBuffer) + { + windowattribs[index++] = NSOpenGLPFAStencilSize; + windowattribs[index++] = (NSOpenGLPixelFormatAttribute)1; + } + + windowattribs[index++] = (NSOpenGLPixelFormatAttribute)NULL; + + format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs]; + if (format != NULL) + { + _oglcontext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:NULL]; + [format release]; + } + + if (_oglcontext != NULL) + { + [_window center]; + [_window setDelegate:[NSApp delegate]]; + [_oglcontext setView:[_window contentView]]; + [_window setAcceptsMouseMovedEvents:TRUE]; + [_window setIsVisible:TRUE]; + [_window makeKeyAndOrderFront:nil]; + + _cglcontext = (CGLContextObj) [_oglcontext CGLContextObj]; + _width = windowSize.Width; + _height = windowSize.Height; + result = true; + } + } + } + else + { + displaymode = CGDisplayBestModeForParameters(display,bits,windowSize.Width,windowSize.Height,NULL); + if (displaymode != NULL) + { + olddisplaymode = CGDisplayCurrentMode(display); + error = CGCaptureAllDisplays(); + if (error == CGDisplayNoErr) + { + error = CGDisplaySwitchToMode(display,displaymode); + if (error == CGDisplayNoErr) + { + pixelFormat = NULL; + numPixelFormats = 0; + + index = 0; + fullattribs[index++] = kCGLPFAFullScreen; + fullattribs[index++] = kCGLPFADisplayMask; + fullattribs[index++] = (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display); + fullattribs[index++] = kCGLPFADoubleBuffer; + fullattribs[index++] = kCGLPFAAccelerated; + fullattribs[index++] = kCGLPFADepthSize; + fullattribs[index++] = (CGLPixelFormatAttribute)16; + fullattribs[index++] = kCGLPFAColorSize; + fullattribs[index++] = (CGLPixelFormatAttribute)bits; + + if (stencilBuffer) + { + fullattribs[index++] = kCGLPFAStencilSize; + fullattribs[index++] = (CGLPixelFormatAttribute)1; + } + + fullattribs[index++] = (CGLPixelFormatAttribute)NULL; + CGLChoosePixelFormat(fullattribs,&pixelFormat,&numPixelFormats); + + if (pixelFormat != NULL) + { + CGLCreateContext(pixelFormat,NULL,&_cglcontext); + CGLDestroyPixelFormat(pixelFormat); + } + + if (_cglcontext != NULL) + { + CGLSetFullScreen(_cglcontext); + displayRect = CGDisplayBounds(display); + _width = (int)displayRect.size.width; + _height = (int)displayRect.size.height; + result = true; + } + } + } + } + } + + if (result) + { + CGLSetCurrentContext(_cglcontext); + newSwapInterval = (vsync) ? 1 : 0; + CGLSetParameter(_cglcontext,kCGLCPSwapInterval,&newSwapInterval); + glViewport(0,0,_width,_height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + } + + return (result); +} + +void CIrrDeviceMacOSX::setResize(int width,int height) +{ + _width = width; + _height = height; + [_oglcontext update]; + getVideoDriver()->OnResize(core::dimension2d(width, height)); +} + +void CIrrDeviceMacOSX::createDriver(video::E_DRIVER_TYPE driverType,const core::dimension2d& windowSize,u32 bits,bool fullscreen,bool stencilbuffer, bool vsync, bool antiAlias) +{ + switch (driverType) + { + case video::EDT_SOFTWARE: + #ifdef _IRR_COMPILE_WITH_SOFTWARE_ + VideoDriver = video::createSoftwareDriver(windowSize, fullscreen, FileSystem, this); + #else + os::Printer::log("No Software driver support compiled in.", ELL_WARNING); + #endif + break; + + case video::EDT_BURNINGSVIDEO: + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + VideoDriver = video::createSoftwareDriver2(windowSize, fullscreen, FileSystem, this); + #else + os::Printer::log("Burning's video driver was not compiled in.", ELL_WARNING); + #endif + break; + + case video::EDT_OPENGL: + #ifdef _IRR_COMPILE_WITH_OPENGL_ + VideoDriver = video::createOpenGLDriver(windowSize, this, fullscreen, stencilbuffer, FileSystem, vsync, antiAlias); + #else + os::Printer::log("No OpenGL support compiled in.", ELL_WARNING); + #endif + break; + + case video::EDT_NULL: + VideoDriver = video::createNullDriver(FileSystem, windowSize); + break; + + default: + os::Printer::log("This driver is not available in Linux. Trying OpenGL.", ELL_WARNING); + } +} + +void CIrrDeviceMacOSX::flush() +{ + if (_cglcontext != NULL) + { + glFinish(); + CGLFlushDrawable(_cglcontext); + } +} + +bool CIrrDeviceMacOSX::run() +{ + NSEvent *event; + irr::SEvent ievent; + + os::Timer::tick(); + storeMouseLocation(); + + event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]; + if (event != nil) + { + bzero(&ievent,sizeof(ievent)); + + switch([event type]) + { + case NSKeyDown: + postKeyEvent(event,ievent,true); + break; + + case NSKeyUp: + postKeyEvent(event,ievent,false); + break; + + case NSLeftMouseDown: + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + ievent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN; + postMouseEvent(event,ievent); + break; + + case NSLeftMouseUp: + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + ievent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP; + postMouseEvent(event,ievent); + break; + + case NSMouseMoved: + case NSLeftMouseDragged: + case NSRightMouseDragged: + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + ievent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; + postMouseEvent(event,ievent); + break; + + case NSRightMouseDown: + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + ievent.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN; + postMouseEvent(event,ievent); + break; + + case NSRightMouseUp: + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + ievent.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP; + postMouseEvent(event,ievent); + break; + + case NSScrollWheel: + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + ievent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; + ievent.MouseInput.Wheel = [event deltaY]; + if (ievent.MouseInput.Wheel < 1.0f) ievent.MouseInput.Wheel *= 10.0f; + else ievent.MouseInput.Wheel *= 5.0f; + postMouseEvent(event,ievent); + break; + + default: + [NSApp sendEvent:event]; + break; + } + } + + return (![[NSApp delegate] isQuit] && _active); +} + +//! Pause the current process for the minimum time allowed only to allow other processes to execute +void CIrrDeviceMacOSX::yield() +{ + // TODO: Does this work or maybe is there a better way? + struct timespec ts = {0,0}; + nanosleep(&ts, NULL); +} + +//! Pause execution and let other processes to run for a specified amount of time. +void CIrrDeviceMacOSX::sleep(u32 timeMs, bool pauseTimer=false) +{ + // TODO: Does this work or maybe is there a better way? + + bool wasStopped = Timer ? Timer->isStopped() : true; + + struct timespec ts; + ts.tv_sec = (time_t) (timeMs / 1000); + ts.tv_nsec = (long) (timeMs % 1000) * 1000000; + + if (pauseTimer && !wasStopped) + Timer->stop(); + + nanosleep(&ts, NULL); + + if (pauseTimer && !wasStopped) + Timer->start(); +} + +void CIrrDeviceMacOSX::present(video::IImage* image, s32 windowId, core::rect* src ) +{ +} + +void CIrrDeviceMacOSX::setWindowCaption(const wchar_t* text) +{ + size_t size; + char title[1024]; + + if (_window != NULL) + { + size = wcstombs(title,text,1024); + if (size == 1024) title[1023] = 0; + [_window setTitle:[NSString stringWithCString:title length:size]]; + } +} + +bool CIrrDeviceMacOSX::isWindowActive() +{ + return (_active); +} + +void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed) +{ + NSString *str; + std::map::const_iterator iter; + unsigned int result,c,mkey,mchar; + const unsigned char *cStr; + BOOL skipCommand; + + str = [event characters]; + if (str != nil && [str length] > 0) + { + mkey = mchar = 0; + skipCommand = false; + c = [str characterAtIndex:0]; + + iter = _keycodes.find(c); + if (iter != _keycodes.end()) mkey = (*iter).second; + else + { + cStr = (unsigned char *)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding]; + if (cStr != NULL && strlen((char*)cStr) > 0) + { + mchar = cStr[0]; + mkey = toupper(mchar); + if ([event modifierFlags] & NSCommandKeyMask) + { + if (mkey == 'C' || mkey == 'V' || mkey == 'X') + { + mchar = 0; + skipCommand = true; + } + } + } + } + + ievent.EventType = irr::EET_KEY_INPUT_EVENT; + ievent.KeyInput.Key = (irr::EKEY_CODE)mkey; + ievent.KeyInput.PressedDown = pressed; + ievent.KeyInput.Shift = ([event modifierFlags] & NSShiftKeyMask) != 0; + ievent.KeyInput.Control = ([event modifierFlags] & NSControlKeyMask) != 0; + ievent.KeyInput.Char = (irr::EKEY_CODE)mchar; + + if (skipCommand) ievent.KeyInput.Control = true; + else if ([event modifierFlags] & NSCommandKeyMask) [NSApp sendEvent:(NSEvent *)event]; + + postEventFromUser(ievent); + } +} + +void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent) +{ + BOOL post = true; + + if (_window != NULL) + { + ievent.MouseInput.X = (int)[event locationInWindow].x; + ievent.MouseInput.Y = _height - (int)[event locationInWindow].y; + if (ievent.MouseInput.Y < 0) post = false; + } + else + { + ievent.MouseInput.X = (int)[NSEvent mouseLocation].x; + ievent.MouseInput.Y = _height - (int)[NSEvent mouseLocation].y; + } + + if (post) postEventFromUser(ievent); + [NSApp sendEvent:(NSEvent *)event]; +} + +void CIrrDeviceMacOSX::storeMouseLocation() +{ + NSPoint p; + int x,y; + + p = [NSEvent mouseLocation]; + + if (_window != NULL) + { + p = [_window convertScreenToBase:p]; + x = (int)p.x; + y = _height - (int)p.y; + } + else + { + x = (int)p.x; + y = _screenHeight - (int)p.y; + } + + ((CCursorControl *)CursorControl)->updateInternalCursorPosition(x,y); +} + +void CIrrDeviceMacOSX::setMouseLocation(int x,int y) +{ + NSPoint p; + CGPoint c; + + if (_window != NULL) + { + p.x = (float) x; + p.y = (float) (_height - y); + p = [_window convertBaseToScreen:p]; + p.y = _screenHeight - p.y; + } + else + { + p.x = (float) x; + p.y = (float) (_height - y); + } + + c.x = p.x; + c.y = p.y; + CGSetLocalEventsSuppressionInterval(0); + CGWarpMouseCursorPosition(c); +} + +void CIrrDeviceMacOSX::setCursorVisible(bool visible) +{ + CGDirectDisplayID display; + + display = CGMainDisplayID(); + if (visible) CGDisplayShowCursor(display); + else CGDisplayHideCursor(display); +} + +void CIrrDeviceMacOSX::initKeycodes() +{ + _keycodes[NSUpArrowFunctionKey] = irr::KEY_UP; + _keycodes[NSDownArrowFunctionKey] = irr::KEY_DOWN; + _keycodes[NSLeftArrowFunctionKey] = irr::KEY_LEFT; + _keycodes[NSRightArrowFunctionKey] = irr::KEY_RIGHT; + _keycodes[NSF1FunctionKey] = irr::KEY_F1; + _keycodes[NSF2FunctionKey] = irr::KEY_F2; + _keycodes[NSF3FunctionKey] = irr::KEY_F3; + _keycodes[NSF4FunctionKey] = irr::KEY_F4; + _keycodes[NSF5FunctionKey] = irr::KEY_F5; + _keycodes[NSF6FunctionKey] = irr::KEY_F6; + _keycodes[NSF7FunctionKey] = irr::KEY_F7; + _keycodes[NSF8FunctionKey] = irr::KEY_F8; + _keycodes[NSF9FunctionKey] = irr::KEY_F9; + _keycodes[NSF10FunctionKey] = irr::KEY_F10; + _keycodes[NSF11FunctionKey] = irr::KEY_F11; + _keycodes[NSF12FunctionKey] = irr::KEY_F12; + _keycodes[NSF13FunctionKey] = irr::KEY_F13; + _keycodes[NSF14FunctionKey] = irr::KEY_F14; + _keycodes[NSF15FunctionKey] = irr::KEY_F15; + _keycodes[NSF16FunctionKey] = irr::KEY_F16; + _keycodes[NSHomeFunctionKey] = irr::KEY_HOME; + _keycodes[NSEndFunctionKey] = irr::KEY_END; + _keycodes[NSInsertFunctionKey] = irr::KEY_INSERT; + _keycodes[NSDeleteFunctionKey] = irr::KEY_DELETE; + _keycodes[NSHelpFunctionKey] = irr::KEY_HELP; + _keycodes[NSSelectFunctionKey] = irr::KEY_SELECT; + _keycodes[NSPrintFunctionKey] = irr::KEY_PRINT; + _keycodes[NSExecuteFunctionKey] = irr::KEY_EXECUT; + _keycodes[NSPrintScreenFunctionKey] = irr::KEY_SNAPSHOT; + _keycodes[NSPauseFunctionKey] = irr::KEY_PAUSE; + _keycodes[NSScrollLockFunctionKey] = irr::KEY_SCROLL; + _keycodes[0x7F] = irr::KEY_BACK; + _keycodes[0x09] = irr::KEY_TAB; + _keycodes[0x0D] = irr::KEY_RETURN; + _keycodes[0x03] = irr::KEY_RETURN; + _keycodes[0x1B] = irr::KEY_ESCAPE; +} + + +IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& param) +{ + CIrrDeviceMacOSX* dev = new CIrrDeviceMacOSX( + param.DriverType, + param.WindowSize, + param.Bits, + param.Fullscreen, + param.Stencilbuffer, + param.Vsync, + param.AntiAlias, + param.EventReceiver, + param.SDK_version_do_not_use); + + if (dev && !dev->getVideoDriver() && param.DriverType != video::EDT_NULL) + { + dev->drop(); + dev = 0; + } + + return dev; +} + +} + +#endif diff --git a/src/dep/src/irrlicht/Makefile b/src/dep/src/irrlicht/Makefile index 601d785..3f3d283 100644 --- a/src/dep/src/irrlicht/Makefile +++ b/src/dep/src/irrlicht/Makefile @@ -1,117 +1,117 @@ -VERSION = 1.3.0 -# Irrlicht Engine 1.3 -# Makefile for Linux, created by N.Gebhardt. -# -# To use, just run: -# -# make -# -# This will compile Irrlicht, create a static lib (libIrrlicht.a), and copy it -# into the subdirectory lib/Linux. That's all. -# -# If you want Irrlicht to be compiled as shared lib (libIrrlicht.so.versionnumber), then run: -# -# make sharedlib -# make install -# -# Please note that Irrlicht as shared lib is just experimental and -# probably not tested. -# - -#List of object files, separated based on engine architecture -IRROBJ = C3DSMeshFileLoader.o COgreMeshFileLoader.o COBJMeshFileLoader.o CAnimatedMeshMD2.o CAnimatedMeshMD3.o CMD3MeshFileLoader.o CAnimatedMeshMS3D.o CAnimatedMeshB3d.o CAnimatedMeshSceneNode.o CBillboardSceneNode.o CCameraFPSSceneNode.o CCameraMayaSceneNode.o CCameraSceneNode.o CColladaFileLoader.o CCSMLoader.o CDefaultMeshFormatLoader.o CDMFLoader.o CDummyTransformationSceneNode.o CEmptySceneNode.o CGeometryCreator.o CLightSceneNode.o CLMTSMeshFileLoader.o CMeshManipulator.o CMeshSceneNode.o CMetaTriangleSelector.o CMY3DMeshFileLoader.o COCTLoader.o COctTreeSceneNode.o COctTreeTriangleSelector.o CParticleBoxEmitter.o CParticleFadeOutAffector.o CParticleGravityAffector.o CParticlePointEmitter.o CParticleSystemSceneNode.o CQ3LevelMesh.o CSceneCollisionManager.o CSceneManager.o CSceneNodeAnimatorCollisionResponse.o CSceneNodeAnimatorDelete.o CSceneNodeAnimatorFlyCircle.o CSceneNodeAnimatorFlyStraight.o CSceneNodeAnimatorFollowSpline.o CSceneNodeAnimatorRotation.o CSceneNodeAnimatorTexture.o CShadowVolumeSceneNode.o CSkyBoxSceneNode.o CSkyDomeSceneNode.o CTerrainSceneNode.o CTerrainTriangleSelector.o CCubeSceneNode.o CSphereSceneNode.o CTextSceneNode.o CTriangleBBSelector.o CTriangleSelector.o CWaterSurfaceSceneNode.o CXAnimationPlayer.o CXFileReader.o CXMeshFileLoader.o CMeshCache.o CDefaultSceneNodeAnimatorFactory.o CDefaultSceneNodeFactory.o CQuake3ShaderSceneNode.o -IRRVIDEOOBJ = COpenGLDriver.o COpenGLNormalMapRenderer.o COpenGLParallaxMapRenderer.o COpenGLShaderMaterialRenderer.o COpenGLTexture.o COpenGLSLMaterialRenderer.o CD3D8Driver.o CD3D8NormalMapRenderer.o CD3D8ParallaxMapRenderer.o CD3D8ShaderMaterialRenderer.o CD3D8Texture.o CColorConverter.o CFPSCounter.o CImage.o CImageLoaderBMP.o CImageLoaderJPG.o CImageLoaderPCX.o CImageLoaderPNG.o CImageLoaderPSD.o CImageLoaderTGA.o CImageWriterBMP.o CImageWriterJPG.o CImageWriterPCX.o CImageWriterPNG.o CImageWriterPPM.o CImageWriterPSD.o CImageWriterTGA.o CNullDriver.o CD3D9Driver.o CD3D9HLSLMaterialRenderer.o CD3D9NormalMapRenderer.o CD3D9ParallaxMapRenderer.o CD3D9ShaderMaterialRenderer.o CD3D9Texture.o CVideoModeList.o -IRRSWRENDEROBJ = CSoftwareDriver.o CSoftwareTexture.o CTRFlat.o CTRFlatWire.o CTRGouraud.o CTRGouraudWire.o CTRTextureFlat.o CTRTextureFlatWire.o CTRTextureGouraud.o CTRTextureGouraudAdd.o CTRTextureGouraudNoZ.o CTRTextureGouraudWire.o CZBuffer.o CTRTextureGouraudVertexAlpha2.o CTRTextureGouraudNoZ2.o CTRTextureLightMap2_M2.o CTRTextureLightMap2_M4.o CTRTextureLightMap2_M1.o CSoftwareDriver2.o CSoftwareTexture2.o CTRTextureGouraud2.o CTRGouraud2.o CTRGouraudAlpha2.o CTRGouraudAlphaNoZ2.o CTRTextureDetailMap2.o CTRTextureGouraudAdd2.o CTRTextureGouraudAddNoZ2.o CTRTextureWire2.o CTRTextureLightMap2_Add.o CTRTextureLightMapGouraud2_M4.o IBurningShader.o CTRTextureBlend.o CTRTextureGouraudAlpha.o CTRTextureGouraudAlphaNoZ.o CDepthBuffer.o -IRRIOOBJ = CFileList.o CFileSystem.o CLimitReadFile.o CMemoryReadFile.o CReadFile.o CWriteFile.o CXMLReader.o CXMLWriter.o CZipReader.o CPakReader.o irrXML.o CAttributes.o -IRROTHEROBJ = CIrrDeviceLinux.o CIrrDeviceStub.o CIrrDeviceWin32.o CLogger.o COSOperator.o Irrlicht.o os.o -IRRGUIOBJ = CGUIButton.o CGUICheckBox.o CGUIComboBox.o CGUIContextMenu.o CGUIEditBox.o CGUIEnvironment.o CGUIFileOpenDialog.o CGUIFont.o CGUIImage.o CGUIInOutFader.o CGUIListBox.o CGUIMenu.o CGUIMeshViewer.o CGUIMessageBox.o CGUIModalScreen.o CGUIScrollBar.o CGUISkin.o CGUIStaticText.o CGUITabControl.o CGUIToolBar.o CGUIWindow.o CGUIColorSelectDialog.o CDefaultGUIElementFactory.o CGUISpriteBank.o -ZLIBOBJ = zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o zlib/uncompr.o zlib/zutil.o -JPEGLIBOBJ = jpeglib/jcapimin.o jpeglib/jcapistd.o jpeglib/jccoefct.o jpeglib/jccolor.o jpeglib/jcdctmgr.o jpeglib/jchuff.o jpeglib/jcinit.o jpeglib/jcmainct.o jpeglib/jcmarker.o jpeglib/jcmaster.o jpeglib/jcomapi.o jpeglib/jcparam.o jpeglib/jcphuff.o jpeglib/jcprepct.o jpeglib/jcsample.o jpeglib/jctrans.o jpeglib/jdapimin.o jpeglib/jdapistd.o jpeglib/jdatadst.o jpeglib/jdatasrc.o jpeglib/jdcoefct.o jpeglib/jdcolor.o jpeglib/jddctmgr.o jpeglib/jdhuff.o jpeglib/jdinput.o jpeglib/jdmainct.o jpeglib/jdmarker.o jpeglib/jdmaster.o jpeglib/jdmerge.o jpeglib/jdphuff.o jpeglib/jdpostct.o jpeglib/jdsample.o jpeglib/jdtrans.o jpeglib/jerror.o jpeglib/jfdctflt.o jpeglib/jfdctfst.o jpeglib/jfdctint.o jpeglib/jidctflt.o jpeglib/jidctfst.o jpeglib/jidctint.o jpeglib/jidctred.o jpeglib/jmemmgr.o jpeglib/jmemnobs.o jpeglib/jquant1.o jpeglib/jquant2.o jpeglib/jutils.o jpeglib/rdbmp.o jpeglib/rdcolmap.o jpeglib/rdgif.o jpeglib/rdppm.o jpeglib/rdrle.o jpeglib/rdswitch.o jpeglib/rdtarga.o jpeglib/transupp.o jpeglib/wrbmp.o jpeglib/wrgif.o jpeglib/wrppm.o jpeglib/wrrle.o jpeglib/wrtarga.o -LIBPNGOBJ = libpng/png.o libpng/pngerror.o libpng/pngget.o libpng/pngmem.o libpng/pngpread.o libpng/pngread.o libpng/pngrio.o libpng/pngrtran.o libpng/pngrutil.o libpng/pngset.o libpng/pngtrans.o libpng/pngwio.o libpng/pngwrite.o libpng/pngwtran.o libpng/pngwutil.o -# Next variable is for additional scene nodes etc. of customized Irrlicht versions -EXTRAOBJ = -LINKOBJ = $(IRROBJ) $(IRRVIDEOOBJ) $(IRRSWRENDEROBJ) $(IRRIOOBJ) $(IRROTHEROBJ) $(IRRGUIOBJ) $(ZLIBOBJ) $(JPEGLIBOBJ) $(LIBPNGOBJ) $(EXTRAOBJ) - -############### -#Compiler flags -CXXINCS = -I../../include -Izlib -Ijpeglib -Ilibpng -CPPFLAGS = $(CXXINCS) -DIRRLICHT_EXPORTS=1 -CXXFLAGS = -Wall -ifndef NDEBUG -CXXFLAGS += -g -else -CXXFLAGS += -fexpensive-optimizations -O3 -endif -CFLAGS := -fexpensive-optimizations -O3 -DPNG_NO_MMX_CODE - -#Linux specific options -STATIC_LIB = libIrrlicht.a -SHARED_LIB = libIrrlicht.so -IRRLICHT_DLL := ../../bin/Win32-gcc/Irrlicht.dll -LIB_PATH = ../../lib/$(SYSTEM) -INSTALL_DIR = /usr/local/lib -staticlib sharedlib install: SYSTEM = Linux -staticlib sharedlib : LDFLAGS = -L/usr/X11R6/lib --no-export-all-symbols --add-stdcall-alias -lGLU -lGL -lXxf86vm -staticlib sharedlib : CXXINCS += -I/usr/X11R6/include - -#Windows specific options -sharedlib_win32 staticlib_win32: SYSTEM = Win32-gcc -sharedlib_win32: LDFLAGS = -lgdi32 -lwinspool -lcomdlg32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lglu32 -lopengl32 -sharedlib_win32 staticlib_win32: CPPFLAGS += -D__GNUWIN32__ -D_WIN32 -DWIN32 -D_WINDOWS -D_MBCS -D_USRDLL -staticlib_win32: CPPFLAGS += -D_IRR_STATIC_LIB_ - -#################### -# All target, builds Irrlicht as static lib (libIrrlicht.a) and copies it into /lib/Linux -all linux: staticlib - -# Builds Irrlicht as shared lib (libIrrlicht.so.versionNumber) and copies it into /lib/Linux -sharedlib: $(LINKOBJ) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -fPIC -o $(SHARED_LIB).$(VERSION) $^ $(LDFLAGS) - cp $(SHARED_LIB).$(VERSION) $(LIB_PATH) - -# Builds Irrlicht as static lib (libIrrlicht.a) -$(STATIC_LIB): $(LINKOBJ) - $(AR) rs $@ $^ - -# Copies static lib into /lib/Linux -staticlib: $(STATIC_LIB) - cp $^ $(LIB_PATH) - -# Builds Irrlicht as dll (Irrlicht.dll) into ../../bin/Win32-gcc -win32: sharedlib_win32 -sharedlib_win32: $(IRRLICHT_DLL) -../../bin/Win32-gcc/Irrlicht.dll: $(LINKOBJ) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -o $@ $^ $(LDFLAGS) -Wl,--out-implib,../../lib/Win32-gcc/$(STATIC_LIB) -# Copies static lib into /lib/Win32-gcc -staticlib_win32: $(STATIC_LIB) - cp $^ $(LIB_PATH) - -# Installs Irrlicht if it was created as shared lib -install: - cp $(LIB_PATH)/$(SHARED_LIB).$(VERSION) $(INSTALL_DIR) - cd $(INSTALL_DIR) && ln -s libIrrlicht.so.$(VERSION) $(SHARED_LIB) - ldconfig -n $(INSTALL_DIR) - -# Create dependency files for automatic recompilation -%.d:%.cpp - $(CXX) $(CPPFLAGS) -MM -MF $@ $< - --include $(LINKOBJ:.o=.d) - -help: - @echo "Available targets for Irrlicht" - @echo " sharedlib: Build shared library Irrlicht.so for Linux" - @echo " staticlib: Build static library Irrlicht.a for Linux" - @echo " install: Copy shared library to /usr/lib" - @echo "" - @echo " sharedlib_win32: Build shared library Irrlicht.dll for Windows" - @echo " staticlib_win32: Build static library Irrlicht.a for Windows" - @echo "" - @echo " clean: Clean up directory" - -# Cleans all temporary files and compilation results. -clean: - $(RM) $(LINKOBJ) $(SHARED_LIB).$(VERSION) $(STATIC_LIB) $(LINKOBJ:.o=.d) - -.PHONY: all sharedlib staticlib sharedlib_win32 staticlib_win32 help install clean - +VERSION = 1.3.0 +# Irrlicht Engine 1.3 +# Makefile for Linux, created by N.Gebhardt. +# +# To use, just run: +# +# make +# +# This will compile Irrlicht, create a static lib (libIrrlicht.a), and copy it +# into the subdirectory lib/Linux. That's all. +# +# If you want Irrlicht to be compiled as shared lib (libIrrlicht.so.versionnumber), then run: +# +# make sharedlib +# make install +# +# Please note that Irrlicht as shared lib is just experimental and +# probably not tested. +# + +#List of object files, separated based on engine architecture +IRROBJ = C3DSMeshFileLoader.o COgreMeshFileLoader.o COBJMeshFileLoader.o CAnimatedMeshMD2.o CAnimatedMeshMD3.o CMD3MeshFileLoader.o CAnimatedMeshMS3D.o CAnimatedMeshB3d.o CAnimatedMeshSceneNode.o CBillboardSceneNode.o CCameraFPSSceneNode.o CCameraMayaSceneNode.o CCameraSceneNode.o CColladaFileLoader.o CCSMLoader.o CDefaultMeshFormatLoader.o CDMFLoader.o CDummyTransformationSceneNode.o CEmptySceneNode.o CGeometryCreator.o CLightSceneNode.o CLMTSMeshFileLoader.o CMeshManipulator.o CMeshSceneNode.o CMetaTriangleSelector.o CMY3DMeshFileLoader.o COCTLoader.o COctTreeSceneNode.o COctTreeTriangleSelector.o CParticleBoxEmitter.o CParticleFadeOutAffector.o CParticleGravityAffector.o CParticlePointEmitter.o CParticleSystemSceneNode.o CQ3LevelMesh.o CSceneCollisionManager.o CSceneManager.o CSceneNodeAnimatorCollisionResponse.o CSceneNodeAnimatorDelete.o CSceneNodeAnimatorFlyCircle.o CSceneNodeAnimatorFlyStraight.o CSceneNodeAnimatorFollowSpline.o CSceneNodeAnimatorRotation.o CSceneNodeAnimatorTexture.o CShadowVolumeSceneNode.o CSkyBoxSceneNode.o CSkyDomeSceneNode.o CTerrainSceneNode.o CTerrainTriangleSelector.o CCubeSceneNode.o CSphereSceneNode.o CTextSceneNode.o CTriangleBBSelector.o CTriangleSelector.o CWaterSurfaceSceneNode.o CXAnimationPlayer.o CXFileReader.o CXMeshFileLoader.o CMeshCache.o CDefaultSceneNodeAnimatorFactory.o CDefaultSceneNodeFactory.o CQuake3ShaderSceneNode.o +IRRVIDEOOBJ = COpenGLDriver.o COpenGLNormalMapRenderer.o COpenGLParallaxMapRenderer.o COpenGLShaderMaterialRenderer.o COpenGLTexture.o COpenGLSLMaterialRenderer.o CD3D8Driver.o CD3D8NormalMapRenderer.o CD3D8ParallaxMapRenderer.o CD3D8ShaderMaterialRenderer.o CD3D8Texture.o CColorConverter.o CFPSCounter.o CImage.o CImageLoaderBMP.o CImageLoaderJPG.o CImageLoaderPCX.o CImageLoaderPNG.o CImageLoaderPSD.o CImageLoaderTGA.o CImageWriterBMP.o CImageWriterJPG.o CImageWriterPCX.o CImageWriterPNG.o CImageWriterPPM.o CImageWriterPSD.o CImageWriterTGA.o CNullDriver.o CD3D9Driver.o CD3D9HLSLMaterialRenderer.o CD3D9NormalMapRenderer.o CD3D9ParallaxMapRenderer.o CD3D9ShaderMaterialRenderer.o CD3D9Texture.o CVideoModeList.o +IRRSWRENDEROBJ = CSoftwareDriver.o CSoftwareTexture.o CTRFlat.o CTRFlatWire.o CTRGouraud.o CTRGouraudWire.o CTRTextureFlat.o CTRTextureFlatWire.o CTRTextureGouraud.o CTRTextureGouraudAdd.o CTRTextureGouraudNoZ.o CTRTextureGouraudWire.o CZBuffer.o CTRTextureGouraudVertexAlpha2.o CTRTextureGouraudNoZ2.o CTRTextureLightMap2_M2.o CTRTextureLightMap2_M4.o CTRTextureLightMap2_M1.o CSoftwareDriver2.o CSoftwareTexture2.o CTRTextureGouraud2.o CTRGouraud2.o CTRGouraudAlpha2.o CTRGouraudAlphaNoZ2.o CTRTextureDetailMap2.o CTRTextureGouraudAdd2.o CTRTextureGouraudAddNoZ2.o CTRTextureWire2.o CTRTextureLightMap2_Add.o CTRTextureLightMapGouraud2_M4.o IBurningShader.o CTRTextureBlend.o CTRTextureGouraudAlpha.o CTRTextureGouraudAlphaNoZ.o CDepthBuffer.o +IRRIOOBJ = CFileList.o CFileSystem.o CLimitReadFile.o CMemoryReadFile.o CReadFile.o CWriteFile.o CXMLReader.o CXMLWriter.o CZipReader.o CPakReader.o irrXML.o CAttributes.o +IRROTHEROBJ = CIrrDeviceLinux.o CIrrDeviceStub.o CIrrDeviceWin32.o CLogger.o COSOperator.o Irrlicht.o os.o +IRRGUIOBJ = CGUIButton.o CGUICheckBox.o CGUIComboBox.o CGUIContextMenu.o CGUIEditBox.o CGUIEnvironment.o CGUIFileOpenDialog.o CGUIFont.o CGUIImage.o CGUIInOutFader.o CGUIListBox.o CGUIMenu.o CGUIMeshViewer.o CGUIMessageBox.o CGUIModalScreen.o CGUIScrollBar.o CGUISkin.o CGUIStaticText.o CGUITabControl.o CGUIToolBar.o CGUIWindow.o CGUIColorSelectDialog.o CDefaultGUIElementFactory.o CGUISpriteBank.o +ZLIBOBJ = zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o zlib/uncompr.o zlib/zutil.o +JPEGLIBOBJ = jpeglib/jcapimin.o jpeglib/jcapistd.o jpeglib/jccoefct.o jpeglib/jccolor.o jpeglib/jcdctmgr.o jpeglib/jchuff.o jpeglib/jcinit.o jpeglib/jcmainct.o jpeglib/jcmarker.o jpeglib/jcmaster.o jpeglib/jcomapi.o jpeglib/jcparam.o jpeglib/jcphuff.o jpeglib/jcprepct.o jpeglib/jcsample.o jpeglib/jctrans.o jpeglib/jdapimin.o jpeglib/jdapistd.o jpeglib/jdatadst.o jpeglib/jdatasrc.o jpeglib/jdcoefct.o jpeglib/jdcolor.o jpeglib/jddctmgr.o jpeglib/jdhuff.o jpeglib/jdinput.o jpeglib/jdmainct.o jpeglib/jdmarker.o jpeglib/jdmaster.o jpeglib/jdmerge.o jpeglib/jdphuff.o jpeglib/jdpostct.o jpeglib/jdsample.o jpeglib/jdtrans.o jpeglib/jerror.o jpeglib/jfdctflt.o jpeglib/jfdctfst.o jpeglib/jfdctint.o jpeglib/jidctflt.o jpeglib/jidctfst.o jpeglib/jidctint.o jpeglib/jidctred.o jpeglib/jmemmgr.o jpeglib/jmemnobs.o jpeglib/jquant1.o jpeglib/jquant2.o jpeglib/jutils.o jpeglib/rdbmp.o jpeglib/rdcolmap.o jpeglib/rdgif.o jpeglib/rdppm.o jpeglib/rdrle.o jpeglib/rdswitch.o jpeglib/rdtarga.o jpeglib/transupp.o jpeglib/wrbmp.o jpeglib/wrgif.o jpeglib/wrppm.o jpeglib/wrrle.o jpeglib/wrtarga.o +LIBPNGOBJ = libpng/png.o libpng/pngerror.o libpng/pngget.o libpng/pngmem.o libpng/pngpread.o libpng/pngread.o libpng/pngrio.o libpng/pngrtran.o libpng/pngrutil.o libpng/pngset.o libpng/pngtrans.o libpng/pngwio.o libpng/pngwrite.o libpng/pngwtran.o libpng/pngwutil.o +# Next variable is for additional scene nodes etc. of customized Irrlicht versions +EXTRAOBJ = +LINKOBJ = $(IRROBJ) $(IRRVIDEOOBJ) $(IRRSWRENDEROBJ) $(IRRIOOBJ) $(IRROTHEROBJ) $(IRRGUIOBJ) $(ZLIBOBJ) $(JPEGLIBOBJ) $(LIBPNGOBJ) $(EXTRAOBJ) + +############### +#Compiler flags +CXXINCS = -I../../include -Izlib -Ijpeglib -Ilibpng +CPPFLAGS = $(CXXINCS) -DIRRLICHT_EXPORTS=1 +CXXFLAGS = -Wall +ifndef NDEBUG +CXXFLAGS += -g +else +CXXFLAGS += -fexpensive-optimizations -O3 +endif +CFLAGS := -fexpensive-optimizations -O3 -DPNG_NO_MMX_CODE + +#Linux specific options +STATIC_LIB = libIrrlicht.a +SHARED_LIB = libIrrlicht.so +IRRLICHT_DLL := ../../bin/Win32-gcc/Irrlicht.dll +LIB_PATH = ../../lib/$(SYSTEM) +INSTALL_DIR = /usr/local/lib +staticlib sharedlib install: SYSTEM = Linux +staticlib sharedlib : LDFLAGS = -L/usr/X11R6/lib --no-export-all-symbols --add-stdcall-alias -lGLU -lGL -lXxf86vm +staticlib sharedlib : CXXINCS += -I/usr/X11R6/include + +#Windows specific options +sharedlib_win32 staticlib_win32: SYSTEM = Win32-gcc +sharedlib_win32: LDFLAGS = -lgdi32 -lwinspool -lcomdlg32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lglu32 -lopengl32 +sharedlib_win32 staticlib_win32: CPPFLAGS += -D__GNUWIN32__ -D_WIN32 -DWIN32 -D_WINDOWS -D_MBCS -D_USRDLL +staticlib_win32: CPPFLAGS += -D_IRR_STATIC_LIB_ + +#################### +# All target, builds Irrlicht as static lib (libIrrlicht.a) and copies it into /lib/Linux +all linux: staticlib + +# Builds Irrlicht as shared lib (libIrrlicht.so.versionNumber) and copies it into /lib/Linux +sharedlib: $(LINKOBJ) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -fPIC -o $(SHARED_LIB).$(VERSION) $^ $(LDFLAGS) + cp $(SHARED_LIB).$(VERSION) $(LIB_PATH) + +# Builds Irrlicht as static lib (libIrrlicht.a) +$(STATIC_LIB): $(LINKOBJ) + $(AR) rs $@ $^ + +# Copies static lib into /lib/Linux +staticlib: $(STATIC_LIB) + cp $^ $(LIB_PATH) + +# Builds Irrlicht as dll (Irrlicht.dll) into ../../bin/Win32-gcc +win32: sharedlib_win32 +sharedlib_win32: $(IRRLICHT_DLL) +../../bin/Win32-gcc/Irrlicht.dll: $(LINKOBJ) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -o $@ $^ $(LDFLAGS) -Wl,--out-implib,../../lib/Win32-gcc/$(STATIC_LIB) +# Copies static lib into /lib/Win32-gcc +staticlib_win32: $(STATIC_LIB) + cp $^ $(LIB_PATH) + +# Installs Irrlicht if it was created as shared lib +install: + cp $(LIB_PATH)/$(SHARED_LIB).$(VERSION) $(INSTALL_DIR) + cd $(INSTALL_DIR) && ln -s libIrrlicht.so.$(VERSION) $(SHARED_LIB) + ldconfig -n $(INSTALL_DIR) + +# Create dependency files for automatic recompilation +%.d:%.cpp + $(CXX) $(CPPFLAGS) -MM -MF $@ $< + +-include $(LINKOBJ:.o=.d) + +help: + @echo "Available targets for Irrlicht" + @echo " sharedlib: Build shared library Irrlicht.so for Linux" + @echo " staticlib: Build static library Irrlicht.a for Linux" + @echo " install: Copy shared library to /usr/lib" + @echo "" + @echo " sharedlib_win32: Build shared library Irrlicht.dll for Windows" + @echo " staticlib_win32: Build static library Irrlicht.a for Windows" + @echo "" + @echo " clean: Clean up directory" + +# Cleans all temporary files and compilation results. +clean: + $(RM) $(LINKOBJ) $(SHARED_LIB).$(VERSION) $(STATIC_LIB) $(LINKOBJ:.o=.d) + +.PHONY: all sharedlib staticlib sharedlib_win32 staticlib_win32 help install clean + diff --git a/src/dep/src/irrlicht/OctTree.h b/src/dep/src/irrlicht/OctTree.h index 83c7985..fad90eb 100644 --- a/src/dep/src/irrlicht/OctTree.h +++ b/src/dep/src/irrlicht/OctTree.h @@ -1,432 +1,432 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OCT_TREE_H_INCLUDED__ -#define __C_OCT_TREE_H_INCLUDED__ - -#include "SViewFrustum.h" -#include "S3DVertex.h" -#include "aabbox3d.h" -#include "irrArray.h" -#include "irrString.h" - -namespace irr -{ - -//! template octtree. T must be a vertex type which has a member -//! called .Pos, which is a core::vertex3df position. -template -class OctTree -{ -public: - - u32 nodeCount; - - struct SMeshChunk - { - core::array Vertices; - core::array Indices; - s32 MaterialId; - }; - - struct SIndexChunk - { - core::array Indices; - s32 MaterialId; - }; - - struct SIndexData - { - u16* Indices; - s32 CurrentSize; - s32 MaxSize; - }; - - - - //! constructor - OctTree(const core::array& meshes, s32 minimalPolysPerNode=128) - { - nodeCount = 0; - - IndexDataCount = meshes.size(); - IndexData = new SIndexData[IndexDataCount]; - - // construct array of all indices - - core::array* indexChunks = new core::array; - SIndexChunk ic; - - for (u32 i=0; ipush_back(ic); - - SIndexChunk& tic = (*indexChunks)[i]; - - for (u32 t=0; t& box) - { - for (u32 i=0; igetPolys(box, IndexData, 0); - } - - //! returns all ids of polygons partially or fully enclosed - //! by a view frustum. - void calculatePolys(const scene::SViewFrustum& frustum) - { - for (u32 i=0; igetPolys(frustum, IndexData); - } - - - SIndexData* getIndexData() - { - return IndexData; - } - - u32 getIndexDataCount() - { - return IndexDataCount; - } - - // for debug purposes only, renders the bounding boxes of the tree - void renderBoundingBoxes(const core::aabbox3d& box, - core::array< core::aabbox3d >&outBoxes) - { - Root->renderBoundingBoxes(box, outBoxes); - } - - //! destructor - ~OctTree() - { - for (u32 i=0; i& allmeshdata, - core::array* indices, - s32 minimalPolysPerNode) : IndexData(0), - Depth(currentdepth+1) - { - ++nodeCount; - - u32 i; // new ISO for scoping problem with different compilers - - for (i=0; i<8; ++i) - Children[i] = 0; - - if (indices->empty()) - { - delete indices; - return; - } - - bool found = false; - - // find first point for bounding box - - for (i=0; isize(); ++i) - { - if (!(*indices)[i].Indices.empty()) - { - Box.reset(allmeshdata[i].Vertices[(*indices)[i].Indices[0]].Pos); - found = true; - break; - } - } - - if (!found) - { - delete indices; - return; - } - - s32 totalPrimitives = 0; - - // now lets calculate our bounding box - for (i=0; isize(); ++i) - { - totalPrimitives += (*indices)[i].Indices.size(); - for (u32 j=0; j<(*indices)[i].Indices.size(); ++j) - Box.addInternalPoint(allmeshdata[i].Vertices[(*indices)[i].Indices[j]].Pos); - } - - core::vector3df middle = Box.getCenter(); - core::vector3df edges[8]; - Box.getEdges(edges); - - // calculate all children - core::aabbox3d box; - - if (totalPrimitives > minimalPolysPerNode && !Box.isEmpty()) - for (s32 ch=0; ch<8; ++ch) - { - box.reset(middle); - box.addInternalPoint(edges[ch]); - - // create indices for child - core::array* cindexChunks = new core::array; - - bool added = false; - - for (i=0; ipush_back(ic); - - SIndexChunk& tic = (*cindexChunks)[i]; - - for (u32 t=0; t<(*indices)[i].Indices.size(); t+=3) - { - if (box.isPointInside(allmeshdata[i].Vertices[(*indices)[i].Indices[t]].Pos) && - box.isPointInside(allmeshdata[i].Vertices[(*indices)[i].Indices[t+1]].Pos) && - box.isPointInside(allmeshdata[i].Vertices[(*indices)[i].Indices[t+2]].Pos)) - { - tic.Indices.push_back((*indices)[i].Indices[t]); - tic.Indices.push_back((*indices)[i].Indices[t+1]); - tic.Indices.push_back((*indices)[i].Indices[t+2]); - - (*indices)[i].Indices.erase(t, 3); - - t-=3; - - added = true; - } - } - } - - if (added) - Children[ch] = new OctTreeNode(nodeCount, Depth, - allmeshdata, cindexChunks, minimalPolysPerNode); - else - delete cindexChunks; - - } // end for all possible children - - IndexData = indices; - } - - - - // destructor - ~OctTreeNode() - { - delete IndexData; - - for (u32 i=0; i<8; ++i) - delete Children[i]; - } - - - - // returns all ids of polygons partially or full enclosed - // by this bounding box. - void getPolys(const core::aabbox3d& box, SIndexData* idxdata, u32 parentTest ) const - { - // if not full inside - if ( parentTest != 2 ) - { - // partially inside ? - parentTest = (u32) Box.intersectsWithBox(box); - if ( 0 == parentTest ) - return; - - // fully inside ? - parentTest+= Box.isFullInside(box); - } - - //if (Box.intersectsWithBox(box)) - { - u32 cnt = IndexData->size(); - u32 i; // new ISO for scoping problem in some compilers - - for (i=0; igetPolys(box, idxdata,parentTest); - } - } - - -#if 0 - // returns all ids of polygons partially or full enclosed - // by the view frustum. - void getPolys(const scene::SViewFrustum& frustum, SIndexData* idxdata,u32 parentTest) const - { - // not full inside - //if ( parentTest != 2 ) - { - s32 i; // new ISO for scoping problem in some compilers - - core::vector3df edges[8]; - Box.getEdges(edges); - - u32 bitTest = 0; - for (i=0; isize(); - - for (i=0; igetPolys(frustum, idxdata,parentTest); - } -#endif - - // returns all ids of polygons partially or full enclosed - // by the view frustum. - void getPolys(const scene::SViewFrustum& frustum, SIndexData* idxdata,u32 parentTest) const - { - u32 totalIn = 0; - s32 i; // new ISO for scoping problem in some compilers - - // not full inside - //if ( parentTest != 2 ) - { - - core::vector3df edges[8]; - Box.getEdges(edges); - - u32 bitTest = 0; - for (i=0; isize(); - - for (i=0; igetPolys(frustum, idxdata,parentTest); - } - - - - void renderBoundingBoxes(const core::aabbox3d& box, - core::array< core::aabbox3d >&outBoxes) - { - if (Box.intersectsWithBox(box)) - { - outBoxes.push_back(Box); - - for (u32 i=0; i<8; ++i) - if (Children[i]) - Children[i]->renderBoundingBoxes(box, outBoxes); - } - } - - private: - - core::aabbox3df Box; - core::array* IndexData; - OctTreeNode* Children[8]; - u32 Depth; - }; - - OctTreeNode* Root; - SIndexData* IndexData; - u32 IndexDataCount; -}; - -} // end namespace - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_OCT_TREE_H_INCLUDED__ +#define __C_OCT_TREE_H_INCLUDED__ + +#include "SViewFrustum.h" +#include "S3DVertex.h" +#include "aabbox3d.h" +#include "irrArray.h" +#include "irrString.h" + +namespace irr +{ + +//! template octtree. T must be a vertex type which has a member +//! called .Pos, which is a core::vertex3df position. +template +class OctTree +{ +public: + + u32 nodeCount; + + struct SMeshChunk + { + core::array Vertices; + core::array Indices; + s32 MaterialId; + }; + + struct SIndexChunk + { + core::array Indices; + s32 MaterialId; + }; + + struct SIndexData + { + u16* Indices; + s32 CurrentSize; + s32 MaxSize; + }; + + + + //! constructor + OctTree(const core::array& meshes, s32 minimalPolysPerNode=128) + { + nodeCount = 0; + + IndexDataCount = meshes.size(); + IndexData = new SIndexData[IndexDataCount]; + + // construct array of all indices + + core::array* indexChunks = new core::array; + SIndexChunk ic; + + for (u32 i=0; ipush_back(ic); + + SIndexChunk& tic = (*indexChunks)[i]; + + for (u32 t=0; t& box) + { + for (u32 i=0; igetPolys(box, IndexData, 0); + } + + //! returns all ids of polygons partially or fully enclosed + //! by a view frustum. + void calculatePolys(const scene::SViewFrustum& frustum) + { + for (u32 i=0; igetPolys(frustum, IndexData); + } + + + SIndexData* getIndexData() + { + return IndexData; + } + + u32 getIndexDataCount() + { + return IndexDataCount; + } + + // for debug purposes only, renders the bounding boxes of the tree + void renderBoundingBoxes(const core::aabbox3d& box, + core::array< core::aabbox3d >&outBoxes) + { + Root->renderBoundingBoxes(box, outBoxes); + } + + //! destructor + ~OctTree() + { + for (u32 i=0; i& allmeshdata, + core::array* indices, + s32 minimalPolysPerNode) : IndexData(0), + Depth(currentdepth+1) + { + ++nodeCount; + + u32 i; // new ISO for scoping problem with different compilers + + for (i=0; i<8; ++i) + Children[i] = 0; + + if (indices->empty()) + { + delete indices; + return; + } + + bool found = false; + + // find first point for bounding box + + for (i=0; isize(); ++i) + { + if (!(*indices)[i].Indices.empty()) + { + Box.reset(allmeshdata[i].Vertices[(*indices)[i].Indices[0]].Pos); + found = true; + break; + } + } + + if (!found) + { + delete indices; + return; + } + + s32 totalPrimitives = 0; + + // now lets calculate our bounding box + for (i=0; isize(); ++i) + { + totalPrimitives += (*indices)[i].Indices.size(); + for (u32 j=0; j<(*indices)[i].Indices.size(); ++j) + Box.addInternalPoint(allmeshdata[i].Vertices[(*indices)[i].Indices[j]].Pos); + } + + core::vector3df middle = Box.getCenter(); + core::vector3df edges[8]; + Box.getEdges(edges); + + // calculate all children + core::aabbox3d box; + + if (totalPrimitives > minimalPolysPerNode && !Box.isEmpty()) + for (s32 ch=0; ch<8; ++ch) + { + box.reset(middle); + box.addInternalPoint(edges[ch]); + + // create indices for child + core::array* cindexChunks = new core::array; + + bool added = false; + + for (i=0; ipush_back(ic); + + SIndexChunk& tic = (*cindexChunks)[i]; + + for (u32 t=0; t<(*indices)[i].Indices.size(); t+=3) + { + if (box.isPointInside(allmeshdata[i].Vertices[(*indices)[i].Indices[t]].Pos) && + box.isPointInside(allmeshdata[i].Vertices[(*indices)[i].Indices[t+1]].Pos) && + box.isPointInside(allmeshdata[i].Vertices[(*indices)[i].Indices[t+2]].Pos)) + { + tic.Indices.push_back((*indices)[i].Indices[t]); + tic.Indices.push_back((*indices)[i].Indices[t+1]); + tic.Indices.push_back((*indices)[i].Indices[t+2]); + + (*indices)[i].Indices.erase(t, 3); + + t-=3; + + added = true; + } + } + } + + if (added) + Children[ch] = new OctTreeNode(nodeCount, Depth, + allmeshdata, cindexChunks, minimalPolysPerNode); + else + delete cindexChunks; + + } // end for all possible children + + IndexData = indices; + } + + + + // destructor + ~OctTreeNode() + { + delete IndexData; + + for (u32 i=0; i<8; ++i) + delete Children[i]; + } + + + + // returns all ids of polygons partially or full enclosed + // by this bounding box. + void getPolys(const core::aabbox3d& box, SIndexData* idxdata, u32 parentTest ) const + { + // if not full inside + if ( parentTest != 2 ) + { + // partially inside ? + parentTest = (u32) Box.intersectsWithBox(box); + if ( 0 == parentTest ) + return; + + // fully inside ? + parentTest+= Box.isFullInside(box); + } + + //if (Box.intersectsWithBox(box)) + { + u32 cnt = IndexData->size(); + u32 i; // new ISO for scoping problem in some compilers + + for (i=0; igetPolys(box, idxdata,parentTest); + } + } + + +#if 0 + // returns all ids of polygons partially or full enclosed + // by the view frustum. + void getPolys(const scene::SViewFrustum& frustum, SIndexData* idxdata,u32 parentTest) const + { + // not full inside + //if ( parentTest != 2 ) + { + s32 i; // new ISO for scoping problem in some compilers + + core::vector3df edges[8]; + Box.getEdges(edges); + + u32 bitTest = 0; + for (i=0; isize(); + + for (i=0; igetPolys(frustum, idxdata,parentTest); + } +#endif + + // returns all ids of polygons partially or full enclosed + // by the view frustum. + void getPolys(const scene::SViewFrustum& frustum, SIndexData* idxdata,u32 parentTest) const + { + u32 totalIn = 0; + s32 i; // new ISO for scoping problem in some compilers + + // not full inside + //if ( parentTest != 2 ) + { + + core::vector3df edges[8]; + Box.getEdges(edges); + + u32 bitTest = 0; + for (i=0; isize(); + + for (i=0; igetPolys(frustum, idxdata,parentTest); + } + + + + void renderBoundingBoxes(const core::aabbox3d& box, + core::array< core::aabbox3d >&outBoxes) + { + if (Box.intersectsWithBox(box)) + { + outBoxes.push_back(Box); + + for (u32 i=0; i<8; ++i) + if (Children[i]) + Children[i]->renderBoundingBoxes(box, outBoxes); + } + } + + private: + + core::aabbox3df Box; + core::array* IndexData; + OctTreeNode* Children[8]; + u32 Depth; + }; + + OctTreeNode* Root; + SIndexData* IndexData; + u32 IndexDataCount; +}; + +} // end namespace + +#endif + diff --git a/src/dep/src/irrlicht/S2DVertex.h b/src/dep/src/irrlicht/S2DVertex.h index 9127ff2..b6b6335 100644 --- a/src/dep/src/irrlicht/S2DVertex.h +++ b/src/dep/src/irrlicht/S2DVertex.h @@ -1,30 +1,30 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_K_2D_VERTEX_H_INCLUDED__ -#define __S_K_2D_VERTEX_H_INCLUDED__ - -#include "vector2d.h" - -typedef signed short TZBufferType; - -namespace irr -{ -namespace video -{ - - struct S2DVertex - { - core::vector2d Pos; // position - core::vector2d TCoords; // texture coordinates - TZBufferType ZValue; // zvalue - u16 Color; - }; - - -} // end namespace video -} // end namespace irr - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __S_K_2D_VERTEX_H_INCLUDED__ +#define __S_K_2D_VERTEX_H_INCLUDED__ + +#include "vector2d.h" + +typedef signed short TZBufferType; + +namespace irr +{ +namespace video +{ + + struct S2DVertex + { + core::vector2d Pos; // position + core::vector2d TCoords; // texture coordinates + TZBufferType ZValue; // zvalue + u16 Color; + }; + + +} // end namespace video +} // end namespace irr + +#endif + diff --git a/src/dep/src/irrlicht/S4DVertex.h b/src/dep/src/irrlicht/S4DVertex.h index 90ecb51..4f6cb85 100644 --- a/src/dep/src/irrlicht/S4DVertex.h +++ b/src/dep/src/irrlicht/S4DVertex.h @@ -1,501 +1,501 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - - -#ifndef __S_4D_VERTEX_H_INCLUDED__ -#define __S_4D_VERTEX_H_INCLUDED__ - -#include "SoftwareDriver2_compile_config.h" -#include "SoftwareDriver2_helper.h" -#include "irrAllocator.h" - -namespace irr -{ - -namespace video -{ - -struct sVec2 -{ - f32 x; - f32 y; - - sVec2 () {} - - sVec2 ( f32 _x, f32 _y ) - : x ( _x ), y ( _y ) {} - - void set ( f32 _x, f32 _y ) - { - x = _x; - y = _y; - } - - // f = a * t + b * ( 1 - t ) - void interpolate(const sVec2& a, const sVec2& b, const f32 t) - { - x = b.x + ( ( a.x - b.x ) * t ); - y = b.y + ( ( a.y - b.y ) * t ); - } - - sVec2 operator-(const sVec2& other) const - { - return sVec2(x - other.x, y - other.y); - } - - sVec2 operator+(const sVec2& other) const - { - return sVec2(x + other.x, y + other.y); - } - - void operator+=(const sVec2& other) - { - x += other.x; - y += other.y; - } - - sVec2 operator*(const f32 s) const - { - return sVec2(x * s , y * s); - } - - void operator*=( const f32 s) - { - x *= s; - y *= s; - } - - void operator=(const sVec2& other) - { - x = other.x; - y = other.y; - } - -}; - -// A8R8G8B8 -struct sVec4; -struct sCompressedVec4 -{ - u32 argb; - - void setA8R8G8B8 ( u32 value ) - { - argb = value; - } - - void setColorf ( const irr::video::SColorf & color ) - { - argb = core::floor32 ( color.a * 255.f ) << 24 | - core::floor32 ( color.r * 255.f ) << 16 | - core::floor32 ( color.g * 255.f ) << 8 | - core::floor32 ( color.b * 255.f ); - } - - void setVec4 ( const sVec4 & v ); - - // f = a * t + b * ( 1 - t ) - void interpolate(const sCompressedVec4& a, const sCompressedVec4& b, const f32 t) - { - argb = PixelBlend32 ( b.argb, a.argb, core::floor32 ( t * 256.f ) ); - } - - -}; - - -struct sVec4 -{ - f32 x, y, z, w; - - sVec4 () {} - - sVec4 ( f32 _x, f32 _y, f32 _z, f32 _w ) - : x ( _x ), y ( _y ), z( _z ), w ( _w ){} - - void set ( f32 _x, f32 _y, f32 _z, f32 _w ) - { - x = _x; - y = _y; - z = _z; - w = _w; - } - - void setA8R8G8B8 ( u32 argb ) - { - x = ( ( argb & 0xFF000000 ) >> 24 ) * ( 1.f / 255.f ); - y = ( ( argb & 0x00FF0000 ) >> 16 ) * ( 1.f / 255.f ); - z = ( ( argb & 0x0000FF00 ) >> 8 ) * ( 1.f / 255.f ); - w = ( ( argb & 0x000000FF ) ) * ( 1.f / 255.f ); - } - - - void setColorf ( const irr::video::SColorf & color ) - { - x = color.a; - y = color.r; - z = color.g; - w = color.b; - } - - void saturate () - { - x = core::clamp ( x, 0.f, 1.f ); - y = core::clamp ( y, 0.f, 1.f ); - z = core::clamp ( z, 0.f, 1.f ); - w = core::clamp ( w, 0.f, 1.f ); - } - - // f = a * t + b * ( 1 - t ) - void interpolate(const sVec4& a, const sVec4& b, const f32 t) - { - x = b.x + ( ( a.x - b.x ) * t ); - y = b.y + ( ( a.y - b.y ) * t ); - z = b.z + ( ( a.z - b.z ) * t ); - w = b.w + ( ( a.w - b.w ) * t ); - } - - - f32 dotProduct(const sVec4& other) const - { - return x*other.x + y*other.y + z*other.z + w*other.w; - } - - f32 dot_xyz( const sVec4& other) const - { - return x*other.x + y*other.y + z*other.z; - } - - f32 get_length_xyz () const - { - return sqrtf ( x * x + y * y + z * z ); - } - - f32 get_inverse_length_xyz () const - { - return core::reciprocal_squareroot ( x * x + y * y + z * z ); - } - - - void normalize_xyz () - { - const f32 l = core::reciprocal_squareroot ( x * x + y * y + z * z ); - - x *= l; - y *= l; - z *= l; - } - - void project_xyz () - { - w = core::reciprocal ( w ); - x *= w; - y *= w; - z *= w; - } - - sVec4 operator-(const sVec4& other) const - { - return sVec4(x - other.x, y - other.y, z - other.z,w - other.w); - } - - sVec4 operator+(const sVec4& other) const - { - return sVec4(x + other.x, y + other.y, z + other.z,w + other.w); - } - - void operator+=(const sVec4& other) - { - x += other.x; - y += other.y; - z += other.z; - w += other.w; - } - - sVec4 operator*(f32 s) const - { - return sVec4(x * s , y * s, z * s,w * s); - } - - sVec4 operator*(const sVec4 &other) const - { - return sVec4(x * other.x , y * other.y, z * other.z,w * other.w); - } - - void operator*=(f32 s) - { - x *= s; - y *= s; - z *= s; - w *= s; - } - - void operator*=(const sVec4 &other) - { - x *= other.x; - y *= other.y; - z *= other.z; - w *= other.w; - } - - void operator=(const sVec4& other) - { - x = other.x; - y = other.y; - z = other.z; - w = other.w; - } -}; - -inline void sCompressedVec4::setVec4 ( const sVec4 & v ) -{ - argb = core::floor32 ( v.x * 255.f ) << 24 | - core::floor32 ( v.y * 255.f ) << 16 | - core::floor32 ( v.z * 255.f ) << 8 | - core::floor32 ( v.w * 255.f ); -} - - -enum e4DVertexFlag -{ - VERTEX4D_INSIDE = 0x0000003F, - VERTEX4D_CLIPMASK = 0x0000003F, - VERTEX4D_PROJECTED = 0x00000100, - - VERTEX4D_FORMAT_MASK = 0xFFFF0000, - VERTEX4D_FORMAT_0 = 0x00010000, - VERTEX4D_FORMAT_1 = VERTEX4D_FORMAT_0 | 0x00020000, - VERTEX4D_FORMAT_2 = VERTEX4D_FORMAT_1 | 0x00040000 -}; - -// dummy Vertex -struct __s4DVertex -{ - sVec4 Pos; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - sVec4 Color[1]; -#endif - - sVec2 Tex[2]; - u32 flag; -}; - -#define SIZEOF_SVERTEX 64 -#define SIZEOF_SVERTEX_LOG2 6 - -struct s4DVertex -{ - sVec4 Pos; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - sVec4 Color[1]; -#endif - - sVec2 Tex[2]; - - u32 flag; - - u8 fill [ SIZEOF_SVERTEX - sizeof (__s4DVertex) ]; - - // f = a * t + b * ( 1 - t ) - void interpolate(const s4DVertex& b, const s4DVertex& a, const f32 t) - { - Pos.interpolate ( a.Pos, b.Pos, t ); - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - Color[0].interpolate ( a.Color[0], b.Color[0], t ); -#endif - - Tex[0].interpolate ( a.Tex[0], b.Tex[0], t ); - - if ( (flag & VERTEX4D_FORMAT_1 ) == VERTEX4D_FORMAT_1 ) - { - Tex[1].interpolate ( a.Tex[1], b.Tex[1], t ); - } - - - } -}; - -// ----------------- Vertex Cache --------------------------- - -struct SAlignedVertex -{ - SAlignedVertex ( u32 element, u32 aligned ) - : ElementSize ( element ) - { - u32 byteSize = (ElementSize << SIZEOF_SVERTEX_LOG2 ) + aligned; - mem = new u8 [ byteSize ]; - //data = (s4DVertex*) ((PointerAsValue ( mem ) + (aligned-1) ) & ~ ( aligned - 1 ) ); - data = (s4DVertex*) mem; - } - - virtual ~SAlignedVertex () - { - delete [] mem; - } - - s4DVertex *data; - u8 *mem; - u32 ElementSize; -}; - - -// hold info for different Vertex Types -struct SVSize -{ - u32 Format; - u32 Pitch; - u32 TexSize; -}; - - -// a cache info -struct SCacheInfo -{ - u32 index; - u32 hit; -}; - -#define VERTEXCACHE_ELEMENT 16 -#define VERTEXCACHE_MISS 0xFFFFFFFF -struct SVertexCache -{ - SVertexCache (): mem ( VERTEXCACHE_ELEMENT * 2, 128 ) {} - - SCacheInfo info[VERTEXCACHE_ELEMENT]; - - - // Transformed and lite, clipping state - // + Clipped, Projected - SAlignedVertex mem; - - // source - const void* vertices; - u32 vertexCount; - - const u16* indices; - u32 indexCount; - u32 indicesIndex; - - u32 indicesRun; - - // primitives consist of x vertices - u32 primitivePitch; - - u32 vType; //E_VERTEX_TYPE - u32 pType; //scene::E_PRIMITIVE_TYPE - -}; - - -// swap 2 pointer -inline void swapVertexPointer(const s4DVertex** v1, const s4DVertex** v2) -{ - const s4DVertex* b = *v1; - *v1 = *v2; - *v2 = b; -} - - -// ------------------------ Internal Scanline Rasterizer ----------------------------- - - -// internal scan convert -struct sScanConvertData -{ - s32 left; // major edge left/right - s32 right; // !left - - f32 invDeltaY[3]; // inverse edge delta y - - f32 x[2]; // x coordinate - f32 slopeX[2]; // x slope along edges - -#if defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) || defined ( SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT ) - f32 w[2]; // w coordinate - fp24 slopeW[2]; // w slope along edges -#else - f32 z[2]; // z coordinate - f32 slopeZ[2]; // z slope along edges -#endif - - sVec4 c[2]; // color - sVec4 slopeC[2]; // color slope along edges - - sVec2 t0[2]; // texture - sVec2 slopeT0[2]; // texture slope along edges - - sVec2 t1[2]; // texture - sVec2 slopeT1[2]; // texture slope along edges - -}; - -// passed to scan Line -struct sScanLineData -{ - s32 y; // y position of scanline - f32 x[2]; // x start, x end of scanline - -#if defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) || defined ( SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT ) - f32 w[2]; // w start, w end of scanline -#else - f32 z[2]; // z start, z end of scanline -#endif - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - sVec4 c[2]; // color start, color end of scanline -#endif - - sVec2 t0[2]; // texture start, texture end of scanline - sVec2 t1[2]; // texture start, texture end of scanline -}; - - -/* - load a color value -*/ -inline void getTexel_plain ( tFixPoint &r, tFixPoint &g, tFixPoint &b, - const sVec4 &v - ) -{ - r = f32_to_fixPoint ( v.y ); - g = f32_to_fixPoint ( v.z ); - b = f32_to_fixPoint ( v.w ); -} - -/* - load a color value -*/ -inline void getSample_color ( tFixPoint &a, tFixPoint &r, tFixPoint &g, tFixPoint &b, - const sVec4 &v - ) -{ - a = f32_to_fixPoint ( v.x ); - r = f32_to_fixPoint ( v.y, COLOR_MAX * FIX_POINT_F32_MUL); - g = f32_to_fixPoint ( v.z, COLOR_MAX * FIX_POINT_F32_MUL); - b = f32_to_fixPoint ( v.w, COLOR_MAX * FIX_POINT_F32_MUL); -} - -/* - load a color value -*/ -inline void getSample_color ( tFixPoint &r, tFixPoint &g, tFixPoint &b, - const sVec4 &v - ) -{ - r = f32_to_fixPoint ( v.y, COLOR_MAX * FIX_POINT_F32_MUL); - g = f32_to_fixPoint ( v.z, COLOR_MAX * FIX_POINT_F32_MUL); - b = f32_to_fixPoint ( v.w, COLOR_MAX * FIX_POINT_F32_MUL); -} - - - -} - -} - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + + +#ifndef __S_4D_VERTEX_H_INCLUDED__ +#define __S_4D_VERTEX_H_INCLUDED__ + +#include "SoftwareDriver2_compile_config.h" +#include "SoftwareDriver2_helper.h" +#include "irrAllocator.h" + +namespace irr +{ + +namespace video +{ + +struct sVec2 +{ + f32 x; + f32 y; + + sVec2 () {} + + sVec2 ( f32 _x, f32 _y ) + : x ( _x ), y ( _y ) {} + + void set ( f32 _x, f32 _y ) + { + x = _x; + y = _y; + } + + // f = a * t + b * ( 1 - t ) + void interpolate(const sVec2& a, const sVec2& b, const f32 t) + { + x = b.x + ( ( a.x - b.x ) * t ); + y = b.y + ( ( a.y - b.y ) * t ); + } + + sVec2 operator-(const sVec2& other) const + { + return sVec2(x - other.x, y - other.y); + } + + sVec2 operator+(const sVec2& other) const + { + return sVec2(x + other.x, y + other.y); + } + + void operator+=(const sVec2& other) + { + x += other.x; + y += other.y; + } + + sVec2 operator*(const f32 s) const + { + return sVec2(x * s , y * s); + } + + void operator*=( const f32 s) + { + x *= s; + y *= s; + } + + void operator=(const sVec2& other) + { + x = other.x; + y = other.y; + } + +}; + +// A8R8G8B8 +struct sVec4; +struct sCompressedVec4 +{ + u32 argb; + + void setA8R8G8B8 ( u32 value ) + { + argb = value; + } + + void setColorf ( const irr::video::SColorf & color ) + { + argb = core::floor32 ( color.a * 255.f ) << 24 | + core::floor32 ( color.r * 255.f ) << 16 | + core::floor32 ( color.g * 255.f ) << 8 | + core::floor32 ( color.b * 255.f ); + } + + void setVec4 ( const sVec4 & v ); + + // f = a * t + b * ( 1 - t ) + void interpolate(const sCompressedVec4& a, const sCompressedVec4& b, const f32 t) + { + argb = PixelBlend32 ( b.argb, a.argb, core::floor32 ( t * 256.f ) ); + } + + +}; + + +struct sVec4 +{ + f32 x, y, z, w; + + sVec4 () {} + + sVec4 ( f32 _x, f32 _y, f32 _z, f32 _w ) + : x ( _x ), y ( _y ), z( _z ), w ( _w ){} + + void set ( f32 _x, f32 _y, f32 _z, f32 _w ) + { + x = _x; + y = _y; + z = _z; + w = _w; + } + + void setA8R8G8B8 ( u32 argb ) + { + x = ( ( argb & 0xFF000000 ) >> 24 ) * ( 1.f / 255.f ); + y = ( ( argb & 0x00FF0000 ) >> 16 ) * ( 1.f / 255.f ); + z = ( ( argb & 0x0000FF00 ) >> 8 ) * ( 1.f / 255.f ); + w = ( ( argb & 0x000000FF ) ) * ( 1.f / 255.f ); + } + + + void setColorf ( const irr::video::SColorf & color ) + { + x = color.a; + y = color.r; + z = color.g; + w = color.b; + } + + void saturate () + { + x = core::clamp ( x, 0.f, 1.f ); + y = core::clamp ( y, 0.f, 1.f ); + z = core::clamp ( z, 0.f, 1.f ); + w = core::clamp ( w, 0.f, 1.f ); + } + + // f = a * t + b * ( 1 - t ) + void interpolate(const sVec4& a, const sVec4& b, const f32 t) + { + x = b.x + ( ( a.x - b.x ) * t ); + y = b.y + ( ( a.y - b.y ) * t ); + z = b.z + ( ( a.z - b.z ) * t ); + w = b.w + ( ( a.w - b.w ) * t ); + } + + + f32 dotProduct(const sVec4& other) const + { + return x*other.x + y*other.y + z*other.z + w*other.w; + } + + f32 dot_xyz( const sVec4& other) const + { + return x*other.x + y*other.y + z*other.z; + } + + f32 get_length_xyz () const + { + return sqrtf ( x * x + y * y + z * z ); + } + + f32 get_inverse_length_xyz () const + { + return core::reciprocal_squareroot ( x * x + y * y + z * z ); + } + + + void normalize_xyz () + { + const f32 l = core::reciprocal_squareroot ( x * x + y * y + z * z ); + + x *= l; + y *= l; + z *= l; + } + + void project_xyz () + { + w = core::reciprocal ( w ); + x *= w; + y *= w; + z *= w; + } + + sVec4 operator-(const sVec4& other) const + { + return sVec4(x - other.x, y - other.y, z - other.z,w - other.w); + } + + sVec4 operator+(const sVec4& other) const + { + return sVec4(x + other.x, y + other.y, z + other.z,w + other.w); + } + + void operator+=(const sVec4& other) + { + x += other.x; + y += other.y; + z += other.z; + w += other.w; + } + + sVec4 operator*(f32 s) const + { + return sVec4(x * s , y * s, z * s,w * s); + } + + sVec4 operator*(const sVec4 &other) const + { + return sVec4(x * other.x , y * other.y, z * other.z,w * other.w); + } + + void operator*=(f32 s) + { + x *= s; + y *= s; + z *= s; + w *= s; + } + + void operator*=(const sVec4 &other) + { + x *= other.x; + y *= other.y; + z *= other.z; + w *= other.w; + } + + void operator=(const sVec4& other) + { + x = other.x; + y = other.y; + z = other.z; + w = other.w; + } +}; + +inline void sCompressedVec4::setVec4 ( const sVec4 & v ) +{ + argb = core::floor32 ( v.x * 255.f ) << 24 | + core::floor32 ( v.y * 255.f ) << 16 | + core::floor32 ( v.z * 255.f ) << 8 | + core::floor32 ( v.w * 255.f ); +} + + +enum e4DVertexFlag +{ + VERTEX4D_INSIDE = 0x0000003F, + VERTEX4D_CLIPMASK = 0x0000003F, + VERTEX4D_PROJECTED = 0x00000100, + + VERTEX4D_FORMAT_MASK = 0xFFFF0000, + VERTEX4D_FORMAT_0 = 0x00010000, + VERTEX4D_FORMAT_1 = VERTEX4D_FORMAT_0 | 0x00020000, + VERTEX4D_FORMAT_2 = VERTEX4D_FORMAT_1 | 0x00040000 +}; + +// dummy Vertex +struct __s4DVertex +{ + sVec4 Pos; + +#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + sVec4 Color[1]; +#endif + + sVec2 Tex[2]; + u32 flag; +}; + +#define SIZEOF_SVERTEX 64 +#define SIZEOF_SVERTEX_LOG2 6 + +struct s4DVertex +{ + sVec4 Pos; + +#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + sVec4 Color[1]; +#endif + + sVec2 Tex[2]; + + u32 flag; + + u8 fill [ SIZEOF_SVERTEX - sizeof (__s4DVertex) ]; + + // f = a * t + b * ( 1 - t ) + void interpolate(const s4DVertex& b, const s4DVertex& a, const f32 t) + { + Pos.interpolate ( a.Pos, b.Pos, t ); + +#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + Color[0].interpolate ( a.Color[0], b.Color[0], t ); +#endif + + Tex[0].interpolate ( a.Tex[0], b.Tex[0], t ); + + if ( (flag & VERTEX4D_FORMAT_1 ) == VERTEX4D_FORMAT_1 ) + { + Tex[1].interpolate ( a.Tex[1], b.Tex[1], t ); + } + + + } +}; + +// ----------------- Vertex Cache --------------------------- + +struct SAlignedVertex +{ + SAlignedVertex ( u32 element, u32 aligned ) + : ElementSize ( element ) + { + u32 byteSize = (ElementSize << SIZEOF_SVERTEX_LOG2 ) + aligned; + mem = new u8 [ byteSize ]; + //data = (s4DVertex*) ((PointerAsValue ( mem ) + (aligned-1) ) & ~ ( aligned - 1 ) ); + data = (s4DVertex*) mem; + } + + virtual ~SAlignedVertex () + { + delete [] mem; + } + + s4DVertex *data; + u8 *mem; + u32 ElementSize; +}; + + +// hold info for different Vertex Types +struct SVSize +{ + u32 Format; + u32 Pitch; + u32 TexSize; +}; + + +// a cache info +struct SCacheInfo +{ + u32 index; + u32 hit; +}; + +#define VERTEXCACHE_ELEMENT 16 +#define VERTEXCACHE_MISS 0xFFFFFFFF +struct SVertexCache +{ + SVertexCache (): mem ( VERTEXCACHE_ELEMENT * 2, 128 ) {} + + SCacheInfo info[VERTEXCACHE_ELEMENT]; + + + // Transformed and lite, clipping state + // + Clipped, Projected + SAlignedVertex mem; + + // source + const void* vertices; + u32 vertexCount; + + const u16* indices; + u32 indexCount; + u32 indicesIndex; + + u32 indicesRun; + + // primitives consist of x vertices + u32 primitivePitch; + + u32 vType; //E_VERTEX_TYPE + u32 pType; //scene::E_PRIMITIVE_TYPE + +}; + + +// swap 2 pointer +inline void swapVertexPointer(const s4DVertex** v1, const s4DVertex** v2) +{ + const s4DVertex* b = *v1; + *v1 = *v2; + *v2 = b; +} + + +// ------------------------ Internal Scanline Rasterizer ----------------------------- + + +// internal scan convert +struct sScanConvertData +{ + s32 left; // major edge left/right + s32 right; // !left + + f32 invDeltaY[3]; // inverse edge delta y + + f32 x[2]; // x coordinate + f32 slopeX[2]; // x slope along edges + +#if defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) || defined ( SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT ) + f32 w[2]; // w coordinate + fp24 slopeW[2]; // w slope along edges +#else + f32 z[2]; // z coordinate + f32 slopeZ[2]; // z slope along edges +#endif + + sVec4 c[2]; // color + sVec4 slopeC[2]; // color slope along edges + + sVec2 t0[2]; // texture + sVec2 slopeT0[2]; // texture slope along edges + + sVec2 t1[2]; // texture + sVec2 slopeT1[2]; // texture slope along edges + +}; + +// passed to scan Line +struct sScanLineData +{ + s32 y; // y position of scanline + f32 x[2]; // x start, x end of scanline + +#if defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) || defined ( SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT ) + f32 w[2]; // w start, w end of scanline +#else + f32 z[2]; // z start, z end of scanline +#endif + +#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + sVec4 c[2]; // color start, color end of scanline +#endif + + sVec2 t0[2]; // texture start, texture end of scanline + sVec2 t1[2]; // texture start, texture end of scanline +}; + + +/* + load a color value +*/ +inline void getTexel_plain ( tFixPoint &r, tFixPoint &g, tFixPoint &b, + const sVec4 &v + ) +{ + r = f32_to_fixPoint ( v.y ); + g = f32_to_fixPoint ( v.z ); + b = f32_to_fixPoint ( v.w ); +} + +/* + load a color value +*/ +inline void getSample_color ( tFixPoint &a, tFixPoint &r, tFixPoint &g, tFixPoint &b, + const sVec4 &v + ) +{ + a = f32_to_fixPoint ( v.x ); + r = f32_to_fixPoint ( v.y, COLOR_MAX * FIX_POINT_F32_MUL); + g = f32_to_fixPoint ( v.z, COLOR_MAX * FIX_POINT_F32_MUL); + b = f32_to_fixPoint ( v.w, COLOR_MAX * FIX_POINT_F32_MUL); +} + +/* + load a color value +*/ +inline void getSample_color ( tFixPoint &r, tFixPoint &g, tFixPoint &b, + const sVec4 &v + ) +{ + r = f32_to_fixPoint ( v.y, COLOR_MAX * FIX_POINT_F32_MUL); + g = f32_to_fixPoint ( v.z, COLOR_MAX * FIX_POINT_F32_MUL); + b = f32_to_fixPoint ( v.w, COLOR_MAX * FIX_POINT_F32_MUL); +} + + + +} + +} + +#endif + diff --git a/src/dep/src/irrlicht/SoftwareDriver2_compile_config.h b/src/dep/src/irrlicht/SoftwareDriver2_compile_config.h index 87729c0..44ba16c 100644 --- a/src/dep/src/irrlicht/SoftwareDriver2_compile_config.h +++ b/src/dep/src/irrlicht/SoftwareDriver2_compile_config.h @@ -1,84 +1,84 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_VIDEO_2_SOFTWARE_COMPILE_CONFIG_H_INCLUDED__ -#define __S_VIDEO_2_SOFTWARE_COMPILE_CONFIG_H_INCLUDED__ - -#include "IrrCompileConfig.h" - - -// Generic Render Flags for burning's video rasterizer -// defined now in irrlicht compile config - - -#ifdef BURNINGVIDEO_RENDERER_BEAUTIFUL - #define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #define SOFTWARE_DRIVER_2_SUBTEXEL - #define SOFTWARE_DRIVER_2_BILINEAR - #define SOFTWARE_DRIVER_2_LIGHTING - #define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #define SOFTWARE_DRIVER_2_32BIT - #define SOFTWARE_DRIVER_2_MIPMAPPING - #define SOFTWARE_DRIVER_2_USE_WBUFFER - #define SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM -#endif - -#ifdef BURNINGVIDEO_RENDERER_FAST - #define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #define SOFTWARE_DRIVER_2_SUBTEXEL - //#define SOFTWARE_DRIVER_2_BILINEAR - //#define SOFTWARE_DRIVER_2_LIGHTING - //#define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #define SOFTWARE_DRIVER_2_32BIT - #define SOFTWARE_DRIVER_2_MIPMAPPING - #define SOFTWARE_DRIVER_2_USE_WBUFFER -#endif - -#ifdef BURNINGVIDEO_RENDERER_ULTRA_FAST - #define BURNINGVIDEO_RENDERER_FAST - - //#define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #define SOFTWARE_DRIVER_2_SUBTEXEL - //#define SOFTWARE_DRIVER_2_BILINEAR - //#define SOFTWARE_DRIVER_2_LIGHTING - //#define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - //#define SOFTWARE_DRIVER_2_32BIT - #define SOFTWARE_DRIVER_2_MIPMAPPING - //#define SOFTWARE_DRIVER_2_USE_WBUFFER -#endif - -// Derivate flags - -// texture format -#ifdef SOFTWARE_DRIVER_2_32BIT - #define ECF_SOFTWARE2 ECF_A8R8G8B8 -#else - #define ECF_SOFTWARE2 ECF_A1R5G5B5 -#endif - -// mip mapping -#ifdef SOFTWARE_DRIVER_2_MIPMAPPING - #ifdef BURNINGVIDEO_RENDERER_BEAUTIFUL - #define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 8 - #define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS -1 - #else - #define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 8 - #define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS -1 - #endif -#else - #define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 1 - #define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS 0 -#endif - - - -#ifndef REALINLINE - #ifdef _MSC_VER - #define REALINLINE __forceinline - #else - #define REALINLINE inline - #endif -#endif - -#endif +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __S_VIDEO_2_SOFTWARE_COMPILE_CONFIG_H_INCLUDED__ +#define __S_VIDEO_2_SOFTWARE_COMPILE_CONFIG_H_INCLUDED__ + +#include "IrrCompileConfig.h" + + +// Generic Render Flags for burning's video rasterizer +// defined now in irrlicht compile config + + +#ifdef BURNINGVIDEO_RENDERER_BEAUTIFUL + #define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #define SOFTWARE_DRIVER_2_SUBTEXEL + #define SOFTWARE_DRIVER_2_BILINEAR + #define SOFTWARE_DRIVER_2_LIGHTING + #define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #define SOFTWARE_DRIVER_2_32BIT + #define SOFTWARE_DRIVER_2_MIPMAPPING + #define SOFTWARE_DRIVER_2_USE_WBUFFER + #define SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM +#endif + +#ifdef BURNINGVIDEO_RENDERER_FAST + #define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #define SOFTWARE_DRIVER_2_SUBTEXEL + //#define SOFTWARE_DRIVER_2_BILINEAR + //#define SOFTWARE_DRIVER_2_LIGHTING + //#define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + #define SOFTWARE_DRIVER_2_32BIT + #define SOFTWARE_DRIVER_2_MIPMAPPING + #define SOFTWARE_DRIVER_2_USE_WBUFFER +#endif + +#ifdef BURNINGVIDEO_RENDERER_ULTRA_FAST + #define BURNINGVIDEO_RENDERER_FAST + + //#define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + #define SOFTWARE_DRIVER_2_SUBTEXEL + //#define SOFTWARE_DRIVER_2_BILINEAR + //#define SOFTWARE_DRIVER_2_LIGHTING + //#define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR + //#define SOFTWARE_DRIVER_2_32BIT + #define SOFTWARE_DRIVER_2_MIPMAPPING + //#define SOFTWARE_DRIVER_2_USE_WBUFFER +#endif + +// Derivate flags + +// texture format +#ifdef SOFTWARE_DRIVER_2_32BIT + #define ECF_SOFTWARE2 ECF_A8R8G8B8 +#else + #define ECF_SOFTWARE2 ECF_A1R5G5B5 +#endif + +// mip mapping +#ifdef SOFTWARE_DRIVER_2_MIPMAPPING + #ifdef BURNINGVIDEO_RENDERER_BEAUTIFUL + #define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 8 + #define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS -1 + #else + #define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 8 + #define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS -1 + #endif +#else + #define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 1 + #define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS 0 +#endif + + + +#ifndef REALINLINE + #ifdef _MSC_VER + #define REALINLINE __forceinline + #else + #define REALINLINE inline + #endif +#endif + +#endif diff --git a/src/dep/src/irrlicht/SoftwareDriver2_helper.h b/src/dep/src/irrlicht/SoftwareDriver2_helper.h index 74d98e2..03b4bb9 100644 --- a/src/dep/src/irrlicht/SoftwareDriver2_helper.h +++ b/src/dep/src/irrlicht/SoftwareDriver2_helper.h @@ -1,888 +1,888 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -/* - History: - - changed behaviour for log2 textures ( replaced multiplys by shift ) -*/ - -#ifndef __S_VIDEO_2_SOFTWARE_HELPER_H_INCLUDED__ -#define __S_VIDEO_2_SOFTWARE_HELPER_H_INCLUDED__ - -#include "SoftwareDriver2_compile_config.h" -#include "irrMath.h" -#include "CSoftwareTexture2.h" - - - -namespace irr -{ - -// supporting different packed pixel needs many defines... - -#ifdef SOFTWARE_DRIVER_2_32BIT - typedef u32 tVideoSample; - - #define MASK_A 0xFF000000 - #define MASK_R 0x00FF0000 - #define MASK_G 0x0000FF00 - #define MASK_B 0x000000FF - - #define SHIFT_A 24 - #define SHIFT_R 16 - #define SHIFT_G 8 - #define SHIFT_B 0 - - #define COLOR_MAX 0xFF - #define COLOR_BRIGHT_WHITE 0xFFFFFFFF - - #define VIDEO_SAMPLE_GRANULARITY 2 - #define ECF_SOFTWARE2 ECF_A8R8G8B8 - -#else - typedef u16 tVideoSample; - - #define MASK_A 0x8000 - #define MASK_R 0x7C00 - #define MASK_G 0x03E0 - #define MASK_B 0x001F - - #define SHIFT_A 15 - #define SHIFT_R 10 - #define SHIFT_G 5 - #define SHIFT_B 0 - - #define COLOR_MAX 0x1F - #define COLOR_BRIGHT_WHITE 0xFFFF - #define VIDEO_SAMPLE_GRANULARITY 1 - #define ECF_SOFTWARE2 ECF_A1R5G5B5 - -#endif - - - - -// ----------------------- Generic ---------------------------------- - -//! a more useful memset for pixel -inline void memset32 ( void * dest, const u32 value, u32 bytesize ) -{ - u32 * d = (u32*) dest; - - u32 i; - - i = bytesize >> ( 2 + 3 ); - while( i ) - { - d[0] = value; - d[1] = value; - d[2] = value; - d[3] = value; - - d[4] = value; - d[5] = value; - d[6] = value; - d[7] = value; - - d += 8; - i -= 1; - } - - i = (bytesize >> 2 ) & 7; - while( i ) - { - d[0] = value; - d += 1; - i -= 1; - } - -} - -/* - use biased loop counter - --> 0 byte copy is forbidden -*/ -REALINLINE void memcpy32_small ( void * dest, const void *source, u32 bytesize ) -{ - u32 c = bytesize >> 2; - - do - { - ((u32*) dest ) [ c + -1 ] = ((u32*) source) [ c + -1 ]; - } while ( --c ); - -} - - - -// integer log2 of a float ieee 754. TODO: non ieee floating point -static inline s32 s32_log2_f32( f32 f) -{ - u32 x = IR ( f ); - - return ((x & 0x7F800000) >> 23) - 127; -} - -static inline s32 s32_log2_s32(u32 x) -{ - return s32_log2_f32( (f32) x); -} - -static inline s32 s32_abs(s32 x) -{ - s32 b = x >> 31; - return (x ^ b ) - b; -} - - -// TODO: don't stick on 32 Bit Pointer -#define PointerAsValue(x) ( (u32) (u32*) (x) ) - - -//! conditional set based on mask and arithmetic shift -REALINLINE u32 if_mask_a_else_b ( const u32 mask, const u32 a, const u32 b ) -{ - return ( mask & ( a ^ b ) ) ^ b; -} - -inline void setbits ( u32 &state, s32 condition, u32 mask ) -{ - state ^= ( ( -condition >> 31 ) ^ state ) & mask; -} - - -// ------------------ Video--------------------------------------- -/*! - Pixel = dest * ( 1 - alpha ) + source * alpha - alpha [0;256] -*/ -REALINLINE u32 PixelBlend32 ( const u32 c2, const u32 c1, u32 alpha ) -{ - u32 srcRB = c1 & 0x00FF00FF; - u32 srcXG = c1 & 0x0000FF00; - - u32 dstRB = c2 & 0x00FF00FF; - u32 dstXG = c2 & 0x0000FF00; - - - u32 rb = srcRB - dstRB; - u32 xg = srcXG - dstXG; - - rb *= alpha; - xg *= alpha; - rb >>= 8; - xg >>= 8; - - rb += dstRB; - xg += dstXG; - - rb &= 0x00FF00FF; - xg &= 0x0000FF00; - - return rb | xg; -} - -/*! - Pixel = dest * ( 1 - alpha ) + source * alpha - alpha [0;32] -*/ -inline u16 PixelBlend16 ( const u16 c2, const u32 c1, const u32 alpha ) -{ - u32 srcRB = c1 & 0x7C1F; - u32 srcXG = c1 & 0x03E0; - - u32 dstRB = c2 & 0x7C1F; - u32 dstXG = c2 & 0x03E0; - - - u32 rb = srcRB - dstRB; - u32 xg = srcXG - dstXG; - - rb *= alpha; - xg *= alpha; - rb >>= 5; - xg >>= 5; - - rb += dstRB; - xg += dstXG; - - rb &= 0x7C1F; - xg &= 0x03E0; - - return rb | xg; -} - -/*! - Scale Color by (1/value) - value 0 - 256 ( alpha ) -*/ -inline u32 PixelLerp32 ( const u32 source, const u32 value ) -{ - u32 srcRB = source & 0x00FF00FF; - u32 srcXG = (source & 0xFF00FF00) >> 8; - - srcRB *= value; - srcXG *= value; - - srcRB >>= 8; - //srcXG >>= 8; - - srcXG &= 0xFF00FF00; - srcRB &= 0x00FF00FF; - - return srcRB | srcXG; -} - -/* - return alpha in [0;256] Granularity - add highbit alpha ( alpha > 127 ? + 1 ) -*/ -inline u32 extractAlpha ( const u32 c ) -{ - return ( c >> 24 ) + ( c >> 31 ); -} - -/* - Pixel = c0 * (c1/31). c0 Alpha retain -*/ -inline u16 PixelMul16 ( const u16 c0, const u16 c1) -{ - return ((( ( (c0 & 0x7C00) * (c1 & 0x7C00) ) & 0x3E000000 ) >> 15 ) | - (( ( (c0 & 0x03E0) * (c1 & 0x03E0) ) & 0x000F8000 ) >> 10 ) | - (( ( (c0 & 0x001F) * (c1 & 0x001F) ) & 0x000003E0 ) >> 5 ) | - (c0 & 0x8000)); -} - -/* - Pixel = c0 * (c1/31). -*/ -inline u16 PixelMul16_2 ( u16 c0, u16 c1) -{ - return ( ( (c0 & 0x7C00) * (c1 & 0x7C00) ) & 0x3E000000 ) >> 15 | - ( ( (c0 & 0x03E0) * (c1 & 0x03E0) ) & 0x000F8000 ) >> 10 | - ( ( (c0 & 0x001F) * (c1 & 0x001F) ) & 0x000003E0 ) >> 5 | - ( c0 & c1 & 0x8000); -} - -/* - Pixel = c0 * (c1/255). c0 Alpha Retain -*/ -REALINLINE u32 PixelMul32 ( const u32 c0, const u32 c1) -{ - return (c0 & 0xFF000000) | - (( ( (c0 & 0x00FF0000) >> 12 ) * ( (c1 & 0x00FF0000) >> 12 ) ) & 0x00FF0000 ) | - (( ( (c0 & 0x0000FF00) * (c1 & 0x0000FF00) ) >> 16 ) & 0x0000FF00 ) | - (( ( (c0 & 0x000000FF) * (c1 & 0x000000FF) ) >> 8 ) & 0x000000FF); -} - -/* - Pixel = c0 * (c1/255). -*/ -REALINLINE u32 PixelMul32_2 ( const u32 c0, const u32 c1) -{ - return (( ( (c0 & 0xFF000000) >> 16 ) * ( (c1 & 0xFF000000) >> 16 ) ) & 0xFF000000 ) | - (( ( (c0 & 0x00FF0000) >> 12 ) * ( (c1 & 0x00FF0000) >> 12 ) ) & 0x00FF0000 ) | - (( ( (c0 & 0x0000FF00) * (c1 & 0x0000FF00) ) >> 16 ) & 0x0000FF00 ) | - (( ( (c0 & 0x000000FF) * (c1 & 0x000000FF) ) >> 8 ) & 0x000000FF); -} - -/* - Pixel = clamp ( c0 + c1, 0, 255 ) -*/ -REALINLINE u32 PixelAdd32 ( const u32 c2, const u32 c1) -{ - u32 sum = ( c2 & 0x00FFFFFF ) + ( c1 & 0x00FFFFFF ); - u32 low_bits = ( c2 ^ c1 ) & 0x00010101; - s32 carries = ( sum - low_bits ) & 0x01010100; - u32 modulo = sum - carries; - u32 clamp = carries - ( carries >> 8 ); - return modulo | clamp; -} - - - -// 1 - Bit Alpha Blending -inline u16 PixelBlend16 ( const u16 c2, const u16 c1 ) -{ - u16 c = c1 & 0x8000; - - c >>= 15; - c += 0x7fff; - - c &= c2; - c |= c1; - - return c; -} - -// 1 - Bit Alpha Blending 16Bit SIMD -inline u32 PixelBlend16_simd ( const u32 c2, const u32 c1 ) -{ - u32 c = c1 & 0x80008000; - - c >>= 15; - c += 0x7fff7fff; - - c &= c2; - c |= c1; - - return c; -} - - -/*! - Pixel = dest * ( 1 - SourceAlpha ) + source * SourceAlpha -*/ -inline u32 PixelBlend32 ( const u32 c2, const u32 c1 ) -{ - // alpha test - u32 alpha = c1 & 0xFF000000; - - if ( 0 == alpha ) - return c2; - - if ( 0xFF000000 == alpha ) - { - return c1; - } - - alpha >>= 24; - - // add highbit alpha, if ( alpha > 127 ) alpha += 1; - alpha += ( alpha >> 7); - - u32 srcRB = c1 & 0x00FF00FF; - u32 srcXG = c1 & 0x0000FF00; - - u32 dstRB = c2 & 0x00FF00FF; - u32 dstXG = c2 & 0x0000FF00; - - - u32 rb = srcRB - dstRB; - u32 xg = srcXG - dstXG; - - rb *= alpha; - xg *= alpha; - rb >>= 8; - xg >>= 8; - - rb += dstRB; - xg += dstXG; - - rb &= 0x00FF00FF; - xg &= 0x0000FF00; - - return rb | xg; -} - - - -// ------------------ Fix Point ---------------------------------- - -typedef s32 tFixPoint; -typedef u32 tFixPointu; - -// Fix Point 9 -#if 1 - #define FIX_POINT_PRE 9 - #define FIX_POINT_FRACT_MASK 0x1FF - #define FIX_POINT_SIGNED_MASK 0xFFFFFE00 - #define FIX_POINT_UNSIGNED_MASK 0x7FFFFE00 - #define FIX_POINT_ONE 0x200 - #define FIX_POINT_ZERO_DOT_FIVE 0x100 - #define FIX_POINT_F32_MUL 512.f -#endif - -// Fix Point 7 -#if 0 - #define FIX_POINT_PRE 7 - #define FIX_POINT_FRACT_MASK 0x7F - #define FIX_POINT_SIGNED_MASK 0xFFFFFF80 - #define FIX_POINT_UNSIGNED_MASK 0x7FFFFF80 - #define FIX_POINT_ONE 0x80 - #define FIX_POINT_ZERO_DOT_FIVE 0x40 - #define FIX_POINT_F32_MUL 128.f -#endif - -#define FIXPOINT_COLOR_MAX ( COLOR_MAX << FIX_POINT_PRE ) - - -/* - convert signed integer to fixpoint -*/ -inline tFixPoint s32_to_fixPoint (const s32 x) -{ - return x << FIX_POINT_PRE; -} - -inline tFixPointu u32_to_fixPoint (const u32 x) -{ - return x << FIX_POINT_PRE; -} - -inline u32 fixPointu_to_u32 (const tFixPointu x) -{ - return x >> FIX_POINT_PRE; -} - - -// 1/x * FIX_POINT -REALINLINE f32 fix_inverse32 ( const f32 x ) -{ - return FIX_POINT_F32_MUL / x; -} - - -/* - convert float to fixpoint - fast convert (fistp on x86) HAS to be used.. - hints: compileflag /QIfist for msvc7. msvc 8.0 has smth different - others should use their favourite assembler.. -*/ -static inline int f_round2(f32 f) -{ - f += (3<<22); - return *((int*)&f) - 0x4b400000; -} - -/* - convert f32 to Fix Point. - multiply is needed anyway, so scale mulby -*/ -REALINLINE tFixPoint f32_to_fixPoint (const f32 x, const f32 mulby = FIX_POINT_F32_MUL ) -{ - return (tFixPoint) (x * mulby); -} - - -/* - Fix Point , Fix Point Multiply -*/ -REALINLINE tFixPointu imulFixu(const tFixPointu x, const tFixPointu y) -{ - return (x * y) >> (tFixPointu) FIX_POINT_PRE; -} - -/* - Fix Point , Fix Point Multiply -*/ -REALINLINE tFixPoint imulFix(const tFixPoint x, const tFixPoint y) -{ - return ( x * y) >> ( FIX_POINT_PRE ); -} - -/* - Multiply x * y * 1 -*/ -REALINLINE tFixPoint imulFix_tex1(const tFixPoint x, const tFixPoint y) -{ - return ( ( (tFixPointu) x >> 2 ) * ( (tFixPointu) y >> 2 ) ) >> (tFixPointu) ( FIX_POINT_PRE + 1 ); -} - -/* - Multiply x * y * 2 -*/ -REALINLINE tFixPoint imulFix_tex2(const tFixPoint x, const tFixPoint y) -{ - return ( ( (tFixPointu) x >> 2 ) * ( (tFixPointu) y >> 2 ) ) >> (tFixPointu) ( FIX_POINT_PRE + 3 ); -} - -/* - Multiply x * y * 4 -*/ -REALINLINE tFixPoint imulFix_tex4(const tFixPoint x, const tFixPoint y) -{ -#ifdef SOFTWARE_DRIVER_2_32BIT - return ( ( (tFixPointu) x >> 2 ) * ( (tFixPointu) y >> 2 ) ) >> (tFixPointu) ( FIX_POINT_PRE + 2 ); -#else - return ( x * y) >> ( FIX_POINT_PRE + ( VIDEO_SAMPLE_GRANULARITY * 3 ) ); -#endif -} - -/*! - clamp FixPoint to maxcolor in FixPoint, min(a,31) -*/ -REALINLINE tFixPoint clampfix_maxcolor ( const tFixPoint a) -{ - tFixPoint c = (a - FIXPOINT_COLOR_MAX) >> 31; - return (a & c) | ( FIXPOINT_COLOR_MAX & ~c); -} - -/*! - clamp FixPoint to 0 in FixPoint, max(a,0) -*/ -inline tFixPoint clampfix_mincolor ( const tFixPoint a) -{ - return a - ( a & ( a >> 31 ) ); -} - - -// rount fixpoint to int -inline s32 roundFix ( const tFixPoint x ) -{ - return ( x + FIX_POINT_ZERO_DOT_FIVE ) >> FIX_POINT_PRE; -} - - - -// x in [0;1[ -inline s32 f32_to_23Bits(const f32 x) -{ - f32 y = x + 1.f; - return ((u32&)y) & 0x7FFFFF; // last 23 bits -} - -/*! - return VideoSample from fixpoint -*/ -REALINLINE tVideoSample fix_to_color ( const tFixPoint r, const tFixPoint g, const tFixPoint b ) -{ -#ifdef __BIG_ENDIAN__ - return ( r & FIXPOINT_COLOR_MAX) >> ( FIX_POINT_PRE - 8) | - ( g & FIXPOINT_COLOR_MAX) << ( 16 - FIX_POINT_PRE ) | - //( g & FIXPOINT_COLOR_MAX) << ( SHIFT_G - FIX_POINT_PRE ) | - ( b & FIXPOINT_COLOR_MAX) << ( 24 - FIX_POINT_PRE ); -#else - return ( r & FIXPOINT_COLOR_MAX) << ( SHIFT_R - FIX_POINT_PRE ) | - ( g & FIXPOINT_COLOR_MAX) >> ( FIX_POINT_PRE - SHIFT_G ) | - //( g & FIXPOINT_COLOR_MAX) << ( SHIFT_G - FIX_POINT_PRE ) | - ( b & FIXPOINT_COLOR_MAX) >> ( FIX_POINT_PRE - SHIFT_B ); -#endif -} - - -/*! - return fixpoint from VideoSample -*/ -inline void color_to_fix ( tFixPoint &r, tFixPoint &g, tFixPoint &b, const tVideoSample t00 ) -{ - r = (t00 & MASK_R) >> ( SHIFT_R - FIX_POINT_PRE ); - //g = (t00 & MASK_G) >> ( SHIFT_G - FIX_POINT_PRE ); - g = (t00 & MASK_G) << ( FIX_POINT_PRE - SHIFT_G ); - b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B ); -} - - -// ----- FP24 ---- floating point z-buffer - -#if 1 -typedef f32 fp24; -#else -struct fp24 -{ - u32 v; - - fp24() {} - - fp24 ( const f32 f ) - { - f32 y = f + 1.f; - v = ((u32&)y) & 0x7FFFFF; // last 23 bits - } - - void operator=(const f32 f ) - { - f32 y = f + 1.f; - v = ((u32&)y) & 0x7FFFFF; // last 23 bits - } - - void operator+=(const fp24 &other ) - { - v += other.v; - } - - operator f32 () const - { - f32 r = FR ( v ); - return r + 1.f; - } - -}; -#endif - - -// ------------------------ Internal Texture ----------------------------- - -struct sInternalTexture -{ - u32 textureXMask; - u32 textureYMask; - - u32 pitchlog2; - void *data; - - video::CSoftwareTexture2 *Texture; - s32 lodLevel; -}; - - - -// get video sample plain -inline tVideoSample getTexel_plain ( const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty ) -{ - u32 ofs; - - ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); - - // texel - return *((tVideoSample*)( (u8*) t->data + ofs )); -} - -// get video sample to fix -inline void getTexel_fix ( tFixPoint &r, tFixPoint &g, tFixPoint &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty - ) -{ - u32 ofs; - - ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); - - // texel - tVideoSample t00; - t00 = *((tVideoSample*)( (u8*) t->data + ofs )); - - r = (t00 & MASK_R) >> ( SHIFT_R - FIX_POINT_PRE); - g = (t00 & MASK_G) << ( FIX_POINT_PRE - SHIFT_G ); - b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B ); - -} - - -inline void getSample_texture_dither ( tFixPoint &r, tFixPoint &g, tFixPoint &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty, - const u32 x, const u32 y - ) -{ - static const tFixPointu dithermask[] = - { - 0x00,0x80,0x20,0xa0, - 0xc0,0x40,0xe0,0x60, - 0x30,0xb0,0x10,0x90, - 0xf0,0x70,0xd0,0x50 - }; - - const u32 index = (y & 3 ) << 2 | (x & 3); - - const tFixPointu _ntx = (tx + dithermask [ index ] ) & t->textureXMask; - const tFixPointu _nty = (ty + dithermask [ index ] ) & t->textureYMask; - - u32 ofs; - ofs = ( ( _nty ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ( _ntx ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); - - // texel - const tVideoSample t00 = *((tVideoSample*)( (u8*) t->data + ofs )); - - (tFixPointu &) r = (t00 & MASK_R) >> ( SHIFT_R - FIX_POINT_PRE); - (tFixPointu &) g = (t00 & MASK_G) << ( FIX_POINT_PRE - SHIFT_G ); - (tFixPointu &) b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B ); - -} - -/* - load a sample from internal texture at position tx,ty to fixpoint -*/ -#ifndef SOFTWARE_DRIVER_2_BILINEAR - -// get Sample linear == getSample_fixpoint - -inline void getSample_texture ( tFixPoint &r, tFixPoint &g, tFixPoint &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty - ) -{ - u32 ofs; - - ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); - - // texel - const tVideoSample t00 = *((tVideoSample*)( (u8*) t->data + ofs )); - - (tFixPointu &) r = (t00 & MASK_R) >> ( SHIFT_R - FIX_POINT_PRE); - (tFixPointu &) g = (t00 & MASK_G) << ( FIX_POINT_PRE - SHIFT_G ); - (tFixPointu &) b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B ); - -} - - -#else - -// get sample linear -REALINLINE void getSample_linear ( tFixPointu &r, tFixPointu &g, tFixPointu &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty - ) -{ - u32 ofs; - - ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); - - // texel - tVideoSample t00; - t00 = *((tVideoSample*)( (u8*) t->data + ofs )); - - r = (t00 & MASK_R) >> SHIFT_R; - g = (t00 & MASK_G) >> SHIFT_G; - b = (t00 & MASK_B); -} - -// get Sample bilinear -REALINLINE void getSample_texture ( tFixPoint &r, tFixPoint &g, tFixPoint &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty - ) -{ - - tFixPointu r00,g00,b00; - tFixPointu r01,g01,b01; - tFixPointu r10,g10,b10; - tFixPointu r11,g11,b11; - - getSample_linear ( r00, g00, b00, t, tx,ty ); - getSample_linear ( r10, g10, b10, t, tx + FIX_POINT_ONE,ty ); - getSample_linear ( r01, g01, b01, t, tx,ty + FIX_POINT_ONE ); - getSample_linear ( r11, g11, b11, t, tx + FIX_POINT_ONE,ty + FIX_POINT_ONE ); - - const tFixPointu txFract = tx & FIX_POINT_FRACT_MASK; - const tFixPointu txFractInv = FIX_POINT_ONE - txFract; - - const tFixPointu tyFract = ty & FIX_POINT_FRACT_MASK; - const tFixPointu tyFractInv = FIX_POINT_ONE - tyFract; - - const tFixPointu w00 = imulFixu ( txFractInv, tyFractInv ); - const tFixPointu w10 = imulFixu ( txFract , tyFractInv ); - const tFixPointu w01 = imulFixu ( txFractInv, tyFract ); - const tFixPointu w11 = imulFixu ( txFract , tyFract ); - - r = (r00 * w00 ) + - (r01 * w01 ) + - (r10 * w10 ) + - (r11 * w11 ); - - g = (g00 * w00 ) + - (g01 * w01 ) + - (g10 * w10 ) + - (g11 * w11 ); - - b = (b00 * w00 ) + - (b01 * w01 ) + - (b10 * w10 ) + - (b11 * w11 ); - -} - - -// get sample linear -REALINLINE void getSample_linear ( tFixPointu &a, tFixPointu &r, tFixPointu &g, tFixPointu &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty - ) -{ - u32 ofs; - - ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); - - // texel - tVideoSample t00; - t00 = *((tVideoSample*)( (u8*) t->data + ofs )); - - a = (t00 & MASK_A) >> SHIFT_A; - r = (t00 & MASK_R) >> SHIFT_R; - g = (t00 & MASK_G) >> SHIFT_G; - b = (t00 & MASK_B); -} - -// get Sample bilinear -REALINLINE void getSample_texture ( tFixPointu &a, tFixPointu &r, tFixPointu &g, tFixPointu &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty - ) -{ - - tFixPointu a00, r00,g00,b00; - tFixPointu a01, r01,g01,b01; - tFixPointu a10, r10,g10,b10; - tFixPointu a11, r11,g11,b11; - - getSample_linear ( a00, r00, g00, b00, t, tx,ty ); - getSample_linear ( a10, r10, g10, b10, t, tx + FIX_POINT_ONE,ty ); - getSample_linear ( a01, r01, g01, b01, t, tx,ty + FIX_POINT_ONE ); - getSample_linear ( a11, r11, g11, b11, t, tx + FIX_POINT_ONE,ty + FIX_POINT_ONE ); - - const tFixPointu txFract = tx & FIX_POINT_FRACT_MASK; - const tFixPointu txFractInv = FIX_POINT_ONE - txFract; - - const tFixPointu tyFract = ty & FIX_POINT_FRACT_MASK; - const tFixPointu tyFractInv = FIX_POINT_ONE - tyFract; - - const tFixPointu w00 = imulFixu ( txFractInv, tyFractInv ); - const tFixPointu w10 = imulFixu ( txFract , tyFractInv ); - const tFixPointu w01 = imulFixu ( txFractInv, tyFract ); - const tFixPointu w11 = imulFixu ( txFract , tyFract ); - - a = (a00 * w00 ) + - (a01 * w01 ) + - (a10 * w10 ) + - (a11 * w11 ); - - r = (r00 * w00 ) + - (r01 * w01 ) + - (r10 * w10 ) + - (r11 * w11 ); - - g = (g00 * w00 ) + - (g01 * w01 ) + - (g10 * w10 ) + - (g11 * w11 ); - - b = (b00 * w00 ) + - (b01 * w01 ) + - (b10 * w10 ) + - (b11 * w11 ); - -} - - -#endif - -// some 2D Defines -struct AbsRectangle -{ - s32 x0; - s32 y0; - s32 x1; - s32 y1; -}; - -inline void intersect ( AbsRectangle &dest, const AbsRectangle& a, const AbsRectangle& b) -{ - dest.x0 = core::s32_max( a.x0, b.x0 ); - dest.y0 = core::s32_max( a.y0, b.y0 ); - dest.x1 = core::s32_min( a.x1, b.x1 ); - dest.y1 = core::s32_min( a.y1, b.y1 ); -} - -inline bool isValid (const AbsRectangle& a) -{ - return a.x0 < a.x1 && a.y0 < a.y1; -} - -// some 1D defines -struct sIntervall -{ - s32 start; - s32 end; -}; - -// returning intersection width -inline s32 intervall_intersect_test( const sIntervall& a, const sIntervall& b) -{ - return core::s32_min( a.end, b.end ) - core::s32_max( a.start, b.start ); -} - - -} // namespace - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +/* + History: + - changed behaviour for log2 textures ( replaced multiplys by shift ) +*/ + +#ifndef __S_VIDEO_2_SOFTWARE_HELPER_H_INCLUDED__ +#define __S_VIDEO_2_SOFTWARE_HELPER_H_INCLUDED__ + +#include "SoftwareDriver2_compile_config.h" +#include "irrMath.h" +#include "CSoftwareTexture2.h" + + + +namespace irr +{ + +// supporting different packed pixel needs many defines... + +#ifdef SOFTWARE_DRIVER_2_32BIT + typedef u32 tVideoSample; + + #define MASK_A 0xFF000000 + #define MASK_R 0x00FF0000 + #define MASK_G 0x0000FF00 + #define MASK_B 0x000000FF + + #define SHIFT_A 24 + #define SHIFT_R 16 + #define SHIFT_G 8 + #define SHIFT_B 0 + + #define COLOR_MAX 0xFF + #define COLOR_BRIGHT_WHITE 0xFFFFFFFF + + #define VIDEO_SAMPLE_GRANULARITY 2 + #define ECF_SOFTWARE2 ECF_A8R8G8B8 + +#else + typedef u16 tVideoSample; + + #define MASK_A 0x8000 + #define MASK_R 0x7C00 + #define MASK_G 0x03E0 + #define MASK_B 0x001F + + #define SHIFT_A 15 + #define SHIFT_R 10 + #define SHIFT_G 5 + #define SHIFT_B 0 + + #define COLOR_MAX 0x1F + #define COLOR_BRIGHT_WHITE 0xFFFF + #define VIDEO_SAMPLE_GRANULARITY 1 + #define ECF_SOFTWARE2 ECF_A1R5G5B5 + +#endif + + + + +// ----------------------- Generic ---------------------------------- + +//! a more useful memset for pixel +inline void memset32 ( void * dest, const u32 value, u32 bytesize ) +{ + u32 * d = (u32*) dest; + + u32 i; + + i = bytesize >> ( 2 + 3 ); + while( i ) + { + d[0] = value; + d[1] = value; + d[2] = value; + d[3] = value; + + d[4] = value; + d[5] = value; + d[6] = value; + d[7] = value; + + d += 8; + i -= 1; + } + + i = (bytesize >> 2 ) & 7; + while( i ) + { + d[0] = value; + d += 1; + i -= 1; + } + +} + +/* + use biased loop counter + --> 0 byte copy is forbidden +*/ +REALINLINE void memcpy32_small ( void * dest, const void *source, u32 bytesize ) +{ + u32 c = bytesize >> 2; + + do + { + ((u32*) dest ) [ c + -1 ] = ((u32*) source) [ c + -1 ]; + } while ( --c ); + +} + + + +// integer log2 of a float ieee 754. TODO: non ieee floating point +static inline s32 s32_log2_f32( f32 f) +{ + u32 x = IR ( f ); + + return ((x & 0x7F800000) >> 23) - 127; +} + +static inline s32 s32_log2_s32(u32 x) +{ + return s32_log2_f32( (f32) x); +} + +static inline s32 s32_abs(s32 x) +{ + s32 b = x >> 31; + return (x ^ b ) - b; +} + + +// TODO: don't stick on 32 Bit Pointer +#define PointerAsValue(x) ( (u32) (u32*) (x) ) + + +//! conditional set based on mask and arithmetic shift +REALINLINE u32 if_mask_a_else_b ( const u32 mask, const u32 a, const u32 b ) +{ + return ( mask & ( a ^ b ) ) ^ b; +} + +inline void setbits ( u32 &state, s32 condition, u32 mask ) +{ + state ^= ( ( -condition >> 31 ) ^ state ) & mask; +} + + +// ------------------ Video--------------------------------------- +/*! + Pixel = dest * ( 1 - alpha ) + source * alpha + alpha [0;256] +*/ +REALINLINE u32 PixelBlend32 ( const u32 c2, const u32 c1, u32 alpha ) +{ + u32 srcRB = c1 & 0x00FF00FF; + u32 srcXG = c1 & 0x0000FF00; + + u32 dstRB = c2 & 0x00FF00FF; + u32 dstXG = c2 & 0x0000FF00; + + + u32 rb = srcRB - dstRB; + u32 xg = srcXG - dstXG; + + rb *= alpha; + xg *= alpha; + rb >>= 8; + xg >>= 8; + + rb += dstRB; + xg += dstXG; + + rb &= 0x00FF00FF; + xg &= 0x0000FF00; + + return rb | xg; +} + +/*! + Pixel = dest * ( 1 - alpha ) + source * alpha + alpha [0;32] +*/ +inline u16 PixelBlend16 ( const u16 c2, const u32 c1, const u32 alpha ) +{ + u32 srcRB = c1 & 0x7C1F; + u32 srcXG = c1 & 0x03E0; + + u32 dstRB = c2 & 0x7C1F; + u32 dstXG = c2 & 0x03E0; + + + u32 rb = srcRB - dstRB; + u32 xg = srcXG - dstXG; + + rb *= alpha; + xg *= alpha; + rb >>= 5; + xg >>= 5; + + rb += dstRB; + xg += dstXG; + + rb &= 0x7C1F; + xg &= 0x03E0; + + return rb | xg; +} + +/*! + Scale Color by (1/value) + value 0 - 256 ( alpha ) +*/ +inline u32 PixelLerp32 ( const u32 source, const u32 value ) +{ + u32 srcRB = source & 0x00FF00FF; + u32 srcXG = (source & 0xFF00FF00) >> 8; + + srcRB *= value; + srcXG *= value; + + srcRB >>= 8; + //srcXG >>= 8; + + srcXG &= 0xFF00FF00; + srcRB &= 0x00FF00FF; + + return srcRB | srcXG; +} + +/* + return alpha in [0;256] Granularity + add highbit alpha ( alpha > 127 ? + 1 ) +*/ +inline u32 extractAlpha ( const u32 c ) +{ + return ( c >> 24 ) + ( c >> 31 ); +} + +/* + Pixel = c0 * (c1/31). c0 Alpha retain +*/ +inline u16 PixelMul16 ( const u16 c0, const u16 c1) +{ + return ((( ( (c0 & 0x7C00) * (c1 & 0x7C00) ) & 0x3E000000 ) >> 15 ) | + (( ( (c0 & 0x03E0) * (c1 & 0x03E0) ) & 0x000F8000 ) >> 10 ) | + (( ( (c0 & 0x001F) * (c1 & 0x001F) ) & 0x000003E0 ) >> 5 ) | + (c0 & 0x8000)); +} + +/* + Pixel = c0 * (c1/31). +*/ +inline u16 PixelMul16_2 ( u16 c0, u16 c1) +{ + return ( ( (c0 & 0x7C00) * (c1 & 0x7C00) ) & 0x3E000000 ) >> 15 | + ( ( (c0 & 0x03E0) * (c1 & 0x03E0) ) & 0x000F8000 ) >> 10 | + ( ( (c0 & 0x001F) * (c1 & 0x001F) ) & 0x000003E0 ) >> 5 | + ( c0 & c1 & 0x8000); +} + +/* + Pixel = c0 * (c1/255). c0 Alpha Retain +*/ +REALINLINE u32 PixelMul32 ( const u32 c0, const u32 c1) +{ + return (c0 & 0xFF000000) | + (( ( (c0 & 0x00FF0000) >> 12 ) * ( (c1 & 0x00FF0000) >> 12 ) ) & 0x00FF0000 ) | + (( ( (c0 & 0x0000FF00) * (c1 & 0x0000FF00) ) >> 16 ) & 0x0000FF00 ) | + (( ( (c0 & 0x000000FF) * (c1 & 0x000000FF) ) >> 8 ) & 0x000000FF); +} + +/* + Pixel = c0 * (c1/255). +*/ +REALINLINE u32 PixelMul32_2 ( const u32 c0, const u32 c1) +{ + return (( ( (c0 & 0xFF000000) >> 16 ) * ( (c1 & 0xFF000000) >> 16 ) ) & 0xFF000000 ) | + (( ( (c0 & 0x00FF0000) >> 12 ) * ( (c1 & 0x00FF0000) >> 12 ) ) & 0x00FF0000 ) | + (( ( (c0 & 0x0000FF00) * (c1 & 0x0000FF00) ) >> 16 ) & 0x0000FF00 ) | + (( ( (c0 & 0x000000FF) * (c1 & 0x000000FF) ) >> 8 ) & 0x000000FF); +} + +/* + Pixel = clamp ( c0 + c1, 0, 255 ) +*/ +REALINLINE u32 PixelAdd32 ( const u32 c2, const u32 c1) +{ + u32 sum = ( c2 & 0x00FFFFFF ) + ( c1 & 0x00FFFFFF ); + u32 low_bits = ( c2 ^ c1 ) & 0x00010101; + s32 carries = ( sum - low_bits ) & 0x01010100; + u32 modulo = sum - carries; + u32 clamp = carries - ( carries >> 8 ); + return modulo | clamp; +} + + + +// 1 - Bit Alpha Blending +inline u16 PixelBlend16 ( const u16 c2, const u16 c1 ) +{ + u16 c = c1 & 0x8000; + + c >>= 15; + c += 0x7fff; + + c &= c2; + c |= c1; + + return c; +} + +// 1 - Bit Alpha Blending 16Bit SIMD +inline u32 PixelBlend16_simd ( const u32 c2, const u32 c1 ) +{ + u32 c = c1 & 0x80008000; + + c >>= 15; + c += 0x7fff7fff; + + c &= c2; + c |= c1; + + return c; +} + + +/*! + Pixel = dest * ( 1 - SourceAlpha ) + source * SourceAlpha +*/ +inline u32 PixelBlend32 ( const u32 c2, const u32 c1 ) +{ + // alpha test + u32 alpha = c1 & 0xFF000000; + + if ( 0 == alpha ) + return c2; + + if ( 0xFF000000 == alpha ) + { + return c1; + } + + alpha >>= 24; + + // add highbit alpha, if ( alpha > 127 ) alpha += 1; + alpha += ( alpha >> 7); + + u32 srcRB = c1 & 0x00FF00FF; + u32 srcXG = c1 & 0x0000FF00; + + u32 dstRB = c2 & 0x00FF00FF; + u32 dstXG = c2 & 0x0000FF00; + + + u32 rb = srcRB - dstRB; + u32 xg = srcXG - dstXG; + + rb *= alpha; + xg *= alpha; + rb >>= 8; + xg >>= 8; + + rb += dstRB; + xg += dstXG; + + rb &= 0x00FF00FF; + xg &= 0x0000FF00; + + return rb | xg; +} + + + +// ------------------ Fix Point ---------------------------------- + +typedef s32 tFixPoint; +typedef u32 tFixPointu; + +// Fix Point 9 +#if 1 + #define FIX_POINT_PRE 9 + #define FIX_POINT_FRACT_MASK 0x1FF + #define FIX_POINT_SIGNED_MASK 0xFFFFFE00 + #define FIX_POINT_UNSIGNED_MASK 0x7FFFFE00 + #define FIX_POINT_ONE 0x200 + #define FIX_POINT_ZERO_DOT_FIVE 0x100 + #define FIX_POINT_F32_MUL 512.f +#endif + +// Fix Point 7 +#if 0 + #define FIX_POINT_PRE 7 + #define FIX_POINT_FRACT_MASK 0x7F + #define FIX_POINT_SIGNED_MASK 0xFFFFFF80 + #define FIX_POINT_UNSIGNED_MASK 0x7FFFFF80 + #define FIX_POINT_ONE 0x80 + #define FIX_POINT_ZERO_DOT_FIVE 0x40 + #define FIX_POINT_F32_MUL 128.f +#endif + +#define FIXPOINT_COLOR_MAX ( COLOR_MAX << FIX_POINT_PRE ) + + +/* + convert signed integer to fixpoint +*/ +inline tFixPoint s32_to_fixPoint (const s32 x) +{ + return x << FIX_POINT_PRE; +} + +inline tFixPointu u32_to_fixPoint (const u32 x) +{ + return x << FIX_POINT_PRE; +} + +inline u32 fixPointu_to_u32 (const tFixPointu x) +{ + return x >> FIX_POINT_PRE; +} + + +// 1/x * FIX_POINT +REALINLINE f32 fix_inverse32 ( const f32 x ) +{ + return FIX_POINT_F32_MUL / x; +} + + +/* + convert float to fixpoint + fast convert (fistp on x86) HAS to be used.. + hints: compileflag /QIfist for msvc7. msvc 8.0 has smth different + others should use their favourite assembler.. +*/ +static inline int f_round2(f32 f) +{ + f += (3<<22); + return *((int*)&f) - 0x4b400000; +} + +/* + convert f32 to Fix Point. + multiply is needed anyway, so scale mulby +*/ +REALINLINE tFixPoint f32_to_fixPoint (const f32 x, const f32 mulby = FIX_POINT_F32_MUL ) +{ + return (tFixPoint) (x * mulby); +} + + +/* + Fix Point , Fix Point Multiply +*/ +REALINLINE tFixPointu imulFixu(const tFixPointu x, const tFixPointu y) +{ + return (x * y) >> (tFixPointu) FIX_POINT_PRE; +} + +/* + Fix Point , Fix Point Multiply +*/ +REALINLINE tFixPoint imulFix(const tFixPoint x, const tFixPoint y) +{ + return ( x * y) >> ( FIX_POINT_PRE ); +} + +/* + Multiply x * y * 1 +*/ +REALINLINE tFixPoint imulFix_tex1(const tFixPoint x, const tFixPoint y) +{ + return ( ( (tFixPointu) x >> 2 ) * ( (tFixPointu) y >> 2 ) ) >> (tFixPointu) ( FIX_POINT_PRE + 1 ); +} + +/* + Multiply x * y * 2 +*/ +REALINLINE tFixPoint imulFix_tex2(const tFixPoint x, const tFixPoint y) +{ + return ( ( (tFixPointu) x >> 2 ) * ( (tFixPointu) y >> 2 ) ) >> (tFixPointu) ( FIX_POINT_PRE + 3 ); +} + +/* + Multiply x * y * 4 +*/ +REALINLINE tFixPoint imulFix_tex4(const tFixPoint x, const tFixPoint y) +{ +#ifdef SOFTWARE_DRIVER_2_32BIT + return ( ( (tFixPointu) x >> 2 ) * ( (tFixPointu) y >> 2 ) ) >> (tFixPointu) ( FIX_POINT_PRE + 2 ); +#else + return ( x * y) >> ( FIX_POINT_PRE + ( VIDEO_SAMPLE_GRANULARITY * 3 ) ); +#endif +} + +/*! + clamp FixPoint to maxcolor in FixPoint, min(a,31) +*/ +REALINLINE tFixPoint clampfix_maxcolor ( const tFixPoint a) +{ + tFixPoint c = (a - FIXPOINT_COLOR_MAX) >> 31; + return (a & c) | ( FIXPOINT_COLOR_MAX & ~c); +} + +/*! + clamp FixPoint to 0 in FixPoint, max(a,0) +*/ +inline tFixPoint clampfix_mincolor ( const tFixPoint a) +{ + return a - ( a & ( a >> 31 ) ); +} + + +// rount fixpoint to int +inline s32 roundFix ( const tFixPoint x ) +{ + return ( x + FIX_POINT_ZERO_DOT_FIVE ) >> FIX_POINT_PRE; +} + + + +// x in [0;1[ +inline s32 f32_to_23Bits(const f32 x) +{ + f32 y = x + 1.f; + return ((u32&)y) & 0x7FFFFF; // last 23 bits +} + +/*! + return VideoSample from fixpoint +*/ +REALINLINE tVideoSample fix_to_color ( const tFixPoint r, const tFixPoint g, const tFixPoint b ) +{ +#ifdef __BIG_ENDIAN__ + return ( r & FIXPOINT_COLOR_MAX) >> ( FIX_POINT_PRE - 8) | + ( g & FIXPOINT_COLOR_MAX) << ( 16 - FIX_POINT_PRE ) | + //( g & FIXPOINT_COLOR_MAX) << ( SHIFT_G - FIX_POINT_PRE ) | + ( b & FIXPOINT_COLOR_MAX) << ( 24 - FIX_POINT_PRE ); +#else + return ( r & FIXPOINT_COLOR_MAX) << ( SHIFT_R - FIX_POINT_PRE ) | + ( g & FIXPOINT_COLOR_MAX) >> ( FIX_POINT_PRE - SHIFT_G ) | + //( g & FIXPOINT_COLOR_MAX) << ( SHIFT_G - FIX_POINT_PRE ) | + ( b & FIXPOINT_COLOR_MAX) >> ( FIX_POINT_PRE - SHIFT_B ); +#endif +} + + +/*! + return fixpoint from VideoSample +*/ +inline void color_to_fix ( tFixPoint &r, tFixPoint &g, tFixPoint &b, const tVideoSample t00 ) +{ + r = (t00 & MASK_R) >> ( SHIFT_R - FIX_POINT_PRE ); + //g = (t00 & MASK_G) >> ( SHIFT_G - FIX_POINT_PRE ); + g = (t00 & MASK_G) << ( FIX_POINT_PRE - SHIFT_G ); + b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B ); +} + + +// ----- FP24 ---- floating point z-buffer + +#if 1 +typedef f32 fp24; +#else +struct fp24 +{ + u32 v; + + fp24() {} + + fp24 ( const f32 f ) + { + f32 y = f + 1.f; + v = ((u32&)y) & 0x7FFFFF; // last 23 bits + } + + void operator=(const f32 f ) + { + f32 y = f + 1.f; + v = ((u32&)y) & 0x7FFFFF; // last 23 bits + } + + void operator+=(const fp24 &other ) + { + v += other.v; + } + + operator f32 () const + { + f32 r = FR ( v ); + return r + 1.f; + } + +}; +#endif + + +// ------------------------ Internal Texture ----------------------------- + +struct sInternalTexture +{ + u32 textureXMask; + u32 textureYMask; + + u32 pitchlog2; + void *data; + + video::CSoftwareTexture2 *Texture; + s32 lodLevel; +}; + + + +// get video sample plain +inline tVideoSample getTexel_plain ( const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty ) +{ + u32 ofs; + + ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; + ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); + + // texel + return *((tVideoSample*)( (u8*) t->data + ofs )); +} + +// get video sample to fix +inline void getTexel_fix ( tFixPoint &r, tFixPoint &g, tFixPoint &b, + const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty + ) +{ + u32 ofs; + + ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; + ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); + + // texel + tVideoSample t00; + t00 = *((tVideoSample*)( (u8*) t->data + ofs )); + + r = (t00 & MASK_R) >> ( SHIFT_R - FIX_POINT_PRE); + g = (t00 & MASK_G) << ( FIX_POINT_PRE - SHIFT_G ); + b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B ); + +} + + +inline void getSample_texture_dither ( tFixPoint &r, tFixPoint &g, tFixPoint &b, + const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty, + const u32 x, const u32 y + ) +{ + static const tFixPointu dithermask[] = + { + 0x00,0x80,0x20,0xa0, + 0xc0,0x40,0xe0,0x60, + 0x30,0xb0,0x10,0x90, + 0xf0,0x70,0xd0,0x50 + }; + + const u32 index = (y & 3 ) << 2 | (x & 3); + + const tFixPointu _ntx = (tx + dithermask [ index ] ) & t->textureXMask; + const tFixPointu _nty = (ty + dithermask [ index ] ) & t->textureYMask; + + u32 ofs; + ofs = ( ( _nty ) >> FIX_POINT_PRE ) << t->pitchlog2; + ofs |= ( _ntx ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); + + // texel + const tVideoSample t00 = *((tVideoSample*)( (u8*) t->data + ofs )); + + (tFixPointu &) r = (t00 & MASK_R) >> ( SHIFT_R - FIX_POINT_PRE); + (tFixPointu &) g = (t00 & MASK_G) << ( FIX_POINT_PRE - SHIFT_G ); + (tFixPointu &) b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B ); + +} + +/* + load a sample from internal texture at position tx,ty to fixpoint +*/ +#ifndef SOFTWARE_DRIVER_2_BILINEAR + +// get Sample linear == getSample_fixpoint + +inline void getSample_texture ( tFixPoint &r, tFixPoint &g, tFixPoint &b, + const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty + ) +{ + u32 ofs; + + ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; + ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); + + // texel + const tVideoSample t00 = *((tVideoSample*)( (u8*) t->data + ofs )); + + (tFixPointu &) r = (t00 & MASK_R) >> ( SHIFT_R - FIX_POINT_PRE); + (tFixPointu &) g = (t00 & MASK_G) << ( FIX_POINT_PRE - SHIFT_G ); + (tFixPointu &) b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B ); + +} + + +#else + +// get sample linear +REALINLINE void getSample_linear ( tFixPointu &r, tFixPointu &g, tFixPointu &b, + const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty + ) +{ + u32 ofs; + + ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; + ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); + + // texel + tVideoSample t00; + t00 = *((tVideoSample*)( (u8*) t->data + ofs )); + + r = (t00 & MASK_R) >> SHIFT_R; + g = (t00 & MASK_G) >> SHIFT_G; + b = (t00 & MASK_B); +} + +// get Sample bilinear +REALINLINE void getSample_texture ( tFixPoint &r, tFixPoint &g, tFixPoint &b, + const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty + ) +{ + + tFixPointu r00,g00,b00; + tFixPointu r01,g01,b01; + tFixPointu r10,g10,b10; + tFixPointu r11,g11,b11; + + getSample_linear ( r00, g00, b00, t, tx,ty ); + getSample_linear ( r10, g10, b10, t, tx + FIX_POINT_ONE,ty ); + getSample_linear ( r01, g01, b01, t, tx,ty + FIX_POINT_ONE ); + getSample_linear ( r11, g11, b11, t, tx + FIX_POINT_ONE,ty + FIX_POINT_ONE ); + + const tFixPointu txFract = tx & FIX_POINT_FRACT_MASK; + const tFixPointu txFractInv = FIX_POINT_ONE - txFract; + + const tFixPointu tyFract = ty & FIX_POINT_FRACT_MASK; + const tFixPointu tyFractInv = FIX_POINT_ONE - tyFract; + + const tFixPointu w00 = imulFixu ( txFractInv, tyFractInv ); + const tFixPointu w10 = imulFixu ( txFract , tyFractInv ); + const tFixPointu w01 = imulFixu ( txFractInv, tyFract ); + const tFixPointu w11 = imulFixu ( txFract , tyFract ); + + r = (r00 * w00 ) + + (r01 * w01 ) + + (r10 * w10 ) + + (r11 * w11 ); + + g = (g00 * w00 ) + + (g01 * w01 ) + + (g10 * w10 ) + + (g11 * w11 ); + + b = (b00 * w00 ) + + (b01 * w01 ) + + (b10 * w10 ) + + (b11 * w11 ); + +} + + +// get sample linear +REALINLINE void getSample_linear ( tFixPointu &a, tFixPointu &r, tFixPointu &g, tFixPointu &b, + const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty + ) +{ + u32 ofs; + + ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; + ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); + + // texel + tVideoSample t00; + t00 = *((tVideoSample*)( (u8*) t->data + ofs )); + + a = (t00 & MASK_A) >> SHIFT_A; + r = (t00 & MASK_R) >> SHIFT_R; + g = (t00 & MASK_G) >> SHIFT_G; + b = (t00 & MASK_B); +} + +// get Sample bilinear +REALINLINE void getSample_texture ( tFixPointu &a, tFixPointu &r, tFixPointu &g, tFixPointu &b, + const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty + ) +{ + + tFixPointu a00, r00,g00,b00; + tFixPointu a01, r01,g01,b01; + tFixPointu a10, r10,g10,b10; + tFixPointu a11, r11,g11,b11; + + getSample_linear ( a00, r00, g00, b00, t, tx,ty ); + getSample_linear ( a10, r10, g10, b10, t, tx + FIX_POINT_ONE,ty ); + getSample_linear ( a01, r01, g01, b01, t, tx,ty + FIX_POINT_ONE ); + getSample_linear ( a11, r11, g11, b11, t, tx + FIX_POINT_ONE,ty + FIX_POINT_ONE ); + + const tFixPointu txFract = tx & FIX_POINT_FRACT_MASK; + const tFixPointu txFractInv = FIX_POINT_ONE - txFract; + + const tFixPointu tyFract = ty & FIX_POINT_FRACT_MASK; + const tFixPointu tyFractInv = FIX_POINT_ONE - tyFract; + + const tFixPointu w00 = imulFixu ( txFractInv, tyFractInv ); + const tFixPointu w10 = imulFixu ( txFract , tyFractInv ); + const tFixPointu w01 = imulFixu ( txFractInv, tyFract ); + const tFixPointu w11 = imulFixu ( txFract , tyFract ); + + a = (a00 * w00 ) + + (a01 * w01 ) + + (a10 * w10 ) + + (a11 * w11 ); + + r = (r00 * w00 ) + + (r01 * w01 ) + + (r10 * w10 ) + + (r11 * w11 ); + + g = (g00 * w00 ) + + (g01 * w01 ) + + (g10 * w10 ) + + (g11 * w11 ); + + b = (b00 * w00 ) + + (b01 * w01 ) + + (b10 * w10 ) + + (b11 * w11 ); + +} + + +#endif + +// some 2D Defines +struct AbsRectangle +{ + s32 x0; + s32 y0; + s32 x1; + s32 y1; +}; + +inline void intersect ( AbsRectangle &dest, const AbsRectangle& a, const AbsRectangle& b) +{ + dest.x0 = core::s32_max( a.x0, b.x0 ); + dest.y0 = core::s32_max( a.y0, b.y0 ); + dest.x1 = core::s32_min( a.x1, b.x1 ); + dest.y1 = core::s32_min( a.y1, b.y1 ); +} + +inline bool isValid (const AbsRectangle& a) +{ + return a.x0 < a.x1 && a.y0 < a.y1; +} + +// some 1D defines +struct sIntervall +{ + s32 start; + s32 end; +}; + +// returning intersection width +inline s32 intervall_intersect_test( const sIntervall& a, const sIntervall& b) +{ + return core::s32_min( a.end, b.end ) - core::s32_max( a.start, b.start ); +} + + +} // namespace + +#endif + diff --git a/src/dep/src/irrlicht/dmfsupport.h b/src/dep/src/irrlicht/dmfsupport.h index c01bd58..ded1ac6 100644 --- a/src/dep/src/irrlicht/dmfsupport.h +++ b/src/dep/src/irrlicht/dmfsupport.h @@ -1,781 +1,781 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This file was originally written by Salvatore Russo. -// I (Nikolaus Gebhardt) did some minor modifications changes to it and integrated -// it into Irrlicht: -// - removed STL dependency -// - removed log file and replaced it with irrlicht logging -// - adapted code formatting a bit to Irrlicht style -// - removed memory leaks -// Thanks a lot to Salvatore for his work on this and that he gave me -// his permission to add it into Irrlicht. - -// This support library has been made by Salvatore Russo and is released under GNU public license for general uses. -// For uses in Irrlicht core and only for Irrlicht related uses I release this library under zlib license. -// It uses standard template libraries to create String class and StringList class used in DeleD -// plugins made by me. - -#ifndef __DMF_SUPPORT_H_INCLUDED__ -#define __DMF_SUPPORT_H_INCLUDED__ - -using namespace irr; -using namespace video; - -#include "irrString.h" - -/** A structure representing some DeleD infos. - This structure contains data about DeleD level file like: version, ambient colour, number of objects etc...*/ -struct dmfHeader -{ - //main file header - f32 dmfVersion; //! tileNum;//! -{ -public: - - /**Basic Constructor*/ - StringList() - { - } - - /**Constructor based on file loading. - Look at LoadFromFile specifications.*/ - StringList(io::IReadFile* file) - { - LoadFromFile(file); - } - - /**Basic destructor.*/ - ~StringList() - { - clear(); - } - - //Adds a String to StringList - /** Add a string to this StringList.*/ - void Add(String str/*getSize(); - char* buf = new char[sz+1]; - file->read(buf, sz); - buf[sz] = 0; - char* p = buf; - char* start = p; - - while(*p) - { - if (*p == '\n') - { - core::stringc str(start, p - start - 1); - str.trim(); - Add(str); - start = p+1; - } - - ++p; - } - - if (p - start > 1) - { - core::stringc str(start, p - start - 1); - str.trim(); - Add(str); - } - - delete [] buf; - } -}; - - //This function subdivides a string in a list of strings -/** This function subdivides strings divided by divider in a list of strings. -\return A StringList made of all strings divided by divider.*/ -StringList SubdivideString(String str, String divider) -{ - StringList strings; //returned StringList - strings.clear(); //clear returned stringlist - - int c=0; - int l=str.size(); - - //process entire string - while(c= 0.91 - temp=SubdivideString(RawFile[0],String(";"));//file info - - if ( temp[0] != String("DeleD Map File") ) - return false;//not a deled file - - temp.clear(); - temp=SubdivideString(RawFile[1],String(" "));//get version - temp1=SubdivideString(temp[1],String(";")); - - if (atof(temp1[0].c_str()) < 0.91) - return false;//not correct version - - //end checking - temp.clear(); - temp1.clear(); - - for(int i=0;i=9) - { - temp1=SubdivideString(temp[temp.size() - 1],","); - materials[i].lightmapFlag=atoi(temp1[0].c_str()); - if(!use_material_dirs) - { - temp2=SubdivideString(temp1[1],"\\"); - sprintf(materials[i].lightmapName,"%s",temp2[temp2.size() - 1].c_str()); - } - else - sprintf(materials[i].lightmapName,"%s",temp1[1].c_str()); - } - else - { - materials[i].lightmapFlag=1; - materials[i].lightmapName[0]=0; - } - temp1.clear(); - temp2.clear(); - } - return true; -} - - -/**This function extract an array of dmfMaterial from a DMF file considering 1st an 2nd layer for water plains. -You must give in input a StringList representing a DMF file loaded with LoadFromFile. -\return true if function succeed or false on fail.*/ -bool GetDMFWaterMaterials(StringList RawFile /**= 0.91 - temp=SubdivideString(RawFile[0],String(";"));//file info - - if ( temp[0] != String("DeleD Map File") ) - return false;//not a deled file - - temp.clear(); - temp=SubdivideString(RawFile[1],String(" "));//get version - temp1=SubdivideString(temp[1],String(";")); - - if (atof(temp1[0].c_str()) < 0.91) - return false;//not correct version - - //end checking - temp.clear(); - temp1.clear(); - - for(int i=0;i= 0.91 - temp=SubdivideString(RawFile[0],String(";"));//file info - - if ( temp[0] != String("DeleD Map File") ) - return false;//not a deled file - - temp.clear(); - temp=SubdivideString(RawFile[1],String(" "));//get version - temp1=SubdivideString(temp[1],String(";")); - - if (atof(temp1[0].c_str()) < 0.91) - return false;//not correct version - //end checking - - temp.clear(); - temp1.clear(); - offs=offs + atoi(RawFile[offs].c_str()); - offs++; - - s32 objs = atoi(RawFile[offs].c_str()); - s32 fac=0, vert=0, tmp_sz=0, vert_cnt=0, face_cnt=0; - offs++; - - for (int i=0; i= 0.91 - temp=SubdivideString(RawFile[0],String(";"));//file info - - if ( temp[0] != String("DeleD Map File") ) - return false;//not a deled file - - temp.clear(); - temp=SubdivideString(RawFile[1],String(" "));//get version - temp1=SubdivideString(temp[1],String(";")); - - if (atof(temp1[0].c_str()) < 0.91) - return false;//not correct version - - //end checking - - temp.clear(); - temp1.clear(); - offs=offs + atoi(RawFile[offs].c_str()); - offs++; - s32 objs = atoi(RawFile[offs].c_str()); - s32 lit=0; - s32 d_lit=0; - offs++; - - //let's get position of lights in file - int i; - for(i=0;i= 0.91 - temp=SubdivideString(RawFile[0],String(";"));//file info - - if ( temp[0] != String("DeleD Map File") ) - return false;//not a deled file - - temp.clear(); - temp=SubdivideString(RawFile[1],String(" "));//get version - temp1=SubdivideString(temp[1],String(";")); - - if (atof(temp1[0].c_str()) < 0.91) - return false;//not correct version - - //end checking - - temp.clear(); - temp1.clear(); - offs=offs+atoi(RawFile[offs].c_str()); - offs++; - s32 objs=atoi(RawFile[offs].c_str()); - s32 fac=0,vert=0,tmp_sz=0,vert_cnt=0,face_cnt=0,wat_id=0; - core::dimension2d tilenum(40,40); - f32 waveheight=3.0f; - f32 wavespeed=300.0f; - f32 wavelength=80.0f; - offs++; - - for(int i=0;i tileNum;//! +{ +public: + + /**Basic Constructor*/ + StringList() + { + } + + /**Constructor based on file loading. + Look at LoadFromFile specifications.*/ + StringList(io::IReadFile* file) + { + LoadFromFile(file); + } + + /**Basic destructor.*/ + ~StringList() + { + clear(); + } + + //Adds a String to StringList + /** Add a string to this StringList.*/ + void Add(String str/*getSize(); + char* buf = new char[sz+1]; + file->read(buf, sz); + buf[sz] = 0; + char* p = buf; + char* start = p; + + while(*p) + { + if (*p == '\n') + { + core::stringc str(start, p - start - 1); + str.trim(); + Add(str); + start = p+1; + } + + ++p; + } + + if (p - start > 1) + { + core::stringc str(start, p - start - 1); + str.trim(); + Add(str); + } + + delete [] buf; + } +}; + + //This function subdivides a string in a list of strings +/** This function subdivides strings divided by divider in a list of strings. +\return A StringList made of all strings divided by divider.*/ +StringList SubdivideString(String str, String divider) +{ + StringList strings; //returned StringList + strings.clear(); //clear returned stringlist + + int c=0; + int l=str.size(); + + //process entire string + while(c= 0.91 + temp=SubdivideString(RawFile[0],String(";"));//file info + + if ( temp[0] != String("DeleD Map File") ) + return false;//not a deled file + + temp.clear(); + temp=SubdivideString(RawFile[1],String(" "));//get version + temp1=SubdivideString(temp[1],String(";")); + + if (atof(temp1[0].c_str()) < 0.91) + return false;//not correct version + + //end checking + temp.clear(); + temp1.clear(); + + for(int i=0;i=9) + { + temp1=SubdivideString(temp[temp.size() - 1],","); + materials[i].lightmapFlag=atoi(temp1[0].c_str()); + if(!use_material_dirs) + { + temp2=SubdivideString(temp1[1],"\\"); + sprintf(materials[i].lightmapName,"%s",temp2[temp2.size() - 1].c_str()); + } + else + sprintf(materials[i].lightmapName,"%s",temp1[1].c_str()); + } + else + { + materials[i].lightmapFlag=1; + materials[i].lightmapName[0]=0; + } + temp1.clear(); + temp2.clear(); + } + return true; +} + + +/**This function extract an array of dmfMaterial from a DMF file considering 1st an 2nd layer for water plains. +You must give in input a StringList representing a DMF file loaded with LoadFromFile. +\return true if function succeed or false on fail.*/ +bool GetDMFWaterMaterials(StringList RawFile /**= 0.91 + temp=SubdivideString(RawFile[0],String(";"));//file info + + if ( temp[0] != String("DeleD Map File") ) + return false;//not a deled file + + temp.clear(); + temp=SubdivideString(RawFile[1],String(" "));//get version + temp1=SubdivideString(temp[1],String(";")); + + if (atof(temp1[0].c_str()) < 0.91) + return false;//not correct version + + //end checking + temp.clear(); + temp1.clear(); + + for(int i=0;i= 0.91 + temp=SubdivideString(RawFile[0],String(";"));//file info + + if ( temp[0] != String("DeleD Map File") ) + return false;//not a deled file + + temp.clear(); + temp=SubdivideString(RawFile[1],String(" "));//get version + temp1=SubdivideString(temp[1],String(";")); + + if (atof(temp1[0].c_str()) < 0.91) + return false;//not correct version + //end checking + + temp.clear(); + temp1.clear(); + offs=offs + atoi(RawFile[offs].c_str()); + offs++; + + s32 objs = atoi(RawFile[offs].c_str()); + s32 fac=0, vert=0, tmp_sz=0, vert_cnt=0, face_cnt=0; + offs++; + + for (int i=0; i= 0.91 + temp=SubdivideString(RawFile[0],String(";"));//file info + + if ( temp[0] != String("DeleD Map File") ) + return false;//not a deled file + + temp.clear(); + temp=SubdivideString(RawFile[1],String(" "));//get version + temp1=SubdivideString(temp[1],String(";")); + + if (atof(temp1[0].c_str()) < 0.91) + return false;//not correct version + + //end checking + + temp.clear(); + temp1.clear(); + offs=offs + atoi(RawFile[offs].c_str()); + offs++; + s32 objs = atoi(RawFile[offs].c_str()); + s32 lit=0; + s32 d_lit=0; + offs++; + + //let's get position of lights in file + int i; + for(i=0;i= 0.91 + temp=SubdivideString(RawFile[0],String(";"));//file info + + if ( temp[0] != String("DeleD Map File") ) + return false;//not a deled file + + temp.clear(); + temp=SubdivideString(RawFile[1],String(" "));//get version + temp1=SubdivideString(temp[1],String(";")); + + if (atof(temp1[0].c_str()) < 0.91) + return false;//not correct version + + //end checking + + temp.clear(); + temp1.clear(); + offs=offs+atoi(RawFile[offs].c_str()); + offs++; + s32 objs=atoi(RawFile[offs].c_str()); + s32 fac=0,vert=0,tmp_sz=0,vert_cnt=0,face_cnt=0,wat_id=0; + core::dimension2d tilenum(40,40); + f32 waveheight=3.0f; + f32 wavespeed=300.0f; + f32 wavelength=80.0f; + offs++; + + for(int i=0;i -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated 2006/10/13 */ -/* Current version at http://www.opengl.org/registry/ */ -#define GL_GLEXT_VERSION 36 - -#ifndef GL_VERSION_1_2 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_RESCALE_NORMAL 0x803A -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#endif - -#ifndef GL_ARB_imaging -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 -#endif - -#ifndef GL_VERSION_1_3 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_MULTISAMPLE_BIT 0x20000000 -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_CLAMP_TO_BORDER 0x812D -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_SUBTRACT 0x84E7 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -#endif - -#ifndef GL_VERSION_1_4 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_COMPARE_R_TO_TEXTURE 0x884E -#endif - -#ifndef GL_VERSION_1_5 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE -#define GL_FOG_COORD GL_FOG_COORDINATE -#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE -#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE -#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE -#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER -#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING -#define GL_SRC0_RGB GL_SOURCE0_RGB -#define GL_SRC1_RGB GL_SOURCE1_RGB -#define GL_SRC2_RGB GL_SOURCE2_RGB -#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA -#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA -#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA -#endif - -#ifndef GL_VERSION_2_0 -#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_COORDS 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#endif - -#ifndef GL_VERSION_2_1 -#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB_ALPHA 0x8C42 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_SLUMINANCE_ALPHA 0x8C44 -#define GL_SLUMINANCE8_ALPHA8 0x8C45 -#define GL_SLUMINANCE 0x8C46 -#define GL_SLUMINANCE8 0x8C47 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#define GL_COMPRESSED_SLUMINANCE 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B -#endif - -#ifndef GL_ARB_multitexture -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -#endif - -#ifndef GL_ARB_multisample -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -#endif - -#ifndef GL_ARB_texture_env_add -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif - -#ifndef GL_ARB_texture_compression -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif - -#ifndef GL_ARB_point_parameters -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif - -#ifndef GL_ARB_shadow -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#endif - -#ifndef GL_ARB_window_pos -#endif - -#ifndef GL_ARB_vertex_program -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -#endif - -#ifndef GL_ARB_fragment_program -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -#endif - -#ifndef GL_ARB_shader_objects -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#endif - -#ifndef GL_ARB_point_sprite -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif - -#ifndef GL_ARB_texture_float -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif - -#ifndef GL_EXT_abgr -#define GL_ABGR_EXT 0x8000 -#endif - -#ifndef GL_EXT_blend_color -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -#endif - -#ifndef GL_EXT_texture -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif - -#ifndef GL_EXT_texture3D -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -#endif - -#ifndef GL_EXT_subtexture -#endif - -#ifndef GL_EXT_copy_texture -#endif - -#ifndef GL_EXT_histogram -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -#endif - -#ifndef GL_EXT_convolution -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -#endif - -#ifndef GL_SGI_color_matrix -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif - -#ifndef GL_SGI_color_table -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -#endif - -#ifndef GL_SGIS_texture4D -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif - -#ifndef GL_EXT_cmyka -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif - -#ifndef GL_EXT_texture_object -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif - -#ifndef GL_SGIS_multisample -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif - -#ifndef GL_EXT_vertex_array -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#endif - -#ifndef GL_EXT_misc_attribute -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif - -#ifndef GL_SGIX_shadow -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif - -#ifndef GL_EXT_blend_logic_op -#endif - -#ifndef GL_SGIX_interlace -#define GL_INTERLACE_SGIX 0x8094 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif - -#ifndef GL_SGIS_texture_select -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif - -#ifndef GL_EXT_point_parameters -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -#endif - -#ifndef GL_SGIX_instruments -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif - -#ifndef GL_SGIX_framezoom -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#endif - -#ifndef GL_FfdMaskSGIX -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -#endif - -#ifndef GL_SGIX_flush_raster -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif - -#ifndef GL_HP_image_transform -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif - -#ifndef GL_INGR_palette_buffer -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif - -#ifndef GL_EXT_color_subtable -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_LIST_PRIORITY_SGIX 0x8182 -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif - -#ifndef GL_EXT_index_texture -#endif - -#ifndef GL_EXT_index_material -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -#endif - -#ifndef GL_EXT_index_func -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -#endif - -#ifndef GL_WIN_phong_shading -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif - -#ifndef GL_WIN_specular_fog -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif - -#ifndef GL_EXT_light_texture -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -/* reuse GL_FRAGMENT_DEPTH_EXT */ -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif - -#ifndef GL_SGIX_impact_pixel_texture -#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 -#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 -#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 -#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 -#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 -#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 -#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A -#endif - -#ifndef GL_EXT_bgra -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif - -#ifndef GL_SGIX_async -#define GL_ASYNC_MARKER_SGIX 0x8329 -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif - -#ifndef GL_INTEL_texture_scissor -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -#endif - -#ifndef GL_HP_occlusion_test -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif - -#ifndef GL_EXT_secondary_color -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -#endif - -#ifndef GL_EXT_multi_draw_arrays -#endif - -#ifndef GL_EXT_fog_coord -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_FOG_SCALE_SGIX 0x81FC -#define GL_FOG_SCALE_VALUE_SGIX 0x81FD -#endif - -#ifndef GL_SUNX_constant_data -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -#endif - -#ifndef GL_SUN_global_alpha -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -#endif - -#ifndef GL_SUN_triangle_list -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -#endif - -#ifndef GL_SUN_vertex -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -#endif - -#ifndef GL_INGR_color_clamp -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INTERLACE_READ_INGR 0x8568 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif - -#ifndef GL_EXT_texture_cube_map -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif - -#ifndef GL_EXT_texture_env_add -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT GL_MODELVIEW -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -#endif - -#ifndef GL_NV_register_combiners -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -/* reuse GL_TEXTURE0_ARB */ -/* reuse GL_TEXTURE1_ARB */ -/* reuse GL_ZERO */ -/* reuse GL_NONE */ -/* reuse GL_FOG */ -#endif - -#ifndef GL_NV_fog_distance -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -/* reuse GL_EYE_PLANE */ -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif - -#ifndef GL_NV_blend_square -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif - -#ifndef GL_MESA_resize_buffers -#endif - -#ifndef GL_MESA_window_pos -#endif - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_CULL_VERTEX_IBM 103050 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -#endif - -#ifndef GL_SGIX_subsample -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif - -#ifndef GL_SGI_depth_pass_instrument -#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 -#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 -#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif - -#ifndef GL_3DFX_tbuffer -#endif - -#ifndef GL_EXT_multisample -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif - -#ifndef GL_SGIX_resample -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif - -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif - -#ifndef GL_NV_evaluators -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -#endif - -#ifndef GL_NV_texture_compression_vtc -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif - -#ifndef GL_NV_texture_shader -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV -#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV -#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif - -#ifndef GL_NV_vertex_program -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif - -#ifndef GL_OML_interlace -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif - -#ifndef GL_OML_subsample -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif - -#ifndef GL_OML_resample -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -#endif - -#ifndef GL_ATI_element_array -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -#endif - -#ifndef GL_SUN_mesh_array -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_DEPTH_CLAMP_NV 0x864F -#endif - -#ifndef GL_NV_occlusion_query -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#endif - -#ifndef GL_NV_point_sprite -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif - -#ifndef GL_NV_vertex_program1_1 -#endif - -#ifndef GL_EXT_shadow_funcs -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif - -#ifndef GL_APPLE_element_array -#define GL_ELEMENT_ARRAY_APPLE 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A -#endif - -#ifndef GL_APPLE_fence -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -#ifndef GL_S3_s3tc -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif - -#ifndef GL_ATI_texture_float -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif - -#ifndef GL_NV_float_buffer -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif - -#ifndef GL_NV_fragment_program -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -#endif - -#ifndef GL_NV_half_float -#define GL_HALF_FLOAT_NV 0x140B -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -#endif - -#ifndef GL_NV_primitive_restart -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif - -#ifndef GL_NV_vertex_program2 -#endif - -#ifndef GL_ATI_map_object_buffer -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#endif - -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -#endif - -#ifndef GL_MESA_pack_invert -#define GL_PACK_INVERT_MESA 0x8758 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif - -#ifndef GL_NV_fragment_program_option -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif - -#ifndef GL_NV_vertex_program2_option -/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ -/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ -#endif - -#ifndef GL_NV_vertex_program3 -/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#endif - -#ifndef GL_GREMEDY_string_marker -#endif - -#ifndef GL_EXT_packed_depth_stencil -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 -#endif - -#ifndef GL_EXT_stencil_clear_tag -#define GL_STENCIL_TAG_BITS_EXT 0x88F2 -#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 -#endif - -#ifndef GL_EXT_texture_sRGB -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif - -#ifndef GL_EXT_framebuffer_blit -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CAA -#endif - -#ifndef GL_EXT_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -#endif - -#ifndef GL_MESAX_texture_stack -#define GL_TEXTURE_1D_STACK_MESAX 0x8759 -#define GL_TEXTURE_2D_STACK_MESAX 0x875A -#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B -#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C -#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D -#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E -#endif - -#ifndef GL_EXT_timer_query -#define GL_TIME_ELAPSED_EXT 0x88BF -#endif - -#ifndef GL_EXT_gpu_program_parameters -#endif - -#ifndef GL_APPLE_flush_buffer_range -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 -#endif - - -/*************************************************************/ - -#include -#ifndef GL_VERSION_2_0 -/* GL type for program/shader text */ -typedef char GLchar; /* native character */ -#endif - -#ifndef GL_VERSION_1_5 -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -#endif - -#ifndef GL_ARB_vertex_buffer_object -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for handling shader object handles and program/shader text */ -typedef char GLcharARB; /* native character */ -typedef unsigned int GLhandleARB; /* shader object handle */ -#endif - -/* GL types for "half" precision (s10e5) float data in host memory */ -#ifndef GL_ARB_half_float_pixel -typedef unsigned short GLhalfARB; -#endif - -#ifndef GL_NV_half_float -typedef unsigned short GLhalfNV; -#endif - -#ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glext.h, so must be protected */ -#define GLEXT_64_TYPES_DEFINED -/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ -/* (as used in the GL_EXT_timer_query extension). */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include -#elif defined(__sun__) -#include -#if defined(__STDC__) -#if defined(__arch64__) -typedef long int int64_t; -typedef unsigned long int uint64_t; -#else -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#endif /* __arch64__ */ -#endif /* __STDC__ */ -#elif defined( __VMS ) -#include -#elif defined(__SCO__) || defined(__USLC__) -#include -#elif defined(__UNIXOS2__) || defined(__SOL64__) -typedef long int int32_t; -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#elif defined(WIN32) && defined(__GNUC__) -#include -#elif defined(WIN32) -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -#include /* Fallback option */ -#endif -#endif - -#ifndef GL_EXT_timer_query -typedef int64_t GLint64EXT; -typedef uint64_t GLuint64EXT; -#endif - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); -GLAPI void APIENTRY glBlendEquation (GLenum); -GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); -GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); -GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); -GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); -GLAPI void APIENTRY glResetHistogram (GLenum); -GLAPI void APIENTRY glResetMinmax (GLenum); -GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum); -GLAPI void APIENTRY glClientActiveTexture (GLenum); -GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); -GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); -GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); -GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); -GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); -GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); -GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); -GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glFogCoordf (GLfloat); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *); -GLAPI void APIENTRY glFogCoordd (GLdouble); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); -GLAPI void APIENTRY glPointParameteri (GLenum, GLint); -GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); -GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); -GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); -GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); -GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); -GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); -GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); -GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); -GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); -GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); -GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); -GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); -GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); -GLAPI void APIENTRY glWindowPos2i (GLint, GLint); -GLAPI void APIENTRY glWindowPos2iv (const GLint *); -GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2sv (const GLshort *); -GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); -GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); -GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3iv (const GLint *); -GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3sv (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -#endif - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsQuery (GLuint); -GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); -GLAPI void APIENTRY glEndQuery (GLenum); -GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); -GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); -GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint); -GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); -GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); -GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); -GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); -GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); -GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); -GLAPI void APIENTRY glAttachShader (GLuint, GLuint); -GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); -GLAPI void APIENTRY glCompileShader (GLuint); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum); -GLAPI void APIENTRY glDeleteProgram (GLuint); -GLAPI void APIENTRY glDeleteShader (GLuint); -GLAPI void APIENTRY glDetachShader (GLuint, GLuint); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); -GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); -GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgram (GLuint); -GLAPI GLboolean APIENTRY glIsShader (GLuint); -GLAPI void APIENTRY glLinkProgram (GLuint); -GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); -GLAPI void APIENTRY glUseProgram (GLuint); -GLAPI void APIENTRY glUniform1f (GLint, GLfloat); -GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform1i (GLint, GLint); -GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); -GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glValidateProgram (GLuint); -GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformMatrix2x3fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3x2fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix2x4fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4x2fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3x4fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4x3fv (GLint, GLsizei, GLboolean, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTextureARB (GLenum); -GLAPI void APIENTRY glClientActiveTextureARB (GLenum); -GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); -GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); -GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); -GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); -GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); -GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -#endif - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); -#endif - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#endif - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#endif - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); -GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); -GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); -GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); -GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); -GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); -GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); -GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); -GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexBlendARB (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); -typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); -typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); -typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); -typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); -typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); -GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); -GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); -GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); -GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#endif - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#endif - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); -GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); -GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); -GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); -GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); -GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); -GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); -GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); -GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#endif - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); -GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); -GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); -GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); -GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); -#endif - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); -GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); -GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); -GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); -GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); -GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); -GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); -GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); -GLAPI void APIENTRY glEndQueryARB (GLenum); -GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); -GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); -GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); -GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); -GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); -GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); -GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); -GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); -GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); -GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); -GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); -GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); -GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform1iARB (GLint, GLint); -GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); -GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); -GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); -GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); -GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); -GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); -GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); -GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); -GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 -#endif - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 -#endif - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#endif - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 -#endif - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); -#endif - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#endif - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); -GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); -GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); -GLAPI void APIENTRY glResetHistogramEXT (GLenum); -GLAPI void APIENTRY glResetMinmaxEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); -#endif - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); -GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif - -#ifndef GL_SGI_color_matrix -#define GL_SGI_color_matrix 1 -#endif - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); -GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); -GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); -GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); -GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); -GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 -#endif - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 -#endif - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); -GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); -GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#endif - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); -GLAPI void APIENTRY glSamplePatternSGIS (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#endif - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glArrayElementEXT (GLint); -GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); -GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); -GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); -GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#endif - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 -#endif - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 -#endif - -#ifndef GL_SGIX_texture_select -#define GL_SGIX_texture_select 1 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); -GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); -GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); -GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#endif - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); -GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); -GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); -GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); -GLAPI void APIENTRY glStartInstrumentsSGIX (void); -GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#endif - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameZoomSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTagSampleBufferSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); -GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); -GLAPI void APIENTRY glDeformSGIX (GLbitfield); -GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#endif - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRasterSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#endif - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); -GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#endif - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glHintPGI (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); -GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); -GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); -GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#endif - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); -GLAPI void APIENTRY glUnlockArraysEXT (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); -GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); -GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); -GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); -GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); -GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#endif - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#endif - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyTextureEXT (GLenum); -GLAPI void APIENTRY glTextureLightEXT (GLenum); -GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 -#endif - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#endif - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); -GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); -GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); -GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); -GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); -GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); -GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); -GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); -GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -#endif - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); -GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#endif - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); -GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); -GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); -GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); -GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); -GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); -GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); -GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); -GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); -GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureNormalEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif - -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordfEXT (GLfloat); -GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); -GLAPI void APIENTRY glFogCoorddEXT (GLdouble); -GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); -GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); -GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); -GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glTangent3ivEXT (const GLint *); -GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glTangent3svEXT (const GLshort *); -GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); -GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); -GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); -GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); -GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); -GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_SGIX_fog_scale 1 -#endif - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFinishTextureSUNX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); -#endif - -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); -GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); -GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); -GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); -GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); -GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); -GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); -GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -#endif - -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); -GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); -GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); -GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); -GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); -GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); -GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif - -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_blend_func_separate -#define GL_INGR_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#endif - -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); -GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); -GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); -#endif - -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); -GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); -GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); -GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); -GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); -GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); -#endif - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#endif - -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#endif - -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glResizeBuffersMESA (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); -#endif - -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); -GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); -GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); -GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); -GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); -GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -#endif - -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 -#endif - -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#endif - -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTbufferMask3DFX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); -#endif - -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); -GLAPI void APIENTRY glSamplePatternEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#endif - -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif - -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#endif - -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); -GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); -GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glFinishFenceNV (GLuint); -GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif - -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); -GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); -GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 -#endif - -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 -#endif - -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); -GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); -GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); -GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); -GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); -GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); -GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); -GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); -GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); -typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); -typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); -typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 -#endif - -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 -#endif - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#endif - -#ifndef GL_OML_resample -#define GL_OML_resample 1 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); -GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); -GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); -GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); -GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); -GLAPI void APIENTRY glBeginFragmentShaderATI (void); -GLAPI void APIENTRY glEndFragmentShaderATI (void); -GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); -GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); -GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); -GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); -GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); -GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); -GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); -GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVertexShaderEXT (void); -GLAPI void APIENTRY glEndVertexShaderEXT (void); -GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); -GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); -GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); -GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); -GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); -GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); -GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); -GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); -GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); -GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); -GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); -GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); -GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); -GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); -GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); -GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); -GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); -GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); -GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); -GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); -GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); -GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); -GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); -GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); -GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); -GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); -GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); -GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); -GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); -GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); -GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif - -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 -#endif - -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); -GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); -GLAPI void APIENTRY glEndOcclusionQueryNV (void); -GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); -GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#endif - -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 -#endif - -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#endif - -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); -GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); -GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); -GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif - -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); -GLAPI void APIENTRY glSetFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); -GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); -GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); -GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); -GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); -GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#endif - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -/* This is really a WGL extension, but defines some associated GL enums. - * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. - */ -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#endif - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 -#endif - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 -#endif - -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); -GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); -GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif - -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); -GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); -GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); -GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); -GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); -GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -#endif - -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartNV (void); -GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#endif - -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif - -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); -GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#endif - -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -#endif - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 -#endif - -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 -#endif - -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 -#endif - -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint); -GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); -GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); -GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint); -GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); -GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGenerateMipmapEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -#endif - -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); -#endif - -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil 1 -#endif - -#ifndef GL_EXT_stencil_clear_tag -#define GL_EXT_stencil_clear_tag 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilClearTagEXT (GLsizei, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); -#endif - -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 -#endif - -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlitFramebufferEXT (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif - -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_MESAX_texture_stack -#define GL_MESAX_texture_stack 1 -#endif - -#ifndef GL_EXT_timer_query -#define GL_EXT_timer_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint, GLenum, GLint64EXT *); -GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint, GLenum, GLuint64EXT *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); -#endif - -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum, GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum, GLuint, GLsizei, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#endif - -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum, GLintptr, GLsizeiptr); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); -#endif - - -#ifdef __cplusplus -} -#endif - -#endif +#ifndef __glext_h_ +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: This software was created using the +** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has +** not been independently verified as being compliant with the OpenGL(R) +** version 1.2.1 Specification. +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated 2006/10/13 */ +/* Current version at http://www.opengl.org/registry/ */ +#define GL_GLEXT_VERSION 36 + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_RESCALE_NORMAL 0x803A +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE +#define GL_FOG_COORD GL_FOG_COORDINATE +#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE +#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE +#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER +#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING +#define GL_SRC0_RGB GL_SOURCE0_RGB +#define GL_SRC1_RGB GL_SOURCE1_RGB +#define GL_SRC2_RGB GL_SOURCE2_RGB +#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA +#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA +#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA +#endif + +#ifndef GL_VERSION_2_0 +#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_COORDS 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#endif + +#ifndef GL_VERSION_2_1 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +#ifndef GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_FfdMaskSGIX +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_FOG_SCALE_SGIX 0x81FC +#define GL_FOG_SCALE_VALUE_SGIX 0x81FD +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_SGI_depth_pass_instrument +#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 +#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 +#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif + +#ifndef GL_NV_fragment_program_option +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif + +#ifndef GL_NV_vertex_program2_option +/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ +/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ +#endif + +#ifndef GL_NV_vertex_program3 +/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#endif + +#ifndef GL_GREMEDY_string_marker +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CAA +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif + +#ifndef GL_EXT_timer_query +#define GL_TIME_ELAPSED_EXT 0x88BF +#endif + +#ifndef GL_EXT_gpu_program_parameters +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +#endif + + +/*************************************************************/ + +#include +#ifndef GL_VERSION_2_0 +/* GL type for program/shader text */ +typedef char GLchar; /* native character */ +#endif + +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for handling shader object handles and program/shader text */ +typedef char GLcharARB; /* native character */ +typedef unsigned int GLhandleARB; /* shader object handle */ +#endif + +/* GL types for "half" precision (s10e5) float data in host memory */ +#ifndef GL_ARB_half_float_pixel +typedef unsigned short GLhalfARB; +#endif + +#ifndef GL_NV_half_float +typedef unsigned short GLhalfNV; +#endif + +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) +#include +#if defined(__STDC__) +#if defined(__arch64__) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(WIN32) && defined(__GNUC__) +#include +#elif defined(WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +#include /* Fallback option */ +#endif +#endif + +#ifndef GL_EXT_timer_query +typedef int64_t GLint64EXT; +typedef uint64_t GLuint64EXT; +#endif + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); +GLAPI void APIENTRY glBlendEquation (GLenum); +GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogram (GLenum); +GLAPI void APIENTRY glResetMinmax (GLenum); +GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum); +GLAPI void APIENTRY glClientActiveTexture (GLenum); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glFogCoordf (GLfloat); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *); +GLAPI void APIENTRY glFogCoordd (GLdouble); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); +GLAPI void APIENTRY glPointParameteri (GLenum, GLint); +GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); +GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos2i (GLint, GLint); +GLAPI void APIENTRY glWindowPos2iv (const GLint *); +GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *); +GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3iv (const GLint *); +GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQuery (GLuint); +GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); +GLAPI void APIENTRY glEndQuery (GLenum); +GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); +GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint); +GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); +GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); +GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); +GLAPI void APIENTRY glAttachShader (GLuint, GLuint); +GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); +GLAPI void APIENTRY glCompileShader (GLuint); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum); +GLAPI void APIENTRY glDeleteProgram (GLuint); +GLAPI void APIENTRY glDeleteShader (GLuint); +GLAPI void APIENTRY glDetachShader (GLuint, GLuint); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); +GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgram (GLuint); +GLAPI GLboolean APIENTRY glIsShader (GLuint); +GLAPI void APIENTRY glLinkProgram (GLuint); +GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); +GLAPI void APIENTRY glUseProgram (GLuint); +GLAPI void APIENTRY glUniform1f (GLint, GLfloat); +GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1i (GLint, GLint); +GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glValidateProgram (GLuint); +GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint, GLsizei, GLboolean, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); +GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); +GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); +GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); +GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); +GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexBlendARB (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); +GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); +GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); +GLAPI void APIENTRY glEndQueryARB (GLenum); +GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); +GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); +GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1iARB (GLint, GLint); +GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#endif + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogramEXT (GLenum); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint); +GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); +GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); +GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIX_texture_select +#define GL_SGIX_texture_select 1 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); +GLAPI void APIENTRY glDeformSGIX (GLbitfield); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); +GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); +GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum); +GLAPI void APIENTRY glTextureLightEXT (GLenum); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); +GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); +GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); +GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); +GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *); +GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); +GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); +GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); +GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); +GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFinishFenceNV (GLuint); +GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); +GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); +GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); +GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); +GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); +GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); +GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); +GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); +GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); +GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); +GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); +GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); +GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +/* This is really a WGL extension, but defines some associated GL enums. + * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. + */ +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#endif + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#endif + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#endif + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint, GLenum, GLint64EXT *); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint, GLenum, GLuint64EXT *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum, GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum, GLuint, GLsizei, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum, GLintptr, GLsizeiptr); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/src/irrlicht/glxext.h b/src/dep/src/irrlicht/glxext.h index f644a49..aac6d61 100644 --- a/src/dep/src/irrlicht/glxext.h +++ b/src/dep/src/irrlicht/glxext.h @@ -1,728 +1,728 @@ -#ifndef __glxext_h_ -#define __glxext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: This software was created using the -** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has -** not been independently verified as being compliant with the OpenGL(R) -** version 1.2.1 Specification. -*/ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number, required by OpenGL ABI for Linux */ -/* glxext.h last updated 2006/10/11 */ -/* Current version at http://www.opengl.org/registry/ */ -#define GLX_GLXEXT_VERSION 15 - -#ifndef GLX_VERSION_1_3 -#define GLX_WINDOW_BIT 0x00000001 -#define GLX_PIXMAP_BIT 0x00000002 -#define GLX_PBUFFER_BIT 0x00000004 -#define GLX_RGBA_BIT 0x00000001 -#define GLX_COLOR_INDEX_BIT 0x00000002 -#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 -#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 -#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 -#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 -#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 -#define GLX_AUX_BUFFERS_BIT 0x00000010 -#define GLX_DEPTH_BUFFER_BIT 0x00000020 -#define GLX_STENCIL_BUFFER_BIT 0x00000040 -#define GLX_ACCUM_BUFFER_BIT 0x00000080 -#define GLX_CONFIG_CAVEAT 0x20 -#define GLX_X_VISUAL_TYPE 0x22 -#define GLX_TRANSPARENT_TYPE 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE 0x24 -#define GLX_TRANSPARENT_RED_VALUE 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE 0x28 -#define GLX_DONT_CARE 0xFFFFFFFF -#define GLX_NONE 0x8000 -#define GLX_SLOW_CONFIG 0x8001 -#define GLX_TRUE_COLOR 0x8002 -#define GLX_DIRECT_COLOR 0x8003 -#define GLX_PSEUDO_COLOR 0x8004 -#define GLX_STATIC_COLOR 0x8005 -#define GLX_GRAY_SCALE 0x8006 -#define GLX_STATIC_GRAY 0x8007 -#define GLX_TRANSPARENT_RGB 0x8008 -#define GLX_TRANSPARENT_INDEX 0x8009 -#define GLX_VISUAL_ID 0x800B -#define GLX_SCREEN 0x800C -#define GLX_NON_CONFORMANT_CONFIG 0x800D -#define GLX_DRAWABLE_TYPE 0x8010 -#define GLX_RENDER_TYPE 0x8011 -#define GLX_X_RENDERABLE 0x8012 -#define GLX_FBCONFIG_ID 0x8013 -#define GLX_RGBA_TYPE 0x8014 -#define GLX_COLOR_INDEX_TYPE 0x8015 -#define GLX_MAX_PBUFFER_WIDTH 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT 0x8017 -#define GLX_MAX_PBUFFER_PIXELS 0x8018 -#define GLX_PRESERVED_CONTENTS 0x801B -#define GLX_LARGEST_PBUFFER 0x801C -#define GLX_WIDTH 0x801D -#define GLX_HEIGHT 0x801E -#define GLX_EVENT_MASK 0x801F -#define GLX_DAMAGED 0x8020 -#define GLX_SAVED 0x8021 -#define GLX_WINDOW 0x8022 -#define GLX_PBUFFER 0x8023 -#define GLX_PBUFFER_HEIGHT 0x8040 -#define GLX_PBUFFER_WIDTH 0x8041 -#endif - -#ifndef GLX_VERSION_1_4 -#define GLX_SAMPLE_BUFFERS 100000 -#define GLX_SAMPLES 100001 -#endif - -#ifndef GLX_ARB_get_proc_address -#endif - -#ifndef GLX_ARB_multisample -#define GLX_SAMPLE_BUFFERS_ARB 100000 -#define GLX_SAMPLES_ARB 100001 -#endif - -#ifndef GLX_ARB_fbconfig_float -#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9 -#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004 -#endif - -#ifndef GLX_SGIS_multisample -#define GLX_SAMPLE_BUFFERS_SGIS 100000 -#define GLX_SAMPLES_SGIS 100001 -#endif - -#ifndef GLX_EXT_visual_info -#define GLX_X_VISUAL_TYPE_EXT 0x22 -#define GLX_TRANSPARENT_TYPE_EXT 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 -#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 -#define GLX_NONE_EXT 0x8000 -#define GLX_TRUE_COLOR_EXT 0x8002 -#define GLX_DIRECT_COLOR_EXT 0x8003 -#define GLX_PSEUDO_COLOR_EXT 0x8004 -#define GLX_STATIC_COLOR_EXT 0x8005 -#define GLX_GRAY_SCALE_EXT 0x8006 -#define GLX_STATIC_GRAY_EXT 0x8007 -#define GLX_TRANSPARENT_RGB_EXT 0x8008 -#define GLX_TRANSPARENT_INDEX_EXT 0x8009 -#endif - -#ifndef GLX_SGI_swap_control -#endif - -#ifndef GLX_SGI_video_sync -#endif - -#ifndef GLX_SGI_make_current_read -#endif - -#ifndef GLX_SGIX_video_source -#endif - -#ifndef GLX_EXT_visual_rating -#define GLX_VISUAL_CAVEAT_EXT 0x20 -#define GLX_SLOW_VISUAL_EXT 0x8001 -#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D -/* reuse GLX_NONE_EXT */ -#endif - -#ifndef GLX_EXT_import_context -#define GLX_SHARE_CONTEXT_EXT 0x800A -#define GLX_VISUAL_ID_EXT 0x800B -#define GLX_SCREEN_EXT 0x800C -#endif - -#ifndef GLX_SGIX_fbconfig -#define GLX_WINDOW_BIT_SGIX 0x00000001 -#define GLX_PIXMAP_BIT_SGIX 0x00000002 -#define GLX_RGBA_BIT_SGIX 0x00000001 -#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002 -#define GLX_DRAWABLE_TYPE_SGIX 0x8010 -#define GLX_RENDER_TYPE_SGIX 0x8011 -#define GLX_X_RENDERABLE_SGIX 0x8012 -#define GLX_FBCONFIG_ID_SGIX 0x8013 -#define GLX_RGBA_TYPE_SGIX 0x8014 -#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015 -/* reuse GLX_SCREEN_EXT */ -#endif - -#ifndef GLX_SGIX_pbuffer -#define GLX_PBUFFER_BIT_SGIX 0x00000004 -#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 -#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 -#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 -#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 -#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 -#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 -#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 -#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 -#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 -#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 -#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 -#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 -#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 -#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A -#define GLX_PRESERVED_CONTENTS_SGIX 0x801B -#define GLX_LARGEST_PBUFFER_SGIX 0x801C -#define GLX_WIDTH_SGIX 0x801D -#define GLX_HEIGHT_SGIX 0x801E -#define GLX_EVENT_MASK_SGIX 0x801F -#define GLX_DAMAGED_SGIX 0x8020 -#define GLX_SAVED_SGIX 0x8021 -#define GLX_WINDOW_SGIX 0x8022 -#define GLX_PBUFFER_SGIX 0x8023 -#endif - -#ifndef GLX_SGI_cushion -#endif - -#ifndef GLX_SGIX_video_resize -#define GLX_SYNC_FRAME_SGIX 0x00000000 -#define GLX_SYNC_SWAP_SGIX 0x00000001 -#endif - -#ifndef GLX_SGIX_dmbuffer -#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX 0x8024 -#endif - -#ifndef GLX_SGIX_swap_group -#endif - -#ifndef GLX_SGIX_swap_barrier -#endif - -#ifndef GLX_SGIS_blended_overlay -#define GLX_BLENDED_RGBA_SGIS 0x8025 -#endif - -#ifndef GLX_SGIS_shared_multisample -#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 -#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 -#endif - -#ifndef GLX_SUN_get_transparent_index -#endif - -#ifndef GLX_3DFX_multisample -#define GLX_SAMPLE_BUFFERS_3DFX 0x8050 -#define GLX_SAMPLES_3DFX 0x8051 -#endif - -#ifndef GLX_MESA_copy_sub_buffer -#endif - -#ifndef GLX_MESA_pixmap_colormap -#endif - -#ifndef GLX_MESA_release_buffers -#endif - -#ifndef GLX_MESA_set_3dfx_mode -#define GLX_3DFX_WINDOW_MODE_MESA 0x1 -#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 -#endif - -#ifndef GLX_SGIX_visual_select_group -#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 -#endif - -#ifndef GLX_OML_swap_method -#define GLX_SWAP_METHOD_OML 0x8060 -#define GLX_SWAP_EXCHANGE_OML 0x8061 -#define GLX_SWAP_COPY_OML 0x8062 -#define GLX_SWAP_UNDEFINED_OML 0x8063 -#endif - -#ifndef GLX_OML_sync_control -#endif - -#ifndef GLX_NV_float_buffer -#define GLX_FLOAT_COMPONENTS_NV 0x20B0 -#endif - -#ifndef GLX_SGIX_hyperpipe -#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80 -#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91 -#define GLX_BAD_HYPERPIPE_SGIX 92 -#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001 -#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002 -#define GLX_PIPE_RECT_SGIX 0x00000001 -#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002 -#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003 -#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004 -#define GLX_HYPERPIPE_ID_SGIX 0x8030 -#endif - -#ifndef GLX_MESA_agp_offset -#endif - - -/*************************************************************/ - -#ifndef GLX_ARB_get_proc_address -typedef void (*__GLXextFuncPtr)(void); -#endif - -#ifndef GLX_SGIX_video_source -typedef XID GLXVideoSourceSGIX; -#endif - -#ifndef GLX_SGIX_fbconfig -typedef XID GLXFBConfigIDSGIX; -typedef struct __GLXFBConfigRec *GLXFBConfigSGIX; -#endif - -#ifndef GLX_SGIX_pbuffer -typedef XID GLXPbufferSGIX; -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came for SendEvent request */ - Display *display; /* display the event was read from */ - GLXDrawable drawable; /* i.d. of Drawable */ - int event_type; /* GLX_DAMAGED_SGIX or GLX_SAVED_SGIX */ - int draw_type; /* GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX */ - unsigned int mask; /* mask indicating which buffers are affected*/ - int x, y; - int width, height; - int count; /* if nonzero, at least this many more */ -} GLXBufferClobberEventSGIX; -#endif - -#ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glxext.h, so must be protected */ -#define GLEXT_64_TYPES_DEFINED -/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ -/* (as used in the GLX_OML_sync_control extension). */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include -#elif defined(__sun__) -#include -#if defined(__STDC__) -#if defined(__arch64__) -typedef long int int64_t; -typedef unsigned long int uint64_t; -#else -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#endif /* __arch64__ */ -#endif /* __STDC__ */ -#elif defined( __VMS ) -#include -#elif defined(__SCO__) || defined(__USLC__) -#include -#elif defined(__UNIXOS2__) || defined(__SOL64__) -typedef long int int32_t; -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#elif defined(WIN32) && defined(__GNUC__) -#include -#elif defined(WIN32) -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -#include /* Fallback option */ -#endif -#endif - -#ifndef GLX_VERSION_1_3 -#define GLX_VERSION_1_3 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXFBConfig * glXGetFBConfigs (Display *, int, int *); -extern GLXFBConfig * glXChooseFBConfig (Display *, int, const int *, int *); -extern int glXGetFBConfigAttrib (Display *, GLXFBConfig, int, int *); -extern XVisualInfo * glXGetVisualFromFBConfig (Display *, GLXFBConfig); -extern GLXWindow glXCreateWindow (Display *, GLXFBConfig, Window, const int *); -extern void glXDestroyWindow (Display *, GLXWindow); -extern GLXPixmap glXCreatePixmap (Display *, GLXFBConfig, Pixmap, const int *); -extern void glXDestroyPixmap (Display *, GLXPixmap); -extern GLXPbuffer glXCreatePbuffer (Display *, GLXFBConfig, const int *); -extern void glXDestroyPbuffer (Display *, GLXPbuffer); -extern void glXQueryDrawable (Display *, GLXDrawable, int, unsigned int *); -extern GLXContext glXCreateNewContext (Display *, GLXFBConfig, int, GLXContext, Bool); -extern Bool glXMakeContextCurrent (Display *, GLXDrawable, GLXDrawable, GLXContext); -extern GLXDrawable glXGetCurrentReadDrawable (void); -extern Display * glXGetCurrentDisplay (void); -extern int glXQueryContext (Display *, GLXContext, int, int *); -extern void glXSelectEvent (Display *, GLXDrawable, unsigned long); -extern void glXGetSelectedEvent (Display *, GLXDrawable, unsigned long *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXFBConfig * ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements); -typedef GLXFBConfig * ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); -typedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value); -typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config); -typedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); -typedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win); -typedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); -typedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap); -typedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list); -typedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf); -typedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); -typedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); -typedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); -typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void); -typedef Display * ( * PFNGLXGETCURRENTDISPLAYPROC) (void); -typedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); -typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask); -typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask); -#endif - -#ifndef GLX_VERSION_1_4 -#define GLX_VERSION_1_4 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern __GLXextFuncPtr glXGetProcAddress (const GLubyte *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); -#endif - -#ifndef GLX_ARB_get_proc_address -#define GLX_ARB_get_proc_address 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName); -#endif - -#ifndef GLX_ARB_multisample -#define GLX_ARB_multisample 1 -#endif - -#ifndef GLX_ARB_fbconfig_float -#define GLX_ARB_fbconfig_float 1 -#endif - -#ifndef GLX_SGIS_multisample -#define GLX_SGIS_multisample 1 -#endif - -#ifndef GLX_EXT_visual_info -#define GLX_EXT_visual_info 1 -#endif - -#ifndef GLX_SGI_swap_control -#define GLX_SGI_swap_control 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXSwapIntervalSGI (int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval); -#endif - -#ifndef GLX_SGI_video_sync -#define GLX_SGI_video_sync 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXGetVideoSyncSGI (unsigned int *); -extern int glXWaitVideoSyncSGI (int, int, unsigned int *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count); -typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count); -#endif - -#ifndef GLX_SGI_make_current_read -#define GLX_SGI_make_current_read 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXMakeCurrentReadSGI (Display *, GLXDrawable, GLXDrawable, GLXContext); -extern GLXDrawable glXGetCurrentReadDrawableSGI (void); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); -typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void); -#endif - -#ifndef GLX_SGIX_video_source -#define GLX_SGIX_video_source 1 -#ifdef _VL_H -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *, int, VLServer, VLPath, int, VLNode); -extern void glXDestroyGLXVideoSourceSGIX (Display *, GLXVideoSourceSGIX); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXVideoSourceSGIX ( * PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode); -typedef void ( * PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource); -#endif /* _VL_H */ -#endif - -#ifndef GLX_EXT_visual_rating -#define GLX_EXT_visual_rating 1 -#endif - -#ifndef GLX_EXT_import_context -#define GLX_EXT_import_context 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Display * glXGetCurrentDisplayEXT (void); -extern int glXQueryContextInfoEXT (Display *, GLXContext, int, int *); -extern GLXContextID glXGetContextIDEXT (const GLXContext); -extern GLXContext glXImportContextEXT (Display *, GLXContextID); -extern void glXFreeContextEXT (Display *, GLXContext); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Display * ( * PFNGLXGETCURRENTDISPLAYEXTPROC) (void); -typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value); -typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context); -typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID); -typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context); -#endif - -#ifndef GLX_SGIX_fbconfig -#define GLX_SGIX_fbconfig 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXGetFBConfigAttribSGIX (Display *, GLXFBConfigSGIX, int, int *); -extern GLXFBConfigSGIX * glXChooseFBConfigSGIX (Display *, int, int *, int *); -extern GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *, GLXFBConfigSGIX, Pixmap); -extern GLXContext glXCreateContextWithConfigSGIX (Display *, GLXFBConfigSGIX, int, GLXContext, Bool); -extern XVisualInfo * glXGetVisualFromFBConfigSGIX (Display *, GLXFBConfigSGIX); -extern GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *, XVisualInfo *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value); -typedef GLXFBConfigSGIX * ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements); -typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap); -typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct); -typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config); -typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis); -#endif - -#ifndef GLX_SGIX_pbuffer -#define GLX_SGIX_pbuffer 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *, GLXFBConfigSGIX, unsigned int, unsigned int, int *); -extern void glXDestroyGLXPbufferSGIX (Display *, GLXPbufferSGIX); -extern int glXQueryGLXPbufferSGIX (Display *, GLXPbufferSGIX, int, unsigned int *); -extern void glXSelectEventSGIX (Display *, GLXDrawable, unsigned long); -extern void glXGetSelectedEventSGIX (Display *, GLXDrawable, unsigned long *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXPbufferSGIX ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list); -typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf); -typedef int ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); -typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask); -typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask); -#endif - -#ifndef GLX_SGI_cushion -#define GLX_SGI_cushion 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXCushionSGI (Display *, Window, float); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion); -#endif - -#ifndef GLX_SGIX_video_resize -#define GLX_SGIX_video_resize 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXBindChannelToWindowSGIX (Display *, int, int, Window); -extern int glXChannelRectSGIX (Display *, int, int, int, int, int, int); -extern int glXQueryChannelRectSGIX (Display *, int, int, int *, int *, int *, int *); -extern int glXQueryChannelDeltasSGIX (Display *, int, int, int *, int *, int *, int *); -extern int glXChannelRectSyncSGIX (Display *, int, int, GLenum); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window); -typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h); -typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); -typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h); -typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype); -#endif - -#ifndef GLX_SGIX_dmbuffer -#define GLX_SGIX_dmbuffer 1 -#ifdef _DM_BUFFER_H_ -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXAssociateDMPbufferSGIX (Display *, GLXPbufferSGIX, DMparams *, DMbuffer); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer); -#endif /* _DM_BUFFER_H_ */ -#endif - -#ifndef GLX_SGIX_swap_group -#define GLX_SGIX_swap_group 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXJoinSwapGroupSGIX (Display *, GLXDrawable, GLXDrawable); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member); -#endif - -#ifndef GLX_SGIX_swap_barrier -#define GLX_SGIX_swap_barrier 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXBindSwapBarrierSGIX (Display *, GLXDrawable, int); -extern Bool glXQueryMaxSwapBarriersSGIX (Display *, int, int *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier); -typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max); -#endif - -#ifndef GLX_SUN_get_transparent_index -#define GLX_SUN_get_transparent_index 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Status glXGetTransparentIndexSUN (Display *, Window, Window, long *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex); -#endif - -#ifndef GLX_MESA_copy_sub_buffer -#define GLX_MESA_copy_sub_buffer 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXCopySubBufferMESA (Display *, GLXDrawable, int, int, int, int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height); -#endif - -#ifndef GLX_MESA_pixmap_colormap -#define GLX_MESA_pixmap_colormap 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXPixmap glXCreateGLXPixmapMESA (Display *, XVisualInfo *, Pixmap, Colormap); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); -#endif - -#ifndef GLX_MESA_release_buffers -#define GLX_MESA_release_buffers 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXReleaseBuffersMESA (Display *, GLXDrawable); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable); -#endif - -#ifndef GLX_MESA_set_3dfx_mode -#define GLX_MESA_set_3dfx_mode 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXSet3DfxModeMESA (int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXSET3DFXMODEMESAPROC) (int mode); -#endif - -#ifndef GLX_SGIX_visual_select_group -#define GLX_SGIX_visual_select_group 1 -#endif - -#ifndef GLX_OML_swap_method -#define GLX_OML_swap_method 1 -#endif - -#ifndef GLX_OML_sync_control -#define GLX_OML_sync_control 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXGetSyncValuesOML (Display *, GLXDrawable, int64_t *, int64_t *, int64_t *); -extern Bool glXGetMscRateOML (Display *, GLXDrawable, int32_t *, int32_t *); -extern int64_t glXSwapBuffersMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t); -extern Bool glXWaitForMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t, int64_t *, int64_t *, int64_t *); -extern Bool glXWaitForSbcOML (Display *, GLXDrawable, int64_t, int64_t *, int64_t *, int64_t *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc); -typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator); -typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); -typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc); -typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc); -#endif - -#ifndef GLX_NV_float_buffer -#define GLX_NV_float_buffer 1 -#endif - -#ifndef GLX_SGIX_hyperpipe -#define GLX_SGIX_hyperpipe 1 - -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int networkId; -} GLXHyperpipeNetworkSGIX; - -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int channel; - unsigned int - participationType; - int timeSlice; -} GLXHyperpipeConfigSGIX; - -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int srcXOrigin, srcYOrigin, srcWidth, srcHeight; - int destXOrigin, destYOrigin, destWidth, destHeight; -} GLXPipeRect; - -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int XOrigin, YOrigin, maxHeight, maxWidth; -} GLXPipeRectLimits; - -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXHyperpipeNetworkSGIX * glXQueryHyperpipeNetworkSGIX (Display *, int *); -extern int glXHyperpipeConfigSGIX (Display *, int, int, GLXHyperpipeConfigSGIX *, int *); -extern GLXHyperpipeConfigSGIX * glXQueryHyperpipeConfigSGIX (Display *, int, int *); -extern int glXDestroyHyperpipeConfigSGIX (Display *, int); -extern int glXBindHyperpipeSGIX (Display *, int); -extern int glXQueryHyperpipeBestAttribSGIX (Display *, int, int, int, void *, void *); -extern int glXHyperpipeAttribSGIX (Display *, int, int, int, void *); -extern int glXQueryHyperpipeAttribSGIX (Display *, int, int, int, void *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes); -typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); -typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes); -typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId); -typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId); -typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); -typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList); -typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); -#endif - -#ifndef GLX_MESA_agp_offset -#define GLX_MESA_agp_offset 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern unsigned int glXGetAGPOffsetMESA (const void *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void *pointer); -#endif - - -#ifdef __cplusplus -} -#endif - -#endif +#ifndef __glxext_h_ +#define __glxext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: This software was created using the +** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has +** not been independently verified as being compliant with the OpenGL(R) +** version 1.2.1 Specification. +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glxext.h last updated 2006/10/11 */ +/* Current version at http://www.opengl.org/registry/ */ +#define GLX_GLXEXT_VERSION 15 + +#ifndef GLX_VERSION_1_3 +#define GLX_WINDOW_BIT 0x00000001 +#define GLX_PIXMAP_BIT 0x00000002 +#define GLX_PBUFFER_BIT 0x00000004 +#define GLX_RGBA_BIT 0x00000001 +#define GLX_COLOR_INDEX_BIT 0x00000002 +#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 +#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 +#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 +#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 +#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 +#define GLX_AUX_BUFFERS_BIT 0x00000010 +#define GLX_DEPTH_BUFFER_BIT 0x00000020 +#define GLX_STENCIL_BUFFER_BIT 0x00000040 +#define GLX_ACCUM_BUFFER_BIT 0x00000080 +#define GLX_CONFIG_CAVEAT 0x20 +#define GLX_X_VISUAL_TYPE 0x22 +#define GLX_TRANSPARENT_TYPE 0x23 +#define GLX_TRANSPARENT_INDEX_VALUE 0x24 +#define GLX_TRANSPARENT_RED_VALUE 0x25 +#define GLX_TRANSPARENT_GREEN_VALUE 0x26 +#define GLX_TRANSPARENT_BLUE_VALUE 0x27 +#define GLX_TRANSPARENT_ALPHA_VALUE 0x28 +#define GLX_DONT_CARE 0xFFFFFFFF +#define GLX_NONE 0x8000 +#define GLX_SLOW_CONFIG 0x8001 +#define GLX_TRUE_COLOR 0x8002 +#define GLX_DIRECT_COLOR 0x8003 +#define GLX_PSEUDO_COLOR 0x8004 +#define GLX_STATIC_COLOR 0x8005 +#define GLX_GRAY_SCALE 0x8006 +#define GLX_STATIC_GRAY 0x8007 +#define GLX_TRANSPARENT_RGB 0x8008 +#define GLX_TRANSPARENT_INDEX 0x8009 +#define GLX_VISUAL_ID 0x800B +#define GLX_SCREEN 0x800C +#define GLX_NON_CONFORMANT_CONFIG 0x800D +#define GLX_DRAWABLE_TYPE 0x8010 +#define GLX_RENDER_TYPE 0x8011 +#define GLX_X_RENDERABLE 0x8012 +#define GLX_FBCONFIG_ID 0x8013 +#define GLX_RGBA_TYPE 0x8014 +#define GLX_COLOR_INDEX_TYPE 0x8015 +#define GLX_MAX_PBUFFER_WIDTH 0x8016 +#define GLX_MAX_PBUFFER_HEIGHT 0x8017 +#define GLX_MAX_PBUFFER_PIXELS 0x8018 +#define GLX_PRESERVED_CONTENTS 0x801B +#define GLX_LARGEST_PBUFFER 0x801C +#define GLX_WIDTH 0x801D +#define GLX_HEIGHT 0x801E +#define GLX_EVENT_MASK 0x801F +#define GLX_DAMAGED 0x8020 +#define GLX_SAVED 0x8021 +#define GLX_WINDOW 0x8022 +#define GLX_PBUFFER 0x8023 +#define GLX_PBUFFER_HEIGHT 0x8040 +#define GLX_PBUFFER_WIDTH 0x8041 +#endif + +#ifndef GLX_VERSION_1_4 +#define GLX_SAMPLE_BUFFERS 100000 +#define GLX_SAMPLES 100001 +#endif + +#ifndef GLX_ARB_get_proc_address +#endif + +#ifndef GLX_ARB_multisample +#define GLX_SAMPLE_BUFFERS_ARB 100000 +#define GLX_SAMPLES_ARB 100001 +#endif + +#ifndef GLX_ARB_fbconfig_float +#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9 +#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004 +#endif + +#ifndef GLX_SGIS_multisample +#define GLX_SAMPLE_BUFFERS_SGIS 100000 +#define GLX_SAMPLES_SGIS 100001 +#endif + +#ifndef GLX_EXT_visual_info +#define GLX_X_VISUAL_TYPE_EXT 0x22 +#define GLX_TRANSPARENT_TYPE_EXT 0x23 +#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 +#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 +#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 +#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 +#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 +#define GLX_NONE_EXT 0x8000 +#define GLX_TRUE_COLOR_EXT 0x8002 +#define GLX_DIRECT_COLOR_EXT 0x8003 +#define GLX_PSEUDO_COLOR_EXT 0x8004 +#define GLX_STATIC_COLOR_EXT 0x8005 +#define GLX_GRAY_SCALE_EXT 0x8006 +#define GLX_STATIC_GRAY_EXT 0x8007 +#define GLX_TRANSPARENT_RGB_EXT 0x8008 +#define GLX_TRANSPARENT_INDEX_EXT 0x8009 +#endif + +#ifndef GLX_SGI_swap_control +#endif + +#ifndef GLX_SGI_video_sync +#endif + +#ifndef GLX_SGI_make_current_read +#endif + +#ifndef GLX_SGIX_video_source +#endif + +#ifndef GLX_EXT_visual_rating +#define GLX_VISUAL_CAVEAT_EXT 0x20 +#define GLX_SLOW_VISUAL_EXT 0x8001 +#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D +/* reuse GLX_NONE_EXT */ +#endif + +#ifndef GLX_EXT_import_context +#define GLX_SHARE_CONTEXT_EXT 0x800A +#define GLX_VISUAL_ID_EXT 0x800B +#define GLX_SCREEN_EXT 0x800C +#endif + +#ifndef GLX_SGIX_fbconfig +#define GLX_WINDOW_BIT_SGIX 0x00000001 +#define GLX_PIXMAP_BIT_SGIX 0x00000002 +#define GLX_RGBA_BIT_SGIX 0x00000001 +#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002 +#define GLX_DRAWABLE_TYPE_SGIX 0x8010 +#define GLX_RENDER_TYPE_SGIX 0x8011 +#define GLX_X_RENDERABLE_SGIX 0x8012 +#define GLX_FBCONFIG_ID_SGIX 0x8013 +#define GLX_RGBA_TYPE_SGIX 0x8014 +#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015 +/* reuse GLX_SCREEN_EXT */ +#endif + +#ifndef GLX_SGIX_pbuffer +#define GLX_PBUFFER_BIT_SGIX 0x00000004 +#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 +#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 +#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 +#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 +#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 +#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 +#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 +#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 +#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 +#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 +#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 +#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 +#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 +#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 +#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A +#define GLX_PRESERVED_CONTENTS_SGIX 0x801B +#define GLX_LARGEST_PBUFFER_SGIX 0x801C +#define GLX_WIDTH_SGIX 0x801D +#define GLX_HEIGHT_SGIX 0x801E +#define GLX_EVENT_MASK_SGIX 0x801F +#define GLX_DAMAGED_SGIX 0x8020 +#define GLX_SAVED_SGIX 0x8021 +#define GLX_WINDOW_SGIX 0x8022 +#define GLX_PBUFFER_SGIX 0x8023 +#endif + +#ifndef GLX_SGI_cushion +#endif + +#ifndef GLX_SGIX_video_resize +#define GLX_SYNC_FRAME_SGIX 0x00000000 +#define GLX_SYNC_SWAP_SGIX 0x00000001 +#endif + +#ifndef GLX_SGIX_dmbuffer +#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX 0x8024 +#endif + +#ifndef GLX_SGIX_swap_group +#endif + +#ifndef GLX_SGIX_swap_barrier +#endif + +#ifndef GLX_SGIS_blended_overlay +#define GLX_BLENDED_RGBA_SGIS 0x8025 +#endif + +#ifndef GLX_SGIS_shared_multisample +#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 +#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 +#endif + +#ifndef GLX_SUN_get_transparent_index +#endif + +#ifndef GLX_3DFX_multisample +#define GLX_SAMPLE_BUFFERS_3DFX 0x8050 +#define GLX_SAMPLES_3DFX 0x8051 +#endif + +#ifndef GLX_MESA_copy_sub_buffer +#endif + +#ifndef GLX_MESA_pixmap_colormap +#endif + +#ifndef GLX_MESA_release_buffers +#endif + +#ifndef GLX_MESA_set_3dfx_mode +#define GLX_3DFX_WINDOW_MODE_MESA 0x1 +#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 +#endif + +#ifndef GLX_SGIX_visual_select_group +#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 +#endif + +#ifndef GLX_OML_swap_method +#define GLX_SWAP_METHOD_OML 0x8060 +#define GLX_SWAP_EXCHANGE_OML 0x8061 +#define GLX_SWAP_COPY_OML 0x8062 +#define GLX_SWAP_UNDEFINED_OML 0x8063 +#endif + +#ifndef GLX_OML_sync_control +#endif + +#ifndef GLX_NV_float_buffer +#define GLX_FLOAT_COMPONENTS_NV 0x20B0 +#endif + +#ifndef GLX_SGIX_hyperpipe +#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80 +#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91 +#define GLX_BAD_HYPERPIPE_SGIX 92 +#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001 +#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002 +#define GLX_PIPE_RECT_SGIX 0x00000001 +#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002 +#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003 +#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004 +#define GLX_HYPERPIPE_ID_SGIX 0x8030 +#endif + +#ifndef GLX_MESA_agp_offset +#endif + + +/*************************************************************/ + +#ifndef GLX_ARB_get_proc_address +typedef void (*__GLXextFuncPtr)(void); +#endif + +#ifndef GLX_SGIX_video_source +typedef XID GLXVideoSourceSGIX; +#endif + +#ifndef GLX_SGIX_fbconfig +typedef XID GLXFBConfigIDSGIX; +typedef struct __GLXFBConfigRec *GLXFBConfigSGIX; +#endif + +#ifndef GLX_SGIX_pbuffer +typedef XID GLXPbufferSGIX; +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came for SendEvent request */ + Display *display; /* display the event was read from */ + GLXDrawable drawable; /* i.d. of Drawable */ + int event_type; /* GLX_DAMAGED_SGIX or GLX_SAVED_SGIX */ + int draw_type; /* GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX */ + unsigned int mask; /* mask indicating which buffers are affected*/ + int x, y; + int width, height; + int count; /* if nonzero, at least this many more */ +} GLXBufferClobberEventSGIX; +#endif + +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GLX_OML_sync_control extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) +#include +#if defined(__STDC__) +#if defined(__arch64__) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(WIN32) && defined(__GNUC__) +#include +#elif defined(WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +#include /* Fallback option */ +#endif +#endif + +#ifndef GLX_VERSION_1_3 +#define GLX_VERSION_1_3 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern GLXFBConfig * glXGetFBConfigs (Display *, int, int *); +extern GLXFBConfig * glXChooseFBConfig (Display *, int, const int *, int *); +extern int glXGetFBConfigAttrib (Display *, GLXFBConfig, int, int *); +extern XVisualInfo * glXGetVisualFromFBConfig (Display *, GLXFBConfig); +extern GLXWindow glXCreateWindow (Display *, GLXFBConfig, Window, const int *); +extern void glXDestroyWindow (Display *, GLXWindow); +extern GLXPixmap glXCreatePixmap (Display *, GLXFBConfig, Pixmap, const int *); +extern void glXDestroyPixmap (Display *, GLXPixmap); +extern GLXPbuffer glXCreatePbuffer (Display *, GLXFBConfig, const int *); +extern void glXDestroyPbuffer (Display *, GLXPbuffer); +extern void glXQueryDrawable (Display *, GLXDrawable, int, unsigned int *); +extern GLXContext glXCreateNewContext (Display *, GLXFBConfig, int, GLXContext, Bool); +extern Bool glXMakeContextCurrent (Display *, GLXDrawable, GLXDrawable, GLXContext); +extern GLXDrawable glXGetCurrentReadDrawable (void); +extern Display * glXGetCurrentDisplay (void); +extern int glXQueryContext (Display *, GLXContext, int, int *); +extern void glXSelectEvent (Display *, GLXDrawable, unsigned long); +extern void glXGetSelectedEvent (Display *, GLXDrawable, unsigned long *); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef GLXFBConfig * ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements); +typedef GLXFBConfig * ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); +typedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value); +typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config); +typedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); +typedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win); +typedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); +typedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap); +typedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list); +typedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf); +typedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); +typedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); +typedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void); +typedef Display * ( * PFNGLXGETCURRENTDISPLAYPROC) (void); +typedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); +typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask); +typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask); +#endif + +#ifndef GLX_VERSION_1_4 +#define GLX_VERSION_1_4 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern __GLXextFuncPtr glXGetProcAddress (const GLubyte *); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); +#endif + +#ifndef GLX_ARB_get_proc_address +#define GLX_ARB_get_proc_address 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName); +#endif + +#ifndef GLX_ARB_multisample +#define GLX_ARB_multisample 1 +#endif + +#ifndef GLX_ARB_fbconfig_float +#define GLX_ARB_fbconfig_float 1 +#endif + +#ifndef GLX_SGIS_multisample +#define GLX_SGIS_multisample 1 +#endif + +#ifndef GLX_EXT_visual_info +#define GLX_EXT_visual_info 1 +#endif + +#ifndef GLX_SGI_swap_control +#define GLX_SGI_swap_control 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern int glXSwapIntervalSGI (int); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval); +#endif + +#ifndef GLX_SGI_video_sync +#define GLX_SGI_video_sync 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern int glXGetVideoSyncSGI (unsigned int *); +extern int glXWaitVideoSyncSGI (int, int, unsigned int *); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count); +typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count); +#endif + +#ifndef GLX_SGI_make_current_read +#define GLX_SGI_make_current_read 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern Bool glXMakeCurrentReadSGI (Display *, GLXDrawable, GLXDrawable, GLXContext); +extern GLXDrawable glXGetCurrentReadDrawableSGI (void); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void); +#endif + +#ifndef GLX_SGIX_video_source +#define GLX_SGIX_video_source 1 +#ifdef _VL_H +#ifdef GLX_GLXEXT_PROTOTYPES +extern GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *, int, VLServer, VLPath, int, VLNode); +extern void glXDestroyGLXVideoSourceSGIX (Display *, GLXVideoSourceSGIX); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef GLXVideoSourceSGIX ( * PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode); +typedef void ( * PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource); +#endif /* _VL_H */ +#endif + +#ifndef GLX_EXT_visual_rating +#define GLX_EXT_visual_rating 1 +#endif + +#ifndef GLX_EXT_import_context +#define GLX_EXT_import_context 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern Display * glXGetCurrentDisplayEXT (void); +extern int glXQueryContextInfoEXT (Display *, GLXContext, int, int *); +extern GLXContextID glXGetContextIDEXT (const GLXContext); +extern GLXContext glXImportContextEXT (Display *, GLXContextID); +extern void glXFreeContextEXT (Display *, GLXContext); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef Display * ( * PFNGLXGETCURRENTDISPLAYEXTPROC) (void); +typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value); +typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context); +typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID); +typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context); +#endif + +#ifndef GLX_SGIX_fbconfig +#define GLX_SGIX_fbconfig 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern int glXGetFBConfigAttribSGIX (Display *, GLXFBConfigSGIX, int, int *); +extern GLXFBConfigSGIX * glXChooseFBConfigSGIX (Display *, int, int *, int *); +extern GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *, GLXFBConfigSGIX, Pixmap); +extern GLXContext glXCreateContextWithConfigSGIX (Display *, GLXFBConfigSGIX, int, GLXContext, Bool); +extern XVisualInfo * glXGetVisualFromFBConfigSGIX (Display *, GLXFBConfigSGIX); +extern GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *, XVisualInfo *); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value); +typedef GLXFBConfigSGIX * ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements); +typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap); +typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct); +typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config); +typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis); +#endif + +#ifndef GLX_SGIX_pbuffer +#define GLX_SGIX_pbuffer 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *, GLXFBConfigSGIX, unsigned int, unsigned int, int *); +extern void glXDestroyGLXPbufferSGIX (Display *, GLXPbufferSGIX); +extern int glXQueryGLXPbufferSGIX (Display *, GLXPbufferSGIX, int, unsigned int *); +extern void glXSelectEventSGIX (Display *, GLXDrawable, unsigned long); +extern void glXGetSelectedEventSGIX (Display *, GLXDrawable, unsigned long *); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef GLXPbufferSGIX ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list); +typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf); +typedef int ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); +typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask); +typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask); +#endif + +#ifndef GLX_SGI_cushion +#define GLX_SGI_cushion 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern void glXCushionSGI (Display *, Window, float); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef void ( * PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion); +#endif + +#ifndef GLX_SGIX_video_resize +#define GLX_SGIX_video_resize 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern int glXBindChannelToWindowSGIX (Display *, int, int, Window); +extern int glXChannelRectSGIX (Display *, int, int, int, int, int, int); +extern int glXQueryChannelRectSGIX (Display *, int, int, int *, int *, int *, int *); +extern int glXQueryChannelDeltasSGIX (Display *, int, int, int *, int *, int *, int *); +extern int glXChannelRectSyncSGIX (Display *, int, int, GLenum); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window); +typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h); +typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); +typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h); +typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype); +#endif + +#ifndef GLX_SGIX_dmbuffer +#define GLX_SGIX_dmbuffer 1 +#ifdef _DM_BUFFER_H_ +#ifdef GLX_GLXEXT_PROTOTYPES +extern Bool glXAssociateDMPbufferSGIX (Display *, GLXPbufferSGIX, DMparams *, DMbuffer); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef Bool ( * PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer); +#endif /* _DM_BUFFER_H_ */ +#endif + +#ifndef GLX_SGIX_swap_group +#define GLX_SGIX_swap_group 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern void glXJoinSwapGroupSGIX (Display *, GLXDrawable, GLXDrawable); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member); +#endif + +#ifndef GLX_SGIX_swap_barrier +#define GLX_SGIX_swap_barrier 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern void glXBindSwapBarrierSGIX (Display *, GLXDrawable, int); +extern Bool glXQueryMaxSwapBarriersSGIX (Display *, int, int *); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier); +typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max); +#endif + +#ifndef GLX_SUN_get_transparent_index +#define GLX_SUN_get_transparent_index 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern Status glXGetTransparentIndexSUN (Display *, Window, Window, long *); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex); +#endif + +#ifndef GLX_MESA_copy_sub_buffer +#define GLX_MESA_copy_sub_buffer 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern void glXCopySubBufferMESA (Display *, GLXDrawable, int, int, int, int); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height); +#endif + +#ifndef GLX_MESA_pixmap_colormap +#define GLX_MESA_pixmap_colormap 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern GLXPixmap glXCreateGLXPixmapMESA (Display *, XVisualInfo *, Pixmap, Colormap); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); +#endif + +#ifndef GLX_MESA_release_buffers +#define GLX_MESA_release_buffers 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern Bool glXReleaseBuffersMESA (Display *, GLXDrawable); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable); +#endif + +#ifndef GLX_MESA_set_3dfx_mode +#define GLX_MESA_set_3dfx_mode 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern Bool glXSet3DfxModeMESA (int); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef Bool ( * PFNGLXSET3DFXMODEMESAPROC) (int mode); +#endif + +#ifndef GLX_SGIX_visual_select_group +#define GLX_SGIX_visual_select_group 1 +#endif + +#ifndef GLX_OML_swap_method +#define GLX_OML_swap_method 1 +#endif + +#ifndef GLX_OML_sync_control +#define GLX_OML_sync_control 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern Bool glXGetSyncValuesOML (Display *, GLXDrawable, int64_t *, int64_t *, int64_t *); +extern Bool glXGetMscRateOML (Display *, GLXDrawable, int32_t *, int32_t *); +extern int64_t glXSwapBuffersMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t); +extern Bool glXWaitForMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t, int64_t *, int64_t *, int64_t *); +extern Bool glXWaitForSbcOML (Display *, GLXDrawable, int64_t, int64_t *, int64_t *, int64_t *); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc); +typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator); +typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); +typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc); +typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc); +#endif + +#ifndef GLX_NV_float_buffer +#define GLX_NV_float_buffer 1 +#endif + +#ifndef GLX_SGIX_hyperpipe +#define GLX_SGIX_hyperpipe 1 + +typedef struct { + char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; + int networkId; +} GLXHyperpipeNetworkSGIX; + +typedef struct { + char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; + int channel; + unsigned int + participationType; + int timeSlice; +} GLXHyperpipeConfigSGIX; + +typedef struct { + char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; + int srcXOrigin, srcYOrigin, srcWidth, srcHeight; + int destXOrigin, destYOrigin, destWidth, destHeight; +} GLXPipeRect; + +typedef struct { + char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; + int XOrigin, YOrigin, maxHeight, maxWidth; +} GLXPipeRectLimits; + +#ifdef GLX_GLXEXT_PROTOTYPES +extern GLXHyperpipeNetworkSGIX * glXQueryHyperpipeNetworkSGIX (Display *, int *); +extern int glXHyperpipeConfigSGIX (Display *, int, int, GLXHyperpipeConfigSGIX *, int *); +extern GLXHyperpipeConfigSGIX * glXQueryHyperpipeConfigSGIX (Display *, int, int *); +extern int glXDestroyHyperpipeConfigSGIX (Display *, int); +extern int glXBindHyperpipeSGIX (Display *, int); +extern int glXQueryHyperpipeBestAttribSGIX (Display *, int, int, int, void *, void *); +extern int glXHyperpipeAttribSGIX (Display *, int, int, int, void *); +extern int glXQueryHyperpipeAttribSGIX (Display *, int, int, int, void *); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes); +typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); +typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes); +typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId); +typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId); +typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); +typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList); +typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); +#endif + +#ifndef GLX_MESA_agp_offset +#define GLX_MESA_agp_offset 1 +#ifdef GLX_GLXEXT_PROTOTYPES +extern unsigned int glXGetAGPOffsetMESA (const void *); +#endif /* GLX_GLXEXT_PROTOTYPES */ +typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void *pointer); +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dep/src/irrlicht/irrXML.cpp b/src/dep/src/irrlicht/irrXML.cpp index e0d5eb6..c99c78c 100644 --- a/src/dep/src/irrlicht/irrXML.cpp +++ b/src/dep/src/irrlicht/irrXML.cpp @@ -1,147 +1,147 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h - -#include "irrXML.h" -#include "irrString.h" -#include "irrArray.h" -#include "fast_atof.h" -#include "CXMLReaderImpl.h" - -namespace irr -{ -namespace io -{ - -//! Implementation of the file read callback for ordinary files -class CFileReadCallBack : public IFileReadCallBack -{ -public: - - //! construct from filename - CFileReadCallBack(const char* filename) - : File(0), Size(0), Close(true) - { - // open file - File = fopen(filename, "rb"); - - if (File) - getFileSize(); - } - - //! construct from FILE pointer - CFileReadCallBack(FILE* file) - : File(file), Size(0), Close(false) - { - if (File) - getFileSize(); - } - - //! destructor - virtual ~CFileReadCallBack() - { - if (Close && File) - fclose(File); - } - - //! Reads an amount of bytes from the file. - virtual int read(void* buffer, int sizeToRead) - { - if (!File) - return 0; - - return (int)fread(buffer, 1, sizeToRead, File); - } - - //! Returns size of file in bytes - virtual int getSize() - { - return Size; - } - -private: - - //! retrieves the file size of the open file - void getFileSize() - { - fseek(File, 0, SEEK_END); - Size = ftell(File); - fseek(File, 0, SEEK_SET); - } - - FILE* File; - int Size; - bool Close; - -}; // end class CFileReadCallBack - - - -// FACTORY FUNCTIONS: - - -//! Creates an instance of an UFT-8 or ASCII character xml parser. -IrrXMLReader* createIrrXMLReader(const char* filename) -{ - return new CXMLReaderImpl(new CFileReadCallBack(filename)); -} - - -//! Creates an instance of an UFT-8 or ASCII character xml parser. -IrrXMLReader* createIrrXMLReader(FILE* file) -{ - return new CXMLReaderImpl(new CFileReadCallBack(file)); -} - - -//! Creates an instance of an UFT-8 or ASCII character xml parser. -IrrXMLReader* createIrrXMLReader(IFileReadCallBack* callback) -{ - return new CXMLReaderImpl(callback, false); -} - - -//! Creates an instance of an UTF-16 xml parser. -IrrXMLReaderUTF16* createIrrXMLReaderUTF16(const char* filename) -{ - return new CXMLReaderImpl(new CFileReadCallBack(filename)); -} - - -//! Creates an instance of an UTF-16 xml parser. -IrrXMLReaderUTF16* createIrrXMLReaderUTF16(FILE* file) -{ - return new CXMLReaderImpl(new CFileReadCallBack(file)); -} - - -//! Creates an instance of an UTF-16 xml parser. -IrrXMLReaderUTF16* createIrrXMLReaderUTF16(IFileReadCallBack* callback) -{ - return new CXMLReaderImpl(callback, false); -} - - -//! Creates an instance of an UTF-32 xml parser. -IrrXMLReaderUTF32* createIrrXMLReaderUTF32(const char* filename) -{ - return new CXMLReaderImpl(new CFileReadCallBack(filename)); -} - - -//! Creates an instance of an UTF-32 xml parser. -IrrXMLReaderUTF32* createIrrXMLReaderUTF32(FILE* file) -{ - return new CXMLReaderImpl(new CFileReadCallBack(file)); -} - - -//! Creates an instance of an UTF-32 xml parser. -IrrXMLReaderUTF32* createIrrXMLReaderUTF32(IFileReadCallBack* callback) -{ - return new CXMLReaderImpl(callback, false); -} - - -} // end namespace io -} // end namespace irr +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine" and the "irrXML" project. +// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h + +#include "irrXML.h" +#include "irrString.h" +#include "irrArray.h" +#include "fast_atof.h" +#include "CXMLReaderImpl.h" + +namespace irr +{ +namespace io +{ + +//! Implementation of the file read callback for ordinary files +class CFileReadCallBack : public IFileReadCallBack +{ +public: + + //! construct from filename + CFileReadCallBack(const char* filename) + : File(0), Size(0), Close(true) + { + // open file + File = fopen(filename, "rb"); + + if (File) + getFileSize(); + } + + //! construct from FILE pointer + CFileReadCallBack(FILE* file) + : File(file), Size(0), Close(false) + { + if (File) + getFileSize(); + } + + //! destructor + virtual ~CFileReadCallBack() + { + if (Close && File) + fclose(File); + } + + //! Reads an amount of bytes from the file. + virtual int read(void* buffer, int sizeToRead) + { + if (!File) + return 0; + + return (int)fread(buffer, 1, sizeToRead, File); + } + + //! Returns size of file in bytes + virtual int getSize() + { + return Size; + } + +private: + + //! retrieves the file size of the open file + void getFileSize() + { + fseek(File, 0, SEEK_END); + Size = ftell(File); + fseek(File, 0, SEEK_SET); + } + + FILE* File; + int Size; + bool Close; + +}; // end class CFileReadCallBack + + + +// FACTORY FUNCTIONS: + + +//! Creates an instance of an UFT-8 or ASCII character xml parser. +IrrXMLReader* createIrrXMLReader(const char* filename) +{ + return new CXMLReaderImpl(new CFileReadCallBack(filename)); +} + + +//! Creates an instance of an UFT-8 or ASCII character xml parser. +IrrXMLReader* createIrrXMLReader(FILE* file) +{ + return new CXMLReaderImpl(new CFileReadCallBack(file)); +} + + +//! Creates an instance of an UFT-8 or ASCII character xml parser. +IrrXMLReader* createIrrXMLReader(IFileReadCallBack* callback) +{ + return new CXMLReaderImpl(callback, false); +} + + +//! Creates an instance of an UTF-16 xml parser. +IrrXMLReaderUTF16* createIrrXMLReaderUTF16(const char* filename) +{ + return new CXMLReaderImpl(new CFileReadCallBack(filename)); +} + + +//! Creates an instance of an UTF-16 xml parser. +IrrXMLReaderUTF16* createIrrXMLReaderUTF16(FILE* file) +{ + return new CXMLReaderImpl(new CFileReadCallBack(file)); +} + + +//! Creates an instance of an UTF-16 xml parser. +IrrXMLReaderUTF16* createIrrXMLReaderUTF16(IFileReadCallBack* callback) +{ + return new CXMLReaderImpl(callback, false); +} + + +//! Creates an instance of an UTF-32 xml parser. +IrrXMLReaderUTF32* createIrrXMLReaderUTF32(const char* filename) +{ + return new CXMLReaderImpl(new CFileReadCallBack(filename)); +} + + +//! Creates an instance of an UTF-32 xml parser. +IrrXMLReaderUTF32* createIrrXMLReaderUTF32(FILE* file) +{ + return new CXMLReaderImpl(new CFileReadCallBack(file)); +} + + +//! Creates an instance of an UTF-32 xml parser. +IrrXMLReaderUTF32* createIrrXMLReaderUTF32(IFileReadCallBack* callback) +{ + return new CXMLReaderImpl(callback, false); +} + + +} // end namespace io +} // end namespace irr diff --git a/src/dep/src/irrlicht/jpeglib/README b/src/dep/src/irrlicht/jpeglib/README index 911d0e8..86cc206 100644 --- a/src/dep/src/irrlicht/jpeglib/README +++ b/src/dep/src/irrlicht/jpeglib/README @@ -1,385 +1,385 @@ -The Independent JPEG Group's JPEG software -========================================== - -README for release 6b of 27-Mar-1998 -==================================== - -This distribution contains the sixth public release of the Independent JPEG -Group's free JPEG software. You are welcome to redistribute this software and -to use it for any purpose, subject to the conditions under LEGAL ISSUES, below. - -Serious users of this software (particularly those incorporating it into -larger programs) should contact IJG at jpeg-info@uunet.uu.net to be added to -our electronic mailing list. Mailing list members are notified of updates -and have a chance to participate in technical discussions, etc. - -This software is the work of Tom Lane, Philip Gladstone, Jim Boucher, -Lee Crocker, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, -Guido Vollbeding, Ge' Weijers, and other members of the Independent JPEG -Group. - -IJG is not affiliated with the official ISO JPEG standards committee. - - -DOCUMENTATION ROADMAP -===================== - -This file contains the following sections: - -OVERVIEW General description of JPEG and the IJG software. -LEGAL ISSUES Copyright, lack of warranty, terms of distribution. -REFERENCES Where to learn more about JPEG. -ARCHIVE LOCATIONS Where to find newer versions of this software. -RELATED SOFTWARE Other stuff you should get. -FILE FORMAT WARS Software *not* to get. -TO DO Plans for future IJG releases. - -Other documentation files in the distribution are: - -User documentation: - install.doc How to configure and install the IJG software. - usage.doc Usage instructions for cjpeg, djpeg, jpegtran, - rdjpgcom, and wrjpgcom. - *.1 Unix-style man pages for programs (same info as usage.doc). - wizard.doc Advanced usage instructions for JPEG wizards only. - change.log Version-to-version change highlights. -Programmer and internal documentation: - libjpeg.doc How to use the JPEG library in your own programs. - example.c Sample code for calling the JPEG library. - structure.doc Overview of the JPEG library's internal structure. - filelist.doc Road map of IJG files. - coderules.doc Coding style rules --- please read if you contribute code. - -Please read at least the files install.doc and usage.doc. Useful information -can also be found in the JPEG FAQ (Frequently Asked Questions) article. See -ARCHIVE LOCATIONS below to find out where to obtain the FAQ article. - -If you want to understand how the JPEG code works, we suggest reading one or -more of the REFERENCES, then looking at the documentation files (in roughly -the order listed) before diving into the code. - - -OVERVIEW -======== - -This package contains C software to implement JPEG image compression and -decompression. JPEG (pronounced "jay-peg") is a standardized compression -method for full-color and gray-scale images. JPEG is intended for compressing -"real-world" scenes; line drawings, cartoons and other non-realistic images -are not its strong suit. JPEG is lossy, meaning that the output image is not -exactly identical to the input image. Hence you must not use JPEG if you -have to have identical output bits. However, on typical photographic images, -very good compression levels can be obtained with no visible change, and -remarkably high compression levels are possible if you can tolerate a -low-quality image. For more details, see the references, or just experiment -with various compression settings. - -This software implements JPEG baseline, extended-sequential, and progressive -compression processes. Provision is made for supporting all variants of these -processes, although some uncommon parameter settings aren't implemented yet. -For legal reasons, we are not distributing code for the arithmetic-coding -variants of JPEG; see LEGAL ISSUES. We have made no provision for supporting -the hierarchical or lossless processes defined in the standard. - -We provide a set of library routines for reading and writing JPEG image files, -plus two sample applications "cjpeg" and "djpeg", which use the library to -perform conversion between JPEG and some other popular image file formats. -The library is intended to be reused in other applications. - -In order to support file conversion and viewing software, we have included -considerable functionality beyond the bare JPEG coding/decoding capability; -for example, the color quantization modules are not strictly part of JPEG -decoding, but they are essential for output to colormapped file formats or -colormapped displays. These extra functions can be compiled out of the -library if not required for a particular application. We have also included -"jpegtran", a utility for lossless transcoding between different JPEG -processes, and "rdjpgcom" and "wrjpgcom", two simple applications for -inserting and extracting textual comments in JFIF files. - -The emphasis in designing this software has been on achieving portability and -flexibility, while also making it fast enough to be useful. In particular, -the software is not intended to be read as a tutorial on JPEG. (See the -REFERENCES section for introductory material.) Rather, it is intended to -be reliable, portable, industrial-strength code. We do not claim to have -achieved that goal in every aspect of the software, but we strive for it. - -We welcome the use of this software as a component of commercial products. -No royalty is required, but we do ask for an acknowledgement in product -documentation, as described under LEGAL ISSUES. - - -LEGAL ISSUES -============ - -In plain English: - -1. We don't promise that this software works. (But if you find any bugs, - please let us know!) -2. You can use this software for whatever you want. You don't have to pay us. -3. You may not pretend that you wrote this software. If you use it in a - program, you must acknowledge somewhere in your documentation that - you've used the IJG code. - -In legalese: - -The authors make NO WARRANTY or representation, either express or implied, -with respect to this software, its quality, accuracy, merchantability, or -fitness for a particular purpose. This software is provided "AS IS", and you, -its user, assume the entire risk as to its quality and accuracy. - -This software is copyright (C) 1991-1998, Thomas G. Lane. -All Rights Reserved except as specified below. - -Permission is hereby granted to use, copy, modify, and distribute this -software (or portions thereof) for any purpose, without fee, subject to these -conditions: -(1) If any part of the source code for this software is distributed, then this -README file must be included, with this copyright and no-warranty notice -unaltered; and any additions, deletions, or changes to the original files -must be clearly indicated in accompanying documentation. -(2) If only executable code is distributed, then the accompanying -documentation must state that "this software is based in part on the work of -the Independent JPEG Group". -(3) Permission for use of this software is granted only if the user accepts -full responsibility for any undesirable consequences; the authors accept -NO LIABILITY for damages of any kind. - -These conditions apply to any software derived from or based on the IJG code, -not just to the unmodified library. If you use our work, you ought to -acknowledge us. - -Permission is NOT granted for the use of any IJG author's name or company name -in advertising or publicity relating to this software or products derived from -it. This software may be referred to only as "the Independent JPEG Group's -software". - -We specifically permit and encourage the use of this software as the basis of -commercial products, provided that all warranty or liability claims are -assumed by the product vendor. - - -ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, -sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA. -ansi2knr.c is NOT covered by the above copyright and conditions, but instead -by the usual distribution terms of the Free Software Foundation; principally, -that you must include source code if you redistribute it. (See the file -ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part -of any program generated from the IJG code, this does not limit you more than -the foregoing paragraphs do. - -The Unix configuration script "configure" was produced with GNU Autoconf. -It is copyright by the Free Software Foundation but is freely distributable. -The same holds for its supporting scripts (config.guess, config.sub, -ltconfig, ltmain.sh). Another support script, install-sh, is copyright -by M.I.T. but is also freely distributable. - -It appears that the arithmetic coding option of the JPEG spec is covered by -patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot -legally be used without obtaining one or more licenses. For this reason, -support for arithmetic coding has been removed from the free JPEG software. -(Since arithmetic coding provides only a marginal gain over the unpatented -Huffman mode, it is unlikely that very many implementations will support it.) -So far as we are aware, there are no patent restrictions on the remaining -code. - -The IJG distribution formerly included code to read and write GIF files. -To avoid entanglement with the Unisys LZW patent, GIF reading support has -been removed altogether, and the GIF writer has been simplified to produce -"uncompressed GIFs". This technique does not use the LZW algorithm; the -resulting GIF files are larger than usual, but are readable by all standard -GIF decoders. - -We are required to state that - "The Graphics Interchange Format(c) is the Copyright property of - CompuServe Incorporated. GIF(sm) is a Service Mark property of - CompuServe Incorporated." - - -REFERENCES -========== - -We highly recommend reading one or more of these references before trying to -understand the innards of the JPEG software. - -The best short technical introduction to the JPEG compression algorithm is - Wallace, Gregory K. "The JPEG Still Picture Compression Standard", - Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44. -(Adjacent articles in that issue discuss MPEG motion picture compression, -applications of JPEG, and related topics.) If you don't have the CACM issue -handy, a PostScript file containing a revised version of Wallace's article is -available at ftp://ftp.uu.net/graphics/jpeg/wallace.ps.gz. The file (actually -a preprint for an article that appeared in IEEE Trans. Consumer Electronics) -omits the sample images that appeared in CACM, but it includes corrections -and some added material. Note: the Wallace article is copyright ACM and IEEE, -and it may not be used for commercial purposes. - -A somewhat less technical, more leisurely introduction to JPEG can be found in -"The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by -M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides -good explanations and example C code for a multitude of compression methods -including JPEG. It is an excellent source if you are comfortable reading C -code but don't know much about data compression in general. The book's JPEG -sample code is far from industrial-strength, but when you are ready to look -at a full implementation, you've got one here... - -The best full description of JPEG is the textbook "JPEG Still Image Data -Compression Standard" by William B. Pennebaker and Joan L. Mitchell, published -by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. Price US$59.95, 638 pp. -The book includes the complete text of the ISO JPEG standards (DIS 10918-1 -and draft DIS 10918-2). This is by far the most complete exposition of JPEG -in existence, and we highly recommend it. - -The JPEG standard itself is not available electronically; you must order a -paper copy through ISO or ITU. (Unless you feel a need to own a certified -official copy, we recommend buying the Pennebaker and Mitchell book instead; -it's much cheaper and includes a great deal of useful explanatory material.) -In the USA, copies of the standard may be ordered from ANSI Sales at (212) -642-4900, or from Global Engineering Documents at (800) 854-7179. (ANSI -doesn't take credit card orders, but Global does.) It's not cheap: as of -1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7% -shipping/handling. The standard is divided into two parts, Part 1 being the -actual specification, while Part 2 covers compliance testing methods. Part 1 -is titled "Digital Compression and Coding of Continuous-tone Still Images, -Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS -10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of -Continuous-tone Still Images, Part 2: Compliance testing" and has document -numbers ISO/IEC IS 10918-2, ITU-T T.83. - -Some extensions to the original JPEG standard are defined in JPEG Part 3, -a newer ISO standard numbered ISO/IEC IS 10918-3 and ITU-T T.84. IJG -currently does not support any Part 3 extensions. - -The JPEG standard does not specify all details of an interchangeable file -format. For the omitted details we follow the "JFIF" conventions, revision -1.02. A copy of the JFIF spec is available from: - Literature Department - C-Cube Microsystems, Inc. - 1778 McCarthy Blvd. - Milpitas, CA 95035 - phone (408) 944-6300, fax (408) 944-6314 -A PostScript version of this document is available by FTP at -ftp://ftp.uu.net/graphics/jpeg/jfif.ps.gz. There is also a plain text -version at ftp://ftp.uu.net/graphics/jpeg/jfif.txt.gz, but it is missing -the figures. - -The TIFF 6.0 file format specification can be obtained by FTP from -ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme -found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems. -IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6). -Instead, we recommend the JPEG design proposed by TIFF Technical Note #2 -(Compression tag 7). Copies of this Note can be obtained from ftp.sgi.com or -from ftp://ftp.uu.net/graphics/jpeg/. It is expected that the next revision -of the TIFF spec will replace the 6.0 JPEG design with the Note's design. -Although IJG's own code does not support TIFF/JPEG, the free libtiff library -uses our library to implement TIFF/JPEG per the Note. libtiff is available -from ftp://ftp.sgi.com/graphics/tiff/. - - -ARCHIVE LOCATIONS -================= - -The "official" archive site for this software is ftp.uu.net (Internet -address 192.48.96.9). The most recent released version can always be found -there in directory graphics/jpeg. This particular version will be archived -as ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz. If you don't have -direct Internet access, UUNET's archives are also available via UUCP; contact -help@uunet.uu.net for information on retrieving files that way. - -Numerous Internet sites maintain copies of the UUNET files. However, only -ftp.uu.net is guaranteed to have the latest official version. - -You can also obtain this software in DOS-compatible "zip" archive format from -the SimTel archives (ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/), or -on CompuServe in the Graphics Support forum (GO CIS:GRAPHSUP), library 12 -"JPEG Tools". Again, these versions may sometimes lag behind the ftp.uu.net -release. - -The JPEG FAQ (Frequently Asked Questions) article is a useful source of -general information about JPEG. It is updated constantly and therefore is -not included in this distribution. The FAQ is posted every two weeks to -Usenet newsgroups comp.graphics.misc, news.answers, and other groups. -It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/ -and other news.answers archive sites, including the official news.answers -archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/. -If you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu -with body - send usenet/news.answers/jpeg-faq/part1 - send usenet/news.answers/jpeg-faq/part2 - - -RELATED SOFTWARE -================ - -Numerous viewing and image manipulation programs now support JPEG. (Quite a -few of them use this library to do so.) The JPEG FAQ described above lists -some of the more popular free and shareware viewers, and tells where to -obtain them on Internet. - -If you are on a Unix machine, we highly recommend Jef Poskanzer's free -PBMPLUS software, which provides many useful operations on PPM-format image -files. In particular, it can convert PPM images to and from a wide range of -other formats, thus making cjpeg/djpeg considerably more useful. The latest -version is distributed by the NetPBM group, and is available from numerous -sites, notably ftp://wuarchive.wustl.edu/graphics/graphics/packages/NetPBM/. -Unfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software is; -you are likely to have difficulty making it work on any non-Unix machine. - -A different free JPEG implementation, written by the PVRG group at Stanford, -is available from ftp://havefun.stanford.edu/pub/jpeg/. This program -is designed for research and experimentation rather than production use; -it is slower, harder to use, and less portable than the IJG code, but it -is easier to read and modify. Also, the PVRG code supports lossless JPEG, -which we do not. (On the other hand, it doesn't do progressive JPEG.) - - -FILE FORMAT WARS -================ - -Some JPEG programs produce files that are not compatible with our library. -The root of the problem is that the ISO JPEG committee failed to specify a -concrete file format. Some vendors "filled in the blanks" on their own, -creating proprietary formats that no one else could read. (For example, none -of the early commercial JPEG implementations for the Macintosh were able to -exchange compressed files.) - -The file format we have adopted is called JFIF (see REFERENCES). This format -has been agreed to by a number of major commercial JPEG vendors, and it has -become the de facto standard. JFIF is a minimal or "low end" representation. -We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF -Technical Note #2) for "high end" applications that need to record a lot of -additional data about an image. TIFF/JPEG is fairly new and not yet widely -supported, unfortunately. - -The upcoming JPEG Part 3 standard defines a file format called SPIFF. -SPIFF is interoperable with JFIF, in the sense that most JFIF decoders should -be able to read the most common variant of SPIFF. SPIFF has some technical -advantages over JFIF, but its major claim to fame is simply that it is an -official standard rather than an informal one. At this point it is unclear -whether SPIFF will supersede JFIF or whether JFIF will remain the de-facto -standard. IJG intends to support SPIFF once the standard is frozen, but we -have not decided whether it should become our default output format or not. -(In any case, our decoder will remain capable of reading JFIF indefinitely.) - -Various proprietary file formats incorporating JPEG compression also exist. -We have little or no sympathy for the existence of these formats. Indeed, -one of the original reasons for developing this free software was to help -force convergence on common, open format standards for JPEG files. Don't -use a proprietary file format! - - -TO DO -===== - -The major thrust for v7 will probably be improvement of visual quality. -The current method for scaling the quantization tables is known not to be -very good at low Q values. We also intend to investigate block boundary -smoothing, "poor man's variable quantization", and other means of improving -quality-vs-file-size performance without sacrificing compatibility. - -In future versions, we are considering supporting some of the upcoming JPEG -Part 3 extensions --- principally, variable quantization and the SPIFF file -format. - -As always, speeding things up is of great interest. - -Please send bug reports, offers of help, etc. to jpeg-info@uunet.uu.net. +The Independent JPEG Group's JPEG software +========================================== + +README for release 6b of 27-Mar-1998 +==================================== + +This distribution contains the sixth public release of the Independent JPEG +Group's free JPEG software. You are welcome to redistribute this software and +to use it for any purpose, subject to the conditions under LEGAL ISSUES, below. + +Serious users of this software (particularly those incorporating it into +larger programs) should contact IJG at jpeg-info@uunet.uu.net to be added to +our electronic mailing list. Mailing list members are notified of updates +and have a chance to participate in technical discussions, etc. + +This software is the work of Tom Lane, Philip Gladstone, Jim Boucher, +Lee Crocker, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, +Guido Vollbeding, Ge' Weijers, and other members of the Independent JPEG +Group. + +IJG is not affiliated with the official ISO JPEG standards committee. + + +DOCUMENTATION ROADMAP +===================== + +This file contains the following sections: + +OVERVIEW General description of JPEG and the IJG software. +LEGAL ISSUES Copyright, lack of warranty, terms of distribution. +REFERENCES Where to learn more about JPEG. +ARCHIVE LOCATIONS Where to find newer versions of this software. +RELATED SOFTWARE Other stuff you should get. +FILE FORMAT WARS Software *not* to get. +TO DO Plans for future IJG releases. + +Other documentation files in the distribution are: + +User documentation: + install.doc How to configure and install the IJG software. + usage.doc Usage instructions for cjpeg, djpeg, jpegtran, + rdjpgcom, and wrjpgcom. + *.1 Unix-style man pages for programs (same info as usage.doc). + wizard.doc Advanced usage instructions for JPEG wizards only. + change.log Version-to-version change highlights. +Programmer and internal documentation: + libjpeg.doc How to use the JPEG library in your own programs. + example.c Sample code for calling the JPEG library. + structure.doc Overview of the JPEG library's internal structure. + filelist.doc Road map of IJG files. + coderules.doc Coding style rules --- please read if you contribute code. + +Please read at least the files install.doc and usage.doc. Useful information +can also be found in the JPEG FAQ (Frequently Asked Questions) article. See +ARCHIVE LOCATIONS below to find out where to obtain the FAQ article. + +If you want to understand how the JPEG code works, we suggest reading one or +more of the REFERENCES, then looking at the documentation files (in roughly +the order listed) before diving into the code. + + +OVERVIEW +======== + +This package contains C software to implement JPEG image compression and +decompression. JPEG (pronounced "jay-peg") is a standardized compression +method for full-color and gray-scale images. JPEG is intended for compressing +"real-world" scenes; line drawings, cartoons and other non-realistic images +are not its strong suit. JPEG is lossy, meaning that the output image is not +exactly identical to the input image. Hence you must not use JPEG if you +have to have identical output bits. However, on typical photographic images, +very good compression levels can be obtained with no visible change, and +remarkably high compression levels are possible if you can tolerate a +low-quality image. For more details, see the references, or just experiment +with various compression settings. + +This software implements JPEG baseline, extended-sequential, and progressive +compression processes. Provision is made for supporting all variants of these +processes, although some uncommon parameter settings aren't implemented yet. +For legal reasons, we are not distributing code for the arithmetic-coding +variants of JPEG; see LEGAL ISSUES. We have made no provision for supporting +the hierarchical or lossless processes defined in the standard. + +We provide a set of library routines for reading and writing JPEG image files, +plus two sample applications "cjpeg" and "djpeg", which use the library to +perform conversion between JPEG and some other popular image file formats. +The library is intended to be reused in other applications. + +In order to support file conversion and viewing software, we have included +considerable functionality beyond the bare JPEG coding/decoding capability; +for example, the color quantization modules are not strictly part of JPEG +decoding, but they are essential for output to colormapped file formats or +colormapped displays. These extra functions can be compiled out of the +library if not required for a particular application. We have also included +"jpegtran", a utility for lossless transcoding between different JPEG +processes, and "rdjpgcom" and "wrjpgcom", two simple applications for +inserting and extracting textual comments in JFIF files. + +The emphasis in designing this software has been on achieving portability and +flexibility, while also making it fast enough to be useful. In particular, +the software is not intended to be read as a tutorial on JPEG. (See the +REFERENCES section for introductory material.) Rather, it is intended to +be reliable, portable, industrial-strength code. We do not claim to have +achieved that goal in every aspect of the software, but we strive for it. + +We welcome the use of this software as a component of commercial products. +No royalty is required, but we do ask for an acknowledgement in product +documentation, as described under LEGAL ISSUES. + + +LEGAL ISSUES +============ + +In plain English: + +1. We don't promise that this software works. (But if you find any bugs, + please let us know!) +2. You can use this software for whatever you want. You don't have to pay us. +3. You may not pretend that you wrote this software. If you use it in a + program, you must acknowledge somewhere in your documentation that + you've used the IJG code. + +In legalese: + +The authors make NO WARRANTY or representation, either express or implied, +with respect to this software, its quality, accuracy, merchantability, or +fitness for a particular purpose. This software is provided "AS IS", and you, +its user, assume the entire risk as to its quality and accuracy. + +This software is copyright (C) 1991-1998, Thomas G. Lane. +All Rights Reserved except as specified below. + +Permission is hereby granted to use, copy, modify, and distribute this +software (or portions thereof) for any purpose, without fee, subject to these +conditions: +(1) If any part of the source code for this software is distributed, then this +README file must be included, with this copyright and no-warranty notice +unaltered; and any additions, deletions, or changes to the original files +must be clearly indicated in accompanying documentation. +(2) If only executable code is distributed, then the accompanying +documentation must state that "this software is based in part on the work of +the Independent JPEG Group". +(3) Permission for use of this software is granted only if the user accepts +full responsibility for any undesirable consequences; the authors accept +NO LIABILITY for damages of any kind. + +These conditions apply to any software derived from or based on the IJG code, +not just to the unmodified library. If you use our work, you ought to +acknowledge us. + +Permission is NOT granted for the use of any IJG author's name or company name +in advertising or publicity relating to this software or products derived from +it. This software may be referred to only as "the Independent JPEG Group's +software". + +We specifically permit and encourage the use of this software as the basis of +commercial products, provided that all warranty or liability claims are +assumed by the product vendor. + + +ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, +sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA. +ansi2knr.c is NOT covered by the above copyright and conditions, but instead +by the usual distribution terms of the Free Software Foundation; principally, +that you must include source code if you redistribute it. (See the file +ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part +of any program generated from the IJG code, this does not limit you more than +the foregoing paragraphs do. + +The Unix configuration script "configure" was produced with GNU Autoconf. +It is copyright by the Free Software Foundation but is freely distributable. +The same holds for its supporting scripts (config.guess, config.sub, +ltconfig, ltmain.sh). Another support script, install-sh, is copyright +by M.I.T. but is also freely distributable. + +It appears that the arithmetic coding option of the JPEG spec is covered by +patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot +legally be used without obtaining one or more licenses. For this reason, +support for arithmetic coding has been removed from the free JPEG software. +(Since arithmetic coding provides only a marginal gain over the unpatented +Huffman mode, it is unlikely that very many implementations will support it.) +So far as we are aware, there are no patent restrictions on the remaining +code. + +The IJG distribution formerly included code to read and write GIF files. +To avoid entanglement with the Unisys LZW patent, GIF reading support has +been removed altogether, and the GIF writer has been simplified to produce +"uncompressed GIFs". This technique does not use the LZW algorithm; the +resulting GIF files are larger than usual, but are readable by all standard +GIF decoders. + +We are required to state that + "The Graphics Interchange Format(c) is the Copyright property of + CompuServe Incorporated. GIF(sm) is a Service Mark property of + CompuServe Incorporated." + + +REFERENCES +========== + +We highly recommend reading one or more of these references before trying to +understand the innards of the JPEG software. + +The best short technical introduction to the JPEG compression algorithm is + Wallace, Gregory K. "The JPEG Still Picture Compression Standard", + Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44. +(Adjacent articles in that issue discuss MPEG motion picture compression, +applications of JPEG, and related topics.) If you don't have the CACM issue +handy, a PostScript file containing a revised version of Wallace's article is +available at ftp://ftp.uu.net/graphics/jpeg/wallace.ps.gz. The file (actually +a preprint for an article that appeared in IEEE Trans. Consumer Electronics) +omits the sample images that appeared in CACM, but it includes corrections +and some added material. Note: the Wallace article is copyright ACM and IEEE, +and it may not be used for commercial purposes. + +A somewhat less technical, more leisurely introduction to JPEG can be found in +"The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by +M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides +good explanations and example C code for a multitude of compression methods +including JPEG. It is an excellent source if you are comfortable reading C +code but don't know much about data compression in general. The book's JPEG +sample code is far from industrial-strength, but when you are ready to look +at a full implementation, you've got one here... + +The best full description of JPEG is the textbook "JPEG Still Image Data +Compression Standard" by William B. Pennebaker and Joan L. Mitchell, published +by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. Price US$59.95, 638 pp. +The book includes the complete text of the ISO JPEG standards (DIS 10918-1 +and draft DIS 10918-2). This is by far the most complete exposition of JPEG +in existence, and we highly recommend it. + +The JPEG standard itself is not available electronically; you must order a +paper copy through ISO or ITU. (Unless you feel a need to own a certified +official copy, we recommend buying the Pennebaker and Mitchell book instead; +it's much cheaper and includes a great deal of useful explanatory material.) +In the USA, copies of the standard may be ordered from ANSI Sales at (212) +642-4900, or from Global Engineering Documents at (800) 854-7179. (ANSI +doesn't take credit card orders, but Global does.) It's not cheap: as of +1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7% +shipping/handling. The standard is divided into two parts, Part 1 being the +actual specification, while Part 2 covers compliance testing methods. Part 1 +is titled "Digital Compression and Coding of Continuous-tone Still Images, +Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS +10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of +Continuous-tone Still Images, Part 2: Compliance testing" and has document +numbers ISO/IEC IS 10918-2, ITU-T T.83. + +Some extensions to the original JPEG standard are defined in JPEG Part 3, +a newer ISO standard numbered ISO/IEC IS 10918-3 and ITU-T T.84. IJG +currently does not support any Part 3 extensions. + +The JPEG standard does not specify all details of an interchangeable file +format. For the omitted details we follow the "JFIF" conventions, revision +1.02. A copy of the JFIF spec is available from: + Literature Department + C-Cube Microsystems, Inc. + 1778 McCarthy Blvd. + Milpitas, CA 95035 + phone (408) 944-6300, fax (408) 944-6314 +A PostScript version of this document is available by FTP at +ftp://ftp.uu.net/graphics/jpeg/jfif.ps.gz. There is also a plain text +version at ftp://ftp.uu.net/graphics/jpeg/jfif.txt.gz, but it is missing +the figures. + +The TIFF 6.0 file format specification can be obtained by FTP from +ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme +found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems. +IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6). +Instead, we recommend the JPEG design proposed by TIFF Technical Note #2 +(Compression tag 7). Copies of this Note can be obtained from ftp.sgi.com or +from ftp://ftp.uu.net/graphics/jpeg/. It is expected that the next revision +of the TIFF spec will replace the 6.0 JPEG design with the Note's design. +Although IJG's own code does not support TIFF/JPEG, the free libtiff library +uses our library to implement TIFF/JPEG per the Note. libtiff is available +from ftp://ftp.sgi.com/graphics/tiff/. + + +ARCHIVE LOCATIONS +================= + +The "official" archive site for this software is ftp.uu.net (Internet +address 192.48.96.9). The most recent released version can always be found +there in directory graphics/jpeg. This particular version will be archived +as ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz. If you don't have +direct Internet access, UUNET's archives are also available via UUCP; contact +help@uunet.uu.net for information on retrieving files that way. + +Numerous Internet sites maintain copies of the UUNET files. However, only +ftp.uu.net is guaranteed to have the latest official version. + +You can also obtain this software in DOS-compatible "zip" archive format from +the SimTel archives (ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/), or +on CompuServe in the Graphics Support forum (GO CIS:GRAPHSUP), library 12 +"JPEG Tools". Again, these versions may sometimes lag behind the ftp.uu.net +release. + +The JPEG FAQ (Frequently Asked Questions) article is a useful source of +general information about JPEG. It is updated constantly and therefore is +not included in this distribution. The FAQ is posted every two weeks to +Usenet newsgroups comp.graphics.misc, news.answers, and other groups. +It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/ +and other news.answers archive sites, including the official news.answers +archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/. +If you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu +with body + send usenet/news.answers/jpeg-faq/part1 + send usenet/news.answers/jpeg-faq/part2 + + +RELATED SOFTWARE +================ + +Numerous viewing and image manipulation programs now support JPEG. (Quite a +few of them use this library to do so.) The JPEG FAQ described above lists +some of the more popular free and shareware viewers, and tells where to +obtain them on Internet. + +If you are on a Unix machine, we highly recommend Jef Poskanzer's free +PBMPLUS software, which provides many useful operations on PPM-format image +files. In particular, it can convert PPM images to and from a wide range of +other formats, thus making cjpeg/djpeg considerably more useful. The latest +version is distributed by the NetPBM group, and is available from numerous +sites, notably ftp://wuarchive.wustl.edu/graphics/graphics/packages/NetPBM/. +Unfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software is; +you are likely to have difficulty making it work on any non-Unix machine. + +A different free JPEG implementation, written by the PVRG group at Stanford, +is available from ftp://havefun.stanford.edu/pub/jpeg/. This program +is designed for research and experimentation rather than production use; +it is slower, harder to use, and less portable than the IJG code, but it +is easier to read and modify. Also, the PVRG code supports lossless JPEG, +which we do not. (On the other hand, it doesn't do progressive JPEG.) + + +FILE FORMAT WARS +================ + +Some JPEG programs produce files that are not compatible with our library. +The root of the problem is that the ISO JPEG committee failed to specify a +concrete file format. Some vendors "filled in the blanks" on their own, +creating proprietary formats that no one else could read. (For example, none +of the early commercial JPEG implementations for the Macintosh were able to +exchange compressed files.) + +The file format we have adopted is called JFIF (see REFERENCES). This format +has been agreed to by a number of major commercial JPEG vendors, and it has +become the de facto standard. JFIF is a minimal or "low end" representation. +We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF +Technical Note #2) for "high end" applications that need to record a lot of +additional data about an image. TIFF/JPEG is fairly new and not yet widely +supported, unfortunately. + +The upcoming JPEG Part 3 standard defines a file format called SPIFF. +SPIFF is interoperable with JFIF, in the sense that most JFIF decoders should +be able to read the most common variant of SPIFF. SPIFF has some technical +advantages over JFIF, but its major claim to fame is simply that it is an +official standard rather than an informal one. At this point it is unclear +whether SPIFF will supersede JFIF or whether JFIF will remain the de-facto +standard. IJG intends to support SPIFF once the standard is frozen, but we +have not decided whether it should become our default output format or not. +(In any case, our decoder will remain capable of reading JFIF indefinitely.) + +Various proprietary file formats incorporating JPEG compression also exist. +We have little or no sympathy for the existence of these formats. Indeed, +one of the original reasons for developing this free software was to help +force convergence on common, open format standards for JPEG files. Don't +use a proprietary file format! + + +TO DO +===== + +The major thrust for v7 will probably be improvement of visual quality. +The current method for scaling the quantization tables is known not to be +very good at low Q values. We also intend to investigate block boundary +smoothing, "poor man's variable quantization", and other means of improving +quality-vs-file-size performance without sacrificing compatibility. + +In future versions, we are considering supporting some of the upcoming JPEG +Part 3 extensions --- principally, variable quantization and the SPIFF file +format. + +As always, speeding things up is of great interest. + +Please send bug reports, offers of help, etc. to jpeg-info@uunet.uu.net. diff --git a/src/dep/src/irrlicht/jpeglib/Tcdjpeg.c b/src/dep/src/irrlicht/jpeglib/Tcdjpeg.c index d8667ef..1318d13 100644 --- a/src/dep/src/irrlicht/jpeglib/Tcdjpeg.c +++ b/src/dep/src/irrlicht/jpeglib/Tcdjpeg.c @@ -1,182 +1,182 @@ -#line 1 "cdjpeg.c" -/* - * cdjpeg.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains common support routines used by the IJG application - * programs (cjpeg, djpeg, jpegtran). - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include /* to declare isupper(), tolower() */ -#ifdef NEED_SIGNAL_CATCHER -#include /* to declare signal() */ -#endif -#ifdef USE_SETMODE -#include /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not , just delete this line: */ -#include /* to declare setmode() */ -#endif - - -/* - * Signal catcher to ensure that temporary files are removed before aborting. - * NB: for Amiga Manx C this is actually a global routine named _abort(); - * we put "#define signal_catcher _abort" in jconfig.h. Talk about bogus... - */ - -#ifdef NEED_SIGNAL_CATCHER - -static j_common_ptr sig_cinfo; - -void /* must be global for Manx C */ -signal_catcher (signum) int signum; -{ - if (sig_cinfo != NULL) { - if (sig_cinfo->err != NULL) /* turn off trace output */ - sig_cinfo->err->trace_level = 0; - jpeg_destroy(sig_cinfo); /* clean up memory allocation & temp files */ - } - exit(EXIT_FAILURE); -} - - -GLOBAL(void) -enable_signal_catcher (cinfo) j_common_ptr cinfo; -{ - sig_cinfo = cinfo; -#ifdef SIGINT /* not all systems have SIGINT */ - signal(SIGINT, signal_catcher); -#endif -#ifdef SIGTERM /* not all systems have SIGTERM */ - signal(SIGTERM, signal_catcher); -#endif -} - -#endif - - -/* - * Optional progress monitor: display a percent-done figure on stderr. - */ - -#ifdef PROGRESS_REPORT - -METHODDEF(void) -progress_monitor (cinfo) j_common_ptr cinfo; -{ - cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress; - int total_passes = prog->pub.total_passes + prog->total_extra_passes; - int percent_done = (int) (prog->pub.pass_counter*100L/prog->pub.pass_limit); - - if (percent_done != prog->percent_done) { - prog->percent_done = percent_done; - if (total_passes > 1) { - fprintf(stderr, "\rPass %d/%d: %3d%% ", - prog->pub.completed_passes + prog->completed_extra_passes + 1, - total_passes, percent_done); - } else { - fprintf(stderr, "\r %3d%% ", percent_done); - } - fflush(stderr); - } -} - - -GLOBAL(void) -start_progress_monitor (cinfo, progress) j_common_ptr cinfo; cd_progress_ptr progress; -{ - /* Enable progress display, unless trace output is on */ - if (cinfo->err->trace_level == 0) { - progress->pub.progress_monitor = progress_monitor; - progress->completed_extra_passes = 0; - progress->total_extra_passes = 0; - progress->percent_done = -1; - cinfo->progress = &progress->pub; - } -} - - -GLOBAL(void) -end_progress_monitor (cinfo) j_common_ptr cinfo; -{ - /* Clear away progress display */ - if (cinfo->err->trace_level == 0) { - fprintf(stderr, "\r \r"); - fflush(stderr); - } -} - -#endif - - -/* - * Case-insensitive matching of possibly-abbreviated keyword switches. - * keyword is the constant keyword (must be lower case already), - * minchars is length of minimum legal abbreviation. - */ - -GLOBAL(boolean) -keymatch (arg, keyword, minchars) char * arg; const char * keyword; int minchars; -{ - register int ca, ck; - register int nmatched = 0; - - while ((ca = *arg++) != '\0') { - if ((ck = *keyword++) == '\0') - return FALSE; /* arg longer than keyword, no good */ - if (isupper(ca)) /* force arg to lcase (assume ck is already) */ - ca = tolower(ca); - if (ca != ck) - return FALSE; /* no good */ - nmatched++; /* count matched characters */ - } - /* reached end of argument; fail if it's too short for unique abbrev */ - if (nmatched < minchars) - return FALSE; - return TRUE; /* A-OK */ -} - - -/* - * Routines to establish binary I/O mode for stdin and stdout. - * Non-Unix systems often require some hacking to get out of text mode. - */ - -GLOBAL(FILE *) -read_stdin () -{ - FILE * input_file = stdin; - -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdin), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) { - fprintf(stderr, "Cannot reopen stdin\n"); - exit(EXIT_FAILURE); - } -#endif - return input_file; -} - - -GLOBAL(FILE *) -write_stdout () -{ - FILE * output_file = stdout; - -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdout), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { - fprintf(stderr, "Cannot reopen stdout\n"); - exit(EXIT_FAILURE); - } -#endif - return output_file; -} +#line 1 "cdjpeg.c" +/* + * cdjpeg.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains common support routines used by the IJG application + * programs (cjpeg, djpeg, jpegtran). + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include /* to declare isupper(), tolower() */ +#ifdef NEED_SIGNAL_CATCHER +#include /* to declare signal() */ +#endif +#ifdef USE_SETMODE +#include /* to declare setmode()'s parameter macros */ +/* If you have setmode() but not , just delete this line: */ +#include /* to declare setmode() */ +#endif + + +/* + * Signal catcher to ensure that temporary files are removed before aborting. + * NB: for Amiga Manx C this is actually a global routine named _abort(); + * we put "#define signal_catcher _abort" in jconfig.h. Talk about bogus... + */ + +#ifdef NEED_SIGNAL_CATCHER + +static j_common_ptr sig_cinfo; + +void /* must be global for Manx C */ +signal_catcher (signum) int signum; +{ + if (sig_cinfo != NULL) { + if (sig_cinfo->err != NULL) /* turn off trace output */ + sig_cinfo->err->trace_level = 0; + jpeg_destroy(sig_cinfo); /* clean up memory allocation & temp files */ + } + exit(EXIT_FAILURE); +} + + +GLOBAL(void) +enable_signal_catcher (cinfo) j_common_ptr cinfo; +{ + sig_cinfo = cinfo; +#ifdef SIGINT /* not all systems have SIGINT */ + signal(SIGINT, signal_catcher); +#endif +#ifdef SIGTERM /* not all systems have SIGTERM */ + signal(SIGTERM, signal_catcher); +#endif +} + +#endif + + +/* + * Optional progress monitor: display a percent-done figure on stderr. + */ + +#ifdef PROGRESS_REPORT + +METHODDEF(void) +progress_monitor (cinfo) j_common_ptr cinfo; +{ + cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress; + int total_passes = prog->pub.total_passes + prog->total_extra_passes; + int percent_done = (int) (prog->pub.pass_counter*100L/prog->pub.pass_limit); + + if (percent_done != prog->percent_done) { + prog->percent_done = percent_done; + if (total_passes > 1) { + fprintf(stderr, "\rPass %d/%d: %3d%% ", + prog->pub.completed_passes + prog->completed_extra_passes + 1, + total_passes, percent_done); + } else { + fprintf(stderr, "\r %3d%% ", percent_done); + } + fflush(stderr); + } +} + + +GLOBAL(void) +start_progress_monitor (cinfo, progress) j_common_ptr cinfo; cd_progress_ptr progress; +{ + /* Enable progress display, unless trace output is on */ + if (cinfo->err->trace_level == 0) { + progress->pub.progress_monitor = progress_monitor; + progress->completed_extra_passes = 0; + progress->total_extra_passes = 0; + progress->percent_done = -1; + cinfo->progress = &progress->pub; + } +} + + +GLOBAL(void) +end_progress_monitor (cinfo) j_common_ptr cinfo; +{ + /* Clear away progress display */ + if (cinfo->err->trace_level == 0) { + fprintf(stderr, "\r \r"); + fflush(stderr); + } +} + +#endif + + +/* + * Case-insensitive matching of possibly-abbreviated keyword switches. + * keyword is the constant keyword (must be lower case already), + * minchars is length of minimum legal abbreviation. + */ + +GLOBAL(boolean) +keymatch (arg, keyword, minchars) char * arg; const char * keyword; int minchars; +{ + register int ca, ck; + register int nmatched = 0; + + while ((ca = *arg++) != '\0') { + if ((ck = *keyword++) == '\0') + return FALSE; /* arg longer than keyword, no good */ + if (isupper(ca)) /* force arg to lcase (assume ck is already) */ + ca = tolower(ca); + if (ca != ck) + return FALSE; /* no good */ + nmatched++; /* count matched characters */ + } + /* reached end of argument; fail if it's too short for unique abbrev */ + if (nmatched < minchars) + return FALSE; + return TRUE; /* A-OK */ +} + + +/* + * Routines to establish binary I/O mode for stdin and stdout. + * Non-Unix systems often require some hacking to get out of text mode. + */ + +GLOBAL(FILE *) +read_stdin () +{ + FILE * input_file = stdin; + +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdin), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) { + fprintf(stderr, "Cannot reopen stdin\n"); + exit(EXIT_FAILURE); + } +#endif + return input_file; +} + + +GLOBAL(FILE *) +write_stdout () +{ + FILE * output_file = stdout; + +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdout), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { + fprintf(stderr, "Cannot reopen stdout\n"); + exit(EXIT_FAILURE); + } +#endif + return output_file; +} diff --git a/src/dep/src/irrlicht/jpeglib/ansi2knr.1 b/src/dep/src/irrlicht/jpeglib/ansi2knr.1 index 60b33cf..f9ee5a6 100644 --- a/src/dep/src/irrlicht/jpeglib/ansi2knr.1 +++ b/src/dep/src/irrlicht/jpeglib/ansi2knr.1 @@ -1,36 +1,36 @@ -.TH ANSI2KNR 1 "19 Jan 1996" -.SH NAME -ansi2knr \- convert ANSI C to Kernighan & Ritchie C -.SH SYNOPSIS -.I ansi2knr -[--varargs] input_file [output_file] -.SH DESCRIPTION -If no output_file is supplied, output goes to stdout. -.br -There are no error messages. -.sp -.I ansi2knr -recognizes function definitions by seeing a non-keyword identifier at the left -margin, followed by a left parenthesis, with a right parenthesis as the last -character on the line, and with a left brace as the first token on the -following line (ignoring possible intervening comments). It will recognize a -multi-line header provided that no intervening line ends with a left or right -brace or a semicolon. These algorithms ignore whitespace and comments, except -that the function name must be the first thing on the line. -.sp -The following constructs will confuse it: -.br - - Any other construct that starts at the left margin and follows the -above syntax (such as a macro or function call). -.br - - Some macros that tinker with the syntax of the function header. -.sp -The --varargs switch is obsolete, and is recognized only for -backwards compatibility. The present version of -.I ansi2knr -will always attempt to convert a ... argument to va_alist and va_dcl. -.SH AUTHOR -L. Peter Deutsch wrote the original ansi2knr and -continues to maintain the current version; most of the code in the current -version is his work. ansi2knr also includes contributions by Francois -Pinard and Jim Avera . +.TH ANSI2KNR 1 "19 Jan 1996" +.SH NAME +ansi2knr \- convert ANSI C to Kernighan & Ritchie C +.SH SYNOPSIS +.I ansi2knr +[--varargs] input_file [output_file] +.SH DESCRIPTION +If no output_file is supplied, output goes to stdout. +.br +There are no error messages. +.sp +.I ansi2knr +recognizes function definitions by seeing a non-keyword identifier at the left +margin, followed by a left parenthesis, with a right parenthesis as the last +character on the line, and with a left brace as the first token on the +following line (ignoring possible intervening comments). It will recognize a +multi-line header provided that no intervening line ends with a left or right +brace or a semicolon. These algorithms ignore whitespace and comments, except +that the function name must be the first thing on the line. +.sp +The following constructs will confuse it: +.br + - Any other construct that starts at the left margin and follows the +above syntax (such as a macro or function call). +.br + - Some macros that tinker with the syntax of the function header. +.sp +The --varargs switch is obsolete, and is recognized only for +backwards compatibility. The present version of +.I ansi2knr +will always attempt to convert a ... argument to va_alist and va_dcl. +.SH AUTHOR +L. Peter Deutsch wrote the original ansi2knr and +continues to maintain the current version; most of the code in the current +version is his work. ansi2knr also includes contributions by Francois +Pinard and Jim Avera . diff --git a/src/dep/src/irrlicht/jpeglib/ansi2knr.c b/src/dep/src/irrlicht/jpeglib/ansi2knr.c index 0e3ab13..4e05fc2 100644 --- a/src/dep/src/irrlicht/jpeglib/ansi2knr.c +++ b/src/dep/src/irrlicht/jpeglib/ansi2knr.c @@ -1,693 +1,693 @@ -/* ansi2knr.c */ -/* Convert ANSI C function definitions to K&R ("traditional C") syntax */ - -/* -ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY. No author or distributor accepts responsibility to anyone for the -consequences of using it or for whether it serves any particular purpose or -works at all, unless he says so in writing. Refer to the GNU General Public -License (the "GPL") for full details. - -Everyone is granted permission to copy, modify and redistribute ansi2knr, -but only under the conditions described in the GPL. A copy of this license -is supposed to have been given to you along with ansi2knr so you can know -your rights and responsibilities. It should be in a file named COPYLEFT. -[In the IJG distribution, the GPL appears below, not in a separate file.] -Among other things, the copyright notice and this notice must be preserved -on all copies. - -We explicitly state here what we believe is already implied by the GPL: if -the ansi2knr program is distributed as a separate set of sources and a -separate executable file which are aggregated on a storage medium together -with another program, this in itself does not bring the other program under -the GPL, nor does the mere fact that such a program or the procedures for -constructing it invoke the ansi2knr executable bring any other part of the -program under the GPL. -*/ - -/* ----------- Here is the GNU GPL file COPYLEFT, referred to above ---------- ------ These terms do NOT apply to the JPEG software itself; see README ------ - - GHOSTSCRIPT GENERAL PUBLIC LICENSE - (Clarified 11 Feb 1988) - - Copyright (C) 1988 Richard M. Stallman - Everyone is permitted to copy and distribute verbatim copies of this - license, but changing it is not allowed. You can also use this wording - to make the terms for other programs. - - The license agreements of most software companies keep you at the -mercy of those companies. By contrast, our general public license is -intended to give everyone the right to share Ghostscript. To make sure -that you get the rights we want you to have, we need to make -restrictions that forbid anyone to deny you these rights or to ask you -to surrender the rights. Hence this license agreement. - - Specifically, we want to make sure that you have the right to give -away copies of Ghostscript, that you receive source code or else can get -it if you want it, that you can change Ghostscript or use pieces of it -in new free programs, and that you know you can do these things. - - To make sure that everyone has such rights, we have to forbid you to -deprive anyone else of these rights. For example, if you distribute -copies of Ghostscript, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must tell them their rights. - - Also, for our own protection, we must make certain that everyone finds -out that there is no warranty for Ghostscript. If Ghostscript is -modified by someone else and passed on, we want its recipients to know -that what they have is not what we distributed, so that any problems -introduced by others will not reflect on our reputation. - - Therefore we (Richard M. Stallman and the Free Software Foundation, -Inc.) make the following terms which say what you must do to be allowed -to distribute or change Ghostscript. - - - COPYING POLICIES - - 1. You may copy and distribute verbatim copies of Ghostscript source -code as you receive it, in any medium, provided that you conspicuously -and appropriately publish on each copy a valid copyright and license -notice "Copyright (C) 1989 Aladdin Enterprises. All rights reserved. -Distributed by Free Software Foundation, Inc." (or with whatever year is -appropriate); keep intact the notices on all files that refer to this -License Agreement and to the absence of any warranty; and give any other -recipients of the Ghostscript program a copy of this License Agreement -along with the program. You may charge a distribution fee for the -physical act of transferring a copy. - - 2. You may modify your copy or copies of Ghostscript or any portion of -it, and copy and distribute such modifications under the terms of -Paragraph 1 above, provided that you also do the following: - - a) cause the modified files to carry prominent notices stating - that you changed the files and the date of any change; and - - b) cause the whole of any work that you distribute or publish, - that in whole or in part contains or is a derivative of Ghostscript - or any part thereof, to be licensed at no charge to all third - parties on terms identical to those contained in this License - Agreement (except that you may choose to grant more extensive - warranty protection to some or all third parties, at your option). - - c) You may charge a distribution fee for the physical act of - transferring a copy, and you may at your option offer warranty - protection in exchange for a fee. - -Mere aggregation of another unrelated program with this program (or its -derivative) on a volume of a storage or distribution medium does not bring -the other program under the scope of these terms. - - 3. You may copy and distribute Ghostscript (or a portion or derivative -of it, under Paragraph 2) in object code or executable form under the -terms of Paragraphs 1 and 2 above provided that you also do one of the -following: - - a) accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of - Paragraphs 1 and 2 above; or, - - b) accompany it with a written offer, valid for at least three - years, to give any third party free (except for a nominal - shipping charge) a complete machine-readable copy of the - corresponding source code, to be distributed under the terms of - Paragraphs 1 and 2 above; or, - - c) accompany it with the information you received as to where the - corresponding source code may be obtained. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form alone.) - -For an executable file, complete source code means all the source code for -all modules it contains; but, as a special exception, it need not include -source code for modules which are standard libraries that accompany the -operating system on which the executable file runs. - - 4. You may not copy, sublicense, distribute or transfer Ghostscript -except as expressly provided under this License Agreement. Any attempt -otherwise to copy, sublicense, distribute or transfer Ghostscript is -void and your rights to use the program under this License agreement -shall be automatically terminated. However, parties who have received -computer software programs from you with this License Agreement will not -have their licenses terminated so long as such parties remain in full -compliance. - - 5. If you wish to incorporate parts of Ghostscript into other free -programs whose distribution conditions are different, write to the Free -Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not -yet worked out a simple rule that can be stated here, but we will often -permit this. We will be guided by the two goals of preserving the free -status of all derivatives of our free software and of promoting the -sharing and reuse of software. - -Your comments and suggestions about our licensing policies and our -software are welcome! Please contact the Free Software Foundation, -Inc., 675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296. - - NO WARRANTY - - BECAUSE GHOSTSCRIPT IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY -NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT -WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, RICHARD -M. STALLMAN, ALADDIN ENTERPRISES, L. PETER DEUTSCH, AND/OR OTHER PARTIES -PROVIDE GHOSTSCRIPT "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER -EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE -ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF GHOSTSCRIPT IS WITH -YOU. SHOULD GHOSTSCRIPT PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL -NECESSARY SERVICING, REPAIR OR CORRECTION. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. -STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., L. PETER DEUTSCH, ALADDIN -ENTERPRISES, AND/OR ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE -GHOSTSCRIPT AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING -ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE -(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED -INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE -PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GHOSTSCRIPT, EVEN IF YOU -HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM -BY ANY OTHER PARTY. - --------------------- End of file COPYLEFT ------------------------------ -*/ - -/* - * Usage: - ansi2knr input_file [output_file] - * If no output_file is supplied, output goes to stdout. - * There are no error messages. - * - * ansi2knr recognizes function definitions by seeing a non-keyword - * identifier at the left margin, followed by a left parenthesis, - * with a right parenthesis as the last character on the line, - * and with a left brace as the first token on the following line - * (ignoring possible intervening comments). - * It will recognize a multi-line header provided that no intervening - * line ends with a left or right brace or a semicolon. - * These algorithms ignore whitespace and comments, except that - * the function name must be the first thing on the line. - * The following constructs will confuse it: - * - Any other construct that starts at the left margin and - * follows the above syntax (such as a macro or function call). - * - Some macros that tinker with the syntax of the function header. - */ - -/* - * The original and principal author of ansi2knr is L. Peter Deutsch - * . Other authors are noted in the change history - * that follows (in reverse chronological order): - lpd 96-01-21 added code to cope with not HAVE_CONFIG_H and with - compilers that don't understand void, as suggested by - Tom Lane - lpd 96-01-15 changed to require that the first non-comment token - on the line following a function header be a left brace, - to reduce sensitivity to macros, as suggested by Tom Lane - - lpd 95-06-22 removed #ifndefs whose sole purpose was to define - undefined preprocessor symbols as 0; changed all #ifdefs - for configuration symbols to #ifs - lpd 95-04-05 changed copyright notice to make it clear that - including ansi2knr in a program does not bring the entire - program under the GPL - lpd 94-12-18 added conditionals for systems where ctype macros - don't handle 8-bit characters properly, suggested by - Francois Pinard ; - removed --varargs switch (this is now the default) - lpd 94-10-10 removed CONFIG_BROKETS conditional - lpd 94-07-16 added some conditionals to help GNU `configure', - suggested by Francois Pinard ; - properly erase prototype args in function parameters, - contributed by Jim Avera ; - correct error in writeblanks (it shouldn't erase EOLs) - lpd 89-xx-xx original version - */ - -/* Most of the conditionals here are to make ansi2knr work with */ -/* or without the GNU configure machinery. */ - -#if HAVE_CONFIG_H -# include -#endif - -#include -#include - -#if HAVE_CONFIG_H - -/* - For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h). - This will define HAVE_CONFIG_H and so, activate the following lines. - */ - -# if STDC_HEADERS || HAVE_STRING_H -# include -# else -# include -# endif - -#else /* not HAVE_CONFIG_H */ - -/* Otherwise do it the hard way */ - -# ifdef BSD -# include -# else -# ifdef VMS - extern int strlen(), strncmp(); -# else -# include -# endif -# endif - -#endif /* not HAVE_CONFIG_H */ - -#if STDC_HEADERS -# include -#else -/* - malloc and free should be declared in stdlib.h, - but if you've got a K&R compiler, they probably aren't. - */ -# ifdef MSDOS -# include -# else -# ifdef VMS - extern char *malloc(); - extern void free(); -# else - extern char *malloc(); - extern int free(); -# endif -# endif - -#endif - -/* - * The ctype macros don't always handle 8-bit characters correctly. - * Compensate for this here. - */ -#ifdef isascii -# undef HAVE_ISASCII /* just in case */ -# define HAVE_ISASCII 1 -#else -#endif -#if STDC_HEADERS || !HAVE_ISASCII -# define is_ascii(c) 1 -#else -# define is_ascii(c) isascii(c) -#endif - -#define is_space(c) (is_ascii(c) && isspace(c)) -#define is_alpha(c) (is_ascii(c) && isalpha(c)) -#define is_alnum(c) (is_ascii(c) && isalnum(c)) - -/* Scanning macros */ -#define isidchar(ch) (is_alnum(ch) || (ch) == '_') -#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_') - -/* Forward references */ -char *skipspace(); -int writeblanks(); -int test1(); -int convert1(); - -/* The main program */ -int -main(argc, argv) - int argc; - char *argv[]; -{ FILE *in, *out; -#define bufsize 5000 /* arbitrary size */ - char *buf; - char *line; - char *more; - /* - * In previous versions, ansi2knr recognized a --varargs switch. - * If this switch was supplied, ansi2knr would attempt to convert - * a ... argument to va_alist and va_dcl; if this switch was not - * supplied, ansi2knr would simply drop any such arguments. - * Now, ansi2knr always does this conversion, and we only - * check for this switch for backward compatibility. - */ - int convert_varargs = 1; - - if ( argc > 1 && argv[1][0] == '-' ) - { if ( !strcmp(argv[1], "--varargs") ) - { convert_varargs = 1; - argc--; - argv++; - } - else - { fprintf(stderr, "Unrecognized switch: %s\n", argv[1]); - exit(1); - } - } - switch ( argc ) - { - default: - printf("Usage: ansi2knr input_file [output_file]\n"); - exit(0); - case 2: - out = stdout; - break; - case 3: - out = fopen(argv[2], "w"); - if ( out == NULL ) - { fprintf(stderr, "Cannot open output file %s\n", argv[2]); - exit(1); - } - } - in = fopen(argv[1], "r"); - if ( in == NULL ) - { fprintf(stderr, "Cannot open input file %s\n", argv[1]); - exit(1); - } - fprintf(out, "#line 1 \"%s\"\n", argv[1]); - buf = malloc(bufsize); - line = buf; - while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL ) - { -test: line += strlen(line); - switch ( test1(buf) ) - { - case 2: /* a function header */ - convert1(buf, out, 1, convert_varargs); - break; - case 1: /* a function */ - /* Check for a { at the start of the next line. */ - more = ++line; -f: if ( line >= buf + (bufsize - 1) ) /* overflow check */ - goto wl; - if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL ) - goto wl; - switch ( *skipspace(more, 1) ) - { - case '{': - /* Definitely a function header. */ - convert1(buf, out, 0, convert_varargs); - fputs(more, out); - break; - case 0: - /* The next line was blank or a comment: */ - /* keep scanning for a non-comment. */ - line += strlen(line); - goto f; - default: - /* buf isn't a function header, but */ - /* more might be. */ - fputs(buf, out); - strcpy(buf, more); - line = buf; - goto test; - } - break; - case -1: /* maybe the start of a function */ - if ( line != buf + (bufsize - 1) ) /* overflow check */ - continue; - /* falls through */ - default: /* not a function */ -wl: fputs(buf, out); - break; - } - line = buf; - } - if ( line != buf ) - fputs(buf, out); - free(buf); - fclose(out); - fclose(in); - return 0; -} - -/* Skip over space and comments, in either direction. */ -char * -skipspace(p, dir) - register char *p; - register int dir; /* 1 for forward, -1 for backward */ -{ for ( ; ; ) - { while ( is_space(*p) ) - p += dir; - if ( !(*p == '/' && p[dir] == '*') ) - break; - p += dir; p += dir; - while ( !(*p == '*' && p[dir] == '/') ) - { if ( *p == 0 ) - return p; /* multi-line comment?? */ - p += dir; - } - p += dir; p += dir; - } - return p; -} - -/* - * Write blanks over part of a string. - * Don't overwrite end-of-line characters. - */ -int -writeblanks(start, end) - char *start; - char *end; -{ char *p; - for ( p = start; p < end; p++ ) - if ( *p != '\r' && *p != '\n' ) - *p = ' '; - return 0; -} - -/* - * Test whether the string in buf is a function definition. - * The string may contain and/or end with a newline. - * Return as follows: - * 0 - definitely not a function definition; - * 1 - definitely a function definition; - * 2 - definitely a function prototype (NOT USED); - * -1 - may be the beginning of a function definition, - * append another line and look again. - * The reason we don't attempt to convert function prototypes is that - * Ghostscript's declaration-generating macros look too much like - * prototypes, and confuse the algorithms. - */ -int -test1(buf) - char *buf; -{ register char *p = buf; - char *bend; - char *endfn; - int contin; - - if ( !isidfirstchar(*p) ) - return 0; /* no name at left margin */ - bend = skipspace(buf + strlen(buf) - 1, -1); - switch ( *bend ) - { - case ';': contin = 0 /*2*/; break; - case ')': contin = 1; break; - case '{': return 0; /* not a function */ - case '}': return 0; /* not a function */ - default: contin = -1; - } - while ( isidchar(*p) ) - p++; - endfn = p; - p = skipspace(p, 1); - if ( *p++ != '(' ) - return 0; /* not a function */ - p = skipspace(p, 1); - if ( *p == ')' ) - return 0; /* no parameters */ - /* Check that the apparent function name isn't a keyword. */ - /* We only need to check for keywords that could be followed */ - /* by a left parenthesis (which, unfortunately, is most of them). */ - { static char *words[] = - { "asm", "auto", "case", "char", "const", "double", - "extern", "float", "for", "if", "int", "long", - "register", "return", "short", "signed", "sizeof", - "static", "switch", "typedef", "unsigned", - "void", "volatile", "while", 0 - }; - char **key = words; - char *kp; - int len = endfn - buf; - - while ( (kp = *key) != 0 ) - { if ( strlen(kp) == len && !strncmp(kp, buf, len) ) - return 0; /* name is a keyword */ - key++; - } - } - return contin; -} - -/* Convert a recognized function definition or header to K&R syntax. */ -int -convert1(buf, out, header, convert_varargs) - char *buf; - FILE *out; - int header; /* Boolean */ - int convert_varargs; /* Boolean */ -{ char *endfn; - register char *p; - char **breaks; - unsigned num_breaks = 2; /* for testing */ - char **btop; - char **bp; - char **ap; - char *vararg = 0; - - /* Pre-ANSI implementations don't agree on whether strchr */ - /* is called strchr or index, so we open-code it here. */ - for ( endfn = buf; *(endfn++) != '('; ) - ; -top: p = endfn; - breaks = (char **)malloc(sizeof(char *) * num_breaks * 2); - if ( breaks == 0 ) - { /* Couldn't allocate break table, give up */ - fprintf(stderr, "Unable to allocate break table!\n"); - fputs(buf, out); - return -1; - } - btop = breaks + num_breaks * 2 - 2; - bp = breaks; - /* Parse the argument list */ - do - { int level = 0; - char *lp = NULL; - char *rp; - char *end = NULL; - - if ( bp >= btop ) - { /* Filled up break table. */ - /* Allocate a bigger one and start over. */ - free((char *)breaks); - num_breaks <<= 1; - goto top; - } - *bp++ = p; - /* Find the end of the argument */ - for ( ; end == NULL; p++ ) - { switch(*p) - { - case ',': - if ( !level ) end = p; - break; - case '(': - if ( !level ) lp = p; - level++; - break; - case ')': - if ( --level < 0 ) end = p; - else rp = p; - break; - case '/': - p = skipspace(p, 1) - 1; - break; - default: - ; - } - } - /* Erase any embedded prototype parameters. */ - if ( lp ) - writeblanks(lp + 1, rp); - p--; /* back up over terminator */ - /* Find the name being declared. */ - /* This is complicated because of procedure and */ - /* array modifiers. */ - for ( ; ; ) - { p = skipspace(p - 1, -1); - switch ( *p ) - { - case ']': /* skip array dimension(s) */ - case ')': /* skip procedure args OR name */ - { int level = 1; - while ( level ) - switch ( *--p ) - { - case ']': case ')': level++; break; - case '[': case '(': level--; break; - case '/': p = skipspace(p, -1) + 1; break; - default: ; - } - } - if ( *p == '(' && *skipspace(p + 1, 1) == '*' ) - { /* We found the name being declared */ - while ( !isidfirstchar(*p) ) - p = skipspace(p, 1) + 1; - goto found; - } - break; - default: - goto found; - } - } -found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' ) - { if ( convert_varargs ) - { *bp++ = "va_alist"; - vararg = p-2; - } - else - { p++; - if ( bp == breaks + 1 ) /* sole argument */ - writeblanks(breaks[0], p); - else - writeblanks(bp[-1] - 1, p); - bp--; - } - } - else - { while ( isidchar(*p) ) p--; - *bp++ = p+1; - } - p = end; - } - while ( *p++ == ',' ); - *bp = p; - /* Make a special check for 'void' arglist */ - if ( bp == breaks+2 ) - { p = skipspace(breaks[0], 1); - if ( !strncmp(p, "void", 4) ) - { p = skipspace(p+4, 1); - if ( p == breaks[2] - 1 ) - { bp = breaks; /* yup, pretend arglist is empty */ - writeblanks(breaks[0], p + 1); - } - } - } - /* Put out the function name and left parenthesis. */ - p = buf; - while ( p != endfn ) putc(*p, out), p++; - /* Put out the declaration. */ - if ( header ) - { fputs(");", out); - for ( p = breaks[0]; *p; p++ ) - if ( *p == '\r' || *p == '\n' ) - putc(*p, out); - } - else - { for ( ap = breaks+1; ap < bp; ap += 2 ) - { p = *ap; - while ( isidchar(*p) ) - putc(*p, out), p++; - if ( ap < bp - 1 ) - fputs(", ", out); - } - fputs(") ", out); - /* Put out the argument declarations */ - for ( ap = breaks+2; ap <= bp; ap += 2 ) - (*ap)[-1] = ';'; - if ( vararg != 0 ) - { *vararg = 0; - fputs(breaks[0], out); /* any prior args */ - fputs("va_dcl", out); /* the final arg */ - fputs(bp[0], out); - } - else - fputs(breaks[0], out); - } - free((char *)breaks); - return 0; -} +/* ansi2knr.c */ +/* Convert ANSI C function definitions to K&R ("traditional C") syntax */ + +/* +ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY. No author or distributor accepts responsibility to anyone for the +consequences of using it or for whether it serves any particular purpose or +works at all, unless he says so in writing. Refer to the GNU General Public +License (the "GPL") for full details. + +Everyone is granted permission to copy, modify and redistribute ansi2knr, +but only under the conditions described in the GPL. A copy of this license +is supposed to have been given to you along with ansi2knr so you can know +your rights and responsibilities. It should be in a file named COPYLEFT. +[In the IJG distribution, the GPL appears below, not in a separate file.] +Among other things, the copyright notice and this notice must be preserved +on all copies. + +We explicitly state here what we believe is already implied by the GPL: if +the ansi2knr program is distributed as a separate set of sources and a +separate executable file which are aggregated on a storage medium together +with another program, this in itself does not bring the other program under +the GPL, nor does the mere fact that such a program or the procedures for +constructing it invoke the ansi2knr executable bring any other part of the +program under the GPL. +*/ + +/* +---------- Here is the GNU GPL file COPYLEFT, referred to above ---------- +----- These terms do NOT apply to the JPEG software itself; see README ------ + + GHOSTSCRIPT GENERAL PUBLIC LICENSE + (Clarified 11 Feb 1988) + + Copyright (C) 1988 Richard M. Stallman + Everyone is permitted to copy and distribute verbatim copies of this + license, but changing it is not allowed. You can also use this wording + to make the terms for other programs. + + The license agreements of most software companies keep you at the +mercy of those companies. By contrast, our general public license is +intended to give everyone the right to share Ghostscript. To make sure +that you get the rights we want you to have, we need to make +restrictions that forbid anyone to deny you these rights or to ask you +to surrender the rights. Hence this license agreement. + + Specifically, we want to make sure that you have the right to give +away copies of Ghostscript, that you receive source code or else can get +it if you want it, that you can change Ghostscript or use pieces of it +in new free programs, and that you know you can do these things. + + To make sure that everyone has such rights, we have to forbid you to +deprive anyone else of these rights. For example, if you distribute +copies of Ghostscript, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must tell them their rights. + + Also, for our own protection, we must make certain that everyone finds +out that there is no warranty for Ghostscript. If Ghostscript is +modified by someone else and passed on, we want its recipients to know +that what they have is not what we distributed, so that any problems +introduced by others will not reflect on our reputation. + + Therefore we (Richard M. Stallman and the Free Software Foundation, +Inc.) make the following terms which say what you must do to be allowed +to distribute or change Ghostscript. + + + COPYING POLICIES + + 1. You may copy and distribute verbatim copies of Ghostscript source +code as you receive it, in any medium, provided that you conspicuously +and appropriately publish on each copy a valid copyright and license +notice "Copyright (C) 1989 Aladdin Enterprises. All rights reserved. +Distributed by Free Software Foundation, Inc." (or with whatever year is +appropriate); keep intact the notices on all files that refer to this +License Agreement and to the absence of any warranty; and give any other +recipients of the Ghostscript program a copy of this License Agreement +along with the program. You may charge a distribution fee for the +physical act of transferring a copy. + + 2. You may modify your copy or copies of Ghostscript or any portion of +it, and copy and distribute such modifications under the terms of +Paragraph 1 above, provided that you also do the following: + + a) cause the modified files to carry prominent notices stating + that you changed the files and the date of any change; and + + b) cause the whole of any work that you distribute or publish, + that in whole or in part contains or is a derivative of Ghostscript + or any part thereof, to be licensed at no charge to all third + parties on terms identical to those contained in this License + Agreement (except that you may choose to grant more extensive + warranty protection to some or all third parties, at your option). + + c) You may charge a distribution fee for the physical act of + transferring a copy, and you may at your option offer warranty + protection in exchange for a fee. + +Mere aggregation of another unrelated program with this program (or its +derivative) on a volume of a storage or distribution medium does not bring +the other program under the scope of these terms. + + 3. You may copy and distribute Ghostscript (or a portion or derivative +of it, under Paragraph 2) in object code or executable form under the +terms of Paragraphs 1 and 2 above provided that you also do one of the +following: + + a) accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Paragraphs 1 and 2 above; or, + + b) accompany it with a written offer, valid for at least three + years, to give any third party free (except for a nominal + shipping charge) a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of + Paragraphs 1 and 2 above; or, + + c) accompany it with the information you received as to where the + corresponding source code may be obtained. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form alone.) + +For an executable file, complete source code means all the source code for +all modules it contains; but, as a special exception, it need not include +source code for modules which are standard libraries that accompany the +operating system on which the executable file runs. + + 4. You may not copy, sublicense, distribute or transfer Ghostscript +except as expressly provided under this License Agreement. Any attempt +otherwise to copy, sublicense, distribute or transfer Ghostscript is +void and your rights to use the program under this License agreement +shall be automatically terminated. However, parties who have received +computer software programs from you with this License Agreement will not +have their licenses terminated so long as such parties remain in full +compliance. + + 5. If you wish to incorporate parts of Ghostscript into other free +programs whose distribution conditions are different, write to the Free +Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not +yet worked out a simple rule that can be stated here, but we will often +permit this. We will be guided by the two goals of preserving the free +status of all derivatives of our free software and of promoting the +sharing and reuse of software. + +Your comments and suggestions about our licensing policies and our +software are welcome! Please contact the Free Software Foundation, +Inc., 675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296. + + NO WARRANTY + + BECAUSE GHOSTSCRIPT IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY +NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT +WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, RICHARD +M. STALLMAN, ALADDIN ENTERPRISES, L. PETER DEUTSCH, AND/OR OTHER PARTIES +PROVIDE GHOSTSCRIPT "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE +ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF GHOSTSCRIPT IS WITH +YOU. SHOULD GHOSTSCRIPT PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL +NECESSARY SERVICING, REPAIR OR CORRECTION. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. +STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., L. PETER DEUTSCH, ALADDIN +ENTERPRISES, AND/OR ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE +GHOSTSCRIPT AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING +ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE +(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED +INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE +PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GHOSTSCRIPT, EVEN IF YOU +HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM +BY ANY OTHER PARTY. + +-------------------- End of file COPYLEFT ------------------------------ +*/ + +/* + * Usage: + ansi2knr input_file [output_file] + * If no output_file is supplied, output goes to stdout. + * There are no error messages. + * + * ansi2knr recognizes function definitions by seeing a non-keyword + * identifier at the left margin, followed by a left parenthesis, + * with a right parenthesis as the last character on the line, + * and with a left brace as the first token on the following line + * (ignoring possible intervening comments). + * It will recognize a multi-line header provided that no intervening + * line ends with a left or right brace or a semicolon. + * These algorithms ignore whitespace and comments, except that + * the function name must be the first thing on the line. + * The following constructs will confuse it: + * - Any other construct that starts at the left margin and + * follows the above syntax (such as a macro or function call). + * - Some macros that tinker with the syntax of the function header. + */ + +/* + * The original and principal author of ansi2knr is L. Peter Deutsch + * . Other authors are noted in the change history + * that follows (in reverse chronological order): + lpd 96-01-21 added code to cope with not HAVE_CONFIG_H and with + compilers that don't understand void, as suggested by + Tom Lane + lpd 96-01-15 changed to require that the first non-comment token + on the line following a function header be a left brace, + to reduce sensitivity to macros, as suggested by Tom Lane + + lpd 95-06-22 removed #ifndefs whose sole purpose was to define + undefined preprocessor symbols as 0; changed all #ifdefs + for configuration symbols to #ifs + lpd 95-04-05 changed copyright notice to make it clear that + including ansi2knr in a program does not bring the entire + program under the GPL + lpd 94-12-18 added conditionals for systems where ctype macros + don't handle 8-bit characters properly, suggested by + Francois Pinard ; + removed --varargs switch (this is now the default) + lpd 94-10-10 removed CONFIG_BROKETS conditional + lpd 94-07-16 added some conditionals to help GNU `configure', + suggested by Francois Pinard ; + properly erase prototype args in function parameters, + contributed by Jim Avera ; + correct error in writeblanks (it shouldn't erase EOLs) + lpd 89-xx-xx original version + */ + +/* Most of the conditionals here are to make ansi2knr work with */ +/* or without the GNU configure machinery. */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include + +#if HAVE_CONFIG_H + +/* + For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h). + This will define HAVE_CONFIG_H and so, activate the following lines. + */ + +# if STDC_HEADERS || HAVE_STRING_H +# include +# else +# include +# endif + +#else /* not HAVE_CONFIG_H */ + +/* Otherwise do it the hard way */ + +# ifdef BSD +# include +# else +# ifdef VMS + extern int strlen(), strncmp(); +# else +# include +# endif +# endif + +#endif /* not HAVE_CONFIG_H */ + +#if STDC_HEADERS +# include +#else +/* + malloc and free should be declared in stdlib.h, + but if you've got a K&R compiler, they probably aren't. + */ +# ifdef MSDOS +# include +# else +# ifdef VMS + extern char *malloc(); + extern void free(); +# else + extern char *malloc(); + extern int free(); +# endif +# endif + +#endif + +/* + * The ctype macros don't always handle 8-bit characters correctly. + * Compensate for this here. + */ +#ifdef isascii +# undef HAVE_ISASCII /* just in case */ +# define HAVE_ISASCII 1 +#else +#endif +#if STDC_HEADERS || !HAVE_ISASCII +# define is_ascii(c) 1 +#else +# define is_ascii(c) isascii(c) +#endif + +#define is_space(c) (is_ascii(c) && isspace(c)) +#define is_alpha(c) (is_ascii(c) && isalpha(c)) +#define is_alnum(c) (is_ascii(c) && isalnum(c)) + +/* Scanning macros */ +#define isidchar(ch) (is_alnum(ch) || (ch) == '_') +#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_') + +/* Forward references */ +char *skipspace(); +int writeblanks(); +int test1(); +int convert1(); + +/* The main program */ +int +main(argc, argv) + int argc; + char *argv[]; +{ FILE *in, *out; +#define bufsize 5000 /* arbitrary size */ + char *buf; + char *line; + char *more; + /* + * In previous versions, ansi2knr recognized a --varargs switch. + * If this switch was supplied, ansi2knr would attempt to convert + * a ... argument to va_alist and va_dcl; if this switch was not + * supplied, ansi2knr would simply drop any such arguments. + * Now, ansi2knr always does this conversion, and we only + * check for this switch for backward compatibility. + */ + int convert_varargs = 1; + + if ( argc > 1 && argv[1][0] == '-' ) + { if ( !strcmp(argv[1], "--varargs") ) + { convert_varargs = 1; + argc--; + argv++; + } + else + { fprintf(stderr, "Unrecognized switch: %s\n", argv[1]); + exit(1); + } + } + switch ( argc ) + { + default: + printf("Usage: ansi2knr input_file [output_file]\n"); + exit(0); + case 2: + out = stdout; + break; + case 3: + out = fopen(argv[2], "w"); + if ( out == NULL ) + { fprintf(stderr, "Cannot open output file %s\n", argv[2]); + exit(1); + } + } + in = fopen(argv[1], "r"); + if ( in == NULL ) + { fprintf(stderr, "Cannot open input file %s\n", argv[1]); + exit(1); + } + fprintf(out, "#line 1 \"%s\"\n", argv[1]); + buf = malloc(bufsize); + line = buf; + while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL ) + { +test: line += strlen(line); + switch ( test1(buf) ) + { + case 2: /* a function header */ + convert1(buf, out, 1, convert_varargs); + break; + case 1: /* a function */ + /* Check for a { at the start of the next line. */ + more = ++line; +f: if ( line >= buf + (bufsize - 1) ) /* overflow check */ + goto wl; + if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL ) + goto wl; + switch ( *skipspace(more, 1) ) + { + case '{': + /* Definitely a function header. */ + convert1(buf, out, 0, convert_varargs); + fputs(more, out); + break; + case 0: + /* The next line was blank or a comment: */ + /* keep scanning for a non-comment. */ + line += strlen(line); + goto f; + default: + /* buf isn't a function header, but */ + /* more might be. */ + fputs(buf, out); + strcpy(buf, more); + line = buf; + goto test; + } + break; + case -1: /* maybe the start of a function */ + if ( line != buf + (bufsize - 1) ) /* overflow check */ + continue; + /* falls through */ + default: /* not a function */ +wl: fputs(buf, out); + break; + } + line = buf; + } + if ( line != buf ) + fputs(buf, out); + free(buf); + fclose(out); + fclose(in); + return 0; +} + +/* Skip over space and comments, in either direction. */ +char * +skipspace(p, dir) + register char *p; + register int dir; /* 1 for forward, -1 for backward */ +{ for ( ; ; ) + { while ( is_space(*p) ) + p += dir; + if ( !(*p == '/' && p[dir] == '*') ) + break; + p += dir; p += dir; + while ( !(*p == '*' && p[dir] == '/') ) + { if ( *p == 0 ) + return p; /* multi-line comment?? */ + p += dir; + } + p += dir; p += dir; + } + return p; +} + +/* + * Write blanks over part of a string. + * Don't overwrite end-of-line characters. + */ +int +writeblanks(start, end) + char *start; + char *end; +{ char *p; + for ( p = start; p < end; p++ ) + if ( *p != '\r' && *p != '\n' ) + *p = ' '; + return 0; +} + +/* + * Test whether the string in buf is a function definition. + * The string may contain and/or end with a newline. + * Return as follows: + * 0 - definitely not a function definition; + * 1 - definitely a function definition; + * 2 - definitely a function prototype (NOT USED); + * -1 - may be the beginning of a function definition, + * append another line and look again. + * The reason we don't attempt to convert function prototypes is that + * Ghostscript's declaration-generating macros look too much like + * prototypes, and confuse the algorithms. + */ +int +test1(buf) + char *buf; +{ register char *p = buf; + char *bend; + char *endfn; + int contin; + + if ( !isidfirstchar(*p) ) + return 0; /* no name at left margin */ + bend = skipspace(buf + strlen(buf) - 1, -1); + switch ( *bend ) + { + case ';': contin = 0 /*2*/; break; + case ')': contin = 1; break; + case '{': return 0; /* not a function */ + case '}': return 0; /* not a function */ + default: contin = -1; + } + while ( isidchar(*p) ) + p++; + endfn = p; + p = skipspace(p, 1); + if ( *p++ != '(' ) + return 0; /* not a function */ + p = skipspace(p, 1); + if ( *p == ')' ) + return 0; /* no parameters */ + /* Check that the apparent function name isn't a keyword. */ + /* We only need to check for keywords that could be followed */ + /* by a left parenthesis (which, unfortunately, is most of them). */ + { static char *words[] = + { "asm", "auto", "case", "char", "const", "double", + "extern", "float", "for", "if", "int", "long", + "register", "return", "short", "signed", "sizeof", + "static", "switch", "typedef", "unsigned", + "void", "volatile", "while", 0 + }; + char **key = words; + char *kp; + int len = endfn - buf; + + while ( (kp = *key) != 0 ) + { if ( strlen(kp) == len && !strncmp(kp, buf, len) ) + return 0; /* name is a keyword */ + key++; + } + } + return contin; +} + +/* Convert a recognized function definition or header to K&R syntax. */ +int +convert1(buf, out, header, convert_varargs) + char *buf; + FILE *out; + int header; /* Boolean */ + int convert_varargs; /* Boolean */ +{ char *endfn; + register char *p; + char **breaks; + unsigned num_breaks = 2; /* for testing */ + char **btop; + char **bp; + char **ap; + char *vararg = 0; + + /* Pre-ANSI implementations don't agree on whether strchr */ + /* is called strchr or index, so we open-code it here. */ + for ( endfn = buf; *(endfn++) != '('; ) + ; +top: p = endfn; + breaks = (char **)malloc(sizeof(char *) * num_breaks * 2); + if ( breaks == 0 ) + { /* Couldn't allocate break table, give up */ + fprintf(stderr, "Unable to allocate break table!\n"); + fputs(buf, out); + return -1; + } + btop = breaks + num_breaks * 2 - 2; + bp = breaks; + /* Parse the argument list */ + do + { int level = 0; + char *lp = NULL; + char *rp; + char *end = NULL; + + if ( bp >= btop ) + { /* Filled up break table. */ + /* Allocate a bigger one and start over. */ + free((char *)breaks); + num_breaks <<= 1; + goto top; + } + *bp++ = p; + /* Find the end of the argument */ + for ( ; end == NULL; p++ ) + { switch(*p) + { + case ',': + if ( !level ) end = p; + break; + case '(': + if ( !level ) lp = p; + level++; + break; + case ')': + if ( --level < 0 ) end = p; + else rp = p; + break; + case '/': + p = skipspace(p, 1) - 1; + break; + default: + ; + } + } + /* Erase any embedded prototype parameters. */ + if ( lp ) + writeblanks(lp + 1, rp); + p--; /* back up over terminator */ + /* Find the name being declared. */ + /* This is complicated because of procedure and */ + /* array modifiers. */ + for ( ; ; ) + { p = skipspace(p - 1, -1); + switch ( *p ) + { + case ']': /* skip array dimension(s) */ + case ')': /* skip procedure args OR name */ + { int level = 1; + while ( level ) + switch ( *--p ) + { + case ']': case ')': level++; break; + case '[': case '(': level--; break; + case '/': p = skipspace(p, -1) + 1; break; + default: ; + } + } + if ( *p == '(' && *skipspace(p + 1, 1) == '*' ) + { /* We found the name being declared */ + while ( !isidfirstchar(*p) ) + p = skipspace(p, 1) + 1; + goto found; + } + break; + default: + goto found; + } + } +found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' ) + { if ( convert_varargs ) + { *bp++ = "va_alist"; + vararg = p-2; + } + else + { p++; + if ( bp == breaks + 1 ) /* sole argument */ + writeblanks(breaks[0], p); + else + writeblanks(bp[-1] - 1, p); + bp--; + } + } + else + { while ( isidchar(*p) ) p--; + *bp++ = p+1; + } + p = end; + } + while ( *p++ == ',' ); + *bp = p; + /* Make a special check for 'void' arglist */ + if ( bp == breaks+2 ) + { p = skipspace(breaks[0], 1); + if ( !strncmp(p, "void", 4) ) + { p = skipspace(p+4, 1); + if ( p == breaks[2] - 1 ) + { bp = breaks; /* yup, pretend arglist is empty */ + writeblanks(breaks[0], p + 1); + } + } + } + /* Put out the function name and left parenthesis. */ + p = buf; + while ( p != endfn ) putc(*p, out), p++; + /* Put out the declaration. */ + if ( header ) + { fputs(");", out); + for ( p = breaks[0]; *p; p++ ) + if ( *p == '\r' || *p == '\n' ) + putc(*p, out); + } + else + { for ( ap = breaks+1; ap < bp; ap += 2 ) + { p = *ap; + while ( isidchar(*p) ) + putc(*p, out), p++; + if ( ap < bp - 1 ) + fputs(", ", out); + } + fputs(") ", out); + /* Put out the argument declarations */ + for ( ap = breaks+2; ap <= bp; ap += 2 ) + (*ap)[-1] = ';'; + if ( vararg != 0 ) + { *vararg = 0; + fputs(breaks[0], out); /* any prior args */ + fputs("va_dcl", out); /* the final arg */ + fputs(bp[0], out); + } + else + fputs(breaks[0], out); + } + free((char *)breaks); + return 0; +} diff --git a/src/dep/src/irrlicht/jpeglib/cderror.h b/src/dep/src/irrlicht/jpeglib/cderror.h index c19d38f..70435e1 100644 --- a/src/dep/src/irrlicht/jpeglib/cderror.h +++ b/src/dep/src/irrlicht/jpeglib/cderror.h @@ -1,132 +1,132 @@ -/* - * cderror.h - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the error and message codes for the cjpeg/djpeg - * applications. These strings are not needed as part of the JPEG library - * proper. - * Edit this file to add new codes, or to translate the message strings to - * some other language. - */ - -/* - * To define the enum list of message codes, include this file without - * defining macro JMESSAGE. To create a message string table, include it - * again with a suitable JMESSAGE definition (see jerror.c for an example). - */ -#ifndef JMESSAGE -#ifndef CDERROR_H -#define CDERROR_H -/* First time through, define the enum list */ -#define JMAKE_ENUM_LIST -#else -/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ -#define JMESSAGE(code,string) -#endif /* CDERROR_H */ -#endif /* JMESSAGE */ - -#ifdef JMAKE_ENUM_LIST - -typedef enum { - -#define JMESSAGE(code,string) code , - -#endif /* JMAKE_ENUM_LIST */ - -JMESSAGE(JMSG_FIRSTADDONCODE=1000, NULL) /* Must be first entry! */ - -#ifdef BMP_SUPPORTED -JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format") -JMESSAGE(JERR_BMP_BADDEPTH, "Only 8- and 24-bit BMP files are supported") -JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length") -JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1") -JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB") -JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported") -JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM") -JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image") -JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image") -JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image") -JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image") -#endif /* BMP_SUPPORTED */ - -#ifdef GIF_SUPPORTED -JMESSAGE(JERR_GIF_BUG, "GIF output got confused") -JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d") -JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB") -JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file") -JMESSAGE(JERR_GIF_NOT, "Not a GIF file") -JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image") -JMESSAGE(JTRC_GIF_BADVERSION, - "Warning: unexpected GIF version number '%c%c%c'") -JMESSAGE(JTRC_GIF_EXTENSION, "Ignoring GIF extension block of type 0x%02x") -JMESSAGE(JTRC_GIF_NONSQUARE, "Caution: nonsquare pixels in input") -JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file") -JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring") -JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image") -JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits") -#endif /* GIF_SUPPORTED */ - -#ifdef PPM_SUPPORTED -JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB") -JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file") -JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file") -JMESSAGE(JTRC_PGM, "%ux%u PGM image") -JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image") -JMESSAGE(JTRC_PPM, "%ux%u PPM image") -JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image") -#endif /* PPM_SUPPORTED */ - -#ifdef RLE_SUPPORTED -JMESSAGE(JERR_RLE_BADERROR, "Bogus error code from RLE library") -JMESSAGE(JERR_RLE_COLORSPACE, "RLE output must be grayscale or RGB") -JMESSAGE(JERR_RLE_DIMENSIONS, "Image dimensions (%ux%u) too large for RLE") -JMESSAGE(JERR_RLE_EMPTY, "Empty RLE file") -JMESSAGE(JERR_RLE_EOF, "Premature EOF in RLE header") -JMESSAGE(JERR_RLE_MEM, "Insufficient memory for RLE header") -JMESSAGE(JERR_RLE_NOT, "Not an RLE file") -JMESSAGE(JERR_RLE_TOOMANYCHANNELS, "Cannot handle %d output channels for RLE") -JMESSAGE(JERR_RLE_UNSUPPORTED, "Cannot handle this RLE setup") -JMESSAGE(JTRC_RLE, "%ux%u full-color RLE file") -JMESSAGE(JTRC_RLE_FULLMAP, "%ux%u full-color RLE file with map of length %d") -JMESSAGE(JTRC_RLE_GRAY, "%ux%u grayscale RLE file") -JMESSAGE(JTRC_RLE_MAPGRAY, "%ux%u grayscale RLE file with map of length %d") -JMESSAGE(JTRC_RLE_MAPPED, "%ux%u colormapped RLE file with map of length %d") -#endif /* RLE_SUPPORTED */ - -#ifdef TARGA_SUPPORTED -JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format") -JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file") -JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB") -JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image") -JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image") -JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image") -#else -JMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled") -#endif /* TARGA_SUPPORTED */ - -JMESSAGE(JERR_BAD_CMAP_FILE, - "Color map file is invalid or of unsupported format") -JMESSAGE(JERR_TOO_MANY_COLORS, - "Output file format cannot handle %d colormap entries") -JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed") -#ifdef TARGA_SUPPORTED -JMESSAGE(JERR_UNKNOWN_FORMAT, - "Unrecognized input file format --- perhaps you need -targa") -#else -JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format") -#endif -JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format") - -#ifdef JMAKE_ENUM_LIST - - JMSG_LASTADDONCODE -} ADDON_MESSAGE_CODE; - -#undef JMAKE_ENUM_LIST -#endif /* JMAKE_ENUM_LIST */ - -/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ -#undef JMESSAGE +/* + * cderror.h + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file defines the error and message codes for the cjpeg/djpeg + * applications. These strings are not needed as part of the JPEG library + * proper. + * Edit this file to add new codes, or to translate the message strings to + * some other language. + */ + +/* + * To define the enum list of message codes, include this file without + * defining macro JMESSAGE. To create a message string table, include it + * again with a suitable JMESSAGE definition (see jerror.c for an example). + */ +#ifndef JMESSAGE +#ifndef CDERROR_H +#define CDERROR_H +/* First time through, define the enum list */ +#define JMAKE_ENUM_LIST +#else +/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ +#define JMESSAGE(code,string) +#endif /* CDERROR_H */ +#endif /* JMESSAGE */ + +#ifdef JMAKE_ENUM_LIST + +typedef enum { + +#define JMESSAGE(code,string) code , + +#endif /* JMAKE_ENUM_LIST */ + +JMESSAGE(JMSG_FIRSTADDONCODE=1000, NULL) /* Must be first entry! */ + +#ifdef BMP_SUPPORTED +JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format") +JMESSAGE(JERR_BMP_BADDEPTH, "Only 8- and 24-bit BMP files are supported") +JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length") +JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1") +JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB") +JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported") +JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM") +JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image") +JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image") +JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image") +JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image") +#endif /* BMP_SUPPORTED */ + +#ifdef GIF_SUPPORTED +JMESSAGE(JERR_GIF_BUG, "GIF output got confused") +JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d") +JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB") +JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file") +JMESSAGE(JERR_GIF_NOT, "Not a GIF file") +JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image") +JMESSAGE(JTRC_GIF_BADVERSION, + "Warning: unexpected GIF version number '%c%c%c'") +JMESSAGE(JTRC_GIF_EXTENSION, "Ignoring GIF extension block of type 0x%02x") +JMESSAGE(JTRC_GIF_NONSQUARE, "Caution: nonsquare pixels in input") +JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file") +JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring") +JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image") +JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits") +#endif /* GIF_SUPPORTED */ + +#ifdef PPM_SUPPORTED +JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB") +JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file") +JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file") +JMESSAGE(JTRC_PGM, "%ux%u PGM image") +JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image") +JMESSAGE(JTRC_PPM, "%ux%u PPM image") +JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image") +#endif /* PPM_SUPPORTED */ + +#ifdef RLE_SUPPORTED +JMESSAGE(JERR_RLE_BADERROR, "Bogus error code from RLE library") +JMESSAGE(JERR_RLE_COLORSPACE, "RLE output must be grayscale or RGB") +JMESSAGE(JERR_RLE_DIMENSIONS, "Image dimensions (%ux%u) too large for RLE") +JMESSAGE(JERR_RLE_EMPTY, "Empty RLE file") +JMESSAGE(JERR_RLE_EOF, "Premature EOF in RLE header") +JMESSAGE(JERR_RLE_MEM, "Insufficient memory for RLE header") +JMESSAGE(JERR_RLE_NOT, "Not an RLE file") +JMESSAGE(JERR_RLE_TOOMANYCHANNELS, "Cannot handle %d output channels for RLE") +JMESSAGE(JERR_RLE_UNSUPPORTED, "Cannot handle this RLE setup") +JMESSAGE(JTRC_RLE, "%ux%u full-color RLE file") +JMESSAGE(JTRC_RLE_FULLMAP, "%ux%u full-color RLE file with map of length %d") +JMESSAGE(JTRC_RLE_GRAY, "%ux%u grayscale RLE file") +JMESSAGE(JTRC_RLE_MAPGRAY, "%ux%u grayscale RLE file with map of length %d") +JMESSAGE(JTRC_RLE_MAPPED, "%ux%u colormapped RLE file with map of length %d") +#endif /* RLE_SUPPORTED */ + +#ifdef TARGA_SUPPORTED +JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format") +JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file") +JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB") +JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image") +JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image") +JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image") +#else +JMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled") +#endif /* TARGA_SUPPORTED */ + +JMESSAGE(JERR_BAD_CMAP_FILE, + "Color map file is invalid or of unsupported format") +JMESSAGE(JERR_TOO_MANY_COLORS, + "Output file format cannot handle %d colormap entries") +JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed") +#ifdef TARGA_SUPPORTED +JMESSAGE(JERR_UNKNOWN_FORMAT, + "Unrecognized input file format --- perhaps you need -targa") +#else +JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format") +#endif +JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format") + +#ifdef JMAKE_ENUM_LIST + + JMSG_LASTADDONCODE +} ADDON_MESSAGE_CODE; + +#undef JMAKE_ENUM_LIST +#endif /* JMAKE_ENUM_LIST */ + +/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ +#undef JMESSAGE diff --git a/src/dep/src/irrlicht/jpeglib/cdjpeg.c b/src/dep/src/irrlicht/jpeglib/cdjpeg.c index 89fe633..b6250ff 100644 --- a/src/dep/src/irrlicht/jpeglib/cdjpeg.c +++ b/src/dep/src/irrlicht/jpeglib/cdjpeg.c @@ -1,181 +1,181 @@ -/* - * cdjpeg.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains common support routines used by the IJG application - * programs (cjpeg, djpeg, jpegtran). - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include /* to declare isupper(), tolower() */ -#ifdef NEED_SIGNAL_CATCHER -#include /* to declare signal() */ -#endif -#ifdef USE_SETMODE -#include /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not , just delete this line: */ -#include /* to declare setmode() */ -#endif - - -/* - * Signal catcher to ensure that temporary files are removed before aborting. - * NB: for Amiga Manx C this is actually a global routine named _abort(); - * we put "#define signal_catcher _abort" in jconfig.h. Talk about bogus... - */ - -#ifdef NEED_SIGNAL_CATCHER - -static j_common_ptr sig_cinfo; - -void /* must be global for Manx C */ -signal_catcher (int signum) -{ - if (sig_cinfo != NULL) { - if (sig_cinfo->err != NULL) /* turn off trace output */ - sig_cinfo->err->trace_level = 0; - jpeg_destroy(sig_cinfo); /* clean up memory allocation & temp files */ - } - exit(EXIT_FAILURE); -} - - -GLOBAL(void) -enable_signal_catcher (j_common_ptr cinfo) -{ - sig_cinfo = cinfo; -#ifdef SIGINT /* not all systems have SIGINT */ - signal(SIGINT, signal_catcher); -#endif -#ifdef SIGTERM /* not all systems have SIGTERM */ - signal(SIGTERM, signal_catcher); -#endif -} - -#endif - - -/* - * Optional progress monitor: display a percent-done figure on stderr. - */ - -#ifdef PROGRESS_REPORT - -METHODDEF(void) -progress_monitor (j_common_ptr cinfo) -{ - cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress; - int total_passes = prog->pub.total_passes + prog->total_extra_passes; - int percent_done = (int) (prog->pub.pass_counter*100L/prog->pub.pass_limit); - - if (percent_done != prog->percent_done) { - prog->percent_done = percent_done; - if (total_passes > 1) { - fprintf(stderr, "\rPass %d/%d: %3d%% ", - prog->pub.completed_passes + prog->completed_extra_passes + 1, - total_passes, percent_done); - } else { - fprintf(stderr, "\r %3d%% ", percent_done); - } - fflush(stderr); - } -} - - -GLOBAL(void) -start_progress_monitor (j_common_ptr cinfo, cd_progress_ptr progress) -{ - /* Enable progress display, unless trace output is on */ - if (cinfo->err->trace_level == 0) { - progress->pub.progress_monitor = progress_monitor; - progress->completed_extra_passes = 0; - progress->total_extra_passes = 0; - progress->percent_done = -1; - cinfo->progress = &progress->pub; - } -} - - -GLOBAL(void) -end_progress_monitor (j_common_ptr cinfo) -{ - /* Clear away progress display */ - if (cinfo->err->trace_level == 0) { - fprintf(stderr, "\r \r"); - fflush(stderr); - } -} - -#endif - - -/* - * Case-insensitive matching of possibly-abbreviated keyword switches. - * keyword is the constant keyword (must be lower case already), - * minchars is length of minimum legal abbreviation. - */ - -GLOBAL(boolean) -keymatch (char * arg, const char * keyword, int minchars) -{ - register int ca, ck; - register int nmatched = 0; - - while ((ca = *arg++) != '\0') { - if ((ck = *keyword++) == '\0') - return FALSE; /* arg longer than keyword, no good */ - if (isupper(ca)) /* force arg to lcase (assume ck is already) */ - ca = tolower(ca); - if (ca != ck) - return FALSE; /* no good */ - nmatched++; /* count matched characters */ - } - /* reached end of argument; fail if it's too short for unique abbrev */ - if (nmatched < minchars) - return FALSE; - return TRUE; /* A-OK */ -} - - -/* - * Routines to establish binary I/O mode for stdin and stdout. - * Non-Unix systems often require some hacking to get out of text mode. - */ - -GLOBAL(FILE *) -read_stdin (void) -{ - FILE * input_file = stdin; - -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdin), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) { - fprintf(stderr, "Cannot reopen stdin\n"); - exit(EXIT_FAILURE); - } -#endif - return input_file; -} - - -GLOBAL(FILE *) -write_stdout (void) -{ - FILE * output_file = stdout; - -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdout), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { - fprintf(stderr, "Cannot reopen stdout\n"); - exit(EXIT_FAILURE); - } -#endif - return output_file; -} +/* + * cdjpeg.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains common support routines used by the IJG application + * programs (cjpeg, djpeg, jpegtran). + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include /* to declare isupper(), tolower() */ +#ifdef NEED_SIGNAL_CATCHER +#include /* to declare signal() */ +#endif +#ifdef USE_SETMODE +#include /* to declare setmode()'s parameter macros */ +/* If you have setmode() but not , just delete this line: */ +#include /* to declare setmode() */ +#endif + + +/* + * Signal catcher to ensure that temporary files are removed before aborting. + * NB: for Amiga Manx C this is actually a global routine named _abort(); + * we put "#define signal_catcher _abort" in jconfig.h. Talk about bogus... + */ + +#ifdef NEED_SIGNAL_CATCHER + +static j_common_ptr sig_cinfo; + +void /* must be global for Manx C */ +signal_catcher (int signum) +{ + if (sig_cinfo != NULL) { + if (sig_cinfo->err != NULL) /* turn off trace output */ + sig_cinfo->err->trace_level = 0; + jpeg_destroy(sig_cinfo); /* clean up memory allocation & temp files */ + } + exit(EXIT_FAILURE); +} + + +GLOBAL(void) +enable_signal_catcher (j_common_ptr cinfo) +{ + sig_cinfo = cinfo; +#ifdef SIGINT /* not all systems have SIGINT */ + signal(SIGINT, signal_catcher); +#endif +#ifdef SIGTERM /* not all systems have SIGTERM */ + signal(SIGTERM, signal_catcher); +#endif +} + +#endif + + +/* + * Optional progress monitor: display a percent-done figure on stderr. + */ + +#ifdef PROGRESS_REPORT + +METHODDEF(void) +progress_monitor (j_common_ptr cinfo) +{ + cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress; + int total_passes = prog->pub.total_passes + prog->total_extra_passes; + int percent_done = (int) (prog->pub.pass_counter*100L/prog->pub.pass_limit); + + if (percent_done != prog->percent_done) { + prog->percent_done = percent_done; + if (total_passes > 1) { + fprintf(stderr, "\rPass %d/%d: %3d%% ", + prog->pub.completed_passes + prog->completed_extra_passes + 1, + total_passes, percent_done); + } else { + fprintf(stderr, "\r %3d%% ", percent_done); + } + fflush(stderr); + } +} + + +GLOBAL(void) +start_progress_monitor (j_common_ptr cinfo, cd_progress_ptr progress) +{ + /* Enable progress display, unless trace output is on */ + if (cinfo->err->trace_level == 0) { + progress->pub.progress_monitor = progress_monitor; + progress->completed_extra_passes = 0; + progress->total_extra_passes = 0; + progress->percent_done = -1; + cinfo->progress = &progress->pub; + } +} + + +GLOBAL(void) +end_progress_monitor (j_common_ptr cinfo) +{ + /* Clear away progress display */ + if (cinfo->err->trace_level == 0) { + fprintf(stderr, "\r \r"); + fflush(stderr); + } +} + +#endif + + +/* + * Case-insensitive matching of possibly-abbreviated keyword switches. + * keyword is the constant keyword (must be lower case already), + * minchars is length of minimum legal abbreviation. + */ + +GLOBAL(boolean) +keymatch (char * arg, const char * keyword, int minchars) +{ + register int ca, ck; + register int nmatched = 0; + + while ((ca = *arg++) != '\0') { + if ((ck = *keyword++) == '\0') + return FALSE; /* arg longer than keyword, no good */ + if (isupper(ca)) /* force arg to lcase (assume ck is already) */ + ca = tolower(ca); + if (ca != ck) + return FALSE; /* no good */ + nmatched++; /* count matched characters */ + } + /* reached end of argument; fail if it's too short for unique abbrev */ + if (nmatched < minchars) + return FALSE; + return TRUE; /* A-OK */ +} + + +/* + * Routines to establish binary I/O mode for stdin and stdout. + * Non-Unix systems often require some hacking to get out of text mode. + */ + +GLOBAL(FILE *) +read_stdin (void) +{ + FILE * input_file = stdin; + +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdin), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) { + fprintf(stderr, "Cannot reopen stdin\n"); + exit(EXIT_FAILURE); + } +#endif + return input_file; +} + + +GLOBAL(FILE *) +write_stdout (void) +{ + FILE * output_file = stdout; + +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdout), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { + fprintf(stderr, "Cannot reopen stdout\n"); + exit(EXIT_FAILURE); + } +#endif + return output_file; +} diff --git a/src/dep/src/irrlicht/jpeglib/cdjpeg.h b/src/dep/src/irrlicht/jpeglib/cdjpeg.h index 1574e0b..2b387b6 100644 --- a/src/dep/src/irrlicht/jpeglib/cdjpeg.h +++ b/src/dep/src/irrlicht/jpeglib/cdjpeg.h @@ -1,184 +1,184 @@ -/* - * cdjpeg.h - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains common declarations for the sample applications - * cjpeg and djpeg. It is NOT used by the core JPEG library. - */ - -#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */ -#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jerror.h" /* get library error codes too */ -#include "cderror.h" /* get application-specific error codes */ - - -/* - * Object interface for cjpeg's source file decoding modules - */ - -typedef struct cjpeg_source_struct * cjpeg_source_ptr; - -struct cjpeg_source_struct { - JMETHOD(void, start_input, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); - JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); - JMETHOD(void, finish_input, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); - - FILE *input_file; - - JSAMPARRAY buffer; - JDIMENSION buffer_height; -}; - - -/* - * Object interface for djpeg's output file encoding modules - */ - -typedef struct djpeg_dest_struct * djpeg_dest_ptr; - -struct djpeg_dest_struct { - /* start_output is called after jpeg_start_decompress finishes. - * The color map will be ready at this time, if one is needed. - */ - JMETHOD(void, start_output, (j_decompress_ptr cinfo, - djpeg_dest_ptr dinfo)); - /* Emit the specified number of pixel rows from the buffer. */ - JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo, - djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied)); - /* Finish up at the end of the image. */ - JMETHOD(void, finish_output, (j_decompress_ptr cinfo, - djpeg_dest_ptr dinfo)); - - /* Target file spec; filled in by djpeg.c after object is created. */ - FILE * output_file; - - /* Output pixel-row buffer. Created by module init or start_output. - * Width is cinfo->output_width * cinfo->output_components; - * height is buffer_height. - */ - JSAMPARRAY buffer; - JDIMENSION buffer_height; -}; - - -/* - * cjpeg/djpeg may need to perform extra passes to convert to or from - * the source/destination file format. The JPEG library does not know - * about these passes, but we'd like them to be counted by the progress - * monitor. We use an expanded progress monitor object to hold the - * additional pass count. - */ - -struct cdjpeg_progress_mgr { - struct jpeg_progress_mgr pub; /* fields known to JPEG library */ - int completed_extra_passes; /* extra passes completed */ - int total_extra_passes; /* total extra */ - /* last printed percentage stored here to avoid multiple printouts */ - int percent_done; -}; - -typedef struct cdjpeg_progress_mgr * cd_progress_ptr; - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jinit_read_bmp jIRdBMP -#define jinit_write_bmp jIWrBMP -#define jinit_read_gif jIRdGIF -#define jinit_write_gif jIWrGIF -#define jinit_read_ppm jIRdPPM -#define jinit_write_ppm jIWrPPM -#define jinit_read_rle jIRdRLE -#define jinit_write_rle jIWrRLE -#define jinit_read_targa jIRdTarga -#define jinit_write_targa jIWrTarga -#define read_quant_tables RdQTables -#define read_scan_script RdScnScript -#define set_quant_slots SetQSlots -#define set_sample_factors SetSFacts -#define read_color_map RdCMap -#define enable_signal_catcher EnSigCatcher -#define start_progress_monitor StProgMon -#define end_progress_monitor EnProgMon -#define read_stdin RdStdin -#define write_stdout WrStdout -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Module selection routines for I/O modules. */ - -EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo, - boolean is_os2)); -EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo)); -EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo)); -EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo)); -EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo)); - -/* cjpeg support routines (in rdswitch.c) */ - -EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename, - int scale_factor, boolean force_baseline)); -EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename)); -EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg)); -EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg)); - -/* djpeg support routines (in rdcolmap.c) */ - -EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile)); - -/* common support routines (in cdjpeg.c) */ - -EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo)); -EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo, - cd_progress_ptr progress)); -EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo)); -EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars)); -EXTERN(FILE *) read_stdin JPP((void)); -EXTERN(FILE *) write_stdout JPP((void)); - -/* miscellaneous useful macros */ - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#define WRITE_BINARY "w" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#define WRITE_BINARY "wb", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#define WRITE_BINARY "wb" -#endif -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif -#ifndef EXIT_SUCCESS -#ifdef VMS -#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ -#else -#define EXIT_SUCCESS 0 -#endif -#endif -#ifndef EXIT_WARNING -#ifdef VMS -#define EXIT_WARNING 1 /* VMS is very nonstandard */ -#else -#define EXIT_WARNING 2 -#endif -#endif +/* + * cdjpeg.h + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains common declarations for the sample applications + * cjpeg and djpeg. It is NOT used by the core JPEG library. + */ + +#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */ +#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jerror.h" /* get library error codes too */ +#include "cderror.h" /* get application-specific error codes */ + + +/* + * Object interface for cjpeg's source file decoding modules + */ + +typedef struct cjpeg_source_struct * cjpeg_source_ptr; + +struct cjpeg_source_struct { + JMETHOD(void, start_input, (j_compress_ptr cinfo, + cjpeg_source_ptr sinfo)); + JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, + cjpeg_source_ptr sinfo)); + JMETHOD(void, finish_input, (j_compress_ptr cinfo, + cjpeg_source_ptr sinfo)); + + FILE *input_file; + + JSAMPARRAY buffer; + JDIMENSION buffer_height; +}; + + +/* + * Object interface for djpeg's output file encoding modules + */ + +typedef struct djpeg_dest_struct * djpeg_dest_ptr; + +struct djpeg_dest_struct { + /* start_output is called after jpeg_start_decompress finishes. + * The color map will be ready at this time, if one is needed. + */ + JMETHOD(void, start_output, (j_decompress_ptr cinfo, + djpeg_dest_ptr dinfo)); + /* Emit the specified number of pixel rows from the buffer. */ + JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo, + djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied)); + /* Finish up at the end of the image. */ + JMETHOD(void, finish_output, (j_decompress_ptr cinfo, + djpeg_dest_ptr dinfo)); + + /* Target file spec; filled in by djpeg.c after object is created. */ + FILE * output_file; + + /* Output pixel-row buffer. Created by module init or start_output. + * Width is cinfo->output_width * cinfo->output_components; + * height is buffer_height. + */ + JSAMPARRAY buffer; + JDIMENSION buffer_height; +}; + + +/* + * cjpeg/djpeg may need to perform extra passes to convert to or from + * the source/destination file format. The JPEG library does not know + * about these passes, but we'd like them to be counted by the progress + * monitor. We use an expanded progress monitor object to hold the + * additional pass count. + */ + +struct cdjpeg_progress_mgr { + struct jpeg_progress_mgr pub; /* fields known to JPEG library */ + int completed_extra_passes; /* extra passes completed */ + int total_extra_passes; /* total extra */ + /* last printed percentage stored here to avoid multiple printouts */ + int percent_done; +}; + +typedef struct cdjpeg_progress_mgr * cd_progress_ptr; + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jinit_read_bmp jIRdBMP +#define jinit_write_bmp jIWrBMP +#define jinit_read_gif jIRdGIF +#define jinit_write_gif jIWrGIF +#define jinit_read_ppm jIRdPPM +#define jinit_write_ppm jIWrPPM +#define jinit_read_rle jIRdRLE +#define jinit_write_rle jIWrRLE +#define jinit_read_targa jIRdTarga +#define jinit_write_targa jIWrTarga +#define read_quant_tables RdQTables +#define read_scan_script RdScnScript +#define set_quant_slots SetQSlots +#define set_sample_factors SetSFacts +#define read_color_map RdCMap +#define enable_signal_catcher EnSigCatcher +#define start_progress_monitor StProgMon +#define end_progress_monitor EnProgMon +#define read_stdin RdStdin +#define write_stdout WrStdout +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + +/* Module selection routines for I/O modules. */ + +EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo, + boolean is_os2)); +EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo)); +EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo)); +EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo)); +EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo)); + +/* cjpeg support routines (in rdswitch.c) */ + +EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename, + int scale_factor, boolean force_baseline)); +EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename)); +EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg)); +EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg)); + +/* djpeg support routines (in rdcolmap.c) */ + +EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile)); + +/* common support routines (in cdjpeg.c) */ + +EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo)); +EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo, + cd_progress_ptr progress)); +EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo)); +EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars)); +EXTERN(FILE *) read_stdin JPP((void)); +EXTERN(FILE *) write_stdout JPP((void)); + +/* miscellaneous useful macros */ + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#define WRITE_BINARY "w" +#else +#ifdef VMS /* VMS is very nonstandard */ +#define READ_BINARY "rb", "ctx=stm" +#define WRITE_BINARY "wb", "ctx=stm" +#else /* standard ANSI-compliant case */ +#define READ_BINARY "rb" +#define WRITE_BINARY "wb" +#endif +#endif + +#ifndef EXIT_FAILURE /* define exit() codes if not provided */ +#define EXIT_FAILURE 1 +#endif +#ifndef EXIT_SUCCESS +#ifdef VMS +#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ +#else +#define EXIT_SUCCESS 0 +#endif +#endif +#ifndef EXIT_WARNING +#ifdef VMS +#define EXIT_WARNING 1 /* VMS is very nonstandard */ +#else +#define EXIT_WARNING 2 +#endif +#endif diff --git a/src/dep/src/irrlicht/jpeglib/change.log b/src/dep/src/irrlicht/jpeglib/change.log index 953680c..74102c0 100644 --- a/src/dep/src/irrlicht/jpeglib/change.log +++ b/src/dep/src/irrlicht/jpeglib/change.log @@ -1,217 +1,217 @@ -CHANGE LOG for Independent JPEG Group's JPEG software - - -Version 6b 27-Mar-1998 ------------------------ - -jpegtran has new features for lossless image transformations (rotation -and flipping) as well as "lossless" reduction to grayscale. - -jpegtran now copies comments by default; it has a -copy switch to enable -copying all APPn blocks as well, or to suppress comments. (Formerly it -always suppressed comments and APPn blocks.) jpegtran now also preserves -JFIF version and resolution information. - -New decompressor library feature: COM and APPn markers found in the input -file can be saved in memory for later use by the application. (Before, -you had to code this up yourself with a custom marker processor.) - -There is an unused field "void * client_data" now in compress and decompress -parameter structs; this may be useful in some applications. - -JFIF version number information is now saved by the decoder and accepted by -the encoder. jpegtran uses this to copy the source file's version number, -to ensure "jpegtran -copy all" won't create bogus files that contain JFXX -extensions but claim to be version 1.01. Applications that generate their -own JFXX extension markers also (finally) have a supported way to cause the -encoder to emit JFIF version number 1.02. - -djpeg's trace mode reports JFIF 1.02 thumbnail images as such, rather -than as unknown APP0 markers. - -In -verbose mode, djpeg and rdjpgcom will try to print the contents of -APP12 markers as text. Some digital cameras store useful text information -in APP12 markers. - -Handling of truncated data streams is more robust: blocks beyond the one in -which the error occurs will be output as uniform gray, or left unchanged -if decoding a progressive JPEG. The appearance no longer depends on the -Huffman tables being used. - -Huffman tables are checked for validity much more carefully than before. - -To avoid the Unisys LZW patent, djpeg's GIF output capability has been -changed to produce "uncompressed GIFs", and cjpeg's GIF input capability -has been removed altogether. We're not happy about it either, but there -seems to be no good alternative. - -The configure script now supports building libjpeg as a shared library -on many flavors of Unix (all the ones that GNU libtool knows how to -build shared libraries for). Use "./configure --enable-shared" to -try this out. - -New jconfig file and makefiles for Microsoft Visual C++ and Developer Studio. -Also, a jconfig file and a build script for Metrowerks CodeWarrior -on Apple Macintosh. makefile.dj has been updated for DJGPP v2, and there -are miscellaneous other minor improvements in the makefiles. - -jmemmac.c now knows how to create temporary files following Mac System 7 -conventions. - -djpeg's -map switch is now able to read raw-format PPM files reliably. - -cjpeg -progressive -restart no longer generates any unnecessary DRI markers. - -Multiple calls to jpeg_simple_progression for a single JPEG object -no longer leak memory. - - -Version 6a 7-Feb-96 --------------------- - -Library initialization sequence modified to detect version mismatches -and struct field packing mismatches between library and calling application. -This change requires applications to be recompiled, but does not require -any application source code change. - -All routine declarations changed to the style "GLOBAL(type) name ...", -that is, GLOBAL, LOCAL, METHODDEF, EXTERN are now macros taking the -routine's return type as an argument. This makes it possible to add -Microsoft-style linkage keywords to all the routines by changing just -these macros. Note that any application code that was using these macros -will have to be changed. - -DCT coefficient quantization tables are now stored in normal array order -rather than zigzag order. Application code that calls jpeg_add_quant_table, -or otherwise manipulates quantization tables directly, will need to be -changed. If you need to make such code work with either older or newer -versions of the library, a test like "#if JPEG_LIB_VERSION >= 61" is -recommended. - -djpeg's trace capability now dumps DQT tables in natural order, not zigzag -order. This allows the trace output to be made into a "-qtables" file -more easily. - -New system-dependent memory manager module for use on Apple Macintosh. - -Fix bug in cjpeg's -smooth option: last one or two scanlines would be -duplicates of the prior line unless the image height mod 16 was 1 or 2. - -Repair minor problems in VMS, BCC, MC6 makefiles. - -New configure script based on latest GNU Autoconf. - -Correct the list of include files needed by MetroWerks C for ccommand(). - -Numerous small documentation updates. - - -Version 6 2-Aug-95 -------------------- - -Progressive JPEG support: library can read and write full progressive JPEG -files. A "buffered image" mode supports incremental decoding for on-the-fly -display of progressive images. Simply recompiling an existing IJG-v5-based -decoder with v6 should allow it to read progressive files, though of course -without any special progressive display. - -New "jpegtran" application performs lossless transcoding between different -JPEG formats; primarily, it can be used to convert baseline to progressive -JPEG and vice versa. In support of jpegtran, the library now allows lossless -reading and writing of JPEG files as DCT coefficient arrays. This ability -may be of use in other applications. - -Notes for programmers: -* We changed jpeg_start_decompress() to be able to suspend; this makes all -decoding modes available to suspending-input applications. However, -existing applications that use suspending input will need to be changed -to check the return value from jpeg_start_decompress(). You don't need to -do anything if you don't use a suspending data source. -* We changed the interface to the virtual array routines: access_virt_array -routines now take a count of the number of rows to access this time. The -last parameter to request_virt_array routines is now interpreted as the -maximum number of rows that may be accessed at once, but not necessarily -the height of every access. - - -Version 5b 15-Mar-95 ---------------------- - -Correct bugs with grayscale images having v_samp_factor > 1. - -jpeg_write_raw_data() now supports output suspension. - -Correct bugs in "configure" script for case of compiling in -a directory other than the one containing the source files. - -Repair bug in jquant1.c: sometimes didn't use as many colors as it could. - -Borland C makefile and jconfig file work under either MS-DOS or OS/2. - -Miscellaneous improvements to documentation. - - -Version 5a 7-Dec-94 --------------------- - -Changed color conversion roundoff behavior so that grayscale values are -represented exactly. (This causes test image files to change.) - -Make ordered dither use 16x16 instead of 4x4 pattern for a small quality -improvement. - -New configure script based on latest GNU Autoconf. -Fix configure script to handle CFLAGS correctly. -Rename *.auto files to *.cfg, so that configure script still works if -file names have been truncated for DOS. - -Fix bug in rdbmp.c: didn't allow for extra data between header and image. - -Modify rdppm.c/wrppm.c to handle 2-byte raw PPM/PGM formats for 12-bit data. - -Fix several bugs in rdrle.c. - -NEED_SHORT_EXTERNAL_NAMES option was broken. - -Revise jerror.h/jerror.c for more flexibility in message table. - -Repair oversight in jmemname.c NO_MKTEMP case: file could be there -but unreadable. - - -Version 5 24-Sep-94 --------------------- - -Version 5 represents a nearly complete redesign and rewrite of the IJG -software. Major user-visible changes include: - * Automatic configuration simplifies installation for most Unix systems. - * A range of speed vs. image quality tradeoffs are supported. - This includes resizing of an image during decompression: scaling down - by a factor of 1/2, 1/4, or 1/8 is handled very efficiently. - * New programs rdjpgcom and wrjpgcom allow insertion and extraction - of text comments in a JPEG file. - -The application programmer's interface to the library has changed completely. -Notable improvements include: - * We have eliminated the use of callback routines for handling the - uncompressed image data. The application now sees the library as a - set of routines that it calls to read or write image data on a - scanline-by-scanline basis. - * The application image data is represented in a conventional interleaved- - pixel format, rather than as a separate array for each color channel. - This can save a copying step in many programs. - * The handling of compressed data has been cleaned up: the application can - supply routines to source or sink the compressed data. It is possible to - suspend processing on source/sink buffer overrun, although this is not - supported in all operating modes. - * All static state has been eliminated from the library, so that multiple - instances of compression or decompression can be active concurrently. - * JPEG abbreviated datastream formats are supported, ie, quantization and - Huffman tables can be stored separately from the image data. - * And not only that, but the documentation of the library has improved - considerably! - - -The last widely used release before the version 5 rewrite was version 4A of -18-Feb-93. Change logs before that point have been discarded, since they -are not of much interest after the rewrite. +CHANGE LOG for Independent JPEG Group's JPEG software + + +Version 6b 27-Mar-1998 +----------------------- + +jpegtran has new features for lossless image transformations (rotation +and flipping) as well as "lossless" reduction to grayscale. + +jpegtran now copies comments by default; it has a -copy switch to enable +copying all APPn blocks as well, or to suppress comments. (Formerly it +always suppressed comments and APPn blocks.) jpegtran now also preserves +JFIF version and resolution information. + +New decompressor library feature: COM and APPn markers found in the input +file can be saved in memory for later use by the application. (Before, +you had to code this up yourself with a custom marker processor.) + +There is an unused field "void * client_data" now in compress and decompress +parameter structs; this may be useful in some applications. + +JFIF version number information is now saved by the decoder and accepted by +the encoder. jpegtran uses this to copy the source file's version number, +to ensure "jpegtran -copy all" won't create bogus files that contain JFXX +extensions but claim to be version 1.01. Applications that generate their +own JFXX extension markers also (finally) have a supported way to cause the +encoder to emit JFIF version number 1.02. + +djpeg's trace mode reports JFIF 1.02 thumbnail images as such, rather +than as unknown APP0 markers. + +In -verbose mode, djpeg and rdjpgcom will try to print the contents of +APP12 markers as text. Some digital cameras store useful text information +in APP12 markers. + +Handling of truncated data streams is more robust: blocks beyond the one in +which the error occurs will be output as uniform gray, or left unchanged +if decoding a progressive JPEG. The appearance no longer depends on the +Huffman tables being used. + +Huffman tables are checked for validity much more carefully than before. + +To avoid the Unisys LZW patent, djpeg's GIF output capability has been +changed to produce "uncompressed GIFs", and cjpeg's GIF input capability +has been removed altogether. We're not happy about it either, but there +seems to be no good alternative. + +The configure script now supports building libjpeg as a shared library +on many flavors of Unix (all the ones that GNU libtool knows how to +build shared libraries for). Use "./configure --enable-shared" to +try this out. + +New jconfig file and makefiles for Microsoft Visual C++ and Developer Studio. +Also, a jconfig file and a build script for Metrowerks CodeWarrior +on Apple Macintosh. makefile.dj has been updated for DJGPP v2, and there +are miscellaneous other minor improvements in the makefiles. + +jmemmac.c now knows how to create temporary files following Mac System 7 +conventions. + +djpeg's -map switch is now able to read raw-format PPM files reliably. + +cjpeg -progressive -restart no longer generates any unnecessary DRI markers. + +Multiple calls to jpeg_simple_progression for a single JPEG object +no longer leak memory. + + +Version 6a 7-Feb-96 +-------------------- + +Library initialization sequence modified to detect version mismatches +and struct field packing mismatches between library and calling application. +This change requires applications to be recompiled, but does not require +any application source code change. + +All routine declarations changed to the style "GLOBAL(type) name ...", +that is, GLOBAL, LOCAL, METHODDEF, EXTERN are now macros taking the +routine's return type as an argument. This makes it possible to add +Microsoft-style linkage keywords to all the routines by changing just +these macros. Note that any application code that was using these macros +will have to be changed. + +DCT coefficient quantization tables are now stored in normal array order +rather than zigzag order. Application code that calls jpeg_add_quant_table, +or otherwise manipulates quantization tables directly, will need to be +changed. If you need to make such code work with either older or newer +versions of the library, a test like "#if JPEG_LIB_VERSION >= 61" is +recommended. + +djpeg's trace capability now dumps DQT tables in natural order, not zigzag +order. This allows the trace output to be made into a "-qtables" file +more easily. + +New system-dependent memory manager module for use on Apple Macintosh. + +Fix bug in cjpeg's -smooth option: last one or two scanlines would be +duplicates of the prior line unless the image height mod 16 was 1 or 2. + +Repair minor problems in VMS, BCC, MC6 makefiles. + +New configure script based on latest GNU Autoconf. + +Correct the list of include files needed by MetroWerks C for ccommand(). + +Numerous small documentation updates. + + +Version 6 2-Aug-95 +------------------- + +Progressive JPEG support: library can read and write full progressive JPEG +files. A "buffered image" mode supports incremental decoding for on-the-fly +display of progressive images. Simply recompiling an existing IJG-v5-based +decoder with v6 should allow it to read progressive files, though of course +without any special progressive display. + +New "jpegtran" application performs lossless transcoding between different +JPEG formats; primarily, it can be used to convert baseline to progressive +JPEG and vice versa. In support of jpegtran, the library now allows lossless +reading and writing of JPEG files as DCT coefficient arrays. This ability +may be of use in other applications. + +Notes for programmers: +* We changed jpeg_start_decompress() to be able to suspend; this makes all +decoding modes available to suspending-input applications. However, +existing applications that use suspending input will need to be changed +to check the return value from jpeg_start_decompress(). You don't need to +do anything if you don't use a suspending data source. +* We changed the interface to the virtual array routines: access_virt_array +routines now take a count of the number of rows to access this time. The +last parameter to request_virt_array routines is now interpreted as the +maximum number of rows that may be accessed at once, but not necessarily +the height of every access. + + +Version 5b 15-Mar-95 +--------------------- + +Correct bugs with grayscale images having v_samp_factor > 1. + +jpeg_write_raw_data() now supports output suspension. + +Correct bugs in "configure" script for case of compiling in +a directory other than the one containing the source files. + +Repair bug in jquant1.c: sometimes didn't use as many colors as it could. + +Borland C makefile and jconfig file work under either MS-DOS or OS/2. + +Miscellaneous improvements to documentation. + + +Version 5a 7-Dec-94 +-------------------- + +Changed color conversion roundoff behavior so that grayscale values are +represented exactly. (This causes test image files to change.) + +Make ordered dither use 16x16 instead of 4x4 pattern for a small quality +improvement. + +New configure script based on latest GNU Autoconf. +Fix configure script to handle CFLAGS correctly. +Rename *.auto files to *.cfg, so that configure script still works if +file names have been truncated for DOS. + +Fix bug in rdbmp.c: didn't allow for extra data between header and image. + +Modify rdppm.c/wrppm.c to handle 2-byte raw PPM/PGM formats for 12-bit data. + +Fix several bugs in rdrle.c. + +NEED_SHORT_EXTERNAL_NAMES option was broken. + +Revise jerror.h/jerror.c for more flexibility in message table. + +Repair oversight in jmemname.c NO_MKTEMP case: file could be there +but unreadable. + + +Version 5 24-Sep-94 +-------------------- + +Version 5 represents a nearly complete redesign and rewrite of the IJG +software. Major user-visible changes include: + * Automatic configuration simplifies installation for most Unix systems. + * A range of speed vs. image quality tradeoffs are supported. + This includes resizing of an image during decompression: scaling down + by a factor of 1/2, 1/4, or 1/8 is handled very efficiently. + * New programs rdjpgcom and wrjpgcom allow insertion and extraction + of text comments in a JPEG file. + +The application programmer's interface to the library has changed completely. +Notable improvements include: + * We have eliminated the use of callback routines for handling the + uncompressed image data. The application now sees the library as a + set of routines that it calls to read or write image data on a + scanline-by-scanline basis. + * The application image data is represented in a conventional interleaved- + pixel format, rather than as a separate array for each color channel. + This can save a copying step in many programs. + * The handling of compressed data has been cleaned up: the application can + supply routines to source or sink the compressed data. It is possible to + suspend processing on source/sink buffer overrun, although this is not + supported in all operating modes. + * All static state has been eliminated from the library, so that multiple + instances of compression or decompression can be active concurrently. + * JPEG abbreviated datastream formats are supported, ie, quantization and + Huffman tables can be stored separately from the image data. + * And not only that, but the documentation of the library has improved + considerably! + + +The last widely used release before the version 5 rewrite was version 4A of +18-Feb-93. Change logs before that point have been discarded, since they +are not of much interest after the rewrite. diff --git a/src/dep/src/irrlicht/jpeglib/cjpeg.1 b/src/dep/src/irrlicht/jpeglib/cjpeg.1 index cf6a5b2..d175a96 100644 --- a/src/dep/src/irrlicht/jpeglib/cjpeg.1 +++ b/src/dep/src/irrlicht/jpeglib/cjpeg.1 @@ -1,292 +1,292 @@ -.TH CJPEG 1 "20 March 1998" -.SH NAME -cjpeg \- compress an image file to a JPEG file -.SH SYNOPSIS -.B cjpeg -[ -.I options -] -[ -.I filename -] -.LP -.SH DESCRIPTION -.LP -.B cjpeg -compresses the named image file, or the standard input if no file is -named, and produces a JPEG/JFIF file on the standard output. -The currently supported input file formats are: PPM (PBMPLUS color -format), PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster -Toolkit format). (RLE is supported only if the URT library is available.) -.SH OPTIONS -All switch names may be abbreviated; for example, -.B \-grayscale -may be written -.B \-gray -or -.BR \-gr . -Most of the "basic" switches can be abbreviated to as little as one letter. -Upper and lower case are equivalent (thus -.B \-BMP -is the same as -.BR \-bmp ). -British spellings are also accepted (e.g., -.BR \-greyscale ), -though for brevity these are not mentioned below. -.PP -The basic switches are: -.TP -.BI \-quality " N" -Scale quantization tables to adjust image quality. Quality is 0 (worst) to -100 (best); default is 75. (See below for more info.) -.TP -.B \-grayscale -Create monochrome JPEG file from color input. Be sure to use this switch when -compressing a grayscale BMP file, because -.B cjpeg -isn't bright enough to notice whether a BMP file uses only shades of gray. -By saying -.BR \-grayscale , -you'll get a smaller JPEG file that takes less time to process. -.TP -.B \-optimize -Perform optimization of entropy encoding parameters. Without this, default -encoding parameters are used. -.B \-optimize -usually makes the JPEG file a little smaller, but -.B cjpeg -runs somewhat slower and needs much more memory. Image quality and speed of -decompression are unaffected by -.BR \-optimize . -.TP -.B \-progressive -Create progressive JPEG file (see below). -.TP -.B \-targa -Input file is Targa format. Targa files that contain an "identification" -field will not be automatically recognized by -.BR cjpeg ; -for such files you must specify -.B \-targa -to make -.B cjpeg -treat the input as Targa format. -For most Targa files, you won't need this switch. -.PP -The -.B \-quality -switch lets you trade off compressed file size against quality of the -reconstructed image: the higher the quality setting, the larger the JPEG file, -and the closer the output image will be to the original input. Normally you -want to use the lowest quality setting (smallest file) that decompresses into -something visually indistinguishable from the original image. For this -purpose the quality setting should be between 50 and 95; the default of 75 is -often about right. If you see defects at -.B \-quality -75, then go up 5 or 10 counts at a time until you are happy with the output -image. (The optimal setting will vary from one image to another.) -.PP -.B \-quality -100 will generate a quantization table of all 1's, minimizing loss in the -quantization step (but there is still information loss in subsampling, as well -as roundoff error). This setting is mainly of interest for experimental -purposes. Quality values above about 95 are -.B not -recommended for normal use; the compressed file size goes up dramatically for -hardly any gain in output image quality. -.PP -In the other direction, quality values below 50 will produce very small files -of low image quality. Settings around 5 to 10 might be useful in preparing an -index of a large image library, for example. Try -.B \-quality -2 (or so) for some amusing Cubist effects. (Note: quality -values below about 25 generate 2-byte quantization tables, which are -considered optional in the JPEG standard. -.B cjpeg -emits a warning message when you give such a quality value, because some -other JPEG programs may be unable to decode the resulting file. Use -.B \-baseline -if you need to ensure compatibility at low quality values.) -.PP -The -.B \-progressive -switch creates a "progressive JPEG" file. In this type of JPEG file, the data -is stored in multiple scans of increasing quality. If the file is being -transmitted over a slow communications link, the decoder can use the first -scan to display a low-quality image very quickly, and can then improve the -display with each subsequent scan. The final image is exactly equivalent to a -standard JPEG file of the same quality setting, and the total file size is -about the same --- often a little smaller. -.B Caution: -progressive JPEG is not yet widely implemented, so many decoders will be -unable to view a progressive JPEG file at all. -.PP -Switches for advanced users: -.TP -.B \-dct int -Use integer DCT method (default). -.TP -.B \-dct fast -Use fast integer DCT (less accurate). -.TP -.B \-dct float -Use floating-point DCT method. -The float method is very slightly more accurate than the int method, but is -much slower unless your machine has very fast floating-point hardware. Also -note that results of the floating-point method may vary slightly across -machines, while the integer methods should give the same results everywhere. -The fast integer method is much less accurate than the other two. -.TP -.BI \-restart " N" -Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is -attached to the number. -.B \-restart 0 -(the default) means no restart markers. -.TP -.BI \-smooth " N" -Smooth the input image to eliminate dithering noise. N, ranging from 1 to -100, indicates the strength of smoothing. 0 (the default) means no smoothing. -.TP -.BI \-maxmemory " N" -Set limit for amount of memory to use in processing large images. Value is -in thousands of bytes, or millions of bytes if "M" is attached to the -number. For example, -.B \-max 4m -selects 4000000 bytes. If more space is needed, temporary files will be used. -.TP -.BI \-outfile " name" -Send output image to the named file, not to standard output. -.TP -.B \-verbose -Enable debug printout. More -.BR \-v 's -give more output. Also, version information is printed at startup. -.TP -.B \-debug -Same as -.BR \-verbose . -.PP -The -.B \-restart -option inserts extra markers that allow a JPEG decoder to resynchronize after -a transmission error. Without restart markers, any damage to a compressed -file will usually ruin the image from the point of the error to the end of the -image; with restart markers, the damage is usually confined to the portion of -the image up to the next restart marker. Of course, the restart markers -occupy extra space. We recommend -.B \-restart 1 -for images that will be transmitted across unreliable networks such as Usenet. -.PP -The -.B \-smooth -option filters the input to eliminate fine-scale noise. This is often useful -when converting dithered images to JPEG: a moderate smoothing factor of 10 to -50 gets rid of dithering patterns in the input file, resulting in a smaller -JPEG file and a better-looking image. Too large a smoothing factor will -visibly blur the image, however. -.PP -Switches for wizards: -.TP -.B \-baseline -Force baseline-compatible quantization tables to be generated. This clamps -quantization values to 8 bits even at low quality settings. (This switch is -poorly named, since it does not ensure that the output is actually baseline -JPEG. For example, you can use -.B \-baseline -and -.B \-progressive -together.) -.TP -.BI \-qtables " file" -Use the quantization tables given in the specified text file. -.TP -.BI \-qslots " N[,...]" -Select which quantization table to use for each color component. -.TP -.BI \-sample " HxV[,...]" -Set JPEG sampling factors for each color component. -.TP -.BI \-scans " file" -Use the scan script given in the specified text file. -.PP -The "wizard" switches are intended for experimentation with JPEG. If you -don't know what you are doing, \fBdon't use them\fR. These switches are -documented further in the file wizard.doc. -.SH EXAMPLES -.LP -This example compresses the PPM file foo.ppm with a quality factor of -60 and saves the output as foo.jpg: -.IP -.B cjpeg \-quality -.I 60 foo.ppm -.B > -.I foo.jpg -.SH HINTS -Color GIF files are not the ideal input for JPEG; JPEG is really intended for -compressing full-color (24-bit) images. In particular, don't try to convert -cartoons, line drawings, and other images that have only a few distinct -colors. GIF works great on these, JPEG does not. If you want to convert a -GIF to JPEG, you should experiment with -.BR cjpeg 's -.B \-quality -and -.B \-smooth -options to get a satisfactory conversion. -.B \-smooth 10 -or so is often helpful. -.PP -Avoid running an image through a series of JPEG compression/decompression -cycles. Image quality loss will accumulate; after ten or so cycles the image -may be noticeably worse than it was after one cycle. It's best to use a -lossless format while manipulating an image, then convert to JPEG format when -you are ready to file the image away. -.PP -The -.B \-optimize -option to -.B cjpeg -is worth using when you are making a "final" version for posting or archiving. -It's also a win when you are using low quality settings to make very small -JPEG files; the percentage improvement is often a lot more than it is on -larger files. (At present, -.B \-optimize -mode is always selected when generating progressive JPEG files.) -.SH ENVIRONMENT -.TP -.B JPEGMEM -If this environment variable is set, its value is the default memory limit. -The value is specified as described for the -.B \-maxmemory -switch. -.B JPEGMEM -overrides the default value specified when the program was compiled, and -itself is overridden by an explicit -.BR \-maxmemory . -.SH SEE ALSO -.BR djpeg (1), -.BR jpegtran (1), -.BR rdjpgcom (1), -.BR wrjpgcom (1) -.br -.BR ppm (5), -.BR pgm (5) -.br -Wallace, Gregory K. "The JPEG Still Picture Compression Standard", -Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. -.SH AUTHOR -Independent JPEG Group -.SH BUGS -Arithmetic coding is not supported for legal reasons. -.PP -GIF input files are no longer supported, to avoid the Unisys LZW patent. -Use a Unisys-licensed program if you need to read a GIF file. (Conversion -of GIF files to JPEG is usually a bad idea anyway.) -.PP -Not all variants of BMP and Targa file formats are supported. -.PP -The -.B \-targa -switch is not a bug, it's a feature. (It would be a bug if the Targa format -designers had not been clueless.) -.PP -Still not as fast as we'd like. +.TH CJPEG 1 "20 March 1998" +.SH NAME +cjpeg \- compress an image file to a JPEG file +.SH SYNOPSIS +.B cjpeg +[ +.I options +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B cjpeg +compresses the named image file, or the standard input if no file is +named, and produces a JPEG/JFIF file on the standard output. +The currently supported input file formats are: PPM (PBMPLUS color +format), PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster +Toolkit format). (RLE is supported only if the URT library is available.) +.SH OPTIONS +All switch names may be abbreviated; for example, +.B \-grayscale +may be written +.B \-gray +or +.BR \-gr . +Most of the "basic" switches can be abbreviated to as little as one letter. +Upper and lower case are equivalent (thus +.B \-BMP +is the same as +.BR \-bmp ). +British spellings are also accepted (e.g., +.BR \-greyscale ), +though for brevity these are not mentioned below. +.PP +The basic switches are: +.TP +.BI \-quality " N" +Scale quantization tables to adjust image quality. Quality is 0 (worst) to +100 (best); default is 75. (See below for more info.) +.TP +.B \-grayscale +Create monochrome JPEG file from color input. Be sure to use this switch when +compressing a grayscale BMP file, because +.B cjpeg +isn't bright enough to notice whether a BMP file uses only shades of gray. +By saying +.BR \-grayscale , +you'll get a smaller JPEG file that takes less time to process. +.TP +.B \-optimize +Perform optimization of entropy encoding parameters. Without this, default +encoding parameters are used. +.B \-optimize +usually makes the JPEG file a little smaller, but +.B cjpeg +runs somewhat slower and needs much more memory. Image quality and speed of +decompression are unaffected by +.BR \-optimize . +.TP +.B \-progressive +Create progressive JPEG file (see below). +.TP +.B \-targa +Input file is Targa format. Targa files that contain an "identification" +field will not be automatically recognized by +.BR cjpeg ; +for such files you must specify +.B \-targa +to make +.B cjpeg +treat the input as Targa format. +For most Targa files, you won't need this switch. +.PP +The +.B \-quality +switch lets you trade off compressed file size against quality of the +reconstructed image: the higher the quality setting, the larger the JPEG file, +and the closer the output image will be to the original input. Normally you +want to use the lowest quality setting (smallest file) that decompresses into +something visually indistinguishable from the original image. For this +purpose the quality setting should be between 50 and 95; the default of 75 is +often about right. If you see defects at +.B \-quality +75, then go up 5 or 10 counts at a time until you are happy with the output +image. (The optimal setting will vary from one image to another.) +.PP +.B \-quality +100 will generate a quantization table of all 1's, minimizing loss in the +quantization step (but there is still information loss in subsampling, as well +as roundoff error). This setting is mainly of interest for experimental +purposes. Quality values above about 95 are +.B not +recommended for normal use; the compressed file size goes up dramatically for +hardly any gain in output image quality. +.PP +In the other direction, quality values below 50 will produce very small files +of low image quality. Settings around 5 to 10 might be useful in preparing an +index of a large image library, for example. Try +.B \-quality +2 (or so) for some amusing Cubist effects. (Note: quality +values below about 25 generate 2-byte quantization tables, which are +considered optional in the JPEG standard. +.B cjpeg +emits a warning message when you give such a quality value, because some +other JPEG programs may be unable to decode the resulting file. Use +.B \-baseline +if you need to ensure compatibility at low quality values.) +.PP +The +.B \-progressive +switch creates a "progressive JPEG" file. In this type of JPEG file, the data +is stored in multiple scans of increasing quality. If the file is being +transmitted over a slow communications link, the decoder can use the first +scan to display a low-quality image very quickly, and can then improve the +display with each subsequent scan. The final image is exactly equivalent to a +standard JPEG file of the same quality setting, and the total file size is +about the same --- often a little smaller. +.B Caution: +progressive JPEG is not yet widely implemented, so many decoders will be +unable to view a progressive JPEG file at all. +.PP +Switches for advanced users: +.TP +.B \-dct int +Use integer DCT method (default). +.TP +.B \-dct fast +Use fast integer DCT (less accurate). +.TP +.B \-dct float +Use floating-point DCT method. +The float method is very slightly more accurate than the int method, but is +much slower unless your machine has very fast floating-point hardware. Also +note that results of the floating-point method may vary slightly across +machines, while the integer methods should give the same results everywhere. +The fast integer method is much less accurate than the other two. +.TP +.BI \-restart " N" +Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is +attached to the number. +.B \-restart 0 +(the default) means no restart markers. +.TP +.BI \-smooth " N" +Smooth the input image to eliminate dithering noise. N, ranging from 1 to +100, indicates the strength of smoothing. 0 (the default) means no smoothing. +.TP +.BI \-maxmemory " N" +Set limit for amount of memory to use in processing large images. Value is +in thousands of bytes, or millions of bytes if "M" is attached to the +number. For example, +.B \-max 4m +selects 4000000 bytes. If more space is needed, temporary files will be used. +.TP +.BI \-outfile " name" +Send output image to the named file, not to standard output. +.TP +.B \-verbose +Enable debug printout. More +.BR \-v 's +give more output. Also, version information is printed at startup. +.TP +.B \-debug +Same as +.BR \-verbose . +.PP +The +.B \-restart +option inserts extra markers that allow a JPEG decoder to resynchronize after +a transmission error. Without restart markers, any damage to a compressed +file will usually ruin the image from the point of the error to the end of the +image; with restart markers, the damage is usually confined to the portion of +the image up to the next restart marker. Of course, the restart markers +occupy extra space. We recommend +.B \-restart 1 +for images that will be transmitted across unreliable networks such as Usenet. +.PP +The +.B \-smooth +option filters the input to eliminate fine-scale noise. This is often useful +when converting dithered images to JPEG: a moderate smoothing factor of 10 to +50 gets rid of dithering patterns in the input file, resulting in a smaller +JPEG file and a better-looking image. Too large a smoothing factor will +visibly blur the image, however. +.PP +Switches for wizards: +.TP +.B \-baseline +Force baseline-compatible quantization tables to be generated. This clamps +quantization values to 8 bits even at low quality settings. (This switch is +poorly named, since it does not ensure that the output is actually baseline +JPEG. For example, you can use +.B \-baseline +and +.B \-progressive +together.) +.TP +.BI \-qtables " file" +Use the quantization tables given in the specified text file. +.TP +.BI \-qslots " N[,...]" +Select which quantization table to use for each color component. +.TP +.BI \-sample " HxV[,...]" +Set JPEG sampling factors for each color component. +.TP +.BI \-scans " file" +Use the scan script given in the specified text file. +.PP +The "wizard" switches are intended for experimentation with JPEG. If you +don't know what you are doing, \fBdon't use them\fR. These switches are +documented further in the file wizard.doc. +.SH EXAMPLES +.LP +This example compresses the PPM file foo.ppm with a quality factor of +60 and saves the output as foo.jpg: +.IP +.B cjpeg \-quality +.I 60 foo.ppm +.B > +.I foo.jpg +.SH HINTS +Color GIF files are not the ideal input for JPEG; JPEG is really intended for +compressing full-color (24-bit) images. In particular, don't try to convert +cartoons, line drawings, and other images that have only a few distinct +colors. GIF works great on these, JPEG does not. If you want to convert a +GIF to JPEG, you should experiment with +.BR cjpeg 's +.B \-quality +and +.B \-smooth +options to get a satisfactory conversion. +.B \-smooth 10 +or so is often helpful. +.PP +Avoid running an image through a series of JPEG compression/decompression +cycles. Image quality loss will accumulate; after ten or so cycles the image +may be noticeably worse than it was after one cycle. It's best to use a +lossless format while manipulating an image, then convert to JPEG format when +you are ready to file the image away. +.PP +The +.B \-optimize +option to +.B cjpeg +is worth using when you are making a "final" version for posting or archiving. +It's also a win when you are using low quality settings to make very small +JPEG files; the percentage improvement is often a lot more than it is on +larger files. (At present, +.B \-optimize +mode is always selected when generating progressive JPEG files.) +.SH ENVIRONMENT +.TP +.B JPEGMEM +If this environment variable is set, its value is the default memory limit. +The value is specified as described for the +.B \-maxmemory +switch. +.B JPEGMEM +overrides the default value specified when the program was compiled, and +itself is overridden by an explicit +.BR \-maxmemory . +.SH SEE ALSO +.BR djpeg (1), +.BR jpegtran (1), +.BR rdjpgcom (1), +.BR wrjpgcom (1) +.br +.BR ppm (5), +.BR pgm (5) +.br +Wallace, Gregory K. "The JPEG Still Picture Compression Standard", +Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. +.SH AUTHOR +Independent JPEG Group +.SH BUGS +Arithmetic coding is not supported for legal reasons. +.PP +GIF input files are no longer supported, to avoid the Unisys LZW patent. +Use a Unisys-licensed program if you need to read a GIF file. (Conversion +of GIF files to JPEG is usually a bad idea anyway.) +.PP +Not all variants of BMP and Targa file formats are supported. +.PP +The +.B \-targa +switch is not a bug, it's a feature. (It would be a bug if the Targa format +designers had not been clueless.) +.PP +Still not as fast as we'd like. diff --git a/src/dep/src/irrlicht/jpeglib/cjpeg.c b/src/dep/src/irrlicht/jpeglib/cjpeg.c index b9102ee..f2a929f 100644 --- a/src/dep/src/irrlicht/jpeglib/cjpeg.c +++ b/src/dep/src/irrlicht/jpeglib/cjpeg.c @@ -1,606 +1,606 @@ -/* - * cjpeg.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a command-line user interface for the JPEG compressor. - * It should work on any system with Unix- or MS-DOS-style command lines. - * - * Two different command line styles are permitted, depending on the - * compile-time switch TWO_FILE_COMMANDLINE: - * cjpeg [options] inputfile outputfile - * cjpeg [options] [inputfile] - * In the second style, output is always to standard output, which you'd - * normally redirect to a file or pipe to some other program. Input is - * either from a named file or from standard input (typically redirected). - * The second style is convenient on Unix but is unhelpful on systems that - * don't support pipes. Also, you MUST use the first style if your system - * doesn't do binary I/O to stdin/stdout. - * To simplify script writing, the "-outfile" switch is provided. The syntax - * cjpeg [options] -outfile outputfile inputfile - * works regardless of which command line style is used. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include "jversion.h" /* for version message */ - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - - -/* Create the add-on message string table. */ - -#define JMESSAGE(code,string) string , - -static const char * const cdjpeg_message_table[] = { -#include "cderror.h" - NULL -}; - - -/* - * This routine determines what format the input file is, - * and selects the appropriate input-reading module. - * - * To determine which family of input formats the file belongs to, - * we may look only at the first byte of the file, since C does not - * guarantee that more than one character can be pushed back with ungetc. - * Looking at additional bytes would require one of these approaches: - * 1) assume we can fseek() the input file (fails for piped input); - * 2) assume we can push back more than one character (works in - * some C implementations, but unportable); - * 3) provide our own buffering (breaks input readers that want to use - * stdio directly, such as the RLE library); - * or 4) don't put back the data, and modify the input_init methods to assume - * they start reading after the start of file (also breaks RLE library). - * #1 is attractive for MS-DOS but is untenable on Unix. - * - * The most portable solution for file types that can't be identified by their - * first byte is to make the user tell us what they are. This is also the - * only approach for "raw" file types that contain only arbitrary values. - * We presently apply this method for Targa files. Most of the time Targa - * files start with 0x00, so we recognize that case. Potentially, however, - * a Targa file could start with any byte value (byte 0 is the length of the - * seldom-used ID field), so we provide a switch to force Targa input mode. - */ - -static boolean is_targa; /* records user -targa switch */ - - -LOCAL(cjpeg_source_ptr) -select_file_type (j_compress_ptr cinfo, FILE * infile) -{ - int c; - - if (is_targa) { -#ifdef TARGA_SUPPORTED - return jinit_read_targa(cinfo); -#else - ERREXIT(cinfo, JERR_TGA_NOTCOMP); -#endif - } - - if ((c = getc(infile)) == EOF) - ERREXIT(cinfo, JERR_INPUT_EMPTY); - if (ungetc(c, infile) == EOF) - ERREXIT(cinfo, JERR_UNGETC_FAILED); - - switch (c) { -#ifdef BMP_SUPPORTED - case 'B': - return jinit_read_bmp(cinfo); -#endif -#ifdef GIF_SUPPORTED - case 'G': - return jinit_read_gif(cinfo); -#endif -#ifdef PPM_SUPPORTED - case 'P': - return jinit_read_ppm(cinfo); -#endif -#ifdef RLE_SUPPORTED - case 'R': - return jinit_read_rle(cinfo); -#endif -#ifdef TARGA_SUPPORTED - case 0x00: - return jinit_read_targa(cinfo); -#endif - default: - ERREXIT(cinfo, JERR_UNKNOWN_FORMAT); - break; - } - - return NULL; /* suppress compiler warnings */ -} - - -/* - * Argument-parsing code. - * The switch parser is designed to be useful with DOS-style command line - * syntax, ie, intermixed switches and file names, where only the switches - * to the left of a given file name affect processing of that file. - * The main program in this file doesn't actually use this capability... - */ - - -static const char * progname; /* program name for error messages */ -static char * outfilename; /* for -outfile switch */ - - -LOCAL(void) -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -quality N Compression quality (0..100; 5-95 is useful range)\n"); - fprintf(stderr, " -grayscale Create monochrome JPEG file\n"); -#ifdef ENTROPY_OPT_SUPPORTED - fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); -#endif -#ifdef C_PROGRESSIVE_SUPPORTED - fprintf(stderr, " -progressive Create progressive JPEG file\n"); -#endif -#ifdef TARGA_SUPPORTED - fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n"); -#endif - fprintf(stderr, "Switches for advanced users:\n"); -#ifdef DCT_ISLOW_SUPPORTED - fprintf(stderr, " -dct int Use integer DCT method%s\n", - (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); -#endif -#ifdef DCT_IFAST_SUPPORTED - fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", - (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); -#endif -#ifdef DCT_FLOAT_SUPPORTED - fprintf(stderr, " -dct float Use floating-point DCT method%s\n", - (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); -#endif - fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); -#ifdef INPUT_SMOOTHING_SUPPORTED - fprintf(stderr, " -smooth N Smooth dithered input (N=1..100 is strength)\n"); -#endif - fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); - fprintf(stderr, " -outfile name Specify name for output file\n"); - fprintf(stderr, " -verbose or -debug Emit debug output\n"); - fprintf(stderr, "Switches for wizards:\n"); -#ifdef C_ARITH_CODING_SUPPORTED - fprintf(stderr, " -arithmetic Use arithmetic coding\n"); -#endif - fprintf(stderr, " -baseline Force baseline quantization tables\n"); - fprintf(stderr, " -qtables file Use quantization tables given in file\n"); - fprintf(stderr, " -qslots N[,...] Set component quantization tables\n"); - fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n"); -#ifdef C_MULTISCAN_FILES_SUPPORTED - fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); -#endif - exit(EXIT_FAILURE); -} - - -LOCAL(int) -parse_switches (j_compress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -/* Parse optional switches. - * Returns argv[] index of first file-name argument (== argc if none). - * Any file names with indexes <= last_file_arg_seen are ignored; - * they have presumably been processed in a previous iteration. - * (Pass 0 for last_file_arg_seen on the first or only iteration.) - * for_real is FALSE on the first (dummy) pass; we may skip any expensive - * processing. - */ -{ - int argn; - char * arg; - int quality; /* -quality parameter */ - int q_scale_factor; /* scaling percentage for -qtables */ - boolean force_baseline; - boolean simple_progressive; - char * qtablefile = NULL; /* saves -qtables filename if any */ - char * qslotsarg = NULL; /* saves -qslots parm if any */ - char * samplearg = NULL; /* saves -sample parm if any */ - char * scansarg = NULL; /* saves -scans parm if any */ - - /* Set up default JPEG parameters. */ - /* Note that default -quality level need not, and does not, - * match the default scaling for an explicit -qtables argument. - */ - quality = 75; /* default -quality value */ - q_scale_factor = 100; /* default to no scaling for -qtables */ - force_baseline = FALSE; /* by default, allow 16-bit quantizers */ - simple_progressive = FALSE; - is_targa = FALSE; - outfilename = NULL; - cinfo->err->trace_level = 0; - - /* Scan command line options, adjust parameters */ - - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (*arg != '-') { - /* Not a switch, must be a file name argument */ - if (argn <= last_file_arg_seen) { - outfilename = NULL; /* -outfile applies to just one input file */ - continue; /* ignore this name if previously processed */ - } - break; /* else done parsing switches */ - } - arg++; /* advance past switch marker character */ - - if (keymatch(arg, "arithmetic", 1)) { - /* Use arithmetic coding. */ -#ifdef C_ARITH_CODING_SUPPORTED - cinfo->arith_code = TRUE; -#else - fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "baseline", 1)) { - /* Force baseline-compatible output (8-bit quantizer values). */ - force_baseline = TRUE; - - } else if (keymatch(arg, "dct", 2)) { - /* Select DCT algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "int", 1)) { - cinfo->dct_method = JDCT_ISLOW; - } else if (keymatch(argv[argn], "fast", 2)) { - cinfo->dct_method = JDCT_IFAST; - } else if (keymatch(argv[argn], "float", 2)) { - cinfo->dct_method = JDCT_FLOAT; - } else - usage(); - - } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { - /* Enable debug printouts. */ - /* On first -d, print version identification */ - static boolean printed_version = FALSE; - - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's CJPEG, version %s\n%s\n", - JVERSION, JCOPYRIGHT); - printed_version = TRUE; - } - cinfo->err->trace_level++; - - } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { - /* Force a monochrome JPEG file to be generated. */ - jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); - - } else if (keymatch(arg, "maxmemory", 3)) { - /* Maximum memory in Kb (or Mb with 'm'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (ch == 'm' || ch == 'M') - lval *= 1000L; - cinfo->mem->max_memory_to_use = lval * 1000L; - - } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { - /* Enable entropy parm optimization. */ -#ifdef ENTROPY_OPT_SUPPORTED - cinfo->optimize_coding = TRUE; -#else - fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "outfile", 4)) { - /* Set output file name. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - outfilename = argv[argn]; /* save it away for later use */ - - } else if (keymatch(arg, "progressive", 1)) { - /* Select simple progressive mode. */ -#ifdef C_PROGRESSIVE_SUPPORTED - simple_progressive = TRUE; - /* We must postpone execution until num_components is known. */ -#else - fprintf(stderr, "%s: sorry, progressive output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "quality", 1)) { - /* Quality factor (quantization table scaling factor). */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &quality) != 1) - usage(); - /* Change scale factor in case -qtables is present. */ - q_scale_factor = jpeg_quality_scaling(quality); - - } else if (keymatch(arg, "qslots", 2)) { - /* Quantization table slot numbers. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - qslotsarg = argv[argn]; - /* Must delay setting qslots until after we have processed any - * colorspace-determining switches, since jpeg_set_colorspace sets - * default quant table numbers. - */ - - } else if (keymatch(arg, "qtables", 2)) { - /* Quantization tables fetched from file. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - qtablefile = argv[argn]; - /* We postpone actually reading the file in case -quality comes later. */ - - } else if (keymatch(arg, "restart", 1)) { - /* Restart interval in MCU rows (or in MCUs with 'b'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (lval < 0 || lval > 65535L) - usage(); - if (ch == 'b' || ch == 'B') { - cinfo->restart_interval = (unsigned int) lval; - cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ - } else { - cinfo->restart_in_rows = (int) lval; - /* restart_interval will be computed during startup */ - } - - } else if (keymatch(arg, "sample", 2)) { - /* Set sampling factors. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - samplearg = argv[argn]; - /* Must delay setting sample factors until after we have processed any - * colorspace-determining switches, since jpeg_set_colorspace sets - * default sampling factors. - */ - - } else if (keymatch(arg, "scans", 2)) { - /* Set scan script. */ -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (++argn >= argc) /* advance to next argument */ - usage(); - scansarg = argv[argn]; - /* We must postpone reading the file in case -progressive appears. */ -#else - fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "smooth", 2)) { - /* Set input smoothing factor. */ - int val; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &val) != 1) - usage(); - if (val < 0 || val > 100) - usage(); - cinfo->smoothing_factor = val; - - } else if (keymatch(arg, "targa", 1)) { - /* Input file is Targa format. */ - is_targa = TRUE; - - } else { - usage(); /* bogus switch */ - } - } - - /* Post-switch-scanning cleanup */ - - if (for_real) { - - /* Set quantization tables for selected quality. */ - /* Some or all may be overridden if -qtables is present. */ - jpeg_set_quality(cinfo, quality, force_baseline); - - if (qtablefile != NULL) /* process -qtables if it was present */ - if (! read_quant_tables(cinfo, qtablefile, - q_scale_factor, force_baseline)) - usage(); - - if (qslotsarg != NULL) /* process -qslots if it was present */ - if (! set_quant_slots(cinfo, qslotsarg)) - usage(); - - if (samplearg != NULL) /* process -sample if it was present */ - if (! set_sample_factors(cinfo, samplearg)) - usage(); - -#ifdef C_PROGRESSIVE_SUPPORTED - if (simple_progressive) /* process -progressive; -scans can override */ - jpeg_simple_progression(cinfo); -#endif - -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (scansarg != NULL) /* process -scans if it was present */ - if (! read_scan_script(cinfo, scansarg)) - usage(); -#endif - } - - return argn; /* return index of next arg (file name) */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; -#ifdef PROGRESS_REPORT - struct cdjpeg_progress_mgr progress; -#endif - int file_index; - cjpeg_source_ptr src_mgr; - FILE * input_file; - FILE * output_file; - JDIMENSION num_scanlines; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "cjpeg"; /* in case C library doesn't provide it */ - - /* Initialize the JPEG compression object with default error handling. */ - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - /* Add some application-specific error messages (from cderror.h) */ - jerr.addon_message_table = cdjpeg_message_table; - jerr.first_addon_message = JMSG_FIRSTADDONCODE; - jerr.last_addon_message = JMSG_LASTADDONCODE; - - /* Now safe to enable signal catcher. */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &cinfo); -#endif - - /* Initialize JPEG parameters. - * Much of this may be overridden later. - * In particular, we don't yet know the input file's color space, - * but we need to provide some value for jpeg_set_defaults() to work. - */ - - cinfo.in_color_space = JCS_RGB; /* arbitrary guess */ - jpeg_set_defaults(&cinfo); - - /* Scan command line to find file names. - * It is convenient to use just one switch-parsing routine, but the switch - * values read here are ignored; we will rescan the switches after opening - * the input file. - */ - - file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); - -#ifdef TWO_FILE_COMMANDLINE - /* Must have either -outfile switch or explicit output file name */ - if (outfilename == NULL) { - if (file_index != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - outfilename = argv[file_index+1]; - } else { - if (file_index != argc-1) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - } -#else - /* Unix style: expect zero or one file name */ - if (file_index < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } -#endif /* TWO_FILE_COMMANDLINE */ - - /* Open the input file. */ - if (file_index < argc) { - if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ - input_file = read_stdin(); - } - - /* Open the output file. */ - if (outfilename != NULL) { - if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, outfilename); - exit(EXIT_FAILURE); - } - } else { - /* default output file is stdout */ - output_file = write_stdout(); - } - -#ifdef PROGRESS_REPORT - start_progress_monitor((j_common_ptr) &cinfo, &progress); -#endif - - /* Figure out the input file format, and set up to read it. */ - src_mgr = select_file_type(&cinfo, input_file); - src_mgr->input_file = input_file; - - /* Read the input file header to obtain file size & colorspace. */ - (*src_mgr->start_input) (&cinfo, src_mgr); - - /* Now that we know input colorspace, fix colorspace-dependent defaults */ - jpeg_default_colorspace(&cinfo); - - /* Adjust default compression parameters by re-parsing the options */ - file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); - - /* Specify data destination for compression */ - jpeg_stdio_dest(&cinfo, output_file); - - /* Start compressor */ - jpeg_start_compress(&cinfo, TRUE); - - /* Process data */ - while (cinfo.next_scanline < cinfo.image_height) { - num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr); - (void) jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines); - } - - /* Finish compression and release memory */ - (*src_mgr->finish_input) (&cinfo, src_mgr); - jpeg_finish_compress(&cinfo); - jpeg_destroy_compress(&cinfo); - - /* Close files, if we opened them */ - if (input_file != stdin) - fclose(input_file); - if (output_file != stdout) - fclose(output_file); - -#ifdef PROGRESS_REPORT - end_progress_monitor((j_common_ptr) &cinfo); -#endif - - /* All done. */ - exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} +/* + * cjpeg.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a command-line user interface for the JPEG compressor. + * It should work on any system with Unix- or MS-DOS-style command lines. + * + * Two different command line styles are permitted, depending on the + * compile-time switch TWO_FILE_COMMANDLINE: + * cjpeg [options] inputfile outputfile + * cjpeg [options] [inputfile] + * In the second style, output is always to standard output, which you'd + * normally redirect to a file or pipe to some other program. Input is + * either from a named file or from standard input (typically redirected). + * The second style is convenient on Unix but is unhelpful on systems that + * don't support pipes. Also, you MUST use the first style if your system + * doesn't do binary I/O to stdin/stdout. + * To simplify script writing, the "-outfile" switch is provided. The syntax + * cjpeg [options] -outfile outputfile inputfile + * works regardless of which command line style is used. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include "jversion.h" /* for version message */ + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + + +/* Create the add-on message string table. */ + +#define JMESSAGE(code,string) string , + +static const char * const cdjpeg_message_table[] = { +#include "cderror.h" + NULL +}; + + +/* + * This routine determines what format the input file is, + * and selects the appropriate input-reading module. + * + * To determine which family of input formats the file belongs to, + * we may look only at the first byte of the file, since C does not + * guarantee that more than one character can be pushed back with ungetc. + * Looking at additional bytes would require one of these approaches: + * 1) assume we can fseek() the input file (fails for piped input); + * 2) assume we can push back more than one character (works in + * some C implementations, but unportable); + * 3) provide our own buffering (breaks input readers that want to use + * stdio directly, such as the RLE library); + * or 4) don't put back the data, and modify the input_init methods to assume + * they start reading after the start of file (also breaks RLE library). + * #1 is attractive for MS-DOS but is untenable on Unix. + * + * The most portable solution for file types that can't be identified by their + * first byte is to make the user tell us what they are. This is also the + * only approach for "raw" file types that contain only arbitrary values. + * We presently apply this method for Targa files. Most of the time Targa + * files start with 0x00, so we recognize that case. Potentially, however, + * a Targa file could start with any byte value (byte 0 is the length of the + * seldom-used ID field), so we provide a switch to force Targa input mode. + */ + +static boolean is_targa; /* records user -targa switch */ + + +LOCAL(cjpeg_source_ptr) +select_file_type (j_compress_ptr cinfo, FILE * infile) +{ + int c; + + if (is_targa) { +#ifdef TARGA_SUPPORTED + return jinit_read_targa(cinfo); +#else + ERREXIT(cinfo, JERR_TGA_NOTCOMP); +#endif + } + + if ((c = getc(infile)) == EOF) + ERREXIT(cinfo, JERR_INPUT_EMPTY); + if (ungetc(c, infile) == EOF) + ERREXIT(cinfo, JERR_UNGETC_FAILED); + + switch (c) { +#ifdef BMP_SUPPORTED + case 'B': + return jinit_read_bmp(cinfo); +#endif +#ifdef GIF_SUPPORTED + case 'G': + return jinit_read_gif(cinfo); +#endif +#ifdef PPM_SUPPORTED + case 'P': + return jinit_read_ppm(cinfo); +#endif +#ifdef RLE_SUPPORTED + case 'R': + return jinit_read_rle(cinfo); +#endif +#ifdef TARGA_SUPPORTED + case 0x00: + return jinit_read_targa(cinfo); +#endif + default: + ERREXIT(cinfo, JERR_UNKNOWN_FORMAT); + break; + } + + return NULL; /* suppress compiler warnings */ +} + + +/* + * Argument-parsing code. + * The switch parser is designed to be useful with DOS-style command line + * syntax, ie, intermixed switches and file names, where only the switches + * to the left of a given file name affect processing of that file. + * The main program in this file doesn't actually use this capability... + */ + + +static const char * progname; /* program name for error messages */ +static char * outfilename; /* for -outfile switch */ + + +LOCAL(void) +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "usage: %s [switches] ", progname); +#ifdef TWO_FILE_COMMANDLINE + fprintf(stderr, "inputfile outputfile\n"); +#else + fprintf(stderr, "[inputfile]\n"); +#endif + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -quality N Compression quality (0..100; 5-95 is useful range)\n"); + fprintf(stderr, " -grayscale Create monochrome JPEG file\n"); +#ifdef ENTROPY_OPT_SUPPORTED + fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); +#endif +#ifdef C_PROGRESSIVE_SUPPORTED + fprintf(stderr, " -progressive Create progressive JPEG file\n"); +#endif +#ifdef TARGA_SUPPORTED + fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n"); +#endif + fprintf(stderr, "Switches for advanced users:\n"); +#ifdef DCT_ISLOW_SUPPORTED + fprintf(stderr, " -dct int Use integer DCT method%s\n", + (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); +#endif +#ifdef DCT_IFAST_SUPPORTED + fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", + (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); +#endif +#ifdef DCT_FLOAT_SUPPORTED + fprintf(stderr, " -dct float Use floating-point DCT method%s\n", + (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); +#endif + fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); +#ifdef INPUT_SMOOTHING_SUPPORTED + fprintf(stderr, " -smooth N Smooth dithered input (N=1..100 is strength)\n"); +#endif + fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); + fprintf(stderr, " -outfile name Specify name for output file\n"); + fprintf(stderr, " -verbose or -debug Emit debug output\n"); + fprintf(stderr, "Switches for wizards:\n"); +#ifdef C_ARITH_CODING_SUPPORTED + fprintf(stderr, " -arithmetic Use arithmetic coding\n"); +#endif + fprintf(stderr, " -baseline Force baseline quantization tables\n"); + fprintf(stderr, " -qtables file Use quantization tables given in file\n"); + fprintf(stderr, " -qslots N[,...] Set component quantization tables\n"); + fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n"); +#ifdef C_MULTISCAN_FILES_SUPPORTED + fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); +#endif + exit(EXIT_FAILURE); +} + + +LOCAL(int) +parse_switches (j_compress_ptr cinfo, int argc, char **argv, + int last_file_arg_seen, boolean for_real) +/* Parse optional switches. + * Returns argv[] index of first file-name argument (== argc if none). + * Any file names with indexes <= last_file_arg_seen are ignored; + * they have presumably been processed in a previous iteration. + * (Pass 0 for last_file_arg_seen on the first or only iteration.) + * for_real is FALSE on the first (dummy) pass; we may skip any expensive + * processing. + */ +{ + int argn; + char * arg; + int quality; /* -quality parameter */ + int q_scale_factor; /* scaling percentage for -qtables */ + boolean force_baseline; + boolean simple_progressive; + char * qtablefile = NULL; /* saves -qtables filename if any */ + char * qslotsarg = NULL; /* saves -qslots parm if any */ + char * samplearg = NULL; /* saves -sample parm if any */ + char * scansarg = NULL; /* saves -scans parm if any */ + + /* Set up default JPEG parameters. */ + /* Note that default -quality level need not, and does not, + * match the default scaling for an explicit -qtables argument. + */ + quality = 75; /* default -quality value */ + q_scale_factor = 100; /* default to no scaling for -qtables */ + force_baseline = FALSE; /* by default, allow 16-bit quantizers */ + simple_progressive = FALSE; + is_targa = FALSE; + outfilename = NULL; + cinfo->err->trace_level = 0; + + /* Scan command line options, adjust parameters */ + + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (*arg != '-') { + /* Not a switch, must be a file name argument */ + if (argn <= last_file_arg_seen) { + outfilename = NULL; /* -outfile applies to just one input file */ + continue; /* ignore this name if previously processed */ + } + break; /* else done parsing switches */ + } + arg++; /* advance past switch marker character */ + + if (keymatch(arg, "arithmetic", 1)) { + /* Use arithmetic coding. */ +#ifdef C_ARITH_CODING_SUPPORTED + cinfo->arith_code = TRUE; +#else + fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "baseline", 1)) { + /* Force baseline-compatible output (8-bit quantizer values). */ + force_baseline = TRUE; + + } else if (keymatch(arg, "dct", 2)) { + /* Select DCT algorithm. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "int", 1)) { + cinfo->dct_method = JDCT_ISLOW; + } else if (keymatch(argv[argn], "fast", 2)) { + cinfo->dct_method = JDCT_IFAST; + } else if (keymatch(argv[argn], "float", 2)) { + cinfo->dct_method = JDCT_FLOAT; + } else + usage(); + + } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { + /* Enable debug printouts. */ + /* On first -d, print version identification */ + static boolean printed_version = FALSE; + + if (! printed_version) { + fprintf(stderr, "Independent JPEG Group's CJPEG, version %s\n%s\n", + JVERSION, JCOPYRIGHT); + printed_version = TRUE; + } + cinfo->err->trace_level++; + + } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { + /* Force a monochrome JPEG file to be generated. */ + jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); + + } else if (keymatch(arg, "maxmemory", 3)) { + /* Maximum memory in Kb (or Mb with 'm'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (ch == 'm' || ch == 'M') + lval *= 1000L; + cinfo->mem->max_memory_to_use = lval * 1000L; + + } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { + /* Enable entropy parm optimization. */ +#ifdef ENTROPY_OPT_SUPPORTED + cinfo->optimize_coding = TRUE; +#else + fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "outfile", 4)) { + /* Set output file name. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + outfilename = argv[argn]; /* save it away for later use */ + + } else if (keymatch(arg, "progressive", 1)) { + /* Select simple progressive mode. */ +#ifdef C_PROGRESSIVE_SUPPORTED + simple_progressive = TRUE; + /* We must postpone execution until num_components is known. */ +#else + fprintf(stderr, "%s: sorry, progressive output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "quality", 1)) { + /* Quality factor (quantization table scaling factor). */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d", &quality) != 1) + usage(); + /* Change scale factor in case -qtables is present. */ + q_scale_factor = jpeg_quality_scaling(quality); + + } else if (keymatch(arg, "qslots", 2)) { + /* Quantization table slot numbers. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + qslotsarg = argv[argn]; + /* Must delay setting qslots until after we have processed any + * colorspace-determining switches, since jpeg_set_colorspace sets + * default quant table numbers. + */ + + } else if (keymatch(arg, "qtables", 2)) { + /* Quantization tables fetched from file. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + qtablefile = argv[argn]; + /* We postpone actually reading the file in case -quality comes later. */ + + } else if (keymatch(arg, "restart", 1)) { + /* Restart interval in MCU rows (or in MCUs with 'b'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (lval < 0 || lval > 65535L) + usage(); + if (ch == 'b' || ch == 'B') { + cinfo->restart_interval = (unsigned int) lval; + cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ + } else { + cinfo->restart_in_rows = (int) lval; + /* restart_interval will be computed during startup */ + } + + } else if (keymatch(arg, "sample", 2)) { + /* Set sampling factors. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + samplearg = argv[argn]; + /* Must delay setting sample factors until after we have processed any + * colorspace-determining switches, since jpeg_set_colorspace sets + * default sampling factors. + */ + + } else if (keymatch(arg, "scans", 2)) { + /* Set scan script. */ +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (++argn >= argc) /* advance to next argument */ + usage(); + scansarg = argv[argn]; + /* We must postpone reading the file in case -progressive appears. */ +#else + fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "smooth", 2)) { + /* Set input smoothing factor. */ + int val; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d", &val) != 1) + usage(); + if (val < 0 || val > 100) + usage(); + cinfo->smoothing_factor = val; + + } else if (keymatch(arg, "targa", 1)) { + /* Input file is Targa format. */ + is_targa = TRUE; + + } else { + usage(); /* bogus switch */ + } + } + + /* Post-switch-scanning cleanup */ + + if (for_real) { + + /* Set quantization tables for selected quality. */ + /* Some or all may be overridden if -qtables is present. */ + jpeg_set_quality(cinfo, quality, force_baseline); + + if (qtablefile != NULL) /* process -qtables if it was present */ + if (! read_quant_tables(cinfo, qtablefile, + q_scale_factor, force_baseline)) + usage(); + + if (qslotsarg != NULL) /* process -qslots if it was present */ + if (! set_quant_slots(cinfo, qslotsarg)) + usage(); + + if (samplearg != NULL) /* process -sample if it was present */ + if (! set_sample_factors(cinfo, samplearg)) + usage(); + +#ifdef C_PROGRESSIVE_SUPPORTED + if (simple_progressive) /* process -progressive; -scans can override */ + jpeg_simple_progression(cinfo); +#endif + +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (scansarg != NULL) /* process -scans if it was present */ + if (! read_scan_script(cinfo, scansarg)) + usage(); +#endif + } + + return argn; /* return index of next arg (file name) */ +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; +#ifdef PROGRESS_REPORT + struct cdjpeg_progress_mgr progress; +#endif + int file_index; + cjpeg_source_ptr src_mgr; + FILE * input_file; + FILE * output_file; + JDIMENSION num_scanlines; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "cjpeg"; /* in case C library doesn't provide it */ + + /* Initialize the JPEG compression object with default error handling. */ + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + /* Add some application-specific error messages (from cderror.h) */ + jerr.addon_message_table = cdjpeg_message_table; + jerr.first_addon_message = JMSG_FIRSTADDONCODE; + jerr.last_addon_message = JMSG_LASTADDONCODE; + + /* Now safe to enable signal catcher. */ +#ifdef NEED_SIGNAL_CATCHER + enable_signal_catcher((j_common_ptr) &cinfo); +#endif + + /* Initialize JPEG parameters. + * Much of this may be overridden later. + * In particular, we don't yet know the input file's color space, + * but we need to provide some value for jpeg_set_defaults() to work. + */ + + cinfo.in_color_space = JCS_RGB; /* arbitrary guess */ + jpeg_set_defaults(&cinfo); + + /* Scan command line to find file names. + * It is convenient to use just one switch-parsing routine, but the switch + * values read here are ignored; we will rescan the switches after opening + * the input file. + */ + + file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); + +#ifdef TWO_FILE_COMMANDLINE + /* Must have either -outfile switch or explicit output file name */ + if (outfilename == NULL) { + if (file_index != argc-2) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + outfilename = argv[file_index+1]; + } else { + if (file_index != argc-1) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + } +#else + /* Unix style: expect zero or one file name */ + if (file_index < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } +#endif /* TWO_FILE_COMMANDLINE */ + + /* Open the input file. */ + if (file_index < argc) { + if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ + input_file = read_stdin(); + } + + /* Open the output file. */ + if (outfilename != NULL) { + if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, outfilename); + exit(EXIT_FAILURE); + } + } else { + /* default output file is stdout */ + output_file = write_stdout(); + } + +#ifdef PROGRESS_REPORT + start_progress_monitor((j_common_ptr) &cinfo, &progress); +#endif + + /* Figure out the input file format, and set up to read it. */ + src_mgr = select_file_type(&cinfo, input_file); + src_mgr->input_file = input_file; + + /* Read the input file header to obtain file size & colorspace. */ + (*src_mgr->start_input) (&cinfo, src_mgr); + + /* Now that we know input colorspace, fix colorspace-dependent defaults */ + jpeg_default_colorspace(&cinfo); + + /* Adjust default compression parameters by re-parsing the options */ + file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); + + /* Specify data destination for compression */ + jpeg_stdio_dest(&cinfo, output_file); + + /* Start compressor */ + jpeg_start_compress(&cinfo, TRUE); + + /* Process data */ + while (cinfo.next_scanline < cinfo.image_height) { + num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr); + (void) jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines); + } + + /* Finish compression and release memory */ + (*src_mgr->finish_input) (&cinfo, src_mgr); + jpeg_finish_compress(&cinfo); + jpeg_destroy_compress(&cinfo); + + /* Close files, if we opened them */ + if (input_file != stdin) + fclose(input_file); + if (output_file != stdout) + fclose(output_file); + +#ifdef PROGRESS_REPORT + end_progress_monitor((j_common_ptr) &cinfo); +#endif + + /* All done. */ + exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/src/dep/src/irrlicht/jpeglib/ckconfig.c b/src/dep/src/irrlicht/jpeglib/ckconfig.c index 58e9c17..34baf79 100644 --- a/src/dep/src/irrlicht/jpeglib/ckconfig.c +++ b/src/dep/src/irrlicht/jpeglib/ckconfig.c @@ -1,402 +1,402 @@ -/* - * ckconfig.c - * - * Copyright (C) 1991-1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - */ - -/* - * This program is intended to help you determine how to configure the JPEG - * software for installation on a particular system. The idea is to try to - * compile and execute this program. If your compiler fails to compile the - * program, make changes as indicated in the comments below. Once you can - * compile the program, run it, and it will produce a "jconfig.h" file for - * your system. - * - * As a general rule, each time you try to compile this program, - * pay attention only to the *first* error message you get from the compiler. - * Many C compilers will issue lots of spurious error messages once they - * have gotten confused. Go to the line indicated in the first error message, - * and read the comments preceding that line to see what to change. - * - * Almost all of the edits you may need to make to this program consist of - * changing a line that reads "#define SOME_SYMBOL" to "#undef SOME_SYMBOL", - * or vice versa. This is called defining or undefining that symbol. - */ - - -/* First we must see if your system has the include files we need. - * We start out with the assumption that your system has all the ANSI-standard - * include files. If you get any error trying to include one of these files, - * undefine the corresponding HAVE_xxx symbol. - */ - -#define HAVE_STDDEF_H /* replace 'define' by 'undef' if error here */ -#ifdef HAVE_STDDEF_H /* next line will be skipped if you undef... */ -#include -#endif - -#define HAVE_STDLIB_H /* same thing for stdlib.h */ -#ifdef HAVE_STDLIB_H -#include -#endif - -#include /* If you ain't got this, you ain't got C. */ - -/* We have to see if your string functions are defined by - * strings.h (old BSD convention) or string.h (everybody else). - * We try the non-BSD convention first; define NEED_BSD_STRINGS - * if the compiler says it can't find string.h. - */ - -#undef NEED_BSD_STRINGS - -#ifdef NEED_BSD_STRINGS -#include -#else -#include -#endif - -/* On some systems (especially older Unix machines), type size_t is - * defined only in the include file . If you get a failure - * on the size_t test below, try defining NEED_SYS_TYPES_H. - */ - -#undef NEED_SYS_TYPES_H /* start by assuming we don't need it */ -#ifdef NEED_SYS_TYPES_H -#include -#endif - - -/* Usually type size_t is defined in one of the include files we've included - * above. If not, you'll get an error on the "typedef size_t my_size_t;" line. - * In that case, first try defining NEED_SYS_TYPES_H just above. - * If that doesn't work, you'll have to search through your system library - * to figure out which include file defines "size_t". Look for a line that - * says "typedef something-or-other size_t;". Then, change the line below - * that says "#include " to instead include the file - * you found size_t in, and define NEED_SPECIAL_INCLUDE. If you can't find - * type size_t anywhere, try replacing "#include " with - * "typedef unsigned int size_t;". - */ - -#undef NEED_SPECIAL_INCLUDE /* assume we DON'T need it, for starters */ - -#ifdef NEED_SPECIAL_INCLUDE -#include -#endif - -typedef size_t my_size_t; /* The payoff: do we have size_t now? */ - - -/* The next question is whether your compiler supports ANSI-style function - * prototypes. You need to know this in order to choose between using - * makefile.ansi and using makefile.unix. - * The #define line below is set to assume you have ANSI function prototypes. - * If you get an error in this group of lines, undefine HAVE_PROTOTYPES. - */ - -#define HAVE_PROTOTYPES - -#ifdef HAVE_PROTOTYPES -int testfunction (int arg1, int * arg2); /* check prototypes */ - -struct methods_struct { /* check method-pointer declarations */ - int (*error_exit) (char *msgtext); - int (*trace_message) (char *msgtext); - int (*another_method) (void); -}; - -int testfunction (int arg1, int * arg2) /* check definitions */ -{ - return arg2[arg1]; -} - -int test2function (void) /* check void arg list */ -{ - return 0; -} -#endif - - -/* Now we want to find out if your compiler knows what "unsigned char" means. - * If you get an error on the "unsigned char un_char;" line, - * then undefine HAVE_UNSIGNED_CHAR. - */ - -#define HAVE_UNSIGNED_CHAR - -#ifdef HAVE_UNSIGNED_CHAR -unsigned char un_char; -#endif - - -/* Now we want to find out if your compiler knows what "unsigned short" means. - * If you get an error on the "unsigned short un_short;" line, - * then undefine HAVE_UNSIGNED_SHORT. - */ - -#define HAVE_UNSIGNED_SHORT - -#ifdef HAVE_UNSIGNED_SHORT -unsigned short un_short; -#endif - - -/* Now we want to find out if your compiler understands type "void". - * If you get an error anywhere in here, undefine HAVE_VOID. - */ - -#define HAVE_VOID - -#ifdef HAVE_VOID -/* Caution: a C++ compiler will insist on complete prototypes */ -typedef void * void_ptr; /* check void * */ -#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */ -typedef void (*void_func) (int a, int b); -#else -typedef void (*void_func) (); -#endif - -#ifdef HAVE_PROTOTYPES /* check void function result */ -void test3function (void_ptr arg1, void_func arg2) -#else -void test3function (arg1, arg2) - void_ptr arg1; - void_func arg2; -#endif -{ - char * locptr = (char *) arg1; /* check casting to and from void * */ - arg1 = (void *) locptr; - (*arg2) (1, 2); /* check call of fcn returning void */ -} -#endif - - -/* Now we want to find out if your compiler knows what "const" means. - * If you get an error here, undefine HAVE_CONST. - */ - -#define HAVE_CONST - -#ifdef HAVE_CONST -static const int carray[3] = {1, 2, 3}; - -#ifdef HAVE_PROTOTYPES -int test4function (const int arg1) -#else -int test4function (arg1) - const int arg1; -#endif -{ - return carray[arg1]; -} -#endif - - -/* If you get an error or warning about this structure definition, - * define INCOMPLETE_TYPES_BROKEN. - */ - -#undef INCOMPLETE_TYPES_BROKEN - -#ifndef INCOMPLETE_TYPES_BROKEN -typedef struct undefined_structure * undef_struct_ptr; -#endif - - -/* If you get an error about duplicate names, - * define NEED_SHORT_EXTERNAL_NAMES. - */ - -#undef NEED_SHORT_EXTERNAL_NAMES - -#ifndef NEED_SHORT_EXTERNAL_NAMES - -int possibly_duplicate_function () -{ - return 0; -} - -int possibly_dupli_function () -{ - return 1; -} - -#endif - - - -/************************************************************************ - * OK, that's it. You should not have to change anything beyond this - * point in order to compile and execute this program. (You might get - * some warnings, but you can ignore them.) - * When you run the program, it will make a couple more tests that it - * can do automatically, and then it will create jconfig.h and print out - * any additional suggestions it has. - ************************************************************************ - */ - - -#ifdef HAVE_PROTOTYPES -int is_char_signed (int arg) -#else -int is_char_signed (arg) - int arg; -#endif -{ - if (arg == 189) { /* expected result for unsigned char */ - return 0; /* type char is unsigned */ - } - else if (arg != -67) { /* expected result for signed char */ - printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n"); - printf("I fear the JPEG software will not work at all.\n\n"); - } - return 1; /* assume char is signed otherwise */ -} - - -#ifdef HAVE_PROTOTYPES -int is_shifting_signed (long arg) -#else -int is_shifting_signed (arg) - long arg; -#endif -/* See whether right-shift on a long is signed or not. */ -{ - long res = arg >> 4; - - if (res == -0x7F7E80CL) { /* expected result for signed shift */ - return 1; /* right shift is signed */ - } - /* see if unsigned-shift hack will fix it. */ - /* we can't just test exact value since it depends on width of long... */ - res |= (~0L) << (32-4); - if (res == -0x7F7E80CL) { /* expected result now? */ - return 0; /* right shift is unsigned */ - } - printf("Right shift isn't acting as I expect it to.\n"); - printf("I fear the JPEG software will not work at all.\n\n"); - return 0; /* try it with unsigned anyway */ -} - - -#ifdef HAVE_PROTOTYPES -int main (int argc, char ** argv) -#else -int main (argc, argv) - int argc; - char ** argv; -#endif -{ - char signed_char_check = (char) (-67); - FILE *outfile; - - /* Attempt to write jconfig.h */ - if ((outfile = fopen("jconfig.h", "w")) == NULL) { - printf("Failed to write jconfig.h\n"); - return 1; - } - - /* Write out all the info */ - fprintf(outfile, "/* jconfig.h --- generated by ckconfig.c */\n"); - fprintf(outfile, "/* see jconfig.doc for explanations */\n\n"); -#ifdef HAVE_PROTOTYPES - fprintf(outfile, "#define HAVE_PROTOTYPES\n"); -#else - fprintf(outfile, "#undef HAVE_PROTOTYPES\n"); -#endif -#ifdef HAVE_UNSIGNED_CHAR - fprintf(outfile, "#define HAVE_UNSIGNED_CHAR\n"); -#else - fprintf(outfile, "#undef HAVE_UNSIGNED_CHAR\n"); -#endif -#ifdef HAVE_UNSIGNED_SHORT - fprintf(outfile, "#define HAVE_UNSIGNED_SHORT\n"); -#else - fprintf(outfile, "#undef HAVE_UNSIGNED_SHORT\n"); -#endif -#ifdef HAVE_VOID - fprintf(outfile, "/* #define void char */\n"); -#else - fprintf(outfile, "#define void char\n"); -#endif -#ifdef HAVE_CONST - fprintf(outfile, "/* #define const */\n"); -#else - fprintf(outfile, "#define const\n"); -#endif - if (is_char_signed((int) signed_char_check)) - fprintf(outfile, "#undef CHAR_IS_UNSIGNED\n"); - else - fprintf(outfile, "#define CHAR_IS_UNSIGNED\n"); -#ifdef HAVE_STDDEF_H - fprintf(outfile, "#define HAVE_STDDEF_H\n"); -#else - fprintf(outfile, "#undef HAVE_STDDEF_H\n"); -#endif -#ifdef HAVE_STDLIB_H - fprintf(outfile, "#define HAVE_STDLIB_H\n"); -#else - fprintf(outfile, "#undef HAVE_STDLIB_H\n"); -#endif -#ifdef NEED_BSD_STRINGS - fprintf(outfile, "#define NEED_BSD_STRINGS\n"); -#else - fprintf(outfile, "#undef NEED_BSD_STRINGS\n"); -#endif -#ifdef NEED_SYS_TYPES_H - fprintf(outfile, "#define NEED_SYS_TYPES_H\n"); -#else - fprintf(outfile, "#undef NEED_SYS_TYPES_H\n"); -#endif - fprintf(outfile, "#undef NEED_FAR_POINTERS\n"); -#ifdef NEED_SHORT_EXTERNAL_NAMES - fprintf(outfile, "#define NEED_SHORT_EXTERNAL_NAMES\n"); -#else - fprintf(outfile, "#undef NEED_SHORT_EXTERNAL_NAMES\n"); -#endif -#ifdef INCOMPLETE_TYPES_BROKEN - fprintf(outfile, "#define INCOMPLETE_TYPES_BROKEN\n"); -#else - fprintf(outfile, "#undef INCOMPLETE_TYPES_BROKEN\n"); -#endif - fprintf(outfile, "\n#ifdef JPEG_INTERNALS\n\n"); - if (is_shifting_signed(-0x7F7E80B1L)) - fprintf(outfile, "#undef RIGHT_SHIFT_IS_UNSIGNED\n"); - else - fprintf(outfile, "#define RIGHT_SHIFT_IS_UNSIGNED\n"); - fprintf(outfile, "\n#endif /* JPEG_INTERNALS */\n"); - fprintf(outfile, "\n#ifdef JPEG_CJPEG_DJPEG\n\n"); - fprintf(outfile, "#define BMP_SUPPORTED /* BMP image file format */\n"); - fprintf(outfile, "#define GIF_SUPPORTED /* GIF image file format */\n"); - fprintf(outfile, "#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */\n"); - fprintf(outfile, "#undef RLE_SUPPORTED /* Utah RLE image file format */\n"); - fprintf(outfile, "#define TARGA_SUPPORTED /* Targa image file format */\n\n"); - fprintf(outfile, "#undef TWO_FILE_COMMANDLINE /* You may need this on non-Unix systems */\n"); - fprintf(outfile, "#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */\n"); - fprintf(outfile, "#undef DONT_USE_B_MODE\n"); - fprintf(outfile, "/* #define PROGRESS_REPORT */ /* optional */\n"); - fprintf(outfile, "\n#endif /* JPEG_CJPEG_DJPEG */\n"); - - /* Close the jconfig.h file */ - fclose(outfile); - - /* User report */ - printf("Configuration check for Independent JPEG Group's software done.\n"); - printf("\nI have written the jconfig.h file for you.\n\n"); -#ifdef HAVE_PROTOTYPES - printf("You should use makefile.ansi as the starting point for your Makefile.\n"); -#else - printf("You should use makefile.unix as the starting point for your Makefile.\n"); -#endif - -#ifdef NEED_SPECIAL_INCLUDE - printf("\nYou'll need to change jconfig.h to include the system include file\n"); - printf("that you found type size_t in, or add a direct definition of type\n"); - printf("size_t if that's what you used. Just add it to the end.\n"); -#endif - - return 0; -} +/* + * ckconfig.c + * + * Copyright (C) 1991-1994, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + */ + +/* + * This program is intended to help you determine how to configure the JPEG + * software for installation on a particular system. The idea is to try to + * compile and execute this program. If your compiler fails to compile the + * program, make changes as indicated in the comments below. Once you can + * compile the program, run it, and it will produce a "jconfig.h" file for + * your system. + * + * As a general rule, each time you try to compile this program, + * pay attention only to the *first* error message you get from the compiler. + * Many C compilers will issue lots of spurious error messages once they + * have gotten confused. Go to the line indicated in the first error message, + * and read the comments preceding that line to see what to change. + * + * Almost all of the edits you may need to make to this program consist of + * changing a line that reads "#define SOME_SYMBOL" to "#undef SOME_SYMBOL", + * or vice versa. This is called defining or undefining that symbol. + */ + + +/* First we must see if your system has the include files we need. + * We start out with the assumption that your system has all the ANSI-standard + * include files. If you get any error trying to include one of these files, + * undefine the corresponding HAVE_xxx symbol. + */ + +#define HAVE_STDDEF_H /* replace 'define' by 'undef' if error here */ +#ifdef HAVE_STDDEF_H /* next line will be skipped if you undef... */ +#include +#endif + +#define HAVE_STDLIB_H /* same thing for stdlib.h */ +#ifdef HAVE_STDLIB_H +#include +#endif + +#include /* If you ain't got this, you ain't got C. */ + +/* We have to see if your string functions are defined by + * strings.h (old BSD convention) or string.h (everybody else). + * We try the non-BSD convention first; define NEED_BSD_STRINGS + * if the compiler says it can't find string.h. + */ + +#undef NEED_BSD_STRINGS + +#ifdef NEED_BSD_STRINGS +#include +#else +#include +#endif + +/* On some systems (especially older Unix machines), type size_t is + * defined only in the include file . If you get a failure + * on the size_t test below, try defining NEED_SYS_TYPES_H. + */ + +#undef NEED_SYS_TYPES_H /* start by assuming we don't need it */ +#ifdef NEED_SYS_TYPES_H +#include +#endif + + +/* Usually type size_t is defined in one of the include files we've included + * above. If not, you'll get an error on the "typedef size_t my_size_t;" line. + * In that case, first try defining NEED_SYS_TYPES_H just above. + * If that doesn't work, you'll have to search through your system library + * to figure out which include file defines "size_t". Look for a line that + * says "typedef something-or-other size_t;". Then, change the line below + * that says "#include " to instead include the file + * you found size_t in, and define NEED_SPECIAL_INCLUDE. If you can't find + * type size_t anywhere, try replacing "#include " with + * "typedef unsigned int size_t;". + */ + +#undef NEED_SPECIAL_INCLUDE /* assume we DON'T need it, for starters */ + +#ifdef NEED_SPECIAL_INCLUDE +#include +#endif + +typedef size_t my_size_t; /* The payoff: do we have size_t now? */ + + +/* The next question is whether your compiler supports ANSI-style function + * prototypes. You need to know this in order to choose between using + * makefile.ansi and using makefile.unix. + * The #define line below is set to assume you have ANSI function prototypes. + * If you get an error in this group of lines, undefine HAVE_PROTOTYPES. + */ + +#define HAVE_PROTOTYPES + +#ifdef HAVE_PROTOTYPES +int testfunction (int arg1, int * arg2); /* check prototypes */ + +struct methods_struct { /* check method-pointer declarations */ + int (*error_exit) (char *msgtext); + int (*trace_message) (char *msgtext); + int (*another_method) (void); +}; + +int testfunction (int arg1, int * arg2) /* check definitions */ +{ + return arg2[arg1]; +} + +int test2function (void) /* check void arg list */ +{ + return 0; +} +#endif + + +/* Now we want to find out if your compiler knows what "unsigned char" means. + * If you get an error on the "unsigned char un_char;" line, + * then undefine HAVE_UNSIGNED_CHAR. + */ + +#define HAVE_UNSIGNED_CHAR + +#ifdef HAVE_UNSIGNED_CHAR +unsigned char un_char; +#endif + + +/* Now we want to find out if your compiler knows what "unsigned short" means. + * If you get an error on the "unsigned short un_short;" line, + * then undefine HAVE_UNSIGNED_SHORT. + */ + +#define HAVE_UNSIGNED_SHORT + +#ifdef HAVE_UNSIGNED_SHORT +unsigned short un_short; +#endif + + +/* Now we want to find out if your compiler understands type "void". + * If you get an error anywhere in here, undefine HAVE_VOID. + */ + +#define HAVE_VOID + +#ifdef HAVE_VOID +/* Caution: a C++ compiler will insist on complete prototypes */ +typedef void * void_ptr; /* check void * */ +#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */ +typedef void (*void_func) (int a, int b); +#else +typedef void (*void_func) (); +#endif + +#ifdef HAVE_PROTOTYPES /* check void function result */ +void test3function (void_ptr arg1, void_func arg2) +#else +void test3function (arg1, arg2) + void_ptr arg1; + void_func arg2; +#endif +{ + char * locptr = (char *) arg1; /* check casting to and from void * */ + arg1 = (void *) locptr; + (*arg2) (1, 2); /* check call of fcn returning void */ +} +#endif + + +/* Now we want to find out if your compiler knows what "const" means. + * If you get an error here, undefine HAVE_CONST. + */ + +#define HAVE_CONST + +#ifdef HAVE_CONST +static const int carray[3] = {1, 2, 3}; + +#ifdef HAVE_PROTOTYPES +int test4function (const int arg1) +#else +int test4function (arg1) + const int arg1; +#endif +{ + return carray[arg1]; +} +#endif + + +/* If you get an error or warning about this structure definition, + * define INCOMPLETE_TYPES_BROKEN. + */ + +#undef INCOMPLETE_TYPES_BROKEN + +#ifndef INCOMPLETE_TYPES_BROKEN +typedef struct undefined_structure * undef_struct_ptr; +#endif + + +/* If you get an error about duplicate names, + * define NEED_SHORT_EXTERNAL_NAMES. + */ + +#undef NEED_SHORT_EXTERNAL_NAMES + +#ifndef NEED_SHORT_EXTERNAL_NAMES + +int possibly_duplicate_function () +{ + return 0; +} + +int possibly_dupli_function () +{ + return 1; +} + +#endif + + + +/************************************************************************ + * OK, that's it. You should not have to change anything beyond this + * point in order to compile and execute this program. (You might get + * some warnings, but you can ignore them.) + * When you run the program, it will make a couple more tests that it + * can do automatically, and then it will create jconfig.h and print out + * any additional suggestions it has. + ************************************************************************ + */ + + +#ifdef HAVE_PROTOTYPES +int is_char_signed (int arg) +#else +int is_char_signed (arg) + int arg; +#endif +{ + if (arg == 189) { /* expected result for unsigned char */ + return 0; /* type char is unsigned */ + } + else if (arg != -67) { /* expected result for signed char */ + printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n"); + printf("I fear the JPEG software will not work at all.\n\n"); + } + return 1; /* assume char is signed otherwise */ +} + + +#ifdef HAVE_PROTOTYPES +int is_shifting_signed (long arg) +#else +int is_shifting_signed (arg) + long arg; +#endif +/* See whether right-shift on a long is signed or not. */ +{ + long res = arg >> 4; + + if (res == -0x7F7E80CL) { /* expected result for signed shift */ + return 1; /* right shift is signed */ + } + /* see if unsigned-shift hack will fix it. */ + /* we can't just test exact value since it depends on width of long... */ + res |= (~0L) << (32-4); + if (res == -0x7F7E80CL) { /* expected result now? */ + return 0; /* right shift is unsigned */ + } + printf("Right shift isn't acting as I expect it to.\n"); + printf("I fear the JPEG software will not work at all.\n\n"); + return 0; /* try it with unsigned anyway */ +} + + +#ifdef HAVE_PROTOTYPES +int main (int argc, char ** argv) +#else +int main (argc, argv) + int argc; + char ** argv; +#endif +{ + char signed_char_check = (char) (-67); + FILE *outfile; + + /* Attempt to write jconfig.h */ + if ((outfile = fopen("jconfig.h", "w")) == NULL) { + printf("Failed to write jconfig.h\n"); + return 1; + } + + /* Write out all the info */ + fprintf(outfile, "/* jconfig.h --- generated by ckconfig.c */\n"); + fprintf(outfile, "/* see jconfig.doc for explanations */\n\n"); +#ifdef HAVE_PROTOTYPES + fprintf(outfile, "#define HAVE_PROTOTYPES\n"); +#else + fprintf(outfile, "#undef HAVE_PROTOTYPES\n"); +#endif +#ifdef HAVE_UNSIGNED_CHAR + fprintf(outfile, "#define HAVE_UNSIGNED_CHAR\n"); +#else + fprintf(outfile, "#undef HAVE_UNSIGNED_CHAR\n"); +#endif +#ifdef HAVE_UNSIGNED_SHORT + fprintf(outfile, "#define HAVE_UNSIGNED_SHORT\n"); +#else + fprintf(outfile, "#undef HAVE_UNSIGNED_SHORT\n"); +#endif +#ifdef HAVE_VOID + fprintf(outfile, "/* #define void char */\n"); +#else + fprintf(outfile, "#define void char\n"); +#endif +#ifdef HAVE_CONST + fprintf(outfile, "/* #define const */\n"); +#else + fprintf(outfile, "#define const\n"); +#endif + if (is_char_signed((int) signed_char_check)) + fprintf(outfile, "#undef CHAR_IS_UNSIGNED\n"); + else + fprintf(outfile, "#define CHAR_IS_UNSIGNED\n"); +#ifdef HAVE_STDDEF_H + fprintf(outfile, "#define HAVE_STDDEF_H\n"); +#else + fprintf(outfile, "#undef HAVE_STDDEF_H\n"); +#endif +#ifdef HAVE_STDLIB_H + fprintf(outfile, "#define HAVE_STDLIB_H\n"); +#else + fprintf(outfile, "#undef HAVE_STDLIB_H\n"); +#endif +#ifdef NEED_BSD_STRINGS + fprintf(outfile, "#define NEED_BSD_STRINGS\n"); +#else + fprintf(outfile, "#undef NEED_BSD_STRINGS\n"); +#endif +#ifdef NEED_SYS_TYPES_H + fprintf(outfile, "#define NEED_SYS_TYPES_H\n"); +#else + fprintf(outfile, "#undef NEED_SYS_TYPES_H\n"); +#endif + fprintf(outfile, "#undef NEED_FAR_POINTERS\n"); +#ifdef NEED_SHORT_EXTERNAL_NAMES + fprintf(outfile, "#define NEED_SHORT_EXTERNAL_NAMES\n"); +#else + fprintf(outfile, "#undef NEED_SHORT_EXTERNAL_NAMES\n"); +#endif +#ifdef INCOMPLETE_TYPES_BROKEN + fprintf(outfile, "#define INCOMPLETE_TYPES_BROKEN\n"); +#else + fprintf(outfile, "#undef INCOMPLETE_TYPES_BROKEN\n"); +#endif + fprintf(outfile, "\n#ifdef JPEG_INTERNALS\n\n"); + if (is_shifting_signed(-0x7F7E80B1L)) + fprintf(outfile, "#undef RIGHT_SHIFT_IS_UNSIGNED\n"); + else + fprintf(outfile, "#define RIGHT_SHIFT_IS_UNSIGNED\n"); + fprintf(outfile, "\n#endif /* JPEG_INTERNALS */\n"); + fprintf(outfile, "\n#ifdef JPEG_CJPEG_DJPEG\n\n"); + fprintf(outfile, "#define BMP_SUPPORTED /* BMP image file format */\n"); + fprintf(outfile, "#define GIF_SUPPORTED /* GIF image file format */\n"); + fprintf(outfile, "#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */\n"); + fprintf(outfile, "#undef RLE_SUPPORTED /* Utah RLE image file format */\n"); + fprintf(outfile, "#define TARGA_SUPPORTED /* Targa image file format */\n\n"); + fprintf(outfile, "#undef TWO_FILE_COMMANDLINE /* You may need this on non-Unix systems */\n"); + fprintf(outfile, "#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */\n"); + fprintf(outfile, "#undef DONT_USE_B_MODE\n"); + fprintf(outfile, "/* #define PROGRESS_REPORT */ /* optional */\n"); + fprintf(outfile, "\n#endif /* JPEG_CJPEG_DJPEG */\n"); + + /* Close the jconfig.h file */ + fclose(outfile); + + /* User report */ + printf("Configuration check for Independent JPEG Group's software done.\n"); + printf("\nI have written the jconfig.h file for you.\n\n"); +#ifdef HAVE_PROTOTYPES + printf("You should use makefile.ansi as the starting point for your Makefile.\n"); +#else + printf("You should use makefile.unix as the starting point for your Makefile.\n"); +#endif + +#ifdef NEED_SPECIAL_INCLUDE + printf("\nYou'll need to change jconfig.h to include the system include file\n"); + printf("that you found type size_t in, or add a direct definition of type\n"); + printf("size_t if that's what you used. Just add it to the end.\n"); +#endif + + return 0; +} diff --git a/src/dep/src/irrlicht/jpeglib/coderules.doc b/src/dep/src/irrlicht/jpeglib/coderules.doc index 2c56534..0ab5d9b 100644 --- a/src/dep/src/irrlicht/jpeglib/coderules.doc +++ b/src/dep/src/irrlicht/jpeglib/coderules.doc @@ -1,118 +1,118 @@ -IJG JPEG LIBRARY: CODING RULES - -Copyright (C) 1991-1996, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -Since numerous people will be contributing code and bug fixes, it's important -to establish a common coding style. The goal of using similar coding styles -is much more important than the details of just what that style is. - -In general we follow the recommendations of "Recommended C Style and Coding -Standards" revision 6.1 (Cannon et al. as modified by Spencer, Keppel and -Brader). This document is available in the IJG FTP archive (see -jpeg/doc/cstyle.ms.tbl.Z, or cstyle.txt.Z for those without nroff/tbl). - -Block comments should be laid out thusly: - -/* - * Block comments in this style. - */ - -We indent statements in K&R style, e.g., - if (test) { - then-part; - } else { - else-part; - } -with two spaces per indentation level. (This indentation convention is -handled automatically by GNU Emacs and many other text editors.) - -Multi-word names should be written in lower case with underscores, e.g., -multi_word_name (not multiWordName). Preprocessor symbols and enum constants -are similar but upper case (MULTI_WORD_NAME). Names should be unique within -the first fifteen characters. (On some older systems, global names must be -unique within six characters. We accommodate this without cluttering the -source code by using macros to substitute shorter names.) - -We use function prototypes everywhere; we rely on automatic source code -transformation to feed prototype-less C compilers. Transformation is done -by the simple and portable tool 'ansi2knr.c' (courtesy of Ghostscript). -ansi2knr is not very bright, so it imposes a format requirement on function -declarations: the function name MUST BEGIN IN COLUMN 1. Thus all functions -should be written in the following style: - -LOCAL(int *) -function_name (int a, char *b) -{ - code... -} - -Note that each function definition must begin with GLOBAL(type), LOCAL(type), -or METHODDEF(type). These macros expand to "static type" or just "type" as -appropriate. They provide a readable indication of the routine's usage and -can readily be changed for special needs. (For instance, special linkage -keywords can be inserted for use in Windows DLLs.) - -ansi2knr does not transform method declarations (function pointers in -structs). We handle these with a macro JMETHOD, defined as - #ifdef HAVE_PROTOTYPES - #define JMETHOD(type,methodname,arglist) type (*methodname) arglist - #else - #define JMETHOD(type,methodname,arglist) type (*methodname) () - #endif -which is used like this: - struct function_pointers { - JMETHOD(void, init_entropy_encoder, (int somearg, jparms *jp)); - JMETHOD(void, term_entropy_encoder, (void)); - }; -Note the set of parentheses surrounding the parameter list. - -A similar solution is used for forward and external function declarations -(see the EXTERN and JPP macros). - -If the code is to work on non-ANSI compilers, we cannot rely on a prototype -declaration to coerce actual parameters into the right types. Therefore, use -explicit casts on actual parameters whenever the actual parameter type is not -identical to the formal parameter. Beware of implicit conversions to "int". - -It seems there are some non-ANSI compilers in which the sizeof() operator -is defined to return int, yet size_t is defined as long. Needless to say, -this is brain-damaged. Always use the SIZEOF() macro in place of sizeof(), -so that the result is guaranteed to be of type size_t. - - -The JPEG library is intended to be used within larger programs. Furthermore, -we want it to be reentrant so that it can be used by applications that process -multiple images concurrently. The following rules support these requirements: - -1. Avoid direct use of file I/O, "malloc", error report printouts, etc; -pass these through the common routines provided. - -2. Minimize global namespace pollution. Functions should be declared static -wherever possible. (Note that our method-based calling conventions help this -a lot: in many modules only the initialization function will ever need to be -called directly, so only that function need be externally visible.) All -global function names should begin with "jpeg_", and should have an -abbreviated name (unique in the first six characters) substituted by macro -when NEED_SHORT_EXTERNAL_NAMES is set. - -3. Don't use global variables; anything that must be used in another module -should be in the common data structures. - -4. Don't use static variables except for read-only constant tables. Variables -that should be private to a module can be placed into private structures (see -the system architecture document, structure.doc). - -5. Source file names should begin with "j" for files that are part of the -library proper; source files that are not part of the library, such as cjpeg.c -and djpeg.c, do not begin with "j". Keep source file names to eight -characters (plus ".c" or ".h", etc) to make life easy for MS-DOSers. Keep -compression and decompression code in separate source files --- some -applications may want only one half of the library. - -Note: these rules (particularly #4) are not followed religiously in the -modules that are used in cjpeg/djpeg but are not part of the JPEG library -proper. Those modules are not really intended to be used in other -applications. +IJG JPEG LIBRARY: CODING RULES + +Copyright (C) 1991-1996, Thomas G. Lane. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +Since numerous people will be contributing code and bug fixes, it's important +to establish a common coding style. The goal of using similar coding styles +is much more important than the details of just what that style is. + +In general we follow the recommendations of "Recommended C Style and Coding +Standards" revision 6.1 (Cannon et al. as modified by Spencer, Keppel and +Brader). This document is available in the IJG FTP archive (see +jpeg/doc/cstyle.ms.tbl.Z, or cstyle.txt.Z for those without nroff/tbl). + +Block comments should be laid out thusly: + +/* + * Block comments in this style. + */ + +We indent statements in K&R style, e.g., + if (test) { + then-part; + } else { + else-part; + } +with two spaces per indentation level. (This indentation convention is +handled automatically by GNU Emacs and many other text editors.) + +Multi-word names should be written in lower case with underscores, e.g., +multi_word_name (not multiWordName). Preprocessor symbols and enum constants +are similar but upper case (MULTI_WORD_NAME). Names should be unique within +the first fifteen characters. (On some older systems, global names must be +unique within six characters. We accommodate this without cluttering the +source code by using macros to substitute shorter names.) + +We use function prototypes everywhere; we rely on automatic source code +transformation to feed prototype-less C compilers. Transformation is done +by the simple and portable tool 'ansi2knr.c' (courtesy of Ghostscript). +ansi2knr is not very bright, so it imposes a format requirement on function +declarations: the function name MUST BEGIN IN COLUMN 1. Thus all functions +should be written in the following style: + +LOCAL(int *) +function_name (int a, char *b) +{ + code... +} + +Note that each function definition must begin with GLOBAL(type), LOCAL(type), +or METHODDEF(type). These macros expand to "static type" or just "type" as +appropriate. They provide a readable indication of the routine's usage and +can readily be changed for special needs. (For instance, special linkage +keywords can be inserted for use in Windows DLLs.) + +ansi2knr does not transform method declarations (function pointers in +structs). We handle these with a macro JMETHOD, defined as + #ifdef HAVE_PROTOTYPES + #define JMETHOD(type,methodname,arglist) type (*methodname) arglist + #else + #define JMETHOD(type,methodname,arglist) type (*methodname) () + #endif +which is used like this: + struct function_pointers { + JMETHOD(void, init_entropy_encoder, (int somearg, jparms *jp)); + JMETHOD(void, term_entropy_encoder, (void)); + }; +Note the set of parentheses surrounding the parameter list. + +A similar solution is used for forward and external function declarations +(see the EXTERN and JPP macros). + +If the code is to work on non-ANSI compilers, we cannot rely on a prototype +declaration to coerce actual parameters into the right types. Therefore, use +explicit casts on actual parameters whenever the actual parameter type is not +identical to the formal parameter. Beware of implicit conversions to "int". + +It seems there are some non-ANSI compilers in which the sizeof() operator +is defined to return int, yet size_t is defined as long. Needless to say, +this is brain-damaged. Always use the SIZEOF() macro in place of sizeof(), +so that the result is guaranteed to be of type size_t. + + +The JPEG library is intended to be used within larger programs. Furthermore, +we want it to be reentrant so that it can be used by applications that process +multiple images concurrently. The following rules support these requirements: + +1. Avoid direct use of file I/O, "malloc", error report printouts, etc; +pass these through the common routines provided. + +2. Minimize global namespace pollution. Functions should be declared static +wherever possible. (Note that our method-based calling conventions help this +a lot: in many modules only the initialization function will ever need to be +called directly, so only that function need be externally visible.) All +global function names should begin with "jpeg_", and should have an +abbreviated name (unique in the first six characters) substituted by macro +when NEED_SHORT_EXTERNAL_NAMES is set. + +3. Don't use global variables; anything that must be used in another module +should be in the common data structures. + +4. Don't use static variables except for read-only constant tables. Variables +that should be private to a module can be placed into private structures (see +the system architecture document, structure.doc). + +5. Source file names should begin with "j" for files that are part of the +library proper; source files that are not part of the library, such as cjpeg.c +and djpeg.c, do not begin with "j". Keep source file names to eight +characters (plus ".c" or ".h", etc) to make life easy for MS-DOSers. Keep +compression and decompression code in separate source files --- some +applications may want only one half of the library. + +Note: these rules (particularly #4) are not followed religiously in the +modules that are used in cjpeg/djpeg but are not part of the JPEG library +proper. Those modules are not really intended to be used in other +applications. diff --git a/src/dep/src/irrlicht/jpeglib/config.guess b/src/dep/src/irrlicht/jpeglib/config.guess index f60829f..413ed41 100644 --- a/src/dep/src/irrlicht/jpeglib/config.guess +++ b/src/dep/src/irrlicht/jpeglib/config.guess @@ -1,883 +1,883 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. -# -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Written by Per Bothner . -# The master version of this file is at the FSF in /home/gd/gnu/lib. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit system type (host/target name). -# -# Only a few systems have been added to this list; please add others -# (but try to keep the structure clean). -# - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 8/24/94.) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15 - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - alpha:OSF1:*:*) - if test $UNAME_RELEASE = "V4.0"; then - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - fi - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - cat <dummy.s - .globl main - .ent main -main: - .frame \$30,0,\$26,0 - .prologue 0 - .long 0x47e03d80 # implver $0 - lda \$2,259 - .long 0x47e20c21 # amask $2,$1 - srl \$1,8,\$2 - sll \$2,2,\$2 - sll \$0,3,\$0 - addl \$1,\$0,\$0 - addl \$2,\$0,\$0 - ret \$31,(\$26),1 - .end main -EOF - ${CC-cc} dummy.s -o dummy 2>/dev/null - if test "$?" = 0 ; then - ./dummy - case "$?" in - 7) - UNAME_MACHINE="alpha" - ;; - 15) - UNAME_MACHINE="alphaev5" - ;; - 14) - UNAME_MACHINE="alphaev56" - ;; - 10) - UNAME_MACHINE="alphapca56" - ;; - 16) - UNAME_MACHINE="alphaev6" - ;; - esac - fi - rm -f dummy.s dummy - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]` - exit 0 ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit 0 ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-cbm-sysv4 - exit 0;; - amiga:NetBSD:*:*) - echo m68k-cbm-netbsd${UNAME_RELEASE} - exit 0 ;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc64:OpenBSD:*:*) - echo mips64el-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hkmips:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; - arm32:NetBSD:*:*) - echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - SR2?01:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit 0;; - Pyramid*:OSx*:*:*|MIS*:OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit 0 ;; - NILE:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit 0 ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit 0 ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; - atari*:NetBSD:*:*) - echo m68k-atari-netbsd${UNAME_RELEASE} - exit 0 ;; - atari*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sun3*:NetBSD:*:*) - echo m68k-sun-netbsd${UNAME_RELEASE} - exit 0 ;; - sun3*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:NetBSD:*:*) - echo m68k-apple-netbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit 0 ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - 2020:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - sed 's/^ //' << EOF >dummy.c - int main (argc, argv) int argc; char **argv; { - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - ${CC-cc} dummy.c -o dummy \ - && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && rm dummy.c dummy && exit 0 - rm -f dummy.c dummy - echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit 0 ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit 0 ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit 0 ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit 0 ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ - -o ${TARGET_BINARY_INTERFACE}x = x ] ; then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else echo i586-dg-dgux${UNAME_RELEASE} - fi - exit 0 ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit 0 ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit 0 ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit 0 ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit 0 ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i?86:AIX:*:*) - echo i386-ibm-aix - exit 0 ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - sed 's/^ //' << EOF >dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 - rm -f dummy.c dummy - echo rs6000-ibm-aix3.2.5 - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit 0 ;; - *:AIX:*:4) - if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=4.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit 0 ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit 0 ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit 0 ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit 0 ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit 0 ;; - 9000/[3478]??:HP-UX:*:*) - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;; - 9000/8?? ) HP_ARCH=hppa1.0 ;; - esac - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; - 3050*:HI-UX:*:*) - sed 's/^ //' << EOF >dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 - rm -f dummy.c dummy - echo unknown-hitachi-hiuxwe2 - exit 0 ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit 0 ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit 0 ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit 0 ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit 0 ;; - i?86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit 0 ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit 0 ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit 0 ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit 0 ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit 0 ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit 0 ;; - CRAY*X-MP:*:*:*) - echo xmp-cray-unicos - exit 0 ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} - exit 0 ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ - exit 0 ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} - exit 0 ;; - CRAY-2:*:*:*) - echo cray2-cray-unicos - exit 0 ;; - F300:UNIX_System_V:*:*) - FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; - F301:UNIX_System_V:*:*) - echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` - exit 0 ;; - hp3[0-9][05]:NetBSD:*:*) - echo m68k-hp-netbsd${UNAME_RELEASE} - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - i?86:BSD/386:*:* | *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; - *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - *:NetBSD:*:*) - echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - i*:CYGWIN*:*) - echo i386-pc-cygwin32 - exit 0 ;; - i*:MINGW*:*) - echo i386-pc-mingw32 - exit 0 ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin32 - exit 0 ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - *:GNU:*:*) - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; - *:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. - ld_help_string=`ld --help 2>&1` - ld_supported_emulations=`echo $ld_help_string \ - | sed -ne '/supported emulations:/!d - s/[ ][ ]*/ /g - s/.*supported emulations: *// - s/ .*// - p'` - case "$ld_supported_emulations" in - i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;; - i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;; - sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; - m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; - elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;; - esac - - if test "${UNAME_MACHINE}" = "alpha" ; then - sed 's/^ //' <dummy.s - .globl main - .ent main - main: - .frame \$30,0,\$26,0 - .prologue 0 - .long 0x47e03d80 # implver $0 - lda \$2,259 - .long 0x47e20c21 # amask $2,$1 - srl \$1,8,\$2 - sll \$2,2,\$2 - sll \$0,3,\$0 - addl \$1,\$0,\$0 - addl \$2,\$0,\$0 - ret \$31,(\$26),1 - .end main -EOF - LIBC="" - ${CC-cc} dummy.s -o dummy 2>/dev/null - if test "$?" = 0 ; then - ./dummy - case "$?" in - 7) - UNAME_MACHINE="alpha" - ;; - 15) - UNAME_MACHINE="alphaev5" - ;; - 14) - UNAME_MACHINE="alphaev56" - ;; - 10) - UNAME_MACHINE="alphapca56" - ;; - 16) - UNAME_MACHINE="alphaev6" - ;; - esac - - objdump --private-headers dummy | \ - grep ld.so.1 > /dev/null - if test "$?" = 0 ; then - LIBC="libc1" - fi - fi - rm -f dummy.s dummy - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 - elif test "${UNAME_MACHINE}" = "mips" ; then - cat >dummy.c </dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 - rm -f dummy.c dummy - else - # Either a pre-BFD a.out linker (linux-gnuoldld) - # or one that does not give us useful --help. - # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. - # If ld does not provide *any* "supported emulations:" - # that means it is gnuoldld. - echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" - test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 - - case "${UNAME_MACHINE}" in - i?86) - VENDOR=pc; - ;; - *) - VENDOR=unknown; - ;; - esac - # Determine whether the default compiler is a.out or elf - cat >dummy.c < -main(argc, argv) - int argc; - char *argv[]; -{ -#ifdef __ELF__ -# ifdef __GLIBC__ -# if __GLIBC__ >= 2 - printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); -# else - printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); -# endif -# else - printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); -# endif -#else - printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); -#endif - return 0; -} -EOF - ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 - rm -f dummy.c dummy - fi ;; -# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions -# are messed up and put the nodename in both sysname and nodename. - i?86:DYNIX/ptx:4*:*) - echo i386-sequent-sysv4 - exit 0 ;; - i?86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; - i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} - fi - exit 0 ;; - i?86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` - (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit 0 ;; - pc:*:*:*) - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit 0 ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit 0 ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit 0 ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit 0 ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit 0 ;; - M68*:*:R3V[567]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; - m68*:LynxOS:2.*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit 0 ;; - i?86:LynxOS:2.*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit 0 ;; - PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit 0 ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit 0 ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit 0 ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; - news*:NEWS-OS:*:6*) - echo mips-sony-newsos6 - exit 0 ;; - R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit 0 ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -cat >dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -#if !defined (ultrix) - printf ("vax-dec-bsd\n"); exit (0); -#else - printf ("vax-dec-ultrix\n"); exit (0); -#endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 -rm -f dummy.c dummy - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit 0 ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - c34*) - echo c34-convex-bsd - exit 0 ;; - c38*) - echo c38-convex-bsd - exit 0 ;; - c4*) - echo c4-convex-bsd - exit 0 ;; - esac -fi - -#echo '(Unable to guess system type)' 1>&2 - -exit 1 +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Written by Per Bothner . +# The master version of this file is at the FSF in /home/gd/gnu/lib. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit system type (host/target name). +# +# Only a few systems have been added to this list; please add others +# (but try to keep the structure clean). +# + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 8/24/94.) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15 + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + cat <dummy.s + .globl main + .ent main +main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d80 # implver $0 + lda \$2,259 + .long 0x47e20c21 # amask $2,$1 + srl \$1,8,\$2 + sll \$2,2,\$2 + sll \$0,3,\$0 + addl \$1,\$0,\$0 + addl \$2,\$0,\$0 + ret \$31,(\$26),1 + .end main +EOF + ${CC-cc} dummy.s -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy + case "$?" in + 7) + UNAME_MACHINE="alpha" + ;; + 15) + UNAME_MACHINE="alphaev5" + ;; + 14) + UNAME_MACHINE="alphaev56" + ;; + 10) + UNAME_MACHINE="alphapca56" + ;; + 16) + UNAME_MACHINE="alphaev6" + ;; + esac + fi + rm -f dummy.s dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]` + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-cbm-sysv4 + exit 0;; + amiga:NetBSD:*:*) + echo m68k-cbm-netbsd${UNAME_RELEASE} + exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + arm32:NetBSD:*:*) + echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + SR2?01:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:*|MIS*:OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + atari*:NetBSD:*:*) + echo m68k-atari-netbsd${UNAME_RELEASE} + exit 0 ;; + atari*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3*:NetBSD:*:*) + echo m68k-sun-netbsd${UNAME_RELEASE} + exit 0 ;; + sun3*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:NetBSD:*:*) + echo m68k-apple-netbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + sed 's/^ //' << EOF >dummy.c + int main (argc, argv) int argc; char **argv; { + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + ${CC-cc} dummy.c -o dummy \ + && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ + -o ${TARGET_BINARY_INTERFACE}x = x ] ; then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i?86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + sed 's/^ //' << EOF >dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:4) + if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=4.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[3478]??:HP-UX:*:*) + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;; + 9000/8?? ) HP_ARCH=hppa1.0 ;; + esac + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + sed 's/^ //' << EOF >dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i?86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:*:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + F300:UNIX_System_V:*:*) + FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + F301:UNIX_System_V:*:*) + echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` + exit 0 ;; + hp3[0-9][05]:NetBSD:*:*) + echo m68k-hp-netbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + i?86:BSD/386:*:* | *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + *:NetBSD:*:*) + echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + i*:CYGWIN*:*) + echo i386-pc-cygwin32 + exit 0 ;; + i*:MINGW*:*) + echo i386-pc-mingw32 + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin32 + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + *:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. + ld_help_string=`ld --help 2>&1` + ld_supported_emulations=`echo $ld_help_string \ + | sed -ne '/supported emulations:/!d + s/[ ][ ]*/ /g + s/.*supported emulations: *// + s/ .*// + p'` + case "$ld_supported_emulations" in + i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;; + i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;; + sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;; + esac + + if test "${UNAME_MACHINE}" = "alpha" ; then + sed 's/^ //' <dummy.s + .globl main + .ent main + main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d80 # implver $0 + lda \$2,259 + .long 0x47e20c21 # amask $2,$1 + srl \$1,8,\$2 + sll \$2,2,\$2 + sll \$0,3,\$0 + addl \$1,\$0,\$0 + addl \$2,\$0,\$0 + ret \$31,(\$26),1 + .end main +EOF + LIBC="" + ${CC-cc} dummy.s -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy + case "$?" in + 7) + UNAME_MACHINE="alpha" + ;; + 15) + UNAME_MACHINE="alphaev5" + ;; + 14) + UNAME_MACHINE="alphaev56" + ;; + 10) + UNAME_MACHINE="alphapca56" + ;; + 16) + UNAME_MACHINE="alphaev6" + ;; + esac + + objdump --private-headers dummy | \ + grep ld.so.1 > /dev/null + if test "$?" = 0 ; then + LIBC="libc1" + fi + fi + rm -f dummy.s dummy + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 + elif test "${UNAME_MACHINE}" = "mips" ; then + cat >dummy.c </dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + else + # Either a pre-BFD a.out linker (linux-gnuoldld) + # or one that does not give us useful --help. + # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. + # If ld does not provide *any* "supported emulations:" + # that means it is gnuoldld. + echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" + test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 + + case "${UNAME_MACHINE}" in + i?86) + VENDOR=pc; + ;; + *) + VENDOR=unknown; + ;; + esac + # Determine whether the default compiler is a.out or elf + cat >dummy.c < +main(argc, argv) + int argc; + char *argv[]; +{ +#ifdef __ELF__ +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +#else + printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); +#endif + return 0; +} +EOF + ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + fi ;; +# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions +# are messed up and put the nodename in both sysname and nodename. + i?86:DYNIX/ptx:4*:*) + echo i386-sequent-sysv4 + exit 0 ;; + i?86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} + fi + exit 0 ;; + i?86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + pc:*:*:*) + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i?86:LynxOS:2.*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:*:6*) + echo mips-sony-newsos6 + exit 0 ;; + R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +cat >dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +#if !defined (ultrix) + printf ("vax-dec-bsd\n"); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 +rm -f dummy.c dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +#echo '(Unable to guess system type)' 1>&2 + +exit 1 diff --git a/src/dep/src/irrlicht/jpeglib/config.sub b/src/dep/src/irrlicht/jpeglib/config.sub index fe5c364..213a6d4 100644 --- a/src/dep/src/irrlicht/jpeglib/config.sub +++ b/src/dep/src/irrlicht/jpeglib/config.sub @@ -1,954 +1,954 @@ -#! /bin/sh -# Configuration validation subroutine script, version 1.1. -# Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -if [ x$1 = x ] -then - echo Configuration name missing. 1>&2 - echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 - echo "or $0 ALIAS" 1>&2 - echo where ALIAS is a recognized configuration type. 1>&2 - exit 1 -fi - -# First pass through any local machine types. -case $1 in - *local*) - echo $1 - exit 0 - ;; - *) - ;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - linux-gnu*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple) - os= - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ - | arme[lb] | pyramid | mn10200 | mn10300 \ - | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \ - | alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \ - | i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \ - | mips64 | mipsel | mips64el | mips64orion | mips64orionel \ - | mipstx39 | mipstx39el \ - | sparc | sparclet | sparclite | sparc64 | v850) - basic_machine=$basic_machine-unknown - ;; - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i[3456]86) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - vax-* | tahoe-* | i[3456]86-* | i860-* | m32r-* | m68k-* | m68000-* \ - | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ - | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ - | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \ - | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \ - | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \ - | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \ - | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ - | sparc64-* | mips64-* | mipsel-* \ - | mips64el-* | mips64orion-* | mips64orionel-* \ - | mipstx39-* | mipstx39el-* \ - | f301-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-cbm - ;; - amigaos | amigados) - basic_machine=m68k-cbm - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-cbm - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | ymp) - basic_machine=ymp-cray - os=-unicos - ;; - cray2) - basic_machine=cray2-cray - os=-unicos - ;; - [ctj]90-cray) - basic_machine=c90-cray - os=-unicos - ;; - crds | unos) - basic_machine=m68k-crds - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - os=-mvs - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i[3456]86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i[3456]86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i[3456]86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i[3456]86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - miniframe) - basic_machine=m68000-convergent - ;; - mipsel*-linux*) - basic_machine=mipsel-unknown - os=-linux-gnu - ;; - mips*-linux*) - basic_machine=mips-unknown - os=-linux-gnu - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - np1) - basic_machine=np1-gould - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5) - basic_machine=i586-intel - ;; - pentiumpro | p6) - basic_machine=i686-intel - ;; - pentium-* | p5-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - k5) - # We don't have specific support for AMD's K5 yet, so just call it a Pentium - basic_machine=i586-amd - ;; - nexen) - # We don't have specific support for Nexgen yet, so just call it a Pentium - basic_machine=i586-nexgen - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=rs6000-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - xmp) - basic_machine=xmp-cray - os=-unicos - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - mips) - if [ x$os = x-linux-gnu ]; then - basic_machine=mips-unknown - else - basic_machine=mips-mips - fi - ;; - romp) - basic_machine=romp-ibm - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sparc) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -ctix* | -uts*) - os=-sysv - ;; - -ns2 ) - os=-nextstep2 - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -xenix) - os=-xenix - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-semi) - os=-aout - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-ibm) - os=-aix - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f301-fujitsu) - os=-uxpv - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -hpux*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -vxsim* | -vxworks*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os +#! /bin/sh +# Configuration validation subroutine script, version 1.1. +# Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +if [ x$1 = x ] +then + echo Configuration name missing. 1>&2 + echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 + echo "or $0 ALIAS" 1>&2 + echo where ALIAS is a recognized configuration type. 1>&2 + exit 1 +fi + +# First pass through any local machine types. +case $1 in + *local*) + echo $1 + exit 0 + ;; + *) + ;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + linux-gnu*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple) + os= + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ + | arme[lb] | pyramid | mn10200 | mn10300 \ + | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \ + | alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \ + | i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \ + | mips64 | mipsel | mips64el | mips64orion | mips64orionel \ + | mipstx39 | mipstx39el \ + | sparc | sparclet | sparclite | sparc64 | v850) + basic_machine=$basic_machine-unknown + ;; + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i[3456]86) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + vax-* | tahoe-* | i[3456]86-* | i860-* | m32r-* | m68k-* | m68000-* \ + | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ + | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ + | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \ + | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \ + | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \ + | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \ + | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ + | sparc64-* | mips64-* | mipsel-* \ + | mips64el-* | mips64orion-* | mips64orionel-* \ + | mipstx39-* | mipstx39el-* \ + | f301-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-cbm + ;; + amigaos | amigados) + basic_machine=m68k-cbm + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-cbm + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [ctj]90-cray) + basic_machine=c90-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + os=-mvs + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i[3456]86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i[3456]86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i[3456]86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i[3456]86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + miniframe) + basic_machine=m68000-convergent + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + np1) + basic_machine=np1-gould + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5) + basic_machine=i586-intel + ;; + pentiumpro | p6) + basic_machine=i686-intel + ;; + pentium-* | p5-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + k5) + # We don't have specific support for AMD's K5 yet, so just call it a Pentium + basic_machine=i586-amd + ;; + nexen) + # We don't have specific support for Nexgen yet, so just call it a Pentium + basic_machine=i586-nexgen + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=rs6000-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sparc) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -xenix) + os=-xenix + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-semi) + os=-aout + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-ibm) + os=-aix + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f301-fujitsu) + os=-uxpv + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -hpux*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os diff --git a/src/dep/src/irrlicht/jpeglib/configure b/src/dep/src/irrlicht/jpeglib/configure index d3239e7..35c9db5 100644 --- a/src/dep/src/irrlicht/jpeglib/configure +++ b/src/dep/src/irrlicht/jpeglib/configure @@ -1,2011 +1,2011 @@ -#! /bin/sh - -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.12 -# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. - -# Defaults: -ac_help= -ac_default_prefix=/usr/local -# Any additions from configure.in: -ac_help="$ac_help - --enable-shared build shared library using GNU libtool" -ac_help="$ac_help - --enable-static build static library using GNU libtool" -ac_help="$ac_help - --enable-maxmem[=N] enable use of temp files, set max mem usage to N MB" -ac_help="$ac_help -" - -# Initialize some variables set by options. -# The variables have the same names as the options, with -# dashes changed to underlines. -build=NONE -cache_file=./config.cache -exec_prefix=NONE -host=NONE -no_create= -nonopt=NONE -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -target=NONE -verbose= -x_includes=NONE -x_libraries=NONE -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' -includedir='${prefix}/include' -oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' - -# Initialize some other variables. -subdirs= -MFLAGS= MAKEFLAGS= -# Maximum number of lines to put in a shell here document. -ac_max_here_lines=12 - -ac_prev= -for ac_option -do - - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case "$ac_option" in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build="$ac_optarg" ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir="$ac_optarg" ;; - - -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; - - -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "enable_${ac_feature}='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [same as prefix] - --bindir=DIR user executables in DIR [EPREFIX/bin] - --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] - --libexecdir=DIR program executables in DIR [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data in DIR - [PREFIX/share] - --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data in DIR - [PREFIX/com] - --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] - --libdir=DIR object code libraries in DIR [EPREFIX/lib] - --includedir=DIR C header files in DIR [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] - --infodir=DIR info documentation in DIR [PREFIX/info] - --mandir=DIR man documentation in DIR [PREFIX/man] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM - run sed PROGRAM on installed program names -EOF - cat << EOF -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR -EOF - if test -n "$ac_help"; then - echo "--enable and --with options recognized:$ac_help" - fi - exit 0 ;; - - -host | --host | --hos | --ho) - ac_prev=host ;; - -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir="$ac_optarg" ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir="$ac_optarg" ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir="$ac_optarg" ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir="$ac_optarg" ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir="$ac_optarg" ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir="$ac_optarg" ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir="$ac_optarg" ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir="$ac_optarg" ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir="$ac_optarg" ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir="$ac_optarg" ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.12" - exit 0 ;; - - -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "with_${ac_package}='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; - - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } - ;; - - *=*) - varname=`echo "$ac_option"|sed -e 's/=.*//'` - # Reject names that aren't valid shell variable names. - if test -n "`echo $varname| sed 's/[a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $varname: invalid shell variable name" 1>&2; exit 1; } - fi - val="`echo "$ac_option"|sed 's/[^=]*=//'`" - test -n "$verbose" && echo " setting shell variable $varname to $val" - eval "$varname='$val'" - eval "export $varname" ;; - - *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" - ;; - - esac -done - -if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } -fi - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 6 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 - -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg -do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; - esac -done - -# NLS nuisances. -# Only set these to C if already set. These must not be set unconditionally -# because not all systems understand e.g. LANG=C (notably SCO). -# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! -# Non-C LC_CTYPE values break the ctype check. -if test "${LANG+set}" = set; then LANG=C; export LANG; fi -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi -if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=jcmaster.c - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } - else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } - fi -fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` - -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" - . "$ac_site_file" - fi -done - - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi - - - -# Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:538: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:567: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - ac_prog_rejected=no - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - break - fi - done - IFS="$ac_save_ifs" -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# -gt 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - set dummy "$ac_dir/$ac_word" "$@" - shift - ac_cv_prog_CC="$@" - fi -fi -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } -fi - -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:615: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - ac_cv_prog_cc_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cc_cross=no - else - ac_cv_prog_cc_cross=yes - fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cc_works=no -fi -rm -fr conftest* - -echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 -if test $ac_cv_prog_cc_works = no; then - { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:649: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 -cross_compiling=$ac_cv_prog_cc_cross - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:654: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes -else - ac_cv_prog_gcc=no -fi -fi - -echo "$ac_t""$ac_cv_prog_gcc" 1>&6 - -if test $ac_cv_prog_gcc = yes; then - GCC=yes - test "${CFLAGS+set}" = set || CFLAGS="-O2" -else - GCC= - test "${CFLAGS+set}" = set || CFLAGS="-O" -fi - -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:681: checking how to run the C preprocessor" >&5 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:702: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:719: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* -fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" -fi - CPP="$ac_cv_prog_CPP" -else - ac_cv_prog_CPP="$CPP" -fi -echo "$ac_t""$CPP" 1>&6 - -echo $ac_n "checking for function prototypes""... $ac_c" 1>&6 -echo "configure:742: checking for function prototypes" >&5 -if eval "test \"`echo '$''{'ijg_cv_have_prototypes'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ijg_cv_have_prototypes=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ijg_cv_have_prototypes=no -fi -rm -f conftest* -fi - -echo "$ac_t""$ijg_cv_have_prototypes" 1>&6 -if test $ijg_cv_have_prototypes = yes; then - cat >> confdefs.h <<\EOF -#define HAVE_PROTOTYPES -EOF - -else - echo Your compiler does not seem to know about function prototypes. - echo Perhaps it needs a special switch to enable ANSI C mode. - echo If so, we recommend running configure like this: - echo " ./configure CC='cc -switch'" - echo where -switch is the proper switch. -fi -ac_safe=`echo "stddef.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for stddef.h""... $ac_c" 1>&6 -echo "configure:792: checking for stddef.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:802: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF -#define HAVE_STDDEF_H -EOF - -else - echo "$ac_t""no" 1>&6 -fi - -ac_safe=`echo "stdlib.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for stdlib.h""... $ac_c" 1>&6 -echo "configure:828: checking for stdlib.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:838: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF -#define HAVE_STDLIB_H -EOF - -else - echo "$ac_t""no" 1>&6 -fi - -ac_safe=`echo "string.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for string.h""... $ac_c" 1>&6 -echo "configure:864: checking for string.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:874: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -cat >> confdefs.h <<\EOF -#define NEED_BSD_STRINGS -EOF - -fi - -echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:900: checking for size_t" >&5 -cat > conftest.$ac_ext < -#endif -#ifdef HAVE_STDLIB_H -#include -#endif -#include -#ifdef NEED_BSD_STRINGS -#include -#else -#include -#endif -typedef size_t my_size_t; - -int main() { - my_size_t foovar; -; return 0; } -EOF -if { (eval echo configure:923: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ijg_size_t_ok=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h" -fi -rm -f conftest* -echo "$ac_t""$ijg_size_t_ok" 1>&6 -if test "$ijg_size_t_ok" != yes; then -ac_safe=`echo "sys/types.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for sys/types.h""... $ac_c" 1>&6 -echo "configure:937: checking for sys/types.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:947: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF -#define NEED_SYS_TYPES_H -EOF - -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "size_t" >/dev/null 2>&1; then - rm -rf conftest* - ijg_size_t_ok="size_t is in sys/types.h" -else - rm -rf conftest* - ijg_size_t_ok=no -fi -rm -f conftest* - -else - echo "$ac_t""no" 1>&6 -ijg_size_t_ok=no -fi - -echo "$ac_t""$ijg_size_t_ok" 1>&6 -if test "$ijg_size_t_ok" = no; then - echo Type size_t is not defined in any of the usual places. - echo Try putting '"typedef unsigned int size_t;"' in jconfig.h. -fi -fi -echo $ac_n "checking for type unsigned char""... $ac_c" 1>&6 -echo "configure:994: checking for type unsigned char" >&5 -cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -cat >> confdefs.h <<\EOF -#define HAVE_UNSIGNED_CHAR -EOF - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 -fi -rm -f conftest* -echo $ac_n "checking for type unsigned short""... $ac_c" 1>&6 -echo "configure:1018: checking for type unsigned short" >&5 -cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -cat >> confdefs.h <<\EOF -#define HAVE_UNSIGNED_SHORT -EOF - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 -fi -rm -f conftest* -echo $ac_n "checking for type void""... $ac_c" 1>&6 -echo "configure:1042: checking for type void" >&5 -cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 -cat >> confdefs.h <<\EOF -#define void char -EOF - -fi -rm -f conftest* - -echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1088: checking for working const" >&5 -if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <j = 5; -} -{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; -} - -; return 0; } -EOF -if { (eval echo configure:1142: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_c_const=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_c_const=no -fi -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_c_const" 1>&6 -if test $ac_cv_c_const = no; then - cat >> confdefs.h <<\EOF -#define const -EOF - -fi - -echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:1163: checking for inline" >&5 -ijg_cv_inline="" -cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ijg_cv_inline="__inline__" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ijg_cv_inline="__inline" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ijg_cv_inline="inline" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* -fi -rm -f conftest* -fi -rm -f conftest* -echo "$ac_t""$ijg_cv_inline" 1>&6 -cat >> confdefs.h <&6 -echo "configure:1224: checking for broken incomplete types" >&5 -cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - echo "$ac_t""ok" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""broken" 1>&6 -cat >> confdefs.h <<\EOF -#define INCOMPLETE_TYPES_BROKEN -EOF - -fi -rm -f conftest* -echo $ac_n "checking for short external names""... $ac_c" 1>&6 -echo "configure:1248: checking for short external names" >&5 -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - echo "$ac_t""ok" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""short" 1>&6 -cat >> confdefs.h <<\EOF -#define NEED_SHORT_EXTERNAL_NAMES -EOF - -fi -rm -f conftest* -echo $ac_n "checking to see if char is signed""... $ac_c" 1>&6 -echo "configure:1275: checking to see if char is signed" >&5 -if test "$cross_compiling" = yes; then - echo Assuming that char is signed on target machine. -echo If it is unsigned, this will be a little bit inefficient. - -else - cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null -then - echo "$ac_t""no" 1>&6 -cat >> confdefs.h <<\EOF -#define CHAR_IS_UNSIGNED -EOF - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - echo "$ac_t""yes" 1>&6 -fi -rm -fr conftest* -fi - -echo $ac_n "checking to see if right shift is signed""... $ac_c" 1>&6 -echo "configure:1323: checking to see if right shift is signed" >&5 -if test "$cross_compiling" = yes; then - echo "$ac_t""Assuming that right shift is signed on target machine." 1>&6 -else - cat > conftest.$ac_ext <> 4; - - if (res == -0x7F7E80CL) { /* expected result for signed shift */ - return 1; /* right shift is signed */ - } - /* see if unsigned-shift hack will fix it. */ - /* we can't just test exact value since it depends on width of long... */ - res |= (~0L) << (32-4); - if (res == -0x7F7E80CL) { /* expected result now? */ - return 0; /* right shift is unsigned */ - } - printf("Right shift isn't acting as I expect it to.\n"); - printf("I fear the JPEG software will not work at all.\n\n"); - return 0; /* try it with unsigned anyway */ -} -main() { - exit(is_shifting_signed(-0x7F7E80B1L)); -} -EOF -if { (eval echo configure:1358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null -then - echo "$ac_t""no" 1>&6 -cat >> confdefs.h <<\EOF -#define RIGHT_SHIFT_IS_UNSIGNED -EOF - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - echo "$ac_t""yes" 1>&6 -fi -rm -fr conftest* -fi - -echo $ac_n "checking to see if fopen accepts b spec""... $ac_c" 1>&6 -echo "configure:1375: checking to see if fopen accepts b spec" >&5 -if test "$cross_compiling" = yes; then - echo "$ac_t""Assuming that it does." 1>&6 -else - cat > conftest.$ac_ext < -main() { - if (fopen("conftestdata", "wb") != NULL) - exit(0); - exit(1); -} -EOF -if { (eval echo configure:1390: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null -then - echo "$ac_t""yes" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - echo "$ac_t""no" 1>&6 -cat >> confdefs.h <<\EOF -#define DONT_USE_B_MODE -EOF - -fi -rm -fr conftest* -fi - -ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/install-sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f $ac_dir/install.sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } -fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1436: checking for a BSD compatible install" >&5 -if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - # Account for people who put trailing slashes in PATH elements. - case "$ac_dir/" in - /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - for ac_prog in ginstall installbsd scoinst install; do - if test -f $ac_dir/$ac_prog; then - if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - # OSF/1 installbsd also uses dspmsg, but is usable. - : - else - ac_cv_path_install="$ac_dir/$ac_prog -c" - break 2 - fi - fi - done - ;; - esac - done - IFS="$ac_save_IFS" - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL="$ac_cv_path_install" - else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the path is relative. - INSTALL="$ac_install_sh" - fi -fi -echo "$ac_t""$INSTALL" 1>&6 - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -# Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1488: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="ranlib" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" -fi -fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - -# Decide whether to use libtool, -# and if so whether to build shared, static, or both flavors of library. -LTSHARED="no" -# Check whether --enable-shared or --disable-shared was given. -if test "${enable_shared+set}" = set; then - enableval="$enable_shared" - LTSHARED="$enableval" -fi - -LTSTATIC="no" -# Check whether --enable-static or --disable-static was given. -if test "${enable_static+set}" = set; then - enableval="$enable_static" - LTSTATIC="$enableval" -fi - -if test "x$LTSHARED" != xno -o "x$LTSTATIC" != xno; then - USELIBTOOL="yes" - LIBTOOL="./libtool" - O="lo" - A="la" - LN='$(LIBTOOL) --mode=link $(CC)' - INSTALL_LIB='$(LIBTOOL) --mode=install ${INSTALL}' - INSTALL_PROGRAM="\$(LIBTOOL) --mode=install $INSTALL_PROGRAM" -else - USELIBTOOL="no" - LIBTOOL="" - O="o" - A="a" - LN='$(CC)' - INSTALL_LIB="$INSTALL_DATA" -fi - - - - - - -# Configure libtool if needed. -if test $USELIBTOOL = yes; then - disable_shared= - disable_static= - if test "x$LTSHARED" = xno; then - disable_shared="--disable-shared" - fi - if test "x$LTSTATIC" = xno; then - disable_static="--disable-static" - fi - $srcdir/ltconfig $disable_shared $disable_static $srcdir/ltmain.sh -fi - -# Select memory manager depending on user input. -# If no "-enable-maxmem", use jmemnobs -MEMORYMGR='jmemnobs.$(O)' -MAXMEM="no" -# Check whether --enable-maxmem or --disable-maxmem was given. -if test "${enable_maxmem+set}" = set; then - enableval="$enable_maxmem" - MAXMEM="$enableval" -fi - -# support --with-maxmem for backwards compatibility with IJG V5. -# Check whether --with-maxmem or --without-maxmem was given. -if test "${with_maxmem+set}" = set; then - withval="$with_maxmem" - MAXMEM="$withval" -fi - -if test "x$MAXMEM" = xyes; then - MAXMEM=1 -fi -if test "x$MAXMEM" != xno; then - if test -n "`echo $MAXMEM | sed 's/[0-9]//g'`"; then - { echo "configure: error: non-numeric argument to --enable-maxmem" 1>&2; exit 1; } - fi - DEFAULTMAXMEM=`expr $MAXMEM \* 1048576` -cat >> confdefs.h <&6 -echo "configure:1596: checking for 'tmpfile()'" >&5 -cat > conftest.$ac_ext < -int main() { - FILE * tfile = tmpfile(); -; return 0; } -EOF -if { (eval echo configure:1605: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -MEMORYMGR='jmemansi.$(O)' -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 -MEMORYMGR='jmemname.$(O)' -cat >> confdefs.h <<\EOF -#define NEED_SIGNAL_CATCHER -EOF - -echo $ac_n "checking for 'mktemp()'""... $ac_c" 1>&6 -echo "configure:1620: checking for 'mktemp()'" >&5 -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 -cat >> confdefs.h <<\EOF -#define NO_MKTEMP -EOF - -fi -rm -f conftest* -fi -rm -f conftest* -fi - - -# Extract the library version ID from jpeglib.h. -echo $ac_n "checking libjpeg version number""... $ac_c" 1>&6 -echo "configure:1650: checking libjpeg version number" >&5 -JPEG_LIB_VERSION=`sed -e '/^#define JPEG_LIB_VERSION/!d' -e 's/^[^0-9]*\([0-9][0-9]*\).*$/\1/' $srcdir/jpeglib.h` -echo "$ac_t""$JPEG_LIB_VERSION" 1>&6 - - -# Prepare to massage makefile.cfg correctly. -if test $ijg_cv_have_prototypes = yes; then - A2K_DEPS="" - COM_A2K="# " -else - A2K_DEPS="ansi2knr" - COM_A2K="" -fi - - -# ansi2knr needs -DBSD if string.h is missing -if test $ac_cv_header_string_h = no; then - ANSI2KNRFLAGS="-DBSD" -else - ANSI2KNRFLAGS="" -fi - -# Substitutions to enable or disable libtool-related stuff -if test $USELIBTOOL = yes -a $ijg_cv_have_prototypes = yes; then - COM_LT="" -else - COM_LT="# " -fi - -if test "x$LTSHARED" != xno; then - FORCE_INSTALL_LIB="install-lib" -else - FORCE_INSTALL_LIB="" -fi - -# Set up -I directives -if test "x$srcdir" = x.; then - INCLUDEFLAGS='-I$(srcdir)' -else - INCLUDEFLAGS='-I. -I$(srcdir)' -fi - -trap '' 1 2 15 - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' -fi - -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - -DEFS=-DHAVE_CONFIG_H - -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} - -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS </dev/null | sed 1q`: -# -# $0 $ac_configure_args -# -# Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. - -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option -do - case "\$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.12" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; - esac -done - -ac_given_srcdir=$srcdir -ac_given_INSTALL="$INSTALL" - -trap 'rm -fr `echo "Makefile:makefile.cfg jconfig.h:jconfig.cfg" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 -EOF -cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF -$ac_vpsub -$extrasub -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@bindir@%$bindir%g -s%@sbindir@%$sbindir%g -s%@libexecdir@%$libexecdir%g -s%@datadir@%$datadir%g -s%@sysconfdir@%$sysconfdir%g -s%@sharedstatedir@%$sharedstatedir%g -s%@localstatedir@%$localstatedir%g -s%@libdir@%$libdir%g -s%@includedir@%$includedir%g -s%@oldincludedir@%$oldincludedir%g -s%@infodir@%$infodir%g -s%@mandir@%$mandir%g -s%@CC@%$CC%g -s%@CPP@%$CPP%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@RANLIB@%$RANLIB%g -s%@LIBTOOL@%$LIBTOOL%g -s%@O@%$O%g -s%@A@%$A%g -s%@LN@%$LN%g -s%@INSTALL_LIB@%$INSTALL_LIB%g -s%@MEMORYMGR@%$MEMORYMGR%g -s%@JPEG_LIB_VERSION@%$JPEG_LIB_VERSION%g -s%@A2K_DEPS@%$A2K_DEPS%g -s%@COM_A2K@%$COM_A2K%g -s%@ANSI2KNRFLAGS@%$ANSI2KNRFLAGS%g -s%@COM_LT@%$COM_LT%g -s%@FORCE_INSTALL_LIB@%$FORCE_INSTALL_LIB%g -s%@INCLUDEFLAGS@%$INCLUDEFLAGS%g - -CEOF -EOF - -cat >> $CONFIG_STATUS <<\EOF - -# Split the substitutions into bite-sized pieces for seds with -# small command number limits, like on Digital OSF/1 and HP-UX. -ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. -ac_file=1 # Number of current file. -ac_beg=1 # First line for current file. -ac_end=$ac_max_sed_cmds # Line after last line for current file. -ac_more_lines=: -ac_sed_cmds="" -while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file - else - sed "${ac_end}q" conftest.subs > conftest.s$ac_file - fi - if test ! -s conftest.s$ac_file; then - ac_more_lines=false - rm -f conftest.s$ac_file - else - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f conftest.s$ac_file" - else - ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" - fi - ac_file=`expr $ac_file + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_cmds` - fi -done -if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat -fi -EOF - -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= - fi - - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; - esac - - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g -" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file -fi; done -rm -f conftest.s* - -# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where -# NAME is the cpp macro being defined and VALUE is the value it is being given. -# -# ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' -ac_dC='\3' -ac_dD='%g' -# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". -ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='\([ ]\)%\1#\2define\3' -ac_uC=' ' -ac_uD='\4%g' -# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_eB='$%\1#\2define\3' -ac_eC=' ' -ac_eD='%g' - -if test "${CONFIG_HEADERS+set}" != set; then -EOF -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -fi -for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - echo creating $ac_file - - rm -f conftest.frag conftest.in conftest.out - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - cat $ac_file_inputs > conftest.in - -EOF - -# Transform confdefs.h into a sed script conftest.vals that substitutes -# the proper values into config.h.in to produce config.h. And first: -# Protect against being on the right side of a sed subst in config.status. -# Protect against being in an unquoted here document in config.status. -rm -f conftest.vals -cat > conftest.hdr <<\EOF -s/[\\&%]/\\&/g -s%[\\$`]%\\&%g -s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp -s%ac_d%ac_u%gp -s%ac_u%ac_e%gp -EOF -sed -n -f conftest.hdr confdefs.h > conftest.vals -rm -f conftest.hdr - -# This sed command replaces #undef with comments. This is necessary, for -# example, in the case of _POSIX_SOURCE, which is predefined and required -# on some systems where configure will not decide to define it. -cat >> conftest.vals <<\EOF -EOF - -# Break up conftest.vals because some shells have a limit on -# the size of here documents, and old seds have small limits too. - -rm -f conftest.tail -while : -do - ac_lines=`grep -c . conftest.vals` - # grep -c gives empty output for an empty file on some AIX systems. - if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi - # Write a limited-size here document to conftest.frag. - echo ' cat > conftest.frag <> $CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS - echo 'CEOF - sed -f conftest.frag conftest.in > conftest.out - rm -f conftest.in - mv conftest.out conftest.in -' >> $CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail - rm -f conftest.vals - mv conftest.tail conftest.vals -done -rm -f conftest.vals - -cat >> $CONFIG_STATUS <<\EOF - rm -f conftest.frag conftest.h - echo "/* $ac_file. Generated automatically by configure. */" > conftest.h - cat conftest.in >> conftest.h - rm -f conftest.in - if cmp -s $ac_file conftest.h 2>/dev/null; then - echo "$ac_file is unchanged" - rm -f conftest.h - else - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - fi - rm -f $ac_file - mv conftest.h $ac_file - fi -fi; done - -EOF -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF - -exit 0 -EOF -chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 - +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.12 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_help="$ac_help + --enable-shared build shared library using GNU libtool" +ac_help="$ac_help + --enable-static build static library using GNU libtool" +ac_help="$ac_help + --enable-maxmem[=N] enable use of temp files, set max mem usage to N MB" +ac_help="$ac_help +" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.12" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *=*) + varname=`echo "$ac_option"|sed -e 's/=.*//'` + # Reject names that aren't valid shell variable names. + if test -n "`echo $varname| sed 's/[a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $varname: invalid shell variable name" 1>&2; exit 1; } + fi + val="`echo "$ac_option"|sed 's/[^=]*=//'`" + test -n "$verbose" && echo " setting shell variable $varname to $val" + eval "$varname='$val'" + eval "export $varname" ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=jcmaster.c + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:538: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:567: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + ac_prog_rejected=no + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:615: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:649: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:654: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes + test "${CFLAGS+set}" = set || CFLAGS="-O2" +else + GCC= + test "${CFLAGS+set}" = set || CFLAGS="-O" +fi + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:681: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:702: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:719: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +echo $ac_n "checking for function prototypes""... $ac_c" 1>&6 +echo "configure:742: checking for function prototypes" >&5 +if eval "test \"`echo '$''{'ijg_cv_have_prototypes'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ijg_cv_have_prototypes=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ijg_cv_have_prototypes=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ijg_cv_have_prototypes" 1>&6 +if test $ijg_cv_have_prototypes = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_PROTOTYPES +EOF + +else + echo Your compiler does not seem to know about function prototypes. + echo Perhaps it needs a special switch to enable ANSI C mode. + echo If so, we recommend running configure like this: + echo " ./configure CC='cc -switch'" + echo where -switch is the proper switch. +fi +ac_safe=`echo "stddef.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for stddef.h""... $ac_c" 1>&6 +echo "configure:792: checking for stddef.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:802: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_STDDEF_H +EOF + +else + echo "$ac_t""no" 1>&6 +fi + +ac_safe=`echo "stdlib.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for stdlib.h""... $ac_c" 1>&6 +echo "configure:828: checking for stdlib.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:838: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_STDLIB_H +EOF + +else + echo "$ac_t""no" 1>&6 +fi + +ac_safe=`echo "string.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for string.h""... $ac_c" 1>&6 +echo "configure:864: checking for string.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:874: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +cat >> confdefs.h <<\EOF +#define NEED_BSD_STRINGS +EOF + +fi + +echo $ac_n "checking for size_t""... $ac_c" 1>&6 +echo "configure:900: checking for size_t" >&5 +cat > conftest.$ac_ext < +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#include +#ifdef NEED_BSD_STRINGS +#include +#else +#include +#endif +typedef size_t my_size_t; + +int main() { + my_size_t foovar; +; return 0; } +EOF +if { (eval echo configure:923: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ijg_size_t_ok=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h" +fi +rm -f conftest* +echo "$ac_t""$ijg_size_t_ok" 1>&6 +if test "$ijg_size_t_ok" != yes; then +ac_safe=`echo "sys/types.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for sys/types.h""... $ac_c" 1>&6 +echo "configure:937: checking for sys/types.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:947: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define NEED_SYS_TYPES_H +EOF + +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "size_t" >/dev/null 2>&1; then + rm -rf conftest* + ijg_size_t_ok="size_t is in sys/types.h" +else + rm -rf conftest* + ijg_size_t_ok=no +fi +rm -f conftest* + +else + echo "$ac_t""no" 1>&6 +ijg_size_t_ok=no +fi + +echo "$ac_t""$ijg_size_t_ok" 1>&6 +if test "$ijg_size_t_ok" = no; then + echo Type size_t is not defined in any of the usual places. + echo Try putting '"typedef unsigned int size_t;"' in jconfig.h. +fi +fi +echo $ac_n "checking for type unsigned char""... $ac_c" 1>&6 +echo "configure:994: checking for type unsigned char" >&5 +cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + echo "$ac_t""yes" 1>&6 +cat >> confdefs.h <<\EOF +#define HAVE_UNSIGNED_CHAR +EOF + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "$ac_t""no" 1>&6 +fi +rm -f conftest* +echo $ac_n "checking for type unsigned short""... $ac_c" 1>&6 +echo "configure:1018: checking for type unsigned short" >&5 +cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + echo "$ac_t""yes" 1>&6 +cat >> confdefs.h <<\EOF +#define HAVE_UNSIGNED_SHORT +EOF + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "$ac_t""no" 1>&6 +fi +rm -f conftest* +echo $ac_n "checking for type void""... $ac_c" 1>&6 +echo "configure:1042: checking for type void" >&5 +cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + echo "$ac_t""yes" 1>&6 +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "$ac_t""no" 1>&6 +cat >> confdefs.h <<\EOF +#define void char +EOF + +fi +rm -f conftest* + +echo $ac_n "checking for working const""... $ac_c" 1>&6 +echo "configure:1088: checking for working const" >&5 +if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <j = 5; +} +{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +} + +; return 0; } +EOF +if { (eval echo configure:1142: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_const=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_c_const=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_c_const" 1>&6 +if test $ac_cv_c_const = no; then + cat >> confdefs.h <<\EOF +#define const +EOF + +fi + +echo $ac_n "checking for inline""... $ac_c" 1>&6 +echo "configure:1163: checking for inline" >&5 +ijg_cv_inline="" +cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ijg_cv_inline="__inline__" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ijg_cv_inline="__inline" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ijg_cv_inline="inline" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* +echo "$ac_t""$ijg_cv_inline" 1>&6 +cat >> confdefs.h <&6 +echo "configure:1224: checking for broken incomplete types" >&5 +cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + echo "$ac_t""ok" 1>&6 +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "$ac_t""broken" 1>&6 +cat >> confdefs.h <<\EOF +#define INCOMPLETE_TYPES_BROKEN +EOF + +fi +rm -f conftest* +echo $ac_n "checking for short external names""... $ac_c" 1>&6 +echo "configure:1248: checking for short external names" >&5 +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + echo "$ac_t""ok" 1>&6 +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "$ac_t""short" 1>&6 +cat >> confdefs.h <<\EOF +#define NEED_SHORT_EXTERNAL_NAMES +EOF + +fi +rm -f conftest* +echo $ac_n "checking to see if char is signed""... $ac_c" 1>&6 +echo "configure:1275: checking to see if char is signed" >&5 +if test "$cross_compiling" = yes; then + echo Assuming that char is signed on target machine. +echo If it is unsigned, this will be a little bit inefficient. + +else + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + echo "$ac_t""no" 1>&6 +cat >> confdefs.h <<\EOF +#define CHAR_IS_UNSIGNED +EOF + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + echo "$ac_t""yes" 1>&6 +fi +rm -fr conftest* +fi + +echo $ac_n "checking to see if right shift is signed""... $ac_c" 1>&6 +echo "configure:1323: checking to see if right shift is signed" >&5 +if test "$cross_compiling" = yes; then + echo "$ac_t""Assuming that right shift is signed on target machine." 1>&6 +else + cat > conftest.$ac_ext <> 4; + + if (res == -0x7F7E80CL) { /* expected result for signed shift */ + return 1; /* right shift is signed */ + } + /* see if unsigned-shift hack will fix it. */ + /* we can't just test exact value since it depends on width of long... */ + res |= (~0L) << (32-4); + if (res == -0x7F7E80CL) { /* expected result now? */ + return 0; /* right shift is unsigned */ + } + printf("Right shift isn't acting as I expect it to.\n"); + printf("I fear the JPEG software will not work at all.\n\n"); + return 0; /* try it with unsigned anyway */ +} +main() { + exit(is_shifting_signed(-0x7F7E80B1L)); +} +EOF +if { (eval echo configure:1358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + echo "$ac_t""no" 1>&6 +cat >> confdefs.h <<\EOF +#define RIGHT_SHIFT_IS_UNSIGNED +EOF + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + echo "$ac_t""yes" 1>&6 +fi +rm -fr conftest* +fi + +echo $ac_n "checking to see if fopen accepts b spec""... $ac_c" 1>&6 +echo "configure:1375: checking to see if fopen accepts b spec" >&5 +if test "$cross_compiling" = yes; then + echo "$ac_t""Assuming that it does." 1>&6 +else + cat > conftest.$ac_ext < +main() { + if (fopen("conftestdata", "wb") != NULL) + exit(0); + exit(1); +} +EOF +if { (eval echo configure:1390: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + echo "$ac_t""yes" 1>&6 +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + echo "$ac_t""no" 1>&6 +cat >> confdefs.h <<\EOF +#define DONT_USE_B_MODE +EOF + +fi +rm -fr conftest* +fi + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:1436: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + for ac_prog in ginstall installbsd scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + # OSF/1 installbsd also uses dspmsg, but is usable. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +# Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1488: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +# Decide whether to use libtool, +# and if so whether to build shared, static, or both flavors of library. +LTSHARED="no" +# Check whether --enable-shared or --disable-shared was given. +if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + LTSHARED="$enableval" +fi + +LTSTATIC="no" +# Check whether --enable-static or --disable-static was given. +if test "${enable_static+set}" = set; then + enableval="$enable_static" + LTSTATIC="$enableval" +fi + +if test "x$LTSHARED" != xno -o "x$LTSTATIC" != xno; then + USELIBTOOL="yes" + LIBTOOL="./libtool" + O="lo" + A="la" + LN='$(LIBTOOL) --mode=link $(CC)' + INSTALL_LIB='$(LIBTOOL) --mode=install ${INSTALL}' + INSTALL_PROGRAM="\$(LIBTOOL) --mode=install $INSTALL_PROGRAM" +else + USELIBTOOL="no" + LIBTOOL="" + O="o" + A="a" + LN='$(CC)' + INSTALL_LIB="$INSTALL_DATA" +fi + + + + + + +# Configure libtool if needed. +if test $USELIBTOOL = yes; then + disable_shared= + disable_static= + if test "x$LTSHARED" = xno; then + disable_shared="--disable-shared" + fi + if test "x$LTSTATIC" = xno; then + disable_static="--disable-static" + fi + $srcdir/ltconfig $disable_shared $disable_static $srcdir/ltmain.sh +fi + +# Select memory manager depending on user input. +# If no "-enable-maxmem", use jmemnobs +MEMORYMGR='jmemnobs.$(O)' +MAXMEM="no" +# Check whether --enable-maxmem or --disable-maxmem was given. +if test "${enable_maxmem+set}" = set; then + enableval="$enable_maxmem" + MAXMEM="$enableval" +fi + +# support --with-maxmem for backwards compatibility with IJG V5. +# Check whether --with-maxmem or --without-maxmem was given. +if test "${with_maxmem+set}" = set; then + withval="$with_maxmem" + MAXMEM="$withval" +fi + +if test "x$MAXMEM" = xyes; then + MAXMEM=1 +fi +if test "x$MAXMEM" != xno; then + if test -n "`echo $MAXMEM | sed 's/[0-9]//g'`"; then + { echo "configure: error: non-numeric argument to --enable-maxmem" 1>&2; exit 1; } + fi + DEFAULTMAXMEM=`expr $MAXMEM \* 1048576` +cat >> confdefs.h <&6 +echo "configure:1596: checking for 'tmpfile()'" >&5 +cat > conftest.$ac_ext < +int main() { + FILE * tfile = tmpfile(); +; return 0; } +EOF +if { (eval echo configure:1605: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + echo "$ac_t""yes" 1>&6 +MEMORYMGR='jmemansi.$(O)' +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "$ac_t""no" 1>&6 +MEMORYMGR='jmemname.$(O)' +cat >> confdefs.h <<\EOF +#define NEED_SIGNAL_CATCHER +EOF + +echo $ac_n "checking for 'mktemp()'""... $ac_c" 1>&6 +echo "configure:1620: checking for 'mktemp()'" >&5 +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + echo "$ac_t""yes" 1>&6 +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "$ac_t""no" 1>&6 +cat >> confdefs.h <<\EOF +#define NO_MKTEMP +EOF + +fi +rm -f conftest* +fi +rm -f conftest* +fi + + +# Extract the library version ID from jpeglib.h. +echo $ac_n "checking libjpeg version number""... $ac_c" 1>&6 +echo "configure:1650: checking libjpeg version number" >&5 +JPEG_LIB_VERSION=`sed -e '/^#define JPEG_LIB_VERSION/!d' -e 's/^[^0-9]*\([0-9][0-9]*\).*$/\1/' $srcdir/jpeglib.h` +echo "$ac_t""$JPEG_LIB_VERSION" 1>&6 + + +# Prepare to massage makefile.cfg correctly. +if test $ijg_cv_have_prototypes = yes; then + A2K_DEPS="" + COM_A2K="# " +else + A2K_DEPS="ansi2knr" + COM_A2K="" +fi + + +# ansi2knr needs -DBSD if string.h is missing +if test $ac_cv_header_string_h = no; then + ANSI2KNRFLAGS="-DBSD" +else + ANSI2KNRFLAGS="" +fi + +# Substitutions to enable or disable libtool-related stuff +if test $USELIBTOOL = yes -a $ijg_cv_have_prototypes = yes; then + COM_LT="" +else + COM_LT="# " +fi + +if test "x$LTSHARED" != xno; then + FORCE_INSTALL_LIB="install-lib" +else + FORCE_INSTALL_LIB="" +fi + +# Set up -I directives +if test "x$srcdir" = x.; then + INCLUDEFLAGS='-I$(srcdir)' +else + INCLUDEFLAGS='-I. -I$(srcdir)' +fi + +trap '' 1 2 15 + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +DEFS=-DHAVE_CONFIG_H + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.12" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "Makefile:makefile.cfg jconfig.h:jconfig.cfg" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@CC@%$CC%g +s%@CPP@%$CPP%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@RANLIB@%$RANLIB%g +s%@LIBTOOL@%$LIBTOOL%g +s%@O@%$O%g +s%@A@%$A%g +s%@LN@%$LN%g +s%@INSTALL_LIB@%$INSTALL_LIB%g +s%@MEMORYMGR@%$MEMORYMGR%g +s%@JPEG_LIB_VERSION@%$JPEG_LIB_VERSION%g +s%@A2K_DEPS@%$A2K_DEPS%g +s%@COM_A2K@%$COM_A2K%g +s%@ANSI2KNRFLAGS@%$ANSI2KNRFLAGS%g +s%@COM_LT@%$COM_LT%g +s%@FORCE_INSTALL_LIB@%$FORCE_INSTALL_LIB%g +s%@INCLUDEFLAGS@%$INCLUDEFLAGS%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + diff --git a/src/dep/src/irrlicht/jpeglib/djpeg.1 b/src/dep/src/irrlicht/jpeglib/djpeg.1 index a1a335a..11beb6a 100644 --- a/src/dep/src/irrlicht/jpeglib/djpeg.1 +++ b/src/dep/src/irrlicht/jpeglib/djpeg.1 @@ -1,253 +1,253 @@ -.TH DJPEG 1 "22 August 1997" -.SH NAME -djpeg \- decompress a JPEG file to an image file -.SH SYNOPSIS -.B djpeg -[ -.I options -] -[ -.I filename -] -.LP -.SH DESCRIPTION -.LP -.B djpeg -decompresses the named JPEG file, or the standard input if no file is named, -and produces an image file on the standard output. PBMPLUS (PPM/PGM), BMP, -GIF, Targa, or RLE (Utah Raster Toolkit) output format can be selected. -(RLE is supported only if the URT library is available.) -.SH OPTIONS -All switch names may be abbreviated; for example, -.B \-grayscale -may be written -.B \-gray -or -.BR \-gr . -Most of the "basic" switches can be abbreviated to as little as one letter. -Upper and lower case are equivalent (thus -.B \-BMP -is the same as -.BR \-bmp ). -British spellings are also accepted (e.g., -.BR \-greyscale ), -though for brevity these are not mentioned below. -.PP -The basic switches are: -.TP -.BI \-colors " N" -Reduce image to at most N colors. This reduces the number of colors used in -the output image, so that it can be displayed on a colormapped display or -stored in a colormapped file format. For example, if you have an 8-bit -display, you'd need to reduce to 256 or fewer colors. -.TP -.BI \-quantize " N" -Same as -.BR \-colors . -.B \-colors -is the recommended name, -.B \-quantize -is provided only for backwards compatibility. -.TP -.B \-fast -Select recommended processing options for fast, low quality output. (The -default options are chosen for highest quality output.) Currently, this is -equivalent to \fB\-dct fast \-nosmooth \-onepass \-dither ordered\fR. -.TP -.B \-grayscale -Force gray-scale output even if JPEG file is color. Useful for viewing on -monochrome displays; also, -.B djpeg -runs noticeably faster in this mode. -.TP -.BI \-scale " M/N" -Scale the output image by a factor M/N. Currently the scale factor must be -1/1, 1/2, 1/4, or 1/8. Scaling is handy if the image is larger than your -screen; also, -.B djpeg -runs much faster when scaling down the output. -.TP -.B \-bmp -Select BMP output format (Windows flavor). 8-bit colormapped format is -emitted if -.B \-colors -or -.B \-grayscale -is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color -format is emitted. -.TP -.B \-gif -Select GIF output format. Since GIF does not support more than 256 colors, -.B \-colors 256 -is assumed (unless you specify a smaller number of colors). -.TP -.B \-os2 -Select BMP output format (OS/2 1.x flavor). 8-bit colormapped format is -emitted if -.B \-colors -or -.B \-grayscale -is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color -format is emitted. -.TP -.B \-pnm -Select PBMPLUS (PPM/PGM) output format (this is the default format). -PGM is emitted if the JPEG file is gray-scale or if -.B \-grayscale -is specified; otherwise PPM is emitted. -.TP -.B \-rle -Select RLE output format. (Requires URT library.) -.TP -.B \-targa -Select Targa output format. Gray-scale format is emitted if the JPEG file is -gray-scale or if -.B \-grayscale -is specified; otherwise, colormapped format is emitted if -.B \-colors -is specified; otherwise, 24-bit full-color format is emitted. -.PP -Switches for advanced users: -.TP -.B \-dct int -Use integer DCT method (default). -.TP -.B \-dct fast -Use fast integer DCT (less accurate). -.TP -.B \-dct float -Use floating-point DCT method. -The float method is very slightly more accurate than the int method, but is -much slower unless your machine has very fast floating-point hardware. Also -note that results of the floating-point method may vary slightly across -machines, while the integer methods should give the same results everywhere. -The fast integer method is much less accurate than the other two. -.TP -.B \-dither fs -Use Floyd-Steinberg dithering in color quantization. -.TP -.B \-dither ordered -Use ordered dithering in color quantization. -.TP -.B \-dither none -Do not use dithering in color quantization. -By default, Floyd-Steinberg dithering is applied when quantizing colors; this -is slow but usually produces the best results. Ordered dither is a compromise -between speed and quality; no dithering is fast but usually looks awful. Note -that these switches have no effect unless color quantization is being done. -Ordered dither is only available in -.B \-onepass -mode. -.TP -.BI \-map " file" -Quantize to the colors used in the specified image file. This is useful for -producing multiple files with identical color maps, or for forcing a -predefined set of colors to be used. The -.I file -must be a GIF or PPM file. This option overrides -.B \-colors -and -.BR \-onepass . -.TP -.B \-nosmooth -Use a faster, lower-quality upsampling routine. -.TP -.B \-onepass -Use one-pass instead of two-pass color quantization. The one-pass method is -faster and needs less memory, but it produces a lower-quality image. -.B \-onepass -is ignored unless you also say -.B \-colors -.IR N . -Also, the one-pass method is always used for gray-scale output (the two-pass -method is no improvement then). -.TP -.BI \-maxmemory " N" -Set limit for amount of memory to use in processing large images. Value is -in thousands of bytes, or millions of bytes if "M" is attached to the -number. For example, -.B \-max 4m -selects 4000000 bytes. If more space is needed, temporary files will be used. -.TP -.BI \-outfile " name" -Send output image to the named file, not to standard output. -.TP -.B \-verbose -Enable debug printout. More -.BR \-v 's -give more output. Also, version information is printed at startup. -.TP -.B \-debug -Same as -.BR \-verbose . -.SH EXAMPLES -.LP -This example decompresses the JPEG file foo.jpg, quantizes it to -256 colors, and saves the output in 8-bit BMP format in foo.bmp: -.IP -.B djpeg \-colors 256 \-bmp -.I foo.jpg -.B > -.I foo.bmp -.SH HINTS -To get a quick preview of an image, use the -.B \-grayscale -and/or -.B \-scale -switches. -.B \-grayscale \-scale 1/8 -is the fastest case. -.PP -Several options are available that trade off image quality to gain speed. -.B \-fast -turns on the recommended settings. -.PP -.B \-dct fast -and/or -.B \-nosmooth -gain speed at a small sacrifice in quality. -When producing a color-quantized image, -.B \-onepass \-dither ordered -is fast but much lower quality than the default behavior. -.B \-dither none -may give acceptable results in two-pass mode, but is seldom tolerable in -one-pass mode. -.PP -If you are fortunate enough to have very fast floating point hardware, -\fB\-dct float\fR may be even faster than \fB\-dct fast\fR. But on most -machines \fB\-dct float\fR is slower than \fB\-dct int\fR; in this case it is -not worth using, because its theoretical accuracy advantage is too small to be -significant in practice. -.SH ENVIRONMENT -.TP -.B JPEGMEM -If this environment variable is set, its value is the default memory limit. -The value is specified as described for the -.B \-maxmemory -switch. -.B JPEGMEM -overrides the default value specified when the program was compiled, and -itself is overridden by an explicit -.BR \-maxmemory . -.SH SEE ALSO -.BR cjpeg (1), -.BR jpegtran (1), -.BR rdjpgcom (1), -.BR wrjpgcom (1) -.br -.BR ppm (5), -.BR pgm (5) -.br -Wallace, Gregory K. "The JPEG Still Picture Compression Standard", -Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. -.SH AUTHOR -Independent JPEG Group -.SH BUGS -Arithmetic coding is not supported for legal reasons. -.PP -To avoid the Unisys LZW patent, -.B djpeg -produces uncompressed GIF files. These are larger than they should be, but -are readable by standard GIF decoders. -.PP -Still not as fast as we'd like. +.TH DJPEG 1 "22 August 1997" +.SH NAME +djpeg \- decompress a JPEG file to an image file +.SH SYNOPSIS +.B djpeg +[ +.I options +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B djpeg +decompresses the named JPEG file, or the standard input if no file is named, +and produces an image file on the standard output. PBMPLUS (PPM/PGM), BMP, +GIF, Targa, or RLE (Utah Raster Toolkit) output format can be selected. +(RLE is supported only if the URT library is available.) +.SH OPTIONS +All switch names may be abbreviated; for example, +.B \-grayscale +may be written +.B \-gray +or +.BR \-gr . +Most of the "basic" switches can be abbreviated to as little as one letter. +Upper and lower case are equivalent (thus +.B \-BMP +is the same as +.BR \-bmp ). +British spellings are also accepted (e.g., +.BR \-greyscale ), +though for brevity these are not mentioned below. +.PP +The basic switches are: +.TP +.BI \-colors " N" +Reduce image to at most N colors. This reduces the number of colors used in +the output image, so that it can be displayed on a colormapped display or +stored in a colormapped file format. For example, if you have an 8-bit +display, you'd need to reduce to 256 or fewer colors. +.TP +.BI \-quantize " N" +Same as +.BR \-colors . +.B \-colors +is the recommended name, +.B \-quantize +is provided only for backwards compatibility. +.TP +.B \-fast +Select recommended processing options for fast, low quality output. (The +default options are chosen for highest quality output.) Currently, this is +equivalent to \fB\-dct fast \-nosmooth \-onepass \-dither ordered\fR. +.TP +.B \-grayscale +Force gray-scale output even if JPEG file is color. Useful for viewing on +monochrome displays; also, +.B djpeg +runs noticeably faster in this mode. +.TP +.BI \-scale " M/N" +Scale the output image by a factor M/N. Currently the scale factor must be +1/1, 1/2, 1/4, or 1/8. Scaling is handy if the image is larger than your +screen; also, +.B djpeg +runs much faster when scaling down the output. +.TP +.B \-bmp +Select BMP output format (Windows flavor). 8-bit colormapped format is +emitted if +.B \-colors +or +.B \-grayscale +is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color +format is emitted. +.TP +.B \-gif +Select GIF output format. Since GIF does not support more than 256 colors, +.B \-colors 256 +is assumed (unless you specify a smaller number of colors). +.TP +.B \-os2 +Select BMP output format (OS/2 1.x flavor). 8-bit colormapped format is +emitted if +.B \-colors +or +.B \-grayscale +is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color +format is emitted. +.TP +.B \-pnm +Select PBMPLUS (PPM/PGM) output format (this is the default format). +PGM is emitted if the JPEG file is gray-scale or if +.B \-grayscale +is specified; otherwise PPM is emitted. +.TP +.B \-rle +Select RLE output format. (Requires URT library.) +.TP +.B \-targa +Select Targa output format. Gray-scale format is emitted if the JPEG file is +gray-scale or if +.B \-grayscale +is specified; otherwise, colormapped format is emitted if +.B \-colors +is specified; otherwise, 24-bit full-color format is emitted. +.PP +Switches for advanced users: +.TP +.B \-dct int +Use integer DCT method (default). +.TP +.B \-dct fast +Use fast integer DCT (less accurate). +.TP +.B \-dct float +Use floating-point DCT method. +The float method is very slightly more accurate than the int method, but is +much slower unless your machine has very fast floating-point hardware. Also +note that results of the floating-point method may vary slightly across +machines, while the integer methods should give the same results everywhere. +The fast integer method is much less accurate than the other two. +.TP +.B \-dither fs +Use Floyd-Steinberg dithering in color quantization. +.TP +.B \-dither ordered +Use ordered dithering in color quantization. +.TP +.B \-dither none +Do not use dithering in color quantization. +By default, Floyd-Steinberg dithering is applied when quantizing colors; this +is slow but usually produces the best results. Ordered dither is a compromise +between speed and quality; no dithering is fast but usually looks awful. Note +that these switches have no effect unless color quantization is being done. +Ordered dither is only available in +.B \-onepass +mode. +.TP +.BI \-map " file" +Quantize to the colors used in the specified image file. This is useful for +producing multiple files with identical color maps, or for forcing a +predefined set of colors to be used. The +.I file +must be a GIF or PPM file. This option overrides +.B \-colors +and +.BR \-onepass . +.TP +.B \-nosmooth +Use a faster, lower-quality upsampling routine. +.TP +.B \-onepass +Use one-pass instead of two-pass color quantization. The one-pass method is +faster and needs less memory, but it produces a lower-quality image. +.B \-onepass +is ignored unless you also say +.B \-colors +.IR N . +Also, the one-pass method is always used for gray-scale output (the two-pass +method is no improvement then). +.TP +.BI \-maxmemory " N" +Set limit for amount of memory to use in processing large images. Value is +in thousands of bytes, or millions of bytes if "M" is attached to the +number. For example, +.B \-max 4m +selects 4000000 bytes. If more space is needed, temporary files will be used. +.TP +.BI \-outfile " name" +Send output image to the named file, not to standard output. +.TP +.B \-verbose +Enable debug printout. More +.BR \-v 's +give more output. Also, version information is printed at startup. +.TP +.B \-debug +Same as +.BR \-verbose . +.SH EXAMPLES +.LP +This example decompresses the JPEG file foo.jpg, quantizes it to +256 colors, and saves the output in 8-bit BMP format in foo.bmp: +.IP +.B djpeg \-colors 256 \-bmp +.I foo.jpg +.B > +.I foo.bmp +.SH HINTS +To get a quick preview of an image, use the +.B \-grayscale +and/or +.B \-scale +switches. +.B \-grayscale \-scale 1/8 +is the fastest case. +.PP +Several options are available that trade off image quality to gain speed. +.B \-fast +turns on the recommended settings. +.PP +.B \-dct fast +and/or +.B \-nosmooth +gain speed at a small sacrifice in quality. +When producing a color-quantized image, +.B \-onepass \-dither ordered +is fast but much lower quality than the default behavior. +.B \-dither none +may give acceptable results in two-pass mode, but is seldom tolerable in +one-pass mode. +.PP +If you are fortunate enough to have very fast floating point hardware, +\fB\-dct float\fR may be even faster than \fB\-dct fast\fR. But on most +machines \fB\-dct float\fR is slower than \fB\-dct int\fR; in this case it is +not worth using, because its theoretical accuracy advantage is too small to be +significant in practice. +.SH ENVIRONMENT +.TP +.B JPEGMEM +If this environment variable is set, its value is the default memory limit. +The value is specified as described for the +.B \-maxmemory +switch. +.B JPEGMEM +overrides the default value specified when the program was compiled, and +itself is overridden by an explicit +.BR \-maxmemory . +.SH SEE ALSO +.BR cjpeg (1), +.BR jpegtran (1), +.BR rdjpgcom (1), +.BR wrjpgcom (1) +.br +.BR ppm (5), +.BR pgm (5) +.br +Wallace, Gregory K. "The JPEG Still Picture Compression Standard", +Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. +.SH AUTHOR +Independent JPEG Group +.SH BUGS +Arithmetic coding is not supported for legal reasons. +.PP +To avoid the Unisys LZW patent, +.B djpeg +produces uncompressed GIF files. These are larger than they should be, but +are readable by standard GIF decoders. +.PP +Still not as fast as we'd like. diff --git a/src/dep/src/irrlicht/jpeglib/djpeg.c b/src/dep/src/irrlicht/jpeglib/djpeg.c index a63523c..e099e90 100644 --- a/src/dep/src/irrlicht/jpeglib/djpeg.c +++ b/src/dep/src/irrlicht/jpeglib/djpeg.c @@ -1,616 +1,616 @@ -/* - * djpeg.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a command-line user interface for the JPEG decompressor. - * It should work on any system with Unix- or MS-DOS-style command lines. - * - * Two different command line styles are permitted, depending on the - * compile-time switch TWO_FILE_COMMANDLINE: - * djpeg [options] inputfile outputfile - * djpeg [options] [inputfile] - * In the second style, output is always to standard output, which you'd - * normally redirect to a file or pipe to some other program. Input is - * either from a named file or from standard input (typically redirected). - * The second style is convenient on Unix but is unhelpful on systems that - * don't support pipes. Also, you MUST use the first style if your system - * doesn't do binary I/O to stdin/stdout. - * To simplify script writing, the "-outfile" switch is provided. The syntax - * djpeg [options] -outfile outputfile inputfile - * works regardless of which command line style is used. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include "jversion.h" /* for version message */ - -#include /* to declare isprint() */ - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - - -/* Create the add-on message string table. */ - -#define JMESSAGE(code,string) string , - -static const char * const cdjpeg_message_table[] = { -#include "cderror.h" - NULL -}; - - -/* - * This list defines the known output image formats - * (not all of which need be supported by a given version). - * You can change the default output format by defining DEFAULT_FMT; - * indeed, you had better do so if you undefine PPM_SUPPORTED. - */ - -typedef enum { - FMT_BMP, /* BMP format (Windows flavor) */ - FMT_GIF, /* GIF format */ - FMT_OS2, /* BMP format (OS/2 flavor) */ - FMT_PPM, /* PPM/PGM (PBMPLUS formats) */ - FMT_RLE, /* RLE format */ - FMT_TARGA, /* Targa format */ - FMT_TIFF /* TIFF format */ -} IMAGE_FORMATS; - -#ifndef DEFAULT_FMT /* so can override from CFLAGS in Makefile */ -#define DEFAULT_FMT FMT_PPM -#endif - -static IMAGE_FORMATS requested_fmt; - - -/* - * Argument-parsing code. - * The switch parser is designed to be useful with DOS-style command line - * syntax, ie, intermixed switches and file names, where only the switches - * to the left of a given file name affect processing of that file. - * The main program in this file doesn't actually use this capability... - */ - - -static const char * progname; /* program name for error messages */ -static char * outfilename; /* for -outfile switch */ - - -LOCAL(void) -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -colors N Reduce image to no more than N colors\n"); - fprintf(stderr, " -fast Fast, low-quality processing\n"); - fprintf(stderr, " -grayscale Force grayscale output\n"); -#ifdef IDCT_SCALING_SUPPORTED - fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n"); -#endif -#ifdef BMP_SUPPORTED - fprintf(stderr, " -bmp Select BMP output format (Windows style)%s\n", - (DEFAULT_FMT == FMT_BMP ? " (default)" : "")); -#endif -#ifdef GIF_SUPPORTED - fprintf(stderr, " -gif Select GIF output format%s\n", - (DEFAULT_FMT == FMT_GIF ? " (default)" : "")); -#endif -#ifdef BMP_SUPPORTED - fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s\n", - (DEFAULT_FMT == FMT_OS2 ? " (default)" : "")); -#endif -#ifdef PPM_SUPPORTED - fprintf(stderr, " -pnm Select PBMPLUS (PPM/PGM) output format%s\n", - (DEFAULT_FMT == FMT_PPM ? " (default)" : "")); -#endif -#ifdef RLE_SUPPORTED - fprintf(stderr, " -rle Select Utah RLE output format%s\n", - (DEFAULT_FMT == FMT_RLE ? " (default)" : "")); -#endif -#ifdef TARGA_SUPPORTED - fprintf(stderr, " -targa Select Targa output format%s\n", - (DEFAULT_FMT == FMT_TARGA ? " (default)" : "")); -#endif - fprintf(stderr, "Switches for advanced users:\n"); -#ifdef DCT_ISLOW_SUPPORTED - fprintf(stderr, " -dct int Use integer DCT method%s\n", - (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); -#endif -#ifdef DCT_IFAST_SUPPORTED - fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", - (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); -#endif -#ifdef DCT_FLOAT_SUPPORTED - fprintf(stderr, " -dct float Use floating-point DCT method%s\n", - (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); -#endif - fprintf(stderr, " -dither fs Use F-S dithering (default)\n"); - fprintf(stderr, " -dither none Don't use dithering in quantization\n"); - fprintf(stderr, " -dither ordered Use ordered dither (medium speed, quality)\n"); -#ifdef QUANT_2PASS_SUPPORTED - fprintf(stderr, " -map FILE Map to colors used in named image file\n"); -#endif - fprintf(stderr, " -nosmooth Don't use high-quality upsampling\n"); -#ifdef QUANT_1PASS_SUPPORTED - fprintf(stderr, " -onepass Use 1-pass quantization (fast, low quality)\n"); -#endif - fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); - fprintf(stderr, " -outfile name Specify name for output file\n"); - fprintf(stderr, " -verbose or -debug Emit debug output\n"); - exit(EXIT_FAILURE); -} - - -LOCAL(int) -parse_switches (j_decompress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -/* Parse optional switches. - * Returns argv[] index of first file-name argument (== argc if none). - * Any file names with indexes <= last_file_arg_seen are ignored; - * they have presumably been processed in a previous iteration. - * (Pass 0 for last_file_arg_seen on the first or only iteration.) - * for_real is FALSE on the first (dummy) pass; we may skip any expensive - * processing. - */ -{ - int argn; - char * arg; - - /* Set up default JPEG parameters. */ - requested_fmt = DEFAULT_FMT; /* set default output file format */ - outfilename = NULL; - cinfo->err->trace_level = 0; - - /* Scan command line options, adjust parameters */ - - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (*arg != '-') { - /* Not a switch, must be a file name argument */ - if (argn <= last_file_arg_seen) { - outfilename = NULL; /* -outfile applies to just one input file */ - continue; /* ignore this name if previously processed */ - } - break; /* else done parsing switches */ - } - arg++; /* advance past switch marker character */ - - if (keymatch(arg, "bmp", 1)) { - /* BMP output format. */ - requested_fmt = FMT_BMP; - - } else if (keymatch(arg, "colors", 1) || keymatch(arg, "colours", 1) || - keymatch(arg, "quantize", 1) || keymatch(arg, "quantise", 1)) { - /* Do color quantization. */ - int val; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &val) != 1) - usage(); - cinfo->desired_number_of_colors = val; - cinfo->quantize_colors = TRUE; - - } else if (keymatch(arg, "dct", 2)) { - /* Select IDCT algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "int", 1)) { - cinfo->dct_method = JDCT_ISLOW; - } else if (keymatch(argv[argn], "fast", 2)) { - cinfo->dct_method = JDCT_IFAST; - } else if (keymatch(argv[argn], "float", 2)) { - cinfo->dct_method = JDCT_FLOAT; - } else - usage(); - - } else if (keymatch(arg, "dither", 2)) { - /* Select dithering algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "fs", 2)) { - cinfo->dither_mode = JDITHER_FS; - } else if (keymatch(argv[argn], "none", 2)) { - cinfo->dither_mode = JDITHER_NONE; - } else if (keymatch(argv[argn], "ordered", 2)) { - cinfo->dither_mode = JDITHER_ORDERED; - } else - usage(); - - } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { - /* Enable debug printouts. */ - /* On first -d, print version identification */ - static boolean printed_version = FALSE; - - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's DJPEG, version %s\n%s\n", - JVERSION, JCOPYRIGHT); - printed_version = TRUE; - } - cinfo->err->trace_level++; - - } else if (keymatch(arg, "fast", 1)) { - /* Select recommended processing options for quick-and-dirty output. */ - cinfo->two_pass_quantize = FALSE; - cinfo->dither_mode = JDITHER_ORDERED; - if (! cinfo->quantize_colors) /* don't override an earlier -colors */ - cinfo->desired_number_of_colors = 216; - cinfo->dct_method = JDCT_FASTEST; - cinfo->do_fancy_upsampling = FALSE; - - } else if (keymatch(arg, "gif", 1)) { - /* GIF output format. */ - requested_fmt = FMT_GIF; - - } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { - /* Force monochrome output. */ - cinfo->out_color_space = JCS_GRAYSCALE; - - } else if (keymatch(arg, "map", 3)) { - /* Quantize to a color map taken from an input file. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (for_real) { /* too expensive to do twice! */ -#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ - FILE * mapfile; - - if ((mapfile = fopen(argv[argn], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - read_color_map(cinfo, mapfile); - fclose(mapfile); - cinfo->quantize_colors = TRUE; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - - } else if (keymatch(arg, "maxmemory", 3)) { - /* Maximum memory in Kb (or Mb with 'm'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (ch == 'm' || ch == 'M') - lval *= 1000L; - cinfo->mem->max_memory_to_use = lval * 1000L; - - } else if (keymatch(arg, "nosmooth", 3)) { - /* Suppress fancy upsampling */ - cinfo->do_fancy_upsampling = FALSE; - - } else if (keymatch(arg, "onepass", 3)) { - /* Use fast one-pass quantization. */ - cinfo->two_pass_quantize = FALSE; - - } else if (keymatch(arg, "os2", 3)) { - /* BMP output format (OS/2 flavor). */ - requested_fmt = FMT_OS2; - - } else if (keymatch(arg, "outfile", 4)) { - /* Set output file name. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - outfilename = argv[argn]; /* save it away for later use */ - - } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) { - /* PPM/PGM output format. */ - requested_fmt = FMT_PPM; - - } else if (keymatch(arg, "rle", 1)) { - /* RLE output format. */ - requested_fmt = FMT_RLE; - - } else if (keymatch(arg, "scale", 1)) { - /* Scale the output image by a fraction M/N. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d/%d", - &cinfo->scale_num, &cinfo->scale_denom) != 2) - usage(); - - } else if (keymatch(arg, "targa", 1)) { - /* Targa output format. */ - requested_fmt = FMT_TARGA; - - } else { - usage(); /* bogus switch */ - } - } - - return argn; /* return index of next arg (file name) */ -} - - -/* - * Marker processor for COM and interesting APPn markers. - * This replaces the library's built-in processor, which just skips the marker. - * We want to print out the marker as text, to the extent possible. - * Note this code relies on a non-suspending data source. - */ - -LOCAL(unsigned int) -jpeg_getc (j_decompress_ptr cinfo) -/* Read next byte */ -{ - struct jpeg_source_mgr * datasrc = cinfo->src; - - if (datasrc->bytes_in_buffer == 0) { - if (! (*datasrc->fill_input_buffer) (cinfo)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } - datasrc->bytes_in_buffer--; - return GETJOCTET(*datasrc->next_input_byte++); -} - - -METHODDEF(boolean) -print_text_marker (j_decompress_ptr cinfo) -{ - boolean traceit = (cinfo->err->trace_level >= 1); - INT32 length; - unsigned int ch; - unsigned int lastch = 0; - - length = jpeg_getc(cinfo) << 8; - length += jpeg_getc(cinfo); - length -= 2; /* discount the length word itself */ - - if (traceit) { - if (cinfo->unread_marker == JPEG_COM) - fprintf(stderr, "Comment, length %ld:\n", (long) length); - else /* assume it is an APPn otherwise */ - fprintf(stderr, "APP%d, length %ld:\n", - cinfo->unread_marker - JPEG_APP0, (long) length); - } - - while (--length >= 0) { - ch = jpeg_getc(cinfo); - if (traceit) { - /* Emit the character in a readable form. - * Nonprintables are converted to \nnn form, - * while \ is converted to \\. - * Newlines in CR, CR/LF, or LF form will be printed as one newline. - */ - if (ch == '\r') { - fprintf(stderr, "\n"); - } else if (ch == '\n') { - if (lastch != '\r') - fprintf(stderr, "\n"); - } else if (ch == '\\') { - fprintf(stderr, "\\\\"); - } else if (isprint(ch)) { - putc(ch, stderr); - } else { - fprintf(stderr, "\\%03o", ch); - } - lastch = ch; - } - } - - if (traceit) - fprintf(stderr, "\n"); - - return TRUE; -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - struct jpeg_decompress_struct cinfo; - struct jpeg_error_mgr jerr; -#ifdef PROGRESS_REPORT - struct cdjpeg_progress_mgr progress; -#endif - int file_index; - djpeg_dest_ptr dest_mgr = NULL; - FILE * input_file; - FILE * output_file; - JDIMENSION num_scanlines; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "djpeg"; /* in case C library doesn't provide it */ - - /* Initialize the JPEG decompression object with default error handling. */ - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_decompress(&cinfo); - /* Add some application-specific error messages (from cderror.h) */ - jerr.addon_message_table = cdjpeg_message_table; - jerr.first_addon_message = JMSG_FIRSTADDONCODE; - jerr.last_addon_message = JMSG_LASTADDONCODE; - - /* Insert custom marker processor for COM and APP12. - * APP12 is used by some digital camera makers for textual info, - * so we provide the ability to display it as text. - * If you like, additional APPn marker types can be selected for display, - * but don't try to override APP0 or APP14 this way (see libjpeg.doc). - */ - jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker); - jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker); - - /* Now safe to enable signal catcher. */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &cinfo); -#endif - - /* Scan command line to find file names. */ - /* It is convenient to use just one switch-parsing routine, but the switch - * values read here are ignored; we will rescan the switches after opening - * the input file. - * (Exception: tracing level set here controls verbosity for COM markers - * found during jpeg_read_header...) - */ - - file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); - -#ifdef TWO_FILE_COMMANDLINE - /* Must have either -outfile switch or explicit output file name */ - if (outfilename == NULL) { - if (file_index != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - outfilename = argv[file_index+1]; - } else { - if (file_index != argc-1) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - } -#else - /* Unix style: expect zero or one file name */ - if (file_index < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } -#endif /* TWO_FILE_COMMANDLINE */ - - /* Open the input file. */ - if (file_index < argc) { - if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ - input_file = read_stdin(); - } - - /* Open the output file. */ - if (outfilename != NULL) { - if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, outfilename); - exit(EXIT_FAILURE); - } - } else { - /* default output file is stdout */ - output_file = write_stdout(); - } - -#ifdef PROGRESS_REPORT - start_progress_monitor((j_common_ptr) &cinfo, &progress); -#endif - - /* Specify data source for decompression */ - jpeg_stdio_src(&cinfo, input_file); - - /* Read file header, set default decompression parameters */ - (void) jpeg_read_header(&cinfo, TRUE); - - /* Adjust default decompression parameters by re-parsing the options */ - file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); - - /* Initialize the output module now to let it override any crucial - * option settings (for instance, GIF wants to force color quantization). - */ - switch (requested_fmt) { -#ifdef BMP_SUPPORTED - case FMT_BMP: - dest_mgr = jinit_write_bmp(&cinfo, FALSE); - break; - case FMT_OS2: - dest_mgr = jinit_write_bmp(&cinfo, TRUE); - break; -#endif -#ifdef GIF_SUPPORTED - case FMT_GIF: - dest_mgr = jinit_write_gif(&cinfo); - break; -#endif -#ifdef PPM_SUPPORTED - case FMT_PPM: - dest_mgr = jinit_write_ppm(&cinfo); - break; -#endif -#ifdef RLE_SUPPORTED - case FMT_RLE: - dest_mgr = jinit_write_rle(&cinfo); - break; -#endif -#ifdef TARGA_SUPPORTED - case FMT_TARGA: - dest_mgr = jinit_write_targa(&cinfo); - break; -#endif - default: - ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT); - break; - } - dest_mgr->output_file = output_file; - - /* Start decompressor */ - (void) jpeg_start_decompress(&cinfo); - - /* Write output file header */ - (*dest_mgr->start_output) (&cinfo, dest_mgr); - - /* Process data */ - while (cinfo.output_scanline < cinfo.output_height) { - num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer, - dest_mgr->buffer_height); - (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines); - } - -#ifdef PROGRESS_REPORT - /* Hack: count final pass as done in case finish_output does an extra pass. - * The library won't have updated completed_passes. - */ - progress.pub.completed_passes = progress.pub.total_passes; -#endif - - /* Finish decompression and release memory. - * I must do it in this order because output module has allocated memory - * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory. - */ - (*dest_mgr->finish_output) (&cinfo, dest_mgr); - (void) jpeg_finish_decompress(&cinfo); - jpeg_destroy_decompress(&cinfo); - - /* Close files, if we opened them */ - if (input_file != stdin) - fclose(input_file); - if (output_file != stdout) - fclose(output_file); - -#ifdef PROGRESS_REPORT - end_progress_monitor((j_common_ptr) &cinfo); -#endif - - /* All done. */ - exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} +/* + * djpeg.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a command-line user interface for the JPEG decompressor. + * It should work on any system with Unix- or MS-DOS-style command lines. + * + * Two different command line styles are permitted, depending on the + * compile-time switch TWO_FILE_COMMANDLINE: + * djpeg [options] inputfile outputfile + * djpeg [options] [inputfile] + * In the second style, output is always to standard output, which you'd + * normally redirect to a file or pipe to some other program. Input is + * either from a named file or from standard input (typically redirected). + * The second style is convenient on Unix but is unhelpful on systems that + * don't support pipes. Also, you MUST use the first style if your system + * doesn't do binary I/O to stdin/stdout. + * To simplify script writing, the "-outfile" switch is provided. The syntax + * djpeg [options] -outfile outputfile inputfile + * works regardless of which command line style is used. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include "jversion.h" /* for version message */ + +#include /* to declare isprint() */ + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + + +/* Create the add-on message string table. */ + +#define JMESSAGE(code,string) string , + +static const char * const cdjpeg_message_table[] = { +#include "cderror.h" + NULL +}; + + +/* + * This list defines the known output image formats + * (not all of which need be supported by a given version). + * You can change the default output format by defining DEFAULT_FMT; + * indeed, you had better do so if you undefine PPM_SUPPORTED. + */ + +typedef enum { + FMT_BMP, /* BMP format (Windows flavor) */ + FMT_GIF, /* GIF format */ + FMT_OS2, /* BMP format (OS/2 flavor) */ + FMT_PPM, /* PPM/PGM (PBMPLUS formats) */ + FMT_RLE, /* RLE format */ + FMT_TARGA, /* Targa format */ + FMT_TIFF /* TIFF format */ +} IMAGE_FORMATS; + +#ifndef DEFAULT_FMT /* so can override from CFLAGS in Makefile */ +#define DEFAULT_FMT FMT_PPM +#endif + +static IMAGE_FORMATS requested_fmt; + + +/* + * Argument-parsing code. + * The switch parser is designed to be useful with DOS-style command line + * syntax, ie, intermixed switches and file names, where only the switches + * to the left of a given file name affect processing of that file. + * The main program in this file doesn't actually use this capability... + */ + + +static const char * progname; /* program name for error messages */ +static char * outfilename; /* for -outfile switch */ + + +LOCAL(void) +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "usage: %s [switches] ", progname); +#ifdef TWO_FILE_COMMANDLINE + fprintf(stderr, "inputfile outputfile\n"); +#else + fprintf(stderr, "[inputfile]\n"); +#endif + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -colors N Reduce image to no more than N colors\n"); + fprintf(stderr, " -fast Fast, low-quality processing\n"); + fprintf(stderr, " -grayscale Force grayscale output\n"); +#ifdef IDCT_SCALING_SUPPORTED + fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n"); +#endif +#ifdef BMP_SUPPORTED + fprintf(stderr, " -bmp Select BMP output format (Windows style)%s\n", + (DEFAULT_FMT == FMT_BMP ? " (default)" : "")); +#endif +#ifdef GIF_SUPPORTED + fprintf(stderr, " -gif Select GIF output format%s\n", + (DEFAULT_FMT == FMT_GIF ? " (default)" : "")); +#endif +#ifdef BMP_SUPPORTED + fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s\n", + (DEFAULT_FMT == FMT_OS2 ? " (default)" : "")); +#endif +#ifdef PPM_SUPPORTED + fprintf(stderr, " -pnm Select PBMPLUS (PPM/PGM) output format%s\n", + (DEFAULT_FMT == FMT_PPM ? " (default)" : "")); +#endif +#ifdef RLE_SUPPORTED + fprintf(stderr, " -rle Select Utah RLE output format%s\n", + (DEFAULT_FMT == FMT_RLE ? " (default)" : "")); +#endif +#ifdef TARGA_SUPPORTED + fprintf(stderr, " -targa Select Targa output format%s\n", + (DEFAULT_FMT == FMT_TARGA ? " (default)" : "")); +#endif + fprintf(stderr, "Switches for advanced users:\n"); +#ifdef DCT_ISLOW_SUPPORTED + fprintf(stderr, " -dct int Use integer DCT method%s\n", + (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); +#endif +#ifdef DCT_IFAST_SUPPORTED + fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", + (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); +#endif +#ifdef DCT_FLOAT_SUPPORTED + fprintf(stderr, " -dct float Use floating-point DCT method%s\n", + (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); +#endif + fprintf(stderr, " -dither fs Use F-S dithering (default)\n"); + fprintf(stderr, " -dither none Don't use dithering in quantization\n"); + fprintf(stderr, " -dither ordered Use ordered dither (medium speed, quality)\n"); +#ifdef QUANT_2PASS_SUPPORTED + fprintf(stderr, " -map FILE Map to colors used in named image file\n"); +#endif + fprintf(stderr, " -nosmooth Don't use high-quality upsampling\n"); +#ifdef QUANT_1PASS_SUPPORTED + fprintf(stderr, " -onepass Use 1-pass quantization (fast, low quality)\n"); +#endif + fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); + fprintf(stderr, " -outfile name Specify name for output file\n"); + fprintf(stderr, " -verbose or -debug Emit debug output\n"); + exit(EXIT_FAILURE); +} + + +LOCAL(int) +parse_switches (j_decompress_ptr cinfo, int argc, char **argv, + int last_file_arg_seen, boolean for_real) +/* Parse optional switches. + * Returns argv[] index of first file-name argument (== argc if none). + * Any file names with indexes <= last_file_arg_seen are ignored; + * they have presumably been processed in a previous iteration. + * (Pass 0 for last_file_arg_seen on the first or only iteration.) + * for_real is FALSE on the first (dummy) pass; we may skip any expensive + * processing. + */ +{ + int argn; + char * arg; + + /* Set up default JPEG parameters. */ + requested_fmt = DEFAULT_FMT; /* set default output file format */ + outfilename = NULL; + cinfo->err->trace_level = 0; + + /* Scan command line options, adjust parameters */ + + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (*arg != '-') { + /* Not a switch, must be a file name argument */ + if (argn <= last_file_arg_seen) { + outfilename = NULL; /* -outfile applies to just one input file */ + continue; /* ignore this name if previously processed */ + } + break; /* else done parsing switches */ + } + arg++; /* advance past switch marker character */ + + if (keymatch(arg, "bmp", 1)) { + /* BMP output format. */ + requested_fmt = FMT_BMP; + + } else if (keymatch(arg, "colors", 1) || keymatch(arg, "colours", 1) || + keymatch(arg, "quantize", 1) || keymatch(arg, "quantise", 1)) { + /* Do color quantization. */ + int val; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d", &val) != 1) + usage(); + cinfo->desired_number_of_colors = val; + cinfo->quantize_colors = TRUE; + + } else if (keymatch(arg, "dct", 2)) { + /* Select IDCT algorithm. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "int", 1)) { + cinfo->dct_method = JDCT_ISLOW; + } else if (keymatch(argv[argn], "fast", 2)) { + cinfo->dct_method = JDCT_IFAST; + } else if (keymatch(argv[argn], "float", 2)) { + cinfo->dct_method = JDCT_FLOAT; + } else + usage(); + + } else if (keymatch(arg, "dither", 2)) { + /* Select dithering algorithm. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "fs", 2)) { + cinfo->dither_mode = JDITHER_FS; + } else if (keymatch(argv[argn], "none", 2)) { + cinfo->dither_mode = JDITHER_NONE; + } else if (keymatch(argv[argn], "ordered", 2)) { + cinfo->dither_mode = JDITHER_ORDERED; + } else + usage(); + + } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { + /* Enable debug printouts. */ + /* On first -d, print version identification */ + static boolean printed_version = FALSE; + + if (! printed_version) { + fprintf(stderr, "Independent JPEG Group's DJPEG, version %s\n%s\n", + JVERSION, JCOPYRIGHT); + printed_version = TRUE; + } + cinfo->err->trace_level++; + + } else if (keymatch(arg, "fast", 1)) { + /* Select recommended processing options for quick-and-dirty output. */ + cinfo->two_pass_quantize = FALSE; + cinfo->dither_mode = JDITHER_ORDERED; + if (! cinfo->quantize_colors) /* don't override an earlier -colors */ + cinfo->desired_number_of_colors = 216; + cinfo->dct_method = JDCT_FASTEST; + cinfo->do_fancy_upsampling = FALSE; + + } else if (keymatch(arg, "gif", 1)) { + /* GIF output format. */ + requested_fmt = FMT_GIF; + + } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { + /* Force monochrome output. */ + cinfo->out_color_space = JCS_GRAYSCALE; + + } else if (keymatch(arg, "map", 3)) { + /* Quantize to a color map taken from an input file. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (for_real) { /* too expensive to do twice! */ +#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ + FILE * mapfile; + + if ((mapfile = fopen(argv[argn], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); + exit(EXIT_FAILURE); + } + read_color_map(cinfo, mapfile); + fclose(mapfile); + cinfo->quantize_colors = TRUE; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } + + } else if (keymatch(arg, "maxmemory", 3)) { + /* Maximum memory in Kb (or Mb with 'm'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (ch == 'm' || ch == 'M') + lval *= 1000L; + cinfo->mem->max_memory_to_use = lval * 1000L; + + } else if (keymatch(arg, "nosmooth", 3)) { + /* Suppress fancy upsampling */ + cinfo->do_fancy_upsampling = FALSE; + + } else if (keymatch(arg, "onepass", 3)) { + /* Use fast one-pass quantization. */ + cinfo->two_pass_quantize = FALSE; + + } else if (keymatch(arg, "os2", 3)) { + /* BMP output format (OS/2 flavor). */ + requested_fmt = FMT_OS2; + + } else if (keymatch(arg, "outfile", 4)) { + /* Set output file name. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + outfilename = argv[argn]; /* save it away for later use */ + + } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) { + /* PPM/PGM output format. */ + requested_fmt = FMT_PPM; + + } else if (keymatch(arg, "rle", 1)) { + /* RLE output format. */ + requested_fmt = FMT_RLE; + + } else if (keymatch(arg, "scale", 1)) { + /* Scale the output image by a fraction M/N. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d/%d", + &cinfo->scale_num, &cinfo->scale_denom) != 2) + usage(); + + } else if (keymatch(arg, "targa", 1)) { + /* Targa output format. */ + requested_fmt = FMT_TARGA; + + } else { + usage(); /* bogus switch */ + } + } + + return argn; /* return index of next arg (file name) */ +} + + +/* + * Marker processor for COM and interesting APPn markers. + * This replaces the library's built-in processor, which just skips the marker. + * We want to print out the marker as text, to the extent possible. + * Note this code relies on a non-suspending data source. + */ + +LOCAL(unsigned int) +jpeg_getc (j_decompress_ptr cinfo) +/* Read next byte */ +{ + struct jpeg_source_mgr * datasrc = cinfo->src; + + if (datasrc->bytes_in_buffer == 0) { + if (! (*datasrc->fill_input_buffer) (cinfo)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + } + datasrc->bytes_in_buffer--; + return GETJOCTET(*datasrc->next_input_byte++); +} + + +METHODDEF(boolean) +print_text_marker (j_decompress_ptr cinfo) +{ + boolean traceit = (cinfo->err->trace_level >= 1); + INT32 length; + unsigned int ch; + unsigned int lastch = 0; + + length = jpeg_getc(cinfo) << 8; + length += jpeg_getc(cinfo); + length -= 2; /* discount the length word itself */ + + if (traceit) { + if (cinfo->unread_marker == JPEG_COM) + fprintf(stderr, "Comment, length %ld:\n", (long) length); + else /* assume it is an APPn otherwise */ + fprintf(stderr, "APP%d, length %ld:\n", + cinfo->unread_marker - JPEG_APP0, (long) length); + } + + while (--length >= 0) { + ch = jpeg_getc(cinfo); + if (traceit) { + /* Emit the character in a readable form. + * Nonprintables are converted to \nnn form, + * while \ is converted to \\. + * Newlines in CR, CR/LF, or LF form will be printed as one newline. + */ + if (ch == '\r') { + fprintf(stderr, "\n"); + } else if (ch == '\n') { + if (lastch != '\r') + fprintf(stderr, "\n"); + } else if (ch == '\\') { + fprintf(stderr, "\\\\"); + } else if (isprint(ch)) { + putc(ch, stderr); + } else { + fprintf(stderr, "\\%03o", ch); + } + lastch = ch; + } + } + + if (traceit) + fprintf(stderr, "\n"); + + return TRUE; +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; +#ifdef PROGRESS_REPORT + struct cdjpeg_progress_mgr progress; +#endif + int file_index; + djpeg_dest_ptr dest_mgr = NULL; + FILE * input_file; + FILE * output_file; + JDIMENSION num_scanlines; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "djpeg"; /* in case C library doesn't provide it */ + + /* Initialize the JPEG decompression object with default error handling. */ + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + /* Add some application-specific error messages (from cderror.h) */ + jerr.addon_message_table = cdjpeg_message_table; + jerr.first_addon_message = JMSG_FIRSTADDONCODE; + jerr.last_addon_message = JMSG_LASTADDONCODE; + + /* Insert custom marker processor for COM and APP12. + * APP12 is used by some digital camera makers for textual info, + * so we provide the ability to display it as text. + * If you like, additional APPn marker types can be selected for display, + * but don't try to override APP0 or APP14 this way (see libjpeg.doc). + */ + jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker); + jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker); + + /* Now safe to enable signal catcher. */ +#ifdef NEED_SIGNAL_CATCHER + enable_signal_catcher((j_common_ptr) &cinfo); +#endif + + /* Scan command line to find file names. */ + /* It is convenient to use just one switch-parsing routine, but the switch + * values read here are ignored; we will rescan the switches after opening + * the input file. + * (Exception: tracing level set here controls verbosity for COM markers + * found during jpeg_read_header...) + */ + + file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); + +#ifdef TWO_FILE_COMMANDLINE + /* Must have either -outfile switch or explicit output file name */ + if (outfilename == NULL) { + if (file_index != argc-2) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + outfilename = argv[file_index+1]; + } else { + if (file_index != argc-1) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + } +#else + /* Unix style: expect zero or one file name */ + if (file_index < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } +#endif /* TWO_FILE_COMMANDLINE */ + + /* Open the input file. */ + if (file_index < argc) { + if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ + input_file = read_stdin(); + } + + /* Open the output file. */ + if (outfilename != NULL) { + if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, outfilename); + exit(EXIT_FAILURE); + } + } else { + /* default output file is stdout */ + output_file = write_stdout(); + } + +#ifdef PROGRESS_REPORT + start_progress_monitor((j_common_ptr) &cinfo, &progress); +#endif + + /* Specify data source for decompression */ + jpeg_stdio_src(&cinfo, input_file); + + /* Read file header, set default decompression parameters */ + (void) jpeg_read_header(&cinfo, TRUE); + + /* Adjust default decompression parameters by re-parsing the options */ + file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); + + /* Initialize the output module now to let it override any crucial + * option settings (for instance, GIF wants to force color quantization). + */ + switch (requested_fmt) { +#ifdef BMP_SUPPORTED + case FMT_BMP: + dest_mgr = jinit_write_bmp(&cinfo, FALSE); + break; + case FMT_OS2: + dest_mgr = jinit_write_bmp(&cinfo, TRUE); + break; +#endif +#ifdef GIF_SUPPORTED + case FMT_GIF: + dest_mgr = jinit_write_gif(&cinfo); + break; +#endif +#ifdef PPM_SUPPORTED + case FMT_PPM: + dest_mgr = jinit_write_ppm(&cinfo); + break; +#endif +#ifdef RLE_SUPPORTED + case FMT_RLE: + dest_mgr = jinit_write_rle(&cinfo); + break; +#endif +#ifdef TARGA_SUPPORTED + case FMT_TARGA: + dest_mgr = jinit_write_targa(&cinfo); + break; +#endif + default: + ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT); + break; + } + dest_mgr->output_file = output_file; + + /* Start decompressor */ + (void) jpeg_start_decompress(&cinfo); + + /* Write output file header */ + (*dest_mgr->start_output) (&cinfo, dest_mgr); + + /* Process data */ + while (cinfo.output_scanline < cinfo.output_height) { + num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer, + dest_mgr->buffer_height); + (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines); + } + +#ifdef PROGRESS_REPORT + /* Hack: count final pass as done in case finish_output does an extra pass. + * The library won't have updated completed_passes. + */ + progress.pub.completed_passes = progress.pub.total_passes; +#endif + + /* Finish decompression and release memory. + * I must do it in this order because output module has allocated memory + * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory. + */ + (*dest_mgr->finish_output) (&cinfo, dest_mgr); + (void) jpeg_finish_decompress(&cinfo); + jpeg_destroy_decompress(&cinfo); + + /* Close files, if we opened them */ + if (input_file != stdin) + fclose(input_file); + if (output_file != stdout) + fclose(output_file); + +#ifdef PROGRESS_REPORT + end_progress_monitor((j_common_ptr) &cinfo); +#endif + + /* All done. */ + exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/src/dep/src/irrlicht/jpeglib/example.c b/src/dep/src/irrlicht/jpeglib/example.c index 9dcbd7d..7fc354f 100644 --- a/src/dep/src/irrlicht/jpeglib/example.c +++ b/src/dep/src/irrlicht/jpeglib/example.c @@ -1,433 +1,433 @@ -/* - * example.c - * - * This file illustrates how to use the IJG code as a subroutine library - * to read or write JPEG image files. You should look at this code in - * conjunction with the documentation file libjpeg.doc. - * - * This code will not do anything useful as-is, but it may be helpful as a - * skeleton for constructing routines that call the JPEG library. - * - * We present these routines in the same coding style used in the JPEG code - * (ANSI function definitions, etc); but you are of course free to code your - * routines in a different style if you prefer. - */ - -#include - -/* - * Include file for users of JPEG library. - * You will need to have included system headers that define at least - * the typedefs FILE and size_t before you can include jpeglib.h. - * (stdio.h is sufficient on ANSI-conforming systems.) - * You may also wish to include "jerror.h". - */ - -#include "jpeglib.h" - -/* - * is used for the optional error recovery mechanism shown in - * the second part of the example. - */ - -#include - - - -/******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/ - -/* This half of the example shows how to feed data into the JPEG compressor. - * We present a minimal version that does not worry about refinements such - * as error recovery (the JPEG code will just exit() if it gets an error). - */ - - -/* - * IMAGE DATA FORMATS: - * - * The standard input image format is a rectangular array of pixels, with - * each pixel having the same number of "component" values (color channels). - * Each pixel row is an array of JSAMPLEs (which typically are unsigned chars). - * If you are working with color data, then the color values for each pixel - * must be adjacent in the row; for example, R,G,B,R,G,B,R,G,B,... for 24-bit - * RGB color. - * - * For this example, we'll assume that this data structure matches the way - * our application has stored the image in memory, so we can just pass a - * pointer to our image buffer. In particular, let's say that the image is - * RGB color and is described by: - */ - -extern JSAMPLE * image_buffer; /* Points to large array of R,G,B-order data */ -extern int image_height; /* Number of rows in image */ -extern int image_width; /* Number of columns in image */ - - -/* - * Sample routine for JPEG compression. We assume that the target file name - * and a compression quality factor are passed in. - */ - -GLOBAL(void) -write_JPEG_file (char * filename, int quality) -{ - /* This struct contains the JPEG compression parameters and pointers to - * working space (which is allocated as needed by the JPEG library). - * It is possible to have several such structures, representing multiple - * compression/decompression processes, in existence at once. We refer - * to any one struct (and its associated working data) as a "JPEG object". - */ - struct jpeg_compress_struct cinfo; - /* This struct represents a JPEG error handler. It is declared separately - * because applications often want to supply a specialized error handler - * (see the second half of this file for an example). But here we just - * take the easy way out and use the standard error handler, which will - * print a message on stderr and call exit() if compression fails. - * Note that this struct must live as long as the main JPEG parameter - * struct, to avoid dangling-pointer problems. - */ - struct jpeg_error_mgr jerr; - /* More stuff */ - FILE * outfile; /* target file */ - JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ - int row_stride; /* physical row width in image buffer */ - - /* Step 1: allocate and initialize JPEG compression object */ - - /* We have to set up the error handler first, in case the initialization - * step fails. (Unlikely, but it could happen if you are out of memory.) - * This routine fills in the contents of struct jerr, and returns jerr's - * address which we place into the link field in cinfo. - */ - cinfo.err = jpeg_std_error(&jerr); - /* Now we can initialize the JPEG compression object. */ - jpeg_create_compress(&cinfo); - - /* Step 2: specify data destination (eg, a file) */ - /* Note: steps 2 and 3 can be done in either order. */ - - /* Here we use the library-supplied code to send compressed data to a - * stdio stream. You can also write your own code to do something else. - * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that - * requires it in order to write binary files. - */ - if ((outfile = fopen(filename, "wb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - exit(1); - } - jpeg_stdio_dest(&cinfo, outfile); - - /* Step 3: set parameters for compression */ - - /* First we supply a description of the input image. - * Four fields of the cinfo struct must be filled in: - */ - cinfo.image_width = image_width; /* image width and height, in pixels */ - cinfo.image_height = image_height; - cinfo.input_components = 3; /* # of color components per pixel */ - cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ - /* Now use the library's routine to set default compression parameters. - * (You must set at least cinfo.in_color_space before calling this, - * since the defaults depend on the source color space.) - */ - jpeg_set_defaults(&cinfo); - /* Now you can set any non-default parameters you wish to. - * Here we just illustrate the use of quality (quantization table) scaling: - */ - jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); - - /* Step 4: Start compressor */ - - /* TRUE ensures that we will write a complete interchange-JPEG file. - * Pass TRUE unless you are very sure of what you're doing. - */ - jpeg_start_compress(&cinfo, TRUE); - - /* Step 5: while (scan lines remain to be written) */ - /* jpeg_write_scanlines(...); */ - - /* Here we use the library's state variable cinfo.next_scanline as the - * loop counter, so that we don't have to keep track ourselves. - * To keep things simple, we pass one scanline per call; you can pass - * more if you wish, though. - */ - row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ - - while (cinfo.next_scanline < cinfo.image_height) { - /* jpeg_write_scanlines expects an array of pointers to scanlines. - * Here the array is only one element long, but you could pass - * more than one scanline at a time if that's more convenient. - */ - row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; - (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - - /* Step 6: Finish compression */ - - jpeg_finish_compress(&cinfo); - /* After finish_compress, we can close the output file. */ - fclose(outfile); - - /* Step 7: release JPEG compression object */ - - /* This is an important step since it will release a good deal of memory. */ - jpeg_destroy_compress(&cinfo); - - /* And we're done! */ -} - - -/* - * SOME FINE POINTS: - * - * In the above loop, we ignored the return value of jpeg_write_scanlines, - * which is the number of scanlines actually written. We could get away - * with this because we were only relying on the value of cinfo.next_scanline, - * which will be incremented correctly. If you maintain additional loop - * variables then you should be careful to increment them properly. - * Actually, for output to a stdio stream you needn't worry, because - * then jpeg_write_scanlines will write all the lines passed (or else exit - * with a fatal error). Partial writes can only occur if you use a data - * destination module that can demand suspension of the compressor. - * (If you don't know what that's for, you don't need it.) - * - * If the compressor requires full-image buffers (for entropy-coding - * optimization or a multi-scan JPEG file), it will create temporary - * files for anything that doesn't fit within the maximum-memory setting. - * (Note that temp files are NOT needed if you use the default parameters.) - * On some systems you may need to set up a signal handler to ensure that - * temporary files are deleted if the program is interrupted. See libjpeg.doc. - * - * Scanlines MUST be supplied in top-to-bottom order if you want your JPEG - * files to be compatible with everyone else's. If you cannot readily read - * your data in that order, you'll need an intermediate array to hold the - * image. See rdtarga.c or rdbmp.c for examples of handling bottom-to-top - * source data using the JPEG code's internal virtual-array mechanisms. - */ - - - -/******************** JPEG DECOMPRESSION SAMPLE INTERFACE *******************/ - -/* This half of the example shows how to read data from the JPEG decompressor. - * It's a bit more refined than the above, in that we show: - * (a) how to modify the JPEG library's standard error-reporting behavior; - * (b) how to allocate workspace using the library's memory manager. - * - * Just to make this example a little different from the first one, we'll - * assume that we do not intend to put the whole image into an in-memory - * buffer, but to send it line-by-line someplace else. We need a one- - * scanline-high JSAMPLE array as a work buffer, and we will let the JPEG - * memory manager allocate it for us. This approach is actually quite useful - * because we don't need to remember to deallocate the buffer separately: it - * will go away automatically when the JPEG object is cleaned up. - */ - - -/* - * ERROR HANDLING: - * - * The JPEG library's standard error handler (jerror.c) is divided into - * several "methods" which you can override individually. This lets you - * adjust the behavior without duplicating a lot of code, which you might - * have to update with each future release. - * - * Our example here shows how to override the "error_exit" method so that - * control is returned to the library's caller when a fatal error occurs, - * rather than calling exit() as the standard error_exit method does. - * - * We use C's setjmp/longjmp facility to return control. This means that the - * routine which calls the JPEG library must first execute a setjmp() call to - * establish the return point. We want the replacement error_exit to do a - * longjmp(). But we need to make the setjmp buffer accessible to the - * error_exit routine. To do this, we make a private extension of the - * standard JPEG error handler object. (If we were using C++, we'd say we - * were making a subclass of the regular error handler.) - * - * Here's the extended error handler struct: - */ - -struct my_error_mgr { - struct jpeg_error_mgr pub; /* "public" fields */ - - jmp_buf setjmp_buffer; /* for return to caller */ -}; - -typedef struct my_error_mgr * my_error_ptr; - -/* - * Here's the routine that will replace the standard error_exit method: - */ - -METHODDEF(void) -my_error_exit (j_common_ptr cinfo) -{ - /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ - my_error_ptr myerr = (my_error_ptr) cinfo->err; - - /* Always display the message. */ - /* We could postpone this until after returning, if we chose. */ - (*cinfo->err->output_message) (cinfo); - - /* Return control to the setjmp point */ - longjmp(myerr->setjmp_buffer, 1); -} - - -/* - * Sample routine for JPEG decompression. We assume that the source file name - * is passed in. We want to return 1 on success, 0 on error. - */ - - -GLOBAL(int) -read_JPEG_file (char * filename) -{ - /* This struct contains the JPEG decompression parameters and pointers to - * working space (which is allocated as needed by the JPEG library). - */ - struct jpeg_decompress_struct cinfo; - /* We use our private extension JPEG error handler. - * Note that this struct must live as long as the main JPEG parameter - * struct, to avoid dangling-pointer problems. - */ - struct my_error_mgr jerr; - /* More stuff */ - FILE * infile; /* source file */ - JSAMPARRAY buffer; /* Output row buffer */ - int row_stride; /* physical row width in output buffer */ - - /* In this example we want to open the input file before doing anything else, - * so that the setjmp() error recovery below can assume the file is open. - * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that - * requires it in order to read binary files. - */ - - if ((infile = fopen(filename, "rb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - return 0; - } - - /* Step 1: allocate and initialize JPEG decompression object */ - - /* We set up the normal JPEG error routines, then override error_exit. */ - cinfo.err = jpeg_std_error(&jerr.pub); - jerr.pub.error_exit = my_error_exit; - /* Establish the setjmp return context for my_error_exit to use. */ - if (setjmp(jerr.setjmp_buffer)) { - /* If we get here, the JPEG code has signaled an error. - * We need to clean up the JPEG object, close the input file, and return. - */ - jpeg_destroy_decompress(&cinfo); - fclose(infile); - return 0; - } - /* Now we can initialize the JPEG decompression object. */ - jpeg_create_decompress(&cinfo); - - /* Step 2: specify data source (eg, a file) */ - - jpeg_stdio_src(&cinfo, infile); - - /* Step 3: read file parameters with jpeg_read_header() */ - - (void) jpeg_read_header(&cinfo, TRUE); - /* We can ignore the return value from jpeg_read_header since - * (a) suspension is not possible with the stdio data source, and - * (b) we passed TRUE to reject a tables-only JPEG file as an error. - * See libjpeg.doc for more info. - */ - - /* Step 4: set parameters for decompression */ - - /* In this example, we don't need to change any of the defaults set by - * jpeg_read_header(), so we do nothing here. - */ - - /* Step 5: Start decompressor */ - - (void) jpeg_start_decompress(&cinfo); - /* We can ignore the return value since suspension is not possible - * with the stdio data source. - */ - - /* We may need to do some setup of our own at this point before reading - * the data. After jpeg_start_decompress() we have the correct scaled - * output image dimensions available, as well as the output colormap - * if we asked for color quantization. - * In this example, we need to make an output work buffer of the right size. - */ - /* JSAMPLEs per row in output buffer */ - row_stride = cinfo.output_width * cinfo.output_components; - /* Make a one-row-high sample array that will go away when done with image */ - buffer = (*cinfo.mem->alloc_sarray) - ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); - - /* Step 6: while (scan lines remain to be read) */ - /* jpeg_read_scanlines(...); */ - - /* Here we use the library's state variable cinfo.output_scanline as the - * loop counter, so that we don't have to keep track ourselves. - */ - while (cinfo.output_scanline < cinfo.output_height) { - /* jpeg_read_scanlines expects an array of pointers to scanlines. - * Here the array is only one element long, but you could ask for - * more than one scanline at a time if that's more convenient. - */ - (void) jpeg_read_scanlines(&cinfo, buffer, 1); - /* Assume put_scanline_someplace wants a pointer and sample count. */ - put_scanline_someplace(buffer[0], row_stride); - } - - /* Step 7: Finish decompression */ - - (void) jpeg_finish_decompress(&cinfo); - /* We can ignore the return value since suspension is not possible - * with the stdio data source. - */ - - /* Step 8: Release JPEG decompression object */ - - /* This is an important step since it will release a good deal of memory. */ - jpeg_destroy_decompress(&cinfo); - - /* After finish_decompress, we can close the input file. - * Here we postpone it until after no more JPEG errors are possible, - * so as to simplify the setjmp error logic above. (Actually, I don't - * think that jpeg_destroy can do an error exit, but why assume anything...) - */ - fclose(infile); - - /* At this point you may want to check to see whether any corrupt-data - * warnings occurred (test whether jerr.pub.num_warnings is nonzero). - */ - - /* And we're done! */ - return 1; -} - - -/* - * SOME FINE POINTS: - * - * In the above code, we ignored the return value of jpeg_read_scanlines, - * which is the number of scanlines actually read. We could get away with - * this because we asked for only one line at a time and we weren't using - * a suspending data source. See libjpeg.doc for more info. - * - * We cheated a bit by calling alloc_sarray() after jpeg_start_decompress(); - * we should have done it beforehand to ensure that the space would be - * counted against the JPEG max_memory setting. In some systems the above - * code would risk an out-of-memory error. However, in general we don't - * know the output image dimensions before jpeg_start_decompress(), unless we - * call jpeg_calc_output_dimensions(). See libjpeg.doc for more about this. - * - * Scanlines are returned in the same order as they appear in the JPEG file, - * which is standardly top-to-bottom. If you must emit data bottom-to-top, - * you can use one of the virtual arrays provided by the JPEG memory manager - * to invert the data. See wrbmp.c for an example. - * - * As with compression, some operating modes may require temporary files. - * On some systems you may need to set up a signal handler to ensure that - * temporary files are deleted if the program is interrupted. See libjpeg.doc. - */ +/* + * example.c + * + * This file illustrates how to use the IJG code as a subroutine library + * to read or write JPEG image files. You should look at this code in + * conjunction with the documentation file libjpeg.doc. + * + * This code will not do anything useful as-is, but it may be helpful as a + * skeleton for constructing routines that call the JPEG library. + * + * We present these routines in the same coding style used in the JPEG code + * (ANSI function definitions, etc); but you are of course free to code your + * routines in a different style if you prefer. + */ + +#include + +/* + * Include file for users of JPEG library. + * You will need to have included system headers that define at least + * the typedefs FILE and size_t before you can include jpeglib.h. + * (stdio.h is sufficient on ANSI-conforming systems.) + * You may also wish to include "jerror.h". + */ + +#include "jpeglib.h" + +/* + * is used for the optional error recovery mechanism shown in + * the second part of the example. + */ + +#include + + + +/******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/ + +/* This half of the example shows how to feed data into the JPEG compressor. + * We present a minimal version that does not worry about refinements such + * as error recovery (the JPEG code will just exit() if it gets an error). + */ + + +/* + * IMAGE DATA FORMATS: + * + * The standard input image format is a rectangular array of pixels, with + * each pixel having the same number of "component" values (color channels). + * Each pixel row is an array of JSAMPLEs (which typically are unsigned chars). + * If you are working with color data, then the color values for each pixel + * must be adjacent in the row; for example, R,G,B,R,G,B,R,G,B,... for 24-bit + * RGB color. + * + * For this example, we'll assume that this data structure matches the way + * our application has stored the image in memory, so we can just pass a + * pointer to our image buffer. In particular, let's say that the image is + * RGB color and is described by: + */ + +extern JSAMPLE * image_buffer; /* Points to large array of R,G,B-order data */ +extern int image_height; /* Number of rows in image */ +extern int image_width; /* Number of columns in image */ + + +/* + * Sample routine for JPEG compression. We assume that the target file name + * and a compression quality factor are passed in. + */ + +GLOBAL(void) +write_JPEG_file (char * filename, int quality) +{ + /* This struct contains the JPEG compression parameters and pointers to + * working space (which is allocated as needed by the JPEG library). + * It is possible to have several such structures, representing multiple + * compression/decompression processes, in existence at once. We refer + * to any one struct (and its associated working data) as a "JPEG object". + */ + struct jpeg_compress_struct cinfo; + /* This struct represents a JPEG error handler. It is declared separately + * because applications often want to supply a specialized error handler + * (see the second half of this file for an example). But here we just + * take the easy way out and use the standard error handler, which will + * print a message on stderr and call exit() if compression fails. + * Note that this struct must live as long as the main JPEG parameter + * struct, to avoid dangling-pointer problems. + */ + struct jpeg_error_mgr jerr; + /* More stuff */ + FILE * outfile; /* target file */ + JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ + int row_stride; /* physical row width in image buffer */ + + /* Step 1: allocate and initialize JPEG compression object */ + + /* We have to set up the error handler first, in case the initialization + * step fails. (Unlikely, but it could happen if you are out of memory.) + * This routine fills in the contents of struct jerr, and returns jerr's + * address which we place into the link field in cinfo. + */ + cinfo.err = jpeg_std_error(&jerr); + /* Now we can initialize the JPEG compression object. */ + jpeg_create_compress(&cinfo); + + /* Step 2: specify data destination (eg, a file) */ + /* Note: steps 2 and 3 can be done in either order. */ + + /* Here we use the library-supplied code to send compressed data to a + * stdio stream. You can also write your own code to do something else. + * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that + * requires it in order to write binary files. + */ + if ((outfile = fopen(filename, "wb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + exit(1); + } + jpeg_stdio_dest(&cinfo, outfile); + + /* Step 3: set parameters for compression */ + + /* First we supply a description of the input image. + * Four fields of the cinfo struct must be filled in: + */ + cinfo.image_width = image_width; /* image width and height, in pixels */ + cinfo.image_height = image_height; + cinfo.input_components = 3; /* # of color components per pixel */ + cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ + /* Now use the library's routine to set default compression parameters. + * (You must set at least cinfo.in_color_space before calling this, + * since the defaults depend on the source color space.) + */ + jpeg_set_defaults(&cinfo); + /* Now you can set any non-default parameters you wish to. + * Here we just illustrate the use of quality (quantization table) scaling: + */ + jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); + + /* Step 4: Start compressor */ + + /* TRUE ensures that we will write a complete interchange-JPEG file. + * Pass TRUE unless you are very sure of what you're doing. + */ + jpeg_start_compress(&cinfo, TRUE); + + /* Step 5: while (scan lines remain to be written) */ + /* jpeg_write_scanlines(...); */ + + /* Here we use the library's state variable cinfo.next_scanline as the + * loop counter, so that we don't have to keep track ourselves. + * To keep things simple, we pass one scanline per call; you can pass + * more if you wish, though. + */ + row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ + + while (cinfo.next_scanline < cinfo.image_height) { + /* jpeg_write_scanlines expects an array of pointers to scanlines. + * Here the array is only one element long, but you could pass + * more than one scanline at a time if that's more convenient. + */ + row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; + (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); + } + + /* Step 6: Finish compression */ + + jpeg_finish_compress(&cinfo); + /* After finish_compress, we can close the output file. */ + fclose(outfile); + + /* Step 7: release JPEG compression object */ + + /* This is an important step since it will release a good deal of memory. */ + jpeg_destroy_compress(&cinfo); + + /* And we're done! */ +} + + +/* + * SOME FINE POINTS: + * + * In the above loop, we ignored the return value of jpeg_write_scanlines, + * which is the number of scanlines actually written. We could get away + * with this because we were only relying on the value of cinfo.next_scanline, + * which will be incremented correctly. If you maintain additional loop + * variables then you should be careful to increment them properly. + * Actually, for output to a stdio stream you needn't worry, because + * then jpeg_write_scanlines will write all the lines passed (or else exit + * with a fatal error). Partial writes can only occur if you use a data + * destination module that can demand suspension of the compressor. + * (If you don't know what that's for, you don't need it.) + * + * If the compressor requires full-image buffers (for entropy-coding + * optimization or a multi-scan JPEG file), it will create temporary + * files for anything that doesn't fit within the maximum-memory setting. + * (Note that temp files are NOT needed if you use the default parameters.) + * On some systems you may need to set up a signal handler to ensure that + * temporary files are deleted if the program is interrupted. See libjpeg.doc. + * + * Scanlines MUST be supplied in top-to-bottom order if you want your JPEG + * files to be compatible with everyone else's. If you cannot readily read + * your data in that order, you'll need an intermediate array to hold the + * image. See rdtarga.c or rdbmp.c for examples of handling bottom-to-top + * source data using the JPEG code's internal virtual-array mechanisms. + */ + + + +/******************** JPEG DECOMPRESSION SAMPLE INTERFACE *******************/ + +/* This half of the example shows how to read data from the JPEG decompressor. + * It's a bit more refined than the above, in that we show: + * (a) how to modify the JPEG library's standard error-reporting behavior; + * (b) how to allocate workspace using the library's memory manager. + * + * Just to make this example a little different from the first one, we'll + * assume that we do not intend to put the whole image into an in-memory + * buffer, but to send it line-by-line someplace else. We need a one- + * scanline-high JSAMPLE array as a work buffer, and we will let the JPEG + * memory manager allocate it for us. This approach is actually quite useful + * because we don't need to remember to deallocate the buffer separately: it + * will go away automatically when the JPEG object is cleaned up. + */ + + +/* + * ERROR HANDLING: + * + * The JPEG library's standard error handler (jerror.c) is divided into + * several "methods" which you can override individually. This lets you + * adjust the behavior without duplicating a lot of code, which you might + * have to update with each future release. + * + * Our example here shows how to override the "error_exit" method so that + * control is returned to the library's caller when a fatal error occurs, + * rather than calling exit() as the standard error_exit method does. + * + * We use C's setjmp/longjmp facility to return control. This means that the + * routine which calls the JPEG library must first execute a setjmp() call to + * establish the return point. We want the replacement error_exit to do a + * longjmp(). But we need to make the setjmp buffer accessible to the + * error_exit routine. To do this, we make a private extension of the + * standard JPEG error handler object. (If we were using C++, we'd say we + * were making a subclass of the regular error handler.) + * + * Here's the extended error handler struct: + */ + +struct my_error_mgr { + struct jpeg_error_mgr pub; /* "public" fields */ + + jmp_buf setjmp_buffer; /* for return to caller */ +}; + +typedef struct my_error_mgr * my_error_ptr; + +/* + * Here's the routine that will replace the standard error_exit method: + */ + +METHODDEF(void) +my_error_exit (j_common_ptr cinfo) +{ + /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ + my_error_ptr myerr = (my_error_ptr) cinfo->err; + + /* Always display the message. */ + /* We could postpone this until after returning, if we chose. */ + (*cinfo->err->output_message) (cinfo); + + /* Return control to the setjmp point */ + longjmp(myerr->setjmp_buffer, 1); +} + + +/* + * Sample routine for JPEG decompression. We assume that the source file name + * is passed in. We want to return 1 on success, 0 on error. + */ + + +GLOBAL(int) +read_JPEG_file (char * filename) +{ + /* This struct contains the JPEG decompression parameters and pointers to + * working space (which is allocated as needed by the JPEG library). + */ + struct jpeg_decompress_struct cinfo; + /* We use our private extension JPEG error handler. + * Note that this struct must live as long as the main JPEG parameter + * struct, to avoid dangling-pointer problems. + */ + struct my_error_mgr jerr; + /* More stuff */ + FILE * infile; /* source file */ + JSAMPARRAY buffer; /* Output row buffer */ + int row_stride; /* physical row width in output buffer */ + + /* In this example we want to open the input file before doing anything else, + * so that the setjmp() error recovery below can assume the file is open. + * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that + * requires it in order to read binary files. + */ + + if ((infile = fopen(filename, "rb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + return 0; + } + + /* Step 1: allocate and initialize JPEG decompression object */ + + /* We set up the normal JPEG error routines, then override error_exit. */ + cinfo.err = jpeg_std_error(&jerr.pub); + jerr.pub.error_exit = my_error_exit; + /* Establish the setjmp return context for my_error_exit to use. */ + if (setjmp(jerr.setjmp_buffer)) { + /* If we get here, the JPEG code has signaled an error. + * We need to clean up the JPEG object, close the input file, and return. + */ + jpeg_destroy_decompress(&cinfo); + fclose(infile); + return 0; + } + /* Now we can initialize the JPEG decompression object. */ + jpeg_create_decompress(&cinfo); + + /* Step 2: specify data source (eg, a file) */ + + jpeg_stdio_src(&cinfo, infile); + + /* Step 3: read file parameters with jpeg_read_header() */ + + (void) jpeg_read_header(&cinfo, TRUE); + /* We can ignore the return value from jpeg_read_header since + * (a) suspension is not possible with the stdio data source, and + * (b) we passed TRUE to reject a tables-only JPEG file as an error. + * See libjpeg.doc for more info. + */ + + /* Step 4: set parameters for decompression */ + + /* In this example, we don't need to change any of the defaults set by + * jpeg_read_header(), so we do nothing here. + */ + + /* Step 5: Start decompressor */ + + (void) jpeg_start_decompress(&cinfo); + /* We can ignore the return value since suspension is not possible + * with the stdio data source. + */ + + /* We may need to do some setup of our own at this point before reading + * the data. After jpeg_start_decompress() we have the correct scaled + * output image dimensions available, as well as the output colormap + * if we asked for color quantization. + * In this example, we need to make an output work buffer of the right size. + */ + /* JSAMPLEs per row in output buffer */ + row_stride = cinfo.output_width * cinfo.output_components; + /* Make a one-row-high sample array that will go away when done with image */ + buffer = (*cinfo.mem->alloc_sarray) + ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); + + /* Step 6: while (scan lines remain to be read) */ + /* jpeg_read_scanlines(...); */ + + /* Here we use the library's state variable cinfo.output_scanline as the + * loop counter, so that we don't have to keep track ourselves. + */ + while (cinfo.output_scanline < cinfo.output_height) { + /* jpeg_read_scanlines expects an array of pointers to scanlines. + * Here the array is only one element long, but you could ask for + * more than one scanline at a time if that's more convenient. + */ + (void) jpeg_read_scanlines(&cinfo, buffer, 1); + /* Assume put_scanline_someplace wants a pointer and sample count. */ + put_scanline_someplace(buffer[0], row_stride); + } + + /* Step 7: Finish decompression */ + + (void) jpeg_finish_decompress(&cinfo); + /* We can ignore the return value since suspension is not possible + * with the stdio data source. + */ + + /* Step 8: Release JPEG decompression object */ + + /* This is an important step since it will release a good deal of memory. */ + jpeg_destroy_decompress(&cinfo); + + /* After finish_decompress, we can close the input file. + * Here we postpone it until after no more JPEG errors are possible, + * so as to simplify the setjmp error logic above. (Actually, I don't + * think that jpeg_destroy can do an error exit, but why assume anything...) + */ + fclose(infile); + + /* At this point you may want to check to see whether any corrupt-data + * warnings occurred (test whether jerr.pub.num_warnings is nonzero). + */ + + /* And we're done! */ + return 1; +} + + +/* + * SOME FINE POINTS: + * + * In the above code, we ignored the return value of jpeg_read_scanlines, + * which is the number of scanlines actually read. We could get away with + * this because we asked for only one line at a time and we weren't using + * a suspending data source. See libjpeg.doc for more info. + * + * We cheated a bit by calling alloc_sarray() after jpeg_start_decompress(); + * we should have done it beforehand to ensure that the space would be + * counted against the JPEG max_memory setting. In some systems the above + * code would risk an out-of-memory error. However, in general we don't + * know the output image dimensions before jpeg_start_decompress(), unless we + * call jpeg_calc_output_dimensions(). See libjpeg.doc for more about this. + * + * Scanlines are returned in the same order as they appear in the JPEG file, + * which is standardly top-to-bottom. If you must emit data bottom-to-top, + * you can use one of the virtual arrays provided by the JPEG memory manager + * to invert the data. See wrbmp.c for an example. + * + * As with compression, some operating modes may require temporary files. + * On some systems you may need to set up a signal handler to ensure that + * temporary files are deleted if the program is interrupted. See libjpeg.doc. + */ diff --git a/src/dep/src/irrlicht/jpeglib/filelist.doc b/src/dep/src/irrlicht/jpeglib/filelist.doc index ad6a82d..e14982c 100644 --- a/src/dep/src/irrlicht/jpeglib/filelist.doc +++ b/src/dep/src/irrlicht/jpeglib/filelist.doc @@ -1,210 +1,210 @@ -IJG JPEG LIBRARY: FILE LIST - -Copyright (C) 1994-1998, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -Here is a road map to the files in the IJG JPEG distribution. The -distribution includes the JPEG library proper, plus two application -programs ("cjpeg" and "djpeg") which use the library to convert JPEG -files to and from some other popular image formats. A third application -"jpegtran" uses the library to do lossless conversion between different -variants of JPEG. There are also two stand-alone applications, -"rdjpgcom" and "wrjpgcom". - - -THE JPEG LIBRARY -================ - -Include files: - -jpeglib.h JPEG library's exported data and function declarations. -jconfig.h Configuration declarations. Note: this file is not present - in the distribution; it is generated during installation. -jmorecfg.h Additional configuration declarations; need not be changed - for a standard installation. -jerror.h Declares JPEG library's error and trace message codes. -jinclude.h Central include file used by all IJG .c files to reference - system include files. -jpegint.h JPEG library's internal data structures. -jchuff.h Private declarations for Huffman encoder modules. -jdhuff.h Private declarations for Huffman decoder modules. -jdct.h Private declarations for forward & reverse DCT subsystems. -jmemsys.h Private declarations for memory management subsystem. -jversion.h Version information. - -Applications using the library should include jpeglib.h (which in turn -includes jconfig.h and jmorecfg.h). Optionally, jerror.h may be included -if the application needs to reference individual JPEG error codes. The -other include files are intended for internal use and would not normally -be included by an application program. (cjpeg/djpeg/etc do use jinclude.h, -since its function is to improve portability of the whole IJG distribution. -Most other applications will directly include the system include files they -want, and hence won't need jinclude.h.) - - -C source code files: - -These files contain most of the functions intended to be called directly by -an application program: - -jcapimin.c Application program interface: core routines for compression. -jcapistd.c Application program interface: standard compression. -jdapimin.c Application program interface: core routines for decompression. -jdapistd.c Application program interface: standard decompression. -jcomapi.c Application program interface routines common to compression - and decompression. -jcparam.c Compression parameter setting helper routines. -jctrans.c API and library routines for transcoding compression. -jdtrans.c API and library routines for transcoding decompression. - -Compression side of the library: - -jcinit.c Initialization: determines which other modules to use. -jcmaster.c Master control: setup and inter-pass sequencing logic. -jcmainct.c Main buffer controller (preprocessor => JPEG compressor). -jcprepct.c Preprocessor buffer controller. -jccoefct.c Buffer controller for DCT coefficient buffer. -jccolor.c Color space conversion. -jcsample.c Downsampling. -jcdctmgr.c DCT manager (DCT implementation selection & control). -jfdctint.c Forward DCT using slow-but-accurate integer method. -jfdctfst.c Forward DCT using faster, less accurate integer method. -jfdctflt.c Forward DCT using floating-point arithmetic. -jchuff.c Huffman entropy coding for sequential JPEG. -jcphuff.c Huffman entropy coding for progressive JPEG. -jcmarker.c JPEG marker writing. -jdatadst.c Data destination manager for stdio output. - -Decompression side of the library: - -jdmaster.c Master control: determines which other modules to use. -jdinput.c Input controller: controls input processing modules. -jdmainct.c Main buffer controller (JPEG decompressor => postprocessor). -jdcoefct.c Buffer controller for DCT coefficient buffer. -jdpostct.c Postprocessor buffer controller. -jdmarker.c JPEG marker reading. -jdhuff.c Huffman entropy decoding for sequential JPEG. -jdphuff.c Huffman entropy decoding for progressive JPEG. -jddctmgr.c IDCT manager (IDCT implementation selection & control). -jidctint.c Inverse DCT using slow-but-accurate integer method. -jidctfst.c Inverse DCT using faster, less accurate integer method. -jidctflt.c Inverse DCT using floating-point arithmetic. -jidctred.c Inverse DCTs with reduced-size outputs. -jdsample.c Upsampling. -jdcolor.c Color space conversion. -jdmerge.c Merged upsampling/color conversion (faster, lower quality). -jquant1.c One-pass color quantization using a fixed-spacing colormap. -jquant2.c Two-pass color quantization using a custom-generated colormap. - Also handles one-pass quantization to an externally given map. -jdatasrc.c Data source manager for stdio input. - -Support files for both compression and decompression: - -jerror.c Standard error handling routines (application replaceable). -jmemmgr.c System-independent (more or less) memory management code. -jutils.c Miscellaneous utility routines. - -jmemmgr.c relies on a system-dependent memory management module. The IJG -distribution includes the following implementations of the system-dependent -module: - -jmemnobs.c "No backing store": assumes adequate virtual memory exists. -jmemansi.c Makes temporary files with ANSI-standard routine tmpfile(). -jmemname.c Makes temporary files with program-generated file names. -jmemdos.c Custom implementation for MS-DOS (16-bit environment only): - can use extended and expanded memory as well as temp files. -jmemmac.c Custom implementation for Apple Macintosh. - -Exactly one of the system-dependent modules should be configured into an -installed JPEG library (see install.doc for hints about which one to use). -On unusual systems you may find it worthwhile to make a special -system-dependent memory manager. - - -Non-C source code files: - -jmemdosa.asm 80x86 assembly code support for jmemdos.c; used only in - MS-DOS-specific configurations of the JPEG library. - - -CJPEG/DJPEG/JPEGTRAN -==================== - -Include files: - -cdjpeg.h Declarations shared by cjpeg/djpeg/jpegtran modules. -cderror.h Additional error and trace message codes for cjpeg et al. -transupp.h Declarations for jpegtran support routines in transupp.c. - -C source code files: - -cjpeg.c Main program for cjpeg. -djpeg.c Main program for djpeg. -jpegtran.c Main program for jpegtran. -cdjpeg.c Utility routines used by all three programs. -rdcolmap.c Code to read a colormap file for djpeg's "-map" switch. -rdswitch.c Code to process some of cjpeg's more complex switches. - Also used by jpegtran. -transupp.c Support code for jpegtran: lossless image manipulations. - -Image file reader modules for cjpeg: - -rdbmp.c BMP file input. -rdgif.c GIF file input (now just a stub). -rdppm.c PPM/PGM file input. -rdrle.c Utah RLE file input. -rdtarga.c Targa file input. - -Image file writer modules for djpeg: - -wrbmp.c BMP file output. -wrgif.c GIF file output (a mere shadow of its former self). -wrppm.c PPM/PGM file output. -wrrle.c Utah RLE file output. -wrtarga.c Targa file output. - - -RDJPGCOM/WRJPGCOM -================= - -C source code files: - -rdjpgcom.c Stand-alone rdjpgcom application. -wrjpgcom.c Stand-alone wrjpgcom application. - -These programs do not depend on the IJG library. They do use -jconfig.h and jinclude.h, only to improve portability. - - -ADDITIONAL FILES -================ - -Documentation (see README for a guide to the documentation files): - -README Master documentation file. -*.doc Other documentation files. -*.1 Documentation in Unix man page format. -change.log Version-to-version change highlights. -example.c Sample code for calling JPEG library. - -Configuration/installation files and programs (see install.doc for more info): - -configure Unix shell script to perform automatic configuration. -ltconfig Support scripts for configure (from GNU libtool). -ltmain.sh -config.guess -config.sub -install-sh Install shell script for those Unix systems lacking one. -ckconfig.c Program to generate jconfig.h on non-Unix systems. -jconfig.doc Template for making jconfig.h by hand. -makefile.* Sample makefiles for particular systems. -jconfig.* Sample jconfig.h for particular systems. -ansi2knr.c De-ANSIfier for pre-ANSI C compilers (courtesy of - L. Peter Deutsch and Aladdin Enterprises). - -Test files (see install.doc for test procedure): - -test*.* Source and comparison files for confidence test. - These are binary image files, NOT text files. +IJG JPEG LIBRARY: FILE LIST + +Copyright (C) 1994-1998, Thomas G. Lane. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +Here is a road map to the files in the IJG JPEG distribution. The +distribution includes the JPEG library proper, plus two application +programs ("cjpeg" and "djpeg") which use the library to convert JPEG +files to and from some other popular image formats. A third application +"jpegtran" uses the library to do lossless conversion between different +variants of JPEG. There are also two stand-alone applications, +"rdjpgcom" and "wrjpgcom". + + +THE JPEG LIBRARY +================ + +Include files: + +jpeglib.h JPEG library's exported data and function declarations. +jconfig.h Configuration declarations. Note: this file is not present + in the distribution; it is generated during installation. +jmorecfg.h Additional configuration declarations; need not be changed + for a standard installation. +jerror.h Declares JPEG library's error and trace message codes. +jinclude.h Central include file used by all IJG .c files to reference + system include files. +jpegint.h JPEG library's internal data structures. +jchuff.h Private declarations for Huffman encoder modules. +jdhuff.h Private declarations for Huffman decoder modules. +jdct.h Private declarations for forward & reverse DCT subsystems. +jmemsys.h Private declarations for memory management subsystem. +jversion.h Version information. + +Applications using the library should include jpeglib.h (which in turn +includes jconfig.h and jmorecfg.h). Optionally, jerror.h may be included +if the application needs to reference individual JPEG error codes. The +other include files are intended for internal use and would not normally +be included by an application program. (cjpeg/djpeg/etc do use jinclude.h, +since its function is to improve portability of the whole IJG distribution. +Most other applications will directly include the system include files they +want, and hence won't need jinclude.h.) + + +C source code files: + +These files contain most of the functions intended to be called directly by +an application program: + +jcapimin.c Application program interface: core routines for compression. +jcapistd.c Application program interface: standard compression. +jdapimin.c Application program interface: core routines for decompression. +jdapistd.c Application program interface: standard decompression. +jcomapi.c Application program interface routines common to compression + and decompression. +jcparam.c Compression parameter setting helper routines. +jctrans.c API and library routines for transcoding compression. +jdtrans.c API and library routines for transcoding decompression. + +Compression side of the library: + +jcinit.c Initialization: determines which other modules to use. +jcmaster.c Master control: setup and inter-pass sequencing logic. +jcmainct.c Main buffer controller (preprocessor => JPEG compressor). +jcprepct.c Preprocessor buffer controller. +jccoefct.c Buffer controller for DCT coefficient buffer. +jccolor.c Color space conversion. +jcsample.c Downsampling. +jcdctmgr.c DCT manager (DCT implementation selection & control). +jfdctint.c Forward DCT using slow-but-accurate integer method. +jfdctfst.c Forward DCT using faster, less accurate integer method. +jfdctflt.c Forward DCT using floating-point arithmetic. +jchuff.c Huffman entropy coding for sequential JPEG. +jcphuff.c Huffman entropy coding for progressive JPEG. +jcmarker.c JPEG marker writing. +jdatadst.c Data destination manager for stdio output. + +Decompression side of the library: + +jdmaster.c Master control: determines which other modules to use. +jdinput.c Input controller: controls input processing modules. +jdmainct.c Main buffer controller (JPEG decompressor => postprocessor). +jdcoefct.c Buffer controller for DCT coefficient buffer. +jdpostct.c Postprocessor buffer controller. +jdmarker.c JPEG marker reading. +jdhuff.c Huffman entropy decoding for sequential JPEG. +jdphuff.c Huffman entropy decoding for progressive JPEG. +jddctmgr.c IDCT manager (IDCT implementation selection & control). +jidctint.c Inverse DCT using slow-but-accurate integer method. +jidctfst.c Inverse DCT using faster, less accurate integer method. +jidctflt.c Inverse DCT using floating-point arithmetic. +jidctred.c Inverse DCTs with reduced-size outputs. +jdsample.c Upsampling. +jdcolor.c Color space conversion. +jdmerge.c Merged upsampling/color conversion (faster, lower quality). +jquant1.c One-pass color quantization using a fixed-spacing colormap. +jquant2.c Two-pass color quantization using a custom-generated colormap. + Also handles one-pass quantization to an externally given map. +jdatasrc.c Data source manager for stdio input. + +Support files for both compression and decompression: + +jerror.c Standard error handling routines (application replaceable). +jmemmgr.c System-independent (more or less) memory management code. +jutils.c Miscellaneous utility routines. + +jmemmgr.c relies on a system-dependent memory management module. The IJG +distribution includes the following implementations of the system-dependent +module: + +jmemnobs.c "No backing store": assumes adequate virtual memory exists. +jmemansi.c Makes temporary files with ANSI-standard routine tmpfile(). +jmemname.c Makes temporary files with program-generated file names. +jmemdos.c Custom implementation for MS-DOS (16-bit environment only): + can use extended and expanded memory as well as temp files. +jmemmac.c Custom implementation for Apple Macintosh. + +Exactly one of the system-dependent modules should be configured into an +installed JPEG library (see install.doc for hints about which one to use). +On unusual systems you may find it worthwhile to make a special +system-dependent memory manager. + + +Non-C source code files: + +jmemdosa.asm 80x86 assembly code support for jmemdos.c; used only in + MS-DOS-specific configurations of the JPEG library. + + +CJPEG/DJPEG/JPEGTRAN +==================== + +Include files: + +cdjpeg.h Declarations shared by cjpeg/djpeg/jpegtran modules. +cderror.h Additional error and trace message codes for cjpeg et al. +transupp.h Declarations for jpegtran support routines in transupp.c. + +C source code files: + +cjpeg.c Main program for cjpeg. +djpeg.c Main program for djpeg. +jpegtran.c Main program for jpegtran. +cdjpeg.c Utility routines used by all three programs. +rdcolmap.c Code to read a colormap file for djpeg's "-map" switch. +rdswitch.c Code to process some of cjpeg's more complex switches. + Also used by jpegtran. +transupp.c Support code for jpegtran: lossless image manipulations. + +Image file reader modules for cjpeg: + +rdbmp.c BMP file input. +rdgif.c GIF file input (now just a stub). +rdppm.c PPM/PGM file input. +rdrle.c Utah RLE file input. +rdtarga.c Targa file input. + +Image file writer modules for djpeg: + +wrbmp.c BMP file output. +wrgif.c GIF file output (a mere shadow of its former self). +wrppm.c PPM/PGM file output. +wrrle.c Utah RLE file output. +wrtarga.c Targa file output. + + +RDJPGCOM/WRJPGCOM +================= + +C source code files: + +rdjpgcom.c Stand-alone rdjpgcom application. +wrjpgcom.c Stand-alone wrjpgcom application. + +These programs do not depend on the IJG library. They do use +jconfig.h and jinclude.h, only to improve portability. + + +ADDITIONAL FILES +================ + +Documentation (see README for a guide to the documentation files): + +README Master documentation file. +*.doc Other documentation files. +*.1 Documentation in Unix man page format. +change.log Version-to-version change highlights. +example.c Sample code for calling JPEG library. + +Configuration/installation files and programs (see install.doc for more info): + +configure Unix shell script to perform automatic configuration. +ltconfig Support scripts for configure (from GNU libtool). +ltmain.sh +config.guess +config.sub +install-sh Install shell script for those Unix systems lacking one. +ckconfig.c Program to generate jconfig.h on non-Unix systems. +jconfig.doc Template for making jconfig.h by hand. +makefile.* Sample makefiles for particular systems. +jconfig.* Sample jconfig.h for particular systems. +ansi2knr.c De-ANSIfier for pre-ANSI C compilers (courtesy of + L. Peter Deutsch and Aladdin Enterprises). + +Test files (see install.doc for test procedure): + +test*.* Source and comparison files for confidence test. + These are binary image files, NOT text files. diff --git a/src/dep/src/irrlicht/jpeglib/install-sh b/src/dep/src/irrlicht/jpeglib/install-sh index 082fd7c..e843669 100644 --- a/src/dep/src/irrlicht/jpeglib/install-sh +++ b/src/dep/src/irrlicht/jpeglib/install-sh @@ -1,250 +1,250 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). -# -# Copyright 1991 by the Massachusetts Institute of Technology -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/src/dep/src/irrlicht/jpeglib/install.doc b/src/dep/src/irrlicht/jpeglib/install.doc index 7d72c93..3702b98 100644 --- a/src/dep/src/irrlicht/jpeglib/install.doc +++ b/src/dep/src/irrlicht/jpeglib/install.doc @@ -1,1063 +1,1063 @@ -INSTALLATION INSTRUCTIONS for the Independent JPEG Group's JPEG software - -Copyright (C) 1991-1998, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -This file explains how to configure and install the IJG software. We have -tried to make this software extremely portable and flexible, so that it can be -adapted to almost any environment. The downside of this decision is that the -installation process is complicated. We have provided shortcuts to simplify -the task on common systems. But in any case, you will need at least a little -familiarity with C programming and program build procedures for your system. - -If you are only using this software as part of a larger program, the larger -program's installation procedure may take care of configuring the IJG code. -For example, Ghostscript's installation script will configure the IJG code. -You don't need to read this file if you just want to compile Ghostscript. - -If you are on a Unix machine, you may not need to read this file at all. -Try doing - ./configure - make - make test -If that doesn't complain, do - make install -(better do "make -n install" first to see if the makefile will put the files -where you want them). Read further if you run into snags or want to customize -the code for your system. - - -TABLE OF CONTENTS ------------------ - -Before you start -Configuring the software: - using the automatic "configure" script - using one of the supplied jconfig and makefile files - by hand -Building the software -Testing the software -Installing the software -Optional stuff -Optimization -Hints for specific systems - - -BEFORE YOU START -================ - -Before installing the software you must unpack the distributed source code. -Since you are reading this file, you have probably already succeeded in this -task. However, there is a potential for error if you needed to convert the -files to the local standard text file format (for example, if you are on -MS-DOS you may have converted LF end-of-line to CR/LF). You must apply -such conversion to all the files EXCEPT those whose names begin with "test". -The test files contain binary data; if you change them in any way then the -self-test will give bad results. - -Please check the last section of this file to see if there are hints for the -specific machine or compiler you are using. - - -CONFIGURING THE SOFTWARE -======================== - -To configure the IJG code for your system, you need to create two files: - * jconfig.h: contains values for system-dependent #define symbols. - * Makefile: controls the compilation process. -(On a non-Unix machine, you may create "project files" or some other -substitute for a Makefile. jconfig.h is needed in any environment.) - -We provide three different ways to generate these files: - * On a Unix system, you can just run the "configure" script. - * We provide sample jconfig files and makefiles for popular machines; - if your machine matches one of the samples, just copy the right sample - files to jconfig.h and Makefile. - * If all else fails, read the instructions below and make your own files. - - -Configuring the software using the automatic "configure" script ---------------------------------------------------------------- - -If you are on a Unix machine, you can just type - ./configure -and let the configure script construct appropriate configuration files. -If you're using "csh" on an old version of System V, you might need to type - sh configure -instead to prevent csh from trying to execute configure itself. -Expect configure to run for a few minutes, particularly on slower machines; -it works by compiling a series of test programs. - -Configure was created with GNU Autoconf and it follows the usual conventions -for GNU configure scripts. It makes a few assumptions that you may want to -override. You can do this by providing optional switches to configure: - -* If you want to build libjpeg as a shared library, say - ./configure --enable-shared -To get both shared and static libraries, say - ./configure --enable-shared --enable-static -Note that these switches invoke GNU libtool to take care of system-dependent -shared library building methods. If things don't work this way, please try -running configure without either switch; that should build a static library -without using libtool. If that works, your problem is probably with libtool -not with the IJG code. libtool is fairly new and doesn't support all flavors -of Unix yet. (You might be able to find a newer version of libtool than the -one included with libjpeg; see ftp.gnu.org. Report libtool problems to -bug-libtool@gnu.org.) - -* Configure will use gcc (GNU C compiler) if it's available, otherwise cc. -To force a particular compiler to be selected, use the CC option, for example - ./configure CC='cc' -The same method can be used to include any unusual compiler switches. -For example, on HP-UX you probably want to say - ./configure CC='cc -Aa' -to get HP's compiler to run in ANSI mode. - -* The default CFLAGS setting is "-O" for non-gcc compilers, "-O2" for gcc. -You can override this by saying, for example, - ./configure CFLAGS='-g' -if you want to compile with debugging support. - -* Configure will set up the makefile so that "make install" will install files -into /usr/local/bin, /usr/local/man, etc. You can specify an installation -prefix other than "/usr/local" by giving configure the option "--prefix=PATH". - -* If you don't have a lot of swap space, you may need to enable the IJG -software's internal virtual memory mechanism. To do this, give the option -"--enable-maxmem=N" where N is the default maxmemory limit in megabytes. -This is discussed in more detail under "Selecting a memory manager", below. -You probably don't need to worry about this on reasonably-sized Unix machines, -unless you plan to process very large images. - -Configure has some other features that are useful if you are cross-compiling -or working in a network of multiple machine types; but if you need those -features, you probably already know how to use them. - - -Configuring the software using one of the supplied jconfig and makefile files ------------------------------------------------------------------------------ - -If you have one of these systems, you can just use the provided configuration -files: - -Makefile jconfig file System and/or compiler - -makefile.manx jconfig.manx Amiga, Manx Aztec C -makefile.sas jconfig.sas Amiga, SAS C -makeproj.mac jconfig.mac Apple Macintosh, Metrowerks CodeWarrior -mak*jpeg.st jconfig.st Atari ST/STE/TT, Pure C or Turbo C -makefile.bcc jconfig.bcc MS-DOS or OS/2, Borland C -makefile.dj jconfig.dj MS-DOS, DJGPP (Delorie's port of GNU C) -makefile.mc6 jconfig.mc6 MS-DOS, Microsoft C (16-bit only) -makefile.wat jconfig.wat MS-DOS, OS/2, or Windows NT, Watcom C -makefile.vc jconfig.vc Windows NT/95, MS Visual C++ -make*.ds jconfig.vc Windows NT/95, MS Developer Studio -makefile.mms jconfig.vms Digital VMS, with MMS software -makefile.vms jconfig.vms Digital VMS, without MMS software - -Copy the proper jconfig file to jconfig.h and the makefile to Makefile (or -whatever your system uses as the standard makefile name). For more info see -the appropriate system-specific hints section near the end of this file. - - -Configuring the software by hand --------------------------------- - -First, generate a jconfig.h file. If you are moderately familiar with C, -the comments in jconfig.doc should be enough information to do this; just -copy jconfig.doc to jconfig.h and edit it appropriately. Otherwise, you may -prefer to use the ckconfig.c program. You will need to compile and execute -ckconfig.c by hand --- we hope you know at least enough to do that. -ckconfig.c may not compile the first try (in fact, the whole idea is for it -to fail if anything is going to). If you get compile errors, fix them by -editing ckconfig.c according to the directions given in ckconfig.c. Once -you get it to run, it will write a suitable jconfig.h file, and will also -print out some advice about which makefile to use. - -You may also want to look at the canned jconfig files, if there is one for a -system similar to yours. - -Second, select a makefile and copy it to Makefile (or whatever your system -uses as the standard makefile name). The most generic makefiles we provide -are - makefile.ansi: if your C compiler supports function prototypes - makefile.unix: if not. -(You have function prototypes if ckconfig.c put "#define HAVE_PROTOTYPES" -in jconfig.h.) You may want to start from one of the other makefiles if -there is one for a system similar to yours. - -Look over the selected Makefile and adjust options as needed. In particular -you may want to change the CC and CFLAGS definitions. For instance, if you -are using GCC, set CC=gcc. If you had to use any compiler switches to get -ckconfig.c to work, make sure the same switches are in CFLAGS. - -If you are on a system that doesn't use makefiles, you'll need to set up -project files (or whatever you do use) to compile all the source files and -link them into executable files cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom. -See the file lists in any of the makefiles to find out which files go into -each program. Note that the provided makefiles all make a "library" file -libjpeg first, but you don't have to do that if you don't want to; the file -lists identify which source files are actually needed for compression, -decompression, or both. As a last resort, you can make a batch script that -just compiles everything and links it all together; makefile.vms is an example -of this (it's for VMS systems that have no make-like utility). - -Here are comments about some specific configuration decisions you'll -need to make: - -Command line style ------------------- - -These programs can use a Unix-like command line style which supports -redirection and piping, like this: - cjpeg inputfile >outputfile - cjpeg outputfile - source program | cjpeg >outputfile -The simpler "two file" command line style is just - cjpeg inputfile outputfile -You may prefer the two-file style, particularly if you don't have pipes. - -You MUST use two-file style on any system that doesn't cope well with binary -data fed through stdin/stdout; this is true for some MS-DOS compilers, for -example. If you're not on a Unix system, it's safest to assume you need -two-file style. (But if your compiler provides either the Posix-standard -fdopen() library routine or a Microsoft-compatible setmode() routine, you -can safely use the Unix command line style, by defining USE_FDOPEN or -USE_SETMODE respectively.) - -To use the two-file style, make jconfig.h say "#define TWO_FILE_COMMANDLINE". - -Selecting a memory manager --------------------------- - -The IJG code is capable of working on images that are too big to fit in main -memory; data is swapped out to temporary files as necessary. However, the -code to do this is rather system-dependent. We provide five different -memory managers: - -* jmemansi.c This version uses the ANSI-standard library routine tmpfile(), - which not all non-ANSI systems have. On some systems - tmpfile() may put the temporary file in a non-optimal - location; if you don't like what it does, use jmemname.c. - -* jmemname.c This version creates named temporary files. For anything - except a Unix machine, you'll need to configure the - select_file_name() routine appropriately; see the comments - near the head of jmemname.c. If you use this version, define - NEED_SIGNAL_CATCHER in jconfig.h to make sure the temp files - are removed if the program is aborted. - -* jmemnobs.c (That stands for No Backing Store :-).) This will compile on - almost any system, but it assumes you have enough main memory - or virtual memory to hold the biggest images you work with. - -* jmemdos.c This should be used with most 16-bit MS-DOS compilers. - See the system-specific notes about MS-DOS for more info. - IMPORTANT: if you use this, define USE_MSDOS_MEMMGR in - jconfig.h, and include the assembly file jmemdosa.asm in the - programs. The supplied makefiles and jconfig files for - 16-bit MS-DOS compilers already do both. - -* jmemmac.c Custom version for Apple Macintosh; see the system-specific - notes for Macintosh for more info. - -To use a particular memory manager, change the SYSDEPMEM variable in your -makefile to equal the corresponding object file name (for example, jmemansi.o -or jmemansi.obj for jmemansi.c). - -If you have plenty of (real or virtual) main memory, just use jmemnobs.c. -"Plenty" means about ten bytes for every pixel in the largest images -you plan to process, so a lot of systems don't meet this criterion. -If yours doesn't, try jmemansi.c first. If that doesn't compile, you'll have -to use jmemname.c; be sure to adjust select_file_name() for local conditions. -You may also need to change unlink() to remove() in close_backing_store(). - -Except with jmemnobs.c or jmemmac.c, you need to adjust the DEFAULT_MAX_MEM -setting to a reasonable value for your system (either by adding a #define for -DEFAULT_MAX_MEM to jconfig.h, or by adding a -D switch to the Makefile). -This value limits the amount of data space the program will attempt to -allocate. Code and static data space isn't counted, so the actual memory -needs for cjpeg or djpeg are typically 100 to 150Kb more than the max-memory -setting. Larger max-memory settings reduce the amount of I/O needed to -process a large image, but too large a value can result in "insufficient -memory" failures. On most Unix machines (and other systems with virtual -memory), just set DEFAULT_MAX_MEM to several million and forget it. At the -other end of the spectrum, for MS-DOS machines you probably can't go much -above 300K to 400K. (On MS-DOS the value refers to conventional memory only. -Extended/expanded memory is handled separately by jmemdos.c.) - - -BUILDING THE SOFTWARE -===================== - -Now you should be able to compile the software. Just say "make" (or -whatever's necessary to start the compilation). Have a cup of coffee. - -Here are some things that could go wrong: - -If your compiler complains about undefined structures, you should be able to -shut it up by putting "#define INCOMPLETE_TYPES_BROKEN" in jconfig.h. - -If you have trouble with missing system include files or inclusion of the -wrong ones, read jinclude.h. This shouldn't happen if you used configure -or ckconfig.c to set up jconfig.h. - -There are a fair number of routines that do not use all of their parameters; -some compilers will issue warnings about this, which you can ignore. There -are also a few configuration checks that may give "unreachable code" warnings. -Any other warning deserves investigation. - -If you don't have a getenv() library routine, define NO_GETENV. - -Also see the system-specific hints, below. - - -TESTING THE SOFTWARE -==================== - -As a quick test of functionality we've included a small sample image in -several forms: - testorig.jpg Starting point for the djpeg tests. - testimg.ppm The output of djpeg testorig.jpg - testimg.bmp The output of djpeg -bmp -colors 256 testorig.jpg - testimg.jpg The output of cjpeg testimg.ppm - testprog.jpg Progressive-mode equivalent of testorig.jpg. - testimgp.jpg The output of cjpeg -progressive -optimize testimg.ppm -(The first- and second-generation .jpg files aren't identical since JPEG is -lossy.) If you can generate duplicates of the testimg* files then you -probably have working programs. - -With most of the makefiles, "make test" will perform the necessary -comparisons. - -If you're using a makefile that doesn't provide the test option, run djpeg -and cjpeg by hand and compare the output files to testimg* with whatever -binary file comparison tool you have. The files should be bit-for-bit -identical. - -If the programs complain "MAX_ALLOC_CHUNK is wrong, please fix", then you -need to reduce MAX_ALLOC_CHUNK to a value that fits in type size_t. -Try adding "#define MAX_ALLOC_CHUNK 65520L" to jconfig.h. A less likely -configuration error is "ALIGN_TYPE is wrong, please fix": defining ALIGN_TYPE -as long should take care of that one. - -If the cjpeg test run fails with "Missing Huffman code table entry", it's a -good bet that you needed to define RIGHT_SHIFT_IS_UNSIGNED. Go back to the -configuration step and run ckconfig.c. (This is a good plan for any other -test failure, too.) - -If you are using Unix (one-file) command line style on a non-Unix system, -it's a good idea to check that binary I/O through stdin/stdout actually -works. You should get the same results from "djpeg out.ppm" -as from "djpeg -outfile out.ppm testorig.jpg". Note that the makefiles all -use the latter style and therefore do not exercise stdin/stdout! If this -check fails, try recompiling with USE_SETMODE or USE_FDOPEN defined. -If it still doesn't work, better use two-file style. - -If you chose a memory manager other than jmemnobs.c, you should test that -temporary-file usage works. Try "djpeg -bmp -colors 256 -max 0 testorig.jpg" -and make sure its output matches testimg.bmp. If you have any really large -images handy, try compressing them with -optimize and/or decompressing with --colors 256 to make sure your DEFAULT_MAX_MEM setting is not too large. - -NOTE: this is far from an exhaustive test of the JPEG software; some modules, -such as 1-pass color quantization, are not exercised at all. It's just a -quick test to give you some confidence that you haven't missed something -major. - - -INSTALLING THE SOFTWARE -======================= - -Once you're done with the above steps, you can install the software by -copying the executable files (cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom) -to wherever you normally install programs. On Unix systems, you'll also want -to put the man pages (cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1) -in the man-page directory. The pre-fab makefiles don't support this step -since there's such a wide variety of installation procedures on different -systems. - -If you generated a Makefile with the "configure" script, you can just say - make install -to install the programs and their man pages into the standard places. -(You'll probably need to be root to do this.) We recommend first saying - make -n install -to see where configure thought the files should go. You may need to edit -the Makefile, particularly if your system's conventions for man page -filenames don't match what configure expects. - -If you want to install the IJG library itself, for use in compiling other -programs besides ours, then you need to put the four include files - jpeglib.h jerror.h jconfig.h jmorecfg.h -into your include-file directory, and put the library file libjpeg.a -(extension may vary depending on system) wherever library files go. -If you generated a Makefile with "configure", it will do what it thinks -is the right thing if you say - make install-lib - - -OPTIONAL STUFF -============== - -Progress monitor: - -If you like, you can #define PROGRESS_REPORT (in jconfig.h) to enable display -of percent-done progress reports. The routine provided in cdjpeg.c merely -prints percentages to stderr, but you can customize it to do something -fancier. - -Utah RLE file format support: - -We distribute the software with support for RLE image files (Utah Raster -Toolkit format) disabled, because the RLE support won't compile without the -Utah library. If you have URT version 3.1 or later, you can enable RLE -support as follows: - 1. #define RLE_SUPPORTED in jconfig.h. - 2. Add a -I option to CFLAGS in the Makefile for the directory - containing the URT .h files (typically the "include" - subdirectory of the URT distribution). - 3. Add -L... -lrle to LDLIBS in the Makefile, where ... specifies - the directory containing the URT "librle.a" file (typically the - "lib" subdirectory of the URT distribution). - -Support for 12-bit-deep pixel data: - -The JPEG standard allows either 8-bit or 12-bit data precision. (For color, -this means 8 or 12 bits per channel, of course.) If you need to work with -deeper than 8-bit data, you can compile the IJG code for 12-bit operation. -To do so: - 1. In jmorecfg.h, define BITS_IN_JSAMPLE as 12 rather than 8. - 2. In jconfig.h, undefine BMP_SUPPORTED, RLE_SUPPORTED, and TARGA_SUPPORTED, - because the code for those formats doesn't handle 12-bit data and won't - even compile. (The PPM code does work, as explained below. The GIF - code works too; it scales 8-bit GIF data to and from 12-bit depth - automatically.) - 3. Compile. Don't expect "make test" to pass, since the supplied test - files are for 8-bit data. - -Currently, 12-bit support does not work on 16-bit-int machines. - -Note that a 12-bit version will not read 8-bit JPEG files, nor vice versa; -so you'll want to keep around a regular 8-bit compilation as well. -(Run-time selection of data depth, to allow a single copy that does both, -is possible but would probably slow things down considerably; it's very low -on our to-do list.) - -The PPM reader (rdppm.c) can read 12-bit data from either text-format or -binary-format PPM and PGM files. Binary-format PPM/PGM files which have a -maxval greater than 255 are assumed to use 2 bytes per sample, LSB first -(little-endian order). As of early 1995, 2-byte binary format is not -officially supported by the PBMPLUS library, but it is expected that a -future release of PBMPLUS will support it. Note that the PPM reader will -read files of any maxval regardless of the BITS_IN_JSAMPLE setting; incoming -data is automatically rescaled to either maxval=255 or maxval=4095 as -appropriate for the cjpeg bit depth. - -The PPM writer (wrppm.c) will normally write 2-byte binary PPM or PGM -format, maxval 4095, when compiled with BITS_IN_JSAMPLE=12. Since this -format is not yet widely supported, you can disable it by compiling wrppm.c -with PPM_NORAWWORD defined; then the data is scaled down to 8 bits to make a -standard 1-byte/sample PPM or PGM file. (Yes, this means still another copy -of djpeg to keep around. But hopefully you won't need it for very long. -Poskanzer's supposed to get that new PBMPLUS release out Real Soon Now.) - -Of course, if you are working with 12-bit data, you probably have it stored -in some other, nonstandard format. In that case you'll probably want to -write your own I/O modules to read and write your format. - -Note that a 12-bit version of cjpeg always runs in "-optimize" mode, in -order to generate valid Huffman tables. This is necessary because our -default Huffman tables only cover 8-bit data. - -Removing code: - -If you need to make a smaller version of the JPEG software, some optional -functions can be removed at compile time. See the xxx_SUPPORTED #defines in -jconfig.h and jmorecfg.h. If at all possible, we recommend that you leave in -decoder support for all valid JPEG files, to ensure that you can read anyone's -output. Taking out support for image file formats that you don't use is the -most painless way to make the programs smaller. Another possibility is to -remove some of the DCT methods: in particular, the "IFAST" method may not be -enough faster than the others to be worth keeping on your machine. (If you -do remove ISLOW or IFAST, be sure to redefine JDCT_DEFAULT or JDCT_FASTEST -to a supported method, by adding a #define in jconfig.h.) - - -OPTIMIZATION -============ - -Unless you own a Cray, you'll probably be interested in making the JPEG -software go as fast as possible. This section covers some machine-dependent -optimizations you may want to try. We suggest that before trying any of -this, you first get the basic installation to pass the self-test step. -Repeat the self-test after any optimization to make sure that you haven't -broken anything. - -The integer DCT routines perform a lot of multiplications. These -multiplications must yield 32-bit results, but none of their input values -are more than 16 bits wide. On many machines, notably the 680x0 and 80x86 -CPUs, a 16x16=>32 bit multiply instruction is faster than a full 32x32=>32 -bit multiply. Unfortunately there is no portable way to specify such a -multiplication in C, but some compilers can generate one when you use the -right combination of casts. See the MULTIPLYxxx macro definitions in -jdct.h. If your compiler makes "int" be 32 bits and "short" be 16 bits, -defining SHORTxSHORT_32 is fairly likely to work. When experimenting with -alternate definitions, be sure to test not only whether the code still works -(use the self-test), but also whether it is actually faster --- on some -compilers, alternate definitions may compute the right answer, yet be slower -than the default. Timing cjpeg on a large PGM (grayscale) input file is the -best way to check this, as the DCT will be the largest fraction of the runtime -in that mode. (Note: some of the distributed compiler-specific jconfig files -already contain #define switches to select appropriate MULTIPLYxxx -definitions.) - -If your machine has sufficiently fast floating point hardware, you may find -that the float DCT method is faster than the integer DCT methods, even -after tweaking the integer multiply macros. In that case you may want to -make the float DCT be the default method. (The only objection to this is -that float DCT results may vary slightly across machines.) To do that, add -"#define JDCT_DEFAULT JDCT_FLOAT" to jconfig.h. Even if you don't change -the default, you should redefine JDCT_FASTEST, which is the method selected -by djpeg's -fast switch. Don't forget to update the documentation files -(usage.doc and/or cjpeg.1, djpeg.1) to agree with what you've done. - -If access to "short" arrays is slow on your machine, it may be a win to -define type JCOEF as int rather than short. This will cost a good deal of -memory though, particularly in some multi-pass modes, so don't do it unless -you have memory to burn and short is REALLY slow. - -If your compiler can compile function calls in-line, make sure the INLINE -macro in jmorecfg.h is defined as the keyword that marks a function -inline-able. Some compilers have a switch that tells the compiler to inline -any function it thinks is profitable (e.g., -finline-functions for gcc). -Enabling such a switch is likely to make the compiled code bigger but faster. - -In general, it's worth trying the maximum optimization level of your compiler, -and experimenting with any optional optimizations such as loop unrolling. -(Unfortunately, far too many compilers have optimizer bugs ... be prepared to -back off if the code fails self-test.) If you do any experimentation along -these lines, please report the optimal settings to jpeg-info@uunet.uu.net so -we can mention them in future releases. Be sure to specify your machine and -compiler version. - - -HINTS FOR SPECIFIC SYSTEMS -========================== - -We welcome reports on changes needed for systems not mentioned here. Submit -'em to jpeg-info@uunet.uu.net. Also, if configure or ckconfig.c is wrong -about how to configure the JPEG software for your system, please let us know. - - -Acorn RISC OS: - -(Thanks to Simon Middleton for these hints on compiling with Desktop C.) -After renaming the files according to Acorn conventions, take a copy of -makefile.ansi, change all occurrences of 'libjpeg.a' to 'libjpeg.o' and -change these definitions as indicated: - -CFLAGS= -throwback -IC: -Wn -LDLIBS=C:o.Stubs -SYSDEPMEM=jmemansi.o -LN=Link -AR=LibFile -c -o - -Also add a new line '.c.o:; $(cc) $< $(cflags) -c -o $@'. Remove the -lines '$(RM) libjpeg.o' and '$(AR2) libjpeg.o' and the 'jconfig.h' -dependency section. - -Copy jconfig.doc to jconfig.h. Edit jconfig.h to define TWO_FILE_COMMANDLINE -and CHAR_IS_UNSIGNED. - -Run the makefile using !AMU not !Make. If you want to use the 'clean' and -'test' makefile entries then you will have to fiddle with the syntax a bit -and rename the test files. - - -Amiga: - -SAS C 6.50 reportedly is too buggy to compile the IJG code properly. -A patch to update to 6.51 is available from SAS or AmiNet FTP sites. - -The supplied config files are set up to use jmemname.c as the memory -manager, with temporary files being created on the device named by -"JPEGTMP:". - - -Atari ST/STE/TT: - -Copy the project files makcjpeg.st, makdjpeg.st, maktjpeg.st, and makljpeg.st -to cjpeg.prj, djpeg.prj, jpegtran.prj, and libjpeg.prj respectively. The -project files should work as-is with Pure C. For Turbo C, change library -filenames "pc..." to "tc..." in each project file. Note that libjpeg.prj -selects jmemansi.c as the recommended memory manager. You'll probably want to -adjust the DEFAULT_MAX_MEM setting --- you want it to be a couple hundred K -less than your normal free memory. Put "#define DEFAULT_MAX_MEM nnnn" into -jconfig.h to do this. - -To use the 68881/68882 coprocessor for the floating point DCT, add the -compiler option "-8" to the project files and replace pcfltlib.lib with -pc881lib.lib in cjpeg.prj and djpeg.prj. Or if you don't have a -coprocessor, you may prefer to remove the float DCT code by undefining -DCT_FLOAT_SUPPORTED in jmorecfg.h (since without a coprocessor, the float -code will be too slow to be useful). In that case, you can delete -pcfltlib.lib from the project files. - -Note that you must make libjpeg.lib before making cjpeg.ttp, djpeg.ttp, -or jpegtran.ttp. You'll have to perform the self-test by hand. - -We haven't bothered to include project files for rdjpgcom and wrjpgcom. -Those source files should just be compiled by themselves; they don't -depend on the JPEG library. - -There is a bug in some older versions of the Turbo C library which causes the -space used by temporary files created with "tmpfile()" not to be freed after -an abnormal program exit. If you check your disk afterwards, you will find -cluster chains that are allocated but not used by a file. This should not -happen in cjpeg/djpeg/jpegtran, since we enable a signal catcher to explicitly -close temp files before exiting. But if you use the JPEG library with your -own code, be sure to supply a signal catcher, or else use a different -system-dependent memory manager. - - -Cray: - -Should you be so fortunate as to be running JPEG on a Cray YMP, there is a -compiler bug in old versions of Cray's Standard C (prior to 3.1). If you -still have an old compiler, you'll need to insert a line reading -"#pragma novector" just before the loop - for (i = 1; i <= (int) htbl->bits[l]; i++) - huffsize[p++] = (char) l; -in fix_huff_tbl (in V5beta1, line 204 of jchuff.c and line 176 of jdhuff.c). -[This bug may or may not still occur with the current IJG code, but it's -probably a dead issue anyway...] - - -HP-UX: - -If you have HP-UX 7.05 or later with the "software development" C compiler, -you should run the compiler in ANSI mode. If using the configure script, -say - ./configure CC='cc -Aa' -(or -Ae if you prefer). If configuring by hand, use makefile.ansi and add -"-Aa" to the CFLAGS line in the makefile. - -If you have a pre-7.05 system, or if you are using the non-ANSI C compiler -delivered with a minimum HP-UX system, then you must use makefile.unix -(and do NOT add -Aa); or just run configure without the CC option. - -On HP 9000 series 800 machines, the HP C compiler is buggy in revisions prior -to A.08.07. If you get complaints about "not a typedef name", you'll have to -use makefile.unix, or run configure without the CC option. - - -Macintosh, generic comments: - -The supplied user-interface files (cjpeg.c, djpeg.c, etc) are set up to -provide a Unix-style command line interface. You can use this interface on -the Mac by means of the ccommand() library routine provided by Metrowerks -CodeWarrior or Think C. This is only appropriate for testing the library, -however; to make a user-friendly equivalent of cjpeg/djpeg you'd really want -to develop a Mac-style user interface. There isn't a complete example -available at the moment, but there are some helpful starting points: -1. Sam Bushell's free "To JPEG" applet provides drag-and-drop conversion to -JPEG under System 7 and later. This only illustrates how to use the -compression half of the library, but it does a very nice job of that part. -The CodeWarrior source code is available from http://www.pobox.com/~jsam. -2. Jim Brunner prepared a Mac-style user interface for both compression and -decompression. Unfortunately, it hasn't been updated since IJG v4, and -the library's API has changed considerably since then. Still it may be of -some help, particularly as a guide to compiling the IJG code under Think C. -Jim's code is available from the Info-Mac archives, at sumex-aim.stanford.edu -or mirrors thereof; see file /info-mac/dev/src/jpeg-convert-c.hqx. - -jmemmac.c is the recommended memory manager back end for Macintosh. It uses -NewPtr/DisposePtr instead of malloc/free, and has a Mac-specific -implementation of jpeg_mem_available(). It also creates temporary files that -follow Mac conventions. (That part of the code relies on System-7-or-later OS -functions. See the comments in jmemmac.c if you need to run it on System 6.) -NOTE that USE_MAC_MEMMGR must be defined in jconfig.h to use jmemmac.c. - -You can also use jmemnobs.c, if you don't care about handling images larger -than available memory. If you use any memory manager back end other than -jmemmac.c, we recommend replacing "malloc" and "free" by "NewPtr" and -"DisposePtr", because Mac C libraries often have peculiar implementations of -malloc/free. (For instance, free() may not return the freed space to the -Mac Memory Manager. This is undesirable for the IJG code because jmemmgr.c -already clumps space requests.) - - -Macintosh, Metrowerks CodeWarrior: - -The Unix-command-line-style interface can be used by defining USE_CCOMMAND. -You'll also need to define TWO_FILE_COMMANDLINE to avoid stdin/stdout. -This means that when using the cjpeg/djpeg programs, you'll have to type the -input and output file names in the "Arguments" text-edit box, rather than -using the file radio buttons. (Perhaps USE_FDOPEN or USE_SETMODE would -eliminate the problem, but I haven't heard from anyone who's tried it.) - -On 680x0 Macs, Metrowerks defines type "double" as a 10-byte IEEE extended -float. jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power -of 2. Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. - -The supplied configuration file jconfig.mac can be used for your jconfig.h; -it includes all the recommended symbol definitions. If you have AppleScript -installed, you can run the supplied script makeproj.mac to create CodeWarrior -project files for the library and the testbed applications, then build the -library and applications. (Thanks to Dan Sears and Don Agro for this nifty -hack, which saves us from trying to maintain CodeWarrior project files as part -of the IJG distribution...) - - -Macintosh, Think C: - -The documentation in Jim Brunner's "JPEG Convert" source code (see above) -includes detailed build instructions for Think C; it's probably somewhat -out of date for the current release, but may be helpful. - -If you want to build the minimal command line version, proceed as follows. -You'll have to prepare project files for the programs; we don't include any -in the distribution since they are not text files. Use the file lists in -any of the supplied makefiles as a guide. Also add the ANSI and Unix C -libraries in a separate segment. You may need to divide the JPEG files into -more than one segment; we recommend dividing compression and decompression -modules. Define USE_CCOMMAND in jconfig.h so that the ccommand() routine is -called. You must also define TWO_FILE_COMMANDLINE because stdin/stdout -don't handle binary data correctly. - -On 680x0 Macs, Think C defines type "double" as a 12-byte IEEE extended float. -jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power of 2. -Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. - -jconfig.mac should work as a jconfig.h configuration file for Think C, -but the makeproj.mac AppleScript script is specific to CodeWarrior. Sorry. - - -MIPS R3000: - -MIPS's cc version 1.31 has a rather nasty optimization bug. Don't use -O -if you have that compiler version. (Use "cc -V" to check the version.) -Note that the R3000 chip is found in workstations from DEC and others. - - -MS-DOS, generic comments for 16-bit compilers: - -The IJG code is designed to work well in 80x86 "small" or "medium" memory -models (i.e., data pointers are 16 bits unless explicitly declared "far"; -code pointers can be either size). You may be able to use small model to -compile cjpeg or djpeg by itself, but you will probably have to use medium -model for any larger application. This won't make much difference in -performance. You *will* take a noticeable performance hit if you use a -large-data memory model, and you should avoid "huge" model if at all -possible. Be sure that NEED_FAR_POINTERS is defined in jconfig.h if you use -a small-data memory model; be sure it is NOT defined if you use a large-data -model. (The supplied makefiles and jconfig files for Borland and Microsoft C -compile in medium model and define NEED_FAR_POINTERS.) - -The DOS-specific memory manager, jmemdos.c, should be used if possible. -It needs some assembly-code routines which are in jmemdosa.asm; make sure -your makefile assembles that file and includes it in the library. If you -don't have a suitable assembler, you can get pre-assembled object files for -jmemdosa by FTP from ftp.uu.net:/graphics/jpeg/jdosaobj.zip. (DOS-oriented -distributions of the IJG source code often include these object files.) - -When using jmemdos.c, jconfig.h must define USE_MSDOS_MEMMGR and must set -MAX_ALLOC_CHUNK to less than 64K (65520L is a typical value). If your -C library's far-heap malloc() can't allocate blocks that large, reduce -MAX_ALLOC_CHUNK to whatever it can handle. - -If you can't use jmemdos.c for some reason --- for example, because you -don't have an assembler to assemble jmemdosa.asm --- you'll have to fall -back to jmemansi.c or jmemname.c. You'll probably still need to set -MAX_ALLOC_CHUNK in jconfig.h, because most DOS C libraries won't malloc() -more than 64K at a time. IMPORTANT: if you use jmemansi.c or jmemname.c, -you will have to compile in a large-data memory model in order to get the -right stdio library. Too bad. - -wrjpgcom needs to be compiled in large model, because it malloc()s a 64KB -work area to hold the comment text. If your C library's malloc can't -handle that, reduce MAX_COM_LENGTH as necessary in wrjpgcom.c. - -Most MS-DOS compilers treat stdin/stdout as text files, so you must use -two-file command line style. But if your compiler has either fdopen() or -setmode(), you can use one-file style if you like. To do this, define -USE_SETMODE or USE_FDOPEN so that stdin/stdout will be set to binary mode. -(USE_SETMODE seems to work with more DOS compilers than USE_FDOPEN.) You -should test that I/O through stdin/stdout produces the same results as I/O -to explicitly named files... the "make test" procedures in the supplied -makefiles do NOT use stdin/stdout. - - -MS-DOS, generic comments for 32-bit compilers: - -None of the above comments about memory models apply if you are using a -32-bit flat-memory-space environment, such as DJGPP or Watcom C. (And you -should use one if you have it, as performance will be much better than -8086-compatible code!) For flat-memory-space compilers, do NOT define -NEED_FAR_POINTERS, and do NOT use jmemdos.c. Use jmemnobs.c if the -environment supplies adequate virtual memory, otherwise use jmemansi.c or -jmemname.c. - -You'll still need to be careful about binary I/O through stdin/stdout. -See the last paragraph of the previous section. - - -MS-DOS, Borland C: - -Be sure to convert all the source files to DOS text format (CR/LF newlines). -Although Borland C will often work OK with unmodified Unix (LF newlines) -source files, sometimes it will give bogus compile errors. -"Illegal character '#'" is the most common such error. (This is true with -Borland C 3.1, but perhaps is fixed in newer releases.) - -If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. -jconfig.bcc already includes #define USE_SETMODE to make this work. -(fdopen does not work correctly.) - - -MS-DOS, Microsoft C: - -makefile.mc6 works with Microsoft C, DOS Visual C++, etc. It should only -be used if you want to build a 16-bit (small or medium memory model) program. - -If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. -jconfig.mc6 already includes #define USE_SETMODE to make this work. -(fdopen does not work correctly.) - -Note that this makefile assumes that the working copy of itself is called -"makefile". If you want to call it something else, say "makefile.mak", -be sure to adjust the dependency line that reads "$(RFILE) : makefile". -Otherwise the make will fail because it doesn't know how to create "makefile". -Worse, some releases of Microsoft's make utilities give an incorrect error -message in this situation. - -Old versions of MS C fail with an "out of macro expansion space" error -because they can't cope with the macro TRACEMS8 (defined in jerror.h). -If this happens to you, the easiest solution is to change TRACEMS8 to -expand to nothing. You'll lose the ability to dump out JPEG coefficient -tables with djpeg -debug -debug, but at least you can compile. - -Original MS C 6.0 is very buggy; it compiles incorrect code unless you turn -off optimization entirely (remove -O from CFLAGS). 6.00A is better, but it -still generates bad code if you enable loop optimizations (-Ol or -Ox). - -MS C 8.0 crashes when compiling jquant1.c with optimization switch /Oo ... -which is on by default. To work around this bug, compile that one file -with /Oo-. - - -Microsoft Windows (all versions), generic comments: - -Some Windows system include files define typedef boolean as "unsigned char". -The IJG code also defines typedef boolean, but we make it "int" by default. -This doesn't affect the IJG programs because we don't import those Windows -include files. But if you use the JPEG library in your own program, and some -of your program's files import one definition of boolean while some import the -other, you can get all sorts of mysterious problems. A good preventive step -is to make the IJG library use "unsigned char" for boolean. To do that, -add something like this to your jconfig.h file: - /* Define "boolean" as unsigned char, not int, per Windows custom */ - #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ - typedef unsigned char boolean; - #endif - #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ -(This is already in jconfig.vc, by the way.) - -windef.h contains the declarations - #define far - #define FAR far -Since jmorecfg.h tries to define FAR as empty, you may get a compiler -warning if you include both jpeglib.h and windef.h (which windows.h -includes). To suppress the warning, you can put "#ifndef FAR"/"#endif" -around the line "#define FAR" in jmorecfg.h. - -When using the library in a Windows application, you will almost certainly -want to modify or replace the error handler module jerror.c, since our -default error handler does a couple of inappropriate things: - 1. it tries to write error and warning messages on stderr; - 2. in event of a fatal error, it exits by calling exit(). - -A simple stopgap solution for problem 1 is to replace the line - fprintf(stderr, "%s\n", buffer); -(in output_message in jerror.c) with - MessageBox(GetActiveWindow(),buffer,"JPEG Error",MB_OK|MB_ICONERROR); -It's highly recommended that you at least do that much, since otherwise -error messages will disappear into nowhere. (Beginning with IJG v6b, this -code is already present in jerror.c; just define USE_WINDOWS_MESSAGEBOX in -jconfig.h to enable it.) - -The proper solution for problem 2 is to return control to your calling -application after a library error. This can be done with the setjmp/longjmp -technique discussed in libjpeg.doc and illustrated in example.c. (NOTE: -some older Windows C compilers provide versions of setjmp/longjmp that -don't actually work under Windows. You may need to use the Windows system -functions Catch and Throw instead.) - -The recommended memory manager under Windows is jmemnobs.c; in other words, -let Windows do any virtual memory management needed. You should NOT use -jmemdos.c nor jmemdosa.asm under Windows. - -For Windows 3.1, we recommend compiling in medium or large memory model; -for newer Windows versions, use a 32-bit flat memory model. (See the MS-DOS -sections above for more info about memory models.) In the 16-bit memory -models only, you'll need to put - #define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ -into jconfig.h to limit allocation chunks to 64Kb. (Without that, you'd -have to use huge memory model, which slows things down unnecessarily.) -jmemnobs.c works without modification in large or flat memory models, but to -use medium model, you need to modify its jpeg_get_large and jpeg_free_large -routines to allocate far memory. In any case, you might like to replace -its calls to malloc and free with direct calls on Windows memory allocation -functions. - -You may also want to modify jdatasrc.c and jdatadst.c to use Windows file -operations rather than fread/fwrite. This is only necessary if your C -compiler doesn't provide a competent implementation of C stdio functions. - -You might want to tweak the RGB_xxx macros in jmorecfg.h so that the library -will accept or deliver color pixels in BGR sample order, not RGB; BGR order -is usually more convenient under Windows. Note that this change will break -the sample applications cjpeg/djpeg, but the library itself works fine. - - -Many people want to convert the IJG library into a DLL. This is reasonably -straightforward, but watch out for the following: - - 1. Don't try to compile as a DLL in small or medium memory model; use -large model, or even better, 32-bit flat model. Many places in the IJG code -assume the address of a local variable is an ordinary (not FAR) pointer; -that isn't true in a medium-model DLL. - - 2. Microsoft C cannot pass file pointers between applications and DLLs. -(See Microsoft Knowledge Base, PSS ID Number Q50336.) So jdatasrc.c and -jdatadst.c don't work if you open a file in your application and then pass -the pointer to the DLL. One workaround is to make jdatasrc.c/jdatadst.c -part of your main application rather than part of the DLL. - - 3. You'll probably need to modify the macros GLOBAL() and EXTERN() to -attach suitable linkage keywords to the exported routine names. Similarly, -you'll want to modify METHODDEF() and JMETHOD() to ensure function pointers -are declared in a way that lets application routines be called back through -the function pointers. These macros are in jmorecfg.h. Typical definitions -for a 16-bit DLL are: - #define GLOBAL(type) type _far _pascal _loadds _export - #define EXTERN(type) extern type _far _pascal _loadds - #define METHODDEF(type) static type _far _pascal - #define JMETHOD(type,methodname,arglist) \ - type (_far _pascal *methodname) arglist -For a 32-bit DLL you may want something like - #define GLOBAL(type) __declspec(dllexport) type - #define EXTERN(type) extern __declspec(dllexport) type -Although not all the GLOBAL routines are actually intended to be called by -the application, the performance cost of making them all DLL entry points is -negligible. - -The unmodified IJG library presents a very C-specific application interface, -so the resulting DLL is only usable from C or C++ applications. There has -been some talk of writing wrapper code that would present a simpler interface -usable from other languages, such as Visual Basic. This is on our to-do list -but hasn't been very high priority --- any volunteers out there? - - -Microsoft Windows, Borland C: - -The provided jconfig.bcc should work OK in a 32-bit Windows environment, -but you'll need to tweak it in a 16-bit environment (you'd need to define -NEED_FAR_POINTERS and MAX_ALLOC_CHUNK). Beware that makefile.bcc will need -alteration if you want to use it for Windows --- in particular, you should -use jmemnobs.c not jmemdos.c under Windows. - -Borland C++ 4.5 fails with an internal compiler error when trying to compile -jdmerge.c in 32-bit mode. If enough people complain, perhaps Borland will fix -it. In the meantime, the simplest known workaround is to add a redundant -definition of the variable range_limit in h2v1_merged_upsample(), at the head -of the block that handles odd image width (about line 268 in v6 jdmerge.c): - /* If image width is odd, do the last output column separately */ - if (cinfo->output_width & 1) { - register JSAMPLE * range_limit = cinfo->sample_range_limit; /* ADD THIS */ - cb = GETJSAMPLE(*inptr1); -Pretty bizarre, especially since the very similar routine h2v2_merged_upsample -doesn't trigger the bug. -Recent reports suggest that this bug does not occur with "bcc32a" (the -Pentium-optimized version of the compiler). - -Another report from a user of Borland C 4.5 was that incorrect code (leading -to a color shift in processed images) was produced if any of the following -optimization switch combinations were used: - -Ot -Og - -Ot -Op - -Ot -Om -So try backing off on optimization if you see such a problem. (Are there -several different releases all numbered "4.5"??) - - -Microsoft Windows, Microsoft Visual C++: - -jconfig.vc should work OK with any Microsoft compiler for a 32-bit memory -model. makefile.vc is intended for command-line use. (If you are using -the Developer Studio environment, you may prefer the DevStudio project -files; see below.) - -Some users feel that it's easier to call the library from C++ code if you -force VC++ to treat the library as C++ code, which you can do by renaming -all the *.c files to *.cpp (and adjusting the makefile to match). This -avoids the need to put extern "C" { ... } around #include "jpeglib.h" in -your C++ application. - - -Microsoft Windows, Microsoft Developer Studio: - -We include makefiles that should work as project files in DevStudio 4.2 or -later. There is a library makefile that builds the IJG library as a static -Win32 library, and an application makefile that builds the sample applications -as Win32 console applications. (Even if you only want the library, we -recommend building the applications so that you can run the self-test.) - -To use: -1. Copy jconfig.vc to jconfig.h, makelib.ds to jpeg.mak, and - makeapps.ds to apps.mak. (Note that the renaming is critical!) -2. Click on the .mak files to construct project workspaces. - (If you are using DevStudio more recent than 4.2, you'll probably - get a message saying that the makefiles are being updated.) -3. Build the library project, then the applications project. -4. Move the application .exe files from `app`\Release to an - appropriate location on your path. -5. To perform the self-test, execute the command line - NMAKE /f makefile.vc test - - -OS/2, Borland C++: - -Watch out for optimization bugs in older Borland compilers; you may need -to back off the optimization switch settings. See the comments in -makefile.bcc. - - -SGI: - -On some SGI systems, you may need to set "AR2= ar -ts" in the Makefile. -If you are using configure, you can do this by saying - ./configure RANLIB='ar -ts' -This change is not needed on all SGIs. Use it only if the make fails at the -stage of linking the completed programs. - -On the MIPS R4000 architecture (Indy, etc.), the compiler option "-mips2" -reportedly speeds up the float DCT method substantially, enough to make it -faster than the default int method (but still slower than the fast int -method). If you use -mips2, you may want to alter the default DCT method to -be float. To do this, put "#define JDCT_DEFAULT JDCT_FLOAT" in jconfig.h. - - -VMS: - -On an Alpha/VMS system with MMS, be sure to use the "/Marco=Alpha=1" -qualifier with MMS when building the JPEG package. - -VAX/VMS v5.5-1 may have problems with the test step of the build procedure -reporting differences when it compares the original and test images. If the -error points to the last block of the files, it is most likely bogus and may -be safely ignored. It seems to be because the files are Stream_LF and -Backup/Compare has difficulty with the (presumably) null padded files. -This problem was not observed on VAX/VMS v6.1 or AXP/VMS v6.1. +INSTALLATION INSTRUCTIONS for the Independent JPEG Group's JPEG software + +Copyright (C) 1991-1998, Thomas G. Lane. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +This file explains how to configure and install the IJG software. We have +tried to make this software extremely portable and flexible, so that it can be +adapted to almost any environment. The downside of this decision is that the +installation process is complicated. We have provided shortcuts to simplify +the task on common systems. But in any case, you will need at least a little +familiarity with C programming and program build procedures for your system. + +If you are only using this software as part of a larger program, the larger +program's installation procedure may take care of configuring the IJG code. +For example, Ghostscript's installation script will configure the IJG code. +You don't need to read this file if you just want to compile Ghostscript. + +If you are on a Unix machine, you may not need to read this file at all. +Try doing + ./configure + make + make test +If that doesn't complain, do + make install +(better do "make -n install" first to see if the makefile will put the files +where you want them). Read further if you run into snags or want to customize +the code for your system. + + +TABLE OF CONTENTS +----------------- + +Before you start +Configuring the software: + using the automatic "configure" script + using one of the supplied jconfig and makefile files + by hand +Building the software +Testing the software +Installing the software +Optional stuff +Optimization +Hints for specific systems + + +BEFORE YOU START +================ + +Before installing the software you must unpack the distributed source code. +Since you are reading this file, you have probably already succeeded in this +task. However, there is a potential for error if you needed to convert the +files to the local standard text file format (for example, if you are on +MS-DOS you may have converted LF end-of-line to CR/LF). You must apply +such conversion to all the files EXCEPT those whose names begin with "test". +The test files contain binary data; if you change them in any way then the +self-test will give bad results. + +Please check the last section of this file to see if there are hints for the +specific machine or compiler you are using. + + +CONFIGURING THE SOFTWARE +======================== + +To configure the IJG code for your system, you need to create two files: + * jconfig.h: contains values for system-dependent #define symbols. + * Makefile: controls the compilation process. +(On a non-Unix machine, you may create "project files" or some other +substitute for a Makefile. jconfig.h is needed in any environment.) + +We provide three different ways to generate these files: + * On a Unix system, you can just run the "configure" script. + * We provide sample jconfig files and makefiles for popular machines; + if your machine matches one of the samples, just copy the right sample + files to jconfig.h and Makefile. + * If all else fails, read the instructions below and make your own files. + + +Configuring the software using the automatic "configure" script +--------------------------------------------------------------- + +If you are on a Unix machine, you can just type + ./configure +and let the configure script construct appropriate configuration files. +If you're using "csh" on an old version of System V, you might need to type + sh configure +instead to prevent csh from trying to execute configure itself. +Expect configure to run for a few minutes, particularly on slower machines; +it works by compiling a series of test programs. + +Configure was created with GNU Autoconf and it follows the usual conventions +for GNU configure scripts. It makes a few assumptions that you may want to +override. You can do this by providing optional switches to configure: + +* If you want to build libjpeg as a shared library, say + ./configure --enable-shared +To get both shared and static libraries, say + ./configure --enable-shared --enable-static +Note that these switches invoke GNU libtool to take care of system-dependent +shared library building methods. If things don't work this way, please try +running configure without either switch; that should build a static library +without using libtool. If that works, your problem is probably with libtool +not with the IJG code. libtool is fairly new and doesn't support all flavors +of Unix yet. (You might be able to find a newer version of libtool than the +one included with libjpeg; see ftp.gnu.org. Report libtool problems to +bug-libtool@gnu.org.) + +* Configure will use gcc (GNU C compiler) if it's available, otherwise cc. +To force a particular compiler to be selected, use the CC option, for example + ./configure CC='cc' +The same method can be used to include any unusual compiler switches. +For example, on HP-UX you probably want to say + ./configure CC='cc -Aa' +to get HP's compiler to run in ANSI mode. + +* The default CFLAGS setting is "-O" for non-gcc compilers, "-O2" for gcc. +You can override this by saying, for example, + ./configure CFLAGS='-g' +if you want to compile with debugging support. + +* Configure will set up the makefile so that "make install" will install files +into /usr/local/bin, /usr/local/man, etc. You can specify an installation +prefix other than "/usr/local" by giving configure the option "--prefix=PATH". + +* If you don't have a lot of swap space, you may need to enable the IJG +software's internal virtual memory mechanism. To do this, give the option +"--enable-maxmem=N" where N is the default maxmemory limit in megabytes. +This is discussed in more detail under "Selecting a memory manager", below. +You probably don't need to worry about this on reasonably-sized Unix machines, +unless you plan to process very large images. + +Configure has some other features that are useful if you are cross-compiling +or working in a network of multiple machine types; but if you need those +features, you probably already know how to use them. + + +Configuring the software using one of the supplied jconfig and makefile files +----------------------------------------------------------------------------- + +If you have one of these systems, you can just use the provided configuration +files: + +Makefile jconfig file System and/or compiler + +makefile.manx jconfig.manx Amiga, Manx Aztec C +makefile.sas jconfig.sas Amiga, SAS C +makeproj.mac jconfig.mac Apple Macintosh, Metrowerks CodeWarrior +mak*jpeg.st jconfig.st Atari ST/STE/TT, Pure C or Turbo C +makefile.bcc jconfig.bcc MS-DOS or OS/2, Borland C +makefile.dj jconfig.dj MS-DOS, DJGPP (Delorie's port of GNU C) +makefile.mc6 jconfig.mc6 MS-DOS, Microsoft C (16-bit only) +makefile.wat jconfig.wat MS-DOS, OS/2, or Windows NT, Watcom C +makefile.vc jconfig.vc Windows NT/95, MS Visual C++ +make*.ds jconfig.vc Windows NT/95, MS Developer Studio +makefile.mms jconfig.vms Digital VMS, with MMS software +makefile.vms jconfig.vms Digital VMS, without MMS software + +Copy the proper jconfig file to jconfig.h and the makefile to Makefile (or +whatever your system uses as the standard makefile name). For more info see +the appropriate system-specific hints section near the end of this file. + + +Configuring the software by hand +-------------------------------- + +First, generate a jconfig.h file. If you are moderately familiar with C, +the comments in jconfig.doc should be enough information to do this; just +copy jconfig.doc to jconfig.h and edit it appropriately. Otherwise, you may +prefer to use the ckconfig.c program. You will need to compile and execute +ckconfig.c by hand --- we hope you know at least enough to do that. +ckconfig.c may not compile the first try (in fact, the whole idea is for it +to fail if anything is going to). If you get compile errors, fix them by +editing ckconfig.c according to the directions given in ckconfig.c. Once +you get it to run, it will write a suitable jconfig.h file, and will also +print out some advice about which makefile to use. + +You may also want to look at the canned jconfig files, if there is one for a +system similar to yours. + +Second, select a makefile and copy it to Makefile (or whatever your system +uses as the standard makefile name). The most generic makefiles we provide +are + makefile.ansi: if your C compiler supports function prototypes + makefile.unix: if not. +(You have function prototypes if ckconfig.c put "#define HAVE_PROTOTYPES" +in jconfig.h.) You may want to start from one of the other makefiles if +there is one for a system similar to yours. + +Look over the selected Makefile and adjust options as needed. In particular +you may want to change the CC and CFLAGS definitions. For instance, if you +are using GCC, set CC=gcc. If you had to use any compiler switches to get +ckconfig.c to work, make sure the same switches are in CFLAGS. + +If you are on a system that doesn't use makefiles, you'll need to set up +project files (or whatever you do use) to compile all the source files and +link them into executable files cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom. +See the file lists in any of the makefiles to find out which files go into +each program. Note that the provided makefiles all make a "library" file +libjpeg first, but you don't have to do that if you don't want to; the file +lists identify which source files are actually needed for compression, +decompression, or both. As a last resort, you can make a batch script that +just compiles everything and links it all together; makefile.vms is an example +of this (it's for VMS systems that have no make-like utility). + +Here are comments about some specific configuration decisions you'll +need to make: + +Command line style +------------------ + +These programs can use a Unix-like command line style which supports +redirection and piping, like this: + cjpeg inputfile >outputfile + cjpeg outputfile + source program | cjpeg >outputfile +The simpler "two file" command line style is just + cjpeg inputfile outputfile +You may prefer the two-file style, particularly if you don't have pipes. + +You MUST use two-file style on any system that doesn't cope well with binary +data fed through stdin/stdout; this is true for some MS-DOS compilers, for +example. If you're not on a Unix system, it's safest to assume you need +two-file style. (But if your compiler provides either the Posix-standard +fdopen() library routine or a Microsoft-compatible setmode() routine, you +can safely use the Unix command line style, by defining USE_FDOPEN or +USE_SETMODE respectively.) + +To use the two-file style, make jconfig.h say "#define TWO_FILE_COMMANDLINE". + +Selecting a memory manager +-------------------------- + +The IJG code is capable of working on images that are too big to fit in main +memory; data is swapped out to temporary files as necessary. However, the +code to do this is rather system-dependent. We provide five different +memory managers: + +* jmemansi.c This version uses the ANSI-standard library routine tmpfile(), + which not all non-ANSI systems have. On some systems + tmpfile() may put the temporary file in a non-optimal + location; if you don't like what it does, use jmemname.c. + +* jmemname.c This version creates named temporary files. For anything + except a Unix machine, you'll need to configure the + select_file_name() routine appropriately; see the comments + near the head of jmemname.c. If you use this version, define + NEED_SIGNAL_CATCHER in jconfig.h to make sure the temp files + are removed if the program is aborted. + +* jmemnobs.c (That stands for No Backing Store :-).) This will compile on + almost any system, but it assumes you have enough main memory + or virtual memory to hold the biggest images you work with. + +* jmemdos.c This should be used with most 16-bit MS-DOS compilers. + See the system-specific notes about MS-DOS for more info. + IMPORTANT: if you use this, define USE_MSDOS_MEMMGR in + jconfig.h, and include the assembly file jmemdosa.asm in the + programs. The supplied makefiles and jconfig files for + 16-bit MS-DOS compilers already do both. + +* jmemmac.c Custom version for Apple Macintosh; see the system-specific + notes for Macintosh for more info. + +To use a particular memory manager, change the SYSDEPMEM variable in your +makefile to equal the corresponding object file name (for example, jmemansi.o +or jmemansi.obj for jmemansi.c). + +If you have plenty of (real or virtual) main memory, just use jmemnobs.c. +"Plenty" means about ten bytes for every pixel in the largest images +you plan to process, so a lot of systems don't meet this criterion. +If yours doesn't, try jmemansi.c first. If that doesn't compile, you'll have +to use jmemname.c; be sure to adjust select_file_name() for local conditions. +You may also need to change unlink() to remove() in close_backing_store(). + +Except with jmemnobs.c or jmemmac.c, you need to adjust the DEFAULT_MAX_MEM +setting to a reasonable value for your system (either by adding a #define for +DEFAULT_MAX_MEM to jconfig.h, or by adding a -D switch to the Makefile). +This value limits the amount of data space the program will attempt to +allocate. Code and static data space isn't counted, so the actual memory +needs for cjpeg or djpeg are typically 100 to 150Kb more than the max-memory +setting. Larger max-memory settings reduce the amount of I/O needed to +process a large image, but too large a value can result in "insufficient +memory" failures. On most Unix machines (and other systems with virtual +memory), just set DEFAULT_MAX_MEM to several million and forget it. At the +other end of the spectrum, for MS-DOS machines you probably can't go much +above 300K to 400K. (On MS-DOS the value refers to conventional memory only. +Extended/expanded memory is handled separately by jmemdos.c.) + + +BUILDING THE SOFTWARE +===================== + +Now you should be able to compile the software. Just say "make" (or +whatever's necessary to start the compilation). Have a cup of coffee. + +Here are some things that could go wrong: + +If your compiler complains about undefined structures, you should be able to +shut it up by putting "#define INCOMPLETE_TYPES_BROKEN" in jconfig.h. + +If you have trouble with missing system include files or inclusion of the +wrong ones, read jinclude.h. This shouldn't happen if you used configure +or ckconfig.c to set up jconfig.h. + +There are a fair number of routines that do not use all of their parameters; +some compilers will issue warnings about this, which you can ignore. There +are also a few configuration checks that may give "unreachable code" warnings. +Any other warning deserves investigation. + +If you don't have a getenv() library routine, define NO_GETENV. + +Also see the system-specific hints, below. + + +TESTING THE SOFTWARE +==================== + +As a quick test of functionality we've included a small sample image in +several forms: + testorig.jpg Starting point for the djpeg tests. + testimg.ppm The output of djpeg testorig.jpg + testimg.bmp The output of djpeg -bmp -colors 256 testorig.jpg + testimg.jpg The output of cjpeg testimg.ppm + testprog.jpg Progressive-mode equivalent of testorig.jpg. + testimgp.jpg The output of cjpeg -progressive -optimize testimg.ppm +(The first- and second-generation .jpg files aren't identical since JPEG is +lossy.) If you can generate duplicates of the testimg* files then you +probably have working programs. + +With most of the makefiles, "make test" will perform the necessary +comparisons. + +If you're using a makefile that doesn't provide the test option, run djpeg +and cjpeg by hand and compare the output files to testimg* with whatever +binary file comparison tool you have. The files should be bit-for-bit +identical. + +If the programs complain "MAX_ALLOC_CHUNK is wrong, please fix", then you +need to reduce MAX_ALLOC_CHUNK to a value that fits in type size_t. +Try adding "#define MAX_ALLOC_CHUNK 65520L" to jconfig.h. A less likely +configuration error is "ALIGN_TYPE is wrong, please fix": defining ALIGN_TYPE +as long should take care of that one. + +If the cjpeg test run fails with "Missing Huffman code table entry", it's a +good bet that you needed to define RIGHT_SHIFT_IS_UNSIGNED. Go back to the +configuration step and run ckconfig.c. (This is a good plan for any other +test failure, too.) + +If you are using Unix (one-file) command line style on a non-Unix system, +it's a good idea to check that binary I/O through stdin/stdout actually +works. You should get the same results from "djpeg out.ppm" +as from "djpeg -outfile out.ppm testorig.jpg". Note that the makefiles all +use the latter style and therefore do not exercise stdin/stdout! If this +check fails, try recompiling with USE_SETMODE or USE_FDOPEN defined. +If it still doesn't work, better use two-file style. + +If you chose a memory manager other than jmemnobs.c, you should test that +temporary-file usage works. Try "djpeg -bmp -colors 256 -max 0 testorig.jpg" +and make sure its output matches testimg.bmp. If you have any really large +images handy, try compressing them with -optimize and/or decompressing with +-colors 256 to make sure your DEFAULT_MAX_MEM setting is not too large. + +NOTE: this is far from an exhaustive test of the JPEG software; some modules, +such as 1-pass color quantization, are not exercised at all. It's just a +quick test to give you some confidence that you haven't missed something +major. + + +INSTALLING THE SOFTWARE +======================= + +Once you're done with the above steps, you can install the software by +copying the executable files (cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom) +to wherever you normally install programs. On Unix systems, you'll also want +to put the man pages (cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1) +in the man-page directory. The pre-fab makefiles don't support this step +since there's such a wide variety of installation procedures on different +systems. + +If you generated a Makefile with the "configure" script, you can just say + make install +to install the programs and their man pages into the standard places. +(You'll probably need to be root to do this.) We recommend first saying + make -n install +to see where configure thought the files should go. You may need to edit +the Makefile, particularly if your system's conventions for man page +filenames don't match what configure expects. + +If you want to install the IJG library itself, for use in compiling other +programs besides ours, then you need to put the four include files + jpeglib.h jerror.h jconfig.h jmorecfg.h +into your include-file directory, and put the library file libjpeg.a +(extension may vary depending on system) wherever library files go. +If you generated a Makefile with "configure", it will do what it thinks +is the right thing if you say + make install-lib + + +OPTIONAL STUFF +============== + +Progress monitor: + +If you like, you can #define PROGRESS_REPORT (in jconfig.h) to enable display +of percent-done progress reports. The routine provided in cdjpeg.c merely +prints percentages to stderr, but you can customize it to do something +fancier. + +Utah RLE file format support: + +We distribute the software with support for RLE image files (Utah Raster +Toolkit format) disabled, because the RLE support won't compile without the +Utah library. If you have URT version 3.1 or later, you can enable RLE +support as follows: + 1. #define RLE_SUPPORTED in jconfig.h. + 2. Add a -I option to CFLAGS in the Makefile for the directory + containing the URT .h files (typically the "include" + subdirectory of the URT distribution). + 3. Add -L... -lrle to LDLIBS in the Makefile, where ... specifies + the directory containing the URT "librle.a" file (typically the + "lib" subdirectory of the URT distribution). + +Support for 12-bit-deep pixel data: + +The JPEG standard allows either 8-bit or 12-bit data precision. (For color, +this means 8 or 12 bits per channel, of course.) If you need to work with +deeper than 8-bit data, you can compile the IJG code for 12-bit operation. +To do so: + 1. In jmorecfg.h, define BITS_IN_JSAMPLE as 12 rather than 8. + 2. In jconfig.h, undefine BMP_SUPPORTED, RLE_SUPPORTED, and TARGA_SUPPORTED, + because the code for those formats doesn't handle 12-bit data and won't + even compile. (The PPM code does work, as explained below. The GIF + code works too; it scales 8-bit GIF data to and from 12-bit depth + automatically.) + 3. Compile. Don't expect "make test" to pass, since the supplied test + files are for 8-bit data. + +Currently, 12-bit support does not work on 16-bit-int machines. + +Note that a 12-bit version will not read 8-bit JPEG files, nor vice versa; +so you'll want to keep around a regular 8-bit compilation as well. +(Run-time selection of data depth, to allow a single copy that does both, +is possible but would probably slow things down considerably; it's very low +on our to-do list.) + +The PPM reader (rdppm.c) can read 12-bit data from either text-format or +binary-format PPM and PGM files. Binary-format PPM/PGM files which have a +maxval greater than 255 are assumed to use 2 bytes per sample, LSB first +(little-endian order). As of early 1995, 2-byte binary format is not +officially supported by the PBMPLUS library, but it is expected that a +future release of PBMPLUS will support it. Note that the PPM reader will +read files of any maxval regardless of the BITS_IN_JSAMPLE setting; incoming +data is automatically rescaled to either maxval=255 or maxval=4095 as +appropriate for the cjpeg bit depth. + +The PPM writer (wrppm.c) will normally write 2-byte binary PPM or PGM +format, maxval 4095, when compiled with BITS_IN_JSAMPLE=12. Since this +format is not yet widely supported, you can disable it by compiling wrppm.c +with PPM_NORAWWORD defined; then the data is scaled down to 8 bits to make a +standard 1-byte/sample PPM or PGM file. (Yes, this means still another copy +of djpeg to keep around. But hopefully you won't need it for very long. +Poskanzer's supposed to get that new PBMPLUS release out Real Soon Now.) + +Of course, if you are working with 12-bit data, you probably have it stored +in some other, nonstandard format. In that case you'll probably want to +write your own I/O modules to read and write your format. + +Note that a 12-bit version of cjpeg always runs in "-optimize" mode, in +order to generate valid Huffman tables. This is necessary because our +default Huffman tables only cover 8-bit data. + +Removing code: + +If you need to make a smaller version of the JPEG software, some optional +functions can be removed at compile time. See the xxx_SUPPORTED #defines in +jconfig.h and jmorecfg.h. If at all possible, we recommend that you leave in +decoder support for all valid JPEG files, to ensure that you can read anyone's +output. Taking out support for image file formats that you don't use is the +most painless way to make the programs smaller. Another possibility is to +remove some of the DCT methods: in particular, the "IFAST" method may not be +enough faster than the others to be worth keeping on your machine. (If you +do remove ISLOW or IFAST, be sure to redefine JDCT_DEFAULT or JDCT_FASTEST +to a supported method, by adding a #define in jconfig.h.) + + +OPTIMIZATION +============ + +Unless you own a Cray, you'll probably be interested in making the JPEG +software go as fast as possible. This section covers some machine-dependent +optimizations you may want to try. We suggest that before trying any of +this, you first get the basic installation to pass the self-test step. +Repeat the self-test after any optimization to make sure that you haven't +broken anything. + +The integer DCT routines perform a lot of multiplications. These +multiplications must yield 32-bit results, but none of their input values +are more than 16 bits wide. On many machines, notably the 680x0 and 80x86 +CPUs, a 16x16=>32 bit multiply instruction is faster than a full 32x32=>32 +bit multiply. Unfortunately there is no portable way to specify such a +multiplication in C, but some compilers can generate one when you use the +right combination of casts. See the MULTIPLYxxx macro definitions in +jdct.h. If your compiler makes "int" be 32 bits and "short" be 16 bits, +defining SHORTxSHORT_32 is fairly likely to work. When experimenting with +alternate definitions, be sure to test not only whether the code still works +(use the self-test), but also whether it is actually faster --- on some +compilers, alternate definitions may compute the right answer, yet be slower +than the default. Timing cjpeg on a large PGM (grayscale) input file is the +best way to check this, as the DCT will be the largest fraction of the runtime +in that mode. (Note: some of the distributed compiler-specific jconfig files +already contain #define switches to select appropriate MULTIPLYxxx +definitions.) + +If your machine has sufficiently fast floating point hardware, you may find +that the float DCT method is faster than the integer DCT methods, even +after tweaking the integer multiply macros. In that case you may want to +make the float DCT be the default method. (The only objection to this is +that float DCT results may vary slightly across machines.) To do that, add +"#define JDCT_DEFAULT JDCT_FLOAT" to jconfig.h. Even if you don't change +the default, you should redefine JDCT_FASTEST, which is the method selected +by djpeg's -fast switch. Don't forget to update the documentation files +(usage.doc and/or cjpeg.1, djpeg.1) to agree with what you've done. + +If access to "short" arrays is slow on your machine, it may be a win to +define type JCOEF as int rather than short. This will cost a good deal of +memory though, particularly in some multi-pass modes, so don't do it unless +you have memory to burn and short is REALLY slow. + +If your compiler can compile function calls in-line, make sure the INLINE +macro in jmorecfg.h is defined as the keyword that marks a function +inline-able. Some compilers have a switch that tells the compiler to inline +any function it thinks is profitable (e.g., -finline-functions for gcc). +Enabling such a switch is likely to make the compiled code bigger but faster. + +In general, it's worth trying the maximum optimization level of your compiler, +and experimenting with any optional optimizations such as loop unrolling. +(Unfortunately, far too many compilers have optimizer bugs ... be prepared to +back off if the code fails self-test.) If you do any experimentation along +these lines, please report the optimal settings to jpeg-info@uunet.uu.net so +we can mention them in future releases. Be sure to specify your machine and +compiler version. + + +HINTS FOR SPECIFIC SYSTEMS +========================== + +We welcome reports on changes needed for systems not mentioned here. Submit +'em to jpeg-info@uunet.uu.net. Also, if configure or ckconfig.c is wrong +about how to configure the JPEG software for your system, please let us know. + + +Acorn RISC OS: + +(Thanks to Simon Middleton for these hints on compiling with Desktop C.) +After renaming the files according to Acorn conventions, take a copy of +makefile.ansi, change all occurrences of 'libjpeg.a' to 'libjpeg.o' and +change these definitions as indicated: + +CFLAGS= -throwback -IC: -Wn +LDLIBS=C:o.Stubs +SYSDEPMEM=jmemansi.o +LN=Link +AR=LibFile -c -o + +Also add a new line '.c.o:; $(cc) $< $(cflags) -c -o $@'. Remove the +lines '$(RM) libjpeg.o' and '$(AR2) libjpeg.o' and the 'jconfig.h' +dependency section. + +Copy jconfig.doc to jconfig.h. Edit jconfig.h to define TWO_FILE_COMMANDLINE +and CHAR_IS_UNSIGNED. + +Run the makefile using !AMU not !Make. If you want to use the 'clean' and +'test' makefile entries then you will have to fiddle with the syntax a bit +and rename the test files. + + +Amiga: + +SAS C 6.50 reportedly is too buggy to compile the IJG code properly. +A patch to update to 6.51 is available from SAS or AmiNet FTP sites. + +The supplied config files are set up to use jmemname.c as the memory +manager, with temporary files being created on the device named by +"JPEGTMP:". + + +Atari ST/STE/TT: + +Copy the project files makcjpeg.st, makdjpeg.st, maktjpeg.st, and makljpeg.st +to cjpeg.prj, djpeg.prj, jpegtran.prj, and libjpeg.prj respectively. The +project files should work as-is with Pure C. For Turbo C, change library +filenames "pc..." to "tc..." in each project file. Note that libjpeg.prj +selects jmemansi.c as the recommended memory manager. You'll probably want to +adjust the DEFAULT_MAX_MEM setting --- you want it to be a couple hundred K +less than your normal free memory. Put "#define DEFAULT_MAX_MEM nnnn" into +jconfig.h to do this. + +To use the 68881/68882 coprocessor for the floating point DCT, add the +compiler option "-8" to the project files and replace pcfltlib.lib with +pc881lib.lib in cjpeg.prj and djpeg.prj. Or if you don't have a +coprocessor, you may prefer to remove the float DCT code by undefining +DCT_FLOAT_SUPPORTED in jmorecfg.h (since without a coprocessor, the float +code will be too slow to be useful). In that case, you can delete +pcfltlib.lib from the project files. + +Note that you must make libjpeg.lib before making cjpeg.ttp, djpeg.ttp, +or jpegtran.ttp. You'll have to perform the self-test by hand. + +We haven't bothered to include project files for rdjpgcom and wrjpgcom. +Those source files should just be compiled by themselves; they don't +depend on the JPEG library. + +There is a bug in some older versions of the Turbo C library which causes the +space used by temporary files created with "tmpfile()" not to be freed after +an abnormal program exit. If you check your disk afterwards, you will find +cluster chains that are allocated but not used by a file. This should not +happen in cjpeg/djpeg/jpegtran, since we enable a signal catcher to explicitly +close temp files before exiting. But if you use the JPEG library with your +own code, be sure to supply a signal catcher, or else use a different +system-dependent memory manager. + + +Cray: + +Should you be so fortunate as to be running JPEG on a Cray YMP, there is a +compiler bug in old versions of Cray's Standard C (prior to 3.1). If you +still have an old compiler, you'll need to insert a line reading +"#pragma novector" just before the loop + for (i = 1; i <= (int) htbl->bits[l]; i++) + huffsize[p++] = (char) l; +in fix_huff_tbl (in V5beta1, line 204 of jchuff.c and line 176 of jdhuff.c). +[This bug may or may not still occur with the current IJG code, but it's +probably a dead issue anyway...] + + +HP-UX: + +If you have HP-UX 7.05 or later with the "software development" C compiler, +you should run the compiler in ANSI mode. If using the configure script, +say + ./configure CC='cc -Aa' +(or -Ae if you prefer). If configuring by hand, use makefile.ansi and add +"-Aa" to the CFLAGS line in the makefile. + +If you have a pre-7.05 system, or if you are using the non-ANSI C compiler +delivered with a minimum HP-UX system, then you must use makefile.unix +(and do NOT add -Aa); or just run configure without the CC option. + +On HP 9000 series 800 machines, the HP C compiler is buggy in revisions prior +to A.08.07. If you get complaints about "not a typedef name", you'll have to +use makefile.unix, or run configure without the CC option. + + +Macintosh, generic comments: + +The supplied user-interface files (cjpeg.c, djpeg.c, etc) are set up to +provide a Unix-style command line interface. You can use this interface on +the Mac by means of the ccommand() library routine provided by Metrowerks +CodeWarrior or Think C. This is only appropriate for testing the library, +however; to make a user-friendly equivalent of cjpeg/djpeg you'd really want +to develop a Mac-style user interface. There isn't a complete example +available at the moment, but there are some helpful starting points: +1. Sam Bushell's free "To JPEG" applet provides drag-and-drop conversion to +JPEG under System 7 and later. This only illustrates how to use the +compression half of the library, but it does a very nice job of that part. +The CodeWarrior source code is available from http://www.pobox.com/~jsam. +2. Jim Brunner prepared a Mac-style user interface for both compression and +decompression. Unfortunately, it hasn't been updated since IJG v4, and +the library's API has changed considerably since then. Still it may be of +some help, particularly as a guide to compiling the IJG code under Think C. +Jim's code is available from the Info-Mac archives, at sumex-aim.stanford.edu +or mirrors thereof; see file /info-mac/dev/src/jpeg-convert-c.hqx. + +jmemmac.c is the recommended memory manager back end for Macintosh. It uses +NewPtr/DisposePtr instead of malloc/free, and has a Mac-specific +implementation of jpeg_mem_available(). It also creates temporary files that +follow Mac conventions. (That part of the code relies on System-7-or-later OS +functions. See the comments in jmemmac.c if you need to run it on System 6.) +NOTE that USE_MAC_MEMMGR must be defined in jconfig.h to use jmemmac.c. + +You can also use jmemnobs.c, if you don't care about handling images larger +than available memory. If you use any memory manager back end other than +jmemmac.c, we recommend replacing "malloc" and "free" by "NewPtr" and +"DisposePtr", because Mac C libraries often have peculiar implementations of +malloc/free. (For instance, free() may not return the freed space to the +Mac Memory Manager. This is undesirable for the IJG code because jmemmgr.c +already clumps space requests.) + + +Macintosh, Metrowerks CodeWarrior: + +The Unix-command-line-style interface can be used by defining USE_CCOMMAND. +You'll also need to define TWO_FILE_COMMANDLINE to avoid stdin/stdout. +This means that when using the cjpeg/djpeg programs, you'll have to type the +input and output file names in the "Arguments" text-edit box, rather than +using the file radio buttons. (Perhaps USE_FDOPEN or USE_SETMODE would +eliminate the problem, but I haven't heard from anyone who's tried it.) + +On 680x0 Macs, Metrowerks defines type "double" as a 10-byte IEEE extended +float. jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power +of 2. Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. + +The supplied configuration file jconfig.mac can be used for your jconfig.h; +it includes all the recommended symbol definitions. If you have AppleScript +installed, you can run the supplied script makeproj.mac to create CodeWarrior +project files for the library and the testbed applications, then build the +library and applications. (Thanks to Dan Sears and Don Agro for this nifty +hack, which saves us from trying to maintain CodeWarrior project files as part +of the IJG distribution...) + + +Macintosh, Think C: + +The documentation in Jim Brunner's "JPEG Convert" source code (see above) +includes detailed build instructions for Think C; it's probably somewhat +out of date for the current release, but may be helpful. + +If you want to build the minimal command line version, proceed as follows. +You'll have to prepare project files for the programs; we don't include any +in the distribution since they are not text files. Use the file lists in +any of the supplied makefiles as a guide. Also add the ANSI and Unix C +libraries in a separate segment. You may need to divide the JPEG files into +more than one segment; we recommend dividing compression and decompression +modules. Define USE_CCOMMAND in jconfig.h so that the ccommand() routine is +called. You must also define TWO_FILE_COMMANDLINE because stdin/stdout +don't handle binary data correctly. + +On 680x0 Macs, Think C defines type "double" as a 12-byte IEEE extended float. +jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power of 2. +Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. + +jconfig.mac should work as a jconfig.h configuration file for Think C, +but the makeproj.mac AppleScript script is specific to CodeWarrior. Sorry. + + +MIPS R3000: + +MIPS's cc version 1.31 has a rather nasty optimization bug. Don't use -O +if you have that compiler version. (Use "cc -V" to check the version.) +Note that the R3000 chip is found in workstations from DEC and others. + + +MS-DOS, generic comments for 16-bit compilers: + +The IJG code is designed to work well in 80x86 "small" or "medium" memory +models (i.e., data pointers are 16 bits unless explicitly declared "far"; +code pointers can be either size). You may be able to use small model to +compile cjpeg or djpeg by itself, but you will probably have to use medium +model for any larger application. This won't make much difference in +performance. You *will* take a noticeable performance hit if you use a +large-data memory model, and you should avoid "huge" model if at all +possible. Be sure that NEED_FAR_POINTERS is defined in jconfig.h if you use +a small-data memory model; be sure it is NOT defined if you use a large-data +model. (The supplied makefiles and jconfig files for Borland and Microsoft C +compile in medium model and define NEED_FAR_POINTERS.) + +The DOS-specific memory manager, jmemdos.c, should be used if possible. +It needs some assembly-code routines which are in jmemdosa.asm; make sure +your makefile assembles that file and includes it in the library. If you +don't have a suitable assembler, you can get pre-assembled object files for +jmemdosa by FTP from ftp.uu.net:/graphics/jpeg/jdosaobj.zip. (DOS-oriented +distributions of the IJG source code often include these object files.) + +When using jmemdos.c, jconfig.h must define USE_MSDOS_MEMMGR and must set +MAX_ALLOC_CHUNK to less than 64K (65520L is a typical value). If your +C library's far-heap malloc() can't allocate blocks that large, reduce +MAX_ALLOC_CHUNK to whatever it can handle. + +If you can't use jmemdos.c for some reason --- for example, because you +don't have an assembler to assemble jmemdosa.asm --- you'll have to fall +back to jmemansi.c or jmemname.c. You'll probably still need to set +MAX_ALLOC_CHUNK in jconfig.h, because most DOS C libraries won't malloc() +more than 64K at a time. IMPORTANT: if you use jmemansi.c or jmemname.c, +you will have to compile in a large-data memory model in order to get the +right stdio library. Too bad. + +wrjpgcom needs to be compiled in large model, because it malloc()s a 64KB +work area to hold the comment text. If your C library's malloc can't +handle that, reduce MAX_COM_LENGTH as necessary in wrjpgcom.c. + +Most MS-DOS compilers treat stdin/stdout as text files, so you must use +two-file command line style. But if your compiler has either fdopen() or +setmode(), you can use one-file style if you like. To do this, define +USE_SETMODE or USE_FDOPEN so that stdin/stdout will be set to binary mode. +(USE_SETMODE seems to work with more DOS compilers than USE_FDOPEN.) You +should test that I/O through stdin/stdout produces the same results as I/O +to explicitly named files... the "make test" procedures in the supplied +makefiles do NOT use stdin/stdout. + + +MS-DOS, generic comments for 32-bit compilers: + +None of the above comments about memory models apply if you are using a +32-bit flat-memory-space environment, such as DJGPP or Watcom C. (And you +should use one if you have it, as performance will be much better than +8086-compatible code!) For flat-memory-space compilers, do NOT define +NEED_FAR_POINTERS, and do NOT use jmemdos.c. Use jmemnobs.c if the +environment supplies adequate virtual memory, otherwise use jmemansi.c or +jmemname.c. + +You'll still need to be careful about binary I/O through stdin/stdout. +See the last paragraph of the previous section. + + +MS-DOS, Borland C: + +Be sure to convert all the source files to DOS text format (CR/LF newlines). +Although Borland C will often work OK with unmodified Unix (LF newlines) +source files, sometimes it will give bogus compile errors. +"Illegal character '#'" is the most common such error. (This is true with +Borland C 3.1, but perhaps is fixed in newer releases.) + +If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. +jconfig.bcc already includes #define USE_SETMODE to make this work. +(fdopen does not work correctly.) + + +MS-DOS, Microsoft C: + +makefile.mc6 works with Microsoft C, DOS Visual C++, etc. It should only +be used if you want to build a 16-bit (small or medium memory model) program. + +If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. +jconfig.mc6 already includes #define USE_SETMODE to make this work. +(fdopen does not work correctly.) + +Note that this makefile assumes that the working copy of itself is called +"makefile". If you want to call it something else, say "makefile.mak", +be sure to adjust the dependency line that reads "$(RFILE) : makefile". +Otherwise the make will fail because it doesn't know how to create "makefile". +Worse, some releases of Microsoft's make utilities give an incorrect error +message in this situation. + +Old versions of MS C fail with an "out of macro expansion space" error +because they can't cope with the macro TRACEMS8 (defined in jerror.h). +If this happens to you, the easiest solution is to change TRACEMS8 to +expand to nothing. You'll lose the ability to dump out JPEG coefficient +tables with djpeg -debug -debug, but at least you can compile. + +Original MS C 6.0 is very buggy; it compiles incorrect code unless you turn +off optimization entirely (remove -O from CFLAGS). 6.00A is better, but it +still generates bad code if you enable loop optimizations (-Ol or -Ox). + +MS C 8.0 crashes when compiling jquant1.c with optimization switch /Oo ... +which is on by default. To work around this bug, compile that one file +with /Oo-. + + +Microsoft Windows (all versions), generic comments: + +Some Windows system include files define typedef boolean as "unsigned char". +The IJG code also defines typedef boolean, but we make it "int" by default. +This doesn't affect the IJG programs because we don't import those Windows +include files. But if you use the JPEG library in your own program, and some +of your program's files import one definition of boolean while some import the +other, you can get all sorts of mysterious problems. A good preventive step +is to make the IJG library use "unsigned char" for boolean. To do that, +add something like this to your jconfig.h file: + /* Define "boolean" as unsigned char, not int, per Windows custom */ + #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ + typedef unsigned char boolean; + #endif + #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ +(This is already in jconfig.vc, by the way.) + +windef.h contains the declarations + #define far + #define FAR far +Since jmorecfg.h tries to define FAR as empty, you may get a compiler +warning if you include both jpeglib.h and windef.h (which windows.h +includes). To suppress the warning, you can put "#ifndef FAR"/"#endif" +around the line "#define FAR" in jmorecfg.h. + +When using the library in a Windows application, you will almost certainly +want to modify or replace the error handler module jerror.c, since our +default error handler does a couple of inappropriate things: + 1. it tries to write error and warning messages on stderr; + 2. in event of a fatal error, it exits by calling exit(). + +A simple stopgap solution for problem 1 is to replace the line + fprintf(stderr, "%s\n", buffer); +(in output_message in jerror.c) with + MessageBox(GetActiveWindow(),buffer,"JPEG Error",MB_OK|MB_ICONERROR); +It's highly recommended that you at least do that much, since otherwise +error messages will disappear into nowhere. (Beginning with IJG v6b, this +code is already present in jerror.c; just define USE_WINDOWS_MESSAGEBOX in +jconfig.h to enable it.) + +The proper solution for problem 2 is to return control to your calling +application after a library error. This can be done with the setjmp/longjmp +technique discussed in libjpeg.doc and illustrated in example.c. (NOTE: +some older Windows C compilers provide versions of setjmp/longjmp that +don't actually work under Windows. You may need to use the Windows system +functions Catch and Throw instead.) + +The recommended memory manager under Windows is jmemnobs.c; in other words, +let Windows do any virtual memory management needed. You should NOT use +jmemdos.c nor jmemdosa.asm under Windows. + +For Windows 3.1, we recommend compiling in medium or large memory model; +for newer Windows versions, use a 32-bit flat memory model. (See the MS-DOS +sections above for more info about memory models.) In the 16-bit memory +models only, you'll need to put + #define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ +into jconfig.h to limit allocation chunks to 64Kb. (Without that, you'd +have to use huge memory model, which slows things down unnecessarily.) +jmemnobs.c works without modification in large or flat memory models, but to +use medium model, you need to modify its jpeg_get_large and jpeg_free_large +routines to allocate far memory. In any case, you might like to replace +its calls to malloc and free with direct calls on Windows memory allocation +functions. + +You may also want to modify jdatasrc.c and jdatadst.c to use Windows file +operations rather than fread/fwrite. This is only necessary if your C +compiler doesn't provide a competent implementation of C stdio functions. + +You might want to tweak the RGB_xxx macros in jmorecfg.h so that the library +will accept or deliver color pixels in BGR sample order, not RGB; BGR order +is usually more convenient under Windows. Note that this change will break +the sample applications cjpeg/djpeg, but the library itself works fine. + + +Many people want to convert the IJG library into a DLL. This is reasonably +straightforward, but watch out for the following: + + 1. Don't try to compile as a DLL in small or medium memory model; use +large model, or even better, 32-bit flat model. Many places in the IJG code +assume the address of a local variable is an ordinary (not FAR) pointer; +that isn't true in a medium-model DLL. + + 2. Microsoft C cannot pass file pointers between applications and DLLs. +(See Microsoft Knowledge Base, PSS ID Number Q50336.) So jdatasrc.c and +jdatadst.c don't work if you open a file in your application and then pass +the pointer to the DLL. One workaround is to make jdatasrc.c/jdatadst.c +part of your main application rather than part of the DLL. + + 3. You'll probably need to modify the macros GLOBAL() and EXTERN() to +attach suitable linkage keywords to the exported routine names. Similarly, +you'll want to modify METHODDEF() and JMETHOD() to ensure function pointers +are declared in a way that lets application routines be called back through +the function pointers. These macros are in jmorecfg.h. Typical definitions +for a 16-bit DLL are: + #define GLOBAL(type) type _far _pascal _loadds _export + #define EXTERN(type) extern type _far _pascal _loadds + #define METHODDEF(type) static type _far _pascal + #define JMETHOD(type,methodname,arglist) \ + type (_far _pascal *methodname) arglist +For a 32-bit DLL you may want something like + #define GLOBAL(type) __declspec(dllexport) type + #define EXTERN(type) extern __declspec(dllexport) type +Although not all the GLOBAL routines are actually intended to be called by +the application, the performance cost of making them all DLL entry points is +negligible. + +The unmodified IJG library presents a very C-specific application interface, +so the resulting DLL is only usable from C or C++ applications. There has +been some talk of writing wrapper code that would present a simpler interface +usable from other languages, such as Visual Basic. This is on our to-do list +but hasn't been very high priority --- any volunteers out there? + + +Microsoft Windows, Borland C: + +The provided jconfig.bcc should work OK in a 32-bit Windows environment, +but you'll need to tweak it in a 16-bit environment (you'd need to define +NEED_FAR_POINTERS and MAX_ALLOC_CHUNK). Beware that makefile.bcc will need +alteration if you want to use it for Windows --- in particular, you should +use jmemnobs.c not jmemdos.c under Windows. + +Borland C++ 4.5 fails with an internal compiler error when trying to compile +jdmerge.c in 32-bit mode. If enough people complain, perhaps Borland will fix +it. In the meantime, the simplest known workaround is to add a redundant +definition of the variable range_limit in h2v1_merged_upsample(), at the head +of the block that handles odd image width (about line 268 in v6 jdmerge.c): + /* If image width is odd, do the last output column separately */ + if (cinfo->output_width & 1) { + register JSAMPLE * range_limit = cinfo->sample_range_limit; /* ADD THIS */ + cb = GETJSAMPLE(*inptr1); +Pretty bizarre, especially since the very similar routine h2v2_merged_upsample +doesn't trigger the bug. +Recent reports suggest that this bug does not occur with "bcc32a" (the +Pentium-optimized version of the compiler). + +Another report from a user of Borland C 4.5 was that incorrect code (leading +to a color shift in processed images) was produced if any of the following +optimization switch combinations were used: + -Ot -Og + -Ot -Op + -Ot -Om +So try backing off on optimization if you see such a problem. (Are there +several different releases all numbered "4.5"??) + + +Microsoft Windows, Microsoft Visual C++: + +jconfig.vc should work OK with any Microsoft compiler for a 32-bit memory +model. makefile.vc is intended for command-line use. (If you are using +the Developer Studio environment, you may prefer the DevStudio project +files; see below.) + +Some users feel that it's easier to call the library from C++ code if you +force VC++ to treat the library as C++ code, which you can do by renaming +all the *.c files to *.cpp (and adjusting the makefile to match). This +avoids the need to put extern "C" { ... } around #include "jpeglib.h" in +your C++ application. + + +Microsoft Windows, Microsoft Developer Studio: + +We include makefiles that should work as project files in DevStudio 4.2 or +later. There is a library makefile that builds the IJG library as a static +Win32 library, and an application makefile that builds the sample applications +as Win32 console applications. (Even if you only want the library, we +recommend building the applications so that you can run the self-test.) + +To use: +1. Copy jconfig.vc to jconfig.h, makelib.ds to jpeg.mak, and + makeapps.ds to apps.mak. (Note that the renaming is critical!) +2. Click on the .mak files to construct project workspaces. + (If you are using DevStudio more recent than 4.2, you'll probably + get a message saying that the makefiles are being updated.) +3. Build the library project, then the applications project. +4. Move the application .exe files from `app`\Release to an + appropriate location on your path. +5. To perform the self-test, execute the command line + NMAKE /f makefile.vc test + + +OS/2, Borland C++: + +Watch out for optimization bugs in older Borland compilers; you may need +to back off the optimization switch settings. See the comments in +makefile.bcc. + + +SGI: + +On some SGI systems, you may need to set "AR2= ar -ts" in the Makefile. +If you are using configure, you can do this by saying + ./configure RANLIB='ar -ts' +This change is not needed on all SGIs. Use it only if the make fails at the +stage of linking the completed programs. + +On the MIPS R4000 architecture (Indy, etc.), the compiler option "-mips2" +reportedly speeds up the float DCT method substantially, enough to make it +faster than the default int method (but still slower than the fast int +method). If you use -mips2, you may want to alter the default DCT method to +be float. To do this, put "#define JDCT_DEFAULT JDCT_FLOAT" in jconfig.h. + + +VMS: + +On an Alpha/VMS system with MMS, be sure to use the "/Marco=Alpha=1" +qualifier with MMS when building the JPEG package. + +VAX/VMS v5.5-1 may have problems with the test step of the build procedure +reporting differences when it compares the original and test images. If the +error points to the last block of the files, it is most likely bogus and may +be safely ignored. It seems to be because the files are Stream_LF and +Backup/Compare has difficulty with the (presumably) null padded files. +This problem was not observed on VAX/VMS v6.1 or AXP/VMS v6.1. diff --git a/src/dep/src/irrlicht/jpeglib/jcapimin.c b/src/dep/src/irrlicht/jpeglib/jcapimin.c index 493af5c..54fb8c5 100644 --- a/src/dep/src/irrlicht/jpeglib/jcapimin.c +++ b/src/dep/src/irrlicht/jpeglib/jcapimin.c @@ -1,280 +1,280 @@ -/* - * jcapimin.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the compression half - * of the JPEG library. These are the "minimum" API routines that may be - * needed in either the normal full-compression case or the transcoding-only - * case. - * - * Most of the routines intended to be called directly by an application - * are in this file or in jcapistd.c. But also see jcparam.c for - * parameter-setup helper routines, jcomapi.c for routines shared by - * compression and decompression, and jctrans.c for the transcoding case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Initialization of a JPEG compression object. - * The error manager must already be set up (in case memory manager fails). - */ - -GLOBAL(void) -jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize) -{ - int i; - - /* Guard against version mismatches between library and caller. */ - cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ - if (version != JPEG_LIB_VERSION) - ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); - if (structsize != SIZEOF(struct jpeg_compress_struct)) - ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, - (int) SIZEOF(struct jpeg_compress_struct), (int) structsize); - - /* For debugging purposes, we zero the whole master structure. - * But the application has already set the err pointer, and may have set - * client_data, so we have to save and restore those fields. - * Note: if application hasn't set client_data, tools like Purify may - * complain here. - */ - { - struct jpeg_error_mgr * err = cinfo->err; - void * client_data = cinfo->client_data; /* ignore Purify complaint here */ - MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct)); - cinfo->err = err; - cinfo->client_data = client_data; - } - cinfo->is_decompressor = FALSE; - - /* Initialize a memory manager instance for this object */ - jinit_memory_mgr((j_common_ptr) cinfo); - - /* Zero out pointers to permanent structures. */ - cinfo->progress = NULL; - cinfo->dest = NULL; - - cinfo->comp_info = NULL; - - for (i = 0; i < NUM_QUANT_TBLS; i++) - cinfo->quant_tbl_ptrs[i] = NULL; - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - cinfo->dc_huff_tbl_ptrs[i] = NULL; - cinfo->ac_huff_tbl_ptrs[i] = NULL; - } - - cinfo->script_space = NULL; - - cinfo->input_gamma = 1.0; /* in case application forgets */ - - /* OK, I'm ready */ - cinfo->global_state = CSTATE_START; -} - - -/* - * Destruction of a JPEG compression object - */ - -GLOBAL(void) -jpeg_destroy_compress (j_compress_ptr cinfo) -{ - jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Abort processing of a JPEG compression operation, - * but don't destroy the object itself. - */ - -GLOBAL(void) -jpeg_abort_compress (j_compress_ptr cinfo) -{ - jpeg_abort((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Forcibly suppress or un-suppress all quantization and Huffman tables. - * Marks all currently defined tables as already written (if suppress) - * or not written (if !suppress). This will control whether they get emitted - * by a subsequent jpeg_start_compress call. - * - * This routine is exported for use by applications that want to produce - * abbreviated JPEG datastreams. It logically belongs in jcparam.c, but - * since it is called by jpeg_start_compress, we put it here --- otherwise - * jcparam.o would be linked whether the application used it or not. - */ - -GLOBAL(void) -jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress) -{ - int i; - JQUANT_TBL * qtbl; - JHUFF_TBL * htbl; - - for (i = 0; i < NUM_QUANT_TBLS; i++) { - if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL) - qtbl->sent_table = suppress; - } - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL) - htbl->sent_table = suppress; - if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL) - htbl->sent_table = suppress; - } -} - - -/* - * Finish JPEG compression. - * - * If a multipass operating mode was selected, this may do a great deal of - * work including most of the actual output. - */ - -GLOBAL(void) -jpeg_finish_compress (j_compress_ptr cinfo) -{ - JDIMENSION iMCU_row; - - if (cinfo->global_state == CSTATE_SCANNING || - cinfo->global_state == CSTATE_RAW_OK) { - /* Terminate first pass */ - if (cinfo->next_scanline < cinfo->image_height) - ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); - (*cinfo->master->finish_pass) (cinfo); - } else if (cinfo->global_state != CSTATE_WRCOEFS) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Perform any remaining passes */ - while (! cinfo->master->is_last_pass) { - (*cinfo->master->prepare_for_pass) (cinfo); - for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) { - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) iMCU_row; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - /* We bypass the main controller and invoke coef controller directly; - * all work is being done from the coefficient buffer. - */ - if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } - (*cinfo->master->finish_pass) (cinfo); - } - /* Write EOI, do final cleanup */ - (*cinfo->marker->write_file_trailer) (cinfo); - (*cinfo->dest->term_destination) (cinfo); - /* We can use jpeg_abort to release memory and reset global_state */ - jpeg_abort((j_common_ptr) cinfo); -} - - -/* - * Write a special marker. - * This is only recommended for writing COM or APPn markers. - * Must be called after jpeg_start_compress() and before - * first call to jpeg_write_scanlines() or jpeg_write_raw_data(). - */ - -GLOBAL(void) -jpeg_write_marker (j_compress_ptr cinfo, int marker, - const JOCTET *dataptr, unsigned int datalen) -{ - JMETHOD(void, write_marker_byte, (j_compress_ptr info, int val)); - - if (cinfo->next_scanline != 0 || - (cinfo->global_state != CSTATE_SCANNING && - cinfo->global_state != CSTATE_RAW_OK && - cinfo->global_state != CSTATE_WRCOEFS)) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); - write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */ - while (datalen--) { - (*write_marker_byte) (cinfo, *dataptr); - dataptr++; - } -} - -/* Same, but piecemeal. */ - -GLOBAL(void) -jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen) -{ - if (cinfo->next_scanline != 0 || - (cinfo->global_state != CSTATE_SCANNING && - cinfo->global_state != CSTATE_RAW_OK && - cinfo->global_state != CSTATE_WRCOEFS)) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); -} - -GLOBAL(void) -jpeg_write_m_byte (j_compress_ptr cinfo, int val) -{ - (*cinfo->marker->write_marker_byte) (cinfo, val); -} - - -/* - * Alternate compression function: just write an abbreviated table file. - * Before calling this, all parameters and a data destination must be set up. - * - * To produce a pair of files containing abbreviated tables and abbreviated - * image data, one would proceed as follows: - * - * initialize JPEG object - * set JPEG parameters - * set destination to table file - * jpeg_write_tables(cinfo); - * set destination to image file - * jpeg_start_compress(cinfo, FALSE); - * write data... - * jpeg_finish_compress(cinfo); - * - * jpeg_write_tables has the side effect of marking all tables written - * (same as jpeg_suppress_tables(..., TRUE)). Thus a subsequent start_compress - * will not re-emit the tables unless it is passed write_all_tables=TRUE. - */ - -GLOBAL(void) -jpeg_write_tables (j_compress_ptr cinfo) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Initialize the marker writer ... bit of a crock to do it here. */ - jinit_marker_writer(cinfo); - /* Write them tables! */ - (*cinfo->marker->write_tables_only) (cinfo); - /* And clean up. */ - (*cinfo->dest->term_destination) (cinfo); - /* - * In library releases up through v6a, we called jpeg_abort() here to free - * any working memory allocated by the destination manager and marker - * writer. Some applications had a problem with that: they allocated space - * of their own from the library memory manager, and didn't want it to go - * away during write_tables. So now we do nothing. This will cause a - * memory leak if an app calls write_tables repeatedly without doing a full - * compression cycle or otherwise resetting the JPEG object. However, that - * seems less bad than unexpectedly freeing memory in the normal case. - * An app that prefers the old behavior can call jpeg_abort for itself after - * each call to jpeg_write_tables(). - */ -} +/* + * jcapimin.c + * + * Copyright (C) 1994-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the compression half + * of the JPEG library. These are the "minimum" API routines that may be + * needed in either the normal full-compression case or the transcoding-only + * case. + * + * Most of the routines intended to be called directly by an application + * are in this file or in jcapistd.c. But also see jcparam.c for + * parameter-setup helper routines, jcomapi.c for routines shared by + * compression and decompression, and jctrans.c for the transcoding case. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Initialization of a JPEG compression object. + * The error manager must already be set up (in case memory manager fails). + */ + +GLOBAL(void) +jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize) +{ + int i; + + /* Guard against version mismatches between library and caller. */ + cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ + if (version != JPEG_LIB_VERSION) + ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); + if (structsize != SIZEOF(struct jpeg_compress_struct)) + ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, + (int) SIZEOF(struct jpeg_compress_struct), (int) structsize); + + /* For debugging purposes, we zero the whole master structure. + * But the application has already set the err pointer, and may have set + * client_data, so we have to save and restore those fields. + * Note: if application hasn't set client_data, tools like Purify may + * complain here. + */ + { + struct jpeg_error_mgr * err = cinfo->err; + void * client_data = cinfo->client_data; /* ignore Purify complaint here */ + MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct)); + cinfo->err = err; + cinfo->client_data = client_data; + } + cinfo->is_decompressor = FALSE; + + /* Initialize a memory manager instance for this object */ + jinit_memory_mgr((j_common_ptr) cinfo); + + /* Zero out pointers to permanent structures. */ + cinfo->progress = NULL; + cinfo->dest = NULL; + + cinfo->comp_info = NULL; + + for (i = 0; i < NUM_QUANT_TBLS; i++) + cinfo->quant_tbl_ptrs[i] = NULL; + + for (i = 0; i < NUM_HUFF_TBLS; i++) { + cinfo->dc_huff_tbl_ptrs[i] = NULL; + cinfo->ac_huff_tbl_ptrs[i] = NULL; + } + + cinfo->script_space = NULL; + + cinfo->input_gamma = 1.0; /* in case application forgets */ + + /* OK, I'm ready */ + cinfo->global_state = CSTATE_START; +} + + +/* + * Destruction of a JPEG compression object + */ + +GLOBAL(void) +jpeg_destroy_compress (j_compress_ptr cinfo) +{ + jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Abort processing of a JPEG compression operation, + * but don't destroy the object itself. + */ + +GLOBAL(void) +jpeg_abort_compress (j_compress_ptr cinfo) +{ + jpeg_abort((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Forcibly suppress or un-suppress all quantization and Huffman tables. + * Marks all currently defined tables as already written (if suppress) + * or not written (if !suppress). This will control whether they get emitted + * by a subsequent jpeg_start_compress call. + * + * This routine is exported for use by applications that want to produce + * abbreviated JPEG datastreams. It logically belongs in jcparam.c, but + * since it is called by jpeg_start_compress, we put it here --- otherwise + * jcparam.o would be linked whether the application used it or not. + */ + +GLOBAL(void) +jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress) +{ + int i; + JQUANT_TBL * qtbl; + JHUFF_TBL * htbl; + + for (i = 0; i < NUM_QUANT_TBLS; i++) { + if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL) + qtbl->sent_table = suppress; + } + + for (i = 0; i < NUM_HUFF_TBLS; i++) { + if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL) + htbl->sent_table = suppress; + if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL) + htbl->sent_table = suppress; + } +} + + +/* + * Finish JPEG compression. + * + * If a multipass operating mode was selected, this may do a great deal of + * work including most of the actual output. + */ + +GLOBAL(void) +jpeg_finish_compress (j_compress_ptr cinfo) +{ + JDIMENSION iMCU_row; + + if (cinfo->global_state == CSTATE_SCANNING || + cinfo->global_state == CSTATE_RAW_OK) { + /* Terminate first pass */ + if (cinfo->next_scanline < cinfo->image_height) + ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); + (*cinfo->master->finish_pass) (cinfo); + } else if (cinfo->global_state != CSTATE_WRCOEFS) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Perform any remaining passes */ + while (! cinfo->master->is_last_pass) { + (*cinfo->master->prepare_for_pass) (cinfo); + for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) { + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) iMCU_row; + cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + /* We bypass the main controller and invoke coef controller directly; + * all work is being done from the coefficient buffer. + */ + if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + } + (*cinfo->master->finish_pass) (cinfo); + } + /* Write EOI, do final cleanup */ + (*cinfo->marker->write_file_trailer) (cinfo); + (*cinfo->dest->term_destination) (cinfo); + /* We can use jpeg_abort to release memory and reset global_state */ + jpeg_abort((j_common_ptr) cinfo); +} + + +/* + * Write a special marker. + * This is only recommended for writing COM or APPn markers. + * Must be called after jpeg_start_compress() and before + * first call to jpeg_write_scanlines() or jpeg_write_raw_data(). + */ + +GLOBAL(void) +jpeg_write_marker (j_compress_ptr cinfo, int marker, + const JOCTET *dataptr, unsigned int datalen) +{ + JMETHOD(void, write_marker_byte, (j_compress_ptr info, int val)); + + if (cinfo->next_scanline != 0 || + (cinfo->global_state != CSTATE_SCANNING && + cinfo->global_state != CSTATE_RAW_OK && + cinfo->global_state != CSTATE_WRCOEFS)) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); + write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */ + while (datalen--) { + (*write_marker_byte) (cinfo, *dataptr); + dataptr++; + } +} + +/* Same, but piecemeal. */ + +GLOBAL(void) +jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen) +{ + if (cinfo->next_scanline != 0 || + (cinfo->global_state != CSTATE_SCANNING && + cinfo->global_state != CSTATE_RAW_OK && + cinfo->global_state != CSTATE_WRCOEFS)) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); +} + +GLOBAL(void) +jpeg_write_m_byte (j_compress_ptr cinfo, int val) +{ + (*cinfo->marker->write_marker_byte) (cinfo, val); +} + + +/* + * Alternate compression function: just write an abbreviated table file. + * Before calling this, all parameters and a data destination must be set up. + * + * To produce a pair of files containing abbreviated tables and abbreviated + * image data, one would proceed as follows: + * + * initialize JPEG object + * set JPEG parameters + * set destination to table file + * jpeg_write_tables(cinfo); + * set destination to image file + * jpeg_start_compress(cinfo, FALSE); + * write data... + * jpeg_finish_compress(cinfo); + * + * jpeg_write_tables has the side effect of marking all tables written + * (same as jpeg_suppress_tables(..., TRUE)). Thus a subsequent start_compress + * will not re-emit the tables unless it is passed write_all_tables=TRUE. + */ + +GLOBAL(void) +jpeg_write_tables (j_compress_ptr cinfo) +{ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* (Re)initialize error mgr and destination modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->dest->init_destination) (cinfo); + /* Initialize the marker writer ... bit of a crock to do it here. */ + jinit_marker_writer(cinfo); + /* Write them tables! */ + (*cinfo->marker->write_tables_only) (cinfo); + /* And clean up. */ + (*cinfo->dest->term_destination) (cinfo); + /* + * In library releases up through v6a, we called jpeg_abort() here to free + * any working memory allocated by the destination manager and marker + * writer. Some applications had a problem with that: they allocated space + * of their own from the library memory manager, and didn't want it to go + * away during write_tables. So now we do nothing. This will cause a + * memory leak if an app calls write_tables repeatedly without doing a full + * compression cycle or otherwise resetting the JPEG object. However, that + * seems less bad than unexpectedly freeing memory in the normal case. + * An app that prefers the old behavior can call jpeg_abort for itself after + * each call to jpeg_write_tables(). + */ +} diff --git a/src/dep/src/irrlicht/jpeglib/jcapistd.c b/src/dep/src/irrlicht/jpeglib/jcapistd.c index fed66ca..c0320b1 100644 --- a/src/dep/src/irrlicht/jpeglib/jcapistd.c +++ b/src/dep/src/irrlicht/jpeglib/jcapistd.c @@ -1,161 +1,161 @@ -/* - * jcapistd.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the compression half - * of the JPEG library. These are the "standard" API routines that are - * used in the normal full-compression case. They are not used by a - * transcoding-only application. Note that if an application links in - * jpeg_start_compress, it will end up linking in the entire compressor. - * We thus must separate this file from jcapimin.c to avoid linking the - * whole compression library into a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Compression initialization. - * Before calling this, all parameters and a data destination must be set up. - * - * We require a write_all_tables parameter as a failsafe check when writing - * multiple datastreams from the same compression object. Since prior runs - * will have left all the tables marked sent_table=TRUE, a subsequent run - * would emit an abbreviated stream (no tables) by default. This may be what - * is wanted, but for safety's sake it should not be the default behavior: - * programmers should have to make a deliberate choice to emit abbreviated - * images. Therefore the documentation and examples should encourage people - * to pass write_all_tables=TRUE; then it will take active thought to do the - * wrong thing. - */ - -GLOBAL(void) -jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (write_all_tables) - jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */ - - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Perform master selection of active modules */ - jinit_compress_master(cinfo); - /* Set up for the first pass */ - (*cinfo->master->prepare_for_pass) (cinfo); - /* Ready for application to drive first pass through jpeg_write_scanlines - * or jpeg_write_raw_data. - */ - cinfo->next_scanline = 0; - cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING); -} - - -/* - * Write some scanlines of data to the JPEG compressor. - * - * The return value will be the number of lines actually written. - * This should be less than the supplied num_lines only in case that - * the data destination module has requested suspension of the compressor, - * or if more than image_height scanlines are passed in. - * - * Note: we warn about excess calls to jpeg_write_scanlines() since - * this likely signals an application programmer error. However, - * excess scanlines passed in the last valid call are *silently* ignored, - * so that the application need not adjust num_lines for end-of-image - * when using a multiple-scanline buffer. - */ - -GLOBAL(JDIMENSION) -jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines, - JDIMENSION num_lines) -{ - JDIMENSION row_ctr, rows_left; - - if (cinfo->global_state != CSTATE_SCANNING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->next_scanline >= cinfo->image_height) - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->next_scanline; - cinfo->progress->pass_limit = (long) cinfo->image_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Give master control module another chance if this is first call to - * jpeg_write_scanlines. This lets output of the frame/scan headers be - * delayed so that application can write COM, etc, markers between - * jpeg_start_compress and jpeg_write_scanlines. - */ - if (cinfo->master->call_pass_startup) - (*cinfo->master->pass_startup) (cinfo); - - /* Ignore any extra scanlines at bottom of image. */ - rows_left = cinfo->image_height - cinfo->next_scanline; - if (num_lines > rows_left) - num_lines = rows_left; - - row_ctr = 0; - (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines); - cinfo->next_scanline += row_ctr; - return row_ctr; -} - - -/* - * Alternate entry point to write raw data. - * Processes exactly one iMCU row per call, unless suspended. - */ - -GLOBAL(JDIMENSION) -jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data, - JDIMENSION num_lines) -{ - JDIMENSION lines_per_iMCU_row; - - if (cinfo->global_state != CSTATE_RAW_OK) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->next_scanline >= cinfo->image_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->next_scanline; - cinfo->progress->pass_limit = (long) cinfo->image_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Give master control module another chance if this is first call to - * jpeg_write_raw_data. This lets output of the frame/scan headers be - * delayed so that application can write COM, etc, markers between - * jpeg_start_compress and jpeg_write_raw_data. - */ - if (cinfo->master->call_pass_startup) - (*cinfo->master->pass_startup) (cinfo); - - /* Verify that at least one iMCU row has been passed. */ - lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE; - if (num_lines < lines_per_iMCU_row) - ERREXIT(cinfo, JERR_BUFFER_SIZE); - - /* Directly compress the row. */ - if (! (*cinfo->coef->compress_data) (cinfo, data)) { - /* If compressor did not consume the whole row, suspend processing. */ - return 0; - } - - /* OK, we processed one iMCU row. */ - cinfo->next_scanline += lines_per_iMCU_row; - return lines_per_iMCU_row; -} +/* + * jcapistd.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the compression half + * of the JPEG library. These are the "standard" API routines that are + * used in the normal full-compression case. They are not used by a + * transcoding-only application. Note that if an application links in + * jpeg_start_compress, it will end up linking in the entire compressor. + * We thus must separate this file from jcapimin.c to avoid linking the + * whole compression library into a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Compression initialization. + * Before calling this, all parameters and a data destination must be set up. + * + * We require a write_all_tables parameter as a failsafe check when writing + * multiple datastreams from the same compression object. Since prior runs + * will have left all the tables marked sent_table=TRUE, a subsequent run + * would emit an abbreviated stream (no tables) by default. This may be what + * is wanted, but for safety's sake it should not be the default behavior: + * programmers should have to make a deliberate choice to emit abbreviated + * images. Therefore the documentation and examples should encourage people + * to pass write_all_tables=TRUE; then it will take active thought to do the + * wrong thing. + */ + +GLOBAL(void) +jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables) +{ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + if (write_all_tables) + jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */ + + /* (Re)initialize error mgr and destination modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->dest->init_destination) (cinfo); + /* Perform master selection of active modules */ + jinit_compress_master(cinfo); + /* Set up for the first pass */ + (*cinfo->master->prepare_for_pass) (cinfo); + /* Ready for application to drive first pass through jpeg_write_scanlines + * or jpeg_write_raw_data. + */ + cinfo->next_scanline = 0; + cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING); +} + + +/* + * Write some scanlines of data to the JPEG compressor. + * + * The return value will be the number of lines actually written. + * This should be less than the supplied num_lines only in case that + * the data destination module has requested suspension of the compressor, + * or if more than image_height scanlines are passed in. + * + * Note: we warn about excess calls to jpeg_write_scanlines() since + * this likely signals an application programmer error. However, + * excess scanlines passed in the last valid call are *silently* ignored, + * so that the application need not adjust num_lines for end-of-image + * when using a multiple-scanline buffer. + */ + +GLOBAL(JDIMENSION) +jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines, + JDIMENSION num_lines) +{ + JDIMENSION row_ctr, rows_left; + + if (cinfo->global_state != CSTATE_SCANNING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->next_scanline >= cinfo->image_height) + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->next_scanline; + cinfo->progress->pass_limit = (long) cinfo->image_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Give master control module another chance if this is first call to + * jpeg_write_scanlines. This lets output of the frame/scan headers be + * delayed so that application can write COM, etc, markers between + * jpeg_start_compress and jpeg_write_scanlines. + */ + if (cinfo->master->call_pass_startup) + (*cinfo->master->pass_startup) (cinfo); + + /* Ignore any extra scanlines at bottom of image. */ + rows_left = cinfo->image_height - cinfo->next_scanline; + if (num_lines > rows_left) + num_lines = rows_left; + + row_ctr = 0; + (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines); + cinfo->next_scanline += row_ctr; + return row_ctr; +} + + +/* + * Alternate entry point to write raw data. + * Processes exactly one iMCU row per call, unless suspended. + */ + +GLOBAL(JDIMENSION) +jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data, + JDIMENSION num_lines) +{ + JDIMENSION lines_per_iMCU_row; + + if (cinfo->global_state != CSTATE_RAW_OK) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->next_scanline >= cinfo->image_height) { + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + return 0; + } + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->next_scanline; + cinfo->progress->pass_limit = (long) cinfo->image_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Give master control module another chance if this is first call to + * jpeg_write_raw_data. This lets output of the frame/scan headers be + * delayed so that application can write COM, etc, markers between + * jpeg_start_compress and jpeg_write_raw_data. + */ + if (cinfo->master->call_pass_startup) + (*cinfo->master->pass_startup) (cinfo); + + /* Verify that at least one iMCU row has been passed. */ + lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE; + if (num_lines < lines_per_iMCU_row) + ERREXIT(cinfo, JERR_BUFFER_SIZE); + + /* Directly compress the row. */ + if (! (*cinfo->coef->compress_data) (cinfo, data)) { + /* If compressor did not consume the whole row, suspend processing. */ + return 0; + } + + /* OK, we processed one iMCU row. */ + cinfo->next_scanline += lines_per_iMCU_row; + return lines_per_iMCU_row; +} diff --git a/src/dep/src/irrlicht/jpeglib/jccoefct.c b/src/dep/src/irrlicht/jpeglib/jccoefct.c index c713b85..1963ddb 100644 --- a/src/dep/src/irrlicht/jpeglib/jccoefct.c +++ b/src/dep/src/irrlicht/jpeglib/jccoefct.c @@ -1,449 +1,449 @@ -/* - * jccoefct.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the coefficient buffer controller for compression. - * This controller is the top level of the JPEG compressor proper. - * The coefficient buffer lies between forward-DCT and entropy encoding steps. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* We use a full-image coefficient buffer when doing Huffman optimization, - * and also for writing multiple-scan JPEG files. In all cases, the DCT - * step is run during the first pass, and subsequent passes need only read - * the buffered coefficients. - */ -#ifdef ENTROPY_OPT_SUPPORTED -#define FULL_COEF_BUFFER_SUPPORTED -#else -#ifdef C_MULTISCAN_FILES_SUPPORTED -#define FULL_COEF_BUFFER_SUPPORTED -#endif -#endif - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_coef_controller pub; /* public fields */ - - JDIMENSION iMCU_row_num; /* iMCU row # within image */ - JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* For single-pass compression, it's sufficient to buffer just one MCU - * (although this may prove a bit slow in practice). We allocate a - * workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each - * MCU constructed and sent. (On 80x86, the workspace is FAR even though - * it's not really very big; this is to keep the module interfaces unchanged - * when a large coefficient buffer is necessary.) - * In multi-pass modes, this array points to the current MCU's blocks - * within the virtual arrays. - */ - JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; - - /* In multi-pass modes, we need a virtual block array for each component. */ - jvirt_barray_ptr whole_image[MAX_COMPONENTS]; -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - - -/* Forward declarations */ -METHODDEF(boolean) compress_data - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -#ifdef FULL_COEF_BUFFER_SUPPORTED -METHODDEF(boolean) compress_first_pass - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -METHODDEF(boolean) compress_output - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -#endif - - -LOCAL(void) -start_iMCU_row (j_compress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->mcu_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - coef->iMCU_row_num = 0; - start_iMCU_row(cinfo); - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (coef->whole_image[0] != NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_data; - break; -#ifdef FULL_COEF_BUFFER_SUPPORTED - case JBUF_SAVE_AND_PASS: - if (coef->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_first_pass; - break; - case JBUF_CRANK_DEST: - if (coef->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_output; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data in the single-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the image. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf contains a plane for each component in image, - * which we index according to the component's SOF position. - */ - -METHODDEF(boolean) -compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, bi, ci, yindex, yoffset, blockcnt; - JDIMENSION ypos, xpos; - jpeg_component_info *compptr; - - /* Loop to write as much as one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col; - MCU_col_num++) { - /* Determine where data comes from in input_buf and do the DCT thing. - * Each call on forward_DCT processes a horizontal row of DCT blocks - * as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks - * sequentially. Dummy blocks at the right or bottom edge are filled in - * specially. The data in them does not matter for image reconstruction, - * so we fill them with values that will encode to the smallest amount of - * data, viz: all zeroes in the AC entries, DC entries equal to previous - * block's DC value. (Thanks to Thomas Kinsman for this idea.) - */ - blkn = 0; - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - xpos = MCU_col_num * compptr->MCU_sample_width; - ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */ - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (coef->iMCU_row_num < last_iMCU_row || - yoffset+yindex < compptr->last_row_height) { - (*cinfo->fdct->forward_DCT) (cinfo, compptr, - input_buf[compptr->component_index], - coef->MCU_buffer[blkn], - ypos, xpos, (JDIMENSION) blockcnt); - if (blockcnt < compptr->MCU_width) { - /* Create some dummy blocks at the right edge of the image. */ - jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt], - (compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK)); - for (bi = blockcnt; bi < compptr->MCU_width; bi++) { - coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0]; - } - } - } else { - /* Create a row of dummy blocks at the bottom of the image. */ - jzero_far((void FAR *) coef->MCU_buffer[blkn], - compptr->MCU_width * SIZEOF(JBLOCK)); - for (bi = 0; bi < compptr->MCU_width; bi++) { - coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0]; - } - } - blkn += compptr->MCU_width; - ypos += DCTSIZE; - } - } - /* Try to write the MCU. In event of a suspension failure, we will - * re-DCT the MCU on restart (a bit inefficient, could be fixed...) - */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - - -#ifdef FULL_COEF_BUFFER_SUPPORTED - -/* - * Process some data in the first pass of a multi-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the image. - * This amount of data is read from the source buffer, DCT'd and quantized, - * and saved into the virtual arrays. We also generate suitable dummy blocks - * as needed at the right and lower edges. (The dummy blocks are constructed - * in the virtual arrays, which have been padded appropriately.) This makes - * it possible for subsequent passes not to worry about real vs. dummy blocks. - * - * We must also emit the data to the entropy encoder. This is conveniently - * done by calling compress_output() after we've loaded the current strip - * of the virtual arrays. - * - * NB: input_buf contains a plane for each component in image. All - * components are DCT'd and loaded into the virtual arrays in this pass. - * However, it may be that only a subset of the components are emitted to - * the entropy encoder during this first pass; be careful about looking - * at the scan-dependent variables (MCU dimensions, etc). - */ - -METHODDEF(boolean) -compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION blocks_across, MCUs_across, MCUindex; - int bi, ci, h_samp_factor, block_row, block_rows, ndummy; - JCOEF lastDC; - jpeg_component_info *compptr; - JBLOCKARRAY buffer; - JBLOCKROW thisblockrow, lastblockrow; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Align the virtual buffer for this component. */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, TRUE); - /* Count non-dummy DCT block rows in this iMCU row. */ - if (coef->iMCU_row_num < last_iMCU_row) - block_rows = compptr->v_samp_factor; - else { - /* NB: can't use last_row_height here, since may not be set! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - } - blocks_across = compptr->width_in_blocks; - h_samp_factor = compptr->h_samp_factor; - /* Count number of dummy blocks to be added at the right margin. */ - ndummy = (int) (blocks_across % h_samp_factor); - if (ndummy > 0) - ndummy = h_samp_factor - ndummy; - /* Perform DCT for all non-dummy blocks in this iMCU row. Each call - * on forward_DCT processes a complete horizontal row of DCT blocks. - */ - for (block_row = 0; block_row < block_rows; block_row++) { - thisblockrow = buffer[block_row]; - (*cinfo->fdct->forward_DCT) (cinfo, compptr, - input_buf[ci], thisblockrow, - (JDIMENSION) (block_row * DCTSIZE), - (JDIMENSION) 0, blocks_across); - if (ndummy > 0) { - /* Create dummy blocks at the right edge of the image. */ - thisblockrow += blocks_across; /* => first dummy block */ - jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK)); - lastDC = thisblockrow[-1][0]; - for (bi = 0; bi < ndummy; bi++) { - thisblockrow[bi][0] = lastDC; - } - } - } - /* If at end of image, create dummy block rows as needed. - * The tricky part here is that within each MCU, we want the DC values - * of the dummy blocks to match the last real block's DC value. - * This squeezes a few more bytes out of the resulting file... - */ - if (coef->iMCU_row_num == last_iMCU_row) { - blocks_across += ndummy; /* include lower right corner */ - MCUs_across = blocks_across / h_samp_factor; - for (block_row = block_rows; block_row < compptr->v_samp_factor; - block_row++) { - thisblockrow = buffer[block_row]; - lastblockrow = buffer[block_row-1]; - jzero_far((void FAR *) thisblockrow, - (size_t) (blocks_across * SIZEOF(JBLOCK))); - for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) { - lastDC = lastblockrow[h_samp_factor-1][0]; - for (bi = 0; bi < h_samp_factor; bi++) { - thisblockrow[bi][0] = lastDC; - } - thisblockrow += h_samp_factor; /* advance to next MCU in row */ - lastblockrow += h_samp_factor; - } - } - } - } - /* NB: compress_output will increment iMCU_row_num if successful. - * A suspension return will result in redoing all the work above next time. - */ - - /* Emit data to the entropy encoder, sharing code with subsequent passes */ - return compress_output(cinfo, input_buf); -} - - -/* - * Process some data in subsequent passes of a multi-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the scan. - * The data is obtained from the virtual arrays and fed to the entropy coder. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf is ignored; it is likely to be a NULL pointer. - */ - -METHODDEF(boolean) -compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - int blkn, ci, xindex, yindex, yoffset; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. - * NB: during first pass, this is safe only because the buffers will - * already be aligned properly, so jmemmgr.c won't need to do any I/O. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < compptr->MCU_width; xindex++) { - coef->MCU_buffer[blkn++] = buffer_ptr++; - } - } - } - /* Try to write the MCU. */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - -#endif /* FULL_COEF_BUFFER_SUPPORTED */ - - -/* - * Initialize coefficient buffer controller. - */ - -GLOBAL(void) -jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_coef_ptr coef; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_c_coef_controller *) coef; - coef->pub.start_pass = start_pass_coef; - - /* Create the coefficient buffer. */ - if (need_full_buffer) { -#ifdef FULL_COEF_BUFFER_SUPPORTED - /* Allocate a full-image virtual array for each component, */ - /* padded to a multiple of samp_factor DCT blocks in each direction. */ - int ci; - jpeg_component_info *compptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) compptr->v_samp_factor); - } -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - } else { - /* We only need a single-MCU buffer. */ - JBLOCKROW buffer; - int i; - - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { - coef->MCU_buffer[i] = buffer + i; - } - coef->whole_image[0] = NULL; /* flag for no virtual arrays */ - } -} +/* + * jccoefct.c + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the coefficient buffer controller for compression. + * This controller is the top level of the JPEG compressor proper. + * The coefficient buffer lies between forward-DCT and entropy encoding steps. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* We use a full-image coefficient buffer when doing Huffman optimization, + * and also for writing multiple-scan JPEG files. In all cases, the DCT + * step is run during the first pass, and subsequent passes need only read + * the buffered coefficients. + */ +#ifdef ENTROPY_OPT_SUPPORTED +#define FULL_COEF_BUFFER_SUPPORTED +#else +#ifdef C_MULTISCAN_FILES_SUPPORTED +#define FULL_COEF_BUFFER_SUPPORTED +#endif +#endif + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_coef_controller pub; /* public fields */ + + JDIMENSION iMCU_row_num; /* iMCU row # within image */ + JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ + int MCU_vert_offset; /* counts MCU rows within iMCU row */ + int MCU_rows_per_iMCU_row; /* number of such rows needed */ + + /* For single-pass compression, it's sufficient to buffer just one MCU + * (although this may prove a bit slow in practice). We allocate a + * workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each + * MCU constructed and sent. (On 80x86, the workspace is FAR even though + * it's not really very big; this is to keep the module interfaces unchanged + * when a large coefficient buffer is necessary.) + * In multi-pass modes, this array points to the current MCU's blocks + * within the virtual arrays. + */ + JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; + + /* In multi-pass modes, we need a virtual block array for each component. */ + jvirt_barray_ptr whole_image[MAX_COMPONENTS]; +} my_coef_controller; + +typedef my_coef_controller * my_coef_ptr; + + +/* Forward declarations */ +METHODDEF(boolean) compress_data + JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); +#ifdef FULL_COEF_BUFFER_SUPPORTED +METHODDEF(boolean) compress_first_pass + JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); +METHODDEF(boolean) compress_output + JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); +#endif + + +LOCAL(void) +start_iMCU_row (j_compress_ptr cinfo) +/* Reset within-iMCU-row counters for a new row */ +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* In an interleaved scan, an MCU row is the same as an iMCU row. + * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. + * But at the bottom of the image, process only what's left. + */ + if (cinfo->comps_in_scan > 1) { + coef->MCU_rows_per_iMCU_row = 1; + } else { + if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; + else + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; + } + + coef->mcu_ctr = 0; + coef->MCU_vert_offset = 0; +} + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + coef->iMCU_row_num = 0; + start_iMCU_row(cinfo); + + switch (pass_mode) { + case JBUF_PASS_THRU: + if (coef->whole_image[0] != NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + coef->pub.compress_data = compress_data; + break; +#ifdef FULL_COEF_BUFFER_SUPPORTED + case JBUF_SAVE_AND_PASS: + if (coef->whole_image[0] == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + coef->pub.compress_data = compress_first_pass; + break; + case JBUF_CRANK_DEST: + if (coef->whole_image[0] == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + coef->pub.compress_data = compress_output; + break; +#endif + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + break; + } +} + + +/* + * Process some data in the single-pass case. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the image. + * Returns TRUE if the iMCU row is completed, FALSE if suspended. + * + * NB: input_buf contains a plane for each component in image, + * which we index according to the component's SOF position. + */ + +METHODDEF(boolean) +compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + int blkn, bi, ci, yindex, yoffset, blockcnt; + JDIMENSION ypos, xpos; + jpeg_component_info *compptr; + + /* Loop to write as much as one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col; + MCU_col_num++) { + /* Determine where data comes from in input_buf and do the DCT thing. + * Each call on forward_DCT processes a horizontal row of DCT blocks + * as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks + * sequentially. Dummy blocks at the right or bottom edge are filled in + * specially. The data in them does not matter for image reconstruction, + * so we fill them with values that will encode to the smallest amount of + * data, viz: all zeroes in the AC entries, DC entries equal to previous + * block's DC value. (Thanks to Thomas Kinsman for this idea.) + */ + blkn = 0; + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width + : compptr->last_col_width; + xpos = MCU_col_num * compptr->MCU_sample_width; + ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */ + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + if (coef->iMCU_row_num < last_iMCU_row || + yoffset+yindex < compptr->last_row_height) { + (*cinfo->fdct->forward_DCT) (cinfo, compptr, + input_buf[compptr->component_index], + coef->MCU_buffer[blkn], + ypos, xpos, (JDIMENSION) blockcnt); + if (blockcnt < compptr->MCU_width) { + /* Create some dummy blocks at the right edge of the image. */ + jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt], + (compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK)); + for (bi = blockcnt; bi < compptr->MCU_width; bi++) { + coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0]; + } + } + } else { + /* Create a row of dummy blocks at the bottom of the image. */ + jzero_far((void FAR *) coef->MCU_buffer[blkn], + compptr->MCU_width * SIZEOF(JBLOCK)); + for (bi = 0; bi < compptr->MCU_width; bi++) { + coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0]; + } + } + blkn += compptr->MCU_width; + ypos += DCTSIZE; + } + } + /* Try to write the MCU. In event of a suspension failure, we will + * re-DCT the MCU on restart (a bit inefficient, could be fixed...) + */ + if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->mcu_ctr = MCU_col_num; + return FALSE; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->mcu_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + coef->iMCU_row_num++; + start_iMCU_row(cinfo); + return TRUE; +} + + +#ifdef FULL_COEF_BUFFER_SUPPORTED + +/* + * Process some data in the first pass of a multi-pass case. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the image. + * This amount of data is read from the source buffer, DCT'd and quantized, + * and saved into the virtual arrays. We also generate suitable dummy blocks + * as needed at the right and lower edges. (The dummy blocks are constructed + * in the virtual arrays, which have been padded appropriately.) This makes + * it possible for subsequent passes not to worry about real vs. dummy blocks. + * + * We must also emit the data to the entropy encoder. This is conveniently + * done by calling compress_output() after we've loaded the current strip + * of the virtual arrays. + * + * NB: input_buf contains a plane for each component in image. All + * components are DCT'd and loaded into the virtual arrays in this pass. + * However, it may be that only a subset of the components are emitted to + * the entropy encoder during this first pass; be careful about looking + * at the scan-dependent variables (MCU dimensions, etc). + */ + +METHODDEF(boolean) +compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + JDIMENSION blocks_across, MCUs_across, MCUindex; + int bi, ci, h_samp_factor, block_row, block_rows, ndummy; + JCOEF lastDC; + jpeg_component_info *compptr; + JBLOCKARRAY buffer; + JBLOCKROW thisblockrow, lastblockrow; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Align the virtual buffer for this component. */ + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + coef->iMCU_row_num * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, TRUE); + /* Count non-dummy DCT block rows in this iMCU row. */ + if (coef->iMCU_row_num < last_iMCU_row) + block_rows = compptr->v_samp_factor; + else { + /* NB: can't use last_row_height here, since may not be set! */ + block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (block_rows == 0) block_rows = compptr->v_samp_factor; + } + blocks_across = compptr->width_in_blocks; + h_samp_factor = compptr->h_samp_factor; + /* Count number of dummy blocks to be added at the right margin. */ + ndummy = (int) (blocks_across % h_samp_factor); + if (ndummy > 0) + ndummy = h_samp_factor - ndummy; + /* Perform DCT for all non-dummy blocks in this iMCU row. Each call + * on forward_DCT processes a complete horizontal row of DCT blocks. + */ + for (block_row = 0; block_row < block_rows; block_row++) { + thisblockrow = buffer[block_row]; + (*cinfo->fdct->forward_DCT) (cinfo, compptr, + input_buf[ci], thisblockrow, + (JDIMENSION) (block_row * DCTSIZE), + (JDIMENSION) 0, blocks_across); + if (ndummy > 0) { + /* Create dummy blocks at the right edge of the image. */ + thisblockrow += blocks_across; /* => first dummy block */ + jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK)); + lastDC = thisblockrow[-1][0]; + for (bi = 0; bi < ndummy; bi++) { + thisblockrow[bi][0] = lastDC; + } + } + } + /* If at end of image, create dummy block rows as needed. + * The tricky part here is that within each MCU, we want the DC values + * of the dummy blocks to match the last real block's DC value. + * This squeezes a few more bytes out of the resulting file... + */ + if (coef->iMCU_row_num == last_iMCU_row) { + blocks_across += ndummy; /* include lower right corner */ + MCUs_across = blocks_across / h_samp_factor; + for (block_row = block_rows; block_row < compptr->v_samp_factor; + block_row++) { + thisblockrow = buffer[block_row]; + lastblockrow = buffer[block_row-1]; + jzero_far((void FAR *) thisblockrow, + (size_t) (blocks_across * SIZEOF(JBLOCK))); + for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) { + lastDC = lastblockrow[h_samp_factor-1][0]; + for (bi = 0; bi < h_samp_factor; bi++) { + thisblockrow[bi][0] = lastDC; + } + thisblockrow += h_samp_factor; /* advance to next MCU in row */ + lastblockrow += h_samp_factor; + } + } + } + } + /* NB: compress_output will increment iMCU_row_num if successful. + * A suspension return will result in redoing all the work above next time. + */ + + /* Emit data to the entropy encoder, sharing code with subsequent passes */ + return compress_output(cinfo, input_buf); +} + + +/* + * Process some data in subsequent passes of a multi-pass case. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the scan. + * The data is obtained from the virtual arrays and fed to the entropy coder. + * Returns TRUE if the iMCU row is completed, FALSE if suspended. + * + * NB: input_buf is ignored; it is likely to be a NULL pointer. + */ + +METHODDEF(boolean) +compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + int blkn, ci, xindex, yindex, yoffset; + JDIMENSION start_col; + JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; + JBLOCKROW buffer_ptr; + jpeg_component_info *compptr; + + /* Align the virtual buffers for the components used in this scan. + * NB: during first pass, this is safe only because the buffers will + * already be aligned properly, so jmemmgr.c won't need to do any I/O. + */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + buffer[ci] = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], + coef->iMCU_row_num * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + + /* Loop to process one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; + MCU_col_num++) { + /* Construct list of pointers to DCT blocks belonging to this MCU */ + blkn = 0; /* index of current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + start_col = MCU_col_num * compptr->MCU_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + buffer_ptr = buffer[ci][yindex+yoffset] + start_col; + for (xindex = 0; xindex < compptr->MCU_width; xindex++) { + coef->MCU_buffer[blkn++] = buffer_ptr++; + } + } + } + /* Try to write the MCU. */ + if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->mcu_ctr = MCU_col_num; + return FALSE; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->mcu_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + coef->iMCU_row_num++; + start_iMCU_row(cinfo); + return TRUE; +} + +#endif /* FULL_COEF_BUFFER_SUPPORTED */ + + +/* + * Initialize coefficient buffer controller. + */ + +GLOBAL(void) +jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer) +{ + my_coef_ptr coef; + + coef = (my_coef_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_coef_controller)); + cinfo->coef = (struct jpeg_c_coef_controller *) coef; + coef->pub.start_pass = start_pass_coef; + + /* Create the coefficient buffer. */ + if (need_full_buffer) { +#ifdef FULL_COEF_BUFFER_SUPPORTED + /* Allocate a full-image virtual array for each component, */ + /* padded to a multiple of samp_factor DCT blocks in each direction. */ + int ci; + jpeg_component_info *compptr; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) jround_up((long) compptr->width_in_blocks, + (long) compptr->h_samp_factor), + (JDIMENSION) jround_up((long) compptr->height_in_blocks, + (long) compptr->v_samp_factor), + (JDIMENSION) compptr->v_samp_factor); + } +#else + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif + } else { + /* We only need a single-MCU buffer. */ + JBLOCKROW buffer; + int i; + + buffer = (JBLOCKROW) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); + for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { + coef->MCU_buffer[i] = buffer + i; + } + coef->whole_image[0] = NULL; /* flag for no virtual arrays */ + } +} diff --git a/src/dep/src/irrlicht/jpeglib/jccolor.c b/src/dep/src/irrlicht/jpeglib/jccolor.c index 2663724..0a8a4b5 100644 --- a/src/dep/src/irrlicht/jpeglib/jccolor.c +++ b/src/dep/src/irrlicht/jpeglib/jccolor.c @@ -1,459 +1,459 @@ -/* - * jccolor.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains input colorspace conversion routines. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private subobject */ - -typedef struct { - struct jpeg_color_converter pub; /* public fields */ - - /* Private state for RGB->YCC conversion */ - INT32 * rgb_ycc_tab; /* => table for RGB to YCbCr conversion */ -} my_color_converter; - -typedef my_color_converter * my_cconvert_ptr; - - -/**************** RGB -> YCbCr conversion: most common case **************/ - -/* - * YCbCr is defined per CCIR 601-1, except that Cb and Cr are - * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. - * The conversion equations to be implemented are therefore - * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B - * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE - * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE - * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) - * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2, - * rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and - * negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0) - * were not represented exactly. Now we sacrifice exact representation of - * maximum red and maximum blue in order to get exact grayscales. - * - * To avoid floating-point arithmetic, we represent the fractional constants - * as integers scaled up by 2^16 (about 4 digits precision); we have to divide - * the products by 2^16, with appropriate rounding, to get the correct answer. - * - * For even more speed, we avoid doing any multiplications in the inner loop - * by precalculating the constants times R,G,B for all possible values. - * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); - * for 12-bit samples it is still acceptable. It's not very reasonable for - * 16-bit samples, but if you want lossless storage you shouldn't be changing - * colorspace anyway. - * The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included - * in the tables to save adding them separately in the inner loop. - */ - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define CBCR_OFFSET ((INT32) CENTERJSAMPLE << SCALEBITS) -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L< Y section */ -#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */ -#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */ -#define R_CB_OFF (3*(MAXJSAMPLE+1)) -#define G_CB_OFF (4*(MAXJSAMPLE+1)) -#define B_CB_OFF (5*(MAXJSAMPLE+1)) -#define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */ -#define G_CR_OFF (6*(MAXJSAMPLE+1)) -#define B_CR_OFF (7*(MAXJSAMPLE+1)) -#define TABLE_SIZE (8*(MAXJSAMPLE+1)) - - -/* - * Initialize for RGB->YCC colorspace conversion. - */ - -METHODDEF(void) -rgb_ycc_start (j_compress_ptr cinfo) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - INT32 * rgb_ycc_tab; - INT32 i; - - /* Allocate and fill in the conversion tables. */ - cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (TABLE_SIZE * SIZEOF(INT32))); - - for (i = 0; i <= MAXJSAMPLE; i++) { - rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i; - rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i; - rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF; - rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i; - rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i; - /* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr. - * This ensures that the maximum output will round to MAXJSAMPLE - * not MAXJSAMPLE+1, and thus that we don't have to range-limit. - */ - rgb_ycc_tab[i+B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; -/* B=>Cb and R=>Cr tables are the same - rgb_ycc_tab[i+R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; -*/ - rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i; - rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i; - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * - * Note that we change from the application's interleaved-pixel format - * to our internal noninterleaved, one-plane-per-component format. - * The input buffer is therefore three times as wide as the output buffer. - * - * A starting row offset is provided only for the output buffer. The caller - * can easily adjust the passed input_buf value to accommodate any row - * offset required on that side. - */ - -METHODDEF(void) -rgb_ycc_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr0, outptr1, outptr2; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr0 = output_buf[0][output_row]; - outptr1 = output_buf[1][output_row]; - outptr2 = output_buf[2][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = GETJSAMPLE(inptr[RGB_RED]); - g = GETJSAMPLE(inptr[RGB_GREEN]); - b = GETJSAMPLE(inptr[RGB_BLUE]); - inptr += RGB_PIXELSIZE; - /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations - * must be too; we do not need an explicit range-limiting operation. - * Hence the value being shifted is never negative, and we don't - * need the general RIGHT_SHIFT macro. - */ - /* Y */ - outptr0[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - /* Cb */ - outptr1[col] = (JSAMPLE) - ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) - >> SCALEBITS); - /* Cr */ - outptr2[col] = (JSAMPLE) - ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) - >> SCALEBITS); - } - } -} - - -/**************** Cases other than RGB -> YCbCr **************/ - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles RGB->grayscale conversion, which is the same - * as the RGB->Y portion of RGB->YCbCr. - * We assume rgb_ycc_start has been called (we only use the Y tables). - */ - -METHODDEF(void) -rgb_gray_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr = output_buf[0][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = GETJSAMPLE(inptr[RGB_RED]); - g = GETJSAMPLE(inptr[RGB_GREEN]); - b = GETJSAMPLE(inptr[RGB_BLUE]); - inptr += RGB_PIXELSIZE; - /* Y */ - outptr[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles Adobe-style CMYK->YCCK conversion, - * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same - * conversion as above, while passing K (black) unchanged. - * We assume rgb_ycc_start has been called. - */ - -METHODDEF(void) -cmyk_ycck_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr0, outptr1, outptr2, outptr3; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr0 = output_buf[0][output_row]; - outptr1 = output_buf[1][output_row]; - outptr2 = output_buf[2][output_row]; - outptr3 = output_buf[3][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = MAXJSAMPLE - GETJSAMPLE(inptr[0]); - g = MAXJSAMPLE - GETJSAMPLE(inptr[1]); - b = MAXJSAMPLE - GETJSAMPLE(inptr[2]); - /* K passes through as-is */ - outptr3[col] = inptr[3]; /* don't need GETJSAMPLE here */ - inptr += 4; - /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations - * must be too; we do not need an explicit range-limiting operation. - * Hence the value being shifted is never negative, and we don't - * need the general RIGHT_SHIFT macro. - */ - /* Y */ - outptr0[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - /* Cb */ - outptr1[col] = (JSAMPLE) - ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) - >> SCALEBITS); - /* Cr */ - outptr2[col] = (JSAMPLE) - ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) - >> SCALEBITS); - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles grayscale output with no conversion. - * The source can be either plain grayscale or YCbCr (since Y == gray). - */ - -METHODDEF(void) -grayscale_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - int instride = cinfo->input_components; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr = output_buf[0][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - outptr[col] = inptr[0]; /* don't need GETJSAMPLE() here */ - inptr += instride; - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles multi-component colorspaces without conversion. - * We assume input_components == num_components. - */ - -METHODDEF(void) -null_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - register int ci; - int nc = cinfo->num_components; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - /* It seems fastest to make a separate pass for each component. */ - for (ci = 0; ci < nc; ci++) { - inptr = *input_buf; - outptr = output_buf[ci][output_row]; - for (col = 0; col < num_cols; col++) { - outptr[col] = inptr[ci]; /* don't need GETJSAMPLE() here */ - inptr += nc; - } - } - input_buf++; - output_row++; - } -} - - -/* - * Empty method for start_pass. - */ - -METHODDEF(void) -null_method (j_compress_ptr cinfo) -{ - /* no work needed */ -} - - -/* - * Module initialization routine for input colorspace conversion. - */ - -GLOBAL(void) -jinit_color_converter (j_compress_ptr cinfo) -{ - my_cconvert_ptr cconvert; - - cconvert = (my_cconvert_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_color_converter)); - cinfo->cconvert = (struct jpeg_color_converter *) cconvert; - /* set start_pass to null method until we find out differently */ - cconvert->pub.start_pass = null_method; - - /* Make sure input_components agrees with in_color_space */ - switch (cinfo->in_color_space) { - case JCS_GRAYSCALE: - if (cinfo->input_components != 1) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - case JCS_RGB: -#if RGB_PIXELSIZE != 3 - if (cinfo->input_components != RGB_PIXELSIZE) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; -#endif /* else share code with YCbCr */ - - case JCS_YCbCr: - if (cinfo->input_components != 3) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - case JCS_CMYK: - case JCS_YCCK: - if (cinfo->input_components != 4) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - default: /* JCS_UNKNOWN can be anything */ - if (cinfo->input_components < 1) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - } - - /* Check num_components, set conversion method based on requested space */ - switch (cinfo->jpeg_color_space) { - case JCS_GRAYSCALE: - if (cinfo->num_components != 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_GRAYSCALE) - cconvert->pub.color_convert = grayscale_convert; - else if (cinfo->in_color_space == JCS_RGB) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = rgb_gray_convert; - } else if (cinfo->in_color_space == JCS_YCbCr) - cconvert->pub.color_convert = grayscale_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_RGB: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_RGB && RGB_PIXELSIZE == 3) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_YCbCr: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_RGB) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = rgb_ycc_convert; - } else if (cinfo->in_color_space == JCS_YCbCr) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_CMYK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_CMYK) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_YCCK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_CMYK) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = cmyk_ycck_convert; - } else if (cinfo->in_color_space == JCS_YCCK) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - default: /* allow null conversion of JCS_UNKNOWN */ - if (cinfo->jpeg_color_space != cinfo->in_color_space || - cinfo->num_components != cinfo->input_components) - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - cconvert->pub.color_convert = null_convert; - break; - } -} +/* + * jccolor.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains input colorspace conversion routines. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private subobject */ + +typedef struct { + struct jpeg_color_converter pub; /* public fields */ + + /* Private state for RGB->YCC conversion */ + INT32 * rgb_ycc_tab; /* => table for RGB to YCbCr conversion */ +} my_color_converter; + +typedef my_color_converter * my_cconvert_ptr; + + +/**************** RGB -> YCbCr conversion: most common case **************/ + +/* + * YCbCr is defined per CCIR 601-1, except that Cb and Cr are + * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. + * The conversion equations to be implemented are therefore + * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B + * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE + * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE + * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) + * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2, + * rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and + * negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0) + * were not represented exactly. Now we sacrifice exact representation of + * maximum red and maximum blue in order to get exact grayscales. + * + * To avoid floating-point arithmetic, we represent the fractional constants + * as integers scaled up by 2^16 (about 4 digits precision); we have to divide + * the products by 2^16, with appropriate rounding, to get the correct answer. + * + * For even more speed, we avoid doing any multiplications in the inner loop + * by precalculating the constants times R,G,B for all possible values. + * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); + * for 12-bit samples it is still acceptable. It's not very reasonable for + * 16-bit samples, but if you want lossless storage you shouldn't be changing + * colorspace anyway. + * The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included + * in the tables to save adding them separately in the inner loop. + */ + +#define SCALEBITS 16 /* speediest right-shift on some machines */ +#define CBCR_OFFSET ((INT32) CENTERJSAMPLE << SCALEBITS) +#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) +#define FIX(x) ((INT32) ((x) * (1L< Y section */ +#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */ +#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */ +#define R_CB_OFF (3*(MAXJSAMPLE+1)) +#define G_CB_OFF (4*(MAXJSAMPLE+1)) +#define B_CB_OFF (5*(MAXJSAMPLE+1)) +#define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */ +#define G_CR_OFF (6*(MAXJSAMPLE+1)) +#define B_CR_OFF (7*(MAXJSAMPLE+1)) +#define TABLE_SIZE (8*(MAXJSAMPLE+1)) + + +/* + * Initialize for RGB->YCC colorspace conversion. + */ + +METHODDEF(void) +rgb_ycc_start (j_compress_ptr cinfo) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + INT32 * rgb_ycc_tab; + INT32 i; + + /* Allocate and fill in the conversion tables. */ + cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (TABLE_SIZE * SIZEOF(INT32))); + + for (i = 0; i <= MAXJSAMPLE; i++) { + rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i; + rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i; + rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF; + rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i; + rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i; + /* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr. + * This ensures that the maximum output will round to MAXJSAMPLE + * not MAXJSAMPLE+1, and thus that we don't have to range-limit. + */ + rgb_ycc_tab[i+B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; +/* B=>Cb and R=>Cr tables are the same + rgb_ycc_tab[i+R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; +*/ + rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i; + rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i; + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * + * Note that we change from the application's interleaved-pixel format + * to our internal noninterleaved, one-plane-per-component format. + * The input buffer is therefore three times as wide as the output buffer. + * + * A starting row offset is provided only for the output buffer. The caller + * can easily adjust the passed input_buf value to accommodate any row + * offset required on that side. + */ + +METHODDEF(void) +rgb_ycc_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_ycc_tab; + register JSAMPROW inptr; + register JSAMPROW outptr0, outptr1, outptr2; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr0 = output_buf[0][output_row]; + outptr1 = output_buf[1][output_row]; + outptr2 = output_buf[2][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + r = GETJSAMPLE(inptr[RGB_RED]); + g = GETJSAMPLE(inptr[RGB_GREEN]); + b = GETJSAMPLE(inptr[RGB_BLUE]); + inptr += RGB_PIXELSIZE; + /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations + * must be too; we do not need an explicit range-limiting operation. + * Hence the value being shifted is never negative, and we don't + * need the general RIGHT_SHIFT macro. + */ + /* Y */ + outptr0[col] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + /* Cb */ + outptr1[col] = (JSAMPLE) + ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) + >> SCALEBITS); + /* Cr */ + outptr2[col] = (JSAMPLE) + ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) + >> SCALEBITS); + } + } +} + + +/**************** Cases other than RGB -> YCbCr **************/ + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles RGB->grayscale conversion, which is the same + * as the RGB->Y portion of RGB->YCbCr. + * We assume rgb_ycc_start has been called (we only use the Y tables). + */ + +METHODDEF(void) +rgb_gray_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_ycc_tab; + register JSAMPROW inptr; + register JSAMPROW outptr; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr = output_buf[0][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + r = GETJSAMPLE(inptr[RGB_RED]); + g = GETJSAMPLE(inptr[RGB_GREEN]); + b = GETJSAMPLE(inptr[RGB_BLUE]); + inptr += RGB_PIXELSIZE; + /* Y */ + outptr[col] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + } + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles Adobe-style CMYK->YCCK conversion, + * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same + * conversion as above, while passing K (black) unchanged. + * We assume rgb_ycc_start has been called. + */ + +METHODDEF(void) +cmyk_ycck_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_ycc_tab; + register JSAMPROW inptr; + register JSAMPROW outptr0, outptr1, outptr2, outptr3; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr0 = output_buf[0][output_row]; + outptr1 = output_buf[1][output_row]; + outptr2 = output_buf[2][output_row]; + outptr3 = output_buf[3][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + r = MAXJSAMPLE - GETJSAMPLE(inptr[0]); + g = MAXJSAMPLE - GETJSAMPLE(inptr[1]); + b = MAXJSAMPLE - GETJSAMPLE(inptr[2]); + /* K passes through as-is */ + outptr3[col] = inptr[3]; /* don't need GETJSAMPLE here */ + inptr += 4; + /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations + * must be too; we do not need an explicit range-limiting operation. + * Hence the value being shifted is never negative, and we don't + * need the general RIGHT_SHIFT macro. + */ + /* Y */ + outptr0[col] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + /* Cb */ + outptr1[col] = (JSAMPLE) + ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) + >> SCALEBITS); + /* Cr */ + outptr2[col] = (JSAMPLE) + ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) + >> SCALEBITS); + } + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles grayscale output with no conversion. + * The source can be either plain grayscale or YCbCr (since Y == gray). + */ + +METHODDEF(void) +grayscale_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + register JSAMPROW inptr; + register JSAMPROW outptr; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + int instride = cinfo->input_components; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr = output_buf[0][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + outptr[col] = inptr[0]; /* don't need GETJSAMPLE() here */ + inptr += instride; + } + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles multi-component colorspaces without conversion. + * We assume input_components == num_components. + */ + +METHODDEF(void) +null_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + register JSAMPROW inptr; + register JSAMPROW outptr; + register JDIMENSION col; + register int ci; + int nc = cinfo->num_components; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + /* It seems fastest to make a separate pass for each component. */ + for (ci = 0; ci < nc; ci++) { + inptr = *input_buf; + outptr = output_buf[ci][output_row]; + for (col = 0; col < num_cols; col++) { + outptr[col] = inptr[ci]; /* don't need GETJSAMPLE() here */ + inptr += nc; + } + } + input_buf++; + output_row++; + } +} + + +/* + * Empty method for start_pass. + */ + +METHODDEF(void) +null_method (j_compress_ptr cinfo) +{ + /* no work needed */ +} + + +/* + * Module initialization routine for input colorspace conversion. + */ + +GLOBAL(void) +jinit_color_converter (j_compress_ptr cinfo) +{ + my_cconvert_ptr cconvert; + + cconvert = (my_cconvert_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_color_converter)); + cinfo->cconvert = (struct jpeg_color_converter *) cconvert; + /* set start_pass to null method until we find out differently */ + cconvert->pub.start_pass = null_method; + + /* Make sure input_components agrees with in_color_space */ + switch (cinfo->in_color_space) { + case JCS_GRAYSCALE: + if (cinfo->input_components != 1) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + + case JCS_RGB: +#if RGB_PIXELSIZE != 3 + if (cinfo->input_components != RGB_PIXELSIZE) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; +#endif /* else share code with YCbCr */ + + case JCS_YCbCr: + if (cinfo->input_components != 3) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + + case JCS_CMYK: + case JCS_YCCK: + if (cinfo->input_components != 4) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + + default: /* JCS_UNKNOWN can be anything */ + if (cinfo->input_components < 1) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + } + + /* Check num_components, set conversion method based on requested space */ + switch (cinfo->jpeg_color_space) { + case JCS_GRAYSCALE: + if (cinfo->num_components != 1) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_GRAYSCALE) + cconvert->pub.color_convert = grayscale_convert; + else if (cinfo->in_color_space == JCS_RGB) { + cconvert->pub.start_pass = rgb_ycc_start; + cconvert->pub.color_convert = rgb_gray_convert; + } else if (cinfo->in_color_space == JCS_YCbCr) + cconvert->pub.color_convert = grayscale_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_RGB: + if (cinfo->num_components != 3) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_RGB && RGB_PIXELSIZE == 3) + cconvert->pub.color_convert = null_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_YCbCr: + if (cinfo->num_components != 3) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_RGB) { + cconvert->pub.start_pass = rgb_ycc_start; + cconvert->pub.color_convert = rgb_ycc_convert; + } else if (cinfo->in_color_space == JCS_YCbCr) + cconvert->pub.color_convert = null_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_CMYK: + if (cinfo->num_components != 4) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_CMYK) + cconvert->pub.color_convert = null_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_YCCK: + if (cinfo->num_components != 4) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_CMYK) { + cconvert->pub.start_pass = rgb_ycc_start; + cconvert->pub.color_convert = cmyk_ycck_convert; + } else if (cinfo->in_color_space == JCS_YCCK) + cconvert->pub.color_convert = null_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + default: /* allow null conversion of JCS_UNKNOWN */ + if (cinfo->jpeg_color_space != cinfo->in_color_space || + cinfo->num_components != cinfo->input_components) + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + cconvert->pub.color_convert = null_convert; + break; + } +} diff --git a/src/dep/src/irrlicht/jpeglib/jcdctmgr.c b/src/dep/src/irrlicht/jpeglib/jcdctmgr.c index e3f90dc..61fa79b 100644 --- a/src/dep/src/irrlicht/jpeglib/jcdctmgr.c +++ b/src/dep/src/irrlicht/jpeglib/jcdctmgr.c @@ -1,387 +1,387 @@ -/* - * jcdctmgr.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the forward-DCT management logic. - * This code selects a particular DCT implementation to be used, - * and it performs related housekeeping chores including coefficient - * quantization. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - - -/* Private subobject for this module */ - -typedef struct { - struct jpeg_forward_dct pub; /* public fields */ - - /* Pointer to the DCT routine actually in use */ - forward_DCT_method_ptr do_dct; - - /* The actual post-DCT divisors --- not identical to the quant table - * entries, because of scaling (especially for an unnormalized DCT). - * Each table is given in normal array order. - */ - DCTELEM * divisors[NUM_QUANT_TBLS]; - -#ifdef DCT_FLOAT_SUPPORTED - /* Same as above for the floating-point case. */ - float_DCT_method_ptr do_float_dct; - FAST_FLOAT * float_divisors[NUM_QUANT_TBLS]; -#endif -} my_fdct_controller; - -typedef my_fdct_controller * my_fdct_ptr; - - -/* - * Initialize for a processing pass. - * Verify that all referenced Q-tables are present, and set up - * the divisor table for each one. - * In the current implementation, DCT of all components is done during - * the first pass, even if only some components will be output in the - * first scan. Hence all components should be examined here. - */ - -METHODDEF(void) -start_pass_fdctmgr (j_compress_ptr cinfo) -{ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - int ci, qtblno, i; - jpeg_component_info *compptr; - JQUANT_TBL * qtbl; - DCTELEM * dtbl; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - qtblno = compptr->quant_tbl_no; - /* Make sure specified quantization table is present */ - if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || - cinfo->quant_tbl_ptrs[qtblno] == NULL) - ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); - qtbl = cinfo->quant_tbl_ptrs[qtblno]; - /* Compute divisors for this quant table */ - /* We may do this more than once for same table, but it's not a big deal */ - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - /* For LL&M IDCT method, divisors are equal to raw quantization - * coefficients multiplied by 8 (to counteract scaling). - */ - if (fdct->divisors[qtblno] == NULL) { - fdct->divisors[qtblno] = (DCTELEM *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(DCTELEM)); - } - dtbl = fdct->divisors[qtblno]; - for (i = 0; i < DCTSIZE2; i++) { - dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3; - } - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - { - /* For AA&N IDCT method, divisors are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * We apply a further scale factor of 8. - */ -#define CONST_BITS 14 - static const INT16 aanscales[DCTSIZE2] = { - /* precomputed values scaled up by 14 bits */ - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, - 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, - 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, - 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, - 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 - }; - SHIFT_TEMPS - - if (fdct->divisors[qtblno] == NULL) { - fdct->divisors[qtblno] = (DCTELEM *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(DCTELEM)); - } - dtbl = fdct->divisors[qtblno]; - for (i = 0; i < DCTSIZE2; i++) { - dtbl[i] = (DCTELEM) - DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], - (INT32) aanscales[i]), - CONST_BITS-3); - } - } - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - { - /* For float AA&N IDCT method, divisors are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * We apply a further scale factor of 8. - * What's actually stored is 1/divisor so that the inner loop can - * use a multiplication rather than a division. - */ - FAST_FLOAT * fdtbl; - int row, col; - static const double aanscalefactor[DCTSIZE] = { - 1.0, 1.387039845, 1.306562965, 1.175875602, - 1.0, 0.785694958, 0.541196100, 0.275899379 - }; - - if (fdct->float_divisors[qtblno] == NULL) { - fdct->float_divisors[qtblno] = (FAST_FLOAT *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(FAST_FLOAT)); - } - fdtbl = fdct->float_divisors[qtblno]; - i = 0; - for (row = 0; row < DCTSIZE; row++) { - for (col = 0; col < DCTSIZE; col++) { - fdtbl[i] = (FAST_FLOAT) - (1.0 / (((double) qtbl->quantval[i] * - aanscalefactor[row] * aanscalefactor[col] * 8.0))); - i++; - } - } - } - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - } -} - - -/* - * Perform forward DCT on one or more blocks of a component. - * - * The input samples are taken from the sample_data[] array starting at - * position start_row/start_col, and moving to the right for any additional - * blocks. The quantized coefficients are returned in coef_blocks[]. - */ - -METHODDEF(void) -forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks) -/* This version is used for integer DCT implementations. */ -{ - /* This routine is heavily used, so it's worth coding it tightly. */ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - forward_DCT_method_ptr do_dct = fdct->do_dct; - DCTELEM * divisors = fdct->divisors[compptr->quant_tbl_no]; - DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */ - JDIMENSION bi; - - sample_data += start_row; /* fold in the vertical offset once */ - - for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { - /* Load data into workspace, applying unsigned->signed conversion */ - { register DCTELEM *workspaceptr; - register JSAMPROW elemptr; - register int elemr; - - workspaceptr = workspace; - for (elemr = 0; elemr < DCTSIZE; elemr++) { - elemptr = sample_data[elemr] + start_col; -#if DCTSIZE == 8 /* unroll the inner loop */ - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; -#else - { register int elemc; - for (elemc = DCTSIZE; elemc > 0; elemc--) { - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - } - } -#endif - } - } - - /* Perform the DCT */ - (*do_dct) (workspace); - - /* Quantize/descale the coefficients, and store into coef_blocks[] */ - { register DCTELEM temp, qval; - register int i; - register JCOEFPTR output_ptr = coef_blocks[bi]; - - for (i = 0; i < DCTSIZE2; i++) { - qval = divisors[i]; - temp = workspace[i]; - /* Divide the coefficient value by qval, ensuring proper rounding. - * Since C does not specify the direction of rounding for negative - * quotients, we have to force the dividend positive for portability. - * - * In most files, at least half of the output values will be zero - * (at default quantization settings, more like three-quarters...) - * so we should ensure that this case is fast. On many machines, - * a comparison is enough cheaper than a divide to make a special test - * a win. Since both inputs will be nonnegative, we need only test - * for a < b to discover whether a/b is 0. - * If your machine's division is fast enough, define FAST_DIVIDE. - */ -#ifdef FAST_DIVIDE -#define DIVIDE_BY(a,b) a /= b -#else -#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0 -#endif - if (temp < 0) { - temp = -temp; - temp += qval>>1; /* for rounding */ - DIVIDE_BY(temp, qval); - temp = -temp; - } else { - temp += qval>>1; /* for rounding */ - DIVIDE_BY(temp, qval); - } - output_ptr[i] = (JCOEF) temp; - } - } - } -} - - -#ifdef DCT_FLOAT_SUPPORTED - -METHODDEF(void) -forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks) -/* This version is used for floating-point DCT implementations. */ -{ - /* This routine is heavily used, so it's worth coding it tightly. */ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - float_DCT_method_ptr do_dct = fdct->do_float_dct; - FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no]; - FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */ - JDIMENSION bi; - - sample_data += start_row; /* fold in the vertical offset once */ - - for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { - /* Load data into workspace, applying unsigned->signed conversion */ - { register FAST_FLOAT *workspaceptr; - register JSAMPROW elemptr; - register int elemr; - - workspaceptr = workspace; - for (elemr = 0; elemr < DCTSIZE; elemr++) { - elemptr = sample_data[elemr] + start_col; -#if DCTSIZE == 8 /* unroll the inner loop */ - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); -#else - { register int elemc; - for (elemc = DCTSIZE; elemc > 0; elemc--) { - *workspaceptr++ = (FAST_FLOAT) - (GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - } - } -#endif - } - } - - /* Perform the DCT */ - (*do_dct) (workspace); - - /* Quantize/descale the coefficients, and store into coef_blocks[] */ - { register FAST_FLOAT temp; - register int i; - register JCOEFPTR output_ptr = coef_blocks[bi]; - - for (i = 0; i < DCTSIZE2; i++) { - /* Apply the quantization and scaling factor */ - temp = workspace[i] * divisors[i]; - /* Round to nearest integer. - * Since C does not specify the direction of rounding for negative - * quotients, we have to force the dividend positive for portability. - * The maximum coefficient size is +-16K (for 12-bit data), so this - * code should work for either 16-bit or 32-bit ints. - */ - output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384); - } - } - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ - - -/* - * Initialize FDCT manager. - */ - -GLOBAL(void) -jinit_forward_dct (j_compress_ptr cinfo) -{ - my_fdct_ptr fdct; - int i; - - fdct = (my_fdct_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_fdct_controller)); - cinfo->fdct = (struct jpeg_forward_dct *) fdct; - fdct->pub.start_pass = start_pass_fdctmgr; - - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - fdct->pub.forward_DCT = forward_DCT; - fdct->do_dct = jpeg_fdct_islow; - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - fdct->pub.forward_DCT = forward_DCT; - fdct->do_dct = jpeg_fdct_ifast; - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - fdct->pub.forward_DCT = forward_DCT_float; - fdct->do_float_dct = jpeg_fdct_float; - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - - /* Mark divisor tables unallocated */ - for (i = 0; i < NUM_QUANT_TBLS; i++) { - fdct->divisors[i] = NULL; -#ifdef DCT_FLOAT_SUPPORTED - fdct->float_divisors[i] = NULL; -#endif - } -} +/* + * jcdctmgr.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the forward-DCT management logic. + * This code selects a particular DCT implementation to be used, + * and it performs related housekeeping chores including coefficient + * quantization. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + + +/* Private subobject for this module */ + +typedef struct { + struct jpeg_forward_dct pub; /* public fields */ + + /* Pointer to the DCT routine actually in use */ + forward_DCT_method_ptr do_dct; + + /* The actual post-DCT divisors --- not identical to the quant table + * entries, because of scaling (especially for an unnormalized DCT). + * Each table is given in normal array order. + */ + DCTELEM * divisors[NUM_QUANT_TBLS]; + +#ifdef DCT_FLOAT_SUPPORTED + /* Same as above for the floating-point case. */ + float_DCT_method_ptr do_float_dct; + FAST_FLOAT * float_divisors[NUM_QUANT_TBLS]; +#endif +} my_fdct_controller; + +typedef my_fdct_controller * my_fdct_ptr; + + +/* + * Initialize for a processing pass. + * Verify that all referenced Q-tables are present, and set up + * the divisor table for each one. + * In the current implementation, DCT of all components is done during + * the first pass, even if only some components will be output in the + * first scan. Hence all components should be examined here. + */ + +METHODDEF(void) +start_pass_fdctmgr (j_compress_ptr cinfo) +{ + my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; + int ci, qtblno, i; + jpeg_component_info *compptr; + JQUANT_TBL * qtbl; + DCTELEM * dtbl; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + qtblno = compptr->quant_tbl_no; + /* Make sure specified quantization table is present */ + if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || + cinfo->quant_tbl_ptrs[qtblno] == NULL) + ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); + qtbl = cinfo->quant_tbl_ptrs[qtblno]; + /* Compute divisors for this quant table */ + /* We may do this more than once for same table, but it's not a big deal */ + switch (cinfo->dct_method) { +#ifdef DCT_ISLOW_SUPPORTED + case JDCT_ISLOW: + /* For LL&M IDCT method, divisors are equal to raw quantization + * coefficients multiplied by 8 (to counteract scaling). + */ + if (fdct->divisors[qtblno] == NULL) { + fdct->divisors[qtblno] = (DCTELEM *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + DCTSIZE2 * SIZEOF(DCTELEM)); + } + dtbl = fdct->divisors[qtblno]; + for (i = 0; i < DCTSIZE2; i++) { + dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3; + } + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + { + /* For AA&N IDCT method, divisors are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + * We apply a further scale factor of 8. + */ +#define CONST_BITS 14 + static const INT16 aanscales[DCTSIZE2] = { + /* precomputed values scaled up by 14 bits */ + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, + 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, + 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, + 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, + 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 + }; + SHIFT_TEMPS + + if (fdct->divisors[qtblno] == NULL) { + fdct->divisors[qtblno] = (DCTELEM *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + DCTSIZE2 * SIZEOF(DCTELEM)); + } + dtbl = fdct->divisors[qtblno]; + for (i = 0; i < DCTSIZE2; i++) { + dtbl[i] = (DCTELEM) + DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], + (INT32) aanscales[i]), + CONST_BITS-3); + } + } + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + { + /* For float AA&N IDCT method, divisors are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + * We apply a further scale factor of 8. + * What's actually stored is 1/divisor so that the inner loop can + * use a multiplication rather than a division. + */ + FAST_FLOAT * fdtbl; + int row, col; + static const double aanscalefactor[DCTSIZE] = { + 1.0, 1.387039845, 1.306562965, 1.175875602, + 1.0, 0.785694958, 0.541196100, 0.275899379 + }; + + if (fdct->float_divisors[qtblno] == NULL) { + fdct->float_divisors[qtblno] = (FAST_FLOAT *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + DCTSIZE2 * SIZEOF(FAST_FLOAT)); + } + fdtbl = fdct->float_divisors[qtblno]; + i = 0; + for (row = 0; row < DCTSIZE; row++) { + for (col = 0; col < DCTSIZE; col++) { + fdtbl[i] = (FAST_FLOAT) + (1.0 / (((double) qtbl->quantval[i] * + aanscalefactor[row] * aanscalefactor[col] * 8.0))); + i++; + } + } + } + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } + } +} + + +/* + * Perform forward DCT on one or more blocks of a component. + * + * The input samples are taken from the sample_data[] array starting at + * position start_row/start_col, and moving to the right for any additional + * blocks. The quantized coefficients are returned in coef_blocks[]. + */ + +METHODDEF(void) +forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY sample_data, JBLOCKROW coef_blocks, + JDIMENSION start_row, JDIMENSION start_col, + JDIMENSION num_blocks) +/* This version is used for integer DCT implementations. */ +{ + /* This routine is heavily used, so it's worth coding it tightly. */ + my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; + forward_DCT_method_ptr do_dct = fdct->do_dct; + DCTELEM * divisors = fdct->divisors[compptr->quant_tbl_no]; + DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */ + JDIMENSION bi; + + sample_data += start_row; /* fold in the vertical offset once */ + + for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { + /* Load data into workspace, applying unsigned->signed conversion */ + { register DCTELEM *workspaceptr; + register JSAMPROW elemptr; + register int elemr; + + workspaceptr = workspace; + for (elemr = 0; elemr < DCTSIZE; elemr++) { + elemptr = sample_data[elemr] + start_col; +#if DCTSIZE == 8 /* unroll the inner loop */ + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; +#else + { register int elemc; + for (elemc = DCTSIZE; elemc > 0; elemc--) { + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + } + } +#endif + } + } + + /* Perform the DCT */ + (*do_dct) (workspace); + + /* Quantize/descale the coefficients, and store into coef_blocks[] */ + { register DCTELEM temp, qval; + register int i; + register JCOEFPTR output_ptr = coef_blocks[bi]; + + for (i = 0; i < DCTSIZE2; i++) { + qval = divisors[i]; + temp = workspace[i]; + /* Divide the coefficient value by qval, ensuring proper rounding. + * Since C does not specify the direction of rounding for negative + * quotients, we have to force the dividend positive for portability. + * + * In most files, at least half of the output values will be zero + * (at default quantization settings, more like three-quarters...) + * so we should ensure that this case is fast. On many machines, + * a comparison is enough cheaper than a divide to make a special test + * a win. Since both inputs will be nonnegative, we need only test + * for a < b to discover whether a/b is 0. + * If your machine's division is fast enough, define FAST_DIVIDE. + */ +#ifdef FAST_DIVIDE +#define DIVIDE_BY(a,b) a /= b +#else +#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0 +#endif + if (temp < 0) { + temp = -temp; + temp += qval>>1; /* for rounding */ + DIVIDE_BY(temp, qval); + temp = -temp; + } else { + temp += qval>>1; /* for rounding */ + DIVIDE_BY(temp, qval); + } + output_ptr[i] = (JCOEF) temp; + } + } + } +} + + +#ifdef DCT_FLOAT_SUPPORTED + +METHODDEF(void) +forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY sample_data, JBLOCKROW coef_blocks, + JDIMENSION start_row, JDIMENSION start_col, + JDIMENSION num_blocks) +/* This version is used for floating-point DCT implementations. */ +{ + /* This routine is heavily used, so it's worth coding it tightly. */ + my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; + float_DCT_method_ptr do_dct = fdct->do_float_dct; + FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no]; + FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */ + JDIMENSION bi; + + sample_data += start_row; /* fold in the vertical offset once */ + + for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { + /* Load data into workspace, applying unsigned->signed conversion */ + { register FAST_FLOAT *workspaceptr; + register JSAMPROW elemptr; + register int elemr; + + workspaceptr = workspace; + for (elemr = 0; elemr < DCTSIZE; elemr++) { + elemptr = sample_data[elemr] + start_col; +#if DCTSIZE == 8 /* unroll the inner loop */ + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); +#else + { register int elemc; + for (elemc = DCTSIZE; elemc > 0; elemc--) { + *workspaceptr++ = (FAST_FLOAT) + (GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + } + } +#endif + } + } + + /* Perform the DCT */ + (*do_dct) (workspace); + + /* Quantize/descale the coefficients, and store into coef_blocks[] */ + { register FAST_FLOAT temp; + register int i; + register JCOEFPTR output_ptr = coef_blocks[bi]; + + for (i = 0; i < DCTSIZE2; i++) { + /* Apply the quantization and scaling factor */ + temp = workspace[i] * divisors[i]; + /* Round to nearest integer. + * Since C does not specify the direction of rounding for negative + * quotients, we have to force the dividend positive for portability. + * The maximum coefficient size is +-16K (for 12-bit data), so this + * code should work for either 16-bit or 32-bit ints. + */ + output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384); + } + } + } +} + +#endif /* DCT_FLOAT_SUPPORTED */ + + +/* + * Initialize FDCT manager. + */ + +GLOBAL(void) +jinit_forward_dct (j_compress_ptr cinfo) +{ + my_fdct_ptr fdct; + int i; + + fdct = (my_fdct_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_fdct_controller)); + cinfo->fdct = (struct jpeg_forward_dct *) fdct; + fdct->pub.start_pass = start_pass_fdctmgr; + + switch (cinfo->dct_method) { +#ifdef DCT_ISLOW_SUPPORTED + case JDCT_ISLOW: + fdct->pub.forward_DCT = forward_DCT; + fdct->do_dct = jpeg_fdct_islow; + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + fdct->pub.forward_DCT = forward_DCT; + fdct->do_dct = jpeg_fdct_ifast; + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + fdct->pub.forward_DCT = forward_DCT_float; + fdct->do_float_dct = jpeg_fdct_float; + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } + + /* Mark divisor tables unallocated */ + for (i = 0; i < NUM_QUANT_TBLS; i++) { + fdct->divisors[i] = NULL; +#ifdef DCT_FLOAT_SUPPORTED + fdct->float_divisors[i] = NULL; +#endif + } +} diff --git a/src/dep/src/irrlicht/jpeglib/jchuff.c b/src/dep/src/irrlicht/jpeglib/jchuff.c index 16d9366..f235250 100644 --- a/src/dep/src/irrlicht/jpeglib/jchuff.c +++ b/src/dep/src/irrlicht/jpeglib/jchuff.c @@ -1,909 +1,909 @@ -/* - * jchuff.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy encoding routines. - * - * Much of the complexity here has to do with supporting output suspension. - * If the data destination module demands suspension, we want to be able to - * back up to the start of the current MCU. To do this, we copy state - * variables into local working storage, and update them back to the - * permanent JPEG objects only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jchuff.h" /* Declarations shared with jcphuff.c */ - - -/* Expanded entropy encoder object for Huffman encoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - INT32 put_buffer; /* current bit-accumulation buffer */ - int put_bits; /* # of bits now in it */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).put_buffer = (src).put_buffer, \ - (dest).put_bits = (src).put_bits, \ - (dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_encoder pub; /* public fields */ - - savable_state saved; /* Bit buffer & DC state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - int next_restart_num; /* next restart number to write (0-7) */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; - c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; - -#ifdef ENTROPY_OPT_SUPPORTED /* Statistics tables for optimization */ - long * dc_count_ptrs[NUM_HUFF_TBLS]; - long * ac_count_ptrs[NUM_HUFF_TBLS]; -#endif -} huff_entropy_encoder; - -typedef huff_entropy_encoder * huff_entropy_ptr; - -/* Working state while writing an MCU. - * This struct contains all the fields that are needed by subroutines. - */ - -typedef struct { - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - savable_state cur; /* Current bit buffer & DC state */ - j_compress_ptr cinfo; /* dump_buffer needs access to this */ -} working_state; - - -/* Forward declarations */ -METHODDEF(boolean) encode_mcu_huff JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_huff JPP((j_compress_ptr cinfo)); -#ifdef ENTROPY_OPT_SUPPORTED -METHODDEF(boolean) encode_mcu_gather JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_gather JPP((j_compress_ptr cinfo)); -#endif - - -/* - * Initialize for a Huffman-compressed scan. - * If gather_statistics is TRUE, we do not output anything during the scan, - * just count the Huffman symbols used and generate Huffman code tables. - */ - -METHODDEF(void) -start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, dctbl, actbl; - jpeg_component_info * compptr; - - if (gather_statistics) { -#ifdef ENTROPY_OPT_SUPPORTED - entropy->pub.encode_mcu = encode_mcu_gather; - entropy->pub.finish_pass = finish_pass_gather; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - entropy->pub.encode_mcu = encode_mcu_huff; - entropy->pub.finish_pass = finish_pass_huff; - } - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - if (gather_statistics) { -#ifdef ENTROPY_OPT_SUPPORTED - /* Check for invalid table indexes */ - /* (make_c_derived_tbl does this in the other path) */ - if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl); - if (actbl < 0 || actbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl); - /* Allocate and zero the statistics tables */ - /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ - if (entropy->dc_count_ptrs[dctbl] == NULL) - entropy->dc_count_ptrs[dctbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * SIZEOF(long)); - if (entropy->ac_count_ptrs[actbl] == NULL) - entropy->ac_count_ptrs[actbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->ac_count_ptrs[actbl], 257 * SIZEOF(long)); -#endif - } else { - /* Compute derived values for Huffman tables */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_c_derived_tbl(cinfo, TRUE, dctbl, - & entropy->dc_derived_tbls[dctbl]); - jpeg_make_c_derived_tbl(cinfo, FALSE, actbl, - & entropy->ac_derived_tbls[actbl]); - } - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Initialize bit buffer to empty */ - entropy->saved.put_buffer = 0; - entropy->saved.put_bits = 0; - - /* Initialize restart stuff */ - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num = 0; -} - - -/* - * Compute the derived values for a Huffman table. - * This routine also performs some validation checks on the table. - * - * Note this is also used by jcphuff.c. - */ - -GLOBAL(void) -jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno, - c_derived_tbl ** pdtbl) -{ - JHUFF_TBL *htbl; - c_derived_tbl *dtbl; - int p, i, l, lastp, si, maxsymbol; - char huffsize[257]; - unsigned int huffcode[257]; - unsigned int code; - - /* Note that huffsize[] and huffcode[] are filled in code-length order, - * paralleling the order of the symbols themselves in htbl->huffval[]. - */ - - /* Find the input Huffman table */ - if (tblno < 0 || tblno >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - htbl = - isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - - /* Allocate a workspace if we haven't already done so. */ - if (*pdtbl == NULL) - *pdtbl = (c_derived_tbl *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(c_derived_tbl)); - dtbl = *pdtbl; - - /* Figure C.1: make table of Huffman code length for each symbol */ - - p = 0; - for (l = 1; l <= 16; l++) { - i = (int) htbl->bits[l]; - if (i < 0 || p + i > 256) /* protect against table overrun */ - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - while (i--) - huffsize[p++] = (char) l; - } - huffsize[p] = 0; - lastp = p; - - /* Figure C.2: generate the codes themselves */ - /* We also validate that the counts represent a legal Huffman code tree. */ - - code = 0; - si = huffsize[0]; - p = 0; - while (huffsize[p]) { - while (((int) huffsize[p]) == si) { - huffcode[p++] = code; - code++; - } - /* code is now 1 more than the last code used for codelength si; but - * it must still fit in si bits, since no code is allowed to be all ones. - */ - if (((INT32) code) >= (((INT32) 1) << si)) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - code <<= 1; - si++; - } - - /* Figure C.3: generate encoding tables */ - /* These are code and size indexed by symbol value */ - - /* Set all codeless symbols to have code length 0; - * this lets us detect duplicate VAL entries here, and later - * allows emit_bits to detect any attempt to emit such symbols. - */ - MEMZERO(dtbl->ehufsi, SIZEOF(dtbl->ehufsi)); - - /* This is also a convenient place to check for out-of-range - * and duplicated VAL entries. We allow 0..255 for AC symbols - * but only 0..15 for DC. (We could constrain them further - * based on data depth and mode, but this seems enough.) - */ - maxsymbol = isDC ? 15 : 255; - - for (p = 0; p < lastp; p++) { - i = htbl->huffval[p]; - if (i < 0 || i > maxsymbol || dtbl->ehufsi[i]) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - dtbl->ehufco[i] = huffcode[p]; - dtbl->ehufsi[i] = huffsize[p]; - } -} - - -/* Outputting bytes to the file */ - -/* Emit a byte, taking 'action' if must suspend. */ -#define emit_byte(state,val,action) \ - { *(state)->next_output_byte++ = (JOCTET) (val); \ - if (--(state)->free_in_buffer == 0) \ - if (! dump_buffer(state)) \ - { action; } } - - -LOCAL(boolean) -dump_buffer (working_state * state) -/* Empty the output buffer; return TRUE if successful, FALSE if must suspend */ -{ - struct jpeg_destination_mgr * dest = state->cinfo->dest; - - if (! (*dest->empty_output_buffer) (state->cinfo)) - return FALSE; - /* After a successful buffer dump, must reset buffer pointers */ - state->next_output_byte = dest->next_output_byte; - state->free_in_buffer = dest->free_in_buffer; - return TRUE; -} - - -/* Outputting bits to the file */ - -/* Only the right 24 bits of put_buffer are used; the valid bits are - * left-justified in this part. At most 16 bits can be passed to emit_bits - * in one call, and we never retain more than 7 bits in put_buffer - * between calls, so 24 bits are sufficient. - */ - -INLINE -LOCAL(boolean) -emit_bits (working_state * state, unsigned int code, int size) -/* Emit some bits; return TRUE if successful, FALSE if must suspend */ -{ - /* This routine is heavily used, so it's worth coding tightly. */ - register INT32 put_buffer = (INT32) code; - register int put_bits = state->cur.put_bits; - - /* if size is 0, caller used an invalid Huffman table entry */ - if (size == 0) - ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE); - - put_buffer &= (((INT32) 1)<cur.put_buffer; /* and merge with old buffer contents */ - - while (put_bits >= 8) { - int c = (int) ((put_buffer >> 16) & 0xFF); - - emit_byte(state, c, return FALSE); - if (c == 0xFF) { /* need to stuff a zero byte? */ - emit_byte(state, 0, return FALSE); - } - put_buffer <<= 8; - put_bits -= 8; - } - - state->cur.put_buffer = put_buffer; /* update state variables */ - state->cur.put_bits = put_bits; - - return TRUE; -} - - -LOCAL(boolean) -flush_bits (working_state * state) -{ - if (! emit_bits(state, 0x7F, 7)) /* fill any partial byte with ones */ - return FALSE; - state->cur.put_buffer = 0; /* and reset bit-buffer to empty */ - state->cur.put_bits = 0; - return TRUE; -} - - -/* Encode a single block's worth of coefficients */ - -LOCAL(boolean) -encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val, - c_derived_tbl *dctbl, c_derived_tbl *actbl) -{ - register int temp, temp2; - register int nbits; - register int k, r, i; - - /* Encode the DC coefficient difference per section F.1.2.1 */ - - temp = temp2 = block[0] - last_dc_val; - - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* For a negative input, want temp2 = bitwise complement of abs(input) */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); - - /* Emit the Huffman-coded symbol for the number of bits */ - if (! emit_bits(state, dctbl->ehufco[nbits], dctbl->ehufsi[nbits])) - return FALSE; - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (nbits) /* emit_bits rejects calls with size 0 */ - if (! emit_bits(state, (unsigned int) temp2, nbits)) - return FALSE; - - /* Encode the AC coefficients per section F.1.2.2 */ - - r = 0; /* r = run length of zeros */ - - for (k = 1; k < DCTSIZE2; k++) { - if ((temp = block[jpeg_natural_order[k]]) == 0) { - r++; - } else { - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - if (! emit_bits(state, actbl->ehufco[0xF0], actbl->ehufsi[0xF0])) - return FALSE; - r -= 16; - } - - temp2 = temp; - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); - - /* Emit Huffman symbol for run length / number of bits */ - i = (r << 4) + nbits; - if (! emit_bits(state, actbl->ehufco[i], actbl->ehufsi[i])) - return FALSE; - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (! emit_bits(state, (unsigned int) temp2, nbits)) - return FALSE; - - r = 0; - } - } - - /* If the last coef(s) were zero, emit an end-of-block code */ - if (r > 0) - if (! emit_bits(state, actbl->ehufco[0], actbl->ehufsi[0])) - return FALSE; - - return TRUE; -} - - -/* - * Emit a restart marker & resynchronize predictions. - */ - -LOCAL(boolean) -emit_restart (working_state * state, int restart_num) -{ - int ci; - - if (! flush_bits(state)) - return FALSE; - - emit_byte(state, 0xFF, return FALSE); - emit_byte(state, JPEG_RST0 + restart_num, return FALSE); - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < state->cinfo->comps_in_scan; ci++) - state->cur.last_dc_val[ci] = 0; - - /* The restart counter is not updated until we successfully write the MCU. */ - - return TRUE; -} - - -/* - * Encode and output one MCU's worth of Huffman-compressed coefficients. - */ - -METHODDEF(boolean) -encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - working_state state; - int blkn, ci; - jpeg_component_info * compptr; - - /* Load up working state */ - state.next_output_byte = cinfo->dest->next_output_byte; - state.free_in_buffer = cinfo->dest->free_in_buffer; - ASSIGN_STATE(state.cur, entropy->saved); - state.cinfo = cinfo; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! emit_restart(&state, entropy->next_restart_num)) - return FALSE; - } - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - if (! encode_one_block(&state, - MCU_data[blkn][0], state.cur.last_dc_val[ci], - entropy->dc_derived_tbls[compptr->dc_tbl_no], - entropy->ac_derived_tbls[compptr->ac_tbl_no])) - return FALSE; - /* Update last_dc_val */ - state.cur.last_dc_val[ci] = MCU_data[blkn][0][0]; - } - - /* Completed MCU, so update state */ - cinfo->dest->next_output_byte = state.next_output_byte; - cinfo->dest->free_in_buffer = state.free_in_buffer; - ASSIGN_STATE(entropy->saved, state.cur); - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * Finish up at the end of a Huffman-compressed scan. - */ - -METHODDEF(void) -finish_pass_huff (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - working_state state; - - /* Load up working state ... flush_bits needs it */ - state.next_output_byte = cinfo->dest->next_output_byte; - state.free_in_buffer = cinfo->dest->free_in_buffer; - ASSIGN_STATE(state.cur, entropy->saved); - state.cinfo = cinfo; - - /* Flush out the last data */ - if (! flush_bits(&state)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - - /* Update state */ - cinfo->dest->next_output_byte = state.next_output_byte; - cinfo->dest->free_in_buffer = state.free_in_buffer; - ASSIGN_STATE(entropy->saved, state.cur); -} - - -/* - * Huffman coding optimization. - * - * We first scan the supplied data and count the number of uses of each symbol - * that is to be Huffman-coded. (This process MUST agree with the code above.) - * Then we build a Huffman coding tree for the observed counts. - * Symbols which are not needed at all for the particular image are not - * assigned any code, which saves space in the DHT marker as well as in - * the compressed data. - */ - -#ifdef ENTROPY_OPT_SUPPORTED - - -/* Process a single block's worth of coefficients */ - -LOCAL(void) -htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val, - long dc_counts[], long ac_counts[]) -{ - register int temp; - register int nbits; - register int k, r; - - /* Encode the DC coefficient difference per section F.1.2.1 */ - - temp = block[0] - last_dc_val; - if (temp < 0) - temp = -temp; - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count the Huffman symbol for the number of bits */ - dc_counts[nbits]++; - - /* Encode the AC coefficients per section F.1.2.2 */ - - r = 0; /* r = run length of zeros */ - - for (k = 1; k < DCTSIZE2; k++) { - if ((temp = block[jpeg_natural_order[k]]) == 0) { - r++; - } else { - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - ac_counts[0xF0]++; - r -= 16; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - if (temp < 0) - temp = -temp; - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count Huffman symbol for run length / number of bits */ - ac_counts[(r << 4) + nbits]++; - - r = 0; - } - } - - /* If the last coef(s) were zero, emit an end-of-block code */ - if (r > 0) - ac_counts[0]++; -} - - -/* - * Trial-encode one MCU's worth of Huffman-compressed coefficients. - * No data is actually output, so no suspension return is possible. - */ - -METHODDEF(boolean) -encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int blkn, ci; - jpeg_component_info * compptr; - - /* Take care of restart intervals if needed */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - /* Update restart state */ - entropy->restarts_to_go = cinfo->restart_interval; - } - entropy->restarts_to_go--; - } - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - htest_one_block(cinfo, MCU_data[blkn][0], entropy->saved.last_dc_val[ci], - entropy->dc_count_ptrs[compptr->dc_tbl_no], - entropy->ac_count_ptrs[compptr->ac_tbl_no]); - entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0]; - } - - return TRUE; -} - - -/* - * Generate the best Huffman code table for the given counts, fill htbl. - * Note this is also used by jcphuff.c. - * - * The JPEG standard requires that no symbol be assigned a codeword of all - * one bits (so that padding bits added at the end of a compressed segment - * can't look like a valid code). Because of the canonical ordering of - * codewords, this just means that there must be an unused slot in the - * longest codeword length category. Section K.2 of the JPEG spec suggests - * reserving such a slot by pretending that symbol 256 is a valid symbol - * with count 1. In theory that's not optimal; giving it count zero but - * including it in the symbol set anyway should give a better Huffman code. - * But the theoretically better code actually seems to come out worse in - * practice, because it produces more all-ones bytes (which incur stuffed - * zero bytes in the final file). In any case the difference is tiny. - * - * The JPEG standard requires Huffman codes to be no more than 16 bits long. - * If some symbols have a very small but nonzero probability, the Huffman tree - * must be adjusted to meet the code length restriction. We currently use - * the adjustment method suggested in JPEG section K.2. This method is *not* - * optimal; it may not choose the best possible limited-length code. But - * typically only very-low-frequency symbols will be given less-than-optimal - * lengths, so the code is almost optimal. Experimental comparisons against - * an optimal limited-length-code algorithm indicate that the difference is - * microscopic --- usually less than a hundredth of a percent of total size. - * So the extra complexity of an optimal algorithm doesn't seem worthwhile. - */ - -GLOBAL(void) -jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[]) -{ -#define MAX_CLEN 32 /* assumed maximum initial code length */ - UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */ - int codesize[257]; /* codesize[k] = code length of symbol k */ - int others[257]; /* next symbol in current branch of tree */ - int c1, c2; - int p, i, j; - long v; - - /* This algorithm is explained in section K.2 of the JPEG standard */ - - MEMZERO(bits, SIZEOF(bits)); - MEMZERO(codesize, SIZEOF(codesize)); - for (i = 0; i < 257; i++) - others[i] = -1; /* init links to empty */ - - freq[256] = 1; /* make sure 256 has a nonzero count */ - /* Including the pseudo-symbol 256 in the Huffman procedure guarantees - * that no real symbol is given code-value of all ones, because 256 - * will be placed last in the largest codeword category. - */ - - /* Huffman's basic algorithm to assign optimal code lengths to symbols */ - - for (;;) { - /* Find the smallest nonzero frequency, set c1 = its symbol */ - /* In case of ties, take the larger symbol number */ - c1 = -1; - v = 1000000000L; - for (i = 0; i <= 256; i++) { - if (freq[i] && freq[i] <= v) { - v = freq[i]; - c1 = i; - } - } - - /* Find the next smallest nonzero frequency, set c2 = its symbol */ - /* In case of ties, take the larger symbol number */ - c2 = -1; - v = 1000000000L; - for (i = 0; i <= 256; i++) { - if (freq[i] && freq[i] <= v && i != c1) { - v = freq[i]; - c2 = i; - } - } - - /* Done if we've merged everything into one frequency */ - if (c2 < 0) - break; - - /* Else merge the two counts/trees */ - freq[c1] += freq[c2]; - freq[c2] = 0; - - /* Increment the codesize of everything in c1's tree branch */ - codesize[c1]++; - while (others[c1] >= 0) { - c1 = others[c1]; - codesize[c1]++; - } - - others[c1] = c2; /* chain c2 onto c1's tree branch */ - - /* Increment the codesize of everything in c2's tree branch */ - codesize[c2]++; - while (others[c2] >= 0) { - c2 = others[c2]; - codesize[c2]++; - } - } - - /* Now count the number of symbols of each code length */ - for (i = 0; i <= 256; i++) { - if (codesize[i]) { - /* The JPEG standard seems to think that this can't happen, */ - /* but I'm paranoid... */ - if (codesize[i] > MAX_CLEN) - ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW); - - bits[codesize[i]]++; - } - } - - /* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure - * Huffman procedure assigned any such lengths, we must adjust the coding. - * Here is what the JPEG spec says about how this next bit works: - * Since symbols are paired for the longest Huffman code, the symbols are - * removed from this length category two at a time. The prefix for the pair - * (which is one bit shorter) is allocated to one of the pair; then, - * skipping the BITS entry for that prefix length, a code word from the next - * shortest nonzero BITS entry is converted into a prefix for two code words - * one bit longer. - */ - - for (i = MAX_CLEN; i > 16; i--) { - while (bits[i] > 0) { - j = i - 2; /* find length of new prefix to be used */ - while (bits[j] == 0) - j--; - - bits[i] -= 2; /* remove two symbols */ - bits[i-1]++; /* one goes in this length */ - bits[j+1] += 2; /* two new symbols in this length */ - bits[j]--; /* symbol of this length is now a prefix */ - } - } - - /* Remove the count for the pseudo-symbol 256 from the largest codelength */ - while (bits[i] == 0) /* find largest codelength still in use */ - i--; - bits[i]--; - - /* Return final symbol counts (only for lengths 0..16) */ - MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits)); - - /* Return a list of the symbols sorted by code length */ - /* It's not real clear to me why we don't need to consider the codelength - * changes made above, but the JPEG spec seems to think this works. - */ - p = 0; - for (i = 1; i <= MAX_CLEN; i++) { - for (j = 0; j <= 255; j++) { - if (codesize[j] == i) { - htbl->huffval[p] = (UINT8) j; - p++; - } - } - } - - /* Set sent_table FALSE so updated table will be written to JPEG file. */ - htbl->sent_table = FALSE; -} - - -/* - * Finish up a statistics-gathering pass and create the new Huffman tables. - */ - -METHODDEF(void) -finish_pass_gather (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, dctbl, actbl; - jpeg_component_info * compptr; - JHUFF_TBL **htblptr; - boolean did_dc[NUM_HUFF_TBLS]; - boolean did_ac[NUM_HUFF_TBLS]; - - /* It's important not to apply jpeg_gen_optimal_table more than once - * per table, because it clobbers the input frequency counts! - */ - MEMZERO(did_dc, SIZEOF(did_dc)); - MEMZERO(did_ac, SIZEOF(did_ac)); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - if (! did_dc[dctbl]) { - htblptr = & cinfo->dc_huff_tbl_ptrs[dctbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[dctbl]); - did_dc[dctbl] = TRUE; - } - if (! did_ac[actbl]) { - htblptr = & cinfo->ac_huff_tbl_ptrs[actbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[actbl]); - did_ac[actbl] = TRUE; - } - } -} - - -#endif /* ENTROPY_OPT_SUPPORTED */ - - -/* - * Module initialization routine for Huffman entropy encoding. - */ - -GLOBAL(void) -jinit_huff_encoder (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy; - int i; - - entropy = (huff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(huff_entropy_encoder)); - cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; - entropy->pub.start_pass = start_pass_huff; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; -#ifdef ENTROPY_OPT_SUPPORTED - entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL; -#endif - } -} +/* + * jchuff.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains Huffman entropy encoding routines. + * + * Much of the complexity here has to do with supporting output suspension. + * If the data destination module demands suspension, we want to be able to + * back up to the start of the current MCU. To do this, we copy state + * variables into local working storage, and update them back to the + * permanent JPEG objects only upon successful completion of an MCU. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jchuff.h" /* Declarations shared with jcphuff.c */ + + +/* Expanded entropy encoder object for Huffman encoding. + * + * The savable_state subrecord contains fields that change within an MCU, + * but must not be updated permanently until we complete the MCU. + */ + +typedef struct { + INT32 put_buffer; /* current bit-accumulation buffer */ + int put_bits; /* # of bits now in it */ + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ +} savable_state; + +/* This macro is to work around compilers with missing or broken + * structure assignment. You'll need to fix this code if you have + * such a compiler and you change MAX_COMPS_IN_SCAN. + */ + +#ifndef NO_STRUCT_ASSIGN +#define ASSIGN_STATE(dest,src) ((dest) = (src)) +#else +#if MAX_COMPS_IN_SCAN == 4 +#define ASSIGN_STATE(dest,src) \ + ((dest).put_buffer = (src).put_buffer, \ + (dest).put_bits = (src).put_bits, \ + (dest).last_dc_val[0] = (src).last_dc_val[0], \ + (dest).last_dc_val[1] = (src).last_dc_val[1], \ + (dest).last_dc_val[2] = (src).last_dc_val[2], \ + (dest).last_dc_val[3] = (src).last_dc_val[3]) +#endif +#endif + + +typedef struct { + struct jpeg_entropy_encoder pub; /* public fields */ + + savable_state saved; /* Bit buffer & DC state at start of MCU */ + + /* These fields are NOT loaded into local working state. */ + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + int next_restart_num; /* next restart number to write (0-7) */ + + /* Pointers to derived tables (these workspaces have image lifespan) */ + c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; + c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; + +#ifdef ENTROPY_OPT_SUPPORTED /* Statistics tables for optimization */ + long * dc_count_ptrs[NUM_HUFF_TBLS]; + long * ac_count_ptrs[NUM_HUFF_TBLS]; +#endif +} huff_entropy_encoder; + +typedef huff_entropy_encoder * huff_entropy_ptr; + +/* Working state while writing an MCU. + * This struct contains all the fields that are needed by subroutines. + */ + +typedef struct { + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + savable_state cur; /* Current bit buffer & DC state */ + j_compress_ptr cinfo; /* dump_buffer needs access to this */ +} working_state; + + +/* Forward declarations */ +METHODDEF(boolean) encode_mcu_huff JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(void) finish_pass_huff JPP((j_compress_ptr cinfo)); +#ifdef ENTROPY_OPT_SUPPORTED +METHODDEF(boolean) encode_mcu_gather JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(void) finish_pass_gather JPP((j_compress_ptr cinfo)); +#endif + + +/* + * Initialize for a Huffman-compressed scan. + * If gather_statistics is TRUE, we do not output anything during the scan, + * just count the Huffman symbols used and generate Huffman code tables. + */ + +METHODDEF(void) +start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci, dctbl, actbl; + jpeg_component_info * compptr; + + if (gather_statistics) { +#ifdef ENTROPY_OPT_SUPPORTED + entropy->pub.encode_mcu = encode_mcu_gather; + entropy->pub.finish_pass = finish_pass_gather; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + entropy->pub.encode_mcu = encode_mcu_huff; + entropy->pub.finish_pass = finish_pass_huff; + } + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + dctbl = compptr->dc_tbl_no; + actbl = compptr->ac_tbl_no; + if (gather_statistics) { +#ifdef ENTROPY_OPT_SUPPORTED + /* Check for invalid table indexes */ + /* (make_c_derived_tbl does this in the other path) */ + if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl); + if (actbl < 0 || actbl >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl); + /* Allocate and zero the statistics tables */ + /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ + if (entropy->dc_count_ptrs[dctbl] == NULL) + entropy->dc_count_ptrs[dctbl] = (long *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + 257 * SIZEOF(long)); + MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * SIZEOF(long)); + if (entropy->ac_count_ptrs[actbl] == NULL) + entropy->ac_count_ptrs[actbl] = (long *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + 257 * SIZEOF(long)); + MEMZERO(entropy->ac_count_ptrs[actbl], 257 * SIZEOF(long)); +#endif + } else { + /* Compute derived values for Huffman tables */ + /* We may do this more than once for a table, but it's not expensive */ + jpeg_make_c_derived_tbl(cinfo, TRUE, dctbl, + & entropy->dc_derived_tbls[dctbl]); + jpeg_make_c_derived_tbl(cinfo, FALSE, actbl, + & entropy->ac_derived_tbls[actbl]); + } + /* Initialize DC predictions to 0 */ + entropy->saved.last_dc_val[ci] = 0; + } + + /* Initialize bit buffer to empty */ + entropy->saved.put_buffer = 0; + entropy->saved.put_bits = 0; + + /* Initialize restart stuff */ + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num = 0; +} + + +/* + * Compute the derived values for a Huffman table. + * This routine also performs some validation checks on the table. + * + * Note this is also used by jcphuff.c. + */ + +GLOBAL(void) +jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno, + c_derived_tbl ** pdtbl) +{ + JHUFF_TBL *htbl; + c_derived_tbl *dtbl; + int p, i, l, lastp, si, maxsymbol; + char huffsize[257]; + unsigned int huffcode[257]; + unsigned int code; + + /* Note that huffsize[] and huffcode[] are filled in code-length order, + * paralleling the order of the symbols themselves in htbl->huffval[]. + */ + + /* Find the input Huffman table */ + if (tblno < 0 || tblno >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); + htbl = + isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; + if (htbl == NULL) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); + + /* Allocate a workspace if we haven't already done so. */ + if (*pdtbl == NULL) + *pdtbl = (c_derived_tbl *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(c_derived_tbl)); + dtbl = *pdtbl; + + /* Figure C.1: make table of Huffman code length for each symbol */ + + p = 0; + for (l = 1; l <= 16; l++) { + i = (int) htbl->bits[l]; + if (i < 0 || p + i > 256) /* protect against table overrun */ + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + while (i--) + huffsize[p++] = (char) l; + } + huffsize[p] = 0; + lastp = p; + + /* Figure C.2: generate the codes themselves */ + /* We also validate that the counts represent a legal Huffman code tree. */ + + code = 0; + si = huffsize[0]; + p = 0; + while (huffsize[p]) { + while (((int) huffsize[p]) == si) { + huffcode[p++] = code; + code++; + } + /* code is now 1 more than the last code used for codelength si; but + * it must still fit in si bits, since no code is allowed to be all ones. + */ + if (((INT32) code) >= (((INT32) 1) << si)) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + code <<= 1; + si++; + } + + /* Figure C.3: generate encoding tables */ + /* These are code and size indexed by symbol value */ + + /* Set all codeless symbols to have code length 0; + * this lets us detect duplicate VAL entries here, and later + * allows emit_bits to detect any attempt to emit such symbols. + */ + MEMZERO(dtbl->ehufsi, SIZEOF(dtbl->ehufsi)); + + /* This is also a convenient place to check for out-of-range + * and duplicated VAL entries. We allow 0..255 for AC symbols + * but only 0..15 for DC. (We could constrain them further + * based on data depth and mode, but this seems enough.) + */ + maxsymbol = isDC ? 15 : 255; + + for (p = 0; p < lastp; p++) { + i = htbl->huffval[p]; + if (i < 0 || i > maxsymbol || dtbl->ehufsi[i]) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + dtbl->ehufco[i] = huffcode[p]; + dtbl->ehufsi[i] = huffsize[p]; + } +} + + +/* Outputting bytes to the file */ + +/* Emit a byte, taking 'action' if must suspend. */ +#define emit_byte(state,val,action) \ + { *(state)->next_output_byte++ = (JOCTET) (val); \ + if (--(state)->free_in_buffer == 0) \ + if (! dump_buffer(state)) \ + { action; } } + + +LOCAL(boolean) +dump_buffer (working_state * state) +/* Empty the output buffer; return TRUE if successful, FALSE if must suspend */ +{ + struct jpeg_destination_mgr * dest = state->cinfo->dest; + + if (! (*dest->empty_output_buffer) (state->cinfo)) + return FALSE; + /* After a successful buffer dump, must reset buffer pointers */ + state->next_output_byte = dest->next_output_byte; + state->free_in_buffer = dest->free_in_buffer; + return TRUE; +} + + +/* Outputting bits to the file */ + +/* Only the right 24 bits of put_buffer are used; the valid bits are + * left-justified in this part. At most 16 bits can be passed to emit_bits + * in one call, and we never retain more than 7 bits in put_buffer + * between calls, so 24 bits are sufficient. + */ + +INLINE +LOCAL(boolean) +emit_bits (working_state * state, unsigned int code, int size) +/* Emit some bits; return TRUE if successful, FALSE if must suspend */ +{ + /* This routine is heavily used, so it's worth coding tightly. */ + register INT32 put_buffer = (INT32) code; + register int put_bits = state->cur.put_bits; + + /* if size is 0, caller used an invalid Huffman table entry */ + if (size == 0) + ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE); + + put_buffer &= (((INT32) 1)<cur.put_buffer; /* and merge with old buffer contents */ + + while (put_bits >= 8) { + int c = (int) ((put_buffer >> 16) & 0xFF); + + emit_byte(state, c, return FALSE); + if (c == 0xFF) { /* need to stuff a zero byte? */ + emit_byte(state, 0, return FALSE); + } + put_buffer <<= 8; + put_bits -= 8; + } + + state->cur.put_buffer = put_buffer; /* update state variables */ + state->cur.put_bits = put_bits; + + return TRUE; +} + + +LOCAL(boolean) +flush_bits (working_state * state) +{ + if (! emit_bits(state, 0x7F, 7)) /* fill any partial byte with ones */ + return FALSE; + state->cur.put_buffer = 0; /* and reset bit-buffer to empty */ + state->cur.put_bits = 0; + return TRUE; +} + + +/* Encode a single block's worth of coefficients */ + +LOCAL(boolean) +encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val, + c_derived_tbl *dctbl, c_derived_tbl *actbl) +{ + register int temp, temp2; + register int nbits; + register int k, r, i; + + /* Encode the DC coefficient difference per section F.1.2.1 */ + + temp = temp2 = block[0] - last_dc_val; + + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + /* For a negative input, want temp2 = bitwise complement of abs(input) */ + /* This code assumes we are on a two's complement machine */ + temp2--; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 0; + while (temp) { + nbits++; + temp >>= 1; + } + /* Check for out-of-range coefficient values. + * Since we're encoding a difference, the range limit is twice as much. + */ + if (nbits > MAX_COEF_BITS+1) + ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); + + /* Emit the Huffman-coded symbol for the number of bits */ + if (! emit_bits(state, dctbl->ehufco[nbits], dctbl->ehufsi[nbits])) + return FALSE; + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + if (nbits) /* emit_bits rejects calls with size 0 */ + if (! emit_bits(state, (unsigned int) temp2, nbits)) + return FALSE; + + /* Encode the AC coefficients per section F.1.2.2 */ + + r = 0; /* r = run length of zeros */ + + for (k = 1; k < DCTSIZE2; k++) { + if ((temp = block[jpeg_natural_order[k]]) == 0) { + r++; + } else { + /* if run length > 15, must emit special run-length-16 codes (0xF0) */ + while (r > 15) { + if (! emit_bits(state, actbl->ehufco[0xF0], actbl->ehufsi[0xF0])) + return FALSE; + r -= 16; + } + + temp2 = temp; + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + /* This code assumes we are on a two's complement machine */ + temp2--; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 1; /* there must be at least one 1 bit */ + while ((temp >>= 1)) + nbits++; + /* Check for out-of-range coefficient values */ + if (nbits > MAX_COEF_BITS) + ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); + + /* Emit Huffman symbol for run length / number of bits */ + i = (r << 4) + nbits; + if (! emit_bits(state, actbl->ehufco[i], actbl->ehufsi[i])) + return FALSE; + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + if (! emit_bits(state, (unsigned int) temp2, nbits)) + return FALSE; + + r = 0; + } + } + + /* If the last coef(s) were zero, emit an end-of-block code */ + if (r > 0) + if (! emit_bits(state, actbl->ehufco[0], actbl->ehufsi[0])) + return FALSE; + + return TRUE; +} + + +/* + * Emit a restart marker & resynchronize predictions. + */ + +LOCAL(boolean) +emit_restart (working_state * state, int restart_num) +{ + int ci; + + if (! flush_bits(state)) + return FALSE; + + emit_byte(state, 0xFF, return FALSE); + emit_byte(state, JPEG_RST0 + restart_num, return FALSE); + + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < state->cinfo->comps_in_scan; ci++) + state->cur.last_dc_val[ci] = 0; + + /* The restart counter is not updated until we successfully write the MCU. */ + + return TRUE; +} + + +/* + * Encode and output one MCU's worth of Huffman-compressed coefficients. + */ + +METHODDEF(boolean) +encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + working_state state; + int blkn, ci; + jpeg_component_info * compptr; + + /* Load up working state */ + state.next_output_byte = cinfo->dest->next_output_byte; + state.free_in_buffer = cinfo->dest->free_in_buffer; + ASSIGN_STATE(state.cur, entropy->saved); + state.cinfo = cinfo; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! emit_restart(&state, entropy->next_restart_num)) + return FALSE; + } + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + if (! encode_one_block(&state, + MCU_data[blkn][0], state.cur.last_dc_val[ci], + entropy->dc_derived_tbls[compptr->dc_tbl_no], + entropy->ac_derived_tbls[compptr->ac_tbl_no])) + return FALSE; + /* Update last_dc_val */ + state.cur.last_dc_val[ci] = MCU_data[blkn][0][0]; + } + + /* Completed MCU, so update state */ + cinfo->dest->next_output_byte = state.next_output_byte; + cinfo->dest->free_in_buffer = state.free_in_buffer; + ASSIGN_STATE(entropy->saved, state.cur); + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * Finish up at the end of a Huffman-compressed scan. + */ + +METHODDEF(void) +finish_pass_huff (j_compress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + working_state state; + + /* Load up working state ... flush_bits needs it */ + state.next_output_byte = cinfo->dest->next_output_byte; + state.free_in_buffer = cinfo->dest->free_in_buffer; + ASSIGN_STATE(state.cur, entropy->saved); + state.cinfo = cinfo; + + /* Flush out the last data */ + if (! flush_bits(&state)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + + /* Update state */ + cinfo->dest->next_output_byte = state.next_output_byte; + cinfo->dest->free_in_buffer = state.free_in_buffer; + ASSIGN_STATE(entropy->saved, state.cur); +} + + +/* + * Huffman coding optimization. + * + * We first scan the supplied data and count the number of uses of each symbol + * that is to be Huffman-coded. (This process MUST agree with the code above.) + * Then we build a Huffman coding tree for the observed counts. + * Symbols which are not needed at all for the particular image are not + * assigned any code, which saves space in the DHT marker as well as in + * the compressed data. + */ + +#ifdef ENTROPY_OPT_SUPPORTED + + +/* Process a single block's worth of coefficients */ + +LOCAL(void) +htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val, + long dc_counts[], long ac_counts[]) +{ + register int temp; + register int nbits; + register int k, r; + + /* Encode the DC coefficient difference per section F.1.2.1 */ + + temp = block[0] - last_dc_val; + if (temp < 0) + temp = -temp; + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 0; + while (temp) { + nbits++; + temp >>= 1; + } + /* Check for out-of-range coefficient values. + * Since we're encoding a difference, the range limit is twice as much. + */ + if (nbits > MAX_COEF_BITS+1) + ERREXIT(cinfo, JERR_BAD_DCT_COEF); + + /* Count the Huffman symbol for the number of bits */ + dc_counts[nbits]++; + + /* Encode the AC coefficients per section F.1.2.2 */ + + r = 0; /* r = run length of zeros */ + + for (k = 1; k < DCTSIZE2; k++) { + if ((temp = block[jpeg_natural_order[k]]) == 0) { + r++; + } else { + /* if run length > 15, must emit special run-length-16 codes (0xF0) */ + while (r > 15) { + ac_counts[0xF0]++; + r -= 16; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + if (temp < 0) + temp = -temp; + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 1; /* there must be at least one 1 bit */ + while ((temp >>= 1)) + nbits++; + /* Check for out-of-range coefficient values */ + if (nbits > MAX_COEF_BITS) + ERREXIT(cinfo, JERR_BAD_DCT_COEF); + + /* Count Huffman symbol for run length / number of bits */ + ac_counts[(r << 4) + nbits]++; + + r = 0; + } + } + + /* If the last coef(s) were zero, emit an end-of-block code */ + if (r > 0) + ac_counts[0]++; +} + + +/* + * Trial-encode one MCU's worth of Huffman-compressed coefficients. + * No data is actually output, so no suspension return is possible. + */ + +METHODDEF(boolean) +encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int blkn, ci; + jpeg_component_info * compptr; + + /* Take care of restart intervals if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) + entropy->saved.last_dc_val[ci] = 0; + /* Update restart state */ + entropy->restarts_to_go = cinfo->restart_interval; + } + entropy->restarts_to_go--; + } + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + htest_one_block(cinfo, MCU_data[blkn][0], entropy->saved.last_dc_val[ci], + entropy->dc_count_ptrs[compptr->dc_tbl_no], + entropy->ac_count_ptrs[compptr->ac_tbl_no]); + entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0]; + } + + return TRUE; +} + + +/* + * Generate the best Huffman code table for the given counts, fill htbl. + * Note this is also used by jcphuff.c. + * + * The JPEG standard requires that no symbol be assigned a codeword of all + * one bits (so that padding bits added at the end of a compressed segment + * can't look like a valid code). Because of the canonical ordering of + * codewords, this just means that there must be an unused slot in the + * longest codeword length category. Section K.2 of the JPEG spec suggests + * reserving such a slot by pretending that symbol 256 is a valid symbol + * with count 1. In theory that's not optimal; giving it count zero but + * including it in the symbol set anyway should give a better Huffman code. + * But the theoretically better code actually seems to come out worse in + * practice, because it produces more all-ones bytes (which incur stuffed + * zero bytes in the final file). In any case the difference is tiny. + * + * The JPEG standard requires Huffman codes to be no more than 16 bits long. + * If some symbols have a very small but nonzero probability, the Huffman tree + * must be adjusted to meet the code length restriction. We currently use + * the adjustment method suggested in JPEG section K.2. This method is *not* + * optimal; it may not choose the best possible limited-length code. But + * typically only very-low-frequency symbols will be given less-than-optimal + * lengths, so the code is almost optimal. Experimental comparisons against + * an optimal limited-length-code algorithm indicate that the difference is + * microscopic --- usually less than a hundredth of a percent of total size. + * So the extra complexity of an optimal algorithm doesn't seem worthwhile. + */ + +GLOBAL(void) +jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[]) +{ +#define MAX_CLEN 32 /* assumed maximum initial code length */ + UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */ + int codesize[257]; /* codesize[k] = code length of symbol k */ + int others[257]; /* next symbol in current branch of tree */ + int c1, c2; + int p, i, j; + long v; + + /* This algorithm is explained in section K.2 of the JPEG standard */ + + MEMZERO(bits, SIZEOF(bits)); + MEMZERO(codesize, SIZEOF(codesize)); + for (i = 0; i < 257; i++) + others[i] = -1; /* init links to empty */ + + freq[256] = 1; /* make sure 256 has a nonzero count */ + /* Including the pseudo-symbol 256 in the Huffman procedure guarantees + * that no real symbol is given code-value of all ones, because 256 + * will be placed last in the largest codeword category. + */ + + /* Huffman's basic algorithm to assign optimal code lengths to symbols */ + + for (;;) { + /* Find the smallest nonzero frequency, set c1 = its symbol */ + /* In case of ties, take the larger symbol number */ + c1 = -1; + v = 1000000000L; + for (i = 0; i <= 256; i++) { + if (freq[i] && freq[i] <= v) { + v = freq[i]; + c1 = i; + } + } + + /* Find the next smallest nonzero frequency, set c2 = its symbol */ + /* In case of ties, take the larger symbol number */ + c2 = -1; + v = 1000000000L; + for (i = 0; i <= 256; i++) { + if (freq[i] && freq[i] <= v && i != c1) { + v = freq[i]; + c2 = i; + } + } + + /* Done if we've merged everything into one frequency */ + if (c2 < 0) + break; + + /* Else merge the two counts/trees */ + freq[c1] += freq[c2]; + freq[c2] = 0; + + /* Increment the codesize of everything in c1's tree branch */ + codesize[c1]++; + while (others[c1] >= 0) { + c1 = others[c1]; + codesize[c1]++; + } + + others[c1] = c2; /* chain c2 onto c1's tree branch */ + + /* Increment the codesize of everything in c2's tree branch */ + codesize[c2]++; + while (others[c2] >= 0) { + c2 = others[c2]; + codesize[c2]++; + } + } + + /* Now count the number of symbols of each code length */ + for (i = 0; i <= 256; i++) { + if (codesize[i]) { + /* The JPEG standard seems to think that this can't happen, */ + /* but I'm paranoid... */ + if (codesize[i] > MAX_CLEN) + ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW); + + bits[codesize[i]]++; + } + } + + /* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure + * Huffman procedure assigned any such lengths, we must adjust the coding. + * Here is what the JPEG spec says about how this next bit works: + * Since symbols are paired for the longest Huffman code, the symbols are + * removed from this length category two at a time. The prefix for the pair + * (which is one bit shorter) is allocated to one of the pair; then, + * skipping the BITS entry for that prefix length, a code word from the next + * shortest nonzero BITS entry is converted into a prefix for two code words + * one bit longer. + */ + + for (i = MAX_CLEN; i > 16; i--) { + while (bits[i] > 0) { + j = i - 2; /* find length of new prefix to be used */ + while (bits[j] == 0) + j--; + + bits[i] -= 2; /* remove two symbols */ + bits[i-1]++; /* one goes in this length */ + bits[j+1] += 2; /* two new symbols in this length */ + bits[j]--; /* symbol of this length is now a prefix */ + } + } + + /* Remove the count for the pseudo-symbol 256 from the largest codelength */ + while (bits[i] == 0) /* find largest codelength still in use */ + i--; + bits[i]--; + + /* Return final symbol counts (only for lengths 0..16) */ + MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits)); + + /* Return a list of the symbols sorted by code length */ + /* It's not real clear to me why we don't need to consider the codelength + * changes made above, but the JPEG spec seems to think this works. + */ + p = 0; + for (i = 1; i <= MAX_CLEN; i++) { + for (j = 0; j <= 255; j++) { + if (codesize[j] == i) { + htbl->huffval[p] = (UINT8) j; + p++; + } + } + } + + /* Set sent_table FALSE so updated table will be written to JPEG file. */ + htbl->sent_table = FALSE; +} + + +/* + * Finish up a statistics-gathering pass and create the new Huffman tables. + */ + +METHODDEF(void) +finish_pass_gather (j_compress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci, dctbl, actbl; + jpeg_component_info * compptr; + JHUFF_TBL **htblptr; + boolean did_dc[NUM_HUFF_TBLS]; + boolean did_ac[NUM_HUFF_TBLS]; + + /* It's important not to apply jpeg_gen_optimal_table more than once + * per table, because it clobbers the input frequency counts! + */ + MEMZERO(did_dc, SIZEOF(did_dc)); + MEMZERO(did_ac, SIZEOF(did_ac)); + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + dctbl = compptr->dc_tbl_no; + actbl = compptr->ac_tbl_no; + if (! did_dc[dctbl]) { + htblptr = & cinfo->dc_huff_tbl_ptrs[dctbl]; + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[dctbl]); + did_dc[dctbl] = TRUE; + } + if (! did_ac[actbl]) { + htblptr = & cinfo->ac_huff_tbl_ptrs[actbl]; + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[actbl]); + did_ac[actbl] = TRUE; + } + } +} + + +#endif /* ENTROPY_OPT_SUPPORTED */ + + +/* + * Module initialization routine for Huffman entropy encoding. + */ + +GLOBAL(void) +jinit_huff_encoder (j_compress_ptr cinfo) +{ + huff_entropy_ptr entropy; + int i; + + entropy = (huff_entropy_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(huff_entropy_encoder)); + cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; + entropy->pub.start_pass = start_pass_huff; + + /* Mark tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; +#ifdef ENTROPY_OPT_SUPPORTED + entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL; +#endif + } +} diff --git a/src/dep/src/irrlicht/jpeglib/jchuff.h b/src/dep/src/irrlicht/jpeglib/jchuff.h index 8c02c09..a9599fc 100644 --- a/src/dep/src/irrlicht/jpeglib/jchuff.h +++ b/src/dep/src/irrlicht/jpeglib/jchuff.h @@ -1,47 +1,47 @@ -/* - * jchuff.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for Huffman entropy encoding routines - * that are shared between the sequential encoder (jchuff.c) and the - * progressive encoder (jcphuff.c). No other modules need to see these. - */ - -/* The legal range of a DCT coefficient is - * -1024 .. +1023 for 8-bit data; - * -16384 .. +16383 for 12-bit data. - * Hence the magnitude should always fit in 10 or 14 bits respectively. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MAX_COEF_BITS 10 -#else -#define MAX_COEF_BITS 14 -#endif - -/* Derived data constructed for each Huffman table */ - -typedef struct { - unsigned int ehufco[256]; /* code for each symbol */ - char ehufsi[256]; /* length of code for each symbol */ - /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ -} c_derived_tbl; - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_make_c_derived_tbl jMkCDerived -#define jpeg_gen_optimal_table jGenOptTbl -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Expand a Huffman table definition into the derived format */ -EXTERN(void) jpeg_make_c_derived_tbl - JPP((j_compress_ptr cinfo, boolean isDC, int tblno, - c_derived_tbl ** pdtbl)); - -/* Generate an optimal table definition given the specified counts */ -EXTERN(void) jpeg_gen_optimal_table - JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])); +/* + * jchuff.h + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains declarations for Huffman entropy encoding routines + * that are shared between the sequential encoder (jchuff.c) and the + * progressive encoder (jcphuff.c). No other modules need to see these. + */ + +/* The legal range of a DCT coefficient is + * -1024 .. +1023 for 8-bit data; + * -16384 .. +16383 for 12-bit data. + * Hence the magnitude should always fit in 10 or 14 bits respectively. + */ + +#if BITS_IN_JSAMPLE == 8 +#define MAX_COEF_BITS 10 +#else +#define MAX_COEF_BITS 14 +#endif + +/* Derived data constructed for each Huffman table */ + +typedef struct { + unsigned int ehufco[256]; /* code for each symbol */ + char ehufsi[256]; /* length of code for each symbol */ + /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ +} c_derived_tbl; + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_make_c_derived_tbl jMkCDerived +#define jpeg_gen_optimal_table jGenOptTbl +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + +/* Expand a Huffman table definition into the derived format */ +EXTERN(void) jpeg_make_c_derived_tbl + JPP((j_compress_ptr cinfo, boolean isDC, int tblno, + c_derived_tbl ** pdtbl)); + +/* Generate an optimal table definition given the specified counts */ +EXTERN(void) jpeg_gen_optimal_table + JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])); diff --git a/src/dep/src/irrlicht/jpeglib/jcinit.c b/src/dep/src/irrlicht/jpeglib/jcinit.c index 19de8d0..5efffe3 100644 --- a/src/dep/src/irrlicht/jpeglib/jcinit.c +++ b/src/dep/src/irrlicht/jpeglib/jcinit.c @@ -1,72 +1,72 @@ -/* - * jcinit.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains initialization logic for the JPEG compressor. - * This routine is in charge of selecting the modules to be executed and - * making an initialization call to each one. - * - * Logically, this code belongs in jcmaster.c. It's split out because - * linking this routine implies linking the entire compression library. - * For a transcoding-only application, we want to be able to use jcmaster.c - * without linking in the whole library. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Master selection of compression modules. - * This is done once at the start of processing an image. We determine - * which modules will be used and give them appropriate initialization calls. - */ - -GLOBAL(void) -jinit_compress_master (j_compress_ptr cinfo) -{ - /* Initialize master control (includes parameter checking/processing) */ - jinit_c_master_control(cinfo, FALSE /* full compression */); - - /* Preprocessing */ - if (! cinfo->raw_data_in) { - jinit_color_converter(cinfo); - jinit_downsampler(cinfo); - jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); - } - /* Forward DCT */ - jinit_forward_dct(cinfo); - /* Entropy encoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - jinit_phuff_encoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_encoder(cinfo); - } - - /* Need a full-image coefficient buffer in any multi-pass mode. */ - jinit_c_coef_controller(cinfo, - (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); - jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); - - jinit_marker_writer(cinfo); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Write the datastream header (SOI) immediately. - * Frame and scan headers are postponed till later. - * This lets application insert special markers after the SOI. - */ - (*cinfo->marker->write_file_header) (cinfo); -} +/* + * jcinit.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains initialization logic for the JPEG compressor. + * This routine is in charge of selecting the modules to be executed and + * making an initialization call to each one. + * + * Logically, this code belongs in jcmaster.c. It's split out because + * linking this routine implies linking the entire compression library. + * For a transcoding-only application, we want to be able to use jcmaster.c + * without linking in the whole library. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Master selection of compression modules. + * This is done once at the start of processing an image. We determine + * which modules will be used and give them appropriate initialization calls. + */ + +GLOBAL(void) +jinit_compress_master (j_compress_ptr cinfo) +{ + /* Initialize master control (includes parameter checking/processing) */ + jinit_c_master_control(cinfo, FALSE /* full compression */); + + /* Preprocessing */ + if (! cinfo->raw_data_in) { + jinit_color_converter(cinfo); + jinit_downsampler(cinfo); + jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); + } + /* Forward DCT */ + jinit_forward_dct(cinfo); + /* Entropy encoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) { + ERREXIT(cinfo, JERR_ARITH_NOTIMPL); + } else { + if (cinfo->progressive_mode) { +#ifdef C_PROGRESSIVE_SUPPORTED + jinit_phuff_encoder(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else + jinit_huff_encoder(cinfo); + } + + /* Need a full-image coefficient buffer in any multi-pass mode. */ + jinit_c_coef_controller(cinfo, + (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); + jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); + + jinit_marker_writer(cinfo); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Write the datastream header (SOI) immediately. + * Frame and scan headers are postponed till later. + * This lets application insert special markers after the SOI. + */ + (*cinfo->marker->write_file_header) (cinfo); +} diff --git a/src/dep/src/irrlicht/jpeglib/jcmainct.c b/src/dep/src/irrlicht/jpeglib/jcmainct.c index 14aa4c7..e0279a7 100644 --- a/src/dep/src/irrlicht/jpeglib/jcmainct.c +++ b/src/dep/src/irrlicht/jpeglib/jcmainct.c @@ -1,293 +1,293 @@ -/* - * jcmainct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the main buffer controller for compression. - * The main buffer lies between the pre-processor and the JPEG - * compressor proper; it holds downsampled data in the JPEG colorspace. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Note: currently, there is no operating mode in which a full-image buffer - * is needed at this step. If there were, that mode could not be used with - * "raw data" input, since this module is bypassed in that case. However, - * we've left the code here for possible use in special applications. - */ -#undef FULL_MAIN_BUFFER_SUPPORTED - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_main_controller pub; /* public fields */ - - JDIMENSION cur_iMCU_row; /* number of current iMCU row */ - JDIMENSION rowgroup_ctr; /* counts row groups received in iMCU row */ - boolean suspended; /* remember if we suspended output */ - J_BUF_MODE pass_mode; /* current operating mode */ - - /* If using just a strip buffer, this points to the entire set of buffers - * (we allocate one for each component). In the full-image case, this - * points to the currently accessible strips of the virtual arrays. - */ - JSAMPARRAY buffer[MAX_COMPONENTS]; - -#ifdef FULL_MAIN_BUFFER_SUPPORTED - /* If using full-image storage, this array holds pointers to virtual-array - * control blocks for each component. Unused if not full-image storage. - */ - jvirt_sarray_ptr whole_image[MAX_COMPONENTS]; -#endif -} my_main_controller; - -typedef my_main_controller * my_main_ptr; - - -/* Forward declarations */ -METHODDEF(void) process_data_simple_main - JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); -#ifdef FULL_MAIN_BUFFER_SUPPORTED -METHODDEF(void) process_data_buffer_main - JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); -#endif - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - /* Do nothing in raw-data mode. */ - if (cinfo->raw_data_in) - return; - - main->cur_iMCU_row = 0; /* initialize counters */ - main->rowgroup_ctr = 0; - main->suspended = FALSE; - main->pass_mode = pass_mode; /* save mode for use by process_data */ - - switch (pass_mode) { - case JBUF_PASS_THRU: -#ifdef FULL_MAIN_BUFFER_SUPPORTED - if (main->whole_image[0] != NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - main->pub.process_data = process_data_simple_main; - break; -#ifdef FULL_MAIN_BUFFER_SUPPORTED - case JBUF_SAVE_SOURCE: - case JBUF_CRANK_DEST: - case JBUF_SAVE_AND_PASS: - if (main->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - main->pub.process_data = process_data_buffer_main; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data. - * This routine handles the simple pass-through mode, - * where we have only a strip buffer. - */ - -METHODDEF(void) -process_data_simple_main (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { - /* Read input data if we haven't filled the main buffer yet */ - if (main->rowgroup_ctr < DCTSIZE) - (*cinfo->prep->pre_process_data) (cinfo, - input_buf, in_row_ctr, in_rows_avail, - main->buffer, &main->rowgroup_ctr, - (JDIMENSION) DCTSIZE); - - /* If we don't have a full iMCU row buffered, return to application for - * more data. Note that preprocessor will always pad to fill the iMCU row - * at the bottom of the image. - */ - if (main->rowgroup_ctr != DCTSIZE) - return; - - /* Send the completed row to the compressor */ - if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { - /* If compressor did not consume the whole row, then we must need to - * suspend processing and return to the application. In this situation - * we pretend we didn't yet consume the last input row; otherwise, if - * it happened to be the last row of the image, the application would - * think we were done. - */ - if (! main->suspended) { - (*in_row_ctr)--; - main->suspended = TRUE; - } - return; - } - /* We did finish the row. Undo our little suspension hack if a previous - * call suspended; then mark the main buffer empty. - */ - if (main->suspended) { - (*in_row_ctr)++; - main->suspended = FALSE; - } - main->rowgroup_ctr = 0; - main->cur_iMCU_row++; - } -} - - -#ifdef FULL_MAIN_BUFFER_SUPPORTED - -/* - * Process some data. - * This routine handles all of the modes that use a full-size buffer. - */ - -METHODDEF(void) -process_data_buffer_main (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci; - jpeg_component_info *compptr; - boolean writing = (main->pass_mode != JBUF_CRANK_DEST); - - while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { - /* Realign the virtual buffers if at the start of an iMCU row. */ - if (main->rowgroup_ctr == 0) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->buffer[ci] = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, main->whole_image[ci], - main->cur_iMCU_row * (compptr->v_samp_factor * DCTSIZE), - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE), writing); - } - /* In a read pass, pretend we just read some source data. */ - if (! writing) { - *in_row_ctr += cinfo->max_v_samp_factor * DCTSIZE; - main->rowgroup_ctr = DCTSIZE; - } - } - - /* If a write pass, read input data until the current iMCU row is full. */ - /* Note: preprocessor will pad if necessary to fill the last iMCU row. */ - if (writing) { - (*cinfo->prep->pre_process_data) (cinfo, - input_buf, in_row_ctr, in_rows_avail, - main->buffer, &main->rowgroup_ctr, - (JDIMENSION) DCTSIZE); - /* Return to application if we need more data to fill the iMCU row. */ - if (main->rowgroup_ctr < DCTSIZE) - return; - } - - /* Emit data, unless this is a sink-only pass. */ - if (main->pass_mode != JBUF_SAVE_SOURCE) { - if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { - /* If compressor did not consume the whole row, then we must need to - * suspend processing and return to the application. In this situation - * we pretend we didn't yet consume the last input row; otherwise, if - * it happened to be the last row of the image, the application would - * think we were done. - */ - if (! main->suspended) { - (*in_row_ctr)--; - main->suspended = TRUE; - } - return; - } - /* We did finish the row. Undo our little suspension hack if a previous - * call suspended; then mark the main buffer empty. - */ - if (main->suspended) { - (*in_row_ctr)++; - main->suspended = FALSE; - } - } - - /* If get here, we are done with this iMCU row. Mark buffer empty. */ - main->rowgroup_ctr = 0; - main->cur_iMCU_row++; - } -} - -#endif /* FULL_MAIN_BUFFER_SUPPORTED */ - - -/* - * Initialize main buffer controller. - */ - -GLOBAL(void) -jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_main_ptr main; - int ci; - jpeg_component_info *compptr; - - main = (my_main_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_main_controller)); - cinfo->main = (struct jpeg_c_main_controller *) main; - main->pub.start_pass = start_pass_main; - - /* We don't need to create a buffer in raw-data mode. */ - if (cinfo->raw_data_in) - return; - - /* Create the buffer. It holds downsampled data, so each component - * may be of a different size. - */ - if (need_full_buffer) { -#ifdef FULL_MAIN_BUFFER_SUPPORTED - /* Allocate a full-image virtual array for each component */ - /* Note we pad the bottom to a multiple of the iMCU height */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->whole_image[ci] = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - compptr->width_in_blocks * DCTSIZE, - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor) * DCTSIZE, - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); - } -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - } else { -#ifdef FULL_MAIN_BUFFER_SUPPORTED - main->whole_image[0] = NULL; /* flag for no virtual arrays */ -#endif - /* Allocate a strip buffer for each component */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->buffer[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - compptr->width_in_blocks * DCTSIZE, - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); - } - } -} +/* + * jcmainct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the main buffer controller for compression. + * The main buffer lies between the pre-processor and the JPEG + * compressor proper; it holds downsampled data in the JPEG colorspace. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Note: currently, there is no operating mode in which a full-image buffer + * is needed at this step. If there were, that mode could not be used with + * "raw data" input, since this module is bypassed in that case. However, + * we've left the code here for possible use in special applications. + */ +#undef FULL_MAIN_BUFFER_SUPPORTED + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_main_controller pub; /* public fields */ + + JDIMENSION cur_iMCU_row; /* number of current iMCU row */ + JDIMENSION rowgroup_ctr; /* counts row groups received in iMCU row */ + boolean suspended; /* remember if we suspended output */ + J_BUF_MODE pass_mode; /* current operating mode */ + + /* If using just a strip buffer, this points to the entire set of buffers + * (we allocate one for each component). In the full-image case, this + * points to the currently accessible strips of the virtual arrays. + */ + JSAMPARRAY buffer[MAX_COMPONENTS]; + +#ifdef FULL_MAIN_BUFFER_SUPPORTED + /* If using full-image storage, this array holds pointers to virtual-array + * control blocks for each component. Unused if not full-image storage. + */ + jvirt_sarray_ptr whole_image[MAX_COMPONENTS]; +#endif +} my_main_controller; + +typedef my_main_controller * my_main_ptr; + + +/* Forward declarations */ +METHODDEF(void) process_data_simple_main + JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, + JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); +#ifdef FULL_MAIN_BUFFER_SUPPORTED +METHODDEF(void) process_data_buffer_main + JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, + JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); +#endif + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + + /* Do nothing in raw-data mode. */ + if (cinfo->raw_data_in) + return; + + main->cur_iMCU_row = 0; /* initialize counters */ + main->rowgroup_ctr = 0; + main->suspended = FALSE; + main->pass_mode = pass_mode; /* save mode for use by process_data */ + + switch (pass_mode) { + case JBUF_PASS_THRU: +#ifdef FULL_MAIN_BUFFER_SUPPORTED + if (main->whole_image[0] != NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif + main->pub.process_data = process_data_simple_main; + break; +#ifdef FULL_MAIN_BUFFER_SUPPORTED + case JBUF_SAVE_SOURCE: + case JBUF_CRANK_DEST: + case JBUF_SAVE_AND_PASS: + if (main->whole_image[0] == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + main->pub.process_data = process_data_buffer_main; + break; +#endif + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + break; + } +} + + +/* + * Process some data. + * This routine handles the simple pass-through mode, + * where we have only a strip buffer. + */ + +METHODDEF(void) +process_data_simple_main (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + + while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { + /* Read input data if we haven't filled the main buffer yet */ + if (main->rowgroup_ctr < DCTSIZE) + (*cinfo->prep->pre_process_data) (cinfo, + input_buf, in_row_ctr, in_rows_avail, + main->buffer, &main->rowgroup_ctr, + (JDIMENSION) DCTSIZE); + + /* If we don't have a full iMCU row buffered, return to application for + * more data. Note that preprocessor will always pad to fill the iMCU row + * at the bottom of the image. + */ + if (main->rowgroup_ctr != DCTSIZE) + return; + + /* Send the completed row to the compressor */ + if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { + /* If compressor did not consume the whole row, then we must need to + * suspend processing and return to the application. In this situation + * we pretend we didn't yet consume the last input row; otherwise, if + * it happened to be the last row of the image, the application would + * think we were done. + */ + if (! main->suspended) { + (*in_row_ctr)--; + main->suspended = TRUE; + } + return; + } + /* We did finish the row. Undo our little suspension hack if a previous + * call suspended; then mark the main buffer empty. + */ + if (main->suspended) { + (*in_row_ctr)++; + main->suspended = FALSE; + } + main->rowgroup_ctr = 0; + main->cur_iMCU_row++; + } +} + + +#ifdef FULL_MAIN_BUFFER_SUPPORTED + +/* + * Process some data. + * This routine handles all of the modes that use a full-size buffer. + */ + +METHODDEF(void) +process_data_buffer_main (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci; + jpeg_component_info *compptr; + boolean writing = (main->pass_mode != JBUF_CRANK_DEST); + + while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { + /* Realign the virtual buffers if at the start of an iMCU row. */ + if (main->rowgroup_ctr == 0) { + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + main->buffer[ci] = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, main->whole_image[ci], + main->cur_iMCU_row * (compptr->v_samp_factor * DCTSIZE), + (JDIMENSION) (compptr->v_samp_factor * DCTSIZE), writing); + } + /* In a read pass, pretend we just read some source data. */ + if (! writing) { + *in_row_ctr += cinfo->max_v_samp_factor * DCTSIZE; + main->rowgroup_ctr = DCTSIZE; + } + } + + /* If a write pass, read input data until the current iMCU row is full. */ + /* Note: preprocessor will pad if necessary to fill the last iMCU row. */ + if (writing) { + (*cinfo->prep->pre_process_data) (cinfo, + input_buf, in_row_ctr, in_rows_avail, + main->buffer, &main->rowgroup_ctr, + (JDIMENSION) DCTSIZE); + /* Return to application if we need more data to fill the iMCU row. */ + if (main->rowgroup_ctr < DCTSIZE) + return; + } + + /* Emit data, unless this is a sink-only pass. */ + if (main->pass_mode != JBUF_SAVE_SOURCE) { + if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { + /* If compressor did not consume the whole row, then we must need to + * suspend processing and return to the application. In this situation + * we pretend we didn't yet consume the last input row; otherwise, if + * it happened to be the last row of the image, the application would + * think we were done. + */ + if (! main->suspended) { + (*in_row_ctr)--; + main->suspended = TRUE; + } + return; + } + /* We did finish the row. Undo our little suspension hack if a previous + * call suspended; then mark the main buffer empty. + */ + if (main->suspended) { + (*in_row_ctr)++; + main->suspended = FALSE; + } + } + + /* If get here, we are done with this iMCU row. Mark buffer empty. */ + main->rowgroup_ctr = 0; + main->cur_iMCU_row++; + } +} + +#endif /* FULL_MAIN_BUFFER_SUPPORTED */ + + +/* + * Initialize main buffer controller. + */ + +GLOBAL(void) +jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer) +{ + my_main_ptr main; + int ci; + jpeg_component_info *compptr; + + main = (my_main_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_main_controller)); + cinfo->main = (struct jpeg_c_main_controller *) main; + main->pub.start_pass = start_pass_main; + + /* We don't need to create a buffer in raw-data mode. */ + if (cinfo->raw_data_in) + return; + + /* Create the buffer. It holds downsampled data, so each component + * may be of a different size. + */ + if (need_full_buffer) { +#ifdef FULL_MAIN_BUFFER_SUPPORTED + /* Allocate a full-image virtual array for each component */ + /* Note we pad the bottom to a multiple of the iMCU height */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + main->whole_image[ci] = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + compptr->width_in_blocks * DCTSIZE, + (JDIMENSION) jround_up((long) compptr->height_in_blocks, + (long) compptr->v_samp_factor) * DCTSIZE, + (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); + } +#else + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif + } else { +#ifdef FULL_MAIN_BUFFER_SUPPORTED + main->whole_image[0] = NULL; /* flag for no virtual arrays */ +#endif + /* Allocate a strip buffer for each component */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + main->buffer[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + compptr->width_in_blocks * DCTSIZE, + (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); + } + } +} diff --git a/src/dep/src/irrlicht/jpeglib/jcmarker.c b/src/dep/src/irrlicht/jpeglib/jcmarker.c index 0d3ca5e..3d1e6c6 100644 --- a/src/dep/src/irrlicht/jpeglib/jcmarker.c +++ b/src/dep/src/irrlicht/jpeglib/jcmarker.c @@ -1,664 +1,664 @@ -/* - * jcmarker.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write JPEG datastream markers. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -typedef enum { /* JPEG marker codes */ - M_SOF0 = 0xc0, - M_SOF1 = 0xc1, - M_SOF2 = 0xc2, - M_SOF3 = 0xc3, - - M_SOF5 = 0xc5, - M_SOF6 = 0xc6, - M_SOF7 = 0xc7, - - M_JPG = 0xc8, - M_SOF9 = 0xc9, - M_SOF10 = 0xca, - M_SOF11 = 0xcb, - - M_SOF13 = 0xcd, - M_SOF14 = 0xce, - M_SOF15 = 0xcf, - - M_DHT = 0xc4, - - M_DAC = 0xcc, - - M_RST0 = 0xd0, - M_RST1 = 0xd1, - M_RST2 = 0xd2, - M_RST3 = 0xd3, - M_RST4 = 0xd4, - M_RST5 = 0xd5, - M_RST6 = 0xd6, - M_RST7 = 0xd7, - - M_SOI = 0xd8, - M_EOI = 0xd9, - M_SOS = 0xda, - M_DQT = 0xdb, - M_DNL = 0xdc, - M_DRI = 0xdd, - M_DHP = 0xde, - M_EXP = 0xdf, - - M_APP0 = 0xe0, - M_APP1 = 0xe1, - M_APP2 = 0xe2, - M_APP3 = 0xe3, - M_APP4 = 0xe4, - M_APP5 = 0xe5, - M_APP6 = 0xe6, - M_APP7 = 0xe7, - M_APP8 = 0xe8, - M_APP9 = 0xe9, - M_APP10 = 0xea, - M_APP11 = 0xeb, - M_APP12 = 0xec, - M_APP13 = 0xed, - M_APP14 = 0xee, - M_APP15 = 0xef, - - M_JPG0 = 0xf0, - M_JPG13 = 0xfd, - M_COM = 0xfe, - - M_TEM = 0x01, - - M_ERROR = 0x100 -} JPEG_MARKER; - - -/* Private state */ - -typedef struct { - struct jpeg_marker_writer pub; /* public fields */ - - unsigned int last_restart_interval; /* last DRI value emitted; 0 after SOI */ -} my_marker_writer; - -typedef my_marker_writer * my_marker_ptr; - - -/* - * Basic output routines. - * - * Note that we do not support suspension while writing a marker. - * Therefore, an application using suspension must ensure that there is - * enough buffer space for the initial markers (typ. 600-700 bytes) before - * calling jpeg_start_compress, and enough space to write the trailing EOI - * (a few bytes) before calling jpeg_finish_compress. Multipass compression - * modes are not supported at all with suspension, so those two are the only - * points where markers will be written. - */ - -LOCAL(void) -emit_byte (j_compress_ptr cinfo, int val) -/* Emit a byte */ -{ - struct jpeg_destination_mgr * dest = cinfo->dest; - - *(dest->next_output_byte)++ = (JOCTET) val; - if (--dest->free_in_buffer == 0) { - if (! (*dest->empty_output_buffer) (cinfo)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } -} - - -LOCAL(void) -emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark) -/* Emit a marker code */ -{ - emit_byte(cinfo, 0xFF); - emit_byte(cinfo, (int) mark); -} - - -LOCAL(void) -emit_2bytes (j_compress_ptr cinfo, int value) -/* Emit a 2-byte integer; these are always MSB first in JPEG files */ -{ - emit_byte(cinfo, (value >> 8) & 0xFF); - emit_byte(cinfo, value & 0xFF); -} - - -/* - * Routines to write specific marker types. - */ - -LOCAL(int) -emit_dqt (j_compress_ptr cinfo, int index) -/* Emit a DQT marker */ -/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */ -{ - JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index]; - int prec; - int i; - - if (qtbl == NULL) - ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index); - - prec = 0; - for (i = 0; i < DCTSIZE2; i++) { - if (qtbl->quantval[i] > 255) - prec = 1; - } - - if (! qtbl->sent_table) { - emit_marker(cinfo, M_DQT); - - emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2); - - emit_byte(cinfo, index + (prec<<4)); - - for (i = 0; i < DCTSIZE2; i++) { - /* The table entries must be emitted in zigzag order. */ - unsigned int qval = qtbl->quantval[jpeg_natural_order[i]]; - if (prec) - emit_byte(cinfo, (int) (qval >> 8)); - emit_byte(cinfo, (int) (qval & 0xFF)); - } - - qtbl->sent_table = TRUE; - } - - return prec; -} - - -LOCAL(void) -emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) -/* Emit a DHT marker */ -{ - JHUFF_TBL * htbl; - int length, i; - - if (is_ac) { - htbl = cinfo->ac_huff_tbl_ptrs[index]; - index += 0x10; /* output index has AC bit set */ - } else { - htbl = cinfo->dc_huff_tbl_ptrs[index]; - } - - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index); - - if (! htbl->sent_table) { - emit_marker(cinfo, M_DHT); - - length = 0; - for (i = 1; i <= 16; i++) - length += htbl->bits[i]; - - emit_2bytes(cinfo, length + 2 + 1 + 16); - emit_byte(cinfo, index); - - for (i = 1; i <= 16; i++) - emit_byte(cinfo, htbl->bits[i]); - - for (i = 0; i < length; i++) - emit_byte(cinfo, htbl->huffval[i]); - - htbl->sent_table = TRUE; - } -} - - -LOCAL(void) -emit_dac (j_compress_ptr cinfo) -/* Emit a DAC marker */ -/* Since the useful info is so small, we want to emit all the tables in */ -/* one DAC marker. Therefore this routine does its own scan of the table. */ -{ -#ifdef C_ARITH_CODING_SUPPORTED - char dc_in_use[NUM_ARITH_TBLS]; - char ac_in_use[NUM_ARITH_TBLS]; - int length, i; - jpeg_component_info *compptr; - - for (i = 0; i < NUM_ARITH_TBLS; i++) - dc_in_use[i] = ac_in_use[i] = 0; - - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - dc_in_use[compptr->dc_tbl_no] = 1; - ac_in_use[compptr->ac_tbl_no] = 1; - } - - length = 0; - for (i = 0; i < NUM_ARITH_TBLS; i++) - length += dc_in_use[i] + ac_in_use[i]; - - emit_marker(cinfo, M_DAC); - - emit_2bytes(cinfo, length*2 + 2); - - for (i = 0; i < NUM_ARITH_TBLS; i++) { - if (dc_in_use[i]) { - emit_byte(cinfo, i); - emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4)); - } - if (ac_in_use[i]) { - emit_byte(cinfo, i + 0x10); - emit_byte(cinfo, cinfo->arith_ac_K[i]); - } - } -#endif /* C_ARITH_CODING_SUPPORTED */ -} - - -LOCAL(void) -emit_dri (j_compress_ptr cinfo) -/* Emit a DRI marker */ -{ - emit_marker(cinfo, M_DRI); - - emit_2bytes(cinfo, 4); /* fixed length */ - - emit_2bytes(cinfo, (int) cinfo->restart_interval); -} - - -LOCAL(void) -emit_sof (j_compress_ptr cinfo, JPEG_MARKER code) -/* Emit a SOF marker */ -{ - int ci; - jpeg_component_info *compptr; - - emit_marker(cinfo, code); - - emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ - - /* Make sure image isn't bigger than SOF field can handle */ - if ((long) cinfo->image_height > 65535L || - (long) cinfo->image_width > 65535L) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535); - - emit_byte(cinfo, cinfo->data_precision); - emit_2bytes(cinfo, (int) cinfo->image_height); - emit_2bytes(cinfo, (int) cinfo->image_width); - - emit_byte(cinfo, cinfo->num_components); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - emit_byte(cinfo, compptr->component_id); - emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor); - emit_byte(cinfo, compptr->quant_tbl_no); - } -} - - -LOCAL(void) -emit_sos (j_compress_ptr cinfo) -/* Emit a SOS marker */ -{ - int i, td, ta; - jpeg_component_info *compptr; - - emit_marker(cinfo, M_SOS); - - emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */ - - emit_byte(cinfo, cinfo->comps_in_scan); - - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - emit_byte(cinfo, compptr->component_id); - td = compptr->dc_tbl_no; - ta = compptr->ac_tbl_no; - if (cinfo->progressive_mode) { - /* Progressive mode: only DC or only AC tables are used in one scan; - * furthermore, Huffman coding of DC refinement uses no table at all. - * We emit 0 for unused field(s); this is recommended by the P&M text - * but does not seem to be specified in the standard. - */ - if (cinfo->Ss == 0) { - ta = 0; /* DC scan */ - if (cinfo->Ah != 0 && !cinfo->arith_code) - td = 0; /* no DC table either */ - } else { - td = 0; /* AC scan */ - } - } - emit_byte(cinfo, (td << 4) + ta); - } - - emit_byte(cinfo, cinfo->Ss); - emit_byte(cinfo, cinfo->Se); - emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al); -} - - -LOCAL(void) -emit_jfif_app0 (j_compress_ptr cinfo) -/* Emit a JFIF-compliant APP0 marker */ -{ - /* - * Length of APP0 block (2 bytes) - * Block ID (4 bytes - ASCII "JFIF") - * Zero byte (1 byte to terminate the ID string) - * Version Major, Minor (2 bytes - major first) - * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm) - * Xdpu (2 bytes - dots per unit horizontal) - * Ydpu (2 bytes - dots per unit vertical) - * Thumbnail X size (1 byte) - * Thumbnail Y size (1 byte) - */ - - emit_marker(cinfo, M_APP0); - - emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */ - - emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ - emit_byte(cinfo, 0x46); - emit_byte(cinfo, 0x49); - emit_byte(cinfo, 0x46); - emit_byte(cinfo, 0); - emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */ - emit_byte(cinfo, cinfo->JFIF_minor_version); - emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */ - emit_2bytes(cinfo, (int) cinfo->X_density); - emit_2bytes(cinfo, (int) cinfo->Y_density); - emit_byte(cinfo, 0); /* No thumbnail image */ - emit_byte(cinfo, 0); -} - - -LOCAL(void) -emit_adobe_app14 (j_compress_ptr cinfo) -/* Emit an Adobe APP14 marker */ -{ - /* - * Length of APP14 block (2 bytes) - * Block ID (5 bytes - ASCII "Adobe") - * Version Number (2 bytes - currently 100) - * Flags0 (2 bytes - currently 0) - * Flags1 (2 bytes - currently 0) - * Color transform (1 byte) - * - * Although Adobe TN 5116 mentions Version = 101, all the Adobe files - * now in circulation seem to use Version = 100, so that's what we write. - * - * We write the color transform byte as 1 if the JPEG color space is - * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with - * whether the encoder performed a transformation, which is pretty useless. - */ - - emit_marker(cinfo, M_APP14); - - emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */ - - emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ - emit_byte(cinfo, 0x64); - emit_byte(cinfo, 0x6F); - emit_byte(cinfo, 0x62); - emit_byte(cinfo, 0x65); - emit_2bytes(cinfo, 100); /* Version */ - emit_2bytes(cinfo, 0); /* Flags0 */ - emit_2bytes(cinfo, 0); /* Flags1 */ - switch (cinfo->jpeg_color_space) { - case JCS_YCbCr: - emit_byte(cinfo, 1); /* Color transform = 1 */ - break; - case JCS_YCCK: - emit_byte(cinfo, 2); /* Color transform = 2 */ - break; - default: - emit_byte(cinfo, 0); /* Color transform = 0 */ - break; - } -} - - -/* - * These routines allow writing an arbitrary marker with parameters. - * The only intended use is to emit COM or APPn markers after calling - * write_file_header and before calling write_frame_header. - * Other uses are not guaranteed to produce desirable results. - * Counting the parameter bytes properly is the caller's responsibility. - */ - -METHODDEF(void) -write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen) -/* Emit an arbitrary marker header */ -{ - if (datalen > (unsigned int) 65533) /* safety check */ - ERREXIT(cinfo, JERR_BAD_LENGTH); - - emit_marker(cinfo, (JPEG_MARKER) marker); - - emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */ -} - -METHODDEF(void) -write_marker_byte (j_compress_ptr cinfo, int val) -/* Emit one byte of marker parameters following write_marker_header */ -{ - emit_byte(cinfo, val); -} - - -/* - * Write datastream header. - * This consists of an SOI and optional APPn markers. - * We recommend use of the JFIF marker, but not the Adobe marker, - * when using YCbCr or grayscale data. The JFIF marker should NOT - * be used for any other JPEG colorspace. The Adobe marker is helpful - * to distinguish RGB, CMYK, and YCCK colorspaces. - * Note that an application can write additional header markers after - * jpeg_start_compress returns. - */ - -METHODDEF(void) -write_file_header (j_compress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - emit_marker(cinfo, M_SOI); /* first the SOI */ - - /* SOI is defined to reset restart interval to 0 */ - marker->last_restart_interval = 0; - - if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */ - emit_jfif_app0(cinfo); - if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */ - emit_adobe_app14(cinfo); -} - - -/* - * Write frame header. - * This consists of DQT and SOFn markers. - * Note that we do not emit the SOF until we have emitted the DQT(s). - * This avoids compatibility problems with incorrect implementations that - * try to error-check the quant table numbers as soon as they see the SOF. - */ - -METHODDEF(void) -write_frame_header (j_compress_ptr cinfo) -{ - int ci, prec; - boolean is_baseline; - jpeg_component_info *compptr; - - /* Emit DQT for each quantization table. - * Note that emit_dqt() suppresses any duplicate tables. - */ - prec = 0; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - prec += emit_dqt(cinfo, compptr->quant_tbl_no); - } - /* now prec is nonzero iff there are any 16-bit quant tables. */ - - /* Check for a non-baseline specification. - * Note we assume that Huffman table numbers won't be changed later. - */ - if (cinfo->arith_code || cinfo->progressive_mode || - cinfo->data_precision != 8) { - is_baseline = FALSE; - } else { - is_baseline = TRUE; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1) - is_baseline = FALSE; - } - if (prec && is_baseline) { - is_baseline = FALSE; - /* If it's baseline except for quantizer size, warn the user */ - TRACEMS(cinfo, 0, JTRC_16BIT_TABLES); - } - } - - /* Emit the proper SOF marker */ - if (cinfo->arith_code) { - emit_sof(cinfo, M_SOF9); /* SOF code for arithmetic coding */ - } else { - if (cinfo->progressive_mode) - emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */ - else if (is_baseline) - emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */ - else - emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */ - } -} - - -/* - * Write scan header. - * This consists of DHT or DAC markers, optional DRI, and SOS. - * Compressed data will be written following the SOS. - */ - -METHODDEF(void) -write_scan_header (j_compress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - int i; - jpeg_component_info *compptr; - - if (cinfo->arith_code) { - /* Emit arith conditioning info. We may have some duplication - * if the file has multiple scans, but it's so small it's hardly - * worth worrying about. - */ - emit_dac(cinfo); - } else { - /* Emit Huffman tables. - * Note that emit_dht() suppresses any duplicate tables. - */ - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - if (cinfo->progressive_mode) { - /* Progressive mode: only DC or only AC tables are used in one scan */ - if (cinfo->Ss == 0) { - if (cinfo->Ah == 0) /* DC needs no table for refinement scan */ - emit_dht(cinfo, compptr->dc_tbl_no, FALSE); - } else { - emit_dht(cinfo, compptr->ac_tbl_no, TRUE); - } - } else { - /* Sequential mode: need both DC and AC tables */ - emit_dht(cinfo, compptr->dc_tbl_no, FALSE); - emit_dht(cinfo, compptr->ac_tbl_no, TRUE); - } - } - } - - /* Emit DRI if required --- note that DRI value could change for each scan. - * We avoid wasting space with unnecessary DRIs, however. - */ - if (cinfo->restart_interval != marker->last_restart_interval) { - emit_dri(cinfo); - marker->last_restart_interval = cinfo->restart_interval; - } - - emit_sos(cinfo); -} - - -/* - * Write datastream trailer. - */ - -METHODDEF(void) -write_file_trailer (j_compress_ptr cinfo) -{ - emit_marker(cinfo, M_EOI); -} - - -/* - * Write an abbreviated table-specification datastream. - * This consists of SOI, DQT and DHT tables, and EOI. - * Any table that is defined and not marked sent_table = TRUE will be - * emitted. Note that all tables will be marked sent_table = TRUE at exit. - */ - -METHODDEF(void) -write_tables_only (j_compress_ptr cinfo) -{ - int i; - - emit_marker(cinfo, M_SOI); - - for (i = 0; i < NUM_QUANT_TBLS; i++) { - if (cinfo->quant_tbl_ptrs[i] != NULL) - (void) emit_dqt(cinfo, i); - } - - if (! cinfo->arith_code) { - for (i = 0; i < NUM_HUFF_TBLS; i++) { - if (cinfo->dc_huff_tbl_ptrs[i] != NULL) - emit_dht(cinfo, i, FALSE); - if (cinfo->ac_huff_tbl_ptrs[i] != NULL) - emit_dht(cinfo, i, TRUE); - } - } - - emit_marker(cinfo, M_EOI); -} - - -/* - * Initialize the marker writer module. - */ - -GLOBAL(void) -jinit_marker_writer (j_compress_ptr cinfo) -{ - my_marker_ptr marker; - - /* Create the subobject */ - marker = (my_marker_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_marker_writer)); - cinfo->marker = (struct jpeg_marker_writer *) marker; - /* Initialize method pointers */ - marker->pub.write_file_header = write_file_header; - marker->pub.write_frame_header = write_frame_header; - marker->pub.write_scan_header = write_scan_header; - marker->pub.write_file_trailer = write_file_trailer; - marker->pub.write_tables_only = write_tables_only; - marker->pub.write_marker_header = write_marker_header; - marker->pub.write_marker_byte = write_marker_byte; - /* Initialize private state */ - marker->last_restart_interval = 0; -} +/* + * jcmarker.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write JPEG datastream markers. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +typedef enum { /* JPEG marker codes */ + M_SOF0 = 0xc0, + M_SOF1 = 0xc1, + M_SOF2 = 0xc2, + M_SOF3 = 0xc3, + + M_SOF5 = 0xc5, + M_SOF6 = 0xc6, + M_SOF7 = 0xc7, + + M_JPG = 0xc8, + M_SOF9 = 0xc9, + M_SOF10 = 0xca, + M_SOF11 = 0xcb, + + M_SOF13 = 0xcd, + M_SOF14 = 0xce, + M_SOF15 = 0xcf, + + M_DHT = 0xc4, + + M_DAC = 0xcc, + + M_RST0 = 0xd0, + M_RST1 = 0xd1, + M_RST2 = 0xd2, + M_RST3 = 0xd3, + M_RST4 = 0xd4, + M_RST5 = 0xd5, + M_RST6 = 0xd6, + M_RST7 = 0xd7, + + M_SOI = 0xd8, + M_EOI = 0xd9, + M_SOS = 0xda, + M_DQT = 0xdb, + M_DNL = 0xdc, + M_DRI = 0xdd, + M_DHP = 0xde, + M_EXP = 0xdf, + + M_APP0 = 0xe0, + M_APP1 = 0xe1, + M_APP2 = 0xe2, + M_APP3 = 0xe3, + M_APP4 = 0xe4, + M_APP5 = 0xe5, + M_APP6 = 0xe6, + M_APP7 = 0xe7, + M_APP8 = 0xe8, + M_APP9 = 0xe9, + M_APP10 = 0xea, + M_APP11 = 0xeb, + M_APP12 = 0xec, + M_APP13 = 0xed, + M_APP14 = 0xee, + M_APP15 = 0xef, + + M_JPG0 = 0xf0, + M_JPG13 = 0xfd, + M_COM = 0xfe, + + M_TEM = 0x01, + + M_ERROR = 0x100 +} JPEG_MARKER; + + +/* Private state */ + +typedef struct { + struct jpeg_marker_writer pub; /* public fields */ + + unsigned int last_restart_interval; /* last DRI value emitted; 0 after SOI */ +} my_marker_writer; + +typedef my_marker_writer * my_marker_ptr; + + +/* + * Basic output routines. + * + * Note that we do not support suspension while writing a marker. + * Therefore, an application using suspension must ensure that there is + * enough buffer space for the initial markers (typ. 600-700 bytes) before + * calling jpeg_start_compress, and enough space to write the trailing EOI + * (a few bytes) before calling jpeg_finish_compress. Multipass compression + * modes are not supported at all with suspension, so those two are the only + * points where markers will be written. + */ + +LOCAL(void) +emit_byte (j_compress_ptr cinfo, int val) +/* Emit a byte */ +{ + struct jpeg_destination_mgr * dest = cinfo->dest; + + *(dest->next_output_byte)++ = (JOCTET) val; + if (--dest->free_in_buffer == 0) { + if (! (*dest->empty_output_buffer) (cinfo)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + } +} + + +LOCAL(void) +emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark) +/* Emit a marker code */ +{ + emit_byte(cinfo, 0xFF); + emit_byte(cinfo, (int) mark); +} + + +LOCAL(void) +emit_2bytes (j_compress_ptr cinfo, int value) +/* Emit a 2-byte integer; these are always MSB first in JPEG files */ +{ + emit_byte(cinfo, (value >> 8) & 0xFF); + emit_byte(cinfo, value & 0xFF); +} + + +/* + * Routines to write specific marker types. + */ + +LOCAL(int) +emit_dqt (j_compress_ptr cinfo, int index) +/* Emit a DQT marker */ +/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */ +{ + JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index]; + int prec; + int i; + + if (qtbl == NULL) + ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index); + + prec = 0; + for (i = 0; i < DCTSIZE2; i++) { + if (qtbl->quantval[i] > 255) + prec = 1; + } + + if (! qtbl->sent_table) { + emit_marker(cinfo, M_DQT); + + emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2); + + emit_byte(cinfo, index + (prec<<4)); + + for (i = 0; i < DCTSIZE2; i++) { + /* The table entries must be emitted in zigzag order. */ + unsigned int qval = qtbl->quantval[jpeg_natural_order[i]]; + if (prec) + emit_byte(cinfo, (int) (qval >> 8)); + emit_byte(cinfo, (int) (qval & 0xFF)); + } + + qtbl->sent_table = TRUE; + } + + return prec; +} + + +LOCAL(void) +emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) +/* Emit a DHT marker */ +{ + JHUFF_TBL * htbl; + int length, i; + + if (is_ac) { + htbl = cinfo->ac_huff_tbl_ptrs[index]; + index += 0x10; /* output index has AC bit set */ + } else { + htbl = cinfo->dc_huff_tbl_ptrs[index]; + } + + if (htbl == NULL) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index); + + if (! htbl->sent_table) { + emit_marker(cinfo, M_DHT); + + length = 0; + for (i = 1; i <= 16; i++) + length += htbl->bits[i]; + + emit_2bytes(cinfo, length + 2 + 1 + 16); + emit_byte(cinfo, index); + + for (i = 1; i <= 16; i++) + emit_byte(cinfo, htbl->bits[i]); + + for (i = 0; i < length; i++) + emit_byte(cinfo, htbl->huffval[i]); + + htbl->sent_table = TRUE; + } +} + + +LOCAL(void) +emit_dac (j_compress_ptr cinfo) +/* Emit a DAC marker */ +/* Since the useful info is so small, we want to emit all the tables in */ +/* one DAC marker. Therefore this routine does its own scan of the table. */ +{ +#ifdef C_ARITH_CODING_SUPPORTED + char dc_in_use[NUM_ARITH_TBLS]; + char ac_in_use[NUM_ARITH_TBLS]; + int length, i; + jpeg_component_info *compptr; + + for (i = 0; i < NUM_ARITH_TBLS; i++) + dc_in_use[i] = ac_in_use[i] = 0; + + for (i = 0; i < cinfo->comps_in_scan; i++) { + compptr = cinfo->cur_comp_info[i]; + dc_in_use[compptr->dc_tbl_no] = 1; + ac_in_use[compptr->ac_tbl_no] = 1; + } + + length = 0; + for (i = 0; i < NUM_ARITH_TBLS; i++) + length += dc_in_use[i] + ac_in_use[i]; + + emit_marker(cinfo, M_DAC); + + emit_2bytes(cinfo, length*2 + 2); + + for (i = 0; i < NUM_ARITH_TBLS; i++) { + if (dc_in_use[i]) { + emit_byte(cinfo, i); + emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4)); + } + if (ac_in_use[i]) { + emit_byte(cinfo, i + 0x10); + emit_byte(cinfo, cinfo->arith_ac_K[i]); + } + } +#endif /* C_ARITH_CODING_SUPPORTED */ +} + + +LOCAL(void) +emit_dri (j_compress_ptr cinfo) +/* Emit a DRI marker */ +{ + emit_marker(cinfo, M_DRI); + + emit_2bytes(cinfo, 4); /* fixed length */ + + emit_2bytes(cinfo, (int) cinfo->restart_interval); +} + + +LOCAL(void) +emit_sof (j_compress_ptr cinfo, JPEG_MARKER code) +/* Emit a SOF marker */ +{ + int ci; + jpeg_component_info *compptr; + + emit_marker(cinfo, code); + + emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ + + /* Make sure image isn't bigger than SOF field can handle */ + if ((long) cinfo->image_height > 65535L || + (long) cinfo->image_width > 65535L) + ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535); + + emit_byte(cinfo, cinfo->data_precision); + emit_2bytes(cinfo, (int) cinfo->image_height); + emit_2bytes(cinfo, (int) cinfo->image_width); + + emit_byte(cinfo, cinfo->num_components); + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + emit_byte(cinfo, compptr->component_id); + emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor); + emit_byte(cinfo, compptr->quant_tbl_no); + } +} + + +LOCAL(void) +emit_sos (j_compress_ptr cinfo) +/* Emit a SOS marker */ +{ + int i, td, ta; + jpeg_component_info *compptr; + + emit_marker(cinfo, M_SOS); + + emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */ + + emit_byte(cinfo, cinfo->comps_in_scan); + + for (i = 0; i < cinfo->comps_in_scan; i++) { + compptr = cinfo->cur_comp_info[i]; + emit_byte(cinfo, compptr->component_id); + td = compptr->dc_tbl_no; + ta = compptr->ac_tbl_no; + if (cinfo->progressive_mode) { + /* Progressive mode: only DC or only AC tables are used in one scan; + * furthermore, Huffman coding of DC refinement uses no table at all. + * We emit 0 for unused field(s); this is recommended by the P&M text + * but does not seem to be specified in the standard. + */ + if (cinfo->Ss == 0) { + ta = 0; /* DC scan */ + if (cinfo->Ah != 0 && !cinfo->arith_code) + td = 0; /* no DC table either */ + } else { + td = 0; /* AC scan */ + } + } + emit_byte(cinfo, (td << 4) + ta); + } + + emit_byte(cinfo, cinfo->Ss); + emit_byte(cinfo, cinfo->Se); + emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al); +} + + +LOCAL(void) +emit_jfif_app0 (j_compress_ptr cinfo) +/* Emit a JFIF-compliant APP0 marker */ +{ + /* + * Length of APP0 block (2 bytes) + * Block ID (4 bytes - ASCII "JFIF") + * Zero byte (1 byte to terminate the ID string) + * Version Major, Minor (2 bytes - major first) + * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm) + * Xdpu (2 bytes - dots per unit horizontal) + * Ydpu (2 bytes - dots per unit vertical) + * Thumbnail X size (1 byte) + * Thumbnail Y size (1 byte) + */ + + emit_marker(cinfo, M_APP0); + + emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */ + + emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ + emit_byte(cinfo, 0x46); + emit_byte(cinfo, 0x49); + emit_byte(cinfo, 0x46); + emit_byte(cinfo, 0); + emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */ + emit_byte(cinfo, cinfo->JFIF_minor_version); + emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */ + emit_2bytes(cinfo, (int) cinfo->X_density); + emit_2bytes(cinfo, (int) cinfo->Y_density); + emit_byte(cinfo, 0); /* No thumbnail image */ + emit_byte(cinfo, 0); +} + + +LOCAL(void) +emit_adobe_app14 (j_compress_ptr cinfo) +/* Emit an Adobe APP14 marker */ +{ + /* + * Length of APP14 block (2 bytes) + * Block ID (5 bytes - ASCII "Adobe") + * Version Number (2 bytes - currently 100) + * Flags0 (2 bytes - currently 0) + * Flags1 (2 bytes - currently 0) + * Color transform (1 byte) + * + * Although Adobe TN 5116 mentions Version = 101, all the Adobe files + * now in circulation seem to use Version = 100, so that's what we write. + * + * We write the color transform byte as 1 if the JPEG color space is + * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with + * whether the encoder performed a transformation, which is pretty useless. + */ + + emit_marker(cinfo, M_APP14); + + emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */ + + emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ + emit_byte(cinfo, 0x64); + emit_byte(cinfo, 0x6F); + emit_byte(cinfo, 0x62); + emit_byte(cinfo, 0x65); + emit_2bytes(cinfo, 100); /* Version */ + emit_2bytes(cinfo, 0); /* Flags0 */ + emit_2bytes(cinfo, 0); /* Flags1 */ + switch (cinfo->jpeg_color_space) { + case JCS_YCbCr: + emit_byte(cinfo, 1); /* Color transform = 1 */ + break; + case JCS_YCCK: + emit_byte(cinfo, 2); /* Color transform = 2 */ + break; + default: + emit_byte(cinfo, 0); /* Color transform = 0 */ + break; + } +} + + +/* + * These routines allow writing an arbitrary marker with parameters. + * The only intended use is to emit COM or APPn markers after calling + * write_file_header and before calling write_frame_header. + * Other uses are not guaranteed to produce desirable results. + * Counting the parameter bytes properly is the caller's responsibility. + */ + +METHODDEF(void) +write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen) +/* Emit an arbitrary marker header */ +{ + if (datalen > (unsigned int) 65533) /* safety check */ + ERREXIT(cinfo, JERR_BAD_LENGTH); + + emit_marker(cinfo, (JPEG_MARKER) marker); + + emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */ +} + +METHODDEF(void) +write_marker_byte (j_compress_ptr cinfo, int val) +/* Emit one byte of marker parameters following write_marker_header */ +{ + emit_byte(cinfo, val); +} + + +/* + * Write datastream header. + * This consists of an SOI and optional APPn markers. + * We recommend use of the JFIF marker, but not the Adobe marker, + * when using YCbCr or grayscale data. The JFIF marker should NOT + * be used for any other JPEG colorspace. The Adobe marker is helpful + * to distinguish RGB, CMYK, and YCCK colorspaces. + * Note that an application can write additional header markers after + * jpeg_start_compress returns. + */ + +METHODDEF(void) +write_file_header (j_compress_ptr cinfo) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + + emit_marker(cinfo, M_SOI); /* first the SOI */ + + /* SOI is defined to reset restart interval to 0 */ + marker->last_restart_interval = 0; + + if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */ + emit_jfif_app0(cinfo); + if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */ + emit_adobe_app14(cinfo); +} + + +/* + * Write frame header. + * This consists of DQT and SOFn markers. + * Note that we do not emit the SOF until we have emitted the DQT(s). + * This avoids compatibility problems with incorrect implementations that + * try to error-check the quant table numbers as soon as they see the SOF. + */ + +METHODDEF(void) +write_frame_header (j_compress_ptr cinfo) +{ + int ci, prec; + boolean is_baseline; + jpeg_component_info *compptr; + + /* Emit DQT for each quantization table. + * Note that emit_dqt() suppresses any duplicate tables. + */ + prec = 0; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + prec += emit_dqt(cinfo, compptr->quant_tbl_no); + } + /* now prec is nonzero iff there are any 16-bit quant tables. */ + + /* Check for a non-baseline specification. + * Note we assume that Huffman table numbers won't be changed later. + */ + if (cinfo->arith_code || cinfo->progressive_mode || + cinfo->data_precision != 8) { + is_baseline = FALSE; + } else { + is_baseline = TRUE; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1) + is_baseline = FALSE; + } + if (prec && is_baseline) { + is_baseline = FALSE; + /* If it's baseline except for quantizer size, warn the user */ + TRACEMS(cinfo, 0, JTRC_16BIT_TABLES); + } + } + + /* Emit the proper SOF marker */ + if (cinfo->arith_code) { + emit_sof(cinfo, M_SOF9); /* SOF code for arithmetic coding */ + } else { + if (cinfo->progressive_mode) + emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */ + else if (is_baseline) + emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */ + else + emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */ + } +} + + +/* + * Write scan header. + * This consists of DHT or DAC markers, optional DRI, and SOS. + * Compressed data will be written following the SOS. + */ + +METHODDEF(void) +write_scan_header (j_compress_ptr cinfo) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + int i; + jpeg_component_info *compptr; + + if (cinfo->arith_code) { + /* Emit arith conditioning info. We may have some duplication + * if the file has multiple scans, but it's so small it's hardly + * worth worrying about. + */ + emit_dac(cinfo); + } else { + /* Emit Huffman tables. + * Note that emit_dht() suppresses any duplicate tables. + */ + for (i = 0; i < cinfo->comps_in_scan; i++) { + compptr = cinfo->cur_comp_info[i]; + if (cinfo->progressive_mode) { + /* Progressive mode: only DC or only AC tables are used in one scan */ + if (cinfo->Ss == 0) { + if (cinfo->Ah == 0) /* DC needs no table for refinement scan */ + emit_dht(cinfo, compptr->dc_tbl_no, FALSE); + } else { + emit_dht(cinfo, compptr->ac_tbl_no, TRUE); + } + } else { + /* Sequential mode: need both DC and AC tables */ + emit_dht(cinfo, compptr->dc_tbl_no, FALSE); + emit_dht(cinfo, compptr->ac_tbl_no, TRUE); + } + } + } + + /* Emit DRI if required --- note that DRI value could change for each scan. + * We avoid wasting space with unnecessary DRIs, however. + */ + if (cinfo->restart_interval != marker->last_restart_interval) { + emit_dri(cinfo); + marker->last_restart_interval = cinfo->restart_interval; + } + + emit_sos(cinfo); +} + + +/* + * Write datastream trailer. + */ + +METHODDEF(void) +write_file_trailer (j_compress_ptr cinfo) +{ + emit_marker(cinfo, M_EOI); +} + + +/* + * Write an abbreviated table-specification datastream. + * This consists of SOI, DQT and DHT tables, and EOI. + * Any table that is defined and not marked sent_table = TRUE will be + * emitted. Note that all tables will be marked sent_table = TRUE at exit. + */ + +METHODDEF(void) +write_tables_only (j_compress_ptr cinfo) +{ + int i; + + emit_marker(cinfo, M_SOI); + + for (i = 0; i < NUM_QUANT_TBLS; i++) { + if (cinfo->quant_tbl_ptrs[i] != NULL) + (void) emit_dqt(cinfo, i); + } + + if (! cinfo->arith_code) { + for (i = 0; i < NUM_HUFF_TBLS; i++) { + if (cinfo->dc_huff_tbl_ptrs[i] != NULL) + emit_dht(cinfo, i, FALSE); + if (cinfo->ac_huff_tbl_ptrs[i] != NULL) + emit_dht(cinfo, i, TRUE); + } + } + + emit_marker(cinfo, M_EOI); +} + + +/* + * Initialize the marker writer module. + */ + +GLOBAL(void) +jinit_marker_writer (j_compress_ptr cinfo) +{ + my_marker_ptr marker; + + /* Create the subobject */ + marker = (my_marker_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_marker_writer)); + cinfo->marker = (struct jpeg_marker_writer *) marker; + /* Initialize method pointers */ + marker->pub.write_file_header = write_file_header; + marker->pub.write_frame_header = write_frame_header; + marker->pub.write_scan_header = write_scan_header; + marker->pub.write_file_trailer = write_file_trailer; + marker->pub.write_tables_only = write_tables_only; + marker->pub.write_marker_header = write_marker_header; + marker->pub.write_marker_byte = write_marker_byte; + /* Initialize private state */ + marker->last_restart_interval = 0; +} diff --git a/src/dep/src/irrlicht/jpeglib/jcmaster.c b/src/dep/src/irrlicht/jpeglib/jcmaster.c index e61138b..aab4020 100644 --- a/src/dep/src/irrlicht/jpeglib/jcmaster.c +++ b/src/dep/src/irrlicht/jpeglib/jcmaster.c @@ -1,590 +1,590 @@ -/* - * jcmaster.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains master control logic for the JPEG compressor. - * These routines are concerned with parameter validation, initial setup, - * and inter-pass control (determining the number of passes and the work - * to be done in each pass). - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef enum { - main_pass, /* input data, also do first output step */ - huff_opt_pass, /* Huffman code optimization pass */ - output_pass /* data output pass */ -} c_pass_type; - -typedef struct { - struct jpeg_comp_master pub; /* public fields */ - - c_pass_type pass_type; /* the type of the current pass */ - - int pass_number; /* # of passes completed */ - int total_passes; /* total # of passes needed */ - - int scan_number; /* current index in scan_info[] */ -} my_comp_master; - -typedef my_comp_master * my_master_ptr; - - -/* - * Support routines that do various essential calculations. - */ - -LOCAL(void) -initial_setup (j_compress_ptr cinfo) -/* Do computations that are needed before master selection phase */ -{ - int ci; - jpeg_component_info *compptr; - long samplesperrow; - JDIMENSION jd_samplesperrow; - - /* Sanity check on image dimensions */ - if (cinfo->image_height <= 0 || cinfo->image_width <= 0 - || cinfo->num_components <= 0 || cinfo->input_components <= 0) - ERREXIT(cinfo, JERR_EMPTY_IMAGE); - - /* Make sure image isn't bigger than I can handle */ - if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || - (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); - - /* Width of an input scanline must be representable as JDIMENSION. */ - samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components; - jd_samplesperrow = (JDIMENSION) samplesperrow; - if ((long) jd_samplesperrow != samplesperrow) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - - /* For now, precision must match compiled-in value... */ - if (cinfo->data_precision != BITS_IN_JSAMPLE) - ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); - - /* Check that number of components won't exceed internal array sizes */ - if (cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - - /* Compute maximum sampling factors; check factor validity */ - cinfo->max_h_samp_factor = 1; - cinfo->max_v_samp_factor = 1; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || - compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) - ERREXIT(cinfo, JERR_BAD_SAMPLING); - cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, - compptr->h_samp_factor); - cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, - compptr->v_samp_factor); - } - - /* Compute dimensions of components */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Fill in the correct component_index value; don't rely on application */ - compptr->component_index = ci; - /* For compression, we never do DCT scaling. */ - compptr->DCT_scaled_size = DCTSIZE; - /* Size in DCT blocks */ - compptr->width_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->height_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - /* Size in samples */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) cinfo->max_h_samp_factor); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) cinfo->max_v_samp_factor); - /* Mark component needed (this flag isn't actually used for compression) */ - compptr->component_needed = TRUE; - } - - /* Compute number of fully interleaved MCU rows (number of times that - * main controller will call coefficient controller). - */ - cinfo->total_iMCU_rows = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); -} - - -#ifdef C_MULTISCAN_FILES_SUPPORTED - -LOCAL(void) -validate_script (j_compress_ptr cinfo) -/* Verify that the scan script in cinfo->scan_info[] is valid; also - * determine whether it uses progressive JPEG, and set cinfo->progressive_mode. - */ -{ - const jpeg_scan_info * scanptr; - int scanno, ncomps, ci, coefi, thisi; - int Ss, Se, Ah, Al; - boolean component_sent[MAX_COMPONENTS]; -#ifdef C_PROGRESSIVE_SUPPORTED - int * last_bitpos_ptr; - int last_bitpos[MAX_COMPONENTS][DCTSIZE2]; - /* -1 until that coefficient has been seen; then last Al for it */ -#endif - - if (cinfo->num_scans <= 0) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0); - - /* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1; - * for progressive JPEG, no scan can have this. - */ - scanptr = cinfo->scan_info; - if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) { -#ifdef C_PROGRESSIVE_SUPPORTED - cinfo->progressive_mode = TRUE; - last_bitpos_ptr = & last_bitpos[0][0]; - for (ci = 0; ci < cinfo->num_components; ci++) - for (coefi = 0; coefi < DCTSIZE2; coefi++) - *last_bitpos_ptr++ = -1; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - cinfo->progressive_mode = FALSE; - for (ci = 0; ci < cinfo->num_components; ci++) - component_sent[ci] = FALSE; - } - - for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) { - /* Validate component indexes */ - ncomps = scanptr->comps_in_scan; - if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_COMPS_IN_SCAN); - for (ci = 0; ci < ncomps; ci++) { - thisi = scanptr->component_index[ci]; - if (thisi < 0 || thisi >= cinfo->num_components) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - /* Components must appear in SOF order within each scan */ - if (ci > 0 && thisi <= scanptr->component_index[ci-1]) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - } - /* Validate progression parameters */ - Ss = scanptr->Ss; - Se = scanptr->Se; - Ah = scanptr->Ah; - Al = scanptr->Al; - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - /* The JPEG spec simply gives the ranges 0..13 for Ah and Al, but that - * seems wrong: the upper bound ought to depend on data precision. - * Perhaps they really meant 0..N+1 for N-bit precision. - * Here we allow 0..10 for 8-bit data; Al larger than 10 results in - * out-of-range reconstructed DC values during the first DC scan, - * which might cause problems for some decoders. - */ -#if BITS_IN_JSAMPLE == 8 -#define MAX_AH_AL 10 -#else -#define MAX_AH_AL 13 -#endif - if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 || - Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - if (Ss == 0) { - if (Se != 0) /* DC and AC together not OK */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } else { - if (ncomps != 1) /* AC scans must be for only one component */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } - for (ci = 0; ci < ncomps; ci++) { - last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0]; - if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - for (coefi = Ss; coefi <= Se; coefi++) { - if (last_bitpos_ptr[coefi] < 0) { - /* first scan of this coefficient */ - if (Ah != 0) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } else { - /* not first scan */ - if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } - last_bitpos_ptr[coefi] = Al; - } - } -#endif - } else { - /* For sequential JPEG, all progression parameters must be these: */ - if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - /* Make sure components are not sent twice */ - for (ci = 0; ci < ncomps; ci++) { - thisi = scanptr->component_index[ci]; - if (component_sent[thisi]) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - component_sent[thisi] = TRUE; - } - } - } - - /* Now verify that everything got sent. */ - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - /* For progressive mode, we only check that at least some DC data - * got sent for each component; the spec does not require that all bits - * of all coefficients be transmitted. Would it be wiser to enforce - * transmission of all coefficient bits?? - */ - for (ci = 0; ci < cinfo->num_components; ci++) { - if (last_bitpos[ci][0] < 0) - ERREXIT(cinfo, JERR_MISSING_DATA); - } -#endif - } else { - for (ci = 0; ci < cinfo->num_components; ci++) { - if (! component_sent[ci]) - ERREXIT(cinfo, JERR_MISSING_DATA); - } - } -} - -#endif /* C_MULTISCAN_FILES_SUPPORTED */ - - -LOCAL(void) -select_scan_parameters (j_compress_ptr cinfo) -/* Set up the scan parameters for the current scan */ -{ - int ci; - -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (cinfo->scan_info != NULL) { - /* Prepare for current scan --- the script is already validated */ - my_master_ptr master = (my_master_ptr) cinfo->master; - const jpeg_scan_info * scanptr = cinfo->scan_info + master->scan_number; - - cinfo->comps_in_scan = scanptr->comps_in_scan; - for (ci = 0; ci < scanptr->comps_in_scan; ci++) { - cinfo->cur_comp_info[ci] = - &cinfo->comp_info[scanptr->component_index[ci]]; - } - cinfo->Ss = scanptr->Ss; - cinfo->Se = scanptr->Se; - cinfo->Ah = scanptr->Ah; - cinfo->Al = scanptr->Al; - } - else -#endif - { - /* Prepare for single sequential-JPEG scan containing all components */ - if (cinfo->num_components > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPS_IN_SCAN); - cinfo->comps_in_scan = cinfo->num_components; - for (ci = 0; ci < cinfo->num_components; ci++) { - cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci]; - } - cinfo->Ss = 0; - cinfo->Se = DCTSIZE2-1; - cinfo->Ah = 0; - cinfo->Al = 0; - } -} - - -LOCAL(void) -per_scan_setup (j_compress_ptr cinfo) -/* Do computations that are needed before processing a JPEG scan */ -/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */ -{ - int ci, mcublks, tmp; - jpeg_component_info *compptr; - - if (cinfo->comps_in_scan == 1) { - - /* Noninterleaved (single-component) scan */ - compptr = cinfo->cur_comp_info[0]; - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = compptr->width_in_blocks; - cinfo->MCU_rows_in_scan = compptr->height_in_blocks; - - /* For noninterleaved scan, always one block per MCU */ - compptr->MCU_width = 1; - compptr->MCU_height = 1; - compptr->MCU_blocks = 1; - compptr->MCU_sample_width = DCTSIZE; - compptr->last_col_width = 1; - /* For noninterleaved scans, it is convenient to define last_row_height - * as the number of block rows present in the last iMCU row. - */ - tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (tmp == 0) tmp = compptr->v_samp_factor; - compptr->last_row_height = tmp; - - /* Prepare array describing MCU composition */ - cinfo->blocks_in_MCU = 1; - cinfo->MCU_membership[0] = 0; - - } else { - - /* Interleaved (multi-component) scan */ - if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, - MAX_COMPS_IN_SCAN); - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, - (long) (cinfo->max_h_samp_factor*DCTSIZE)); - cinfo->MCU_rows_in_scan = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - cinfo->blocks_in_MCU = 0; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Sampling factors give # of blocks of component in each MCU */ - compptr->MCU_width = compptr->h_samp_factor; - compptr->MCU_height = compptr->v_samp_factor; - compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; - compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE; - /* Figure number of non-dummy blocks in last MCU column & row */ - tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); - if (tmp == 0) tmp = compptr->MCU_width; - compptr->last_col_width = tmp; - tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); - if (tmp == 0) tmp = compptr->MCU_height; - compptr->last_row_height = tmp; - /* Prepare array describing MCU composition */ - mcublks = compptr->MCU_blocks; - if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU) - ERREXIT(cinfo, JERR_BAD_MCU_SIZE); - while (mcublks-- > 0) { - cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; - } - } - - } - - /* Convert restart specified in rows to actual MCU count. */ - /* Note that count must fit in 16 bits, so we provide limiting. */ - if (cinfo->restart_in_rows > 0) { - long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row; - cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L); - } -} - - -/* - * Per-pass setup. - * This is called at the beginning of each pass. We determine which modules - * will be active during this pass and give them appropriate start_pass calls. - * We also set is_last_pass to indicate whether any more passes will be - * required. - */ - -METHODDEF(void) -prepare_for_pass (j_compress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - switch (master->pass_type) { - case main_pass: - /* Initial pass: will collect input data, and do either Huffman - * optimization or data output for the first scan. - */ - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - if (! cinfo->raw_data_in) { - (*cinfo->cconvert->start_pass) (cinfo); - (*cinfo->downsample->start_pass) (cinfo); - (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU); - } - (*cinfo->fdct->start_pass) (cinfo); - (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding); - (*cinfo->coef->start_pass) (cinfo, - (master->total_passes > 1 ? - JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); - (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); - if (cinfo->optimize_coding) { - /* No immediate data output; postpone writing frame/scan headers */ - master->pub.call_pass_startup = FALSE; - } else { - /* Will write frame/scan headers at first jpeg_write_scanlines call */ - master->pub.call_pass_startup = TRUE; - } - break; -#ifdef ENTROPY_OPT_SUPPORTED - case huff_opt_pass: - /* Do Huffman optimization for a scan after the first one. */ - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code) { - (*cinfo->entropy->start_pass) (cinfo, TRUE); - (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); - master->pub.call_pass_startup = FALSE; - break; - } - /* Special case: Huffman DC refinement scans need no Huffman table - * and therefore we can skip the optimization pass for them. - */ - master->pass_type = output_pass; - master->pass_number++; - /*FALLTHROUGH*/ -#endif - case output_pass: - /* Do a data-output pass. */ - /* We need not repeat per-scan setup if prior optimization pass did it. */ - if (! cinfo->optimize_coding) { - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - } - (*cinfo->entropy->start_pass) (cinfo, FALSE); - (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); - /* We emit frame/scan headers now */ - if (master->scan_number == 0) - (*cinfo->marker->write_frame_header) (cinfo); - (*cinfo->marker->write_scan_header) (cinfo); - master->pub.call_pass_startup = FALSE; - break; - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - } - - master->pub.is_last_pass = (master->pass_number == master->total_passes-1); - - /* Set up progress monitor's pass info if present */ - if (cinfo->progress != NULL) { - cinfo->progress->completed_passes = master->pass_number; - cinfo->progress->total_passes = master->total_passes; - } -} - - -/* - * Special start-of-pass hook. - * This is called by jpeg_write_scanlines if call_pass_startup is TRUE. - * In single-pass processing, we need this hook because we don't want to - * write frame/scan headers during jpeg_start_compress; we want to let the - * application write COM markers etc. between jpeg_start_compress and the - * jpeg_write_scanlines loop. - * In multi-pass processing, this routine is not used. - */ - -METHODDEF(void) -pass_startup (j_compress_ptr cinfo) -{ - cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */ - - (*cinfo->marker->write_frame_header) (cinfo); - (*cinfo->marker->write_scan_header) (cinfo); -} - - -/* - * Finish up at end of pass. - */ - -METHODDEF(void) -finish_pass_master (j_compress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - /* The entropy coder always needs an end-of-pass call, - * either to analyze statistics or to flush its output buffer. - */ - (*cinfo->entropy->finish_pass) (cinfo); - - /* Update state for next pass */ - switch (master->pass_type) { - case main_pass: - /* next pass is either output of scan 0 (after optimization) - * or output of scan 1 (if no optimization). - */ - master->pass_type = output_pass; - if (! cinfo->optimize_coding) - master->scan_number++; - break; - case huff_opt_pass: - /* next pass is always output of current scan */ - master->pass_type = output_pass; - break; - case output_pass: - /* next pass is either optimization or output of next scan */ - if (cinfo->optimize_coding) - master->pass_type = huff_opt_pass; - master->scan_number++; - break; - } - - master->pass_number++; -} - - -/* - * Initialize master compression control. - */ - -GLOBAL(void) -jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only) -{ - my_master_ptr master; - - master = (my_master_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_comp_master)); - cinfo->master = (struct jpeg_comp_master *) master; - master->pub.prepare_for_pass = prepare_for_pass; - master->pub.pass_startup = pass_startup; - master->pub.finish_pass = finish_pass_master; - master->pub.is_last_pass = FALSE; - - /* Validate parameters, determine derived values */ - initial_setup(cinfo); - - if (cinfo->scan_info != NULL) { -#ifdef C_MULTISCAN_FILES_SUPPORTED - validate_script(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - cinfo->progressive_mode = FALSE; - cinfo->num_scans = 1; - } - - if (cinfo->progressive_mode) /* TEMPORARY HACK ??? */ - cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */ - - /* Initialize my private state */ - if (transcode_only) { - /* no main pass in transcoding */ - if (cinfo->optimize_coding) - master->pass_type = huff_opt_pass; - else - master->pass_type = output_pass; - } else { - /* for normal compression, first pass is always this type: */ - master->pass_type = main_pass; - } - master->scan_number = 0; - master->pass_number = 0; - if (cinfo->optimize_coding) - master->total_passes = cinfo->num_scans * 2; - else - master->total_passes = cinfo->num_scans; -} +/* + * jcmaster.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains master control logic for the JPEG compressor. + * These routines are concerned with parameter validation, initial setup, + * and inter-pass control (determining the number of passes and the work + * to be done in each pass). + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private state */ + +typedef enum { + main_pass, /* input data, also do first output step */ + huff_opt_pass, /* Huffman code optimization pass */ + output_pass /* data output pass */ +} c_pass_type; + +typedef struct { + struct jpeg_comp_master pub; /* public fields */ + + c_pass_type pass_type; /* the type of the current pass */ + + int pass_number; /* # of passes completed */ + int total_passes; /* total # of passes needed */ + + int scan_number; /* current index in scan_info[] */ +} my_comp_master; + +typedef my_comp_master * my_master_ptr; + + +/* + * Support routines that do various essential calculations. + */ + +LOCAL(void) +initial_setup (j_compress_ptr cinfo) +/* Do computations that are needed before master selection phase */ +{ + int ci; + jpeg_component_info *compptr; + long samplesperrow; + JDIMENSION jd_samplesperrow; + + /* Sanity check on image dimensions */ + if (cinfo->image_height <= 0 || cinfo->image_width <= 0 + || cinfo->num_components <= 0 || cinfo->input_components <= 0) + ERREXIT(cinfo, JERR_EMPTY_IMAGE); + + /* Make sure image isn't bigger than I can handle */ + if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || + (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) + ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); + + /* Width of an input scanline must be representable as JDIMENSION. */ + samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components; + jd_samplesperrow = (JDIMENSION) samplesperrow; + if ((long) jd_samplesperrow != samplesperrow) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + + /* For now, precision must match compiled-in value... */ + if (cinfo->data_precision != BITS_IN_JSAMPLE) + ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); + + /* Check that number of components won't exceed internal array sizes */ + if (cinfo->num_components > MAX_COMPONENTS) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPONENTS); + + /* Compute maximum sampling factors; check factor validity */ + cinfo->max_h_samp_factor = 1; + cinfo->max_v_samp_factor = 1; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || + compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) + ERREXIT(cinfo, JERR_BAD_SAMPLING); + cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, + compptr->h_samp_factor); + cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, + compptr->v_samp_factor); + } + + /* Compute dimensions of components */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Fill in the correct component_index value; don't rely on application */ + compptr->component_index = ci; + /* For compression, we never do DCT scaling. */ + compptr->DCT_scaled_size = DCTSIZE; + /* Size in DCT blocks */ + compptr->width_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, + (long) (cinfo->max_h_samp_factor * DCTSIZE)); + compptr->height_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, + (long) (cinfo->max_v_samp_factor * DCTSIZE)); + /* Size in samples */ + compptr->downsampled_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, + (long) cinfo->max_h_samp_factor); + compptr->downsampled_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, + (long) cinfo->max_v_samp_factor); + /* Mark component needed (this flag isn't actually used for compression) */ + compptr->component_needed = TRUE; + } + + /* Compute number of fully interleaved MCU rows (number of times that + * main controller will call coefficient controller). + */ + cinfo->total_iMCU_rows = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, + (long) (cinfo->max_v_samp_factor*DCTSIZE)); +} + + +#ifdef C_MULTISCAN_FILES_SUPPORTED + +LOCAL(void) +validate_script (j_compress_ptr cinfo) +/* Verify that the scan script in cinfo->scan_info[] is valid; also + * determine whether it uses progressive JPEG, and set cinfo->progressive_mode. + */ +{ + const jpeg_scan_info * scanptr; + int scanno, ncomps, ci, coefi, thisi; + int Ss, Se, Ah, Al; + boolean component_sent[MAX_COMPONENTS]; +#ifdef C_PROGRESSIVE_SUPPORTED + int * last_bitpos_ptr; + int last_bitpos[MAX_COMPONENTS][DCTSIZE2]; + /* -1 until that coefficient has been seen; then last Al for it */ +#endif + + if (cinfo->num_scans <= 0) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0); + + /* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1; + * for progressive JPEG, no scan can have this. + */ + scanptr = cinfo->scan_info; + if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) { +#ifdef C_PROGRESSIVE_SUPPORTED + cinfo->progressive_mode = TRUE; + last_bitpos_ptr = & last_bitpos[0][0]; + for (ci = 0; ci < cinfo->num_components; ci++) + for (coefi = 0; coefi < DCTSIZE2; coefi++) + *last_bitpos_ptr++ = -1; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + cinfo->progressive_mode = FALSE; + for (ci = 0; ci < cinfo->num_components; ci++) + component_sent[ci] = FALSE; + } + + for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) { + /* Validate component indexes */ + ncomps = scanptr->comps_in_scan; + if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_COMPS_IN_SCAN); + for (ci = 0; ci < ncomps; ci++) { + thisi = scanptr->component_index[ci]; + if (thisi < 0 || thisi >= cinfo->num_components) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); + /* Components must appear in SOF order within each scan */ + if (ci > 0 && thisi <= scanptr->component_index[ci-1]) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); + } + /* Validate progression parameters */ + Ss = scanptr->Ss; + Se = scanptr->Se; + Ah = scanptr->Ah; + Al = scanptr->Al; + if (cinfo->progressive_mode) { +#ifdef C_PROGRESSIVE_SUPPORTED + /* The JPEG spec simply gives the ranges 0..13 for Ah and Al, but that + * seems wrong: the upper bound ought to depend on data precision. + * Perhaps they really meant 0..N+1 for N-bit precision. + * Here we allow 0..10 for 8-bit data; Al larger than 10 results in + * out-of-range reconstructed DC values during the first DC scan, + * which might cause problems for some decoders. + */ +#if BITS_IN_JSAMPLE == 8 +#define MAX_AH_AL 10 +#else +#define MAX_AH_AL 13 +#endif + if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 || + Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + if (Ss == 0) { + if (Se != 0) /* DC and AC together not OK */ + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } else { + if (ncomps != 1) /* AC scans must be for only one component */ + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } + for (ci = 0; ci < ncomps; ci++) { + last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0]; + if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */ + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + for (coefi = Ss; coefi <= Se; coefi++) { + if (last_bitpos_ptr[coefi] < 0) { + /* first scan of this coefficient */ + if (Ah != 0) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } else { + /* not first scan */ + if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } + last_bitpos_ptr[coefi] = Al; + } + } +#endif + } else { + /* For sequential JPEG, all progression parameters must be these: */ + if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + /* Make sure components are not sent twice */ + for (ci = 0; ci < ncomps; ci++) { + thisi = scanptr->component_index[ci]; + if (component_sent[thisi]) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); + component_sent[thisi] = TRUE; + } + } + } + + /* Now verify that everything got sent. */ + if (cinfo->progressive_mode) { +#ifdef C_PROGRESSIVE_SUPPORTED + /* For progressive mode, we only check that at least some DC data + * got sent for each component; the spec does not require that all bits + * of all coefficients be transmitted. Would it be wiser to enforce + * transmission of all coefficient bits?? + */ + for (ci = 0; ci < cinfo->num_components; ci++) { + if (last_bitpos[ci][0] < 0) + ERREXIT(cinfo, JERR_MISSING_DATA); + } +#endif + } else { + for (ci = 0; ci < cinfo->num_components; ci++) { + if (! component_sent[ci]) + ERREXIT(cinfo, JERR_MISSING_DATA); + } + } +} + +#endif /* C_MULTISCAN_FILES_SUPPORTED */ + + +LOCAL(void) +select_scan_parameters (j_compress_ptr cinfo) +/* Set up the scan parameters for the current scan */ +{ + int ci; + +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (cinfo->scan_info != NULL) { + /* Prepare for current scan --- the script is already validated */ + my_master_ptr master = (my_master_ptr) cinfo->master; + const jpeg_scan_info * scanptr = cinfo->scan_info + master->scan_number; + + cinfo->comps_in_scan = scanptr->comps_in_scan; + for (ci = 0; ci < scanptr->comps_in_scan; ci++) { + cinfo->cur_comp_info[ci] = + &cinfo->comp_info[scanptr->component_index[ci]]; + } + cinfo->Ss = scanptr->Ss; + cinfo->Se = scanptr->Se; + cinfo->Ah = scanptr->Ah; + cinfo->Al = scanptr->Al; + } + else +#endif + { + /* Prepare for single sequential-JPEG scan containing all components */ + if (cinfo->num_components > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPS_IN_SCAN); + cinfo->comps_in_scan = cinfo->num_components; + for (ci = 0; ci < cinfo->num_components; ci++) { + cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci]; + } + cinfo->Ss = 0; + cinfo->Se = DCTSIZE2-1; + cinfo->Ah = 0; + cinfo->Al = 0; + } +} + + +LOCAL(void) +per_scan_setup (j_compress_ptr cinfo) +/* Do computations that are needed before processing a JPEG scan */ +/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */ +{ + int ci, mcublks, tmp; + jpeg_component_info *compptr; + + if (cinfo->comps_in_scan == 1) { + + /* Noninterleaved (single-component) scan */ + compptr = cinfo->cur_comp_info[0]; + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = compptr->width_in_blocks; + cinfo->MCU_rows_in_scan = compptr->height_in_blocks; + + /* For noninterleaved scan, always one block per MCU */ + compptr->MCU_width = 1; + compptr->MCU_height = 1; + compptr->MCU_blocks = 1; + compptr->MCU_sample_width = DCTSIZE; + compptr->last_col_width = 1; + /* For noninterleaved scans, it is convenient to define last_row_height + * as the number of block rows present in the last iMCU row. + */ + tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (tmp == 0) tmp = compptr->v_samp_factor; + compptr->last_row_height = tmp; + + /* Prepare array describing MCU composition */ + cinfo->blocks_in_MCU = 1; + cinfo->MCU_membership[0] = 0; + + } else { + + /* Interleaved (multi-component) scan */ + if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, + MAX_COMPS_IN_SCAN); + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, + (long) (cinfo->max_h_samp_factor*DCTSIZE)); + cinfo->MCU_rows_in_scan = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, + (long) (cinfo->max_v_samp_factor*DCTSIZE)); + + cinfo->blocks_in_MCU = 0; + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Sampling factors give # of blocks of component in each MCU */ + compptr->MCU_width = compptr->h_samp_factor; + compptr->MCU_height = compptr->v_samp_factor; + compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; + compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE; + /* Figure number of non-dummy blocks in last MCU column & row */ + tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); + if (tmp == 0) tmp = compptr->MCU_width; + compptr->last_col_width = tmp; + tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); + if (tmp == 0) tmp = compptr->MCU_height; + compptr->last_row_height = tmp; + /* Prepare array describing MCU composition */ + mcublks = compptr->MCU_blocks; + if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU) + ERREXIT(cinfo, JERR_BAD_MCU_SIZE); + while (mcublks-- > 0) { + cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; + } + } + + } + + /* Convert restart specified in rows to actual MCU count. */ + /* Note that count must fit in 16 bits, so we provide limiting. */ + if (cinfo->restart_in_rows > 0) { + long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row; + cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L); + } +} + + +/* + * Per-pass setup. + * This is called at the beginning of each pass. We determine which modules + * will be active during this pass and give them appropriate start_pass calls. + * We also set is_last_pass to indicate whether any more passes will be + * required. + */ + +METHODDEF(void) +prepare_for_pass (j_compress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + switch (master->pass_type) { + case main_pass: + /* Initial pass: will collect input data, and do either Huffman + * optimization or data output for the first scan. + */ + select_scan_parameters(cinfo); + per_scan_setup(cinfo); + if (! cinfo->raw_data_in) { + (*cinfo->cconvert->start_pass) (cinfo); + (*cinfo->downsample->start_pass) (cinfo); + (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU); + } + (*cinfo->fdct->start_pass) (cinfo); + (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding); + (*cinfo->coef->start_pass) (cinfo, + (master->total_passes > 1 ? + JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); + (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); + if (cinfo->optimize_coding) { + /* No immediate data output; postpone writing frame/scan headers */ + master->pub.call_pass_startup = FALSE; + } else { + /* Will write frame/scan headers at first jpeg_write_scanlines call */ + master->pub.call_pass_startup = TRUE; + } + break; +#ifdef ENTROPY_OPT_SUPPORTED + case huff_opt_pass: + /* Do Huffman optimization for a scan after the first one. */ + select_scan_parameters(cinfo); + per_scan_setup(cinfo); + if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code) { + (*cinfo->entropy->start_pass) (cinfo, TRUE); + (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); + master->pub.call_pass_startup = FALSE; + break; + } + /* Special case: Huffman DC refinement scans need no Huffman table + * and therefore we can skip the optimization pass for them. + */ + master->pass_type = output_pass; + master->pass_number++; + /*FALLTHROUGH*/ +#endif + case output_pass: + /* Do a data-output pass. */ + /* We need not repeat per-scan setup if prior optimization pass did it. */ + if (! cinfo->optimize_coding) { + select_scan_parameters(cinfo); + per_scan_setup(cinfo); + } + (*cinfo->entropy->start_pass) (cinfo, FALSE); + (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); + /* We emit frame/scan headers now */ + if (master->scan_number == 0) + (*cinfo->marker->write_frame_header) (cinfo); + (*cinfo->marker->write_scan_header) (cinfo); + master->pub.call_pass_startup = FALSE; + break; + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + } + + master->pub.is_last_pass = (master->pass_number == master->total_passes-1); + + /* Set up progress monitor's pass info if present */ + if (cinfo->progress != NULL) { + cinfo->progress->completed_passes = master->pass_number; + cinfo->progress->total_passes = master->total_passes; + } +} + + +/* + * Special start-of-pass hook. + * This is called by jpeg_write_scanlines if call_pass_startup is TRUE. + * In single-pass processing, we need this hook because we don't want to + * write frame/scan headers during jpeg_start_compress; we want to let the + * application write COM markers etc. between jpeg_start_compress and the + * jpeg_write_scanlines loop. + * In multi-pass processing, this routine is not used. + */ + +METHODDEF(void) +pass_startup (j_compress_ptr cinfo) +{ + cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */ + + (*cinfo->marker->write_frame_header) (cinfo); + (*cinfo->marker->write_scan_header) (cinfo); +} + + +/* + * Finish up at end of pass. + */ + +METHODDEF(void) +finish_pass_master (j_compress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + /* The entropy coder always needs an end-of-pass call, + * either to analyze statistics or to flush its output buffer. + */ + (*cinfo->entropy->finish_pass) (cinfo); + + /* Update state for next pass */ + switch (master->pass_type) { + case main_pass: + /* next pass is either output of scan 0 (after optimization) + * or output of scan 1 (if no optimization). + */ + master->pass_type = output_pass; + if (! cinfo->optimize_coding) + master->scan_number++; + break; + case huff_opt_pass: + /* next pass is always output of current scan */ + master->pass_type = output_pass; + break; + case output_pass: + /* next pass is either optimization or output of next scan */ + if (cinfo->optimize_coding) + master->pass_type = huff_opt_pass; + master->scan_number++; + break; + } + + master->pass_number++; +} + + +/* + * Initialize master compression control. + */ + +GLOBAL(void) +jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only) +{ + my_master_ptr master; + + master = (my_master_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_comp_master)); + cinfo->master = (struct jpeg_comp_master *) master; + master->pub.prepare_for_pass = prepare_for_pass; + master->pub.pass_startup = pass_startup; + master->pub.finish_pass = finish_pass_master; + master->pub.is_last_pass = FALSE; + + /* Validate parameters, determine derived values */ + initial_setup(cinfo); + + if (cinfo->scan_info != NULL) { +#ifdef C_MULTISCAN_FILES_SUPPORTED + validate_script(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + cinfo->progressive_mode = FALSE; + cinfo->num_scans = 1; + } + + if (cinfo->progressive_mode) /* TEMPORARY HACK ??? */ + cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */ + + /* Initialize my private state */ + if (transcode_only) { + /* no main pass in transcoding */ + if (cinfo->optimize_coding) + master->pass_type = huff_opt_pass; + else + master->pass_type = output_pass; + } else { + /* for normal compression, first pass is always this type: */ + master->pass_type = main_pass; + } + master->scan_number = 0; + master->pass_number = 0; + if (cinfo->optimize_coding) + master->total_passes = cinfo->num_scans * 2; + else + master->total_passes = cinfo->num_scans; +} diff --git a/src/dep/src/irrlicht/jpeglib/jcomapi.c b/src/dep/src/irrlicht/jpeglib/jcomapi.c index 1b1a340..9b1fa75 100644 --- a/src/dep/src/irrlicht/jpeglib/jcomapi.c +++ b/src/dep/src/irrlicht/jpeglib/jcomapi.c @@ -1,106 +1,106 @@ -/* - * jcomapi.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface routines that are used for both - * compression and decompression. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Abort processing of a JPEG compression or decompression operation, - * but don't destroy the object itself. - * - * For this, we merely clean up all the nonpermanent memory pools. - * Note that temp files (virtual arrays) are not allowed to belong to - * the permanent pool, so we will be able to close all temp files here. - * Closing a data source or destination, if necessary, is the application's - * responsibility. - */ - -GLOBAL(void) -jpeg_abort (j_common_ptr cinfo) -{ - int pool; - - /* Do nothing if called on a not-initialized or destroyed JPEG object. */ - if (cinfo->mem == NULL) - return; - - /* Releasing pools in reverse order might help avoid fragmentation - * with some (brain-damaged) malloc libraries. - */ - for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) { - (*cinfo->mem->free_pool) (cinfo, pool); - } - - /* Reset overall state for possible reuse of object */ - if (cinfo->is_decompressor) { - cinfo->global_state = DSTATE_START; - /* Try to keep application from accessing now-deleted marker list. - * A bit kludgy to do it here, but this is the most central place. - */ - ((j_decompress_ptr) cinfo)->marker_list = NULL; - } else { - cinfo->global_state = CSTATE_START; - } -} - - -/* - * Destruction of a JPEG object. - * - * Everything gets deallocated except the master jpeg_compress_struct itself - * and the error manager struct. Both of these are supplied by the application - * and must be freed, if necessary, by the application. (Often they are on - * the stack and so don't need to be freed anyway.) - * Closing a data source or destination, if necessary, is the application's - * responsibility. - */ - -GLOBAL(void) -jpeg_destroy (j_common_ptr cinfo) -{ - /* We need only tell the memory manager to release everything. */ - /* NB: mem pointer is NULL if memory mgr failed to initialize. */ - if (cinfo->mem != NULL) - (*cinfo->mem->self_destruct) (cinfo); - cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */ - cinfo->global_state = 0; /* mark it destroyed */ -} - - -/* - * Convenience routines for allocating quantization and Huffman tables. - * (Would jutils.c be a more reasonable place to put these?) - */ - -GLOBAL(JQUANT_TBL *) -jpeg_alloc_quant_table (j_common_ptr cinfo) -{ - JQUANT_TBL *tbl; - - tbl = (JQUANT_TBL *) - (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL)); - tbl->sent_table = FALSE; /* make sure this is false in any new table */ - return tbl; -} - - -GLOBAL(JHUFF_TBL *) -jpeg_alloc_huff_table (j_common_ptr cinfo) -{ - JHUFF_TBL *tbl; - - tbl = (JHUFF_TBL *) - (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL)); - tbl->sent_table = FALSE; /* make sure this is false in any new table */ - return tbl; -} +/* + * jcomapi.c + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface routines that are used for both + * compression and decompression. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Abort processing of a JPEG compression or decompression operation, + * but don't destroy the object itself. + * + * For this, we merely clean up all the nonpermanent memory pools. + * Note that temp files (virtual arrays) are not allowed to belong to + * the permanent pool, so we will be able to close all temp files here. + * Closing a data source or destination, if necessary, is the application's + * responsibility. + */ + +GLOBAL(void) +jpeg_abort (j_common_ptr cinfo) +{ + int pool; + + /* Do nothing if called on a not-initialized or destroyed JPEG object. */ + if (cinfo->mem == NULL) + return; + + /* Releasing pools in reverse order might help avoid fragmentation + * with some (brain-damaged) malloc libraries. + */ + for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) { + (*cinfo->mem->free_pool) (cinfo, pool); + } + + /* Reset overall state for possible reuse of object */ + if (cinfo->is_decompressor) { + cinfo->global_state = DSTATE_START; + /* Try to keep application from accessing now-deleted marker list. + * A bit kludgy to do it here, but this is the most central place. + */ + ((j_decompress_ptr) cinfo)->marker_list = NULL; + } else { + cinfo->global_state = CSTATE_START; + } +} + + +/* + * Destruction of a JPEG object. + * + * Everything gets deallocated except the master jpeg_compress_struct itself + * and the error manager struct. Both of these are supplied by the application + * and must be freed, if necessary, by the application. (Often they are on + * the stack and so don't need to be freed anyway.) + * Closing a data source or destination, if necessary, is the application's + * responsibility. + */ + +GLOBAL(void) +jpeg_destroy (j_common_ptr cinfo) +{ + /* We need only tell the memory manager to release everything. */ + /* NB: mem pointer is NULL if memory mgr failed to initialize. */ + if (cinfo->mem != NULL) + (*cinfo->mem->self_destruct) (cinfo); + cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */ + cinfo->global_state = 0; /* mark it destroyed */ +} + + +/* + * Convenience routines for allocating quantization and Huffman tables. + * (Would jutils.c be a more reasonable place to put these?) + */ + +GLOBAL(JQUANT_TBL *) +jpeg_alloc_quant_table (j_common_ptr cinfo) +{ + JQUANT_TBL *tbl; + + tbl = (JQUANT_TBL *) + (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL)); + tbl->sent_table = FALSE; /* make sure this is false in any new table */ + return tbl; +} + + +GLOBAL(JHUFF_TBL *) +jpeg_alloc_huff_table (j_common_ptr cinfo) +{ + JHUFF_TBL *tbl; + + tbl = (JHUFF_TBL *) + (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL)); + tbl->sent_table = FALSE; /* make sure this is false in any new table */ + return tbl; +} diff --git a/src/dep/src/irrlicht/jpeglib/jconfig.bcc b/src/dep/src/irrlicht/jpeglib/jconfig.bcc index 6538a0f..c6c53ff 100644 --- a/src/dep/src/irrlicht/jpeglib/jconfig.bcc +++ b/src/dep/src/irrlicht/jpeglib/jconfig.bcc @@ -1,48 +1,48 @@ -/* jconfig.bcc --- jconfig.h for Borland C (Turbo C) on MS-DOS or OS/2. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#ifdef __MSDOS__ -#define NEED_FAR_POINTERS /* for small or medium memory model */ -#endif -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN /* this assumes you have -w-stu in CFLAGS */ - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#ifdef __MSDOS__ -#define USE_MSDOS_MEMMGR /* Define this if you use jmemdos.c */ -#define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ -#define USE_FMEM /* Borland has _fmemcpy() and _fmemset() */ -#endif - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE -#define USE_SETMODE /* Borland has setmode() */ -#ifdef __MSDOS__ -#define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */ -#endif -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ +/* jconfig.bcc --- jconfig.h for Borland C (Turbo C) on MS-DOS or OS/2. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#ifdef __MSDOS__ +#define NEED_FAR_POINTERS /* for small or medium memory model */ +#endif +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN /* this assumes you have -w-stu in CFLAGS */ + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#ifdef __MSDOS__ +#define USE_MSDOS_MEMMGR /* Define this if you use jmemdos.c */ +#define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ +#define USE_FMEM /* Borland has _fmemcpy() and _fmemset() */ +#endif + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE +#define USE_SETMODE /* Borland has setmode() */ +#ifdef __MSDOS__ +#define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */ +#endif +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/src/dep/src/irrlicht/jpeglib/jconfig.cfg b/src/dep/src/irrlicht/jpeglib/jconfig.cfg index 5bc0113..36a04fa 100644 --- a/src/dep/src/irrlicht/jpeglib/jconfig.cfg +++ b/src/dep/src/irrlicht/jpeglib/jconfig.cfg @@ -1,44 +1,44 @@ -/* jconfig.cfg --- source file edited by configure script */ -/* see jconfig.doc for explanations */ - -#undef HAVE_PROTOTYPES -#undef HAVE_UNSIGNED_CHAR -#undef HAVE_UNSIGNED_SHORT -#undef void -#undef const -#undef CHAR_IS_UNSIGNED -#undef HAVE_STDDEF_H -#undef HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -/* Define this if you get warnings about undefined structures. */ -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED -#undef INLINE -/* These are for configuring the JPEG memory manager. */ -#undef DEFAULT_MAX_MEM -#undef NO_MKTEMP - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#undef TWO_FILE_COMMANDLINE -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE - -/* Define this if you want percent-done progress reports from cjpeg/djpeg. */ -#undef PROGRESS_REPORT - -#endif /* JPEG_CJPEG_DJPEG */ +/* jconfig.cfg --- source file edited by configure script */ +/* see jconfig.doc for explanations */ + +#undef HAVE_PROTOTYPES +#undef HAVE_UNSIGNED_CHAR +#undef HAVE_UNSIGNED_SHORT +#undef void +#undef const +#undef CHAR_IS_UNSIGNED +#undef HAVE_STDDEF_H +#undef HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +/* Define this if you get warnings about undefined structures. */ +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED +#undef INLINE +/* These are for configuring the JPEG memory manager. */ +#undef DEFAULT_MAX_MEM +#undef NO_MKTEMP + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#undef TWO_FILE_COMMANDLINE +#undef NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE + +/* Define this if you want percent-done progress reports from cjpeg/djpeg. */ +#undef PROGRESS_REPORT + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/src/dep/src/irrlicht/jpeglib/jconfig.dj b/src/dep/src/irrlicht/jpeglib/jconfig.dj index 7cd1ed5..f759a9d 100644 --- a/src/dep/src/irrlicht/jpeglib/jconfig.dj +++ b/src/dep/src/irrlicht/jpeglib/jconfig.dj @@ -1,38 +1,38 @@ -/* jconfig.dj --- jconfig.h for DJGPP (Delorie's GNU C port) on MS-DOS. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS /* DJGPP uses flat 32-bit addressing */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#undef TWO_FILE_COMMANDLINE /* optional */ -#define USE_SETMODE /* Needed to make one-file style work in DJGPP */ -#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ +/* jconfig.dj --- jconfig.h for DJGPP (Delorie's GNU C port) on MS-DOS. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS /* DJGPP uses flat 32-bit addressing */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#undef TWO_FILE_COMMANDLINE /* optional */ +#define USE_SETMODE /* Needed to make one-file style work in DJGPP */ +#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/src/dep/src/irrlicht/jpeglib/jconfig.doc b/src/dep/src/irrlicht/jpeglib/jconfig.doc index 6e2552b..c18d1c0 100644 --- a/src/dep/src/irrlicht/jpeglib/jconfig.doc +++ b/src/dep/src/irrlicht/jpeglib/jconfig.doc @@ -1,155 +1,155 @@ -/* - * jconfig.doc - * - * Copyright (C) 1991-1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file documents the configuration options that are required to - * customize the JPEG software for a particular system. - * - * The actual configuration options for a particular installation are stored - * in jconfig.h. On many machines, jconfig.h can be generated automatically - * or copied from one of the "canned" jconfig files that we supply. But if - * you need to generate a jconfig.h file by hand, this file tells you how. - * - * DO NOT EDIT THIS FILE --- IT WON'T ACCOMPLISH ANYTHING. - * EDIT A COPY NAMED JCONFIG.H. - */ - - -/* - * These symbols indicate the properties of your machine or compiler. - * #define the symbol if yes, #undef it if no. - */ - -/* Does your compiler support function prototypes? - * (If not, you also need to use ansi2knr, see install.doc) - */ -#define HAVE_PROTOTYPES - -/* Does your compiler support the declaration "unsigned char" ? - * How about "unsigned short" ? - */ -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT - -/* Define "void" as "char" if your compiler doesn't know about type void. - * NOTE: be sure to define void such that "void *" represents the most general - * pointer type, e.g., that returned by malloc(). - */ -/* #define void char */ - -/* Define "const" as empty if your compiler doesn't know the "const" keyword. - */ -/* #define const */ - -/* Define this if an ordinary "char" type is unsigned. - * If you're not sure, leaving it undefined will work at some cost in speed. - * If you defined HAVE_UNSIGNED_CHAR then the speed difference is minimal. - */ -#undef CHAR_IS_UNSIGNED - -/* Define this if your system has an ANSI-conforming file. - */ -#define HAVE_STDDEF_H - -/* Define this if your system has an ANSI-conforming file. - */ -#define HAVE_STDLIB_H - -/* Define this if your system does not have an ANSI/SysV , - * but does have a BSD-style . - */ -#undef NEED_BSD_STRINGS - -/* Define this if your system does not provide typedef size_t in any of the - * ANSI-standard places (stddef.h, stdlib.h, or stdio.h), but places it in - * instead. - */ -#undef NEED_SYS_TYPES_H - -/* For 80x86 machines, you need to define NEED_FAR_POINTERS, - * unless you are using a large-data memory model or 80386 flat-memory mode. - * On less brain-damaged CPUs this symbol must not be defined. - * (Defining this symbol causes large data structures to be referenced through - * "far" pointers and to be allocated with a special version of malloc.) - */ -#undef NEED_FAR_POINTERS - -/* Define this if your linker needs global names to be unique in less - * than the first 15 characters. - */ -#undef NEED_SHORT_EXTERNAL_NAMES - -/* Although a real ANSI C compiler can deal perfectly well with pointers to - * unspecified structures (see "incomplete types" in the spec), a few pre-ANSI - * and pseudo-ANSI compilers get confused. To keep one of these bozos happy, - * define INCOMPLETE_TYPES_BROKEN. This is not recommended unless you - * actually get "missing structure definition" warnings or errors while - * compiling the JPEG code. - */ -#undef INCOMPLETE_TYPES_BROKEN - - -/* - * The following options affect code selection within the JPEG library, - * but they don't need to be visible to applications using the library. - * To minimize application namespace pollution, the symbols won't be - * defined unless JPEG_INTERNALS has been defined. - */ - -#ifdef JPEG_INTERNALS - -/* Define this if your compiler implements ">>" on signed values as a logical - * (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift, - * which is the normal and rational definition. - */ -#undef RIGHT_SHIFT_IS_UNSIGNED - - -#endif /* JPEG_INTERNALS */ - - -/* - * The remaining options do not affect the JPEG library proper, - * but only the sample applications cjpeg/djpeg (see cjpeg.c, djpeg.c). - * Other applications can ignore these. - */ - -#ifdef JPEG_CJPEG_DJPEG - -/* These defines indicate which image (non-JPEG) file formats are allowed. */ - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -/* Define this if you want to name both input and output files on the command - * line, rather than using stdout and optionally stdin. You MUST do this if - * your system can't cope with binary I/O to stdin/stdout. See comments at - * head of cjpeg.c or djpeg.c. - */ -#undef TWO_FILE_COMMANDLINE - -/* Define this if your system needs explicit cleanup of temporary files. - * This is crucial under MS-DOS, where the temporary "files" may be areas - * of extended memory; on most other systems it's not as important. - */ -#undef NEED_SIGNAL_CATCHER - -/* By default, we open image files with fopen(...,"rb") or fopen(...,"wb"). - * This is necessary on systems that distinguish text files from binary files, - * and is harmless on most systems that don't. If you have one of the rare - * systems that complains about the "b" spec, define this symbol. - */ -#undef DONT_USE_B_MODE - -/* Define this if you want percent-done progress reports from cjpeg/djpeg. - */ -#undef PROGRESS_REPORT - - -#endif /* JPEG_CJPEG_DJPEG */ +/* + * jconfig.doc + * + * Copyright (C) 1991-1994, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file documents the configuration options that are required to + * customize the JPEG software for a particular system. + * + * The actual configuration options for a particular installation are stored + * in jconfig.h. On many machines, jconfig.h can be generated automatically + * or copied from one of the "canned" jconfig files that we supply. But if + * you need to generate a jconfig.h file by hand, this file tells you how. + * + * DO NOT EDIT THIS FILE --- IT WON'T ACCOMPLISH ANYTHING. + * EDIT A COPY NAMED JCONFIG.H. + */ + + +/* + * These symbols indicate the properties of your machine or compiler. + * #define the symbol if yes, #undef it if no. + */ + +/* Does your compiler support function prototypes? + * (If not, you also need to use ansi2knr, see install.doc) + */ +#define HAVE_PROTOTYPES + +/* Does your compiler support the declaration "unsigned char" ? + * How about "unsigned short" ? + */ +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT + +/* Define "void" as "char" if your compiler doesn't know about type void. + * NOTE: be sure to define void such that "void *" represents the most general + * pointer type, e.g., that returned by malloc(). + */ +/* #define void char */ + +/* Define "const" as empty if your compiler doesn't know the "const" keyword. + */ +/* #define const */ + +/* Define this if an ordinary "char" type is unsigned. + * If you're not sure, leaving it undefined will work at some cost in speed. + * If you defined HAVE_UNSIGNED_CHAR then the speed difference is minimal. + */ +#undef CHAR_IS_UNSIGNED + +/* Define this if your system has an ANSI-conforming file. + */ +#define HAVE_STDDEF_H + +/* Define this if your system has an ANSI-conforming file. + */ +#define HAVE_STDLIB_H + +/* Define this if your system does not have an ANSI/SysV , + * but does have a BSD-style . + */ +#undef NEED_BSD_STRINGS + +/* Define this if your system does not provide typedef size_t in any of the + * ANSI-standard places (stddef.h, stdlib.h, or stdio.h), but places it in + * instead. + */ +#undef NEED_SYS_TYPES_H + +/* For 80x86 machines, you need to define NEED_FAR_POINTERS, + * unless you are using a large-data memory model or 80386 flat-memory mode. + * On less brain-damaged CPUs this symbol must not be defined. + * (Defining this symbol causes large data structures to be referenced through + * "far" pointers and to be allocated with a special version of malloc.) + */ +#undef NEED_FAR_POINTERS + +/* Define this if your linker needs global names to be unique in less + * than the first 15 characters. + */ +#undef NEED_SHORT_EXTERNAL_NAMES + +/* Although a real ANSI C compiler can deal perfectly well with pointers to + * unspecified structures (see "incomplete types" in the spec), a few pre-ANSI + * and pseudo-ANSI compilers get confused. To keep one of these bozos happy, + * define INCOMPLETE_TYPES_BROKEN. This is not recommended unless you + * actually get "missing structure definition" warnings or errors while + * compiling the JPEG code. + */ +#undef INCOMPLETE_TYPES_BROKEN + + +/* + * The following options affect code selection within the JPEG library, + * but they don't need to be visible to applications using the library. + * To minimize application namespace pollution, the symbols won't be + * defined unless JPEG_INTERNALS has been defined. + */ + +#ifdef JPEG_INTERNALS + +/* Define this if your compiler implements ">>" on signed values as a logical + * (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift, + * which is the normal and rational definition. + */ +#undef RIGHT_SHIFT_IS_UNSIGNED + + +#endif /* JPEG_INTERNALS */ + + +/* + * The remaining options do not affect the JPEG library proper, + * but only the sample applications cjpeg/djpeg (see cjpeg.c, djpeg.c). + * Other applications can ignore these. + */ + +#ifdef JPEG_CJPEG_DJPEG + +/* These defines indicate which image (non-JPEG) file formats are allowed. */ + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +/* Define this if you want to name both input and output files on the command + * line, rather than using stdout and optionally stdin. You MUST do this if + * your system can't cope with binary I/O to stdin/stdout. See comments at + * head of cjpeg.c or djpeg.c. + */ +#undef TWO_FILE_COMMANDLINE + +/* Define this if your system needs explicit cleanup of temporary files. + * This is crucial under MS-DOS, where the temporary "files" may be areas + * of extended memory; on most other systems it's not as important. + */ +#undef NEED_SIGNAL_CATCHER + +/* By default, we open image files with fopen(...,"rb") or fopen(...,"wb"). + * This is necessary on systems that distinguish text files from binary files, + * and is harmless on most systems that don't. If you have one of the rare + * systems that complains about the "b" spec, define this symbol. + */ +#undef DONT_USE_B_MODE + +/* Define this if you want percent-done progress reports from cjpeg/djpeg. + */ +#undef PROGRESS_REPORT + + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/src/dep/src/irrlicht/jpeglib/jconfig.h b/src/dep/src/irrlicht/jpeglib/jconfig.h index 2f4da14..7e291c7 100644 --- a/src/dep/src/irrlicht/jpeglib/jconfig.h +++ b/src/dep/src/irrlicht/jpeglib/jconfig.h @@ -1,45 +1,45 @@ -/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -/* Define "boolean" as unsigned char, not int, per Windows custom */ -#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ -typedef unsigned char boolean; -#endif -#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ - - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE /* optional */ -#define USE_SETMODE /* Microsoft has setmode() */ -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ +/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +/* Define "boolean" as unsigned char, not int, per Windows custom */ +#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ +typedef unsigned char boolean; +#endif +#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ + + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE /* optional */ +#define USE_SETMODE /* Microsoft has setmode() */ +#undef NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/src/dep/src/irrlicht/jpeglib/jconfig.mac b/src/dep/src/irrlicht/jpeglib/jconfig.mac index 1db67f5..0de3efe 100644 --- a/src/dep/src/irrlicht/jpeglib/jconfig.mac +++ b/src/dep/src/irrlicht/jpeglib/jconfig.mac @@ -1,43 +1,43 @@ -/* jconfig.mac --- jconfig.h for CodeWarrior on Apple Macintosh */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define USE_MAC_MEMMGR /* Define this if you use jmemmac.c */ - -#define ALIGN_TYPE long /* Needed for 680x0 Macs */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define USE_CCOMMAND /* Command line reader for Macintosh */ -#define TWO_FILE_COMMANDLINE /* Binary I/O thru stdin/stdout doesn't work */ - -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ +/* jconfig.mac --- jconfig.h for CodeWarrior on Apple Macintosh */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#define USE_MAC_MEMMGR /* Define this if you use jmemmac.c */ + +#define ALIGN_TYPE long /* Needed for 680x0 Macs */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define USE_CCOMMAND /* Command line reader for Macintosh */ +#define TWO_FILE_COMMANDLINE /* Binary I/O thru stdin/stdout doesn't work */ + +#undef NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/src/dep/src/irrlicht/jpeglib/jconfig.manx b/src/dep/src/irrlicht/jpeglib/jconfig.manx index 0dbd0b8..6dd0d00 100644 --- a/src/dep/src/irrlicht/jpeglib/jconfig.manx +++ b/src/dep/src/irrlicht/jpeglib/jconfig.manx @@ -1,43 +1,43 @@ -/* jconfig.manx --- jconfig.h for Amiga systems using Manx Aztec C ver 5.x. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define TEMP_DIRECTORY "JPEGTMP:" /* recommended setting for Amiga */ - -#define SHORTxSHORT_32 /* produces better DCT code with Aztec C */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE -#define NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#define signal_catcher _abort /* hack for Aztec C naming requirements */ - -#endif /* JPEG_CJPEG_DJPEG */ +/* jconfig.manx --- jconfig.h for Amiga systems using Manx Aztec C ver 5.x. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#define TEMP_DIRECTORY "JPEGTMP:" /* recommended setting for Amiga */ + +#define SHORTxSHORT_32 /* produces better DCT code with Aztec C */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE +#define NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#define signal_catcher _abort /* hack for Aztec C naming requirements */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/src/dep/src/irrlicht/jpeglib/jconfig.mc6 b/src/dep/src/irrlicht/jpeglib/jconfig.mc6 index 5492365..c55082d 100644 --- a/src/dep/src/irrlicht/jpeglib/jconfig.mc6 +++ b/src/dep/src/irrlicht/jpeglib/jconfig.mc6 @@ -1,52 +1,52 @@ -/* jconfig.mc6 --- jconfig.h for Microsoft C on MS-DOS, version 6.00A & up. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#define NEED_FAR_POINTERS /* for small or medium memory model */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define USE_MSDOS_MEMMGR /* Define this if you use jmemdos.c */ - -#define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ - -#define USE_FMEM /* Microsoft has _fmemcpy() and _fmemset() */ - -#define NEED_FHEAPMIN /* far heap management routines are broken */ - -#define SHORTxLCONST_32 /* enable compiler-specific DCT optimization */ -/* Note: the above define is known to improve the code with Microsoft C 6.00A. - * I do not know whether it is good for later compiler versions. - * Please report any info on this point to jpeg-info@uunet.uu.net. - */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE -#define USE_SETMODE /* Microsoft has setmode() */ -#define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */ -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ +/* jconfig.mc6 --- jconfig.h for Microsoft C on MS-DOS, version 6.00A & up. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#define NEED_FAR_POINTERS /* for small or medium memory model */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#define USE_MSDOS_MEMMGR /* Define this if you use jmemdos.c */ + +#define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ + +#define USE_FMEM /* Microsoft has _fmemcpy() and _fmemset() */ + +#define NEED_FHEAPMIN /* far heap management routines are broken */ + +#define SHORTxLCONST_32 /* enable compiler-specific DCT optimization */ +/* Note: the above define is known to improve the code with Microsoft C 6.00A. + * I do not know whether it is good for later compiler versions. + * Please report any info on this point to jpeg-info@uunet.uu.net. + */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE +#define USE_SETMODE /* Microsoft has setmode() */ +#define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */ +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/src/dep/src/irrlicht/jpeglib/jconfig.sas b/src/dep/src/irrlicht/jpeglib/jconfig.sas index a802dd3..efdac22 100644 --- a/src/dep/src/irrlicht/jpeglib/jconfig.sas +++ b/src/dep/src/irrlicht/jpeglib/jconfig.sas @@ -1,43 +1,43 @@ -/* jconfig.sas --- jconfig.h for Amiga systems using SAS C 6.0 and up. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define TEMP_DIRECTORY "JPEGTMP:" /* recommended setting for Amiga */ - -#define NO_MKTEMP /* SAS C doesn't have mktemp() */ - -#define SHORTxSHORT_32 /* produces better DCT code with SAS C */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE -#define NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ +/* jconfig.sas --- jconfig.h for Amiga systems using SAS C 6.0 and up. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#define TEMP_DIRECTORY "JPEGTMP:" /* recommended setting for Amiga */ + +#define NO_MKTEMP /* SAS C doesn't have mktemp() */ + +#define SHORTxSHORT_32 /* produces better DCT code with SAS C */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE +#define NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/src/dep/src/irrlicht/jpeglib/jconfig.st b/src/dep/src/irrlicht/jpeglib/jconfig.st index 796b3c9..4421b7a 100644 --- a/src/dep/src/irrlicht/jpeglib/jconfig.st +++ b/src/dep/src/irrlicht/jpeglib/jconfig.st @@ -1,42 +1,42 @@ -/* jconfig.st --- jconfig.h for Atari ST/STE/TT using Pure C or Turbo C. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#define INCOMPLETE_TYPES_BROKEN /* suppress undefined-structure warnings */ - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define ALIGN_TYPE long /* apparently double is a weird size? */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE /* optional -- undef if you like Unix style */ -/* Note: if you undef TWO_FILE_COMMANDLINE, you may need to define - * USE_SETMODE. Some Atari compilers require it, some do not. - */ -#define NEED_SIGNAL_CATCHER /* needed if you use jmemname.c */ -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ +/* jconfig.st --- jconfig.h for Atari ST/STE/TT using Pure C or Turbo C. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +#define INCOMPLETE_TYPES_BROKEN /* suppress undefined-structure warnings */ + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#define ALIGN_TYPE long /* apparently double is a weird size? */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE /* optional -- undef if you like Unix style */ +/* Note: if you undef TWO_FILE_COMMANDLINE, you may need to define + * USE_SETMODE. Some Atari compilers require it, some do not. + */ +#define NEED_SIGNAL_CATCHER /* needed if you use jmemname.c */ +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/src/dep/src/irrlicht/jpeglib/jconfig.vc b/src/dep/src/irrlicht/jpeglib/jconfig.vc index 2f4da14..7e291c7 100644 --- a/src/dep/src/irrlicht/jpeglib/jconfig.vc +++ b/src/dep/src/irrlicht/jpeglib/jconfig.vc @@ -1,45 +1,45 @@ -/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -/* Define "boolean" as unsigned char, not int, per Windows custom */ -#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ -typedef unsigned char boolean; -#endif -#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ - - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE /* optional */ -#define USE_SETMODE /* Microsoft has setmode() */ -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ +/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +/* Define "boolean" as unsigned char, not int, per Windows custom */ +#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ +typedef unsigned char boolean; +#endif +#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ + + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE /* optional */ +#define USE_SETMODE /* Microsoft has setmode() */ +#undef NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/src/dep/src/irrlicht/jpeglib/jconfig.vms b/src/dep/src/irrlicht/jpeglib/jconfig.vms index eb582dc..55a6ffb 100644 --- a/src/dep/src/irrlicht/jpeglib/jconfig.vms +++ b/src/dep/src/irrlicht/jpeglib/jconfig.vms @@ -1,37 +1,37 @@ -/* jconfig.vms --- jconfig.h for use on Digital VMS. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE /* Needed on VMS */ -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ +/* jconfig.vms --- jconfig.h for use on Digital VMS. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE /* Needed on VMS */ +#undef NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/src/dep/src/irrlicht/jpeglib/jconfig.wat b/src/dep/src/irrlicht/jpeglib/jconfig.wat index d57ceb9..6cc545b 100644 --- a/src/dep/src/irrlicht/jpeglib/jconfig.wat +++ b/src/dep/src/irrlicht/jpeglib/jconfig.wat @@ -1,38 +1,38 @@ -/* jconfig.wat --- jconfig.h for Watcom C/C++ on MS-DOS or OS/2. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#define CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS /* Watcom uses flat 32-bit addressing */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#undef TWO_FILE_COMMANDLINE /* optional */ -#define USE_SETMODE /* Needed to make one-file style work in Watcom */ -#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ +/* jconfig.wat --- jconfig.h for Watcom C/C++ on MS-DOS or OS/2. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#define CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS /* Watcom uses flat 32-bit addressing */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#undef TWO_FILE_COMMANDLINE /* optional */ +#define USE_SETMODE /* Needed to make one-file style work in Watcom */ +#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/src/dep/src/irrlicht/jpeglib/jcparam.c b/src/dep/src/irrlicht/jpeglib/jcparam.c index bbd175c..6fc48f5 100644 --- a/src/dep/src/irrlicht/jpeglib/jcparam.c +++ b/src/dep/src/irrlicht/jpeglib/jcparam.c @@ -1,610 +1,610 @@ -/* - * jcparam.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains optional default-setting code for the JPEG compressor. - * Applications do not have to use this file, but those that don't use it - * must know a lot more about the innards of the JPEG code. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Quantization table setup routines - */ - -GLOBAL(void) -jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, boolean force_baseline) -/* Define a quantization table equal to the basic_table times - * a scale factor (given as a percentage). - * If force_baseline is TRUE, the computed quantization table entries - * are limited to 1..255 for JPEG baseline compatibility. - */ -{ - JQUANT_TBL ** qtblptr; - int i; - long temp; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (which_tbl < 0 || which_tbl >= NUM_QUANT_TBLS) - ERREXIT1(cinfo, JERR_DQT_INDEX, which_tbl); - - qtblptr = & cinfo->quant_tbl_ptrs[which_tbl]; - - if (*qtblptr == NULL) - *qtblptr = jpeg_alloc_quant_table((j_common_ptr) cinfo); - - for (i = 0; i < DCTSIZE2; i++) { - temp = ((long) basic_table[i] * scale_factor + 50L) / 100L; - /* limit the values to the valid range */ - if (temp <= 0L) temp = 1L; - if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */ - if (force_baseline && temp > 255L) - temp = 255L; /* limit to baseline range if requested */ - (*qtblptr)->quantval[i] = (UINT16) temp; - } - - /* Initialize sent_table FALSE so table will be written to JPEG file. */ - (*qtblptr)->sent_table = FALSE; -} - - -GLOBAL(void) -jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, - boolean force_baseline) -/* Set or change the 'quality' (quantization) setting, using default tables - * and a straight percentage-scaling quality scale. In most cases it's better - * to use jpeg_set_quality (below); this entry point is provided for - * applications that insist on a linear percentage scaling. - */ -{ - /* These are the sample quantization tables given in JPEG spec section K.1. - * The spec says that the values given produce "good" quality, and - * when divided by 2, "very good" quality. - */ - static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = { - 16, 11, 10, 16, 24, 40, 51, 61, - 12, 12, 14, 19, 26, 58, 60, 55, - 14, 13, 16, 24, 40, 57, 69, 56, - 14, 17, 22, 29, 51, 87, 80, 62, - 18, 22, 37, 56, 68, 109, 103, 77, - 24, 35, 55, 64, 81, 104, 113, 92, - 49, 64, 78, 87, 103, 121, 120, 101, - 72, 92, 95, 98, 112, 100, 103, 99 - }; - static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = { - 17, 18, 24, 47, 99, 99, 99, 99, - 18, 21, 26, 66, 99, 99, 99, 99, - 24, 26, 56, 99, 99, 99, 99, 99, - 47, 66, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99 - }; - - /* Set up two quantization tables using the specified scaling */ - jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, - scale_factor, force_baseline); - jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl, - scale_factor, force_baseline); -} - - -GLOBAL(int) -jpeg_quality_scaling (int quality) -/* Convert a user-specified quality rating to a percentage scaling factor - * for an underlying quantization table, using our recommended scaling curve. - * The input 'quality' factor should be 0 (terrible) to 100 (very good). - */ -{ - /* Safety limit on quality factor. Convert 0 to 1 to avoid zero divide. */ - if (quality <= 0) quality = 1; - if (quality > 100) quality = 100; - - /* The basic table is used as-is (scaling 100) for a quality of 50. - * Qualities 50..100 are converted to scaling percentage 200 - 2*Q; - * note that at Q=100 the scaling is 0, which will cause jpeg_add_quant_table - * to make all the table entries 1 (hence, minimum quantization loss). - * Qualities 1..50 are converted to scaling percentage 5000/Q. - */ - if (quality < 50) - quality = 5000 / quality; - else - quality = 200 - quality*2; - - return quality; -} - - -GLOBAL(void) -jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) -/* Set or change the 'quality' (quantization) setting, using default tables. - * This is the standard quality-adjusting entry point for typical user - * interfaces; only those who want detailed control over quantization tables - * would use the preceding three routines directly. - */ -{ - /* Convert user 0-100 rating to percentage scaling */ - quality = jpeg_quality_scaling(quality); - - /* Set up standard quality tables */ - jpeg_set_linear_quality(cinfo, quality, force_baseline); -} - - -/* - * Huffman table setup routines - */ - -LOCAL(void) -add_huff_table (j_compress_ptr cinfo, - JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) -/* Define a Huffman table */ -{ - int nsymbols, len; - - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - - /* Copy the number-of-symbols-of-each-code-length counts */ - MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); - - /* Validate the counts. We do this here mainly so we can copy the right - * number of symbols from the val[] array, without risking marching off - * the end of memory. jchuff.c will do a more thorough test later. - */ - nsymbols = 0; - for (len = 1; len <= 16; len++) - nsymbols += bits[len]; - if (nsymbols < 1 || nsymbols > 256) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - - MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8)); - - /* Initialize sent_table FALSE so table will be written to JPEG file. */ - (*htblptr)->sent_table = FALSE; -} - - -LOCAL(void) -std_huff_tables (j_compress_ptr cinfo) -/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */ -/* IMPORTANT: these are only valid for 8-bit data precision! */ -{ - static const UINT8 bits_dc_luminance[17] = - { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; - static const UINT8 val_dc_luminance[] = - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - - static const UINT8 bits_dc_chrominance[17] = - { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; - static const UINT8 val_dc_chrominance[] = - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - - static const UINT8 bits_ac_luminance[17] = - { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; - static const UINT8 val_ac_luminance[] = - { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, - 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, - 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, - 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, - 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, - 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, - 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, - 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, - 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, - 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, - 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, - 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, - 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, - 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, - 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; - - static const UINT8 bits_ac_chrominance[17] = - { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; - static const UINT8 val_ac_chrominance[] = - { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, - 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, - 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, - 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, - 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, - 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, - 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, - 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, - 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, - 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, - 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, - 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, - 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, - 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; - - add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0], - bits_dc_luminance, val_dc_luminance); - add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0], - bits_ac_luminance, val_ac_luminance); - add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[1], - bits_dc_chrominance, val_dc_chrominance); - add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[1], - bits_ac_chrominance, val_ac_chrominance); -} - - -/* - * Default parameter setup for compression. - * - * Applications that don't choose to use this routine must do their - * own setup of all these parameters. Alternately, you can call this - * to establish defaults and then alter parameters selectively. This - * is the recommended approach since, if we add any new parameters, - * your code will still work (they'll be set to reasonable defaults). - */ - -GLOBAL(void) -jpeg_set_defaults (j_compress_ptr cinfo) -{ - int i; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* Allocate comp_info array large enough for maximum component count. - * Array is made permanent in case application wants to compress - * multiple images at same param settings. - */ - if (cinfo->comp_info == NULL) - cinfo->comp_info = (jpeg_component_info *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - MAX_COMPONENTS * SIZEOF(jpeg_component_info)); - - /* Initialize everything not dependent on the color space */ - - cinfo->data_precision = BITS_IN_JSAMPLE; - /* Set up two quantization tables using default quality of 75 */ - jpeg_set_quality(cinfo, 75, TRUE); - /* Set up two Huffman tables */ - std_huff_tables(cinfo); - - /* Initialize default arithmetic coding conditioning */ - for (i = 0; i < NUM_ARITH_TBLS; i++) { - cinfo->arith_dc_L[i] = 0; - cinfo->arith_dc_U[i] = 1; - cinfo->arith_ac_K[i] = 5; - } - - /* Default is no multiple-scan output */ - cinfo->scan_info = NULL; - cinfo->num_scans = 0; - - /* Expect normal source image, not raw downsampled data */ - cinfo->raw_data_in = FALSE; - - /* Use Huffman coding, not arithmetic coding, by default */ - cinfo->arith_code = FALSE; - - /* By default, don't do extra passes to optimize entropy coding */ - cinfo->optimize_coding = FALSE; - /* The standard Huffman tables are only valid for 8-bit data precision. - * If the precision is higher, force optimization on so that usable - * tables will be computed. This test can be removed if default tables - * are supplied that are valid for the desired precision. - */ - if (cinfo->data_precision > 8) - cinfo->optimize_coding = TRUE; - - /* By default, use the simpler non-cosited sampling alignment */ - cinfo->CCIR601_sampling = FALSE; - - /* No input smoothing */ - cinfo->smoothing_factor = 0; - - /* DCT algorithm preference */ - cinfo->dct_method = JDCT_DEFAULT; - - /* No restart markers */ - cinfo->restart_interval = 0; - cinfo->restart_in_rows = 0; - - /* Fill in default JFIF marker parameters. Note that whether the marker - * will actually be written is determined by jpeg_set_colorspace. - * - * By default, the library emits JFIF version code 1.01. - * An application that wants to emit JFIF 1.02 extension markers should set - * JFIF_minor_version to 2. We could probably get away with just defaulting - * to 1.02, but there may still be some decoders in use that will complain - * about that; saying 1.01 should minimize compatibility problems. - */ - cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */ - cinfo->JFIF_minor_version = 1; - cinfo->density_unit = 0; /* Pixel size is unknown by default */ - cinfo->X_density = 1; /* Pixel aspect ratio is square by default */ - cinfo->Y_density = 1; - - /* Choose JPEG colorspace based on input space, set defaults accordingly */ - - jpeg_default_colorspace(cinfo); -} - - -/* - * Select an appropriate JPEG colorspace for in_color_space. - */ - -GLOBAL(void) -jpeg_default_colorspace (j_compress_ptr cinfo) -{ - switch (cinfo->in_color_space) { - case JCS_GRAYSCALE: - jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); - break; - case JCS_RGB: - jpeg_set_colorspace(cinfo, JCS_YCbCr); - break; - case JCS_YCbCr: - jpeg_set_colorspace(cinfo, JCS_YCbCr); - break; - case JCS_CMYK: - jpeg_set_colorspace(cinfo, JCS_CMYK); /* By default, no translation */ - break; - case JCS_YCCK: - jpeg_set_colorspace(cinfo, JCS_YCCK); - break; - case JCS_UNKNOWN: - jpeg_set_colorspace(cinfo, JCS_UNKNOWN); - break; - default: - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - } -} - - -/* - * Set the JPEG colorspace, and choose colorspace-dependent default values. - */ - -GLOBAL(void) -jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) -{ - jpeg_component_info * compptr; - int ci; - -#define SET_COMP(index,id,hsamp,vsamp,quant,dctbl,actbl) \ - (compptr = &cinfo->comp_info[index], \ - compptr->component_id = (id), \ - compptr->h_samp_factor = (hsamp), \ - compptr->v_samp_factor = (vsamp), \ - compptr->quant_tbl_no = (quant), \ - compptr->dc_tbl_no = (dctbl), \ - compptr->ac_tbl_no = (actbl) ) - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* For all colorspaces, we use Q and Huff tables 0 for luminance components, - * tables 1 for chrominance components. - */ - - cinfo->jpeg_color_space = colorspace; - - cinfo->write_JFIF_header = FALSE; /* No marker for non-JFIF colorspaces */ - cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */ - - switch (colorspace) { - case JCS_GRAYSCALE: - cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ - cinfo->num_components = 1; - /* JFIF specifies component ID 1 */ - SET_COMP(0, 1, 1,1, 0, 0,0); - break; - case JCS_RGB: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */ - cinfo->num_components = 3; - SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0); - SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0); - SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0); - break; - case JCS_YCbCr: - cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ - cinfo->num_components = 3; - /* JFIF specifies component IDs 1,2,3 */ - /* We default to 2x2 subsamples of chrominance */ - SET_COMP(0, 1, 2,2, 0, 0,0); - SET_COMP(1, 2, 1,1, 1, 1,1); - SET_COMP(2, 3, 1,1, 1, 1,1); - break; - case JCS_CMYK: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */ - cinfo->num_components = 4; - SET_COMP(0, 0x43 /* 'C' */, 1,1, 0, 0,0); - SET_COMP(1, 0x4D /* 'M' */, 1,1, 0, 0,0); - SET_COMP(2, 0x59 /* 'Y' */, 1,1, 0, 0,0); - SET_COMP(3, 0x4B /* 'K' */, 1,1, 0, 0,0); - break; - case JCS_YCCK: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */ - cinfo->num_components = 4; - SET_COMP(0, 1, 2,2, 0, 0,0); - SET_COMP(1, 2, 1,1, 1, 1,1); - SET_COMP(2, 3, 1,1, 1, 1,1); - SET_COMP(3, 4, 2,2, 0, 0,0); - break; - case JCS_UNKNOWN: - cinfo->num_components = cinfo->input_components; - if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - for (ci = 0; ci < cinfo->num_components; ci++) { - SET_COMP(ci, ci, 1,1, 0, 0,0); - } - break; - default: - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - } -} - - -#ifdef C_PROGRESSIVE_SUPPORTED - -LOCAL(jpeg_scan_info *) -fill_a_scan (jpeg_scan_info * scanptr, int ci, - int Ss, int Se, int Ah, int Al) -/* Support routine: generate one scan for specified component */ -{ - scanptr->comps_in_scan = 1; - scanptr->component_index[0] = ci; - scanptr->Ss = Ss; - scanptr->Se = Se; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - return scanptr; -} - -LOCAL(jpeg_scan_info *) -fill_scans (jpeg_scan_info * scanptr, int ncomps, - int Ss, int Se, int Ah, int Al) -/* Support routine: generate one scan for each component */ -{ - int ci; - - for (ci = 0; ci < ncomps; ci++) { - scanptr->comps_in_scan = 1; - scanptr->component_index[0] = ci; - scanptr->Ss = Ss; - scanptr->Se = Se; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - } - return scanptr; -} - -LOCAL(jpeg_scan_info *) -fill_dc_scans (jpeg_scan_info * scanptr, int ncomps, int Ah, int Al) -/* Support routine: generate interleaved DC scan if possible, else N scans */ -{ - int ci; - - if (ncomps <= MAX_COMPS_IN_SCAN) { - /* Single interleaved DC scan */ - scanptr->comps_in_scan = ncomps; - for (ci = 0; ci < ncomps; ci++) - scanptr->component_index[ci] = ci; - scanptr->Ss = scanptr->Se = 0; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - } else { - /* Noninterleaved DC scan for each component */ - scanptr = fill_scans(scanptr, ncomps, 0, 0, Ah, Al); - } - return scanptr; -} - - -/* - * Create a recommended progressive-JPEG script. - * cinfo->num_components and cinfo->jpeg_color_space must be correct. - */ - -GLOBAL(void) -jpeg_simple_progression (j_compress_ptr cinfo) -{ - int ncomps = cinfo->num_components; - int nscans; - jpeg_scan_info * scanptr; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* Figure space needed for script. Calculation must match code below! */ - if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { - /* Custom script for YCbCr color images. */ - nscans = 10; - } else { - /* All-purpose script for other color spaces. */ - if (ncomps > MAX_COMPS_IN_SCAN) - nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */ - else - nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */ - } - - /* Allocate space for script. - * We need to put it in the permanent pool in case the application performs - * multiple compressions without changing the settings. To avoid a memory - * leak if jpeg_simple_progression is called repeatedly for the same JPEG - * object, we try to re-use previously allocated space, and we allocate - * enough space to handle YCbCr even if initially asked for grayscale. - */ - if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) { - cinfo->script_space_size = MAX(nscans, 10); - cinfo->script_space = (jpeg_scan_info *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - cinfo->script_space_size * SIZEOF(jpeg_scan_info)); - } - scanptr = cinfo->script_space; - cinfo->scan_info = scanptr; - cinfo->num_scans = nscans; - - if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { - /* Custom script for YCbCr color images. */ - /* Initial DC scan */ - scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); - /* Initial AC scan: get some luma data out in a hurry */ - scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2); - /* Chroma data is too small to be worth expending many scans on */ - scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1); - scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1); - /* Complete spectral selection for luma AC */ - scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2); - /* Refine next bit of luma AC */ - scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1); - /* Finish DC successive approximation */ - scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); - /* Finish AC successive approximation */ - scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0); - scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0); - /* Luma bottom bit comes last since it's usually largest scan */ - scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0); - } else { - /* All-purpose script for other color spaces. */ - /* Successive approximation first pass */ - scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); - scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2); - scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2); - /* Successive approximation second pass */ - scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1); - /* Successive approximation final pass */ - scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); - scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0); - } -} - -#endif /* C_PROGRESSIVE_SUPPORTED */ +/* + * jcparam.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains optional default-setting code for the JPEG compressor. + * Applications do not have to use this file, but those that don't use it + * must know a lot more about the innards of the JPEG code. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Quantization table setup routines + */ + +GLOBAL(void) +jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, + const unsigned int *basic_table, + int scale_factor, boolean force_baseline) +/* Define a quantization table equal to the basic_table times + * a scale factor (given as a percentage). + * If force_baseline is TRUE, the computed quantization table entries + * are limited to 1..255 for JPEG baseline compatibility. + */ +{ + JQUANT_TBL ** qtblptr; + int i; + long temp; + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + if (which_tbl < 0 || which_tbl >= NUM_QUANT_TBLS) + ERREXIT1(cinfo, JERR_DQT_INDEX, which_tbl); + + qtblptr = & cinfo->quant_tbl_ptrs[which_tbl]; + + if (*qtblptr == NULL) + *qtblptr = jpeg_alloc_quant_table((j_common_ptr) cinfo); + + for (i = 0; i < DCTSIZE2; i++) { + temp = ((long) basic_table[i] * scale_factor + 50L) / 100L; + /* limit the values to the valid range */ + if (temp <= 0L) temp = 1L; + if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */ + if (force_baseline && temp > 255L) + temp = 255L; /* limit to baseline range if requested */ + (*qtblptr)->quantval[i] = (UINT16) temp; + } + + /* Initialize sent_table FALSE so table will be written to JPEG file. */ + (*qtblptr)->sent_table = FALSE; +} + + +GLOBAL(void) +jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, + boolean force_baseline) +/* Set or change the 'quality' (quantization) setting, using default tables + * and a straight percentage-scaling quality scale. In most cases it's better + * to use jpeg_set_quality (below); this entry point is provided for + * applications that insist on a linear percentage scaling. + */ +{ + /* These are the sample quantization tables given in JPEG spec section K.1. + * The spec says that the values given produce "good" quality, and + * when divided by 2, "very good" quality. + */ + static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = { + 16, 11, 10, 16, 24, 40, 51, 61, + 12, 12, 14, 19, 26, 58, 60, 55, + 14, 13, 16, 24, 40, 57, 69, 56, + 14, 17, 22, 29, 51, 87, 80, 62, + 18, 22, 37, 56, 68, 109, 103, 77, + 24, 35, 55, 64, 81, 104, 113, 92, + 49, 64, 78, 87, 103, 121, 120, 101, + 72, 92, 95, 98, 112, 100, 103, 99 + }; + static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = { + 17, 18, 24, 47, 99, 99, 99, 99, + 18, 21, 26, 66, 99, 99, 99, 99, + 24, 26, 56, 99, 99, 99, 99, 99, + 47, 66, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99 + }; + + /* Set up two quantization tables using the specified scaling */ + jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, + scale_factor, force_baseline); + jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl, + scale_factor, force_baseline); +} + + +GLOBAL(int) +jpeg_quality_scaling (int quality) +/* Convert a user-specified quality rating to a percentage scaling factor + * for an underlying quantization table, using our recommended scaling curve. + * The input 'quality' factor should be 0 (terrible) to 100 (very good). + */ +{ + /* Safety limit on quality factor. Convert 0 to 1 to avoid zero divide. */ + if (quality <= 0) quality = 1; + if (quality > 100) quality = 100; + + /* The basic table is used as-is (scaling 100) for a quality of 50. + * Qualities 50..100 are converted to scaling percentage 200 - 2*Q; + * note that at Q=100 the scaling is 0, which will cause jpeg_add_quant_table + * to make all the table entries 1 (hence, minimum quantization loss). + * Qualities 1..50 are converted to scaling percentage 5000/Q. + */ + if (quality < 50) + quality = 5000 / quality; + else + quality = 200 - quality*2; + + return quality; +} + + +GLOBAL(void) +jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) +/* Set or change the 'quality' (quantization) setting, using default tables. + * This is the standard quality-adjusting entry point for typical user + * interfaces; only those who want detailed control over quantization tables + * would use the preceding three routines directly. + */ +{ + /* Convert user 0-100 rating to percentage scaling */ + quality = jpeg_quality_scaling(quality); + + /* Set up standard quality tables */ + jpeg_set_linear_quality(cinfo, quality, force_baseline); +} + + +/* + * Huffman table setup routines + */ + +LOCAL(void) +add_huff_table (j_compress_ptr cinfo, + JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) +/* Define a Huffman table */ +{ + int nsymbols, len; + + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + + /* Copy the number-of-symbols-of-each-code-length counts */ + MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); + + /* Validate the counts. We do this here mainly so we can copy the right + * number of symbols from the val[] array, without risking marching off + * the end of memory. jchuff.c will do a more thorough test later. + */ + nsymbols = 0; + for (len = 1; len <= 16; len++) + nsymbols += bits[len]; + if (nsymbols < 1 || nsymbols > 256) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + + MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8)); + + /* Initialize sent_table FALSE so table will be written to JPEG file. */ + (*htblptr)->sent_table = FALSE; +} + + +LOCAL(void) +std_huff_tables (j_compress_ptr cinfo) +/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */ +/* IMPORTANT: these are only valid for 8-bit data precision! */ +{ + static const UINT8 bits_dc_luminance[17] = + { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; + static const UINT8 val_dc_luminance[] = + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + + static const UINT8 bits_dc_chrominance[17] = + { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; + static const UINT8 val_dc_chrominance[] = + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + + static const UINT8 bits_ac_luminance[17] = + { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; + static const UINT8 val_ac_luminance[] = + { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, + 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, + 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, + 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, + 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, + 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, + 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, + 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, + 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, + 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, + 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, + 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, + 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, + 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, + 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, + 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa }; + + static const UINT8 bits_ac_chrominance[17] = + { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; + static const UINT8 val_ac_chrominance[] = + { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, + 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, + 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, + 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, + 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, + 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, + 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, + 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, + 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, + 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, + 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, + 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, + 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, + 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, + 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, + 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa }; + + add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0], + bits_dc_luminance, val_dc_luminance); + add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0], + bits_ac_luminance, val_ac_luminance); + add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[1], + bits_dc_chrominance, val_dc_chrominance); + add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[1], + bits_ac_chrominance, val_ac_chrominance); +} + + +/* + * Default parameter setup for compression. + * + * Applications that don't choose to use this routine must do their + * own setup of all these parameters. Alternately, you can call this + * to establish defaults and then alter parameters selectively. This + * is the recommended approach since, if we add any new parameters, + * your code will still work (they'll be set to reasonable defaults). + */ + +GLOBAL(void) +jpeg_set_defaults (j_compress_ptr cinfo) +{ + int i; + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* Allocate comp_info array large enough for maximum component count. + * Array is made permanent in case application wants to compress + * multiple images at same param settings. + */ + if (cinfo->comp_info == NULL) + cinfo->comp_info = (jpeg_component_info *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + MAX_COMPONENTS * SIZEOF(jpeg_component_info)); + + /* Initialize everything not dependent on the color space */ + + cinfo->data_precision = BITS_IN_JSAMPLE; + /* Set up two quantization tables using default quality of 75 */ + jpeg_set_quality(cinfo, 75, TRUE); + /* Set up two Huffman tables */ + std_huff_tables(cinfo); + + /* Initialize default arithmetic coding conditioning */ + for (i = 0; i < NUM_ARITH_TBLS; i++) { + cinfo->arith_dc_L[i] = 0; + cinfo->arith_dc_U[i] = 1; + cinfo->arith_ac_K[i] = 5; + } + + /* Default is no multiple-scan output */ + cinfo->scan_info = NULL; + cinfo->num_scans = 0; + + /* Expect normal source image, not raw downsampled data */ + cinfo->raw_data_in = FALSE; + + /* Use Huffman coding, not arithmetic coding, by default */ + cinfo->arith_code = FALSE; + + /* By default, don't do extra passes to optimize entropy coding */ + cinfo->optimize_coding = FALSE; + /* The standard Huffman tables are only valid for 8-bit data precision. + * If the precision is higher, force optimization on so that usable + * tables will be computed. This test can be removed if default tables + * are supplied that are valid for the desired precision. + */ + if (cinfo->data_precision > 8) + cinfo->optimize_coding = TRUE; + + /* By default, use the simpler non-cosited sampling alignment */ + cinfo->CCIR601_sampling = FALSE; + + /* No input smoothing */ + cinfo->smoothing_factor = 0; + + /* DCT algorithm preference */ + cinfo->dct_method = JDCT_DEFAULT; + + /* No restart markers */ + cinfo->restart_interval = 0; + cinfo->restart_in_rows = 0; + + /* Fill in default JFIF marker parameters. Note that whether the marker + * will actually be written is determined by jpeg_set_colorspace. + * + * By default, the library emits JFIF version code 1.01. + * An application that wants to emit JFIF 1.02 extension markers should set + * JFIF_minor_version to 2. We could probably get away with just defaulting + * to 1.02, but there may still be some decoders in use that will complain + * about that; saying 1.01 should minimize compatibility problems. + */ + cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */ + cinfo->JFIF_minor_version = 1; + cinfo->density_unit = 0; /* Pixel size is unknown by default */ + cinfo->X_density = 1; /* Pixel aspect ratio is square by default */ + cinfo->Y_density = 1; + + /* Choose JPEG colorspace based on input space, set defaults accordingly */ + + jpeg_default_colorspace(cinfo); +} + + +/* + * Select an appropriate JPEG colorspace for in_color_space. + */ + +GLOBAL(void) +jpeg_default_colorspace (j_compress_ptr cinfo) +{ + switch (cinfo->in_color_space) { + case JCS_GRAYSCALE: + jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); + break; + case JCS_RGB: + jpeg_set_colorspace(cinfo, JCS_YCbCr); + break; + case JCS_YCbCr: + jpeg_set_colorspace(cinfo, JCS_YCbCr); + break; + case JCS_CMYK: + jpeg_set_colorspace(cinfo, JCS_CMYK); /* By default, no translation */ + break; + case JCS_YCCK: + jpeg_set_colorspace(cinfo, JCS_YCCK); + break; + case JCS_UNKNOWN: + jpeg_set_colorspace(cinfo, JCS_UNKNOWN); + break; + default: + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + } +} + + +/* + * Set the JPEG colorspace, and choose colorspace-dependent default values. + */ + +GLOBAL(void) +jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) +{ + jpeg_component_info * compptr; + int ci; + +#define SET_COMP(index,id,hsamp,vsamp,quant,dctbl,actbl) \ + (compptr = &cinfo->comp_info[index], \ + compptr->component_id = (id), \ + compptr->h_samp_factor = (hsamp), \ + compptr->v_samp_factor = (vsamp), \ + compptr->quant_tbl_no = (quant), \ + compptr->dc_tbl_no = (dctbl), \ + compptr->ac_tbl_no = (actbl) ) + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* For all colorspaces, we use Q and Huff tables 0 for luminance components, + * tables 1 for chrominance components. + */ + + cinfo->jpeg_color_space = colorspace; + + cinfo->write_JFIF_header = FALSE; /* No marker for non-JFIF colorspaces */ + cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */ + + switch (colorspace) { + case JCS_GRAYSCALE: + cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ + cinfo->num_components = 1; + /* JFIF specifies component ID 1 */ + SET_COMP(0, 1, 1,1, 0, 0,0); + break; + case JCS_RGB: + cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */ + cinfo->num_components = 3; + SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0); + SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0); + SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0); + break; + case JCS_YCbCr: + cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ + cinfo->num_components = 3; + /* JFIF specifies component IDs 1,2,3 */ + /* We default to 2x2 subsamples of chrominance */ + SET_COMP(0, 1, 2,2, 0, 0,0); + SET_COMP(1, 2, 1,1, 1, 1,1); + SET_COMP(2, 3, 1,1, 1, 1,1); + break; + case JCS_CMYK: + cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */ + cinfo->num_components = 4; + SET_COMP(0, 0x43 /* 'C' */, 1,1, 0, 0,0); + SET_COMP(1, 0x4D /* 'M' */, 1,1, 0, 0,0); + SET_COMP(2, 0x59 /* 'Y' */, 1,1, 0, 0,0); + SET_COMP(3, 0x4B /* 'K' */, 1,1, 0, 0,0); + break; + case JCS_YCCK: + cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */ + cinfo->num_components = 4; + SET_COMP(0, 1, 2,2, 0, 0,0); + SET_COMP(1, 2, 1,1, 1, 1,1); + SET_COMP(2, 3, 1,1, 1, 1,1); + SET_COMP(3, 4, 2,2, 0, 0,0); + break; + case JCS_UNKNOWN: + cinfo->num_components = cinfo->input_components; + if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPONENTS); + for (ci = 0; ci < cinfo->num_components; ci++) { + SET_COMP(ci, ci, 1,1, 0, 0,0); + } + break; + default: + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + } +} + + +#ifdef C_PROGRESSIVE_SUPPORTED + +LOCAL(jpeg_scan_info *) +fill_a_scan (jpeg_scan_info * scanptr, int ci, + int Ss, int Se, int Ah, int Al) +/* Support routine: generate one scan for specified component */ +{ + scanptr->comps_in_scan = 1; + scanptr->component_index[0] = ci; + scanptr->Ss = Ss; + scanptr->Se = Se; + scanptr->Ah = Ah; + scanptr->Al = Al; + scanptr++; + return scanptr; +} + +LOCAL(jpeg_scan_info *) +fill_scans (jpeg_scan_info * scanptr, int ncomps, + int Ss, int Se, int Ah, int Al) +/* Support routine: generate one scan for each component */ +{ + int ci; + + for (ci = 0; ci < ncomps; ci++) { + scanptr->comps_in_scan = 1; + scanptr->component_index[0] = ci; + scanptr->Ss = Ss; + scanptr->Se = Se; + scanptr->Ah = Ah; + scanptr->Al = Al; + scanptr++; + } + return scanptr; +} + +LOCAL(jpeg_scan_info *) +fill_dc_scans (jpeg_scan_info * scanptr, int ncomps, int Ah, int Al) +/* Support routine: generate interleaved DC scan if possible, else N scans */ +{ + int ci; + + if (ncomps <= MAX_COMPS_IN_SCAN) { + /* Single interleaved DC scan */ + scanptr->comps_in_scan = ncomps; + for (ci = 0; ci < ncomps; ci++) + scanptr->component_index[ci] = ci; + scanptr->Ss = scanptr->Se = 0; + scanptr->Ah = Ah; + scanptr->Al = Al; + scanptr++; + } else { + /* Noninterleaved DC scan for each component */ + scanptr = fill_scans(scanptr, ncomps, 0, 0, Ah, Al); + } + return scanptr; +} + + +/* + * Create a recommended progressive-JPEG script. + * cinfo->num_components and cinfo->jpeg_color_space must be correct. + */ + +GLOBAL(void) +jpeg_simple_progression (j_compress_ptr cinfo) +{ + int ncomps = cinfo->num_components; + int nscans; + jpeg_scan_info * scanptr; + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* Figure space needed for script. Calculation must match code below! */ + if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { + /* Custom script for YCbCr color images. */ + nscans = 10; + } else { + /* All-purpose script for other color spaces. */ + if (ncomps > MAX_COMPS_IN_SCAN) + nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */ + else + nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */ + } + + /* Allocate space for script. + * We need to put it in the permanent pool in case the application performs + * multiple compressions without changing the settings. To avoid a memory + * leak if jpeg_simple_progression is called repeatedly for the same JPEG + * object, we try to re-use previously allocated space, and we allocate + * enough space to handle YCbCr even if initially asked for grayscale. + */ + if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) { + cinfo->script_space_size = MAX(nscans, 10); + cinfo->script_space = (jpeg_scan_info *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + cinfo->script_space_size * SIZEOF(jpeg_scan_info)); + } + scanptr = cinfo->script_space; + cinfo->scan_info = scanptr; + cinfo->num_scans = nscans; + + if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { + /* Custom script for YCbCr color images. */ + /* Initial DC scan */ + scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); + /* Initial AC scan: get some luma data out in a hurry */ + scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2); + /* Chroma data is too small to be worth expending many scans on */ + scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1); + scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1); + /* Complete spectral selection for luma AC */ + scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2); + /* Refine next bit of luma AC */ + scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1); + /* Finish DC successive approximation */ + scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); + /* Finish AC successive approximation */ + scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0); + scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0); + /* Luma bottom bit comes last since it's usually largest scan */ + scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0); + } else { + /* All-purpose script for other color spaces. */ + /* Successive approximation first pass */ + scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); + scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2); + scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2); + /* Successive approximation second pass */ + scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1); + /* Successive approximation final pass */ + scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); + scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0); + } +} + +#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/jcphuff.c b/src/dep/src/irrlicht/jpeglib/jcphuff.c index a4ee850..07f9178 100644 --- a/src/dep/src/irrlicht/jpeglib/jcphuff.c +++ b/src/dep/src/irrlicht/jpeglib/jcphuff.c @@ -1,833 +1,833 @@ -/* - * jcphuff.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy encoding routines for progressive JPEG. - * - * We do not support output suspension in this module, since the library - * currently does not allow multiple-scan files to be written with output - * suspension. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jchuff.h" /* Declarations shared with jchuff.c */ - -#ifdef C_PROGRESSIVE_SUPPORTED - -/* Expanded entropy encoder object for progressive Huffman encoding. */ - -typedef struct { - struct jpeg_entropy_encoder pub; /* public fields */ - - /* Mode flag: TRUE for optimization, FALSE for actual data output */ - boolean gather_statistics; - - /* Bit-level coding status. - * next_output_byte/free_in_buffer are local copies of cinfo->dest fields. - */ - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - INT32 put_buffer; /* current bit-accumulation buffer */ - int put_bits; /* # of bits now in it */ - j_compress_ptr cinfo; /* link to cinfo (needed for dump_buffer) */ - - /* Coding status for DC components */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ - - /* Coding status for AC components */ - int ac_tbl_no; /* the table number of the single component */ - unsigned int EOBRUN; /* run length of EOBs */ - unsigned int BE; /* # of buffered correction bits before MCU */ - char * bit_buffer; /* buffer for correction bits (1 per char) */ - /* packing correction bits tightly would save some space but cost time... */ - - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - int next_restart_num; /* next restart number to write (0-7) */ - - /* Pointers to derived tables (these workspaces have image lifespan). - * Since any one scan codes only DC or only AC, we only need one set - * of tables, not one for DC and one for AC. - */ - c_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; - - /* Statistics tables for optimization; again, one set is enough */ - long * count_ptrs[NUM_HUFF_TBLS]; -} phuff_entropy_encoder; - -typedef phuff_entropy_encoder * phuff_entropy_ptr; - -/* MAX_CORR_BITS is the number of bits the AC refinement correction-bit - * buffer can hold. Larger sizes may slightly improve compression, but - * 1000 is already well into the realm of overkill. - * The minimum safe size is 64 bits. - */ - -#define MAX_CORR_BITS 1000 /* Max # of correction bits I can buffer */ - -/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32. - * We assume that int right shift is unsigned if INT32 right shift is, - * which should be safe. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define ISHIFT_TEMPS int ishift_temp; -#define IRIGHT_SHIFT(x,shft) \ - ((ishift_temp = (x)) < 0 ? \ - (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \ - (ishift_temp >> (shft))) -#else -#define ISHIFT_TEMPS -#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - -/* Forward declarations */ -METHODDEF(boolean) encode_mcu_DC_first JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_AC_first JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_DC_refine JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_AC_refine JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_phuff JPP((j_compress_ptr cinfo)); -METHODDEF(void) finish_pass_gather_phuff JPP((j_compress_ptr cinfo)); - - -/* - * Initialize for a Huffman-compressed scan using progressive JPEG. - */ - -METHODDEF(void) -start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band; - int ci, tbl; - jpeg_component_info * compptr; - - entropy->cinfo = cinfo; - entropy->gather_statistics = gather_statistics; - - is_DC_band = (cinfo->Ss == 0); - - /* We assume jcmaster.c already validated the scan parameters. */ - - /* Select execution routines */ - if (cinfo->Ah == 0) { - if (is_DC_band) - entropy->pub.encode_mcu = encode_mcu_DC_first; - else - entropy->pub.encode_mcu = encode_mcu_AC_first; - } else { - if (is_DC_band) - entropy->pub.encode_mcu = encode_mcu_DC_refine; - else { - entropy->pub.encode_mcu = encode_mcu_AC_refine; - /* AC refinement needs a correction bit buffer */ - if (entropy->bit_buffer == NULL) - entropy->bit_buffer = (char *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - MAX_CORR_BITS * SIZEOF(char)); - } - } - if (gather_statistics) - entropy->pub.finish_pass = finish_pass_gather_phuff; - else - entropy->pub.finish_pass = finish_pass_phuff; - - /* Only DC coefficients may be interleaved, so cinfo->comps_in_scan = 1 - * for AC coefficients. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Initialize DC predictions to 0 */ - entropy->last_dc_val[ci] = 0; - /* Get table index */ - if (is_DC_band) { - if (cinfo->Ah != 0) /* DC refinement needs no table */ - continue; - tbl = compptr->dc_tbl_no; - } else { - entropy->ac_tbl_no = tbl = compptr->ac_tbl_no; - } - if (gather_statistics) { - /* Check for invalid table index */ - /* (make_c_derived_tbl does this in the other path) */ - if (tbl < 0 || tbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl); - /* Allocate and zero the statistics tables */ - /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ - if (entropy->count_ptrs[tbl] == NULL) - entropy->count_ptrs[tbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->count_ptrs[tbl], 257 * SIZEOF(long)); - } else { - /* Compute derived values for Huffman table */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl, - & entropy->derived_tbls[tbl]); - } - } - - /* Initialize AC stuff */ - entropy->EOBRUN = 0; - entropy->BE = 0; - - /* Initialize bit buffer to empty */ - entropy->put_buffer = 0; - entropy->put_bits = 0; - - /* Initialize restart stuff */ - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num = 0; -} - - -/* Outputting bytes to the file. - * NB: these must be called only when actually outputting, - * that is, entropy->gather_statistics == FALSE. - */ - -/* Emit a byte */ -#define emit_byte(entropy,val) \ - { *(entropy)->next_output_byte++ = (JOCTET) (val); \ - if (--(entropy)->free_in_buffer == 0) \ - dump_buffer(entropy); } - - -LOCAL(void) -dump_buffer (phuff_entropy_ptr entropy) -/* Empty the output buffer; we do not support suspension in this module. */ -{ - struct jpeg_destination_mgr * dest = entropy->cinfo->dest; - - if (! (*dest->empty_output_buffer) (entropy->cinfo)) - ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND); - /* After a successful buffer dump, must reset buffer pointers */ - entropy->next_output_byte = dest->next_output_byte; - entropy->free_in_buffer = dest->free_in_buffer; -} - - -/* Outputting bits to the file */ - -/* Only the right 24 bits of put_buffer are used; the valid bits are - * left-justified in this part. At most 16 bits can be passed to emit_bits - * in one call, and we never retain more than 7 bits in put_buffer - * between calls, so 24 bits are sufficient. - */ - -INLINE -LOCAL(void) -emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size) -/* Emit some bits, unless we are in gather mode */ -{ - /* This routine is heavily used, so it's worth coding tightly. */ - register INT32 put_buffer = (INT32) code; - register int put_bits = entropy->put_bits; - - /* if size is 0, caller used an invalid Huffman table entry */ - if (size == 0) - ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); - - if (entropy->gather_statistics) - return; /* do nothing if we're only getting stats */ - - put_buffer &= (((INT32) 1)<put_buffer; /* and merge with old buffer contents */ - - while (put_bits >= 8) { - int c = (int) ((put_buffer >> 16) & 0xFF); - - emit_byte(entropy, c); - if (c == 0xFF) { /* need to stuff a zero byte? */ - emit_byte(entropy, 0); - } - put_buffer <<= 8; - put_bits -= 8; - } - - entropy->put_buffer = put_buffer; /* update variables */ - entropy->put_bits = put_bits; -} - - -LOCAL(void) -flush_bits (phuff_entropy_ptr entropy) -{ - emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */ - entropy->put_buffer = 0; /* and reset bit-buffer to empty */ - entropy->put_bits = 0; -} - - -/* - * Emit (or just count) a Huffman symbol. - */ - -INLINE -LOCAL(void) -emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol) -{ - if (entropy->gather_statistics) - entropy->count_ptrs[tbl_no][symbol]++; - else { - c_derived_tbl * tbl = entropy->derived_tbls[tbl_no]; - emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); - } -} - - -/* - * Emit bits from a correction bit buffer. - */ - -LOCAL(void) -emit_buffered_bits (phuff_entropy_ptr entropy, char * bufstart, - unsigned int nbits) -{ - if (entropy->gather_statistics) - return; /* no real work */ - - while (nbits > 0) { - emit_bits(entropy, (unsigned int) (*bufstart), 1); - bufstart++; - nbits--; - } -} - - -/* - * Emit any pending EOBRUN symbol. - */ - -LOCAL(void) -emit_eobrun (phuff_entropy_ptr entropy) -{ - register int temp, nbits; - - if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */ - temp = entropy->EOBRUN; - nbits = 0; - while ((temp >>= 1)) - nbits++; - /* safety check: shouldn't happen given limited correction-bit buffer */ - if (nbits > 14) - ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); - - emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4); - if (nbits) - emit_bits(entropy, entropy->EOBRUN, nbits); - - entropy->EOBRUN = 0; - - /* Emit any buffered correction bits */ - emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE); - entropy->BE = 0; - } -} - - -/* - * Emit a restart marker & resynchronize predictions. - */ - -LOCAL(void) -emit_restart (phuff_entropy_ptr entropy, int restart_num) -{ - int ci; - - emit_eobrun(entropy); - - if (! entropy->gather_statistics) { - flush_bits(entropy); - emit_byte(entropy, 0xFF); - emit_byte(entropy, JPEG_RST0 + restart_num); - } - - if (entropy->cinfo->Ss == 0) { - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++) - entropy->last_dc_val[ci] = 0; - } else { - /* Re-initialize all AC-related fields to 0 */ - entropy->EOBRUN = 0; - entropy->BE = 0; - } -} - - -/* - * MCU encoding for DC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp, temp2; - register int nbits; - int blkn, ci; - int Al = cinfo->Al; - JBLOCKROW block; - jpeg_component_info * compptr; - ISHIFT_TEMPS - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - - /* Compute the DC value after the required point transform by Al. - * This is simply an arithmetic right shift. - */ - temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al); - - /* DC differences are figured on the point-transformed values. */ - temp = temp2 - entropy->last_dc_val[ci]; - entropy->last_dc_val[ci] = temp2; - - /* Encode the DC coefficient difference per section G.1.2.1 */ - temp2 = temp; - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* For a negative input, want temp2 = bitwise complement of abs(input) */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count/emit the Huffman-coded symbol for the number of bits */ - emit_symbol(entropy, compptr->dc_tbl_no, nbits); - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (nbits) /* emit_bits rejects calls with size 0 */ - emit_bits(entropy, (unsigned int) temp2, nbits); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for AC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp, temp2; - register int nbits; - register int r, k; - int Se = cinfo->Se; - int Al = cinfo->Al; - JBLOCKROW block; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data block */ - block = MCU_data[0]; - - /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */ - - r = 0; /* r = run length of zeros */ - - for (k = cinfo->Ss; k <= Se; k++) { - if ((temp = (*block)[jpeg_natural_order[k]]) == 0) { - r++; - continue; - } - /* We must apply the point transform by Al. For AC coefficients this - * is an integer division with rounding towards 0. To do this portably - * in C, we shift after obtaining the absolute value; so the code is - * interwoven with finding the abs value (temp) and output bits (temp2). - */ - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - temp >>= Al; /* apply the point transform */ - /* For a negative coef, want temp2 = bitwise complement of abs(coef) */ - temp2 = ~temp; - } else { - temp >>= Al; /* apply the point transform */ - temp2 = temp; - } - /* Watch out for case that nonzero coef is zero after point transform */ - if (temp == 0) { - r++; - continue; - } - - /* Emit any pending EOBRUN */ - if (entropy->EOBRUN > 0) - emit_eobrun(entropy); - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); - r -= 16; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count/emit Huffman symbol for run length / number of bits */ - emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - emit_bits(entropy, (unsigned int) temp2, nbits); - - r = 0; /* reset zero run length */ - } - - if (r > 0) { /* If there are trailing zeroes, */ - entropy->EOBRUN++; /* count an EOB */ - if (entropy->EOBRUN == 0x7FFF) - emit_eobrun(entropy); /* force it out to avoid overflow */ - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for DC successive approximation refinement scan. - * Note: we assume such scans can be multi-component, although the spec - * is not very clear on the point. - */ - -METHODDEF(boolean) -encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp; - int blkn; - int Al = cinfo->Al; - JBLOCKROW block; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - - /* We simply emit the Al'th bit of the DC coefficient value. */ - temp = (*block)[0]; - emit_bits(entropy, (unsigned int) (temp >> Al), 1); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for AC successive approximation refinement scan. - */ - -METHODDEF(boolean) -encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp; - register int r, k; - int EOB; - char *BR_buffer; - unsigned int BR; - int Se = cinfo->Se; - int Al = cinfo->Al; - JBLOCKROW block; - int absvalues[DCTSIZE2]; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data block */ - block = MCU_data[0]; - - /* It is convenient to make a pre-pass to determine the transformed - * coefficients' absolute values and the EOB position. - */ - EOB = 0; - for (k = cinfo->Ss; k <= Se; k++) { - temp = (*block)[jpeg_natural_order[k]]; - /* We must apply the point transform by Al. For AC coefficients this - * is an integer division with rounding towards 0. To do this portably - * in C, we shift after obtaining the absolute value. - */ - if (temp < 0) - temp = -temp; /* temp is abs value of input */ - temp >>= Al; /* apply the point transform */ - absvalues[k] = temp; /* save abs value for main pass */ - if (temp == 1) - EOB = k; /* EOB = index of last newly-nonzero coef */ - } - - /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */ - - r = 0; /* r = run length of zeros */ - BR = 0; /* BR = count of buffered bits added now */ - BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */ - - for (k = cinfo->Ss; k <= Se; k++) { - if ((temp = absvalues[k]) == 0) { - r++; - continue; - } - - /* Emit any required ZRLs, but not if they can be folded into EOB */ - while (r > 15 && k <= EOB) { - /* emit any pending EOBRUN and the BE correction bits */ - emit_eobrun(entropy); - /* Emit ZRL */ - emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); - r -= 16; - /* Emit buffered correction bits that must be associated with ZRL */ - emit_buffered_bits(entropy, BR_buffer, BR); - BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ - BR = 0; - } - - /* If the coef was previously nonzero, it only needs a correction bit. - * NOTE: a straight translation of the spec's figure G.7 would suggest - * that we also need to test r > 15. But if r > 15, we can only get here - * if k > EOB, which implies that this coefficient is not 1. - */ - if (temp > 1) { - /* The correction bit is the next bit of the absolute value. */ - BR_buffer[BR++] = (char) (temp & 1); - continue; - } - - /* Emit any pending EOBRUN and the BE correction bits */ - emit_eobrun(entropy); - - /* Count/emit Huffman symbol for run length / number of bits */ - emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); - - /* Emit output bit for newly-nonzero coef */ - temp = ((*block)[jpeg_natural_order[k]] < 0) ? 0 : 1; - emit_bits(entropy, (unsigned int) temp, 1); - - /* Emit buffered correction bits that must be associated with this code */ - emit_buffered_bits(entropy, BR_buffer, BR); - BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ - BR = 0; - r = 0; /* reset zero run length */ - } - - if (r > 0 || BR > 0) { /* If there are trailing zeroes, */ - entropy->EOBRUN++; /* count an EOB */ - entropy->BE += BR; /* concat my correction bits to older ones */ - /* We force out the EOB if we risk either: - * 1. overflow of the EOB counter; - * 2. overflow of the correction bit buffer during the next MCU. - */ - if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1)) - emit_eobrun(entropy); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * Finish up at the end of a Huffman-compressed progressive scan. - */ - -METHODDEF(void) -finish_pass_phuff (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Flush out any buffered data */ - emit_eobrun(entropy); - flush_bits(entropy); - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; -} - - -/* - * Finish up a statistics-gathering pass and create the new Huffman tables. - */ - -METHODDEF(void) -finish_pass_gather_phuff (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band; - int ci, tbl; - jpeg_component_info * compptr; - JHUFF_TBL **htblptr; - boolean did[NUM_HUFF_TBLS]; - - /* Flush out buffered data (all we care about is counting the EOB symbol) */ - emit_eobrun(entropy); - - is_DC_band = (cinfo->Ss == 0); - - /* It's important not to apply jpeg_gen_optimal_table more than once - * per table, because it clobbers the input frequency counts! - */ - MEMZERO(did, SIZEOF(did)); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - if (is_DC_band) { - if (cinfo->Ah != 0) /* DC refinement needs no table */ - continue; - tbl = compptr->dc_tbl_no; - } else { - tbl = compptr->ac_tbl_no; - } - if (! did[tbl]) { - if (is_DC_band) - htblptr = & cinfo->dc_huff_tbl_ptrs[tbl]; - else - htblptr = & cinfo->ac_huff_tbl_ptrs[tbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]); - did[tbl] = TRUE; - } - } -} - - -/* - * Module initialization routine for progressive Huffman entropy encoding. - */ - -GLOBAL(void) -jinit_phuff_encoder (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy; - int i; - - entropy = (phuff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(phuff_entropy_encoder)); - cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; - entropy->pub.start_pass = start_pass_phuff; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->derived_tbls[i] = NULL; - entropy->count_ptrs[i] = NULL; - } - entropy->bit_buffer = NULL; /* needed only in AC refinement scan */ -} - -#endif /* C_PROGRESSIVE_SUPPORTED */ +/* + * jcphuff.c + * + * Copyright (C) 1995-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains Huffman entropy encoding routines for progressive JPEG. + * + * We do not support output suspension in this module, since the library + * currently does not allow multiple-scan files to be written with output + * suspension. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jchuff.h" /* Declarations shared with jchuff.c */ + +#ifdef C_PROGRESSIVE_SUPPORTED + +/* Expanded entropy encoder object for progressive Huffman encoding. */ + +typedef struct { + struct jpeg_entropy_encoder pub; /* public fields */ + + /* Mode flag: TRUE for optimization, FALSE for actual data output */ + boolean gather_statistics; + + /* Bit-level coding status. + * next_output_byte/free_in_buffer are local copies of cinfo->dest fields. + */ + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + INT32 put_buffer; /* current bit-accumulation buffer */ + int put_bits; /* # of bits now in it */ + j_compress_ptr cinfo; /* link to cinfo (needed for dump_buffer) */ + + /* Coding status for DC components */ + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ + + /* Coding status for AC components */ + int ac_tbl_no; /* the table number of the single component */ + unsigned int EOBRUN; /* run length of EOBs */ + unsigned int BE; /* # of buffered correction bits before MCU */ + char * bit_buffer; /* buffer for correction bits (1 per char) */ + /* packing correction bits tightly would save some space but cost time... */ + + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + int next_restart_num; /* next restart number to write (0-7) */ + + /* Pointers to derived tables (these workspaces have image lifespan). + * Since any one scan codes only DC or only AC, we only need one set + * of tables, not one for DC and one for AC. + */ + c_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; + + /* Statistics tables for optimization; again, one set is enough */ + long * count_ptrs[NUM_HUFF_TBLS]; +} phuff_entropy_encoder; + +typedef phuff_entropy_encoder * phuff_entropy_ptr; + +/* MAX_CORR_BITS is the number of bits the AC refinement correction-bit + * buffer can hold. Larger sizes may slightly improve compression, but + * 1000 is already well into the realm of overkill. + * The minimum safe size is 64 bits. + */ + +#define MAX_CORR_BITS 1000 /* Max # of correction bits I can buffer */ + +/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32. + * We assume that int right shift is unsigned if INT32 right shift is, + * which should be safe. + */ + +#ifdef RIGHT_SHIFT_IS_UNSIGNED +#define ISHIFT_TEMPS int ishift_temp; +#define IRIGHT_SHIFT(x,shft) \ + ((ishift_temp = (x)) < 0 ? \ + (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \ + (ishift_temp >> (shft))) +#else +#define ISHIFT_TEMPS +#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) +#endif + +/* Forward declarations */ +METHODDEF(boolean) encode_mcu_DC_first JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) encode_mcu_AC_first JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) encode_mcu_DC_refine JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) encode_mcu_AC_refine JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(void) finish_pass_phuff JPP((j_compress_ptr cinfo)); +METHODDEF(void) finish_pass_gather_phuff JPP((j_compress_ptr cinfo)); + + +/* + * Initialize for a Huffman-compressed scan using progressive JPEG. + */ + +METHODDEF(void) +start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + boolean is_DC_band; + int ci, tbl; + jpeg_component_info * compptr; + + entropy->cinfo = cinfo; + entropy->gather_statistics = gather_statistics; + + is_DC_band = (cinfo->Ss == 0); + + /* We assume jcmaster.c already validated the scan parameters. */ + + /* Select execution routines */ + if (cinfo->Ah == 0) { + if (is_DC_band) + entropy->pub.encode_mcu = encode_mcu_DC_first; + else + entropy->pub.encode_mcu = encode_mcu_AC_first; + } else { + if (is_DC_band) + entropy->pub.encode_mcu = encode_mcu_DC_refine; + else { + entropy->pub.encode_mcu = encode_mcu_AC_refine; + /* AC refinement needs a correction bit buffer */ + if (entropy->bit_buffer == NULL) + entropy->bit_buffer = (char *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + MAX_CORR_BITS * SIZEOF(char)); + } + } + if (gather_statistics) + entropy->pub.finish_pass = finish_pass_gather_phuff; + else + entropy->pub.finish_pass = finish_pass_phuff; + + /* Only DC coefficients may be interleaved, so cinfo->comps_in_scan = 1 + * for AC coefficients. + */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Initialize DC predictions to 0 */ + entropy->last_dc_val[ci] = 0; + /* Get table index */ + if (is_DC_band) { + if (cinfo->Ah != 0) /* DC refinement needs no table */ + continue; + tbl = compptr->dc_tbl_no; + } else { + entropy->ac_tbl_no = tbl = compptr->ac_tbl_no; + } + if (gather_statistics) { + /* Check for invalid table index */ + /* (make_c_derived_tbl does this in the other path) */ + if (tbl < 0 || tbl >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl); + /* Allocate and zero the statistics tables */ + /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ + if (entropy->count_ptrs[tbl] == NULL) + entropy->count_ptrs[tbl] = (long *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + 257 * SIZEOF(long)); + MEMZERO(entropy->count_ptrs[tbl], 257 * SIZEOF(long)); + } else { + /* Compute derived values for Huffman table */ + /* We may do this more than once for a table, but it's not expensive */ + jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl, + & entropy->derived_tbls[tbl]); + } + } + + /* Initialize AC stuff */ + entropy->EOBRUN = 0; + entropy->BE = 0; + + /* Initialize bit buffer to empty */ + entropy->put_buffer = 0; + entropy->put_bits = 0; + + /* Initialize restart stuff */ + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num = 0; +} + + +/* Outputting bytes to the file. + * NB: these must be called only when actually outputting, + * that is, entropy->gather_statistics == FALSE. + */ + +/* Emit a byte */ +#define emit_byte(entropy,val) \ + { *(entropy)->next_output_byte++ = (JOCTET) (val); \ + if (--(entropy)->free_in_buffer == 0) \ + dump_buffer(entropy); } + + +LOCAL(void) +dump_buffer (phuff_entropy_ptr entropy) +/* Empty the output buffer; we do not support suspension in this module. */ +{ + struct jpeg_destination_mgr * dest = entropy->cinfo->dest; + + if (! (*dest->empty_output_buffer) (entropy->cinfo)) + ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND); + /* After a successful buffer dump, must reset buffer pointers */ + entropy->next_output_byte = dest->next_output_byte; + entropy->free_in_buffer = dest->free_in_buffer; +} + + +/* Outputting bits to the file */ + +/* Only the right 24 bits of put_buffer are used; the valid bits are + * left-justified in this part. At most 16 bits can be passed to emit_bits + * in one call, and we never retain more than 7 bits in put_buffer + * between calls, so 24 bits are sufficient. + */ + +INLINE +LOCAL(void) +emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size) +/* Emit some bits, unless we are in gather mode */ +{ + /* This routine is heavily used, so it's worth coding tightly. */ + register INT32 put_buffer = (INT32) code; + register int put_bits = entropy->put_bits; + + /* if size is 0, caller used an invalid Huffman table entry */ + if (size == 0) + ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); + + if (entropy->gather_statistics) + return; /* do nothing if we're only getting stats */ + + put_buffer &= (((INT32) 1)<put_buffer; /* and merge with old buffer contents */ + + while (put_bits >= 8) { + int c = (int) ((put_buffer >> 16) & 0xFF); + + emit_byte(entropy, c); + if (c == 0xFF) { /* need to stuff a zero byte? */ + emit_byte(entropy, 0); + } + put_buffer <<= 8; + put_bits -= 8; + } + + entropy->put_buffer = put_buffer; /* update variables */ + entropy->put_bits = put_bits; +} + + +LOCAL(void) +flush_bits (phuff_entropy_ptr entropy) +{ + emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */ + entropy->put_buffer = 0; /* and reset bit-buffer to empty */ + entropy->put_bits = 0; +} + + +/* + * Emit (or just count) a Huffman symbol. + */ + +INLINE +LOCAL(void) +emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol) +{ + if (entropy->gather_statistics) + entropy->count_ptrs[tbl_no][symbol]++; + else { + c_derived_tbl * tbl = entropy->derived_tbls[tbl_no]; + emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); + } +} + + +/* + * Emit bits from a correction bit buffer. + */ + +LOCAL(void) +emit_buffered_bits (phuff_entropy_ptr entropy, char * bufstart, + unsigned int nbits) +{ + if (entropy->gather_statistics) + return; /* no real work */ + + while (nbits > 0) { + emit_bits(entropy, (unsigned int) (*bufstart), 1); + bufstart++; + nbits--; + } +} + + +/* + * Emit any pending EOBRUN symbol. + */ + +LOCAL(void) +emit_eobrun (phuff_entropy_ptr entropy) +{ + register int temp, nbits; + + if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */ + temp = entropy->EOBRUN; + nbits = 0; + while ((temp >>= 1)) + nbits++; + /* safety check: shouldn't happen given limited correction-bit buffer */ + if (nbits > 14) + ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); + + emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4); + if (nbits) + emit_bits(entropy, entropy->EOBRUN, nbits); + + entropy->EOBRUN = 0; + + /* Emit any buffered correction bits */ + emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE); + entropy->BE = 0; + } +} + + +/* + * Emit a restart marker & resynchronize predictions. + */ + +LOCAL(void) +emit_restart (phuff_entropy_ptr entropy, int restart_num) +{ + int ci; + + emit_eobrun(entropy); + + if (! entropy->gather_statistics) { + flush_bits(entropy); + emit_byte(entropy, 0xFF); + emit_byte(entropy, JPEG_RST0 + restart_num); + } + + if (entropy->cinfo->Ss == 0) { + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++) + entropy->last_dc_val[ci] = 0; + } else { + /* Re-initialize all AC-related fields to 0 */ + entropy->EOBRUN = 0; + entropy->BE = 0; + } +} + + +/* + * MCU encoding for DC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + register int temp, temp2; + register int nbits; + int blkn, ci; + int Al = cinfo->Al; + JBLOCKROW block; + jpeg_component_info * compptr; + ISHIFT_TEMPS + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart(entropy, entropy->next_restart_num); + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + + /* Compute the DC value after the required point transform by Al. + * This is simply an arithmetic right shift. + */ + temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al); + + /* DC differences are figured on the point-transformed values. */ + temp = temp2 - entropy->last_dc_val[ci]; + entropy->last_dc_val[ci] = temp2; + + /* Encode the DC coefficient difference per section G.1.2.1 */ + temp2 = temp; + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + /* For a negative input, want temp2 = bitwise complement of abs(input) */ + /* This code assumes we are on a two's complement machine */ + temp2--; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 0; + while (temp) { + nbits++; + temp >>= 1; + } + /* Check for out-of-range coefficient values. + * Since we're encoding a difference, the range limit is twice as much. + */ + if (nbits > MAX_COEF_BITS+1) + ERREXIT(cinfo, JERR_BAD_DCT_COEF); + + /* Count/emit the Huffman-coded symbol for the number of bits */ + emit_symbol(entropy, compptr->dc_tbl_no, nbits); + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + if (nbits) /* emit_bits rejects calls with size 0 */ + emit_bits(entropy, (unsigned int) temp2, nbits); + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * MCU encoding for AC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + register int temp, temp2; + register int nbits; + register int r, k; + int Se = cinfo->Se; + int Al = cinfo->Al; + JBLOCKROW block; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart(entropy, entropy->next_restart_num); + + /* Encode the MCU data block */ + block = MCU_data[0]; + + /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */ + + r = 0; /* r = run length of zeros */ + + for (k = cinfo->Ss; k <= Se; k++) { + if ((temp = (*block)[jpeg_natural_order[k]]) == 0) { + r++; + continue; + } + /* We must apply the point transform by Al. For AC coefficients this + * is an integer division with rounding towards 0. To do this portably + * in C, we shift after obtaining the absolute value; so the code is + * interwoven with finding the abs value (temp) and output bits (temp2). + */ + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + temp >>= Al; /* apply the point transform */ + /* For a negative coef, want temp2 = bitwise complement of abs(coef) */ + temp2 = ~temp; + } else { + temp >>= Al; /* apply the point transform */ + temp2 = temp; + } + /* Watch out for case that nonzero coef is zero after point transform */ + if (temp == 0) { + r++; + continue; + } + + /* Emit any pending EOBRUN */ + if (entropy->EOBRUN > 0) + emit_eobrun(entropy); + /* if run length > 15, must emit special run-length-16 codes (0xF0) */ + while (r > 15) { + emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); + r -= 16; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 1; /* there must be at least one 1 bit */ + while ((temp >>= 1)) + nbits++; + /* Check for out-of-range coefficient values */ + if (nbits > MAX_COEF_BITS) + ERREXIT(cinfo, JERR_BAD_DCT_COEF); + + /* Count/emit Huffman symbol for run length / number of bits */ + emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + emit_bits(entropy, (unsigned int) temp2, nbits); + + r = 0; /* reset zero run length */ + } + + if (r > 0) { /* If there are trailing zeroes, */ + entropy->EOBRUN++; /* count an EOB */ + if (entropy->EOBRUN == 0x7FFF) + emit_eobrun(entropy); /* force it out to avoid overflow */ + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * MCU encoding for DC successive approximation refinement scan. + * Note: we assume such scans can be multi-component, although the spec + * is not very clear on the point. + */ + +METHODDEF(boolean) +encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + register int temp; + int blkn; + int Al = cinfo->Al; + JBLOCKROW block; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart(entropy, entropy->next_restart_num); + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + + /* We simply emit the Al'th bit of the DC coefficient value. */ + temp = (*block)[0]; + emit_bits(entropy, (unsigned int) (temp >> Al), 1); + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * MCU encoding for AC successive approximation refinement scan. + */ + +METHODDEF(boolean) +encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + register int temp; + register int r, k; + int EOB; + char *BR_buffer; + unsigned int BR; + int Se = cinfo->Se; + int Al = cinfo->Al; + JBLOCKROW block; + int absvalues[DCTSIZE2]; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart(entropy, entropy->next_restart_num); + + /* Encode the MCU data block */ + block = MCU_data[0]; + + /* It is convenient to make a pre-pass to determine the transformed + * coefficients' absolute values and the EOB position. + */ + EOB = 0; + for (k = cinfo->Ss; k <= Se; k++) { + temp = (*block)[jpeg_natural_order[k]]; + /* We must apply the point transform by Al. For AC coefficients this + * is an integer division with rounding towards 0. To do this portably + * in C, we shift after obtaining the absolute value. + */ + if (temp < 0) + temp = -temp; /* temp is abs value of input */ + temp >>= Al; /* apply the point transform */ + absvalues[k] = temp; /* save abs value for main pass */ + if (temp == 1) + EOB = k; /* EOB = index of last newly-nonzero coef */ + } + + /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */ + + r = 0; /* r = run length of zeros */ + BR = 0; /* BR = count of buffered bits added now */ + BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */ + + for (k = cinfo->Ss; k <= Se; k++) { + if ((temp = absvalues[k]) == 0) { + r++; + continue; + } + + /* Emit any required ZRLs, but not if they can be folded into EOB */ + while (r > 15 && k <= EOB) { + /* emit any pending EOBRUN and the BE correction bits */ + emit_eobrun(entropy); + /* Emit ZRL */ + emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); + r -= 16; + /* Emit buffered correction bits that must be associated with ZRL */ + emit_buffered_bits(entropy, BR_buffer, BR); + BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ + BR = 0; + } + + /* If the coef was previously nonzero, it only needs a correction bit. + * NOTE: a straight translation of the spec's figure G.7 would suggest + * that we also need to test r > 15. But if r > 15, we can only get here + * if k > EOB, which implies that this coefficient is not 1. + */ + if (temp > 1) { + /* The correction bit is the next bit of the absolute value. */ + BR_buffer[BR++] = (char) (temp & 1); + continue; + } + + /* Emit any pending EOBRUN and the BE correction bits */ + emit_eobrun(entropy); + + /* Count/emit Huffman symbol for run length / number of bits */ + emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); + + /* Emit output bit for newly-nonzero coef */ + temp = ((*block)[jpeg_natural_order[k]] < 0) ? 0 : 1; + emit_bits(entropy, (unsigned int) temp, 1); + + /* Emit buffered correction bits that must be associated with this code */ + emit_buffered_bits(entropy, BR_buffer, BR); + BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ + BR = 0; + r = 0; /* reset zero run length */ + } + + if (r > 0 || BR > 0) { /* If there are trailing zeroes, */ + entropy->EOBRUN++; /* count an EOB */ + entropy->BE += BR; /* concat my correction bits to older ones */ + /* We force out the EOB if we risk either: + * 1. overflow of the EOB counter; + * 2. overflow of the correction bit buffer during the next MCU. + */ + if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1)) + emit_eobrun(entropy); + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * Finish up at the end of a Huffman-compressed progressive scan. + */ + +METHODDEF(void) +finish_pass_phuff (j_compress_ptr cinfo) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Flush out any buffered data */ + emit_eobrun(entropy); + flush_bits(entropy); + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; +} + + +/* + * Finish up a statistics-gathering pass and create the new Huffman tables. + */ + +METHODDEF(void) +finish_pass_gather_phuff (j_compress_ptr cinfo) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + boolean is_DC_band; + int ci, tbl; + jpeg_component_info * compptr; + JHUFF_TBL **htblptr; + boolean did[NUM_HUFF_TBLS]; + + /* Flush out buffered data (all we care about is counting the EOB symbol) */ + emit_eobrun(entropy); + + is_DC_band = (cinfo->Ss == 0); + + /* It's important not to apply jpeg_gen_optimal_table more than once + * per table, because it clobbers the input frequency counts! + */ + MEMZERO(did, SIZEOF(did)); + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + if (is_DC_band) { + if (cinfo->Ah != 0) /* DC refinement needs no table */ + continue; + tbl = compptr->dc_tbl_no; + } else { + tbl = compptr->ac_tbl_no; + } + if (! did[tbl]) { + if (is_DC_band) + htblptr = & cinfo->dc_huff_tbl_ptrs[tbl]; + else + htblptr = & cinfo->ac_huff_tbl_ptrs[tbl]; + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]); + did[tbl] = TRUE; + } + } +} + + +/* + * Module initialization routine for progressive Huffman entropy encoding. + */ + +GLOBAL(void) +jinit_phuff_encoder (j_compress_ptr cinfo) +{ + phuff_entropy_ptr entropy; + int i; + + entropy = (phuff_entropy_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(phuff_entropy_encoder)); + cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; + entropy->pub.start_pass = start_pass_phuff; + + /* Mark tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->derived_tbls[i] = NULL; + entropy->count_ptrs[i] = NULL; + } + entropy->bit_buffer = NULL; /* needed only in AC refinement scan */ +} + +#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/jcprepct.c b/src/dep/src/irrlicht/jpeglib/jcprepct.c index fdc4bc2..fa93333 100644 --- a/src/dep/src/irrlicht/jpeglib/jcprepct.c +++ b/src/dep/src/irrlicht/jpeglib/jcprepct.c @@ -1,354 +1,354 @@ -/* - * jcprepct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the compression preprocessing controller. - * This controller manages the color conversion, downsampling, - * and edge expansion steps. - * - * Most of the complexity here is associated with buffering input rows - * as required by the downsampler. See the comments at the head of - * jcsample.c for the downsampler's needs. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* At present, jcsample.c can request context rows only for smoothing. - * In the future, we might also need context rows for CCIR601 sampling - * or other more-complex downsampling procedures. The code to support - * context rows should be compiled only if needed. - */ -#ifdef INPUT_SMOOTHING_SUPPORTED -#define CONTEXT_ROWS_SUPPORTED -#endif - - -/* - * For the simple (no-context-row) case, we just need to buffer one - * row group's worth of pixels for the downsampling step. At the bottom of - * the image, we pad to a full row group by replicating the last pixel row. - * The downsampler's last output row is then replicated if needed to pad - * out to a full iMCU row. - * - * When providing context rows, we must buffer three row groups' worth of - * pixels. Three row groups are physically allocated, but the row pointer - * arrays are made five row groups high, with the extra pointers above and - * below "wrapping around" to point to the last and first real row groups. - * This allows the downsampler to access the proper context rows. - * At the top and bottom of the image, we create dummy context rows by - * copying the first or last real pixel row. This copying could be avoided - * by pointer hacking as is done in jdmainct.c, but it doesn't seem worth the - * trouble on the compression side. - */ - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_prep_controller pub; /* public fields */ - - /* Downsampling input buffer. This buffer holds color-converted data - * until we have enough to do a downsample step. - */ - JSAMPARRAY color_buf[MAX_COMPONENTS]; - - JDIMENSION rows_to_go; /* counts rows remaining in source image */ - int next_buf_row; /* index of next row to store in color_buf */ - -#ifdef CONTEXT_ROWS_SUPPORTED /* only needed for context case */ - int this_row_group; /* starting row index of group to process */ - int next_buf_stop; /* downsample when we reach this index */ -#endif -} my_prep_controller; - -typedef my_prep_controller * my_prep_ptr; - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - - if (pass_mode != JBUF_PASS_THRU) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - /* Initialize total-height counter for detecting bottom of image */ - prep->rows_to_go = cinfo->image_height; - /* Mark the conversion buffer empty */ - prep->next_buf_row = 0; -#ifdef CONTEXT_ROWS_SUPPORTED - /* Preset additional state variables for context mode. - * These aren't used in non-context mode, so we needn't test which mode. - */ - prep->this_row_group = 0; - /* Set next_buf_stop to stop after two row groups have been read in. */ - prep->next_buf_stop = 2 * cinfo->max_v_samp_factor; -#endif -} - - -/* - * Expand an image vertically from height input_rows to height output_rows, - * by duplicating the bottom row. - */ - -LOCAL(void) -expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols, - int input_rows, int output_rows) -{ - register int row; - - for (row = input_rows; row < output_rows; row++) { - jcopy_sample_rows(image_data, input_rows-1, image_data, row, - 1, num_cols); - } -} - - -/* - * Process some data in the simple no-context case. - * - * Preprocessor output data is counted in "row groups". A row group - * is defined to be v_samp_factor sample rows of each component. - * Downsampling will produce this much data from each max_v_samp_factor - * input rows. - */ - -METHODDEF(void) -pre_process_data (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int numrows, ci; - JDIMENSION inrows; - jpeg_component_info * compptr; - - while (*in_row_ctr < in_rows_avail && - *out_row_group_ctr < out_row_groups_avail) { - /* Do color conversion to fill the conversion buffer. */ - inrows = in_rows_avail - *in_row_ctr; - numrows = cinfo->max_v_samp_factor - prep->next_buf_row; - numrows = (int) MIN((JDIMENSION) numrows, inrows); - (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, - prep->color_buf, - (JDIMENSION) prep->next_buf_row, - numrows); - *in_row_ctr += numrows; - prep->next_buf_row += numrows; - prep->rows_to_go -= numrows; - /* If at bottom of image, pad to fill the conversion buffer. */ - if (prep->rows_to_go == 0 && - prep->next_buf_row < cinfo->max_v_samp_factor) { - for (ci = 0; ci < cinfo->num_components; ci++) { - expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, - prep->next_buf_row, cinfo->max_v_samp_factor); - } - prep->next_buf_row = cinfo->max_v_samp_factor; - } - /* If we've filled the conversion buffer, empty it. */ - if (prep->next_buf_row == cinfo->max_v_samp_factor) { - (*cinfo->downsample->downsample) (cinfo, - prep->color_buf, (JDIMENSION) 0, - output_buf, *out_row_group_ctr); - prep->next_buf_row = 0; - (*out_row_group_ctr)++; - } - /* If at bottom of image, pad the output to a full iMCU height. - * Note we assume the caller is providing a one-iMCU-height output buffer! - */ - if (prep->rows_to_go == 0 && - *out_row_group_ctr < out_row_groups_avail) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - expand_bottom_edge(output_buf[ci], - compptr->width_in_blocks * DCTSIZE, - (int) (*out_row_group_ctr * compptr->v_samp_factor), - (int) (out_row_groups_avail * compptr->v_samp_factor)); - } - *out_row_group_ctr = out_row_groups_avail; - break; /* can exit outer loop without test */ - } - } -} - - -#ifdef CONTEXT_ROWS_SUPPORTED - -/* - * Process some data in the context case. - */ - -METHODDEF(void) -pre_process_context (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int numrows, ci; - int buf_height = cinfo->max_v_samp_factor * 3; - JDIMENSION inrows; - - while (*out_row_group_ctr < out_row_groups_avail) { - if (*in_row_ctr < in_rows_avail) { - /* Do color conversion to fill the conversion buffer. */ - inrows = in_rows_avail - *in_row_ctr; - numrows = prep->next_buf_stop - prep->next_buf_row; - numrows = (int) MIN((JDIMENSION) numrows, inrows); - (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, - prep->color_buf, - (JDIMENSION) prep->next_buf_row, - numrows); - /* Pad at top of image, if first time through */ - if (prep->rows_to_go == cinfo->image_height) { - for (ci = 0; ci < cinfo->num_components; ci++) { - int row; - for (row = 1; row <= cinfo->max_v_samp_factor; row++) { - jcopy_sample_rows(prep->color_buf[ci], 0, - prep->color_buf[ci], -row, - 1, cinfo->image_width); - } - } - } - *in_row_ctr += numrows; - prep->next_buf_row += numrows; - prep->rows_to_go -= numrows; - } else { - /* Return for more data, unless we are at the bottom of the image. */ - if (prep->rows_to_go != 0) - break; - /* When at bottom of image, pad to fill the conversion buffer. */ - if (prep->next_buf_row < prep->next_buf_stop) { - for (ci = 0; ci < cinfo->num_components; ci++) { - expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, - prep->next_buf_row, prep->next_buf_stop); - } - prep->next_buf_row = prep->next_buf_stop; - } - } - /* If we've gotten enough data, downsample a row group. */ - if (prep->next_buf_row == prep->next_buf_stop) { - (*cinfo->downsample->downsample) (cinfo, - prep->color_buf, - (JDIMENSION) prep->this_row_group, - output_buf, *out_row_group_ctr); - (*out_row_group_ctr)++; - /* Advance pointers with wraparound as necessary. */ - prep->this_row_group += cinfo->max_v_samp_factor; - if (prep->this_row_group >= buf_height) - prep->this_row_group = 0; - if (prep->next_buf_row >= buf_height) - prep->next_buf_row = 0; - prep->next_buf_stop = prep->next_buf_row + cinfo->max_v_samp_factor; - } - } -} - - -/* - * Create the wrapped-around downsampling input buffer needed for context mode. - */ - -LOCAL(void) -create_context_buffer (j_compress_ptr cinfo) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int rgroup_height = cinfo->max_v_samp_factor; - int ci, i; - jpeg_component_info * compptr; - JSAMPARRAY true_buffer, fake_buffer; - - /* Grab enough space for fake row pointers for all the components; - * we need five row groups' worth of pointers for each component. - */ - fake_buffer = (JSAMPARRAY) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (cinfo->num_components * 5 * rgroup_height) * - SIZEOF(JSAMPROW)); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Allocate the actual buffer space (3 row groups) for this component. - * We make the buffer wide enough to allow the downsampler to edge-expand - * horizontally within the buffer, if it so chooses. - */ - true_buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * - cinfo->max_h_samp_factor) / compptr->h_samp_factor), - (JDIMENSION) (3 * rgroup_height)); - /* Copy true buffer row pointers into the middle of the fake row array */ - MEMCOPY(fake_buffer + rgroup_height, true_buffer, - 3 * rgroup_height * SIZEOF(JSAMPROW)); - /* Fill in the above and below wraparound pointers */ - for (i = 0; i < rgroup_height; i++) { - fake_buffer[i] = true_buffer[2 * rgroup_height + i]; - fake_buffer[4 * rgroup_height + i] = true_buffer[i]; - } - prep->color_buf[ci] = fake_buffer + rgroup_height; - fake_buffer += 5 * rgroup_height; /* point to space for next component */ - } -} - -#endif /* CONTEXT_ROWS_SUPPORTED */ - - -/* - * Initialize preprocessing controller. - */ - -GLOBAL(void) -jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_prep_ptr prep; - int ci; - jpeg_component_info * compptr; - - if (need_full_buffer) /* safety check */ - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - prep = (my_prep_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_prep_controller)); - cinfo->prep = (struct jpeg_c_prep_controller *) prep; - prep->pub.start_pass = start_pass_prep; - - /* Allocate the color conversion buffer. - * We make the buffer wide enough to allow the downsampler to edge-expand - * horizontally within the buffer, if it so chooses. - */ - if (cinfo->downsample->need_context_rows) { - /* Set up to provide context rows */ -#ifdef CONTEXT_ROWS_SUPPORTED - prep->pub.pre_process_data = pre_process_context; - create_context_buffer(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - /* No context, just make it tall enough for one row group */ - prep->pub.pre_process_data = pre_process_data; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - prep->color_buf[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * - cinfo->max_h_samp_factor) / compptr->h_samp_factor), - (JDIMENSION) cinfo->max_v_samp_factor); - } - } -} +/* + * jcprepct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the compression preprocessing controller. + * This controller manages the color conversion, downsampling, + * and edge expansion steps. + * + * Most of the complexity here is associated with buffering input rows + * as required by the downsampler. See the comments at the head of + * jcsample.c for the downsampler's needs. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* At present, jcsample.c can request context rows only for smoothing. + * In the future, we might also need context rows for CCIR601 sampling + * or other more-complex downsampling procedures. The code to support + * context rows should be compiled only if needed. + */ +#ifdef INPUT_SMOOTHING_SUPPORTED +#define CONTEXT_ROWS_SUPPORTED +#endif + + +/* + * For the simple (no-context-row) case, we just need to buffer one + * row group's worth of pixels for the downsampling step. At the bottom of + * the image, we pad to a full row group by replicating the last pixel row. + * The downsampler's last output row is then replicated if needed to pad + * out to a full iMCU row. + * + * When providing context rows, we must buffer three row groups' worth of + * pixels. Three row groups are physically allocated, but the row pointer + * arrays are made five row groups high, with the extra pointers above and + * below "wrapping around" to point to the last and first real row groups. + * This allows the downsampler to access the proper context rows. + * At the top and bottom of the image, we create dummy context rows by + * copying the first or last real pixel row. This copying could be avoided + * by pointer hacking as is done in jdmainct.c, but it doesn't seem worth the + * trouble on the compression side. + */ + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_prep_controller pub; /* public fields */ + + /* Downsampling input buffer. This buffer holds color-converted data + * until we have enough to do a downsample step. + */ + JSAMPARRAY color_buf[MAX_COMPONENTS]; + + JDIMENSION rows_to_go; /* counts rows remaining in source image */ + int next_buf_row; /* index of next row to store in color_buf */ + +#ifdef CONTEXT_ROWS_SUPPORTED /* only needed for context case */ + int this_row_group; /* starting row index of group to process */ + int next_buf_stop; /* downsample when we reach this index */ +#endif +} my_prep_controller; + +typedef my_prep_controller * my_prep_ptr; + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + + if (pass_mode != JBUF_PASS_THRU) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + /* Initialize total-height counter for detecting bottom of image */ + prep->rows_to_go = cinfo->image_height; + /* Mark the conversion buffer empty */ + prep->next_buf_row = 0; +#ifdef CONTEXT_ROWS_SUPPORTED + /* Preset additional state variables for context mode. + * These aren't used in non-context mode, so we needn't test which mode. + */ + prep->this_row_group = 0; + /* Set next_buf_stop to stop after two row groups have been read in. */ + prep->next_buf_stop = 2 * cinfo->max_v_samp_factor; +#endif +} + + +/* + * Expand an image vertically from height input_rows to height output_rows, + * by duplicating the bottom row. + */ + +LOCAL(void) +expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols, + int input_rows, int output_rows) +{ + register int row; + + for (row = input_rows; row < output_rows; row++) { + jcopy_sample_rows(image_data, input_rows-1, image_data, row, + 1, num_cols); + } +} + + +/* + * Process some data in the simple no-context case. + * + * Preprocessor output data is counted in "row groups". A row group + * is defined to be v_samp_factor sample rows of each component. + * Downsampling will produce this much data from each max_v_samp_factor + * input rows. + */ + +METHODDEF(void) +pre_process_data (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail, + JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, + JDIMENSION out_row_groups_avail) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + int numrows, ci; + JDIMENSION inrows; + jpeg_component_info * compptr; + + while (*in_row_ctr < in_rows_avail && + *out_row_group_ctr < out_row_groups_avail) { + /* Do color conversion to fill the conversion buffer. */ + inrows = in_rows_avail - *in_row_ctr; + numrows = cinfo->max_v_samp_factor - prep->next_buf_row; + numrows = (int) MIN((JDIMENSION) numrows, inrows); + (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, + prep->color_buf, + (JDIMENSION) prep->next_buf_row, + numrows); + *in_row_ctr += numrows; + prep->next_buf_row += numrows; + prep->rows_to_go -= numrows; + /* If at bottom of image, pad to fill the conversion buffer. */ + if (prep->rows_to_go == 0 && + prep->next_buf_row < cinfo->max_v_samp_factor) { + for (ci = 0; ci < cinfo->num_components; ci++) { + expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, + prep->next_buf_row, cinfo->max_v_samp_factor); + } + prep->next_buf_row = cinfo->max_v_samp_factor; + } + /* If we've filled the conversion buffer, empty it. */ + if (prep->next_buf_row == cinfo->max_v_samp_factor) { + (*cinfo->downsample->downsample) (cinfo, + prep->color_buf, (JDIMENSION) 0, + output_buf, *out_row_group_ctr); + prep->next_buf_row = 0; + (*out_row_group_ctr)++; + } + /* If at bottom of image, pad the output to a full iMCU height. + * Note we assume the caller is providing a one-iMCU-height output buffer! + */ + if (prep->rows_to_go == 0 && + *out_row_group_ctr < out_row_groups_avail) { + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + expand_bottom_edge(output_buf[ci], + compptr->width_in_blocks * DCTSIZE, + (int) (*out_row_group_ctr * compptr->v_samp_factor), + (int) (out_row_groups_avail * compptr->v_samp_factor)); + } + *out_row_group_ctr = out_row_groups_avail; + break; /* can exit outer loop without test */ + } + } +} + + +#ifdef CONTEXT_ROWS_SUPPORTED + +/* + * Process some data in the context case. + */ + +METHODDEF(void) +pre_process_context (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail, + JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, + JDIMENSION out_row_groups_avail) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + int numrows, ci; + int buf_height = cinfo->max_v_samp_factor * 3; + JDIMENSION inrows; + + while (*out_row_group_ctr < out_row_groups_avail) { + if (*in_row_ctr < in_rows_avail) { + /* Do color conversion to fill the conversion buffer. */ + inrows = in_rows_avail - *in_row_ctr; + numrows = prep->next_buf_stop - prep->next_buf_row; + numrows = (int) MIN((JDIMENSION) numrows, inrows); + (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, + prep->color_buf, + (JDIMENSION) prep->next_buf_row, + numrows); + /* Pad at top of image, if first time through */ + if (prep->rows_to_go == cinfo->image_height) { + for (ci = 0; ci < cinfo->num_components; ci++) { + int row; + for (row = 1; row <= cinfo->max_v_samp_factor; row++) { + jcopy_sample_rows(prep->color_buf[ci], 0, + prep->color_buf[ci], -row, + 1, cinfo->image_width); + } + } + } + *in_row_ctr += numrows; + prep->next_buf_row += numrows; + prep->rows_to_go -= numrows; + } else { + /* Return for more data, unless we are at the bottom of the image. */ + if (prep->rows_to_go != 0) + break; + /* When at bottom of image, pad to fill the conversion buffer. */ + if (prep->next_buf_row < prep->next_buf_stop) { + for (ci = 0; ci < cinfo->num_components; ci++) { + expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, + prep->next_buf_row, prep->next_buf_stop); + } + prep->next_buf_row = prep->next_buf_stop; + } + } + /* If we've gotten enough data, downsample a row group. */ + if (prep->next_buf_row == prep->next_buf_stop) { + (*cinfo->downsample->downsample) (cinfo, + prep->color_buf, + (JDIMENSION) prep->this_row_group, + output_buf, *out_row_group_ctr); + (*out_row_group_ctr)++; + /* Advance pointers with wraparound as necessary. */ + prep->this_row_group += cinfo->max_v_samp_factor; + if (prep->this_row_group >= buf_height) + prep->this_row_group = 0; + if (prep->next_buf_row >= buf_height) + prep->next_buf_row = 0; + prep->next_buf_stop = prep->next_buf_row + cinfo->max_v_samp_factor; + } + } +} + + +/* + * Create the wrapped-around downsampling input buffer needed for context mode. + */ + +LOCAL(void) +create_context_buffer (j_compress_ptr cinfo) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + int rgroup_height = cinfo->max_v_samp_factor; + int ci, i; + jpeg_component_info * compptr; + JSAMPARRAY true_buffer, fake_buffer; + + /* Grab enough space for fake row pointers for all the components; + * we need five row groups' worth of pointers for each component. + */ + fake_buffer = (JSAMPARRAY) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (cinfo->num_components * 5 * rgroup_height) * + SIZEOF(JSAMPROW)); + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Allocate the actual buffer space (3 row groups) for this component. + * We make the buffer wide enough to allow the downsampler to edge-expand + * horizontally within the buffer, if it so chooses. + */ + true_buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * + cinfo->max_h_samp_factor) / compptr->h_samp_factor), + (JDIMENSION) (3 * rgroup_height)); + /* Copy true buffer row pointers into the middle of the fake row array */ + MEMCOPY(fake_buffer + rgroup_height, true_buffer, + 3 * rgroup_height * SIZEOF(JSAMPROW)); + /* Fill in the above and below wraparound pointers */ + for (i = 0; i < rgroup_height; i++) { + fake_buffer[i] = true_buffer[2 * rgroup_height + i]; + fake_buffer[4 * rgroup_height + i] = true_buffer[i]; + } + prep->color_buf[ci] = fake_buffer + rgroup_height; + fake_buffer += 5 * rgroup_height; /* point to space for next component */ + } +} + +#endif /* CONTEXT_ROWS_SUPPORTED */ + + +/* + * Initialize preprocessing controller. + */ + +GLOBAL(void) +jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer) +{ + my_prep_ptr prep; + int ci; + jpeg_component_info * compptr; + + if (need_full_buffer) /* safety check */ + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + prep = (my_prep_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_prep_controller)); + cinfo->prep = (struct jpeg_c_prep_controller *) prep; + prep->pub.start_pass = start_pass_prep; + + /* Allocate the color conversion buffer. + * We make the buffer wide enough to allow the downsampler to edge-expand + * horizontally within the buffer, if it so chooses. + */ + if (cinfo->downsample->need_context_rows) { + /* Set up to provide context rows */ +#ifdef CONTEXT_ROWS_SUPPORTED + prep->pub.pre_process_data = pre_process_context; + create_context_buffer(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + /* No context, just make it tall enough for one row group */ + prep->pub.pre_process_data = pre_process_data; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + prep->color_buf[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * + cinfo->max_h_samp_factor) / compptr->h_samp_factor), + (JDIMENSION) cinfo->max_v_samp_factor); + } + } +} diff --git a/src/dep/src/irrlicht/jpeglib/jcsample.c b/src/dep/src/irrlicht/jpeglib/jcsample.c index fe29fca..212ec87 100644 --- a/src/dep/src/irrlicht/jpeglib/jcsample.c +++ b/src/dep/src/irrlicht/jpeglib/jcsample.c @@ -1,519 +1,519 @@ -/* - * jcsample.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains downsampling routines. - * - * Downsampling input data is counted in "row groups". A row group - * is defined to be max_v_samp_factor pixel rows of each component, - * from which the downsampler produces v_samp_factor sample rows. - * A single row group is processed in each call to the downsampler module. - * - * The downsampler is responsible for edge-expansion of its output data - * to fill an integral number of DCT blocks horizontally. The source buffer - * may be modified if it is helpful for this purpose (the source buffer is - * allocated wide enough to correspond to the desired output width). - * The caller (the prep controller) is responsible for vertical padding. - * - * The downsampler may request "context rows" by setting need_context_rows - * during startup. In this case, the input arrays will contain at least - * one row group's worth of pixels above and below the passed-in data; - * the caller will create dummy rows at image top and bottom by replicating - * the first or last real pixel row. - * - * An excellent reference for image resampling is - * Digital Image Warping, George Wolberg, 1990. - * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. - * - * The downsampling algorithm used here is a simple average of the source - * pixels covered by the output pixel. The hi-falutin sampling literature - * refers to this as a "box filter". In general the characteristics of a box - * filter are not very good, but for the specific cases we normally use (1:1 - * and 2:1 ratios) the box is equivalent to a "triangle filter" which is not - * nearly so bad. If you intend to use other sampling ratios, you'd be well - * advised to improve this code. - * - * A simple input-smoothing capability is provided. This is mainly intended - * for cleaning up color-dithered GIF input files (if you find it inadequate, - * we suggest using an external filtering program such as pnmconvol). When - * enabled, each input pixel P is replaced by a weighted sum of itself and its - * eight neighbors. P's weight is 1-8*SF and each neighbor's weight is SF, - * where SF = (smoothing_factor / 1024). - * Currently, smoothing is only supported for 2h2v sampling factors. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Pointer to routine to downsample a single component */ -typedef JMETHOD(void, downsample1_ptr, - (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data)); - -/* Private subobject */ - -typedef struct { - struct jpeg_downsampler pub; /* public fields */ - - /* Downsampling method pointers, one per component */ - downsample1_ptr methods[MAX_COMPONENTS]; -} my_downsampler; - -typedef my_downsampler * my_downsample_ptr; - - -/* - * Initialize for a downsampling pass. - */ - -METHODDEF(void) -start_pass_downsample (j_compress_ptr cinfo) -{ - /* no work for now */ -} - - -/* - * Expand a component horizontally from width input_cols to width output_cols, - * by duplicating the rightmost samples. - */ - -LOCAL(void) -expand_right_edge (JSAMPARRAY image_data, int num_rows, - JDIMENSION input_cols, JDIMENSION output_cols) -{ - register JSAMPROW ptr; - register JSAMPLE pixval; - register int count; - int row; - int numcols = (int) (output_cols - input_cols); - - if (numcols > 0) { - for (row = 0; row < num_rows; row++) { - ptr = image_data[row] + input_cols; - pixval = ptr[-1]; /* don't need GETJSAMPLE() here */ - for (count = numcols; count > 0; count--) - *ptr++ = pixval; - } - } -} - - -/* - * Do downsampling for a whole row group (all components). - * - * In this version we simply downsample each component independently. - */ - -METHODDEF(void) -sep_downsample (j_compress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_index, - JSAMPIMAGE output_buf, JDIMENSION out_row_group_index) -{ - my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample; - int ci; - jpeg_component_info * compptr; - JSAMPARRAY in_ptr, out_ptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - in_ptr = input_buf[ci] + in_row_index; - out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor); - (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr); - } -} - - -/* - * Downsample pixel values of a single component. - * One row group is processed per call. - * This version handles arbitrary integral sampling ratios, without smoothing. - * Note that this version is not actually used for customary sampling ratios. - */ - -METHODDEF(void) -int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v; - JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */ - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - JSAMPROW inptr, outptr; - INT32 outvalue; - - h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor; - v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor; - numpix = h_expand * v_expand; - numpix2 = numpix/2; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * h_expand); - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - for (outcol = 0, outcol_h = 0; outcol < output_cols; - outcol++, outcol_h += h_expand) { - outvalue = 0; - for (v = 0; v < v_expand; v++) { - inptr = input_data[inrow+v] + outcol_h; - for (h = 0; h < h_expand; h++) { - outvalue += (INT32) GETJSAMPLE(*inptr++); - } - } - *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix); - } - inrow += v_expand; - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the special case of a full-size component, - * without smoothing. - */ - -METHODDEF(void) -fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - /* Copy the data */ - jcopy_sample_rows(input_data, 0, output_data, 0, - cinfo->max_v_samp_factor, cinfo->image_width); - /* Edge-expand */ - expand_right_edge(output_data, cinfo->max_v_samp_factor, - cinfo->image_width, compptr->width_in_blocks * DCTSIZE); -} - - -/* - * Downsample pixel values of a single component. - * This version handles the common case of 2:1 horizontal and 1:1 vertical, - * without smoothing. - * - * A note about the "bias" calculations: when rounding fractional values to - * integer, we do not want to always round 0.5 up to the next integer. - * If we did that, we'd introduce a noticeable bias towards larger values. - * Instead, this code is arranged so that 0.5 will be rounded up or down at - * alternate pixel locations (a simple ordered dither pattern). - */ - -METHODDEF(void) -h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int outrow; - JDIMENSION outcol; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr, outptr; - register int bias; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * 2); - - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr = input_data[outrow]; - bias = 0; /* bias = 0,1,0,1,... for successive samples */ - for (outcol = 0; outcol < output_cols; outcol++) { - *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1]) - + bias) >> 1); - bias ^= 1; /* 0=>1, 1=>0 */ - inptr += 2; - } - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the standard case of 2:1 horizontal and 2:1 vertical, - * without smoothing. - */ - -METHODDEF(void) -h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow; - JDIMENSION outcol; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr0, inptr1, outptr; - register int bias; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * 2); - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr0 = input_data[inrow]; - inptr1 = input_data[inrow+1]; - bias = 1; /* bias = 1,2,1,2,... for successive samples */ - for (outcol = 0; outcol < output_cols; outcol++) { - *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]) - + bias) >> 2); - bias ^= 3; /* 1=>2, 2=>1 */ - inptr0 += 2; inptr1 += 2; - } - inrow += 2; - } -} - - -#ifdef INPUT_SMOOTHING_SUPPORTED - -/* - * Downsample pixel values of a single component. - * This version handles the standard case of 2:1 horizontal and 2:1 vertical, - * with smoothing. One row of context is required. - */ - -METHODDEF(void) -h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow; - JDIMENSION colctr; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr; - INT32 membersum, neighsum, memberscale, neighscale; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, - cinfo->image_width, output_cols * 2); - - /* We don't bother to form the individual "smoothed" input pixel values; - * we can directly compute the output which is the average of the four - * smoothed values. Each of the four member pixels contributes a fraction - * (1-8*SF) to its own smoothed image and a fraction SF to each of the three - * other smoothed pixels, therefore a total fraction (1-5*SF)/4 to the final - * output. The four corner-adjacent neighbor pixels contribute a fraction - * SF to just one smoothed pixel, or SF/4 to the final output; while the - * eight edge-adjacent neighbors contribute SF to each of two smoothed - * pixels, or SF/2 overall. In order to use integer arithmetic, these - * factors are scaled by 2^16 = 65536. - * Also recall that SF = smoothing_factor / 1024. - */ - - memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */ - neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */ - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr0 = input_data[inrow]; - inptr1 = input_data[inrow+1]; - above_ptr = input_data[inrow-1]; - below_ptr = input_data[inrow+2]; - - /* Special case for first column: pretend column -1 is same as column 0 */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[2]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[2]); - neighsum += neighsum; - neighsum += GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[2]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]); - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; - - for (colctr = output_cols - 2; colctr > 0; colctr--) { - /* sum of pixels directly mapped to this output element */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - /* sum of edge-neighbor pixels */ - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[2]) + - GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[2]); - /* The edge-neighbors count twice as much as corner-neighbors */ - neighsum += neighsum; - /* Add in the corner-neighbors */ - neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[2]) + - GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[2]); - /* form final output scaled up by 2^16 */ - membersum = membersum * memberscale + neighsum * neighscale; - /* round, descale and output it */ - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; - } - - /* Special case for last column */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[1]); - neighsum += neighsum; - neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[1]); - membersum = membersum * memberscale + neighsum * neighscale; - *outptr = (JSAMPLE) ((membersum + 32768) >> 16); - - inrow += 2; - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the special case of a full-size component, - * with smoothing. One row of context is required. - */ - -METHODDEF(void) -fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int outrow; - JDIMENSION colctr; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr, above_ptr, below_ptr, outptr; - INT32 membersum, neighsum, memberscale, neighscale; - int colsum, lastcolsum, nextcolsum; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, - cinfo->image_width, output_cols); - - /* Each of the eight neighbor pixels contributes a fraction SF to the - * smoothed pixel, while the main pixel contributes (1-8*SF). In order - * to use integer arithmetic, these factors are multiplied by 2^16 = 65536. - * Also recall that SF = smoothing_factor / 1024. - */ - - memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */ - neighscale = cinfo->smoothing_factor * 64; /* scaled SF */ - - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr = input_data[outrow]; - above_ptr = input_data[outrow-1]; - below_ptr = input_data[outrow+1]; - - /* Special case for first column */ - colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) + - GETJSAMPLE(*inptr); - membersum = GETJSAMPLE(*inptr++); - nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + - GETJSAMPLE(*inptr); - neighsum = colsum + (colsum - membersum) + nextcolsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - lastcolsum = colsum; colsum = nextcolsum; - - for (colctr = output_cols - 2; colctr > 0; colctr--) { - membersum = GETJSAMPLE(*inptr++); - above_ptr++; below_ptr++; - nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + - GETJSAMPLE(*inptr); - neighsum = lastcolsum + (colsum - membersum) + nextcolsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - lastcolsum = colsum; colsum = nextcolsum; - } - - /* Special case for last column */ - membersum = GETJSAMPLE(*inptr); - neighsum = lastcolsum + (colsum - membersum) + colsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr = (JSAMPLE) ((membersum + 32768) >> 16); - - } -} - -#endif /* INPUT_SMOOTHING_SUPPORTED */ - - -/* - * Module initialization routine for downsampling. - * Note that we must select a routine for each component. - */ - -GLOBAL(void) -jinit_downsampler (j_compress_ptr cinfo) -{ - my_downsample_ptr downsample; - int ci; - jpeg_component_info * compptr; - boolean smoothok = TRUE; - - downsample = (my_downsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_downsampler)); - cinfo->downsample = (struct jpeg_downsampler *) downsample; - downsample->pub.start_pass = start_pass_downsample; - downsample->pub.downsample = sep_downsample; - downsample->pub.need_context_rows = FALSE; - - if (cinfo->CCIR601_sampling) - ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); - - /* Verify we can handle the sampling factors, and set up method pointers */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor == cinfo->max_h_samp_factor && - compptr->v_samp_factor == cinfo->max_v_samp_factor) { -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor) { - downsample->methods[ci] = fullsize_smooth_downsample; - downsample->pub.need_context_rows = TRUE; - } else -#endif - downsample->methods[ci] = fullsize_downsample; - } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && - compptr->v_samp_factor == cinfo->max_v_samp_factor) { - smoothok = FALSE; - downsample->methods[ci] = h2v1_downsample; - } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && - compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) { -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor) { - downsample->methods[ci] = h2v2_smooth_downsample; - downsample->pub.need_context_rows = TRUE; - } else -#endif - downsample->methods[ci] = h2v2_downsample; - } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 && - (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) { - smoothok = FALSE; - downsample->methods[ci] = int_downsample; - } else - ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); - } - -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor && !smoothok) - TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL); -#endif -} +/* + * jcsample.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains downsampling routines. + * + * Downsampling input data is counted in "row groups". A row group + * is defined to be max_v_samp_factor pixel rows of each component, + * from which the downsampler produces v_samp_factor sample rows. + * A single row group is processed in each call to the downsampler module. + * + * The downsampler is responsible for edge-expansion of its output data + * to fill an integral number of DCT blocks horizontally. The source buffer + * may be modified if it is helpful for this purpose (the source buffer is + * allocated wide enough to correspond to the desired output width). + * The caller (the prep controller) is responsible for vertical padding. + * + * The downsampler may request "context rows" by setting need_context_rows + * during startup. In this case, the input arrays will contain at least + * one row group's worth of pixels above and below the passed-in data; + * the caller will create dummy rows at image top and bottom by replicating + * the first or last real pixel row. + * + * An excellent reference for image resampling is + * Digital Image Warping, George Wolberg, 1990. + * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. + * + * The downsampling algorithm used here is a simple average of the source + * pixels covered by the output pixel. The hi-falutin sampling literature + * refers to this as a "box filter". In general the characteristics of a box + * filter are not very good, but for the specific cases we normally use (1:1 + * and 2:1 ratios) the box is equivalent to a "triangle filter" which is not + * nearly so bad. If you intend to use other sampling ratios, you'd be well + * advised to improve this code. + * + * A simple input-smoothing capability is provided. This is mainly intended + * for cleaning up color-dithered GIF input files (if you find it inadequate, + * we suggest using an external filtering program such as pnmconvol). When + * enabled, each input pixel P is replaced by a weighted sum of itself and its + * eight neighbors. P's weight is 1-8*SF and each neighbor's weight is SF, + * where SF = (smoothing_factor / 1024). + * Currently, smoothing is only supported for 2h2v sampling factors. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Pointer to routine to downsample a single component */ +typedef JMETHOD(void, downsample1_ptr, + (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data)); + +/* Private subobject */ + +typedef struct { + struct jpeg_downsampler pub; /* public fields */ + + /* Downsampling method pointers, one per component */ + downsample1_ptr methods[MAX_COMPONENTS]; +} my_downsampler; + +typedef my_downsampler * my_downsample_ptr; + + +/* + * Initialize for a downsampling pass. + */ + +METHODDEF(void) +start_pass_downsample (j_compress_ptr cinfo) +{ + /* no work for now */ +} + + +/* + * Expand a component horizontally from width input_cols to width output_cols, + * by duplicating the rightmost samples. + */ + +LOCAL(void) +expand_right_edge (JSAMPARRAY image_data, int num_rows, + JDIMENSION input_cols, JDIMENSION output_cols) +{ + register JSAMPROW ptr; + register JSAMPLE pixval; + register int count; + int row; + int numcols = (int) (output_cols - input_cols); + + if (numcols > 0) { + for (row = 0; row < num_rows; row++) { + ptr = image_data[row] + input_cols; + pixval = ptr[-1]; /* don't need GETJSAMPLE() here */ + for (count = numcols; count > 0; count--) + *ptr++ = pixval; + } + } +} + + +/* + * Do downsampling for a whole row group (all components). + * + * In this version we simply downsample each component independently. + */ + +METHODDEF(void) +sep_downsample (j_compress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_index, + JSAMPIMAGE output_buf, JDIMENSION out_row_group_index) +{ + my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample; + int ci; + jpeg_component_info * compptr; + JSAMPARRAY in_ptr, out_ptr; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + in_ptr = input_buf[ci] + in_row_index; + out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor); + (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr); + } +} + + +/* + * Downsample pixel values of a single component. + * One row group is processed per call. + * This version handles arbitrary integral sampling ratios, without smoothing. + * Note that this version is not actually used for customary sampling ratios. + */ + +METHODDEF(void) +int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v; + JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */ + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + JSAMPROW inptr, outptr; + INT32 outvalue; + + h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor; + v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor; + numpix = h_expand * v_expand; + numpix2 = numpix/2; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data, cinfo->max_v_samp_factor, + cinfo->image_width, output_cols * h_expand); + + inrow = 0; + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + for (outcol = 0, outcol_h = 0; outcol < output_cols; + outcol++, outcol_h += h_expand) { + outvalue = 0; + for (v = 0; v < v_expand; v++) { + inptr = input_data[inrow+v] + outcol_h; + for (h = 0; h < h_expand; h++) { + outvalue += (INT32) GETJSAMPLE(*inptr++); + } + } + *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix); + } + inrow += v_expand; + } +} + + +/* + * Downsample pixel values of a single component. + * This version handles the special case of a full-size component, + * without smoothing. + */ + +METHODDEF(void) +fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + /* Copy the data */ + jcopy_sample_rows(input_data, 0, output_data, 0, + cinfo->max_v_samp_factor, cinfo->image_width); + /* Edge-expand */ + expand_right_edge(output_data, cinfo->max_v_samp_factor, + cinfo->image_width, compptr->width_in_blocks * DCTSIZE); +} + + +/* + * Downsample pixel values of a single component. + * This version handles the common case of 2:1 horizontal and 1:1 vertical, + * without smoothing. + * + * A note about the "bias" calculations: when rounding fractional values to + * integer, we do not want to always round 0.5 up to the next integer. + * If we did that, we'd introduce a noticeable bias towards larger values. + * Instead, this code is arranged so that 0.5 will be rounded up or down at + * alternate pixel locations (a simple ordered dither pattern). + */ + +METHODDEF(void) +h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int outrow; + JDIMENSION outcol; + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + register JSAMPROW inptr, outptr; + register int bias; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data, cinfo->max_v_samp_factor, + cinfo->image_width, output_cols * 2); + + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + inptr = input_data[outrow]; + bias = 0; /* bias = 0,1,0,1,... for successive samples */ + for (outcol = 0; outcol < output_cols; outcol++) { + *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1]) + + bias) >> 1); + bias ^= 1; /* 0=>1, 1=>0 */ + inptr += 2; + } + } +} + + +/* + * Downsample pixel values of a single component. + * This version handles the standard case of 2:1 horizontal and 2:1 vertical, + * without smoothing. + */ + +METHODDEF(void) +h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int inrow, outrow; + JDIMENSION outcol; + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + register JSAMPROW inptr0, inptr1, outptr; + register int bias; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data, cinfo->max_v_samp_factor, + cinfo->image_width, output_cols * 2); + + inrow = 0; + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + inptr0 = input_data[inrow]; + inptr1 = input_data[inrow+1]; + bias = 1; /* bias = 1,2,1,2,... for successive samples */ + for (outcol = 0; outcol < output_cols; outcol++) { + *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]) + + bias) >> 2); + bias ^= 3; /* 1=>2, 2=>1 */ + inptr0 += 2; inptr1 += 2; + } + inrow += 2; + } +} + + +#ifdef INPUT_SMOOTHING_SUPPORTED + +/* + * Downsample pixel values of a single component. + * This version handles the standard case of 2:1 horizontal and 2:1 vertical, + * with smoothing. One row of context is required. + */ + +METHODDEF(void) +h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int inrow, outrow; + JDIMENSION colctr; + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr; + INT32 membersum, neighsum, memberscale, neighscale; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, + cinfo->image_width, output_cols * 2); + + /* We don't bother to form the individual "smoothed" input pixel values; + * we can directly compute the output which is the average of the four + * smoothed values. Each of the four member pixels contributes a fraction + * (1-8*SF) to its own smoothed image and a fraction SF to each of the three + * other smoothed pixels, therefore a total fraction (1-5*SF)/4 to the final + * output. The four corner-adjacent neighbor pixels contribute a fraction + * SF to just one smoothed pixel, or SF/4 to the final output; while the + * eight edge-adjacent neighbors contribute SF to each of two smoothed + * pixels, or SF/2 overall. In order to use integer arithmetic, these + * factors are scaled by 2^16 = 65536. + * Also recall that SF = smoothing_factor / 1024. + */ + + memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */ + neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */ + + inrow = 0; + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + inptr0 = input_data[inrow]; + inptr1 = input_data[inrow+1]; + above_ptr = input_data[inrow-1]; + below_ptr = input_data[inrow+2]; + + /* Special case for first column: pretend column -1 is same as column 0 */ + membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); + neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + + GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[2]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[2]); + neighsum += neighsum; + neighsum += GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[2]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]); + membersum = membersum * memberscale + neighsum * neighscale; + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; + + for (colctr = output_cols - 2; colctr > 0; colctr--) { + /* sum of pixels directly mapped to this output element */ + membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); + /* sum of edge-neighbor pixels */ + neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + + GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[2]) + + GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[2]); + /* The edge-neighbors count twice as much as corner-neighbors */ + neighsum += neighsum; + /* Add in the corner-neighbors */ + neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[2]) + + GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[2]); + /* form final output scaled up by 2^16 */ + membersum = membersum * memberscale + neighsum * neighscale; + /* round, descale and output it */ + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; + } + + /* Special case for last column */ + membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); + neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + + GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[1]); + neighsum += neighsum; + neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[1]); + membersum = membersum * memberscale + neighsum * neighscale; + *outptr = (JSAMPLE) ((membersum + 32768) >> 16); + + inrow += 2; + } +} + + +/* + * Downsample pixel values of a single component. + * This version handles the special case of a full-size component, + * with smoothing. One row of context is required. + */ + +METHODDEF(void) +fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int outrow; + JDIMENSION colctr; + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + register JSAMPROW inptr, above_ptr, below_ptr, outptr; + INT32 membersum, neighsum, memberscale, neighscale; + int colsum, lastcolsum, nextcolsum; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, + cinfo->image_width, output_cols); + + /* Each of the eight neighbor pixels contributes a fraction SF to the + * smoothed pixel, while the main pixel contributes (1-8*SF). In order + * to use integer arithmetic, these factors are multiplied by 2^16 = 65536. + * Also recall that SF = smoothing_factor / 1024. + */ + + memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */ + neighscale = cinfo->smoothing_factor * 64; /* scaled SF */ + + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + inptr = input_data[outrow]; + above_ptr = input_data[outrow-1]; + below_ptr = input_data[outrow+1]; + + /* Special case for first column */ + colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) + + GETJSAMPLE(*inptr); + membersum = GETJSAMPLE(*inptr++); + nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + + GETJSAMPLE(*inptr); + neighsum = colsum + (colsum - membersum) + nextcolsum; + membersum = membersum * memberscale + neighsum * neighscale; + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + lastcolsum = colsum; colsum = nextcolsum; + + for (colctr = output_cols - 2; colctr > 0; colctr--) { + membersum = GETJSAMPLE(*inptr++); + above_ptr++; below_ptr++; + nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + + GETJSAMPLE(*inptr); + neighsum = lastcolsum + (colsum - membersum) + nextcolsum; + membersum = membersum * memberscale + neighsum * neighscale; + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + lastcolsum = colsum; colsum = nextcolsum; + } + + /* Special case for last column */ + membersum = GETJSAMPLE(*inptr); + neighsum = lastcolsum + (colsum - membersum) + colsum; + membersum = membersum * memberscale + neighsum * neighscale; + *outptr = (JSAMPLE) ((membersum + 32768) >> 16); + + } +} + +#endif /* INPUT_SMOOTHING_SUPPORTED */ + + +/* + * Module initialization routine for downsampling. + * Note that we must select a routine for each component. + */ + +GLOBAL(void) +jinit_downsampler (j_compress_ptr cinfo) +{ + my_downsample_ptr downsample; + int ci; + jpeg_component_info * compptr; + boolean smoothok = TRUE; + + downsample = (my_downsample_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_downsampler)); + cinfo->downsample = (struct jpeg_downsampler *) downsample; + downsample->pub.start_pass = start_pass_downsample; + downsample->pub.downsample = sep_downsample; + downsample->pub.need_context_rows = FALSE; + + if (cinfo->CCIR601_sampling) + ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); + + /* Verify we can handle the sampling factors, and set up method pointers */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->h_samp_factor == cinfo->max_h_samp_factor && + compptr->v_samp_factor == cinfo->max_v_samp_factor) { +#ifdef INPUT_SMOOTHING_SUPPORTED + if (cinfo->smoothing_factor) { + downsample->methods[ci] = fullsize_smooth_downsample; + downsample->pub.need_context_rows = TRUE; + } else +#endif + downsample->methods[ci] = fullsize_downsample; + } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && + compptr->v_samp_factor == cinfo->max_v_samp_factor) { + smoothok = FALSE; + downsample->methods[ci] = h2v1_downsample; + } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && + compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) { +#ifdef INPUT_SMOOTHING_SUPPORTED + if (cinfo->smoothing_factor) { + downsample->methods[ci] = h2v2_smooth_downsample; + downsample->pub.need_context_rows = TRUE; + } else +#endif + downsample->methods[ci] = h2v2_downsample; + } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 && + (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) { + smoothok = FALSE; + downsample->methods[ci] = int_downsample; + } else + ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); + } + +#ifdef INPUT_SMOOTHING_SUPPORTED + if (cinfo->smoothing_factor && !smoothok) + TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL); +#endif +} diff --git a/src/dep/src/irrlicht/jpeglib/jctrans.c b/src/dep/src/irrlicht/jpeglib/jctrans.c index 8b36e36..0e6d707 100644 --- a/src/dep/src/irrlicht/jpeglib/jctrans.c +++ b/src/dep/src/irrlicht/jpeglib/jctrans.c @@ -1,388 +1,388 @@ -/* - * jctrans.c - * - * Copyright (C) 1995-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains library routines for transcoding compression, - * that is, writing raw DCT coefficient arrays to an output JPEG file. - * The routines in jcapimin.c will also be needed by a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(void) transencode_master_selection - JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); -LOCAL(void) transencode_coef_controller - JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); - - -/* - * Compression initialization for writing raw-coefficient data. - * Before calling this, all parameters and a data destination must be set up. - * Call jpeg_finish_compress() to actually write the data. - * - * The number of passed virtual arrays must match cinfo->num_components. - * Note that the virtual arrays need not be filled or even realized at - * the time write_coefficients is called; indeed, if the virtual arrays - * were requested from this compression object's memory manager, they - * typically will be realized during this routine and filled afterwards. - */ - -GLOBAL(void) -jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Mark all tables to be written */ - jpeg_suppress_tables(cinfo, FALSE); - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Perform master selection of active modules */ - transencode_master_selection(cinfo, coef_arrays); - /* Wait for jpeg_finish_compress() call */ - cinfo->next_scanline = 0; /* so jpeg_write_marker works */ - cinfo->global_state = CSTATE_WRCOEFS; -} - - -/* - * Initialize the compression object with default parameters, - * then copy from the source object all parameters needed for lossless - * transcoding. Parameters that can be varied without loss (such as - * scan script and Huffman optimization) are left in their default states. - */ - -GLOBAL(void) -jpeg_copy_critical_parameters (j_decompress_ptr srcinfo, - j_compress_ptr dstinfo) -{ - JQUANT_TBL ** qtblptr; - jpeg_component_info *incomp, *outcomp; - JQUANT_TBL *c_quant, *slot_quant; - int tblno, ci, coefi; - - /* Safety check to ensure start_compress not called yet. */ - if (dstinfo->global_state != CSTATE_START) - ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state); - /* Copy fundamental image dimensions */ - dstinfo->image_width = srcinfo->image_width; - dstinfo->image_height = srcinfo->image_height; - dstinfo->input_components = srcinfo->num_components; - dstinfo->in_color_space = srcinfo->jpeg_color_space; - /* Initialize all parameters to default values */ - jpeg_set_defaults(dstinfo); - /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. - * Fix it to get the right header markers for the image colorspace. - */ - jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space); - dstinfo->data_precision = srcinfo->data_precision; - dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; - /* Copy the source's quantization tables. */ - for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { - if (srcinfo->quant_tbl_ptrs[tblno] != NULL) { - qtblptr = & dstinfo->quant_tbl_ptrs[tblno]; - if (*qtblptr == NULL) - *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo); - MEMCOPY((*qtblptr)->quantval, - srcinfo->quant_tbl_ptrs[tblno]->quantval, - SIZEOF((*qtblptr)->quantval)); - (*qtblptr)->sent_table = FALSE; - } - } - /* Copy the source's per-component info. - * Note we assume jpeg_set_defaults has allocated the dest comp_info array. - */ - dstinfo->num_components = srcinfo->num_components; - if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS) - ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components, - MAX_COMPONENTS); - for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info; - ci < dstinfo->num_components; ci++, incomp++, outcomp++) { - outcomp->component_id = incomp->component_id; - outcomp->h_samp_factor = incomp->h_samp_factor; - outcomp->v_samp_factor = incomp->v_samp_factor; - outcomp->quant_tbl_no = incomp->quant_tbl_no; - /* Make sure saved quantization table for component matches the qtable - * slot. If not, the input file re-used this qtable slot. - * IJG encoder currently cannot duplicate this. - */ - tblno = outcomp->quant_tbl_no; - if (tblno < 0 || tblno >= NUM_QUANT_TBLS || - srcinfo->quant_tbl_ptrs[tblno] == NULL) - ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno); - slot_quant = srcinfo->quant_tbl_ptrs[tblno]; - c_quant = incomp->quant_table; - if (c_quant != NULL) { - for (coefi = 0; coefi < DCTSIZE2; coefi++) { - if (c_quant->quantval[coefi] != slot_quant->quantval[coefi]) - ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno); - } - } - /* Note: we do not copy the source's Huffman table assignments; - * instead we rely on jpeg_set_colorspace to have made a suitable choice. - */ - } - /* Also copy JFIF version and resolution information, if available. - * Strictly speaking this isn't "critical" info, but it's nearly - * always appropriate to copy it if available. In particular, - * if the application chooses to copy JFIF 1.02 extension markers from - * the source file, we need to copy the version to make sure we don't - * emit a file that has 1.02 extensions but a claimed version of 1.01. - * We will *not*, however, copy version info from mislabeled "2.01" files. - */ - if (srcinfo->saw_JFIF_marker) { - if (srcinfo->JFIF_major_version == 1) { - dstinfo->JFIF_major_version = srcinfo->JFIF_major_version; - dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version; - } - dstinfo->density_unit = srcinfo->density_unit; - dstinfo->X_density = srcinfo->X_density; - dstinfo->Y_density = srcinfo->Y_density; - } -} - - -/* - * Master selection of compression modules for transcoding. - * This substitutes for jcinit.c's initialization of the full compressor. - */ - -LOCAL(void) -transencode_master_selection (j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays) -{ - /* Although we don't actually use input_components for transcoding, - * jcmaster.c's initial_setup will complain if input_components is 0. - */ - cinfo->input_components = 1; - /* Initialize master control (includes parameter checking/processing) */ - jinit_c_master_control(cinfo, TRUE /* transcode only */); - - /* Entropy encoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - jinit_phuff_encoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_encoder(cinfo); - } - - /* We need a special coefficient buffer controller. */ - transencode_coef_controller(cinfo, coef_arrays); - - jinit_marker_writer(cinfo); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Write the datastream header (SOI, JFIF) immediately. - * Frame and scan headers are postponed till later. - * This lets application insert special markers after the SOI. - */ - (*cinfo->marker->write_file_header) (cinfo); -} - - -/* - * The rest of this file is a special implementation of the coefficient - * buffer controller. This is similar to jccoefct.c, but it handles only - * output from presupplied virtual arrays. Furthermore, we generate any - * dummy padding blocks on-the-fly rather than expecting them to be present - * in the arrays. - */ - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_coef_controller pub; /* public fields */ - - JDIMENSION iMCU_row_num; /* iMCU row # within image */ - JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* Virtual block array for each component. */ - jvirt_barray_ptr * whole_image; - - /* Workspace for constructing dummy blocks at right/bottom edges. */ - JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU]; -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - - -LOCAL(void) -start_iMCU_row (j_compress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->mcu_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - if (pass_mode != JBUF_CRANK_DEST) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - coef->iMCU_row_num = 0; - start_iMCU_row(cinfo); -} - - -/* - * Process some data. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the scan. - * The data is obtained from the virtual arrays and fed to the entropy coder. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf is ignored; it is likely to be a NULL pointer. - */ - -METHODDEF(boolean) -compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, ci, xindex, yindex, yoffset, blockcnt; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (coef->iMCU_row_num < last_iMCU_row || - yindex+yoffset < compptr->last_row_height) { - /* Fill in pointers to real blocks in this row */ - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < blockcnt; xindex++) - MCU_buffer[blkn++] = buffer_ptr++; - } else { - /* At bottom of image, need a whole row of dummy blocks */ - xindex = 0; - } - /* Fill in any dummy blocks needed in this row. - * Dummy blocks are filled in the same way as in jccoefct.c: - * all zeroes in the AC entries, DC entries equal to previous - * block's DC value. The init routine has already zeroed the - * AC entries, so we need only set the DC entries correctly. - */ - for (; xindex < compptr->MCU_width; xindex++) { - MCU_buffer[blkn] = coef->dummy_buffer[blkn]; - MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0]; - blkn++; - } - } - } - /* Try to write the MCU. */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - - -/* - * Initialize coefficient buffer controller. - * - * Each passed coefficient array must be the right size for that - * coefficient: width_in_blocks wide and height_in_blocks high, - * with unitheight at least v_samp_factor. - */ - -LOCAL(void) -transencode_coef_controller (j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays) -{ - my_coef_ptr coef; - JBLOCKROW buffer; - int i; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_c_coef_controller *) coef; - coef->pub.start_pass = start_pass_coef; - coef->pub.compress_data = compress_output; - - /* Save pointer to virtual arrays */ - coef->whole_image = coef_arrays; - - /* Allocate and pre-zero space for dummy DCT blocks. */ - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { - coef->dummy_buffer[i] = buffer + i; - } -} +/* + * jctrans.c + * + * Copyright (C) 1995-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains library routines for transcoding compression, + * that is, writing raw DCT coefficient arrays to an output JPEG file. + * The routines in jcapimin.c will also be needed by a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Forward declarations */ +LOCAL(void) transencode_master_selection + JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); +LOCAL(void) transencode_coef_controller + JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); + + +/* + * Compression initialization for writing raw-coefficient data. + * Before calling this, all parameters and a data destination must be set up. + * Call jpeg_finish_compress() to actually write the data. + * + * The number of passed virtual arrays must match cinfo->num_components. + * Note that the virtual arrays need not be filled or even realized at + * the time write_coefficients is called; indeed, if the virtual arrays + * were requested from this compression object's memory manager, they + * typically will be realized during this routine and filled afterwards. + */ + +GLOBAL(void) +jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays) +{ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Mark all tables to be written */ + jpeg_suppress_tables(cinfo, FALSE); + /* (Re)initialize error mgr and destination modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->dest->init_destination) (cinfo); + /* Perform master selection of active modules */ + transencode_master_selection(cinfo, coef_arrays); + /* Wait for jpeg_finish_compress() call */ + cinfo->next_scanline = 0; /* so jpeg_write_marker works */ + cinfo->global_state = CSTATE_WRCOEFS; +} + + +/* + * Initialize the compression object with default parameters, + * then copy from the source object all parameters needed for lossless + * transcoding. Parameters that can be varied without loss (such as + * scan script and Huffman optimization) are left in their default states. + */ + +GLOBAL(void) +jpeg_copy_critical_parameters (j_decompress_ptr srcinfo, + j_compress_ptr dstinfo) +{ + JQUANT_TBL ** qtblptr; + jpeg_component_info *incomp, *outcomp; + JQUANT_TBL *c_quant, *slot_quant; + int tblno, ci, coefi; + + /* Safety check to ensure start_compress not called yet. */ + if (dstinfo->global_state != CSTATE_START) + ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state); + /* Copy fundamental image dimensions */ + dstinfo->image_width = srcinfo->image_width; + dstinfo->image_height = srcinfo->image_height; + dstinfo->input_components = srcinfo->num_components; + dstinfo->in_color_space = srcinfo->jpeg_color_space; + /* Initialize all parameters to default values */ + jpeg_set_defaults(dstinfo); + /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. + * Fix it to get the right header markers for the image colorspace. + */ + jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space); + dstinfo->data_precision = srcinfo->data_precision; + dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; + /* Copy the source's quantization tables. */ + for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { + if (srcinfo->quant_tbl_ptrs[tblno] != NULL) { + qtblptr = & dstinfo->quant_tbl_ptrs[tblno]; + if (*qtblptr == NULL) + *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo); + MEMCOPY((*qtblptr)->quantval, + srcinfo->quant_tbl_ptrs[tblno]->quantval, + SIZEOF((*qtblptr)->quantval)); + (*qtblptr)->sent_table = FALSE; + } + } + /* Copy the source's per-component info. + * Note we assume jpeg_set_defaults has allocated the dest comp_info array. + */ + dstinfo->num_components = srcinfo->num_components; + if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS) + ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components, + MAX_COMPONENTS); + for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info; + ci < dstinfo->num_components; ci++, incomp++, outcomp++) { + outcomp->component_id = incomp->component_id; + outcomp->h_samp_factor = incomp->h_samp_factor; + outcomp->v_samp_factor = incomp->v_samp_factor; + outcomp->quant_tbl_no = incomp->quant_tbl_no; + /* Make sure saved quantization table for component matches the qtable + * slot. If not, the input file re-used this qtable slot. + * IJG encoder currently cannot duplicate this. + */ + tblno = outcomp->quant_tbl_no; + if (tblno < 0 || tblno >= NUM_QUANT_TBLS || + srcinfo->quant_tbl_ptrs[tblno] == NULL) + ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno); + slot_quant = srcinfo->quant_tbl_ptrs[tblno]; + c_quant = incomp->quant_table; + if (c_quant != NULL) { + for (coefi = 0; coefi < DCTSIZE2; coefi++) { + if (c_quant->quantval[coefi] != slot_quant->quantval[coefi]) + ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno); + } + } + /* Note: we do not copy the source's Huffman table assignments; + * instead we rely on jpeg_set_colorspace to have made a suitable choice. + */ + } + /* Also copy JFIF version and resolution information, if available. + * Strictly speaking this isn't "critical" info, but it's nearly + * always appropriate to copy it if available. In particular, + * if the application chooses to copy JFIF 1.02 extension markers from + * the source file, we need to copy the version to make sure we don't + * emit a file that has 1.02 extensions but a claimed version of 1.01. + * We will *not*, however, copy version info from mislabeled "2.01" files. + */ + if (srcinfo->saw_JFIF_marker) { + if (srcinfo->JFIF_major_version == 1) { + dstinfo->JFIF_major_version = srcinfo->JFIF_major_version; + dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version; + } + dstinfo->density_unit = srcinfo->density_unit; + dstinfo->X_density = srcinfo->X_density; + dstinfo->Y_density = srcinfo->Y_density; + } +} + + +/* + * Master selection of compression modules for transcoding. + * This substitutes for jcinit.c's initialization of the full compressor. + */ + +LOCAL(void) +transencode_master_selection (j_compress_ptr cinfo, + jvirt_barray_ptr * coef_arrays) +{ + /* Although we don't actually use input_components for transcoding, + * jcmaster.c's initial_setup will complain if input_components is 0. + */ + cinfo->input_components = 1; + /* Initialize master control (includes parameter checking/processing) */ + jinit_c_master_control(cinfo, TRUE /* transcode only */); + + /* Entropy encoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) { + ERREXIT(cinfo, JERR_ARITH_NOTIMPL); + } else { + if (cinfo->progressive_mode) { +#ifdef C_PROGRESSIVE_SUPPORTED + jinit_phuff_encoder(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else + jinit_huff_encoder(cinfo); + } + + /* We need a special coefficient buffer controller. */ + transencode_coef_controller(cinfo, coef_arrays); + + jinit_marker_writer(cinfo); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Write the datastream header (SOI, JFIF) immediately. + * Frame and scan headers are postponed till later. + * This lets application insert special markers after the SOI. + */ + (*cinfo->marker->write_file_header) (cinfo); +} + + +/* + * The rest of this file is a special implementation of the coefficient + * buffer controller. This is similar to jccoefct.c, but it handles only + * output from presupplied virtual arrays. Furthermore, we generate any + * dummy padding blocks on-the-fly rather than expecting them to be present + * in the arrays. + */ + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_coef_controller pub; /* public fields */ + + JDIMENSION iMCU_row_num; /* iMCU row # within image */ + JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ + int MCU_vert_offset; /* counts MCU rows within iMCU row */ + int MCU_rows_per_iMCU_row; /* number of such rows needed */ + + /* Virtual block array for each component. */ + jvirt_barray_ptr * whole_image; + + /* Workspace for constructing dummy blocks at right/bottom edges. */ + JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU]; +} my_coef_controller; + +typedef my_coef_controller * my_coef_ptr; + + +LOCAL(void) +start_iMCU_row (j_compress_ptr cinfo) +/* Reset within-iMCU-row counters for a new row */ +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* In an interleaved scan, an MCU row is the same as an iMCU row. + * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. + * But at the bottom of the image, process only what's left. + */ + if (cinfo->comps_in_scan > 1) { + coef->MCU_rows_per_iMCU_row = 1; + } else { + if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; + else + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; + } + + coef->mcu_ctr = 0; + coef->MCU_vert_offset = 0; +} + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + if (pass_mode != JBUF_CRANK_DEST) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + coef->iMCU_row_num = 0; + start_iMCU_row(cinfo); +} + + +/* + * Process some data. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the scan. + * The data is obtained from the virtual arrays and fed to the entropy coder. + * Returns TRUE if the iMCU row is completed, FALSE if suspended. + * + * NB: input_buf is ignored; it is likely to be a NULL pointer. + */ + +METHODDEF(boolean) +compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + int blkn, ci, xindex, yindex, yoffset, blockcnt; + JDIMENSION start_col; + JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; + JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; + JBLOCKROW buffer_ptr; + jpeg_component_info *compptr; + + /* Align the virtual buffers for the components used in this scan. */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + buffer[ci] = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], + coef->iMCU_row_num * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + + /* Loop to process one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; + MCU_col_num++) { + /* Construct list of pointers to DCT blocks belonging to this MCU */ + blkn = 0; /* index of current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + start_col = MCU_col_num * compptr->MCU_width; + blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width + : compptr->last_col_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + if (coef->iMCU_row_num < last_iMCU_row || + yindex+yoffset < compptr->last_row_height) { + /* Fill in pointers to real blocks in this row */ + buffer_ptr = buffer[ci][yindex+yoffset] + start_col; + for (xindex = 0; xindex < blockcnt; xindex++) + MCU_buffer[blkn++] = buffer_ptr++; + } else { + /* At bottom of image, need a whole row of dummy blocks */ + xindex = 0; + } + /* Fill in any dummy blocks needed in this row. + * Dummy blocks are filled in the same way as in jccoefct.c: + * all zeroes in the AC entries, DC entries equal to previous + * block's DC value. The init routine has already zeroed the + * AC entries, so we need only set the DC entries correctly. + */ + for (; xindex < compptr->MCU_width; xindex++) { + MCU_buffer[blkn] = coef->dummy_buffer[blkn]; + MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0]; + blkn++; + } + } + } + /* Try to write the MCU. */ + if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->mcu_ctr = MCU_col_num; + return FALSE; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->mcu_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + coef->iMCU_row_num++; + start_iMCU_row(cinfo); + return TRUE; +} + + +/* + * Initialize coefficient buffer controller. + * + * Each passed coefficient array must be the right size for that + * coefficient: width_in_blocks wide and height_in_blocks high, + * with unitheight at least v_samp_factor. + */ + +LOCAL(void) +transencode_coef_controller (j_compress_ptr cinfo, + jvirt_barray_ptr * coef_arrays) +{ + my_coef_ptr coef; + JBLOCKROW buffer; + int i; + + coef = (my_coef_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_coef_controller)); + cinfo->coef = (struct jpeg_c_coef_controller *) coef; + coef->pub.start_pass = start_pass_coef; + coef->pub.compress_data = compress_output; + + /* Save pointer to virtual arrays */ + coef->whole_image = coef_arrays; + + /* Allocate and pre-zero space for dummy DCT blocks. */ + buffer = (JBLOCKROW) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); + jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); + for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { + coef->dummy_buffer[i] = buffer + i; + } +} diff --git a/src/dep/src/irrlicht/jpeglib/jdapimin.c b/src/dep/src/irrlicht/jpeglib/jdapimin.c index bd1df92..cadb59f 100644 --- a/src/dep/src/irrlicht/jpeglib/jdapimin.c +++ b/src/dep/src/irrlicht/jpeglib/jdapimin.c @@ -1,395 +1,395 @@ -/* - * jdapimin.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the decompression half - * of the JPEG library. These are the "minimum" API routines that may be - * needed in either the normal full-decompression case or the - * transcoding-only case. - * - * Most of the routines intended to be called directly by an application - * are in this file or in jdapistd.c. But also see jcomapi.c for routines - * shared by compression and decompression, and jdtrans.c for the transcoding - * case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Initialization of a JPEG decompression object. - * The error manager must already be set up (in case memory manager fails). - */ - -GLOBAL(void) -jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize) -{ - int i; - - /* Guard against version mismatches between library and caller. */ - cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ - if (version != JPEG_LIB_VERSION) - ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); - if (structsize != SIZEOF(struct jpeg_decompress_struct)) - ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, - (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize); - - /* For debugging purposes, we zero the whole master structure. - * But the application has already set the err pointer, and may have set - * client_data, so we have to save and restore those fields. - * Note: if application hasn't set client_data, tools like Purify may - * complain here. - */ - { - struct jpeg_error_mgr * err = cinfo->err; - void * client_data = cinfo->client_data; /* ignore Purify complaint here */ - MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct)); - cinfo->err = err; - cinfo->client_data = client_data; - } - cinfo->is_decompressor = TRUE; - - /* Initialize a memory manager instance for this object */ - jinit_memory_mgr((j_common_ptr) cinfo); - - /* Zero out pointers to permanent structures. */ - cinfo->progress = NULL; - cinfo->src = NULL; - - for (i = 0; i < NUM_QUANT_TBLS; i++) - cinfo->quant_tbl_ptrs[i] = NULL; - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - cinfo->dc_huff_tbl_ptrs[i] = NULL; - cinfo->ac_huff_tbl_ptrs[i] = NULL; - } - - /* Initialize marker processor so application can override methods - * for COM, APPn markers before calling jpeg_read_header. - */ - cinfo->marker_list = NULL; - jinit_marker_reader(cinfo); - - /* And initialize the overall input controller. */ - jinit_input_controller(cinfo); - - /* OK, I'm ready */ - cinfo->global_state = DSTATE_START; -} - - -/* - * Destruction of a JPEG decompression object - */ - -GLOBAL(void) -jpeg_destroy_decompress (j_decompress_ptr cinfo) -{ - jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Abort processing of a JPEG decompression operation, - * but don't destroy the object itself. - */ - -GLOBAL(void) -jpeg_abort_decompress (j_decompress_ptr cinfo) -{ - jpeg_abort((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Set default decompression parameters. - */ - -LOCAL(void) -default_decompress_parms (j_decompress_ptr cinfo) -{ - /* Guess the input colorspace, and set output colorspace accordingly. */ - /* (Wish JPEG committee had provided a real way to specify this...) */ - /* Note application may override our guesses. */ - switch (cinfo->num_components) { - case 1: - cinfo->jpeg_color_space = JCS_GRAYSCALE; - cinfo->out_color_space = JCS_GRAYSCALE; - break; - - case 3: - if (cinfo->saw_JFIF_marker) { - cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */ - } else if (cinfo->saw_Adobe_marker) { - switch (cinfo->Adobe_transform) { - case 0: - cinfo->jpeg_color_space = JCS_RGB; - break; - case 1: - cinfo->jpeg_color_space = JCS_YCbCr; - break; - default: - WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); - cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ - break; - } - } else { - /* Saw no special markers, try to guess from the component IDs */ - int cid0 = cinfo->comp_info[0].component_id; - int cid1 = cinfo->comp_info[1].component_id; - int cid2 = cinfo->comp_info[2].component_id; - - if (cid0 == 1 && cid1 == 2 && cid2 == 3) - cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */ - else if (cid0 == 82 && cid1 == 71 && cid2 == 66) - cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */ - else { - TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2); - cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ - } - } - /* Always guess RGB is proper output colorspace. */ - cinfo->out_color_space = JCS_RGB; - break; - - case 4: - if (cinfo->saw_Adobe_marker) { - switch (cinfo->Adobe_transform) { - case 0: - cinfo->jpeg_color_space = JCS_CMYK; - break; - case 2: - cinfo->jpeg_color_space = JCS_YCCK; - break; - default: - WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); - cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */ - break; - } - } else { - /* No special markers, assume straight CMYK. */ - cinfo->jpeg_color_space = JCS_CMYK; - } - cinfo->out_color_space = JCS_CMYK; - break; - - default: - cinfo->jpeg_color_space = JCS_UNKNOWN; - cinfo->out_color_space = JCS_UNKNOWN; - break; - } - - /* Set defaults for other decompression parameters. */ - cinfo->scale_num = 1; /* 1:1 scaling */ - cinfo->scale_denom = 1; - cinfo->output_gamma = 1.0; - cinfo->buffered_image = FALSE; - cinfo->raw_data_out = FALSE; - cinfo->dct_method = JDCT_DEFAULT; - cinfo->do_fancy_upsampling = TRUE; - cinfo->do_block_smoothing = TRUE; - cinfo->quantize_colors = FALSE; - /* We set these in case application only sets quantize_colors. */ - cinfo->dither_mode = JDITHER_FS; -#ifdef QUANT_2PASS_SUPPORTED - cinfo->two_pass_quantize = TRUE; -#else - cinfo->two_pass_quantize = FALSE; -#endif - cinfo->desired_number_of_colors = 256; - cinfo->colormap = NULL; - /* Initialize for no mode change in buffered-image mode. */ - cinfo->enable_1pass_quant = FALSE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; -} - - -/* - * Decompression startup: read start of JPEG datastream to see what's there. - * Need only initialize JPEG object and supply a data source before calling. - * - * This routine will read as far as the first SOS marker (ie, actual start of - * compressed data), and will save all tables and parameters in the JPEG - * object. It will also initialize the decompression parameters to default - * values, and finally return JPEG_HEADER_OK. On return, the application may - * adjust the decompression parameters and then call jpeg_start_decompress. - * (Or, if the application only wanted to determine the image parameters, - * the data need not be decompressed. In that case, call jpeg_abort or - * jpeg_destroy to release any temporary space.) - * If an abbreviated (tables only) datastream is presented, the routine will - * return JPEG_HEADER_TABLES_ONLY upon reaching EOI. The application may then - * re-use the JPEG object to read the abbreviated image datastream(s). - * It is unnecessary (but OK) to call jpeg_abort in this case. - * The JPEG_SUSPENDED return code only occurs if the data source module - * requests suspension of the decompressor. In this case the application - * should load more source data and then re-call jpeg_read_header to resume - * processing. - * If a non-suspending data source is used and require_image is TRUE, then the - * return code need not be inspected since only JPEG_HEADER_OK is possible. - * - * This routine is now just a front end to jpeg_consume_input, with some - * extra error checking. - */ - -GLOBAL(int) -jpeg_read_header (j_decompress_ptr cinfo, boolean require_image) -{ - int retcode; - - if (cinfo->global_state != DSTATE_START && - cinfo->global_state != DSTATE_INHEADER) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - retcode = jpeg_consume_input(cinfo); - - switch (retcode) { - case JPEG_REACHED_SOS: - retcode = JPEG_HEADER_OK; - break; - case JPEG_REACHED_EOI: - if (require_image) /* Complain if application wanted an image */ - ERREXIT(cinfo, JERR_NO_IMAGE); - /* Reset to start state; it would be safer to require the application to - * call jpeg_abort, but we can't change it now for compatibility reasons. - * A side effect is to free any temporary memory (there shouldn't be any). - */ - jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */ - retcode = JPEG_HEADER_TABLES_ONLY; - break; - case JPEG_SUSPENDED: - /* no work */ - break; - } - - return retcode; -} - - -/* - * Consume data in advance of what the decompressor requires. - * This can be called at any time once the decompressor object has - * been created and a data source has been set up. - * - * This routine is essentially a state machine that handles a couple - * of critical state-transition actions, namely initial setup and - * transition from header scanning to ready-for-start_decompress. - * All the actual input is done via the input controller's consume_input - * method. - */ - -GLOBAL(int) -jpeg_consume_input (j_decompress_ptr cinfo) -{ - int retcode = JPEG_SUSPENDED; - - /* NB: every possible DSTATE value should be listed in this switch */ - switch (cinfo->global_state) { - case DSTATE_START: - /* Start-of-datastream actions: reset appropriate modules */ - (*cinfo->inputctl->reset_input_controller) (cinfo); - /* Initialize application's data source module */ - (*cinfo->src->init_source) (cinfo); - cinfo->global_state = DSTATE_INHEADER; - /*FALLTHROUGH*/ - case DSTATE_INHEADER: - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */ - /* Set up default parameters based on header data */ - default_decompress_parms(cinfo); - /* Set global state: ready for start_decompress */ - cinfo->global_state = DSTATE_READY; - } - break; - case DSTATE_READY: - /* Can't advance past first SOS until start_decompress is called */ - retcode = JPEG_REACHED_SOS; - break; - case DSTATE_PRELOAD: - case DSTATE_PRESCAN: - case DSTATE_SCANNING: - case DSTATE_RAW_OK: - case DSTATE_BUFIMAGE: - case DSTATE_BUFPOST: - case DSTATE_STOPPING: - retcode = (*cinfo->inputctl->consume_input) (cinfo); - break; - default: - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - return retcode; -} - - -/* - * Have we finished reading the input file? - */ - -GLOBAL(boolean) -jpeg_input_complete (j_decompress_ptr cinfo) -{ - /* Check for valid jpeg object */ - if (cinfo->global_state < DSTATE_START || - cinfo->global_state > DSTATE_STOPPING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return cinfo->inputctl->eoi_reached; -} - - -/* - * Is there more than one scan? - */ - -GLOBAL(boolean) -jpeg_has_multiple_scans (j_decompress_ptr cinfo) -{ - /* Only valid after jpeg_read_header completes */ - if (cinfo->global_state < DSTATE_READY || - cinfo->global_state > DSTATE_STOPPING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return cinfo->inputctl->has_multiple_scans; -} - - -/* - * Finish JPEG decompression. - * - * This will normally just verify the file trailer and release temp storage. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_finish_decompress (j_decompress_ptr cinfo) -{ - if ((cinfo->global_state == DSTATE_SCANNING || - cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) { - /* Terminate final pass of non-buffered mode */ - if (cinfo->output_scanline < cinfo->output_height) - ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); - (*cinfo->master->finish_output_pass) (cinfo); - cinfo->global_state = DSTATE_STOPPING; - } else if (cinfo->global_state == DSTATE_BUFIMAGE) { - /* Finishing after a buffered-image operation */ - cinfo->global_state = DSTATE_STOPPING; - } else if (cinfo->global_state != DSTATE_STOPPING) { - /* STOPPING = repeat call after a suspension, anything else is error */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - /* Read until EOI */ - while (! cinfo->inputctl->eoi_reached) { - if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) - return FALSE; /* Suspend, come back later */ - } - /* Do final cleanup */ - (*cinfo->src->term_source) (cinfo); - /* We can use jpeg_abort to release memory and reset global_state */ - jpeg_abort((j_common_ptr) cinfo); - return TRUE; -} +/* + * jdapimin.c + * + * Copyright (C) 1994-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the decompression half + * of the JPEG library. These are the "minimum" API routines that may be + * needed in either the normal full-decompression case or the + * transcoding-only case. + * + * Most of the routines intended to be called directly by an application + * are in this file or in jdapistd.c. But also see jcomapi.c for routines + * shared by compression and decompression, and jdtrans.c for the transcoding + * case. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Initialization of a JPEG decompression object. + * The error manager must already be set up (in case memory manager fails). + */ + +GLOBAL(void) +jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize) +{ + int i; + + /* Guard against version mismatches between library and caller. */ + cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ + if (version != JPEG_LIB_VERSION) + ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); + if (structsize != SIZEOF(struct jpeg_decompress_struct)) + ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, + (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize); + + /* For debugging purposes, we zero the whole master structure. + * But the application has already set the err pointer, and may have set + * client_data, so we have to save and restore those fields. + * Note: if application hasn't set client_data, tools like Purify may + * complain here. + */ + { + struct jpeg_error_mgr * err = cinfo->err; + void * client_data = cinfo->client_data; /* ignore Purify complaint here */ + MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct)); + cinfo->err = err; + cinfo->client_data = client_data; + } + cinfo->is_decompressor = TRUE; + + /* Initialize a memory manager instance for this object */ + jinit_memory_mgr((j_common_ptr) cinfo); + + /* Zero out pointers to permanent structures. */ + cinfo->progress = NULL; + cinfo->src = NULL; + + for (i = 0; i < NUM_QUANT_TBLS; i++) + cinfo->quant_tbl_ptrs[i] = NULL; + + for (i = 0; i < NUM_HUFF_TBLS; i++) { + cinfo->dc_huff_tbl_ptrs[i] = NULL; + cinfo->ac_huff_tbl_ptrs[i] = NULL; + } + + /* Initialize marker processor so application can override methods + * for COM, APPn markers before calling jpeg_read_header. + */ + cinfo->marker_list = NULL; + jinit_marker_reader(cinfo); + + /* And initialize the overall input controller. */ + jinit_input_controller(cinfo); + + /* OK, I'm ready */ + cinfo->global_state = DSTATE_START; +} + + +/* + * Destruction of a JPEG decompression object + */ + +GLOBAL(void) +jpeg_destroy_decompress (j_decompress_ptr cinfo) +{ + jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Abort processing of a JPEG decompression operation, + * but don't destroy the object itself. + */ + +GLOBAL(void) +jpeg_abort_decompress (j_decompress_ptr cinfo) +{ + jpeg_abort((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Set default decompression parameters. + */ + +LOCAL(void) +default_decompress_parms (j_decompress_ptr cinfo) +{ + /* Guess the input colorspace, and set output colorspace accordingly. */ + /* (Wish JPEG committee had provided a real way to specify this...) */ + /* Note application may override our guesses. */ + switch (cinfo->num_components) { + case 1: + cinfo->jpeg_color_space = JCS_GRAYSCALE; + cinfo->out_color_space = JCS_GRAYSCALE; + break; + + case 3: + if (cinfo->saw_JFIF_marker) { + cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */ + } else if (cinfo->saw_Adobe_marker) { + switch (cinfo->Adobe_transform) { + case 0: + cinfo->jpeg_color_space = JCS_RGB; + break; + case 1: + cinfo->jpeg_color_space = JCS_YCbCr; + break; + default: + WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); + cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ + break; + } + } else { + /* Saw no special markers, try to guess from the component IDs */ + int cid0 = cinfo->comp_info[0].component_id; + int cid1 = cinfo->comp_info[1].component_id; + int cid2 = cinfo->comp_info[2].component_id; + + if (cid0 == 1 && cid1 == 2 && cid2 == 3) + cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */ + else if (cid0 == 82 && cid1 == 71 && cid2 == 66) + cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */ + else { + TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2); + cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ + } + } + /* Always guess RGB is proper output colorspace. */ + cinfo->out_color_space = JCS_RGB; + break; + + case 4: + if (cinfo->saw_Adobe_marker) { + switch (cinfo->Adobe_transform) { + case 0: + cinfo->jpeg_color_space = JCS_CMYK; + break; + case 2: + cinfo->jpeg_color_space = JCS_YCCK; + break; + default: + WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); + cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */ + break; + } + } else { + /* No special markers, assume straight CMYK. */ + cinfo->jpeg_color_space = JCS_CMYK; + } + cinfo->out_color_space = JCS_CMYK; + break; + + default: + cinfo->jpeg_color_space = JCS_UNKNOWN; + cinfo->out_color_space = JCS_UNKNOWN; + break; + } + + /* Set defaults for other decompression parameters. */ + cinfo->scale_num = 1; /* 1:1 scaling */ + cinfo->scale_denom = 1; + cinfo->output_gamma = 1.0; + cinfo->buffered_image = FALSE; + cinfo->raw_data_out = FALSE; + cinfo->dct_method = JDCT_DEFAULT; + cinfo->do_fancy_upsampling = TRUE; + cinfo->do_block_smoothing = TRUE; + cinfo->quantize_colors = FALSE; + /* We set these in case application only sets quantize_colors. */ + cinfo->dither_mode = JDITHER_FS; +#ifdef QUANT_2PASS_SUPPORTED + cinfo->two_pass_quantize = TRUE; +#else + cinfo->two_pass_quantize = FALSE; +#endif + cinfo->desired_number_of_colors = 256; + cinfo->colormap = NULL; + /* Initialize for no mode change in buffered-image mode. */ + cinfo->enable_1pass_quant = FALSE; + cinfo->enable_external_quant = FALSE; + cinfo->enable_2pass_quant = FALSE; +} + + +/* + * Decompression startup: read start of JPEG datastream to see what's there. + * Need only initialize JPEG object and supply a data source before calling. + * + * This routine will read as far as the first SOS marker (ie, actual start of + * compressed data), and will save all tables and parameters in the JPEG + * object. It will also initialize the decompression parameters to default + * values, and finally return JPEG_HEADER_OK. On return, the application may + * adjust the decompression parameters and then call jpeg_start_decompress. + * (Or, if the application only wanted to determine the image parameters, + * the data need not be decompressed. In that case, call jpeg_abort or + * jpeg_destroy to release any temporary space.) + * If an abbreviated (tables only) datastream is presented, the routine will + * return JPEG_HEADER_TABLES_ONLY upon reaching EOI. The application may then + * re-use the JPEG object to read the abbreviated image datastream(s). + * It is unnecessary (but OK) to call jpeg_abort in this case. + * The JPEG_SUSPENDED return code only occurs if the data source module + * requests suspension of the decompressor. In this case the application + * should load more source data and then re-call jpeg_read_header to resume + * processing. + * If a non-suspending data source is used and require_image is TRUE, then the + * return code need not be inspected since only JPEG_HEADER_OK is possible. + * + * This routine is now just a front end to jpeg_consume_input, with some + * extra error checking. + */ + +GLOBAL(int) +jpeg_read_header (j_decompress_ptr cinfo, boolean require_image) +{ + int retcode; + + if (cinfo->global_state != DSTATE_START && + cinfo->global_state != DSTATE_INHEADER) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + retcode = jpeg_consume_input(cinfo); + + switch (retcode) { + case JPEG_REACHED_SOS: + retcode = JPEG_HEADER_OK; + break; + case JPEG_REACHED_EOI: + if (require_image) /* Complain if application wanted an image */ + ERREXIT(cinfo, JERR_NO_IMAGE); + /* Reset to start state; it would be safer to require the application to + * call jpeg_abort, but we can't change it now for compatibility reasons. + * A side effect is to free any temporary memory (there shouldn't be any). + */ + jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */ + retcode = JPEG_HEADER_TABLES_ONLY; + break; + case JPEG_SUSPENDED: + /* no work */ + break; + } + + return retcode; +} + + +/* + * Consume data in advance of what the decompressor requires. + * This can be called at any time once the decompressor object has + * been created and a data source has been set up. + * + * This routine is essentially a state machine that handles a couple + * of critical state-transition actions, namely initial setup and + * transition from header scanning to ready-for-start_decompress. + * All the actual input is done via the input controller's consume_input + * method. + */ + +GLOBAL(int) +jpeg_consume_input (j_decompress_ptr cinfo) +{ + int retcode = JPEG_SUSPENDED; + + /* NB: every possible DSTATE value should be listed in this switch */ + switch (cinfo->global_state) { + case DSTATE_START: + /* Start-of-datastream actions: reset appropriate modules */ + (*cinfo->inputctl->reset_input_controller) (cinfo); + /* Initialize application's data source module */ + (*cinfo->src->init_source) (cinfo); + cinfo->global_state = DSTATE_INHEADER; + /*FALLTHROUGH*/ + case DSTATE_INHEADER: + retcode = (*cinfo->inputctl->consume_input) (cinfo); + if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */ + /* Set up default parameters based on header data */ + default_decompress_parms(cinfo); + /* Set global state: ready for start_decompress */ + cinfo->global_state = DSTATE_READY; + } + break; + case DSTATE_READY: + /* Can't advance past first SOS until start_decompress is called */ + retcode = JPEG_REACHED_SOS; + break; + case DSTATE_PRELOAD: + case DSTATE_PRESCAN: + case DSTATE_SCANNING: + case DSTATE_RAW_OK: + case DSTATE_BUFIMAGE: + case DSTATE_BUFPOST: + case DSTATE_STOPPING: + retcode = (*cinfo->inputctl->consume_input) (cinfo); + break; + default: + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + } + return retcode; +} + + +/* + * Have we finished reading the input file? + */ + +GLOBAL(boolean) +jpeg_input_complete (j_decompress_ptr cinfo) +{ + /* Check for valid jpeg object */ + if (cinfo->global_state < DSTATE_START || + cinfo->global_state > DSTATE_STOPPING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + return cinfo->inputctl->eoi_reached; +} + + +/* + * Is there more than one scan? + */ + +GLOBAL(boolean) +jpeg_has_multiple_scans (j_decompress_ptr cinfo) +{ + /* Only valid after jpeg_read_header completes */ + if (cinfo->global_state < DSTATE_READY || + cinfo->global_state > DSTATE_STOPPING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + return cinfo->inputctl->has_multiple_scans; +} + + +/* + * Finish JPEG decompression. + * + * This will normally just verify the file trailer and release temp storage. + * + * Returns FALSE if suspended. The return value need be inspected only if + * a suspending data source is used. + */ + +GLOBAL(boolean) +jpeg_finish_decompress (j_decompress_ptr cinfo) +{ + if ((cinfo->global_state == DSTATE_SCANNING || + cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) { + /* Terminate final pass of non-buffered mode */ + if (cinfo->output_scanline < cinfo->output_height) + ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); + (*cinfo->master->finish_output_pass) (cinfo); + cinfo->global_state = DSTATE_STOPPING; + } else if (cinfo->global_state == DSTATE_BUFIMAGE) { + /* Finishing after a buffered-image operation */ + cinfo->global_state = DSTATE_STOPPING; + } else if (cinfo->global_state != DSTATE_STOPPING) { + /* STOPPING = repeat call after a suspension, anything else is error */ + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + } + /* Read until EOI */ + while (! cinfo->inputctl->eoi_reached) { + if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) + return FALSE; /* Suspend, come back later */ + } + /* Do final cleanup */ + (*cinfo->src->term_source) (cinfo); + /* We can use jpeg_abort to release memory and reset global_state */ + jpeg_abort((j_common_ptr) cinfo); + return TRUE; +} diff --git a/src/dep/src/irrlicht/jpeglib/jdapistd.c b/src/dep/src/irrlicht/jpeglib/jdapistd.c index f6c7fff..c8e3fa0 100644 --- a/src/dep/src/irrlicht/jpeglib/jdapistd.c +++ b/src/dep/src/irrlicht/jpeglib/jdapistd.c @@ -1,275 +1,275 @@ -/* - * jdapistd.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the decompression half - * of the JPEG library. These are the "standard" API routines that are - * used in the normal full-decompression case. They are not used by a - * transcoding-only application. Note that if an application links in - * jpeg_start_decompress, it will end up linking in the entire decompressor. - * We thus must separate this file from jdapimin.c to avoid linking the - * whole decompression library into a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo)); - - -/* - * Decompression initialization. - * jpeg_read_header must be completed before calling this. - * - * If a multipass operating mode was selected, this will do all but the - * last pass, and thus may take a great deal of time. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_start_decompress (j_decompress_ptr cinfo) -{ - if (cinfo->global_state == DSTATE_READY) { - /* First call: initialize master control, select active modules */ - jinit_master_decompress(cinfo); - if (cinfo->buffered_image) { - /* No more work here; expecting jpeg_start_output next */ - cinfo->global_state = DSTATE_BUFIMAGE; - return TRUE; - } - cinfo->global_state = DSTATE_PRELOAD; - } - if (cinfo->global_state == DSTATE_PRELOAD) { - /* If file has multiple scans, absorb them all into the coef buffer */ - if (cinfo->inputctl->has_multiple_scans) { -#ifdef D_MULTISCAN_FILES_SUPPORTED - for (;;) { - int retcode; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - /* Absorb some more input */ - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_SUSPENDED) - return FALSE; - if (retcode == JPEG_REACHED_EOI) - break; - /* Advance progress counter if appropriate */ - if (cinfo->progress != NULL && - (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { - if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { - /* jdmaster underestimated number of scans; ratchet up one scan */ - cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; - } - } - } -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - } - cinfo->output_scan_number = cinfo->input_scan_number; - } else if (cinfo->global_state != DSTATE_PRESCAN) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Perform any dummy output passes, and set up for the final pass */ - return output_pass_setup(cinfo); -} - - -/* - * Set up for an output pass, and perform any dummy pass(es) needed. - * Common subroutine for jpeg_start_decompress and jpeg_start_output. - * Entry: global_state = DSTATE_PRESCAN only if previously suspended. - * Exit: If done, returns TRUE and sets global_state for proper output mode. - * If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN. - */ - -LOCAL(boolean) -output_pass_setup (j_decompress_ptr cinfo) -{ - if (cinfo->global_state != DSTATE_PRESCAN) { - /* First call: do pass setup */ - (*cinfo->master->prepare_for_output_pass) (cinfo); - cinfo->output_scanline = 0; - cinfo->global_state = DSTATE_PRESCAN; - } - /* Loop over any required dummy passes */ - while (cinfo->master->is_dummy_pass) { -#ifdef QUANT_2PASS_SUPPORTED - /* Crank through the dummy pass */ - while (cinfo->output_scanline < cinfo->output_height) { - JDIMENSION last_scanline; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - /* Process some data */ - last_scanline = cinfo->output_scanline; - (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL, - &cinfo->output_scanline, (JDIMENSION) 0); - if (cinfo->output_scanline == last_scanline) - return FALSE; /* No progress made, must suspend */ - } - /* Finish up dummy pass, and set up for another one */ - (*cinfo->master->finish_output_pass) (cinfo); - (*cinfo->master->prepare_for_output_pass) (cinfo); - cinfo->output_scanline = 0; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* QUANT_2PASS_SUPPORTED */ - } - /* Ready for application to drive output pass through - * jpeg_read_scanlines or jpeg_read_raw_data. - */ - cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING; - return TRUE; -} - - -/* - * Read some scanlines of data from the JPEG decompressor. - * - * The return value will be the number of lines actually read. - * This may be less than the number requested in several cases, - * including bottom of image, data source suspension, and operating - * modes that emit multiple scanlines at a time. - * - * Note: we warn about excess calls to jpeg_read_scanlines() since - * this likely signals an application programmer error. However, - * an oversize buffer (max_lines > scanlines remaining) is not an error. - */ - -GLOBAL(JDIMENSION) -jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, - JDIMENSION max_lines) -{ - JDIMENSION row_ctr; - - if (cinfo->global_state != DSTATE_SCANNING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->output_scanline >= cinfo->output_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Process some data */ - row_ctr = 0; - (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines); - cinfo->output_scanline += row_ctr; - return row_ctr; -} - - -/* - * Alternate entry point to read raw data. - * Processes exactly one iMCU row per call, unless suspended. - */ - -GLOBAL(JDIMENSION) -jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, - JDIMENSION max_lines) -{ - JDIMENSION lines_per_iMCU_row; - - if (cinfo->global_state != DSTATE_RAW_OK) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->output_scanline >= cinfo->output_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Verify that at least one iMCU row can be returned. */ - lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size; - if (max_lines < lines_per_iMCU_row) - ERREXIT(cinfo, JERR_BUFFER_SIZE); - - /* Decompress directly into user's buffer. */ - if (! (*cinfo->coef->decompress_data) (cinfo, data)) - return 0; /* suspension forced, can do nothing more */ - - /* OK, we processed one iMCU row. */ - cinfo->output_scanline += lines_per_iMCU_row; - return lines_per_iMCU_row; -} - - -/* Additional entry points for buffered-image mode. */ - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Initialize for an output pass in buffered-image mode. - */ - -GLOBAL(boolean) -jpeg_start_output (j_decompress_ptr cinfo, int scan_number) -{ - if (cinfo->global_state != DSTATE_BUFIMAGE && - cinfo->global_state != DSTATE_PRESCAN) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Limit scan number to valid range */ - if (scan_number <= 0) - scan_number = 1; - if (cinfo->inputctl->eoi_reached && - scan_number > cinfo->input_scan_number) - scan_number = cinfo->input_scan_number; - cinfo->output_scan_number = scan_number; - /* Perform any dummy output passes, and set up for the real pass */ - return output_pass_setup(cinfo); -} - - -/* - * Finish up after an output pass in buffered-image mode. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_finish_output (j_decompress_ptr cinfo) -{ - if ((cinfo->global_state == DSTATE_SCANNING || - cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) { - /* Terminate this pass. */ - /* We do not require the whole pass to have been completed. */ - (*cinfo->master->finish_output_pass) (cinfo); - cinfo->global_state = DSTATE_BUFPOST; - } else if (cinfo->global_state != DSTATE_BUFPOST) { - /* BUFPOST = repeat call after a suspension, anything else is error */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - /* Read markers looking for SOS or EOI */ - while (cinfo->input_scan_number <= cinfo->output_scan_number && - ! cinfo->inputctl->eoi_reached) { - if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) - return FALSE; /* Suspend, come back later */ - } - cinfo->global_state = DSTATE_BUFIMAGE; - return TRUE; -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ +/* + * jdapistd.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the decompression half + * of the JPEG library. These are the "standard" API routines that are + * used in the normal full-decompression case. They are not used by a + * transcoding-only application. Note that if an application links in + * jpeg_start_decompress, it will end up linking in the entire decompressor. + * We thus must separate this file from jdapimin.c to avoid linking the + * whole decompression library into a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Forward declarations */ +LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo)); + + +/* + * Decompression initialization. + * jpeg_read_header must be completed before calling this. + * + * If a multipass operating mode was selected, this will do all but the + * last pass, and thus may take a great deal of time. + * + * Returns FALSE if suspended. The return value need be inspected only if + * a suspending data source is used. + */ + +GLOBAL(boolean) +jpeg_start_decompress (j_decompress_ptr cinfo) +{ + if (cinfo->global_state == DSTATE_READY) { + /* First call: initialize master control, select active modules */ + jinit_master_decompress(cinfo); + if (cinfo->buffered_image) { + /* No more work here; expecting jpeg_start_output next */ + cinfo->global_state = DSTATE_BUFIMAGE; + return TRUE; + } + cinfo->global_state = DSTATE_PRELOAD; + } + if (cinfo->global_state == DSTATE_PRELOAD) { + /* If file has multiple scans, absorb them all into the coef buffer */ + if (cinfo->inputctl->has_multiple_scans) { +#ifdef D_MULTISCAN_FILES_SUPPORTED + for (;;) { + int retcode; + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + /* Absorb some more input */ + retcode = (*cinfo->inputctl->consume_input) (cinfo); + if (retcode == JPEG_SUSPENDED) + return FALSE; + if (retcode == JPEG_REACHED_EOI) + break; + /* Advance progress counter if appropriate */ + if (cinfo->progress != NULL && + (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { + if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { + /* jdmaster underestimated number of scans; ratchet up one scan */ + cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; + } + } + } +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif /* D_MULTISCAN_FILES_SUPPORTED */ + } + cinfo->output_scan_number = cinfo->input_scan_number; + } else if (cinfo->global_state != DSTATE_PRESCAN) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Perform any dummy output passes, and set up for the final pass */ + return output_pass_setup(cinfo); +} + + +/* + * Set up for an output pass, and perform any dummy pass(es) needed. + * Common subroutine for jpeg_start_decompress and jpeg_start_output. + * Entry: global_state = DSTATE_PRESCAN only if previously suspended. + * Exit: If done, returns TRUE and sets global_state for proper output mode. + * If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN. + */ + +LOCAL(boolean) +output_pass_setup (j_decompress_ptr cinfo) +{ + if (cinfo->global_state != DSTATE_PRESCAN) { + /* First call: do pass setup */ + (*cinfo->master->prepare_for_output_pass) (cinfo); + cinfo->output_scanline = 0; + cinfo->global_state = DSTATE_PRESCAN; + } + /* Loop over any required dummy passes */ + while (cinfo->master->is_dummy_pass) { +#ifdef QUANT_2PASS_SUPPORTED + /* Crank through the dummy pass */ + while (cinfo->output_scanline < cinfo->output_height) { + JDIMENSION last_scanline; + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->output_scanline; + cinfo->progress->pass_limit = (long) cinfo->output_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + /* Process some data */ + last_scanline = cinfo->output_scanline; + (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL, + &cinfo->output_scanline, (JDIMENSION) 0); + if (cinfo->output_scanline == last_scanline) + return FALSE; /* No progress made, must suspend */ + } + /* Finish up dummy pass, and set up for another one */ + (*cinfo->master->finish_output_pass) (cinfo); + (*cinfo->master->prepare_for_output_pass) (cinfo); + cinfo->output_scanline = 0; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif /* QUANT_2PASS_SUPPORTED */ + } + /* Ready for application to drive output pass through + * jpeg_read_scanlines or jpeg_read_raw_data. + */ + cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING; + return TRUE; +} + + +/* + * Read some scanlines of data from the JPEG decompressor. + * + * The return value will be the number of lines actually read. + * This may be less than the number requested in several cases, + * including bottom of image, data source suspension, and operating + * modes that emit multiple scanlines at a time. + * + * Note: we warn about excess calls to jpeg_read_scanlines() since + * this likely signals an application programmer error. However, + * an oversize buffer (max_lines > scanlines remaining) is not an error. + */ + +GLOBAL(JDIMENSION) +jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, + JDIMENSION max_lines) +{ + JDIMENSION row_ctr; + + if (cinfo->global_state != DSTATE_SCANNING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->output_scanline >= cinfo->output_height) { + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + return 0; + } + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->output_scanline; + cinfo->progress->pass_limit = (long) cinfo->output_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Process some data */ + row_ctr = 0; + (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines); + cinfo->output_scanline += row_ctr; + return row_ctr; +} + + +/* + * Alternate entry point to read raw data. + * Processes exactly one iMCU row per call, unless suspended. + */ + +GLOBAL(JDIMENSION) +jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, + JDIMENSION max_lines) +{ + JDIMENSION lines_per_iMCU_row; + + if (cinfo->global_state != DSTATE_RAW_OK) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->output_scanline >= cinfo->output_height) { + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + return 0; + } + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->output_scanline; + cinfo->progress->pass_limit = (long) cinfo->output_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Verify that at least one iMCU row can be returned. */ + lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size; + if (max_lines < lines_per_iMCU_row) + ERREXIT(cinfo, JERR_BUFFER_SIZE); + + /* Decompress directly into user's buffer. */ + if (! (*cinfo->coef->decompress_data) (cinfo, data)) + return 0; /* suspension forced, can do nothing more */ + + /* OK, we processed one iMCU row. */ + cinfo->output_scanline += lines_per_iMCU_row; + return lines_per_iMCU_row; +} + + +/* Additional entry points for buffered-image mode. */ + +#ifdef D_MULTISCAN_FILES_SUPPORTED + +/* + * Initialize for an output pass in buffered-image mode. + */ + +GLOBAL(boolean) +jpeg_start_output (j_decompress_ptr cinfo, int scan_number) +{ + if (cinfo->global_state != DSTATE_BUFIMAGE && + cinfo->global_state != DSTATE_PRESCAN) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Limit scan number to valid range */ + if (scan_number <= 0) + scan_number = 1; + if (cinfo->inputctl->eoi_reached && + scan_number > cinfo->input_scan_number) + scan_number = cinfo->input_scan_number; + cinfo->output_scan_number = scan_number; + /* Perform any dummy output passes, and set up for the real pass */ + return output_pass_setup(cinfo); +} + + +/* + * Finish up after an output pass in buffered-image mode. + * + * Returns FALSE if suspended. The return value need be inspected only if + * a suspending data source is used. + */ + +GLOBAL(boolean) +jpeg_finish_output (j_decompress_ptr cinfo) +{ + if ((cinfo->global_state == DSTATE_SCANNING || + cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) { + /* Terminate this pass. */ + /* We do not require the whole pass to have been completed. */ + (*cinfo->master->finish_output_pass) (cinfo); + cinfo->global_state = DSTATE_BUFPOST; + } else if (cinfo->global_state != DSTATE_BUFPOST) { + /* BUFPOST = repeat call after a suspension, anything else is error */ + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + } + /* Read markers looking for SOS or EOI */ + while (cinfo->input_scan_number <= cinfo->output_scan_number && + ! cinfo->inputctl->eoi_reached) { + if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) + return FALSE; /* Suspend, come back later */ + } + cinfo->global_state = DSTATE_BUFIMAGE; + return TRUE; +} + +#endif /* D_MULTISCAN_FILES_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/jdatadst.c b/src/dep/src/irrlicht/jpeglib/jdatadst.c index 2ece4e9..a8f6fb0 100644 --- a/src/dep/src/irrlicht/jpeglib/jdatadst.c +++ b/src/dep/src/irrlicht/jpeglib/jdatadst.c @@ -1,151 +1,151 @@ -/* - * jdatadst.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains compression data destination routines for the case of - * emitting JPEG data to a file (or any stdio stream). While these routines - * are sufficient for most applications, some will want to use a different - * destination manager. - * IMPORTANT: we assume that fwrite() will correctly transcribe an array of - * JOCTETs into 8-bit-wide elements on external storage. If char is wider - * than 8 bits on your machine, you may need to do some tweaking. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jerror.h" - - -/* Expanded data destination object for stdio output */ - -typedef struct { - struct jpeg_destination_mgr pub; /* public fields */ - - FILE * outfile; /* target stream */ - JOCTET * buffer; /* start of buffer */ -} my_destination_mgr; - -typedef my_destination_mgr * my_dest_ptr; - -#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */ - - -/* - * Initialize destination --- called by jpeg_start_compress - * before any data is actually written. - */ - -METHODDEF(void) -init_destination (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - - /* Allocate the output buffer --- it will be released when done with image */ - dest->buffer = (JOCTET *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - OUTPUT_BUF_SIZE * SIZEOF(JOCTET)); - - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; -} - - -/* - * Empty the output buffer --- called whenever buffer fills up. - * - * In typical applications, this should write the entire output buffer - * (ignoring the current state of next_output_byte & free_in_buffer), - * reset the pointer & count to the start of the buffer, and return TRUE - * indicating that the buffer has been dumped. - * - * In applications that need to be able to suspend compression due to output - * overrun, a FALSE return indicates that the buffer cannot be emptied now. - * In this situation, the compressor will return to its caller (possibly with - * an indication that it has not accepted all the supplied scanlines). The - * application should resume compression after it has made more room in the - * output buffer. Note that there are substantial restrictions on the use of - * suspension --- see the documentation. - * - * When suspending, the compressor will back up to a convenient restart point - * (typically the start of the current MCU). next_output_byte & free_in_buffer - * indicate where the restart point will be if the current call returns FALSE. - * Data beyond this point will be regenerated after resumption, so do not - * write it out when emptying the buffer externally. - */ - -METHODDEF(boolean) -empty_output_buffer (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - - if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) != - (size_t) OUTPUT_BUF_SIZE) - ERREXIT(cinfo, JERR_FILE_WRITE); - - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; - - return TRUE; -} - - -/* - * Terminate destination --- called by jpeg_finish_compress - * after all data has been written. Usually needs to flush buffer. - * - * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding - * application must deal with any cleanup that should happen even - * for error exit. - */ - -METHODDEF(void) -term_destination (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; - - /* Write any data remaining in the buffer */ - if (datacount > 0) { - if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount) - ERREXIT(cinfo, JERR_FILE_WRITE); - } - fflush(dest->outfile); - /* Make sure we wrote the output file OK */ - if (ferror(dest->outfile)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * Prepare for output to a stdio stream. - * The caller must have already opened the stream, and is responsible - * for closing it after finishing compression. - */ - -GLOBAL(void) -jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile) -{ - my_dest_ptr dest; - - /* The destination object is made permanent so that multiple JPEG images - * can be written to the same file without re-executing jpeg_stdio_dest. - * This makes it dangerous to use this manager and a different destination - * manager serially with the same JPEG object, because their private object - * sizes may be different. Caveat programmer. - */ - if (cinfo->dest == NULL) { /* first time for this JPEG object? */ - cinfo->dest = (struct jpeg_destination_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_destination_mgr)); - } - - dest = (my_dest_ptr) cinfo->dest; - dest->pub.init_destination = init_destination; - dest->pub.empty_output_buffer = empty_output_buffer; - dest->pub.term_destination = term_destination; - dest->outfile = outfile; -} +/* + * jdatadst.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains compression data destination routines for the case of + * emitting JPEG data to a file (or any stdio stream). While these routines + * are sufficient for most applications, some will want to use a different + * destination manager. + * IMPORTANT: we assume that fwrite() will correctly transcribe an array of + * JOCTETs into 8-bit-wide elements on external storage. If char is wider + * than 8 bits on your machine, you may need to do some tweaking. + */ + +/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jerror.h" + + +/* Expanded data destination object for stdio output */ + +typedef struct { + struct jpeg_destination_mgr pub; /* public fields */ + + FILE * outfile; /* target stream */ + JOCTET * buffer; /* start of buffer */ +} my_destination_mgr; + +typedef my_destination_mgr * my_dest_ptr; + +#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */ + + +/* + * Initialize destination --- called by jpeg_start_compress + * before any data is actually written. + */ + +METHODDEF(void) +init_destination (j_compress_ptr cinfo) +{ + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + + /* Allocate the output buffer --- it will be released when done with image */ + dest->buffer = (JOCTET *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + OUTPUT_BUF_SIZE * SIZEOF(JOCTET)); + + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; +} + + +/* + * Empty the output buffer --- called whenever buffer fills up. + * + * In typical applications, this should write the entire output buffer + * (ignoring the current state of next_output_byte & free_in_buffer), + * reset the pointer & count to the start of the buffer, and return TRUE + * indicating that the buffer has been dumped. + * + * In applications that need to be able to suspend compression due to output + * overrun, a FALSE return indicates that the buffer cannot be emptied now. + * In this situation, the compressor will return to its caller (possibly with + * an indication that it has not accepted all the supplied scanlines). The + * application should resume compression after it has made more room in the + * output buffer. Note that there are substantial restrictions on the use of + * suspension --- see the documentation. + * + * When suspending, the compressor will back up to a convenient restart point + * (typically the start of the current MCU). next_output_byte & free_in_buffer + * indicate where the restart point will be if the current call returns FALSE. + * Data beyond this point will be regenerated after resumption, so do not + * write it out when emptying the buffer externally. + */ + +METHODDEF(boolean) +empty_output_buffer (j_compress_ptr cinfo) +{ + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + + if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) != + (size_t) OUTPUT_BUF_SIZE) + ERREXIT(cinfo, JERR_FILE_WRITE); + + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; + + return TRUE; +} + + +/* + * Terminate destination --- called by jpeg_finish_compress + * after all data has been written. Usually needs to flush buffer. + * + * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding + * application must deal with any cleanup that should happen even + * for error exit. + */ + +METHODDEF(void) +term_destination (j_compress_ptr cinfo) +{ + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; + + /* Write any data remaining in the buffer */ + if (datacount > 0) { + if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount) + ERREXIT(cinfo, JERR_FILE_WRITE); + } + fflush(dest->outfile); + /* Make sure we wrote the output file OK */ + if (ferror(dest->outfile)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * Prepare for output to a stdio stream. + * The caller must have already opened the stream, and is responsible + * for closing it after finishing compression. + */ + +GLOBAL(void) +jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile) +{ + my_dest_ptr dest; + + /* The destination object is made permanent so that multiple JPEG images + * can be written to the same file without re-executing jpeg_stdio_dest. + * This makes it dangerous to use this manager and a different destination + * manager serially with the same JPEG object, because their private object + * sizes may be different. Caveat programmer. + */ + if (cinfo->dest == NULL) { /* first time for this JPEG object? */ + cinfo->dest = (struct jpeg_destination_mgr *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + SIZEOF(my_destination_mgr)); + } + + dest = (my_dest_ptr) cinfo->dest; + dest->pub.init_destination = init_destination; + dest->pub.empty_output_buffer = empty_output_buffer; + dest->pub.term_destination = term_destination; + dest->outfile = outfile; +} diff --git a/src/dep/src/irrlicht/jpeglib/jdatasrc.c b/src/dep/src/irrlicht/jpeglib/jdatasrc.c index 29b6983..edc752b 100644 --- a/src/dep/src/irrlicht/jpeglib/jdatasrc.c +++ b/src/dep/src/irrlicht/jpeglib/jdatasrc.c @@ -1,212 +1,212 @@ -/* - * jdatasrc.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains decompression data source routines for the case of - * reading JPEG data from a file (or any stdio stream). While these routines - * are sufficient for most applications, some will want to use a different - * source manager. - * IMPORTANT: we assume that fread() will correctly transcribe an array of - * JOCTETs from 8-bit-wide elements on external storage. If char is wider - * than 8 bits on your machine, you may need to do some tweaking. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jerror.h" - - -/* Expanded data source object for stdio input */ - -typedef struct { - struct jpeg_source_mgr pub; /* public fields */ - - FILE * infile; /* source stream */ - JOCTET * buffer; /* start of buffer */ - boolean start_of_file; /* have we gotten any data yet? */ -} my_source_mgr; - -typedef my_source_mgr * my_src_ptr; - -#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */ - - -/* - * Initialize source --- called by jpeg_read_header - * before any data is actually read. - */ - -METHODDEF(void) -init_source (j_decompress_ptr cinfo) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - - /* We reset the empty-input-file flag for each image, - * but we don't clear the input buffer. - * This is correct behavior for reading a series of images from one source. - */ - src->start_of_file = TRUE; -} - - -/* - * Fill the input buffer --- called whenever buffer is emptied. - * - * In typical applications, this should read fresh data into the buffer - * (ignoring the current state of next_input_byte & bytes_in_buffer), - * reset the pointer & count to the start of the buffer, and return TRUE - * indicating that the buffer has been reloaded. It is not necessary to - * fill the buffer entirely, only to obtain at least one more byte. - * - * There is no such thing as an EOF return. If the end of the file has been - * reached, the routine has a choice of ERREXIT() or inserting fake data into - * the buffer. In most cases, generating a warning message and inserting a - * fake EOI marker is the best course of action --- this will allow the - * decompressor to output however much of the image is there. However, - * the resulting error message is misleading if the real problem is an empty - * input file, so we handle that case specially. - * - * In applications that need to be able to suspend compression due to input - * not being available yet, a FALSE return indicates that no more data can be - * obtained right now, but more may be forthcoming later. In this situation, - * the decompressor will return to its caller (with an indication of the - * number of scanlines it has read, if any). The application should resume - * decompression after it has loaded more data into the input buffer. Note - * that there are substantial restrictions on the use of suspension --- see - * the documentation. - * - * When suspending, the decompressor will back up to a convenient restart point - * (typically the start of the current MCU). next_input_byte & bytes_in_buffer - * indicate where the restart point will be if the current call returns FALSE. - * Data beyond this point must be rescanned after resumption, so move it to - * the front of the buffer rather than discarding it. - */ - -METHODDEF(boolean) -fill_input_buffer (j_decompress_ptr cinfo) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - size_t nbytes; - - nbytes = JFREAD(src->infile, src->buffer, INPUT_BUF_SIZE); - - if (nbytes <= 0) { - if (src->start_of_file) /* Treat empty input file as fatal error */ - ERREXIT(cinfo, JERR_INPUT_EMPTY); - WARNMS(cinfo, JWRN_JPEG_EOF); - /* Insert a fake EOI marker */ - src->buffer[0] = (JOCTET) 0xFF; - src->buffer[1] = (JOCTET) JPEG_EOI; - nbytes = 2; - } - - src->pub.next_input_byte = src->buffer; - src->pub.bytes_in_buffer = nbytes; - src->start_of_file = FALSE; - - return TRUE; -} - - -/* - * Skip data --- used to skip over a potentially large amount of - * uninteresting data (such as an APPn marker). - * - * Writers of suspendable-input applications must note that skip_input_data - * is not granted the right to give a suspension return. If the skip extends - * beyond the data currently in the buffer, the buffer can be marked empty so - * that the next read will cause a fill_input_buffer call that can suspend. - * Arranging for additional bytes to be discarded before reloading the input - * buffer is the application writer's problem. - */ - -METHODDEF(void) -skip_input_data (j_decompress_ptr cinfo, long num_bytes) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - - /* Just a dumb implementation for now. Could use fseek() except - * it doesn't work on pipes. Not clear that being smart is worth - * any trouble anyway --- large skips are infrequent. - */ - if (num_bytes > 0) { - while (num_bytes > (long) src->pub.bytes_in_buffer) { - num_bytes -= (long) src->pub.bytes_in_buffer; - (void) fill_input_buffer(cinfo); - /* note we assume that fill_input_buffer will never return FALSE, - * so suspension need not be handled. - */ - } - src->pub.next_input_byte += (size_t) num_bytes; - src->pub.bytes_in_buffer -= (size_t) num_bytes; - } -} - - -/* - * An additional method that can be provided by data source modules is the - * resync_to_restart method for error recovery in the presence of RST markers. - * For the moment, this source module just uses the default resync method - * provided by the JPEG library. That method assumes that no backtracking - * is possible. - */ - - -/* - * Terminate source --- called by jpeg_finish_decompress - * after all data has been read. Often a no-op. - * - * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding - * application must deal with any cleanup that should happen even - * for error exit. - */ - -METHODDEF(void) -term_source (j_decompress_ptr cinfo) -{ - /* no work necessary here */ -} - - -/* - * Prepare for input from a stdio stream. - * The caller must have already opened the stream, and is responsible - * for closing it after finishing decompression. - */ - -GLOBAL(void) -jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile) -{ - my_src_ptr src; - - /* The source object and input buffer are made permanent so that a series - * of JPEG images can be read from the same file by calling jpeg_stdio_src - * only before the first one. (If we discarded the buffer at the end of - * one image, we'd likely lose the start of the next one.) - * This makes it unsafe to use this manager and a different source - * manager serially with the same JPEG object. Caveat programmer. - */ - if (cinfo->src == NULL) { /* first time for this JPEG object? */ - cinfo->src = (struct jpeg_source_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_source_mgr)); - src = (my_src_ptr) cinfo->src; - src->buffer = (JOCTET *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - INPUT_BUF_SIZE * SIZEOF(JOCTET)); - } - - src = (my_src_ptr) cinfo->src; - src->pub.init_source = init_source; - src->pub.fill_input_buffer = fill_input_buffer; - src->pub.skip_input_data = skip_input_data; - src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ - src->pub.term_source = term_source; - src->infile = infile; - src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ - src->pub.next_input_byte = NULL; /* until buffer loaded */ -} +/* + * jdatasrc.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains decompression data source routines for the case of + * reading JPEG data from a file (or any stdio stream). While these routines + * are sufficient for most applications, some will want to use a different + * source manager. + * IMPORTANT: we assume that fread() will correctly transcribe an array of + * JOCTETs from 8-bit-wide elements on external storage. If char is wider + * than 8 bits on your machine, you may need to do some tweaking. + */ + +/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jerror.h" + + +/* Expanded data source object for stdio input */ + +typedef struct { + struct jpeg_source_mgr pub; /* public fields */ + + FILE * infile; /* source stream */ + JOCTET * buffer; /* start of buffer */ + boolean start_of_file; /* have we gotten any data yet? */ +} my_source_mgr; + +typedef my_source_mgr * my_src_ptr; + +#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */ + + +/* + * Initialize source --- called by jpeg_read_header + * before any data is actually read. + */ + +METHODDEF(void) +init_source (j_decompress_ptr cinfo) +{ + my_src_ptr src = (my_src_ptr) cinfo->src; + + /* We reset the empty-input-file flag for each image, + * but we don't clear the input buffer. + * This is correct behavior for reading a series of images from one source. + */ + src->start_of_file = TRUE; +} + + +/* + * Fill the input buffer --- called whenever buffer is emptied. + * + * In typical applications, this should read fresh data into the buffer + * (ignoring the current state of next_input_byte & bytes_in_buffer), + * reset the pointer & count to the start of the buffer, and return TRUE + * indicating that the buffer has been reloaded. It is not necessary to + * fill the buffer entirely, only to obtain at least one more byte. + * + * There is no such thing as an EOF return. If the end of the file has been + * reached, the routine has a choice of ERREXIT() or inserting fake data into + * the buffer. In most cases, generating a warning message and inserting a + * fake EOI marker is the best course of action --- this will allow the + * decompressor to output however much of the image is there. However, + * the resulting error message is misleading if the real problem is an empty + * input file, so we handle that case specially. + * + * In applications that need to be able to suspend compression due to input + * not being available yet, a FALSE return indicates that no more data can be + * obtained right now, but more may be forthcoming later. In this situation, + * the decompressor will return to its caller (with an indication of the + * number of scanlines it has read, if any). The application should resume + * decompression after it has loaded more data into the input buffer. Note + * that there are substantial restrictions on the use of suspension --- see + * the documentation. + * + * When suspending, the decompressor will back up to a convenient restart point + * (typically the start of the current MCU). next_input_byte & bytes_in_buffer + * indicate where the restart point will be if the current call returns FALSE. + * Data beyond this point must be rescanned after resumption, so move it to + * the front of the buffer rather than discarding it. + */ + +METHODDEF(boolean) +fill_input_buffer (j_decompress_ptr cinfo) +{ + my_src_ptr src = (my_src_ptr) cinfo->src; + size_t nbytes; + + nbytes = JFREAD(src->infile, src->buffer, INPUT_BUF_SIZE); + + if (nbytes <= 0) { + if (src->start_of_file) /* Treat empty input file as fatal error */ + ERREXIT(cinfo, JERR_INPUT_EMPTY); + WARNMS(cinfo, JWRN_JPEG_EOF); + /* Insert a fake EOI marker */ + src->buffer[0] = (JOCTET) 0xFF; + src->buffer[1] = (JOCTET) JPEG_EOI; + nbytes = 2; + } + + src->pub.next_input_byte = src->buffer; + src->pub.bytes_in_buffer = nbytes; + src->start_of_file = FALSE; + + return TRUE; +} + + +/* + * Skip data --- used to skip over a potentially large amount of + * uninteresting data (such as an APPn marker). + * + * Writers of suspendable-input applications must note that skip_input_data + * is not granted the right to give a suspension return. If the skip extends + * beyond the data currently in the buffer, the buffer can be marked empty so + * that the next read will cause a fill_input_buffer call that can suspend. + * Arranging for additional bytes to be discarded before reloading the input + * buffer is the application writer's problem. + */ + +METHODDEF(void) +skip_input_data (j_decompress_ptr cinfo, long num_bytes) +{ + my_src_ptr src = (my_src_ptr) cinfo->src; + + /* Just a dumb implementation for now. Could use fseek() except + * it doesn't work on pipes. Not clear that being smart is worth + * any trouble anyway --- large skips are infrequent. + */ + if (num_bytes > 0) { + while (num_bytes > (long) src->pub.bytes_in_buffer) { + num_bytes -= (long) src->pub.bytes_in_buffer; + (void) fill_input_buffer(cinfo); + /* note we assume that fill_input_buffer will never return FALSE, + * so suspension need not be handled. + */ + } + src->pub.next_input_byte += (size_t) num_bytes; + src->pub.bytes_in_buffer -= (size_t) num_bytes; + } +} + + +/* + * An additional method that can be provided by data source modules is the + * resync_to_restart method for error recovery in the presence of RST markers. + * For the moment, this source module just uses the default resync method + * provided by the JPEG library. That method assumes that no backtracking + * is possible. + */ + + +/* + * Terminate source --- called by jpeg_finish_decompress + * after all data has been read. Often a no-op. + * + * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding + * application must deal with any cleanup that should happen even + * for error exit. + */ + +METHODDEF(void) +term_source (j_decompress_ptr cinfo) +{ + /* no work necessary here */ +} + + +/* + * Prepare for input from a stdio stream. + * The caller must have already opened the stream, and is responsible + * for closing it after finishing decompression. + */ + +GLOBAL(void) +jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile) +{ + my_src_ptr src; + + /* The source object and input buffer are made permanent so that a series + * of JPEG images can be read from the same file by calling jpeg_stdio_src + * only before the first one. (If we discarded the buffer at the end of + * one image, we'd likely lose the start of the next one.) + * This makes it unsafe to use this manager and a different source + * manager serially with the same JPEG object. Caveat programmer. + */ + if (cinfo->src == NULL) { /* first time for this JPEG object? */ + cinfo->src = (struct jpeg_source_mgr *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + SIZEOF(my_source_mgr)); + src = (my_src_ptr) cinfo->src; + src->buffer = (JOCTET *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + INPUT_BUF_SIZE * SIZEOF(JOCTET)); + } + + src = (my_src_ptr) cinfo->src; + src->pub.init_source = init_source; + src->pub.fill_input_buffer = fill_input_buffer; + src->pub.skip_input_data = skip_input_data; + src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ + src->pub.term_source = term_source; + src->infile = infile; + src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ + src->pub.next_input_byte = NULL; /* until buffer loaded */ +} diff --git a/src/dep/src/irrlicht/jpeglib/jdcoefct.c b/src/dep/src/irrlicht/jpeglib/jdcoefct.c index 992bd10..4938d20 100644 --- a/src/dep/src/irrlicht/jpeglib/jdcoefct.c +++ b/src/dep/src/irrlicht/jpeglib/jdcoefct.c @@ -1,736 +1,736 @@ -/* - * jdcoefct.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the coefficient buffer controller for decompression. - * This controller is the top level of the JPEG decompressor proper. - * The coefficient buffer lies between entropy decoding and inverse-DCT steps. - * - * In buffered-image mode, this controller is the interface between - * input-oriented processing and output-oriented processing. - * Also, the input side (only) is used when reading a file for transcoding. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -/* Block smoothing is only applicable for progressive JPEG, so: */ -#ifndef D_PROGRESSIVE_SUPPORTED -#undef BLOCK_SMOOTHING_SUPPORTED -#endif - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_coef_controller pub; /* public fields */ - - /* These variables keep track of the current location of the input side. */ - /* cinfo->input_iMCU_row is also used for this. */ - JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* The output side's location is represented by cinfo->output_iMCU_row. */ - - /* In single-pass modes, it's sufficient to buffer just one MCU. - * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks, - * and let the entropy decoder write into that workspace each time. - * (On 80x86, the workspace is FAR even though it's not really very big; - * this is to keep the module interfaces unchanged when a large coefficient - * buffer is necessary.) - * In multi-pass modes, this array points to the current MCU's blocks - * within the virtual arrays; it is used only by the input side. - */ - JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU]; - -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* In multi-pass modes, we need a virtual block array for each component. */ - jvirt_barray_ptr whole_image[MAX_COMPONENTS]; -#endif - -#ifdef BLOCK_SMOOTHING_SUPPORTED - /* When doing block smoothing, we latch coefficient Al values here */ - int * coef_bits_latch; -#define SAVED_COEFS 6 /* we save coef_bits[0..5] */ -#endif -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - -/* Forward declarations */ -METHODDEF(int) decompress_onepass - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#ifdef D_MULTISCAN_FILES_SUPPORTED -METHODDEF(int) decompress_data - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#endif -#ifdef BLOCK_SMOOTHING_SUPPORTED -LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo)); -METHODDEF(int) decompress_smooth_data - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#endif - - -LOCAL(void) -start_iMCU_row (j_decompress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row (input side) */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->MCU_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for an input processing pass. - */ - -METHODDEF(void) -start_input_pass (j_decompress_ptr cinfo) -{ - cinfo->input_iMCU_row = 0; - start_iMCU_row(cinfo); -} - - -/* - * Initialize for an output processing pass. - */ - -METHODDEF(void) -start_output_pass (j_decompress_ptr cinfo) -{ -#ifdef BLOCK_SMOOTHING_SUPPORTED - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* If multipass, check to see whether to use block smoothing on this pass */ - if (coef->pub.coef_arrays != NULL) { - if (cinfo->do_block_smoothing && smoothing_ok(cinfo)) - coef->pub.decompress_data = decompress_smooth_data; - else - coef->pub.decompress_data = decompress_data; - } -#endif - cinfo->output_iMCU_row = 0; -} - - -/* - * Decompress and return some data in the single-pass case. - * Always attempts to emit one fully interleaved MCU row ("iMCU" row). - * Input and output must run in lockstep since we have only a one-MCU buffer. - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - * - * NB: output_buf contains a plane for each component in image, - * which we index according to the component's SOF position. - */ - -METHODDEF(int) -decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, ci, xindex, yindex, yoffset, useful_width; - JSAMPARRAY output_ptr; - JDIMENSION start_col, output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - - /* Loop to process as much as one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; - MCU_col_num++) { - /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */ - jzero_far((void FAR *) coef->MCU_buffer[0], - (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK))); - if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->MCU_ctr = MCU_col_num; - return JPEG_SUSPENDED; - } - /* Determine where data should go in output_buf and do the IDCT thing. - * We skip dummy blocks at the right and bottom edges (but blkn gets - * incremented past them!). Note the inner loop relies on having - * allocated the MCU_buffer[] blocks sequentially. - */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) { - blkn += compptr->MCU_blocks; - continue; - } - inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index]; - useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - output_ptr = output_buf[compptr->component_index] + - yoffset * compptr->DCT_scaled_size; - start_col = MCU_col_num * compptr->MCU_sample_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (cinfo->input_iMCU_row < last_iMCU_row || - yoffset+yindex < compptr->last_row_height) { - output_col = start_col; - for (xindex = 0; xindex < useful_width; xindex++) { - (*inverse_DCT) (cinfo, compptr, - (JCOEFPTR) coef->MCU_buffer[blkn+xindex], - output_ptr, output_col); - output_col += compptr->DCT_scaled_size; - } - } - blkn += compptr->MCU_width; - output_ptr += compptr->DCT_scaled_size; - } - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->MCU_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - cinfo->output_iMCU_row++; - if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { - start_iMCU_row(cinfo); - return JPEG_ROW_COMPLETED; - } - /* Completed the scan */ - (*cinfo->inputctl->finish_input_pass) (cinfo); - return JPEG_SCAN_COMPLETED; -} - - -/* - * Dummy consume-input routine for single-pass operation. - */ - -METHODDEF(int) -dummy_consume_data (j_decompress_ptr cinfo) -{ - return JPEG_SUSPENDED; /* Always indicate nothing was done */ -} - - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Consume input data and store it in the full-image coefficient buffer. - * We read as much as one fully interleaved MCU row ("iMCU" row) per call, - * ie, v_samp_factor block rows for each component in the scan. - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - */ - -METHODDEF(int) -consume_data (j_decompress_ptr cinfo) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - int blkn, ci, xindex, yindex, yoffset; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - cinfo->input_iMCU_row * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, TRUE); - /* Note: entropy decoder expects buffer to be zeroed, - * but this is handled automatically by the memory manager - * because we requested a pre-zeroed array. - */ - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < compptr->MCU_width; xindex++) { - coef->MCU_buffer[blkn++] = buffer_ptr++; - } - } - } - /* Try to fetch the MCU. */ - if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->MCU_ctr = MCU_col_num; - return JPEG_SUSPENDED; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->MCU_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { - start_iMCU_row(cinfo); - return JPEG_ROW_COMPLETED; - } - /* Completed the scan */ - (*cinfo->inputctl->finish_input_pass) (cinfo); - return JPEG_SCAN_COMPLETED; -} - - -/* - * Decompress and return some data in the multi-pass case. - * Always attempts to emit one fully interleaved MCU row ("iMCU" row). - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - * - * NB: output_buf contains a plane for each component in image. - */ - -METHODDEF(int) -decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION block_num; - int ci, block_row, block_rows; - JBLOCKARRAY buffer; - JBLOCKROW buffer_ptr; - JSAMPARRAY output_ptr; - JDIMENSION output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - - /* Force some input to be done if we are getting ahead of the input. */ - while (cinfo->input_scan_number < cinfo->output_scan_number || - (cinfo->input_scan_number == cinfo->output_scan_number && - cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { - if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) - return JPEG_SUSPENDED; - } - - /* OK, output from the virtual arrays. */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) - continue; - /* Align the virtual buffer for this component. */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - cinfo->output_iMCU_row * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - /* Count non-dummy DCT block rows in this iMCU row. */ - if (cinfo->output_iMCU_row < last_iMCU_row) - block_rows = compptr->v_samp_factor; - else { - /* NB: can't use last_row_height here; it is input-side-dependent! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - } - inverse_DCT = cinfo->idct->inverse_DCT[ci]; - output_ptr = output_buf[ci]; - /* Loop over all DCT blocks to be processed. */ - for (block_row = 0; block_row < block_rows; block_row++) { - buffer_ptr = buffer[block_row]; - output_col = 0; - for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) { - (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr, - output_ptr, output_col); - buffer_ptr++; - output_col += compptr->DCT_scaled_size; - } - output_ptr += compptr->DCT_scaled_size; - } - } - - if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) - return JPEG_ROW_COMPLETED; - return JPEG_SCAN_COMPLETED; -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - - -#ifdef BLOCK_SMOOTHING_SUPPORTED - -/* - * This code applies interblock smoothing as described by section K.8 - * of the JPEG standard: the first 5 AC coefficients are estimated from - * the DC values of a DCT block and its 8 neighboring blocks. - * We apply smoothing only for progressive JPEG decoding, and only if - * the coefficients it can estimate are not yet known to full precision. - */ - -/* Natural-order array positions of the first 5 zigzag-order coefficients */ -#define Q01_POS 1 -#define Q10_POS 8 -#define Q20_POS 16 -#define Q11_POS 9 -#define Q02_POS 2 - -/* - * Determine whether block smoothing is applicable and safe. - * We also latch the current states of the coef_bits[] entries for the - * AC coefficients; otherwise, if the input side of the decompressor - * advances into a new scan, we might think the coefficients are known - * more accurately than they really are. - */ - -LOCAL(boolean) -smoothing_ok (j_decompress_ptr cinfo) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - boolean smoothing_useful = FALSE; - int ci, coefi; - jpeg_component_info *compptr; - JQUANT_TBL * qtable; - int * coef_bits; - int * coef_bits_latch; - - if (! cinfo->progressive_mode || cinfo->coef_bits == NULL) - return FALSE; - - /* Allocate latch area if not already done */ - if (coef->coef_bits_latch == NULL) - coef->coef_bits_latch = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * - (SAVED_COEFS * SIZEOF(int))); - coef_bits_latch = coef->coef_bits_latch; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* All components' quantization values must already be latched. */ - if ((qtable = compptr->quant_table) == NULL) - return FALSE; - /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */ - if (qtable->quantval[0] == 0 || - qtable->quantval[Q01_POS] == 0 || - qtable->quantval[Q10_POS] == 0 || - qtable->quantval[Q20_POS] == 0 || - qtable->quantval[Q11_POS] == 0 || - qtable->quantval[Q02_POS] == 0) - return FALSE; - /* DC values must be at least partly known for all components. */ - coef_bits = cinfo->coef_bits[ci]; - if (coef_bits[0] < 0) - return FALSE; - /* Block smoothing is helpful if some AC coefficients remain inaccurate. */ - for (coefi = 1; coefi <= 5; coefi++) { - coef_bits_latch[coefi] = coef_bits[coefi]; - if (coef_bits[coefi] != 0) - smoothing_useful = TRUE; - } - coef_bits_latch += SAVED_COEFS; - } - - return smoothing_useful; -} - - -/* - * Variant of decompress_data for use when doing block smoothing. - */ - -METHODDEF(int) -decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION block_num, last_block_column; - int ci, block_row, block_rows, access_rows; - JBLOCKARRAY buffer; - JBLOCKROW buffer_ptr, prev_block_row, next_block_row; - JSAMPARRAY output_ptr; - JDIMENSION output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - boolean first_row, last_row; - JBLOCK workspace; - int *coef_bits; - JQUANT_TBL *quanttbl; - INT32 Q00,Q01,Q02,Q10,Q11,Q20, num; - int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9; - int Al, pred; - - /* Force some input to be done if we are getting ahead of the input. */ - while (cinfo->input_scan_number <= cinfo->output_scan_number && - ! cinfo->inputctl->eoi_reached) { - if (cinfo->input_scan_number == cinfo->output_scan_number) { - /* If input is working on current scan, we ordinarily want it to - * have completed the current row. But if input scan is DC, - * we want it to keep one row ahead so that next block row's DC - * values are up to date. - */ - JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0; - if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta) - break; - } - if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) - return JPEG_SUSPENDED; - } - - /* OK, output from the virtual arrays. */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) - continue; - /* Count non-dummy DCT block rows in this iMCU row. */ - if (cinfo->output_iMCU_row < last_iMCU_row) { - block_rows = compptr->v_samp_factor; - access_rows = block_rows * 2; /* this and next iMCU row */ - last_row = FALSE; - } else { - /* NB: can't use last_row_height here; it is input-side-dependent! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - access_rows = block_rows; /* this iMCU row only */ - last_row = TRUE; - } - /* Align the virtual buffer for this component. */ - if (cinfo->output_iMCU_row > 0) { - access_rows += compptr->v_samp_factor; /* prior iMCU row too */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor, - (JDIMENSION) access_rows, FALSE); - buffer += compptr->v_samp_factor; /* point to current iMCU row */ - first_row = FALSE; - } else { - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE); - first_row = TRUE; - } - /* Fetch component-dependent info */ - coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS); - quanttbl = compptr->quant_table; - Q00 = quanttbl->quantval[0]; - Q01 = quanttbl->quantval[Q01_POS]; - Q10 = quanttbl->quantval[Q10_POS]; - Q20 = quanttbl->quantval[Q20_POS]; - Q11 = quanttbl->quantval[Q11_POS]; - Q02 = quanttbl->quantval[Q02_POS]; - inverse_DCT = cinfo->idct->inverse_DCT[ci]; - output_ptr = output_buf[ci]; - /* Loop over all DCT blocks to be processed. */ - for (block_row = 0; block_row < block_rows; block_row++) { - buffer_ptr = buffer[block_row]; - if (first_row && block_row == 0) - prev_block_row = buffer_ptr; - else - prev_block_row = buffer[block_row-1]; - if (last_row && block_row == block_rows-1) - next_block_row = buffer_ptr; - else - next_block_row = buffer[block_row+1]; - /* We fetch the surrounding DC values using a sliding-register approach. - * Initialize all nine here so as to do the right thing on narrow pics. - */ - DC1 = DC2 = DC3 = (int) prev_block_row[0][0]; - DC4 = DC5 = DC6 = (int) buffer_ptr[0][0]; - DC7 = DC8 = DC9 = (int) next_block_row[0][0]; - output_col = 0; - last_block_column = compptr->width_in_blocks - 1; - for (block_num = 0; block_num <= last_block_column; block_num++) { - /* Fetch current DCT block into workspace so we can modify it. */ - jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1); - /* Update DC values */ - if (block_num < last_block_column) { - DC3 = (int) prev_block_row[1][0]; - DC6 = (int) buffer_ptr[1][0]; - DC9 = (int) next_block_row[1][0]; - } - /* Compute coefficient estimates per K.8. - * An estimate is applied only if coefficient is still zero, - * and is not known to be fully accurate. - */ - /* AC01 */ - if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) { - num = 36 * Q00 * (DC4 - DC6); - if (num >= 0) { - pred = (int) (((Q01<<7) + num) / (Q01<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q10<<7) + num) / (Q10<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q20<<7) + num) / (Q20<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q11<<7) + num) / (Q11<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q02<<7) + num) / (Q02<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<DCT_scaled_size; - } - output_ptr += compptr->DCT_scaled_size; - } - } - - if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) - return JPEG_ROW_COMPLETED; - return JPEG_SCAN_COMPLETED; -} - -#endif /* BLOCK_SMOOTHING_SUPPORTED */ - - -/* - * Initialize coefficient buffer controller. - */ - -GLOBAL(void) -jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_coef_ptr coef; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_d_coef_controller *) coef; - coef->pub.start_input_pass = start_input_pass; - coef->pub.start_output_pass = start_output_pass; -#ifdef BLOCK_SMOOTHING_SUPPORTED - coef->coef_bits_latch = NULL; -#endif - - /* Create the coefficient buffer. */ - if (need_full_buffer) { -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* Allocate a full-image virtual array for each component, */ - /* padded to a multiple of samp_factor DCT blocks in each direction. */ - /* Note we ask for a pre-zeroed array. */ - int ci, access_rows; - jpeg_component_info *compptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - access_rows = compptr->v_samp_factor; -#ifdef BLOCK_SMOOTHING_SUPPORTED - /* If block smoothing could be used, need a bigger window */ - if (cinfo->progressive_mode) - access_rows *= 3; -#endif - coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE, - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) access_rows); - } - coef->pub.consume_data = consume_data; - coef->pub.decompress_data = decompress_data; - coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */ -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - /* We only need a single-MCU buffer. */ - JBLOCKROW buffer; - int i; - - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { - coef->MCU_buffer[i] = buffer + i; - } - coef->pub.consume_data = dummy_consume_data; - coef->pub.decompress_data = decompress_onepass; - coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ - } -} +/* + * jdcoefct.c + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the coefficient buffer controller for decompression. + * This controller is the top level of the JPEG decompressor proper. + * The coefficient buffer lies between entropy decoding and inverse-DCT steps. + * + * In buffered-image mode, this controller is the interface between + * input-oriented processing and output-oriented processing. + * Also, the input side (only) is used when reading a file for transcoding. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +/* Block smoothing is only applicable for progressive JPEG, so: */ +#ifndef D_PROGRESSIVE_SUPPORTED +#undef BLOCK_SMOOTHING_SUPPORTED +#endif + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_d_coef_controller pub; /* public fields */ + + /* These variables keep track of the current location of the input side. */ + /* cinfo->input_iMCU_row is also used for this. */ + JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ + int MCU_vert_offset; /* counts MCU rows within iMCU row */ + int MCU_rows_per_iMCU_row; /* number of such rows needed */ + + /* The output side's location is represented by cinfo->output_iMCU_row. */ + + /* In single-pass modes, it's sufficient to buffer just one MCU. + * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks, + * and let the entropy decoder write into that workspace each time. + * (On 80x86, the workspace is FAR even though it's not really very big; + * this is to keep the module interfaces unchanged when a large coefficient + * buffer is necessary.) + * In multi-pass modes, this array points to the current MCU's blocks + * within the virtual arrays; it is used only by the input side. + */ + JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU]; + +#ifdef D_MULTISCAN_FILES_SUPPORTED + /* In multi-pass modes, we need a virtual block array for each component. */ + jvirt_barray_ptr whole_image[MAX_COMPONENTS]; +#endif + +#ifdef BLOCK_SMOOTHING_SUPPORTED + /* When doing block smoothing, we latch coefficient Al values here */ + int * coef_bits_latch; +#define SAVED_COEFS 6 /* we save coef_bits[0..5] */ +#endif +} my_coef_controller; + +typedef my_coef_controller * my_coef_ptr; + +/* Forward declarations */ +METHODDEF(int) decompress_onepass + JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); +#ifdef D_MULTISCAN_FILES_SUPPORTED +METHODDEF(int) decompress_data + JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); +#endif +#ifdef BLOCK_SMOOTHING_SUPPORTED +LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo)); +METHODDEF(int) decompress_smooth_data + JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); +#endif + + +LOCAL(void) +start_iMCU_row (j_decompress_ptr cinfo) +/* Reset within-iMCU-row counters for a new row (input side) */ +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* In an interleaved scan, an MCU row is the same as an iMCU row. + * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. + * But at the bottom of the image, process only what's left. + */ + if (cinfo->comps_in_scan > 1) { + coef->MCU_rows_per_iMCU_row = 1; + } else { + if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; + else + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; + } + + coef->MCU_ctr = 0; + coef->MCU_vert_offset = 0; +} + + +/* + * Initialize for an input processing pass. + */ + +METHODDEF(void) +start_input_pass (j_decompress_ptr cinfo) +{ + cinfo->input_iMCU_row = 0; + start_iMCU_row(cinfo); +} + + +/* + * Initialize for an output processing pass. + */ + +METHODDEF(void) +start_output_pass (j_decompress_ptr cinfo) +{ +#ifdef BLOCK_SMOOTHING_SUPPORTED + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* If multipass, check to see whether to use block smoothing on this pass */ + if (coef->pub.coef_arrays != NULL) { + if (cinfo->do_block_smoothing && smoothing_ok(cinfo)) + coef->pub.decompress_data = decompress_smooth_data; + else + coef->pub.decompress_data = decompress_data; + } +#endif + cinfo->output_iMCU_row = 0; +} + + +/* + * Decompress and return some data in the single-pass case. + * Always attempts to emit one fully interleaved MCU row ("iMCU" row). + * Input and output must run in lockstep since we have only a one-MCU buffer. + * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. + * + * NB: output_buf contains a plane for each component in image, + * which we index according to the component's SOF position. + */ + +METHODDEF(int) +decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + int blkn, ci, xindex, yindex, yoffset, useful_width; + JSAMPARRAY output_ptr; + JDIMENSION start_col, output_col; + jpeg_component_info *compptr; + inverse_DCT_method_ptr inverse_DCT; + + /* Loop to process as much as one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; + MCU_col_num++) { + /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */ + jzero_far((void FAR *) coef->MCU_buffer[0], + (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK))); + if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->MCU_ctr = MCU_col_num; + return JPEG_SUSPENDED; + } + /* Determine where data should go in output_buf and do the IDCT thing. + * We skip dummy blocks at the right and bottom edges (but blkn gets + * incremented past them!). Note the inner loop relies on having + * allocated the MCU_buffer[] blocks sequentially. + */ + blkn = 0; /* index of current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Don't bother to IDCT an uninteresting component. */ + if (! compptr->component_needed) { + blkn += compptr->MCU_blocks; + continue; + } + inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index]; + useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width + : compptr->last_col_width; + output_ptr = output_buf[compptr->component_index] + + yoffset * compptr->DCT_scaled_size; + start_col = MCU_col_num * compptr->MCU_sample_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + if (cinfo->input_iMCU_row < last_iMCU_row || + yoffset+yindex < compptr->last_row_height) { + output_col = start_col; + for (xindex = 0; xindex < useful_width; xindex++) { + (*inverse_DCT) (cinfo, compptr, + (JCOEFPTR) coef->MCU_buffer[blkn+xindex], + output_ptr, output_col); + output_col += compptr->DCT_scaled_size; + } + } + blkn += compptr->MCU_width; + output_ptr += compptr->DCT_scaled_size; + } + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->MCU_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + cinfo->output_iMCU_row++; + if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { + start_iMCU_row(cinfo); + return JPEG_ROW_COMPLETED; + } + /* Completed the scan */ + (*cinfo->inputctl->finish_input_pass) (cinfo); + return JPEG_SCAN_COMPLETED; +} + + +/* + * Dummy consume-input routine for single-pass operation. + */ + +METHODDEF(int) +dummy_consume_data (j_decompress_ptr cinfo) +{ + return JPEG_SUSPENDED; /* Always indicate nothing was done */ +} + + +#ifdef D_MULTISCAN_FILES_SUPPORTED + +/* + * Consume input data and store it in the full-image coefficient buffer. + * We read as much as one fully interleaved MCU row ("iMCU" row) per call, + * ie, v_samp_factor block rows for each component in the scan. + * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. + */ + +METHODDEF(int) +consume_data (j_decompress_ptr cinfo) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + int blkn, ci, xindex, yindex, yoffset; + JDIMENSION start_col; + JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; + JBLOCKROW buffer_ptr; + jpeg_component_info *compptr; + + /* Align the virtual buffers for the components used in this scan. */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + buffer[ci] = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], + cinfo->input_iMCU_row * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, TRUE); + /* Note: entropy decoder expects buffer to be zeroed, + * but this is handled automatically by the memory manager + * because we requested a pre-zeroed array. + */ + } + + /* Loop to process one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; + MCU_col_num++) { + /* Construct list of pointers to DCT blocks belonging to this MCU */ + blkn = 0; /* index of current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + start_col = MCU_col_num * compptr->MCU_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + buffer_ptr = buffer[ci][yindex+yoffset] + start_col; + for (xindex = 0; xindex < compptr->MCU_width; xindex++) { + coef->MCU_buffer[blkn++] = buffer_ptr++; + } + } + } + /* Try to fetch the MCU. */ + if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->MCU_ctr = MCU_col_num; + return JPEG_SUSPENDED; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->MCU_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { + start_iMCU_row(cinfo); + return JPEG_ROW_COMPLETED; + } + /* Completed the scan */ + (*cinfo->inputctl->finish_input_pass) (cinfo); + return JPEG_SCAN_COMPLETED; +} + + +/* + * Decompress and return some data in the multi-pass case. + * Always attempts to emit one fully interleaved MCU row ("iMCU" row). + * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. + * + * NB: output_buf contains a plane for each component in image. + */ + +METHODDEF(int) +decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + JDIMENSION block_num; + int ci, block_row, block_rows; + JBLOCKARRAY buffer; + JBLOCKROW buffer_ptr; + JSAMPARRAY output_ptr; + JDIMENSION output_col; + jpeg_component_info *compptr; + inverse_DCT_method_ptr inverse_DCT; + + /* Force some input to be done if we are getting ahead of the input. */ + while (cinfo->input_scan_number < cinfo->output_scan_number || + (cinfo->input_scan_number == cinfo->output_scan_number && + cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { + if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) + return JPEG_SUSPENDED; + } + + /* OK, output from the virtual arrays. */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Don't bother to IDCT an uninteresting component. */ + if (! compptr->component_needed) + continue; + /* Align the virtual buffer for this component. */ + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + cinfo->output_iMCU_row * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + /* Count non-dummy DCT block rows in this iMCU row. */ + if (cinfo->output_iMCU_row < last_iMCU_row) + block_rows = compptr->v_samp_factor; + else { + /* NB: can't use last_row_height here; it is input-side-dependent! */ + block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (block_rows == 0) block_rows = compptr->v_samp_factor; + } + inverse_DCT = cinfo->idct->inverse_DCT[ci]; + output_ptr = output_buf[ci]; + /* Loop over all DCT blocks to be processed. */ + for (block_row = 0; block_row < block_rows; block_row++) { + buffer_ptr = buffer[block_row]; + output_col = 0; + for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) { + (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr, + output_ptr, output_col); + buffer_ptr++; + output_col += compptr->DCT_scaled_size; + } + output_ptr += compptr->DCT_scaled_size; + } + } + + if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) + return JPEG_ROW_COMPLETED; + return JPEG_SCAN_COMPLETED; +} + +#endif /* D_MULTISCAN_FILES_SUPPORTED */ + + +#ifdef BLOCK_SMOOTHING_SUPPORTED + +/* + * This code applies interblock smoothing as described by section K.8 + * of the JPEG standard: the first 5 AC coefficients are estimated from + * the DC values of a DCT block and its 8 neighboring blocks. + * We apply smoothing only for progressive JPEG decoding, and only if + * the coefficients it can estimate are not yet known to full precision. + */ + +/* Natural-order array positions of the first 5 zigzag-order coefficients */ +#define Q01_POS 1 +#define Q10_POS 8 +#define Q20_POS 16 +#define Q11_POS 9 +#define Q02_POS 2 + +/* + * Determine whether block smoothing is applicable and safe. + * We also latch the current states of the coef_bits[] entries for the + * AC coefficients; otherwise, if the input side of the decompressor + * advances into a new scan, we might think the coefficients are known + * more accurately than they really are. + */ + +LOCAL(boolean) +smoothing_ok (j_decompress_ptr cinfo) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + boolean smoothing_useful = FALSE; + int ci, coefi; + jpeg_component_info *compptr; + JQUANT_TBL * qtable; + int * coef_bits; + int * coef_bits_latch; + + if (! cinfo->progressive_mode || cinfo->coef_bits == NULL) + return FALSE; + + /* Allocate latch area if not already done */ + if (coef->coef_bits_latch == NULL) + coef->coef_bits_latch = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components * + (SAVED_COEFS * SIZEOF(int))); + coef_bits_latch = coef->coef_bits_latch; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* All components' quantization values must already be latched. */ + if ((qtable = compptr->quant_table) == NULL) + return FALSE; + /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */ + if (qtable->quantval[0] == 0 || + qtable->quantval[Q01_POS] == 0 || + qtable->quantval[Q10_POS] == 0 || + qtable->quantval[Q20_POS] == 0 || + qtable->quantval[Q11_POS] == 0 || + qtable->quantval[Q02_POS] == 0) + return FALSE; + /* DC values must be at least partly known for all components. */ + coef_bits = cinfo->coef_bits[ci]; + if (coef_bits[0] < 0) + return FALSE; + /* Block smoothing is helpful if some AC coefficients remain inaccurate. */ + for (coefi = 1; coefi <= 5; coefi++) { + coef_bits_latch[coefi] = coef_bits[coefi]; + if (coef_bits[coefi] != 0) + smoothing_useful = TRUE; + } + coef_bits_latch += SAVED_COEFS; + } + + return smoothing_useful; +} + + +/* + * Variant of decompress_data for use when doing block smoothing. + */ + +METHODDEF(int) +decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + JDIMENSION block_num, last_block_column; + int ci, block_row, block_rows, access_rows; + JBLOCKARRAY buffer; + JBLOCKROW buffer_ptr, prev_block_row, next_block_row; + JSAMPARRAY output_ptr; + JDIMENSION output_col; + jpeg_component_info *compptr; + inverse_DCT_method_ptr inverse_DCT; + boolean first_row, last_row; + JBLOCK workspace; + int *coef_bits; + JQUANT_TBL *quanttbl; + INT32 Q00,Q01,Q02,Q10,Q11,Q20, num; + int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9; + int Al, pred; + + /* Force some input to be done if we are getting ahead of the input. */ + while (cinfo->input_scan_number <= cinfo->output_scan_number && + ! cinfo->inputctl->eoi_reached) { + if (cinfo->input_scan_number == cinfo->output_scan_number) { + /* If input is working on current scan, we ordinarily want it to + * have completed the current row. But if input scan is DC, + * we want it to keep one row ahead so that next block row's DC + * values are up to date. + */ + JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0; + if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta) + break; + } + if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) + return JPEG_SUSPENDED; + } + + /* OK, output from the virtual arrays. */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Don't bother to IDCT an uninteresting component. */ + if (! compptr->component_needed) + continue; + /* Count non-dummy DCT block rows in this iMCU row. */ + if (cinfo->output_iMCU_row < last_iMCU_row) { + block_rows = compptr->v_samp_factor; + access_rows = block_rows * 2; /* this and next iMCU row */ + last_row = FALSE; + } else { + /* NB: can't use last_row_height here; it is input-side-dependent! */ + block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (block_rows == 0) block_rows = compptr->v_samp_factor; + access_rows = block_rows; /* this iMCU row only */ + last_row = TRUE; + } + /* Align the virtual buffer for this component. */ + if (cinfo->output_iMCU_row > 0) { + access_rows += compptr->v_samp_factor; /* prior iMCU row too */ + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor, + (JDIMENSION) access_rows, FALSE); + buffer += compptr->v_samp_factor; /* point to current iMCU row */ + first_row = FALSE; + } else { + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE); + first_row = TRUE; + } + /* Fetch component-dependent info */ + coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS); + quanttbl = compptr->quant_table; + Q00 = quanttbl->quantval[0]; + Q01 = quanttbl->quantval[Q01_POS]; + Q10 = quanttbl->quantval[Q10_POS]; + Q20 = quanttbl->quantval[Q20_POS]; + Q11 = quanttbl->quantval[Q11_POS]; + Q02 = quanttbl->quantval[Q02_POS]; + inverse_DCT = cinfo->idct->inverse_DCT[ci]; + output_ptr = output_buf[ci]; + /* Loop over all DCT blocks to be processed. */ + for (block_row = 0; block_row < block_rows; block_row++) { + buffer_ptr = buffer[block_row]; + if (first_row && block_row == 0) + prev_block_row = buffer_ptr; + else + prev_block_row = buffer[block_row-1]; + if (last_row && block_row == block_rows-1) + next_block_row = buffer_ptr; + else + next_block_row = buffer[block_row+1]; + /* We fetch the surrounding DC values using a sliding-register approach. + * Initialize all nine here so as to do the right thing on narrow pics. + */ + DC1 = DC2 = DC3 = (int) prev_block_row[0][0]; + DC4 = DC5 = DC6 = (int) buffer_ptr[0][0]; + DC7 = DC8 = DC9 = (int) next_block_row[0][0]; + output_col = 0; + last_block_column = compptr->width_in_blocks - 1; + for (block_num = 0; block_num <= last_block_column; block_num++) { + /* Fetch current DCT block into workspace so we can modify it. */ + jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1); + /* Update DC values */ + if (block_num < last_block_column) { + DC3 = (int) prev_block_row[1][0]; + DC6 = (int) buffer_ptr[1][0]; + DC9 = (int) next_block_row[1][0]; + } + /* Compute coefficient estimates per K.8. + * An estimate is applied only if coefficient is still zero, + * and is not known to be fully accurate. + */ + /* AC01 */ + if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) { + num = 36 * Q00 * (DC4 - DC6); + if (num >= 0) { + pred = (int) (((Q01<<7) + num) / (Q01<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q10<<7) + num) / (Q10<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q20<<7) + num) / (Q20<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q11<<7) + num) / (Q11<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q02<<7) + num) / (Q02<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<DCT_scaled_size; + } + output_ptr += compptr->DCT_scaled_size; + } + } + + if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) + return JPEG_ROW_COMPLETED; + return JPEG_SCAN_COMPLETED; +} + +#endif /* BLOCK_SMOOTHING_SUPPORTED */ + + +/* + * Initialize coefficient buffer controller. + */ + +GLOBAL(void) +jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer) +{ + my_coef_ptr coef; + + coef = (my_coef_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_coef_controller)); + cinfo->coef = (struct jpeg_d_coef_controller *) coef; + coef->pub.start_input_pass = start_input_pass; + coef->pub.start_output_pass = start_output_pass; +#ifdef BLOCK_SMOOTHING_SUPPORTED + coef->coef_bits_latch = NULL; +#endif + + /* Create the coefficient buffer. */ + if (need_full_buffer) { +#ifdef D_MULTISCAN_FILES_SUPPORTED + /* Allocate a full-image virtual array for each component, */ + /* padded to a multiple of samp_factor DCT blocks in each direction. */ + /* Note we ask for a pre-zeroed array. */ + int ci, access_rows; + jpeg_component_info *compptr; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + access_rows = compptr->v_samp_factor; +#ifdef BLOCK_SMOOTHING_SUPPORTED + /* If block smoothing could be used, need a bigger window */ + if (cinfo->progressive_mode) + access_rows *= 3; +#endif + coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE, + (JDIMENSION) jround_up((long) compptr->width_in_blocks, + (long) compptr->h_samp_factor), + (JDIMENSION) jround_up((long) compptr->height_in_blocks, + (long) compptr->v_samp_factor), + (JDIMENSION) access_rows); + } + coef->pub.consume_data = consume_data; + coef->pub.decompress_data = decompress_data; + coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */ +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + /* We only need a single-MCU buffer. */ + JBLOCKROW buffer; + int i; + + buffer = (JBLOCKROW) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); + for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { + coef->MCU_buffer[i] = buffer + i; + } + coef->pub.consume_data = dummy_consume_data; + coef->pub.decompress_data = decompress_onepass; + coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ + } +} diff --git a/src/dep/src/irrlicht/jpeglib/jdcolor.c b/src/dep/src/irrlicht/jpeglib/jdcolor.c index fd7b138..6c04dfe 100644 --- a/src/dep/src/irrlicht/jpeglib/jdcolor.c +++ b/src/dep/src/irrlicht/jpeglib/jdcolor.c @@ -1,396 +1,396 @@ -/* - * jdcolor.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains output colorspace conversion routines. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private subobject */ - -typedef struct { - struct jpeg_color_deconverter pub; /* public fields */ - - /* Private state for YCC->RGB conversion */ - int * Cr_r_tab; /* => table for Cr to R conversion */ - int * Cb_b_tab; /* => table for Cb to B conversion */ - INT32 * Cr_g_tab; /* => table for Cr to G conversion */ - INT32 * Cb_g_tab; /* => table for Cb to G conversion */ -} my_color_deconverter; - -typedef my_color_deconverter * my_cconvert_ptr; - - -/**************** YCbCr -> RGB conversion: most common case **************/ - -/* - * YCbCr is defined per CCIR 601-1, except that Cb and Cr are - * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. - * The conversion equations to be implemented are therefore - * R = Y + 1.40200 * Cr - * G = Y - 0.34414 * Cb - 0.71414 * Cr - * B = Y + 1.77200 * Cb - * where Cb and Cr represent the incoming values less CENTERJSAMPLE. - * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) - * - * To avoid floating-point arithmetic, we represent the fractional constants - * as integers scaled up by 2^16 (about 4 digits precision); we have to divide - * the products by 2^16, with appropriate rounding, to get the correct answer. - * Notice that Y, being an integral input, does not contribute any fraction - * so it need not participate in the rounding. - * - * For even more speed, we avoid doing any multiplications in the inner loop - * by precalculating the constants times Cb and Cr for all possible values. - * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); - * for 12-bit samples it is still acceptable. It's not very reasonable for - * 16-bit samples, but if you want lossless storage you shouldn't be changing - * colorspace anyway. - * The Cr=>R and Cb=>B values can be rounded to integers in advance; the - * values for the G calculation are left scaled up, since we must add them - * together before rounding. - */ - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L<RGB colorspace conversion. - */ - -LOCAL(void) -build_ycc_rgb_table (j_decompress_ptr cinfo) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - int i; - INT32 x; - SHIFT_TEMPS - - cconvert->Cr_r_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - cconvert->Cb_b_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - cconvert->Cr_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - cconvert->Cb_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - - for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { - /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ - /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ - /* Cr=>R value is nearest int to 1.40200 * x */ - cconvert->Cr_r_tab[i] = (int) - RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); - /* Cb=>B value is nearest int to 1.77200 * x */ - cconvert->Cb_b_tab[i] = (int) - RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); - /* Cr=>G value is scaled-up -0.71414 * x */ - cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x; - /* Cb=>G value is scaled-up -0.34414 * x */ - /* We also add in ONE_HALF so that need not do it in inner loop */ - cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; - } -} - - -/* - * Convert some rows of samples to the output colorspace. - * - * Note that we change from noninterleaved, one-plane-per-component format - * to interleaved-pixel format. The output buffer is therefore three times - * as wide as the input buffer. - * A starting row offset is provided only for the input buffer. The caller - * can easily adjust the passed output_buf value to accommodate any row - * offset required on that side. - */ - -METHODDEF(void) -ycc_rgb_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int y, cb, cr; - register JSAMPROW outptr; - register JSAMPROW inptr0, inptr1, inptr2; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - register int * Crrtab = cconvert->Cr_r_tab; - register int * Cbbtab = cconvert->Cb_b_tab; - register INT32 * Crgtab = cconvert->Cr_g_tab; - register INT32 * Cbgtab = cconvert->Cb_g_tab; - SHIFT_TEMPS - - while (--num_rows >= 0) { - inptr0 = input_buf[0][input_row]; - inptr1 = input_buf[1][input_row]; - inptr2 = input_buf[2][input_row]; - input_row++; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - y = GETJSAMPLE(inptr0[col]); - cb = GETJSAMPLE(inptr1[col]); - cr = GETJSAMPLE(inptr2[col]); - /* Range-limiting is essential due to noise introduced by DCT losses. */ - outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; - outptr[RGB_GREEN] = range_limit[y + - ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], - SCALEBITS))]; - outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; - outptr += RGB_PIXELSIZE; - } - } -} - - -/**************** Cases other than YCbCr -> RGB **************/ - - -/* - * Color conversion for no colorspace change: just copy the data, - * converting from separate-planes to interleaved representation. - */ - -METHODDEF(void) -null_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - register JSAMPROW inptr, outptr; - register JDIMENSION count; - register int num_components = cinfo->num_components; - JDIMENSION num_cols = cinfo->output_width; - int ci; - - while (--num_rows >= 0) { - for (ci = 0; ci < num_components; ci++) { - inptr = input_buf[ci][input_row]; - outptr = output_buf[0] + ci; - for (count = num_cols; count > 0; count--) { - *outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */ - outptr += num_components; - } - } - input_row++; - output_buf++; - } -} - - -/* - * Color conversion for grayscale: just copy the data. - * This also works for YCbCr -> grayscale conversion, in which - * we just copy the Y (luminance) component and ignore chrominance. - */ - -METHODDEF(void) -grayscale_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0, - num_rows, cinfo->output_width); -} - - -/* - * Convert grayscale to RGB: just duplicate the graylevel three times. - * This is provided to support applications that don't want to cope - * with grayscale as a separate case. - */ - -METHODDEF(void) -gray_rgb_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - register JSAMPROW inptr, outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - - while (--num_rows >= 0) { - inptr = input_buf[0][input_row++]; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - /* We can dispense with GETJSAMPLE() here */ - outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; - outptr += RGB_PIXELSIZE; - } - } -} - - -/* - * Adobe-style YCCK->CMYK conversion. - * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same - * conversion as above, while passing K (black) unchanged. - * We assume build_ycc_rgb_table has been called. - */ - -METHODDEF(void) -ycck_cmyk_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int y, cb, cr; - register JSAMPROW outptr; - register JSAMPROW inptr0, inptr1, inptr2, inptr3; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - register int * Crrtab = cconvert->Cr_r_tab; - register int * Cbbtab = cconvert->Cb_b_tab; - register INT32 * Crgtab = cconvert->Cr_g_tab; - register INT32 * Cbgtab = cconvert->Cb_g_tab; - SHIFT_TEMPS - - while (--num_rows >= 0) { - inptr0 = input_buf[0][input_row]; - inptr1 = input_buf[1][input_row]; - inptr2 = input_buf[2][input_row]; - inptr3 = input_buf[3][input_row]; - input_row++; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - y = GETJSAMPLE(inptr0[col]); - cb = GETJSAMPLE(inptr1[col]); - cr = GETJSAMPLE(inptr2[col]); - /* Range-limiting is essential due to noise introduced by DCT losses. */ - outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */ - outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ - ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], - SCALEBITS)))]; - outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */ - /* K passes through unchanged */ - outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */ - outptr += 4; - } - } -} - - -/* - * Empty method for start_pass. - */ - -METHODDEF(void) -start_pass_dcolor (j_decompress_ptr cinfo) -{ - /* no work needed */ -} - - -/* - * Module initialization routine for output colorspace conversion. - */ - -GLOBAL(void) -jinit_color_deconverter (j_decompress_ptr cinfo) -{ - my_cconvert_ptr cconvert; - int ci; - - cconvert = (my_cconvert_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_color_deconverter)); - cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert; - cconvert->pub.start_pass = start_pass_dcolor; - - /* Make sure num_components agrees with jpeg_color_space */ - switch (cinfo->jpeg_color_space) { - case JCS_GRAYSCALE: - if (cinfo->num_components != 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - case JCS_RGB: - case JCS_YCbCr: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - case JCS_CMYK: - case JCS_YCCK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - default: /* JCS_UNKNOWN can be anything */ - if (cinfo->num_components < 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - } - - /* Set out_color_components and conversion method based on requested space. - * Also clear the component_needed flags for any unused components, - * so that earlier pipeline stages can avoid useless computation. - */ - - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - cinfo->out_color_components = 1; - if (cinfo->jpeg_color_space == JCS_GRAYSCALE || - cinfo->jpeg_color_space == JCS_YCbCr) { - cconvert->pub.color_convert = grayscale_convert; - /* For color->grayscale conversion, only the Y (0) component is needed */ - for (ci = 1; ci < cinfo->num_components; ci++) - cinfo->comp_info[ci].component_needed = FALSE; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_RGB: - cinfo->out_color_components = RGB_PIXELSIZE; - if (cinfo->jpeg_color_space == JCS_YCbCr) { - cconvert->pub.color_convert = ycc_rgb_convert; - build_ycc_rgb_table(cinfo); - } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) { - cconvert->pub.color_convert = gray_rgb_convert; - } else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) { - cconvert->pub.color_convert = null_convert; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_CMYK: - cinfo->out_color_components = 4; - if (cinfo->jpeg_color_space == JCS_YCCK) { - cconvert->pub.color_convert = ycck_cmyk_convert; - build_ycc_rgb_table(cinfo); - } else if (cinfo->jpeg_color_space == JCS_CMYK) { - cconvert->pub.color_convert = null_convert; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - default: - /* Permit null conversion to same output space */ - if (cinfo->out_color_space == cinfo->jpeg_color_space) { - cinfo->out_color_components = cinfo->num_components; - cconvert->pub.color_convert = null_convert; - } else /* unsupported non-null conversion */ - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - } - - if (cinfo->quantize_colors) - cinfo->output_components = 1; /* single colormapped output component */ - else - cinfo->output_components = cinfo->out_color_components; -} +/* + * jdcolor.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains output colorspace conversion routines. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private subobject */ + +typedef struct { + struct jpeg_color_deconverter pub; /* public fields */ + + /* Private state for YCC->RGB conversion */ + int * Cr_r_tab; /* => table for Cr to R conversion */ + int * Cb_b_tab; /* => table for Cb to B conversion */ + INT32 * Cr_g_tab; /* => table for Cr to G conversion */ + INT32 * Cb_g_tab; /* => table for Cb to G conversion */ +} my_color_deconverter; + +typedef my_color_deconverter * my_cconvert_ptr; + + +/**************** YCbCr -> RGB conversion: most common case **************/ + +/* + * YCbCr is defined per CCIR 601-1, except that Cb and Cr are + * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. + * The conversion equations to be implemented are therefore + * R = Y + 1.40200 * Cr + * G = Y - 0.34414 * Cb - 0.71414 * Cr + * B = Y + 1.77200 * Cb + * where Cb and Cr represent the incoming values less CENTERJSAMPLE. + * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) + * + * To avoid floating-point arithmetic, we represent the fractional constants + * as integers scaled up by 2^16 (about 4 digits precision); we have to divide + * the products by 2^16, with appropriate rounding, to get the correct answer. + * Notice that Y, being an integral input, does not contribute any fraction + * so it need not participate in the rounding. + * + * For even more speed, we avoid doing any multiplications in the inner loop + * by precalculating the constants times Cb and Cr for all possible values. + * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); + * for 12-bit samples it is still acceptable. It's not very reasonable for + * 16-bit samples, but if you want lossless storage you shouldn't be changing + * colorspace anyway. + * The Cr=>R and Cb=>B values can be rounded to integers in advance; the + * values for the G calculation are left scaled up, since we must add them + * together before rounding. + */ + +#define SCALEBITS 16 /* speediest right-shift on some machines */ +#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) +#define FIX(x) ((INT32) ((x) * (1L<RGB colorspace conversion. + */ + +LOCAL(void) +build_ycc_rgb_table (j_decompress_ptr cinfo) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + int i; + INT32 x; + SHIFT_TEMPS + + cconvert->Cr_r_tab = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(int)); + cconvert->Cb_b_tab = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(int)); + cconvert->Cr_g_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(INT32)); + cconvert->Cb_g_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(INT32)); + + for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { + /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ + /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ + /* Cr=>R value is nearest int to 1.40200 * x */ + cconvert->Cr_r_tab[i] = (int) + RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); + /* Cb=>B value is nearest int to 1.77200 * x */ + cconvert->Cb_b_tab[i] = (int) + RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); + /* Cr=>G value is scaled-up -0.71414 * x */ + cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x; + /* Cb=>G value is scaled-up -0.34414 * x */ + /* We also add in ONE_HALF so that need not do it in inner loop */ + cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; + } +} + + +/* + * Convert some rows of samples to the output colorspace. + * + * Note that we change from noninterleaved, one-plane-per-component format + * to interleaved-pixel format. The output buffer is therefore three times + * as wide as the input buffer. + * A starting row offset is provided only for the input buffer. The caller + * can easily adjust the passed output_buf value to accommodate any row + * offset required on that side. + */ + +METHODDEF(void) +ycc_rgb_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int y, cb, cr; + register JSAMPROW outptr; + register JSAMPROW inptr0, inptr1, inptr2; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + register int * Crrtab = cconvert->Cr_r_tab; + register int * Cbbtab = cconvert->Cb_b_tab; + register INT32 * Crgtab = cconvert->Cr_g_tab; + register INT32 * Cbgtab = cconvert->Cb_g_tab; + SHIFT_TEMPS + + while (--num_rows >= 0) { + inptr0 = input_buf[0][input_row]; + inptr1 = input_buf[1][input_row]; + inptr2 = input_buf[2][input_row]; + input_row++; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + y = GETJSAMPLE(inptr0[col]); + cb = GETJSAMPLE(inptr1[col]); + cr = GETJSAMPLE(inptr2[col]); + /* Range-limiting is essential due to noise introduced by DCT losses. */ + outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; + outptr[RGB_GREEN] = range_limit[y + + ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], + SCALEBITS))]; + outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; + outptr += RGB_PIXELSIZE; + } + } +} + + +/**************** Cases other than YCbCr -> RGB **************/ + + +/* + * Color conversion for no colorspace change: just copy the data, + * converting from separate-planes to interleaved representation. + */ + +METHODDEF(void) +null_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + register JSAMPROW inptr, outptr; + register JDIMENSION count; + register int num_components = cinfo->num_components; + JDIMENSION num_cols = cinfo->output_width; + int ci; + + while (--num_rows >= 0) { + for (ci = 0; ci < num_components; ci++) { + inptr = input_buf[ci][input_row]; + outptr = output_buf[0] + ci; + for (count = num_cols; count > 0; count--) { + *outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */ + outptr += num_components; + } + } + input_row++; + output_buf++; + } +} + + +/* + * Color conversion for grayscale: just copy the data. + * This also works for YCbCr -> grayscale conversion, in which + * we just copy the Y (luminance) component and ignore chrominance. + */ + +METHODDEF(void) +grayscale_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0, + num_rows, cinfo->output_width); +} + + +/* + * Convert grayscale to RGB: just duplicate the graylevel three times. + * This is provided to support applications that don't want to cope + * with grayscale as a separate case. + */ + +METHODDEF(void) +gray_rgb_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + register JSAMPROW inptr, outptr; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + + while (--num_rows >= 0) { + inptr = input_buf[0][input_row++]; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + /* We can dispense with GETJSAMPLE() here */ + outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; + outptr += RGB_PIXELSIZE; + } + } +} + + +/* + * Adobe-style YCCK->CMYK conversion. + * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same + * conversion as above, while passing K (black) unchanged. + * We assume build_ycc_rgb_table has been called. + */ + +METHODDEF(void) +ycck_cmyk_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int y, cb, cr; + register JSAMPROW outptr; + register JSAMPROW inptr0, inptr1, inptr2, inptr3; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + register int * Crrtab = cconvert->Cr_r_tab; + register int * Cbbtab = cconvert->Cb_b_tab; + register INT32 * Crgtab = cconvert->Cr_g_tab; + register INT32 * Cbgtab = cconvert->Cb_g_tab; + SHIFT_TEMPS + + while (--num_rows >= 0) { + inptr0 = input_buf[0][input_row]; + inptr1 = input_buf[1][input_row]; + inptr2 = input_buf[2][input_row]; + inptr3 = input_buf[3][input_row]; + input_row++; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + y = GETJSAMPLE(inptr0[col]); + cb = GETJSAMPLE(inptr1[col]); + cr = GETJSAMPLE(inptr2[col]); + /* Range-limiting is essential due to noise introduced by DCT losses. */ + outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */ + outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ + ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], + SCALEBITS)))]; + outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */ + /* K passes through unchanged */ + outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */ + outptr += 4; + } + } +} + + +/* + * Empty method for start_pass. + */ + +METHODDEF(void) +start_pass_dcolor (j_decompress_ptr cinfo) +{ + /* no work needed */ +} + + +/* + * Module initialization routine for output colorspace conversion. + */ + +GLOBAL(void) +jinit_color_deconverter (j_decompress_ptr cinfo) +{ + my_cconvert_ptr cconvert; + int ci; + + cconvert = (my_cconvert_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_color_deconverter)); + cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert; + cconvert->pub.start_pass = start_pass_dcolor; + + /* Make sure num_components agrees with jpeg_color_space */ + switch (cinfo->jpeg_color_space) { + case JCS_GRAYSCALE: + if (cinfo->num_components != 1) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + + case JCS_RGB: + case JCS_YCbCr: + if (cinfo->num_components != 3) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + + case JCS_CMYK: + case JCS_YCCK: + if (cinfo->num_components != 4) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + + default: /* JCS_UNKNOWN can be anything */ + if (cinfo->num_components < 1) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + } + + /* Set out_color_components and conversion method based on requested space. + * Also clear the component_needed flags for any unused components, + * so that earlier pipeline stages can avoid useless computation. + */ + + switch (cinfo->out_color_space) { + case JCS_GRAYSCALE: + cinfo->out_color_components = 1; + if (cinfo->jpeg_color_space == JCS_GRAYSCALE || + cinfo->jpeg_color_space == JCS_YCbCr) { + cconvert->pub.color_convert = grayscale_convert; + /* For color->grayscale conversion, only the Y (0) component is needed */ + for (ci = 1; ci < cinfo->num_components; ci++) + cinfo->comp_info[ci].component_needed = FALSE; + } else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_RGB: + cinfo->out_color_components = RGB_PIXELSIZE; + if (cinfo->jpeg_color_space == JCS_YCbCr) { + cconvert->pub.color_convert = ycc_rgb_convert; + build_ycc_rgb_table(cinfo); + } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) { + cconvert->pub.color_convert = gray_rgb_convert; + } else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) { + cconvert->pub.color_convert = null_convert; + } else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_CMYK: + cinfo->out_color_components = 4; + if (cinfo->jpeg_color_space == JCS_YCCK) { + cconvert->pub.color_convert = ycck_cmyk_convert; + build_ycc_rgb_table(cinfo); + } else if (cinfo->jpeg_color_space == JCS_CMYK) { + cconvert->pub.color_convert = null_convert; + } else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + default: + /* Permit null conversion to same output space */ + if (cinfo->out_color_space == cinfo->jpeg_color_space) { + cinfo->out_color_components = cinfo->num_components; + cconvert->pub.color_convert = null_convert; + } else /* unsupported non-null conversion */ + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + } + + if (cinfo->quantize_colors) + cinfo->output_components = 1; /* single colormapped output component */ + else + cinfo->output_components = cinfo->out_color_components; +} diff --git a/src/dep/src/irrlicht/jpeglib/jdct.h b/src/dep/src/irrlicht/jpeglib/jdct.h index b664cab..04192a2 100644 --- a/src/dep/src/irrlicht/jpeglib/jdct.h +++ b/src/dep/src/irrlicht/jpeglib/jdct.h @@ -1,176 +1,176 @@ -/* - * jdct.h - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This include file contains common declarations for the forward and - * inverse DCT modules. These declarations are private to the DCT managers - * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms. - * The individual DCT algorithms are kept in separate files to ease - * machine-dependent tuning (e.g., assembly coding). - */ - - -/* - * A forward DCT routine is given a pointer to a work area of type DCTELEM[]; - * the DCT is to be performed in-place in that buffer. Type DCTELEM is int - * for 8-bit samples, INT32 for 12-bit samples. (NOTE: Floating-point DCT - * implementations use an array of type FAST_FLOAT, instead.) - * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE). - * The DCT outputs are returned scaled up by a factor of 8; they therefore - * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This - * convention improves accuracy in integer implementations and saves some - * work in floating-point ones. - * Quantization of the output coefficients is done by jcdctmgr.c. - */ - -#if BITS_IN_JSAMPLE == 8 -typedef int DCTELEM; /* 16 or 32 bits is fine */ -#else -typedef INT32 DCTELEM; /* must have 32 bits */ -#endif - -typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data)); -typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data)); - - -/* - * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer - * to an output sample array. The routine must dequantize the input data as - * well as perform the IDCT; for dequantization, it uses the multiplier table - * pointed to by compptr->dct_table. The output data is to be placed into the - * sample array starting at a specified column. (Any row offset needed will - * be applied to the array pointer before it is passed to the IDCT code.) - * Note that the number of samples emitted by the IDCT routine is - * DCT_scaled_size * DCT_scaled_size. - */ - -/* typedef inverse_DCT_method_ptr is declared in jpegint.h */ - -/* - * Each IDCT routine has its own ideas about the best dct_table element type. - */ - -typedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */ -#if BITS_IN_JSAMPLE == 8 -typedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */ -#define IFAST_SCALE_BITS 2 /* fractional bits in scale factors */ -#else -typedef INT32 IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */ -#define IFAST_SCALE_BITS 13 /* fractional bits in scale factors */ -#endif -typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */ - - -/* - * Each IDCT routine is responsible for range-limiting its results and - * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could - * be quite far out of range if the input data is corrupt, so a bulletproof - * range-limiting step is required. We use a mask-and-table-lookup method - * to do the combined operations quickly. See the comments with - * prepare_range_limit_table (in jdmaster.c) for more info. - */ - -#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE) - -#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */ - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_fdct_islow jFDislow -#define jpeg_fdct_ifast jFDifast -#define jpeg_fdct_float jFDfloat -#define jpeg_idct_islow jRDislow -#define jpeg_idct_ifast jRDifast -#define jpeg_idct_float jRDfloat -#define jpeg_idct_4x4 jRD4x4 -#define jpeg_idct_2x2 jRD2x2 -#define jpeg_idct_1x1 jRD1x1 -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Extern declarations for the forward and inverse DCT routines. */ - -EXTERN(void) jpeg_fdct_islow JPP((DCTELEM * data)); -EXTERN(void) jpeg_fdct_ifast JPP((DCTELEM * data)); -EXTERN(void) jpeg_fdct_float JPP((FAST_FLOAT * data)); - -EXTERN(void) jpeg_idct_islow - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_ifast - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_float - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_4x4 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_2x2 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_1x1 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); - - -/* - * Macros for handling fixed-point arithmetic; these are used by many - * but not all of the DCT/IDCT modules. - * - * All values are expected to be of type INT32. - * Fractional constants are scaled left by CONST_BITS bits. - * CONST_BITS is defined within each module using these macros, - * and may differ from one module to the next. - */ - -#define ONE ((INT32) 1) -#define CONST_SCALE (ONE << CONST_BITS) - -/* Convert a positive real constant to an integer scaled by CONST_SCALE. - * Caution: some C compilers fail to reduce "FIX(constant)" at compile time, - * thus causing a lot of useless floating-point operations at run time. - */ - -#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5)) - -/* Descale and correctly round an INT32 value that's scaled by N bits. - * We assume RIGHT_SHIFT rounds towards minus infinity, so adding - * the fudge factor is correct for either sign of X. - */ - -#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n) - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * This macro is used only when the two inputs will actually be no more than - * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a - * full 32x32 multiply. This provides a useful speedup on many machines. - * Unfortunately there is no way to specify a 16x16->32 multiply portably - * in C, but some C compilers will do the right thing if you provide the - * correct combination of casts. - */ - -#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ -#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT16) (const))) -#endif -#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */ -#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT32) (const))) -#endif - -#ifndef MULTIPLY16C16 /* default definition */ -#define MULTIPLY16C16(var,const) ((var) * (const)) -#endif - -/* Same except both inputs are variables. */ - -#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ -#define MULTIPLY16V16(var1,var2) (((INT16) (var1)) * ((INT16) (var2))) -#endif - -#ifndef MULTIPLY16V16 /* default definition */ -#define MULTIPLY16V16(var1,var2) ((var1) * (var2)) -#endif +/* + * jdct.h + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This include file contains common declarations for the forward and + * inverse DCT modules. These declarations are private to the DCT managers + * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms. + * The individual DCT algorithms are kept in separate files to ease + * machine-dependent tuning (e.g., assembly coding). + */ + + +/* + * A forward DCT routine is given a pointer to a work area of type DCTELEM[]; + * the DCT is to be performed in-place in that buffer. Type DCTELEM is int + * for 8-bit samples, INT32 for 12-bit samples. (NOTE: Floating-point DCT + * implementations use an array of type FAST_FLOAT, instead.) + * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE). + * The DCT outputs are returned scaled up by a factor of 8; they therefore + * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This + * convention improves accuracy in integer implementations and saves some + * work in floating-point ones. + * Quantization of the output coefficients is done by jcdctmgr.c. + */ + +#if BITS_IN_JSAMPLE == 8 +typedef int DCTELEM; /* 16 or 32 bits is fine */ +#else +typedef INT32 DCTELEM; /* must have 32 bits */ +#endif + +typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data)); +typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data)); + + +/* + * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer + * to an output sample array. The routine must dequantize the input data as + * well as perform the IDCT; for dequantization, it uses the multiplier table + * pointed to by compptr->dct_table. The output data is to be placed into the + * sample array starting at a specified column. (Any row offset needed will + * be applied to the array pointer before it is passed to the IDCT code.) + * Note that the number of samples emitted by the IDCT routine is + * DCT_scaled_size * DCT_scaled_size. + */ + +/* typedef inverse_DCT_method_ptr is declared in jpegint.h */ + +/* + * Each IDCT routine has its own ideas about the best dct_table element type. + */ + +typedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */ +#if BITS_IN_JSAMPLE == 8 +typedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */ +#define IFAST_SCALE_BITS 2 /* fractional bits in scale factors */ +#else +typedef INT32 IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */ +#define IFAST_SCALE_BITS 13 /* fractional bits in scale factors */ +#endif +typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */ + + +/* + * Each IDCT routine is responsible for range-limiting its results and + * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could + * be quite far out of range if the input data is corrupt, so a bulletproof + * range-limiting step is required. We use a mask-and-table-lookup method + * to do the combined operations quickly. See the comments with + * prepare_range_limit_table (in jdmaster.c) for more info. + */ + +#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE) + +#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */ + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_fdct_islow jFDislow +#define jpeg_fdct_ifast jFDifast +#define jpeg_fdct_float jFDfloat +#define jpeg_idct_islow jRDislow +#define jpeg_idct_ifast jRDifast +#define jpeg_idct_float jRDfloat +#define jpeg_idct_4x4 jRD4x4 +#define jpeg_idct_2x2 jRD2x2 +#define jpeg_idct_1x1 jRD1x1 +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + +/* Extern declarations for the forward and inverse DCT routines. */ + +EXTERN(void) jpeg_fdct_islow JPP((DCTELEM * data)); +EXTERN(void) jpeg_fdct_ifast JPP((DCTELEM * data)); +EXTERN(void) jpeg_fdct_float JPP((FAST_FLOAT * data)); + +EXTERN(void) jpeg_idct_islow + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_ifast + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_float + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_4x4 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_2x2 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_1x1 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); + + +/* + * Macros for handling fixed-point arithmetic; these are used by many + * but not all of the DCT/IDCT modules. + * + * All values are expected to be of type INT32. + * Fractional constants are scaled left by CONST_BITS bits. + * CONST_BITS is defined within each module using these macros, + * and may differ from one module to the next. + */ + +#define ONE ((INT32) 1) +#define CONST_SCALE (ONE << CONST_BITS) + +/* Convert a positive real constant to an integer scaled by CONST_SCALE. + * Caution: some C compilers fail to reduce "FIX(constant)" at compile time, + * thus causing a lot of useless floating-point operations at run time. + */ + +#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5)) + +/* Descale and correctly round an INT32 value that's scaled by N bits. + * We assume RIGHT_SHIFT rounds towards minus infinity, so adding + * the fudge factor is correct for either sign of X. + */ + +#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n) + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * This macro is used only when the two inputs will actually be no more than + * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a + * full 32x32 multiply. This provides a useful speedup on many machines. + * Unfortunately there is no way to specify a 16x16->32 multiply portably + * in C, but some C compilers will do the right thing if you provide the + * correct combination of casts. + */ + +#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ +#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT16) (const))) +#endif +#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */ +#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT32) (const))) +#endif + +#ifndef MULTIPLY16C16 /* default definition */ +#define MULTIPLY16C16(var,const) ((var) * (const)) +#endif + +/* Same except both inputs are variables. */ + +#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ +#define MULTIPLY16V16(var1,var2) (((INT16) (var1)) * ((INT16) (var2))) +#endif + +#ifndef MULTIPLY16V16 /* default definition */ +#define MULTIPLY16V16(var1,var2) ((var1) * (var2)) +#endif diff --git a/src/dep/src/irrlicht/jpeglib/jddctmgr.c b/src/dep/src/irrlicht/jpeglib/jddctmgr.c index 0e44eb1..bbf8d0e 100644 --- a/src/dep/src/irrlicht/jpeglib/jddctmgr.c +++ b/src/dep/src/irrlicht/jpeglib/jddctmgr.c @@ -1,269 +1,269 @@ -/* - * jddctmgr.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the inverse-DCT management logic. - * This code selects a particular IDCT implementation to be used, - * and it performs related housekeeping chores. No code in this file - * is executed per IDCT step, only during output pass setup. - * - * Note that the IDCT routines are responsible for performing coefficient - * dequantization as well as the IDCT proper. This module sets up the - * dequantization multiplier table needed by the IDCT routine. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - - -/* - * The decompressor input side (jdinput.c) saves away the appropriate - * quantization table for each component at the start of the first scan - * involving that component. (This is necessary in order to correctly - * decode files that reuse Q-table slots.) - * When we are ready to make an output pass, the saved Q-table is converted - * to a multiplier table that will actually be used by the IDCT routine. - * The multiplier table contents are IDCT-method-dependent. To support - * application changes in IDCT method between scans, we can remake the - * multiplier tables if necessary. - * In buffered-image mode, the first output pass may occur before any data - * has been seen for some components, and thus before their Q-tables have - * been saved away. To handle this case, multiplier tables are preset - * to zeroes; the result of the IDCT will be a neutral gray level. - */ - - -/* Private subobject for this module */ - -typedef struct { - struct jpeg_inverse_dct pub; /* public fields */ - - /* This array contains the IDCT method code that each multiplier table - * is currently set up for, or -1 if it's not yet set up. - * The actual multiplier tables are pointed to by dct_table in the - * per-component comp_info structures. - */ - int cur_method[MAX_COMPONENTS]; -} my_idct_controller; - -typedef my_idct_controller * my_idct_ptr; - - -/* Allocated multiplier tables: big enough for any supported variant */ - -typedef union { - ISLOW_MULT_TYPE islow_array[DCTSIZE2]; -#ifdef DCT_IFAST_SUPPORTED - IFAST_MULT_TYPE ifast_array[DCTSIZE2]; -#endif -#ifdef DCT_FLOAT_SUPPORTED - FLOAT_MULT_TYPE float_array[DCTSIZE2]; -#endif -} multiplier_table; - - -/* The current scaled-IDCT routines require ISLOW-style multiplier tables, - * so be sure to compile that code if either ISLOW or SCALING is requested. - */ -#ifdef DCT_ISLOW_SUPPORTED -#define PROVIDE_ISLOW_TABLES -#else -#ifdef IDCT_SCALING_SUPPORTED -#define PROVIDE_ISLOW_TABLES -#endif -#endif - - -/* - * Prepare for an output pass. - * Here we select the proper IDCT routine for each component and build - * a matching multiplier table. - */ - -METHODDEF(void) -start_pass (j_decompress_ptr cinfo) -{ - my_idct_ptr idct = (my_idct_ptr) cinfo->idct; - int ci, i; - jpeg_component_info *compptr; - int method = 0; - inverse_DCT_method_ptr method_ptr = NULL; - JQUANT_TBL * qtbl; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Select the proper IDCT routine for this component's scaling */ - switch (compptr->DCT_scaled_size) { -#ifdef IDCT_SCALING_SUPPORTED - case 1: - method_ptr = jpeg_idct_1x1; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; - case 2: - method_ptr = jpeg_idct_2x2; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; - case 4: - method_ptr = jpeg_idct_4x4; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; -#endif - case DCTSIZE: - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - method_ptr = jpeg_idct_islow; - method = JDCT_ISLOW; - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - method_ptr = jpeg_idct_ifast; - method = JDCT_IFAST; - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - method_ptr = jpeg_idct_float; - method = JDCT_FLOAT; - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - break; - default: - ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size); - break; - } - idct->pub.inverse_DCT[ci] = method_ptr; - /* Create multiplier table from quant table. - * However, we can skip this if the component is uninteresting - * or if we already built the table. Also, if no quant table - * has yet been saved for the component, we leave the - * multiplier table all-zero; we'll be reading zeroes from the - * coefficient controller's buffer anyway. - */ - if (! compptr->component_needed || idct->cur_method[ci] == method) - continue; - qtbl = compptr->quant_table; - if (qtbl == NULL) /* happens if no data yet for component */ - continue; - idct->cur_method[ci] = method; - switch (method) { -#ifdef PROVIDE_ISLOW_TABLES - case JDCT_ISLOW: - { - /* For LL&M IDCT method, multipliers are equal to raw quantization - * coefficients, but are stored as ints to ensure access efficiency. - */ - ISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table; - for (i = 0; i < DCTSIZE2; i++) { - ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[i]; - } - } - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - { - /* For AA&N IDCT method, multipliers are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * For integer operation, the multiplier table is to be scaled by - * IFAST_SCALE_BITS. - */ - IFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table; -#define CONST_BITS 14 - static const INT16 aanscales[DCTSIZE2] = { - /* precomputed values scaled up by 14 bits */ - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, - 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, - 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, - 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, - 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 - }; - SHIFT_TEMPS - - for (i = 0; i < DCTSIZE2; i++) { - ifmtbl[i] = (IFAST_MULT_TYPE) - DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], - (INT32) aanscales[i]), - CONST_BITS-IFAST_SCALE_BITS); - } - } - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - { - /* For float AA&N IDCT method, multipliers are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - */ - FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table; - int row, col; - static const double aanscalefactor[DCTSIZE] = { - 1.0, 1.387039845, 1.306562965, 1.175875602, - 1.0, 0.785694958, 0.541196100, 0.275899379 - }; - - i = 0; - for (row = 0; row < DCTSIZE; row++) { - for (col = 0; col < DCTSIZE; col++) { - fmtbl[i] = (FLOAT_MULT_TYPE) - ((double) qtbl->quantval[i] * - aanscalefactor[row] * aanscalefactor[col]); - i++; - } - } - } - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - } -} - - -/* - * Initialize IDCT manager. - */ - -GLOBAL(void) -jinit_inverse_dct (j_decompress_ptr cinfo) -{ - my_idct_ptr idct; - int ci; - jpeg_component_info *compptr; - - idct = (my_idct_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_idct_controller)); - cinfo->idct = (struct jpeg_inverse_dct *) idct; - idct->pub.start_pass = start_pass; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Allocate and pre-zero a multiplier table for each component */ - compptr->dct_table = - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(multiplier_table)); - MEMZERO(compptr->dct_table, SIZEOF(multiplier_table)); - /* Mark multiplier table not yet set up for any method */ - idct->cur_method[ci] = -1; - } -} +/* + * jddctmgr.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the inverse-DCT management logic. + * This code selects a particular IDCT implementation to be used, + * and it performs related housekeeping chores. No code in this file + * is executed per IDCT step, only during output pass setup. + * + * Note that the IDCT routines are responsible for performing coefficient + * dequantization as well as the IDCT proper. This module sets up the + * dequantization multiplier table needed by the IDCT routine. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + + +/* + * The decompressor input side (jdinput.c) saves away the appropriate + * quantization table for each component at the start of the first scan + * involving that component. (This is necessary in order to correctly + * decode files that reuse Q-table slots.) + * When we are ready to make an output pass, the saved Q-table is converted + * to a multiplier table that will actually be used by the IDCT routine. + * The multiplier table contents are IDCT-method-dependent. To support + * application changes in IDCT method between scans, we can remake the + * multiplier tables if necessary. + * In buffered-image mode, the first output pass may occur before any data + * has been seen for some components, and thus before their Q-tables have + * been saved away. To handle this case, multiplier tables are preset + * to zeroes; the result of the IDCT will be a neutral gray level. + */ + + +/* Private subobject for this module */ + +typedef struct { + struct jpeg_inverse_dct pub; /* public fields */ + + /* This array contains the IDCT method code that each multiplier table + * is currently set up for, or -1 if it's not yet set up. + * The actual multiplier tables are pointed to by dct_table in the + * per-component comp_info structures. + */ + int cur_method[MAX_COMPONENTS]; +} my_idct_controller; + +typedef my_idct_controller * my_idct_ptr; + + +/* Allocated multiplier tables: big enough for any supported variant */ + +typedef union { + ISLOW_MULT_TYPE islow_array[DCTSIZE2]; +#ifdef DCT_IFAST_SUPPORTED + IFAST_MULT_TYPE ifast_array[DCTSIZE2]; +#endif +#ifdef DCT_FLOAT_SUPPORTED + FLOAT_MULT_TYPE float_array[DCTSIZE2]; +#endif +} multiplier_table; + + +/* The current scaled-IDCT routines require ISLOW-style multiplier tables, + * so be sure to compile that code if either ISLOW or SCALING is requested. + */ +#ifdef DCT_ISLOW_SUPPORTED +#define PROVIDE_ISLOW_TABLES +#else +#ifdef IDCT_SCALING_SUPPORTED +#define PROVIDE_ISLOW_TABLES +#endif +#endif + + +/* + * Prepare for an output pass. + * Here we select the proper IDCT routine for each component and build + * a matching multiplier table. + */ + +METHODDEF(void) +start_pass (j_decompress_ptr cinfo) +{ + my_idct_ptr idct = (my_idct_ptr) cinfo->idct; + int ci, i; + jpeg_component_info *compptr; + int method = 0; + inverse_DCT_method_ptr method_ptr = NULL; + JQUANT_TBL * qtbl; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Select the proper IDCT routine for this component's scaling */ + switch (compptr->DCT_scaled_size) { +#ifdef IDCT_SCALING_SUPPORTED + case 1: + method_ptr = jpeg_idct_1x1; + method = JDCT_ISLOW; /* jidctred uses islow-style table */ + break; + case 2: + method_ptr = jpeg_idct_2x2; + method = JDCT_ISLOW; /* jidctred uses islow-style table */ + break; + case 4: + method_ptr = jpeg_idct_4x4; + method = JDCT_ISLOW; /* jidctred uses islow-style table */ + break; +#endif + case DCTSIZE: + switch (cinfo->dct_method) { +#ifdef DCT_ISLOW_SUPPORTED + case JDCT_ISLOW: + method_ptr = jpeg_idct_islow; + method = JDCT_ISLOW; + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + method_ptr = jpeg_idct_ifast; + method = JDCT_IFAST; + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + method_ptr = jpeg_idct_float; + method = JDCT_FLOAT; + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } + break; + default: + ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size); + break; + } + idct->pub.inverse_DCT[ci] = method_ptr; + /* Create multiplier table from quant table. + * However, we can skip this if the component is uninteresting + * or if we already built the table. Also, if no quant table + * has yet been saved for the component, we leave the + * multiplier table all-zero; we'll be reading zeroes from the + * coefficient controller's buffer anyway. + */ + if (! compptr->component_needed || idct->cur_method[ci] == method) + continue; + qtbl = compptr->quant_table; + if (qtbl == NULL) /* happens if no data yet for component */ + continue; + idct->cur_method[ci] = method; + switch (method) { +#ifdef PROVIDE_ISLOW_TABLES + case JDCT_ISLOW: + { + /* For LL&M IDCT method, multipliers are equal to raw quantization + * coefficients, but are stored as ints to ensure access efficiency. + */ + ISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table; + for (i = 0; i < DCTSIZE2; i++) { + ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[i]; + } + } + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + { + /* For AA&N IDCT method, multipliers are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + * For integer operation, the multiplier table is to be scaled by + * IFAST_SCALE_BITS. + */ + IFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table; +#define CONST_BITS 14 + static const INT16 aanscales[DCTSIZE2] = { + /* precomputed values scaled up by 14 bits */ + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, + 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, + 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, + 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, + 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 + }; + SHIFT_TEMPS + + for (i = 0; i < DCTSIZE2; i++) { + ifmtbl[i] = (IFAST_MULT_TYPE) + DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], + (INT32) aanscales[i]), + CONST_BITS-IFAST_SCALE_BITS); + } + } + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + { + /* For float AA&N IDCT method, multipliers are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + */ + FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table; + int row, col; + static const double aanscalefactor[DCTSIZE] = { + 1.0, 1.387039845, 1.306562965, 1.175875602, + 1.0, 0.785694958, 0.541196100, 0.275899379 + }; + + i = 0; + for (row = 0; row < DCTSIZE; row++) { + for (col = 0; col < DCTSIZE; col++) { + fmtbl[i] = (FLOAT_MULT_TYPE) + ((double) qtbl->quantval[i] * + aanscalefactor[row] * aanscalefactor[col]); + i++; + } + } + } + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } + } +} + + +/* + * Initialize IDCT manager. + */ + +GLOBAL(void) +jinit_inverse_dct (j_decompress_ptr cinfo) +{ + my_idct_ptr idct; + int ci; + jpeg_component_info *compptr; + + idct = (my_idct_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_idct_controller)); + cinfo->idct = (struct jpeg_inverse_dct *) idct; + idct->pub.start_pass = start_pass; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Allocate and pre-zero a multiplier table for each component */ + compptr->dct_table = + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(multiplier_table)); + MEMZERO(compptr->dct_table, SIZEOF(multiplier_table)); + /* Mark multiplier table not yet set up for any method */ + idct->cur_method[ci] = -1; + } +} diff --git a/src/dep/src/irrlicht/jpeglib/jdhuff.c b/src/dep/src/irrlicht/jpeglib/jdhuff.c index b2ad66d..b5ba39f 100644 --- a/src/dep/src/irrlicht/jpeglib/jdhuff.c +++ b/src/dep/src/irrlicht/jpeglib/jdhuff.c @@ -1,651 +1,651 @@ -/* - * jdhuff.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy decoding routines. - * - * Much of the complexity here has to do with supporting input suspension. - * If the data source module demands suspension, we want to be able to back - * up to the start of the current MCU. To do this, we copy state variables - * into local working storage, and update them back to the permanent - * storage only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdhuff.h" /* Declarations shared with jdphuff.c */ - - -/* - * Expanded entropy decoder object for Huffman decoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_decoder pub; /* public fields */ - - /* These fields are loaded into local variables at start of each MCU. - * In case of suspension, we exit WITHOUT updating them. - */ - bitread_perm_state bitstate; /* Bit buffer at start of MCU */ - savable_state saved; /* Other state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; - d_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; - - /* Precalculated info set up by start_pass for use in decode_mcu: */ - - /* Pointers to derived tables to be used for each block within an MCU */ - d_derived_tbl * dc_cur_tbls[D_MAX_BLOCKS_IN_MCU]; - d_derived_tbl * ac_cur_tbls[D_MAX_BLOCKS_IN_MCU]; - /* Whether we care about the DC and AC coefficient values for each block */ - boolean dc_needed[D_MAX_BLOCKS_IN_MCU]; - boolean ac_needed[D_MAX_BLOCKS_IN_MCU]; -} huff_entropy_decoder; - -typedef huff_entropy_decoder * huff_entropy_ptr; - - -/* - * Initialize for a Huffman-compressed scan. - */ - -METHODDEF(void) -start_pass_huff_decoder (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, blkn, dctbl, actbl; - jpeg_component_info * compptr; - - /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG. - * This ought to be an error condition, but we make it a warning because - * there are some baseline files out there with all zeroes in these bytes. - */ - if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 || - cinfo->Ah != 0 || cinfo->Al != 0) - WARNMS(cinfo, JWRN_NOT_SEQUENTIAL); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - /* Compute derived values for Huffman tables */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl, - & entropy->dc_derived_tbls[dctbl]); - jpeg_make_d_derived_tbl(cinfo, FALSE, actbl, - & entropy->ac_derived_tbls[actbl]); - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Precalculate decoding info for each block in an MCU of this scan */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - /* Precalculate which table to use for each block */ - entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no]; - entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no]; - /* Decide whether we really care about the coefficient values */ - if (compptr->component_needed) { - entropy->dc_needed[blkn] = TRUE; - /* we don't need the ACs if producing a 1/8th-size image */ - entropy->ac_needed[blkn] = (compptr->DCT_scaled_size > 1); - } else { - entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE; - } - } - - /* Initialize bitread state variables */ - entropy->bitstate.bits_left = 0; - entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ - entropy->pub.insufficient_data = FALSE; - - /* Initialize restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; -} - - -/* - * Compute the derived values for a Huffman table. - * This routine also performs some validation checks on the table. - * - * Note this is also used by jdphuff.c. - */ - -GLOBAL(void) -jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno, - d_derived_tbl ** pdtbl) -{ - JHUFF_TBL *htbl; - d_derived_tbl *dtbl; - int p, i, l, si, numsymbols; - int lookbits, ctr; - char huffsize[257]; - unsigned int huffcode[257]; - unsigned int code; - - /* Note that huffsize[] and huffcode[] are filled in code-length order, - * paralleling the order of the symbols themselves in htbl->huffval[]. - */ - - /* Find the input Huffman table */ - if (tblno < 0 || tblno >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - htbl = - isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - - /* Allocate a workspace if we haven't already done so. */ - if (*pdtbl == NULL) - *pdtbl = (d_derived_tbl *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(d_derived_tbl)); - dtbl = *pdtbl; - dtbl->pub = htbl; /* fill in back link */ - - /* Figure C.1: make table of Huffman code length for each symbol */ - - p = 0; - for (l = 1; l <= 16; l++) { - i = (int) htbl->bits[l]; - if (i < 0 || p + i > 256) /* protect against table overrun */ - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - while (i--) - huffsize[p++] = (char) l; - } - huffsize[p] = 0; - numsymbols = p; - - /* Figure C.2: generate the codes themselves */ - /* We also validate that the counts represent a legal Huffman code tree. */ - - code = 0; - si = huffsize[0]; - p = 0; - while (huffsize[p]) { - while (((int) huffsize[p]) == si) { - huffcode[p++] = code; - code++; - } - /* code is now 1 more than the last code used for codelength si; but - * it must still fit in si bits, since no code is allowed to be all ones. - */ - if (((INT32) code) >= (((INT32) 1) << si)) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - code <<= 1; - si++; - } - - /* Figure F.15: generate decoding tables for bit-sequential decoding */ - - p = 0; - for (l = 1; l <= 16; l++) { - if (htbl->bits[l]) { - /* valoffset[l] = huffval[] index of 1st symbol of code length l, - * minus the minimum code of length l - */ - dtbl->valoffset[l] = (INT32) p - (INT32) huffcode[p]; - p += htbl->bits[l]; - dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */ - } else { - dtbl->maxcode[l] = -1; /* -1 if no codes of this length */ - } - } - dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */ - - /* Compute lookahead tables to speed up decoding. - * First we set all the table entries to 0, indicating "too long"; - * then we iterate through the Huffman codes that are short enough and - * fill in all the entries that correspond to bit sequences starting - * with that code. - */ - - MEMZERO(dtbl->look_nbits, SIZEOF(dtbl->look_nbits)); - - p = 0; - for (l = 1; l <= HUFF_LOOKAHEAD; l++) { - for (i = 1; i <= (int) htbl->bits[l]; i++, p++) { - /* l = current code's length, p = its index in huffcode[] & huffval[]. */ - /* Generate left-justified code followed by all possible bit sequences */ - lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l); - for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) { - dtbl->look_nbits[lookbits] = l; - dtbl->look_sym[lookbits] = htbl->huffval[p]; - lookbits++; - } - } - } - - /* Validate symbols as being reasonable. - * For AC tables, we make no check, but accept all byte values 0..255. - * For DC tables, we require the symbols to be in range 0..15. - * (Tighter bounds could be applied depending on the data depth and mode, - * but this is sufficient to ensure safe decoding.) - */ - if (isDC) { - for (i = 0; i < numsymbols; i++) { - int sym = htbl->huffval[i]; - if (sym < 0 || sym > 15) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - } - } -} - - -/* - * Out-of-line code for bit fetching (shared with jdphuff.c). - * See jdhuff.h for info about usage. - * Note: current values of get_buffer and bits_left are passed as parameters, - * but are returned in the corresponding fields of the state struct. - * - * On most machines MIN_GET_BITS should be 25 to allow the full 32-bit width - * of get_buffer to be used. (On machines with wider words, an even larger - * buffer could be used.) However, on some machines 32-bit shifts are - * quite slow and take time proportional to the number of places shifted. - * (This is true with most PC compilers, for instance.) In this case it may - * be a win to set MIN_GET_BITS to the minimum value of 15. This reduces the - * average shift distance at the cost of more calls to jpeg_fill_bit_buffer. - */ - -#ifdef SLOW_SHIFT_32 -#define MIN_GET_BITS 15 /* minimum allowable value */ -#else -#define MIN_GET_BITS (BIT_BUF_SIZE-7) -#endif - - -GLOBAL(boolean) -jpeg_fill_bit_buffer (bitread_working_state * state, - register bit_buf_type get_buffer, register int bits_left, - int nbits) -/* Load up the bit buffer to a depth of at least nbits */ -{ - /* Copy heavily used state fields into locals (hopefully registers) */ - register const JOCTET * next_input_byte = state->next_input_byte; - register size_t bytes_in_buffer = state->bytes_in_buffer; - j_decompress_ptr cinfo = state->cinfo; - - /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */ - /* (It is assumed that no request will be for more than that many bits.) */ - /* We fail to do so only if we hit a marker or are forced to suspend. */ - - if (cinfo->unread_marker == 0) { /* cannot advance past a marker */ - while (bits_left < MIN_GET_BITS) { - register int c; - - /* Attempt to read a byte */ - if (bytes_in_buffer == 0) { - if (! (*cinfo->src->fill_input_buffer) (cinfo)) - return FALSE; - next_input_byte = cinfo->src->next_input_byte; - bytes_in_buffer = cinfo->src->bytes_in_buffer; - } - bytes_in_buffer--; - c = GETJOCTET(*next_input_byte++); - - /* If it's 0xFF, check and discard stuffed zero byte */ - if (c == 0xFF) { - /* Loop here to discard any padding FF's on terminating marker, - * so that we can save a valid unread_marker value. NOTE: we will - * accept multiple FF's followed by a 0 as meaning a single FF data - * byte. This data pattern is not valid according to the standard. - */ - do { - if (bytes_in_buffer == 0) { - if (! (*cinfo->src->fill_input_buffer) (cinfo)) - return FALSE; - next_input_byte = cinfo->src->next_input_byte; - bytes_in_buffer = cinfo->src->bytes_in_buffer; - } - bytes_in_buffer--; - c = GETJOCTET(*next_input_byte++); - } while (c == 0xFF); - - if (c == 0) { - /* Found FF/00, which represents an FF data byte */ - c = 0xFF; - } else { - /* Oops, it's actually a marker indicating end of compressed data. - * Save the marker code for later use. - * Fine point: it might appear that we should save the marker into - * bitread working state, not straight into permanent state. But - * once we have hit a marker, we cannot need to suspend within the - * current MCU, because we will read no more bytes from the data - * source. So it is OK to update permanent state right away. - */ - cinfo->unread_marker = c; - /* See if we need to insert some fake zero bits. */ - goto no_more_bytes; - } - } - - /* OK, load c into get_buffer */ - get_buffer = (get_buffer << 8) | c; - bits_left += 8; - } /* end while */ - } else { - no_more_bytes: - /* We get here if we've read the marker that terminates the compressed - * data segment. There should be enough bits in the buffer register - * to satisfy the request; if so, no problem. - */ - if (nbits > bits_left) { - /* Uh-oh. Report corrupted data to user and stuff zeroes into - * the data stream, so that we can produce some kind of image. - * We use a nonvolatile flag to ensure that only one warning message - * appears per data segment. - */ - if (! cinfo->entropy->insufficient_data) { - WARNMS(cinfo, JWRN_HIT_MARKER); - cinfo->entropy->insufficient_data = TRUE; - } - /* Fill the buffer with zero bits */ - get_buffer <<= MIN_GET_BITS - bits_left; - bits_left = MIN_GET_BITS; - } - } - - /* Unload the local registers */ - state->next_input_byte = next_input_byte; - state->bytes_in_buffer = bytes_in_buffer; - state->get_buffer = get_buffer; - state->bits_left = bits_left; - - return TRUE; -} - - -/* - * Out-of-line code for Huffman code decoding. - * See jdhuff.h for info about usage. - */ - -GLOBAL(int) -jpeg_huff_decode (bitread_working_state * state, - register bit_buf_type get_buffer, register int bits_left, - d_derived_tbl * htbl, int min_bits) -{ - register int l = min_bits; - register INT32 code; - - /* HUFF_DECODE has determined that the code is at least min_bits */ - /* bits long, so fetch that many bits in one swoop. */ - - CHECK_BIT_BUFFER(*state, l, return -1); - code = GET_BITS(l); - - /* Collect the rest of the Huffman code one bit at a time. */ - /* This is per Figure F.16 in the JPEG spec. */ - - while (code > htbl->maxcode[l]) { - code <<= 1; - CHECK_BIT_BUFFER(*state, 1, return -1); - code |= GET_BITS(1); - l++; - } - - /* Unload the local registers */ - state->get_buffer = get_buffer; - state->bits_left = bits_left; - - /* With garbage input we may reach the sentinel value l = 17. */ - - if (l > 16) { - WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE); - return 0; /* fake a zero as the safest result */ - } - - return htbl->pub->huffval[ (int) (code + htbl->valoffset[l]) ]; -} - - -/* - * Figure F.12: extend sign bit. - * On some machines, a shift and add will be faster than a table lookup. - */ - -#ifdef AVOID_TABLES - -#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) - -#else - -#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) - -static const int extend_test[16] = /* entry n is 2**(n-1) */ - { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, - 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; - -static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ - { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, - ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, - ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, - ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; - -#endif /* AVOID_TABLES */ - - -/* - * Check for a restart marker & resynchronize decoder. - * Returns FALSE if must suspend. - */ - -LOCAL(boolean) -process_restart (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci; - - /* Throw away any unused bits remaining in bit buffer; */ - /* include any full bytes in next_marker's count of discarded bytes */ - cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; - entropy->bitstate.bits_left = 0; - - /* Advance past the RSTn marker */ - if (! (*cinfo->marker->read_restart_marker) (cinfo)) - return FALSE; - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - - /* Reset restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; - - /* Reset out-of-data flag, unless read_restart_marker left us smack up - * against a marker. In that case we will end up treating the next data - * segment as empty, and we can avoid producing bogus output pixels by - * leaving the flag set. - */ - if (cinfo->unread_marker == 0) - entropy->pub.insufficient_data = FALSE; - - return TRUE; -} - - -/* - * Decode and return one MCU's worth of Huffman-compressed coefficients. - * The coefficients are reordered from zigzag order into natural array order, - * but are not dequantized. - * - * The i'th block of the MCU is stored into the block pointed to by - * MCU_data[i]. WE ASSUME THIS AREA HAS BEEN ZEROED BY THE CALLER. - * (Wholesale zeroing is usually a little faster than retail...) - * - * Returns FALSE if data source requested suspension. In that case no - * changes have been made to permanent state. (Exception: some output - * coefficients may already have been assigned. This is harmless for - * this module, since we'll just re-assign them on the next call.) - */ - -METHODDEF(boolean) -decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int blkn; - BITREAD_STATE_VARS; - savable_state state; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(state, entropy->saved); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - JBLOCKROW block = MCU_data[blkn]; - d_derived_tbl * dctbl = entropy->dc_cur_tbls[blkn]; - d_derived_tbl * actbl = entropy->ac_cur_tbls[blkn]; - register int s, k, r; - - /* Decode a single block's worth of coefficients */ - - /* Section F.2.2.1: decode the DC coefficient difference */ - HUFF_DECODE(s, br_state, dctbl, return FALSE, label1); - if (s) { - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - } - - if (entropy->dc_needed[blkn]) { - /* Convert DC difference to actual value, update last_dc_val */ - int ci = cinfo->MCU_membership[blkn]; - s += state.last_dc_val[ci]; - state.last_dc_val[ci] = s; - /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */ - (*block)[0] = (JCOEF) s; - } - - if (entropy->ac_needed[blkn]) { - - /* Section F.2.2.2: decode the AC coefficients */ - /* Since zeroes are skipped, output area must be cleared beforehand */ - for (k = 1; k < DCTSIZE2; k++) { - HUFF_DECODE(s, br_state, actbl, return FALSE, label2); - - r = s >> 4; - s &= 15; - - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - /* Output coefficient in natural (dezigzagged) order. - * Note: the extra entries in jpeg_natural_order[] will save us - * if k >= DCTSIZE2, which could happen if the data is corrupted. - */ - (*block)[jpeg_natural_order[k]] = (JCOEF) s; - } else { - if (r != 15) - break; - k += 15; - } - } - - } else { - - /* Section F.2.2.2: decode the AC coefficients */ - /* In this path we just discard the values */ - for (k = 1; k < DCTSIZE2; k++) { - HUFF_DECODE(s, br_state, actbl, return FALSE, label3); - - r = s >> 4; - s &= 15; - - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - DROP_BITS(s); - } else { - if (r != 15) - break; - k += 15; - } - } - - } - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(entropy->saved, state); - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * Module initialization routine for Huffman entropy decoding. - */ - -GLOBAL(void) -jinit_huff_decoder (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy; - int i; - - entropy = (huff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(huff_entropy_decoder)); - cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; - entropy->pub.start_pass = start_pass_huff_decoder; - entropy->pub.decode_mcu = decode_mcu; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; - } -} +/* + * jdhuff.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains Huffman entropy decoding routines. + * + * Much of the complexity here has to do with supporting input suspension. + * If the data source module demands suspension, we want to be able to back + * up to the start of the current MCU. To do this, we copy state variables + * into local working storage, and update them back to the permanent + * storage only upon successful completion of an MCU. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdhuff.h" /* Declarations shared with jdphuff.c */ + + +/* + * Expanded entropy decoder object for Huffman decoding. + * + * The savable_state subrecord contains fields that change within an MCU, + * but must not be updated permanently until we complete the MCU. + */ + +typedef struct { + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ +} savable_state; + +/* This macro is to work around compilers with missing or broken + * structure assignment. You'll need to fix this code if you have + * such a compiler and you change MAX_COMPS_IN_SCAN. + */ + +#ifndef NO_STRUCT_ASSIGN +#define ASSIGN_STATE(dest,src) ((dest) = (src)) +#else +#if MAX_COMPS_IN_SCAN == 4 +#define ASSIGN_STATE(dest,src) \ + ((dest).last_dc_val[0] = (src).last_dc_val[0], \ + (dest).last_dc_val[1] = (src).last_dc_val[1], \ + (dest).last_dc_val[2] = (src).last_dc_val[2], \ + (dest).last_dc_val[3] = (src).last_dc_val[3]) +#endif +#endif + + +typedef struct { + struct jpeg_entropy_decoder pub; /* public fields */ + + /* These fields are loaded into local variables at start of each MCU. + * In case of suspension, we exit WITHOUT updating them. + */ + bitread_perm_state bitstate; /* Bit buffer at start of MCU */ + savable_state saved; /* Other state at start of MCU */ + + /* These fields are NOT loaded into local working state. */ + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + + /* Pointers to derived tables (these workspaces have image lifespan) */ + d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; + d_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; + + /* Precalculated info set up by start_pass for use in decode_mcu: */ + + /* Pointers to derived tables to be used for each block within an MCU */ + d_derived_tbl * dc_cur_tbls[D_MAX_BLOCKS_IN_MCU]; + d_derived_tbl * ac_cur_tbls[D_MAX_BLOCKS_IN_MCU]; + /* Whether we care about the DC and AC coefficient values for each block */ + boolean dc_needed[D_MAX_BLOCKS_IN_MCU]; + boolean ac_needed[D_MAX_BLOCKS_IN_MCU]; +} huff_entropy_decoder; + +typedef huff_entropy_decoder * huff_entropy_ptr; + + +/* + * Initialize for a Huffman-compressed scan. + */ + +METHODDEF(void) +start_pass_huff_decoder (j_decompress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci, blkn, dctbl, actbl; + jpeg_component_info * compptr; + + /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG. + * This ought to be an error condition, but we make it a warning because + * there are some baseline files out there with all zeroes in these bytes. + */ + if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 || + cinfo->Ah != 0 || cinfo->Al != 0) + WARNMS(cinfo, JWRN_NOT_SEQUENTIAL); + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + dctbl = compptr->dc_tbl_no; + actbl = compptr->ac_tbl_no; + /* Compute derived values for Huffman tables */ + /* We may do this more than once for a table, but it's not expensive */ + jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl, + & entropy->dc_derived_tbls[dctbl]); + jpeg_make_d_derived_tbl(cinfo, FALSE, actbl, + & entropy->ac_derived_tbls[actbl]); + /* Initialize DC predictions to 0 */ + entropy->saved.last_dc_val[ci] = 0; + } + + /* Precalculate decoding info for each block in an MCU of this scan */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + /* Precalculate which table to use for each block */ + entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no]; + entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no]; + /* Decide whether we really care about the coefficient values */ + if (compptr->component_needed) { + entropy->dc_needed[blkn] = TRUE; + /* we don't need the ACs if producing a 1/8th-size image */ + entropy->ac_needed[blkn] = (compptr->DCT_scaled_size > 1); + } else { + entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE; + } + } + + /* Initialize bitread state variables */ + entropy->bitstate.bits_left = 0; + entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ + entropy->pub.insufficient_data = FALSE; + + /* Initialize restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; +} + + +/* + * Compute the derived values for a Huffman table. + * This routine also performs some validation checks on the table. + * + * Note this is also used by jdphuff.c. + */ + +GLOBAL(void) +jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno, + d_derived_tbl ** pdtbl) +{ + JHUFF_TBL *htbl; + d_derived_tbl *dtbl; + int p, i, l, si, numsymbols; + int lookbits, ctr; + char huffsize[257]; + unsigned int huffcode[257]; + unsigned int code; + + /* Note that huffsize[] and huffcode[] are filled in code-length order, + * paralleling the order of the symbols themselves in htbl->huffval[]. + */ + + /* Find the input Huffman table */ + if (tblno < 0 || tblno >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); + htbl = + isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; + if (htbl == NULL) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); + + /* Allocate a workspace if we haven't already done so. */ + if (*pdtbl == NULL) + *pdtbl = (d_derived_tbl *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(d_derived_tbl)); + dtbl = *pdtbl; + dtbl->pub = htbl; /* fill in back link */ + + /* Figure C.1: make table of Huffman code length for each symbol */ + + p = 0; + for (l = 1; l <= 16; l++) { + i = (int) htbl->bits[l]; + if (i < 0 || p + i > 256) /* protect against table overrun */ + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + while (i--) + huffsize[p++] = (char) l; + } + huffsize[p] = 0; + numsymbols = p; + + /* Figure C.2: generate the codes themselves */ + /* We also validate that the counts represent a legal Huffman code tree. */ + + code = 0; + si = huffsize[0]; + p = 0; + while (huffsize[p]) { + while (((int) huffsize[p]) == si) { + huffcode[p++] = code; + code++; + } + /* code is now 1 more than the last code used for codelength si; but + * it must still fit in si bits, since no code is allowed to be all ones. + */ + if (((INT32) code) >= (((INT32) 1) << si)) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + code <<= 1; + si++; + } + + /* Figure F.15: generate decoding tables for bit-sequential decoding */ + + p = 0; + for (l = 1; l <= 16; l++) { + if (htbl->bits[l]) { + /* valoffset[l] = huffval[] index of 1st symbol of code length l, + * minus the minimum code of length l + */ + dtbl->valoffset[l] = (INT32) p - (INT32) huffcode[p]; + p += htbl->bits[l]; + dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */ + } else { + dtbl->maxcode[l] = -1; /* -1 if no codes of this length */ + } + } + dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */ + + /* Compute lookahead tables to speed up decoding. + * First we set all the table entries to 0, indicating "too long"; + * then we iterate through the Huffman codes that are short enough and + * fill in all the entries that correspond to bit sequences starting + * with that code. + */ + + MEMZERO(dtbl->look_nbits, SIZEOF(dtbl->look_nbits)); + + p = 0; + for (l = 1; l <= HUFF_LOOKAHEAD; l++) { + for (i = 1; i <= (int) htbl->bits[l]; i++, p++) { + /* l = current code's length, p = its index in huffcode[] & huffval[]. */ + /* Generate left-justified code followed by all possible bit sequences */ + lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l); + for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) { + dtbl->look_nbits[lookbits] = l; + dtbl->look_sym[lookbits] = htbl->huffval[p]; + lookbits++; + } + } + } + + /* Validate symbols as being reasonable. + * For AC tables, we make no check, but accept all byte values 0..255. + * For DC tables, we require the symbols to be in range 0..15. + * (Tighter bounds could be applied depending on the data depth and mode, + * but this is sufficient to ensure safe decoding.) + */ + if (isDC) { + for (i = 0; i < numsymbols; i++) { + int sym = htbl->huffval[i]; + if (sym < 0 || sym > 15) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + } + } +} + + +/* + * Out-of-line code for bit fetching (shared with jdphuff.c). + * See jdhuff.h for info about usage. + * Note: current values of get_buffer and bits_left are passed as parameters, + * but are returned in the corresponding fields of the state struct. + * + * On most machines MIN_GET_BITS should be 25 to allow the full 32-bit width + * of get_buffer to be used. (On machines with wider words, an even larger + * buffer could be used.) However, on some machines 32-bit shifts are + * quite slow and take time proportional to the number of places shifted. + * (This is true with most PC compilers, for instance.) In this case it may + * be a win to set MIN_GET_BITS to the minimum value of 15. This reduces the + * average shift distance at the cost of more calls to jpeg_fill_bit_buffer. + */ + +#ifdef SLOW_SHIFT_32 +#define MIN_GET_BITS 15 /* minimum allowable value */ +#else +#define MIN_GET_BITS (BIT_BUF_SIZE-7) +#endif + + +GLOBAL(boolean) +jpeg_fill_bit_buffer (bitread_working_state * state, + register bit_buf_type get_buffer, register int bits_left, + int nbits) +/* Load up the bit buffer to a depth of at least nbits */ +{ + /* Copy heavily used state fields into locals (hopefully registers) */ + register const JOCTET * next_input_byte = state->next_input_byte; + register size_t bytes_in_buffer = state->bytes_in_buffer; + j_decompress_ptr cinfo = state->cinfo; + + /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */ + /* (It is assumed that no request will be for more than that many bits.) */ + /* We fail to do so only if we hit a marker or are forced to suspend. */ + + if (cinfo->unread_marker == 0) { /* cannot advance past a marker */ + while (bits_left < MIN_GET_BITS) { + register int c; + + /* Attempt to read a byte */ + if (bytes_in_buffer == 0) { + if (! (*cinfo->src->fill_input_buffer) (cinfo)) + return FALSE; + next_input_byte = cinfo->src->next_input_byte; + bytes_in_buffer = cinfo->src->bytes_in_buffer; + } + bytes_in_buffer--; + c = GETJOCTET(*next_input_byte++); + + /* If it's 0xFF, check and discard stuffed zero byte */ + if (c == 0xFF) { + /* Loop here to discard any padding FF's on terminating marker, + * so that we can save a valid unread_marker value. NOTE: we will + * accept multiple FF's followed by a 0 as meaning a single FF data + * byte. This data pattern is not valid according to the standard. + */ + do { + if (bytes_in_buffer == 0) { + if (! (*cinfo->src->fill_input_buffer) (cinfo)) + return FALSE; + next_input_byte = cinfo->src->next_input_byte; + bytes_in_buffer = cinfo->src->bytes_in_buffer; + } + bytes_in_buffer--; + c = GETJOCTET(*next_input_byte++); + } while (c == 0xFF); + + if (c == 0) { + /* Found FF/00, which represents an FF data byte */ + c = 0xFF; + } else { + /* Oops, it's actually a marker indicating end of compressed data. + * Save the marker code for later use. + * Fine point: it might appear that we should save the marker into + * bitread working state, not straight into permanent state. But + * once we have hit a marker, we cannot need to suspend within the + * current MCU, because we will read no more bytes from the data + * source. So it is OK to update permanent state right away. + */ + cinfo->unread_marker = c; + /* See if we need to insert some fake zero bits. */ + goto no_more_bytes; + } + } + + /* OK, load c into get_buffer */ + get_buffer = (get_buffer << 8) | c; + bits_left += 8; + } /* end while */ + } else { + no_more_bytes: + /* We get here if we've read the marker that terminates the compressed + * data segment. There should be enough bits in the buffer register + * to satisfy the request; if so, no problem. + */ + if (nbits > bits_left) { + /* Uh-oh. Report corrupted data to user and stuff zeroes into + * the data stream, so that we can produce some kind of image. + * We use a nonvolatile flag to ensure that only one warning message + * appears per data segment. + */ + if (! cinfo->entropy->insufficient_data) { + WARNMS(cinfo, JWRN_HIT_MARKER); + cinfo->entropy->insufficient_data = TRUE; + } + /* Fill the buffer with zero bits */ + get_buffer <<= MIN_GET_BITS - bits_left; + bits_left = MIN_GET_BITS; + } + } + + /* Unload the local registers */ + state->next_input_byte = next_input_byte; + state->bytes_in_buffer = bytes_in_buffer; + state->get_buffer = get_buffer; + state->bits_left = bits_left; + + return TRUE; +} + + +/* + * Out-of-line code for Huffman code decoding. + * See jdhuff.h for info about usage. + */ + +GLOBAL(int) +jpeg_huff_decode (bitread_working_state * state, + register bit_buf_type get_buffer, register int bits_left, + d_derived_tbl * htbl, int min_bits) +{ + register int l = min_bits; + register INT32 code; + + /* HUFF_DECODE has determined that the code is at least min_bits */ + /* bits long, so fetch that many bits in one swoop. */ + + CHECK_BIT_BUFFER(*state, l, return -1); + code = GET_BITS(l); + + /* Collect the rest of the Huffman code one bit at a time. */ + /* This is per Figure F.16 in the JPEG spec. */ + + while (code > htbl->maxcode[l]) { + code <<= 1; + CHECK_BIT_BUFFER(*state, 1, return -1); + code |= GET_BITS(1); + l++; + } + + /* Unload the local registers */ + state->get_buffer = get_buffer; + state->bits_left = bits_left; + + /* With garbage input we may reach the sentinel value l = 17. */ + + if (l > 16) { + WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE); + return 0; /* fake a zero as the safest result */ + } + + return htbl->pub->huffval[ (int) (code + htbl->valoffset[l]) ]; +} + + +/* + * Figure F.12: extend sign bit. + * On some machines, a shift and add will be faster than a table lookup. + */ + +#ifdef AVOID_TABLES + +#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) + +#else + +#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) + +static const int extend_test[16] = /* entry n is 2**(n-1) */ + { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, + 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; + +static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ + { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, + ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, + ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, + ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; + +#endif /* AVOID_TABLES */ + + +/* + * Check for a restart marker & resynchronize decoder. + * Returns FALSE if must suspend. + */ + +LOCAL(boolean) +process_restart (j_decompress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci; + + /* Throw away any unused bits remaining in bit buffer; */ + /* include any full bytes in next_marker's count of discarded bytes */ + cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; + entropy->bitstate.bits_left = 0; + + /* Advance past the RSTn marker */ + if (! (*cinfo->marker->read_restart_marker) (cinfo)) + return FALSE; + + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) + entropy->saved.last_dc_val[ci] = 0; + + /* Reset restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; + + /* Reset out-of-data flag, unless read_restart_marker left us smack up + * against a marker. In that case we will end up treating the next data + * segment as empty, and we can avoid producing bogus output pixels by + * leaving the flag set. + */ + if (cinfo->unread_marker == 0) + entropy->pub.insufficient_data = FALSE; + + return TRUE; +} + + +/* + * Decode and return one MCU's worth of Huffman-compressed coefficients. + * The coefficients are reordered from zigzag order into natural array order, + * but are not dequantized. + * + * The i'th block of the MCU is stored into the block pointed to by + * MCU_data[i]. WE ASSUME THIS AREA HAS BEEN ZEROED BY THE CALLER. + * (Wholesale zeroing is usually a little faster than retail...) + * + * Returns FALSE if data source requested suspension. In that case no + * changes have been made to permanent state. (Exception: some output + * coefficients may already have been assigned. This is harmless for + * this module, since we'll just re-assign them on the next call.) + */ + +METHODDEF(boolean) +decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int blkn; + BITREAD_STATE_VARS; + savable_state state; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* If we've run out of data, just leave the MCU set to zeroes. + * This way, we return uniform gray for the remainder of the segment. + */ + if (! entropy->pub.insufficient_data) { + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + ASSIGN_STATE(state, entropy->saved); + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + JBLOCKROW block = MCU_data[blkn]; + d_derived_tbl * dctbl = entropy->dc_cur_tbls[blkn]; + d_derived_tbl * actbl = entropy->ac_cur_tbls[blkn]; + register int s, k, r; + + /* Decode a single block's worth of coefficients */ + + /* Section F.2.2.1: decode the DC coefficient difference */ + HUFF_DECODE(s, br_state, dctbl, return FALSE, label1); + if (s) { + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + } + + if (entropy->dc_needed[blkn]) { + /* Convert DC difference to actual value, update last_dc_val */ + int ci = cinfo->MCU_membership[blkn]; + s += state.last_dc_val[ci]; + state.last_dc_val[ci] = s; + /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */ + (*block)[0] = (JCOEF) s; + } + + if (entropy->ac_needed[blkn]) { + + /* Section F.2.2.2: decode the AC coefficients */ + /* Since zeroes are skipped, output area must be cleared beforehand */ + for (k = 1; k < DCTSIZE2; k++) { + HUFF_DECODE(s, br_state, actbl, return FALSE, label2); + + r = s >> 4; + s &= 15; + + if (s) { + k += r; + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + /* Output coefficient in natural (dezigzagged) order. + * Note: the extra entries in jpeg_natural_order[] will save us + * if k >= DCTSIZE2, which could happen if the data is corrupted. + */ + (*block)[jpeg_natural_order[k]] = (JCOEF) s; + } else { + if (r != 15) + break; + k += 15; + } + } + + } else { + + /* Section F.2.2.2: decode the AC coefficients */ + /* In this path we just discard the values */ + for (k = 1; k < DCTSIZE2; k++) { + HUFF_DECODE(s, br_state, actbl, return FALSE, label3); + + r = s >> 4; + s &= 15; + + if (s) { + k += r; + CHECK_BIT_BUFFER(br_state, s, return FALSE); + DROP_BITS(s); + } else { + if (r != 15) + break; + k += 15; + } + } + + } + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + ASSIGN_STATE(entropy->saved, state); + } + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * Module initialization routine for Huffman entropy decoding. + */ + +GLOBAL(void) +jinit_huff_decoder (j_decompress_ptr cinfo) +{ + huff_entropy_ptr entropy; + int i; + + entropy = (huff_entropy_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(huff_entropy_decoder)); + cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; + entropy->pub.start_pass = start_pass_huff_decoder; + entropy->pub.decode_mcu = decode_mcu; + + /* Mark tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; + } +} diff --git a/src/dep/src/irrlicht/jpeglib/jdhuff.h b/src/dep/src/irrlicht/jpeglib/jdhuff.h index 12c0747..ae19b6c 100644 --- a/src/dep/src/irrlicht/jpeglib/jdhuff.h +++ b/src/dep/src/irrlicht/jpeglib/jdhuff.h @@ -1,201 +1,201 @@ -/* - * jdhuff.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for Huffman entropy decoding routines - * that are shared between the sequential decoder (jdhuff.c) and the - * progressive decoder (jdphuff.c). No other modules need to see these. - */ - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_make_d_derived_tbl jMkDDerived -#define jpeg_fill_bit_buffer jFilBitBuf -#define jpeg_huff_decode jHufDecode -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Derived data constructed for each Huffman table */ - -#define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */ - -typedef struct { - /* Basic tables: (element [0] of each array is unused) */ - INT32 maxcode[18]; /* largest code of length k (-1 if none) */ - /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */ - INT32 valoffset[17]; /* huffval[] offset for codes of length k */ - /* valoffset[k] = huffval[] index of 1st symbol of code length k, less - * the smallest code of length k; so given a code of length k, the - * corresponding symbol is huffval[code + valoffset[k]] - */ - - /* Link to public Huffman table (needed only in jpeg_huff_decode) */ - JHUFF_TBL *pub; - - /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of - * the input data stream. If the next Huffman code is no more - * than HUFF_LOOKAHEAD bits long, we can obtain its length and - * the corresponding symbol directly from these tables. - */ - int look_nbits[1< 32 bits on your machine, and shifting/masking longs is - * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE - * appropriately should be a win. Unfortunately we can't define the size - * with something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8) - * because not all machines measure sizeof in 8-bit bytes. - */ - -typedef struct { /* Bitreading state saved across MCUs */ - bit_buf_type get_buffer; /* current bit-extraction buffer */ - int bits_left; /* # of unused bits in it */ -} bitread_perm_state; - -typedef struct { /* Bitreading working state within an MCU */ - /* Current data source location */ - /* We need a copy, rather than munging the original, in case of suspension */ - const JOCTET * next_input_byte; /* => next byte to read from source */ - size_t bytes_in_buffer; /* # of bytes remaining in source buffer */ - /* Bit input buffer --- note these values are kept in register variables, - * not in this struct, inside the inner loops. - */ - bit_buf_type get_buffer; /* current bit-extraction buffer */ - int bits_left; /* # of unused bits in it */ - /* Pointer needed by jpeg_fill_bit_buffer. */ - j_decompress_ptr cinfo; /* back link to decompress master record */ -} bitread_working_state; - -/* Macros to declare and load/save bitread local variables. */ -#define BITREAD_STATE_VARS \ - register bit_buf_type get_buffer; \ - register int bits_left; \ - bitread_working_state br_state - -#define BITREAD_LOAD_STATE(cinfop,permstate) \ - br_state.cinfo = cinfop; \ - br_state.next_input_byte = cinfop->src->next_input_byte; \ - br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \ - get_buffer = permstate.get_buffer; \ - bits_left = permstate.bits_left; - -#define BITREAD_SAVE_STATE(cinfop,permstate) \ - cinfop->src->next_input_byte = br_state.next_input_byte; \ - cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \ - permstate.get_buffer = get_buffer; \ - permstate.bits_left = bits_left - -/* - * These macros provide the in-line portion of bit fetching. - * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer - * before using GET_BITS, PEEK_BITS, or DROP_BITS. - * The variables get_buffer and bits_left are assumed to be locals, - * but the state struct might not be (jpeg_huff_decode needs this). - * CHECK_BIT_BUFFER(state,n,action); - * Ensure there are N bits in get_buffer; if suspend, take action. - * val = GET_BITS(n); - * Fetch next N bits. - * val = PEEK_BITS(n); - * Fetch next N bits without removing them from the buffer. - * DROP_BITS(n); - * Discard next N bits. - * The value N should be a simple variable, not an expression, because it - * is evaluated multiple times. - */ - -#define CHECK_BIT_BUFFER(state,nbits,action) \ - { if (bits_left < (nbits)) { \ - if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \ - { action; } \ - get_buffer = (state).get_buffer; bits_left = (state).bits_left; } } - -#define GET_BITS(nbits) \ - (((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1)) - -#define PEEK_BITS(nbits) \ - (((int) (get_buffer >> (bits_left - (nbits)))) & ((1<<(nbits))-1)) - -#define DROP_BITS(nbits) \ - (bits_left -= (nbits)) - -/* Load up the bit buffer to a depth of at least nbits */ -EXTERN(boolean) jpeg_fill_bit_buffer - JPP((bitread_working_state * state, register bit_buf_type get_buffer, - register int bits_left, int nbits)); - - -/* - * Code for extracting next Huffman-coded symbol from input bit stream. - * Again, this is time-critical and we make the main paths be macros. - * - * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits - * without looping. Usually, more than 95% of the Huffman codes will be 8 - * or fewer bits long. The few overlength codes are handled with a loop, - * which need not be inline code. - * - * Notes about the HUFF_DECODE macro: - * 1. Near the end of the data segment, we may fail to get enough bits - * for a lookahead. In that case, we do it the hard way. - * 2. If the lookahead table contains no entry, the next code must be - * more than HUFF_LOOKAHEAD bits long. - * 3. jpeg_huff_decode returns -1 if forced to suspend. - */ - -#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \ -{ register int nb, look; \ - if (bits_left < HUFF_LOOKAHEAD) { \ - if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \ - get_buffer = state.get_buffer; bits_left = state.bits_left; \ - if (bits_left < HUFF_LOOKAHEAD) { \ - nb = 1; goto slowlabel; \ - } \ - } \ - look = PEEK_BITS(HUFF_LOOKAHEAD); \ - if ((nb = htbl->look_nbits[look]) != 0) { \ - DROP_BITS(nb); \ - result = htbl->look_sym[look]; \ - } else { \ - nb = HUFF_LOOKAHEAD+1; \ -slowlabel: \ - if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \ - { failaction; } \ - get_buffer = state.get_buffer; bits_left = state.bits_left; \ - } \ -} - -/* Out-of-line case for Huffman code fetching */ -EXTERN(int) jpeg_huff_decode - JPP((bitread_working_state * state, register bit_buf_type get_buffer, - register int bits_left, d_derived_tbl * htbl, int min_bits)); +/* + * jdhuff.h + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains declarations for Huffman entropy decoding routines + * that are shared between the sequential decoder (jdhuff.c) and the + * progressive decoder (jdphuff.c). No other modules need to see these. + */ + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_make_d_derived_tbl jMkDDerived +#define jpeg_fill_bit_buffer jFilBitBuf +#define jpeg_huff_decode jHufDecode +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* Derived data constructed for each Huffman table */ + +#define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */ + +typedef struct { + /* Basic tables: (element [0] of each array is unused) */ + INT32 maxcode[18]; /* largest code of length k (-1 if none) */ + /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */ + INT32 valoffset[17]; /* huffval[] offset for codes of length k */ + /* valoffset[k] = huffval[] index of 1st symbol of code length k, less + * the smallest code of length k; so given a code of length k, the + * corresponding symbol is huffval[code + valoffset[k]] + */ + + /* Link to public Huffman table (needed only in jpeg_huff_decode) */ + JHUFF_TBL *pub; + + /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of + * the input data stream. If the next Huffman code is no more + * than HUFF_LOOKAHEAD bits long, we can obtain its length and + * the corresponding symbol directly from these tables. + */ + int look_nbits[1< 32 bits on your machine, and shifting/masking longs is + * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE + * appropriately should be a win. Unfortunately we can't define the size + * with something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8) + * because not all machines measure sizeof in 8-bit bytes. + */ + +typedef struct { /* Bitreading state saved across MCUs */ + bit_buf_type get_buffer; /* current bit-extraction buffer */ + int bits_left; /* # of unused bits in it */ +} bitread_perm_state; + +typedef struct { /* Bitreading working state within an MCU */ + /* Current data source location */ + /* We need a copy, rather than munging the original, in case of suspension */ + const JOCTET * next_input_byte; /* => next byte to read from source */ + size_t bytes_in_buffer; /* # of bytes remaining in source buffer */ + /* Bit input buffer --- note these values are kept in register variables, + * not in this struct, inside the inner loops. + */ + bit_buf_type get_buffer; /* current bit-extraction buffer */ + int bits_left; /* # of unused bits in it */ + /* Pointer needed by jpeg_fill_bit_buffer. */ + j_decompress_ptr cinfo; /* back link to decompress master record */ +} bitread_working_state; + +/* Macros to declare and load/save bitread local variables. */ +#define BITREAD_STATE_VARS \ + register bit_buf_type get_buffer; \ + register int bits_left; \ + bitread_working_state br_state + +#define BITREAD_LOAD_STATE(cinfop,permstate) \ + br_state.cinfo = cinfop; \ + br_state.next_input_byte = cinfop->src->next_input_byte; \ + br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \ + get_buffer = permstate.get_buffer; \ + bits_left = permstate.bits_left; + +#define BITREAD_SAVE_STATE(cinfop,permstate) \ + cinfop->src->next_input_byte = br_state.next_input_byte; \ + cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \ + permstate.get_buffer = get_buffer; \ + permstate.bits_left = bits_left + +/* + * These macros provide the in-line portion of bit fetching. + * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer + * before using GET_BITS, PEEK_BITS, or DROP_BITS. + * The variables get_buffer and bits_left are assumed to be locals, + * but the state struct might not be (jpeg_huff_decode needs this). + * CHECK_BIT_BUFFER(state,n,action); + * Ensure there are N bits in get_buffer; if suspend, take action. + * val = GET_BITS(n); + * Fetch next N bits. + * val = PEEK_BITS(n); + * Fetch next N bits without removing them from the buffer. + * DROP_BITS(n); + * Discard next N bits. + * The value N should be a simple variable, not an expression, because it + * is evaluated multiple times. + */ + +#define CHECK_BIT_BUFFER(state,nbits,action) \ + { if (bits_left < (nbits)) { \ + if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \ + { action; } \ + get_buffer = (state).get_buffer; bits_left = (state).bits_left; } } + +#define GET_BITS(nbits) \ + (((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1)) + +#define PEEK_BITS(nbits) \ + (((int) (get_buffer >> (bits_left - (nbits)))) & ((1<<(nbits))-1)) + +#define DROP_BITS(nbits) \ + (bits_left -= (nbits)) + +/* Load up the bit buffer to a depth of at least nbits */ +EXTERN(boolean) jpeg_fill_bit_buffer + JPP((bitread_working_state * state, register bit_buf_type get_buffer, + register int bits_left, int nbits)); + + +/* + * Code for extracting next Huffman-coded symbol from input bit stream. + * Again, this is time-critical and we make the main paths be macros. + * + * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits + * without looping. Usually, more than 95% of the Huffman codes will be 8 + * or fewer bits long. The few overlength codes are handled with a loop, + * which need not be inline code. + * + * Notes about the HUFF_DECODE macro: + * 1. Near the end of the data segment, we may fail to get enough bits + * for a lookahead. In that case, we do it the hard way. + * 2. If the lookahead table contains no entry, the next code must be + * more than HUFF_LOOKAHEAD bits long. + * 3. jpeg_huff_decode returns -1 if forced to suspend. + */ + +#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \ +{ register int nb, look; \ + if (bits_left < HUFF_LOOKAHEAD) { \ + if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \ + get_buffer = state.get_buffer; bits_left = state.bits_left; \ + if (bits_left < HUFF_LOOKAHEAD) { \ + nb = 1; goto slowlabel; \ + } \ + } \ + look = PEEK_BITS(HUFF_LOOKAHEAD); \ + if ((nb = htbl->look_nbits[look]) != 0) { \ + DROP_BITS(nb); \ + result = htbl->look_sym[look]; \ + } else { \ + nb = HUFF_LOOKAHEAD+1; \ +slowlabel: \ + if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \ + { failaction; } \ + get_buffer = state.get_buffer; bits_left = state.bits_left; \ + } \ +} + +/* Out-of-line case for Huffman code fetching */ +EXTERN(int) jpeg_huff_decode + JPP((bitread_working_state * state, register bit_buf_type get_buffer, + register int bits_left, d_derived_tbl * htbl, int min_bits)); diff --git a/src/dep/src/irrlicht/jpeglib/jdinput.c b/src/dep/src/irrlicht/jpeglib/jdinput.c index 2d5c747..0c2ac8f 100644 --- a/src/dep/src/irrlicht/jpeglib/jdinput.c +++ b/src/dep/src/irrlicht/jpeglib/jdinput.c @@ -1,381 +1,381 @@ -/* - * jdinput.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains input control logic for the JPEG decompressor. - * These routines are concerned with controlling the decompressor's input - * processing (marker reading and coefficient decoding). The actual input - * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef struct { - struct jpeg_input_controller pub; /* public fields */ - - boolean inheaders; /* TRUE until first SOS is reached */ -} my_input_controller; - -typedef my_input_controller * my_inputctl_ptr; - - -/* Forward declarations */ -METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo)); - - -/* - * Routines to calculate various quantities related to the size of the image. - */ - -LOCAL(void) -initial_setup (j_decompress_ptr cinfo) -/* Called once, when first SOS marker is reached */ -{ - int ci; - jpeg_component_info *compptr; - - /* Make sure image isn't bigger than I can handle */ - if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || - (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); - - /* For now, precision must match compiled-in value... */ - if (cinfo->data_precision != BITS_IN_JSAMPLE) - ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); - - /* Check that number of components won't exceed internal array sizes */ - if (cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - - /* Compute maximum sampling factors; check factor validity */ - cinfo->max_h_samp_factor = 1; - cinfo->max_v_samp_factor = 1; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || - compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) - ERREXIT(cinfo, JERR_BAD_SAMPLING); - cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, - compptr->h_samp_factor); - cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, - compptr->v_samp_factor); - } - - /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE. - * In the full decompressor, this will be overridden by jdmaster.c; - * but in the transcoder, jdmaster.c is not used, so we must do it here. - */ - cinfo->min_DCT_scaled_size = DCTSIZE; - - /* Compute dimensions of components */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - compptr->DCT_scaled_size = DCTSIZE; - /* Size in DCT blocks */ - compptr->width_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->height_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - /* downsampled_width and downsampled_height will also be overridden by - * jdmaster.c if we are doing full decompression. The transcoder library - * doesn't use these values, but the calling application might. - */ - /* Size in samples */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) cinfo->max_h_samp_factor); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) cinfo->max_v_samp_factor); - /* Mark component needed, until color conversion says otherwise */ - compptr->component_needed = TRUE; - /* Mark no quantization table yet saved for component */ - compptr->quant_table = NULL; - } - - /* Compute number of fully interleaved MCU rows. */ - cinfo->total_iMCU_rows = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - /* Decide whether file contains multiple scans */ - if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode) - cinfo->inputctl->has_multiple_scans = TRUE; - else - cinfo->inputctl->has_multiple_scans = FALSE; -} - - -LOCAL(void) -per_scan_setup (j_decompress_ptr cinfo) -/* Do computations that are needed before processing a JPEG scan */ -/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */ -{ - int ci, mcublks, tmp; - jpeg_component_info *compptr; - - if (cinfo->comps_in_scan == 1) { - - /* Noninterleaved (single-component) scan */ - compptr = cinfo->cur_comp_info[0]; - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = compptr->width_in_blocks; - cinfo->MCU_rows_in_scan = compptr->height_in_blocks; - - /* For noninterleaved scan, always one block per MCU */ - compptr->MCU_width = 1; - compptr->MCU_height = 1; - compptr->MCU_blocks = 1; - compptr->MCU_sample_width = compptr->DCT_scaled_size; - compptr->last_col_width = 1; - /* For noninterleaved scans, it is convenient to define last_row_height - * as the number of block rows present in the last iMCU row. - */ - tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (tmp == 0) tmp = compptr->v_samp_factor; - compptr->last_row_height = tmp; - - /* Prepare array describing MCU composition */ - cinfo->blocks_in_MCU = 1; - cinfo->MCU_membership[0] = 0; - - } else { - - /* Interleaved (multi-component) scan */ - if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, - MAX_COMPS_IN_SCAN); - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, - (long) (cinfo->max_h_samp_factor*DCTSIZE)); - cinfo->MCU_rows_in_scan = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - cinfo->blocks_in_MCU = 0; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Sampling factors give # of blocks of component in each MCU */ - compptr->MCU_width = compptr->h_samp_factor; - compptr->MCU_height = compptr->v_samp_factor; - compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; - compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size; - /* Figure number of non-dummy blocks in last MCU column & row */ - tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); - if (tmp == 0) tmp = compptr->MCU_width; - compptr->last_col_width = tmp; - tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); - if (tmp == 0) tmp = compptr->MCU_height; - compptr->last_row_height = tmp; - /* Prepare array describing MCU composition */ - mcublks = compptr->MCU_blocks; - if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU) - ERREXIT(cinfo, JERR_BAD_MCU_SIZE); - while (mcublks-- > 0) { - cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; - } - } - - } -} - - -/* - * Save away a copy of the Q-table referenced by each component present - * in the current scan, unless already saved during a prior scan. - * - * In a multiple-scan JPEG file, the encoder could assign different components - * the same Q-table slot number, but change table definitions between scans - * so that each component uses a different Q-table. (The IJG encoder is not - * currently capable of doing this, but other encoders might.) Since we want - * to be able to dequantize all the components at the end of the file, this - * means that we have to save away the table actually used for each component. - * We do this by copying the table at the start of the first scan containing - * the component. - * The JPEG spec prohibits the encoder from changing the contents of a Q-table - * slot between scans of a component using that slot. If the encoder does so - * anyway, this decoder will simply use the Q-table values that were current - * at the start of the first scan for the component. - * - * The decompressor output side looks only at the saved quant tables, - * not at the current Q-table slots. - */ - -LOCAL(void) -latch_quant_tables (j_decompress_ptr cinfo) -{ - int ci, qtblno; - jpeg_component_info *compptr; - JQUANT_TBL * qtbl; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* No work if we already saved Q-table for this component */ - if (compptr->quant_table != NULL) - continue; - /* Make sure specified quantization table is present */ - qtblno = compptr->quant_tbl_no; - if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || - cinfo->quant_tbl_ptrs[qtblno] == NULL) - ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); - /* OK, save away the quantization table */ - qtbl = (JQUANT_TBL *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(JQUANT_TBL)); - MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL)); - compptr->quant_table = qtbl; - } -} - - -/* - * Initialize the input modules to read a scan of compressed data. - * The first call to this is done by jdmaster.c after initializing - * the entire decompressor (during jpeg_start_decompress). - * Subsequent calls come from consume_markers, below. - */ - -METHODDEF(void) -start_input_pass (j_decompress_ptr cinfo) -{ - per_scan_setup(cinfo); - latch_quant_tables(cinfo); - (*cinfo->entropy->start_pass) (cinfo); - (*cinfo->coef->start_input_pass) (cinfo); - cinfo->inputctl->consume_input = cinfo->coef->consume_data; -} - - -/* - * Finish up after inputting a compressed-data scan. - * This is called by the coefficient controller after it's read all - * the expected data of the scan. - */ - -METHODDEF(void) -finish_input_pass (j_decompress_ptr cinfo) -{ - cinfo->inputctl->consume_input = consume_markers; -} - - -/* - * Read JPEG markers before, between, or after compressed-data scans. - * Change state as necessary when a new scan is reached. - * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - * - * The consume_input method pointer points either here or to the - * coefficient controller's consume_data routine, depending on whether - * we are reading a compressed data segment or inter-segment markers. - */ - -METHODDEF(int) -consume_markers (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; - int val; - - if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */ - return JPEG_REACHED_EOI; - - val = (*cinfo->marker->read_markers) (cinfo); - - switch (val) { - case JPEG_REACHED_SOS: /* Found SOS */ - if (inputctl->inheaders) { /* 1st SOS */ - initial_setup(cinfo); - inputctl->inheaders = FALSE; - /* Note: start_input_pass must be called by jdmaster.c - * before any more input can be consumed. jdapimin.c is - * responsible for enforcing this sequencing. - */ - } else { /* 2nd or later SOS marker */ - if (! inputctl->pub.has_multiple_scans) - ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */ - start_input_pass(cinfo); - } - break; - case JPEG_REACHED_EOI: /* Found EOI */ - inputctl->pub.eoi_reached = TRUE; - if (inputctl->inheaders) { /* Tables-only datastream, apparently */ - if (cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOF_NO_SOS); - } else { - /* Prevent infinite loop in coef ctlr's decompress_data routine - * if user set output_scan_number larger than number of scans. - */ - if (cinfo->output_scan_number > cinfo->input_scan_number) - cinfo->output_scan_number = cinfo->input_scan_number; - } - break; - case JPEG_SUSPENDED: - break; - } - - return val; -} - - -/* - * Reset state to begin a fresh datastream. - */ - -METHODDEF(void) -reset_input_controller (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; - - inputctl->pub.consume_input = consume_markers; - inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ - inputctl->pub.eoi_reached = FALSE; - inputctl->inheaders = TRUE; - /* Reset other modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->marker->reset_marker_reader) (cinfo); - /* Reset progression state -- would be cleaner if entropy decoder did this */ - cinfo->coef_bits = NULL; -} - - -/* - * Initialize the input controller module. - * This is called only once, when the decompression object is created. - */ - -GLOBAL(void) -jinit_input_controller (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl; - - /* Create subobject in permanent pool */ - inputctl = (my_inputctl_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_input_controller)); - cinfo->inputctl = (struct jpeg_input_controller *) inputctl; - /* Initialize method pointers */ - inputctl->pub.consume_input = consume_markers; - inputctl->pub.reset_input_controller = reset_input_controller; - inputctl->pub.start_input_pass = start_input_pass; - inputctl->pub.finish_input_pass = finish_input_pass; - /* Initialize state: can't use reset_input_controller since we don't - * want to try to reset other modules yet. - */ - inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ - inputctl->pub.eoi_reached = FALSE; - inputctl->inheaders = TRUE; -} +/* + * jdinput.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains input control logic for the JPEG decompressor. + * These routines are concerned with controlling the decompressor's input + * processing (marker reading and coefficient decoding). The actual input + * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private state */ + +typedef struct { + struct jpeg_input_controller pub; /* public fields */ + + boolean inheaders; /* TRUE until first SOS is reached */ +} my_input_controller; + +typedef my_input_controller * my_inputctl_ptr; + + +/* Forward declarations */ +METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo)); + + +/* + * Routines to calculate various quantities related to the size of the image. + */ + +LOCAL(void) +initial_setup (j_decompress_ptr cinfo) +/* Called once, when first SOS marker is reached */ +{ + int ci; + jpeg_component_info *compptr; + + /* Make sure image isn't bigger than I can handle */ + if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || + (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) + ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); + + /* For now, precision must match compiled-in value... */ + if (cinfo->data_precision != BITS_IN_JSAMPLE) + ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); + + /* Check that number of components won't exceed internal array sizes */ + if (cinfo->num_components > MAX_COMPONENTS) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPONENTS); + + /* Compute maximum sampling factors; check factor validity */ + cinfo->max_h_samp_factor = 1; + cinfo->max_v_samp_factor = 1; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || + compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) + ERREXIT(cinfo, JERR_BAD_SAMPLING); + cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, + compptr->h_samp_factor); + cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, + compptr->v_samp_factor); + } + + /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE. + * In the full decompressor, this will be overridden by jdmaster.c; + * but in the transcoder, jdmaster.c is not used, so we must do it here. + */ + cinfo->min_DCT_scaled_size = DCTSIZE; + + /* Compute dimensions of components */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + compptr->DCT_scaled_size = DCTSIZE; + /* Size in DCT blocks */ + compptr->width_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, + (long) (cinfo->max_h_samp_factor * DCTSIZE)); + compptr->height_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, + (long) (cinfo->max_v_samp_factor * DCTSIZE)); + /* downsampled_width and downsampled_height will also be overridden by + * jdmaster.c if we are doing full decompression. The transcoder library + * doesn't use these values, but the calling application might. + */ + /* Size in samples */ + compptr->downsampled_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, + (long) cinfo->max_h_samp_factor); + compptr->downsampled_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, + (long) cinfo->max_v_samp_factor); + /* Mark component needed, until color conversion says otherwise */ + compptr->component_needed = TRUE; + /* Mark no quantization table yet saved for component */ + compptr->quant_table = NULL; + } + + /* Compute number of fully interleaved MCU rows. */ + cinfo->total_iMCU_rows = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, + (long) (cinfo->max_v_samp_factor*DCTSIZE)); + + /* Decide whether file contains multiple scans */ + if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode) + cinfo->inputctl->has_multiple_scans = TRUE; + else + cinfo->inputctl->has_multiple_scans = FALSE; +} + + +LOCAL(void) +per_scan_setup (j_decompress_ptr cinfo) +/* Do computations that are needed before processing a JPEG scan */ +/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */ +{ + int ci, mcublks, tmp; + jpeg_component_info *compptr; + + if (cinfo->comps_in_scan == 1) { + + /* Noninterleaved (single-component) scan */ + compptr = cinfo->cur_comp_info[0]; + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = compptr->width_in_blocks; + cinfo->MCU_rows_in_scan = compptr->height_in_blocks; + + /* For noninterleaved scan, always one block per MCU */ + compptr->MCU_width = 1; + compptr->MCU_height = 1; + compptr->MCU_blocks = 1; + compptr->MCU_sample_width = compptr->DCT_scaled_size; + compptr->last_col_width = 1; + /* For noninterleaved scans, it is convenient to define last_row_height + * as the number of block rows present in the last iMCU row. + */ + tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (tmp == 0) tmp = compptr->v_samp_factor; + compptr->last_row_height = tmp; + + /* Prepare array describing MCU composition */ + cinfo->blocks_in_MCU = 1; + cinfo->MCU_membership[0] = 0; + + } else { + + /* Interleaved (multi-component) scan */ + if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, + MAX_COMPS_IN_SCAN); + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, + (long) (cinfo->max_h_samp_factor*DCTSIZE)); + cinfo->MCU_rows_in_scan = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, + (long) (cinfo->max_v_samp_factor*DCTSIZE)); + + cinfo->blocks_in_MCU = 0; + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Sampling factors give # of blocks of component in each MCU */ + compptr->MCU_width = compptr->h_samp_factor; + compptr->MCU_height = compptr->v_samp_factor; + compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; + compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size; + /* Figure number of non-dummy blocks in last MCU column & row */ + tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); + if (tmp == 0) tmp = compptr->MCU_width; + compptr->last_col_width = tmp; + tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); + if (tmp == 0) tmp = compptr->MCU_height; + compptr->last_row_height = tmp; + /* Prepare array describing MCU composition */ + mcublks = compptr->MCU_blocks; + if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU) + ERREXIT(cinfo, JERR_BAD_MCU_SIZE); + while (mcublks-- > 0) { + cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; + } + } + + } +} + + +/* + * Save away a copy of the Q-table referenced by each component present + * in the current scan, unless already saved during a prior scan. + * + * In a multiple-scan JPEG file, the encoder could assign different components + * the same Q-table slot number, but change table definitions between scans + * so that each component uses a different Q-table. (The IJG encoder is not + * currently capable of doing this, but other encoders might.) Since we want + * to be able to dequantize all the components at the end of the file, this + * means that we have to save away the table actually used for each component. + * We do this by copying the table at the start of the first scan containing + * the component. + * The JPEG spec prohibits the encoder from changing the contents of a Q-table + * slot between scans of a component using that slot. If the encoder does so + * anyway, this decoder will simply use the Q-table values that were current + * at the start of the first scan for the component. + * + * The decompressor output side looks only at the saved quant tables, + * not at the current Q-table slots. + */ + +LOCAL(void) +latch_quant_tables (j_decompress_ptr cinfo) +{ + int ci, qtblno; + jpeg_component_info *compptr; + JQUANT_TBL * qtbl; + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* No work if we already saved Q-table for this component */ + if (compptr->quant_table != NULL) + continue; + /* Make sure specified quantization table is present */ + qtblno = compptr->quant_tbl_no; + if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || + cinfo->quant_tbl_ptrs[qtblno] == NULL) + ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); + /* OK, save away the quantization table */ + qtbl = (JQUANT_TBL *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(JQUANT_TBL)); + MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL)); + compptr->quant_table = qtbl; + } +} + + +/* + * Initialize the input modules to read a scan of compressed data. + * The first call to this is done by jdmaster.c after initializing + * the entire decompressor (during jpeg_start_decompress). + * Subsequent calls come from consume_markers, below. + */ + +METHODDEF(void) +start_input_pass (j_decompress_ptr cinfo) +{ + per_scan_setup(cinfo); + latch_quant_tables(cinfo); + (*cinfo->entropy->start_pass) (cinfo); + (*cinfo->coef->start_input_pass) (cinfo); + cinfo->inputctl->consume_input = cinfo->coef->consume_data; +} + + +/* + * Finish up after inputting a compressed-data scan. + * This is called by the coefficient controller after it's read all + * the expected data of the scan. + */ + +METHODDEF(void) +finish_input_pass (j_decompress_ptr cinfo) +{ + cinfo->inputctl->consume_input = consume_markers; +} + + +/* + * Read JPEG markers before, between, or after compressed-data scans. + * Change state as necessary when a new scan is reached. + * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. + * + * The consume_input method pointer points either here or to the + * coefficient controller's consume_data routine, depending on whether + * we are reading a compressed data segment or inter-segment markers. + */ + +METHODDEF(int) +consume_markers (j_decompress_ptr cinfo) +{ + my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; + int val; + + if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */ + return JPEG_REACHED_EOI; + + val = (*cinfo->marker->read_markers) (cinfo); + + switch (val) { + case JPEG_REACHED_SOS: /* Found SOS */ + if (inputctl->inheaders) { /* 1st SOS */ + initial_setup(cinfo); + inputctl->inheaders = FALSE; + /* Note: start_input_pass must be called by jdmaster.c + * before any more input can be consumed. jdapimin.c is + * responsible for enforcing this sequencing. + */ + } else { /* 2nd or later SOS marker */ + if (! inputctl->pub.has_multiple_scans) + ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */ + start_input_pass(cinfo); + } + break; + case JPEG_REACHED_EOI: /* Found EOI */ + inputctl->pub.eoi_reached = TRUE; + if (inputctl->inheaders) { /* Tables-only datastream, apparently */ + if (cinfo->marker->saw_SOF) + ERREXIT(cinfo, JERR_SOF_NO_SOS); + } else { + /* Prevent infinite loop in coef ctlr's decompress_data routine + * if user set output_scan_number larger than number of scans. + */ + if (cinfo->output_scan_number > cinfo->input_scan_number) + cinfo->output_scan_number = cinfo->input_scan_number; + } + break; + case JPEG_SUSPENDED: + break; + } + + return val; +} + + +/* + * Reset state to begin a fresh datastream. + */ + +METHODDEF(void) +reset_input_controller (j_decompress_ptr cinfo) +{ + my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; + + inputctl->pub.consume_input = consume_markers; + inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ + inputctl->pub.eoi_reached = FALSE; + inputctl->inheaders = TRUE; + /* Reset other modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->marker->reset_marker_reader) (cinfo); + /* Reset progression state -- would be cleaner if entropy decoder did this */ + cinfo->coef_bits = NULL; +} + + +/* + * Initialize the input controller module. + * This is called only once, when the decompression object is created. + */ + +GLOBAL(void) +jinit_input_controller (j_decompress_ptr cinfo) +{ + my_inputctl_ptr inputctl; + + /* Create subobject in permanent pool */ + inputctl = (my_inputctl_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + SIZEOF(my_input_controller)); + cinfo->inputctl = (struct jpeg_input_controller *) inputctl; + /* Initialize method pointers */ + inputctl->pub.consume_input = consume_markers; + inputctl->pub.reset_input_controller = reset_input_controller; + inputctl->pub.start_input_pass = start_input_pass; + inputctl->pub.finish_input_pass = finish_input_pass; + /* Initialize state: can't use reset_input_controller since we don't + * want to try to reset other modules yet. + */ + inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ + inputctl->pub.eoi_reached = FALSE; + inputctl->inheaders = TRUE; +} diff --git a/src/dep/src/irrlicht/jpeglib/jdmainct.c b/src/dep/src/irrlicht/jpeglib/jdmainct.c index 6b0f06f..13c956f 100644 --- a/src/dep/src/irrlicht/jpeglib/jdmainct.c +++ b/src/dep/src/irrlicht/jpeglib/jdmainct.c @@ -1,512 +1,512 @@ -/* - * jdmainct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the main buffer controller for decompression. - * The main buffer lies between the JPEG decompressor proper and the - * post-processor; it holds downsampled data in the JPEG colorspace. - * - * Note that this code is bypassed in raw-data mode, since the application - * supplies the equivalent of the main buffer in that case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * In the current system design, the main buffer need never be a full-image - * buffer; any full-height buffers will be found inside the coefficient or - * postprocessing controllers. Nonetheless, the main controller is not - * trivial. Its responsibility is to provide context rows for upsampling/ - * rescaling, and doing this in an efficient fashion is a bit tricky. - * - * Postprocessor input data is counted in "row groups". A row group - * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) - * sample rows of each component. (We require DCT_scaled_size values to be - * chosen such that these numbers are integers. In practice DCT_scaled_size - * values will likely be powers of two, so we actually have the stronger - * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.) - * Upsampling will typically produce max_v_samp_factor pixel rows from each - * row group (times any additional scale factor that the upsampler is - * applying). - * - * The coefficient controller will deliver data to us one iMCU row at a time; - * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or - * exactly min_DCT_scaled_size row groups. (This amount of data corresponds - * to one row of MCUs when the image is fully interleaved.) Note that the - * number of sample rows varies across components, but the number of row - * groups does not. Some garbage sample rows may be included in the last iMCU - * row at the bottom of the image. - * - * Depending on the vertical scaling algorithm used, the upsampler may need - * access to the sample row(s) above and below its current input row group. - * The upsampler is required to set need_context_rows TRUE at global selection - * time if so. When need_context_rows is FALSE, this controller can simply - * obtain one iMCU row at a time from the coefficient controller and dole it - * out as row groups to the postprocessor. - * - * When need_context_rows is TRUE, this controller guarantees that the buffer - * passed to postprocessing contains at least one row group's worth of samples - * above and below the row group(s) being processed. Note that the context - * rows "above" the first passed row group appear at negative row offsets in - * the passed buffer. At the top and bottom of the image, the required - * context rows are manufactured by duplicating the first or last real sample - * row; this avoids having special cases in the upsampling inner loops. - * - * The amount of context is fixed at one row group just because that's a - * convenient number for this controller to work with. The existing - * upsamplers really only need one sample row of context. An upsampler - * supporting arbitrary output rescaling might wish for more than one row - * group of context when shrinking the image; tough, we don't handle that. - * (This is justified by the assumption that downsizing will be handled mostly - * by adjusting the DCT_scaled_size values, so that the actual scale factor at - * the upsample step needn't be much less than one.) - * - * To provide the desired context, we have to retain the last two row groups - * of one iMCU row while reading in the next iMCU row. (The last row group - * can't be processed until we have another row group for its below-context, - * and so we have to save the next-to-last group too for its above-context.) - * We could do this most simply by copying data around in our buffer, but - * that'd be very slow. We can avoid copying any data by creating a rather - * strange pointer structure. Here's how it works. We allocate a workspace - * consisting of M+2 row groups (where M = min_DCT_scaled_size is the number - * of row groups per iMCU row). We create two sets of redundant pointers to - * the workspace. Labeling the physical row groups 0 to M+1, the synthesized - * pointer lists look like this: - * M+1 M-1 - * master pointer --> 0 master pointer --> 0 - * 1 1 - * ... ... - * M-3 M-3 - * M-2 M - * M-1 M+1 - * M M-2 - * M+1 M-1 - * 0 0 - * We read alternate iMCU rows using each master pointer; thus the last two - * row groups of the previous iMCU row remain un-overwritten in the workspace. - * The pointer lists are set up so that the required context rows appear to - * be adjacent to the proper places when we pass the pointer lists to the - * upsampler. - * - * The above pictures describe the normal state of the pointer lists. - * At top and bottom of the image, we diddle the pointer lists to duplicate - * the first or last sample row as necessary (this is cheaper than copying - * sample rows around). - * - * This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1. In that - * situation each iMCU row provides only one row group so the buffering logic - * must be different (eg, we must read two iMCU rows before we can emit the - * first row group). For now, we simply do not support providing context - * rows when min_DCT_scaled_size is 1. That combination seems unlikely to - * be worth providing --- if someone wants a 1/8th-size preview, they probably - * want it quick and dirty, so a context-free upsampler is sufficient. - */ - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_main_controller pub; /* public fields */ - - /* Pointer to allocated workspace (M or M+2 row groups). */ - JSAMPARRAY buffer[MAX_COMPONENTS]; - - boolean buffer_full; /* Have we gotten an iMCU row from decoder? */ - JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */ - - /* Remaining fields are only used in the context case. */ - - /* These are the master pointers to the funny-order pointer lists. */ - JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */ - - int whichptr; /* indicates which pointer set is now in use */ - int context_state; /* process_data state machine status */ - JDIMENSION rowgroups_avail; /* row groups available to postprocessor */ - JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */ -} my_main_controller; - -typedef my_main_controller * my_main_ptr; - -/* context_state values: */ -#define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */ -#define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */ -#define CTX_POSTPONED_ROW 2 /* feeding postponed row group */ - - -/* Forward declarations */ -METHODDEF(void) process_data_simple_main - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -METHODDEF(void) process_data_context_main - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -#ifdef QUANT_2PASS_SUPPORTED -METHODDEF(void) process_data_crank_post - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -#endif - - -LOCAL(void) -alloc_funny_pointers (j_decompress_ptr cinfo) -/* Allocate space for the funny pointer lists. - * This is done only once, not once per pass. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY xbuf; - - /* Get top-level space for component array pointers. - * We alloc both arrays with one call to save a few cycles. - */ - main->xbuffer[0] = (JSAMPIMAGE) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * 2 * SIZEOF(JSAMPARRAY)); - main->xbuffer[1] = main->xbuffer[0] + cinfo->num_components; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - /* Get space for pointer lists --- M+4 row groups in each list. - * We alloc both pointer lists with one call to save a few cycles. - */ - xbuf = (JSAMPARRAY) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW)); - xbuf += rgroup; /* want one row group at negative offsets */ - main->xbuffer[0][ci] = xbuf; - xbuf += rgroup * (M + 4); - main->xbuffer[1][ci] = xbuf; - } -} - - -LOCAL(void) -make_funny_pointers (j_decompress_ptr cinfo) -/* Create the funny pointer lists discussed in the comments above. - * The actual workspace is already allocated (in main->buffer), - * and the space for the pointer lists is allocated too. - * This routine just fills in the curiously ordered lists. - * This will be repeated at the beginning of each pass. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY buf, xbuf0, xbuf1; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - xbuf0 = main->xbuffer[0][ci]; - xbuf1 = main->xbuffer[1][ci]; - /* First copy the workspace pointers as-is */ - buf = main->buffer[ci]; - for (i = 0; i < rgroup * (M + 2); i++) { - xbuf0[i] = xbuf1[i] = buf[i]; - } - /* In the second list, put the last four row groups in swapped order */ - for (i = 0; i < rgroup * 2; i++) { - xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i]; - xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i]; - } - /* The wraparound pointers at top and bottom will be filled later - * (see set_wraparound_pointers, below). Initially we want the "above" - * pointers to duplicate the first actual data line. This only needs - * to happen in xbuffer[0]. - */ - for (i = 0; i < rgroup; i++) { - xbuf0[i - rgroup] = xbuf0[0]; - } - } -} - - -LOCAL(void) -set_wraparound_pointers (j_decompress_ptr cinfo) -/* Set up the "wraparound" pointers at top and bottom of the pointer lists. - * This changes the pointer list state from top-of-image to the normal state. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY xbuf0, xbuf1; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - xbuf0 = main->xbuffer[0][ci]; - xbuf1 = main->xbuffer[1][ci]; - for (i = 0; i < rgroup; i++) { - xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i]; - xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i]; - xbuf0[rgroup*(M+2) + i] = xbuf0[i]; - xbuf1[rgroup*(M+2) + i] = xbuf1[i]; - } - } -} - - -LOCAL(void) -set_bottom_pointers (j_decompress_ptr cinfo) -/* Change the pointer lists to duplicate the last sample row at the bottom - * of the image. whichptr indicates which xbuffer holds the final iMCU row. - * Also sets rowgroups_avail to indicate number of nondummy row groups in row. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup, iMCUheight, rows_left; - jpeg_component_info *compptr; - JSAMPARRAY xbuf; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Count sample rows in one iMCU row and in one row group */ - iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size; - rgroup = iMCUheight / cinfo->min_DCT_scaled_size; - /* Count nondummy sample rows remaining for this component */ - rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight); - if (rows_left == 0) rows_left = iMCUheight; - /* Count nondummy row groups. Should get same answer for each component, - * so we need only do it once. - */ - if (ci == 0) { - main->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1); - } - /* Duplicate the last real sample row rgroup*2 times; this pads out the - * last partial rowgroup and ensures at least one full rowgroup of context. - */ - xbuf = main->xbuffer[main->whichptr][ci]; - for (i = 0; i < rgroup * 2; i++) { - xbuf[rows_left + i] = xbuf[rows_left-1]; - } - } -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (cinfo->upsample->need_context_rows) { - main->pub.process_data = process_data_context_main; - make_funny_pointers(cinfo); /* Create the xbuffer[] lists */ - main->whichptr = 0; /* Read first iMCU row into xbuffer[0] */ - main->context_state = CTX_PREPARE_FOR_IMCU; - main->iMCU_row_ctr = 0; - } else { - /* Simple case with no context needed */ - main->pub.process_data = process_data_simple_main; - } - main->buffer_full = FALSE; /* Mark buffer empty */ - main->rowgroup_ctr = 0; - break; -#ifdef QUANT_2PASS_SUPPORTED - case JBUF_CRANK_DEST: - /* For last pass of 2-pass quantization, just crank the postprocessor */ - main->pub.process_data = process_data_crank_post; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data. - * This handles the simple case where no context is required. - */ - -METHODDEF(void) -process_data_simple_main (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - JDIMENSION rowgroups_avail; - - /* Read input data if we haven't filled the main buffer yet */ - if (! main->buffer_full) { - if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer)) - return; /* suspension forced, can do nothing more */ - main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ - } - - /* There are always min_DCT_scaled_size row groups in an iMCU row. */ - rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size; - /* Note: at the bottom of the image, we may pass extra garbage row groups - * to the postprocessor. The postprocessor has to check for bottom - * of image anyway (at row resolution), so no point in us doing it too. - */ - - /* Feed the postprocessor */ - (*cinfo->post->post_process_data) (cinfo, main->buffer, - &main->rowgroup_ctr, rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - - /* Has postprocessor consumed all the data yet? If so, mark buffer empty */ - if (main->rowgroup_ctr >= rowgroups_avail) { - main->buffer_full = FALSE; - main->rowgroup_ctr = 0; - } -} - - -/* - * Process some data. - * This handles the case where context rows must be provided. - */ - -METHODDEF(void) -process_data_context_main (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - /* Read input data if we haven't filled the main buffer yet */ - if (! main->buffer_full) { - if (! (*cinfo->coef->decompress_data) (cinfo, - main->xbuffer[main->whichptr])) - return; /* suspension forced, can do nothing more */ - main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ - main->iMCU_row_ctr++; /* count rows received */ - } - - /* Postprocessor typically will not swallow all the input data it is handed - * in one call (due to filling the output buffer first). Must be prepared - * to exit and restart. This switch lets us keep track of how far we got. - * Note that each case falls through to the next on successful completion. - */ - switch (main->context_state) { - case CTX_POSTPONED_ROW: - /* Call postprocessor using previously set pointers for postponed row */ - (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], - &main->rowgroup_ctr, main->rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - if (main->rowgroup_ctr < main->rowgroups_avail) - return; /* Need to suspend */ - main->context_state = CTX_PREPARE_FOR_IMCU; - if (*out_row_ctr >= out_rows_avail) - return; /* Postprocessor exactly filled output buf */ - /*FALLTHROUGH*/ - case CTX_PREPARE_FOR_IMCU: - /* Prepare to process first M-1 row groups of this iMCU row */ - main->rowgroup_ctr = 0; - main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1); - /* Check for bottom of image: if so, tweak pointers to "duplicate" - * the last sample row, and adjust rowgroups_avail to ignore padding rows. - */ - if (main->iMCU_row_ctr == cinfo->total_iMCU_rows) - set_bottom_pointers(cinfo); - main->context_state = CTX_PROCESS_IMCU; - /*FALLTHROUGH*/ - case CTX_PROCESS_IMCU: - /* Call postprocessor using previously set pointers */ - (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], - &main->rowgroup_ctr, main->rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - if (main->rowgroup_ctr < main->rowgroups_avail) - return; /* Need to suspend */ - /* After the first iMCU, change wraparound pointers to normal state */ - if (main->iMCU_row_ctr == 1) - set_wraparound_pointers(cinfo); - /* Prepare to load new iMCU row using other xbuffer list */ - main->whichptr ^= 1; /* 0=>1 or 1=>0 */ - main->buffer_full = FALSE; - /* Still need to process last row group of this iMCU row, */ - /* which is saved at index M+1 of the other xbuffer */ - main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1); - main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2); - main->context_state = CTX_POSTPONED_ROW; - } -} - - -/* - * Process some data. - * Final pass of two-pass quantization: just call the postprocessor. - * Source data will be the postprocessor controller's internal buffer. - */ - -#ifdef QUANT_2PASS_SUPPORTED - -METHODDEF(void) -process_data_crank_post (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL, - (JDIMENSION *) NULL, (JDIMENSION) 0, - output_buf, out_row_ctr, out_rows_avail); -} - -#endif /* QUANT_2PASS_SUPPORTED */ - - -/* - * Initialize main buffer controller. - */ - -GLOBAL(void) -jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_main_ptr main; - int ci, rgroup, ngroups; - jpeg_component_info *compptr; - - main = (my_main_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_main_controller)); - cinfo->main = (struct jpeg_d_main_controller *) main; - main->pub.start_pass = start_pass_main; - - if (need_full_buffer) /* shouldn't happen */ - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - /* Allocate the workspace. - * ngroups is the number of row groups we need. - */ - if (cinfo->upsample->need_context_rows) { - if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */ - ERREXIT(cinfo, JERR_NOTIMPL); - alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ - ngroups = cinfo->min_DCT_scaled_size + 2; - } else { - ngroups = cinfo->min_DCT_scaled_size; - } - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - main->buffer[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - compptr->width_in_blocks * compptr->DCT_scaled_size, - (JDIMENSION) (rgroup * ngroups)); - } -} +/* + * jdmainct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the main buffer controller for decompression. + * The main buffer lies between the JPEG decompressor proper and the + * post-processor; it holds downsampled data in the JPEG colorspace. + * + * Note that this code is bypassed in raw-data mode, since the application + * supplies the equivalent of the main buffer in that case. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * In the current system design, the main buffer need never be a full-image + * buffer; any full-height buffers will be found inside the coefficient or + * postprocessing controllers. Nonetheless, the main controller is not + * trivial. Its responsibility is to provide context rows for upsampling/ + * rescaling, and doing this in an efficient fashion is a bit tricky. + * + * Postprocessor input data is counted in "row groups". A row group + * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) + * sample rows of each component. (We require DCT_scaled_size values to be + * chosen such that these numbers are integers. In practice DCT_scaled_size + * values will likely be powers of two, so we actually have the stronger + * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.) + * Upsampling will typically produce max_v_samp_factor pixel rows from each + * row group (times any additional scale factor that the upsampler is + * applying). + * + * The coefficient controller will deliver data to us one iMCU row at a time; + * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or + * exactly min_DCT_scaled_size row groups. (This amount of data corresponds + * to one row of MCUs when the image is fully interleaved.) Note that the + * number of sample rows varies across components, but the number of row + * groups does not. Some garbage sample rows may be included in the last iMCU + * row at the bottom of the image. + * + * Depending on the vertical scaling algorithm used, the upsampler may need + * access to the sample row(s) above and below its current input row group. + * The upsampler is required to set need_context_rows TRUE at global selection + * time if so. When need_context_rows is FALSE, this controller can simply + * obtain one iMCU row at a time from the coefficient controller and dole it + * out as row groups to the postprocessor. + * + * When need_context_rows is TRUE, this controller guarantees that the buffer + * passed to postprocessing contains at least one row group's worth of samples + * above and below the row group(s) being processed. Note that the context + * rows "above" the first passed row group appear at negative row offsets in + * the passed buffer. At the top and bottom of the image, the required + * context rows are manufactured by duplicating the first or last real sample + * row; this avoids having special cases in the upsampling inner loops. + * + * The amount of context is fixed at one row group just because that's a + * convenient number for this controller to work with. The existing + * upsamplers really only need one sample row of context. An upsampler + * supporting arbitrary output rescaling might wish for more than one row + * group of context when shrinking the image; tough, we don't handle that. + * (This is justified by the assumption that downsizing will be handled mostly + * by adjusting the DCT_scaled_size values, so that the actual scale factor at + * the upsample step needn't be much less than one.) + * + * To provide the desired context, we have to retain the last two row groups + * of one iMCU row while reading in the next iMCU row. (The last row group + * can't be processed until we have another row group for its below-context, + * and so we have to save the next-to-last group too for its above-context.) + * We could do this most simply by copying data around in our buffer, but + * that'd be very slow. We can avoid copying any data by creating a rather + * strange pointer structure. Here's how it works. We allocate a workspace + * consisting of M+2 row groups (where M = min_DCT_scaled_size is the number + * of row groups per iMCU row). We create two sets of redundant pointers to + * the workspace. Labeling the physical row groups 0 to M+1, the synthesized + * pointer lists look like this: + * M+1 M-1 + * master pointer --> 0 master pointer --> 0 + * 1 1 + * ... ... + * M-3 M-3 + * M-2 M + * M-1 M+1 + * M M-2 + * M+1 M-1 + * 0 0 + * We read alternate iMCU rows using each master pointer; thus the last two + * row groups of the previous iMCU row remain un-overwritten in the workspace. + * The pointer lists are set up so that the required context rows appear to + * be adjacent to the proper places when we pass the pointer lists to the + * upsampler. + * + * The above pictures describe the normal state of the pointer lists. + * At top and bottom of the image, we diddle the pointer lists to duplicate + * the first or last sample row as necessary (this is cheaper than copying + * sample rows around). + * + * This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1. In that + * situation each iMCU row provides only one row group so the buffering logic + * must be different (eg, we must read two iMCU rows before we can emit the + * first row group). For now, we simply do not support providing context + * rows when min_DCT_scaled_size is 1. That combination seems unlikely to + * be worth providing --- if someone wants a 1/8th-size preview, they probably + * want it quick and dirty, so a context-free upsampler is sufficient. + */ + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_d_main_controller pub; /* public fields */ + + /* Pointer to allocated workspace (M or M+2 row groups). */ + JSAMPARRAY buffer[MAX_COMPONENTS]; + + boolean buffer_full; /* Have we gotten an iMCU row from decoder? */ + JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */ + + /* Remaining fields are only used in the context case. */ + + /* These are the master pointers to the funny-order pointer lists. */ + JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */ + + int whichptr; /* indicates which pointer set is now in use */ + int context_state; /* process_data state machine status */ + JDIMENSION rowgroups_avail; /* row groups available to postprocessor */ + JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */ +} my_main_controller; + +typedef my_main_controller * my_main_ptr; + +/* context_state values: */ +#define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */ +#define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */ +#define CTX_POSTPONED_ROW 2 /* feeding postponed row group */ + + +/* Forward declarations */ +METHODDEF(void) process_data_simple_main + JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); +METHODDEF(void) process_data_context_main + JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); +#ifdef QUANT_2PASS_SUPPORTED +METHODDEF(void) process_data_crank_post + JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); +#endif + + +LOCAL(void) +alloc_funny_pointers (j_decompress_ptr cinfo) +/* Allocate space for the funny pointer lists. + * This is done only once, not once per pass. + */ +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci, rgroup; + int M = cinfo->min_DCT_scaled_size; + jpeg_component_info *compptr; + JSAMPARRAY xbuf; + + /* Get top-level space for component array pointers. + * We alloc both arrays with one call to save a few cycles. + */ + main->xbuffer[0] = (JSAMPIMAGE) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components * 2 * SIZEOF(JSAMPARRAY)); + main->xbuffer[1] = main->xbuffer[0] + cinfo->num_components; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; /* height of a row group of component */ + /* Get space for pointer lists --- M+4 row groups in each list. + * We alloc both pointer lists with one call to save a few cycles. + */ + xbuf = (JSAMPARRAY) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW)); + xbuf += rgroup; /* want one row group at negative offsets */ + main->xbuffer[0][ci] = xbuf; + xbuf += rgroup * (M + 4); + main->xbuffer[1][ci] = xbuf; + } +} + + +LOCAL(void) +make_funny_pointers (j_decompress_ptr cinfo) +/* Create the funny pointer lists discussed in the comments above. + * The actual workspace is already allocated (in main->buffer), + * and the space for the pointer lists is allocated too. + * This routine just fills in the curiously ordered lists. + * This will be repeated at the beginning of each pass. + */ +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci, i, rgroup; + int M = cinfo->min_DCT_scaled_size; + jpeg_component_info *compptr; + JSAMPARRAY buf, xbuf0, xbuf1; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; /* height of a row group of component */ + xbuf0 = main->xbuffer[0][ci]; + xbuf1 = main->xbuffer[1][ci]; + /* First copy the workspace pointers as-is */ + buf = main->buffer[ci]; + for (i = 0; i < rgroup * (M + 2); i++) { + xbuf0[i] = xbuf1[i] = buf[i]; + } + /* In the second list, put the last four row groups in swapped order */ + for (i = 0; i < rgroup * 2; i++) { + xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i]; + xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i]; + } + /* The wraparound pointers at top and bottom will be filled later + * (see set_wraparound_pointers, below). Initially we want the "above" + * pointers to duplicate the first actual data line. This only needs + * to happen in xbuffer[0]. + */ + for (i = 0; i < rgroup; i++) { + xbuf0[i - rgroup] = xbuf0[0]; + } + } +} + + +LOCAL(void) +set_wraparound_pointers (j_decompress_ptr cinfo) +/* Set up the "wraparound" pointers at top and bottom of the pointer lists. + * This changes the pointer list state from top-of-image to the normal state. + */ +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci, i, rgroup; + int M = cinfo->min_DCT_scaled_size; + jpeg_component_info *compptr; + JSAMPARRAY xbuf0, xbuf1; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; /* height of a row group of component */ + xbuf0 = main->xbuffer[0][ci]; + xbuf1 = main->xbuffer[1][ci]; + for (i = 0; i < rgroup; i++) { + xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i]; + xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i]; + xbuf0[rgroup*(M+2) + i] = xbuf0[i]; + xbuf1[rgroup*(M+2) + i] = xbuf1[i]; + } + } +} + + +LOCAL(void) +set_bottom_pointers (j_decompress_ptr cinfo) +/* Change the pointer lists to duplicate the last sample row at the bottom + * of the image. whichptr indicates which xbuffer holds the final iMCU row. + * Also sets rowgroups_avail to indicate number of nondummy row groups in row. + */ +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci, i, rgroup, iMCUheight, rows_left; + jpeg_component_info *compptr; + JSAMPARRAY xbuf; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Count sample rows in one iMCU row and in one row group */ + iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size; + rgroup = iMCUheight / cinfo->min_DCT_scaled_size; + /* Count nondummy sample rows remaining for this component */ + rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight); + if (rows_left == 0) rows_left = iMCUheight; + /* Count nondummy row groups. Should get same answer for each component, + * so we need only do it once. + */ + if (ci == 0) { + main->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1); + } + /* Duplicate the last real sample row rgroup*2 times; this pads out the + * last partial rowgroup and ensures at least one full rowgroup of context. + */ + xbuf = main->xbuffer[main->whichptr][ci]; + for (i = 0; i < rgroup * 2; i++) { + xbuf[rows_left + i] = xbuf[rows_left-1]; + } + } +} + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + + switch (pass_mode) { + case JBUF_PASS_THRU: + if (cinfo->upsample->need_context_rows) { + main->pub.process_data = process_data_context_main; + make_funny_pointers(cinfo); /* Create the xbuffer[] lists */ + main->whichptr = 0; /* Read first iMCU row into xbuffer[0] */ + main->context_state = CTX_PREPARE_FOR_IMCU; + main->iMCU_row_ctr = 0; + } else { + /* Simple case with no context needed */ + main->pub.process_data = process_data_simple_main; + } + main->buffer_full = FALSE; /* Mark buffer empty */ + main->rowgroup_ctr = 0; + break; +#ifdef QUANT_2PASS_SUPPORTED + case JBUF_CRANK_DEST: + /* For last pass of 2-pass quantization, just crank the postprocessor */ + main->pub.process_data = process_data_crank_post; + break; +#endif + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + break; + } +} + + +/* + * Process some data. + * This handles the simple case where no context is required. + */ + +METHODDEF(void) +process_data_simple_main (j_decompress_ptr cinfo, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + JDIMENSION rowgroups_avail; + + /* Read input data if we haven't filled the main buffer yet */ + if (! main->buffer_full) { + if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer)) + return; /* suspension forced, can do nothing more */ + main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ + } + + /* There are always min_DCT_scaled_size row groups in an iMCU row. */ + rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size; + /* Note: at the bottom of the image, we may pass extra garbage row groups + * to the postprocessor. The postprocessor has to check for bottom + * of image anyway (at row resolution), so no point in us doing it too. + */ + + /* Feed the postprocessor */ + (*cinfo->post->post_process_data) (cinfo, main->buffer, + &main->rowgroup_ctr, rowgroups_avail, + output_buf, out_row_ctr, out_rows_avail); + + /* Has postprocessor consumed all the data yet? If so, mark buffer empty */ + if (main->rowgroup_ctr >= rowgroups_avail) { + main->buffer_full = FALSE; + main->rowgroup_ctr = 0; + } +} + + +/* + * Process some data. + * This handles the case where context rows must be provided. + */ + +METHODDEF(void) +process_data_context_main (j_decompress_ptr cinfo, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + + /* Read input data if we haven't filled the main buffer yet */ + if (! main->buffer_full) { + if (! (*cinfo->coef->decompress_data) (cinfo, + main->xbuffer[main->whichptr])) + return; /* suspension forced, can do nothing more */ + main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ + main->iMCU_row_ctr++; /* count rows received */ + } + + /* Postprocessor typically will not swallow all the input data it is handed + * in one call (due to filling the output buffer first). Must be prepared + * to exit and restart. This switch lets us keep track of how far we got. + * Note that each case falls through to the next on successful completion. + */ + switch (main->context_state) { + case CTX_POSTPONED_ROW: + /* Call postprocessor using previously set pointers for postponed row */ + (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], + &main->rowgroup_ctr, main->rowgroups_avail, + output_buf, out_row_ctr, out_rows_avail); + if (main->rowgroup_ctr < main->rowgroups_avail) + return; /* Need to suspend */ + main->context_state = CTX_PREPARE_FOR_IMCU; + if (*out_row_ctr >= out_rows_avail) + return; /* Postprocessor exactly filled output buf */ + /*FALLTHROUGH*/ + case CTX_PREPARE_FOR_IMCU: + /* Prepare to process first M-1 row groups of this iMCU row */ + main->rowgroup_ctr = 0; + main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1); + /* Check for bottom of image: if so, tweak pointers to "duplicate" + * the last sample row, and adjust rowgroups_avail to ignore padding rows. + */ + if (main->iMCU_row_ctr == cinfo->total_iMCU_rows) + set_bottom_pointers(cinfo); + main->context_state = CTX_PROCESS_IMCU; + /*FALLTHROUGH*/ + case CTX_PROCESS_IMCU: + /* Call postprocessor using previously set pointers */ + (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], + &main->rowgroup_ctr, main->rowgroups_avail, + output_buf, out_row_ctr, out_rows_avail); + if (main->rowgroup_ctr < main->rowgroups_avail) + return; /* Need to suspend */ + /* After the first iMCU, change wraparound pointers to normal state */ + if (main->iMCU_row_ctr == 1) + set_wraparound_pointers(cinfo); + /* Prepare to load new iMCU row using other xbuffer list */ + main->whichptr ^= 1; /* 0=>1 or 1=>0 */ + main->buffer_full = FALSE; + /* Still need to process last row group of this iMCU row, */ + /* which is saved at index M+1 of the other xbuffer */ + main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1); + main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2); + main->context_state = CTX_POSTPONED_ROW; + } +} + + +/* + * Process some data. + * Final pass of two-pass quantization: just call the postprocessor. + * Source data will be the postprocessor controller's internal buffer. + */ + +#ifdef QUANT_2PASS_SUPPORTED + +METHODDEF(void) +process_data_crank_post (j_decompress_ptr cinfo, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL, + (JDIMENSION *) NULL, (JDIMENSION) 0, + output_buf, out_row_ctr, out_rows_avail); +} + +#endif /* QUANT_2PASS_SUPPORTED */ + + +/* + * Initialize main buffer controller. + */ + +GLOBAL(void) +jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) +{ + my_main_ptr main; + int ci, rgroup, ngroups; + jpeg_component_info *compptr; + + main = (my_main_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_main_controller)); + cinfo->main = (struct jpeg_d_main_controller *) main; + main->pub.start_pass = start_pass_main; + + if (need_full_buffer) /* shouldn't happen */ + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + /* Allocate the workspace. + * ngroups is the number of row groups we need. + */ + if (cinfo->upsample->need_context_rows) { + if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */ + ERREXIT(cinfo, JERR_NOTIMPL); + alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ + ngroups = cinfo->min_DCT_scaled_size + 2; + } else { + ngroups = cinfo->min_DCT_scaled_size; + } + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; /* height of a row group of component */ + main->buffer[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + compptr->width_in_blocks * compptr->DCT_scaled_size, + (JDIMENSION) (rgroup * ngroups)); + } +} diff --git a/src/dep/src/irrlicht/jpeglib/jdmarker.c b/src/dep/src/irrlicht/jpeglib/jdmarker.c index 9811761..f4cca8c 100644 --- a/src/dep/src/irrlicht/jpeglib/jdmarker.c +++ b/src/dep/src/irrlicht/jpeglib/jdmarker.c @@ -1,1360 +1,1360 @@ -/* - * jdmarker.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to decode JPEG datastream markers. - * Most of the complexity arises from our desire to support input - * suspension: if not all of the data for a marker is available, - * we must exit back to the application. On resumption, we reprocess - * the marker. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -typedef enum { /* JPEG marker codes */ - M_SOF0 = 0xc0, - M_SOF1 = 0xc1, - M_SOF2 = 0xc2, - M_SOF3 = 0xc3, - - M_SOF5 = 0xc5, - M_SOF6 = 0xc6, - M_SOF7 = 0xc7, - - M_JPG = 0xc8, - M_SOF9 = 0xc9, - M_SOF10 = 0xca, - M_SOF11 = 0xcb, - - M_SOF13 = 0xcd, - M_SOF14 = 0xce, - M_SOF15 = 0xcf, - - M_DHT = 0xc4, - - M_DAC = 0xcc, - - M_RST0 = 0xd0, - M_RST1 = 0xd1, - M_RST2 = 0xd2, - M_RST3 = 0xd3, - M_RST4 = 0xd4, - M_RST5 = 0xd5, - M_RST6 = 0xd6, - M_RST7 = 0xd7, - - M_SOI = 0xd8, - M_EOI = 0xd9, - M_SOS = 0xda, - M_DQT = 0xdb, - M_DNL = 0xdc, - M_DRI = 0xdd, - M_DHP = 0xde, - M_EXP = 0xdf, - - M_APP0 = 0xe0, - M_APP1 = 0xe1, - M_APP2 = 0xe2, - M_APP3 = 0xe3, - M_APP4 = 0xe4, - M_APP5 = 0xe5, - M_APP6 = 0xe6, - M_APP7 = 0xe7, - M_APP8 = 0xe8, - M_APP9 = 0xe9, - M_APP10 = 0xea, - M_APP11 = 0xeb, - M_APP12 = 0xec, - M_APP13 = 0xed, - M_APP14 = 0xee, - M_APP15 = 0xef, - - M_JPG0 = 0xf0, - M_JPG13 = 0xfd, - M_COM = 0xfe, - - M_TEM = 0x01, - - M_ERROR = 0x100 -} JPEG_MARKER; - - -/* Private state */ - -typedef struct { - struct jpeg_marker_reader pub; /* public fields */ - - /* Application-overridable marker processing methods */ - jpeg_marker_parser_method process_COM; - jpeg_marker_parser_method process_APPn[16]; - - /* Limit on marker data length to save for each marker type */ - unsigned int length_limit_COM; - unsigned int length_limit_APPn[16]; - - /* Status of COM/APPn marker saving */ - jpeg_saved_marker_ptr cur_marker; /* NULL if not processing a marker */ - unsigned int bytes_read; /* data bytes read so far in marker */ - /* Note: cur_marker is not linked into marker_list until it's all read. */ -} my_marker_reader; - -typedef my_marker_reader * my_marker_ptr; - - -/* - * Macros for fetching data from the data source module. - * - * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect - * the current restart point; we update them only when we have reached a - * suitable place to restart if a suspension occurs. - */ - -/* Declare and initialize local copies of input pointer/count */ -#define INPUT_VARS(cinfo) \ - struct jpeg_source_mgr * datasrc = (cinfo)->src; \ - const JOCTET * next_input_byte = datasrc->next_input_byte; \ - size_t bytes_in_buffer = datasrc->bytes_in_buffer - -/* Unload the local copies --- do this only at a restart boundary */ -#define INPUT_SYNC(cinfo) \ - ( datasrc->next_input_byte = next_input_byte, \ - datasrc->bytes_in_buffer = bytes_in_buffer ) - -/* Reload the local copies --- used only in MAKE_BYTE_AVAIL */ -#define INPUT_RELOAD(cinfo) \ - ( next_input_byte = datasrc->next_input_byte, \ - bytes_in_buffer = datasrc->bytes_in_buffer ) - -/* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available. - * Note we do *not* do INPUT_SYNC before calling fill_input_buffer, - * but we must reload the local copies after a successful fill. - */ -#define MAKE_BYTE_AVAIL(cinfo,action) \ - if (bytes_in_buffer == 0) { \ - if (! (*datasrc->fill_input_buffer) (cinfo)) \ - { action; } \ - INPUT_RELOAD(cinfo); \ - } - -/* Read a byte into variable V. - * If must suspend, take the specified action (typically "return FALSE"). - */ -#define INPUT_BYTE(cinfo,V,action) \ - MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V = GETJOCTET(*next_input_byte++); ) - -/* As above, but read two bytes interpreted as an unsigned 16-bit integer. - * V should be declared unsigned int or perhaps INT32. - */ -#define INPUT_2BYTES(cinfo,V,action) \ - MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \ - MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V += GETJOCTET(*next_input_byte++); ) - - -/* - * Routines to process JPEG markers. - * - * Entry condition: JPEG marker itself has been read and its code saved - * in cinfo->unread_marker; input restart point is just after the marker. - * - * Exit: if return TRUE, have read and processed any parameters, and have - * updated the restart point to point after the parameters. - * If return FALSE, was forced to suspend before reaching end of - * marker parameters; restart point has not been moved. Same routine - * will be called again after application supplies more input data. - * - * This approach to suspension assumes that all of a marker's parameters - * can fit into a single input bufferload. This should hold for "normal" - * markers. Some COM/APPn markers might have large parameter segments - * that might not fit. If we are simply dropping such a marker, we use - * skip_input_data to get past it, and thereby put the problem on the - * source manager's shoulders. If we are saving the marker's contents - * into memory, we use a slightly different convention: when forced to - * suspend, the marker processor updates the restart point to the end of - * what it's consumed (ie, the end of the buffer) before returning FALSE. - * On resumption, cinfo->unread_marker still contains the marker code, - * but the data source will point to the next chunk of marker data. - * The marker processor must retain internal state to deal with this. - * - * Note that we don't bother to avoid duplicate trace messages if a - * suspension occurs within marker parameters. Other side effects - * require more care. - */ - - -LOCAL(boolean) -get_soi (j_decompress_ptr cinfo) -/* Process an SOI marker */ -{ - int i; - - TRACEMS(cinfo, 1, JTRC_SOI); - - if (cinfo->marker->saw_SOI) - ERREXIT(cinfo, JERR_SOI_DUPLICATE); - - /* Reset all parameters that are defined to be reset by SOI */ - - for (i = 0; i < NUM_ARITH_TBLS; i++) { - cinfo->arith_dc_L[i] = 0; - cinfo->arith_dc_U[i] = 1; - cinfo->arith_ac_K[i] = 5; - } - cinfo->restart_interval = 0; - - /* Set initial assumptions for colorspace etc */ - - cinfo->jpeg_color_space = JCS_UNKNOWN; - cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */ - - cinfo->saw_JFIF_marker = FALSE; - cinfo->JFIF_major_version = 1; /* set default JFIF APP0 values */ - cinfo->JFIF_minor_version = 1; - cinfo->density_unit = 0; - cinfo->X_density = 1; - cinfo->Y_density = 1; - cinfo->saw_Adobe_marker = FALSE; - cinfo->Adobe_transform = 0; - - cinfo->marker->saw_SOI = TRUE; - - return TRUE; -} - - -LOCAL(boolean) -get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith) -/* Process a SOFn marker */ -{ - INT32 length; - int c, ci; - jpeg_component_info * compptr; - INPUT_VARS(cinfo); - - cinfo->progressive_mode = is_prog; - cinfo->arith_code = is_arith; - - INPUT_2BYTES(cinfo, length, return FALSE); - - INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE); - INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE); - INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE); - INPUT_BYTE(cinfo, cinfo->num_components, return FALSE); - - length -= 8; - - TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker, - (int) cinfo->image_width, (int) cinfo->image_height, - cinfo->num_components); - - if (cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOF_DUPLICATE); - - /* We don't support files in which the image height is initially specified */ - /* as 0 and is later redefined by DNL. As long as we have to check that, */ - /* might as well have a general sanity check. */ - if (cinfo->image_height <= 0 || cinfo->image_width <= 0 - || cinfo->num_components <= 0) - ERREXIT(cinfo, JERR_EMPTY_IMAGE); - - if (length != (cinfo->num_components * 3)) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - if (cinfo->comp_info == NULL) /* do only once, even if suspend */ - cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * SIZEOF(jpeg_component_info)); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - compptr->component_index = ci; - INPUT_BYTE(cinfo, compptr->component_id, return FALSE); - INPUT_BYTE(cinfo, c, return FALSE); - compptr->h_samp_factor = (c >> 4) & 15; - compptr->v_samp_factor = (c ) & 15; - INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE); - - TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT, - compptr->component_id, compptr->h_samp_factor, - compptr->v_samp_factor, compptr->quant_tbl_no); - } - - cinfo->marker->saw_SOF = TRUE; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_sos (j_decompress_ptr cinfo) -/* Process a SOS marker */ -{ - INT32 length; - int i, ci, n, c, cc; - jpeg_component_info * compptr; - INPUT_VARS(cinfo); - - if (! cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOS_NO_SOF); - - INPUT_2BYTES(cinfo, length, return FALSE); - - INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */ - - TRACEMS1(cinfo, 1, JTRC_SOS, n); - - if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - cinfo->comps_in_scan = n; - - /* Collect the component-spec parameters */ - - for (i = 0; i < n; i++) { - INPUT_BYTE(cinfo, cc, return FALSE); - INPUT_BYTE(cinfo, c, return FALSE); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (cc == compptr->component_id) - goto id_found; - } - - ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc); - - id_found: - - cinfo->cur_comp_info[i] = compptr; - compptr->dc_tbl_no = (c >> 4) & 15; - compptr->ac_tbl_no = (c ) & 15; - - TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc, - compptr->dc_tbl_no, compptr->ac_tbl_no); - } - - /* Collect the additional scan parameters Ss, Se, Ah/Al. */ - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Ss = c; - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Se = c; - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Ah = (c >> 4) & 15; - cinfo->Al = (c ) & 15; - - TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se, - cinfo->Ah, cinfo->Al); - - /* Prepare to scan data & restart markers */ - cinfo->marker->next_restart_num = 0; - - /* Count another SOS marker */ - cinfo->input_scan_number++; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -#ifdef D_ARITH_CODING_SUPPORTED - -LOCAL(boolean) -get_dac (j_decompress_ptr cinfo) -/* Process a DAC marker */ -{ - INT32 length; - int index, val; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 0) { - INPUT_BYTE(cinfo, index, return FALSE); - INPUT_BYTE(cinfo, val, return FALSE); - - length -= 2; - - TRACEMS2(cinfo, 1, JTRC_DAC, index, val); - - if (index < 0 || index >= (2*NUM_ARITH_TBLS)) - ERREXIT1(cinfo, JERR_DAC_INDEX, index); - - if (index >= NUM_ARITH_TBLS) { /* define AC table */ - cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val; - } else { /* define DC table */ - cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F); - cinfo->arith_dc_U[index] = (UINT8) (val >> 4); - if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index]) - ERREXIT1(cinfo, JERR_DAC_VALUE, val); - } - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - -#else /* ! D_ARITH_CODING_SUPPORTED */ - -#define get_dac(cinfo) skip_variable(cinfo) - -#endif /* D_ARITH_CODING_SUPPORTED */ - - -LOCAL(boolean) -get_dht (j_decompress_ptr cinfo) -/* Process a DHT marker */ -{ - INT32 length; - UINT8 bits[17]; - UINT8 huffval[256]; - int i, index, count; - JHUFF_TBL **htblptr; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 16) { - INPUT_BYTE(cinfo, index, return FALSE); - - TRACEMS1(cinfo, 1, JTRC_DHT, index); - - bits[0] = 0; - count = 0; - for (i = 1; i <= 16; i++) { - INPUT_BYTE(cinfo, bits[i], return FALSE); - count += bits[i]; - } - - length -= 1 + 16; - - TRACEMS8(cinfo, 2, JTRC_HUFFBITS, - bits[1], bits[2], bits[3], bits[4], - bits[5], bits[6], bits[7], bits[8]); - TRACEMS8(cinfo, 2, JTRC_HUFFBITS, - bits[9], bits[10], bits[11], bits[12], - bits[13], bits[14], bits[15], bits[16]); - - /* Here we just do minimal validation of the counts to avoid walking - * off the end of our table space. jdhuff.c will check more carefully. - */ - if (count > 256 || ((INT32) count) > length) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - - for (i = 0; i < count; i++) - INPUT_BYTE(cinfo, huffval[i], return FALSE); - - length -= count; - - if (index & 0x10) { /* AC table definition */ - index -= 0x10; - htblptr = &cinfo->ac_huff_tbl_ptrs[index]; - } else { /* DC table definition */ - htblptr = &cinfo->dc_huff_tbl_ptrs[index]; - } - - if (index < 0 || index >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_DHT_INDEX, index); - - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - - MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); - MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval)); - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_dqt (j_decompress_ptr cinfo) -/* Process a DQT marker */ -{ - INT32 length; - int n, i, prec; - unsigned int tmp; - JQUANT_TBL *quant_ptr; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 0) { - INPUT_BYTE(cinfo, n, return FALSE); - prec = n >> 4; - n &= 0x0F; - - TRACEMS2(cinfo, 1, JTRC_DQT, n, prec); - - if (n >= NUM_QUANT_TBLS) - ERREXIT1(cinfo, JERR_DQT_INDEX, n); - - if (cinfo->quant_tbl_ptrs[n] == NULL) - cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo); - quant_ptr = cinfo->quant_tbl_ptrs[n]; - - for (i = 0; i < DCTSIZE2; i++) { - if (prec) - INPUT_2BYTES(cinfo, tmp, return FALSE); - else - INPUT_BYTE(cinfo, tmp, return FALSE); - /* We convert the zigzag-order table to natural array order. */ - quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16) tmp; - } - - if (cinfo->err->trace_level >= 2) { - for (i = 0; i < DCTSIZE2; i += 8) { - TRACEMS8(cinfo, 2, JTRC_QUANTVALS, - quant_ptr->quantval[i], quant_ptr->quantval[i+1], - quant_ptr->quantval[i+2], quant_ptr->quantval[i+3], - quant_ptr->quantval[i+4], quant_ptr->quantval[i+5], - quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]); - } - } - - length -= DCTSIZE2+1; - if (prec) length -= DCTSIZE2; - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_dri (j_decompress_ptr cinfo) -/* Process a DRI marker */ -{ - INT32 length; - unsigned int tmp; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - - if (length != 4) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_2BYTES(cinfo, tmp, return FALSE); - - TRACEMS1(cinfo, 1, JTRC_DRI, tmp); - - cinfo->restart_interval = tmp; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -/* - * Routines for processing APPn and COM markers. - * These are either saved in memory or discarded, per application request. - * APP0 and APP14 are specially checked to see if they are - * JFIF and Adobe markers, respectively. - */ - -#define APP0_DATA_LEN 14 /* Length of interesting data in APP0 */ -#define APP14_DATA_LEN 12 /* Length of interesting data in APP14 */ -#define APPN_DATA_LEN 14 /* Must be the largest of the above!! */ - - -LOCAL(void) -examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data, - unsigned int datalen, INT32 remaining) -/* Examine first few bytes from an APP0. - * Take appropriate action if it is a JFIF marker. - * datalen is # of bytes at data[], remaining is length of rest of marker data. - */ -{ - INT32 totallen = (INT32) datalen + remaining; - - if (datalen >= APP0_DATA_LEN && - GETJOCTET(data[0]) == 0x4A && - GETJOCTET(data[1]) == 0x46 && - GETJOCTET(data[2]) == 0x49 && - GETJOCTET(data[3]) == 0x46 && - GETJOCTET(data[4]) == 0) { - /* Found JFIF APP0 marker: save info */ - cinfo->saw_JFIF_marker = TRUE; - cinfo->JFIF_major_version = GETJOCTET(data[5]); - cinfo->JFIF_minor_version = GETJOCTET(data[6]); - cinfo->density_unit = GETJOCTET(data[7]); - cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]); - cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]); - /* Check version. - * Major version must be 1, anything else signals an incompatible change. - * (We used to treat this as an error, but now it's a nonfatal warning, - * because some bozo at Hijaak couldn't read the spec.) - * Minor version should be 0..2, but process anyway if newer. - */ - if (cinfo->JFIF_major_version != 1) - WARNMS2(cinfo, JWRN_JFIF_MAJOR, - cinfo->JFIF_major_version, cinfo->JFIF_minor_version); - /* Generate trace messages */ - TRACEMS5(cinfo, 1, JTRC_JFIF, - cinfo->JFIF_major_version, cinfo->JFIF_minor_version, - cinfo->X_density, cinfo->Y_density, cinfo->density_unit); - /* Validate thumbnail dimensions and issue appropriate messages */ - if (GETJOCTET(data[12]) | GETJOCTET(data[13])) - TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, - GETJOCTET(data[12]), GETJOCTET(data[13])); - totallen -= APP0_DATA_LEN; - if (totallen != - ((INT32)GETJOCTET(data[12]) * (INT32)GETJOCTET(data[13]) * (INT32) 3)) - TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen); - } else if (datalen >= 6 && - GETJOCTET(data[0]) == 0x4A && - GETJOCTET(data[1]) == 0x46 && - GETJOCTET(data[2]) == 0x58 && - GETJOCTET(data[3]) == 0x58 && - GETJOCTET(data[4]) == 0) { - /* Found JFIF "JFXX" extension APP0 marker */ - /* The library doesn't actually do anything with these, - * but we try to produce a helpful trace message. - */ - switch (GETJOCTET(data[5])) { - case 0x10: - TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen); - break; - case 0x11: - TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen); - break; - case 0x13: - TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen); - break; - default: - TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION, - GETJOCTET(data[5]), (int) totallen); - break; - } - } else { - /* Start of APP0 does not match "JFIF" or "JFXX", or too short */ - TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen); - } -} - - -LOCAL(void) -examine_app14 (j_decompress_ptr cinfo, JOCTET FAR * data, - unsigned int datalen, INT32 remaining) -/* Examine first few bytes from an APP14. - * Take appropriate action if it is an Adobe marker. - * datalen is # of bytes at data[], remaining is length of rest of marker data. - */ -{ - unsigned int version, flags0, flags1, transform; - - if (datalen >= APP14_DATA_LEN && - GETJOCTET(data[0]) == 0x41 && - GETJOCTET(data[1]) == 0x64 && - GETJOCTET(data[2]) == 0x6F && - GETJOCTET(data[3]) == 0x62 && - GETJOCTET(data[4]) == 0x65) { - /* Found Adobe APP14 marker */ - version = (GETJOCTET(data[5]) << 8) + GETJOCTET(data[6]); - flags0 = (GETJOCTET(data[7]) << 8) + GETJOCTET(data[8]); - flags1 = (GETJOCTET(data[9]) << 8) + GETJOCTET(data[10]); - transform = GETJOCTET(data[11]); - TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform); - cinfo->saw_Adobe_marker = TRUE; - cinfo->Adobe_transform = (UINT8) transform; - } else { - /* Start of APP14 does not match "Adobe", or too short */ - TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining)); - } -} - - -METHODDEF(boolean) -get_interesting_appn (j_decompress_ptr cinfo) -/* Process an APP0 or APP14 marker without saving it */ -{ - INT32 length; - JOCTET b[APPN_DATA_LEN]; - unsigned int i, numtoread; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - /* get the interesting part of the marker data */ - if (length >= APPN_DATA_LEN) - numtoread = APPN_DATA_LEN; - else if (length > 0) - numtoread = (unsigned int) length; - else - numtoread = 0; - for (i = 0; i < numtoread; i++) - INPUT_BYTE(cinfo, b[i], return FALSE); - length -= numtoread; - - /* process it */ - switch (cinfo->unread_marker) { - case M_APP0: - examine_app0(cinfo, (JOCTET FAR *) b, numtoread, length); - break; - case M_APP14: - examine_app14(cinfo, (JOCTET FAR *) b, numtoread, length); - break; - default: - /* can't get here unless jpeg_save_markers chooses wrong processor */ - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); - break; - } - - /* skip any remaining data -- could be lots */ - INPUT_SYNC(cinfo); - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - - -#ifdef SAVE_MARKERS_SUPPORTED - -METHODDEF(boolean) -save_marker (j_decompress_ptr cinfo) -/* Save an APPn or COM marker into the marker list */ -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - jpeg_saved_marker_ptr cur_marker = marker->cur_marker; - unsigned int bytes_read, data_length; - JOCTET FAR * data; - INT32 length = 0; - INPUT_VARS(cinfo); - - if (cur_marker == NULL) { - /* begin reading a marker */ - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - if (length >= 0) { /* watch out for bogus length word */ - /* figure out how much we want to save */ - unsigned int limit; - if (cinfo->unread_marker == (int) M_COM) - limit = marker->length_limit_COM; - else - limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0]; - if ((unsigned int) length < limit) - limit = (unsigned int) length; - /* allocate and initialize the marker item */ - cur_marker = (jpeg_saved_marker_ptr) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(struct jpeg_marker_struct) + limit); - cur_marker->next = NULL; - cur_marker->marker = (UINT8) cinfo->unread_marker; - cur_marker->original_length = (unsigned int) length; - cur_marker->data_length = limit; - /* data area is just beyond the jpeg_marker_struct */ - data = cur_marker->data = (JOCTET FAR *) (cur_marker + 1); - marker->cur_marker = cur_marker; - marker->bytes_read = 0; - bytes_read = 0; - data_length = limit; - } else { - /* deal with bogus length word */ - bytes_read = data_length = 0; - data = NULL; - } - } else { - /* resume reading a marker */ - bytes_read = marker->bytes_read; - data_length = cur_marker->data_length; - data = cur_marker->data + bytes_read; - } - - while (bytes_read < data_length) { - INPUT_SYNC(cinfo); /* move the restart point to here */ - marker->bytes_read = bytes_read; - /* If there's not at least one byte in buffer, suspend */ - MAKE_BYTE_AVAIL(cinfo, return FALSE); - /* Copy bytes with reasonable rapidity */ - while (bytes_read < data_length && bytes_in_buffer > 0) { - *data++ = *next_input_byte++; - bytes_in_buffer--; - bytes_read++; - } - } - - /* Done reading what we want to read */ - if (cur_marker != NULL) { /* will be NULL if bogus length word */ - /* Add new marker to end of list */ - if (cinfo->marker_list == NULL) { - cinfo->marker_list = cur_marker; - } else { - jpeg_saved_marker_ptr prev = cinfo->marker_list; - while (prev->next != NULL) - prev = prev->next; - prev->next = cur_marker; - } - /* Reset pointer & calc remaining data length */ - data = cur_marker->data; - length = cur_marker->original_length - data_length; - } - /* Reset to initial state for next marker */ - marker->cur_marker = NULL; - - /* Process the marker if interesting; else just make a generic trace msg */ - switch (cinfo->unread_marker) { - case M_APP0: - examine_app0(cinfo, data, data_length, length); - break; - case M_APP14: - examine_app14(cinfo, data, data_length, length); - break; - default: - TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, - (int) (data_length + length)); - break; - } - - /* skip any remaining data -- could be lots */ - INPUT_SYNC(cinfo); /* do before skip_input_data */ - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - -#endif /* SAVE_MARKERS_SUPPORTED */ - - -METHODDEF(boolean) -skip_variable (j_decompress_ptr cinfo) -/* Skip over an unknown or uninteresting variable-length marker */ -{ - INT32 length; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length); - - INPUT_SYNC(cinfo); /* do before skip_input_data */ - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - - -/* - * Find the next JPEG marker, save it in cinfo->unread_marker. - * Returns FALSE if had to suspend before reaching a marker; - * in that case cinfo->unread_marker is unchanged. - * - * Note that the result might not be a valid marker code, - * but it will never be 0 or FF. - */ - -LOCAL(boolean) -next_marker (j_decompress_ptr cinfo) -{ - int c; - INPUT_VARS(cinfo); - - for (;;) { - INPUT_BYTE(cinfo, c, return FALSE); - /* Skip any non-FF bytes. - * This may look a bit inefficient, but it will not occur in a valid file. - * We sync after each discarded byte so that a suspending data source - * can discard the byte from its buffer. - */ - while (c != 0xFF) { - cinfo->marker->discarded_bytes++; - INPUT_SYNC(cinfo); - INPUT_BYTE(cinfo, c, return FALSE); - } - /* This loop swallows any duplicate FF bytes. Extra FFs are legal as - * pad bytes, so don't count them in discarded_bytes. We assume there - * will not be so many consecutive FF bytes as to overflow a suspending - * data source's input buffer. - */ - do { - INPUT_BYTE(cinfo, c, return FALSE); - } while (c == 0xFF); - if (c != 0) - break; /* found a valid marker, exit loop */ - /* Reach here if we found a stuffed-zero data sequence (FF/00). - * Discard it and loop back to try again. - */ - cinfo->marker->discarded_bytes += 2; - INPUT_SYNC(cinfo); - } - - if (cinfo->marker->discarded_bytes != 0) { - WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c); - cinfo->marker->discarded_bytes = 0; - } - - cinfo->unread_marker = c; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -first_marker (j_decompress_ptr cinfo) -/* Like next_marker, but used to obtain the initial SOI marker. */ -/* For this marker, we do not allow preceding garbage or fill; otherwise, - * we might well scan an entire input file before realizing it ain't JPEG. - * If an application wants to process non-JFIF files, it must seek to the - * SOI before calling the JPEG library. - */ -{ - int c, c2; - INPUT_VARS(cinfo); - - INPUT_BYTE(cinfo, c, return FALSE); - INPUT_BYTE(cinfo, c2, return FALSE); - if (c != 0xFF || c2 != (int) M_SOI) - ERREXIT2(cinfo, JERR_NO_SOI, c, c2); - - cinfo->unread_marker = c2; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -/* - * Read markers until SOS or EOI. - * - * Returns same codes as are defined for jpeg_consume_input: - * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - */ - -METHODDEF(int) -read_markers (j_decompress_ptr cinfo) -{ - /* Outer loop repeats once for each marker. */ - for (;;) { - /* Collect the marker proper, unless we already did. */ - /* NB: first_marker() enforces the requirement that SOI appear first. */ - if (cinfo->unread_marker == 0) { - if (! cinfo->marker->saw_SOI) { - if (! first_marker(cinfo)) - return JPEG_SUSPENDED; - } else { - if (! next_marker(cinfo)) - return JPEG_SUSPENDED; - } - } - /* At this point cinfo->unread_marker contains the marker code and the - * input point is just past the marker proper, but before any parameters. - * A suspension will cause us to return with this state still true. - */ - switch (cinfo->unread_marker) { - case M_SOI: - if (! get_soi(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_SOF0: /* Baseline */ - case M_SOF1: /* Extended sequential, Huffman */ - if (! get_sof(cinfo, FALSE, FALSE)) - return JPEG_SUSPENDED; - break; - - case M_SOF2: /* Progressive, Huffman */ - if (! get_sof(cinfo, TRUE, FALSE)) - return JPEG_SUSPENDED; - break; - - case M_SOF9: /* Extended sequential, arithmetic */ - if (! get_sof(cinfo, FALSE, TRUE)) - return JPEG_SUSPENDED; - break; - - case M_SOF10: /* Progressive, arithmetic */ - if (! get_sof(cinfo, TRUE, TRUE)) - return JPEG_SUSPENDED; - break; - - /* Currently unsupported SOFn types */ - case M_SOF3: /* Lossless, Huffman */ - case M_SOF5: /* Differential sequential, Huffman */ - case M_SOF6: /* Differential progressive, Huffman */ - case M_SOF7: /* Differential lossless, Huffman */ - case M_JPG: /* Reserved for JPEG extensions */ - case M_SOF11: /* Lossless, arithmetic */ - case M_SOF13: /* Differential sequential, arithmetic */ - case M_SOF14: /* Differential progressive, arithmetic */ - case M_SOF15: /* Differential lossless, arithmetic */ - ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker); - break; - - case M_SOS: - if (! get_sos(cinfo)) - return JPEG_SUSPENDED; - cinfo->unread_marker = 0; /* processed the marker */ - return JPEG_REACHED_SOS; - - case M_EOI: - TRACEMS(cinfo, 1, JTRC_EOI); - cinfo->unread_marker = 0; /* processed the marker */ - return JPEG_REACHED_EOI; - - case M_DAC: - if (! get_dac(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DHT: - if (! get_dht(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DQT: - if (! get_dqt(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DRI: - if (! get_dri(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_APP0: - case M_APP1: - case M_APP2: - case M_APP3: - case M_APP4: - case M_APP5: - case M_APP6: - case M_APP7: - case M_APP8: - case M_APP9: - case M_APP10: - case M_APP11: - case M_APP12: - case M_APP13: - case M_APP14: - case M_APP15: - if (! (*((my_marker_ptr) cinfo->marker)->process_APPn[ - cinfo->unread_marker - (int) M_APP0]) (cinfo)) - return JPEG_SUSPENDED; - break; - - case M_COM: - if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo)) - return JPEG_SUSPENDED; - break; - - case M_RST0: /* these are all parameterless */ - case M_RST1: - case M_RST2: - case M_RST3: - case M_RST4: - case M_RST5: - case M_RST6: - case M_RST7: - case M_TEM: - TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker); - break; - - case M_DNL: /* Ignore DNL ... perhaps the wrong thing */ - if (! skip_variable(cinfo)) - return JPEG_SUSPENDED; - break; - - default: /* must be DHP, EXP, JPGn, or RESn */ - /* For now, we treat the reserved markers as fatal errors since they are - * likely to be used to signal incompatible JPEG Part 3 extensions. - * Once the JPEG 3 version-number marker is well defined, this code - * ought to change! - */ - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); - break; - } - /* Successfully processed marker, so reset state variable */ - cinfo->unread_marker = 0; - } /* end loop */ -} - - -/* - * Read a restart marker, which is expected to appear next in the datastream; - * if the marker is not there, take appropriate recovery action. - * Returns FALSE if suspension is required. - * - * This is called by the entropy decoder after it has read an appropriate - * number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder - * has already read a marker from the data source. Under normal conditions - * cinfo->unread_marker will be reset to 0 before returning; if not reset, - * it holds a marker which the decoder will be unable to read past. - */ - -METHODDEF(boolean) -read_restart_marker (j_decompress_ptr cinfo) -{ - /* Obtain a marker unless we already did. */ - /* Note that next_marker will complain if it skips any data. */ - if (cinfo->unread_marker == 0) { - if (! next_marker(cinfo)) - return FALSE; - } - - if (cinfo->unread_marker == - ((int) M_RST0 + cinfo->marker->next_restart_num)) { - /* Normal case --- swallow the marker and let entropy decoder continue */ - TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num); - cinfo->unread_marker = 0; - } else { - /* Uh-oh, the restart markers have been messed up. */ - /* Let the data source manager determine how to resync. */ - if (! (*cinfo->src->resync_to_restart) (cinfo, - cinfo->marker->next_restart_num)) - return FALSE; - } - - /* Update next-restart state */ - cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7; - - return TRUE; -} - - -/* - * This is the default resync_to_restart method for data source managers - * to use if they don't have any better approach. Some data source managers - * may be able to back up, or may have additional knowledge about the data - * which permits a more intelligent recovery strategy; such managers would - * presumably supply their own resync method. - * - * read_restart_marker calls resync_to_restart if it finds a marker other than - * the restart marker it was expecting. (This code is *not* used unless - * a nonzero restart interval has been declared.) cinfo->unread_marker is - * the marker code actually found (might be anything, except 0 or FF). - * The desired restart marker number (0..7) is passed as a parameter. - * This routine is supposed to apply whatever error recovery strategy seems - * appropriate in order to position the input stream to the next data segment. - * Note that cinfo->unread_marker is treated as a marker appearing before - * the current data-source input point; usually it should be reset to zero - * before returning. - * Returns FALSE if suspension is required. - * - * This implementation is substantially constrained by wanting to treat the - * input as a data stream; this means we can't back up. Therefore, we have - * only the following actions to work with: - * 1. Simply discard the marker and let the entropy decoder resume at next - * byte of file. - * 2. Read forward until we find another marker, discarding intervening - * data. (In theory we could look ahead within the current bufferload, - * without having to discard data if we don't find the desired marker. - * This idea is not implemented here, in part because it makes behavior - * dependent on buffer size and chance buffer-boundary positions.) - * 3. Leave the marker unread (by failing to zero cinfo->unread_marker). - * This will cause the entropy decoder to process an empty data segment, - * inserting dummy zeroes, and then we will reprocess the marker. - * - * #2 is appropriate if we think the desired marker lies ahead, while #3 is - * appropriate if the found marker is a future restart marker (indicating - * that we have missed the desired restart marker, probably because it got - * corrupted). - * We apply #2 or #3 if the found marker is a restart marker no more than - * two counts behind or ahead of the expected one. We also apply #2 if the - * found marker is not a legal JPEG marker code (it's certainly bogus data). - * If the found marker is a restart marker more than 2 counts away, we do #1 - * (too much risk that the marker is erroneous; with luck we will be able to - * resync at some future point). - * For any valid non-restart JPEG marker, we apply #3. This keeps us from - * overrunning the end of a scan. An implementation limited to single-scan - * files might find it better to apply #2 for markers other than EOI, since - * any other marker would have to be bogus data in that case. - */ - -GLOBAL(boolean) -jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired) -{ - int marker = cinfo->unread_marker; - int action = 1; - - /* Always put up a warning. */ - WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired); - - /* Outer loop handles repeated decision after scanning forward. */ - for (;;) { - if (marker < (int) M_SOF0) - action = 2; /* invalid marker */ - else if (marker < (int) M_RST0 || marker > (int) M_RST7) - action = 3; /* valid non-restart marker */ - else { - if (marker == ((int) M_RST0 + ((desired+1) & 7)) || - marker == ((int) M_RST0 + ((desired+2) & 7))) - action = 3; /* one of the next two expected restarts */ - else if (marker == ((int) M_RST0 + ((desired-1) & 7)) || - marker == ((int) M_RST0 + ((desired-2) & 7))) - action = 2; /* a prior restart, so advance */ - else - action = 1; /* desired restart or too far away */ - } - TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action); - switch (action) { - case 1: - /* Discard marker and let entropy decoder resume processing. */ - cinfo->unread_marker = 0; - return TRUE; - case 2: - /* Scan to the next marker, and repeat the decision loop. */ - if (! next_marker(cinfo)) - return FALSE; - marker = cinfo->unread_marker; - break; - case 3: - /* Return without advancing past this marker. */ - /* Entropy decoder will be forced to process an empty segment. */ - return TRUE; - } - } /* end loop */ -} - - -/* - * Reset marker processing state to begin a fresh datastream. - */ - -METHODDEF(void) -reset_marker_reader (j_decompress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - cinfo->comp_info = NULL; /* until allocated by get_sof */ - cinfo->input_scan_number = 0; /* no SOS seen yet */ - cinfo->unread_marker = 0; /* no pending marker */ - marker->pub.saw_SOI = FALSE; /* set internal state too */ - marker->pub.saw_SOF = FALSE; - marker->pub.discarded_bytes = 0; - marker->cur_marker = NULL; -} - - -/* - * Initialize the marker reader module. - * This is called only once, when the decompression object is created. - */ - -GLOBAL(void) -jinit_marker_reader (j_decompress_ptr cinfo) -{ - my_marker_ptr marker; - int i; - - /* Create subobject in permanent pool */ - marker = (my_marker_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_marker_reader)); - cinfo->marker = (struct jpeg_marker_reader *) marker; - /* Initialize public method pointers */ - marker->pub.reset_marker_reader = reset_marker_reader; - marker->pub.read_markers = read_markers; - marker->pub.read_restart_marker = read_restart_marker; - /* Initialize COM/APPn processing. - * By default, we examine and then discard APP0 and APP14, - * but simply discard COM and all other APPn. - */ - marker->process_COM = skip_variable; - marker->length_limit_COM = 0; - for (i = 0; i < 16; i++) { - marker->process_APPn[i] = skip_variable; - marker->length_limit_APPn[i] = 0; - } - marker->process_APPn[0] = get_interesting_appn; - marker->process_APPn[14] = get_interesting_appn; - /* Reset marker processing state */ - reset_marker_reader(cinfo); -} - - -/* - * Control saving of COM and APPn markers into marker_list. - */ - -#ifdef SAVE_MARKERS_SUPPORTED - -GLOBAL(void) -jpeg_save_markers (j_decompress_ptr cinfo, int marker_code, - unsigned int length_limit) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - long maxlength; - jpeg_marker_parser_method processor; - - /* Length limit mustn't be larger than what we can allocate - * (should only be a concern in a 16-bit environment). - */ - maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct); - if (((long) length_limit) > maxlength) - length_limit = (unsigned int) maxlength; - - /* Choose processor routine to use. - * APP0/APP14 have special requirements. - */ - if (length_limit) { - processor = save_marker; - /* If saving APP0/APP14, save at least enough for our internal use. */ - if (marker_code == (int) M_APP0 && length_limit < APP0_DATA_LEN) - length_limit = APP0_DATA_LEN; - else if (marker_code == (int) M_APP14 && length_limit < APP14_DATA_LEN) - length_limit = APP14_DATA_LEN; - } else { - processor = skip_variable; - /* If discarding APP0/APP14, use our regular on-the-fly processor. */ - if (marker_code == (int) M_APP0 || marker_code == (int) M_APP14) - processor = get_interesting_appn; - } - - if (marker_code == (int) M_COM) { - marker->process_COM = processor; - marker->length_limit_COM = length_limit; - } else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) { - marker->process_APPn[marker_code - (int) M_APP0] = processor; - marker->length_limit_APPn[marker_code - (int) M_APP0] = length_limit; - } else - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); -} - -#endif /* SAVE_MARKERS_SUPPORTED */ - - -/* - * Install a special processing method for COM or APPn markers. - */ - -GLOBAL(void) -jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code, - jpeg_marker_parser_method routine) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - if (marker_code == (int) M_COM) - marker->process_COM = routine; - else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) - marker->process_APPn[marker_code - (int) M_APP0] = routine; - else - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); -} +/* + * jdmarker.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to decode JPEG datastream markers. + * Most of the complexity arises from our desire to support input + * suspension: if not all of the data for a marker is available, + * we must exit back to the application. On resumption, we reprocess + * the marker. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +typedef enum { /* JPEG marker codes */ + M_SOF0 = 0xc0, + M_SOF1 = 0xc1, + M_SOF2 = 0xc2, + M_SOF3 = 0xc3, + + M_SOF5 = 0xc5, + M_SOF6 = 0xc6, + M_SOF7 = 0xc7, + + M_JPG = 0xc8, + M_SOF9 = 0xc9, + M_SOF10 = 0xca, + M_SOF11 = 0xcb, + + M_SOF13 = 0xcd, + M_SOF14 = 0xce, + M_SOF15 = 0xcf, + + M_DHT = 0xc4, + + M_DAC = 0xcc, + + M_RST0 = 0xd0, + M_RST1 = 0xd1, + M_RST2 = 0xd2, + M_RST3 = 0xd3, + M_RST4 = 0xd4, + M_RST5 = 0xd5, + M_RST6 = 0xd6, + M_RST7 = 0xd7, + + M_SOI = 0xd8, + M_EOI = 0xd9, + M_SOS = 0xda, + M_DQT = 0xdb, + M_DNL = 0xdc, + M_DRI = 0xdd, + M_DHP = 0xde, + M_EXP = 0xdf, + + M_APP0 = 0xe0, + M_APP1 = 0xe1, + M_APP2 = 0xe2, + M_APP3 = 0xe3, + M_APP4 = 0xe4, + M_APP5 = 0xe5, + M_APP6 = 0xe6, + M_APP7 = 0xe7, + M_APP8 = 0xe8, + M_APP9 = 0xe9, + M_APP10 = 0xea, + M_APP11 = 0xeb, + M_APP12 = 0xec, + M_APP13 = 0xed, + M_APP14 = 0xee, + M_APP15 = 0xef, + + M_JPG0 = 0xf0, + M_JPG13 = 0xfd, + M_COM = 0xfe, + + M_TEM = 0x01, + + M_ERROR = 0x100 +} JPEG_MARKER; + + +/* Private state */ + +typedef struct { + struct jpeg_marker_reader pub; /* public fields */ + + /* Application-overridable marker processing methods */ + jpeg_marker_parser_method process_COM; + jpeg_marker_parser_method process_APPn[16]; + + /* Limit on marker data length to save for each marker type */ + unsigned int length_limit_COM; + unsigned int length_limit_APPn[16]; + + /* Status of COM/APPn marker saving */ + jpeg_saved_marker_ptr cur_marker; /* NULL if not processing a marker */ + unsigned int bytes_read; /* data bytes read so far in marker */ + /* Note: cur_marker is not linked into marker_list until it's all read. */ +} my_marker_reader; + +typedef my_marker_reader * my_marker_ptr; + + +/* + * Macros for fetching data from the data source module. + * + * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect + * the current restart point; we update them only when we have reached a + * suitable place to restart if a suspension occurs. + */ + +/* Declare and initialize local copies of input pointer/count */ +#define INPUT_VARS(cinfo) \ + struct jpeg_source_mgr * datasrc = (cinfo)->src; \ + const JOCTET * next_input_byte = datasrc->next_input_byte; \ + size_t bytes_in_buffer = datasrc->bytes_in_buffer + +/* Unload the local copies --- do this only at a restart boundary */ +#define INPUT_SYNC(cinfo) \ + ( datasrc->next_input_byte = next_input_byte, \ + datasrc->bytes_in_buffer = bytes_in_buffer ) + +/* Reload the local copies --- used only in MAKE_BYTE_AVAIL */ +#define INPUT_RELOAD(cinfo) \ + ( next_input_byte = datasrc->next_input_byte, \ + bytes_in_buffer = datasrc->bytes_in_buffer ) + +/* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available. + * Note we do *not* do INPUT_SYNC before calling fill_input_buffer, + * but we must reload the local copies after a successful fill. + */ +#define MAKE_BYTE_AVAIL(cinfo,action) \ + if (bytes_in_buffer == 0) { \ + if (! (*datasrc->fill_input_buffer) (cinfo)) \ + { action; } \ + INPUT_RELOAD(cinfo); \ + } + +/* Read a byte into variable V. + * If must suspend, take the specified action (typically "return FALSE"). + */ +#define INPUT_BYTE(cinfo,V,action) \ + MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ + bytes_in_buffer--; \ + V = GETJOCTET(*next_input_byte++); ) + +/* As above, but read two bytes interpreted as an unsigned 16-bit integer. + * V should be declared unsigned int or perhaps INT32. + */ +#define INPUT_2BYTES(cinfo,V,action) \ + MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ + bytes_in_buffer--; \ + V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \ + MAKE_BYTE_AVAIL(cinfo,action); \ + bytes_in_buffer--; \ + V += GETJOCTET(*next_input_byte++); ) + + +/* + * Routines to process JPEG markers. + * + * Entry condition: JPEG marker itself has been read and its code saved + * in cinfo->unread_marker; input restart point is just after the marker. + * + * Exit: if return TRUE, have read and processed any parameters, and have + * updated the restart point to point after the parameters. + * If return FALSE, was forced to suspend before reaching end of + * marker parameters; restart point has not been moved. Same routine + * will be called again after application supplies more input data. + * + * This approach to suspension assumes that all of a marker's parameters + * can fit into a single input bufferload. This should hold for "normal" + * markers. Some COM/APPn markers might have large parameter segments + * that might not fit. If we are simply dropping such a marker, we use + * skip_input_data to get past it, and thereby put the problem on the + * source manager's shoulders. If we are saving the marker's contents + * into memory, we use a slightly different convention: when forced to + * suspend, the marker processor updates the restart point to the end of + * what it's consumed (ie, the end of the buffer) before returning FALSE. + * On resumption, cinfo->unread_marker still contains the marker code, + * but the data source will point to the next chunk of marker data. + * The marker processor must retain internal state to deal with this. + * + * Note that we don't bother to avoid duplicate trace messages if a + * suspension occurs within marker parameters. Other side effects + * require more care. + */ + + +LOCAL(boolean) +get_soi (j_decompress_ptr cinfo) +/* Process an SOI marker */ +{ + int i; + + TRACEMS(cinfo, 1, JTRC_SOI); + + if (cinfo->marker->saw_SOI) + ERREXIT(cinfo, JERR_SOI_DUPLICATE); + + /* Reset all parameters that are defined to be reset by SOI */ + + for (i = 0; i < NUM_ARITH_TBLS; i++) { + cinfo->arith_dc_L[i] = 0; + cinfo->arith_dc_U[i] = 1; + cinfo->arith_ac_K[i] = 5; + } + cinfo->restart_interval = 0; + + /* Set initial assumptions for colorspace etc */ + + cinfo->jpeg_color_space = JCS_UNKNOWN; + cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */ + + cinfo->saw_JFIF_marker = FALSE; + cinfo->JFIF_major_version = 1; /* set default JFIF APP0 values */ + cinfo->JFIF_minor_version = 1; + cinfo->density_unit = 0; + cinfo->X_density = 1; + cinfo->Y_density = 1; + cinfo->saw_Adobe_marker = FALSE; + cinfo->Adobe_transform = 0; + + cinfo->marker->saw_SOI = TRUE; + + return TRUE; +} + + +LOCAL(boolean) +get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith) +/* Process a SOFn marker */ +{ + INT32 length; + int c, ci; + jpeg_component_info * compptr; + INPUT_VARS(cinfo); + + cinfo->progressive_mode = is_prog; + cinfo->arith_code = is_arith; + + INPUT_2BYTES(cinfo, length, return FALSE); + + INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE); + INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE); + INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE); + INPUT_BYTE(cinfo, cinfo->num_components, return FALSE); + + length -= 8; + + TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker, + (int) cinfo->image_width, (int) cinfo->image_height, + cinfo->num_components); + + if (cinfo->marker->saw_SOF) + ERREXIT(cinfo, JERR_SOF_DUPLICATE); + + /* We don't support files in which the image height is initially specified */ + /* as 0 and is later redefined by DNL. As long as we have to check that, */ + /* might as well have a general sanity check. */ + if (cinfo->image_height <= 0 || cinfo->image_width <= 0 + || cinfo->num_components <= 0) + ERREXIT(cinfo, JERR_EMPTY_IMAGE); + + if (length != (cinfo->num_components * 3)) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + if (cinfo->comp_info == NULL) /* do only once, even if suspend */ + cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components * SIZEOF(jpeg_component_info)); + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + compptr->component_index = ci; + INPUT_BYTE(cinfo, compptr->component_id, return FALSE); + INPUT_BYTE(cinfo, c, return FALSE); + compptr->h_samp_factor = (c >> 4) & 15; + compptr->v_samp_factor = (c ) & 15; + INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE); + + TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT, + compptr->component_id, compptr->h_samp_factor, + compptr->v_samp_factor, compptr->quant_tbl_no); + } + + cinfo->marker->saw_SOF = TRUE; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +get_sos (j_decompress_ptr cinfo) +/* Process a SOS marker */ +{ + INT32 length; + int i, ci, n, c, cc; + jpeg_component_info * compptr; + INPUT_VARS(cinfo); + + if (! cinfo->marker->saw_SOF) + ERREXIT(cinfo, JERR_SOS_NO_SOF); + + INPUT_2BYTES(cinfo, length, return FALSE); + + INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */ + + TRACEMS1(cinfo, 1, JTRC_SOS, n); + + if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + cinfo->comps_in_scan = n; + + /* Collect the component-spec parameters */ + + for (i = 0; i < n; i++) { + INPUT_BYTE(cinfo, cc, return FALSE); + INPUT_BYTE(cinfo, c, return FALSE); + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (cc == compptr->component_id) + goto id_found; + } + + ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc); + + id_found: + + cinfo->cur_comp_info[i] = compptr; + compptr->dc_tbl_no = (c >> 4) & 15; + compptr->ac_tbl_no = (c ) & 15; + + TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc, + compptr->dc_tbl_no, compptr->ac_tbl_no); + } + + /* Collect the additional scan parameters Ss, Se, Ah/Al. */ + INPUT_BYTE(cinfo, c, return FALSE); + cinfo->Ss = c; + INPUT_BYTE(cinfo, c, return FALSE); + cinfo->Se = c; + INPUT_BYTE(cinfo, c, return FALSE); + cinfo->Ah = (c >> 4) & 15; + cinfo->Al = (c ) & 15; + + TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se, + cinfo->Ah, cinfo->Al); + + /* Prepare to scan data & restart markers */ + cinfo->marker->next_restart_num = 0; + + /* Count another SOS marker */ + cinfo->input_scan_number++; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +#ifdef D_ARITH_CODING_SUPPORTED + +LOCAL(boolean) +get_dac (j_decompress_ptr cinfo) +/* Process a DAC marker */ +{ + INT32 length; + int index, val; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + while (length > 0) { + INPUT_BYTE(cinfo, index, return FALSE); + INPUT_BYTE(cinfo, val, return FALSE); + + length -= 2; + + TRACEMS2(cinfo, 1, JTRC_DAC, index, val); + + if (index < 0 || index >= (2*NUM_ARITH_TBLS)) + ERREXIT1(cinfo, JERR_DAC_INDEX, index); + + if (index >= NUM_ARITH_TBLS) { /* define AC table */ + cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val; + } else { /* define DC table */ + cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F); + cinfo->arith_dc_U[index] = (UINT8) (val >> 4); + if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index]) + ERREXIT1(cinfo, JERR_DAC_VALUE, val); + } + } + + if (length != 0) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + INPUT_SYNC(cinfo); + return TRUE; +} + +#else /* ! D_ARITH_CODING_SUPPORTED */ + +#define get_dac(cinfo) skip_variable(cinfo) + +#endif /* D_ARITH_CODING_SUPPORTED */ + + +LOCAL(boolean) +get_dht (j_decompress_ptr cinfo) +/* Process a DHT marker */ +{ + INT32 length; + UINT8 bits[17]; + UINT8 huffval[256]; + int i, index, count; + JHUFF_TBL **htblptr; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + while (length > 16) { + INPUT_BYTE(cinfo, index, return FALSE); + + TRACEMS1(cinfo, 1, JTRC_DHT, index); + + bits[0] = 0; + count = 0; + for (i = 1; i <= 16; i++) { + INPUT_BYTE(cinfo, bits[i], return FALSE); + count += bits[i]; + } + + length -= 1 + 16; + + TRACEMS8(cinfo, 2, JTRC_HUFFBITS, + bits[1], bits[2], bits[3], bits[4], + bits[5], bits[6], bits[7], bits[8]); + TRACEMS8(cinfo, 2, JTRC_HUFFBITS, + bits[9], bits[10], bits[11], bits[12], + bits[13], bits[14], bits[15], bits[16]); + + /* Here we just do minimal validation of the counts to avoid walking + * off the end of our table space. jdhuff.c will check more carefully. + */ + if (count > 256 || ((INT32) count) > length) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + + for (i = 0; i < count; i++) + INPUT_BYTE(cinfo, huffval[i], return FALSE); + + length -= count; + + if (index & 0x10) { /* AC table definition */ + index -= 0x10; + htblptr = &cinfo->ac_huff_tbl_ptrs[index]; + } else { /* DC table definition */ + htblptr = &cinfo->dc_huff_tbl_ptrs[index]; + } + + if (index < 0 || index >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_DHT_INDEX, index); + + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + + MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); + MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval)); + } + + if (length != 0) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +get_dqt (j_decompress_ptr cinfo) +/* Process a DQT marker */ +{ + INT32 length; + int n, i, prec; + unsigned int tmp; + JQUANT_TBL *quant_ptr; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + while (length > 0) { + INPUT_BYTE(cinfo, n, return FALSE); + prec = n >> 4; + n &= 0x0F; + + TRACEMS2(cinfo, 1, JTRC_DQT, n, prec); + + if (n >= NUM_QUANT_TBLS) + ERREXIT1(cinfo, JERR_DQT_INDEX, n); + + if (cinfo->quant_tbl_ptrs[n] == NULL) + cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo); + quant_ptr = cinfo->quant_tbl_ptrs[n]; + + for (i = 0; i < DCTSIZE2; i++) { + if (prec) + INPUT_2BYTES(cinfo, tmp, return FALSE); + else + INPUT_BYTE(cinfo, tmp, return FALSE); + /* We convert the zigzag-order table to natural array order. */ + quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16) tmp; + } + + if (cinfo->err->trace_level >= 2) { + for (i = 0; i < DCTSIZE2; i += 8) { + TRACEMS8(cinfo, 2, JTRC_QUANTVALS, + quant_ptr->quantval[i], quant_ptr->quantval[i+1], + quant_ptr->quantval[i+2], quant_ptr->quantval[i+3], + quant_ptr->quantval[i+4], quant_ptr->quantval[i+5], + quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]); + } + } + + length -= DCTSIZE2+1; + if (prec) length -= DCTSIZE2; + } + + if (length != 0) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +get_dri (j_decompress_ptr cinfo) +/* Process a DRI marker */ +{ + INT32 length; + unsigned int tmp; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + + if (length != 4) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + INPUT_2BYTES(cinfo, tmp, return FALSE); + + TRACEMS1(cinfo, 1, JTRC_DRI, tmp); + + cinfo->restart_interval = tmp; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +/* + * Routines for processing APPn and COM markers. + * These are either saved in memory or discarded, per application request. + * APP0 and APP14 are specially checked to see if they are + * JFIF and Adobe markers, respectively. + */ + +#define APP0_DATA_LEN 14 /* Length of interesting data in APP0 */ +#define APP14_DATA_LEN 12 /* Length of interesting data in APP14 */ +#define APPN_DATA_LEN 14 /* Must be the largest of the above!! */ + + +LOCAL(void) +examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data, + unsigned int datalen, INT32 remaining) +/* Examine first few bytes from an APP0. + * Take appropriate action if it is a JFIF marker. + * datalen is # of bytes at data[], remaining is length of rest of marker data. + */ +{ + INT32 totallen = (INT32) datalen + remaining; + + if (datalen >= APP0_DATA_LEN && + GETJOCTET(data[0]) == 0x4A && + GETJOCTET(data[1]) == 0x46 && + GETJOCTET(data[2]) == 0x49 && + GETJOCTET(data[3]) == 0x46 && + GETJOCTET(data[4]) == 0) { + /* Found JFIF APP0 marker: save info */ + cinfo->saw_JFIF_marker = TRUE; + cinfo->JFIF_major_version = GETJOCTET(data[5]); + cinfo->JFIF_minor_version = GETJOCTET(data[6]); + cinfo->density_unit = GETJOCTET(data[7]); + cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]); + cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]); + /* Check version. + * Major version must be 1, anything else signals an incompatible change. + * (We used to treat this as an error, but now it's a nonfatal warning, + * because some bozo at Hijaak couldn't read the spec.) + * Minor version should be 0..2, but process anyway if newer. + */ + if (cinfo->JFIF_major_version != 1) + WARNMS2(cinfo, JWRN_JFIF_MAJOR, + cinfo->JFIF_major_version, cinfo->JFIF_minor_version); + /* Generate trace messages */ + TRACEMS5(cinfo, 1, JTRC_JFIF, + cinfo->JFIF_major_version, cinfo->JFIF_minor_version, + cinfo->X_density, cinfo->Y_density, cinfo->density_unit); + /* Validate thumbnail dimensions and issue appropriate messages */ + if (GETJOCTET(data[12]) | GETJOCTET(data[13])) + TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, + GETJOCTET(data[12]), GETJOCTET(data[13])); + totallen -= APP0_DATA_LEN; + if (totallen != + ((INT32)GETJOCTET(data[12]) * (INT32)GETJOCTET(data[13]) * (INT32) 3)) + TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen); + } else if (datalen >= 6 && + GETJOCTET(data[0]) == 0x4A && + GETJOCTET(data[1]) == 0x46 && + GETJOCTET(data[2]) == 0x58 && + GETJOCTET(data[3]) == 0x58 && + GETJOCTET(data[4]) == 0) { + /* Found JFIF "JFXX" extension APP0 marker */ + /* The library doesn't actually do anything with these, + * but we try to produce a helpful trace message. + */ + switch (GETJOCTET(data[5])) { + case 0x10: + TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen); + break; + case 0x11: + TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen); + break; + case 0x13: + TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen); + break; + default: + TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION, + GETJOCTET(data[5]), (int) totallen); + break; + } + } else { + /* Start of APP0 does not match "JFIF" or "JFXX", or too short */ + TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen); + } +} + + +LOCAL(void) +examine_app14 (j_decompress_ptr cinfo, JOCTET FAR * data, + unsigned int datalen, INT32 remaining) +/* Examine first few bytes from an APP14. + * Take appropriate action if it is an Adobe marker. + * datalen is # of bytes at data[], remaining is length of rest of marker data. + */ +{ + unsigned int version, flags0, flags1, transform; + + if (datalen >= APP14_DATA_LEN && + GETJOCTET(data[0]) == 0x41 && + GETJOCTET(data[1]) == 0x64 && + GETJOCTET(data[2]) == 0x6F && + GETJOCTET(data[3]) == 0x62 && + GETJOCTET(data[4]) == 0x65) { + /* Found Adobe APP14 marker */ + version = (GETJOCTET(data[5]) << 8) + GETJOCTET(data[6]); + flags0 = (GETJOCTET(data[7]) << 8) + GETJOCTET(data[8]); + flags1 = (GETJOCTET(data[9]) << 8) + GETJOCTET(data[10]); + transform = GETJOCTET(data[11]); + TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform); + cinfo->saw_Adobe_marker = TRUE; + cinfo->Adobe_transform = (UINT8) transform; + } else { + /* Start of APP14 does not match "Adobe", or too short */ + TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining)); + } +} + + +METHODDEF(boolean) +get_interesting_appn (j_decompress_ptr cinfo) +/* Process an APP0 or APP14 marker without saving it */ +{ + INT32 length; + JOCTET b[APPN_DATA_LEN]; + unsigned int i, numtoread; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + /* get the interesting part of the marker data */ + if (length >= APPN_DATA_LEN) + numtoread = APPN_DATA_LEN; + else if (length > 0) + numtoread = (unsigned int) length; + else + numtoread = 0; + for (i = 0; i < numtoread; i++) + INPUT_BYTE(cinfo, b[i], return FALSE); + length -= numtoread; + + /* process it */ + switch (cinfo->unread_marker) { + case M_APP0: + examine_app0(cinfo, (JOCTET FAR *) b, numtoread, length); + break; + case M_APP14: + examine_app14(cinfo, (JOCTET FAR *) b, numtoread, length); + break; + default: + /* can't get here unless jpeg_save_markers chooses wrong processor */ + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); + break; + } + + /* skip any remaining data -- could be lots */ + INPUT_SYNC(cinfo); + if (length > 0) + (*cinfo->src->skip_input_data) (cinfo, (long) length); + + return TRUE; +} + + +#ifdef SAVE_MARKERS_SUPPORTED + +METHODDEF(boolean) +save_marker (j_decompress_ptr cinfo) +/* Save an APPn or COM marker into the marker list */ +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + jpeg_saved_marker_ptr cur_marker = marker->cur_marker; + unsigned int bytes_read, data_length; + JOCTET FAR * data; + INT32 length = 0; + INPUT_VARS(cinfo); + + if (cur_marker == NULL) { + /* begin reading a marker */ + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + if (length >= 0) { /* watch out for bogus length word */ + /* figure out how much we want to save */ + unsigned int limit; + if (cinfo->unread_marker == (int) M_COM) + limit = marker->length_limit_COM; + else + limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0]; + if ((unsigned int) length < limit) + limit = (unsigned int) length; + /* allocate and initialize the marker item */ + cur_marker = (jpeg_saved_marker_ptr) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(struct jpeg_marker_struct) + limit); + cur_marker->next = NULL; + cur_marker->marker = (UINT8) cinfo->unread_marker; + cur_marker->original_length = (unsigned int) length; + cur_marker->data_length = limit; + /* data area is just beyond the jpeg_marker_struct */ + data = cur_marker->data = (JOCTET FAR *) (cur_marker + 1); + marker->cur_marker = cur_marker; + marker->bytes_read = 0; + bytes_read = 0; + data_length = limit; + } else { + /* deal with bogus length word */ + bytes_read = data_length = 0; + data = NULL; + } + } else { + /* resume reading a marker */ + bytes_read = marker->bytes_read; + data_length = cur_marker->data_length; + data = cur_marker->data + bytes_read; + } + + while (bytes_read < data_length) { + INPUT_SYNC(cinfo); /* move the restart point to here */ + marker->bytes_read = bytes_read; + /* If there's not at least one byte in buffer, suspend */ + MAKE_BYTE_AVAIL(cinfo, return FALSE); + /* Copy bytes with reasonable rapidity */ + while (bytes_read < data_length && bytes_in_buffer > 0) { + *data++ = *next_input_byte++; + bytes_in_buffer--; + bytes_read++; + } + } + + /* Done reading what we want to read */ + if (cur_marker != NULL) { /* will be NULL if bogus length word */ + /* Add new marker to end of list */ + if (cinfo->marker_list == NULL) { + cinfo->marker_list = cur_marker; + } else { + jpeg_saved_marker_ptr prev = cinfo->marker_list; + while (prev->next != NULL) + prev = prev->next; + prev->next = cur_marker; + } + /* Reset pointer & calc remaining data length */ + data = cur_marker->data; + length = cur_marker->original_length - data_length; + } + /* Reset to initial state for next marker */ + marker->cur_marker = NULL; + + /* Process the marker if interesting; else just make a generic trace msg */ + switch (cinfo->unread_marker) { + case M_APP0: + examine_app0(cinfo, data, data_length, length); + break; + case M_APP14: + examine_app14(cinfo, data, data_length, length); + break; + default: + TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, + (int) (data_length + length)); + break; + } + + /* skip any remaining data -- could be lots */ + INPUT_SYNC(cinfo); /* do before skip_input_data */ + if (length > 0) + (*cinfo->src->skip_input_data) (cinfo, (long) length); + + return TRUE; +} + +#endif /* SAVE_MARKERS_SUPPORTED */ + + +METHODDEF(boolean) +skip_variable (j_decompress_ptr cinfo) +/* Skip over an unknown or uninteresting variable-length marker */ +{ + INT32 length; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length); + + INPUT_SYNC(cinfo); /* do before skip_input_data */ + if (length > 0) + (*cinfo->src->skip_input_data) (cinfo, (long) length); + + return TRUE; +} + + +/* + * Find the next JPEG marker, save it in cinfo->unread_marker. + * Returns FALSE if had to suspend before reaching a marker; + * in that case cinfo->unread_marker is unchanged. + * + * Note that the result might not be a valid marker code, + * but it will never be 0 or FF. + */ + +LOCAL(boolean) +next_marker (j_decompress_ptr cinfo) +{ + int c; + INPUT_VARS(cinfo); + + for (;;) { + INPUT_BYTE(cinfo, c, return FALSE); + /* Skip any non-FF bytes. + * This may look a bit inefficient, but it will not occur in a valid file. + * We sync after each discarded byte so that a suspending data source + * can discard the byte from its buffer. + */ + while (c != 0xFF) { + cinfo->marker->discarded_bytes++; + INPUT_SYNC(cinfo); + INPUT_BYTE(cinfo, c, return FALSE); + } + /* This loop swallows any duplicate FF bytes. Extra FFs are legal as + * pad bytes, so don't count them in discarded_bytes. We assume there + * will not be so many consecutive FF bytes as to overflow a suspending + * data source's input buffer. + */ + do { + INPUT_BYTE(cinfo, c, return FALSE); + } while (c == 0xFF); + if (c != 0) + break; /* found a valid marker, exit loop */ + /* Reach here if we found a stuffed-zero data sequence (FF/00). + * Discard it and loop back to try again. + */ + cinfo->marker->discarded_bytes += 2; + INPUT_SYNC(cinfo); + } + + if (cinfo->marker->discarded_bytes != 0) { + WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c); + cinfo->marker->discarded_bytes = 0; + } + + cinfo->unread_marker = c; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +first_marker (j_decompress_ptr cinfo) +/* Like next_marker, but used to obtain the initial SOI marker. */ +/* For this marker, we do not allow preceding garbage or fill; otherwise, + * we might well scan an entire input file before realizing it ain't JPEG. + * If an application wants to process non-JFIF files, it must seek to the + * SOI before calling the JPEG library. + */ +{ + int c, c2; + INPUT_VARS(cinfo); + + INPUT_BYTE(cinfo, c, return FALSE); + INPUT_BYTE(cinfo, c2, return FALSE); + if (c != 0xFF || c2 != (int) M_SOI) + ERREXIT2(cinfo, JERR_NO_SOI, c, c2); + + cinfo->unread_marker = c2; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +/* + * Read markers until SOS or EOI. + * + * Returns same codes as are defined for jpeg_consume_input: + * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. + */ + +METHODDEF(int) +read_markers (j_decompress_ptr cinfo) +{ + /* Outer loop repeats once for each marker. */ + for (;;) { + /* Collect the marker proper, unless we already did. */ + /* NB: first_marker() enforces the requirement that SOI appear first. */ + if (cinfo->unread_marker == 0) { + if (! cinfo->marker->saw_SOI) { + if (! first_marker(cinfo)) + return JPEG_SUSPENDED; + } else { + if (! next_marker(cinfo)) + return JPEG_SUSPENDED; + } + } + /* At this point cinfo->unread_marker contains the marker code and the + * input point is just past the marker proper, but before any parameters. + * A suspension will cause us to return with this state still true. + */ + switch (cinfo->unread_marker) { + case M_SOI: + if (! get_soi(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_SOF0: /* Baseline */ + case M_SOF1: /* Extended sequential, Huffman */ + if (! get_sof(cinfo, FALSE, FALSE)) + return JPEG_SUSPENDED; + break; + + case M_SOF2: /* Progressive, Huffman */ + if (! get_sof(cinfo, TRUE, FALSE)) + return JPEG_SUSPENDED; + break; + + case M_SOF9: /* Extended sequential, arithmetic */ + if (! get_sof(cinfo, FALSE, TRUE)) + return JPEG_SUSPENDED; + break; + + case M_SOF10: /* Progressive, arithmetic */ + if (! get_sof(cinfo, TRUE, TRUE)) + return JPEG_SUSPENDED; + break; + + /* Currently unsupported SOFn types */ + case M_SOF3: /* Lossless, Huffman */ + case M_SOF5: /* Differential sequential, Huffman */ + case M_SOF6: /* Differential progressive, Huffman */ + case M_SOF7: /* Differential lossless, Huffman */ + case M_JPG: /* Reserved for JPEG extensions */ + case M_SOF11: /* Lossless, arithmetic */ + case M_SOF13: /* Differential sequential, arithmetic */ + case M_SOF14: /* Differential progressive, arithmetic */ + case M_SOF15: /* Differential lossless, arithmetic */ + ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker); + break; + + case M_SOS: + if (! get_sos(cinfo)) + return JPEG_SUSPENDED; + cinfo->unread_marker = 0; /* processed the marker */ + return JPEG_REACHED_SOS; + + case M_EOI: + TRACEMS(cinfo, 1, JTRC_EOI); + cinfo->unread_marker = 0; /* processed the marker */ + return JPEG_REACHED_EOI; + + case M_DAC: + if (! get_dac(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_DHT: + if (! get_dht(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_DQT: + if (! get_dqt(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_DRI: + if (! get_dri(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_APP0: + case M_APP1: + case M_APP2: + case M_APP3: + case M_APP4: + case M_APP5: + case M_APP6: + case M_APP7: + case M_APP8: + case M_APP9: + case M_APP10: + case M_APP11: + case M_APP12: + case M_APP13: + case M_APP14: + case M_APP15: + if (! (*((my_marker_ptr) cinfo->marker)->process_APPn[ + cinfo->unread_marker - (int) M_APP0]) (cinfo)) + return JPEG_SUSPENDED; + break; + + case M_COM: + if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo)) + return JPEG_SUSPENDED; + break; + + case M_RST0: /* these are all parameterless */ + case M_RST1: + case M_RST2: + case M_RST3: + case M_RST4: + case M_RST5: + case M_RST6: + case M_RST7: + case M_TEM: + TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker); + break; + + case M_DNL: /* Ignore DNL ... perhaps the wrong thing */ + if (! skip_variable(cinfo)) + return JPEG_SUSPENDED; + break; + + default: /* must be DHP, EXP, JPGn, or RESn */ + /* For now, we treat the reserved markers as fatal errors since they are + * likely to be used to signal incompatible JPEG Part 3 extensions. + * Once the JPEG 3 version-number marker is well defined, this code + * ought to change! + */ + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); + break; + } + /* Successfully processed marker, so reset state variable */ + cinfo->unread_marker = 0; + } /* end loop */ +} + + +/* + * Read a restart marker, which is expected to appear next in the datastream; + * if the marker is not there, take appropriate recovery action. + * Returns FALSE if suspension is required. + * + * This is called by the entropy decoder after it has read an appropriate + * number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder + * has already read a marker from the data source. Under normal conditions + * cinfo->unread_marker will be reset to 0 before returning; if not reset, + * it holds a marker which the decoder will be unable to read past. + */ + +METHODDEF(boolean) +read_restart_marker (j_decompress_ptr cinfo) +{ + /* Obtain a marker unless we already did. */ + /* Note that next_marker will complain if it skips any data. */ + if (cinfo->unread_marker == 0) { + if (! next_marker(cinfo)) + return FALSE; + } + + if (cinfo->unread_marker == + ((int) M_RST0 + cinfo->marker->next_restart_num)) { + /* Normal case --- swallow the marker and let entropy decoder continue */ + TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num); + cinfo->unread_marker = 0; + } else { + /* Uh-oh, the restart markers have been messed up. */ + /* Let the data source manager determine how to resync. */ + if (! (*cinfo->src->resync_to_restart) (cinfo, + cinfo->marker->next_restart_num)) + return FALSE; + } + + /* Update next-restart state */ + cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7; + + return TRUE; +} + + +/* + * This is the default resync_to_restart method for data source managers + * to use if they don't have any better approach. Some data source managers + * may be able to back up, or may have additional knowledge about the data + * which permits a more intelligent recovery strategy; such managers would + * presumably supply their own resync method. + * + * read_restart_marker calls resync_to_restart if it finds a marker other than + * the restart marker it was expecting. (This code is *not* used unless + * a nonzero restart interval has been declared.) cinfo->unread_marker is + * the marker code actually found (might be anything, except 0 or FF). + * The desired restart marker number (0..7) is passed as a parameter. + * This routine is supposed to apply whatever error recovery strategy seems + * appropriate in order to position the input stream to the next data segment. + * Note that cinfo->unread_marker is treated as a marker appearing before + * the current data-source input point; usually it should be reset to zero + * before returning. + * Returns FALSE if suspension is required. + * + * This implementation is substantially constrained by wanting to treat the + * input as a data stream; this means we can't back up. Therefore, we have + * only the following actions to work with: + * 1. Simply discard the marker and let the entropy decoder resume at next + * byte of file. + * 2. Read forward until we find another marker, discarding intervening + * data. (In theory we could look ahead within the current bufferload, + * without having to discard data if we don't find the desired marker. + * This idea is not implemented here, in part because it makes behavior + * dependent on buffer size and chance buffer-boundary positions.) + * 3. Leave the marker unread (by failing to zero cinfo->unread_marker). + * This will cause the entropy decoder to process an empty data segment, + * inserting dummy zeroes, and then we will reprocess the marker. + * + * #2 is appropriate if we think the desired marker lies ahead, while #3 is + * appropriate if the found marker is a future restart marker (indicating + * that we have missed the desired restart marker, probably because it got + * corrupted). + * We apply #2 or #3 if the found marker is a restart marker no more than + * two counts behind or ahead of the expected one. We also apply #2 if the + * found marker is not a legal JPEG marker code (it's certainly bogus data). + * If the found marker is a restart marker more than 2 counts away, we do #1 + * (too much risk that the marker is erroneous; with luck we will be able to + * resync at some future point). + * For any valid non-restart JPEG marker, we apply #3. This keeps us from + * overrunning the end of a scan. An implementation limited to single-scan + * files might find it better to apply #2 for markers other than EOI, since + * any other marker would have to be bogus data in that case. + */ + +GLOBAL(boolean) +jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired) +{ + int marker = cinfo->unread_marker; + int action = 1; + + /* Always put up a warning. */ + WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired); + + /* Outer loop handles repeated decision after scanning forward. */ + for (;;) { + if (marker < (int) M_SOF0) + action = 2; /* invalid marker */ + else if (marker < (int) M_RST0 || marker > (int) M_RST7) + action = 3; /* valid non-restart marker */ + else { + if (marker == ((int) M_RST0 + ((desired+1) & 7)) || + marker == ((int) M_RST0 + ((desired+2) & 7))) + action = 3; /* one of the next two expected restarts */ + else if (marker == ((int) M_RST0 + ((desired-1) & 7)) || + marker == ((int) M_RST0 + ((desired-2) & 7))) + action = 2; /* a prior restart, so advance */ + else + action = 1; /* desired restart or too far away */ + } + TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action); + switch (action) { + case 1: + /* Discard marker and let entropy decoder resume processing. */ + cinfo->unread_marker = 0; + return TRUE; + case 2: + /* Scan to the next marker, and repeat the decision loop. */ + if (! next_marker(cinfo)) + return FALSE; + marker = cinfo->unread_marker; + break; + case 3: + /* Return without advancing past this marker. */ + /* Entropy decoder will be forced to process an empty segment. */ + return TRUE; + } + } /* end loop */ +} + + +/* + * Reset marker processing state to begin a fresh datastream. + */ + +METHODDEF(void) +reset_marker_reader (j_decompress_ptr cinfo) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + + cinfo->comp_info = NULL; /* until allocated by get_sof */ + cinfo->input_scan_number = 0; /* no SOS seen yet */ + cinfo->unread_marker = 0; /* no pending marker */ + marker->pub.saw_SOI = FALSE; /* set internal state too */ + marker->pub.saw_SOF = FALSE; + marker->pub.discarded_bytes = 0; + marker->cur_marker = NULL; +} + + +/* + * Initialize the marker reader module. + * This is called only once, when the decompression object is created. + */ + +GLOBAL(void) +jinit_marker_reader (j_decompress_ptr cinfo) +{ + my_marker_ptr marker; + int i; + + /* Create subobject in permanent pool */ + marker = (my_marker_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + SIZEOF(my_marker_reader)); + cinfo->marker = (struct jpeg_marker_reader *) marker; + /* Initialize public method pointers */ + marker->pub.reset_marker_reader = reset_marker_reader; + marker->pub.read_markers = read_markers; + marker->pub.read_restart_marker = read_restart_marker; + /* Initialize COM/APPn processing. + * By default, we examine and then discard APP0 and APP14, + * but simply discard COM and all other APPn. + */ + marker->process_COM = skip_variable; + marker->length_limit_COM = 0; + for (i = 0; i < 16; i++) { + marker->process_APPn[i] = skip_variable; + marker->length_limit_APPn[i] = 0; + } + marker->process_APPn[0] = get_interesting_appn; + marker->process_APPn[14] = get_interesting_appn; + /* Reset marker processing state */ + reset_marker_reader(cinfo); +} + + +/* + * Control saving of COM and APPn markers into marker_list. + */ + +#ifdef SAVE_MARKERS_SUPPORTED + +GLOBAL(void) +jpeg_save_markers (j_decompress_ptr cinfo, int marker_code, + unsigned int length_limit) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + long maxlength; + jpeg_marker_parser_method processor; + + /* Length limit mustn't be larger than what we can allocate + * (should only be a concern in a 16-bit environment). + */ + maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct); + if (((long) length_limit) > maxlength) + length_limit = (unsigned int) maxlength; + + /* Choose processor routine to use. + * APP0/APP14 have special requirements. + */ + if (length_limit) { + processor = save_marker; + /* If saving APP0/APP14, save at least enough for our internal use. */ + if (marker_code == (int) M_APP0 && length_limit < APP0_DATA_LEN) + length_limit = APP0_DATA_LEN; + else if (marker_code == (int) M_APP14 && length_limit < APP14_DATA_LEN) + length_limit = APP14_DATA_LEN; + } else { + processor = skip_variable; + /* If discarding APP0/APP14, use our regular on-the-fly processor. */ + if (marker_code == (int) M_APP0 || marker_code == (int) M_APP14) + processor = get_interesting_appn; + } + + if (marker_code == (int) M_COM) { + marker->process_COM = processor; + marker->length_limit_COM = length_limit; + } else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) { + marker->process_APPn[marker_code - (int) M_APP0] = processor; + marker->length_limit_APPn[marker_code - (int) M_APP0] = length_limit; + } else + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); +} + +#endif /* SAVE_MARKERS_SUPPORTED */ + + +/* + * Install a special processing method for COM or APPn markers. + */ + +GLOBAL(void) +jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code, + jpeg_marker_parser_method routine) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + + if (marker_code == (int) M_COM) + marker->process_COM = routine; + else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) + marker->process_APPn[marker_code - (int) M_APP0] = routine; + else + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); +} diff --git a/src/dep/src/irrlicht/jpeglib/jdmaster.c b/src/dep/src/irrlicht/jpeglib/jdmaster.c index eda4b3f..2802c5b 100644 --- a/src/dep/src/irrlicht/jpeglib/jdmaster.c +++ b/src/dep/src/irrlicht/jpeglib/jdmaster.c @@ -1,557 +1,557 @@ -/* - * jdmaster.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains master control logic for the JPEG decompressor. - * These routines are concerned with selecting the modules to be executed - * and with determining the number of passes and the work to be done in each - * pass. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef struct { - struct jpeg_decomp_master pub; /* public fields */ - - int pass_number; /* # of passes completed */ - - boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */ - - /* Saved references to initialized quantizer modules, - * in case we need to switch modes. - */ - struct jpeg_color_quantizer * quantizer_1pass; - struct jpeg_color_quantizer * quantizer_2pass; -} my_decomp_master; - -typedef my_decomp_master * my_master_ptr; - - -/* - * Determine whether merged upsample/color conversion should be used. - * CRUCIAL: this must match the actual capabilities of jdmerge.c! - */ - -LOCAL(boolean) -use_merged_upsample (j_decompress_ptr cinfo) -{ -#ifdef UPSAMPLE_MERGING_SUPPORTED - /* Merging is the equivalent of plain box-filter upsampling */ - if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling) - return FALSE; - /* jdmerge.c only supports YCC=>RGB color conversion */ - if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 || - cinfo->out_color_space != JCS_RGB || - cinfo->out_color_components != RGB_PIXELSIZE) - return FALSE; - /* and it only handles 2h1v or 2h2v sampling ratios */ - if (cinfo->comp_info[0].h_samp_factor != 2 || - cinfo->comp_info[1].h_samp_factor != 1 || - cinfo->comp_info[2].h_samp_factor != 1 || - cinfo->comp_info[0].v_samp_factor > 2 || - cinfo->comp_info[1].v_samp_factor != 1 || - cinfo->comp_info[2].v_samp_factor != 1) - return FALSE; - /* furthermore, it doesn't work if we've scaled the IDCTs differently */ - if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size || - cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size || - cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size) - return FALSE; - /* ??? also need to test for upsample-time rescaling, when & if supported */ - return TRUE; /* by golly, it'll work... */ -#else - return FALSE; -#endif -} - - -/* - * Compute output image dimensions and related values. - * NOTE: this is exported for possible use by application. - * Hence it mustn't do anything that can't be done twice. - * Also note that it may be called before the master module is initialized! - */ - -GLOBAL(void) -jpeg_calc_output_dimensions (j_decompress_ptr cinfo) -/* Do computations that are needed before master selection phase */ -{ -#ifdef IDCT_SCALING_SUPPORTED - int ci; - jpeg_component_info *compptr; -#endif - - /* Prevent application from calling me at wrong times */ - if (cinfo->global_state != DSTATE_READY) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - -#ifdef IDCT_SCALING_SUPPORTED - - /* Compute actual output image dimensions and DCT scaling choices. */ - if (cinfo->scale_num * 8 <= cinfo->scale_denom) { - /* Provide 1/8 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 8L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 8L); - cinfo->min_DCT_scaled_size = 1; - } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) { - /* Provide 1/4 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 4L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 4L); - cinfo->min_DCT_scaled_size = 2; - } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) { - /* Provide 1/2 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 2L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 2L); - cinfo->min_DCT_scaled_size = 4; - } else { - /* Provide 1/1 scaling */ - cinfo->output_width = cinfo->image_width; - cinfo->output_height = cinfo->image_height; - cinfo->min_DCT_scaled_size = DCTSIZE; - } - /* In selecting the actual DCT scaling for each component, we try to - * scale up the chroma components via IDCT scaling rather than upsampling. - * This saves time if the upsampler gets to use 1:1 scaling. - * Note this code assumes that the supported DCT scalings are powers of 2. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - int ssize = cinfo->min_DCT_scaled_size; - while (ssize < DCTSIZE && - (compptr->h_samp_factor * ssize * 2 <= - cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) && - (compptr->v_samp_factor * ssize * 2 <= - cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) { - ssize = ssize * 2; - } - compptr->DCT_scaled_size = ssize; - } - - /* Recompute downsampled dimensions of components; - * application needs to know these if using raw downsampled data. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Size in samples, after IDCT scaling */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * - (long) (compptr->h_samp_factor * compptr->DCT_scaled_size), - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * - (long) (compptr->v_samp_factor * compptr->DCT_scaled_size), - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - } - -#else /* !IDCT_SCALING_SUPPORTED */ - - /* Hardwire it to "no scaling" */ - cinfo->output_width = cinfo->image_width; - cinfo->output_height = cinfo->image_height; - /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE, - * and has computed unscaled downsampled_width and downsampled_height. - */ - -#endif /* IDCT_SCALING_SUPPORTED */ - - /* Report number of components in selected colorspace. */ - /* Probably this should be in the color conversion module... */ - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - cinfo->out_color_components = 1; - break; - case JCS_RGB: -#if RGB_PIXELSIZE != 3 - cinfo->out_color_components = RGB_PIXELSIZE; - break; -#endif /* else share code with YCbCr */ - case JCS_YCbCr: - cinfo->out_color_components = 3; - break; - case JCS_CMYK: - case JCS_YCCK: - cinfo->out_color_components = 4; - break; - default: /* else must be same colorspace as in file */ - cinfo->out_color_components = cinfo->num_components; - break; - } - cinfo->output_components = (cinfo->quantize_colors ? 1 : - cinfo->out_color_components); - - /* See if upsampler will want to emit more than one row at a time */ - if (use_merged_upsample(cinfo)) - cinfo->rec_outbuf_height = cinfo->max_v_samp_factor; - else - cinfo->rec_outbuf_height = 1; -} - - -/* - * Several decompression processes need to range-limit values to the range - * 0..MAXJSAMPLE; the input value may fall somewhat outside this range - * due to noise introduced by quantization, roundoff error, etc. These - * processes are inner loops and need to be as fast as possible. On most - * machines, particularly CPUs with pipelines or instruction prefetch, - * a (subscript-check-less) C table lookup - * x = sample_range_limit[x]; - * is faster than explicit tests - * if (x < 0) x = 0; - * else if (x > MAXJSAMPLE) x = MAXJSAMPLE; - * These processes all use a common table prepared by the routine below. - * - * For most steps we can mathematically guarantee that the initial value - * of x is within MAXJSAMPLE+1 of the legal range, so a table running from - * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial - * limiting step (just after the IDCT), a wildly out-of-range value is - * possible if the input data is corrupt. To avoid any chance of indexing - * off the end of memory and getting a bad-pointer trap, we perform the - * post-IDCT limiting thus: - * x = range_limit[x & MASK]; - * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit - * samples. Under normal circumstances this is more than enough range and - * a correct output will be generated; with bogus input data the mask will - * cause wraparound, and we will safely generate a bogus-but-in-range output. - * For the post-IDCT step, we want to convert the data from signed to unsigned - * representation by adding CENTERJSAMPLE at the same time that we limit it. - * So the post-IDCT limiting table ends up looking like this: - * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE, - * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), - * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), - * 0,1,...,CENTERJSAMPLE-1 - * Negative inputs select values from the upper half of the table after - * masking. - * - * We can save some space by overlapping the start of the post-IDCT table - * with the simpler range limiting table. The post-IDCT table begins at - * sample_range_limit + CENTERJSAMPLE. - * - * Note that the table is allocated in near data space on PCs; it's small - * enough and used often enough to justify this. - */ - -LOCAL(void) -prepare_range_limit_table (j_decompress_ptr cinfo) -/* Allocate and fill in the sample_range_limit table */ -{ - JSAMPLE * table; - int i; - - table = (JSAMPLE *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)); - table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */ - cinfo->sample_range_limit = table; - /* First segment of "simple" table: limit[x] = 0 for x < 0 */ - MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE)); - /* Main part of "simple" table: limit[x] = x */ - for (i = 0; i <= MAXJSAMPLE; i++) - table[i] = (JSAMPLE) i; - table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */ - /* End of simple table, rest of first half of post-IDCT table */ - for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++) - table[i] = MAXJSAMPLE; - /* Second half of post-IDCT table */ - MEMZERO(table + (2 * (MAXJSAMPLE+1)), - (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE)); - MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE), - cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE)); -} - - -/* - * Master selection of decompression modules. - * This is done once at jpeg_start_decompress time. We determine - * which modules will be used and give them appropriate initialization calls. - * We also initialize the decompressor input side to begin consuming data. - * - * Since jpeg_read_header has finished, we know what is in the SOF - * and (first) SOS markers. We also have all the application parameter - * settings. - */ - -LOCAL(void) -master_selection (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - boolean use_c_buffer; - long samplesperrow; - JDIMENSION jd_samplesperrow; - - /* Initialize dimensions and other stuff */ - jpeg_calc_output_dimensions(cinfo); - prepare_range_limit_table(cinfo); - - /* Width of an output scanline must be representable as JDIMENSION. */ - samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components; - jd_samplesperrow = (JDIMENSION) samplesperrow; - if ((long) jd_samplesperrow != samplesperrow) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - - /* Initialize my private state */ - master->pass_number = 0; - master->using_merged_upsample = use_merged_upsample(cinfo); - - /* Color quantizer selection */ - master->quantizer_1pass = NULL; - master->quantizer_2pass = NULL; - /* No mode changes if not using buffered-image mode. */ - if (! cinfo->quantize_colors || ! cinfo->buffered_image) { - cinfo->enable_1pass_quant = FALSE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; - } - if (cinfo->quantize_colors) { - if (cinfo->raw_data_out) - ERREXIT(cinfo, JERR_NOTIMPL); - /* 2-pass quantizer only works in 3-component color space. */ - if (cinfo->out_color_components != 3) { - cinfo->enable_1pass_quant = TRUE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; - cinfo->colormap = NULL; - } else if (cinfo->colormap != NULL) { - cinfo->enable_external_quant = TRUE; - } else if (cinfo->two_pass_quantize) { - cinfo->enable_2pass_quant = TRUE; - } else { - cinfo->enable_1pass_quant = TRUE; - } - - if (cinfo->enable_1pass_quant) { -#ifdef QUANT_1PASS_SUPPORTED - jinit_1pass_quantizer(cinfo); - master->quantizer_1pass = cinfo->cquantize; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - - /* We use the 2-pass code to map to external colormaps. */ - if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) { -#ifdef QUANT_2PASS_SUPPORTED - jinit_2pass_quantizer(cinfo); - master->quantizer_2pass = cinfo->cquantize; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - /* If both quantizers are initialized, the 2-pass one is left active; - * this is necessary for starting with quantization to an external map. - */ - } - - /* Post-processing: in particular, color conversion first */ - if (! cinfo->raw_data_out) { - if (master->using_merged_upsample) { -#ifdef UPSAMPLE_MERGING_SUPPORTED - jinit_merged_upsampler(cinfo); /* does color conversion too */ -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - jinit_color_deconverter(cinfo); - jinit_upsampler(cinfo); - } - jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant); - } - /* Inverse DCT */ - jinit_inverse_dct(cinfo); - /* Entropy decoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef D_PROGRESSIVE_SUPPORTED - jinit_phuff_decoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_decoder(cinfo); - } - - /* Initialize principal buffer controllers. */ - use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image; - jinit_d_coef_controller(cinfo, use_c_buffer); - - if (! cinfo->raw_data_out) - jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Initialize input side of decompressor to consume first scan. */ - (*cinfo->inputctl->start_input_pass) (cinfo); - -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* If jpeg_start_decompress will read the whole file, initialize - * progress monitoring appropriately. The input step is counted - * as one pass. - */ - if (cinfo->progress != NULL && ! cinfo->buffered_image && - cinfo->inputctl->has_multiple_scans) { - int nscans; - /* Estimate number of scans to set pass_limit. */ - if (cinfo->progressive_mode) { - /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ - nscans = 2 + 3 * cinfo->num_components; - } else { - /* For a nonprogressive multiscan file, estimate 1 scan per component. */ - nscans = cinfo->num_components; - } - cinfo->progress->pass_counter = 0L; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; - cinfo->progress->completed_passes = 0; - cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2); - /* Count the input pass as done */ - master->pass_number++; - } -#endif /* D_MULTISCAN_FILES_SUPPORTED */ -} - - -/* - * Per-pass setup. - * This is called at the beginning of each output pass. We determine which - * modules will be active during this pass and give them appropriate - * start_pass calls. We also set is_dummy_pass to indicate whether this - * is a "real" output pass or a dummy pass for color quantization. - * (In the latter case, jdapistd.c will crank the pass to completion.) - */ - -METHODDEF(void) -prepare_for_output_pass (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - if (master->pub.is_dummy_pass) { -#ifdef QUANT_2PASS_SUPPORTED - /* Final pass of 2-pass quantization */ - master->pub.is_dummy_pass = FALSE; - (*cinfo->cquantize->start_pass) (cinfo, FALSE); - (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST); - (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* QUANT_2PASS_SUPPORTED */ - } else { - if (cinfo->quantize_colors && cinfo->colormap == NULL) { - /* Select new quantization method */ - if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) { - cinfo->cquantize = master->quantizer_2pass; - master->pub.is_dummy_pass = TRUE; - } else if (cinfo->enable_1pass_quant) { - cinfo->cquantize = master->quantizer_1pass; - } else { - ERREXIT(cinfo, JERR_MODE_CHANGE); - } - } - (*cinfo->idct->start_pass) (cinfo); - (*cinfo->coef->start_output_pass) (cinfo); - if (! cinfo->raw_data_out) { - if (! master->using_merged_upsample) - (*cinfo->cconvert->start_pass) (cinfo); - (*cinfo->upsample->start_pass) (cinfo); - if (cinfo->quantize_colors) - (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass); - (*cinfo->post->start_pass) (cinfo, - (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); - (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); - } - } - - /* Set up progress monitor's pass info if present */ - if (cinfo->progress != NULL) { - cinfo->progress->completed_passes = master->pass_number; - cinfo->progress->total_passes = master->pass_number + - (master->pub.is_dummy_pass ? 2 : 1); - /* In buffered-image mode, we assume one more output pass if EOI not - * yet reached, but no more passes if EOI has been reached. - */ - if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) { - cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1); - } - } -} - - -/* - * Finish up at end of an output pass. - */ - -METHODDEF(void) -finish_output_pass (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - if (cinfo->quantize_colors) - (*cinfo->cquantize->finish_pass) (cinfo); - master->pass_number++; -} - - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Switch to a new external colormap between output passes. - */ - -GLOBAL(void) -jpeg_new_colormap (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - /* Prevent application from calling me at wrong times */ - if (cinfo->global_state != DSTATE_BUFIMAGE) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (cinfo->quantize_colors && cinfo->enable_external_quant && - cinfo->colormap != NULL) { - /* Select 2-pass quantizer for external colormap use */ - cinfo->cquantize = master->quantizer_2pass; - /* Notify quantizer of colormap change */ - (*cinfo->cquantize->new_color_map) (cinfo); - master->pub.is_dummy_pass = FALSE; /* just in case */ - } else - ERREXIT(cinfo, JERR_MODE_CHANGE); -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - - -/* - * Initialize master decompression control and select active modules. - * This is performed at the start of jpeg_start_decompress. - */ - -GLOBAL(void) -jinit_master_decompress (j_decompress_ptr cinfo) -{ - my_master_ptr master; - - master = (my_master_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_decomp_master)); - cinfo->master = (struct jpeg_decomp_master *) master; - master->pub.prepare_for_output_pass = prepare_for_output_pass; - master->pub.finish_output_pass = finish_output_pass; - - master->pub.is_dummy_pass = FALSE; - - master_selection(cinfo); -} +/* + * jdmaster.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains master control logic for the JPEG decompressor. + * These routines are concerned with selecting the modules to be executed + * and with determining the number of passes and the work to be done in each + * pass. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private state */ + +typedef struct { + struct jpeg_decomp_master pub; /* public fields */ + + int pass_number; /* # of passes completed */ + + boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */ + + /* Saved references to initialized quantizer modules, + * in case we need to switch modes. + */ + struct jpeg_color_quantizer * quantizer_1pass; + struct jpeg_color_quantizer * quantizer_2pass; +} my_decomp_master; + +typedef my_decomp_master * my_master_ptr; + + +/* + * Determine whether merged upsample/color conversion should be used. + * CRUCIAL: this must match the actual capabilities of jdmerge.c! + */ + +LOCAL(boolean) +use_merged_upsample (j_decompress_ptr cinfo) +{ +#ifdef UPSAMPLE_MERGING_SUPPORTED + /* Merging is the equivalent of plain box-filter upsampling */ + if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling) + return FALSE; + /* jdmerge.c only supports YCC=>RGB color conversion */ + if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 || + cinfo->out_color_space != JCS_RGB || + cinfo->out_color_components != RGB_PIXELSIZE) + return FALSE; + /* and it only handles 2h1v or 2h2v sampling ratios */ + if (cinfo->comp_info[0].h_samp_factor != 2 || + cinfo->comp_info[1].h_samp_factor != 1 || + cinfo->comp_info[2].h_samp_factor != 1 || + cinfo->comp_info[0].v_samp_factor > 2 || + cinfo->comp_info[1].v_samp_factor != 1 || + cinfo->comp_info[2].v_samp_factor != 1) + return FALSE; + /* furthermore, it doesn't work if we've scaled the IDCTs differently */ + if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size || + cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size || + cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size) + return FALSE; + /* ??? also need to test for upsample-time rescaling, when & if supported */ + return TRUE; /* by golly, it'll work... */ +#else + return FALSE; +#endif +} + + +/* + * Compute output image dimensions and related values. + * NOTE: this is exported for possible use by application. + * Hence it mustn't do anything that can't be done twice. + * Also note that it may be called before the master module is initialized! + */ + +GLOBAL(void) +jpeg_calc_output_dimensions (j_decompress_ptr cinfo) +/* Do computations that are needed before master selection phase */ +{ +#ifdef IDCT_SCALING_SUPPORTED + int ci; + jpeg_component_info *compptr; +#endif + + /* Prevent application from calling me at wrong times */ + if (cinfo->global_state != DSTATE_READY) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + +#ifdef IDCT_SCALING_SUPPORTED + + /* Compute actual output image dimensions and DCT scaling choices. */ + if (cinfo->scale_num * 8 <= cinfo->scale_denom) { + /* Provide 1/8 scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, 8L); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, 8L); + cinfo->min_DCT_scaled_size = 1; + } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) { + /* Provide 1/4 scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, 4L); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, 4L); + cinfo->min_DCT_scaled_size = 2; + } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) { + /* Provide 1/2 scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, 2L); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, 2L); + cinfo->min_DCT_scaled_size = 4; + } else { + /* Provide 1/1 scaling */ + cinfo->output_width = cinfo->image_width; + cinfo->output_height = cinfo->image_height; + cinfo->min_DCT_scaled_size = DCTSIZE; + } + /* In selecting the actual DCT scaling for each component, we try to + * scale up the chroma components via IDCT scaling rather than upsampling. + * This saves time if the upsampler gets to use 1:1 scaling. + * Note this code assumes that the supported DCT scalings are powers of 2. + */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + int ssize = cinfo->min_DCT_scaled_size; + while (ssize < DCTSIZE && + (compptr->h_samp_factor * ssize * 2 <= + cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) && + (compptr->v_samp_factor * ssize * 2 <= + cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) { + ssize = ssize * 2; + } + compptr->DCT_scaled_size = ssize; + } + + /* Recompute downsampled dimensions of components; + * application needs to know these if using raw downsampled data. + */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Size in samples, after IDCT scaling */ + compptr->downsampled_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * + (long) (compptr->h_samp_factor * compptr->DCT_scaled_size), + (long) (cinfo->max_h_samp_factor * DCTSIZE)); + compptr->downsampled_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * + (long) (compptr->v_samp_factor * compptr->DCT_scaled_size), + (long) (cinfo->max_v_samp_factor * DCTSIZE)); + } + +#else /* !IDCT_SCALING_SUPPORTED */ + + /* Hardwire it to "no scaling" */ + cinfo->output_width = cinfo->image_width; + cinfo->output_height = cinfo->image_height; + /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE, + * and has computed unscaled downsampled_width and downsampled_height. + */ + +#endif /* IDCT_SCALING_SUPPORTED */ + + /* Report number of components in selected colorspace. */ + /* Probably this should be in the color conversion module... */ + switch (cinfo->out_color_space) { + case JCS_GRAYSCALE: + cinfo->out_color_components = 1; + break; + case JCS_RGB: +#if RGB_PIXELSIZE != 3 + cinfo->out_color_components = RGB_PIXELSIZE; + break; +#endif /* else share code with YCbCr */ + case JCS_YCbCr: + cinfo->out_color_components = 3; + break; + case JCS_CMYK: + case JCS_YCCK: + cinfo->out_color_components = 4; + break; + default: /* else must be same colorspace as in file */ + cinfo->out_color_components = cinfo->num_components; + break; + } + cinfo->output_components = (cinfo->quantize_colors ? 1 : + cinfo->out_color_components); + + /* See if upsampler will want to emit more than one row at a time */ + if (use_merged_upsample(cinfo)) + cinfo->rec_outbuf_height = cinfo->max_v_samp_factor; + else + cinfo->rec_outbuf_height = 1; +} + + +/* + * Several decompression processes need to range-limit values to the range + * 0..MAXJSAMPLE; the input value may fall somewhat outside this range + * due to noise introduced by quantization, roundoff error, etc. These + * processes are inner loops and need to be as fast as possible. On most + * machines, particularly CPUs with pipelines or instruction prefetch, + * a (subscript-check-less) C table lookup + * x = sample_range_limit[x]; + * is faster than explicit tests + * if (x < 0) x = 0; + * else if (x > MAXJSAMPLE) x = MAXJSAMPLE; + * These processes all use a common table prepared by the routine below. + * + * For most steps we can mathematically guarantee that the initial value + * of x is within MAXJSAMPLE+1 of the legal range, so a table running from + * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial + * limiting step (just after the IDCT), a wildly out-of-range value is + * possible if the input data is corrupt. To avoid any chance of indexing + * off the end of memory and getting a bad-pointer trap, we perform the + * post-IDCT limiting thus: + * x = range_limit[x & MASK]; + * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit + * samples. Under normal circumstances this is more than enough range and + * a correct output will be generated; with bogus input data the mask will + * cause wraparound, and we will safely generate a bogus-but-in-range output. + * For the post-IDCT step, we want to convert the data from signed to unsigned + * representation by adding CENTERJSAMPLE at the same time that we limit it. + * So the post-IDCT limiting table ends up looking like this: + * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE, + * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), + * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), + * 0,1,...,CENTERJSAMPLE-1 + * Negative inputs select values from the upper half of the table after + * masking. + * + * We can save some space by overlapping the start of the post-IDCT table + * with the simpler range limiting table. The post-IDCT table begins at + * sample_range_limit + CENTERJSAMPLE. + * + * Note that the table is allocated in near data space on PCs; it's small + * enough and used often enough to justify this. + */ + +LOCAL(void) +prepare_range_limit_table (j_decompress_ptr cinfo) +/* Allocate and fill in the sample_range_limit table */ +{ + JSAMPLE * table; + int i; + + table = (JSAMPLE *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)); + table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */ + cinfo->sample_range_limit = table; + /* First segment of "simple" table: limit[x] = 0 for x < 0 */ + MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE)); + /* Main part of "simple" table: limit[x] = x */ + for (i = 0; i <= MAXJSAMPLE; i++) + table[i] = (JSAMPLE) i; + table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */ + /* End of simple table, rest of first half of post-IDCT table */ + for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++) + table[i] = MAXJSAMPLE; + /* Second half of post-IDCT table */ + MEMZERO(table + (2 * (MAXJSAMPLE+1)), + (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE)); + MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE), + cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE)); +} + + +/* + * Master selection of decompression modules. + * This is done once at jpeg_start_decompress time. We determine + * which modules will be used and give them appropriate initialization calls. + * We also initialize the decompressor input side to begin consuming data. + * + * Since jpeg_read_header has finished, we know what is in the SOF + * and (first) SOS markers. We also have all the application parameter + * settings. + */ + +LOCAL(void) +master_selection (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + boolean use_c_buffer; + long samplesperrow; + JDIMENSION jd_samplesperrow; + + /* Initialize dimensions and other stuff */ + jpeg_calc_output_dimensions(cinfo); + prepare_range_limit_table(cinfo); + + /* Width of an output scanline must be representable as JDIMENSION. */ + samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components; + jd_samplesperrow = (JDIMENSION) samplesperrow; + if ((long) jd_samplesperrow != samplesperrow) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + + /* Initialize my private state */ + master->pass_number = 0; + master->using_merged_upsample = use_merged_upsample(cinfo); + + /* Color quantizer selection */ + master->quantizer_1pass = NULL; + master->quantizer_2pass = NULL; + /* No mode changes if not using buffered-image mode. */ + if (! cinfo->quantize_colors || ! cinfo->buffered_image) { + cinfo->enable_1pass_quant = FALSE; + cinfo->enable_external_quant = FALSE; + cinfo->enable_2pass_quant = FALSE; + } + if (cinfo->quantize_colors) { + if (cinfo->raw_data_out) + ERREXIT(cinfo, JERR_NOTIMPL); + /* 2-pass quantizer only works in 3-component color space. */ + if (cinfo->out_color_components != 3) { + cinfo->enable_1pass_quant = TRUE; + cinfo->enable_external_quant = FALSE; + cinfo->enable_2pass_quant = FALSE; + cinfo->colormap = NULL; + } else if (cinfo->colormap != NULL) { + cinfo->enable_external_quant = TRUE; + } else if (cinfo->two_pass_quantize) { + cinfo->enable_2pass_quant = TRUE; + } else { + cinfo->enable_1pass_quant = TRUE; + } + + if (cinfo->enable_1pass_quant) { +#ifdef QUANT_1PASS_SUPPORTED + jinit_1pass_quantizer(cinfo); + master->quantizer_1pass = cinfo->cquantize; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } + + /* We use the 2-pass code to map to external colormaps. */ + if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) { +#ifdef QUANT_2PASS_SUPPORTED + jinit_2pass_quantizer(cinfo); + master->quantizer_2pass = cinfo->cquantize; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } + /* If both quantizers are initialized, the 2-pass one is left active; + * this is necessary for starting with quantization to an external map. + */ + } + + /* Post-processing: in particular, color conversion first */ + if (! cinfo->raw_data_out) { + if (master->using_merged_upsample) { +#ifdef UPSAMPLE_MERGING_SUPPORTED + jinit_merged_upsampler(cinfo); /* does color conversion too */ +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + jinit_color_deconverter(cinfo); + jinit_upsampler(cinfo); + } + jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant); + } + /* Inverse DCT */ + jinit_inverse_dct(cinfo); + /* Entropy decoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) { + ERREXIT(cinfo, JERR_ARITH_NOTIMPL); + } else { + if (cinfo->progressive_mode) { +#ifdef D_PROGRESSIVE_SUPPORTED + jinit_phuff_decoder(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else + jinit_huff_decoder(cinfo); + } + + /* Initialize principal buffer controllers. */ + use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image; + jinit_d_coef_controller(cinfo, use_c_buffer); + + if (! cinfo->raw_data_out) + jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Initialize input side of decompressor to consume first scan. */ + (*cinfo->inputctl->start_input_pass) (cinfo); + +#ifdef D_MULTISCAN_FILES_SUPPORTED + /* If jpeg_start_decompress will read the whole file, initialize + * progress monitoring appropriately. The input step is counted + * as one pass. + */ + if (cinfo->progress != NULL && ! cinfo->buffered_image && + cinfo->inputctl->has_multiple_scans) { + int nscans; + /* Estimate number of scans to set pass_limit. */ + if (cinfo->progressive_mode) { + /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ + nscans = 2 + 3 * cinfo->num_components; + } else { + /* For a nonprogressive multiscan file, estimate 1 scan per component. */ + nscans = cinfo->num_components; + } + cinfo->progress->pass_counter = 0L; + cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; + cinfo->progress->completed_passes = 0; + cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2); + /* Count the input pass as done */ + master->pass_number++; + } +#endif /* D_MULTISCAN_FILES_SUPPORTED */ +} + + +/* + * Per-pass setup. + * This is called at the beginning of each output pass. We determine which + * modules will be active during this pass and give them appropriate + * start_pass calls. We also set is_dummy_pass to indicate whether this + * is a "real" output pass or a dummy pass for color quantization. + * (In the latter case, jdapistd.c will crank the pass to completion.) + */ + +METHODDEF(void) +prepare_for_output_pass (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + if (master->pub.is_dummy_pass) { +#ifdef QUANT_2PASS_SUPPORTED + /* Final pass of 2-pass quantization */ + master->pub.is_dummy_pass = FALSE; + (*cinfo->cquantize->start_pass) (cinfo, FALSE); + (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST); + (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif /* QUANT_2PASS_SUPPORTED */ + } else { + if (cinfo->quantize_colors && cinfo->colormap == NULL) { + /* Select new quantization method */ + if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) { + cinfo->cquantize = master->quantizer_2pass; + master->pub.is_dummy_pass = TRUE; + } else if (cinfo->enable_1pass_quant) { + cinfo->cquantize = master->quantizer_1pass; + } else { + ERREXIT(cinfo, JERR_MODE_CHANGE); + } + } + (*cinfo->idct->start_pass) (cinfo); + (*cinfo->coef->start_output_pass) (cinfo); + if (! cinfo->raw_data_out) { + if (! master->using_merged_upsample) + (*cinfo->cconvert->start_pass) (cinfo); + (*cinfo->upsample->start_pass) (cinfo); + if (cinfo->quantize_colors) + (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass); + (*cinfo->post->start_pass) (cinfo, + (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); + (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); + } + } + + /* Set up progress monitor's pass info if present */ + if (cinfo->progress != NULL) { + cinfo->progress->completed_passes = master->pass_number; + cinfo->progress->total_passes = master->pass_number + + (master->pub.is_dummy_pass ? 2 : 1); + /* In buffered-image mode, we assume one more output pass if EOI not + * yet reached, but no more passes if EOI has been reached. + */ + if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) { + cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1); + } + } +} + + +/* + * Finish up at end of an output pass. + */ + +METHODDEF(void) +finish_output_pass (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + if (cinfo->quantize_colors) + (*cinfo->cquantize->finish_pass) (cinfo); + master->pass_number++; +} + + +#ifdef D_MULTISCAN_FILES_SUPPORTED + +/* + * Switch to a new external colormap between output passes. + */ + +GLOBAL(void) +jpeg_new_colormap (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + /* Prevent application from calling me at wrong times */ + if (cinfo->global_state != DSTATE_BUFIMAGE) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + if (cinfo->quantize_colors && cinfo->enable_external_quant && + cinfo->colormap != NULL) { + /* Select 2-pass quantizer for external colormap use */ + cinfo->cquantize = master->quantizer_2pass; + /* Notify quantizer of colormap change */ + (*cinfo->cquantize->new_color_map) (cinfo); + master->pub.is_dummy_pass = FALSE; /* just in case */ + } else + ERREXIT(cinfo, JERR_MODE_CHANGE); +} + +#endif /* D_MULTISCAN_FILES_SUPPORTED */ + + +/* + * Initialize master decompression control and select active modules. + * This is performed at the start of jpeg_start_decompress. + */ + +GLOBAL(void) +jinit_master_decompress (j_decompress_ptr cinfo) +{ + my_master_ptr master; + + master = (my_master_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_decomp_master)); + cinfo->master = (struct jpeg_decomp_master *) master; + master->pub.prepare_for_output_pass = prepare_for_output_pass; + master->pub.finish_output_pass = finish_output_pass; + + master->pub.is_dummy_pass = FALSE; + + master_selection(cinfo); +} diff --git a/src/dep/src/irrlicht/jpeglib/jdmerge.c b/src/dep/src/irrlicht/jpeglib/jdmerge.c index 9e3a595..3744446 100644 --- a/src/dep/src/irrlicht/jpeglib/jdmerge.c +++ b/src/dep/src/irrlicht/jpeglib/jdmerge.c @@ -1,400 +1,400 @@ -/* - * jdmerge.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains code for merged upsampling/color conversion. - * - * This file combines functions from jdsample.c and jdcolor.c; - * read those files first to understand what's going on. - * - * When the chroma components are to be upsampled by simple replication - * (ie, box filtering), we can save some work in color conversion by - * calculating all the output pixels corresponding to a pair of chroma - * samples at one time. In the conversion equations - * R = Y + K1 * Cr - * G = Y + K2 * Cb + K3 * Cr - * B = Y + K4 * Cb - * only the Y term varies among the group of pixels corresponding to a pair - * of chroma samples, so the rest of the terms can be calculated just once. - * At typical sampling ratios, this eliminates half or three-quarters of the - * multiplications needed for color conversion. - * - * This file currently provides implementations for the following cases: - * YCbCr => RGB color conversion only. - * Sampling ratios of 2h1v or 2h2v. - * No scaling needed at upsample time. - * Corner-aligned (non-CCIR601) sampling alignment. - * Other special cases could be added, but in most applications these are - * the only common cases. (For uncommon cases we fall back on the more - * general code in jdsample.c and jdcolor.c.) - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef UPSAMPLE_MERGING_SUPPORTED - - -/* Private subobject */ - -typedef struct { - struct jpeg_upsampler pub; /* public fields */ - - /* Pointer to routine to do actual upsampling/conversion of one row group */ - JMETHOD(void, upmethod, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf)); - - /* Private state for YCC->RGB conversion */ - int * Cr_r_tab; /* => table for Cr to R conversion */ - int * Cb_b_tab; /* => table for Cb to B conversion */ - INT32 * Cr_g_tab; /* => table for Cr to G conversion */ - INT32 * Cb_g_tab; /* => table for Cb to G conversion */ - - /* For 2:1 vertical sampling, we produce two output rows at a time. - * We need a "spare" row buffer to hold the second output row if the - * application provides just a one-row buffer; we also use the spare - * to discard the dummy last row if the image height is odd. - */ - JSAMPROW spare_row; - boolean spare_full; /* T if spare buffer is occupied */ - - JDIMENSION out_row_width; /* samples per output row */ - JDIMENSION rows_to_go; /* counts rows remaining in image */ -} my_upsampler; - -typedef my_upsampler * my_upsample_ptr; - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L<RGB colorspace conversion. - * This is taken directly from jdcolor.c; see that file for more info. - */ - -LOCAL(void) -build_ycc_rgb_table (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - int i; - INT32 x; - SHIFT_TEMPS - - upsample->Cr_r_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - upsample->Cb_b_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - upsample->Cr_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - upsample->Cb_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - - for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { - /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ - /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ - /* Cr=>R value is nearest int to 1.40200 * x */ - upsample->Cr_r_tab[i] = (int) - RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); - /* Cb=>B value is nearest int to 1.77200 * x */ - upsample->Cb_b_tab[i] = (int) - RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); - /* Cr=>G value is scaled-up -0.71414 * x */ - upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x; - /* Cb=>G value is scaled-up -0.34414 * x */ - /* We also add in ONE_HALF so that need not do it in inner loop */ - upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; - } -} - - -/* - * Initialize for an upsampling pass. - */ - -METHODDEF(void) -start_pass_merged_upsample (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Mark the spare buffer empty */ - upsample->spare_full = FALSE; - /* Initialize total-height counter for detecting bottom of image */ - upsample->rows_to_go = cinfo->output_height; -} - - -/* - * Control routine to do upsampling (and color conversion). - * - * The control routine just handles the row buffering considerations. - */ - -METHODDEF(void) -merged_2v_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -/* 2:1 vertical sampling case: may need a spare row. */ -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - JSAMPROW work_ptrs[2]; - JDIMENSION num_rows; /* number of rows returned to caller */ - - if (upsample->spare_full) { - /* If we have a spare row saved from a previous cycle, just return it. */ - jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0, - 1, upsample->out_row_width); - num_rows = 1; - upsample->spare_full = FALSE; - } else { - /* Figure number of rows to return to caller. */ - num_rows = 2; - /* Not more than the distance to the end of the image. */ - if (num_rows > upsample->rows_to_go) - num_rows = upsample->rows_to_go; - /* And not more than what the client can accept: */ - out_rows_avail -= *out_row_ctr; - if (num_rows > out_rows_avail) - num_rows = out_rows_avail; - /* Create output pointer array for upsampler. */ - work_ptrs[0] = output_buf[*out_row_ctr]; - if (num_rows > 1) { - work_ptrs[1] = output_buf[*out_row_ctr + 1]; - } else { - work_ptrs[1] = upsample->spare_row; - upsample->spare_full = TRUE; - } - /* Now do the upsampling. */ - (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs); - } - - /* Adjust counts */ - *out_row_ctr += num_rows; - upsample->rows_to_go -= num_rows; - /* When the buffer is emptied, declare this input row group consumed */ - if (! upsample->spare_full) - (*in_row_group_ctr)++; -} - - -METHODDEF(void) -merged_1v_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -/* 1:1 vertical sampling case: much easier, never need a spare row. */ -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Just do the upsampling. */ - (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, - output_buf + *out_row_ctr); - /* Adjust counts */ - (*out_row_ctr)++; - (*in_row_group_ctr)++; -} - - -/* - * These are the routines invoked by the control routines to do - * the actual upsampling/conversion. One row group is processed per call. - * - * Note: since we may be writing directly into application-supplied buffers, - * we have to be honest about the output width; we can't assume the buffer - * has been rounded up to an even width. - */ - - -/* - * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. - */ - -METHODDEF(void) -h2v1_merged_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - register int y, cred, cgreen, cblue; - int cb, cr; - register JSAMPROW outptr; - JSAMPROW inptr0, inptr1, inptr2; - JDIMENSION col; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - int * Crrtab = upsample->Cr_r_tab; - int * Cbbtab = upsample->Cb_b_tab; - INT32 * Crgtab = upsample->Cr_g_tab; - INT32 * Cbgtab = upsample->Cb_g_tab; - SHIFT_TEMPS - - inptr0 = input_buf[0][in_row_group_ctr]; - inptr1 = input_buf[1][in_row_group_ctr]; - inptr2 = input_buf[2][in_row_group_ctr]; - outptr = output_buf[0]; - /* Loop for each pair of output pixels */ - for (col = cinfo->output_width >> 1; col > 0; col--) { - /* Do the chroma part of the calculation */ - cb = GETJSAMPLE(*inptr1++); - cr = GETJSAMPLE(*inptr2++); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - /* Fetch 2 Y values and emit 2 pixels */ - y = GETJSAMPLE(*inptr0++); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - outptr += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr0++); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - outptr += RGB_PIXELSIZE; - } - /* If image width is odd, do the last output column separately */ - if (cinfo->output_width & 1) { - cb = GETJSAMPLE(*inptr1); - cr = GETJSAMPLE(*inptr2); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - y = GETJSAMPLE(*inptr0); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - } -} - - -/* - * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. - */ - -METHODDEF(void) -h2v2_merged_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - register int y, cred, cgreen, cblue; - int cb, cr; - register JSAMPROW outptr0, outptr1; - JSAMPROW inptr00, inptr01, inptr1, inptr2; - JDIMENSION col; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - int * Crrtab = upsample->Cr_r_tab; - int * Cbbtab = upsample->Cb_b_tab; - INT32 * Crgtab = upsample->Cr_g_tab; - INT32 * Cbgtab = upsample->Cb_g_tab; - SHIFT_TEMPS - - inptr00 = input_buf[0][in_row_group_ctr*2]; - inptr01 = input_buf[0][in_row_group_ctr*2 + 1]; - inptr1 = input_buf[1][in_row_group_ctr]; - inptr2 = input_buf[2][in_row_group_ctr]; - outptr0 = output_buf[0]; - outptr1 = output_buf[1]; - /* Loop for each group of output pixels */ - for (col = cinfo->output_width >> 1; col > 0; col--) { - /* Do the chroma part of the calculation */ - cb = GETJSAMPLE(*inptr1++); - cr = GETJSAMPLE(*inptr2++); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - /* Fetch 4 Y values and emit 4 pixels */ - y = GETJSAMPLE(*inptr00++); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - outptr0 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr00++); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - outptr0 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr01++); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - outptr1 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr01++); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - outptr1 += RGB_PIXELSIZE; - } - /* If image width is odd, do the last output column separately */ - if (cinfo->output_width & 1) { - cb = GETJSAMPLE(*inptr1); - cr = GETJSAMPLE(*inptr2); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - y = GETJSAMPLE(*inptr00); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - y = GETJSAMPLE(*inptr01); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - } -} - - -/* - * Module initialization routine for merged upsampling/color conversion. - * - * NB: this is called under the conditions determined by use_merged_upsample() - * in jdmaster.c. That routine MUST correspond to the actual capabilities - * of this module; no safety checks are made here. - */ - -GLOBAL(void) -jinit_merged_upsampler (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample; - - upsample = (my_upsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_upsampler)); - cinfo->upsample = (struct jpeg_upsampler *) upsample; - upsample->pub.start_pass = start_pass_merged_upsample; - upsample->pub.need_context_rows = FALSE; - - upsample->out_row_width = cinfo->output_width * cinfo->out_color_components; - - if (cinfo->max_v_samp_factor == 2) { - upsample->pub.upsample = merged_2v_upsample; - upsample->upmethod = h2v2_merged_upsample; - /* Allocate a spare row buffer */ - upsample->spare_row = (JSAMPROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) (upsample->out_row_width * SIZEOF(JSAMPLE))); - } else { - upsample->pub.upsample = merged_1v_upsample; - upsample->upmethod = h2v1_merged_upsample; - /* No spare row needed */ - upsample->spare_row = NULL; - } - - build_ycc_rgb_table(cinfo); -} - -#endif /* UPSAMPLE_MERGING_SUPPORTED */ +/* + * jdmerge.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains code for merged upsampling/color conversion. + * + * This file combines functions from jdsample.c and jdcolor.c; + * read those files first to understand what's going on. + * + * When the chroma components are to be upsampled by simple replication + * (ie, box filtering), we can save some work in color conversion by + * calculating all the output pixels corresponding to a pair of chroma + * samples at one time. In the conversion equations + * R = Y + K1 * Cr + * G = Y + K2 * Cb + K3 * Cr + * B = Y + K4 * Cb + * only the Y term varies among the group of pixels corresponding to a pair + * of chroma samples, so the rest of the terms can be calculated just once. + * At typical sampling ratios, this eliminates half or three-quarters of the + * multiplications needed for color conversion. + * + * This file currently provides implementations for the following cases: + * YCbCr => RGB color conversion only. + * Sampling ratios of 2h1v or 2h2v. + * No scaling needed at upsample time. + * Corner-aligned (non-CCIR601) sampling alignment. + * Other special cases could be added, but in most applications these are + * the only common cases. (For uncommon cases we fall back on the more + * general code in jdsample.c and jdcolor.c.) + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +#ifdef UPSAMPLE_MERGING_SUPPORTED + + +/* Private subobject */ + +typedef struct { + struct jpeg_upsampler pub; /* public fields */ + + /* Pointer to routine to do actual upsampling/conversion of one row group */ + JMETHOD(void, upmethod, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf)); + + /* Private state for YCC->RGB conversion */ + int * Cr_r_tab; /* => table for Cr to R conversion */ + int * Cb_b_tab; /* => table for Cb to B conversion */ + INT32 * Cr_g_tab; /* => table for Cr to G conversion */ + INT32 * Cb_g_tab; /* => table for Cb to G conversion */ + + /* For 2:1 vertical sampling, we produce two output rows at a time. + * We need a "spare" row buffer to hold the second output row if the + * application provides just a one-row buffer; we also use the spare + * to discard the dummy last row if the image height is odd. + */ + JSAMPROW spare_row; + boolean spare_full; /* T if spare buffer is occupied */ + + JDIMENSION out_row_width; /* samples per output row */ + JDIMENSION rows_to_go; /* counts rows remaining in image */ +} my_upsampler; + +typedef my_upsampler * my_upsample_ptr; + +#define SCALEBITS 16 /* speediest right-shift on some machines */ +#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) +#define FIX(x) ((INT32) ((x) * (1L<RGB colorspace conversion. + * This is taken directly from jdcolor.c; see that file for more info. + */ + +LOCAL(void) +build_ycc_rgb_table (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + int i; + INT32 x; + SHIFT_TEMPS + + upsample->Cr_r_tab = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(int)); + upsample->Cb_b_tab = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(int)); + upsample->Cr_g_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(INT32)); + upsample->Cb_g_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(INT32)); + + for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { + /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ + /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ + /* Cr=>R value is nearest int to 1.40200 * x */ + upsample->Cr_r_tab[i] = (int) + RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); + /* Cb=>B value is nearest int to 1.77200 * x */ + upsample->Cb_b_tab[i] = (int) + RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); + /* Cr=>G value is scaled-up -0.71414 * x */ + upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x; + /* Cb=>G value is scaled-up -0.34414 * x */ + /* We also add in ONE_HALF so that need not do it in inner loop */ + upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; + } +} + + +/* + * Initialize for an upsampling pass. + */ + +METHODDEF(void) +start_pass_merged_upsample (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + + /* Mark the spare buffer empty */ + upsample->spare_full = FALSE; + /* Initialize total-height counter for detecting bottom of image */ + upsample->rows_to_go = cinfo->output_height; +} + + +/* + * Control routine to do upsampling (and color conversion). + * + * The control routine just handles the row buffering considerations. + */ + +METHODDEF(void) +merged_2v_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +/* 2:1 vertical sampling case: may need a spare row. */ +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + JSAMPROW work_ptrs[2]; + JDIMENSION num_rows; /* number of rows returned to caller */ + + if (upsample->spare_full) { + /* If we have a spare row saved from a previous cycle, just return it. */ + jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0, + 1, upsample->out_row_width); + num_rows = 1; + upsample->spare_full = FALSE; + } else { + /* Figure number of rows to return to caller. */ + num_rows = 2; + /* Not more than the distance to the end of the image. */ + if (num_rows > upsample->rows_to_go) + num_rows = upsample->rows_to_go; + /* And not more than what the client can accept: */ + out_rows_avail -= *out_row_ctr; + if (num_rows > out_rows_avail) + num_rows = out_rows_avail; + /* Create output pointer array for upsampler. */ + work_ptrs[0] = output_buf[*out_row_ctr]; + if (num_rows > 1) { + work_ptrs[1] = output_buf[*out_row_ctr + 1]; + } else { + work_ptrs[1] = upsample->spare_row; + upsample->spare_full = TRUE; + } + /* Now do the upsampling. */ + (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs); + } + + /* Adjust counts */ + *out_row_ctr += num_rows; + upsample->rows_to_go -= num_rows; + /* When the buffer is emptied, declare this input row group consumed */ + if (! upsample->spare_full) + (*in_row_group_ctr)++; +} + + +METHODDEF(void) +merged_1v_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +/* 1:1 vertical sampling case: much easier, never need a spare row. */ +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + + /* Just do the upsampling. */ + (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, + output_buf + *out_row_ctr); + /* Adjust counts */ + (*out_row_ctr)++; + (*in_row_group_ctr)++; +} + + +/* + * These are the routines invoked by the control routines to do + * the actual upsampling/conversion. One row group is processed per call. + * + * Note: since we may be writing directly into application-supplied buffers, + * we have to be honest about the output width; we can't assume the buffer + * has been rounded up to an even width. + */ + + +/* + * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. + */ + +METHODDEF(void) +h2v1_merged_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + register int y, cred, cgreen, cblue; + int cb, cr; + register JSAMPROW outptr; + JSAMPROW inptr0, inptr1, inptr2; + JDIMENSION col; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + int * Crrtab = upsample->Cr_r_tab; + int * Cbbtab = upsample->Cb_b_tab; + INT32 * Crgtab = upsample->Cr_g_tab; + INT32 * Cbgtab = upsample->Cb_g_tab; + SHIFT_TEMPS + + inptr0 = input_buf[0][in_row_group_ctr]; + inptr1 = input_buf[1][in_row_group_ctr]; + inptr2 = input_buf[2][in_row_group_ctr]; + outptr = output_buf[0]; + /* Loop for each pair of output pixels */ + for (col = cinfo->output_width >> 1; col > 0; col--) { + /* Do the chroma part of the calculation */ + cb = GETJSAMPLE(*inptr1++); + cr = GETJSAMPLE(*inptr2++); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + /* Fetch 2 Y values and emit 2 pixels */ + y = GETJSAMPLE(*inptr0++); + outptr[RGB_RED] = range_limit[y + cred]; + outptr[RGB_GREEN] = range_limit[y + cgreen]; + outptr[RGB_BLUE] = range_limit[y + cblue]; + outptr += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr0++); + outptr[RGB_RED] = range_limit[y + cred]; + outptr[RGB_GREEN] = range_limit[y + cgreen]; + outptr[RGB_BLUE] = range_limit[y + cblue]; + outptr += RGB_PIXELSIZE; + } + /* If image width is odd, do the last output column separately */ + if (cinfo->output_width & 1) { + cb = GETJSAMPLE(*inptr1); + cr = GETJSAMPLE(*inptr2); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + y = GETJSAMPLE(*inptr0); + outptr[RGB_RED] = range_limit[y + cred]; + outptr[RGB_GREEN] = range_limit[y + cgreen]; + outptr[RGB_BLUE] = range_limit[y + cblue]; + } +} + + +/* + * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. + */ + +METHODDEF(void) +h2v2_merged_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + register int y, cred, cgreen, cblue; + int cb, cr; + register JSAMPROW outptr0, outptr1; + JSAMPROW inptr00, inptr01, inptr1, inptr2; + JDIMENSION col; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + int * Crrtab = upsample->Cr_r_tab; + int * Cbbtab = upsample->Cb_b_tab; + INT32 * Crgtab = upsample->Cr_g_tab; + INT32 * Cbgtab = upsample->Cb_g_tab; + SHIFT_TEMPS + + inptr00 = input_buf[0][in_row_group_ctr*2]; + inptr01 = input_buf[0][in_row_group_ctr*2 + 1]; + inptr1 = input_buf[1][in_row_group_ctr]; + inptr2 = input_buf[2][in_row_group_ctr]; + outptr0 = output_buf[0]; + outptr1 = output_buf[1]; + /* Loop for each group of output pixels */ + for (col = cinfo->output_width >> 1; col > 0; col--) { + /* Do the chroma part of the calculation */ + cb = GETJSAMPLE(*inptr1++); + cr = GETJSAMPLE(*inptr2++); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + /* Fetch 4 Y values and emit 4 pixels */ + y = GETJSAMPLE(*inptr00++); + outptr0[RGB_RED] = range_limit[y + cred]; + outptr0[RGB_GREEN] = range_limit[y + cgreen]; + outptr0[RGB_BLUE] = range_limit[y + cblue]; + outptr0 += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr00++); + outptr0[RGB_RED] = range_limit[y + cred]; + outptr0[RGB_GREEN] = range_limit[y + cgreen]; + outptr0[RGB_BLUE] = range_limit[y + cblue]; + outptr0 += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr01++); + outptr1[RGB_RED] = range_limit[y + cred]; + outptr1[RGB_GREEN] = range_limit[y + cgreen]; + outptr1[RGB_BLUE] = range_limit[y + cblue]; + outptr1 += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr01++); + outptr1[RGB_RED] = range_limit[y + cred]; + outptr1[RGB_GREEN] = range_limit[y + cgreen]; + outptr1[RGB_BLUE] = range_limit[y + cblue]; + outptr1 += RGB_PIXELSIZE; + } + /* If image width is odd, do the last output column separately */ + if (cinfo->output_width & 1) { + cb = GETJSAMPLE(*inptr1); + cr = GETJSAMPLE(*inptr2); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + y = GETJSAMPLE(*inptr00); + outptr0[RGB_RED] = range_limit[y + cred]; + outptr0[RGB_GREEN] = range_limit[y + cgreen]; + outptr0[RGB_BLUE] = range_limit[y + cblue]; + y = GETJSAMPLE(*inptr01); + outptr1[RGB_RED] = range_limit[y + cred]; + outptr1[RGB_GREEN] = range_limit[y + cgreen]; + outptr1[RGB_BLUE] = range_limit[y + cblue]; + } +} + + +/* + * Module initialization routine for merged upsampling/color conversion. + * + * NB: this is called under the conditions determined by use_merged_upsample() + * in jdmaster.c. That routine MUST correspond to the actual capabilities + * of this module; no safety checks are made here. + */ + +GLOBAL(void) +jinit_merged_upsampler (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample; + + upsample = (my_upsample_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_upsampler)); + cinfo->upsample = (struct jpeg_upsampler *) upsample; + upsample->pub.start_pass = start_pass_merged_upsample; + upsample->pub.need_context_rows = FALSE; + + upsample->out_row_width = cinfo->output_width * cinfo->out_color_components; + + if (cinfo->max_v_samp_factor == 2) { + upsample->pub.upsample = merged_2v_upsample; + upsample->upmethod = h2v2_merged_upsample; + /* Allocate a spare row buffer */ + upsample->spare_row = (JSAMPROW) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (size_t) (upsample->out_row_width * SIZEOF(JSAMPLE))); + } else { + upsample->pub.upsample = merged_1v_upsample; + upsample->upmethod = h2v1_merged_upsample; + /* No spare row needed */ + upsample->spare_row = NULL; + } + + build_ycc_rgb_table(cinfo); +} + +#endif /* UPSAMPLE_MERGING_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/jdphuff.c b/src/dep/src/irrlicht/jpeglib/jdphuff.c index 2404743..2267809 100644 --- a/src/dep/src/irrlicht/jpeglib/jdphuff.c +++ b/src/dep/src/irrlicht/jpeglib/jdphuff.c @@ -1,668 +1,668 @@ -/* - * jdphuff.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy decoding routines for progressive JPEG. - * - * Much of the complexity here has to do with supporting input suspension. - * If the data source module demands suspension, we want to be able to back - * up to the start of the current MCU. To do this, we copy state variables - * into local working storage, and update them back to the permanent - * storage only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdhuff.h" /* Declarations shared with jdhuff.c */ - - -#ifdef D_PROGRESSIVE_SUPPORTED - -/* - * Expanded entropy decoder object for progressive Huffman decoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - unsigned int EOBRUN; /* remaining EOBs in EOBRUN */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).EOBRUN = (src).EOBRUN, \ - (dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_decoder pub; /* public fields */ - - /* These fields are loaded into local variables at start of each MCU. - * In case of suspension, we exit WITHOUT updating them. - */ - bitread_perm_state bitstate; /* Bit buffer at start of MCU */ - savable_state saved; /* Other state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - d_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; - - d_derived_tbl * ac_derived_tbl; /* active table during an AC scan */ -} phuff_entropy_decoder; - -typedef phuff_entropy_decoder * phuff_entropy_ptr; - -/* Forward declarations */ -METHODDEF(boolean) decode_mcu_DC_first JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_AC_first JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_DC_refine JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_AC_refine JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); - - -/* - * Initialize for a Huffman-compressed scan. - */ - -METHODDEF(void) -start_pass_phuff_decoder (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band, bad; - int ci, coefi, tbl; - int *coef_bit_ptr; - jpeg_component_info * compptr; - - is_DC_band = (cinfo->Ss == 0); - - /* Validate scan parameters */ - bad = FALSE; - if (is_DC_band) { - if (cinfo->Se != 0) - bad = TRUE; - } else { - /* need not check Ss/Se < 0 since they came from unsigned bytes */ - if (cinfo->Ss > cinfo->Se || cinfo->Se >= DCTSIZE2) - bad = TRUE; - /* AC scans may have only one component */ - if (cinfo->comps_in_scan != 1) - bad = TRUE; - } - if (cinfo->Ah != 0) { - /* Successive approximation refinement scan: must have Al = Ah-1. */ - if (cinfo->Al != cinfo->Ah-1) - bad = TRUE; - } - if (cinfo->Al > 13) /* need not check for < 0 */ - bad = TRUE; - /* Arguably the maximum Al value should be less than 13 for 8-bit precision, - * but the spec doesn't say so, and we try to be liberal about what we - * accept. Note: large Al values could result in out-of-range DC - * coefficients during early scans, leading to bizarre displays due to - * overflows in the IDCT math. But we won't crash. - */ - if (bad) - ERREXIT4(cinfo, JERR_BAD_PROGRESSION, - cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); - /* Update progression status, and verify that scan order is legal. - * Note that inter-scan inconsistencies are treated as warnings - * not fatal errors ... not clear if this is right way to behave. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - int cindex = cinfo->cur_comp_info[ci]->component_index; - coef_bit_ptr = & cinfo->coef_bits[cindex][0]; - if (!is_DC_band && coef_bit_ptr[0] < 0) /* AC without prior DC scan */ - WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0); - for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) { - int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi]; - if (cinfo->Ah != expected) - WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi); - coef_bit_ptr[coefi] = cinfo->Al; - } - } - - /* Select MCU decoding routine */ - if (cinfo->Ah == 0) { - if (is_DC_band) - entropy->pub.decode_mcu = decode_mcu_DC_first; - else - entropy->pub.decode_mcu = decode_mcu_AC_first; - } else { - if (is_DC_band) - entropy->pub.decode_mcu = decode_mcu_DC_refine; - else - entropy->pub.decode_mcu = decode_mcu_AC_refine; - } - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Make sure requested tables are present, and compute derived tables. - * We may build same derived table more than once, but it's not expensive. - */ - if (is_DC_band) { - if (cinfo->Ah == 0) { /* DC refinement needs no table */ - tbl = compptr->dc_tbl_no; - jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, - & entropy->derived_tbls[tbl]); - } - } else { - tbl = compptr->ac_tbl_no; - jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, - & entropy->derived_tbls[tbl]); - /* remember the single active table */ - entropy->ac_derived_tbl = entropy->derived_tbls[tbl]; - } - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Initialize bitread state variables */ - entropy->bitstate.bits_left = 0; - entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ - entropy->pub.insufficient_data = FALSE; - - /* Initialize private state variables */ - entropy->saved.EOBRUN = 0; - - /* Initialize restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; -} - - -/* - * Figure F.12: extend sign bit. - * On some machines, a shift and add will be faster than a table lookup. - */ - -#ifdef AVOID_TABLES - -#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) - -#else - -#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) - -static const int extend_test[16] = /* entry n is 2**(n-1) */ - { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, - 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; - -static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ - { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, - ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, - ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, - ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; - -#endif /* AVOID_TABLES */ - - -/* - * Check for a restart marker & resynchronize decoder. - * Returns FALSE if must suspend. - */ - -LOCAL(boolean) -process_restart (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int ci; - - /* Throw away any unused bits remaining in bit buffer; */ - /* include any full bytes in next_marker's count of discarded bytes */ - cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; - entropy->bitstate.bits_left = 0; - - /* Advance past the RSTn marker */ - if (! (*cinfo->marker->read_restart_marker) (cinfo)) - return FALSE; - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - /* Re-init EOB run count, too */ - entropy->saved.EOBRUN = 0; - - /* Reset restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; - - /* Reset out-of-data flag, unless read_restart_marker left us smack up - * against a marker. In that case we will end up treating the next data - * segment as empty, and we can avoid producing bogus output pixels by - * leaving the flag set. - */ - if (cinfo->unread_marker == 0) - entropy->pub.insufficient_data = FALSE; - - return TRUE; -} - - -/* - * Huffman MCU decoding. - * Each of these routines decodes and returns one MCU's worth of - * Huffman-compressed coefficients. - * The coefficients are reordered from zigzag order into natural array order, - * but are not dequantized. - * - * The i'th block of the MCU is stored into the block pointed to by - * MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER. - * - * We return FALSE if data source requested suspension. In that case no - * changes have been made to permanent state. (Exception: some output - * coefficients may already have been assigned. This is harmless for - * spectral selection, since we'll just re-assign them on the next call. - * Successive approximation AC refinement has to be more careful, however.) - */ - -/* - * MCU decoding for DC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Al = cinfo->Al; - register int s, r; - int blkn, ci; - JBLOCKROW block; - BITREAD_STATE_VARS; - savable_state state; - d_derived_tbl * tbl; - jpeg_component_info * compptr; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(state, entropy->saved); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - tbl = entropy->derived_tbls[compptr->dc_tbl_no]; - - /* Decode a single block's worth of coefficients */ - - /* Section F.2.2.1: decode the DC coefficient difference */ - HUFF_DECODE(s, br_state, tbl, return FALSE, label1); - if (s) { - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - } - - /* Convert DC difference to actual value, update last_dc_val */ - s += state.last_dc_val[ci]; - state.last_dc_val[ci] = s; - /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */ - (*block)[0] = (JCOEF) (s << Al); - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(entropy->saved, state); - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for AC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Se = cinfo->Se; - int Al = cinfo->Al; - register int s, k, r; - unsigned int EOBRUN; - JBLOCKROW block; - BITREAD_STATE_VARS; - d_derived_tbl * tbl; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state. - * We can avoid loading/saving bitread state if in an EOB run. - */ - EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ - - /* There is always only one block per MCU */ - - if (EOBRUN > 0) /* if it's a band of zeroes... */ - EOBRUN--; /* ...process it now (we do nothing) */ - else { - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - block = MCU_data[0]; - tbl = entropy->ac_derived_tbl; - - for (k = cinfo->Ss; k <= Se; k++) { - HUFF_DECODE(s, br_state, tbl, return FALSE, label2); - r = s >> 4; - s &= 15; - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - /* Scale and output coefficient in natural (dezigzagged) order */ - (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al); - } else { - if (r == 15) { /* ZRL */ - k += 15; /* skip 15 zeroes in band */ - } else { /* EOBr, run length is 2^r + appended bits */ - EOBRUN = 1 << r; - if (r) { /* EOBr, r > 0 */ - CHECK_BIT_BUFFER(br_state, r, return FALSE); - r = GET_BITS(r); - EOBRUN += r; - } - EOBRUN--; /* this band is processed at this moment */ - break; /* force end-of-band */ - } - } - } - - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - } - - /* Completed MCU, so update state */ - entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for DC successive approximation refinement scan. - * Note: we assume such scans can be multi-component, although the spec - * is not very clear on the point. - */ - -METHODDEF(boolean) -decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ - int blkn; - JBLOCKROW block; - BITREAD_STATE_VARS; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* Not worth the cycles to check insufficient_data here, - * since we will not change the data anyway if we read zeroes. - */ - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - - /* Encoded data is simply the next bit of the two's-complement DC value */ - CHECK_BIT_BUFFER(br_state, 1, return FALSE); - if (GET_BITS(1)) - (*block)[0] |= p1; - /* Note: since we use |=, repeating the assignment later is safe */ - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for AC successive approximation refinement scan. - */ - -METHODDEF(boolean) -decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Se = cinfo->Se; - int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ - int m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */ - register int s, k, r; - unsigned int EOBRUN; - JBLOCKROW block; - JCOEFPTR thiscoef; - BITREAD_STATE_VARS; - d_derived_tbl * tbl; - int num_newnz; - int newnz_pos[DCTSIZE2]; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, don't modify the MCU. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ - - /* There is always only one block per MCU */ - block = MCU_data[0]; - tbl = entropy->ac_derived_tbl; - - /* If we are forced to suspend, we must undo the assignments to any newly - * nonzero coefficients in the block, because otherwise we'd get confused - * next time about which coefficients were already nonzero. - * But we need not undo addition of bits to already-nonzero coefficients; - * instead, we can test the current bit to see if we already did it. - */ - num_newnz = 0; - - /* initialize coefficient loop counter to start of band */ - k = cinfo->Ss; - - if (EOBRUN == 0) { - for (; k <= Se; k++) { - HUFF_DECODE(s, br_state, tbl, goto undoit, label3); - r = s >> 4; - s &= 15; - if (s) { - if (s != 1) /* size of new coef should always be 1 */ - WARNMS(cinfo, JWRN_HUFF_BAD_CODE); - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) - s = p1; /* newly nonzero coef is positive */ - else - s = m1; /* newly nonzero coef is negative */ - } else { - if (r != 15) { - EOBRUN = 1 << r; /* EOBr, run length is 2^r + appended bits */ - if (r) { - CHECK_BIT_BUFFER(br_state, r, goto undoit); - r = GET_BITS(r); - EOBRUN += r; - } - break; /* rest of block is handled by EOB logic */ - } - /* note s = 0 for processing ZRL */ - } - /* Advance over already-nonzero coefs and r still-zero coefs, - * appending correction bits to the nonzeroes. A correction bit is 1 - * if the absolute value of the coefficient must be increased. - */ - do { - thiscoef = *block + jpeg_natural_order[k]; - if (*thiscoef != 0) { - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) { - if ((*thiscoef & p1) == 0) { /* do nothing if already set it */ - if (*thiscoef >= 0) - *thiscoef += p1; - else - *thiscoef += m1; - } - } - } else { - if (--r < 0) - break; /* reached target zero coefficient */ - } - k++; - } while (k <= Se); - if (s) { - int pos = jpeg_natural_order[k]; - /* Output newly nonzero coefficient */ - (*block)[pos] = (JCOEF) s; - /* Remember its position in case we have to suspend */ - newnz_pos[num_newnz++] = pos; - } - } - } - - if (EOBRUN > 0) { - /* Scan any remaining coefficient positions after the end-of-band - * (the last newly nonzero coefficient, if any). Append a correction - * bit to each already-nonzero coefficient. A correction bit is 1 - * if the absolute value of the coefficient must be increased. - */ - for (; k <= Se; k++) { - thiscoef = *block + jpeg_natural_order[k]; - if (*thiscoef != 0) { - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) { - if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */ - if (*thiscoef >= 0) - *thiscoef += p1; - else - *thiscoef += m1; - } - } - } - } - /* Count one block completed in EOB run */ - EOBRUN--; - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; - -undoit: - /* Re-zero any output coefficients that we made newly nonzero */ - while (num_newnz > 0) - (*block)[newnz_pos[--num_newnz]] = 0; - - return FALSE; -} - - -/* - * Module initialization routine for progressive Huffman entropy decoding. - */ - -GLOBAL(void) -jinit_phuff_decoder (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy; - int *coef_bit_ptr; - int ci, i; - - entropy = (phuff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(phuff_entropy_decoder)); - cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; - entropy->pub.start_pass = start_pass_phuff_decoder; - - /* Mark derived tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->derived_tbls[i] = NULL; - } - - /* Create progression status table */ - cinfo->coef_bits = (int (*)[DCTSIZE2]) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components*DCTSIZE2*SIZEOF(int)); - coef_bit_ptr = & cinfo->coef_bits[0][0]; - for (ci = 0; ci < cinfo->num_components; ci++) - for (i = 0; i < DCTSIZE2; i++) - *coef_bit_ptr++ = -1; -} - -#endif /* D_PROGRESSIVE_SUPPORTED */ +/* + * jdphuff.c + * + * Copyright (C) 1995-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains Huffman entropy decoding routines for progressive JPEG. + * + * Much of the complexity here has to do with supporting input suspension. + * If the data source module demands suspension, we want to be able to back + * up to the start of the current MCU. To do this, we copy state variables + * into local working storage, and update them back to the permanent + * storage only upon successful completion of an MCU. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdhuff.h" /* Declarations shared with jdhuff.c */ + + +#ifdef D_PROGRESSIVE_SUPPORTED + +/* + * Expanded entropy decoder object for progressive Huffman decoding. + * + * The savable_state subrecord contains fields that change within an MCU, + * but must not be updated permanently until we complete the MCU. + */ + +typedef struct { + unsigned int EOBRUN; /* remaining EOBs in EOBRUN */ + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ +} savable_state; + +/* This macro is to work around compilers with missing or broken + * structure assignment. You'll need to fix this code if you have + * such a compiler and you change MAX_COMPS_IN_SCAN. + */ + +#ifndef NO_STRUCT_ASSIGN +#define ASSIGN_STATE(dest,src) ((dest) = (src)) +#else +#if MAX_COMPS_IN_SCAN == 4 +#define ASSIGN_STATE(dest,src) \ + ((dest).EOBRUN = (src).EOBRUN, \ + (dest).last_dc_val[0] = (src).last_dc_val[0], \ + (dest).last_dc_val[1] = (src).last_dc_val[1], \ + (dest).last_dc_val[2] = (src).last_dc_val[2], \ + (dest).last_dc_val[3] = (src).last_dc_val[3]) +#endif +#endif + + +typedef struct { + struct jpeg_entropy_decoder pub; /* public fields */ + + /* These fields are loaded into local variables at start of each MCU. + * In case of suspension, we exit WITHOUT updating them. + */ + bitread_perm_state bitstate; /* Bit buffer at start of MCU */ + savable_state saved; /* Other state at start of MCU */ + + /* These fields are NOT loaded into local working state. */ + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + + /* Pointers to derived tables (these workspaces have image lifespan) */ + d_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; + + d_derived_tbl * ac_derived_tbl; /* active table during an AC scan */ +} phuff_entropy_decoder; + +typedef phuff_entropy_decoder * phuff_entropy_ptr; + +/* Forward declarations */ +METHODDEF(boolean) decode_mcu_DC_first JPP((j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) decode_mcu_AC_first JPP((j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) decode_mcu_DC_refine JPP((j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) decode_mcu_AC_refine JPP((j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); + + +/* + * Initialize for a Huffman-compressed scan. + */ + +METHODDEF(void) +start_pass_phuff_decoder (j_decompress_ptr cinfo) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + boolean is_DC_band, bad; + int ci, coefi, tbl; + int *coef_bit_ptr; + jpeg_component_info * compptr; + + is_DC_band = (cinfo->Ss == 0); + + /* Validate scan parameters */ + bad = FALSE; + if (is_DC_band) { + if (cinfo->Se != 0) + bad = TRUE; + } else { + /* need not check Ss/Se < 0 since they came from unsigned bytes */ + if (cinfo->Ss > cinfo->Se || cinfo->Se >= DCTSIZE2) + bad = TRUE; + /* AC scans may have only one component */ + if (cinfo->comps_in_scan != 1) + bad = TRUE; + } + if (cinfo->Ah != 0) { + /* Successive approximation refinement scan: must have Al = Ah-1. */ + if (cinfo->Al != cinfo->Ah-1) + bad = TRUE; + } + if (cinfo->Al > 13) /* need not check for < 0 */ + bad = TRUE; + /* Arguably the maximum Al value should be less than 13 for 8-bit precision, + * but the spec doesn't say so, and we try to be liberal about what we + * accept. Note: large Al values could result in out-of-range DC + * coefficients during early scans, leading to bizarre displays due to + * overflows in the IDCT math. But we won't crash. + */ + if (bad) + ERREXIT4(cinfo, JERR_BAD_PROGRESSION, + cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); + /* Update progression status, and verify that scan order is legal. + * Note that inter-scan inconsistencies are treated as warnings + * not fatal errors ... not clear if this is right way to behave. + */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + int cindex = cinfo->cur_comp_info[ci]->component_index; + coef_bit_ptr = & cinfo->coef_bits[cindex][0]; + if (!is_DC_band && coef_bit_ptr[0] < 0) /* AC without prior DC scan */ + WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0); + for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) { + int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi]; + if (cinfo->Ah != expected) + WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi); + coef_bit_ptr[coefi] = cinfo->Al; + } + } + + /* Select MCU decoding routine */ + if (cinfo->Ah == 0) { + if (is_DC_band) + entropy->pub.decode_mcu = decode_mcu_DC_first; + else + entropy->pub.decode_mcu = decode_mcu_AC_first; + } else { + if (is_DC_band) + entropy->pub.decode_mcu = decode_mcu_DC_refine; + else + entropy->pub.decode_mcu = decode_mcu_AC_refine; + } + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Make sure requested tables are present, and compute derived tables. + * We may build same derived table more than once, but it's not expensive. + */ + if (is_DC_band) { + if (cinfo->Ah == 0) { /* DC refinement needs no table */ + tbl = compptr->dc_tbl_no; + jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, + & entropy->derived_tbls[tbl]); + } + } else { + tbl = compptr->ac_tbl_no; + jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, + & entropy->derived_tbls[tbl]); + /* remember the single active table */ + entropy->ac_derived_tbl = entropy->derived_tbls[tbl]; + } + /* Initialize DC predictions to 0 */ + entropy->saved.last_dc_val[ci] = 0; + } + + /* Initialize bitread state variables */ + entropy->bitstate.bits_left = 0; + entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ + entropy->pub.insufficient_data = FALSE; + + /* Initialize private state variables */ + entropy->saved.EOBRUN = 0; + + /* Initialize restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; +} + + +/* + * Figure F.12: extend sign bit. + * On some machines, a shift and add will be faster than a table lookup. + */ + +#ifdef AVOID_TABLES + +#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) + +#else + +#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) + +static const int extend_test[16] = /* entry n is 2**(n-1) */ + { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, + 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; + +static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ + { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, + ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, + ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, + ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; + +#endif /* AVOID_TABLES */ + + +/* + * Check for a restart marker & resynchronize decoder. + * Returns FALSE if must suspend. + */ + +LOCAL(boolean) +process_restart (j_decompress_ptr cinfo) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int ci; + + /* Throw away any unused bits remaining in bit buffer; */ + /* include any full bytes in next_marker's count of discarded bytes */ + cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; + entropy->bitstate.bits_left = 0; + + /* Advance past the RSTn marker */ + if (! (*cinfo->marker->read_restart_marker) (cinfo)) + return FALSE; + + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) + entropy->saved.last_dc_val[ci] = 0; + /* Re-init EOB run count, too */ + entropy->saved.EOBRUN = 0; + + /* Reset restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; + + /* Reset out-of-data flag, unless read_restart_marker left us smack up + * against a marker. In that case we will end up treating the next data + * segment as empty, and we can avoid producing bogus output pixels by + * leaving the flag set. + */ + if (cinfo->unread_marker == 0) + entropy->pub.insufficient_data = FALSE; + + return TRUE; +} + + +/* + * Huffman MCU decoding. + * Each of these routines decodes and returns one MCU's worth of + * Huffman-compressed coefficients. + * The coefficients are reordered from zigzag order into natural array order, + * but are not dequantized. + * + * The i'th block of the MCU is stored into the block pointed to by + * MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER. + * + * We return FALSE if data source requested suspension. In that case no + * changes have been made to permanent state. (Exception: some output + * coefficients may already have been assigned. This is harmless for + * spectral selection, since we'll just re-assign them on the next call. + * Successive approximation AC refinement has to be more careful, however.) + */ + +/* + * MCU decoding for DC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int Al = cinfo->Al; + register int s, r; + int blkn, ci; + JBLOCKROW block; + BITREAD_STATE_VARS; + savable_state state; + d_derived_tbl * tbl; + jpeg_component_info * compptr; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* If we've run out of data, just leave the MCU set to zeroes. + * This way, we return uniform gray for the remainder of the segment. + */ + if (! entropy->pub.insufficient_data) { + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + ASSIGN_STATE(state, entropy->saved); + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + tbl = entropy->derived_tbls[compptr->dc_tbl_no]; + + /* Decode a single block's worth of coefficients */ + + /* Section F.2.2.1: decode the DC coefficient difference */ + HUFF_DECODE(s, br_state, tbl, return FALSE, label1); + if (s) { + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + } + + /* Convert DC difference to actual value, update last_dc_val */ + s += state.last_dc_val[ci]; + state.last_dc_val[ci] = s; + /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */ + (*block)[0] = (JCOEF) (s << Al); + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + ASSIGN_STATE(entropy->saved, state); + } + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * MCU decoding for AC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int Se = cinfo->Se; + int Al = cinfo->Al; + register int s, k, r; + unsigned int EOBRUN; + JBLOCKROW block; + BITREAD_STATE_VARS; + d_derived_tbl * tbl; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* If we've run out of data, just leave the MCU set to zeroes. + * This way, we return uniform gray for the remainder of the segment. + */ + if (! entropy->pub.insufficient_data) { + + /* Load up working state. + * We can avoid loading/saving bitread state if in an EOB run. + */ + EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ + + /* There is always only one block per MCU */ + + if (EOBRUN > 0) /* if it's a band of zeroes... */ + EOBRUN--; /* ...process it now (we do nothing) */ + else { + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + block = MCU_data[0]; + tbl = entropy->ac_derived_tbl; + + for (k = cinfo->Ss; k <= Se; k++) { + HUFF_DECODE(s, br_state, tbl, return FALSE, label2); + r = s >> 4; + s &= 15; + if (s) { + k += r; + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + /* Scale and output coefficient in natural (dezigzagged) order */ + (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al); + } else { + if (r == 15) { /* ZRL */ + k += 15; /* skip 15 zeroes in band */ + } else { /* EOBr, run length is 2^r + appended bits */ + EOBRUN = 1 << r; + if (r) { /* EOBr, r > 0 */ + CHECK_BIT_BUFFER(br_state, r, return FALSE); + r = GET_BITS(r); + EOBRUN += r; + } + EOBRUN--; /* this band is processed at this moment */ + break; /* force end-of-band */ + } + } + } + + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + } + + /* Completed MCU, so update state */ + entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ + } + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * MCU decoding for DC successive approximation refinement scan. + * Note: we assume such scans can be multi-component, although the spec + * is not very clear on the point. + */ + +METHODDEF(boolean) +decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ + int blkn; + JBLOCKROW block; + BITREAD_STATE_VARS; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* Not worth the cycles to check insufficient_data here, + * since we will not change the data anyway if we read zeroes. + */ + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + + /* Encoded data is simply the next bit of the two's-complement DC value */ + CHECK_BIT_BUFFER(br_state, 1, return FALSE); + if (GET_BITS(1)) + (*block)[0] |= p1; + /* Note: since we use |=, repeating the assignment later is safe */ + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * MCU decoding for AC successive approximation refinement scan. + */ + +METHODDEF(boolean) +decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int Se = cinfo->Se; + int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ + int m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */ + register int s, k, r; + unsigned int EOBRUN; + JBLOCKROW block; + JCOEFPTR thiscoef; + BITREAD_STATE_VARS; + d_derived_tbl * tbl; + int num_newnz; + int newnz_pos[DCTSIZE2]; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* If we've run out of data, don't modify the MCU. + */ + if (! entropy->pub.insufficient_data) { + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ + + /* There is always only one block per MCU */ + block = MCU_data[0]; + tbl = entropy->ac_derived_tbl; + + /* If we are forced to suspend, we must undo the assignments to any newly + * nonzero coefficients in the block, because otherwise we'd get confused + * next time about which coefficients were already nonzero. + * But we need not undo addition of bits to already-nonzero coefficients; + * instead, we can test the current bit to see if we already did it. + */ + num_newnz = 0; + + /* initialize coefficient loop counter to start of band */ + k = cinfo->Ss; + + if (EOBRUN == 0) { + for (; k <= Se; k++) { + HUFF_DECODE(s, br_state, tbl, goto undoit, label3); + r = s >> 4; + s &= 15; + if (s) { + if (s != 1) /* size of new coef should always be 1 */ + WARNMS(cinfo, JWRN_HUFF_BAD_CODE); + CHECK_BIT_BUFFER(br_state, 1, goto undoit); + if (GET_BITS(1)) + s = p1; /* newly nonzero coef is positive */ + else + s = m1; /* newly nonzero coef is negative */ + } else { + if (r != 15) { + EOBRUN = 1 << r; /* EOBr, run length is 2^r + appended bits */ + if (r) { + CHECK_BIT_BUFFER(br_state, r, goto undoit); + r = GET_BITS(r); + EOBRUN += r; + } + break; /* rest of block is handled by EOB logic */ + } + /* note s = 0 for processing ZRL */ + } + /* Advance over already-nonzero coefs and r still-zero coefs, + * appending correction bits to the nonzeroes. A correction bit is 1 + * if the absolute value of the coefficient must be increased. + */ + do { + thiscoef = *block + jpeg_natural_order[k]; + if (*thiscoef != 0) { + CHECK_BIT_BUFFER(br_state, 1, goto undoit); + if (GET_BITS(1)) { + if ((*thiscoef & p1) == 0) { /* do nothing if already set it */ + if (*thiscoef >= 0) + *thiscoef += p1; + else + *thiscoef += m1; + } + } + } else { + if (--r < 0) + break; /* reached target zero coefficient */ + } + k++; + } while (k <= Se); + if (s) { + int pos = jpeg_natural_order[k]; + /* Output newly nonzero coefficient */ + (*block)[pos] = (JCOEF) s; + /* Remember its position in case we have to suspend */ + newnz_pos[num_newnz++] = pos; + } + } + } + + if (EOBRUN > 0) { + /* Scan any remaining coefficient positions after the end-of-band + * (the last newly nonzero coefficient, if any). Append a correction + * bit to each already-nonzero coefficient. A correction bit is 1 + * if the absolute value of the coefficient must be increased. + */ + for (; k <= Se; k++) { + thiscoef = *block + jpeg_natural_order[k]; + if (*thiscoef != 0) { + CHECK_BIT_BUFFER(br_state, 1, goto undoit); + if (GET_BITS(1)) { + if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */ + if (*thiscoef >= 0) + *thiscoef += p1; + else + *thiscoef += m1; + } + } + } + } + /* Count one block completed in EOB run */ + EOBRUN--; + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ + } + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; + +undoit: + /* Re-zero any output coefficients that we made newly nonzero */ + while (num_newnz > 0) + (*block)[newnz_pos[--num_newnz]] = 0; + + return FALSE; +} + + +/* + * Module initialization routine for progressive Huffman entropy decoding. + */ + +GLOBAL(void) +jinit_phuff_decoder (j_decompress_ptr cinfo) +{ + phuff_entropy_ptr entropy; + int *coef_bit_ptr; + int ci, i; + + entropy = (phuff_entropy_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(phuff_entropy_decoder)); + cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; + entropy->pub.start_pass = start_pass_phuff_decoder; + + /* Mark derived tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->derived_tbls[i] = NULL; + } + + /* Create progression status table */ + cinfo->coef_bits = (int (*)[DCTSIZE2]) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components*DCTSIZE2*SIZEOF(int)); + coef_bit_ptr = & cinfo->coef_bits[0][0]; + for (ci = 0; ci < cinfo->num_components; ci++) + for (i = 0; i < DCTSIZE2; i++) + *coef_bit_ptr++ = -1; +} + +#endif /* D_PROGRESSIVE_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/jdpostct.c b/src/dep/src/irrlicht/jpeglib/jdpostct.c index 7ba9eed..571563d 100644 --- a/src/dep/src/irrlicht/jpeglib/jdpostct.c +++ b/src/dep/src/irrlicht/jpeglib/jdpostct.c @@ -1,290 +1,290 @@ -/* - * jdpostct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the decompression postprocessing controller. - * This controller manages the upsampling, color conversion, and color - * quantization/reduction steps; specifically, it controls the buffering - * between upsample/color conversion and color quantization/reduction. - * - * If no color quantization/reduction is required, then this module has no - * work to do, and it just hands off to the upsample/color conversion code. - * An integrated upsample/convert/quantize process would replace this module - * entirely. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_post_controller pub; /* public fields */ - - /* Color quantization source buffer: this holds output data from - * the upsample/color conversion step to be passed to the quantizer. - * For two-pass color quantization, we need a full-image buffer; - * for one-pass operation, a strip buffer is sufficient. - */ - jvirt_sarray_ptr whole_image; /* virtual array, or NULL if one-pass */ - JSAMPARRAY buffer; /* strip buffer, or current strip of virtual */ - JDIMENSION strip_height; /* buffer size in rows */ - /* for two-pass mode only: */ - JDIMENSION starting_row; /* row # of first row in current strip */ - JDIMENSION next_row; /* index of next row to fill/empty in strip */ -} my_post_controller; - -typedef my_post_controller * my_post_ptr; - - -/* Forward declarations */ -METHODDEF(void) post_process_1pass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -#ifdef QUANT_2PASS_SUPPORTED -METHODDEF(void) post_process_prepass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -METHODDEF(void) post_process_2pass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -#endif - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (cinfo->quantize_colors) { - /* Single-pass processing with color quantization. */ - post->pub.post_process_data = post_process_1pass; - /* We could be doing buffered-image output before starting a 2-pass - * color quantization; in that case, jinit_d_post_controller did not - * allocate a strip buffer. Use the virtual-array buffer as workspace. - */ - if (post->buffer == NULL) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - (JDIMENSION) 0, post->strip_height, TRUE); - } - } else { - /* For single-pass processing without color quantization, - * I have no work to do; just call the upsampler directly. - */ - post->pub.post_process_data = cinfo->upsample->upsample; - } - break; -#ifdef QUANT_2PASS_SUPPORTED - case JBUF_SAVE_AND_PASS: - /* First pass of 2-pass quantization */ - if (post->whole_image == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - post->pub.post_process_data = post_process_prepass; - break; - case JBUF_CRANK_DEST: - /* Second pass of 2-pass quantization */ - if (post->whole_image == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - post->pub.post_process_data = post_process_2pass; - break; -#endif /* QUANT_2PASS_SUPPORTED */ - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } - post->starting_row = post->next_row = 0; -} - - -/* - * Process some data in the one-pass (strip buffer) case. - * This is used for color precision reduction as well as one-pass quantization. - */ - -METHODDEF(void) -post_process_1pass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION num_rows, max_rows; - - /* Fill the buffer, but not more than what we can dump out in one go. */ - /* Note we rely on the upsampler to detect bottom of image. */ - max_rows = out_rows_avail - *out_row_ctr; - if (max_rows > post->strip_height) - max_rows = post->strip_height; - num_rows = 0; - (*cinfo->upsample->upsample) (cinfo, - input_buf, in_row_group_ctr, in_row_groups_avail, - post->buffer, &num_rows, max_rows); - /* Quantize and emit data. */ - (*cinfo->cquantize->color_quantize) (cinfo, - post->buffer, output_buf + *out_row_ctr, (int) num_rows); - *out_row_ctr += num_rows; -} - - -#ifdef QUANT_2PASS_SUPPORTED - -/* - * Process some data in the first pass of 2-pass quantization. - */ - -METHODDEF(void) -post_process_prepass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION old_next_row, num_rows; - - /* Reposition virtual buffer if at start of strip. */ - if (post->next_row == 0) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - post->starting_row, post->strip_height, TRUE); - } - - /* Upsample some data (up to a strip height's worth). */ - old_next_row = post->next_row; - (*cinfo->upsample->upsample) (cinfo, - input_buf, in_row_group_ctr, in_row_groups_avail, - post->buffer, &post->next_row, post->strip_height); - - /* Allow quantizer to scan new data. No data is emitted, */ - /* but we advance out_row_ctr so outer loop can tell when we're done. */ - if (post->next_row > old_next_row) { - num_rows = post->next_row - old_next_row; - (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row, - (JSAMPARRAY) NULL, (int) num_rows); - *out_row_ctr += num_rows; - } - - /* Advance if we filled the strip. */ - if (post->next_row >= post->strip_height) { - post->starting_row += post->strip_height; - post->next_row = 0; - } -} - - -/* - * Process some data in the second pass of 2-pass quantization. - */ - -METHODDEF(void) -post_process_2pass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION num_rows, max_rows; - - /* Reposition virtual buffer if at start of strip. */ - if (post->next_row == 0) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - post->starting_row, post->strip_height, FALSE); - } - - /* Determine number of rows to emit. */ - num_rows = post->strip_height - post->next_row; /* available in strip */ - max_rows = out_rows_avail - *out_row_ctr; /* available in output area */ - if (num_rows > max_rows) - num_rows = max_rows; - /* We have to check bottom of image here, can't depend on upsampler. */ - max_rows = cinfo->output_height - post->starting_row; - if (num_rows > max_rows) - num_rows = max_rows; - - /* Quantize and emit data. */ - (*cinfo->cquantize->color_quantize) (cinfo, - post->buffer + post->next_row, output_buf + *out_row_ctr, - (int) num_rows); - *out_row_ctr += num_rows; - - /* Advance if we filled the strip. */ - post->next_row += num_rows; - if (post->next_row >= post->strip_height) { - post->starting_row += post->strip_height; - post->next_row = 0; - } -} - -#endif /* QUANT_2PASS_SUPPORTED */ - - -/* - * Initialize postprocessing controller. - */ - -GLOBAL(void) -jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_post_ptr post; - - post = (my_post_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_post_controller)); - cinfo->post = (struct jpeg_d_post_controller *) post; - post->pub.start_pass = start_pass_dpost; - post->whole_image = NULL; /* flag for no virtual arrays */ - post->buffer = NULL; /* flag for no strip buffer */ - - /* Create the quantization buffer, if needed */ - if (cinfo->quantize_colors) { - /* The buffer strip height is max_v_samp_factor, which is typically - * an efficient number of rows for upsampling to return. - * (In the presence of output rescaling, we might want to be smarter?) - */ - post->strip_height = (JDIMENSION) cinfo->max_v_samp_factor; - if (need_full_buffer) { - /* Two-pass color quantization: need full-image storage. */ - /* We round up the number of rows to a multiple of the strip height. */ -#ifdef QUANT_2PASS_SUPPORTED - post->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - cinfo->output_width * cinfo->out_color_components, - (JDIMENSION) jround_up((long) cinfo->output_height, - (long) post->strip_height), - post->strip_height); -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif /* QUANT_2PASS_SUPPORTED */ - } else { - /* One-pass color quantization: just make a strip buffer. */ - post->buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->output_width * cinfo->out_color_components, - post->strip_height); - } - } -} +/* + * jdpostct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the decompression postprocessing controller. + * This controller manages the upsampling, color conversion, and color + * quantization/reduction steps; specifically, it controls the buffering + * between upsample/color conversion and color quantization/reduction. + * + * If no color quantization/reduction is required, then this module has no + * work to do, and it just hands off to the upsample/color conversion code. + * An integrated upsample/convert/quantize process would replace this module + * entirely. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_d_post_controller pub; /* public fields */ + + /* Color quantization source buffer: this holds output data from + * the upsample/color conversion step to be passed to the quantizer. + * For two-pass color quantization, we need a full-image buffer; + * for one-pass operation, a strip buffer is sufficient. + */ + jvirt_sarray_ptr whole_image; /* virtual array, or NULL if one-pass */ + JSAMPARRAY buffer; /* strip buffer, or current strip of virtual */ + JDIMENSION strip_height; /* buffer size in rows */ + /* for two-pass mode only: */ + JDIMENSION starting_row; /* row # of first row in current strip */ + JDIMENSION next_row; /* index of next row to fill/empty in strip */ +} my_post_controller; + +typedef my_post_controller * my_post_ptr; + + +/* Forward declarations */ +METHODDEF(void) post_process_1pass + JPP((j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +#ifdef QUANT_2PASS_SUPPORTED +METHODDEF(void) post_process_prepass + JPP((j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +METHODDEF(void) post_process_2pass + JPP((j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +#endif + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + + switch (pass_mode) { + case JBUF_PASS_THRU: + if (cinfo->quantize_colors) { + /* Single-pass processing with color quantization. */ + post->pub.post_process_data = post_process_1pass; + /* We could be doing buffered-image output before starting a 2-pass + * color quantization; in that case, jinit_d_post_controller did not + * allocate a strip buffer. Use the virtual-array buffer as workspace. + */ + if (post->buffer == NULL) { + post->buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, post->whole_image, + (JDIMENSION) 0, post->strip_height, TRUE); + } + } else { + /* For single-pass processing without color quantization, + * I have no work to do; just call the upsampler directly. + */ + post->pub.post_process_data = cinfo->upsample->upsample; + } + break; +#ifdef QUANT_2PASS_SUPPORTED + case JBUF_SAVE_AND_PASS: + /* First pass of 2-pass quantization */ + if (post->whole_image == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + post->pub.post_process_data = post_process_prepass; + break; + case JBUF_CRANK_DEST: + /* Second pass of 2-pass quantization */ + if (post->whole_image == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + post->pub.post_process_data = post_process_2pass; + break; +#endif /* QUANT_2PASS_SUPPORTED */ + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + break; + } + post->starting_row = post->next_row = 0; +} + + +/* + * Process some data in the one-pass (strip buffer) case. + * This is used for color precision reduction as well as one-pass quantization. + */ + +METHODDEF(void) +post_process_1pass (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + JDIMENSION num_rows, max_rows; + + /* Fill the buffer, but not more than what we can dump out in one go. */ + /* Note we rely on the upsampler to detect bottom of image. */ + max_rows = out_rows_avail - *out_row_ctr; + if (max_rows > post->strip_height) + max_rows = post->strip_height; + num_rows = 0; + (*cinfo->upsample->upsample) (cinfo, + input_buf, in_row_group_ctr, in_row_groups_avail, + post->buffer, &num_rows, max_rows); + /* Quantize and emit data. */ + (*cinfo->cquantize->color_quantize) (cinfo, + post->buffer, output_buf + *out_row_ctr, (int) num_rows); + *out_row_ctr += num_rows; +} + + +#ifdef QUANT_2PASS_SUPPORTED + +/* + * Process some data in the first pass of 2-pass quantization. + */ + +METHODDEF(void) +post_process_prepass (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + JDIMENSION old_next_row, num_rows; + + /* Reposition virtual buffer if at start of strip. */ + if (post->next_row == 0) { + post->buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, post->whole_image, + post->starting_row, post->strip_height, TRUE); + } + + /* Upsample some data (up to a strip height's worth). */ + old_next_row = post->next_row; + (*cinfo->upsample->upsample) (cinfo, + input_buf, in_row_group_ctr, in_row_groups_avail, + post->buffer, &post->next_row, post->strip_height); + + /* Allow quantizer to scan new data. No data is emitted, */ + /* but we advance out_row_ctr so outer loop can tell when we're done. */ + if (post->next_row > old_next_row) { + num_rows = post->next_row - old_next_row; + (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row, + (JSAMPARRAY) NULL, (int) num_rows); + *out_row_ctr += num_rows; + } + + /* Advance if we filled the strip. */ + if (post->next_row >= post->strip_height) { + post->starting_row += post->strip_height; + post->next_row = 0; + } +} + + +/* + * Process some data in the second pass of 2-pass quantization. + */ + +METHODDEF(void) +post_process_2pass (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + JDIMENSION num_rows, max_rows; + + /* Reposition virtual buffer if at start of strip. */ + if (post->next_row == 0) { + post->buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, post->whole_image, + post->starting_row, post->strip_height, FALSE); + } + + /* Determine number of rows to emit. */ + num_rows = post->strip_height - post->next_row; /* available in strip */ + max_rows = out_rows_avail - *out_row_ctr; /* available in output area */ + if (num_rows > max_rows) + num_rows = max_rows; + /* We have to check bottom of image here, can't depend on upsampler. */ + max_rows = cinfo->output_height - post->starting_row; + if (num_rows > max_rows) + num_rows = max_rows; + + /* Quantize and emit data. */ + (*cinfo->cquantize->color_quantize) (cinfo, + post->buffer + post->next_row, output_buf + *out_row_ctr, + (int) num_rows); + *out_row_ctr += num_rows; + + /* Advance if we filled the strip. */ + post->next_row += num_rows; + if (post->next_row >= post->strip_height) { + post->starting_row += post->strip_height; + post->next_row = 0; + } +} + +#endif /* QUANT_2PASS_SUPPORTED */ + + +/* + * Initialize postprocessing controller. + */ + +GLOBAL(void) +jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer) +{ + my_post_ptr post; + + post = (my_post_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_post_controller)); + cinfo->post = (struct jpeg_d_post_controller *) post; + post->pub.start_pass = start_pass_dpost; + post->whole_image = NULL; /* flag for no virtual arrays */ + post->buffer = NULL; /* flag for no strip buffer */ + + /* Create the quantization buffer, if needed */ + if (cinfo->quantize_colors) { + /* The buffer strip height is max_v_samp_factor, which is typically + * an efficient number of rows for upsampling to return. + * (In the presence of output rescaling, we might want to be smarter?) + */ + post->strip_height = (JDIMENSION) cinfo->max_v_samp_factor; + if (need_full_buffer) { + /* Two-pass color quantization: need full-image storage. */ + /* We round up the number of rows to a multiple of the strip height. */ +#ifdef QUANT_2PASS_SUPPORTED + post->whole_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + cinfo->output_width * cinfo->out_color_components, + (JDIMENSION) jround_up((long) cinfo->output_height, + (long) post->strip_height), + post->strip_height); +#else + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif /* QUANT_2PASS_SUPPORTED */ + } else { + /* One-pass color quantization: just make a strip buffer. */ + post->buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->output_width * cinfo->out_color_components, + post->strip_height); + } + } +} diff --git a/src/dep/src/irrlicht/jpeglib/jdsample.c b/src/dep/src/irrlicht/jpeglib/jdsample.c index e0d9040..80ffefb 100644 --- a/src/dep/src/irrlicht/jpeglib/jdsample.c +++ b/src/dep/src/irrlicht/jpeglib/jdsample.c @@ -1,478 +1,478 @@ -/* - * jdsample.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains upsampling routines. - * - * Upsampling input data is counted in "row groups". A row group - * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) - * sample rows of each component. Upsampling will normally produce - * max_v_samp_factor pixel rows from each row group (but this could vary - * if the upsampler is applying a scale factor of its own). - * - * An excellent reference for image resampling is - * Digital Image Warping, George Wolberg, 1990. - * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Pointer to routine to upsample a single component */ -typedef JMETHOD(void, upsample1_ptr, - (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); - -/* Private subobject */ - -typedef struct { - struct jpeg_upsampler pub; /* public fields */ - - /* Color conversion buffer. When using separate upsampling and color - * conversion steps, this buffer holds one upsampled row group until it - * has been color converted and output. - * Note: we do not allocate any storage for component(s) which are full-size, - * ie do not need rescaling. The corresponding entry of color_buf[] is - * simply set to point to the input data array, thereby avoiding copying. - */ - JSAMPARRAY color_buf[MAX_COMPONENTS]; - - /* Per-component upsampling method pointers */ - upsample1_ptr methods[MAX_COMPONENTS]; - - int next_row_out; /* counts rows emitted from color_buf */ - JDIMENSION rows_to_go; /* counts rows remaining in image */ - - /* Height of an input row group for each component. */ - int rowgroup_height[MAX_COMPONENTS]; - - /* These arrays save pixel expansion factors so that int_expand need not - * recompute them each time. They are unused for other upsampling methods. - */ - UINT8 h_expand[MAX_COMPONENTS]; - UINT8 v_expand[MAX_COMPONENTS]; -} my_upsampler; - -typedef my_upsampler * my_upsample_ptr; - - -/* - * Initialize for an upsampling pass. - */ - -METHODDEF(void) -start_pass_upsample (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Mark the conversion buffer empty */ - upsample->next_row_out = cinfo->max_v_samp_factor; - /* Initialize total-height counter for detecting bottom of image */ - upsample->rows_to_go = cinfo->output_height; -} - - -/* - * Control routine to do upsampling (and color conversion). - * - * In this version we upsample each component independently. - * We upsample one row group into the conversion buffer, then apply - * color conversion a row at a time. - */ - -METHODDEF(void) -sep_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - int ci; - jpeg_component_info * compptr; - JDIMENSION num_rows; - - /* Fill the conversion buffer, if it's empty */ - if (upsample->next_row_out >= cinfo->max_v_samp_factor) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Invoke per-component upsample method. Notice we pass a POINTER - * to color_buf[ci], so that fullsize_upsample can change it. - */ - (*upsample->methods[ci]) (cinfo, compptr, - input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]), - upsample->color_buf + ci); - } - upsample->next_row_out = 0; - } - - /* Color-convert and emit rows */ - - /* How many we have in the buffer: */ - num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out); - /* Not more than the distance to the end of the image. Need this test - * in case the image height is not a multiple of max_v_samp_factor: - */ - if (num_rows > upsample->rows_to_go) - num_rows = upsample->rows_to_go; - /* And not more than what the client can accept: */ - out_rows_avail -= *out_row_ctr; - if (num_rows > out_rows_avail) - num_rows = out_rows_avail; - - (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf, - (JDIMENSION) upsample->next_row_out, - output_buf + *out_row_ctr, - (int) num_rows); - - /* Adjust counts */ - *out_row_ctr += num_rows; - upsample->rows_to_go -= num_rows; - upsample->next_row_out += num_rows; - /* When the buffer is emptied, declare this input row group consumed */ - if (upsample->next_row_out >= cinfo->max_v_samp_factor) - (*in_row_group_ctr)++; -} - - -/* - * These are the routines invoked by sep_upsample to upsample pixel values - * of a single component. One row group is processed per call. - */ - - -/* - * For full-size components, we just make color_buf[ci] point at the - * input buffer, and thus avoid copying any data. Note that this is - * safe only because sep_upsample doesn't declare the input row group - * "consumed" until we are done color converting and emitting it. - */ - -METHODDEF(void) -fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - *output_data_ptr = input_data; -} - - -/* - * This is a no-op version used for "uninteresting" components. - * These components will not be referenced by color conversion. - */ - -METHODDEF(void) -noop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - *output_data_ptr = NULL; /* safety check */ -} - - -/* - * This version handles any integral sampling ratios. - * This is not used for typical JPEG files, so it need not be fast. - * Nor, for that matter, is it particularly accurate: the algorithm is - * simple replication of the input pixel onto the corresponding output - * pixels. The hi-falutin sampling literature refers to this as a - * "box filter". A box filter tends to introduce visible artifacts, - * so if you are actually going to use 3:1 or 4:1 sampling ratios - * you would be well advised to improve this code. - */ - -METHODDEF(void) -int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - register int h; - JSAMPROW outend; - int h_expand, v_expand; - int inrow, outrow; - - h_expand = upsample->h_expand[compptr->component_index]; - v_expand = upsample->v_expand[compptr->component_index]; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - /* Generate one output row with proper horizontal expansion */ - inptr = input_data[inrow]; - outptr = output_data[outrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - for (h = h_expand; h > 0; h--) { - *outptr++ = invalue; - } - } - /* Generate any additional output rows by duplicating the first one */ - if (v_expand > 1) { - jcopy_sample_rows(output_data, outrow, output_data, outrow+1, - v_expand-1, cinfo->output_width); - } - inrow++; - outrow += v_expand; - } -} - - -/* - * Fast processing for the common case of 2:1 horizontal and 1:1 vertical. - * It's still a box filter. - */ - -METHODDEF(void) -h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - JSAMPROW outend; - int inrow; - - for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { - inptr = input_data[inrow]; - outptr = output_data[inrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - *outptr++ = invalue; - *outptr++ = invalue; - } - } -} - - -/* - * Fast processing for the common case of 2:1 horizontal and 2:1 vertical. - * It's still a box filter. - */ - -METHODDEF(void) -h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - JSAMPROW outend; - int inrow, outrow; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - inptr = input_data[inrow]; - outptr = output_data[outrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - *outptr++ = invalue; - *outptr++ = invalue; - } - jcopy_sample_rows(output_data, outrow, output_data, outrow+1, - 1, cinfo->output_width); - inrow++; - outrow += 2; - } -} - - -/* - * Fancy processing for the common case of 2:1 horizontal and 1:1 vertical. - * - * The upsampling algorithm is linear interpolation between pixel centers, - * also known as a "triangle filter". This is a good compromise between - * speed and visual quality. The centers of the output pixels are 1/4 and 3/4 - * of the way between input pixel centers. - * - * A note about the "bias" calculations: when rounding fractional values to - * integer, we do not want to always round 0.5 up to the next integer. - * If we did that, we'd introduce a noticeable bias towards larger values. - * Instead, this code is arranged so that 0.5 will be rounded up or down at - * alternate pixel locations (a simple ordered dither pattern). - */ - -METHODDEF(void) -h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register int invalue; - register JDIMENSION colctr; - int inrow; - - for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { - inptr = input_data[inrow]; - outptr = output_data[inrow]; - /* Special case for first column */ - invalue = GETJSAMPLE(*inptr++); - *outptr++ = (JSAMPLE) invalue; - *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2); - - for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { - /* General case: 3/4 * nearer pixel + 1/4 * further pixel */ - invalue = GETJSAMPLE(*inptr++) * 3; - *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2); - *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(*inptr) + 2) >> 2); - } - - /* Special case for last column */ - invalue = GETJSAMPLE(*inptr); - *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2); - *outptr++ = (JSAMPLE) invalue; - } -} - - -/* - * Fancy processing for the common case of 2:1 horizontal and 2:1 vertical. - * Again a triangle filter; see comments for h2v1 case, above. - * - * It is OK for us to reference the adjacent input rows because we demanded - * context from the main buffer controller (see initialization code). - */ - -METHODDEF(void) -h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr0, inptr1, outptr; -#if BITS_IN_JSAMPLE == 8 - register int thiscolsum, lastcolsum, nextcolsum; -#else - register INT32 thiscolsum, lastcolsum, nextcolsum; -#endif - register JDIMENSION colctr; - int inrow, outrow, v; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - for (v = 0; v < 2; v++) { - /* inptr0 points to nearest input row, inptr1 points to next nearest */ - inptr0 = input_data[inrow]; - if (v == 0) /* next nearest is row above */ - inptr1 = input_data[inrow-1]; - else /* next nearest is row below */ - inptr1 = input_data[inrow+1]; - outptr = output_data[outrow++]; - - /* Special case for first column */ - thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); - lastcolsum = thiscolsum; thiscolsum = nextcolsum; - - for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { - /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */ - /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */ - nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); - lastcolsum = thiscolsum; thiscolsum = nextcolsum; - } - - /* Special case for last column */ - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4); - } - inrow++; - } -} - - -/* - * Module initialization routine for upsampling. - */ - -GLOBAL(void) -jinit_upsampler (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample; - int ci; - jpeg_component_info * compptr; - boolean need_buffer, do_fancy; - int h_in_group, v_in_group, h_out_group, v_out_group; - - upsample = (my_upsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_upsampler)); - cinfo->upsample = (struct jpeg_upsampler *) upsample; - upsample->pub.start_pass = start_pass_upsample; - upsample->pub.upsample = sep_upsample; - upsample->pub.need_context_rows = FALSE; /* until we find out differently */ - - if (cinfo->CCIR601_sampling) /* this isn't supported */ - ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); - - /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, - * so don't ask for it. - */ - do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1; - - /* Verify we can handle the sampling factors, select per-component methods, - * and create storage as needed. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Compute size of an "input group" after IDCT scaling. This many samples - * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. - */ - h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; - v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; - h_out_group = cinfo->max_h_samp_factor; - v_out_group = cinfo->max_v_samp_factor; - upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ - need_buffer = TRUE; - if (! compptr->component_needed) { - /* Don't bother to upsample an uninteresting component. */ - upsample->methods[ci] = noop_upsample; - need_buffer = FALSE; - } else if (h_in_group == h_out_group && v_in_group == v_out_group) { - /* Fullsize components can be processed without any work. */ - upsample->methods[ci] = fullsize_upsample; - need_buffer = FALSE; - } else if (h_in_group * 2 == h_out_group && - v_in_group == v_out_group) { - /* Special cases for 2h1v upsampling */ - if (do_fancy && compptr->downsampled_width > 2) - upsample->methods[ci] = h2v1_fancy_upsample; - else - upsample->methods[ci] = h2v1_upsample; - } else if (h_in_group * 2 == h_out_group && - v_in_group * 2 == v_out_group) { - /* Special cases for 2h2v upsampling */ - if (do_fancy && compptr->downsampled_width > 2) { - upsample->methods[ci] = h2v2_fancy_upsample; - upsample->pub.need_context_rows = TRUE; - } else - upsample->methods[ci] = h2v2_upsample; - } else if ((h_out_group % h_in_group) == 0 && - (v_out_group % v_in_group) == 0) { - /* Generic integral-factors upsampling method */ - upsample->methods[ci] = int_upsample; - upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group); - upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group); - } else - ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); - if (need_buffer) { - upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) jround_up((long) cinfo->output_width, - (long) cinfo->max_h_samp_factor), - (JDIMENSION) cinfo->max_v_samp_factor); - } - } -} +/* + * jdsample.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains upsampling routines. + * + * Upsampling input data is counted in "row groups". A row group + * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) + * sample rows of each component. Upsampling will normally produce + * max_v_samp_factor pixel rows from each row group (but this could vary + * if the upsampler is applying a scale factor of its own). + * + * An excellent reference for image resampling is + * Digital Image Warping, George Wolberg, 1990. + * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Pointer to routine to upsample a single component */ +typedef JMETHOD(void, upsample1_ptr, + (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); + +/* Private subobject */ + +typedef struct { + struct jpeg_upsampler pub; /* public fields */ + + /* Color conversion buffer. When using separate upsampling and color + * conversion steps, this buffer holds one upsampled row group until it + * has been color converted and output. + * Note: we do not allocate any storage for component(s) which are full-size, + * ie do not need rescaling. The corresponding entry of color_buf[] is + * simply set to point to the input data array, thereby avoiding copying. + */ + JSAMPARRAY color_buf[MAX_COMPONENTS]; + + /* Per-component upsampling method pointers */ + upsample1_ptr methods[MAX_COMPONENTS]; + + int next_row_out; /* counts rows emitted from color_buf */ + JDIMENSION rows_to_go; /* counts rows remaining in image */ + + /* Height of an input row group for each component. */ + int rowgroup_height[MAX_COMPONENTS]; + + /* These arrays save pixel expansion factors so that int_expand need not + * recompute them each time. They are unused for other upsampling methods. + */ + UINT8 h_expand[MAX_COMPONENTS]; + UINT8 v_expand[MAX_COMPONENTS]; +} my_upsampler; + +typedef my_upsampler * my_upsample_ptr; + + +/* + * Initialize for an upsampling pass. + */ + +METHODDEF(void) +start_pass_upsample (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + + /* Mark the conversion buffer empty */ + upsample->next_row_out = cinfo->max_v_samp_factor; + /* Initialize total-height counter for detecting bottom of image */ + upsample->rows_to_go = cinfo->output_height; +} + + +/* + * Control routine to do upsampling (and color conversion). + * + * In this version we upsample each component independently. + * We upsample one row group into the conversion buffer, then apply + * color conversion a row at a time. + */ + +METHODDEF(void) +sep_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + int ci; + jpeg_component_info * compptr; + JDIMENSION num_rows; + + /* Fill the conversion buffer, if it's empty */ + if (upsample->next_row_out >= cinfo->max_v_samp_factor) { + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Invoke per-component upsample method. Notice we pass a POINTER + * to color_buf[ci], so that fullsize_upsample can change it. + */ + (*upsample->methods[ci]) (cinfo, compptr, + input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]), + upsample->color_buf + ci); + } + upsample->next_row_out = 0; + } + + /* Color-convert and emit rows */ + + /* How many we have in the buffer: */ + num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out); + /* Not more than the distance to the end of the image. Need this test + * in case the image height is not a multiple of max_v_samp_factor: + */ + if (num_rows > upsample->rows_to_go) + num_rows = upsample->rows_to_go; + /* And not more than what the client can accept: */ + out_rows_avail -= *out_row_ctr; + if (num_rows > out_rows_avail) + num_rows = out_rows_avail; + + (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf, + (JDIMENSION) upsample->next_row_out, + output_buf + *out_row_ctr, + (int) num_rows); + + /* Adjust counts */ + *out_row_ctr += num_rows; + upsample->rows_to_go -= num_rows; + upsample->next_row_out += num_rows; + /* When the buffer is emptied, declare this input row group consumed */ + if (upsample->next_row_out >= cinfo->max_v_samp_factor) + (*in_row_group_ctr)++; +} + + +/* + * These are the routines invoked by sep_upsample to upsample pixel values + * of a single component. One row group is processed per call. + */ + + +/* + * For full-size components, we just make color_buf[ci] point at the + * input buffer, and thus avoid copying any data. Note that this is + * safe only because sep_upsample doesn't declare the input row group + * "consumed" until we are done color converting and emitting it. + */ + +METHODDEF(void) +fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + *output_data_ptr = input_data; +} + + +/* + * This is a no-op version used for "uninteresting" components. + * These components will not be referenced by color conversion. + */ + +METHODDEF(void) +noop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + *output_data_ptr = NULL; /* safety check */ +} + + +/* + * This version handles any integral sampling ratios. + * This is not used for typical JPEG files, so it need not be fast. + * Nor, for that matter, is it particularly accurate: the algorithm is + * simple replication of the input pixel onto the corresponding output + * pixels. The hi-falutin sampling literature refers to this as a + * "box filter". A box filter tends to introduce visible artifacts, + * so if you are actually going to use 3:1 or 4:1 sampling ratios + * you would be well advised to improve this code. + */ + +METHODDEF(void) +int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr, outptr; + register JSAMPLE invalue; + register int h; + JSAMPROW outend; + int h_expand, v_expand; + int inrow, outrow; + + h_expand = upsample->h_expand[compptr->component_index]; + v_expand = upsample->v_expand[compptr->component_index]; + + inrow = outrow = 0; + while (outrow < cinfo->max_v_samp_factor) { + /* Generate one output row with proper horizontal expansion */ + inptr = input_data[inrow]; + outptr = output_data[outrow]; + outend = outptr + cinfo->output_width; + while (outptr < outend) { + invalue = *inptr++; /* don't need GETJSAMPLE() here */ + for (h = h_expand; h > 0; h--) { + *outptr++ = invalue; + } + } + /* Generate any additional output rows by duplicating the first one */ + if (v_expand > 1) { + jcopy_sample_rows(output_data, outrow, output_data, outrow+1, + v_expand-1, cinfo->output_width); + } + inrow++; + outrow += v_expand; + } +} + + +/* + * Fast processing for the common case of 2:1 horizontal and 1:1 vertical. + * It's still a box filter. + */ + +METHODDEF(void) +h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr, outptr; + register JSAMPLE invalue; + JSAMPROW outend; + int inrow; + + for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { + inptr = input_data[inrow]; + outptr = output_data[inrow]; + outend = outptr + cinfo->output_width; + while (outptr < outend) { + invalue = *inptr++; /* don't need GETJSAMPLE() here */ + *outptr++ = invalue; + *outptr++ = invalue; + } + } +} + + +/* + * Fast processing for the common case of 2:1 horizontal and 2:1 vertical. + * It's still a box filter. + */ + +METHODDEF(void) +h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr, outptr; + register JSAMPLE invalue; + JSAMPROW outend; + int inrow, outrow; + + inrow = outrow = 0; + while (outrow < cinfo->max_v_samp_factor) { + inptr = input_data[inrow]; + outptr = output_data[outrow]; + outend = outptr + cinfo->output_width; + while (outptr < outend) { + invalue = *inptr++; /* don't need GETJSAMPLE() here */ + *outptr++ = invalue; + *outptr++ = invalue; + } + jcopy_sample_rows(output_data, outrow, output_data, outrow+1, + 1, cinfo->output_width); + inrow++; + outrow += 2; + } +} + + +/* + * Fancy processing for the common case of 2:1 horizontal and 1:1 vertical. + * + * The upsampling algorithm is linear interpolation between pixel centers, + * also known as a "triangle filter". This is a good compromise between + * speed and visual quality. The centers of the output pixels are 1/4 and 3/4 + * of the way between input pixel centers. + * + * A note about the "bias" calculations: when rounding fractional values to + * integer, we do not want to always round 0.5 up to the next integer. + * If we did that, we'd introduce a noticeable bias towards larger values. + * Instead, this code is arranged so that 0.5 will be rounded up or down at + * alternate pixel locations (a simple ordered dither pattern). + */ + +METHODDEF(void) +h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr, outptr; + register int invalue; + register JDIMENSION colctr; + int inrow; + + for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { + inptr = input_data[inrow]; + outptr = output_data[inrow]; + /* Special case for first column */ + invalue = GETJSAMPLE(*inptr++); + *outptr++ = (JSAMPLE) invalue; + *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2); + + for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { + /* General case: 3/4 * nearer pixel + 1/4 * further pixel */ + invalue = GETJSAMPLE(*inptr++) * 3; + *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2); + *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(*inptr) + 2) >> 2); + } + + /* Special case for last column */ + invalue = GETJSAMPLE(*inptr); + *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2); + *outptr++ = (JSAMPLE) invalue; + } +} + + +/* + * Fancy processing for the common case of 2:1 horizontal and 2:1 vertical. + * Again a triangle filter; see comments for h2v1 case, above. + * + * It is OK for us to reference the adjacent input rows because we demanded + * context from the main buffer controller (see initialization code). + */ + +METHODDEF(void) +h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr0, inptr1, outptr; +#if BITS_IN_JSAMPLE == 8 + register int thiscolsum, lastcolsum, nextcolsum; +#else + register INT32 thiscolsum, lastcolsum, nextcolsum; +#endif + register JDIMENSION colctr; + int inrow, outrow, v; + + inrow = outrow = 0; + while (outrow < cinfo->max_v_samp_factor) { + for (v = 0; v < 2; v++) { + /* inptr0 points to nearest input row, inptr1 points to next nearest */ + inptr0 = input_data[inrow]; + if (v == 0) /* next nearest is row above */ + inptr1 = input_data[inrow-1]; + else /* next nearest is row below */ + inptr1 = input_data[inrow+1]; + outptr = output_data[outrow++]; + + /* Special case for first column */ + thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); + nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); + *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4); + *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); + lastcolsum = thiscolsum; thiscolsum = nextcolsum; + + for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { + /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */ + /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */ + nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); + *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); + *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); + lastcolsum = thiscolsum; thiscolsum = nextcolsum; + } + + /* Special case for last column */ + *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); + *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4); + } + inrow++; + } +} + + +/* + * Module initialization routine for upsampling. + */ + +GLOBAL(void) +jinit_upsampler (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample; + int ci; + jpeg_component_info * compptr; + boolean need_buffer, do_fancy; + int h_in_group, v_in_group, h_out_group, v_out_group; + + upsample = (my_upsample_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_upsampler)); + cinfo->upsample = (struct jpeg_upsampler *) upsample; + upsample->pub.start_pass = start_pass_upsample; + upsample->pub.upsample = sep_upsample; + upsample->pub.need_context_rows = FALSE; /* until we find out differently */ + + if (cinfo->CCIR601_sampling) /* this isn't supported */ + ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); + + /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, + * so don't ask for it. + */ + do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1; + + /* Verify we can handle the sampling factors, select per-component methods, + * and create storage as needed. + */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Compute size of an "input group" after IDCT scaling. This many samples + * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. + */ + h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; + v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; + h_out_group = cinfo->max_h_samp_factor; + v_out_group = cinfo->max_v_samp_factor; + upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ + need_buffer = TRUE; + if (! compptr->component_needed) { + /* Don't bother to upsample an uninteresting component. */ + upsample->methods[ci] = noop_upsample; + need_buffer = FALSE; + } else if (h_in_group == h_out_group && v_in_group == v_out_group) { + /* Fullsize components can be processed without any work. */ + upsample->methods[ci] = fullsize_upsample; + need_buffer = FALSE; + } else if (h_in_group * 2 == h_out_group && + v_in_group == v_out_group) { + /* Special cases for 2h1v upsampling */ + if (do_fancy && compptr->downsampled_width > 2) + upsample->methods[ci] = h2v1_fancy_upsample; + else + upsample->methods[ci] = h2v1_upsample; + } else if (h_in_group * 2 == h_out_group && + v_in_group * 2 == v_out_group) { + /* Special cases for 2h2v upsampling */ + if (do_fancy && compptr->downsampled_width > 2) { + upsample->methods[ci] = h2v2_fancy_upsample; + upsample->pub.need_context_rows = TRUE; + } else + upsample->methods[ci] = h2v2_upsample; + } else if ((h_out_group % h_in_group) == 0 && + (v_out_group % v_in_group) == 0) { + /* Generic integral-factors upsampling method */ + upsample->methods[ci] = int_upsample; + upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group); + upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group); + } else + ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); + if (need_buffer) { + upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) jround_up((long) cinfo->output_width, + (long) cinfo->max_h_samp_factor), + (JDIMENSION) cinfo->max_v_samp_factor); + } + } +} diff --git a/src/dep/src/irrlicht/jpeglib/jdtrans.c b/src/dep/src/irrlicht/jpeglib/jdtrans.c index 12c193c..6c0ab71 100644 --- a/src/dep/src/irrlicht/jpeglib/jdtrans.c +++ b/src/dep/src/irrlicht/jpeglib/jdtrans.c @@ -1,143 +1,143 @@ -/* - * jdtrans.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains library routines for transcoding decompression, - * that is, reading raw DCT coefficient arrays from an input JPEG file. - * The routines in jdapimin.c will also be needed by a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo)); - - -/* - * Read the coefficient arrays from a JPEG file. - * jpeg_read_header must be completed before calling this. - * - * The entire image is read into a set of virtual coefficient-block arrays, - * one per component. The return value is a pointer to the array of - * virtual-array descriptors. These can be manipulated directly via the - * JPEG memory manager, or handed off to jpeg_write_coefficients(). - * To release the memory occupied by the virtual arrays, call - * jpeg_finish_decompress() when done with the data. - * - * An alternative usage is to simply obtain access to the coefficient arrays - * during a buffered-image-mode decompression operation. This is allowed - * after any jpeg_finish_output() call. The arrays can be accessed until - * jpeg_finish_decompress() is called. (Note that any call to the library - * may reposition the arrays, so don't rely on access_virt_barray() results - * to stay valid across library calls.) - * - * Returns NULL if suspended. This case need be checked only if - * a suspending data source is used. - */ - -GLOBAL(jvirt_barray_ptr *) -jpeg_read_coefficients (j_decompress_ptr cinfo) -{ - if (cinfo->global_state == DSTATE_READY) { - /* First call: initialize active modules */ - transdecode_master_selection(cinfo); - cinfo->global_state = DSTATE_RDCOEFS; - } - if (cinfo->global_state == DSTATE_RDCOEFS) { - /* Absorb whole file into the coef buffer */ - for (;;) { - int retcode; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - /* Absorb some more input */ - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_SUSPENDED) - return NULL; - if (retcode == JPEG_REACHED_EOI) - break; - /* Advance progress counter if appropriate */ - if (cinfo->progress != NULL && - (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { - if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { - /* startup underestimated number of scans; ratchet up one scan */ - cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; - } - } - } - /* Set state so that jpeg_finish_decompress does the right thing */ - cinfo->global_state = DSTATE_STOPPING; - } - /* At this point we should be in state DSTATE_STOPPING if being used - * standalone, or in state DSTATE_BUFIMAGE if being invoked to get access - * to the coefficients during a full buffered-image-mode decompression. - */ - if ((cinfo->global_state == DSTATE_STOPPING || - cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) { - return cinfo->coef->coef_arrays; - } - /* Oops, improper usage */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return NULL; /* keep compiler happy */ -} - - -/* - * Master selection of decompression modules for transcoding. - * This substitutes for jdmaster.c's initialization of the full decompressor. - */ - -LOCAL(void) -transdecode_master_selection (j_decompress_ptr cinfo) -{ - /* This is effectively a buffered-image operation. */ - cinfo->buffered_image = TRUE; - - /* Entropy decoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef D_PROGRESSIVE_SUPPORTED - jinit_phuff_decoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_decoder(cinfo); - } - - /* Always get a full-image coefficient buffer. */ - jinit_d_coef_controller(cinfo, TRUE); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Initialize input side of decompressor to consume first scan. */ - (*cinfo->inputctl->start_input_pass) (cinfo); - - /* Initialize progress monitoring. */ - if (cinfo->progress != NULL) { - int nscans; - /* Estimate number of scans to set pass_limit. */ - if (cinfo->progressive_mode) { - /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ - nscans = 2 + 3 * cinfo->num_components; - } else if (cinfo->inputctl->has_multiple_scans) { - /* For a nonprogressive multiscan file, estimate 1 scan per component. */ - nscans = cinfo->num_components; - } else { - nscans = 1; - } - cinfo->progress->pass_counter = 0L; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; - cinfo->progress->completed_passes = 0; - cinfo->progress->total_passes = 1; - } -} +/* + * jdtrans.c + * + * Copyright (C) 1995-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains library routines for transcoding decompression, + * that is, reading raw DCT coefficient arrays from an input JPEG file. + * The routines in jdapimin.c will also be needed by a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Forward declarations */ +LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo)); + + +/* + * Read the coefficient arrays from a JPEG file. + * jpeg_read_header must be completed before calling this. + * + * The entire image is read into a set of virtual coefficient-block arrays, + * one per component. The return value is a pointer to the array of + * virtual-array descriptors. These can be manipulated directly via the + * JPEG memory manager, or handed off to jpeg_write_coefficients(). + * To release the memory occupied by the virtual arrays, call + * jpeg_finish_decompress() when done with the data. + * + * An alternative usage is to simply obtain access to the coefficient arrays + * during a buffered-image-mode decompression operation. This is allowed + * after any jpeg_finish_output() call. The arrays can be accessed until + * jpeg_finish_decompress() is called. (Note that any call to the library + * may reposition the arrays, so don't rely on access_virt_barray() results + * to stay valid across library calls.) + * + * Returns NULL if suspended. This case need be checked only if + * a suspending data source is used. + */ + +GLOBAL(jvirt_barray_ptr *) +jpeg_read_coefficients (j_decompress_ptr cinfo) +{ + if (cinfo->global_state == DSTATE_READY) { + /* First call: initialize active modules */ + transdecode_master_selection(cinfo); + cinfo->global_state = DSTATE_RDCOEFS; + } + if (cinfo->global_state == DSTATE_RDCOEFS) { + /* Absorb whole file into the coef buffer */ + for (;;) { + int retcode; + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + /* Absorb some more input */ + retcode = (*cinfo->inputctl->consume_input) (cinfo); + if (retcode == JPEG_SUSPENDED) + return NULL; + if (retcode == JPEG_REACHED_EOI) + break; + /* Advance progress counter if appropriate */ + if (cinfo->progress != NULL && + (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { + if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { + /* startup underestimated number of scans; ratchet up one scan */ + cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; + } + } + } + /* Set state so that jpeg_finish_decompress does the right thing */ + cinfo->global_state = DSTATE_STOPPING; + } + /* At this point we should be in state DSTATE_STOPPING if being used + * standalone, or in state DSTATE_BUFIMAGE if being invoked to get access + * to the coefficients during a full buffered-image-mode decompression. + */ + if ((cinfo->global_state == DSTATE_STOPPING || + cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) { + return cinfo->coef->coef_arrays; + } + /* Oops, improper usage */ + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + return NULL; /* keep compiler happy */ +} + + +/* + * Master selection of decompression modules for transcoding. + * This substitutes for jdmaster.c's initialization of the full decompressor. + */ + +LOCAL(void) +transdecode_master_selection (j_decompress_ptr cinfo) +{ + /* This is effectively a buffered-image operation. */ + cinfo->buffered_image = TRUE; + + /* Entropy decoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) { + ERREXIT(cinfo, JERR_ARITH_NOTIMPL); + } else { + if (cinfo->progressive_mode) { +#ifdef D_PROGRESSIVE_SUPPORTED + jinit_phuff_decoder(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else + jinit_huff_decoder(cinfo); + } + + /* Always get a full-image coefficient buffer. */ + jinit_d_coef_controller(cinfo, TRUE); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Initialize input side of decompressor to consume first scan. */ + (*cinfo->inputctl->start_input_pass) (cinfo); + + /* Initialize progress monitoring. */ + if (cinfo->progress != NULL) { + int nscans; + /* Estimate number of scans to set pass_limit. */ + if (cinfo->progressive_mode) { + /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ + nscans = 2 + 3 * cinfo->num_components; + } else if (cinfo->inputctl->has_multiple_scans) { + /* For a nonprogressive multiscan file, estimate 1 scan per component. */ + nscans = cinfo->num_components; + } else { + nscans = 1; + } + cinfo->progress->pass_counter = 0L; + cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; + cinfo->progress->completed_passes = 0; + cinfo->progress->total_passes = 1; + } +} diff --git a/src/dep/src/irrlicht/jpeglib/jerror.c b/src/dep/src/irrlicht/jpeglib/jerror.c index c98aed7..3da7be8 100644 --- a/src/dep/src/irrlicht/jpeglib/jerror.c +++ b/src/dep/src/irrlicht/jpeglib/jerror.c @@ -1,252 +1,252 @@ -/* - * jerror.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains simple error-reporting and trace-message routines. - * These are suitable for Unix-like systems and others where writing to - * stderr is the right thing to do. Many applications will want to replace - * some or all of these routines. - * - * If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile, - * you get a Windows-specific hack to display error messages in a dialog box. - * It ain't much, but it beats dropping error messages into the bit bucket, - * which is what happens to output to stderr under most Windows C compilers. - * - * These routines are used by both the compression and decompression code. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jversion.h" -#include "jerror.h" - -#ifdef USE_WINDOWS_MESSAGEBOX -#include -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif - - -/* - * Create the message string table. - * We do this from the master message list in jerror.h by re-reading - * jerror.h with a suitable definition for macro JMESSAGE. - * The message table is made an external symbol just in case any applications - * want to refer to it directly. - */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_std_message_table jMsgTable -#endif - -#define JMESSAGE(code,string) string , - -const char * const jpeg_std_message_table[] = { -#include "jerror.h" - NULL -}; - - -/* - * Error exit handler: must not return to caller. - * - * Applications may override this if they want to get control back after - * an error. Typically one would longjmp somewhere instead of exiting. - * The setjmp buffer can be made a private field within an expanded error - * handler object. Note that the info needed to generate an error message - * is stored in the error object, so you can generate the message now or - * later, at your convenience. - * You should make sure that the JPEG object is cleaned up (with jpeg_abort - * or jpeg_destroy) at some point. - */ - -METHODDEF(void) -error_exit (j_common_ptr cinfo) -{ - /* Always display the message */ - (*cinfo->err->output_message) (cinfo); - - /* Let the memory manager delete any temp files before we die */ - jpeg_destroy(cinfo); - - exit(EXIT_FAILURE); -} - - -/* - * Actual output of an error or trace message. - * Applications may override this method to send JPEG messages somewhere - * other than stderr. - * - * On Windows, printing to stderr is generally completely useless, - * so we provide optional code to produce an error-dialog popup. - * Most Windows applications will still prefer to override this routine, - * but if they don't, it'll do something at least marginally useful. - * - * NOTE: to use the library in an environment that doesn't support the - * C stdio library, you may have to delete the call to fprintf() entirely, - * not just not use this routine. - */ - -METHODDEF(void) -output_message (j_common_ptr cinfo) -{ - char buffer[JMSG_LENGTH_MAX]; - - /* Create the message */ - (*cinfo->err->format_message) (cinfo, buffer); - -#ifdef USE_WINDOWS_MESSAGEBOX - /* Display it in a message dialog box */ - MessageBox(GetActiveWindow(), buffer, "JPEG Library Error", - MB_OK | MB_ICONERROR); -#else - /* Send it to stderr, adding a newline */ - fprintf(stderr, "%s\n", buffer); -#endif -} - - -/* - * Decide whether to emit a trace or warning message. - * msg_level is one of: - * -1: recoverable corrupt-data warning, may want to abort. - * 0: important advisory messages (always display to user). - * 1: first level of tracing detail. - * 2,3,...: successively more detailed tracing messages. - * An application might override this method if it wanted to abort on warnings - * or change the policy about which messages to display. - */ - -METHODDEF(void) -emit_message (j_common_ptr cinfo, int msg_level) -{ - struct jpeg_error_mgr * err = cinfo->err; - - if (msg_level < 0) { - /* It's a warning message. Since corrupt files may generate many warnings, - * the policy implemented here is to show only the first warning, - * unless trace_level >= 3. - */ - if (err->num_warnings == 0 || err->trace_level >= 3) - (*err->output_message) (cinfo); - /* Always count warnings in num_warnings. */ - err->num_warnings++; - } else { - /* It's a trace message. Show it if trace_level >= msg_level. */ - if (err->trace_level >= msg_level) - (*err->output_message) (cinfo); - } -} - - -/* - * Format a message string for the most recent JPEG error or message. - * The message is stored into buffer, which should be at least JMSG_LENGTH_MAX - * characters. Note that no '\n' character is added to the string. - * Few applications should need to override this method. - */ - -METHODDEF(void) -format_message (j_common_ptr cinfo, char * buffer) -{ - struct jpeg_error_mgr * err = cinfo->err; - int msg_code = err->msg_code; - const char * msgtext = NULL; - const char * msgptr; - char ch; - boolean isstring; - - /* Look up message string in proper table */ - if (msg_code > 0 && msg_code <= err->last_jpeg_message) { - msgtext = err->jpeg_message_table[msg_code]; - } else if (err->addon_message_table != NULL && - msg_code >= err->first_addon_message && - msg_code <= err->last_addon_message) { - msgtext = err->addon_message_table[msg_code - err->first_addon_message]; - } - - /* Defend against bogus message number */ - if (msgtext == NULL) { - err->msg_parm.i[0] = msg_code; - msgtext = err->jpeg_message_table[0]; - } - - /* Check for string parameter, as indicated by %s in the message text */ - isstring = FALSE; - msgptr = msgtext; - while ((ch = *msgptr++) != '\0') { - if (ch == '%') { - if (*msgptr == 's') isstring = TRUE; - break; - } - } - - /* Format the message into the passed buffer */ - if (isstring) - sprintf(buffer, msgtext, err->msg_parm.s); - else - sprintf(buffer, msgtext, - err->msg_parm.i[0], err->msg_parm.i[1], - err->msg_parm.i[2], err->msg_parm.i[3], - err->msg_parm.i[4], err->msg_parm.i[5], - err->msg_parm.i[6], err->msg_parm.i[7]); -} - - -/* - * Reset error state variables at start of a new image. - * This is called during compression startup to reset trace/error - * processing to default state, without losing any application-specific - * method pointers. An application might possibly want to override - * this method if it has additional error processing state. - */ - -METHODDEF(void) -reset_error_mgr (j_common_ptr cinfo) -{ - cinfo->err->num_warnings = 0; - /* trace_level is not reset since it is an application-supplied parameter */ - cinfo->err->msg_code = 0; /* may be useful as a flag for "no error" */ -} - - -/* - * Fill in the standard error-handling methods in a jpeg_error_mgr object. - * Typical call is: - * struct jpeg_compress_struct cinfo; - * struct jpeg_error_mgr err; - * - * cinfo.err = jpeg_std_error(&err); - * after which the application may override some of the methods. - */ - -GLOBAL(struct jpeg_error_mgr *) -jpeg_std_error (struct jpeg_error_mgr * err) -{ - err->error_exit = error_exit; - err->emit_message = emit_message; - err->output_message = output_message; - err->format_message = format_message; - err->reset_error_mgr = reset_error_mgr; - - err->trace_level = 0; /* default = no tracing */ - err->num_warnings = 0; /* no warnings emitted yet */ - err->msg_code = 0; /* may be useful as a flag for "no error" */ - - /* Initialize message table pointers */ - err->jpeg_message_table = jpeg_std_message_table; - err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1; - - err->addon_message_table = NULL; - err->first_addon_message = 0; /* for safety */ - err->last_addon_message = 0; - - return err; -} +/* + * jerror.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains simple error-reporting and trace-message routines. + * These are suitable for Unix-like systems and others where writing to + * stderr is the right thing to do. Many applications will want to replace + * some or all of these routines. + * + * If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile, + * you get a Windows-specific hack to display error messages in a dialog box. + * It ain't much, but it beats dropping error messages into the bit bucket, + * which is what happens to output to stderr under most Windows C compilers. + * + * These routines are used by both the compression and decompression code. + */ + +/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jversion.h" +#include "jerror.h" + +#ifdef USE_WINDOWS_MESSAGEBOX +#include +#endif + +#ifndef EXIT_FAILURE /* define exit() codes if not provided */ +#define EXIT_FAILURE 1 +#endif + + +/* + * Create the message string table. + * We do this from the master message list in jerror.h by re-reading + * jerror.h with a suitable definition for macro JMESSAGE. + * The message table is made an external symbol just in case any applications + * want to refer to it directly. + */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_std_message_table jMsgTable +#endif + +#define JMESSAGE(code,string) string , + +const char * const jpeg_std_message_table[] = { +#include "jerror.h" + NULL +}; + + +/* + * Error exit handler: must not return to caller. + * + * Applications may override this if they want to get control back after + * an error. Typically one would longjmp somewhere instead of exiting. + * The setjmp buffer can be made a private field within an expanded error + * handler object. Note that the info needed to generate an error message + * is stored in the error object, so you can generate the message now or + * later, at your convenience. + * You should make sure that the JPEG object is cleaned up (with jpeg_abort + * or jpeg_destroy) at some point. + */ + +METHODDEF(void) +error_exit (j_common_ptr cinfo) +{ + /* Always display the message */ + (*cinfo->err->output_message) (cinfo); + + /* Let the memory manager delete any temp files before we die */ + jpeg_destroy(cinfo); + + exit(EXIT_FAILURE); +} + + +/* + * Actual output of an error or trace message. + * Applications may override this method to send JPEG messages somewhere + * other than stderr. + * + * On Windows, printing to stderr is generally completely useless, + * so we provide optional code to produce an error-dialog popup. + * Most Windows applications will still prefer to override this routine, + * but if they don't, it'll do something at least marginally useful. + * + * NOTE: to use the library in an environment that doesn't support the + * C stdio library, you may have to delete the call to fprintf() entirely, + * not just not use this routine. + */ + +METHODDEF(void) +output_message (j_common_ptr cinfo) +{ + char buffer[JMSG_LENGTH_MAX]; + + /* Create the message */ + (*cinfo->err->format_message) (cinfo, buffer); + +#ifdef USE_WINDOWS_MESSAGEBOX + /* Display it in a message dialog box */ + MessageBox(GetActiveWindow(), buffer, "JPEG Library Error", + MB_OK | MB_ICONERROR); +#else + /* Send it to stderr, adding a newline */ + fprintf(stderr, "%s\n", buffer); +#endif +} + + +/* + * Decide whether to emit a trace or warning message. + * msg_level is one of: + * -1: recoverable corrupt-data warning, may want to abort. + * 0: important advisory messages (always display to user). + * 1: first level of tracing detail. + * 2,3,...: successively more detailed tracing messages. + * An application might override this method if it wanted to abort on warnings + * or change the policy about which messages to display. + */ + +METHODDEF(void) +emit_message (j_common_ptr cinfo, int msg_level) +{ + struct jpeg_error_mgr * err = cinfo->err; + + if (msg_level < 0) { + /* It's a warning message. Since corrupt files may generate many warnings, + * the policy implemented here is to show only the first warning, + * unless trace_level >= 3. + */ + if (err->num_warnings == 0 || err->trace_level >= 3) + (*err->output_message) (cinfo); + /* Always count warnings in num_warnings. */ + err->num_warnings++; + } else { + /* It's a trace message. Show it if trace_level >= msg_level. */ + if (err->trace_level >= msg_level) + (*err->output_message) (cinfo); + } +} + + +/* + * Format a message string for the most recent JPEG error or message. + * The message is stored into buffer, which should be at least JMSG_LENGTH_MAX + * characters. Note that no '\n' character is added to the string. + * Few applications should need to override this method. + */ + +METHODDEF(void) +format_message (j_common_ptr cinfo, char * buffer) +{ + struct jpeg_error_mgr * err = cinfo->err; + int msg_code = err->msg_code; + const char * msgtext = NULL; + const char * msgptr; + char ch; + boolean isstring; + + /* Look up message string in proper table */ + if (msg_code > 0 && msg_code <= err->last_jpeg_message) { + msgtext = err->jpeg_message_table[msg_code]; + } else if (err->addon_message_table != NULL && + msg_code >= err->first_addon_message && + msg_code <= err->last_addon_message) { + msgtext = err->addon_message_table[msg_code - err->first_addon_message]; + } + + /* Defend against bogus message number */ + if (msgtext == NULL) { + err->msg_parm.i[0] = msg_code; + msgtext = err->jpeg_message_table[0]; + } + + /* Check for string parameter, as indicated by %s in the message text */ + isstring = FALSE; + msgptr = msgtext; + while ((ch = *msgptr++) != '\0') { + if (ch == '%') { + if (*msgptr == 's') isstring = TRUE; + break; + } + } + + /* Format the message into the passed buffer */ + if (isstring) + sprintf(buffer, msgtext, err->msg_parm.s); + else + sprintf(buffer, msgtext, + err->msg_parm.i[0], err->msg_parm.i[1], + err->msg_parm.i[2], err->msg_parm.i[3], + err->msg_parm.i[4], err->msg_parm.i[5], + err->msg_parm.i[6], err->msg_parm.i[7]); +} + + +/* + * Reset error state variables at start of a new image. + * This is called during compression startup to reset trace/error + * processing to default state, without losing any application-specific + * method pointers. An application might possibly want to override + * this method if it has additional error processing state. + */ + +METHODDEF(void) +reset_error_mgr (j_common_ptr cinfo) +{ + cinfo->err->num_warnings = 0; + /* trace_level is not reset since it is an application-supplied parameter */ + cinfo->err->msg_code = 0; /* may be useful as a flag for "no error" */ +} + + +/* + * Fill in the standard error-handling methods in a jpeg_error_mgr object. + * Typical call is: + * struct jpeg_compress_struct cinfo; + * struct jpeg_error_mgr err; + * + * cinfo.err = jpeg_std_error(&err); + * after which the application may override some of the methods. + */ + +GLOBAL(struct jpeg_error_mgr *) +jpeg_std_error (struct jpeg_error_mgr * err) +{ + err->error_exit = error_exit; + err->emit_message = emit_message; + err->output_message = output_message; + err->format_message = format_message; + err->reset_error_mgr = reset_error_mgr; + + err->trace_level = 0; /* default = no tracing */ + err->num_warnings = 0; /* no warnings emitted yet */ + err->msg_code = 0; /* may be useful as a flag for "no error" */ + + /* Initialize message table pointers */ + err->jpeg_message_table = jpeg_std_message_table; + err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1; + + err->addon_message_table = NULL; + err->first_addon_message = 0; /* for safety */ + err->last_addon_message = 0; + + return err; +} diff --git a/src/dep/src/irrlicht/jpeglib/jerror.h b/src/dep/src/irrlicht/jpeglib/jerror.h index 79084f2..fc2fffe 100644 --- a/src/dep/src/irrlicht/jpeglib/jerror.h +++ b/src/dep/src/irrlicht/jpeglib/jerror.h @@ -1,291 +1,291 @@ -/* - * jerror.h - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the error and message codes for the JPEG library. - * Edit this file to add new codes, or to translate the message strings to - * some other language. - * A set of error-reporting macros are defined too. Some applications using - * the JPEG library may wish to include this file to get the error codes - * and/or the macros. - */ - -/* - * To define the enum list of message codes, include this file without - * defining macro JMESSAGE. To create a message string table, include it - * again with a suitable JMESSAGE definition (see jerror.c for an example). - */ -#ifndef JMESSAGE -#ifndef JERROR_H -/* First time through, define the enum list */ -#define JMAKE_ENUM_LIST -#else -/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ -#define JMESSAGE(code,string) -#endif /* JERROR_H */ -#endif /* JMESSAGE */ - -#ifdef JMAKE_ENUM_LIST - -typedef enum { - -#define JMESSAGE(code,string) code , - -#endif /* JMAKE_ENUM_LIST */ - -JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ - -/* For maintenance convenience, list is alphabetical by message code name */ -JMESSAGE(JERR_ARITH_NOTIMPL, - "Sorry, there are legal restrictions on arithmetic coding") -JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") -JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") -JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") -JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") -JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") -JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") -JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") -JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") -JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") -JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length") -JMESSAGE(JERR_BAD_LIB_VERSION, - "Wrong JPEG library version: library is %d, caller expects %d") -JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan") -JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d") -JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d") -JMESSAGE(JERR_BAD_PROGRESSION, - "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d") -JMESSAGE(JERR_BAD_PROG_SCRIPT, - "Invalid progressive parameters at scan script entry %d") -JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors") -JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d") -JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d") -JMESSAGE(JERR_BAD_STRUCT_SIZE, - "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u") -JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access") -JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small") -JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here") -JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet") -JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d") -JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request") -JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d") -JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x") -JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d") -JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d") -JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)") -JMESSAGE(JERR_EMS_READ, "Read from EMS failed") -JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed") -JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan") -JMESSAGE(JERR_FILE_READ, "Input file read error") -JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") -JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") -JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow") -JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") -JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") -JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") -JMESSAGE(JERR_INPUT_EOF, "Premature end of input file") -JMESSAGE(JERR_MISMATCHED_QUANT_TABLE, - "Cannot transcode due to multiple use of quantization table %d") -JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data") -JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") -JMESSAGE(JERR_NOTIMPL, "Not implemented yet") -JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") -JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") -JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") -JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") -JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined") -JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x") -JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)") -JMESSAGE(JERR_QUANT_COMPONENTS, - "Cannot quantize more than %d color components") -JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") -JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors") -JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") -JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") -JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") -JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") -JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF") -JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") -JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") -JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") -JMESSAGE(JERR_TFILE_WRITE, - "Write failed on temporary file --- out of disk space?") -JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines") -JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x") -JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up") -JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation") -JMESSAGE(JERR_XMS_READ, "Read from XMS failed") -JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed") -JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT) -JMESSAGE(JMSG_VERSION, JVERSION) -JMESSAGE(JTRC_16BIT_TABLES, - "Caution: quantization tables are too coarse for baseline JPEG") -JMESSAGE(JTRC_ADOBE, - "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d") -JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u") -JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u") -JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x") -JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x") -JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d") -JMESSAGE(JTRC_DRI, "Define Restart Interval %u") -JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u") -JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u") -JMESSAGE(JTRC_EOI, "End Of Image") -JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d") -JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d") -JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE, - "Warning: thumbnail image size does not match data length %u") -JMESSAGE(JTRC_JFIF_EXTENSION, - "JFIF extension marker: type 0x%02x, length %u") -JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image") -JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u") -JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x") -JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u") -JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors") -JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors") -JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization") -JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d") -JMESSAGE(JTRC_RST, "RST%d") -JMESSAGE(JTRC_SMOOTH_NOTIMPL, - "Smoothing not supported with nonstandard sampling ratios") -JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d") -JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d") -JMESSAGE(JTRC_SOI, "Start of Image") -JMESSAGE(JTRC_SOS, "Start Of Scan: %d components") -JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d") -JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d") -JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s") -JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s") -JMESSAGE(JTRC_THUMB_JPEG, - "JFIF extension marker: JPEG-compressed thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_PALETTE, - "JFIF extension marker: palette thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_RGB, - "JFIF extension marker: RGB thumbnail image, length %u") -JMESSAGE(JTRC_UNKNOWN_IDS, - "Unrecognized component IDs %d %d %d, assuming YCbCr") -JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") -JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") -JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") -JMESSAGE(JWRN_BOGUS_PROGRESSION, - "Inconsistent progression sequence for component %d coefficient %d") -JMESSAGE(JWRN_EXTRANEOUS_DATA, - "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x") -JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment") -JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code") -JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d") -JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file") -JMESSAGE(JWRN_MUST_RESYNC, - "Corrupt JPEG data: found marker 0x%02x instead of RST%d") -JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG") -JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines") - -#ifdef JMAKE_ENUM_LIST - - JMSG_LASTMSGCODE -} J_MESSAGE_CODE; - -#undef JMAKE_ENUM_LIST -#endif /* JMAKE_ENUM_LIST */ - -/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ -#undef JMESSAGE - - -#ifndef JERROR_H -#define JERROR_H - -/* Macros to simplify using the error and trace message stuff */ -/* The first parameter is either type of cinfo pointer */ - -/* Fatal errors (print message and exit) */ -#define ERREXIT(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT3(cinfo,code,p1,p2,p3) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (cinfo)->err->msg_parm.i[3] = (p4), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXITS(cinfo,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) - -#define MAKESTMT(stuff) do { stuff } while (0) - -/* Nonfatal errors (we can keep going, but the data is probably corrupt) */ -#define WARNMS(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) - -/* Informational/debugging messages */ -#define TRACEMS(cinfo,lvl,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS1(cinfo,lvl,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS2(cinfo,lvl,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMSS(cinfo,lvl,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) - -#endif /* JERROR_H */ +/* + * jerror.h + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file defines the error and message codes for the JPEG library. + * Edit this file to add new codes, or to translate the message strings to + * some other language. + * A set of error-reporting macros are defined too. Some applications using + * the JPEG library may wish to include this file to get the error codes + * and/or the macros. + */ + +/* + * To define the enum list of message codes, include this file without + * defining macro JMESSAGE. To create a message string table, include it + * again with a suitable JMESSAGE definition (see jerror.c for an example). + */ +#ifndef JMESSAGE +#ifndef JERROR_H +/* First time through, define the enum list */ +#define JMAKE_ENUM_LIST +#else +/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ +#define JMESSAGE(code,string) +#endif /* JERROR_H */ +#endif /* JMESSAGE */ + +#ifdef JMAKE_ENUM_LIST + +typedef enum { + +#define JMESSAGE(code,string) code , + +#endif /* JMAKE_ENUM_LIST */ + +JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ + +/* For maintenance convenience, list is alphabetical by message code name */ +JMESSAGE(JERR_ARITH_NOTIMPL, + "Sorry, there are legal restrictions on arithmetic coding") +JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") +JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") +JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") +JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") +JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") +JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") +JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") +JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") +JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") +JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length") +JMESSAGE(JERR_BAD_LIB_VERSION, + "Wrong JPEG library version: library is %d, caller expects %d") +JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan") +JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d") +JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d") +JMESSAGE(JERR_BAD_PROGRESSION, + "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d") +JMESSAGE(JERR_BAD_PROG_SCRIPT, + "Invalid progressive parameters at scan script entry %d") +JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors") +JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d") +JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d") +JMESSAGE(JERR_BAD_STRUCT_SIZE, + "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u") +JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access") +JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small") +JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here") +JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet") +JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d") +JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request") +JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d") +JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x") +JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d") +JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d") +JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)") +JMESSAGE(JERR_EMS_READ, "Read from EMS failed") +JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed") +JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan") +JMESSAGE(JERR_FILE_READ, "Input file read error") +JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") +JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") +JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow") +JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") +JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") +JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") +JMESSAGE(JERR_INPUT_EOF, "Premature end of input file") +JMESSAGE(JERR_MISMATCHED_QUANT_TABLE, + "Cannot transcode due to multiple use of quantization table %d") +JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data") +JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") +JMESSAGE(JERR_NOTIMPL, "Not implemented yet") +JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") +JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") +JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") +JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") +JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined") +JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x") +JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)") +JMESSAGE(JERR_QUANT_COMPONENTS, + "Cannot quantize more than %d color components") +JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") +JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors") +JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") +JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") +JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") +JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") +JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF") +JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") +JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") +JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") +JMESSAGE(JERR_TFILE_WRITE, + "Write failed on temporary file --- out of disk space?") +JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines") +JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x") +JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up") +JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation") +JMESSAGE(JERR_XMS_READ, "Read from XMS failed") +JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed") +JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT) +JMESSAGE(JMSG_VERSION, JVERSION) +JMESSAGE(JTRC_16BIT_TABLES, + "Caution: quantization tables are too coarse for baseline JPEG") +JMESSAGE(JTRC_ADOBE, + "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d") +JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u") +JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u") +JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x") +JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x") +JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d") +JMESSAGE(JTRC_DRI, "Define Restart Interval %u") +JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u") +JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u") +JMESSAGE(JTRC_EOI, "End Of Image") +JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d") +JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d") +JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE, + "Warning: thumbnail image size does not match data length %u") +JMESSAGE(JTRC_JFIF_EXTENSION, + "JFIF extension marker: type 0x%02x, length %u") +JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image") +JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u") +JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x") +JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u") +JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors") +JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors") +JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization") +JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d") +JMESSAGE(JTRC_RST, "RST%d") +JMESSAGE(JTRC_SMOOTH_NOTIMPL, + "Smoothing not supported with nonstandard sampling ratios") +JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d") +JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d") +JMESSAGE(JTRC_SOI, "Start of Image") +JMESSAGE(JTRC_SOS, "Start Of Scan: %d components") +JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d") +JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d") +JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s") +JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s") +JMESSAGE(JTRC_THUMB_JPEG, + "JFIF extension marker: JPEG-compressed thumbnail image, length %u") +JMESSAGE(JTRC_THUMB_PALETTE, + "JFIF extension marker: palette thumbnail image, length %u") +JMESSAGE(JTRC_THUMB_RGB, + "JFIF extension marker: RGB thumbnail image, length %u") +JMESSAGE(JTRC_UNKNOWN_IDS, + "Unrecognized component IDs %d %d %d, assuming YCbCr") +JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") +JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") +JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") +JMESSAGE(JWRN_BOGUS_PROGRESSION, + "Inconsistent progression sequence for component %d coefficient %d") +JMESSAGE(JWRN_EXTRANEOUS_DATA, + "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x") +JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment") +JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code") +JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d") +JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file") +JMESSAGE(JWRN_MUST_RESYNC, + "Corrupt JPEG data: found marker 0x%02x instead of RST%d") +JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG") +JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines") + +#ifdef JMAKE_ENUM_LIST + + JMSG_LASTMSGCODE +} J_MESSAGE_CODE; + +#undef JMAKE_ENUM_LIST +#endif /* JMAKE_ENUM_LIST */ + +/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ +#undef JMESSAGE + + +#ifndef JERROR_H +#define JERROR_H + +/* Macros to simplify using the error and trace message stuff */ +/* The first parameter is either type of cinfo pointer */ + +/* Fatal errors (print message and exit) */ +#define ERREXIT(cinfo,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT1(cinfo,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT2(cinfo,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT3(cinfo,code,p1,p2,p3) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (cinfo)->err->msg_parm.i[2] = (p3), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (cinfo)->err->msg_parm.i[2] = (p3), \ + (cinfo)->err->msg_parm.i[3] = (p4), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXITS(cinfo,code,str) \ + ((cinfo)->err->msg_code = (code), \ + strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) + +#define MAKESTMT(stuff) do { stuff } while (0) + +/* Nonfatal errors (we can keep going, but the data is probably corrupt) */ +#define WARNMS(cinfo,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) +#define WARNMS1(cinfo,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) +#define WARNMS2(cinfo,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) + +/* Informational/debugging messages */ +#define TRACEMS(cinfo,lvl,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS1(cinfo,lvl,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS2(cinfo,lvl,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ + _mp[4] = (p5); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ + _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMSS(cinfo,lvl,code,str) \ + ((cinfo)->err->msg_code = (code), \ + strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) + +#endif /* JERROR_H */ diff --git a/src/dep/src/irrlicht/jpeglib/jfdctflt.c b/src/dep/src/irrlicht/jpeglib/jfdctflt.c index 7ccfb38..79d7a00 100644 --- a/src/dep/src/irrlicht/jpeglib/jfdctflt.c +++ b/src/dep/src/irrlicht/jpeglib/jfdctflt.c @@ -1,168 +1,168 @@ -/* - * jfdctflt.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a floating-point implementation of the - * forward DCT (Discrete Cosine Transform). - * - * This implementation should be more accurate than either of the integer - * DCT implementations. However, it may not give the same results on all - * machines because of differences in roundoff behavior. Speed will depend - * on the hardware's floating point capacity. - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with a fixed-point - * implementation, accuracy is lost due to imprecise representation of the - * scaled quantization values. However, that problem does not arise if - * we use floating point arithmetic. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_FLOAT_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_float (FAST_FLOAT * data) -{ - FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - FAST_FLOAT tmp10, tmp11, tmp12, tmp13; - FAST_FLOAT z1, z2, z3, z4, z5, z11, z13; - FAST_FLOAT *dataptr; - int ctr; - - /* Pass 1: process rows. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = tmp10 + tmp11; /* phase 3 */ - dataptr[4] = tmp10 - tmp11; - - z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ - dataptr[2] = tmp13 + z1; /* phase 5 */ - dataptr[6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ - z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ - z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ - z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[5] = z13 + z2; /* phase 6 */ - dataptr[3] = z13 - z2; - dataptr[1] = z11 + z4; - dataptr[7] = z11 - z4; - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ - dataptr[DCTSIZE*4] = tmp10 - tmp11; - - z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ - dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ - dataptr[DCTSIZE*6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ - z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ - z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ - z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ - dataptr[DCTSIZE*3] = z13 - z2; - dataptr[DCTSIZE*1] = z11 + z4; - dataptr[DCTSIZE*7] = z11 - z4; - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ +/* + * jfdctflt.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a floating-point implementation of the + * forward DCT (Discrete Cosine Transform). + * + * This implementation should be more accurate than either of the integer + * DCT implementations. However, it may not give the same results on all + * machines because of differences in roundoff behavior. Speed will depend + * on the hardware's floating point capacity. + * + * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT + * on each column. Direct algorithms are also available, but they are + * much more complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with a fixed-point + * implementation, accuracy is lost due to imprecise representation of the + * scaled quantization values. However, that problem does not arise if + * we use floating point arithmetic. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_FLOAT_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* + * Perform the forward DCT on one block of samples. + */ + +GLOBAL(void) +jpeg_fdct_float (FAST_FLOAT * data) +{ + FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + FAST_FLOAT tmp10, tmp11, tmp12, tmp13; + FAST_FLOAT z1, z2, z3, z4, z5, z11, z13; + FAST_FLOAT *dataptr; + int ctr; + + /* Pass 1: process rows. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[0] + dataptr[7]; + tmp7 = dataptr[0] - dataptr[7]; + tmp1 = dataptr[1] + dataptr[6]; + tmp6 = dataptr[1] - dataptr[6]; + tmp2 = dataptr[2] + dataptr[5]; + tmp5 = dataptr[2] - dataptr[5]; + tmp3 = dataptr[3] + dataptr[4]; + tmp4 = dataptr[3] - dataptr[4]; + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[0] = tmp10 + tmp11; /* phase 3 */ + dataptr[4] = tmp10 - tmp11; + + z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ + dataptr[2] = tmp13 + z1; /* phase 5 */ + dataptr[6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ + z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ + z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ + z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[5] = z13 + z2; /* phase 6 */ + dataptr[3] = z13 - z2; + dataptr[1] = z11 + z4; + dataptr[7] = z11 - z4; + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ + dataptr[DCTSIZE*4] = tmp10 - tmp11; + + z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ + dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ + dataptr[DCTSIZE*6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ + z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ + z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ + z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ + dataptr[DCTSIZE*3] = z13 - z2; + dataptr[DCTSIZE*1] = z11 + z4; + dataptr[DCTSIZE*7] = z11 - z4; + + dataptr++; /* advance pointer to next column */ + } +} + +#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/jfdctfst.c b/src/dep/src/irrlicht/jpeglib/jfdctfst.c index 005a74f..ccb378a 100644 --- a/src/dep/src/irrlicht/jpeglib/jfdctfst.c +++ b/src/dep/src/irrlicht/jpeglib/jfdctfst.c @@ -1,224 +1,224 @@ -/* - * jfdctfst.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a fast, not so accurate integer implementation of the - * forward DCT (Discrete Cosine Transform). - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with fixed-point math, - * accuracy is lost due to imprecise representation of the scaled - * quantization values. The smaller the quantization table entry, the less - * precise the scaled value, so this implementation does worse with high- - * quality-setting files than with low-quality ones. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_IFAST_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling decisions are generally the same as in the LL&M algorithm; - * see jfdctint.c for more details. However, we choose to descale - * (right shift) multiplication products as soon as they are formed, - * rather than carrying additional fractional bits into subsequent additions. - * This compromises accuracy slightly, but it lets us save a few shifts. - * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) - * everywhere except in the multiplications proper; this saves a good deal - * of work on 16-bit-int machines. - * - * Again to save a few shifts, the intermediate results between pass 1 and - * pass 2 are not upscaled, but are represented only to integral precision. - * - * A final compromise is to represent the multiplicative constants to only - * 8 fractional bits, rather than 13. This saves some shifting work on some - * machines, and may also reduce the cost of multiplication (since there - * are fewer one-bits in the constants). - */ - -#define CONST_BITS 8 - - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 8 -#define FIX_0_382683433 ((INT32) 98) /* FIX(0.382683433) */ -#define FIX_0_541196100 ((INT32) 139) /* FIX(0.541196100) */ -#define FIX_0_707106781 ((INT32) 181) /* FIX(0.707106781) */ -#define FIX_1_306562965 ((INT32) 334) /* FIX(1.306562965) */ -#else -#define FIX_0_382683433 FIX(0.382683433) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_707106781 FIX(0.707106781) -#define FIX_1_306562965 FIX(1.306562965) -#endif - - -/* We can gain a little more speed, with a further compromise in accuracy, - * by omitting the addition in a descaling shift. This yields an incorrectly - * rounded result half the time... - */ - -#ifndef USE_ACCURATE_ROUNDING -#undef DESCALE -#define DESCALE(x,n) RIGHT_SHIFT(x, n) -#endif - - -/* Multiply a DCTELEM variable by an INT32 constant, and immediately - * descale to yield a DCTELEM result. - */ - -#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_ifast (DCTELEM * data) -{ - DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - DCTELEM tmp10, tmp11, tmp12, tmp13; - DCTELEM z1, z2, z3, z4, z5, z11, z13; - DCTELEM *dataptr; - int ctr; - SHIFT_TEMPS - - /* Pass 1: process rows. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = tmp10 + tmp11; /* phase 3 */ - dataptr[4] = tmp10 - tmp11; - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ - dataptr[2] = tmp13 + z1; /* phase 5 */ - dataptr[6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ - z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ - z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ - z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[5] = z13 + z2; /* phase 6 */ - dataptr[3] = z13 - z2; - dataptr[1] = z11 + z4; - dataptr[7] = z11 - z4; - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ - dataptr[DCTSIZE*4] = tmp10 - tmp11; - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ - dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ - dataptr[DCTSIZE*6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ - z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ - z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ - z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ - dataptr[DCTSIZE*3] = z13 - z2; - dataptr[DCTSIZE*1] = z11 + z4; - dataptr[DCTSIZE*7] = z11 - z4; - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_IFAST_SUPPORTED */ +/* + * jfdctfst.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a fast, not so accurate integer implementation of the + * forward DCT (Discrete Cosine Transform). + * + * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT + * on each column. Direct algorithms are also available, but they are + * much more complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with fixed-point math, + * accuracy is lost due to imprecise representation of the scaled + * quantization values. The smaller the quantization table entry, the less + * precise the scaled value, so this implementation does worse with high- + * quality-setting files than with low-quality ones. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_IFAST_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* Scaling decisions are generally the same as in the LL&M algorithm; + * see jfdctint.c for more details. However, we choose to descale + * (right shift) multiplication products as soon as they are formed, + * rather than carrying additional fractional bits into subsequent additions. + * This compromises accuracy slightly, but it lets us save a few shifts. + * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) + * everywhere except in the multiplications proper; this saves a good deal + * of work on 16-bit-int machines. + * + * Again to save a few shifts, the intermediate results between pass 1 and + * pass 2 are not upscaled, but are represented only to integral precision. + * + * A final compromise is to represent the multiplicative constants to only + * 8 fractional bits, rather than 13. This saves some shifting work on some + * machines, and may also reduce the cost of multiplication (since there + * are fewer one-bits in the constants). + */ + +#define CONST_BITS 8 + + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 8 +#define FIX_0_382683433 ((INT32) 98) /* FIX(0.382683433) */ +#define FIX_0_541196100 ((INT32) 139) /* FIX(0.541196100) */ +#define FIX_0_707106781 ((INT32) 181) /* FIX(0.707106781) */ +#define FIX_1_306562965 ((INT32) 334) /* FIX(1.306562965) */ +#else +#define FIX_0_382683433 FIX(0.382683433) +#define FIX_0_541196100 FIX(0.541196100) +#define FIX_0_707106781 FIX(0.707106781) +#define FIX_1_306562965 FIX(1.306562965) +#endif + + +/* We can gain a little more speed, with a further compromise in accuracy, + * by omitting the addition in a descaling shift. This yields an incorrectly + * rounded result half the time... + */ + +#ifndef USE_ACCURATE_ROUNDING +#undef DESCALE +#define DESCALE(x,n) RIGHT_SHIFT(x, n) +#endif + + +/* Multiply a DCTELEM variable by an INT32 constant, and immediately + * descale to yield a DCTELEM result. + */ + +#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) + + +/* + * Perform the forward DCT on one block of samples. + */ + +GLOBAL(void) +jpeg_fdct_ifast (DCTELEM * data) +{ + DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + DCTELEM tmp10, tmp11, tmp12, tmp13; + DCTELEM z1, z2, z3, z4, z5, z11, z13; + DCTELEM *dataptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[0] + dataptr[7]; + tmp7 = dataptr[0] - dataptr[7]; + tmp1 = dataptr[1] + dataptr[6]; + tmp6 = dataptr[1] - dataptr[6]; + tmp2 = dataptr[2] + dataptr[5]; + tmp5 = dataptr[2] - dataptr[5]; + tmp3 = dataptr[3] + dataptr[4]; + tmp4 = dataptr[3] - dataptr[4]; + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[0] = tmp10 + tmp11; /* phase 3 */ + dataptr[4] = tmp10 - tmp11; + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ + dataptr[2] = tmp13 + z1; /* phase 5 */ + dataptr[6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ + z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ + z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ + z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[5] = z13 + z2; /* phase 6 */ + dataptr[3] = z13 - z2; + dataptr[1] = z11 + z4; + dataptr[7] = z11 - z4; + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ + dataptr[DCTSIZE*4] = tmp10 - tmp11; + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ + dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ + dataptr[DCTSIZE*6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ + z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ + z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ + z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ + dataptr[DCTSIZE*3] = z13 - z2; + dataptr[DCTSIZE*1] = z11 + z4; + dataptr[DCTSIZE*7] = z11 - z4; + + dataptr++; /* advance pointer to next column */ + } +} + +#endif /* DCT_IFAST_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/jfdctint.c b/src/dep/src/irrlicht/jpeglib/jfdctint.c index d626927..0a78b64 100644 --- a/src/dep/src/irrlicht/jpeglib/jfdctint.c +++ b/src/dep/src/irrlicht/jpeglib/jfdctint.c @@ -1,283 +1,283 @@ -/* - * jfdctint.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a slow-but-accurate integer implementation of the - * forward DCT (Discrete Cosine Transform). - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on an algorithm described in - * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT - * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, - * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. - * The primary algorithm described there uses 11 multiplies and 29 adds. - * We use their alternate method with 12 multiplies and 32 adds. - * The advantage of this method is that no data path contains more than one - * multiplication; this allows a very simple and accurate implementation in - * scaled fixed-point arithmetic, with a minimal number of shifts. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_ISLOW_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * The poop on this scaling stuff is as follows: - * - * Each 1-D DCT step produces outputs which are a factor of sqrt(N) - * larger than the true DCT outputs. The final outputs are therefore - * a factor of N larger than desired; since N=8 this can be cured by - * a simple right shift at the end of the algorithm. The advantage of - * this arrangement is that we save two multiplications per 1-D DCT, - * because the y0 and y4 outputs need not be divided by sqrt(N). - * In the IJG code, this factor of 8 is removed by the quantization step - * (in jcdctmgr.c), NOT in this module. - * - * We have to do addition and subtraction of the integer inputs, which - * is no problem, and multiplication by fractional constants, which is - * a problem to do in integer arithmetic. We multiply all the constants - * by CONST_SCALE and convert them to integer constants (thus retaining - * CONST_BITS bits of precision in the constants). After doing a - * multiplication we have to divide the product by CONST_SCALE, with proper - * rounding, to produce the correct output. This division can be done - * cheaply as a right shift of CONST_BITS bits. We postpone shifting - * as long as possible so that partial sums can be added together with - * full fractional precision. - * - * The outputs of the first pass are scaled up by PASS1_BITS bits so that - * they are represented to better-than-integral precision. These outputs - * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word - * with the recommended scaling. (For 12-bit sample data, the intermediate - * array is INT32 anyway.) - * - * To avoid overflow of the 32-bit intermediate results in pass 2, we must - * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis - * shows that the values given below are the most effective. - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ -#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ -#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ -#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ -#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ -#else -#define FIX_0_298631336 FIX(0.298631336) -#define FIX_0_390180644 FIX(0.390180644) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_175875602 FIX(1.175875602) -#define FIX_1_501321110 FIX(1.501321110) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_1_961570560 FIX(1.961570560) -#define FIX_2_053119869 FIX(2.053119869) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_072711026 FIX(3.072711026) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_islow (DCTELEM * data) -{ - INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - INT32 tmp10, tmp11, tmp12, tmp13; - INT32 z1, z2, z3, z4, z5; - DCTELEM *dataptr; - int ctr; - SHIFT_TEMPS - - /* Pass 1: process rows. */ - /* Note results are scaled up by sqrt(8) compared to a true DCT; */ - /* furthermore, we scale the results by 2**PASS1_BITS. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part per LL&M figure 1 --- note that published figure is faulty; - * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". - */ - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS); - dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS-PASS1_BITS); - dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS-PASS1_BITS); - - /* Odd part per figure 8 --- note paper omits factor of sqrt(2). - * cK represents cos(K*pi/16). - * i0..i3 in the paper are tmp4..tmp7 here. - */ - - z1 = tmp4 + tmp7; - z2 = tmp5 + tmp6; - z3 = tmp4 + tmp6; - z4 = tmp5 + tmp7; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); - dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); - dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); - dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. - * We remove the PASS1_BITS scaling, but leave the results scaled up - * by an overall factor of 8. - */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part per LL&M figure 1 --- note that published figure is faulty; - * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". - */ - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS); - dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS+PASS1_BITS); - - /* Odd part per figure 8 --- note paper omits factor of sqrt(2). - * cK represents cos(K*pi/16). - * i0..i3 in the paper are tmp4..tmp7 here. - */ - - z1 = tmp4 + tmp7; - z2 = tmp5 + tmp6; - z3 = tmp4 + tmp6; - z4 = tmp5 + tmp7; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, - CONST_BITS+PASS1_BITS); - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_ISLOW_SUPPORTED */ +/* + * jfdctint.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a slow-but-accurate integer implementation of the + * forward DCT (Discrete Cosine Transform). + * + * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT + * on each column. Direct algorithms are also available, but they are + * much more complex and seem not to be any faster when reduced to code. + * + * This implementation is based on an algorithm described in + * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT + * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, + * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. + * The primary algorithm described there uses 11 multiplies and 29 adds. + * We use their alternate method with 12 multiplies and 32 adds. + * The advantage of this method is that no data path contains more than one + * multiplication; this allows a very simple and accurate implementation in + * scaled fixed-point arithmetic, with a minimal number of shifts. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_ISLOW_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* + * The poop on this scaling stuff is as follows: + * + * Each 1-D DCT step produces outputs which are a factor of sqrt(N) + * larger than the true DCT outputs. The final outputs are therefore + * a factor of N larger than desired; since N=8 this can be cured by + * a simple right shift at the end of the algorithm. The advantage of + * this arrangement is that we save two multiplications per 1-D DCT, + * because the y0 and y4 outputs need not be divided by sqrt(N). + * In the IJG code, this factor of 8 is removed by the quantization step + * (in jcdctmgr.c), NOT in this module. + * + * We have to do addition and subtraction of the integer inputs, which + * is no problem, and multiplication by fractional constants, which is + * a problem to do in integer arithmetic. We multiply all the constants + * by CONST_SCALE and convert them to integer constants (thus retaining + * CONST_BITS bits of precision in the constants). After doing a + * multiplication we have to divide the product by CONST_SCALE, with proper + * rounding, to produce the correct output. This division can be done + * cheaply as a right shift of CONST_BITS bits. We postpone shifting + * as long as possible so that partial sums can be added together with + * full fractional precision. + * + * The outputs of the first pass are scaled up by PASS1_BITS bits so that + * they are represented to better-than-integral precision. These outputs + * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word + * with the recommended scaling. (For 12-bit sample data, the intermediate + * array is INT32 anyway.) + * + * To avoid overflow of the 32-bit intermediate results in pass 2, we must + * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis + * shows that the values given below are the most effective. + */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 13 +#define PASS1_BITS 2 +#else +#define CONST_BITS 13 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 13 +#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ +#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ +#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ +#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ +#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ +#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ +#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ +#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ +#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ +#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ +#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ +#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ +#else +#define FIX_0_298631336 FIX(0.298631336) +#define FIX_0_390180644 FIX(0.390180644) +#define FIX_0_541196100 FIX(0.541196100) +#define FIX_0_765366865 FIX(0.765366865) +#define FIX_0_899976223 FIX(0.899976223) +#define FIX_1_175875602 FIX(1.175875602) +#define FIX_1_501321110 FIX(1.501321110) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_1_961570560 FIX(1.961570560) +#define FIX_2_053119869 FIX(2.053119869) +#define FIX_2_562915447 FIX(2.562915447) +#define FIX_3_072711026 FIX(3.072711026) +#endif + + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * For 8-bit samples with the recommended scaling, all the variable + * and constant values involved are no more than 16 bits wide, so a + * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. + * For 12-bit samples, a full 32-bit multiplication will be needed. + */ + +#if BITS_IN_JSAMPLE == 8 +#define MULTIPLY(var,const) MULTIPLY16C16(var,const) +#else +#define MULTIPLY(var,const) ((var) * (const)) +#endif + + +/* + * Perform the forward DCT on one block of samples. + */ + +GLOBAL(void) +jpeg_fdct_islow (DCTELEM * data) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + INT32 tmp10, tmp11, tmp12, tmp13; + INT32 z1, z2, z3, z4, z5; + DCTELEM *dataptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. */ + /* Note results are scaled up by sqrt(8) compared to a true DCT; */ + /* furthermore, we scale the results by 2**PASS1_BITS. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[0] + dataptr[7]; + tmp7 = dataptr[0] - dataptr[7]; + tmp1 = dataptr[1] + dataptr[6]; + tmp6 = dataptr[1] - dataptr[6]; + tmp2 = dataptr[2] + dataptr[5]; + tmp5 = dataptr[2] - dataptr[5]; + tmp3 = dataptr[3] + dataptr[4]; + tmp4 = dataptr[3] - dataptr[4]; + + /* Even part per LL&M figure 1 --- note that published figure is faulty; + * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". + */ + + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS); + dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); + dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), + CONST_BITS-PASS1_BITS); + dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), + CONST_BITS-PASS1_BITS); + + /* Odd part per figure 8 --- note paper omits factor of sqrt(2). + * cK represents cos(K*pi/16). + * i0..i3 in the paper are tmp4..tmp7 here. + */ + + z1 = tmp4 + tmp7; + z2 = tmp5 + tmp6; + z3 = tmp4 + tmp6; + z4 = tmp5 + tmp7; + z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ + + tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ + tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ + tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ + tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ + z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ + z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ + z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ + z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ + + z3 += z5; + z4 += z5; + + dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); + dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); + dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); + dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + /* Even part per LL&M figure 1 --- note that published figure is faulty; + * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". + */ + + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS); + dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); + dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), + CONST_BITS+PASS1_BITS); + + /* Odd part per figure 8 --- note paper omits factor of sqrt(2). + * cK represents cos(K*pi/16). + * i0..i3 in the paper are tmp4..tmp7 here. + */ + + z1 = tmp4 + tmp7; + z2 = tmp5 + tmp6; + z3 = tmp4 + tmp6; + z4 = tmp5 + tmp7; + z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ + + tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ + tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ + tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ + tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ + z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ + z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ + z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ + z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ + + z3 += z5; + z4 += z5; + + dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, + CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + } +} + +#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/jidctflt.c b/src/dep/src/irrlicht/jpeglib/jidctflt.c index 5fea54c..0188ce3 100644 --- a/src/dep/src/irrlicht/jpeglib/jidctflt.c +++ b/src/dep/src/irrlicht/jpeglib/jidctflt.c @@ -1,242 +1,242 @@ -/* - * jidctflt.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a floating-point implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * This implementation should be more accurate than either of the integer - * IDCT implementations. However, it may not give the same results on all - * machines because of differences in roundoff behavior. Speed will depend - * on the hardware's floating point capacity. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with a fixed-point - * implementation, accuracy is lost due to imprecise representation of the - * scaled quantization values. However, that problem does not arise if - * we use floating point arithmetic. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_FLOAT_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce a float result. - */ - -#define DEQUANTIZE(coef,quantval) (((FAST_FLOAT) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - FAST_FLOAT tmp10, tmp11, tmp12, tmp13; - FAST_FLOAT z5, z10, z11, z12, z13; - JCOEFPTR inptr; - FLOAT_MULT_TYPE * quantptr; - FAST_FLOAT * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp10 = tmp0 + tmp2; /* phase 3 */ - tmp11 = tmp0 - tmp2; - - tmp13 = tmp1 + tmp3; /* phases 5-3 */ - tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */ - - tmp0 = tmp10 + tmp13; /* phase 2 */ - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - - z13 = tmp6 + tmp5; /* phase 6 */ - z10 = tmp6 - tmp5; - z11 = tmp4 + tmp7; - z12 = tmp4 - tmp7; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */ - - z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ - tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ - tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - wsptr[DCTSIZE*0] = tmp0 + tmp7; - wsptr[DCTSIZE*7] = tmp0 - tmp7; - wsptr[DCTSIZE*1] = tmp1 + tmp6; - wsptr[DCTSIZE*6] = tmp1 - tmp6; - wsptr[DCTSIZE*2] = tmp2 + tmp5; - wsptr[DCTSIZE*5] = tmp2 - tmp5; - wsptr[DCTSIZE*4] = tmp3 + tmp4; - wsptr[DCTSIZE*3] = tmp3 - tmp4; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * And testing floats for zero is relatively expensive, so we don't bother. - */ - - /* Even part */ - - tmp10 = wsptr[0] + wsptr[4]; - tmp11 = wsptr[0] - wsptr[4]; - - tmp13 = wsptr[2] + wsptr[6]; - tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13; - - tmp0 = tmp10 + tmp13; - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - z13 = wsptr[5] + wsptr[3]; - z10 = wsptr[5] - wsptr[3]; - z11 = wsptr[1] + wsptr[7]; - z12 = wsptr[1] - wsptr[7]; - - tmp7 = z11 + z13; - tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); - - z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ - tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ - tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - /* Final output stage: scale down by a factor of 8 and range-limit */ - - outptr[0] = range_limit[(int) DESCALE((INT32) (tmp0 + tmp7), 3) - & RANGE_MASK]; - outptr[7] = range_limit[(int) DESCALE((INT32) (tmp0 - tmp7), 3) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE((INT32) (tmp1 + tmp6), 3) - & RANGE_MASK]; - outptr[6] = range_limit[(int) DESCALE((INT32) (tmp1 - tmp6), 3) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE((INT32) (tmp2 + tmp5), 3) - & RANGE_MASK]; - outptr[5] = range_limit[(int) DESCALE((INT32) (tmp2 - tmp5), 3) - & RANGE_MASK]; - outptr[4] = range_limit[(int) DESCALE((INT32) (tmp3 + tmp4), 3) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE((INT32) (tmp3 - tmp4), 3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ +/* + * jidctflt.c + * + * Copyright (C) 1994-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a floating-point implementation of the + * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine + * must also perform dequantization of the input coefficients. + * + * This implementation should be more accurate than either of the integer + * IDCT implementations. However, it may not give the same results on all + * machines because of differences in roundoff behavior. Speed will depend + * on the hardware's floating point capacity. + * + * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT + * on each row (or vice versa, but it's more convenient to emit a row at + * a time). Direct algorithms are also available, but they are much more + * complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with a fixed-point + * implementation, accuracy is lost due to imprecise representation of the + * scaled quantization values. However, that problem does not arise if + * we use floating point arithmetic. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_FLOAT_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce a float result. + */ + +#define DEQUANTIZE(coef,quantval) (((FAST_FLOAT) (coef)) * (quantval)) + + +/* + * Perform dequantization and inverse DCT on one block of coefficients. + */ + +GLOBAL(void) +jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + FAST_FLOAT tmp10, tmp11, tmp12, tmp13; + FAST_FLOAT z5, z10, z11, z12, z13; + JCOEFPTR inptr; + FLOAT_MULT_TYPE * quantptr; + FAST_FLOAT * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; ctr--) { + /* Due to quantization, we will usually find that many of the input + * coefficients are zero, especially the AC terms. We can exploit this + * by short-circuiting the IDCT calculation for any column in which all + * the AC terms are zero. In that case each output is equal to the + * DC coefficient (with scale factor as needed). + * With typical images and quantization tables, half or more of the + * column DCT calculations can be simplified this way. + */ + + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && + inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && + inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && + inptr[DCTSIZE*7] == 0) { + /* AC terms all zero */ + FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + wsptr[DCTSIZE*4] = dcval; + wsptr[DCTSIZE*5] = dcval; + wsptr[DCTSIZE*6] = dcval; + wsptr[DCTSIZE*7] = dcval; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + continue; + } + + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp10 = tmp0 + tmp2; /* phase 3 */ + tmp11 = tmp0 - tmp2; + + tmp13 = tmp1 + tmp3; /* phases 5-3 */ + tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */ + + tmp0 = tmp10 + tmp13; /* phase 2 */ + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + z13 = tmp6 + tmp5; /* phase 6 */ + z10 = tmp6 - tmp5; + z11 = tmp4 + tmp7; + z12 = tmp4 - tmp7; + + tmp7 = z11 + z13; /* phase 5 */ + tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */ + + z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ + tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ + tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; /* phase 2 */ + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 + tmp5; + + wsptr[DCTSIZE*0] = tmp0 + tmp7; + wsptr[DCTSIZE*7] = tmp0 - tmp7; + wsptr[DCTSIZE*1] = tmp1 + tmp6; + wsptr[DCTSIZE*6] = tmp1 - tmp6; + wsptr[DCTSIZE*2] = tmp2 + tmp5; + wsptr[DCTSIZE*5] = tmp2 - tmp5; + wsptr[DCTSIZE*4] = tmp3 + tmp4; + wsptr[DCTSIZE*3] = tmp3 - tmp4; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + } + + /* Pass 2: process rows from work array, store into output array. */ + /* Note that we must descale the results by a factor of 8 == 2**3. */ + + wsptr = workspace; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + outptr = output_buf[ctr] + output_col; + /* Rows of zeroes can be exploited in the same way as we did with columns. + * However, the column calculation has created many nonzero AC terms, so + * the simplification applies less often (typically 5% to 10% of the time). + * And testing floats for zero is relatively expensive, so we don't bother. + */ + + /* Even part */ + + tmp10 = wsptr[0] + wsptr[4]; + tmp11 = wsptr[0] - wsptr[4]; + + tmp13 = wsptr[2] + wsptr[6]; + tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13; + + tmp0 = tmp10 + tmp13; + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + z13 = wsptr[5] + wsptr[3]; + z10 = wsptr[5] - wsptr[3]; + z11 = wsptr[1] + wsptr[7]; + z12 = wsptr[1] - wsptr[7]; + + tmp7 = z11 + z13; + tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); + + z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ + tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ + tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 + tmp5; + + /* Final output stage: scale down by a factor of 8 and range-limit */ + + outptr[0] = range_limit[(int) DESCALE((INT32) (tmp0 + tmp7), 3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) DESCALE((INT32) (tmp0 - tmp7), 3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) DESCALE((INT32) (tmp1 + tmp6), 3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) DESCALE((INT32) (tmp1 - tmp6), 3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) DESCALE((INT32) (tmp2 + tmp5), 3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) DESCALE((INT32) (tmp2 - tmp5), 3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) DESCALE((INT32) (tmp3 + tmp4), 3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) DESCALE((INT32) (tmp3 - tmp4), 3) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + +#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/jidctfst.c b/src/dep/src/irrlicht/jpeglib/jidctfst.c index 078b8c4..dba4216 100644 --- a/src/dep/src/irrlicht/jpeglib/jidctfst.c +++ b/src/dep/src/irrlicht/jpeglib/jidctfst.c @@ -1,368 +1,368 @@ -/* - * jidctfst.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a fast, not so accurate integer implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with fixed-point math, - * accuracy is lost due to imprecise representation of the scaled - * quantization values. The smaller the quantization table entry, the less - * precise the scaled value, so this implementation does worse with high- - * quality-setting files than with low-quality ones. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_IFAST_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling decisions are generally the same as in the LL&M algorithm; - * see jidctint.c for more details. However, we choose to descale - * (right shift) multiplication products as soon as they are formed, - * rather than carrying additional fractional bits into subsequent additions. - * This compromises accuracy slightly, but it lets us save a few shifts. - * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) - * everywhere except in the multiplications proper; this saves a good deal - * of work on 16-bit-int machines. - * - * The dequantized coefficients are not integers because the AA&N scaling - * factors have been incorporated. We represent them scaled up by PASS1_BITS, - * so that the first and second IDCT rounds have the same input scaling. - * For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = PASS1_BITS so as to - * avoid a descaling shift; this compromises accuracy rather drastically - * for small quantization table entries, but it saves a lot of shifts. - * For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway, - * so we use a much larger scaling factor to preserve accuracy. - * - * A final compromise is to represent the multiplicative constants to only - * 8 fractional bits, rather than 13. This saves some shifting work on some - * machines, and may also reduce the cost of multiplication (since there - * are fewer one-bits in the constants). - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 8 -#define PASS1_BITS 2 -#else -#define CONST_BITS 8 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 8 -#define FIX_1_082392200 ((INT32) 277) /* FIX(1.082392200) */ -#define FIX_1_414213562 ((INT32) 362) /* FIX(1.414213562) */ -#define FIX_1_847759065 ((INT32) 473) /* FIX(1.847759065) */ -#define FIX_2_613125930 ((INT32) 669) /* FIX(2.613125930) */ -#else -#define FIX_1_082392200 FIX(1.082392200) -#define FIX_1_414213562 FIX(1.414213562) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_2_613125930 FIX(2.613125930) -#endif - - -/* We can gain a little more speed, with a further compromise in accuracy, - * by omitting the addition in a descaling shift. This yields an incorrectly - * rounded result half the time... - */ - -#ifndef USE_ACCURATE_ROUNDING -#undef DESCALE -#define DESCALE(x,n) RIGHT_SHIFT(x, n) -#endif - - -/* Multiply a DCTELEM variable by an INT32 constant, and immediately - * descale to yield a DCTELEM result. - */ - -#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce a DCTELEM result. For 8-bit data a 16x16->16 - * multiplication will do. For 12-bit data, the multiplier table is - * declared INT32, so a 32-bit multiply will be used. - */ - -#if BITS_IN_JSAMPLE == 8 -#define DEQUANTIZE(coef,quantval) (((IFAST_MULT_TYPE) (coef)) * (quantval)) -#else -#define DEQUANTIZE(coef,quantval) \ - DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS) -#endif - - -/* Like DESCALE, but applies to a DCTELEM and produces an int. - * We assume that int right shift is unsigned if INT32 right shift is. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define ISHIFT_TEMPS DCTELEM ishift_temp; -#if BITS_IN_JSAMPLE == 8 -#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */ -#else -#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */ -#endif -#define IRIGHT_SHIFT(x,shft) \ - ((ishift_temp = (x)) < 0 ? \ - (ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \ - (ishift_temp >> (shft))) -#else -#define ISHIFT_TEMPS -#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - -#ifdef USE_ACCURATE_ROUNDING -#define IDESCALE(x,n) ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n)) -#else -#define IDESCALE(x,n) ((int) IRIGHT_SHIFT(x, n)) -#endif - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - DCTELEM tmp10, tmp11, tmp12, tmp13; - DCTELEM z5, z10, z11, z12, z13; - JCOEFPTR inptr; - IFAST_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS /* for DESCALE */ - ISHIFT_TEMPS /* for IDESCALE */ - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (IFAST_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp10 = tmp0 + tmp2; /* phase 3 */ - tmp11 = tmp0 - tmp2; - - tmp13 = tmp1 + tmp3; /* phases 5-3 */ - tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ - - tmp0 = tmp10 + tmp13; /* phase 2 */ - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - - z13 = tmp6 + tmp5; /* phase 6 */ - z10 = tmp6 - tmp5; - z11 = tmp4 + tmp7; - z12 = tmp4 - tmp7; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ - - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ - tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ - tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); - wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); - wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); - wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); - wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5); - wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); - wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); - wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3, */ - /* and also undo the PASS1_BITS scaling. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * On machines with very fast multiplication, it's possible that the - * test takes more time than it's worth. In that case this section - * may be commented out. - */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - outptr[4] = dcval; - outptr[5] = dcval; - outptr[6] = dcval; - outptr[7] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); - tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); - - tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); - tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562) - - tmp13; - - tmp0 = tmp10 + tmp13; - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; - z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; - z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; - z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ - - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ - tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ - tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - /* Final output stage: scale down by a factor of 8 and range-limit */ - - outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) - & RANGE_MASK]; - outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) - & RANGE_MASK]; - outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) - & RANGE_MASK]; - outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) - & RANGE_MASK]; - outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) - & RANGE_MASK]; - outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) - & RANGE_MASK]; - outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) - & RANGE_MASK]; - outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_IFAST_SUPPORTED */ +/* + * jidctfst.c + * + * Copyright (C) 1994-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a fast, not so accurate integer implementation of the + * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine + * must also perform dequantization of the input coefficients. + * + * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT + * on each row (or vice versa, but it's more convenient to emit a row at + * a time). Direct algorithms are also available, but they are much more + * complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with fixed-point math, + * accuracy is lost due to imprecise representation of the scaled + * quantization values. The smaller the quantization table entry, the less + * precise the scaled value, so this implementation does worse with high- + * quality-setting files than with low-quality ones. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_IFAST_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* Scaling decisions are generally the same as in the LL&M algorithm; + * see jidctint.c for more details. However, we choose to descale + * (right shift) multiplication products as soon as they are formed, + * rather than carrying additional fractional bits into subsequent additions. + * This compromises accuracy slightly, but it lets us save a few shifts. + * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) + * everywhere except in the multiplications proper; this saves a good deal + * of work on 16-bit-int machines. + * + * The dequantized coefficients are not integers because the AA&N scaling + * factors have been incorporated. We represent them scaled up by PASS1_BITS, + * so that the first and second IDCT rounds have the same input scaling. + * For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = PASS1_BITS so as to + * avoid a descaling shift; this compromises accuracy rather drastically + * for small quantization table entries, but it saves a lot of shifts. + * For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway, + * so we use a much larger scaling factor to preserve accuracy. + * + * A final compromise is to represent the multiplicative constants to only + * 8 fractional bits, rather than 13. This saves some shifting work on some + * machines, and may also reduce the cost of multiplication (since there + * are fewer one-bits in the constants). + */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 8 +#define PASS1_BITS 2 +#else +#define CONST_BITS 8 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 8 +#define FIX_1_082392200 ((INT32) 277) /* FIX(1.082392200) */ +#define FIX_1_414213562 ((INT32) 362) /* FIX(1.414213562) */ +#define FIX_1_847759065 ((INT32) 473) /* FIX(1.847759065) */ +#define FIX_2_613125930 ((INT32) 669) /* FIX(2.613125930) */ +#else +#define FIX_1_082392200 FIX(1.082392200) +#define FIX_1_414213562 FIX(1.414213562) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_2_613125930 FIX(2.613125930) +#endif + + +/* We can gain a little more speed, with a further compromise in accuracy, + * by omitting the addition in a descaling shift. This yields an incorrectly + * rounded result half the time... + */ + +#ifndef USE_ACCURATE_ROUNDING +#undef DESCALE +#define DESCALE(x,n) RIGHT_SHIFT(x, n) +#endif + + +/* Multiply a DCTELEM variable by an INT32 constant, and immediately + * descale to yield a DCTELEM result. + */ + +#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce a DCTELEM result. For 8-bit data a 16x16->16 + * multiplication will do. For 12-bit data, the multiplier table is + * declared INT32, so a 32-bit multiply will be used. + */ + +#if BITS_IN_JSAMPLE == 8 +#define DEQUANTIZE(coef,quantval) (((IFAST_MULT_TYPE) (coef)) * (quantval)) +#else +#define DEQUANTIZE(coef,quantval) \ + DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS) +#endif + + +/* Like DESCALE, but applies to a DCTELEM and produces an int. + * We assume that int right shift is unsigned if INT32 right shift is. + */ + +#ifdef RIGHT_SHIFT_IS_UNSIGNED +#define ISHIFT_TEMPS DCTELEM ishift_temp; +#if BITS_IN_JSAMPLE == 8 +#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */ +#else +#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */ +#endif +#define IRIGHT_SHIFT(x,shft) \ + ((ishift_temp = (x)) < 0 ? \ + (ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \ + (ishift_temp >> (shft))) +#else +#define ISHIFT_TEMPS +#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) +#endif + +#ifdef USE_ACCURATE_ROUNDING +#define IDESCALE(x,n) ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n)) +#else +#define IDESCALE(x,n) ((int) IRIGHT_SHIFT(x, n)) +#endif + + +/* + * Perform dequantization and inverse DCT on one block of coefficients. + */ + +GLOBAL(void) +jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + DCTELEM tmp10, tmp11, tmp12, tmp13; + DCTELEM z5, z10, z11, z12, z13; + JCOEFPTR inptr; + IFAST_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[DCTSIZE2]; /* buffers data between passes */ + SHIFT_TEMPS /* for DESCALE */ + ISHIFT_TEMPS /* for IDESCALE */ + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (IFAST_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; ctr--) { + /* Due to quantization, we will usually find that many of the input + * coefficients are zero, especially the AC terms. We can exploit this + * by short-circuiting the IDCT calculation for any column in which all + * the AC terms are zero. In that case each output is equal to the + * DC coefficient (with scale factor as needed). + * With typical images and quantization tables, half or more of the + * column DCT calculations can be simplified this way. + */ + + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && + inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && + inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && + inptr[DCTSIZE*7] == 0) { + /* AC terms all zero */ + int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + wsptr[DCTSIZE*4] = dcval; + wsptr[DCTSIZE*5] = dcval; + wsptr[DCTSIZE*6] = dcval; + wsptr[DCTSIZE*7] = dcval; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + continue; + } + + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp10 = tmp0 + tmp2; /* phase 3 */ + tmp11 = tmp0 - tmp2; + + tmp13 = tmp1 + tmp3; /* phases 5-3 */ + tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ + + tmp0 = tmp10 + tmp13; /* phase 2 */ + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + z13 = tmp6 + tmp5; /* phase 6 */ + z10 = tmp6 - tmp5; + z11 = tmp4 + tmp7; + z12 = tmp4 - tmp7; + + tmp7 = z11 + z13; /* phase 5 */ + tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ + + z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ + tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ + tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; /* phase 2 */ + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 + tmp5; + + wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); + wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); + wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); + wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); + wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5); + wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); + wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); + wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + } + + /* Pass 2: process rows from work array, store into output array. */ + /* Note that we must descale the results by a factor of 8 == 2**3, */ + /* and also undo the PASS1_BITS scaling. */ + + wsptr = workspace; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + outptr = output_buf[ctr] + output_col; + /* Rows of zeroes can be exploited in the same way as we did with columns. + * However, the column calculation has created many nonzero AC terms, so + * the simplification applies less often (typically 5% to 10% of the time). + * On machines with very fast multiplication, it's possible that the + * test takes more time than it's worth. In that case this section + * may be commented out. + */ + +#ifndef NO_ZERO_ROW_TEST + if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && + wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { + /* AC terms all zero */ + JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3) + & RANGE_MASK]; + + outptr[0] = dcval; + outptr[1] = dcval; + outptr[2] = dcval; + outptr[3] = dcval; + outptr[4] = dcval; + outptr[5] = dcval; + outptr[6] = dcval; + outptr[7] = dcval; + + wsptr += DCTSIZE; /* advance pointer to next row */ + continue; + } +#endif + + /* Even part */ + + tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); + tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); + + tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); + tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562) + - tmp13; + + tmp0 = tmp10 + tmp13; + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; + z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; + z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; + z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; + + tmp7 = z11 + z13; /* phase 5 */ + tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ + + z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ + tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ + tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; /* phase 2 */ + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 + tmp5; + + /* Final output stage: scale down by a factor of 8 and range-limit */ + + outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + +#endif /* DCT_IFAST_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/jidctint.c b/src/dep/src/irrlicht/jpeglib/jidctint.c index 4f47fe8..a72b320 100644 --- a/src/dep/src/irrlicht/jpeglib/jidctint.c +++ b/src/dep/src/irrlicht/jpeglib/jidctint.c @@ -1,389 +1,389 @@ -/* - * jidctint.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a slow-but-accurate integer implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on an algorithm described in - * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT - * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, - * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. - * The primary algorithm described there uses 11 multiplies and 29 adds. - * We use their alternate method with 12 multiplies and 32 adds. - * The advantage of this method is that no data path contains more than one - * multiplication; this allows a very simple and accurate implementation in - * scaled fixed-point arithmetic, with a minimal number of shifts. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_ISLOW_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * The poop on this scaling stuff is as follows: - * - * Each 1-D IDCT step produces outputs which are a factor of sqrt(N) - * larger than the true IDCT outputs. The final outputs are therefore - * a factor of N larger than desired; since N=8 this can be cured by - * a simple right shift at the end of the algorithm. The advantage of - * this arrangement is that we save two multiplications per 1-D IDCT, - * because the y0 and y4 inputs need not be divided by sqrt(N). - * - * We have to do addition and subtraction of the integer inputs, which - * is no problem, and multiplication by fractional constants, which is - * a problem to do in integer arithmetic. We multiply all the constants - * by CONST_SCALE and convert them to integer constants (thus retaining - * CONST_BITS bits of precision in the constants). After doing a - * multiplication we have to divide the product by CONST_SCALE, with proper - * rounding, to produce the correct output. This division can be done - * cheaply as a right shift of CONST_BITS bits. We postpone shifting - * as long as possible so that partial sums can be added together with - * full fractional precision. - * - * The outputs of the first pass are scaled up by PASS1_BITS bits so that - * they are represented to better-than-integral precision. These outputs - * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word - * with the recommended scaling. (To scale up 12-bit sample data further, an - * intermediate INT32 array would be needed.) - * - * To avoid overflow of the 32-bit intermediate results in pass 2, we must - * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis - * shows that the values given below are the most effective. - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ -#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ -#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ -#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ -#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ -#else -#define FIX_0_298631336 FIX(0.298631336) -#define FIX_0_390180644 FIX(0.390180644) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_175875602 FIX(1.175875602) -#define FIX_1_501321110 FIX(1.501321110) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_1_961570560 FIX(1.961570560) -#define FIX_2_053119869 FIX(2.053119869) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_072711026 FIX(3.072711026) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce an int result. In this module, both inputs and result - * are 16 bits or less, so either int or short multiply will work. - */ - -#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp1, tmp2, tmp3; - INT32 tmp10, tmp11, tmp12, tmp13; - INT32 z1, z2, z3, z4, z5; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - /* Note results are scaled up by sqrt(8) compared to a true IDCT; */ - /* furthermore, we scale the results by 2**PASS1_BITS. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part: reverse the even part of the forward DCT. */ - /* The rotator is sqrt(2)*c(-6). */ - - z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - z1 = MULTIPLY(z2 + z3, FIX_0_541196100); - tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); - tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); - - z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - - tmp0 = (z2 + z3) << CONST_BITS; - tmp1 = (z2 - z3) << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - /* Odd part per figure 8; the matrix is unitary and hence its - * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. - */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - - z1 = tmp0 + tmp3; - z2 = tmp1 + tmp2; - z3 = tmp0 + tmp2; - z4 = tmp1 + tmp3; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - tmp0 += z1 + z3; - tmp1 += z2 + z4; - tmp2 += z2 + z3; - tmp3 += z1 + z4; - - /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*7] = (int) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*6] = (int) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*5] = (int) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*3] = (int) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*4] = (int) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS); - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3, */ - /* and also undo the PASS1_BITS scaling. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * On machines with very fast multiplication, it's possible that the - * test takes more time than it's worth. In that case this section - * may be commented out. - */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - outptr[4] = dcval; - outptr[5] = dcval; - outptr[6] = dcval; - outptr[7] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part: reverse the even part of the forward DCT. */ - /* The rotator is sqrt(2)*c(-6). */ - - z2 = (INT32) wsptr[2]; - z3 = (INT32) wsptr[6]; - - z1 = MULTIPLY(z2 + z3, FIX_0_541196100); - tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); - tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); - - tmp0 = ((INT32) wsptr[0] + (INT32) wsptr[4]) << CONST_BITS; - tmp1 = ((INT32) wsptr[0] - (INT32) wsptr[4]) << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - /* Odd part per figure 8; the matrix is unitary and hence its - * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. - */ - - tmp0 = (INT32) wsptr[7]; - tmp1 = (INT32) wsptr[5]; - tmp2 = (INT32) wsptr[3]; - tmp3 = (INT32) wsptr[1]; - - z1 = tmp0 + tmp3; - z2 = tmp1 + tmp2; - z3 = tmp0 + tmp2; - z4 = tmp1 + tmp3; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - tmp0 += z1 + z3; - tmp1 += z2 + z4; - tmp2 += z2 + z3; - tmp3 += z1 + z4; - - /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp3, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[7] = range_limit[(int) DESCALE(tmp10 - tmp3, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp11 + tmp2, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[6] = range_limit[(int) DESCALE(tmp11 - tmp2, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE(tmp12 + tmp1, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[5] = range_limit[(int) DESCALE(tmp12 - tmp1, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE(tmp13 + tmp0, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[4] = range_limit[(int) DESCALE(tmp13 - tmp0, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_ISLOW_SUPPORTED */ +/* + * jidctint.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a slow-but-accurate integer implementation of the + * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine + * must also perform dequantization of the input coefficients. + * + * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT + * on each row (or vice versa, but it's more convenient to emit a row at + * a time). Direct algorithms are also available, but they are much more + * complex and seem not to be any faster when reduced to code. + * + * This implementation is based on an algorithm described in + * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT + * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, + * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. + * The primary algorithm described there uses 11 multiplies and 29 adds. + * We use their alternate method with 12 multiplies and 32 adds. + * The advantage of this method is that no data path contains more than one + * multiplication; this allows a very simple and accurate implementation in + * scaled fixed-point arithmetic, with a minimal number of shifts. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_ISLOW_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* + * The poop on this scaling stuff is as follows: + * + * Each 1-D IDCT step produces outputs which are a factor of sqrt(N) + * larger than the true IDCT outputs. The final outputs are therefore + * a factor of N larger than desired; since N=8 this can be cured by + * a simple right shift at the end of the algorithm. The advantage of + * this arrangement is that we save two multiplications per 1-D IDCT, + * because the y0 and y4 inputs need not be divided by sqrt(N). + * + * We have to do addition and subtraction of the integer inputs, which + * is no problem, and multiplication by fractional constants, which is + * a problem to do in integer arithmetic. We multiply all the constants + * by CONST_SCALE and convert them to integer constants (thus retaining + * CONST_BITS bits of precision in the constants). After doing a + * multiplication we have to divide the product by CONST_SCALE, with proper + * rounding, to produce the correct output. This division can be done + * cheaply as a right shift of CONST_BITS bits. We postpone shifting + * as long as possible so that partial sums can be added together with + * full fractional precision. + * + * The outputs of the first pass are scaled up by PASS1_BITS bits so that + * they are represented to better-than-integral precision. These outputs + * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word + * with the recommended scaling. (To scale up 12-bit sample data further, an + * intermediate INT32 array would be needed.) + * + * To avoid overflow of the 32-bit intermediate results in pass 2, we must + * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis + * shows that the values given below are the most effective. + */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 13 +#define PASS1_BITS 2 +#else +#define CONST_BITS 13 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 13 +#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ +#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ +#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ +#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ +#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ +#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ +#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ +#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ +#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ +#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ +#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ +#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ +#else +#define FIX_0_298631336 FIX(0.298631336) +#define FIX_0_390180644 FIX(0.390180644) +#define FIX_0_541196100 FIX(0.541196100) +#define FIX_0_765366865 FIX(0.765366865) +#define FIX_0_899976223 FIX(0.899976223) +#define FIX_1_175875602 FIX(1.175875602) +#define FIX_1_501321110 FIX(1.501321110) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_1_961570560 FIX(1.961570560) +#define FIX_2_053119869 FIX(2.053119869) +#define FIX_2_562915447 FIX(2.562915447) +#define FIX_3_072711026 FIX(3.072711026) +#endif + + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * For 8-bit samples with the recommended scaling, all the variable + * and constant values involved are no more than 16 bits wide, so a + * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. + * For 12-bit samples, a full 32-bit multiplication will be needed. + */ + +#if BITS_IN_JSAMPLE == 8 +#define MULTIPLY(var,const) MULTIPLY16C16(var,const) +#else +#define MULTIPLY(var,const) ((var) * (const)) +#endif + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce an int result. In this module, both inputs and result + * are 16 bits or less, so either int or short multiply will work. + */ + +#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) + + +/* + * Perform dequantization and inverse DCT on one block of coefficients. + */ + +GLOBAL(void) +jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3; + INT32 tmp10, tmp11, tmp12, tmp13; + INT32 z1, z2, z3, z4, z5; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[DCTSIZE2]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + /* Note results are scaled up by sqrt(8) compared to a true IDCT; */ + /* furthermore, we scale the results by 2**PASS1_BITS. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; ctr--) { + /* Due to quantization, we will usually find that many of the input + * coefficients are zero, especially the AC terms. We can exploit this + * by short-circuiting the IDCT calculation for any column in which all + * the AC terms are zero. In that case each output is equal to the + * DC coefficient (with scale factor as needed). + * With typical images and quantization tables, half or more of the + * column DCT calculations can be simplified this way. + */ + + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && + inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && + inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && + inptr[DCTSIZE*7] == 0) { + /* AC terms all zero */ + int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + wsptr[DCTSIZE*4] = dcval; + wsptr[DCTSIZE*5] = dcval; + wsptr[DCTSIZE*6] = dcval; + wsptr[DCTSIZE*7] = dcval; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + continue; + } + + /* Even part: reverse the even part of the forward DCT. */ + /* The rotator is sqrt(2)*c(-6). */ + + z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); + tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); + tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); + + z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + + tmp0 = (z2 + z3) << CONST_BITS; + tmp1 = (z2 - z3) << CONST_BITS; + + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + /* Odd part per figure 8; the matrix is unitary and hence its + * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. + */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + + z1 = tmp0 + tmp3; + z2 = tmp1 + tmp2; + z3 = tmp0 + tmp2; + z4 = tmp1 + tmp3; + z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ + + tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ + tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ + tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ + tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ + z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ + z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ + z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ + z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ + + z3 += z5; + z4 += z5; + + tmp0 += z1 + z3; + tmp1 += z2 + z4; + tmp2 += z2 + z3; + tmp3 += z1 + z4; + + /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ + + wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*7] = (int) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*1] = (int) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*6] = (int) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*5] = (int) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*3] = (int) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*4] = (int) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS); + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + } + + /* Pass 2: process rows from work array, store into output array. */ + /* Note that we must descale the results by a factor of 8 == 2**3, */ + /* and also undo the PASS1_BITS scaling. */ + + wsptr = workspace; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + outptr = output_buf[ctr] + output_col; + /* Rows of zeroes can be exploited in the same way as we did with columns. + * However, the column calculation has created many nonzero AC terms, so + * the simplification applies less often (typically 5% to 10% of the time). + * On machines with very fast multiplication, it's possible that the + * test takes more time than it's worth. In that case this section + * may be commented out. + */ + +#ifndef NO_ZERO_ROW_TEST + if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && + wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { + /* AC terms all zero */ + JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) + & RANGE_MASK]; + + outptr[0] = dcval; + outptr[1] = dcval; + outptr[2] = dcval; + outptr[3] = dcval; + outptr[4] = dcval; + outptr[5] = dcval; + outptr[6] = dcval; + outptr[7] = dcval; + + wsptr += DCTSIZE; /* advance pointer to next row */ + continue; + } +#endif + + /* Even part: reverse the even part of the forward DCT. */ + /* The rotator is sqrt(2)*c(-6). */ + + z2 = (INT32) wsptr[2]; + z3 = (INT32) wsptr[6]; + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); + tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); + tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); + + tmp0 = ((INT32) wsptr[0] + (INT32) wsptr[4]) << CONST_BITS; + tmp1 = ((INT32) wsptr[0] - (INT32) wsptr[4]) << CONST_BITS; + + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + /* Odd part per figure 8; the matrix is unitary and hence its + * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. + */ + + tmp0 = (INT32) wsptr[7]; + tmp1 = (INT32) wsptr[5]; + tmp2 = (INT32) wsptr[3]; + tmp3 = (INT32) wsptr[1]; + + z1 = tmp0 + tmp3; + z2 = tmp1 + tmp2; + z3 = tmp0 + tmp2; + z4 = tmp1 + tmp3; + z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ + + tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ + tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ + tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ + tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ + z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ + z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ + z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ + z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ + + z3 += z5; + z4 += z5; + + tmp0 += z1 + z3; + tmp1 += z2 + z4; + tmp2 += z2 + z3; + tmp3 += z1 + z4; + + /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ + + outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) DESCALE(tmp10 - tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) DESCALE(tmp11 + tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) DESCALE(tmp11 - tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) DESCALE(tmp12 + tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) DESCALE(tmp12 - tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) DESCALE(tmp13 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) DESCALE(tmp13 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + +#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/jidctred.c b/src/dep/src/irrlicht/jpeglib/jidctred.c index 911899b..421f3c7 100644 --- a/src/dep/src/irrlicht/jpeglib/jidctred.c +++ b/src/dep/src/irrlicht/jpeglib/jidctred.c @@ -1,398 +1,398 @@ -/* - * jidctred.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains inverse-DCT routines that produce reduced-size output: - * either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block. - * - * The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M) - * algorithm used in jidctint.c. We simply replace each 8-to-8 1-D IDCT step - * with an 8-to-4 step that produces the four averages of two adjacent outputs - * (or an 8-to-2 step producing two averages of four outputs, for 2x2 output). - * These steps were derived by computing the corresponding values at the end - * of the normal LL&M code, then simplifying as much as possible. - * - * 1x1 is trivial: just take the DC coefficient divided by 8. - * - * See jidctint.c for additional comments. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef IDCT_SCALING_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling is the same as in jidctint.c. */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_211164243 ((INT32) 1730) /* FIX(0.211164243) */ -#define FIX_0_509795579 ((INT32) 4176) /* FIX(0.509795579) */ -#define FIX_0_601344887 ((INT32) 4926) /* FIX(0.601344887) */ -#define FIX_0_720959822 ((INT32) 5906) /* FIX(0.720959822) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_850430095 ((INT32) 6967) /* FIX(0.850430095) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_061594337 ((INT32) 8697) /* FIX(1.061594337) */ -#define FIX_1_272758580 ((INT32) 10426) /* FIX(1.272758580) */ -#define FIX_1_451774981 ((INT32) 11893) /* FIX(1.451774981) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_2_172734803 ((INT32) 17799) /* FIX(2.172734803) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_624509785 ((INT32) 29692) /* FIX(3.624509785) */ -#else -#define FIX_0_211164243 FIX(0.211164243) -#define FIX_0_509795579 FIX(0.509795579) -#define FIX_0_601344887 FIX(0.601344887) -#define FIX_0_720959822 FIX(0.720959822) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_850430095 FIX(0.850430095) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_061594337 FIX(1.061594337) -#define FIX_1_272758580 FIX(1.272758580) -#define FIX_1_451774981 FIX(1.451774981) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_2_172734803 FIX(2.172734803) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_624509785 FIX(3.624509785) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce an int result. In this module, both inputs and result - * are 16 bits or less, so either int or short multiply will work. - */ - -#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 4x4 output block. - */ - -GLOBAL(void) -jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp2, tmp10, tmp12; - INT32 z1, z2, z3, z4; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE*4]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { - /* Don't bother to process column 4, because second pass won't use it */ - if (ctr == DCTSIZE-4) - continue; - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 && - inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) { - /* AC terms all zero; we need not examine term 4 for 4x4 output */ - int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - - continue; - } - - /* Even part */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp0 <<= (CONST_BITS+1); - - z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865); - - tmp10 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - - /* Odd part */ - - z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - - tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ - + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ - + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ - + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ - - tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ - + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ - + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ - + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ - - /* Final output stage */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1); - } - - /* Pass 2: process 4 rows from work array, store into output array. */ - - wsptr = workspace; - for (ctr = 0; ctr < 4; ctr++) { - outptr = output_buf[ctr] + output_col; - /* It's not clear whether a zero row test is worthwhile here ... */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp0 = ((INT32) wsptr[0]) << (CONST_BITS+1); - - tmp2 = MULTIPLY((INT32) wsptr[2], FIX_1_847759065) - + MULTIPLY((INT32) wsptr[6], - FIX_0_765366865); - - tmp10 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - - /* Odd part */ - - z1 = (INT32) wsptr[7]; - z2 = (INT32) wsptr[5]; - z3 = (INT32) wsptr[3]; - z4 = (INT32) wsptr[1]; - - tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ - + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ - + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ - + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ - - tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ - + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ - + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ - + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ - - /* Final output stage */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 2x2 output block. - */ - -GLOBAL(void) -jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp10, z1; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE*2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { - /* Don't bother to process columns 2,4,6 */ - if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6) - continue; - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) { - /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */ - int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - - continue; - } - - /* Even part */ - - z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp10 = z1 << (CONST_BITS+2); - - /* Odd part */ - - z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */ - z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */ - z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */ - z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ - - /* Final output stage */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2); - } - - /* Pass 2: process 2 rows from work array, store into output array. */ - - wsptr = workspace; - for (ctr = 0; ctr < 2; ctr++) { - outptr = output_buf[ctr] + output_col; - /* It's not clear whether a zero row test is worthwhile here ... */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp10 = ((INT32) wsptr[0]) << (CONST_BITS+2); - - /* Odd part */ - - tmp0 = MULTIPLY((INT32) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */ - + MULTIPLY((INT32) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */ - + MULTIPLY((INT32) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */ - + MULTIPLY((INT32) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ - - /* Final output stage */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0, - CONST_BITS+PASS1_BITS+3+2) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0, - CONST_BITS+PASS1_BITS+3+2) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 1x1 output block. - */ - -GLOBAL(void) -jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - int dcval; - ISLOW_MULT_TYPE * quantptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - SHIFT_TEMPS - - /* We hardly need an inverse DCT routine for this: just take the - * average pixel value, which is one-eighth of the DC coefficient. - */ - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - dcval = DEQUANTIZE(coef_block[0], quantptr[0]); - dcval = (int) DESCALE((INT32) dcval, 3); - - output_buf[0][output_col] = range_limit[dcval & RANGE_MASK]; -} - -#endif /* IDCT_SCALING_SUPPORTED */ +/* + * jidctred.c + * + * Copyright (C) 1994-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains inverse-DCT routines that produce reduced-size output: + * either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block. + * + * The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M) + * algorithm used in jidctint.c. We simply replace each 8-to-8 1-D IDCT step + * with an 8-to-4 step that produces the four averages of two adjacent outputs + * (or an 8-to-2 step producing two averages of four outputs, for 2x2 output). + * These steps were derived by computing the corresponding values at the end + * of the normal LL&M code, then simplifying as much as possible. + * + * 1x1 is trivial: just take the DC coefficient divided by 8. + * + * See jidctint.c for additional comments. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef IDCT_SCALING_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* Scaling is the same as in jidctint.c. */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 13 +#define PASS1_BITS 2 +#else +#define CONST_BITS 13 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 13 +#define FIX_0_211164243 ((INT32) 1730) /* FIX(0.211164243) */ +#define FIX_0_509795579 ((INT32) 4176) /* FIX(0.509795579) */ +#define FIX_0_601344887 ((INT32) 4926) /* FIX(0.601344887) */ +#define FIX_0_720959822 ((INT32) 5906) /* FIX(0.720959822) */ +#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ +#define FIX_0_850430095 ((INT32) 6967) /* FIX(0.850430095) */ +#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ +#define FIX_1_061594337 ((INT32) 8697) /* FIX(1.061594337) */ +#define FIX_1_272758580 ((INT32) 10426) /* FIX(1.272758580) */ +#define FIX_1_451774981 ((INT32) 11893) /* FIX(1.451774981) */ +#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ +#define FIX_2_172734803 ((INT32) 17799) /* FIX(2.172734803) */ +#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ +#define FIX_3_624509785 ((INT32) 29692) /* FIX(3.624509785) */ +#else +#define FIX_0_211164243 FIX(0.211164243) +#define FIX_0_509795579 FIX(0.509795579) +#define FIX_0_601344887 FIX(0.601344887) +#define FIX_0_720959822 FIX(0.720959822) +#define FIX_0_765366865 FIX(0.765366865) +#define FIX_0_850430095 FIX(0.850430095) +#define FIX_0_899976223 FIX(0.899976223) +#define FIX_1_061594337 FIX(1.061594337) +#define FIX_1_272758580 FIX(1.272758580) +#define FIX_1_451774981 FIX(1.451774981) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_2_172734803 FIX(2.172734803) +#define FIX_2_562915447 FIX(2.562915447) +#define FIX_3_624509785 FIX(3.624509785) +#endif + + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * For 8-bit samples with the recommended scaling, all the variable + * and constant values involved are no more than 16 bits wide, so a + * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. + * For 12-bit samples, a full 32-bit multiplication will be needed. + */ + +#if BITS_IN_JSAMPLE == 8 +#define MULTIPLY(var,const) MULTIPLY16C16(var,const) +#else +#define MULTIPLY(var,const) ((var) * (const)) +#endif + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce an int result. In this module, both inputs and result + * are 16 bits or less, so either int or short multiply will work. + */ + +#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 4x4 output block. + */ + +GLOBAL(void) +jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp2, tmp10, tmp12; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[DCTSIZE*4]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { + /* Don't bother to process column 4, because second pass won't use it */ + if (ctr == DCTSIZE-4) + continue; + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && + inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 && + inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) { + /* AC terms all zero; we need not examine term 4 for 4x4 output */ + int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + + continue; + } + + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp0 <<= (CONST_BITS+1); + + z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865); + + tmp10 = tmp0 + tmp2; + tmp12 = tmp0 - tmp2; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + + tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ + + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ + + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ + + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ + + tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ + + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ + + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ + + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ + + /* Final output stage */ + + wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1); + wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1); + wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1); + wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1); + } + + /* Pass 2: process 4 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 4; ctr++) { + outptr = output_buf[ctr] + output_col; + /* It's not clear whether a zero row test is worthwhile here ... */ + +#ifndef NO_ZERO_ROW_TEST + if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && + wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { + /* AC terms all zero */ + JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) + & RANGE_MASK]; + + outptr[0] = dcval; + outptr[1] = dcval; + outptr[2] = dcval; + outptr[3] = dcval; + + wsptr += DCTSIZE; /* advance pointer to next row */ + continue; + } +#endif + + /* Even part */ + + tmp0 = ((INT32) wsptr[0]) << (CONST_BITS+1); + + tmp2 = MULTIPLY((INT32) wsptr[2], FIX_1_847759065) + + MULTIPLY((INT32) wsptr[6], - FIX_0_765366865); + + tmp10 = tmp0 + tmp2; + tmp12 = tmp0 - tmp2; + + /* Odd part */ + + z1 = (INT32) wsptr[7]; + z2 = (INT32) wsptr[5]; + z3 = (INT32) wsptr[3]; + z4 = (INT32) wsptr[1]; + + tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ + + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ + + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ + + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ + + tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ + + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ + + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ + + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2, + CONST_BITS+PASS1_BITS+3+1) + & RANGE_MASK]; + outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2, + CONST_BITS+PASS1_BITS+3+1) + & RANGE_MASK]; + outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0, + CONST_BITS+PASS1_BITS+3+1) + & RANGE_MASK]; + outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0, + CONST_BITS+PASS1_BITS+3+1) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 2x2 output block. + */ + +GLOBAL(void) +jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp10, z1; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[DCTSIZE*2]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { + /* Don't bother to process columns 2,4,6 */ + if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6) + continue; + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 && + inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) { + /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */ + int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + + continue; + } + + /* Even part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp10 = z1 << (CONST_BITS+2); + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */ + z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */ + z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */ + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ + + /* Final output stage */ + + wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2); + wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2); + } + + /* Pass 2: process 2 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 2; ctr++) { + outptr = output_buf[ctr] + output_col; + /* It's not clear whether a zero row test is worthwhile here ... */ + +#ifndef NO_ZERO_ROW_TEST + if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) { + /* AC terms all zero */ + JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) + & RANGE_MASK]; + + outptr[0] = dcval; + outptr[1] = dcval; + + wsptr += DCTSIZE; /* advance pointer to next row */ + continue; + } +#endif + + /* Even part */ + + tmp10 = ((INT32) wsptr[0]) << (CONST_BITS+2); + + /* Odd part */ + + tmp0 = MULTIPLY((INT32) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */ + + MULTIPLY((INT32) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */ + + MULTIPLY((INT32) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */ + + MULTIPLY((INT32) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0, + CONST_BITS+PASS1_BITS+3+2) + & RANGE_MASK]; + outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0, + CONST_BITS+PASS1_BITS+3+2) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 1x1 output block. + */ + +GLOBAL(void) +jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + int dcval; + ISLOW_MULT_TYPE * quantptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + SHIFT_TEMPS + + /* We hardly need an inverse DCT routine for this: just take the + * average pixel value, which is one-eighth of the DC coefficient. + */ + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + dcval = DEQUANTIZE(coef_block[0], quantptr[0]); + dcval = (int) DESCALE((INT32) dcval, 3); + + output_buf[0][output_col] = range_limit[dcval & RANGE_MASK]; +} + +#endif /* IDCT_SCALING_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/jinclude.h b/src/dep/src/irrlicht/jpeglib/jinclude.h index 5ff60fe..0a4f151 100644 --- a/src/dep/src/irrlicht/jpeglib/jinclude.h +++ b/src/dep/src/irrlicht/jpeglib/jinclude.h @@ -1,91 +1,91 @@ -/* - * jinclude.h - * - * Copyright (C) 1991-1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file exists to provide a single place to fix any problems with - * including the wrong system include files. (Common problems are taken - * care of by the standard jconfig symbols, but on really weird systems - * you may have to edit this file.) - * - * NOTE: this file is NOT intended to be included by applications using the - * JPEG library. Most applications need only include jpeglib.h. - */ - - -/* Include auto-config file to find out which system include files we need. */ - -#include "jconfig.h" /* auto configuration options */ -#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ - -/* - * We need the NULL macro and size_t typedef. - * On an ANSI-conforming system it is sufficient to include . - * Otherwise, we get them from or ; we may have to - * pull in as well. - * Note that the core JPEG library does not require ; - * only the default error handler and data source/destination modules do. - * But we must pull it in because of the references to FILE in jpeglib.h. - * You can remove those references if you want to compile without . - */ - -#ifdef HAVE_STDDEF_H -#include -#endif - -#ifdef HAVE_STDLIB_H -#include -#endif - -#ifdef NEED_SYS_TYPES_H -#include -#endif - -#include - -/* - * We need memory copying and zeroing functions, plus strncpy(). - * ANSI and System V implementations declare these in . - * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). - * Some systems may declare memset and memcpy in . - * - * NOTE: we assume the size parameters to these functions are of type size_t. - * Change the casts in these macros if not! - */ - -#ifdef NEED_BSD_STRINGS - -#include -#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) -#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) - -#else /* not BSD, assume ANSI/SysV string lib */ - -#include -#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) -#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) - -#endif - -/* - * In ANSI C, and indeed any rational implementation, size_t is also the - * type returned by sizeof(). However, it seems there are some irrational - * implementations out there, in which sizeof() returns an int even though - * size_t is defined as long or unsigned long. To ensure consistent results - * we always use this SIZEOF() macro in place of using sizeof() directly. - */ - -#define SIZEOF(object) ((size_t) sizeof(object)) - -/* - * The modules that use fread() and fwrite() always invoke them through - * these macros. On some systems you may need to twiddle the argument casts. - * CAUTION: argument order is different from underlying functions! - */ - -#define JFREAD(file,buf,sizeofbuf) \ - ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) -#define JFWRITE(file,buf,sizeofbuf) \ - ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) +/* + * jinclude.h + * + * Copyright (C) 1991-1994, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file exists to provide a single place to fix any problems with + * including the wrong system include files. (Common problems are taken + * care of by the standard jconfig symbols, but on really weird systems + * you may have to edit this file.) + * + * NOTE: this file is NOT intended to be included by applications using the + * JPEG library. Most applications need only include jpeglib.h. + */ + + +/* Include auto-config file to find out which system include files we need. */ + +#include "jconfig.h" /* auto configuration options */ +#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ + +/* + * We need the NULL macro and size_t typedef. + * On an ANSI-conforming system it is sufficient to include . + * Otherwise, we get them from or ; we may have to + * pull in as well. + * Note that the core JPEG library does not require ; + * only the default error handler and data source/destination modules do. + * But we must pull it in because of the references to FILE in jpeglib.h. + * You can remove those references if you want to compile without . + */ + +#ifdef HAVE_STDDEF_H +#include +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef NEED_SYS_TYPES_H +#include +#endif + +#include + +/* + * We need memory copying and zeroing functions, plus strncpy(). + * ANSI and System V implementations declare these in . + * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). + * Some systems may declare memset and memcpy in . + * + * NOTE: we assume the size parameters to these functions are of type size_t. + * Change the casts in these macros if not! + */ + +#ifdef NEED_BSD_STRINGS + +#include +#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) +#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) + +#else /* not BSD, assume ANSI/SysV string lib */ + +#include +#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) +#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) + +#endif + +/* + * In ANSI C, and indeed any rational implementation, size_t is also the + * type returned by sizeof(). However, it seems there are some irrational + * implementations out there, in which sizeof() returns an int even though + * size_t is defined as long or unsigned long. To ensure consistent results + * we always use this SIZEOF() macro in place of using sizeof() directly. + */ + +#define SIZEOF(object) ((size_t) sizeof(object)) + +/* + * The modules that use fread() and fwrite() always invoke them through + * these macros. On some systems you may need to twiddle the argument casts. + * CAUTION: argument order is different from underlying functions! + */ + +#define JFREAD(file,buf,sizeofbuf) \ + ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) +#define JFWRITE(file,buf,sizeofbuf) \ + ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) diff --git a/src/dep/src/irrlicht/jpeglib/jmemansi.c b/src/dep/src/irrlicht/jpeglib/jmemansi.c index b5da474..2d93e49 100644 --- a/src/dep/src/irrlicht/jpeglib/jmemansi.c +++ b/src/dep/src/irrlicht/jpeglib/jmemansi.c @@ -1,167 +1,167 @@ -/* - * jmemansi.c - * - * Copyright (C) 1992-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides a simple generic implementation of the system- - * dependent portion of the JPEG memory manager. This implementation - * assumes that you have the ANSI-standard library routine tmpfile(). - * Also, the problem of determining the amount of memory available - * is shoved onto the user. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -#endif - -#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ -#define SEEK_SET 0 /* if not, assume 0 is correct */ -#endif - - -/* - * Memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: although we include FAR keywords in the routine declarations, - * this file won't actually work in 80x86 small/medium model; at least, - * you probably won't be able to process useful-size images in only 64KB. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * It's impossible to do this in a portable way; our current solution is - * to make the user tell us (with a default value set at compile time). - * If you can actually get the available space, it's a good idea to subtract - * a slop factor of 5% or so. - */ - -#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ -#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ -#endif - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return cinfo->mem->max_memory_to_use - already_allocated; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - - -METHODDEF(void) -read_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFREAD(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFWRITE(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_backing_store (j_common_ptr cinfo, backing_store_ptr info) -{ - fclose(info->temp_file); - /* Since this implementation uses tmpfile() to create the file, - * no explicit file deletion is needed. - */ -} - - -/* - * Initial opening of a backing-store object. - * - * This version uses tmpfile(), which constructs a suitable file name - * behind the scenes. We don't have to use info->temp_name[] at all; - * indeed, we can't even find out the actual name of the temp file. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - if ((info->temp_file = tmpfile()) == NULL) - ERREXITS(cinfo, JERR_TFILE_CREATE, ""); - info->read_backing_store = read_backing_store; - info->write_backing_store = write_backing_store; - info->close_backing_store = close_backing_store; -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} +/* + * jmemansi.c + * + * Copyright (C) 1992-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides a simple generic implementation of the system- + * dependent portion of the JPEG memory manager. This implementation + * assumes that you have the ANSI-standard library routine tmpfile(). + * Also, the problem of determining the amount of memory available + * is shoved onto the user. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +#endif + +#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ +#define SEEK_SET 0 /* if not, assume 0 is correct */ +#endif + + +/* + * Memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: although we include FAR keywords in the routine declarations, + * this file won't actually work in 80x86 small/medium model; at least, + * you probably won't be able to process useful-size images in only 64KB. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * It's impossible to do this in a portable way; our current solution is + * to make the user tell us (with a default value set at compile time). + * If you can actually get the available space, it's a good idea to subtract + * a slop factor of 5% or so. + */ + +#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ +#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ +#endif + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return cinfo->mem->max_memory_to_use - already_allocated; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + + +METHODDEF(void) +read_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFREAD(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFWRITE(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_backing_store (j_common_ptr cinfo, backing_store_ptr info) +{ + fclose(info->temp_file); + /* Since this implementation uses tmpfile() to create the file, + * no explicit file deletion is needed. + */ +} + + +/* + * Initial opening of a backing-store object. + * + * This version uses tmpfile(), which constructs a suitable file name + * behind the scenes. We don't have to use info->temp_name[] at all; + * indeed, we can't even find out the actual name of the temp file. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + if ((info->temp_file = tmpfile()) == NULL) + ERREXITS(cinfo, JERR_TFILE_CREATE, ""); + info->read_backing_store = read_backing_store; + info->write_backing_store = write_backing_store; + info->close_backing_store = close_backing_store; +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/src/dep/src/irrlicht/jpeglib/jmemdos.c b/src/dep/src/irrlicht/jpeglib/jmemdos.c index 0955047..60b45c6 100644 --- a/src/dep/src/irrlicht/jpeglib/jmemdos.c +++ b/src/dep/src/irrlicht/jpeglib/jmemdos.c @@ -1,638 +1,638 @@ -/* - * jmemdos.c - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides an MS-DOS-compatible implementation of the system- - * dependent portion of the JPEG memory manager. Temporary data can be - * stored in extended or expanded memory as well as in regular DOS files. - * - * If you use this file, you must be sure that NEED_FAR_POINTERS is defined - * if you compile in a small-data memory model; it should NOT be defined if - * you use a large-data memory model. This file is not recommended if you - * are using a flat-memory-space 386 environment such as DJGCC or Watcom C. - * Also, this code will NOT work if struct fields are aligned on greater than - * 2-byte boundaries. - * - * Based on code contributed by Ge' Weijers. - */ - -/* - * If you have both extended and expanded memory, you may want to change the - * order in which they are tried in jopen_backing_store. On a 286 machine - * expanded memory is usually faster, since extended memory access involves - * an expensive protected-mode-and-back switch. On 386 and better, extended - * memory is usually faster. As distributed, the code tries extended memory - * first (what? not everyone has a 386? :-). - * - * You can disable use of extended/expanded memory entirely by altering these - * definitions or overriding them from the Makefile (eg, -DEMS_SUPPORTED=0). - */ - -#ifndef XMS_SUPPORTED -#define XMS_SUPPORTED 1 -#endif -#ifndef EMS_SUPPORTED -#define EMS_SUPPORTED 1 -#endif - - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* should declare these */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -extern char * getenv JPP((const char * name)); -#endif - -#ifdef NEED_FAR_POINTERS - -#ifdef __TURBOC__ -/* These definitions work for Borland C (Turbo C) */ -#include /* need farmalloc(), farfree() */ -#define far_malloc(x) farmalloc(x) -#define far_free(x) farfree(x) -#else -/* These definitions work for Microsoft C and compatible compilers */ -#include /* need _fmalloc(), _ffree() */ -#define far_malloc(x) _fmalloc(x) -#define far_free(x) _ffree(x) -#endif - -#else /* not NEED_FAR_POINTERS */ - -#define far_malloc(x) malloc(x) -#define far_free(x) free(x) - -#endif /* NEED_FAR_POINTERS */ - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#else -#define READ_BINARY "rb" -#endif - -#ifndef USE_MSDOS_MEMMGR /* make sure user got configuration right */ - You forgot to define USE_MSDOS_MEMMGR in jconfig.h. /* deliberate syntax error */ -#endif - -#if MAX_ALLOC_CHUNK >= 65535L /* make sure jconfig.h got this right */ - MAX_ALLOC_CHUNK should be less than 64K. /* deliberate syntax error */ -#endif - - -/* - * Declarations for assembly-language support routines (see jmemdosa.asm). - * - * The functions are declared "far" as are all their pointer arguments; - * this ensures the assembly source code will work regardless of the - * compiler memory model. We assume "short" is 16 bits, "long" is 32. - */ - -typedef void far * XMSDRIVER; /* actually a pointer to code */ -typedef struct { /* registers for calling XMS driver */ - unsigned short ax, dx, bx; - void far * ds_si; - } XMScontext; -typedef struct { /* registers for calling EMS driver */ - unsigned short ax, dx, bx; - void far * ds_si; - } EMScontext; - -extern short far jdos_open JPP((short far * handle, char far * filename)); -extern short far jdos_close JPP((short handle)); -extern short far jdos_seek JPP((short handle, long offset)); -extern short far jdos_read JPP((short handle, void far * buffer, - unsigned short count)); -extern short far jdos_write JPP((short handle, void far * buffer, - unsigned short count)); -extern void far jxms_getdriver JPP((XMSDRIVER far *)); -extern void far jxms_calldriver JPP((XMSDRIVER, XMScontext far *)); -extern short far jems_available JPP((void)); -extern void far jems_calldriver JPP((EMScontext far *)); - - -/* - * Selection of a file name for a temporary file. - * This is highly system-dependent, and you may want to customize it. - */ - -static int next_file_num; /* to distinguish among several temp files */ - -LOCAL(void) -select_file_name (char * fname) -{ - const char * env; - char * ptr; - FILE * tfile; - - /* Keep generating file names till we find one that's not in use */ - for (;;) { - /* Get temp directory name from environment TMP or TEMP variable; - * if none, use "." - */ - if ((env = (const char *) getenv("TMP")) == NULL) - if ((env = (const char *) getenv("TEMP")) == NULL) - env = "."; - if (*env == '\0') /* null string means "." */ - env = "."; - ptr = fname; /* copy name to fname */ - while (*env != '\0') - *ptr++ = *env++; - if (ptr[-1] != '\\' && ptr[-1] != '/') - *ptr++ = '\\'; /* append backslash if not in env variable */ - /* Append a suitable file name */ - next_file_num++; /* advance counter */ - sprintf(ptr, "JPG%03d.TMP", next_file_num); - /* Probe to see if file name is already in use */ - if ((tfile = fopen(fname, READ_BINARY)) == NULL) - break; - fclose(tfile); /* oops, it's there; close tfile & try again */ - } -} - - -/* - * Near-memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are allocated in far memory, if possible - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) far_malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - far_free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * It's impossible to do this in a portable way; our current solution is - * to make the user tell us (with a default value set at compile time). - * If you can actually get the available space, it's a good idea to subtract - * a slop factor of 5% or so. - */ - -#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ -#define DEFAULT_MAX_MEM 300000L /* for total usage about 450K */ -#endif - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return cinfo->mem->max_memory_to_use - already_allocated; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - -/* - * For MS-DOS we support three types of backing storage: - * 1. Conventional DOS files. We access these by direct DOS calls rather - * than via the stdio package. This provides a bit better performance, - * but the real reason is that the buffers to be read or written are FAR. - * The stdio library for small-data memory models can't cope with that. - * 2. Extended memory, accessed per the XMS V2.0 specification. - * 3. Expanded memory, accessed per the LIM/EMS 4.0 specification. - * You'll need copies of those specs to make sense of the related code. - * The specs are available by Internet FTP from the SIMTEL archives - * (oak.oakland.edu and its various mirror sites). See files - * pub/msdos/microsoft/xms20.arc and pub/msdos/info/limems41.zip. - */ - - -/* - * Access methods for a DOS file. - */ - - -METHODDEF(void) -read_file_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (jdos_seek(info->handle.file_handle, file_offset)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ - if (byte_count > 65535L) /* safety check */ - ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); - if (jdos_read(info->handle.file_handle, buffer_address, - (unsigned short) byte_count)) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_file_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (jdos_seek(info->handle.file_handle, file_offset)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ - if (byte_count > 65535L) /* safety check */ - ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); - if (jdos_write(info->handle.file_handle, buffer_address, - (unsigned short) byte_count)) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_file_store (j_common_ptr cinfo, backing_store_ptr info) -{ - jdos_close(info->handle.file_handle); /* close the file */ - remove(info->temp_name); /* delete the file */ -/* If your system doesn't have remove(), try unlink() instead. - * remove() is the ANSI-standard name for this function, but - * unlink() was more common in pre-ANSI systems. - */ - TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); -} - - -LOCAL(boolean) -open_file_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - short handle; - - select_file_name(info->temp_name); - if (jdos_open((short far *) & handle, (char far *) info->temp_name)) { - /* might as well exit since jpeg_open_backing_store will fail anyway */ - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - return FALSE; - } - info->handle.file_handle = handle; - info->read_backing_store = read_file_store; - info->write_backing_store = write_file_store; - info->close_backing_store = close_file_store; - TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); - return TRUE; /* succeeded */ -} - - -/* - * Access methods for extended memory. - */ - -#if XMS_SUPPORTED - -static XMSDRIVER xms_driver; /* saved address of XMS driver */ - -typedef union { /* either long offset or real-mode pointer */ - long offset; - void far * ptr; - } XMSPTR; - -typedef struct { /* XMS move specification structure */ - long length; - XMSH src_handle; - XMSPTR src; - XMSH dst_handle; - XMSPTR dst; - } XMSspec; - -#define ODD(X) (((X) & 1L) != 0) - - -METHODDEF(void) -read_xms_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - XMScontext ctx; - XMSspec spec; - char endbuffer[2]; - - /* The XMS driver can't cope with an odd length, so handle the last byte - * specially if byte_count is odd. We don't expect this to be common. - */ - - spec.length = byte_count & (~ 1L); - spec.src_handle = info->handle.xms_handle; - spec.src.offset = file_offset; - spec.dst_handle = 0; - spec.dst.ptr = buffer_address; - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x0b00; /* EMB move */ - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax != 1) - ERREXIT(cinfo, JERR_XMS_READ); - - if (ODD(byte_count)) { - read_xms_store(cinfo, info, (void FAR *) endbuffer, - file_offset + byte_count - 1L, 2L); - ((char FAR *) buffer_address)[byte_count - 1L] = endbuffer[0]; - } -} - - -METHODDEF(void) -write_xms_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - XMScontext ctx; - XMSspec spec; - char endbuffer[2]; - - /* The XMS driver can't cope with an odd length, so handle the last byte - * specially if byte_count is odd. We don't expect this to be common. - */ - - spec.length = byte_count & (~ 1L); - spec.src_handle = 0; - spec.src.ptr = buffer_address; - spec.dst_handle = info->handle.xms_handle; - spec.dst.offset = file_offset; - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x0b00; /* EMB move */ - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax != 1) - ERREXIT(cinfo, JERR_XMS_WRITE); - - if (ODD(byte_count)) { - read_xms_store(cinfo, info, (void FAR *) endbuffer, - file_offset + byte_count - 1L, 2L); - endbuffer[0] = ((char FAR *) buffer_address)[byte_count - 1L]; - write_xms_store(cinfo, info, (void FAR *) endbuffer, - file_offset + byte_count - 1L, 2L); - } -} - - -METHODDEF(void) -close_xms_store (j_common_ptr cinfo, backing_store_ptr info) -{ - XMScontext ctx; - - ctx.dx = info->handle.xms_handle; - ctx.ax = 0x0a00; - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - TRACEMS1(cinfo, 1, JTRC_XMS_CLOSE, info->handle.xms_handle); - /* we ignore any error return from the driver */ -} - - -LOCAL(boolean) -open_xms_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - XMScontext ctx; - - /* Get address of XMS driver */ - jxms_getdriver((XMSDRIVER far *) & xms_driver); - if (xms_driver == NULL) - return FALSE; /* no driver to be had */ - - /* Get version number, must be >= 2.00 */ - ctx.ax = 0x0000; - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax < (unsigned short) 0x0200) - return FALSE; - - /* Try to get space (expressed in kilobytes) */ - ctx.dx = (unsigned short) ((total_bytes_needed + 1023L) >> 10); - ctx.ax = 0x0900; - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax != 1) - return FALSE; - - /* Succeeded, save the handle and away we go */ - info->handle.xms_handle = ctx.dx; - info->read_backing_store = read_xms_store; - info->write_backing_store = write_xms_store; - info->close_backing_store = close_xms_store; - TRACEMS1(cinfo, 1, JTRC_XMS_OPEN, ctx.dx); - return TRUE; /* succeeded */ -} - -#endif /* XMS_SUPPORTED */ - - -/* - * Access methods for expanded memory. - */ - -#if EMS_SUPPORTED - -/* The EMS move specification structure requires word and long fields aligned - * at odd byte boundaries. Some compilers will align struct fields at even - * byte boundaries. While it's usually possible to force byte alignment, - * that causes an overall performance penalty and may pose problems in merging - * JPEG into a larger application. Instead we accept some rather dirty code - * here. Note this code would fail if the hardware did not allow odd-byte - * word & long accesses, but all 80x86 CPUs do. - */ - -typedef void far * EMSPTR; - -typedef union { /* EMS move specification structure */ - long length; /* It's easy to access first 4 bytes */ - char bytes[18]; /* Misaligned fields in here! */ - } EMSspec; - -/* Macros for accessing misaligned fields */ -#define FIELD_AT(spec,offset,type) (*((type *) &(spec.bytes[offset]))) -#define SRC_TYPE(spec) FIELD_AT(spec,4,char) -#define SRC_HANDLE(spec) FIELD_AT(spec,5,EMSH) -#define SRC_OFFSET(spec) FIELD_AT(spec,7,unsigned short) -#define SRC_PAGE(spec) FIELD_AT(spec,9,unsigned short) -#define SRC_PTR(spec) FIELD_AT(spec,7,EMSPTR) -#define DST_TYPE(spec) FIELD_AT(spec,11,char) -#define DST_HANDLE(spec) FIELD_AT(spec,12,EMSH) -#define DST_OFFSET(spec) FIELD_AT(spec,14,unsigned short) -#define DST_PAGE(spec) FIELD_AT(spec,16,unsigned short) -#define DST_PTR(spec) FIELD_AT(spec,14,EMSPTR) - -#define EMSPAGESIZE 16384L /* gospel, see the EMS specs */ - -#define HIBYTE(W) (((W) >> 8) & 0xFF) -#define LOBYTE(W) ((W) & 0xFF) - - -METHODDEF(void) -read_ems_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - EMScontext ctx; - EMSspec spec; - - spec.length = byte_count; - SRC_TYPE(spec) = 1; - SRC_HANDLE(spec) = info->handle.ems_handle; - SRC_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); - SRC_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); - DST_TYPE(spec) = 0; - DST_HANDLE(spec) = 0; - DST_PTR(spec) = buffer_address; - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x5700; /* move memory region */ - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - ERREXIT(cinfo, JERR_EMS_READ); -} - - -METHODDEF(void) -write_ems_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - EMScontext ctx; - EMSspec spec; - - spec.length = byte_count; - SRC_TYPE(spec) = 0; - SRC_HANDLE(spec) = 0; - SRC_PTR(spec) = buffer_address; - DST_TYPE(spec) = 1; - DST_HANDLE(spec) = info->handle.ems_handle; - DST_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); - DST_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x5700; /* move memory region */ - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - ERREXIT(cinfo, JERR_EMS_WRITE); -} - - -METHODDEF(void) -close_ems_store (j_common_ptr cinfo, backing_store_ptr info) -{ - EMScontext ctx; - - ctx.ax = 0x4500; - ctx.dx = info->handle.ems_handle; - jems_calldriver((EMScontext far *) & ctx); - TRACEMS1(cinfo, 1, JTRC_EMS_CLOSE, info->handle.ems_handle); - /* we ignore any error return from the driver */ -} - - -LOCAL(boolean) -open_ems_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - EMScontext ctx; - - /* Is EMS driver there? */ - if (! jems_available()) - return FALSE; - - /* Get status, make sure EMS is OK */ - ctx.ax = 0x4000; - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - return FALSE; - - /* Get version, must be >= 4.0 */ - ctx.ax = 0x4600; - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0 || LOBYTE(ctx.ax) < 0x40) - return FALSE; - - /* Try to allocate requested space */ - ctx.ax = 0x4300; - ctx.bx = (unsigned short) ((total_bytes_needed + EMSPAGESIZE-1L) / EMSPAGESIZE); - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - return FALSE; - - /* Succeeded, save the handle and away we go */ - info->handle.ems_handle = ctx.dx; - info->read_backing_store = read_ems_store; - info->write_backing_store = write_ems_store; - info->close_backing_store = close_ems_store; - TRACEMS1(cinfo, 1, JTRC_EMS_OPEN, ctx.dx); - return TRUE; /* succeeded */ -} - -#endif /* EMS_SUPPORTED */ - - -/* - * Initial opening of a backing-store object. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - /* Try extended memory, then expanded memory, then regular file. */ -#if XMS_SUPPORTED - if (open_xms_store(cinfo, info, total_bytes_needed)) - return; -#endif -#if EMS_SUPPORTED - if (open_ems_store(cinfo, info, total_bytes_needed)) - return; -#endif - if (open_file_store(cinfo, info, total_bytes_needed)) - return; - ERREXITS(cinfo, JERR_TFILE_CREATE, ""); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - next_file_num = 0; /* initialize temp file name generator */ - return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* Microsoft C, at least in v6.00A, will not successfully reclaim freed - * blocks of size > 32Kbytes unless we give it a kick in the rear, like so: - */ -#ifdef NEED_FHEAPMIN - _fheapmin(); -#endif -} +/* + * jmemdos.c + * + * Copyright (C) 1992-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides an MS-DOS-compatible implementation of the system- + * dependent portion of the JPEG memory manager. Temporary data can be + * stored in extended or expanded memory as well as in regular DOS files. + * + * If you use this file, you must be sure that NEED_FAR_POINTERS is defined + * if you compile in a small-data memory model; it should NOT be defined if + * you use a large-data memory model. This file is not recommended if you + * are using a flat-memory-space 386 environment such as DJGCC or Watcom C. + * Also, this code will NOT work if struct fields are aligned on greater than + * 2-byte boundaries. + * + * Based on code contributed by Ge' Weijers. + */ + +/* + * If you have both extended and expanded memory, you may want to change the + * order in which they are tried in jopen_backing_store. On a 286 machine + * expanded memory is usually faster, since extended memory access involves + * an expensive protected-mode-and-back switch. On 386 and better, extended + * memory is usually faster. As distributed, the code tries extended memory + * first (what? not everyone has a 386? :-). + * + * You can disable use of extended/expanded memory entirely by altering these + * definitions or overriding them from the Makefile (eg, -DEMS_SUPPORTED=0). + */ + +#ifndef XMS_SUPPORTED +#define XMS_SUPPORTED 1 +#endif +#ifndef EMS_SUPPORTED +#define EMS_SUPPORTED 1 +#endif + + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare these */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +extern char * getenv JPP((const char * name)); +#endif + +#ifdef NEED_FAR_POINTERS + +#ifdef __TURBOC__ +/* These definitions work for Borland C (Turbo C) */ +#include /* need farmalloc(), farfree() */ +#define far_malloc(x) farmalloc(x) +#define far_free(x) farfree(x) +#else +/* These definitions work for Microsoft C and compatible compilers */ +#include /* need _fmalloc(), _ffree() */ +#define far_malloc(x) _fmalloc(x) +#define far_free(x) _ffree(x) +#endif + +#else /* not NEED_FAR_POINTERS */ + +#define far_malloc(x) malloc(x) +#define far_free(x) free(x) + +#endif /* NEED_FAR_POINTERS */ + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#else +#define READ_BINARY "rb" +#endif + +#ifndef USE_MSDOS_MEMMGR /* make sure user got configuration right */ + You forgot to define USE_MSDOS_MEMMGR in jconfig.h. /* deliberate syntax error */ +#endif + +#if MAX_ALLOC_CHUNK >= 65535L /* make sure jconfig.h got this right */ + MAX_ALLOC_CHUNK should be less than 64K. /* deliberate syntax error */ +#endif + + +/* + * Declarations for assembly-language support routines (see jmemdosa.asm). + * + * The functions are declared "far" as are all their pointer arguments; + * this ensures the assembly source code will work regardless of the + * compiler memory model. We assume "short" is 16 bits, "long" is 32. + */ + +typedef void far * XMSDRIVER; /* actually a pointer to code */ +typedef struct { /* registers for calling XMS driver */ + unsigned short ax, dx, bx; + void far * ds_si; + } XMScontext; +typedef struct { /* registers for calling EMS driver */ + unsigned short ax, dx, bx; + void far * ds_si; + } EMScontext; + +extern short far jdos_open JPP((short far * handle, char far * filename)); +extern short far jdos_close JPP((short handle)); +extern short far jdos_seek JPP((short handle, long offset)); +extern short far jdos_read JPP((short handle, void far * buffer, + unsigned short count)); +extern short far jdos_write JPP((short handle, void far * buffer, + unsigned short count)); +extern void far jxms_getdriver JPP((XMSDRIVER far *)); +extern void far jxms_calldriver JPP((XMSDRIVER, XMScontext far *)); +extern short far jems_available JPP((void)); +extern void far jems_calldriver JPP((EMScontext far *)); + + +/* + * Selection of a file name for a temporary file. + * This is highly system-dependent, and you may want to customize it. + */ + +static int next_file_num; /* to distinguish among several temp files */ + +LOCAL(void) +select_file_name (char * fname) +{ + const char * env; + char * ptr; + FILE * tfile; + + /* Keep generating file names till we find one that's not in use */ + for (;;) { + /* Get temp directory name from environment TMP or TEMP variable; + * if none, use "." + */ + if ((env = (const char *) getenv("TMP")) == NULL) + if ((env = (const char *) getenv("TEMP")) == NULL) + env = "."; + if (*env == '\0') /* null string means "." */ + env = "."; + ptr = fname; /* copy name to fname */ + while (*env != '\0') + *ptr++ = *env++; + if (ptr[-1] != '\\' && ptr[-1] != '/') + *ptr++ = '\\'; /* append backslash if not in env variable */ + /* Append a suitable file name */ + next_file_num++; /* advance counter */ + sprintf(ptr, "JPG%03d.TMP", next_file_num); + /* Probe to see if file name is already in use */ + if ((tfile = fopen(fname, READ_BINARY)) == NULL) + break; + fclose(tfile); /* oops, it's there; close tfile & try again */ + } +} + + +/* + * Near-memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are allocated in far memory, if possible + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) far_malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + far_free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * It's impossible to do this in a portable way; our current solution is + * to make the user tell us (with a default value set at compile time). + * If you can actually get the available space, it's a good idea to subtract + * a slop factor of 5% or so. + */ + +#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ +#define DEFAULT_MAX_MEM 300000L /* for total usage about 450K */ +#endif + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return cinfo->mem->max_memory_to_use - already_allocated; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + +/* + * For MS-DOS we support three types of backing storage: + * 1. Conventional DOS files. We access these by direct DOS calls rather + * than via the stdio package. This provides a bit better performance, + * but the real reason is that the buffers to be read or written are FAR. + * The stdio library for small-data memory models can't cope with that. + * 2. Extended memory, accessed per the XMS V2.0 specification. + * 3. Expanded memory, accessed per the LIM/EMS 4.0 specification. + * You'll need copies of those specs to make sense of the related code. + * The specs are available by Internet FTP from the SIMTEL archives + * (oak.oakland.edu and its various mirror sites). See files + * pub/msdos/microsoft/xms20.arc and pub/msdos/info/limems41.zip. + */ + + +/* + * Access methods for a DOS file. + */ + + +METHODDEF(void) +read_file_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (jdos_seek(info->handle.file_handle, file_offset)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ + if (byte_count > 65535L) /* safety check */ + ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); + if (jdos_read(info->handle.file_handle, buffer_address, + (unsigned short) byte_count)) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_file_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (jdos_seek(info->handle.file_handle, file_offset)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ + if (byte_count > 65535L) /* safety check */ + ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); + if (jdos_write(info->handle.file_handle, buffer_address, + (unsigned short) byte_count)) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_file_store (j_common_ptr cinfo, backing_store_ptr info) +{ + jdos_close(info->handle.file_handle); /* close the file */ + remove(info->temp_name); /* delete the file */ +/* If your system doesn't have remove(), try unlink() instead. + * remove() is the ANSI-standard name for this function, but + * unlink() was more common in pre-ANSI systems. + */ + TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); +} + + +LOCAL(boolean) +open_file_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + short handle; + + select_file_name(info->temp_name); + if (jdos_open((short far *) & handle, (char far *) info->temp_name)) { + /* might as well exit since jpeg_open_backing_store will fail anyway */ + ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); + return FALSE; + } + info->handle.file_handle = handle; + info->read_backing_store = read_file_store; + info->write_backing_store = write_file_store; + info->close_backing_store = close_file_store; + TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); + return TRUE; /* succeeded */ +} + + +/* + * Access methods for extended memory. + */ + +#if XMS_SUPPORTED + +static XMSDRIVER xms_driver; /* saved address of XMS driver */ + +typedef union { /* either long offset or real-mode pointer */ + long offset; + void far * ptr; + } XMSPTR; + +typedef struct { /* XMS move specification structure */ + long length; + XMSH src_handle; + XMSPTR src; + XMSH dst_handle; + XMSPTR dst; + } XMSspec; + +#define ODD(X) (((X) & 1L) != 0) + + +METHODDEF(void) +read_xms_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + XMScontext ctx; + XMSspec spec; + char endbuffer[2]; + + /* The XMS driver can't cope with an odd length, so handle the last byte + * specially if byte_count is odd. We don't expect this to be common. + */ + + spec.length = byte_count & (~ 1L); + spec.src_handle = info->handle.xms_handle; + spec.src.offset = file_offset; + spec.dst_handle = 0; + spec.dst.ptr = buffer_address; + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x0b00; /* EMB move */ + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax != 1) + ERREXIT(cinfo, JERR_XMS_READ); + + if (ODD(byte_count)) { + read_xms_store(cinfo, info, (void FAR *) endbuffer, + file_offset + byte_count - 1L, 2L); + ((char FAR *) buffer_address)[byte_count - 1L] = endbuffer[0]; + } +} + + +METHODDEF(void) +write_xms_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + XMScontext ctx; + XMSspec spec; + char endbuffer[2]; + + /* The XMS driver can't cope with an odd length, so handle the last byte + * specially if byte_count is odd. We don't expect this to be common. + */ + + spec.length = byte_count & (~ 1L); + spec.src_handle = 0; + spec.src.ptr = buffer_address; + spec.dst_handle = info->handle.xms_handle; + spec.dst.offset = file_offset; + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x0b00; /* EMB move */ + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax != 1) + ERREXIT(cinfo, JERR_XMS_WRITE); + + if (ODD(byte_count)) { + read_xms_store(cinfo, info, (void FAR *) endbuffer, + file_offset + byte_count - 1L, 2L); + endbuffer[0] = ((char FAR *) buffer_address)[byte_count - 1L]; + write_xms_store(cinfo, info, (void FAR *) endbuffer, + file_offset + byte_count - 1L, 2L); + } +} + + +METHODDEF(void) +close_xms_store (j_common_ptr cinfo, backing_store_ptr info) +{ + XMScontext ctx; + + ctx.dx = info->handle.xms_handle; + ctx.ax = 0x0a00; + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + TRACEMS1(cinfo, 1, JTRC_XMS_CLOSE, info->handle.xms_handle); + /* we ignore any error return from the driver */ +} + + +LOCAL(boolean) +open_xms_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + XMScontext ctx; + + /* Get address of XMS driver */ + jxms_getdriver((XMSDRIVER far *) & xms_driver); + if (xms_driver == NULL) + return FALSE; /* no driver to be had */ + + /* Get version number, must be >= 2.00 */ + ctx.ax = 0x0000; + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax < (unsigned short) 0x0200) + return FALSE; + + /* Try to get space (expressed in kilobytes) */ + ctx.dx = (unsigned short) ((total_bytes_needed + 1023L) >> 10); + ctx.ax = 0x0900; + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax != 1) + return FALSE; + + /* Succeeded, save the handle and away we go */ + info->handle.xms_handle = ctx.dx; + info->read_backing_store = read_xms_store; + info->write_backing_store = write_xms_store; + info->close_backing_store = close_xms_store; + TRACEMS1(cinfo, 1, JTRC_XMS_OPEN, ctx.dx); + return TRUE; /* succeeded */ +} + +#endif /* XMS_SUPPORTED */ + + +/* + * Access methods for expanded memory. + */ + +#if EMS_SUPPORTED + +/* The EMS move specification structure requires word and long fields aligned + * at odd byte boundaries. Some compilers will align struct fields at even + * byte boundaries. While it's usually possible to force byte alignment, + * that causes an overall performance penalty and may pose problems in merging + * JPEG into a larger application. Instead we accept some rather dirty code + * here. Note this code would fail if the hardware did not allow odd-byte + * word & long accesses, but all 80x86 CPUs do. + */ + +typedef void far * EMSPTR; + +typedef union { /* EMS move specification structure */ + long length; /* It's easy to access first 4 bytes */ + char bytes[18]; /* Misaligned fields in here! */ + } EMSspec; + +/* Macros for accessing misaligned fields */ +#define FIELD_AT(spec,offset,type) (*((type *) &(spec.bytes[offset]))) +#define SRC_TYPE(spec) FIELD_AT(spec,4,char) +#define SRC_HANDLE(spec) FIELD_AT(spec,5,EMSH) +#define SRC_OFFSET(spec) FIELD_AT(spec,7,unsigned short) +#define SRC_PAGE(spec) FIELD_AT(spec,9,unsigned short) +#define SRC_PTR(spec) FIELD_AT(spec,7,EMSPTR) +#define DST_TYPE(spec) FIELD_AT(spec,11,char) +#define DST_HANDLE(spec) FIELD_AT(spec,12,EMSH) +#define DST_OFFSET(spec) FIELD_AT(spec,14,unsigned short) +#define DST_PAGE(spec) FIELD_AT(spec,16,unsigned short) +#define DST_PTR(spec) FIELD_AT(spec,14,EMSPTR) + +#define EMSPAGESIZE 16384L /* gospel, see the EMS specs */ + +#define HIBYTE(W) (((W) >> 8) & 0xFF) +#define LOBYTE(W) ((W) & 0xFF) + + +METHODDEF(void) +read_ems_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + EMScontext ctx; + EMSspec spec; + + spec.length = byte_count; + SRC_TYPE(spec) = 1; + SRC_HANDLE(spec) = info->handle.ems_handle; + SRC_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); + SRC_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); + DST_TYPE(spec) = 0; + DST_HANDLE(spec) = 0; + DST_PTR(spec) = buffer_address; + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x5700; /* move memory region */ + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + ERREXIT(cinfo, JERR_EMS_READ); +} + + +METHODDEF(void) +write_ems_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + EMScontext ctx; + EMSspec spec; + + spec.length = byte_count; + SRC_TYPE(spec) = 0; + SRC_HANDLE(spec) = 0; + SRC_PTR(spec) = buffer_address; + DST_TYPE(spec) = 1; + DST_HANDLE(spec) = info->handle.ems_handle; + DST_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); + DST_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x5700; /* move memory region */ + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + ERREXIT(cinfo, JERR_EMS_WRITE); +} + + +METHODDEF(void) +close_ems_store (j_common_ptr cinfo, backing_store_ptr info) +{ + EMScontext ctx; + + ctx.ax = 0x4500; + ctx.dx = info->handle.ems_handle; + jems_calldriver((EMScontext far *) & ctx); + TRACEMS1(cinfo, 1, JTRC_EMS_CLOSE, info->handle.ems_handle); + /* we ignore any error return from the driver */ +} + + +LOCAL(boolean) +open_ems_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + EMScontext ctx; + + /* Is EMS driver there? */ + if (! jems_available()) + return FALSE; + + /* Get status, make sure EMS is OK */ + ctx.ax = 0x4000; + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + return FALSE; + + /* Get version, must be >= 4.0 */ + ctx.ax = 0x4600; + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0 || LOBYTE(ctx.ax) < 0x40) + return FALSE; + + /* Try to allocate requested space */ + ctx.ax = 0x4300; + ctx.bx = (unsigned short) ((total_bytes_needed + EMSPAGESIZE-1L) / EMSPAGESIZE); + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + return FALSE; + + /* Succeeded, save the handle and away we go */ + info->handle.ems_handle = ctx.dx; + info->read_backing_store = read_ems_store; + info->write_backing_store = write_ems_store; + info->close_backing_store = close_ems_store; + TRACEMS1(cinfo, 1, JTRC_EMS_OPEN, ctx.dx); + return TRUE; /* succeeded */ +} + +#endif /* EMS_SUPPORTED */ + + +/* + * Initial opening of a backing-store object. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + /* Try extended memory, then expanded memory, then regular file. */ +#if XMS_SUPPORTED + if (open_xms_store(cinfo, info, total_bytes_needed)) + return; +#endif +#if EMS_SUPPORTED + if (open_ems_store(cinfo, info, total_bytes_needed)) + return; +#endif + if (open_file_store(cinfo, info, total_bytes_needed)) + return; + ERREXITS(cinfo, JERR_TFILE_CREATE, ""); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + next_file_num = 0; /* initialize temp file name generator */ + return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* Microsoft C, at least in v6.00A, will not successfully reclaim freed + * blocks of size > 32Kbytes unless we give it a kick in the rear, like so: + */ +#ifdef NEED_FHEAPMIN + _fheapmin(); +#endif +} diff --git a/src/dep/src/irrlicht/jpeglib/jmemdosa.asm b/src/dep/src/irrlicht/jpeglib/jmemdosa.asm index c6ec48b..ecd4372 100644 --- a/src/dep/src/irrlicht/jpeglib/jmemdosa.asm +++ b/src/dep/src/irrlicht/jpeglib/jmemdosa.asm @@ -1,379 +1,379 @@ -; -; jmemdosa.asm -; -; Copyright (C) 1992, Thomas G. Lane. -; This file is part of the Independent JPEG Group's software. -; For conditions of distribution and use, see the accompanying README file. -; -; This file contains low-level interface routines to support the MS-DOS -; backing store manager (jmemdos.c). Routines are provided to access disk -; files through direct DOS calls, and to access XMS and EMS drivers. -; -; This file should assemble with Microsoft's MASM or any compatible -; assembler (including Borland's Turbo Assembler). If you haven't got -; a compatible assembler, better fall back to jmemansi.c or jmemname.c. -; -; To minimize dependence on the C compiler's register usage conventions, -; we save and restore all 8086 registers, even though most compilers only -; require SI,DI,DS to be preserved. Also, we use only 16-bit-wide return -; values, which everybody returns in AX. -; -; Based on code contributed by Ge' Weijers. -; - -JMEMDOSA_TXT segment byte public 'CODE' - - assume cs:JMEMDOSA_TXT - - public _jdos_open - public _jdos_close - public _jdos_seek - public _jdos_read - public _jdos_write - public _jxms_getdriver - public _jxms_calldriver - public _jems_available - public _jems_calldriver - -; -; short far jdos_open (short far * handle, char far * filename) -; -; Create and open a temporary file -; -_jdos_open proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov cx,0 ; normal file attributes - lds dx,dword ptr [bp+10] ; get filename pointer - mov ah,3ch ; create file - int 21h - jc open_err ; if failed, return error code - lds bx,dword ptr [bp+6] ; get handle pointer - mov word ptr [bx],ax ; save the handle - xor ax,ax ; return zero for OK -open_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_open endp - - -; -; short far jdos_close (short handle) -; -; Close the file handle -; -_jdos_close proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov bx,word ptr [bp+6] ; file handle - mov ah,3eh ; close file - int 21h - jc close_err ; if failed, return error code - xor ax,ax ; return zero for OK -close_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_close endp - - -; -; short far jdos_seek (short handle, long offset) -; -; Set file position -; -_jdos_seek proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov bx,word ptr [bp+6] ; file handle - mov dx,word ptr [bp+8] ; LS offset - mov cx,word ptr [bp+10] ; MS offset - mov ax,4200h ; absolute seek - int 21h - jc seek_err ; if failed, return error code - xor ax,ax ; return zero for OK -seek_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_seek endp - - -; -; short far jdos_read (short handle, void far * buffer, unsigned short count) -; -; Read from file -; -_jdos_read proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov bx,word ptr [bp+6] ; file handle - lds dx,dword ptr [bp+8] ; buffer address - mov cx,word ptr [bp+12] ; number of bytes - mov ah,3fh ; read file - int 21h - jc read_err ; if failed, return error code - cmp ax,word ptr [bp+12] ; make sure all bytes were read - je read_ok - mov ax,1 ; else return 1 for not OK - jmp short read_err -read_ok: xor ax,ax ; return zero for OK -read_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_read endp - - -; -; short far jdos_write (short handle, void far * buffer, unsigned short count) -; -; Write to file -; -_jdos_write proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov bx,word ptr [bp+6] ; file handle - lds dx,dword ptr [bp+8] ; buffer address - mov cx,word ptr [bp+12] ; number of bytes - mov ah,40h ; write file - int 21h - jc write_err ; if failed, return error code - cmp ax,word ptr [bp+12] ; make sure all bytes written - je write_ok - mov ax,1 ; else return 1 for not OK - jmp short write_err -write_ok: xor ax,ax ; return zero for OK -write_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_write endp - - -; -; void far jxms_getdriver (XMSDRIVER far *) -; -; Get the address of the XMS driver, or NULL if not available -; -_jxms_getdriver proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov ax,4300h ; call multiplex interrupt with - int 2fh ; a magic cookie, hex 4300 - cmp al,80h ; AL should contain hex 80 - je xmsavail - xor dx,dx ; no XMS driver available - xor ax,ax ; return a nil pointer - jmp short xmsavail_done -xmsavail: mov ax,4310h ; fetch driver address with - int 2fh ; another magic cookie - mov dx,es ; copy address to dx:ax - mov ax,bx -xmsavail_done: les bx,dword ptr [bp+6] ; get pointer to return value - mov word ptr es:[bx],ax - mov word ptr es:[bx+2],dx - pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jxms_getdriver endp - - -; -; void far jxms_calldriver (XMSDRIVER, XMScontext far *) -; -; The XMScontext structure contains values for the AX,DX,BX,SI,DS registers. -; These are loaded, the XMS call is performed, and the new values of the -; AX,DX,BX registers are written back to the context structure. -; -_jxms_calldriver proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - les bx,dword ptr [bp+10] ; get XMScontext pointer - mov ax,word ptr es:[bx] ; load registers - mov dx,word ptr es:[bx+2] - mov si,word ptr es:[bx+6] - mov ds,word ptr es:[bx+8] - mov bx,word ptr es:[bx+4] - call dword ptr [bp+6] ; call the driver - mov cx,bx ; save returned BX for a sec - les bx,dword ptr [bp+10] ; get XMScontext pointer - mov word ptr es:[bx],ax ; put back ax,dx,bx - mov word ptr es:[bx+2],dx - mov word ptr es:[bx+4],cx - pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jxms_calldriver endp - - -; -; short far jems_available (void) -; -; Have we got an EMS driver? (this comes straight from the EMS 4.0 specs) -; -_jems_available proc far - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov ax,3567h ; get interrupt vector 67h - int 21h - push cs - pop ds - mov di,000ah ; check offs 10 in returned seg - lea si,ASCII_device_name ; against literal string - mov cx,8 - cld - repe cmpsb - jne no_ems - mov ax,1 ; match, it's there - jmp short avail_done -no_ems: xor ax,ax ; it's not there -avail_done: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - ret - -ASCII_device_name db "EMMXXXX0" - -_jems_available endp - - -; -; void far jems_calldriver (EMScontext far *) -; -; The EMScontext structure contains values for the AX,DX,BX,SI,DS registers. -; These are loaded, the EMS trap is performed, and the new values of the -; AX,DX,BX registers are written back to the context structure. -; -_jems_calldriver proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - les bx,dword ptr [bp+6] ; get EMScontext pointer - mov ax,word ptr es:[bx] ; load registers - mov dx,word ptr es:[bx+2] - mov si,word ptr es:[bx+6] - mov ds,word ptr es:[bx+8] - mov bx,word ptr es:[bx+4] - int 67h ; call the EMS driver - mov cx,bx ; save returned BX for a sec - les bx,dword ptr [bp+6] ; get EMScontext pointer - mov word ptr es:[bx],ax ; put back ax,dx,bx - mov word ptr es:[bx+2],dx - mov word ptr es:[bx+4],cx - pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jems_calldriver endp - -JMEMDOSA_TXT ends - - end +; +; jmemdosa.asm +; +; Copyright (C) 1992, Thomas G. Lane. +; This file is part of the Independent JPEG Group's software. +; For conditions of distribution and use, see the accompanying README file. +; +; This file contains low-level interface routines to support the MS-DOS +; backing store manager (jmemdos.c). Routines are provided to access disk +; files through direct DOS calls, and to access XMS and EMS drivers. +; +; This file should assemble with Microsoft's MASM or any compatible +; assembler (including Borland's Turbo Assembler). If you haven't got +; a compatible assembler, better fall back to jmemansi.c or jmemname.c. +; +; To minimize dependence on the C compiler's register usage conventions, +; we save and restore all 8086 registers, even though most compilers only +; require SI,DI,DS to be preserved. Also, we use only 16-bit-wide return +; values, which everybody returns in AX. +; +; Based on code contributed by Ge' Weijers. +; + +JMEMDOSA_TXT segment byte public 'CODE' + + assume cs:JMEMDOSA_TXT + + public _jdos_open + public _jdos_close + public _jdos_seek + public _jdos_read + public _jdos_write + public _jxms_getdriver + public _jxms_calldriver + public _jems_available + public _jems_calldriver + +; +; short far jdos_open (short far * handle, char far * filename) +; +; Create and open a temporary file +; +_jdos_open proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov cx,0 ; normal file attributes + lds dx,dword ptr [bp+10] ; get filename pointer + mov ah,3ch ; create file + int 21h + jc open_err ; if failed, return error code + lds bx,dword ptr [bp+6] ; get handle pointer + mov word ptr [bx],ax ; save the handle + xor ax,ax ; return zero for OK +open_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_open endp + + +; +; short far jdos_close (short handle) +; +; Close the file handle +; +_jdos_close proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov bx,word ptr [bp+6] ; file handle + mov ah,3eh ; close file + int 21h + jc close_err ; if failed, return error code + xor ax,ax ; return zero for OK +close_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_close endp + + +; +; short far jdos_seek (short handle, long offset) +; +; Set file position +; +_jdos_seek proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov bx,word ptr [bp+6] ; file handle + mov dx,word ptr [bp+8] ; LS offset + mov cx,word ptr [bp+10] ; MS offset + mov ax,4200h ; absolute seek + int 21h + jc seek_err ; if failed, return error code + xor ax,ax ; return zero for OK +seek_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_seek endp + + +; +; short far jdos_read (short handle, void far * buffer, unsigned short count) +; +; Read from file +; +_jdos_read proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov bx,word ptr [bp+6] ; file handle + lds dx,dword ptr [bp+8] ; buffer address + mov cx,word ptr [bp+12] ; number of bytes + mov ah,3fh ; read file + int 21h + jc read_err ; if failed, return error code + cmp ax,word ptr [bp+12] ; make sure all bytes were read + je read_ok + mov ax,1 ; else return 1 for not OK + jmp short read_err +read_ok: xor ax,ax ; return zero for OK +read_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_read endp + + +; +; short far jdos_write (short handle, void far * buffer, unsigned short count) +; +; Write to file +; +_jdos_write proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov bx,word ptr [bp+6] ; file handle + lds dx,dword ptr [bp+8] ; buffer address + mov cx,word ptr [bp+12] ; number of bytes + mov ah,40h ; write file + int 21h + jc write_err ; if failed, return error code + cmp ax,word ptr [bp+12] ; make sure all bytes written + je write_ok + mov ax,1 ; else return 1 for not OK + jmp short write_err +write_ok: xor ax,ax ; return zero for OK +write_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_write endp + + +; +; void far jxms_getdriver (XMSDRIVER far *) +; +; Get the address of the XMS driver, or NULL if not available +; +_jxms_getdriver proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov ax,4300h ; call multiplex interrupt with + int 2fh ; a magic cookie, hex 4300 + cmp al,80h ; AL should contain hex 80 + je xmsavail + xor dx,dx ; no XMS driver available + xor ax,ax ; return a nil pointer + jmp short xmsavail_done +xmsavail: mov ax,4310h ; fetch driver address with + int 2fh ; another magic cookie + mov dx,es ; copy address to dx:ax + mov ax,bx +xmsavail_done: les bx,dword ptr [bp+6] ; get pointer to return value + mov word ptr es:[bx],ax + mov word ptr es:[bx+2],dx + pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jxms_getdriver endp + + +; +; void far jxms_calldriver (XMSDRIVER, XMScontext far *) +; +; The XMScontext structure contains values for the AX,DX,BX,SI,DS registers. +; These are loaded, the XMS call is performed, and the new values of the +; AX,DX,BX registers are written back to the context structure. +; +_jxms_calldriver proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + les bx,dword ptr [bp+10] ; get XMScontext pointer + mov ax,word ptr es:[bx] ; load registers + mov dx,word ptr es:[bx+2] + mov si,word ptr es:[bx+6] + mov ds,word ptr es:[bx+8] + mov bx,word ptr es:[bx+4] + call dword ptr [bp+6] ; call the driver + mov cx,bx ; save returned BX for a sec + les bx,dword ptr [bp+10] ; get XMScontext pointer + mov word ptr es:[bx],ax ; put back ax,dx,bx + mov word ptr es:[bx+2],dx + mov word ptr es:[bx+4],cx + pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jxms_calldriver endp + + +; +; short far jems_available (void) +; +; Have we got an EMS driver? (this comes straight from the EMS 4.0 specs) +; +_jems_available proc far + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov ax,3567h ; get interrupt vector 67h + int 21h + push cs + pop ds + mov di,000ah ; check offs 10 in returned seg + lea si,ASCII_device_name ; against literal string + mov cx,8 + cld + repe cmpsb + jne no_ems + mov ax,1 ; match, it's there + jmp short avail_done +no_ems: xor ax,ax ; it's not there +avail_done: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + ret + +ASCII_device_name db "EMMXXXX0" + +_jems_available endp + + +; +; void far jems_calldriver (EMScontext far *) +; +; The EMScontext structure contains values for the AX,DX,BX,SI,DS registers. +; These are loaded, the EMS trap is performed, and the new values of the +; AX,DX,BX registers are written back to the context structure. +; +_jems_calldriver proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + les bx,dword ptr [bp+6] ; get EMScontext pointer + mov ax,word ptr es:[bx] ; load registers + mov dx,word ptr es:[bx+2] + mov si,word ptr es:[bx+6] + mov ds,word ptr es:[bx+8] + mov bx,word ptr es:[bx+4] + int 67h ; call the EMS driver + mov cx,bx ; save returned BX for a sec + les bx,dword ptr [bp+6] ; get EMScontext pointer + mov word ptr es:[bx],ax ; put back ax,dx,bx + mov word ptr es:[bx+2],dx + mov word ptr es:[bx+4],cx + pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jems_calldriver endp + +JMEMDOSA_TXT ends + + end diff --git a/src/dep/src/irrlicht/jpeglib/jmemmac.c b/src/dep/src/irrlicht/jpeglib/jmemmac.c index a6f043e..106f9be 100644 --- a/src/dep/src/irrlicht/jpeglib/jmemmac.c +++ b/src/dep/src/irrlicht/jpeglib/jmemmac.c @@ -1,289 +1,289 @@ -/* - * jmemmac.c - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * jmemmac.c provides an Apple Macintosh implementation of the system- - * dependent portion of the JPEG memory manager. - * - * If you use jmemmac.c, then you must define USE_MAC_MEMMGR in the - * JPEG_INTERNALS part of jconfig.h. - * - * jmemmac.c uses the Macintosh toolbox routines NewPtr and DisposePtr - * instead of malloc and free. It accurately determines the amount of - * memory available by using CompactMem. Notice that if left to its - * own devices, this code can chew up all available space in the - * application's zone, with the exception of the rather small "slop" - * factor computed in jpeg_mem_available(). The application can ensure - * that more space is left over by reducing max_memory_to_use. - * - * Large images are swapped to disk using temporary files and System 7.0+'s - * temporary folder functionality. - * - * Note that jmemmac.c depends on two features of MacOS that were first - * introduced in System 7: FindFolder and the FSSpec-based calls. - * If your application uses jmemmac.c and is run under System 6 or earlier, - * and the jpeg library decides it needs a temporary file, it will abort, - * printing error messages about requiring System 7. (If no temporary files - * are created, it will run fine.) - * - * If you want to use jmemmac.c in an application that might be used with - * System 6 or earlier, then you should remove dependencies on FindFolder - * and the FSSpec calls. You will need to replace FindFolder with some - * other mechanism for finding a place to put temporary files, and you - * should replace the FSSpec calls with their HFS equivalents: - * - * FSpDelete -> HDelete - * FSpGetFInfo -> HGetFInfo - * FSpCreate -> HCreate - * FSpOpenDF -> HOpen *** Note: not HOpenDF *** - * FSMakeFSSpec -> (fill in spec by hand.) - * - * (Use HOpen instead of HOpenDF. HOpen is just a glue-interface to PBHOpen, - * which is on all HFS macs. HOpenDF is a System 7 addition which avoids the - * ages-old problem of names starting with a period.) - * - * Contributed by Sam Bushell (jsam@iagu.on.net) and - * Dan Gildor (gyld@in-touch.com). - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef USE_MAC_MEMMGR /* make sure user got configuration right */ - You forgot to define USE_MAC_MEMMGR in jconfig.h. /* deliberate syntax error */ -#endif - -#include /* we use the MacOS memory manager */ -#include /* we use the MacOS File stuff */ -#include /* we use the MacOS HFS stuff */ -#include /* for smSystemScript */ -#include /* we use Gestalt to test for specific functionality */ - -#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ -#define TEMP_FILE_NAME "JPG%03d.TMP" -#endif - -static int next_file_num; /* to distinguish among several temp files */ - - -/* - * Memory allocation and freeing are controlled by the MacOS library - * routines NewPtr() and DisposePtr(), which allocate fixed-address - * storage. Unfortunately, the IJG library isn't smart enough to cope - * with relocatable storage. - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) NewPtr(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - DisposePtr((Ptr) object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: we include FAR keywords in the routine declarations simply for - * consistency with the rest of the IJG code; FAR should expand to empty - * on rational architectures like the Mac. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) NewPtr(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - DisposePtr((Ptr) object); -} - - -/* - * This routine computes the total memory space available for allocation. - */ - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - long limit = cinfo->mem->max_memory_to_use - already_allocated; - long slop, mem; - - /* Don't ask for more than what application has told us we may use */ - if (max_bytes_needed > limit && limit > 0) - max_bytes_needed = limit; - /* Find whether there's a big enough free block in the heap. - * CompactMem tries to create a contiguous block of the requested size, - * and then returns the size of the largest free block (which could be - * much more or much less than we asked for). - * We add some slop to ensure we don't use up all available memory. - */ - slop = max_bytes_needed / 16 + 32768L; - mem = CompactMem(max_bytes_needed + slop) - slop; - if (mem < 0) - mem = 0; /* sigh, couldn't even get the slop */ - /* Don't take more than the application says we can have */ - if (mem > limit && limit > 0) - mem = limit; - return mem; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - - -METHODDEF(void) -read_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - long bytes = byte_count; - long retVal; - - if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr ) - ERREXIT(cinfo, JERR_TFILE_SEEK); - - retVal = FSRead ( info->temp_file, &bytes, - (unsigned char *) buffer_address ); - if ( retVal != noErr || bytes != byte_count ) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - long bytes = byte_count; - long retVal; - - if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr ) - ERREXIT(cinfo, JERR_TFILE_SEEK); - - retVal = FSWrite ( info->temp_file, &bytes, - (unsigned char *) buffer_address ); - if ( retVal != noErr || bytes != byte_count ) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_backing_store (j_common_ptr cinfo, backing_store_ptr info) -{ - FSClose ( info->temp_file ); - FSpDelete ( &(info->tempSpec) ); -} - - -/* - * Initial opening of a backing-store object. - * - * This version uses FindFolder to find the Temporary Items folder, - * and puts the temporary file in there. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - short tmpRef, vRefNum; - long dirID; - FInfo finderInfo; - FSSpec theSpec; - Str255 fName; - OSErr osErr; - long gestaltResponse = 0; - - /* Check that FSSpec calls are available. */ - osErr = Gestalt( gestaltFSAttr, &gestaltResponse ); - if ( ( osErr != noErr ) - || !( gestaltResponse & (1<temp_name, TEMP_FILE_NAME, next_file_num); - strcpy ( (Ptr)fName+1, info->temp_name ); - *fName = strlen (info->temp_name); - osErr = FSMakeFSSpec ( vRefNum, dirID, fName, &theSpec ); - - if ( (osErr = FSpGetFInfo ( &theSpec, &finderInfo ) ) != noErr ) - break; - } - - osErr = FSpCreate ( &theSpec, '????', '????', smSystemScript ); - if ( osErr != noErr ) - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - - osErr = FSpOpenDF ( &theSpec, fsRdWrPerm, &(info->temp_file) ); - if ( osErr != noErr ) - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - - info->tempSpec = theSpec; - - info->read_backing_store = read_backing_store; - info->write_backing_store = write_backing_store; - info->close_backing_store = close_backing_store; - TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - next_file_num = 0; - - /* max_memory_to_use will be initialized to FreeMem()'s result; - * the calling application might later reduce it, for example - * to leave room to invoke multiple JPEG objects. - * Note that FreeMem returns the total number of free bytes; - * it may not be possible to allocate a single block of this size. - */ - return FreeMem(); -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} +/* + * jmemmac.c + * + * Copyright (C) 1992-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * jmemmac.c provides an Apple Macintosh implementation of the system- + * dependent portion of the JPEG memory manager. + * + * If you use jmemmac.c, then you must define USE_MAC_MEMMGR in the + * JPEG_INTERNALS part of jconfig.h. + * + * jmemmac.c uses the Macintosh toolbox routines NewPtr and DisposePtr + * instead of malloc and free. It accurately determines the amount of + * memory available by using CompactMem. Notice that if left to its + * own devices, this code can chew up all available space in the + * application's zone, with the exception of the rather small "slop" + * factor computed in jpeg_mem_available(). The application can ensure + * that more space is left over by reducing max_memory_to_use. + * + * Large images are swapped to disk using temporary files and System 7.0+'s + * temporary folder functionality. + * + * Note that jmemmac.c depends on two features of MacOS that were first + * introduced in System 7: FindFolder and the FSSpec-based calls. + * If your application uses jmemmac.c and is run under System 6 or earlier, + * and the jpeg library decides it needs a temporary file, it will abort, + * printing error messages about requiring System 7. (If no temporary files + * are created, it will run fine.) + * + * If you want to use jmemmac.c in an application that might be used with + * System 6 or earlier, then you should remove dependencies on FindFolder + * and the FSSpec calls. You will need to replace FindFolder with some + * other mechanism for finding a place to put temporary files, and you + * should replace the FSSpec calls with their HFS equivalents: + * + * FSpDelete -> HDelete + * FSpGetFInfo -> HGetFInfo + * FSpCreate -> HCreate + * FSpOpenDF -> HOpen *** Note: not HOpenDF *** + * FSMakeFSSpec -> (fill in spec by hand.) + * + * (Use HOpen instead of HOpenDF. HOpen is just a glue-interface to PBHOpen, + * which is on all HFS macs. HOpenDF is a System 7 addition which avoids the + * ages-old problem of names starting with a period.) + * + * Contributed by Sam Bushell (jsam@iagu.on.net) and + * Dan Gildor (gyld@in-touch.com). + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef USE_MAC_MEMMGR /* make sure user got configuration right */ + You forgot to define USE_MAC_MEMMGR in jconfig.h. /* deliberate syntax error */ +#endif + +#include /* we use the MacOS memory manager */ +#include /* we use the MacOS File stuff */ +#include /* we use the MacOS HFS stuff */ +#include /* for smSystemScript */ +#include /* we use Gestalt to test for specific functionality */ + +#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ +#define TEMP_FILE_NAME "JPG%03d.TMP" +#endif + +static int next_file_num; /* to distinguish among several temp files */ + + +/* + * Memory allocation and freeing are controlled by the MacOS library + * routines NewPtr() and DisposePtr(), which allocate fixed-address + * storage. Unfortunately, the IJG library isn't smart enough to cope + * with relocatable storage. + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) NewPtr(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + DisposePtr((Ptr) object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: we include FAR keywords in the routine declarations simply for + * consistency with the rest of the IJG code; FAR should expand to empty + * on rational architectures like the Mac. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) NewPtr(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + DisposePtr((Ptr) object); +} + + +/* + * This routine computes the total memory space available for allocation. + */ + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + long limit = cinfo->mem->max_memory_to_use - already_allocated; + long slop, mem; + + /* Don't ask for more than what application has told us we may use */ + if (max_bytes_needed > limit && limit > 0) + max_bytes_needed = limit; + /* Find whether there's a big enough free block in the heap. + * CompactMem tries to create a contiguous block of the requested size, + * and then returns the size of the largest free block (which could be + * much more or much less than we asked for). + * We add some slop to ensure we don't use up all available memory. + */ + slop = max_bytes_needed / 16 + 32768L; + mem = CompactMem(max_bytes_needed + slop) - slop; + if (mem < 0) + mem = 0; /* sigh, couldn't even get the slop */ + /* Don't take more than the application says we can have */ + if (mem > limit && limit > 0) + mem = limit; + return mem; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + + +METHODDEF(void) +read_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + long bytes = byte_count; + long retVal; + + if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr ) + ERREXIT(cinfo, JERR_TFILE_SEEK); + + retVal = FSRead ( info->temp_file, &bytes, + (unsigned char *) buffer_address ); + if ( retVal != noErr || bytes != byte_count ) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + long bytes = byte_count; + long retVal; + + if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr ) + ERREXIT(cinfo, JERR_TFILE_SEEK); + + retVal = FSWrite ( info->temp_file, &bytes, + (unsigned char *) buffer_address ); + if ( retVal != noErr || bytes != byte_count ) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_backing_store (j_common_ptr cinfo, backing_store_ptr info) +{ + FSClose ( info->temp_file ); + FSpDelete ( &(info->tempSpec) ); +} + + +/* + * Initial opening of a backing-store object. + * + * This version uses FindFolder to find the Temporary Items folder, + * and puts the temporary file in there. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + short tmpRef, vRefNum; + long dirID; + FInfo finderInfo; + FSSpec theSpec; + Str255 fName; + OSErr osErr; + long gestaltResponse = 0; + + /* Check that FSSpec calls are available. */ + osErr = Gestalt( gestaltFSAttr, &gestaltResponse ); + if ( ( osErr != noErr ) + || !( gestaltResponse & (1<temp_name, TEMP_FILE_NAME, next_file_num); + strcpy ( (Ptr)fName+1, info->temp_name ); + *fName = strlen (info->temp_name); + osErr = FSMakeFSSpec ( vRefNum, dirID, fName, &theSpec ); + + if ( (osErr = FSpGetFInfo ( &theSpec, &finderInfo ) ) != noErr ) + break; + } + + osErr = FSpCreate ( &theSpec, '????', '????', smSystemScript ); + if ( osErr != noErr ) + ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); + + osErr = FSpOpenDF ( &theSpec, fsRdWrPerm, &(info->temp_file) ); + if ( osErr != noErr ) + ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); + + info->tempSpec = theSpec; + + info->read_backing_store = read_backing_store; + info->write_backing_store = write_backing_store; + info->close_backing_store = close_backing_store; + TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + next_file_num = 0; + + /* max_memory_to_use will be initialized to FreeMem()'s result; + * the calling application might later reduce it, for example + * to leave room to invoke multiple JPEG objects. + * Note that FreeMem returns the total number of free bytes; + * it may not be possible to allocate a single block of this size. + */ + return FreeMem(); +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/src/dep/src/irrlicht/jpeglib/jmemmgr.c b/src/dep/src/irrlicht/jpeglib/jmemmgr.c index b636f1b..d801b32 100644 --- a/src/dep/src/irrlicht/jpeglib/jmemmgr.c +++ b/src/dep/src/irrlicht/jpeglib/jmemmgr.c @@ -1,1118 +1,1118 @@ -/* - * jmemmgr.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the JPEG system-independent memory management - * routines. This code is usable across a wide variety of machines; most - * of the system dependencies have been isolated in a separate file. - * The major functions provided here are: - * * pool-based allocation and freeing of memory; - * * policy decisions about how to divide available memory among the - * virtual arrays; - * * control logic for swapping virtual arrays between main memory and - * backing storage. - * The separate system-dependent file provides the actual backing-storage - * access code, and it contains the policy decision about how much total - * main memory to use. - * This file is system-dependent in the sense that some of its functions - * are unnecessary in some systems. For example, if there is enough virtual - * memory so that backing storage will never be used, much of the virtual - * array control logic could be removed. (Of course, if you have that much - * memory then you shouldn't care about a little bit of unused code...) - */ - -#define JPEG_INTERNALS -#define AM_MEMORY_MANAGER /* we define jvirt_Xarray_control structs */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef NO_GETENV -#ifndef HAVE_STDLIB_H /* should declare getenv() */ -extern char * getenv JPP((const char * name)); -#endif -#endif - - -/* - * Some important notes: - * The allocation routines provided here must never return NULL. - * They should exit to error_exit if unsuccessful. - * - * It's not a good idea to try to merge the sarray and barray routines, - * even though they are textually almost the same, because samples are - * usually stored as bytes while coefficients are shorts or ints. Thus, - * in machines where byte pointers have a different representation from - * word pointers, the resulting machine code could not be the same. - */ - - -/* - * Many machines require storage alignment: longs must start on 4-byte - * boundaries, doubles on 8-byte boundaries, etc. On such machines, malloc() - * always returns pointers that are multiples of the worst-case alignment - * requirement, and we had better do so too. - * There isn't any really portable way to determine the worst-case alignment - * requirement. This module assumes that the alignment requirement is - * multiples of sizeof(ALIGN_TYPE). - * By default, we define ALIGN_TYPE as double. This is necessary on some - * workstations (where doubles really do need 8-byte alignment) and will work - * fine on nearly everything. If your machine has lesser alignment needs, - * you can save a few bytes by making ALIGN_TYPE smaller. - * The only place I know of where this will NOT work is certain Macintosh - * 680x0 compilers that define double as a 10-byte IEEE extended float. - * Doing 10-byte alignment is counterproductive because longwords won't be - * aligned well. Put "#define ALIGN_TYPE long" in jconfig.h if you have - * such a compiler. - */ - -#ifndef ALIGN_TYPE /* so can override from jconfig.h */ -#define ALIGN_TYPE double -#endif - - -/* - * We allocate objects from "pools", where each pool is gotten with a single - * request to jpeg_get_small() or jpeg_get_large(). There is no per-object - * overhead within a pool, except for alignment padding. Each pool has a - * header with a link to the next pool of the same class. - * Small and large pool headers are identical except that the latter's - * link pointer must be FAR on 80x86 machines. - * Notice that the "real" header fields are union'ed with a dummy ALIGN_TYPE - * field. This forces the compiler to make SIZEOF(small_pool_hdr) a multiple - * of the alignment requirement of ALIGN_TYPE. - */ - -typedef union small_pool_struct * small_pool_ptr; - -typedef union small_pool_struct { - struct { - small_pool_ptr next; /* next in list of pools */ - size_t bytes_used; /* how many bytes already used within pool */ - size_t bytes_left; /* bytes still available in this pool */ - } hdr; - ALIGN_TYPE dummy; /* included in union to ensure alignment */ -} small_pool_hdr; - -typedef union large_pool_struct FAR * large_pool_ptr; - -typedef union large_pool_struct { - struct { - large_pool_ptr next; /* next in list of pools */ - size_t bytes_used; /* how many bytes already used within pool */ - size_t bytes_left; /* bytes still available in this pool */ - } hdr; - ALIGN_TYPE dummy; /* included in union to ensure alignment */ -} large_pool_hdr; - - -/* - * Here is the full definition of a memory manager object. - */ - -typedef struct { - struct jpeg_memory_mgr pub; /* public fields */ - - /* Each pool identifier (lifetime class) names a linked list of pools. */ - small_pool_ptr small_list[JPOOL_NUMPOOLS]; - large_pool_ptr large_list[JPOOL_NUMPOOLS]; - - /* Since we only have one lifetime class of virtual arrays, only one - * linked list is necessary (for each datatype). Note that the virtual - * array control blocks being linked together are actually stored somewhere - * in the small-pool list. - */ - jvirt_sarray_ptr virt_sarray_list; - jvirt_barray_ptr virt_barray_list; - - /* This counts total space obtained from jpeg_get_small/large */ - long total_space_allocated; - - /* alloc_sarray and alloc_barray set this value for use by virtual - * array routines. - */ - JDIMENSION last_rowsperchunk; /* from most recent alloc_sarray/barray */ -} my_memory_mgr; - -typedef my_memory_mgr * my_mem_ptr; - - -/* - * The control blocks for virtual arrays. - * Note that these blocks are allocated in the "small" pool area. - * System-dependent info for the associated backing store (if any) is hidden - * inside the backing_store_info struct. - */ - -struct jvirt_sarray_control { - JSAMPARRAY mem_buffer; /* => the in-memory buffer */ - JDIMENSION rows_in_array; /* total virtual array height */ - JDIMENSION samplesperrow; /* width of array (and of memory buffer) */ - JDIMENSION maxaccess; /* max rows accessed by access_virt_sarray */ - JDIMENSION rows_in_mem; /* height of memory buffer */ - JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ - JDIMENSION cur_start_row; /* first logical row # in the buffer */ - JDIMENSION first_undef_row; /* row # of first uninitialized row */ - boolean pre_zero; /* pre-zero mode requested? */ - boolean dirty; /* do current buffer contents need written? */ - boolean b_s_open; /* is backing-store data valid? */ - jvirt_sarray_ptr next; /* link to next virtual sarray control block */ - backing_store_info b_s_info; /* System-dependent control info */ -}; - -struct jvirt_barray_control { - JBLOCKARRAY mem_buffer; /* => the in-memory buffer */ - JDIMENSION rows_in_array; /* total virtual array height */ - JDIMENSION blocksperrow; /* width of array (and of memory buffer) */ - JDIMENSION maxaccess; /* max rows accessed by access_virt_barray */ - JDIMENSION rows_in_mem; /* height of memory buffer */ - JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ - JDIMENSION cur_start_row; /* first logical row # in the buffer */ - JDIMENSION first_undef_row; /* row # of first uninitialized row */ - boolean pre_zero; /* pre-zero mode requested? */ - boolean dirty; /* do current buffer contents need written? */ - boolean b_s_open; /* is backing-store data valid? */ - jvirt_barray_ptr next; /* link to next virtual barray control block */ - backing_store_info b_s_info; /* System-dependent control info */ -}; - - -#ifdef MEM_STATS /* optional extra stuff for statistics */ - -LOCAL(void) -print_mem_stats (j_common_ptr cinfo, int pool_id) -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr shdr_ptr; - large_pool_ptr lhdr_ptr; - - /* Since this is only a debugging stub, we can cheat a little by using - * fprintf directly rather than going through the trace message code. - * This is helpful because message parm array can't handle longs. - */ - fprintf(stderr, "Freeing pool %d, total space = %ld\n", - pool_id, mem->total_space_allocated); - - for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL; - lhdr_ptr = lhdr_ptr->hdr.next) { - fprintf(stderr, " Large chunk used %ld\n", - (long) lhdr_ptr->hdr.bytes_used); - } - - for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL; - shdr_ptr = shdr_ptr->hdr.next) { - fprintf(stderr, " Small chunk used %ld free %ld\n", - (long) shdr_ptr->hdr.bytes_used, - (long) shdr_ptr->hdr.bytes_left); - } -} - -#endif /* MEM_STATS */ - - -LOCAL(void) -out_of_memory (j_common_ptr cinfo, int which) -/* Report an out-of-memory error and stop execution */ -/* If we compiled MEM_STATS support, report alloc requests before dying */ -{ -#ifdef MEM_STATS - cinfo->err->trace_level = 2; /* force self_destruct to report stats */ -#endif - ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, which); -} - - -/* - * Allocation of "small" objects. - * - * For these, we use pooled storage. When a new pool must be created, - * we try to get enough space for the current request plus a "slop" factor, - * where the slop will be the amount of leftover space in the new pool. - * The speed vs. space tradeoff is largely determined by the slop values. - * A different slop value is provided for each pool class (lifetime), - * and we also distinguish the first pool of a class from later ones. - * NOTE: the values given work fairly well on both 16- and 32-bit-int - * machines, but may be too small if longs are 64 bits or more. - */ - -static const size_t first_pool_slop[JPOOL_NUMPOOLS] = -{ - 1600, /* first PERMANENT pool */ - 16000 /* first IMAGE pool */ -}; - -static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = -{ - 0, /* additional PERMANENT pools */ - 5000 /* additional IMAGE pools */ -}; - -#define MIN_SLOP 50 /* greater than 0 to avoid futile looping */ - - -METHODDEF(void *) -alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject) -/* Allocate a "small" object */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr hdr_ptr, prev_hdr_ptr; - char * data_ptr; - size_t odd_bytes, min_request, slop; - - /* Check for unsatisfiable request (do now to ensure no overflow below) */ - if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr))) - out_of_memory(cinfo, 1); /* request exceeds malloc's ability */ - - /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ - odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); - if (odd_bytes > 0) - sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; - - /* See if space is available in any existing pool */ - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - prev_hdr_ptr = NULL; - hdr_ptr = mem->small_list[pool_id]; - while (hdr_ptr != NULL) { - if (hdr_ptr->hdr.bytes_left >= sizeofobject) - break; /* found pool with enough space */ - prev_hdr_ptr = hdr_ptr; - hdr_ptr = hdr_ptr->hdr.next; - } - - /* Time to make a new pool? */ - if (hdr_ptr == NULL) { - /* min_request is what we need now, slop is what will be leftover */ - min_request = sizeofobject + SIZEOF(small_pool_hdr); - if (prev_hdr_ptr == NULL) /* first pool in class? */ - slop = first_pool_slop[pool_id]; - else - slop = extra_pool_slop[pool_id]; - /* Don't ask for more than MAX_ALLOC_CHUNK */ - if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request)) - slop = (size_t) (MAX_ALLOC_CHUNK-min_request); - /* Try to get space, if fail reduce slop and try again */ - for (;;) { - hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop); - if (hdr_ptr != NULL) - break; - slop /= 2; - if (slop < MIN_SLOP) /* give up when it gets real small */ - out_of_memory(cinfo, 2); /* jpeg_get_small failed */ - } - mem->total_space_allocated += min_request + slop; - /* Success, initialize the new pool header and add to end of list */ - hdr_ptr->hdr.next = NULL; - hdr_ptr->hdr.bytes_used = 0; - hdr_ptr->hdr.bytes_left = sizeofobject + slop; - if (prev_hdr_ptr == NULL) /* first pool in class? */ - mem->small_list[pool_id] = hdr_ptr; - else - prev_hdr_ptr->hdr.next = hdr_ptr; - } - - /* OK, allocate the object from the current pool */ - data_ptr = (char *) (hdr_ptr + 1); /* point to first data byte in pool */ - data_ptr += hdr_ptr->hdr.bytes_used; /* point to place for object */ - hdr_ptr->hdr.bytes_used += sizeofobject; - hdr_ptr->hdr.bytes_left -= sizeofobject; - - return (void *) data_ptr; -} - - -/* - * Allocation of "large" objects. - * - * The external semantics of these are the same as "small" objects, - * except that FAR pointers are used on 80x86. However the pool - * management heuristics are quite different. We assume that each - * request is large enough that it may as well be passed directly to - * jpeg_get_large; the pool management just links everything together - * so that we can free it all on demand. - * Note: the major use of "large" objects is in JSAMPARRAY and JBLOCKARRAY - * structures. The routines that create these structures (see below) - * deliberately bunch rows together to ensure a large request size. - */ - -METHODDEF(void FAR *) -alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject) -/* Allocate a "large" object */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - large_pool_ptr hdr_ptr; - size_t odd_bytes; - - /* Check for unsatisfiable request (do now to ensure no overflow below) */ - if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr))) - out_of_memory(cinfo, 3); /* request exceeds malloc's ability */ - - /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ - odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); - if (odd_bytes > 0) - sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; - - /* Always make a new pool */ - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject + - SIZEOF(large_pool_hdr)); - if (hdr_ptr == NULL) - out_of_memory(cinfo, 4); /* jpeg_get_large failed */ - mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr); - - /* Success, initialize the new pool header and add to list */ - hdr_ptr->hdr.next = mem->large_list[pool_id]; - /* We maintain space counts in each pool header for statistical purposes, - * even though they are not needed for allocation. - */ - hdr_ptr->hdr.bytes_used = sizeofobject; - hdr_ptr->hdr.bytes_left = 0; - mem->large_list[pool_id] = hdr_ptr; - - return (void FAR *) (hdr_ptr + 1); /* point to first data byte in pool */ -} - - -/* - * Creation of 2-D sample arrays. - * The pointers are in near heap, the samples themselves in FAR heap. - * - * To minimize allocation overhead and to allow I/O of large contiguous - * blocks, we allocate the sample rows in groups of as many rows as possible - * without exceeding MAX_ALLOC_CHUNK total bytes per allocation request. - * NB: the virtual array control routines, later in this file, know about - * this chunking of rows. The rowsperchunk value is left in the mem manager - * object so that it can be saved away if this sarray is the workspace for - * a virtual array. - */ - -METHODDEF(JSAMPARRAY) -alloc_sarray (j_common_ptr cinfo, int pool_id, - JDIMENSION samplesperrow, JDIMENSION numrows) -/* Allocate a 2-D sample array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - JSAMPARRAY result; - JSAMPROW workspace; - JDIMENSION rowsperchunk, currow, i; - long ltemp; - - /* Calculate max # of rows allowed in one allocation chunk */ - ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / - ((long) samplesperrow * SIZEOF(JSAMPLE)); - if (ltemp <= 0) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - if (ltemp < (long) numrows) - rowsperchunk = (JDIMENSION) ltemp; - else - rowsperchunk = numrows; - mem->last_rowsperchunk = rowsperchunk; - - /* Get space for row pointers (small object) */ - result = (JSAMPARRAY) alloc_small(cinfo, pool_id, - (size_t) (numrows * SIZEOF(JSAMPROW))); - - /* Get the rows themselves (large objects) */ - currow = 0; - while (currow < numrows) { - rowsperchunk = MIN(rowsperchunk, numrows - currow); - workspace = (JSAMPROW) alloc_large(cinfo, pool_id, - (size_t) ((size_t) rowsperchunk * (size_t) samplesperrow - * SIZEOF(JSAMPLE))); - for (i = rowsperchunk; i > 0; i--) { - result[currow++] = workspace; - workspace += samplesperrow; - } - } - - return result; -} - - -/* - * Creation of 2-D coefficient-block arrays. - * This is essentially the same as the code for sample arrays, above. - */ - -METHODDEF(JBLOCKARRAY) -alloc_barray (j_common_ptr cinfo, int pool_id, - JDIMENSION blocksperrow, JDIMENSION numrows) -/* Allocate a 2-D coefficient-block array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - JBLOCKARRAY result; - JBLOCKROW workspace; - JDIMENSION rowsperchunk, currow, i; - long ltemp; - - /* Calculate max # of rows allowed in one allocation chunk */ - ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / - ((long) blocksperrow * SIZEOF(JBLOCK)); - if (ltemp <= 0) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - if (ltemp < (long) numrows) - rowsperchunk = (JDIMENSION) ltemp; - else - rowsperchunk = numrows; - mem->last_rowsperchunk = rowsperchunk; - - /* Get space for row pointers (small object) */ - result = (JBLOCKARRAY) alloc_small(cinfo, pool_id, - (size_t) (numrows * SIZEOF(JBLOCKROW))); - - /* Get the rows themselves (large objects) */ - currow = 0; - while (currow < numrows) { - rowsperchunk = MIN(rowsperchunk, numrows - currow); - workspace = (JBLOCKROW) alloc_large(cinfo, pool_id, - (size_t) ((size_t) rowsperchunk * (size_t) blocksperrow - * SIZEOF(JBLOCK))); - for (i = rowsperchunk; i > 0; i--) { - result[currow++] = workspace; - workspace += blocksperrow; - } - } - - return result; -} - - -/* - * About virtual array management: - * - * The above "normal" array routines are only used to allocate strip buffers - * (as wide as the image, but just a few rows high). Full-image-sized buffers - * are handled as "virtual" arrays. The array is still accessed a strip at a - * time, but the memory manager must save the whole array for repeated - * accesses. The intended implementation is that there is a strip buffer in - * memory (as high as is possible given the desired memory limit), plus a - * backing file that holds the rest of the array. - * - * The request_virt_array routines are told the total size of the image and - * the maximum number of rows that will be accessed at once. The in-memory - * buffer must be at least as large as the maxaccess value. - * - * The request routines create control blocks but not the in-memory buffers. - * That is postponed until realize_virt_arrays is called. At that time the - * total amount of space needed is known (approximately, anyway), so free - * memory can be divided up fairly. - * - * The access_virt_array routines are responsible for making a specific strip - * area accessible (after reading or writing the backing file, if necessary). - * Note that the access routines are told whether the caller intends to modify - * the accessed strip; during a read-only pass this saves having to rewrite - * data to disk. The access routines are also responsible for pre-zeroing - * any newly accessed rows, if pre-zeroing was requested. - * - * In current usage, the access requests are usually for nonoverlapping - * strips; that is, successive access start_row numbers differ by exactly - * num_rows = maxaccess. This means we can get good performance with simple - * buffer dump/reload logic, by making the in-memory buffer be a multiple - * of the access height; then there will never be accesses across bufferload - * boundaries. The code will still work with overlapping access requests, - * but it doesn't handle bufferload overlaps very efficiently. - */ - - -METHODDEF(jvirt_sarray_ptr) -request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero, - JDIMENSION samplesperrow, JDIMENSION numrows, - JDIMENSION maxaccess) -/* Request a virtual 2-D sample array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - jvirt_sarray_ptr result; - - /* Only IMAGE-lifetime virtual arrays are currently supported */ - if (pool_id != JPOOL_IMAGE) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - /* get control block */ - result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id, - SIZEOF(struct jvirt_sarray_control)); - - result->mem_buffer = NULL; /* marks array not yet realized */ - result->rows_in_array = numrows; - result->samplesperrow = samplesperrow; - result->maxaccess = maxaccess; - result->pre_zero = pre_zero; - result->b_s_open = FALSE; /* no associated backing-store object */ - result->next = mem->virt_sarray_list; /* add to list of virtual arrays */ - mem->virt_sarray_list = result; - - return result; -} - - -METHODDEF(jvirt_barray_ptr) -request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero, - JDIMENSION blocksperrow, JDIMENSION numrows, - JDIMENSION maxaccess) -/* Request a virtual 2-D coefficient-block array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - jvirt_barray_ptr result; - - /* Only IMAGE-lifetime virtual arrays are currently supported */ - if (pool_id != JPOOL_IMAGE) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - /* get control block */ - result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id, - SIZEOF(struct jvirt_barray_control)); - - result->mem_buffer = NULL; /* marks array not yet realized */ - result->rows_in_array = numrows; - result->blocksperrow = blocksperrow; - result->maxaccess = maxaccess; - result->pre_zero = pre_zero; - result->b_s_open = FALSE; /* no associated backing-store object */ - result->next = mem->virt_barray_list; /* add to list of virtual arrays */ - mem->virt_barray_list = result; - - return result; -} - - -METHODDEF(void) -realize_virt_arrays (j_common_ptr cinfo) -/* Allocate the in-memory buffers for any unrealized virtual arrays */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - long space_per_minheight, maximum_space, avail_mem; - long minheights, max_minheights; - jvirt_sarray_ptr sptr; - jvirt_barray_ptr bptr; - - /* Compute the minimum space needed (maxaccess rows in each buffer) - * and the maximum space needed (full image height in each buffer). - * These may be of use to the system-dependent jpeg_mem_available routine. - */ - space_per_minheight = 0; - maximum_space = 0; - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->mem_buffer == NULL) { /* if not realized yet */ - space_per_minheight += (long) sptr->maxaccess * - (long) sptr->samplesperrow * SIZEOF(JSAMPLE); - maximum_space += (long) sptr->rows_in_array * - (long) sptr->samplesperrow * SIZEOF(JSAMPLE); - } - } - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->mem_buffer == NULL) { /* if not realized yet */ - space_per_minheight += (long) bptr->maxaccess * - (long) bptr->blocksperrow * SIZEOF(JBLOCK); - maximum_space += (long) bptr->rows_in_array * - (long) bptr->blocksperrow * SIZEOF(JBLOCK); - } - } - - if (space_per_minheight <= 0) - return; /* no unrealized arrays, no work */ - - /* Determine amount of memory to actually use; this is system-dependent. */ - avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space, - mem->total_space_allocated); - - /* If the maximum space needed is available, make all the buffers full - * height; otherwise parcel it out with the same number of minheights - * in each buffer. - */ - if (avail_mem >= maximum_space) - max_minheights = 1000000000L; - else { - max_minheights = avail_mem / space_per_minheight; - /* If there doesn't seem to be enough space, try to get the minimum - * anyway. This allows a "stub" implementation of jpeg_mem_available(). - */ - if (max_minheights <= 0) - max_minheights = 1; - } - - /* Allocate the in-memory buffers and initialize backing store as needed. */ - - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->mem_buffer == NULL) { /* if not realized yet */ - minheights = ((long) sptr->rows_in_array - 1L) / sptr->maxaccess + 1L; - if (minheights <= max_minheights) { - /* This buffer fits in memory */ - sptr->rows_in_mem = sptr->rows_in_array; - } else { - /* It doesn't fit in memory, create backing store. */ - sptr->rows_in_mem = (JDIMENSION) (max_minheights * sptr->maxaccess); - jpeg_open_backing_store(cinfo, & sptr->b_s_info, - (long) sptr->rows_in_array * - (long) sptr->samplesperrow * - (long) SIZEOF(JSAMPLE)); - sptr->b_s_open = TRUE; - } - sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE, - sptr->samplesperrow, sptr->rows_in_mem); - sptr->rowsperchunk = mem->last_rowsperchunk; - sptr->cur_start_row = 0; - sptr->first_undef_row = 0; - sptr->dirty = FALSE; - } - } - - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->mem_buffer == NULL) { /* if not realized yet */ - minheights = ((long) bptr->rows_in_array - 1L) / bptr->maxaccess + 1L; - if (minheights <= max_minheights) { - /* This buffer fits in memory */ - bptr->rows_in_mem = bptr->rows_in_array; - } else { - /* It doesn't fit in memory, create backing store. */ - bptr->rows_in_mem = (JDIMENSION) (max_minheights * bptr->maxaccess); - jpeg_open_backing_store(cinfo, & bptr->b_s_info, - (long) bptr->rows_in_array * - (long) bptr->blocksperrow * - (long) SIZEOF(JBLOCK)); - bptr->b_s_open = TRUE; - } - bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE, - bptr->blocksperrow, bptr->rows_in_mem); - bptr->rowsperchunk = mem->last_rowsperchunk; - bptr->cur_start_row = 0; - bptr->first_undef_row = 0; - bptr->dirty = FALSE; - } - } -} - - -LOCAL(void) -do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing) -/* Do backing store read or write of a virtual sample array */ -{ - long bytesperrow, file_offset, byte_count, rows, thisrow, i; - - bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE); - file_offset = ptr->cur_start_row * bytesperrow; - /* Loop to read or write each allocation chunk in mem_buffer */ - for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { - /* One chunk, but check for short chunk at end of buffer */ - rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); - /* Transfer no more than is currently defined */ - thisrow = (long) ptr->cur_start_row + i; - rows = MIN(rows, (long) ptr->first_undef_row - thisrow); - /* Transfer no more than fits in file */ - rows = MIN(rows, (long) ptr->rows_in_array - thisrow); - if (rows <= 0) /* this chunk might be past end of file! */ - break; - byte_count = rows * bytesperrow; - if (writing) - (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - else - (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - file_offset += byte_count; - } -} - - -LOCAL(void) -do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing) -/* Do backing store read or write of a virtual coefficient-block array */ -{ - long bytesperrow, file_offset, byte_count, rows, thisrow, i; - - bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK); - file_offset = ptr->cur_start_row * bytesperrow; - /* Loop to read or write each allocation chunk in mem_buffer */ - for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { - /* One chunk, but check for short chunk at end of buffer */ - rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); - /* Transfer no more than is currently defined */ - thisrow = (long) ptr->cur_start_row + i; - rows = MIN(rows, (long) ptr->first_undef_row - thisrow); - /* Transfer no more than fits in file */ - rows = MIN(rows, (long) ptr->rows_in_array - thisrow); - if (rows <= 0) /* this chunk might be past end of file! */ - break; - byte_count = rows * bytesperrow; - if (writing) - (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - else - (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - file_offset += byte_count; - } -} - - -METHODDEF(JSAMPARRAY) -access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr, - JDIMENSION start_row, JDIMENSION num_rows, - boolean writable) -/* Access the part of a virtual sample array starting at start_row */ -/* and extending for num_rows rows. writable is true if */ -/* caller intends to modify the accessed area. */ -{ - JDIMENSION end_row = start_row + num_rows; - JDIMENSION undef_row; - - /* debugging check */ - if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || - ptr->mem_buffer == NULL) - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - - /* Make the desired part of the virtual array accessible */ - if (start_row < ptr->cur_start_row || - end_row > ptr->cur_start_row+ptr->rows_in_mem) { - if (! ptr->b_s_open) - ERREXIT(cinfo, JERR_VIRTUAL_BUG); - /* Flush old buffer contents if necessary */ - if (ptr->dirty) { - do_sarray_io(cinfo, ptr, TRUE); - ptr->dirty = FALSE; - } - /* Decide what part of virtual array to access. - * Algorithm: if target address > current window, assume forward scan, - * load starting at target address. If target address < current window, - * assume backward scan, load so that target area is top of window. - * Note that when switching from forward write to forward read, will have - * start_row = 0, so the limiting case applies and we load from 0 anyway. - */ - if (start_row > ptr->cur_start_row) { - ptr->cur_start_row = start_row; - } else { - /* use long arithmetic here to avoid overflow & unsigned problems */ - long ltemp; - - ltemp = (long) end_row - (long) ptr->rows_in_mem; - if (ltemp < 0) - ltemp = 0; /* don't fall off front end of file */ - ptr->cur_start_row = (JDIMENSION) ltemp; - } - /* Read in the selected part of the array. - * During the initial write pass, we will do no actual read - * because the selected part is all undefined. - */ - do_sarray_io(cinfo, ptr, FALSE); - } - /* Ensure the accessed part of the array is defined; prezero if needed. - * To improve locality of access, we only prezero the part of the array - * that the caller is about to access, not the entire in-memory array. - */ - if (ptr->first_undef_row < end_row) { - if (ptr->first_undef_row < start_row) { - if (writable) /* writer skipped over a section of array */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - undef_row = start_row; /* but reader is allowed to read ahead */ - } else { - undef_row = ptr->first_undef_row; - } - if (writable) - ptr->first_undef_row = end_row; - if (ptr->pre_zero) { - size_t bytesperrow = (size_t) ptr->samplesperrow * SIZEOF(JSAMPLE); - undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ - end_row -= ptr->cur_start_row; - while (undef_row < end_row) { - jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); - undef_row++; - } - } else { - if (! writable) /* reader looking at undefined data */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - } - } - /* Flag the buffer dirty if caller will write in it */ - if (writable) - ptr->dirty = TRUE; - /* Return address of proper part of the buffer */ - return ptr->mem_buffer + (start_row - ptr->cur_start_row); -} - - -METHODDEF(JBLOCKARRAY) -access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr, - JDIMENSION start_row, JDIMENSION num_rows, - boolean writable) -/* Access the part of a virtual block array starting at start_row */ -/* and extending for num_rows rows. writable is true if */ -/* caller intends to modify the accessed area. */ -{ - JDIMENSION end_row = start_row + num_rows; - JDIMENSION undef_row; - - /* debugging check */ - if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || - ptr->mem_buffer == NULL) - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - - /* Make the desired part of the virtual array accessible */ - if (start_row < ptr->cur_start_row || - end_row > ptr->cur_start_row+ptr->rows_in_mem) { - if (! ptr->b_s_open) - ERREXIT(cinfo, JERR_VIRTUAL_BUG); - /* Flush old buffer contents if necessary */ - if (ptr->dirty) { - do_barray_io(cinfo, ptr, TRUE); - ptr->dirty = FALSE; - } - /* Decide what part of virtual array to access. - * Algorithm: if target address > current window, assume forward scan, - * load starting at target address. If target address < current window, - * assume backward scan, load so that target area is top of window. - * Note that when switching from forward write to forward read, will have - * start_row = 0, so the limiting case applies and we load from 0 anyway. - */ - if (start_row > ptr->cur_start_row) { - ptr->cur_start_row = start_row; - } else { - /* use long arithmetic here to avoid overflow & unsigned problems */ - long ltemp; - - ltemp = (long) end_row - (long) ptr->rows_in_mem; - if (ltemp < 0) - ltemp = 0; /* don't fall off front end of file */ - ptr->cur_start_row = (JDIMENSION) ltemp; - } - /* Read in the selected part of the array. - * During the initial write pass, we will do no actual read - * because the selected part is all undefined. - */ - do_barray_io(cinfo, ptr, FALSE); - } - /* Ensure the accessed part of the array is defined; prezero if needed. - * To improve locality of access, we only prezero the part of the array - * that the caller is about to access, not the entire in-memory array. - */ - if (ptr->first_undef_row < end_row) { - if (ptr->first_undef_row < start_row) { - if (writable) /* writer skipped over a section of array */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - undef_row = start_row; /* but reader is allowed to read ahead */ - } else { - undef_row = ptr->first_undef_row; - } - if (writable) - ptr->first_undef_row = end_row; - if (ptr->pre_zero) { - size_t bytesperrow = (size_t) ptr->blocksperrow * SIZEOF(JBLOCK); - undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ - end_row -= ptr->cur_start_row; - while (undef_row < end_row) { - jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); - undef_row++; - } - } else { - if (! writable) /* reader looking at undefined data */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - } - } - /* Flag the buffer dirty if caller will write in it */ - if (writable) - ptr->dirty = TRUE; - /* Return address of proper part of the buffer */ - return ptr->mem_buffer + (start_row - ptr->cur_start_row); -} - - -/* - * Release all objects belonging to a specified pool. - */ - -METHODDEF(void) -free_pool (j_common_ptr cinfo, int pool_id) -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr shdr_ptr; - large_pool_ptr lhdr_ptr; - size_t space_freed; - - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - -#ifdef MEM_STATS - if (cinfo->err->trace_level > 1) - print_mem_stats(cinfo, pool_id); /* print pool's memory usage statistics */ -#endif - - /* If freeing IMAGE pool, close any virtual arrays first */ - if (pool_id == JPOOL_IMAGE) { - jvirt_sarray_ptr sptr; - jvirt_barray_ptr bptr; - - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->b_s_open) { /* there may be no backing store */ - sptr->b_s_open = FALSE; /* prevent recursive close if error */ - (*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info); - } - } - mem->virt_sarray_list = NULL; - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->b_s_open) { /* there may be no backing store */ - bptr->b_s_open = FALSE; /* prevent recursive close if error */ - (*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info); - } - } - mem->virt_barray_list = NULL; - } - - /* Release large objects */ - lhdr_ptr = mem->large_list[pool_id]; - mem->large_list[pool_id] = NULL; - - while (lhdr_ptr != NULL) { - large_pool_ptr next_lhdr_ptr = lhdr_ptr->hdr.next; - space_freed = lhdr_ptr->hdr.bytes_used + - lhdr_ptr->hdr.bytes_left + - SIZEOF(large_pool_hdr); - jpeg_free_large(cinfo, (void FAR *) lhdr_ptr, space_freed); - mem->total_space_allocated -= space_freed; - lhdr_ptr = next_lhdr_ptr; - } - - /* Release small objects */ - shdr_ptr = mem->small_list[pool_id]; - mem->small_list[pool_id] = NULL; - - while (shdr_ptr != NULL) { - small_pool_ptr next_shdr_ptr = shdr_ptr->hdr.next; - space_freed = shdr_ptr->hdr.bytes_used + - shdr_ptr->hdr.bytes_left + - SIZEOF(small_pool_hdr); - jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed); - mem->total_space_allocated -= space_freed; - shdr_ptr = next_shdr_ptr; - } -} - - -/* - * Close up shop entirely. - * Note that this cannot be called unless cinfo->mem is non-NULL. - */ - -METHODDEF(void) -self_destruct (j_common_ptr cinfo) -{ - int pool; - - /* Close all backing store, release all memory. - * Releasing pools in reverse order might help avoid fragmentation - * with some (brain-damaged) malloc libraries. - */ - for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { - free_pool(cinfo, pool); - } - - /* Release the memory manager control block too. */ - jpeg_free_small(cinfo, (void *) cinfo->mem, SIZEOF(my_memory_mgr)); - cinfo->mem = NULL; /* ensures I will be called only once */ - - jpeg_mem_term(cinfo); /* system-dependent cleanup */ -} - - -/* - * Memory manager initialization. - * When this is called, only the error manager pointer is valid in cinfo! - */ - -GLOBAL(void) -jinit_memory_mgr (j_common_ptr cinfo) -{ - my_mem_ptr mem; - long max_to_use; - int pool; - size_t test_mac; - - cinfo->mem = NULL; /* for safety if init fails */ - - /* Check for configuration errors. - * SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably - * doesn't reflect any real hardware alignment requirement. - * The test is a little tricky: for X>0, X and X-1 have no one-bits - * in common if and only if X is a power of 2, ie has only one one-bit. - * Some compilers may give an "unreachable code" warning here; ignore it. - */ - if ((SIZEOF(ALIGN_TYPE) & (SIZEOF(ALIGN_TYPE)-1)) != 0) - ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE); - /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be - * a multiple of SIZEOF(ALIGN_TYPE). - * Again, an "unreachable code" warning may be ignored here. - * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK. - */ - test_mac = (size_t) MAX_ALLOC_CHUNK; - if ((long) test_mac != MAX_ALLOC_CHUNK || - (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0) - ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); - - max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */ - - /* Attempt to allocate memory manager's control block */ - mem = (my_mem_ptr) jpeg_get_small(cinfo, SIZEOF(my_memory_mgr)); - - if (mem == NULL) { - jpeg_mem_term(cinfo); /* system-dependent cleanup */ - ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 0); - } - - /* OK, fill in the method pointers */ - mem->pub.alloc_small = alloc_small; - mem->pub.alloc_large = alloc_large; - mem->pub.alloc_sarray = alloc_sarray; - mem->pub.alloc_barray = alloc_barray; - mem->pub.request_virt_sarray = request_virt_sarray; - mem->pub.request_virt_barray = request_virt_barray; - mem->pub.realize_virt_arrays = realize_virt_arrays; - mem->pub.access_virt_sarray = access_virt_sarray; - mem->pub.access_virt_barray = access_virt_barray; - mem->pub.free_pool = free_pool; - mem->pub.self_destruct = self_destruct; - - /* Make MAX_ALLOC_CHUNK accessible to other modules */ - mem->pub.max_alloc_chunk = MAX_ALLOC_CHUNK; - - /* Initialize working state */ - mem->pub.max_memory_to_use = max_to_use; - - for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { - mem->small_list[pool] = NULL; - mem->large_list[pool] = NULL; - } - mem->virt_sarray_list = NULL; - mem->virt_barray_list = NULL; - - mem->total_space_allocated = SIZEOF(my_memory_mgr); - - /* Declare ourselves open for business */ - cinfo->mem = & mem->pub; - - /* Check for an environment variable JPEGMEM; if found, override the - * default max_memory setting from jpeg_mem_init. Note that the - * surrounding application may again override this value. - * If your system doesn't support getenv(), define NO_GETENV to disable - * this feature. - */ -#ifndef NO_GETENV - { char * memenv; - - if ((memenv = getenv("JPEGMEM")) != NULL) { - char ch = 'x'; - - if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) { - if (ch == 'm' || ch == 'M') - max_to_use *= 1000L; - mem->pub.max_memory_to_use = max_to_use * 1000L; - } - } - } -#endif - -} +/* + * jmemmgr.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the JPEG system-independent memory management + * routines. This code is usable across a wide variety of machines; most + * of the system dependencies have been isolated in a separate file. + * The major functions provided here are: + * * pool-based allocation and freeing of memory; + * * policy decisions about how to divide available memory among the + * virtual arrays; + * * control logic for swapping virtual arrays between main memory and + * backing storage. + * The separate system-dependent file provides the actual backing-storage + * access code, and it contains the policy decision about how much total + * main memory to use. + * This file is system-dependent in the sense that some of its functions + * are unnecessary in some systems. For example, if there is enough virtual + * memory so that backing storage will never be used, much of the virtual + * array control logic could be removed. (Of course, if you have that much + * memory then you shouldn't care about a little bit of unused code...) + */ + +#define JPEG_INTERNALS +#define AM_MEMORY_MANAGER /* we define jvirt_Xarray_control structs */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef NO_GETENV +#ifndef HAVE_STDLIB_H /* should declare getenv() */ +extern char * getenv JPP((const char * name)); +#endif +#endif + + +/* + * Some important notes: + * The allocation routines provided here must never return NULL. + * They should exit to error_exit if unsuccessful. + * + * It's not a good idea to try to merge the sarray and barray routines, + * even though they are textually almost the same, because samples are + * usually stored as bytes while coefficients are shorts or ints. Thus, + * in machines where byte pointers have a different representation from + * word pointers, the resulting machine code could not be the same. + */ + + +/* + * Many machines require storage alignment: longs must start on 4-byte + * boundaries, doubles on 8-byte boundaries, etc. On such machines, malloc() + * always returns pointers that are multiples of the worst-case alignment + * requirement, and we had better do so too. + * There isn't any really portable way to determine the worst-case alignment + * requirement. This module assumes that the alignment requirement is + * multiples of sizeof(ALIGN_TYPE). + * By default, we define ALIGN_TYPE as double. This is necessary on some + * workstations (where doubles really do need 8-byte alignment) and will work + * fine on nearly everything. If your machine has lesser alignment needs, + * you can save a few bytes by making ALIGN_TYPE smaller. + * The only place I know of where this will NOT work is certain Macintosh + * 680x0 compilers that define double as a 10-byte IEEE extended float. + * Doing 10-byte alignment is counterproductive because longwords won't be + * aligned well. Put "#define ALIGN_TYPE long" in jconfig.h if you have + * such a compiler. + */ + +#ifndef ALIGN_TYPE /* so can override from jconfig.h */ +#define ALIGN_TYPE double +#endif + + +/* + * We allocate objects from "pools", where each pool is gotten with a single + * request to jpeg_get_small() or jpeg_get_large(). There is no per-object + * overhead within a pool, except for alignment padding. Each pool has a + * header with a link to the next pool of the same class. + * Small and large pool headers are identical except that the latter's + * link pointer must be FAR on 80x86 machines. + * Notice that the "real" header fields are union'ed with a dummy ALIGN_TYPE + * field. This forces the compiler to make SIZEOF(small_pool_hdr) a multiple + * of the alignment requirement of ALIGN_TYPE. + */ + +typedef union small_pool_struct * small_pool_ptr; + +typedef union small_pool_struct { + struct { + small_pool_ptr next; /* next in list of pools */ + size_t bytes_used; /* how many bytes already used within pool */ + size_t bytes_left; /* bytes still available in this pool */ + } hdr; + ALIGN_TYPE dummy; /* included in union to ensure alignment */ +} small_pool_hdr; + +typedef union large_pool_struct FAR * large_pool_ptr; + +typedef union large_pool_struct { + struct { + large_pool_ptr next; /* next in list of pools */ + size_t bytes_used; /* how many bytes already used within pool */ + size_t bytes_left; /* bytes still available in this pool */ + } hdr; + ALIGN_TYPE dummy; /* included in union to ensure alignment */ +} large_pool_hdr; + + +/* + * Here is the full definition of a memory manager object. + */ + +typedef struct { + struct jpeg_memory_mgr pub; /* public fields */ + + /* Each pool identifier (lifetime class) names a linked list of pools. */ + small_pool_ptr small_list[JPOOL_NUMPOOLS]; + large_pool_ptr large_list[JPOOL_NUMPOOLS]; + + /* Since we only have one lifetime class of virtual arrays, only one + * linked list is necessary (for each datatype). Note that the virtual + * array control blocks being linked together are actually stored somewhere + * in the small-pool list. + */ + jvirt_sarray_ptr virt_sarray_list; + jvirt_barray_ptr virt_barray_list; + + /* This counts total space obtained from jpeg_get_small/large */ + long total_space_allocated; + + /* alloc_sarray and alloc_barray set this value for use by virtual + * array routines. + */ + JDIMENSION last_rowsperchunk; /* from most recent alloc_sarray/barray */ +} my_memory_mgr; + +typedef my_memory_mgr * my_mem_ptr; + + +/* + * The control blocks for virtual arrays. + * Note that these blocks are allocated in the "small" pool area. + * System-dependent info for the associated backing store (if any) is hidden + * inside the backing_store_info struct. + */ + +struct jvirt_sarray_control { + JSAMPARRAY mem_buffer; /* => the in-memory buffer */ + JDIMENSION rows_in_array; /* total virtual array height */ + JDIMENSION samplesperrow; /* width of array (and of memory buffer) */ + JDIMENSION maxaccess; /* max rows accessed by access_virt_sarray */ + JDIMENSION rows_in_mem; /* height of memory buffer */ + JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ + JDIMENSION cur_start_row; /* first logical row # in the buffer */ + JDIMENSION first_undef_row; /* row # of first uninitialized row */ + boolean pre_zero; /* pre-zero mode requested? */ + boolean dirty; /* do current buffer contents need written? */ + boolean b_s_open; /* is backing-store data valid? */ + jvirt_sarray_ptr next; /* link to next virtual sarray control block */ + backing_store_info b_s_info; /* System-dependent control info */ +}; + +struct jvirt_barray_control { + JBLOCKARRAY mem_buffer; /* => the in-memory buffer */ + JDIMENSION rows_in_array; /* total virtual array height */ + JDIMENSION blocksperrow; /* width of array (and of memory buffer) */ + JDIMENSION maxaccess; /* max rows accessed by access_virt_barray */ + JDIMENSION rows_in_mem; /* height of memory buffer */ + JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ + JDIMENSION cur_start_row; /* first logical row # in the buffer */ + JDIMENSION first_undef_row; /* row # of first uninitialized row */ + boolean pre_zero; /* pre-zero mode requested? */ + boolean dirty; /* do current buffer contents need written? */ + boolean b_s_open; /* is backing-store data valid? */ + jvirt_barray_ptr next; /* link to next virtual barray control block */ + backing_store_info b_s_info; /* System-dependent control info */ +}; + + +#ifdef MEM_STATS /* optional extra stuff for statistics */ + +LOCAL(void) +print_mem_stats (j_common_ptr cinfo, int pool_id) +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + small_pool_ptr shdr_ptr; + large_pool_ptr lhdr_ptr; + + /* Since this is only a debugging stub, we can cheat a little by using + * fprintf directly rather than going through the trace message code. + * This is helpful because message parm array can't handle longs. + */ + fprintf(stderr, "Freeing pool %d, total space = %ld\n", + pool_id, mem->total_space_allocated); + + for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL; + lhdr_ptr = lhdr_ptr->hdr.next) { + fprintf(stderr, " Large chunk used %ld\n", + (long) lhdr_ptr->hdr.bytes_used); + } + + for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL; + shdr_ptr = shdr_ptr->hdr.next) { + fprintf(stderr, " Small chunk used %ld free %ld\n", + (long) shdr_ptr->hdr.bytes_used, + (long) shdr_ptr->hdr.bytes_left); + } +} + +#endif /* MEM_STATS */ + + +LOCAL(void) +out_of_memory (j_common_ptr cinfo, int which) +/* Report an out-of-memory error and stop execution */ +/* If we compiled MEM_STATS support, report alloc requests before dying */ +{ +#ifdef MEM_STATS + cinfo->err->trace_level = 2; /* force self_destruct to report stats */ +#endif + ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, which); +} + + +/* + * Allocation of "small" objects. + * + * For these, we use pooled storage. When a new pool must be created, + * we try to get enough space for the current request plus a "slop" factor, + * where the slop will be the amount of leftover space in the new pool. + * The speed vs. space tradeoff is largely determined by the slop values. + * A different slop value is provided for each pool class (lifetime), + * and we also distinguish the first pool of a class from later ones. + * NOTE: the values given work fairly well on both 16- and 32-bit-int + * machines, but may be too small if longs are 64 bits or more. + */ + +static const size_t first_pool_slop[JPOOL_NUMPOOLS] = +{ + 1600, /* first PERMANENT pool */ + 16000 /* first IMAGE pool */ +}; + +static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = +{ + 0, /* additional PERMANENT pools */ + 5000 /* additional IMAGE pools */ +}; + +#define MIN_SLOP 50 /* greater than 0 to avoid futile looping */ + + +METHODDEF(void *) +alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject) +/* Allocate a "small" object */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + small_pool_ptr hdr_ptr, prev_hdr_ptr; + char * data_ptr; + size_t odd_bytes, min_request, slop; + + /* Check for unsatisfiable request (do now to ensure no overflow below) */ + if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr))) + out_of_memory(cinfo, 1); /* request exceeds malloc's ability */ + + /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ + odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); + if (odd_bytes > 0) + sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; + + /* See if space is available in any existing pool */ + if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + prev_hdr_ptr = NULL; + hdr_ptr = mem->small_list[pool_id]; + while (hdr_ptr != NULL) { + if (hdr_ptr->hdr.bytes_left >= sizeofobject) + break; /* found pool with enough space */ + prev_hdr_ptr = hdr_ptr; + hdr_ptr = hdr_ptr->hdr.next; + } + + /* Time to make a new pool? */ + if (hdr_ptr == NULL) { + /* min_request is what we need now, slop is what will be leftover */ + min_request = sizeofobject + SIZEOF(small_pool_hdr); + if (prev_hdr_ptr == NULL) /* first pool in class? */ + slop = first_pool_slop[pool_id]; + else + slop = extra_pool_slop[pool_id]; + /* Don't ask for more than MAX_ALLOC_CHUNK */ + if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request)) + slop = (size_t) (MAX_ALLOC_CHUNK-min_request); + /* Try to get space, if fail reduce slop and try again */ + for (;;) { + hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop); + if (hdr_ptr != NULL) + break; + slop /= 2; + if (slop < MIN_SLOP) /* give up when it gets real small */ + out_of_memory(cinfo, 2); /* jpeg_get_small failed */ + } + mem->total_space_allocated += min_request + slop; + /* Success, initialize the new pool header and add to end of list */ + hdr_ptr->hdr.next = NULL; + hdr_ptr->hdr.bytes_used = 0; + hdr_ptr->hdr.bytes_left = sizeofobject + slop; + if (prev_hdr_ptr == NULL) /* first pool in class? */ + mem->small_list[pool_id] = hdr_ptr; + else + prev_hdr_ptr->hdr.next = hdr_ptr; + } + + /* OK, allocate the object from the current pool */ + data_ptr = (char *) (hdr_ptr + 1); /* point to first data byte in pool */ + data_ptr += hdr_ptr->hdr.bytes_used; /* point to place for object */ + hdr_ptr->hdr.bytes_used += sizeofobject; + hdr_ptr->hdr.bytes_left -= sizeofobject; + + return (void *) data_ptr; +} + + +/* + * Allocation of "large" objects. + * + * The external semantics of these are the same as "small" objects, + * except that FAR pointers are used on 80x86. However the pool + * management heuristics are quite different. We assume that each + * request is large enough that it may as well be passed directly to + * jpeg_get_large; the pool management just links everything together + * so that we can free it all on demand. + * Note: the major use of "large" objects is in JSAMPARRAY and JBLOCKARRAY + * structures. The routines that create these structures (see below) + * deliberately bunch rows together to ensure a large request size. + */ + +METHODDEF(void FAR *) +alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject) +/* Allocate a "large" object */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + large_pool_ptr hdr_ptr; + size_t odd_bytes; + + /* Check for unsatisfiable request (do now to ensure no overflow below) */ + if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr))) + out_of_memory(cinfo, 3); /* request exceeds malloc's ability */ + + /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ + odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); + if (odd_bytes > 0) + sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; + + /* Always make a new pool */ + if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + + hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject + + SIZEOF(large_pool_hdr)); + if (hdr_ptr == NULL) + out_of_memory(cinfo, 4); /* jpeg_get_large failed */ + mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr); + + /* Success, initialize the new pool header and add to list */ + hdr_ptr->hdr.next = mem->large_list[pool_id]; + /* We maintain space counts in each pool header for statistical purposes, + * even though they are not needed for allocation. + */ + hdr_ptr->hdr.bytes_used = sizeofobject; + hdr_ptr->hdr.bytes_left = 0; + mem->large_list[pool_id] = hdr_ptr; + + return (void FAR *) (hdr_ptr + 1); /* point to first data byte in pool */ +} + + +/* + * Creation of 2-D sample arrays. + * The pointers are in near heap, the samples themselves in FAR heap. + * + * To minimize allocation overhead and to allow I/O of large contiguous + * blocks, we allocate the sample rows in groups of as many rows as possible + * without exceeding MAX_ALLOC_CHUNK total bytes per allocation request. + * NB: the virtual array control routines, later in this file, know about + * this chunking of rows. The rowsperchunk value is left in the mem manager + * object so that it can be saved away if this sarray is the workspace for + * a virtual array. + */ + +METHODDEF(JSAMPARRAY) +alloc_sarray (j_common_ptr cinfo, int pool_id, + JDIMENSION samplesperrow, JDIMENSION numrows) +/* Allocate a 2-D sample array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + JSAMPARRAY result; + JSAMPROW workspace; + JDIMENSION rowsperchunk, currow, i; + long ltemp; + + /* Calculate max # of rows allowed in one allocation chunk */ + ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / + ((long) samplesperrow * SIZEOF(JSAMPLE)); + if (ltemp <= 0) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + if (ltemp < (long) numrows) + rowsperchunk = (JDIMENSION) ltemp; + else + rowsperchunk = numrows; + mem->last_rowsperchunk = rowsperchunk; + + /* Get space for row pointers (small object) */ + result = (JSAMPARRAY) alloc_small(cinfo, pool_id, + (size_t) (numrows * SIZEOF(JSAMPROW))); + + /* Get the rows themselves (large objects) */ + currow = 0; + while (currow < numrows) { + rowsperchunk = MIN(rowsperchunk, numrows - currow); + workspace = (JSAMPROW) alloc_large(cinfo, pool_id, + (size_t) ((size_t) rowsperchunk * (size_t) samplesperrow + * SIZEOF(JSAMPLE))); + for (i = rowsperchunk; i > 0; i--) { + result[currow++] = workspace; + workspace += samplesperrow; + } + } + + return result; +} + + +/* + * Creation of 2-D coefficient-block arrays. + * This is essentially the same as the code for sample arrays, above. + */ + +METHODDEF(JBLOCKARRAY) +alloc_barray (j_common_ptr cinfo, int pool_id, + JDIMENSION blocksperrow, JDIMENSION numrows) +/* Allocate a 2-D coefficient-block array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + JBLOCKARRAY result; + JBLOCKROW workspace; + JDIMENSION rowsperchunk, currow, i; + long ltemp; + + /* Calculate max # of rows allowed in one allocation chunk */ + ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / + ((long) blocksperrow * SIZEOF(JBLOCK)); + if (ltemp <= 0) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + if (ltemp < (long) numrows) + rowsperchunk = (JDIMENSION) ltemp; + else + rowsperchunk = numrows; + mem->last_rowsperchunk = rowsperchunk; + + /* Get space for row pointers (small object) */ + result = (JBLOCKARRAY) alloc_small(cinfo, pool_id, + (size_t) (numrows * SIZEOF(JBLOCKROW))); + + /* Get the rows themselves (large objects) */ + currow = 0; + while (currow < numrows) { + rowsperchunk = MIN(rowsperchunk, numrows - currow); + workspace = (JBLOCKROW) alloc_large(cinfo, pool_id, + (size_t) ((size_t) rowsperchunk * (size_t) blocksperrow + * SIZEOF(JBLOCK))); + for (i = rowsperchunk; i > 0; i--) { + result[currow++] = workspace; + workspace += blocksperrow; + } + } + + return result; +} + + +/* + * About virtual array management: + * + * The above "normal" array routines are only used to allocate strip buffers + * (as wide as the image, but just a few rows high). Full-image-sized buffers + * are handled as "virtual" arrays. The array is still accessed a strip at a + * time, but the memory manager must save the whole array for repeated + * accesses. The intended implementation is that there is a strip buffer in + * memory (as high as is possible given the desired memory limit), plus a + * backing file that holds the rest of the array. + * + * The request_virt_array routines are told the total size of the image and + * the maximum number of rows that will be accessed at once. The in-memory + * buffer must be at least as large as the maxaccess value. + * + * The request routines create control blocks but not the in-memory buffers. + * That is postponed until realize_virt_arrays is called. At that time the + * total amount of space needed is known (approximately, anyway), so free + * memory can be divided up fairly. + * + * The access_virt_array routines are responsible for making a specific strip + * area accessible (after reading or writing the backing file, if necessary). + * Note that the access routines are told whether the caller intends to modify + * the accessed strip; during a read-only pass this saves having to rewrite + * data to disk. The access routines are also responsible for pre-zeroing + * any newly accessed rows, if pre-zeroing was requested. + * + * In current usage, the access requests are usually for nonoverlapping + * strips; that is, successive access start_row numbers differ by exactly + * num_rows = maxaccess. This means we can get good performance with simple + * buffer dump/reload logic, by making the in-memory buffer be a multiple + * of the access height; then there will never be accesses across bufferload + * boundaries. The code will still work with overlapping access requests, + * but it doesn't handle bufferload overlaps very efficiently. + */ + + +METHODDEF(jvirt_sarray_ptr) +request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero, + JDIMENSION samplesperrow, JDIMENSION numrows, + JDIMENSION maxaccess) +/* Request a virtual 2-D sample array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + jvirt_sarray_ptr result; + + /* Only IMAGE-lifetime virtual arrays are currently supported */ + if (pool_id != JPOOL_IMAGE) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + + /* get control block */ + result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id, + SIZEOF(struct jvirt_sarray_control)); + + result->mem_buffer = NULL; /* marks array not yet realized */ + result->rows_in_array = numrows; + result->samplesperrow = samplesperrow; + result->maxaccess = maxaccess; + result->pre_zero = pre_zero; + result->b_s_open = FALSE; /* no associated backing-store object */ + result->next = mem->virt_sarray_list; /* add to list of virtual arrays */ + mem->virt_sarray_list = result; + + return result; +} + + +METHODDEF(jvirt_barray_ptr) +request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero, + JDIMENSION blocksperrow, JDIMENSION numrows, + JDIMENSION maxaccess) +/* Request a virtual 2-D coefficient-block array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + jvirt_barray_ptr result; + + /* Only IMAGE-lifetime virtual arrays are currently supported */ + if (pool_id != JPOOL_IMAGE) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + + /* get control block */ + result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id, + SIZEOF(struct jvirt_barray_control)); + + result->mem_buffer = NULL; /* marks array not yet realized */ + result->rows_in_array = numrows; + result->blocksperrow = blocksperrow; + result->maxaccess = maxaccess; + result->pre_zero = pre_zero; + result->b_s_open = FALSE; /* no associated backing-store object */ + result->next = mem->virt_barray_list; /* add to list of virtual arrays */ + mem->virt_barray_list = result; + + return result; +} + + +METHODDEF(void) +realize_virt_arrays (j_common_ptr cinfo) +/* Allocate the in-memory buffers for any unrealized virtual arrays */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + long space_per_minheight, maximum_space, avail_mem; + long minheights, max_minheights; + jvirt_sarray_ptr sptr; + jvirt_barray_ptr bptr; + + /* Compute the minimum space needed (maxaccess rows in each buffer) + * and the maximum space needed (full image height in each buffer). + * These may be of use to the system-dependent jpeg_mem_available routine. + */ + space_per_minheight = 0; + maximum_space = 0; + for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { + if (sptr->mem_buffer == NULL) { /* if not realized yet */ + space_per_minheight += (long) sptr->maxaccess * + (long) sptr->samplesperrow * SIZEOF(JSAMPLE); + maximum_space += (long) sptr->rows_in_array * + (long) sptr->samplesperrow * SIZEOF(JSAMPLE); + } + } + for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { + if (bptr->mem_buffer == NULL) { /* if not realized yet */ + space_per_minheight += (long) bptr->maxaccess * + (long) bptr->blocksperrow * SIZEOF(JBLOCK); + maximum_space += (long) bptr->rows_in_array * + (long) bptr->blocksperrow * SIZEOF(JBLOCK); + } + } + + if (space_per_minheight <= 0) + return; /* no unrealized arrays, no work */ + + /* Determine amount of memory to actually use; this is system-dependent. */ + avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space, + mem->total_space_allocated); + + /* If the maximum space needed is available, make all the buffers full + * height; otherwise parcel it out with the same number of minheights + * in each buffer. + */ + if (avail_mem >= maximum_space) + max_minheights = 1000000000L; + else { + max_minheights = avail_mem / space_per_minheight; + /* If there doesn't seem to be enough space, try to get the minimum + * anyway. This allows a "stub" implementation of jpeg_mem_available(). + */ + if (max_minheights <= 0) + max_minheights = 1; + } + + /* Allocate the in-memory buffers and initialize backing store as needed. */ + + for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { + if (sptr->mem_buffer == NULL) { /* if not realized yet */ + minheights = ((long) sptr->rows_in_array - 1L) / sptr->maxaccess + 1L; + if (minheights <= max_minheights) { + /* This buffer fits in memory */ + sptr->rows_in_mem = sptr->rows_in_array; + } else { + /* It doesn't fit in memory, create backing store. */ + sptr->rows_in_mem = (JDIMENSION) (max_minheights * sptr->maxaccess); + jpeg_open_backing_store(cinfo, & sptr->b_s_info, + (long) sptr->rows_in_array * + (long) sptr->samplesperrow * + (long) SIZEOF(JSAMPLE)); + sptr->b_s_open = TRUE; + } + sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE, + sptr->samplesperrow, sptr->rows_in_mem); + sptr->rowsperchunk = mem->last_rowsperchunk; + sptr->cur_start_row = 0; + sptr->first_undef_row = 0; + sptr->dirty = FALSE; + } + } + + for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { + if (bptr->mem_buffer == NULL) { /* if not realized yet */ + minheights = ((long) bptr->rows_in_array - 1L) / bptr->maxaccess + 1L; + if (minheights <= max_minheights) { + /* This buffer fits in memory */ + bptr->rows_in_mem = bptr->rows_in_array; + } else { + /* It doesn't fit in memory, create backing store. */ + bptr->rows_in_mem = (JDIMENSION) (max_minheights * bptr->maxaccess); + jpeg_open_backing_store(cinfo, & bptr->b_s_info, + (long) bptr->rows_in_array * + (long) bptr->blocksperrow * + (long) SIZEOF(JBLOCK)); + bptr->b_s_open = TRUE; + } + bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE, + bptr->blocksperrow, bptr->rows_in_mem); + bptr->rowsperchunk = mem->last_rowsperchunk; + bptr->cur_start_row = 0; + bptr->first_undef_row = 0; + bptr->dirty = FALSE; + } + } +} + + +LOCAL(void) +do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing) +/* Do backing store read or write of a virtual sample array */ +{ + long bytesperrow, file_offset, byte_count, rows, thisrow, i; + + bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE); + file_offset = ptr->cur_start_row * bytesperrow; + /* Loop to read or write each allocation chunk in mem_buffer */ + for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { + /* One chunk, but check for short chunk at end of buffer */ + rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); + /* Transfer no more than is currently defined */ + thisrow = (long) ptr->cur_start_row + i; + rows = MIN(rows, (long) ptr->first_undef_row - thisrow); + /* Transfer no more than fits in file */ + rows = MIN(rows, (long) ptr->rows_in_array - thisrow); + if (rows <= 0) /* this chunk might be past end of file! */ + break; + byte_count = rows * bytesperrow; + if (writing) + (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + else + (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + file_offset += byte_count; + } +} + + +LOCAL(void) +do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing) +/* Do backing store read or write of a virtual coefficient-block array */ +{ + long bytesperrow, file_offset, byte_count, rows, thisrow, i; + + bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK); + file_offset = ptr->cur_start_row * bytesperrow; + /* Loop to read or write each allocation chunk in mem_buffer */ + for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { + /* One chunk, but check for short chunk at end of buffer */ + rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); + /* Transfer no more than is currently defined */ + thisrow = (long) ptr->cur_start_row + i; + rows = MIN(rows, (long) ptr->first_undef_row - thisrow); + /* Transfer no more than fits in file */ + rows = MIN(rows, (long) ptr->rows_in_array - thisrow); + if (rows <= 0) /* this chunk might be past end of file! */ + break; + byte_count = rows * bytesperrow; + if (writing) + (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + else + (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + file_offset += byte_count; + } +} + + +METHODDEF(JSAMPARRAY) +access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr, + JDIMENSION start_row, JDIMENSION num_rows, + boolean writable) +/* Access the part of a virtual sample array starting at start_row */ +/* and extending for num_rows rows. writable is true if */ +/* caller intends to modify the accessed area. */ +{ + JDIMENSION end_row = start_row + num_rows; + JDIMENSION undef_row; + + /* debugging check */ + if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || + ptr->mem_buffer == NULL) + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + + /* Make the desired part of the virtual array accessible */ + if (start_row < ptr->cur_start_row || + end_row > ptr->cur_start_row+ptr->rows_in_mem) { + if (! ptr->b_s_open) + ERREXIT(cinfo, JERR_VIRTUAL_BUG); + /* Flush old buffer contents if necessary */ + if (ptr->dirty) { + do_sarray_io(cinfo, ptr, TRUE); + ptr->dirty = FALSE; + } + /* Decide what part of virtual array to access. + * Algorithm: if target address > current window, assume forward scan, + * load starting at target address. If target address < current window, + * assume backward scan, load so that target area is top of window. + * Note that when switching from forward write to forward read, will have + * start_row = 0, so the limiting case applies and we load from 0 anyway. + */ + if (start_row > ptr->cur_start_row) { + ptr->cur_start_row = start_row; + } else { + /* use long arithmetic here to avoid overflow & unsigned problems */ + long ltemp; + + ltemp = (long) end_row - (long) ptr->rows_in_mem; + if (ltemp < 0) + ltemp = 0; /* don't fall off front end of file */ + ptr->cur_start_row = (JDIMENSION) ltemp; + } + /* Read in the selected part of the array. + * During the initial write pass, we will do no actual read + * because the selected part is all undefined. + */ + do_sarray_io(cinfo, ptr, FALSE); + } + /* Ensure the accessed part of the array is defined; prezero if needed. + * To improve locality of access, we only prezero the part of the array + * that the caller is about to access, not the entire in-memory array. + */ + if (ptr->first_undef_row < end_row) { + if (ptr->first_undef_row < start_row) { + if (writable) /* writer skipped over a section of array */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + undef_row = start_row; /* but reader is allowed to read ahead */ + } else { + undef_row = ptr->first_undef_row; + } + if (writable) + ptr->first_undef_row = end_row; + if (ptr->pre_zero) { + size_t bytesperrow = (size_t) ptr->samplesperrow * SIZEOF(JSAMPLE); + undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ + end_row -= ptr->cur_start_row; + while (undef_row < end_row) { + jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); + undef_row++; + } + } else { + if (! writable) /* reader looking at undefined data */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + } + } + /* Flag the buffer dirty if caller will write in it */ + if (writable) + ptr->dirty = TRUE; + /* Return address of proper part of the buffer */ + return ptr->mem_buffer + (start_row - ptr->cur_start_row); +} + + +METHODDEF(JBLOCKARRAY) +access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr, + JDIMENSION start_row, JDIMENSION num_rows, + boolean writable) +/* Access the part of a virtual block array starting at start_row */ +/* and extending for num_rows rows. writable is true if */ +/* caller intends to modify the accessed area. */ +{ + JDIMENSION end_row = start_row + num_rows; + JDIMENSION undef_row; + + /* debugging check */ + if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || + ptr->mem_buffer == NULL) + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + + /* Make the desired part of the virtual array accessible */ + if (start_row < ptr->cur_start_row || + end_row > ptr->cur_start_row+ptr->rows_in_mem) { + if (! ptr->b_s_open) + ERREXIT(cinfo, JERR_VIRTUAL_BUG); + /* Flush old buffer contents if necessary */ + if (ptr->dirty) { + do_barray_io(cinfo, ptr, TRUE); + ptr->dirty = FALSE; + } + /* Decide what part of virtual array to access. + * Algorithm: if target address > current window, assume forward scan, + * load starting at target address. If target address < current window, + * assume backward scan, load so that target area is top of window. + * Note that when switching from forward write to forward read, will have + * start_row = 0, so the limiting case applies and we load from 0 anyway. + */ + if (start_row > ptr->cur_start_row) { + ptr->cur_start_row = start_row; + } else { + /* use long arithmetic here to avoid overflow & unsigned problems */ + long ltemp; + + ltemp = (long) end_row - (long) ptr->rows_in_mem; + if (ltemp < 0) + ltemp = 0; /* don't fall off front end of file */ + ptr->cur_start_row = (JDIMENSION) ltemp; + } + /* Read in the selected part of the array. + * During the initial write pass, we will do no actual read + * because the selected part is all undefined. + */ + do_barray_io(cinfo, ptr, FALSE); + } + /* Ensure the accessed part of the array is defined; prezero if needed. + * To improve locality of access, we only prezero the part of the array + * that the caller is about to access, not the entire in-memory array. + */ + if (ptr->first_undef_row < end_row) { + if (ptr->first_undef_row < start_row) { + if (writable) /* writer skipped over a section of array */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + undef_row = start_row; /* but reader is allowed to read ahead */ + } else { + undef_row = ptr->first_undef_row; + } + if (writable) + ptr->first_undef_row = end_row; + if (ptr->pre_zero) { + size_t bytesperrow = (size_t) ptr->blocksperrow * SIZEOF(JBLOCK); + undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ + end_row -= ptr->cur_start_row; + while (undef_row < end_row) { + jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); + undef_row++; + } + } else { + if (! writable) /* reader looking at undefined data */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + } + } + /* Flag the buffer dirty if caller will write in it */ + if (writable) + ptr->dirty = TRUE; + /* Return address of proper part of the buffer */ + return ptr->mem_buffer + (start_row - ptr->cur_start_row); +} + + +/* + * Release all objects belonging to a specified pool. + */ + +METHODDEF(void) +free_pool (j_common_ptr cinfo, int pool_id) +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + small_pool_ptr shdr_ptr; + large_pool_ptr lhdr_ptr; + size_t space_freed; + + if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + +#ifdef MEM_STATS + if (cinfo->err->trace_level > 1) + print_mem_stats(cinfo, pool_id); /* print pool's memory usage statistics */ +#endif + + /* If freeing IMAGE pool, close any virtual arrays first */ + if (pool_id == JPOOL_IMAGE) { + jvirt_sarray_ptr sptr; + jvirt_barray_ptr bptr; + + for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { + if (sptr->b_s_open) { /* there may be no backing store */ + sptr->b_s_open = FALSE; /* prevent recursive close if error */ + (*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info); + } + } + mem->virt_sarray_list = NULL; + for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { + if (bptr->b_s_open) { /* there may be no backing store */ + bptr->b_s_open = FALSE; /* prevent recursive close if error */ + (*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info); + } + } + mem->virt_barray_list = NULL; + } + + /* Release large objects */ + lhdr_ptr = mem->large_list[pool_id]; + mem->large_list[pool_id] = NULL; + + while (lhdr_ptr != NULL) { + large_pool_ptr next_lhdr_ptr = lhdr_ptr->hdr.next; + space_freed = lhdr_ptr->hdr.bytes_used + + lhdr_ptr->hdr.bytes_left + + SIZEOF(large_pool_hdr); + jpeg_free_large(cinfo, (void FAR *) lhdr_ptr, space_freed); + mem->total_space_allocated -= space_freed; + lhdr_ptr = next_lhdr_ptr; + } + + /* Release small objects */ + shdr_ptr = mem->small_list[pool_id]; + mem->small_list[pool_id] = NULL; + + while (shdr_ptr != NULL) { + small_pool_ptr next_shdr_ptr = shdr_ptr->hdr.next; + space_freed = shdr_ptr->hdr.bytes_used + + shdr_ptr->hdr.bytes_left + + SIZEOF(small_pool_hdr); + jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed); + mem->total_space_allocated -= space_freed; + shdr_ptr = next_shdr_ptr; + } +} + + +/* + * Close up shop entirely. + * Note that this cannot be called unless cinfo->mem is non-NULL. + */ + +METHODDEF(void) +self_destruct (j_common_ptr cinfo) +{ + int pool; + + /* Close all backing store, release all memory. + * Releasing pools in reverse order might help avoid fragmentation + * with some (brain-damaged) malloc libraries. + */ + for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { + free_pool(cinfo, pool); + } + + /* Release the memory manager control block too. */ + jpeg_free_small(cinfo, (void *) cinfo->mem, SIZEOF(my_memory_mgr)); + cinfo->mem = NULL; /* ensures I will be called only once */ + + jpeg_mem_term(cinfo); /* system-dependent cleanup */ +} + + +/* + * Memory manager initialization. + * When this is called, only the error manager pointer is valid in cinfo! + */ + +GLOBAL(void) +jinit_memory_mgr (j_common_ptr cinfo) +{ + my_mem_ptr mem; + long max_to_use; + int pool; + size_t test_mac; + + cinfo->mem = NULL; /* for safety if init fails */ + + /* Check for configuration errors. + * SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably + * doesn't reflect any real hardware alignment requirement. + * The test is a little tricky: for X>0, X and X-1 have no one-bits + * in common if and only if X is a power of 2, ie has only one one-bit. + * Some compilers may give an "unreachable code" warning here; ignore it. + */ + if ((SIZEOF(ALIGN_TYPE) & (SIZEOF(ALIGN_TYPE)-1)) != 0) + ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE); + /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be + * a multiple of SIZEOF(ALIGN_TYPE). + * Again, an "unreachable code" warning may be ignored here. + * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK. + */ + test_mac = (size_t) MAX_ALLOC_CHUNK; + if ((long) test_mac != MAX_ALLOC_CHUNK || + (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0) + ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); + + max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */ + + /* Attempt to allocate memory manager's control block */ + mem = (my_mem_ptr) jpeg_get_small(cinfo, SIZEOF(my_memory_mgr)); + + if (mem == NULL) { + jpeg_mem_term(cinfo); /* system-dependent cleanup */ + ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 0); + } + + /* OK, fill in the method pointers */ + mem->pub.alloc_small = alloc_small; + mem->pub.alloc_large = alloc_large; + mem->pub.alloc_sarray = alloc_sarray; + mem->pub.alloc_barray = alloc_barray; + mem->pub.request_virt_sarray = request_virt_sarray; + mem->pub.request_virt_barray = request_virt_barray; + mem->pub.realize_virt_arrays = realize_virt_arrays; + mem->pub.access_virt_sarray = access_virt_sarray; + mem->pub.access_virt_barray = access_virt_barray; + mem->pub.free_pool = free_pool; + mem->pub.self_destruct = self_destruct; + + /* Make MAX_ALLOC_CHUNK accessible to other modules */ + mem->pub.max_alloc_chunk = MAX_ALLOC_CHUNK; + + /* Initialize working state */ + mem->pub.max_memory_to_use = max_to_use; + + for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { + mem->small_list[pool] = NULL; + mem->large_list[pool] = NULL; + } + mem->virt_sarray_list = NULL; + mem->virt_barray_list = NULL; + + mem->total_space_allocated = SIZEOF(my_memory_mgr); + + /* Declare ourselves open for business */ + cinfo->mem = & mem->pub; + + /* Check for an environment variable JPEGMEM; if found, override the + * default max_memory setting from jpeg_mem_init. Note that the + * surrounding application may again override this value. + * If your system doesn't support getenv(), define NO_GETENV to disable + * this feature. + */ +#ifndef NO_GETENV + { char * memenv; + + if ((memenv = getenv("JPEGMEM")) != NULL) { + char ch = 'x'; + + if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) { + if (ch == 'm' || ch == 'M') + max_to_use *= 1000L; + mem->pub.max_memory_to_use = max_to_use * 1000L; + } + } + } +#endif + +} diff --git a/src/dep/src/irrlicht/jpeglib/jmemname.c b/src/dep/src/irrlicht/jpeglib/jmemname.c index e28b212..ed96dee 100644 --- a/src/dep/src/irrlicht/jpeglib/jmemname.c +++ b/src/dep/src/irrlicht/jpeglib/jmemname.c @@ -1,276 +1,276 @@ -/* - * jmemname.c - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides a generic implementation of the system-dependent - * portion of the JPEG memory manager. This implementation assumes that - * you must explicitly construct a name for each temp file. - * Also, the problem of determining the amount of memory available - * is shoved onto the user. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -#endif - -#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ -#define SEEK_SET 0 /* if not, assume 0 is correct */ -#endif - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#define RW_BINARY "w+" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#define RW_BINARY "w+b", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#define RW_BINARY "w+b" -#endif -#endif - - -/* - * Selection of a file name for a temporary file. - * This is system-dependent! - * - * The code as given is suitable for most Unix systems, and it is easily - * modified for most non-Unix systems. Some notes: - * 1. The temp file is created in the directory named by TEMP_DIRECTORY. - * The default value is /usr/tmp, which is the conventional place for - * creating large temp files on Unix. On other systems you'll probably - * want to change the file location. You can do this by editing the - * #define, or (preferred) by defining TEMP_DIRECTORY in jconfig.h. - * - * 2. If you need to change the file name as well as its location, - * you can override the TEMP_FILE_NAME macro. (Note that this is - * actually a printf format string; it must contain %s and %d.) - * Few people should need to do this. - * - * 3. mktemp() is used to ensure that multiple processes running - * simultaneously won't select the same file names. If your system - * doesn't have mktemp(), define NO_MKTEMP to do it the hard way. - * (If you don't have , also define NO_ERRNO_H.) - * - * 4. You probably want to define NEED_SIGNAL_CATCHER so that cjpeg.c/djpeg.c - * will cause the temp files to be removed if you stop the program early. - */ - -#ifndef TEMP_DIRECTORY /* can override from jconfig.h or Makefile */ -#define TEMP_DIRECTORY "/usr/tmp/" /* recommended setting for Unix */ -#endif - -static int next_file_num; /* to distinguish among several temp files */ - -#ifdef NO_MKTEMP - -#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ -#define TEMP_FILE_NAME "%sJPG%03d.TMP" -#endif - -#ifndef NO_ERRNO_H -#include /* to define ENOENT */ -#endif - -/* ANSI C specifies that errno is a macro, but on older systems it's more - * likely to be a plain int variable. And not all versions of errno.h - * bother to declare it, so we have to in order to be most portable. Thus: - */ -#ifndef errno -extern int errno; -#endif - - -LOCAL(void) -select_file_name (char * fname) -{ - FILE * tfile; - - /* Keep generating file names till we find one that's not in use */ - for (;;) { - next_file_num++; /* advance counter */ - sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); - if ((tfile = fopen(fname, READ_BINARY)) == NULL) { - /* fopen could have failed for a reason other than the file not - * being there; for example, file there but unreadable. - * If isn't available, then we cannot test the cause. - */ -#ifdef ENOENT - if (errno != ENOENT) - continue; -#endif - break; - } - fclose(tfile); /* oops, it's there; close tfile & try again */ - } -} - -#else /* ! NO_MKTEMP */ - -/* Note that mktemp() requires the initial filename to end in six X's */ -#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ -#define TEMP_FILE_NAME "%sJPG%dXXXXXX" -#endif - -LOCAL(void) -select_file_name (char * fname) -{ - next_file_num++; /* advance counter */ - sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); - mktemp(fname); /* make sure file name is unique */ - /* mktemp replaces the trailing XXXXXX with a unique string of characters */ -} - -#endif /* NO_MKTEMP */ - - -/* - * Memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: although we include FAR keywords in the routine declarations, - * this file won't actually work in 80x86 small/medium model; at least, - * you probably won't be able to process useful-size images in only 64KB. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * It's impossible to do this in a portable way; our current solution is - * to make the user tell us (with a default value set at compile time). - * If you can actually get the available space, it's a good idea to subtract - * a slop factor of 5% or so. - */ - -#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ -#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ -#endif - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return cinfo->mem->max_memory_to_use - already_allocated; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - - -METHODDEF(void) -read_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFREAD(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFWRITE(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_backing_store (j_common_ptr cinfo, backing_store_ptr info) -{ - fclose(info->temp_file); /* close the file */ - unlink(info->temp_name); /* delete the file */ -/* If your system doesn't have unlink(), use remove() instead. - * remove() is the ANSI-standard name for this function, but if - * your system was ANSI you'd be using jmemansi.c, right? - */ - TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); -} - - -/* - * Initial opening of a backing-store object. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - select_file_name(info->temp_name); - if ((info->temp_file = fopen(info->temp_name, RW_BINARY)) == NULL) - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - info->read_backing_store = read_backing_store; - info->write_backing_store = write_backing_store; - info->close_backing_store = close_backing_store; - TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - next_file_num = 0; /* initialize temp file name generator */ - return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} +/* + * jmemname.c + * + * Copyright (C) 1992-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides a generic implementation of the system-dependent + * portion of the JPEG memory manager. This implementation assumes that + * you must explicitly construct a name for each temp file. + * Also, the problem of determining the amount of memory available + * is shoved onto the user. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +#endif + +#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ +#define SEEK_SET 0 /* if not, assume 0 is correct */ +#endif + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#define RW_BINARY "w+" +#else +#ifdef VMS /* VMS is very nonstandard */ +#define READ_BINARY "rb", "ctx=stm" +#define RW_BINARY "w+b", "ctx=stm" +#else /* standard ANSI-compliant case */ +#define READ_BINARY "rb" +#define RW_BINARY "w+b" +#endif +#endif + + +/* + * Selection of a file name for a temporary file. + * This is system-dependent! + * + * The code as given is suitable for most Unix systems, and it is easily + * modified for most non-Unix systems. Some notes: + * 1. The temp file is created in the directory named by TEMP_DIRECTORY. + * The default value is /usr/tmp, which is the conventional place for + * creating large temp files on Unix. On other systems you'll probably + * want to change the file location. You can do this by editing the + * #define, or (preferred) by defining TEMP_DIRECTORY in jconfig.h. + * + * 2. If you need to change the file name as well as its location, + * you can override the TEMP_FILE_NAME macro. (Note that this is + * actually a printf format string; it must contain %s and %d.) + * Few people should need to do this. + * + * 3. mktemp() is used to ensure that multiple processes running + * simultaneously won't select the same file names. If your system + * doesn't have mktemp(), define NO_MKTEMP to do it the hard way. + * (If you don't have , also define NO_ERRNO_H.) + * + * 4. You probably want to define NEED_SIGNAL_CATCHER so that cjpeg.c/djpeg.c + * will cause the temp files to be removed if you stop the program early. + */ + +#ifndef TEMP_DIRECTORY /* can override from jconfig.h or Makefile */ +#define TEMP_DIRECTORY "/usr/tmp/" /* recommended setting for Unix */ +#endif + +static int next_file_num; /* to distinguish among several temp files */ + +#ifdef NO_MKTEMP + +#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ +#define TEMP_FILE_NAME "%sJPG%03d.TMP" +#endif + +#ifndef NO_ERRNO_H +#include /* to define ENOENT */ +#endif + +/* ANSI C specifies that errno is a macro, but on older systems it's more + * likely to be a plain int variable. And not all versions of errno.h + * bother to declare it, so we have to in order to be most portable. Thus: + */ +#ifndef errno +extern int errno; +#endif + + +LOCAL(void) +select_file_name (char * fname) +{ + FILE * tfile; + + /* Keep generating file names till we find one that's not in use */ + for (;;) { + next_file_num++; /* advance counter */ + sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); + if ((tfile = fopen(fname, READ_BINARY)) == NULL) { + /* fopen could have failed for a reason other than the file not + * being there; for example, file there but unreadable. + * If isn't available, then we cannot test the cause. + */ +#ifdef ENOENT + if (errno != ENOENT) + continue; +#endif + break; + } + fclose(tfile); /* oops, it's there; close tfile & try again */ + } +} + +#else /* ! NO_MKTEMP */ + +/* Note that mktemp() requires the initial filename to end in six X's */ +#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ +#define TEMP_FILE_NAME "%sJPG%dXXXXXX" +#endif + +LOCAL(void) +select_file_name (char * fname) +{ + next_file_num++; /* advance counter */ + sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); + mktemp(fname); /* make sure file name is unique */ + /* mktemp replaces the trailing XXXXXX with a unique string of characters */ +} + +#endif /* NO_MKTEMP */ + + +/* + * Memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: although we include FAR keywords in the routine declarations, + * this file won't actually work in 80x86 small/medium model; at least, + * you probably won't be able to process useful-size images in only 64KB. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * It's impossible to do this in a portable way; our current solution is + * to make the user tell us (with a default value set at compile time). + * If you can actually get the available space, it's a good idea to subtract + * a slop factor of 5% or so. + */ + +#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ +#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ +#endif + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return cinfo->mem->max_memory_to_use - already_allocated; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + + +METHODDEF(void) +read_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFREAD(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFWRITE(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_backing_store (j_common_ptr cinfo, backing_store_ptr info) +{ + fclose(info->temp_file); /* close the file */ + unlink(info->temp_name); /* delete the file */ +/* If your system doesn't have unlink(), use remove() instead. + * remove() is the ANSI-standard name for this function, but if + * your system was ANSI you'd be using jmemansi.c, right? + */ + TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); +} + + +/* + * Initial opening of a backing-store object. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + select_file_name(info->temp_name); + if ((info->temp_file = fopen(info->temp_name, RW_BINARY)) == NULL) + ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); + info->read_backing_store = read_backing_store; + info->write_backing_store = write_backing_store; + info->close_backing_store = close_backing_store; + TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + next_file_num = 0; /* initialize temp file name generator */ + return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/src/dep/src/irrlicht/jpeglib/jmemnobs.c b/src/dep/src/irrlicht/jpeglib/jmemnobs.c index 6aa1e92..eb8c337 100644 --- a/src/dep/src/irrlicht/jpeglib/jmemnobs.c +++ b/src/dep/src/irrlicht/jpeglib/jmemnobs.c @@ -1,109 +1,109 @@ -/* - * jmemnobs.c - * - * Copyright (C) 1992-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides a really simple implementation of the system- - * dependent portion of the JPEG memory manager. This implementation - * assumes that no backing-store files are needed: all required space - * can be obtained from malloc(). - * This is very portable in the sense that it'll compile on almost anything, - * but you'd better have lots of main memory (or virtual memory) if you want - * to process big images. - * Note that the max_memory_to_use option is ignored by this implementation. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -#endif - - -/* - * Memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: although we include FAR keywords in the routine declarations, - * this file won't actually work in 80x86 small/medium model; at least, - * you probably won't be able to process useful-size images in only 64KB. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * Here we always say, "we got all you want bud!" - */ - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return max_bytes_needed; -} - - -/* - * Backing store (temporary file) management. - * Since jpeg_mem_available always promised the moon, - * this should never be called and we can just error out. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - ERREXIT(cinfo, JERR_NO_BACKING_STORE); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. Here, there isn't any. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - return 0; /* just set max_memory_to_use to 0 */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} +/* + * jmemnobs.c + * + * Copyright (C) 1992-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides a really simple implementation of the system- + * dependent portion of the JPEG memory manager. This implementation + * assumes that no backing-store files are needed: all required space + * can be obtained from malloc(). + * This is very portable in the sense that it'll compile on almost anything, + * but you'd better have lots of main memory (or virtual memory) if you want + * to process big images. + * Note that the max_memory_to_use option is ignored by this implementation. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +#endif + + +/* + * Memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: although we include FAR keywords in the routine declarations, + * this file won't actually work in 80x86 small/medium model; at least, + * you probably won't be able to process useful-size images in only 64KB. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * Here we always say, "we got all you want bud!" + */ + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return max_bytes_needed; +} + + +/* + * Backing store (temporary file) management. + * Since jpeg_mem_available always promised the moon, + * this should never be called and we can just error out. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + ERREXIT(cinfo, JERR_NO_BACKING_STORE); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. Here, there isn't any. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + return 0; /* just set max_memory_to_use to 0 */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/src/dep/src/irrlicht/jpeglib/jmemsys.h b/src/dep/src/irrlicht/jpeglib/jmemsys.h index 2a87961..6c3c6d3 100644 --- a/src/dep/src/irrlicht/jpeglib/jmemsys.h +++ b/src/dep/src/irrlicht/jpeglib/jmemsys.h @@ -1,198 +1,198 @@ -/* - * jmemsys.h - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This include file defines the interface between the system-independent - * and system-dependent portions of the JPEG memory manager. No other - * modules need include it. (The system-independent portion is jmemmgr.c; - * there are several different versions of the system-dependent portion.) - * - * This file works as-is for the system-dependent memory managers supplied - * in the IJG distribution. You may need to modify it if you write a - * custom memory manager. If system-dependent changes are needed in - * this file, the best method is to #ifdef them based on a configuration - * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR - * and USE_MAC_MEMMGR. - */ - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_get_small jGetSmall -#define jpeg_free_small jFreeSmall -#define jpeg_get_large jGetLarge -#define jpeg_free_large jFreeLarge -#define jpeg_mem_available jMemAvail -#define jpeg_open_backing_store jOpenBackStore -#define jpeg_mem_init jMemInit -#define jpeg_mem_term jMemTerm -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* - * These two functions are used to allocate and release small chunks of - * memory. (Typically the total amount requested through jpeg_get_small is - * no more than 20K or so; this will be requested in chunks of a few K each.) - * Behavior should be the same as for the standard library functions malloc - * and free; in particular, jpeg_get_small must return NULL on failure. - * On most systems, these ARE malloc and free. jpeg_free_small is passed the - * size of the object being freed, just in case it's needed. - * On an 80x86 machine using small-data memory model, these manage near heap. - */ - -EXTERN(void *) jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject)); -EXTERN(void) jpeg_free_small JPP((j_common_ptr cinfo, void * object, - size_t sizeofobject)); - -/* - * These two functions are used to allocate and release large chunks of - * memory (up to the total free space designated by jpeg_mem_available). - * The interface is the same as above, except that on an 80x86 machine, - * far pointers are used. On most other machines these are identical to - * the jpeg_get/free_small routines; but we keep them separate anyway, - * in case a different allocation strategy is desirable for large chunks. - */ - -EXTERN(void FAR *) jpeg_get_large JPP((j_common_ptr cinfo, - size_t sizeofobject)); -EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object, - size_t sizeofobject)); - -/* - * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may - * be requested in a single call to jpeg_get_large (and jpeg_get_small for that - * matter, but that case should never come into play). This macro is needed - * to model the 64Kb-segment-size limit of far addressing on 80x86 machines. - * On those machines, we expect that jconfig.h will provide a proper value. - * On machines with 32-bit flat address spaces, any large constant may be used. - * - * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type - * size_t and will be a multiple of sizeof(align_type). - */ - -#ifndef MAX_ALLOC_CHUNK /* may be overridden in jconfig.h */ -#define MAX_ALLOC_CHUNK 1000000000L -#endif - -/* - * This routine computes the total space still available for allocation by - * jpeg_get_large. If more space than this is needed, backing store will be - * used. NOTE: any memory already allocated must not be counted. - * - * There is a minimum space requirement, corresponding to the minimum - * feasible buffer sizes; jmemmgr.c will request that much space even if - * jpeg_mem_available returns zero. The maximum space needed, enough to hold - * all working storage in memory, is also passed in case it is useful. - * Finally, the total space already allocated is passed. If no better - * method is available, cinfo->mem->max_memory_to_use - already_allocated - * is often a suitable calculation. - * - * It is OK for jpeg_mem_available to underestimate the space available - * (that'll just lead to more backing-store access than is really necessary). - * However, an overestimate will lead to failure. Hence it's wise to subtract - * a slop factor from the true available space. 5% should be enough. - * - * On machines with lots of virtual memory, any large constant may be returned. - * Conversely, zero may be returned to always use the minimum amount of memory. - */ - -EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo, - long min_bytes_needed, - long max_bytes_needed, - long already_allocated)); - - -/* - * This structure holds whatever state is needed to access a single - * backing-store object. The read/write/close method pointers are called - * by jmemmgr.c to manipulate the backing-store object; all other fields - * are private to the system-dependent backing store routines. - */ - -#define TEMP_NAME_LENGTH 64 /* max length of a temporary file's name */ - - -#ifdef USE_MSDOS_MEMMGR /* DOS-specific junk */ - -typedef unsigned short XMSH; /* type of extended-memory handles */ -typedef unsigned short EMSH; /* type of expanded-memory handles */ - -typedef union { - short file_handle; /* DOS file handle if it's a temp file */ - XMSH xms_handle; /* handle if it's a chunk of XMS */ - EMSH ems_handle; /* handle if it's a chunk of EMS */ -} handle_union; - -#endif /* USE_MSDOS_MEMMGR */ - -#ifdef USE_MAC_MEMMGR /* Mac-specific junk */ -#include -#endif /* USE_MAC_MEMMGR */ - - -typedef struct backing_store_struct * backing_store_ptr; - -typedef struct backing_store_struct { - /* Methods for reading/writing/closing this backing-store object */ - JMETHOD(void, read_backing_store, (j_common_ptr cinfo, - backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count)); - JMETHOD(void, write_backing_store, (j_common_ptr cinfo, - backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count)); - JMETHOD(void, close_backing_store, (j_common_ptr cinfo, - backing_store_ptr info)); - - /* Private fields for system-dependent backing-store management */ -#ifdef USE_MSDOS_MEMMGR - /* For the MS-DOS manager (jmemdos.c), we need: */ - handle_union handle; /* reference to backing-store storage object */ - char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ -#else -#ifdef USE_MAC_MEMMGR - /* For the Mac manager (jmemmac.c), we need: */ - short temp_file; /* file reference number to temp file */ - FSSpec tempSpec; /* the FSSpec for the temp file */ - char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ -#else - /* For a typical implementation with temp files, we need: */ - FILE * temp_file; /* stdio reference to temp file */ - char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */ -#endif -#endif -} backing_store_info; - - -/* - * Initial opening of a backing-store object. This must fill in the - * read/write/close pointers in the object. The read/write routines - * may take an error exit if the specified maximum file size is exceeded. - * (If jpeg_mem_available always returns a large value, this routine can - * just take an error exit.) - */ - -EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo, - backing_store_ptr info, - long total_bytes_needed)); - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. jpeg_mem_init will be called before anything is - * allocated (and, therefore, nothing in cinfo is of use except the error - * manager pointer). It should return a suitable default value for - * max_memory_to_use; this may subsequently be overridden by the surrounding - * application. (Note that max_memory_to_use is only important if - * jpeg_mem_available chooses to consult it ... no one else will.) - * jpeg_mem_term may assume that all requested memory has been freed and that - * all opened backing-store objects have been closed. - */ - -EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo)); -EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo)); +/* + * jmemsys.h + * + * Copyright (C) 1992-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This include file defines the interface between the system-independent + * and system-dependent portions of the JPEG memory manager. No other + * modules need include it. (The system-independent portion is jmemmgr.c; + * there are several different versions of the system-dependent portion.) + * + * This file works as-is for the system-dependent memory managers supplied + * in the IJG distribution. You may need to modify it if you write a + * custom memory manager. If system-dependent changes are needed in + * this file, the best method is to #ifdef them based on a configuration + * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR + * and USE_MAC_MEMMGR. + */ + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_get_small jGetSmall +#define jpeg_free_small jFreeSmall +#define jpeg_get_large jGetLarge +#define jpeg_free_large jFreeLarge +#define jpeg_mem_available jMemAvail +#define jpeg_open_backing_store jOpenBackStore +#define jpeg_mem_init jMemInit +#define jpeg_mem_term jMemTerm +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* + * These two functions are used to allocate and release small chunks of + * memory. (Typically the total amount requested through jpeg_get_small is + * no more than 20K or so; this will be requested in chunks of a few K each.) + * Behavior should be the same as for the standard library functions malloc + * and free; in particular, jpeg_get_small must return NULL on failure. + * On most systems, these ARE malloc and free. jpeg_free_small is passed the + * size of the object being freed, just in case it's needed. + * On an 80x86 machine using small-data memory model, these manage near heap. + */ + +EXTERN(void *) jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject)); +EXTERN(void) jpeg_free_small JPP((j_common_ptr cinfo, void * object, + size_t sizeofobject)); + +/* + * These two functions are used to allocate and release large chunks of + * memory (up to the total free space designated by jpeg_mem_available). + * The interface is the same as above, except that on an 80x86 machine, + * far pointers are used. On most other machines these are identical to + * the jpeg_get/free_small routines; but we keep them separate anyway, + * in case a different allocation strategy is desirable for large chunks. + */ + +EXTERN(void FAR *) jpeg_get_large JPP((j_common_ptr cinfo, + size_t sizeofobject)); +EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object, + size_t sizeofobject)); + +/* + * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may + * be requested in a single call to jpeg_get_large (and jpeg_get_small for that + * matter, but that case should never come into play). This macro is needed + * to model the 64Kb-segment-size limit of far addressing on 80x86 machines. + * On those machines, we expect that jconfig.h will provide a proper value. + * On machines with 32-bit flat address spaces, any large constant may be used. + * + * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type + * size_t and will be a multiple of sizeof(align_type). + */ + +#ifndef MAX_ALLOC_CHUNK /* may be overridden in jconfig.h */ +#define MAX_ALLOC_CHUNK 1000000000L +#endif + +/* + * This routine computes the total space still available for allocation by + * jpeg_get_large. If more space than this is needed, backing store will be + * used. NOTE: any memory already allocated must not be counted. + * + * There is a minimum space requirement, corresponding to the minimum + * feasible buffer sizes; jmemmgr.c will request that much space even if + * jpeg_mem_available returns zero. The maximum space needed, enough to hold + * all working storage in memory, is also passed in case it is useful. + * Finally, the total space already allocated is passed. If no better + * method is available, cinfo->mem->max_memory_to_use - already_allocated + * is often a suitable calculation. + * + * It is OK for jpeg_mem_available to underestimate the space available + * (that'll just lead to more backing-store access than is really necessary). + * However, an overestimate will lead to failure. Hence it's wise to subtract + * a slop factor from the true available space. 5% should be enough. + * + * On machines with lots of virtual memory, any large constant may be returned. + * Conversely, zero may be returned to always use the minimum amount of memory. + */ + +EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo, + long min_bytes_needed, + long max_bytes_needed, + long already_allocated)); + + +/* + * This structure holds whatever state is needed to access a single + * backing-store object. The read/write/close method pointers are called + * by jmemmgr.c to manipulate the backing-store object; all other fields + * are private to the system-dependent backing store routines. + */ + +#define TEMP_NAME_LENGTH 64 /* max length of a temporary file's name */ + + +#ifdef USE_MSDOS_MEMMGR /* DOS-specific junk */ + +typedef unsigned short XMSH; /* type of extended-memory handles */ +typedef unsigned short EMSH; /* type of expanded-memory handles */ + +typedef union { + short file_handle; /* DOS file handle if it's a temp file */ + XMSH xms_handle; /* handle if it's a chunk of XMS */ + EMSH ems_handle; /* handle if it's a chunk of EMS */ +} handle_union; + +#endif /* USE_MSDOS_MEMMGR */ + +#ifdef USE_MAC_MEMMGR /* Mac-specific junk */ +#include +#endif /* USE_MAC_MEMMGR */ + + +typedef struct backing_store_struct * backing_store_ptr; + +typedef struct backing_store_struct { + /* Methods for reading/writing/closing this backing-store object */ + JMETHOD(void, read_backing_store, (j_common_ptr cinfo, + backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count)); + JMETHOD(void, write_backing_store, (j_common_ptr cinfo, + backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count)); + JMETHOD(void, close_backing_store, (j_common_ptr cinfo, + backing_store_ptr info)); + + /* Private fields for system-dependent backing-store management */ +#ifdef USE_MSDOS_MEMMGR + /* For the MS-DOS manager (jmemdos.c), we need: */ + handle_union handle; /* reference to backing-store storage object */ + char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ +#else +#ifdef USE_MAC_MEMMGR + /* For the Mac manager (jmemmac.c), we need: */ + short temp_file; /* file reference number to temp file */ + FSSpec tempSpec; /* the FSSpec for the temp file */ + char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ +#else + /* For a typical implementation with temp files, we need: */ + FILE * temp_file; /* stdio reference to temp file */ + char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */ +#endif +#endif +} backing_store_info; + + +/* + * Initial opening of a backing-store object. This must fill in the + * read/write/close pointers in the object. The read/write routines + * may take an error exit if the specified maximum file size is exceeded. + * (If jpeg_mem_available always returns a large value, this routine can + * just take an error exit.) + */ + +EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo, + backing_store_ptr info, + long total_bytes_needed)); + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. jpeg_mem_init will be called before anything is + * allocated (and, therefore, nothing in cinfo is of use except the error + * manager pointer). It should return a suitable default value for + * max_memory_to_use; this may subsequently be overridden by the surrounding + * application. (Note that max_memory_to_use is only important if + * jpeg_mem_available chooses to consult it ... no one else will.) + * jpeg_mem_term may assume that all requested memory has been freed and that + * all opened backing-store objects have been closed. + */ + +EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo)); +EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo)); diff --git a/src/dep/src/irrlicht/jpeglib/jmorecfg.h b/src/dep/src/irrlicht/jpeglib/jmorecfg.h index c856e22..54a7d1c 100644 --- a/src/dep/src/irrlicht/jpeglib/jmorecfg.h +++ b/src/dep/src/irrlicht/jpeglib/jmorecfg.h @@ -1,363 +1,363 @@ -/* - * jmorecfg.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains additional configuration options that customize the - * JPEG software for special applications or support machine-dependent - * optimizations. Most users will not need to touch this file. - */ - - -/* - * Define BITS_IN_JSAMPLE as either - * 8 for 8-bit sample values (the usual setting) - * 12 for 12-bit sample values - * Only 8 and 12 are legal data precisions for lossy JPEG according to the - * JPEG standard, and the IJG code does not support anything else! - * We do not support run-time selection of data precision, sorry. - */ - -#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ - - -/* - * Maximum number of components (color channels) allowed in JPEG image. - * To meet the letter of the JPEG spec, set this to 255. However, darn - * few applications need more than 4 channels (maybe 5 for CMYK + alpha - * mask). We recommend 10 as a reasonable compromise; use 4 if you are - * really short on memory. (Each allowed component costs a hundred or so - * bytes of storage, whether actually used in an image or not.) - */ - -#define MAX_COMPONENTS 10 /* maximum number of image components */ - - -/* - * Basic data types. - * You may need to change these if you have a machine with unusual data - * type sizes; for example, "char" not 8 bits, "short" not 16 bits, - * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, - * but it had better be at least 16. - */ - -/* Representation of a single sample (pixel element value). - * We frequently allocate large arrays of these, so it's important to keep - * them small. But if you have memory to burn and access to char or short - * arrays is very slow on your hardware, you might want to change these. - */ - -#if BITS_IN_JSAMPLE == 8 -/* JSAMPLE should be the smallest type that will hold the values 0..255. - * You can use a signed char by having GETJSAMPLE mask it with 0xFF. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JSAMPLE; -#ifdef CHAR_IS_UNSIGNED -#define GETJSAMPLE(value) ((int) (value)) -#else -#define GETJSAMPLE(value) ((int) (value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - -#define MAXJSAMPLE 255 -#define CENTERJSAMPLE 128 - -#endif /* BITS_IN_JSAMPLE == 8 */ - - -#if BITS_IN_JSAMPLE == 12 -/* JSAMPLE should be the smallest type that will hold the values 0..4095. - * On nearly all machines "short" will do nicely. - */ - -typedef short JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#define MAXJSAMPLE 4095 -#define CENTERJSAMPLE 2048 - -#endif /* BITS_IN_JSAMPLE == 12 */ - - -/* Representation of a DCT frequency coefficient. - * This should be a signed value of at least 16 bits; "short" is usually OK. - * Again, we allocate large arrays of these, but you can change to int - * if you have memory to burn and "short" is really slow. - */ - -typedef short JCOEF; - - -/* Compressed datastreams are represented as arrays of JOCTET. - * These must be EXACTLY 8 bits wide, at least once they are written to - * external storage. Note that when using the stdio data source/destination - * managers, this is also the data type passed to fread/fwrite. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JOCTET; -#define GETJOCTET(value) (value) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JOCTET; -#ifdef CHAR_IS_UNSIGNED -#define GETJOCTET(value) (value) -#else -#define GETJOCTET(value) ((value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - - -/* These typedefs are used for various table entries and so forth. - * They must be at least as wide as specified; but making them too big - * won't cost a huge amount of memory, so we don't provide special - * extraction code like we did for JSAMPLE. (In other words, these - * typedefs live at a different point on the speed/space tradeoff curve.) - */ - -/* UINT8 must hold at least the values 0..255. */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char UINT8; -#else /* not HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char UINT8; -#else /* not CHAR_IS_UNSIGNED */ -typedef short UINT8; -#endif /* CHAR_IS_UNSIGNED */ -#endif /* HAVE_UNSIGNED_CHAR */ - -/* UINT16 must hold at least the values 0..65535. */ - -#ifdef HAVE_UNSIGNED_SHORT -typedef unsigned short UINT16; -#else /* not HAVE_UNSIGNED_SHORT */ -typedef unsigned int UINT16; -#endif /* HAVE_UNSIGNED_SHORT */ - -/* INT16 must hold at least the values -32768..32767. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ -typedef short INT16; -#endif - -/* INT32 must hold at least signed 32-bit values. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ -typedef long INT32; -#endif - -/* Datatype used for image dimensions. The JPEG standard only supports - * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore - * "unsigned int" is sufficient on all machines. However, if you need to - * handle larger images and you don't mind deviating from the spec, you - * can change this datatype. - */ - -typedef unsigned int JDIMENSION; - -#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ - - -/* These macros are used in all function definitions and extern declarations. - * You could modify them if you need to change function linkage conventions; - * in particular, you'll need to do that to make the library a Windows DLL. - * Another application is to make all functions global for use with debuggers - * or code profilers that require it. - */ - -/* a function called through method pointers: */ -#define METHODDEF(type) static type -/* a function used only in its module: */ -#define LOCAL(type) static type -/* a function referenced thru EXTERNs: */ -#define GLOBAL(type) type -/* a reference to a GLOBAL function: */ -#define EXTERN(type) extern type - - -/* This macro is used to declare a "method", that is, a function pointer. - * We want to supply prototype parameters if the compiler can cope. - * Note that the arglist parameter must be parenthesized! - * Again, you can customize this if you need special linkage keywords. - */ - -#ifdef HAVE_PROTOTYPES -#define JMETHOD(type,methodname,arglist) type (*methodname) arglist -#else -#define JMETHOD(type,methodname,arglist) type (*methodname) () -#endif - - -/* Here is the pseudo-keyword for declaring pointers that must be "far" - * on 80x86 machines. Most of the specialized coding for 80x86 is handled - * by just saying "FAR *" where such a pointer is needed. In a few places - * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. - */ - -#ifdef NEED_FAR_POINTERS -#define FAR far -#else -#define FAR -#endif - - -/* - * On a few systems, type boolean and/or its values FALSE, TRUE may appear - * in standard header files. Or you may have conflicts with application- - * specific header files that you want to include together with these files. - * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. - */ - -#ifndef HAVE_BOOLEAN -typedef int boolean; -#endif -#ifndef FALSE /* in case these macros already exist */ -#define FALSE 0 /* values of boolean */ -#endif -#ifndef TRUE -#define TRUE 1 -#endif - - -/* - * The remaining options affect code selection within the JPEG library, - * but they don't need to be visible to most applications using the library. - * To minimize application namespace pollution, the symbols won't be - * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. - */ - -#ifdef JPEG_INTERNALS -#define JPEG_INTERNAL_OPTIONS -#endif - -#ifdef JPEG_INTERNAL_OPTIONS - - -/* - * These defines indicate whether to include various optional functions. - * Undefining some of these symbols will produce a smaller but less capable - * library. Note that you can leave certain source files out of the - * compilation/linking process if you've #undef'd the corresponding symbols. - * (You may HAVE to do that if your compiler doesn't like null source files.) - */ - -/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ - -/* Capability options common to encoder and decoder: */ - -#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ -#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ -#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ - -/* Encoder capability options: */ - -#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ -/* Note: if you selected 12-bit data precision, it is dangerous to turn off - * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit - * precision, so jchuff.c normally uses entropy optimization to compute - * usable tables for higher precision. If you don't want to do optimization, - * you'll have to supply different default Huffman tables. - * The exact same statements apply for progressive JPEG: the default tables - * don't work for progressive mode. (This may get fixed, however.) - */ -#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ - -/* Decoder capability options: */ - -#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ -#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ -#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ -#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ -#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ -#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ -#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ - -/* more capability options later, no doubt */ - - -/* - * Ordering of RGB data in scanlines passed to or from the application. - * If your application wants to deal with data in the order B,G,R, just - * change these macros. You can also deal with formats such as R,G,B,X - * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing - * the offsets will also change the order in which colormap data is organized. - * RESTRICTIONS: - * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. - * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not - * useful if you are using JPEG color spaces other than YCbCr or grayscale. - * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE - * is not 3 (they don't understand about dummy color components!). So you - * can't use color quantization if you change that value. - */ - -#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ -#define RGB_GREEN 1 /* Offset of Green */ -#define RGB_BLUE 2 /* Offset of Blue */ -#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ - - -/* Definitions for speed-related optimizations. */ - - -/* If your compiler supports inline functions, define INLINE - * as the inline keyword; otherwise define it as empty. - */ - -#ifndef INLINE -#ifdef __GNUC__ /* for instance, GNU C knows about inline */ -#define INLINE __inline__ -#endif -#ifndef INLINE -#define INLINE /* default is to define it as empty */ -#endif -#endif - - -/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying - * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER - * as short on such a machine. MULTIPLIER must be at least 16 bits wide. - */ - -#ifndef MULTIPLIER -#define MULTIPLIER int /* type for fastest integer multiply */ -#endif - - -/* FAST_FLOAT should be either float or double, whichever is done faster - * by your compiler. (Note that this type is only used in the floating point - * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) - * Typically, float is faster in ANSI C compilers, while double is faster in - * pre-ANSI compilers (because they insist on converting to double anyway). - * The code below therefore chooses float if we have ANSI-style prototypes. - */ - -#ifndef FAST_FLOAT -#ifdef HAVE_PROTOTYPES -#define FAST_FLOAT float -#else -#define FAST_FLOAT double -#endif -#endif - -#endif /* JPEG_INTERNAL_OPTIONS */ +/* + * jmorecfg.h + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains additional configuration options that customize the + * JPEG software for special applications or support machine-dependent + * optimizations. Most users will not need to touch this file. + */ + + +/* + * Define BITS_IN_JSAMPLE as either + * 8 for 8-bit sample values (the usual setting) + * 12 for 12-bit sample values + * Only 8 and 12 are legal data precisions for lossy JPEG according to the + * JPEG standard, and the IJG code does not support anything else! + * We do not support run-time selection of data precision, sorry. + */ + +#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ + + +/* + * Maximum number of components (color channels) allowed in JPEG image. + * To meet the letter of the JPEG spec, set this to 255. However, darn + * few applications need more than 4 channels (maybe 5 for CMYK + alpha + * mask). We recommend 10 as a reasonable compromise; use 4 if you are + * really short on memory. (Each allowed component costs a hundred or so + * bytes of storage, whether actually used in an image or not.) + */ + +#define MAX_COMPONENTS 10 /* maximum number of image components */ + + +/* + * Basic data types. + * You may need to change these if you have a machine with unusual data + * type sizes; for example, "char" not 8 bits, "short" not 16 bits, + * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, + * but it had better be at least 16. + */ + +/* Representation of a single sample (pixel element value). + * We frequently allocate large arrays of these, so it's important to keep + * them small. But if you have memory to burn and access to char or short + * arrays is very slow on your hardware, you might want to change these. + */ + +#if BITS_IN_JSAMPLE == 8 +/* JSAMPLE should be the smallest type that will hold the values 0..255. + * You can use a signed char by having GETJSAMPLE mask it with 0xFF. + */ + +#ifdef HAVE_UNSIGNED_CHAR + +typedef unsigned char JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#else /* not HAVE_UNSIGNED_CHAR */ + +typedef char JSAMPLE; +#ifdef CHAR_IS_UNSIGNED +#define GETJSAMPLE(value) ((int) (value)) +#else +#define GETJSAMPLE(value) ((int) (value) & 0xFF) +#endif /* CHAR_IS_UNSIGNED */ + +#endif /* HAVE_UNSIGNED_CHAR */ + +#define MAXJSAMPLE 255 +#define CENTERJSAMPLE 128 + +#endif /* BITS_IN_JSAMPLE == 8 */ + + +#if BITS_IN_JSAMPLE == 12 +/* JSAMPLE should be the smallest type that will hold the values 0..4095. + * On nearly all machines "short" will do nicely. + */ + +typedef short JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#define MAXJSAMPLE 4095 +#define CENTERJSAMPLE 2048 + +#endif /* BITS_IN_JSAMPLE == 12 */ + + +/* Representation of a DCT frequency coefficient. + * This should be a signed value of at least 16 bits; "short" is usually OK. + * Again, we allocate large arrays of these, but you can change to int + * if you have memory to burn and "short" is really slow. + */ + +typedef short JCOEF; + + +/* Compressed datastreams are represented as arrays of JOCTET. + * These must be EXACTLY 8 bits wide, at least once they are written to + * external storage. Note that when using the stdio data source/destination + * managers, this is also the data type passed to fread/fwrite. + */ + +#ifdef HAVE_UNSIGNED_CHAR + +typedef unsigned char JOCTET; +#define GETJOCTET(value) (value) + +#else /* not HAVE_UNSIGNED_CHAR */ + +typedef char JOCTET; +#ifdef CHAR_IS_UNSIGNED +#define GETJOCTET(value) (value) +#else +#define GETJOCTET(value) ((value) & 0xFF) +#endif /* CHAR_IS_UNSIGNED */ + +#endif /* HAVE_UNSIGNED_CHAR */ + + +/* These typedefs are used for various table entries and so forth. + * They must be at least as wide as specified; but making them too big + * won't cost a huge amount of memory, so we don't provide special + * extraction code like we did for JSAMPLE. (In other words, these + * typedefs live at a different point on the speed/space tradeoff curve.) + */ + +/* UINT8 must hold at least the values 0..255. */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char UINT8; +#else /* not HAVE_UNSIGNED_CHAR */ +#ifdef CHAR_IS_UNSIGNED +typedef char UINT8; +#else /* not CHAR_IS_UNSIGNED */ +typedef short UINT8; +#endif /* CHAR_IS_UNSIGNED */ +#endif /* HAVE_UNSIGNED_CHAR */ + +/* UINT16 must hold at least the values 0..65535. */ + +#ifdef HAVE_UNSIGNED_SHORT +typedef unsigned short UINT16; +#else /* not HAVE_UNSIGNED_SHORT */ +typedef unsigned int UINT16; +#endif /* HAVE_UNSIGNED_SHORT */ + +/* INT16 must hold at least the values -32768..32767. */ + +#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ +typedef short INT16; +#endif + +/* INT32 must hold at least signed 32-bit values. */ + +#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ +typedef long INT32; +#endif + +/* Datatype used for image dimensions. The JPEG standard only supports + * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore + * "unsigned int" is sufficient on all machines. However, if you need to + * handle larger images and you don't mind deviating from the spec, you + * can change this datatype. + */ + +typedef unsigned int JDIMENSION; + +#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ + + +/* These macros are used in all function definitions and extern declarations. + * You could modify them if you need to change function linkage conventions; + * in particular, you'll need to do that to make the library a Windows DLL. + * Another application is to make all functions global for use with debuggers + * or code profilers that require it. + */ + +/* a function called through method pointers: */ +#define METHODDEF(type) static type +/* a function used only in its module: */ +#define LOCAL(type) static type +/* a function referenced thru EXTERNs: */ +#define GLOBAL(type) type +/* a reference to a GLOBAL function: */ +#define EXTERN(type) extern type + + +/* This macro is used to declare a "method", that is, a function pointer. + * We want to supply prototype parameters if the compiler can cope. + * Note that the arglist parameter must be parenthesized! + * Again, you can customize this if you need special linkage keywords. + */ + +#ifdef HAVE_PROTOTYPES +#define JMETHOD(type,methodname,arglist) type (*methodname) arglist +#else +#define JMETHOD(type,methodname,arglist) type (*methodname) () +#endif + + +/* Here is the pseudo-keyword for declaring pointers that must be "far" + * on 80x86 machines. Most of the specialized coding for 80x86 is handled + * by just saying "FAR *" where such a pointer is needed. In a few places + * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. + */ + +#ifdef NEED_FAR_POINTERS +#define FAR far +#else +#define FAR +#endif + + +/* + * On a few systems, type boolean and/or its values FALSE, TRUE may appear + * in standard header files. Or you may have conflicts with application- + * specific header files that you want to include together with these files. + * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. + */ + +#ifndef HAVE_BOOLEAN +typedef int boolean; +#endif +#ifndef FALSE /* in case these macros already exist */ +#define FALSE 0 /* values of boolean */ +#endif +#ifndef TRUE +#define TRUE 1 +#endif + + +/* + * The remaining options affect code selection within the JPEG library, + * but they don't need to be visible to most applications using the library. + * To minimize application namespace pollution, the symbols won't be + * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. + */ + +#ifdef JPEG_INTERNALS +#define JPEG_INTERNAL_OPTIONS +#endif + +#ifdef JPEG_INTERNAL_OPTIONS + + +/* + * These defines indicate whether to include various optional functions. + * Undefining some of these symbols will produce a smaller but less capable + * library. Note that you can leave certain source files out of the + * compilation/linking process if you've #undef'd the corresponding symbols. + * (You may HAVE to do that if your compiler doesn't like null source files.) + */ + +/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ + +/* Capability options common to encoder and decoder: */ + +#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ +#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ +#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ + +/* Encoder capability options: */ + +#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ +#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ +#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ +#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ +/* Note: if you selected 12-bit data precision, it is dangerous to turn off + * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit + * precision, so jchuff.c normally uses entropy optimization to compute + * usable tables for higher precision. If you don't want to do optimization, + * you'll have to supply different default Huffman tables. + * The exact same statements apply for progressive JPEG: the default tables + * don't work for progressive mode. (This may get fixed, however.) + */ +#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ + +/* Decoder capability options: */ + +#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ +#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ +#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ +#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ +#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ +#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ +#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ +#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ +#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ +#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ + +/* more capability options later, no doubt */ + + +/* + * Ordering of RGB data in scanlines passed to or from the application. + * If your application wants to deal with data in the order B,G,R, just + * change these macros. You can also deal with formats such as R,G,B,X + * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing + * the offsets will also change the order in which colormap data is organized. + * RESTRICTIONS: + * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. + * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not + * useful if you are using JPEG color spaces other than YCbCr or grayscale. + * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE + * is not 3 (they don't understand about dummy color components!). So you + * can't use color quantization if you change that value. + */ + +#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ +#define RGB_GREEN 1 /* Offset of Green */ +#define RGB_BLUE 2 /* Offset of Blue */ +#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ + + +/* Definitions for speed-related optimizations. */ + + +/* If your compiler supports inline functions, define INLINE + * as the inline keyword; otherwise define it as empty. + */ + +#ifndef INLINE +#ifdef __GNUC__ /* for instance, GNU C knows about inline */ +#define INLINE __inline__ +#endif +#ifndef INLINE +#define INLINE /* default is to define it as empty */ +#endif +#endif + + +/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying + * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER + * as short on such a machine. MULTIPLIER must be at least 16 bits wide. + */ + +#ifndef MULTIPLIER +#define MULTIPLIER int /* type for fastest integer multiply */ +#endif + + +/* FAST_FLOAT should be either float or double, whichever is done faster + * by your compiler. (Note that this type is only used in the floating point + * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) + * Typically, float is faster in ANSI C compilers, while double is faster in + * pre-ANSI compilers (because they insist on converting to double anyway). + * The code below therefore chooses float if we have ANSI-style prototypes. + */ + +#ifndef FAST_FLOAT +#ifdef HAVE_PROTOTYPES +#define FAST_FLOAT float +#else +#define FAST_FLOAT double +#endif +#endif + +#endif /* JPEG_INTERNAL_OPTIONS */ diff --git a/src/dep/src/irrlicht/jpeglib/jpegint.h b/src/dep/src/irrlicht/jpeglib/jpegint.h index 685a361..95b00d4 100644 --- a/src/dep/src/irrlicht/jpeglib/jpegint.h +++ b/src/dep/src/irrlicht/jpeglib/jpegint.h @@ -1,392 +1,392 @@ -/* - * jpegint.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides common declarations for the various JPEG modules. - * These declarations are considered internal to the JPEG library; most - * applications using the library shouldn't need to include this file. - */ - - -/* Declarations for both compression & decompression */ - -typedef enum { /* Operating modes for buffer controllers */ - JBUF_PASS_THRU, /* Plain stripwise operation */ - /* Remaining modes require a full-image buffer to have been created */ - JBUF_SAVE_SOURCE, /* Run source subobject only, save output */ - JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */ - JBUF_SAVE_AND_PASS /* Run both subobjects, save output */ -} J_BUF_MODE; - -/* Values of global_state field (jdapi.c has some dependencies on ordering!) */ -#define CSTATE_START 100 /* after create_compress */ -#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */ -#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */ -#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */ -#define DSTATE_START 200 /* after create_decompress */ -#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */ -#define DSTATE_READY 202 /* found SOS, ready for start_decompress */ -#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/ -#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */ -#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */ -#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */ -#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */ -#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */ -#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */ -#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */ - - -/* Declarations for compression modules */ - -/* Master control module */ -struct jpeg_comp_master { - JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo)); - JMETHOD(void, pass_startup, (j_compress_ptr cinfo)); - JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean call_pass_startup; /* True if pass_startup must be called */ - boolean is_last_pass; /* True during last pass */ -}; - -/* Main buffer control (downsampled-data buffer) */ -struct jpeg_c_main_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, process_data, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail)); -}; - -/* Compression preprocessing (downsampling input buffer control) */ -struct jpeg_c_prep_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, pre_process_data, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, - JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail)); -}; - -/* Coefficient buffer control */ -struct jpeg_c_coef_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(boolean, compress_data, (j_compress_ptr cinfo, - JSAMPIMAGE input_buf)); -}; - -/* Colorspace conversion */ -struct jpeg_color_converter { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - JMETHOD(void, color_convert, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows)); -}; - -/* Downsampling */ -struct jpeg_downsampler { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - JMETHOD(void, downsample, (j_compress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_index, - JSAMPIMAGE output_buf, - JDIMENSION out_row_group_index)); - - boolean need_context_rows; /* TRUE if need rows above & below */ -}; - -/* Forward DCT (also controls coefficient quantization) */ -struct jpeg_forward_dct { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - /* perhaps this should be an array??? */ - JMETHOD(void, forward_DCT, (j_compress_ptr cinfo, - jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks)); -}; - -/* Entropy encoding */ -struct jpeg_entropy_encoder { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics)); - JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data)); - JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); -}; - -/* Marker writing */ -struct jpeg_marker_writer { - JMETHOD(void, write_file_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_frame_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_scan_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo)); - JMETHOD(void, write_tables_only, (j_compress_ptr cinfo)); - /* These routines are exported to allow insertion of extra markers */ - /* Probably only COM and APPn markers should be written this way */ - JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker, - unsigned int datalen)); - JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val)); -}; - - -/* Declarations for decompression modules */ - -/* Master control module */ -struct jpeg_decomp_master { - JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */ -}; - -/* Input control module */ -struct jpeg_input_controller { - JMETHOD(int, consume_input, (j_decompress_ptr cinfo)); - JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo)); - JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean has_multiple_scans; /* True if file has multiple scans */ - boolean eoi_reached; /* True when EOI has been consumed */ -}; - -/* Main buffer control (downsampled-data buffer) */ -struct jpeg_d_main_controller { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, process_data, (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -}; - -/* Coefficient buffer control */ -struct jpeg_d_coef_controller { - JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); - JMETHOD(int, consume_data, (j_decompress_ptr cinfo)); - JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo)); - JMETHOD(int, decompress_data, (j_decompress_ptr cinfo, - JSAMPIMAGE output_buf)); - /* Pointer to array of coefficient virtual arrays, or NULL if none */ - jvirt_barray_ptr *coef_arrays; -}; - -/* Decompression postprocessing (color quantization buffer control) */ -struct jpeg_d_post_controller { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, post_process_data, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, - JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -}; - -/* Marker reading & parsing */ -struct jpeg_marker_reader { - JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo)); - /* Read markers until SOS or EOI. - * Returns same codes as are defined for jpeg_consume_input: - * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - */ - JMETHOD(int, read_markers, (j_decompress_ptr cinfo)); - /* Read a restart marker --- exported for use by entropy decoder only */ - jpeg_marker_parser_method read_restart_marker; - - /* State of marker reader --- nominally internal, but applications - * supplying COM or APPn handlers might like to know the state. - */ - boolean saw_SOI; /* found SOI? */ - boolean saw_SOF; /* found SOF? */ - int next_restart_num; /* next restart number expected (0-7) */ - unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */ -}; - -/* Entropy decoding */ -struct jpeg_entropy_decoder { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); - - /* This is here to share code between baseline and progressive decoders; */ - /* other modules probably should not use it */ - boolean insufficient_data; /* set TRUE after emitting warning */ -}; - -/* Inverse DCT (also performs dequantization) */ -typedef JMETHOD(void, inverse_DCT_method_ptr, - (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col)); - -struct jpeg_inverse_dct { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - /* It is useful to allow each component to have a separate IDCT method. */ - inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]; -}; - -/* Upsampling (note that upsampler must also call color converter) */ -struct jpeg_upsampler { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, upsample, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, - JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); - - boolean need_context_rows; /* TRUE if need rows above & below */ -}; - -/* Colorspace conversion */ -struct jpeg_color_deconverter { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, color_convert, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows)); -}; - -/* Color quantization or color precision reduction */ -struct jpeg_color_quantizer { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan)); - JMETHOD(void, color_quantize, (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, - int num_rows)); - JMETHOD(void, finish_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, new_color_map, (j_decompress_ptr cinfo)); -}; - - -/* Miscellaneous useful macros */ - -#undef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#undef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - - -/* We assume that right shift corresponds to signed division by 2 with - * rounding towards minus infinity. This is correct for typical "arithmetic - * shift" instructions that shift in copies of the sign bit. But some - * C compilers implement >> with an unsigned shift. For these machines you - * must define RIGHT_SHIFT_IS_UNSIGNED. - * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity. - * It is only applied with constant shift counts. SHIFT_TEMPS must be - * included in the variables of any routine using RIGHT_SHIFT. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define SHIFT_TEMPS INT32 shift_temp; -#define RIGHT_SHIFT(x,shft) \ - ((shift_temp = (x)) < 0 ? \ - (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \ - (shift_temp >> (shft))) -#else -#define SHIFT_TEMPS -#define RIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jinit_compress_master jICompress -#define jinit_c_master_control jICMaster -#define jinit_c_main_controller jICMainC -#define jinit_c_prep_controller jICPrepC -#define jinit_c_coef_controller jICCoefC -#define jinit_color_converter jICColor -#define jinit_downsampler jIDownsampler -#define jinit_forward_dct jIFDCT -#define jinit_huff_encoder jIHEncoder -#define jinit_phuff_encoder jIPHEncoder -#define jinit_marker_writer jIMWriter -#define jinit_master_decompress jIDMaster -#define jinit_d_main_controller jIDMainC -#define jinit_d_coef_controller jIDCoefC -#define jinit_d_post_controller jIDPostC -#define jinit_input_controller jIInCtlr -#define jinit_marker_reader jIMReader -#define jinit_huff_decoder jIHDecoder -#define jinit_phuff_decoder jIPHDecoder -#define jinit_inverse_dct jIIDCT -#define jinit_upsampler jIUpsampler -#define jinit_color_deconverter jIDColor -#define jinit_1pass_quantizer jI1Quant -#define jinit_2pass_quantizer jI2Quant -#define jinit_merged_upsampler jIMUpsampler -#define jinit_memory_mgr jIMemMgr -#define jdiv_round_up jDivRound -#define jround_up jRound -#define jcopy_sample_rows jCopySamples -#define jcopy_block_row jCopyBlocks -#define jzero_far jZeroFar -#define jpeg_zigzag_order jZIGTable -#define jpeg_natural_order jZAGTable -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Compression module initialization routines */ -EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo, - boolean transcode_only)); -EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo)); -/* Decompression module initialization routines */ -EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo)); -/* Memory manager initialization */ -EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo)); - -/* Utility routines in jutils.c */ -EXTERN(long) jdiv_round_up JPP((long a, long b)); -EXTERN(long) jround_up JPP((long a, long b)); -EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row, - JSAMPARRAY output_array, int dest_row, - int num_rows, JDIMENSION num_cols)); -EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, - JDIMENSION num_blocks)); -EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero)); -/* Constant tables in jutils.c */ -#if 0 /* This table is not actually needed in v6a */ -extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ -#endif -extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ - -/* Suppress undefined-structure complaints if necessary. */ - -#ifdef INCOMPLETE_TYPES_BROKEN -#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */ -struct jvirt_sarray_control { long dummy; }; -struct jvirt_barray_control { long dummy; }; -#endif -#endif /* INCOMPLETE_TYPES_BROKEN */ +/* + * jpegint.h + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides common declarations for the various JPEG modules. + * These declarations are considered internal to the JPEG library; most + * applications using the library shouldn't need to include this file. + */ + + +/* Declarations for both compression & decompression */ + +typedef enum { /* Operating modes for buffer controllers */ + JBUF_PASS_THRU, /* Plain stripwise operation */ + /* Remaining modes require a full-image buffer to have been created */ + JBUF_SAVE_SOURCE, /* Run source subobject only, save output */ + JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */ + JBUF_SAVE_AND_PASS /* Run both subobjects, save output */ +} J_BUF_MODE; + +/* Values of global_state field (jdapi.c has some dependencies on ordering!) */ +#define CSTATE_START 100 /* after create_compress */ +#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */ +#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */ +#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */ +#define DSTATE_START 200 /* after create_decompress */ +#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */ +#define DSTATE_READY 202 /* found SOS, ready for start_decompress */ +#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/ +#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */ +#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */ +#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */ +#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */ +#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */ +#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */ +#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */ + + +/* Declarations for compression modules */ + +/* Master control module */ +struct jpeg_comp_master { + JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo)); + JMETHOD(void, pass_startup, (j_compress_ptr cinfo)); + JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); + + /* State variables made visible to other modules */ + boolean call_pass_startup; /* True if pass_startup must be called */ + boolean is_last_pass; /* True during last pass */ +}; + +/* Main buffer control (downsampled-data buffer) */ +struct jpeg_c_main_controller { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, process_data, (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail)); +}; + +/* Compression preprocessing (downsampling input buffer control) */ +struct jpeg_c_prep_controller { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, pre_process_data, (j_compress_ptr cinfo, + JSAMPARRAY input_buf, + JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail, + JSAMPIMAGE output_buf, + JDIMENSION *out_row_group_ctr, + JDIMENSION out_row_groups_avail)); +}; + +/* Coefficient buffer control */ +struct jpeg_c_coef_controller { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(boolean, compress_data, (j_compress_ptr cinfo, + JSAMPIMAGE input_buf)); +}; + +/* Colorspace conversion */ +struct jpeg_color_converter { + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); + JMETHOD(void, color_convert, (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows)); +}; + +/* Downsampling */ +struct jpeg_downsampler { + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); + JMETHOD(void, downsample, (j_compress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_index, + JSAMPIMAGE output_buf, + JDIMENSION out_row_group_index)); + + boolean need_context_rows; /* TRUE if need rows above & below */ +}; + +/* Forward DCT (also controls coefficient quantization) */ +struct jpeg_forward_dct { + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); + /* perhaps this should be an array??? */ + JMETHOD(void, forward_DCT, (j_compress_ptr cinfo, + jpeg_component_info * compptr, + JSAMPARRAY sample_data, JBLOCKROW coef_blocks, + JDIMENSION start_row, JDIMENSION start_col, + JDIMENSION num_blocks)); +}; + +/* Entropy encoding */ +struct jpeg_entropy_encoder { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics)); + JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data)); + JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); +}; + +/* Marker writing */ +struct jpeg_marker_writer { + JMETHOD(void, write_file_header, (j_compress_ptr cinfo)); + JMETHOD(void, write_frame_header, (j_compress_ptr cinfo)); + JMETHOD(void, write_scan_header, (j_compress_ptr cinfo)); + JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo)); + JMETHOD(void, write_tables_only, (j_compress_ptr cinfo)); + /* These routines are exported to allow insertion of extra markers */ + /* Probably only COM and APPn markers should be written this way */ + JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker, + unsigned int datalen)); + JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val)); +}; + + +/* Declarations for decompression modules */ + +/* Master control module */ +struct jpeg_decomp_master { + JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo)); + + /* State variables made visible to other modules */ + boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */ +}; + +/* Input control module */ +struct jpeg_input_controller { + JMETHOD(int, consume_input, (j_decompress_ptr cinfo)); + JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo)); + JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo)); + + /* State variables made visible to other modules */ + boolean has_multiple_scans; /* True if file has multiple scans */ + boolean eoi_reached; /* True when EOI has been consumed */ +}; + +/* Main buffer control (downsampled-data buffer) */ +struct jpeg_d_main_controller { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, process_data, (j_decompress_ptr cinfo, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +}; + +/* Coefficient buffer control */ +struct jpeg_d_coef_controller { + JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); + JMETHOD(int, consume_data, (j_decompress_ptr cinfo)); + JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo)); + JMETHOD(int, decompress_data, (j_decompress_ptr cinfo, + JSAMPIMAGE output_buf)); + /* Pointer to array of coefficient virtual arrays, or NULL if none */ + jvirt_barray_ptr *coef_arrays; +}; + +/* Decompression postprocessing (color quantization buffer control) */ +struct jpeg_d_post_controller { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, post_process_data, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, + JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +}; + +/* Marker reading & parsing */ +struct jpeg_marker_reader { + JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo)); + /* Read markers until SOS or EOI. + * Returns same codes as are defined for jpeg_consume_input: + * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. + */ + JMETHOD(int, read_markers, (j_decompress_ptr cinfo)); + /* Read a restart marker --- exported for use by entropy decoder only */ + jpeg_marker_parser_method read_restart_marker; + + /* State of marker reader --- nominally internal, but applications + * supplying COM or APPn handlers might like to know the state. + */ + boolean saw_SOI; /* found SOI? */ + boolean saw_SOF; /* found SOF? */ + int next_restart_num; /* next restart number expected (0-7) */ + unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */ +}; + +/* Entropy decoding */ +struct jpeg_entropy_decoder { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); + + /* This is here to share code between baseline and progressive decoders; */ + /* other modules probably should not use it */ + boolean insufficient_data; /* set TRUE after emitting warning */ +}; + +/* Inverse DCT (also performs dequantization) */ +typedef JMETHOD(void, inverse_DCT_method_ptr, + (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col)); + +struct jpeg_inverse_dct { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + /* It is useful to allow each component to have a separate IDCT method. */ + inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]; +}; + +/* Upsampling (note that upsampler must also call color converter) */ +struct jpeg_upsampler { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, upsample, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, + JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); + + boolean need_context_rows; /* TRUE if need rows above & below */ +}; + +/* Colorspace conversion */ +struct jpeg_color_deconverter { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, color_convert, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows)); +}; + +/* Color quantization or color precision reduction */ +struct jpeg_color_quantizer { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan)); + JMETHOD(void, color_quantize, (j_decompress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPARRAY output_buf, + int num_rows)); + JMETHOD(void, finish_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, new_color_map, (j_decompress_ptr cinfo)); +}; + + +/* Miscellaneous useful macros */ + +#undef MAX +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#undef MIN +#define MIN(a,b) ((a) < (b) ? (a) : (b)) + + +/* We assume that right shift corresponds to signed division by 2 with + * rounding towards minus infinity. This is correct for typical "arithmetic + * shift" instructions that shift in copies of the sign bit. But some + * C compilers implement >> with an unsigned shift. For these machines you + * must define RIGHT_SHIFT_IS_UNSIGNED. + * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity. + * It is only applied with constant shift counts. SHIFT_TEMPS must be + * included in the variables of any routine using RIGHT_SHIFT. + */ + +#ifdef RIGHT_SHIFT_IS_UNSIGNED +#define SHIFT_TEMPS INT32 shift_temp; +#define RIGHT_SHIFT(x,shft) \ + ((shift_temp = (x)) < 0 ? \ + (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \ + (shift_temp >> (shft))) +#else +#define SHIFT_TEMPS +#define RIGHT_SHIFT(x,shft) ((x) >> (shft)) +#endif + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jinit_compress_master jICompress +#define jinit_c_master_control jICMaster +#define jinit_c_main_controller jICMainC +#define jinit_c_prep_controller jICPrepC +#define jinit_c_coef_controller jICCoefC +#define jinit_color_converter jICColor +#define jinit_downsampler jIDownsampler +#define jinit_forward_dct jIFDCT +#define jinit_huff_encoder jIHEncoder +#define jinit_phuff_encoder jIPHEncoder +#define jinit_marker_writer jIMWriter +#define jinit_master_decompress jIDMaster +#define jinit_d_main_controller jIDMainC +#define jinit_d_coef_controller jIDCoefC +#define jinit_d_post_controller jIDPostC +#define jinit_input_controller jIInCtlr +#define jinit_marker_reader jIMReader +#define jinit_huff_decoder jIHDecoder +#define jinit_phuff_decoder jIPHDecoder +#define jinit_inverse_dct jIIDCT +#define jinit_upsampler jIUpsampler +#define jinit_color_deconverter jIDColor +#define jinit_1pass_quantizer jI1Quant +#define jinit_2pass_quantizer jI2Quant +#define jinit_merged_upsampler jIMUpsampler +#define jinit_memory_mgr jIMemMgr +#define jdiv_round_up jDivRound +#define jround_up jRound +#define jcopy_sample_rows jCopySamples +#define jcopy_block_row jCopyBlocks +#define jzero_far jZeroFar +#define jpeg_zigzag_order jZIGTable +#define jpeg_natural_order jZAGTable +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* Compression module initialization routines */ +EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo, + boolean transcode_only)); +EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo)); +/* Decompression module initialization routines */ +EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo)); +/* Memory manager initialization */ +EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo)); + +/* Utility routines in jutils.c */ +EXTERN(long) jdiv_round_up JPP((long a, long b)); +EXTERN(long) jround_up JPP((long a, long b)); +EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row, + JSAMPARRAY output_array, int dest_row, + int num_rows, JDIMENSION num_cols)); +EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, + JDIMENSION num_blocks)); +EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero)); +/* Constant tables in jutils.c */ +#if 0 /* This table is not actually needed in v6a */ +extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ +#endif +extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ + +/* Suppress undefined-structure complaints if necessary. */ + +#ifdef INCOMPLETE_TYPES_BROKEN +#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */ +struct jvirt_sarray_control { long dummy; }; +struct jvirt_barray_control { long dummy; }; +#endif +#endif /* INCOMPLETE_TYPES_BROKEN */ diff --git a/src/dep/src/irrlicht/jpeglib/jpeglib.h b/src/dep/src/irrlicht/jpeglib/jpeglib.h index b9356f3..d1be8dd 100644 --- a/src/dep/src/irrlicht/jpeglib/jpeglib.h +++ b/src/dep/src/irrlicht/jpeglib/jpeglib.h @@ -1,1096 +1,1096 @@ -/* - * jpeglib.h - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the application interface for the JPEG library. - * Most applications using the library need only include this file, - * and perhaps jerror.h if they want to know the exact error codes. - */ - -#ifndef JPEGLIB_H -#define JPEGLIB_H - -/* - * First we include the configuration files that record how this - * installation of the JPEG library is set up. jconfig.h can be - * generated automatically for many systems. jmorecfg.h contains - * manual configuration options that most people need not worry about. - */ - -#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ -#include "jconfig.h" /* widely used configuration options */ -#endif -#include "jmorecfg.h" /* seldom changed options */ - - -/* Version ID for the JPEG library. - * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". - */ - -#define JPEG_LIB_VERSION 62 /* Version 6b */ - - -/* Various constants determining the sizes of things. - * All of these are specified by the JPEG standard, so don't change them - * if you want to be compatible. - */ - -#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ -#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ -#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ -#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ -#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ -#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ -#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ -/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; - * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. - * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU - * to handle it. We even let you do this from the jconfig.h file. However, - * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe - * sometimes emits noncompliant files doesn't mean you should too. - */ -#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ -#ifndef D_MAX_BLOCKS_IN_MCU -#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ -#endif - - -/* Data structures for images (arrays of samples and of DCT coefficients). - * On 80x86 machines, the image arrays are too big for near pointers, - * but the pointer arrays can fit in near memory. - */ - -typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ -typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ -typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ - -typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ -typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ -typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ -typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ - -typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ - - -/* Types for JPEG compression parameters and working tables. */ - - -/* DCT coefficient quantization tables. */ - -typedef struct { - /* This array gives the coefficient quantizers in natural array order - * (not the zigzag order in which they are stored in a JPEG DQT marker). - * CAUTION: IJG versions prior to v6a kept this array in zigzag order. - */ - UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JQUANT_TBL; - - -/* Huffman coding tables. */ - -typedef struct { - /* These two fields directly represent the contents of a JPEG DHT marker */ - UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ - /* length k bits; bits[0] is unused */ - UINT8 huffval[256]; /* The symbols, in order of incr code length */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JHUFF_TBL; - - -/* Basic info about one component (color channel). */ - -typedef struct { - /* These values are fixed over the whole image. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOF marker. */ - int component_id; /* identifier for this component (0..255) */ - int component_index; /* its index in SOF or cinfo->comp_info[] */ - int h_samp_factor; /* horizontal sampling factor (1..4) */ - int v_samp_factor; /* vertical sampling factor (1..4) */ - int quant_tbl_no; /* quantization table selector (0..3) */ - /* These values may vary between scans. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOS marker. */ - /* The decompressor output side may not use these variables. */ - int dc_tbl_no; /* DC entropy table selector (0..3) */ - int ac_tbl_no; /* AC entropy table selector (0..3) */ - - /* Remaining fields should be treated as private by applications. */ - - /* These values are computed during compression or decompression startup: */ - /* Component's size in DCT blocks. - * Any dummy blocks added to complete an MCU are not counted; therefore - * these values do not depend on whether a scan is interleaved or not. - */ - JDIMENSION width_in_blocks; - JDIMENSION height_in_blocks; - /* Size of a DCT block in samples. Always DCTSIZE for compression. - * For decompression this is the size of the output from one DCT block, - * reflecting any scaling we choose to apply during the IDCT step. - * Values of 1,2,4,8 are likely to be supported. Note that different - * components may receive different IDCT scalings. - */ - int DCT_scaled_size; - /* The downsampled dimensions are the component's actual, unpadded number - * of samples at the main buffer (preprocessing/compression interface), thus - * downsampled_width = ceil(image_width * Hi/Hmax) - * and similarly for height. For decompression, IDCT scaling is included, so - * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) - */ - JDIMENSION downsampled_width; /* actual width in samples */ - JDIMENSION downsampled_height; /* actual height in samples */ - /* This flag is used only for decompression. In cases where some of the - * components will be ignored (eg grayscale output from YCbCr image), - * we can skip most computations for the unused components. - */ - boolean component_needed; /* do we need the value of this component? */ - - /* These values are computed before starting a scan of the component. */ - /* The decompressor output side may not use these variables. */ - int MCU_width; /* number of blocks per MCU, horizontally */ - int MCU_height; /* number of blocks per MCU, vertically */ - int MCU_blocks; /* MCU_width * MCU_height */ - int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ - int last_col_width; /* # of non-dummy blocks across in last MCU */ - int last_row_height; /* # of non-dummy blocks down in last MCU */ - - /* Saved quantization table for component; NULL if none yet saved. - * See jdinput.c comments about the need for this information. - * This field is currently used only for decompression. - */ - JQUANT_TBL * quant_table; - - /* Private per-component storage for DCT or IDCT subsystem. */ - void * dct_table; -} jpeg_component_info; - - -/* The script for encoding a multiple-scan file is an array of these: */ - -typedef struct { - int comps_in_scan; /* number of components encoded in this scan */ - int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ - int Ss, Se; /* progressive JPEG spectral selection parms */ - int Ah, Al; /* progressive JPEG successive approx. parms */ -} jpeg_scan_info; - -/* The decompressor can save APPn and COM markers in a list of these: */ - -typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; - -struct jpeg_marker_struct { - jpeg_saved_marker_ptr next; /* next in list, or NULL */ - UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ - unsigned int original_length; /* # bytes of data in the file */ - unsigned int data_length; /* # bytes of data saved at data[] */ - JOCTET FAR * data; /* the data contained in the marker */ - /* the marker length word is not counted in data_length or original_length */ -}; - -/* Known color spaces. */ - -typedef enum { - JCS_UNKNOWN, /* error/unspecified */ - JCS_GRAYSCALE, /* monochrome */ - JCS_RGB, /* red/green/blue */ - JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ - JCS_CMYK, /* C/M/Y/K */ - JCS_YCCK /* Y/Cb/Cr/K */ -} J_COLOR_SPACE; - -/* DCT/IDCT algorithm options. */ - -typedef enum { - JDCT_ISLOW, /* slow but accurate integer algorithm */ - JDCT_IFAST, /* faster, less accurate integer method */ - JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ -} J_DCT_METHOD; - -#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ -#define JDCT_DEFAULT JDCT_ISLOW -#endif -#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ -#define JDCT_FASTEST JDCT_IFAST -#endif - -/* Dithering options for decompression. */ - -typedef enum { - JDITHER_NONE, /* no dithering */ - JDITHER_ORDERED, /* simple ordered dither */ - JDITHER_FS /* Floyd-Steinberg error diffusion dither */ -} J_DITHER_MODE; - - -/* Common fields between JPEG compression and decompression master structs. */ - -#define jpeg_common_fields \ - struct jpeg_error_mgr * err; /* Error handler module */\ - struct jpeg_memory_mgr * mem; /* Memory manager module */\ - struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ - void * client_data; /* Available for use by application */\ - boolean is_decompressor; /* So common code can tell which is which */\ - int global_state /* For checking call sequence validity */ - -/* Routines that are to be used by both halves of the library are declared - * to receive a pointer to this structure. There are no actual instances of - * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. - */ -struct jpeg_common_struct { - jpeg_common_fields; /* Fields common to both master struct types */ - /* Additional fields follow in an actual jpeg_compress_struct or - * jpeg_decompress_struct. All three structs must agree on these - * initial fields! (This would be a lot cleaner in C++.) - */ -}; - -typedef struct jpeg_common_struct * j_common_ptr; -typedef struct jpeg_compress_struct * j_compress_ptr; -typedef struct jpeg_decompress_struct * j_decompress_ptr; - - -/* Master record for a compression instance */ - -struct jpeg_compress_struct { - jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ - - /* Destination for compressed data */ - struct jpeg_destination_mgr * dest; - - /* Description of source image --- these fields must be filled in by - * outer application before starting compression. in_color_space must - * be correct before you can even call jpeg_set_defaults(). - */ - - JDIMENSION image_width; /* input image width */ - JDIMENSION image_height; /* input image height */ - int input_components; /* # of color components in input image */ - J_COLOR_SPACE in_color_space; /* colorspace of input image */ - - double input_gamma; /* image gamma of input image */ - - /* Compression parameters --- these fields must be set before calling - * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to - * initialize everything to reasonable defaults, then changing anything - * the application specifically wants to change. That way you won't get - * burnt when new parameters are added. Also note that there are several - * helper routines to simplify changing parameters. - */ - - int data_precision; /* bits of precision in image data */ - - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - int num_scans; /* # of entries in scan_info array */ - const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ - /* The default value of scan_info is NULL, which causes a single-scan - * sequential JPEG file to be emitted. To create a multi-scan file, - * set num_scans and scan_info to point to an array of scan definitions. - */ - - boolean raw_data_in; /* TRUE=caller supplies downsampled data */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - int smoothing_factor; /* 1..100, or 0 for no input smoothing */ - J_DCT_METHOD dct_method; /* DCT algorithm selector */ - - /* The restart interval can be specified in absolute MCUs by setting - * restart_interval, or in MCU rows by setting restart_in_rows - * (in which case the correct restart_interval will be figured - * for each scan). - */ - unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ - int restart_in_rows; /* if > 0, MCU rows per restart interval */ - - /* Parameters controlling emission of special markers. */ - - boolean write_JFIF_header; /* should a JFIF marker be written? */ - UINT8 JFIF_major_version; /* What to write for the JFIF version number */ - UINT8 JFIF_minor_version; - /* These three values are not used by the JPEG code, merely copied */ - /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ - /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ - /* ratio is defined by X_density/Y_density even when density_unit=0. */ - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean write_Adobe_marker; /* should an Adobe marker be written? */ - - /* State variable: index of next scanline to be written to - * jpeg_write_scanlines(). Application may use this to control its - * processing loop, e.g., "while (next_scanline < image_height)". - */ - - JDIMENSION next_scanline; /* 0 .. image_height-1 */ - - /* Remaining fields are known throughout compressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during compression startup - */ - boolean progressive_mode; /* TRUE if scan script uses progressive mode */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ - /* The coefficient controller receives data in units of MCU rows as defined - * for fully interleaved scans (whether the JPEG file is interleaved or not). - * There are v_samp_factor * DCTSIZE sample rows of each component in an - * "iMCU" (interleaved MCU) row. - */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[C_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* - * Links to compression subobjects (methods and private variables of modules) - */ - struct jpeg_comp_master * master; - struct jpeg_c_main_controller * main; - struct jpeg_c_prep_controller * prep; - struct jpeg_c_coef_controller * coef; - struct jpeg_marker_writer * marker; - struct jpeg_color_converter * cconvert; - struct jpeg_downsampler * downsample; - struct jpeg_forward_dct * fdct; - struct jpeg_entropy_encoder * entropy; - jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ - int script_space_size; -}; - - -/* Master record for a decompression instance */ - -struct jpeg_decompress_struct { - jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ - - /* Source of compressed data */ - struct jpeg_source_mgr * src; - - /* Basic description of image --- filled in by jpeg_read_header(). */ - /* Application may inspect these values to decide how to process image. */ - - JDIMENSION image_width; /* nominal image width (from SOF marker) */ - JDIMENSION image_height; /* nominal image height */ - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - /* Decompression processing parameters --- these fields must be set before - * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes - * them to default values. - */ - - J_COLOR_SPACE out_color_space; /* colorspace for output */ - - unsigned int scale_num, scale_denom; /* fraction by which to scale image */ - - double output_gamma; /* image gamma wanted in output */ - - boolean buffered_image; /* TRUE=multiple output passes */ - boolean raw_data_out; /* TRUE=downsampled data wanted */ - - J_DCT_METHOD dct_method; /* IDCT algorithm selector */ - boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ - boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ - - boolean quantize_colors; /* TRUE=colormapped output wanted */ - /* the following are ignored if not quantize_colors: */ - J_DITHER_MODE dither_mode; /* type of color dithering to use */ - boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ - int desired_number_of_colors; /* max # colors to use in created colormap */ - /* these are significant only in buffered-image mode: */ - boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ - boolean enable_external_quant;/* enable future use of external colormap */ - boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ - - /* Description of actual output image that will be returned to application. - * These fields are computed by jpeg_start_decompress(). - * You can also use jpeg_calc_output_dimensions() to determine these values - * in advance of calling jpeg_start_decompress(). - */ - - JDIMENSION output_width; /* scaled image width */ - JDIMENSION output_height; /* scaled image height */ - int out_color_components; /* # of color components in out_color_space */ - int output_components; /* # of color components returned */ - /* output_components is 1 (a colormap index) when quantizing colors; - * otherwise it equals out_color_components. - */ - int rec_outbuf_height; /* min recommended height of scanline buffer */ - /* If the buffer passed to jpeg_read_scanlines() is less than this many rows - * high, space and time will be wasted due to unnecessary data copying. - * Usually rec_outbuf_height will be 1 or 2, at most 4. - */ - - /* When quantizing colors, the output colormap is described by these fields. - * The application can supply a colormap by setting colormap non-NULL before - * calling jpeg_start_decompress; otherwise a colormap is created during - * jpeg_start_decompress or jpeg_start_output. - * The map has out_color_components rows and actual_number_of_colors columns. - */ - int actual_number_of_colors; /* number of entries in use */ - JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ - - /* State variables: these variables indicate the progress of decompression. - * The application may examine these but must not modify them. - */ - - /* Row index of next scanline to be read from jpeg_read_scanlines(). - * Application may use this to control its processing loop, e.g., - * "while (output_scanline < output_height)". - */ - JDIMENSION output_scanline; /* 0 .. output_height-1 */ - - /* Current input scan number and number of iMCU rows completed in scan. - * These indicate the progress of the decompressor input side. - */ - int input_scan_number; /* Number of SOS markers seen so far */ - JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ - - /* The "output scan number" is the notional scan being displayed by the - * output side. The decompressor will not allow output scan/row number - * to get ahead of input scan/row, but it can fall arbitrarily far behind. - */ - int output_scan_number; /* Nominal scan number being displayed */ - JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ - - /* Current progression status. coef_bits[c][i] indicates the precision - * with which component c's DCT coefficient i (in zigzag order) is known. - * It is -1 when no data has yet been received, otherwise it is the point - * transform (shift) value for the most recent scan of the coefficient - * (thus, 0 at completion of the progression). - * This pointer is NULL when reading a non-progressive file. - */ - int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ - - /* Internal JPEG parameters --- the application usually need not look at - * these fields. Note that the decompressor output side may not use - * any parameters that can change between scans. - */ - - /* Quantization and Huffman tables are carried forward across input - * datastreams when processing abbreviated JPEG datastreams. - */ - - JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - /* These parameters are never carried across datastreams, since they - * are given in SOF/SOS markers or defined to be reset by SOI. - */ - - int data_precision; /* bits of precision in image data */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ - - /* These fields record data obtained from optional markers recognized by - * the JPEG library. - */ - boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ - /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ - UINT8 JFIF_major_version; /* JFIF version number */ - UINT8 JFIF_minor_version; - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ - UINT8 Adobe_transform; /* Color transform code from Adobe marker */ - - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - - /* Aside from the specific data retained from APPn markers known to the - * library, the uninterpreted contents of any or all APPn and COM markers - * can be saved in a list for examination by the application. - */ - jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ - - /* Remaining fields are known throughout decompressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during decompression startup - */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ - /* The coefficient controller's input and output progress is measured in - * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows - * in fully interleaved JPEG scans, but are used whether the scan is - * interleaved or not. We define an iMCU row as v_samp_factor DCT block - * rows of each component. Therefore, the IDCT output contains - * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. - */ - - JSAMPLE * sample_range_limit; /* table for fast range-limiting */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - * Note that the decompressor output side must not use these fields. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[D_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* This field is shared between entropy decoder and marker parser. - * It is either zero or the code of a JPEG marker that has been - * read from the data source, but has not yet been processed. - */ - int unread_marker; - - /* - * Links to decompression subobjects (methods, private variables of modules) - */ - struct jpeg_decomp_master * master; - struct jpeg_d_main_controller * main; - struct jpeg_d_coef_controller * coef; - struct jpeg_d_post_controller * post; - struct jpeg_input_controller * inputctl; - struct jpeg_marker_reader * marker; - struct jpeg_entropy_decoder * entropy; - struct jpeg_inverse_dct * idct; - struct jpeg_upsampler * upsample; - struct jpeg_color_deconverter * cconvert; - struct jpeg_color_quantizer * cquantize; -}; - - -/* "Object" declarations for JPEG modules that may be supplied or called - * directly by the surrounding application. - * As with all objects in the JPEG library, these structs only define the - * publicly visible methods and state variables of a module. Additional - * private fields may exist after the public ones. - */ - - -/* Error handler object */ - -struct jpeg_error_mgr { - /* Error exit handler: does not return to caller */ - JMETHOD(void, error_exit, (j_common_ptr cinfo)); - /* Conditionally emit a trace or warning message */ - JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); - /* Routine that actually outputs a trace or error message */ - JMETHOD(void, output_message, (j_common_ptr cinfo)); - /* Format a message string for the most recent JPEG error or message */ - JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); -#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ - /* Reset error state variables at start of a new image */ - JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); - - /* The message ID code and any parameters are saved here. - * A message can have one string parameter or up to 8 int parameters. - */ - int msg_code; -#define JMSG_STR_PARM_MAX 80 - union { - int i[8]; - char s[JMSG_STR_PARM_MAX]; - } msg_parm; - - /* Standard state variables for error facility */ - - int trace_level; /* max msg_level that will be displayed */ - - /* For recoverable corrupt-data errors, we emit a warning message, - * but keep going unless emit_message chooses to abort. emit_message - * should count warnings in num_warnings. The surrounding application - * can check for bad data by seeing if num_warnings is nonzero at the - * end of processing. - */ - long num_warnings; /* number of corrupt-data warnings */ - - /* These fields point to the table(s) of error message strings. - * An application can change the table pointer to switch to a different - * message list (typically, to change the language in which errors are - * reported). Some applications may wish to add additional error codes - * that will be handled by the JPEG library error mechanism; the second - * table pointer is used for this purpose. - * - * First table includes all errors generated by JPEG library itself. - * Error code 0 is reserved for a "no such error string" message. - */ - const char * const * jpeg_message_table; /* Library errors */ - int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ - /* Second table can be added by application (see cjpeg/djpeg for example). - * It contains strings numbered first_addon_message..last_addon_message. - */ - const char * const * addon_message_table; /* Non-library errors */ - int first_addon_message; /* code for first string in addon table */ - int last_addon_message; /* code for last string in addon table */ -}; - - -/* Progress monitor object */ - -struct jpeg_progress_mgr { - JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); - - long pass_counter; /* work units completed in this pass */ - long pass_limit; /* total number of work units in this pass */ - int completed_passes; /* passes completed so far */ - int total_passes; /* total number of passes expected */ -}; - - -/* Data destination object for compression */ - -struct jpeg_destination_mgr { - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - - JMETHOD(void, init_destination, (j_compress_ptr cinfo)); - JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); - JMETHOD(void, term_destination, (j_compress_ptr cinfo)); -}; - - -/* Data source object for decompression */ - -struct jpeg_source_mgr { - const JOCTET * next_input_byte; /* => next byte to read from buffer */ - size_t bytes_in_buffer; /* # of bytes remaining in buffer */ - - JMETHOD(void, init_source, (j_decompress_ptr cinfo)); - JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); - JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); - JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); - JMETHOD(void, term_source, (j_decompress_ptr cinfo)); -}; - - -/* Memory manager object. - * Allocates "small" objects (a few K total), "large" objects (tens of K), - * and "really big" objects (virtual arrays with backing store if needed). - * The memory manager does not allow individual objects to be freed; rather, - * each created object is assigned to a pool, and whole pools can be freed - * at once. This is faster and more convenient than remembering exactly what - * to free, especially where malloc()/free() are not too speedy. - * NB: alloc routines never return NULL. They exit to error_exit if not - * successful. - */ - -#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ -#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ -#define JPOOL_NUMPOOLS 2 - -typedef struct jvirt_sarray_control * jvirt_sarray_ptr; -typedef struct jvirt_barray_control * jvirt_barray_ptr; - - -struct jpeg_memory_mgr { - /* Method pointers */ - JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, - JDIMENSION samplesperrow, - JDIMENSION numrows)); - JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, - JDIMENSION blocksperrow, - JDIMENSION numrows)); - JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION samplesperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION blocksperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); - JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, - jvirt_sarray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, - jvirt_barray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); - JMETHOD(void, self_destruct, (j_common_ptr cinfo)); - - /* Limit on memory allocation for this JPEG object. (Note that this is - * merely advisory, not a guaranteed maximum; it only affects the space - * used for virtual-array buffers.) May be changed by outer application - * after creating the JPEG object. - */ - long max_memory_to_use; - - /* Maximum allocation request accepted by alloc_large. */ - long max_alloc_chunk; -}; - - -/* Routine signature for application-supplied marker processing methods. - * Need not pass marker code since it is stored in cinfo->unread_marker. - */ -typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); - - -/* Declarations for routines called by application. - * The JPP macro hides prototype parameters from compilers that can't cope. - * Note JPP requires double parentheses. - */ - -#ifdef HAVE_PROTOTYPES -#define JPP(arglist) arglist -#else -#define JPP(arglist) () -#endif - - -/* Short forms of external names for systems with brain-damaged linkers. - * We shorten external names to be unique in the first six letters, which - * is good enough for all known systems. - * (If your compiler itself needs names to be unique in less than 15 - * characters, you are out of luck. Get a better compiler.) - */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_std_error jStdError -#define jpeg_CreateCompress jCreaCompress -#define jpeg_CreateDecompress jCreaDecompress -#define jpeg_destroy_compress jDestCompress -#define jpeg_destroy_decompress jDestDecompress -#define jpeg_stdio_dest jStdDest -#define jpeg_stdio_src jStdSrc -#define jpeg_set_defaults jSetDefaults -#define jpeg_set_colorspace jSetColorspace -#define jpeg_default_colorspace jDefColorspace -#define jpeg_set_quality jSetQuality -#define jpeg_set_linear_quality jSetLQuality -#define jpeg_add_quant_table jAddQuantTable -#define jpeg_quality_scaling jQualityScaling -#define jpeg_simple_progression jSimProgress -#define jpeg_suppress_tables jSuppressTables -#define jpeg_alloc_quant_table jAlcQTable -#define jpeg_alloc_huff_table jAlcHTable -#define jpeg_start_compress jStrtCompress -#define jpeg_write_scanlines jWrtScanlines -#define jpeg_finish_compress jFinCompress -#define jpeg_write_raw_data jWrtRawData -#define jpeg_write_marker jWrtMarker -#define jpeg_write_m_header jWrtMHeader -#define jpeg_write_m_byte jWrtMByte -#define jpeg_write_tables jWrtTables -#define jpeg_read_header jReadHeader -#define jpeg_start_decompress jStrtDecompress -#define jpeg_read_scanlines jReadScanlines -#define jpeg_finish_decompress jFinDecompress -#define jpeg_read_raw_data jReadRawData -#define jpeg_has_multiple_scans jHasMultScn -#define jpeg_start_output jStrtOutput -#define jpeg_finish_output jFinOutput -#define jpeg_input_complete jInComplete -#define jpeg_new_colormap jNewCMap -#define jpeg_consume_input jConsumeInput -#define jpeg_calc_output_dimensions jCalcDimensions -#define jpeg_save_markers jSaveMarkers -#define jpeg_set_marker_processor jSetMarker -#define jpeg_read_coefficients jReadCoefs -#define jpeg_write_coefficients jWrtCoefs -#define jpeg_copy_critical_parameters jCopyCrit -#define jpeg_abort_compress jAbrtCompress -#define jpeg_abort_decompress jAbrtDecompress -#define jpeg_abort jAbort -#define jpeg_destroy jDestroy -#define jpeg_resync_to_restart jResyncRestart -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Default error-management setup */ -EXTERN(struct jpeg_error_mgr *) jpeg_std_error - JPP((struct jpeg_error_mgr * err)); - -/* Initialization of JPEG compression objects. - * jpeg_create_compress() and jpeg_create_decompress() are the exported - * names that applications should call. These expand to calls on - * jpeg_CreateCompress and jpeg_CreateDecompress with additional information - * passed for version mismatch checking. - * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. - */ -#define jpeg_create_compress(cinfo) \ - jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_compress_struct)) -#define jpeg_create_decompress(cinfo) \ - jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_decompress_struct)) -EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, - int version, size_t structsize)); -EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, - int version, size_t structsize)); -/* Destruction of JPEG compression objects */ -EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); - -/* Standard data source and destination managers: stdio streams. */ -/* Caller is responsible for opening the file before and closing after. */ -EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); -EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); - -/* Default parameter setup for compression */ -EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); -/* Compression parameter setup aids */ -EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, - J_COLOR_SPACE colorspace)); -EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, - boolean force_baseline)); -EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, - int scale_factor, - boolean force_baseline)); -EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, - boolean force_baseline)); -EXTERN(int) jpeg_quality_scaling JPP((int quality)); -EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, - boolean suppress)); -EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); -EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); - -/* Main entry points for compression */ -EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, - boolean write_all_tables)); -EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION num_lines)); -EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); - -/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION num_lines)); - -/* Write a special marker. See libjpeg.doc concerning safe usage. */ -EXTERN(void) jpeg_write_marker - JPP((j_compress_ptr cinfo, int marker, - const JOCTET * dataptr, unsigned int datalen)); -/* Same, but piecemeal. */ -EXTERN(void) jpeg_write_m_header - JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); -EXTERN(void) jpeg_write_m_byte - JPP((j_compress_ptr cinfo, int val)); - -/* Alternate compression function: just write an abbreviated table file */ -EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); - -/* Decompression startup: read start of JPEG datastream to see what's there */ -EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, - boolean require_image)); -/* Return value is one of: */ -#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ -#define JPEG_HEADER_OK 1 /* Found valid image datastream */ -#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ -/* If you pass require_image = TRUE (normal case), you need not check for - * a TABLES_ONLY return code; an abbreviated file will cause an error exit. - * JPEG_SUSPENDED is only possible if you use a data source module that can - * give a suspension return (the stdio source module doesn't). - */ - -/* Main entry points for decompression */ -EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); -EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION max_lines)); -EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); - -/* Replaces jpeg_read_scanlines when reading raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION max_lines)); - -/* Additional entry points for buffered-image mode. */ -EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, - int scan_number)); -EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); -EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); -/* Return value is one of: */ -/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ -#define JPEG_REACHED_SOS 1 /* Reached start of new scan */ -#define JPEG_REACHED_EOI 2 /* Reached end of image */ -#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ -#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ - -/* Precalculate output dimensions for current decompression parameters. */ -EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); - -/* Control saving of COM and APPn markers into marker_list. */ -EXTERN(void) jpeg_save_markers - JPP((j_decompress_ptr cinfo, int marker_code, - unsigned int length_limit)); - -/* Install a special processing method for COM or APPn markers. */ -EXTERN(void) jpeg_set_marker_processor - JPP((j_decompress_ptr cinfo, int marker_code, - jpeg_marker_parser_method routine)); - -/* Read or write raw DCT coefficients --- useful for lossless transcoding. */ -EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays)); -EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, - j_compress_ptr dstinfo)); - -/* If you choose to abort compression or decompression before completing - * jpeg_finish_(de)compress, then you need to clean up to release memory, - * temporary files, etc. You can just call jpeg_destroy_(de)compress - * if you're done with the JPEG object, but if you want to clean it up and - * reuse it, call this: - */ -EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); - -/* Generic versions of jpeg_abort and jpeg_destroy that work on either - * flavor of JPEG object. These may be more convenient in some places. - */ -EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); -EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); - -/* Default restart-marker-resync procedure for use by data source modules */ -EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, - int desired)); - - -/* These marker codes are exported since applications and data source modules - * are likely to want to use them. - */ - -#define JPEG_RST0 0xD0 /* RST0 marker code */ -#define JPEG_EOI 0xD9 /* EOI marker code */ -#define JPEG_APP0 0xE0 /* APP0 marker code */ -#define JPEG_COM 0xFE /* COM marker code */ - - -/* If we have a brain-damaged compiler that emits warnings (or worse, errors) - * for structure definitions that are never filled in, keep it quiet by - * supplying dummy definitions for the various substructures. - */ - -#ifdef INCOMPLETE_TYPES_BROKEN -#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ -struct jvirt_sarray_control { long dummy; }; -struct jvirt_barray_control { long dummy; }; -struct jpeg_comp_master { long dummy; }; -struct jpeg_c_main_controller { long dummy; }; -struct jpeg_c_prep_controller { long dummy; }; -struct jpeg_c_coef_controller { long dummy; }; -struct jpeg_marker_writer { long dummy; }; -struct jpeg_color_converter { long dummy; }; -struct jpeg_downsampler { long dummy; }; -struct jpeg_forward_dct { long dummy; }; -struct jpeg_entropy_encoder { long dummy; }; -struct jpeg_decomp_master { long dummy; }; -struct jpeg_d_main_controller { long dummy; }; -struct jpeg_d_coef_controller { long dummy; }; -struct jpeg_d_post_controller { long dummy; }; -struct jpeg_input_controller { long dummy; }; -struct jpeg_marker_reader { long dummy; }; -struct jpeg_entropy_decoder { long dummy; }; -struct jpeg_inverse_dct { long dummy; }; -struct jpeg_upsampler { long dummy; }; -struct jpeg_color_deconverter { long dummy; }; -struct jpeg_color_quantizer { long dummy; }; -#endif /* JPEG_INTERNALS */ -#endif /* INCOMPLETE_TYPES_BROKEN */ - - -/* - * The JPEG library modules define JPEG_INTERNALS before including this file. - * The internal structure declarations are read only when that is true. - * Applications using the library should not include jpegint.h, but may wish - * to include jerror.h. - */ - -#ifdef JPEG_INTERNALS -#include "jpegint.h" /* fetch private declarations */ -#include "jerror.h" /* fetch error codes too */ -#endif - -#endif /* JPEGLIB_H */ +/* + * jpeglib.h + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file defines the application interface for the JPEG library. + * Most applications using the library need only include this file, + * and perhaps jerror.h if they want to know the exact error codes. + */ + +#ifndef JPEGLIB_H +#define JPEGLIB_H + +/* + * First we include the configuration files that record how this + * installation of the JPEG library is set up. jconfig.h can be + * generated automatically for many systems. jmorecfg.h contains + * manual configuration options that most people need not worry about. + */ + +#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ +#include "jconfig.h" /* widely used configuration options */ +#endif +#include "jmorecfg.h" /* seldom changed options */ + + +/* Version ID for the JPEG library. + * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". + */ + +#define JPEG_LIB_VERSION 62 /* Version 6b */ + + +/* Various constants determining the sizes of things. + * All of these are specified by the JPEG standard, so don't change them + * if you want to be compatible. + */ + +#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ +#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ +#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ +#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ +#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ +#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ +#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ +/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; + * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. + * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU + * to handle it. We even let you do this from the jconfig.h file. However, + * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe + * sometimes emits noncompliant files doesn't mean you should too. + */ +#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ +#ifndef D_MAX_BLOCKS_IN_MCU +#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ +#endif + + +/* Data structures for images (arrays of samples and of DCT coefficients). + * On 80x86 machines, the image arrays are too big for near pointers, + * but the pointer arrays can fit in near memory. + */ + +typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ +typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ +typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ + +typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ +typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ +typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ +typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ + +typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ + + +/* Types for JPEG compression parameters and working tables. */ + + +/* DCT coefficient quantization tables. */ + +typedef struct { + /* This array gives the coefficient quantizers in natural array order + * (not the zigzag order in which they are stored in a JPEG DQT marker). + * CAUTION: IJG versions prior to v6a kept this array in zigzag order. + */ + UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ + /* This field is used only during compression. It's initialized FALSE when + * the table is created, and set TRUE when it's been output to the file. + * You could suppress output of a table by setting this to TRUE. + * (See jpeg_suppress_tables for an example.) + */ + boolean sent_table; /* TRUE when table has been output */ +} JQUANT_TBL; + + +/* Huffman coding tables. */ + +typedef struct { + /* These two fields directly represent the contents of a JPEG DHT marker */ + UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ + /* length k bits; bits[0] is unused */ + UINT8 huffval[256]; /* The symbols, in order of incr code length */ + /* This field is used only during compression. It's initialized FALSE when + * the table is created, and set TRUE when it's been output to the file. + * You could suppress output of a table by setting this to TRUE. + * (See jpeg_suppress_tables for an example.) + */ + boolean sent_table; /* TRUE when table has been output */ +} JHUFF_TBL; + + +/* Basic info about one component (color channel). */ + +typedef struct { + /* These values are fixed over the whole image. */ + /* For compression, they must be supplied by parameter setup; */ + /* for decompression, they are read from the SOF marker. */ + int component_id; /* identifier for this component (0..255) */ + int component_index; /* its index in SOF or cinfo->comp_info[] */ + int h_samp_factor; /* horizontal sampling factor (1..4) */ + int v_samp_factor; /* vertical sampling factor (1..4) */ + int quant_tbl_no; /* quantization table selector (0..3) */ + /* These values may vary between scans. */ + /* For compression, they must be supplied by parameter setup; */ + /* for decompression, they are read from the SOS marker. */ + /* The decompressor output side may not use these variables. */ + int dc_tbl_no; /* DC entropy table selector (0..3) */ + int ac_tbl_no; /* AC entropy table selector (0..3) */ + + /* Remaining fields should be treated as private by applications. */ + + /* These values are computed during compression or decompression startup: */ + /* Component's size in DCT blocks. + * Any dummy blocks added to complete an MCU are not counted; therefore + * these values do not depend on whether a scan is interleaved or not. + */ + JDIMENSION width_in_blocks; + JDIMENSION height_in_blocks; + /* Size of a DCT block in samples. Always DCTSIZE for compression. + * For decompression this is the size of the output from one DCT block, + * reflecting any scaling we choose to apply during the IDCT step. + * Values of 1,2,4,8 are likely to be supported. Note that different + * components may receive different IDCT scalings. + */ + int DCT_scaled_size; + /* The downsampled dimensions are the component's actual, unpadded number + * of samples at the main buffer (preprocessing/compression interface), thus + * downsampled_width = ceil(image_width * Hi/Hmax) + * and similarly for height. For decompression, IDCT scaling is included, so + * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) + */ + JDIMENSION downsampled_width; /* actual width in samples */ + JDIMENSION downsampled_height; /* actual height in samples */ + /* This flag is used only for decompression. In cases where some of the + * components will be ignored (eg grayscale output from YCbCr image), + * we can skip most computations for the unused components. + */ + boolean component_needed; /* do we need the value of this component? */ + + /* These values are computed before starting a scan of the component. */ + /* The decompressor output side may not use these variables. */ + int MCU_width; /* number of blocks per MCU, horizontally */ + int MCU_height; /* number of blocks per MCU, vertically */ + int MCU_blocks; /* MCU_width * MCU_height */ + int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ + int last_col_width; /* # of non-dummy blocks across in last MCU */ + int last_row_height; /* # of non-dummy blocks down in last MCU */ + + /* Saved quantization table for component; NULL if none yet saved. + * See jdinput.c comments about the need for this information. + * This field is currently used only for decompression. + */ + JQUANT_TBL * quant_table; + + /* Private per-component storage for DCT or IDCT subsystem. */ + void * dct_table; +} jpeg_component_info; + + +/* The script for encoding a multiple-scan file is an array of these: */ + +typedef struct { + int comps_in_scan; /* number of components encoded in this scan */ + int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ + int Ss, Se; /* progressive JPEG spectral selection parms */ + int Ah, Al; /* progressive JPEG successive approx. parms */ +} jpeg_scan_info; + +/* The decompressor can save APPn and COM markers in a list of these: */ + +typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; + +struct jpeg_marker_struct { + jpeg_saved_marker_ptr next; /* next in list, or NULL */ + UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ + unsigned int original_length; /* # bytes of data in the file */ + unsigned int data_length; /* # bytes of data saved at data[] */ + JOCTET FAR * data; /* the data contained in the marker */ + /* the marker length word is not counted in data_length or original_length */ +}; + +/* Known color spaces. */ + +typedef enum { + JCS_UNKNOWN, /* error/unspecified */ + JCS_GRAYSCALE, /* monochrome */ + JCS_RGB, /* red/green/blue */ + JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ + JCS_CMYK, /* C/M/Y/K */ + JCS_YCCK /* Y/Cb/Cr/K */ +} J_COLOR_SPACE; + +/* DCT/IDCT algorithm options. */ + +typedef enum { + JDCT_ISLOW, /* slow but accurate integer algorithm */ + JDCT_IFAST, /* faster, less accurate integer method */ + JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ +} J_DCT_METHOD; + +#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ +#define JDCT_DEFAULT JDCT_ISLOW +#endif +#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ +#define JDCT_FASTEST JDCT_IFAST +#endif + +/* Dithering options for decompression. */ + +typedef enum { + JDITHER_NONE, /* no dithering */ + JDITHER_ORDERED, /* simple ordered dither */ + JDITHER_FS /* Floyd-Steinberg error diffusion dither */ +} J_DITHER_MODE; + + +/* Common fields between JPEG compression and decompression master structs. */ + +#define jpeg_common_fields \ + struct jpeg_error_mgr * err; /* Error handler module */\ + struct jpeg_memory_mgr * mem; /* Memory manager module */\ + struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ + void * client_data; /* Available for use by application */\ + boolean is_decompressor; /* So common code can tell which is which */\ + int global_state /* For checking call sequence validity */ + +/* Routines that are to be used by both halves of the library are declared + * to receive a pointer to this structure. There are no actual instances of + * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. + */ +struct jpeg_common_struct { + jpeg_common_fields; /* Fields common to both master struct types */ + /* Additional fields follow in an actual jpeg_compress_struct or + * jpeg_decompress_struct. All three structs must agree on these + * initial fields! (This would be a lot cleaner in C++.) + */ +}; + +typedef struct jpeg_common_struct * j_common_ptr; +typedef struct jpeg_compress_struct * j_compress_ptr; +typedef struct jpeg_decompress_struct * j_decompress_ptr; + + +/* Master record for a compression instance */ + +struct jpeg_compress_struct { + jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ + + /* Destination for compressed data */ + struct jpeg_destination_mgr * dest; + + /* Description of source image --- these fields must be filled in by + * outer application before starting compression. in_color_space must + * be correct before you can even call jpeg_set_defaults(). + */ + + JDIMENSION image_width; /* input image width */ + JDIMENSION image_height; /* input image height */ + int input_components; /* # of color components in input image */ + J_COLOR_SPACE in_color_space; /* colorspace of input image */ + + double input_gamma; /* image gamma of input image */ + + /* Compression parameters --- these fields must be set before calling + * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to + * initialize everything to reasonable defaults, then changing anything + * the application specifically wants to change. That way you won't get + * burnt when new parameters are added. Also note that there are several + * helper routines to simplify changing parameters. + */ + + int data_precision; /* bits of precision in image data */ + + int num_components; /* # of color components in JPEG image */ + J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ + + jpeg_component_info * comp_info; + /* comp_info[i] describes component that appears i'th in SOF */ + + JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; + /* ptrs to coefficient quantization tables, or NULL if not defined */ + + JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; + JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; + /* ptrs to Huffman coding tables, or NULL if not defined */ + + UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ + UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ + UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ + + int num_scans; /* # of entries in scan_info array */ + const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ + /* The default value of scan_info is NULL, which causes a single-scan + * sequential JPEG file to be emitted. To create a multi-scan file, + * set num_scans and scan_info to point to an array of scan definitions. + */ + + boolean raw_data_in; /* TRUE=caller supplies downsampled data */ + boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ + boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ + boolean CCIR601_sampling; /* TRUE=first samples are cosited */ + int smoothing_factor; /* 1..100, or 0 for no input smoothing */ + J_DCT_METHOD dct_method; /* DCT algorithm selector */ + + /* The restart interval can be specified in absolute MCUs by setting + * restart_interval, or in MCU rows by setting restart_in_rows + * (in which case the correct restart_interval will be figured + * for each scan). + */ + unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ + int restart_in_rows; /* if > 0, MCU rows per restart interval */ + + /* Parameters controlling emission of special markers. */ + + boolean write_JFIF_header; /* should a JFIF marker be written? */ + UINT8 JFIF_major_version; /* What to write for the JFIF version number */ + UINT8 JFIF_minor_version; + /* These three values are not used by the JPEG code, merely copied */ + /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ + /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ + /* ratio is defined by X_density/Y_density even when density_unit=0. */ + UINT8 density_unit; /* JFIF code for pixel size units */ + UINT16 X_density; /* Horizontal pixel density */ + UINT16 Y_density; /* Vertical pixel density */ + boolean write_Adobe_marker; /* should an Adobe marker be written? */ + + /* State variable: index of next scanline to be written to + * jpeg_write_scanlines(). Application may use this to control its + * processing loop, e.g., "while (next_scanline < image_height)". + */ + + JDIMENSION next_scanline; /* 0 .. image_height-1 */ + + /* Remaining fields are known throughout compressor, but generally + * should not be touched by a surrounding application. + */ + + /* + * These fields are computed during compression startup + */ + boolean progressive_mode; /* TRUE if scan script uses progressive mode */ + int max_h_samp_factor; /* largest h_samp_factor */ + int max_v_samp_factor; /* largest v_samp_factor */ + + JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ + /* The coefficient controller receives data in units of MCU rows as defined + * for fully interleaved scans (whether the JPEG file is interleaved or not). + * There are v_samp_factor * DCTSIZE sample rows of each component in an + * "iMCU" (interleaved MCU) row. + */ + + /* + * These fields are valid during any one scan. + * They describe the components and MCUs actually appearing in the scan. + */ + int comps_in_scan; /* # of JPEG components in this scan */ + jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; + /* *cur_comp_info[i] describes component that appears i'th in SOS */ + + JDIMENSION MCUs_per_row; /* # of MCUs across the image */ + JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ + + int blocks_in_MCU; /* # of DCT blocks per MCU */ + int MCU_membership[C_MAX_BLOCKS_IN_MCU]; + /* MCU_membership[i] is index in cur_comp_info of component owning */ + /* i'th block in an MCU */ + + int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ + + /* + * Links to compression subobjects (methods and private variables of modules) + */ + struct jpeg_comp_master * master; + struct jpeg_c_main_controller * main; + struct jpeg_c_prep_controller * prep; + struct jpeg_c_coef_controller * coef; + struct jpeg_marker_writer * marker; + struct jpeg_color_converter * cconvert; + struct jpeg_downsampler * downsample; + struct jpeg_forward_dct * fdct; + struct jpeg_entropy_encoder * entropy; + jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ + int script_space_size; +}; + + +/* Master record for a decompression instance */ + +struct jpeg_decompress_struct { + jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ + + /* Source of compressed data */ + struct jpeg_source_mgr * src; + + /* Basic description of image --- filled in by jpeg_read_header(). */ + /* Application may inspect these values to decide how to process image. */ + + JDIMENSION image_width; /* nominal image width (from SOF marker) */ + JDIMENSION image_height; /* nominal image height */ + int num_components; /* # of color components in JPEG image */ + J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ + + /* Decompression processing parameters --- these fields must be set before + * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes + * them to default values. + */ + + J_COLOR_SPACE out_color_space; /* colorspace for output */ + + unsigned int scale_num, scale_denom; /* fraction by which to scale image */ + + double output_gamma; /* image gamma wanted in output */ + + boolean buffered_image; /* TRUE=multiple output passes */ + boolean raw_data_out; /* TRUE=downsampled data wanted */ + + J_DCT_METHOD dct_method; /* IDCT algorithm selector */ + boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ + boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ + + boolean quantize_colors; /* TRUE=colormapped output wanted */ + /* the following are ignored if not quantize_colors: */ + J_DITHER_MODE dither_mode; /* type of color dithering to use */ + boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ + int desired_number_of_colors; /* max # colors to use in created colormap */ + /* these are significant only in buffered-image mode: */ + boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ + boolean enable_external_quant;/* enable future use of external colormap */ + boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ + + /* Description of actual output image that will be returned to application. + * These fields are computed by jpeg_start_decompress(). + * You can also use jpeg_calc_output_dimensions() to determine these values + * in advance of calling jpeg_start_decompress(). + */ + + JDIMENSION output_width; /* scaled image width */ + JDIMENSION output_height; /* scaled image height */ + int out_color_components; /* # of color components in out_color_space */ + int output_components; /* # of color components returned */ + /* output_components is 1 (a colormap index) when quantizing colors; + * otherwise it equals out_color_components. + */ + int rec_outbuf_height; /* min recommended height of scanline buffer */ + /* If the buffer passed to jpeg_read_scanlines() is less than this many rows + * high, space and time will be wasted due to unnecessary data copying. + * Usually rec_outbuf_height will be 1 or 2, at most 4. + */ + + /* When quantizing colors, the output colormap is described by these fields. + * The application can supply a colormap by setting colormap non-NULL before + * calling jpeg_start_decompress; otherwise a colormap is created during + * jpeg_start_decompress or jpeg_start_output. + * The map has out_color_components rows and actual_number_of_colors columns. + */ + int actual_number_of_colors; /* number of entries in use */ + JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ + + /* State variables: these variables indicate the progress of decompression. + * The application may examine these but must not modify them. + */ + + /* Row index of next scanline to be read from jpeg_read_scanlines(). + * Application may use this to control its processing loop, e.g., + * "while (output_scanline < output_height)". + */ + JDIMENSION output_scanline; /* 0 .. output_height-1 */ + + /* Current input scan number and number of iMCU rows completed in scan. + * These indicate the progress of the decompressor input side. + */ + int input_scan_number; /* Number of SOS markers seen so far */ + JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ + + /* The "output scan number" is the notional scan being displayed by the + * output side. The decompressor will not allow output scan/row number + * to get ahead of input scan/row, but it can fall arbitrarily far behind. + */ + int output_scan_number; /* Nominal scan number being displayed */ + JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ + + /* Current progression status. coef_bits[c][i] indicates the precision + * with which component c's DCT coefficient i (in zigzag order) is known. + * It is -1 when no data has yet been received, otherwise it is the point + * transform (shift) value for the most recent scan of the coefficient + * (thus, 0 at completion of the progression). + * This pointer is NULL when reading a non-progressive file. + */ + int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ + + /* Internal JPEG parameters --- the application usually need not look at + * these fields. Note that the decompressor output side may not use + * any parameters that can change between scans. + */ + + /* Quantization and Huffman tables are carried forward across input + * datastreams when processing abbreviated JPEG datastreams. + */ + + JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; + /* ptrs to coefficient quantization tables, or NULL if not defined */ + + JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; + JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; + /* ptrs to Huffman coding tables, or NULL if not defined */ + + /* These parameters are never carried across datastreams, since they + * are given in SOF/SOS markers or defined to be reset by SOI. + */ + + int data_precision; /* bits of precision in image data */ + + jpeg_component_info * comp_info; + /* comp_info[i] describes component that appears i'th in SOF */ + + boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ + boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ + + UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ + UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ + UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ + + unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ + + /* These fields record data obtained from optional markers recognized by + * the JPEG library. + */ + boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ + /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ + UINT8 JFIF_major_version; /* JFIF version number */ + UINT8 JFIF_minor_version; + UINT8 density_unit; /* JFIF code for pixel size units */ + UINT16 X_density; /* Horizontal pixel density */ + UINT16 Y_density; /* Vertical pixel density */ + boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ + UINT8 Adobe_transform; /* Color transform code from Adobe marker */ + + boolean CCIR601_sampling; /* TRUE=first samples are cosited */ + + /* Aside from the specific data retained from APPn markers known to the + * library, the uninterpreted contents of any or all APPn and COM markers + * can be saved in a list for examination by the application. + */ + jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ + + /* Remaining fields are known throughout decompressor, but generally + * should not be touched by a surrounding application. + */ + + /* + * These fields are computed during decompression startup + */ + int max_h_samp_factor; /* largest h_samp_factor */ + int max_v_samp_factor; /* largest v_samp_factor */ + + int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ + + JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ + /* The coefficient controller's input and output progress is measured in + * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows + * in fully interleaved JPEG scans, but are used whether the scan is + * interleaved or not. We define an iMCU row as v_samp_factor DCT block + * rows of each component. Therefore, the IDCT output contains + * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. + */ + + JSAMPLE * sample_range_limit; /* table for fast range-limiting */ + + /* + * These fields are valid during any one scan. + * They describe the components and MCUs actually appearing in the scan. + * Note that the decompressor output side must not use these fields. + */ + int comps_in_scan; /* # of JPEG components in this scan */ + jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; + /* *cur_comp_info[i] describes component that appears i'th in SOS */ + + JDIMENSION MCUs_per_row; /* # of MCUs across the image */ + JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ + + int blocks_in_MCU; /* # of DCT blocks per MCU */ + int MCU_membership[D_MAX_BLOCKS_IN_MCU]; + /* MCU_membership[i] is index in cur_comp_info of component owning */ + /* i'th block in an MCU */ + + int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ + + /* This field is shared between entropy decoder and marker parser. + * It is either zero or the code of a JPEG marker that has been + * read from the data source, but has not yet been processed. + */ + int unread_marker; + + /* + * Links to decompression subobjects (methods, private variables of modules) + */ + struct jpeg_decomp_master * master; + struct jpeg_d_main_controller * main; + struct jpeg_d_coef_controller * coef; + struct jpeg_d_post_controller * post; + struct jpeg_input_controller * inputctl; + struct jpeg_marker_reader * marker; + struct jpeg_entropy_decoder * entropy; + struct jpeg_inverse_dct * idct; + struct jpeg_upsampler * upsample; + struct jpeg_color_deconverter * cconvert; + struct jpeg_color_quantizer * cquantize; +}; + + +/* "Object" declarations for JPEG modules that may be supplied or called + * directly by the surrounding application. + * As with all objects in the JPEG library, these structs only define the + * publicly visible methods and state variables of a module. Additional + * private fields may exist after the public ones. + */ + + +/* Error handler object */ + +struct jpeg_error_mgr { + /* Error exit handler: does not return to caller */ + JMETHOD(void, error_exit, (j_common_ptr cinfo)); + /* Conditionally emit a trace or warning message */ + JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); + /* Routine that actually outputs a trace or error message */ + JMETHOD(void, output_message, (j_common_ptr cinfo)); + /* Format a message string for the most recent JPEG error or message */ + JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); +#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ + /* Reset error state variables at start of a new image */ + JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); + + /* The message ID code and any parameters are saved here. + * A message can have one string parameter or up to 8 int parameters. + */ + int msg_code; +#define JMSG_STR_PARM_MAX 80 + union { + int i[8]; + char s[JMSG_STR_PARM_MAX]; + } msg_parm; + + /* Standard state variables for error facility */ + + int trace_level; /* max msg_level that will be displayed */ + + /* For recoverable corrupt-data errors, we emit a warning message, + * but keep going unless emit_message chooses to abort. emit_message + * should count warnings in num_warnings. The surrounding application + * can check for bad data by seeing if num_warnings is nonzero at the + * end of processing. + */ + long num_warnings; /* number of corrupt-data warnings */ + + /* These fields point to the table(s) of error message strings. + * An application can change the table pointer to switch to a different + * message list (typically, to change the language in which errors are + * reported). Some applications may wish to add additional error codes + * that will be handled by the JPEG library error mechanism; the second + * table pointer is used for this purpose. + * + * First table includes all errors generated by JPEG library itself. + * Error code 0 is reserved for a "no such error string" message. + */ + const char * const * jpeg_message_table; /* Library errors */ + int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ + /* Second table can be added by application (see cjpeg/djpeg for example). + * It contains strings numbered first_addon_message..last_addon_message. + */ + const char * const * addon_message_table; /* Non-library errors */ + int first_addon_message; /* code for first string in addon table */ + int last_addon_message; /* code for last string in addon table */ +}; + + +/* Progress monitor object */ + +struct jpeg_progress_mgr { + JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); + + long pass_counter; /* work units completed in this pass */ + long pass_limit; /* total number of work units in this pass */ + int completed_passes; /* passes completed so far */ + int total_passes; /* total number of passes expected */ +}; + + +/* Data destination object for compression */ + +struct jpeg_destination_mgr { + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + + JMETHOD(void, init_destination, (j_compress_ptr cinfo)); + JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); + JMETHOD(void, term_destination, (j_compress_ptr cinfo)); +}; + + +/* Data source object for decompression */ + +struct jpeg_source_mgr { + const JOCTET * next_input_byte; /* => next byte to read from buffer */ + size_t bytes_in_buffer; /* # of bytes remaining in buffer */ + + JMETHOD(void, init_source, (j_decompress_ptr cinfo)); + JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); + JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); + JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); + JMETHOD(void, term_source, (j_decompress_ptr cinfo)); +}; + + +/* Memory manager object. + * Allocates "small" objects (a few K total), "large" objects (tens of K), + * and "really big" objects (virtual arrays with backing store if needed). + * The memory manager does not allow individual objects to be freed; rather, + * each created object is assigned to a pool, and whole pools can be freed + * at once. This is faster and more convenient than remembering exactly what + * to free, especially where malloc()/free() are not too speedy. + * NB: alloc routines never return NULL. They exit to error_exit if not + * successful. + */ + +#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ +#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ +#define JPOOL_NUMPOOLS 2 + +typedef struct jvirt_sarray_control * jvirt_sarray_ptr; +typedef struct jvirt_barray_control * jvirt_barray_ptr; + + +struct jpeg_memory_mgr { + /* Method pointers */ + JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, + size_t sizeofobject)); + JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, + size_t sizeofobject)); + JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, + JDIMENSION samplesperrow, + JDIMENSION numrows)); + JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, + JDIMENSION blocksperrow, + JDIMENSION numrows)); + JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, + int pool_id, + boolean pre_zero, + JDIMENSION samplesperrow, + JDIMENSION numrows, + JDIMENSION maxaccess)); + JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, + int pool_id, + boolean pre_zero, + JDIMENSION blocksperrow, + JDIMENSION numrows, + JDIMENSION maxaccess)); + JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); + JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, + jvirt_sarray_ptr ptr, + JDIMENSION start_row, + JDIMENSION num_rows, + boolean writable)); + JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, + jvirt_barray_ptr ptr, + JDIMENSION start_row, + JDIMENSION num_rows, + boolean writable)); + JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); + JMETHOD(void, self_destruct, (j_common_ptr cinfo)); + + /* Limit on memory allocation for this JPEG object. (Note that this is + * merely advisory, not a guaranteed maximum; it only affects the space + * used for virtual-array buffers.) May be changed by outer application + * after creating the JPEG object. + */ + long max_memory_to_use; + + /* Maximum allocation request accepted by alloc_large. */ + long max_alloc_chunk; +}; + + +/* Routine signature for application-supplied marker processing methods. + * Need not pass marker code since it is stored in cinfo->unread_marker. + */ +typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); + + +/* Declarations for routines called by application. + * The JPP macro hides prototype parameters from compilers that can't cope. + * Note JPP requires double parentheses. + */ + +#ifdef HAVE_PROTOTYPES +#define JPP(arglist) arglist +#else +#define JPP(arglist) () +#endif + + +/* Short forms of external names for systems with brain-damaged linkers. + * We shorten external names to be unique in the first six letters, which + * is good enough for all known systems. + * (If your compiler itself needs names to be unique in less than 15 + * characters, you are out of luck. Get a better compiler.) + */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_std_error jStdError +#define jpeg_CreateCompress jCreaCompress +#define jpeg_CreateDecompress jCreaDecompress +#define jpeg_destroy_compress jDestCompress +#define jpeg_destroy_decompress jDestDecompress +#define jpeg_stdio_dest jStdDest +#define jpeg_stdio_src jStdSrc +#define jpeg_set_defaults jSetDefaults +#define jpeg_set_colorspace jSetColorspace +#define jpeg_default_colorspace jDefColorspace +#define jpeg_set_quality jSetQuality +#define jpeg_set_linear_quality jSetLQuality +#define jpeg_add_quant_table jAddQuantTable +#define jpeg_quality_scaling jQualityScaling +#define jpeg_simple_progression jSimProgress +#define jpeg_suppress_tables jSuppressTables +#define jpeg_alloc_quant_table jAlcQTable +#define jpeg_alloc_huff_table jAlcHTable +#define jpeg_start_compress jStrtCompress +#define jpeg_write_scanlines jWrtScanlines +#define jpeg_finish_compress jFinCompress +#define jpeg_write_raw_data jWrtRawData +#define jpeg_write_marker jWrtMarker +#define jpeg_write_m_header jWrtMHeader +#define jpeg_write_m_byte jWrtMByte +#define jpeg_write_tables jWrtTables +#define jpeg_read_header jReadHeader +#define jpeg_start_decompress jStrtDecompress +#define jpeg_read_scanlines jReadScanlines +#define jpeg_finish_decompress jFinDecompress +#define jpeg_read_raw_data jReadRawData +#define jpeg_has_multiple_scans jHasMultScn +#define jpeg_start_output jStrtOutput +#define jpeg_finish_output jFinOutput +#define jpeg_input_complete jInComplete +#define jpeg_new_colormap jNewCMap +#define jpeg_consume_input jConsumeInput +#define jpeg_calc_output_dimensions jCalcDimensions +#define jpeg_save_markers jSaveMarkers +#define jpeg_set_marker_processor jSetMarker +#define jpeg_read_coefficients jReadCoefs +#define jpeg_write_coefficients jWrtCoefs +#define jpeg_copy_critical_parameters jCopyCrit +#define jpeg_abort_compress jAbrtCompress +#define jpeg_abort_decompress jAbrtDecompress +#define jpeg_abort jAbort +#define jpeg_destroy jDestroy +#define jpeg_resync_to_restart jResyncRestart +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* Default error-management setup */ +EXTERN(struct jpeg_error_mgr *) jpeg_std_error + JPP((struct jpeg_error_mgr * err)); + +/* Initialization of JPEG compression objects. + * jpeg_create_compress() and jpeg_create_decompress() are the exported + * names that applications should call. These expand to calls on + * jpeg_CreateCompress and jpeg_CreateDecompress with additional information + * passed for version mismatch checking. + * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. + */ +#define jpeg_create_compress(cinfo) \ + jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ + (size_t) sizeof(struct jpeg_compress_struct)) +#define jpeg_create_decompress(cinfo) \ + jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ + (size_t) sizeof(struct jpeg_decompress_struct)) +EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, + int version, size_t structsize)); +EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, + int version, size_t structsize)); +/* Destruction of JPEG compression objects */ +EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); + +/* Standard data source and destination managers: stdio streams. */ +/* Caller is responsible for opening the file before and closing after. */ +EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); +EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); + +/* Default parameter setup for compression */ +EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); +/* Compression parameter setup aids */ +EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, + J_COLOR_SPACE colorspace)); +EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, + boolean force_baseline)); +EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, + int scale_factor, + boolean force_baseline)); +EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, + const unsigned int *basic_table, + int scale_factor, + boolean force_baseline)); +EXTERN(int) jpeg_quality_scaling JPP((int quality)); +EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, + boolean suppress)); +EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); +EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); + +/* Main entry points for compression */ +EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, + boolean write_all_tables)); +EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, + JSAMPARRAY scanlines, + JDIMENSION num_lines)); +EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); + +/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ +EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, + JSAMPIMAGE data, + JDIMENSION num_lines)); + +/* Write a special marker. See libjpeg.doc concerning safe usage. */ +EXTERN(void) jpeg_write_marker + JPP((j_compress_ptr cinfo, int marker, + const JOCTET * dataptr, unsigned int datalen)); +/* Same, but piecemeal. */ +EXTERN(void) jpeg_write_m_header + JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); +EXTERN(void) jpeg_write_m_byte + JPP((j_compress_ptr cinfo, int val)); + +/* Alternate compression function: just write an abbreviated table file */ +EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); + +/* Decompression startup: read start of JPEG datastream to see what's there */ +EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, + boolean require_image)); +/* Return value is one of: */ +#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ +#define JPEG_HEADER_OK 1 /* Found valid image datastream */ +#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ +/* If you pass require_image = TRUE (normal case), you need not check for + * a TABLES_ONLY return code; an abbreviated file will cause an error exit. + * JPEG_SUSPENDED is only possible if you use a data source module that can + * give a suspension return (the stdio source module doesn't). + */ + +/* Main entry points for decompression */ +EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); +EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, + JSAMPARRAY scanlines, + JDIMENSION max_lines)); +EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); + +/* Replaces jpeg_read_scanlines when reading raw downsampled data. */ +EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, + JSAMPIMAGE data, + JDIMENSION max_lines)); + +/* Additional entry points for buffered-image mode. */ +EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); +EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, + int scan_number)); +EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); +EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); +EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); +EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); +/* Return value is one of: */ +/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ +#define JPEG_REACHED_SOS 1 /* Reached start of new scan */ +#define JPEG_REACHED_EOI 2 /* Reached end of image */ +#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ +#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ + +/* Precalculate output dimensions for current decompression parameters. */ +EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); + +/* Control saving of COM and APPn markers into marker_list. */ +EXTERN(void) jpeg_save_markers + JPP((j_decompress_ptr cinfo, int marker_code, + unsigned int length_limit)); + +/* Install a special processing method for COM or APPn markers. */ +EXTERN(void) jpeg_set_marker_processor + JPP((j_decompress_ptr cinfo, int marker_code, + jpeg_marker_parser_method routine)); + +/* Read or write raw DCT coefficients --- useful for lossless transcoding. */ +EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); +EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, + jvirt_barray_ptr * coef_arrays)); +EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, + j_compress_ptr dstinfo)); + +/* If you choose to abort compression or decompression before completing + * jpeg_finish_(de)compress, then you need to clean up to release memory, + * temporary files, etc. You can just call jpeg_destroy_(de)compress + * if you're done with the JPEG object, but if you want to clean it up and + * reuse it, call this: + */ +EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); + +/* Generic versions of jpeg_abort and jpeg_destroy that work on either + * flavor of JPEG object. These may be more convenient in some places. + */ +EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); +EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); + +/* Default restart-marker-resync procedure for use by data source modules */ +EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, + int desired)); + + +/* These marker codes are exported since applications and data source modules + * are likely to want to use them. + */ + +#define JPEG_RST0 0xD0 /* RST0 marker code */ +#define JPEG_EOI 0xD9 /* EOI marker code */ +#define JPEG_APP0 0xE0 /* APP0 marker code */ +#define JPEG_COM 0xFE /* COM marker code */ + + +/* If we have a brain-damaged compiler that emits warnings (or worse, errors) + * for structure definitions that are never filled in, keep it quiet by + * supplying dummy definitions for the various substructures. + */ + +#ifdef INCOMPLETE_TYPES_BROKEN +#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ +struct jvirt_sarray_control { long dummy; }; +struct jvirt_barray_control { long dummy; }; +struct jpeg_comp_master { long dummy; }; +struct jpeg_c_main_controller { long dummy; }; +struct jpeg_c_prep_controller { long dummy; }; +struct jpeg_c_coef_controller { long dummy; }; +struct jpeg_marker_writer { long dummy; }; +struct jpeg_color_converter { long dummy; }; +struct jpeg_downsampler { long dummy; }; +struct jpeg_forward_dct { long dummy; }; +struct jpeg_entropy_encoder { long dummy; }; +struct jpeg_decomp_master { long dummy; }; +struct jpeg_d_main_controller { long dummy; }; +struct jpeg_d_coef_controller { long dummy; }; +struct jpeg_d_post_controller { long dummy; }; +struct jpeg_input_controller { long dummy; }; +struct jpeg_marker_reader { long dummy; }; +struct jpeg_entropy_decoder { long dummy; }; +struct jpeg_inverse_dct { long dummy; }; +struct jpeg_upsampler { long dummy; }; +struct jpeg_color_deconverter { long dummy; }; +struct jpeg_color_quantizer { long dummy; }; +#endif /* JPEG_INTERNALS */ +#endif /* INCOMPLETE_TYPES_BROKEN */ + + +/* + * The JPEG library modules define JPEG_INTERNALS before including this file. + * The internal structure declarations are read only when that is true. + * Applications using the library should not include jpegint.h, but may wish + * to include jerror.h. + */ + +#ifdef JPEG_INTERNALS +#include "jpegint.h" /* fetch private declarations */ +#include "jerror.h" /* fetch error codes too */ +#endif + +#endif /* JPEGLIB_H */ diff --git a/src/dep/src/irrlicht/jpeglib/jpegtran.1 b/src/dep/src/irrlicht/jpeglib/jpegtran.1 index ba3c2b3..6de18e2 100644 --- a/src/dep/src/irrlicht/jpeglib/jpegtran.1 +++ b/src/dep/src/irrlicht/jpeglib/jpegtran.1 @@ -1,238 +1,238 @@ -.TH JPEGTRAN 1 "3 August 1997" -.SH NAME -jpegtran \- lossless transformation of JPEG files -.SH SYNOPSIS -.B jpegtran -[ -.I options -] -[ -.I filename -] -.LP -.SH DESCRIPTION -.LP -.B jpegtran -performs various useful transformations of JPEG files. -It can translate the coded representation from one variant of JPEG to another, -for example from baseline JPEG to progressive JPEG or vice versa. It can also -perform some rearrangements of the image data, for example turning an image -from landscape to portrait format by rotation. -.PP -.B jpegtran -works by rearranging the compressed data (DCT coefficients), without -ever fully decoding the image. Therefore, its transformations are lossless: -there is no image degradation at all, which would not be true if you used -.B djpeg -followed by -.B cjpeg -to accomplish the same conversion. But by the same token, -.B jpegtran -cannot perform lossy operations such as changing the image quality. -.PP -.B jpegtran -reads the named JPEG/JFIF file, or the standard input if no file is -named, and produces a JPEG/JFIF file on the standard output. -.SH OPTIONS -All switch names may be abbreviated; for example, -.B \-optimize -may be written -.B \-opt -or -.BR \-o . -Upper and lower case are equivalent. -British spellings are also accepted (e.g., -.BR \-optimise ), -though for brevity these are not mentioned below. -.PP -To specify the coded JPEG representation used in the output file, -.B jpegtran -accepts a subset of the switches recognized by -.BR cjpeg : -.TP -.B \-optimize -Perform optimization of entropy encoding parameters. -.TP -.B \-progressive -Create progressive JPEG file. -.TP -.BI \-restart " N" -Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is -attached to the number. -.TP -.BI \-scans " file" -Use the scan script given in the specified text file. -.PP -See -.BR cjpeg (1) -for more details about these switches. -If you specify none of these switches, you get a plain baseline-JPEG output -file. The quality setting and so forth are determined by the input file. -.PP -The image can be losslessly transformed by giving one of these switches: -.TP -.B \-flip horizontal -Mirror image horizontally (left-right). -.TP -.B \-flip vertical -Mirror image vertically (top-bottom). -.TP -.B \-rotate 90 -Rotate image 90 degrees clockwise. -.TP -.B \-rotate 180 -Rotate image 180 degrees. -.TP -.B \-rotate 270 -Rotate image 270 degrees clockwise (or 90 ccw). -.TP -.B \-transpose -Transpose image (across UL-to-LR axis). -.TP -.B \-transverse -Transverse transpose (across UR-to-LL axis). -.PP -The transpose transformation has no restrictions regarding image dimensions. -The other transformations operate rather oddly if the image dimensions are not -a multiple of the iMCU size (usually 8 or 16 pixels), because they can only -transform complete blocks of DCT coefficient data in the desired way. -.PP -.BR jpegtran 's -default behavior when transforming an odd-size image is designed -to preserve exact reversibility and mathematical consistency of the -transformation set. As stated, transpose is able to flip the entire image -area. Horizontal mirroring leaves any partial iMCU column at the right edge -untouched, but is able to flip all rows of the image. Similarly, vertical -mirroring leaves any partial iMCU row at the bottom edge untouched, but is -able to flip all columns. The other transforms can be built up as sequences -of transpose and flip operations; for consistency, their actions on edge -pixels are defined to be the same as the end result of the corresponding -transpose-and-flip sequence. -.PP -For practical use, you may prefer to discard any untransformable edge pixels -rather than having a strange-looking strip along the right and/or bottom edges -of a transformed image. To do this, add the -.B \-trim -switch: -.TP -.B \-trim -Drop non-transformable edge blocks. -.PP -Obviously, a transformation with -.B \-trim -is not reversible, so strictly speaking -.B jpegtran -with this switch is not lossless. Also, the expected mathematical -equivalences between the transformations no longer hold. For example, -.B \-rot 270 -trim -trims only the bottom edge, but -.B \-rot 90 -trim -followed by -.B \-rot 180 -trim -trims both edges. -.PP -Another not-strictly-lossless transformation switch is: -.TP -.B \-grayscale -Force grayscale output. -.PP -This option discards the chrominance channels if the input image is YCbCr -(ie, a standard color JPEG), resulting in a grayscale JPEG file. The -luminance channel is preserved exactly, so this is a better method of reducing -to grayscale than decompression, conversion, and recompression. This switch -is particularly handy for fixing a monochrome picture that was mistakenly -encoded as a color JPEG. (In such a case, the space savings from getting rid -of the near-empty chroma channels won't be large; but the decoding time for -a grayscale JPEG is substantially less than that for a color JPEG.) -.PP -.B jpegtran -also recognizes these switches that control what to do with "extra" markers, -such as comment blocks: -.TP -.B \-copy none -Copy no extra markers from source file. This setting suppresses all -comments and other excess baggage present in the source file. -.TP -.B \-copy comments -Copy only comment markers. This setting copies comments from the source file, -but discards any other inessential data. -.TP -.B \-copy all -Copy all extra markers. This setting preserves miscellaneous markers -found in the source file, such as JFIF thumbnails and Photoshop settings. -In some files these extra markers can be sizable. -.PP -The default behavior is -.BR "\-copy comments" . -(Note: in IJG releases v6 and v6a, -.B jpegtran -always did the equivalent of -.BR "\-copy none" .) -.PP -Additional switches recognized by jpegtran are: -.TP -.BI \-maxmemory " N" -Set limit for amount of memory to use in processing large images. Value is -in thousands of bytes, or millions of bytes if "M" is attached to the -number. For example, -.B \-max 4m -selects 4000000 bytes. If more space is needed, temporary files will be used. -.TP -.BI \-outfile " name" -Send output image to the named file, not to standard output. -.TP -.B \-verbose -Enable debug printout. More -.BR \-v 's -give more output. Also, version information is printed at startup. -.TP -.B \-debug -Same as -.BR \-verbose . -.SH EXAMPLES -.LP -This example converts a baseline JPEG file to progressive form: -.IP -.B jpegtran \-progressive -.I foo.jpg -.B > -.I fooprog.jpg -.PP -This example rotates an image 90 degrees clockwise, discarding any -unrotatable edge pixels: -.IP -.B jpegtran \-rot 90 -trim -.I foo.jpg -.B > -.I foo90.jpg -.SH ENVIRONMENT -.TP -.B JPEGMEM -If this environment variable is set, its value is the default memory limit. -The value is specified as described for the -.B \-maxmemory -switch. -.B JPEGMEM -overrides the default value specified when the program was compiled, and -itself is overridden by an explicit -.BR \-maxmemory . -.SH SEE ALSO -.BR cjpeg (1), -.BR djpeg (1), -.BR rdjpgcom (1), -.BR wrjpgcom (1) -.br -Wallace, Gregory K. "The JPEG Still Picture Compression Standard", -Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. -.SH AUTHOR -Independent JPEG Group -.SH BUGS -Arithmetic coding is not supported for legal reasons. -.PP -The transform options can't transform odd-size images perfectly. Use -.B \-trim -if you don't like the results without it. -.PP -The entire image is read into memory and then written out again, even in -cases where this isn't really necessary. Expect swapping on large images, -especially when using the more complex transform options. +.TH JPEGTRAN 1 "3 August 1997" +.SH NAME +jpegtran \- lossless transformation of JPEG files +.SH SYNOPSIS +.B jpegtran +[ +.I options +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B jpegtran +performs various useful transformations of JPEG files. +It can translate the coded representation from one variant of JPEG to another, +for example from baseline JPEG to progressive JPEG or vice versa. It can also +perform some rearrangements of the image data, for example turning an image +from landscape to portrait format by rotation. +.PP +.B jpegtran +works by rearranging the compressed data (DCT coefficients), without +ever fully decoding the image. Therefore, its transformations are lossless: +there is no image degradation at all, which would not be true if you used +.B djpeg +followed by +.B cjpeg +to accomplish the same conversion. But by the same token, +.B jpegtran +cannot perform lossy operations such as changing the image quality. +.PP +.B jpegtran +reads the named JPEG/JFIF file, or the standard input if no file is +named, and produces a JPEG/JFIF file on the standard output. +.SH OPTIONS +All switch names may be abbreviated; for example, +.B \-optimize +may be written +.B \-opt +or +.BR \-o . +Upper and lower case are equivalent. +British spellings are also accepted (e.g., +.BR \-optimise ), +though for brevity these are not mentioned below. +.PP +To specify the coded JPEG representation used in the output file, +.B jpegtran +accepts a subset of the switches recognized by +.BR cjpeg : +.TP +.B \-optimize +Perform optimization of entropy encoding parameters. +.TP +.B \-progressive +Create progressive JPEG file. +.TP +.BI \-restart " N" +Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is +attached to the number. +.TP +.BI \-scans " file" +Use the scan script given in the specified text file. +.PP +See +.BR cjpeg (1) +for more details about these switches. +If you specify none of these switches, you get a plain baseline-JPEG output +file. The quality setting and so forth are determined by the input file. +.PP +The image can be losslessly transformed by giving one of these switches: +.TP +.B \-flip horizontal +Mirror image horizontally (left-right). +.TP +.B \-flip vertical +Mirror image vertically (top-bottom). +.TP +.B \-rotate 90 +Rotate image 90 degrees clockwise. +.TP +.B \-rotate 180 +Rotate image 180 degrees. +.TP +.B \-rotate 270 +Rotate image 270 degrees clockwise (or 90 ccw). +.TP +.B \-transpose +Transpose image (across UL-to-LR axis). +.TP +.B \-transverse +Transverse transpose (across UR-to-LL axis). +.PP +The transpose transformation has no restrictions regarding image dimensions. +The other transformations operate rather oddly if the image dimensions are not +a multiple of the iMCU size (usually 8 or 16 pixels), because they can only +transform complete blocks of DCT coefficient data in the desired way. +.PP +.BR jpegtran 's +default behavior when transforming an odd-size image is designed +to preserve exact reversibility and mathematical consistency of the +transformation set. As stated, transpose is able to flip the entire image +area. Horizontal mirroring leaves any partial iMCU column at the right edge +untouched, but is able to flip all rows of the image. Similarly, vertical +mirroring leaves any partial iMCU row at the bottom edge untouched, but is +able to flip all columns. The other transforms can be built up as sequences +of transpose and flip operations; for consistency, their actions on edge +pixels are defined to be the same as the end result of the corresponding +transpose-and-flip sequence. +.PP +For practical use, you may prefer to discard any untransformable edge pixels +rather than having a strange-looking strip along the right and/or bottom edges +of a transformed image. To do this, add the +.B \-trim +switch: +.TP +.B \-trim +Drop non-transformable edge blocks. +.PP +Obviously, a transformation with +.B \-trim +is not reversible, so strictly speaking +.B jpegtran +with this switch is not lossless. Also, the expected mathematical +equivalences between the transformations no longer hold. For example, +.B \-rot 270 -trim +trims only the bottom edge, but +.B \-rot 90 -trim +followed by +.B \-rot 180 -trim +trims both edges. +.PP +Another not-strictly-lossless transformation switch is: +.TP +.B \-grayscale +Force grayscale output. +.PP +This option discards the chrominance channels if the input image is YCbCr +(ie, a standard color JPEG), resulting in a grayscale JPEG file. The +luminance channel is preserved exactly, so this is a better method of reducing +to grayscale than decompression, conversion, and recompression. This switch +is particularly handy for fixing a monochrome picture that was mistakenly +encoded as a color JPEG. (In such a case, the space savings from getting rid +of the near-empty chroma channels won't be large; but the decoding time for +a grayscale JPEG is substantially less than that for a color JPEG.) +.PP +.B jpegtran +also recognizes these switches that control what to do with "extra" markers, +such as comment blocks: +.TP +.B \-copy none +Copy no extra markers from source file. This setting suppresses all +comments and other excess baggage present in the source file. +.TP +.B \-copy comments +Copy only comment markers. This setting copies comments from the source file, +but discards any other inessential data. +.TP +.B \-copy all +Copy all extra markers. This setting preserves miscellaneous markers +found in the source file, such as JFIF thumbnails and Photoshop settings. +In some files these extra markers can be sizable. +.PP +The default behavior is +.BR "\-copy comments" . +(Note: in IJG releases v6 and v6a, +.B jpegtran +always did the equivalent of +.BR "\-copy none" .) +.PP +Additional switches recognized by jpegtran are: +.TP +.BI \-maxmemory " N" +Set limit for amount of memory to use in processing large images. Value is +in thousands of bytes, or millions of bytes if "M" is attached to the +number. For example, +.B \-max 4m +selects 4000000 bytes. If more space is needed, temporary files will be used. +.TP +.BI \-outfile " name" +Send output image to the named file, not to standard output. +.TP +.B \-verbose +Enable debug printout. More +.BR \-v 's +give more output. Also, version information is printed at startup. +.TP +.B \-debug +Same as +.BR \-verbose . +.SH EXAMPLES +.LP +This example converts a baseline JPEG file to progressive form: +.IP +.B jpegtran \-progressive +.I foo.jpg +.B > +.I fooprog.jpg +.PP +This example rotates an image 90 degrees clockwise, discarding any +unrotatable edge pixels: +.IP +.B jpegtran \-rot 90 -trim +.I foo.jpg +.B > +.I foo90.jpg +.SH ENVIRONMENT +.TP +.B JPEGMEM +If this environment variable is set, its value is the default memory limit. +The value is specified as described for the +.B \-maxmemory +switch. +.B JPEGMEM +overrides the default value specified when the program was compiled, and +itself is overridden by an explicit +.BR \-maxmemory . +.SH SEE ALSO +.BR cjpeg (1), +.BR djpeg (1), +.BR rdjpgcom (1), +.BR wrjpgcom (1) +.br +Wallace, Gregory K. "The JPEG Still Picture Compression Standard", +Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. +.SH AUTHOR +Independent JPEG Group +.SH BUGS +Arithmetic coding is not supported for legal reasons. +.PP +The transform options can't transform odd-size images perfectly. Use +.B \-trim +if you don't like the results without it. +.PP +The entire image is read into memory and then written out again, even in +cases where this isn't really necessary. Expect swapping on large images, +especially when using the more complex transform options. diff --git a/src/dep/src/irrlicht/jpeglib/jpegtran.c b/src/dep/src/irrlicht/jpeglib/jpegtran.c index 719aaa7..20ef111 100644 --- a/src/dep/src/irrlicht/jpeglib/jpegtran.c +++ b/src/dep/src/irrlicht/jpeglib/jpegtran.c @@ -1,504 +1,504 @@ -/* - * jpegtran.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a command-line user interface for JPEG transcoding. - * It is very similar to cjpeg.c, but provides lossless transcoding between - * different JPEG file formats. It also provides some lossless and sort-of- - * lossless transformations of JPEG data. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include "transupp.h" /* Support routines for jpegtran */ -#include "jversion.h" /* for version message */ - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - - -/* - * Argument-parsing code. - * The switch parser is designed to be useful with DOS-style command line - * syntax, ie, intermixed switches and file names, where only the switches - * to the left of a given file name affect processing of that file. - * The main program in this file doesn't actually use this capability... - */ - - -static const char * progname; /* program name for error messages */ -static char * outfilename; /* for -outfile switch */ -static JCOPY_OPTION copyoption; /* -copy switch */ -static jpeg_transform_info transformoption; /* image transformation options */ - - -LOCAL(void) -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -copy none Copy no extra markers from source file\n"); - fprintf(stderr, " -copy comments Copy only comment markers (default)\n"); - fprintf(stderr, " -copy all Copy all extra markers\n"); -#ifdef ENTROPY_OPT_SUPPORTED - fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); -#endif -#ifdef C_PROGRESSIVE_SUPPORTED - fprintf(stderr, " -progressive Create progressive JPEG file\n"); -#endif -#if TRANSFORMS_SUPPORTED - fprintf(stderr, "Switches for modifying the image:\n"); - fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n"); - fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n"); - fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n"); - fprintf(stderr, " -transpose Transpose image\n"); - fprintf(stderr, " -transverse Transverse transpose image\n"); - fprintf(stderr, " -trim Drop non-transformable edge blocks\n"); -#endif /* TRANSFORMS_SUPPORTED */ - fprintf(stderr, "Switches for advanced users:\n"); - fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); - fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); - fprintf(stderr, " -outfile name Specify name for output file\n"); - fprintf(stderr, " -verbose or -debug Emit debug output\n"); - fprintf(stderr, "Switches for wizards:\n"); -#ifdef C_ARITH_CODING_SUPPORTED - fprintf(stderr, " -arithmetic Use arithmetic coding\n"); -#endif -#ifdef C_MULTISCAN_FILES_SUPPORTED - fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); -#endif - exit(EXIT_FAILURE); -} - - -LOCAL(void) -select_transform (JXFORM_CODE transform) -/* Silly little routine to detect multiple transform options, - * which we can't handle. - */ -{ -#if TRANSFORMS_SUPPORTED - if (transformoption.transform == JXFORM_NONE || - transformoption.transform == transform) { - transformoption.transform = transform; - } else { - fprintf(stderr, "%s: can only do one image transformation at a time\n", - progname); - usage(); - } -#else - fprintf(stderr, "%s: sorry, image transformation was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif -} - - -LOCAL(int) -parse_switches (j_compress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -/* Parse optional switches. - * Returns argv[] index of first file-name argument (== argc if none). - * Any file names with indexes <= last_file_arg_seen are ignored; - * they have presumably been processed in a previous iteration. - * (Pass 0 for last_file_arg_seen on the first or only iteration.) - * for_real is FALSE on the first (dummy) pass; we may skip any expensive - * processing. - */ -{ - int argn; - char * arg; - boolean simple_progressive; - char * scansarg = NULL; /* saves -scans parm if any */ - - /* Set up default JPEG parameters. */ - simple_progressive = FALSE; - outfilename = NULL; - copyoption = JCOPYOPT_DEFAULT; - transformoption.transform = JXFORM_NONE; - transformoption.trim = FALSE; - transformoption.force_grayscale = FALSE; - cinfo->err->trace_level = 0; - - /* Scan command line options, adjust parameters */ - - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (*arg != '-') { - /* Not a switch, must be a file name argument */ - if (argn <= last_file_arg_seen) { - outfilename = NULL; /* -outfile applies to just one input file */ - continue; /* ignore this name if previously processed */ - } - break; /* else done parsing switches */ - } - arg++; /* advance past switch marker character */ - - if (keymatch(arg, "arithmetic", 1)) { - /* Use arithmetic coding. */ -#ifdef C_ARITH_CODING_SUPPORTED - cinfo->arith_code = TRUE; -#else - fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "copy", 1)) { - /* Select which extra markers to copy. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "none", 1)) { - copyoption = JCOPYOPT_NONE; - } else if (keymatch(argv[argn], "comments", 1)) { - copyoption = JCOPYOPT_COMMENTS; - } else if (keymatch(argv[argn], "all", 1)) { - copyoption = JCOPYOPT_ALL; - } else - usage(); - - } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { - /* Enable debug printouts. */ - /* On first -d, print version identification */ - static boolean printed_version = FALSE; - - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's JPEGTRAN, version %s\n%s\n", - JVERSION, JCOPYRIGHT); - printed_version = TRUE; - } - cinfo->err->trace_level++; - - } else if (keymatch(arg, "flip", 1)) { - /* Mirror left-right or top-bottom. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "horizontal", 1)) - select_transform(JXFORM_FLIP_H); - else if (keymatch(argv[argn], "vertical", 1)) - select_transform(JXFORM_FLIP_V); - else - usage(); - - } else if (keymatch(arg, "grayscale", 1) || keymatch(arg, "greyscale",1)) { - /* Force to grayscale. */ -#if TRANSFORMS_SUPPORTED - transformoption.force_grayscale = TRUE; -#else - select_transform(JXFORM_NONE); /* force an error */ -#endif - - } else if (keymatch(arg, "maxmemory", 3)) { - /* Maximum memory in Kb (or Mb with 'm'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (ch == 'm' || ch == 'M') - lval *= 1000L; - cinfo->mem->max_memory_to_use = lval * 1000L; - - } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { - /* Enable entropy parm optimization. */ -#ifdef ENTROPY_OPT_SUPPORTED - cinfo->optimize_coding = TRUE; -#else - fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "outfile", 4)) { - /* Set output file name. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - outfilename = argv[argn]; /* save it away for later use */ - - } else if (keymatch(arg, "progressive", 1)) { - /* Select simple progressive mode. */ -#ifdef C_PROGRESSIVE_SUPPORTED - simple_progressive = TRUE; - /* We must postpone execution until num_components is known. */ -#else - fprintf(stderr, "%s: sorry, progressive output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "restart", 1)) { - /* Restart interval in MCU rows (or in MCUs with 'b'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (lval < 0 || lval > 65535L) - usage(); - if (ch == 'b' || ch == 'B') { - cinfo->restart_interval = (unsigned int) lval; - cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ - } else { - cinfo->restart_in_rows = (int) lval; - /* restart_interval will be computed during startup */ - } - - } else if (keymatch(arg, "rotate", 2)) { - /* Rotate 90, 180, or 270 degrees (measured clockwise). */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "90", 2)) - select_transform(JXFORM_ROT_90); - else if (keymatch(argv[argn], "180", 3)) - select_transform(JXFORM_ROT_180); - else if (keymatch(argv[argn], "270", 3)) - select_transform(JXFORM_ROT_270); - else - usage(); - - } else if (keymatch(arg, "scans", 1)) { - /* Set scan script. */ -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (++argn >= argc) /* advance to next argument */ - usage(); - scansarg = argv[argn]; - /* We must postpone reading the file in case -progressive appears. */ -#else - fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "transpose", 1)) { - /* Transpose (across UL-to-LR axis). */ - select_transform(JXFORM_TRANSPOSE); - - } else if (keymatch(arg, "transverse", 6)) { - /* Transverse transpose (across UR-to-LL axis). */ - select_transform(JXFORM_TRANSVERSE); - - } else if (keymatch(arg, "trim", 3)) { - /* Trim off any partial edge MCUs that the transform can't handle. */ - transformoption.trim = TRUE; - - } else { - usage(); /* bogus switch */ - } - } - - /* Post-switch-scanning cleanup */ - - if (for_real) { - -#ifdef C_PROGRESSIVE_SUPPORTED - if (simple_progressive) /* process -progressive; -scans can override */ - jpeg_simple_progression(cinfo); -#endif - -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (scansarg != NULL) /* process -scans if it was present */ - if (! read_scan_script(cinfo, scansarg)) - usage(); -#endif - } - - return argn; /* return index of next arg (file name) */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - struct jpeg_decompress_struct srcinfo; - struct jpeg_compress_struct dstinfo; - struct jpeg_error_mgr jsrcerr, jdsterr; -#ifdef PROGRESS_REPORT - struct cdjpeg_progress_mgr progress; -#endif - jvirt_barray_ptr * src_coef_arrays; - jvirt_barray_ptr * dst_coef_arrays; - int file_index; - FILE * input_file; - FILE * output_file; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "jpegtran"; /* in case C library doesn't provide it */ - - /* Initialize the JPEG decompression object with default error handling. */ - srcinfo.err = jpeg_std_error(&jsrcerr); - jpeg_create_decompress(&srcinfo); - /* Initialize the JPEG compression object with default error handling. */ - dstinfo.err = jpeg_std_error(&jdsterr); - jpeg_create_compress(&dstinfo); - - /* Now safe to enable signal catcher. - * Note: we assume only the decompression object will have virtual arrays. - */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &srcinfo); -#endif - - /* Scan command line to find file names. - * It is convenient to use just one switch-parsing routine, but the switch - * values read here are mostly ignored; we will rescan the switches after - * opening the input file. Also note that most of the switches affect the - * destination JPEG object, so we parse into that and then copy over what - * needs to affects the source too. - */ - - file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE); - jsrcerr.trace_level = jdsterr.trace_level; - srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use; - -#ifdef TWO_FILE_COMMANDLINE - /* Must have either -outfile switch or explicit output file name */ - if (outfilename == NULL) { - if (file_index != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - outfilename = argv[file_index+1]; - } else { - if (file_index != argc-1) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - } -#else - /* Unix style: expect zero or one file name */ - if (file_index < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } -#endif /* TWO_FILE_COMMANDLINE */ - - /* Open the input file. */ - if (file_index < argc) { - if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ - input_file = read_stdin(); - } - - /* Open the output file. */ - if (outfilename != NULL) { - if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, outfilename); - exit(EXIT_FAILURE); - } - } else { - /* default output file is stdout */ - output_file = write_stdout(); - } - -#ifdef PROGRESS_REPORT - start_progress_monitor((j_common_ptr) &dstinfo, &progress); -#endif - - /* Specify data source for decompression */ - jpeg_stdio_src(&srcinfo, input_file); - - /* Enable saving of extra markers that we want to copy */ - jcopy_markers_setup(&srcinfo, copyoption); - - /* Read file header */ - (void) jpeg_read_header(&srcinfo, TRUE); - - /* Any space needed by a transform option must be requested before - * jpeg_read_coefficients so that memory allocation will be done right. - */ -#if TRANSFORMS_SUPPORTED - jtransform_request_workspace(&srcinfo, &transformoption); -#endif - - /* Read source file as DCT coefficients */ - src_coef_arrays = jpeg_read_coefficients(&srcinfo); - - /* Initialize destination compression parameters from source values */ - jpeg_copy_critical_parameters(&srcinfo, &dstinfo); - - /* Adjust destination parameters if required by transform options; - * also find out which set of coefficient arrays will hold the output. - */ -#if TRANSFORMS_SUPPORTED - dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo, - src_coef_arrays, - &transformoption); -#else - dst_coef_arrays = src_coef_arrays; -#endif - - /* Adjust default compression parameters by re-parsing the options */ - file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); - - /* Specify data destination for compression */ - jpeg_stdio_dest(&dstinfo, output_file); - - /* Start compressor (note no image data is actually written here) */ - jpeg_write_coefficients(&dstinfo, dst_coef_arrays); - - /* Copy to the output file any extra markers that we want to preserve */ - jcopy_markers_execute(&srcinfo, &dstinfo, copyoption); - - /* Execute image transformation, if any */ -#if TRANSFORMS_SUPPORTED - jtransform_execute_transformation(&srcinfo, &dstinfo, - src_coef_arrays, - &transformoption); -#endif - - /* Finish compression and release memory */ - jpeg_finish_compress(&dstinfo); - jpeg_destroy_compress(&dstinfo); - (void) jpeg_finish_decompress(&srcinfo); - jpeg_destroy_decompress(&srcinfo); - - /* Close files, if we opened them */ - if (input_file != stdin) - fclose(input_file); - if (output_file != stdout) - fclose(output_file); - -#ifdef PROGRESS_REPORT - end_progress_monitor((j_common_ptr) &dstinfo); -#endif - - /* All done. */ - exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} +/* + * jpegtran.c + * + * Copyright (C) 1995-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a command-line user interface for JPEG transcoding. + * It is very similar to cjpeg.c, but provides lossless transcoding between + * different JPEG file formats. It also provides some lossless and sort-of- + * lossless transformations of JPEG data. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include "transupp.h" /* Support routines for jpegtran */ +#include "jversion.h" /* for version message */ + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + + +/* + * Argument-parsing code. + * The switch parser is designed to be useful with DOS-style command line + * syntax, ie, intermixed switches and file names, where only the switches + * to the left of a given file name affect processing of that file. + * The main program in this file doesn't actually use this capability... + */ + + +static const char * progname; /* program name for error messages */ +static char * outfilename; /* for -outfile switch */ +static JCOPY_OPTION copyoption; /* -copy switch */ +static jpeg_transform_info transformoption; /* image transformation options */ + + +LOCAL(void) +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "usage: %s [switches] ", progname); +#ifdef TWO_FILE_COMMANDLINE + fprintf(stderr, "inputfile outputfile\n"); +#else + fprintf(stderr, "[inputfile]\n"); +#endif + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -copy none Copy no extra markers from source file\n"); + fprintf(stderr, " -copy comments Copy only comment markers (default)\n"); + fprintf(stderr, " -copy all Copy all extra markers\n"); +#ifdef ENTROPY_OPT_SUPPORTED + fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); +#endif +#ifdef C_PROGRESSIVE_SUPPORTED + fprintf(stderr, " -progressive Create progressive JPEG file\n"); +#endif +#if TRANSFORMS_SUPPORTED + fprintf(stderr, "Switches for modifying the image:\n"); + fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n"); + fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n"); + fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n"); + fprintf(stderr, " -transpose Transpose image\n"); + fprintf(stderr, " -transverse Transverse transpose image\n"); + fprintf(stderr, " -trim Drop non-transformable edge blocks\n"); +#endif /* TRANSFORMS_SUPPORTED */ + fprintf(stderr, "Switches for advanced users:\n"); + fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); + fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); + fprintf(stderr, " -outfile name Specify name for output file\n"); + fprintf(stderr, " -verbose or -debug Emit debug output\n"); + fprintf(stderr, "Switches for wizards:\n"); +#ifdef C_ARITH_CODING_SUPPORTED + fprintf(stderr, " -arithmetic Use arithmetic coding\n"); +#endif +#ifdef C_MULTISCAN_FILES_SUPPORTED + fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); +#endif + exit(EXIT_FAILURE); +} + + +LOCAL(void) +select_transform (JXFORM_CODE transform) +/* Silly little routine to detect multiple transform options, + * which we can't handle. + */ +{ +#if TRANSFORMS_SUPPORTED + if (transformoption.transform == JXFORM_NONE || + transformoption.transform == transform) { + transformoption.transform = transform; + } else { + fprintf(stderr, "%s: can only do one image transformation at a time\n", + progname); + usage(); + } +#else + fprintf(stderr, "%s: sorry, image transformation was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif +} + + +LOCAL(int) +parse_switches (j_compress_ptr cinfo, int argc, char **argv, + int last_file_arg_seen, boolean for_real) +/* Parse optional switches. + * Returns argv[] index of first file-name argument (== argc if none). + * Any file names with indexes <= last_file_arg_seen are ignored; + * they have presumably been processed in a previous iteration. + * (Pass 0 for last_file_arg_seen on the first or only iteration.) + * for_real is FALSE on the first (dummy) pass; we may skip any expensive + * processing. + */ +{ + int argn; + char * arg; + boolean simple_progressive; + char * scansarg = NULL; /* saves -scans parm if any */ + + /* Set up default JPEG parameters. */ + simple_progressive = FALSE; + outfilename = NULL; + copyoption = JCOPYOPT_DEFAULT; + transformoption.transform = JXFORM_NONE; + transformoption.trim = FALSE; + transformoption.force_grayscale = FALSE; + cinfo->err->trace_level = 0; + + /* Scan command line options, adjust parameters */ + + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (*arg != '-') { + /* Not a switch, must be a file name argument */ + if (argn <= last_file_arg_seen) { + outfilename = NULL; /* -outfile applies to just one input file */ + continue; /* ignore this name if previously processed */ + } + break; /* else done parsing switches */ + } + arg++; /* advance past switch marker character */ + + if (keymatch(arg, "arithmetic", 1)) { + /* Use arithmetic coding. */ +#ifdef C_ARITH_CODING_SUPPORTED + cinfo->arith_code = TRUE; +#else + fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "copy", 1)) { + /* Select which extra markers to copy. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "none", 1)) { + copyoption = JCOPYOPT_NONE; + } else if (keymatch(argv[argn], "comments", 1)) { + copyoption = JCOPYOPT_COMMENTS; + } else if (keymatch(argv[argn], "all", 1)) { + copyoption = JCOPYOPT_ALL; + } else + usage(); + + } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { + /* Enable debug printouts. */ + /* On first -d, print version identification */ + static boolean printed_version = FALSE; + + if (! printed_version) { + fprintf(stderr, "Independent JPEG Group's JPEGTRAN, version %s\n%s\n", + JVERSION, JCOPYRIGHT); + printed_version = TRUE; + } + cinfo->err->trace_level++; + + } else if (keymatch(arg, "flip", 1)) { + /* Mirror left-right or top-bottom. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "horizontal", 1)) + select_transform(JXFORM_FLIP_H); + else if (keymatch(argv[argn], "vertical", 1)) + select_transform(JXFORM_FLIP_V); + else + usage(); + + } else if (keymatch(arg, "grayscale", 1) || keymatch(arg, "greyscale",1)) { + /* Force to grayscale. */ +#if TRANSFORMS_SUPPORTED + transformoption.force_grayscale = TRUE; +#else + select_transform(JXFORM_NONE); /* force an error */ +#endif + + } else if (keymatch(arg, "maxmemory", 3)) { + /* Maximum memory in Kb (or Mb with 'm'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (ch == 'm' || ch == 'M') + lval *= 1000L; + cinfo->mem->max_memory_to_use = lval * 1000L; + + } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { + /* Enable entropy parm optimization. */ +#ifdef ENTROPY_OPT_SUPPORTED + cinfo->optimize_coding = TRUE; +#else + fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "outfile", 4)) { + /* Set output file name. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + outfilename = argv[argn]; /* save it away for later use */ + + } else if (keymatch(arg, "progressive", 1)) { + /* Select simple progressive mode. */ +#ifdef C_PROGRESSIVE_SUPPORTED + simple_progressive = TRUE; + /* We must postpone execution until num_components is known. */ +#else + fprintf(stderr, "%s: sorry, progressive output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "restart", 1)) { + /* Restart interval in MCU rows (or in MCUs with 'b'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (lval < 0 || lval > 65535L) + usage(); + if (ch == 'b' || ch == 'B') { + cinfo->restart_interval = (unsigned int) lval; + cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ + } else { + cinfo->restart_in_rows = (int) lval; + /* restart_interval will be computed during startup */ + } + + } else if (keymatch(arg, "rotate", 2)) { + /* Rotate 90, 180, or 270 degrees (measured clockwise). */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "90", 2)) + select_transform(JXFORM_ROT_90); + else if (keymatch(argv[argn], "180", 3)) + select_transform(JXFORM_ROT_180); + else if (keymatch(argv[argn], "270", 3)) + select_transform(JXFORM_ROT_270); + else + usage(); + + } else if (keymatch(arg, "scans", 1)) { + /* Set scan script. */ +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (++argn >= argc) /* advance to next argument */ + usage(); + scansarg = argv[argn]; + /* We must postpone reading the file in case -progressive appears. */ +#else + fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "transpose", 1)) { + /* Transpose (across UL-to-LR axis). */ + select_transform(JXFORM_TRANSPOSE); + + } else if (keymatch(arg, "transverse", 6)) { + /* Transverse transpose (across UR-to-LL axis). */ + select_transform(JXFORM_TRANSVERSE); + + } else if (keymatch(arg, "trim", 3)) { + /* Trim off any partial edge MCUs that the transform can't handle. */ + transformoption.trim = TRUE; + + } else { + usage(); /* bogus switch */ + } + } + + /* Post-switch-scanning cleanup */ + + if (for_real) { + +#ifdef C_PROGRESSIVE_SUPPORTED + if (simple_progressive) /* process -progressive; -scans can override */ + jpeg_simple_progression(cinfo); +#endif + +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (scansarg != NULL) /* process -scans if it was present */ + if (! read_scan_script(cinfo, scansarg)) + usage(); +#endif + } + + return argn; /* return index of next arg (file name) */ +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + struct jpeg_decompress_struct srcinfo; + struct jpeg_compress_struct dstinfo; + struct jpeg_error_mgr jsrcerr, jdsterr; +#ifdef PROGRESS_REPORT + struct cdjpeg_progress_mgr progress; +#endif + jvirt_barray_ptr * src_coef_arrays; + jvirt_barray_ptr * dst_coef_arrays; + int file_index; + FILE * input_file; + FILE * output_file; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "jpegtran"; /* in case C library doesn't provide it */ + + /* Initialize the JPEG decompression object with default error handling. */ + srcinfo.err = jpeg_std_error(&jsrcerr); + jpeg_create_decompress(&srcinfo); + /* Initialize the JPEG compression object with default error handling. */ + dstinfo.err = jpeg_std_error(&jdsterr); + jpeg_create_compress(&dstinfo); + + /* Now safe to enable signal catcher. + * Note: we assume only the decompression object will have virtual arrays. + */ +#ifdef NEED_SIGNAL_CATCHER + enable_signal_catcher((j_common_ptr) &srcinfo); +#endif + + /* Scan command line to find file names. + * It is convenient to use just one switch-parsing routine, but the switch + * values read here are mostly ignored; we will rescan the switches after + * opening the input file. Also note that most of the switches affect the + * destination JPEG object, so we parse into that and then copy over what + * needs to affects the source too. + */ + + file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE); + jsrcerr.trace_level = jdsterr.trace_level; + srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use; + +#ifdef TWO_FILE_COMMANDLINE + /* Must have either -outfile switch or explicit output file name */ + if (outfilename == NULL) { + if (file_index != argc-2) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + outfilename = argv[file_index+1]; + } else { + if (file_index != argc-1) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + } +#else + /* Unix style: expect zero or one file name */ + if (file_index < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } +#endif /* TWO_FILE_COMMANDLINE */ + + /* Open the input file. */ + if (file_index < argc) { + if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ + input_file = read_stdin(); + } + + /* Open the output file. */ + if (outfilename != NULL) { + if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, outfilename); + exit(EXIT_FAILURE); + } + } else { + /* default output file is stdout */ + output_file = write_stdout(); + } + +#ifdef PROGRESS_REPORT + start_progress_monitor((j_common_ptr) &dstinfo, &progress); +#endif + + /* Specify data source for decompression */ + jpeg_stdio_src(&srcinfo, input_file); + + /* Enable saving of extra markers that we want to copy */ + jcopy_markers_setup(&srcinfo, copyoption); + + /* Read file header */ + (void) jpeg_read_header(&srcinfo, TRUE); + + /* Any space needed by a transform option must be requested before + * jpeg_read_coefficients so that memory allocation will be done right. + */ +#if TRANSFORMS_SUPPORTED + jtransform_request_workspace(&srcinfo, &transformoption); +#endif + + /* Read source file as DCT coefficients */ + src_coef_arrays = jpeg_read_coefficients(&srcinfo); + + /* Initialize destination compression parameters from source values */ + jpeg_copy_critical_parameters(&srcinfo, &dstinfo); + + /* Adjust destination parameters if required by transform options; + * also find out which set of coefficient arrays will hold the output. + */ +#if TRANSFORMS_SUPPORTED + dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo, + src_coef_arrays, + &transformoption); +#else + dst_coef_arrays = src_coef_arrays; +#endif + + /* Adjust default compression parameters by re-parsing the options */ + file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); + + /* Specify data destination for compression */ + jpeg_stdio_dest(&dstinfo, output_file); + + /* Start compressor (note no image data is actually written here) */ + jpeg_write_coefficients(&dstinfo, dst_coef_arrays); + + /* Copy to the output file any extra markers that we want to preserve */ + jcopy_markers_execute(&srcinfo, &dstinfo, copyoption); + + /* Execute image transformation, if any */ +#if TRANSFORMS_SUPPORTED + jtransform_execute_transformation(&srcinfo, &dstinfo, + src_coef_arrays, + &transformoption); +#endif + + /* Finish compression and release memory */ + jpeg_finish_compress(&dstinfo); + jpeg_destroy_compress(&dstinfo); + (void) jpeg_finish_decompress(&srcinfo); + jpeg_destroy_decompress(&srcinfo); + + /* Close files, if we opened them */ + if (input_file != stdin) + fclose(input_file); + if (output_file != stdout) + fclose(output_file); + +#ifdef PROGRESS_REPORT + end_progress_monitor((j_common_ptr) &dstinfo); +#endif + + /* All done. */ + exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/src/dep/src/irrlicht/jpeglib/jquant1.c b/src/dep/src/irrlicht/jpeglib/jquant1.c index aaa34a1..b2f96aa 100644 --- a/src/dep/src/irrlicht/jpeglib/jquant1.c +++ b/src/dep/src/irrlicht/jpeglib/jquant1.c @@ -1,856 +1,856 @@ -/* - * jquant1.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains 1-pass color quantization (color mapping) routines. - * These routines provide mapping to a fixed color map using equally spaced - * color values. Optional Floyd-Steinberg or ordered dithering is available. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef QUANT_1PASS_SUPPORTED - - -/* - * The main purpose of 1-pass quantization is to provide a fast, if not very - * high quality, colormapped output capability. A 2-pass quantizer usually - * gives better visual quality; however, for quantized grayscale output this - * quantizer is perfectly adequate. Dithering is highly recommended with this - * quantizer, though you can turn it off if you really want to. - * - * In 1-pass quantization the colormap must be chosen in advance of seeing the - * image. We use a map consisting of all combinations of Ncolors[i] color - * values for the i'th component. The Ncolors[] values are chosen so that - * their product, the total number of colors, is no more than that requested. - * (In most cases, the product will be somewhat less.) - * - * Since the colormap is orthogonal, the representative value for each color - * component can be determined without considering the other components; - * then these indexes can be combined into a colormap index by a standard - * N-dimensional-array-subscript calculation. Most of the arithmetic involved - * can be precalculated and stored in the lookup table colorindex[]. - * colorindex[i][j] maps pixel value j in component i to the nearest - * representative value (grid plane) for that component; this index is - * multiplied by the array stride for component i, so that the - * index of the colormap entry closest to a given pixel value is just - * sum( colorindex[component-number][pixel-component-value] ) - * Aside from being fast, this scheme allows for variable spacing between - * representative values with no additional lookup cost. - * - * If gamma correction has been applied in color conversion, it might be wise - * to adjust the color grid spacing so that the representative colors are - * equidistant in linear space. At this writing, gamma correction is not - * implemented by jdcolor, so nothing is done here. - */ - - -/* Declarations for ordered dithering. - * - * We use a standard 16x16 ordered dither array. The basic concept of ordered - * dithering is described in many references, for instance Dale Schumacher's - * chapter II.2 of Graphics Gems II (James Arvo, ed. Academic Press, 1991). - * In place of Schumacher's comparisons against a "threshold" value, we add a - * "dither" value to the input pixel and then round the result to the nearest - * output value. The dither value is equivalent to (0.5 - threshold) times - * the distance between output values. For ordered dithering, we assume that - * the output colors are equally spaced; if not, results will probably be - * worse, since the dither may be too much or too little at a given point. - * - * The normal calculation would be to form pixel value + dither, range-limit - * this to 0..MAXJSAMPLE, and then index into the colorindex table as usual. - * We can skip the separate range-limiting step by extending the colorindex - * table in both directions. - */ - -#define ODITHER_SIZE 16 /* dimension of dither matrix */ -/* NB: if ODITHER_SIZE is not a power of 2, ODITHER_MASK uses will break */ -#define ODITHER_CELLS (ODITHER_SIZE*ODITHER_SIZE) /* # cells in matrix */ -#define ODITHER_MASK (ODITHER_SIZE-1) /* mask for wrapping around counters */ - -typedef int ODITHER_MATRIX[ODITHER_SIZE][ODITHER_SIZE]; -typedef int (*ODITHER_MATRIX_PTR)[ODITHER_SIZE]; - -static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = { - /* Bayer's order-4 dither array. Generated by the code given in - * Stephen Hawley's article "Ordered Dithering" in Graphics Gems I. - * The values in this array must range from 0 to ODITHER_CELLS-1. - */ - { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 }, - { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 }, - { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 }, - { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 }, - { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 }, - { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 }, - { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 }, - { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 }, - { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 }, - { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 }, - { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 }, - { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 }, - { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 }, - { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 }, - { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 }, - { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 } -}; - - -/* Declarations for Floyd-Steinberg dithering. - * - * Errors are accumulated into the array fserrors[], at a resolution of - * 1/16th of a pixel count. The error at a given pixel is propagated - * to its not-yet-processed neighbors using the standard F-S fractions, - * ... (here) 7/16 - * 3/16 5/16 1/16 - * We work left-to-right on even rows, right-to-left on odd rows. - * - * We can get away with a single array (holding one row's worth of errors) - * by using it to store the current row's errors at pixel columns not yet - * processed, but the next row's errors at columns already processed. We - * need only a few extra variables to hold the errors immediately around the - * current column. (If we are lucky, those variables are in registers, but - * even if not, they're probably cheaper to access than array elements are.) - * - * The fserrors[] array is indexed [component#][position]. - * We provide (#columns + 2) entries per component; the extra entry at each - * end saves us from special-casing the first and last pixels. - * - * Note: on a wide image, we might not have enough room in a PC's near data - * segment to hold the error array; so it is allocated with alloc_large. - */ - -#if BITS_IN_JSAMPLE == 8 -typedef INT16 FSERROR; /* 16 bits should be enough */ -typedef int LOCFSERROR; /* use 'int' for calculation temps */ -#else -typedef INT32 FSERROR; /* may need more than 16 bits */ -typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */ -#endif - -typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */ - - -/* Private subobject */ - -#define MAX_Q_COMPS 4 /* max components I can handle */ - -typedef struct { - struct jpeg_color_quantizer pub; /* public fields */ - - /* Initially allocated colormap is saved here */ - JSAMPARRAY sv_colormap; /* The color map as a 2-D pixel array */ - int sv_actual; /* number of entries in use */ - - JSAMPARRAY colorindex; /* Precomputed mapping for speed */ - /* colorindex[i][j] = index of color closest to pixel value j in component i, - * premultiplied as described above. Since colormap indexes must fit into - * JSAMPLEs, the entries of this array will too. - */ - boolean is_padded; /* is the colorindex padded for odither? */ - - int Ncolors[MAX_Q_COMPS]; /* # of values alloced to each component */ - - /* Variables for ordered dithering */ - int row_index; /* cur row's vertical index in dither matrix */ - ODITHER_MATRIX_PTR odither[MAX_Q_COMPS]; /* one dither array per component */ - - /* Variables for Floyd-Steinberg dithering */ - FSERRPTR fserrors[MAX_Q_COMPS]; /* accumulated errors */ - boolean on_odd_row; /* flag to remember which row we are on */ -} my_cquantizer; - -typedef my_cquantizer * my_cquantize_ptr; - - -/* - * Policy-making subroutines for create_colormap and create_colorindex. - * These routines determine the colormap to be used. The rest of the module - * only assumes that the colormap is orthogonal. - * - * * select_ncolors decides how to divvy up the available colors - * among the components. - * * output_value defines the set of representative values for a component. - * * largest_input_value defines the mapping from input values to - * representative values for a component. - * Note that the latter two routines may impose different policies for - * different components, though this is not currently done. - */ - - -LOCAL(int) -select_ncolors (j_decompress_ptr cinfo, int Ncolors[]) -/* Determine allocation of desired colors to components, */ -/* and fill in Ncolors[] array to indicate choice. */ -/* Return value is total number of colors (product of Ncolors[] values). */ -{ - int nc = cinfo->out_color_components; /* number of color components */ - int max_colors = cinfo->desired_number_of_colors; - int total_colors, iroot, i, j; - boolean changed; - long temp; - static const int RGB_order[3] = { RGB_GREEN, RGB_RED, RGB_BLUE }; - - /* We can allocate at least the nc'th root of max_colors per component. */ - /* Compute floor(nc'th root of max_colors). */ - iroot = 1; - do { - iroot++; - temp = iroot; /* set temp = iroot ** nc */ - for (i = 1; i < nc; i++) - temp *= iroot; - } while (temp <= (long) max_colors); /* repeat till iroot exceeds root */ - iroot--; /* now iroot = floor(root) */ - - /* Must have at least 2 color values per component */ - if (iroot < 2) - ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int) temp); - - /* Initialize to iroot color values for each component */ - total_colors = 1; - for (i = 0; i < nc; i++) { - Ncolors[i] = iroot; - total_colors *= iroot; - } - /* We may be able to increment the count for one or more components without - * exceeding max_colors, though we know not all can be incremented. - * Sometimes, the first component can be incremented more than once! - * (Example: for 16 colors, we start at 2*2*2, go to 3*2*2, then 4*2*2.) - * In RGB colorspace, try to increment G first, then R, then B. - */ - do { - changed = FALSE; - for (i = 0; i < nc; i++) { - j = (cinfo->out_color_space == JCS_RGB ? RGB_order[i] : i); - /* calculate new total_colors if Ncolors[j] is incremented */ - temp = total_colors / Ncolors[j]; - temp *= Ncolors[j]+1; /* done in long arith to avoid oflo */ - if (temp > (long) max_colors) - break; /* won't fit, done with this pass */ - Ncolors[j]++; /* OK, apply the increment */ - total_colors = (int) temp; - changed = TRUE; - } - } while (changed); - - return total_colors; -} - - -LOCAL(int) -output_value (j_decompress_ptr cinfo, int ci, int j, int maxj) -/* Return j'th output value, where j will range from 0 to maxj */ -/* The output values must fall in 0..MAXJSAMPLE in increasing order */ -{ - /* We always provide values 0 and MAXJSAMPLE for each component; - * any additional values are equally spaced between these limits. - * (Forcing the upper and lower values to the limits ensures that - * dithering can't produce a color outside the selected gamut.) - */ - return (int) (((INT32) j * MAXJSAMPLE + maxj/2) / maxj); -} - - -LOCAL(int) -largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj) -/* Return largest input value that should map to j'th output value */ -/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */ -{ - /* Breakpoints are halfway between values returned by output_value */ - return (int) (((INT32) (2*j + 1) * MAXJSAMPLE + maxj) / (2*maxj)); -} - - -/* - * Create the colormap. - */ - -LOCAL(void) -create_colormap (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPARRAY colormap; /* Created colormap */ - int total_colors; /* Number of distinct output colors */ - int i,j,k, nci, blksize, blkdist, ptr, val; - - /* Select number of colors for each component */ - total_colors = select_ncolors(cinfo, cquantize->Ncolors); - - /* Report selected color counts */ - if (cinfo->out_color_components == 3) - TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS, - total_colors, cquantize->Ncolors[0], - cquantize->Ncolors[1], cquantize->Ncolors[2]); - else - TRACEMS1(cinfo, 1, JTRC_QUANT_NCOLORS, total_colors); - - /* Allocate and fill in the colormap. */ - /* The colors are ordered in the map in standard row-major order, */ - /* i.e. rightmost (highest-indexed) color changes most rapidly. */ - - colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components); - - /* blksize is number of adjacent repeated entries for a component */ - /* blkdist is distance between groups of identical entries for a component */ - blkdist = total_colors; - - for (i = 0; i < cinfo->out_color_components; i++) { - /* fill in colormap entries for i'th color component */ - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - blksize = blkdist / nci; - for (j = 0; j < nci; j++) { - /* Compute j'th output value (out of nci) for component */ - val = output_value(cinfo, i, j, nci-1); - /* Fill in all colormap entries that have this value of this component */ - for (ptr = j * blksize; ptr < total_colors; ptr += blkdist) { - /* fill in blksize entries beginning at ptr */ - for (k = 0; k < blksize; k++) - colormap[i][ptr+k] = (JSAMPLE) val; - } - } - blkdist = blksize; /* blksize of this color is blkdist of next */ - } - - /* Save the colormap in private storage, - * where it will survive color quantization mode changes. - */ - cquantize->sv_colormap = colormap; - cquantize->sv_actual = total_colors; -} - - -/* - * Create the color index table. - */ - -LOCAL(void) -create_colorindex (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPROW indexptr; - int i,j,k, nci, blksize, val, pad; - - /* For ordered dither, we pad the color index tables by MAXJSAMPLE in - * each direction (input index values can be -MAXJSAMPLE .. 2*MAXJSAMPLE). - * This is not necessary in the other dithering modes. However, we - * flag whether it was done in case user changes dithering mode. - */ - if (cinfo->dither_mode == JDITHER_ORDERED) { - pad = MAXJSAMPLE*2; - cquantize->is_padded = TRUE; - } else { - pad = 0; - cquantize->is_padded = FALSE; - } - - cquantize->colorindex = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (MAXJSAMPLE+1 + pad), - (JDIMENSION) cinfo->out_color_components); - - /* blksize is number of adjacent repeated entries for a component */ - blksize = cquantize->sv_actual; - - for (i = 0; i < cinfo->out_color_components; i++) { - /* fill in colorindex entries for i'th color component */ - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - blksize = blksize / nci; - - /* adjust colorindex pointers to provide padding at negative indexes. */ - if (pad) - cquantize->colorindex[i] += MAXJSAMPLE; - - /* in loop, val = index of current output value, */ - /* and k = largest j that maps to current val */ - indexptr = cquantize->colorindex[i]; - val = 0; - k = largest_input_value(cinfo, i, 0, nci-1); - for (j = 0; j <= MAXJSAMPLE; j++) { - while (j > k) /* advance val if past boundary */ - k = largest_input_value(cinfo, i, ++val, nci-1); - /* premultiply so that no multiplication needed in main processing */ - indexptr[j] = (JSAMPLE) (val * blksize); - } - /* Pad at both ends if necessary */ - if (pad) - for (j = 1; j <= MAXJSAMPLE; j++) { - indexptr[-j] = indexptr[0]; - indexptr[MAXJSAMPLE+j] = indexptr[MAXJSAMPLE]; - } - } -} - - -/* - * Create an ordered-dither array for a component having ncolors - * distinct output values. - */ - -LOCAL(ODITHER_MATRIX_PTR) -make_odither_array (j_decompress_ptr cinfo, int ncolors) -{ - ODITHER_MATRIX_PTR odither; - int j,k; - INT32 num,den; - - odither = (ODITHER_MATRIX_PTR) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(ODITHER_MATRIX)); - /* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1). - * Hence the dither value for the matrix cell with fill order f - * (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1). - * On 16-bit-int machine, be careful to avoid overflow. - */ - den = 2 * ODITHER_CELLS * ((INT32) (ncolors - 1)); - for (j = 0; j < ODITHER_SIZE; j++) { - for (k = 0; k < ODITHER_SIZE; k++) { - num = ((INT32) (ODITHER_CELLS-1 - 2*((int)base_dither_matrix[j][k]))) - * MAXJSAMPLE; - /* Ensure round towards zero despite C's lack of consistency - * about rounding negative values in integer division... - */ - odither[j][k] = (int) (num<0 ? -((-num)/den) : num/den); - } - } - return odither; -} - - -/* - * Create the ordered-dither tables. - * Components having the same number of representative colors may - * share a dither table. - */ - -LOCAL(void) -create_odither_tables (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - ODITHER_MATRIX_PTR odither; - int i, j, nci; - - for (i = 0; i < cinfo->out_color_components; i++) { - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - odither = NULL; /* search for matching prior component */ - for (j = 0; j < i; j++) { - if (nci == cquantize->Ncolors[j]) { - odither = cquantize->odither[j]; - break; - } - } - if (odither == NULL) /* need a new table? */ - odither = make_odither_array(cinfo, nci); - cquantize->odither[i] = odither; - } -} - - -/* - * Map some rows of pixels to the output colormapped representation. - */ - -METHODDEF(void) -color_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPARRAY colorindex = cquantize->colorindex; - register int pixcode, ci; - register JSAMPROW ptrin, ptrout; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - register int nc = cinfo->out_color_components; - - for (row = 0; row < num_rows; row++) { - ptrin = input_buf[row]; - ptrout = output_buf[row]; - for (col = width; col > 0; col--) { - pixcode = 0; - for (ci = 0; ci < nc; ci++) { - pixcode += GETJSAMPLE(colorindex[ci][GETJSAMPLE(*ptrin++)]); - } - *ptrout++ = (JSAMPLE) pixcode; - } - } -} - - -METHODDEF(void) -color_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* Fast path for out_color_components==3, no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register int pixcode; - register JSAMPROW ptrin, ptrout; - JSAMPROW colorindex0 = cquantize->colorindex[0]; - JSAMPROW colorindex1 = cquantize->colorindex[1]; - JSAMPROW colorindex2 = cquantize->colorindex[2]; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - ptrin = input_buf[row]; - ptrout = output_buf[row]; - for (col = width; col > 0; col--) { - pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*ptrin++)]); - pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*ptrin++)]); - pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*ptrin++)]); - *ptrout++ = (JSAMPLE) pixcode; - } - } -} - - -METHODDEF(void) -quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, with ordered dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex_ci; - int * dither; /* points to active row of dither matrix */ - int row_index, col_index; /* current indexes into dither matrix */ - int nc = cinfo->out_color_components; - int ci; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - /* Initialize output values to 0 so can process components separately */ - jzero_far((void FAR *) output_buf[row], - (size_t) (width * SIZEOF(JSAMPLE))); - row_index = cquantize->row_index; - for (ci = 0; ci < nc; ci++) { - input_ptr = input_buf[row] + ci; - output_ptr = output_buf[row]; - colorindex_ci = cquantize->colorindex[ci]; - dither = cquantize->odither[ci][row_index]; - col_index = 0; - - for (col = width; col > 0; col--) { - /* Form pixel value + dither, range-limit to 0..MAXJSAMPLE, - * select output value, accumulate into output code for this pixel. - * Range-limiting need not be done explicitly, as we have extended - * the colorindex table to produce the right answers for out-of-range - * inputs. The maximum dither is +- MAXJSAMPLE; this sets the - * required amount of padding. - */ - *output_ptr += colorindex_ci[GETJSAMPLE(*input_ptr)+dither[col_index]]; - input_ptr += nc; - output_ptr++; - col_index = (col_index + 1) & ODITHER_MASK; - } - } - /* Advance row index for next row */ - row_index = (row_index + 1) & ODITHER_MASK; - cquantize->row_index = row_index; - } -} - - -METHODDEF(void) -quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* Fast path for out_color_components==3, with ordered dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register int pixcode; - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex0 = cquantize->colorindex[0]; - JSAMPROW colorindex1 = cquantize->colorindex[1]; - JSAMPROW colorindex2 = cquantize->colorindex[2]; - int * dither0; /* points to active row of dither matrix */ - int * dither1; - int * dither2; - int row_index, col_index; /* current indexes into dither matrix */ - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - row_index = cquantize->row_index; - input_ptr = input_buf[row]; - output_ptr = output_buf[row]; - dither0 = cquantize->odither[0][row_index]; - dither1 = cquantize->odither[1][row_index]; - dither2 = cquantize->odither[2][row_index]; - col_index = 0; - - for (col = width; col > 0; col--) { - pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*input_ptr++) + - dither0[col_index]]); - pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*input_ptr++) + - dither1[col_index]]); - pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*input_ptr++) + - dither2[col_index]]); - *output_ptr++ = (JSAMPLE) pixcode; - col_index = (col_index + 1) & ODITHER_MASK; - } - row_index = (row_index + 1) & ODITHER_MASK; - cquantize->row_index = row_index; - } -} - - -METHODDEF(void) -quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, with Floyd-Steinberg dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register LOCFSERROR cur; /* current error or pixel value */ - LOCFSERROR belowerr; /* error for pixel below cur */ - LOCFSERROR bpreverr; /* error for below/prev col */ - LOCFSERROR bnexterr; /* error for below/next col */ - LOCFSERROR delta; - register FSERRPTR errorptr; /* => fserrors[] at column before current */ - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex_ci; - JSAMPROW colormap_ci; - int pixcode; - int nc = cinfo->out_color_components; - int dir; /* 1 for left-to-right, -1 for right-to-left */ - int dirnc; /* dir * nc */ - int ci; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - JSAMPLE *range_limit = cinfo->sample_range_limit; - SHIFT_TEMPS - - for (row = 0; row < num_rows; row++) { - /* Initialize output values to 0 so can process components separately */ - jzero_far((void FAR *) output_buf[row], - (size_t) (width * SIZEOF(JSAMPLE))); - for (ci = 0; ci < nc; ci++) { - input_ptr = input_buf[row] + ci; - output_ptr = output_buf[row]; - if (cquantize->on_odd_row) { - /* work right to left in this row */ - input_ptr += (width-1) * nc; /* so point to rightmost pixel */ - output_ptr += width-1; - dir = -1; - dirnc = -nc; - errorptr = cquantize->fserrors[ci] + (width+1); /* => entry after last column */ - } else { - /* work left to right in this row */ - dir = 1; - dirnc = nc; - errorptr = cquantize->fserrors[ci]; /* => entry before first column */ - } - colorindex_ci = cquantize->colorindex[ci]; - colormap_ci = cquantize->sv_colormap[ci]; - /* Preset error values: no error propagated to first pixel from left */ - cur = 0; - /* and no error propagated to row below yet */ - belowerr = bpreverr = 0; - - for (col = width; col > 0; col--) { - /* cur holds the error propagated from the previous pixel on the - * current line. Add the error propagated from the previous line - * to form the complete error correction term for this pixel, and - * round the error term (which is expressed * 16) to an integer. - * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct - * for either sign of the error value. - * Note: errorptr points to *previous* column's array entry. - */ - cur = RIGHT_SHIFT(cur + errorptr[dir] + 8, 4); - /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. - * The maximum error is +- MAXJSAMPLE; this sets the required size - * of the range_limit array. - */ - cur += GETJSAMPLE(*input_ptr); - cur = GETJSAMPLE(range_limit[cur]); - /* Select output value, accumulate into output code for this pixel */ - pixcode = GETJSAMPLE(colorindex_ci[cur]); - *output_ptr += (JSAMPLE) pixcode; - /* Compute actual representation error at this pixel */ - /* Note: we can do this even though we don't have the final */ - /* pixel code, because the colormap is orthogonal. */ - cur -= GETJSAMPLE(colormap_ci[pixcode]); - /* Compute error fractions to be propagated to adjacent pixels. - * Add these into the running sums, and simultaneously shift the - * next-line error sums left by 1 column. - */ - bnexterr = cur; - delta = cur * 2; - cur += delta; /* form error * 3 */ - errorptr[0] = (FSERROR) (bpreverr + cur); - cur += delta; /* form error * 5 */ - bpreverr = belowerr + cur; - belowerr = bnexterr; - cur += delta; /* form error * 7 */ - /* At this point cur contains the 7/16 error value to be propagated - * to the next pixel on the current line, and all the errors for the - * next line have been shifted over. We are therefore ready to move on. - */ - input_ptr += dirnc; /* advance input ptr to next column */ - output_ptr += dir; /* advance output ptr to next column */ - errorptr += dir; /* advance errorptr to current column */ - } - /* Post-loop cleanup: we must unload the final error value into the - * final fserrors[] entry. Note we need not unload belowerr because - * it is for the dummy column before or after the actual array. - */ - errorptr[0] = (FSERROR) bpreverr; /* unload prev err into array */ - } - cquantize->on_odd_row = (cquantize->on_odd_row ? FALSE : TRUE); - } -} - - -/* - * Allocate workspace for Floyd-Steinberg errors. - */ - -LOCAL(void) -alloc_fs_workspace (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - size_t arraysize; - int i; - - arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); - for (i = 0; i < cinfo->out_color_components; i++) { - cquantize->fserrors[i] = (FSERRPTR) - (*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); - } -} - - -/* - * Initialize for one-pass color quantization. - */ - -METHODDEF(void) -start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - size_t arraysize; - int i; - - /* Install my colormap. */ - cinfo->colormap = cquantize->sv_colormap; - cinfo->actual_number_of_colors = cquantize->sv_actual; - - /* Initialize for desired dithering mode. */ - switch (cinfo->dither_mode) { - case JDITHER_NONE: - if (cinfo->out_color_components == 3) - cquantize->pub.color_quantize = color_quantize3; - else - cquantize->pub.color_quantize = color_quantize; - break; - case JDITHER_ORDERED: - if (cinfo->out_color_components == 3) - cquantize->pub.color_quantize = quantize3_ord_dither; - else - cquantize->pub.color_quantize = quantize_ord_dither; - cquantize->row_index = 0; /* initialize state for ordered dither */ - /* If user changed to ordered dither from another mode, - * we must recreate the color index table with padding. - * This will cost extra space, but probably isn't very likely. - */ - if (! cquantize->is_padded) - create_colorindex(cinfo); - /* Create ordered-dither tables if we didn't already. */ - if (cquantize->odither[0] == NULL) - create_odither_tables(cinfo); - break; - case JDITHER_FS: - cquantize->pub.color_quantize = quantize_fs_dither; - cquantize->on_odd_row = FALSE; /* initialize state for F-S dither */ - /* Allocate Floyd-Steinberg workspace if didn't already. */ - if (cquantize->fserrors[0] == NULL) - alloc_fs_workspace(cinfo); - /* Initialize the propagated errors to zero. */ - arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); - for (i = 0; i < cinfo->out_color_components; i++) - jzero_far((void FAR *) cquantize->fserrors[i], arraysize); - break; - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } -} - - -/* - * Finish up at the end of the pass. - */ - -METHODDEF(void) -finish_pass_1_quant (j_decompress_ptr cinfo) -{ - /* no work in 1-pass case */ -} - - -/* - * Switch to a new external colormap between output passes. - * Shouldn't get to this module! - */ - -METHODDEF(void) -new_color_map_1_quant (j_decompress_ptr cinfo) -{ - ERREXIT(cinfo, JERR_MODE_CHANGE); -} - - -/* - * Module initialization routine for 1-pass color quantization. - */ - -GLOBAL(void) -jinit_1pass_quantizer (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize; - - cquantize = (my_cquantize_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_cquantizer)); - cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; - cquantize->pub.start_pass = start_pass_1_quant; - cquantize->pub.finish_pass = finish_pass_1_quant; - cquantize->pub.new_color_map = new_color_map_1_quant; - cquantize->fserrors[0] = NULL; /* Flag FS workspace not allocated */ - cquantize->odither[0] = NULL; /* Also flag odither arrays not allocated */ - - /* Make sure my internal arrays won't overflow */ - if (cinfo->out_color_components > MAX_Q_COMPS) - ERREXIT1(cinfo, JERR_QUANT_COMPONENTS, MAX_Q_COMPS); - /* Make sure colormap indexes can be represented by JSAMPLEs */ - if (cinfo->desired_number_of_colors > (MAXJSAMPLE+1)) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE+1); - - /* Create the colormap and color index table. */ - create_colormap(cinfo); - create_colorindex(cinfo); - - /* Allocate Floyd-Steinberg workspace now if requested. - * We do this now since it is FAR storage and may affect the memory - * manager's space calculations. If the user changes to FS dither - * mode in a later pass, we will allocate the space then, and will - * possibly overrun the max_memory_to_use setting. - */ - if (cinfo->dither_mode == JDITHER_FS) - alloc_fs_workspace(cinfo); -} - -#endif /* QUANT_1PASS_SUPPORTED */ +/* + * jquant1.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains 1-pass color quantization (color mapping) routines. + * These routines provide mapping to a fixed color map using equally spaced + * color values. Optional Floyd-Steinberg or ordered dithering is available. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +#ifdef QUANT_1PASS_SUPPORTED + + +/* + * The main purpose of 1-pass quantization is to provide a fast, if not very + * high quality, colormapped output capability. A 2-pass quantizer usually + * gives better visual quality; however, for quantized grayscale output this + * quantizer is perfectly adequate. Dithering is highly recommended with this + * quantizer, though you can turn it off if you really want to. + * + * In 1-pass quantization the colormap must be chosen in advance of seeing the + * image. We use a map consisting of all combinations of Ncolors[i] color + * values for the i'th component. The Ncolors[] values are chosen so that + * their product, the total number of colors, is no more than that requested. + * (In most cases, the product will be somewhat less.) + * + * Since the colormap is orthogonal, the representative value for each color + * component can be determined without considering the other components; + * then these indexes can be combined into a colormap index by a standard + * N-dimensional-array-subscript calculation. Most of the arithmetic involved + * can be precalculated and stored in the lookup table colorindex[]. + * colorindex[i][j] maps pixel value j in component i to the nearest + * representative value (grid plane) for that component; this index is + * multiplied by the array stride for component i, so that the + * index of the colormap entry closest to a given pixel value is just + * sum( colorindex[component-number][pixel-component-value] ) + * Aside from being fast, this scheme allows for variable spacing between + * representative values with no additional lookup cost. + * + * If gamma correction has been applied in color conversion, it might be wise + * to adjust the color grid spacing so that the representative colors are + * equidistant in linear space. At this writing, gamma correction is not + * implemented by jdcolor, so nothing is done here. + */ + + +/* Declarations for ordered dithering. + * + * We use a standard 16x16 ordered dither array. The basic concept of ordered + * dithering is described in many references, for instance Dale Schumacher's + * chapter II.2 of Graphics Gems II (James Arvo, ed. Academic Press, 1991). + * In place of Schumacher's comparisons against a "threshold" value, we add a + * "dither" value to the input pixel and then round the result to the nearest + * output value. The dither value is equivalent to (0.5 - threshold) times + * the distance between output values. For ordered dithering, we assume that + * the output colors are equally spaced; if not, results will probably be + * worse, since the dither may be too much or too little at a given point. + * + * The normal calculation would be to form pixel value + dither, range-limit + * this to 0..MAXJSAMPLE, and then index into the colorindex table as usual. + * We can skip the separate range-limiting step by extending the colorindex + * table in both directions. + */ + +#define ODITHER_SIZE 16 /* dimension of dither matrix */ +/* NB: if ODITHER_SIZE is not a power of 2, ODITHER_MASK uses will break */ +#define ODITHER_CELLS (ODITHER_SIZE*ODITHER_SIZE) /* # cells in matrix */ +#define ODITHER_MASK (ODITHER_SIZE-1) /* mask for wrapping around counters */ + +typedef int ODITHER_MATRIX[ODITHER_SIZE][ODITHER_SIZE]; +typedef int (*ODITHER_MATRIX_PTR)[ODITHER_SIZE]; + +static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = { + /* Bayer's order-4 dither array. Generated by the code given in + * Stephen Hawley's article "Ordered Dithering" in Graphics Gems I. + * The values in this array must range from 0 to ODITHER_CELLS-1. + */ + { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 }, + { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 }, + { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 }, + { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 }, + { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 }, + { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 }, + { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 }, + { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 }, + { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 }, + { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 }, + { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 }, + { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 }, + { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 }, + { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 }, + { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 }, + { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 } +}; + + +/* Declarations for Floyd-Steinberg dithering. + * + * Errors are accumulated into the array fserrors[], at a resolution of + * 1/16th of a pixel count. The error at a given pixel is propagated + * to its not-yet-processed neighbors using the standard F-S fractions, + * ... (here) 7/16 + * 3/16 5/16 1/16 + * We work left-to-right on even rows, right-to-left on odd rows. + * + * We can get away with a single array (holding one row's worth of errors) + * by using it to store the current row's errors at pixel columns not yet + * processed, but the next row's errors at columns already processed. We + * need only a few extra variables to hold the errors immediately around the + * current column. (If we are lucky, those variables are in registers, but + * even if not, they're probably cheaper to access than array elements are.) + * + * The fserrors[] array is indexed [component#][position]. + * We provide (#columns + 2) entries per component; the extra entry at each + * end saves us from special-casing the first and last pixels. + * + * Note: on a wide image, we might not have enough room in a PC's near data + * segment to hold the error array; so it is allocated with alloc_large. + */ + +#if BITS_IN_JSAMPLE == 8 +typedef INT16 FSERROR; /* 16 bits should be enough */ +typedef int LOCFSERROR; /* use 'int' for calculation temps */ +#else +typedef INT32 FSERROR; /* may need more than 16 bits */ +typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */ +#endif + +typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */ + + +/* Private subobject */ + +#define MAX_Q_COMPS 4 /* max components I can handle */ + +typedef struct { + struct jpeg_color_quantizer pub; /* public fields */ + + /* Initially allocated colormap is saved here */ + JSAMPARRAY sv_colormap; /* The color map as a 2-D pixel array */ + int sv_actual; /* number of entries in use */ + + JSAMPARRAY colorindex; /* Precomputed mapping for speed */ + /* colorindex[i][j] = index of color closest to pixel value j in component i, + * premultiplied as described above. Since colormap indexes must fit into + * JSAMPLEs, the entries of this array will too. + */ + boolean is_padded; /* is the colorindex padded for odither? */ + + int Ncolors[MAX_Q_COMPS]; /* # of values alloced to each component */ + + /* Variables for ordered dithering */ + int row_index; /* cur row's vertical index in dither matrix */ + ODITHER_MATRIX_PTR odither[MAX_Q_COMPS]; /* one dither array per component */ + + /* Variables for Floyd-Steinberg dithering */ + FSERRPTR fserrors[MAX_Q_COMPS]; /* accumulated errors */ + boolean on_odd_row; /* flag to remember which row we are on */ +} my_cquantizer; + +typedef my_cquantizer * my_cquantize_ptr; + + +/* + * Policy-making subroutines for create_colormap and create_colorindex. + * These routines determine the colormap to be used. The rest of the module + * only assumes that the colormap is orthogonal. + * + * * select_ncolors decides how to divvy up the available colors + * among the components. + * * output_value defines the set of representative values for a component. + * * largest_input_value defines the mapping from input values to + * representative values for a component. + * Note that the latter two routines may impose different policies for + * different components, though this is not currently done. + */ + + +LOCAL(int) +select_ncolors (j_decompress_ptr cinfo, int Ncolors[]) +/* Determine allocation of desired colors to components, */ +/* and fill in Ncolors[] array to indicate choice. */ +/* Return value is total number of colors (product of Ncolors[] values). */ +{ + int nc = cinfo->out_color_components; /* number of color components */ + int max_colors = cinfo->desired_number_of_colors; + int total_colors, iroot, i, j; + boolean changed; + long temp; + static const int RGB_order[3] = { RGB_GREEN, RGB_RED, RGB_BLUE }; + + /* We can allocate at least the nc'th root of max_colors per component. */ + /* Compute floor(nc'th root of max_colors). */ + iroot = 1; + do { + iroot++; + temp = iroot; /* set temp = iroot ** nc */ + for (i = 1; i < nc; i++) + temp *= iroot; + } while (temp <= (long) max_colors); /* repeat till iroot exceeds root */ + iroot--; /* now iroot = floor(root) */ + + /* Must have at least 2 color values per component */ + if (iroot < 2) + ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int) temp); + + /* Initialize to iroot color values for each component */ + total_colors = 1; + for (i = 0; i < nc; i++) { + Ncolors[i] = iroot; + total_colors *= iroot; + } + /* We may be able to increment the count for one or more components without + * exceeding max_colors, though we know not all can be incremented. + * Sometimes, the first component can be incremented more than once! + * (Example: for 16 colors, we start at 2*2*2, go to 3*2*2, then 4*2*2.) + * In RGB colorspace, try to increment G first, then R, then B. + */ + do { + changed = FALSE; + for (i = 0; i < nc; i++) { + j = (cinfo->out_color_space == JCS_RGB ? RGB_order[i] : i); + /* calculate new total_colors if Ncolors[j] is incremented */ + temp = total_colors / Ncolors[j]; + temp *= Ncolors[j]+1; /* done in long arith to avoid oflo */ + if (temp > (long) max_colors) + break; /* won't fit, done with this pass */ + Ncolors[j]++; /* OK, apply the increment */ + total_colors = (int) temp; + changed = TRUE; + } + } while (changed); + + return total_colors; +} + + +LOCAL(int) +output_value (j_decompress_ptr cinfo, int ci, int j, int maxj) +/* Return j'th output value, where j will range from 0 to maxj */ +/* The output values must fall in 0..MAXJSAMPLE in increasing order */ +{ + /* We always provide values 0 and MAXJSAMPLE for each component; + * any additional values are equally spaced between these limits. + * (Forcing the upper and lower values to the limits ensures that + * dithering can't produce a color outside the selected gamut.) + */ + return (int) (((INT32) j * MAXJSAMPLE + maxj/2) / maxj); +} + + +LOCAL(int) +largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj) +/* Return largest input value that should map to j'th output value */ +/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */ +{ + /* Breakpoints are halfway between values returned by output_value */ + return (int) (((INT32) (2*j + 1) * MAXJSAMPLE + maxj) / (2*maxj)); +} + + +/* + * Create the colormap. + */ + +LOCAL(void) +create_colormap (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + JSAMPARRAY colormap; /* Created colormap */ + int total_colors; /* Number of distinct output colors */ + int i,j,k, nci, blksize, blkdist, ptr, val; + + /* Select number of colors for each component */ + total_colors = select_ncolors(cinfo, cquantize->Ncolors); + + /* Report selected color counts */ + if (cinfo->out_color_components == 3) + TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS, + total_colors, cquantize->Ncolors[0], + cquantize->Ncolors[1], cquantize->Ncolors[2]); + else + TRACEMS1(cinfo, 1, JTRC_QUANT_NCOLORS, total_colors); + + /* Allocate and fill in the colormap. */ + /* The colors are ordered in the map in standard row-major order, */ + /* i.e. rightmost (highest-indexed) color changes most rapidly. */ + + colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components); + + /* blksize is number of adjacent repeated entries for a component */ + /* blkdist is distance between groups of identical entries for a component */ + blkdist = total_colors; + + for (i = 0; i < cinfo->out_color_components; i++) { + /* fill in colormap entries for i'th color component */ + nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ + blksize = blkdist / nci; + for (j = 0; j < nci; j++) { + /* Compute j'th output value (out of nci) for component */ + val = output_value(cinfo, i, j, nci-1); + /* Fill in all colormap entries that have this value of this component */ + for (ptr = j * blksize; ptr < total_colors; ptr += blkdist) { + /* fill in blksize entries beginning at ptr */ + for (k = 0; k < blksize; k++) + colormap[i][ptr+k] = (JSAMPLE) val; + } + } + blkdist = blksize; /* blksize of this color is blkdist of next */ + } + + /* Save the colormap in private storage, + * where it will survive color quantization mode changes. + */ + cquantize->sv_colormap = colormap; + cquantize->sv_actual = total_colors; +} + + +/* + * Create the color index table. + */ + +LOCAL(void) +create_colorindex (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + JSAMPROW indexptr; + int i,j,k, nci, blksize, val, pad; + + /* For ordered dither, we pad the color index tables by MAXJSAMPLE in + * each direction (input index values can be -MAXJSAMPLE .. 2*MAXJSAMPLE). + * This is not necessary in the other dithering modes. However, we + * flag whether it was done in case user changes dithering mode. + */ + if (cinfo->dither_mode == JDITHER_ORDERED) { + pad = MAXJSAMPLE*2; + cquantize->is_padded = TRUE; + } else { + pad = 0; + cquantize->is_padded = FALSE; + } + + cquantize->colorindex = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (MAXJSAMPLE+1 + pad), + (JDIMENSION) cinfo->out_color_components); + + /* blksize is number of adjacent repeated entries for a component */ + blksize = cquantize->sv_actual; + + for (i = 0; i < cinfo->out_color_components; i++) { + /* fill in colorindex entries for i'th color component */ + nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ + blksize = blksize / nci; + + /* adjust colorindex pointers to provide padding at negative indexes. */ + if (pad) + cquantize->colorindex[i] += MAXJSAMPLE; + + /* in loop, val = index of current output value, */ + /* and k = largest j that maps to current val */ + indexptr = cquantize->colorindex[i]; + val = 0; + k = largest_input_value(cinfo, i, 0, nci-1); + for (j = 0; j <= MAXJSAMPLE; j++) { + while (j > k) /* advance val if past boundary */ + k = largest_input_value(cinfo, i, ++val, nci-1); + /* premultiply so that no multiplication needed in main processing */ + indexptr[j] = (JSAMPLE) (val * blksize); + } + /* Pad at both ends if necessary */ + if (pad) + for (j = 1; j <= MAXJSAMPLE; j++) { + indexptr[-j] = indexptr[0]; + indexptr[MAXJSAMPLE+j] = indexptr[MAXJSAMPLE]; + } + } +} + + +/* + * Create an ordered-dither array for a component having ncolors + * distinct output values. + */ + +LOCAL(ODITHER_MATRIX_PTR) +make_odither_array (j_decompress_ptr cinfo, int ncolors) +{ + ODITHER_MATRIX_PTR odither; + int j,k; + INT32 num,den; + + odither = (ODITHER_MATRIX_PTR) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(ODITHER_MATRIX)); + /* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1). + * Hence the dither value for the matrix cell with fill order f + * (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1). + * On 16-bit-int machine, be careful to avoid overflow. + */ + den = 2 * ODITHER_CELLS * ((INT32) (ncolors - 1)); + for (j = 0; j < ODITHER_SIZE; j++) { + for (k = 0; k < ODITHER_SIZE; k++) { + num = ((INT32) (ODITHER_CELLS-1 - 2*((int)base_dither_matrix[j][k]))) + * MAXJSAMPLE; + /* Ensure round towards zero despite C's lack of consistency + * about rounding negative values in integer division... + */ + odither[j][k] = (int) (num<0 ? -((-num)/den) : num/den); + } + } + return odither; +} + + +/* + * Create the ordered-dither tables. + * Components having the same number of representative colors may + * share a dither table. + */ + +LOCAL(void) +create_odither_tables (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + ODITHER_MATRIX_PTR odither; + int i, j, nci; + + for (i = 0; i < cinfo->out_color_components; i++) { + nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ + odither = NULL; /* search for matching prior component */ + for (j = 0; j < i; j++) { + if (nci == cquantize->Ncolors[j]) { + odither = cquantize->odither[j]; + break; + } + } + if (odither == NULL) /* need a new table? */ + odither = make_odither_array(cinfo, nci); + cquantize->odither[i] = odither; + } +} + + +/* + * Map some rows of pixels to the output colormapped representation. + */ + +METHODDEF(void) +color_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* General case, no dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + JSAMPARRAY colorindex = cquantize->colorindex; + register int pixcode, ci; + register JSAMPROW ptrin, ptrout; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + register int nc = cinfo->out_color_components; + + for (row = 0; row < num_rows; row++) { + ptrin = input_buf[row]; + ptrout = output_buf[row]; + for (col = width; col > 0; col--) { + pixcode = 0; + for (ci = 0; ci < nc; ci++) { + pixcode += GETJSAMPLE(colorindex[ci][GETJSAMPLE(*ptrin++)]); + } + *ptrout++ = (JSAMPLE) pixcode; + } + } +} + + +METHODDEF(void) +color_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* Fast path for out_color_components==3, no dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register int pixcode; + register JSAMPROW ptrin, ptrout; + JSAMPROW colorindex0 = cquantize->colorindex[0]; + JSAMPROW colorindex1 = cquantize->colorindex[1]; + JSAMPROW colorindex2 = cquantize->colorindex[2]; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + ptrin = input_buf[row]; + ptrout = output_buf[row]; + for (col = width; col > 0; col--) { + pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*ptrin++)]); + pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*ptrin++)]); + pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*ptrin++)]); + *ptrout++ = (JSAMPLE) pixcode; + } + } +} + + +METHODDEF(void) +quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* General case, with ordered dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register JSAMPROW input_ptr; + register JSAMPROW output_ptr; + JSAMPROW colorindex_ci; + int * dither; /* points to active row of dither matrix */ + int row_index, col_index; /* current indexes into dither matrix */ + int nc = cinfo->out_color_components; + int ci; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + /* Initialize output values to 0 so can process components separately */ + jzero_far((void FAR *) output_buf[row], + (size_t) (width * SIZEOF(JSAMPLE))); + row_index = cquantize->row_index; + for (ci = 0; ci < nc; ci++) { + input_ptr = input_buf[row] + ci; + output_ptr = output_buf[row]; + colorindex_ci = cquantize->colorindex[ci]; + dither = cquantize->odither[ci][row_index]; + col_index = 0; + + for (col = width; col > 0; col--) { + /* Form pixel value + dither, range-limit to 0..MAXJSAMPLE, + * select output value, accumulate into output code for this pixel. + * Range-limiting need not be done explicitly, as we have extended + * the colorindex table to produce the right answers for out-of-range + * inputs. The maximum dither is +- MAXJSAMPLE; this sets the + * required amount of padding. + */ + *output_ptr += colorindex_ci[GETJSAMPLE(*input_ptr)+dither[col_index]]; + input_ptr += nc; + output_ptr++; + col_index = (col_index + 1) & ODITHER_MASK; + } + } + /* Advance row index for next row */ + row_index = (row_index + 1) & ODITHER_MASK; + cquantize->row_index = row_index; + } +} + + +METHODDEF(void) +quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* Fast path for out_color_components==3, with ordered dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register int pixcode; + register JSAMPROW input_ptr; + register JSAMPROW output_ptr; + JSAMPROW colorindex0 = cquantize->colorindex[0]; + JSAMPROW colorindex1 = cquantize->colorindex[1]; + JSAMPROW colorindex2 = cquantize->colorindex[2]; + int * dither0; /* points to active row of dither matrix */ + int * dither1; + int * dither2; + int row_index, col_index; /* current indexes into dither matrix */ + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + row_index = cquantize->row_index; + input_ptr = input_buf[row]; + output_ptr = output_buf[row]; + dither0 = cquantize->odither[0][row_index]; + dither1 = cquantize->odither[1][row_index]; + dither2 = cquantize->odither[2][row_index]; + col_index = 0; + + for (col = width; col > 0; col--) { + pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*input_ptr++) + + dither0[col_index]]); + pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*input_ptr++) + + dither1[col_index]]); + pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*input_ptr++) + + dither2[col_index]]); + *output_ptr++ = (JSAMPLE) pixcode; + col_index = (col_index + 1) & ODITHER_MASK; + } + row_index = (row_index + 1) & ODITHER_MASK; + cquantize->row_index = row_index; + } +} + + +METHODDEF(void) +quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* General case, with Floyd-Steinberg dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register LOCFSERROR cur; /* current error or pixel value */ + LOCFSERROR belowerr; /* error for pixel below cur */ + LOCFSERROR bpreverr; /* error for below/prev col */ + LOCFSERROR bnexterr; /* error for below/next col */ + LOCFSERROR delta; + register FSERRPTR errorptr; /* => fserrors[] at column before current */ + register JSAMPROW input_ptr; + register JSAMPROW output_ptr; + JSAMPROW colorindex_ci; + JSAMPROW colormap_ci; + int pixcode; + int nc = cinfo->out_color_components; + int dir; /* 1 for left-to-right, -1 for right-to-left */ + int dirnc; /* dir * nc */ + int ci; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + JSAMPLE *range_limit = cinfo->sample_range_limit; + SHIFT_TEMPS + + for (row = 0; row < num_rows; row++) { + /* Initialize output values to 0 so can process components separately */ + jzero_far((void FAR *) output_buf[row], + (size_t) (width * SIZEOF(JSAMPLE))); + for (ci = 0; ci < nc; ci++) { + input_ptr = input_buf[row] + ci; + output_ptr = output_buf[row]; + if (cquantize->on_odd_row) { + /* work right to left in this row */ + input_ptr += (width-1) * nc; /* so point to rightmost pixel */ + output_ptr += width-1; + dir = -1; + dirnc = -nc; + errorptr = cquantize->fserrors[ci] + (width+1); /* => entry after last column */ + } else { + /* work left to right in this row */ + dir = 1; + dirnc = nc; + errorptr = cquantize->fserrors[ci]; /* => entry before first column */ + } + colorindex_ci = cquantize->colorindex[ci]; + colormap_ci = cquantize->sv_colormap[ci]; + /* Preset error values: no error propagated to first pixel from left */ + cur = 0; + /* and no error propagated to row below yet */ + belowerr = bpreverr = 0; + + for (col = width; col > 0; col--) { + /* cur holds the error propagated from the previous pixel on the + * current line. Add the error propagated from the previous line + * to form the complete error correction term for this pixel, and + * round the error term (which is expressed * 16) to an integer. + * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct + * for either sign of the error value. + * Note: errorptr points to *previous* column's array entry. + */ + cur = RIGHT_SHIFT(cur + errorptr[dir] + 8, 4); + /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. + * The maximum error is +- MAXJSAMPLE; this sets the required size + * of the range_limit array. + */ + cur += GETJSAMPLE(*input_ptr); + cur = GETJSAMPLE(range_limit[cur]); + /* Select output value, accumulate into output code for this pixel */ + pixcode = GETJSAMPLE(colorindex_ci[cur]); + *output_ptr += (JSAMPLE) pixcode; + /* Compute actual representation error at this pixel */ + /* Note: we can do this even though we don't have the final */ + /* pixel code, because the colormap is orthogonal. */ + cur -= GETJSAMPLE(colormap_ci[pixcode]); + /* Compute error fractions to be propagated to adjacent pixels. + * Add these into the running sums, and simultaneously shift the + * next-line error sums left by 1 column. + */ + bnexterr = cur; + delta = cur * 2; + cur += delta; /* form error * 3 */ + errorptr[0] = (FSERROR) (bpreverr + cur); + cur += delta; /* form error * 5 */ + bpreverr = belowerr + cur; + belowerr = bnexterr; + cur += delta; /* form error * 7 */ + /* At this point cur contains the 7/16 error value to be propagated + * to the next pixel on the current line, and all the errors for the + * next line have been shifted over. We are therefore ready to move on. + */ + input_ptr += dirnc; /* advance input ptr to next column */ + output_ptr += dir; /* advance output ptr to next column */ + errorptr += dir; /* advance errorptr to current column */ + } + /* Post-loop cleanup: we must unload the final error value into the + * final fserrors[] entry. Note we need not unload belowerr because + * it is for the dummy column before or after the actual array. + */ + errorptr[0] = (FSERROR) bpreverr; /* unload prev err into array */ + } + cquantize->on_odd_row = (cquantize->on_odd_row ? FALSE : TRUE); + } +} + + +/* + * Allocate workspace for Floyd-Steinberg errors. + */ + +LOCAL(void) +alloc_fs_workspace (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + size_t arraysize; + int i; + + arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); + for (i = 0; i < cinfo->out_color_components; i++) { + cquantize->fserrors[i] = (FSERRPTR) + (*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); + } +} + + +/* + * Initialize for one-pass color quantization. + */ + +METHODDEF(void) +start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + size_t arraysize; + int i; + + /* Install my colormap. */ + cinfo->colormap = cquantize->sv_colormap; + cinfo->actual_number_of_colors = cquantize->sv_actual; + + /* Initialize for desired dithering mode. */ + switch (cinfo->dither_mode) { + case JDITHER_NONE: + if (cinfo->out_color_components == 3) + cquantize->pub.color_quantize = color_quantize3; + else + cquantize->pub.color_quantize = color_quantize; + break; + case JDITHER_ORDERED: + if (cinfo->out_color_components == 3) + cquantize->pub.color_quantize = quantize3_ord_dither; + else + cquantize->pub.color_quantize = quantize_ord_dither; + cquantize->row_index = 0; /* initialize state for ordered dither */ + /* If user changed to ordered dither from another mode, + * we must recreate the color index table with padding. + * This will cost extra space, but probably isn't very likely. + */ + if (! cquantize->is_padded) + create_colorindex(cinfo); + /* Create ordered-dither tables if we didn't already. */ + if (cquantize->odither[0] == NULL) + create_odither_tables(cinfo); + break; + case JDITHER_FS: + cquantize->pub.color_quantize = quantize_fs_dither; + cquantize->on_odd_row = FALSE; /* initialize state for F-S dither */ + /* Allocate Floyd-Steinberg workspace if didn't already. */ + if (cquantize->fserrors[0] == NULL) + alloc_fs_workspace(cinfo); + /* Initialize the propagated errors to zero. */ + arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); + for (i = 0; i < cinfo->out_color_components; i++) + jzero_far((void FAR *) cquantize->fserrors[i], arraysize); + break; + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } +} + + +/* + * Finish up at the end of the pass. + */ + +METHODDEF(void) +finish_pass_1_quant (j_decompress_ptr cinfo) +{ + /* no work in 1-pass case */ +} + + +/* + * Switch to a new external colormap between output passes. + * Shouldn't get to this module! + */ + +METHODDEF(void) +new_color_map_1_quant (j_decompress_ptr cinfo) +{ + ERREXIT(cinfo, JERR_MODE_CHANGE); +} + + +/* + * Module initialization routine for 1-pass color quantization. + */ + +GLOBAL(void) +jinit_1pass_quantizer (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize; + + cquantize = (my_cquantize_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_cquantizer)); + cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; + cquantize->pub.start_pass = start_pass_1_quant; + cquantize->pub.finish_pass = finish_pass_1_quant; + cquantize->pub.new_color_map = new_color_map_1_quant; + cquantize->fserrors[0] = NULL; /* Flag FS workspace not allocated */ + cquantize->odither[0] = NULL; /* Also flag odither arrays not allocated */ + + /* Make sure my internal arrays won't overflow */ + if (cinfo->out_color_components > MAX_Q_COMPS) + ERREXIT1(cinfo, JERR_QUANT_COMPONENTS, MAX_Q_COMPS); + /* Make sure colormap indexes can be represented by JSAMPLEs */ + if (cinfo->desired_number_of_colors > (MAXJSAMPLE+1)) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE+1); + + /* Create the colormap and color index table. */ + create_colormap(cinfo); + create_colorindex(cinfo); + + /* Allocate Floyd-Steinberg workspace now if requested. + * We do this now since it is FAR storage and may affect the memory + * manager's space calculations. If the user changes to FS dither + * mode in a later pass, we will allocate the space then, and will + * possibly overrun the max_memory_to_use setting. + */ + if (cinfo->dither_mode == JDITHER_FS) + alloc_fs_workspace(cinfo); +} + +#endif /* QUANT_1PASS_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/jquant2.c b/src/dep/src/irrlicht/jpeglib/jquant2.c index 87a3920..af601e3 100644 --- a/src/dep/src/irrlicht/jpeglib/jquant2.c +++ b/src/dep/src/irrlicht/jpeglib/jquant2.c @@ -1,1310 +1,1310 @@ -/* - * jquant2.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains 2-pass color quantization (color mapping) routines. - * These routines provide selection of a custom color map for an image, - * followed by mapping of the image to that color map, with optional - * Floyd-Steinberg dithering. - * It is also possible to use just the second pass to map to an arbitrary - * externally-given color map. - * - * Note: ordered dithering is not supported, since there isn't any fast - * way to compute intercolor distances; it's unclear that ordered dither's - * fundamental assumptions even hold with an irregularly spaced color map. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef QUANT_2PASS_SUPPORTED - - -/* - * This module implements the well-known Heckbert paradigm for color - * quantization. Most of the ideas used here can be traced back to - * Heckbert's seminal paper - * Heckbert, Paul. "Color Image Quantization for Frame Buffer Display", - * Proc. SIGGRAPH '82, Computer Graphics v.16 #3 (July 1982), pp 297-304. - * - * In the first pass over the image, we accumulate a histogram showing the - * usage count of each possible color. To keep the histogram to a reasonable - * size, we reduce the precision of the input; typical practice is to retain - * 5 or 6 bits per color, so that 8 or 4 different input values are counted - * in the same histogram cell. - * - * Next, the color-selection step begins with a box representing the whole - * color space, and repeatedly splits the "largest" remaining box until we - * have as many boxes as desired colors. Then the mean color in each - * remaining box becomes one of the possible output colors. - * - * The second pass over the image maps each input pixel to the closest output - * color (optionally after applying a Floyd-Steinberg dithering correction). - * This mapping is logically trivial, but making it go fast enough requires - * considerable care. - * - * Heckbert-style quantizers vary a good deal in their policies for choosing - * the "largest" box and deciding where to cut it. The particular policies - * used here have proved out well in experimental comparisons, but better ones - * may yet be found. - * - * In earlier versions of the IJG code, this module quantized in YCbCr color - * space, processing the raw upsampled data without a color conversion step. - * This allowed the color conversion math to be done only once per colormap - * entry, not once per pixel. However, that optimization precluded other - * useful optimizations (such as merging color conversion with upsampling) - * and it also interfered with desired capabilities such as quantizing to an - * externally-supplied colormap. We have therefore abandoned that approach. - * The present code works in the post-conversion color space, typically RGB. - * - * To improve the visual quality of the results, we actually work in scaled - * RGB space, giving G distances more weight than R, and R in turn more than - * B. To do everything in integer math, we must use integer scale factors. - * The 2/3/1 scale factors used here correspond loosely to the relative - * weights of the colors in the NTSC grayscale equation. - * If you want to use this code to quantize a non-RGB color space, you'll - * probably need to change these scale factors. - */ - -#define R_SCALE 2 /* scale R distances by this much */ -#define G_SCALE 3 /* scale G distances by this much */ -#define B_SCALE 1 /* and B by this much */ - -/* Relabel R/G/B as components 0/1/2, respecting the RGB ordering defined - * in jmorecfg.h. As the code stands, it will do the right thing for R,G,B - * and B,G,R orders. If you define some other weird order in jmorecfg.h, - * you'll get compile errors until you extend this logic. In that case - * you'll probably want to tweak the histogram sizes too. - */ - -#if RGB_RED == 0 -#define C0_SCALE R_SCALE -#endif -#if RGB_BLUE == 0 -#define C0_SCALE B_SCALE -#endif -#if RGB_GREEN == 1 -#define C1_SCALE G_SCALE -#endif -#if RGB_RED == 2 -#define C2_SCALE R_SCALE -#endif -#if RGB_BLUE == 2 -#define C2_SCALE B_SCALE -#endif - - -/* - * First we have the histogram data structure and routines for creating it. - * - * The number of bits of precision can be adjusted by changing these symbols. - * We recommend keeping 6 bits for G and 5 each for R and B. - * If you have plenty of memory and cycles, 6 bits all around gives marginally - * better results; if you are short of memory, 5 bits all around will save - * some space but degrade the results. - * To maintain a fully accurate histogram, we'd need to allocate a "long" - * (preferably unsigned long) for each cell. In practice this is overkill; - * we can get by with 16 bits per cell. Few of the cell counts will overflow, - * and clamping those that do overflow to the maximum value will give close- - * enough results. This reduces the recommended histogram size from 256Kb - * to 128Kb, which is a useful savings on PC-class machines. - * (In the second pass the histogram space is re-used for pixel mapping data; - * in that capacity, each cell must be able to store zero to the number of - * desired colors. 16 bits/cell is plenty for that too.) - * Since the JPEG code is intended to run in small memory model on 80x86 - * machines, we can't just allocate the histogram in one chunk. Instead - * of a true 3-D array, we use a row of pointers to 2-D arrays. Each - * pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and - * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries. Note that - * on 80x86 machines, the pointer row is in near memory but the actual - * arrays are in far memory (same arrangement as we use for image arrays). - */ - -#define MAXNUMCOLORS (MAXJSAMPLE+1) /* maximum size of colormap */ - -/* These will do the right thing for either R,G,B or B,G,R color order, - * but you may not like the results for other color orders. - */ -#define HIST_C0_BITS 5 /* bits of precision in R/B histogram */ -#define HIST_C1_BITS 6 /* bits of precision in G histogram */ -#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */ - -/* Number of elements along histogram axes. */ -#define HIST_C0_ELEMS (1<cquantize; - register JSAMPROW ptr; - register histptr histp; - register hist3d histogram = cquantize->histogram; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - ptr = input_buf[row]; - for (col = width; col > 0; col--) { - /* get pixel value and index into the histogram */ - histp = & histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT] - [GETJSAMPLE(ptr[1]) >> C1_SHIFT] - [GETJSAMPLE(ptr[2]) >> C2_SHIFT]; - /* increment, check for overflow and undo increment if so. */ - if (++(*histp) <= 0) - (*histp)--; - ptr += 3; - } - } -} - - -/* - * Next we have the really interesting routines: selection of a colormap - * given the completed histogram. - * These routines work with a list of "boxes", each representing a rectangular - * subset of the input color space (to histogram precision). - */ - -typedef struct { - /* The bounds of the box (inclusive); expressed as histogram indexes */ - int c0min, c0max; - int c1min, c1max; - int c2min, c2max; - /* The volume (actually 2-norm) of the box */ - INT32 volume; - /* The number of nonzero histogram cells within this box */ - long colorcount; -} box; - -typedef box * boxptr; - - -LOCAL(boxptr) -find_biggest_color_pop (boxptr boxlist, int numboxes) -/* Find the splittable box with the largest color population */ -/* Returns NULL if no splittable boxes remain */ -{ - register boxptr boxp; - register int i; - register long maxc = 0; - boxptr which = NULL; - - for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { - if (boxp->colorcount > maxc && boxp->volume > 0) { - which = boxp; - maxc = boxp->colorcount; - } - } - return which; -} - - -LOCAL(boxptr) -find_biggest_volume (boxptr boxlist, int numboxes) -/* Find the splittable box with the largest (scaled) volume */ -/* Returns NULL if no splittable boxes remain */ -{ - register boxptr boxp; - register int i; - register INT32 maxv = 0; - boxptr which = NULL; - - for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { - if (boxp->volume > maxv) { - which = boxp; - maxv = boxp->volume; - } - } - return which; -} - - -LOCAL(void) -update_box (j_decompress_ptr cinfo, boxptr boxp) -/* Shrink the min/max bounds of a box to enclose only nonzero elements, */ -/* and recompute its volume and population */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - histptr histp; - int c0,c1,c2; - int c0min,c0max,c1min,c1max,c2min,c2max; - INT32 dist0,dist1,dist2; - long ccount; - - c0min = boxp->c0min; c0max = boxp->c0max; - c1min = boxp->c1min; c1max = boxp->c1max; - c2min = boxp->c2min; c2max = boxp->c2max; - - if (c0max > c0min) - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c0min = c0min = c0; - goto have_c0min; - } - } - have_c0min: - if (c0max > c0min) - for (c0 = c0max; c0 >= c0min; c0--) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c0max = c0max = c0; - goto have_c0max; - } - } - have_c0max: - if (c1max > c1min) - for (c1 = c1min; c1 <= c1max; c1++) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c1min = c1min = c1; - goto have_c1min; - } - } - have_c1min: - if (c1max > c1min) - for (c1 = c1max; c1 >= c1min; c1--) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c1max = c1max = c1; - goto have_c1max; - } - } - have_c1max: - if (c2max > c2min) - for (c2 = c2min; c2 <= c2max; c2++) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1min][c2]; - for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) - if (*histp != 0) { - boxp->c2min = c2min = c2; - goto have_c2min; - } - } - have_c2min: - if (c2max > c2min) - for (c2 = c2max; c2 >= c2min; c2--) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1min][c2]; - for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) - if (*histp != 0) { - boxp->c2max = c2max = c2; - goto have_c2max; - } - } - have_c2max: - - /* Update box volume. - * We use 2-norm rather than real volume here; this biases the method - * against making long narrow boxes, and it has the side benefit that - * a box is splittable iff norm > 0. - * Since the differences are expressed in histogram-cell units, - * we have to shift back to JSAMPLE units to get consistent distances; - * after which, we scale according to the selected distance scale factors. - */ - dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE; - dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE; - dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE; - boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2; - - /* Now scan remaining volume of box and compute population */ - ccount = 0; - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++, histp++) - if (*histp != 0) { - ccount++; - } - } - boxp->colorcount = ccount; -} - - -LOCAL(int) -median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes, - int desired_colors) -/* Repeatedly select and split the largest box until we have enough boxes */ -{ - int n,lb; - int c0,c1,c2,cmax; - register boxptr b1,b2; - - while (numboxes < desired_colors) { - /* Select box to split. - * Current algorithm: by population for first half, then by volume. - */ - if (numboxes*2 <= desired_colors) { - b1 = find_biggest_color_pop(boxlist, numboxes); - } else { - b1 = find_biggest_volume(boxlist, numboxes); - } - if (b1 == NULL) /* no splittable boxes left! */ - break; - b2 = &boxlist[numboxes]; /* where new box will go */ - /* Copy the color bounds to the new box. */ - b2->c0max = b1->c0max; b2->c1max = b1->c1max; b2->c2max = b1->c2max; - b2->c0min = b1->c0min; b2->c1min = b1->c1min; b2->c2min = b1->c2min; - /* Choose which axis to split the box on. - * Current algorithm: longest scaled axis. - * See notes in update_box about scaling distances. - */ - c0 = ((b1->c0max - b1->c0min) << C0_SHIFT) * C0_SCALE; - c1 = ((b1->c1max - b1->c1min) << C1_SHIFT) * C1_SCALE; - c2 = ((b1->c2max - b1->c2min) << C2_SHIFT) * C2_SCALE; - /* We want to break any ties in favor of green, then red, blue last. - * This code does the right thing for R,G,B or B,G,R color orders only. - */ -#if RGB_RED == 0 - cmax = c1; n = 1; - if (c0 > cmax) { cmax = c0; n = 0; } - if (c2 > cmax) { n = 2; } -#else - cmax = c1; n = 1; - if (c2 > cmax) { cmax = c2; n = 2; } - if (c0 > cmax) { n = 0; } -#endif - /* Choose split point along selected axis, and update box bounds. - * Current algorithm: split at halfway point. - * (Since the box has been shrunk to minimum volume, - * any split will produce two nonempty subboxes.) - * Note that lb value is max for lower box, so must be < old max. - */ - switch (n) { - case 0: - lb = (b1->c0max + b1->c0min) / 2; - b1->c0max = lb; - b2->c0min = lb+1; - break; - case 1: - lb = (b1->c1max + b1->c1min) / 2; - b1->c1max = lb; - b2->c1min = lb+1; - break; - case 2: - lb = (b1->c2max + b1->c2min) / 2; - b1->c2max = lb; - b2->c2min = lb+1; - break; - } - /* Update stats for boxes */ - update_box(cinfo, b1); - update_box(cinfo, b2); - numboxes++; - } - return numboxes; -} - - -LOCAL(void) -compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor) -/* Compute representative color for a box, put it in colormap[icolor] */ -{ - /* Current algorithm: mean weighted by pixels (not colors) */ - /* Note it is important to get the rounding correct! */ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - histptr histp; - int c0,c1,c2; - int c0min,c0max,c1min,c1max,c2min,c2max; - long count; - long total = 0; - long c0total = 0; - long c1total = 0; - long c2total = 0; - - c0min = boxp->c0min; c0max = boxp->c0max; - c1min = boxp->c1min; c1max = boxp->c1max; - c2min = boxp->c2min; c2max = boxp->c2max; - - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) { - if ((count = *histp++) != 0) { - total += count; - c0total += ((c0 << C0_SHIFT) + ((1<>1)) * count; - c1total += ((c1 << C1_SHIFT) + ((1<>1)) * count; - c2total += ((c2 << C2_SHIFT) + ((1<>1)) * count; - } - } - } - - cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total); - cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total); - cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total); -} - - -LOCAL(void) -select_colors (j_decompress_ptr cinfo, int desired_colors) -/* Master routine for color selection */ -{ - boxptr boxlist; - int numboxes; - int i; - - /* Allocate workspace for box list */ - boxlist = (boxptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(box)); - /* Initialize one box containing whole space */ - numboxes = 1; - boxlist[0].c0min = 0; - boxlist[0].c0max = MAXJSAMPLE >> C0_SHIFT; - boxlist[0].c1min = 0; - boxlist[0].c1max = MAXJSAMPLE >> C1_SHIFT; - boxlist[0].c2min = 0; - boxlist[0].c2max = MAXJSAMPLE >> C2_SHIFT; - /* Shrink it to actually-used volume and set its statistics */ - update_box(cinfo, & boxlist[0]); - /* Perform median-cut to produce final box list */ - numboxes = median_cut(cinfo, boxlist, numboxes, desired_colors); - /* Compute the representative color for each box, fill colormap */ - for (i = 0; i < numboxes; i++) - compute_color(cinfo, & boxlist[i], i); - cinfo->actual_number_of_colors = numboxes; - TRACEMS1(cinfo, 1, JTRC_QUANT_SELECTED, numboxes); -} - - -/* - * These routines are concerned with the time-critical task of mapping input - * colors to the nearest color in the selected colormap. - * - * We re-use the histogram space as an "inverse color map", essentially a - * cache for the results of nearest-color searches. All colors within a - * histogram cell will be mapped to the same colormap entry, namely the one - * closest to the cell's center. This may not be quite the closest entry to - * the actual input color, but it's almost as good. A zero in the cache - * indicates we haven't found the nearest color for that cell yet; the array - * is cleared to zeroes before starting the mapping pass. When we find the - * nearest color for a cell, its colormap index plus one is recorded in the - * cache for future use. The pass2 scanning routines call fill_inverse_cmap - * when they need to use an unfilled entry in the cache. - * - * Our method of efficiently finding nearest colors is based on the "locally - * sorted search" idea described by Heckbert and on the incremental distance - * calculation described by Spencer W. Thomas in chapter III.1 of Graphics - * Gems II (James Arvo, ed. Academic Press, 1991). Thomas points out that - * the distances from a given colormap entry to each cell of the histogram can - * be computed quickly using an incremental method: the differences between - * distances to adjacent cells themselves differ by a constant. This allows a - * fairly fast implementation of the "brute force" approach of computing the - * distance from every colormap entry to every histogram cell. Unfortunately, - * it needs a work array to hold the best-distance-so-far for each histogram - * cell (because the inner loop has to be over cells, not colormap entries). - * The work array elements have to be INT32s, so the work array would need - * 256Kb at our recommended precision. This is not feasible in DOS machines. - * - * To get around these problems, we apply Thomas' method to compute the - * nearest colors for only the cells within a small subbox of the histogram. - * The work array need be only as big as the subbox, so the memory usage - * problem is solved. Furthermore, we need not fill subboxes that are never - * referenced in pass2; many images use only part of the color gamut, so a - * fair amount of work is saved. An additional advantage of this - * approach is that we can apply Heckbert's locality criterion to quickly - * eliminate colormap entries that are far away from the subbox; typically - * three-fourths of the colormap entries are rejected by Heckbert's criterion, - * and we need not compute their distances to individual cells in the subbox. - * The speed of this approach is heavily influenced by the subbox size: too - * small means too much overhead, too big loses because Heckbert's criterion - * can't eliminate as many colormap entries. Empirically the best subbox - * size seems to be about 1/512th of the histogram (1/8th in each direction). - * - * Thomas' article also describes a refined method which is asymptotically - * faster than the brute-force method, but it is also far more complex and - * cannot efficiently be applied to small subboxes. It is therefore not - * useful for programs intended to be portable to DOS machines. On machines - * with plenty of memory, filling the whole histogram in one shot with Thomas' - * refined method might be faster than the present code --- but then again, - * it might not be any faster, and it's certainly more complicated. - */ - - -/* log2(histogram cells in update box) for each axis; this can be adjusted */ -#define BOX_C0_LOG (HIST_C0_BITS-3) -#define BOX_C1_LOG (HIST_C1_BITS-3) -#define BOX_C2_LOG (HIST_C2_BITS-3) - -#define BOX_C0_ELEMS (1<actual_number_of_colors; - int maxc0, maxc1, maxc2; - int centerc0, centerc1, centerc2; - int i, x, ncolors; - INT32 minmaxdist, min_dist, max_dist, tdist; - INT32 mindist[MAXNUMCOLORS]; /* min distance to colormap entry i */ - - /* Compute true coordinates of update box's upper corner and center. - * Actually we compute the coordinates of the center of the upper-corner - * histogram cell, which are the upper bounds of the volume we care about. - * Note that since ">>" rounds down, the "center" values may be closer to - * min than to max; hence comparisons to them must be "<=", not "<". - */ - maxc0 = minc0 + ((1 << BOX_C0_SHIFT) - (1 << C0_SHIFT)); - centerc0 = (minc0 + maxc0) >> 1; - maxc1 = minc1 + ((1 << BOX_C1_SHIFT) - (1 << C1_SHIFT)); - centerc1 = (minc1 + maxc1) >> 1; - maxc2 = minc2 + ((1 << BOX_C2_SHIFT) - (1 << C2_SHIFT)); - centerc2 = (minc2 + maxc2) >> 1; - - /* For each color in colormap, find: - * 1. its minimum squared-distance to any point in the update box - * (zero if color is within update box); - * 2. its maximum squared-distance to any point in the update box. - * Both of these can be found by considering only the corners of the box. - * We save the minimum distance for each color in mindist[]; - * only the smallest maximum distance is of interest. - */ - minmaxdist = 0x7FFFFFFFL; - - for (i = 0; i < numcolors; i++) { - /* We compute the squared-c0-distance term, then add in the other two. */ - x = GETJSAMPLE(cinfo->colormap[0][i]); - if (x < minc0) { - tdist = (x - minc0) * C0_SCALE; - min_dist = tdist*tdist; - tdist = (x - maxc0) * C0_SCALE; - max_dist = tdist*tdist; - } else if (x > maxc0) { - tdist = (x - maxc0) * C0_SCALE; - min_dist = tdist*tdist; - tdist = (x - minc0) * C0_SCALE; - max_dist = tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - min_dist = 0; - if (x <= centerc0) { - tdist = (x - maxc0) * C0_SCALE; - max_dist = tdist*tdist; - } else { - tdist = (x - minc0) * C0_SCALE; - max_dist = tdist*tdist; - } - } - - x = GETJSAMPLE(cinfo->colormap[1][i]); - if (x < minc1) { - tdist = (x - minc1) * C1_SCALE; - min_dist += tdist*tdist; - tdist = (x - maxc1) * C1_SCALE; - max_dist += tdist*tdist; - } else if (x > maxc1) { - tdist = (x - maxc1) * C1_SCALE; - min_dist += tdist*tdist; - tdist = (x - minc1) * C1_SCALE; - max_dist += tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - if (x <= centerc1) { - tdist = (x - maxc1) * C1_SCALE; - max_dist += tdist*tdist; - } else { - tdist = (x - minc1) * C1_SCALE; - max_dist += tdist*tdist; - } - } - - x = GETJSAMPLE(cinfo->colormap[2][i]); - if (x < minc2) { - tdist = (x - minc2) * C2_SCALE; - min_dist += tdist*tdist; - tdist = (x - maxc2) * C2_SCALE; - max_dist += tdist*tdist; - } else if (x > maxc2) { - tdist = (x - maxc2) * C2_SCALE; - min_dist += tdist*tdist; - tdist = (x - minc2) * C2_SCALE; - max_dist += tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - if (x <= centerc2) { - tdist = (x - maxc2) * C2_SCALE; - max_dist += tdist*tdist; - } else { - tdist = (x - minc2) * C2_SCALE; - max_dist += tdist*tdist; - } - } - - mindist[i] = min_dist; /* save away the results */ - if (max_dist < minmaxdist) - minmaxdist = max_dist; - } - - /* Now we know that no cell in the update box is more than minmaxdist - * away from some colormap entry. Therefore, only colors that are - * within minmaxdist of some part of the box need be considered. - */ - ncolors = 0; - for (i = 0; i < numcolors; i++) { - if (mindist[i] <= minmaxdist) - colorlist[ncolors++] = (JSAMPLE) i; - } - return ncolors; -} - - -LOCAL(void) -find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2, - int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[]) -/* Find the closest colormap entry for each cell in the update box, - * given the list of candidate colors prepared by find_nearby_colors. - * Return the indexes of the closest entries in the bestcolor[] array. - * This routine uses Thomas' incremental distance calculation method to - * find the distance from a colormap entry to successive cells in the box. - */ -{ - int ic0, ic1, ic2; - int i, icolor; - register INT32 * bptr; /* pointer into bestdist[] array */ - JSAMPLE * cptr; /* pointer into bestcolor[] array */ - INT32 dist0, dist1; /* initial distance values */ - register INT32 dist2; /* current distance in inner loop */ - INT32 xx0, xx1; /* distance increments */ - register INT32 xx2; - INT32 inc0, inc1, inc2; /* initial values for increments */ - /* This array holds the distance to the nearest-so-far color for each cell */ - INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; - - /* Initialize best-distance for each cell of the update box */ - bptr = bestdist; - for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--) - *bptr++ = 0x7FFFFFFFL; - - /* For each color selected by find_nearby_colors, - * compute its distance to the center of each cell in the box. - * If that's less than best-so-far, update best distance and color number. - */ - - /* Nominal steps between cell centers ("x" in Thomas article) */ -#define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE) -#define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE) -#define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE) - - for (i = 0; i < numcolors; i++) { - icolor = GETJSAMPLE(colorlist[i]); - /* Compute (square of) distance from minc0/c1/c2 to this color */ - inc0 = (minc0 - GETJSAMPLE(cinfo->colormap[0][icolor])) * C0_SCALE; - dist0 = inc0*inc0; - inc1 = (minc1 - GETJSAMPLE(cinfo->colormap[1][icolor])) * C1_SCALE; - dist0 += inc1*inc1; - inc2 = (minc2 - GETJSAMPLE(cinfo->colormap[2][icolor])) * C2_SCALE; - dist0 += inc2*inc2; - /* Form the initial difference increments */ - inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0; - inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1; - inc2 = inc2 * (2 * STEP_C2) + STEP_C2 * STEP_C2; - /* Now loop over all cells in box, updating distance per Thomas method */ - bptr = bestdist; - cptr = bestcolor; - xx0 = inc0; - for (ic0 = BOX_C0_ELEMS-1; ic0 >= 0; ic0--) { - dist1 = dist0; - xx1 = inc1; - for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) { - dist2 = dist1; - xx2 = inc2; - for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) { - if (dist2 < *bptr) { - *bptr = dist2; - *cptr = (JSAMPLE) icolor; - } - dist2 += xx2; - xx2 += 2 * STEP_C2 * STEP_C2; - bptr++; - cptr++; - } - dist1 += xx1; - xx1 += 2 * STEP_C1 * STEP_C1; - } - dist0 += xx0; - xx0 += 2 * STEP_C0 * STEP_C0; - } - } -} - - -LOCAL(void) -fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2) -/* Fill the inverse-colormap entries in the update box that contains */ -/* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */ -/* we can fill as many others as we wish.) */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - int minc0, minc1, minc2; /* lower left corner of update box */ - int ic0, ic1, ic2; - register JSAMPLE * cptr; /* pointer into bestcolor[] array */ - register histptr cachep; /* pointer into main cache array */ - /* This array lists the candidate colormap indexes. */ - JSAMPLE colorlist[MAXNUMCOLORS]; - int numcolors; /* number of candidate colors */ - /* This array holds the actually closest colormap index for each cell. */ - JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; - - /* Convert cell coordinates to update box ID */ - c0 >>= BOX_C0_LOG; - c1 >>= BOX_C1_LOG; - c2 >>= BOX_C2_LOG; - - /* Compute true coordinates of update box's origin corner. - * Actually we compute the coordinates of the center of the corner - * histogram cell, which are the lower bounds of the volume we care about. - */ - minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1); - minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1); - minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1); - - /* Determine which colormap entries are close enough to be candidates - * for the nearest entry to some cell in the update box. - */ - numcolors = find_nearby_colors(cinfo, minc0, minc1, minc2, colorlist); - - /* Determine the actually nearest colors. */ - find_best_colors(cinfo, minc0, minc1, minc2, numcolors, colorlist, - bestcolor); - - /* Save the best color numbers (plus 1) in the main cache array */ - c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */ - c1 <<= BOX_C1_LOG; - c2 <<= BOX_C2_LOG; - cptr = bestcolor; - for (ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++) { - for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) { - cachep = & histogram[c0+ic0][c1+ic1][c2]; - for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) { - *cachep++ = (histcell) (GETJSAMPLE(*cptr++) + 1); - } - } - } -} - - -/* - * Map some rows of pixels to the output colormapped representation. - */ - -METHODDEF(void) -pass2_no_dither (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) -/* This version performs no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - register JSAMPROW inptr, outptr; - register histptr cachep; - register int c0, c1, c2; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - inptr = input_buf[row]; - outptr = output_buf[row]; - for (col = width; col > 0; col--) { - /* get pixel value and index into the cache */ - c0 = GETJSAMPLE(*inptr++) >> C0_SHIFT; - c1 = GETJSAMPLE(*inptr++) >> C1_SHIFT; - c2 = GETJSAMPLE(*inptr++) >> C2_SHIFT; - cachep = & histogram[c0][c1][c2]; - /* If we have not seen this color before, find nearest colormap entry */ - /* and update the cache */ - if (*cachep == 0) - fill_inverse_cmap(cinfo, c0,c1,c2); - /* Now emit the colormap index for this cell */ - *outptr++ = (JSAMPLE) (*cachep - 1); - } - } -} - - -METHODDEF(void) -pass2_fs_dither (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) -/* This version performs Floyd-Steinberg dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */ - LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */ - LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */ - register FSERRPTR errorptr; /* => fserrors[] at column before current */ - JSAMPROW inptr; /* => current input pixel */ - JSAMPROW outptr; /* => current output pixel */ - histptr cachep; - int dir; /* +1 or -1 depending on direction */ - int dir3; /* 3*dir, for advancing inptr & errorptr */ - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - JSAMPLE *range_limit = cinfo->sample_range_limit; - int *error_limit = cquantize->error_limiter; - JSAMPROW colormap0 = cinfo->colormap[0]; - JSAMPROW colormap1 = cinfo->colormap[1]; - JSAMPROW colormap2 = cinfo->colormap[2]; - SHIFT_TEMPS - - for (row = 0; row < num_rows; row++) { - inptr = input_buf[row]; - outptr = output_buf[row]; - if (cquantize->on_odd_row) { - /* work right to left in this row */ - inptr += (width-1) * 3; /* so point to rightmost pixel */ - outptr += width-1; - dir = -1; - dir3 = -3; - errorptr = cquantize->fserrors + (width+1)*3; /* => entry after last column */ - cquantize->on_odd_row = FALSE; /* flip for next time */ - } else { - /* work left to right in this row */ - dir = 1; - dir3 = 3; - errorptr = cquantize->fserrors; /* => entry before first real column */ - cquantize->on_odd_row = TRUE; /* flip for next time */ - } - /* Preset error values: no error propagated to first pixel from left */ - cur0 = cur1 = cur2 = 0; - /* and no error propagated to row below yet */ - belowerr0 = belowerr1 = belowerr2 = 0; - bpreverr0 = bpreverr1 = bpreverr2 = 0; - - for (col = width; col > 0; col--) { - /* curN holds the error propagated from the previous pixel on the - * current line. Add the error propagated from the previous line - * to form the complete error correction term for this pixel, and - * round the error term (which is expressed * 16) to an integer. - * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct - * for either sign of the error value. - * Note: errorptr points to *previous* column's array entry. - */ - cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3+0] + 8, 4); - cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3+1] + 8, 4); - cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3+2] + 8, 4); - /* Limit the error using transfer function set by init_error_limit. - * See comments with init_error_limit for rationale. - */ - cur0 = error_limit[cur0]; - cur1 = error_limit[cur1]; - cur2 = error_limit[cur2]; - /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. - * The maximum error is +- MAXJSAMPLE (or less with error limiting); - * this sets the required size of the range_limit array. - */ - cur0 += GETJSAMPLE(inptr[0]); - cur1 += GETJSAMPLE(inptr[1]); - cur2 += GETJSAMPLE(inptr[2]); - cur0 = GETJSAMPLE(range_limit[cur0]); - cur1 = GETJSAMPLE(range_limit[cur1]); - cur2 = GETJSAMPLE(range_limit[cur2]); - /* Index into the cache with adjusted pixel value */ - cachep = & histogram[cur0>>C0_SHIFT][cur1>>C1_SHIFT][cur2>>C2_SHIFT]; - /* If we have not seen this color before, find nearest colormap */ - /* entry and update the cache */ - if (*cachep == 0) - fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT); - /* Now emit the colormap index for this cell */ - { register int pixcode = *cachep - 1; - *outptr = (JSAMPLE) pixcode; - /* Compute representation error for this pixel */ - cur0 -= GETJSAMPLE(colormap0[pixcode]); - cur1 -= GETJSAMPLE(colormap1[pixcode]); - cur2 -= GETJSAMPLE(colormap2[pixcode]); - } - /* Compute error fractions to be propagated to adjacent pixels. - * Add these into the running sums, and simultaneously shift the - * next-line error sums left by 1 column. - */ - { register LOCFSERROR bnexterr, delta; - - bnexterr = cur0; /* Process component 0 */ - delta = cur0 * 2; - cur0 += delta; /* form error * 3 */ - errorptr[0] = (FSERROR) (bpreverr0 + cur0); - cur0 += delta; /* form error * 5 */ - bpreverr0 = belowerr0 + cur0; - belowerr0 = bnexterr; - cur0 += delta; /* form error * 7 */ - bnexterr = cur1; /* Process component 1 */ - delta = cur1 * 2; - cur1 += delta; /* form error * 3 */ - errorptr[1] = (FSERROR) (bpreverr1 + cur1); - cur1 += delta; /* form error * 5 */ - bpreverr1 = belowerr1 + cur1; - belowerr1 = bnexterr; - cur1 += delta; /* form error * 7 */ - bnexterr = cur2; /* Process component 2 */ - delta = cur2 * 2; - cur2 += delta; /* form error * 3 */ - errorptr[2] = (FSERROR) (bpreverr2 + cur2); - cur2 += delta; /* form error * 5 */ - bpreverr2 = belowerr2 + cur2; - belowerr2 = bnexterr; - cur2 += delta; /* form error * 7 */ - } - /* At this point curN contains the 7/16 error value to be propagated - * to the next pixel on the current line, and all the errors for the - * next line have been shifted over. We are therefore ready to move on. - */ - inptr += dir3; /* Advance pixel pointers to next column */ - outptr += dir; - errorptr += dir3; /* advance errorptr to current column */ - } - /* Post-loop cleanup: we must unload the final error values into the - * final fserrors[] entry. Note we need not unload belowerrN because - * it is for the dummy column before or after the actual array. - */ - errorptr[0] = (FSERROR) bpreverr0; /* unload prev errs into array */ - errorptr[1] = (FSERROR) bpreverr1; - errorptr[2] = (FSERROR) bpreverr2; - } -} - - -/* - * Initialize the error-limiting transfer function (lookup table). - * The raw F-S error computation can potentially compute error values of up to - * +- MAXJSAMPLE. But we want the maximum correction applied to a pixel to be - * much less, otherwise obviously wrong pixels will be created. (Typical - * effects include weird fringes at color-area boundaries, isolated bright - * pixels in a dark area, etc.) The standard advice for avoiding this problem - * is to ensure that the "corners" of the color cube are allocated as output - * colors; then repeated errors in the same direction cannot cause cascading - * error buildup. However, that only prevents the error from getting - * completely out of hand; Aaron Giles reports that error limiting improves - * the results even with corner colors allocated. - * A simple clamping of the error values to about +- MAXJSAMPLE/8 works pretty - * well, but the smoother transfer function used below is even better. Thanks - * to Aaron Giles for this idea. - */ - -LOCAL(void) -init_error_limit (j_decompress_ptr cinfo) -/* Allocate and fill in the error_limiter table */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - int * table; - int in, out; - - table = (int *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * SIZEOF(int)); - table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */ - cquantize->error_limiter = table; - -#define STEPSIZE ((MAXJSAMPLE+1)/16) - /* Map errors 1:1 up to +- MAXJSAMPLE/16 */ - out = 0; - for (in = 0; in < STEPSIZE; in++, out++) { - table[in] = out; table[-in] = -out; - } - /* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */ - for (; in < STEPSIZE*3; in++, out += (in&1) ? 0 : 1) { - table[in] = out; table[-in] = -out; - } - /* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */ - for (; in <= MAXJSAMPLE; in++) { - table[in] = out; table[-in] = -out; - } -#undef STEPSIZE -} - - -/* - * Finish up at the end of each pass. - */ - -METHODDEF(void) -finish_pass1 (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - - /* Select the representative colors and fill in cinfo->colormap */ - cinfo->colormap = cquantize->sv_colormap; - select_colors(cinfo, cquantize->desired); - /* Force next pass to zero the color index table */ - cquantize->needs_zeroed = TRUE; -} - - -METHODDEF(void) -finish_pass2 (j_decompress_ptr cinfo) -{ - /* no work */ -} - - -/* - * Initialize for each processing pass. - */ - -METHODDEF(void) -start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - int i; - - /* Only F-S dithering or no dithering is supported. */ - /* If user asks for ordered dither, give him F-S. */ - if (cinfo->dither_mode != JDITHER_NONE) - cinfo->dither_mode = JDITHER_FS; - - if (is_pre_scan) { - /* Set up method pointers */ - cquantize->pub.color_quantize = prescan_quantize; - cquantize->pub.finish_pass = finish_pass1; - cquantize->needs_zeroed = TRUE; /* Always zero histogram */ - } else { - /* Set up method pointers */ - if (cinfo->dither_mode == JDITHER_FS) - cquantize->pub.color_quantize = pass2_fs_dither; - else - cquantize->pub.color_quantize = pass2_no_dither; - cquantize->pub.finish_pass = finish_pass2; - - /* Make sure color count is acceptable */ - i = cinfo->actual_number_of_colors; - if (i < 1) - ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 1); - if (i > MAXNUMCOLORS) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); - - if (cinfo->dither_mode == JDITHER_FS) { - size_t arraysize = (size_t) ((cinfo->output_width + 2) * - (3 * SIZEOF(FSERROR))); - /* Allocate Floyd-Steinberg workspace if we didn't already. */ - if (cquantize->fserrors == NULL) - cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); - /* Initialize the propagated errors to zero. */ - jzero_far((void FAR *) cquantize->fserrors, arraysize); - /* Make the error-limit table if we didn't already. */ - if (cquantize->error_limiter == NULL) - init_error_limit(cinfo); - cquantize->on_odd_row = FALSE; - } - - } - /* Zero the histogram or inverse color map, if necessary */ - if (cquantize->needs_zeroed) { - for (i = 0; i < HIST_C0_ELEMS; i++) { - jzero_far((void FAR *) histogram[i], - HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); - } - cquantize->needs_zeroed = FALSE; - } -} - - -/* - * Switch to a new external colormap between output passes. - */ - -METHODDEF(void) -new_color_map_2_quant (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - - /* Reset the inverse color map */ - cquantize->needs_zeroed = TRUE; -} - - -/* - * Module initialization routine for 2-pass color quantization. - */ - -GLOBAL(void) -jinit_2pass_quantizer (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize; - int i; - - cquantize = (my_cquantize_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_cquantizer)); - cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; - cquantize->pub.start_pass = start_pass_2_quant; - cquantize->pub.new_color_map = new_color_map_2_quant; - cquantize->fserrors = NULL; /* flag optional arrays not allocated */ - cquantize->error_limiter = NULL; - - /* Make sure jdmaster didn't give me a case I can't handle */ - if (cinfo->out_color_components != 3) - ERREXIT(cinfo, JERR_NOTIMPL); - - /* Allocate the histogram/inverse colormap storage */ - cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * SIZEOF(hist2d)); - for (i = 0; i < HIST_C0_ELEMS; i++) { - cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); - } - cquantize->needs_zeroed = TRUE; /* histogram is garbage now */ - - /* Allocate storage for the completed colormap, if required. - * We do this now since it is FAR storage and may affect - * the memory manager's space calculations. - */ - if (cinfo->enable_2pass_quant) { - /* Make sure color count is acceptable */ - int desired = cinfo->desired_number_of_colors; - /* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */ - if (desired < 8) - ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 8); - /* Make sure colormap indexes can be represented by JSAMPLEs */ - if (desired > MAXNUMCOLORS) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); - cquantize->sv_colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo,JPOOL_IMAGE, (JDIMENSION) desired, (JDIMENSION) 3); - cquantize->desired = desired; - } else - cquantize->sv_colormap = NULL; - - /* Only F-S dithering or no dithering is supported. */ - /* If user asks for ordered dither, give him F-S. */ - if (cinfo->dither_mode != JDITHER_NONE) - cinfo->dither_mode = JDITHER_FS; - - /* Allocate Floyd-Steinberg workspace if necessary. - * This isn't really needed until pass 2, but again it is FAR storage. - * Although we will cope with a later change in dither_mode, - * we do not promise to honor max_memory_to_use if dither_mode changes. - */ - if (cinfo->dither_mode == JDITHER_FS) { - cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) ((cinfo->output_width + 2) * (3 * SIZEOF(FSERROR)))); - /* Might as well create the error-limiting table too. */ - init_error_limit(cinfo); - } -} - -#endif /* QUANT_2PASS_SUPPORTED */ +/* + * jquant2.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains 2-pass color quantization (color mapping) routines. + * These routines provide selection of a custom color map for an image, + * followed by mapping of the image to that color map, with optional + * Floyd-Steinberg dithering. + * It is also possible to use just the second pass to map to an arbitrary + * externally-given color map. + * + * Note: ordered dithering is not supported, since there isn't any fast + * way to compute intercolor distances; it's unclear that ordered dither's + * fundamental assumptions even hold with an irregularly spaced color map. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +#ifdef QUANT_2PASS_SUPPORTED + + +/* + * This module implements the well-known Heckbert paradigm for color + * quantization. Most of the ideas used here can be traced back to + * Heckbert's seminal paper + * Heckbert, Paul. "Color Image Quantization for Frame Buffer Display", + * Proc. SIGGRAPH '82, Computer Graphics v.16 #3 (July 1982), pp 297-304. + * + * In the first pass over the image, we accumulate a histogram showing the + * usage count of each possible color. To keep the histogram to a reasonable + * size, we reduce the precision of the input; typical practice is to retain + * 5 or 6 bits per color, so that 8 or 4 different input values are counted + * in the same histogram cell. + * + * Next, the color-selection step begins with a box representing the whole + * color space, and repeatedly splits the "largest" remaining box until we + * have as many boxes as desired colors. Then the mean color in each + * remaining box becomes one of the possible output colors. + * + * The second pass over the image maps each input pixel to the closest output + * color (optionally after applying a Floyd-Steinberg dithering correction). + * This mapping is logically trivial, but making it go fast enough requires + * considerable care. + * + * Heckbert-style quantizers vary a good deal in their policies for choosing + * the "largest" box and deciding where to cut it. The particular policies + * used here have proved out well in experimental comparisons, but better ones + * may yet be found. + * + * In earlier versions of the IJG code, this module quantized in YCbCr color + * space, processing the raw upsampled data without a color conversion step. + * This allowed the color conversion math to be done only once per colormap + * entry, not once per pixel. However, that optimization precluded other + * useful optimizations (such as merging color conversion with upsampling) + * and it also interfered with desired capabilities such as quantizing to an + * externally-supplied colormap. We have therefore abandoned that approach. + * The present code works in the post-conversion color space, typically RGB. + * + * To improve the visual quality of the results, we actually work in scaled + * RGB space, giving G distances more weight than R, and R in turn more than + * B. To do everything in integer math, we must use integer scale factors. + * The 2/3/1 scale factors used here correspond loosely to the relative + * weights of the colors in the NTSC grayscale equation. + * If you want to use this code to quantize a non-RGB color space, you'll + * probably need to change these scale factors. + */ + +#define R_SCALE 2 /* scale R distances by this much */ +#define G_SCALE 3 /* scale G distances by this much */ +#define B_SCALE 1 /* and B by this much */ + +/* Relabel R/G/B as components 0/1/2, respecting the RGB ordering defined + * in jmorecfg.h. As the code stands, it will do the right thing for R,G,B + * and B,G,R orders. If you define some other weird order in jmorecfg.h, + * you'll get compile errors until you extend this logic. In that case + * you'll probably want to tweak the histogram sizes too. + */ + +#if RGB_RED == 0 +#define C0_SCALE R_SCALE +#endif +#if RGB_BLUE == 0 +#define C0_SCALE B_SCALE +#endif +#if RGB_GREEN == 1 +#define C1_SCALE G_SCALE +#endif +#if RGB_RED == 2 +#define C2_SCALE R_SCALE +#endif +#if RGB_BLUE == 2 +#define C2_SCALE B_SCALE +#endif + + +/* + * First we have the histogram data structure and routines for creating it. + * + * The number of bits of precision can be adjusted by changing these symbols. + * We recommend keeping 6 bits for G and 5 each for R and B. + * If you have plenty of memory and cycles, 6 bits all around gives marginally + * better results; if you are short of memory, 5 bits all around will save + * some space but degrade the results. + * To maintain a fully accurate histogram, we'd need to allocate a "long" + * (preferably unsigned long) for each cell. In practice this is overkill; + * we can get by with 16 bits per cell. Few of the cell counts will overflow, + * and clamping those that do overflow to the maximum value will give close- + * enough results. This reduces the recommended histogram size from 256Kb + * to 128Kb, which is a useful savings on PC-class machines. + * (In the second pass the histogram space is re-used for pixel mapping data; + * in that capacity, each cell must be able to store zero to the number of + * desired colors. 16 bits/cell is plenty for that too.) + * Since the JPEG code is intended to run in small memory model on 80x86 + * machines, we can't just allocate the histogram in one chunk. Instead + * of a true 3-D array, we use a row of pointers to 2-D arrays. Each + * pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and + * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries. Note that + * on 80x86 machines, the pointer row is in near memory but the actual + * arrays are in far memory (same arrangement as we use for image arrays). + */ + +#define MAXNUMCOLORS (MAXJSAMPLE+1) /* maximum size of colormap */ + +/* These will do the right thing for either R,G,B or B,G,R color order, + * but you may not like the results for other color orders. + */ +#define HIST_C0_BITS 5 /* bits of precision in R/B histogram */ +#define HIST_C1_BITS 6 /* bits of precision in G histogram */ +#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */ + +/* Number of elements along histogram axes. */ +#define HIST_C0_ELEMS (1<cquantize; + register JSAMPROW ptr; + register histptr histp; + register hist3d histogram = cquantize->histogram; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + ptr = input_buf[row]; + for (col = width; col > 0; col--) { + /* get pixel value and index into the histogram */ + histp = & histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT] + [GETJSAMPLE(ptr[1]) >> C1_SHIFT] + [GETJSAMPLE(ptr[2]) >> C2_SHIFT]; + /* increment, check for overflow and undo increment if so. */ + if (++(*histp) <= 0) + (*histp)--; + ptr += 3; + } + } +} + + +/* + * Next we have the really interesting routines: selection of a colormap + * given the completed histogram. + * These routines work with a list of "boxes", each representing a rectangular + * subset of the input color space (to histogram precision). + */ + +typedef struct { + /* The bounds of the box (inclusive); expressed as histogram indexes */ + int c0min, c0max; + int c1min, c1max; + int c2min, c2max; + /* The volume (actually 2-norm) of the box */ + INT32 volume; + /* The number of nonzero histogram cells within this box */ + long colorcount; +} box; + +typedef box * boxptr; + + +LOCAL(boxptr) +find_biggest_color_pop (boxptr boxlist, int numboxes) +/* Find the splittable box with the largest color population */ +/* Returns NULL if no splittable boxes remain */ +{ + register boxptr boxp; + register int i; + register long maxc = 0; + boxptr which = NULL; + + for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { + if (boxp->colorcount > maxc && boxp->volume > 0) { + which = boxp; + maxc = boxp->colorcount; + } + } + return which; +} + + +LOCAL(boxptr) +find_biggest_volume (boxptr boxlist, int numboxes) +/* Find the splittable box with the largest (scaled) volume */ +/* Returns NULL if no splittable boxes remain */ +{ + register boxptr boxp; + register int i; + register INT32 maxv = 0; + boxptr which = NULL; + + for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { + if (boxp->volume > maxv) { + which = boxp; + maxv = boxp->volume; + } + } + return which; +} + + +LOCAL(void) +update_box (j_decompress_ptr cinfo, boxptr boxp) +/* Shrink the min/max bounds of a box to enclose only nonzero elements, */ +/* and recompute its volume and population */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + histptr histp; + int c0,c1,c2; + int c0min,c0max,c1min,c1max,c2min,c2max; + INT32 dist0,dist1,dist2; + long ccount; + + c0min = boxp->c0min; c0max = boxp->c0max; + c1min = boxp->c1min; c1max = boxp->c1max; + c2min = boxp->c2min; c2max = boxp->c2max; + + if (c0max > c0min) + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c0min = c0min = c0; + goto have_c0min; + } + } + have_c0min: + if (c0max > c0min) + for (c0 = c0max; c0 >= c0min; c0--) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c0max = c0max = c0; + goto have_c0max; + } + } + have_c0max: + if (c1max > c1min) + for (c1 = c1min; c1 <= c1max; c1++) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c1min = c1min = c1; + goto have_c1min; + } + } + have_c1min: + if (c1max > c1min) + for (c1 = c1max; c1 >= c1min; c1--) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c1max = c1max = c1; + goto have_c1max; + } + } + have_c1max: + if (c2max > c2min) + for (c2 = c2min; c2 <= c2max; c2++) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1min][c2]; + for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) + if (*histp != 0) { + boxp->c2min = c2min = c2; + goto have_c2min; + } + } + have_c2min: + if (c2max > c2min) + for (c2 = c2max; c2 >= c2min; c2--) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1min][c2]; + for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) + if (*histp != 0) { + boxp->c2max = c2max = c2; + goto have_c2max; + } + } + have_c2max: + + /* Update box volume. + * We use 2-norm rather than real volume here; this biases the method + * against making long narrow boxes, and it has the side benefit that + * a box is splittable iff norm > 0. + * Since the differences are expressed in histogram-cell units, + * we have to shift back to JSAMPLE units to get consistent distances; + * after which, we scale according to the selected distance scale factors. + */ + dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE; + dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE; + dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE; + boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2; + + /* Now scan remaining volume of box and compute population */ + ccount = 0; + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++, histp++) + if (*histp != 0) { + ccount++; + } + } + boxp->colorcount = ccount; +} + + +LOCAL(int) +median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes, + int desired_colors) +/* Repeatedly select and split the largest box until we have enough boxes */ +{ + int n,lb; + int c0,c1,c2,cmax; + register boxptr b1,b2; + + while (numboxes < desired_colors) { + /* Select box to split. + * Current algorithm: by population for first half, then by volume. + */ + if (numboxes*2 <= desired_colors) { + b1 = find_biggest_color_pop(boxlist, numboxes); + } else { + b1 = find_biggest_volume(boxlist, numboxes); + } + if (b1 == NULL) /* no splittable boxes left! */ + break; + b2 = &boxlist[numboxes]; /* where new box will go */ + /* Copy the color bounds to the new box. */ + b2->c0max = b1->c0max; b2->c1max = b1->c1max; b2->c2max = b1->c2max; + b2->c0min = b1->c0min; b2->c1min = b1->c1min; b2->c2min = b1->c2min; + /* Choose which axis to split the box on. + * Current algorithm: longest scaled axis. + * See notes in update_box about scaling distances. + */ + c0 = ((b1->c0max - b1->c0min) << C0_SHIFT) * C0_SCALE; + c1 = ((b1->c1max - b1->c1min) << C1_SHIFT) * C1_SCALE; + c2 = ((b1->c2max - b1->c2min) << C2_SHIFT) * C2_SCALE; + /* We want to break any ties in favor of green, then red, blue last. + * This code does the right thing for R,G,B or B,G,R color orders only. + */ +#if RGB_RED == 0 + cmax = c1; n = 1; + if (c0 > cmax) { cmax = c0; n = 0; } + if (c2 > cmax) { n = 2; } +#else + cmax = c1; n = 1; + if (c2 > cmax) { cmax = c2; n = 2; } + if (c0 > cmax) { n = 0; } +#endif + /* Choose split point along selected axis, and update box bounds. + * Current algorithm: split at halfway point. + * (Since the box has been shrunk to minimum volume, + * any split will produce two nonempty subboxes.) + * Note that lb value is max for lower box, so must be < old max. + */ + switch (n) { + case 0: + lb = (b1->c0max + b1->c0min) / 2; + b1->c0max = lb; + b2->c0min = lb+1; + break; + case 1: + lb = (b1->c1max + b1->c1min) / 2; + b1->c1max = lb; + b2->c1min = lb+1; + break; + case 2: + lb = (b1->c2max + b1->c2min) / 2; + b1->c2max = lb; + b2->c2min = lb+1; + break; + } + /* Update stats for boxes */ + update_box(cinfo, b1); + update_box(cinfo, b2); + numboxes++; + } + return numboxes; +} + + +LOCAL(void) +compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor) +/* Compute representative color for a box, put it in colormap[icolor] */ +{ + /* Current algorithm: mean weighted by pixels (not colors) */ + /* Note it is important to get the rounding correct! */ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + histptr histp; + int c0,c1,c2; + int c0min,c0max,c1min,c1max,c2min,c2max; + long count; + long total = 0; + long c0total = 0; + long c1total = 0; + long c2total = 0; + + c0min = boxp->c0min; c0max = boxp->c0max; + c1min = boxp->c1min; c1max = boxp->c1max; + c2min = boxp->c2min; c2max = boxp->c2max; + + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) { + if ((count = *histp++) != 0) { + total += count; + c0total += ((c0 << C0_SHIFT) + ((1<>1)) * count; + c1total += ((c1 << C1_SHIFT) + ((1<>1)) * count; + c2total += ((c2 << C2_SHIFT) + ((1<>1)) * count; + } + } + } + + cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total); + cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total); + cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total); +} + + +LOCAL(void) +select_colors (j_decompress_ptr cinfo, int desired_colors) +/* Master routine for color selection */ +{ + boxptr boxlist; + int numboxes; + int i; + + /* Allocate workspace for box list */ + boxlist = (boxptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(box)); + /* Initialize one box containing whole space */ + numboxes = 1; + boxlist[0].c0min = 0; + boxlist[0].c0max = MAXJSAMPLE >> C0_SHIFT; + boxlist[0].c1min = 0; + boxlist[0].c1max = MAXJSAMPLE >> C1_SHIFT; + boxlist[0].c2min = 0; + boxlist[0].c2max = MAXJSAMPLE >> C2_SHIFT; + /* Shrink it to actually-used volume and set its statistics */ + update_box(cinfo, & boxlist[0]); + /* Perform median-cut to produce final box list */ + numboxes = median_cut(cinfo, boxlist, numboxes, desired_colors); + /* Compute the representative color for each box, fill colormap */ + for (i = 0; i < numboxes; i++) + compute_color(cinfo, & boxlist[i], i); + cinfo->actual_number_of_colors = numboxes; + TRACEMS1(cinfo, 1, JTRC_QUANT_SELECTED, numboxes); +} + + +/* + * These routines are concerned with the time-critical task of mapping input + * colors to the nearest color in the selected colormap. + * + * We re-use the histogram space as an "inverse color map", essentially a + * cache for the results of nearest-color searches. All colors within a + * histogram cell will be mapped to the same colormap entry, namely the one + * closest to the cell's center. This may not be quite the closest entry to + * the actual input color, but it's almost as good. A zero in the cache + * indicates we haven't found the nearest color for that cell yet; the array + * is cleared to zeroes before starting the mapping pass. When we find the + * nearest color for a cell, its colormap index plus one is recorded in the + * cache for future use. The pass2 scanning routines call fill_inverse_cmap + * when they need to use an unfilled entry in the cache. + * + * Our method of efficiently finding nearest colors is based on the "locally + * sorted search" idea described by Heckbert and on the incremental distance + * calculation described by Spencer W. Thomas in chapter III.1 of Graphics + * Gems II (James Arvo, ed. Academic Press, 1991). Thomas points out that + * the distances from a given colormap entry to each cell of the histogram can + * be computed quickly using an incremental method: the differences between + * distances to adjacent cells themselves differ by a constant. This allows a + * fairly fast implementation of the "brute force" approach of computing the + * distance from every colormap entry to every histogram cell. Unfortunately, + * it needs a work array to hold the best-distance-so-far for each histogram + * cell (because the inner loop has to be over cells, not colormap entries). + * The work array elements have to be INT32s, so the work array would need + * 256Kb at our recommended precision. This is not feasible in DOS machines. + * + * To get around these problems, we apply Thomas' method to compute the + * nearest colors for only the cells within a small subbox of the histogram. + * The work array need be only as big as the subbox, so the memory usage + * problem is solved. Furthermore, we need not fill subboxes that are never + * referenced in pass2; many images use only part of the color gamut, so a + * fair amount of work is saved. An additional advantage of this + * approach is that we can apply Heckbert's locality criterion to quickly + * eliminate colormap entries that are far away from the subbox; typically + * three-fourths of the colormap entries are rejected by Heckbert's criterion, + * and we need not compute their distances to individual cells in the subbox. + * The speed of this approach is heavily influenced by the subbox size: too + * small means too much overhead, too big loses because Heckbert's criterion + * can't eliminate as many colormap entries. Empirically the best subbox + * size seems to be about 1/512th of the histogram (1/8th in each direction). + * + * Thomas' article also describes a refined method which is asymptotically + * faster than the brute-force method, but it is also far more complex and + * cannot efficiently be applied to small subboxes. It is therefore not + * useful for programs intended to be portable to DOS machines. On machines + * with plenty of memory, filling the whole histogram in one shot with Thomas' + * refined method might be faster than the present code --- but then again, + * it might not be any faster, and it's certainly more complicated. + */ + + +/* log2(histogram cells in update box) for each axis; this can be adjusted */ +#define BOX_C0_LOG (HIST_C0_BITS-3) +#define BOX_C1_LOG (HIST_C1_BITS-3) +#define BOX_C2_LOG (HIST_C2_BITS-3) + +#define BOX_C0_ELEMS (1<actual_number_of_colors; + int maxc0, maxc1, maxc2; + int centerc0, centerc1, centerc2; + int i, x, ncolors; + INT32 minmaxdist, min_dist, max_dist, tdist; + INT32 mindist[MAXNUMCOLORS]; /* min distance to colormap entry i */ + + /* Compute true coordinates of update box's upper corner and center. + * Actually we compute the coordinates of the center of the upper-corner + * histogram cell, which are the upper bounds of the volume we care about. + * Note that since ">>" rounds down, the "center" values may be closer to + * min than to max; hence comparisons to them must be "<=", not "<". + */ + maxc0 = minc0 + ((1 << BOX_C0_SHIFT) - (1 << C0_SHIFT)); + centerc0 = (minc0 + maxc0) >> 1; + maxc1 = minc1 + ((1 << BOX_C1_SHIFT) - (1 << C1_SHIFT)); + centerc1 = (minc1 + maxc1) >> 1; + maxc2 = minc2 + ((1 << BOX_C2_SHIFT) - (1 << C2_SHIFT)); + centerc2 = (minc2 + maxc2) >> 1; + + /* For each color in colormap, find: + * 1. its minimum squared-distance to any point in the update box + * (zero if color is within update box); + * 2. its maximum squared-distance to any point in the update box. + * Both of these can be found by considering only the corners of the box. + * We save the minimum distance for each color in mindist[]; + * only the smallest maximum distance is of interest. + */ + minmaxdist = 0x7FFFFFFFL; + + for (i = 0; i < numcolors; i++) { + /* We compute the squared-c0-distance term, then add in the other two. */ + x = GETJSAMPLE(cinfo->colormap[0][i]); + if (x < minc0) { + tdist = (x - minc0) * C0_SCALE; + min_dist = tdist*tdist; + tdist = (x - maxc0) * C0_SCALE; + max_dist = tdist*tdist; + } else if (x > maxc0) { + tdist = (x - maxc0) * C0_SCALE; + min_dist = tdist*tdist; + tdist = (x - minc0) * C0_SCALE; + max_dist = tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + min_dist = 0; + if (x <= centerc0) { + tdist = (x - maxc0) * C0_SCALE; + max_dist = tdist*tdist; + } else { + tdist = (x - minc0) * C0_SCALE; + max_dist = tdist*tdist; + } + } + + x = GETJSAMPLE(cinfo->colormap[1][i]); + if (x < minc1) { + tdist = (x - minc1) * C1_SCALE; + min_dist += tdist*tdist; + tdist = (x - maxc1) * C1_SCALE; + max_dist += tdist*tdist; + } else if (x > maxc1) { + tdist = (x - maxc1) * C1_SCALE; + min_dist += tdist*tdist; + tdist = (x - minc1) * C1_SCALE; + max_dist += tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + if (x <= centerc1) { + tdist = (x - maxc1) * C1_SCALE; + max_dist += tdist*tdist; + } else { + tdist = (x - minc1) * C1_SCALE; + max_dist += tdist*tdist; + } + } + + x = GETJSAMPLE(cinfo->colormap[2][i]); + if (x < minc2) { + tdist = (x - minc2) * C2_SCALE; + min_dist += tdist*tdist; + tdist = (x - maxc2) * C2_SCALE; + max_dist += tdist*tdist; + } else if (x > maxc2) { + tdist = (x - maxc2) * C2_SCALE; + min_dist += tdist*tdist; + tdist = (x - minc2) * C2_SCALE; + max_dist += tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + if (x <= centerc2) { + tdist = (x - maxc2) * C2_SCALE; + max_dist += tdist*tdist; + } else { + tdist = (x - minc2) * C2_SCALE; + max_dist += tdist*tdist; + } + } + + mindist[i] = min_dist; /* save away the results */ + if (max_dist < minmaxdist) + minmaxdist = max_dist; + } + + /* Now we know that no cell in the update box is more than minmaxdist + * away from some colormap entry. Therefore, only colors that are + * within minmaxdist of some part of the box need be considered. + */ + ncolors = 0; + for (i = 0; i < numcolors; i++) { + if (mindist[i] <= minmaxdist) + colorlist[ncolors++] = (JSAMPLE) i; + } + return ncolors; +} + + +LOCAL(void) +find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2, + int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[]) +/* Find the closest colormap entry for each cell in the update box, + * given the list of candidate colors prepared by find_nearby_colors. + * Return the indexes of the closest entries in the bestcolor[] array. + * This routine uses Thomas' incremental distance calculation method to + * find the distance from a colormap entry to successive cells in the box. + */ +{ + int ic0, ic1, ic2; + int i, icolor; + register INT32 * bptr; /* pointer into bestdist[] array */ + JSAMPLE * cptr; /* pointer into bestcolor[] array */ + INT32 dist0, dist1; /* initial distance values */ + register INT32 dist2; /* current distance in inner loop */ + INT32 xx0, xx1; /* distance increments */ + register INT32 xx2; + INT32 inc0, inc1, inc2; /* initial values for increments */ + /* This array holds the distance to the nearest-so-far color for each cell */ + INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; + + /* Initialize best-distance for each cell of the update box */ + bptr = bestdist; + for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--) + *bptr++ = 0x7FFFFFFFL; + + /* For each color selected by find_nearby_colors, + * compute its distance to the center of each cell in the box. + * If that's less than best-so-far, update best distance and color number. + */ + + /* Nominal steps between cell centers ("x" in Thomas article) */ +#define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE) +#define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE) +#define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE) + + for (i = 0; i < numcolors; i++) { + icolor = GETJSAMPLE(colorlist[i]); + /* Compute (square of) distance from minc0/c1/c2 to this color */ + inc0 = (minc0 - GETJSAMPLE(cinfo->colormap[0][icolor])) * C0_SCALE; + dist0 = inc0*inc0; + inc1 = (minc1 - GETJSAMPLE(cinfo->colormap[1][icolor])) * C1_SCALE; + dist0 += inc1*inc1; + inc2 = (minc2 - GETJSAMPLE(cinfo->colormap[2][icolor])) * C2_SCALE; + dist0 += inc2*inc2; + /* Form the initial difference increments */ + inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0; + inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1; + inc2 = inc2 * (2 * STEP_C2) + STEP_C2 * STEP_C2; + /* Now loop over all cells in box, updating distance per Thomas method */ + bptr = bestdist; + cptr = bestcolor; + xx0 = inc0; + for (ic0 = BOX_C0_ELEMS-1; ic0 >= 0; ic0--) { + dist1 = dist0; + xx1 = inc1; + for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) { + dist2 = dist1; + xx2 = inc2; + for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) { + if (dist2 < *bptr) { + *bptr = dist2; + *cptr = (JSAMPLE) icolor; + } + dist2 += xx2; + xx2 += 2 * STEP_C2 * STEP_C2; + bptr++; + cptr++; + } + dist1 += xx1; + xx1 += 2 * STEP_C1 * STEP_C1; + } + dist0 += xx0; + xx0 += 2 * STEP_C0 * STEP_C0; + } + } +} + + +LOCAL(void) +fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2) +/* Fill the inverse-colormap entries in the update box that contains */ +/* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */ +/* we can fill as many others as we wish.) */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + int minc0, minc1, minc2; /* lower left corner of update box */ + int ic0, ic1, ic2; + register JSAMPLE * cptr; /* pointer into bestcolor[] array */ + register histptr cachep; /* pointer into main cache array */ + /* This array lists the candidate colormap indexes. */ + JSAMPLE colorlist[MAXNUMCOLORS]; + int numcolors; /* number of candidate colors */ + /* This array holds the actually closest colormap index for each cell. */ + JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; + + /* Convert cell coordinates to update box ID */ + c0 >>= BOX_C0_LOG; + c1 >>= BOX_C1_LOG; + c2 >>= BOX_C2_LOG; + + /* Compute true coordinates of update box's origin corner. + * Actually we compute the coordinates of the center of the corner + * histogram cell, which are the lower bounds of the volume we care about. + */ + minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1); + minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1); + minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1); + + /* Determine which colormap entries are close enough to be candidates + * for the nearest entry to some cell in the update box. + */ + numcolors = find_nearby_colors(cinfo, minc0, minc1, minc2, colorlist); + + /* Determine the actually nearest colors. */ + find_best_colors(cinfo, minc0, minc1, minc2, numcolors, colorlist, + bestcolor); + + /* Save the best color numbers (plus 1) in the main cache array */ + c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */ + c1 <<= BOX_C1_LOG; + c2 <<= BOX_C2_LOG; + cptr = bestcolor; + for (ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++) { + for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) { + cachep = & histogram[c0+ic0][c1+ic1][c2]; + for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) { + *cachep++ = (histcell) (GETJSAMPLE(*cptr++) + 1); + } + } + } +} + + +/* + * Map some rows of pixels to the output colormapped representation. + */ + +METHODDEF(void) +pass2_no_dither (j_decompress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) +/* This version performs no dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + register JSAMPROW inptr, outptr; + register histptr cachep; + register int c0, c1, c2; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + inptr = input_buf[row]; + outptr = output_buf[row]; + for (col = width; col > 0; col--) { + /* get pixel value and index into the cache */ + c0 = GETJSAMPLE(*inptr++) >> C0_SHIFT; + c1 = GETJSAMPLE(*inptr++) >> C1_SHIFT; + c2 = GETJSAMPLE(*inptr++) >> C2_SHIFT; + cachep = & histogram[c0][c1][c2]; + /* If we have not seen this color before, find nearest colormap entry */ + /* and update the cache */ + if (*cachep == 0) + fill_inverse_cmap(cinfo, c0,c1,c2); + /* Now emit the colormap index for this cell */ + *outptr++ = (JSAMPLE) (*cachep - 1); + } + } +} + + +METHODDEF(void) +pass2_fs_dither (j_decompress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) +/* This version performs Floyd-Steinberg dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */ + LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */ + LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */ + register FSERRPTR errorptr; /* => fserrors[] at column before current */ + JSAMPROW inptr; /* => current input pixel */ + JSAMPROW outptr; /* => current output pixel */ + histptr cachep; + int dir; /* +1 or -1 depending on direction */ + int dir3; /* 3*dir, for advancing inptr & errorptr */ + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + JSAMPLE *range_limit = cinfo->sample_range_limit; + int *error_limit = cquantize->error_limiter; + JSAMPROW colormap0 = cinfo->colormap[0]; + JSAMPROW colormap1 = cinfo->colormap[1]; + JSAMPROW colormap2 = cinfo->colormap[2]; + SHIFT_TEMPS + + for (row = 0; row < num_rows; row++) { + inptr = input_buf[row]; + outptr = output_buf[row]; + if (cquantize->on_odd_row) { + /* work right to left in this row */ + inptr += (width-1) * 3; /* so point to rightmost pixel */ + outptr += width-1; + dir = -1; + dir3 = -3; + errorptr = cquantize->fserrors + (width+1)*3; /* => entry after last column */ + cquantize->on_odd_row = FALSE; /* flip for next time */ + } else { + /* work left to right in this row */ + dir = 1; + dir3 = 3; + errorptr = cquantize->fserrors; /* => entry before first real column */ + cquantize->on_odd_row = TRUE; /* flip for next time */ + } + /* Preset error values: no error propagated to first pixel from left */ + cur0 = cur1 = cur2 = 0; + /* and no error propagated to row below yet */ + belowerr0 = belowerr1 = belowerr2 = 0; + bpreverr0 = bpreverr1 = bpreverr2 = 0; + + for (col = width; col > 0; col--) { + /* curN holds the error propagated from the previous pixel on the + * current line. Add the error propagated from the previous line + * to form the complete error correction term for this pixel, and + * round the error term (which is expressed * 16) to an integer. + * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct + * for either sign of the error value. + * Note: errorptr points to *previous* column's array entry. + */ + cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3+0] + 8, 4); + cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3+1] + 8, 4); + cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3+2] + 8, 4); + /* Limit the error using transfer function set by init_error_limit. + * See comments with init_error_limit for rationale. + */ + cur0 = error_limit[cur0]; + cur1 = error_limit[cur1]; + cur2 = error_limit[cur2]; + /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. + * The maximum error is +- MAXJSAMPLE (or less with error limiting); + * this sets the required size of the range_limit array. + */ + cur0 += GETJSAMPLE(inptr[0]); + cur1 += GETJSAMPLE(inptr[1]); + cur2 += GETJSAMPLE(inptr[2]); + cur0 = GETJSAMPLE(range_limit[cur0]); + cur1 = GETJSAMPLE(range_limit[cur1]); + cur2 = GETJSAMPLE(range_limit[cur2]); + /* Index into the cache with adjusted pixel value */ + cachep = & histogram[cur0>>C0_SHIFT][cur1>>C1_SHIFT][cur2>>C2_SHIFT]; + /* If we have not seen this color before, find nearest colormap */ + /* entry and update the cache */ + if (*cachep == 0) + fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT); + /* Now emit the colormap index for this cell */ + { register int pixcode = *cachep - 1; + *outptr = (JSAMPLE) pixcode; + /* Compute representation error for this pixel */ + cur0 -= GETJSAMPLE(colormap0[pixcode]); + cur1 -= GETJSAMPLE(colormap1[pixcode]); + cur2 -= GETJSAMPLE(colormap2[pixcode]); + } + /* Compute error fractions to be propagated to adjacent pixels. + * Add these into the running sums, and simultaneously shift the + * next-line error sums left by 1 column. + */ + { register LOCFSERROR bnexterr, delta; + + bnexterr = cur0; /* Process component 0 */ + delta = cur0 * 2; + cur0 += delta; /* form error * 3 */ + errorptr[0] = (FSERROR) (bpreverr0 + cur0); + cur0 += delta; /* form error * 5 */ + bpreverr0 = belowerr0 + cur0; + belowerr0 = bnexterr; + cur0 += delta; /* form error * 7 */ + bnexterr = cur1; /* Process component 1 */ + delta = cur1 * 2; + cur1 += delta; /* form error * 3 */ + errorptr[1] = (FSERROR) (bpreverr1 + cur1); + cur1 += delta; /* form error * 5 */ + bpreverr1 = belowerr1 + cur1; + belowerr1 = bnexterr; + cur1 += delta; /* form error * 7 */ + bnexterr = cur2; /* Process component 2 */ + delta = cur2 * 2; + cur2 += delta; /* form error * 3 */ + errorptr[2] = (FSERROR) (bpreverr2 + cur2); + cur2 += delta; /* form error * 5 */ + bpreverr2 = belowerr2 + cur2; + belowerr2 = bnexterr; + cur2 += delta; /* form error * 7 */ + } + /* At this point curN contains the 7/16 error value to be propagated + * to the next pixel on the current line, and all the errors for the + * next line have been shifted over. We are therefore ready to move on. + */ + inptr += dir3; /* Advance pixel pointers to next column */ + outptr += dir; + errorptr += dir3; /* advance errorptr to current column */ + } + /* Post-loop cleanup: we must unload the final error values into the + * final fserrors[] entry. Note we need not unload belowerrN because + * it is for the dummy column before or after the actual array. + */ + errorptr[0] = (FSERROR) bpreverr0; /* unload prev errs into array */ + errorptr[1] = (FSERROR) bpreverr1; + errorptr[2] = (FSERROR) bpreverr2; + } +} + + +/* + * Initialize the error-limiting transfer function (lookup table). + * The raw F-S error computation can potentially compute error values of up to + * +- MAXJSAMPLE. But we want the maximum correction applied to a pixel to be + * much less, otherwise obviously wrong pixels will be created. (Typical + * effects include weird fringes at color-area boundaries, isolated bright + * pixels in a dark area, etc.) The standard advice for avoiding this problem + * is to ensure that the "corners" of the color cube are allocated as output + * colors; then repeated errors in the same direction cannot cause cascading + * error buildup. However, that only prevents the error from getting + * completely out of hand; Aaron Giles reports that error limiting improves + * the results even with corner colors allocated. + * A simple clamping of the error values to about +- MAXJSAMPLE/8 works pretty + * well, but the smoother transfer function used below is even better. Thanks + * to Aaron Giles for this idea. + */ + +LOCAL(void) +init_error_limit (j_decompress_ptr cinfo) +/* Allocate and fill in the error_limiter table */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + int * table; + int in, out; + + table = (int *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * SIZEOF(int)); + table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */ + cquantize->error_limiter = table; + +#define STEPSIZE ((MAXJSAMPLE+1)/16) + /* Map errors 1:1 up to +- MAXJSAMPLE/16 */ + out = 0; + for (in = 0; in < STEPSIZE; in++, out++) { + table[in] = out; table[-in] = -out; + } + /* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */ + for (; in < STEPSIZE*3; in++, out += (in&1) ? 0 : 1) { + table[in] = out; table[-in] = -out; + } + /* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */ + for (; in <= MAXJSAMPLE; in++) { + table[in] = out; table[-in] = -out; + } +#undef STEPSIZE +} + + +/* + * Finish up at the end of each pass. + */ + +METHODDEF(void) +finish_pass1 (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + + /* Select the representative colors and fill in cinfo->colormap */ + cinfo->colormap = cquantize->sv_colormap; + select_colors(cinfo, cquantize->desired); + /* Force next pass to zero the color index table */ + cquantize->needs_zeroed = TRUE; +} + + +METHODDEF(void) +finish_pass2 (j_decompress_ptr cinfo) +{ + /* no work */ +} + + +/* + * Initialize for each processing pass. + */ + +METHODDEF(void) +start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + int i; + + /* Only F-S dithering or no dithering is supported. */ + /* If user asks for ordered dither, give him F-S. */ + if (cinfo->dither_mode != JDITHER_NONE) + cinfo->dither_mode = JDITHER_FS; + + if (is_pre_scan) { + /* Set up method pointers */ + cquantize->pub.color_quantize = prescan_quantize; + cquantize->pub.finish_pass = finish_pass1; + cquantize->needs_zeroed = TRUE; /* Always zero histogram */ + } else { + /* Set up method pointers */ + if (cinfo->dither_mode == JDITHER_FS) + cquantize->pub.color_quantize = pass2_fs_dither; + else + cquantize->pub.color_quantize = pass2_no_dither; + cquantize->pub.finish_pass = finish_pass2; + + /* Make sure color count is acceptable */ + i = cinfo->actual_number_of_colors; + if (i < 1) + ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 1); + if (i > MAXNUMCOLORS) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); + + if (cinfo->dither_mode == JDITHER_FS) { + size_t arraysize = (size_t) ((cinfo->output_width + 2) * + (3 * SIZEOF(FSERROR))); + /* Allocate Floyd-Steinberg workspace if we didn't already. */ + if (cquantize->fserrors == NULL) + cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); + /* Initialize the propagated errors to zero. */ + jzero_far((void FAR *) cquantize->fserrors, arraysize); + /* Make the error-limit table if we didn't already. */ + if (cquantize->error_limiter == NULL) + init_error_limit(cinfo); + cquantize->on_odd_row = FALSE; + } + + } + /* Zero the histogram or inverse color map, if necessary */ + if (cquantize->needs_zeroed) { + for (i = 0; i < HIST_C0_ELEMS; i++) { + jzero_far((void FAR *) histogram[i], + HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); + } + cquantize->needs_zeroed = FALSE; + } +} + + +/* + * Switch to a new external colormap between output passes. + */ + +METHODDEF(void) +new_color_map_2_quant (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + + /* Reset the inverse color map */ + cquantize->needs_zeroed = TRUE; +} + + +/* + * Module initialization routine for 2-pass color quantization. + */ + +GLOBAL(void) +jinit_2pass_quantizer (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize; + int i; + + cquantize = (my_cquantize_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_cquantizer)); + cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; + cquantize->pub.start_pass = start_pass_2_quant; + cquantize->pub.new_color_map = new_color_map_2_quant; + cquantize->fserrors = NULL; /* flag optional arrays not allocated */ + cquantize->error_limiter = NULL; + + /* Make sure jdmaster didn't give me a case I can't handle */ + if (cinfo->out_color_components != 3) + ERREXIT(cinfo, JERR_NOTIMPL); + + /* Allocate the histogram/inverse colormap storage */ + cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * SIZEOF(hist2d)); + for (i = 0; i < HIST_C0_ELEMS; i++) { + cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); + } + cquantize->needs_zeroed = TRUE; /* histogram is garbage now */ + + /* Allocate storage for the completed colormap, if required. + * We do this now since it is FAR storage and may affect + * the memory manager's space calculations. + */ + if (cinfo->enable_2pass_quant) { + /* Make sure color count is acceptable */ + int desired = cinfo->desired_number_of_colors; + /* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */ + if (desired < 8) + ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 8); + /* Make sure colormap indexes can be represented by JSAMPLEs */ + if (desired > MAXNUMCOLORS) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); + cquantize->sv_colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo,JPOOL_IMAGE, (JDIMENSION) desired, (JDIMENSION) 3); + cquantize->desired = desired; + } else + cquantize->sv_colormap = NULL; + + /* Only F-S dithering or no dithering is supported. */ + /* If user asks for ordered dither, give him F-S. */ + if (cinfo->dither_mode != JDITHER_NONE) + cinfo->dither_mode = JDITHER_FS; + + /* Allocate Floyd-Steinberg workspace if necessary. + * This isn't really needed until pass 2, but again it is FAR storage. + * Although we will cope with a later change in dither_mode, + * we do not promise to honor max_memory_to_use if dither_mode changes. + */ + if (cinfo->dither_mode == JDITHER_FS) { + cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (size_t) ((cinfo->output_width + 2) * (3 * SIZEOF(FSERROR)))); + /* Might as well create the error-limiting table too. */ + init_error_limit(cinfo); + } +} + +#endif /* QUANT_2PASS_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/jutils.c b/src/dep/src/irrlicht/jpeglib/jutils.c index 286cda2..d18a955 100644 --- a/src/dep/src/irrlicht/jpeglib/jutils.c +++ b/src/dep/src/irrlicht/jpeglib/jutils.c @@ -1,179 +1,179 @@ -/* - * jutils.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains tables and miscellaneous utility routines needed - * for both compression and decompression. - * Note we prefix all global names with "j" to minimize conflicts with - * a surrounding application. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element - * of a DCT block read in natural order (left to right, top to bottom). - */ - -#if 0 /* This table is not actually needed in v6a */ - -const int jpeg_zigzag_order[DCTSIZE2] = { - 0, 1, 5, 6, 14, 15, 27, 28, - 2, 4, 7, 13, 16, 26, 29, 42, - 3, 8, 12, 17, 25, 30, 41, 43, - 9, 11, 18, 24, 31, 40, 44, 53, - 10, 19, 23, 32, 39, 45, 52, 54, - 20, 22, 33, 38, 46, 51, 55, 60, - 21, 34, 37, 47, 50, 56, 59, 61, - 35, 36, 48, 49, 57, 58, 62, 63 -}; - -#endif - -/* - * jpeg_natural_order[i] is the natural-order position of the i'th element - * of zigzag order. - * - * When reading corrupted data, the Huffman decoders could attempt - * to reference an entry beyond the end of this array (if the decoded - * zero run length reaches past the end of the block). To prevent - * wild stores without adding an inner-loop test, we put some extra - * "63"s after the real entries. This will cause the extra coefficient - * to be stored in location 63 of the block, not somewhere random. - * The worst case would be a run-length of 15, which means we need 16 - * fake entries. - */ - -const int jpeg_natural_order[DCTSIZE2+16] = { - 0, 1, 8, 16, 9, 2, 3, 10, - 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63, - 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ - 63, 63, 63, 63, 63, 63, 63, 63 -}; - - -/* - * Arithmetic utilities - */ - -GLOBAL(long) -jdiv_round_up (long a, long b) -/* Compute a/b rounded up to next integer, ie, ceil(a/b) */ -/* Assumes a >= 0, b > 0 */ -{ - return (a + b - 1L) / b; -} - - -GLOBAL(long) -jround_up (long a, long b) -/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ -/* Assumes a >= 0, b > 0 */ -{ - a += b - 1L; - return a - (a % b); -} - - -/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays - * and coefficient-block arrays. This won't work on 80x86 because the arrays - * are FAR and we're assuming a small-pointer memory model. However, some - * DOS compilers provide far-pointer versions of memcpy() and memset() even - * in the small-model libraries. These will be used if USE_FMEM is defined. - * Otherwise, the routines below do it the hard way. (The performance cost - * is not all that great, because these routines aren't very heavily used.) - */ - -#ifndef NEED_FAR_POINTERS /* normal case, same as regular macros */ -#define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size) -#define FMEMZERO(target,size) MEMZERO(target,size) -#else /* 80x86 case, define if we can */ -#ifdef USE_FMEM -#define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size)) -#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size)) -#endif -#endif - - -GLOBAL(void) -jcopy_sample_rows (JSAMPARRAY input_array, int source_row, - JSAMPARRAY output_array, int dest_row, - int num_rows, JDIMENSION num_cols) -/* Copy some rows of samples from one place to another. - * num_rows rows are copied from input_array[source_row++] - * to output_array[dest_row++]; these areas may overlap for duplication. - * The source and destination arrays must be at least as wide as num_cols. - */ -{ - register JSAMPROW inptr, outptr; -#ifdef FMEMCOPY - register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE)); -#else - register JDIMENSION count; -#endif - register int row; - - input_array += source_row; - output_array += dest_row; - - for (row = num_rows; row > 0; row--) { - inptr = *input_array++; - outptr = *output_array++; -#ifdef FMEMCOPY - FMEMCOPY(outptr, inptr, count); -#else - for (count = num_cols; count > 0; count--) - *outptr++ = *inptr++; /* needn't bother with GETJSAMPLE() here */ -#endif - } -} - - -GLOBAL(void) -jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row, - JDIMENSION num_blocks) -/* Copy a row of coefficient blocks from one place to another. */ -{ -#ifdef FMEMCOPY - FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); -#else - register JCOEFPTR inptr, outptr; - register long count; - - inptr = (JCOEFPTR) input_row; - outptr = (JCOEFPTR) output_row; - for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) { - *outptr++ = *inptr++; - } -#endif -} - - -GLOBAL(void) -jzero_far (void FAR * target, size_t bytestozero) -/* Zero out a chunk of FAR memory. */ -/* This might be sample-array data, block-array data, or alloc_large data. */ -{ -#ifdef FMEMZERO - FMEMZERO(target, bytestozero); -#else - register char FAR * ptr = (char FAR *) target; - register size_t count; - - for (count = bytestozero; count > 0; count--) { - *ptr++ = 0; - } -#endif -} +/* + * jutils.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains tables and miscellaneous utility routines needed + * for both compression and decompression. + * Note we prefix all global names with "j" to minimize conflicts with + * a surrounding application. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element + * of a DCT block read in natural order (left to right, top to bottom). + */ + +#if 0 /* This table is not actually needed in v6a */ + +const int jpeg_zigzag_order[DCTSIZE2] = { + 0, 1, 5, 6, 14, 15, 27, 28, + 2, 4, 7, 13, 16, 26, 29, 42, + 3, 8, 12, 17, 25, 30, 41, 43, + 9, 11, 18, 24, 31, 40, 44, 53, + 10, 19, 23, 32, 39, 45, 52, 54, + 20, 22, 33, 38, 46, 51, 55, 60, + 21, 34, 37, 47, 50, 56, 59, 61, + 35, 36, 48, 49, 57, 58, 62, 63 +}; + +#endif + +/* + * jpeg_natural_order[i] is the natural-order position of the i'th element + * of zigzag order. + * + * When reading corrupted data, the Huffman decoders could attempt + * to reference an entry beyond the end of this array (if the decoded + * zero run length reaches past the end of the block). To prevent + * wild stores without adding an inner-loop test, we put some extra + * "63"s after the real entries. This will cause the extra coefficient + * to be stored in location 63 of the block, not somewhere random. + * The worst case would be a run-length of 15, which means we need 16 + * fake entries. + */ + +const int jpeg_natural_order[DCTSIZE2+16] = { + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, + 27, 20, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63, + 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ + 63, 63, 63, 63, 63, 63, 63, 63 +}; + + +/* + * Arithmetic utilities + */ + +GLOBAL(long) +jdiv_round_up (long a, long b) +/* Compute a/b rounded up to next integer, ie, ceil(a/b) */ +/* Assumes a >= 0, b > 0 */ +{ + return (a + b - 1L) / b; +} + + +GLOBAL(long) +jround_up (long a, long b) +/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ +/* Assumes a >= 0, b > 0 */ +{ + a += b - 1L; + return a - (a % b); +} + + +/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays + * and coefficient-block arrays. This won't work on 80x86 because the arrays + * are FAR and we're assuming a small-pointer memory model. However, some + * DOS compilers provide far-pointer versions of memcpy() and memset() even + * in the small-model libraries. These will be used if USE_FMEM is defined. + * Otherwise, the routines below do it the hard way. (The performance cost + * is not all that great, because these routines aren't very heavily used.) + */ + +#ifndef NEED_FAR_POINTERS /* normal case, same as regular macros */ +#define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size) +#define FMEMZERO(target,size) MEMZERO(target,size) +#else /* 80x86 case, define if we can */ +#ifdef USE_FMEM +#define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size)) +#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size)) +#endif +#endif + + +GLOBAL(void) +jcopy_sample_rows (JSAMPARRAY input_array, int source_row, + JSAMPARRAY output_array, int dest_row, + int num_rows, JDIMENSION num_cols) +/* Copy some rows of samples from one place to another. + * num_rows rows are copied from input_array[source_row++] + * to output_array[dest_row++]; these areas may overlap for duplication. + * The source and destination arrays must be at least as wide as num_cols. + */ +{ + register JSAMPROW inptr, outptr; +#ifdef FMEMCOPY + register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE)); +#else + register JDIMENSION count; +#endif + register int row; + + input_array += source_row; + output_array += dest_row; + + for (row = num_rows; row > 0; row--) { + inptr = *input_array++; + outptr = *output_array++; +#ifdef FMEMCOPY + FMEMCOPY(outptr, inptr, count); +#else + for (count = num_cols; count > 0; count--) + *outptr++ = *inptr++; /* needn't bother with GETJSAMPLE() here */ +#endif + } +} + + +GLOBAL(void) +jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row, + JDIMENSION num_blocks) +/* Copy a row of coefficient blocks from one place to another. */ +{ +#ifdef FMEMCOPY + FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); +#else + register JCOEFPTR inptr, outptr; + register long count; + + inptr = (JCOEFPTR) input_row; + outptr = (JCOEFPTR) output_row; + for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) { + *outptr++ = *inptr++; + } +#endif +} + + +GLOBAL(void) +jzero_far (void FAR * target, size_t bytestozero) +/* Zero out a chunk of FAR memory. */ +/* This might be sample-array data, block-array data, or alloc_large data. */ +{ +#ifdef FMEMZERO + FMEMZERO(target, bytestozero); +#else + register char FAR * ptr = (char FAR *) target; + register size_t count; + + for (count = bytestozero; count > 0; count--) { + *ptr++ = 0; + } +#endif +} diff --git a/src/dep/src/irrlicht/jpeglib/jversion.h b/src/dep/src/irrlicht/jpeglib/jversion.h index dadd453..6472c58 100644 --- a/src/dep/src/irrlicht/jpeglib/jversion.h +++ b/src/dep/src/irrlicht/jpeglib/jversion.h @@ -1,14 +1,14 @@ -/* - * jversion.h - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains software version identification. - */ - - -#define JVERSION "6b 27-Mar-1998" - -#define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane" +/* + * jversion.h + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains software version identification. + */ + + +#define JVERSION "6b 27-Mar-1998" + +#define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane" diff --git a/src/dep/src/irrlicht/jpeglib/libjpeg.doc b/src/dep/src/irrlicht/jpeglib/libjpeg.doc index f741051..689b206 100644 --- a/src/dep/src/irrlicht/jpeglib/libjpeg.doc +++ b/src/dep/src/irrlicht/jpeglib/libjpeg.doc @@ -1,3006 +1,3006 @@ -USING THE IJG JPEG LIBRARY - -Copyright (C) 1994-1998, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -This file describes how to use the IJG JPEG library within an application -program. Read it if you want to write a program that uses the library. - -The file example.c provides heavily commented skeleton code for calling the -JPEG library. Also see jpeglib.h (the include file to be used by application -programs) for full details about data structures and function parameter lists. -The library source code, of course, is the ultimate reference. - -Note that there have been *major* changes from the application interface -presented by IJG version 4 and earlier versions. The old design had several -inherent limitations, and it had accumulated a lot of cruft as we added -features while trying to minimize application-interface changes. We have -sacrificed backward compatibility in the version 5 rewrite, but we think the -improvements justify this. - - -TABLE OF CONTENTS ------------------ - -Overview: - Functions provided by the library - Outline of typical usage -Basic library usage: - Data formats - Compression details - Decompression details - Mechanics of usage: include files, linking, etc -Advanced features: - Compression parameter selection - Decompression parameter selection - Special color spaces - Error handling - Compressed data handling (source and destination managers) - I/O suspension - Progressive JPEG support - Buffered-image mode - Abbreviated datastreams and multiple images - Special markers - Raw (downsampled) image data - Really raw data: DCT coefficients - Progress monitoring - Memory management - Memory usage - Library compile-time options - Portability considerations - Notes for MS-DOS implementors - -You should read at least the overview and basic usage sections before trying -to program with the library. The sections on advanced features can be read -if and when you need them. - - -OVERVIEW -======== - -Functions provided by the library ---------------------------------- - -The IJG JPEG library provides C code to read and write JPEG-compressed image -files. The surrounding application program receives or supplies image data a -scanline at a time, using a straightforward uncompressed image format. All -details of color conversion and other preprocessing/postprocessing can be -handled by the library. - -The library includes a substantial amount of code that is not covered by the -JPEG standard but is necessary for typical applications of JPEG. These -functions preprocess the image before JPEG compression or postprocess it after -decompression. They include colorspace conversion, downsampling/upsampling, -and color quantization. The application indirectly selects use of this code -by specifying the format in which it wishes to supply or receive image data. -For example, if colormapped output is requested, then the decompression -library automatically invokes color quantization. - -A wide range of quality vs. speed tradeoffs are possible in JPEG processing, -and even more so in decompression postprocessing. The decompression library -provides multiple implementations that cover most of the useful tradeoffs, -ranging from very-high-quality down to fast-preview operation. On the -compression side we have generally not provided low-quality choices, since -compression is normally less time-critical. It should be understood that the -low-quality modes may not meet the JPEG standard's accuracy requirements; -nonetheless, they are useful for viewers. - -A word about functions *not* provided by the library. We handle a subset of -the ISO JPEG standard; most baseline, extended-sequential, and progressive -JPEG processes are supported. (Our subset includes all features now in common -use.) Unsupported ISO options include: - * Hierarchical storage - * Lossless JPEG - * Arithmetic entropy coding (unsupported for legal reasons) - * DNL marker - * Nonintegral subsampling ratios -We support both 8- and 12-bit data precision, but this is a compile-time -choice rather than a run-time choice; hence it is difficult to use both -precisions in a single application. - -By itself, the library handles only interchange JPEG datastreams --- in -particular the widely used JFIF file format. The library can be used by -surrounding code to process interchange or abbreviated JPEG datastreams that -are embedded in more complex file formats. (For example, this library is -used by the free LIBTIFF library to support JPEG compression in TIFF.) - - -Outline of typical usage ------------------------- - -The rough outline of a JPEG compression operation is: - - Allocate and initialize a JPEG compression object - Specify the destination for the compressed data (eg, a file) - Set parameters for compression, including image size & colorspace - jpeg_start_compress(...); - while (scan lines remain to be written) - jpeg_write_scanlines(...); - jpeg_finish_compress(...); - Release the JPEG compression object - -A JPEG compression object holds parameters and working state for the JPEG -library. We make creation/destruction of the object separate from starting -or finishing compression of an image; the same object can be re-used for a -series of image compression operations. This makes it easy to re-use the -same parameter settings for a sequence of images. Re-use of a JPEG object -also has important implications for processing abbreviated JPEG datastreams, -as discussed later. - -The image data to be compressed is supplied to jpeg_write_scanlines() from -in-memory buffers. If the application is doing file-to-file compression, -reading image data from the source file is the application's responsibility. -The library emits compressed data by calling a "data destination manager", -which typically will write the data into a file; but the application can -provide its own destination manager to do something else. - -Similarly, the rough outline of a JPEG decompression operation is: - - Allocate and initialize a JPEG decompression object - Specify the source of the compressed data (eg, a file) - Call jpeg_read_header() to obtain image info - Set parameters for decompression - jpeg_start_decompress(...); - while (scan lines remain to be read) - jpeg_read_scanlines(...); - jpeg_finish_decompress(...); - Release the JPEG decompression object - -This is comparable to the compression outline except that reading the -datastream header is a separate step. This is helpful because information -about the image's size, colorspace, etc is available when the application -selects decompression parameters. For example, the application can choose an -output scaling ratio that will fit the image into the available screen size. - -The decompression library obtains compressed data by calling a data source -manager, which typically will read the data from a file; but other behaviors -can be obtained with a custom source manager. Decompressed data is delivered -into in-memory buffers passed to jpeg_read_scanlines(). - -It is possible to abort an incomplete compression or decompression operation -by calling jpeg_abort(); or, if you do not need to retain the JPEG object, -simply release it by calling jpeg_destroy(). - -JPEG compression and decompression objects are two separate struct types. -However, they share some common fields, and certain routines such as -jpeg_destroy() can work on either type of object. - -The JPEG library has no static variables: all state is in the compression -or decompression object. Therefore it is possible to process multiple -compression and decompression operations concurrently, using multiple JPEG -objects. - -Both compression and decompression can be done in an incremental memory-to- -memory fashion, if suitable source/destination managers are used. See the -section on "I/O suspension" for more details. - - -BASIC LIBRARY USAGE -=================== - -Data formats ------------- - -Before diving into procedural details, it is helpful to understand the -image data format that the JPEG library expects or returns. - -The standard input image format is a rectangular array of pixels, with each -pixel having the same number of "component" or "sample" values (color -channels). You must specify how many components there are and the colorspace -interpretation of the components. Most applications will use RGB data -(three components per pixel) or grayscale data (one component per pixel). -PLEASE NOTE THAT RGB DATA IS THREE SAMPLES PER PIXEL, GRAYSCALE ONLY ONE. -A remarkable number of people manage to miss this, only to find that their -programs don't work with grayscale JPEG files. - -There is no provision for colormapped input. JPEG files are always full-color -or full grayscale (or sometimes another colorspace such as CMYK). You can -feed in a colormapped image by expanding it to full-color format. However -JPEG often doesn't work very well with source data that has been colormapped, -because of dithering noise. This is discussed in more detail in the JPEG FAQ -and the other references mentioned in the README file. - -Pixels are stored by scanlines, with each scanline running from left to -right. The component values for each pixel are adjacent in the row; for -example, R,G,B,R,G,B,R,G,B,... for 24-bit RGB color. Each scanline is an -array of data type JSAMPLE --- which is typically "unsigned char", unless -you've changed jmorecfg.h. (You can also change the RGB pixel layout, say -to B,G,R order, by modifying jmorecfg.h. But see the restrictions listed in -that file before doing so.) - -A 2-D array of pixels is formed by making a list of pointers to the starts of -scanlines; so the scanlines need not be physically adjacent in memory. Even -if you process just one scanline at a time, you must make a one-element -pointer array to conform to this structure. Pointers to JSAMPLE rows are of -type JSAMPROW, and the pointer to the pointer array is of type JSAMPARRAY. - -The library accepts or supplies one or more complete scanlines per call. -It is not possible to process part of a row at a time. Scanlines are always -processed top-to-bottom. You can process an entire image in one call if you -have it all in memory, but usually it's simplest to process one scanline at -a time. - -For best results, source data values should have the precision specified by -BITS_IN_JSAMPLE (normally 8 bits). For instance, if you choose to compress -data that's only 6 bits/channel, you should left-justify each value in a -byte before passing it to the compressor. If you need to compress data -that has more than 8 bits/channel, compile with BITS_IN_JSAMPLE = 12. -(See "Library compile-time options", later.) - - -The data format returned by the decompressor is the same in all details, -except that colormapped output is supported. (Again, a JPEG file is never -colormapped. But you can ask the decompressor to perform on-the-fly color -quantization to deliver colormapped output.) If you request colormapped -output then the returned data array contains a single JSAMPLE per pixel; -its value is an index into a color map. The color map is represented as -a 2-D JSAMPARRAY in which each row holds the values of one color component, -that is, colormap[i][j] is the value of the i'th color component for pixel -value (map index) j. Note that since the colormap indexes are stored in -JSAMPLEs, the maximum number of colors is limited by the size of JSAMPLE -(ie, at most 256 colors for an 8-bit JPEG library). - - -Compression details -------------------- - -Here we revisit the JPEG compression outline given in the overview. - -1. Allocate and initialize a JPEG compression object. - -A JPEG compression object is a "struct jpeg_compress_struct". (It also has -a bunch of subsidiary structures which are allocated via malloc(), but the -application doesn't control those directly.) This struct can be just a local -variable in the calling routine, if a single routine is going to execute the -whole JPEG compression sequence. Otherwise it can be static or allocated -from malloc(). - -You will also need a structure representing a JPEG error handler. The part -of this that the library cares about is a "struct jpeg_error_mgr". If you -are providing your own error handler, you'll typically want to embed the -jpeg_error_mgr struct in a larger structure; this is discussed later under -"Error handling". For now we'll assume you are just using the default error -handler. The default error handler will print JPEG error/warning messages -on stderr, and it will call exit() if a fatal error occurs. - -You must initialize the error handler structure, store a pointer to it into -the JPEG object's "err" field, and then call jpeg_create_compress() to -initialize the rest of the JPEG object. - -Typical code for this step, if you are using the default error handler, is - - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; - ... - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - -jpeg_create_compress allocates a small amount of memory, so it could fail -if you are out of memory. In that case it will exit via the error handler; -that's why the error handler must be initialized first. - - -2. Specify the destination for the compressed data (eg, a file). - -As previously mentioned, the JPEG library delivers compressed data to a -"data destination" module. The library includes one data destination -module which knows how to write to a stdio stream. You can use your own -destination module if you want to do something else, as discussed later. - -If you use the standard destination module, you must open the target stdio -stream beforehand. Typical code for this step looks like: - - FILE * outfile; - ... - if ((outfile = fopen(filename, "wb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - exit(1); - } - jpeg_stdio_dest(&cinfo, outfile); - -where the last line invokes the standard destination module. - -WARNING: it is critical that the binary compressed data be delivered to the -output file unchanged. On non-Unix systems the stdio library may perform -newline translation or otherwise corrupt binary data. To suppress this -behavior, you may need to use a "b" option to fopen (as shown above), or use -setmode() or another routine to put the stdio stream in binary mode. See -cjpeg.c and djpeg.c for code that has been found to work on many systems. - -You can select the data destination after setting other parameters (step 3), -if that's more convenient. You may not change the destination between -calling jpeg_start_compress() and jpeg_finish_compress(). - - -3. Set parameters for compression, including image size & colorspace. - -You must supply information about the source image by setting the following -fields in the JPEG object (cinfo structure): - - image_width Width of image, in pixels - image_height Height of image, in pixels - input_components Number of color channels (samples per pixel) - in_color_space Color space of source image - -The image dimensions are, hopefully, obvious. JPEG supports image dimensions -of 1 to 64K pixels in either direction. The input color space is typically -RGB or grayscale, and input_components is 3 or 1 accordingly. (See "Special -color spaces", later, for more info.) The in_color_space field must be -assigned one of the J_COLOR_SPACE enum constants, typically JCS_RGB or -JCS_GRAYSCALE. - -JPEG has a large number of compression parameters that determine how the -image is encoded. Most applications don't need or want to know about all -these parameters. You can set all the parameters to reasonable defaults by -calling jpeg_set_defaults(); then, if there are particular values you want -to change, you can do so after that. The "Compression parameter selection" -section tells about all the parameters. - -You must set in_color_space correctly before calling jpeg_set_defaults(), -because the defaults depend on the source image colorspace. However the -other three source image parameters need not be valid until you call -jpeg_start_compress(). There's no harm in calling jpeg_set_defaults() more -than once, if that happens to be convenient. - -Typical code for a 24-bit RGB source image is - - cinfo.image_width = Width; /* image width and height, in pixels */ - cinfo.image_height = Height; - cinfo.input_components = 3; /* # of color components per pixel */ - cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ - - jpeg_set_defaults(&cinfo); - /* Make optional parameter settings here */ - - -4. jpeg_start_compress(...); - -After you have established the data destination and set all the necessary -source image info and other parameters, call jpeg_start_compress() to begin -a compression cycle. This will initialize internal state, allocate working -storage, and emit the first few bytes of the JPEG datastream header. - -Typical code: - - jpeg_start_compress(&cinfo, TRUE); - -The "TRUE" parameter ensures that a complete JPEG interchange datastream -will be written. This is appropriate in most cases. If you think you might -want to use an abbreviated datastream, read the section on abbreviated -datastreams, below. - -Once you have called jpeg_start_compress(), you may not alter any JPEG -parameters or other fields of the JPEG object until you have completed -the compression cycle. - - -5. while (scan lines remain to be written) - jpeg_write_scanlines(...); - -Now write all the required image data by calling jpeg_write_scanlines() -one or more times. You can pass one or more scanlines in each call, up -to the total image height. In most applications it is convenient to pass -just one or a few scanlines at a time. The expected format for the passed -data is discussed under "Data formats", above. - -Image data should be written in top-to-bottom scanline order. The JPEG spec -contains some weasel wording about how top and bottom are application-defined -terms (a curious interpretation of the English language...) but if you want -your files to be compatible with everyone else's, you WILL use top-to-bottom -order. If the source data must be read in bottom-to-top order, you can use -the JPEG library's virtual array mechanism to invert the data efficiently. -Examples of this can be found in the sample application cjpeg. - -The library maintains a count of the number of scanlines written so far -in the next_scanline field of the JPEG object. Usually you can just use -this variable as the loop counter, so that the loop test looks like -"while (cinfo.next_scanline < cinfo.image_height)". - -Code for this step depends heavily on the way that you store the source data. -example.c shows the following code for the case of a full-size 2-D source -array containing 3-byte RGB pixels: - - JSAMPROW row_pointer[1]; /* pointer to a single row */ - int row_stride; /* physical row width in buffer */ - - row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ - - while (cinfo.next_scanline < cinfo.image_height) { - row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; - jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - -jpeg_write_scanlines() returns the number of scanlines actually written. -This will normally be equal to the number passed in, so you can usually -ignore the return value. It is different in just two cases: - * If you try to write more scanlines than the declared image height, - the additional scanlines are ignored. - * If you use a suspending data destination manager, output buffer overrun - will cause the compressor to return before accepting all the passed lines. - This feature is discussed under "I/O suspension", below. The normal - stdio destination manager will NOT cause this to happen. -In any case, the return value is the same as the change in the value of -next_scanline. - - -6. jpeg_finish_compress(...); - -After all the image data has been written, call jpeg_finish_compress() to -complete the compression cycle. This step is ESSENTIAL to ensure that the -last bufferload of data is written to the data destination. -jpeg_finish_compress() also releases working memory associated with the JPEG -object. - -Typical code: - - jpeg_finish_compress(&cinfo); - -If using the stdio destination manager, don't forget to close the output -stdio stream (if necessary) afterwards. - -If you have requested a multi-pass operating mode, such as Huffman code -optimization, jpeg_finish_compress() will perform the additional passes using -data buffered by the first pass. In this case jpeg_finish_compress() may take -quite a while to complete. With the default compression parameters, this will -not happen. - -It is an error to call jpeg_finish_compress() before writing the necessary -total number of scanlines. If you wish to abort compression, call -jpeg_abort() as discussed below. - -After completing a compression cycle, you may dispose of the JPEG object -as discussed next, or you may use it to compress another image. In that case -return to step 2, 3, or 4 as appropriate. If you do not change the -destination manager, the new datastream will be written to the same target. -If you do not change any JPEG parameters, the new datastream will be written -with the same parameters as before. Note that you can change the input image -dimensions freely between cycles, but if you change the input colorspace, you -should call jpeg_set_defaults() to adjust for the new colorspace; and then -you'll need to repeat all of step 3. - - -7. Release the JPEG compression object. - -When you are done with a JPEG compression object, destroy it by calling -jpeg_destroy_compress(). This will free all subsidiary memory (regardless of -the previous state of the object). Or you can call jpeg_destroy(), which -works for either compression or decompression objects --- this may be more -convenient if you are sharing code between compression and decompression -cases. (Actually, these routines are equivalent except for the declared type -of the passed pointer. To avoid gripes from ANSI C compilers, jpeg_destroy() -should be passed a j_common_ptr.) - -If you allocated the jpeg_compress_struct structure from malloc(), freeing -it is your responsibility --- jpeg_destroy() won't. Ditto for the error -handler structure. - -Typical code: - - jpeg_destroy_compress(&cinfo); - - -8. Aborting. - -If you decide to abort a compression cycle before finishing, you can clean up -in either of two ways: - -* If you don't need the JPEG object any more, just call - jpeg_destroy_compress() or jpeg_destroy() to release memory. This is - legitimate at any point after calling jpeg_create_compress() --- in fact, - it's safe even if jpeg_create_compress() fails. - -* If you want to re-use the JPEG object, call jpeg_abort_compress(), or call - jpeg_abort() which works on both compression and decompression objects. - This will return the object to an idle state, releasing any working memory. - jpeg_abort() is allowed at any time after successful object creation. - -Note that cleaning up the data destination, if required, is your -responsibility; neither of these routines will call term_destination(). -(See "Compressed data handling", below, for more about that.) - -jpeg_destroy() and jpeg_abort() are the only safe calls to make on a JPEG -object that has reported an error by calling error_exit (see "Error handling" -for more info). The internal state of such an object is likely to be out of -whack. Either of these two routines will return the object to a known state. - - -Decompression details ---------------------- - -Here we revisit the JPEG decompression outline given in the overview. - -1. Allocate and initialize a JPEG decompression object. - -This is just like initialization for compression, as discussed above, -except that the object is a "struct jpeg_decompress_struct" and you -call jpeg_create_decompress(). Error handling is exactly the same. - -Typical code: - - struct jpeg_decompress_struct cinfo; - struct jpeg_error_mgr jerr; - ... - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_decompress(&cinfo); - -(Both here and in the IJG code, we usually use variable name "cinfo" for -both compression and decompression objects.) - - -2. Specify the source of the compressed data (eg, a file). - -As previously mentioned, the JPEG library reads compressed data from a "data -source" module. The library includes one data source module which knows how -to read from a stdio stream. You can use your own source module if you want -to do something else, as discussed later. - -If you use the standard source module, you must open the source stdio stream -beforehand. Typical code for this step looks like: - - FILE * infile; - ... - if ((infile = fopen(filename, "rb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - exit(1); - } - jpeg_stdio_src(&cinfo, infile); - -where the last line invokes the standard source module. - -WARNING: it is critical that the binary compressed data be read unchanged. -On non-Unix systems the stdio library may perform newline translation or -otherwise corrupt binary data. To suppress this behavior, you may need to use -a "b" option to fopen (as shown above), or use setmode() or another routine to -put the stdio stream in binary mode. See cjpeg.c and djpeg.c for code that -has been found to work on many systems. - -You may not change the data source between calling jpeg_read_header() and -jpeg_finish_decompress(). If you wish to read a series of JPEG images from -a single source file, you should repeat the jpeg_read_header() to -jpeg_finish_decompress() sequence without reinitializing either the JPEG -object or the data source module; this prevents buffered input data from -being discarded. - - -3. Call jpeg_read_header() to obtain image info. - -Typical code for this step is just - - jpeg_read_header(&cinfo, TRUE); - -This will read the source datastream header markers, up to the beginning -of the compressed data proper. On return, the image dimensions and other -info have been stored in the JPEG object. The application may wish to -consult this information before selecting decompression parameters. - -More complex code is necessary if - * A suspending data source is used --- in that case jpeg_read_header() - may return before it has read all the header data. See "I/O suspension", - below. The normal stdio source manager will NOT cause this to happen. - * Abbreviated JPEG files are to be processed --- see the section on - abbreviated datastreams. Standard applications that deal only in - interchange JPEG files need not be concerned with this case either. - -It is permissible to stop at this point if you just wanted to find out the -image dimensions and other header info for a JPEG file. In that case, -call jpeg_destroy() when you are done with the JPEG object, or call -jpeg_abort() to return it to an idle state before selecting a new data -source and reading another header. - - -4. Set parameters for decompression. - -jpeg_read_header() sets appropriate default decompression parameters based on -the properties of the image (in particular, its colorspace). However, you -may well want to alter these defaults before beginning the decompression. -For example, the default is to produce full color output from a color file. -If you want colormapped output you must ask for it. Other options allow the -returned image to be scaled and allow various speed/quality tradeoffs to be -selected. "Decompression parameter selection", below, gives details. - -If the defaults are appropriate, nothing need be done at this step. - -Note that all default values are set by each call to jpeg_read_header(). -If you reuse a decompression object, you cannot expect your parameter -settings to be preserved across cycles, as you can for compression. -You must set desired parameter values each time. - - -5. jpeg_start_decompress(...); - -Once the parameter values are satisfactory, call jpeg_start_decompress() to -begin decompression. This will initialize internal state, allocate working -memory, and prepare for returning data. - -Typical code is just - - jpeg_start_decompress(&cinfo); - -If you have requested a multi-pass operating mode, such as 2-pass color -quantization, jpeg_start_decompress() will do everything needed before data -output can begin. In this case jpeg_start_decompress() may take quite a while -to complete. With a single-scan (non progressive) JPEG file and default -decompression parameters, this will not happen; jpeg_start_decompress() will -return quickly. - -After this call, the final output image dimensions, including any requested -scaling, are available in the JPEG object; so is the selected colormap, if -colormapped output has been requested. Useful fields include - - output_width image width and height, as scaled - output_height - out_color_components # of color components in out_color_space - output_components # of color components returned per pixel - colormap the selected colormap, if any - actual_number_of_colors number of entries in colormap - -output_components is 1 (a colormap index) when quantizing colors; otherwise it -equals out_color_components. It is the number of JSAMPLE values that will be -emitted per pixel in the output arrays. - -Typically you will need to allocate data buffers to hold the incoming image. -You will need output_width * output_components JSAMPLEs per scanline in your -output buffer, and a total of output_height scanlines will be returned. - -Note: if you are using the JPEG library's internal memory manager to allocate -data buffers (as djpeg does), then the manager's protocol requires that you -request large buffers *before* calling jpeg_start_decompress(). This is a -little tricky since the output_XXX fields are not normally valid then. You -can make them valid by calling jpeg_calc_output_dimensions() after setting the -relevant parameters (scaling, output color space, and quantization flag). - - -6. while (scan lines remain to be read) - jpeg_read_scanlines(...); - -Now you can read the decompressed image data by calling jpeg_read_scanlines() -one or more times. At each call, you pass in the maximum number of scanlines -to be read (ie, the height of your working buffer); jpeg_read_scanlines() -will return up to that many lines. The return value is the number of lines -actually read. The format of the returned data is discussed under "Data -formats", above. Don't forget that grayscale and color JPEGs will return -different data formats! - -Image data is returned in top-to-bottom scanline order. If you must write -out the image in bottom-to-top order, you can use the JPEG library's virtual -array mechanism to invert the data efficiently. Examples of this can be -found in the sample application djpeg. - -The library maintains a count of the number of scanlines returned so far -in the output_scanline field of the JPEG object. Usually you can just use -this variable as the loop counter, so that the loop test looks like -"while (cinfo.output_scanline < cinfo.output_height)". (Note that the test -should NOT be against image_height, unless you never use scaling. The -image_height field is the height of the original unscaled image.) -The return value always equals the change in the value of output_scanline. - -If you don't use a suspending data source, it is safe to assume that -jpeg_read_scanlines() reads at least one scanline per call, until the -bottom of the image has been reached. - -If you use a buffer larger than one scanline, it is NOT safe to assume that -jpeg_read_scanlines() fills it. (The current implementation returns only a -few scanlines per call, no matter how large a buffer you pass.) So you must -always provide a loop that calls jpeg_read_scanlines() repeatedly until the -whole image has been read. - - -7. jpeg_finish_decompress(...); - -After all the image data has been read, call jpeg_finish_decompress() to -complete the decompression cycle. This causes working memory associated -with the JPEG object to be released. - -Typical code: - - jpeg_finish_decompress(&cinfo); - -If using the stdio source manager, don't forget to close the source stdio -stream if necessary. - -It is an error to call jpeg_finish_decompress() before reading the correct -total number of scanlines. If you wish to abort decompression, call -jpeg_abort() as discussed below. - -After completing a decompression cycle, you may dispose of the JPEG object as -discussed next, or you may use it to decompress another image. In that case -return to step 2 or 3 as appropriate. If you do not change the source -manager, the next image will be read from the same source. - - -8. Release the JPEG decompression object. - -When you are done with a JPEG decompression object, destroy it by calling -jpeg_destroy_decompress() or jpeg_destroy(). The previous discussion of -destroying compression objects applies here too. - -Typical code: - - jpeg_destroy_decompress(&cinfo); - - -9. Aborting. - -You can abort a decompression cycle by calling jpeg_destroy_decompress() or -jpeg_destroy() if you don't need the JPEG object any more, or -jpeg_abort_decompress() or jpeg_abort() if you want to reuse the object. -The previous discussion of aborting compression cycles applies here too. - - -Mechanics of usage: include files, linking, etc ------------------------------------------------ - -Applications using the JPEG library should include the header file jpeglib.h -to obtain declarations of data types and routines. Before including -jpeglib.h, include system headers that define at least the typedefs FILE and -size_t. On ANSI-conforming systems, including is sufficient; on -older Unix systems, you may need to define size_t. - -If the application needs to refer to individual JPEG library error codes, also -include jerror.h to define those symbols. - -jpeglib.h indirectly includes the files jconfig.h and jmorecfg.h. If you are -installing the JPEG header files in a system directory, you will want to -install all four files: jpeglib.h, jerror.h, jconfig.h, jmorecfg.h. - -The most convenient way to include the JPEG code into your executable program -is to prepare a library file ("libjpeg.a", or a corresponding name on non-Unix -machines) and reference it at your link step. If you use only half of the -library (only compression or only decompression), only that much code will be -included from the library, unless your linker is hopelessly brain-damaged. -The supplied makefiles build libjpeg.a automatically (see install.doc). - -While you can build the JPEG library as a shared library if the whim strikes -you, we don't really recommend it. The trouble with shared libraries is that -at some point you'll probably try to substitute a new version of the library -without recompiling the calling applications. That generally doesn't work -because the parameter struct declarations usually change with each new -version. In other words, the library's API is *not* guaranteed binary -compatible across versions; we only try to ensure source-code compatibility. -(In hindsight, it might have been smarter to hide the parameter structs from -applications and introduce a ton of access functions instead. Too late now, -however.) - -On some systems your application may need to set up a signal handler to ensure -that temporary files are deleted if the program is interrupted. This is most -critical if you are on MS-DOS and use the jmemdos.c memory manager back end; -it will try to grab extended memory for temp files, and that space will NOT be -freed automatically. See cjpeg.c or djpeg.c for an example signal handler. - -It may be worth pointing out that the core JPEG library does not actually -require the stdio library: only the default source/destination managers and -error handler need it. You can use the library in a stdio-less environment -if you replace those modules and use jmemnobs.c (or another memory manager of -your own devising). More info about the minimum system library requirements -may be found in jinclude.h. - - -ADVANCED FEATURES -================= - -Compression parameter selection -------------------------------- - -This section describes all the optional parameters you can set for JPEG -compression, as well as the "helper" routines provided to assist in this -task. Proper setting of some parameters requires detailed understanding -of the JPEG standard; if you don't know what a parameter is for, it's best -not to mess with it! See REFERENCES in the README file for pointers to -more info about JPEG. - -It's a good idea to call jpeg_set_defaults() first, even if you plan to set -all the parameters; that way your code is more likely to work with future JPEG -libraries that have additional parameters. For the same reason, we recommend -you use a helper routine where one is provided, in preference to twiddling -cinfo fields directly. - -The helper routines are: - -jpeg_set_defaults (j_compress_ptr cinfo) - This routine sets all JPEG parameters to reasonable defaults, using - only the input image's color space (field in_color_space, which must - already be set in cinfo). Many applications will only need to use - this routine and perhaps jpeg_set_quality(). - -jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) - Sets the JPEG file's colorspace (field jpeg_color_space) as specified, - and sets other color-space-dependent parameters appropriately. See - "Special color spaces", below, before using this. A large number of - parameters, including all per-component parameters, are set by this - routine; if you want to twiddle individual parameters you should call - jpeg_set_colorspace() before rather than after. - -jpeg_default_colorspace (j_compress_ptr cinfo) - Selects an appropriate JPEG colorspace based on cinfo->in_color_space, - and calls jpeg_set_colorspace(). This is actually a subroutine of - jpeg_set_defaults(). It's broken out in case you want to change - just the colorspace-dependent JPEG parameters. - -jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) - Constructs JPEG quantization tables appropriate for the indicated - quality setting. The quality value is expressed on the 0..100 scale - recommended by IJG (cjpeg's "-quality" switch uses this routine). - Note that the exact mapping from quality values to tables may change - in future IJG releases as more is learned about DCT quantization. - If the force_baseline parameter is TRUE, then the quantization table - entries are constrained to the range 1..255 for full JPEG baseline - compatibility. In the current implementation, this only makes a - difference for quality settings below 25, and it effectively prevents - very small/low quality files from being generated. The IJG decoder - is capable of reading the non-baseline files generated at low quality - settings when force_baseline is FALSE, but other decoders may not be. - -jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, - boolean force_baseline) - Same as jpeg_set_quality() except that the generated tables are the - sample tables given in the JPEC spec section K.1, multiplied by the - specified scale factor (which is expressed as a percentage; thus - scale_factor = 100 reproduces the spec's tables). Note that larger - scale factors give lower quality. This entry point is useful for - conforming to the Adobe PostScript DCT conventions, but we do not - recommend linear scaling as a user-visible quality scale otherwise. - force_baseline again constrains the computed table entries to 1..255. - -int jpeg_quality_scaling (int quality) - Converts a value on the IJG-recommended quality scale to a linear - scaling percentage. Note that this routine may change or go away - in future releases --- IJG may choose to adopt a scaling method that - can't be expressed as a simple scalar multiplier, in which case the - premise of this routine collapses. Caveat user. - -jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, boolean force_baseline) - Allows an arbitrary quantization table to be created. which_tbl - indicates which table slot to fill. basic_table points to an array - of 64 unsigned ints given in normal array order. These values are - multiplied by scale_factor/100 and then clamped to the range 1..65535 - (or to 1..255 if force_baseline is TRUE). - CAUTION: prior to library version 6a, jpeg_add_quant_table expected - the basic table to be given in JPEG zigzag order. If you need to - write code that works with either older or newer versions of this - routine, you must check the library version number. Something like - "#if JPEG_LIB_VERSION >= 61" is the right test. - -jpeg_simple_progression (j_compress_ptr cinfo) - Generates a default scan script for writing a progressive-JPEG file. - This is the recommended method of creating a progressive file, - unless you want to make a custom scan sequence. You must ensure that - the JPEG color space is set correctly before calling this routine. - - -Compression parameters (cinfo fields) include: - -J_DCT_METHOD dct_method - Selects the algorithm used for the DCT step. Choices are: - JDCT_ISLOW: slow but accurate integer algorithm - JDCT_IFAST: faster, less accurate integer method - JDCT_FLOAT: floating-point method - JDCT_DEFAULT: default method (normally JDCT_ISLOW) - JDCT_FASTEST: fastest method (normally JDCT_IFAST) - The FLOAT method is very slightly more accurate than the ISLOW method, - but may give different results on different machines due to varying - roundoff behavior. The integer methods should give the same results - on all machines. On machines with sufficiently fast FP hardware, the - floating-point method may also be the fastest. The IFAST method is - considerably less accurate than the other two; its use is not - recommended if high quality is a concern. JDCT_DEFAULT and - JDCT_FASTEST are macros configurable by each installation. - -J_COLOR_SPACE jpeg_color_space -int num_components - The JPEG color space and corresponding number of components; see - "Special color spaces", below, for more info. We recommend using - jpeg_set_color_space() if you want to change these. - -boolean optimize_coding - TRUE causes the compressor to compute optimal Huffman coding tables - for the image. This requires an extra pass over the data and - therefore costs a good deal of space and time. The default is - FALSE, which tells the compressor to use the supplied or default - Huffman tables. In most cases optimal tables save only a few percent - of file size compared to the default tables. Note that when this is - TRUE, you need not supply Huffman tables at all, and any you do - supply will be overwritten. - -unsigned int restart_interval -int restart_in_rows - To emit restart markers in the JPEG file, set one of these nonzero. - Set restart_interval to specify the exact interval in MCU blocks. - Set restart_in_rows to specify the interval in MCU rows. (If - restart_in_rows is not 0, then restart_interval is set after the - image width in MCUs is computed.) Defaults are zero (no restarts). - One restart marker per MCU row is often a good choice. - NOTE: the overhead of restart markers is higher in grayscale JPEG - files than in color files, and MUCH higher in progressive JPEGs. - If you use restarts, you may want to use larger intervals in those - cases. - -const jpeg_scan_info * scan_info -int num_scans - By default, scan_info is NULL; this causes the compressor to write a - single-scan sequential JPEG file. If not NULL, scan_info points to - an array of scan definition records of length num_scans. The - compressor will then write a JPEG file having one scan for each scan - definition record. This is used to generate noninterleaved or - progressive JPEG files. The library checks that the scan array - defines a valid JPEG scan sequence. (jpeg_simple_progression creates - a suitable scan definition array for progressive JPEG.) This is - discussed further under "Progressive JPEG support". - -int smoothing_factor - If non-zero, the input image is smoothed; the value should be 1 for - minimal smoothing to 100 for maximum smoothing. Consult jcsample.c - for details of the smoothing algorithm. The default is zero. - -boolean write_JFIF_header - If TRUE, a JFIF APP0 marker is emitted. jpeg_set_defaults() and - jpeg_set_colorspace() set this TRUE if a JFIF-legal JPEG color space - (ie, YCbCr or grayscale) is selected, otherwise FALSE. - -UINT8 JFIF_major_version -UINT8 JFIF_minor_version - The version number to be written into the JFIF marker. - jpeg_set_defaults() initializes the version to 1.01 (major=minor=1). - You should set it to 1.02 (major=1, minor=2) if you plan to write - any JFIF 1.02 extension markers. - -UINT8 density_unit -UINT16 X_density -UINT16 Y_density - The resolution information to be written into the JFIF marker; - not used otherwise. density_unit may be 0 for unknown, - 1 for dots/inch, or 2 for dots/cm. The default values are 0,1,1 - indicating square pixels of unknown size. - -boolean write_Adobe_marker - If TRUE, an Adobe APP14 marker is emitted. jpeg_set_defaults() and - jpeg_set_colorspace() set this TRUE if JPEG color space RGB, CMYK, - or YCCK is selected, otherwise FALSE. It is generally a bad idea - to set both write_JFIF_header and write_Adobe_marker. In fact, - you probably shouldn't change the default settings at all --- the - default behavior ensures that the JPEG file's color space can be - recognized by the decoder. - -JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS] - Pointers to coefficient quantization tables, one per table slot, - or NULL if no table is defined for a slot. Usually these should - be set via one of the above helper routines; jpeg_add_quant_table() - is general enough to define any quantization table. The other - routines will set up table slot 0 for luminance quality and table - slot 1 for chrominance. - -JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS] -JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS] - Pointers to Huffman coding tables, one per table slot, or NULL if - no table is defined for a slot. Slots 0 and 1 are filled with the - JPEG sample tables by jpeg_set_defaults(). If you need to allocate - more table structures, jpeg_alloc_huff_table() may be used. - Note that optimal Huffman tables can be computed for an image - by setting optimize_coding, as discussed above; there's seldom - any need to mess with providing your own Huffman tables. - -There are some additional cinfo fields which are not documented here -because you currently can't change them; for example, you can't set -arith_code TRUE because arithmetic coding is unsupported. - - -Per-component parameters are stored in the struct cinfo.comp_info[i] for -component number i. Note that components here refer to components of the -JPEG color space, *not* the source image color space. A suitably large -comp_info[] array is allocated by jpeg_set_defaults(); if you choose not -to use that routine, it's up to you to allocate the array. - -int component_id - The one-byte identifier code to be recorded in the JPEG file for - this component. For the standard color spaces, we recommend you - leave the default values alone. - -int h_samp_factor -int v_samp_factor - Horizontal and vertical sampling factors for the component; must - be 1..4 according to the JPEG standard. Note that larger sampling - factors indicate a higher-resolution component; many people find - this behavior quite unintuitive. The default values are 2,2 for - luminance components and 1,1 for chrominance components, except - for grayscale where 1,1 is used. - -int quant_tbl_no - Quantization table number for component. The default value is - 0 for luminance components and 1 for chrominance components. - -int dc_tbl_no -int ac_tbl_no - DC and AC entropy coding table numbers. The default values are - 0 for luminance components and 1 for chrominance components. - -int component_index - Must equal the component's index in comp_info[]. (Beginning in - release v6, the compressor library will fill this in automatically; - you don't have to.) - - -Decompression parameter selection ---------------------------------- - -Decompression parameter selection is somewhat simpler than compression -parameter selection, since all of the JPEG internal parameters are -recorded in the source file and need not be supplied by the application. -(Unless you are working with abbreviated files, in which case see -"Abbreviated datastreams", below.) Decompression parameters control -the postprocessing done on the image to deliver it in a format suitable -for the application's use. Many of the parameters control speed/quality -tradeoffs, in which faster decompression may be obtained at the price of -a poorer-quality image. The defaults select the highest quality (slowest) -processing. - -The following fields in the JPEG object are set by jpeg_read_header() and -may be useful to the application in choosing decompression parameters: - -JDIMENSION image_width Width and height of image -JDIMENSION image_height -int num_components Number of color components -J_COLOR_SPACE jpeg_color_space Colorspace of image -boolean saw_JFIF_marker TRUE if a JFIF APP0 marker was seen - UINT8 JFIF_major_version Version information from JFIF marker - UINT8 JFIF_minor_version - UINT8 density_unit Resolution data from JFIF marker - UINT16 X_density - UINT16 Y_density -boolean saw_Adobe_marker TRUE if an Adobe APP14 marker was seen - UINT8 Adobe_transform Color transform code from Adobe marker - -The JPEG color space, unfortunately, is something of a guess since the JPEG -standard proper does not provide a way to record it. In practice most files -adhere to the JFIF or Adobe conventions, and the decoder will recognize these -correctly. See "Special color spaces", below, for more info. - - -The decompression parameters that determine the basic properties of the -returned image are: - -J_COLOR_SPACE out_color_space - Output color space. jpeg_read_header() sets an appropriate default - based on jpeg_color_space; typically it will be RGB or grayscale. - The application can change this field to request output in a different - colorspace. For example, set it to JCS_GRAYSCALE to get grayscale - output from a color file. (This is useful for previewing: grayscale - output is faster than full color since the color components need not - be processed.) Note that not all possible color space transforms are - currently implemented; you may need to extend jdcolor.c if you want an - unusual conversion. - -unsigned int scale_num, scale_denom - Scale the image by the fraction scale_num/scale_denom. Default is - 1/1, or no scaling. Currently, the only supported scaling ratios - are 1/1, 1/2, 1/4, and 1/8. (The library design allows for arbitrary - scaling ratios but this is not likely to be implemented any time soon.) - Smaller scaling ratios permit significantly faster decoding since - fewer pixels need be processed and a simpler IDCT method can be used. - -boolean quantize_colors - If set TRUE, colormapped output will be delivered. Default is FALSE, - meaning that full-color output will be delivered. - -The next three parameters are relevant only if quantize_colors is TRUE. - -int desired_number_of_colors - Maximum number of colors to use in generating a library-supplied color - map (the actual number of colors is returned in a different field). - Default 256. Ignored when the application supplies its own color map. - -boolean two_pass_quantize - If TRUE, an extra pass over the image is made to select a custom color - map for the image. This usually looks a lot better than the one-size- - fits-all colormap that is used otherwise. Default is TRUE. Ignored - when the application supplies its own color map. - -J_DITHER_MODE dither_mode - Selects color dithering method. Supported values are: - JDITHER_NONE no dithering: fast, very low quality - JDITHER_ORDERED ordered dither: moderate speed and quality - JDITHER_FS Floyd-Steinberg dither: slow, high quality - Default is JDITHER_FS. (At present, ordered dither is implemented - only in the single-pass, standard-colormap case. If you ask for - ordered dither when two_pass_quantize is TRUE or when you supply - an external color map, you'll get F-S dithering.) - -When quantize_colors is TRUE, the target color map is described by the next -two fields. colormap is set to NULL by jpeg_read_header(). The application -can supply a color map by setting colormap non-NULL and setting -actual_number_of_colors to the map size. Otherwise, jpeg_start_decompress() -selects a suitable color map and sets these two fields itself. -[Implementation restriction: at present, an externally supplied colormap is -only accepted for 3-component output color spaces.] - -JSAMPARRAY colormap - The color map, represented as a 2-D pixel array of out_color_components - rows and actual_number_of_colors columns. Ignored if not quantizing. - CAUTION: if the JPEG library creates its own colormap, the storage - pointed to by this field is released by jpeg_finish_decompress(). - Copy the colormap somewhere else first, if you want to save it. - -int actual_number_of_colors - The number of colors in the color map. - -Additional decompression parameters that the application may set include: - -J_DCT_METHOD dct_method - Selects the algorithm used for the DCT step. Choices are the same - as described above for compression. - -boolean do_fancy_upsampling - If TRUE, do careful upsampling of chroma components. If FALSE, - a faster but sloppier method is used. Default is TRUE. The visual - impact of the sloppier method is often very small. - -boolean do_block_smoothing - If TRUE, interblock smoothing is applied in early stages of decoding - progressive JPEG files; if FALSE, not. Default is TRUE. Early - progression stages look "fuzzy" with smoothing, "blocky" without. - In any case, block smoothing ceases to be applied after the first few - AC coefficients are known to full accuracy, so it is relevant only - when using buffered-image mode for progressive images. - -boolean enable_1pass_quant -boolean enable_external_quant -boolean enable_2pass_quant - These are significant only in buffered-image mode, which is - described in its own section below. - - -The output image dimensions are given by the following fields. These are -computed from the source image dimensions and the decompression parameters -by jpeg_start_decompress(). You can also call jpeg_calc_output_dimensions() -to obtain the values that will result from the current parameter settings. -This can be useful if you are trying to pick a scaling ratio that will get -close to a desired target size. It's also important if you are using the -JPEG library's memory manager to allocate output buffer space, because you -are supposed to request such buffers *before* jpeg_start_decompress(). - -JDIMENSION output_width Actual dimensions of output image. -JDIMENSION output_height -int out_color_components Number of color components in out_color_space. -int output_components Number of color components returned. -int rec_outbuf_height Recommended height of scanline buffer. - -When quantizing colors, output_components is 1, indicating a single color map -index per pixel. Otherwise it equals out_color_components. The output arrays -are required to be output_width * output_components JSAMPLEs wide. - -rec_outbuf_height is the recommended minimum height (in scanlines) of the -buffer passed to jpeg_read_scanlines(). If the buffer is smaller, the -library will still work, but time will be wasted due to unnecessary data -copying. In high-quality modes, rec_outbuf_height is always 1, but some -faster, lower-quality modes set it to larger values (typically 2 to 4). -If you are going to ask for a high-speed processing mode, you may as well -go to the trouble of honoring rec_outbuf_height so as to avoid data copying. -(An output buffer larger than rec_outbuf_height lines is OK, but won't -provide any material speed improvement over that height.) - - -Special color spaces --------------------- - -The JPEG standard itself is "color blind" and doesn't specify any particular -color space. It is customary to convert color data to a luminance/chrominance -color space before compressing, since this permits greater compression. The -existing de-facto JPEG file format standards specify YCbCr or grayscale data -(JFIF), or grayscale, RGB, YCbCr, CMYK, or YCCK (Adobe). For special -applications such as multispectral images, other color spaces can be used, -but it must be understood that such files will be unportable. - -The JPEG library can handle the most common colorspace conversions (namely -RGB <=> YCbCr and CMYK <=> YCCK). It can also deal with data of an unknown -color space, passing it through without conversion. If you deal extensively -with an unusual color space, you can easily extend the library to understand -additional color spaces and perform appropriate conversions. - -For compression, the source data's color space is specified by field -in_color_space. This is transformed to the JPEG file's color space given -by jpeg_color_space. jpeg_set_defaults() chooses a reasonable JPEG color -space depending on in_color_space, but you can override this by calling -jpeg_set_colorspace(). Of course you must select a supported transformation. -jccolor.c currently supports the following transformations: - RGB => YCbCr - RGB => GRAYSCALE - YCbCr => GRAYSCALE - CMYK => YCCK -plus the null transforms: GRAYSCALE => GRAYSCALE, RGB => RGB, -YCbCr => YCbCr, CMYK => CMYK, YCCK => YCCK, and UNKNOWN => UNKNOWN. - -The de-facto file format standards (JFIF and Adobe) specify APPn markers that -indicate the color space of the JPEG file. It is important to ensure that -these are written correctly, or omitted if the JPEG file's color space is not -one of the ones supported by the de-facto standards. jpeg_set_colorspace() -will set the compression parameters to include or omit the APPn markers -properly, so long as it is told the truth about the JPEG color space. -For example, if you are writing some random 3-component color space without -conversion, don't try to fake out the library by setting in_color_space and -jpeg_color_space to JCS_YCbCr; use JCS_UNKNOWN. You may want to write an -APPn marker of your own devising to identify the colorspace --- see "Special -markers", below. - -When told that the color space is UNKNOWN, the library will default to using -luminance-quality compression parameters for all color components. You may -well want to change these parameters. See the source code for -jpeg_set_colorspace(), in jcparam.c, for details. - -For decompression, the JPEG file's color space is given in jpeg_color_space, -and this is transformed to the output color space out_color_space. -jpeg_read_header's setting of jpeg_color_space can be relied on if the file -conforms to JFIF or Adobe conventions, but otherwise it is no better than a -guess. If you know the JPEG file's color space for certain, you can override -jpeg_read_header's guess by setting jpeg_color_space. jpeg_read_header also -selects a default output color space based on (its guess of) jpeg_color_space; -set out_color_space to override this. Again, you must select a supported -transformation. jdcolor.c currently supports - YCbCr => GRAYSCALE - YCbCr => RGB - GRAYSCALE => RGB - YCCK => CMYK -as well as the null transforms. (Since GRAYSCALE=>RGB is provided, an -application can force grayscale JPEGs to look like color JPEGs if it only -wants to handle one case.) - -The two-pass color quantizer, jquant2.c, is specialized to handle RGB data -(it weights distances appropriately for RGB colors). You'll need to modify -the code if you want to use it for non-RGB output color spaces. Note that -jquant2.c is used to map to an application-supplied colormap as well as for -the normal two-pass colormap selection process. - -CAUTION: it appears that Adobe Photoshop writes inverted data in CMYK JPEG -files: 0 represents 100% ink coverage, rather than 0% ink as you'd expect. -This is arguably a bug in Photoshop, but if you need to work with Photoshop -CMYK files, you will have to deal with it in your application. We cannot -"fix" this in the library by inverting the data during the CMYK<=>YCCK -transform, because that would break other applications, notably Ghostscript. -Photoshop versions prior to 3.0 write EPS files containing JPEG-encoded CMYK -data in the same inverted-YCCK representation used in bare JPEG files, but -the surrounding PostScript code performs an inversion using the PS image -operator. I am told that Photoshop 3.0 will write uninverted YCCK in -EPS/JPEG files, and will omit the PS-level inversion. (But the data -polarity used in bare JPEG files will not change in 3.0.) In either case, -the JPEG library must not invert the data itself, or else Ghostscript would -read these EPS files incorrectly. - - -Error handling --------------- - -When the default error handler is used, any error detected inside the JPEG -routines will cause a message to be printed on stderr, followed by exit(). -You can supply your own error handling routines to override this behavior -and to control the treatment of nonfatal warnings and trace/debug messages. -The file example.c illustrates the most common case, which is to have the -application regain control after an error rather than exiting. - -The JPEG library never writes any message directly; it always goes through -the error handling routines. Three classes of messages are recognized: - * Fatal errors: the library cannot continue. - * Warnings: the library can continue, but the data is corrupt, and a - damaged output image is likely to result. - * Trace/informational messages. These come with a trace level indicating - the importance of the message; you can control the verbosity of the - program by adjusting the maximum trace level that will be displayed. - -You may, if you wish, simply replace the entire JPEG error handling module -(jerror.c) with your own code. However, you can avoid code duplication by -only replacing some of the routines depending on the behavior you need. -This is accomplished by calling jpeg_std_error() as usual, but then overriding -some of the method pointers in the jpeg_error_mgr struct, as illustrated by -example.c. - -All of the error handling routines will receive a pointer to the JPEG object -(a j_common_ptr which points to either a jpeg_compress_struct or a -jpeg_decompress_struct; if you need to tell which, test the is_decompressor -field). This struct includes a pointer to the error manager struct in its -"err" field. Frequently, custom error handler routines will need to access -additional data which is not known to the JPEG library or the standard error -handler. The most convenient way to do this is to embed either the JPEG -object or the jpeg_error_mgr struct in a larger structure that contains -additional fields; then casting the passed pointer provides access to the -additional fields. Again, see example.c for one way to do it. (Beginning -with IJG version 6b, there is also a void pointer "client_data" in each -JPEG object, which the application can also use to find related data. -The library does not touch client_data at all.) - -The individual methods that you might wish to override are: - -error_exit (j_common_ptr cinfo) - Receives control for a fatal error. Information sufficient to - generate the error message has been stored in cinfo->err; call - output_message to display it. Control must NOT return to the caller; - generally this routine will exit() or longjmp() somewhere. - Typically you would override this routine to get rid of the exit() - default behavior. Note that if you continue processing, you should - clean up the JPEG object with jpeg_abort() or jpeg_destroy(). - -output_message (j_common_ptr cinfo) - Actual output of any JPEG message. Override this to send messages - somewhere other than stderr. Note that this method does not know - how to generate a message, only where to send it. - -format_message (j_common_ptr cinfo, char * buffer) - Constructs a readable error message string based on the error info - stored in cinfo->err. This method is called by output_message. Few - applications should need to override this method. One possible - reason for doing so is to implement dynamic switching of error message - language. - -emit_message (j_common_ptr cinfo, int msg_level) - Decide whether or not to emit a warning or trace message; if so, - calls output_message. The main reason for overriding this method - would be to abort on warnings. msg_level is -1 for warnings, - 0 and up for trace messages. - -Only error_exit() and emit_message() are called from the rest of the JPEG -library; the other two are internal to the error handler. - -The actual message texts are stored in an array of strings which is pointed to -by the field err->jpeg_message_table. The messages are numbered from 0 to -err->last_jpeg_message, and it is these code numbers that are used in the -JPEG library code. You could replace the message texts (for instance, with -messages in French or German) by changing the message table pointer. See -jerror.h for the default texts. CAUTION: this table will almost certainly -change or grow from one library version to the next. - -It may be useful for an application to add its own message texts that are -handled by the same mechanism. The error handler supports a second "add-on" -message table for this purpose. To define an addon table, set the pointer -err->addon_message_table and the message numbers err->first_addon_message and -err->last_addon_message. If you number the addon messages beginning at 1000 -or so, you won't have to worry about conflicts with the library's built-in -messages. See the sample applications cjpeg/djpeg for an example of using -addon messages (the addon messages are defined in cderror.h). - -Actual invocation of the error handler is done via macros defined in jerror.h: - ERREXITn(...) for fatal errors - WARNMSn(...) for corrupt-data warnings - TRACEMSn(...) for trace and informational messages. -These macros store the message code and any additional parameters into the -error handler struct, then invoke the error_exit() or emit_message() method. -The variants of each macro are for varying numbers of additional parameters. -The additional parameters are inserted into the generated message using -standard printf() format codes. - -See jerror.h and jerror.c for further details. - - -Compressed data handling (source and destination managers) ----------------------------------------------------------- - -The JPEG compression library sends its compressed data to a "destination -manager" module. The default destination manager just writes the data to a -stdio stream, but you can provide your own manager to do something else. -Similarly, the decompression library calls a "source manager" to obtain the -compressed data; you can provide your own source manager if you want the data -to come from somewhere other than a stdio stream. - -In both cases, compressed data is processed a bufferload at a time: the -destination or source manager provides a work buffer, and the library invokes -the manager only when the buffer is filled or emptied. (You could define a -one-character buffer to force the manager to be invoked for each byte, but -that would be rather inefficient.) The buffer's size and location are -controlled by the manager, not by the library. For example, if you desired to -decompress a JPEG datastream that was all in memory, you could just make the -buffer pointer and length point to the original data in memory. Then the -buffer-reload procedure would be invoked only if the decompressor ran off the -end of the datastream, which would indicate an erroneous datastream. - -The work buffer is defined as an array of datatype JOCTET, which is generally -"char" or "unsigned char". On a machine where char is not exactly 8 bits -wide, you must define JOCTET as a wider data type and then modify the data -source and destination modules to transcribe the work arrays into 8-bit units -on external storage. - -A data destination manager struct contains a pointer and count defining the -next byte to write in the work buffer and the remaining free space: - - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - -The library increments the pointer and decrements the count until the buffer -is filled. The manager's empty_output_buffer method must reset the pointer -and count. The manager is expected to remember the buffer's starting address -and total size in private fields not visible to the library. - -A data destination manager provides three methods: - -init_destination (j_compress_ptr cinfo) - Initialize destination. This is called by jpeg_start_compress() - before any data is actually written. It must initialize - next_output_byte and free_in_buffer. free_in_buffer must be - initialized to a positive value. - -empty_output_buffer (j_compress_ptr cinfo) - This is called whenever the buffer has filled (free_in_buffer - reaches zero). In typical applications, it should write out the - *entire* buffer (use the saved start address and buffer length; - ignore the current state of next_output_byte and free_in_buffer). - Then reset the pointer & count to the start of the buffer, and - return TRUE indicating that the buffer has been dumped. - free_in_buffer must be set to a positive value when TRUE is - returned. A FALSE return should only be used when I/O suspension is - desired (this operating mode is discussed in the next section). - -term_destination (j_compress_ptr cinfo) - Terminate destination --- called by jpeg_finish_compress() after all - data has been written. In most applications, this must flush any - data remaining in the buffer. Use either next_output_byte or - free_in_buffer to determine how much data is in the buffer. - -term_destination() is NOT called by jpeg_abort() or jpeg_destroy(). If you -want the destination manager to be cleaned up during an abort, you must do it -yourself. - -You will also need code to create a jpeg_destination_mgr struct, fill in its -method pointers, and insert a pointer to the struct into the "dest" field of -the JPEG compression object. This can be done in-line in your setup code if -you like, but it's probably cleaner to provide a separate routine similar to -the jpeg_stdio_dest() routine of the supplied destination manager. - -Decompression source managers follow a parallel design, but with some -additional frammishes. The source manager struct contains a pointer and count -defining the next byte to read from the work buffer and the number of bytes -remaining: - - const JOCTET * next_input_byte; /* => next byte to read from buffer */ - size_t bytes_in_buffer; /* # of bytes remaining in buffer */ - -The library increments the pointer and decrements the count until the buffer -is emptied. The manager's fill_input_buffer method must reset the pointer and -count. In most applications, the manager must remember the buffer's starting -address and total size in private fields not visible to the library. - -A data source manager provides five methods: - -init_source (j_decompress_ptr cinfo) - Initialize source. This is called by jpeg_read_header() before any - data is actually read. Unlike init_destination(), it may leave - bytes_in_buffer set to 0 (in which case a fill_input_buffer() call - will occur immediately). - -fill_input_buffer (j_decompress_ptr cinfo) - This is called whenever bytes_in_buffer has reached zero and more - data is wanted. In typical applications, it should read fresh data - into the buffer (ignoring the current state of next_input_byte and - bytes_in_buffer), reset the pointer & count to the start of the - buffer, and return TRUE indicating that the buffer has been reloaded. - It is not necessary to fill the buffer entirely, only to obtain at - least one more byte. bytes_in_buffer MUST be set to a positive value - if TRUE is returned. A FALSE return should only be used when I/O - suspension is desired (this mode is discussed in the next section). - -skip_input_data (j_decompress_ptr cinfo, long num_bytes) - Skip num_bytes worth of data. The buffer pointer and count should - be advanced over num_bytes input bytes, refilling the buffer as - needed. This is used to skip over a potentially large amount of - uninteresting data (such as an APPn marker). In some applications - it may be possible to optimize away the reading of the skipped data, - but it's not clear that being smart is worth much trouble; large - skips are uncommon. bytes_in_buffer may be zero on return. - A zero or negative skip count should be treated as a no-op. - -resync_to_restart (j_decompress_ptr cinfo, int desired) - This routine is called only when the decompressor has failed to find - a restart (RSTn) marker where one is expected. Its mission is to - find a suitable point for resuming decompression. For most - applications, we recommend that you just use the default resync - procedure, jpeg_resync_to_restart(). However, if you are able to back - up in the input data stream, or if you have a-priori knowledge about - the likely location of restart markers, you may be able to do better. - Read the read_restart_marker() and jpeg_resync_to_restart() routines - in jdmarker.c if you think you'd like to implement your own resync - procedure. - -term_source (j_decompress_ptr cinfo) - Terminate source --- called by jpeg_finish_decompress() after all - data has been read. Often a no-op. - -For both fill_input_buffer() and skip_input_data(), there is no such thing -as an EOF return. If the end of the file has been reached, the routine has -a choice of exiting via ERREXIT() or inserting fake data into the buffer. -In most cases, generating a warning message and inserting a fake EOI marker -is the best course of action --- this will allow the decompressor to output -however much of the image is there. In pathological cases, the decompressor -may swallow the EOI and again demand data ... just keep feeding it fake EOIs. -jdatasrc.c illustrates the recommended error recovery behavior. - -term_source() is NOT called by jpeg_abort() or jpeg_destroy(). If you want -the source manager to be cleaned up during an abort, you must do it yourself. - -You will also need code to create a jpeg_source_mgr struct, fill in its method -pointers, and insert a pointer to the struct into the "src" field of the JPEG -decompression object. This can be done in-line in your setup code if you -like, but it's probably cleaner to provide a separate routine similar to the -jpeg_stdio_src() routine of the supplied source manager. - -For more information, consult the stdio source and destination managers -in jdatasrc.c and jdatadst.c. - - -I/O suspension --------------- - -Some applications need to use the JPEG library as an incremental memory-to- -memory filter: when the compressed data buffer is filled or emptied, they want -control to return to the outer loop, rather than expecting that the buffer can -be emptied or reloaded within the data source/destination manager subroutine. -The library supports this need by providing an "I/O suspension" mode, which we -describe in this section. - -The I/O suspension mode is not a panacea: nothing is guaranteed about the -maximum amount of time spent in any one call to the library, so it will not -eliminate response-time problems in single-threaded applications. If you -need guaranteed response time, we suggest you "bite the bullet" and implement -a real multi-tasking capability. - -To use I/O suspension, cooperation is needed between the calling application -and the data source or destination manager; you will always need a custom -source/destination manager. (Please read the previous section if you haven't -already.) The basic idea is that the empty_output_buffer() or -fill_input_buffer() routine is a no-op, merely returning FALSE to indicate -that it has done nothing. Upon seeing this, the JPEG library suspends -operation and returns to its caller. The surrounding application is -responsible for emptying or refilling the work buffer before calling the -JPEG library again. - -Compression suspension: - -For compression suspension, use an empty_output_buffer() routine that returns -FALSE; typically it will not do anything else. This will cause the -compressor to return to the caller of jpeg_write_scanlines(), with the return -value indicating that not all the supplied scanlines have been accepted. -The application must make more room in the output buffer, adjust the output -buffer pointer/count appropriately, and then call jpeg_write_scanlines() -again, pointing to the first unconsumed scanline. - -When forced to suspend, the compressor will backtrack to a convenient stopping -point (usually the start of the current MCU); it will regenerate some output -data when restarted. Therefore, although empty_output_buffer() is only -called when the buffer is filled, you should NOT write out the entire buffer -after a suspension. Write only the data up to the current position of -next_output_byte/free_in_buffer. The data beyond that point will be -regenerated after resumption. - -Because of the backtracking behavior, a good-size output buffer is essential -for efficiency; you don't want the compressor to suspend often. (In fact, an -overly small buffer could lead to infinite looping, if a single MCU required -more data than would fit in the buffer.) We recommend a buffer of at least -several Kbytes. You may want to insert explicit code to ensure that you don't -call jpeg_write_scanlines() unless there is a reasonable amount of space in -the output buffer; in other words, flush the buffer before trying to compress -more data. - -The compressor does not allow suspension while it is trying to write JPEG -markers at the beginning and end of the file. This means that: - * At the beginning of a compression operation, there must be enough free - space in the output buffer to hold the header markers (typically 600 or - so bytes). The recommended buffer size is bigger than this anyway, so - this is not a problem as long as you start with an empty buffer. However, - this restriction might catch you if you insert large special markers, such - as a JFIF thumbnail image, without flushing the buffer afterwards. - * When you call jpeg_finish_compress(), there must be enough space in the - output buffer to emit any buffered data and the final EOI marker. In the - current implementation, half a dozen bytes should suffice for this, but - for safety's sake we recommend ensuring that at least 100 bytes are free - before calling jpeg_finish_compress(). - -A more significant restriction is that jpeg_finish_compress() cannot suspend. -This means you cannot use suspension with multi-pass operating modes, namely -Huffman code optimization and multiple-scan output. Those modes write the -whole file during jpeg_finish_compress(), which will certainly result in -buffer overrun. (Note that this restriction applies only to compression, -not decompression. The decompressor supports input suspension in all of its -operating modes.) - -Decompression suspension: - -For decompression suspension, use a fill_input_buffer() routine that simply -returns FALSE (except perhaps during error recovery, as discussed below). -This will cause the decompressor to return to its caller with an indication -that suspension has occurred. This can happen at four places: - * jpeg_read_header(): will return JPEG_SUSPENDED. - * jpeg_start_decompress(): will return FALSE, rather than its usual TRUE. - * jpeg_read_scanlines(): will return the number of scanlines already - completed (possibly 0). - * jpeg_finish_decompress(): will return FALSE, rather than its usual TRUE. -The surrounding application must recognize these cases, load more data into -the input buffer, and repeat the call. In the case of jpeg_read_scanlines(), -increment the passed pointers past any scanlines successfully read. - -Just as with compression, the decompressor will typically backtrack to a -convenient restart point before suspending. When fill_input_buffer() is -called, next_input_byte/bytes_in_buffer point to the current restart point, -which is where the decompressor will backtrack to if FALSE is returned. -The data beyond that position must NOT be discarded if you suspend; it needs -to be re-read upon resumption. In most implementations, you'll need to shift -this data down to the start of your work buffer and then load more data after -it. Again, this behavior means that a several-Kbyte work buffer is essential -for decent performance; furthermore, you should load a reasonable amount of -new data before resuming decompression. (If you loaded, say, only one new -byte each time around, you could waste a LOT of cycles.) - -The skip_input_data() source manager routine requires special care in a -suspension scenario. This routine is NOT granted the ability to suspend the -decompressor; it can decrement bytes_in_buffer to zero, but no more. If the -requested skip distance exceeds the amount of data currently in the input -buffer, then skip_input_data() must set bytes_in_buffer to zero and record the -additional skip distance somewhere else. The decompressor will immediately -call fill_input_buffer(), which should return FALSE, which will cause a -suspension return. The surrounding application must then arrange to discard -the recorded number of bytes before it resumes loading the input buffer. -(Yes, this design is rather baroque, but it avoids complexity in the far more -common case where a non-suspending source manager is used.) - -If the input data has been exhausted, we recommend that you emit a warning -and insert dummy EOI markers just as a non-suspending data source manager -would do. This can be handled either in the surrounding application logic or -within fill_input_buffer(); the latter is probably more efficient. If -fill_input_buffer() knows that no more data is available, it can set the -pointer/count to point to a dummy EOI marker and then return TRUE just as -though it had read more data in a non-suspending situation. - -The decompressor does not attempt to suspend within standard JPEG markers; -instead it will backtrack to the start of the marker and reprocess the whole -marker next time. Hence the input buffer must be large enough to hold the -longest standard marker in the file. Standard JPEG markers should normally -not exceed a few hundred bytes each (DHT tables are typically the longest). -We recommend at least a 2K buffer for performance reasons, which is much -larger than any correct marker is likely to be. For robustness against -damaged marker length counts, you may wish to insert a test in your -application for the case that the input buffer is completely full and yet -the decoder has suspended without consuming any data --- otherwise, if this -situation did occur, it would lead to an endless loop. (The library can't -provide this test since it has no idea whether "the buffer is full", or -even whether there is a fixed-size input buffer.) - -The input buffer would need to be 64K to allow for arbitrary COM or APPn -markers, but these are handled specially: they are either saved into allocated -memory, or skipped over by calling skip_input_data(). In the former case, -suspension is handled correctly, and in the latter case, the problem of -buffer overrun is placed on skip_input_data's shoulders, as explained above. -Note that if you provide your own marker handling routine for large markers, -you should consider how to deal with buffer overflow. - -Multiple-buffer management: - -In some applications it is desirable to store the compressed data in a linked -list of buffer areas, so as to avoid data copying. This can be handled by -having empty_output_buffer() or fill_input_buffer() set the pointer and count -to reference the next available buffer; FALSE is returned only if no more -buffers are available. Although seemingly straightforward, there is a -pitfall in this approach: the backtrack that occurs when FALSE is returned -could back up into an earlier buffer. For example, when fill_input_buffer() -is called, the current pointer & count indicate the backtrack restart point. -Since fill_input_buffer() will set the pointer and count to refer to a new -buffer, the restart position must be saved somewhere else. Suppose a second -call to fill_input_buffer() occurs in the same library call, and no -additional input data is available, so fill_input_buffer must return FALSE. -If the JPEG library has not moved the pointer/count forward in the current -buffer, then *the correct restart point is the saved position in the prior -buffer*. Prior buffers may be discarded only after the library establishes -a restart point within a later buffer. Similar remarks apply for output into -a chain of buffers. - -The library will never attempt to backtrack over a skip_input_data() call, -so any skipped data can be permanently discarded. You still have to deal -with the case of skipping not-yet-received data, however. - -It's much simpler to use only a single buffer; when fill_input_buffer() is -called, move any unconsumed data (beyond the current pointer/count) down to -the beginning of this buffer and then load new data into the remaining buffer -space. This approach requires a little more data copying but is far easier -to get right. - - -Progressive JPEG support ------------------------- - -Progressive JPEG rearranges the stored data into a series of scans of -increasing quality. In situations where a JPEG file is transmitted across a -slow communications link, a decoder can generate a low-quality image very -quickly from the first scan, then gradually improve the displayed quality as -more scans are received. The final image after all scans are complete is -identical to that of a regular (sequential) JPEG file of the same quality -setting. Progressive JPEG files are often slightly smaller than equivalent -sequential JPEG files, but the possibility of incremental display is the main -reason for using progressive JPEG. - -The IJG encoder library generates progressive JPEG files when given a -suitable "scan script" defining how to divide the data into scans. -Creation of progressive JPEG files is otherwise transparent to the encoder. -Progressive JPEG files can also be read transparently by the decoder library. -If the decoding application simply uses the library as defined above, it -will receive a final decoded image without any indication that the file was -progressive. Of course, this approach does not allow incremental display. -To perform incremental display, an application needs to use the decoder -library's "buffered-image" mode, in which it receives a decoded image -multiple times. - -Each displayed scan requires about as much work to decode as a full JPEG -image of the same size, so the decoder must be fairly fast in relation to the -data transmission rate in order to make incremental display useful. However, -it is possible to skip displaying the image and simply add the incoming bits -to the decoder's coefficient buffer. This is fast because only Huffman -decoding need be done, not IDCT, upsampling, colorspace conversion, etc. -The IJG decoder library allows the application to switch dynamically between -displaying the image and simply absorbing the incoming bits. A properly -coded application can automatically adapt the number of display passes to -suit the time available as the image is received. Also, a final -higher-quality display cycle can be performed from the buffered data after -the end of the file is reached. - -Progressive compression: - -To create a progressive JPEG file (or a multiple-scan sequential JPEG file), -set the scan_info cinfo field to point to an array of scan descriptors, and -perform compression as usual. Instead of constructing your own scan list, -you can call the jpeg_simple_progression() helper routine to create a -recommended progression sequence; this method should be used by all -applications that don't want to get involved in the nitty-gritty of -progressive scan sequence design. (If you want to provide user control of -scan sequences, you may wish to borrow the scan script reading code found -in rdswitch.c, so that you can read scan script files just like cjpeg's.) -When scan_info is not NULL, the compression library will store DCT'd data -into a buffer array as jpeg_write_scanlines() is called, and will emit all -the requested scans during jpeg_finish_compress(). This implies that -multiple-scan output cannot be created with a suspending data destination -manager, since jpeg_finish_compress() does not support suspension. We -should also note that the compressor currently forces Huffman optimization -mode when creating a progressive JPEG file, because the default Huffman -tables are unsuitable for progressive files. - -Progressive decompression: - -When buffered-image mode is not used, the decoder library will read all of -a multi-scan file during jpeg_start_decompress(), so that it can provide a -final decoded image. (Here "multi-scan" means either progressive or -multi-scan sequential.) This makes multi-scan files transparent to the -decoding application. However, existing applications that used suspending -input with version 5 of the IJG library will need to be modified to check -for a suspension return from jpeg_start_decompress(). - -To perform incremental display, an application must use the library's -buffered-image mode. This is described in the next section. - - -Buffered-image mode -------------------- - -In buffered-image mode, the library stores the partially decoded image in a -coefficient buffer, from which it can be read out as many times as desired. -This mode is typically used for incremental display of progressive JPEG files, -but it can be used with any JPEG file. Each scan of a progressive JPEG file -adds more data (more detail) to the buffered image. The application can -display in lockstep with the source file (one display pass per input scan), -or it can allow input processing to outrun display processing. By making -input and display processing run independently, it is possible for the -application to adapt progressive display to a wide range of data transmission -rates. - -The basic control flow for buffered-image decoding is - - jpeg_create_decompress() - set data source - jpeg_read_header() - set overall decompression parameters - cinfo.buffered_image = TRUE; /* select buffered-image mode */ - jpeg_start_decompress() - for (each output pass) { - adjust output decompression parameters if required - jpeg_start_output() /* start a new output pass */ - for (all scanlines in image) { - jpeg_read_scanlines() - display scanlines - } - jpeg_finish_output() /* terminate output pass */ - } - jpeg_finish_decompress() - jpeg_destroy_decompress() - -This differs from ordinary unbuffered decoding in that there is an additional -level of looping. The application can choose how many output passes to make -and how to display each pass. - -The simplest approach to displaying progressive images is to do one display -pass for each scan appearing in the input file. In this case the outer loop -condition is typically - while (! jpeg_input_complete(&cinfo)) -and the start-output call should read - jpeg_start_output(&cinfo, cinfo.input_scan_number); -The second parameter to jpeg_start_output() indicates which scan of the input -file is to be displayed; the scans are numbered starting at 1 for this -purpose. (You can use a loop counter starting at 1 if you like, but using -the library's input scan counter is easier.) The library automatically reads -data as necessary to complete each requested scan, and jpeg_finish_output() -advances to the next scan or end-of-image marker (hence input_scan_number -will be incremented by the time control arrives back at jpeg_start_output()). -With this technique, data is read from the input file only as needed, and -input and output processing run in lockstep. - -After reading the final scan and reaching the end of the input file, the -buffered image remains available; it can be read additional times by -repeating the jpeg_start_output()/jpeg_read_scanlines()/jpeg_finish_output() -sequence. For example, a useful technique is to use fast one-pass color -quantization for display passes made while the image is arriving, followed by -a final display pass using two-pass quantization for highest quality. This -is done by changing the library parameters before the final output pass. -Changing parameters between passes is discussed in detail below. - -In general the last scan of a progressive file cannot be recognized as such -until after it is read, so a post-input display pass is the best approach if -you want special processing in the final pass. - -When done with the image, be sure to call jpeg_finish_decompress() to release -the buffered image (or just use jpeg_destroy_decompress()). - -If input data arrives faster than it can be displayed, the application can -cause the library to decode input data in advance of what's needed to produce -output. This is done by calling the routine jpeg_consume_input(). -The return value is one of the following: - JPEG_REACHED_SOS: reached an SOS marker (the start of a new scan) - JPEG_REACHED_EOI: reached the EOI marker (end of image) - JPEG_ROW_COMPLETED: completed reading one MCU row of compressed data - JPEG_SCAN_COMPLETED: completed reading last MCU row of current scan - JPEG_SUSPENDED: suspended before completing any of the above -(JPEG_SUSPENDED can occur only if a suspending data source is used.) This -routine can be called at any time after initializing the JPEG object. It -reads some additional data and returns when one of the indicated significant -events occurs. (If called after the EOI marker is reached, it will -immediately return JPEG_REACHED_EOI without attempting to read more data.) - -The library's output processing will automatically call jpeg_consume_input() -whenever the output processing overtakes the input; thus, simple lockstep -display requires no direct calls to jpeg_consume_input(). But by adding -calls to jpeg_consume_input(), you can absorb data in advance of what is -being displayed. This has two benefits: - * You can limit buildup of unprocessed data in your input buffer. - * You can eliminate extra display passes by paying attention to the - state of the library's input processing. - -The first of these benefits only requires interspersing calls to -jpeg_consume_input() with your display operations and any other processing -you may be doing. To avoid wasting cycles due to backtracking, it's best to -call jpeg_consume_input() only after a hundred or so new bytes have arrived. -This is discussed further under "I/O suspension", above. (Note: the JPEG -library currently is not thread-safe. You must not call jpeg_consume_input() -from one thread of control if a different library routine is working on the -same JPEG object in another thread.) - -When input arrives fast enough that more than one new scan is available -before you start a new output pass, you may as well skip the output pass -corresponding to the completed scan. This occurs for free if you pass -cinfo.input_scan_number as the target scan number to jpeg_start_output(). -The input_scan_number field is simply the index of the scan currently being -consumed by the input processor. You can ensure that this is up-to-date by -emptying the input buffer just before calling jpeg_start_output(): call -jpeg_consume_input() repeatedly until it returns JPEG_SUSPENDED or -JPEG_REACHED_EOI. - -The target scan number passed to jpeg_start_output() is saved in the -cinfo.output_scan_number field. The library's output processing calls -jpeg_consume_input() whenever the current input scan number and row within -that scan is less than or equal to the current output scan number and row. -Thus, input processing can "get ahead" of the output processing but is not -allowed to "fall behind". You can achieve several different effects by -manipulating this interlock rule. For example, if you pass a target scan -number greater than the current input scan number, the output processor will -wait until that scan starts to arrive before producing any output. (To avoid -an infinite loop, the target scan number is automatically reset to the last -scan number when the end of image is reached. Thus, if you specify a large -target scan number, the library will just absorb the entire input file and -then perform an output pass. This is effectively the same as what -jpeg_start_decompress() does when you don't select buffered-image mode.) -When you pass a target scan number equal to the current input scan number, -the image is displayed no faster than the current input scan arrives. The -final possibility is to pass a target scan number less than the current input -scan number; this disables the input/output interlock and causes the output -processor to simply display whatever it finds in the image buffer, without -waiting for input. (However, the library will not accept a target scan -number less than one, so you can't avoid waiting for the first scan.) - -When data is arriving faster than the output display processing can advance -through the image, jpeg_consume_input() will store data into the buffered -image beyond the point at which the output processing is reading data out -again. If the input arrives fast enough, it may "wrap around" the buffer to -the point where the input is more than one whole scan ahead of the output. -If the output processing simply proceeds through its display pass without -paying attention to the input, the effect seen on-screen is that the lower -part of the image is one or more scans better in quality than the upper part. -Then, when the next output scan is started, you have a choice of what target -scan number to use. The recommended choice is to use the current input scan -number at that time, which implies that you've skipped the output scans -corresponding to the input scans that were completed while you processed the -previous output scan. In this way, the decoder automatically adapts its -speed to the arriving data, by skipping output scans as necessary to keep up -with the arriving data. - -When using this strategy, you'll want to be sure that you perform a final -output pass after receiving all the data; otherwise your last display may not -be full quality across the whole screen. So the right outer loop logic is -something like this: - do { - absorb any waiting input by calling jpeg_consume_input() - final_pass = jpeg_input_complete(&cinfo); - adjust output decompression parameters if required - jpeg_start_output(&cinfo, cinfo.input_scan_number); - ... - jpeg_finish_output() - } while (! final_pass); -rather than quitting as soon as jpeg_input_complete() returns TRUE. This -arrangement makes it simple to use higher-quality decoding parameters -for the final pass. But if you don't want to use special parameters for -the final pass, the right loop logic is like this: - for (;;) { - absorb any waiting input by calling jpeg_consume_input() - jpeg_start_output(&cinfo, cinfo.input_scan_number); - ... - jpeg_finish_output() - if (jpeg_input_complete(&cinfo) && - cinfo.input_scan_number == cinfo.output_scan_number) - break; - } -In this case you don't need to know in advance whether an output pass is to -be the last one, so it's not necessary to have reached EOF before starting -the final output pass; rather, what you want to test is whether the output -pass was performed in sync with the final input scan. This form of the loop -will avoid an extra output pass whenever the decoder is able (or nearly able) -to keep up with the incoming data. - -When the data transmission speed is high, you might begin a display pass, -then find that much or all of the file has arrived before you can complete -the pass. (You can detect this by noting the JPEG_REACHED_EOI return code -from jpeg_consume_input(), or equivalently by testing jpeg_input_complete().) -In this situation you may wish to abort the current display pass and start a -new one using the newly arrived information. To do so, just call -jpeg_finish_output() and then start a new pass with jpeg_start_output(). - -A variant strategy is to abort and restart display if more than one complete -scan arrives during an output pass; this can be detected by noting -JPEG_REACHED_SOS returns and/or examining cinfo.input_scan_number. This -idea should be employed with caution, however, since the display process -might never get to the bottom of the image before being aborted, resulting -in the lower part of the screen being several passes worse than the upper. -In most cases it's probably best to abort an output pass only if the whole -file has arrived and you want to begin the final output pass immediately. - -When receiving data across a communication link, we recommend always using -the current input scan number for the output target scan number; if a -higher-quality final pass is to be done, it should be started (aborting any -incomplete output pass) as soon as the end of file is received. However, -many other strategies are possible. For example, the application can examine -the parameters of the current input scan and decide whether to display it or -not. If the scan contains only chroma data, one might choose not to use it -as the target scan, expecting that the scan will be small and will arrive -quickly. To skip to the next scan, call jpeg_consume_input() until it -returns JPEG_REACHED_SOS or JPEG_REACHED_EOI. Or just use the next higher -number as the target scan for jpeg_start_output(); but that method doesn't -let you inspect the next scan's parameters before deciding to display it. - - -In buffered-image mode, jpeg_start_decompress() never performs input and -thus never suspends. An application that uses input suspension with -buffered-image mode must be prepared for suspension returns from these -routines: -* jpeg_start_output() performs input only if you request 2-pass quantization - and the target scan isn't fully read yet. (This is discussed below.) -* jpeg_read_scanlines(), as always, returns the number of scanlines that it - was able to produce before suspending. -* jpeg_finish_output() will read any markers following the target scan, - up to the end of the file or the SOS marker that begins another scan. - (But it reads no input if jpeg_consume_input() has already reached the - end of the file or a SOS marker beyond the target output scan.) -* jpeg_finish_decompress() will read until the end of file, and thus can - suspend if the end hasn't already been reached (as can be tested by - calling jpeg_input_complete()). -jpeg_start_output(), jpeg_finish_output(), and jpeg_finish_decompress() -all return TRUE if they completed their tasks, FALSE if they had to suspend. -In the event of a FALSE return, the application must load more input data -and repeat the call. Applications that use non-suspending data sources need -not check the return values of these three routines. - - -It is possible to change decoding parameters between output passes in the -buffered-image mode. The decoder library currently supports only very -limited changes of parameters. ONLY THE FOLLOWING parameter changes are -allowed after jpeg_start_decompress() is called: -* dct_method can be changed before each call to jpeg_start_output(). - For example, one could use a fast DCT method for early scans, changing - to a higher quality method for the final scan. -* dither_mode can be changed before each call to jpeg_start_output(); - of course this has no impact if not using color quantization. Typically - one would use ordered dither for initial passes, then switch to - Floyd-Steinberg dither for the final pass. Caution: changing dither mode - can cause more memory to be allocated by the library. Although the amount - of memory involved is not large (a scanline or so), it may cause the - initial max_memory_to_use specification to be exceeded, which in the worst - case would result in an out-of-memory failure. -* do_block_smoothing can be changed before each call to jpeg_start_output(). - This setting is relevant only when decoding a progressive JPEG image. - During the first DC-only scan, block smoothing provides a very "fuzzy" look - instead of the very "blocky" look seen without it; which is better seems a - matter of personal taste. But block smoothing is nearly always a win - during later stages, especially when decoding a successive-approximation - image: smoothing helps to hide the slight blockiness that otherwise shows - up on smooth gradients until the lowest coefficient bits are sent. -* Color quantization mode can be changed under the rules described below. - You *cannot* change between full-color and quantized output (because that - would alter the required I/O buffer sizes), but you can change which - quantization method is used. - -When generating color-quantized output, changing quantization method is a -very useful way of switching between high-speed and high-quality display. -The library allows you to change among its three quantization methods: -1. Single-pass quantization to a fixed color cube. - Selected by cinfo.two_pass_quantize = FALSE and cinfo.colormap = NULL. -2. Single-pass quantization to an application-supplied colormap. - Selected by setting cinfo.colormap to point to the colormap (the value of - two_pass_quantize is ignored); also set cinfo.actual_number_of_colors. -3. Two-pass quantization to a colormap chosen specifically for the image. - Selected by cinfo.two_pass_quantize = TRUE and cinfo.colormap = NULL. - (This is the default setting selected by jpeg_read_header, but it is - probably NOT what you want for the first pass of progressive display!) -These methods offer successively better quality and lesser speed. However, -only the first method is available for quantizing in non-RGB color spaces. - -IMPORTANT: because the different quantizer methods have very different -working-storage requirements, the library requires you to indicate which -one(s) you intend to use before you call jpeg_start_decompress(). (If we did -not require this, the max_memory_to_use setting would be a complete fiction.) -You do this by setting one or more of these three cinfo fields to TRUE: - enable_1pass_quant Fixed color cube colormap - enable_external_quant Externally-supplied colormap - enable_2pass_quant Two-pass custom colormap -All three are initialized FALSE by jpeg_read_header(). But -jpeg_start_decompress() automatically sets TRUE the one selected by the -current two_pass_quantize and colormap settings, so you only need to set the -enable flags for any other quantization methods you plan to change to later. - -After setting the enable flags correctly at jpeg_start_decompress() time, you -can change to any enabled quantization method by setting two_pass_quantize -and colormap properly just before calling jpeg_start_output(). The following -special rules apply: -1. You must explicitly set cinfo.colormap to NULL when switching to 1-pass - or 2-pass mode from a different mode, or when you want the 2-pass - quantizer to be re-run to generate a new colormap. -2. To switch to an external colormap, or to change to a different external - colormap than was used on the prior pass, you must call - jpeg_new_colormap() after setting cinfo.colormap. -NOTE: if you want to use the same colormap as was used in the prior pass, -you should not do either of these things. This will save some nontrivial -switchover costs. -(These requirements exist because cinfo.colormap will always be non-NULL -after completing a prior output pass, since both the 1-pass and 2-pass -quantizers set it to point to their output colormaps. Thus you have to -do one of these two things to notify the library that something has changed. -Yup, it's a bit klugy, but it's necessary to do it this way for backwards -compatibility.) - -Note that in buffered-image mode, the library generates any requested colormap -during jpeg_start_output(), not during jpeg_start_decompress(). - -When using two-pass quantization, jpeg_start_output() makes a pass over the -buffered image to determine the optimum color map; it therefore may take a -significant amount of time, whereas ordinarily it does little work. The -progress monitor hook is called during this pass, if defined. It is also -important to realize that if the specified target scan number is greater than -or equal to the current input scan number, jpeg_start_output() will attempt -to consume input as it makes this pass. If you use a suspending data source, -you need to check for a FALSE return from jpeg_start_output() under these -conditions. The combination of 2-pass quantization and a not-yet-fully-read -target scan is the only case in which jpeg_start_output() will consume input. - - -Application authors who support buffered-image mode may be tempted to use it -for all JPEG images, even single-scan ones. This will work, but it is -inefficient: there is no need to create an image-sized coefficient buffer for -single-scan images. Requesting buffered-image mode for such an image wastes -memory. Worse, it can cost time on large images, since the buffered data has -to be swapped out or written to a temporary file. If you are concerned about -maximum performance on baseline JPEG files, you should use buffered-image -mode only when the incoming file actually has multiple scans. This can be -tested by calling jpeg_has_multiple_scans(), which will return a correct -result at any time after jpeg_read_header() completes. - -It is also worth noting that when you use jpeg_consume_input() to let input -processing get ahead of output processing, the resulting pattern of access to -the coefficient buffer is quite nonsequential. It's best to use the memory -manager jmemnobs.c if you can (ie, if you have enough real or virtual main -memory). If not, at least make sure that max_memory_to_use is set as high as -possible. If the JPEG memory manager has to use a temporary file, you will -probably see a lot of disk traffic and poor performance. (This could be -improved with additional work on the memory manager, but we haven't gotten -around to it yet.) - -In some applications it may be convenient to use jpeg_consume_input() for all -input processing, including reading the initial markers; that is, you may -wish to call jpeg_consume_input() instead of jpeg_read_header() during -startup. This works, but note that you must check for JPEG_REACHED_SOS and -JPEG_REACHED_EOI return codes as the equivalent of jpeg_read_header's codes. -Once the first SOS marker has been reached, you must call -jpeg_start_decompress() before jpeg_consume_input() will consume more input; -it'll just keep returning JPEG_REACHED_SOS until you do. If you read a -tables-only file this way, jpeg_consume_input() will return JPEG_REACHED_EOI -without ever returning JPEG_REACHED_SOS; be sure to check for this case. -If this happens, the decompressor will not read any more input until you call -jpeg_abort() to reset it. It is OK to call jpeg_consume_input() even when not -using buffered-image mode, but in that case it's basically a no-op after the -initial markers have been read: it will just return JPEG_SUSPENDED. - - -Abbreviated datastreams and multiple images -------------------------------------------- - -A JPEG compression or decompression object can be reused to process multiple -images. This saves a small amount of time per image by eliminating the -"create" and "destroy" operations, but that isn't the real purpose of the -feature. Rather, reuse of an object provides support for abbreviated JPEG -datastreams. Object reuse can also simplify processing a series of images in -a single input or output file. This section explains these features. - -A JPEG file normally contains several hundred bytes worth of quantization -and Huffman tables. In a situation where many images will be stored or -transmitted with identical tables, this may represent an annoying overhead. -The JPEG standard therefore permits tables to be omitted. The standard -defines three classes of JPEG datastreams: - * "Interchange" datastreams contain an image and all tables needed to decode - the image. These are the usual kind of JPEG file. - * "Abbreviated image" datastreams contain an image, but are missing some or - all of the tables needed to decode that image. - * "Abbreviated table specification" (henceforth "tables-only") datastreams - contain only table specifications. -To decode an abbreviated image, it is necessary to load the missing table(s) -into the decoder beforehand. This can be accomplished by reading a separate -tables-only file. A variant scheme uses a series of images in which the first -image is an interchange (complete) datastream, while subsequent ones are -abbreviated and rely on the tables loaded by the first image. It is assumed -that once the decoder has read a table, it will remember that table until a -new definition for the same table number is encountered. - -It is the application designer's responsibility to figure out how to associate -the correct tables with an abbreviated image. While abbreviated datastreams -can be useful in a closed environment, their use is strongly discouraged in -any situation where data exchange with other applications might be needed. -Caveat designer. - -The JPEG library provides support for reading and writing any combination of -tables-only datastreams and abbreviated images. In both compression and -decompression objects, a quantization or Huffman table will be retained for -the lifetime of the object, unless it is overwritten by a new table definition. - - -To create abbreviated image datastreams, it is only necessary to tell the -compressor not to emit some or all of the tables it is using. Each -quantization and Huffman table struct contains a boolean field "sent_table", -which normally is initialized to FALSE. For each table used by the image, the -header-writing process emits the table and sets sent_table = TRUE unless it is -already TRUE. (In normal usage, this prevents outputting the same table -definition multiple times, as would otherwise occur because the chroma -components typically share tables.) Thus, setting this field to TRUE before -calling jpeg_start_compress() will prevent the table from being written at -all. - -If you want to create a "pure" abbreviated image file containing no tables, -just call "jpeg_suppress_tables(&cinfo, TRUE)" after constructing all the -tables. If you want to emit some but not all tables, you'll need to set the -individual sent_table fields directly. - -To create an abbreviated image, you must also call jpeg_start_compress() -with a second parameter of FALSE, not TRUE. Otherwise jpeg_start_compress() -will force all the sent_table fields to FALSE. (This is a safety feature to -prevent abbreviated images from being created accidentally.) - -To create a tables-only file, perform the same parameter setup that you -normally would, but instead of calling jpeg_start_compress() and so on, call -jpeg_write_tables(&cinfo). This will write an abbreviated datastream -containing only SOI, DQT and/or DHT markers, and EOI. All the quantization -and Huffman tables that are currently defined in the compression object will -be emitted unless their sent_tables flag is already TRUE, and then all the -sent_tables flags will be set TRUE. - -A sure-fire way to create matching tables-only and abbreviated image files -is to proceed as follows: - - create JPEG compression object - set JPEG parameters - set destination to tables-only file - jpeg_write_tables(&cinfo); - set destination to image file - jpeg_start_compress(&cinfo, FALSE); - write data... - jpeg_finish_compress(&cinfo); - -Since the JPEG parameters are not altered between writing the table file and -the abbreviated image file, the same tables are sure to be used. Of course, -you can repeat the jpeg_start_compress() ... jpeg_finish_compress() sequence -many times to produce many abbreviated image files matching the table file. - -You cannot suppress output of the computed Huffman tables when Huffman -optimization is selected. (If you could, there'd be no way to decode the -image...) Generally, you don't want to set optimize_coding = TRUE when -you are trying to produce abbreviated files. - -In some cases you might want to compress an image using tables which are -not stored in the application, but are defined in an interchange or -tables-only file readable by the application. This can be done by setting up -a JPEG decompression object to read the specification file, then copying the -tables into your compression object. See jpeg_copy_critical_parameters() -for an example of copying quantization tables. - - -To read abbreviated image files, you simply need to load the proper tables -into the decompression object before trying to read the abbreviated image. -If the proper tables are stored in the application program, you can just -allocate the table structs and fill in their contents directly. For example, -to load a fixed quantization table into table slot "n": - - if (cinfo.quant_tbl_ptrs[n] == NULL) - cinfo.quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) &cinfo); - quant_ptr = cinfo.quant_tbl_ptrs[n]; /* quant_ptr is JQUANT_TBL* */ - for (i = 0; i < 64; i++) { - /* Qtable[] is desired quantization table, in natural array order */ - quant_ptr->quantval[i] = Qtable[i]; - } - -Code to load a fixed Huffman table is typically (for AC table "n"): - - if (cinfo.ac_huff_tbl_ptrs[n] == NULL) - cinfo.ac_huff_tbl_ptrs[n] = jpeg_alloc_huff_table((j_common_ptr) &cinfo); - huff_ptr = cinfo.ac_huff_tbl_ptrs[n]; /* huff_ptr is JHUFF_TBL* */ - for (i = 1; i <= 16; i++) { - /* counts[i] is number of Huffman codes of length i bits, i=1..16 */ - huff_ptr->bits[i] = counts[i]; - } - for (i = 0; i < 256; i++) { - /* symbols[] is the list of Huffman symbols, in code-length order */ - huff_ptr->huffval[i] = symbols[i]; - } - -(Note that trying to set cinfo.quant_tbl_ptrs[n] to point directly at a -constant JQUANT_TBL object is not safe. If the incoming file happened to -contain a quantization table definition, your master table would get -overwritten! Instead allocate a working table copy and copy the master table -into it, as illustrated above. Ditto for Huffman tables, of course.) - -You might want to read the tables from a tables-only file, rather than -hard-wiring them into your application. The jpeg_read_header() call is -sufficient to read a tables-only file. You must pass a second parameter of -FALSE to indicate that you do not require an image to be present. Thus, the -typical scenario is - - create JPEG decompression object - set source to tables-only file - jpeg_read_header(&cinfo, FALSE); - set source to abbreviated image file - jpeg_read_header(&cinfo, TRUE); - set decompression parameters - jpeg_start_decompress(&cinfo); - read data... - jpeg_finish_decompress(&cinfo); - -In some cases, you may want to read a file without knowing whether it contains -an image or just tables. In that case, pass FALSE and check the return value -from jpeg_read_header(): it will be JPEG_HEADER_OK if an image was found, -JPEG_HEADER_TABLES_ONLY if only tables were found. (A third return value, -JPEG_SUSPENDED, is possible when using a suspending data source manager.) -Note that jpeg_read_header() will not complain if you read an abbreviated -image for which you haven't loaded the missing tables; the missing-table check -occurs later, in jpeg_start_decompress(). - - -It is possible to read a series of images from a single source file by -repeating the jpeg_read_header() ... jpeg_finish_decompress() sequence, -without releasing/recreating the JPEG object or the data source module. -(If you did reinitialize, any partial bufferload left in the data source -buffer at the end of one image would be discarded, causing you to lose the -start of the next image.) When you use this method, stored tables are -automatically carried forward, so some of the images can be abbreviated images -that depend on tables from earlier images. - -If you intend to write a series of images into a single destination file, -you might want to make a specialized data destination module that doesn't -flush the output buffer at term_destination() time. This would speed things -up by some trifling amount. Of course, you'd need to remember to flush the -buffer after the last image. You can make the later images be abbreviated -ones by passing FALSE to jpeg_start_compress(). - - -Special markers ---------------- - -Some applications may need to insert or extract special data in the JPEG -datastream. The JPEG standard provides marker types "COM" (comment) and -"APP0" through "APP15" (application) to hold application-specific data. -Unfortunately, the use of these markers is not specified by the standard. -COM markers are fairly widely used to hold user-supplied text. The JFIF file -format spec uses APP0 markers with specified initial strings to hold certain -data. Adobe applications use APP14 markers beginning with the string "Adobe" -for miscellaneous data. Other APPn markers are rarely seen, but might -contain almost anything. - -If you wish to store user-supplied text, we recommend you use COM markers -and place readable 7-bit ASCII text in them. Newline conventions are not -standardized --- expect to find LF (Unix style), CR/LF (DOS style), or CR -(Mac style). A robust COM reader should be able to cope with random binary -garbage, including nulls, since some applications generate COM markers -containing non-ASCII junk. (But yours should not be one of them.) - -For program-supplied data, use an APPn marker, and be sure to begin it with an -identifying string so that you can tell whether the marker is actually yours. -It's probably best to avoid using APP0 or APP14 for any private markers. -(NOTE: the upcoming SPIFF standard will use APP8 markers; we recommend you -not use APP8 markers for any private purposes, either.) - -Keep in mind that at most 65533 bytes can be put into one marker, but you -can have as many markers as you like. - -By default, the IJG compression library will write a JFIF APP0 marker if the -selected JPEG colorspace is grayscale or YCbCr, or an Adobe APP14 marker if -the selected colorspace is RGB, CMYK, or YCCK. You can disable this, but -we don't recommend it. The decompression library will recognize JFIF and -Adobe markers and will set the JPEG colorspace properly when one is found. - - -You can write special markers immediately following the datastream header by -calling jpeg_write_marker() after jpeg_start_compress() and before the first -call to jpeg_write_scanlines(). When you do this, the markers appear after -the SOI and the JFIF APP0 and Adobe APP14 markers (if written), but before -all else. Specify the marker type parameter as "JPEG_COM" for COM or -"JPEG_APP0 + n" for APPn. (Actually, jpeg_write_marker will let you write -any marker type, but we don't recommend writing any other kinds of marker.) -For example, to write a user comment string pointed to by comment_text: - jpeg_write_marker(cinfo, JPEG_COM, comment_text, strlen(comment_text)); - -If it's not convenient to store all the marker data in memory at once, -you can instead call jpeg_write_m_header() followed by multiple calls to -jpeg_write_m_byte(). If you do it this way, it's your responsibility to -call jpeg_write_m_byte() exactly the number of times given in the length -parameter to jpeg_write_m_header(). (This method lets you empty the -output buffer partway through a marker, which might be important when -using a suspending data destination module. In any case, if you are using -a suspending destination, you should flush its buffer after inserting -any special markers. See "I/O suspension".) - -Or, if you prefer to synthesize the marker byte sequence yourself, -you can just cram it straight into the data destination module. - -If you are writing JFIF 1.02 extension markers (thumbnail images), don't -forget to set cinfo.JFIF_minor_version = 2 so that the encoder will write the -correct JFIF version number in the JFIF header marker. The library's default -is to write version 1.01, but that's wrong if you insert any 1.02 extension -markers. (We could probably get away with just defaulting to 1.02, but there -used to be broken decoders that would complain about unknown minor version -numbers. To reduce compatibility risks it's safest not to write 1.02 unless -you are actually using 1.02 extensions.) - - -When reading, two methods of handling special markers are available: -1. You can ask the library to save the contents of COM and/or APPn markers -into memory, and then examine them at your leisure afterwards. -2. You can supply your own routine to process COM and/or APPn markers -on-the-fly as they are read. -The first method is simpler to use, especially if you are using a suspending -data source; writing a marker processor that copes with input suspension is -not easy (consider what happens if the marker is longer than your available -input buffer). However, the second method conserves memory since the marker -data need not be kept around after it's been processed. - -For either method, you'd normally set up marker handling after creating a -decompression object and before calling jpeg_read_header(), because the -markers of interest will typically be near the head of the file and so will -be scanned by jpeg_read_header. Once you've established a marker handling -method, it will be used for the life of that decompression object -(potentially many datastreams), unless you change it. Marker handling is -determined separately for COM markers and for each APPn marker code. - - -To save the contents of special markers in memory, call - jpeg_save_markers(cinfo, marker_code, length_limit) -where marker_code is the marker type to save, JPEG_COM or JPEG_APP0+n. -(To arrange to save all the special marker types, you need to call this -routine 17 times, for COM and APP0-APP15.) If the incoming marker is longer -than length_limit data bytes, only length_limit bytes will be saved; this -parameter allows you to avoid chewing up memory when you only need to see the -first few bytes of a potentially large marker. If you want to save all the -data, set length_limit to 0xFFFF; that is enough since marker lengths are only -16 bits. As a special case, setting length_limit to 0 prevents that marker -type from being saved at all. (That is the default behavior, in fact.) - -After jpeg_read_header() completes, you can examine the special markers by -following the cinfo->marker_list pointer chain. All the special markers in -the file appear in this list, in order of their occurrence in the file (but -omitting any markers of types you didn't ask for). Both the original data -length and the saved data length are recorded for each list entry; the latter -will not exceed length_limit for the particular marker type. Note that these -lengths exclude the marker length word, whereas the stored representation -within the JPEG file includes it. (Hence the maximum data length is really -only 65533.) - -It is possible that additional special markers appear in the file beyond the -SOS marker at which jpeg_read_header stops; if so, the marker list will be -extended during reading of the rest of the file. This is not expected to be -common, however. If you are short on memory you may want to reset the length -limit to zero for all marker types after finishing jpeg_read_header, to -ensure that the max_memory_to_use setting cannot be exceeded due to addition -of later markers. - -The marker list remains stored until you call jpeg_finish_decompress or -jpeg_abort, at which point the memory is freed and the list is set to empty. -(jpeg_destroy also releases the storage, of course.) - -Note that the library is internally interested in APP0 and APP14 markers; -if you try to set a small nonzero length limit on these types, the library -will silently force the length up to the minimum it wants. (But you can set -a zero length limit to prevent them from being saved at all.) Also, in a -16-bit environment, the maximum length limit may be constrained to less than -65533 by malloc() limitations. It is therefore best not to assume that the -effective length limit is exactly what you set it to be. - - -If you want to supply your own marker-reading routine, you do it by calling -jpeg_set_marker_processor(). A marker processor routine must have the -signature - boolean jpeg_marker_parser_method (j_decompress_ptr cinfo) -Although the marker code is not explicitly passed, the routine can find it -in cinfo->unread_marker. At the time of call, the marker proper has been -read from the data source module. The processor routine is responsible for -reading the marker length word and the remaining parameter bytes, if any. -Return TRUE to indicate success. (FALSE should be returned only if you are -using a suspending data source and it tells you to suspend. See the standard -marker processors in jdmarker.c for appropriate coding methods if you need to -use a suspending data source.) - -If you override the default APP0 or APP14 processors, it is up to you to -recognize JFIF and Adobe markers if you want colorspace recognition to occur -properly. We recommend copying and extending the default processors if you -want to do that. (A better idea is to save these marker types for later -examination by calling jpeg_save_markers(); that method doesn't interfere -with the library's own processing of these markers.) - -jpeg_set_marker_processor() and jpeg_save_markers() are mutually exclusive ---- if you call one it overrides any previous call to the other, for the -particular marker type specified. - -A simple example of an external COM processor can be found in djpeg.c. -Also, see jpegtran.c for an example of using jpeg_save_markers. - - -Raw (downsampled) image data ----------------------------- - -Some applications need to supply already-downsampled image data to the JPEG -compressor, or to receive raw downsampled data from the decompressor. The -library supports this requirement by allowing the application to write or -read raw data, bypassing the normal preprocessing or postprocessing steps. -The interface is different from the standard one and is somewhat harder to -use. If your interest is merely in bypassing color conversion, we recommend -that you use the standard interface and simply set jpeg_color_space = -in_color_space (or jpeg_color_space = out_color_space for decompression). -The mechanism described in this section is necessary only to supply or -receive downsampled image data, in which not all components have the same -dimensions. - - -To compress raw data, you must supply the data in the colorspace to be used -in the JPEG file (please read the earlier section on Special color spaces) -and downsampled to the sampling factors specified in the JPEG parameters. -You must supply the data in the format used internally by the JPEG library, -namely a JSAMPIMAGE array. This is an array of pointers to two-dimensional -arrays, each of type JSAMPARRAY. Each 2-D array holds the values for one -color component. This structure is necessary since the components are of -different sizes. If the image dimensions are not a multiple of the MCU size, -you must also pad the data correctly (usually, this is done by replicating -the last column and/or row). The data must be padded to a multiple of a DCT -block in each component: that is, each downsampled row must contain a -multiple of 8 valid samples, and there must be a multiple of 8 sample rows -for each component. (For applications such as conversion of digital TV -images, the standard image size is usually a multiple of the DCT block size, -so that no padding need actually be done.) - -The procedure for compression of raw data is basically the same as normal -compression, except that you call jpeg_write_raw_data() in place of -jpeg_write_scanlines(). Before calling jpeg_start_compress(), you must do -the following: - * Set cinfo->raw_data_in to TRUE. (It is set FALSE by jpeg_set_defaults().) - This notifies the library that you will be supplying raw data. - * Ensure jpeg_color_space is correct --- an explicit jpeg_set_colorspace() - call is a good idea. Note that since color conversion is bypassed, - in_color_space is ignored, except that jpeg_set_defaults() uses it to - choose the default jpeg_color_space setting. - * Ensure the sampling factors, cinfo->comp_info[i].h_samp_factor and - cinfo->comp_info[i].v_samp_factor, are correct. Since these indicate the - dimensions of the data you are supplying, it's wise to set them - explicitly, rather than assuming the library's defaults are what you want. - -To pass raw data to the library, call jpeg_write_raw_data() in place of -jpeg_write_scanlines(). The two routines work similarly except that -jpeg_write_raw_data takes a JSAMPIMAGE data array rather than JSAMPARRAY. -The scanlines count passed to and returned from jpeg_write_raw_data is -measured in terms of the component with the largest v_samp_factor. - -jpeg_write_raw_data() processes one MCU row per call, which is to say -v_samp_factor*DCTSIZE sample rows of each component. The passed num_lines -value must be at least max_v_samp_factor*DCTSIZE, and the return value will -be exactly that amount (or possibly some multiple of that amount, in future -library versions). This is true even on the last call at the bottom of the -image; don't forget to pad your data as necessary. - -The required dimensions of the supplied data can be computed for each -component as - cinfo->comp_info[i].width_in_blocks*DCTSIZE samples per row - cinfo->comp_info[i].height_in_blocks*DCTSIZE rows in image -after jpeg_start_compress() has initialized those fields. If the valid data -is smaller than this, it must be padded appropriately. For some sampling -factors and image sizes, additional dummy DCT blocks are inserted to make -the image a multiple of the MCU dimensions. The library creates such dummy -blocks itself; it does not read them from your supplied data. Therefore you -need never pad by more than DCTSIZE samples. An example may help here. -Assume 2h2v downsampling of YCbCr data, that is - cinfo->comp_info[0].h_samp_factor = 2 for Y - cinfo->comp_info[0].v_samp_factor = 2 - cinfo->comp_info[1].h_samp_factor = 1 for Cb - cinfo->comp_info[1].v_samp_factor = 1 - cinfo->comp_info[2].h_samp_factor = 1 for Cr - cinfo->comp_info[2].v_samp_factor = 1 -and suppose that the nominal image dimensions (cinfo->image_width and -cinfo->image_height) are 101x101 pixels. Then jpeg_start_compress() will -compute downsampled_width = 101 and width_in_blocks = 13 for Y, -downsampled_width = 51 and width_in_blocks = 7 for Cb and Cr (and the same -for the height fields). You must pad the Y data to at least 13*8 = 104 -columns and rows, the Cb/Cr data to at least 7*8 = 56 columns and rows. The -MCU height is max_v_samp_factor = 2 DCT rows so you must pass at least 16 -scanlines on each call to jpeg_write_raw_data(), which is to say 16 actual -sample rows of Y and 8 each of Cb and Cr. A total of 7 MCU rows are needed, -so you must pass a total of 7*16 = 112 "scanlines". The last DCT block row -of Y data is dummy, so it doesn't matter what you pass for it in the data -arrays, but the scanlines count must total up to 112 so that all of the Cb -and Cr data gets passed. - -Output suspension is supported with raw-data compression: if the data -destination module suspends, jpeg_write_raw_data() will return 0. -In this case the same data rows must be passed again on the next call. - - -Decompression with raw data output implies bypassing all postprocessing: -you cannot ask for rescaling or color quantization, for instance. More -seriously, you must deal with the color space and sampling factors present in -the incoming file. If your application only handles, say, 2h1v YCbCr data, -you must check for and fail on other color spaces or other sampling factors. -The library will not convert to a different color space for you. - -To obtain raw data output, set cinfo->raw_data_out = TRUE before -jpeg_start_decompress() (it is set FALSE by jpeg_read_header()). Be sure to -verify that the color space and sampling factors are ones you can handle. -Then call jpeg_read_raw_data() in place of jpeg_read_scanlines(). The -decompression process is otherwise the same as usual. - -jpeg_read_raw_data() returns one MCU row per call, and thus you must pass a -buffer of at least max_v_samp_factor*DCTSIZE scanlines (scanline counting is -the same as for raw-data compression). The buffer you pass must be large -enough to hold the actual data plus padding to DCT-block boundaries. As with -compression, any entirely dummy DCT blocks are not processed so you need not -allocate space for them, but the total scanline count includes them. The -above example of computing buffer dimensions for raw-data compression is -equally valid for decompression. - -Input suspension is supported with raw-data decompression: if the data source -module suspends, jpeg_read_raw_data() will return 0. You can also use -buffered-image mode to read raw data in multiple passes. - - -Really raw data: DCT coefficients ---------------------------------- - -It is possible to read or write the contents of a JPEG file as raw DCT -coefficients. This facility is mainly intended for use in lossless -transcoding between different JPEG file formats. Other possible applications -include lossless cropping of a JPEG image, lossless reassembly of a -multi-strip or multi-tile TIFF/JPEG file into a single JPEG datastream, etc. - -To read the contents of a JPEG file as DCT coefficients, open the file and do -jpeg_read_header() as usual. But instead of calling jpeg_start_decompress() -and jpeg_read_scanlines(), call jpeg_read_coefficients(). This will read the -entire image into a set of virtual coefficient-block arrays, one array per -component. The return value is a pointer to an array of virtual-array -descriptors. Each virtual array can be accessed directly using the JPEG -memory manager's access_virt_barray method (see Memory management, below, -and also read structure.doc's discussion of virtual array handling). Or, -for simple transcoding to a different JPEG file format, the array list can -just be handed directly to jpeg_write_coefficients(). - -Each block in the block arrays contains quantized coefficient values in -normal array order (not JPEG zigzag order). The block arrays contain only -DCT blocks containing real data; any entirely-dummy blocks added to fill out -interleaved MCUs at the right or bottom edges of the image are discarded -during reading and are not stored in the block arrays. (The size of each -block array can be determined from the width_in_blocks and height_in_blocks -fields of the component's comp_info entry.) This is also the data format -expected by jpeg_write_coefficients(). - -When you are done using the virtual arrays, call jpeg_finish_decompress() -to release the array storage and return the decompression object to an idle -state; or just call jpeg_destroy() if you don't need to reuse the object. - -If you use a suspending data source, jpeg_read_coefficients() will return -NULL if it is forced to suspend; a non-NULL return value indicates successful -completion. You need not test for a NULL return value when using a -non-suspending data source. - -It is also possible to call jpeg_read_coefficients() to obtain access to the -decoder's coefficient arrays during a normal decode cycle in buffered-image -mode. This frammish might be useful for progressively displaying an incoming -image and then re-encoding it without loss. To do this, decode in buffered- -image mode as discussed previously, then call jpeg_read_coefficients() after -the last jpeg_finish_output() call. The arrays will be available for your use -until you call jpeg_finish_decompress(). - - -To write the contents of a JPEG file as DCT coefficients, you must provide -the DCT coefficients stored in virtual block arrays. You can either pass -block arrays read from an input JPEG file by jpeg_read_coefficients(), or -allocate virtual arrays from the JPEG compression object and fill them -yourself. In either case, jpeg_write_coefficients() is substituted for -jpeg_start_compress() and jpeg_write_scanlines(). Thus the sequence is - * Create compression object - * Set all compression parameters as necessary - * Request virtual arrays if needed - * jpeg_write_coefficients() - * jpeg_finish_compress() - * Destroy or re-use compression object -jpeg_write_coefficients() is passed a pointer to an array of virtual block -array descriptors; the number of arrays is equal to cinfo.num_components. - -The virtual arrays need only have been requested, not realized, before -jpeg_write_coefficients() is called. A side-effect of -jpeg_write_coefficients() is to realize any virtual arrays that have been -requested from the compression object's memory manager. Thus, when obtaining -the virtual arrays from the compression object, you should fill the arrays -after calling jpeg_write_coefficients(). The data is actually written out -when you call jpeg_finish_compress(); jpeg_write_coefficients() only writes -the file header. - -When writing raw DCT coefficients, it is crucial that the JPEG quantization -tables and sampling factors match the way the data was encoded, or the -resulting file will be invalid. For transcoding from an existing JPEG file, -we recommend using jpeg_copy_critical_parameters(). This routine initializes -all the compression parameters to default values (like jpeg_set_defaults()), -then copies the critical information from a source decompression object. -The decompression object should have just been used to read the entire -JPEG input file --- that is, it should be awaiting jpeg_finish_decompress(). - -jpeg_write_coefficients() marks all tables stored in the compression object -as needing to be written to the output file (thus, it acts like -jpeg_start_compress(cinfo, TRUE)). This is for safety's sake, to avoid -emitting abbreviated JPEG files by accident. If you really want to emit an -abbreviated JPEG file, call jpeg_suppress_tables(), or set the tables' -individual sent_table flags, between calling jpeg_write_coefficients() and -jpeg_finish_compress(). - - -Progress monitoring -------------------- - -Some applications may need to regain control from the JPEG library every so -often. The typical use of this feature is to produce a percent-done bar or -other progress display. (For a simple example, see cjpeg.c or djpeg.c.) -Although you do get control back frequently during the data-transferring pass -(the jpeg_read_scanlines or jpeg_write_scanlines loop), any additional passes -will occur inside jpeg_finish_compress or jpeg_start_decompress; those -routines may take a long time to execute, and you don't get control back -until they are done. - -You can define a progress-monitor routine which will be called periodically -by the library. No guarantees are made about how often this call will occur, -so we don't recommend you use it for mouse tracking or anything like that. -At present, a call will occur once per MCU row, scanline, or sample row -group, whichever unit is convenient for the current processing mode; so the -wider the image, the longer the time between calls. During the data -transferring pass, only one call occurs per call of jpeg_read_scanlines or -jpeg_write_scanlines, so don't pass a large number of scanlines at once if -you want fine resolution in the progress count. (If you really need to use -the callback mechanism for time-critical tasks like mouse tracking, you could -insert additional calls inside some of the library's inner loops.) - -To establish a progress-monitor callback, create a struct jpeg_progress_mgr, -fill in its progress_monitor field with a pointer to your callback routine, -and set cinfo->progress to point to the struct. The callback will be called -whenever cinfo->progress is non-NULL. (This pointer is set to NULL by -jpeg_create_compress or jpeg_create_decompress; the library will not change -it thereafter. So if you allocate dynamic storage for the progress struct, -make sure it will live as long as the JPEG object does. Allocating from the -JPEG memory manager with lifetime JPOOL_PERMANENT will work nicely.) You -can use the same callback routine for both compression and decompression. - -The jpeg_progress_mgr struct contains four fields which are set by the library: - long pass_counter; /* work units completed in this pass */ - long pass_limit; /* total number of work units in this pass */ - int completed_passes; /* passes completed so far */ - int total_passes; /* total number of passes expected */ -During any one pass, pass_counter increases from 0 up to (not including) -pass_limit; the step size is usually but not necessarily 1. The pass_limit -value may change from one pass to another. The expected total number of -passes is in total_passes, and the number of passes already completed is in -completed_passes. Thus the fraction of work completed may be estimated as - completed_passes + (pass_counter/pass_limit) - -------------------------------------------- - total_passes -ignoring the fact that the passes may not be equal amounts of work. - -When decompressing, pass_limit can even change within a pass, because it -depends on the number of scans in the JPEG file, which isn't always known in -advance. The computed fraction-of-work-done may jump suddenly (if the library -discovers it has overestimated the number of scans) or even decrease (in the -opposite case). It is not wise to put great faith in the work estimate. - -When using the decompressor's buffered-image mode, the progress monitor work -estimate is likely to be completely unhelpful, because the library has no way -to know how many output passes will be demanded of it. Currently, the library -sets total_passes based on the assumption that there will be one more output -pass if the input file end hasn't yet been read (jpeg_input_complete() isn't -TRUE), but no more output passes if the file end has been reached when the -output pass is started. This means that total_passes will rise as additional -output passes are requested. If you have a way of determining the input file -size, estimating progress based on the fraction of the file that's been read -will probably be more useful than using the library's value. - - -Memory management ------------------ - -This section covers some key facts about the JPEG library's built-in memory -manager. For more info, please read structure.doc's section about the memory -manager, and consult the source code if necessary. - -All memory and temporary file allocation within the library is done via the -memory manager. If necessary, you can replace the "back end" of the memory -manager to control allocation yourself (for example, if you don't want the -library to use malloc() and free() for some reason). - -Some data is allocated "permanently" and will not be freed until the JPEG -object is destroyed. Most data is allocated "per image" and is freed by -jpeg_finish_compress, jpeg_finish_decompress, or jpeg_abort. You can call the -memory manager yourself to allocate structures that will automatically be -freed at these times. Typical code for this is - ptr = (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, size); -Use JPOOL_PERMANENT to get storage that lasts as long as the JPEG object. -Use alloc_large instead of alloc_small for anything bigger than a few Kbytes. -There are also alloc_sarray and alloc_barray routines that automatically -build 2-D sample or block arrays. - -The library's minimum space requirements to process an image depend on the -image's width, but not on its height, because the library ordinarily works -with "strip" buffers that are as wide as the image but just a few rows high. -Some operating modes (eg, two-pass color quantization) require full-image -buffers. Such buffers are treated as "virtual arrays": only the current strip -need be in memory, and the rest can be swapped out to a temporary file. - -If you use the simplest memory manager back end (jmemnobs.c), then no -temporary files are used; virtual arrays are simply malloc()'d. Images bigger -than memory can be processed only if your system supports virtual memory. -The other memory manager back ends support temporary files of various flavors -and thus work in machines without virtual memory. They may also be useful on -Unix machines if you need to process images that exceed available swap space. - -When using temporary files, the library will make the in-memory buffers for -its virtual arrays just big enough to stay within a "maximum memory" setting. -Your application can set this limit by setting cinfo->mem->max_memory_to_use -after creating the JPEG object. (Of course, there is still a minimum size for -the buffers, so the max-memory setting is effective only if it is bigger than -the minimum space needed.) If you allocate any large structures yourself, you -must allocate them before jpeg_start_compress() or jpeg_start_decompress() in -order to have them counted against the max memory limit. Also keep in mind -that space allocated with alloc_small() is ignored, on the assumption that -it's too small to be worth worrying about; so a reasonable safety margin -should be left when setting max_memory_to_use. - -If you use the jmemname.c or jmemdos.c memory manager back end, it is -important to clean up the JPEG object properly to ensure that the temporary -files get deleted. (This is especially crucial with jmemdos.c, where the -"temporary files" may be extended-memory segments; if they are not freed, -DOS will require a reboot to recover the memory.) Thus, with these memory -managers, it's a good idea to provide a signal handler that will trap any -early exit from your program. The handler should call either jpeg_abort() -or jpeg_destroy() for any active JPEG objects. A handler is not needed with -jmemnobs.c, and shouldn't be necessary with jmemansi.c or jmemmac.c either, -since the C library is supposed to take care of deleting files made with -tmpfile(). - - -Memory usage ------------- - -Working memory requirements while performing compression or decompression -depend on image dimensions, image characteristics (such as colorspace and -JPEG process), and operating mode (application-selected options). - -As of v6b, the decompressor requires: - 1. About 24K in more-or-less-fixed-size data. This varies a bit depending - on operating mode and image characteristics (particularly color vs. - grayscale), but it doesn't depend on image dimensions. - 2. Strip buffers (of size proportional to the image width) for IDCT and - upsampling results. The worst case for commonly used sampling factors - is about 34 bytes * width in pixels for a color image. A grayscale image - only needs about 8 bytes per pixel column. - 3. A full-image DCT coefficient buffer is needed to decode a multi-scan JPEG - file (including progressive JPEGs), or whenever you select buffered-image - mode. This takes 2 bytes/coefficient. At typical 2x2 sampling, that's - 3 bytes per pixel for a color image. Worst case (1x1 sampling) requires - 6 bytes/pixel. For grayscale, figure 2 bytes/pixel. - 4. To perform 2-pass color quantization, the decompressor also needs a - 128K color lookup table and a full-image pixel buffer (3 bytes/pixel). -This does not count any memory allocated by the application, such as a -buffer to hold the final output image. - -The above figures are valid for 8-bit JPEG data precision and a machine with -32-bit ints. For 12-bit JPEG data, double the size of the strip buffers and -quantization pixel buffer. The "fixed-size" data will be somewhat smaller -with 16-bit ints, larger with 64-bit ints. Also, CMYK or other unusual -color spaces will require different amounts of space. - -The full-image coefficient and pixel buffers, if needed at all, do not -have to be fully RAM resident; you can have the library use temporary -files instead when the total memory usage would exceed a limit you set. -(But if your OS supports virtual memory, it's probably better to just use -jmemnobs and let the OS do the swapping.) - -The compressor's memory requirements are similar, except that it has no need -for color quantization. Also, it needs a full-image DCT coefficient buffer -if Huffman-table optimization is asked for, even if progressive mode is not -requested. - -If you need more detailed information about memory usage in a particular -situation, you can enable the MEM_STATS code in jmemmgr.c. - - -Library compile-time options ----------------------------- - -A number of compile-time options are available by modifying jmorecfg.h. - -The JPEG standard provides for both the baseline 8-bit DCT process and -a 12-bit DCT process. The IJG code supports 12-bit lossy JPEG if you define -BITS_IN_JSAMPLE as 12 rather than 8. Note that this causes JSAMPLE to be -larger than a char, so it affects the surrounding application's image data. -The sample applications cjpeg and djpeg can support 12-bit mode only for PPM -and GIF file formats; you must disable the other file formats to compile a -12-bit cjpeg or djpeg. (install.doc has more information about that.) -At present, a 12-bit library can handle *only* 12-bit images, not both -precisions. (If you need to include both 8- and 12-bit libraries in a single -application, you could probably do it by defining NEED_SHORT_EXTERNAL_NAMES -for just one of the copies. You'd have to access the 8-bit and 12-bit copies -from separate application source files. This is untested ... if you try it, -we'd like to hear whether it works!) - -Note that a 12-bit library always compresses in Huffman optimization mode, -in order to generate valid Huffman tables. This is necessary because our -default Huffman tables only cover 8-bit data. If you need to output 12-bit -files in one pass, you'll have to supply suitable default Huffman tables. -You may also want to supply your own DCT quantization tables; the existing -quality-scaling code has been developed for 8-bit use, and probably doesn't -generate especially good tables for 12-bit. - -The maximum number of components (color channels) in the image is determined -by MAX_COMPONENTS. The JPEG standard allows up to 255 components, but we -expect that few applications will need more than four or so. - -On machines with unusual data type sizes, you may be able to improve -performance or reduce memory space by tweaking the various typedefs in -jmorecfg.h. In particular, on some RISC CPUs, access to arrays of "short"s -is quite slow; consider trading memory for speed by making JCOEF, INT16, and -UINT16 be "int" or "unsigned int". UINT8 is also a candidate to become int. -You probably don't want to make JSAMPLE be int unless you have lots of memory -to burn. - -You can reduce the size of the library by compiling out various optional -functions. To do this, undefine xxx_SUPPORTED symbols as necessary. - -You can also save a few K by not having text error messages in the library; -the standard error message table occupies about 5Kb. This is particularly -reasonable for embedded applications where there's no good way to display -a message anyway. To do this, remove the creation of the message table -(jpeg_std_message_table[]) from jerror.c, and alter format_message to do -something reasonable without it. You could output the numeric value of the -message code number, for example. If you do this, you can also save a couple -more K by modifying the TRACEMSn() macros in jerror.h to expand to nothing; -you don't need trace capability anyway, right? - - -Portability considerations --------------------------- - -The JPEG library has been written to be extremely portable; the sample -applications cjpeg and djpeg are slightly less so. This section summarizes -the design goals in this area. (If you encounter any bugs that cause the -library to be less portable than is claimed here, we'd appreciate hearing -about them.) - -The code works fine on ANSI C, C++, and pre-ANSI C compilers, using any of -the popular system include file setups, and some not-so-popular ones too. -See install.doc for configuration procedures. - -The code is not dependent on the exact sizes of the C data types. As -distributed, we make the assumptions that - char is at least 8 bits wide - short is at least 16 bits wide - int is at least 16 bits wide - long is at least 32 bits wide -(These are the minimum requirements of the ANSI C standard.) Wider types will -work fine, although memory may be used inefficiently if char is much larger -than 8 bits or short is much bigger than 16 bits. The code should work -equally well with 16- or 32-bit ints. - -In a system where these assumptions are not met, you may be able to make the -code work by modifying the typedefs in jmorecfg.h. However, you will probably -have difficulty if int is less than 16 bits wide, since references to plain -int abound in the code. - -char can be either signed or unsigned, although the code runs faster if an -unsigned char type is available. If char is wider than 8 bits, you will need -to redefine JOCTET and/or provide custom data source/destination managers so -that JOCTET represents exactly 8 bits of data on external storage. - -The JPEG library proper does not assume ASCII representation of characters. -But some of the image file I/O modules in cjpeg/djpeg do have ASCII -dependencies in file-header manipulation; so does cjpeg's select_file_type() -routine. - -The JPEG library does not rely heavily on the C library. In particular, C -stdio is used only by the data source/destination modules and the error -handler, all of which are application-replaceable. (cjpeg/djpeg are more -heavily dependent on stdio.) malloc and free are called only from the memory -manager "back end" module, so you can use a different memory allocator by -replacing that one file. - -The code generally assumes that C names must be unique in the first 15 -characters. However, global function names can be made unique in the -first 6 characters by defining NEED_SHORT_EXTERNAL_NAMES. - -More info about porting the code may be gleaned by reading jconfig.doc, -jmorecfg.h, and jinclude.h. - - -Notes for MS-DOS implementors ------------------------------ - -The IJG code is designed to work efficiently in 80x86 "small" or "medium" -memory models (i.e., data pointers are 16 bits unless explicitly declared -"far"; code pointers can be either size). You may be able to use small -model to compile cjpeg or djpeg by itself, but you will probably have to use -medium model for any larger application. This won't make much difference in -performance. You *will* take a noticeable performance hit if you use a -large-data memory model (perhaps 10%-25%), and you should avoid "huge" model -if at all possible. - -The JPEG library typically needs 2Kb-3Kb of stack space. It will also -malloc about 20K-30K of near heap space while executing (and lots of far -heap, but that doesn't count in this calculation). This figure will vary -depending on selected operating mode, and to a lesser extent on image size. -There is also about 5Kb-6Kb of constant data which will be allocated in the -near data segment (about 4Kb of this is the error message table). -Thus you have perhaps 20K available for other modules' static data and near -heap space before you need to go to a larger memory model. The C library's -static data will account for several K of this, but that still leaves a good -deal for your needs. (If you are tight on space, you could reduce the sizes -of the I/O buffers allocated by jdatasrc.c and jdatadst.c, say from 4K to -1K. Another possibility is to move the error message table to far memory; -this should be doable with only localized hacking on jerror.c.) - -About 2K of the near heap space is "permanent" memory that will not be -released until you destroy the JPEG object. This is only an issue if you -save a JPEG object between compression or decompression operations. - -Far data space may also be a tight resource when you are dealing with large -images. The most memory-intensive case is decompression with two-pass color -quantization, or single-pass quantization to an externally supplied color -map. This requires a 128Kb color lookup table plus strip buffers amounting -to about 40 bytes per column for typical sampling ratios (eg, about 25600 -bytes for a 640-pixel-wide image). You may not be able to process wide -images if you have large data structures of your own. - -Of course, all of these concerns vanish if you use a 32-bit flat-memory-model -compiler, such as DJGPP or Watcom C. We highly recommend flat model if you -can use it; the JPEG library is significantly faster in flat model. +USING THE IJG JPEG LIBRARY + +Copyright (C) 1994-1998, Thomas G. Lane. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +This file describes how to use the IJG JPEG library within an application +program. Read it if you want to write a program that uses the library. + +The file example.c provides heavily commented skeleton code for calling the +JPEG library. Also see jpeglib.h (the include file to be used by application +programs) for full details about data structures and function parameter lists. +The library source code, of course, is the ultimate reference. + +Note that there have been *major* changes from the application interface +presented by IJG version 4 and earlier versions. The old design had several +inherent limitations, and it had accumulated a lot of cruft as we added +features while trying to minimize application-interface changes. We have +sacrificed backward compatibility in the version 5 rewrite, but we think the +improvements justify this. + + +TABLE OF CONTENTS +----------------- + +Overview: + Functions provided by the library + Outline of typical usage +Basic library usage: + Data formats + Compression details + Decompression details + Mechanics of usage: include files, linking, etc +Advanced features: + Compression parameter selection + Decompression parameter selection + Special color spaces + Error handling + Compressed data handling (source and destination managers) + I/O suspension + Progressive JPEG support + Buffered-image mode + Abbreviated datastreams and multiple images + Special markers + Raw (downsampled) image data + Really raw data: DCT coefficients + Progress monitoring + Memory management + Memory usage + Library compile-time options + Portability considerations + Notes for MS-DOS implementors + +You should read at least the overview and basic usage sections before trying +to program with the library. The sections on advanced features can be read +if and when you need them. + + +OVERVIEW +======== + +Functions provided by the library +--------------------------------- + +The IJG JPEG library provides C code to read and write JPEG-compressed image +files. The surrounding application program receives or supplies image data a +scanline at a time, using a straightforward uncompressed image format. All +details of color conversion and other preprocessing/postprocessing can be +handled by the library. + +The library includes a substantial amount of code that is not covered by the +JPEG standard but is necessary for typical applications of JPEG. These +functions preprocess the image before JPEG compression or postprocess it after +decompression. They include colorspace conversion, downsampling/upsampling, +and color quantization. The application indirectly selects use of this code +by specifying the format in which it wishes to supply or receive image data. +For example, if colormapped output is requested, then the decompression +library automatically invokes color quantization. + +A wide range of quality vs. speed tradeoffs are possible in JPEG processing, +and even more so in decompression postprocessing. The decompression library +provides multiple implementations that cover most of the useful tradeoffs, +ranging from very-high-quality down to fast-preview operation. On the +compression side we have generally not provided low-quality choices, since +compression is normally less time-critical. It should be understood that the +low-quality modes may not meet the JPEG standard's accuracy requirements; +nonetheless, they are useful for viewers. + +A word about functions *not* provided by the library. We handle a subset of +the ISO JPEG standard; most baseline, extended-sequential, and progressive +JPEG processes are supported. (Our subset includes all features now in common +use.) Unsupported ISO options include: + * Hierarchical storage + * Lossless JPEG + * Arithmetic entropy coding (unsupported for legal reasons) + * DNL marker + * Nonintegral subsampling ratios +We support both 8- and 12-bit data precision, but this is a compile-time +choice rather than a run-time choice; hence it is difficult to use both +precisions in a single application. + +By itself, the library handles only interchange JPEG datastreams --- in +particular the widely used JFIF file format. The library can be used by +surrounding code to process interchange or abbreviated JPEG datastreams that +are embedded in more complex file formats. (For example, this library is +used by the free LIBTIFF library to support JPEG compression in TIFF.) + + +Outline of typical usage +------------------------ + +The rough outline of a JPEG compression operation is: + + Allocate and initialize a JPEG compression object + Specify the destination for the compressed data (eg, a file) + Set parameters for compression, including image size & colorspace + jpeg_start_compress(...); + while (scan lines remain to be written) + jpeg_write_scanlines(...); + jpeg_finish_compress(...); + Release the JPEG compression object + +A JPEG compression object holds parameters and working state for the JPEG +library. We make creation/destruction of the object separate from starting +or finishing compression of an image; the same object can be re-used for a +series of image compression operations. This makes it easy to re-use the +same parameter settings for a sequence of images. Re-use of a JPEG object +also has important implications for processing abbreviated JPEG datastreams, +as discussed later. + +The image data to be compressed is supplied to jpeg_write_scanlines() from +in-memory buffers. If the application is doing file-to-file compression, +reading image data from the source file is the application's responsibility. +The library emits compressed data by calling a "data destination manager", +which typically will write the data into a file; but the application can +provide its own destination manager to do something else. + +Similarly, the rough outline of a JPEG decompression operation is: + + Allocate and initialize a JPEG decompression object + Specify the source of the compressed data (eg, a file) + Call jpeg_read_header() to obtain image info + Set parameters for decompression + jpeg_start_decompress(...); + while (scan lines remain to be read) + jpeg_read_scanlines(...); + jpeg_finish_decompress(...); + Release the JPEG decompression object + +This is comparable to the compression outline except that reading the +datastream header is a separate step. This is helpful because information +about the image's size, colorspace, etc is available when the application +selects decompression parameters. For example, the application can choose an +output scaling ratio that will fit the image into the available screen size. + +The decompression library obtains compressed data by calling a data source +manager, which typically will read the data from a file; but other behaviors +can be obtained with a custom source manager. Decompressed data is delivered +into in-memory buffers passed to jpeg_read_scanlines(). + +It is possible to abort an incomplete compression or decompression operation +by calling jpeg_abort(); or, if you do not need to retain the JPEG object, +simply release it by calling jpeg_destroy(). + +JPEG compression and decompression objects are two separate struct types. +However, they share some common fields, and certain routines such as +jpeg_destroy() can work on either type of object. + +The JPEG library has no static variables: all state is in the compression +or decompression object. Therefore it is possible to process multiple +compression and decompression operations concurrently, using multiple JPEG +objects. + +Both compression and decompression can be done in an incremental memory-to- +memory fashion, if suitable source/destination managers are used. See the +section on "I/O suspension" for more details. + + +BASIC LIBRARY USAGE +=================== + +Data formats +------------ + +Before diving into procedural details, it is helpful to understand the +image data format that the JPEG library expects or returns. + +The standard input image format is a rectangular array of pixels, with each +pixel having the same number of "component" or "sample" values (color +channels). You must specify how many components there are and the colorspace +interpretation of the components. Most applications will use RGB data +(three components per pixel) or grayscale data (one component per pixel). +PLEASE NOTE THAT RGB DATA IS THREE SAMPLES PER PIXEL, GRAYSCALE ONLY ONE. +A remarkable number of people manage to miss this, only to find that their +programs don't work with grayscale JPEG files. + +There is no provision for colormapped input. JPEG files are always full-color +or full grayscale (or sometimes another colorspace such as CMYK). You can +feed in a colormapped image by expanding it to full-color format. However +JPEG often doesn't work very well with source data that has been colormapped, +because of dithering noise. This is discussed in more detail in the JPEG FAQ +and the other references mentioned in the README file. + +Pixels are stored by scanlines, with each scanline running from left to +right. The component values for each pixel are adjacent in the row; for +example, R,G,B,R,G,B,R,G,B,... for 24-bit RGB color. Each scanline is an +array of data type JSAMPLE --- which is typically "unsigned char", unless +you've changed jmorecfg.h. (You can also change the RGB pixel layout, say +to B,G,R order, by modifying jmorecfg.h. But see the restrictions listed in +that file before doing so.) + +A 2-D array of pixels is formed by making a list of pointers to the starts of +scanlines; so the scanlines need not be physically adjacent in memory. Even +if you process just one scanline at a time, you must make a one-element +pointer array to conform to this structure. Pointers to JSAMPLE rows are of +type JSAMPROW, and the pointer to the pointer array is of type JSAMPARRAY. + +The library accepts or supplies one or more complete scanlines per call. +It is not possible to process part of a row at a time. Scanlines are always +processed top-to-bottom. You can process an entire image in one call if you +have it all in memory, but usually it's simplest to process one scanline at +a time. + +For best results, source data values should have the precision specified by +BITS_IN_JSAMPLE (normally 8 bits). For instance, if you choose to compress +data that's only 6 bits/channel, you should left-justify each value in a +byte before passing it to the compressor. If you need to compress data +that has more than 8 bits/channel, compile with BITS_IN_JSAMPLE = 12. +(See "Library compile-time options", later.) + + +The data format returned by the decompressor is the same in all details, +except that colormapped output is supported. (Again, a JPEG file is never +colormapped. But you can ask the decompressor to perform on-the-fly color +quantization to deliver colormapped output.) If you request colormapped +output then the returned data array contains a single JSAMPLE per pixel; +its value is an index into a color map. The color map is represented as +a 2-D JSAMPARRAY in which each row holds the values of one color component, +that is, colormap[i][j] is the value of the i'th color component for pixel +value (map index) j. Note that since the colormap indexes are stored in +JSAMPLEs, the maximum number of colors is limited by the size of JSAMPLE +(ie, at most 256 colors for an 8-bit JPEG library). + + +Compression details +------------------- + +Here we revisit the JPEG compression outline given in the overview. + +1. Allocate and initialize a JPEG compression object. + +A JPEG compression object is a "struct jpeg_compress_struct". (It also has +a bunch of subsidiary structures which are allocated via malloc(), but the +application doesn't control those directly.) This struct can be just a local +variable in the calling routine, if a single routine is going to execute the +whole JPEG compression sequence. Otherwise it can be static or allocated +from malloc(). + +You will also need a structure representing a JPEG error handler. The part +of this that the library cares about is a "struct jpeg_error_mgr". If you +are providing your own error handler, you'll typically want to embed the +jpeg_error_mgr struct in a larger structure; this is discussed later under +"Error handling". For now we'll assume you are just using the default error +handler. The default error handler will print JPEG error/warning messages +on stderr, and it will call exit() if a fatal error occurs. + +You must initialize the error handler structure, store a pointer to it into +the JPEG object's "err" field, and then call jpeg_create_compress() to +initialize the rest of the JPEG object. + +Typical code for this step, if you are using the default error handler, is + + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + ... + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + +jpeg_create_compress allocates a small amount of memory, so it could fail +if you are out of memory. In that case it will exit via the error handler; +that's why the error handler must be initialized first. + + +2. Specify the destination for the compressed data (eg, a file). + +As previously mentioned, the JPEG library delivers compressed data to a +"data destination" module. The library includes one data destination +module which knows how to write to a stdio stream. You can use your own +destination module if you want to do something else, as discussed later. + +If you use the standard destination module, you must open the target stdio +stream beforehand. Typical code for this step looks like: + + FILE * outfile; + ... + if ((outfile = fopen(filename, "wb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + exit(1); + } + jpeg_stdio_dest(&cinfo, outfile); + +where the last line invokes the standard destination module. + +WARNING: it is critical that the binary compressed data be delivered to the +output file unchanged. On non-Unix systems the stdio library may perform +newline translation or otherwise corrupt binary data. To suppress this +behavior, you may need to use a "b" option to fopen (as shown above), or use +setmode() or another routine to put the stdio stream in binary mode. See +cjpeg.c and djpeg.c for code that has been found to work on many systems. + +You can select the data destination after setting other parameters (step 3), +if that's more convenient. You may not change the destination between +calling jpeg_start_compress() and jpeg_finish_compress(). + + +3. Set parameters for compression, including image size & colorspace. + +You must supply information about the source image by setting the following +fields in the JPEG object (cinfo structure): + + image_width Width of image, in pixels + image_height Height of image, in pixels + input_components Number of color channels (samples per pixel) + in_color_space Color space of source image + +The image dimensions are, hopefully, obvious. JPEG supports image dimensions +of 1 to 64K pixels in either direction. The input color space is typically +RGB or grayscale, and input_components is 3 or 1 accordingly. (See "Special +color spaces", later, for more info.) The in_color_space field must be +assigned one of the J_COLOR_SPACE enum constants, typically JCS_RGB or +JCS_GRAYSCALE. + +JPEG has a large number of compression parameters that determine how the +image is encoded. Most applications don't need or want to know about all +these parameters. You can set all the parameters to reasonable defaults by +calling jpeg_set_defaults(); then, if there are particular values you want +to change, you can do so after that. The "Compression parameter selection" +section tells about all the parameters. + +You must set in_color_space correctly before calling jpeg_set_defaults(), +because the defaults depend on the source image colorspace. However the +other three source image parameters need not be valid until you call +jpeg_start_compress(). There's no harm in calling jpeg_set_defaults() more +than once, if that happens to be convenient. + +Typical code for a 24-bit RGB source image is + + cinfo.image_width = Width; /* image width and height, in pixels */ + cinfo.image_height = Height; + cinfo.input_components = 3; /* # of color components per pixel */ + cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ + + jpeg_set_defaults(&cinfo); + /* Make optional parameter settings here */ + + +4. jpeg_start_compress(...); + +After you have established the data destination and set all the necessary +source image info and other parameters, call jpeg_start_compress() to begin +a compression cycle. This will initialize internal state, allocate working +storage, and emit the first few bytes of the JPEG datastream header. + +Typical code: + + jpeg_start_compress(&cinfo, TRUE); + +The "TRUE" parameter ensures that a complete JPEG interchange datastream +will be written. This is appropriate in most cases. If you think you might +want to use an abbreviated datastream, read the section on abbreviated +datastreams, below. + +Once you have called jpeg_start_compress(), you may not alter any JPEG +parameters or other fields of the JPEG object until you have completed +the compression cycle. + + +5. while (scan lines remain to be written) + jpeg_write_scanlines(...); + +Now write all the required image data by calling jpeg_write_scanlines() +one or more times. You can pass one or more scanlines in each call, up +to the total image height. In most applications it is convenient to pass +just one or a few scanlines at a time. The expected format for the passed +data is discussed under "Data formats", above. + +Image data should be written in top-to-bottom scanline order. The JPEG spec +contains some weasel wording about how top and bottom are application-defined +terms (a curious interpretation of the English language...) but if you want +your files to be compatible with everyone else's, you WILL use top-to-bottom +order. If the source data must be read in bottom-to-top order, you can use +the JPEG library's virtual array mechanism to invert the data efficiently. +Examples of this can be found in the sample application cjpeg. + +The library maintains a count of the number of scanlines written so far +in the next_scanline field of the JPEG object. Usually you can just use +this variable as the loop counter, so that the loop test looks like +"while (cinfo.next_scanline < cinfo.image_height)". + +Code for this step depends heavily on the way that you store the source data. +example.c shows the following code for the case of a full-size 2-D source +array containing 3-byte RGB pixels: + + JSAMPROW row_pointer[1]; /* pointer to a single row */ + int row_stride; /* physical row width in buffer */ + + row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ + + while (cinfo.next_scanline < cinfo.image_height) { + row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; + jpeg_write_scanlines(&cinfo, row_pointer, 1); + } + +jpeg_write_scanlines() returns the number of scanlines actually written. +This will normally be equal to the number passed in, so you can usually +ignore the return value. It is different in just two cases: + * If you try to write more scanlines than the declared image height, + the additional scanlines are ignored. + * If you use a suspending data destination manager, output buffer overrun + will cause the compressor to return before accepting all the passed lines. + This feature is discussed under "I/O suspension", below. The normal + stdio destination manager will NOT cause this to happen. +In any case, the return value is the same as the change in the value of +next_scanline. + + +6. jpeg_finish_compress(...); + +After all the image data has been written, call jpeg_finish_compress() to +complete the compression cycle. This step is ESSENTIAL to ensure that the +last bufferload of data is written to the data destination. +jpeg_finish_compress() also releases working memory associated with the JPEG +object. + +Typical code: + + jpeg_finish_compress(&cinfo); + +If using the stdio destination manager, don't forget to close the output +stdio stream (if necessary) afterwards. + +If you have requested a multi-pass operating mode, such as Huffman code +optimization, jpeg_finish_compress() will perform the additional passes using +data buffered by the first pass. In this case jpeg_finish_compress() may take +quite a while to complete. With the default compression parameters, this will +not happen. + +It is an error to call jpeg_finish_compress() before writing the necessary +total number of scanlines. If you wish to abort compression, call +jpeg_abort() as discussed below. + +After completing a compression cycle, you may dispose of the JPEG object +as discussed next, or you may use it to compress another image. In that case +return to step 2, 3, or 4 as appropriate. If you do not change the +destination manager, the new datastream will be written to the same target. +If you do not change any JPEG parameters, the new datastream will be written +with the same parameters as before. Note that you can change the input image +dimensions freely between cycles, but if you change the input colorspace, you +should call jpeg_set_defaults() to adjust for the new colorspace; and then +you'll need to repeat all of step 3. + + +7. Release the JPEG compression object. + +When you are done with a JPEG compression object, destroy it by calling +jpeg_destroy_compress(). This will free all subsidiary memory (regardless of +the previous state of the object). Or you can call jpeg_destroy(), which +works for either compression or decompression objects --- this may be more +convenient if you are sharing code between compression and decompression +cases. (Actually, these routines are equivalent except for the declared type +of the passed pointer. To avoid gripes from ANSI C compilers, jpeg_destroy() +should be passed a j_common_ptr.) + +If you allocated the jpeg_compress_struct structure from malloc(), freeing +it is your responsibility --- jpeg_destroy() won't. Ditto for the error +handler structure. + +Typical code: + + jpeg_destroy_compress(&cinfo); + + +8. Aborting. + +If you decide to abort a compression cycle before finishing, you can clean up +in either of two ways: + +* If you don't need the JPEG object any more, just call + jpeg_destroy_compress() or jpeg_destroy() to release memory. This is + legitimate at any point after calling jpeg_create_compress() --- in fact, + it's safe even if jpeg_create_compress() fails. + +* If you want to re-use the JPEG object, call jpeg_abort_compress(), or call + jpeg_abort() which works on both compression and decompression objects. + This will return the object to an idle state, releasing any working memory. + jpeg_abort() is allowed at any time after successful object creation. + +Note that cleaning up the data destination, if required, is your +responsibility; neither of these routines will call term_destination(). +(See "Compressed data handling", below, for more about that.) + +jpeg_destroy() and jpeg_abort() are the only safe calls to make on a JPEG +object that has reported an error by calling error_exit (see "Error handling" +for more info). The internal state of such an object is likely to be out of +whack. Either of these two routines will return the object to a known state. + + +Decompression details +--------------------- + +Here we revisit the JPEG decompression outline given in the overview. + +1. Allocate and initialize a JPEG decompression object. + +This is just like initialization for compression, as discussed above, +except that the object is a "struct jpeg_decompress_struct" and you +call jpeg_create_decompress(). Error handling is exactly the same. + +Typical code: + + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; + ... + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + +(Both here and in the IJG code, we usually use variable name "cinfo" for +both compression and decompression objects.) + + +2. Specify the source of the compressed data (eg, a file). + +As previously mentioned, the JPEG library reads compressed data from a "data +source" module. The library includes one data source module which knows how +to read from a stdio stream. You can use your own source module if you want +to do something else, as discussed later. + +If you use the standard source module, you must open the source stdio stream +beforehand. Typical code for this step looks like: + + FILE * infile; + ... + if ((infile = fopen(filename, "rb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + exit(1); + } + jpeg_stdio_src(&cinfo, infile); + +where the last line invokes the standard source module. + +WARNING: it is critical that the binary compressed data be read unchanged. +On non-Unix systems the stdio library may perform newline translation or +otherwise corrupt binary data. To suppress this behavior, you may need to use +a "b" option to fopen (as shown above), or use setmode() or another routine to +put the stdio stream in binary mode. See cjpeg.c and djpeg.c for code that +has been found to work on many systems. + +You may not change the data source between calling jpeg_read_header() and +jpeg_finish_decompress(). If you wish to read a series of JPEG images from +a single source file, you should repeat the jpeg_read_header() to +jpeg_finish_decompress() sequence without reinitializing either the JPEG +object or the data source module; this prevents buffered input data from +being discarded. + + +3. Call jpeg_read_header() to obtain image info. + +Typical code for this step is just + + jpeg_read_header(&cinfo, TRUE); + +This will read the source datastream header markers, up to the beginning +of the compressed data proper. On return, the image dimensions and other +info have been stored in the JPEG object. The application may wish to +consult this information before selecting decompression parameters. + +More complex code is necessary if + * A suspending data source is used --- in that case jpeg_read_header() + may return before it has read all the header data. See "I/O suspension", + below. The normal stdio source manager will NOT cause this to happen. + * Abbreviated JPEG files are to be processed --- see the section on + abbreviated datastreams. Standard applications that deal only in + interchange JPEG files need not be concerned with this case either. + +It is permissible to stop at this point if you just wanted to find out the +image dimensions and other header info for a JPEG file. In that case, +call jpeg_destroy() when you are done with the JPEG object, or call +jpeg_abort() to return it to an idle state before selecting a new data +source and reading another header. + + +4. Set parameters for decompression. + +jpeg_read_header() sets appropriate default decompression parameters based on +the properties of the image (in particular, its colorspace). However, you +may well want to alter these defaults before beginning the decompression. +For example, the default is to produce full color output from a color file. +If you want colormapped output you must ask for it. Other options allow the +returned image to be scaled and allow various speed/quality tradeoffs to be +selected. "Decompression parameter selection", below, gives details. + +If the defaults are appropriate, nothing need be done at this step. + +Note that all default values are set by each call to jpeg_read_header(). +If you reuse a decompression object, you cannot expect your parameter +settings to be preserved across cycles, as you can for compression. +You must set desired parameter values each time. + + +5. jpeg_start_decompress(...); + +Once the parameter values are satisfactory, call jpeg_start_decompress() to +begin decompression. This will initialize internal state, allocate working +memory, and prepare for returning data. + +Typical code is just + + jpeg_start_decompress(&cinfo); + +If you have requested a multi-pass operating mode, such as 2-pass color +quantization, jpeg_start_decompress() will do everything needed before data +output can begin. In this case jpeg_start_decompress() may take quite a while +to complete. With a single-scan (non progressive) JPEG file and default +decompression parameters, this will not happen; jpeg_start_decompress() will +return quickly. + +After this call, the final output image dimensions, including any requested +scaling, are available in the JPEG object; so is the selected colormap, if +colormapped output has been requested. Useful fields include + + output_width image width and height, as scaled + output_height + out_color_components # of color components in out_color_space + output_components # of color components returned per pixel + colormap the selected colormap, if any + actual_number_of_colors number of entries in colormap + +output_components is 1 (a colormap index) when quantizing colors; otherwise it +equals out_color_components. It is the number of JSAMPLE values that will be +emitted per pixel in the output arrays. + +Typically you will need to allocate data buffers to hold the incoming image. +You will need output_width * output_components JSAMPLEs per scanline in your +output buffer, and a total of output_height scanlines will be returned. + +Note: if you are using the JPEG library's internal memory manager to allocate +data buffers (as djpeg does), then the manager's protocol requires that you +request large buffers *before* calling jpeg_start_decompress(). This is a +little tricky since the output_XXX fields are not normally valid then. You +can make them valid by calling jpeg_calc_output_dimensions() after setting the +relevant parameters (scaling, output color space, and quantization flag). + + +6. while (scan lines remain to be read) + jpeg_read_scanlines(...); + +Now you can read the decompressed image data by calling jpeg_read_scanlines() +one or more times. At each call, you pass in the maximum number of scanlines +to be read (ie, the height of your working buffer); jpeg_read_scanlines() +will return up to that many lines. The return value is the number of lines +actually read. The format of the returned data is discussed under "Data +formats", above. Don't forget that grayscale and color JPEGs will return +different data formats! + +Image data is returned in top-to-bottom scanline order. If you must write +out the image in bottom-to-top order, you can use the JPEG library's virtual +array mechanism to invert the data efficiently. Examples of this can be +found in the sample application djpeg. + +The library maintains a count of the number of scanlines returned so far +in the output_scanline field of the JPEG object. Usually you can just use +this variable as the loop counter, so that the loop test looks like +"while (cinfo.output_scanline < cinfo.output_height)". (Note that the test +should NOT be against image_height, unless you never use scaling. The +image_height field is the height of the original unscaled image.) +The return value always equals the change in the value of output_scanline. + +If you don't use a suspending data source, it is safe to assume that +jpeg_read_scanlines() reads at least one scanline per call, until the +bottom of the image has been reached. + +If you use a buffer larger than one scanline, it is NOT safe to assume that +jpeg_read_scanlines() fills it. (The current implementation returns only a +few scanlines per call, no matter how large a buffer you pass.) So you must +always provide a loop that calls jpeg_read_scanlines() repeatedly until the +whole image has been read. + + +7. jpeg_finish_decompress(...); + +After all the image data has been read, call jpeg_finish_decompress() to +complete the decompression cycle. This causes working memory associated +with the JPEG object to be released. + +Typical code: + + jpeg_finish_decompress(&cinfo); + +If using the stdio source manager, don't forget to close the source stdio +stream if necessary. + +It is an error to call jpeg_finish_decompress() before reading the correct +total number of scanlines. If you wish to abort decompression, call +jpeg_abort() as discussed below. + +After completing a decompression cycle, you may dispose of the JPEG object as +discussed next, or you may use it to decompress another image. In that case +return to step 2 or 3 as appropriate. If you do not change the source +manager, the next image will be read from the same source. + + +8. Release the JPEG decompression object. + +When you are done with a JPEG decompression object, destroy it by calling +jpeg_destroy_decompress() or jpeg_destroy(). The previous discussion of +destroying compression objects applies here too. + +Typical code: + + jpeg_destroy_decompress(&cinfo); + + +9. Aborting. + +You can abort a decompression cycle by calling jpeg_destroy_decompress() or +jpeg_destroy() if you don't need the JPEG object any more, or +jpeg_abort_decompress() or jpeg_abort() if you want to reuse the object. +The previous discussion of aborting compression cycles applies here too. + + +Mechanics of usage: include files, linking, etc +----------------------------------------------- + +Applications using the JPEG library should include the header file jpeglib.h +to obtain declarations of data types and routines. Before including +jpeglib.h, include system headers that define at least the typedefs FILE and +size_t. On ANSI-conforming systems, including is sufficient; on +older Unix systems, you may need to define size_t. + +If the application needs to refer to individual JPEG library error codes, also +include jerror.h to define those symbols. + +jpeglib.h indirectly includes the files jconfig.h and jmorecfg.h. If you are +installing the JPEG header files in a system directory, you will want to +install all four files: jpeglib.h, jerror.h, jconfig.h, jmorecfg.h. + +The most convenient way to include the JPEG code into your executable program +is to prepare a library file ("libjpeg.a", or a corresponding name on non-Unix +machines) and reference it at your link step. If you use only half of the +library (only compression or only decompression), only that much code will be +included from the library, unless your linker is hopelessly brain-damaged. +The supplied makefiles build libjpeg.a automatically (see install.doc). + +While you can build the JPEG library as a shared library if the whim strikes +you, we don't really recommend it. The trouble with shared libraries is that +at some point you'll probably try to substitute a new version of the library +without recompiling the calling applications. That generally doesn't work +because the parameter struct declarations usually change with each new +version. In other words, the library's API is *not* guaranteed binary +compatible across versions; we only try to ensure source-code compatibility. +(In hindsight, it might have been smarter to hide the parameter structs from +applications and introduce a ton of access functions instead. Too late now, +however.) + +On some systems your application may need to set up a signal handler to ensure +that temporary files are deleted if the program is interrupted. This is most +critical if you are on MS-DOS and use the jmemdos.c memory manager back end; +it will try to grab extended memory for temp files, and that space will NOT be +freed automatically. See cjpeg.c or djpeg.c for an example signal handler. + +It may be worth pointing out that the core JPEG library does not actually +require the stdio library: only the default source/destination managers and +error handler need it. You can use the library in a stdio-less environment +if you replace those modules and use jmemnobs.c (or another memory manager of +your own devising). More info about the minimum system library requirements +may be found in jinclude.h. + + +ADVANCED FEATURES +================= + +Compression parameter selection +------------------------------- + +This section describes all the optional parameters you can set for JPEG +compression, as well as the "helper" routines provided to assist in this +task. Proper setting of some parameters requires detailed understanding +of the JPEG standard; if you don't know what a parameter is for, it's best +not to mess with it! See REFERENCES in the README file for pointers to +more info about JPEG. + +It's a good idea to call jpeg_set_defaults() first, even if you plan to set +all the parameters; that way your code is more likely to work with future JPEG +libraries that have additional parameters. For the same reason, we recommend +you use a helper routine where one is provided, in preference to twiddling +cinfo fields directly. + +The helper routines are: + +jpeg_set_defaults (j_compress_ptr cinfo) + This routine sets all JPEG parameters to reasonable defaults, using + only the input image's color space (field in_color_space, which must + already be set in cinfo). Many applications will only need to use + this routine and perhaps jpeg_set_quality(). + +jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) + Sets the JPEG file's colorspace (field jpeg_color_space) as specified, + and sets other color-space-dependent parameters appropriately. See + "Special color spaces", below, before using this. A large number of + parameters, including all per-component parameters, are set by this + routine; if you want to twiddle individual parameters you should call + jpeg_set_colorspace() before rather than after. + +jpeg_default_colorspace (j_compress_ptr cinfo) + Selects an appropriate JPEG colorspace based on cinfo->in_color_space, + and calls jpeg_set_colorspace(). This is actually a subroutine of + jpeg_set_defaults(). It's broken out in case you want to change + just the colorspace-dependent JPEG parameters. + +jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) + Constructs JPEG quantization tables appropriate for the indicated + quality setting. The quality value is expressed on the 0..100 scale + recommended by IJG (cjpeg's "-quality" switch uses this routine). + Note that the exact mapping from quality values to tables may change + in future IJG releases as more is learned about DCT quantization. + If the force_baseline parameter is TRUE, then the quantization table + entries are constrained to the range 1..255 for full JPEG baseline + compatibility. In the current implementation, this only makes a + difference for quality settings below 25, and it effectively prevents + very small/low quality files from being generated. The IJG decoder + is capable of reading the non-baseline files generated at low quality + settings when force_baseline is FALSE, but other decoders may not be. + +jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, + boolean force_baseline) + Same as jpeg_set_quality() except that the generated tables are the + sample tables given in the JPEC spec section K.1, multiplied by the + specified scale factor (which is expressed as a percentage; thus + scale_factor = 100 reproduces the spec's tables). Note that larger + scale factors give lower quality. This entry point is useful for + conforming to the Adobe PostScript DCT conventions, but we do not + recommend linear scaling as a user-visible quality scale otherwise. + force_baseline again constrains the computed table entries to 1..255. + +int jpeg_quality_scaling (int quality) + Converts a value on the IJG-recommended quality scale to a linear + scaling percentage. Note that this routine may change or go away + in future releases --- IJG may choose to adopt a scaling method that + can't be expressed as a simple scalar multiplier, in which case the + premise of this routine collapses. Caveat user. + +jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, + const unsigned int *basic_table, + int scale_factor, boolean force_baseline) + Allows an arbitrary quantization table to be created. which_tbl + indicates which table slot to fill. basic_table points to an array + of 64 unsigned ints given in normal array order. These values are + multiplied by scale_factor/100 and then clamped to the range 1..65535 + (or to 1..255 if force_baseline is TRUE). + CAUTION: prior to library version 6a, jpeg_add_quant_table expected + the basic table to be given in JPEG zigzag order. If you need to + write code that works with either older or newer versions of this + routine, you must check the library version number. Something like + "#if JPEG_LIB_VERSION >= 61" is the right test. + +jpeg_simple_progression (j_compress_ptr cinfo) + Generates a default scan script for writing a progressive-JPEG file. + This is the recommended method of creating a progressive file, + unless you want to make a custom scan sequence. You must ensure that + the JPEG color space is set correctly before calling this routine. + + +Compression parameters (cinfo fields) include: + +J_DCT_METHOD dct_method + Selects the algorithm used for the DCT step. Choices are: + JDCT_ISLOW: slow but accurate integer algorithm + JDCT_IFAST: faster, less accurate integer method + JDCT_FLOAT: floating-point method + JDCT_DEFAULT: default method (normally JDCT_ISLOW) + JDCT_FASTEST: fastest method (normally JDCT_IFAST) + The FLOAT method is very slightly more accurate than the ISLOW method, + but may give different results on different machines due to varying + roundoff behavior. The integer methods should give the same results + on all machines. On machines with sufficiently fast FP hardware, the + floating-point method may also be the fastest. The IFAST method is + considerably less accurate than the other two; its use is not + recommended if high quality is a concern. JDCT_DEFAULT and + JDCT_FASTEST are macros configurable by each installation. + +J_COLOR_SPACE jpeg_color_space +int num_components + The JPEG color space and corresponding number of components; see + "Special color spaces", below, for more info. We recommend using + jpeg_set_color_space() if you want to change these. + +boolean optimize_coding + TRUE causes the compressor to compute optimal Huffman coding tables + for the image. This requires an extra pass over the data and + therefore costs a good deal of space and time. The default is + FALSE, which tells the compressor to use the supplied or default + Huffman tables. In most cases optimal tables save only a few percent + of file size compared to the default tables. Note that when this is + TRUE, you need not supply Huffman tables at all, and any you do + supply will be overwritten. + +unsigned int restart_interval +int restart_in_rows + To emit restart markers in the JPEG file, set one of these nonzero. + Set restart_interval to specify the exact interval in MCU blocks. + Set restart_in_rows to specify the interval in MCU rows. (If + restart_in_rows is not 0, then restart_interval is set after the + image width in MCUs is computed.) Defaults are zero (no restarts). + One restart marker per MCU row is often a good choice. + NOTE: the overhead of restart markers is higher in grayscale JPEG + files than in color files, and MUCH higher in progressive JPEGs. + If you use restarts, you may want to use larger intervals in those + cases. + +const jpeg_scan_info * scan_info +int num_scans + By default, scan_info is NULL; this causes the compressor to write a + single-scan sequential JPEG file. If not NULL, scan_info points to + an array of scan definition records of length num_scans. The + compressor will then write a JPEG file having one scan for each scan + definition record. This is used to generate noninterleaved or + progressive JPEG files. The library checks that the scan array + defines a valid JPEG scan sequence. (jpeg_simple_progression creates + a suitable scan definition array for progressive JPEG.) This is + discussed further under "Progressive JPEG support". + +int smoothing_factor + If non-zero, the input image is smoothed; the value should be 1 for + minimal smoothing to 100 for maximum smoothing. Consult jcsample.c + for details of the smoothing algorithm. The default is zero. + +boolean write_JFIF_header + If TRUE, a JFIF APP0 marker is emitted. jpeg_set_defaults() and + jpeg_set_colorspace() set this TRUE if a JFIF-legal JPEG color space + (ie, YCbCr or grayscale) is selected, otherwise FALSE. + +UINT8 JFIF_major_version +UINT8 JFIF_minor_version + The version number to be written into the JFIF marker. + jpeg_set_defaults() initializes the version to 1.01 (major=minor=1). + You should set it to 1.02 (major=1, minor=2) if you plan to write + any JFIF 1.02 extension markers. + +UINT8 density_unit +UINT16 X_density +UINT16 Y_density + The resolution information to be written into the JFIF marker; + not used otherwise. density_unit may be 0 for unknown, + 1 for dots/inch, or 2 for dots/cm. The default values are 0,1,1 + indicating square pixels of unknown size. + +boolean write_Adobe_marker + If TRUE, an Adobe APP14 marker is emitted. jpeg_set_defaults() and + jpeg_set_colorspace() set this TRUE if JPEG color space RGB, CMYK, + or YCCK is selected, otherwise FALSE. It is generally a bad idea + to set both write_JFIF_header and write_Adobe_marker. In fact, + you probably shouldn't change the default settings at all --- the + default behavior ensures that the JPEG file's color space can be + recognized by the decoder. + +JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS] + Pointers to coefficient quantization tables, one per table slot, + or NULL if no table is defined for a slot. Usually these should + be set via one of the above helper routines; jpeg_add_quant_table() + is general enough to define any quantization table. The other + routines will set up table slot 0 for luminance quality and table + slot 1 for chrominance. + +JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS] +JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS] + Pointers to Huffman coding tables, one per table slot, or NULL if + no table is defined for a slot. Slots 0 and 1 are filled with the + JPEG sample tables by jpeg_set_defaults(). If you need to allocate + more table structures, jpeg_alloc_huff_table() may be used. + Note that optimal Huffman tables can be computed for an image + by setting optimize_coding, as discussed above; there's seldom + any need to mess with providing your own Huffman tables. + +There are some additional cinfo fields which are not documented here +because you currently can't change them; for example, you can't set +arith_code TRUE because arithmetic coding is unsupported. + + +Per-component parameters are stored in the struct cinfo.comp_info[i] for +component number i. Note that components here refer to components of the +JPEG color space, *not* the source image color space. A suitably large +comp_info[] array is allocated by jpeg_set_defaults(); if you choose not +to use that routine, it's up to you to allocate the array. + +int component_id + The one-byte identifier code to be recorded in the JPEG file for + this component. For the standard color spaces, we recommend you + leave the default values alone. + +int h_samp_factor +int v_samp_factor + Horizontal and vertical sampling factors for the component; must + be 1..4 according to the JPEG standard. Note that larger sampling + factors indicate a higher-resolution component; many people find + this behavior quite unintuitive. The default values are 2,2 for + luminance components and 1,1 for chrominance components, except + for grayscale where 1,1 is used. + +int quant_tbl_no + Quantization table number for component. The default value is + 0 for luminance components and 1 for chrominance components. + +int dc_tbl_no +int ac_tbl_no + DC and AC entropy coding table numbers. The default values are + 0 for luminance components and 1 for chrominance components. + +int component_index + Must equal the component's index in comp_info[]. (Beginning in + release v6, the compressor library will fill this in automatically; + you don't have to.) + + +Decompression parameter selection +--------------------------------- + +Decompression parameter selection is somewhat simpler than compression +parameter selection, since all of the JPEG internal parameters are +recorded in the source file and need not be supplied by the application. +(Unless you are working with abbreviated files, in which case see +"Abbreviated datastreams", below.) Decompression parameters control +the postprocessing done on the image to deliver it in a format suitable +for the application's use. Many of the parameters control speed/quality +tradeoffs, in which faster decompression may be obtained at the price of +a poorer-quality image. The defaults select the highest quality (slowest) +processing. + +The following fields in the JPEG object are set by jpeg_read_header() and +may be useful to the application in choosing decompression parameters: + +JDIMENSION image_width Width and height of image +JDIMENSION image_height +int num_components Number of color components +J_COLOR_SPACE jpeg_color_space Colorspace of image +boolean saw_JFIF_marker TRUE if a JFIF APP0 marker was seen + UINT8 JFIF_major_version Version information from JFIF marker + UINT8 JFIF_minor_version + UINT8 density_unit Resolution data from JFIF marker + UINT16 X_density + UINT16 Y_density +boolean saw_Adobe_marker TRUE if an Adobe APP14 marker was seen + UINT8 Adobe_transform Color transform code from Adobe marker + +The JPEG color space, unfortunately, is something of a guess since the JPEG +standard proper does not provide a way to record it. In practice most files +adhere to the JFIF or Adobe conventions, and the decoder will recognize these +correctly. See "Special color spaces", below, for more info. + + +The decompression parameters that determine the basic properties of the +returned image are: + +J_COLOR_SPACE out_color_space + Output color space. jpeg_read_header() sets an appropriate default + based on jpeg_color_space; typically it will be RGB or grayscale. + The application can change this field to request output in a different + colorspace. For example, set it to JCS_GRAYSCALE to get grayscale + output from a color file. (This is useful for previewing: grayscale + output is faster than full color since the color components need not + be processed.) Note that not all possible color space transforms are + currently implemented; you may need to extend jdcolor.c if you want an + unusual conversion. + +unsigned int scale_num, scale_denom + Scale the image by the fraction scale_num/scale_denom. Default is + 1/1, or no scaling. Currently, the only supported scaling ratios + are 1/1, 1/2, 1/4, and 1/8. (The library design allows for arbitrary + scaling ratios but this is not likely to be implemented any time soon.) + Smaller scaling ratios permit significantly faster decoding since + fewer pixels need be processed and a simpler IDCT method can be used. + +boolean quantize_colors + If set TRUE, colormapped output will be delivered. Default is FALSE, + meaning that full-color output will be delivered. + +The next three parameters are relevant only if quantize_colors is TRUE. + +int desired_number_of_colors + Maximum number of colors to use in generating a library-supplied color + map (the actual number of colors is returned in a different field). + Default 256. Ignored when the application supplies its own color map. + +boolean two_pass_quantize + If TRUE, an extra pass over the image is made to select a custom color + map for the image. This usually looks a lot better than the one-size- + fits-all colormap that is used otherwise. Default is TRUE. Ignored + when the application supplies its own color map. + +J_DITHER_MODE dither_mode + Selects color dithering method. Supported values are: + JDITHER_NONE no dithering: fast, very low quality + JDITHER_ORDERED ordered dither: moderate speed and quality + JDITHER_FS Floyd-Steinberg dither: slow, high quality + Default is JDITHER_FS. (At present, ordered dither is implemented + only in the single-pass, standard-colormap case. If you ask for + ordered dither when two_pass_quantize is TRUE or when you supply + an external color map, you'll get F-S dithering.) + +When quantize_colors is TRUE, the target color map is described by the next +two fields. colormap is set to NULL by jpeg_read_header(). The application +can supply a color map by setting colormap non-NULL and setting +actual_number_of_colors to the map size. Otherwise, jpeg_start_decompress() +selects a suitable color map and sets these two fields itself. +[Implementation restriction: at present, an externally supplied colormap is +only accepted for 3-component output color spaces.] + +JSAMPARRAY colormap + The color map, represented as a 2-D pixel array of out_color_components + rows and actual_number_of_colors columns. Ignored if not quantizing. + CAUTION: if the JPEG library creates its own colormap, the storage + pointed to by this field is released by jpeg_finish_decompress(). + Copy the colormap somewhere else first, if you want to save it. + +int actual_number_of_colors + The number of colors in the color map. + +Additional decompression parameters that the application may set include: + +J_DCT_METHOD dct_method + Selects the algorithm used for the DCT step. Choices are the same + as described above for compression. + +boolean do_fancy_upsampling + If TRUE, do careful upsampling of chroma components. If FALSE, + a faster but sloppier method is used. Default is TRUE. The visual + impact of the sloppier method is often very small. + +boolean do_block_smoothing + If TRUE, interblock smoothing is applied in early stages of decoding + progressive JPEG files; if FALSE, not. Default is TRUE. Early + progression stages look "fuzzy" with smoothing, "blocky" without. + In any case, block smoothing ceases to be applied after the first few + AC coefficients are known to full accuracy, so it is relevant only + when using buffered-image mode for progressive images. + +boolean enable_1pass_quant +boolean enable_external_quant +boolean enable_2pass_quant + These are significant only in buffered-image mode, which is + described in its own section below. + + +The output image dimensions are given by the following fields. These are +computed from the source image dimensions and the decompression parameters +by jpeg_start_decompress(). You can also call jpeg_calc_output_dimensions() +to obtain the values that will result from the current parameter settings. +This can be useful if you are trying to pick a scaling ratio that will get +close to a desired target size. It's also important if you are using the +JPEG library's memory manager to allocate output buffer space, because you +are supposed to request such buffers *before* jpeg_start_decompress(). + +JDIMENSION output_width Actual dimensions of output image. +JDIMENSION output_height +int out_color_components Number of color components in out_color_space. +int output_components Number of color components returned. +int rec_outbuf_height Recommended height of scanline buffer. + +When quantizing colors, output_components is 1, indicating a single color map +index per pixel. Otherwise it equals out_color_components. The output arrays +are required to be output_width * output_components JSAMPLEs wide. + +rec_outbuf_height is the recommended minimum height (in scanlines) of the +buffer passed to jpeg_read_scanlines(). If the buffer is smaller, the +library will still work, but time will be wasted due to unnecessary data +copying. In high-quality modes, rec_outbuf_height is always 1, but some +faster, lower-quality modes set it to larger values (typically 2 to 4). +If you are going to ask for a high-speed processing mode, you may as well +go to the trouble of honoring rec_outbuf_height so as to avoid data copying. +(An output buffer larger than rec_outbuf_height lines is OK, but won't +provide any material speed improvement over that height.) + + +Special color spaces +-------------------- + +The JPEG standard itself is "color blind" and doesn't specify any particular +color space. It is customary to convert color data to a luminance/chrominance +color space before compressing, since this permits greater compression. The +existing de-facto JPEG file format standards specify YCbCr or grayscale data +(JFIF), or grayscale, RGB, YCbCr, CMYK, or YCCK (Adobe). For special +applications such as multispectral images, other color spaces can be used, +but it must be understood that such files will be unportable. + +The JPEG library can handle the most common colorspace conversions (namely +RGB <=> YCbCr and CMYK <=> YCCK). It can also deal with data of an unknown +color space, passing it through without conversion. If you deal extensively +with an unusual color space, you can easily extend the library to understand +additional color spaces and perform appropriate conversions. + +For compression, the source data's color space is specified by field +in_color_space. This is transformed to the JPEG file's color space given +by jpeg_color_space. jpeg_set_defaults() chooses a reasonable JPEG color +space depending on in_color_space, but you can override this by calling +jpeg_set_colorspace(). Of course you must select a supported transformation. +jccolor.c currently supports the following transformations: + RGB => YCbCr + RGB => GRAYSCALE + YCbCr => GRAYSCALE + CMYK => YCCK +plus the null transforms: GRAYSCALE => GRAYSCALE, RGB => RGB, +YCbCr => YCbCr, CMYK => CMYK, YCCK => YCCK, and UNKNOWN => UNKNOWN. + +The de-facto file format standards (JFIF and Adobe) specify APPn markers that +indicate the color space of the JPEG file. It is important to ensure that +these are written correctly, or omitted if the JPEG file's color space is not +one of the ones supported by the de-facto standards. jpeg_set_colorspace() +will set the compression parameters to include or omit the APPn markers +properly, so long as it is told the truth about the JPEG color space. +For example, if you are writing some random 3-component color space without +conversion, don't try to fake out the library by setting in_color_space and +jpeg_color_space to JCS_YCbCr; use JCS_UNKNOWN. You may want to write an +APPn marker of your own devising to identify the colorspace --- see "Special +markers", below. + +When told that the color space is UNKNOWN, the library will default to using +luminance-quality compression parameters for all color components. You may +well want to change these parameters. See the source code for +jpeg_set_colorspace(), in jcparam.c, for details. + +For decompression, the JPEG file's color space is given in jpeg_color_space, +and this is transformed to the output color space out_color_space. +jpeg_read_header's setting of jpeg_color_space can be relied on if the file +conforms to JFIF or Adobe conventions, but otherwise it is no better than a +guess. If you know the JPEG file's color space for certain, you can override +jpeg_read_header's guess by setting jpeg_color_space. jpeg_read_header also +selects a default output color space based on (its guess of) jpeg_color_space; +set out_color_space to override this. Again, you must select a supported +transformation. jdcolor.c currently supports + YCbCr => GRAYSCALE + YCbCr => RGB + GRAYSCALE => RGB + YCCK => CMYK +as well as the null transforms. (Since GRAYSCALE=>RGB is provided, an +application can force grayscale JPEGs to look like color JPEGs if it only +wants to handle one case.) + +The two-pass color quantizer, jquant2.c, is specialized to handle RGB data +(it weights distances appropriately for RGB colors). You'll need to modify +the code if you want to use it for non-RGB output color spaces. Note that +jquant2.c is used to map to an application-supplied colormap as well as for +the normal two-pass colormap selection process. + +CAUTION: it appears that Adobe Photoshop writes inverted data in CMYK JPEG +files: 0 represents 100% ink coverage, rather than 0% ink as you'd expect. +This is arguably a bug in Photoshop, but if you need to work with Photoshop +CMYK files, you will have to deal with it in your application. We cannot +"fix" this in the library by inverting the data during the CMYK<=>YCCK +transform, because that would break other applications, notably Ghostscript. +Photoshop versions prior to 3.0 write EPS files containing JPEG-encoded CMYK +data in the same inverted-YCCK representation used in bare JPEG files, but +the surrounding PostScript code performs an inversion using the PS image +operator. I am told that Photoshop 3.0 will write uninverted YCCK in +EPS/JPEG files, and will omit the PS-level inversion. (But the data +polarity used in bare JPEG files will not change in 3.0.) In either case, +the JPEG library must not invert the data itself, or else Ghostscript would +read these EPS files incorrectly. + + +Error handling +-------------- + +When the default error handler is used, any error detected inside the JPEG +routines will cause a message to be printed on stderr, followed by exit(). +You can supply your own error handling routines to override this behavior +and to control the treatment of nonfatal warnings and trace/debug messages. +The file example.c illustrates the most common case, which is to have the +application regain control after an error rather than exiting. + +The JPEG library never writes any message directly; it always goes through +the error handling routines. Three classes of messages are recognized: + * Fatal errors: the library cannot continue. + * Warnings: the library can continue, but the data is corrupt, and a + damaged output image is likely to result. + * Trace/informational messages. These come with a trace level indicating + the importance of the message; you can control the verbosity of the + program by adjusting the maximum trace level that will be displayed. + +You may, if you wish, simply replace the entire JPEG error handling module +(jerror.c) with your own code. However, you can avoid code duplication by +only replacing some of the routines depending on the behavior you need. +This is accomplished by calling jpeg_std_error() as usual, but then overriding +some of the method pointers in the jpeg_error_mgr struct, as illustrated by +example.c. + +All of the error handling routines will receive a pointer to the JPEG object +(a j_common_ptr which points to either a jpeg_compress_struct or a +jpeg_decompress_struct; if you need to tell which, test the is_decompressor +field). This struct includes a pointer to the error manager struct in its +"err" field. Frequently, custom error handler routines will need to access +additional data which is not known to the JPEG library or the standard error +handler. The most convenient way to do this is to embed either the JPEG +object or the jpeg_error_mgr struct in a larger structure that contains +additional fields; then casting the passed pointer provides access to the +additional fields. Again, see example.c for one way to do it. (Beginning +with IJG version 6b, there is also a void pointer "client_data" in each +JPEG object, which the application can also use to find related data. +The library does not touch client_data at all.) + +The individual methods that you might wish to override are: + +error_exit (j_common_ptr cinfo) + Receives control for a fatal error. Information sufficient to + generate the error message has been stored in cinfo->err; call + output_message to display it. Control must NOT return to the caller; + generally this routine will exit() or longjmp() somewhere. + Typically you would override this routine to get rid of the exit() + default behavior. Note that if you continue processing, you should + clean up the JPEG object with jpeg_abort() or jpeg_destroy(). + +output_message (j_common_ptr cinfo) + Actual output of any JPEG message. Override this to send messages + somewhere other than stderr. Note that this method does not know + how to generate a message, only where to send it. + +format_message (j_common_ptr cinfo, char * buffer) + Constructs a readable error message string based on the error info + stored in cinfo->err. This method is called by output_message. Few + applications should need to override this method. One possible + reason for doing so is to implement dynamic switching of error message + language. + +emit_message (j_common_ptr cinfo, int msg_level) + Decide whether or not to emit a warning or trace message; if so, + calls output_message. The main reason for overriding this method + would be to abort on warnings. msg_level is -1 for warnings, + 0 and up for trace messages. + +Only error_exit() and emit_message() are called from the rest of the JPEG +library; the other two are internal to the error handler. + +The actual message texts are stored in an array of strings which is pointed to +by the field err->jpeg_message_table. The messages are numbered from 0 to +err->last_jpeg_message, and it is these code numbers that are used in the +JPEG library code. You could replace the message texts (for instance, with +messages in French or German) by changing the message table pointer. See +jerror.h for the default texts. CAUTION: this table will almost certainly +change or grow from one library version to the next. + +It may be useful for an application to add its own message texts that are +handled by the same mechanism. The error handler supports a second "add-on" +message table for this purpose. To define an addon table, set the pointer +err->addon_message_table and the message numbers err->first_addon_message and +err->last_addon_message. If you number the addon messages beginning at 1000 +or so, you won't have to worry about conflicts with the library's built-in +messages. See the sample applications cjpeg/djpeg for an example of using +addon messages (the addon messages are defined in cderror.h). + +Actual invocation of the error handler is done via macros defined in jerror.h: + ERREXITn(...) for fatal errors + WARNMSn(...) for corrupt-data warnings + TRACEMSn(...) for trace and informational messages. +These macros store the message code and any additional parameters into the +error handler struct, then invoke the error_exit() or emit_message() method. +The variants of each macro are for varying numbers of additional parameters. +The additional parameters are inserted into the generated message using +standard printf() format codes. + +See jerror.h and jerror.c for further details. + + +Compressed data handling (source and destination managers) +---------------------------------------------------------- + +The JPEG compression library sends its compressed data to a "destination +manager" module. The default destination manager just writes the data to a +stdio stream, but you can provide your own manager to do something else. +Similarly, the decompression library calls a "source manager" to obtain the +compressed data; you can provide your own source manager if you want the data +to come from somewhere other than a stdio stream. + +In both cases, compressed data is processed a bufferload at a time: the +destination or source manager provides a work buffer, and the library invokes +the manager only when the buffer is filled or emptied. (You could define a +one-character buffer to force the manager to be invoked for each byte, but +that would be rather inefficient.) The buffer's size and location are +controlled by the manager, not by the library. For example, if you desired to +decompress a JPEG datastream that was all in memory, you could just make the +buffer pointer and length point to the original data in memory. Then the +buffer-reload procedure would be invoked only if the decompressor ran off the +end of the datastream, which would indicate an erroneous datastream. + +The work buffer is defined as an array of datatype JOCTET, which is generally +"char" or "unsigned char". On a machine where char is not exactly 8 bits +wide, you must define JOCTET as a wider data type and then modify the data +source and destination modules to transcribe the work arrays into 8-bit units +on external storage. + +A data destination manager struct contains a pointer and count defining the +next byte to write in the work buffer and the remaining free space: + + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + +The library increments the pointer and decrements the count until the buffer +is filled. The manager's empty_output_buffer method must reset the pointer +and count. The manager is expected to remember the buffer's starting address +and total size in private fields not visible to the library. + +A data destination manager provides three methods: + +init_destination (j_compress_ptr cinfo) + Initialize destination. This is called by jpeg_start_compress() + before any data is actually written. It must initialize + next_output_byte and free_in_buffer. free_in_buffer must be + initialized to a positive value. + +empty_output_buffer (j_compress_ptr cinfo) + This is called whenever the buffer has filled (free_in_buffer + reaches zero). In typical applications, it should write out the + *entire* buffer (use the saved start address and buffer length; + ignore the current state of next_output_byte and free_in_buffer). + Then reset the pointer & count to the start of the buffer, and + return TRUE indicating that the buffer has been dumped. + free_in_buffer must be set to a positive value when TRUE is + returned. A FALSE return should only be used when I/O suspension is + desired (this operating mode is discussed in the next section). + +term_destination (j_compress_ptr cinfo) + Terminate destination --- called by jpeg_finish_compress() after all + data has been written. In most applications, this must flush any + data remaining in the buffer. Use either next_output_byte or + free_in_buffer to determine how much data is in the buffer. + +term_destination() is NOT called by jpeg_abort() or jpeg_destroy(). If you +want the destination manager to be cleaned up during an abort, you must do it +yourself. + +You will also need code to create a jpeg_destination_mgr struct, fill in its +method pointers, and insert a pointer to the struct into the "dest" field of +the JPEG compression object. This can be done in-line in your setup code if +you like, but it's probably cleaner to provide a separate routine similar to +the jpeg_stdio_dest() routine of the supplied destination manager. + +Decompression source managers follow a parallel design, but with some +additional frammishes. The source manager struct contains a pointer and count +defining the next byte to read from the work buffer and the number of bytes +remaining: + + const JOCTET * next_input_byte; /* => next byte to read from buffer */ + size_t bytes_in_buffer; /* # of bytes remaining in buffer */ + +The library increments the pointer and decrements the count until the buffer +is emptied. The manager's fill_input_buffer method must reset the pointer and +count. In most applications, the manager must remember the buffer's starting +address and total size in private fields not visible to the library. + +A data source manager provides five methods: + +init_source (j_decompress_ptr cinfo) + Initialize source. This is called by jpeg_read_header() before any + data is actually read. Unlike init_destination(), it may leave + bytes_in_buffer set to 0 (in which case a fill_input_buffer() call + will occur immediately). + +fill_input_buffer (j_decompress_ptr cinfo) + This is called whenever bytes_in_buffer has reached zero and more + data is wanted. In typical applications, it should read fresh data + into the buffer (ignoring the current state of next_input_byte and + bytes_in_buffer), reset the pointer & count to the start of the + buffer, and return TRUE indicating that the buffer has been reloaded. + It is not necessary to fill the buffer entirely, only to obtain at + least one more byte. bytes_in_buffer MUST be set to a positive value + if TRUE is returned. A FALSE return should only be used when I/O + suspension is desired (this mode is discussed in the next section). + +skip_input_data (j_decompress_ptr cinfo, long num_bytes) + Skip num_bytes worth of data. The buffer pointer and count should + be advanced over num_bytes input bytes, refilling the buffer as + needed. This is used to skip over a potentially large amount of + uninteresting data (such as an APPn marker). In some applications + it may be possible to optimize away the reading of the skipped data, + but it's not clear that being smart is worth much trouble; large + skips are uncommon. bytes_in_buffer may be zero on return. + A zero or negative skip count should be treated as a no-op. + +resync_to_restart (j_decompress_ptr cinfo, int desired) + This routine is called only when the decompressor has failed to find + a restart (RSTn) marker where one is expected. Its mission is to + find a suitable point for resuming decompression. For most + applications, we recommend that you just use the default resync + procedure, jpeg_resync_to_restart(). However, if you are able to back + up in the input data stream, or if you have a-priori knowledge about + the likely location of restart markers, you may be able to do better. + Read the read_restart_marker() and jpeg_resync_to_restart() routines + in jdmarker.c if you think you'd like to implement your own resync + procedure. + +term_source (j_decompress_ptr cinfo) + Terminate source --- called by jpeg_finish_decompress() after all + data has been read. Often a no-op. + +For both fill_input_buffer() and skip_input_data(), there is no such thing +as an EOF return. If the end of the file has been reached, the routine has +a choice of exiting via ERREXIT() or inserting fake data into the buffer. +In most cases, generating a warning message and inserting a fake EOI marker +is the best course of action --- this will allow the decompressor to output +however much of the image is there. In pathological cases, the decompressor +may swallow the EOI and again demand data ... just keep feeding it fake EOIs. +jdatasrc.c illustrates the recommended error recovery behavior. + +term_source() is NOT called by jpeg_abort() or jpeg_destroy(). If you want +the source manager to be cleaned up during an abort, you must do it yourself. + +You will also need code to create a jpeg_source_mgr struct, fill in its method +pointers, and insert a pointer to the struct into the "src" field of the JPEG +decompression object. This can be done in-line in your setup code if you +like, but it's probably cleaner to provide a separate routine similar to the +jpeg_stdio_src() routine of the supplied source manager. + +For more information, consult the stdio source and destination managers +in jdatasrc.c and jdatadst.c. + + +I/O suspension +-------------- + +Some applications need to use the JPEG library as an incremental memory-to- +memory filter: when the compressed data buffer is filled or emptied, they want +control to return to the outer loop, rather than expecting that the buffer can +be emptied or reloaded within the data source/destination manager subroutine. +The library supports this need by providing an "I/O suspension" mode, which we +describe in this section. + +The I/O suspension mode is not a panacea: nothing is guaranteed about the +maximum amount of time spent in any one call to the library, so it will not +eliminate response-time problems in single-threaded applications. If you +need guaranteed response time, we suggest you "bite the bullet" and implement +a real multi-tasking capability. + +To use I/O suspension, cooperation is needed between the calling application +and the data source or destination manager; you will always need a custom +source/destination manager. (Please read the previous section if you haven't +already.) The basic idea is that the empty_output_buffer() or +fill_input_buffer() routine is a no-op, merely returning FALSE to indicate +that it has done nothing. Upon seeing this, the JPEG library suspends +operation and returns to its caller. The surrounding application is +responsible for emptying or refilling the work buffer before calling the +JPEG library again. + +Compression suspension: + +For compression suspension, use an empty_output_buffer() routine that returns +FALSE; typically it will not do anything else. This will cause the +compressor to return to the caller of jpeg_write_scanlines(), with the return +value indicating that not all the supplied scanlines have been accepted. +The application must make more room in the output buffer, adjust the output +buffer pointer/count appropriately, and then call jpeg_write_scanlines() +again, pointing to the first unconsumed scanline. + +When forced to suspend, the compressor will backtrack to a convenient stopping +point (usually the start of the current MCU); it will regenerate some output +data when restarted. Therefore, although empty_output_buffer() is only +called when the buffer is filled, you should NOT write out the entire buffer +after a suspension. Write only the data up to the current position of +next_output_byte/free_in_buffer. The data beyond that point will be +regenerated after resumption. + +Because of the backtracking behavior, a good-size output buffer is essential +for efficiency; you don't want the compressor to suspend often. (In fact, an +overly small buffer could lead to infinite looping, if a single MCU required +more data than would fit in the buffer.) We recommend a buffer of at least +several Kbytes. You may want to insert explicit code to ensure that you don't +call jpeg_write_scanlines() unless there is a reasonable amount of space in +the output buffer; in other words, flush the buffer before trying to compress +more data. + +The compressor does not allow suspension while it is trying to write JPEG +markers at the beginning and end of the file. This means that: + * At the beginning of a compression operation, there must be enough free + space in the output buffer to hold the header markers (typically 600 or + so bytes). The recommended buffer size is bigger than this anyway, so + this is not a problem as long as you start with an empty buffer. However, + this restriction might catch you if you insert large special markers, such + as a JFIF thumbnail image, without flushing the buffer afterwards. + * When you call jpeg_finish_compress(), there must be enough space in the + output buffer to emit any buffered data and the final EOI marker. In the + current implementation, half a dozen bytes should suffice for this, but + for safety's sake we recommend ensuring that at least 100 bytes are free + before calling jpeg_finish_compress(). + +A more significant restriction is that jpeg_finish_compress() cannot suspend. +This means you cannot use suspension with multi-pass operating modes, namely +Huffman code optimization and multiple-scan output. Those modes write the +whole file during jpeg_finish_compress(), which will certainly result in +buffer overrun. (Note that this restriction applies only to compression, +not decompression. The decompressor supports input suspension in all of its +operating modes.) + +Decompression suspension: + +For decompression suspension, use a fill_input_buffer() routine that simply +returns FALSE (except perhaps during error recovery, as discussed below). +This will cause the decompressor to return to its caller with an indication +that suspension has occurred. This can happen at four places: + * jpeg_read_header(): will return JPEG_SUSPENDED. + * jpeg_start_decompress(): will return FALSE, rather than its usual TRUE. + * jpeg_read_scanlines(): will return the number of scanlines already + completed (possibly 0). + * jpeg_finish_decompress(): will return FALSE, rather than its usual TRUE. +The surrounding application must recognize these cases, load more data into +the input buffer, and repeat the call. In the case of jpeg_read_scanlines(), +increment the passed pointers past any scanlines successfully read. + +Just as with compression, the decompressor will typically backtrack to a +convenient restart point before suspending. When fill_input_buffer() is +called, next_input_byte/bytes_in_buffer point to the current restart point, +which is where the decompressor will backtrack to if FALSE is returned. +The data beyond that position must NOT be discarded if you suspend; it needs +to be re-read upon resumption. In most implementations, you'll need to shift +this data down to the start of your work buffer and then load more data after +it. Again, this behavior means that a several-Kbyte work buffer is essential +for decent performance; furthermore, you should load a reasonable amount of +new data before resuming decompression. (If you loaded, say, only one new +byte each time around, you could waste a LOT of cycles.) + +The skip_input_data() source manager routine requires special care in a +suspension scenario. This routine is NOT granted the ability to suspend the +decompressor; it can decrement bytes_in_buffer to zero, but no more. If the +requested skip distance exceeds the amount of data currently in the input +buffer, then skip_input_data() must set bytes_in_buffer to zero and record the +additional skip distance somewhere else. The decompressor will immediately +call fill_input_buffer(), which should return FALSE, which will cause a +suspension return. The surrounding application must then arrange to discard +the recorded number of bytes before it resumes loading the input buffer. +(Yes, this design is rather baroque, but it avoids complexity in the far more +common case where a non-suspending source manager is used.) + +If the input data has been exhausted, we recommend that you emit a warning +and insert dummy EOI markers just as a non-suspending data source manager +would do. This can be handled either in the surrounding application logic or +within fill_input_buffer(); the latter is probably more efficient. If +fill_input_buffer() knows that no more data is available, it can set the +pointer/count to point to a dummy EOI marker and then return TRUE just as +though it had read more data in a non-suspending situation. + +The decompressor does not attempt to suspend within standard JPEG markers; +instead it will backtrack to the start of the marker and reprocess the whole +marker next time. Hence the input buffer must be large enough to hold the +longest standard marker in the file. Standard JPEG markers should normally +not exceed a few hundred bytes each (DHT tables are typically the longest). +We recommend at least a 2K buffer for performance reasons, which is much +larger than any correct marker is likely to be. For robustness against +damaged marker length counts, you may wish to insert a test in your +application for the case that the input buffer is completely full and yet +the decoder has suspended without consuming any data --- otherwise, if this +situation did occur, it would lead to an endless loop. (The library can't +provide this test since it has no idea whether "the buffer is full", or +even whether there is a fixed-size input buffer.) + +The input buffer would need to be 64K to allow for arbitrary COM or APPn +markers, but these are handled specially: they are either saved into allocated +memory, or skipped over by calling skip_input_data(). In the former case, +suspension is handled correctly, and in the latter case, the problem of +buffer overrun is placed on skip_input_data's shoulders, as explained above. +Note that if you provide your own marker handling routine for large markers, +you should consider how to deal with buffer overflow. + +Multiple-buffer management: + +In some applications it is desirable to store the compressed data in a linked +list of buffer areas, so as to avoid data copying. This can be handled by +having empty_output_buffer() or fill_input_buffer() set the pointer and count +to reference the next available buffer; FALSE is returned only if no more +buffers are available. Although seemingly straightforward, there is a +pitfall in this approach: the backtrack that occurs when FALSE is returned +could back up into an earlier buffer. For example, when fill_input_buffer() +is called, the current pointer & count indicate the backtrack restart point. +Since fill_input_buffer() will set the pointer and count to refer to a new +buffer, the restart position must be saved somewhere else. Suppose a second +call to fill_input_buffer() occurs in the same library call, and no +additional input data is available, so fill_input_buffer must return FALSE. +If the JPEG library has not moved the pointer/count forward in the current +buffer, then *the correct restart point is the saved position in the prior +buffer*. Prior buffers may be discarded only after the library establishes +a restart point within a later buffer. Similar remarks apply for output into +a chain of buffers. + +The library will never attempt to backtrack over a skip_input_data() call, +so any skipped data can be permanently discarded. You still have to deal +with the case of skipping not-yet-received data, however. + +It's much simpler to use only a single buffer; when fill_input_buffer() is +called, move any unconsumed data (beyond the current pointer/count) down to +the beginning of this buffer and then load new data into the remaining buffer +space. This approach requires a little more data copying but is far easier +to get right. + + +Progressive JPEG support +------------------------ + +Progressive JPEG rearranges the stored data into a series of scans of +increasing quality. In situations where a JPEG file is transmitted across a +slow communications link, a decoder can generate a low-quality image very +quickly from the first scan, then gradually improve the displayed quality as +more scans are received. The final image after all scans are complete is +identical to that of a regular (sequential) JPEG file of the same quality +setting. Progressive JPEG files are often slightly smaller than equivalent +sequential JPEG files, but the possibility of incremental display is the main +reason for using progressive JPEG. + +The IJG encoder library generates progressive JPEG files when given a +suitable "scan script" defining how to divide the data into scans. +Creation of progressive JPEG files is otherwise transparent to the encoder. +Progressive JPEG files can also be read transparently by the decoder library. +If the decoding application simply uses the library as defined above, it +will receive a final decoded image without any indication that the file was +progressive. Of course, this approach does not allow incremental display. +To perform incremental display, an application needs to use the decoder +library's "buffered-image" mode, in which it receives a decoded image +multiple times. + +Each displayed scan requires about as much work to decode as a full JPEG +image of the same size, so the decoder must be fairly fast in relation to the +data transmission rate in order to make incremental display useful. However, +it is possible to skip displaying the image and simply add the incoming bits +to the decoder's coefficient buffer. This is fast because only Huffman +decoding need be done, not IDCT, upsampling, colorspace conversion, etc. +The IJG decoder library allows the application to switch dynamically between +displaying the image and simply absorbing the incoming bits. A properly +coded application can automatically adapt the number of display passes to +suit the time available as the image is received. Also, a final +higher-quality display cycle can be performed from the buffered data after +the end of the file is reached. + +Progressive compression: + +To create a progressive JPEG file (or a multiple-scan sequential JPEG file), +set the scan_info cinfo field to point to an array of scan descriptors, and +perform compression as usual. Instead of constructing your own scan list, +you can call the jpeg_simple_progression() helper routine to create a +recommended progression sequence; this method should be used by all +applications that don't want to get involved in the nitty-gritty of +progressive scan sequence design. (If you want to provide user control of +scan sequences, you may wish to borrow the scan script reading code found +in rdswitch.c, so that you can read scan script files just like cjpeg's.) +When scan_info is not NULL, the compression library will store DCT'd data +into a buffer array as jpeg_write_scanlines() is called, and will emit all +the requested scans during jpeg_finish_compress(). This implies that +multiple-scan output cannot be created with a suspending data destination +manager, since jpeg_finish_compress() does not support suspension. We +should also note that the compressor currently forces Huffman optimization +mode when creating a progressive JPEG file, because the default Huffman +tables are unsuitable for progressive files. + +Progressive decompression: + +When buffered-image mode is not used, the decoder library will read all of +a multi-scan file during jpeg_start_decompress(), so that it can provide a +final decoded image. (Here "multi-scan" means either progressive or +multi-scan sequential.) This makes multi-scan files transparent to the +decoding application. However, existing applications that used suspending +input with version 5 of the IJG library will need to be modified to check +for a suspension return from jpeg_start_decompress(). + +To perform incremental display, an application must use the library's +buffered-image mode. This is described in the next section. + + +Buffered-image mode +------------------- + +In buffered-image mode, the library stores the partially decoded image in a +coefficient buffer, from which it can be read out as many times as desired. +This mode is typically used for incremental display of progressive JPEG files, +but it can be used with any JPEG file. Each scan of a progressive JPEG file +adds more data (more detail) to the buffered image. The application can +display in lockstep with the source file (one display pass per input scan), +or it can allow input processing to outrun display processing. By making +input and display processing run independently, it is possible for the +application to adapt progressive display to a wide range of data transmission +rates. + +The basic control flow for buffered-image decoding is + + jpeg_create_decompress() + set data source + jpeg_read_header() + set overall decompression parameters + cinfo.buffered_image = TRUE; /* select buffered-image mode */ + jpeg_start_decompress() + for (each output pass) { + adjust output decompression parameters if required + jpeg_start_output() /* start a new output pass */ + for (all scanlines in image) { + jpeg_read_scanlines() + display scanlines + } + jpeg_finish_output() /* terminate output pass */ + } + jpeg_finish_decompress() + jpeg_destroy_decompress() + +This differs from ordinary unbuffered decoding in that there is an additional +level of looping. The application can choose how many output passes to make +and how to display each pass. + +The simplest approach to displaying progressive images is to do one display +pass for each scan appearing in the input file. In this case the outer loop +condition is typically + while (! jpeg_input_complete(&cinfo)) +and the start-output call should read + jpeg_start_output(&cinfo, cinfo.input_scan_number); +The second parameter to jpeg_start_output() indicates which scan of the input +file is to be displayed; the scans are numbered starting at 1 for this +purpose. (You can use a loop counter starting at 1 if you like, but using +the library's input scan counter is easier.) The library automatically reads +data as necessary to complete each requested scan, and jpeg_finish_output() +advances to the next scan or end-of-image marker (hence input_scan_number +will be incremented by the time control arrives back at jpeg_start_output()). +With this technique, data is read from the input file only as needed, and +input and output processing run in lockstep. + +After reading the final scan and reaching the end of the input file, the +buffered image remains available; it can be read additional times by +repeating the jpeg_start_output()/jpeg_read_scanlines()/jpeg_finish_output() +sequence. For example, a useful technique is to use fast one-pass color +quantization for display passes made while the image is arriving, followed by +a final display pass using two-pass quantization for highest quality. This +is done by changing the library parameters before the final output pass. +Changing parameters between passes is discussed in detail below. + +In general the last scan of a progressive file cannot be recognized as such +until after it is read, so a post-input display pass is the best approach if +you want special processing in the final pass. + +When done with the image, be sure to call jpeg_finish_decompress() to release +the buffered image (or just use jpeg_destroy_decompress()). + +If input data arrives faster than it can be displayed, the application can +cause the library to decode input data in advance of what's needed to produce +output. This is done by calling the routine jpeg_consume_input(). +The return value is one of the following: + JPEG_REACHED_SOS: reached an SOS marker (the start of a new scan) + JPEG_REACHED_EOI: reached the EOI marker (end of image) + JPEG_ROW_COMPLETED: completed reading one MCU row of compressed data + JPEG_SCAN_COMPLETED: completed reading last MCU row of current scan + JPEG_SUSPENDED: suspended before completing any of the above +(JPEG_SUSPENDED can occur only if a suspending data source is used.) This +routine can be called at any time after initializing the JPEG object. It +reads some additional data and returns when one of the indicated significant +events occurs. (If called after the EOI marker is reached, it will +immediately return JPEG_REACHED_EOI without attempting to read more data.) + +The library's output processing will automatically call jpeg_consume_input() +whenever the output processing overtakes the input; thus, simple lockstep +display requires no direct calls to jpeg_consume_input(). But by adding +calls to jpeg_consume_input(), you can absorb data in advance of what is +being displayed. This has two benefits: + * You can limit buildup of unprocessed data in your input buffer. + * You can eliminate extra display passes by paying attention to the + state of the library's input processing. + +The first of these benefits only requires interspersing calls to +jpeg_consume_input() with your display operations and any other processing +you may be doing. To avoid wasting cycles due to backtracking, it's best to +call jpeg_consume_input() only after a hundred or so new bytes have arrived. +This is discussed further under "I/O suspension", above. (Note: the JPEG +library currently is not thread-safe. You must not call jpeg_consume_input() +from one thread of control if a different library routine is working on the +same JPEG object in another thread.) + +When input arrives fast enough that more than one new scan is available +before you start a new output pass, you may as well skip the output pass +corresponding to the completed scan. This occurs for free if you pass +cinfo.input_scan_number as the target scan number to jpeg_start_output(). +The input_scan_number field is simply the index of the scan currently being +consumed by the input processor. You can ensure that this is up-to-date by +emptying the input buffer just before calling jpeg_start_output(): call +jpeg_consume_input() repeatedly until it returns JPEG_SUSPENDED or +JPEG_REACHED_EOI. + +The target scan number passed to jpeg_start_output() is saved in the +cinfo.output_scan_number field. The library's output processing calls +jpeg_consume_input() whenever the current input scan number and row within +that scan is less than or equal to the current output scan number and row. +Thus, input processing can "get ahead" of the output processing but is not +allowed to "fall behind". You can achieve several different effects by +manipulating this interlock rule. For example, if you pass a target scan +number greater than the current input scan number, the output processor will +wait until that scan starts to arrive before producing any output. (To avoid +an infinite loop, the target scan number is automatically reset to the last +scan number when the end of image is reached. Thus, if you specify a large +target scan number, the library will just absorb the entire input file and +then perform an output pass. This is effectively the same as what +jpeg_start_decompress() does when you don't select buffered-image mode.) +When you pass a target scan number equal to the current input scan number, +the image is displayed no faster than the current input scan arrives. The +final possibility is to pass a target scan number less than the current input +scan number; this disables the input/output interlock and causes the output +processor to simply display whatever it finds in the image buffer, without +waiting for input. (However, the library will not accept a target scan +number less than one, so you can't avoid waiting for the first scan.) + +When data is arriving faster than the output display processing can advance +through the image, jpeg_consume_input() will store data into the buffered +image beyond the point at which the output processing is reading data out +again. If the input arrives fast enough, it may "wrap around" the buffer to +the point where the input is more than one whole scan ahead of the output. +If the output processing simply proceeds through its display pass without +paying attention to the input, the effect seen on-screen is that the lower +part of the image is one or more scans better in quality than the upper part. +Then, when the next output scan is started, you have a choice of what target +scan number to use. The recommended choice is to use the current input scan +number at that time, which implies that you've skipped the output scans +corresponding to the input scans that were completed while you processed the +previous output scan. In this way, the decoder automatically adapts its +speed to the arriving data, by skipping output scans as necessary to keep up +with the arriving data. + +When using this strategy, you'll want to be sure that you perform a final +output pass after receiving all the data; otherwise your last display may not +be full quality across the whole screen. So the right outer loop logic is +something like this: + do { + absorb any waiting input by calling jpeg_consume_input() + final_pass = jpeg_input_complete(&cinfo); + adjust output decompression parameters if required + jpeg_start_output(&cinfo, cinfo.input_scan_number); + ... + jpeg_finish_output() + } while (! final_pass); +rather than quitting as soon as jpeg_input_complete() returns TRUE. This +arrangement makes it simple to use higher-quality decoding parameters +for the final pass. But if you don't want to use special parameters for +the final pass, the right loop logic is like this: + for (;;) { + absorb any waiting input by calling jpeg_consume_input() + jpeg_start_output(&cinfo, cinfo.input_scan_number); + ... + jpeg_finish_output() + if (jpeg_input_complete(&cinfo) && + cinfo.input_scan_number == cinfo.output_scan_number) + break; + } +In this case you don't need to know in advance whether an output pass is to +be the last one, so it's not necessary to have reached EOF before starting +the final output pass; rather, what you want to test is whether the output +pass was performed in sync with the final input scan. This form of the loop +will avoid an extra output pass whenever the decoder is able (or nearly able) +to keep up with the incoming data. + +When the data transmission speed is high, you might begin a display pass, +then find that much or all of the file has arrived before you can complete +the pass. (You can detect this by noting the JPEG_REACHED_EOI return code +from jpeg_consume_input(), or equivalently by testing jpeg_input_complete().) +In this situation you may wish to abort the current display pass and start a +new one using the newly arrived information. To do so, just call +jpeg_finish_output() and then start a new pass with jpeg_start_output(). + +A variant strategy is to abort and restart display if more than one complete +scan arrives during an output pass; this can be detected by noting +JPEG_REACHED_SOS returns and/or examining cinfo.input_scan_number. This +idea should be employed with caution, however, since the display process +might never get to the bottom of the image before being aborted, resulting +in the lower part of the screen being several passes worse than the upper. +In most cases it's probably best to abort an output pass only if the whole +file has arrived and you want to begin the final output pass immediately. + +When receiving data across a communication link, we recommend always using +the current input scan number for the output target scan number; if a +higher-quality final pass is to be done, it should be started (aborting any +incomplete output pass) as soon as the end of file is received. However, +many other strategies are possible. For example, the application can examine +the parameters of the current input scan and decide whether to display it or +not. If the scan contains only chroma data, one might choose not to use it +as the target scan, expecting that the scan will be small and will arrive +quickly. To skip to the next scan, call jpeg_consume_input() until it +returns JPEG_REACHED_SOS or JPEG_REACHED_EOI. Or just use the next higher +number as the target scan for jpeg_start_output(); but that method doesn't +let you inspect the next scan's parameters before deciding to display it. + + +In buffered-image mode, jpeg_start_decompress() never performs input and +thus never suspends. An application that uses input suspension with +buffered-image mode must be prepared for suspension returns from these +routines: +* jpeg_start_output() performs input only if you request 2-pass quantization + and the target scan isn't fully read yet. (This is discussed below.) +* jpeg_read_scanlines(), as always, returns the number of scanlines that it + was able to produce before suspending. +* jpeg_finish_output() will read any markers following the target scan, + up to the end of the file or the SOS marker that begins another scan. + (But it reads no input if jpeg_consume_input() has already reached the + end of the file or a SOS marker beyond the target output scan.) +* jpeg_finish_decompress() will read until the end of file, and thus can + suspend if the end hasn't already been reached (as can be tested by + calling jpeg_input_complete()). +jpeg_start_output(), jpeg_finish_output(), and jpeg_finish_decompress() +all return TRUE if they completed their tasks, FALSE if they had to suspend. +In the event of a FALSE return, the application must load more input data +and repeat the call. Applications that use non-suspending data sources need +not check the return values of these three routines. + + +It is possible to change decoding parameters between output passes in the +buffered-image mode. The decoder library currently supports only very +limited changes of parameters. ONLY THE FOLLOWING parameter changes are +allowed after jpeg_start_decompress() is called: +* dct_method can be changed before each call to jpeg_start_output(). + For example, one could use a fast DCT method for early scans, changing + to a higher quality method for the final scan. +* dither_mode can be changed before each call to jpeg_start_output(); + of course this has no impact if not using color quantization. Typically + one would use ordered dither for initial passes, then switch to + Floyd-Steinberg dither for the final pass. Caution: changing dither mode + can cause more memory to be allocated by the library. Although the amount + of memory involved is not large (a scanline or so), it may cause the + initial max_memory_to_use specification to be exceeded, which in the worst + case would result in an out-of-memory failure. +* do_block_smoothing can be changed before each call to jpeg_start_output(). + This setting is relevant only when decoding a progressive JPEG image. + During the first DC-only scan, block smoothing provides a very "fuzzy" look + instead of the very "blocky" look seen without it; which is better seems a + matter of personal taste. But block smoothing is nearly always a win + during later stages, especially when decoding a successive-approximation + image: smoothing helps to hide the slight blockiness that otherwise shows + up on smooth gradients until the lowest coefficient bits are sent. +* Color quantization mode can be changed under the rules described below. + You *cannot* change between full-color and quantized output (because that + would alter the required I/O buffer sizes), but you can change which + quantization method is used. + +When generating color-quantized output, changing quantization method is a +very useful way of switching between high-speed and high-quality display. +The library allows you to change among its three quantization methods: +1. Single-pass quantization to a fixed color cube. + Selected by cinfo.two_pass_quantize = FALSE and cinfo.colormap = NULL. +2. Single-pass quantization to an application-supplied colormap. + Selected by setting cinfo.colormap to point to the colormap (the value of + two_pass_quantize is ignored); also set cinfo.actual_number_of_colors. +3. Two-pass quantization to a colormap chosen specifically for the image. + Selected by cinfo.two_pass_quantize = TRUE and cinfo.colormap = NULL. + (This is the default setting selected by jpeg_read_header, but it is + probably NOT what you want for the first pass of progressive display!) +These methods offer successively better quality and lesser speed. However, +only the first method is available for quantizing in non-RGB color spaces. + +IMPORTANT: because the different quantizer methods have very different +working-storage requirements, the library requires you to indicate which +one(s) you intend to use before you call jpeg_start_decompress(). (If we did +not require this, the max_memory_to_use setting would be a complete fiction.) +You do this by setting one or more of these three cinfo fields to TRUE: + enable_1pass_quant Fixed color cube colormap + enable_external_quant Externally-supplied colormap + enable_2pass_quant Two-pass custom colormap +All three are initialized FALSE by jpeg_read_header(). But +jpeg_start_decompress() automatically sets TRUE the one selected by the +current two_pass_quantize and colormap settings, so you only need to set the +enable flags for any other quantization methods you plan to change to later. + +After setting the enable flags correctly at jpeg_start_decompress() time, you +can change to any enabled quantization method by setting two_pass_quantize +and colormap properly just before calling jpeg_start_output(). The following +special rules apply: +1. You must explicitly set cinfo.colormap to NULL when switching to 1-pass + or 2-pass mode from a different mode, or when you want the 2-pass + quantizer to be re-run to generate a new colormap. +2. To switch to an external colormap, or to change to a different external + colormap than was used on the prior pass, you must call + jpeg_new_colormap() after setting cinfo.colormap. +NOTE: if you want to use the same colormap as was used in the prior pass, +you should not do either of these things. This will save some nontrivial +switchover costs. +(These requirements exist because cinfo.colormap will always be non-NULL +after completing a prior output pass, since both the 1-pass and 2-pass +quantizers set it to point to their output colormaps. Thus you have to +do one of these two things to notify the library that something has changed. +Yup, it's a bit klugy, but it's necessary to do it this way for backwards +compatibility.) + +Note that in buffered-image mode, the library generates any requested colormap +during jpeg_start_output(), not during jpeg_start_decompress(). + +When using two-pass quantization, jpeg_start_output() makes a pass over the +buffered image to determine the optimum color map; it therefore may take a +significant amount of time, whereas ordinarily it does little work. The +progress monitor hook is called during this pass, if defined. It is also +important to realize that if the specified target scan number is greater than +or equal to the current input scan number, jpeg_start_output() will attempt +to consume input as it makes this pass. If you use a suspending data source, +you need to check for a FALSE return from jpeg_start_output() under these +conditions. The combination of 2-pass quantization and a not-yet-fully-read +target scan is the only case in which jpeg_start_output() will consume input. + + +Application authors who support buffered-image mode may be tempted to use it +for all JPEG images, even single-scan ones. This will work, but it is +inefficient: there is no need to create an image-sized coefficient buffer for +single-scan images. Requesting buffered-image mode for such an image wastes +memory. Worse, it can cost time on large images, since the buffered data has +to be swapped out or written to a temporary file. If you are concerned about +maximum performance on baseline JPEG files, you should use buffered-image +mode only when the incoming file actually has multiple scans. This can be +tested by calling jpeg_has_multiple_scans(), which will return a correct +result at any time after jpeg_read_header() completes. + +It is also worth noting that when you use jpeg_consume_input() to let input +processing get ahead of output processing, the resulting pattern of access to +the coefficient buffer is quite nonsequential. It's best to use the memory +manager jmemnobs.c if you can (ie, if you have enough real or virtual main +memory). If not, at least make sure that max_memory_to_use is set as high as +possible. If the JPEG memory manager has to use a temporary file, you will +probably see a lot of disk traffic and poor performance. (This could be +improved with additional work on the memory manager, but we haven't gotten +around to it yet.) + +In some applications it may be convenient to use jpeg_consume_input() for all +input processing, including reading the initial markers; that is, you may +wish to call jpeg_consume_input() instead of jpeg_read_header() during +startup. This works, but note that you must check for JPEG_REACHED_SOS and +JPEG_REACHED_EOI return codes as the equivalent of jpeg_read_header's codes. +Once the first SOS marker has been reached, you must call +jpeg_start_decompress() before jpeg_consume_input() will consume more input; +it'll just keep returning JPEG_REACHED_SOS until you do. If you read a +tables-only file this way, jpeg_consume_input() will return JPEG_REACHED_EOI +without ever returning JPEG_REACHED_SOS; be sure to check for this case. +If this happens, the decompressor will not read any more input until you call +jpeg_abort() to reset it. It is OK to call jpeg_consume_input() even when not +using buffered-image mode, but in that case it's basically a no-op after the +initial markers have been read: it will just return JPEG_SUSPENDED. + + +Abbreviated datastreams and multiple images +------------------------------------------- + +A JPEG compression or decompression object can be reused to process multiple +images. This saves a small amount of time per image by eliminating the +"create" and "destroy" operations, but that isn't the real purpose of the +feature. Rather, reuse of an object provides support for abbreviated JPEG +datastreams. Object reuse can also simplify processing a series of images in +a single input or output file. This section explains these features. + +A JPEG file normally contains several hundred bytes worth of quantization +and Huffman tables. In a situation where many images will be stored or +transmitted with identical tables, this may represent an annoying overhead. +The JPEG standard therefore permits tables to be omitted. The standard +defines three classes of JPEG datastreams: + * "Interchange" datastreams contain an image and all tables needed to decode + the image. These are the usual kind of JPEG file. + * "Abbreviated image" datastreams contain an image, but are missing some or + all of the tables needed to decode that image. + * "Abbreviated table specification" (henceforth "tables-only") datastreams + contain only table specifications. +To decode an abbreviated image, it is necessary to load the missing table(s) +into the decoder beforehand. This can be accomplished by reading a separate +tables-only file. A variant scheme uses a series of images in which the first +image is an interchange (complete) datastream, while subsequent ones are +abbreviated and rely on the tables loaded by the first image. It is assumed +that once the decoder has read a table, it will remember that table until a +new definition for the same table number is encountered. + +It is the application designer's responsibility to figure out how to associate +the correct tables with an abbreviated image. While abbreviated datastreams +can be useful in a closed environment, their use is strongly discouraged in +any situation where data exchange with other applications might be needed. +Caveat designer. + +The JPEG library provides support for reading and writing any combination of +tables-only datastreams and abbreviated images. In both compression and +decompression objects, a quantization or Huffman table will be retained for +the lifetime of the object, unless it is overwritten by a new table definition. + + +To create abbreviated image datastreams, it is only necessary to tell the +compressor not to emit some or all of the tables it is using. Each +quantization and Huffman table struct contains a boolean field "sent_table", +which normally is initialized to FALSE. For each table used by the image, the +header-writing process emits the table and sets sent_table = TRUE unless it is +already TRUE. (In normal usage, this prevents outputting the same table +definition multiple times, as would otherwise occur because the chroma +components typically share tables.) Thus, setting this field to TRUE before +calling jpeg_start_compress() will prevent the table from being written at +all. + +If you want to create a "pure" abbreviated image file containing no tables, +just call "jpeg_suppress_tables(&cinfo, TRUE)" after constructing all the +tables. If you want to emit some but not all tables, you'll need to set the +individual sent_table fields directly. + +To create an abbreviated image, you must also call jpeg_start_compress() +with a second parameter of FALSE, not TRUE. Otherwise jpeg_start_compress() +will force all the sent_table fields to FALSE. (This is a safety feature to +prevent abbreviated images from being created accidentally.) + +To create a tables-only file, perform the same parameter setup that you +normally would, but instead of calling jpeg_start_compress() and so on, call +jpeg_write_tables(&cinfo). This will write an abbreviated datastream +containing only SOI, DQT and/or DHT markers, and EOI. All the quantization +and Huffman tables that are currently defined in the compression object will +be emitted unless their sent_tables flag is already TRUE, and then all the +sent_tables flags will be set TRUE. + +A sure-fire way to create matching tables-only and abbreviated image files +is to proceed as follows: + + create JPEG compression object + set JPEG parameters + set destination to tables-only file + jpeg_write_tables(&cinfo); + set destination to image file + jpeg_start_compress(&cinfo, FALSE); + write data... + jpeg_finish_compress(&cinfo); + +Since the JPEG parameters are not altered between writing the table file and +the abbreviated image file, the same tables are sure to be used. Of course, +you can repeat the jpeg_start_compress() ... jpeg_finish_compress() sequence +many times to produce many abbreviated image files matching the table file. + +You cannot suppress output of the computed Huffman tables when Huffman +optimization is selected. (If you could, there'd be no way to decode the +image...) Generally, you don't want to set optimize_coding = TRUE when +you are trying to produce abbreviated files. + +In some cases you might want to compress an image using tables which are +not stored in the application, but are defined in an interchange or +tables-only file readable by the application. This can be done by setting up +a JPEG decompression object to read the specification file, then copying the +tables into your compression object. See jpeg_copy_critical_parameters() +for an example of copying quantization tables. + + +To read abbreviated image files, you simply need to load the proper tables +into the decompression object before trying to read the abbreviated image. +If the proper tables are stored in the application program, you can just +allocate the table structs and fill in their contents directly. For example, +to load a fixed quantization table into table slot "n": + + if (cinfo.quant_tbl_ptrs[n] == NULL) + cinfo.quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) &cinfo); + quant_ptr = cinfo.quant_tbl_ptrs[n]; /* quant_ptr is JQUANT_TBL* */ + for (i = 0; i < 64; i++) { + /* Qtable[] is desired quantization table, in natural array order */ + quant_ptr->quantval[i] = Qtable[i]; + } + +Code to load a fixed Huffman table is typically (for AC table "n"): + + if (cinfo.ac_huff_tbl_ptrs[n] == NULL) + cinfo.ac_huff_tbl_ptrs[n] = jpeg_alloc_huff_table((j_common_ptr) &cinfo); + huff_ptr = cinfo.ac_huff_tbl_ptrs[n]; /* huff_ptr is JHUFF_TBL* */ + for (i = 1; i <= 16; i++) { + /* counts[i] is number of Huffman codes of length i bits, i=1..16 */ + huff_ptr->bits[i] = counts[i]; + } + for (i = 0; i < 256; i++) { + /* symbols[] is the list of Huffman symbols, in code-length order */ + huff_ptr->huffval[i] = symbols[i]; + } + +(Note that trying to set cinfo.quant_tbl_ptrs[n] to point directly at a +constant JQUANT_TBL object is not safe. If the incoming file happened to +contain a quantization table definition, your master table would get +overwritten! Instead allocate a working table copy and copy the master table +into it, as illustrated above. Ditto for Huffman tables, of course.) + +You might want to read the tables from a tables-only file, rather than +hard-wiring them into your application. The jpeg_read_header() call is +sufficient to read a tables-only file. You must pass a second parameter of +FALSE to indicate that you do not require an image to be present. Thus, the +typical scenario is + + create JPEG decompression object + set source to tables-only file + jpeg_read_header(&cinfo, FALSE); + set source to abbreviated image file + jpeg_read_header(&cinfo, TRUE); + set decompression parameters + jpeg_start_decompress(&cinfo); + read data... + jpeg_finish_decompress(&cinfo); + +In some cases, you may want to read a file without knowing whether it contains +an image or just tables. In that case, pass FALSE and check the return value +from jpeg_read_header(): it will be JPEG_HEADER_OK if an image was found, +JPEG_HEADER_TABLES_ONLY if only tables were found. (A third return value, +JPEG_SUSPENDED, is possible when using a suspending data source manager.) +Note that jpeg_read_header() will not complain if you read an abbreviated +image for which you haven't loaded the missing tables; the missing-table check +occurs later, in jpeg_start_decompress(). + + +It is possible to read a series of images from a single source file by +repeating the jpeg_read_header() ... jpeg_finish_decompress() sequence, +without releasing/recreating the JPEG object or the data source module. +(If you did reinitialize, any partial bufferload left in the data source +buffer at the end of one image would be discarded, causing you to lose the +start of the next image.) When you use this method, stored tables are +automatically carried forward, so some of the images can be abbreviated images +that depend on tables from earlier images. + +If you intend to write a series of images into a single destination file, +you might want to make a specialized data destination module that doesn't +flush the output buffer at term_destination() time. This would speed things +up by some trifling amount. Of course, you'd need to remember to flush the +buffer after the last image. You can make the later images be abbreviated +ones by passing FALSE to jpeg_start_compress(). + + +Special markers +--------------- + +Some applications may need to insert or extract special data in the JPEG +datastream. The JPEG standard provides marker types "COM" (comment) and +"APP0" through "APP15" (application) to hold application-specific data. +Unfortunately, the use of these markers is not specified by the standard. +COM markers are fairly widely used to hold user-supplied text. The JFIF file +format spec uses APP0 markers with specified initial strings to hold certain +data. Adobe applications use APP14 markers beginning with the string "Adobe" +for miscellaneous data. Other APPn markers are rarely seen, but might +contain almost anything. + +If you wish to store user-supplied text, we recommend you use COM markers +and place readable 7-bit ASCII text in them. Newline conventions are not +standardized --- expect to find LF (Unix style), CR/LF (DOS style), or CR +(Mac style). A robust COM reader should be able to cope with random binary +garbage, including nulls, since some applications generate COM markers +containing non-ASCII junk. (But yours should not be one of them.) + +For program-supplied data, use an APPn marker, and be sure to begin it with an +identifying string so that you can tell whether the marker is actually yours. +It's probably best to avoid using APP0 or APP14 for any private markers. +(NOTE: the upcoming SPIFF standard will use APP8 markers; we recommend you +not use APP8 markers for any private purposes, either.) + +Keep in mind that at most 65533 bytes can be put into one marker, but you +can have as many markers as you like. + +By default, the IJG compression library will write a JFIF APP0 marker if the +selected JPEG colorspace is grayscale or YCbCr, or an Adobe APP14 marker if +the selected colorspace is RGB, CMYK, or YCCK. You can disable this, but +we don't recommend it. The decompression library will recognize JFIF and +Adobe markers and will set the JPEG colorspace properly when one is found. + + +You can write special markers immediately following the datastream header by +calling jpeg_write_marker() after jpeg_start_compress() and before the first +call to jpeg_write_scanlines(). When you do this, the markers appear after +the SOI and the JFIF APP0 and Adobe APP14 markers (if written), but before +all else. Specify the marker type parameter as "JPEG_COM" for COM or +"JPEG_APP0 + n" for APPn. (Actually, jpeg_write_marker will let you write +any marker type, but we don't recommend writing any other kinds of marker.) +For example, to write a user comment string pointed to by comment_text: + jpeg_write_marker(cinfo, JPEG_COM, comment_text, strlen(comment_text)); + +If it's not convenient to store all the marker data in memory at once, +you can instead call jpeg_write_m_header() followed by multiple calls to +jpeg_write_m_byte(). If you do it this way, it's your responsibility to +call jpeg_write_m_byte() exactly the number of times given in the length +parameter to jpeg_write_m_header(). (This method lets you empty the +output buffer partway through a marker, which might be important when +using a suspending data destination module. In any case, if you are using +a suspending destination, you should flush its buffer after inserting +any special markers. See "I/O suspension".) + +Or, if you prefer to synthesize the marker byte sequence yourself, +you can just cram it straight into the data destination module. + +If you are writing JFIF 1.02 extension markers (thumbnail images), don't +forget to set cinfo.JFIF_minor_version = 2 so that the encoder will write the +correct JFIF version number in the JFIF header marker. The library's default +is to write version 1.01, but that's wrong if you insert any 1.02 extension +markers. (We could probably get away with just defaulting to 1.02, but there +used to be broken decoders that would complain about unknown minor version +numbers. To reduce compatibility risks it's safest not to write 1.02 unless +you are actually using 1.02 extensions.) + + +When reading, two methods of handling special markers are available: +1. You can ask the library to save the contents of COM and/or APPn markers +into memory, and then examine them at your leisure afterwards. +2. You can supply your own routine to process COM and/or APPn markers +on-the-fly as they are read. +The first method is simpler to use, especially if you are using a suspending +data source; writing a marker processor that copes with input suspension is +not easy (consider what happens if the marker is longer than your available +input buffer). However, the second method conserves memory since the marker +data need not be kept around after it's been processed. + +For either method, you'd normally set up marker handling after creating a +decompression object and before calling jpeg_read_header(), because the +markers of interest will typically be near the head of the file and so will +be scanned by jpeg_read_header. Once you've established a marker handling +method, it will be used for the life of that decompression object +(potentially many datastreams), unless you change it. Marker handling is +determined separately for COM markers and for each APPn marker code. + + +To save the contents of special markers in memory, call + jpeg_save_markers(cinfo, marker_code, length_limit) +where marker_code is the marker type to save, JPEG_COM or JPEG_APP0+n. +(To arrange to save all the special marker types, you need to call this +routine 17 times, for COM and APP0-APP15.) If the incoming marker is longer +than length_limit data bytes, only length_limit bytes will be saved; this +parameter allows you to avoid chewing up memory when you only need to see the +first few bytes of a potentially large marker. If you want to save all the +data, set length_limit to 0xFFFF; that is enough since marker lengths are only +16 bits. As a special case, setting length_limit to 0 prevents that marker +type from being saved at all. (That is the default behavior, in fact.) + +After jpeg_read_header() completes, you can examine the special markers by +following the cinfo->marker_list pointer chain. All the special markers in +the file appear in this list, in order of their occurrence in the file (but +omitting any markers of types you didn't ask for). Both the original data +length and the saved data length are recorded for each list entry; the latter +will not exceed length_limit for the particular marker type. Note that these +lengths exclude the marker length word, whereas the stored representation +within the JPEG file includes it. (Hence the maximum data length is really +only 65533.) + +It is possible that additional special markers appear in the file beyond the +SOS marker at which jpeg_read_header stops; if so, the marker list will be +extended during reading of the rest of the file. This is not expected to be +common, however. If you are short on memory you may want to reset the length +limit to zero for all marker types after finishing jpeg_read_header, to +ensure that the max_memory_to_use setting cannot be exceeded due to addition +of later markers. + +The marker list remains stored until you call jpeg_finish_decompress or +jpeg_abort, at which point the memory is freed and the list is set to empty. +(jpeg_destroy also releases the storage, of course.) + +Note that the library is internally interested in APP0 and APP14 markers; +if you try to set a small nonzero length limit on these types, the library +will silently force the length up to the minimum it wants. (But you can set +a zero length limit to prevent them from being saved at all.) Also, in a +16-bit environment, the maximum length limit may be constrained to less than +65533 by malloc() limitations. It is therefore best not to assume that the +effective length limit is exactly what you set it to be. + + +If you want to supply your own marker-reading routine, you do it by calling +jpeg_set_marker_processor(). A marker processor routine must have the +signature + boolean jpeg_marker_parser_method (j_decompress_ptr cinfo) +Although the marker code is not explicitly passed, the routine can find it +in cinfo->unread_marker. At the time of call, the marker proper has been +read from the data source module. The processor routine is responsible for +reading the marker length word and the remaining parameter bytes, if any. +Return TRUE to indicate success. (FALSE should be returned only if you are +using a suspending data source and it tells you to suspend. See the standard +marker processors in jdmarker.c for appropriate coding methods if you need to +use a suspending data source.) + +If you override the default APP0 or APP14 processors, it is up to you to +recognize JFIF and Adobe markers if you want colorspace recognition to occur +properly. We recommend copying and extending the default processors if you +want to do that. (A better idea is to save these marker types for later +examination by calling jpeg_save_markers(); that method doesn't interfere +with the library's own processing of these markers.) + +jpeg_set_marker_processor() and jpeg_save_markers() are mutually exclusive +--- if you call one it overrides any previous call to the other, for the +particular marker type specified. + +A simple example of an external COM processor can be found in djpeg.c. +Also, see jpegtran.c for an example of using jpeg_save_markers. + + +Raw (downsampled) image data +---------------------------- + +Some applications need to supply already-downsampled image data to the JPEG +compressor, or to receive raw downsampled data from the decompressor. The +library supports this requirement by allowing the application to write or +read raw data, bypassing the normal preprocessing or postprocessing steps. +The interface is different from the standard one and is somewhat harder to +use. If your interest is merely in bypassing color conversion, we recommend +that you use the standard interface and simply set jpeg_color_space = +in_color_space (or jpeg_color_space = out_color_space for decompression). +The mechanism described in this section is necessary only to supply or +receive downsampled image data, in which not all components have the same +dimensions. + + +To compress raw data, you must supply the data in the colorspace to be used +in the JPEG file (please read the earlier section on Special color spaces) +and downsampled to the sampling factors specified in the JPEG parameters. +You must supply the data in the format used internally by the JPEG library, +namely a JSAMPIMAGE array. This is an array of pointers to two-dimensional +arrays, each of type JSAMPARRAY. Each 2-D array holds the values for one +color component. This structure is necessary since the components are of +different sizes. If the image dimensions are not a multiple of the MCU size, +you must also pad the data correctly (usually, this is done by replicating +the last column and/or row). The data must be padded to a multiple of a DCT +block in each component: that is, each downsampled row must contain a +multiple of 8 valid samples, and there must be a multiple of 8 sample rows +for each component. (For applications such as conversion of digital TV +images, the standard image size is usually a multiple of the DCT block size, +so that no padding need actually be done.) + +The procedure for compression of raw data is basically the same as normal +compression, except that you call jpeg_write_raw_data() in place of +jpeg_write_scanlines(). Before calling jpeg_start_compress(), you must do +the following: + * Set cinfo->raw_data_in to TRUE. (It is set FALSE by jpeg_set_defaults().) + This notifies the library that you will be supplying raw data. + * Ensure jpeg_color_space is correct --- an explicit jpeg_set_colorspace() + call is a good idea. Note that since color conversion is bypassed, + in_color_space is ignored, except that jpeg_set_defaults() uses it to + choose the default jpeg_color_space setting. + * Ensure the sampling factors, cinfo->comp_info[i].h_samp_factor and + cinfo->comp_info[i].v_samp_factor, are correct. Since these indicate the + dimensions of the data you are supplying, it's wise to set them + explicitly, rather than assuming the library's defaults are what you want. + +To pass raw data to the library, call jpeg_write_raw_data() in place of +jpeg_write_scanlines(). The two routines work similarly except that +jpeg_write_raw_data takes a JSAMPIMAGE data array rather than JSAMPARRAY. +The scanlines count passed to and returned from jpeg_write_raw_data is +measured in terms of the component with the largest v_samp_factor. + +jpeg_write_raw_data() processes one MCU row per call, which is to say +v_samp_factor*DCTSIZE sample rows of each component. The passed num_lines +value must be at least max_v_samp_factor*DCTSIZE, and the return value will +be exactly that amount (or possibly some multiple of that amount, in future +library versions). This is true even on the last call at the bottom of the +image; don't forget to pad your data as necessary. + +The required dimensions of the supplied data can be computed for each +component as + cinfo->comp_info[i].width_in_blocks*DCTSIZE samples per row + cinfo->comp_info[i].height_in_blocks*DCTSIZE rows in image +after jpeg_start_compress() has initialized those fields. If the valid data +is smaller than this, it must be padded appropriately. For some sampling +factors and image sizes, additional dummy DCT blocks are inserted to make +the image a multiple of the MCU dimensions. The library creates such dummy +blocks itself; it does not read them from your supplied data. Therefore you +need never pad by more than DCTSIZE samples. An example may help here. +Assume 2h2v downsampling of YCbCr data, that is + cinfo->comp_info[0].h_samp_factor = 2 for Y + cinfo->comp_info[0].v_samp_factor = 2 + cinfo->comp_info[1].h_samp_factor = 1 for Cb + cinfo->comp_info[1].v_samp_factor = 1 + cinfo->comp_info[2].h_samp_factor = 1 for Cr + cinfo->comp_info[2].v_samp_factor = 1 +and suppose that the nominal image dimensions (cinfo->image_width and +cinfo->image_height) are 101x101 pixels. Then jpeg_start_compress() will +compute downsampled_width = 101 and width_in_blocks = 13 for Y, +downsampled_width = 51 and width_in_blocks = 7 for Cb and Cr (and the same +for the height fields). You must pad the Y data to at least 13*8 = 104 +columns and rows, the Cb/Cr data to at least 7*8 = 56 columns and rows. The +MCU height is max_v_samp_factor = 2 DCT rows so you must pass at least 16 +scanlines on each call to jpeg_write_raw_data(), which is to say 16 actual +sample rows of Y and 8 each of Cb and Cr. A total of 7 MCU rows are needed, +so you must pass a total of 7*16 = 112 "scanlines". The last DCT block row +of Y data is dummy, so it doesn't matter what you pass for it in the data +arrays, but the scanlines count must total up to 112 so that all of the Cb +and Cr data gets passed. + +Output suspension is supported with raw-data compression: if the data +destination module suspends, jpeg_write_raw_data() will return 0. +In this case the same data rows must be passed again on the next call. + + +Decompression with raw data output implies bypassing all postprocessing: +you cannot ask for rescaling or color quantization, for instance. More +seriously, you must deal with the color space and sampling factors present in +the incoming file. If your application only handles, say, 2h1v YCbCr data, +you must check for and fail on other color spaces or other sampling factors. +The library will not convert to a different color space for you. + +To obtain raw data output, set cinfo->raw_data_out = TRUE before +jpeg_start_decompress() (it is set FALSE by jpeg_read_header()). Be sure to +verify that the color space and sampling factors are ones you can handle. +Then call jpeg_read_raw_data() in place of jpeg_read_scanlines(). The +decompression process is otherwise the same as usual. + +jpeg_read_raw_data() returns one MCU row per call, and thus you must pass a +buffer of at least max_v_samp_factor*DCTSIZE scanlines (scanline counting is +the same as for raw-data compression). The buffer you pass must be large +enough to hold the actual data plus padding to DCT-block boundaries. As with +compression, any entirely dummy DCT blocks are not processed so you need not +allocate space for them, but the total scanline count includes them. The +above example of computing buffer dimensions for raw-data compression is +equally valid for decompression. + +Input suspension is supported with raw-data decompression: if the data source +module suspends, jpeg_read_raw_data() will return 0. You can also use +buffered-image mode to read raw data in multiple passes. + + +Really raw data: DCT coefficients +--------------------------------- + +It is possible to read or write the contents of a JPEG file as raw DCT +coefficients. This facility is mainly intended for use in lossless +transcoding between different JPEG file formats. Other possible applications +include lossless cropping of a JPEG image, lossless reassembly of a +multi-strip or multi-tile TIFF/JPEG file into a single JPEG datastream, etc. + +To read the contents of a JPEG file as DCT coefficients, open the file and do +jpeg_read_header() as usual. But instead of calling jpeg_start_decompress() +and jpeg_read_scanlines(), call jpeg_read_coefficients(). This will read the +entire image into a set of virtual coefficient-block arrays, one array per +component. The return value is a pointer to an array of virtual-array +descriptors. Each virtual array can be accessed directly using the JPEG +memory manager's access_virt_barray method (see Memory management, below, +and also read structure.doc's discussion of virtual array handling). Or, +for simple transcoding to a different JPEG file format, the array list can +just be handed directly to jpeg_write_coefficients(). + +Each block in the block arrays contains quantized coefficient values in +normal array order (not JPEG zigzag order). The block arrays contain only +DCT blocks containing real data; any entirely-dummy blocks added to fill out +interleaved MCUs at the right or bottom edges of the image are discarded +during reading and are not stored in the block arrays. (The size of each +block array can be determined from the width_in_blocks and height_in_blocks +fields of the component's comp_info entry.) This is also the data format +expected by jpeg_write_coefficients(). + +When you are done using the virtual arrays, call jpeg_finish_decompress() +to release the array storage and return the decompression object to an idle +state; or just call jpeg_destroy() if you don't need to reuse the object. + +If you use a suspending data source, jpeg_read_coefficients() will return +NULL if it is forced to suspend; a non-NULL return value indicates successful +completion. You need not test for a NULL return value when using a +non-suspending data source. + +It is also possible to call jpeg_read_coefficients() to obtain access to the +decoder's coefficient arrays during a normal decode cycle in buffered-image +mode. This frammish might be useful for progressively displaying an incoming +image and then re-encoding it without loss. To do this, decode in buffered- +image mode as discussed previously, then call jpeg_read_coefficients() after +the last jpeg_finish_output() call. The arrays will be available for your use +until you call jpeg_finish_decompress(). + + +To write the contents of a JPEG file as DCT coefficients, you must provide +the DCT coefficients stored in virtual block arrays. You can either pass +block arrays read from an input JPEG file by jpeg_read_coefficients(), or +allocate virtual arrays from the JPEG compression object and fill them +yourself. In either case, jpeg_write_coefficients() is substituted for +jpeg_start_compress() and jpeg_write_scanlines(). Thus the sequence is + * Create compression object + * Set all compression parameters as necessary + * Request virtual arrays if needed + * jpeg_write_coefficients() + * jpeg_finish_compress() + * Destroy or re-use compression object +jpeg_write_coefficients() is passed a pointer to an array of virtual block +array descriptors; the number of arrays is equal to cinfo.num_components. + +The virtual arrays need only have been requested, not realized, before +jpeg_write_coefficients() is called. A side-effect of +jpeg_write_coefficients() is to realize any virtual arrays that have been +requested from the compression object's memory manager. Thus, when obtaining +the virtual arrays from the compression object, you should fill the arrays +after calling jpeg_write_coefficients(). The data is actually written out +when you call jpeg_finish_compress(); jpeg_write_coefficients() only writes +the file header. + +When writing raw DCT coefficients, it is crucial that the JPEG quantization +tables and sampling factors match the way the data was encoded, or the +resulting file will be invalid. For transcoding from an existing JPEG file, +we recommend using jpeg_copy_critical_parameters(). This routine initializes +all the compression parameters to default values (like jpeg_set_defaults()), +then copies the critical information from a source decompression object. +The decompression object should have just been used to read the entire +JPEG input file --- that is, it should be awaiting jpeg_finish_decompress(). + +jpeg_write_coefficients() marks all tables stored in the compression object +as needing to be written to the output file (thus, it acts like +jpeg_start_compress(cinfo, TRUE)). This is for safety's sake, to avoid +emitting abbreviated JPEG files by accident. If you really want to emit an +abbreviated JPEG file, call jpeg_suppress_tables(), or set the tables' +individual sent_table flags, between calling jpeg_write_coefficients() and +jpeg_finish_compress(). + + +Progress monitoring +------------------- + +Some applications may need to regain control from the JPEG library every so +often. The typical use of this feature is to produce a percent-done bar or +other progress display. (For a simple example, see cjpeg.c or djpeg.c.) +Although you do get control back frequently during the data-transferring pass +(the jpeg_read_scanlines or jpeg_write_scanlines loop), any additional passes +will occur inside jpeg_finish_compress or jpeg_start_decompress; those +routines may take a long time to execute, and you don't get control back +until they are done. + +You can define a progress-monitor routine which will be called periodically +by the library. No guarantees are made about how often this call will occur, +so we don't recommend you use it for mouse tracking or anything like that. +At present, a call will occur once per MCU row, scanline, or sample row +group, whichever unit is convenient for the current processing mode; so the +wider the image, the longer the time between calls. During the data +transferring pass, only one call occurs per call of jpeg_read_scanlines or +jpeg_write_scanlines, so don't pass a large number of scanlines at once if +you want fine resolution in the progress count. (If you really need to use +the callback mechanism for time-critical tasks like mouse tracking, you could +insert additional calls inside some of the library's inner loops.) + +To establish a progress-monitor callback, create a struct jpeg_progress_mgr, +fill in its progress_monitor field with a pointer to your callback routine, +and set cinfo->progress to point to the struct. The callback will be called +whenever cinfo->progress is non-NULL. (This pointer is set to NULL by +jpeg_create_compress or jpeg_create_decompress; the library will not change +it thereafter. So if you allocate dynamic storage for the progress struct, +make sure it will live as long as the JPEG object does. Allocating from the +JPEG memory manager with lifetime JPOOL_PERMANENT will work nicely.) You +can use the same callback routine for both compression and decompression. + +The jpeg_progress_mgr struct contains four fields which are set by the library: + long pass_counter; /* work units completed in this pass */ + long pass_limit; /* total number of work units in this pass */ + int completed_passes; /* passes completed so far */ + int total_passes; /* total number of passes expected */ +During any one pass, pass_counter increases from 0 up to (not including) +pass_limit; the step size is usually but not necessarily 1. The pass_limit +value may change from one pass to another. The expected total number of +passes is in total_passes, and the number of passes already completed is in +completed_passes. Thus the fraction of work completed may be estimated as + completed_passes + (pass_counter/pass_limit) + -------------------------------------------- + total_passes +ignoring the fact that the passes may not be equal amounts of work. + +When decompressing, pass_limit can even change within a pass, because it +depends on the number of scans in the JPEG file, which isn't always known in +advance. The computed fraction-of-work-done may jump suddenly (if the library +discovers it has overestimated the number of scans) or even decrease (in the +opposite case). It is not wise to put great faith in the work estimate. + +When using the decompressor's buffered-image mode, the progress monitor work +estimate is likely to be completely unhelpful, because the library has no way +to know how many output passes will be demanded of it. Currently, the library +sets total_passes based on the assumption that there will be one more output +pass if the input file end hasn't yet been read (jpeg_input_complete() isn't +TRUE), but no more output passes if the file end has been reached when the +output pass is started. This means that total_passes will rise as additional +output passes are requested. If you have a way of determining the input file +size, estimating progress based on the fraction of the file that's been read +will probably be more useful than using the library's value. + + +Memory management +----------------- + +This section covers some key facts about the JPEG library's built-in memory +manager. For more info, please read structure.doc's section about the memory +manager, and consult the source code if necessary. + +All memory and temporary file allocation within the library is done via the +memory manager. If necessary, you can replace the "back end" of the memory +manager to control allocation yourself (for example, if you don't want the +library to use malloc() and free() for some reason). + +Some data is allocated "permanently" and will not be freed until the JPEG +object is destroyed. Most data is allocated "per image" and is freed by +jpeg_finish_compress, jpeg_finish_decompress, or jpeg_abort. You can call the +memory manager yourself to allocate structures that will automatically be +freed at these times. Typical code for this is + ptr = (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, size); +Use JPOOL_PERMANENT to get storage that lasts as long as the JPEG object. +Use alloc_large instead of alloc_small for anything bigger than a few Kbytes. +There are also alloc_sarray and alloc_barray routines that automatically +build 2-D sample or block arrays. + +The library's minimum space requirements to process an image depend on the +image's width, but not on its height, because the library ordinarily works +with "strip" buffers that are as wide as the image but just a few rows high. +Some operating modes (eg, two-pass color quantization) require full-image +buffers. Such buffers are treated as "virtual arrays": only the current strip +need be in memory, and the rest can be swapped out to a temporary file. + +If you use the simplest memory manager back end (jmemnobs.c), then no +temporary files are used; virtual arrays are simply malloc()'d. Images bigger +than memory can be processed only if your system supports virtual memory. +The other memory manager back ends support temporary files of various flavors +and thus work in machines without virtual memory. They may also be useful on +Unix machines if you need to process images that exceed available swap space. + +When using temporary files, the library will make the in-memory buffers for +its virtual arrays just big enough to stay within a "maximum memory" setting. +Your application can set this limit by setting cinfo->mem->max_memory_to_use +after creating the JPEG object. (Of course, there is still a minimum size for +the buffers, so the max-memory setting is effective only if it is bigger than +the minimum space needed.) If you allocate any large structures yourself, you +must allocate them before jpeg_start_compress() or jpeg_start_decompress() in +order to have them counted against the max memory limit. Also keep in mind +that space allocated with alloc_small() is ignored, on the assumption that +it's too small to be worth worrying about; so a reasonable safety margin +should be left when setting max_memory_to_use. + +If you use the jmemname.c or jmemdos.c memory manager back end, it is +important to clean up the JPEG object properly to ensure that the temporary +files get deleted. (This is especially crucial with jmemdos.c, where the +"temporary files" may be extended-memory segments; if they are not freed, +DOS will require a reboot to recover the memory.) Thus, with these memory +managers, it's a good idea to provide a signal handler that will trap any +early exit from your program. The handler should call either jpeg_abort() +or jpeg_destroy() for any active JPEG objects. A handler is not needed with +jmemnobs.c, and shouldn't be necessary with jmemansi.c or jmemmac.c either, +since the C library is supposed to take care of deleting files made with +tmpfile(). + + +Memory usage +------------ + +Working memory requirements while performing compression or decompression +depend on image dimensions, image characteristics (such as colorspace and +JPEG process), and operating mode (application-selected options). + +As of v6b, the decompressor requires: + 1. About 24K in more-or-less-fixed-size data. This varies a bit depending + on operating mode and image characteristics (particularly color vs. + grayscale), but it doesn't depend on image dimensions. + 2. Strip buffers (of size proportional to the image width) for IDCT and + upsampling results. The worst case for commonly used sampling factors + is about 34 bytes * width in pixels for a color image. A grayscale image + only needs about 8 bytes per pixel column. + 3. A full-image DCT coefficient buffer is needed to decode a multi-scan JPEG + file (including progressive JPEGs), or whenever you select buffered-image + mode. This takes 2 bytes/coefficient. At typical 2x2 sampling, that's + 3 bytes per pixel for a color image. Worst case (1x1 sampling) requires + 6 bytes/pixel. For grayscale, figure 2 bytes/pixel. + 4. To perform 2-pass color quantization, the decompressor also needs a + 128K color lookup table and a full-image pixel buffer (3 bytes/pixel). +This does not count any memory allocated by the application, such as a +buffer to hold the final output image. + +The above figures are valid for 8-bit JPEG data precision and a machine with +32-bit ints. For 12-bit JPEG data, double the size of the strip buffers and +quantization pixel buffer. The "fixed-size" data will be somewhat smaller +with 16-bit ints, larger with 64-bit ints. Also, CMYK or other unusual +color spaces will require different amounts of space. + +The full-image coefficient and pixel buffers, if needed at all, do not +have to be fully RAM resident; you can have the library use temporary +files instead when the total memory usage would exceed a limit you set. +(But if your OS supports virtual memory, it's probably better to just use +jmemnobs and let the OS do the swapping.) + +The compressor's memory requirements are similar, except that it has no need +for color quantization. Also, it needs a full-image DCT coefficient buffer +if Huffman-table optimization is asked for, even if progressive mode is not +requested. + +If you need more detailed information about memory usage in a particular +situation, you can enable the MEM_STATS code in jmemmgr.c. + + +Library compile-time options +---------------------------- + +A number of compile-time options are available by modifying jmorecfg.h. + +The JPEG standard provides for both the baseline 8-bit DCT process and +a 12-bit DCT process. The IJG code supports 12-bit lossy JPEG if you define +BITS_IN_JSAMPLE as 12 rather than 8. Note that this causes JSAMPLE to be +larger than a char, so it affects the surrounding application's image data. +The sample applications cjpeg and djpeg can support 12-bit mode only for PPM +and GIF file formats; you must disable the other file formats to compile a +12-bit cjpeg or djpeg. (install.doc has more information about that.) +At present, a 12-bit library can handle *only* 12-bit images, not both +precisions. (If you need to include both 8- and 12-bit libraries in a single +application, you could probably do it by defining NEED_SHORT_EXTERNAL_NAMES +for just one of the copies. You'd have to access the 8-bit and 12-bit copies +from separate application source files. This is untested ... if you try it, +we'd like to hear whether it works!) + +Note that a 12-bit library always compresses in Huffman optimization mode, +in order to generate valid Huffman tables. This is necessary because our +default Huffman tables only cover 8-bit data. If you need to output 12-bit +files in one pass, you'll have to supply suitable default Huffman tables. +You may also want to supply your own DCT quantization tables; the existing +quality-scaling code has been developed for 8-bit use, and probably doesn't +generate especially good tables for 12-bit. + +The maximum number of components (color channels) in the image is determined +by MAX_COMPONENTS. The JPEG standard allows up to 255 components, but we +expect that few applications will need more than four or so. + +On machines with unusual data type sizes, you may be able to improve +performance or reduce memory space by tweaking the various typedefs in +jmorecfg.h. In particular, on some RISC CPUs, access to arrays of "short"s +is quite slow; consider trading memory for speed by making JCOEF, INT16, and +UINT16 be "int" or "unsigned int". UINT8 is also a candidate to become int. +You probably don't want to make JSAMPLE be int unless you have lots of memory +to burn. + +You can reduce the size of the library by compiling out various optional +functions. To do this, undefine xxx_SUPPORTED symbols as necessary. + +You can also save a few K by not having text error messages in the library; +the standard error message table occupies about 5Kb. This is particularly +reasonable for embedded applications where there's no good way to display +a message anyway. To do this, remove the creation of the message table +(jpeg_std_message_table[]) from jerror.c, and alter format_message to do +something reasonable without it. You could output the numeric value of the +message code number, for example. If you do this, you can also save a couple +more K by modifying the TRACEMSn() macros in jerror.h to expand to nothing; +you don't need trace capability anyway, right? + + +Portability considerations +-------------------------- + +The JPEG library has been written to be extremely portable; the sample +applications cjpeg and djpeg are slightly less so. This section summarizes +the design goals in this area. (If you encounter any bugs that cause the +library to be less portable than is claimed here, we'd appreciate hearing +about them.) + +The code works fine on ANSI C, C++, and pre-ANSI C compilers, using any of +the popular system include file setups, and some not-so-popular ones too. +See install.doc for configuration procedures. + +The code is not dependent on the exact sizes of the C data types. As +distributed, we make the assumptions that + char is at least 8 bits wide + short is at least 16 bits wide + int is at least 16 bits wide + long is at least 32 bits wide +(These are the minimum requirements of the ANSI C standard.) Wider types will +work fine, although memory may be used inefficiently if char is much larger +than 8 bits or short is much bigger than 16 bits. The code should work +equally well with 16- or 32-bit ints. + +In a system where these assumptions are not met, you may be able to make the +code work by modifying the typedefs in jmorecfg.h. However, you will probably +have difficulty if int is less than 16 bits wide, since references to plain +int abound in the code. + +char can be either signed or unsigned, although the code runs faster if an +unsigned char type is available. If char is wider than 8 bits, you will need +to redefine JOCTET and/or provide custom data source/destination managers so +that JOCTET represents exactly 8 bits of data on external storage. + +The JPEG library proper does not assume ASCII representation of characters. +But some of the image file I/O modules in cjpeg/djpeg do have ASCII +dependencies in file-header manipulation; so does cjpeg's select_file_type() +routine. + +The JPEG library does not rely heavily on the C library. In particular, C +stdio is used only by the data source/destination modules and the error +handler, all of which are application-replaceable. (cjpeg/djpeg are more +heavily dependent on stdio.) malloc and free are called only from the memory +manager "back end" module, so you can use a different memory allocator by +replacing that one file. + +The code generally assumes that C names must be unique in the first 15 +characters. However, global function names can be made unique in the +first 6 characters by defining NEED_SHORT_EXTERNAL_NAMES. + +More info about porting the code may be gleaned by reading jconfig.doc, +jmorecfg.h, and jinclude.h. + + +Notes for MS-DOS implementors +----------------------------- + +The IJG code is designed to work efficiently in 80x86 "small" or "medium" +memory models (i.e., data pointers are 16 bits unless explicitly declared +"far"; code pointers can be either size). You may be able to use small +model to compile cjpeg or djpeg by itself, but you will probably have to use +medium model for any larger application. This won't make much difference in +performance. You *will* take a noticeable performance hit if you use a +large-data memory model (perhaps 10%-25%), and you should avoid "huge" model +if at all possible. + +The JPEG library typically needs 2Kb-3Kb of stack space. It will also +malloc about 20K-30K of near heap space while executing (and lots of far +heap, but that doesn't count in this calculation). This figure will vary +depending on selected operating mode, and to a lesser extent on image size. +There is also about 5Kb-6Kb of constant data which will be allocated in the +near data segment (about 4Kb of this is the error message table). +Thus you have perhaps 20K available for other modules' static data and near +heap space before you need to go to a larger memory model. The C library's +static data will account for several K of this, but that still leaves a good +deal for your needs. (If you are tight on space, you could reduce the sizes +of the I/O buffers allocated by jdatasrc.c and jdatadst.c, say from 4K to +1K. Another possibility is to move the error message table to far memory; +this should be doable with only localized hacking on jerror.c.) + +About 2K of the near heap space is "permanent" memory that will not be +released until you destroy the JPEG object. This is only an issue if you +save a JPEG object between compression or decompression operations. + +Far data space may also be a tight resource when you are dealing with large +images. The most memory-intensive case is decompression with two-pass color +quantization, or single-pass quantization to an externally supplied color +map. This requires a 128Kb color lookup table plus strip buffers amounting +to about 40 bytes per column for typical sampling ratios (eg, about 25600 +bytes for a 640-pixel-wide image). You may not be able to process wide +images if you have large data structures of your own. + +Of course, all of these concerns vanish if you use a 32-bit flat-memory-model +compiler, such as DJGPP or Watcom C. We highly recommend flat model if you +can use it; the JPEG library is significantly faster in flat model. diff --git a/src/dep/src/irrlicht/jpeglib/ltconfig b/src/dep/src/irrlicht/jpeglib/ltconfig index 679dd73..2347e69 100644 --- a/src/dep/src/irrlicht/jpeglib/ltconfig +++ b/src/dep/src/irrlicht/jpeglib/ltconfig @@ -1,1512 +1,1512 @@ -#! /bin/sh - -# ltconfig - Create a system-specific libtool. -# Copyright (C) 1996-1998 Free Software Foundation, Inc. -# Gordon Matzigkeit , 1996 -# -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# A lot of this script is taken from autoconf-2.10. - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test "${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi - -echo=echo -if test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then : -else - # The Solaris and AIX default echo program unquotes backslashes. - # This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # So, we emulate echo with printf '%s\n' - echo="printf %s\\n" - if test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then : - else - # Oops. We have no working printf. Try to find a not-so-buggy echo. - echo=echo - IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" - for dir in $PATH /usr/ucb; do - if test -f $dir/echo && test "X`$dir/echo '\t'`" = 'X\t'; then - echo="$dir/echo" - break - fi - done - IFS="$save_ifs" - fi -fi - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e s/^X//' -sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' - -# The name of this program. -progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'` - -# Constants: -PROGRAM=ltconfig -PACKAGE=libtool -VERSION=1.2 -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.c 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.c $LIBS 1>&5' -rm="rm -f" - -help="Try \`$progname --help' for more information." - -# Global variables: -can_build_shared=yes -enable_shared=yes -# All known linkers require a `.a' archive for static linking. -enable_static=yes -ltmain= -silent= -srcdir= -ac_config_guess= -ac_config_sub= -host= -nonopt= -verify_host=yes -with_gcc=no -with_gnu_ld=no - -old_AR="$AR" -old_CC="$CC" -old_CFLAGS="$CFLAGS" -old_CPPFLAGS="$CPPFLAGS" -old_LD="$LD" -old_LN_S="$LN_S" -old_NM="$NM" -old_RANLIB="$RANLIB" - -# Parse the command line options. -args= -prev= -for option -do - case "$option" in - -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - eval "$prev=\$option" - prev= - continue - fi - - case "$option" in - --help) cat <&2 - echo "$help" 1>&2 - exit 1 - ;; - - *) - if test -z "$ltmain"; then - ltmain="$option" - elif test -z "$host"; then -# This generates an unnecessary warning for sparc-sun-solaris4.1.3_U1 -# if test -n "`echo $option| sed 's/[-a-z0-9.]//g'`"; then -# echo "$progname: warning \`$option' is not a valid host type" 1>&2 -# fi - host="$option" - else - echo "$progname: too many arguments" 1>&2 - echo "$help" 1>&2 - exit 1 - fi ;; - esac -done - -if test -z "$ltmain"; then - echo "$progname: you must specify a LTMAIN file" 1>&2 - echo "$help" 1>&2 - exit 1 -fi - -if test -f "$ltmain"; then : -else - echo "$progname: \`$ltmain' does not exist" 1>&2 - echo "$help" 1>&2 - exit 1 -fi - -# Quote any args containing shell metacharacters. -ltconfig_args= -for arg -do - case "$arg" in - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ltconfig_args="$ltconfig_args '$arg'" ;; - *) ltconfig_args="$ltconfig_args $arg" ;; - esac -done - -# A relevant subset of AC_INIT. - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 5 compiler messages saved in config.log -# 6 checking for... messages and results -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 -fi -exec 5>>./config.log - -# NLS nuisances. -# Only set LANG and LC_ALL to C if already set. -# These must not be set unconditionally because not all systems understand -# e.g. LANG=C (notably SCO). -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LANG+set}" = set; then LANG=C; export LANG; fi - -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi - -if test -z "$srcdir"; then - # Assume the source directory is the same one as the path to ltmain.sh. - srcdir=`$echo "$ltmain" | $Xsed -e 's%/[^/]*$%%'` - test "$srcdir" = "$ltmain" && srcdir=. -fi - -trap "$rm conftest*; exit 1" 1 2 15 -if test "$verify_host" = yes; then - # Check for config.guess and config.sub. - ac_aux_dir= - for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/config.guess; then - ac_aux_dir=$ac_dir - break - fi - done - if test -z "$ac_aux_dir"; then - echo "$progname: cannot find config.guess in $srcdir $srcdir/.. $srcdir/../.." 1>&2 - echo "$help" 1>&2 - exit 1 - fi - ac_config_guess=$ac_aux_dir/config.guess - ac_config_sub=$ac_aux_dir/config.sub - - # Make sure we can run config.sub. - if $ac_config_sub sun4 >/dev/null 2>&1; then : - else - echo "$progname: cannot run $ac_config_sub" 1>&2 - echo "$help" 1>&2 - exit 1 - fi - - echo $ac_n "checking host system type""... $ac_c" 1>&6 - - host_alias=$host - case "$host_alias" in - "") - if host_alias=`$ac_config_guess`; then : - else - echo "$progname: cannot guess host type; you must specify one" 1>&2 - echo "$help" 1>&2 - exit 1 - fi ;; - esac - host=`$ac_config_sub $host_alias` - echo "$ac_t$host" 1>&6 - - # Make sure the host verified. - test -z "$host" && exit 1 - -elif test -z "$host"; then - echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2 - echo "$help" 1>&2 - exit 1 -else - host_alias=$host -fi - -# Transform linux* to *-*-linux-gnu*, to support old configure scripts. -case "$host_os" in -linux-gnu*) ;; -linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` -esac - -host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - -case "$host_os" in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "${COLLECT_NAMES+set}" != set; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR cru $oldlib$oldobjs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -# Set a sane default for `AR'. -test -z "$AR" && AR=ar - -# If RANLIB is not set, then run the test. -if test "${RANLIB+set}" != "set"; then - result=no - - echo $ac_n "checking for ranlib... $ac_c" 1>&6 - IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" - for dir in $PATH; do - test -z "$dir" && dir=. - if test -f $dir/ranlib; then - RANLIB="ranlib" - result="ranlib" - break - fi - done - IFS="$save_ifs" - - echo "$ac_t$result" 1>&6 -fi - -if test -n "$RANLIB"; then - old_archive_cmds="$old_archive_cmds;\$RANLIB \$oldlib" - old_postinstall_cmds="\$RANLIB \$oldlib;$old_postinstall_cmds" -fi - -# Check to see if we are using GCC. -if test "$with_gcc" != yes || test -z "$CC"; then - # If CC is not set, then try to find GCC or a usable CC. - if test -z "$CC"; then - echo $ac_n "checking for gcc... $ac_c" 1>&6 - IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" - for dir in $PATH; do - IFS="$save_ifs" - test -z "$dir" && dir=. - if test -f $dir/gcc; then - CC="gcc" - break - fi - done - IFS="$save_ifs" - - if test -n "$CC"; then - echo "$ac_t$CC" 1>&6 - else - echo "$ac_t"no 1>&6 - fi - fi - - # Not "gcc", so try "cc", rejecting "/usr/ucb/cc". - if test -z "$CC"; then - echo $ac_n "checking for cc... $ac_c" 1>&6 - IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" - cc_rejected=no - for dir in $PATH; do - test -z "$dir" && dir=. - if test -f $dir/cc; then - if test "$dir/cc" = "/usr/ucb/cc"; then - cc_rejected=yes - continue - fi - CC="cc" - break - fi - done - IFS="$save_ifs" - if test $cc_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $CC - shift - if test $# -gt 0; then - # We chose a different compiler from the bogus one. - # However, it has the same name, so the bogon will be chosen - # first if we set CC to just the name; use the full file name. - shift - set dummy "$dir/cc" "$@" - shift - CC="$@" - fi - fi - - if test -n "$CC"; then - echo "$ac_t$CC" 1>&6 - else - echo "$ac_t"no 1>&6 - fi - - if test -z "$CC"; then - echo "$progname: error: no acceptable cc found in \$PATH" 1>&2 - exit 1 - fi - fi - - # Now see if the compiler is really GCC. - with_gcc=no - echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6 - echo "$progname:424: checking whether we are using GNU C" >&5 - - $rm conftest.c - cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - with_gcc=yes - fi - $rm conftest.c - echo "$ac_t$with_gcc" 1>&6 -fi - -# Allow CC to be a program name with arguments. -set dummy $CC -compiler="$2" - -echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6 -pic_flag= -special_shlib_compile_flags= -wl= -link_static_flag= -no_builtin_flag= - -if test "$with_gcc" = yes; then - wl='-Wl,' - link_static_flag='-static' - no_builtin_flag=' -fno-builtin' - - case "$host_os" in - aix3* | aix4* | irix5* | irix6* | osf3* | osf4*) - # PIC is the default for these OSes. - ;; - os2*) - # We can build DLLs from non-PIC. - ;; - amigaos*) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - pic_flag='-m68020 -resident32 -malways-restore-a4' - ;; - *) - pic_flag='-fPIC' - ;; - esac -else - # PORTME Check for PIC flags for the system compiler. - case "$host_os" in - aix3* | aix4*) - # All AIX code is PIC. - link_static_flag='-bnso -bI:/lib/syscalls.exp' - ;; - - hpux9* | hpux10*) - # Is there a better link_static_flag that works with the bundled CC? - wl='-Wl,' - link_static_flag="${wl}-a ${wl}archive" - pic_flag='+Z' - ;; - - irix5* | irix6*) - wl='-Wl,' - link_static_flag='-non_shared' - # PIC (with -KPIC) is the default. - ;; - - os2*) - # We can build DLLs from non-PIC. - ;; - - osf3* | osf4*) - # All OSF/1 code is PIC. - wl='-Wl,' - link_static_flag='-non_shared' - ;; - - sco3.2v5*) - pic_flag='-Kpic' - link_static_flag='-dn' - special_shlib_compile_flags='-belf' - ;; - - solaris2*) - pic_flag='-KPIC' - link_static_flag='-Bstatic' - wl='-Wl,' - ;; - - sunos4*) - pic_flag='-PIC' - link_static_flag='-Bstatic' - wl='-Qoption ld ' - ;; - - sysv4.2uw2*) - pic_flag='-KPIC' - link_static_flag='-Bstatic' - wl='-Wl,' - ;; - - uts4*) - pic_flag='-pic' - link_static_flag='-Bstatic' - ;; - - *) - can_build_shared=no - ;; - esac -fi - -if test -n "$pic_flag"; then - echo "$ac_t$pic_flag" 1>&6 - - # Check to make sure the pic_flag actually works. - echo $ac_n "checking if $compiler PIC flag $pic_flag works... $ac_c" 1>&6 - $rm conftest* - echo > conftest.c - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $pic_flag -DPIC" - echo "$progname:547: checking if $compiler PIC flag $pic_flag works" >&5 - if { (eval echo $progname:548: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then - # Append any warnings to the config.log. - cat conftest.err 1>&5 - - # On HP-UX, both CC and GCC only warn that PIC is supported... then they - # create non-PIC objects. So, if there were any warnings, we assume that - # PIC is not supported. - if test -s conftest.err; then - echo "$ac_t"no 1>&6 - can_build_shared=no - pic_flag= - else - echo "$ac_t"yes 1>&6 - pic_flag=" $pic_flag" - fi - else - # Append any errors to the config.log. - cat conftest.err 1>&5 - can_build_shared=no - pic_flag= - echo "$ac_t"no 1>&6 - fi - CFLAGS="$save_CFLAGS" - $rm conftest* -else - echo "$ac_t"none 1>&6 -fi - -# Check for any special shared library compilation flags. -if test -n "$special_shlib_compile_flags"; then - echo "$progname: warning: \`$CC' requires \`$special_shlib_compile_flags' to build shared libraries" 1>&2 - if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$special_shlib_compile_flags[ ]" >/dev/null; then : - else - echo "$progname: add \`$special_shlib_compile_flags' to the CC or CFLAGS env variable and reconfigure" 1>&2 - can_build_shared=no - fi -fi - -echo $ac_n "checking if $compiler static flag $link_static_flag works... $ac_c" 1>&6 -$rm conftest* -echo 'main(){return(0);}' > conftest.c -save_LDFLAGS="$LDFLAGS" -LDFLAGS="$LDFLAGS $link_static_flag" -echo "$progname:591: checking if $compiler static flag $link_static_flag works" >&5 -if { (eval echo $progname:592: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - echo "$ac_t$link_static_flag" 1>&6 -else - echo "$ac_t"none 1>&6 - link_static_flag= -fi -LDFLAGS="$save_LDFLAGS" -$rm conftest* - -if test -z "$LN_S"; then - # Check to see if we can use ln -s, or we need hard links. - echo $ac_n "checking whether ln -s works... $ac_c" 1>&6 - $rm conftestdata - if ln -s X conftestdata 2>/dev/null; then - $rm conftestdata - LN_S="ln -s" - else - LN_S=ln - fi - if test "$LN_S" = "ln -s"; then - echo "$ac_t"yes 1>&6 - else - echo "$ac_t"no 1>&6 - fi -fi - -# Make sure LD is an absolute path. -if test -z "$LD"; then - ac_prog=ld - if test "$with_gcc" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6 - echo "$progname:624: checking for ld used by GCC" >&5 - ac_prog=`($CC -print-prog-name=ld) 2>&5` - case "$ac_prog" in - # Accept absolute paths. - /* | [A-Za-z]:\\*) - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we are not using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac - elif test "$with_gnu_ld" = yes; then - echo $ac_n "checking for GNU ld... $ac_c" 1>&6 - echo "$progname:642: checking for GNU ld" >&5 - else - echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 - echo "$progname:645: checking for non-GNU ld" >&5 - fi - - if test -z "$LD"; then - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog"; then - LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some GNU ld's only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - if "$LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then - test "$with_gnu_ld" != no && break - else - test "$with_gnu_ld" != yes && break - fi - fi - done - IFS="$ac_save_ifs" - fi - - if test -n "$LD"; then - echo "$ac_t$LD" 1>&6 - else - echo "$ac_t"no 1>&6 - fi - - if test -z "$LD"; then - echo "$progname: error: no acceptable ld found in \$PATH" 1>&2 - exit 1 - fi -fi - -# Check to see if it really is or is not GNU ld. -echo $ac_n "checking if the linker ($LD) is GNU ld... $ac_c" 1>&6 -# I'd rather use --version here, but apparently some GNU ld's only accept -v. -if $LD -v 2>&1 &5; then - with_gnu_ld=yes -else - with_gnu_ld=no -fi -echo "$ac_t$with_gnu_ld" 1>&6 - -# See if the linker supports building shared libraries. -echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6 - -allow_undefined_flag= -no_undefined_flag= -archive_cmds= -old_archive_from_new_cmds= -export_dynamic_flag_spec= -hardcode_libdir_flag_spec= -hardcode_libdir_separator= -hardcode_direct=no -hardcode_minus_L=no -hardcode_shlibpath_var=unsupported -runpath_var= - -case "$host_os" in -amigaos* | sunos4*) - # On these operating systems, we should treat GNU ld like the system ld. - gnu_ld_acts_native=yes - ;; -*) - gnu_ld_acts_native=no - ;; -esac - -ld_shlibs=yes -if test "$with_gnu_ld" = yes && test "$gnu_ld_acts_native" != yes; then - - # See if GNU ld supports shared libraries. - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared ${wl}-soname $wl$soname -o $lib$libobjs' - runpath_var=LD_RUN_PATH - ld_shlibs=yes - else - ld_shlibs=no - fi - - if test "$ld_shlibs" = yes; then - hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec='${wl}--export-dynamic' - fi -else - # PORTME fill in a description of your system's linker (not GNU ld) - case "$host_os" in - aix3*) - allow_undefined_flag=unsupported - archive_cmds='$NM$libobjs | $global_symbol_pipe | sed '\''s/.* //'\'' > $lib.exp;$LD -o $objdir/$soname$libobjs -bE:$lib.exp -T512 -H512 -bM:SRE;$AR cru $lib $objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes - if test "$with_gcc" = yes && test -z "$link_static_flag"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - - aix4*) - allow_undefined_flag=unsupported - archive_cmds='$NM$libobjs | $global_symbol_pipe | sed '\''s/.* //'\'' > $lib.exp;$CC -o $objdir/$soname$libobjs ${wl}-bE:$lib.exp ${wl}-bM:SRE ${wl}-bnoentry;$AR cru $lib $objdir/$soname' - hardcode_direct=yes - hardcode_minus_L=yes - ;; - - amigaos*) - archive_cmds='$rm $objdir/a2ixlibrary.data;$echo "#define NAME $libname" > $objdir/a2ixlibrary.data;$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data;$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data;$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data;$AR cru $lib$libobjs;$RANLIB $lib;(cd $objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - archive_cmds='$LD -Bshareable -o $lib$libobjs /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - archive_cmds='$LD -Bshareable -o $lib$libobjs' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - # FreeBSD 3, at last, uses gcc -shared to do shared libraries. - freebsd3*) - archive_cmds='$CC -shared -o $lib$libobjs' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - hpux9*) - archive_cmds='$rm $objdir/$soname;$LD -b +s +b $install_libdir -o $objdir/$soname$libobjs;mv $objdir/$soname $lib' - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - export_dynamic_flag_spec='${wl}-E' - ;; - - hpux10*) - archive_cmds='$LD -b +h $soname +s +b $install_libdir -o $lib$libobjs' - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - export_dynamic_flag_spec='${wl}-E' - ;; - - irix5* | irix6*) - archive_cmds='$LD -shared -o $lib -soname $soname -set_version $verstring$libobjs' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - ;; - - netbsd*) - # Tested with NetBSD 1.2 ld - archive_cmds='$LD -Bshareable -o $lib$libobjs' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - openbsd*) - archive_cmds='$LD -Bshareable -o $lib$libobjs' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - os2*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - allow_undefined_flag=unsupported - archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def;$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def;$echo DATA >> $objdir/$libname.def;$echo " SINGLE NONSHARED" >> $objdir/$libname.def;$echo EXPORTS >> $objdir/$libname.def;emxexp$libobjs >> $objdir/$libname.def;$CC -Zdll -Zcrtdll -o $lib$libobjs $objdir/$libname.def' - old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def' - ;; - - osf3* | osf4*) - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$LD -shared${allow_undefined_flag} -o $lib -soname $soname -set_version $verstring$libobjs$deplibs' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - - sco3.2v5*) - archive_cmds='$LD -G -o $lib$libobjs' - hardcode_direct=yes - ;; - - solaris2*) - no_undefined_flag=' -z text' - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib$libobjs' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_shlibpath_var=no - - # Solaris 2 before 2.5 hardcodes -L paths. - case "$host_os" in - solaris2.[0-4]*) - hardcode_minus_L=yes - ;; - esac - ;; - - sunos4*) - if test "$with_gcc" = yes; then - archive_cmds='$CC -shared -o $lib$libobjs' - else - archive_cmds='$LD -assert pure-text -Bstatic -o $lib$libobjs' - fi - - if test "$with_gnu_ld" = yes; then - export_dynamic_flag_spec='${wl}-export-dynamic' - fi - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - uts4*) - archive_cmds='$LD -G -h $soname -o $lib$libobjs' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=no - hardcode_minus_L=no - hardcode_shlibpath_var=no - ;; - - *) - ld_shlibs=no - can_build_shared=no - ;; - esac -fi -echo "$ac_t$ld_shlibs" 1>&6 - -if test -z "$NM"; then - echo $ac_n "checking for BSD-compatible nm... $ac_c" 1>&6 - case "$NM" in - /* | [A-Za-z]:\\*) ;; # Let the user override the test with a path. - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/nm; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then - NM="$ac_dir/nm -B" - elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then - NM="$ac_dir/nm -p" - else - NM="$ac_dir/nm" - fi - break - fi - done - IFS="$ac_save_ifs" - test -z "$NM" && NM=nm - ;; - esac - echo "$ac_t$NM" 1>&6 -fi - -# Check for command to grab the raw symbol name followed by C symbol from nm. -echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6 - -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[BCDEGRSTU]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([_A-Za-z][_A-Za-z0-9]*\)' - -# Transform the above into a raw symbol and a C symbol. -symxfrm='\1 \1' - -# Define system-specific variables. -case "$host_os" in -aix*) - symcode='[BCDTU]' - ;; -irix*) - # Cannot use undefined symbols on IRIX because inlined functions mess us up. - symcode='[BCDEGRST]' - ;; -solaris2*) - symcode='[BDTU]' - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then - symcode='[ABCDGISTUW]' -fi - -# Write the raw and C identifiers. -global_symbol_pipe="sed -n -e 's/^.* $symcode $sympat$/$symxfrm/p'" - -# Check to see that the pipe works correctly. -pipe_works=no -$rm conftest* -cat > conftest.c <&5 -if { (eval echo $progname:972: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then - # Now try to grab the symbols. - nlist=conftest.nm - if { echo "$progname:975: eval \"$NM conftest.o | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.o | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then - - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - wcout=`wc "$nlist" 2>/dev/null` - count=`$echo "X$wcout" | $Xsed -e 's/^[ ]*\([0-9][0-9]*\).*$/\1/'` - (test "$count" -ge 0) 2>/dev/null || count=-1 - else - rm -f "$nlist"T - count=-1 - fi - - # Make sure that we snagged all the symbols we need. - if egrep ' nm_test_var$' "$nlist" >/dev/null; then - if egrep ' nm_test_func$' "$nlist" >/dev/null; then - cat < conftest.c -#ifdef __cplusplus -extern "C" { -#endif - -EOF - # Now generate the symbol file. - sed 's/^.* \(.*\)$/extern char \1;/' < "$nlist" >> conftest.c - - cat <> conftest.c -#if defined (__STDC__) && __STDC__ -# define __ptr_t void * -#else -# define __ptr_t char * -#endif - -/* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */ -int dld_preloaded_symbol_count = $count; - -/* The mapping between symbol names and symbols. */ -struct { - char *name; - __ptr_t address; -} -dld_preloaded_symbols[] = -{ -EOF - sed 's/^\(.*\) \(.*\)$/ {"\1", (__ptr_t) \&\2},/' < "$nlist" >> conftest.c - cat <<\EOF >> conftest.c - {0, (__ptr_t) 0} -}; - -#ifdef __cplusplus -} -#endif -EOF - # Now try linking the two files. - mv conftest.o conftestm.o - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - LIBS='conftestm.o' - CFLAGS="$CFLAGS$no_builtin_flag" - if { (eval echo $progname:1033: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - pipe_works=yes - else - echo "$progname: failed program was:" >&5 - cat conftest.c >&5 - fi - LIBS="$save_LIBS" - else - echo "cannot find nm_test_func in $nlist" >&5 - fi - else - echo "cannot find nm_test_var in $nlist" >&5 - fi - else - echo "cannot run $global_symbol_pipe" >&5 - fi -else - echo "$progname: failed program was:" >&5 - cat conftest.c >&5 -fi -$rm conftest* - -# Do not use the global_symbol_pipe unless it works. -echo "$ac_t$pipe_works" 1>&6 -test "$pipe_works" = yes || global_symbol_pipe= - -# Check hardcoding attributes. -echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6 -hardcode_action= -if test -n "$hardcode_libdir_flag_spec" || \ - test -n "$runpath_var"; then - - # We can hardcode non-existant directories. - if test "$hardcode_direct" != no && \ - test "$hardcode_minus_L" != no && \ - test "$hardcode_shlibpath_var" != no; then - - # Linking always hardcodes the temporary library directory. - hardcode_action=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action=immediate - fi -elif test "$hardcode_direct" != yes && \ - test "$hardcode_minus_L" != yes && \ - test "$hardcode_shlibpath_var" != yes; then - # We cannot hardcode anything. - hardcode_action=unsupported -else - # We can only hardcode existing directories. - hardcode_action=relink -fi -echo "$ac_t$hardcode_action" 1>&6 -test "$hardcode_action" = unsupported && can_build_shared=no - - -reload_flag= -reload_cmds='$LD$reload_flag -o $output$reload_objs' -echo $ac_n "checking for $LD option to reload object files... $ac_c" 1>&6 -# PORTME Some linker may need a different reload flag. -reload_flag='-r' -echo "$ac_t$reload_flag" -test -n "$reload_flag" && reload_flag=" $reload_flag" - -# PORTME Fill in your ld.so characteristics -library_names_spec= -libname_spec='lib$name' -soname_spec= -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -version_type=none -dynamic_linker="$host_os ld.so" - -echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6 -case "$host_os" in -aix3* | aix4*) - version_type=linux - library_names_spec='${libname}${release}.so.$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}.so.$major' - ;; - -amigaos*) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' - ;; - -freebsd2* | freebsd3*) - version_type=sunos - library_names_spec='${libname}${release}.so.$versuffix $libname.so' - finish_cmds='PATH="$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - ;; - -gnu*) - version_type=sunos - library_names_spec='${libname}${release}.so.$versuffix' - shlibpath_var=LD_LIBRARY_PATH - ;; - -hpux9* | hpux10*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - dynamic_linker="$host_os dld.sl" - version_type=sunos - shlibpath_var=SHLIB_PATH - library_names_spec='${libname}${release}.sl.$versuffix ${libname}${release}.sl.$major $libname.sl' - soname_spec='${libname}${release}.sl.$major' - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -irix5* | irix6*) - version_type=osf - soname_spec='${libname}${release}.so' - library_names_spec='${libname}${release}.so.$versuffix $libname.so' - shlibpath_var=LD_LIBRARY_PATH - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux-gnu*) - version_type=linux - library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' - soname_spec='${libname}${release}.so.$major' - finish_cmds='PATH="$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - - if test -f /lib/ld.so.1; then - dynamic_linker='GNU ld.so' - else - # Only the GNU ld.so supports shared libraries on MkLinux. - case "$host_cpu" in - powerpc*) dynamic_linker=no ;; - *) dynamic_linker='Linux ld.so' ;; - esac - fi - ;; - -netbsd* | openbsd*) - version_type=sunos - library_names_spec='${libname}${release}.so.$versuffix' - finish_cmds='PATH="$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - ;; - -os2*) - libname_spec='$name' - library_names_spec='$libname.dll $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4*) - version_type=osf - soname_spec='${libname}${release}.so' - library_names_spec='${libname}${release}.so.$versuffix $libname.so' - shlibpath_var=LD_LIBRARY_PATH - ;; - -sco3.2v5*) - version_type=osf - soname_spec='${libname}${release}.so.$major' - library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' - shlibpath_var=LD_LIBRARY_PATH - ;; - -solaris2*) - version_type=linux - library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' - soname_spec='${libname}${release}.so.$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}.so.$versuffix' - finish_cmds='PATH="$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - ;; - -sysv4.2uw2*) - version_type=linux - library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' - soname_spec='${libname}${release}.so.$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' - soname_spec='${libname}${release}.so.$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -echo "$ac_t$dynamic_linker" -test "$dynamic_linker" = no && can_build_shared=no - -# Report the final consequences. -echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6 - -echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6 -test "$can_build_shared" = "no" && enable_shared=no - -# On AIX, shared libraries and static libraries use the same namespace, and -# are all built from PIC. -case "$host_os" in -aix*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds;\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; -esac - -echo "$ac_t$enable_shared" 1>&6 - -# Make sure either enable_shared or enable_static is yes. -test "$enable_shared" = yes || enable_static=yes - -echo "checking whether to build static libraries... $enable_static" 1>&6 - -echo $ac_n "checking for objdir... $ac_c" 1>&6 -rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - objdir=_libs -fi -rmdir .libs 2>/dev/null -echo "$ac_t$objdir" 1>&6 - -# Copy echo and quote the copy, instead of the original, because it is -# used later. -ltecho="$echo" - -# Now quote all the things that may contain metacharacters. -for var in ltecho old_CC old_CFLAGS old_CPPFLAGS old_LD old_NM old_RANLIB \ - old_LN_S AR CC LD LN_S NM reload_flag reload_cmds wl pic_flag \ - link_static_flag no_builtin_flag export_dynamic_flag_spec \ - libname_spec library_names_spec soname_spec RANLIB \ - old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ - old_postuninstall_cmds archive_cmds postinstall_cmds postuninstall_cmds \ - allow_undefined_flag no_undefined_flag \ - finish_cmds finish_eval global_symbol_pipe \ - hardcode_libdir_flag_spec hardcode_libdir_separator; do - - case "$var" in - reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | archive_cmds | \ - postinstall_cmds | postuninstall_cmds | finish_cmds) - # Double-quote double-evaled strings. - eval "$var=\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\"\`" - ;; - *) - eval "$var=\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`" - ;; - esac -done - -ofile=libtool -trap "$rm $ofile; exit 1" 1 2 15 -echo creating $ofile -$rm $ofile -cat < $ofile -#! /bin/sh - -# libtool - Provide generalized library-building support services. -# Generated automatically by $PROGRAM - GNU $PACKAGE $VERSION -# NOTE: Changes made to this file will be lost: look at ltconfig or ltmain.sh. -# -# Copyright (C) 1996-1998 Free Software Foundation, Inc. -# Gordon Matzigkeit , 1996 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This program was configured as follows, -# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# -# CC="$old_CC" CFLAGS="$old_CFLAGS" CPPFLAGS="$old_CPPFLAGS" \\ -# LD="$old_LD" NM="$old_NM" RANLIB="$old_RANLIB" LN_S="$old_LN_S" \\ -# $0$ltconfig_args -# -# Compiler and other test output produced by $progname, useful for -# debugging $progname, is in ./config.log if it exists. - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="sed -e s/^X//" - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test "\${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi - -# An echo program that does not interpret backslashes. -echo="$ltecho" - -# The version of $progname that generated this script. -LTCONFIG_VERSION="$VERSION" - -# Shell to use when invoking shell scripts. -SHELL=${CONFIG_SHELL-/bin/sh} - -# Whether or not to build libtool libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build old-style libraries. -build_old_libs=$enable_static - -# The host system. -host_alias="$host_alias" -host="$host" - -# The archiver. -AR="$AR" - -# The default C compiler. -CC="$CC" - -# The linker used to build libraries. -LD="$LD" - -# Whether we need hard or soft links. -LN_S="$LN_S" - -# A BSD-compatible nm program. -NM="$NM" - -# The name of the directory that contains temporary libtool files. -objdir="$objdir" - -# How to create reloadable object files. -reload_flag="$reload_flag" -reload_cmds="$reload_cmds" - -# How to pass a linker flag through the compiler. -wl="$wl" - -# Additional compiler flags for building library objects. -pic_flag="$pic_flag" - -# Compiler flag to prevent dynamic linking. -link_static_flag="$link_static_flag" - -# Compiler flag to turn off builtin functions. -no_builtin_flag="$no_builtin_flag" - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec="$export_dynamic_flag_spec" - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec="$libname_spec" - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME. -library_names_spec="$library_names_spec" - -# The coded name of the library, if different from the real name. -soname_spec="$soname_spec" - -# Commands used to build and install an old-style archive. -RANLIB="$RANLIB" -old_archive_cmds="$old_archive_cmds" -old_postinstall_cmds="$old_postinstall_cmds" -old_postuninstall_cmds="$old_postuninstall_cmds" - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds="$old_archive_from_new_cmds" - -# Commands used to build and install a shared archive. -archive_cmds="$archive_cmds" -postinstall_cmds="$postinstall_cmds" -postuninstall_cmds="$postuninstall_cmds" - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag="$allow_undefined_flag" - -# Flag that forces no undefined symbols. -no_undefined_flag="$no_undefined_flag" - -# Commands used to finish a libtool library installation in a directory. -finish_cmds="$finish_cmds" - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval="$finish_eval" - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe="$global_symbol_pipe" - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec="$hardcode_libdir_flag_spec" - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator="$hardcode_libdir_separator" - -# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$hardcode_direct - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$hardcode_minus_L - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var - -EOF - -case "$host_os" in -aix3*) - cat <<\EOF >> $ofile -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "${COLLECT_NAMES+set}" != set; then - COLLECT_NAMES= - export COLLECT_NAMES -fi - -EOF - ;; -esac - -# Append the ltmain.sh script. -cat "$ltmain" >> $ofile || (rm -f $ofile; exit 1) - -chmod +x $ofile -exit 0 - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: +#! /bin/sh + +# ltconfig - Create a system-specific libtool. +# Copyright (C) 1996-1998 Free Software Foundation, Inc. +# Gordon Matzigkeit , 1996 +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A lot of this script is taken from autoconf-2.10. + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi + +echo=echo +if test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then : +else + # The Solaris and AIX default echo program unquotes backslashes. + # This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # So, we emulate echo with printf '%s\n' + echo="printf %s\\n" + if test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then : + else + # Oops. We have no working printf. Try to find a not-so-buggy echo. + echo=echo + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + for dir in $PATH /usr/ucb; do + if test -f $dir/echo && test "X`$dir/echo '\t'`" = 'X\t'; then + echo="$dir/echo" + break + fi + done + IFS="$save_ifs" + fi +fi + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' + +# The name of this program. +progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'` + +# Constants: +PROGRAM=ltconfig +PACKAGE=libtool +VERSION=1.2 +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.c 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.c $LIBS 1>&5' +rm="rm -f" + +help="Try \`$progname --help' for more information." + +# Global variables: +can_build_shared=yes +enable_shared=yes +# All known linkers require a `.a' archive for static linking. +enable_static=yes +ltmain= +silent= +srcdir= +ac_config_guess= +ac_config_sub= +host= +nonopt= +verify_host=yes +with_gcc=no +with_gnu_ld=no + +old_AR="$AR" +old_CC="$CC" +old_CFLAGS="$CFLAGS" +old_CPPFLAGS="$CPPFLAGS" +old_LD="$LD" +old_LN_S="$LN_S" +old_NM="$NM" +old_RANLIB="$RANLIB" + +# Parse the command line options. +args= +prev= +for option +do + case "$option" in + -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + eval "$prev=\$option" + prev= + continue + fi + + case "$option" in + --help) cat <&2 + echo "$help" 1>&2 + exit 1 + ;; + + *) + if test -z "$ltmain"; then + ltmain="$option" + elif test -z "$host"; then +# This generates an unnecessary warning for sparc-sun-solaris4.1.3_U1 +# if test -n "`echo $option| sed 's/[-a-z0-9.]//g'`"; then +# echo "$progname: warning \`$option' is not a valid host type" 1>&2 +# fi + host="$option" + else + echo "$progname: too many arguments" 1>&2 + echo "$help" 1>&2 + exit 1 + fi ;; + esac +done + +if test -z "$ltmain"; then + echo "$progname: you must specify a LTMAIN file" 1>&2 + echo "$help" 1>&2 + exit 1 +fi + +if test -f "$ltmain"; then : +else + echo "$progname: \`$ltmain' does not exist" 1>&2 + echo "$help" 1>&2 + exit 1 +fi + +# Quote any args containing shell metacharacters. +ltconfig_args= +for arg +do + case "$arg" in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ltconfig_args="$ltconfig_args '$arg'" ;; + *) ltconfig_args="$ltconfig_args $arg" ;; + esac +done + +# A relevant subset of AC_INIT. + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 5 compiler messages saved in config.log +# 6 checking for... messages and results +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>>./config.log + +# NLS nuisances. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LANG+set}" = set; then LANG=C; export LANG; fi + +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + +if test -z "$srcdir"; then + # Assume the source directory is the same one as the path to ltmain.sh. + srcdir=`$echo "$ltmain" | $Xsed -e 's%/[^/]*$%%'` + test "$srcdir" = "$ltmain" && srcdir=. +fi + +trap "$rm conftest*; exit 1" 1 2 15 +if test "$verify_host" = yes; then + # Check for config.guess and config.sub. + ac_aux_dir= + for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/config.guess; then + ac_aux_dir=$ac_dir + break + fi + done + if test -z "$ac_aux_dir"; then + echo "$progname: cannot find config.guess in $srcdir $srcdir/.. $srcdir/../.." 1>&2 + echo "$help" 1>&2 + exit 1 + fi + ac_config_guess=$ac_aux_dir/config.guess + ac_config_sub=$ac_aux_dir/config.sub + + # Make sure we can run config.sub. + if $ac_config_sub sun4 >/dev/null 2>&1; then : + else + echo "$progname: cannot run $ac_config_sub" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + + echo $ac_n "checking host system type""... $ac_c" 1>&6 + + host_alias=$host + case "$host_alias" in + "") + if host_alias=`$ac_config_guess`; then : + else + echo "$progname: cannot guess host type; you must specify one" 1>&2 + echo "$help" 1>&2 + exit 1 + fi ;; + esac + host=`$ac_config_sub $host_alias` + echo "$ac_t$host" 1>&6 + + # Make sure the host verified. + test -z "$host" && exit 1 + +elif test -z "$host"; then + echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2 + echo "$help" 1>&2 + exit 1 +else + host_alias=$host +fi + +# Transform linux* to *-*-linux-gnu*, to support old configure scripts. +case "$host_os" in +linux-gnu*) ;; +linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` +esac + +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +case "$host_os" in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "${COLLECT_NAMES+set}" != set; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR cru $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +# Set a sane default for `AR'. +test -z "$AR" && AR=ar + +# If RANLIB is not set, then run the test. +if test "${RANLIB+set}" != "set"; then + result=no + + echo $ac_n "checking for ranlib... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/ranlib; then + RANLIB="ranlib" + result="ranlib" + break + fi + done + IFS="$save_ifs" + + echo "$ac_t$result" 1>&6 +fi + +if test -n "$RANLIB"; then + old_archive_cmds="$old_archive_cmds;\$RANLIB \$oldlib" + old_postinstall_cmds="\$RANLIB \$oldlib;$old_postinstall_cmds" +fi + +# Check to see if we are using GCC. +if test "$with_gcc" != yes || test -z "$CC"; then + # If CC is not set, then try to find GCC or a usable CC. + if test -z "$CC"; then + echo $ac_n "checking for gcc... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + for dir in $PATH; do + IFS="$save_ifs" + test -z "$dir" && dir=. + if test -f $dir/gcc; then + CC="gcc" + break + fi + done + IFS="$save_ifs" + + if test -n "$CC"; then + echo "$ac_t$CC" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + fi + + # Not "gcc", so try "cc", rejecting "/usr/ucb/cc". + if test -z "$CC"; then + echo $ac_n "checking for cc... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + cc_rejected=no + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/cc; then + if test "$dir/cc" = "/usr/ucb/cc"; then + cc_rejected=yes + continue + fi + CC="cc" + break + fi + done + IFS="$save_ifs" + if test $cc_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same name, so the bogon will be chosen + # first if we set CC to just the name; use the full file name. + shift + set dummy "$dir/cc" "$@" + shift + CC="$@" + fi + fi + + if test -n "$CC"; then + echo "$ac_t$CC" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + + if test -z "$CC"; then + echo "$progname: error: no acceptable cc found in \$PATH" 1>&2 + exit 1 + fi + fi + + # Now see if the compiler is really GCC. + with_gcc=no + echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6 + echo "$progname:424: checking whether we are using GNU C" >&5 + + $rm conftest.c + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + with_gcc=yes + fi + $rm conftest.c + echo "$ac_t$with_gcc" 1>&6 +fi + +# Allow CC to be a program name with arguments. +set dummy $CC +compiler="$2" + +echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6 +pic_flag= +special_shlib_compile_flags= +wl= +link_static_flag= +no_builtin_flag= + +if test "$with_gcc" = yes; then + wl='-Wl,' + link_static_flag='-static' + no_builtin_flag=' -fno-builtin' + + case "$host_os" in + aix3* | aix4* | irix5* | irix6* | osf3* | osf4*) + # PIC is the default for these OSes. + ;; + os2*) + # We can build DLLs from non-PIC. + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + pic_flag='-m68020 -resident32 -malways-restore-a4' + ;; + *) + pic_flag='-fPIC' + ;; + esac +else + # PORTME Check for PIC flags for the system compiler. + case "$host_os" in + aix3* | aix4*) + # All AIX code is PIC. + link_static_flag='-bnso -bI:/lib/syscalls.exp' + ;; + + hpux9* | hpux10*) + # Is there a better link_static_flag that works with the bundled CC? + wl='-Wl,' + link_static_flag="${wl}-a ${wl}archive" + pic_flag='+Z' + ;; + + irix5* | irix6*) + wl='-Wl,' + link_static_flag='-non_shared' + # PIC (with -KPIC) is the default. + ;; + + os2*) + # We can build DLLs from non-PIC. + ;; + + osf3* | osf4*) + # All OSF/1 code is PIC. + wl='-Wl,' + link_static_flag='-non_shared' + ;; + + sco3.2v5*) + pic_flag='-Kpic' + link_static_flag='-dn' + special_shlib_compile_flags='-belf' + ;; + + solaris2*) + pic_flag='-KPIC' + link_static_flag='-Bstatic' + wl='-Wl,' + ;; + + sunos4*) + pic_flag='-PIC' + link_static_flag='-Bstatic' + wl='-Qoption ld ' + ;; + + sysv4.2uw2*) + pic_flag='-KPIC' + link_static_flag='-Bstatic' + wl='-Wl,' + ;; + + uts4*) + pic_flag='-pic' + link_static_flag='-Bstatic' + ;; + + *) + can_build_shared=no + ;; + esac +fi + +if test -n "$pic_flag"; then + echo "$ac_t$pic_flag" 1>&6 + + # Check to make sure the pic_flag actually works. + echo $ac_n "checking if $compiler PIC flag $pic_flag works... $ac_c" 1>&6 + $rm conftest* + echo > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $pic_flag -DPIC" + echo "$progname:547: checking if $compiler PIC flag $pic_flag works" >&5 + if { (eval echo $progname:548: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + # On HP-UX, both CC and GCC only warn that PIC is supported... then they + # create non-PIC objects. So, if there were any warnings, we assume that + # PIC is not supported. + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + can_build_shared=no + pic_flag= + else + echo "$ac_t"yes 1>&6 + pic_flag=" $pic_flag" + fi + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + can_build_shared=no + pic_flag= + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* +else + echo "$ac_t"none 1>&6 +fi + +# Check for any special shared library compilation flags. +if test -n "$special_shlib_compile_flags"; then + echo "$progname: warning: \`$CC' requires \`$special_shlib_compile_flags' to build shared libraries" 1>&2 + if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$special_shlib_compile_flags[ ]" >/dev/null; then : + else + echo "$progname: add \`$special_shlib_compile_flags' to the CC or CFLAGS env variable and reconfigure" 1>&2 + can_build_shared=no + fi +fi + +echo $ac_n "checking if $compiler static flag $link_static_flag works... $ac_c" 1>&6 +$rm conftest* +echo 'main(){return(0);}' > conftest.c +save_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS $link_static_flag" +echo "$progname:591: checking if $compiler static flag $link_static_flag works" >&5 +if { (eval echo $progname:592: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + echo "$ac_t$link_static_flag" 1>&6 +else + echo "$ac_t"none 1>&6 + link_static_flag= +fi +LDFLAGS="$save_LDFLAGS" +$rm conftest* + +if test -z "$LN_S"; then + # Check to see if we can use ln -s, or we need hard links. + echo $ac_n "checking whether ln -s works... $ac_c" 1>&6 + $rm conftestdata + if ln -s X conftestdata 2>/dev/null; then + $rm conftestdata + LN_S="ln -s" + else + LN_S=ln + fi + if test "$LN_S" = "ln -s"; then + echo "$ac_t"yes 1>&6 + else + echo "$ac_t"no 1>&6 + fi +fi + +# Make sure LD is an absolute path. +if test -z "$LD"; then + ac_prog=ld + if test "$with_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6 + echo "$progname:624: checking for ld used by GCC" >&5 + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. + /* | [A-Za-z]:\\*) + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we are not using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac + elif test "$with_gnu_ld" = yes; then + echo $ac_n "checking for GNU ld... $ac_c" 1>&6 + echo "$progname:642: checking for GNU ld" >&5 + else + echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 + echo "$progname:645: checking for non-GNU ld" >&5 + fi + + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog"; then + LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" + fi + + if test -n "$LD"; then + echo "$ac_t$LD" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + + if test -z "$LD"; then + echo "$progname: error: no acceptable ld found in \$PATH" 1>&2 + exit 1 + fi +fi + +# Check to see if it really is or is not GNU ld. +echo $ac_n "checking if the linker ($LD) is GNU ld... $ac_c" 1>&6 +# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + with_gnu_ld=yes +else + with_gnu_ld=no +fi +echo "$ac_t$with_gnu_ld" 1>&6 + +# See if the linker supports building shared libraries. +echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6 + +allow_undefined_flag= +no_undefined_flag= +archive_cmds= +old_archive_from_new_cmds= +export_dynamic_flag_spec= +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no +hardcode_shlibpath_var=unsupported +runpath_var= + +case "$host_os" in +amigaos* | sunos4*) + # On these operating systems, we should treat GNU ld like the system ld. + gnu_ld_acts_native=yes + ;; +*) + gnu_ld_acts_native=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes && test "$gnu_ld_acts_native" != yes; then + + # See if GNU ld supports shared libraries. + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared ${wl}-soname $wl$soname -o $lib$libobjs' + runpath_var=LD_RUN_PATH + ld_shlibs=yes + else + ld_shlibs=no + fi + + if test "$ld_shlibs" = yes; then + hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + fi +else + # PORTME fill in a description of your system's linker (not GNU ld) + case "$host_os" in + aix3*) + allow_undefined_flag=unsupported + archive_cmds='$NM$libobjs | $global_symbol_pipe | sed '\''s/.* //'\'' > $lib.exp;$LD -o $objdir/$soname$libobjs -bE:$lib.exp -T512 -H512 -bM:SRE;$AR cru $lib $objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$with_gcc" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix4*) + allow_undefined_flag=unsupported + archive_cmds='$NM$libobjs | $global_symbol_pipe | sed '\''s/.* //'\'' > $lib.exp;$CC -o $objdir/$soname$libobjs ${wl}-bE:$lib.exp ${wl}-bM:SRE ${wl}-bnoentry;$AR cru $lib $objdir/$soname' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + + amigaos*) + archive_cmds='$rm $objdir/a2ixlibrary.data;$echo "#define NAME $libname" > $objdir/a2ixlibrary.data;$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data;$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data;$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data;$AR cru $lib$libobjs;$RANLIB $lib;(cd $objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib$libobjs /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib$libobjs' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3, at last, uses gcc -shared to do shared libraries. + freebsd3*) + archive_cmds='$CC -shared -o $lib$libobjs' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + hpux9*) + archive_cmds='$rm $objdir/$soname;$LD -b +s +b $install_libdir -o $objdir/$soname$libobjs;mv $objdir/$soname $lib' + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + export_dynamic_flag_spec='${wl}-E' + ;; + + hpux10*) + archive_cmds='$LD -b +h $soname +s +b $install_libdir -o $lib$libobjs' + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + export_dynamic_flag_spec='${wl}-E' + ;; + + irix5* | irix6*) + archive_cmds='$LD -shared -o $lib -soname $soname -set_version $verstring$libobjs' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + ;; + + netbsd*) + # Tested with NetBSD 1.2 ld + archive_cmds='$LD -Bshareable -o $lib$libobjs' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + openbsd*) + archive_cmds='$LD -Bshareable -o $lib$libobjs' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def;$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def;$echo DATA >> $objdir/$libname.def;$echo " SINGLE NONSHARED" >> $objdir/$libname.def;$echo EXPORTS >> $objdir/$libname.def;emxexp$libobjs >> $objdir/$libname.def;$CC -Zdll -Zcrtdll -o $lib$libobjs $objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def' + ;; + + osf3* | osf4*) + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} -o $lib -soname $soname -set_version $verstring$libobjs$deplibs' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + sco3.2v5*) + archive_cmds='$LD -G -o $lib$libobjs' + hardcode_direct=yes + ;; + + solaris2*) + no_undefined_flag=' -z text' + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib$libobjs' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + + # Solaris 2 before 2.5 hardcodes -L paths. + case "$host_os" in + solaris2.[0-4]*) + hardcode_minus_L=yes + ;; + esac + ;; + + sunos4*) + if test "$with_gcc" = yes; then + archive_cmds='$CC -shared -o $lib$libobjs' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib$libobjs' + fi + + if test "$with_gnu_ld" = yes; then + export_dynamic_flag_spec='${wl}-export-dynamic' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib$libobjs' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=no + hardcode_minus_L=no + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + can_build_shared=no + ;; + esac +fi +echo "$ac_t$ld_shlibs" 1>&6 + +if test -z "$NM"; then + echo $ac_n "checking for BSD-compatible nm... $ac_c" 1>&6 + case "$NM" in + /* | [A-Za-z]:\\*) ;; # Let the user override the test with a path. + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + NM="$ac_dir/nm -B" + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + NM="$ac_dir/nm -p" + else + NM="$ac_dir/nm" + fi + break + fi + done + IFS="$ac_save_ifs" + test -z "$NM" && NM=nm + ;; + esac + echo "$ac_t$NM" 1>&6 +fi + +# Check for command to grab the raw symbol name followed by C symbol from nm. +echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6 + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRSTU]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Transform the above into a raw symbol and a C symbol. +symxfrm='\1 \1' + +# Define system-specific variables. +case "$host_os" in +aix*) + symcode='[BCDTU]' + ;; +irix*) + # Cannot use undefined symbols on IRIX because inlined functions mess us up. + symcode='[BCDEGRST]' + ;; +solaris2*) + symcode='[BDTU]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then + symcode='[ABCDGISTUW]' +fi + +# Write the raw and C identifiers. +global_symbol_pipe="sed -n -e 's/^.* $symcode $sympat$/$symxfrm/p'" + +# Check to see that the pipe works correctly. +pipe_works=no +$rm conftest* +cat > conftest.c <&5 +if { (eval echo $progname:972: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then + # Now try to grab the symbols. + nlist=conftest.nm + if { echo "$progname:975: eval \"$NM conftest.o | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.o | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then + + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + wcout=`wc "$nlist" 2>/dev/null` + count=`$echo "X$wcout" | $Xsed -e 's/^[ ]*\([0-9][0-9]*\).*$/\1/'` + (test "$count" -ge 0) 2>/dev/null || count=-1 + else + rm -f "$nlist"T + count=-1 + fi + + # Make sure that we snagged all the symbols we need. + if egrep ' nm_test_var$' "$nlist" >/dev/null; then + if egrep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.c +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + sed 's/^.* \(.*\)$/extern char \1;/' < "$nlist" >> conftest.c + + cat <> conftest.c +#if defined (__STDC__) && __STDC__ +# define __ptr_t void * +#else +# define __ptr_t char * +#endif + +/* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */ +int dld_preloaded_symbol_count = $count; + +/* The mapping between symbol names and symbols. */ +struct { + char *name; + __ptr_t address; +} +dld_preloaded_symbols[] = +{ +EOF + sed 's/^\(.*\) \(.*\)$/ {"\1", (__ptr_t) \&\2},/' < "$nlist" >> conftest.c + cat <<\EOF >> conftest.c + {0, (__ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.o conftestm.o + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS='conftestm.o' + CFLAGS="$CFLAGS$no_builtin_flag" + if { (eval echo $progname:1033: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + pipe_works=yes + else + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + LIBS="$save_LIBS" + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $global_symbol_pipe" >&5 + fi +else + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 +fi +$rm conftest* + +# Do not use the global_symbol_pipe unless it works. +echo "$ac_t$pipe_works" 1>&6 +test "$pipe_works" = yes || global_symbol_pipe= + +# Check hardcoding attributes. +echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6 +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test -n "$runpath_var"; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && \ + test "$hardcode_minus_L" != no && \ + test "$hardcode_shlibpath_var" != no; then + + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +elif test "$hardcode_direct" != yes && \ + test "$hardcode_minus_L" != yes && \ + test "$hardcode_shlibpath_var" != yes; then + # We cannot hardcode anything. + hardcode_action=unsupported +else + # We can only hardcode existing directories. + hardcode_action=relink +fi +echo "$ac_t$hardcode_action" 1>&6 +test "$hardcode_action" = unsupported && can_build_shared=no + + +reload_flag= +reload_cmds='$LD$reload_flag -o $output$reload_objs' +echo $ac_n "checking for $LD option to reload object files... $ac_c" 1>&6 +# PORTME Some linker may need a different reload flag. +reload_flag='-r' +echo "$ac_t$reload_flag" +test -n "$reload_flag" && reload_flag=" $reload_flag" + +# PORTME Fill in your ld.so characteristics +library_names_spec= +libname_spec='lib$name' +soname_spec= +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +version_type=none +dynamic_linker="$host_os ld.so" + +echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6 +case "$host_os" in +aix3* | aix4*) + version_type=linux + library_names_spec='${libname}${release}.so.$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}.so.$major' + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' + ;; + +freebsd2* | freebsd3*) + version_type=sunos + library_names_spec='${libname}${release}.so.$versuffix $libname.so' + finish_cmds='PATH="$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + ;; + +gnu*) + version_type=sunos + library_names_spec='${libname}${release}.so.$versuffix' + shlibpath_var=LD_LIBRARY_PATH + ;; + +hpux9* | hpux10*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + dynamic_linker="$host_os dld.sl" + version_type=sunos + shlibpath_var=SHLIB_PATH + library_names_spec='${libname}${release}.sl.$versuffix ${libname}${release}.sl.$major $libname.sl' + soname_spec='${libname}${release}.sl.$major' + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6*) + version_type=osf + soname_spec='${libname}${release}.so' + library_names_spec='${libname}${release}.so.$versuffix $libname.so' + shlibpath_var=LD_LIBRARY_PATH + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux-gnu*) + version_type=linux + library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' + soname_spec='${libname}${release}.so.$major' + finish_cmds='PATH="$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + + if test -f /lib/ld.so.1; then + dynamic_linker='GNU ld.so' + else + # Only the GNU ld.so supports shared libraries on MkLinux. + case "$host_cpu" in + powerpc*) dynamic_linker=no ;; + *) dynamic_linker='Linux ld.so' ;; + esac + fi + ;; + +netbsd* | openbsd*) + version_type=sunos + library_names_spec='${libname}${release}.so.$versuffix' + finish_cmds='PATH="$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + ;; + +os2*) + libname_spec='$name' + library_names_spec='$libname.dll $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4*) + version_type=osf + soname_spec='${libname}${release}.so' + library_names_spec='${libname}${release}.so.$versuffix $libname.so' + shlibpath_var=LD_LIBRARY_PATH + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}.so.$major' + library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris2*) + version_type=linux + library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' + soname_spec='${libname}${release}.so.$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}.so.$versuffix' + finish_cmds='PATH="$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + ;; + +sysv4.2uw2*) + version_type=linux + library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' + soname_spec='${libname}${release}.so.$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' + soname_spec='${libname}${release}.so.$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$ac_t$dynamic_linker" +test "$dynamic_linker" = no && can_build_shared=no + +# Report the final consequences. +echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6 + +echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6 +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds;\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; +esac + +echo "$ac_t$enable_shared" 1>&6 + +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes + +echo "checking whether to build static libraries... $enable_static" 1>&6 + +echo $ac_n "checking for objdir... $ac_c" 1>&6 +rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + objdir=_libs +fi +rmdir .libs 2>/dev/null +echo "$ac_t$objdir" 1>&6 + +# Copy echo and quote the copy, instead of the original, because it is +# used later. +ltecho="$echo" + +# Now quote all the things that may contain metacharacters. +for var in ltecho old_CC old_CFLAGS old_CPPFLAGS old_LD old_NM old_RANLIB \ + old_LN_S AR CC LD LN_S NM reload_flag reload_cmds wl pic_flag \ + link_static_flag no_builtin_flag export_dynamic_flag_spec \ + libname_spec library_names_spec soname_spec RANLIB \ + old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ + old_postuninstall_cmds archive_cmds postinstall_cmds postuninstall_cmds \ + allow_undefined_flag no_undefined_flag \ + finish_cmds finish_eval global_symbol_pipe \ + hardcode_libdir_flag_spec hardcode_libdir_separator; do + + case "$var" in + reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | archive_cmds | \ + postinstall_cmds | postuninstall_cmds | finish_cmds) + # Double-quote double-evaled strings. + eval "$var=\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\"\`" + ;; + *) + eval "$var=\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`" + ;; + esac +done + +ofile=libtool +trap "$rm $ofile; exit 1" 1 2 15 +echo creating $ofile +$rm $ofile +cat < $ofile +#! /bin/sh + +# libtool - Provide generalized library-building support services. +# Generated automatically by $PROGRAM - GNU $PACKAGE $VERSION +# NOTE: Changes made to this file will be lost: look at ltconfig or ltmain.sh. +# +# Copyright (C) 1996-1998 Free Software Foundation, Inc. +# Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This program was configured as follows, +# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# CC="$old_CC" CFLAGS="$old_CFLAGS" CPPFLAGS="$old_CPPFLAGS" \\ +# LD="$old_LD" NM="$old_NM" RANLIB="$old_RANLIB" LN_S="$old_LN_S" \\ +# $0$ltconfig_args +# +# Compiler and other test output produced by $progname, useful for +# debugging $progname, is in ./config.log if it exists. + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="sed -e s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "\${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi + +# An echo program that does not interpret backslashes. +echo="$ltecho" + +# The version of $progname that generated this script. +LTCONFIG_VERSION="$VERSION" + +# Shell to use when invoking shell scripts. +SHELL=${CONFIG_SHELL-/bin/sh} + +# Whether or not to build libtool libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build old-style libraries. +build_old_libs=$enable_static + +# The host system. +host_alias="$host_alias" +host="$host" + +# The archiver. +AR="$AR" + +# The default C compiler. +CC="$CC" + +# The linker used to build libraries. +LD="$LD" + +# Whether we need hard or soft links. +LN_S="$LN_S" + +# A BSD-compatible nm program. +NM="$NM" + +# The name of the directory that contains temporary libtool files. +objdir="$objdir" + +# How to create reloadable object files. +reload_flag="$reload_flag" +reload_cmds="$reload_cmds" + +# How to pass a linker flag through the compiler. +wl="$wl" + +# Additional compiler flags for building library objects. +pic_flag="$pic_flag" + +# Compiler flag to prevent dynamic linking. +link_static_flag="$link_static_flag" + +# Compiler flag to turn off builtin functions. +no_builtin_flag="$no_builtin_flag" + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec="$export_dynamic_flag_spec" + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec="$libname_spec" + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec="$library_names_spec" + +# The coded name of the library, if different from the real name. +soname_spec="$soname_spec" + +# Commands used to build and install an old-style archive. +RANLIB="$RANLIB" +old_archive_cmds="$old_archive_cmds" +old_postinstall_cmds="$old_postinstall_cmds" +old_postuninstall_cmds="$old_postuninstall_cmds" + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds="$old_archive_from_new_cmds" + +# Commands used to build and install a shared archive. +archive_cmds="$archive_cmds" +postinstall_cmds="$postinstall_cmds" +postuninstall_cmds="$postuninstall_cmds" + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag="$allow_undefined_flag" + +# Flag that forces no undefined symbols. +no_undefined_flag="$no_undefined_flag" + +# Commands used to finish a libtool library installation in a directory. +finish_cmds="$finish_cmds" + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval="$finish_eval" + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe="$global_symbol_pipe" + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec="$hardcode_libdir_flag_spec" + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator="$hardcode_libdir_separator" + +# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +EOF + +case "$host_os" in +aix3*) + cat <<\EOF >> $ofile +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "${COLLECT_NAMES+set}" != set; then + COLLECT_NAMES= + export COLLECT_NAMES +fi + +EOF + ;; +esac + +# Append the ltmain.sh script. +cat "$ltmain" >> $ofile || (rm -f $ofile; exit 1) + +chmod +x $ofile +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/src/dep/src/irrlicht/jpeglib/ltmain.sh b/src/dep/src/irrlicht/jpeglib/ltmain.sh index fe2d850..e9350b3 100644 --- a/src/dep/src/irrlicht/jpeglib/ltmain.sh +++ b/src/dep/src/irrlicht/jpeglib/ltmain.sh @@ -1,2453 +1,2453 @@ -# ltmain.sh - Provide generalized library-building support services. -# NOTE: Changing this file will not affect anything until you rerun ltconfig. -# -# Copyright (C) 1996-1998 Free Software Foundation, Inc. -# Gordon Matzigkeit , 1996 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# The name of this program. -progname=`$echo "$0" | sed 's%^.*/%%'` -modename="$progname" - -# Constants. -PROGRAM=ltmain.sh -PACKAGE=libtool -VERSION=1.2 - -default_mode= -help="Try \`$progname --help' for more information." -magic="%%%MAGIC variable%%%" -mkdir="mkdir" -mv="mv -f" -rm="rm -f" - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e s/^X//' -sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' - -# NLS nuisances. -# Only set LANG and LC_ALL to C if already set. -# These must not be set unconditionally because not all systems understand -# e.g. LANG=C (notably SCO). -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LANG+set}" = set; then LANG=C; export LANG; fi - -if test "$LTCONFIG_VERSION" != "$VERSION"; then - echo "$modename: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2 - echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit 1 -fi - -if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then - echo "$modename: not configured to build any kind of library" 1>&2 - echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit 1 -fi - -# Global variables. -mode=$default_mode -nonopt= -prev= -prevopt= -run= -show="$echo" -show_help= -execute_dlfiles= - -# Parse our command line options once, thoroughly. -while test $# -gt 0 -do - arg="$1" - shift - - case "$arg" in - -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case "$prev" in - execute_dlfiles) - eval "$prev=\"\$$prev \$arg\"" - ;; - *) - eval "$prev=\$arg" - ;; - esac - - prev= - prevopt= - continue - fi - - # Have we seen a non-optional argument yet? - case "$arg" in - --help) - show_help=yes - ;; - - --version) - echo "$PROGRAM (GNU $PACKAGE) $VERSION" - exit 0 - ;; - - --dry-run | -n) - run=: - ;; - - --features) - echo "host: $host" - if test "$build_libtool_libs" = yes; then - echo "enable shared libraries" - else - echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then - echo "enable static libraries" - else - echo "disable static libraries" - fi - exit 0 - ;; - - --finish) mode="finish" ;; - - --mode) prevopt="--mode" prev=mode ;; - --mode=*) mode="$optarg" ;; - - --quiet | --silent) - show=: - ;; - - -dlopen) - prevopt="-dlopen" - prev=execute_dlfiles - ;; - - -*) - $echo "$modename: unrecognized option \`$arg'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - - *) - nonopt="$arg" - break - ;; - esac -done - -if test -n "$prevopt"; then - $echo "$modename: option \`$prevopt' requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 -fi - -if test -z "$show_help"; then - - # Infer the operation mode. - if test -z "$mode"; then - case "$nonopt" in - *cc | *++ | gcc* | *-gcc*) - mode=link - for arg - do - case "$arg" in - -c) - mode=compile - break - ;; - esac - done - ;; - *db | *dbx) - mode=execute - ;; - *install*|cp|mv) - mode=install - ;; - *rm) - mode=uninstall - ;; - *) - # If we have no mode, but dlfiles were specified, then do execute mode. - test -n "$execute_dlfiles" && mode=execute - - # Just use the default operation mode. - if test -z "$mode"; then - if test -n "$nonopt"; then - $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 - else - $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 - fi - fi - ;; - esac - fi - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$execute_dlfiles" && test "$mode" != execute; then - $echo "$modename: unrecognized option \`-dlopen'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$modename --help --mode=$mode' for more information." - - # These modes are in order of execution frequency so that they run quickly. - case "$mode" in - # libtool compile mode - compile) - modename="$modename: compile" - # Get the compilation command and the source file. - base_compile= - lastarg= - srcfile="$nonopt" - suppress_output= - - for arg - do - # Accept any command-line options. - case "$arg" in - -o) - $echo "$modename: you cannot specify the output filename with \`-o'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - - -static) - build_libtool_libs=no - build_old_libs=yes - continue - ;; - esac - - # Accept the current argument as the source file. - lastarg="$srcfile" - srcfile="$arg" - - # Aesthetically quote the previous argument. - - # Backslashify any backslashes, double quotes, and dollar signs. - # These are the only characters that are still specially - # interpreted inside of double-quoted scrings. - lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` - - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly in scan - # sets, so we specify it separately. - case "$lastarg" in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - lastarg="\"$lastarg\"" - ;; - esac - - # Add the previous argument to base_compile. - if test -z "$base_compile"; then - base_compile="$lastarg" - else - base_compile="$base_compile $lastarg" - fi - done - - # Get the name of the library object. - libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` - - # Recognize several different file suffixes. - xform='[cCFSfms]' - case "$libobj" in - *.ada) xform=ada ;; - *.adb) xform=adb ;; - *.ads) xform=ads ;; - *.asm) xform=asm ;; - *.c++) xform=c++ ;; - *.cc) xform=cc ;; - *.cpp) xform=cpp ;; - *.cxx) xform=cxx ;; - *.f90) xform=f90 ;; - *.for) xform=for ;; - esac - - libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` - - case "$libobj" in - *.lo) obj=`$echo "X$libobj" | $Xsed -e 's/\.lo$/.o/'` ;; - *) - $echo "$modename: cannot determine name of library object from \`$srcfile'" 1>&2 - exit 1 - ;; - esac - - if test -z "$base_compile"; then - $echo "$modename: you must specify a compilation command" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Delete any leftover library objects. - if test "$build_old_libs" = yes; then - $run $rm $obj $libobj - trap "$run $rm $obj $libobj; exit 1" 1 2 15 - else - $run $rm $libobj - trap "$run $rm $libobj; exit 1" 1 2 15 - fi - - # Only build a PIC object if we are building libtool libraries. - if test "$build_libtool_libs" = yes; then - # Without this assignment, base_compile gets emptied. - fbsd_hideous_sh_bug=$base_compile - - # All platforms use -DPIC, to notify preprocessed assembler code. - $show "$base_compile$pic_flag -DPIC $srcfile" - if $run eval "$base_compile\$pic_flag -DPIC \$srcfile"; then : - else - test -n "$obj" && $run $rm $obj - exit 1 - fi - - # If we have no pic_flag, then copy the object into place and finish. - if test -z "$pic_flag"; then - $show "$LN_S $obj $libobj" - $run $LN_S $obj $libobj - exit $? - fi - - # Just move the object, then go on to compile the next one - $show "$mv $obj $libobj" - $run $mv $obj $libobj || exit 1 - - # Allow error messages only from the first compilation. - suppress_output=' >/dev/null 2>&1' - fi - - # Only build a position-dependent object if we build old libraries. - if test "$build_old_libs" = yes; then - # Suppress compiler output if we already did a PIC compilation. - $show "$base_compile $srcfile$suppress_output" - if $run eval "$base_compile \$srcfile$suppress_output"; then : - else - $run $rm $obj $libobj - exit 1 - fi - fi - - # Create an invalid libtool object if no PIC, so that we do not - # accidentally link it into a program. - if test "$build_libtool_libs" != yes; then - $show "echo timestamp > $libobj" - $run eval "echo timestamp > \$libobj" || exit $? - fi - - exit 0 - ;; - - # libtool link mode - link) - modename="$modename: link" - CC="$nonopt" - allow_undefined=yes - compile_command="$CC" - finalize_command="$CC" - - compile_shlibpath= - finalize_shlibpath= - deplibs= - dlfiles= - dlprefiles= - export_dynamic=no - hardcode_libdirs= - libobjs= - link_against_libtool_libs= - ltlibs= - objs= - prev= - prevarg= - release= - rpath= - perm_rpath= - temp_rpath= - vinfo= - - # We need to know -static, to get the right output filenames. - for arg - do - case "$arg" in - -all-static | -static) - if test "X$arg" = "X-all-static" && test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then - $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 - fi - build_libtool_libs=no - build_old_libs=yes - break - ;; - esac - done - - # See if our shared archives depend on static archives. - test -n "$old_archive_from_new_cmds" && build_old_libs=yes - - # Go through the arguments, transforming them on the way. - for arg - do - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case "$prev" in - output) - compile_command="$compile_command @OUTPUT@" - finalize_command="$finalize_command @OUTPUT@" - ;; - esac - - case "$prev" in - dlfiles|dlprefiles) - case "$arg" in - *.la | *.lo) ;; # We handle these cases below. - *) - dlprefiles="$dlprefiles $arg" - test "$prev" = dlfiles && dlfiles="$dlfiles $arg" - prev= - ;; - esac - ;; - release) - release="-$arg" - prev= - continue - ;; - rpath) - rpath="$rpath $arg" - prev= - continue - ;; - *) - eval "$prev=\"\$arg\"" - prev= - continue - ;; - esac - fi - - prevarg="$arg" - - case "$arg" in - -all-static) - if test -n "$link_static_flag"; then - compile_command="$compile_command $link_static_flag" - finalize_command="$finalize_command $link_static_flag" - fi - continue - ;; - - -allow-undefined) - # FIXME: remove this flag sometime in the future. - $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 - continue - ;; - - -dlopen) - prev=dlfiles - continue - ;; - - -dlpreopen) - prev=dlprefiles - continue - ;; - - -export-dynamic) - if test "$export_dynamic" != yes; then - export_dynamic=yes - if test -n "$export_dynamic_flag_spec"; then - eval arg=\"$export_dynamic_flag_spec\" - else - arg= - fi - - # Add the symbol object into the linking commands. - compile_command="$compile_command @SYMFILE@" - finalize_command="$finalize_command @SYMFILE@" - fi - ;; - - -L*) - dir=`$echo "X$arg" | $Xsed -e 's%^-L\(.*\)$%\1%'` - case "$dir" in - /* | [A-Za-z]:\\*) - # Add the corresponding hardcode_libdir_flag, if it is not identical. - ;; - *) - $echo "$modename: \`-L$dir' cannot specify a relative directory" 1>&2 - exit 1 - ;; - esac - deplibs="$deplibs $arg" - ;; - - -l*) deplibs="$deplibs $arg" ;; - - -no-undefined) - allow_undefined=no - continue - ;; - - -o) prev=output ;; - - -release) - prev=release - continue - ;; - - -rpath) - prev=rpath - continue - ;; - - -static) - # If we have no pic_flag, then this is the same as -all-static. - if test -z "$pic_flag" && test -n "$link_static_flag"; then - compile_command="$compile_command $link_static_flag" - finalize_command="$finalize_command $link_static_flag" - fi - continue - ;; - - -version-info) - prev=vinfo - continue - ;; - - # Some other compiler flag. - -* | +*) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case "$arg" in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - ;; - - *.o | *.a) - # A standard object. - objs="$objs $arg" - ;; - - *.lo) - # A library object. - if test "$prev" = dlfiles; then - dlfiles="$dlfiles $arg" - if test "$build_libtool_libs" = yes; then - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e 's/\.lo$/\.o/'` - prev= - fi - libobjs="$libobjs $arg" - ;; - - *.la) - # A libtool-controlled library. - - dlname= - libdir= - library_names= - old_library= - - # Check to see that this really is a libtool archive. - if (sed -e '2q' $arg | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then : - else - $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2 - exit 1 - fi - - # If there is no directory component, then add one. - case "$arg" in - */* | *\\*) . $arg ;; - *) . ./$arg ;; - esac - - if test -z "$libdir"; then - $echo "$modename: \`$arg' contains no -rpath information" 1>&2 - exit 1 - fi - - # Get the name of the library we link against. - linklib= - for l in $old_library $library_names; do - linklib="$l" - done - - if test -z "$linklib"; then - $echo "$modename: cannot find name of link library for \`$arg'" 1>&2 - exit 1 - fi - - # Find the relevant object directory and library name. - name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'` - dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` - if test "X$dir" = "X$arg"; then - dir="$objdir" - else - dir="$dir/$objdir" - fi - - # This library was specified with -dlopen. - if test "$prev" = dlfiles; then - dlfiles="$dlfiles $arg" - if test -z "$dlname"; then - # If there is no dlname, we need to preload. - prev=dlprefiles - else - # We should not create a dependency on this library, but we - # may need any libraries it requires. - compile_command="$compile_command$dependency_libs" - finalize_command="$finalize_command$dependency_libs" - prev= - continue - fi - fi - - # The library was specified with -dlpreopen. - if test "$prev" = dlprefiles; then - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - dlprefiles="$dlprefiles $dir/$old_library" - else - dlprefiles="$dlprefiles $dir/$linklib" - fi - prev= - fi - - if test "$build_libtool_libs" = yes && test -n "$library_names"; then - link_against_libtool_libs="$link_against_libtool_libs $arg" - if test -n "$shlibpath_var"; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath " in - *" $dir "*) ;; - *) temp_rpath="$temp_rpath $dir" ;; - esac - fi - - # This is the magic to use -rpath. - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - # Put the magic libdir with the hardcode flag. - hardcode_libdirs="$libdir" - libdir="@HARDCODE_LIBDIRS@" - else - # Just accumulate the unique libdirs. - case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - libdir= - fi - fi - - if test -n "$libdir"; then - eval flag=\"$hardcode_libdir_flag_spec\" - - compile_command="$compile_command $flag" - finalize_command="$finalize_command $flag" - fi - elif test -n "$runpath_var"; then - # Do the same for the permanent run path. - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - - - case "$hardcode_action" in - immediate) - if test "$hardcode_direct" = no; then - compile_command="$compile_command $dir/$linklib" - elif test "$hardcode_minus_L" = no; then - compile_command="$compile_command -L$dir -l$name" - elif test "$hardcode_shlibpath_var" = no; then - compile_shlibpath="$compile_shlibpath$dir:" - compile_command="$compile_command -l$name" - fi - ;; - - relink) - # We need an absolute path. - case "$dir" in - /* | [A-Za-z]:\\*) ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 - exit 1 - fi - dir="$absdir" - ;; - esac - - if test "$hardcode_direct" = yes; then - compile_command="$compile_command $dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - compile_command="$compile_command -L$dir -l$name" - elif test "$hardcode_shlibpath_var" = yes; then - compile_shlibpath="$compile_shlibpath$dir:" - compile_command="$compile_command -l$name" - fi - ;; - - *) - $echo "$modename: \`$hardcode_action' is an unknown hardcode action" 1>&2 - exit 1 - ;; - esac - - # Finalize command for both is simple: just hardcode it. - if test "$hardcode_direct" = yes; then - finalize_command="$finalize_command $libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then - finalize_command="$finalize_command -L$libdir -l$name" - elif test "$hardcode_shlibpath_var" = yes; then - finalize_shlibpath="$finalize_shlibpath$libdir:" - finalize_command="$finalize_command -l$name" - else - # We cannot seem to hardcode it, guess we'll fake it. - finalize_command="$finalize_command -L$libdir -l$name" - fi - else - # Transform directly to old archives if we don't build new libraries. - if test -n "$pic_flag" && test -z "$old_library"; then - $echo "$modename: cannot find static library for \`$arg'" 1>&2 - exit 1 - fi - - # Here we assume that one of hardcode_direct or hardcode_minus_L - # is not unsupported. This is valid on all known static and - # shared platforms. - if test "$hardcode_direct" != unsupported; then - test -n "$old_library" && linklib="$old_library" - compile_command="$compile_command $dir/$linklib" - finalize_command="$finalize_command $dir/$linklib" - else - compile_command="$compile_command -L$dir -l$name" - finalize_command="$finalize_command -L$dir -l$name" - fi - fi - - # Add in any libraries that this one depends upon. - compile_command="$compile_command$dependency_libs" - finalize_command="$finalize_command$dependency_libs" - continue - ;; - - # Some other compiler argument. - *) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case "$arg" in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - ;; - esac - - # Now actually substitute the argument into the commands. - if test -n "$arg"; then - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - fi - done - - if test -n "$prev"; then - $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test -n "$vinfo" && test -n "$release"; then - $echo "$modename: you cannot specify both \`-version-info' and \`-release'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - oldlib= - oldobjs= - case "$output" in - "") - $echo "$modename: you must specify an output file" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - - */* | *\\*) - $echo "$modename: output file \`$output' must have no directory components" 1>&2 - exit 1 - ;; - - *.a) - # Now set the variables for building old libraries. - build_libtool_libs=no - build_old_libs=yes - oldlib="$output" - $show "$rm $oldlib" - $run $rm $oldlib - ;; - - *.la) - # Make sure we only generate libraries of the form `libNAME.la'. - case "$output" in - lib*) ;; - *) - $echo "$modename: libtool library \`$arg' must begin with \`lib'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - esac - - name=`$echo "X$output" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - eval libname=\"$libname_spec\" - - # All the library-specific variables (install_libdir is set above). - library_names= - old_library= - dlname= - current=0 - revision=0 - age=0 - - if test -n "$objs"; then - $echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1 - exit 1 - fi - - # How the heck are we supposed to write a wrapper for a shared library? - if test -n "$link_against_libtool_libs"; then - $echo "$modename: libtool library \`$output' may not depend on uninstalled libraries:$link_against_libtool_libs" 1>&2 - exit 1 - fi - - if test -n "$dlfiles$dlprefiles"; then - $echo "$modename: warning: \`-dlopen' is ignored while creating libtool libraries" 1>&2 - # Nullify the symbol file. - compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` - fi - - if test -z "$rpath"; then - $echo "$modename: you must specify an installation directory with \`-rpath'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - set dummy $rpath - if test $# -gt 2; then - $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 - fi - install_libdir="$2" - - # Parse the version information argument. - IFS="${IFS= }"; save_ifs="$IFS"; IFS=':' - set dummy $vinfo - IFS="$save_ifs" - - if test -n "$5"; then - $echo "$modename: too many parameters to \`-version-info'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - test -n "$2" && current="$2" - test -n "$3" && revision="$3" - test -n "$4" && age="$4" - - # Check that each of the things are valid numbers. - case "$current" in - 0 | [1-9] | [1-9][0-9]*) ;; - *) - $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - case "$revision" in - 0 | [1-9] | [1-9][0-9]*) ;; - *) - $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - case "$age" in - 0 | [1-9] | [1-9][0-9]*) ;; - *) - $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - if test $age -gt $current; then - $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - fi - - # Calculate the version variables. - version_vars="version_type current age revision" - case "$version_type" in - none) ;; - - linux) - version_vars="$version_vars major versuffix" - major=`expr $current - $age` - versuffix="$major.$age.$revision" - ;; - - osf) - version_vars="$version_vars versuffix verstring" - major=`expr $current - $age` - versuffix="$current.$age.$revision" - verstring="$versuffix" - - # Add in all the interfaces that we are compatible with. - loop=$age - while test $loop != 0; do - iface=`expr $current - $loop` - loop=`expr $loop - 1` - verstring="$verstring:${iface}.0" - done - - # Make executables depend on our current version. - verstring="$verstring:${current}.0" - ;; - - sunos) - version_vars="$version_vars major versuffix" - major="$current" - versuffix="$current.$revision" - ;; - - *) - $echo "$modename: unknown library version type \`$version_type'" 1>&2 - echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit 1 - ;; - esac - - # Create the output directory, or remove our outputs if we need to. - if test -d $objdir; then - $show "$rm $objdir/$output $objdir/$libname.* $objdir/${libname}${release}.*" - $run $rm $objdir/$output $objdir/$libname.* $objdir/${libname}${release}.* - else - $show "$mkdir $objdir" - $run $mkdir $objdir - status=$? - if test $status -eq 0 || test -d $objdir; then : - else - exit $status - fi - fi - - # Check to see if the archive will have undefined symbols. - if test "$allow_undefined" = yes; then - if test "$allow_undefined_flag" = unsupported; then - $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 - build_libtool_libs=no - build_old_libs=yes - fi - else - # Don't allow undefined symbols. - allow_undefined_flag="$no_undefined_flag" - fi - - # Add libc to deplibs on all systems. - dependency_libs="$deplibs" - deplibs="$deplibs -lc" - - if test "$build_libtool_libs" = yes; then - # Get the real and link names of the library. - eval library_names=\"$library_names_spec\" - set dummy $library_names - realname="$2" - shift; shift - - if test -n "$soname_spec"; then - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - - lib="$objdir/$realname" - for link - do - linknames="$linknames $link" - done - - # Use standard objects if they are PIC. - test -z "$pic_flag" && libobjs=`$echo "X$libobjs " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//g'` - - # Do each of the archive commands. - eval cmds=\"$archive_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Create links to the real library. - for linkname in $linknames; do - $show "(cd $objdir && $LN_S $realname $linkname)" - $run eval '(cd $objdir && $LN_S $realname $linkname)' || exit $? - done - - # If -export-dynamic was specified, set the dlname. - if test "$export_dynamic" = yes; then - # On all known operating systems, these are identical. - dlname="$soname" - fi - fi - - # Now set the variables for building old libraries. - oldlib="$objdir/$libname.a" - ;; - - *.lo | *.o) - if test -n "$link_against_libtool_libs"; then - $echo "$modename: error: cannot link libtool libraries into reloadable objects" 1>&2 - exit 1 - fi - - if test -n "$deplibs"; then - $echo "$modename: warning: \`-l' and \`-L' are ignored while creating objects" 1>&2 - fi - - if test -n "$dlfiles$dlprefiles"; then - $echo "$modename: warning: \`-dlopen' is ignored while creating objects" 1>&2 - # Nullify the symbol file. - compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` - fi - - if test -n "$rpath"; then - $echo "$modename: warning: \`-rpath' is ignored while creating objects" 1>&2 - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored while creating objects" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored while creating objects" 1>&2 - fi - - case "$output" in - *.lo) - if test -n "$objs"; then - $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 - exit 1 - fi - libobj="$output" - obj=`$echo "X$output" | $Xsed -e 's/\.lo$/.o/'` - ;; - *) - libobj= - obj="$output" - ;; - esac - - # Delete the old objects. - $run $rm $obj $libobj - - # Create the old-style object. - reload_objs="$objs"`$echo "X$libobjs " | $Xsed -e 's/[^ ]*\.a //g' -e 's/\.lo /.o /g' -e 's/ $//g'` - - output="$obj" - eval cmds=\"$reload_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Exit if we aren't doing a library object file. - test -z "$libobj" && exit 0 - - if test "$build_libtool_libs" != yes; then - # Create an invalid libtool object if no PIC, so that we don't - # accidentally link it into a program. - $show "echo timestamp > $libobj" - $run eval "echo timestamp > $libobj" || exit $? - exit 0 - fi - - if test -n "$pic_flag"; then - # Only do commands if we really have different PIC objects. - reload_objs="$libobjs" - output="$libobj" - eval cmds=\"$reload_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - else - # Just create a symlink. - $show "$LN_S $obj $libobj" - $run $LN_S $obj $libobj || exit 1 - fi - - exit 0 - ;; - - *) - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored while linking programs" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored while creating objects" 1>&2 - fi - - if test -n "$rpath"; then - # If the user specified any rpath flags, then add them. - for libdir in $rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - # Put the magic libdir with the hardcode flag. - hardcode_libdirs="$libdir" - libdir="@HARDCODE_LIBDIRS@" - else - # Just accumulate the unique libdirs. - case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - libdir= - fi - fi - - if test -n "$libdir"; then - eval flag=\"$hardcode_libdir_flag_spec\" - - compile_command="$compile_command $flag" - finalize_command="$finalize_command $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - done - fi - - # Substitute the hardcoded libdirs into the compile commands. - if test -n "$hardcode_libdir_separator"; then - compile_command=`$echo "X$compile_command" | $Xsed -e "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"` - fi - - if test -n "$libobjs" && test "$build_old_libs" = yes; then - # Transform all the library objects into standard objects. - compile_command=`$echo "X$compile_command " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//'` - finalize_command=`$echo "X$finalize_command " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//'` - fi - - if test "$export_dynamic" = yes && test -n "$NM" && test -n "$global_symbol_pipe"; then - dlsyms="${output}S.c" - else - dlsyms= - fi - - if test -n "$dlsyms"; then - # Add our own program objects to the preloaded list. - dlprefiles=`$echo "X$objs$dlprefiles " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//'` - - # Discover the nlist of each of the dlfiles. - nlist="$objdir/${output}.nm" - - if test -d $objdir; then - $show "$rm $nlist ${nlist}T" - $run $rm "$nlist" "${nlist}T" - else - $show "$mkdir $objdir" - $run $mkdir $objdir - status=$? - if test $status -eq 0 || test -d $objdir; then : - else - exit $status - fi - fi - - for arg in $dlprefiles; do - $show "extracting global C symbols from \`$arg'" - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - - # Parse the name list into a source file. - $show "creating $objdir/$dlsyms" - if test -z "$run"; then - # Make sure we at least have an empty file. - test -f "$nlist" || : > "$nlist" - - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - wcout=`wc "$nlist" 2>/dev/null` - count=`echo "X$wcout" | $Xsed -e 's/^[ ]*\([0-9][0-9]*\).*$/\1/'` - (test "$count" -ge 0) 2>/dev/null || count=-1 - else - $rm "$nlist"T - count=-1 - fi - - case "$dlsyms" in - "") ;; - *.c) - $echo > "$objdir/$dlsyms" "\ -/* $dlsyms - symbol resolution table for \`$output' dlsym emulation. */ -/* Generated by $PROGRAM - GNU $PACKAGE $VERSION */ - -#ifdef __cplusplus -extern \"C\" { -#endif - -/* Prevent the only kind of declaration conflicts we can make. */ -#define dld_preloaded_symbol_count some_other_symbol -#define dld_preloaded_symbols some_other_symbol - -/* External symbol declarations for the compiler. */\ -" - - if test -f "$nlist"; then - sed -e 's/^.* \(.*\)$/extern char \1;/' < "$nlist" >> "$objdir/$dlsyms" - else - echo '/* NONE */' >> "$objdir/$dlsyms" - fi - - $echo >> "$objdir/$dlsyms" "\ - -#undef dld_preloaded_symbol_count -#undef dld_preloaded_symbols - -#if defined (__STDC__) && __STDC__ -# define __ptr_t void * -#else -# define __ptr_t char * -#endif - -/* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */ -int dld_preloaded_symbol_count = $count; - -/* The mapping between symbol names and symbols. */ -struct { - char *name; - __ptr_t address; -} -dld_preloaded_symbols[] = -{\ -" - - if test -f "$nlist"; then - sed 's/^\(.*\) \(.*\)$/ {"\1", (__ptr_t) \&\2},/' < "$nlist" >> "$objdir/$dlsyms" - fi - - $echo >> "$objdir/$dlsyms" "\ - {0, (__ptr_t) 0} -}; - -#ifdef __cplusplus -} -#endif\ -" - ;; - - *) - $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 - exit 1 - ;; - esac - fi - - # Now compile the dynamic symbol file. - $show "(cd $objdir && $CC -c$no_builtin_flag \"$dlsyms\")" - $run eval '(cd $objdir && $CC -c$no_builtin_flag "$dlsyms")' || exit $? - - # Transform the symbol file into the correct name. - compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$objdir/${output}S.o%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$objdir/${output}S.o%"` - elif test "$export_dynamic" != yes; then - test -n "$dlfiles$dlprefiles" && $echo "$modename: warning: \`-dlopen' and \`-dlpreopen' are ignored without \`-export-dynamic'" 1>&2 - else - # We keep going just in case the user didn't refer to - # dld_preloaded_symbols. The linker will fail if global_symbol_pipe - # really was required. - $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 - - # Nullify the symbol file. - compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` - fi - - if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then - # Replace the output file specification. - compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - finalize_command=`$echo "X$finalize_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - - # We have no uninstalled library dependencies, so finalize right now. - $show "$compile_command" - $run eval "$compile_command" - exit $? - fi - - # Replace the output file specification. - compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$objdir/$output"'%g'` - finalize_command=`$echo "X$finalize_command" | $Xsed -e 's%@OUTPUT@%'"$objdir/$output"'T%g'` - - # Create the binary in the object directory, then wrap it. - if test -d $objdir; then : - else - $show "$mkdir $objdir" - $run $mkdir $objdir - status=$? - if test $status -eq 0 || test -d $objdir; then : - else - exit $status - fi - fi - - if test -n "$shlibpath_var"; then - # We should set the shlibpath_var - rpath= - for dir in $temp_rpath; do - case "$dir" in - /* | [A-Za-z]:\\*) - # Absolute path. - rpath="$rpath$dir:" - ;; - *) - # Relative path: add a thisdir entry. - rpath="$rpath\$thisdir/$dir:" - ;; - esac - done - temp_rpath="$rpath" - fi - - # Delete the old output file. - $run $rm $output - - if test -n "$compile_shlibpath"; then - compile_command="$shlibpath_var=\"$compile_shlibpath\$$shlibpath_var\" $compile_command" - fi - if test -n "$finalize_shlibpath"; then - finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" - fi - - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - compile_command="$runpath_var=\"$rpath\$$runpath_var\" $compile_command" - finalize_command="$runpath_var=\"$rpath\$$runpath_var\" $finalize_command" - fi - - case "$hardcode_action" in - relink) - # AGH! Flame the AIX and HP-UX people for me, will ya? - $echo "$modename: warning: using a buggy system linker" 1>&2 - $echo "$modename: relinking will be required before \`$output' can be installed" 1>&2 - ;; - esac - - $show "$compile_command" - $run eval "$compile_command" || exit $? - - # Now create the wrapper script. - $show "creating $output" - - # Quote the finalize command for shipping. - finalize_command=`$echo "X$finalize_command" | $Xsed -e "$sed_quote_subst"` - - # Quote $echo for shipping. - qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` - - # Only actually do things if our run command is non-null. - if test -z "$run"; then - $rm $output - trap "$rm $output; exit 1" 1 2 15 - - $echo > $output "\ -#! /bin/sh - -# $output - temporary wrapper script for $objdir/$output -# Generated by ltmain.sh - GNU $PACKAGE $VERSION -# -# The $output program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of \``pwd`'. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e s/^X//' -sed_quote_subst='$sed_quote_subst' - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test \"\${CDPATH+set}\" = set; then CDPATH=; export CDPATH; fi - -# This environment variable determines our operation mode. -if test \"\$libtool_install_magic\" = \"$magic\"; then - # install mode needs the following variables: - link_against_libtool_libs='$link_against_libtool_libs' - finalize_command=\"$finalize_command\" -else - # When we are sourced in execute mode, \$file and \$echo are already set. - if test \"\$libtool_execute_magic\" = \"$magic\"; then : - else - echo=\"$qecho\" - file=\"\$0\" - fi\ -" - $echo >> $output "\ - - # Find the directory that this script lives in. - thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` - - # If there was a directory component, then change thisdir. - if test \"x\$destdir\" != \"x\$file\"; then - case \"\$destdir\" in - /* | [A-Za-z]:\\*) thisdir=\"\$destdir\" ;; - *) thisdir=\"\$thisdir/\$destdir\" ;; - esac - fi - - file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` - done - - # Try to get the absolute directory name. - absdir=\`cd \"\$thisdir\" && pwd\` - test -n \"\$absdir\" && thisdir=\"\$absdir\" - - progdir=\"\$thisdir/$objdir\" - program='$output' - - if test -f \"\$progdir/\$program\"; then" - - # Export our shlibpath_var if we have one. - if test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $echo >> $output "\ - # Add our own library path to $shlibpath_var - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" - - # Some systems cannot cope with colon-terminated $shlibpath_var - $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/:*\$//'\` - - export $shlibpath_var -" - fi - - $echo >> $output "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. - - # Export the path to the program. - PATH=\"\$progdir:\$PATH\" - export PATH - - exec \$program \${1+\"\$@\"} - - \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" - exit 1 - fi - else - # The program doesn't exist. - \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 - \$echo \"This script is just a wrapper for \$program.\" 1>&2 - echo \"See the $PACKAGE documentation for more information.\" 1>&2 - exit 1 - fi -fi\ -" - chmod +x $output - fi - exit 0 - ;; - esac - - # See if we need to build an old-fashioned archive. - if test "$build_old_libs" = "yes"; then - # Transform .lo files to .o files. - oldobjs="$objs"`$echo "X$libobjs " | $Xsed -e 's/[^ ]*\.a //g' -e 's/\.lo /.o /g' -e 's/ $//g'` - - # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - eval cmds=\"$old_archive_from_new_cmds\" - else - eval cmds=\"$old_archive_cmds\" - fi - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Now create the libtool archive. - case "$output" in - *.la) - old_library= - test "$build_old_libs" = yes && old_library="$libname.a" - - $show "creating $output" - - # Only create the output if not a dry run. - if test -z "$run"; then - $echo > $output "\ -# $output - a libtool library file -# Generated by ltmain.sh - GNU $PACKAGE $VERSION - -# The name that we can dlopen(3). -dlname='$dlname' - -# Names of this library. -library_names='$library_names' - -# The name of the static archive. -old_library='$old_library' - -# Libraries that this one depends upon. -dependency_libs='$dependency_libs' - -# Version information for $libname. -current=$current -age=$age -revision=$revision - -# Directory that this library needs to be installed in: -libdir='$install_libdir'\ -" - fi - - # Do a symbolic link so that the libtool archive can be found in - # LD_LIBRARY_PATH before the program is installed. - $show "(cd $objdir && $LN_S ../$output $output)" - $run eval "(cd $objdir && $LN_S ../$output $output)" || exit 1 - ;; - esac - exit 0 - ;; - - # libtool install mode - install) - modename="$modename: install" - - # There may be an optional /bin/sh argument at the beginning of - # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL"; then - # Aesthetically quote it. - arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` - case "$arg" in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$arg " - arg="$1" - shift - else - install_prog= - arg="$nonopt" - fi - - # The real first argument should be the name of the installation program. - # Aesthetically quote it. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case "$arg" in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog$arg" - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir= - stripme= - for arg - do - if test -n "$dest"; then - files="$files $dest" - dest="$arg" - continue - fi - - case "$arg" in - -d) isdir=yes ;; - -f) prev="-f" ;; - -g) prev="-g" ;; - -m) prev="-m" ;; - -o) prev="-o" ;; - -s) - stripme=" -s" - continue - ;; - -*) ;; - - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - prev= - else - dest="$arg" - continue - fi - ;; - esac - - # Aesthetically quote the argument. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case "$arg" in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog $arg" - done - - if test -z "$install_prog"; then - $echo "$modename: you must specify an install program" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test -n "$prev"; then - $echo "$modename: the \`$prev' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test -z "$files"; then - if test -z "$dest"; then - $echo "$modename: no file or destination specified" 1>&2 - else - $echo "$modename: you must specify a destination" 1>&2 - fi - $echo "$help" 1>&2 - exit 1 - fi - - # Strip any trailing slash from the destination. - dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` - - # Check to see that the destination is a directory. - test -d "$dest" && isdir=yes - if test -n "$isdir"; then - destdir="$dest" - destname= - else - destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` - test "X$destdir" = "X$dest" && destdir=. - destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` - - # Not a directory, so check to see that there is only one file specified. - set dummy $files - if test $# -gt 2; then - $echo "$modename: \`$dest' is not a directory" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - fi - case "$destdir" in - /* | [A-Za-z]:\\*) ;; - *) - for file in $files; do - case "$file" in - *.lo) ;; - *) - $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - esac - done - ;; - esac - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - staticlibs= - future_libdirs= - current_libdirs= - for file in $files; do - - # Do each installation. - case "$file" in - *.a) - # Do the static libraries later. - staticlibs="$staticlibs $file" - ;; - - *.la) - # Check to see that this really is a libtool archive. - if (sed -e '2q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then : - else - $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - library_names= - old_library= - # If there is no directory component, then add one. - case "$file" in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Add the libdir to current_libdirs if it is the destination. - if test "X$destdir" = "X$libdir"; then - case "$current_libdirs " in - *" $libdir "*) ;; - *) current_libdirs="$current_libdirs $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) future_libdirs="$future_libdirs $libdir" ;; - esac - fi - - dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/" - test "X$dir" = "X$file/" && dir= - dir="$dir$objdir" - - # See the names of the shared library. - set dummy $library_names - if test -n "$2"; then - realname="$2" - shift - shift - - # Install the shared library and build the symlinks. - $show "$install_prog $dir/$realname $destdir/$realname" - $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $? - test "X$dlname" = "X$realname" && dlname= - - if test $# -gt 0; then - # Delete the old symlinks. - rmcmd="$rm" - for linkname - do - rmcmd="$rmcmd $destdir/$linkname" - done - $show "$rmcmd" - $run $rmcmd - - # ... and create new ones. - for linkname - do - test "X$dlname" = "X$linkname" && dlname= - $show "(cd $destdir && $LN_S $realname $linkname)" - $run eval "(cd $destdir && $LN_S $realname $linkname)" - done - fi - - if test -n "$dlname"; then - # Install the dynamically-loadable library. - $show "$install_prog $dir/$dlname $destdir/$dlname" - $run eval "$install_prog $dir/$dlname $destdir/$dlname" || exit $? - fi - - # Do each command in the postinstall commands. - lib="$destdir/$realname" - eval cmds=\"$postinstall_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Install the pseudo-library for information purposes. - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - $show "$install_prog $file $destdir/$name" - $run eval "$install_prog $file $destdir/$name" || exit $? - - # Maybe install the static library, too. - test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" - ;; - - *.lo) - # Install (i.e. copy) a libtool object. - - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - destfile="$destdir/$destfile" - fi - - # Deduce the name of the destination old-style object file. - case "$destfile" in - *.lo) - staticdest=`$echo "X$destfile" | $Xsed -e 's/\.lo$/\.o/'` - ;; - *.o) - staticdest="$destfile" - destfile= - ;; - *) - $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - esac - - # Install the libtool object if requested. - if test -n "$destfile"; then - $show "$install_prog $file $destfile" - $run eval "$install_prog $file $destfile" || exit $? - fi - - # Install the old object if enabled. - if test "$build_old_libs" = yes; then - # Deduce the name of the old-style object file. - staticobj=`$echo "X$file" | $Xsed -e 's/\.lo$/\.o/'` - - $show "$install_prog $staticobj $staticdest" - $run eval "$install_prog \$staticobj \$staticdest" || exit $? - fi - exit 0 - ;; - - *) - # Do a test to see if this is really a libtool program. - if (sed -e '4q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then - link_against_libtool_libs= - finalize_command= - - # If there is no directory component, then add one. - case "$file" in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Check the variables that should have been set. - if test -z "$link_against_libtool_libs" || test -z "$finalize_command"; then - $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 - exit 1 - fi - - finalize=yes - for lib in $link_against_libtool_libs; do - # Check to see that each library is installed. - libdir= - if test -f "$lib"; then - # If there is no directory component, then add one. - case "$lib" in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - fi - libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`" - if test -z "$libdir"; then - $echo "$modename: warning: \`$lib' contains no -rpath information" 1>&2 - elif test -f "$libfile"; then : - else - $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 - finalize=no - fi - done - - if test "$hardcode_action" = relink; then - if test "$finalize" = yes; then - $echo "$modename: warning: relinking \`$file' on behalf of your buggy system linker" 1>&2 - $show "$finalize_command" - if $run eval "$finalize_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - continue - fi - file="$objdir/$file"T - else - $echo "$modename: warning: cannot relink \`$file' on behalf of your buggy system linker" 1>&2 - fi - else - # Install the binary that we compiled earlier. - file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` - fi - fi - - $show "$install_prog$stripme $file $dest" - $run eval "$install_prog\$stripme \$file \$dest" || exit $? - ;; - esac - done - - for file in $staticlibs; do - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - - # Set up the ranlib parameters. - oldlib="$destdir/$name" - - $show "$install_prog $file $oldlib" - $run eval "$install_prog \$file \$oldlib" || exit $? - - # Do each command in the postinstall commands. - eval cmds=\"$old_postinstall_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - done - - if test -n "$future_libdirs"; then - $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 - fi - - if test -n "$current_libdirs"; then - # Maybe just do a dry run. - test -n "$run" && current_libdirs=" -n$current_libdirs" - exec $SHELL $0 --finish$current_libdirs - exit 1 - fi - - exit 0 - ;; - - # libtool finish mode - finish) - modename="$modename: finish" - libdirs="$nonopt" - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for dir - do - libdirs="$libdirs $dir" - done - - for libdir in $libdirs; do - if test -n "$finish_cmds"; then - # Do each command in the finish commands. - eval cmds=\"$finish_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" - done - IFS="$save_ifs" - fi - if test -n "$finish_eval"; then - # Do the single finish_eval. - eval cmds=\"$finish_eval\" - $run eval "$cmds" - fi - done - fi - - echo "------------------------------------------------------------------------------" - echo "Libraries have been installed in:" - for libdir in $libdirs; do - echo " $libdir" - done - echo - echo "To link against installed libraries in a given directory, LIBDIR," - echo "you must use the \`-LLIBDIR' flag during linking." - echo - echo " You will also need to do one of the following:" - if test -n "$shlibpath_var"; then - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - echo " during execution" - fi - if test -n "$runpath_var"; then - echo " - add LIBDIR to the \`$runpath_var' environment variable" - echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - - echo " - use the \`$flag' linker flag" - fi - if test -f /etc/ld.so.conf; then - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - echo - echo "See any operating system documentation about shared libraries for" - echo "more information, such as the ld(1) and ld.so(8) manual pages." - echo "------------------------------------------------------------------------------" - exit 0 - ;; - - # libtool execute mode - execute) - modename="$modename: execute" - - # The first argument is the command name. - cmd="$nonopt" - if test -z "$cmd"; then - $echo "$modename: you must specify a COMMAND" 1>&2 - $echo "$help" - exit 1 - fi - - # Handle -dlopen flags immediately. - for file in $execute_dlfiles; do - if test -f "$file"; then : - else - $echo "$modename: \`$file' is not a file" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - dir= - case "$file" in - *.la) - # Check to see that this really is a libtool archive. - if (sed -e '2q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Read the libtool library. - dlname= - library_names= - - # If there is no directory component, then add one. - case "$file" in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Skip this library if it cannot be dlopened. - if test -z "$dlname"; then - # Warn if it was a shared library. - test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" - continue - fi - - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - - if test -f "$dir/$objdir/$dlname"; then - dir="$dir/$objdir" - else - $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 - exit 1 - fi - ;; - - *.lo) - # Just add the directory containing the .lo file. - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - ;; - - *) - $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 - continue - ;; - esac - - # Get the absolute pathname. - absdir=`cd "$dir" && pwd` - test -n "$absdir" && dir="$absdir" - - # Now add the directory to shlibpath_var. - if eval "test -z \"\$$shlibpath_var\""; then - eval "$shlibpath_var=\"\$dir\"" - else - eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" - fi - done - - # This variable tells wrapper scripts just to set shlibpath_var - # rather than running their programs. - libtool_execute_magic="$magic" - - # Check if any of the arguments is a wrapper script. - args= - for file - do - case "$file" in - -*) ;; - *) - # Do a test to see if this is really a libtool program. - if (sed -e '4q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then - # If there is no directory component, then add one. - case "$file" in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Transform arg to wrapped name. - file="$progdir/$program" - fi - ;; - esac - # Quote arguments (to preserve shell metacharacters). - file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` - args="$args \"$file\"" - done - - if test -z "$run"; then - # Export the shlibpath_var. - eval "export $shlibpath_var" - - # Now actually exec the command. - eval "exec \$cmd$args" - - $echo "$modename: cannot exec \$cmd$args" - exit 1 - else - # Display what would be done. - eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" - $echo "export $shlibpath_var" - $echo "$cmd$args" - exit 0 - fi - ;; - - # libtool uninstall mode - uninstall) - modename="$modename: uninstall" - rm="$nonopt" - files= - - for arg - do - case "$arg" in - -*) rm="$rm $arg" ;; - *) files="$files $arg" ;; - esac - done - - if test -z "$rm"; then - $echo "$modename: you must specify an RM program" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - for file in $files; do - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - - rmfiles="$file" - - case "$name" in - *.la) - # Possibly a libtool archive, so verify it. - if (sed -e '2q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then - . $dir/$name - - # Delete the libtool libraries and symlinks. - for n in $library_names; do - rmfiles="$rmfiles $dir/$n" - test "X$n" = "X$dlname" && dlname= - done - test -n "$dlname" && rmfiles="$rmfiles $dir/$dlname" - test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library" - - $show "$rm $rmfiles" - $run $rm $rmfiles - - if test -n "$library_names"; then - # Do each command in the postuninstall commands. - eval cmds=\"$postuninstall_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" - done - IFS="$save_ifs" - fi - - if test -n "$old_library"; then - # Do each command in the old_postuninstall commands. - eval cmds=\"$old_postuninstall_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" - done - IFS="$save_ifs" - fi - - # FIXME: should reinstall the best remaining shared library. - fi - ;; - - *.lo) - if test "$build_old_libs" = yes; then - oldobj=`$echo "X$name" | $Xsed -e 's/\.lo$/\.o/'` - rmfiles="$rmfiles $dir/$oldobj" - fi - $show "$rm $rmfiles" - $run $rm $rmfiles - ;; - - *) - $show "$rm $rmfiles" - $run $rm $rmfiles - ;; - esac - done - exit 0 - ;; - - "") - $echo "$modename: you must specify a MODE" 1>&2 - $echo "$generic_help" 1>&2 - exit 1 - ;; - esac - - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$generic_help" 1>&2 - exit 1 -fi # test -z "$show_help" - -# We need to display help for each of the modes. -case "$mode" in -"") $echo \ -"Usage: $modename [OPTION]... [MODE-ARG]... - -Provide generalized library-building support services. - --n, --dry-run display commands without modifying any files - --features display configuration information and exit - --finish same as \`--mode=finish' - --help display this help message and exit - --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] - --quiet same as \`--silent' - --silent don't print informational messages - --version print version information - -MODE must be one of the following: - - compile compile a source file into a libtool object - execute automatically set library path, then run a program - finish complete the installation of libtool libraries - install install libraries or executables - link create a library or an executable - uninstall remove libraries from an installed directory - -MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for -a more detailed description of MODE." - exit 0 - ;; - -compile) - $echo \ -"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE - -Compile a source file into a libtool library object. - -COMPILE-COMMAND is a command to be used in creating a \`standard' object file -from the given SOURCEFILE. - -The output file name is determined by removing the directory component from -SOURCEFILE, then substituting the C source code suffix \`.c' with the -library object suffix, \`.lo'." - ;; - -execute) - $echo \ -"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... - -Automatically set library path, then run a program. - -This mode accepts the following additional options: - - -dlopen FILE add the directory containing FILE to the library path - -This mode sets the library path environment variable according to \`-dlopen' -flags. - -If any of the ARGS are libtool executable wrappers, then they are translated -into their corresponding uninstalled binary, and any of their required library -directories are added to the library path. - -Then, COMMAND is executed, with ARGS as arguments." - ;; - -finish) - $echo \ -"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... - -Complete the installation of libtool libraries. - -Each LIBDIR is a directory that contains libtool libraries. - -The commands that this mode executes may require superuser privileges. Use -the \`--dry-run' option if you just want to see what would be executed." - ;; - -install) - $echo \ -"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... - -Install executables or libraries. - -INSTALL-COMMAND is the installation command. The first component should be -either the \`install' or \`cp' program. - -The rest of the components are interpreted as arguments to that command (only -BSD-compatible install options are recognized)." - ;; - -link) - $echo \ -"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... - -Link object files or libraries together to form another library, or to -create an executable program. - -LINK-COMMAND is a command using the C compiler that you would use to create -a program from several object files. - -The following components of LINK-COMMAND are treated specially: - - -all-static do not do any dynamic linking at all - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime - -dlpreopen FILE link in FILE and add its symbols to dld_preloaded_symbols - -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) - -LLIBDIR search LIBDIR for required installed libraries - -lNAME OUTPUT-FILE requires the installed library libNAME - -no-undefined declare that a library does not refer to external symbols - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects - -release RELEASE specify package release information - -rpath LIBDIR the created library will eventually be installed in LIBDIR - -static do not do any dynamic linking of libtool libraries - -version-info CURRENT[:REVISION[:AGE]] - specify library version info [each variable defaults to 0] - -All other options (arguments beginning with \`-') are ignored. - -Every other argument is treated as a filename. Files ending in \`.la' are -treated as uninstalled libtool libraries, other files are standard or library -object files. - -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only -library objects (\`.lo' files) may be specified, and \`-rpath' is required. - -If OUTPUT-FILE ends in \`.a', then a standard library is created using \`ar' -and \`ranlib'. - -If OUTPUT-FILE ends in \`.lo' or \`.o', then a reloadable object file is -created, otherwise an executable program is created." - ;; - -uninstall) - $echo -"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... - -Remove libraries from an installation directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, all the files associated with it are deleted. -Otherwise, only FILE itself is deleted using RM." - ;; - -*) - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; -esac - -echo -$echo "Try \`$modename --help' for more information about other modes." - -exit 0 - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: +# ltmain.sh - Provide generalized library-building support services. +# NOTE: Changing this file will not affect anything until you rerun ltconfig. +# +# Copyright (C) 1996-1998 Free Software Foundation, Inc. +# Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# The name of this program. +progname=`$echo "$0" | sed 's%^.*/%%'` +modename="$progname" + +# Constants. +PROGRAM=ltmain.sh +PACKAGE=libtool +VERSION=1.2 + +default_mode= +help="Try \`$progname --help' for more information." +magic="%%%MAGIC variable%%%" +mkdir="mkdir" +mv="mv -f" +rm="rm -f" + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' + +# NLS nuisances. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LANG+set}" = set; then LANG=C; export LANG; fi + +if test "$LTCONFIG_VERSION" != "$VERSION"; then + echo "$modename: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 +fi + +if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + echo "$modename: not configured to build any kind of library" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 +fi + +# Global variables. +mode=$default_mode +nonopt= +prev= +prevopt= +run= +show="$echo" +show_help= +execute_dlfiles= + +# Parse our command line options once, thoroughly. +while test $# -gt 0 +do + arg="$1" + shift + + case "$arg" in + -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case "$prev" in + execute_dlfiles) + eval "$prev=\"\$$prev \$arg\"" + ;; + *) + eval "$prev=\$arg" + ;; + esac + + prev= + prevopt= + continue + fi + + # Have we seen a non-optional argument yet? + case "$arg" in + --help) + show_help=yes + ;; + + --version) + echo "$PROGRAM (GNU $PACKAGE) $VERSION" + exit 0 + ;; + + --dry-run | -n) + run=: + ;; + + --features) + echo "host: $host" + if test "$build_libtool_libs" = yes; then + echo "enable shared libraries" + else + echo "disable shared libraries" + fi + if test "$build_old_libs" = yes; then + echo "enable static libraries" + else + echo "disable static libraries" + fi + exit 0 + ;; + + --finish) mode="finish" ;; + + --mode) prevopt="--mode" prev=mode ;; + --mode=*) mode="$optarg" ;; + + --quiet | --silent) + show=: + ;; + + -dlopen) + prevopt="-dlopen" + prev=execute_dlfiles + ;; + + -*) + $echo "$modename: unrecognized option \`$arg'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + + *) + nonopt="$arg" + break + ;; + esac +done + +if test -n "$prevopt"; then + $echo "$modename: option \`$prevopt' requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 +fi + +if test -z "$show_help"; then + + # Infer the operation mode. + if test -z "$mode"; then + case "$nonopt" in + *cc | *++ | gcc* | *-gcc*) + mode=link + for arg + do + case "$arg" in + -c) + mode=compile + break + ;; + esac + done + ;; + *db | *dbx) + mode=execute + ;; + *install*|cp|mv) + mode=install + ;; + *rm) + mode=uninstall + ;; + *) + # If we have no mode, but dlfiles were specified, then do execute mode. + test -n "$execute_dlfiles" && mode=execute + + # Just use the default operation mode. + if test -z "$mode"; then + if test -n "$nonopt"; then + $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 + else + $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 + fi + fi + ;; + esac + fi + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + $echo "$modename: unrecognized option \`-dlopen'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$modename --help --mode=$mode' for more information." + + # These modes are in order of execution frequency so that they run quickly. + case "$mode" in + # libtool compile mode + compile) + modename="$modename: compile" + # Get the compilation command and the source file. + base_compile= + lastarg= + srcfile="$nonopt" + suppress_output= + + for arg + do + # Accept any command-line options. + case "$arg" in + -o) + $echo "$modename: you cannot specify the output filename with \`-o'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + + -static) + build_libtool_libs=no + build_old_libs=yes + continue + ;; + esac + + # Accept the current argument as the source file. + lastarg="$srcfile" + srcfile="$arg" + + # Aesthetically quote the previous argument. + + # Backslashify any backslashes, double quotes, and dollar signs. + # These are the only characters that are still specially + # interpreted inside of double-quoted scrings. + lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` + + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly in scan + # sets, so we specify it separately. + case "$lastarg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + lastarg="\"$lastarg\"" + ;; + esac + + # Add the previous argument to base_compile. + if test -z "$base_compile"; then + base_compile="$lastarg" + else + base_compile="$base_compile $lastarg" + fi + done + + # Get the name of the library object. + libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` + + # Recognize several different file suffixes. + xform='[cCFSfms]' + case "$libobj" in + *.ada) xform=ada ;; + *.adb) xform=adb ;; + *.ads) xform=ads ;; + *.asm) xform=asm ;; + *.c++) xform=c++ ;; + *.cc) xform=cc ;; + *.cpp) xform=cpp ;; + *.cxx) xform=cxx ;; + *.f90) xform=f90 ;; + *.for) xform=for ;; + esac + + libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` + + case "$libobj" in + *.lo) obj=`$echo "X$libobj" | $Xsed -e 's/\.lo$/.o/'` ;; + *) + $echo "$modename: cannot determine name of library object from \`$srcfile'" 1>&2 + exit 1 + ;; + esac + + if test -z "$base_compile"; then + $echo "$modename: you must specify a compilation command" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + $run $rm $obj $libobj + trap "$run $rm $obj $libobj; exit 1" 1 2 15 + else + $run $rm $libobj + trap "$run $rm $libobj; exit 1" 1 2 15 + fi + + # Only build a PIC object if we are building libtool libraries. + if test "$build_libtool_libs" = yes; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + # All platforms use -DPIC, to notify preprocessed assembler code. + $show "$base_compile$pic_flag -DPIC $srcfile" + if $run eval "$base_compile\$pic_flag -DPIC \$srcfile"; then : + else + test -n "$obj" && $run $rm $obj + exit 1 + fi + + # If we have no pic_flag, then copy the object into place and finish. + if test -z "$pic_flag"; then + $show "$LN_S $obj $libobj" + $run $LN_S $obj $libobj + exit $? + fi + + # Just move the object, then go on to compile the next one + $show "$mv $obj $libobj" + $run $mv $obj $libobj || exit 1 + + # Allow error messages only from the first compilation. + suppress_output=' >/dev/null 2>&1' + fi + + # Only build a position-dependent object if we build old libraries. + if test "$build_old_libs" = yes; then + # Suppress compiler output if we already did a PIC compilation. + $show "$base_compile $srcfile$suppress_output" + if $run eval "$base_compile \$srcfile$suppress_output"; then : + else + $run $rm $obj $libobj + exit 1 + fi + fi + + # Create an invalid libtool object if no PIC, so that we do not + # accidentally link it into a program. + if test "$build_libtool_libs" != yes; then + $show "echo timestamp > $libobj" + $run eval "echo timestamp > \$libobj" || exit $? + fi + + exit 0 + ;; + + # libtool link mode + link) + modename="$modename: link" + CC="$nonopt" + allow_undefined=yes + compile_command="$CC" + finalize_command="$CC" + + compile_shlibpath= + finalize_shlibpath= + deplibs= + dlfiles= + dlprefiles= + export_dynamic=no + hardcode_libdirs= + libobjs= + link_against_libtool_libs= + ltlibs= + objs= + prev= + prevarg= + release= + rpath= + perm_rpath= + temp_rpath= + vinfo= + + # We need to know -static, to get the right output filenames. + for arg + do + case "$arg" in + -all-static | -static) + if test "X$arg" = "X-all-static" && test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then + $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 + fi + build_libtool_libs=no + build_old_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + for arg + do + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case "$prev" in + output) + compile_command="$compile_command @OUTPUT@" + finalize_command="$finalize_command @OUTPUT@" + ;; + esac + + case "$prev" in + dlfiles|dlprefiles) + case "$arg" in + *.la | *.lo) ;; # We handle these cases below. + *) + dlprefiles="$dlprefiles $arg" + test "$prev" = dlfiles && dlfiles="$dlfiles $arg" + prev= + ;; + esac + ;; + release) + release="-$arg" + prev= + continue + ;; + rpath) + rpath="$rpath $arg" + prev= + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi + + prevarg="$arg" + + case "$arg" in + -all-static) + if test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + if test "$export_dynamic" != yes; then + export_dynamic=yes + if test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + else + arg= + fi + + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$finalize_command @SYMFILE@" + fi + ;; + + -L*) + dir=`$echo "X$arg" | $Xsed -e 's%^-L\(.*\)$%\1%'` + case "$dir" in + /* | [A-Za-z]:\\*) + # Add the corresponding hardcode_libdir_flag, if it is not identical. + ;; + *) + $echo "$modename: \`-L$dir' cannot specify a relative directory" 1>&2 + exit 1 + ;; + esac + deplibs="$deplibs $arg" + ;; + + -l*) deplibs="$deplibs $arg" ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -o) prev=output ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -static) + # If we have no pic_flag, then this is the same as -all-static. + if test -z "$pic_flag" && test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + + # Some other compiler flag. + -* | +*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + ;; + + *.o | *.a) + # A standard object. + objs="$objs $arg" + ;; + + *.lo) + # A library object. + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + if test "$build_libtool_libs" = yes; then + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e 's/\.lo$/\.o/'` + prev= + fi + libobjs="$libobjs $arg" + ;; + + *.la) + # A libtool-controlled library. + + dlname= + libdir= + library_names= + old_library= + + # Check to see that this really is a libtool archive. + if (sed -e '2q' $arg | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then : + else + $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2 + exit 1 + fi + + # If there is no directory component, then add one. + case "$arg" in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$libdir"; then + $echo "$modename: \`$arg' contains no -rpath information" 1>&2 + exit 1 + fi + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + + if test -z "$linklib"; then + $echo "$modename: cannot find name of link library for \`$arg'" 1>&2 + exit 1 + fi + + # Find the relevant object directory and library name. + name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'` + dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$arg"; then + dir="$objdir" + else + dir="$dir/$objdir" + fi + + # This library was specified with -dlopen. + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + if test -z "$dlname"; then + # If there is no dlname, we need to preload. + prev=dlprefiles + else + # We should not create a dependency on this library, but we + # may need any libraries it requires. + compile_command="$compile_command$dependency_libs" + finalize_command="$finalize_command$dependency_libs" + prev= + continue + fi + fi + + # The library was specified with -dlpreopen. + if test "$prev" = dlprefiles; then + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + dlprefiles="$dlprefiles $dir/$old_library" + else + dlprefiles="$dlprefiles $dir/$linklib" + fi + prev= + fi + + if test "$build_libtool_libs" = yes && test -n "$library_names"; then + link_against_libtool_libs="$link_against_libtool_libs $arg" + if test -n "$shlibpath_var"; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + *" $dir "*) ;; + *) temp_rpath="$temp_rpath $dir" ;; + esac + fi + + # This is the magic to use -rpath. + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + # Put the magic libdir with the hardcode flag. + hardcode_libdirs="$libdir" + libdir="@HARDCODE_LIBDIRS@" + else + # Just accumulate the unique libdirs. + case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + libdir= + fi + fi + + if test -n "$libdir"; then + eval flag=\"$hardcode_libdir_flag_spec\" + + compile_command="$compile_command $flag" + finalize_command="$finalize_command $flag" + fi + elif test -n "$runpath_var"; then + # Do the same for the permanent run path. + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + + + case "$hardcode_action" in + immediate) + if test "$hardcode_direct" = no; then + compile_command="$compile_command $dir/$linklib" + elif test "$hardcode_minus_L" = no; then + compile_command="$compile_command -L$dir -l$name" + elif test "$hardcode_shlibpath_var" = no; then + compile_shlibpath="$compile_shlibpath$dir:" + compile_command="$compile_command -l$name" + fi + ;; + + relink) + # We need an absolute path. + case "$dir" in + /* | [A-Za-z]:\\*) ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 + exit 1 + fi + dir="$absdir" + ;; + esac + + if test "$hardcode_direct" = yes; then + compile_command="$compile_command $dir/$linklib" + elif test "$hardcode_minus_L" = yes; then + compile_command="$compile_command -L$dir -l$name" + elif test "$hardcode_shlibpath_var" = yes; then + compile_shlibpath="$compile_shlibpath$dir:" + compile_command="$compile_command -l$name" + fi + ;; + + *) + $echo "$modename: \`$hardcode_action' is an unknown hardcode action" 1>&2 + exit 1 + ;; + esac + + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes; then + finalize_command="$finalize_command $libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + finalize_command="$finalize_command -L$libdir -l$name" + elif test "$hardcode_shlibpath_var" = yes; then + finalize_shlibpath="$finalize_shlibpath$libdir:" + finalize_command="$finalize_command -l$name" + else + # We cannot seem to hardcode it, guess we'll fake it. + finalize_command="$finalize_command -L$libdir -l$name" + fi + else + # Transform directly to old archives if we don't build new libraries. + if test -n "$pic_flag" && test -z "$old_library"; then + $echo "$modename: cannot find static library for \`$arg'" 1>&2 + exit 1 + fi + + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_command="$compile_command $dir/$linklib" + finalize_command="$finalize_command $dir/$linklib" + else + compile_command="$compile_command -L$dir -l$name" + finalize_command="$finalize_command -L$dir -l$name" + fi + fi + + # Add in any libraries that this one depends upon. + compile_command="$compile_command$dependency_libs" + finalize_command="$finalize_command$dependency_libs" + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + ;; + esac + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + done + + if test -n "$prev"; then + $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -n "$vinfo" && test -n "$release"; then + $echo "$modename: you cannot specify both \`-version-info' and \`-release'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + oldlib= + oldobjs= + case "$output" in + "") + $echo "$modename: you must specify an output file" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + + */* | *\\*) + $echo "$modename: output file \`$output' must have no directory components" 1>&2 + exit 1 + ;; + + *.a) + # Now set the variables for building old libraries. + build_libtool_libs=no + build_old_libs=yes + oldlib="$output" + $show "$rm $oldlib" + $run $rm $oldlib + ;; + + *.la) + # Make sure we only generate libraries of the form `libNAME.la'. + case "$output" in + lib*) ;; + *) + $echo "$modename: libtool library \`$arg' must begin with \`lib'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + + name=`$echo "X$output" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + eval libname=\"$libname_spec\" + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + current=0 + revision=0 + age=0 + + if test -n "$objs"; then + $echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1 + exit 1 + fi + + # How the heck are we supposed to write a wrapper for a shared library? + if test -n "$link_against_libtool_libs"; then + $echo "$modename: libtool library \`$output' may not depend on uninstalled libraries:$link_against_libtool_libs" 1>&2 + exit 1 + fi + + if test -n "$dlfiles$dlprefiles"; then + $echo "$modename: warning: \`-dlopen' is ignored while creating libtool libraries" 1>&2 + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi + + if test -z "$rpath"; then + $echo "$modename: you must specify an installation directory with \`-rpath'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + set dummy $rpath + if test $# -gt 2; then + $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 + fi + install_libdir="$2" + + # Parse the version information argument. + IFS="${IFS= }"; save_ifs="$IFS"; IFS=':' + set dummy $vinfo + IFS="$save_ifs" + + if test -n "$5"; then + $echo "$modename: too many parameters to \`-version-info'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + test -n "$2" && current="$2" + test -n "$3" && revision="$3" + test -n "$4" && age="$4" + + # Check that each of the things are valid numbers. + case "$current" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case "$revision" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case "$age" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + if test $age -gt $current; then + $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + fi + + # Calculate the version variables. + version_vars="version_type current age revision" + case "$version_type" in + none) ;; + + linux) + version_vars="$version_vars major versuffix" + major=`expr $current - $age` + versuffix="$major.$age.$revision" + ;; + + osf) + version_vars="$version_vars versuffix verstring" + major=`expr $current - $age` + versuffix="$current.$age.$revision" + verstring="$versuffix" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test $loop != 0; do + iface=`expr $current - $loop` + loop=`expr $loop - 1` + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + sunos) + version_vars="$version_vars major versuffix" + major="$current" + versuffix="$current.$revision" + ;; + + *) + $echo "$modename: unknown library version type \`$version_type'" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 + ;; + esac + + # Create the output directory, or remove our outputs if we need to. + if test -d $objdir; then + $show "$rm $objdir/$output $objdir/$libname.* $objdir/${libname}${release}.*" + $run $rm $objdir/$output $objdir/$libname.* $objdir/${libname}${release}.* + else + $show "$mkdir $objdir" + $run $mkdir $objdir + status=$? + if test $status -eq 0 || test -d $objdir; then : + else + exit $status + fi + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + + # Add libc to deplibs on all systems. + dependency_libs="$deplibs" + deplibs="$deplibs -lc" + + if test "$build_libtool_libs" = yes; then + # Get the real and link names of the library. + eval library_names=\"$library_names_spec\" + set dummy $library_names + realname="$2" + shift; shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + lib="$objdir/$realname" + for link + do + linknames="$linknames $link" + done + + # Use standard objects if they are PIC. + test -z "$pic_flag" && libobjs=`$echo "X$libobjs " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//g'` + + # Do each of the archive commands. + eval cmds=\"$archive_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Create links to the real library. + for linkname in $linknames; do + $show "(cd $objdir && $LN_S $realname $linkname)" + $run eval '(cd $objdir && $LN_S $realname $linkname)' || exit $? + done + + # If -export-dynamic was specified, set the dlname. + if test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + + # Now set the variables for building old libraries. + oldlib="$objdir/$libname.a" + ;; + + *.lo | *.o) + if test -n "$link_against_libtool_libs"; then + $echo "$modename: error: cannot link libtool libraries into reloadable objects" 1>&2 + exit 1 + fi + + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored while creating objects" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles"; then + $echo "$modename: warning: \`-dlopen' is ignored while creating objects" 1>&2 + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored while creating objects" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored while creating objects" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored while creating objects" 1>&2 + fi + + case "$output" in + *.lo) + if test -n "$objs"; then + $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 + exit 1 + fi + libobj="$output" + obj=`$echo "X$output" | $Xsed -e 's/\.lo$/.o/'` + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $run $rm $obj $libobj + + # Create the old-style object. + reload_objs="$objs"`$echo "X$libobjs " | $Xsed -e 's/[^ ]*\.a //g' -e 's/\.lo /.o /g' -e 's/ $//g'` + + output="$obj" + eval cmds=\"$reload_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Exit if we aren't doing a library object file. + test -z "$libobj" && exit 0 + + if test "$build_libtool_libs" != yes; then + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + $show "echo timestamp > $libobj" + $run eval "echo timestamp > $libobj" || exit $? + exit 0 + fi + + if test -n "$pic_flag"; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs" + output="$libobj" + eval cmds=\"$reload_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + else + # Just create a symlink. + $show "$LN_S $obj $libobj" + $run $LN_S $obj $libobj || exit 1 + fi + + exit 0 + ;; + + *) + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored while linking programs" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored while creating objects" 1>&2 + fi + + if test -n "$rpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + # Put the magic libdir with the hardcode flag. + hardcode_libdirs="$libdir" + libdir="@HARDCODE_LIBDIRS@" + else + # Just accumulate the unique libdirs. + case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + libdir= + fi + fi + + if test -n "$libdir"; then + eval flag=\"$hardcode_libdir_flag_spec\" + + compile_command="$compile_command $flag" + finalize_command="$finalize_command $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + fi + + # Substitute the hardcoded libdirs into the compile commands. + if test -n "$hardcode_libdir_separator"; then + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"` + fi + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$echo "X$compile_command " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//'` + finalize_command=`$echo "X$finalize_command " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//'` + fi + + if test "$export_dynamic" = yes && test -n "$NM" && test -n "$global_symbol_pipe"; then + dlsyms="${output}S.c" + else + dlsyms= + fi + + if test -n "$dlsyms"; then + # Add our own program objects to the preloaded list. + dlprefiles=`$echo "X$objs$dlprefiles " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//'` + + # Discover the nlist of each of the dlfiles. + nlist="$objdir/${output}.nm" + + if test -d $objdir; then + $show "$rm $nlist ${nlist}T" + $run $rm "$nlist" "${nlist}T" + else + $show "$mkdir $objdir" + $run $mkdir $objdir + status=$? + if test $status -eq 0 || test -d $objdir; then : + else + exit $status + fi + fi + + for arg in $dlprefiles; do + $show "extracting global C symbols from \`$arg'" + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + # Parse the name list into a source file. + $show "creating $objdir/$dlsyms" + if test -z "$run"; then + # Make sure we at least have an empty file. + test -f "$nlist" || : > "$nlist" + + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + wcout=`wc "$nlist" 2>/dev/null` + count=`echo "X$wcout" | $Xsed -e 's/^[ ]*\([0-9][0-9]*\).*$/\1/'` + (test "$count" -ge 0) 2>/dev/null || count=-1 + else + $rm "$nlist"T + count=-1 + fi + + case "$dlsyms" in + "") ;; + *.c) + $echo > "$objdir/$dlsyms" "\ +/* $dlsyms - symbol resolution table for \`$output' dlsym emulation. */ +/* Generated by $PROGRAM - GNU $PACKAGE $VERSION */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* Prevent the only kind of declaration conflicts we can make. */ +#define dld_preloaded_symbol_count some_other_symbol +#define dld_preloaded_symbols some_other_symbol + +/* External symbol declarations for the compiler. */\ +" + + if test -f "$nlist"; then + sed -e 's/^.* \(.*\)$/extern char \1;/' < "$nlist" >> "$objdir/$dlsyms" + else + echo '/* NONE */' >> "$objdir/$dlsyms" + fi + + $echo >> "$objdir/$dlsyms" "\ + +#undef dld_preloaded_symbol_count +#undef dld_preloaded_symbols + +#if defined (__STDC__) && __STDC__ +# define __ptr_t void * +#else +# define __ptr_t char * +#endif + +/* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */ +int dld_preloaded_symbol_count = $count; + +/* The mapping between symbol names and symbols. */ +struct { + char *name; + __ptr_t address; +} +dld_preloaded_symbols[] = +{\ +" + + if test -f "$nlist"; then + sed 's/^\(.*\) \(.*\)$/ {"\1", (__ptr_t) \&\2},/' < "$nlist" >> "$objdir/$dlsyms" + fi + + $echo >> "$objdir/$dlsyms" "\ + {0, (__ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif\ +" + ;; + + *) + $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 + exit 1 + ;; + esac + fi + + # Now compile the dynamic symbol file. + $show "(cd $objdir && $CC -c$no_builtin_flag \"$dlsyms\")" + $run eval '(cd $objdir && $CC -c$no_builtin_flag "$dlsyms")' || exit $? + + # Transform the symbol file into the correct name. + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$objdir/${output}S.o%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$objdir/${output}S.o%"` + elif test "$export_dynamic" != yes; then + test -n "$dlfiles$dlprefiles" && $echo "$modename: warning: \`-dlopen' and \`-dlpreopen' are ignored without \`-export-dynamic'" 1>&2 + else + # We keep going just in case the user didn't refer to + # dld_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 + + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi + + if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + finalize_command=`$echo "X$finalize_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + + # We have no uninstalled library dependencies, so finalize right now. + $show "$compile_command" + $run eval "$compile_command" + exit $? + fi + + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$objdir/$output"'%g'` + finalize_command=`$echo "X$finalize_command" | $Xsed -e 's%@OUTPUT@%'"$objdir/$output"'T%g'` + + # Create the binary in the object directory, then wrap it. + if test -d $objdir; then : + else + $show "$mkdir $objdir" + $run $mkdir $objdir + status=$? + if test $status -eq 0 || test -d $objdir; then : + else + exit $status + fi + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case "$dir" in + /* | [A-Za-z]:\\*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + fi + + # Delete the old output file. + $run $rm $output + + if test -n "$compile_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_command="$runpath_var=\"$rpath\$$runpath_var\" $compile_command" + finalize_command="$runpath_var=\"$rpath\$$runpath_var\" $finalize_command" + fi + + case "$hardcode_action" in + relink) + # AGH! Flame the AIX and HP-UX people for me, will ya? + $echo "$modename: warning: using a buggy system linker" 1>&2 + $echo "$modename: relinking will be required before \`$output' can be installed" 1>&2 + ;; + esac + + $show "$compile_command" + $run eval "$compile_command" || exit $? + + # Now create the wrapper script. + $show "creating $output" + + # Quote the finalize command for shipping. + finalize_command=`$echo "X$finalize_command" | $Xsed -e "$sed_quote_subst"` + + # Quote $echo for shipping. + qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + $rm $output + trap "$rm $output; exit 1" 1 2 15 + + $echo > $output "\ +#! /bin/sh + +# $output - temporary wrapper script for $objdir/$output +# Generated by ltmain.sh - GNU $PACKAGE $VERSION +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of \``pwd`'. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +sed_quote_subst='$sed_quote_subst' + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test \"\${CDPATH+set}\" = set; then CDPATH=; export CDPATH; fi + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variables: + link_against_libtool_libs='$link_against_libtool_libs' + finalize_command=\"$finalize_command\" +else + # When we are sourced in execute mode, \$file and \$echo are already set. + if test \"\$libtool_execute_magic\" = \"$magic\"; then : + else + echo=\"$qecho\" + file=\"\$0\" + fi\ +" + $echo >> $output "\ + + # Find the directory that this script lives in. + thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + /* | [A-Za-z]:\\*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` + done + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" + + progdir=\"\$thisdir/$objdir\" + program='$output' + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $echo >> $output "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/:*\$//'\` + + export $shlibpath_var +" + fi + + $echo >> $output "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. + + # Export the path to the program. + PATH=\"\$progdir:\$PATH\" + export PATH + + exec \$program \${1+\"\$@\"} + + \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" + exit 1 + fi + else + # The program doesn't exist. + \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 + \$echo \"This script is just a wrapper for \$program.\" 1>&2 + echo \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" + chmod +x $output + fi + exit 0 + ;; + esac + + # See if we need to build an old-fashioned archive. + if test "$build_old_libs" = "yes"; then + # Transform .lo files to .o files. + oldobjs="$objs"`$echo "X$libobjs " | $Xsed -e 's/[^ ]*\.a //g' -e 's/\.lo /.o /g' -e 's/ $//g'` + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + eval cmds=\"$old_archive_from_new_cmds\" + else + eval cmds=\"$old_archive_cmds\" + fi + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Now create the libtool archive. + case "$output" in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.a" + + $show "creating $output" + + # Only create the output if not a dry run. + if test -z "$run"; then + $echo > $output "\ +# $output - a libtool library file +# Generated by ltmain.sh - GNU $PACKAGE $VERSION + +# The name that we can dlopen(3). +dlname='$dlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Directory that this library needs to be installed in: +libdir='$install_libdir'\ +" + fi + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + $show "(cd $objdir && $LN_S ../$output $output)" + $run eval "(cd $objdir && $LN_S ../$output $output)" || exit 1 + ;; + esac + exit 0 + ;; + + # libtool install mode + install) + modename="$modename: install" + + # There may be an optional /bin/sh argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL"; then + # Aesthetically quote it. + arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$arg " + arg="$1" + shift + else + install_prog= + arg="$nonopt" + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog$arg" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir= + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest="$arg" + continue + fi + + case "$arg" in + -d) isdir=yes ;; + -f) prev="-f" ;; + -g) prev="-g" ;; + -m) prev="-m" ;; + -o) prev="-o" ;; + -s) + stripme=" -s" + continue + ;; + -*) ;; + + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest="$arg" + continue + fi + ;; + esac + + # Aesthetically quote the argument. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog $arg" + done + + if test -z "$install_prog"; then + $echo "$modename: you must specify an install program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -n "$prev"; then + $echo "$modename: the \`$prev' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -z "$files"; then + if test -z "$dest"; then + $echo "$modename: no file or destination specified" 1>&2 + else + $echo "$modename: you must specify a destination" 1>&2 + fi + $echo "$help" 1>&2 + exit 1 + fi + + # Strip any trailing slash from the destination. + dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test -n "$isdir"; then + destdir="$dest" + destname= + else + destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` + test "X$destdir" = "X$dest" && destdir=. + destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test $# -gt 2; then + $echo "$modename: \`$dest' is not a directory" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + fi + case "$destdir" in + /* | [A-Za-z]:\\*) ;; + *) + for file in $files; do + case "$file" in + *.lo) ;; + *) + $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case "$file" in + *.a) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then : + else + $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + library_names= + old_library= + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/" + test "X$dir" = "X$file/" && dir= + dir="$dir$objdir" + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$realname $destdir/$realname" + $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $? + test "X$dlname" = "X$realname" && dlname= + + if test $# -gt 0; then + # Delete the old symlinks. + rmcmd="$rm" + for linkname + do + rmcmd="$rmcmd $destdir/$linkname" + done + $show "$rmcmd" + $run $rmcmd + + # ... and create new ones. + for linkname + do + test "X$dlname" = "X$linkname" && dlname= + $show "(cd $destdir && $LN_S $realname $linkname)" + $run eval "(cd $destdir && $LN_S $realname $linkname)" + done + fi + + if test -n "$dlname"; then + # Install the dynamically-loadable library. + $show "$install_prog $dir/$dlname $destdir/$dlname" + $run eval "$install_prog $dir/$dlname $destdir/$dlname" || exit $? + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + eval cmds=\"$postinstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + $show "$install_prog $file $destdir/$name" + $run eval "$install_prog $file $destdir/$name" || exit $? + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case "$destfile" in + *.lo) + staticdest=`$echo "X$destfile" | $Xsed -e 's/\.lo$/\.o/'` + ;; + *.o) + staticdest="$destfile" + destfile= + ;; + *) + $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run eval "$install_prog $file $destfile" || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`$echo "X$file" | $Xsed -e 's/\.lo$/\.o/'` + + $show "$install_prog $staticobj $staticdest" + $run eval "$install_prog \$staticobj \$staticdest" || exit $? + fi + exit 0 + ;; + + *) + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then + link_against_libtool_libs= + finalize_command= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Check the variables that should have been set. + if test -z "$link_against_libtool_libs" || test -z "$finalize_command"; then + $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 + exit 1 + fi + + finalize=yes + for lib in $link_against_libtool_libs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case "$lib" in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`" + if test -z "$libdir"; then + $echo "$modename: warning: \`$lib' contains no -rpath information" 1>&2 + elif test -f "$libfile"; then : + else + $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + done + + if test "$hardcode_action" = relink; then + if test "$finalize" = yes; then + $echo "$modename: warning: relinking \`$file' on behalf of your buggy system linker" 1>&2 + $show "$finalize_command" + if $run eval "$finalize_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + continue + fi + file="$objdir/$file"T + else + $echo "$modename: warning: cannot relink \`$file' on behalf of your buggy system linker" 1>&2 + fi + else + # Install the binary that we compiled earlier. + file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + $show "$install_prog$stripme $file $dest" + $run eval "$install_prog\$stripme \$file \$dest" || exit $? + ;; + esac + done + + for file in $staticlibs; do + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run eval "$install_prog \$file \$oldlib" || exit $? + + # Do each command in the postinstall commands. + eval cmds=\"$old_postinstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec $SHELL $0 --finish$current_libdirs + exit 1 + fi + + exit 0 + ;; + + # libtool finish mode + finish) + modename="$modename: finish" + libdirs="$nonopt" + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + eval cmds=\"$finish_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $run eval "$cmds" + fi + done + fi + + echo "------------------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + echo " $libdir" + done + echo + echo "To link against installed libraries in a given directory, LIBDIR," + echo "you must use the \`-LLIBDIR' flag during linking." + echo + echo " You will also need to do one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the \`$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + echo " - use the \`$flag' linker flag" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + echo + echo "See any operating system documentation about shared libraries for" + echo "more information, such as the ld(1) and ld.so(8) manual pages." + echo "------------------------------------------------------------------------------" + exit 0 + ;; + + # libtool execute mode + execute) + modename="$modename: execute" + + # The first argument is the command name. + cmd="$nonopt" + if test -z "$cmd"; then + $echo "$modename: you must specify a COMMAND" 1>&2 + $echo "$help" + exit 1 + fi + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test -f "$file"; then : + else + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + dir= + case "$file" in + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 + exit 1 + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case "$file" in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + + # Now actually exec the command. + eval "exec \$cmd$args" + + $echo "$modename: cannot exec \$cmd$args" + exit 1 + else + # Display what would be done. + eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" + $echo "export $shlibpath_var" + $echo "$cmd$args" + exit 0 + fi + ;; + + # libtool uninstall mode + uninstall) + modename="$modename: uninstall" + rm="$nonopt" + files= + + for arg + do + case "$arg" in + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + rmfiles="$file" + + case "$name" in + *.la) + # Possibly a libtool archive, so verify it. + if (sed -e '2q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then + . $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $dir/$n" + test "X$n" = "X$dlname" && dlname= + done + test -n "$dlname" && rmfiles="$rmfiles $dir/$dlname" + test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library" + + $show "$rm $rmfiles" + $run $rm $rmfiles + + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + eval cmds=\"$postuninstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + eval cmds=\"$old_postuninstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + + # FIXME: should reinstall the best remaining shared library. + fi + ;; + + *.lo) + if test "$build_old_libs" = yes; then + oldobj=`$echo "X$name" | $Xsed -e 's/\.lo$/\.o/'` + rmfiles="$rmfiles $dir/$oldobj" + fi + $show "$rm $rmfiles" + $run $rm $rmfiles + ;; + + *) + $show "$rm $rmfiles" + $run $rm $rmfiles + ;; + esac + done + exit 0 + ;; + + "") + $echo "$modename: you must specify a MODE" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 + ;; + esac + + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 +fi # test -z "$show_help" + +# We need to display help for each of the modes. +case "$mode" in +"") $echo \ +"Usage: $modename [OPTION]... [MODE-ARG]... + +Provide generalized library-building support services. + +-n, --dry-run display commands without modifying any files + --features display configuration information and exit + --finish same as \`--mode=finish' + --help display this help message and exit + --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] + --quiet same as \`--silent' + --silent don't print informational messages + --version print version information + +MODE must be one of the following: + + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for +a more detailed description of MODE." + exit 0 + ;; + +compile) + $echo \ +"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + +execute) + $echo \ +"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + +finish) + $echo \ +"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + +install) + $echo \ +"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + +link) + $echo \ +"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to dld_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -static do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only +library objects (\`.lo' files) may be specified, and \`-rpath' is required. + +If OUTPUT-FILE ends in \`.a', then a standard library is created using \`ar' +and \`ranlib'. + +If OUTPUT-FILE ends in \`.lo' or \`.o', then a reloadable object file is +created, otherwise an executable program is created." + ;; + +uninstall) + $echo +"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + +*) + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; +esac + +echo +$echo "Try \`$modename --help' for more information about other modes." + +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/src/dep/src/irrlicht/jpeglib/makcjpeg.st b/src/dep/src/irrlicht/jpeglib/makcjpeg.st index 06bdf56..fc72c89 100644 --- a/src/dep/src/irrlicht/jpeglib/makcjpeg.st +++ b/src/dep/src/irrlicht/jpeglib/makcjpeg.st @@ -1,38 +1,38 @@ -; Project file for Independent JPEG Group's software -; -; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. -; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de), -; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de), -; and Guido Vollbeding (guivol@esc.de). -; -; To use this file, rename it to cjpeg.prj. -; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." -; Read installation instructions before trying to make the program! -; -; -; * * * Output file * * * -cjpeg.ttp -; -; * * * COMPILER OPTIONS * * * -.C[-P] ; absolute calls -.C[-M] ; and no string merging, folks -.C[-w-cln] ; no "constant is long" warnings -.C[-w-par] ; no "parameter xxxx unused" -.C[-w-rch] ; no "unreachable code" -.C[-wsig] ; warn if significant digits may be lost -= -; * * * * List of modules * * * * -pcstart.o -cjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h) -cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdswitch.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdppm.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdgif.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdtarga.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdbmp.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdrle.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -libjpeg.lib ; built by libjpeg.prj -pcfltlib.lib ; floating point library -; the float library can be omitted if you've turned off DCT_FLOAT_SUPPORTED -pcstdlib.lib ; standard library -pcextlib.lib ; extended library +; Project file for Independent JPEG Group's software +; +; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. +; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de), +; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de), +; and Guido Vollbeding (guivol@esc.de). +; +; To use this file, rename it to cjpeg.prj. +; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." +; Read installation instructions before trying to make the program! +; +; +; * * * Output file * * * +cjpeg.ttp +; +; * * * COMPILER OPTIONS * * * +.C[-P] ; absolute calls +.C[-M] ; and no string merging, folks +.C[-w-cln] ; no "constant is long" warnings +.C[-w-par] ; no "parameter xxxx unused" +.C[-w-rch] ; no "unreachable code" +.C[-wsig] ; warn if significant digits may be lost += +; * * * * List of modules * * * * +pcstart.o +cjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h) +cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdswitch.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdppm.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdgif.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdtarga.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdbmp.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdrle.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +libjpeg.lib ; built by libjpeg.prj +pcfltlib.lib ; floating point library +; the float library can be omitted if you've turned off DCT_FLOAT_SUPPORTED +pcstdlib.lib ; standard library +pcextlib.lib ; extended library diff --git a/src/dep/src/irrlicht/jpeglib/makdjpeg.st b/src/dep/src/irrlicht/jpeglib/makdjpeg.st index 873fd0f..3226726 100644 --- a/src/dep/src/irrlicht/jpeglib/makdjpeg.st +++ b/src/dep/src/irrlicht/jpeglib/makdjpeg.st @@ -1,38 +1,38 @@ -; Project file for Independent JPEG Group's software -; -; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. -; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de), -; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de), -; and Guido Vollbeding (guivol@esc.de). -; -; To use this file, rename it to djpeg.prj. -; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." -; Read installation instructions before trying to make the program! -; -; -; * * * Output file * * * -djpeg.ttp -; -; * * * COMPILER OPTIONS * * * -.C[-P] ; absolute calls -.C[-M] ; and no string merging, folks -.C[-w-cln] ; no "constant is long" warnings -.C[-w-par] ; no "parameter xxxx unused" -.C[-w-rch] ; no "unreachable code" -.C[-wsig] ; warn if significant digits may be lost -= -; * * * * List of modules * * * * -pcstart.o -djpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h) -cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdcolmap.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -wrppm.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -wrgif.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -wrtarga.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -wrbmp.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -wrrle.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -libjpeg.lib ; built by libjpeg.prj -pcfltlib.lib ; floating point library -; the float library can be omitted if you've turned off DCT_FLOAT_SUPPORTED -pcstdlib.lib ; standard library -pcextlib.lib ; extended library +; Project file for Independent JPEG Group's software +; +; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. +; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de), +; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de), +; and Guido Vollbeding (guivol@esc.de). +; +; To use this file, rename it to djpeg.prj. +; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." +; Read installation instructions before trying to make the program! +; +; +; * * * Output file * * * +djpeg.ttp +; +; * * * COMPILER OPTIONS * * * +.C[-P] ; absolute calls +.C[-M] ; and no string merging, folks +.C[-w-cln] ; no "constant is long" warnings +.C[-w-par] ; no "parameter xxxx unused" +.C[-w-rch] ; no "unreachable code" +.C[-wsig] ; warn if significant digits may be lost += +; * * * * List of modules * * * * +pcstart.o +djpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h) +cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdcolmap.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrppm.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrgif.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrtarga.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrbmp.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrrle.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +libjpeg.lib ; built by libjpeg.prj +pcfltlib.lib ; floating point library +; the float library can be omitted if you've turned off DCT_FLOAT_SUPPORTED +pcstdlib.lib ; standard library +pcextlib.lib ; extended library diff --git a/src/dep/src/irrlicht/jpeglib/makeapps.ds b/src/dep/src/irrlicht/jpeglib/makeapps.ds index 8535d4d..bedd038 100644 --- a/src/dep/src/irrlicht/jpeglib/makeapps.ds +++ b/src/dep/src/irrlicht/jpeglib/makeapps.ds @@ -1,828 +1,828 @@ -# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -!IF "$(CFG)" == "" -CFG=cjpeg - Win32 -!MESSAGE No configuration specified. Defaulting to cjpeg - Win32. -!ENDIF - -!IF "$(CFG)" != "cjpeg - Win32" && "$(CFG)" != "djpeg - Win32" &&\ - "$(CFG)" != "jpegtran - Win32" && "$(CFG)" != "rdjpgcom - Win32" &&\ - "$(CFG)" != "wrjpgcom - Win32" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE on this makefile -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "apps.mak" CFG="cjpeg - Win32" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "cjpeg - Win32" (based on "Win32 (x86) Console Application") -!MESSAGE "djpeg - Win32" (based on "Win32 (x86) Console Application") -!MESSAGE "jpegtran - Win32" (based on "Win32 (x86) Console Application") -!MESSAGE "rdjpgcom - Win32" (based on "Win32 (x86) Console Application") -!MESSAGE "wrjpgcom - Win32" (based on "Win32 (x86) Console Application") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF -################################################################################ -# Begin Project -# PROP Target_Last_Scanned "cjpeg - Win32" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "cjpeg - Win32" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "cjpeg\Release" -# PROP BASE Intermediate_Dir "cjpeg\Release" -# PROP BASE Target_Dir "cjpeg" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "cjpeg\Release" -# PROP Intermediate_Dir "cjpeg\Release" -# PROP Target_Dir "cjpeg" -OUTDIR=.\cjpeg\Release -INTDIR=.\cjpeg\Release - -ALL : "$(OUTDIR)\cjpeg.exe" - -CLEAN : - -@erase "$(INTDIR)\cjpeg.obj" - -@erase "$(INTDIR)\rdppm.obj" - -@erase "$(INTDIR)\rdgif.obj" - -@erase "$(INTDIR)\rdtarga.obj" - -@erase "$(INTDIR)\rdrle.obj" - -@erase "$(INTDIR)\rdbmp.obj" - -@erase "$(INTDIR)\rdswitch.obj" - -@erase "$(INTDIR)\cdjpeg.obj" - -@erase "$(OUTDIR)\cjpeg.exe" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ - /Fp"$(INTDIR)/cjpeg.pch" /YX /Fo"$(INTDIR)/" /c -CPP_OBJS=.\cjpeg\Release/ -CPP_SBRS=.\. -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -BSC32_FLAGS=/nologo /o"$(OUTDIR)/cjpeg.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ - odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ - /pdb:"$(OUTDIR)/cjpeg.pdb" /machine:I386 /out:"$(OUTDIR)/cjpeg.exe" -LINK32_OBJS= \ - "$(INTDIR)\cjpeg.obj" \ - "$(INTDIR)\rdppm.obj" \ - "$(INTDIR)\rdgif.obj" \ - "$(INTDIR)\rdtarga.obj" \ - "$(INTDIR)\rdrle.obj" \ - "$(INTDIR)\rdbmp.obj" \ - "$(INTDIR)\rdswitch.obj" \ - "$(INTDIR)\cdjpeg.obj" \ - - -"$(OUTDIR)\cjpeg.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -!ELSEIF "$(CFG)" == "djpeg - Win32" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "djpeg\Release" -# PROP BASE Intermediate_Dir "djpeg\Release" -# PROP BASE Target_Dir "djpeg" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "djpeg\Release" -# PROP Intermediate_Dir "djpeg\Release" -# PROP Target_Dir "djpeg" -OUTDIR=.\djpeg\Release -INTDIR=.\djpeg\Release - -ALL : "$(OUTDIR)\djpeg.exe" - -CLEAN : - -@erase "$(INTDIR)\djpeg.obj" - -@erase "$(INTDIR)\wrppm.obj" - -@erase "$(INTDIR)\wrgif.obj" - -@erase "$(INTDIR)\wrtarga.obj" - -@erase "$(INTDIR)\wrrle.obj" - -@erase "$(INTDIR)\wrbmp.obj" - -@erase "$(INTDIR)\rdcolmap.obj" - -@erase "$(INTDIR)\cdjpeg.obj" - -@erase "$(OUTDIR)\djpeg.exe" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ - /Fp"$(INTDIR)/djpeg.pch" /YX /Fo"$(INTDIR)/" /c -CPP_OBJS=.\djpeg\Release/ -CPP_SBRS=.\. -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -BSC32_FLAGS=/nologo /o"$(OUTDIR)/djpeg.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ - odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ - /pdb:"$(OUTDIR)/djpeg.pdb" /machine:I386 /out:"$(OUTDIR)/djpeg.exe" -LINK32_OBJS= \ - "$(INTDIR)\djpeg.obj" \ - "$(INTDIR)\wrppm.obj" \ - "$(INTDIR)\wrgif.obj" \ - "$(INTDIR)\wrtarga.obj" \ - "$(INTDIR)\wrrle.obj" \ - "$(INTDIR)\wrbmp.obj" \ - "$(INTDIR)\rdcolmap.obj" \ - "$(INTDIR)\cdjpeg.obj" \ - - -"$(OUTDIR)\djpeg.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -!ELSEIF "$(CFG)" == "jpegtran - Win32" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "jpegtran\Release" -# PROP BASE Intermediate_Dir "jpegtran\Release" -# PROP BASE Target_Dir "jpegtran" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "jpegtran\Release" -# PROP Intermediate_Dir "jpegtran\Release" -# PROP Target_Dir "jpegtran" -OUTDIR=.\jpegtran\Release -INTDIR=.\jpegtran\Release - -ALL : "$(OUTDIR)\jpegtran.exe" - -CLEAN : - -@erase "$(INTDIR)\jpegtran.obj" - -@erase "$(INTDIR)\rdswitch.obj" - -@erase "$(INTDIR)\cdjpeg.obj" - -@erase "$(INTDIR)\transupp.obj" - -@erase "$(OUTDIR)\jpegtran.exe" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ - /Fp"$(INTDIR)/jpegtran.pch" /YX /Fo"$(INTDIR)/" /c -CPP_OBJS=.\jpegtran\Release/ -CPP_SBRS=.\. -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -BSC32_FLAGS=/nologo /o"$(OUTDIR)/jpegtran.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ - odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ - /pdb:"$(OUTDIR)/jpegtran.pdb" /machine:I386 /out:"$(OUTDIR)/jpegtran.exe" -LINK32_OBJS= \ - "$(INTDIR)\jpegtran.obj" \ - "$(INTDIR)\rdswitch.obj" \ - "$(INTDIR)\cdjpeg.obj" \ - "$(INTDIR)\transupp.obj" \ - - -"$(OUTDIR)\jpegtran.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -!ELSEIF "$(CFG)" == "rdjpgcom - Win32" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "rdjpgcom\Release" -# PROP BASE Intermediate_Dir "rdjpgcom\Release" -# PROP BASE Target_Dir "rdjpgcom" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "rdjpgcom\Release" -# PROP Intermediate_Dir "rdjpgcom\Release" -# PROP Target_Dir "rdjpgcom" -OUTDIR=.\rdjpgcom\Release -INTDIR=.\rdjpgcom\Release - -ALL : "$(OUTDIR)\rdjpgcom.exe" - -CLEAN : - -@erase "$(INTDIR)\rdjpgcom.obj" - -@erase "$(OUTDIR)\rdjpgcom.exe" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ - /Fp"$(INTDIR)/rdjpgcom.pch" /YX /Fo"$(INTDIR)/" /c -CPP_OBJS=.\rdjpgcom\Release/ -CPP_SBRS=.\. -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -BSC32_FLAGS=/nologo /o"$(OUTDIR)/rdjpgcom.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ - odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ - /pdb:"$(OUTDIR)/rdjpgcom.pdb" /machine:I386 /out:"$(OUTDIR)/rdjpgcom.exe" -LINK32_OBJS= \ - "$(INTDIR)\rdjpgcom.obj" - -"$(OUTDIR)\rdjpgcom.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -!ELSEIF "$(CFG)" == "wrjpgcom - Win32" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "wrjpgcom\Release" -# PROP BASE Intermediate_Dir "wrjpgcom\Release" -# PROP BASE Target_Dir "wrjpgcom" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "wrjpgcom\Release" -# PROP Intermediate_Dir "wrjpgcom\Release" -# PROP Target_Dir "wrjpgcom" -OUTDIR=.\wrjpgcom\Release -INTDIR=.\wrjpgcom\Release - -ALL : "$(OUTDIR)\wrjpgcom.exe" - -CLEAN : - -@erase "$(INTDIR)\wrjpgcom.obj" - -@erase "$(OUTDIR)\wrjpgcom.exe" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ - /Fp"$(INTDIR)/wrjpgcom.pch" /YX /Fo"$(INTDIR)/" /c -CPP_OBJS=.\wrjpgcom\Release/ -CPP_SBRS=.\. -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -BSC32_FLAGS=/nologo /o"$(OUTDIR)/wrjpgcom.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ - odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ - /pdb:"$(OUTDIR)/wrjpgcom.pdb" /machine:I386 /out:"$(OUTDIR)/wrjpgcom.exe" -LINK32_OBJS= \ - "$(INTDIR)\wrjpgcom.obj" - -"$(OUTDIR)\wrjpgcom.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -!ENDIF - -.c{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.cpp{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.cxx{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.c{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -.cpp{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -.cxx{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -################################################################################ -# Begin Target - -# Name "cjpeg - Win32" - -!IF "$(CFG)" == "cjpeg - Win32" - -!ENDIF - -################################################################################ -# Begin Source File - -SOURCE="cjpeg.c" -DEP_CPP_CJPEG=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - "jversion.h"\ - - -"$(INTDIR)\cjpeg.obj" : $(SOURCE) $(DEP_CPP_CJPEG) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="cdjpeg.c" -DEP_CPP_CDJPE=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\cdjpeg.obj" : $(SOURCE) $(DEP_CPP_CDJPE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdswitch.c" -DEP_CPP_RDSWI=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdswitch.obj" : $(SOURCE) $(DEP_CPP_RDSWI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdppm.c" -DEP_CPP_RDPPM=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdppm.obj" : $(SOURCE) $(DEP_CPP_RDPPM) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdgif.c" -DEP_CPP_RDGIF=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdgif.obj" : $(SOURCE) $(DEP_CPP_RDGIF) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdtarga.c" -DEP_CPP_RDTAR=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdtarga.obj" : $(SOURCE) $(DEP_CPP_RDTAR) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdbmp.c" -DEP_CPP_RDBMP=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdbmp.obj" : $(SOURCE) $(DEP_CPP_RDBMP) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdrle.c" -DEP_CPP_RDRLE=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdrle.obj" : $(SOURCE) $(DEP_CPP_RDRLE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -# End Target -################################################################################ -# Begin Target - -# Name "djpeg - Win32" - -!IF "$(CFG)" == "djpeg - Win32" - -!ENDIF - -################################################################################ -# Begin Source File - -SOURCE="djpeg.c" -DEP_CPP_DJPEG=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - "jversion.h"\ - - -"$(INTDIR)\djpeg.obj" : $(SOURCE) $(DEP_CPP_DJPEG) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="cdjpeg.c" -DEP_CPP_CDJPE=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\cdjpeg.obj" : $(SOURCE) $(DEP_CPP_CDJPE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdcolmap.c" -DEP_CPP_RDCOL=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdcolmap.obj" : $(SOURCE) $(DEP_CPP_RDCOL) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="wrppm.c" -DEP_CPP_WRPPM=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\wrppm.obj" : $(SOURCE) $(DEP_CPP_WRPPM) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="wrgif.c" -DEP_CPP_WRGIF=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\wrgif.obj" : $(SOURCE) $(DEP_CPP_WRGIF) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="wrtarga.c" -DEP_CPP_WRTAR=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\wrtarga.obj" : $(SOURCE) $(DEP_CPP_WRTAR) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="wrbmp.c" -DEP_CPP_WRBMP=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\wrbmp.obj" : $(SOURCE) $(DEP_CPP_WRBMP) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="wrrle.c" -DEP_CPP_WRRLE=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\wrrle.obj" : $(SOURCE) $(DEP_CPP_WRRLE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -# End Target -################################################################################ -# Begin Target - -# Name "jpegtran - Win32" - -!IF "$(CFG)" == "jpegtran - Win32" - -!ENDIF - -################################################################################ -# Begin Source File - -SOURCE="jpegtran.c" -DEP_CPP_JPEGT=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - "transupp.h"\ - "jversion.h"\ - - -"$(INTDIR)\jpegtran.obj" : $(SOURCE) $(DEP_CPP_JPEGT) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="cdjpeg.c" -DEP_CPP_CDJPE=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\cdjpeg.obj" : $(SOURCE) $(DEP_CPP_CDJPE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdswitch.c" -DEP_CPP_RDSWI=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdswitch.obj" : $(SOURCE) $(DEP_CPP_RDSWI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="transupp.c" -DEP_CPP_TRANS=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "transupp.h"\ - - -"$(INTDIR)\transupp.obj" : $(SOURCE) $(DEP_CPP_TRANS) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -# End Target -################################################################################ -# Begin Target - -# Name "rdjpgcom - Win32" - -!IF "$(CFG)" == "rdjpgcom - Win32" - -!ENDIF - -################################################################################ -# Begin Source File - -SOURCE="rdjpgcom.c" -DEP_CPP_RDJPG=\ - "jinclude.h"\ - "jconfig.h"\ - - -"$(INTDIR)\rdjpgcom.obj" : $(SOURCE) $(DEP_CPP_RDJPG) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -# End Target -################################################################################ -# Begin Target - -# Name "wrjpgcom - Win32" - -!IF "$(CFG)" == "wrjpgcom - Win32" - -!ENDIF - -################################################################################ -# Begin Source File - -SOURCE="wrjpgcom.c" -DEP_CPP_WRJPG=\ - "jinclude.h"\ - "jconfig.h"\ - - -"$(INTDIR)\wrjpgcom.obj" : $(SOURCE) $(DEP_CPP_WRJPG) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -# End Target -# End Project -################################################################################ - +# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +!IF "$(CFG)" == "" +CFG=cjpeg - Win32 +!MESSAGE No configuration specified. Defaulting to cjpeg - Win32. +!ENDIF + +!IF "$(CFG)" != "cjpeg - Win32" && "$(CFG)" != "djpeg - Win32" &&\ + "$(CFG)" != "jpegtran - Win32" && "$(CFG)" != "rdjpgcom - Win32" &&\ + "$(CFG)" != "wrjpgcom - Win32" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE on this makefile +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "apps.mak" CFG="cjpeg - Win32" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "cjpeg - Win32" (based on "Win32 (x86) Console Application") +!MESSAGE "djpeg - Win32" (based on "Win32 (x86) Console Application") +!MESSAGE "jpegtran - Win32" (based on "Win32 (x86) Console Application") +!MESSAGE "rdjpgcom - Win32" (based on "Win32 (x86) Console Application") +!MESSAGE "wrjpgcom - Win32" (based on "Win32 (x86) Console Application") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF +################################################################################ +# Begin Project +# PROP Target_Last_Scanned "cjpeg - Win32" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "cjpeg - Win32" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "cjpeg\Release" +# PROP BASE Intermediate_Dir "cjpeg\Release" +# PROP BASE Target_Dir "cjpeg" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "cjpeg\Release" +# PROP Intermediate_Dir "cjpeg\Release" +# PROP Target_Dir "cjpeg" +OUTDIR=.\cjpeg\Release +INTDIR=.\cjpeg\Release + +ALL : "$(OUTDIR)\cjpeg.exe" + +CLEAN : + -@erase "$(INTDIR)\cjpeg.obj" + -@erase "$(INTDIR)\rdppm.obj" + -@erase "$(INTDIR)\rdgif.obj" + -@erase "$(INTDIR)\rdtarga.obj" + -@erase "$(INTDIR)\rdrle.obj" + -@erase "$(INTDIR)\rdbmp.obj" + -@erase "$(INTDIR)\rdswitch.obj" + -@erase "$(INTDIR)\cdjpeg.obj" + -@erase "$(OUTDIR)\cjpeg.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ + /Fp"$(INTDIR)/cjpeg.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\cjpeg\Release/ +CPP_SBRS=.\. +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/cjpeg.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ + odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ + /pdb:"$(OUTDIR)/cjpeg.pdb" /machine:I386 /out:"$(OUTDIR)/cjpeg.exe" +LINK32_OBJS= \ + "$(INTDIR)\cjpeg.obj" \ + "$(INTDIR)\rdppm.obj" \ + "$(INTDIR)\rdgif.obj" \ + "$(INTDIR)\rdtarga.obj" \ + "$(INTDIR)\rdrle.obj" \ + "$(INTDIR)\rdbmp.obj" \ + "$(INTDIR)\rdswitch.obj" \ + "$(INTDIR)\cdjpeg.obj" \ + + +"$(OUTDIR)\cjpeg.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "djpeg - Win32" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "djpeg\Release" +# PROP BASE Intermediate_Dir "djpeg\Release" +# PROP BASE Target_Dir "djpeg" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "djpeg\Release" +# PROP Intermediate_Dir "djpeg\Release" +# PROP Target_Dir "djpeg" +OUTDIR=.\djpeg\Release +INTDIR=.\djpeg\Release + +ALL : "$(OUTDIR)\djpeg.exe" + +CLEAN : + -@erase "$(INTDIR)\djpeg.obj" + -@erase "$(INTDIR)\wrppm.obj" + -@erase "$(INTDIR)\wrgif.obj" + -@erase "$(INTDIR)\wrtarga.obj" + -@erase "$(INTDIR)\wrrle.obj" + -@erase "$(INTDIR)\wrbmp.obj" + -@erase "$(INTDIR)\rdcolmap.obj" + -@erase "$(INTDIR)\cdjpeg.obj" + -@erase "$(OUTDIR)\djpeg.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ + /Fp"$(INTDIR)/djpeg.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\djpeg\Release/ +CPP_SBRS=.\. +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/djpeg.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ + odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ + /pdb:"$(OUTDIR)/djpeg.pdb" /machine:I386 /out:"$(OUTDIR)/djpeg.exe" +LINK32_OBJS= \ + "$(INTDIR)\djpeg.obj" \ + "$(INTDIR)\wrppm.obj" \ + "$(INTDIR)\wrgif.obj" \ + "$(INTDIR)\wrtarga.obj" \ + "$(INTDIR)\wrrle.obj" \ + "$(INTDIR)\wrbmp.obj" \ + "$(INTDIR)\rdcolmap.obj" \ + "$(INTDIR)\cdjpeg.obj" \ + + +"$(OUTDIR)\djpeg.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "jpegtran - Win32" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "jpegtran\Release" +# PROP BASE Intermediate_Dir "jpegtran\Release" +# PROP BASE Target_Dir "jpegtran" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "jpegtran\Release" +# PROP Intermediate_Dir "jpegtran\Release" +# PROP Target_Dir "jpegtran" +OUTDIR=.\jpegtran\Release +INTDIR=.\jpegtran\Release + +ALL : "$(OUTDIR)\jpegtran.exe" + +CLEAN : + -@erase "$(INTDIR)\jpegtran.obj" + -@erase "$(INTDIR)\rdswitch.obj" + -@erase "$(INTDIR)\cdjpeg.obj" + -@erase "$(INTDIR)\transupp.obj" + -@erase "$(OUTDIR)\jpegtran.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ + /Fp"$(INTDIR)/jpegtran.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\jpegtran\Release/ +CPP_SBRS=.\. +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/jpegtran.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ + odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ + /pdb:"$(OUTDIR)/jpegtran.pdb" /machine:I386 /out:"$(OUTDIR)/jpegtran.exe" +LINK32_OBJS= \ + "$(INTDIR)\jpegtran.obj" \ + "$(INTDIR)\rdswitch.obj" \ + "$(INTDIR)\cdjpeg.obj" \ + "$(INTDIR)\transupp.obj" \ + + +"$(OUTDIR)\jpegtran.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "rdjpgcom - Win32" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "rdjpgcom\Release" +# PROP BASE Intermediate_Dir "rdjpgcom\Release" +# PROP BASE Target_Dir "rdjpgcom" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "rdjpgcom\Release" +# PROP Intermediate_Dir "rdjpgcom\Release" +# PROP Target_Dir "rdjpgcom" +OUTDIR=.\rdjpgcom\Release +INTDIR=.\rdjpgcom\Release + +ALL : "$(OUTDIR)\rdjpgcom.exe" + +CLEAN : + -@erase "$(INTDIR)\rdjpgcom.obj" + -@erase "$(OUTDIR)\rdjpgcom.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ + /Fp"$(INTDIR)/rdjpgcom.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\rdjpgcom\Release/ +CPP_SBRS=.\. +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/rdjpgcom.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ + odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ + /pdb:"$(OUTDIR)/rdjpgcom.pdb" /machine:I386 /out:"$(OUTDIR)/rdjpgcom.exe" +LINK32_OBJS= \ + "$(INTDIR)\rdjpgcom.obj" + +"$(OUTDIR)\rdjpgcom.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "wrjpgcom - Win32" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "wrjpgcom\Release" +# PROP BASE Intermediate_Dir "wrjpgcom\Release" +# PROP BASE Target_Dir "wrjpgcom" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "wrjpgcom\Release" +# PROP Intermediate_Dir "wrjpgcom\Release" +# PROP Target_Dir "wrjpgcom" +OUTDIR=.\wrjpgcom\Release +INTDIR=.\wrjpgcom\Release + +ALL : "$(OUTDIR)\wrjpgcom.exe" + +CLEAN : + -@erase "$(INTDIR)\wrjpgcom.obj" + -@erase "$(OUTDIR)\wrjpgcom.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ + /Fp"$(INTDIR)/wrjpgcom.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\wrjpgcom\Release/ +CPP_SBRS=.\. +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/wrjpgcom.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ + odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ + /pdb:"$(OUTDIR)/wrjpgcom.pdb" /machine:I386 /out:"$(OUTDIR)/wrjpgcom.exe" +LINK32_OBJS= \ + "$(INTDIR)\wrjpgcom.obj" + +"$(OUTDIR)\wrjpgcom.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ENDIF + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +################################################################################ +# Begin Target + +# Name "cjpeg - Win32" + +!IF "$(CFG)" == "cjpeg - Win32" + +!ENDIF + +################################################################################ +# Begin Source File + +SOURCE="cjpeg.c" +DEP_CPP_CJPEG=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + "jversion.h"\ + + +"$(INTDIR)\cjpeg.obj" : $(SOURCE) $(DEP_CPP_CJPEG) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="cdjpeg.c" +DEP_CPP_CDJPE=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\cdjpeg.obj" : $(SOURCE) $(DEP_CPP_CDJPE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="rdswitch.c" +DEP_CPP_RDSWI=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\rdswitch.obj" : $(SOURCE) $(DEP_CPP_RDSWI) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="rdppm.c" +DEP_CPP_RDPPM=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\rdppm.obj" : $(SOURCE) $(DEP_CPP_RDPPM) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="rdgif.c" +DEP_CPP_RDGIF=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\rdgif.obj" : $(SOURCE) $(DEP_CPP_RDGIF) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="rdtarga.c" +DEP_CPP_RDTAR=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\rdtarga.obj" : $(SOURCE) $(DEP_CPP_RDTAR) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="rdbmp.c" +DEP_CPP_RDBMP=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\rdbmp.obj" : $(SOURCE) $(DEP_CPP_RDBMP) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="rdrle.c" +DEP_CPP_RDRLE=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\rdrle.obj" : $(SOURCE) $(DEP_CPP_RDRLE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +# End Target +################################################################################ +# Begin Target + +# Name "djpeg - Win32" + +!IF "$(CFG)" == "djpeg - Win32" + +!ENDIF + +################################################################################ +# Begin Source File + +SOURCE="djpeg.c" +DEP_CPP_DJPEG=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + "jversion.h"\ + + +"$(INTDIR)\djpeg.obj" : $(SOURCE) $(DEP_CPP_DJPEG) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="cdjpeg.c" +DEP_CPP_CDJPE=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\cdjpeg.obj" : $(SOURCE) $(DEP_CPP_CDJPE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="rdcolmap.c" +DEP_CPP_RDCOL=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\rdcolmap.obj" : $(SOURCE) $(DEP_CPP_RDCOL) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="wrppm.c" +DEP_CPP_WRPPM=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\wrppm.obj" : $(SOURCE) $(DEP_CPP_WRPPM) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="wrgif.c" +DEP_CPP_WRGIF=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\wrgif.obj" : $(SOURCE) $(DEP_CPP_WRGIF) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="wrtarga.c" +DEP_CPP_WRTAR=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\wrtarga.obj" : $(SOURCE) $(DEP_CPP_WRTAR) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="wrbmp.c" +DEP_CPP_WRBMP=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\wrbmp.obj" : $(SOURCE) $(DEP_CPP_WRBMP) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="wrrle.c" +DEP_CPP_WRRLE=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\wrrle.obj" : $(SOURCE) $(DEP_CPP_WRRLE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +# End Target +################################################################################ +# Begin Target + +# Name "jpegtran - Win32" + +!IF "$(CFG)" == "jpegtran - Win32" + +!ENDIF + +################################################################################ +# Begin Source File + +SOURCE="jpegtran.c" +DEP_CPP_JPEGT=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + "transupp.h"\ + "jversion.h"\ + + +"$(INTDIR)\jpegtran.obj" : $(SOURCE) $(DEP_CPP_JPEGT) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="cdjpeg.c" +DEP_CPP_CDJPE=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\cdjpeg.obj" : $(SOURCE) $(DEP_CPP_CDJPE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="rdswitch.c" +DEP_CPP_RDSWI=\ + "cdjpeg.h"\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + "cderror.h"\ + + +"$(INTDIR)\rdswitch.obj" : $(SOURCE) $(DEP_CPP_RDSWI) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="transupp.c" +DEP_CPP_TRANS=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "transupp.h"\ + + +"$(INTDIR)\transupp.obj" : $(SOURCE) $(DEP_CPP_TRANS) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +# End Target +################################################################################ +# Begin Target + +# Name "rdjpgcom - Win32" + +!IF "$(CFG)" == "rdjpgcom - Win32" + +!ENDIF + +################################################################################ +# Begin Source File + +SOURCE="rdjpgcom.c" +DEP_CPP_RDJPG=\ + "jinclude.h"\ + "jconfig.h"\ + + +"$(INTDIR)\rdjpgcom.obj" : $(SOURCE) $(DEP_CPP_RDJPG) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +# End Target +################################################################################ +# Begin Target + +# Name "wrjpgcom - Win32" + +!IF "$(CFG)" == "wrjpgcom - Win32" + +!ENDIF + +################################################################################ +# Begin Source File + +SOURCE="wrjpgcom.c" +DEP_CPP_WRJPG=\ + "jinclude.h"\ + "jconfig.h"\ + + +"$(INTDIR)\wrjpgcom.obj" : $(SOURCE) $(DEP_CPP_WRJPG) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +# End Target +# End Project +################################################################################ + diff --git a/src/dep/src/irrlicht/jpeglib/makefile.ansi b/src/dep/src/irrlicht/jpeglib/makefile.ansi index 39e8462..8291913 100644 --- a/src/dep/src/irrlicht/jpeglib/makefile.ansi +++ b/src/dep/src/irrlicht/jpeglib/makefile.ansi @@ -1,214 +1,214 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is suitable for Unix-like systems with ANSI-capable compilers. -# If you have a non-ANSI compiler, makefile.unix is a better starting point. - -# Read installation instructions before saying "make" !! - -# The name of your C compiler: -CC= cc - -# You may need to adjust these cc options: -CFLAGS= -O -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time cc options: -LDFLAGS= - -# To link any special libraries, add the necessary -l commands here. -LDLIBS= - -# Put here the object file name for the correct system-dependent memory -# manager file. For Unix this is usually jmemnobs.o, but you may want -# to use jmemansi.o or jmemname.o if you have limited swap space. -SYSDEPMEM= jmemnobs.o - -# miscellaneous OS-dependent stuff -# linker -LN= $(CC) -# file deletion command -RM= rm -f -# library (.a) file creation command -AR= ar rc -# second step in .a creation (use "touch" if not needed) -AR2= ranlib - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ - jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ - jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ - jfdctint.o -# decompression library object files -DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ - jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ - jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ - jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o -# These objectfiles are included in libjpeg.a -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ - cdjpeg.o -DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ - cdjpeg.o -TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o - - -all: libjpeg.a cjpeg djpeg jpegtran rdjpgcom wrjpgcom - -libjpeg.a: $(LIBOBJECTS) - $(RM) libjpeg.a - $(AR) libjpeg.a $(LIBOBJECTS) - $(AR2) libjpeg.a - -cjpeg: $(COBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.a $(LDLIBS) - -djpeg: $(DOBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.a $(LDLIBS) - -jpegtran: $(TROBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.a $(LDLIBS) - -rdjpgcom: rdjpgcom.o - $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) - -wrjpgcom: wrjpgcom.o - $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - $(RM) *.o cjpeg djpeg jpegtran libjpeg.a rdjpgcom wrjpgcom - $(RM) core testout* - -test: cjpeg djpeg jpegtran - $(RM) testout* - ./djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - ./cjpeg -dct int -outfile testout.jpg testimg.ppm - ./djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - ./jpegtran -outfile testoutt.jpg testprog.jpg - cmp testimg.ppm testout.ppm - cmp testimg.bmp testout.bmp - cmp testimg.jpg testout.jpg - cmp testimg.ppm testoutp.ppm - cmp testimgp.jpg testoutp.jpg - cmp testorig.jpg testoutt.jpg - - -jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +# Makefile for Independent JPEG Group's software + +# This makefile is suitable for Unix-like systems with ANSI-capable compilers. +# If you have a non-ANSI compiler, makefile.unix is a better starting point. + +# Read installation instructions before saying "make" !! + +# The name of your C compiler: +CC= cc + +# You may need to adjust these cc options: +CFLAGS= -O +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time cc options: +LDFLAGS= + +# To link any special libraries, add the necessary -l commands here. +LDLIBS= + +# Put here the object file name for the correct system-dependent memory +# manager file. For Unix this is usually jmemnobs.o, but you may want +# to use jmemansi.o or jmemname.o if you have limited swap space. +SYSDEPMEM= jmemnobs.o + +# miscellaneous OS-dependent stuff +# linker +LN= $(CC) +# file deletion command +RM= rm -f +# library (.a) file creation command +AR= ar rc +# second step in .a creation (use "touch" if not needed) +AR2= ranlib + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ + makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ + jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ + jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ + jfdctint.o +# decompression library object files +DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ + jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ + jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ + jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o +# These objectfiles are included in libjpeg.a +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ + cdjpeg.o +DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ + cdjpeg.o +TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o + + +all: libjpeg.a cjpeg djpeg jpegtran rdjpgcom wrjpgcom + +libjpeg.a: $(LIBOBJECTS) + $(RM) libjpeg.a + $(AR) libjpeg.a $(LIBOBJECTS) + $(AR2) libjpeg.a + +cjpeg: $(COBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.a $(LDLIBS) + +djpeg: $(DOBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.a $(LDLIBS) + +jpegtran: $(TROBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.a $(LDLIBS) + +rdjpgcom: rdjpgcom.o + $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) + +wrjpgcom: wrjpgcom.o + $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) + +jconfig.h: jconfig.doc + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.doc. + exit 1 + +clean: + $(RM) *.o cjpeg djpeg jpegtran libjpeg.a rdjpgcom wrjpgcom + $(RM) core testout* + +test: cjpeg djpeg jpegtran + $(RM) testout* + ./djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + ./cjpeg -dct int -outfile testout.jpg testimg.ppm + ./djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + ./jpegtran -outfile testoutt.jpg testprog.jpg + cmp testimg.ppm testout.ppm + cmp testimg.bmp testout.bmp + cmp testimg.jpg testout.jpg + cmp testimg.ppm testoutp.ppm + cmp testimgp.jpg testoutp.jpg + cmp testorig.jpg testoutt.jpg + + +jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/src/dep/src/irrlicht/jpeglib/makefile.bcc b/src/dep/src/irrlicht/jpeglib/makefile.bcc index 92e3218..a1cfcde 100644 --- a/src/dep/src/irrlicht/jpeglib/makefile.bcc +++ b/src/dep/src/irrlicht/jpeglib/makefile.bcc @@ -1,285 +1,285 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is suitable for Borland C on MS-DOS or OS/2. -# It works with Borland C++ for DOS, revision 3.0 or later, -# and has been tested with Borland C++ for OS/2. -# Watch out for optimization bugs in the OS/2 compilers --- see notes below! -# Thanks to Tom Wright and Ge' Weijers (original DOS) and -# Ken Porter (OS/2) for this file. - -# Read installation instructions before saying "make" !! - -# Are we under DOS or OS/2? -!if !$d(DOS) && !$d(OS2) -!if $d(__OS2__) -OS2=1 -!else -DOS=1 -!endif -!endif - -# The name of your C compiler: -CC= bcc - -# You may need to adjust these cc options: -!if $d(DOS) -CFLAGS= -O2 -mm -w-par -w-stu -w-ccc -w-rch -!else -CFLAGS= -O1 -w-par -w-stu -w-ccc -w-rch -!endif -# -O2 enables full code optimization (for pre-3.0 Borland C++, use -O -G -Z). -# -O2 is buggy in Borland OS/2 C++ revision 2.0, so use -O1 there for now. -# If you have Borland OS/2 C++ revision 1.0, use -O or no optimization at all. -# -mm selects medium memory model (near data, far code pointers; DOS only!) -# -w-par suppresses warnings about unused function parameters -# -w-stu suppresses warnings about incomplete structures -# -w-ccc suppresses warnings about compile-time-constant conditions -# -w-rch suppresses warnings about unreachable code -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time cc options: -!if $d(DOS) -LDFLAGS= -mm -# memory model option here must match CFLAGS! -!else -LDFLAGS= -# -lai full-screen app -# -lc case-significant link -!endif - -# Put here the object file name for the correct system-dependent memory -# manager file. -# For DOS, we recommend jmemdos.c and jmemdosa.asm. -# For OS/2, we recommend jmemnobs.c (flat memory!) -# SYSDEPMEMLIB must list the same files with "+" signs for the librarian. -!if $d(DOS) -SYSDEPMEM= jmemdos.obj jmemdosa.obj -SYSDEPMEMLIB= +jmemdos.obj +jmemdosa.obj -!else -SYSDEPMEM= jmemnobs.obj -SYSDEPMEMLIB= +jmemnobs.obj -!endif - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj - - -all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.lib: $(LIBOBJECTS) - - del libjpeg.lib - tlib libjpeg.lib /E /C @&&| -+jcapimin.obj +jcapistd.obj +jctrans.obj +jcparam.obj +jdatadst.obj & -+jcinit.obj +jcmaster.obj +jcmarker.obj +jcmainct.obj +jcprepct.obj & -+jccoefct.obj +jccolor.obj +jcsample.obj +jchuff.obj +jcphuff.obj & -+jcdctmgr.obj +jfdctfst.obj +jfdctflt.obj +jfdctint.obj +jdapimin.obj & -+jdapistd.obj +jdtrans.obj +jdatasrc.obj +jdmaster.obj +jdinput.obj & -+jdmarker.obj +jdhuff.obj +jdphuff.obj +jdmainct.obj +jdcoefct.obj & -+jdpostct.obj +jddctmgr.obj +jidctfst.obj +jidctflt.obj +jidctint.obj & -+jidctred.obj +jdsample.obj +jdcolor.obj +jquant1.obj +jquant2.obj & -+jdmerge.obj +jcomapi.obj +jutils.obj +jerror.obj +jmemmgr.obj & -$(SYSDEPMEMLIB) -| - -cjpeg.exe: $(COBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) -ecjpeg.exe $(COBJECTS) libjpeg.lib - -djpeg.exe: $(DOBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) -edjpeg.exe $(DOBJECTS) libjpeg.lib - -jpegtran.exe: $(TROBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) -ejpegtran.exe $(TROBJECTS) libjpeg.lib - -rdjpgcom.exe: rdjpgcom.c -!if $d(DOS) - $(CC) -ms -O rdjpgcom.c -!else - $(CC) $(CFLAGS) rdjpgcom.c -!endif - -# On DOS, wrjpgcom needs large model so it can malloc a 64K chunk -wrjpgcom.exe: wrjpgcom.c -!if $d(DOS) - $(CC) -ml -O wrjpgcom.c -!else - $(CC) $(CFLAGS) wrjpgcom.c -!endif - -# This "{}" syntax allows Borland Make to "batch" source files. -# In this way, each run of the compiler can build many modules. -.c.obj: - $(CC) $(CFLAGS) -c{ $<} - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - - del *.obj - - del libjpeg.lib - - del cjpeg.exe - - del djpeg.exe - - del jpegtran.exe - - del rdjpgcom.exe - - del wrjpgcom.exe - - del testout*.* - -test: cjpeg.exe djpeg.exe jpegtran.exe - - del testout*.* - djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - cjpeg -dct int -outfile testout.jpg testimg.ppm - djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - jpegtran -outfile testoutt.jpg testprog.jpg -!if $d(DOS) - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg -!else - echo n > n.tmp - comp testimg.ppm testout.ppm < n.tmp - comp testimg.bmp testout.bmp < n.tmp - comp testimg.jpg testout.jpg < n.tmp - comp testimg.ppm testoutp.ppm < n.tmp - comp testimgp.jpg testoutp.jpg < n.tmp - comp testorig.jpg testoutt.jpg < n.tmp - del n.tmp -!endif - - -jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -jmemdosa.obj: jmemdosa.asm - tasm /mx jmemdosa.asm +# Makefile for Independent JPEG Group's software + +# This makefile is suitable for Borland C on MS-DOS or OS/2. +# It works with Borland C++ for DOS, revision 3.0 or later, +# and has been tested with Borland C++ for OS/2. +# Watch out for optimization bugs in the OS/2 compilers --- see notes below! +# Thanks to Tom Wright and Ge' Weijers (original DOS) and +# Ken Porter (OS/2) for this file. + +# Read installation instructions before saying "make" !! + +# Are we under DOS or OS/2? +!if !$d(DOS) && !$d(OS2) +!if $d(__OS2__) +OS2=1 +!else +DOS=1 +!endif +!endif + +# The name of your C compiler: +CC= bcc + +# You may need to adjust these cc options: +!if $d(DOS) +CFLAGS= -O2 -mm -w-par -w-stu -w-ccc -w-rch +!else +CFLAGS= -O1 -w-par -w-stu -w-ccc -w-rch +!endif +# -O2 enables full code optimization (for pre-3.0 Borland C++, use -O -G -Z). +# -O2 is buggy in Borland OS/2 C++ revision 2.0, so use -O1 there for now. +# If you have Borland OS/2 C++ revision 1.0, use -O or no optimization at all. +# -mm selects medium memory model (near data, far code pointers; DOS only!) +# -w-par suppresses warnings about unused function parameters +# -w-stu suppresses warnings about incomplete structures +# -w-ccc suppresses warnings about compile-time-constant conditions +# -w-rch suppresses warnings about unreachable code +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time cc options: +!if $d(DOS) +LDFLAGS= -mm +# memory model option here must match CFLAGS! +!else +LDFLAGS= +# -lai full-screen app +# -lc case-significant link +!endif + +# Put here the object file name for the correct system-dependent memory +# manager file. +# For DOS, we recommend jmemdos.c and jmemdosa.asm. +# For OS/2, we recommend jmemnobs.c (flat memory!) +# SYSDEPMEMLIB must list the same files with "+" signs for the librarian. +!if $d(DOS) +SYSDEPMEM= jmemdos.obj jmemdosa.obj +SYSDEPMEMLIB= +jmemdos.obj +jmemdosa.obj +!else +SYSDEPMEM= jmemnobs.obj +SYSDEPMEMLIB= +jmemnobs.obj +!endif + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ + makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ + jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ + jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ + jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ + jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ + jquant1.obj jquant2.obj jdmerge.obj +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj + + +all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +libjpeg.lib: $(LIBOBJECTS) + - del libjpeg.lib + tlib libjpeg.lib /E /C @&&| ++jcapimin.obj +jcapistd.obj +jctrans.obj +jcparam.obj +jdatadst.obj & ++jcinit.obj +jcmaster.obj +jcmarker.obj +jcmainct.obj +jcprepct.obj & ++jccoefct.obj +jccolor.obj +jcsample.obj +jchuff.obj +jcphuff.obj & ++jcdctmgr.obj +jfdctfst.obj +jfdctflt.obj +jfdctint.obj +jdapimin.obj & ++jdapistd.obj +jdtrans.obj +jdatasrc.obj +jdmaster.obj +jdinput.obj & ++jdmarker.obj +jdhuff.obj +jdphuff.obj +jdmainct.obj +jdcoefct.obj & ++jdpostct.obj +jddctmgr.obj +jidctfst.obj +jidctflt.obj +jidctint.obj & ++jidctred.obj +jdsample.obj +jdcolor.obj +jquant1.obj +jquant2.obj & ++jdmerge.obj +jcomapi.obj +jutils.obj +jerror.obj +jmemmgr.obj & +$(SYSDEPMEMLIB) +| + +cjpeg.exe: $(COBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) -ecjpeg.exe $(COBJECTS) libjpeg.lib + +djpeg.exe: $(DOBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) -edjpeg.exe $(DOBJECTS) libjpeg.lib + +jpegtran.exe: $(TROBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) -ejpegtran.exe $(TROBJECTS) libjpeg.lib + +rdjpgcom.exe: rdjpgcom.c +!if $d(DOS) + $(CC) -ms -O rdjpgcom.c +!else + $(CC) $(CFLAGS) rdjpgcom.c +!endif + +# On DOS, wrjpgcom needs large model so it can malloc a 64K chunk +wrjpgcom.exe: wrjpgcom.c +!if $d(DOS) + $(CC) -ml -O wrjpgcom.c +!else + $(CC) $(CFLAGS) wrjpgcom.c +!endif + +# This "{}" syntax allows Borland Make to "batch" source files. +# In this way, each run of the compiler can build many modules. +.c.obj: + $(CC) $(CFLAGS) -c{ $<} + +jconfig.h: jconfig.doc + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.doc. + exit 1 + +clean: + - del *.obj + - del libjpeg.lib + - del cjpeg.exe + - del djpeg.exe + - del jpegtran.exe + - del rdjpgcom.exe + - del wrjpgcom.exe + - del testout*.* + +test: cjpeg.exe djpeg.exe jpegtran.exe + - del testout*.* + djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + cjpeg -dct int -outfile testout.jpg testimg.ppm + djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + jpegtran -outfile testoutt.jpg testprog.jpg +!if $d(DOS) + fc /b testimg.ppm testout.ppm + fc /b testimg.bmp testout.bmp + fc /b testimg.jpg testout.jpg + fc /b testimg.ppm testoutp.ppm + fc /b testimgp.jpg testoutp.jpg + fc /b testorig.jpg testoutt.jpg +!else + echo n > n.tmp + comp testimg.ppm testout.ppm < n.tmp + comp testimg.bmp testout.bmp < n.tmp + comp testimg.jpg testout.jpg < n.tmp + comp testimg.ppm testoutp.ppm < n.tmp + comp testimgp.jpg testoutp.jpg < n.tmp + comp testorig.jpg testoutt.jpg < n.tmp + del n.tmp +!endif + + +jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +jmemdosa.obj: jmemdosa.asm + tasm /mx jmemdosa.asm diff --git a/src/dep/src/irrlicht/jpeglib/makefile.cfg b/src/dep/src/irrlicht/jpeglib/makefile.cfg index 4e54bb0..f25e42e 100644 --- a/src/dep/src/irrlicht/jpeglib/makefile.cfg +++ b/src/dep/src/irrlicht/jpeglib/makefile.cfg @@ -1,319 +1,319 @@ -# Makefile for Independent JPEG Group's software - -# makefile.cfg is edited by configure to produce a custom Makefile. - -# Read installation instructions before saying "make" !! - -# For compiling with source and object files in different directories. -srcdir = @srcdir@ -VPATH = @srcdir@ - -# Where to install the programs and man pages. -prefix = @prefix@ -exec_prefix = @exec_prefix@ -bindir = $(exec_prefix)/bin -libdir = $(exec_prefix)/lib -includedir = $(prefix)/include -binprefix = -manprefix = -manext = 1 -mandir = $(prefix)/man/man$(manext) - -# The name of your C compiler: -CC= @CC@ - -# You may need to adjust these cc options: -CFLAGS= @CFLAGS@ @CPPFLAGS@ @INCLUDEFLAGS@ -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. -# However, any special defines for ansi2knr.c may be included here: -ANSI2KNRFLAGS= @ANSI2KNRFLAGS@ - -# Link-time cc options: -LDFLAGS= @LDFLAGS@ - -# To link any special libraries, add the necessary -l commands here. -LDLIBS= @LIBS@ - -# If using GNU libtool, LIBTOOL references it; if not, LIBTOOL is empty. -LIBTOOL = @LIBTOOL@ -# $(O) expands to "lo" if using libtool, plain "o" if not. -# Similarly, $(A) expands to "la" or "a". -O = @O@ -A = @A@ - -# Library version ID; libtool uses this for the shared library version number. -# Note: we suggest this match the macro of the same name in jpeglib.h. -JPEG_LIB_VERSION = @JPEG_LIB_VERSION@ - -# Put here the object file name for the correct system-dependent memory -# manager file. For Unix this is usually jmemnobs.o, but you may want -# to use jmemansi.o or jmemname.o if you have limited swap space. -SYSDEPMEM= @MEMORYMGR@ - -# miscellaneous OS-dependent stuff -SHELL= /bin/sh -# linker -LN= @LN@ -# file deletion command -RM= rm -f -# directory creation command -MKDIR= mkdir -# library (.a) file creation command -AR= ar rc -# second step in .a creation (use "touch" if not needed) -AR2= @RANLIB@ -# installation program -INSTALL= @INSTALL@ -INSTALL_PROGRAM= @INSTALL_PROGRAM@ -INSTALL_LIB= @INSTALL_LIB@ -INSTALL_DATA= @INSTALL_DATA@ - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.$(O) jutils.$(O) jerror.$(O) jmemmgr.$(O) $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.$(O) jcapistd.$(O) jctrans.$(O) jcparam.$(O) \ - jdatadst.$(O) jcinit.$(O) jcmaster.$(O) jcmarker.$(O) jcmainct.$(O) \ - jcprepct.$(O) jccoefct.$(O) jccolor.$(O) jcsample.$(O) jchuff.$(O) \ - jcphuff.$(O) jcdctmgr.$(O) jfdctfst.$(O) jfdctflt.$(O) \ - jfdctint.$(O) -# decompression library object files -DLIBOBJECTS= jdapimin.$(O) jdapistd.$(O) jdtrans.$(O) jdatasrc.$(O) \ - jdmaster.$(O) jdinput.$(O) jdmarker.$(O) jdhuff.$(O) jdphuff.$(O) \ - jdmainct.$(O) jdcoefct.$(O) jdpostct.$(O) jddctmgr.$(O) \ - jidctfst.$(O) jidctflt.$(O) jidctint.$(O) jidctred.$(O) \ - jdsample.$(O) jdcolor.$(O) jquant1.$(O) jquant2.$(O) jdmerge.$(O) -# These objectfiles are included in libjpeg.a -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.$(O) rdppm.$(O) rdgif.$(O) rdtarga.$(O) rdrle.$(O) \ - rdbmp.$(O) rdswitch.$(O) cdjpeg.$(O) -DOBJECTS= djpeg.$(O) wrppm.$(O) wrgif.$(O) wrtarga.$(O) wrrle.$(O) \ - wrbmp.$(O) rdcolmap.$(O) cdjpeg.$(O) -TROBJECTS= jpegtran.$(O) rdswitch.$(O) cdjpeg.$(O) transupp.$(O) - - -all: @A2K_DEPS@ libjpeg.$(A) cjpeg djpeg jpegtran rdjpgcom wrjpgcom - -# Special compilation rules to support ansi2knr and libtool. -.SUFFIXES: .lo .la - -# How to compile with libtool. -@COM_LT@.c.lo: -@COM_LT@ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/$*.c - -# How to use ansi2knr, when not using libtool. -@COM_A2K@.c.o: -@COM_A2K@ ./ansi2knr $(srcdir)/$*.c knr/$*.c -@COM_A2K@ $(CC) $(CFLAGS) -c knr/$*.c -@COM_A2K@ $(RM) knr/$*.c - -# How to use ansi2knr AND libtool. -@COM_A2K@.c.lo: -@COM_A2K@ ./ansi2knr $(srcdir)/$*.c knr/$*.c -@COM_A2K@ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c knr/$*.c -@COM_A2K@ $(RM) knr/$*.c - -ansi2knr: ansi2knr.c - $(CC) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr $(srcdir)/ansi2knr.c - $(MKDIR) knr - -# the library: - -# without libtool: -libjpeg.a: @A2K_DEPS@ $(LIBOBJECTS) - $(RM) libjpeg.a - $(AR) libjpeg.a $(LIBOBJECTS) - $(AR2) libjpeg.a - -# with libtool: -libjpeg.la: @A2K_DEPS@ $(LIBOBJECTS) - $(LIBTOOL) --mode=link $(CC) -o libjpeg.la $(LIBOBJECTS) \ - -rpath $(libdir) -version-info $(JPEG_LIB_VERSION) - -# sample programs: - -cjpeg: $(COBJECTS) libjpeg.$(A) - $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.$(A) $(LDLIBS) - -djpeg: $(DOBJECTS) libjpeg.$(A) - $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.$(A) $(LDLIBS) - -jpegtran: $(TROBJECTS) libjpeg.$(A) - $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.$(A) $(LDLIBS) - -rdjpgcom: rdjpgcom.$(O) - $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.$(O) $(LDLIBS) - -wrjpgcom: wrjpgcom.$(O) - $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.$(O) $(LDLIBS) - -# Installation rules: - -install: cjpeg djpeg jpegtran rdjpgcom wrjpgcom @FORCE_INSTALL_LIB@ - $(INSTALL_PROGRAM) cjpeg $(bindir)/$(binprefix)cjpeg - $(INSTALL_PROGRAM) djpeg $(bindir)/$(binprefix)djpeg - $(INSTALL_PROGRAM) jpegtran $(bindir)/$(binprefix)jpegtran - $(INSTALL_PROGRAM) rdjpgcom $(bindir)/$(binprefix)rdjpgcom - $(INSTALL_PROGRAM) wrjpgcom $(bindir)/$(binprefix)wrjpgcom - $(INSTALL_DATA) $(srcdir)/cjpeg.1 $(mandir)/$(manprefix)cjpeg.$(manext) - $(INSTALL_DATA) $(srcdir)/djpeg.1 $(mandir)/$(manprefix)djpeg.$(manext) - $(INSTALL_DATA) $(srcdir)/jpegtran.1 $(mandir)/$(manprefix)jpegtran.$(manext) - $(INSTALL_DATA) $(srcdir)/rdjpgcom.1 $(mandir)/$(manprefix)rdjpgcom.$(manext) - $(INSTALL_DATA) $(srcdir)/wrjpgcom.1 $(mandir)/$(manprefix)wrjpgcom.$(manext) - -install-lib: libjpeg.$(A) install-headers - $(INSTALL_LIB) libjpeg.$(A) $(libdir)/$(binprefix)libjpeg.$(A) - -install-headers: jconfig.h - $(INSTALL_DATA) jconfig.h $(includedir)/jconfig.h - $(INSTALL_DATA) $(srcdir)/jpeglib.h $(includedir)/jpeglib.h - $(INSTALL_DATA) $(srcdir)/jmorecfg.h $(includedir)/jmorecfg.h - $(INSTALL_DATA) $(srcdir)/jerror.h $(includedir)/jerror.h - -clean: - $(RM) *.o *.lo libjpeg.a libjpeg.la - $(RM) cjpeg djpeg jpegtran rdjpgcom wrjpgcom - $(RM) ansi2knr core testout* config.log config.status - $(RM) -r knr .libs _libs - -distclean: clean - $(RM) Makefile jconfig.h libtool config.cache - -test: cjpeg djpeg jpegtran - $(RM) testout* - ./djpeg -dct int -ppm -outfile testout.ppm $(srcdir)/testorig.jpg - ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg - ./cjpeg -dct int -outfile testout.jpg $(srcdir)/testimg.ppm - ./djpeg -dct int -ppm -outfile testoutp.ppm $(srcdir)/testprog.jpg - ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg $(srcdir)/testimg.ppm - ./jpegtran -outfile testoutt.jpg $(srcdir)/testprog.jpg - cmp $(srcdir)/testimg.ppm testout.ppm - cmp $(srcdir)/testimg.bmp testout.bmp - cmp $(srcdir)/testimg.jpg testout.jpg - cmp $(srcdir)/testimg.ppm testoutp.ppm - cmp $(srcdir)/testimgp.jpg testoutp.jpg - cmp $(srcdir)/testorig.jpg testoutt.jpg - -check: test - -# Mistake catcher: - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -# GNU Make likes to know which target names are not really files to be made: -.PHONY: all install install-lib install-headers clean distclean test check - - -jcapimin.$(O): jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.$(O): jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.$(O): jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.$(O): jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.$(O): jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.$(O): jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.$(O): jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.$(O): jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.$(O): jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.$(O): jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.$(O): jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.$(O): jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.$(O): jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.$(O): jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.$(O): jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.$(O): jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.$(O): jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.$(O): jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.$(O): jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.$(O): jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.$(O): jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.$(O): jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.$(O): jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.$(O): jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.$(O): jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.$(O): jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.$(O): jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.$(O): jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.$(O): jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.$(O): jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.$(O): jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.$(O): jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.$(O): jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.$(O): jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.$(O): jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.$(O): jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.$(O): jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.$(O): jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.$(O): jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.$(O): jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.$(O): jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.$(O): jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.$(O): jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.$(O): jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.$(O): jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.$(O): jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.$(O): jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.$(O): jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.$(O): jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.$(O): jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.$(O): cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.$(O): djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.$(O): jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.$(O): rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.$(O): wrjpgcom.c jinclude.h jconfig.h -cdjpeg.$(O): cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.$(O): rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.$(O): rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.$(O): transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.$(O): rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.$(O): wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.$(O): rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.$(O): wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.$(O): rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.$(O): wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.$(O): rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.$(O): wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.$(O): rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.$(O): wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +# Makefile for Independent JPEG Group's software + +# makefile.cfg is edited by configure to produce a custom Makefile. + +# Read installation instructions before saying "make" !! + +# For compiling with source and object files in different directories. +srcdir = @srcdir@ +VPATH = @srcdir@ + +# Where to install the programs and man pages. +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = $(exec_prefix)/bin +libdir = $(exec_prefix)/lib +includedir = $(prefix)/include +binprefix = +manprefix = +manext = 1 +mandir = $(prefix)/man/man$(manext) + +# The name of your C compiler: +CC= @CC@ + +# You may need to adjust these cc options: +CFLAGS= @CFLAGS@ @CPPFLAGS@ @INCLUDEFLAGS@ +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. +# However, any special defines for ansi2knr.c may be included here: +ANSI2KNRFLAGS= @ANSI2KNRFLAGS@ + +# Link-time cc options: +LDFLAGS= @LDFLAGS@ + +# To link any special libraries, add the necessary -l commands here. +LDLIBS= @LIBS@ + +# If using GNU libtool, LIBTOOL references it; if not, LIBTOOL is empty. +LIBTOOL = @LIBTOOL@ +# $(O) expands to "lo" if using libtool, plain "o" if not. +# Similarly, $(A) expands to "la" or "a". +O = @O@ +A = @A@ + +# Library version ID; libtool uses this for the shared library version number. +# Note: we suggest this match the macro of the same name in jpeglib.h. +JPEG_LIB_VERSION = @JPEG_LIB_VERSION@ + +# Put here the object file name for the correct system-dependent memory +# manager file. For Unix this is usually jmemnobs.o, but you may want +# to use jmemansi.o or jmemname.o if you have limited swap space. +SYSDEPMEM= @MEMORYMGR@ + +# miscellaneous OS-dependent stuff +SHELL= /bin/sh +# linker +LN= @LN@ +# file deletion command +RM= rm -f +# directory creation command +MKDIR= mkdir +# library (.a) file creation command +AR= ar rc +# second step in .a creation (use "touch" if not needed) +AR2= @RANLIB@ +# installation program +INSTALL= @INSTALL@ +INSTALL_PROGRAM= @INSTALL_PROGRAM@ +INSTALL_LIB= @INSTALL_LIB@ +INSTALL_DATA= @INSTALL_DATA@ + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ + makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.$(O) jutils.$(O) jerror.$(O) jmemmgr.$(O) $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.$(O) jcapistd.$(O) jctrans.$(O) jcparam.$(O) \ + jdatadst.$(O) jcinit.$(O) jcmaster.$(O) jcmarker.$(O) jcmainct.$(O) \ + jcprepct.$(O) jccoefct.$(O) jccolor.$(O) jcsample.$(O) jchuff.$(O) \ + jcphuff.$(O) jcdctmgr.$(O) jfdctfst.$(O) jfdctflt.$(O) \ + jfdctint.$(O) +# decompression library object files +DLIBOBJECTS= jdapimin.$(O) jdapistd.$(O) jdtrans.$(O) jdatasrc.$(O) \ + jdmaster.$(O) jdinput.$(O) jdmarker.$(O) jdhuff.$(O) jdphuff.$(O) \ + jdmainct.$(O) jdcoefct.$(O) jdpostct.$(O) jddctmgr.$(O) \ + jidctfst.$(O) jidctflt.$(O) jidctint.$(O) jidctred.$(O) \ + jdsample.$(O) jdcolor.$(O) jquant1.$(O) jquant2.$(O) jdmerge.$(O) +# These objectfiles are included in libjpeg.a +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.$(O) rdppm.$(O) rdgif.$(O) rdtarga.$(O) rdrle.$(O) \ + rdbmp.$(O) rdswitch.$(O) cdjpeg.$(O) +DOBJECTS= djpeg.$(O) wrppm.$(O) wrgif.$(O) wrtarga.$(O) wrrle.$(O) \ + wrbmp.$(O) rdcolmap.$(O) cdjpeg.$(O) +TROBJECTS= jpegtran.$(O) rdswitch.$(O) cdjpeg.$(O) transupp.$(O) + + +all: @A2K_DEPS@ libjpeg.$(A) cjpeg djpeg jpegtran rdjpgcom wrjpgcom + +# Special compilation rules to support ansi2knr and libtool. +.SUFFIXES: .lo .la + +# How to compile with libtool. +@COM_LT@.c.lo: +@COM_LT@ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/$*.c + +# How to use ansi2knr, when not using libtool. +@COM_A2K@.c.o: +@COM_A2K@ ./ansi2knr $(srcdir)/$*.c knr/$*.c +@COM_A2K@ $(CC) $(CFLAGS) -c knr/$*.c +@COM_A2K@ $(RM) knr/$*.c + +# How to use ansi2knr AND libtool. +@COM_A2K@.c.lo: +@COM_A2K@ ./ansi2knr $(srcdir)/$*.c knr/$*.c +@COM_A2K@ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c knr/$*.c +@COM_A2K@ $(RM) knr/$*.c + +ansi2knr: ansi2knr.c + $(CC) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr $(srcdir)/ansi2knr.c + $(MKDIR) knr + +# the library: + +# without libtool: +libjpeg.a: @A2K_DEPS@ $(LIBOBJECTS) + $(RM) libjpeg.a + $(AR) libjpeg.a $(LIBOBJECTS) + $(AR2) libjpeg.a + +# with libtool: +libjpeg.la: @A2K_DEPS@ $(LIBOBJECTS) + $(LIBTOOL) --mode=link $(CC) -o libjpeg.la $(LIBOBJECTS) \ + -rpath $(libdir) -version-info $(JPEG_LIB_VERSION) + +# sample programs: + +cjpeg: $(COBJECTS) libjpeg.$(A) + $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.$(A) $(LDLIBS) + +djpeg: $(DOBJECTS) libjpeg.$(A) + $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.$(A) $(LDLIBS) + +jpegtran: $(TROBJECTS) libjpeg.$(A) + $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.$(A) $(LDLIBS) + +rdjpgcom: rdjpgcom.$(O) + $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.$(O) $(LDLIBS) + +wrjpgcom: wrjpgcom.$(O) + $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.$(O) $(LDLIBS) + +# Installation rules: + +install: cjpeg djpeg jpegtran rdjpgcom wrjpgcom @FORCE_INSTALL_LIB@ + $(INSTALL_PROGRAM) cjpeg $(bindir)/$(binprefix)cjpeg + $(INSTALL_PROGRAM) djpeg $(bindir)/$(binprefix)djpeg + $(INSTALL_PROGRAM) jpegtran $(bindir)/$(binprefix)jpegtran + $(INSTALL_PROGRAM) rdjpgcom $(bindir)/$(binprefix)rdjpgcom + $(INSTALL_PROGRAM) wrjpgcom $(bindir)/$(binprefix)wrjpgcom + $(INSTALL_DATA) $(srcdir)/cjpeg.1 $(mandir)/$(manprefix)cjpeg.$(manext) + $(INSTALL_DATA) $(srcdir)/djpeg.1 $(mandir)/$(manprefix)djpeg.$(manext) + $(INSTALL_DATA) $(srcdir)/jpegtran.1 $(mandir)/$(manprefix)jpegtran.$(manext) + $(INSTALL_DATA) $(srcdir)/rdjpgcom.1 $(mandir)/$(manprefix)rdjpgcom.$(manext) + $(INSTALL_DATA) $(srcdir)/wrjpgcom.1 $(mandir)/$(manprefix)wrjpgcom.$(manext) + +install-lib: libjpeg.$(A) install-headers + $(INSTALL_LIB) libjpeg.$(A) $(libdir)/$(binprefix)libjpeg.$(A) + +install-headers: jconfig.h + $(INSTALL_DATA) jconfig.h $(includedir)/jconfig.h + $(INSTALL_DATA) $(srcdir)/jpeglib.h $(includedir)/jpeglib.h + $(INSTALL_DATA) $(srcdir)/jmorecfg.h $(includedir)/jmorecfg.h + $(INSTALL_DATA) $(srcdir)/jerror.h $(includedir)/jerror.h + +clean: + $(RM) *.o *.lo libjpeg.a libjpeg.la + $(RM) cjpeg djpeg jpegtran rdjpgcom wrjpgcom + $(RM) ansi2knr core testout* config.log config.status + $(RM) -r knr .libs _libs + +distclean: clean + $(RM) Makefile jconfig.h libtool config.cache + +test: cjpeg djpeg jpegtran + $(RM) testout* + ./djpeg -dct int -ppm -outfile testout.ppm $(srcdir)/testorig.jpg + ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg + ./cjpeg -dct int -outfile testout.jpg $(srcdir)/testimg.ppm + ./djpeg -dct int -ppm -outfile testoutp.ppm $(srcdir)/testprog.jpg + ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg $(srcdir)/testimg.ppm + ./jpegtran -outfile testoutt.jpg $(srcdir)/testprog.jpg + cmp $(srcdir)/testimg.ppm testout.ppm + cmp $(srcdir)/testimg.bmp testout.bmp + cmp $(srcdir)/testimg.jpg testout.jpg + cmp $(srcdir)/testimg.ppm testoutp.ppm + cmp $(srcdir)/testimgp.jpg testoutp.jpg + cmp $(srcdir)/testorig.jpg testoutt.jpg + +check: test + +# Mistake catcher: + +jconfig.h: jconfig.doc + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.doc. + exit 1 + +# GNU Make likes to know which target names are not really files to be made: +.PHONY: all install install-lib install-headers clean distclean test check + + +jcapimin.$(O): jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.$(O): jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.$(O): jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.$(O): jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.$(O): jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.$(O): jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.$(O): jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.$(O): jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.$(O): jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.$(O): jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.$(O): jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.$(O): jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.$(O): jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.$(O): jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.$(O): jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.$(O): jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.$(O): jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.$(O): jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.$(O): jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.$(O): jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.$(O): jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.$(O): jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.$(O): jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.$(O): jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.$(O): jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.$(O): jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.$(O): jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.$(O): jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.$(O): jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.$(O): jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.$(O): jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.$(O): jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.$(O): jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.$(O): jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.$(O): jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.$(O): jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.$(O): jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.$(O): jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.$(O): jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.$(O): jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.$(O): jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.$(O): jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.$(O): jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.$(O): jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.$(O): jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.$(O): jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.$(O): jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.$(O): jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.$(O): jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.$(O): jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.$(O): cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.$(O): djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.$(O): jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.$(O): rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.$(O): wrjpgcom.c jinclude.h jconfig.h +cdjpeg.$(O): cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.$(O): rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.$(O): rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.$(O): transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.$(O): rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.$(O): wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.$(O): rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.$(O): wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.$(O): rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.$(O): wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.$(O): rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.$(O): wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.$(O): rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.$(O): wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/src/dep/src/irrlicht/jpeglib/makefile.dj b/src/dep/src/irrlicht/jpeglib/makefile.dj index 4355ce2..f766d25 100644 --- a/src/dep/src/irrlicht/jpeglib/makefile.dj +++ b/src/dep/src/irrlicht/jpeglib/makefile.dj @@ -1,220 +1,220 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for DJGPP (Delorie's GNU C port on MS-DOS), v2.0 or later. -# Thanks to Frank J. Donahoe for this version. - -# Read installation instructions before saying "make" !! - -# The name of your C compiler: -CC= gcc - -# You may need to adjust these cc options: -CFLAGS= -O2 -Wall -I. -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time cc options: -LDFLAGS= -s - -# To link any special libraries, add the necessary -l commands here. -LDLIBS= - -# Put here the object file name for the correct system-dependent memory -# manager file. For DJGPP this is usually jmemnobs.o, but you could -# use jmemname.o if you want to use named temp files instead of swap space. -SYSDEPMEM= jmemnobs.o - -# miscellaneous OS-dependent stuff -# linker -LN= $(CC) -# file deletion command -RM= del -# library (.a) file creation command -AR= ar rc -# second step in .a creation (use "touch" if not needed) -AR2= ranlib - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ - jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ - jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ - jfdctint.o -# decompression library object files -DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ - jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ - jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ - jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o -# These objectfiles are included in libjpeg.a -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ - cdjpeg.o -DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ - cdjpeg.o -TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o - - -all: libjpeg.a cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.a: $(LIBOBJECTS) - $(RM) libjpeg.a - $(AR) libjpeg.a $(LIBOBJECTS) - $(AR2) libjpeg.a - -cjpeg.exe: $(COBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o cjpeg.exe $(COBJECTS) libjpeg.a $(LDLIBS) - -djpeg.exe: $(DOBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o djpeg.exe $(DOBJECTS) libjpeg.a $(LDLIBS) - -jpegtran.exe: $(TROBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o jpegtran.exe $(TROBJECTS) libjpeg.a $(LDLIBS) - -rdjpgcom.exe: rdjpgcom.o - $(LN) $(LDFLAGS) -o rdjpgcom.exe rdjpgcom.o $(LDLIBS) - -wrjpgcom.exe: wrjpgcom.o - $(LN) $(LDFLAGS) -o wrjpgcom.exe wrjpgcom.o $(LDLIBS) - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - $(RM) *.o - $(RM) cjpeg.exe - $(RM) djpeg.exe - $(RM) jpegtran.exe - $(RM) rdjpgcom.exe - $(RM) wrjpgcom.exe - $(RM) libjpeg.a - $(RM) testout*.* - -test: cjpeg.exe djpeg.exe jpegtran.exe - $(RM) testout*.* - ./djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - ./cjpeg -dct int -outfile testout.jpg testimg.ppm - ./djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - ./jpegtran -outfile testoutt.jpg testprog.jpg - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg - - -jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +# Makefile for Independent JPEG Group's software + +# This makefile is for DJGPP (Delorie's GNU C port on MS-DOS), v2.0 or later. +# Thanks to Frank J. Donahoe for this version. + +# Read installation instructions before saying "make" !! + +# The name of your C compiler: +CC= gcc + +# You may need to adjust these cc options: +CFLAGS= -O2 -Wall -I. +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time cc options: +LDFLAGS= -s + +# To link any special libraries, add the necessary -l commands here. +LDLIBS= + +# Put here the object file name for the correct system-dependent memory +# manager file. For DJGPP this is usually jmemnobs.o, but you could +# use jmemname.o if you want to use named temp files instead of swap space. +SYSDEPMEM= jmemnobs.o + +# miscellaneous OS-dependent stuff +# linker +LN= $(CC) +# file deletion command +RM= del +# library (.a) file creation command +AR= ar rc +# second step in .a creation (use "touch" if not needed) +AR2= ranlib + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ + makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ + jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ + jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ + jfdctint.o +# decompression library object files +DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ + jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ + jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ + jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o +# These objectfiles are included in libjpeg.a +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ + cdjpeg.o +DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ + cdjpeg.o +TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o + + +all: libjpeg.a cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +libjpeg.a: $(LIBOBJECTS) + $(RM) libjpeg.a + $(AR) libjpeg.a $(LIBOBJECTS) + $(AR2) libjpeg.a + +cjpeg.exe: $(COBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o cjpeg.exe $(COBJECTS) libjpeg.a $(LDLIBS) + +djpeg.exe: $(DOBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o djpeg.exe $(DOBJECTS) libjpeg.a $(LDLIBS) + +jpegtran.exe: $(TROBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o jpegtran.exe $(TROBJECTS) libjpeg.a $(LDLIBS) + +rdjpgcom.exe: rdjpgcom.o + $(LN) $(LDFLAGS) -o rdjpgcom.exe rdjpgcom.o $(LDLIBS) + +wrjpgcom.exe: wrjpgcom.o + $(LN) $(LDFLAGS) -o wrjpgcom.exe wrjpgcom.o $(LDLIBS) + +jconfig.h: jconfig.doc + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.doc. + exit 1 + +clean: + $(RM) *.o + $(RM) cjpeg.exe + $(RM) djpeg.exe + $(RM) jpegtran.exe + $(RM) rdjpgcom.exe + $(RM) wrjpgcom.exe + $(RM) libjpeg.a + $(RM) testout*.* + +test: cjpeg.exe djpeg.exe jpegtran.exe + $(RM) testout*.* + ./djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + ./cjpeg -dct int -outfile testout.jpg testimg.ppm + ./djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + ./jpegtran -outfile testoutt.jpg testprog.jpg + fc /b testimg.ppm testout.ppm + fc /b testimg.bmp testout.bmp + fc /b testimg.jpg testout.jpg + fc /b testimg.ppm testoutp.ppm + fc /b testimgp.jpg testoutp.jpg + fc /b testorig.jpg testoutt.jpg + + +jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/src/dep/src/irrlicht/jpeglib/makefile.manx b/src/dep/src/irrlicht/jpeglib/makefile.manx index 7cbc752..4cb42d1 100644 --- a/src/dep/src/irrlicht/jpeglib/makefile.manx +++ b/src/dep/src/irrlicht/jpeglib/makefile.manx @@ -1,214 +1,214 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for Amiga systems using Manx Aztec C ver 5.x. -# Thanks to D.J. James (djjames@cup.portal.com) for this version. - -# Read installation instructions before saying "make" !! - -# The name of your C compiler: -CC= cc - -# You may need to adjust these cc options: -# Uncomment for generic 68000 code (will work on any Amiga) -ARCHFLAGS= -sn - -# Uncomment for 68020/68030 code (faster, but won't run on 68000 CPU) -#ARCHFLAGS= -c2 - -CFLAGS= -MC -MD $(ARCHFLAGS) -spfam -r4 - -# Link-time cc options: -LDFLAGS= -g - -# To link any special libraries, add the necessary -l commands here. -LDLIBS= -lml -lcl - -# Put here the object file name for the correct system-dependent memory -# manager file. For Amiga we recommend jmemname.o. -SYSDEPMEM= jmemname.o - -# miscellaneous OS-dependent stuff -# linker -LN= ln -# file deletion command -RM= delete quiet -# library (.lib) file creation command -AR= lb - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ - jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ - jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ - jfdctint.o -# decompression library object files -DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ - jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ - jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ - jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ - cdjpeg.o -DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ - cdjpeg.o -TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o - - -all: libjpeg.lib cjpeg djpeg jpegtran rdjpgcom wrjpgcom - -libjpeg.lib: $(LIBOBJECTS) - -$(RM) libjpeg.lib - $(AR) libjpeg.lib $(LIBOBJECTS) - -cjpeg: $(COBJECTS) libjpeg.lib - $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.lib $(LDLIBS) - -djpeg: $(DOBJECTS) libjpeg.lib - $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.lib $(LDLIBS) - -jpegtran: $(TROBJECTS) libjpeg.lib - $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.lib $(LDLIBS) - -rdjpgcom: rdjpgcom.o - $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) - -wrjpgcom: wrjpgcom.o - $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - -$(RM) *.o cjpeg djpeg jpegtran libjpeg.lib rdjpgcom wrjpgcom - -$(RM) core testout*.* - -test: cjpeg djpeg jpegtran - -$(RM) testout*.* - djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - cjpeg -dct int -outfile testout.jpg testimg.ppm - djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - jpegtran -outfile testoutt.jpg testprog.jpg - cmp testimg.ppm testout.ppm - cmp testimg.bmp testout.bmp - cmp testimg.jpg testout.jpg - cmp testimg.ppm testoutp.ppm - cmp testimgp.jpg testoutp.jpg - cmp testorig.jpg testoutt.jpg - - -jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +# Makefile for Independent JPEG Group's software + +# This makefile is for Amiga systems using Manx Aztec C ver 5.x. +# Thanks to D.J. James (djjames@cup.portal.com) for this version. + +# Read installation instructions before saying "make" !! + +# The name of your C compiler: +CC= cc + +# You may need to adjust these cc options: +# Uncomment for generic 68000 code (will work on any Amiga) +ARCHFLAGS= -sn + +# Uncomment for 68020/68030 code (faster, but won't run on 68000 CPU) +#ARCHFLAGS= -c2 + +CFLAGS= -MC -MD $(ARCHFLAGS) -spfam -r4 + +# Link-time cc options: +LDFLAGS= -g + +# To link any special libraries, add the necessary -l commands here. +LDLIBS= -lml -lcl + +# Put here the object file name for the correct system-dependent memory +# manager file. For Amiga we recommend jmemname.o. +SYSDEPMEM= jmemname.o + +# miscellaneous OS-dependent stuff +# linker +LN= ln +# file deletion command +RM= delete quiet +# library (.lib) file creation command +AR= lb + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ + makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ + jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ + jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ + jfdctint.o +# decompression library object files +DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ + jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ + jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ + jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ + cdjpeg.o +DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ + cdjpeg.o +TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o + + +all: libjpeg.lib cjpeg djpeg jpegtran rdjpgcom wrjpgcom + +libjpeg.lib: $(LIBOBJECTS) + -$(RM) libjpeg.lib + $(AR) libjpeg.lib $(LIBOBJECTS) + +cjpeg: $(COBJECTS) libjpeg.lib + $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.lib $(LDLIBS) + +djpeg: $(DOBJECTS) libjpeg.lib + $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.lib $(LDLIBS) + +jpegtran: $(TROBJECTS) libjpeg.lib + $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.lib $(LDLIBS) + +rdjpgcom: rdjpgcom.o + $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) + +wrjpgcom: wrjpgcom.o + $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) + +jconfig.h: jconfig.doc + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.doc. + exit 1 + +clean: + -$(RM) *.o cjpeg djpeg jpegtran libjpeg.lib rdjpgcom wrjpgcom + -$(RM) core testout*.* + +test: cjpeg djpeg jpegtran + -$(RM) testout*.* + djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + cjpeg -dct int -outfile testout.jpg testimg.ppm + djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + jpegtran -outfile testoutt.jpg testprog.jpg + cmp testimg.ppm testout.ppm + cmp testimg.bmp testout.bmp + cmp testimg.jpg testout.jpg + cmp testimg.ppm testoutp.ppm + cmp testimgp.jpg testoutp.jpg + cmp testorig.jpg testoutt.jpg + + +jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/src/dep/src/irrlicht/jpeglib/makefile.mc6 b/src/dep/src/irrlicht/jpeglib/makefile.mc6 index 1185fb4..6aff054 100644 --- a/src/dep/src/irrlicht/jpeglib/makefile.mc6 +++ b/src/dep/src/irrlicht/jpeglib/makefile.mc6 @@ -1,249 +1,249 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for Microsoft C for MS-DOS, version 6.00A and up. -# Use NMAKE, not Microsoft's brain-damaged MAKE. -# Thanks to Alan Wright and Chris Turner of Olivetti Research Ltd. - -# Read installation instructions before saying "nmake" !! - -# You may need to adjust these compiler options: -CFLAGS = -AM -Oecigt -Gs -W3 -# -AM medium memory model (or use -AS for small model, if you remove features) -# -Oecigt -Gs maximum safe optimisation (-Ol has bugs in MSC 6.00A) -# -W3 warning level 3 -# You might also want to add -G2 if you have an 80286, etc. -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Jan-Herman Buining suggests the following switches for MS C 8.0 and a 486: -# CFLAGS = /AM /f- /FPi87 /G3 /Gs /Gy /Ob1 /Oc /Oe /Og /Oi /Ol /On /Oo /Ot \ -# /OV4 /W3 -# except for jquant1.c, which must be compiled with /Oo- to avoid a compiler -# crash. - -# Ingar Steinsland suggests the following switches when building -# a 16-bit Windows DLL: -# CFLAGS = -ALw -Gsw -Zpe -W3 -O2 -Zi -Zd - -# Put here the object file name for the correct system-dependent memory -# manager file. For DOS, we recommend jmemdos.c and jmemdosa.asm. -# (But not for Windows; see install.doc if you use this makefile for Windows.) -SYSDEPMEM= jmemdos.obj jmemdosa.obj -# SYSDEPMEMLIB must list the same files with "+" signs for the librarian. -SYSDEPMEMLIB= +jmemdos.obj +jmemdosa.obj - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj - -# need linker response file because file list > 128 chars -RFILE = libjpeg.ans - - -all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.lib: $(LIBOBJECTS) $(RFILE) - del libjpeg.lib - lib @$(RFILE) - -# linker response file for building libjpeg.lib -$(RFILE) : makefile - del $(RFILE) - echo libjpeg.lib >$(RFILE) -# silly want-to-create-it prompt: - echo y >>$(RFILE) - echo +jcapimin.obj +jcapistd.obj +jctrans.obj +jcparam.obj & >>$(RFILE) - echo +jdatadst.obj +jcinit.obj +jcmaster.obj +jcmarker.obj & >>$(RFILE) - echo +jcmainct.obj +jcprepct.obj +jccoefct.obj & >>$(RFILE) - echo +jccolor.obj +jcsample.obj +jchuff.obj +jcphuff.obj & >>$(RFILE) - echo +jcdctmgr.obj +jfdctfst.obj +jfdctflt.obj & >>$(RFILE) - echo +jfdctint.obj +jdapimin.obj +jdapistd.obj & >>$(RFILE) - echo +jdtrans.obj +jdatasrc.obj +jdmaster.obj +jdinput.obj & >>$(RFILE) - echo +jdmarker.obj +jdhuff.obj +jdphuff.obj +jdmainct.obj & >>$(RFILE) - echo +jdcoefct.obj +jdpostct.obj +jddctmgr.obj & >>$(RFILE) - echo +jidctfst.obj +jidctflt.obj +jidctint.obj & >>$(RFILE) - echo +jidctred.obj +jdsample.obj +jdcolor.obj +jquant1.obj & >>$(RFILE) - echo +jquant2.obj +jdmerge.obj +jcomapi.obj +jutils.obj & >>$(RFILE) - echo +jerror.obj +jmemmgr.obj & >>$(RFILE) - echo $(SYSDEPMEMLIB) ; >>$(RFILE) - -cjpeg.exe: $(COBJECTS) libjpeg.lib - echo $(COBJECTS) >cjpeg.lst - link /STACK:4096 /EXEPACK @cjpeg.lst, cjpeg.exe, , libjpeg.lib, ; - del cjpeg.lst - -djpeg.exe: $(DOBJECTS) libjpeg.lib - echo $(DOBJECTS) >djpeg.lst - link /STACK:4096 /EXEPACK @djpeg.lst, djpeg.exe, , libjpeg.lib, ; - del djpeg.lst - -jpegtran.exe: $(TROBJECTS) libjpeg.lib - link /STACK:4096 /EXEPACK $(TROBJECTS), jpegtran.exe, , libjpeg.lib, ; - -rdjpgcom.exe: rdjpgcom.c - $(CC) -AS -O -W3 rdjpgcom.c - -# wrjpgcom needs large model so it can malloc a 64K chunk -wrjpgcom.exe: wrjpgcom.c - $(CC) -AL -O -W3 wrjpgcom.c - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - del *.obj - del libjpeg.lib - del cjpeg.exe - del djpeg.exe - del jpegtran.exe - del rdjpgcom.exe - del wrjpgcom.exe - del testout*.* - -test: cjpeg.exe djpeg.exe jpegtran.exe - del testout*.* - djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - cjpeg -dct int -outfile testout.jpg testimg.ppm - djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - jpegtran -outfile testoutt.jpg testprog.jpg - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg - - -jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -jmemdosa.obj : jmemdosa.asm - masm /mx $*; +# Makefile for Independent JPEG Group's software + +# This makefile is for Microsoft C for MS-DOS, version 6.00A and up. +# Use NMAKE, not Microsoft's brain-damaged MAKE. +# Thanks to Alan Wright and Chris Turner of Olivetti Research Ltd. + +# Read installation instructions before saying "nmake" !! + +# You may need to adjust these compiler options: +CFLAGS = -AM -Oecigt -Gs -W3 +# -AM medium memory model (or use -AS for small model, if you remove features) +# -Oecigt -Gs maximum safe optimisation (-Ol has bugs in MSC 6.00A) +# -W3 warning level 3 +# You might also want to add -G2 if you have an 80286, etc. +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Jan-Herman Buining suggests the following switches for MS C 8.0 and a 486: +# CFLAGS = /AM /f- /FPi87 /G3 /Gs /Gy /Ob1 /Oc /Oe /Og /Oi /Ol /On /Oo /Ot \ +# /OV4 /W3 +# except for jquant1.c, which must be compiled with /Oo- to avoid a compiler +# crash. + +# Ingar Steinsland suggests the following switches when building +# a 16-bit Windows DLL: +# CFLAGS = -ALw -Gsw -Zpe -W3 -O2 -Zi -Zd + +# Put here the object file name for the correct system-dependent memory +# manager file. For DOS, we recommend jmemdos.c and jmemdosa.asm. +# (But not for Windows; see install.doc if you use this makefile for Windows.) +SYSDEPMEM= jmemdos.obj jmemdosa.obj +# SYSDEPMEMLIB must list the same files with "+" signs for the librarian. +SYSDEPMEMLIB= +jmemdos.obj +jmemdosa.obj + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ + makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ + jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ + jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ + jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ + jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ + jquant1.obj jquant2.obj jdmerge.obj +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj + +# need linker response file because file list > 128 chars +RFILE = libjpeg.ans + + +all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +libjpeg.lib: $(LIBOBJECTS) $(RFILE) + del libjpeg.lib + lib @$(RFILE) + +# linker response file for building libjpeg.lib +$(RFILE) : makefile + del $(RFILE) + echo libjpeg.lib >$(RFILE) +# silly want-to-create-it prompt: + echo y >>$(RFILE) + echo +jcapimin.obj +jcapistd.obj +jctrans.obj +jcparam.obj & >>$(RFILE) + echo +jdatadst.obj +jcinit.obj +jcmaster.obj +jcmarker.obj & >>$(RFILE) + echo +jcmainct.obj +jcprepct.obj +jccoefct.obj & >>$(RFILE) + echo +jccolor.obj +jcsample.obj +jchuff.obj +jcphuff.obj & >>$(RFILE) + echo +jcdctmgr.obj +jfdctfst.obj +jfdctflt.obj & >>$(RFILE) + echo +jfdctint.obj +jdapimin.obj +jdapistd.obj & >>$(RFILE) + echo +jdtrans.obj +jdatasrc.obj +jdmaster.obj +jdinput.obj & >>$(RFILE) + echo +jdmarker.obj +jdhuff.obj +jdphuff.obj +jdmainct.obj & >>$(RFILE) + echo +jdcoefct.obj +jdpostct.obj +jddctmgr.obj & >>$(RFILE) + echo +jidctfst.obj +jidctflt.obj +jidctint.obj & >>$(RFILE) + echo +jidctred.obj +jdsample.obj +jdcolor.obj +jquant1.obj & >>$(RFILE) + echo +jquant2.obj +jdmerge.obj +jcomapi.obj +jutils.obj & >>$(RFILE) + echo +jerror.obj +jmemmgr.obj & >>$(RFILE) + echo $(SYSDEPMEMLIB) ; >>$(RFILE) + +cjpeg.exe: $(COBJECTS) libjpeg.lib + echo $(COBJECTS) >cjpeg.lst + link /STACK:4096 /EXEPACK @cjpeg.lst, cjpeg.exe, , libjpeg.lib, ; + del cjpeg.lst + +djpeg.exe: $(DOBJECTS) libjpeg.lib + echo $(DOBJECTS) >djpeg.lst + link /STACK:4096 /EXEPACK @djpeg.lst, djpeg.exe, , libjpeg.lib, ; + del djpeg.lst + +jpegtran.exe: $(TROBJECTS) libjpeg.lib + link /STACK:4096 /EXEPACK $(TROBJECTS), jpegtran.exe, , libjpeg.lib, ; + +rdjpgcom.exe: rdjpgcom.c + $(CC) -AS -O -W3 rdjpgcom.c + +# wrjpgcom needs large model so it can malloc a 64K chunk +wrjpgcom.exe: wrjpgcom.c + $(CC) -AL -O -W3 wrjpgcom.c + +jconfig.h: jconfig.doc + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.doc. + exit 1 + +clean: + del *.obj + del libjpeg.lib + del cjpeg.exe + del djpeg.exe + del jpegtran.exe + del rdjpgcom.exe + del wrjpgcom.exe + del testout*.* + +test: cjpeg.exe djpeg.exe jpegtran.exe + del testout*.* + djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + cjpeg -dct int -outfile testout.jpg testimg.ppm + djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + jpegtran -outfile testoutt.jpg testprog.jpg + fc /b testimg.ppm testout.ppm + fc /b testimg.bmp testout.bmp + fc /b testimg.jpg testout.jpg + fc /b testimg.ppm testoutp.ppm + fc /b testimgp.jpg testoutp.jpg + fc /b testorig.jpg testoutt.jpg + + +jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +jmemdosa.obj : jmemdosa.asm + masm /mx $*; diff --git a/src/dep/src/irrlicht/jpeglib/makefile.mms b/src/dep/src/irrlicht/jpeglib/makefile.mms index 4ce8b89..cf130e5 100644 --- a/src/dep/src/irrlicht/jpeglib/makefile.mms +++ b/src/dep/src/irrlicht/jpeglib/makefile.mms @@ -1,218 +1,218 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for use with MMS on Digital VMS systems. -# Thanks to Rick Dyson (dyson@iowasp.physics.uiowa.edu) -# and Tim Bell (tbell@netcom.com) for their help. - -# Read installation instructions before saying "MMS" !! - -# You may need to adjust these cc options: -CFLAGS= $(CFLAGS) /NoDebug /Optimize -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via /Define switches here. -.ifdef ALPHA -OPT= -.else -OPT= ,Sys$Disk:[]MAKVMS.OPT/Option -.endif - -# Put here the object file name for the correct system-dependent memory -# manager file. For Unix this is usually jmemnobs.o, but you may want -# to use jmemansi.o or jmemname.o if you have limited swap space. -SYSDEPMEM= jmemnobs.obj - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.olb -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj -# objectfile lists with commas --- what a crock -COBJLIST= cjpeg.obj,rdppm.obj,rdgif.obj,rdtarga.obj,rdrle.obj,rdbmp.obj,\ - rdswitch.obj,cdjpeg.obj -DOBJLIST= djpeg.obj,wrppm.obj,wrgif.obj,wrtarga.obj,wrrle.obj,wrbmp.obj,\ - rdcolmap.obj,cdjpeg.obj -TROBJLIST= jpegtran.obj,rdswitch.obj,cdjpeg.obj,transupp.obj -LIBOBJLIST= jcapimin.obj,jcapistd.obj,jctrans.obj,jcparam.obj,jdatadst.obj,\ - jcinit.obj,jcmaster.obj,jcmarker.obj,jcmainct.obj,jcprepct.obj,\ - jccoefct.obj,jccolor.obj,jcsample.obj,jchuff.obj,jcphuff.obj,\ - jcdctmgr.obj,jfdctfst.obj,jfdctflt.obj,jfdctint.obj,jdapimin.obj,\ - jdapistd.obj,jdtrans.obj,jdatasrc.obj,jdmaster.obj,jdinput.obj,\ - jdmarker.obj,jdhuff.obj,jdphuff.obj,jdmainct.obj,jdcoefct.obj,\ - jdpostct.obj,jddctmgr.obj,jidctfst.obj,jidctflt.obj,jidctint.obj,\ - jidctred.obj,jdsample.obj,jdcolor.obj,jquant1.obj,jquant2.obj,\ - jdmerge.obj,jcomapi.obj,jutils.obj,jerror.obj,jmemmgr.obj,$(SYSDEPMEM) - - -.first - @- Define /NoLog Sys Sys$Library - -ALL : libjpeg.olb cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - @ Continue - -libjpeg.olb : $(LIBOBJECTS) - Library /Create libjpeg.olb $(LIBOBJLIST) - -cjpeg.exe : $(COBJECTS) libjpeg.olb - $(LINK) $(LFLAGS) /Executable = cjpeg.exe $(COBJLIST),libjpeg.olb/Library$(OPT) - -djpeg.exe : $(DOBJECTS) libjpeg.olb - $(LINK) $(LFLAGS) /Executable = djpeg.exe $(DOBJLIST),libjpeg.olb/Library$(OPT) - -jpegtran.exe : $(TROBJECTS) libjpeg.olb - $(LINK) $(LFLAGS) /Executable = jpegtran.exe $(TROBJLIST),libjpeg.olb/Library$(OPT) - -rdjpgcom.exe : rdjpgcom.obj - $(LINK) $(LFLAGS) /Executable = rdjpgcom.exe rdjpgcom.obj$(OPT) - -wrjpgcom.exe : wrjpgcom.obj - $(LINK) $(LFLAGS) /Executable = wrjpgcom.exe wrjpgcom.obj$(OPT) - -jconfig.h : jconfig.vms - @- Copy jconfig.vms jconfig.h - -clean : - @- Set Protection = Owner:RWED *.*;-1 - @- Set Protection = Owner:RWED *.OBJ - - Purge /NoLog /NoConfirm *.* - - Delete /NoLog /NoConfirm *.OBJ; - -test : cjpeg.exe djpeg.exe jpegtran.exe - mcr sys$disk:[]djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - mcr sys$disk:[]djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - mcr sys$disk:[]cjpeg -dct int -outfile testout.jpg testimg.ppm - mcr sys$disk:[]djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - mcr sys$disk:[]cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - mcr sys$disk:[]jpegtran -outfile testoutt.jpg testprog.jpg - - Backup /Compare/Log testimg.ppm testout.ppm - - Backup /Compare/Log testimg.bmp testout.bmp - - Backup /Compare/Log testimg.jpg testout.jpg - - Backup /Compare/Log testimg.ppm testoutp.ppm - - Backup /Compare/Log testimgp.jpg testoutp.jpg - - Backup /Compare/Log testorig.jpg testoutt.jpg - - -jcapimin.obj : jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj : jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj : jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj : jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj : jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj : jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj : jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj : jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj : jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj : jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj : jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj : jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj : jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj : jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj : jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj : jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj : jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj : jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj : jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj : jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj : jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj : jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj : jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj : jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj : jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj : jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj : jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj : jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj : jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj : jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj : jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj : jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj : jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj : jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj : jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj : jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj : jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj : jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj : jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj : jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj : jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj : jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj : jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj : jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj : jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj : jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj : jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj : jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj : jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj : jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj : cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj : djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj : jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj : rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj : wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj : cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj : rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj : rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj : transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj : rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj : wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj : rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj : wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj : rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj : wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj : rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj : wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj : rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj : wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +# Makefile for Independent JPEG Group's software + +# This makefile is for use with MMS on Digital VMS systems. +# Thanks to Rick Dyson (dyson@iowasp.physics.uiowa.edu) +# and Tim Bell (tbell@netcom.com) for their help. + +# Read installation instructions before saying "MMS" !! + +# You may need to adjust these cc options: +CFLAGS= $(CFLAGS) /NoDebug /Optimize +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via /Define switches here. +.ifdef ALPHA +OPT= +.else +OPT= ,Sys$Disk:[]MAKVMS.OPT/Option +.endif + +# Put here the object file name for the correct system-dependent memory +# manager file. For Unix this is usually jmemnobs.o, but you may want +# to use jmemansi.o or jmemname.o if you have limited swap space. +SYSDEPMEM= jmemnobs.obj + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ + makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ + jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ + jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ + jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ + jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ + jquant1.obj jquant2.obj jdmerge.obj +# These objectfiles are included in libjpeg.olb +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj +# objectfile lists with commas --- what a crock +COBJLIST= cjpeg.obj,rdppm.obj,rdgif.obj,rdtarga.obj,rdrle.obj,rdbmp.obj,\ + rdswitch.obj,cdjpeg.obj +DOBJLIST= djpeg.obj,wrppm.obj,wrgif.obj,wrtarga.obj,wrrle.obj,wrbmp.obj,\ + rdcolmap.obj,cdjpeg.obj +TROBJLIST= jpegtran.obj,rdswitch.obj,cdjpeg.obj,transupp.obj +LIBOBJLIST= jcapimin.obj,jcapistd.obj,jctrans.obj,jcparam.obj,jdatadst.obj,\ + jcinit.obj,jcmaster.obj,jcmarker.obj,jcmainct.obj,jcprepct.obj,\ + jccoefct.obj,jccolor.obj,jcsample.obj,jchuff.obj,jcphuff.obj,\ + jcdctmgr.obj,jfdctfst.obj,jfdctflt.obj,jfdctint.obj,jdapimin.obj,\ + jdapistd.obj,jdtrans.obj,jdatasrc.obj,jdmaster.obj,jdinput.obj,\ + jdmarker.obj,jdhuff.obj,jdphuff.obj,jdmainct.obj,jdcoefct.obj,\ + jdpostct.obj,jddctmgr.obj,jidctfst.obj,jidctflt.obj,jidctint.obj,\ + jidctred.obj,jdsample.obj,jdcolor.obj,jquant1.obj,jquant2.obj,\ + jdmerge.obj,jcomapi.obj,jutils.obj,jerror.obj,jmemmgr.obj,$(SYSDEPMEM) + + +.first + @- Define /NoLog Sys Sys$Library + +ALL : libjpeg.olb cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + @ Continue + +libjpeg.olb : $(LIBOBJECTS) + Library /Create libjpeg.olb $(LIBOBJLIST) + +cjpeg.exe : $(COBJECTS) libjpeg.olb + $(LINK) $(LFLAGS) /Executable = cjpeg.exe $(COBJLIST),libjpeg.olb/Library$(OPT) + +djpeg.exe : $(DOBJECTS) libjpeg.olb + $(LINK) $(LFLAGS) /Executable = djpeg.exe $(DOBJLIST),libjpeg.olb/Library$(OPT) + +jpegtran.exe : $(TROBJECTS) libjpeg.olb + $(LINK) $(LFLAGS) /Executable = jpegtran.exe $(TROBJLIST),libjpeg.olb/Library$(OPT) + +rdjpgcom.exe : rdjpgcom.obj + $(LINK) $(LFLAGS) /Executable = rdjpgcom.exe rdjpgcom.obj$(OPT) + +wrjpgcom.exe : wrjpgcom.obj + $(LINK) $(LFLAGS) /Executable = wrjpgcom.exe wrjpgcom.obj$(OPT) + +jconfig.h : jconfig.vms + @- Copy jconfig.vms jconfig.h + +clean : + @- Set Protection = Owner:RWED *.*;-1 + @- Set Protection = Owner:RWED *.OBJ + - Purge /NoLog /NoConfirm *.* + - Delete /NoLog /NoConfirm *.OBJ; + +test : cjpeg.exe djpeg.exe jpegtran.exe + mcr sys$disk:[]djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + mcr sys$disk:[]djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + mcr sys$disk:[]cjpeg -dct int -outfile testout.jpg testimg.ppm + mcr sys$disk:[]djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + mcr sys$disk:[]cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + mcr sys$disk:[]jpegtran -outfile testoutt.jpg testprog.jpg + - Backup /Compare/Log testimg.ppm testout.ppm + - Backup /Compare/Log testimg.bmp testout.bmp + - Backup /Compare/Log testimg.jpg testout.jpg + - Backup /Compare/Log testimg.ppm testoutp.ppm + - Backup /Compare/Log testimgp.jpg testoutp.jpg + - Backup /Compare/Log testorig.jpg testoutt.jpg + + +jcapimin.obj : jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj : jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj : jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj : jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj : jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj : jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.obj : jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj : jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj : jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj : jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj : jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj : jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.obj : jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.obj : jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj : jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj : jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj : jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj : jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj : jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj : jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj : jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj : jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj : jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj : jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.obj : jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj : jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj : jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj : jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj : jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.obj : jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.obj : jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj : jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj : jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj : jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj : jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj : jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj : jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj : jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj : jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj : jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.obj : jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj : jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj : jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj : jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj : jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj : jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj : jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj : jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj : jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj : jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj : cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj : djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj : jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.obj : rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj : wrjpgcom.c jinclude.h jconfig.h +cdjpeg.obj : cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj : rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj : rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.obj : transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.obj : rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj : wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj : rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj : wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj : rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj : wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj : rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj : wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj : rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj : wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/src/dep/src/irrlicht/jpeglib/makefile.sas b/src/dep/src/irrlicht/jpeglib/makefile.sas index d26793d..f296faf 100644 --- a/src/dep/src/irrlicht/jpeglib/makefile.sas +++ b/src/dep/src/irrlicht/jpeglib/makefile.sas @@ -1,252 +1,252 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for Amiga systems using SAS C 6.0 and up. -# Thanks to Ed Hanway, Mark Rinfret, and Jim Zepeda. - -# Read installation instructions before saying "make" !! - -# The name of your C compiler: -CC= sc - -# You may need to adjust these cc options: -# Uncomment the following lines for generic 680x0 version -ARCHFLAGS= cpu=any -SUFFIX= - -# Uncomment the following lines for 68030-only version -#ARCHFLAGS= cpu=68030 -#SUFFIX=.030 - -CFLAGS= nostackcheck data=near parms=register optimize $(ARCHFLAGS) \ - ignore=104 ignore=304 ignore=306 -# ignore=104 disables warnings for mismatched const qualifiers -# ignore=304 disables warnings for variables being optimized out -# ignore=306 disables warnings for the inlining of functions -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via define switches here. - -# Link-time cc options: -LDFLAGS= SC SD ND BATCH - -# To link any special libraries, add the necessary commands here. -LDLIBS= LIB:scm.lib LIB:sc.lib - -# Put here the object file name for the correct system-dependent memory -# manager file. For Amiga we recommend jmemname.o. -SYSDEPMEM= jmemname.o - -# miscellaneous OS-dependent stuff -# linker -LN= slink -# file deletion command -RM= delete quiet -# library (.lib) file creation command -AR= oml - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ - jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ - jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ - jfdctint.o -# decompression library object files -DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ - jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ - jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ - jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ - cdjpeg.o -DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ - cdjpeg.o -TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o - - -all: libjpeg.lib cjpeg$(SUFFIX) djpeg$(SUFFIX) jpegtran$(SUFFIX) rdjpgcom$(SUFFIX) wrjpgcom$(SUFFIX) - -# note: do several AR steps to avoid command line length limitations - -libjpeg.lib: $(LIBOBJECTS) - -$(RM) libjpeg.lib - $(AR) libjpeg.lib r $(CLIBOBJECTS) - $(AR) libjpeg.lib r $(DLIBOBJECTS) - $(AR) libjpeg.lib r $(COMOBJECTS) - -cjpeg$(SUFFIX): $(COBJECTS) libjpeg.lib - $(LN) - -# You may want to adjust these compiler options: -CFLAGS= $(cflags) $(cdebug) $(cvars) -I. -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time options: -LDFLAGS= $(ldebug) $(conlflags) - -# To link any special libraries, add the necessary commands here. -LDLIBS= $(conlibs) - -# Put here the object file name for the correct system-dependent memory -# manager file. For NT we suggest jmemnobs.obj, which expects the OS to -# provide adequate virtual memory. -SYSDEPMEM= jmemnobs.obj - -# miscellaneous OS-dependent stuff -# file deletion command -RM= del - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj - -# Template command for compiling .c to .obj -.c.obj: - $(cc) $(CFLAGS) $*.c - - -all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.lib: $(LIBOBJECTS) - $(RM) libjpeg.lib - lib -out:libjpeg.lib $(LIBOBJECTS) - -cjpeg.exe: $(COBJECTS) libjpeg.lib - $(link) $(LDFLAGS) -out:cjpeg.exe $(COBJECTS) libjpeg.lib $(LDLIBS) - -djpeg.exe: $(DOBJECTS) libjpeg.lib - $(link) $(LDFLAGS) -out:djpeg.exe $(DOBJECTS) libjpeg.lib $(LDLIBS) - -jpegtran.exe: $(TROBJECTS) libjpeg.lib - $(link) $(LDFLAGS) -out:jpegtran.exe $(TROBJECTS) libjpeg.lib $(LDLIBS) - -rdjpgcom.exe: rdjpgcom.obj - $(link) $(LDFLAGS) -out:rdjpgcom.exe rdjpgcom.obj $(LDLIBS) - -wrjpgcom.exe: wrjpgcom.obj - $(link) $(LDFLAGS) -out:wrjpgcom.exe wrjpgcom.obj $(LDLIBS) - - -clean: - $(RM) *.obj *.exe libjpeg.lib - $(RM) testout* - -test: cjpeg.exe djpeg.exe jpegtran.exe - $(RM) testout* - .\djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - .\djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - .\cjpeg -dct int -outfile testout.jpg testimg.ppm - .\djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - .\cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - .\jpegtran -outfile testoutt.jpg testprog.jpg - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg - - -jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +# Makefile for Independent JPEG Group's software + +# This makefile is for Microsoft Visual C++ on Windows NT (and 95?). +# It builds the IJG library as a statically linkable library (.LIB), +# and builds the sample applications as console-mode apps. +# Thanks to Xingong Chang, Raymond Everly and others. + +# Read installation instructions before saying "nmake" !! +# To build an optimized library without debug info, say "nmake nodebug=1". + +# Pull in standard variable definitions +!include + +# You may want to adjust these compiler options: +CFLAGS= $(cflags) $(cdebug) $(cvars) -I. +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time options: +LDFLAGS= $(ldebug) $(conlflags) + +# To link any special libraries, add the necessary commands here. +LDLIBS= $(conlibs) + +# Put here the object file name for the correct system-dependent memory +# manager file. For NT we suggest jmemnobs.obj, which expects the OS to +# provide adequate virtual memory. +SYSDEPMEM= jmemnobs.obj + +# miscellaneous OS-dependent stuff +# file deletion command +RM= del + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ + makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ + jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ + jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ + jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ + jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ + jquant1.obj jquant2.obj jdmerge.obj +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj + +# Template command for compiling .c to .obj +.c.obj: + $(cc) $(CFLAGS) $*.c + + +all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +libjpeg.lib: $(LIBOBJECTS) + $(RM) libjpeg.lib + lib -out:libjpeg.lib $(LIBOBJECTS) + +cjpeg.exe: $(COBJECTS) libjpeg.lib + $(link) $(LDFLAGS) -out:cjpeg.exe $(COBJECTS) libjpeg.lib $(LDLIBS) + +djpeg.exe: $(DOBJECTS) libjpeg.lib + $(link) $(LDFLAGS) -out:djpeg.exe $(DOBJECTS) libjpeg.lib $(LDLIBS) + +jpegtran.exe: $(TROBJECTS) libjpeg.lib + $(link) $(LDFLAGS) -out:jpegtran.exe $(TROBJECTS) libjpeg.lib $(LDLIBS) + +rdjpgcom.exe: rdjpgcom.obj + $(link) $(LDFLAGS) -out:rdjpgcom.exe rdjpgcom.obj $(LDLIBS) + +wrjpgcom.exe: wrjpgcom.obj + $(link) $(LDFLAGS) -out:wrjpgcom.exe wrjpgcom.obj $(LDLIBS) + + +clean: + $(RM) *.obj *.exe libjpeg.lib + $(RM) testout* + +test: cjpeg.exe djpeg.exe jpegtran.exe + $(RM) testout* + .\djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + .\djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + .\cjpeg -dct int -outfile testout.jpg testimg.ppm + .\djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + .\cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + .\jpegtran -outfile testoutt.jpg testprog.jpg + fc /b testimg.ppm testout.ppm + fc /b testimg.bmp testout.bmp + fc /b testimg.jpg testout.jpg + fc /b testimg.ppm testoutp.ppm + fc /b testimgp.jpg testoutp.jpg + fc /b testorig.jpg testoutt.jpg + + +jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/src/dep/src/irrlicht/jpeglib/makefile.vms b/src/dep/src/irrlicht/jpeglib/makefile.vms index 711f852..a42358d 100644 --- a/src/dep/src/irrlicht/jpeglib/makefile.vms +++ b/src/dep/src/irrlicht/jpeglib/makefile.vms @@ -1,142 +1,142 @@ -$! Makefile for Independent JPEG Group's software -$! -$! This is a command procedure for Digital VMS systems that do not have MMS. -$! It builds the JPEG software by brute force, recompiling everything whether -$! or not it is necessary. It then runs the basic self-test. -$! Thanks to Rick Dyson (dyson@iowasp.physics.uiowa.edu) -$! and Tim Bell (tbell@netcom.com) for their help. -$! -$! Read installation instructions before running this!! -$! -$ If F$Mode () .eqs. "INTERACTIVE" -$ Then -$ VERIFY = F$Verify (0) -$ Else -$ VERIFY = F$Verify (1) -$ EndIf -$ On Control_Y Then GoTo End -$ On Error Then GoTo End -$ -$ If F$GetSyi ("HW_MODEL") .gt. 1023 -$ Then -$ OPT = "" -$ Else -$ OPT = ",Sys$Disk:[]makvms.opt/Option" -$ EndIf -$ -$ DoCompile := CC /NoDebug /Optimize /NoList -$! -$ DoCompile jcapimin.c -$ DoCompile jcapistd.c -$ DoCompile jctrans.c -$ DoCompile jcparam.c -$ DoCompile jdatadst.c -$ DoCompile jcinit.c -$ DoCompile jcmaster.c -$ DoCompile jcmarker.c -$ DoCompile jcmainct.c -$ DoCompile jcprepct.c -$ DoCompile jccoefct.c -$ DoCompile jccolor.c -$ DoCompile jcsample.c -$ DoCompile jchuff.c -$ DoCompile jcphuff.c -$ DoCompile jcdctmgr.c -$ DoCompile jfdctfst.c -$ DoCompile jfdctflt.c -$ DoCompile jfdctint.c -$ DoCompile jdapimin.c -$ DoCompile jdapistd.c -$ DoCompile jdtrans.c -$ DoCompile jdatasrc.c -$ DoCompile jdmaster.c -$ DoCompile jdinput.c -$ DoCompile jdmarker.c -$ DoCompile jdhuff.c -$ DoCompile jdphuff.c -$ DoCompile jdmainct.c -$ DoCompile jdcoefct.c -$ DoCompile jdpostct.c -$ DoCompile jddctmgr.c -$ DoCompile jidctfst.c -$ DoCompile jidctflt.c -$ DoCompile jidctint.c -$ DoCompile jidctred.c -$ DoCompile jdsample.c -$ DoCompile jdcolor.c -$ DoCompile jquant1.c -$ DoCompile jquant2.c -$ DoCompile jdmerge.c -$ DoCompile jcomapi.c -$ DoCompile jutils.c -$ DoCompile jerror.c -$ DoCompile jmemmgr.c -$ DoCompile jmemnobs.c -$! -$ Library /Create libjpeg.olb jcapimin.obj,jcapistd.obj,jctrans.obj, - - jcparam.obj,jdatadst.obj,jcinit.obj,jcmaster.obj,jcmarker.obj, - - jcmainct.obj,jcprepct.obj,jccoefct.obj,jccolor.obj,jcsample.obj, - - jchuff.obj,jcphuff.obj,jcdctmgr.obj,jfdctfst.obj,jfdctflt.obj, - - jfdctint.obj,jdapimin.obj,jdapistd.obj,jdtrans.obj,jdatasrc.obj, - - jdmaster.obj,jdinput.obj,jdmarker.obj,jdhuff.obj,jdphuff.obj, - - jdmainct.obj,jdcoefct.obj,jdpostct.obj,jddctmgr.obj,jidctfst.obj, - - jidctflt.obj,jidctint.obj,jidctred.obj,jdsample.obj,jdcolor.obj, - - jquant1.obj,jquant2.obj,jdmerge.obj,jcomapi.obj,jutils.obj, - - jerror.obj,jmemmgr.obj,jmemnobs.obj -$! -$ DoCompile cjpeg.c -$ DoCompile rdppm.c -$ DoCompile rdgif.c -$ DoCompile rdtarga.c -$ DoCompile rdrle.c -$ DoCompile rdbmp.c -$ DoCompile rdswitch.c -$ DoCompile cdjpeg.c -$! -$ Link /NoMap /Executable = cjpeg.exe cjpeg.obj,rdppm.obj,rdgif.obj, - - rdtarga.obj,rdrle.obj,rdbmp.obj,rdswitch.obj,cdjpeg.obj,libjpeg.olb/Library'OPT' -$! -$ DoCompile djpeg.c -$ DoCompile wrppm.c -$ DoCompile wrgif.c -$ DoCompile wrtarga.c -$ DoCompile wrrle.c -$ DoCompile wrbmp.c -$ DoCompile rdcolmap.c -$ DoCompile cdjpeg.c -$! -$ Link /NoMap /Executable = djpeg.exe djpeg.obj,wrppm.obj,wrgif.obj, - - wrtarga.obj,wrrle.obj,wrbmp.obj,rdcolmap.obj,cdjpeg.obj,libjpeg.olb/Library'OPT' -$! -$ DoCompile jpegtran.c -$ DoCompile rdswitch.c -$ DoCompile cdjpeg.c -$ DoCompile transupp.c -$! -$ Link /NoMap /Executable = jpegtran.exe jpegtran.obj,rdswitch.obj, - - cdjpeg.obj,transupp.obj,libjpeg.olb/Library'OPT' -$! -$ DoCompile rdjpgcom.c -$ Link /NoMap /Executable = rdjpgcom.exe rdjpgcom.obj'OPT' -$! -$ DoCompile wrjpgcom.c -$ Link /NoMap /Executable = wrjpgcom.exe wrjpgcom.obj'OPT' -$! -$! Run the self-test -$! -$ mcr sys$disk:[]djpeg -dct int -ppm -outfile testout.ppm testorig.jpg -$ mcr sys$disk:[]djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg -$ mcr sys$disk:[]cjpeg -dct int -outfile testout.jpg testimg.ppm -$ mcr sys$disk:[]djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg -$ mcr sys$disk:[]cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm -$ mcr sys$disk:[]jpegtran -outfile testoutt.jpg testprog.jpg -$ Backup /Compare/Log testimg.ppm testout.ppm -$ Backup /Compare/Log testimg.bmp testout.bmp -$ Backup /Compare/Log testimg.jpg testout.jpg -$ Backup /Compare/Log testimg.ppm testoutp.ppm -$ Backup /Compare/Log testimgp.jpg testoutp.jpg -$ Backup /Compare/Log testorig.jpg testoutt.jpg -$! -$End: -$ If Verify Then Set Verify -$ Exit +$! Makefile for Independent JPEG Group's software +$! +$! This is a command procedure for Digital VMS systems that do not have MMS. +$! It builds the JPEG software by brute force, recompiling everything whether +$! or not it is necessary. It then runs the basic self-test. +$! Thanks to Rick Dyson (dyson@iowasp.physics.uiowa.edu) +$! and Tim Bell (tbell@netcom.com) for their help. +$! +$! Read installation instructions before running this!! +$! +$ If F$Mode () .eqs. "INTERACTIVE" +$ Then +$ VERIFY = F$Verify (0) +$ Else +$ VERIFY = F$Verify (1) +$ EndIf +$ On Control_Y Then GoTo End +$ On Error Then GoTo End +$ +$ If F$GetSyi ("HW_MODEL") .gt. 1023 +$ Then +$ OPT = "" +$ Else +$ OPT = ",Sys$Disk:[]makvms.opt/Option" +$ EndIf +$ +$ DoCompile := CC /NoDebug /Optimize /NoList +$! +$ DoCompile jcapimin.c +$ DoCompile jcapistd.c +$ DoCompile jctrans.c +$ DoCompile jcparam.c +$ DoCompile jdatadst.c +$ DoCompile jcinit.c +$ DoCompile jcmaster.c +$ DoCompile jcmarker.c +$ DoCompile jcmainct.c +$ DoCompile jcprepct.c +$ DoCompile jccoefct.c +$ DoCompile jccolor.c +$ DoCompile jcsample.c +$ DoCompile jchuff.c +$ DoCompile jcphuff.c +$ DoCompile jcdctmgr.c +$ DoCompile jfdctfst.c +$ DoCompile jfdctflt.c +$ DoCompile jfdctint.c +$ DoCompile jdapimin.c +$ DoCompile jdapistd.c +$ DoCompile jdtrans.c +$ DoCompile jdatasrc.c +$ DoCompile jdmaster.c +$ DoCompile jdinput.c +$ DoCompile jdmarker.c +$ DoCompile jdhuff.c +$ DoCompile jdphuff.c +$ DoCompile jdmainct.c +$ DoCompile jdcoefct.c +$ DoCompile jdpostct.c +$ DoCompile jddctmgr.c +$ DoCompile jidctfst.c +$ DoCompile jidctflt.c +$ DoCompile jidctint.c +$ DoCompile jidctred.c +$ DoCompile jdsample.c +$ DoCompile jdcolor.c +$ DoCompile jquant1.c +$ DoCompile jquant2.c +$ DoCompile jdmerge.c +$ DoCompile jcomapi.c +$ DoCompile jutils.c +$ DoCompile jerror.c +$ DoCompile jmemmgr.c +$ DoCompile jmemnobs.c +$! +$ Library /Create libjpeg.olb jcapimin.obj,jcapistd.obj,jctrans.obj, - + jcparam.obj,jdatadst.obj,jcinit.obj,jcmaster.obj,jcmarker.obj, - + jcmainct.obj,jcprepct.obj,jccoefct.obj,jccolor.obj,jcsample.obj, - + jchuff.obj,jcphuff.obj,jcdctmgr.obj,jfdctfst.obj,jfdctflt.obj, - + jfdctint.obj,jdapimin.obj,jdapistd.obj,jdtrans.obj,jdatasrc.obj, - + jdmaster.obj,jdinput.obj,jdmarker.obj,jdhuff.obj,jdphuff.obj, - + jdmainct.obj,jdcoefct.obj,jdpostct.obj,jddctmgr.obj,jidctfst.obj, - + jidctflt.obj,jidctint.obj,jidctred.obj,jdsample.obj,jdcolor.obj, - + jquant1.obj,jquant2.obj,jdmerge.obj,jcomapi.obj,jutils.obj, - + jerror.obj,jmemmgr.obj,jmemnobs.obj +$! +$ DoCompile cjpeg.c +$ DoCompile rdppm.c +$ DoCompile rdgif.c +$ DoCompile rdtarga.c +$ DoCompile rdrle.c +$ DoCompile rdbmp.c +$ DoCompile rdswitch.c +$ DoCompile cdjpeg.c +$! +$ Link /NoMap /Executable = cjpeg.exe cjpeg.obj,rdppm.obj,rdgif.obj, - + rdtarga.obj,rdrle.obj,rdbmp.obj,rdswitch.obj,cdjpeg.obj,libjpeg.olb/Library'OPT' +$! +$ DoCompile djpeg.c +$ DoCompile wrppm.c +$ DoCompile wrgif.c +$ DoCompile wrtarga.c +$ DoCompile wrrle.c +$ DoCompile wrbmp.c +$ DoCompile rdcolmap.c +$ DoCompile cdjpeg.c +$! +$ Link /NoMap /Executable = djpeg.exe djpeg.obj,wrppm.obj,wrgif.obj, - + wrtarga.obj,wrrle.obj,wrbmp.obj,rdcolmap.obj,cdjpeg.obj,libjpeg.olb/Library'OPT' +$! +$ DoCompile jpegtran.c +$ DoCompile rdswitch.c +$ DoCompile cdjpeg.c +$ DoCompile transupp.c +$! +$ Link /NoMap /Executable = jpegtran.exe jpegtran.obj,rdswitch.obj, - + cdjpeg.obj,transupp.obj,libjpeg.olb/Library'OPT' +$! +$ DoCompile rdjpgcom.c +$ Link /NoMap /Executable = rdjpgcom.exe rdjpgcom.obj'OPT' +$! +$ DoCompile wrjpgcom.c +$ Link /NoMap /Executable = wrjpgcom.exe wrjpgcom.obj'OPT' +$! +$! Run the self-test +$! +$ mcr sys$disk:[]djpeg -dct int -ppm -outfile testout.ppm testorig.jpg +$ mcr sys$disk:[]djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg +$ mcr sys$disk:[]cjpeg -dct int -outfile testout.jpg testimg.ppm +$ mcr sys$disk:[]djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg +$ mcr sys$disk:[]cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm +$ mcr sys$disk:[]jpegtran -outfile testoutt.jpg testprog.jpg +$ Backup /Compare/Log testimg.ppm testout.ppm +$ Backup /Compare/Log testimg.bmp testout.bmp +$ Backup /Compare/Log testimg.jpg testout.jpg +$ Backup /Compare/Log testimg.ppm testoutp.ppm +$ Backup /Compare/Log testimgp.jpg testoutp.jpg +$ Backup /Compare/Log testorig.jpg testoutt.jpg +$! +$End: +$ If Verify Then Set Verify +$ Exit diff --git a/src/dep/src/irrlicht/jpeglib/makefile.wat b/src/dep/src/irrlicht/jpeglib/makefile.wat index c0570dc..d953e46 100644 --- a/src/dep/src/irrlicht/jpeglib/makefile.wat +++ b/src/dep/src/irrlicht/jpeglib/makefile.wat @@ -1,233 +1,233 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is suitable for Watcom C/C++ 10.0 on MS-DOS (using -# dos4g extender), OS/2, and Windows NT console mode. -# Thanks to Janos Haide, jhaide@btrvtech.com. - -# Read installation instructions before saying "wmake" !! - -# Uncomment line for desired system -SYSTEM=DOS -#SYSTEM=OS2 -#SYSTEM=NT - -# The name of your C compiler: -CC= wcl386 - -# You may need to adjust these cc options: -CFLAGS= -4r -ort -wx -zq -bt=$(SYSTEM) -# Caution: avoid -ol or -ox; these generate bad code with 10.0 or 10.0a. -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time cc options: -!ifeq SYSTEM DOS -LDFLAGS= -zq -l=dos4g -!else ifeq SYSTEM OS2 -LDFLAGS= -zq -l=os2v2 -!else ifeq SYSTEM NT -LDFLAGS= -zq -l=nt -!endif - -# Put here the object file name for the correct system-dependent memory -# manager file. jmemnobs should work fine for dos4g or OS/2 environment. -SYSDEPMEM= jmemnobs.obj - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c & - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c & - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c & - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c & - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c & - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c & - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c & - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c & - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c & - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h & - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 & - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc & - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc & - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds & - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st & - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms & - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat & - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas & - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg & - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) & - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj & - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj & - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj & - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj & - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj & - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj & - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj & - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj & - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj & - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj - - -all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.lib: $(LIBOBJECTS) - - del libjpeg.lib - * wlib -n libjpeg.lib $(LIBOBJECTS) - -cjpeg.exe: $(COBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) $(COBJECTS) libjpeg.lib - -djpeg.exe: $(DOBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) $(DOBJECTS) libjpeg.lib - -jpegtran.exe: $(TROBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) $(TROBJECTS) libjpeg.lib - -rdjpgcom.exe: rdjpgcom.c - $(CC) $(CFLAGS) $(LDFLAGS) rdjpgcom.c - -wrjpgcom.exe: wrjpgcom.c - $(CC) $(CFLAGS) $(LDFLAGS) wrjpgcom.c - -.c.obj: - $(CC) $(CFLAGS) -c $< - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: .SYMBOLIC - - del *.obj - - del libjpeg.lib - - del cjpeg.exe - - del djpeg.exe - - del jpegtran.exe - - del rdjpgcom.exe - - del wrjpgcom.exe - - del testout*.* - -test: cjpeg.exe djpeg.exe jpegtran.exe .SYMBOLIC - - del testout*.* - djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - cjpeg -dct int -outfile testout.jpg testimg.ppm - djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - jpegtran -outfile testoutt.jpg testprog.jpg -!ifeq SYSTEM DOS - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg -!else - echo n > n.tmp - comp testimg.ppm testout.ppm < n.tmp - comp testimg.bmp testout.bmp < n.tmp - comp testimg.jpg testout.jpg < n.tmp - comp testimg.ppm testoutp.ppm < n.tmp - comp testimgp.jpg testoutp.jpg < n.tmp - comp testorig.jpg testoutt.jpg < n.tmp - del n.tmp -!endif - - -jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +# Makefile for Independent JPEG Group's software + +# This makefile is suitable for Watcom C/C++ 10.0 on MS-DOS (using +# dos4g extender), OS/2, and Windows NT console mode. +# Thanks to Janos Haide, jhaide@btrvtech.com. + +# Read installation instructions before saying "wmake" !! + +# Uncomment line for desired system +SYSTEM=DOS +#SYSTEM=OS2 +#SYSTEM=NT + +# The name of your C compiler: +CC= wcl386 + +# You may need to adjust these cc options: +CFLAGS= -4r -ort -wx -zq -bt=$(SYSTEM) +# Caution: avoid -ol or -ox; these generate bad code with 10.0 or 10.0a. +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time cc options: +!ifeq SYSTEM DOS +LDFLAGS= -zq -l=dos4g +!else ifeq SYSTEM OS2 +LDFLAGS= -zq -l=os2v2 +!else ifeq SYSTEM NT +LDFLAGS= -zq -l=nt +!endif + +# Put here the object file name for the correct system-dependent memory +# manager file. jmemnobs should work fine for dos4g or OS/2 environment. +SYSDEPMEM= jmemnobs.obj + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c & + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c & + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c & + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c & + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c & + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c & + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c & + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c & + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c & + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h & + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 & + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc & + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc & + makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds & + makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st & + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms & + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat & + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas & + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg & + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) & + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj & + jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj & + jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj & + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj & + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj & + jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj & + jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj & + jquant1.obj jquant2.obj jdmerge.obj +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj & + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj & + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj + + +all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +libjpeg.lib: $(LIBOBJECTS) + - del libjpeg.lib + * wlib -n libjpeg.lib $(LIBOBJECTS) + +cjpeg.exe: $(COBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) $(COBJECTS) libjpeg.lib + +djpeg.exe: $(DOBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) $(DOBJECTS) libjpeg.lib + +jpegtran.exe: $(TROBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) $(TROBJECTS) libjpeg.lib + +rdjpgcom.exe: rdjpgcom.c + $(CC) $(CFLAGS) $(LDFLAGS) rdjpgcom.c + +wrjpgcom.exe: wrjpgcom.c + $(CC) $(CFLAGS) $(LDFLAGS) wrjpgcom.c + +.c.obj: + $(CC) $(CFLAGS) -c $< + +jconfig.h: jconfig.doc + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.doc. + exit 1 + +clean: .SYMBOLIC + - del *.obj + - del libjpeg.lib + - del cjpeg.exe + - del djpeg.exe + - del jpegtran.exe + - del rdjpgcom.exe + - del wrjpgcom.exe + - del testout*.* + +test: cjpeg.exe djpeg.exe jpegtran.exe .SYMBOLIC + - del testout*.* + djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + cjpeg -dct int -outfile testout.jpg testimg.ppm + djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + jpegtran -outfile testoutt.jpg testprog.jpg +!ifeq SYSTEM DOS + fc /b testimg.ppm testout.ppm + fc /b testimg.bmp testout.bmp + fc /b testimg.jpg testout.jpg + fc /b testimg.ppm testoutp.ppm + fc /b testimgp.jpg testoutp.jpg + fc /b testorig.jpg testoutt.jpg +!else + echo n > n.tmp + comp testimg.ppm testout.ppm < n.tmp + comp testimg.bmp testout.bmp < n.tmp + comp testimg.jpg testout.jpg < n.tmp + comp testimg.ppm testoutp.ppm < n.tmp + comp testimgp.jpg testoutp.jpg < n.tmp + comp testorig.jpg testoutt.jpg < n.tmp + del n.tmp +!endif + + +jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/src/dep/src/irrlicht/jpeglib/makelib.ds b/src/dep/src/irrlicht/jpeglib/makelib.ds index 78d0ddf..c7ad36d 100644 --- a/src/dep/src/irrlicht/jpeglib/makelib.ds +++ b/src/dep/src/irrlicht/jpeglib/makelib.ds @@ -1,1046 +1,1046 @@ -# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -!IF "$(CFG)" == "" -CFG=jpeg - Win32 -!MESSAGE No configuration specified. Defaulting to jpeg - Win32. -!ENDIF - -!IF "$(CFG)" != "jpeg - Win32" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE on this makefile -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "jpeg.mak" CFG="jpeg - Win32" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "jpeg - Win32" (based on "Win32 (x86) Static Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF -################################################################################ -# Begin Project -# PROP Target_Last_Scanned "jpeg - Win32" -CPP=cl.exe - -!IF "$(CFG)" == "jpeg - Win32" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -OUTDIR=.\Release -INTDIR=.\Release - -ALL : "$(OUTDIR)\jpeg.lib" - -CLEAN : - -@erase "$(INTDIR)\jcapimin.obj" - -@erase "$(INTDIR)\jcapistd.obj" - -@erase "$(INTDIR)\jctrans.obj" - -@erase "$(INTDIR)\jcparam.obj" - -@erase "$(INTDIR)\jdatadst.obj" - -@erase "$(INTDIR)\jcinit.obj" - -@erase "$(INTDIR)\jcmaster.obj" - -@erase "$(INTDIR)\jcmarker.obj" - -@erase "$(INTDIR)\jcmainct.obj" - -@erase "$(INTDIR)\jcprepct.obj" - -@erase "$(INTDIR)\jccoefct.obj" - -@erase "$(INTDIR)\jccolor.obj" - -@erase "$(INTDIR)\jcsample.obj" - -@erase "$(INTDIR)\jchuff.obj" - -@erase "$(INTDIR)\jcphuff.obj" - -@erase "$(INTDIR)\jcdctmgr.obj" - -@erase "$(INTDIR)\jfdctfst.obj" - -@erase "$(INTDIR)\jfdctflt.obj" - -@erase "$(INTDIR)\jfdctint.obj" - -@erase "$(INTDIR)\jdapimin.obj" - -@erase "$(INTDIR)\jdapistd.obj" - -@erase "$(INTDIR)\jdtrans.obj" - -@erase "$(INTDIR)\jdatasrc.obj" - -@erase "$(INTDIR)\jdmaster.obj" - -@erase "$(INTDIR)\jdinput.obj" - -@erase "$(INTDIR)\jdmarker.obj" - -@erase "$(INTDIR)\jdhuff.obj" - -@erase "$(INTDIR)\jdphuff.obj" - -@erase "$(INTDIR)\jdmainct.obj" - -@erase "$(INTDIR)\jdcoefct.obj" - -@erase "$(INTDIR)\jdpostct.obj" - -@erase "$(INTDIR)\jddctmgr.obj" - -@erase "$(INTDIR)\jidctfst.obj" - -@erase "$(INTDIR)\jidctflt.obj" - -@erase "$(INTDIR)\jidctint.obj" - -@erase "$(INTDIR)\jidctred.obj" - -@erase "$(INTDIR)\jdsample.obj" - -@erase "$(INTDIR)\jdcolor.obj" - -@erase "$(INTDIR)\jquant1.obj" - -@erase "$(INTDIR)\jquant2.obj" - -@erase "$(INTDIR)\jdmerge.obj" - -@erase "$(INTDIR)\jcomapi.obj" - -@erase "$(INTDIR)\jutils.obj" - -@erase "$(INTDIR)\jerror.obj" - -@erase "$(INTDIR)\jmemmgr.obj" - -@erase "$(INTDIR)\jmemnobs.obj" - -@erase "$(OUTDIR)\jpeg.lib" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\ - /Fp"$(INTDIR)/jpeg.pch" /YX /Fo"$(INTDIR)/" /c -CPP_OBJS=.\Release/ -CPP_SBRS=.\. -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -BSC32_FLAGS=/nologo /o"$(OUTDIR)/jpeg.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo -LIB32_FLAGS=/nologo /out:"$(OUTDIR)/jpeg.lib" -LIB32_OBJS= \ - "$(INTDIR)\jcapimin.obj" \ - "$(INTDIR)\jcapistd.obj" \ - "$(INTDIR)\jctrans.obj" \ - "$(INTDIR)\jcparam.obj" \ - "$(INTDIR)\jdatadst.obj" \ - "$(INTDIR)\jcinit.obj" \ - "$(INTDIR)\jcmaster.obj" \ - "$(INTDIR)\jcmarker.obj" \ - "$(INTDIR)\jcmainct.obj" \ - "$(INTDIR)\jcprepct.obj" \ - "$(INTDIR)\jccoefct.obj" \ - "$(INTDIR)\jccolor.obj" \ - "$(INTDIR)\jcsample.obj" \ - "$(INTDIR)\jchuff.obj" \ - "$(INTDIR)\jcphuff.obj" \ - "$(INTDIR)\jcdctmgr.obj" \ - "$(INTDIR)\jfdctfst.obj" \ - "$(INTDIR)\jfdctflt.obj" \ - "$(INTDIR)\jfdctint.obj" \ - "$(INTDIR)\jdapimin.obj" \ - "$(INTDIR)\jdapistd.obj" \ - "$(INTDIR)\jdtrans.obj" \ - "$(INTDIR)\jdatasrc.obj" \ - "$(INTDIR)\jdmaster.obj" \ - "$(INTDIR)\jdinput.obj" \ - "$(INTDIR)\jdmarker.obj" \ - "$(INTDIR)\jdhuff.obj" \ - "$(INTDIR)\jdphuff.obj" \ - "$(INTDIR)\jdmainct.obj" \ - "$(INTDIR)\jdcoefct.obj" \ - "$(INTDIR)\jdpostct.obj" \ - "$(INTDIR)\jddctmgr.obj" \ - "$(INTDIR)\jidctfst.obj" \ - "$(INTDIR)\jidctflt.obj" \ - "$(INTDIR)\jidctint.obj" \ - "$(INTDIR)\jidctred.obj" \ - "$(INTDIR)\jdsample.obj" \ - "$(INTDIR)\jdcolor.obj" \ - "$(INTDIR)\jquant1.obj" \ - "$(INTDIR)\jquant2.obj" \ - "$(INTDIR)\jdmerge.obj" \ - "$(INTDIR)\jcomapi.obj" \ - "$(INTDIR)\jutils.obj" \ - "$(INTDIR)\jerror.obj" \ - "$(INTDIR)\jmemmgr.obj" \ - "$(INTDIR)\jmemnobs.obj" - -"$(OUTDIR)\jpeg.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ENDIF - -.c{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.cpp{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.cxx{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.c{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -.cpp{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -.cxx{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -################################################################################ -# Begin Target - -# Name "jpeg - Win32" - -!IF "$(CFG)" == "jpeg - Win32" - -!ENDIF - -################################################################################ -# Begin Source File - -SOURCE="jcapimin.c" -DEP_CPP_JCAPI=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcapimin.obj" : $(SOURCE) $(DEP_CPP_JCAPI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcapistd.c" -DEP_CPP_JCAPIS=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcapistd.obj" : $(SOURCE) $(DEP_CPP_JCAPIS) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jccoefct.c" -DEP_CPP_JCCOE=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jccoefct.obj" : $(SOURCE) $(DEP_CPP_JCCOE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jccolor.c" -DEP_CPP_JCCOL=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jccolor.obj" : $(SOURCE) $(DEP_CPP_JCCOL) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcdctmgr.c" -DEP_CPP_JCDCT=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jcdctmgr.obj" : $(SOURCE) $(DEP_CPP_JCDCT) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jchuff.c" -DEP_CPP_JCHUF=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jchuff.h"\ - - -"$(INTDIR)\jchuff.obj" : $(SOURCE) $(DEP_CPP_JCHUF) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcinit.c" -DEP_CPP_JCINI=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcinit.obj" : $(SOURCE) $(DEP_CPP_JCINI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcmainct.c" -DEP_CPP_JCMAI=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcmainct.obj" : $(SOURCE) $(DEP_CPP_JCMAI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcmarker.c" -DEP_CPP_JCMAR=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcmarker.obj" : $(SOURCE) $(DEP_CPP_JCMAR) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcmaster.c" -DEP_CPP_JCMAS=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcmaster.obj" : $(SOURCE) $(DEP_CPP_JCMAS) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcomapi.c" -DEP_CPP_JCOMA=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcomapi.obj" : $(SOURCE) $(DEP_CPP_JCOMA) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcparam.c" -DEP_CPP_JCPAR=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcparam.obj" : $(SOURCE) $(DEP_CPP_JCPAR) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcphuff.c" -DEP_CPP_JCPHU=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jchuff.h"\ - - -"$(INTDIR)\jcphuff.obj" : $(SOURCE) $(DEP_CPP_JCPHU) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcprepct.c" -DEP_CPP_JCPRE=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcprepct.obj" : $(SOURCE) $(DEP_CPP_JCPRE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcsample.c" -DEP_CPP_JCSAM=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcsample.obj" : $(SOURCE) $(DEP_CPP_JCSAM) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jctrans.c" -DEP_CPP_JCTRA=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jctrans.obj" : $(SOURCE) $(DEP_CPP_JCTRA) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdapimin.c" -DEP_CPP_JDAPI=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdapimin.obj" : $(SOURCE) $(DEP_CPP_JDAPI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdapistd.c" -DEP_CPP_JDAPIS=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdapistd.obj" : $(SOURCE) $(DEP_CPP_JDAPIS) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdatadst.c" -DEP_CPP_JDATA=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdatadst.obj" : $(SOURCE) $(DEP_CPP_JDATA) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdatasrc.c" -DEP_CPP_JDATAS=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdatasrc.obj" : $(SOURCE) $(DEP_CPP_JDATAS) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdcoefct.c" -DEP_CPP_JDCOE=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdcoefct.obj" : $(SOURCE) $(DEP_CPP_JDCOE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdcolor.c" -DEP_CPP_JDCOL=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdcolor.obj" : $(SOURCE) $(DEP_CPP_JDCOL) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jddctmgr.c" -DEP_CPP_JDDCT=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jddctmgr.obj" : $(SOURCE) $(DEP_CPP_JDDCT) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdhuff.c" -DEP_CPP_JDHUF=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdhuff.h"\ - - -"$(INTDIR)\jdhuff.obj" : $(SOURCE) $(DEP_CPP_JDHUF) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdinput.c" -DEP_CPP_JDINP=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdinput.obj" : $(SOURCE) $(DEP_CPP_JDINP) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdmainct.c" -DEP_CPP_JDMAI=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdmainct.obj" : $(SOURCE) $(DEP_CPP_JDMAI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdmarker.c" -DEP_CPP_JDMAR=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdmarker.obj" : $(SOURCE) $(DEP_CPP_JDMAR) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdmaster.c" -DEP_CPP_JDMAS=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdmaster.obj" : $(SOURCE) $(DEP_CPP_JDMAS) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdmerge.c" -DEP_CPP_JDMER=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdmerge.obj" : $(SOURCE) $(DEP_CPP_JDMER) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdphuff.c" -DEP_CPP_JDPHU=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdhuff.h"\ - - -"$(INTDIR)\jdphuff.obj" : $(SOURCE) $(DEP_CPP_JDPHU) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdpostct.c" -DEP_CPP_JDPOS=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdpostct.obj" : $(SOURCE) $(DEP_CPP_JDPOS) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdsample.c" -DEP_CPP_JDSAM=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdsample.obj" : $(SOURCE) $(DEP_CPP_JDSAM) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdtrans.c" -DEP_CPP_JDTRA=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdtrans.obj" : $(SOURCE) $(DEP_CPP_JDTRA) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jerror.c" -DEP_CPP_JERRO=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jversion.h"\ - "jerror.h"\ - - -"$(INTDIR)\jerror.obj" : $(SOURCE) $(DEP_CPP_JERRO) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jfdctflt.c" -DEP_CPP_JFDCT=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jfdctflt.obj" : $(SOURCE) $(DEP_CPP_JFDCT) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jfdctfst.c" -DEP_CPP_JFDCTF=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jfdctfst.obj" : $(SOURCE) $(DEP_CPP_JFDCTF) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jfdctint.c" -DEP_CPP_JFDCTI=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jfdctint.obj" : $(SOURCE) $(DEP_CPP_JFDCTI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jidctflt.c" -DEP_CPP_JIDCT=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jidctflt.obj" : $(SOURCE) $(DEP_CPP_JIDCT) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jidctfst.c" -DEP_CPP_JIDCTF=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jidctfst.obj" : $(SOURCE) $(DEP_CPP_JIDCTF) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jidctint.c" -DEP_CPP_JIDCTI=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jidctint.obj" : $(SOURCE) $(DEP_CPP_JIDCTI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jidctred.c" -DEP_CPP_JIDCTR=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jidctred.obj" : $(SOURCE) $(DEP_CPP_JIDCTR) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jquant1.c" -DEP_CPP_JQUAN=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jquant1.obj" : $(SOURCE) $(DEP_CPP_JQUAN) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jquant2.c" -DEP_CPP_JQUANT=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jquant2.obj" : $(SOURCE) $(DEP_CPP_JQUANT) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jutils.c" -DEP_CPP_JUTIL=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jutils.obj" : $(SOURCE) $(DEP_CPP_JUTIL) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jmemmgr.c" -DEP_CPP_JMEMM=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jmemsys.h"\ - - -"$(INTDIR)\jmemmgr.obj" : $(SOURCE) $(DEP_CPP_JMEMM) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jmemnobs.c" -DEP_CPP_JMEMN=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jmemsys.h"\ - - -"$(INTDIR)\jmemnobs.obj" : $(SOURCE) $(DEP_CPP_JMEMN) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -# End Target -# End Project -################################################################################ - +# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +!IF "$(CFG)" == "" +CFG=jpeg - Win32 +!MESSAGE No configuration specified. Defaulting to jpeg - Win32. +!ENDIF + +!IF "$(CFG)" != "jpeg - Win32" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE on this makefile +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "jpeg.mak" CFG="jpeg - Win32" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "jpeg - Win32" (based on "Win32 (x86) Static Library") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF +################################################################################ +# Begin Project +# PROP Target_Last_Scanned "jpeg - Win32" +CPP=cl.exe + +!IF "$(CFG)" == "jpeg - Win32" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +OUTDIR=.\Release +INTDIR=.\Release + +ALL : "$(OUTDIR)\jpeg.lib" + +CLEAN : + -@erase "$(INTDIR)\jcapimin.obj" + -@erase "$(INTDIR)\jcapistd.obj" + -@erase "$(INTDIR)\jctrans.obj" + -@erase "$(INTDIR)\jcparam.obj" + -@erase "$(INTDIR)\jdatadst.obj" + -@erase "$(INTDIR)\jcinit.obj" + -@erase "$(INTDIR)\jcmaster.obj" + -@erase "$(INTDIR)\jcmarker.obj" + -@erase "$(INTDIR)\jcmainct.obj" + -@erase "$(INTDIR)\jcprepct.obj" + -@erase "$(INTDIR)\jccoefct.obj" + -@erase "$(INTDIR)\jccolor.obj" + -@erase "$(INTDIR)\jcsample.obj" + -@erase "$(INTDIR)\jchuff.obj" + -@erase "$(INTDIR)\jcphuff.obj" + -@erase "$(INTDIR)\jcdctmgr.obj" + -@erase "$(INTDIR)\jfdctfst.obj" + -@erase "$(INTDIR)\jfdctflt.obj" + -@erase "$(INTDIR)\jfdctint.obj" + -@erase "$(INTDIR)\jdapimin.obj" + -@erase "$(INTDIR)\jdapistd.obj" + -@erase "$(INTDIR)\jdtrans.obj" + -@erase "$(INTDIR)\jdatasrc.obj" + -@erase "$(INTDIR)\jdmaster.obj" + -@erase "$(INTDIR)\jdinput.obj" + -@erase "$(INTDIR)\jdmarker.obj" + -@erase "$(INTDIR)\jdhuff.obj" + -@erase "$(INTDIR)\jdphuff.obj" + -@erase "$(INTDIR)\jdmainct.obj" + -@erase "$(INTDIR)\jdcoefct.obj" + -@erase "$(INTDIR)\jdpostct.obj" + -@erase "$(INTDIR)\jddctmgr.obj" + -@erase "$(INTDIR)\jidctfst.obj" + -@erase "$(INTDIR)\jidctflt.obj" + -@erase "$(INTDIR)\jidctint.obj" + -@erase "$(INTDIR)\jidctred.obj" + -@erase "$(INTDIR)\jdsample.obj" + -@erase "$(INTDIR)\jdcolor.obj" + -@erase "$(INTDIR)\jquant1.obj" + -@erase "$(INTDIR)\jquant2.obj" + -@erase "$(INTDIR)\jdmerge.obj" + -@erase "$(INTDIR)\jcomapi.obj" + -@erase "$(INTDIR)\jutils.obj" + -@erase "$(INTDIR)\jerror.obj" + -@erase "$(INTDIR)\jmemmgr.obj" + -@erase "$(INTDIR)\jmemnobs.obj" + -@erase "$(OUTDIR)\jpeg.lib" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\ + /Fp"$(INTDIR)/jpeg.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\Release/ +CPP_SBRS=.\. +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/jpeg.bsc" +BSC32_SBRS= \ + +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +LIB32_FLAGS=/nologo /out:"$(OUTDIR)/jpeg.lib" +LIB32_OBJS= \ + "$(INTDIR)\jcapimin.obj" \ + "$(INTDIR)\jcapistd.obj" \ + "$(INTDIR)\jctrans.obj" \ + "$(INTDIR)\jcparam.obj" \ + "$(INTDIR)\jdatadst.obj" \ + "$(INTDIR)\jcinit.obj" \ + "$(INTDIR)\jcmaster.obj" \ + "$(INTDIR)\jcmarker.obj" \ + "$(INTDIR)\jcmainct.obj" \ + "$(INTDIR)\jcprepct.obj" \ + "$(INTDIR)\jccoefct.obj" \ + "$(INTDIR)\jccolor.obj" \ + "$(INTDIR)\jcsample.obj" \ + "$(INTDIR)\jchuff.obj" \ + "$(INTDIR)\jcphuff.obj" \ + "$(INTDIR)\jcdctmgr.obj" \ + "$(INTDIR)\jfdctfst.obj" \ + "$(INTDIR)\jfdctflt.obj" \ + "$(INTDIR)\jfdctint.obj" \ + "$(INTDIR)\jdapimin.obj" \ + "$(INTDIR)\jdapistd.obj" \ + "$(INTDIR)\jdtrans.obj" \ + "$(INTDIR)\jdatasrc.obj" \ + "$(INTDIR)\jdmaster.obj" \ + "$(INTDIR)\jdinput.obj" \ + "$(INTDIR)\jdmarker.obj" \ + "$(INTDIR)\jdhuff.obj" \ + "$(INTDIR)\jdphuff.obj" \ + "$(INTDIR)\jdmainct.obj" \ + "$(INTDIR)\jdcoefct.obj" \ + "$(INTDIR)\jdpostct.obj" \ + "$(INTDIR)\jddctmgr.obj" \ + "$(INTDIR)\jidctfst.obj" \ + "$(INTDIR)\jidctflt.obj" \ + "$(INTDIR)\jidctint.obj" \ + "$(INTDIR)\jidctred.obj" \ + "$(INTDIR)\jdsample.obj" \ + "$(INTDIR)\jdcolor.obj" \ + "$(INTDIR)\jquant1.obj" \ + "$(INTDIR)\jquant2.obj" \ + "$(INTDIR)\jdmerge.obj" \ + "$(INTDIR)\jcomapi.obj" \ + "$(INTDIR)\jutils.obj" \ + "$(INTDIR)\jerror.obj" \ + "$(INTDIR)\jmemmgr.obj" \ + "$(INTDIR)\jmemnobs.obj" + +"$(OUTDIR)\jpeg.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) + $(LIB32) @<< + $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) +<< + +!ENDIF + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +################################################################################ +# Begin Target + +# Name "jpeg - Win32" + +!IF "$(CFG)" == "jpeg - Win32" + +!ENDIF + +################################################################################ +# Begin Source File + +SOURCE="jcapimin.c" +DEP_CPP_JCAPI=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jcapimin.obj" : $(SOURCE) $(DEP_CPP_JCAPI) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jcapistd.c" +DEP_CPP_JCAPIS=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jcapistd.obj" : $(SOURCE) $(DEP_CPP_JCAPIS) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jccoefct.c" +DEP_CPP_JCCOE=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jccoefct.obj" : $(SOURCE) $(DEP_CPP_JCCOE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jccolor.c" +DEP_CPP_JCCOL=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jccolor.obj" : $(SOURCE) $(DEP_CPP_JCCOL) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jcdctmgr.c" +DEP_CPP_JCDCT=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jdct.h"\ + + +"$(INTDIR)\jcdctmgr.obj" : $(SOURCE) $(DEP_CPP_JCDCT) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jchuff.c" +DEP_CPP_JCHUF=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jchuff.h"\ + + +"$(INTDIR)\jchuff.obj" : $(SOURCE) $(DEP_CPP_JCHUF) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jcinit.c" +DEP_CPP_JCINI=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jcinit.obj" : $(SOURCE) $(DEP_CPP_JCINI) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jcmainct.c" +DEP_CPP_JCMAI=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jcmainct.obj" : $(SOURCE) $(DEP_CPP_JCMAI) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jcmarker.c" +DEP_CPP_JCMAR=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jcmarker.obj" : $(SOURCE) $(DEP_CPP_JCMAR) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jcmaster.c" +DEP_CPP_JCMAS=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jcmaster.obj" : $(SOURCE) $(DEP_CPP_JCMAS) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jcomapi.c" +DEP_CPP_JCOMA=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jcomapi.obj" : $(SOURCE) $(DEP_CPP_JCOMA) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jcparam.c" +DEP_CPP_JCPAR=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jcparam.obj" : $(SOURCE) $(DEP_CPP_JCPAR) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jcphuff.c" +DEP_CPP_JCPHU=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jchuff.h"\ + + +"$(INTDIR)\jcphuff.obj" : $(SOURCE) $(DEP_CPP_JCPHU) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jcprepct.c" +DEP_CPP_JCPRE=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jcprepct.obj" : $(SOURCE) $(DEP_CPP_JCPRE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jcsample.c" +DEP_CPP_JCSAM=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jcsample.obj" : $(SOURCE) $(DEP_CPP_JCSAM) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jctrans.c" +DEP_CPP_JCTRA=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jctrans.obj" : $(SOURCE) $(DEP_CPP_JCTRA) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdapimin.c" +DEP_CPP_JDAPI=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jdapimin.obj" : $(SOURCE) $(DEP_CPP_JDAPI) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdapistd.c" +DEP_CPP_JDAPIS=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jdapistd.obj" : $(SOURCE) $(DEP_CPP_JDAPIS) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdatadst.c" +DEP_CPP_JDATA=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + + +"$(INTDIR)\jdatadst.obj" : $(SOURCE) $(DEP_CPP_JDATA) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdatasrc.c" +DEP_CPP_JDATAS=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jerror.h"\ + + +"$(INTDIR)\jdatasrc.obj" : $(SOURCE) $(DEP_CPP_JDATAS) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdcoefct.c" +DEP_CPP_JDCOE=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jdcoefct.obj" : $(SOURCE) $(DEP_CPP_JDCOE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdcolor.c" +DEP_CPP_JDCOL=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jdcolor.obj" : $(SOURCE) $(DEP_CPP_JDCOL) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jddctmgr.c" +DEP_CPP_JDDCT=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jdct.h"\ + + +"$(INTDIR)\jddctmgr.obj" : $(SOURCE) $(DEP_CPP_JDDCT) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdhuff.c" +DEP_CPP_JDHUF=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jdhuff.h"\ + + +"$(INTDIR)\jdhuff.obj" : $(SOURCE) $(DEP_CPP_JDHUF) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdinput.c" +DEP_CPP_JDINP=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jdinput.obj" : $(SOURCE) $(DEP_CPP_JDINP) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdmainct.c" +DEP_CPP_JDMAI=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jdmainct.obj" : $(SOURCE) $(DEP_CPP_JDMAI) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdmarker.c" +DEP_CPP_JDMAR=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jdmarker.obj" : $(SOURCE) $(DEP_CPP_JDMAR) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdmaster.c" +DEP_CPP_JDMAS=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jdmaster.obj" : $(SOURCE) $(DEP_CPP_JDMAS) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdmerge.c" +DEP_CPP_JDMER=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jdmerge.obj" : $(SOURCE) $(DEP_CPP_JDMER) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdphuff.c" +DEP_CPP_JDPHU=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jdhuff.h"\ + + +"$(INTDIR)\jdphuff.obj" : $(SOURCE) $(DEP_CPP_JDPHU) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdpostct.c" +DEP_CPP_JDPOS=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jdpostct.obj" : $(SOURCE) $(DEP_CPP_JDPOS) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdsample.c" +DEP_CPP_JDSAM=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jdsample.obj" : $(SOURCE) $(DEP_CPP_JDSAM) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jdtrans.c" +DEP_CPP_JDTRA=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jdtrans.obj" : $(SOURCE) $(DEP_CPP_JDTRA) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jerror.c" +DEP_CPP_JERRO=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jversion.h"\ + "jerror.h"\ + + +"$(INTDIR)\jerror.obj" : $(SOURCE) $(DEP_CPP_JERRO) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jfdctflt.c" +DEP_CPP_JFDCT=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jdct.h"\ + + +"$(INTDIR)\jfdctflt.obj" : $(SOURCE) $(DEP_CPP_JFDCT) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jfdctfst.c" +DEP_CPP_JFDCTF=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jdct.h"\ + + +"$(INTDIR)\jfdctfst.obj" : $(SOURCE) $(DEP_CPP_JFDCTF) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jfdctint.c" +DEP_CPP_JFDCTI=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jdct.h"\ + + +"$(INTDIR)\jfdctint.obj" : $(SOURCE) $(DEP_CPP_JFDCTI) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jidctflt.c" +DEP_CPP_JIDCT=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jdct.h"\ + + +"$(INTDIR)\jidctflt.obj" : $(SOURCE) $(DEP_CPP_JIDCT) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jidctfst.c" +DEP_CPP_JIDCTF=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jdct.h"\ + + +"$(INTDIR)\jidctfst.obj" : $(SOURCE) $(DEP_CPP_JIDCTF) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jidctint.c" +DEP_CPP_JIDCTI=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jdct.h"\ + + +"$(INTDIR)\jidctint.obj" : $(SOURCE) $(DEP_CPP_JIDCTI) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jidctred.c" +DEP_CPP_JIDCTR=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jdct.h"\ + + +"$(INTDIR)\jidctred.obj" : $(SOURCE) $(DEP_CPP_JIDCTR) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jquant1.c" +DEP_CPP_JQUAN=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jquant1.obj" : $(SOURCE) $(DEP_CPP_JQUAN) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jquant2.c" +DEP_CPP_JQUANT=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jquant2.obj" : $(SOURCE) $(DEP_CPP_JQUANT) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jutils.c" +DEP_CPP_JUTIL=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + + +"$(INTDIR)\jutils.obj" : $(SOURCE) $(DEP_CPP_JUTIL) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jmemmgr.c" +DEP_CPP_JMEMM=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jmemsys.h"\ + + +"$(INTDIR)\jmemmgr.obj" : $(SOURCE) $(DEP_CPP_JMEMM) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="jmemnobs.c" +DEP_CPP_JMEMN=\ + "jinclude.h"\ + "jconfig.h"\ + "jpeglib.h"\ + "jmorecfg.h"\ + "jpegint.h"\ + "jerror.h"\ + "jmemsys.h"\ + + +"$(INTDIR)\jmemnobs.obj" : $(SOURCE) $(DEP_CPP_JMEMN) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +# End Target +# End Project +################################################################################ + diff --git a/src/dep/src/irrlicht/jpeglib/makeproj.mac b/src/dep/src/irrlicht/jpeglib/makeproj.mac index cd466da..ed277c8 100644 --- a/src/dep/src/irrlicht/jpeglib/makeproj.mac +++ b/src/dep/src/irrlicht/jpeglib/makeproj.mac @@ -1,213 +1,213 @@ --- --- makeproj.mac --- --- This AppleScript builds Code Warrior PRO Release 2 project files for the --- libjpeg library as well as the test programs 'cjpeg', 'djpeg', 'jpegtran'. --- (We'd distribute real project files, except they're not text --- and would create maintenance headaches.) --- --- The script then compiles and links the library and the test programs. --- NOTE: if you haven't already created a 'jconfig.h' file, the script --- automatically copies 'jconfig.mac' to 'jconfig.h'. --- --- To use this script, you must have AppleScript 1.1 or later installed --- and a suitable AppleScript editor like Script Editor or Script Debugger --- (http://www.latenightsw.com). Open this file with your AppleScript --- editor and execute the "run" command to build the projects. --- --- Thanks to Dan Sears and Don Agro for this script. --- Questions about this script can be addressed to dogpark@interlog.com --- - -on run - - choose folder with prompt ">>> Select IJG source folder <<<" - set ijg_folder to result - - choose folder with prompt ">>> Select MetroWerks folder <<<" - set cw_folder to result - - -- if jconfig.h doesn't already exist, copy jconfig.mac - - tell application "Finder" - if not (exists file "jconfig.h" of ijg_folder) then - duplicate {file "jconfig.mac" of folder ijg_folder} - select file "jconfig.mac copy" of folder ijg_folder - set name of selection to "jconfig.h" - end if - end tell - - tell application "CodeWarrior IDE 2.1" - with timeout of 10000 seconds - - -- create libjpeg project - - activate - Create Project (ijg_folder as string) & "libjpeg.proj" - Set Preferences of panel "Target Settings" to {Target Name:"libjpeg"} - Set Preferences of panel "PPC Project" to {File Name:"libjpeg"} - Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} - Set Preferences of panel "PPC Project" to {Project Type:library} - Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} - Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} - Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} - Set Preferences of panel "PPC Linker" to {Generate SYM File:false} - - Add Files (ijg_folder as string) & "jcapimin.c" To Segment 1 - Add Files (ijg_folder as string) & "jcapistd.c" To Segment 1 - Add Files (ijg_folder as string) & "jctrans.c" To Segment 1 - Add Files (ijg_folder as string) & "jcparam.c" To Segment 1 - Add Files (ijg_folder as string) & "jdatadst.c" To Segment 1 - Add Files (ijg_folder as string) & "jcinit.c" To Segment 1 - Add Files (ijg_folder as string) & "jcmaster.c" To Segment 1 - Add Files (ijg_folder as string) & "jcmarker.c" To Segment 1 - Add Files (ijg_folder as string) & "jcmainct.c" To Segment 1 - Add Files (ijg_folder as string) & "jcprepct.c" To Segment 1 - Add Files (ijg_folder as string) & "jccoefct.c" To Segment 1 - Add Files (ijg_folder as string) & "jccolor.c" To Segment 1 - Add Files (ijg_folder as string) & "jcsample.c" To Segment 1 - Add Files (ijg_folder as string) & "jchuff.c" To Segment 1 - Add Files (ijg_folder as string) & "jcphuff.c" To Segment 1 - Add Files (ijg_folder as string) & "jcdctmgr.c" To Segment 1 - Add Files (ijg_folder as string) & "jfdctfst.c" To Segment 1 - Add Files (ijg_folder as string) & "jfdctflt.c" To Segment 1 - Add Files (ijg_folder as string) & "jfdctint.c" To Segment 1 - Add Files (ijg_folder as string) & "jdapimin.c" To Segment 1 - Add Files (ijg_folder as string) & "jdapistd.c" To Segment 1 - Add Files (ijg_folder as string) & "jdtrans.c" To Segment 1 - Add Files (ijg_folder as string) & "jdatasrc.c" To Segment 1 - Add Files (ijg_folder as string) & "jdmaster.c" To Segment 1 - Add Files (ijg_folder as string) & "jdinput.c" To Segment 1 - Add Files (ijg_folder as string) & "jdmarker.c" To Segment 1 - Add Files (ijg_folder as string) & "jdhuff.c" To Segment 1 - Add Files (ijg_folder as string) & "jdphuff.c" To Segment 1 - Add Files (ijg_folder as string) & "jdmainct.c" To Segment 1 - Add Files (ijg_folder as string) & "jdcoefct.c" To Segment 1 - Add Files (ijg_folder as string) & "jdpostct.c" To Segment 1 - Add Files (ijg_folder as string) & "jddctmgr.c" To Segment 1 - Add Files (ijg_folder as string) & "jidctfst.c" To Segment 1 - Add Files (ijg_folder as string) & "jidctflt.c" To Segment 1 - Add Files (ijg_folder as string) & "jidctint.c" To Segment 1 - Add Files (ijg_folder as string) & "jidctred.c" To Segment 1 - Add Files (ijg_folder as string) & "jdsample.c" To Segment 1 - Add Files (ijg_folder as string) & "jdcolor.c" To Segment 1 - Add Files (ijg_folder as string) & "jquant1.c" To Segment 1 - Add Files (ijg_folder as string) & "jquant2.c" To Segment 1 - Add Files (ijg_folder as string) & "jdmerge.c" To Segment 1 - Add Files (ijg_folder as string) & "jcomapi.c" To Segment 1 - Add Files (ijg_folder as string) & "jutils.c" To Segment 1 - Add Files (ijg_folder as string) & "jerror.c" To Segment 1 - Add Files (ijg_folder as string) & "jmemmgr.c" To Segment 1 - Add Files (ijg_folder as string) & "jmemmac.c" To Segment 1 - - -- compile and link the library - - Make Project - Close Project - - -- create cjpeg project - - activate - Create Project (ijg_folder as string) & "cjpeg.proj" - Set Preferences of panel "Target Settings" to {Target Name:"cjpeg"} - Set Preferences of panel "PPC Project" to {File Name:"cjpeg"} - Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} - Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} - Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} - Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} - Set Preferences of panel "PPC Linker" to {Generate SYM File:false} - - Add Files (ijg_folder as string) & "cjpeg.c" To Segment 1 - Add Files (ijg_folder as string) & "rdppm.c" To Segment 1 - Add Files (ijg_folder as string) & "rdgif.c" To Segment 1 - Add Files (ijg_folder as string) & "rdtarga.c" To Segment 1 - Add Files (ijg_folder as string) & "rdrle.c" To Segment 1 - Add Files (ijg_folder as string) & "rdbmp.c" To Segment 1 - Add Files (ijg_folder as string) & "rdswitch.c" To Segment 1 - Add Files (ijg_folder as string) & "cdjpeg.c" To Segment 1 - - Add Files (ijg_folder as string) & "libjpeg" To Segment 2 - - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL C.PPC.Lib" To Segment 3 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL SIOUX.PPC.Lib" To Segment 3 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.Lib" To Segment 3 - - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:InterfaceLib" To Segment 4 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:MathLib" To Segment 4 - - -- compile and link cjpeg - - Make Project - Close Project - - -- create djpeg project - - activate - Create Project (ijg_folder as string) & "djpeg.proj" - Set Preferences of panel "Target Settings" to {Target Name:"djpeg"} - Set Preferences of panel "PPC Project" to {File Name:"djpeg"} - Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} - Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} - Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} - Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} - Set Preferences of panel "PPC Linker" to {Generate SYM File:false} - - Add Files (ijg_folder as string) & "djpeg.c" To Segment 1 - Add Files (ijg_folder as string) & "wrppm.c" To Segment 1 - Add Files (ijg_folder as string) & "wrgif.c" To Segment 1 - Add Files (ijg_folder as string) & "wrtarga.c" To Segment 1 - Add Files (ijg_folder as string) & "wrrle.c" To Segment 1 - Add Files (ijg_folder as string) & "wrbmp.c" To Segment 1 - Add Files (ijg_folder as string) & "rdcolmap.c" To Segment 1 - Add Files (ijg_folder as string) & "cdjpeg.c" To Segment 1 - - Add Files (ijg_folder as string) & "libjpeg" To Segment 2 - - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL C.PPC.Lib" To Segment 3 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL SIOUX.PPC.Lib" To Segment 3 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.Lib" To Segment 3 - - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:InterfaceLib" To Segment 4 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:MathLib" To Segment 4 - - -- compile and link djpeg - - Make Project - Close Project - - -- create jpegtran project - - activate - Create Project (ijg_folder as string) & "jpegtran.proj" - Set Preferences of panel "Target Settings" to {Target Name:"jpegtran"} - Set Preferences of panel "PPC Project" to {File Name:"jpegtran"} - Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} - Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} - Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} - Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} - Set Preferences of panel "PPC Linker" to {Generate SYM File:false} - - Add Files (ijg_folder as string) & "jpegtran.c" To Segment 1 - Add Files (ijg_folder as string) & "rdswitch.c" To Segment 1 - Add Files (ijg_folder as string) & "cdjpeg.c" To Segment 1 - Add Files (ijg_folder as string) & "transupp.c" To Segment 1 - - Add Files (ijg_folder as string) & "libjpeg" To Segment 2 - - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL C.PPC.Lib" To Segment 3 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL SIOUX.PPC.Lib" To Segment 3 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.Lib" To Segment 3 - - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:InterfaceLib" To Segment 4 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:MathLib" To Segment 4 - - -- compile and link jpegtran - - Make Project - Close Project - - quit - - end timeout - end tell -end run +-- +-- makeproj.mac +-- +-- This AppleScript builds Code Warrior PRO Release 2 project files for the +-- libjpeg library as well as the test programs 'cjpeg', 'djpeg', 'jpegtran'. +-- (We'd distribute real project files, except they're not text +-- and would create maintenance headaches.) +-- +-- The script then compiles and links the library and the test programs. +-- NOTE: if you haven't already created a 'jconfig.h' file, the script +-- automatically copies 'jconfig.mac' to 'jconfig.h'. +-- +-- To use this script, you must have AppleScript 1.1 or later installed +-- and a suitable AppleScript editor like Script Editor or Script Debugger +-- (http://www.latenightsw.com). Open this file with your AppleScript +-- editor and execute the "run" command to build the projects. +-- +-- Thanks to Dan Sears and Don Agro for this script. +-- Questions about this script can be addressed to dogpark@interlog.com +-- + +on run + + choose folder with prompt ">>> Select IJG source folder <<<" + set ijg_folder to result + + choose folder with prompt ">>> Select MetroWerks folder <<<" + set cw_folder to result + + -- if jconfig.h doesn't already exist, copy jconfig.mac + + tell application "Finder" + if not (exists file "jconfig.h" of ijg_folder) then + duplicate {file "jconfig.mac" of folder ijg_folder} + select file "jconfig.mac copy" of folder ijg_folder + set name of selection to "jconfig.h" + end if + end tell + + tell application "CodeWarrior IDE 2.1" + with timeout of 10000 seconds + + -- create libjpeg project + + activate + Create Project (ijg_folder as string) & "libjpeg.proj" + Set Preferences of panel "Target Settings" to {Target Name:"libjpeg"} + Set Preferences of panel "PPC Project" to {File Name:"libjpeg"} + Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} + Set Preferences of panel "PPC Project" to {Project Type:library} + Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} + Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} + Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} + Set Preferences of panel "PPC Linker" to {Generate SYM File:false} + + Add Files (ijg_folder as string) & "jcapimin.c" To Segment 1 + Add Files (ijg_folder as string) & "jcapistd.c" To Segment 1 + Add Files (ijg_folder as string) & "jctrans.c" To Segment 1 + Add Files (ijg_folder as string) & "jcparam.c" To Segment 1 + Add Files (ijg_folder as string) & "jdatadst.c" To Segment 1 + Add Files (ijg_folder as string) & "jcinit.c" To Segment 1 + Add Files (ijg_folder as string) & "jcmaster.c" To Segment 1 + Add Files (ijg_folder as string) & "jcmarker.c" To Segment 1 + Add Files (ijg_folder as string) & "jcmainct.c" To Segment 1 + Add Files (ijg_folder as string) & "jcprepct.c" To Segment 1 + Add Files (ijg_folder as string) & "jccoefct.c" To Segment 1 + Add Files (ijg_folder as string) & "jccolor.c" To Segment 1 + Add Files (ijg_folder as string) & "jcsample.c" To Segment 1 + Add Files (ijg_folder as string) & "jchuff.c" To Segment 1 + Add Files (ijg_folder as string) & "jcphuff.c" To Segment 1 + Add Files (ijg_folder as string) & "jcdctmgr.c" To Segment 1 + Add Files (ijg_folder as string) & "jfdctfst.c" To Segment 1 + Add Files (ijg_folder as string) & "jfdctflt.c" To Segment 1 + Add Files (ijg_folder as string) & "jfdctint.c" To Segment 1 + Add Files (ijg_folder as string) & "jdapimin.c" To Segment 1 + Add Files (ijg_folder as string) & "jdapistd.c" To Segment 1 + Add Files (ijg_folder as string) & "jdtrans.c" To Segment 1 + Add Files (ijg_folder as string) & "jdatasrc.c" To Segment 1 + Add Files (ijg_folder as string) & "jdmaster.c" To Segment 1 + Add Files (ijg_folder as string) & "jdinput.c" To Segment 1 + Add Files (ijg_folder as string) & "jdmarker.c" To Segment 1 + Add Files (ijg_folder as string) & "jdhuff.c" To Segment 1 + Add Files (ijg_folder as string) & "jdphuff.c" To Segment 1 + Add Files (ijg_folder as string) & "jdmainct.c" To Segment 1 + Add Files (ijg_folder as string) & "jdcoefct.c" To Segment 1 + Add Files (ijg_folder as string) & "jdpostct.c" To Segment 1 + Add Files (ijg_folder as string) & "jddctmgr.c" To Segment 1 + Add Files (ijg_folder as string) & "jidctfst.c" To Segment 1 + Add Files (ijg_folder as string) & "jidctflt.c" To Segment 1 + Add Files (ijg_folder as string) & "jidctint.c" To Segment 1 + Add Files (ijg_folder as string) & "jidctred.c" To Segment 1 + Add Files (ijg_folder as string) & "jdsample.c" To Segment 1 + Add Files (ijg_folder as string) & "jdcolor.c" To Segment 1 + Add Files (ijg_folder as string) & "jquant1.c" To Segment 1 + Add Files (ijg_folder as string) & "jquant2.c" To Segment 1 + Add Files (ijg_folder as string) & "jdmerge.c" To Segment 1 + Add Files (ijg_folder as string) & "jcomapi.c" To Segment 1 + Add Files (ijg_folder as string) & "jutils.c" To Segment 1 + Add Files (ijg_folder as string) & "jerror.c" To Segment 1 + Add Files (ijg_folder as string) & "jmemmgr.c" To Segment 1 + Add Files (ijg_folder as string) & "jmemmac.c" To Segment 1 + + -- compile and link the library + + Make Project + Close Project + + -- create cjpeg project + + activate + Create Project (ijg_folder as string) & "cjpeg.proj" + Set Preferences of panel "Target Settings" to {Target Name:"cjpeg"} + Set Preferences of panel "PPC Project" to {File Name:"cjpeg"} + Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} + Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} + Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} + Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} + Set Preferences of panel "PPC Linker" to {Generate SYM File:false} + + Add Files (ijg_folder as string) & "cjpeg.c" To Segment 1 + Add Files (ijg_folder as string) & "rdppm.c" To Segment 1 + Add Files (ijg_folder as string) & "rdgif.c" To Segment 1 + Add Files (ijg_folder as string) & "rdtarga.c" To Segment 1 + Add Files (ijg_folder as string) & "rdrle.c" To Segment 1 + Add Files (ijg_folder as string) & "rdbmp.c" To Segment 1 + Add Files (ijg_folder as string) & "rdswitch.c" To Segment 1 + Add Files (ijg_folder as string) & "cdjpeg.c" To Segment 1 + + Add Files (ijg_folder as string) & "libjpeg" To Segment 2 + + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL C.PPC.Lib" To Segment 3 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL SIOUX.PPC.Lib" To Segment 3 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.Lib" To Segment 3 + + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:InterfaceLib" To Segment 4 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:MathLib" To Segment 4 + + -- compile and link cjpeg + + Make Project + Close Project + + -- create djpeg project + + activate + Create Project (ijg_folder as string) & "djpeg.proj" + Set Preferences of panel "Target Settings" to {Target Name:"djpeg"} + Set Preferences of panel "PPC Project" to {File Name:"djpeg"} + Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} + Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} + Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} + Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} + Set Preferences of panel "PPC Linker" to {Generate SYM File:false} + + Add Files (ijg_folder as string) & "djpeg.c" To Segment 1 + Add Files (ijg_folder as string) & "wrppm.c" To Segment 1 + Add Files (ijg_folder as string) & "wrgif.c" To Segment 1 + Add Files (ijg_folder as string) & "wrtarga.c" To Segment 1 + Add Files (ijg_folder as string) & "wrrle.c" To Segment 1 + Add Files (ijg_folder as string) & "wrbmp.c" To Segment 1 + Add Files (ijg_folder as string) & "rdcolmap.c" To Segment 1 + Add Files (ijg_folder as string) & "cdjpeg.c" To Segment 1 + + Add Files (ijg_folder as string) & "libjpeg" To Segment 2 + + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL C.PPC.Lib" To Segment 3 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL SIOUX.PPC.Lib" To Segment 3 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.Lib" To Segment 3 + + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:InterfaceLib" To Segment 4 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:MathLib" To Segment 4 + + -- compile and link djpeg + + Make Project + Close Project + + -- create jpegtran project + + activate + Create Project (ijg_folder as string) & "jpegtran.proj" + Set Preferences of panel "Target Settings" to {Target Name:"jpegtran"} + Set Preferences of panel "PPC Project" to {File Name:"jpegtran"} + Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} + Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} + Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} + Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} + Set Preferences of panel "PPC Linker" to {Generate SYM File:false} + + Add Files (ijg_folder as string) & "jpegtran.c" To Segment 1 + Add Files (ijg_folder as string) & "rdswitch.c" To Segment 1 + Add Files (ijg_folder as string) & "cdjpeg.c" To Segment 1 + Add Files (ijg_folder as string) & "transupp.c" To Segment 1 + + Add Files (ijg_folder as string) & "libjpeg" To Segment 2 + + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL C.PPC.Lib" To Segment 3 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL SIOUX.PPC.Lib" To Segment 3 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.Lib" To Segment 3 + + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:InterfaceLib" To Segment 4 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:MathLib" To Segment 4 + + -- compile and link jpegtran + + Make Project + Close Project + + quit + + end timeout + end tell +end run diff --git a/src/dep/src/irrlicht/jpeglib/makljpeg.st b/src/dep/src/irrlicht/jpeglib/makljpeg.st index 96bfb65..813493e 100644 --- a/src/dep/src/irrlicht/jpeglib/makljpeg.st +++ b/src/dep/src/irrlicht/jpeglib/makljpeg.st @@ -1,70 +1,70 @@ -; Project file for Independent JPEG Group's software -; -; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. -; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de), -; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de), -; and Guido Vollbeding (guivol@esc.de). -; -; To use this file, rename it to libjpeg.prj. -; Read installation instructions before trying to make the program! -; -; -; * * * Output file * * * -libjpeg.lib -; -; * * * COMPILER OPTIONS * * * -.C[-P] ; absolute calls -.C[-M] ; and no string merging, folks -.C[-w-cln] ; no "constant is long" warnings -.C[-w-par] ; no "parameter xxxx unused" -.C[-w-rch] ; no "unreachable code" -.C[-wsig] ; warn if significant digits may be lost -.L[-J] ; link new Obj-format (so we get a library) -= -; * * * * List of modules * * * * -jcapimin.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcapistd.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jccoefct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jccolor.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcdctmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jchuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jchuff.h) -jcinit.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcmainct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcmarker.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcmaster.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcomapi.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcparam.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcphuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jchuff.h) -jcprepct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcsample.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jctrans.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdapimin.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdapistd.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdatadst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h) -jdatasrc.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h) -jdcoefct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdcolor.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jddctmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jdhuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdhuff.h) -jdinput.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdmainct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdmarker.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdmaster.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdmerge.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdphuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdhuff.h) -jdpostct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdsample.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdtrans.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jerror.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jversion.h,jerror.h) -jfdctflt.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jfdctfst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jfdctint.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jidctflt.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jidctfst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jidctint.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jidctred.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jquant1.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jquant2.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jutils.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jmemmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jmemsys.h) -jmemansi.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jmemsys.h) +; Project file for Independent JPEG Group's software +; +; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. +; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de), +; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de), +; and Guido Vollbeding (guivol@esc.de). +; +; To use this file, rename it to libjpeg.prj. +; Read installation instructions before trying to make the program! +; +; +; * * * Output file * * * +libjpeg.lib +; +; * * * COMPILER OPTIONS * * * +.C[-P] ; absolute calls +.C[-M] ; and no string merging, folks +.C[-w-cln] ; no "constant is long" warnings +.C[-w-par] ; no "parameter xxxx unused" +.C[-w-rch] ; no "unreachable code" +.C[-wsig] ; warn if significant digits may be lost +.L[-J] ; link new Obj-format (so we get a library) += +; * * * * List of modules * * * * +jcapimin.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcapistd.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jccoefct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jccolor.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcdctmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jchuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jchuff.h) +jcinit.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcmainct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcmarker.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcmaster.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcomapi.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcparam.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcphuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jchuff.h) +jcprepct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcsample.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jctrans.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdapimin.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdapistd.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdatadst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h) +jdatasrc.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h) +jdcoefct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdcolor.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jddctmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jdhuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdhuff.h) +jdinput.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdmainct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdmarker.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdmaster.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdmerge.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdphuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdhuff.h) +jdpostct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdsample.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdtrans.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jerror.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jversion.h,jerror.h) +jfdctflt.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jfdctfst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jfdctint.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jidctflt.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jidctfst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jidctint.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jidctred.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jquant1.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jquant2.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jutils.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jmemmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jmemsys.h) +jmemansi.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jmemsys.h) diff --git a/src/dep/src/irrlicht/jpeglib/maktjpeg.st b/src/dep/src/irrlicht/jpeglib/maktjpeg.st index ced1951..31f4d16 100644 --- a/src/dep/src/irrlicht/jpeglib/maktjpeg.st +++ b/src/dep/src/irrlicht/jpeglib/maktjpeg.st @@ -1,32 +1,32 @@ -; Project file for Independent JPEG Group's software -; -; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. -; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de), -; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de), -; and Guido Vollbeding (guivol@esc.de). -; -; To use this file, rename it to jpegtran.prj. -; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." -; Read installation instructions before trying to make the program! -; -; -; * * * Output file * * * -jpegtran.ttp -; -; * * * COMPILER OPTIONS * * * -.C[-P] ; absolute calls -.C[-M] ; and no string merging, folks -.C[-w-cln] ; no "constant is long" warnings -.C[-w-par] ; no "parameter xxxx unused" -.C[-w-rch] ; no "unreachable code" -.C[-wsig] ; warn if significant digits may be lost -= -; * * * * List of modules * * * * -pcstart.o -jpegtran.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,transupp.h,jversion.h) -cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdswitch.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -transupp.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,transupp.h) -libjpeg.lib ; built by libjpeg.prj -pcstdlib.lib ; standard library -pcextlib.lib ; extended library +; Project file for Independent JPEG Group's software +; +; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. +; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de), +; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de), +; and Guido Vollbeding (guivol@esc.de). +; +; To use this file, rename it to jpegtran.prj. +; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." +; Read installation instructions before trying to make the program! +; +; +; * * * Output file * * * +jpegtran.ttp +; +; * * * COMPILER OPTIONS * * * +.C[-P] ; absolute calls +.C[-M] ; and no string merging, folks +.C[-w-cln] ; no "constant is long" warnings +.C[-w-par] ; no "parameter xxxx unused" +.C[-w-rch] ; no "unreachable code" +.C[-wsig] ; warn if significant digits may be lost += +; * * * * List of modules * * * * +pcstart.o +jpegtran.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,transupp.h,jversion.h) +cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdswitch.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +transupp.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,transupp.h) +libjpeg.lib ; built by libjpeg.prj +pcstdlib.lib ; standard library +pcextlib.lib ; extended library diff --git a/src/dep/src/irrlicht/jpeglib/makvms.opt b/src/dep/src/irrlicht/jpeglib/makvms.opt index 26db714..675e8fe 100644 --- a/src/dep/src/irrlicht/jpeglib/makvms.opt +++ b/src/dep/src/irrlicht/jpeglib/makvms.opt @@ -1,4 +1,4 @@ -! A pointer to the VAX/VMS C Run-Time Shareable Library. -! This file is needed by makefile.mms and makefile.vms, -! but only for the older VAX C compiler. DEC C does not need it. -Sys$Library:VAXCRTL.EXE /Share +! A pointer to the VAX/VMS C Run-Time Shareable Library. +! This file is needed by makefile.mms and makefile.vms, +! but only for the older VAX C compiler. DEC C does not need it. +Sys$Library:VAXCRTL.EXE /Share diff --git a/src/dep/src/irrlicht/jpeglib/rdbmp.c b/src/dep/src/irrlicht/jpeglib/rdbmp.c index 4f61bcf..b05fe2a 100644 --- a/src/dep/src/irrlicht/jpeglib/rdbmp.c +++ b/src/dep/src/irrlicht/jpeglib/rdbmp.c @@ -1,439 +1,439 @@ -/* - * rdbmp.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in Microsoft "BMP" - * format (MS Windows 3.x, OS/2 1.x, and OS/2 2.x flavors). - * Currently, only 8-bit and 24-bit images are supported, not 1-bit or - * 4-bit (feeding such low-depth images into JPEG would be silly anyway). - * Also, we don't support RLE-compressed files. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed BMP format). - * - * This code contributed by James Arthur Boucher. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef BMP_SUPPORTED - - -/* Macros to deal with unsigned chars as efficiently as compiler allows */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char U_CHAR; -#define UCH(x) ((int) (x)) -#else /* !HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char U_CHAR; -#define UCH(x) ((int) (x)) -#else -typedef char U_CHAR; -#define UCH(x) ((int) (x) & 0xFF) -#endif -#endif /* HAVE_UNSIGNED_CHAR */ - - -#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) - - -/* Private version of data source object */ - -typedef struct _bmp_source_struct * bmp_source_ptr; - -typedef struct _bmp_source_struct { - struct cjpeg_source_struct pub; /* public fields */ - - j_compress_ptr cinfo; /* back link saves passing separate parm */ - - JSAMPARRAY colormap; /* BMP colormap (converted to my format) */ - - jvirt_sarray_ptr whole_image; /* Needed to reverse row order */ - JDIMENSION source_row; /* Current source row number */ - JDIMENSION row_width; /* Physical width of scanlines in file */ - - int bits_per_pixel; /* remembers 8- or 24-bit format */ -} bmp_source_struct; - - -LOCAL(int) -read_byte (bmp_source_ptr sinfo) -/* Read next byte from BMP file */ -{ - register FILE *infile = sinfo->pub.input_file; - register int c; - - if ((c = getc(infile)) == EOF) - ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); - return c; -} - - -LOCAL(void) -read_colormap (bmp_source_ptr sinfo, int cmaplen, int mapentrysize) -/* Read the colormap from a BMP file */ -{ - int i; - - switch (mapentrysize) { - case 3: - /* BGR format (occurs in OS/2 files) */ - for (i = 0; i < cmaplen; i++) { - sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); - } - break; - case 4: - /* BGR0 format (occurs in MS Windows files) */ - for (i = 0; i < cmaplen; i++) { - sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); - (void) read_byte(sinfo); - } - break; - default: - ERREXIT(sinfo->cinfo, JERR_BMP_BADCMAP); - break; - } -} - - -/* - * Read one row of pixels. - * The image has been read into the whole_image array, but is otherwise - * unprocessed. We must read it out in top-to-bottom row order, and if - * it is an 8-bit image, we must expand colormapped pixels to 24bit format. - */ - -METHODDEF(JDIMENSION) -get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 8-bit colormap indexes */ -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - register JSAMPARRAY colormap = source->colormap; - JSAMPARRAY image_ptr; - register int t; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - - /* Fetch next row from virtual array */ - source->source_row--; - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, - source->source_row, (JDIMENSION) 1, FALSE); - - /* Expand the colormap indexes to real data */ - inptr = image_ptr[0]; - outptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - t = GETJSAMPLE(*inptr++); - *outptr++ = colormap[0][t]; /* can omit GETJSAMPLE() safely */ - *outptr++ = colormap[1][t]; - *outptr++ = colormap[2][t]; - } - - return 1; -} - - -METHODDEF(JDIMENSION) -get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 24-bit pixels */ -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - JSAMPARRAY image_ptr; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - - /* Fetch next row from virtual array */ - source->source_row--; - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, - source->source_row, (JDIMENSION) 1, FALSE); - - /* Transfer data. Note source values are in BGR order - * (even though Microsoft's own documents say the opposite). - */ - inptr = image_ptr[0]; - outptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ - outptr[1] = *inptr++; - outptr[0] = *inptr++; - outptr += 3; - } - - return 1; -} - - -/* - * This method loads the image into whole_image during the first call on - * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call - * get_8bit_row or get_24bit_row on subsequent calls. - */ - -METHODDEF(JDIMENSION) -preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - register FILE *infile = source->pub.input_file; - register int c; - register JSAMPROW out_ptr; - JSAMPARRAY image_ptr; - JDIMENSION row, col; - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - - /* Read the data into a virtual array in input-file row order. */ - for (row = 0; row < cinfo->image_height; row++) { - if (progress != NULL) { - progress->pub.pass_counter = (long) row; - progress->pub.pass_limit = (long) cinfo->image_height; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, - row, (JDIMENSION) 1, TRUE); - out_ptr = image_ptr[0]; - for (col = source->row_width; col > 0; col--) { - /* inline copy of read_byte() for speed */ - if ((c = getc(infile)) == EOF) - ERREXIT(cinfo, JERR_INPUT_EOF); - *out_ptr++ = (JSAMPLE) c; - } - } - if (progress != NULL) - progress->completed_extra_passes++; - - /* Set up to read from the virtual array in top-to-bottom order */ - switch (source->bits_per_pixel) { - case 8: - source->pub.get_pixel_rows = get_8bit_row; - break; - case 24: - source->pub.get_pixel_rows = get_24bit_row; - break; - default: - ERREXIT(cinfo, JERR_BMP_BADDEPTH); - } - source->source_row = cinfo->image_height; - - /* And read the first row */ - return (*source->pub.get_pixel_rows) (cinfo, sinfo); -} - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - U_CHAR bmpfileheader[14]; - U_CHAR bmpinfoheader[64]; -#define GET_2B(array,offset) ((unsigned int) UCH(array[offset]) + \ - (((unsigned int) UCH(array[offset+1])) << 8)) -#define GET_4B(array,offset) ((INT32) UCH(array[offset]) + \ - (((INT32) UCH(array[offset+1])) << 8) + \ - (((INT32) UCH(array[offset+2])) << 16) + \ - (((INT32) UCH(array[offset+3])) << 24)) - INT32 bfOffBits; - INT32 headerSize; - INT32 biWidth = 0; /* initialize to avoid compiler warning */ - INT32 biHeight = 0; - unsigned int biPlanes; - INT32 biCompression; - INT32 biXPelsPerMeter,biYPelsPerMeter; - INT32 biClrUsed = 0; - int mapentrysize = 0; /* 0 indicates no colormap */ - INT32 bPad; - JDIMENSION row_width; - - /* Read and verify the bitmap file header */ - if (! ReadOK(source->pub.input_file, bmpfileheader, 14)) - ERREXIT(cinfo, JERR_INPUT_EOF); - if (GET_2B(bmpfileheader,0) != 0x4D42) /* 'BM' */ - ERREXIT(cinfo, JERR_BMP_NOT); - bfOffBits = (INT32) GET_4B(bmpfileheader,10); - /* We ignore the remaining fileheader fields */ - - /* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows), - * or 64 bytes (OS/2 2.x). Check the first 4 bytes to find out which. - */ - if (! ReadOK(source->pub.input_file, bmpinfoheader, 4)) - ERREXIT(cinfo, JERR_INPUT_EOF); - headerSize = (INT32) GET_4B(bmpinfoheader,0); - if (headerSize < 12 || headerSize > 64) - ERREXIT(cinfo, JERR_BMP_BADHEADER); - if (! ReadOK(source->pub.input_file, bmpinfoheader+4, headerSize-4)) - ERREXIT(cinfo, JERR_INPUT_EOF); - - switch ((int) headerSize) { - case 12: - /* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */ - biWidth = (INT32) GET_2B(bmpinfoheader,4); - biHeight = (INT32) GET_2B(bmpinfoheader,6); - biPlanes = GET_2B(bmpinfoheader,8); - source->bits_per_pixel = (int) GET_2B(bmpinfoheader,10); - - switch (source->bits_per_pixel) { - case 8: /* colormapped image */ - mapentrysize = 3; /* OS/2 uses RGBTRIPLE colormap */ - TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, (int) biWidth, (int) biHeight); - break; - case 24: /* RGB image */ - TRACEMS2(cinfo, 1, JTRC_BMP_OS2, (int) biWidth, (int) biHeight); - break; - default: - ERREXIT(cinfo, JERR_BMP_BADDEPTH); - break; - } - if (biPlanes != 1) - ERREXIT(cinfo, JERR_BMP_BADPLANES); - break; - case 40: - case 64: - /* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */ - /* or OS/2 2.x header, which has additional fields that we ignore */ - biWidth = GET_4B(bmpinfoheader,4); - biHeight = GET_4B(bmpinfoheader,8); - biPlanes = GET_2B(bmpinfoheader,12); - source->bits_per_pixel = (int) GET_2B(bmpinfoheader,14); - biCompression = GET_4B(bmpinfoheader,16); - biXPelsPerMeter = GET_4B(bmpinfoheader,24); - biYPelsPerMeter = GET_4B(bmpinfoheader,28); - biClrUsed = GET_4B(bmpinfoheader,32); - /* biSizeImage, biClrImportant fields are ignored */ - - switch (source->bits_per_pixel) { - case 8: /* colormapped image */ - mapentrysize = 4; /* Windows uses RGBQUAD colormap */ - TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, (int) biWidth, (int) biHeight); - break; - case 24: /* RGB image */ - TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight); - break; - default: - ERREXIT(cinfo, JERR_BMP_BADDEPTH); - break; - } - if (biPlanes != 1) - ERREXIT(cinfo, JERR_BMP_BADPLANES); - if (biCompression != 0) - ERREXIT(cinfo, JERR_BMP_COMPRESSED); - - if (biXPelsPerMeter > 0 && biYPelsPerMeter > 0) { - /* Set JFIF density parameters from the BMP data */ - cinfo->X_density = (UINT16) (biXPelsPerMeter/100); /* 100 cm per meter */ - cinfo->Y_density = (UINT16) (biYPelsPerMeter/100); - cinfo->density_unit = 2; /* dots/cm */ - } - break; - default: - ERREXIT(cinfo, JERR_BMP_BADHEADER); - break; - } - - /* Compute distance to bitmap data --- will adjust for colormap below */ - bPad = bfOffBits - (headerSize + 14); - - /* Read the colormap, if any */ - if (mapentrysize > 0) { - if (biClrUsed <= 0) - biClrUsed = 256; /* assume it's 256 */ - else if (biClrUsed > 256) - ERREXIT(cinfo, JERR_BMP_BADCMAP); - /* Allocate space to store the colormap */ - source->colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) biClrUsed, (JDIMENSION) 3); - /* and read it from the file */ - read_colormap(source, (int) biClrUsed, mapentrysize); - /* account for size of colormap */ - bPad -= biClrUsed * mapentrysize; - } - - /* Skip any remaining pad bytes */ - if (bPad < 0) /* incorrect bfOffBits value? */ - ERREXIT(cinfo, JERR_BMP_BADHEADER); - while (--bPad >= 0) { - (void) read_byte(source); - } - - /* Compute row width in file, including padding to 4-byte boundary */ - if (source->bits_per_pixel == 24) - row_width = (JDIMENSION) (biWidth * 3); - else - row_width = (JDIMENSION) biWidth; - while ((row_width & 3) != 0) row_width++; - source->row_width = row_width; - - /* Allocate space for inversion array, prepare for preload pass */ - source->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - row_width, (JDIMENSION) biHeight, (JDIMENSION) 1); - source->pub.get_pixel_rows = preload_image; - if (cinfo->progress != NULL) { - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - progress->total_extra_passes++; /* count file input as separate pass */ - } - - /* Allocate one-row buffer for returned data */ - source->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (biWidth * 3), (JDIMENSION) 1); - source->pub.buffer_height = 1; - - cinfo->in_color_space = JCS_RGB; - cinfo->input_components = 3; - cinfo->data_precision = 8; - cinfo->image_width = (JDIMENSION) biWidth; - cinfo->image_height = (JDIMENSION) biHeight; -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for BMP format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_bmp (j_compress_ptr cinfo) -{ - bmp_source_ptr source; - - /* Create module interface object */ - source = (bmp_source_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(bmp_source_struct)); - source->cinfo = cinfo; /* make back link for subroutines */ - /* Fill in method ptrs, except get_pixel_rows which start_input sets */ - source->pub.start_input = start_input_bmp; - source->pub.finish_input = finish_input_bmp; - - return (cjpeg_source_ptr) source; -} - -#endif /* BMP_SUPPORTED */ +/* + * rdbmp.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to read input images in Microsoft "BMP" + * format (MS Windows 3.x, OS/2 1.x, and OS/2 2.x flavors). + * Currently, only 8-bit and 24-bit images are supported, not 1-bit or + * 4-bit (feeding such low-depth images into JPEG would be silly anyway). + * Also, we don't support RLE-compressed files. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume input from + * an ordinary stdio stream. They further assume that reading begins + * at the start of the file; start_input may need work if the + * user interface has already read some data (e.g., to determine that + * the file is indeed BMP format). + * + * This code contributed by James Arthur Boucher. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef BMP_SUPPORTED + + +/* Macros to deal with unsigned chars as efficiently as compiler allows */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char U_CHAR; +#define UCH(x) ((int) (x)) +#else /* !HAVE_UNSIGNED_CHAR */ +#ifdef CHAR_IS_UNSIGNED +typedef char U_CHAR; +#define UCH(x) ((int) (x)) +#else +typedef char U_CHAR; +#define UCH(x) ((int) (x) & 0xFF) +#endif +#endif /* HAVE_UNSIGNED_CHAR */ + + +#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) + + +/* Private version of data source object */ + +typedef struct _bmp_source_struct * bmp_source_ptr; + +typedef struct _bmp_source_struct { + struct cjpeg_source_struct pub; /* public fields */ + + j_compress_ptr cinfo; /* back link saves passing separate parm */ + + JSAMPARRAY colormap; /* BMP colormap (converted to my format) */ + + jvirt_sarray_ptr whole_image; /* Needed to reverse row order */ + JDIMENSION source_row; /* Current source row number */ + JDIMENSION row_width; /* Physical width of scanlines in file */ + + int bits_per_pixel; /* remembers 8- or 24-bit format */ +} bmp_source_struct; + + +LOCAL(int) +read_byte (bmp_source_ptr sinfo) +/* Read next byte from BMP file */ +{ + register FILE *infile = sinfo->pub.input_file; + register int c; + + if ((c = getc(infile)) == EOF) + ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); + return c; +} + + +LOCAL(void) +read_colormap (bmp_source_ptr sinfo, int cmaplen, int mapentrysize) +/* Read the colormap from a BMP file */ +{ + int i; + + switch (mapentrysize) { + case 3: + /* BGR format (occurs in OS/2 files) */ + for (i = 0; i < cmaplen; i++) { + sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); + } + break; + case 4: + /* BGR0 format (occurs in MS Windows files) */ + for (i = 0; i < cmaplen; i++) { + sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); + (void) read_byte(sinfo); + } + break; + default: + ERREXIT(sinfo->cinfo, JERR_BMP_BADCMAP); + break; + } +} + + +/* + * Read one row of pixels. + * The image has been read into the whole_image array, but is otherwise + * unprocessed. We must read it out in top-to-bottom row order, and if + * it is an 8-bit image, we must expand colormapped pixels to 24bit format. + */ + +METHODDEF(JDIMENSION) +get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 8-bit colormap indexes */ +{ + bmp_source_ptr source = (bmp_source_ptr) sinfo; + register JSAMPARRAY colormap = source->colormap; + JSAMPARRAY image_ptr; + register int t; + register JSAMPROW inptr, outptr; + register JDIMENSION col; + + /* Fetch next row from virtual array */ + source->source_row--; + image_ptr = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->whole_image, + source->source_row, (JDIMENSION) 1, FALSE); + + /* Expand the colormap indexes to real data */ + inptr = image_ptr[0]; + outptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + t = GETJSAMPLE(*inptr++); + *outptr++ = colormap[0][t]; /* can omit GETJSAMPLE() safely */ + *outptr++ = colormap[1][t]; + *outptr++ = colormap[2][t]; + } + + return 1; +} + + +METHODDEF(JDIMENSION) +get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 24-bit pixels */ +{ + bmp_source_ptr source = (bmp_source_ptr) sinfo; + JSAMPARRAY image_ptr; + register JSAMPROW inptr, outptr; + register JDIMENSION col; + + /* Fetch next row from virtual array */ + source->source_row--; + image_ptr = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->whole_image, + source->source_row, (JDIMENSION) 1, FALSE); + + /* Transfer data. Note source values are in BGR order + * (even though Microsoft's own documents say the opposite). + */ + inptr = image_ptr[0]; + outptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ + outptr[1] = *inptr++; + outptr[0] = *inptr++; + outptr += 3; + } + + return 1; +} + + +/* + * This method loads the image into whole_image during the first call on + * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call + * get_8bit_row or get_24bit_row on subsequent calls. + */ + +METHODDEF(JDIMENSION) +preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + bmp_source_ptr source = (bmp_source_ptr) sinfo; + register FILE *infile = source->pub.input_file; + register int c; + register JSAMPROW out_ptr; + JSAMPARRAY image_ptr; + JDIMENSION row, col; + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + + /* Read the data into a virtual array in input-file row order. */ + for (row = 0; row < cinfo->image_height; row++) { + if (progress != NULL) { + progress->pub.pass_counter = (long) row; + progress->pub.pass_limit = (long) cinfo->image_height; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } + image_ptr = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->whole_image, + row, (JDIMENSION) 1, TRUE); + out_ptr = image_ptr[0]; + for (col = source->row_width; col > 0; col--) { + /* inline copy of read_byte() for speed */ + if ((c = getc(infile)) == EOF) + ERREXIT(cinfo, JERR_INPUT_EOF); + *out_ptr++ = (JSAMPLE) c; + } + } + if (progress != NULL) + progress->completed_extra_passes++; + + /* Set up to read from the virtual array in top-to-bottom order */ + switch (source->bits_per_pixel) { + case 8: + source->pub.get_pixel_rows = get_8bit_row; + break; + case 24: + source->pub.get_pixel_rows = get_24bit_row; + break; + default: + ERREXIT(cinfo, JERR_BMP_BADDEPTH); + } + source->source_row = cinfo->image_height; + + /* And read the first row */ + return (*source->pub.get_pixel_rows) (cinfo, sinfo); +} + + +/* + * Read the file header; return image size and component count. + */ + +METHODDEF(void) +start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + bmp_source_ptr source = (bmp_source_ptr) sinfo; + U_CHAR bmpfileheader[14]; + U_CHAR bmpinfoheader[64]; +#define GET_2B(array,offset) ((unsigned int) UCH(array[offset]) + \ + (((unsigned int) UCH(array[offset+1])) << 8)) +#define GET_4B(array,offset) ((INT32) UCH(array[offset]) + \ + (((INT32) UCH(array[offset+1])) << 8) + \ + (((INT32) UCH(array[offset+2])) << 16) + \ + (((INT32) UCH(array[offset+3])) << 24)) + INT32 bfOffBits; + INT32 headerSize; + INT32 biWidth = 0; /* initialize to avoid compiler warning */ + INT32 biHeight = 0; + unsigned int biPlanes; + INT32 biCompression; + INT32 biXPelsPerMeter,biYPelsPerMeter; + INT32 biClrUsed = 0; + int mapentrysize = 0; /* 0 indicates no colormap */ + INT32 bPad; + JDIMENSION row_width; + + /* Read and verify the bitmap file header */ + if (! ReadOK(source->pub.input_file, bmpfileheader, 14)) + ERREXIT(cinfo, JERR_INPUT_EOF); + if (GET_2B(bmpfileheader,0) != 0x4D42) /* 'BM' */ + ERREXIT(cinfo, JERR_BMP_NOT); + bfOffBits = (INT32) GET_4B(bmpfileheader,10); + /* We ignore the remaining fileheader fields */ + + /* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows), + * or 64 bytes (OS/2 2.x). Check the first 4 bytes to find out which. + */ + if (! ReadOK(source->pub.input_file, bmpinfoheader, 4)) + ERREXIT(cinfo, JERR_INPUT_EOF); + headerSize = (INT32) GET_4B(bmpinfoheader,0); + if (headerSize < 12 || headerSize > 64) + ERREXIT(cinfo, JERR_BMP_BADHEADER); + if (! ReadOK(source->pub.input_file, bmpinfoheader+4, headerSize-4)) + ERREXIT(cinfo, JERR_INPUT_EOF); + + switch ((int) headerSize) { + case 12: + /* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */ + biWidth = (INT32) GET_2B(bmpinfoheader,4); + biHeight = (INT32) GET_2B(bmpinfoheader,6); + biPlanes = GET_2B(bmpinfoheader,8); + source->bits_per_pixel = (int) GET_2B(bmpinfoheader,10); + + switch (source->bits_per_pixel) { + case 8: /* colormapped image */ + mapentrysize = 3; /* OS/2 uses RGBTRIPLE colormap */ + TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, (int) biWidth, (int) biHeight); + break; + case 24: /* RGB image */ + TRACEMS2(cinfo, 1, JTRC_BMP_OS2, (int) biWidth, (int) biHeight); + break; + default: + ERREXIT(cinfo, JERR_BMP_BADDEPTH); + break; + } + if (biPlanes != 1) + ERREXIT(cinfo, JERR_BMP_BADPLANES); + break; + case 40: + case 64: + /* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */ + /* or OS/2 2.x header, which has additional fields that we ignore */ + biWidth = GET_4B(bmpinfoheader,4); + biHeight = GET_4B(bmpinfoheader,8); + biPlanes = GET_2B(bmpinfoheader,12); + source->bits_per_pixel = (int) GET_2B(bmpinfoheader,14); + biCompression = GET_4B(bmpinfoheader,16); + biXPelsPerMeter = GET_4B(bmpinfoheader,24); + biYPelsPerMeter = GET_4B(bmpinfoheader,28); + biClrUsed = GET_4B(bmpinfoheader,32); + /* biSizeImage, biClrImportant fields are ignored */ + + switch (source->bits_per_pixel) { + case 8: /* colormapped image */ + mapentrysize = 4; /* Windows uses RGBQUAD colormap */ + TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, (int) biWidth, (int) biHeight); + break; + case 24: /* RGB image */ + TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight); + break; + default: + ERREXIT(cinfo, JERR_BMP_BADDEPTH); + break; + } + if (biPlanes != 1) + ERREXIT(cinfo, JERR_BMP_BADPLANES); + if (biCompression != 0) + ERREXIT(cinfo, JERR_BMP_COMPRESSED); + + if (biXPelsPerMeter > 0 && biYPelsPerMeter > 0) { + /* Set JFIF density parameters from the BMP data */ + cinfo->X_density = (UINT16) (biXPelsPerMeter/100); /* 100 cm per meter */ + cinfo->Y_density = (UINT16) (biYPelsPerMeter/100); + cinfo->density_unit = 2; /* dots/cm */ + } + break; + default: + ERREXIT(cinfo, JERR_BMP_BADHEADER); + break; + } + + /* Compute distance to bitmap data --- will adjust for colormap below */ + bPad = bfOffBits - (headerSize + 14); + + /* Read the colormap, if any */ + if (mapentrysize > 0) { + if (biClrUsed <= 0) + biClrUsed = 256; /* assume it's 256 */ + else if (biClrUsed > 256) + ERREXIT(cinfo, JERR_BMP_BADCMAP); + /* Allocate space to store the colormap */ + source->colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) biClrUsed, (JDIMENSION) 3); + /* and read it from the file */ + read_colormap(source, (int) biClrUsed, mapentrysize); + /* account for size of colormap */ + bPad -= biClrUsed * mapentrysize; + } + + /* Skip any remaining pad bytes */ + if (bPad < 0) /* incorrect bfOffBits value? */ + ERREXIT(cinfo, JERR_BMP_BADHEADER); + while (--bPad >= 0) { + (void) read_byte(source); + } + + /* Compute row width in file, including padding to 4-byte boundary */ + if (source->bits_per_pixel == 24) + row_width = (JDIMENSION) (biWidth * 3); + else + row_width = (JDIMENSION) biWidth; + while ((row_width & 3) != 0) row_width++; + source->row_width = row_width; + + /* Allocate space for inversion array, prepare for preload pass */ + source->whole_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + row_width, (JDIMENSION) biHeight, (JDIMENSION) 1); + source->pub.get_pixel_rows = preload_image; + if (cinfo->progress != NULL) { + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + progress->total_extra_passes++; /* count file input as separate pass */ + } + + /* Allocate one-row buffer for returned data */ + source->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (biWidth * 3), (JDIMENSION) 1); + source->pub.buffer_height = 1; + + cinfo->in_color_space = JCS_RGB; + cinfo->input_components = 3; + cinfo->data_precision = 8; + cinfo->image_width = (JDIMENSION) biWidth; + cinfo->image_height = (JDIMENSION) biHeight; +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + /* no work */ +} + + +/* + * The module selection routine for BMP format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_bmp (j_compress_ptr cinfo) +{ + bmp_source_ptr source; + + /* Create module interface object */ + source = (bmp_source_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(bmp_source_struct)); + source->cinfo = cinfo; /* make back link for subroutines */ + /* Fill in method ptrs, except get_pixel_rows which start_input sets */ + source->pub.start_input = start_input_bmp; + source->pub.finish_input = finish_input_bmp; + + return (cjpeg_source_ptr) source; +} + +#endif /* BMP_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/rdcolmap.c b/src/dep/src/irrlicht/jpeglib/rdcolmap.c index eebf834..42b3437 100644 --- a/src/dep/src/irrlicht/jpeglib/rdcolmap.c +++ b/src/dep/src/irrlicht/jpeglib/rdcolmap.c @@ -1,253 +1,253 @@ -/* - * rdcolmap.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file implements djpeg's "-map file" switch. It reads a source image - * and constructs a colormap to be supplied to the JPEG decompressor. - * - * Currently, these file formats are supported for the map file: - * GIF: the contents of the GIF's global colormap are used. - * PPM (either text or raw flavor): the entire file is read and - * each unique pixel value is entered in the map. - * Note that reading a large PPM file will be horrendously slow. - * Typically, a PPM-format map file should contain just one pixel - * of each desired color. Such a file can be extracted from an - * ordinary image PPM file with ppmtomap(1). - * - * Rescaling a PPM that has a maxval unequal to MAXJSAMPLE is not - * currently implemented. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ - -/* Portions of this code are based on the PBMPLUS library, which is: -** -** Copyright (C) 1988 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose and without fee is hereby granted, provided -** that the above copyright notice appear in all copies and that both that -** copyright notice and this permission notice appear in supporting -** documentation. This software is provided "as is" without express or -** implied warranty. -*/ - - -/* - * Add a (potentially) new color to the color map. - */ - -LOCAL(void) -add_map_entry (j_decompress_ptr cinfo, int R, int G, int B) -{ - JSAMPROW colormap0 = cinfo->colormap[0]; - JSAMPROW colormap1 = cinfo->colormap[1]; - JSAMPROW colormap2 = cinfo->colormap[2]; - int ncolors = cinfo->actual_number_of_colors; - int index; - - /* Check for duplicate color. */ - for (index = 0; index < ncolors; index++) { - if (GETJSAMPLE(colormap0[index]) == R && - GETJSAMPLE(colormap1[index]) == G && - GETJSAMPLE(colormap2[index]) == B) - return; /* color is already in map */ - } - - /* Check for map overflow. */ - if (ncolors >= (MAXJSAMPLE+1)) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, (MAXJSAMPLE+1)); - - /* OK, add color to map. */ - colormap0[ncolors] = (JSAMPLE) R; - colormap1[ncolors] = (JSAMPLE) G; - colormap2[ncolors] = (JSAMPLE) B; - cinfo->actual_number_of_colors++; -} - - -/* - * Extract color map from a GIF file. - */ - -LOCAL(void) -read_gif_map (j_decompress_ptr cinfo, FILE * infile) -{ - int header[13]; - int i, colormaplen; - int R, G, B; - - /* Initial 'G' has already been read by read_color_map */ - /* Read the rest of the GIF header and logical screen descriptor */ - for (i = 1; i < 13; i++) { - if ((header[i] = getc(infile)) == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - } - - /* Verify GIF Header */ - if (header[1] != 'I' || header[2] != 'F') - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - /* There must be a global color map. */ - if ((header[10] & 0x80) == 0) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - /* OK, fetch it. */ - colormaplen = 2 << (header[10] & 0x07); - - for (i = 0; i < colormaplen; i++) { - R = getc(infile); - G = getc(infile); - B = getc(infile); - if (R == EOF || G == EOF || B == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - add_map_entry(cinfo, - R << (BITS_IN_JSAMPLE-8), - G << (BITS_IN_JSAMPLE-8), - B << (BITS_IN_JSAMPLE-8)); - } -} - - -/* Support routines for reading PPM */ - - -LOCAL(int) -pbm_getc (FILE * infile) -/* Read next char, skipping over any comments */ -/* A comment/newline sequence is returned as a newline */ -{ - register int ch; - - ch = getc(infile); - if (ch == '#') { - do { - ch = getc(infile); - } while (ch != '\n' && ch != EOF); - } - return ch; -} - - -LOCAL(unsigned int) -read_pbm_integer (j_decompress_ptr cinfo, FILE * infile) -/* Read an unsigned decimal integer from the PPM file */ -/* Swallows one trailing character after the integer */ -/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ -/* This should not be a problem in practice. */ -{ - register int ch; - register unsigned int val; - - /* Skip any leading whitespace */ - do { - ch = pbm_getc(infile); - if (ch == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); - - if (ch < '0' || ch > '9') - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - val = ch - '0'; - while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { - val *= 10; - val += ch - '0'; - } - return val; -} - - -/* - * Extract color map from a PPM file. - */ - -LOCAL(void) -read_ppm_map (j_decompress_ptr cinfo, FILE * infile) -{ - int c; - unsigned int w, h, maxval, row, col; - int R, G, B; - - /* Initial 'P' has already been read by read_color_map */ - c = getc(infile); /* save format discriminator for a sec */ - - /* while we fetch the remaining header info */ - w = read_pbm_integer(cinfo, infile); - h = read_pbm_integer(cinfo, infile); - maxval = read_pbm_integer(cinfo, infile); - - if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - /* For now, we don't support rescaling from an unusual maxval. */ - if (maxval != (unsigned int) MAXJSAMPLE) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - switch (c) { - case '3': /* it's a text-format PPM file */ - for (row = 0; row < h; row++) { - for (col = 0; col < w; col++) { - R = read_pbm_integer(cinfo, infile); - G = read_pbm_integer(cinfo, infile); - B = read_pbm_integer(cinfo, infile); - add_map_entry(cinfo, R, G, B); - } - } - break; - - case '6': /* it's a raw-format PPM file */ - for (row = 0; row < h; row++) { - for (col = 0; col < w; col++) { - R = getc(infile); - G = getc(infile); - B = getc(infile); - if (R == EOF || G == EOF || B == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - add_map_entry(cinfo, R, G, B); - } - } - break; - - default: - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - break; - } -} - - -/* - * Main entry point from djpeg.c. - * Input: opened input file (from file name argument on command line). - * Output: colormap and actual_number_of_colors fields are set in cinfo. - */ - -GLOBAL(void) -read_color_map (j_decompress_ptr cinfo, FILE * infile) -{ - /* Allocate space for a color map of maximum supported size. */ - cinfo->colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (MAXJSAMPLE+1), (JDIMENSION) 3); - cinfo->actual_number_of_colors = 0; /* initialize map to empty */ - - /* Read first byte to determine file format */ - switch (getc(infile)) { - case 'G': - read_gif_map(cinfo, infile); - break; - case 'P': - read_ppm_map(cinfo, infile); - break; - default: - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - break; - } -} - -#endif /* QUANT_2PASS_SUPPORTED */ +/* + * rdcolmap.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file implements djpeg's "-map file" switch. It reads a source image + * and constructs a colormap to be supplied to the JPEG decompressor. + * + * Currently, these file formats are supported for the map file: + * GIF: the contents of the GIF's global colormap are used. + * PPM (either text or raw flavor): the entire file is read and + * each unique pixel value is entered in the map. + * Note that reading a large PPM file will be horrendously slow. + * Typically, a PPM-format map file should contain just one pixel + * of each desired color. Such a file can be extracted from an + * ordinary image PPM file with ppmtomap(1). + * + * Rescaling a PPM that has a maxval unequal to MAXJSAMPLE is not + * currently implemented. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ + +/* Portions of this code are based on the PBMPLUS library, which is: +** +** Copyright (C) 1988 by Jef Poskanzer. +** +** Permission to use, copy, modify, and distribute this software and its +** documentation for any purpose and without fee is hereby granted, provided +** that the above copyright notice appear in all copies and that both that +** copyright notice and this permission notice appear in supporting +** documentation. This software is provided "as is" without express or +** implied warranty. +*/ + + +/* + * Add a (potentially) new color to the color map. + */ + +LOCAL(void) +add_map_entry (j_decompress_ptr cinfo, int R, int G, int B) +{ + JSAMPROW colormap0 = cinfo->colormap[0]; + JSAMPROW colormap1 = cinfo->colormap[1]; + JSAMPROW colormap2 = cinfo->colormap[2]; + int ncolors = cinfo->actual_number_of_colors; + int index; + + /* Check for duplicate color. */ + for (index = 0; index < ncolors; index++) { + if (GETJSAMPLE(colormap0[index]) == R && + GETJSAMPLE(colormap1[index]) == G && + GETJSAMPLE(colormap2[index]) == B) + return; /* color is already in map */ + } + + /* Check for map overflow. */ + if (ncolors >= (MAXJSAMPLE+1)) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, (MAXJSAMPLE+1)); + + /* OK, add color to map. */ + colormap0[ncolors] = (JSAMPLE) R; + colormap1[ncolors] = (JSAMPLE) G; + colormap2[ncolors] = (JSAMPLE) B; + cinfo->actual_number_of_colors++; +} + + +/* + * Extract color map from a GIF file. + */ + +LOCAL(void) +read_gif_map (j_decompress_ptr cinfo, FILE * infile) +{ + int header[13]; + int i, colormaplen; + int R, G, B; + + /* Initial 'G' has already been read by read_color_map */ + /* Read the rest of the GIF header and logical screen descriptor */ + for (i = 1; i < 13; i++) { + if ((header[i] = getc(infile)) == EOF) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + } + + /* Verify GIF Header */ + if (header[1] != 'I' || header[2] != 'F') + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + /* There must be a global color map. */ + if ((header[10] & 0x80) == 0) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + /* OK, fetch it. */ + colormaplen = 2 << (header[10] & 0x07); + + for (i = 0; i < colormaplen; i++) { + R = getc(infile); + G = getc(infile); + B = getc(infile); + if (R == EOF || G == EOF || B == EOF) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + add_map_entry(cinfo, + R << (BITS_IN_JSAMPLE-8), + G << (BITS_IN_JSAMPLE-8), + B << (BITS_IN_JSAMPLE-8)); + } +} + + +/* Support routines for reading PPM */ + + +LOCAL(int) +pbm_getc (FILE * infile) +/* Read next char, skipping over any comments */ +/* A comment/newline sequence is returned as a newline */ +{ + register int ch; + + ch = getc(infile); + if (ch == '#') { + do { + ch = getc(infile); + } while (ch != '\n' && ch != EOF); + } + return ch; +} + + +LOCAL(unsigned int) +read_pbm_integer (j_decompress_ptr cinfo, FILE * infile) +/* Read an unsigned decimal integer from the PPM file */ +/* Swallows one trailing character after the integer */ +/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ +/* This should not be a problem in practice. */ +{ + register int ch; + register unsigned int val; + + /* Skip any leading whitespace */ + do { + ch = pbm_getc(infile); + if (ch == EOF) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); + + if (ch < '0' || ch > '9') + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + val = ch - '0'; + while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { + val *= 10; + val += ch - '0'; + } + return val; +} + + +/* + * Extract color map from a PPM file. + */ + +LOCAL(void) +read_ppm_map (j_decompress_ptr cinfo, FILE * infile) +{ + int c; + unsigned int w, h, maxval, row, col; + int R, G, B; + + /* Initial 'P' has already been read by read_color_map */ + c = getc(infile); /* save format discriminator for a sec */ + + /* while we fetch the remaining header info */ + w = read_pbm_integer(cinfo, infile); + h = read_pbm_integer(cinfo, infile); + maxval = read_pbm_integer(cinfo, infile); + + if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + /* For now, we don't support rescaling from an unusual maxval. */ + if (maxval != (unsigned int) MAXJSAMPLE) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + switch (c) { + case '3': /* it's a text-format PPM file */ + for (row = 0; row < h; row++) { + for (col = 0; col < w; col++) { + R = read_pbm_integer(cinfo, infile); + G = read_pbm_integer(cinfo, infile); + B = read_pbm_integer(cinfo, infile); + add_map_entry(cinfo, R, G, B); + } + } + break; + + case '6': /* it's a raw-format PPM file */ + for (row = 0; row < h; row++) { + for (col = 0; col < w; col++) { + R = getc(infile); + G = getc(infile); + B = getc(infile); + if (R == EOF || G == EOF || B == EOF) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + add_map_entry(cinfo, R, G, B); + } + } + break; + + default: + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + break; + } +} + + +/* + * Main entry point from djpeg.c. + * Input: opened input file (from file name argument on command line). + * Output: colormap and actual_number_of_colors fields are set in cinfo. + */ + +GLOBAL(void) +read_color_map (j_decompress_ptr cinfo, FILE * infile) +{ + /* Allocate space for a color map of maximum supported size. */ + cinfo->colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (MAXJSAMPLE+1), (JDIMENSION) 3); + cinfo->actual_number_of_colors = 0; /* initialize map to empty */ + + /* Read first byte to determine file format */ + switch (getc(infile)) { + case 'G': + read_gif_map(cinfo, infile); + break; + case 'P': + read_ppm_map(cinfo, infile); + break; + default: + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + break; + } +} + +#endif /* QUANT_2PASS_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/rdgif.c b/src/dep/src/irrlicht/jpeglib/rdgif.c index b0757e7..b27c167 100644 --- a/src/dep/src/irrlicht/jpeglib/rdgif.c +++ b/src/dep/src/irrlicht/jpeglib/rdgif.c @@ -1,38 +1,38 @@ -/* - * rdgif.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in GIF format. - * - ***************************************************************************** - * NOTE: to avoid entanglements with Unisys' patent on LZW compression, * - * the ability to read GIF files has been removed from the IJG distribution. * - * Sorry about that. * - ***************************************************************************** - * - * We are required to state that - * "The Graphics Interchange Format(c) is the Copyright property of - * CompuServe Incorporated. GIF(sm) is a Service Mark property of - * CompuServe Incorporated." - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef GIF_SUPPORTED - -/* - * The module selection routine for GIF format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_gif (j_compress_ptr cinfo) -{ - fprintf(stderr, "GIF input is unsupported for legal reasons. Sorry.\n"); - exit(EXIT_FAILURE); - return NULL; /* keep compiler happy */ -} - -#endif /* GIF_SUPPORTED */ +/* + * rdgif.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to read input images in GIF format. + * + ***************************************************************************** + * NOTE: to avoid entanglements with Unisys' patent on LZW compression, * + * the ability to read GIF files has been removed from the IJG distribution. * + * Sorry about that. * + ***************************************************************************** + * + * We are required to state that + * "The Graphics Interchange Format(c) is the Copyright property of + * CompuServe Incorporated. GIF(sm) is a Service Mark property of + * CompuServe Incorporated." + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef GIF_SUPPORTED + +/* + * The module selection routine for GIF format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_gif (j_compress_ptr cinfo) +{ + fprintf(stderr, "GIF input is unsupported for legal reasons. Sorry.\n"); + exit(EXIT_FAILURE); + return NULL; /* keep compiler happy */ +} + +#endif /* GIF_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/rdjpgcom.1 b/src/dep/src/irrlicht/jpeglib/rdjpgcom.1 index dd837a8..2bba04e 100644 --- a/src/dep/src/irrlicht/jpeglib/rdjpgcom.1 +++ b/src/dep/src/irrlicht/jpeglib/rdjpgcom.1 @@ -1,54 +1,54 @@ -.TH RDJPGCOM 1 "11 October 1997" -.SH NAME -rdjpgcom \- display text comments from a JPEG file -.SH SYNOPSIS -.B rdjpgcom -[ -.B \-verbose -] -[ -.I filename -] -.LP -.SH DESCRIPTION -.LP -.B rdjpgcom -reads the named JPEG/JFIF file, or the standard input if no file is named, -and prints any text comments found in the file on the standard output. -.PP -The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. -Although the standard doesn't actually define what COM blocks are for, they -are widely used to hold user-supplied text strings. This lets you add -annotations, titles, index terms, etc to your JPEG files, and later retrieve -them as text. COM blocks do not interfere with the image stored in the JPEG -file. The maximum size of a COM block is 64K, but you can have as many of -them as you like in one JPEG file. -.SH OPTIONS -.TP -.B \-verbose -Causes -.B rdjpgcom -to also display the JPEG image dimensions. -.PP -Switch names may be abbreviated, and are not case sensitive. -.SH HINTS -.B rdjpgcom -does not depend on the IJG JPEG library. Its source code is intended as an -illustration of the minimum amount of code required to parse a JPEG file -header correctly. -.PP -In -.B \-verbose -mode, -.B rdjpgcom -will also attempt to print the contents of any "APP12" markers as text. -Some digital cameras produce APP12 markers containing useful textual -information. If you like, you can modify the source code to print -other APPn marker types as well. -.SH SEE ALSO -.BR cjpeg (1), -.BR djpeg (1), -.BR jpegtran (1), -.BR wrjpgcom (1) -.SH AUTHOR -Independent JPEG Group +.TH RDJPGCOM 1 "11 October 1997" +.SH NAME +rdjpgcom \- display text comments from a JPEG file +.SH SYNOPSIS +.B rdjpgcom +[ +.B \-verbose +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B rdjpgcom +reads the named JPEG/JFIF file, or the standard input if no file is named, +and prints any text comments found in the file on the standard output. +.PP +The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. +Although the standard doesn't actually define what COM blocks are for, they +are widely used to hold user-supplied text strings. This lets you add +annotations, titles, index terms, etc to your JPEG files, and later retrieve +them as text. COM blocks do not interfere with the image stored in the JPEG +file. The maximum size of a COM block is 64K, but you can have as many of +them as you like in one JPEG file. +.SH OPTIONS +.TP +.B \-verbose +Causes +.B rdjpgcom +to also display the JPEG image dimensions. +.PP +Switch names may be abbreviated, and are not case sensitive. +.SH HINTS +.B rdjpgcom +does not depend on the IJG JPEG library. Its source code is intended as an +illustration of the minimum amount of code required to parse a JPEG file +header correctly. +.PP +In +.B \-verbose +mode, +.B rdjpgcom +will also attempt to print the contents of any "APP12" markers as text. +Some digital cameras produce APP12 markers containing useful textual +information. If you like, you can modify the source code to print +other APPn marker types as well. +.SH SEE ALSO +.BR cjpeg (1), +.BR djpeg (1), +.BR jpegtran (1), +.BR wrjpgcom (1) +.SH AUTHOR +Independent JPEG Group diff --git a/src/dep/src/irrlicht/jpeglib/rdjpgcom.c b/src/dep/src/irrlicht/jpeglib/rdjpgcom.c index c8b94bb..ffe6fc6 100644 --- a/src/dep/src/irrlicht/jpeglib/rdjpgcom.c +++ b/src/dep/src/irrlicht/jpeglib/rdjpgcom.c @@ -1,496 +1,496 @@ -/* - * rdjpgcom.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a very simple stand-alone application that displays - * the text in COM (comment) markers in a JFIF file. - * This may be useful as an example of the minimum logic needed to parse - * JPEG markers. - */ - -#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ -#include "jinclude.h" /* get auto-config symbols, */ - -#include /* to declare isupper(), tolower() */ -#ifdef USE_SETMODE -#include /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not , just delete this line: */ -#include /* to declare setmode() */ -#endif - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#endif -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif -#ifndef EXIT_SUCCESS -#ifdef VMS -#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ -#else -#define EXIT_SUCCESS 0 -#endif -#endif - - -/* - * These macros are used to read the input file. - * To reuse this code in another application, you might need to change these. - */ - -static FILE * infile; /* input JPEG file */ - -/* Return next input byte, or EOF if no more */ -#define NEXTBYTE() getc(infile) - - -/* Error exit handler */ -#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) - - -/* Read one byte, testing for EOF */ -static int -read_1_byte (void) -{ - int c; - - c = NEXTBYTE(); - if (c == EOF) - ERREXIT("Premature EOF in JPEG file"); - return c; -} - -/* Read 2 bytes, convert to unsigned int */ -/* All 2-byte quantities in JPEG markers are MSB first */ -static unsigned int -read_2_bytes (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - if (c1 == EOF) - ERREXIT("Premature EOF in JPEG file"); - c2 = NEXTBYTE(); - if (c2 == EOF) - ERREXIT("Premature EOF in JPEG file"); - return (((unsigned int) c1) << 8) + ((unsigned int) c2); -} - - -/* - * JPEG markers consist of one or more 0xFF bytes, followed by a marker - * code byte (which is not an FF). Here are the marker codes of interest - * in this program. (See jdmarker.c for a more complete list.) - */ - -#define M_SOF0 0xC0 /* Start Of Frame N */ -#define M_SOF1 0xC1 /* N indicates which compression process */ -#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ -#define M_SOF3 0xC3 -#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ -#define M_SOF6 0xC6 -#define M_SOF7 0xC7 -#define M_SOF9 0xC9 -#define M_SOF10 0xCA -#define M_SOF11 0xCB -#define M_SOF13 0xCD -#define M_SOF14 0xCE -#define M_SOF15 0xCF -#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ -#define M_EOI 0xD9 /* End Of Image (end of datastream) */ -#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ -#define M_APP0 0xE0 /* Application-specific marker, type N */ -#define M_APP12 0xEC /* (we don't bother to list all 16 APPn's) */ -#define M_COM 0xFE /* COMment */ - - -/* - * Find the next JPEG marker and return its marker code. - * We expect at least one FF byte, possibly more if the compressor used FFs - * to pad the file. - * There could also be non-FF garbage between markers. The treatment of such - * garbage is unspecified; we choose to skip over it but emit a warning msg. - * NB: this routine must not be used after seeing SOS marker, since it will - * not deal correctly with FF/00 sequences in the compressed image data... - */ - -static int -next_marker (void) -{ - int c; - int discarded_bytes = 0; - - /* Find 0xFF byte; count and skip any non-FFs. */ - c = read_1_byte(); - while (c != 0xFF) { - discarded_bytes++; - c = read_1_byte(); - } - /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs - * are legal as pad bytes, so don't count them in discarded_bytes. - */ - do { - c = read_1_byte(); - } while (c == 0xFF); - - if (discarded_bytes != 0) { - fprintf(stderr, "Warning: garbage data found in JPEG file\n"); - } - - return c; -} - - -/* - * Read the initial marker, which should be SOI. - * For a JFIF file, the first two bytes of the file should be literally - * 0xFF M_SOI. To be more general, we could use next_marker, but if the - * input file weren't actually JPEG at all, next_marker might read the whole - * file and then return a misleading error message... - */ - -static int -first_marker (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - c2 = NEXTBYTE(); - if (c1 != 0xFF || c2 != M_SOI) - ERREXIT("Not a JPEG file"); - return c2; -} - - -/* - * Most types of marker are followed by a variable-length parameter segment. - * This routine skips over the parameters for any marker we don't otherwise - * want to process. - * Note that we MUST skip the parameter segment explicitly in order not to - * be fooled by 0xFF bytes that might appear within the parameter segment; - * such bytes do NOT introduce new markers. - */ - -static void -skip_variable (void) -/* Skip over an unknown or uninteresting variable-length marker */ -{ - unsigned int length; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - /* Skip over the remaining bytes */ - while (length > 0) { - (void) read_1_byte(); - length--; - } -} - - -/* - * Process a COM marker. - * We want to print out the marker contents as legible text; - * we must guard against non-text junk and varying newline representations. - */ - -static void -process_COM (void) -{ - unsigned int length; - int ch; - int lastch = 0; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - - while (length > 0) { - ch = read_1_byte(); - /* Emit the character in a readable form. - * Nonprintables are converted to \nnn form, - * while \ is converted to \\. - * Newlines in CR, CR/LF, or LF form will be printed as one newline. - */ - if (ch == '\r') { - printf("\n"); - } else if (ch == '\n') { - if (lastch != '\r') - printf("\n"); - } else if (ch == '\\') { - printf("\\\\"); - } else if (isprint(ch)) { - putc(ch, stdout); - } else { - printf("\\%03o", ch); - } - lastch = ch; - length--; - } - printf("\n"); -} - - -/* - * Process a SOFn marker. - * This code is only needed if you want to know the image dimensions... - */ - -static void -process_SOFn (int marker) -{ - unsigned int length; - unsigned int image_height, image_width; - int data_precision, num_components; - const char * process; - int ci; - - length = read_2_bytes(); /* usual parameter length count */ - - data_precision = read_1_byte(); - image_height = read_2_bytes(); - image_width = read_2_bytes(); - num_components = read_1_byte(); - - switch (marker) { - case M_SOF0: process = "Baseline"; break; - case M_SOF1: process = "Extended sequential"; break; - case M_SOF2: process = "Progressive"; break; - case M_SOF3: process = "Lossless"; break; - case M_SOF5: process = "Differential sequential"; break; - case M_SOF6: process = "Differential progressive"; break; - case M_SOF7: process = "Differential lossless"; break; - case M_SOF9: process = "Extended sequential, arithmetic coding"; break; - case M_SOF10: process = "Progressive, arithmetic coding"; break; - case M_SOF11: process = "Lossless, arithmetic coding"; break; - case M_SOF13: process = "Differential sequential, arithmetic coding"; break; - case M_SOF14: process = "Differential progressive, arithmetic coding"; break; - case M_SOF15: process = "Differential lossless, arithmetic coding"; break; - default: process = "Unknown"; break; - } - - printf("JPEG image is %uw * %uh, %d color components, %d bits per sample\n", - image_width, image_height, num_components, data_precision); - printf("JPEG process: %s\n", process); - - if (length != (unsigned int) (8 + num_components * 3)) - ERREXIT("Bogus SOF marker length"); - - for (ci = 0; ci < num_components; ci++) { - (void) read_1_byte(); /* Component ID code */ - (void) read_1_byte(); /* H, V sampling factors */ - (void) read_1_byte(); /* Quantization table number */ - } -} - - -/* - * Parse the marker stream until SOS or EOI is seen; - * display any COM markers. - * While the companion program wrjpgcom will always insert COM markers before - * SOFn, other implementations might not, so we scan to SOS before stopping. - * If we were only interested in the image dimensions, we would stop at SOFn. - * (Conversely, if we only cared about COM markers, there would be no need - * for special code to handle SOFn; we could treat it like other markers.) - */ - -static int -scan_JPEG_header (int verbose) -{ - int marker; - - /* Expect SOI at start of file */ - if (first_marker() != M_SOI) - ERREXIT("Expected SOI marker first"); - - /* Scan miscellaneous markers until we reach SOS. */ - for (;;) { - marker = next_marker(); - switch (marker) { - /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, - * treated as SOFn. C4 in particular is actually DHT. - */ - case M_SOF0: /* Baseline */ - case M_SOF1: /* Extended sequential, Huffman */ - case M_SOF2: /* Progressive, Huffman */ - case M_SOF3: /* Lossless, Huffman */ - case M_SOF5: /* Differential sequential, Huffman */ - case M_SOF6: /* Differential progressive, Huffman */ - case M_SOF7: /* Differential lossless, Huffman */ - case M_SOF9: /* Extended sequential, arithmetic */ - case M_SOF10: /* Progressive, arithmetic */ - case M_SOF11: /* Lossless, arithmetic */ - case M_SOF13: /* Differential sequential, arithmetic */ - case M_SOF14: /* Differential progressive, arithmetic */ - case M_SOF15: /* Differential lossless, arithmetic */ - if (verbose) - process_SOFn(marker); - else - skip_variable(); - break; - - case M_SOS: /* stop before hitting compressed data */ - return marker; - - case M_EOI: /* in case it's a tables-only JPEG stream */ - return marker; - - case M_COM: - process_COM(); - break; - - case M_APP12: - /* Some digital camera makers put useful textual information into - * APP12 markers, so we print those out too when in -verbose mode. - */ - if (verbose) { - printf("APP12 contains:\n"); - process_COM(); - } else - skip_variable(); - break; - - default: /* Anything else just gets skipped */ - skip_variable(); /* we assume it has a parameter count... */ - break; - } - } /* end loop */ -} - - -/* Command line parsing code */ - -static const char * progname; /* program name for error messages */ - - -static void -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "rdjpgcom displays any textual comments in a JPEG file.\n"); - - fprintf(stderr, "Usage: %s [switches] [inputfile]\n", progname); - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -verbose Also display dimensions of JPEG image\n"); - - exit(EXIT_FAILURE); -} - - -static int -keymatch (char * arg, const char * keyword, int minchars) -/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ -/* keyword is the constant keyword (must be lower case already), */ -/* minchars is length of minimum legal abbreviation. */ -{ - register int ca, ck; - register int nmatched = 0; - - while ((ca = *arg++) != '\0') { - if ((ck = *keyword++) == '\0') - return 0; /* arg longer than keyword, no good */ - if (isupper(ca)) /* force arg to lcase (assume ck is already) */ - ca = tolower(ca); - if (ca != ck) - return 0; /* no good */ - nmatched++; /* count matched characters */ - } - /* reached end of argument; fail if it's too short for unique abbrev */ - if (nmatched < minchars) - return 0; - return 1; /* A-OK */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - int argn; - char * arg; - int verbose = 0; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "rdjpgcom"; /* in case C library doesn't provide it */ - - /* Parse switches, if any */ - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (arg[0] != '-') - break; /* not switch, must be file name */ - arg++; /* advance over '-' */ - if (keymatch(arg, "verbose", 1)) { - verbose++; - } else - usage(); - } - - /* Open the input file. */ - /* Unix style: expect zero or one file name */ - if (argn < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } - if (argn < argc) { - if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdin), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open stdin\n", progname); - exit(EXIT_FAILURE); - } -#else - infile = stdin; -#endif - } - - /* Scan the JPEG headers. */ - (void) scan_JPEG_header(verbose); - - /* All done. */ - exit(EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} +/* + * rdjpgcom.c + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a very simple stand-alone application that displays + * the text in COM (comment) markers in a JFIF file. + * This may be useful as an example of the minimum logic needed to parse + * JPEG markers. + */ + +#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ +#include "jinclude.h" /* get auto-config symbols, */ + +#include /* to declare isupper(), tolower() */ +#ifdef USE_SETMODE +#include /* to declare setmode()'s parameter macros */ +/* If you have setmode() but not , just delete this line: */ +#include /* to declare setmode() */ +#endif + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#else +#ifdef VMS /* VMS is very nonstandard */ +#define READ_BINARY "rb", "ctx=stm" +#else /* standard ANSI-compliant case */ +#define READ_BINARY "rb" +#endif +#endif + +#ifndef EXIT_FAILURE /* define exit() codes if not provided */ +#define EXIT_FAILURE 1 +#endif +#ifndef EXIT_SUCCESS +#ifdef VMS +#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ +#else +#define EXIT_SUCCESS 0 +#endif +#endif + + +/* + * These macros are used to read the input file. + * To reuse this code in another application, you might need to change these. + */ + +static FILE * infile; /* input JPEG file */ + +/* Return next input byte, or EOF if no more */ +#define NEXTBYTE() getc(infile) + + +/* Error exit handler */ +#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) + + +/* Read one byte, testing for EOF */ +static int +read_1_byte (void) +{ + int c; + + c = NEXTBYTE(); + if (c == EOF) + ERREXIT("Premature EOF in JPEG file"); + return c; +} + +/* Read 2 bytes, convert to unsigned int */ +/* All 2-byte quantities in JPEG markers are MSB first */ +static unsigned int +read_2_bytes (void) +{ + int c1, c2; + + c1 = NEXTBYTE(); + if (c1 == EOF) + ERREXIT("Premature EOF in JPEG file"); + c2 = NEXTBYTE(); + if (c2 == EOF) + ERREXIT("Premature EOF in JPEG file"); + return (((unsigned int) c1) << 8) + ((unsigned int) c2); +} + + +/* + * JPEG markers consist of one or more 0xFF bytes, followed by a marker + * code byte (which is not an FF). Here are the marker codes of interest + * in this program. (See jdmarker.c for a more complete list.) + */ + +#define M_SOF0 0xC0 /* Start Of Frame N */ +#define M_SOF1 0xC1 /* N indicates which compression process */ +#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ +#define M_SOF3 0xC3 +#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ +#define M_SOF6 0xC6 +#define M_SOF7 0xC7 +#define M_SOF9 0xC9 +#define M_SOF10 0xCA +#define M_SOF11 0xCB +#define M_SOF13 0xCD +#define M_SOF14 0xCE +#define M_SOF15 0xCF +#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ +#define M_EOI 0xD9 /* End Of Image (end of datastream) */ +#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ +#define M_APP0 0xE0 /* Application-specific marker, type N */ +#define M_APP12 0xEC /* (we don't bother to list all 16 APPn's) */ +#define M_COM 0xFE /* COMment */ + + +/* + * Find the next JPEG marker and return its marker code. + * We expect at least one FF byte, possibly more if the compressor used FFs + * to pad the file. + * There could also be non-FF garbage between markers. The treatment of such + * garbage is unspecified; we choose to skip over it but emit a warning msg. + * NB: this routine must not be used after seeing SOS marker, since it will + * not deal correctly with FF/00 sequences in the compressed image data... + */ + +static int +next_marker (void) +{ + int c; + int discarded_bytes = 0; + + /* Find 0xFF byte; count and skip any non-FFs. */ + c = read_1_byte(); + while (c != 0xFF) { + discarded_bytes++; + c = read_1_byte(); + } + /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs + * are legal as pad bytes, so don't count them in discarded_bytes. + */ + do { + c = read_1_byte(); + } while (c == 0xFF); + + if (discarded_bytes != 0) { + fprintf(stderr, "Warning: garbage data found in JPEG file\n"); + } + + return c; +} + + +/* + * Read the initial marker, which should be SOI. + * For a JFIF file, the first two bytes of the file should be literally + * 0xFF M_SOI. To be more general, we could use next_marker, but if the + * input file weren't actually JPEG at all, next_marker might read the whole + * file and then return a misleading error message... + */ + +static int +first_marker (void) +{ + int c1, c2; + + c1 = NEXTBYTE(); + c2 = NEXTBYTE(); + if (c1 != 0xFF || c2 != M_SOI) + ERREXIT("Not a JPEG file"); + return c2; +} + + +/* + * Most types of marker are followed by a variable-length parameter segment. + * This routine skips over the parameters for any marker we don't otherwise + * want to process. + * Note that we MUST skip the parameter segment explicitly in order not to + * be fooled by 0xFF bytes that might appear within the parameter segment; + * such bytes do NOT introduce new markers. + */ + +static void +skip_variable (void) +/* Skip over an unknown or uninteresting variable-length marker */ +{ + unsigned int length; + + /* Get the marker parameter length count */ + length = read_2_bytes(); + /* Length includes itself, so must be at least 2 */ + if (length < 2) + ERREXIT("Erroneous JPEG marker length"); + length -= 2; + /* Skip over the remaining bytes */ + while (length > 0) { + (void) read_1_byte(); + length--; + } +} + + +/* + * Process a COM marker. + * We want to print out the marker contents as legible text; + * we must guard against non-text junk and varying newline representations. + */ + +static void +process_COM (void) +{ + unsigned int length; + int ch; + int lastch = 0; + + /* Get the marker parameter length count */ + length = read_2_bytes(); + /* Length includes itself, so must be at least 2 */ + if (length < 2) + ERREXIT("Erroneous JPEG marker length"); + length -= 2; + + while (length > 0) { + ch = read_1_byte(); + /* Emit the character in a readable form. + * Nonprintables are converted to \nnn form, + * while \ is converted to \\. + * Newlines in CR, CR/LF, or LF form will be printed as one newline. + */ + if (ch == '\r') { + printf("\n"); + } else if (ch == '\n') { + if (lastch != '\r') + printf("\n"); + } else if (ch == '\\') { + printf("\\\\"); + } else if (isprint(ch)) { + putc(ch, stdout); + } else { + printf("\\%03o", ch); + } + lastch = ch; + length--; + } + printf("\n"); +} + + +/* + * Process a SOFn marker. + * This code is only needed if you want to know the image dimensions... + */ + +static void +process_SOFn (int marker) +{ + unsigned int length; + unsigned int image_height, image_width; + int data_precision, num_components; + const char * process; + int ci; + + length = read_2_bytes(); /* usual parameter length count */ + + data_precision = read_1_byte(); + image_height = read_2_bytes(); + image_width = read_2_bytes(); + num_components = read_1_byte(); + + switch (marker) { + case M_SOF0: process = "Baseline"; break; + case M_SOF1: process = "Extended sequential"; break; + case M_SOF2: process = "Progressive"; break; + case M_SOF3: process = "Lossless"; break; + case M_SOF5: process = "Differential sequential"; break; + case M_SOF6: process = "Differential progressive"; break; + case M_SOF7: process = "Differential lossless"; break; + case M_SOF9: process = "Extended sequential, arithmetic coding"; break; + case M_SOF10: process = "Progressive, arithmetic coding"; break; + case M_SOF11: process = "Lossless, arithmetic coding"; break; + case M_SOF13: process = "Differential sequential, arithmetic coding"; break; + case M_SOF14: process = "Differential progressive, arithmetic coding"; break; + case M_SOF15: process = "Differential lossless, arithmetic coding"; break; + default: process = "Unknown"; break; + } + + printf("JPEG image is %uw * %uh, %d color components, %d bits per sample\n", + image_width, image_height, num_components, data_precision); + printf("JPEG process: %s\n", process); + + if (length != (unsigned int) (8 + num_components * 3)) + ERREXIT("Bogus SOF marker length"); + + for (ci = 0; ci < num_components; ci++) { + (void) read_1_byte(); /* Component ID code */ + (void) read_1_byte(); /* H, V sampling factors */ + (void) read_1_byte(); /* Quantization table number */ + } +} + + +/* + * Parse the marker stream until SOS or EOI is seen; + * display any COM markers. + * While the companion program wrjpgcom will always insert COM markers before + * SOFn, other implementations might not, so we scan to SOS before stopping. + * If we were only interested in the image dimensions, we would stop at SOFn. + * (Conversely, if we only cared about COM markers, there would be no need + * for special code to handle SOFn; we could treat it like other markers.) + */ + +static int +scan_JPEG_header (int verbose) +{ + int marker; + + /* Expect SOI at start of file */ + if (first_marker() != M_SOI) + ERREXIT("Expected SOI marker first"); + + /* Scan miscellaneous markers until we reach SOS. */ + for (;;) { + marker = next_marker(); + switch (marker) { + /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, + * treated as SOFn. C4 in particular is actually DHT. + */ + case M_SOF0: /* Baseline */ + case M_SOF1: /* Extended sequential, Huffman */ + case M_SOF2: /* Progressive, Huffman */ + case M_SOF3: /* Lossless, Huffman */ + case M_SOF5: /* Differential sequential, Huffman */ + case M_SOF6: /* Differential progressive, Huffman */ + case M_SOF7: /* Differential lossless, Huffman */ + case M_SOF9: /* Extended sequential, arithmetic */ + case M_SOF10: /* Progressive, arithmetic */ + case M_SOF11: /* Lossless, arithmetic */ + case M_SOF13: /* Differential sequential, arithmetic */ + case M_SOF14: /* Differential progressive, arithmetic */ + case M_SOF15: /* Differential lossless, arithmetic */ + if (verbose) + process_SOFn(marker); + else + skip_variable(); + break; + + case M_SOS: /* stop before hitting compressed data */ + return marker; + + case M_EOI: /* in case it's a tables-only JPEG stream */ + return marker; + + case M_COM: + process_COM(); + break; + + case M_APP12: + /* Some digital camera makers put useful textual information into + * APP12 markers, so we print those out too when in -verbose mode. + */ + if (verbose) { + printf("APP12 contains:\n"); + process_COM(); + } else + skip_variable(); + break; + + default: /* Anything else just gets skipped */ + skip_variable(); /* we assume it has a parameter count... */ + break; + } + } /* end loop */ +} + + +/* Command line parsing code */ + +static const char * progname; /* program name for error messages */ + + +static void +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "rdjpgcom displays any textual comments in a JPEG file.\n"); + + fprintf(stderr, "Usage: %s [switches] [inputfile]\n", progname); + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -verbose Also display dimensions of JPEG image\n"); + + exit(EXIT_FAILURE); +} + + +static int +keymatch (char * arg, const char * keyword, int minchars) +/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ +/* keyword is the constant keyword (must be lower case already), */ +/* minchars is length of minimum legal abbreviation. */ +{ + register int ca, ck; + register int nmatched = 0; + + while ((ca = *arg++) != '\0') { + if ((ck = *keyword++) == '\0') + return 0; /* arg longer than keyword, no good */ + if (isupper(ca)) /* force arg to lcase (assume ck is already) */ + ca = tolower(ca); + if (ca != ck) + return 0; /* no good */ + nmatched++; /* count matched characters */ + } + /* reached end of argument; fail if it's too short for unique abbrev */ + if (nmatched < minchars) + return 0; + return 1; /* A-OK */ +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + int argn; + char * arg; + int verbose = 0; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "rdjpgcom"; /* in case C library doesn't provide it */ + + /* Parse switches, if any */ + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (arg[0] != '-') + break; /* not switch, must be file name */ + arg++; /* advance over '-' */ + if (keymatch(arg, "verbose", 1)) { + verbose++; + } else + usage(); + } + + /* Open the input file. */ + /* Unix style: expect zero or one file name */ + if (argn < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } + if (argn < argc) { + if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdin), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open stdin\n", progname); + exit(EXIT_FAILURE); + } +#else + infile = stdin; +#endif + } + + /* Scan the JPEG headers. */ + (void) scan_JPEG_header(verbose); + + /* All done. */ + exit(EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/src/dep/src/irrlicht/jpeglib/rdppm.c b/src/dep/src/irrlicht/jpeglib/rdppm.c index bec0bc0..1df35c1 100644 --- a/src/dep/src/irrlicht/jpeglib/rdppm.c +++ b/src/dep/src/irrlicht/jpeglib/rdppm.c @@ -1,458 +1,458 @@ -/* - * rdppm.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in PPM/PGM format. - * The extended 2-byte-per-sample raw PPM/PGM formats are supported. - * The PBMPLUS library is NOT required to compile this software - * (but it is highly useful as a set of PPM image manipulation programs). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed PPM format). - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef PPM_SUPPORTED - - -/* Portions of this code are based on the PBMPLUS library, which is: -** -** Copyright (C) 1988 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose and without fee is hereby granted, provided -** that the above copyright notice appear in all copies and that both that -** copyright notice and this permission notice appear in supporting -** documentation. This software is provided "as is" without express or -** implied warranty. -*/ - - -/* Macros to deal with unsigned chars as efficiently as compiler allows */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char U_CHAR; -#define UCH(x) ((int) (x)) -#else /* !HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char U_CHAR; -#define UCH(x) ((int) (x)) -#else -typedef char U_CHAR; -#define UCH(x) ((int) (x) & 0xFF) -#endif -#endif /* HAVE_UNSIGNED_CHAR */ - - -#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) - - -/* - * On most systems, reading individual bytes with getc() is drastically less - * efficient than buffering a row at a time with fread(). On PCs, we must - * allocate the buffer in near data space, because we are assuming small-data - * memory model, wherein fread() can't reach far memory. If you need to - * process very wide images on a PC, you might have to compile in large-memory - * model, or else replace fread() with a getc() loop --- which will be much - * slower. - */ - - -/* Private version of data source object */ - -typedef struct { - struct cjpeg_source_struct pub; /* public fields */ - - U_CHAR *iobuffer; /* non-FAR pointer to I/O buffer */ - JSAMPROW pixrow; /* FAR pointer to same */ - size_t buffer_width; /* width of I/O buffer */ - JSAMPLE *rescale; /* => maxval-remapping array, or NULL */ -} ppm_source_struct; - -typedef ppm_source_struct * ppm_source_ptr; - - -LOCAL(int) -pbm_getc (FILE * infile) -/* Read next char, skipping over any comments */ -/* A comment/newline sequence is returned as a newline */ -{ - register int ch; - - ch = getc(infile); - if (ch == '#') { - do { - ch = getc(infile); - } while (ch != '\n' && ch != EOF); - } - return ch; -} - - -LOCAL(unsigned int) -read_pbm_integer (j_compress_ptr cinfo, FILE * infile) -/* Read an unsigned decimal integer from the PPM file */ -/* Swallows one trailing character after the integer */ -/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ -/* This should not be a problem in practice. */ -{ - register int ch; - register unsigned int val; - - /* Skip any leading whitespace */ - do { - ch = pbm_getc(infile); - if (ch == EOF) - ERREXIT(cinfo, JERR_INPUT_EOF); - } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); - - if (ch < '0' || ch > '9') - ERREXIT(cinfo, JERR_PPM_NONNUMERIC); - - val = ch - '0'; - while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { - val *= 10; - val += ch - '0'; - } - return val; -} - - -/* - * Read one row of pixels. - * - * We provide several different versions depending on input file format. - * In all cases, input is scaled to the size of JSAMPLE. - * - * A really fast path is provided for reading byte/sample raw files with - * maxval = MAXJSAMPLE, which is the normal case for 8-bit data. - */ - - -METHODDEF(JDIMENSION) -get_text_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading text-format PGM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - FILE * infile = source->pub.input_file; - register JSAMPROW ptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_text_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading text-format PPM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - FILE * infile = source->pub.input_file; - register JSAMPROW ptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; - *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; - *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_scaled_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-byte-format PGM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pub.buffer[0]; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - *ptr++ = rescale[UCH(*bufferptr++)]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_scaled_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-byte-format PPM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pub.buffer[0]; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - *ptr++ = rescale[UCH(*bufferptr++)]; - *ptr++ = rescale[UCH(*bufferptr++)]; - *ptr++ = rescale[UCH(*bufferptr++)]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_raw_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-byte-format files with maxval = MAXJSAMPLE. - * In this case we just read right into the JSAMPLE buffer! - * Note that same code works for PPM and PGM files. - */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - return 1; -} - - -METHODDEF(JDIMENSION) -get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-word-format PGM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pub.buffer[0]; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - register int temp; - temp = UCH(*bufferptr++); - temp |= UCH(*bufferptr++) << 8; - *ptr++ = rescale[temp]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-word-format PPM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pub.buffer[0]; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - register int temp; - temp = UCH(*bufferptr++); - temp |= UCH(*bufferptr++) << 8; - *ptr++ = rescale[temp]; - temp = UCH(*bufferptr++); - temp |= UCH(*bufferptr++) << 8; - *ptr++ = rescale[temp]; - temp = UCH(*bufferptr++); - temp |= UCH(*bufferptr++) << 8; - *ptr++ = rescale[temp]; - } - return 1; -} - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - int c; - unsigned int w, h, maxval; - boolean need_iobuffer, use_raw_buffer, need_rescale; - - if (getc(source->pub.input_file) != 'P') - ERREXIT(cinfo, JERR_PPM_NOT); - - c = getc(source->pub.input_file); /* subformat discriminator character */ - - /* detect unsupported variants (ie, PBM) before trying to read header */ - switch (c) { - case '2': /* it's a text-format PGM file */ - case '3': /* it's a text-format PPM file */ - case '5': /* it's a raw-format PGM file */ - case '6': /* it's a raw-format PPM file */ - break; - default: - ERREXIT(cinfo, JERR_PPM_NOT); - break; - } - - /* fetch the remaining header info */ - w = read_pbm_integer(cinfo, source->pub.input_file); - h = read_pbm_integer(cinfo, source->pub.input_file); - maxval = read_pbm_integer(cinfo, source->pub.input_file); - - if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ - ERREXIT(cinfo, JERR_PPM_NOT); - - cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */ - cinfo->image_width = (JDIMENSION) w; - cinfo->image_height = (JDIMENSION) h; - - /* initialize flags to most common settings */ - need_iobuffer = TRUE; /* do we need an I/O buffer? */ - use_raw_buffer = FALSE; /* do we map input buffer onto I/O buffer? */ - need_rescale = TRUE; /* do we need a rescale array? */ - - switch (c) { - case '2': /* it's a text-format PGM file */ - cinfo->input_components = 1; - cinfo->in_color_space = JCS_GRAYSCALE; - TRACEMS2(cinfo, 1, JTRC_PGM_TEXT, w, h); - source->pub.get_pixel_rows = get_text_gray_row; - need_iobuffer = FALSE; - break; - - case '3': /* it's a text-format PPM file */ - cinfo->input_components = 3; - cinfo->in_color_space = JCS_RGB; - TRACEMS2(cinfo, 1, JTRC_PPM_TEXT, w, h); - source->pub.get_pixel_rows = get_text_rgb_row; - need_iobuffer = FALSE; - break; - - case '5': /* it's a raw-format PGM file */ - cinfo->input_components = 1; - cinfo->in_color_space = JCS_GRAYSCALE; - TRACEMS2(cinfo, 1, JTRC_PGM, w, h); - if (maxval > 255) { - source->pub.get_pixel_rows = get_word_gray_row; - } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { - source->pub.get_pixel_rows = get_raw_row; - use_raw_buffer = TRUE; - need_rescale = FALSE; - } else { - source->pub.get_pixel_rows = get_scaled_gray_row; - } - break; - - case '6': /* it's a raw-format PPM file */ - cinfo->input_components = 3; - cinfo->in_color_space = JCS_RGB; - TRACEMS2(cinfo, 1, JTRC_PPM, w, h); - if (maxval > 255) { - source->pub.get_pixel_rows = get_word_rgb_row; - } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { - source->pub.get_pixel_rows = get_raw_row; - use_raw_buffer = TRUE; - need_rescale = FALSE; - } else { - source->pub.get_pixel_rows = get_scaled_rgb_row; - } - break; - } - - /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */ - if (need_iobuffer) { - source->buffer_width = (size_t) w * cinfo->input_components * - ((maxval<=255) ? SIZEOF(U_CHAR) : (2*SIZEOF(U_CHAR))); - source->iobuffer = (U_CHAR *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - source->buffer_width); - } - - /* Create compressor input buffer. */ - if (use_raw_buffer) { - /* For unscaled raw-input case, we can just map it onto the I/O buffer. */ - /* Synthesize a JSAMPARRAY pointer structure */ - /* Cast here implies near->far pointer conversion on PCs */ - source->pixrow = (JSAMPROW) source->iobuffer; - source->pub.buffer = & source->pixrow; - source->pub.buffer_height = 1; - } else { - /* Need to translate anyway, so make a separate sample buffer. */ - source->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) w * cinfo->input_components, (JDIMENSION) 1); - source->pub.buffer_height = 1; - } - - /* Compute the rescaling array if required. */ - if (need_rescale) { - INT32 val, half_maxval; - - /* On 16-bit-int machines we have to be careful of maxval = 65535 */ - source->rescale = (JSAMPLE *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) (((long) maxval + 1L) * SIZEOF(JSAMPLE))); - half_maxval = maxval / 2; - for (val = 0; val <= (INT32) maxval; val++) { - /* The multiplication here must be done in 32 bits to avoid overflow */ - source->rescale[val] = (JSAMPLE) ((val*MAXJSAMPLE + half_maxval)/maxval); - } - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for PPM format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_ppm (j_compress_ptr cinfo) -{ - ppm_source_ptr source; - - /* Create module interface object */ - source = (ppm_source_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(ppm_source_struct)); - /* Fill in method ptrs, except get_pixel_rows which start_input sets */ - source->pub.start_input = start_input_ppm; - source->pub.finish_input = finish_input_ppm; - - return (cjpeg_source_ptr) source; -} - -#endif /* PPM_SUPPORTED */ +/* + * rdppm.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to read input images in PPM/PGM format. + * The extended 2-byte-per-sample raw PPM/PGM formats are supported. + * The PBMPLUS library is NOT required to compile this software + * (but it is highly useful as a set of PPM image manipulation programs). + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume input from + * an ordinary stdio stream. They further assume that reading begins + * at the start of the file; start_input may need work if the + * user interface has already read some data (e.g., to determine that + * the file is indeed PPM format). + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef PPM_SUPPORTED + + +/* Portions of this code are based on the PBMPLUS library, which is: +** +** Copyright (C) 1988 by Jef Poskanzer. +** +** Permission to use, copy, modify, and distribute this software and its +** documentation for any purpose and without fee is hereby granted, provided +** that the above copyright notice appear in all copies and that both that +** copyright notice and this permission notice appear in supporting +** documentation. This software is provided "as is" without express or +** implied warranty. +*/ + + +/* Macros to deal with unsigned chars as efficiently as compiler allows */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char U_CHAR; +#define UCH(x) ((int) (x)) +#else /* !HAVE_UNSIGNED_CHAR */ +#ifdef CHAR_IS_UNSIGNED +typedef char U_CHAR; +#define UCH(x) ((int) (x)) +#else +typedef char U_CHAR; +#define UCH(x) ((int) (x) & 0xFF) +#endif +#endif /* HAVE_UNSIGNED_CHAR */ + + +#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) + + +/* + * On most systems, reading individual bytes with getc() is drastically less + * efficient than buffering a row at a time with fread(). On PCs, we must + * allocate the buffer in near data space, because we are assuming small-data + * memory model, wherein fread() can't reach far memory. If you need to + * process very wide images on a PC, you might have to compile in large-memory + * model, or else replace fread() with a getc() loop --- which will be much + * slower. + */ + + +/* Private version of data source object */ + +typedef struct { + struct cjpeg_source_struct pub; /* public fields */ + + U_CHAR *iobuffer; /* non-FAR pointer to I/O buffer */ + JSAMPROW pixrow; /* FAR pointer to same */ + size_t buffer_width; /* width of I/O buffer */ + JSAMPLE *rescale; /* => maxval-remapping array, or NULL */ +} ppm_source_struct; + +typedef ppm_source_struct * ppm_source_ptr; + + +LOCAL(int) +pbm_getc (FILE * infile) +/* Read next char, skipping over any comments */ +/* A comment/newline sequence is returned as a newline */ +{ + register int ch; + + ch = getc(infile); + if (ch == '#') { + do { + ch = getc(infile); + } while (ch != '\n' && ch != EOF); + } + return ch; +} + + +LOCAL(unsigned int) +read_pbm_integer (j_compress_ptr cinfo, FILE * infile) +/* Read an unsigned decimal integer from the PPM file */ +/* Swallows one trailing character after the integer */ +/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ +/* This should not be a problem in practice. */ +{ + register int ch; + register unsigned int val; + + /* Skip any leading whitespace */ + do { + ch = pbm_getc(infile); + if (ch == EOF) + ERREXIT(cinfo, JERR_INPUT_EOF); + } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); + + if (ch < '0' || ch > '9') + ERREXIT(cinfo, JERR_PPM_NONNUMERIC); + + val = ch - '0'; + while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { + val *= 10; + val += ch - '0'; + } + return val; +} + + +/* + * Read one row of pixels. + * + * We provide several different versions depending on input file format. + * In all cases, input is scaled to the size of JSAMPLE. + * + * A really fast path is provided for reading byte/sample raw files with + * maxval = MAXJSAMPLE, which is the normal case for 8-bit data. + */ + + +METHODDEF(JDIMENSION) +get_text_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading text-format PGM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + FILE * infile = source->pub.input_file; + register JSAMPROW ptr; + register JSAMPLE *rescale = source->rescale; + JDIMENSION col; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_text_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading text-format PPM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + FILE * infile = source->pub.input_file; + register JSAMPROW ptr; + register JSAMPLE *rescale = source->rescale; + JDIMENSION col; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; + *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; + *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_scaled_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-byte-format PGM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + register JSAMPROW ptr; + register U_CHAR * bufferptr; + register JSAMPLE *rescale = source->rescale; + JDIMENSION col; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + ptr = source->pub.buffer[0]; + bufferptr = source->iobuffer; + for (col = cinfo->image_width; col > 0; col--) { + *ptr++ = rescale[UCH(*bufferptr++)]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_scaled_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-byte-format PPM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + register JSAMPROW ptr; + register U_CHAR * bufferptr; + register JSAMPLE *rescale = source->rescale; + JDIMENSION col; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + ptr = source->pub.buffer[0]; + bufferptr = source->iobuffer; + for (col = cinfo->image_width; col > 0; col--) { + *ptr++ = rescale[UCH(*bufferptr++)]; + *ptr++ = rescale[UCH(*bufferptr++)]; + *ptr++ = rescale[UCH(*bufferptr++)]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_raw_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-byte-format files with maxval = MAXJSAMPLE. + * In this case we just read right into the JSAMPLE buffer! + * Note that same code works for PPM and PGM files. + */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + return 1; +} + + +METHODDEF(JDIMENSION) +get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-word-format PGM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + register JSAMPROW ptr; + register U_CHAR * bufferptr; + register JSAMPLE *rescale = source->rescale; + JDIMENSION col; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + ptr = source->pub.buffer[0]; + bufferptr = source->iobuffer; + for (col = cinfo->image_width; col > 0; col--) { + register int temp; + temp = UCH(*bufferptr++); + temp |= UCH(*bufferptr++) << 8; + *ptr++ = rescale[temp]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-word-format PPM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + register JSAMPROW ptr; + register U_CHAR * bufferptr; + register JSAMPLE *rescale = source->rescale; + JDIMENSION col; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + ptr = source->pub.buffer[0]; + bufferptr = source->iobuffer; + for (col = cinfo->image_width; col > 0; col--) { + register int temp; + temp = UCH(*bufferptr++); + temp |= UCH(*bufferptr++) << 8; + *ptr++ = rescale[temp]; + temp = UCH(*bufferptr++); + temp |= UCH(*bufferptr++) << 8; + *ptr++ = rescale[temp]; + temp = UCH(*bufferptr++); + temp |= UCH(*bufferptr++) << 8; + *ptr++ = rescale[temp]; + } + return 1; +} + + +/* + * Read the file header; return image size and component count. + */ + +METHODDEF(void) +start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + int c; + unsigned int w, h, maxval; + boolean need_iobuffer, use_raw_buffer, need_rescale; + + if (getc(source->pub.input_file) != 'P') + ERREXIT(cinfo, JERR_PPM_NOT); + + c = getc(source->pub.input_file); /* subformat discriminator character */ + + /* detect unsupported variants (ie, PBM) before trying to read header */ + switch (c) { + case '2': /* it's a text-format PGM file */ + case '3': /* it's a text-format PPM file */ + case '5': /* it's a raw-format PGM file */ + case '6': /* it's a raw-format PPM file */ + break; + default: + ERREXIT(cinfo, JERR_PPM_NOT); + break; + } + + /* fetch the remaining header info */ + w = read_pbm_integer(cinfo, source->pub.input_file); + h = read_pbm_integer(cinfo, source->pub.input_file); + maxval = read_pbm_integer(cinfo, source->pub.input_file); + + if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ + ERREXIT(cinfo, JERR_PPM_NOT); + + cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */ + cinfo->image_width = (JDIMENSION) w; + cinfo->image_height = (JDIMENSION) h; + + /* initialize flags to most common settings */ + need_iobuffer = TRUE; /* do we need an I/O buffer? */ + use_raw_buffer = FALSE; /* do we map input buffer onto I/O buffer? */ + need_rescale = TRUE; /* do we need a rescale array? */ + + switch (c) { + case '2': /* it's a text-format PGM file */ + cinfo->input_components = 1; + cinfo->in_color_space = JCS_GRAYSCALE; + TRACEMS2(cinfo, 1, JTRC_PGM_TEXT, w, h); + source->pub.get_pixel_rows = get_text_gray_row; + need_iobuffer = FALSE; + break; + + case '3': /* it's a text-format PPM file */ + cinfo->input_components = 3; + cinfo->in_color_space = JCS_RGB; + TRACEMS2(cinfo, 1, JTRC_PPM_TEXT, w, h); + source->pub.get_pixel_rows = get_text_rgb_row; + need_iobuffer = FALSE; + break; + + case '5': /* it's a raw-format PGM file */ + cinfo->input_components = 1; + cinfo->in_color_space = JCS_GRAYSCALE; + TRACEMS2(cinfo, 1, JTRC_PGM, w, h); + if (maxval > 255) { + source->pub.get_pixel_rows = get_word_gray_row; + } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { + source->pub.get_pixel_rows = get_raw_row; + use_raw_buffer = TRUE; + need_rescale = FALSE; + } else { + source->pub.get_pixel_rows = get_scaled_gray_row; + } + break; + + case '6': /* it's a raw-format PPM file */ + cinfo->input_components = 3; + cinfo->in_color_space = JCS_RGB; + TRACEMS2(cinfo, 1, JTRC_PPM, w, h); + if (maxval > 255) { + source->pub.get_pixel_rows = get_word_rgb_row; + } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { + source->pub.get_pixel_rows = get_raw_row; + use_raw_buffer = TRUE; + need_rescale = FALSE; + } else { + source->pub.get_pixel_rows = get_scaled_rgb_row; + } + break; + } + + /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */ + if (need_iobuffer) { + source->buffer_width = (size_t) w * cinfo->input_components * + ((maxval<=255) ? SIZEOF(U_CHAR) : (2*SIZEOF(U_CHAR))); + source->iobuffer = (U_CHAR *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + source->buffer_width); + } + + /* Create compressor input buffer. */ + if (use_raw_buffer) { + /* For unscaled raw-input case, we can just map it onto the I/O buffer. */ + /* Synthesize a JSAMPARRAY pointer structure */ + /* Cast here implies near->far pointer conversion on PCs */ + source->pixrow = (JSAMPROW) source->iobuffer; + source->pub.buffer = & source->pixrow; + source->pub.buffer_height = 1; + } else { + /* Need to translate anyway, so make a separate sample buffer. */ + source->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) w * cinfo->input_components, (JDIMENSION) 1); + source->pub.buffer_height = 1; + } + + /* Compute the rescaling array if required. */ + if (need_rescale) { + INT32 val, half_maxval; + + /* On 16-bit-int machines we have to be careful of maxval = 65535 */ + source->rescale = (JSAMPLE *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (size_t) (((long) maxval + 1L) * SIZEOF(JSAMPLE))); + half_maxval = maxval / 2; + for (val = 0; val <= (INT32) maxval; val++) { + /* The multiplication here must be done in 32 bits to avoid overflow */ + source->rescale[val] = (JSAMPLE) ((val*MAXJSAMPLE + half_maxval)/maxval); + } + } +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + /* no work */ +} + + +/* + * The module selection routine for PPM format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_ppm (j_compress_ptr cinfo) +{ + ppm_source_ptr source; + + /* Create module interface object */ + source = (ppm_source_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(ppm_source_struct)); + /* Fill in method ptrs, except get_pixel_rows which start_input sets */ + source->pub.start_input = start_input_ppm; + source->pub.finish_input = finish_input_ppm; + + return (cjpeg_source_ptr) source; +} + +#endif /* PPM_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/rdrle.c b/src/dep/src/irrlicht/jpeglib/rdrle.c index df871e0..542bc37 100644 --- a/src/dep/src/irrlicht/jpeglib/rdrle.c +++ b/src/dep/src/irrlicht/jpeglib/rdrle.c @@ -1,387 +1,387 @@ -/* - * rdrle.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in Utah RLE format. - * The Utah Raster Toolkit library is required (version 3.1 or later). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed RLE format). - * - * Based on code contributed by Mike Lijewski, - * with updates from Robert Hutchinson. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef RLE_SUPPORTED - -/* rle.h is provided by the Utah Raster Toolkit. */ - -#include - -/* - * We assume that JSAMPLE has the same representation as rle_pixel, - * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - -/* - * We support the following types of RLE files: - * - * GRAYSCALE - 8 bits, no colormap - * MAPPEDGRAY - 8 bits, 1 channel colomap - * PSEUDOCOLOR - 8 bits, 3 channel colormap - * TRUECOLOR - 24 bits, 3 channel colormap - * DIRECTCOLOR - 24 bits, no colormap - * - * For now, we ignore any alpha channel in the image. - */ - -typedef enum - { GRAYSCALE, MAPPEDGRAY, PSEUDOCOLOR, TRUECOLOR, DIRECTCOLOR } rle_kind; - - -/* - * Since RLE stores scanlines bottom-to-top, we have to invert the image - * to conform to JPEG's top-to-bottom order. To do this, we read the - * incoming image into a virtual array on the first get_pixel_rows call, - * then fetch the required row from the virtual array on subsequent calls. - */ - -typedef struct _rle_source_struct * rle_source_ptr; - -typedef struct _rle_source_struct { - struct cjpeg_source_struct pub; /* public fields */ - - rle_kind visual; /* actual type of input file */ - jvirt_sarray_ptr image; /* virtual array to hold the image */ - JDIMENSION row; /* current row # in the virtual array */ - rle_hdr header; /* Input file information */ - rle_pixel** rle_row; /* holds a row returned by rle_getrow() */ - -} rle_source_struct; - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - JDIMENSION width, height; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - /* Use RLE library routine to get the header info */ - source->header = *rle_hdr_init(NULL); - source->header.rle_file = source->pub.input_file; - switch (rle_get_setup(&(source->header))) { - case RLE_SUCCESS: - /* A-OK */ - break; - case RLE_NOT_RLE: - ERREXIT(cinfo, JERR_RLE_NOT); - break; - case RLE_NO_SPACE: - ERREXIT(cinfo, JERR_RLE_MEM); - break; - case RLE_EMPTY: - ERREXIT(cinfo, JERR_RLE_EMPTY); - break; - case RLE_EOF: - ERREXIT(cinfo, JERR_RLE_EOF); - break; - default: - ERREXIT(cinfo, JERR_RLE_BADERROR); - break; - } - - /* Figure out what we have, set private vars and return values accordingly */ - - width = source->header.xmax - source->header.xmin + 1; - height = source->header.ymax - source->header.ymin + 1; - source->header.xmin = 0; /* realign horizontally */ - source->header.xmax = width-1; - - cinfo->image_width = width; - cinfo->image_height = height; - cinfo->data_precision = 8; /* we can only handle 8 bit data */ - - if (source->header.ncolors == 1 && source->header.ncmap == 0) { - source->visual = GRAYSCALE; - TRACEMS2(cinfo, 1, JTRC_RLE_GRAY, width, height); - } else if (source->header.ncolors == 1 && source->header.ncmap == 1) { - source->visual = MAPPEDGRAY; - TRACEMS3(cinfo, 1, JTRC_RLE_MAPGRAY, width, height, - 1 << source->header.cmaplen); - } else if (source->header.ncolors == 1 && source->header.ncmap == 3) { - source->visual = PSEUDOCOLOR; - TRACEMS3(cinfo, 1, JTRC_RLE_MAPPED, width, height, - 1 << source->header.cmaplen); - } else if (source->header.ncolors == 3 && source->header.ncmap == 3) { - source->visual = TRUECOLOR; - TRACEMS3(cinfo, 1, JTRC_RLE_FULLMAP, width, height, - 1 << source->header.cmaplen); - } else if (source->header.ncolors == 3 && source->header.ncmap == 0) { - source->visual = DIRECTCOLOR; - TRACEMS2(cinfo, 1, JTRC_RLE, width, height); - } else - ERREXIT(cinfo, JERR_RLE_UNSUPPORTED); - - if (source->visual == GRAYSCALE || source->visual == MAPPEDGRAY) { - cinfo->in_color_space = JCS_GRAYSCALE; - cinfo->input_components = 1; - } else { - cinfo->in_color_space = JCS_RGB; - cinfo->input_components = 3; - } - - /* - * A place to hold each scanline while it's converted. - * (GRAYSCALE scanlines don't need converting) - */ - if (source->visual != GRAYSCALE) { - source->rle_row = (rle_pixel**) (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) width, (JDIMENSION) cinfo->input_components); - } - - /* request a virtual array to hold the image */ - source->image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) (width * source->header.ncolors), - (JDIMENSION) height, (JDIMENSION) 1); - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - /* count file input as separate pass */ - progress->total_extra_passes++; - } -#endif - - source->pub.buffer_height = 1; -} - - -/* - * Read one row of pixels. - * Called only after load_image has read the image into the virtual array. - * Used for GRAYSCALE, MAPPEDGRAY, TRUECOLOR, and DIRECTCOLOR images. - */ - -METHODDEF(JDIMENSION) -get_rle_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - - source->row--; - source->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); - - return 1; -} - -/* - * Read one row of pixels. - * Called only after load_image has read the image into the virtual array. - * Used for PSEUDOCOLOR images. - */ - -METHODDEF(JDIMENSION) -get_pseudocolor_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - JSAMPROW src_row, dest_row; - JDIMENSION col; - rle_map *colormap; - int val; - - colormap = source->header.cmap; - dest_row = source->pub.buffer[0]; - source->row--; - src_row = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); - - for (col = cinfo->image_width; col > 0; col--) { - val = GETJSAMPLE(*src_row++); - *dest_row++ = (JSAMPLE) (colormap[val ] >> 8); - *dest_row++ = (JSAMPLE) (colormap[val + 256] >> 8); - *dest_row++ = (JSAMPLE) (colormap[val + 512] >> 8); - } - - return 1; -} - - -/* - * Load the image into a virtual array. We have to do this because RLE - * files start at the lower left while the JPEG standard has them starting - * in the upper left. This is called the first time we want to get a row - * of input. What we do is load the RLE data into the array and then call - * the appropriate routine to read one row from the array. Before returning, - * we set source->pub.get_pixel_rows so that subsequent calls go straight to - * the appropriate row-reading routine. - */ - -METHODDEF(JDIMENSION) -load_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - JDIMENSION row, col; - JSAMPROW scanline, red_ptr, green_ptr, blue_ptr; - rle_pixel **rle_row; - rle_map *colormap; - char channel; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - colormap = source->header.cmap; - rle_row = source->rle_row; - - /* Read the RLE data into our virtual array. - * We assume here that (a) rle_pixel is represented the same as JSAMPLE, - * and (b) we are not on a machine where FAR pointers differ from regular. - */ - RLE_CLR_BIT(source->header, RLE_ALPHA); /* don't read the alpha channel */ - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_limit = cinfo->image_height; - progress->pub.pass_counter = 0; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - - switch (source->visual) { - - case GRAYSCALE: - case PSEUDOCOLOR: - for (row = 0; row < cinfo->image_height; row++) { - rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); - rle_getrow(&source->header, rle_row); -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - break; - - case MAPPEDGRAY: - case TRUECOLOR: - for (row = 0; row < cinfo->image_height; row++) { - scanline = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); - rle_row = source->rle_row; - rle_getrow(&source->header, rle_row); - - for (col = 0; col < cinfo->image_width; col++) { - for (channel = 0; channel < source->header.ncolors; channel++) { - *scanline++ = (JSAMPLE) - (colormap[GETJSAMPLE(rle_row[channel][col]) + 256 * channel] >> 8); - } - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - break; - - case DIRECTCOLOR: - for (row = 0; row < cinfo->image_height; row++) { - scanline = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); - rle_getrow(&source->header, rle_row); - - red_ptr = rle_row[0]; - green_ptr = rle_row[1]; - blue_ptr = rle_row[2]; - - for (col = cinfo->image_width; col > 0; col--) { - *scanline++ = *red_ptr++; - *scanline++ = *green_ptr++; - *scanline++ = *blue_ptr++; - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) - progress->completed_extra_passes++; -#endif - - /* Set up to call proper row-extraction routine in future */ - if (source->visual == PSEUDOCOLOR) { - source->pub.buffer = source->rle_row; - source->pub.get_pixel_rows = get_pseudocolor_row; - } else { - source->pub.get_pixel_rows = get_rle_row; - } - source->row = cinfo->image_height; - - /* And fetch the topmost (bottommost) row */ - return (*source->pub.get_pixel_rows) (cinfo, sinfo); -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for RLE format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_rle (j_compress_ptr cinfo) -{ - rle_source_ptr source; - - /* Create module interface object */ - source = (rle_source_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(rle_source_struct)); - /* Fill in method ptrs */ - source->pub.start_input = start_input_rle; - source->pub.finish_input = finish_input_rle; - source->pub.get_pixel_rows = load_image; - - return (cjpeg_source_ptr) source; -} - -#endif /* RLE_SUPPORTED */ +/* + * rdrle.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to read input images in Utah RLE format. + * The Utah Raster Toolkit library is required (version 3.1 or later). + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume input from + * an ordinary stdio stream. They further assume that reading begins + * at the start of the file; start_input may need work if the + * user interface has already read some data (e.g., to determine that + * the file is indeed RLE format). + * + * Based on code contributed by Mike Lijewski, + * with updates from Robert Hutchinson. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef RLE_SUPPORTED + +/* rle.h is provided by the Utah Raster Toolkit. */ + +#include + +/* + * We assume that JSAMPLE has the same representation as rle_pixel, + * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. + */ + +#if BITS_IN_JSAMPLE != 8 + Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ +#endif + +/* + * We support the following types of RLE files: + * + * GRAYSCALE - 8 bits, no colormap + * MAPPEDGRAY - 8 bits, 1 channel colomap + * PSEUDOCOLOR - 8 bits, 3 channel colormap + * TRUECOLOR - 24 bits, 3 channel colormap + * DIRECTCOLOR - 24 bits, no colormap + * + * For now, we ignore any alpha channel in the image. + */ + +typedef enum + { GRAYSCALE, MAPPEDGRAY, PSEUDOCOLOR, TRUECOLOR, DIRECTCOLOR } rle_kind; + + +/* + * Since RLE stores scanlines bottom-to-top, we have to invert the image + * to conform to JPEG's top-to-bottom order. To do this, we read the + * incoming image into a virtual array on the first get_pixel_rows call, + * then fetch the required row from the virtual array on subsequent calls. + */ + +typedef struct _rle_source_struct * rle_source_ptr; + +typedef struct _rle_source_struct { + struct cjpeg_source_struct pub; /* public fields */ + + rle_kind visual; /* actual type of input file */ + jvirt_sarray_ptr image; /* virtual array to hold the image */ + JDIMENSION row; /* current row # in the virtual array */ + rle_hdr header; /* Input file information */ + rle_pixel** rle_row; /* holds a row returned by rle_getrow() */ + +} rle_source_struct; + + +/* + * Read the file header; return image size and component count. + */ + +METHODDEF(void) +start_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + rle_source_ptr source = (rle_source_ptr) sinfo; + JDIMENSION width, height; +#ifdef PROGRESS_REPORT + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; +#endif + + /* Use RLE library routine to get the header info */ + source->header = *rle_hdr_init(NULL); + source->header.rle_file = source->pub.input_file; + switch (rle_get_setup(&(source->header))) { + case RLE_SUCCESS: + /* A-OK */ + break; + case RLE_NOT_RLE: + ERREXIT(cinfo, JERR_RLE_NOT); + break; + case RLE_NO_SPACE: + ERREXIT(cinfo, JERR_RLE_MEM); + break; + case RLE_EMPTY: + ERREXIT(cinfo, JERR_RLE_EMPTY); + break; + case RLE_EOF: + ERREXIT(cinfo, JERR_RLE_EOF); + break; + default: + ERREXIT(cinfo, JERR_RLE_BADERROR); + break; + } + + /* Figure out what we have, set private vars and return values accordingly */ + + width = source->header.xmax - source->header.xmin + 1; + height = source->header.ymax - source->header.ymin + 1; + source->header.xmin = 0; /* realign horizontally */ + source->header.xmax = width-1; + + cinfo->image_width = width; + cinfo->image_height = height; + cinfo->data_precision = 8; /* we can only handle 8 bit data */ + + if (source->header.ncolors == 1 && source->header.ncmap == 0) { + source->visual = GRAYSCALE; + TRACEMS2(cinfo, 1, JTRC_RLE_GRAY, width, height); + } else if (source->header.ncolors == 1 && source->header.ncmap == 1) { + source->visual = MAPPEDGRAY; + TRACEMS3(cinfo, 1, JTRC_RLE_MAPGRAY, width, height, + 1 << source->header.cmaplen); + } else if (source->header.ncolors == 1 && source->header.ncmap == 3) { + source->visual = PSEUDOCOLOR; + TRACEMS3(cinfo, 1, JTRC_RLE_MAPPED, width, height, + 1 << source->header.cmaplen); + } else if (source->header.ncolors == 3 && source->header.ncmap == 3) { + source->visual = TRUECOLOR; + TRACEMS3(cinfo, 1, JTRC_RLE_FULLMAP, width, height, + 1 << source->header.cmaplen); + } else if (source->header.ncolors == 3 && source->header.ncmap == 0) { + source->visual = DIRECTCOLOR; + TRACEMS2(cinfo, 1, JTRC_RLE, width, height); + } else + ERREXIT(cinfo, JERR_RLE_UNSUPPORTED); + + if (source->visual == GRAYSCALE || source->visual == MAPPEDGRAY) { + cinfo->in_color_space = JCS_GRAYSCALE; + cinfo->input_components = 1; + } else { + cinfo->in_color_space = JCS_RGB; + cinfo->input_components = 3; + } + + /* + * A place to hold each scanline while it's converted. + * (GRAYSCALE scanlines don't need converting) + */ + if (source->visual != GRAYSCALE) { + source->rle_row = (rle_pixel**) (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) width, (JDIMENSION) cinfo->input_components); + } + + /* request a virtual array to hold the image */ + source->image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) (width * source->header.ncolors), + (JDIMENSION) height, (JDIMENSION) 1); + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + /* count file input as separate pass */ + progress->total_extra_passes++; + } +#endif + + source->pub.buffer_height = 1; +} + + +/* + * Read one row of pixels. + * Called only after load_image has read the image into the virtual array. + * Used for GRAYSCALE, MAPPEDGRAY, TRUECOLOR, and DIRECTCOLOR images. + */ + +METHODDEF(JDIMENSION) +get_rle_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + rle_source_ptr source = (rle_source_ptr) sinfo; + + source->row--; + source->pub.buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); + + return 1; +} + +/* + * Read one row of pixels. + * Called only after load_image has read the image into the virtual array. + * Used for PSEUDOCOLOR images. + */ + +METHODDEF(JDIMENSION) +get_pseudocolor_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + rle_source_ptr source = (rle_source_ptr) sinfo; + JSAMPROW src_row, dest_row; + JDIMENSION col; + rle_map *colormap; + int val; + + colormap = source->header.cmap; + dest_row = source->pub.buffer[0]; + source->row--; + src_row = * (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); + + for (col = cinfo->image_width; col > 0; col--) { + val = GETJSAMPLE(*src_row++); + *dest_row++ = (JSAMPLE) (colormap[val ] >> 8); + *dest_row++ = (JSAMPLE) (colormap[val + 256] >> 8); + *dest_row++ = (JSAMPLE) (colormap[val + 512] >> 8); + } + + return 1; +} + + +/* + * Load the image into a virtual array. We have to do this because RLE + * files start at the lower left while the JPEG standard has them starting + * in the upper left. This is called the first time we want to get a row + * of input. What we do is load the RLE data into the array and then call + * the appropriate routine to read one row from the array. Before returning, + * we set source->pub.get_pixel_rows so that subsequent calls go straight to + * the appropriate row-reading routine. + */ + +METHODDEF(JDIMENSION) +load_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + rle_source_ptr source = (rle_source_ptr) sinfo; + JDIMENSION row, col; + JSAMPROW scanline, red_ptr, green_ptr, blue_ptr; + rle_pixel **rle_row; + rle_map *colormap; + char channel; +#ifdef PROGRESS_REPORT + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; +#endif + + colormap = source->header.cmap; + rle_row = source->rle_row; + + /* Read the RLE data into our virtual array. + * We assume here that (a) rle_pixel is represented the same as JSAMPLE, + * and (b) we are not on a machine where FAR pointers differ from regular. + */ + RLE_CLR_BIT(source->header, RLE_ALPHA); /* don't read the alpha channel */ + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_limit = cinfo->image_height; + progress->pub.pass_counter = 0; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + + switch (source->visual) { + + case GRAYSCALE: + case PSEUDOCOLOR: + for (row = 0; row < cinfo->image_height; row++) { + rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); + rle_getrow(&source->header, rle_row); +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + break; + + case MAPPEDGRAY: + case TRUECOLOR: + for (row = 0; row < cinfo->image_height; row++) { + scanline = * (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); + rle_row = source->rle_row; + rle_getrow(&source->header, rle_row); + + for (col = 0; col < cinfo->image_width; col++) { + for (channel = 0; channel < source->header.ncolors; channel++) { + *scanline++ = (JSAMPLE) + (colormap[GETJSAMPLE(rle_row[channel][col]) + 256 * channel] >> 8); + } + } + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + break; + + case DIRECTCOLOR: + for (row = 0; row < cinfo->image_height; row++) { + scanline = * (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); + rle_getrow(&source->header, rle_row); + + red_ptr = rle_row[0]; + green_ptr = rle_row[1]; + blue_ptr = rle_row[2]; + + for (col = cinfo->image_width; col > 0; col--) { + *scanline++ = *red_ptr++; + *scanline++ = *green_ptr++; + *scanline++ = *blue_ptr++; + } + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + } + +#ifdef PROGRESS_REPORT + if (progress != NULL) + progress->completed_extra_passes++; +#endif + + /* Set up to call proper row-extraction routine in future */ + if (source->visual == PSEUDOCOLOR) { + source->pub.buffer = source->rle_row; + source->pub.get_pixel_rows = get_pseudocolor_row; + } else { + source->pub.get_pixel_rows = get_rle_row; + } + source->row = cinfo->image_height; + + /* And fetch the topmost (bottommost) row */ + return (*source->pub.get_pixel_rows) (cinfo, sinfo); +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + /* no work */ +} + + +/* + * The module selection routine for RLE format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_rle (j_compress_ptr cinfo) +{ + rle_source_ptr source; + + /* Create module interface object */ + source = (rle_source_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(rle_source_struct)); + /* Fill in method ptrs */ + source->pub.start_input = start_input_rle; + source->pub.finish_input = finish_input_rle; + source->pub.get_pixel_rows = load_image; + + return (cjpeg_source_ptr) source; +} + +#endif /* RLE_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/rdswitch.c b/src/dep/src/irrlicht/jpeglib/rdswitch.c index b915ad9..4f4bb4f 100644 --- a/src/dep/src/irrlicht/jpeglib/rdswitch.c +++ b/src/dep/src/irrlicht/jpeglib/rdswitch.c @@ -1,332 +1,332 @@ -/* - * rdswitch.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to process some of cjpeg's more complicated - * command-line switches. Switches processed here are: - * -qtables file Read quantization tables from text file - * -scans file Read scan script from text file - * -qslots N[,N,...] Set component quantization table selectors - * -sample HxV[,HxV,...] Set component sampling factors - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include /* to declare isdigit(), isspace() */ - - -LOCAL(int) -text_getc (FILE * file) -/* Read next char, skipping over any comments (# to end of line) */ -/* A comment/newline sequence is returned as a newline */ -{ - register int ch; - - ch = getc(file); - if (ch == '#') { - do { - ch = getc(file); - } while (ch != '\n' && ch != EOF); - } - return ch; -} - - -LOCAL(boolean) -read_text_integer (FILE * file, long * result, int * termchar) -/* Read an unsigned decimal integer from a file, store it in result */ -/* Reads one trailing character after the integer; returns it in termchar */ -{ - register int ch; - register long val; - - /* Skip any leading whitespace, detect EOF */ - do { - ch = text_getc(file); - if (ch == EOF) { - *termchar = ch; - return FALSE; - } - } while (isspace(ch)); - - if (! isdigit(ch)) { - *termchar = ch; - return FALSE; - } - - val = ch - '0'; - while ((ch = text_getc(file)) != EOF) { - if (! isdigit(ch)) - break; - val *= 10; - val += ch - '0'; - } - *result = val; - *termchar = ch; - return TRUE; -} - - -GLOBAL(boolean) -read_quant_tables (j_compress_ptr cinfo, char * filename, - int scale_factor, boolean force_baseline) -/* Read a set of quantization tables from the specified file. - * The file is plain ASCII text: decimal numbers with whitespace between. - * Comments preceded by '#' may be included in the file. - * There may be one to NUM_QUANT_TBLS tables in the file, each of 64 values. - * The tables are implicitly numbered 0,1,etc. - * NOTE: does not affect the qslots mapping, which will default to selecting - * table 0 for luminance (or primary) components, 1 for chrominance components. - * You must use -qslots if you want a different component->table mapping. - */ -{ - FILE * fp; - int tblno, i, termchar; - long val; - unsigned int table[DCTSIZE2]; - - if ((fp = fopen(filename, "r")) == NULL) { - fprintf(stderr, "Can't open table file %s\n", filename); - return FALSE; - } - tblno = 0; - - while (read_text_integer(fp, &val, &termchar)) { /* read 1st element of table */ - if (tblno >= NUM_QUANT_TBLS) { - fprintf(stderr, "Too many tables in file %s\n", filename); - fclose(fp); - return FALSE; - } - table[0] = (unsigned int) val; - for (i = 1; i < DCTSIZE2; i++) { - if (! read_text_integer(fp, &val, &termchar)) { - fprintf(stderr, "Invalid table data in file %s\n", filename); - fclose(fp); - return FALSE; - } - table[i] = (unsigned int) val; - } - jpeg_add_quant_table(cinfo, tblno, table, scale_factor, force_baseline); - tblno++; - } - - if (termchar != EOF) { - fprintf(stderr, "Non-numeric data in file %s\n", filename); - fclose(fp); - return FALSE; - } - - fclose(fp); - return TRUE; -} - - -#ifdef C_MULTISCAN_FILES_SUPPORTED - -LOCAL(boolean) -read_scan_integer (FILE * file, long * result, int * termchar) -/* Variant of read_text_integer that always looks for a non-space termchar; - * this simplifies parsing of punctuation in scan scripts. - */ -{ - register int ch; - - if (! read_text_integer(file, result, termchar)) - return FALSE; - ch = *termchar; - while (ch != EOF && isspace(ch)) - ch = text_getc(file); - if (isdigit(ch)) { /* oops, put it back */ - if (ungetc(ch, file) == EOF) - return FALSE; - ch = ' '; - } else { - /* Any separators other than ';' and ':' are ignored; - * this allows user to insert commas, etc, if desired. - */ - if (ch != EOF && ch != ';' && ch != ':') - ch = ' '; - } - *termchar = ch; - return TRUE; -} - - -GLOBAL(boolean) -read_scan_script (j_compress_ptr cinfo, char * filename) -/* Read a scan script from the specified text file. - * Each entry in the file defines one scan to be emitted. - * Entries are separated by semicolons ';'. - * An entry contains one to four component indexes, - * optionally followed by a colon ':' and four progressive-JPEG parameters. - * The component indexes denote which component(s) are to be transmitted - * in the current scan. The first component has index 0. - * Sequential JPEG is used if the progressive-JPEG parameters are omitted. - * The file is free format text: any whitespace may appear between numbers - * and the ':' and ';' punctuation marks. Also, other punctuation (such - * as commas or dashes) can be placed between numbers if desired. - * Comments preceded by '#' may be included in the file. - * Note: we do very little validity checking here; - * jcmaster.c will validate the script parameters. - */ -{ - FILE * fp; - int scanno, ncomps, termchar; - long val; - jpeg_scan_info * scanptr; -#define MAX_SCANS 100 /* quite arbitrary limit */ - jpeg_scan_info scans[MAX_SCANS]; - - if ((fp = fopen(filename, "r")) == NULL) { - fprintf(stderr, "Can't open scan definition file %s\n", filename); - return FALSE; - } - scanptr = scans; - scanno = 0; - - while (read_scan_integer(fp, &val, &termchar)) { - if (scanno >= MAX_SCANS) { - fprintf(stderr, "Too many scans defined in file %s\n", filename); - fclose(fp); - return FALSE; - } - scanptr->component_index[0] = (int) val; - ncomps = 1; - while (termchar == ' ') { - if (ncomps >= MAX_COMPS_IN_SCAN) { - fprintf(stderr, "Too many components in one scan in file %s\n", - filename); - fclose(fp); - return FALSE; - } - if (! read_scan_integer(fp, &val, &termchar)) - goto bogus; - scanptr->component_index[ncomps] = (int) val; - ncomps++; - } - scanptr->comps_in_scan = ncomps; - if (termchar == ':') { - if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') - goto bogus; - scanptr->Ss = (int) val; - if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') - goto bogus; - scanptr->Se = (int) val; - if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') - goto bogus; - scanptr->Ah = (int) val; - if (! read_scan_integer(fp, &val, &termchar)) - goto bogus; - scanptr->Al = (int) val; - } else { - /* set non-progressive parameters */ - scanptr->Ss = 0; - scanptr->Se = DCTSIZE2-1; - scanptr->Ah = 0; - scanptr->Al = 0; - } - if (termchar != ';' && termchar != EOF) { -bogus: - fprintf(stderr, "Invalid scan entry format in file %s\n", filename); - fclose(fp); - return FALSE; - } - scanptr++, scanno++; - } - - if (termchar != EOF) { - fprintf(stderr, "Non-numeric data in file %s\n", filename); - fclose(fp); - return FALSE; - } - - if (scanno > 0) { - /* Stash completed scan list in cinfo structure. - * NOTE: for cjpeg's use, JPOOL_IMAGE is the right lifetime for this data, - * but if you want to compress multiple images you'd want JPOOL_PERMANENT. - */ - scanptr = (jpeg_scan_info *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - scanno * SIZEOF(jpeg_scan_info)); - MEMCOPY(scanptr, scans, scanno * SIZEOF(jpeg_scan_info)); - cinfo->scan_info = scanptr; - cinfo->num_scans = scanno; - } - - fclose(fp); - return TRUE; -} - -#endif /* C_MULTISCAN_FILES_SUPPORTED */ - - -GLOBAL(boolean) -set_quant_slots (j_compress_ptr cinfo, char *arg) -/* Process a quantization-table-selectors parameter string, of the form - * N[,N,...] - * If there are more components than parameters, the last value is replicated. - */ -{ - int val = 0; /* default table # */ - int ci; - char ch; - - for (ci = 0; ci < MAX_COMPONENTS; ci++) { - if (*arg) { - ch = ','; /* if not set by sscanf, will be ',' */ - if (sscanf(arg, "%d%c", &val, &ch) < 1) - return FALSE; - if (ch != ',') /* syntax check */ - return FALSE; - if (val < 0 || val >= NUM_QUANT_TBLS) { - fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n", - NUM_QUANT_TBLS-1); - return FALSE; - } - cinfo->comp_info[ci].quant_tbl_no = val; - while (*arg && *arg++ != ',') /* advance to next segment of arg string */ - ; - } else { - /* reached end of parameter, set remaining components to last table */ - cinfo->comp_info[ci].quant_tbl_no = val; - } - } - return TRUE; -} - - -GLOBAL(boolean) -set_sample_factors (j_compress_ptr cinfo, char *arg) -/* Process a sample-factors parameter string, of the form - * HxV[,HxV,...] - * If there are more components than parameters, "1x1" is assumed for the rest. - */ -{ - int ci, val1, val2; - char ch1, ch2; - - for (ci = 0; ci < MAX_COMPONENTS; ci++) { - if (*arg) { - ch2 = ','; /* if not set by sscanf, will be ',' */ - if (sscanf(arg, "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3) - return FALSE; - if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */ - return FALSE; - if (val1 <= 0 || val1 > 4 || val2 <= 0 || val2 > 4) { - fprintf(stderr, "JPEG sampling factors must be 1..4\n"); - return FALSE; - } - cinfo->comp_info[ci].h_samp_factor = val1; - cinfo->comp_info[ci].v_samp_factor = val2; - while (*arg && *arg++ != ',') /* advance to next segment of arg string */ - ; - } else { - /* reached end of parameter, set remaining components to 1x1 sampling */ - cinfo->comp_info[ci].h_samp_factor = 1; - cinfo->comp_info[ci].v_samp_factor = 1; - } - } - return TRUE; -} +/* + * rdswitch.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to process some of cjpeg's more complicated + * command-line switches. Switches processed here are: + * -qtables file Read quantization tables from text file + * -scans file Read scan script from text file + * -qslots N[,N,...] Set component quantization table selectors + * -sample HxV[,HxV,...] Set component sampling factors + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include /* to declare isdigit(), isspace() */ + + +LOCAL(int) +text_getc (FILE * file) +/* Read next char, skipping over any comments (# to end of line) */ +/* A comment/newline sequence is returned as a newline */ +{ + register int ch; + + ch = getc(file); + if (ch == '#') { + do { + ch = getc(file); + } while (ch != '\n' && ch != EOF); + } + return ch; +} + + +LOCAL(boolean) +read_text_integer (FILE * file, long * result, int * termchar) +/* Read an unsigned decimal integer from a file, store it in result */ +/* Reads one trailing character after the integer; returns it in termchar */ +{ + register int ch; + register long val; + + /* Skip any leading whitespace, detect EOF */ + do { + ch = text_getc(file); + if (ch == EOF) { + *termchar = ch; + return FALSE; + } + } while (isspace(ch)); + + if (! isdigit(ch)) { + *termchar = ch; + return FALSE; + } + + val = ch - '0'; + while ((ch = text_getc(file)) != EOF) { + if (! isdigit(ch)) + break; + val *= 10; + val += ch - '0'; + } + *result = val; + *termchar = ch; + return TRUE; +} + + +GLOBAL(boolean) +read_quant_tables (j_compress_ptr cinfo, char * filename, + int scale_factor, boolean force_baseline) +/* Read a set of quantization tables from the specified file. + * The file is plain ASCII text: decimal numbers with whitespace between. + * Comments preceded by '#' may be included in the file. + * There may be one to NUM_QUANT_TBLS tables in the file, each of 64 values. + * The tables are implicitly numbered 0,1,etc. + * NOTE: does not affect the qslots mapping, which will default to selecting + * table 0 for luminance (or primary) components, 1 for chrominance components. + * You must use -qslots if you want a different component->table mapping. + */ +{ + FILE * fp; + int tblno, i, termchar; + long val; + unsigned int table[DCTSIZE2]; + + if ((fp = fopen(filename, "r")) == NULL) { + fprintf(stderr, "Can't open table file %s\n", filename); + return FALSE; + } + tblno = 0; + + while (read_text_integer(fp, &val, &termchar)) { /* read 1st element of table */ + if (tblno >= NUM_QUANT_TBLS) { + fprintf(stderr, "Too many tables in file %s\n", filename); + fclose(fp); + return FALSE; + } + table[0] = (unsigned int) val; + for (i = 1; i < DCTSIZE2; i++) { + if (! read_text_integer(fp, &val, &termchar)) { + fprintf(stderr, "Invalid table data in file %s\n", filename); + fclose(fp); + return FALSE; + } + table[i] = (unsigned int) val; + } + jpeg_add_quant_table(cinfo, tblno, table, scale_factor, force_baseline); + tblno++; + } + + if (termchar != EOF) { + fprintf(stderr, "Non-numeric data in file %s\n", filename); + fclose(fp); + return FALSE; + } + + fclose(fp); + return TRUE; +} + + +#ifdef C_MULTISCAN_FILES_SUPPORTED + +LOCAL(boolean) +read_scan_integer (FILE * file, long * result, int * termchar) +/* Variant of read_text_integer that always looks for a non-space termchar; + * this simplifies parsing of punctuation in scan scripts. + */ +{ + register int ch; + + if (! read_text_integer(file, result, termchar)) + return FALSE; + ch = *termchar; + while (ch != EOF && isspace(ch)) + ch = text_getc(file); + if (isdigit(ch)) { /* oops, put it back */ + if (ungetc(ch, file) == EOF) + return FALSE; + ch = ' '; + } else { + /* Any separators other than ';' and ':' are ignored; + * this allows user to insert commas, etc, if desired. + */ + if (ch != EOF && ch != ';' && ch != ':') + ch = ' '; + } + *termchar = ch; + return TRUE; +} + + +GLOBAL(boolean) +read_scan_script (j_compress_ptr cinfo, char * filename) +/* Read a scan script from the specified text file. + * Each entry in the file defines one scan to be emitted. + * Entries are separated by semicolons ';'. + * An entry contains one to four component indexes, + * optionally followed by a colon ':' and four progressive-JPEG parameters. + * The component indexes denote which component(s) are to be transmitted + * in the current scan. The first component has index 0. + * Sequential JPEG is used if the progressive-JPEG parameters are omitted. + * The file is free format text: any whitespace may appear between numbers + * and the ':' and ';' punctuation marks. Also, other punctuation (such + * as commas or dashes) can be placed between numbers if desired. + * Comments preceded by '#' may be included in the file. + * Note: we do very little validity checking here; + * jcmaster.c will validate the script parameters. + */ +{ + FILE * fp; + int scanno, ncomps, termchar; + long val; + jpeg_scan_info * scanptr; +#define MAX_SCANS 100 /* quite arbitrary limit */ + jpeg_scan_info scans[MAX_SCANS]; + + if ((fp = fopen(filename, "r")) == NULL) { + fprintf(stderr, "Can't open scan definition file %s\n", filename); + return FALSE; + } + scanptr = scans; + scanno = 0; + + while (read_scan_integer(fp, &val, &termchar)) { + if (scanno >= MAX_SCANS) { + fprintf(stderr, "Too many scans defined in file %s\n", filename); + fclose(fp); + return FALSE; + } + scanptr->component_index[0] = (int) val; + ncomps = 1; + while (termchar == ' ') { + if (ncomps >= MAX_COMPS_IN_SCAN) { + fprintf(stderr, "Too many components in one scan in file %s\n", + filename); + fclose(fp); + return FALSE; + } + if (! read_scan_integer(fp, &val, &termchar)) + goto bogus; + scanptr->component_index[ncomps] = (int) val; + ncomps++; + } + scanptr->comps_in_scan = ncomps; + if (termchar == ':') { + if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') + goto bogus; + scanptr->Ss = (int) val; + if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') + goto bogus; + scanptr->Se = (int) val; + if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') + goto bogus; + scanptr->Ah = (int) val; + if (! read_scan_integer(fp, &val, &termchar)) + goto bogus; + scanptr->Al = (int) val; + } else { + /* set non-progressive parameters */ + scanptr->Ss = 0; + scanptr->Se = DCTSIZE2-1; + scanptr->Ah = 0; + scanptr->Al = 0; + } + if (termchar != ';' && termchar != EOF) { +bogus: + fprintf(stderr, "Invalid scan entry format in file %s\n", filename); + fclose(fp); + return FALSE; + } + scanptr++, scanno++; + } + + if (termchar != EOF) { + fprintf(stderr, "Non-numeric data in file %s\n", filename); + fclose(fp); + return FALSE; + } + + if (scanno > 0) { + /* Stash completed scan list in cinfo structure. + * NOTE: for cjpeg's use, JPOOL_IMAGE is the right lifetime for this data, + * but if you want to compress multiple images you'd want JPOOL_PERMANENT. + */ + scanptr = (jpeg_scan_info *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + scanno * SIZEOF(jpeg_scan_info)); + MEMCOPY(scanptr, scans, scanno * SIZEOF(jpeg_scan_info)); + cinfo->scan_info = scanptr; + cinfo->num_scans = scanno; + } + + fclose(fp); + return TRUE; +} + +#endif /* C_MULTISCAN_FILES_SUPPORTED */ + + +GLOBAL(boolean) +set_quant_slots (j_compress_ptr cinfo, char *arg) +/* Process a quantization-table-selectors parameter string, of the form + * N[,N,...] + * If there are more components than parameters, the last value is replicated. + */ +{ + int val = 0; /* default table # */ + int ci; + char ch; + + for (ci = 0; ci < MAX_COMPONENTS; ci++) { + if (*arg) { + ch = ','; /* if not set by sscanf, will be ',' */ + if (sscanf(arg, "%d%c", &val, &ch) < 1) + return FALSE; + if (ch != ',') /* syntax check */ + return FALSE; + if (val < 0 || val >= NUM_QUANT_TBLS) { + fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n", + NUM_QUANT_TBLS-1); + return FALSE; + } + cinfo->comp_info[ci].quant_tbl_no = val; + while (*arg && *arg++ != ',') /* advance to next segment of arg string */ + ; + } else { + /* reached end of parameter, set remaining components to last table */ + cinfo->comp_info[ci].quant_tbl_no = val; + } + } + return TRUE; +} + + +GLOBAL(boolean) +set_sample_factors (j_compress_ptr cinfo, char *arg) +/* Process a sample-factors parameter string, of the form + * HxV[,HxV,...] + * If there are more components than parameters, "1x1" is assumed for the rest. + */ +{ + int ci, val1, val2; + char ch1, ch2; + + for (ci = 0; ci < MAX_COMPONENTS; ci++) { + if (*arg) { + ch2 = ','; /* if not set by sscanf, will be ',' */ + if (sscanf(arg, "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3) + return FALSE; + if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */ + return FALSE; + if (val1 <= 0 || val1 > 4 || val2 <= 0 || val2 > 4) { + fprintf(stderr, "JPEG sampling factors must be 1..4\n"); + return FALSE; + } + cinfo->comp_info[ci].h_samp_factor = val1; + cinfo->comp_info[ci].v_samp_factor = val2; + while (*arg && *arg++ != ',') /* advance to next segment of arg string */ + ; + } else { + /* reached end of parameter, set remaining components to 1x1 sampling */ + cinfo->comp_info[ci].h_samp_factor = 1; + cinfo->comp_info[ci].v_samp_factor = 1; + } + } + return TRUE; +} diff --git a/src/dep/src/irrlicht/jpeglib/rdtarga.c b/src/dep/src/irrlicht/jpeglib/rdtarga.c index d7ffc33..4c2cd26 100644 --- a/src/dep/src/irrlicht/jpeglib/rdtarga.c +++ b/src/dep/src/irrlicht/jpeglib/rdtarga.c @@ -1,500 +1,500 @@ -/* - * rdtarga.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in Targa format. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed Targa format). - * - * Based on code contributed by Lee Daniel Crocker. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef TARGA_SUPPORTED - - -/* Macros to deal with unsigned chars as efficiently as compiler allows */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char U_CHAR; -#define UCH(x) ((int) (x)) -#else /* !HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char U_CHAR; -#define UCH(x) ((int) (x)) -#else -typedef char U_CHAR; -#define UCH(x) ((int) (x) & 0xFF) -#endif -#endif /* HAVE_UNSIGNED_CHAR */ - - -#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) - - -/* Private version of data source object */ - -typedef struct _tga_source_struct * tga_source_ptr; - -typedef struct _tga_source_struct { - struct cjpeg_source_struct pub; /* public fields */ - - j_compress_ptr cinfo; /* back link saves passing separate parm */ - - JSAMPARRAY colormap; /* Targa colormap (converted to my format) */ - - jvirt_sarray_ptr whole_image; /* Needed if funny input row order */ - JDIMENSION current_row; /* Current logical row number to read */ - - /* Pointer to routine to extract next Targa pixel from input file */ - JMETHOD(void, read_pixel, (tga_source_ptr sinfo)); - - /* Result of read_pixel is delivered here: */ - U_CHAR tga_pixel[4]; - - int pixel_size; /* Bytes per Targa pixel (1 to 4) */ - - /* State info for reading RLE-coded pixels; both counts must be init to 0 */ - int block_count; /* # of pixels remaining in RLE block */ - int dup_pixel_count; /* # of times to duplicate previous pixel */ - - /* This saves the correct pixel-row-expansion method for preload_image */ - JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); -} tga_source_struct; - - -/* For expanding 5-bit pixel values to 8-bit with best rounding */ - -static const UINT8 c5to8bits[32] = { - 0, 8, 16, 25, 33, 41, 49, 58, - 66, 74, 82, 90, 99, 107, 115, 123, - 132, 140, 148, 156, 165, 173, 181, 189, - 197, 206, 214, 222, 230, 239, 247, 255 -}; - - - -LOCAL(int) -read_byte (tga_source_ptr sinfo) -/* Read next byte from Targa file */ -{ - register FILE *infile = sinfo->pub.input_file; - register int c; - - if ((c = getc(infile)) == EOF) - ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); - return c; -} - - -LOCAL(void) -read_colormap (tga_source_ptr sinfo, int cmaplen, int mapentrysize) -/* Read the colormap from a Targa file */ -{ - int i; - - /* Presently only handles 24-bit BGR format */ - if (mapentrysize != 24) - ERREXIT(sinfo->cinfo, JERR_TGA_BADCMAP); - - for (i = 0; i < cmaplen; i++) { - sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); - } -} - - -/* - * read_pixel methods: get a single pixel from Targa file into tga_pixel[] - */ - -METHODDEF(void) -read_non_rle_pixel (tga_source_ptr sinfo) -/* Read one Targa pixel from the input file; no RLE expansion */ -{ - register FILE *infile = sinfo->pub.input_file; - register int i; - - for (i = 0; i < sinfo->pixel_size; i++) { - sinfo->tga_pixel[i] = (U_CHAR) getc(infile); - } -} - - -METHODDEF(void) -read_rle_pixel (tga_source_ptr sinfo) -/* Read one Targa pixel from the input file, expanding RLE data as needed */ -{ - register FILE *infile = sinfo->pub.input_file; - register int i; - - /* Duplicate previously read pixel? */ - if (sinfo->dup_pixel_count > 0) { - sinfo->dup_pixel_count--; - return; - } - - /* Time to read RLE block header? */ - if (--sinfo->block_count < 0) { /* decrement pixels remaining in block */ - i = read_byte(sinfo); - if (i & 0x80) { /* Start of duplicate-pixel block? */ - sinfo->dup_pixel_count = i & 0x7F; /* number of dups after this one */ - sinfo->block_count = 0; /* then read new block header */ - } else { - sinfo->block_count = i & 0x7F; /* number of pixels after this one */ - } - } - - /* Read next pixel */ - for (i = 0; i < sinfo->pixel_size; i++) { - sinfo->tga_pixel[i] = (U_CHAR) getc(infile); - } -} - - -/* - * Read one row of pixels. - * - * We provide several different versions depending on input file format. - */ - - -METHODDEF(JDIMENSION) -get_8bit_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 8-bit grayscale pixels */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); - } - return 1; -} - -METHODDEF(JDIMENSION) -get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 8-bit colormap indexes */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register int t; - register JSAMPROW ptr; - register JDIMENSION col; - register JSAMPARRAY colormap = source->colormap; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - t = UCH(source->tga_pixel[0]); - *ptr++ = colormap[0][t]; - *ptr++ = colormap[1][t]; - *ptr++ = colormap[2][t]; - } - return 1; -} - -METHODDEF(JDIMENSION) -get_16bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 16-bit pixels */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register int t; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - t = UCH(source->tga_pixel[0]); - t += UCH(source->tga_pixel[1]) << 8; - /* We expand 5 bit data to 8 bit sample width. - * The format of the 16-bit (LSB first) input word is - * xRRRRRGGGGGBBBBB - */ - ptr[2] = (JSAMPLE) c5to8bits[t & 0x1F]; - t >>= 5; - ptr[1] = (JSAMPLE) c5to8bits[t & 0x1F]; - t >>= 5; - ptr[0] = (JSAMPLE) c5to8bits[t & 0x1F]; - ptr += 3; - } - return 1; -} - -METHODDEF(JDIMENSION) -get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 24-bit pixels */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[2]); /* change BGR to RGB order */ - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[1]); - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); - } - return 1; -} - -/* - * Targa also defines a 32-bit pixel format with order B,G,R,A. - * We presently ignore the attribute byte, so the code for reading - * these pixels is identical to the 24-bit routine above. - * This works because the actual pixel length is only known to read_pixel. - */ - -#define get_32bit_row get_24bit_row - - -/* - * This method is for re-reading the input data in standard top-down - * row order. The entire image has already been read into whole_image - * with proper conversion of pixel format, but it's in a funny row order. - */ - -METHODDEF(JDIMENSION) -get_memory_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - JDIMENSION source_row; - - /* Compute row of source that maps to current_row of normal order */ - /* For now, assume image is bottom-up and not interlaced. */ - /* NEEDS WORK to support interlaced images! */ - source_row = cinfo->image_height - source->current_row - 1; - - /* Fetch that row from virtual array */ - source->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, - source_row, (JDIMENSION) 1, FALSE); - - source->current_row++; - return 1; -} - - -/* - * This method loads the image into whole_image during the first call on - * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call - * get_memory_row on subsequent calls. - */ - -METHODDEF(JDIMENSION) -preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - JDIMENSION row; - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - - /* Read the data into a virtual array in input-file row order. */ - for (row = 0; row < cinfo->image_height; row++) { - if (progress != NULL) { - progress->pub.pass_counter = (long) row; - progress->pub.pass_limit = (long) cinfo->image_height; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } - source->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, row, (JDIMENSION) 1, TRUE); - (*source->get_pixel_rows) (cinfo, sinfo); - } - if (progress != NULL) - progress->completed_extra_passes++; - - /* Set up to read from the virtual array in unscrambled order */ - source->pub.get_pixel_rows = get_memory_row; - source->current_row = 0; - /* And read the first row */ - return get_memory_row(cinfo, sinfo); -} - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - U_CHAR targaheader[18]; - int idlen, cmaptype, subtype, flags, interlace_type, components; - unsigned int width, height, maplen; - boolean is_bottom_up; - -#define GET_2B(offset) ((unsigned int) UCH(targaheader[offset]) + \ - (((unsigned int) UCH(targaheader[offset+1])) << 8)) - - if (! ReadOK(source->pub.input_file, targaheader, 18)) - ERREXIT(cinfo, JERR_INPUT_EOF); - - /* Pretend "15-bit" pixels are 16-bit --- we ignore attribute bit anyway */ - if (targaheader[16] == 15) - targaheader[16] = 16; - - idlen = UCH(targaheader[0]); - cmaptype = UCH(targaheader[1]); - subtype = UCH(targaheader[2]); - maplen = GET_2B(5); - width = GET_2B(12); - height = GET_2B(14); - source->pixel_size = UCH(targaheader[16]) >> 3; - flags = UCH(targaheader[17]); /* Image Descriptor byte */ - - is_bottom_up = ((flags & 0x20) == 0); /* bit 5 set => top-down */ - interlace_type = flags >> 6; /* bits 6/7 are interlace code */ - - if (cmaptype > 1 || /* cmaptype must be 0 or 1 */ - source->pixel_size < 1 || source->pixel_size > 4 || - (UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */ - interlace_type != 0) /* currently don't allow interlaced image */ - ERREXIT(cinfo, JERR_TGA_BADPARMS); - - if (subtype > 8) { - /* It's an RLE-coded file */ - source->read_pixel = read_rle_pixel; - source->block_count = source->dup_pixel_count = 0; - subtype -= 8; - } else { - /* Non-RLE file */ - source->read_pixel = read_non_rle_pixel; - } - - /* Now should have subtype 1, 2, or 3 */ - components = 3; /* until proven different */ - cinfo->in_color_space = JCS_RGB; - - switch (subtype) { - case 1: /* Colormapped image */ - if (source->pixel_size == 1 && cmaptype == 1) - source->get_pixel_rows = get_8bit_row; - else - ERREXIT(cinfo, JERR_TGA_BADPARMS); - TRACEMS2(cinfo, 1, JTRC_TGA_MAPPED, width, height); - break; - case 2: /* RGB image */ - switch (source->pixel_size) { - case 2: - source->get_pixel_rows = get_16bit_row; - break; - case 3: - source->get_pixel_rows = get_24bit_row; - break; - case 4: - source->get_pixel_rows = get_32bit_row; - break; - default: - ERREXIT(cinfo, JERR_TGA_BADPARMS); - break; - } - TRACEMS2(cinfo, 1, JTRC_TGA, width, height); - break; - case 3: /* Grayscale image */ - components = 1; - cinfo->in_color_space = JCS_GRAYSCALE; - if (source->pixel_size == 1) - source->get_pixel_rows = get_8bit_gray_row; - else - ERREXIT(cinfo, JERR_TGA_BADPARMS); - TRACEMS2(cinfo, 1, JTRC_TGA_GRAY, width, height); - break; - default: - ERREXIT(cinfo, JERR_TGA_BADPARMS); - break; - } - - if (is_bottom_up) { - /* Create a virtual array to buffer the upside-down image. */ - source->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) width * components, (JDIMENSION) height, (JDIMENSION) 1); - if (cinfo->progress != NULL) { - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - progress->total_extra_passes++; /* count file input as separate pass */ - } - /* source->pub.buffer will point to the virtual array. */ - source->pub.buffer_height = 1; /* in case anyone looks at it */ - source->pub.get_pixel_rows = preload_image; - } else { - /* Don't need a virtual array, but do need a one-row input buffer. */ - source->whole_image = NULL; - source->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) width * components, (JDIMENSION) 1); - source->pub.buffer_height = 1; - source->pub.get_pixel_rows = source->get_pixel_rows; - } - - while (idlen--) /* Throw away ID field */ - (void) read_byte(source); - - if (maplen > 0) { - if (maplen > 256 || GET_2B(3) != 0) - ERREXIT(cinfo, JERR_TGA_BADCMAP); - /* Allocate space to store the colormap */ - source->colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, (JDIMENSION) maplen, (JDIMENSION) 3); - /* and read it from the file */ - read_colormap(source, (int) maplen, UCH(targaheader[7])); - } else { - if (cmaptype) /* but you promised a cmap! */ - ERREXIT(cinfo, JERR_TGA_BADPARMS); - source->colormap = NULL; - } - - cinfo->input_components = components; - cinfo->data_precision = 8; - cinfo->image_width = width; - cinfo->image_height = height; -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for Targa format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_targa (j_compress_ptr cinfo) -{ - tga_source_ptr source; - - /* Create module interface object */ - source = (tga_source_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(tga_source_struct)); - source->cinfo = cinfo; /* make back link for subroutines */ - /* Fill in method ptrs, except get_pixel_rows which start_input sets */ - source->pub.start_input = start_input_tga; - source->pub.finish_input = finish_input_tga; - - return (cjpeg_source_ptr) source; -} - -#endif /* TARGA_SUPPORTED */ +/* + * rdtarga.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to read input images in Targa format. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume input from + * an ordinary stdio stream. They further assume that reading begins + * at the start of the file; start_input may need work if the + * user interface has already read some data (e.g., to determine that + * the file is indeed Targa format). + * + * Based on code contributed by Lee Daniel Crocker. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef TARGA_SUPPORTED + + +/* Macros to deal with unsigned chars as efficiently as compiler allows */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char U_CHAR; +#define UCH(x) ((int) (x)) +#else /* !HAVE_UNSIGNED_CHAR */ +#ifdef CHAR_IS_UNSIGNED +typedef char U_CHAR; +#define UCH(x) ((int) (x)) +#else +typedef char U_CHAR; +#define UCH(x) ((int) (x) & 0xFF) +#endif +#endif /* HAVE_UNSIGNED_CHAR */ + + +#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) + + +/* Private version of data source object */ + +typedef struct _tga_source_struct * tga_source_ptr; + +typedef struct _tga_source_struct { + struct cjpeg_source_struct pub; /* public fields */ + + j_compress_ptr cinfo; /* back link saves passing separate parm */ + + JSAMPARRAY colormap; /* Targa colormap (converted to my format) */ + + jvirt_sarray_ptr whole_image; /* Needed if funny input row order */ + JDIMENSION current_row; /* Current logical row number to read */ + + /* Pointer to routine to extract next Targa pixel from input file */ + JMETHOD(void, read_pixel, (tga_source_ptr sinfo)); + + /* Result of read_pixel is delivered here: */ + U_CHAR tga_pixel[4]; + + int pixel_size; /* Bytes per Targa pixel (1 to 4) */ + + /* State info for reading RLE-coded pixels; both counts must be init to 0 */ + int block_count; /* # of pixels remaining in RLE block */ + int dup_pixel_count; /* # of times to duplicate previous pixel */ + + /* This saves the correct pixel-row-expansion method for preload_image */ + JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, + cjpeg_source_ptr sinfo)); +} tga_source_struct; + + +/* For expanding 5-bit pixel values to 8-bit with best rounding */ + +static const UINT8 c5to8bits[32] = { + 0, 8, 16, 25, 33, 41, 49, 58, + 66, 74, 82, 90, 99, 107, 115, 123, + 132, 140, 148, 156, 165, 173, 181, 189, + 197, 206, 214, 222, 230, 239, 247, 255 +}; + + + +LOCAL(int) +read_byte (tga_source_ptr sinfo) +/* Read next byte from Targa file */ +{ + register FILE *infile = sinfo->pub.input_file; + register int c; + + if ((c = getc(infile)) == EOF) + ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); + return c; +} + + +LOCAL(void) +read_colormap (tga_source_ptr sinfo, int cmaplen, int mapentrysize) +/* Read the colormap from a Targa file */ +{ + int i; + + /* Presently only handles 24-bit BGR format */ + if (mapentrysize != 24) + ERREXIT(sinfo->cinfo, JERR_TGA_BADCMAP); + + for (i = 0; i < cmaplen; i++) { + sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); + } +} + + +/* + * read_pixel methods: get a single pixel from Targa file into tga_pixel[] + */ + +METHODDEF(void) +read_non_rle_pixel (tga_source_ptr sinfo) +/* Read one Targa pixel from the input file; no RLE expansion */ +{ + register FILE *infile = sinfo->pub.input_file; + register int i; + + for (i = 0; i < sinfo->pixel_size; i++) { + sinfo->tga_pixel[i] = (U_CHAR) getc(infile); + } +} + + +METHODDEF(void) +read_rle_pixel (tga_source_ptr sinfo) +/* Read one Targa pixel from the input file, expanding RLE data as needed */ +{ + register FILE *infile = sinfo->pub.input_file; + register int i; + + /* Duplicate previously read pixel? */ + if (sinfo->dup_pixel_count > 0) { + sinfo->dup_pixel_count--; + return; + } + + /* Time to read RLE block header? */ + if (--sinfo->block_count < 0) { /* decrement pixels remaining in block */ + i = read_byte(sinfo); + if (i & 0x80) { /* Start of duplicate-pixel block? */ + sinfo->dup_pixel_count = i & 0x7F; /* number of dups after this one */ + sinfo->block_count = 0; /* then read new block header */ + } else { + sinfo->block_count = i & 0x7F; /* number of pixels after this one */ + } + } + + /* Read next pixel */ + for (i = 0; i < sinfo->pixel_size; i++) { + sinfo->tga_pixel[i] = (U_CHAR) getc(infile); + } +} + + +/* + * Read one row of pixels. + * + * We provide several different versions depending on input file format. + */ + + +METHODDEF(JDIMENSION) +get_8bit_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 8-bit grayscale pixels */ +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + register JSAMPROW ptr; + register JDIMENSION col; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ + *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); + } + return 1; +} + +METHODDEF(JDIMENSION) +get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 8-bit colormap indexes */ +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + register int t; + register JSAMPROW ptr; + register JDIMENSION col; + register JSAMPARRAY colormap = source->colormap; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ + t = UCH(source->tga_pixel[0]); + *ptr++ = colormap[0][t]; + *ptr++ = colormap[1][t]; + *ptr++ = colormap[2][t]; + } + return 1; +} + +METHODDEF(JDIMENSION) +get_16bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 16-bit pixels */ +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + register int t; + register JSAMPROW ptr; + register JDIMENSION col; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ + t = UCH(source->tga_pixel[0]); + t += UCH(source->tga_pixel[1]) << 8; + /* We expand 5 bit data to 8 bit sample width. + * The format of the 16-bit (LSB first) input word is + * xRRRRRGGGGGBBBBB + */ + ptr[2] = (JSAMPLE) c5to8bits[t & 0x1F]; + t >>= 5; + ptr[1] = (JSAMPLE) c5to8bits[t & 0x1F]; + t >>= 5; + ptr[0] = (JSAMPLE) c5to8bits[t & 0x1F]; + ptr += 3; + } + return 1; +} + +METHODDEF(JDIMENSION) +get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 24-bit pixels */ +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + register JSAMPROW ptr; + register JDIMENSION col; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ + *ptr++ = (JSAMPLE) UCH(source->tga_pixel[2]); /* change BGR to RGB order */ + *ptr++ = (JSAMPLE) UCH(source->tga_pixel[1]); + *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); + } + return 1; +} + +/* + * Targa also defines a 32-bit pixel format with order B,G,R,A. + * We presently ignore the attribute byte, so the code for reading + * these pixels is identical to the 24-bit routine above. + * This works because the actual pixel length is only known to read_pixel. + */ + +#define get_32bit_row get_24bit_row + + +/* + * This method is for re-reading the input data in standard top-down + * row order. The entire image has already been read into whole_image + * with proper conversion of pixel format, but it's in a funny row order. + */ + +METHODDEF(JDIMENSION) +get_memory_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + JDIMENSION source_row; + + /* Compute row of source that maps to current_row of normal order */ + /* For now, assume image is bottom-up and not interlaced. */ + /* NEEDS WORK to support interlaced images! */ + source_row = cinfo->image_height - source->current_row - 1; + + /* Fetch that row from virtual array */ + source->pub.buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->whole_image, + source_row, (JDIMENSION) 1, FALSE); + + source->current_row++; + return 1; +} + + +/* + * This method loads the image into whole_image during the first call on + * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call + * get_memory_row on subsequent calls. + */ + +METHODDEF(JDIMENSION) +preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + JDIMENSION row; + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + + /* Read the data into a virtual array in input-file row order. */ + for (row = 0; row < cinfo->image_height; row++) { + if (progress != NULL) { + progress->pub.pass_counter = (long) row; + progress->pub.pass_limit = (long) cinfo->image_height; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } + source->pub.buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->whole_image, row, (JDIMENSION) 1, TRUE); + (*source->get_pixel_rows) (cinfo, sinfo); + } + if (progress != NULL) + progress->completed_extra_passes++; + + /* Set up to read from the virtual array in unscrambled order */ + source->pub.get_pixel_rows = get_memory_row; + source->current_row = 0; + /* And read the first row */ + return get_memory_row(cinfo, sinfo); +} + + +/* + * Read the file header; return image size and component count. + */ + +METHODDEF(void) +start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + U_CHAR targaheader[18]; + int idlen, cmaptype, subtype, flags, interlace_type, components; + unsigned int width, height, maplen; + boolean is_bottom_up; + +#define GET_2B(offset) ((unsigned int) UCH(targaheader[offset]) + \ + (((unsigned int) UCH(targaheader[offset+1])) << 8)) + + if (! ReadOK(source->pub.input_file, targaheader, 18)) + ERREXIT(cinfo, JERR_INPUT_EOF); + + /* Pretend "15-bit" pixels are 16-bit --- we ignore attribute bit anyway */ + if (targaheader[16] == 15) + targaheader[16] = 16; + + idlen = UCH(targaheader[0]); + cmaptype = UCH(targaheader[1]); + subtype = UCH(targaheader[2]); + maplen = GET_2B(5); + width = GET_2B(12); + height = GET_2B(14); + source->pixel_size = UCH(targaheader[16]) >> 3; + flags = UCH(targaheader[17]); /* Image Descriptor byte */ + + is_bottom_up = ((flags & 0x20) == 0); /* bit 5 set => top-down */ + interlace_type = flags >> 6; /* bits 6/7 are interlace code */ + + if (cmaptype > 1 || /* cmaptype must be 0 or 1 */ + source->pixel_size < 1 || source->pixel_size > 4 || + (UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */ + interlace_type != 0) /* currently don't allow interlaced image */ + ERREXIT(cinfo, JERR_TGA_BADPARMS); + + if (subtype > 8) { + /* It's an RLE-coded file */ + source->read_pixel = read_rle_pixel; + source->block_count = source->dup_pixel_count = 0; + subtype -= 8; + } else { + /* Non-RLE file */ + source->read_pixel = read_non_rle_pixel; + } + + /* Now should have subtype 1, 2, or 3 */ + components = 3; /* until proven different */ + cinfo->in_color_space = JCS_RGB; + + switch (subtype) { + case 1: /* Colormapped image */ + if (source->pixel_size == 1 && cmaptype == 1) + source->get_pixel_rows = get_8bit_row; + else + ERREXIT(cinfo, JERR_TGA_BADPARMS); + TRACEMS2(cinfo, 1, JTRC_TGA_MAPPED, width, height); + break; + case 2: /* RGB image */ + switch (source->pixel_size) { + case 2: + source->get_pixel_rows = get_16bit_row; + break; + case 3: + source->get_pixel_rows = get_24bit_row; + break; + case 4: + source->get_pixel_rows = get_32bit_row; + break; + default: + ERREXIT(cinfo, JERR_TGA_BADPARMS); + break; + } + TRACEMS2(cinfo, 1, JTRC_TGA, width, height); + break; + case 3: /* Grayscale image */ + components = 1; + cinfo->in_color_space = JCS_GRAYSCALE; + if (source->pixel_size == 1) + source->get_pixel_rows = get_8bit_gray_row; + else + ERREXIT(cinfo, JERR_TGA_BADPARMS); + TRACEMS2(cinfo, 1, JTRC_TGA_GRAY, width, height); + break; + default: + ERREXIT(cinfo, JERR_TGA_BADPARMS); + break; + } + + if (is_bottom_up) { + /* Create a virtual array to buffer the upside-down image. */ + source->whole_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) width * components, (JDIMENSION) height, (JDIMENSION) 1); + if (cinfo->progress != NULL) { + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + progress->total_extra_passes++; /* count file input as separate pass */ + } + /* source->pub.buffer will point to the virtual array. */ + source->pub.buffer_height = 1; /* in case anyone looks at it */ + source->pub.get_pixel_rows = preload_image; + } else { + /* Don't need a virtual array, but do need a one-row input buffer. */ + source->whole_image = NULL; + source->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) width * components, (JDIMENSION) 1); + source->pub.buffer_height = 1; + source->pub.get_pixel_rows = source->get_pixel_rows; + } + + while (idlen--) /* Throw away ID field */ + (void) read_byte(source); + + if (maplen > 0) { + if (maplen > 256 || GET_2B(3) != 0) + ERREXIT(cinfo, JERR_TGA_BADCMAP); + /* Allocate space to store the colormap */ + source->colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (JDIMENSION) maplen, (JDIMENSION) 3); + /* and read it from the file */ + read_colormap(source, (int) maplen, UCH(targaheader[7])); + } else { + if (cmaptype) /* but you promised a cmap! */ + ERREXIT(cinfo, JERR_TGA_BADPARMS); + source->colormap = NULL; + } + + cinfo->input_components = components; + cinfo->data_precision = 8; + cinfo->image_width = width; + cinfo->image_height = height; +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + /* no work */ +} + + +/* + * The module selection routine for Targa format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_targa (j_compress_ptr cinfo) +{ + tga_source_ptr source; + + /* Create module interface object */ + source = (tga_source_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(tga_source_struct)); + source->cinfo = cinfo; /* make back link for subroutines */ + /* Fill in method ptrs, except get_pixel_rows which start_input sets */ + source->pub.start_input = start_input_tga; + source->pub.finish_input = finish_input_tga; + + return (cjpeg_source_ptr) source; +} + +#endif /* TARGA_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/structure.doc b/src/dep/src/irrlicht/jpeglib/structure.doc index 4179e48..51c9def 100644 --- a/src/dep/src/irrlicht/jpeglib/structure.doc +++ b/src/dep/src/irrlicht/jpeglib/structure.doc @@ -1,948 +1,948 @@ -IJG JPEG LIBRARY: SYSTEM ARCHITECTURE - -Copyright (C) 1991-1995, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -This file provides an overview of the architecture of the IJG JPEG software; -that is, the functions of the various modules in the system and the interfaces -between modules. For more precise details about any data structure or calling -convention, see the include files and comments in the source code. - -We assume that the reader is already somewhat familiar with the JPEG standard. -The README file includes references for learning about JPEG. The file -libjpeg.doc describes the library from the viewpoint of an application -programmer using the library; it's best to read that file before this one. -Also, the file coderules.doc describes the coding style conventions we use. - -In this document, JPEG-specific terminology follows the JPEG standard: - A "component" means a color channel, e.g., Red or Luminance. - A "sample" is a single component value (i.e., one number in the image data). - A "coefficient" is a frequency coefficient (a DCT transform output number). - A "block" is an 8x8 group of samples or coefficients. - An "MCU" (minimum coded unit) is an interleaved set of blocks of size - determined by the sampling factors, or a single block in a - noninterleaved scan. -We do not use the terms "pixel" and "sample" interchangeably. When we say -pixel, we mean an element of the full-size image, while a sample is an element -of the downsampled image. Thus the number of samples may vary across -components while the number of pixels does not. (This terminology is not used -rigorously throughout the code, but it is used in places where confusion would -otherwise result.) - - -*** System features *** - -The IJG distribution contains two parts: - * A subroutine library for JPEG compression and decompression. - * cjpeg/djpeg, two sample applications that use the library to transform - JFIF JPEG files to and from several other image formats. -cjpeg/djpeg are of no great intellectual complexity: they merely add a simple -command-line user interface and I/O routines for several uncompressed image -formats. This document concentrates on the library itself. - -We desire the library to be capable of supporting all JPEG baseline, extended -sequential, and progressive DCT processes. Hierarchical processes are not -supported. - -The library does not support the lossless (spatial) JPEG process. Lossless -JPEG shares little or no code with lossy JPEG, and would normally be used -without the extensive pre- and post-processing provided by this library. -We feel that lossless JPEG is better handled by a separate library. - -Within these limits, any set of compression parameters allowed by the JPEG -spec should be readable for decompression. (We can be more restrictive about -what formats we can generate.) Although the system design allows for all -parameter values, some uncommon settings are not yet implemented and may -never be; nonintegral sampling ratios are the prime example. Furthermore, -we treat 8-bit vs. 12-bit data precision as a compile-time switch, not a -run-time option, because most machines can store 8-bit pixels much more -compactly than 12-bit. - -For legal reasons, JPEG arithmetic coding is not currently supported, but -extending the library to include it would be straightforward. - -By itself, the library handles only interchange JPEG datastreams --- in -particular the widely used JFIF file format. The library can be used by -surrounding code to process interchange or abbreviated JPEG datastreams that -are embedded in more complex file formats. (For example, libtiff uses this -library to implement JPEG compression within the TIFF file format.) - -The library includes a substantial amount of code that is not covered by the -JPEG standard but is necessary for typical applications of JPEG. These -functions preprocess the image before JPEG compression or postprocess it after -decompression. They include colorspace conversion, downsampling/upsampling, -and color quantization. This code can be omitted if not needed. - -A wide range of quality vs. speed tradeoffs are possible in JPEG processing, -and even more so in decompression postprocessing. The decompression library -provides multiple implementations that cover most of the useful tradeoffs, -ranging from very-high-quality down to fast-preview operation. On the -compression side we have generally not provided low-quality choices, since -compression is normally less time-critical. It should be understood that the -low-quality modes may not meet the JPEG standard's accuracy requirements; -nonetheless, they are useful for viewers. - - -*** Portability issues *** - -Portability is an essential requirement for the library. The key portability -issues that show up at the level of system architecture are: - -1. Memory usage. We want the code to be able to run on PC-class machines -with limited memory. Images should therefore be processed sequentially (in -strips), to avoid holding the whole image in memory at once. Where a -full-image buffer is necessary, we should be able to use either virtual memory -or temporary files. - -2. Near/far pointer distinction. To run efficiently on 80x86 machines, the -code should distinguish "small" objects (kept in near data space) from -"large" ones (kept in far data space). This is an annoying restriction, but -fortunately it does not impact code quality for less brain-damaged machines, -and the source code clutter turns out to be minimal with sufficient use of -pointer typedefs. - -3. Data precision. We assume that "char" is at least 8 bits, "short" and -"int" at least 16, "long" at least 32. The code will work fine with larger -data sizes, although memory may be used inefficiently in some cases. However, -the JPEG compressed datastream must ultimately appear on external storage as a -sequence of 8-bit bytes if it is to conform to the standard. This may pose a -problem on machines where char is wider than 8 bits. The library represents -compressed data as an array of values of typedef JOCTET. If no data type -exactly 8 bits wide is available, custom data source and data destination -modules must be written to unpack and pack the chosen JOCTET datatype into -8-bit external representation. - - -*** System overview *** - -The compressor and decompressor are each divided into two main sections: -the JPEG compressor or decompressor proper, and the preprocessing or -postprocessing functions. The interface between these two sections is the -image data that the official JPEG spec regards as its input or output: this -data is in the colorspace to be used for compression, and it is downsampled -to the sampling factors to be used. The preprocessing and postprocessing -steps are responsible for converting a normal image representation to or from -this form. (Those few applications that want to deal with YCbCr downsampled -data can skip the preprocessing or postprocessing step.) - -Looking more closely, the compressor library contains the following main -elements: - - Preprocessing: - * Color space conversion (e.g., RGB to YCbCr). - * Edge expansion and downsampling. Optionally, this step can do simple - smoothing --- this is often helpful for low-quality source data. - JPEG proper: - * MCU assembly, DCT, quantization. - * Entropy coding (sequential or progressive, Huffman or arithmetic). - -In addition to these modules we need overall control, marker generation, -and support code (memory management & error handling). There is also a -module responsible for physically writing the output data --- typically -this is just an interface to fwrite(), but some applications may need to -do something else with the data. - -The decompressor library contains the following main elements: - - JPEG proper: - * Entropy decoding (sequential or progressive, Huffman or arithmetic). - * Dequantization, inverse DCT, MCU disassembly. - Postprocessing: - * Upsampling. Optionally, this step may be able to do more general - rescaling of the image. - * Color space conversion (e.g., YCbCr to RGB). This step may also - provide gamma adjustment [ currently it does not ]. - * Optional color quantization (e.g., reduction to 256 colors). - * Optional color precision reduction (e.g., 24-bit to 15-bit color). - [This feature is not currently implemented.] - -We also need overall control, marker parsing, and a data source module. -The support code (memory management & error handling) can be shared with -the compression half of the library. - -There may be several implementations of each of these elements, particularly -in the decompressor, where a wide range of speed/quality tradeoffs is very -useful. It must be understood that some of the best speedups involve -merging adjacent steps in the pipeline. For example, upsampling, color space -conversion, and color quantization might all be done at once when using a -low-quality ordered-dither technique. The system architecture is designed to -allow such merging where appropriate. - - -Note: it is convenient to regard edge expansion (padding to block boundaries) -as a preprocessing/postprocessing function, even though the JPEG spec includes -it in compression/decompression. We do this because downsampling/upsampling -can be simplified a little if they work on padded data: it's not necessary to -have special cases at the right and bottom edges. Therefore the interface -buffer is always an integral number of blocks wide and high, and we expect -compression preprocessing to pad the source data properly. Padding will occur -only to the next block (8-sample) boundary. In an interleaved-scan situation, -additional dummy blocks may be used to fill out MCUs, but the MCU assembly and -disassembly logic will create or discard these blocks internally. (This is -advantageous for speed reasons, since we avoid DCTing the dummy blocks. -It also permits a small reduction in file size, because the compressor can -choose dummy block contents so as to minimize their size in compressed form. -Finally, it makes the interface buffer specification independent of whether -the file is actually interleaved or not.) Applications that wish to deal -directly with the downsampled data must provide similar buffering and padding -for odd-sized images. - - -*** Poor man's object-oriented programming *** - -It should be clear by now that we have a lot of quasi-independent processing -steps, many of which have several possible behaviors. To avoid cluttering the -code with lots of switch statements, we use a simple form of object-style -programming to separate out the different possibilities. - -For example, two different color quantization algorithms could be implemented -as two separate modules that present the same external interface; at runtime, -the calling code will access the proper module indirectly through an "object". - -We can get the limited features we need while staying within portable C. -The basic tool is a function pointer. An "object" is just a struct -containing one or more function pointer fields, each of which corresponds to -a method name in real object-oriented languages. During initialization we -fill in the function pointers with references to whichever module we have -determined we need to use in this run. Then invocation of the module is done -by indirecting through a function pointer; on most machines this is no more -expensive than a switch statement, which would be the only other way of -making the required run-time choice. The really significant benefit, of -course, is keeping the source code clean and well structured. - -We can also arrange to have private storage that varies between different -implementations of the same kind of object. We do this by making all the -module-specific object structs be separately allocated entities, which will -be accessed via pointers in the master compression or decompression struct. -The "public" fields or methods for a given kind of object are specified by -a commonly known struct. But a module's initialization code can allocate -a larger struct that contains the common struct as its first member, plus -additional private fields. With appropriate pointer casting, the module's -internal functions can access these private fields. (For a simple example, -see jdatadst.c, which implements the external interface specified by struct -jpeg_destination_mgr, but adds extra fields.) - -(Of course this would all be a lot easier if we were using C++, but we are -not yet prepared to assume that everyone has a C++ compiler.) - -An important benefit of this scheme is that it is easy to provide multiple -versions of any method, each tuned to a particular case. While a lot of -precalculation might be done to select an optimal implementation of a method, -the cost per invocation is constant. For example, the upsampling step might -have a "generic" method, plus one or more "hardwired" methods for the most -popular sampling factors; the hardwired methods would be faster because they'd -use straight-line code instead of for-loops. The cost to determine which -method to use is paid only once, at startup, and the selection criteria are -hidden from the callers of the method. - -This plan differs a little bit from usual object-oriented structures, in that -only one instance of each object class will exist during execution. The -reason for having the class structure is that on different runs we may create -different instances (choose to execute different modules). You can think of -the term "method" as denoting the common interface presented by a particular -set of interchangeable functions, and "object" as denoting a group of related -methods, or the total shared interface behavior of a group of modules. - - -*** Overall control structure *** - -We previously mentioned the need for overall control logic in the compression -and decompression libraries. In IJG implementations prior to v5, overall -control was mostly provided by "pipeline control" modules, which proved to be -large, unwieldy, and hard to understand. To improve the situation, the -control logic has been subdivided into multiple modules. The control modules -consist of: - -1. Master control for module selection and initialization. This has two -responsibilities: - - 1A. Startup initialization at the beginning of image processing. - The individual processing modules to be used in this run are selected - and given initialization calls. - - 1B. Per-pass control. This determines how many passes will be performed - and calls each active processing module to configure itself - appropriately at the beginning of each pass. End-of-pass processing, - where necessary, is also invoked from the master control module. - - Method selection is partially distributed, in that a particular processing - module may contain several possible implementations of a particular method, - which it will select among when given its initialization call. The master - control code need only be concerned with decisions that affect more than - one module. - -2. Data buffering control. A separate control module exists for each - inter-processing-step data buffer. This module is responsible for - invoking the processing steps that write or read that data buffer. - -Each buffer controller sees the world as follows: - -input data => processing step A => buffer => processing step B => output data - | | | - ------------------ controller ------------------ - -The controller knows the dataflow requirements of steps A and B: how much data -they want to accept in one chunk and how much they output in one chunk. Its -function is to manage its buffer and call A and B at the proper times. - -A data buffer control module may itself be viewed as a processing step by a -higher-level control module; thus the control modules form a binary tree with -elementary processing steps at the leaves of the tree. - -The control modules are objects. A considerable amount of flexibility can -be had by replacing implementations of a control module. For example: -* Merging of adjacent steps in the pipeline is done by replacing a control - module and its pair of processing-step modules with a single processing- - step module. (Hence the possible merges are determined by the tree of - control modules.) -* In some processing modes, a given interstep buffer need only be a "strip" - buffer large enough to accommodate the desired data chunk sizes. In other - modes, a full-image buffer is needed and several passes are required. - The control module determines which kind of buffer is used and manipulates - virtual array buffers as needed. One or both processing steps may be - unaware of the multi-pass behavior. - -In theory, we might be able to make all of the data buffer controllers -interchangeable and provide just one set of implementations for all. In -practice, each one contains considerable special-case processing for its -particular job. The buffer controller concept should be regarded as an -overall system structuring principle, not as a complete description of the -task performed by any one controller. - - -*** Compression object structure *** - -Here is a sketch of the logical structure of the JPEG compression library: - - |-- Colorspace conversion - |-- Preprocessing controller --| - | |-- Downsampling -Main controller --| - | |-- Forward DCT, quantize - |-- Coefficient controller --| - |-- Entropy encoding - -This sketch also describes the flow of control (subroutine calls) during -typical image data processing. Each of the components shown in the diagram is -an "object" which may have several different implementations available. One -or more source code files contain the actual implementation(s) of each object. - -The objects shown above are: - -* Main controller: buffer controller for the subsampled-data buffer, which - holds the preprocessed input data. This controller invokes preprocessing to - fill the subsampled-data buffer, and JPEG compression to empty it. There is - usually no need for a full-image buffer here; a strip buffer is adequate. - -* Preprocessing controller: buffer controller for the downsampling input data - buffer, which lies between colorspace conversion and downsampling. Note - that a unified conversion/downsampling module would probably replace this - controller entirely. - -* Colorspace conversion: converts application image data into the desired - JPEG color space; also changes the data from pixel-interleaved layout to - separate component planes. Processes one pixel row at a time. - -* Downsampling: performs reduction of chroma components as required. - Optionally may perform pixel-level smoothing as well. Processes a "row - group" at a time, where a row group is defined as Vmax pixel rows of each - component before downsampling, and Vk sample rows afterwards (remember Vk - differs across components). Some downsampling or smoothing algorithms may - require context rows above and below the current row group; the - preprocessing controller is responsible for supplying these rows via proper - buffering. The downsampler is responsible for edge expansion at the right - edge (i.e., extending each sample row to a multiple of 8 samples); but the - preprocessing controller is responsible for vertical edge expansion (i.e., - duplicating the bottom sample row as needed to make a multiple of 8 rows). - -* Coefficient controller: buffer controller for the DCT-coefficient data. - This controller handles MCU assembly, including insertion of dummy DCT - blocks when needed at the right or bottom edge. When performing - Huffman-code optimization or emitting a multiscan JPEG file, this - controller is responsible for buffering the full image. The equivalent of - one fully interleaved MCU row of subsampled data is processed per call, - even when the JPEG file is noninterleaved. - -* Forward DCT and quantization: Perform DCT, quantize, and emit coefficients. - Works on one or more DCT blocks at a time. (Note: the coefficients are now - emitted in normal array order, which the entropy encoder is expected to - convert to zigzag order as necessary. Prior versions of the IJG code did - the conversion to zigzag order within the quantization step.) - -* Entropy encoding: Perform Huffman or arithmetic entropy coding and emit the - coded data to the data destination module. Works on one MCU per call. - For progressive JPEG, the same DCT blocks are fed to the entropy coder - during each pass, and the coder must emit the appropriate subset of - coefficients. - -In addition to the above objects, the compression library includes these -objects: - -* Master control: determines the number of passes required, controls overall - and per-pass initialization of the other modules. - -* Marker writing: generates JPEG markers (except for RSTn, which is emitted - by the entropy encoder when needed). - -* Data destination manager: writes the output JPEG datastream to its final - destination (e.g., a file). The destination manager supplied with the - library knows how to write to a stdio stream; for other behaviors, the - surrounding application may provide its own destination manager. - -* Memory manager: allocates and releases memory, controls virtual arrays - (with backing store management, where required). - -* Error handler: performs formatting and output of error and trace messages; - determines handling of nonfatal errors. The surrounding application may - override some or all of this object's methods to change error handling. - -* Progress monitor: supports output of "percent-done" progress reports. - This object represents an optional callback to the surrounding application: - if wanted, it must be supplied by the application. - -The error handler, destination manager, and progress monitor objects are -defined as separate objects in order to simplify application-specific -customization of the JPEG library. A surrounding application may override -individual methods or supply its own all-new implementation of one of these -objects. The object interfaces for these objects are therefore treated as -part of the application interface of the library, whereas the other objects -are internal to the library. - -The error handler and memory manager are shared by JPEG compression and -decompression; the progress monitor, if used, may be shared as well. - - -*** Decompression object structure *** - -Here is a sketch of the logical structure of the JPEG decompression library: - - |-- Entropy decoding - |-- Coefficient controller --| - | |-- Dequantize, Inverse DCT -Main controller --| - | |-- Upsampling - |-- Postprocessing controller --| |-- Colorspace conversion - |-- Color quantization - |-- Color precision reduction - -As before, this diagram also represents typical control flow. The objects -shown are: - -* Main controller: buffer controller for the subsampled-data buffer, which - holds the output of JPEG decompression proper. This controller's primary - task is to feed the postprocessing procedure. Some upsampling algorithms - may require context rows above and below the current row group; when this - is true, the main controller is responsible for managing its buffer so as - to make context rows available. In the current design, the main buffer is - always a strip buffer; a full-image buffer is never required. - -* Coefficient controller: buffer controller for the DCT-coefficient data. - This controller handles MCU disassembly, including deletion of any dummy - DCT blocks at the right or bottom edge. When reading a multiscan JPEG - file, this controller is responsible for buffering the full image. - (Buffering DCT coefficients, rather than samples, is necessary to support - progressive JPEG.) The equivalent of one fully interleaved MCU row of - subsampled data is processed per call, even when the source JPEG file is - noninterleaved. - -* Entropy decoding: Read coded data from the data source module and perform - Huffman or arithmetic entropy decoding. Works on one MCU per call. - For progressive JPEG decoding, the coefficient controller supplies the prior - coefficients of each MCU (initially all zeroes), which the entropy decoder - modifies in each scan. - -* Dequantization and inverse DCT: like it says. Note that the coefficients - buffered by the coefficient controller have NOT been dequantized; we - merge dequantization and inverse DCT into a single step for speed reasons. - When scaled-down output is asked for, simplified DCT algorithms may be used - that emit only 1x1, 2x2, or 4x4 samples per DCT block, not the full 8x8. - Works on one DCT block at a time. - -* Postprocessing controller: buffer controller for the color quantization - input buffer, when quantization is in use. (Without quantization, this - controller just calls the upsampler.) For two-pass quantization, this - controller is responsible for buffering the full-image data. - -* Upsampling: restores chroma components to full size. (May support more - general output rescaling, too. Note that if undersized DCT outputs have - been emitted by the DCT module, this module must adjust so that properly - sized outputs are created.) Works on one row group at a time. This module - also calls the color conversion module, so its top level is effectively a - buffer controller for the upsampling->color conversion buffer. However, in - all but the highest-quality operating modes, upsampling and color - conversion are likely to be merged into a single step. - -* Colorspace conversion: convert from JPEG color space to output color space, - and change data layout from separate component planes to pixel-interleaved. - Works on one pixel row at a time. - -* Color quantization: reduce the data to colormapped form, using either an - externally specified colormap or an internally generated one. This module - is not used for full-color output. Works on one pixel row at a time; may - require two passes to generate a color map. Note that the output will - always be a single component representing colormap indexes. In the current - design, the output values are JSAMPLEs, so an 8-bit compilation cannot - quantize to more than 256 colors. This is unlikely to be a problem in - practice. - -* Color reduction: this module handles color precision reduction, e.g., - generating 15-bit color (5 bits/primary) from JPEG's 24-bit output. - Not quite clear yet how this should be handled... should we merge it with - colorspace conversion??? - -Note that some high-speed operating modes might condense the entire -postprocessing sequence to a single module (upsample, color convert, and -quantize in one step). - -In addition to the above objects, the decompression library includes these -objects: - -* Master control: determines the number of passes required, controls overall - and per-pass initialization of the other modules. This is subdivided into - input and output control: jdinput.c controls only input-side processing, - while jdmaster.c handles overall initialization and output-side control. - -* Marker reading: decodes JPEG markers (except for RSTn). - -* Data source manager: supplies the input JPEG datastream. The source - manager supplied with the library knows how to read from a stdio stream; - for other behaviors, the surrounding application may provide its own source - manager. - -* Memory manager: same as for compression library. - -* Error handler: same as for compression library. - -* Progress monitor: same as for compression library. - -As with compression, the data source manager, error handler, and progress -monitor are candidates for replacement by a surrounding application. - - -*** Decompression input and output separation *** - -To support efficient incremental display of progressive JPEG files, the -decompressor is divided into two sections that can run independently: - -1. Data input includes marker parsing, entropy decoding, and input into the - coefficient controller's DCT coefficient buffer. Note that this - processing is relatively cheap and fast. - -2. Data output reads from the DCT coefficient buffer and performs the IDCT - and all postprocessing steps. - -For a progressive JPEG file, the data input processing is allowed to get -arbitrarily far ahead of the data output processing. (This occurs only -if the application calls jpeg_consume_input(); otherwise input and output -run in lockstep, since the input section is called only when the output -section needs more data.) In this way the application can avoid making -extra display passes when data is arriving faster than the display pass -can run. Furthermore, it is possible to abort an output pass without -losing anything, since the coefficient buffer is read-only as far as the -output section is concerned. See libjpeg.doc for more detail. - -A full-image coefficient array is only created if the JPEG file has multiple -scans (or if the application specifies buffered-image mode anyway). When -reading a single-scan file, the coefficient controller normally creates only -a one-MCU buffer, so input and output processing must run in lockstep in this -case. jpeg_consume_input() is effectively a no-op in this situation. - -The main impact of dividing the decompressor in this fashion is that we must -be very careful with shared variables in the cinfo data structure. Each -variable that can change during the course of decompression must be -classified as belonging to data input or data output, and each section must -look only at its own variables. For example, the data output section may not -depend on any of the variables that describe the current scan in the JPEG -file, because these may change as the data input section advances into a new -scan. - -The progress monitor is (somewhat arbitrarily) defined to treat input of the -file as one pass when buffered-image mode is not used, and to ignore data -input work completely when buffered-image mode is used. Note that the -library has no reliable way to predict the number of passes when dealing -with a progressive JPEG file, nor can it predict the number of output passes -in buffered-image mode. So the work estimate is inherently bogus anyway. - -No comparable division is currently made in the compression library, because -there isn't any real need for it. - - -*** Data formats *** - -Arrays of pixel sample values use the following data structure: - - typedef something JSAMPLE; a pixel component value, 0..MAXJSAMPLE - typedef JSAMPLE *JSAMPROW; ptr to a row of samples - typedef JSAMPROW *JSAMPARRAY; ptr to a list of rows - typedef JSAMPARRAY *JSAMPIMAGE; ptr to a list of color-component arrays - -The basic element type JSAMPLE will typically be one of unsigned char, -(signed) char, or short. Short will be used if samples wider than 8 bits are -to be supported (this is a compile-time option). Otherwise, unsigned char is -used if possible. If the compiler only supports signed chars, then it is -necessary to mask off the value when reading. Thus, all reads of JSAMPLE -values must be coded as "GETJSAMPLE(value)", where the macro will be defined -as "((value) & 0xFF)" on signed-char machines and "((int) (value))" elsewhere. - -With these conventions, JSAMPLE values can be assumed to be >= 0. This helps -simplify correct rounding during downsampling, etc. The JPEG standard's -specification that sample values run from -128..127 is accommodated by -subtracting 128 just as the sample value is copied into the source array for -the DCT step (this will be an array of signed ints). Similarly, during -decompression the output of the IDCT step will be immediately shifted back to -0..255. (NB: different values are required when 12-bit samples are in use. -The code is written in terms of MAXJSAMPLE and CENTERJSAMPLE, which will be -defined as 255 and 128 respectively in an 8-bit implementation, and as 4095 -and 2048 in a 12-bit implementation.) - -We use a pointer per row, rather than a two-dimensional JSAMPLE array. This -choice costs only a small amount of memory and has several benefits: -* Code using the data structure doesn't need to know the allocated width of - the rows. This simplifies edge expansion/compression, since we can work - in an array that's wider than the logical picture width. -* Indexing doesn't require multiplication; this is a performance win on many - machines. -* Arrays with more than 64K total elements can be supported even on machines - where malloc() cannot allocate chunks larger than 64K. -* The rows forming a component array may be allocated at different times - without extra copying. This trick allows some speedups in smoothing steps - that need access to the previous and next rows. - -Note that each color component is stored in a separate array; we don't use the -traditional layout in which the components of a pixel are stored together. -This simplifies coding of modules that work on each component independently, -because they don't need to know how many components there are. Furthermore, -we can read or write each component to a temporary file independently, which -is helpful when dealing with noninterleaved JPEG files. - -In general, a specific sample value is accessed by code such as - GETJSAMPLE(image[colorcomponent][row][col]) -where col is measured from the image left edge, but row is measured from the -first sample row currently in memory. Either of the first two indexings can -be precomputed by copying the relevant pointer. - - -Since most image-processing applications prefer to work on images in which -the components of a pixel are stored together, the data passed to or from the -surrounding application uses the traditional convention: a single pixel is -represented by N consecutive JSAMPLE values, and an image row is an array of -(# of color components)*(image width) JSAMPLEs. One or more rows of data can -be represented by a pointer of type JSAMPARRAY in this scheme. This scheme is -converted to component-wise storage inside the JPEG library. (Applications -that want to skip JPEG preprocessing or postprocessing will have to contend -with component-wise storage.) - - -Arrays of DCT-coefficient values use the following data structure: - - typedef short JCOEF; a 16-bit signed integer - typedef JCOEF JBLOCK[DCTSIZE2]; an 8x8 block of coefficients - typedef JBLOCK *JBLOCKROW; ptr to one horizontal row of 8x8 blocks - typedef JBLOCKROW *JBLOCKARRAY; ptr to a list of such rows - typedef JBLOCKARRAY *JBLOCKIMAGE; ptr to a list of color component arrays - -The underlying type is at least a 16-bit signed integer; while "short" is big -enough on all machines of interest, on some machines it is preferable to use -"int" for speed reasons, despite the storage cost. Coefficients are grouped -into 8x8 blocks (but we always use #defines DCTSIZE and DCTSIZE2 rather than -"8" and "64"). - -The contents of a coefficient block may be in either "natural" or zigzagged -order, and may be true values or divided by the quantization coefficients, -depending on where the block is in the processing pipeline. In the current -library, coefficient blocks are kept in natural order everywhere; the entropy -codecs zigzag or dezigzag the data as it is written or read. The blocks -contain quantized coefficients everywhere outside the DCT/IDCT subsystems. -(This latter decision may need to be revisited to support variable -quantization a la JPEG Part 3.) - -Notice that the allocation unit is now a row of 8x8 blocks, corresponding to -eight rows of samples. Otherwise the structure is much the same as for -samples, and for the same reasons. - -On machines where malloc() can't handle a request bigger than 64Kb, this data -structure limits us to rows of less than 512 JBLOCKs, or a picture width of -4000+ pixels. This seems an acceptable restriction. - - -On 80x86 machines, the bottom-level pointer types (JSAMPROW and JBLOCKROW) -must be declared as "far" pointers, but the upper levels can be "near" -(implying that the pointer lists are allocated in the DS segment). -We use a #define symbol FAR, which expands to the "far" keyword when -compiling on 80x86 machines and to nothing elsewhere. - - -*** Suspendable processing *** - -In some applications it is desirable to use the JPEG library as an -incremental, memory-to-memory filter. In this situation the data source or -destination may be a limited-size buffer, and we can't rely on being able to -empty or refill the buffer at arbitrary times. Instead the application would -like to have control return from the library at buffer overflow/underrun, and -then resume compression or decompression at a later time. - -This scenario is supported for simple cases. (For anything more complex, we -recommend that the application "bite the bullet" and develop real multitasking -capability.) The libjpeg.doc file goes into more detail about the usage and -limitations of this capability; here we address the implications for library -structure. - -The essence of the problem is that the entropy codec (coder or decoder) must -be prepared to stop at arbitrary times. In turn, the controllers that call -the entropy codec must be able to stop before having produced or consumed all -the data that they normally would handle in one call. That part is reasonably -straightforward: we make the controller call interfaces include "progress -counters" which indicate the number of data chunks successfully processed, and -we require callers to test the counter rather than just assume all of the data -was processed. - -Rather than trying to restart at an arbitrary point, the current Huffman -codecs are designed to restart at the beginning of the current MCU after a -suspension due to buffer overflow/underrun. At the start of each call, the -codec's internal state is loaded from permanent storage (in the JPEG object -structures) into local variables. On successful completion of the MCU, the -permanent state is updated. (This copying is not very expensive, and may even -lead to *improved* performance if the local variables can be registerized.) -If a suspension occurs, the codec simply returns without updating the state, -thus effectively reverting to the start of the MCU. Note that this implies -leaving some data unprocessed in the source/destination buffer (ie, the -compressed partial MCU). The data source/destination module interfaces are -specified so as to make this possible. This also implies that the data buffer -must be large enough to hold a worst-case compressed MCU; a couple thousand -bytes should be enough. - -In a successive-approximation AC refinement scan, the progressive Huffman -decoder has to be able to undo assignments of newly nonzero coefficients if it -suspends before the MCU is complete, since decoding requires distinguishing -previously-zero and previously-nonzero coefficients. This is a bit tedious -but probably won't have much effect on performance. Other variants of Huffman -decoding need not worry about this, since they will just store the same values -again if forced to repeat the MCU. - -This approach would probably not work for an arithmetic codec, since its -modifiable state is quite large and couldn't be copied cheaply. Instead it -would have to suspend and resume exactly at the point of the buffer end. - -The JPEG marker reader is designed to cope with suspension at an arbitrary -point. It does so by backing up to the start of the marker parameter segment, -so the data buffer must be big enough to hold the largest marker of interest. -Again, a couple KB should be adequate. (A special "skip" convention is used -to bypass COM and APPn markers, so these can be larger than the buffer size -without causing problems; otherwise a 64K buffer would be needed in the worst -case.) - -The JPEG marker writer currently does *not* cope with suspension. I feel that -this is not necessary; it is much easier simply to require the application to -ensure there is enough buffer space before starting. (An empty 2K buffer is -more than sufficient for the header markers; and ensuring there are a dozen or -two bytes available before calling jpeg_finish_compress() will suffice for the -trailer.) This would not work for writing multi-scan JPEG files, but -we simply do not intend to support that capability with suspension. - - -*** Memory manager services *** - -The JPEG library's memory manager controls allocation and deallocation of -memory, and it manages large "virtual" data arrays on machines where the -operating system does not provide virtual memory. Note that the same -memory manager serves both compression and decompression operations. - -In all cases, allocated objects are tied to a particular compression or -decompression master record, and they will be released when that master -record is destroyed. - -The memory manager does not provide explicit deallocation of objects. -Instead, objects are created in "pools" of free storage, and a whole pool -can be freed at once. This approach helps prevent storage-leak bugs, and -it speeds up operations whenever malloc/free are slow (as they often are). -The pools can be regarded as lifetime identifiers for objects. Two -pools/lifetimes are defined: - * JPOOL_PERMANENT lasts until master record is destroyed - * JPOOL_IMAGE lasts until done with image (JPEG datastream) -Permanent lifetime is used for parameters and tables that should be carried -across from one datastream to another; this includes all application-visible -parameters. Image lifetime is used for everything else. (A third lifetime, -JPOOL_PASS = one processing pass, was originally planned. However it was -dropped as not being worthwhile. The actual usage patterns are such that the -peak memory usage would be about the same anyway; and having per-pass storage -substantially complicates the virtual memory allocation rules --- see below.) - -The memory manager deals with three kinds of object: -1. "Small" objects. Typically these require no more than 10K-20K total. -2. "Large" objects. These may require tens to hundreds of K depending on - image size. Semantically they behave the same as small objects, but we - distinguish them for two reasons: - * On MS-DOS machines, large objects are referenced by FAR pointers, - small objects by NEAR pointers. - * Pool allocation heuristics may differ for large and small objects. - Note that individual "large" objects cannot exceed the size allowed by - type size_t, which may be 64K or less on some machines. -3. "Virtual" objects. These are large 2-D arrays of JSAMPLEs or JBLOCKs - (typically large enough for the entire image being processed). The - memory manager provides stripwise access to these arrays. On machines - without virtual memory, the rest of the array may be swapped out to a - temporary file. - -(Note: JSAMPARRAY and JBLOCKARRAY data structures are a combination of large -objects for the data proper and small objects for the row pointers. For -convenience and speed, the memory manager provides single routines to create -these structures. Similarly, virtual arrays include a small control block -and a JSAMPARRAY or JBLOCKARRAY working buffer, all created with one call.) - -In the present implementation, virtual arrays are only permitted to have image -lifespan. (Permanent lifespan would not be reasonable, and pass lifespan is -not very useful since a virtual array's raison d'etre is to store data for -multiple passes through the image.) We also expect that only "small" objects -will be given permanent lifespan, though this restriction is not required by -the memory manager. - -In a non-virtual-memory machine, some performance benefit can be gained by -making the in-memory buffers for virtual arrays be as large as possible. -(For small images, the buffers might fit entirely in memory, so blind -swapping would be very wasteful.) The memory manager will adjust the height -of the buffers to fit within a prespecified maximum memory usage. In order -to do this in a reasonably optimal fashion, the manager needs to allocate all -of the virtual arrays at once. Therefore, there isn't a one-step allocation -routine for virtual arrays; instead, there is a "request" routine that simply -allocates the control block, and a "realize" routine (called just once) that -determines space allocation and creates all of the actual buffers. The -realize routine must allow for space occupied by non-virtual large objects. -(We don't bother to factor in the space needed for small objects, on the -grounds that it isn't worth the trouble.) - -To support all this, we establish the following protocol for doing business -with the memory manager: - 1. Modules must request virtual arrays (which may have only image lifespan) - during the initial setup phase, i.e., in their jinit_xxx routines. - 2. All "large" objects (including JSAMPARRAYs and JBLOCKARRAYs) must also be - allocated during initial setup. - 3. realize_virt_arrays will be called at the completion of initial setup. - The above conventions ensure that sufficient information is available - for it to choose a good size for virtual array buffers. -Small objects of any lifespan may be allocated at any time. We expect that -the total space used for small objects will be small enough to be negligible -in the realize_virt_arrays computation. - -In a virtual-memory machine, we simply pretend that the available space is -infinite, thus causing realize_virt_arrays to decide that it can allocate all -the virtual arrays as full-size in-memory buffers. The overhead of the -virtual-array access protocol is very small when no swapping occurs. - -A virtual array can be specified to be "pre-zeroed"; when this flag is set, -never-yet-written sections of the array are set to zero before being made -available to the caller. If this flag is not set, never-written sections -of the array contain garbage. (This feature exists primarily because the -equivalent logic would otherwise be needed in jdcoefct.c for progressive -JPEG mode; we may as well make it available for possible other uses.) - -The first write pass on a virtual array is required to occur in top-to-bottom -order; read passes, as well as any write passes after the first one, may -access the array in any order. This restriction exists partly to simplify -the virtual array control logic, and partly because some file systems may not -support seeking beyond the current end-of-file in a temporary file. The main -implication of this restriction is that rearrangement of rows (such as -converting top-to-bottom data order to bottom-to-top) must be handled while -reading data out of the virtual array, not while putting it in. - - -*** Memory manager internal structure *** - -To isolate system dependencies as much as possible, we have broken the -memory manager into two parts. There is a reasonably system-independent -"front end" (jmemmgr.c) and a "back end" that contains only the code -likely to change across systems. All of the memory management methods -outlined above are implemented by the front end. The back end provides -the following routines for use by the front end (none of these routines -are known to the rest of the JPEG code): - -jpeg_mem_init, jpeg_mem_term system-dependent initialization/shutdown - -jpeg_get_small, jpeg_free_small interface to malloc and free library routines - (or their equivalents) - -jpeg_get_large, jpeg_free_large interface to FAR malloc/free in MSDOS machines; - else usually the same as - jpeg_get_small/jpeg_free_small - -jpeg_mem_available estimate available memory - -jpeg_open_backing_store create a backing-store object - -read_backing_store, manipulate a backing-store object -write_backing_store, -close_backing_store - -On some systems there will be more than one type of backing-store object -(specifically, in MS-DOS a backing store file might be an area of extended -memory as well as a disk file). jpeg_open_backing_store is responsible for -choosing how to implement a given object. The read/write/close routines -are method pointers in the structure that describes a given object; this -lets them be different for different object types. - -It may be necessary to ensure that backing store objects are explicitly -released upon abnormal program termination. For example, MS-DOS won't free -extended memory by itself. To support this, we will expect the main program -or surrounding application to arrange to call self_destruct (typically via -jpeg_destroy) upon abnormal termination. This may require a SIGINT signal -handler or equivalent. We don't want to have the back end module install its -own signal handler, because that would pre-empt the surrounding application's -ability to control signal handling. - -The IJG distribution includes several memory manager back end implementations. -Usually the same back end should be suitable for all applications on a given -system, but it is possible for an application to supply its own back end at -need. - - -*** Implications of DNL marker *** - -Some JPEG files may use a DNL marker to postpone definition of the image -height (this would be useful for a fax-like scanner's output, for instance). -In these files the SOF marker claims the image height is 0, and you only -find out the true image height at the end of the first scan. - -We could read these files as follows: -1. Upon seeing zero image height, replace it by 65535 (the maximum allowed). -2. When the DNL is found, update the image height in the global image - descriptor. -This implies that control modules must avoid making copies of the image -height, and must re-test for termination after each MCU row. This would -be easy enough to do. - -In cases where image-size data structures are allocated, this approach will -result in very inefficient use of virtual memory or much-larger-than-necessary -temporary files. This seems acceptable for something that probably won't be a -mainstream usage. People might have to forgo use of memory-hogging options -(such as two-pass color quantization or noninterleaved JPEG files) if they -want efficient conversion of such files. (One could improve efficiency by -demanding a user-supplied upper bound for the height, less than 65536; in most -cases it could be much less.) - -The standard also permits the SOF marker to overestimate the image height, -with a DNL to give the true, smaller height at the end of the first scan. -This would solve the space problems if the overestimate wasn't too great. -However, it implies that you don't even know whether DNL will be used. - -This leads to a couple of very serious objections: -1. Testing for a DNL marker must occur in the inner loop of the decompressor's - Huffman decoder; this implies a speed penalty whether the feature is used - or not. -2. There is no way to hide the last-minute change in image height from an - application using the decoder. Thus *every* application using the IJG - library would suffer a complexity penalty whether it cared about DNL or - not. -We currently do not support DNL because of these problems. - -A different approach is to insist that DNL-using files be preprocessed by a -separate program that reads ahead to the DNL, then goes back and fixes the SOF -marker. This is a much simpler solution and is probably far more efficient. -Even if one wants piped input, buffering the first scan of the JPEG file needs -a lot smaller temp file than is implied by the maximum-height method. For -this approach we'd simply treat DNL as a no-op in the decompressor (at most, -check that it matches the SOF image height). - -We will not worry about making the compressor capable of outputting DNL. -Something similar to the first scheme above could be applied if anyone ever -wants to make that work. +IJG JPEG LIBRARY: SYSTEM ARCHITECTURE + +Copyright (C) 1991-1995, Thomas G. Lane. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +This file provides an overview of the architecture of the IJG JPEG software; +that is, the functions of the various modules in the system and the interfaces +between modules. For more precise details about any data structure or calling +convention, see the include files and comments in the source code. + +We assume that the reader is already somewhat familiar with the JPEG standard. +The README file includes references for learning about JPEG. The file +libjpeg.doc describes the library from the viewpoint of an application +programmer using the library; it's best to read that file before this one. +Also, the file coderules.doc describes the coding style conventions we use. + +In this document, JPEG-specific terminology follows the JPEG standard: + A "component" means a color channel, e.g., Red or Luminance. + A "sample" is a single component value (i.e., one number in the image data). + A "coefficient" is a frequency coefficient (a DCT transform output number). + A "block" is an 8x8 group of samples or coefficients. + An "MCU" (minimum coded unit) is an interleaved set of blocks of size + determined by the sampling factors, or a single block in a + noninterleaved scan. +We do not use the terms "pixel" and "sample" interchangeably. When we say +pixel, we mean an element of the full-size image, while a sample is an element +of the downsampled image. Thus the number of samples may vary across +components while the number of pixels does not. (This terminology is not used +rigorously throughout the code, but it is used in places where confusion would +otherwise result.) + + +*** System features *** + +The IJG distribution contains two parts: + * A subroutine library for JPEG compression and decompression. + * cjpeg/djpeg, two sample applications that use the library to transform + JFIF JPEG files to and from several other image formats. +cjpeg/djpeg are of no great intellectual complexity: they merely add a simple +command-line user interface and I/O routines for several uncompressed image +formats. This document concentrates on the library itself. + +We desire the library to be capable of supporting all JPEG baseline, extended +sequential, and progressive DCT processes. Hierarchical processes are not +supported. + +The library does not support the lossless (spatial) JPEG process. Lossless +JPEG shares little or no code with lossy JPEG, and would normally be used +without the extensive pre- and post-processing provided by this library. +We feel that lossless JPEG is better handled by a separate library. + +Within these limits, any set of compression parameters allowed by the JPEG +spec should be readable for decompression. (We can be more restrictive about +what formats we can generate.) Although the system design allows for all +parameter values, some uncommon settings are not yet implemented and may +never be; nonintegral sampling ratios are the prime example. Furthermore, +we treat 8-bit vs. 12-bit data precision as a compile-time switch, not a +run-time option, because most machines can store 8-bit pixels much more +compactly than 12-bit. + +For legal reasons, JPEG arithmetic coding is not currently supported, but +extending the library to include it would be straightforward. + +By itself, the library handles only interchange JPEG datastreams --- in +particular the widely used JFIF file format. The library can be used by +surrounding code to process interchange or abbreviated JPEG datastreams that +are embedded in more complex file formats. (For example, libtiff uses this +library to implement JPEG compression within the TIFF file format.) + +The library includes a substantial amount of code that is not covered by the +JPEG standard but is necessary for typical applications of JPEG. These +functions preprocess the image before JPEG compression or postprocess it after +decompression. They include colorspace conversion, downsampling/upsampling, +and color quantization. This code can be omitted if not needed. + +A wide range of quality vs. speed tradeoffs are possible in JPEG processing, +and even more so in decompression postprocessing. The decompression library +provides multiple implementations that cover most of the useful tradeoffs, +ranging from very-high-quality down to fast-preview operation. On the +compression side we have generally not provided low-quality choices, since +compression is normally less time-critical. It should be understood that the +low-quality modes may not meet the JPEG standard's accuracy requirements; +nonetheless, they are useful for viewers. + + +*** Portability issues *** + +Portability is an essential requirement for the library. The key portability +issues that show up at the level of system architecture are: + +1. Memory usage. We want the code to be able to run on PC-class machines +with limited memory. Images should therefore be processed sequentially (in +strips), to avoid holding the whole image in memory at once. Where a +full-image buffer is necessary, we should be able to use either virtual memory +or temporary files. + +2. Near/far pointer distinction. To run efficiently on 80x86 machines, the +code should distinguish "small" objects (kept in near data space) from +"large" ones (kept in far data space). This is an annoying restriction, but +fortunately it does not impact code quality for less brain-damaged machines, +and the source code clutter turns out to be minimal with sufficient use of +pointer typedefs. + +3. Data precision. We assume that "char" is at least 8 bits, "short" and +"int" at least 16, "long" at least 32. The code will work fine with larger +data sizes, although memory may be used inefficiently in some cases. However, +the JPEG compressed datastream must ultimately appear on external storage as a +sequence of 8-bit bytes if it is to conform to the standard. This may pose a +problem on machines where char is wider than 8 bits. The library represents +compressed data as an array of values of typedef JOCTET. If no data type +exactly 8 bits wide is available, custom data source and data destination +modules must be written to unpack and pack the chosen JOCTET datatype into +8-bit external representation. + + +*** System overview *** + +The compressor and decompressor are each divided into two main sections: +the JPEG compressor or decompressor proper, and the preprocessing or +postprocessing functions. The interface between these two sections is the +image data that the official JPEG spec regards as its input or output: this +data is in the colorspace to be used for compression, and it is downsampled +to the sampling factors to be used. The preprocessing and postprocessing +steps are responsible for converting a normal image representation to or from +this form. (Those few applications that want to deal with YCbCr downsampled +data can skip the preprocessing or postprocessing step.) + +Looking more closely, the compressor library contains the following main +elements: + + Preprocessing: + * Color space conversion (e.g., RGB to YCbCr). + * Edge expansion and downsampling. Optionally, this step can do simple + smoothing --- this is often helpful for low-quality source data. + JPEG proper: + * MCU assembly, DCT, quantization. + * Entropy coding (sequential or progressive, Huffman or arithmetic). + +In addition to these modules we need overall control, marker generation, +and support code (memory management & error handling). There is also a +module responsible for physically writing the output data --- typically +this is just an interface to fwrite(), but some applications may need to +do something else with the data. + +The decompressor library contains the following main elements: + + JPEG proper: + * Entropy decoding (sequential or progressive, Huffman or arithmetic). + * Dequantization, inverse DCT, MCU disassembly. + Postprocessing: + * Upsampling. Optionally, this step may be able to do more general + rescaling of the image. + * Color space conversion (e.g., YCbCr to RGB). This step may also + provide gamma adjustment [ currently it does not ]. + * Optional color quantization (e.g., reduction to 256 colors). + * Optional color precision reduction (e.g., 24-bit to 15-bit color). + [This feature is not currently implemented.] + +We also need overall control, marker parsing, and a data source module. +The support code (memory management & error handling) can be shared with +the compression half of the library. + +There may be several implementations of each of these elements, particularly +in the decompressor, where a wide range of speed/quality tradeoffs is very +useful. It must be understood that some of the best speedups involve +merging adjacent steps in the pipeline. For example, upsampling, color space +conversion, and color quantization might all be done at once when using a +low-quality ordered-dither technique. The system architecture is designed to +allow such merging where appropriate. + + +Note: it is convenient to regard edge expansion (padding to block boundaries) +as a preprocessing/postprocessing function, even though the JPEG spec includes +it in compression/decompression. We do this because downsampling/upsampling +can be simplified a little if they work on padded data: it's not necessary to +have special cases at the right and bottom edges. Therefore the interface +buffer is always an integral number of blocks wide and high, and we expect +compression preprocessing to pad the source data properly. Padding will occur +only to the next block (8-sample) boundary. In an interleaved-scan situation, +additional dummy blocks may be used to fill out MCUs, but the MCU assembly and +disassembly logic will create or discard these blocks internally. (This is +advantageous for speed reasons, since we avoid DCTing the dummy blocks. +It also permits a small reduction in file size, because the compressor can +choose dummy block contents so as to minimize their size in compressed form. +Finally, it makes the interface buffer specification independent of whether +the file is actually interleaved or not.) Applications that wish to deal +directly with the downsampled data must provide similar buffering and padding +for odd-sized images. + + +*** Poor man's object-oriented programming *** + +It should be clear by now that we have a lot of quasi-independent processing +steps, many of which have several possible behaviors. To avoid cluttering the +code with lots of switch statements, we use a simple form of object-style +programming to separate out the different possibilities. + +For example, two different color quantization algorithms could be implemented +as two separate modules that present the same external interface; at runtime, +the calling code will access the proper module indirectly through an "object". + +We can get the limited features we need while staying within portable C. +The basic tool is a function pointer. An "object" is just a struct +containing one or more function pointer fields, each of which corresponds to +a method name in real object-oriented languages. During initialization we +fill in the function pointers with references to whichever module we have +determined we need to use in this run. Then invocation of the module is done +by indirecting through a function pointer; on most machines this is no more +expensive than a switch statement, which would be the only other way of +making the required run-time choice. The really significant benefit, of +course, is keeping the source code clean and well structured. + +We can also arrange to have private storage that varies between different +implementations of the same kind of object. We do this by making all the +module-specific object structs be separately allocated entities, which will +be accessed via pointers in the master compression or decompression struct. +The "public" fields or methods for a given kind of object are specified by +a commonly known struct. But a module's initialization code can allocate +a larger struct that contains the common struct as its first member, plus +additional private fields. With appropriate pointer casting, the module's +internal functions can access these private fields. (For a simple example, +see jdatadst.c, which implements the external interface specified by struct +jpeg_destination_mgr, but adds extra fields.) + +(Of course this would all be a lot easier if we were using C++, but we are +not yet prepared to assume that everyone has a C++ compiler.) + +An important benefit of this scheme is that it is easy to provide multiple +versions of any method, each tuned to a particular case. While a lot of +precalculation might be done to select an optimal implementation of a method, +the cost per invocation is constant. For example, the upsampling step might +have a "generic" method, plus one or more "hardwired" methods for the most +popular sampling factors; the hardwired methods would be faster because they'd +use straight-line code instead of for-loops. The cost to determine which +method to use is paid only once, at startup, and the selection criteria are +hidden from the callers of the method. + +This plan differs a little bit from usual object-oriented structures, in that +only one instance of each object class will exist during execution. The +reason for having the class structure is that on different runs we may create +different instances (choose to execute different modules). You can think of +the term "method" as denoting the common interface presented by a particular +set of interchangeable functions, and "object" as denoting a group of related +methods, or the total shared interface behavior of a group of modules. + + +*** Overall control structure *** + +We previously mentioned the need for overall control logic in the compression +and decompression libraries. In IJG implementations prior to v5, overall +control was mostly provided by "pipeline control" modules, which proved to be +large, unwieldy, and hard to understand. To improve the situation, the +control logic has been subdivided into multiple modules. The control modules +consist of: + +1. Master control for module selection and initialization. This has two +responsibilities: + + 1A. Startup initialization at the beginning of image processing. + The individual processing modules to be used in this run are selected + and given initialization calls. + + 1B. Per-pass control. This determines how many passes will be performed + and calls each active processing module to configure itself + appropriately at the beginning of each pass. End-of-pass processing, + where necessary, is also invoked from the master control module. + + Method selection is partially distributed, in that a particular processing + module may contain several possible implementations of a particular method, + which it will select among when given its initialization call. The master + control code need only be concerned with decisions that affect more than + one module. + +2. Data buffering control. A separate control module exists for each + inter-processing-step data buffer. This module is responsible for + invoking the processing steps that write or read that data buffer. + +Each buffer controller sees the world as follows: + +input data => processing step A => buffer => processing step B => output data + | | | + ------------------ controller ------------------ + +The controller knows the dataflow requirements of steps A and B: how much data +they want to accept in one chunk and how much they output in one chunk. Its +function is to manage its buffer and call A and B at the proper times. + +A data buffer control module may itself be viewed as a processing step by a +higher-level control module; thus the control modules form a binary tree with +elementary processing steps at the leaves of the tree. + +The control modules are objects. A considerable amount of flexibility can +be had by replacing implementations of a control module. For example: +* Merging of adjacent steps in the pipeline is done by replacing a control + module and its pair of processing-step modules with a single processing- + step module. (Hence the possible merges are determined by the tree of + control modules.) +* In some processing modes, a given interstep buffer need only be a "strip" + buffer large enough to accommodate the desired data chunk sizes. In other + modes, a full-image buffer is needed and several passes are required. + The control module determines which kind of buffer is used and manipulates + virtual array buffers as needed. One or both processing steps may be + unaware of the multi-pass behavior. + +In theory, we might be able to make all of the data buffer controllers +interchangeable and provide just one set of implementations for all. In +practice, each one contains considerable special-case processing for its +particular job. The buffer controller concept should be regarded as an +overall system structuring principle, not as a complete description of the +task performed by any one controller. + + +*** Compression object structure *** + +Here is a sketch of the logical structure of the JPEG compression library: + + |-- Colorspace conversion + |-- Preprocessing controller --| + | |-- Downsampling +Main controller --| + | |-- Forward DCT, quantize + |-- Coefficient controller --| + |-- Entropy encoding + +This sketch also describes the flow of control (subroutine calls) during +typical image data processing. Each of the components shown in the diagram is +an "object" which may have several different implementations available. One +or more source code files contain the actual implementation(s) of each object. + +The objects shown above are: + +* Main controller: buffer controller for the subsampled-data buffer, which + holds the preprocessed input data. This controller invokes preprocessing to + fill the subsampled-data buffer, and JPEG compression to empty it. There is + usually no need for a full-image buffer here; a strip buffer is adequate. + +* Preprocessing controller: buffer controller for the downsampling input data + buffer, which lies between colorspace conversion and downsampling. Note + that a unified conversion/downsampling module would probably replace this + controller entirely. + +* Colorspace conversion: converts application image data into the desired + JPEG color space; also changes the data from pixel-interleaved layout to + separate component planes. Processes one pixel row at a time. + +* Downsampling: performs reduction of chroma components as required. + Optionally may perform pixel-level smoothing as well. Processes a "row + group" at a time, where a row group is defined as Vmax pixel rows of each + component before downsampling, and Vk sample rows afterwards (remember Vk + differs across components). Some downsampling or smoothing algorithms may + require context rows above and below the current row group; the + preprocessing controller is responsible for supplying these rows via proper + buffering. The downsampler is responsible for edge expansion at the right + edge (i.e., extending each sample row to a multiple of 8 samples); but the + preprocessing controller is responsible for vertical edge expansion (i.e., + duplicating the bottom sample row as needed to make a multiple of 8 rows). + +* Coefficient controller: buffer controller for the DCT-coefficient data. + This controller handles MCU assembly, including insertion of dummy DCT + blocks when needed at the right or bottom edge. When performing + Huffman-code optimization or emitting a multiscan JPEG file, this + controller is responsible for buffering the full image. The equivalent of + one fully interleaved MCU row of subsampled data is processed per call, + even when the JPEG file is noninterleaved. + +* Forward DCT and quantization: Perform DCT, quantize, and emit coefficients. + Works on one or more DCT blocks at a time. (Note: the coefficients are now + emitted in normal array order, which the entropy encoder is expected to + convert to zigzag order as necessary. Prior versions of the IJG code did + the conversion to zigzag order within the quantization step.) + +* Entropy encoding: Perform Huffman or arithmetic entropy coding and emit the + coded data to the data destination module. Works on one MCU per call. + For progressive JPEG, the same DCT blocks are fed to the entropy coder + during each pass, and the coder must emit the appropriate subset of + coefficients. + +In addition to the above objects, the compression library includes these +objects: + +* Master control: determines the number of passes required, controls overall + and per-pass initialization of the other modules. + +* Marker writing: generates JPEG markers (except for RSTn, which is emitted + by the entropy encoder when needed). + +* Data destination manager: writes the output JPEG datastream to its final + destination (e.g., a file). The destination manager supplied with the + library knows how to write to a stdio stream; for other behaviors, the + surrounding application may provide its own destination manager. + +* Memory manager: allocates and releases memory, controls virtual arrays + (with backing store management, where required). + +* Error handler: performs formatting and output of error and trace messages; + determines handling of nonfatal errors. The surrounding application may + override some or all of this object's methods to change error handling. + +* Progress monitor: supports output of "percent-done" progress reports. + This object represents an optional callback to the surrounding application: + if wanted, it must be supplied by the application. + +The error handler, destination manager, and progress monitor objects are +defined as separate objects in order to simplify application-specific +customization of the JPEG library. A surrounding application may override +individual methods or supply its own all-new implementation of one of these +objects. The object interfaces for these objects are therefore treated as +part of the application interface of the library, whereas the other objects +are internal to the library. + +The error handler and memory manager are shared by JPEG compression and +decompression; the progress monitor, if used, may be shared as well. + + +*** Decompression object structure *** + +Here is a sketch of the logical structure of the JPEG decompression library: + + |-- Entropy decoding + |-- Coefficient controller --| + | |-- Dequantize, Inverse DCT +Main controller --| + | |-- Upsampling + |-- Postprocessing controller --| |-- Colorspace conversion + |-- Color quantization + |-- Color precision reduction + +As before, this diagram also represents typical control flow. The objects +shown are: + +* Main controller: buffer controller for the subsampled-data buffer, which + holds the output of JPEG decompression proper. This controller's primary + task is to feed the postprocessing procedure. Some upsampling algorithms + may require context rows above and below the current row group; when this + is true, the main controller is responsible for managing its buffer so as + to make context rows available. In the current design, the main buffer is + always a strip buffer; a full-image buffer is never required. + +* Coefficient controller: buffer controller for the DCT-coefficient data. + This controller handles MCU disassembly, including deletion of any dummy + DCT blocks at the right or bottom edge. When reading a multiscan JPEG + file, this controller is responsible for buffering the full image. + (Buffering DCT coefficients, rather than samples, is necessary to support + progressive JPEG.) The equivalent of one fully interleaved MCU row of + subsampled data is processed per call, even when the source JPEG file is + noninterleaved. + +* Entropy decoding: Read coded data from the data source module and perform + Huffman or arithmetic entropy decoding. Works on one MCU per call. + For progressive JPEG decoding, the coefficient controller supplies the prior + coefficients of each MCU (initially all zeroes), which the entropy decoder + modifies in each scan. + +* Dequantization and inverse DCT: like it says. Note that the coefficients + buffered by the coefficient controller have NOT been dequantized; we + merge dequantization and inverse DCT into a single step for speed reasons. + When scaled-down output is asked for, simplified DCT algorithms may be used + that emit only 1x1, 2x2, or 4x4 samples per DCT block, not the full 8x8. + Works on one DCT block at a time. + +* Postprocessing controller: buffer controller for the color quantization + input buffer, when quantization is in use. (Without quantization, this + controller just calls the upsampler.) For two-pass quantization, this + controller is responsible for buffering the full-image data. + +* Upsampling: restores chroma components to full size. (May support more + general output rescaling, too. Note that if undersized DCT outputs have + been emitted by the DCT module, this module must adjust so that properly + sized outputs are created.) Works on one row group at a time. This module + also calls the color conversion module, so its top level is effectively a + buffer controller for the upsampling->color conversion buffer. However, in + all but the highest-quality operating modes, upsampling and color + conversion are likely to be merged into a single step. + +* Colorspace conversion: convert from JPEG color space to output color space, + and change data layout from separate component planes to pixel-interleaved. + Works on one pixel row at a time. + +* Color quantization: reduce the data to colormapped form, using either an + externally specified colormap or an internally generated one. This module + is not used for full-color output. Works on one pixel row at a time; may + require two passes to generate a color map. Note that the output will + always be a single component representing colormap indexes. In the current + design, the output values are JSAMPLEs, so an 8-bit compilation cannot + quantize to more than 256 colors. This is unlikely to be a problem in + practice. + +* Color reduction: this module handles color precision reduction, e.g., + generating 15-bit color (5 bits/primary) from JPEG's 24-bit output. + Not quite clear yet how this should be handled... should we merge it with + colorspace conversion??? + +Note that some high-speed operating modes might condense the entire +postprocessing sequence to a single module (upsample, color convert, and +quantize in one step). + +In addition to the above objects, the decompression library includes these +objects: + +* Master control: determines the number of passes required, controls overall + and per-pass initialization of the other modules. This is subdivided into + input and output control: jdinput.c controls only input-side processing, + while jdmaster.c handles overall initialization and output-side control. + +* Marker reading: decodes JPEG markers (except for RSTn). + +* Data source manager: supplies the input JPEG datastream. The source + manager supplied with the library knows how to read from a stdio stream; + for other behaviors, the surrounding application may provide its own source + manager. + +* Memory manager: same as for compression library. + +* Error handler: same as for compression library. + +* Progress monitor: same as for compression library. + +As with compression, the data source manager, error handler, and progress +monitor are candidates for replacement by a surrounding application. + + +*** Decompression input and output separation *** + +To support efficient incremental display of progressive JPEG files, the +decompressor is divided into two sections that can run independently: + +1. Data input includes marker parsing, entropy decoding, and input into the + coefficient controller's DCT coefficient buffer. Note that this + processing is relatively cheap and fast. + +2. Data output reads from the DCT coefficient buffer and performs the IDCT + and all postprocessing steps. + +For a progressive JPEG file, the data input processing is allowed to get +arbitrarily far ahead of the data output processing. (This occurs only +if the application calls jpeg_consume_input(); otherwise input and output +run in lockstep, since the input section is called only when the output +section needs more data.) In this way the application can avoid making +extra display passes when data is arriving faster than the display pass +can run. Furthermore, it is possible to abort an output pass without +losing anything, since the coefficient buffer is read-only as far as the +output section is concerned. See libjpeg.doc for more detail. + +A full-image coefficient array is only created if the JPEG file has multiple +scans (or if the application specifies buffered-image mode anyway). When +reading a single-scan file, the coefficient controller normally creates only +a one-MCU buffer, so input and output processing must run in lockstep in this +case. jpeg_consume_input() is effectively a no-op in this situation. + +The main impact of dividing the decompressor in this fashion is that we must +be very careful with shared variables in the cinfo data structure. Each +variable that can change during the course of decompression must be +classified as belonging to data input or data output, and each section must +look only at its own variables. For example, the data output section may not +depend on any of the variables that describe the current scan in the JPEG +file, because these may change as the data input section advances into a new +scan. + +The progress monitor is (somewhat arbitrarily) defined to treat input of the +file as one pass when buffered-image mode is not used, and to ignore data +input work completely when buffered-image mode is used. Note that the +library has no reliable way to predict the number of passes when dealing +with a progressive JPEG file, nor can it predict the number of output passes +in buffered-image mode. So the work estimate is inherently bogus anyway. + +No comparable division is currently made in the compression library, because +there isn't any real need for it. + + +*** Data formats *** + +Arrays of pixel sample values use the following data structure: + + typedef something JSAMPLE; a pixel component value, 0..MAXJSAMPLE + typedef JSAMPLE *JSAMPROW; ptr to a row of samples + typedef JSAMPROW *JSAMPARRAY; ptr to a list of rows + typedef JSAMPARRAY *JSAMPIMAGE; ptr to a list of color-component arrays + +The basic element type JSAMPLE will typically be one of unsigned char, +(signed) char, or short. Short will be used if samples wider than 8 bits are +to be supported (this is a compile-time option). Otherwise, unsigned char is +used if possible. If the compiler only supports signed chars, then it is +necessary to mask off the value when reading. Thus, all reads of JSAMPLE +values must be coded as "GETJSAMPLE(value)", where the macro will be defined +as "((value) & 0xFF)" on signed-char machines and "((int) (value))" elsewhere. + +With these conventions, JSAMPLE values can be assumed to be >= 0. This helps +simplify correct rounding during downsampling, etc. The JPEG standard's +specification that sample values run from -128..127 is accommodated by +subtracting 128 just as the sample value is copied into the source array for +the DCT step (this will be an array of signed ints). Similarly, during +decompression the output of the IDCT step will be immediately shifted back to +0..255. (NB: different values are required when 12-bit samples are in use. +The code is written in terms of MAXJSAMPLE and CENTERJSAMPLE, which will be +defined as 255 and 128 respectively in an 8-bit implementation, and as 4095 +and 2048 in a 12-bit implementation.) + +We use a pointer per row, rather than a two-dimensional JSAMPLE array. This +choice costs only a small amount of memory and has several benefits: +* Code using the data structure doesn't need to know the allocated width of + the rows. This simplifies edge expansion/compression, since we can work + in an array that's wider than the logical picture width. +* Indexing doesn't require multiplication; this is a performance win on many + machines. +* Arrays with more than 64K total elements can be supported even on machines + where malloc() cannot allocate chunks larger than 64K. +* The rows forming a component array may be allocated at different times + without extra copying. This trick allows some speedups in smoothing steps + that need access to the previous and next rows. + +Note that each color component is stored in a separate array; we don't use the +traditional layout in which the components of a pixel are stored together. +This simplifies coding of modules that work on each component independently, +because they don't need to know how many components there are. Furthermore, +we can read or write each component to a temporary file independently, which +is helpful when dealing with noninterleaved JPEG files. + +In general, a specific sample value is accessed by code such as + GETJSAMPLE(image[colorcomponent][row][col]) +where col is measured from the image left edge, but row is measured from the +first sample row currently in memory. Either of the first two indexings can +be precomputed by copying the relevant pointer. + + +Since most image-processing applications prefer to work on images in which +the components of a pixel are stored together, the data passed to or from the +surrounding application uses the traditional convention: a single pixel is +represented by N consecutive JSAMPLE values, and an image row is an array of +(# of color components)*(image width) JSAMPLEs. One or more rows of data can +be represented by a pointer of type JSAMPARRAY in this scheme. This scheme is +converted to component-wise storage inside the JPEG library. (Applications +that want to skip JPEG preprocessing or postprocessing will have to contend +with component-wise storage.) + + +Arrays of DCT-coefficient values use the following data structure: + + typedef short JCOEF; a 16-bit signed integer + typedef JCOEF JBLOCK[DCTSIZE2]; an 8x8 block of coefficients + typedef JBLOCK *JBLOCKROW; ptr to one horizontal row of 8x8 blocks + typedef JBLOCKROW *JBLOCKARRAY; ptr to a list of such rows + typedef JBLOCKARRAY *JBLOCKIMAGE; ptr to a list of color component arrays + +The underlying type is at least a 16-bit signed integer; while "short" is big +enough on all machines of interest, on some machines it is preferable to use +"int" for speed reasons, despite the storage cost. Coefficients are grouped +into 8x8 blocks (but we always use #defines DCTSIZE and DCTSIZE2 rather than +"8" and "64"). + +The contents of a coefficient block may be in either "natural" or zigzagged +order, and may be true values or divided by the quantization coefficients, +depending on where the block is in the processing pipeline. In the current +library, coefficient blocks are kept in natural order everywhere; the entropy +codecs zigzag or dezigzag the data as it is written or read. The blocks +contain quantized coefficients everywhere outside the DCT/IDCT subsystems. +(This latter decision may need to be revisited to support variable +quantization a la JPEG Part 3.) + +Notice that the allocation unit is now a row of 8x8 blocks, corresponding to +eight rows of samples. Otherwise the structure is much the same as for +samples, and for the same reasons. + +On machines where malloc() can't handle a request bigger than 64Kb, this data +structure limits us to rows of less than 512 JBLOCKs, or a picture width of +4000+ pixels. This seems an acceptable restriction. + + +On 80x86 machines, the bottom-level pointer types (JSAMPROW and JBLOCKROW) +must be declared as "far" pointers, but the upper levels can be "near" +(implying that the pointer lists are allocated in the DS segment). +We use a #define symbol FAR, which expands to the "far" keyword when +compiling on 80x86 machines and to nothing elsewhere. + + +*** Suspendable processing *** + +In some applications it is desirable to use the JPEG library as an +incremental, memory-to-memory filter. In this situation the data source or +destination may be a limited-size buffer, and we can't rely on being able to +empty or refill the buffer at arbitrary times. Instead the application would +like to have control return from the library at buffer overflow/underrun, and +then resume compression or decompression at a later time. + +This scenario is supported for simple cases. (For anything more complex, we +recommend that the application "bite the bullet" and develop real multitasking +capability.) The libjpeg.doc file goes into more detail about the usage and +limitations of this capability; here we address the implications for library +structure. + +The essence of the problem is that the entropy codec (coder or decoder) must +be prepared to stop at arbitrary times. In turn, the controllers that call +the entropy codec must be able to stop before having produced or consumed all +the data that they normally would handle in one call. That part is reasonably +straightforward: we make the controller call interfaces include "progress +counters" which indicate the number of data chunks successfully processed, and +we require callers to test the counter rather than just assume all of the data +was processed. + +Rather than trying to restart at an arbitrary point, the current Huffman +codecs are designed to restart at the beginning of the current MCU after a +suspension due to buffer overflow/underrun. At the start of each call, the +codec's internal state is loaded from permanent storage (in the JPEG object +structures) into local variables. On successful completion of the MCU, the +permanent state is updated. (This copying is not very expensive, and may even +lead to *improved* performance if the local variables can be registerized.) +If a suspension occurs, the codec simply returns without updating the state, +thus effectively reverting to the start of the MCU. Note that this implies +leaving some data unprocessed in the source/destination buffer (ie, the +compressed partial MCU). The data source/destination module interfaces are +specified so as to make this possible. This also implies that the data buffer +must be large enough to hold a worst-case compressed MCU; a couple thousand +bytes should be enough. + +In a successive-approximation AC refinement scan, the progressive Huffman +decoder has to be able to undo assignments of newly nonzero coefficients if it +suspends before the MCU is complete, since decoding requires distinguishing +previously-zero and previously-nonzero coefficients. This is a bit tedious +but probably won't have much effect on performance. Other variants of Huffman +decoding need not worry about this, since they will just store the same values +again if forced to repeat the MCU. + +This approach would probably not work for an arithmetic codec, since its +modifiable state is quite large and couldn't be copied cheaply. Instead it +would have to suspend and resume exactly at the point of the buffer end. + +The JPEG marker reader is designed to cope with suspension at an arbitrary +point. It does so by backing up to the start of the marker parameter segment, +so the data buffer must be big enough to hold the largest marker of interest. +Again, a couple KB should be adequate. (A special "skip" convention is used +to bypass COM and APPn markers, so these can be larger than the buffer size +without causing problems; otherwise a 64K buffer would be needed in the worst +case.) + +The JPEG marker writer currently does *not* cope with suspension. I feel that +this is not necessary; it is much easier simply to require the application to +ensure there is enough buffer space before starting. (An empty 2K buffer is +more than sufficient for the header markers; and ensuring there are a dozen or +two bytes available before calling jpeg_finish_compress() will suffice for the +trailer.) This would not work for writing multi-scan JPEG files, but +we simply do not intend to support that capability with suspension. + + +*** Memory manager services *** + +The JPEG library's memory manager controls allocation and deallocation of +memory, and it manages large "virtual" data arrays on machines where the +operating system does not provide virtual memory. Note that the same +memory manager serves both compression and decompression operations. + +In all cases, allocated objects are tied to a particular compression or +decompression master record, and they will be released when that master +record is destroyed. + +The memory manager does not provide explicit deallocation of objects. +Instead, objects are created in "pools" of free storage, and a whole pool +can be freed at once. This approach helps prevent storage-leak bugs, and +it speeds up operations whenever malloc/free are slow (as they often are). +The pools can be regarded as lifetime identifiers for objects. Two +pools/lifetimes are defined: + * JPOOL_PERMANENT lasts until master record is destroyed + * JPOOL_IMAGE lasts until done with image (JPEG datastream) +Permanent lifetime is used for parameters and tables that should be carried +across from one datastream to another; this includes all application-visible +parameters. Image lifetime is used for everything else. (A third lifetime, +JPOOL_PASS = one processing pass, was originally planned. However it was +dropped as not being worthwhile. The actual usage patterns are such that the +peak memory usage would be about the same anyway; and having per-pass storage +substantially complicates the virtual memory allocation rules --- see below.) + +The memory manager deals with three kinds of object: +1. "Small" objects. Typically these require no more than 10K-20K total. +2. "Large" objects. These may require tens to hundreds of K depending on + image size. Semantically they behave the same as small objects, but we + distinguish them for two reasons: + * On MS-DOS machines, large objects are referenced by FAR pointers, + small objects by NEAR pointers. + * Pool allocation heuristics may differ for large and small objects. + Note that individual "large" objects cannot exceed the size allowed by + type size_t, which may be 64K or less on some machines. +3. "Virtual" objects. These are large 2-D arrays of JSAMPLEs or JBLOCKs + (typically large enough for the entire image being processed). The + memory manager provides stripwise access to these arrays. On machines + without virtual memory, the rest of the array may be swapped out to a + temporary file. + +(Note: JSAMPARRAY and JBLOCKARRAY data structures are a combination of large +objects for the data proper and small objects for the row pointers. For +convenience and speed, the memory manager provides single routines to create +these structures. Similarly, virtual arrays include a small control block +and a JSAMPARRAY or JBLOCKARRAY working buffer, all created with one call.) + +In the present implementation, virtual arrays are only permitted to have image +lifespan. (Permanent lifespan would not be reasonable, and pass lifespan is +not very useful since a virtual array's raison d'etre is to store data for +multiple passes through the image.) We also expect that only "small" objects +will be given permanent lifespan, though this restriction is not required by +the memory manager. + +In a non-virtual-memory machine, some performance benefit can be gained by +making the in-memory buffers for virtual arrays be as large as possible. +(For small images, the buffers might fit entirely in memory, so blind +swapping would be very wasteful.) The memory manager will adjust the height +of the buffers to fit within a prespecified maximum memory usage. In order +to do this in a reasonably optimal fashion, the manager needs to allocate all +of the virtual arrays at once. Therefore, there isn't a one-step allocation +routine for virtual arrays; instead, there is a "request" routine that simply +allocates the control block, and a "realize" routine (called just once) that +determines space allocation and creates all of the actual buffers. The +realize routine must allow for space occupied by non-virtual large objects. +(We don't bother to factor in the space needed for small objects, on the +grounds that it isn't worth the trouble.) + +To support all this, we establish the following protocol for doing business +with the memory manager: + 1. Modules must request virtual arrays (which may have only image lifespan) + during the initial setup phase, i.e., in their jinit_xxx routines. + 2. All "large" objects (including JSAMPARRAYs and JBLOCKARRAYs) must also be + allocated during initial setup. + 3. realize_virt_arrays will be called at the completion of initial setup. + The above conventions ensure that sufficient information is available + for it to choose a good size for virtual array buffers. +Small objects of any lifespan may be allocated at any time. We expect that +the total space used for small objects will be small enough to be negligible +in the realize_virt_arrays computation. + +In a virtual-memory machine, we simply pretend that the available space is +infinite, thus causing realize_virt_arrays to decide that it can allocate all +the virtual arrays as full-size in-memory buffers. The overhead of the +virtual-array access protocol is very small when no swapping occurs. + +A virtual array can be specified to be "pre-zeroed"; when this flag is set, +never-yet-written sections of the array are set to zero before being made +available to the caller. If this flag is not set, never-written sections +of the array contain garbage. (This feature exists primarily because the +equivalent logic would otherwise be needed in jdcoefct.c for progressive +JPEG mode; we may as well make it available for possible other uses.) + +The first write pass on a virtual array is required to occur in top-to-bottom +order; read passes, as well as any write passes after the first one, may +access the array in any order. This restriction exists partly to simplify +the virtual array control logic, and partly because some file systems may not +support seeking beyond the current end-of-file in a temporary file. The main +implication of this restriction is that rearrangement of rows (such as +converting top-to-bottom data order to bottom-to-top) must be handled while +reading data out of the virtual array, not while putting it in. + + +*** Memory manager internal structure *** + +To isolate system dependencies as much as possible, we have broken the +memory manager into two parts. There is a reasonably system-independent +"front end" (jmemmgr.c) and a "back end" that contains only the code +likely to change across systems. All of the memory management methods +outlined above are implemented by the front end. The back end provides +the following routines for use by the front end (none of these routines +are known to the rest of the JPEG code): + +jpeg_mem_init, jpeg_mem_term system-dependent initialization/shutdown + +jpeg_get_small, jpeg_free_small interface to malloc and free library routines + (or their equivalents) + +jpeg_get_large, jpeg_free_large interface to FAR malloc/free in MSDOS machines; + else usually the same as + jpeg_get_small/jpeg_free_small + +jpeg_mem_available estimate available memory + +jpeg_open_backing_store create a backing-store object + +read_backing_store, manipulate a backing-store object +write_backing_store, +close_backing_store + +On some systems there will be more than one type of backing-store object +(specifically, in MS-DOS a backing store file might be an area of extended +memory as well as a disk file). jpeg_open_backing_store is responsible for +choosing how to implement a given object. The read/write/close routines +are method pointers in the structure that describes a given object; this +lets them be different for different object types. + +It may be necessary to ensure that backing store objects are explicitly +released upon abnormal program termination. For example, MS-DOS won't free +extended memory by itself. To support this, we will expect the main program +or surrounding application to arrange to call self_destruct (typically via +jpeg_destroy) upon abnormal termination. This may require a SIGINT signal +handler or equivalent. We don't want to have the back end module install its +own signal handler, because that would pre-empt the surrounding application's +ability to control signal handling. + +The IJG distribution includes several memory manager back end implementations. +Usually the same back end should be suitable for all applications on a given +system, but it is possible for an application to supply its own back end at +need. + + +*** Implications of DNL marker *** + +Some JPEG files may use a DNL marker to postpone definition of the image +height (this would be useful for a fax-like scanner's output, for instance). +In these files the SOF marker claims the image height is 0, and you only +find out the true image height at the end of the first scan. + +We could read these files as follows: +1. Upon seeing zero image height, replace it by 65535 (the maximum allowed). +2. When the DNL is found, update the image height in the global image + descriptor. +This implies that control modules must avoid making copies of the image +height, and must re-test for termination after each MCU row. This would +be easy enough to do. + +In cases where image-size data structures are allocated, this approach will +result in very inefficient use of virtual memory or much-larger-than-necessary +temporary files. This seems acceptable for something that probably won't be a +mainstream usage. People might have to forgo use of memory-hogging options +(such as two-pass color quantization or noninterleaved JPEG files) if they +want efficient conversion of such files. (One could improve efficiency by +demanding a user-supplied upper bound for the height, less than 65536; in most +cases it could be much less.) + +The standard also permits the SOF marker to overestimate the image height, +with a DNL to give the true, smaller height at the end of the first scan. +This would solve the space problems if the overestimate wasn't too great. +However, it implies that you don't even know whether DNL will be used. + +This leads to a couple of very serious objections: +1. Testing for a DNL marker must occur in the inner loop of the decompressor's + Huffman decoder; this implies a speed penalty whether the feature is used + or not. +2. There is no way to hide the last-minute change in image height from an + application using the decoder. Thus *every* application using the IJG + library would suffer a complexity penalty whether it cared about DNL or + not. +We currently do not support DNL because of these problems. + +A different approach is to insist that DNL-using files be preprocessed by a +separate program that reads ahead to the DNL, then goes back and fixes the SOF +marker. This is a much simpler solution and is probably far more efficient. +Even if one wants piped input, buffering the first scan of the JPEG file needs +a lot smaller temp file than is implied by the maximum-height method. For +this approach we'd simply treat DNL as a no-op in the decompressor (at most, +check that it matches the SOF image height). + +We will not worry about making the compressor capable of outputting DNL. +Something similar to the first scheme above could be applied if anyone ever +wants to make that work. diff --git a/src/dep/src/irrlicht/jpeglib/transupp.c b/src/dep/src/irrlicht/jpeglib/transupp.c index 53a9940..e5ec564 100644 --- a/src/dep/src/irrlicht/jpeglib/transupp.c +++ b/src/dep/src/irrlicht/jpeglib/transupp.c @@ -1,928 +1,928 @@ -/* - * transupp.c - * - * Copyright (C) 1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains image transformation routines and other utility code - * used by the jpegtran sample application. These are NOT part of the core - * JPEG library. But we keep these routines separate from jpegtran.c to - * ease the task of maintaining jpegtran-like programs that have other user - * interfaces. - */ - -/* Although this file really shouldn't have access to the library internals, - * it's helpful to let it call jround_up() and jcopy_block_row(). - */ -#define JPEG_INTERNALS - -#include "jinclude.h" -#include "jpeglib.h" -#include "transupp.h" /* My own external interface */ - - -#if TRANSFORMS_SUPPORTED - -/* - * Lossless image transformation routines. These routines work on DCT - * coefficient arrays and thus do not require any lossy decompression - * or recompression of the image. - * Thanks to Guido Vollbeding for the initial design and code of this feature. - * - * Horizontal flipping is done in-place, using a single top-to-bottom - * pass through the virtual source array. It will thus be much the - * fastest option for images larger than main memory. - * - * The other routines require a set of destination virtual arrays, so they - * need twice as much memory as jpegtran normally does. The destination - * arrays are always written in normal scan order (top to bottom) because - * the virtual array manager expects this. The source arrays will be scanned - * in the corresponding order, which means multiple passes through the source - * arrays for most of the transforms. That could result in much thrashing - * if the image is larger than main memory. - * - * Some notes about the operating environment of the individual transform - * routines: - * 1. Both the source and destination virtual arrays are allocated from the - * source JPEG object, and therefore should be manipulated by calling the - * source's memory manager. - * 2. The destination's component count should be used. It may be smaller - * than the source's when forcing to grayscale. - * 3. Likewise the destination's sampling factors should be used. When - * forcing to grayscale the destination's sampling factors will be all 1, - * and we may as well take that as the effective iMCU size. - * 4. When "trim" is in effect, the destination's dimensions will be the - * trimmed values but the source's will be untrimmed. - * 5. All the routines assume that the source and destination buffers are - * padded out to a full iMCU boundary. This is true, although for the - * source buffer it is an undocumented property of jdcoefct.c. - * Notes 2,3,4 boil down to this: generally we should use the destination's - * dimensions and ignore the source's. - */ - - -LOCAL(void) -do_flip_h (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays) -/* Horizontal flip; done in-place, so no separate dest array is required */ -{ - JDIMENSION MCU_cols, comp_width, blk_x, blk_y; - int ci, k, offset_y; - JBLOCKARRAY buffer; - JCOEFPTR ptr1, ptr2; - JCOEF temp1, temp2; - jpeg_component_info *compptr; - - /* Horizontal mirroring of DCT blocks is accomplished by swapping - * pairs of blocks in-place. Within a DCT block, we perform horizontal - * mirroring by changing the signs of odd-numbered columns. - * Partial iMCUs at the right edge are left untouched. - */ - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - for (blk_y = 0; blk_y < compptr->height_in_blocks; - blk_y += compptr->v_samp_factor) { - buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (blk_x = 0; blk_x * 2 < comp_width; blk_x++) { - ptr1 = buffer[offset_y][blk_x]; - ptr2 = buffer[offset_y][comp_width - blk_x - 1]; - /* this unrolled loop doesn't need to know which row it's on... */ - for (k = 0; k < DCTSIZE2; k += 2) { - temp1 = *ptr1; /* swap even column */ - temp2 = *ptr2; - *ptr1++ = temp2; - *ptr2++ = temp1; - temp1 = *ptr1; /* swap odd column with sign change */ - temp2 = *ptr2; - *ptr1++ = -temp2; - *ptr2++ = -temp1; - } - } - } - } - } -} - - -LOCAL(void) -do_flip_v (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Vertical flip */ -{ - JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; - int ci, i, j, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JBLOCKROW src_row_ptr, dst_row_ptr; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* We output into a separate array because we can't touch different - * rows of the source virtual array simultaneously. Otherwise, this - * is a pretty straightforward analog of horizontal flip. - * Within a DCT block, vertical mirroring is done by changing the signs - * of odd-numbered rows. - * Partial iMCUs at the bottom edge are copied verbatim. - */ - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_height = MCU_rows * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - if (dst_blk_y < comp_height) { - /* Row is within the mirrorable area. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } else { - /* Bottom-edge blocks will be copied verbatim. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - if (dst_blk_y < comp_height) { - /* Row is within the mirrorable area. */ - dst_row_ptr = dst_buffer[offset_y]; - src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[dst_blk_x]; - for (i = 0; i < DCTSIZE; i += 2) { - /* copy even row */ - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = *src_ptr++; - /* copy odd row with sign change */ - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = - *src_ptr++; - } - } - } else { - /* Just copy row verbatim. */ - jcopy_block_row(src_buffer[offset_y], dst_buffer[offset_y], - compptr->width_in_blocks); - } - } - } - } -} - - -LOCAL(void) -do_transpose (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Transpose source into destination */ -{ - JDIMENSION dst_blk_x, dst_blk_y; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* Transposing pixels within a block just requires transposing the - * DCT coefficients. - * Partial iMCUs at the edges require no special treatment; we simply - * process all the available DCT blocks for every component. - */ - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, - (JDIMENSION) compptr->h_samp_factor, FALSE); - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } -} - - -LOCAL(void) -do_rot_90 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* 90 degree rotation is equivalent to - * 1. Transposing the image; - * 2. Horizontal mirroring. - * These two steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* Because of the horizontal mirror step, we can't process partial iMCUs - * at the (output) right edge properly. They just get transposed and - * not mirrored. - */ - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, - (JDIMENSION) compptr->h_samp_factor, FALSE); - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; - if (dst_blk_x < comp_width) { - /* Block is within the mirrorable area. */ - dst_ptr = dst_buffer[offset_y] - [comp_width - dst_blk_x - offset_x - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - i++; - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } else { - /* Edge blocks are transposed but not mirrored. */ - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } - } -} - - -LOCAL(void) -do_rot_270 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* 270 degree rotation is equivalent to - * 1. Horizontal mirroring; - * 2. Transposing the image. - * These two steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* Because of the horizontal mirror step, we can't process partial iMCUs - * at the (output) bottom edge properly. They just get transposed and - * not mirrored. - */ - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_height = MCU_rows * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, - (JDIMENSION) compptr->h_samp_factor, FALSE); - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - if (dst_blk_y < comp_height) { - /* Block is within the mirrorable area. */ - src_ptr = src_buffer[offset_x] - [comp_height - dst_blk_y - offset_y - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } - } else { - /* Edge blocks are transposed but not mirrored. */ - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } - } -} - - -LOCAL(void) -do_rot_180 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* 180 degree rotation is equivalent to - * 1. Vertical mirroring; - * 2. Horizontal mirroring. - * These two steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; - int ci, i, j, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JBLOCKROW src_row_ptr, dst_row_ptr; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - comp_height = MCU_rows * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - if (dst_blk_y < comp_height) { - /* Row is within the vertically mirrorable area. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } else { - /* Bottom-edge rows are only mirrored horizontally. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - if (dst_blk_y < comp_height) { - /* Row is within the mirrorable area. */ - dst_row_ptr = dst_buffer[offset_y]; - src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; - /* Process the blocks that can be mirrored both ways. */ - for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[comp_width - dst_blk_x - 1]; - for (i = 0; i < DCTSIZE; i += 2) { - /* For even row, negate every odd column. */ - for (j = 0; j < DCTSIZE; j += 2) { - *dst_ptr++ = *src_ptr++; - *dst_ptr++ = - *src_ptr++; - } - /* For odd row, negate every even column. */ - for (j = 0; j < DCTSIZE; j += 2) { - *dst_ptr++ = - *src_ptr++; - *dst_ptr++ = *src_ptr++; - } - } - } - /* Any remaining right-edge blocks are only mirrored vertically. */ - for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[dst_blk_x]; - for (i = 0; i < DCTSIZE; i += 2) { - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = *src_ptr++; - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = - *src_ptr++; - } - } - } else { - /* Remaining rows are just mirrored horizontally. */ - dst_row_ptr = dst_buffer[offset_y]; - src_row_ptr = src_buffer[offset_y]; - /* Process the blocks that can be mirrored. */ - for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[comp_width - dst_blk_x - 1]; - for (i = 0; i < DCTSIZE2; i += 2) { - *dst_ptr++ = *src_ptr++; - *dst_ptr++ = - *src_ptr++; - } - } - /* Any remaining right-edge blocks are only copied. */ - for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[dst_blk_x]; - for (i = 0; i < DCTSIZE2; i++) - *dst_ptr++ = *src_ptr++; - } - } - } - } - } -} - - -LOCAL(void) -do_transverse (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Transverse transpose is equivalent to - * 1. 180 degree rotation; - * 2. Transposition; - * or - * 1. Horizontal mirroring; - * 2. Transposition; - * 3. Horizontal mirroring. - * These steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - comp_height = MCU_rows * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, - (JDIMENSION) compptr->h_samp_factor, FALSE); - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - if (dst_blk_y < comp_height) { - src_ptr = src_buffer[offset_x] - [comp_height - dst_blk_y - offset_y - 1]; - if (dst_blk_x < comp_width) { - /* Block is within the mirrorable area. */ - dst_ptr = dst_buffer[offset_y] - [comp_width - dst_blk_x - offset_x - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - i++; - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } else { - /* Right-edge blocks are mirrored in y only */ - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } - } - } else { - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; - if (dst_blk_x < comp_width) { - /* Bottom-edge blocks are mirrored in x only */ - dst_ptr = dst_buffer[offset_y] - [comp_width - dst_blk_x - offset_x - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - i++; - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } else { - /* At lower right corner, just transpose, no mirroring */ - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } - } - } -} - - -/* Request any required workspace. - * - * We allocate the workspace virtual arrays from the source decompression - * object, so that all the arrays (both the original data and the workspace) - * will be taken into account while making memory management decisions. - * Hence, this routine must be called after jpeg_read_header (which reads - * the image dimensions) and before jpeg_read_coefficients (which realizes - * the source's virtual arrays). - */ - -GLOBAL(void) -jtransform_request_workspace (j_decompress_ptr srcinfo, - jpeg_transform_info *info) -{ - jvirt_barray_ptr *coef_arrays = NULL; - jpeg_component_info *compptr; - int ci; - - if (info->force_grayscale && - srcinfo->jpeg_color_space == JCS_YCbCr && - srcinfo->num_components == 3) { - /* We'll only process the first component */ - info->num_components = 1; - } else { - /* Process all the components */ - info->num_components = srcinfo->num_components; - } - - switch (info->transform) { - case JXFORM_NONE: - case JXFORM_FLIP_H: - /* Don't need a workspace array */ - break; - case JXFORM_FLIP_V: - case JXFORM_ROT_180: - /* Need workspace arrays having same dimensions as source image. - * Note that we allocate arrays padded out to the next iMCU boundary, - * so that transform routines need not worry about missing edge blocks. - */ - coef_arrays = (jvirt_barray_ptr *) - (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, - SIZEOF(jvirt_barray_ptr) * info->num_components); - for (ci = 0; ci < info->num_components; ci++) { - compptr = srcinfo->comp_info + ci; - coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) - ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) compptr->v_samp_factor); - } - break; - case JXFORM_TRANSPOSE: - case JXFORM_TRANSVERSE: - case JXFORM_ROT_90: - case JXFORM_ROT_270: - /* Need workspace arrays having transposed dimensions. - * Note that we allocate arrays padded out to the next iMCU boundary, - * so that transform routines need not worry about missing edge blocks. - */ - coef_arrays = (jvirt_barray_ptr *) - (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, - SIZEOF(jvirt_barray_ptr) * info->num_components); - for (ci = 0; ci < info->num_components; ci++) { - compptr = srcinfo->comp_info + ci; - coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) - ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) compptr->h_samp_factor); - } - break; - } - info->workspace_coef_arrays = coef_arrays; -} - - -/* Transpose destination image parameters */ - -LOCAL(void) -transpose_critical_parameters (j_compress_ptr dstinfo) -{ - int tblno, i, j, ci, itemp; - jpeg_component_info *compptr; - JQUANT_TBL *qtblptr; - JDIMENSION dtemp; - UINT16 qtemp; - - /* Transpose basic image dimensions */ - dtemp = dstinfo->image_width; - dstinfo->image_width = dstinfo->image_height; - dstinfo->image_height = dtemp; - - /* Transpose sampling factors */ - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - itemp = compptr->h_samp_factor; - compptr->h_samp_factor = compptr->v_samp_factor; - compptr->v_samp_factor = itemp; - } - - /* Transpose quantization tables */ - for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { - qtblptr = dstinfo->quant_tbl_ptrs[tblno]; - if (qtblptr != NULL) { - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < i; j++) { - qtemp = qtblptr->quantval[i*DCTSIZE+j]; - qtblptr->quantval[i*DCTSIZE+j] = qtblptr->quantval[j*DCTSIZE+i]; - qtblptr->quantval[j*DCTSIZE+i] = qtemp; - } - } - } - } -} - - -/* Trim off any partial iMCUs on the indicated destination edge */ - -LOCAL(void) -trim_right_edge (j_compress_ptr dstinfo) -{ - int ci, max_h_samp_factor; - JDIMENSION MCU_cols; - - /* We have to compute max_h_samp_factor ourselves, - * because it hasn't been set yet in the destination - * (and we don't want to use the source's value). - */ - max_h_samp_factor = 1; - for (ci = 0; ci < dstinfo->num_components; ci++) { - int h_samp_factor = dstinfo->comp_info[ci].h_samp_factor; - max_h_samp_factor = MAX(max_h_samp_factor, h_samp_factor); - } - MCU_cols = dstinfo->image_width / (max_h_samp_factor * DCTSIZE); - if (MCU_cols > 0) /* can't trim to 0 pixels */ - dstinfo->image_width = MCU_cols * (max_h_samp_factor * DCTSIZE); -} - -LOCAL(void) -trim_bottom_edge (j_compress_ptr dstinfo) -{ - int ci, max_v_samp_factor; - JDIMENSION MCU_rows; - - /* We have to compute max_v_samp_factor ourselves, - * because it hasn't been set yet in the destination - * (and we don't want to use the source's value). - */ - max_v_samp_factor = 1; - for (ci = 0; ci < dstinfo->num_components; ci++) { - int v_samp_factor = dstinfo->comp_info[ci].v_samp_factor; - max_v_samp_factor = MAX(max_v_samp_factor, v_samp_factor); - } - MCU_rows = dstinfo->image_height / (max_v_samp_factor * DCTSIZE); - if (MCU_rows > 0) /* can't trim to 0 pixels */ - dstinfo->image_height = MCU_rows * (max_v_samp_factor * DCTSIZE); -} - - -/* Adjust output image parameters as needed. - * - * This must be called after jpeg_copy_critical_parameters() - * and before jpeg_write_coefficients(). - * - * The return value is the set of virtual coefficient arrays to be written - * (either the ones allocated by jtransform_request_workspace, or the - * original source data arrays). The caller will need to pass this value - * to jpeg_write_coefficients(). - */ - -GLOBAL(jvirt_barray_ptr *) -jtransform_adjust_parameters (j_decompress_ptr srcinfo, - j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jpeg_transform_info *info) -{ - /* If force-to-grayscale is requested, adjust destination parameters */ - if (info->force_grayscale) { - /* We use jpeg_set_colorspace to make sure subsidiary settings get fixed - * properly. Among other things, the target h_samp_factor & v_samp_factor - * will get set to 1, which typically won't match the source. - * In fact we do this even if the source is already grayscale; that - * provides an easy way of coercing a grayscale JPEG with funny sampling - * factors to the customary 1,1. (Some decoders fail on other factors.) - */ - if ((dstinfo->jpeg_color_space == JCS_YCbCr && - dstinfo->num_components == 3) || - (dstinfo->jpeg_color_space == JCS_GRAYSCALE && - dstinfo->num_components == 1)) { - /* We have to preserve the source's quantization table number. */ - int sv_quant_tbl_no = dstinfo->comp_info[0].quant_tbl_no; - jpeg_set_colorspace(dstinfo, JCS_GRAYSCALE); - dstinfo->comp_info[0].quant_tbl_no = sv_quant_tbl_no; - } else { - /* Sorry, can't do it */ - ERREXIT(dstinfo, JERR_CONVERSION_NOTIMPL); - } - } - - /* Correct the destination's image dimensions etc if necessary */ - switch (info->transform) { - case JXFORM_NONE: - /* Nothing to do */ - break; - case JXFORM_FLIP_H: - if (info->trim) - trim_right_edge(dstinfo); - break; - case JXFORM_FLIP_V: - if (info->trim) - trim_bottom_edge(dstinfo); - break; - case JXFORM_TRANSPOSE: - transpose_critical_parameters(dstinfo); - /* transpose does NOT have to trim anything */ - break; - case JXFORM_TRANSVERSE: - transpose_critical_parameters(dstinfo); - if (info->trim) { - trim_right_edge(dstinfo); - trim_bottom_edge(dstinfo); - } - break; - case JXFORM_ROT_90: - transpose_critical_parameters(dstinfo); - if (info->trim) - trim_right_edge(dstinfo); - break; - case JXFORM_ROT_180: - if (info->trim) { - trim_right_edge(dstinfo); - trim_bottom_edge(dstinfo); - } - break; - case JXFORM_ROT_270: - transpose_critical_parameters(dstinfo); - if (info->trim) - trim_bottom_edge(dstinfo); - break; - } - - /* Return the appropriate output data set */ - if (info->workspace_coef_arrays != NULL) - return info->workspace_coef_arrays; - return src_coef_arrays; -} - - -/* Execute the actual transformation, if any. - * - * This must be called *after* jpeg_write_coefficients, because it depends - * on jpeg_write_coefficients to have computed subsidiary values such as - * the per-component width and height fields in the destination object. - * - * Note that some transformations will modify the source data arrays! - */ - -GLOBAL(void) -jtransform_execute_transformation (j_decompress_ptr srcinfo, - j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jpeg_transform_info *info) -{ - jvirt_barray_ptr *dst_coef_arrays = info->workspace_coef_arrays; - - switch (info->transform) { - case JXFORM_NONE: - break; - case JXFORM_FLIP_H: - do_flip_h(srcinfo, dstinfo, src_coef_arrays); - break; - case JXFORM_FLIP_V: - do_flip_v(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_TRANSPOSE: - do_transpose(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_TRANSVERSE: - do_transverse(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_ROT_90: - do_rot_90(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_ROT_180: - do_rot_180(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_ROT_270: - do_rot_270(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - } -} - -#endif /* TRANSFORMS_SUPPORTED */ - - -/* Setup decompression object to save desired markers in memory. - * This must be called before jpeg_read_header() to have the desired effect. - */ - -GLOBAL(void) -jcopy_markers_setup (j_decompress_ptr srcinfo, JCOPY_OPTION option) -{ -#ifdef SAVE_MARKERS_SUPPORTED - int m; - - /* Save comments except under NONE option */ - if (option != JCOPYOPT_NONE) { - jpeg_save_markers(srcinfo, JPEG_COM, 0xFFFF); - } - /* Save all types of APPn markers iff ALL option */ - if (option == JCOPYOPT_ALL) { - for (m = 0; m < 16; m++) - jpeg_save_markers(srcinfo, JPEG_APP0 + m, 0xFFFF); - } -#endif /* SAVE_MARKERS_SUPPORTED */ -} - -/* Copy markers saved in the given source object to the destination object. - * This should be called just after jpeg_start_compress() or - * jpeg_write_coefficients(). - * Note that those routines will have written the SOI, and also the - * JFIF APP0 or Adobe APP14 markers if selected. - */ - -GLOBAL(void) -jcopy_markers_execute (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JCOPY_OPTION option) -{ - jpeg_saved_marker_ptr marker; - - /* In the current implementation, we don't actually need to examine the - * option flag here; we just copy everything that got saved. - * But to avoid confusion, we do not output JFIF and Adobe APP14 markers - * if the encoder library already wrote one. - */ - for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) { - if (dstinfo->write_JFIF_header && - marker->marker == JPEG_APP0 && - marker->data_length >= 5 && - GETJOCTET(marker->data[0]) == 0x4A && - GETJOCTET(marker->data[1]) == 0x46 && - GETJOCTET(marker->data[2]) == 0x49 && - GETJOCTET(marker->data[3]) == 0x46 && - GETJOCTET(marker->data[4]) == 0) - continue; /* reject duplicate JFIF */ - if (dstinfo->write_Adobe_marker && - marker->marker == JPEG_APP0+14 && - marker->data_length >= 5 && - GETJOCTET(marker->data[0]) == 0x41 && - GETJOCTET(marker->data[1]) == 0x64 && - GETJOCTET(marker->data[2]) == 0x6F && - GETJOCTET(marker->data[3]) == 0x62 && - GETJOCTET(marker->data[4]) == 0x65) - continue; /* reject duplicate Adobe */ -#ifdef NEED_FAR_POINTERS - /* We could use jpeg_write_marker if the data weren't FAR... */ - { - unsigned int i; - jpeg_write_m_header(dstinfo, marker->marker, marker->data_length); - for (i = 0; i < marker->data_length; i++) - jpeg_write_m_byte(dstinfo, marker->data[i]); - } -#else - jpeg_write_marker(dstinfo, marker->marker, - marker->data, marker->data_length); -#endif - } -} +/* + * transupp.c + * + * Copyright (C) 1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains image transformation routines and other utility code + * used by the jpegtran sample application. These are NOT part of the core + * JPEG library. But we keep these routines separate from jpegtran.c to + * ease the task of maintaining jpegtran-like programs that have other user + * interfaces. + */ + +/* Although this file really shouldn't have access to the library internals, + * it's helpful to let it call jround_up() and jcopy_block_row(). + */ +#define JPEG_INTERNALS + +#include "jinclude.h" +#include "jpeglib.h" +#include "transupp.h" /* My own external interface */ + + +#if TRANSFORMS_SUPPORTED + +/* + * Lossless image transformation routines. These routines work on DCT + * coefficient arrays and thus do not require any lossy decompression + * or recompression of the image. + * Thanks to Guido Vollbeding for the initial design and code of this feature. + * + * Horizontal flipping is done in-place, using a single top-to-bottom + * pass through the virtual source array. It will thus be much the + * fastest option for images larger than main memory. + * + * The other routines require a set of destination virtual arrays, so they + * need twice as much memory as jpegtran normally does. The destination + * arrays are always written in normal scan order (top to bottom) because + * the virtual array manager expects this. The source arrays will be scanned + * in the corresponding order, which means multiple passes through the source + * arrays for most of the transforms. That could result in much thrashing + * if the image is larger than main memory. + * + * Some notes about the operating environment of the individual transform + * routines: + * 1. Both the source and destination virtual arrays are allocated from the + * source JPEG object, and therefore should be manipulated by calling the + * source's memory manager. + * 2. The destination's component count should be used. It may be smaller + * than the source's when forcing to grayscale. + * 3. Likewise the destination's sampling factors should be used. When + * forcing to grayscale the destination's sampling factors will be all 1, + * and we may as well take that as the effective iMCU size. + * 4. When "trim" is in effect, the destination's dimensions will be the + * trimmed values but the source's will be untrimmed. + * 5. All the routines assume that the source and destination buffers are + * padded out to a full iMCU boundary. This is true, although for the + * source buffer it is an undocumented property of jdcoefct.c. + * Notes 2,3,4 boil down to this: generally we should use the destination's + * dimensions and ignore the source's. + */ + + +LOCAL(void) +do_flip_h (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays) +/* Horizontal flip; done in-place, so no separate dest array is required */ +{ + JDIMENSION MCU_cols, comp_width, blk_x, blk_y; + int ci, k, offset_y; + JBLOCKARRAY buffer; + JCOEFPTR ptr1, ptr2; + JCOEF temp1, temp2; + jpeg_component_info *compptr; + + /* Horizontal mirroring of DCT blocks is accomplished by swapping + * pairs of blocks in-place. Within a DCT block, we perform horizontal + * mirroring by changing the signs of odd-numbered columns. + * Partial iMCUs at the right edge are left untouched. + */ + MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; + for (blk_y = 0; blk_y < compptr->height_in_blocks; + blk_y += compptr->v_samp_factor) { + buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + for (blk_x = 0; blk_x * 2 < comp_width; blk_x++) { + ptr1 = buffer[offset_y][blk_x]; + ptr2 = buffer[offset_y][comp_width - blk_x - 1]; + /* this unrolled loop doesn't need to know which row it's on... */ + for (k = 0; k < DCTSIZE2; k += 2) { + temp1 = *ptr1; /* swap even column */ + temp2 = *ptr2; + *ptr1++ = temp2; + *ptr2++ = temp1; + temp1 = *ptr1; /* swap odd column with sign change */ + temp2 = *ptr2; + *ptr1++ = -temp2; + *ptr2++ = -temp1; + } + } + } + } + } +} + + +LOCAL(void) +do_flip_v (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* Vertical flip */ +{ + JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; + int ci, i, j, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JBLOCKROW src_row_ptr, dst_row_ptr; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + /* We output into a separate array because we can't touch different + * rows of the source virtual array simultaneously. Otherwise, this + * is a pretty straightforward analog of horizontal flip. + * Within a DCT block, vertical mirroring is done by changing the signs + * of odd-numbered rows. + * Partial iMCUs at the bottom edge are copied verbatim. + */ + MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_height = MCU_rows * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + if (dst_blk_y < comp_height) { + /* Row is within the mirrorable area. */ + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } else { + /* Bottom-edge blocks will be copied verbatim. */ + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + if (dst_blk_y < comp_height) { + /* Row is within the mirrorable area. */ + dst_row_ptr = dst_buffer[offset_y]; + src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x++) { + dst_ptr = dst_row_ptr[dst_blk_x]; + src_ptr = src_row_ptr[dst_blk_x]; + for (i = 0; i < DCTSIZE; i += 2) { + /* copy even row */ + for (j = 0; j < DCTSIZE; j++) + *dst_ptr++ = *src_ptr++; + /* copy odd row with sign change */ + for (j = 0; j < DCTSIZE; j++) + *dst_ptr++ = - *src_ptr++; + } + } + } else { + /* Just copy row verbatim. */ + jcopy_block_row(src_buffer[offset_y], dst_buffer[offset_y], + compptr->width_in_blocks); + } + } + } + } +} + + +LOCAL(void) +do_transpose (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* Transpose source into destination */ +{ + JDIMENSION dst_blk_x, dst_blk_y; + int ci, i, j, offset_x, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + /* Transposing pixels within a block just requires transposing the + * DCT coefficients. + * Partial iMCUs at the edges require no special treatment; we simply + * process all the available DCT blocks for every component. + */ + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x += compptr->h_samp_factor) { + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, + (JDIMENSION) compptr->h_samp_factor, FALSE); + for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { + src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; + dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; + for (i = 0; i < DCTSIZE; i++) + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + } + } + } + } + } +} + + +LOCAL(void) +do_rot_90 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* 90 degree rotation is equivalent to + * 1. Transposing the image; + * 2. Horizontal mirroring. + * These two steps are merged into a single processing routine. + */ +{ + JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y; + int ci, i, j, offset_x, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + /* Because of the horizontal mirror step, we can't process partial iMCUs + * at the (output) right edge properly. They just get transposed and + * not mirrored. + */ + MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x += compptr->h_samp_factor) { + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, + (JDIMENSION) compptr->h_samp_factor, FALSE); + for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { + src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; + if (dst_blk_x < comp_width) { + /* Block is within the mirrorable area. */ + dst_ptr = dst_buffer[offset_y] + [comp_width - dst_blk_x - offset_x - 1]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + i++; + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; + } + } else { + /* Edge blocks are transposed but not mirrored. */ + dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; + for (i = 0; i < DCTSIZE; i++) + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + } + } + } + } + } + } +} + + +LOCAL(void) +do_rot_270 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* 270 degree rotation is equivalent to + * 1. Horizontal mirroring; + * 2. Transposing the image. + * These two steps are merged into a single processing routine. + */ +{ + JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; + int ci, i, j, offset_x, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + /* Because of the horizontal mirror step, we can't process partial iMCUs + * at the (output) bottom edge properly. They just get transposed and + * not mirrored. + */ + MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_height = MCU_rows * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x += compptr->h_samp_factor) { + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, + (JDIMENSION) compptr->h_samp_factor, FALSE); + for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { + dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; + if (dst_blk_y < comp_height) { + /* Block is within the mirrorable area. */ + src_ptr = src_buffer[offset_x] + [comp_height - dst_blk_y - offset_y - 1]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) { + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + j++; + dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; + } + } + } else { + /* Edge blocks are transposed but not mirrored. */ + src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; + for (i = 0; i < DCTSIZE; i++) + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + } + } + } + } + } + } +} + + +LOCAL(void) +do_rot_180 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* 180 degree rotation is equivalent to + * 1. Vertical mirroring; + * 2. Horizontal mirroring. + * These two steps are merged into a single processing routine. + */ +{ + JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; + int ci, i, j, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JBLOCKROW src_row_ptr, dst_row_ptr; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); + MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; + comp_height = MCU_rows * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + if (dst_blk_y < comp_height) { + /* Row is within the vertically mirrorable area. */ + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } else { + /* Bottom-edge rows are only mirrored horizontally. */ + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + if (dst_blk_y < comp_height) { + /* Row is within the mirrorable area. */ + dst_row_ptr = dst_buffer[offset_y]; + src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; + /* Process the blocks that can be mirrored both ways. */ + for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) { + dst_ptr = dst_row_ptr[dst_blk_x]; + src_ptr = src_row_ptr[comp_width - dst_blk_x - 1]; + for (i = 0; i < DCTSIZE; i += 2) { + /* For even row, negate every odd column. */ + for (j = 0; j < DCTSIZE; j += 2) { + *dst_ptr++ = *src_ptr++; + *dst_ptr++ = - *src_ptr++; + } + /* For odd row, negate every even column. */ + for (j = 0; j < DCTSIZE; j += 2) { + *dst_ptr++ = - *src_ptr++; + *dst_ptr++ = *src_ptr++; + } + } + } + /* Any remaining right-edge blocks are only mirrored vertically. */ + for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { + dst_ptr = dst_row_ptr[dst_blk_x]; + src_ptr = src_row_ptr[dst_blk_x]; + for (i = 0; i < DCTSIZE; i += 2) { + for (j = 0; j < DCTSIZE; j++) + *dst_ptr++ = *src_ptr++; + for (j = 0; j < DCTSIZE; j++) + *dst_ptr++ = - *src_ptr++; + } + } + } else { + /* Remaining rows are just mirrored horizontally. */ + dst_row_ptr = dst_buffer[offset_y]; + src_row_ptr = src_buffer[offset_y]; + /* Process the blocks that can be mirrored. */ + for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) { + dst_ptr = dst_row_ptr[dst_blk_x]; + src_ptr = src_row_ptr[comp_width - dst_blk_x - 1]; + for (i = 0; i < DCTSIZE2; i += 2) { + *dst_ptr++ = *src_ptr++; + *dst_ptr++ = - *src_ptr++; + } + } + /* Any remaining right-edge blocks are only copied. */ + for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { + dst_ptr = dst_row_ptr[dst_blk_x]; + src_ptr = src_row_ptr[dst_blk_x]; + for (i = 0; i < DCTSIZE2; i++) + *dst_ptr++ = *src_ptr++; + } + } + } + } + } +} + + +LOCAL(void) +do_transverse (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* Transverse transpose is equivalent to + * 1. 180 degree rotation; + * 2. Transposition; + * or + * 1. Horizontal mirroring; + * 2. Transposition; + * 3. Horizontal mirroring. + * These steps are merged into a single processing routine. + */ +{ + JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; + int ci, i, j, offset_x, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); + MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; + comp_height = MCU_rows * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x += compptr->h_samp_factor) { + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, + (JDIMENSION) compptr->h_samp_factor, FALSE); + for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { + if (dst_blk_y < comp_height) { + src_ptr = src_buffer[offset_x] + [comp_height - dst_blk_y - offset_y - 1]; + if (dst_blk_x < comp_width) { + /* Block is within the mirrorable area. */ + dst_ptr = dst_buffer[offset_y] + [comp_width - dst_blk_x - offset_x - 1]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) { + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + j++; + dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; + } + i++; + for (j = 0; j < DCTSIZE; j++) { + dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; + j++; + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + } + } + } else { + /* Right-edge blocks are mirrored in y only */ + dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) { + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + j++; + dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; + } + } + } + } else { + src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; + if (dst_blk_x < comp_width) { + /* Bottom-edge blocks are mirrored in x only */ + dst_ptr = dst_buffer[offset_y] + [comp_width - dst_blk_x - offset_x - 1]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + i++; + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; + } + } else { + /* At lower right corner, just transpose, no mirroring */ + dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; + for (i = 0; i < DCTSIZE; i++) + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + } + } + } + } + } + } + } +} + + +/* Request any required workspace. + * + * We allocate the workspace virtual arrays from the source decompression + * object, so that all the arrays (both the original data and the workspace) + * will be taken into account while making memory management decisions. + * Hence, this routine must be called after jpeg_read_header (which reads + * the image dimensions) and before jpeg_read_coefficients (which realizes + * the source's virtual arrays). + */ + +GLOBAL(void) +jtransform_request_workspace (j_decompress_ptr srcinfo, + jpeg_transform_info *info) +{ + jvirt_barray_ptr *coef_arrays = NULL; + jpeg_component_info *compptr; + int ci; + + if (info->force_grayscale && + srcinfo->jpeg_color_space == JCS_YCbCr && + srcinfo->num_components == 3) { + /* We'll only process the first component */ + info->num_components = 1; + } else { + /* Process all the components */ + info->num_components = srcinfo->num_components; + } + + switch (info->transform) { + case JXFORM_NONE: + case JXFORM_FLIP_H: + /* Don't need a workspace array */ + break; + case JXFORM_FLIP_V: + case JXFORM_ROT_180: + /* Need workspace arrays having same dimensions as source image. + * Note that we allocate arrays padded out to the next iMCU boundary, + * so that transform routines need not worry about missing edge blocks. + */ + coef_arrays = (jvirt_barray_ptr *) + (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, + SIZEOF(jvirt_barray_ptr) * info->num_components); + for (ci = 0; ci < info->num_components; ci++) { + compptr = srcinfo->comp_info + ci; + coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) + ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) jround_up((long) compptr->width_in_blocks, + (long) compptr->h_samp_factor), + (JDIMENSION) jround_up((long) compptr->height_in_blocks, + (long) compptr->v_samp_factor), + (JDIMENSION) compptr->v_samp_factor); + } + break; + case JXFORM_TRANSPOSE: + case JXFORM_TRANSVERSE: + case JXFORM_ROT_90: + case JXFORM_ROT_270: + /* Need workspace arrays having transposed dimensions. + * Note that we allocate arrays padded out to the next iMCU boundary, + * so that transform routines need not worry about missing edge blocks. + */ + coef_arrays = (jvirt_barray_ptr *) + (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, + SIZEOF(jvirt_barray_ptr) * info->num_components); + for (ci = 0; ci < info->num_components; ci++) { + compptr = srcinfo->comp_info + ci; + coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) + ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) jround_up((long) compptr->height_in_blocks, + (long) compptr->v_samp_factor), + (JDIMENSION) jround_up((long) compptr->width_in_blocks, + (long) compptr->h_samp_factor), + (JDIMENSION) compptr->h_samp_factor); + } + break; + } + info->workspace_coef_arrays = coef_arrays; +} + + +/* Transpose destination image parameters */ + +LOCAL(void) +transpose_critical_parameters (j_compress_ptr dstinfo) +{ + int tblno, i, j, ci, itemp; + jpeg_component_info *compptr; + JQUANT_TBL *qtblptr; + JDIMENSION dtemp; + UINT16 qtemp; + + /* Transpose basic image dimensions */ + dtemp = dstinfo->image_width; + dstinfo->image_width = dstinfo->image_height; + dstinfo->image_height = dtemp; + + /* Transpose sampling factors */ + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + itemp = compptr->h_samp_factor; + compptr->h_samp_factor = compptr->v_samp_factor; + compptr->v_samp_factor = itemp; + } + + /* Transpose quantization tables */ + for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { + qtblptr = dstinfo->quant_tbl_ptrs[tblno]; + if (qtblptr != NULL) { + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < i; j++) { + qtemp = qtblptr->quantval[i*DCTSIZE+j]; + qtblptr->quantval[i*DCTSIZE+j] = qtblptr->quantval[j*DCTSIZE+i]; + qtblptr->quantval[j*DCTSIZE+i] = qtemp; + } + } + } + } +} + + +/* Trim off any partial iMCUs on the indicated destination edge */ + +LOCAL(void) +trim_right_edge (j_compress_ptr dstinfo) +{ + int ci, max_h_samp_factor; + JDIMENSION MCU_cols; + + /* We have to compute max_h_samp_factor ourselves, + * because it hasn't been set yet in the destination + * (and we don't want to use the source's value). + */ + max_h_samp_factor = 1; + for (ci = 0; ci < dstinfo->num_components; ci++) { + int h_samp_factor = dstinfo->comp_info[ci].h_samp_factor; + max_h_samp_factor = MAX(max_h_samp_factor, h_samp_factor); + } + MCU_cols = dstinfo->image_width / (max_h_samp_factor * DCTSIZE); + if (MCU_cols > 0) /* can't trim to 0 pixels */ + dstinfo->image_width = MCU_cols * (max_h_samp_factor * DCTSIZE); +} + +LOCAL(void) +trim_bottom_edge (j_compress_ptr dstinfo) +{ + int ci, max_v_samp_factor; + JDIMENSION MCU_rows; + + /* We have to compute max_v_samp_factor ourselves, + * because it hasn't been set yet in the destination + * (and we don't want to use the source's value). + */ + max_v_samp_factor = 1; + for (ci = 0; ci < dstinfo->num_components; ci++) { + int v_samp_factor = dstinfo->comp_info[ci].v_samp_factor; + max_v_samp_factor = MAX(max_v_samp_factor, v_samp_factor); + } + MCU_rows = dstinfo->image_height / (max_v_samp_factor * DCTSIZE); + if (MCU_rows > 0) /* can't trim to 0 pixels */ + dstinfo->image_height = MCU_rows * (max_v_samp_factor * DCTSIZE); +} + + +/* Adjust output image parameters as needed. + * + * This must be called after jpeg_copy_critical_parameters() + * and before jpeg_write_coefficients(). + * + * The return value is the set of virtual coefficient arrays to be written + * (either the ones allocated by jtransform_request_workspace, or the + * original source data arrays). The caller will need to pass this value + * to jpeg_write_coefficients(). + */ + +GLOBAL(jvirt_barray_ptr *) +jtransform_adjust_parameters (j_decompress_ptr srcinfo, + j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jpeg_transform_info *info) +{ + /* If force-to-grayscale is requested, adjust destination parameters */ + if (info->force_grayscale) { + /* We use jpeg_set_colorspace to make sure subsidiary settings get fixed + * properly. Among other things, the target h_samp_factor & v_samp_factor + * will get set to 1, which typically won't match the source. + * In fact we do this even if the source is already grayscale; that + * provides an easy way of coercing a grayscale JPEG with funny sampling + * factors to the customary 1,1. (Some decoders fail on other factors.) + */ + if ((dstinfo->jpeg_color_space == JCS_YCbCr && + dstinfo->num_components == 3) || + (dstinfo->jpeg_color_space == JCS_GRAYSCALE && + dstinfo->num_components == 1)) { + /* We have to preserve the source's quantization table number. */ + int sv_quant_tbl_no = dstinfo->comp_info[0].quant_tbl_no; + jpeg_set_colorspace(dstinfo, JCS_GRAYSCALE); + dstinfo->comp_info[0].quant_tbl_no = sv_quant_tbl_no; + } else { + /* Sorry, can't do it */ + ERREXIT(dstinfo, JERR_CONVERSION_NOTIMPL); + } + } + + /* Correct the destination's image dimensions etc if necessary */ + switch (info->transform) { + case JXFORM_NONE: + /* Nothing to do */ + break; + case JXFORM_FLIP_H: + if (info->trim) + trim_right_edge(dstinfo); + break; + case JXFORM_FLIP_V: + if (info->trim) + trim_bottom_edge(dstinfo); + break; + case JXFORM_TRANSPOSE: + transpose_critical_parameters(dstinfo); + /* transpose does NOT have to trim anything */ + break; + case JXFORM_TRANSVERSE: + transpose_critical_parameters(dstinfo); + if (info->trim) { + trim_right_edge(dstinfo); + trim_bottom_edge(dstinfo); + } + break; + case JXFORM_ROT_90: + transpose_critical_parameters(dstinfo); + if (info->trim) + trim_right_edge(dstinfo); + break; + case JXFORM_ROT_180: + if (info->trim) { + trim_right_edge(dstinfo); + trim_bottom_edge(dstinfo); + } + break; + case JXFORM_ROT_270: + transpose_critical_parameters(dstinfo); + if (info->trim) + trim_bottom_edge(dstinfo); + break; + } + + /* Return the appropriate output data set */ + if (info->workspace_coef_arrays != NULL) + return info->workspace_coef_arrays; + return src_coef_arrays; +} + + +/* Execute the actual transformation, if any. + * + * This must be called *after* jpeg_write_coefficients, because it depends + * on jpeg_write_coefficients to have computed subsidiary values such as + * the per-component width and height fields in the destination object. + * + * Note that some transformations will modify the source data arrays! + */ + +GLOBAL(void) +jtransform_execute_transformation (j_decompress_ptr srcinfo, + j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jpeg_transform_info *info) +{ + jvirt_barray_ptr *dst_coef_arrays = info->workspace_coef_arrays; + + switch (info->transform) { + case JXFORM_NONE: + break; + case JXFORM_FLIP_H: + do_flip_h(srcinfo, dstinfo, src_coef_arrays); + break; + case JXFORM_FLIP_V: + do_flip_v(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_TRANSPOSE: + do_transpose(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_TRANSVERSE: + do_transverse(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_ROT_90: + do_rot_90(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_ROT_180: + do_rot_180(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_ROT_270: + do_rot_270(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); + break; + } +} + +#endif /* TRANSFORMS_SUPPORTED */ + + +/* Setup decompression object to save desired markers in memory. + * This must be called before jpeg_read_header() to have the desired effect. + */ + +GLOBAL(void) +jcopy_markers_setup (j_decompress_ptr srcinfo, JCOPY_OPTION option) +{ +#ifdef SAVE_MARKERS_SUPPORTED + int m; + + /* Save comments except under NONE option */ + if (option != JCOPYOPT_NONE) { + jpeg_save_markers(srcinfo, JPEG_COM, 0xFFFF); + } + /* Save all types of APPn markers iff ALL option */ + if (option == JCOPYOPT_ALL) { + for (m = 0; m < 16; m++) + jpeg_save_markers(srcinfo, JPEG_APP0 + m, 0xFFFF); + } +#endif /* SAVE_MARKERS_SUPPORTED */ +} + +/* Copy markers saved in the given source object to the destination object. + * This should be called just after jpeg_start_compress() or + * jpeg_write_coefficients(). + * Note that those routines will have written the SOI, and also the + * JFIF APP0 or Adobe APP14 markers if selected. + */ + +GLOBAL(void) +jcopy_markers_execute (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JCOPY_OPTION option) +{ + jpeg_saved_marker_ptr marker; + + /* In the current implementation, we don't actually need to examine the + * option flag here; we just copy everything that got saved. + * But to avoid confusion, we do not output JFIF and Adobe APP14 markers + * if the encoder library already wrote one. + */ + for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) { + if (dstinfo->write_JFIF_header && + marker->marker == JPEG_APP0 && + marker->data_length >= 5 && + GETJOCTET(marker->data[0]) == 0x4A && + GETJOCTET(marker->data[1]) == 0x46 && + GETJOCTET(marker->data[2]) == 0x49 && + GETJOCTET(marker->data[3]) == 0x46 && + GETJOCTET(marker->data[4]) == 0) + continue; /* reject duplicate JFIF */ + if (dstinfo->write_Adobe_marker && + marker->marker == JPEG_APP0+14 && + marker->data_length >= 5 && + GETJOCTET(marker->data[0]) == 0x41 && + GETJOCTET(marker->data[1]) == 0x64 && + GETJOCTET(marker->data[2]) == 0x6F && + GETJOCTET(marker->data[3]) == 0x62 && + GETJOCTET(marker->data[4]) == 0x65) + continue; /* reject duplicate Adobe */ +#ifdef NEED_FAR_POINTERS + /* We could use jpeg_write_marker if the data weren't FAR... */ + { + unsigned int i; + jpeg_write_m_header(dstinfo, marker->marker, marker->data_length); + for (i = 0; i < marker->data_length; i++) + jpeg_write_m_byte(dstinfo, marker->data[i]); + } +#else + jpeg_write_marker(dstinfo, marker->marker, + marker->data, marker->data_length); +#endif + } +} diff --git a/src/dep/src/irrlicht/jpeglib/transupp.h b/src/dep/src/irrlicht/jpeglib/transupp.h index eb0b055..5c2d32a 100644 --- a/src/dep/src/irrlicht/jpeglib/transupp.h +++ b/src/dep/src/irrlicht/jpeglib/transupp.h @@ -1,135 +1,135 @@ -/* - * transupp.h - * - * Copyright (C) 1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for image transformation routines and - * other utility code used by the jpegtran sample application. These are - * NOT part of the core JPEG library. But we keep these routines separate - * from jpegtran.c to ease the task of maintaining jpegtran-like programs - * that have other user interfaces. - * - * NOTE: all the routines declared here have very specific requirements - * about when they are to be executed during the reading and writing of the - * source and destination files. See the comments in transupp.c, or see - * jpegtran.c for an example of correct usage. - */ - -/* If you happen not to want the image transform support, disable it here */ -#ifndef TRANSFORMS_SUPPORTED -#define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */ -#endif - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jtransform_request_workspace jTrRequest -#define jtransform_adjust_parameters jTrAdjust -#define jtransform_execute_transformation jTrExec -#define jcopy_markers_setup jCMrkSetup -#define jcopy_markers_execute jCMrkExec -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* - * Codes for supported types of image transformations. - */ - -typedef enum { - JXFORM_NONE, /* no transformation */ - JXFORM_FLIP_H, /* horizontal flip */ - JXFORM_FLIP_V, /* vertical flip */ - JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */ - JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */ - JXFORM_ROT_90, /* 90-degree clockwise rotation */ - JXFORM_ROT_180, /* 180-degree rotation */ - JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */ -} JXFORM_CODE; - -/* - * Although rotating and flipping data expressed as DCT coefficients is not - * hard, there is an asymmetry in the JPEG format specification for images - * whose dimensions aren't multiples of the iMCU size. The right and bottom - * image edges are padded out to the next iMCU boundary with junk data; but - * no padding is possible at the top and left edges. If we were to flip - * the whole image including the pad data, then pad garbage would become - * visible at the top and/or left, and real pixels would disappear into the - * pad margins --- perhaps permanently, since encoders & decoders may not - * bother to preserve DCT blocks that appear to be completely outside the - * nominal image area. So, we have to exclude any partial iMCUs from the - * basic transformation. - * - * Transpose is the only transformation that can handle partial iMCUs at the - * right and bottom edges completely cleanly. flip_h can flip partial iMCUs - * at the bottom, but leaves any partial iMCUs at the right edge untouched. - * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched. - * The other transforms are defined as combinations of these basic transforms - * and process edge blocks in a way that preserves the equivalence. - * - * The "trim" option causes untransformable partial iMCUs to be dropped; - * this is not strictly lossless, but it usually gives the best-looking - * result for odd-size images. Note that when this option is active, - * the expected mathematical equivalences between the transforms may not hold. - * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim - * followed by -rot 180 -trim trims both edges.) - * - * We also offer a "force to grayscale" option, which simply discards the - * chrominance channels of a YCbCr image. This is lossless in the sense that - * the luminance channel is preserved exactly. It's not the same kind of - * thing as the rotate/flip transformations, but it's convenient to handle it - * as part of this package, mainly because the transformation routines have to - * be aware of the option to know how many components to work on. - */ - -typedef struct { - /* Options: set by caller */ - JXFORM_CODE transform; /* image transform operator */ - boolean trim; /* if TRUE, trim partial MCUs as needed */ - boolean force_grayscale; /* if TRUE, convert color image to grayscale */ - - /* Internal workspace: caller should not touch these */ - int num_components; /* # of components in workspace */ - jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */ -} jpeg_transform_info; - - -#if TRANSFORMS_SUPPORTED - -/* Request any required workspace */ -EXTERN(void) jtransform_request_workspace - JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info)); -/* Adjust output image parameters */ -EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters - JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jpeg_transform_info *info)); -/* Execute the actual transformation, if any */ -EXTERN(void) jtransform_execute_transformation - JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jpeg_transform_info *info)); - -#endif /* TRANSFORMS_SUPPORTED */ - - -/* - * Support for copying optional markers from source to destination file. - */ - -typedef enum { - JCOPYOPT_NONE, /* copy no optional markers */ - JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */ - JCOPYOPT_ALL /* copy all optional markers */ -} JCOPY_OPTION; - -#define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */ - -/* Setup decompression object to save desired markers in memory */ -EXTERN(void) jcopy_markers_setup - JPP((j_decompress_ptr srcinfo, JCOPY_OPTION option)); -/* Copy markers saved in the given source object to the destination object */ -EXTERN(void) jcopy_markers_execute - JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JCOPY_OPTION option)); +/* + * transupp.h + * + * Copyright (C) 1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains declarations for image transformation routines and + * other utility code used by the jpegtran sample application. These are + * NOT part of the core JPEG library. But we keep these routines separate + * from jpegtran.c to ease the task of maintaining jpegtran-like programs + * that have other user interfaces. + * + * NOTE: all the routines declared here have very specific requirements + * about when they are to be executed during the reading and writing of the + * source and destination files. See the comments in transupp.c, or see + * jpegtran.c for an example of correct usage. + */ + +/* If you happen not to want the image transform support, disable it here */ +#ifndef TRANSFORMS_SUPPORTED +#define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */ +#endif + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jtransform_request_workspace jTrRequest +#define jtransform_adjust_parameters jTrAdjust +#define jtransform_execute_transformation jTrExec +#define jcopy_markers_setup jCMrkSetup +#define jcopy_markers_execute jCMrkExec +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* + * Codes for supported types of image transformations. + */ + +typedef enum { + JXFORM_NONE, /* no transformation */ + JXFORM_FLIP_H, /* horizontal flip */ + JXFORM_FLIP_V, /* vertical flip */ + JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */ + JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */ + JXFORM_ROT_90, /* 90-degree clockwise rotation */ + JXFORM_ROT_180, /* 180-degree rotation */ + JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */ +} JXFORM_CODE; + +/* + * Although rotating and flipping data expressed as DCT coefficients is not + * hard, there is an asymmetry in the JPEG format specification for images + * whose dimensions aren't multiples of the iMCU size. The right and bottom + * image edges are padded out to the next iMCU boundary with junk data; but + * no padding is possible at the top and left edges. If we were to flip + * the whole image including the pad data, then pad garbage would become + * visible at the top and/or left, and real pixels would disappear into the + * pad margins --- perhaps permanently, since encoders & decoders may not + * bother to preserve DCT blocks that appear to be completely outside the + * nominal image area. So, we have to exclude any partial iMCUs from the + * basic transformation. + * + * Transpose is the only transformation that can handle partial iMCUs at the + * right and bottom edges completely cleanly. flip_h can flip partial iMCUs + * at the bottom, but leaves any partial iMCUs at the right edge untouched. + * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched. + * The other transforms are defined as combinations of these basic transforms + * and process edge blocks in a way that preserves the equivalence. + * + * The "trim" option causes untransformable partial iMCUs to be dropped; + * this is not strictly lossless, but it usually gives the best-looking + * result for odd-size images. Note that when this option is active, + * the expected mathematical equivalences between the transforms may not hold. + * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim + * followed by -rot 180 -trim trims both edges.) + * + * We also offer a "force to grayscale" option, which simply discards the + * chrominance channels of a YCbCr image. This is lossless in the sense that + * the luminance channel is preserved exactly. It's not the same kind of + * thing as the rotate/flip transformations, but it's convenient to handle it + * as part of this package, mainly because the transformation routines have to + * be aware of the option to know how many components to work on. + */ + +typedef struct { + /* Options: set by caller */ + JXFORM_CODE transform; /* image transform operator */ + boolean trim; /* if TRUE, trim partial MCUs as needed */ + boolean force_grayscale; /* if TRUE, convert color image to grayscale */ + + /* Internal workspace: caller should not touch these */ + int num_components; /* # of components in workspace */ + jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */ +} jpeg_transform_info; + + +#if TRANSFORMS_SUPPORTED + +/* Request any required workspace */ +EXTERN(void) jtransform_request_workspace + JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info)); +/* Adjust output image parameters */ +EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters + JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jpeg_transform_info *info)); +/* Execute the actual transformation, if any */ +EXTERN(void) jtransform_execute_transformation + JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jpeg_transform_info *info)); + +#endif /* TRANSFORMS_SUPPORTED */ + + +/* + * Support for copying optional markers from source to destination file. + */ + +typedef enum { + JCOPYOPT_NONE, /* copy no optional markers */ + JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */ + JCOPYOPT_ALL /* copy all optional markers */ +} JCOPY_OPTION; + +#define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */ + +/* Setup decompression object to save desired markers in memory */ +EXTERN(void) jcopy_markers_setup + JPP((j_decompress_ptr srcinfo, JCOPY_OPTION option)); +/* Copy markers saved in the given source object to the destination object */ +EXTERN(void) jcopy_markers_execute + JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JCOPY_OPTION option)); diff --git a/src/dep/src/irrlicht/jpeglib/usage.doc b/src/dep/src/irrlicht/jpeglib/usage.doc index 4c1a1c2..8c4970a 100644 --- a/src/dep/src/irrlicht/jpeglib/usage.doc +++ b/src/dep/src/irrlicht/jpeglib/usage.doc @@ -1,562 +1,562 @@ -USAGE instructions for the Independent JPEG Group's JPEG software -================================================================= - -This file describes usage of the JPEG conversion programs cjpeg and djpeg, -as well as the utility programs jpegtran, rdjpgcom and wrjpgcom. (See -the other documentation files if you wish to use the JPEG library within -your own programs.) - -If you are on a Unix machine you may prefer to read the Unix-style manual -pages in files cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1. - - -INTRODUCTION - -These programs implement JPEG image compression and decompression. JPEG -(pronounced "jay-peg") is a standardized compression method for full-color -and gray-scale images. JPEG is designed to handle "real-world" scenes, -for example scanned photographs. Cartoons, line drawings, and other -non-realistic images are not JPEG's strong suit; on that sort of material -you may get poor image quality and/or little compression. - -JPEG is lossy, meaning that the output image is not necessarily identical to -the input image. Hence you should not use JPEG if you have to have identical -output bits. However, on typical real-world images, very good compression -levels can be obtained with no visible change, and amazingly high compression -is possible if you can tolerate a low-quality image. You can trade off image -quality against file size by adjusting the compressor's "quality" setting. - - -GENERAL USAGE - -We provide two programs, cjpeg to compress an image file into JPEG format, -and djpeg to decompress a JPEG file back into a conventional image format. - -On Unix-like systems, you say: - cjpeg [switches] [imagefile] >jpegfile -or - djpeg [switches] [jpegfile] >imagefile -The programs read the specified input file, or standard input if none is -named. They always write to standard output (with trace/error messages to -standard error). These conventions are handy for piping images between -programs. - -On most non-Unix systems, you say: - cjpeg [switches] imagefile jpegfile -or - djpeg [switches] jpegfile imagefile -i.e., both the input and output files are named on the command line. This -style is a little more foolproof, and it loses no functionality if you don't -have pipes. (You can get this style on Unix too, if you prefer, by defining -TWO_FILE_COMMANDLINE when you compile the programs; see install.doc.) - -You can also say: - cjpeg [switches] -outfile jpegfile imagefile -or - djpeg [switches] -outfile imagefile jpegfile -This syntax works on all systems, so it is useful for scripts. - -The currently supported image file formats are: PPM (PBMPLUS color format), -PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster Toolkit -format). (RLE is supported only if the URT library is available.) -cjpeg recognizes the input image format automatically, with the exception -of some Targa-format files. You have to tell djpeg which format to generate. - -JPEG files are in the defacto standard JFIF file format. There are other, -less widely used JPEG-based file formats, but we don't support them. - -All switch names may be abbreviated; for example, -grayscale may be written --gray or -gr. Most of the "basic" switches can be abbreviated to as little as -one letter. Upper and lower case are equivalent (-BMP is the same as -bmp). -British spellings are also accepted (e.g., -greyscale), though for brevity -these are not mentioned below. - - -CJPEG DETAILS - -The basic command line switches for cjpeg are: - - -quality N Scale quantization tables to adjust image quality. - Quality is 0 (worst) to 100 (best); default is 75. - (See below for more info.) - - -grayscale Create monochrome JPEG file from color input. - Be sure to use this switch when compressing a grayscale - BMP file, because cjpeg isn't bright enough to notice - whether a BMP file uses only shades of gray. By - saying -grayscale, you'll get a smaller JPEG file that - takes less time to process. - - -optimize Perform optimization of entropy encoding parameters. - Without this, default encoding parameters are used. - -optimize usually makes the JPEG file a little smaller, - but cjpeg runs somewhat slower and needs much more - memory. Image quality and speed of decompression are - unaffected by -optimize. - - -progressive Create progressive JPEG file (see below). - - -targa Input file is Targa format. Targa files that contain - an "identification" field will not be automatically - recognized by cjpeg; for such files you must specify - -targa to make cjpeg treat the input as Targa format. - For most Targa files, you won't need this switch. - -The -quality switch lets you trade off compressed file size against quality of -the reconstructed image: the higher the quality setting, the larger the JPEG -file, and the closer the output image will be to the original input. Normally -you want to use the lowest quality setting (smallest file) that decompresses -into something visually indistinguishable from the original image. For this -purpose the quality setting should be between 50 and 95; the default of 75 is -often about right. If you see defects at -quality 75, then go up 5 or 10 -counts at a time until you are happy with the output image. (The optimal -setting will vary from one image to another.) - --quality 100 will generate a quantization table of all 1's, minimizing loss -in the quantization step (but there is still information loss in subsampling, -as well as roundoff error). This setting is mainly of interest for -experimental purposes. Quality values above about 95 are NOT recommended for -normal use; the compressed file size goes up dramatically for hardly any gain -in output image quality. - -In the other direction, quality values below 50 will produce very small files -of low image quality. Settings around 5 to 10 might be useful in preparing an -index of a large image library, for example. Try -quality 2 (or so) for some -amusing Cubist effects. (Note: quality values below about 25 generate 2-byte -quantization tables, which are considered optional in the JPEG standard. -cjpeg emits a warning message when you give such a quality value, because some -other JPEG programs may be unable to decode the resulting file. Use -baseline -if you need to ensure compatibility at low quality values.) - -The -progressive switch creates a "progressive JPEG" file. In this type of -JPEG file, the data is stored in multiple scans of increasing quality. If the -file is being transmitted over a slow communications link, the decoder can use -the first scan to display a low-quality image very quickly, and can then -improve the display with each subsequent scan. The final image is exactly -equivalent to a standard JPEG file of the same quality setting, and the total -file size is about the same --- often a little smaller. CAUTION: progressive -JPEG is not yet widely implemented, so many decoders will be unable to view a -progressive JPEG file at all. - -Switches for advanced users: - - -dct int Use integer DCT method (default). - -dct fast Use fast integer DCT (less accurate). - -dct float Use floating-point DCT method. - The float method is very slightly more accurate than - the int method, but is much slower unless your machine - has very fast floating-point hardware. Also note that - results of the floating-point method may vary slightly - across machines, while the integer methods should give - the same results everywhere. The fast integer method - is much less accurate than the other two. - - -restart N Emit a JPEG restart marker every N MCU rows, or every - N MCU blocks if "B" is attached to the number. - -restart 0 (the default) means no restart markers. - - -smooth N Smooth the input image to eliminate dithering noise. - N, ranging from 1 to 100, indicates the strength of - smoothing. 0 (the default) means no smoothing. - - -maxmemory N Set limit for amount of memory to use in processing - large images. Value is in thousands of bytes, or - millions of bytes if "M" is attached to the number. - For example, -max 4m selects 4000000 bytes. If more - space is needed, temporary files will be used. - - -verbose Enable debug printout. More -v's give more printout. - or -debug Also, version information is printed at startup. - -The -restart option inserts extra markers that allow a JPEG decoder to -resynchronize after a transmission error. Without restart markers, any damage -to a compressed file will usually ruin the image from the point of the error -to the end of the image; with restart markers, the damage is usually confined -to the portion of the image up to the next restart marker. Of course, the -restart markers occupy extra space. We recommend -restart 1 for images that -will be transmitted across unreliable networks such as Usenet. - -The -smooth option filters the input to eliminate fine-scale noise. This is -often useful when converting dithered images to JPEG: a moderate smoothing -factor of 10 to 50 gets rid of dithering patterns in the input file, resulting -in a smaller JPEG file and a better-looking image. Too large a smoothing -factor will visibly blur the image, however. - -Switches for wizards: - - -baseline Force baseline-compatible quantization tables to be - generated. This clamps quantization values to 8 bits - even at low quality settings. (This switch is poorly - named, since it does not ensure that the output is - actually baseline JPEG. For example, you can use - -baseline and -progressive together.) - - -qtables file Use the quantization tables given in the specified - text file. - - -qslots N[,...] Select which quantization table to use for each color - component. - - -sample HxV[,...] Set JPEG sampling factors for each color component. - - -scans file Use the scan script given in the specified text file. - -The "wizard" switches are intended for experimentation with JPEG. If you -don't know what you are doing, DON'T USE THEM. These switches are documented -further in the file wizard.doc. - - -DJPEG DETAILS - -The basic command line switches for djpeg are: - - -colors N Reduce image to at most N colors. This reduces the - or -quantize N number of colors used in the output image, so that it - can be displayed on a colormapped display or stored in - a colormapped file format. For example, if you have - an 8-bit display, you'd need to reduce to 256 or fewer - colors. (-colors is the recommended name, -quantize - is provided only for backwards compatibility.) - - -fast Select recommended processing options for fast, low - quality output. (The default options are chosen for - highest quality output.) Currently, this is equivalent - to "-dct fast -nosmooth -onepass -dither ordered". - - -grayscale Force gray-scale output even if JPEG file is color. - Useful for viewing on monochrome displays; also, - djpeg runs noticeably faster in this mode. - - -scale M/N Scale the output image by a factor M/N. Currently - the scale factor must be 1/1, 1/2, 1/4, or 1/8. - Scaling is handy if the image is larger than your - screen; also, djpeg runs much faster when scaling - down the output. - - -bmp Select BMP output format (Windows flavor). 8-bit - colormapped format is emitted if -colors or -grayscale - is specified, or if the JPEG file is gray-scale; - otherwise, 24-bit full-color format is emitted. - - -gif Select GIF output format. Since GIF does not support - more than 256 colors, -colors 256 is assumed (unless - you specify a smaller number of colors). If you - specify -fast, the default number of colors is 216. - - -os2 Select BMP output format (OS/2 1.x flavor). 8-bit - colormapped format is emitted if -colors or -grayscale - is specified, or if the JPEG file is gray-scale; - otherwise, 24-bit full-color format is emitted. - - -pnm Select PBMPLUS (PPM/PGM) output format (this is the - default format). PGM is emitted if the JPEG file is - gray-scale or if -grayscale is specified; otherwise - PPM is emitted. - - -rle Select RLE output format. (Requires URT library.) - - -targa Select Targa output format. Gray-scale format is - emitted if the JPEG file is gray-scale or if - -grayscale is specified; otherwise, colormapped format - is emitted if -colors is specified; otherwise, 24-bit - full-color format is emitted. - -Switches for advanced users: - - -dct int Use integer DCT method (default). - -dct fast Use fast integer DCT (less accurate). - -dct float Use floating-point DCT method. - The float method is very slightly more accurate than - the int method, but is much slower unless your machine - has very fast floating-point hardware. Also note that - results of the floating-point method may vary slightly - across machines, while the integer methods should give - the same results everywhere. The fast integer method - is much less accurate than the other two. - - -dither fs Use Floyd-Steinberg dithering in color quantization. - -dither ordered Use ordered dithering in color quantization. - -dither none Do not use dithering in color quantization. - By default, Floyd-Steinberg dithering is applied when - quantizing colors; this is slow but usually produces - the best results. Ordered dither is a compromise - between speed and quality; no dithering is fast but - usually looks awful. Note that these switches have - no effect unless color quantization is being done. - Ordered dither is only available in -onepass mode. - - -map FILE Quantize to the colors used in the specified image - file. This is useful for producing multiple files - with identical color maps, or for forcing a predefined - set of colors to be used. The FILE must be a GIF - or PPM file. This option overrides -colors and - -onepass. - - -nosmooth Use a faster, lower-quality upsampling routine. - - -onepass Use one-pass instead of two-pass color quantization. - The one-pass method is faster and needs less memory, - but it produces a lower-quality image. -onepass is - ignored unless you also say -colors N. Also, - the one-pass method is always used for gray-scale - output (the two-pass method is no improvement then). - - -maxmemory N Set limit for amount of memory to use in processing - large images. Value is in thousands of bytes, or - millions of bytes if "M" is attached to the number. - For example, -max 4m selects 4000000 bytes. If more - space is needed, temporary files will be used. - - -verbose Enable debug printout. More -v's give more printout. - or -debug Also, version information is printed at startup. - - -HINTS FOR CJPEG - -Color GIF files are not the ideal input for JPEG; JPEG is really intended for -compressing full-color (24-bit) images. In particular, don't try to convert -cartoons, line drawings, and other images that have only a few distinct -colors. GIF works great on these, JPEG does not. If you want to convert a -GIF to JPEG, you should experiment with cjpeg's -quality and -smooth options -to get a satisfactory conversion. -smooth 10 or so is often helpful. - -Avoid running an image through a series of JPEG compression/decompression -cycles. Image quality loss will accumulate; after ten or so cycles the image -may be noticeably worse than it was after one cycle. It's best to use a -lossless format while manipulating an image, then convert to JPEG format when -you are ready to file the image away. - -The -optimize option to cjpeg is worth using when you are making a "final" -version for posting or archiving. It's also a win when you are using low -quality settings to make very small JPEG files; the percentage improvement -is often a lot more than it is on larger files. (At present, -optimize -mode is always selected when generating progressive JPEG files.) - -GIF input files are no longer supported, to avoid the Unisys LZW patent. -Use a Unisys-licensed program if you need to read a GIF file. (Conversion -of GIF files to JPEG is usually a bad idea anyway.) - - -HINTS FOR DJPEG - -To get a quick preview of an image, use the -grayscale and/or -scale switches. -"-grayscale -scale 1/8" is the fastest case. - -Several options are available that trade off image quality to gain speed. -"-fast" turns on the recommended settings. - -"-dct fast" and/or "-nosmooth" gain speed at a small sacrifice in quality. -When producing a color-quantized image, "-onepass -dither ordered" is fast but -much lower quality than the default behavior. "-dither none" may give -acceptable results in two-pass mode, but is seldom tolerable in one-pass mode. - -If you are fortunate enough to have very fast floating point hardware, -"-dct float" may be even faster than "-dct fast". But on most machines -"-dct float" is slower than "-dct int"; in this case it is not worth using, -because its theoretical accuracy advantage is too small to be significant -in practice. - -Two-pass color quantization requires a good deal of memory; on MS-DOS machines -it may run out of memory even with -maxmemory 0. In that case you can still -decompress, with some loss of image quality, by specifying -onepass for -one-pass quantization. - -To avoid the Unisys LZW patent, djpeg produces uncompressed GIF files. These -are larger than they should be, but are readable by standard GIF decoders. - - -HINTS FOR BOTH PROGRAMS - -If more space is needed than will fit in the available main memory (as -determined by -maxmemory), temporary files will be used. (MS-DOS versions -will try to get extended or expanded memory first.) The temporary files are -often rather large: in typical cases they occupy three bytes per pixel, for -example 3*800*600 = 1.44Mb for an 800x600 image. If you don't have enough -free disk space, leave out -progressive and -optimize (for cjpeg) or specify --onepass (for djpeg). - -On MS-DOS, the temporary files are created in the directory named by the TMP -or TEMP environment variable, or in the current directory if neither of those -exist. Amiga implementations put the temp files in the directory named by -JPEGTMP:, so be sure to assign JPEGTMP: to a disk partition with adequate free -space. - -The default memory usage limit (-maxmemory) is set when the software is -compiled. If you get an "insufficient memory" error, try specifying a smaller --maxmemory value, even -maxmemory 0 to use the absolute minimum space. You -may want to recompile with a smaller default value if this happens often. - -On machines that have "environment" variables, you can define the environment -variable JPEGMEM to set the default memory limit. The value is specified as -described for the -maxmemory switch. JPEGMEM overrides the default value -specified when the program was compiled, and itself is overridden by an -explicit -maxmemory switch. - -On MS-DOS machines, -maxmemory is the amount of main (conventional) memory to -use. (Extended or expanded memory is also used if available.) Most -DOS-specific versions of this software do their own memory space estimation -and do not need you to specify -maxmemory. - - -JPEGTRAN - -jpegtran performs various useful transformations of JPEG files. -It can translate the coded representation from one variant of JPEG to another, -for example from baseline JPEG to progressive JPEG or vice versa. It can also -perform some rearrangements of the image data, for example turning an image -from landscape to portrait format by rotation. - -jpegtran works by rearranging the compressed data (DCT coefficients), without -ever fully decoding the image. Therefore, its transformations are lossless: -there is no image degradation at all, which would not be true if you used -djpeg followed by cjpeg to accomplish the same conversion. But by the same -token, jpegtran cannot perform lossy operations such as changing the image -quality. - -jpegtran uses a command line syntax similar to cjpeg or djpeg. -On Unix-like systems, you say: - jpegtran [switches] [inputfile] >outputfile -On most non-Unix systems, you say: - jpegtran [switches] inputfile outputfile -where both the input and output files are JPEG files. - -To specify the coded JPEG representation used in the output file, -jpegtran accepts a subset of the switches recognized by cjpeg: - -optimize Perform optimization of entropy encoding parameters. - -progressive Create progressive JPEG file. - -restart N Emit a JPEG restart marker every N MCU rows, or every - N MCU blocks if "B" is attached to the number. - -scans file Use the scan script given in the specified text file. -See the previous discussion of cjpeg for more details about these switches. -If you specify none of these switches, you get a plain baseline-JPEG output -file. The quality setting and so forth are determined by the input file. - -The image can be losslessly transformed by giving one of these switches: - -flip horizontal Mirror image horizontally (left-right). - -flip vertical Mirror image vertically (top-bottom). - -rotate 90 Rotate image 90 degrees clockwise. - -rotate 180 Rotate image 180 degrees. - -rotate 270 Rotate image 270 degrees clockwise (or 90 ccw). - -transpose Transpose image (across UL-to-LR axis). - -transverse Transverse transpose (across UR-to-LL axis). - -The transpose transformation has no restrictions regarding image dimensions. -The other transformations operate rather oddly if the image dimensions are not -a multiple of the iMCU size (usually 8 or 16 pixels), because they can only -transform complete blocks of DCT coefficient data in the desired way. - -jpegtran's default behavior when transforming an odd-size image is designed -to preserve exact reversibility and mathematical consistency of the -transformation set. As stated, transpose is able to flip the entire image -area. Horizontal mirroring leaves any partial iMCU column at the right edge -untouched, but is able to flip all rows of the image. Similarly, vertical -mirroring leaves any partial iMCU row at the bottom edge untouched, but is -able to flip all columns. The other transforms can be built up as sequences -of transpose and flip operations; for consistency, their actions on edge -pixels are defined to be the same as the end result of the corresponding -transpose-and-flip sequence. - -For practical use, you may prefer to discard any untransformable edge pixels -rather than having a strange-looking strip along the right and/or bottom edges -of a transformed image. To do this, add the -trim switch: - -trim Drop non-transformable edge blocks. -Obviously, a transformation with -trim is not reversible, so strictly speaking -jpegtran with this switch is not lossless. Also, the expected mathematical -equivalences between the transformations no longer hold. For example, -"-rot 270 -trim" trims only the bottom edge, but "-rot 90 -trim" followed by -"-rot 180 -trim" trims both edges. - -Another not-strictly-lossless transformation switch is: - -grayscale Force grayscale output. -This option discards the chrominance channels if the input image is YCbCr -(ie, a standard color JPEG), resulting in a grayscale JPEG file. The -luminance channel is preserved exactly, so this is a better method of reducing -to grayscale than decompression, conversion, and recompression. This switch -is particularly handy for fixing a monochrome picture that was mistakenly -encoded as a color JPEG. (In such a case, the space savings from getting rid -of the near-empty chroma channels won't be large; but the decoding time for -a grayscale JPEG is substantially less than that for a color JPEG.) - -jpegtran also recognizes these switches that control what to do with "extra" -markers, such as comment blocks: - -copy none Copy no extra markers from source file. This setting - suppresses all comments and other excess baggage - present in the source file. - -copy comments Copy only comment markers. This setting copies - comments from the source file, but discards - any other inessential data. - -copy all Copy all extra markers. This setting preserves - miscellaneous markers found in the source file, such - as JFIF thumbnails and Photoshop settings. In some - files these extra markers can be sizable. -The default behavior is -copy comments. (Note: in IJG releases v6 and v6a, -jpegtran always did the equivalent of -copy none.) - -Additional switches recognized by jpegtran are: - -outfile filename - -maxmemory N - -verbose - -debug -These work the same as in cjpeg or djpeg. - - -THE COMMENT UTILITIES - -The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. -Although the standard doesn't actually define what COM blocks are for, they -are widely used to hold user-supplied text strings. This lets you add -annotations, titles, index terms, etc to your JPEG files, and later retrieve -them as text. COM blocks do not interfere with the image stored in the JPEG -file. The maximum size of a COM block is 64K, but you can have as many of -them as you like in one JPEG file. - -We provide two utility programs to display COM block contents and add COM -blocks to a JPEG file. - -rdjpgcom searches a JPEG file and prints the contents of any COM blocks on -standard output. The command line syntax is - rdjpgcom [-verbose] [inputfilename] -The switch "-verbose" (or just "-v") causes rdjpgcom to also display the JPEG -image dimensions. If you omit the input file name from the command line, -the JPEG file is read from standard input. (This may not work on some -operating systems, if binary data can't be read from stdin.) - -wrjpgcom adds a COM block, containing text you provide, to a JPEG file. -Ordinarily, the COM block is added after any existing COM blocks, but you -can delete the old COM blocks if you wish. wrjpgcom produces a new JPEG -file; it does not modify the input file. DO NOT try to overwrite the input -file by directing wrjpgcom's output back into it; on most systems this will -just destroy your file. - -The command line syntax for wrjpgcom is similar to cjpeg's. On Unix-like -systems, it is - wrjpgcom [switches] [inputfilename] -The output file is written to standard output. The input file comes from -the named file, or from standard input if no input file is named. - -On most non-Unix systems, the syntax is - wrjpgcom [switches] inputfilename outputfilename -where both input and output file names must be given explicitly. - -wrjpgcom understands three switches: - -replace Delete any existing COM blocks from the file. - -comment "Comment text" Supply new COM text on command line. - -cfile name Read text for new COM block from named file. -(Switch names can be abbreviated.) If you have only one line of comment text -to add, you can provide it on the command line with -comment. The comment -text must be surrounded with quotes so that it is treated as a single -argument. Longer comments can be read from a text file. - -If you give neither -comment nor -cfile, then wrjpgcom will read the comment -text from standard input. (In this case an input image file name MUST be -supplied, so that the source JPEG file comes from somewhere else.) You can -enter multiple lines, up to 64KB worth. Type an end-of-file indicator -(usually control-D or control-Z) to terminate the comment text entry. - -wrjpgcom will not add a COM block if the provided comment string is empty. -Therefore -replace -comment "" can be used to delete all COM blocks from a -file. - -These utility programs do not depend on the IJG JPEG library. In -particular, the source code for rdjpgcom is intended as an illustration of -the minimum amount of code required to parse a JPEG file header correctly. +USAGE instructions for the Independent JPEG Group's JPEG software +================================================================= + +This file describes usage of the JPEG conversion programs cjpeg and djpeg, +as well as the utility programs jpegtran, rdjpgcom and wrjpgcom. (See +the other documentation files if you wish to use the JPEG library within +your own programs.) + +If you are on a Unix machine you may prefer to read the Unix-style manual +pages in files cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1. + + +INTRODUCTION + +These programs implement JPEG image compression and decompression. JPEG +(pronounced "jay-peg") is a standardized compression method for full-color +and gray-scale images. JPEG is designed to handle "real-world" scenes, +for example scanned photographs. Cartoons, line drawings, and other +non-realistic images are not JPEG's strong suit; on that sort of material +you may get poor image quality and/or little compression. + +JPEG is lossy, meaning that the output image is not necessarily identical to +the input image. Hence you should not use JPEG if you have to have identical +output bits. However, on typical real-world images, very good compression +levels can be obtained with no visible change, and amazingly high compression +is possible if you can tolerate a low-quality image. You can trade off image +quality against file size by adjusting the compressor's "quality" setting. + + +GENERAL USAGE + +We provide two programs, cjpeg to compress an image file into JPEG format, +and djpeg to decompress a JPEG file back into a conventional image format. + +On Unix-like systems, you say: + cjpeg [switches] [imagefile] >jpegfile +or + djpeg [switches] [jpegfile] >imagefile +The programs read the specified input file, or standard input if none is +named. They always write to standard output (with trace/error messages to +standard error). These conventions are handy for piping images between +programs. + +On most non-Unix systems, you say: + cjpeg [switches] imagefile jpegfile +or + djpeg [switches] jpegfile imagefile +i.e., both the input and output files are named on the command line. This +style is a little more foolproof, and it loses no functionality if you don't +have pipes. (You can get this style on Unix too, if you prefer, by defining +TWO_FILE_COMMANDLINE when you compile the programs; see install.doc.) + +You can also say: + cjpeg [switches] -outfile jpegfile imagefile +or + djpeg [switches] -outfile imagefile jpegfile +This syntax works on all systems, so it is useful for scripts. + +The currently supported image file formats are: PPM (PBMPLUS color format), +PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster Toolkit +format). (RLE is supported only if the URT library is available.) +cjpeg recognizes the input image format automatically, with the exception +of some Targa-format files. You have to tell djpeg which format to generate. + +JPEG files are in the defacto standard JFIF file format. There are other, +less widely used JPEG-based file formats, but we don't support them. + +All switch names may be abbreviated; for example, -grayscale may be written +-gray or -gr. Most of the "basic" switches can be abbreviated to as little as +one letter. Upper and lower case are equivalent (-BMP is the same as -bmp). +British spellings are also accepted (e.g., -greyscale), though for brevity +these are not mentioned below. + + +CJPEG DETAILS + +The basic command line switches for cjpeg are: + + -quality N Scale quantization tables to adjust image quality. + Quality is 0 (worst) to 100 (best); default is 75. + (See below for more info.) + + -grayscale Create monochrome JPEG file from color input. + Be sure to use this switch when compressing a grayscale + BMP file, because cjpeg isn't bright enough to notice + whether a BMP file uses only shades of gray. By + saying -grayscale, you'll get a smaller JPEG file that + takes less time to process. + + -optimize Perform optimization of entropy encoding parameters. + Without this, default encoding parameters are used. + -optimize usually makes the JPEG file a little smaller, + but cjpeg runs somewhat slower and needs much more + memory. Image quality and speed of decompression are + unaffected by -optimize. + + -progressive Create progressive JPEG file (see below). + + -targa Input file is Targa format. Targa files that contain + an "identification" field will not be automatically + recognized by cjpeg; for such files you must specify + -targa to make cjpeg treat the input as Targa format. + For most Targa files, you won't need this switch. + +The -quality switch lets you trade off compressed file size against quality of +the reconstructed image: the higher the quality setting, the larger the JPEG +file, and the closer the output image will be to the original input. Normally +you want to use the lowest quality setting (smallest file) that decompresses +into something visually indistinguishable from the original image. For this +purpose the quality setting should be between 50 and 95; the default of 75 is +often about right. If you see defects at -quality 75, then go up 5 or 10 +counts at a time until you are happy with the output image. (The optimal +setting will vary from one image to another.) + +-quality 100 will generate a quantization table of all 1's, minimizing loss +in the quantization step (but there is still information loss in subsampling, +as well as roundoff error). This setting is mainly of interest for +experimental purposes. Quality values above about 95 are NOT recommended for +normal use; the compressed file size goes up dramatically for hardly any gain +in output image quality. + +In the other direction, quality values below 50 will produce very small files +of low image quality. Settings around 5 to 10 might be useful in preparing an +index of a large image library, for example. Try -quality 2 (or so) for some +amusing Cubist effects. (Note: quality values below about 25 generate 2-byte +quantization tables, which are considered optional in the JPEG standard. +cjpeg emits a warning message when you give such a quality value, because some +other JPEG programs may be unable to decode the resulting file. Use -baseline +if you need to ensure compatibility at low quality values.) + +The -progressive switch creates a "progressive JPEG" file. In this type of +JPEG file, the data is stored in multiple scans of increasing quality. If the +file is being transmitted over a slow communications link, the decoder can use +the first scan to display a low-quality image very quickly, and can then +improve the display with each subsequent scan. The final image is exactly +equivalent to a standard JPEG file of the same quality setting, and the total +file size is about the same --- often a little smaller. CAUTION: progressive +JPEG is not yet widely implemented, so many decoders will be unable to view a +progressive JPEG file at all. + +Switches for advanced users: + + -dct int Use integer DCT method (default). + -dct fast Use fast integer DCT (less accurate). + -dct float Use floating-point DCT method. + The float method is very slightly more accurate than + the int method, but is much slower unless your machine + has very fast floating-point hardware. Also note that + results of the floating-point method may vary slightly + across machines, while the integer methods should give + the same results everywhere. The fast integer method + is much less accurate than the other two. + + -restart N Emit a JPEG restart marker every N MCU rows, or every + N MCU blocks if "B" is attached to the number. + -restart 0 (the default) means no restart markers. + + -smooth N Smooth the input image to eliminate dithering noise. + N, ranging from 1 to 100, indicates the strength of + smoothing. 0 (the default) means no smoothing. + + -maxmemory N Set limit for amount of memory to use in processing + large images. Value is in thousands of bytes, or + millions of bytes if "M" is attached to the number. + For example, -max 4m selects 4000000 bytes. If more + space is needed, temporary files will be used. + + -verbose Enable debug printout. More -v's give more printout. + or -debug Also, version information is printed at startup. + +The -restart option inserts extra markers that allow a JPEG decoder to +resynchronize after a transmission error. Without restart markers, any damage +to a compressed file will usually ruin the image from the point of the error +to the end of the image; with restart markers, the damage is usually confined +to the portion of the image up to the next restart marker. Of course, the +restart markers occupy extra space. We recommend -restart 1 for images that +will be transmitted across unreliable networks such as Usenet. + +The -smooth option filters the input to eliminate fine-scale noise. This is +often useful when converting dithered images to JPEG: a moderate smoothing +factor of 10 to 50 gets rid of dithering patterns in the input file, resulting +in a smaller JPEG file and a better-looking image. Too large a smoothing +factor will visibly blur the image, however. + +Switches for wizards: + + -baseline Force baseline-compatible quantization tables to be + generated. This clamps quantization values to 8 bits + even at low quality settings. (This switch is poorly + named, since it does not ensure that the output is + actually baseline JPEG. For example, you can use + -baseline and -progressive together.) + + -qtables file Use the quantization tables given in the specified + text file. + + -qslots N[,...] Select which quantization table to use for each color + component. + + -sample HxV[,...] Set JPEG sampling factors for each color component. + + -scans file Use the scan script given in the specified text file. + +The "wizard" switches are intended for experimentation with JPEG. If you +don't know what you are doing, DON'T USE THEM. These switches are documented +further in the file wizard.doc. + + +DJPEG DETAILS + +The basic command line switches for djpeg are: + + -colors N Reduce image to at most N colors. This reduces the + or -quantize N number of colors used in the output image, so that it + can be displayed on a colormapped display or stored in + a colormapped file format. For example, if you have + an 8-bit display, you'd need to reduce to 256 or fewer + colors. (-colors is the recommended name, -quantize + is provided only for backwards compatibility.) + + -fast Select recommended processing options for fast, low + quality output. (The default options are chosen for + highest quality output.) Currently, this is equivalent + to "-dct fast -nosmooth -onepass -dither ordered". + + -grayscale Force gray-scale output even if JPEG file is color. + Useful for viewing on monochrome displays; also, + djpeg runs noticeably faster in this mode. + + -scale M/N Scale the output image by a factor M/N. Currently + the scale factor must be 1/1, 1/2, 1/4, or 1/8. + Scaling is handy if the image is larger than your + screen; also, djpeg runs much faster when scaling + down the output. + + -bmp Select BMP output format (Windows flavor). 8-bit + colormapped format is emitted if -colors or -grayscale + is specified, or if the JPEG file is gray-scale; + otherwise, 24-bit full-color format is emitted. + + -gif Select GIF output format. Since GIF does not support + more than 256 colors, -colors 256 is assumed (unless + you specify a smaller number of colors). If you + specify -fast, the default number of colors is 216. + + -os2 Select BMP output format (OS/2 1.x flavor). 8-bit + colormapped format is emitted if -colors or -grayscale + is specified, or if the JPEG file is gray-scale; + otherwise, 24-bit full-color format is emitted. + + -pnm Select PBMPLUS (PPM/PGM) output format (this is the + default format). PGM is emitted if the JPEG file is + gray-scale or if -grayscale is specified; otherwise + PPM is emitted. + + -rle Select RLE output format. (Requires URT library.) + + -targa Select Targa output format. Gray-scale format is + emitted if the JPEG file is gray-scale or if + -grayscale is specified; otherwise, colormapped format + is emitted if -colors is specified; otherwise, 24-bit + full-color format is emitted. + +Switches for advanced users: + + -dct int Use integer DCT method (default). + -dct fast Use fast integer DCT (less accurate). + -dct float Use floating-point DCT method. + The float method is very slightly more accurate than + the int method, but is much slower unless your machine + has very fast floating-point hardware. Also note that + results of the floating-point method may vary slightly + across machines, while the integer methods should give + the same results everywhere. The fast integer method + is much less accurate than the other two. + + -dither fs Use Floyd-Steinberg dithering in color quantization. + -dither ordered Use ordered dithering in color quantization. + -dither none Do not use dithering in color quantization. + By default, Floyd-Steinberg dithering is applied when + quantizing colors; this is slow but usually produces + the best results. Ordered dither is a compromise + between speed and quality; no dithering is fast but + usually looks awful. Note that these switches have + no effect unless color quantization is being done. + Ordered dither is only available in -onepass mode. + + -map FILE Quantize to the colors used in the specified image + file. This is useful for producing multiple files + with identical color maps, or for forcing a predefined + set of colors to be used. The FILE must be a GIF + or PPM file. This option overrides -colors and + -onepass. + + -nosmooth Use a faster, lower-quality upsampling routine. + + -onepass Use one-pass instead of two-pass color quantization. + The one-pass method is faster and needs less memory, + but it produces a lower-quality image. -onepass is + ignored unless you also say -colors N. Also, + the one-pass method is always used for gray-scale + output (the two-pass method is no improvement then). + + -maxmemory N Set limit for amount of memory to use in processing + large images. Value is in thousands of bytes, or + millions of bytes if "M" is attached to the number. + For example, -max 4m selects 4000000 bytes. If more + space is needed, temporary files will be used. + + -verbose Enable debug printout. More -v's give more printout. + or -debug Also, version information is printed at startup. + + +HINTS FOR CJPEG + +Color GIF files are not the ideal input for JPEG; JPEG is really intended for +compressing full-color (24-bit) images. In particular, don't try to convert +cartoons, line drawings, and other images that have only a few distinct +colors. GIF works great on these, JPEG does not. If you want to convert a +GIF to JPEG, you should experiment with cjpeg's -quality and -smooth options +to get a satisfactory conversion. -smooth 10 or so is often helpful. + +Avoid running an image through a series of JPEG compression/decompression +cycles. Image quality loss will accumulate; after ten or so cycles the image +may be noticeably worse than it was after one cycle. It's best to use a +lossless format while manipulating an image, then convert to JPEG format when +you are ready to file the image away. + +The -optimize option to cjpeg is worth using when you are making a "final" +version for posting or archiving. It's also a win when you are using low +quality settings to make very small JPEG files; the percentage improvement +is often a lot more than it is on larger files. (At present, -optimize +mode is always selected when generating progressive JPEG files.) + +GIF input files are no longer supported, to avoid the Unisys LZW patent. +Use a Unisys-licensed program if you need to read a GIF file. (Conversion +of GIF files to JPEG is usually a bad idea anyway.) + + +HINTS FOR DJPEG + +To get a quick preview of an image, use the -grayscale and/or -scale switches. +"-grayscale -scale 1/8" is the fastest case. + +Several options are available that trade off image quality to gain speed. +"-fast" turns on the recommended settings. + +"-dct fast" and/or "-nosmooth" gain speed at a small sacrifice in quality. +When producing a color-quantized image, "-onepass -dither ordered" is fast but +much lower quality than the default behavior. "-dither none" may give +acceptable results in two-pass mode, but is seldom tolerable in one-pass mode. + +If you are fortunate enough to have very fast floating point hardware, +"-dct float" may be even faster than "-dct fast". But on most machines +"-dct float" is slower than "-dct int"; in this case it is not worth using, +because its theoretical accuracy advantage is too small to be significant +in practice. + +Two-pass color quantization requires a good deal of memory; on MS-DOS machines +it may run out of memory even with -maxmemory 0. In that case you can still +decompress, with some loss of image quality, by specifying -onepass for +one-pass quantization. + +To avoid the Unisys LZW patent, djpeg produces uncompressed GIF files. These +are larger than they should be, but are readable by standard GIF decoders. + + +HINTS FOR BOTH PROGRAMS + +If more space is needed than will fit in the available main memory (as +determined by -maxmemory), temporary files will be used. (MS-DOS versions +will try to get extended or expanded memory first.) The temporary files are +often rather large: in typical cases they occupy three bytes per pixel, for +example 3*800*600 = 1.44Mb for an 800x600 image. If you don't have enough +free disk space, leave out -progressive and -optimize (for cjpeg) or specify +-onepass (for djpeg). + +On MS-DOS, the temporary files are created in the directory named by the TMP +or TEMP environment variable, or in the current directory if neither of those +exist. Amiga implementations put the temp files in the directory named by +JPEGTMP:, so be sure to assign JPEGTMP: to a disk partition with adequate free +space. + +The default memory usage limit (-maxmemory) is set when the software is +compiled. If you get an "insufficient memory" error, try specifying a smaller +-maxmemory value, even -maxmemory 0 to use the absolute minimum space. You +may want to recompile with a smaller default value if this happens often. + +On machines that have "environment" variables, you can define the environment +variable JPEGMEM to set the default memory limit. The value is specified as +described for the -maxmemory switch. JPEGMEM overrides the default value +specified when the program was compiled, and itself is overridden by an +explicit -maxmemory switch. + +On MS-DOS machines, -maxmemory is the amount of main (conventional) memory to +use. (Extended or expanded memory is also used if available.) Most +DOS-specific versions of this software do their own memory space estimation +and do not need you to specify -maxmemory. + + +JPEGTRAN + +jpegtran performs various useful transformations of JPEG files. +It can translate the coded representation from one variant of JPEG to another, +for example from baseline JPEG to progressive JPEG or vice versa. It can also +perform some rearrangements of the image data, for example turning an image +from landscape to portrait format by rotation. + +jpegtran works by rearranging the compressed data (DCT coefficients), without +ever fully decoding the image. Therefore, its transformations are lossless: +there is no image degradation at all, which would not be true if you used +djpeg followed by cjpeg to accomplish the same conversion. But by the same +token, jpegtran cannot perform lossy operations such as changing the image +quality. + +jpegtran uses a command line syntax similar to cjpeg or djpeg. +On Unix-like systems, you say: + jpegtran [switches] [inputfile] >outputfile +On most non-Unix systems, you say: + jpegtran [switches] inputfile outputfile +where both the input and output files are JPEG files. + +To specify the coded JPEG representation used in the output file, +jpegtran accepts a subset of the switches recognized by cjpeg: + -optimize Perform optimization of entropy encoding parameters. + -progressive Create progressive JPEG file. + -restart N Emit a JPEG restart marker every N MCU rows, or every + N MCU blocks if "B" is attached to the number. + -scans file Use the scan script given in the specified text file. +See the previous discussion of cjpeg for more details about these switches. +If you specify none of these switches, you get a plain baseline-JPEG output +file. The quality setting and so forth are determined by the input file. + +The image can be losslessly transformed by giving one of these switches: + -flip horizontal Mirror image horizontally (left-right). + -flip vertical Mirror image vertically (top-bottom). + -rotate 90 Rotate image 90 degrees clockwise. + -rotate 180 Rotate image 180 degrees. + -rotate 270 Rotate image 270 degrees clockwise (or 90 ccw). + -transpose Transpose image (across UL-to-LR axis). + -transverse Transverse transpose (across UR-to-LL axis). + +The transpose transformation has no restrictions regarding image dimensions. +The other transformations operate rather oddly if the image dimensions are not +a multiple of the iMCU size (usually 8 or 16 pixels), because they can only +transform complete blocks of DCT coefficient data in the desired way. + +jpegtran's default behavior when transforming an odd-size image is designed +to preserve exact reversibility and mathematical consistency of the +transformation set. As stated, transpose is able to flip the entire image +area. Horizontal mirroring leaves any partial iMCU column at the right edge +untouched, but is able to flip all rows of the image. Similarly, vertical +mirroring leaves any partial iMCU row at the bottom edge untouched, but is +able to flip all columns. The other transforms can be built up as sequences +of transpose and flip operations; for consistency, their actions on edge +pixels are defined to be the same as the end result of the corresponding +transpose-and-flip sequence. + +For practical use, you may prefer to discard any untransformable edge pixels +rather than having a strange-looking strip along the right and/or bottom edges +of a transformed image. To do this, add the -trim switch: + -trim Drop non-transformable edge blocks. +Obviously, a transformation with -trim is not reversible, so strictly speaking +jpegtran with this switch is not lossless. Also, the expected mathematical +equivalences between the transformations no longer hold. For example, +"-rot 270 -trim" trims only the bottom edge, but "-rot 90 -trim" followed by +"-rot 180 -trim" trims both edges. + +Another not-strictly-lossless transformation switch is: + -grayscale Force grayscale output. +This option discards the chrominance channels if the input image is YCbCr +(ie, a standard color JPEG), resulting in a grayscale JPEG file. The +luminance channel is preserved exactly, so this is a better method of reducing +to grayscale than decompression, conversion, and recompression. This switch +is particularly handy for fixing a monochrome picture that was mistakenly +encoded as a color JPEG. (In such a case, the space savings from getting rid +of the near-empty chroma channels won't be large; but the decoding time for +a grayscale JPEG is substantially less than that for a color JPEG.) + +jpegtran also recognizes these switches that control what to do with "extra" +markers, such as comment blocks: + -copy none Copy no extra markers from source file. This setting + suppresses all comments and other excess baggage + present in the source file. + -copy comments Copy only comment markers. This setting copies + comments from the source file, but discards + any other inessential data. + -copy all Copy all extra markers. This setting preserves + miscellaneous markers found in the source file, such + as JFIF thumbnails and Photoshop settings. In some + files these extra markers can be sizable. +The default behavior is -copy comments. (Note: in IJG releases v6 and v6a, +jpegtran always did the equivalent of -copy none.) + +Additional switches recognized by jpegtran are: + -outfile filename + -maxmemory N + -verbose + -debug +These work the same as in cjpeg or djpeg. + + +THE COMMENT UTILITIES + +The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. +Although the standard doesn't actually define what COM blocks are for, they +are widely used to hold user-supplied text strings. This lets you add +annotations, titles, index terms, etc to your JPEG files, and later retrieve +them as text. COM blocks do not interfere with the image stored in the JPEG +file. The maximum size of a COM block is 64K, but you can have as many of +them as you like in one JPEG file. + +We provide two utility programs to display COM block contents and add COM +blocks to a JPEG file. + +rdjpgcom searches a JPEG file and prints the contents of any COM blocks on +standard output. The command line syntax is + rdjpgcom [-verbose] [inputfilename] +The switch "-verbose" (or just "-v") causes rdjpgcom to also display the JPEG +image dimensions. If you omit the input file name from the command line, +the JPEG file is read from standard input. (This may not work on some +operating systems, if binary data can't be read from stdin.) + +wrjpgcom adds a COM block, containing text you provide, to a JPEG file. +Ordinarily, the COM block is added after any existing COM blocks, but you +can delete the old COM blocks if you wish. wrjpgcom produces a new JPEG +file; it does not modify the input file. DO NOT try to overwrite the input +file by directing wrjpgcom's output back into it; on most systems this will +just destroy your file. + +The command line syntax for wrjpgcom is similar to cjpeg's. On Unix-like +systems, it is + wrjpgcom [switches] [inputfilename] +The output file is written to standard output. The input file comes from +the named file, or from standard input if no input file is named. + +On most non-Unix systems, the syntax is + wrjpgcom [switches] inputfilename outputfilename +where both input and output file names must be given explicitly. + +wrjpgcom understands three switches: + -replace Delete any existing COM blocks from the file. + -comment "Comment text" Supply new COM text on command line. + -cfile name Read text for new COM block from named file. +(Switch names can be abbreviated.) If you have only one line of comment text +to add, you can provide it on the command line with -comment. The comment +text must be surrounded with quotes so that it is treated as a single +argument. Longer comments can be read from a text file. + +If you give neither -comment nor -cfile, then wrjpgcom will read the comment +text from standard input. (In this case an input image file name MUST be +supplied, so that the source JPEG file comes from somewhere else.) You can +enter multiple lines, up to 64KB worth. Type an end-of-file indicator +(usually control-D or control-Z) to terminate the comment text entry. + +wrjpgcom will not add a COM block if the provided comment string is empty. +Therefore -replace -comment "" can be used to delete all COM blocks from a +file. + +These utility programs do not depend on the IJG JPEG library. In +particular, the source code for rdjpgcom is intended as an illustration of +the minimum amount of code required to parse a JPEG file header correctly. diff --git a/src/dep/src/irrlicht/jpeglib/wizard.doc b/src/dep/src/irrlicht/jpeglib/wizard.doc index 02418ba..54170b2 100644 --- a/src/dep/src/irrlicht/jpeglib/wizard.doc +++ b/src/dep/src/irrlicht/jpeglib/wizard.doc @@ -1,211 +1,211 @@ -Advanced usage instructions for the Independent JPEG Group's JPEG software -========================================================================== - -This file describes cjpeg's "switches for wizards". - -The "wizard" switches are intended for experimentation with JPEG by persons -who are reasonably knowledgeable about the JPEG standard. If you don't know -what you are doing, DON'T USE THESE SWITCHES. You'll likely produce files -with worse image quality and/or poorer compression than you'd get from the -default settings. Furthermore, these switches must be used with caution -when making files intended for general use, because not all JPEG decoders -will support unusual JPEG parameter settings. - - -Quantization Table Adjustment ------------------------------ - -Ordinarily, cjpeg starts with a default set of tables (the same ones given -as examples in the JPEG standard) and scales them up or down according to -the -quality setting. The details of the scaling algorithm can be found in -jcparam.c. At very low quality settings, some quantization table entries -can get scaled up to values exceeding 255. Although 2-byte quantization -values are supported by the IJG software, this feature is not in baseline -JPEG and is not supported by all implementations. If you need to ensure -wide compatibility of low-quality files, you can constrain the scaled -quantization values to no more than 255 by giving the -baseline switch. -Note that use of -baseline will result in poorer quality for the same file -size, since more bits than necessary are expended on higher AC coefficients. - -You can substitute a different set of quantization values by using the --qtables switch: - - -qtables file Use the quantization tables given in the named file. - -The specified file should be a text file containing decimal quantization -values. The file should contain one to four tables, each of 64 elements. -The tables are implicitly numbered 0,1,etc. in order of appearance. Table -entries appear in normal array order (NOT in the zigzag order in which they -will be stored in the JPEG file). - -Quantization table files are free format, in that arbitrary whitespace can -appear between numbers. Also, comments can be included: a comment starts -with '#' and extends to the end of the line. Here is an example file that -duplicates the default quantization tables: - - # Quantization tables given in JPEG spec, section K.1 - - # This is table 0 (the luminance table): - 16 11 10 16 24 40 51 61 - 12 12 14 19 26 58 60 55 - 14 13 16 24 40 57 69 56 - 14 17 22 29 51 87 80 62 - 18 22 37 56 68 109 103 77 - 24 35 55 64 81 104 113 92 - 49 64 78 87 103 121 120 101 - 72 92 95 98 112 100 103 99 - - # This is table 1 (the chrominance table): - 17 18 24 47 99 99 99 99 - 18 21 26 66 99 99 99 99 - 24 26 56 99 99 99 99 99 - 47 66 99 99 99 99 99 99 - 99 99 99 99 99 99 99 99 - 99 99 99 99 99 99 99 99 - 99 99 99 99 99 99 99 99 - 99 99 99 99 99 99 99 99 - -If the -qtables switch is used without -quality, then the specified tables -are used exactly as-is. If both -qtables and -quality are used, then the -tables taken from the file are scaled in the same fashion that the default -tables would be scaled for that quality setting. If -baseline appears, then -the quantization values are constrained to the range 1-255. - -By default, cjpeg will use quantization table 0 for luminance components and -table 1 for chrominance components. To override this choice, use the -qslots -switch: - - -qslots N[,...] Select which quantization table to use for - each color component. - -The -qslots switch specifies a quantization table number for each color -component, in the order in which the components appear in the JPEG SOF marker. -For example, to create a separate table for each of Y,Cb,Cr, you could -provide a -qtables file that defines three quantization tables and say -"-qslots 0,1,2". If -qslots gives fewer table numbers than there are color -components, then the last table number is repeated as necessary. - - -Sampling Factor Adjustment --------------------------- - -By default, cjpeg uses 2:1 horizontal and vertical downsampling when -compressing YCbCr data, and no downsampling for all other color spaces. -You can override this default with the -sample switch: - - -sample HxV[,...] Set JPEG sampling factors for each color - component. - -The -sample switch specifies the JPEG sampling factors for each color -component, in the order in which they appear in the JPEG SOF marker. -If you specify fewer HxV pairs than there are components, the remaining -components are set to 1x1 sampling. For example, the default YCbCr setting -is equivalent to "-sample 2x2,1x1,1x1", which can be abbreviated to -"-sample 2x2". - -There are still some JPEG decoders in existence that support only 2x1 -sampling (also called 4:2:2 sampling). Compatibility with such decoders can -be achieved by specifying "-sample 2x1". This is not recommended unless -really necessary, since it increases file size and encoding/decoding time -with very little quality gain. - - -Multiple Scan / Progression Control ------------------------------------ - -By default, cjpeg emits a single-scan sequential JPEG file. The --progressive switch generates a progressive JPEG file using a default series -of progression parameters. You can create multiple-scan sequential JPEG -files or progressive JPEG files with custom progression parameters by using -the -scans switch: - - -scans file Use the scan sequence given in the named file. - -The specified file should be a text file containing a "scan script". -The script specifies the contents and ordering of the scans to be emitted. -Each entry in the script defines one scan. A scan definition specifies -the components to be included in the scan, and for progressive JPEG it also -specifies the progression parameters Ss,Se,Ah,Al for the scan. Scan -definitions are separated by semicolons (';'). A semicolon after the last -scan definition is optional. - -Each scan definition contains one to four component indexes, optionally -followed by a colon (':') and the four progressive-JPEG parameters. The -component indexes denote which color component(s) are to be transmitted in -the scan. Components are numbered in the order in which they appear in the -JPEG SOF marker, with the first component being numbered 0. (Note that these -indexes are not the "component ID" codes assigned to the components, just -positional indexes.) - -The progression parameters for each scan are: - Ss Zigzag index of first coefficient included in scan - Se Zigzag index of last coefficient included in scan - Ah Zero for first scan of a coefficient, else Al of prior scan - Al Successive approximation low bit position for scan -If the progression parameters are omitted, the values 0,63,0,0 are used, -producing a sequential JPEG file. cjpeg automatically determines whether -the script represents a progressive or sequential file, by observing whether -Ss and Se values other than 0 and 63 appear. (The -progressive switch is -not needed to specify this; in fact, it is ignored when -scans appears.) -The scan script must meet the JPEG restrictions on progression sequences. -(cjpeg checks that the spec's requirements are obeyed.) - -Scan script files are free format, in that arbitrary whitespace can appear -between numbers and around punctuation. Also, comments can be included: a -comment starts with '#' and extends to the end of the line. For additional -legibility, commas or dashes can be placed between values. (Actually, any -single punctuation character other than ':' or ';' can be inserted.) For -example, the following two scan definitions are equivalent: - 0 1 2: 0 63 0 0; - 0,1,2 : 0-63, 0,0 ; - -Here is an example of a scan script that generates a partially interleaved -sequential JPEG file: - - 0; # Y only in first scan - 1 2; # Cb and Cr in second scan - -Here is an example of a progressive scan script using only spectral selection -(no successive approximation): - - # Interleaved DC scan for Y,Cb,Cr: - 0,1,2: 0-0, 0, 0 ; - # AC scans: - 0: 1-2, 0, 0 ; # First two Y AC coefficients - 0: 3-5, 0, 0 ; # Three more - 1: 1-63, 0, 0 ; # All AC coefficients for Cb - 2: 1-63, 0, 0 ; # All AC coefficients for Cr - 0: 6-9, 0, 0 ; # More Y coefficients - 0: 10-63, 0, 0 ; # Remaining Y coefficients - -Here is an example of a successive-approximation script. This is equivalent -to the default script used by "cjpeg -progressive" for YCbCr images: - - # Initial DC scan for Y,Cb,Cr (lowest bit not sent) - 0,1,2: 0-0, 0, 1 ; - # First AC scan: send first 5 Y AC coefficients, minus 2 lowest bits: - 0: 1-5, 0, 2 ; - # Send all Cr,Cb AC coefficients, minus lowest bit: - # (chroma data is usually too small to be worth subdividing further; - # but note we send Cr first since eye is least sensitive to Cb) - 2: 1-63, 0, 1 ; - 1: 1-63, 0, 1 ; - # Send remaining Y AC coefficients, minus 2 lowest bits: - 0: 6-63, 0, 2 ; - # Send next-to-lowest bit of all Y AC coefficients: - 0: 1-63, 2, 1 ; - # At this point we've sent all but the lowest bit of all coefficients. - # Send lowest bit of DC coefficients - 0,1,2: 0-0, 1, 0 ; - # Send lowest bit of AC coefficients - 2: 1-63, 1, 0 ; - 1: 1-63, 1, 0 ; - # Y AC lowest bit scan is last; it's usually the largest scan - 0: 1-63, 1, 0 ; - -It may be worth pointing out that this script is tuned for quality settings -of around 50 to 75. For lower quality settings, you'd probably want to use -a script with fewer stages of successive approximation (otherwise the -initial scans will be really bad). For higher quality settings, you might -want to use more stages of successive approximation (so that the initial -scans are not too large). +Advanced usage instructions for the Independent JPEG Group's JPEG software +========================================================================== + +This file describes cjpeg's "switches for wizards". + +The "wizard" switches are intended for experimentation with JPEG by persons +who are reasonably knowledgeable about the JPEG standard. If you don't know +what you are doing, DON'T USE THESE SWITCHES. You'll likely produce files +with worse image quality and/or poorer compression than you'd get from the +default settings. Furthermore, these switches must be used with caution +when making files intended for general use, because not all JPEG decoders +will support unusual JPEG parameter settings. + + +Quantization Table Adjustment +----------------------------- + +Ordinarily, cjpeg starts with a default set of tables (the same ones given +as examples in the JPEG standard) and scales them up or down according to +the -quality setting. The details of the scaling algorithm can be found in +jcparam.c. At very low quality settings, some quantization table entries +can get scaled up to values exceeding 255. Although 2-byte quantization +values are supported by the IJG software, this feature is not in baseline +JPEG and is not supported by all implementations. If you need to ensure +wide compatibility of low-quality files, you can constrain the scaled +quantization values to no more than 255 by giving the -baseline switch. +Note that use of -baseline will result in poorer quality for the same file +size, since more bits than necessary are expended on higher AC coefficients. + +You can substitute a different set of quantization values by using the +-qtables switch: + + -qtables file Use the quantization tables given in the named file. + +The specified file should be a text file containing decimal quantization +values. The file should contain one to four tables, each of 64 elements. +The tables are implicitly numbered 0,1,etc. in order of appearance. Table +entries appear in normal array order (NOT in the zigzag order in which they +will be stored in the JPEG file). + +Quantization table files are free format, in that arbitrary whitespace can +appear between numbers. Also, comments can be included: a comment starts +with '#' and extends to the end of the line. Here is an example file that +duplicates the default quantization tables: + + # Quantization tables given in JPEG spec, section K.1 + + # This is table 0 (the luminance table): + 16 11 10 16 24 40 51 61 + 12 12 14 19 26 58 60 55 + 14 13 16 24 40 57 69 56 + 14 17 22 29 51 87 80 62 + 18 22 37 56 68 109 103 77 + 24 35 55 64 81 104 113 92 + 49 64 78 87 103 121 120 101 + 72 92 95 98 112 100 103 99 + + # This is table 1 (the chrominance table): + 17 18 24 47 99 99 99 99 + 18 21 26 66 99 99 99 99 + 24 26 56 99 99 99 99 99 + 47 66 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + +If the -qtables switch is used without -quality, then the specified tables +are used exactly as-is. If both -qtables and -quality are used, then the +tables taken from the file are scaled in the same fashion that the default +tables would be scaled for that quality setting. If -baseline appears, then +the quantization values are constrained to the range 1-255. + +By default, cjpeg will use quantization table 0 for luminance components and +table 1 for chrominance components. To override this choice, use the -qslots +switch: + + -qslots N[,...] Select which quantization table to use for + each color component. + +The -qslots switch specifies a quantization table number for each color +component, in the order in which the components appear in the JPEG SOF marker. +For example, to create a separate table for each of Y,Cb,Cr, you could +provide a -qtables file that defines three quantization tables and say +"-qslots 0,1,2". If -qslots gives fewer table numbers than there are color +components, then the last table number is repeated as necessary. + + +Sampling Factor Adjustment +-------------------------- + +By default, cjpeg uses 2:1 horizontal and vertical downsampling when +compressing YCbCr data, and no downsampling for all other color spaces. +You can override this default with the -sample switch: + + -sample HxV[,...] Set JPEG sampling factors for each color + component. + +The -sample switch specifies the JPEG sampling factors for each color +component, in the order in which they appear in the JPEG SOF marker. +If you specify fewer HxV pairs than there are components, the remaining +components are set to 1x1 sampling. For example, the default YCbCr setting +is equivalent to "-sample 2x2,1x1,1x1", which can be abbreviated to +"-sample 2x2". + +There are still some JPEG decoders in existence that support only 2x1 +sampling (also called 4:2:2 sampling). Compatibility with such decoders can +be achieved by specifying "-sample 2x1". This is not recommended unless +really necessary, since it increases file size and encoding/decoding time +with very little quality gain. + + +Multiple Scan / Progression Control +----------------------------------- + +By default, cjpeg emits a single-scan sequential JPEG file. The +-progressive switch generates a progressive JPEG file using a default series +of progression parameters. You can create multiple-scan sequential JPEG +files or progressive JPEG files with custom progression parameters by using +the -scans switch: + + -scans file Use the scan sequence given in the named file. + +The specified file should be a text file containing a "scan script". +The script specifies the contents and ordering of the scans to be emitted. +Each entry in the script defines one scan. A scan definition specifies +the components to be included in the scan, and for progressive JPEG it also +specifies the progression parameters Ss,Se,Ah,Al for the scan. Scan +definitions are separated by semicolons (';'). A semicolon after the last +scan definition is optional. + +Each scan definition contains one to four component indexes, optionally +followed by a colon (':') and the four progressive-JPEG parameters. The +component indexes denote which color component(s) are to be transmitted in +the scan. Components are numbered in the order in which they appear in the +JPEG SOF marker, with the first component being numbered 0. (Note that these +indexes are not the "component ID" codes assigned to the components, just +positional indexes.) + +The progression parameters for each scan are: + Ss Zigzag index of first coefficient included in scan + Se Zigzag index of last coefficient included in scan + Ah Zero for first scan of a coefficient, else Al of prior scan + Al Successive approximation low bit position for scan +If the progression parameters are omitted, the values 0,63,0,0 are used, +producing a sequential JPEG file. cjpeg automatically determines whether +the script represents a progressive or sequential file, by observing whether +Ss and Se values other than 0 and 63 appear. (The -progressive switch is +not needed to specify this; in fact, it is ignored when -scans appears.) +The scan script must meet the JPEG restrictions on progression sequences. +(cjpeg checks that the spec's requirements are obeyed.) + +Scan script files are free format, in that arbitrary whitespace can appear +between numbers and around punctuation. Also, comments can be included: a +comment starts with '#' and extends to the end of the line. For additional +legibility, commas or dashes can be placed between values. (Actually, any +single punctuation character other than ':' or ';' can be inserted.) For +example, the following two scan definitions are equivalent: + 0 1 2: 0 63 0 0; + 0,1,2 : 0-63, 0,0 ; + +Here is an example of a scan script that generates a partially interleaved +sequential JPEG file: + + 0; # Y only in first scan + 1 2; # Cb and Cr in second scan + +Here is an example of a progressive scan script using only spectral selection +(no successive approximation): + + # Interleaved DC scan for Y,Cb,Cr: + 0,1,2: 0-0, 0, 0 ; + # AC scans: + 0: 1-2, 0, 0 ; # First two Y AC coefficients + 0: 3-5, 0, 0 ; # Three more + 1: 1-63, 0, 0 ; # All AC coefficients for Cb + 2: 1-63, 0, 0 ; # All AC coefficients for Cr + 0: 6-9, 0, 0 ; # More Y coefficients + 0: 10-63, 0, 0 ; # Remaining Y coefficients + +Here is an example of a successive-approximation script. This is equivalent +to the default script used by "cjpeg -progressive" for YCbCr images: + + # Initial DC scan for Y,Cb,Cr (lowest bit not sent) + 0,1,2: 0-0, 0, 1 ; + # First AC scan: send first 5 Y AC coefficients, minus 2 lowest bits: + 0: 1-5, 0, 2 ; + # Send all Cr,Cb AC coefficients, minus lowest bit: + # (chroma data is usually too small to be worth subdividing further; + # but note we send Cr first since eye is least sensitive to Cb) + 2: 1-63, 0, 1 ; + 1: 1-63, 0, 1 ; + # Send remaining Y AC coefficients, minus 2 lowest bits: + 0: 6-63, 0, 2 ; + # Send next-to-lowest bit of all Y AC coefficients: + 0: 1-63, 2, 1 ; + # At this point we've sent all but the lowest bit of all coefficients. + # Send lowest bit of DC coefficients + 0,1,2: 0-0, 1, 0 ; + # Send lowest bit of AC coefficients + 2: 1-63, 1, 0 ; + 1: 1-63, 1, 0 ; + # Y AC lowest bit scan is last; it's usually the largest scan + 0: 1-63, 1, 0 ; + +It may be worth pointing out that this script is tuned for quality settings +of around 50 to 75. For lower quality settings, you'd probably want to use +a script with fewer stages of successive approximation (otherwise the +initial scans will be really bad). For higher quality settings, you might +want to use more stages of successive approximation (so that the initial +scans are not too large). diff --git a/src/dep/src/irrlicht/jpeglib/wrbmp.c b/src/dep/src/irrlicht/jpeglib/wrbmp.c index 2b8146e..3283b0f 100644 --- a/src/dep/src/irrlicht/jpeglib/wrbmp.c +++ b/src/dep/src/irrlicht/jpeglib/wrbmp.c @@ -1,442 +1,442 @@ -/* - * wrbmp.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in Microsoft "BMP" - * format (MS Windows 3.x and OS/2 1.x flavors). - * Either 8-bit colormapped or 24-bit full-color format can be written. - * No compression is supported. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - * - * This code contributed by James Arthur Boucher. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef BMP_SUPPORTED - - -/* - * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. - * This is not yet implemented. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - -/* - * Since BMP stores scanlines bottom-to-top, we have to invert the image - * from JPEG's top-to-bottom order. To do this, we save the outgoing data - * in a virtual array during put_pixel_row calls, then actually emit the - * BMP file during finish_output. The virtual array contains one JSAMPLE per - * pixel if the output is grayscale or colormapped, three if it is full color. - */ - -/* Private version of data destination object */ - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - boolean is_os2; /* saves the OS2 format request flag */ - - jvirt_sarray_ptr whole_image; /* needed to reverse row order */ - JDIMENSION data_width; /* JSAMPLEs per row */ - JDIMENSION row_width; /* physical width of one row in the BMP file */ - int pad_bytes; /* number of padding bytes needed per row */ - JDIMENSION cur_output_row; /* next row# to write to virtual array */ -} bmp_dest_struct; - -typedef bmp_dest_struct * bmp_dest_ptr; - - -/* Forward declarations */ -LOCAL(void) write_colormap - JPP((j_decompress_ptr cinfo, bmp_dest_ptr dest, - int map_colors, int map_entry_size)); - - -/* - * Write some pixel data. - * In this module rows_supplied will always be 1. - */ - -METHODDEF(void) -put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* This version is for writing 24-bit pixels */ -{ - bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; - JSAMPARRAY image_ptr; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - int pad; - - /* Access next row in virtual array */ - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->whole_image, - dest->cur_output_row, (JDIMENSION) 1, TRUE); - dest->cur_output_row++; - - /* Transfer data. Note destination values must be in BGR order - * (even though Microsoft's own documents say the opposite). - */ - inptr = dest->pub.buffer[0]; - outptr = image_ptr[0]; - for (col = cinfo->output_width; col > 0; col--) { - outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ - outptr[1] = *inptr++; - outptr[0] = *inptr++; - outptr += 3; - } - - /* Zero out the pad bytes. */ - pad = dest->pad_bytes; - while (--pad >= 0) - *outptr++ = 0; -} - -METHODDEF(void) -put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* This version is for grayscale OR quantized color output */ -{ - bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; - JSAMPARRAY image_ptr; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - int pad; - - /* Access next row in virtual array */ - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->whole_image, - dest->cur_output_row, (JDIMENSION) 1, TRUE); - dest->cur_output_row++; - - /* Transfer data. */ - inptr = dest->pub.buffer[0]; - outptr = image_ptr[0]; - for (col = cinfo->output_width; col > 0; col--) { - *outptr++ = *inptr++; /* can omit GETJSAMPLE() safely */ - } - - /* Zero out the pad bytes. */ - pad = dest->pad_bytes; - while (--pad >= 0) - *outptr++ = 0; -} - - -/* - * Startup: normally writes the file header. - * In this module we may as well postpone everything until finish_output. - */ - -METHODDEF(void) -start_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - /* no work here */ -} - - -/* - * Finish up at the end of the file. - * - * Here is where we really output the BMP file. - * - * First, routines to write the Windows and OS/2 variants of the file header. - */ - -LOCAL(void) -write_bmp_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) -/* Write a Windows-style BMP file header, including colormap if needed */ -{ - char bmpfileheader[14]; - char bmpinfoheader[40]; -#define PUT_2B(array,offset,value) \ - (array[offset] = (char) ((value) & 0xFF), \ - array[offset+1] = (char) (((value) >> 8) & 0xFF)) -#define PUT_4B(array,offset,value) \ - (array[offset] = (char) ((value) & 0xFF), \ - array[offset+1] = (char) (((value) >> 8) & 0xFF), \ - array[offset+2] = (char) (((value) >> 16) & 0xFF), \ - array[offset+3] = (char) (((value) >> 24) & 0xFF)) - INT32 headersize, bfSize; - int bits_per_pixel, cmap_entries; - - /* Compute colormap size and total file size */ - if (cinfo->out_color_space == JCS_RGB) { - if (cinfo->quantize_colors) { - /* Colormapped RGB */ - bits_per_pixel = 8; - cmap_entries = 256; - } else { - /* Unquantized, full color RGB */ - bits_per_pixel = 24; - cmap_entries = 0; - } - } else { - /* Grayscale output. We need to fake a 256-entry colormap. */ - bits_per_pixel = 8; - cmap_entries = 256; - } - /* File size */ - headersize = 14 + 40 + cmap_entries * 4; /* Header and colormap */ - bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; - - /* Set unused fields of header to 0 */ - MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); - MEMZERO(bmpinfoheader, SIZEOF(bmpinfoheader)); - - /* Fill the file header */ - bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ - bmpfileheader[1] = 0x4D; - PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ - /* we leave bfReserved1 & bfReserved2 = 0 */ - PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ - - /* Fill the info header (Microsoft calls this a BITMAPINFOHEADER) */ - PUT_2B(bmpinfoheader, 0, 40); /* biSize */ - PUT_4B(bmpinfoheader, 4, cinfo->output_width); /* biWidth */ - PUT_4B(bmpinfoheader, 8, cinfo->output_height); /* biHeight */ - PUT_2B(bmpinfoheader, 12, 1); /* biPlanes - must be 1 */ - PUT_2B(bmpinfoheader, 14, bits_per_pixel); /* biBitCount */ - /* we leave biCompression = 0, for none */ - /* we leave biSizeImage = 0; this is correct for uncompressed data */ - if (cinfo->density_unit == 2) { /* if have density in dots/cm, then */ - PUT_4B(bmpinfoheader, 24, (INT32) (cinfo->X_density*100)); /* XPels/M */ - PUT_4B(bmpinfoheader, 28, (INT32) (cinfo->Y_density*100)); /* XPels/M */ - } - PUT_2B(bmpinfoheader, 32, cmap_entries); /* biClrUsed */ - /* we leave biClrImportant = 0 */ - - if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) - ERREXIT(cinfo, JERR_FILE_WRITE); - if (JFWRITE(dest->pub.output_file, bmpinfoheader, 40) != (size_t) 40) - ERREXIT(cinfo, JERR_FILE_WRITE); - - if (cmap_entries > 0) - write_colormap(cinfo, dest, cmap_entries, 4); -} - - -LOCAL(void) -write_os2_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) -/* Write an OS2-style BMP file header, including colormap if needed */ -{ - char bmpfileheader[14]; - char bmpcoreheader[12]; - INT32 headersize, bfSize; - int bits_per_pixel, cmap_entries; - - /* Compute colormap size and total file size */ - if (cinfo->out_color_space == JCS_RGB) { - if (cinfo->quantize_colors) { - /* Colormapped RGB */ - bits_per_pixel = 8; - cmap_entries = 256; - } else { - /* Unquantized, full color RGB */ - bits_per_pixel = 24; - cmap_entries = 0; - } - } else { - /* Grayscale output. We need to fake a 256-entry colormap. */ - bits_per_pixel = 8; - cmap_entries = 256; - } - /* File size */ - headersize = 14 + 12 + cmap_entries * 3; /* Header and colormap */ - bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; - - /* Set unused fields of header to 0 */ - MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); - MEMZERO(bmpcoreheader, SIZEOF(bmpcoreheader)); - - /* Fill the file header */ - bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ - bmpfileheader[1] = 0x4D; - PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ - /* we leave bfReserved1 & bfReserved2 = 0 */ - PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ - - /* Fill the info header (Microsoft calls this a BITMAPCOREHEADER) */ - PUT_2B(bmpcoreheader, 0, 12); /* bcSize */ - PUT_2B(bmpcoreheader, 4, cinfo->output_width); /* bcWidth */ - PUT_2B(bmpcoreheader, 6, cinfo->output_height); /* bcHeight */ - PUT_2B(bmpcoreheader, 8, 1); /* bcPlanes - must be 1 */ - PUT_2B(bmpcoreheader, 10, bits_per_pixel); /* bcBitCount */ - - if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) - ERREXIT(cinfo, JERR_FILE_WRITE); - if (JFWRITE(dest->pub.output_file, bmpcoreheader, 12) != (size_t) 12) - ERREXIT(cinfo, JERR_FILE_WRITE); - - if (cmap_entries > 0) - write_colormap(cinfo, dest, cmap_entries, 3); -} - - -/* - * Write the colormap. - * Windows uses BGR0 map entries; OS/2 uses BGR entries. - */ - -LOCAL(void) -write_colormap (j_decompress_ptr cinfo, bmp_dest_ptr dest, - int map_colors, int map_entry_size) -{ - JSAMPARRAY colormap = cinfo->colormap; - int num_colors = cinfo->actual_number_of_colors; - FILE * outfile = dest->pub.output_file; - int i; - - if (colormap != NULL) { - if (cinfo->out_color_components == 3) { - /* Normal case with RGB colormap */ - for (i = 0; i < num_colors; i++) { - putc(GETJSAMPLE(colormap[2][i]), outfile); - putc(GETJSAMPLE(colormap[1][i]), outfile); - putc(GETJSAMPLE(colormap[0][i]), outfile); - if (map_entry_size == 4) - putc(0, outfile); - } - } else { - /* Grayscale colormap (only happens with grayscale quantization) */ - for (i = 0; i < num_colors; i++) { - putc(GETJSAMPLE(colormap[0][i]), outfile); - putc(GETJSAMPLE(colormap[0][i]), outfile); - putc(GETJSAMPLE(colormap[0][i]), outfile); - if (map_entry_size == 4) - putc(0, outfile); - } - } - } else { - /* If no colormap, must be grayscale data. Generate a linear "map". */ - for (i = 0; i < 256; i++) { - putc(i, outfile); - putc(i, outfile); - putc(i, outfile); - if (map_entry_size == 4) - putc(0, outfile); - } - } - /* Pad colormap with zeros to ensure specified number of colormap entries */ - if (i > map_colors) - ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, i); - for (; i < map_colors; i++) { - putc(0, outfile); - putc(0, outfile); - putc(0, outfile); - if (map_entry_size == 4) - putc(0, outfile); - } -} - - -METHODDEF(void) -finish_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; - register FILE * outfile = dest->pub.output_file; - JSAMPARRAY image_ptr; - register JSAMPROW data_ptr; - JDIMENSION row; - register JDIMENSION col; - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - - /* Write the header and colormap */ - if (dest->is_os2) - write_os2_header(cinfo, dest); - else - write_bmp_header(cinfo, dest); - - /* Write the file body from our virtual array */ - for (row = cinfo->output_height; row > 0; row--) { - if (progress != NULL) { - progress->pub.pass_counter = (long) (cinfo->output_height - row); - progress->pub.pass_limit = (long) cinfo->output_height; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->whole_image, row-1, (JDIMENSION) 1, FALSE); - data_ptr = image_ptr[0]; - for (col = dest->row_width; col > 0; col--) { - putc(GETJSAMPLE(*data_ptr), outfile); - data_ptr++; - } - } - if (progress != NULL) - progress->completed_extra_passes++; - - /* Make sure we wrote the output file OK */ - fflush(outfile); - if (ferror(outfile)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for BMP format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2) -{ - bmp_dest_ptr dest; - JDIMENSION row_width; - - /* Create module interface object, fill in method pointers */ - dest = (bmp_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(bmp_dest_struct)); - dest->pub.start_output = start_output_bmp; - dest->pub.finish_output = finish_output_bmp; - dest->is_os2 = is_os2; - - if (cinfo->out_color_space == JCS_GRAYSCALE) { - dest->pub.put_pixel_rows = put_gray_rows; - } else if (cinfo->out_color_space == JCS_RGB) { - if (cinfo->quantize_colors) - dest->pub.put_pixel_rows = put_gray_rows; - else - dest->pub.put_pixel_rows = put_pixel_rows; - } else { - ERREXIT(cinfo, JERR_BMP_COLORSPACE); - } - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Determine width of rows in the BMP file (padded to 4-byte boundary). */ - row_width = cinfo->output_width * cinfo->output_components; - dest->data_width = row_width; - while ((row_width & 3) != 0) row_width++; - dest->row_width = row_width; - dest->pad_bytes = (int) (row_width - dest->data_width); - - /* Allocate space for inversion array, prepare for write pass */ - dest->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - row_width, cinfo->output_height, (JDIMENSION) 1); - dest->cur_output_row = 0; - if (cinfo->progress != NULL) { - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - progress->total_extra_passes++; /* count file input as separate pass */ - } - - /* Create decompressor output buffer. */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, row_width, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - - return (djpeg_dest_ptr) dest; -} - -#endif /* BMP_SUPPORTED */ +/* + * wrbmp.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write output images in Microsoft "BMP" + * format (MS Windows 3.x and OS/2 1.x flavors). + * Either 8-bit colormapped or 24-bit full-color format can be written. + * No compression is supported. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + * + * This code contributed by James Arthur Boucher. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef BMP_SUPPORTED + + +/* + * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. + * This is not yet implemented. + */ + +#if BITS_IN_JSAMPLE != 8 + Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ +#endif + +/* + * Since BMP stores scanlines bottom-to-top, we have to invert the image + * from JPEG's top-to-bottom order. To do this, we save the outgoing data + * in a virtual array during put_pixel_row calls, then actually emit the + * BMP file during finish_output. The virtual array contains one JSAMPLE per + * pixel if the output is grayscale or colormapped, three if it is full color. + */ + +/* Private version of data destination object */ + +typedef struct { + struct djpeg_dest_struct pub; /* public fields */ + + boolean is_os2; /* saves the OS2 format request flag */ + + jvirt_sarray_ptr whole_image; /* needed to reverse row order */ + JDIMENSION data_width; /* JSAMPLEs per row */ + JDIMENSION row_width; /* physical width of one row in the BMP file */ + int pad_bytes; /* number of padding bytes needed per row */ + JDIMENSION cur_output_row; /* next row# to write to virtual array */ +} bmp_dest_struct; + +typedef bmp_dest_struct * bmp_dest_ptr; + + +/* Forward declarations */ +LOCAL(void) write_colormap + JPP((j_decompress_ptr cinfo, bmp_dest_ptr dest, + int map_colors, int map_entry_size)); + + +/* + * Write some pixel data. + * In this module rows_supplied will always be 1. + */ + +METHODDEF(void) +put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +/* This version is for writing 24-bit pixels */ +{ + bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; + JSAMPARRAY image_ptr; + register JSAMPROW inptr, outptr; + register JDIMENSION col; + int pad; + + /* Access next row in virtual array */ + image_ptr = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->whole_image, + dest->cur_output_row, (JDIMENSION) 1, TRUE); + dest->cur_output_row++; + + /* Transfer data. Note destination values must be in BGR order + * (even though Microsoft's own documents say the opposite). + */ + inptr = dest->pub.buffer[0]; + outptr = image_ptr[0]; + for (col = cinfo->output_width; col > 0; col--) { + outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ + outptr[1] = *inptr++; + outptr[0] = *inptr++; + outptr += 3; + } + + /* Zero out the pad bytes. */ + pad = dest->pad_bytes; + while (--pad >= 0) + *outptr++ = 0; +} + +METHODDEF(void) +put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +/* This version is for grayscale OR quantized color output */ +{ + bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; + JSAMPARRAY image_ptr; + register JSAMPROW inptr, outptr; + register JDIMENSION col; + int pad; + + /* Access next row in virtual array */ + image_ptr = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->whole_image, + dest->cur_output_row, (JDIMENSION) 1, TRUE); + dest->cur_output_row++; + + /* Transfer data. */ + inptr = dest->pub.buffer[0]; + outptr = image_ptr[0]; + for (col = cinfo->output_width; col > 0; col--) { + *outptr++ = *inptr++; /* can omit GETJSAMPLE() safely */ + } + + /* Zero out the pad bytes. */ + pad = dest->pad_bytes; + while (--pad >= 0) + *outptr++ = 0; +} + + +/* + * Startup: normally writes the file header. + * In this module we may as well postpone everything until finish_output. + */ + +METHODDEF(void) +start_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + /* no work here */ +} + + +/* + * Finish up at the end of the file. + * + * Here is where we really output the BMP file. + * + * First, routines to write the Windows and OS/2 variants of the file header. + */ + +LOCAL(void) +write_bmp_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) +/* Write a Windows-style BMP file header, including colormap if needed */ +{ + char bmpfileheader[14]; + char bmpinfoheader[40]; +#define PUT_2B(array,offset,value) \ + (array[offset] = (char) ((value) & 0xFF), \ + array[offset+1] = (char) (((value) >> 8) & 0xFF)) +#define PUT_4B(array,offset,value) \ + (array[offset] = (char) ((value) & 0xFF), \ + array[offset+1] = (char) (((value) >> 8) & 0xFF), \ + array[offset+2] = (char) (((value) >> 16) & 0xFF), \ + array[offset+3] = (char) (((value) >> 24) & 0xFF)) + INT32 headersize, bfSize; + int bits_per_pixel, cmap_entries; + + /* Compute colormap size and total file size */ + if (cinfo->out_color_space == JCS_RGB) { + if (cinfo->quantize_colors) { + /* Colormapped RGB */ + bits_per_pixel = 8; + cmap_entries = 256; + } else { + /* Unquantized, full color RGB */ + bits_per_pixel = 24; + cmap_entries = 0; + } + } else { + /* Grayscale output. We need to fake a 256-entry colormap. */ + bits_per_pixel = 8; + cmap_entries = 256; + } + /* File size */ + headersize = 14 + 40 + cmap_entries * 4; /* Header and colormap */ + bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; + + /* Set unused fields of header to 0 */ + MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); + MEMZERO(bmpinfoheader, SIZEOF(bmpinfoheader)); + + /* Fill the file header */ + bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ + bmpfileheader[1] = 0x4D; + PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ + /* we leave bfReserved1 & bfReserved2 = 0 */ + PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ + + /* Fill the info header (Microsoft calls this a BITMAPINFOHEADER) */ + PUT_2B(bmpinfoheader, 0, 40); /* biSize */ + PUT_4B(bmpinfoheader, 4, cinfo->output_width); /* biWidth */ + PUT_4B(bmpinfoheader, 8, cinfo->output_height); /* biHeight */ + PUT_2B(bmpinfoheader, 12, 1); /* biPlanes - must be 1 */ + PUT_2B(bmpinfoheader, 14, bits_per_pixel); /* biBitCount */ + /* we leave biCompression = 0, for none */ + /* we leave biSizeImage = 0; this is correct for uncompressed data */ + if (cinfo->density_unit == 2) { /* if have density in dots/cm, then */ + PUT_4B(bmpinfoheader, 24, (INT32) (cinfo->X_density*100)); /* XPels/M */ + PUT_4B(bmpinfoheader, 28, (INT32) (cinfo->Y_density*100)); /* XPels/M */ + } + PUT_2B(bmpinfoheader, 32, cmap_entries); /* biClrUsed */ + /* we leave biClrImportant = 0 */ + + if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) + ERREXIT(cinfo, JERR_FILE_WRITE); + if (JFWRITE(dest->pub.output_file, bmpinfoheader, 40) != (size_t) 40) + ERREXIT(cinfo, JERR_FILE_WRITE); + + if (cmap_entries > 0) + write_colormap(cinfo, dest, cmap_entries, 4); +} + + +LOCAL(void) +write_os2_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) +/* Write an OS2-style BMP file header, including colormap if needed */ +{ + char bmpfileheader[14]; + char bmpcoreheader[12]; + INT32 headersize, bfSize; + int bits_per_pixel, cmap_entries; + + /* Compute colormap size and total file size */ + if (cinfo->out_color_space == JCS_RGB) { + if (cinfo->quantize_colors) { + /* Colormapped RGB */ + bits_per_pixel = 8; + cmap_entries = 256; + } else { + /* Unquantized, full color RGB */ + bits_per_pixel = 24; + cmap_entries = 0; + } + } else { + /* Grayscale output. We need to fake a 256-entry colormap. */ + bits_per_pixel = 8; + cmap_entries = 256; + } + /* File size */ + headersize = 14 + 12 + cmap_entries * 3; /* Header and colormap */ + bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; + + /* Set unused fields of header to 0 */ + MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); + MEMZERO(bmpcoreheader, SIZEOF(bmpcoreheader)); + + /* Fill the file header */ + bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ + bmpfileheader[1] = 0x4D; + PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ + /* we leave bfReserved1 & bfReserved2 = 0 */ + PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ + + /* Fill the info header (Microsoft calls this a BITMAPCOREHEADER) */ + PUT_2B(bmpcoreheader, 0, 12); /* bcSize */ + PUT_2B(bmpcoreheader, 4, cinfo->output_width); /* bcWidth */ + PUT_2B(bmpcoreheader, 6, cinfo->output_height); /* bcHeight */ + PUT_2B(bmpcoreheader, 8, 1); /* bcPlanes - must be 1 */ + PUT_2B(bmpcoreheader, 10, bits_per_pixel); /* bcBitCount */ + + if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) + ERREXIT(cinfo, JERR_FILE_WRITE); + if (JFWRITE(dest->pub.output_file, bmpcoreheader, 12) != (size_t) 12) + ERREXIT(cinfo, JERR_FILE_WRITE); + + if (cmap_entries > 0) + write_colormap(cinfo, dest, cmap_entries, 3); +} + + +/* + * Write the colormap. + * Windows uses BGR0 map entries; OS/2 uses BGR entries. + */ + +LOCAL(void) +write_colormap (j_decompress_ptr cinfo, bmp_dest_ptr dest, + int map_colors, int map_entry_size) +{ + JSAMPARRAY colormap = cinfo->colormap; + int num_colors = cinfo->actual_number_of_colors; + FILE * outfile = dest->pub.output_file; + int i; + + if (colormap != NULL) { + if (cinfo->out_color_components == 3) { + /* Normal case with RGB colormap */ + for (i = 0; i < num_colors; i++) { + putc(GETJSAMPLE(colormap[2][i]), outfile); + putc(GETJSAMPLE(colormap[1][i]), outfile); + putc(GETJSAMPLE(colormap[0][i]), outfile); + if (map_entry_size == 4) + putc(0, outfile); + } + } else { + /* Grayscale colormap (only happens with grayscale quantization) */ + for (i = 0; i < num_colors; i++) { + putc(GETJSAMPLE(colormap[0][i]), outfile); + putc(GETJSAMPLE(colormap[0][i]), outfile); + putc(GETJSAMPLE(colormap[0][i]), outfile); + if (map_entry_size == 4) + putc(0, outfile); + } + } + } else { + /* If no colormap, must be grayscale data. Generate a linear "map". */ + for (i = 0; i < 256; i++) { + putc(i, outfile); + putc(i, outfile); + putc(i, outfile); + if (map_entry_size == 4) + putc(0, outfile); + } + } + /* Pad colormap with zeros to ensure specified number of colormap entries */ + if (i > map_colors) + ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, i); + for (; i < map_colors; i++) { + putc(0, outfile); + putc(0, outfile); + putc(0, outfile); + if (map_entry_size == 4) + putc(0, outfile); + } +} + + +METHODDEF(void) +finish_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; + register FILE * outfile = dest->pub.output_file; + JSAMPARRAY image_ptr; + register JSAMPROW data_ptr; + JDIMENSION row; + register JDIMENSION col; + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + + /* Write the header and colormap */ + if (dest->is_os2) + write_os2_header(cinfo, dest); + else + write_bmp_header(cinfo, dest); + + /* Write the file body from our virtual array */ + for (row = cinfo->output_height; row > 0; row--) { + if (progress != NULL) { + progress->pub.pass_counter = (long) (cinfo->output_height - row); + progress->pub.pass_limit = (long) cinfo->output_height; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } + image_ptr = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->whole_image, row-1, (JDIMENSION) 1, FALSE); + data_ptr = image_ptr[0]; + for (col = dest->row_width; col > 0; col--) { + putc(GETJSAMPLE(*data_ptr), outfile); + data_ptr++; + } + } + if (progress != NULL) + progress->completed_extra_passes++; + + /* Make sure we wrote the output file OK */ + fflush(outfile); + if (ferror(outfile)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for BMP format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2) +{ + bmp_dest_ptr dest; + JDIMENSION row_width; + + /* Create module interface object, fill in method pointers */ + dest = (bmp_dest_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(bmp_dest_struct)); + dest->pub.start_output = start_output_bmp; + dest->pub.finish_output = finish_output_bmp; + dest->is_os2 = is_os2; + + if (cinfo->out_color_space == JCS_GRAYSCALE) { + dest->pub.put_pixel_rows = put_gray_rows; + } else if (cinfo->out_color_space == JCS_RGB) { + if (cinfo->quantize_colors) + dest->pub.put_pixel_rows = put_gray_rows; + else + dest->pub.put_pixel_rows = put_pixel_rows; + } else { + ERREXIT(cinfo, JERR_BMP_COLORSPACE); + } + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + /* Determine width of rows in the BMP file (padded to 4-byte boundary). */ + row_width = cinfo->output_width * cinfo->output_components; + dest->data_width = row_width; + while ((row_width & 3) != 0) row_width++; + dest->row_width = row_width; + dest->pad_bytes = (int) (row_width - dest->data_width); + + /* Allocate space for inversion array, prepare for write pass */ + dest->whole_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + row_width, cinfo->output_height, (JDIMENSION) 1); + dest->cur_output_row = 0; + if (cinfo->progress != NULL) { + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + progress->total_extra_passes++; /* count file input as separate pass */ + } + + /* Create decompressor output buffer. */ + dest->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, row_width, (JDIMENSION) 1); + dest->pub.buffer_height = 1; + + return (djpeg_dest_ptr) dest; +} + +#endif /* BMP_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/wrgif.c b/src/dep/src/irrlicht/jpeglib/wrgif.c index 13f953b..5fe8328 100644 --- a/src/dep/src/irrlicht/jpeglib/wrgif.c +++ b/src/dep/src/irrlicht/jpeglib/wrgif.c @@ -1,399 +1,399 @@ -/* - * wrgif.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in GIF format. - * - ************************************************************************** - * NOTE: to avoid entanglements with Unisys' patent on LZW compression, * - * this code has been modified to output "uncompressed GIF" files. * - * There is no trace of the LZW algorithm in this file. * - ************************************************************************** - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - */ - -/* - * This code is loosely based on ppmtogif from the PBMPLUS distribution - * of Feb. 1991. That file contains the following copyright notice: - * Based on GIFENCODE by David Rowley . - * Lempel-Ziv compression based on "compress" by Spencer W. Thomas et al. - * Copyright (C) 1989 by Jef Poskanzer. - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation. This software is provided "as is" without express or - * implied warranty. - * - * We are also required to state that - * "The Graphics Interchange Format(c) is the Copyright property of - * CompuServe Incorporated. GIF(sm) is a Service Mark property of - * CompuServe Incorporated." - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef GIF_SUPPORTED - - -/* Private version of data destination object */ - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - j_decompress_ptr cinfo; /* back link saves passing separate parm */ - - /* State for packing variable-width codes into a bitstream */ - int n_bits; /* current number of bits/code */ - int maxcode; /* maximum code, given n_bits */ - INT32 cur_accum; /* holds bits not yet output */ - int cur_bits; /* # of bits in cur_accum */ - - /* State for GIF code assignment */ - int ClearCode; /* clear code (doesn't change) */ - int EOFCode; /* EOF code (ditto) */ - int code_counter; /* counts output symbols */ - - /* GIF data packet construction buffer */ - int bytesinpkt; /* # of bytes in current packet */ - char packetbuf[256]; /* workspace for accumulating packet */ - -} gif_dest_struct; - -typedef gif_dest_struct * gif_dest_ptr; - -/* Largest value that will fit in N bits */ -#define MAXCODE(n_bits) ((1 << (n_bits)) - 1) - - -/* - * Routines to package finished data bytes into GIF data blocks. - * A data block consists of a count byte (1..255) and that many data bytes. - */ - -LOCAL(void) -flush_packet (gif_dest_ptr dinfo) -/* flush any accumulated data */ -{ - if (dinfo->bytesinpkt > 0) { /* never write zero-length packet */ - dinfo->packetbuf[0] = (char) dinfo->bytesinpkt++; - if (JFWRITE(dinfo->pub.output_file, dinfo->packetbuf, dinfo->bytesinpkt) - != (size_t) dinfo->bytesinpkt) - ERREXIT(dinfo->cinfo, JERR_FILE_WRITE); - dinfo->bytesinpkt = 0; - } -} - - -/* Add a character to current packet; flush to disk if necessary */ -#define CHAR_OUT(dinfo,c) \ - { (dinfo)->packetbuf[++(dinfo)->bytesinpkt] = (char) (c); \ - if ((dinfo)->bytesinpkt >= 255) \ - flush_packet(dinfo); \ - } - - -/* Routine to convert variable-width codes into a byte stream */ - -LOCAL(void) -output (gif_dest_ptr dinfo, int code) -/* Emit a code of n_bits bits */ -/* Uses cur_accum and cur_bits to reblock into 8-bit bytes */ -{ - dinfo->cur_accum |= ((INT32) code) << dinfo->cur_bits; - dinfo->cur_bits += dinfo->n_bits; - - while (dinfo->cur_bits >= 8) { - CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); - dinfo->cur_accum >>= 8; - dinfo->cur_bits -= 8; - } -} - - -/* The pseudo-compression algorithm. - * - * In this module we simply output each pixel value as a separate symbol; - * thus, no compression occurs. In fact, there is expansion of one bit per - * pixel, because we use a symbol width one bit wider than the pixel width. - * - * GIF ordinarily uses variable-width symbols, and the decoder will expect - * to ratchet up the symbol width after a fixed number of symbols. - * To simplify the logic and keep the expansion penalty down, we emit a - * GIF Clear code to reset the decoder just before the width would ratchet up. - * Thus, all the symbols in the output file will have the same bit width. - * Note that emitting the Clear codes at the right times is a mere matter of - * counting output symbols and is in no way dependent on the LZW patent. - * - * With a small basic pixel width (low color count), Clear codes will be - * needed very frequently, causing the file to expand even more. So this - * simplistic approach wouldn't work too well on bilevel images, for example. - * But for output of JPEG conversions the pixel width will usually be 8 bits - * (129 to 256 colors), so the overhead added by Clear symbols is only about - * one symbol in every 256. - */ - -LOCAL(void) -compress_init (gif_dest_ptr dinfo, int i_bits) -/* Initialize pseudo-compressor */ -{ - /* init all the state variables */ - dinfo->n_bits = i_bits; - dinfo->maxcode = MAXCODE(dinfo->n_bits); - dinfo->ClearCode = (1 << (i_bits - 1)); - dinfo->EOFCode = dinfo->ClearCode + 1; - dinfo->code_counter = dinfo->ClearCode + 2; - /* init output buffering vars */ - dinfo->bytesinpkt = 0; - dinfo->cur_accum = 0; - dinfo->cur_bits = 0; - /* GIF specifies an initial Clear code */ - output(dinfo, dinfo->ClearCode); -} - - -LOCAL(void) -compress_pixel (gif_dest_ptr dinfo, int c) -/* Accept and "compress" one pixel value. - * The given value must be less than n_bits wide. - */ -{ - /* Output the given pixel value as a symbol. */ - output(dinfo, c); - /* Issue Clear codes often enough to keep the reader from ratcheting up - * its symbol size. - */ - if (dinfo->code_counter < dinfo->maxcode) { - dinfo->code_counter++; - } else { - output(dinfo, dinfo->ClearCode); - dinfo->code_counter = dinfo->ClearCode + 2; /* reset the counter */ - } -} - - -LOCAL(void) -compress_term (gif_dest_ptr dinfo) -/* Clean up at end */ -{ - /* Send an EOF code */ - output(dinfo, dinfo->EOFCode); - /* Flush the bit-packing buffer */ - if (dinfo->cur_bits > 0) { - CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); - } - /* Flush the packet buffer */ - flush_packet(dinfo); -} - - -/* GIF header construction */ - - -LOCAL(void) -put_word (gif_dest_ptr dinfo, unsigned int w) -/* Emit a 16-bit word, LSB first */ -{ - putc(w & 0xFF, dinfo->pub.output_file); - putc((w >> 8) & 0xFF, dinfo->pub.output_file); -} - - -LOCAL(void) -put_3bytes (gif_dest_ptr dinfo, int val) -/* Emit 3 copies of same byte value --- handy subr for colormap construction */ -{ - putc(val, dinfo->pub.output_file); - putc(val, dinfo->pub.output_file); - putc(val, dinfo->pub.output_file); -} - - -LOCAL(void) -emit_header (gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap) -/* Output the GIF file header, including color map */ -/* If colormap==NULL, synthesize a gray-scale colormap */ -{ - int BitsPerPixel, ColorMapSize, InitCodeSize, FlagByte; - int cshift = dinfo->cinfo->data_precision - 8; - int i; - - if (num_colors > 256) - ERREXIT1(dinfo->cinfo, JERR_TOO_MANY_COLORS, num_colors); - /* Compute bits/pixel and related values */ - BitsPerPixel = 1; - while (num_colors > (1 << BitsPerPixel)) - BitsPerPixel++; - ColorMapSize = 1 << BitsPerPixel; - if (BitsPerPixel <= 1) - InitCodeSize = 2; - else - InitCodeSize = BitsPerPixel; - /* - * Write the GIF header. - * Note that we generate a plain GIF87 header for maximum compatibility. - */ - putc('G', dinfo->pub.output_file); - putc('I', dinfo->pub.output_file); - putc('F', dinfo->pub.output_file); - putc('8', dinfo->pub.output_file); - putc('7', dinfo->pub.output_file); - putc('a', dinfo->pub.output_file); - /* Write the Logical Screen Descriptor */ - put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); - put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); - FlagByte = 0x80; /* Yes, there is a global color table */ - FlagByte |= (BitsPerPixel-1) << 4; /* color resolution */ - FlagByte |= (BitsPerPixel-1); /* size of global color table */ - putc(FlagByte, dinfo->pub.output_file); - putc(0, dinfo->pub.output_file); /* Background color index */ - putc(0, dinfo->pub.output_file); /* Reserved (aspect ratio in GIF89) */ - /* Write the Global Color Map */ - /* If the color map is more than 8 bits precision, */ - /* we reduce it to 8 bits by shifting */ - for (i=0; i < ColorMapSize; i++) { - if (i < num_colors) { - if (colormap != NULL) { - if (dinfo->cinfo->out_color_space == JCS_RGB) { - /* Normal case: RGB color map */ - putc(GETJSAMPLE(colormap[0][i]) >> cshift, dinfo->pub.output_file); - putc(GETJSAMPLE(colormap[1][i]) >> cshift, dinfo->pub.output_file); - putc(GETJSAMPLE(colormap[2][i]) >> cshift, dinfo->pub.output_file); - } else { - /* Grayscale "color map": possible if quantizing grayscale image */ - put_3bytes(dinfo, GETJSAMPLE(colormap[0][i]) >> cshift); - } - } else { - /* Create a gray-scale map of num_colors values, range 0..255 */ - put_3bytes(dinfo, (i * 255 + (num_colors-1)/2) / (num_colors-1)); - } - } else { - /* fill out the map to a power of 2 */ - put_3bytes(dinfo, 0); - } - } - /* Write image separator and Image Descriptor */ - putc(',', dinfo->pub.output_file); /* separator */ - put_word(dinfo, 0); /* left/top offset */ - put_word(dinfo, 0); - put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); /* image size */ - put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); - /* flag byte: not interlaced, no local color map */ - putc(0x00, dinfo->pub.output_file); - /* Write Initial Code Size byte */ - putc(InitCodeSize, dinfo->pub.output_file); - - /* Initialize for "compression" of image data */ - compress_init(dinfo, InitCodeSize+1); -} - - -/* - * Startup: write the file header. - */ - -METHODDEF(void) -start_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - gif_dest_ptr dest = (gif_dest_ptr) dinfo; - - if (cinfo->quantize_colors) - emit_header(dest, cinfo->actual_number_of_colors, cinfo->colormap); - else - emit_header(dest, 256, (JSAMPARRAY) NULL); -} - - -/* - * Write some pixel data. - * In this module rows_supplied will always be 1. - */ - -METHODDEF(void) -put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - gif_dest_ptr dest = (gif_dest_ptr) dinfo; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = dest->pub.buffer[0]; - for (col = cinfo->output_width; col > 0; col--) { - compress_pixel(dest, GETJSAMPLE(*ptr++)); - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - gif_dest_ptr dest = (gif_dest_ptr) dinfo; - - /* Flush "compression" mechanism */ - compress_term(dest); - /* Write a zero-length data block to end the series */ - putc(0, dest->pub.output_file); - /* Write the GIF terminator mark */ - putc(';', dest->pub.output_file); - /* Make sure we wrote the output file OK */ - fflush(dest->pub.output_file); - if (ferror(dest->pub.output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for GIF format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_gif (j_decompress_ptr cinfo) -{ - gif_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (gif_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(gif_dest_struct)); - dest->cinfo = cinfo; /* make back link for subroutines */ - dest->pub.start_output = start_output_gif; - dest->pub.put_pixel_rows = put_pixel_rows; - dest->pub.finish_output = finish_output_gif; - - if (cinfo->out_color_space != JCS_GRAYSCALE && - cinfo->out_color_space != JCS_RGB) - ERREXIT(cinfo, JERR_GIF_COLORSPACE); - - /* Force quantization if color or if > 8 bits input */ - if (cinfo->out_color_space != JCS_GRAYSCALE || cinfo->data_precision > 8) { - /* Force quantization to at most 256 colors */ - cinfo->quantize_colors = TRUE; - if (cinfo->desired_number_of_colors > 256) - cinfo->desired_number_of_colors = 256; - } - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - if (cinfo->output_components != 1) /* safety check: just one component? */ - ERREXIT(cinfo, JERR_GIF_BUG); - - /* Create decompressor output buffer. */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, cinfo->output_width, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - - return (djpeg_dest_ptr) dest; -} - -#endif /* GIF_SUPPORTED */ +/* + * wrgif.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write output images in GIF format. + * + ************************************************************************** + * NOTE: to avoid entanglements with Unisys' patent on LZW compression, * + * this code has been modified to output "uncompressed GIF" files. * + * There is no trace of the LZW algorithm in this file. * + ************************************************************************** + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + */ + +/* + * This code is loosely based on ppmtogif from the PBMPLUS distribution + * of Feb. 1991. That file contains the following copyright notice: + * Based on GIFENCODE by David Rowley . + * Lempel-Ziv compression based on "compress" by Spencer W. Thomas et al. + * Copyright (C) 1989 by Jef Poskanzer. + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. This software is provided "as is" without express or + * implied warranty. + * + * We are also required to state that + * "The Graphics Interchange Format(c) is the Copyright property of + * CompuServe Incorporated. GIF(sm) is a Service Mark property of + * CompuServe Incorporated." + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef GIF_SUPPORTED + + +/* Private version of data destination object */ + +typedef struct { + struct djpeg_dest_struct pub; /* public fields */ + + j_decompress_ptr cinfo; /* back link saves passing separate parm */ + + /* State for packing variable-width codes into a bitstream */ + int n_bits; /* current number of bits/code */ + int maxcode; /* maximum code, given n_bits */ + INT32 cur_accum; /* holds bits not yet output */ + int cur_bits; /* # of bits in cur_accum */ + + /* State for GIF code assignment */ + int ClearCode; /* clear code (doesn't change) */ + int EOFCode; /* EOF code (ditto) */ + int code_counter; /* counts output symbols */ + + /* GIF data packet construction buffer */ + int bytesinpkt; /* # of bytes in current packet */ + char packetbuf[256]; /* workspace for accumulating packet */ + +} gif_dest_struct; + +typedef gif_dest_struct * gif_dest_ptr; + +/* Largest value that will fit in N bits */ +#define MAXCODE(n_bits) ((1 << (n_bits)) - 1) + + +/* + * Routines to package finished data bytes into GIF data blocks. + * A data block consists of a count byte (1..255) and that many data bytes. + */ + +LOCAL(void) +flush_packet (gif_dest_ptr dinfo) +/* flush any accumulated data */ +{ + if (dinfo->bytesinpkt > 0) { /* never write zero-length packet */ + dinfo->packetbuf[0] = (char) dinfo->bytesinpkt++; + if (JFWRITE(dinfo->pub.output_file, dinfo->packetbuf, dinfo->bytesinpkt) + != (size_t) dinfo->bytesinpkt) + ERREXIT(dinfo->cinfo, JERR_FILE_WRITE); + dinfo->bytesinpkt = 0; + } +} + + +/* Add a character to current packet; flush to disk if necessary */ +#define CHAR_OUT(dinfo,c) \ + { (dinfo)->packetbuf[++(dinfo)->bytesinpkt] = (char) (c); \ + if ((dinfo)->bytesinpkt >= 255) \ + flush_packet(dinfo); \ + } + + +/* Routine to convert variable-width codes into a byte stream */ + +LOCAL(void) +output (gif_dest_ptr dinfo, int code) +/* Emit a code of n_bits bits */ +/* Uses cur_accum and cur_bits to reblock into 8-bit bytes */ +{ + dinfo->cur_accum |= ((INT32) code) << dinfo->cur_bits; + dinfo->cur_bits += dinfo->n_bits; + + while (dinfo->cur_bits >= 8) { + CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); + dinfo->cur_accum >>= 8; + dinfo->cur_bits -= 8; + } +} + + +/* The pseudo-compression algorithm. + * + * In this module we simply output each pixel value as a separate symbol; + * thus, no compression occurs. In fact, there is expansion of one bit per + * pixel, because we use a symbol width one bit wider than the pixel width. + * + * GIF ordinarily uses variable-width symbols, and the decoder will expect + * to ratchet up the symbol width after a fixed number of symbols. + * To simplify the logic and keep the expansion penalty down, we emit a + * GIF Clear code to reset the decoder just before the width would ratchet up. + * Thus, all the symbols in the output file will have the same bit width. + * Note that emitting the Clear codes at the right times is a mere matter of + * counting output symbols and is in no way dependent on the LZW patent. + * + * With a small basic pixel width (low color count), Clear codes will be + * needed very frequently, causing the file to expand even more. So this + * simplistic approach wouldn't work too well on bilevel images, for example. + * But for output of JPEG conversions the pixel width will usually be 8 bits + * (129 to 256 colors), so the overhead added by Clear symbols is only about + * one symbol in every 256. + */ + +LOCAL(void) +compress_init (gif_dest_ptr dinfo, int i_bits) +/* Initialize pseudo-compressor */ +{ + /* init all the state variables */ + dinfo->n_bits = i_bits; + dinfo->maxcode = MAXCODE(dinfo->n_bits); + dinfo->ClearCode = (1 << (i_bits - 1)); + dinfo->EOFCode = dinfo->ClearCode + 1; + dinfo->code_counter = dinfo->ClearCode + 2; + /* init output buffering vars */ + dinfo->bytesinpkt = 0; + dinfo->cur_accum = 0; + dinfo->cur_bits = 0; + /* GIF specifies an initial Clear code */ + output(dinfo, dinfo->ClearCode); +} + + +LOCAL(void) +compress_pixel (gif_dest_ptr dinfo, int c) +/* Accept and "compress" one pixel value. + * The given value must be less than n_bits wide. + */ +{ + /* Output the given pixel value as a symbol. */ + output(dinfo, c); + /* Issue Clear codes often enough to keep the reader from ratcheting up + * its symbol size. + */ + if (dinfo->code_counter < dinfo->maxcode) { + dinfo->code_counter++; + } else { + output(dinfo, dinfo->ClearCode); + dinfo->code_counter = dinfo->ClearCode + 2; /* reset the counter */ + } +} + + +LOCAL(void) +compress_term (gif_dest_ptr dinfo) +/* Clean up at end */ +{ + /* Send an EOF code */ + output(dinfo, dinfo->EOFCode); + /* Flush the bit-packing buffer */ + if (dinfo->cur_bits > 0) { + CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); + } + /* Flush the packet buffer */ + flush_packet(dinfo); +} + + +/* GIF header construction */ + + +LOCAL(void) +put_word (gif_dest_ptr dinfo, unsigned int w) +/* Emit a 16-bit word, LSB first */ +{ + putc(w & 0xFF, dinfo->pub.output_file); + putc((w >> 8) & 0xFF, dinfo->pub.output_file); +} + + +LOCAL(void) +put_3bytes (gif_dest_ptr dinfo, int val) +/* Emit 3 copies of same byte value --- handy subr for colormap construction */ +{ + putc(val, dinfo->pub.output_file); + putc(val, dinfo->pub.output_file); + putc(val, dinfo->pub.output_file); +} + + +LOCAL(void) +emit_header (gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap) +/* Output the GIF file header, including color map */ +/* If colormap==NULL, synthesize a gray-scale colormap */ +{ + int BitsPerPixel, ColorMapSize, InitCodeSize, FlagByte; + int cshift = dinfo->cinfo->data_precision - 8; + int i; + + if (num_colors > 256) + ERREXIT1(dinfo->cinfo, JERR_TOO_MANY_COLORS, num_colors); + /* Compute bits/pixel and related values */ + BitsPerPixel = 1; + while (num_colors > (1 << BitsPerPixel)) + BitsPerPixel++; + ColorMapSize = 1 << BitsPerPixel; + if (BitsPerPixel <= 1) + InitCodeSize = 2; + else + InitCodeSize = BitsPerPixel; + /* + * Write the GIF header. + * Note that we generate a plain GIF87 header for maximum compatibility. + */ + putc('G', dinfo->pub.output_file); + putc('I', dinfo->pub.output_file); + putc('F', dinfo->pub.output_file); + putc('8', dinfo->pub.output_file); + putc('7', dinfo->pub.output_file); + putc('a', dinfo->pub.output_file); + /* Write the Logical Screen Descriptor */ + put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); + put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); + FlagByte = 0x80; /* Yes, there is a global color table */ + FlagByte |= (BitsPerPixel-1) << 4; /* color resolution */ + FlagByte |= (BitsPerPixel-1); /* size of global color table */ + putc(FlagByte, dinfo->pub.output_file); + putc(0, dinfo->pub.output_file); /* Background color index */ + putc(0, dinfo->pub.output_file); /* Reserved (aspect ratio in GIF89) */ + /* Write the Global Color Map */ + /* If the color map is more than 8 bits precision, */ + /* we reduce it to 8 bits by shifting */ + for (i=0; i < ColorMapSize; i++) { + if (i < num_colors) { + if (colormap != NULL) { + if (dinfo->cinfo->out_color_space == JCS_RGB) { + /* Normal case: RGB color map */ + putc(GETJSAMPLE(colormap[0][i]) >> cshift, dinfo->pub.output_file); + putc(GETJSAMPLE(colormap[1][i]) >> cshift, dinfo->pub.output_file); + putc(GETJSAMPLE(colormap[2][i]) >> cshift, dinfo->pub.output_file); + } else { + /* Grayscale "color map": possible if quantizing grayscale image */ + put_3bytes(dinfo, GETJSAMPLE(colormap[0][i]) >> cshift); + } + } else { + /* Create a gray-scale map of num_colors values, range 0..255 */ + put_3bytes(dinfo, (i * 255 + (num_colors-1)/2) / (num_colors-1)); + } + } else { + /* fill out the map to a power of 2 */ + put_3bytes(dinfo, 0); + } + } + /* Write image separator and Image Descriptor */ + putc(',', dinfo->pub.output_file); /* separator */ + put_word(dinfo, 0); /* left/top offset */ + put_word(dinfo, 0); + put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); /* image size */ + put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); + /* flag byte: not interlaced, no local color map */ + putc(0x00, dinfo->pub.output_file); + /* Write Initial Code Size byte */ + putc(InitCodeSize, dinfo->pub.output_file); + + /* Initialize for "compression" of image data */ + compress_init(dinfo, InitCodeSize+1); +} + + +/* + * Startup: write the file header. + */ + +METHODDEF(void) +start_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + gif_dest_ptr dest = (gif_dest_ptr) dinfo; + + if (cinfo->quantize_colors) + emit_header(dest, cinfo->actual_number_of_colors, cinfo->colormap); + else + emit_header(dest, 256, (JSAMPARRAY) NULL); +} + + +/* + * Write some pixel data. + * In this module rows_supplied will always be 1. + */ + +METHODDEF(void) +put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + gif_dest_ptr dest = (gif_dest_ptr) dinfo; + register JSAMPROW ptr; + register JDIMENSION col; + + ptr = dest->pub.buffer[0]; + for (col = cinfo->output_width; col > 0; col--) { + compress_pixel(dest, GETJSAMPLE(*ptr++)); + } +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + gif_dest_ptr dest = (gif_dest_ptr) dinfo; + + /* Flush "compression" mechanism */ + compress_term(dest); + /* Write a zero-length data block to end the series */ + putc(0, dest->pub.output_file); + /* Write the GIF terminator mark */ + putc(';', dest->pub.output_file); + /* Make sure we wrote the output file OK */ + fflush(dest->pub.output_file); + if (ferror(dest->pub.output_file)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for GIF format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_gif (j_decompress_ptr cinfo) +{ + gif_dest_ptr dest; + + /* Create module interface object, fill in method pointers */ + dest = (gif_dest_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(gif_dest_struct)); + dest->cinfo = cinfo; /* make back link for subroutines */ + dest->pub.start_output = start_output_gif; + dest->pub.put_pixel_rows = put_pixel_rows; + dest->pub.finish_output = finish_output_gif; + + if (cinfo->out_color_space != JCS_GRAYSCALE && + cinfo->out_color_space != JCS_RGB) + ERREXIT(cinfo, JERR_GIF_COLORSPACE); + + /* Force quantization if color or if > 8 bits input */ + if (cinfo->out_color_space != JCS_GRAYSCALE || cinfo->data_precision > 8) { + /* Force quantization to at most 256 colors */ + cinfo->quantize_colors = TRUE; + if (cinfo->desired_number_of_colors > 256) + cinfo->desired_number_of_colors = 256; + } + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + if (cinfo->output_components != 1) /* safety check: just one component? */ + ERREXIT(cinfo, JERR_GIF_BUG); + + /* Create decompressor output buffer. */ + dest->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, cinfo->output_width, (JDIMENSION) 1); + dest->pub.buffer_height = 1; + + return (djpeg_dest_ptr) dest; +} + +#endif /* GIF_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/wrjpgcom.1 b/src/dep/src/irrlicht/jpeglib/wrjpgcom.1 index 44dad35..d419a99 100644 --- a/src/dep/src/irrlicht/jpeglib/wrjpgcom.1 +++ b/src/dep/src/irrlicht/jpeglib/wrjpgcom.1 @@ -1,103 +1,103 @@ -.TH WRJPGCOM 1 "15 June 1995" -.SH NAME -wrjpgcom \- insert text comments into a JPEG file -.SH SYNOPSIS -.B wrjpgcom -[ -.B \-replace -] -[ -.BI \-comment " text" -] -[ -.BI \-cfile " name" -] -[ -.I filename -] -.LP -.SH DESCRIPTION -.LP -.B wrjpgcom -reads the named JPEG/JFIF file, or the standard input if no file is named, -and generates a new JPEG/JFIF file on standard output. A comment block is -added to the file. -.PP -The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. -Although the standard doesn't actually define what COM blocks are for, they -are widely used to hold user-supplied text strings. This lets you add -annotations, titles, index terms, etc to your JPEG files, and later retrieve -them as text. COM blocks do not interfere with the image stored in the JPEG -file. The maximum size of a COM block is 64K, but you can have as many of -them as you like in one JPEG file. -.PP -.B wrjpgcom -adds a COM block, containing text you provide, to a JPEG file. -Ordinarily, the COM block is added after any existing COM blocks; but you -can delete the old COM blocks if you wish. -.SH OPTIONS -Switch names may be abbreviated, and are not case sensitive. -.TP -.B \-replace -Delete any existing COM blocks from the file. -.TP -.BI \-comment " text" -Supply text for new COM block on command line. -.TP -.BI \-cfile " name" -Read text for new COM block from named file. -.PP -If you have only one line of comment text to add, you can provide it on the -command line with -.BR \-comment . -The comment text must be surrounded with quotes so that it is treated as a -single argument. Longer comments can be read from a text file. -.PP -If you give neither -.B \-comment -nor -.BR \-cfile , -then -.B wrjpgcom -will read the comment text from standard input. (In this case an input image -file name MUST be supplied, so that the source JPEG file comes from somewhere -else.) You can enter multiple lines, up to 64KB worth. Type an end-of-file -indicator (usually control-D) to terminate the comment text entry. -.PP -.B wrjpgcom -will not add a COM block if the provided comment string is empty. Therefore -\fB\-replace \-comment ""\fR can be used to delete all COM blocks from a file. -.SH EXAMPLES -.LP -Add a short comment to in.jpg, producing out.jpg: -.IP -.B wrjpgcom \-c -\fI"View of my back yard" in.jpg -.B > -.I out.jpg -.PP -Attach a long comment previously stored in comment.txt: -.IP -.B wrjpgcom -.I in.jpg -.B < -.I comment.txt -.B > -.I out.jpg -.PP -or equivalently -.IP -.B wrjpgcom -.B -cfile -.I comment.txt -.B < -.I in.jpg -.B > -.I out.jpg -.SH SEE ALSO -.BR cjpeg (1), -.BR djpeg (1), -.BR jpegtran (1), -.BR rdjpgcom (1) -.SH AUTHOR -Independent JPEG Group +.TH WRJPGCOM 1 "15 June 1995" +.SH NAME +wrjpgcom \- insert text comments into a JPEG file +.SH SYNOPSIS +.B wrjpgcom +[ +.B \-replace +] +[ +.BI \-comment " text" +] +[ +.BI \-cfile " name" +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B wrjpgcom +reads the named JPEG/JFIF file, or the standard input if no file is named, +and generates a new JPEG/JFIF file on standard output. A comment block is +added to the file. +.PP +The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. +Although the standard doesn't actually define what COM blocks are for, they +are widely used to hold user-supplied text strings. This lets you add +annotations, titles, index terms, etc to your JPEG files, and later retrieve +them as text. COM blocks do not interfere with the image stored in the JPEG +file. The maximum size of a COM block is 64K, but you can have as many of +them as you like in one JPEG file. +.PP +.B wrjpgcom +adds a COM block, containing text you provide, to a JPEG file. +Ordinarily, the COM block is added after any existing COM blocks; but you +can delete the old COM blocks if you wish. +.SH OPTIONS +Switch names may be abbreviated, and are not case sensitive. +.TP +.B \-replace +Delete any existing COM blocks from the file. +.TP +.BI \-comment " text" +Supply text for new COM block on command line. +.TP +.BI \-cfile " name" +Read text for new COM block from named file. +.PP +If you have only one line of comment text to add, you can provide it on the +command line with +.BR \-comment . +The comment text must be surrounded with quotes so that it is treated as a +single argument. Longer comments can be read from a text file. +.PP +If you give neither +.B \-comment +nor +.BR \-cfile , +then +.B wrjpgcom +will read the comment text from standard input. (In this case an input image +file name MUST be supplied, so that the source JPEG file comes from somewhere +else.) You can enter multiple lines, up to 64KB worth. Type an end-of-file +indicator (usually control-D) to terminate the comment text entry. +.PP +.B wrjpgcom +will not add a COM block if the provided comment string is empty. Therefore +\fB\-replace \-comment ""\fR can be used to delete all COM blocks from a file. +.SH EXAMPLES +.LP +Add a short comment to in.jpg, producing out.jpg: +.IP +.B wrjpgcom \-c +\fI"View of my back yard" in.jpg +.B > +.I out.jpg +.PP +Attach a long comment previously stored in comment.txt: +.IP +.B wrjpgcom +.I in.jpg +.B < +.I comment.txt +.B > +.I out.jpg +.PP +or equivalently +.IP +.B wrjpgcom +.B -cfile +.I comment.txt +.B < +.I in.jpg +.B > +.I out.jpg +.SH SEE ALSO +.BR cjpeg (1), +.BR djpeg (1), +.BR jpegtran (1), +.BR rdjpgcom (1) +.SH AUTHOR +Independent JPEG Group diff --git a/src/dep/src/irrlicht/jpeglib/wrjpgcom.c b/src/dep/src/irrlicht/jpeglib/wrjpgcom.c index 7d10ee6..8c04b05 100644 --- a/src/dep/src/irrlicht/jpeglib/wrjpgcom.c +++ b/src/dep/src/irrlicht/jpeglib/wrjpgcom.c @@ -1,583 +1,583 @@ -/* - * wrjpgcom.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a very simple stand-alone application that inserts - * user-supplied text as a COM (comment) marker in a JFIF file. - * This may be useful as an example of the minimum logic needed to parse - * JPEG markers. - */ - -#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ -#include "jinclude.h" /* get auto-config symbols, */ - -#ifndef HAVE_STDLIB_H /* should declare malloc() */ -extern void * malloc (); -#endif -#include /* to declare isupper(), tolower() */ -#ifdef USE_SETMODE -#include /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not , just delete this line: */ -#include /* to declare setmode() */ -#endif - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#define WRITE_BINARY "w" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#define WRITE_BINARY "wb", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#define WRITE_BINARY "wb" -#endif -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif -#ifndef EXIT_SUCCESS -#ifdef VMS -#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ -#else -#define EXIT_SUCCESS 0 -#endif -#endif - -/* Reduce this value if your malloc() can't allocate blocks up to 64K. - * On DOS, compiling in large model is usually a better solution. - */ - -#ifndef MAX_COM_LENGTH -#define MAX_COM_LENGTH 65000L /* must be <= 65533 in any case */ -#endif - - -/* - * These macros are used to read the input file and write the output file. - * To reuse this code in another application, you might need to change these. - */ - -static FILE * infile; /* input JPEG file */ - -/* Return next input byte, or EOF if no more */ -#define NEXTBYTE() getc(infile) - -static FILE * outfile; /* output JPEG file */ - -/* Emit an output byte */ -#define PUTBYTE(x) putc((x), outfile) - - -/* Error exit handler */ -#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) - - -/* Read one byte, testing for EOF */ -static int -read_1_byte (void) -{ - int c; - - c = NEXTBYTE(); - if (c == EOF) - ERREXIT("Premature EOF in JPEG file"); - return c; -} - -/* Read 2 bytes, convert to unsigned int */ -/* All 2-byte quantities in JPEG markers are MSB first */ -static unsigned int -read_2_bytes (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - if (c1 == EOF) - ERREXIT("Premature EOF in JPEG file"); - c2 = NEXTBYTE(); - if (c2 == EOF) - ERREXIT("Premature EOF in JPEG file"); - return (((unsigned int) c1) << 8) + ((unsigned int) c2); -} - - -/* Routines to write data to output file */ - -static void -write_1_byte (int c) -{ - PUTBYTE(c); -} - -static void -write_2_bytes (unsigned int val) -{ - PUTBYTE((val >> 8) & 0xFF); - PUTBYTE(val & 0xFF); -} - -static void -write_marker (int marker) -{ - PUTBYTE(0xFF); - PUTBYTE(marker); -} - -static void -copy_rest_of_file (void) -{ - int c; - - while ((c = NEXTBYTE()) != EOF) - PUTBYTE(c); -} - - -/* - * JPEG markers consist of one or more 0xFF bytes, followed by a marker - * code byte (which is not an FF). Here are the marker codes of interest - * in this program. (See jdmarker.c for a more complete list.) - */ - -#define M_SOF0 0xC0 /* Start Of Frame N */ -#define M_SOF1 0xC1 /* N indicates which compression process */ -#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ -#define M_SOF3 0xC3 -#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ -#define M_SOF6 0xC6 -#define M_SOF7 0xC7 -#define M_SOF9 0xC9 -#define M_SOF10 0xCA -#define M_SOF11 0xCB -#define M_SOF13 0xCD -#define M_SOF14 0xCE -#define M_SOF15 0xCF -#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ -#define M_EOI 0xD9 /* End Of Image (end of datastream) */ -#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ -#define M_COM 0xFE /* COMment */ - - -/* - * Find the next JPEG marker and return its marker code. - * We expect at least one FF byte, possibly more if the compressor used FFs - * to pad the file. (Padding FFs will NOT be replicated in the output file.) - * There could also be non-FF garbage between markers. The treatment of such - * garbage is unspecified; we choose to skip over it but emit a warning msg. - * NB: this routine must not be used after seeing SOS marker, since it will - * not deal correctly with FF/00 sequences in the compressed image data... - */ - -static int -next_marker (void) -{ - int c; - int discarded_bytes = 0; - - /* Find 0xFF byte; count and skip any non-FFs. */ - c = read_1_byte(); - while (c != 0xFF) { - discarded_bytes++; - c = read_1_byte(); - } - /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs - * are legal as pad bytes, so don't count them in discarded_bytes. - */ - do { - c = read_1_byte(); - } while (c == 0xFF); - - if (discarded_bytes != 0) { - fprintf(stderr, "Warning: garbage data found in JPEG file\n"); - } - - return c; -} - - -/* - * Read the initial marker, which should be SOI. - * For a JFIF file, the first two bytes of the file should be literally - * 0xFF M_SOI. To be more general, we could use next_marker, but if the - * input file weren't actually JPEG at all, next_marker might read the whole - * file and then return a misleading error message... - */ - -static int -first_marker (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - c2 = NEXTBYTE(); - if (c1 != 0xFF || c2 != M_SOI) - ERREXIT("Not a JPEG file"); - return c2; -} - - -/* - * Most types of marker are followed by a variable-length parameter segment. - * This routine skips over the parameters for any marker we don't otherwise - * want to process. - * Note that we MUST skip the parameter segment explicitly in order not to - * be fooled by 0xFF bytes that might appear within the parameter segment; - * such bytes do NOT introduce new markers. - */ - -static void -copy_variable (void) -/* Copy an unknown or uninteresting variable-length marker */ -{ - unsigned int length; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - write_2_bytes(length); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - /* Skip over the remaining bytes */ - while (length > 0) { - write_1_byte(read_1_byte()); - length--; - } -} - -static void -skip_variable (void) -/* Skip over an unknown or uninteresting variable-length marker */ -{ - unsigned int length; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - /* Skip over the remaining bytes */ - while (length > 0) { - (void) read_1_byte(); - length--; - } -} - - -/* - * Parse the marker stream until SOFn or EOI is seen; - * copy data to output, but discard COM markers unless keep_COM is true. - */ - -static int -scan_JPEG_header (int keep_COM) -{ - int marker; - - /* Expect SOI at start of file */ - if (first_marker() != M_SOI) - ERREXIT("Expected SOI marker first"); - write_marker(M_SOI); - - /* Scan miscellaneous markers until we reach SOFn. */ - for (;;) { - marker = next_marker(); - switch (marker) { - /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, - * treated as SOFn. C4 in particular is actually DHT. - */ - case M_SOF0: /* Baseline */ - case M_SOF1: /* Extended sequential, Huffman */ - case M_SOF2: /* Progressive, Huffman */ - case M_SOF3: /* Lossless, Huffman */ - case M_SOF5: /* Differential sequential, Huffman */ - case M_SOF6: /* Differential progressive, Huffman */ - case M_SOF7: /* Differential lossless, Huffman */ - case M_SOF9: /* Extended sequential, arithmetic */ - case M_SOF10: /* Progressive, arithmetic */ - case M_SOF11: /* Lossless, arithmetic */ - case M_SOF13: /* Differential sequential, arithmetic */ - case M_SOF14: /* Differential progressive, arithmetic */ - case M_SOF15: /* Differential lossless, arithmetic */ - return marker; - - case M_SOS: /* should not see compressed data before SOF */ - ERREXIT("SOS without prior SOFn"); - break; - - case M_EOI: /* in case it's a tables-only JPEG stream */ - return marker; - - case M_COM: /* Existing COM: conditionally discard */ - if (keep_COM) { - write_marker(marker); - copy_variable(); - } else { - skip_variable(); - } - break; - - default: /* Anything else just gets copied */ - write_marker(marker); - copy_variable(); /* we assume it has a parameter count... */ - break; - } - } /* end loop */ -} - - -/* Command line parsing code */ - -static const char * progname; /* program name for error messages */ - - -static void -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "wrjpgcom inserts a textual comment in a JPEG file.\n"); - fprintf(stderr, "You can add to or replace any existing comment(s).\n"); - - fprintf(stderr, "Usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -replace Delete any existing comments\n"); - fprintf(stderr, " -comment \"text\" Insert comment with given text\n"); - fprintf(stderr, " -cfile name Read comment from named file\n"); - fprintf(stderr, "Notice that you must put quotes around the comment text\n"); - fprintf(stderr, "when you use -comment.\n"); - fprintf(stderr, "If you do not give either -comment or -cfile on the command line,\n"); - fprintf(stderr, "then the comment text is read from standard input.\n"); - fprintf(stderr, "It can be multiple lines, up to %u characters total.\n", - (unsigned int) MAX_COM_LENGTH); -#ifndef TWO_FILE_COMMANDLINE - fprintf(stderr, "You must specify an input JPEG file name when supplying\n"); - fprintf(stderr, "comment text from standard input.\n"); -#endif - - exit(EXIT_FAILURE); -} - - -static int -keymatch (char * arg, const char * keyword, int minchars) -/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ -/* keyword is the constant keyword (must be lower case already), */ -/* minchars is length of minimum legal abbreviation. */ -{ - register int ca, ck; - register int nmatched = 0; - - while ((ca = *arg++) != '\0') { - if ((ck = *keyword++) == '\0') - return 0; /* arg longer than keyword, no good */ - if (isupper(ca)) /* force arg to lcase (assume ck is already) */ - ca = tolower(ca); - if (ca != ck) - return 0; /* no good */ - nmatched++; /* count matched characters */ - } - /* reached end of argument; fail if it's too short for unique abbrev */ - if (nmatched < minchars) - return 0; - return 1; /* A-OK */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - int argn; - char * arg; - int keep_COM = 1; - char * comment_arg = NULL; - FILE * comment_file = NULL; - unsigned int comment_length = 0; - int marker; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "wrjpgcom"; /* in case C library doesn't provide it */ - - /* Parse switches, if any */ - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (arg[0] != '-') - break; /* not switch, must be file name */ - arg++; /* advance over '-' */ - if (keymatch(arg, "replace", 1)) { - keep_COM = 0; - } else if (keymatch(arg, "cfile", 2)) { - if (++argn >= argc) usage(); - if ((comment_file = fopen(argv[argn], "r")) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - } else if (keymatch(arg, "comment", 1)) { - if (++argn >= argc) usage(); - comment_arg = argv[argn]; - /* If the comment text starts with '"', then we are probably running - * under MS-DOG and must parse out the quoted string ourselves. Sigh. - */ - if (comment_arg[0] == '"') { - comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); - if (comment_arg == NULL) - ERREXIT("Insufficient memory"); - strcpy(comment_arg, argv[argn]+1); - for (;;) { - comment_length = (unsigned int) strlen(comment_arg); - if (comment_length > 0 && comment_arg[comment_length-1] == '"') { - comment_arg[comment_length-1] = '\0'; /* zap terminating quote */ - break; - } - if (++argn >= argc) - ERREXIT("Missing ending quote mark"); - strcat(comment_arg, " "); - strcat(comment_arg, argv[argn]); - } - } - comment_length = (unsigned int) strlen(comment_arg); - } else - usage(); - } - - /* Cannot use both -comment and -cfile. */ - if (comment_arg != NULL && comment_file != NULL) - usage(); - /* If there is neither -comment nor -cfile, we will read the comment text - * from stdin; in this case there MUST be an input JPEG file name. - */ - if (comment_arg == NULL && comment_file == NULL && argn >= argc) - usage(); - - /* Open the input file. */ - if (argn < argc) { - if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdin), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open stdin\n", progname); - exit(EXIT_FAILURE); - } -#else - infile = stdin; -#endif - } - - /* Open the output file. */ -#ifdef TWO_FILE_COMMANDLINE - /* Must have explicit output file name */ - if (argn != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - if ((outfile = fopen(argv[argn+1], WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn+1]); - exit(EXIT_FAILURE); - } -#else - /* Unix style: expect zero or one file name */ - if (argn < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } - /* default output file is stdout */ -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdout), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((outfile = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open stdout\n", progname); - exit(EXIT_FAILURE); - } -#else - outfile = stdout; -#endif -#endif /* TWO_FILE_COMMANDLINE */ - - /* Collect comment text from comment_file or stdin, if necessary */ - if (comment_arg == NULL) { - FILE * src_file; - int c; - - comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); - if (comment_arg == NULL) - ERREXIT("Insufficient memory"); - comment_length = 0; - src_file = (comment_file != NULL ? comment_file : stdin); - while ((c = getc(src_file)) != EOF) { - if (comment_length >= (unsigned int) MAX_COM_LENGTH) { - fprintf(stderr, "Comment text may not exceed %u bytes\n", - (unsigned int) MAX_COM_LENGTH); - exit(EXIT_FAILURE); - } - comment_arg[comment_length++] = (char) c; - } - if (comment_file != NULL) - fclose(comment_file); - } - - /* Copy JPEG headers until SOFn marker; - * we will insert the new comment marker just before SOFn. - * This (a) causes the new comment to appear after, rather than before, - * existing comments; and (b) ensures that comments come after any JFIF - * or JFXX markers, as required by the JFIF specification. - */ - marker = scan_JPEG_header(keep_COM); - /* Insert the new COM marker, but only if nonempty text has been supplied */ - if (comment_length > 0) { - write_marker(M_COM); - write_2_bytes(comment_length + 2); - while (comment_length > 0) { - write_1_byte(*comment_arg++); - comment_length--; - } - } - /* Duplicate the remainder of the source file. - * Note that any COM markers occuring after SOF will not be touched. - */ - write_marker(marker); - copy_rest_of_file(); - - /* All done. */ - exit(EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} +/* + * wrjpgcom.c + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a very simple stand-alone application that inserts + * user-supplied text as a COM (comment) marker in a JFIF file. + * This may be useful as an example of the minimum logic needed to parse + * JPEG markers. + */ + +#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ +#include "jinclude.h" /* get auto-config symbols, */ + +#ifndef HAVE_STDLIB_H /* should declare malloc() */ +extern void * malloc (); +#endif +#include /* to declare isupper(), tolower() */ +#ifdef USE_SETMODE +#include /* to declare setmode()'s parameter macros */ +/* If you have setmode() but not , just delete this line: */ +#include /* to declare setmode() */ +#endif + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#define WRITE_BINARY "w" +#else +#ifdef VMS /* VMS is very nonstandard */ +#define READ_BINARY "rb", "ctx=stm" +#define WRITE_BINARY "wb", "ctx=stm" +#else /* standard ANSI-compliant case */ +#define READ_BINARY "rb" +#define WRITE_BINARY "wb" +#endif +#endif + +#ifndef EXIT_FAILURE /* define exit() codes if not provided */ +#define EXIT_FAILURE 1 +#endif +#ifndef EXIT_SUCCESS +#ifdef VMS +#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ +#else +#define EXIT_SUCCESS 0 +#endif +#endif + +/* Reduce this value if your malloc() can't allocate blocks up to 64K. + * On DOS, compiling in large model is usually a better solution. + */ + +#ifndef MAX_COM_LENGTH +#define MAX_COM_LENGTH 65000L /* must be <= 65533 in any case */ +#endif + + +/* + * These macros are used to read the input file and write the output file. + * To reuse this code in another application, you might need to change these. + */ + +static FILE * infile; /* input JPEG file */ + +/* Return next input byte, or EOF if no more */ +#define NEXTBYTE() getc(infile) + +static FILE * outfile; /* output JPEG file */ + +/* Emit an output byte */ +#define PUTBYTE(x) putc((x), outfile) + + +/* Error exit handler */ +#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) + + +/* Read one byte, testing for EOF */ +static int +read_1_byte (void) +{ + int c; + + c = NEXTBYTE(); + if (c == EOF) + ERREXIT("Premature EOF in JPEG file"); + return c; +} + +/* Read 2 bytes, convert to unsigned int */ +/* All 2-byte quantities in JPEG markers are MSB first */ +static unsigned int +read_2_bytes (void) +{ + int c1, c2; + + c1 = NEXTBYTE(); + if (c1 == EOF) + ERREXIT("Premature EOF in JPEG file"); + c2 = NEXTBYTE(); + if (c2 == EOF) + ERREXIT("Premature EOF in JPEG file"); + return (((unsigned int) c1) << 8) + ((unsigned int) c2); +} + + +/* Routines to write data to output file */ + +static void +write_1_byte (int c) +{ + PUTBYTE(c); +} + +static void +write_2_bytes (unsigned int val) +{ + PUTBYTE((val >> 8) & 0xFF); + PUTBYTE(val & 0xFF); +} + +static void +write_marker (int marker) +{ + PUTBYTE(0xFF); + PUTBYTE(marker); +} + +static void +copy_rest_of_file (void) +{ + int c; + + while ((c = NEXTBYTE()) != EOF) + PUTBYTE(c); +} + + +/* + * JPEG markers consist of one or more 0xFF bytes, followed by a marker + * code byte (which is not an FF). Here are the marker codes of interest + * in this program. (See jdmarker.c for a more complete list.) + */ + +#define M_SOF0 0xC0 /* Start Of Frame N */ +#define M_SOF1 0xC1 /* N indicates which compression process */ +#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ +#define M_SOF3 0xC3 +#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ +#define M_SOF6 0xC6 +#define M_SOF7 0xC7 +#define M_SOF9 0xC9 +#define M_SOF10 0xCA +#define M_SOF11 0xCB +#define M_SOF13 0xCD +#define M_SOF14 0xCE +#define M_SOF15 0xCF +#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ +#define M_EOI 0xD9 /* End Of Image (end of datastream) */ +#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ +#define M_COM 0xFE /* COMment */ + + +/* + * Find the next JPEG marker and return its marker code. + * We expect at least one FF byte, possibly more if the compressor used FFs + * to pad the file. (Padding FFs will NOT be replicated in the output file.) + * There could also be non-FF garbage between markers. The treatment of such + * garbage is unspecified; we choose to skip over it but emit a warning msg. + * NB: this routine must not be used after seeing SOS marker, since it will + * not deal correctly with FF/00 sequences in the compressed image data... + */ + +static int +next_marker (void) +{ + int c; + int discarded_bytes = 0; + + /* Find 0xFF byte; count and skip any non-FFs. */ + c = read_1_byte(); + while (c != 0xFF) { + discarded_bytes++; + c = read_1_byte(); + } + /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs + * are legal as pad bytes, so don't count them in discarded_bytes. + */ + do { + c = read_1_byte(); + } while (c == 0xFF); + + if (discarded_bytes != 0) { + fprintf(stderr, "Warning: garbage data found in JPEG file\n"); + } + + return c; +} + + +/* + * Read the initial marker, which should be SOI. + * For a JFIF file, the first two bytes of the file should be literally + * 0xFF M_SOI. To be more general, we could use next_marker, but if the + * input file weren't actually JPEG at all, next_marker might read the whole + * file and then return a misleading error message... + */ + +static int +first_marker (void) +{ + int c1, c2; + + c1 = NEXTBYTE(); + c2 = NEXTBYTE(); + if (c1 != 0xFF || c2 != M_SOI) + ERREXIT("Not a JPEG file"); + return c2; +} + + +/* + * Most types of marker are followed by a variable-length parameter segment. + * This routine skips over the parameters for any marker we don't otherwise + * want to process. + * Note that we MUST skip the parameter segment explicitly in order not to + * be fooled by 0xFF bytes that might appear within the parameter segment; + * such bytes do NOT introduce new markers. + */ + +static void +copy_variable (void) +/* Copy an unknown or uninteresting variable-length marker */ +{ + unsigned int length; + + /* Get the marker parameter length count */ + length = read_2_bytes(); + write_2_bytes(length); + /* Length includes itself, so must be at least 2 */ + if (length < 2) + ERREXIT("Erroneous JPEG marker length"); + length -= 2; + /* Skip over the remaining bytes */ + while (length > 0) { + write_1_byte(read_1_byte()); + length--; + } +} + +static void +skip_variable (void) +/* Skip over an unknown or uninteresting variable-length marker */ +{ + unsigned int length; + + /* Get the marker parameter length count */ + length = read_2_bytes(); + /* Length includes itself, so must be at least 2 */ + if (length < 2) + ERREXIT("Erroneous JPEG marker length"); + length -= 2; + /* Skip over the remaining bytes */ + while (length > 0) { + (void) read_1_byte(); + length--; + } +} + + +/* + * Parse the marker stream until SOFn or EOI is seen; + * copy data to output, but discard COM markers unless keep_COM is true. + */ + +static int +scan_JPEG_header (int keep_COM) +{ + int marker; + + /* Expect SOI at start of file */ + if (first_marker() != M_SOI) + ERREXIT("Expected SOI marker first"); + write_marker(M_SOI); + + /* Scan miscellaneous markers until we reach SOFn. */ + for (;;) { + marker = next_marker(); + switch (marker) { + /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, + * treated as SOFn. C4 in particular is actually DHT. + */ + case M_SOF0: /* Baseline */ + case M_SOF1: /* Extended sequential, Huffman */ + case M_SOF2: /* Progressive, Huffman */ + case M_SOF3: /* Lossless, Huffman */ + case M_SOF5: /* Differential sequential, Huffman */ + case M_SOF6: /* Differential progressive, Huffman */ + case M_SOF7: /* Differential lossless, Huffman */ + case M_SOF9: /* Extended sequential, arithmetic */ + case M_SOF10: /* Progressive, arithmetic */ + case M_SOF11: /* Lossless, arithmetic */ + case M_SOF13: /* Differential sequential, arithmetic */ + case M_SOF14: /* Differential progressive, arithmetic */ + case M_SOF15: /* Differential lossless, arithmetic */ + return marker; + + case M_SOS: /* should not see compressed data before SOF */ + ERREXIT("SOS without prior SOFn"); + break; + + case M_EOI: /* in case it's a tables-only JPEG stream */ + return marker; + + case M_COM: /* Existing COM: conditionally discard */ + if (keep_COM) { + write_marker(marker); + copy_variable(); + } else { + skip_variable(); + } + break; + + default: /* Anything else just gets copied */ + write_marker(marker); + copy_variable(); /* we assume it has a parameter count... */ + break; + } + } /* end loop */ +} + + +/* Command line parsing code */ + +static const char * progname; /* program name for error messages */ + + +static void +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "wrjpgcom inserts a textual comment in a JPEG file.\n"); + fprintf(stderr, "You can add to or replace any existing comment(s).\n"); + + fprintf(stderr, "Usage: %s [switches] ", progname); +#ifdef TWO_FILE_COMMANDLINE + fprintf(stderr, "inputfile outputfile\n"); +#else + fprintf(stderr, "[inputfile]\n"); +#endif + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -replace Delete any existing comments\n"); + fprintf(stderr, " -comment \"text\" Insert comment with given text\n"); + fprintf(stderr, " -cfile name Read comment from named file\n"); + fprintf(stderr, "Notice that you must put quotes around the comment text\n"); + fprintf(stderr, "when you use -comment.\n"); + fprintf(stderr, "If you do not give either -comment or -cfile on the command line,\n"); + fprintf(stderr, "then the comment text is read from standard input.\n"); + fprintf(stderr, "It can be multiple lines, up to %u characters total.\n", + (unsigned int) MAX_COM_LENGTH); +#ifndef TWO_FILE_COMMANDLINE + fprintf(stderr, "You must specify an input JPEG file name when supplying\n"); + fprintf(stderr, "comment text from standard input.\n"); +#endif + + exit(EXIT_FAILURE); +} + + +static int +keymatch (char * arg, const char * keyword, int minchars) +/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ +/* keyword is the constant keyword (must be lower case already), */ +/* minchars is length of minimum legal abbreviation. */ +{ + register int ca, ck; + register int nmatched = 0; + + while ((ca = *arg++) != '\0') { + if ((ck = *keyword++) == '\0') + return 0; /* arg longer than keyword, no good */ + if (isupper(ca)) /* force arg to lcase (assume ck is already) */ + ca = tolower(ca); + if (ca != ck) + return 0; /* no good */ + nmatched++; /* count matched characters */ + } + /* reached end of argument; fail if it's too short for unique abbrev */ + if (nmatched < minchars) + return 0; + return 1; /* A-OK */ +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + int argn; + char * arg; + int keep_COM = 1; + char * comment_arg = NULL; + FILE * comment_file = NULL; + unsigned int comment_length = 0; + int marker; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "wrjpgcom"; /* in case C library doesn't provide it */ + + /* Parse switches, if any */ + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (arg[0] != '-') + break; /* not switch, must be file name */ + arg++; /* advance over '-' */ + if (keymatch(arg, "replace", 1)) { + keep_COM = 0; + } else if (keymatch(arg, "cfile", 2)) { + if (++argn >= argc) usage(); + if ((comment_file = fopen(argv[argn], "r")) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); + exit(EXIT_FAILURE); + } + } else if (keymatch(arg, "comment", 1)) { + if (++argn >= argc) usage(); + comment_arg = argv[argn]; + /* If the comment text starts with '"', then we are probably running + * under MS-DOG and must parse out the quoted string ourselves. Sigh. + */ + if (comment_arg[0] == '"') { + comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); + if (comment_arg == NULL) + ERREXIT("Insufficient memory"); + strcpy(comment_arg, argv[argn]+1); + for (;;) { + comment_length = (unsigned int) strlen(comment_arg); + if (comment_length > 0 && comment_arg[comment_length-1] == '"') { + comment_arg[comment_length-1] = '\0'; /* zap terminating quote */ + break; + } + if (++argn >= argc) + ERREXIT("Missing ending quote mark"); + strcat(comment_arg, " "); + strcat(comment_arg, argv[argn]); + } + } + comment_length = (unsigned int) strlen(comment_arg); + } else + usage(); + } + + /* Cannot use both -comment and -cfile. */ + if (comment_arg != NULL && comment_file != NULL) + usage(); + /* If there is neither -comment nor -cfile, we will read the comment text + * from stdin; in this case there MUST be an input JPEG file name. + */ + if (comment_arg == NULL && comment_file == NULL && argn >= argc) + usage(); + + /* Open the input file. */ + if (argn < argc) { + if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdin), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open stdin\n", progname); + exit(EXIT_FAILURE); + } +#else + infile = stdin; +#endif + } + + /* Open the output file. */ +#ifdef TWO_FILE_COMMANDLINE + /* Must have explicit output file name */ + if (argn != argc-2) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + if ((outfile = fopen(argv[argn+1], WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn+1]); + exit(EXIT_FAILURE); + } +#else + /* Unix style: expect zero or one file name */ + if (argn < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } + /* default output file is stdout */ +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdout), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((outfile = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open stdout\n", progname); + exit(EXIT_FAILURE); + } +#else + outfile = stdout; +#endif +#endif /* TWO_FILE_COMMANDLINE */ + + /* Collect comment text from comment_file or stdin, if necessary */ + if (comment_arg == NULL) { + FILE * src_file; + int c; + + comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); + if (comment_arg == NULL) + ERREXIT("Insufficient memory"); + comment_length = 0; + src_file = (comment_file != NULL ? comment_file : stdin); + while ((c = getc(src_file)) != EOF) { + if (comment_length >= (unsigned int) MAX_COM_LENGTH) { + fprintf(stderr, "Comment text may not exceed %u bytes\n", + (unsigned int) MAX_COM_LENGTH); + exit(EXIT_FAILURE); + } + comment_arg[comment_length++] = (char) c; + } + if (comment_file != NULL) + fclose(comment_file); + } + + /* Copy JPEG headers until SOFn marker; + * we will insert the new comment marker just before SOFn. + * This (a) causes the new comment to appear after, rather than before, + * existing comments; and (b) ensures that comments come after any JFIF + * or JFXX markers, as required by the JFIF specification. + */ + marker = scan_JPEG_header(keep_COM); + /* Insert the new COM marker, but only if nonempty text has been supplied */ + if (comment_length > 0) { + write_marker(M_COM); + write_2_bytes(comment_length + 2); + while (comment_length > 0) { + write_1_byte(*comment_arg++); + comment_length--; + } + } + /* Duplicate the remainder of the source file. + * Note that any COM markers occuring after SOF will not be touched. + */ + write_marker(marker); + copy_rest_of_file(); + + /* All done. */ + exit(EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/src/dep/src/irrlicht/jpeglib/wrppm.c b/src/dep/src/irrlicht/jpeglib/wrppm.c index cfd4160..6c6d908 100644 --- a/src/dep/src/irrlicht/jpeglib/wrppm.c +++ b/src/dep/src/irrlicht/jpeglib/wrppm.c @@ -1,268 +1,268 @@ -/* - * wrppm.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in PPM/PGM format. - * The extended 2-byte-per-sample raw PPM/PGM formats are supported. - * The PBMPLUS library is NOT required to compile this software - * (but it is highly useful as a set of PPM image manipulation programs). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef PPM_SUPPORTED - - -/* - * For 12-bit JPEG data, we either downscale the values to 8 bits - * (to write standard byte-per-sample PPM/PGM files), or output - * nonstandard word-per-sample PPM/PGM files. Downscaling is done - * if PPM_NORAWWORD is defined (this can be done in the Makefile - * or in jconfig.h). - * (When the core library supports data precision reduction, a cleaner - * implementation will be to ask for that instead.) - */ - -#if BITS_IN_JSAMPLE == 8 -#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) (v) -#define BYTESPERSAMPLE 1 -#define PPM_MAXVAL 255 -#else -#ifdef PPM_NORAWWORD -#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) ((v) >> (BITS_IN_JSAMPLE-8)) -#define BYTESPERSAMPLE 1 -#define PPM_MAXVAL 255 -#else -/* The word-per-sample format always puts the LSB first. */ -#define PUTPPMSAMPLE(ptr,v) \ - { register int val_ = v; \ - *ptr++ = (char) (val_ & 0xFF); \ - *ptr++ = (char) ((val_ >> 8) & 0xFF); \ - } -#define BYTESPERSAMPLE 2 -#define PPM_MAXVAL ((1<pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * This code is used when we have to copy the data and apply a pixel - * format translation. Typically this only happens in 12-bit mode. - */ - -METHODDEF(void) -copy_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - register char * bufferptr; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = dest->pub.buffer[0]; - bufferptr = dest->iobuffer; - for (col = dest->samples_per_row; col > 0; col--) { - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(*ptr++)); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Write some pixel data when color quantization is in effect. - * We have to demap the color index values to straight data. - */ - -METHODDEF(void) -put_demapped_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - register char * bufferptr; - register int pixval; - register JSAMPROW ptr; - register JSAMPROW color_map0 = cinfo->colormap[0]; - register JSAMPROW color_map1 = cinfo->colormap[1]; - register JSAMPROW color_map2 = cinfo->colormap[2]; - register JDIMENSION col; - - ptr = dest->pub.buffer[0]; - bufferptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - pixval = GETJSAMPLE(*ptr++); - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map0[pixval])); - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map1[pixval])); - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map2[pixval])); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -METHODDEF(void) -put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - register char * bufferptr; - register JSAMPROW ptr; - register JSAMPROW color_map = cinfo->colormap[0]; - register JDIMENSION col; - - ptr = dest->pub.buffer[0]; - bufferptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map[GETJSAMPLE(*ptr++)])); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Startup: write the file header. - */ - -METHODDEF(void) -start_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - - /* Emit file header */ - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - /* emit header for raw PGM format */ - fprintf(dest->pub.output_file, "P5\n%ld %ld\n%d\n", - (long) cinfo->output_width, (long) cinfo->output_height, - PPM_MAXVAL); - break; - case JCS_RGB: - /* emit header for raw PPM format */ - fprintf(dest->pub.output_file, "P6\n%ld %ld\n%d\n", - (long) cinfo->output_width, (long) cinfo->output_height, - PPM_MAXVAL); - break; - default: - ERREXIT(cinfo, JERR_PPM_COLORSPACE); - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - /* Make sure we wrote the output file OK */ - fflush(dinfo->output_file); - if (ferror(dinfo->output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for PPM format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_ppm (j_decompress_ptr cinfo) -{ - ppm_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (ppm_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(ppm_dest_struct)); - dest->pub.start_output = start_output_ppm; - dest->pub.finish_output = finish_output_ppm; - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Create physical I/O buffer. Note we make this near on a PC. */ - dest->samples_per_row = cinfo->output_width * cinfo->out_color_components; - dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * SIZEOF(char)); - dest->iobuffer = (char *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width); - - if (cinfo->quantize_colors || BITS_IN_JSAMPLE != 8 || - SIZEOF(JSAMPLE) != SIZEOF(char)) { - /* When quantizing, we need an output buffer for colormap indexes - * that's separate from the physical I/O buffer. We also need a - * separate buffer if pixel format translation must take place. - */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->output_width * cinfo->output_components, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - if (! cinfo->quantize_colors) - dest->pub.put_pixel_rows = copy_pixel_rows; - else if (cinfo->out_color_space == JCS_GRAYSCALE) - dest->pub.put_pixel_rows = put_demapped_gray; - else - dest->pub.put_pixel_rows = put_demapped_rgb; - } else { - /* We will fwrite() directly from decompressor output buffer. */ - /* Synthesize a JSAMPARRAY pointer structure */ - /* Cast here implies near->far pointer conversion on PCs */ - dest->pixrow = (JSAMPROW) dest->iobuffer; - dest->pub.buffer = & dest->pixrow; - dest->pub.buffer_height = 1; - dest->pub.put_pixel_rows = put_pixel_rows; - } - - return (djpeg_dest_ptr) dest; -} - -#endif /* PPM_SUPPORTED */ +/* + * wrppm.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write output images in PPM/PGM format. + * The extended 2-byte-per-sample raw PPM/PGM formats are supported. + * The PBMPLUS library is NOT required to compile this software + * (but it is highly useful as a set of PPM image manipulation programs). + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef PPM_SUPPORTED + + +/* + * For 12-bit JPEG data, we either downscale the values to 8 bits + * (to write standard byte-per-sample PPM/PGM files), or output + * nonstandard word-per-sample PPM/PGM files. Downscaling is done + * if PPM_NORAWWORD is defined (this can be done in the Makefile + * or in jconfig.h). + * (When the core library supports data precision reduction, a cleaner + * implementation will be to ask for that instead.) + */ + +#if BITS_IN_JSAMPLE == 8 +#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) (v) +#define BYTESPERSAMPLE 1 +#define PPM_MAXVAL 255 +#else +#ifdef PPM_NORAWWORD +#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) ((v) >> (BITS_IN_JSAMPLE-8)) +#define BYTESPERSAMPLE 1 +#define PPM_MAXVAL 255 +#else +/* The word-per-sample format always puts the LSB first. */ +#define PUTPPMSAMPLE(ptr,v) \ + { register int val_ = v; \ + *ptr++ = (char) (val_ & 0xFF); \ + *ptr++ = (char) ((val_ >> 8) & 0xFF); \ + } +#define BYTESPERSAMPLE 2 +#define PPM_MAXVAL ((1<pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * This code is used when we have to copy the data and apply a pixel + * format translation. Typically this only happens in 12-bit mode. + */ + +METHODDEF(void) +copy_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; + register char * bufferptr; + register JSAMPROW ptr; + register JDIMENSION col; + + ptr = dest->pub.buffer[0]; + bufferptr = dest->iobuffer; + for (col = dest->samples_per_row; col > 0; col--) { + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(*ptr++)); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * Write some pixel data when color quantization is in effect. + * We have to demap the color index values to straight data. + */ + +METHODDEF(void) +put_demapped_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; + register char * bufferptr; + register int pixval; + register JSAMPROW ptr; + register JSAMPROW color_map0 = cinfo->colormap[0]; + register JSAMPROW color_map1 = cinfo->colormap[1]; + register JSAMPROW color_map2 = cinfo->colormap[2]; + register JDIMENSION col; + + ptr = dest->pub.buffer[0]; + bufferptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + pixval = GETJSAMPLE(*ptr++); + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map0[pixval])); + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map1[pixval])); + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map2[pixval])); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +METHODDEF(void) +put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; + register char * bufferptr; + register JSAMPROW ptr; + register JSAMPROW color_map = cinfo->colormap[0]; + register JDIMENSION col; + + ptr = dest->pub.buffer[0]; + bufferptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map[GETJSAMPLE(*ptr++)])); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * Startup: write the file header. + */ + +METHODDEF(void) +start_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; + + /* Emit file header */ + switch (cinfo->out_color_space) { + case JCS_GRAYSCALE: + /* emit header for raw PGM format */ + fprintf(dest->pub.output_file, "P5\n%ld %ld\n%d\n", + (long) cinfo->output_width, (long) cinfo->output_height, + PPM_MAXVAL); + break; + case JCS_RGB: + /* emit header for raw PPM format */ + fprintf(dest->pub.output_file, "P6\n%ld %ld\n%d\n", + (long) cinfo->output_width, (long) cinfo->output_height, + PPM_MAXVAL); + break; + default: + ERREXIT(cinfo, JERR_PPM_COLORSPACE); + } +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + /* Make sure we wrote the output file OK */ + fflush(dinfo->output_file); + if (ferror(dinfo->output_file)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for PPM format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_ppm (j_decompress_ptr cinfo) +{ + ppm_dest_ptr dest; + + /* Create module interface object, fill in method pointers */ + dest = (ppm_dest_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(ppm_dest_struct)); + dest->pub.start_output = start_output_ppm; + dest->pub.finish_output = finish_output_ppm; + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + /* Create physical I/O buffer. Note we make this near on a PC. */ + dest->samples_per_row = cinfo->output_width * cinfo->out_color_components; + dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * SIZEOF(char)); + dest->iobuffer = (char *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width); + + if (cinfo->quantize_colors || BITS_IN_JSAMPLE != 8 || + SIZEOF(JSAMPLE) != SIZEOF(char)) { + /* When quantizing, we need an output buffer for colormap indexes + * that's separate from the physical I/O buffer. We also need a + * separate buffer if pixel format translation must take place. + */ + dest->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->output_width * cinfo->output_components, (JDIMENSION) 1); + dest->pub.buffer_height = 1; + if (! cinfo->quantize_colors) + dest->pub.put_pixel_rows = copy_pixel_rows; + else if (cinfo->out_color_space == JCS_GRAYSCALE) + dest->pub.put_pixel_rows = put_demapped_gray; + else + dest->pub.put_pixel_rows = put_demapped_rgb; + } else { + /* We will fwrite() directly from decompressor output buffer. */ + /* Synthesize a JSAMPARRAY pointer structure */ + /* Cast here implies near->far pointer conversion on PCs */ + dest->pixrow = (JSAMPROW) dest->iobuffer; + dest->pub.buffer = & dest->pixrow; + dest->pub.buffer_height = 1; + dest->pub.put_pixel_rows = put_pixel_rows; + } + + return (djpeg_dest_ptr) dest; +} + +#endif /* PPM_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/wrrle.c b/src/dep/src/irrlicht/jpeglib/wrrle.c index 7a00c0d..a4e7337 100644 --- a/src/dep/src/irrlicht/jpeglib/wrrle.c +++ b/src/dep/src/irrlicht/jpeglib/wrrle.c @@ -1,305 +1,305 @@ -/* - * wrrle.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in RLE format. - * The Utah Raster Toolkit library is required (version 3.1 or later). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - * - * Based on code contributed by Mike Lijewski, - * with updates from Robert Hutchinson. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef RLE_SUPPORTED - -/* rle.h is provided by the Utah Raster Toolkit. */ - -#include - -/* - * We assume that JSAMPLE has the same representation as rle_pixel, - * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - - -/* - * Since RLE stores scanlines bottom-to-top, we have to invert the image - * from JPEG's top-to-bottom order. To do this, we save the outgoing data - * in a virtual array during put_pixel_row calls, then actually emit the - * RLE file during finish_output. - */ - - -/* - * For now, if we emit an RLE color map then it is always 256 entries long, - * though not all of the entries need be used. - */ - -#define CMAPBITS 8 -#define CMAPLENGTH (1<<(CMAPBITS)) - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - jvirt_sarray_ptr image; /* virtual array to store the output image */ - rle_map *colormap; /* RLE-style color map, or NULL if none */ - rle_pixel **rle_row; /* To pass rows to rle_putrow() */ - -} rle_dest_struct; - -typedef rle_dest_struct * rle_dest_ptr; - -/* Forward declarations */ -METHODDEF(void) rle_put_pixel_rows - JPP((j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied)); - - -/* - * Write the file header. - * - * In this module it's easier to wait till finish_output to write anything. - */ - -METHODDEF(void) -start_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - rle_dest_ptr dest = (rle_dest_ptr) dinfo; - size_t cmapsize; - int i, ci; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - /* - * Make sure the image can be stored in RLE format. - * - * - RLE stores image dimensions as *signed* 16 bit integers. JPEG - * uses unsigned, so we have to check the width. - * - * - Colorspace is expected to be grayscale or RGB. - * - * - The number of channels (components) is expected to be 1 (grayscale/ - * pseudocolor) or 3 (truecolor/directcolor). - * (could be 2 or 4 if using an alpha channel, but we aren't) - */ - - if (cinfo->output_width > 32767 || cinfo->output_height > 32767) - ERREXIT2(cinfo, JERR_RLE_DIMENSIONS, cinfo->output_width, - cinfo->output_height); - - if (cinfo->out_color_space != JCS_GRAYSCALE && - cinfo->out_color_space != JCS_RGB) - ERREXIT(cinfo, JERR_RLE_COLORSPACE); - - if (cinfo->output_components != 1 && cinfo->output_components != 3) - ERREXIT1(cinfo, JERR_RLE_TOOMANYCHANNELS, cinfo->num_components); - - /* Convert colormap, if any, to RLE format. */ - - dest->colormap = NULL; - - if (cinfo->quantize_colors) { - /* Allocate storage for RLE-style cmap, zero any extra entries */ - cmapsize = cinfo->out_color_components * CMAPLENGTH * SIZEOF(rle_map); - dest->colormap = (rle_map *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, cmapsize); - MEMZERO(dest->colormap, cmapsize); - - /* Save away data in RLE format --- note 8-bit left shift! */ - /* Shifting would need adjustment for JSAMPLEs wider than 8 bits. */ - for (ci = 0; ci < cinfo->out_color_components; ci++) { - for (i = 0; i < cinfo->actual_number_of_colors; i++) { - dest->colormap[ci * CMAPLENGTH + i] = - GETJSAMPLE(cinfo->colormap[ci][i]) << 8; - } - } - } - - /* Set the output buffer to the first row */ - dest->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, (JDIMENSION) 0, (JDIMENSION) 1, TRUE); - dest->pub.buffer_height = 1; - - dest->pub.put_pixel_rows = rle_put_pixel_rows; - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->total_extra_passes++; /* count file writing as separate pass */ - } -#endif -} - - -/* - * Write some pixel data. - * - * This routine just saves the data away in a virtual array. - */ - -METHODDEF(void) -rle_put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - rle_dest_ptr dest = (rle_dest_ptr) dinfo; - - if (cinfo->output_scanline < cinfo->output_height) { - dest->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, - cinfo->output_scanline, (JDIMENSION) 1, TRUE); - } -} - -/* - * Finish up at the end of the file. - * - * Here is where we really output the RLE file. - */ - -METHODDEF(void) -finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - rle_dest_ptr dest = (rle_dest_ptr) dinfo; - rle_hdr header; /* Output file information */ - rle_pixel **rle_row, *red, *green, *blue; - JSAMPROW output_row; - char cmapcomment[80]; - int row, col; - int ci; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - /* Initialize the header info */ - header = *rle_hdr_init(NULL); - header.rle_file = dest->pub.output_file; - header.xmin = 0; - header.xmax = cinfo->output_width - 1; - header.ymin = 0; - header.ymax = cinfo->output_height - 1; - header.alpha = 0; - header.ncolors = cinfo->output_components; - for (ci = 0; ci < cinfo->output_components; ci++) { - RLE_SET_BIT(header, ci); - } - if (cinfo->quantize_colors) { - header.ncmap = cinfo->out_color_components; - header.cmaplen = CMAPBITS; - header.cmap = dest->colormap; - /* Add a comment to the output image with the true colormap length. */ - sprintf(cmapcomment, "color_map_length=%d", cinfo->actual_number_of_colors); - rle_putcom(cmapcomment, &header); - } - - /* Emit the RLE header and color map (if any) */ - rle_put_setup(&header); - - /* Now output the RLE data from our virtual array. - * We assume here that (a) rle_pixel is represented the same as JSAMPLE, - * and (b) we are not on a machine where FAR pointers differ from regular. - */ - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_limit = cinfo->output_height; - progress->pub.pass_counter = 0; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - - if (cinfo->output_components == 1) { - for (row = cinfo->output_height-1; row >= 0; row--) { - rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, - (JDIMENSION) row, (JDIMENSION) 1, FALSE); - rle_putrow(rle_row, (int) cinfo->output_width, &header); -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - } else { - for (row = cinfo->output_height-1; row >= 0; row--) { - rle_row = (rle_pixel **) dest->rle_row; - output_row = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, - (JDIMENSION) row, (JDIMENSION) 1, FALSE); - red = rle_row[0]; - green = rle_row[1]; - blue = rle_row[2]; - for (col = cinfo->output_width; col > 0; col--) { - *red++ = GETJSAMPLE(*output_row++); - *green++ = GETJSAMPLE(*output_row++); - *blue++ = GETJSAMPLE(*output_row++); - } - rle_putrow(rle_row, (int) cinfo->output_width, &header); -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) - progress->completed_extra_passes++; -#endif - - /* Emit file trailer */ - rle_puteof(&header); - fflush(dest->pub.output_file); - if (ferror(dest->pub.output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for RLE format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_rle (j_decompress_ptr cinfo) -{ - rle_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (rle_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(rle_dest_struct)); - dest->pub.start_output = start_output_rle; - dest->pub.finish_output = finish_output_rle; - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Allocate a work array for output to the RLE library. */ - dest->rle_row = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->output_width, (JDIMENSION) cinfo->output_components); - - /* Allocate a virtual array to hold the image. */ - dest->image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) (cinfo->output_width * cinfo->output_components), - cinfo->output_height, (JDIMENSION) 1); - - return (djpeg_dest_ptr) dest; -} - -#endif /* RLE_SUPPORTED */ +/* + * wrrle.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write output images in RLE format. + * The Utah Raster Toolkit library is required (version 3.1 or later). + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + * + * Based on code contributed by Mike Lijewski, + * with updates from Robert Hutchinson. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef RLE_SUPPORTED + +/* rle.h is provided by the Utah Raster Toolkit. */ + +#include + +/* + * We assume that JSAMPLE has the same representation as rle_pixel, + * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. + */ + +#if BITS_IN_JSAMPLE != 8 + Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ +#endif + + +/* + * Since RLE stores scanlines bottom-to-top, we have to invert the image + * from JPEG's top-to-bottom order. To do this, we save the outgoing data + * in a virtual array during put_pixel_row calls, then actually emit the + * RLE file during finish_output. + */ + + +/* + * For now, if we emit an RLE color map then it is always 256 entries long, + * though not all of the entries need be used. + */ + +#define CMAPBITS 8 +#define CMAPLENGTH (1<<(CMAPBITS)) + +typedef struct { + struct djpeg_dest_struct pub; /* public fields */ + + jvirt_sarray_ptr image; /* virtual array to store the output image */ + rle_map *colormap; /* RLE-style color map, or NULL if none */ + rle_pixel **rle_row; /* To pass rows to rle_putrow() */ + +} rle_dest_struct; + +typedef rle_dest_struct * rle_dest_ptr; + +/* Forward declarations */ +METHODDEF(void) rle_put_pixel_rows + JPP((j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied)); + + +/* + * Write the file header. + * + * In this module it's easier to wait till finish_output to write anything. + */ + +METHODDEF(void) +start_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + rle_dest_ptr dest = (rle_dest_ptr) dinfo; + size_t cmapsize; + int i, ci; +#ifdef PROGRESS_REPORT + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; +#endif + + /* + * Make sure the image can be stored in RLE format. + * + * - RLE stores image dimensions as *signed* 16 bit integers. JPEG + * uses unsigned, so we have to check the width. + * + * - Colorspace is expected to be grayscale or RGB. + * + * - The number of channels (components) is expected to be 1 (grayscale/ + * pseudocolor) or 3 (truecolor/directcolor). + * (could be 2 or 4 if using an alpha channel, but we aren't) + */ + + if (cinfo->output_width > 32767 || cinfo->output_height > 32767) + ERREXIT2(cinfo, JERR_RLE_DIMENSIONS, cinfo->output_width, + cinfo->output_height); + + if (cinfo->out_color_space != JCS_GRAYSCALE && + cinfo->out_color_space != JCS_RGB) + ERREXIT(cinfo, JERR_RLE_COLORSPACE); + + if (cinfo->output_components != 1 && cinfo->output_components != 3) + ERREXIT1(cinfo, JERR_RLE_TOOMANYCHANNELS, cinfo->num_components); + + /* Convert colormap, if any, to RLE format. */ + + dest->colormap = NULL; + + if (cinfo->quantize_colors) { + /* Allocate storage for RLE-style cmap, zero any extra entries */ + cmapsize = cinfo->out_color_components * CMAPLENGTH * SIZEOF(rle_map); + dest->colormap = (rle_map *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, cmapsize); + MEMZERO(dest->colormap, cmapsize); + + /* Save away data in RLE format --- note 8-bit left shift! */ + /* Shifting would need adjustment for JSAMPLEs wider than 8 bits. */ + for (ci = 0; ci < cinfo->out_color_components; ci++) { + for (i = 0; i < cinfo->actual_number_of_colors; i++) { + dest->colormap[ci * CMAPLENGTH + i] = + GETJSAMPLE(cinfo->colormap[ci][i]) << 8; + } + } + } + + /* Set the output buffer to the first row */ + dest->pub.buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->image, (JDIMENSION) 0, (JDIMENSION) 1, TRUE); + dest->pub.buffer_height = 1; + + dest->pub.put_pixel_rows = rle_put_pixel_rows; + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->total_extra_passes++; /* count file writing as separate pass */ + } +#endif +} + + +/* + * Write some pixel data. + * + * This routine just saves the data away in a virtual array. + */ + +METHODDEF(void) +rle_put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + rle_dest_ptr dest = (rle_dest_ptr) dinfo; + + if (cinfo->output_scanline < cinfo->output_height) { + dest->pub.buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->image, + cinfo->output_scanline, (JDIMENSION) 1, TRUE); + } +} + +/* + * Finish up at the end of the file. + * + * Here is where we really output the RLE file. + */ + +METHODDEF(void) +finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + rle_dest_ptr dest = (rle_dest_ptr) dinfo; + rle_hdr header; /* Output file information */ + rle_pixel **rle_row, *red, *green, *blue; + JSAMPROW output_row; + char cmapcomment[80]; + int row, col; + int ci; +#ifdef PROGRESS_REPORT + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; +#endif + + /* Initialize the header info */ + header = *rle_hdr_init(NULL); + header.rle_file = dest->pub.output_file; + header.xmin = 0; + header.xmax = cinfo->output_width - 1; + header.ymin = 0; + header.ymax = cinfo->output_height - 1; + header.alpha = 0; + header.ncolors = cinfo->output_components; + for (ci = 0; ci < cinfo->output_components; ci++) { + RLE_SET_BIT(header, ci); + } + if (cinfo->quantize_colors) { + header.ncmap = cinfo->out_color_components; + header.cmaplen = CMAPBITS; + header.cmap = dest->colormap; + /* Add a comment to the output image with the true colormap length. */ + sprintf(cmapcomment, "color_map_length=%d", cinfo->actual_number_of_colors); + rle_putcom(cmapcomment, &header); + } + + /* Emit the RLE header and color map (if any) */ + rle_put_setup(&header); + + /* Now output the RLE data from our virtual array. + * We assume here that (a) rle_pixel is represented the same as JSAMPLE, + * and (b) we are not on a machine where FAR pointers differ from regular. + */ + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_limit = cinfo->output_height; + progress->pub.pass_counter = 0; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + + if (cinfo->output_components == 1) { + for (row = cinfo->output_height-1; row >= 0; row--) { + rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->image, + (JDIMENSION) row, (JDIMENSION) 1, FALSE); + rle_putrow(rle_row, (int) cinfo->output_width, &header); +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + } else { + for (row = cinfo->output_height-1; row >= 0; row--) { + rle_row = (rle_pixel **) dest->rle_row; + output_row = * (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->image, + (JDIMENSION) row, (JDIMENSION) 1, FALSE); + red = rle_row[0]; + green = rle_row[1]; + blue = rle_row[2]; + for (col = cinfo->output_width; col > 0; col--) { + *red++ = GETJSAMPLE(*output_row++); + *green++ = GETJSAMPLE(*output_row++); + *blue++ = GETJSAMPLE(*output_row++); + } + rle_putrow(rle_row, (int) cinfo->output_width, &header); +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + } + +#ifdef PROGRESS_REPORT + if (progress != NULL) + progress->completed_extra_passes++; +#endif + + /* Emit file trailer */ + rle_puteof(&header); + fflush(dest->pub.output_file); + if (ferror(dest->pub.output_file)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for RLE format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_rle (j_decompress_ptr cinfo) +{ + rle_dest_ptr dest; + + /* Create module interface object, fill in method pointers */ + dest = (rle_dest_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(rle_dest_struct)); + dest->pub.start_output = start_output_rle; + dest->pub.finish_output = finish_output_rle; + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + /* Allocate a work array for output to the RLE library. */ + dest->rle_row = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->output_width, (JDIMENSION) cinfo->output_components); + + /* Allocate a virtual array to hold the image. */ + dest->image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) (cinfo->output_width * cinfo->output_components), + cinfo->output_height, (JDIMENSION) 1); + + return (djpeg_dest_ptr) dest; +} + +#endif /* RLE_SUPPORTED */ diff --git a/src/dep/src/irrlicht/jpeglib/wrtarga.c b/src/dep/src/irrlicht/jpeglib/wrtarga.c index 6566273..cf104d2 100644 --- a/src/dep/src/irrlicht/jpeglib/wrtarga.c +++ b/src/dep/src/irrlicht/jpeglib/wrtarga.c @@ -1,253 +1,253 @@ -/* - * wrtarga.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in Targa format. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - * - * Based on code contributed by Lee Daniel Crocker. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef TARGA_SUPPORTED - - -/* - * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. - * This is not yet implemented. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - -/* - * The output buffer needs to be writable by fwrite(). On PCs, we must - * allocate the buffer in near data space, because we are assuming small-data - * memory model, wherein fwrite() can't reach far memory. If you need to - * process very wide images on a PC, you might have to compile in large-memory - * model, or else replace fwrite() with a putc() loop --- which will be much - * slower. - */ - - -/* Private version of data destination object */ - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - char *iobuffer; /* physical I/O buffer */ - JDIMENSION buffer_width; /* width of one row */ -} tga_dest_struct; - -typedef tga_dest_struct * tga_dest_ptr; - - -LOCAL(void) -write_header (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors) -/* Create and write a Targa header */ -{ - char targaheader[18]; - - /* Set unused fields of header to 0 */ - MEMZERO(targaheader, SIZEOF(targaheader)); - - if (num_colors > 0) { - targaheader[1] = 1; /* color map type 1 */ - targaheader[5] = (char) (num_colors & 0xFF); - targaheader[6] = (char) (num_colors >> 8); - targaheader[7] = 24; /* 24 bits per cmap entry */ - } - - targaheader[12] = (char) (cinfo->output_width & 0xFF); - targaheader[13] = (char) (cinfo->output_width >> 8); - targaheader[14] = (char) (cinfo->output_height & 0xFF); - targaheader[15] = (char) (cinfo->output_height >> 8); - targaheader[17] = 0x20; /* Top-down, non-interlaced */ - - if (cinfo->out_color_space == JCS_GRAYSCALE) { - targaheader[2] = 3; /* image type = uncompressed gray-scale */ - targaheader[16] = 8; /* bits per pixel */ - } else { /* must be RGB */ - if (num_colors > 0) { - targaheader[2] = 1; /* image type = colormapped RGB */ - targaheader[16] = 8; - } else { - targaheader[2] = 2; /* image type = uncompressed RGB */ - targaheader[16] = 24; - } - } - - if (JFWRITE(dinfo->output_file, targaheader, 18) != (size_t) 18) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * Write some pixel data. - * In this module rows_supplied will always be 1. - */ - -METHODDEF(void) -put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* used for unquantized full-color output */ -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - register JSAMPROW inptr; - register char * outptr; - register JDIMENSION col; - - inptr = dest->pub.buffer[0]; - outptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - outptr[0] = (char) GETJSAMPLE(inptr[2]); /* RGB to BGR order */ - outptr[1] = (char) GETJSAMPLE(inptr[1]); - outptr[2] = (char) GETJSAMPLE(inptr[0]); - inptr += 3, outptr += 3; - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - -METHODDEF(void) -put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* used for grayscale OR quantized color output */ -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - register JSAMPROW inptr; - register char * outptr; - register JDIMENSION col; - - inptr = dest->pub.buffer[0]; - outptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - *outptr++ = (char) GETJSAMPLE(*inptr++); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Write some demapped pixel data when color quantization is in effect. - * For Targa, this is only applied to grayscale data. - */ - -METHODDEF(void) -put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - register JSAMPROW inptr; - register char * outptr; - register JSAMPROW color_map0 = cinfo->colormap[0]; - register JDIMENSION col; - - inptr = dest->pub.buffer[0]; - outptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - *outptr++ = (char) GETJSAMPLE(color_map0[GETJSAMPLE(*inptr++)]); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Startup: write the file header. - */ - -METHODDEF(void) -start_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - int num_colors, i; - FILE *outfile; - - if (cinfo->out_color_space == JCS_GRAYSCALE) { - /* Targa doesn't have a mapped grayscale format, so we will */ - /* demap quantized gray output. Never emit a colormap. */ - write_header(cinfo, dinfo, 0); - if (cinfo->quantize_colors) - dest->pub.put_pixel_rows = put_demapped_gray; - else - dest->pub.put_pixel_rows = put_gray_rows; - } else if (cinfo->out_color_space == JCS_RGB) { - if (cinfo->quantize_colors) { - /* We only support 8-bit colormap indexes, so only 256 colors */ - num_colors = cinfo->actual_number_of_colors; - if (num_colors > 256) - ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, num_colors); - write_header(cinfo, dinfo, num_colors); - /* Write the colormap. Note Targa uses BGR byte order */ - outfile = dest->pub.output_file; - for (i = 0; i < num_colors; i++) { - putc(GETJSAMPLE(cinfo->colormap[2][i]), outfile); - putc(GETJSAMPLE(cinfo->colormap[1][i]), outfile); - putc(GETJSAMPLE(cinfo->colormap[0][i]), outfile); - } - dest->pub.put_pixel_rows = put_gray_rows; - } else { - write_header(cinfo, dinfo, 0); - dest->pub.put_pixel_rows = put_pixel_rows; - } - } else { - ERREXIT(cinfo, JERR_TGA_COLORSPACE); - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - /* Make sure we wrote the output file OK */ - fflush(dinfo->output_file); - if (ferror(dinfo->output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for Targa format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_targa (j_decompress_ptr cinfo) -{ - tga_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (tga_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(tga_dest_struct)); - dest->pub.start_output = start_output_tga; - dest->pub.finish_output = finish_output_tga; - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Create I/O buffer. Note we make this near on a PC. */ - dest->buffer_width = cinfo->output_width * cinfo->output_components; - dest->iobuffer = (char *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) (dest->buffer_width * SIZEOF(char))); - - /* Create decompressor output buffer. */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - - return (djpeg_dest_ptr) dest; -} - -#endif /* TARGA_SUPPORTED */ +/* + * wrtarga.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write output images in Targa format. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + * + * Based on code contributed by Lee Daniel Crocker. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef TARGA_SUPPORTED + + +/* + * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. + * This is not yet implemented. + */ + +#if BITS_IN_JSAMPLE != 8 + Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ +#endif + +/* + * The output buffer needs to be writable by fwrite(). On PCs, we must + * allocate the buffer in near data space, because we are assuming small-data + * memory model, wherein fwrite() can't reach far memory. If you need to + * process very wide images on a PC, you might have to compile in large-memory + * model, or else replace fwrite() with a putc() loop --- which will be much + * slower. + */ + + +/* Private version of data destination object */ + +typedef struct { + struct djpeg_dest_struct pub; /* public fields */ + + char *iobuffer; /* physical I/O buffer */ + JDIMENSION buffer_width; /* width of one row */ +} tga_dest_struct; + +typedef tga_dest_struct * tga_dest_ptr; + + +LOCAL(void) +write_header (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors) +/* Create and write a Targa header */ +{ + char targaheader[18]; + + /* Set unused fields of header to 0 */ + MEMZERO(targaheader, SIZEOF(targaheader)); + + if (num_colors > 0) { + targaheader[1] = 1; /* color map type 1 */ + targaheader[5] = (char) (num_colors & 0xFF); + targaheader[6] = (char) (num_colors >> 8); + targaheader[7] = 24; /* 24 bits per cmap entry */ + } + + targaheader[12] = (char) (cinfo->output_width & 0xFF); + targaheader[13] = (char) (cinfo->output_width >> 8); + targaheader[14] = (char) (cinfo->output_height & 0xFF); + targaheader[15] = (char) (cinfo->output_height >> 8); + targaheader[17] = 0x20; /* Top-down, non-interlaced */ + + if (cinfo->out_color_space == JCS_GRAYSCALE) { + targaheader[2] = 3; /* image type = uncompressed gray-scale */ + targaheader[16] = 8; /* bits per pixel */ + } else { /* must be RGB */ + if (num_colors > 0) { + targaheader[2] = 1; /* image type = colormapped RGB */ + targaheader[16] = 8; + } else { + targaheader[2] = 2; /* image type = uncompressed RGB */ + targaheader[16] = 24; + } + } + + if (JFWRITE(dinfo->output_file, targaheader, 18) != (size_t) 18) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * Write some pixel data. + * In this module rows_supplied will always be 1. + */ + +METHODDEF(void) +put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +/* used for unquantized full-color output */ +{ + tga_dest_ptr dest = (tga_dest_ptr) dinfo; + register JSAMPROW inptr; + register char * outptr; + register JDIMENSION col; + + inptr = dest->pub.buffer[0]; + outptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + outptr[0] = (char) GETJSAMPLE(inptr[2]); /* RGB to BGR order */ + outptr[1] = (char) GETJSAMPLE(inptr[1]); + outptr[2] = (char) GETJSAMPLE(inptr[0]); + inptr += 3, outptr += 3; + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + +METHODDEF(void) +put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +/* used for grayscale OR quantized color output */ +{ + tga_dest_ptr dest = (tga_dest_ptr) dinfo; + register JSAMPROW inptr; + register char * outptr; + register JDIMENSION col; + + inptr = dest->pub.buffer[0]; + outptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + *outptr++ = (char) GETJSAMPLE(*inptr++); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * Write some demapped pixel data when color quantization is in effect. + * For Targa, this is only applied to grayscale data. + */ + +METHODDEF(void) +put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + tga_dest_ptr dest = (tga_dest_ptr) dinfo; + register JSAMPROW inptr; + register char * outptr; + register JSAMPROW color_map0 = cinfo->colormap[0]; + register JDIMENSION col; + + inptr = dest->pub.buffer[0]; + outptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + *outptr++ = (char) GETJSAMPLE(color_map0[GETJSAMPLE(*inptr++)]); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * Startup: write the file header. + */ + +METHODDEF(void) +start_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + tga_dest_ptr dest = (tga_dest_ptr) dinfo; + int num_colors, i; + FILE *outfile; + + if (cinfo->out_color_space == JCS_GRAYSCALE) { + /* Targa doesn't have a mapped grayscale format, so we will */ + /* demap quantized gray output. Never emit a colormap. */ + write_header(cinfo, dinfo, 0); + if (cinfo->quantize_colors) + dest->pub.put_pixel_rows = put_demapped_gray; + else + dest->pub.put_pixel_rows = put_gray_rows; + } else if (cinfo->out_color_space == JCS_RGB) { + if (cinfo->quantize_colors) { + /* We only support 8-bit colormap indexes, so only 256 colors */ + num_colors = cinfo->actual_number_of_colors; + if (num_colors > 256) + ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, num_colors); + write_header(cinfo, dinfo, num_colors); + /* Write the colormap. Note Targa uses BGR byte order */ + outfile = dest->pub.output_file; + for (i = 0; i < num_colors; i++) { + putc(GETJSAMPLE(cinfo->colormap[2][i]), outfile); + putc(GETJSAMPLE(cinfo->colormap[1][i]), outfile); + putc(GETJSAMPLE(cinfo->colormap[0][i]), outfile); + } + dest->pub.put_pixel_rows = put_gray_rows; + } else { + write_header(cinfo, dinfo, 0); + dest->pub.put_pixel_rows = put_pixel_rows; + } + } else { + ERREXIT(cinfo, JERR_TGA_COLORSPACE); + } +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + /* Make sure we wrote the output file OK */ + fflush(dinfo->output_file); + if (ferror(dinfo->output_file)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for Targa format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_targa (j_decompress_ptr cinfo) +{ + tga_dest_ptr dest; + + /* Create module interface object, fill in method pointers */ + dest = (tga_dest_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(tga_dest_struct)); + dest->pub.start_output = start_output_tga; + dest->pub.finish_output = finish_output_tga; + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + /* Create I/O buffer. Note we make this near on a PC. */ + dest->buffer_width = cinfo->output_width * cinfo->output_components; + dest->iobuffer = (char *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (size_t) (dest->buffer_width * SIZEOF(char))); + + /* Create decompressor output buffer. */ + dest->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width, (JDIMENSION) 1); + dest->pub.buffer_height = 1; + + return (djpeg_dest_ptr) dest; +} + +#endif /* TARGA_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/ANNOUNCE b/src/dep/src/irrlicht/libpng/ANNOUNCE index f4a5b23..c0b8188 100644 --- a/src/dep/src/irrlicht/libpng/ANNOUNCE +++ b/src/dep/src/irrlicht/libpng/ANNOUNCE @@ -1,50 +1,50 @@ - -Libpng 1.2.16 - January 31, 2007 - -This is a public release of libpng, intended for use in production codes. - -Files available for download: - -Source files with LF line endings (for Unix/Linux) and with a -"configure" script - - libpng-1.2.16.tar.gz - libpng-1.2.16.tar.bz2 - -Source files with LF line endings (for Unix/Linux) without the -"configure" script - - libpng-1.2.16-no-config.tar.gz - libpng-1.2.16-no-config.tar.bz2 - -Source files with CRLF line endings (for Windows), without the -"configure" script - - lpng1216.zip - lpng1216.tar.bz2 - -Project files - - libpng-1.2.16-project-netware.zip - libpng-1.2.16-project-wince.zip - -Other information: - - libpng-1.2.16-README.txt - libpng-1.2.16-KNOWNBUGS.txt - libpng-1.2.16-LICENSE.txt - libpng-1.2.16-Y2K-compliance.txt - -Changes since the last public release (1.2.15): - -version 1.2.16 [January 31, 2007] - - Fix bugs in makefile.nommx - Revised scripts/CMakeLists.txt - -Send comments/corrections/commendations to png-mng-implement at lists.sf.net -(subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe) or to glennrp at users.sourceforge.net - -Glenn R-P + +Libpng 1.2.16 - January 31, 2007 + +This is a public release of libpng, intended for use in production codes. + +Files available for download: + +Source files with LF line endings (for Unix/Linux) and with a +"configure" script + + libpng-1.2.16.tar.gz + libpng-1.2.16.tar.bz2 + +Source files with LF line endings (for Unix/Linux) without the +"configure" script + + libpng-1.2.16-no-config.tar.gz + libpng-1.2.16-no-config.tar.bz2 + +Source files with CRLF line endings (for Windows), without the +"configure" script + + lpng1216.zip + lpng1216.tar.bz2 + +Project files + + libpng-1.2.16-project-netware.zip + libpng-1.2.16-project-wince.zip + +Other information: + + libpng-1.2.16-README.txt + libpng-1.2.16-KNOWNBUGS.txt + libpng-1.2.16-LICENSE.txt + libpng-1.2.16-Y2K-compliance.txt + +Changes since the last public release (1.2.15): + +version 1.2.16 [January 31, 2007] + + Fix bugs in makefile.nommx + Revised scripts/CMakeLists.txt + +Send comments/corrections/commendations to png-mng-implement at lists.sf.net +(subscription required; visit +https://lists.sourceforge.net/lists/listinfo/png-mng-implement +to subscribe) or to glennrp at users.sourceforge.net + +Glenn R-P diff --git a/src/dep/src/irrlicht/libpng/CHANGES b/src/dep/src/irrlicht/libpng/CHANGES index 2b389c5..8c8abcc 100644 --- a/src/dep/src/irrlicht/libpng/CHANGES +++ b/src/dep/src/irrlicht/libpng/CHANGES @@ -1,1698 +1,1698 @@ - -CHANGES - changes for libpng - -version 0.2 - added reader into png.h - fixed small problems in stub file - -version 0.3 - added pull reader - split up pngwrite.c to several files - added pnglib.txt - added example.c - cleaned up writer, adding a few new transformations - fixed some bugs in writer - interfaced with zlib 0.5 - added K&R support - added check for 64 KB blocks for 16 bit machines - -version 0.4 - cleaned up code and commented code - simplified time handling into png_time - created png_color_16 and png_color_8 to handle color needs - cleaned up color type defines - fixed various bugs - made various names more consistent - interfaced with zlib 0.71 - cleaned up zTXt reader and writer (using zlib's Reset functions) - split transformations into pngrtran.c and pngwtran.c - -version 0.5 - interfaced with zlib 0.8 - fixed many reading and writing bugs - saved using 3 spaces instead of tabs - -version 0.6 - added png_large_malloc() and png_large_free() - added png_size_t - cleaned up some compiler warnings - added png_start_read_image() - -version 0.7 - cleaned up lots of bugs - finished dithering and other stuff - added test program - changed name from pnglib to libpng - -version 0.71 [June, 1995] - changed pngtest.png for zlib 0.93 - fixed error in libpng.txt and example.c - -version 0.8 - cleaned up some bugs - added png_set_filler() - split up pngstub.c into pngmem.c, pngio.c, and pngerror.c - added #define's to remove unwanted code - moved png_info_init() to png.c - added old_size into png_realloc() - added functions to manually set filtering and compression info - changed compression parameters based on image type - optimized filter selection code - added version info - changed external functions passing floats to doubles (k&r problems?) - put all the configurable stuff in pngconf.h - enabled png_set_shift to work with paletted images on read - added png_read_update_info() - updates info structure with - transformations - -version 0.81 [August, 1995] - incorporated Tim Wegner's medium model code (thanks, Tim) - -version 0.82 [September, 1995] - [unspecified changes] - -version 0.85 [December, 1995] - added more medium model code (almost everything's a far) - added i/o, error, and memory callback functions - fixed some bugs (16 bit, 4 bit interlaced, etc.) - added first run progressive reader (barely tested) - -version 0.86 [January, 1996] - fixed bugs - improved documentation - -version 0.87 [January, 1996] - fixed medium model bugs - fixed other bugs introduced in 0.85 and 0.86 - added some minor documentation - -version 0.88 [January, 1996] - fixed progressive bugs - replaced tabs with spaces - cleaned up documentation - added callbacks for read/write and warning/error functions - -version 0.89 [July, 1996] - added new initialization API to make libpng work better with shared libs - we now have png_create_read_struct(), png_create_write_struct(), - png_create_info_struct(), png_destroy_read_struct(), and - png_destroy_write_struct() instead of the separate calls to - malloc and png_read_init(), png_info_init(), and png_write_init() - changed warning/error callback functions to fix bug - this means you - should use the new initialization API if you were using the old - png_set_message_fn() calls, and that the old API no longer exists - so that people are aware that they need to change their code - changed filter selection API to allow selection of multiple filters - since it didn't work in previous versions of libpng anyways - optimized filter selection code - fixed png_set_background() to allow using an arbitrary RGB color for - paletted images - fixed gamma and background correction for paletted images, so - png_correct_palette is not needed unless you are correcting an - external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED - in pngconf.h) - if nobody uses this, it may disappear in the future. - fixed bug with Borland 64K memory allocation (Alexander Lehmann) - fixed bug in interlace handling (Smarasderagd, I think) - added more error checking for writing and image to reduce invalid files - separated read and write functions so that they won't both be linked - into a binary when only reading or writing functionality is used - new pngtest image also has interlacing and zTXt - updated documentation to reflect new API - -version 0.90 [January, 1997] - made CRC errors/warnings on critical and ancillary chunks configurable - libpng will use the zlib CRC routines by (compile-time) default - changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner) - added external C++ wrapper statements to png.h (Gilles Dauphin) - allow PNG file to be read when some or all of file signature has already - been read from the beginning of the stream. ****This affects the size - of info_struct and invalidates all programs that use a shared libpng**** - fixed png_filler() declarations - fixed? background color conversions - fixed order of error function pointers to match documentation - current chunk name is now available in png_struct to reduce the number - of nearly identical error messages (will simplify multi-lingual - support when available) - try to get ready for unknown-chunk callback functions: - - previously read critical chunks are flagged, so the chunk handling - routines can determine if the chunk is in the right place - - all chunk handling routines have the same prototypes, so we will - be able to handle all chunks via a callback mechanism - try to fix Linux "setjmp" buffer size problems - removed png_large_malloc, png_large_free, and png_realloc functions. - -version 0.95 [March, 1997] - fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never - fixed bug in PNG file signature compares when start != 0 - changed parameter type of png_set_filler(...filler...) from png_byte - to png_uint_32 - added test for MACOS to ensure that both math.h and fp.h are not #included - added macros for libpng to be compiled as a Windows DLL (Andreas Kupries) - added "packswap" transformation, which changes the endianness of - packed-pixel bytes (Kevin Bracey) - added "strip_alpha" transformation, which removes the alpha channel of - input images without using it (not necessarily a good idea) - added "swap_alpha" transformation, which puts the alpha channel in front - of the color bytes instead of after - removed all implicit variable tests which assume NULL == 0 (I think) - changed several variables to "png_size_t" to show 16/32-bit limitations - added new pCAL chunk read/write support - added experimental filter selection weighting (Greg Roelofs) - removed old png_set_rgbx() and png_set_xrgb() functions that have been - obsolete for about 2 years now (use png_set_filler() instead) - added macros to read 16- and 32-bit ints directly from buffer, to be - used only on those systems that support it (namely PowerPC and 680x0) - With some testing, this may become the default for MACOS/PPC systems. - only calculate CRC on data if we are going to use it - added macros for zTXt compression type PNG_zTXt_COMPRESSION_??? - added macros for simple libpng debugging output selectable at compile time - removed PNG_READ_END_MODE in progressive reader (Smarasderagd) - more description of info_struct in libpng.txt and png.h - more instructions in example.c - more chunk types tested in pngtest.c - renamed pngrcb.c to pngset.c, and all png_read_ functions to be - png_set_. We now have corresponding png_get_ - functions in pngget.c to get information in info_ptr. This isolates - the application from the internal organization of png_info_struct - (good for shared library implementations). - -version 0.96 [May, 1997] - fixed serious bug with < 8bpp images introduced in 0.95 - fixed 256-color transparency bug (Greg Roelofs) - fixed up documentation (Greg Roelofs, Laszlo Nyul) - fixed "error" in pngconf.h for Linux setjmp() behaviour - fixed DOS medium model support (Tim Wegner) - fixed png_check_keyword() for case with error in static string text - added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul) - added typecasts to quiet compiler errors - added more debugging info - -version 0.97 [January, 1998] - removed PNG_USE_OWN_CRC capability - relocated png_set_crc_action from pngrutil.c to pngrtran.c - fixed typecasts of "new_key", etc. (Andreas Dilger) - added RFC 1152 [sic] date support - fixed bug in gamma handling of 4-bit grayscale - added 2-bit grayscale gamma handling (Glenn R-P) - added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P) - minor corrections in libpng.txt - added simple sRGB support (Glenn R-P) - easier conditional compiling, e.g. define PNG_READ/WRITE_NOT_FULLY_SUPPORTED; - all configurable options can be selected from command-line instead - of having to edit pngconf.h (Glenn R-P) - fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P) - added more conditions for png_do_background, to avoid changing - black pixels to background when a background is supplied and - no pixels are transparent - repaired PNG_NO_STDIO behaviour - tested NODIV support and made it default behaviour (Greg Roelofs) - added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler) - regularized version numbering scheme and bumped shared-library major - version number to 2 to avoid problems with libpng 0.89 apps (Greg Roelofs) - -version 0.98 [January, 1998] - cleaned up some typos in libpng.txt and in code documentation - fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler) - cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c - changed recommendation about file_gamma for PC images to .51 from .45, - in example.c and libpng.txt, added comments to distinguish between - screen_gamma, viewing_gamma, and display_gamma. - changed all references to RFC1152 to read RFC1123 and changed the - PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED - added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent) - changed srgb_intent from png_byte to int to avoid compiler bugs - -version 0.99 [January 30, 1998] - free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler) - fixed a longstanding "packswap" bug in pngtrans.c - fixed some inconsistencies in pngconf.h that prevented compiling with - PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined - fixed some typos and made other minor rearrangement of libpng.txt (Andreas) - changed recommendation about file_gamma for PC images to .50 from .51 in - example.c and libpng.txt, and changed file_gamma for sRGB images to .45 - added a number of functions to access information from the png structure - png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit) - added TARGET_MACOS similar to zlib-1.0.8 - define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined - added type casting to all png_malloc() function calls -version 0.99a [January 31, 1998] - Added type casts and parentheses to all returns that return a value.(Tim W.) -version 0.99b [February 4, 1998] - Added type cast png_uint_32 on malloc function calls where needed. - Changed type of num_hist from png_uint_32 to int (same as num_palette). - Added checks for rowbytes overflow, in case png_size_t is less than 32 bits. - Renamed makefile.elf to makefile.lnx. -version 0.99c [February 7, 1998] - More type casting. Removed erroneous overflow test in pngmem.c. - Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes. - Added UNIX manual pages libpng.3 (incorporating libpng.txt) and png.5. -version 0.99d [February 11, 1998] - Renamed "far_to_near()" "png_far_to_near()" - Revised libpng.3 - Version 99c "buffered" operations didn't work as intended. Replaced them - with png_memcpy_check() and png_memset_check(). - Added many "if (png_ptr == NULL) return" to quell compiler warnings about - unused png_ptr, mostly in pngget.c and pngset.c. - Check for overlength tRNS chunk present when indexed-color PLTE is read. - Cleaned up spelling errors in libpng.3/libpng.txt - Corrected a problem with png_get_tRNS() which returned undefined trans array -version 0.99e [February 28, 1998] - Corrected png_get_tRNS() again. - Add parentheses for easier reading of pngget.c, fixed "||" should be "&&". - Touched up example.c to make more of it compileable, although the entire - file still can't be compiled (Willem van Schaik) - Fixed a bug in png_do_shift() (Bryan Tsai) - Added a space in png.h prototype for png_write_chunk_start() - Replaced pngtest.png with one created with zlib 1.1.1 - Changed pngtest to report PASS even when file size is different (Jean-loup G.) - Corrected some logic errors in png_do_invert_alpha() (Chris Patterson) -version 0.99f [March 5, 1998] - Corrected a bug in pngpread() introduced in version 99c (Kevin Bracey) - Moved makefiles into a "scripts" directory, and added INSTALL instruction file - Added makefile.os2 and pngos2.def (A. Zabolotny) and makefile.s2x (W. Sebok) - Added pointers to "note on libpng versions" in makefile.lnx and README - Added row callback feature when reading and writing nonprogressive rows - and added a test of this feature in pngtest.c - Added user transform callbacks, with test of the feature in pngtest.c -version 0.99g [March 6, 1998, morning] - Minor changes to pngtest.c to suppress compiler warnings. - Removed "beta" language from documentation. -version 0.99h [March 6, 1998, evening] - Minor changes to previous minor changes to pngtest.c - Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED - and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro - Added user transform capability - -version 1.00 [March 7, 1998] - Changed several typedefs in pngrutil.c - Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik) - replaced "while(1)" with "for(;;)" - added PNGARG() to prototypes in pngtest.c and removed some prototypes - updated some of the makefiles (Tom Lane) - changed some typedefs (s_start, etc.) in pngrutil.c - fixed dimensions of "short_months" array in pngwrite.c - Replaced ansi2knr.c with the one from jpeg-v6 - -version 1.0.0 [March 8, 1998] - Changed name from 1.00 to 1.0.0 (Adam Costello) - Added smakefile.ppc (with SCOPTIONS.ppc) for Amiga PPC (Andreas Kleinert) -version 1.0.0a [March 9, 1998] - Fixed three bugs in pngrtran.c to make gamma+background handling consistent - (Greg Roelofs) - Changed format of the PNG_LIBPNG_VER integer to xyyzz instead of xyz - for major, minor, and bugfix releases. This is 10001. (Adam Costello, - Tom Lane) - Make months range from 1-12 in png_convert_to_rfc1123 -version 1.0.0b [March 13, 1998] - Quieted compiler complaints about two empty "for" loops in pngrutil.c - Minor changes to makefile.s2x - Removed #ifdef/#endif around a png_free() in pngread.c - -version 1.0.1 [March 14, 1998] - Changed makefile.s2x to reduce security risk of using a relative pathname - Fixed some typos in the documentation (Greg). - Fixed a problem with value of "channels" returned by png_read_update_info() -version 1.0.1a [April 21, 1998] - Optimized Paeth calculations by replacing abs() function calls with intrinsics - plus other loop optimizations. Improves avg decoding speed by about 20%. - Commented out i386istic "align" compiler flags in makefile.lnx. - Reduced the default warning level in some makefiles, to make them consistent. - Removed references to IJG and JPEG in the ansi2knr.c copyright statement. - Fixed a bug in png_do_strip_filler with XXRRGGBB => RRGGBB transformation. - Added grayscale and 16-bit capability to png_do_read_filler(). - Fixed a bug in pngset.c, introduced in version 0.99c, that sets rowbytes - too large when writing an image with bit_depth < 8 (Bob Dellaca). - Corrected some bugs in the experimental weighted filtering heuristics. - Moved a misplaced pngrutil code block that truncates tRNS if it has more - than num_palette entries -- test was done before num_palette was defined. - Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins). - Changed compiler flags in makefile.wat for better optimization (Pawel Mrochen). -version 1.0.1b [May 2, 1998] - Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg). - Relocated the png_composite macros from pngrtran.c to png.h (Greg). - Added makefile.sco (contributed by Mike Hopkirk). - Fixed two bugs (missing definitions of "istop") introduced in libpng-1.0.1a. - Fixed a bug in pngrtran.c that would set channels=5 under some circumstances. - More work on the Paeth-filtering, achieving imperceptible speedup (A Kleinert). - More work on loop optimization which may help when compiled with C++ compilers. - Added warnings when people try to use transforms they've defined out. - Collapsed 4 "i" and "c" loops into single "i" loops in pngrtran and pngwtran. - Revised paragraph about png_set_expand() in libpng.txt and libpng.3 (Greg) -version 1.0.1c [May 11, 1998] - Fixed a bug in pngrtran.c (introduced in libpng-1.0.1a) where the masks for - filler bytes should have been 0xff instead of 0xf. - Added max_pixel_depth=32 in pngrutil.c when using FILLER with palette images. - Moved PNG_WRITE_WEIGHTED_FILTER_SUPPORTED and PNG_WRITE_FLUSH_SUPPORTED - out of the PNG_WRITE_TRANSFORMS_NOT_SUPPORTED block of pngconf.h - Added "PNG_NO_WRITE_TRANSFORMS" etc., as alternatives for *_NOT_SUPPORTED, - for consistency, in pngconf.h - Added individual "ifndef PNG_NO_[CAPABILITY]" in pngconf.h to make it easier - to remove unwanted capabilities via the compile line - Made some corrections to grammar (which, it's) in documentation (Greg). - Corrected example.c, use of row_pointers in png_write_image(). -version 1.0.1d [May 24, 1998] - Corrected several statements that used side effects illegally in pngrutil.c - and pngtrans.c, that were introduced in version 1.0.1b - Revised png_read_rows() to avoid repeated if-testing for NULL (A Kleinert) - More corrections to example.c, use of row_pointers in png_write_image() - and png_read_rows(). - Added pngdll.mak and pngdef.pas to scripts directory, contributed by - Bob Dellaca, to make a png32bd.dll with Borland C++ 4.5 - Fixed error in example.c with png_set_text: num_text is 3, not 2 (Guido V.) - Changed several loops from count-down to count-up, for consistency. -version 1.0.1e [June 6, 1998] - Revised libpng.txt and libpng.3 description of png_set_read|write_fn(), and - added warnings when people try to set png_read_fn and png_write_fn in - the same structure. - Added a test such that png_do_gamma will be done when num_trans==0 - for truecolor images that have defined a background. This corrects an - error that was introduced in libpng-0.90 that can cause gamma processing - to be skipped. - Added tests in png.h to include "trans" and "trans_values" in structures - when PNG_READ_BACKGROUND_SUPPORTED or PNG_READ_EXPAND_SUPPORTED is defined. - Add png_free(png_ptr->time_buffer) in png_destroy_read_struct() - Moved png_convert_to_rfc_1123() from pngwrite.c to png.c - Added capability for user-provided malloc_fn() and free_fn() functions, - and revised pngtest.c to demonstrate their use, replacing the - PNGTEST_DEBUG_MEM feature. - Added makefile.w32, for Microsoft C++ 4.0 and later (Tim Wegner). - -version 1.0.2 [June 14, 1998] - Fixed two bugs in makefile.bor . -version 1.0.2a [December 30, 1998] - Replaced and extended code that was removed from png_set_filler() in 1.0.1a. - Fixed a bug in png_do_filler() that made it fail to write filler bytes in - the left-most pixel of each row (Kevin Bracey). - Changed "static pngcharp tIME_string" to "static char tIME_string[30]" - in pngtest.c (Duncan Simpson). - Fixed a bug in pngtest.c that caused pngtest to try to write a tIME chunk - even when no tIME chunk was present in the source file. - Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit. - Fixed a problem in png_read_push_finish_row(), which would not skip some - passes that it should skip, for images that are less than 3 pixels high. - Interchanged the order of calls to png_do_swap() and png_do_shift() - in pngwtran.c (John Cromer). - Added #ifdef PNG_DEBUG/#endif surrounding use of PNG_DEBUG in png.h . - Changed "bad adaptive filter type" from error to warning in pngrutil.c . - Fixed a documentation error about default filtering with 8-bit indexed-color. - Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO - (L. Peter Deutsch). - Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions. - Added png_get_copyright() and png_get_header_version() functions. - Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c - Added information about debugging in libpng.txt and libpng.3 . - Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco. - Removed lines after Dynamic Dependencies" in makefile.aco . - Revised makefile.dec to make a shared library (Jeremie Petit). - Removed trailing blanks from all files. -version 1.0.2a [January 6, 1999] - Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h - Added "if" tests to silence complaints about unused png_ptr in png.h and png.c - Changed "check_if_png" function in example.c to return true (nonzero) if PNG. - Changed libpng.txt to demonstrate png_sig_cmp() instead of png_check_sig() - which is obsolete. - -version 1.0.3 [January 14, 1999] - Added makefile.hux, for Hewlett Packard HPUX 10.20 and 11.00 (Jim Rice) - Added a statement of Y2K compliance in png.h, libpng.3, and Y2KINFO. -version 1.0.3a [August 12, 1999] - Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning - if an attempt is made to read an interlaced image when it's not supported. - Added check if png_ptr->trans is defined before freeing it in pngread.c - Modified the Y2K statement to include versions back to version 0.71 - Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c - Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments) - Replaced leading blanks with tab characters in makefile.hux - Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents. - Changed (float)red and (float)green to (double)red, (double)green - in png_set_rgb_to_gray() to avoid "promotion" problems in AIX. - Fixed a bug in pngconf.h that omitted when PNG_DEBUG==0 (K Bracey). - Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt). - Updated documentation to refer to the PNG-1.2 specification. - Removed ansi2knr.c and left pointers to the latest source for ansi2knr.c - in makefile.knr, INSTALL, and README (L. Peter Deutsch) - Fixed bugs in calculation of the length of rowbytes when adding alpha - channels to 16-bit images, in pngrtran.c (Chris Nokleberg) - Added function png_set_user_transform_info() to store user_transform_ptr, - user_depth, and user_channels into the png_struct, and a function - png_get_user_transform_ptr() to retrieve the pointer (Chris Nokleberg) - Added function png_set_empty_plte_permitted() to make libpng useable - in MNG applications. - Corrected the typedef for png_free_ptr in png.h (Jesse Jones). - Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c, to be - consistent with PNG-1.2, and allow variance of 500 before complaining. - Added assembler code contributed by Intel in file pngvcrd.c and modified - makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, Gilles Vollant) - Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy. - Added some aliases for png_set_expand() in pngrtran.c, namely - png_set_expand_PLTE(), png_set_expand_depth(), and png_set_expand_tRNS() - (Greg Roelofs, in "PNG: The Definitive Guide"). - Added makefile.beo for BEOS on X86, contributed by Sander Stok. -version 1.0.3b [August 26, 1999] - Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h - Changed leading blanks to tabs in all makefiles. - Define PNG_USE_PNGVCRD in makefile.w32, to get MMX assembler code. - Made alternate versions of png_set_expand() in pngrtran.c, namely - png_set_gray_1_2_4_to_8, png_set_palette_to_rgb, and png_set_tRNS_to_alpha - (Greg Roelofs, in "PNG: The Definitive Guide"). Deleted the 1.0.3a aliases. - Relocated start of 'extern "C"' block in png.h so it doesn't include pngconf.h - Revised calculation of num_blocks in pngmem.c to avoid a potentially - negative shift distance, whose results are undefined in the C language. - Added a check in pngset.c to prevent writing multiple tIME chunks. - Added a check in pngwrite.c to detect invalid small window_bits sizes. -version 1.0.3d [September 4, 1999] - Fixed type casting of igamma in pngrutil.c - Added new png_expand functions to scripts/pngdef.pas and pngos2.def - Added a demo read_user_transform_fn that examines the row filters in pngtest.c - -version 1.0.4 [September 24, 1999] - Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined - Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h - Made several minor corrections to pngtest.c - Renamed the makefiles with longer but more user friendly extensions. - Copied the PNG copyright and license to a separate LICENSE file. - Revised documentation, png.h, and example.c to remove reference to - "viewing_gamma" which no longer appears in the PNG specification. - Revised pngvcrd.c to use MMX code for interlacing only on the final pass. - Updated pngvcrd.c to use the faster C filter algorithms from libpng-1.0.1a - Split makefile.win32vc into two versions, makefile.vcawin32 (uses MMX - assembler code) and makefile.vcwin32 (doesn't). - Added a CPU timing report to pngtest.c (enabled by defining PNGTEST_TIMING) - Added a copy of pngnow.png to the distribution. -version 1.0.4a [September 25, 1999] - Increase max_pixel_depth in pngrutil.c if a user transform needs it. - Changed several division operations to right-shifts in pngvcrd.c -version 1.0.4b [September 30, 1999] - Added parentheses in line 3732 of pngvcrd.c - Added a comment in makefile.linux warning about buggy -O3 in pgcc 2.95.1 -version 1.0.4c [October 1, 1999] - Added a "png_check_version" function in png.c and pngtest.c that will generate - a helpful compiler error if an old png.h is found in the search path. - Changed type of png_user_transform_depth|channels from int to png_byte. -version 1.0.4d [October 6, 1999] - Changed 0.45 to 0.45455 in png_set_sRGB() - Removed unused PLTE entries from pngnow.png - Re-enabled some parts of pngvcrd.c (png_combine_row) that work properly. -version 1.0.4e [October 10, 1999] - Fixed sign error in pngvcrd.c (Greg Roelofs) - Replaced some instances of memcpy with simple assignments in pngvcrd (GR-P) -version 1.0.4f [October 15, 1999] - Surrounded example.c code with #if 0 .. #endif to prevent people from - inadvertently trying to compile it. - Changed png_get_header_version() from a function to a macro in png.h - Added type casting mostly in pngrtran.c and pngwtran.c - Removed some pointless "ptr = NULL" in pngmem.c - Added a "contrib" directory containing the source code from Greg's book. - -version 1.0.5 [October 15, 1999] - Minor editing of the INSTALL and README files. -version 1.0.5a [October 23, 1999] - Added contrib/pngsuite and contrib/pngminus (Willem van Schaik) - Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans) - Further optimization and bugfix of pngvcrd.c - Revised pngset.c so that it does not allocate or free memory in the user's - text_ptr structure. Instead, it makes its own copy. - Created separate write_end_info_struct in pngtest.c for a more severe test. - Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak. -version 1.0.5b [November 23, 1999] - Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and - PNG_FLAG_WROTE_tIME from flags to mode. - Added png_write_info_before_PLTE() function. - Fixed some typecasting in contrib/gregbook/*.c - Updated scripts/makevms.com and added makevms.com to contrib/gregbook - and contrib/pngminus (Martin Zinser) -version 1.0.5c [November 26, 1999] - Moved png_get_header_version from png.h to png.c, to accommodate ansi2knr. - Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to - accommodate making DLL's: Moved usr_png_ver from global variable to function - png_get_header_ver() in png.c. Moved png_sig to png_sig_bytes in png.c and - eliminated use of png_sig in pngwutil.c. Moved the various png_CHNK arrays - into pngtypes.h. Eliminated use of global png_pass arrays. Declared the - png_CHNK and png_pass arrays to be "const". Made the global arrays - available to applications (although none are used in libpng itself) when - PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined. - Removed some extraneous "-I" from contrib/pngminus/makefile.std - Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2. - Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3 -version 1.0.5d [November 29, 1999] - Add type cast (png_const_charp) two places in png.c - Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays. - Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available - to applications a macro "PNG_USE_LOCAL_ARRAYS". - #ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined. - Added PNG_EXPORT_VAR macro to accommodate making DLL's. -version 1.0.5e [November 30, 1999] - Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text - structure; refactored the inflate/deflate support to make adding new chunks - with trailing compressed parts easier in the future, and added new functions - png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP, - png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond). - NOTE: Applications that write text chunks MUST define png_text->lang - before calling png_set_text(). It must be set to NULL if you want to - write tEXt or zTXt chunks. If you want your application to be able to - run with older versions of libpng, use - - #ifdef PNG_iTXt_SUPPORTED - png_text[i].lang = NULL; - #endif - - Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned - offsets (Eric S. Raymond). - Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into - PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED - macros, leaving the separate macros also available. - Removed comments on #endifs at the end of many short, non-nested #if-blocks. -version 1.0.5f [December 6, 1999] - Changed makefile.solaris to issue a warning about potential problems when - the ucb "ld" is in the path ahead of the ccs "ld". - Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3. - Added sCAL chunk support (Eric S. Raymond). -version 1.0.5g [December 7, 1999] - Fixed "png_free_spallettes" typo in png.h - Added code to handle new chunks in pngpread.c - Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block - Added "translated_key" to png_text structure and png_write_iTXt(). - Added code in pngwrite.c to work around a newly discovered zlib bug. -version 1.0.5h [December 10, 1999] - NOTE: regarding the note for version 1.0.5e, the following must also - be included in your code: - png_text[i].translated_key = NULL; - Unknown chunk handling is now supported. - Option to eliminate all floating point support was added. Some new - fixed-point functions such as png_set_gAMA_fixed() were added. - Expanded tabs and removed trailing blanks in source files. -version 1.0.5i [December 13, 1999] - Added some type casts to silence compiler warnings. - Renamed "png_free_spalette" to "png_free_spalettes" for consistency. - Removed leading blanks from a #define in pngvcrd.c - Added some parameters to the new png_set_keep_unknown_chunks() function. - Added a test for up->location != 0 in the first instance of writing - unknown chunks in pngwrite.c - Changed "num" to "i" in png_free_spalettes() and png_free_unknowns() to - prevent recursion. - Added png_free_hIST() function. - Various patches to fix bugs in the sCAL and integer cHRM processing, - and to add some convenience macros for use with sCAL. -version 1.0.5j [December 21, 1999] - Changed "unit" parameter of png_write_sCAL from png_byte to int, to work - around buggy compilers. - Added new type "png_fixed_point" for integers that hold float*100000 values - Restored backward compatibility of tEXt/zTXt chunk processing: - Restored the first four members of png_text to the same order as v.1.0.5d. - Added members "lang_key" and "itxt_length" to png_text struct. Set - text_length=0 when "text" contains iTXt data. Use the "compression" - member to distinguish among tEXt/zTXt/iTXt types. Added - PNG_ITXT_COMPRESSION_NONE (1) and PNG_ITXT_COMPRESSION_zTXt(2) macros. - The "Note" above, about backward incompatibility of libpng-1.0.5e, no - longer applies. - Fixed png_read|write_iTXt() to read|write parameters in the right order, - and to write the iTXt chunk after IDAT if it appears in the end_ptr. - Added pnggccrd.c, version of pngvcrd.c Intel assembler for gcc (Greg Roelofs) - Reversed the order of trying to write floating-point and fixed-point gAMA. -version 1.0.5k [December 27, 1999] - Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))" - Added png_handle_as_unknown() function (Glenn) - Added png_free_chunk_list() function and chunk_list and num_chunk_list members - of png_ptr. - Eliminated erroneous warnings about multiple sPLT chunks and sPLT-after-PLTE. - Fixed a libpng-1.0.5h bug in pngrutil.c that was issuing erroneous warnings - about ignoring incorrect gAMA with sRGB (gAMA was in fact not ignored) - Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR). - Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is. - Changed type of proflen from png_int_32 to png_uint_32 in png_get_iCCP(). -version 1.0.5l [January 1, 2000] - Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr() - for setting a callback function to handle unknown chunks and for - retrieving the associated user pointer (Glenn). -version 1.0.5m [January 7, 2000] - Added high-level functions png_read_png(), png_write_png(), png_free_pixels(). -version 1.0.5n [January 9, 2000] - Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its - own memory for info_ptr->palette. This makes it safe for the calling - application to free its copy of the palette any time after it calls - png_set_PLTE(). -version 1.0.5o [January 20, 2000] - Cosmetic changes only (removed some trailing blanks and TABs) -version 1.0.5p [January 31, 2000] - Renamed pngdll.mak to makefile.bd32 - Cosmetic changes in pngtest.c -version 1.0.5q [February 5, 2000] - Relocated the makefile.solaris warning about PATH problems. - Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg) - Revised makefile.gcmmx - Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros -version 1.0.5r [February 7, 2000] - Removed superfluous prototype for png_get_itxt from png.h - Fixed a bug in pngrtran.c that improperly expanded the background color. - Return *num_text=0 from png_get_text() when appropriate, and fix documentation - of png_get_text() in libpng.txt/libpng.3. -version 1.0.5s [February 18, 2000] - Added "png_jmp_env()" macro to pngconf.h, to help people migrate to the - new error handler that's planned for the next libpng release, and changed - example.c, pngtest.c, and contrib programs to use this macro. - Revised some of the DLL-export macros in pngconf.h (Greg Roelofs) - Fixed a bug in png_read_png() that caused it to fail to expand some images - that it should have expanded. - Fixed some mistakes in the unused and undocumented INCH_CONVERSIONS functions - in pngget.c - Changed the allocation of palette, history, and trans arrays back to - the version 1.0.5 method (linking instead of copying) which restores - backward compatibility with version 1.0.5. Added some remarks about - that in example.c. Added "free_me" member to info_ptr and png_ptr - and added png_free_data() function. - Updated makefile.linux and makefile.gccmmx to make directories conditionally. - Made cosmetic changes to pngasmrd.h - Added png_set_rows() and png_get_rows(), for use with png_read|write_png(). - Modified png_read_png() to allocate info_ptr->row_pointers only if it - hasn't already been allocated. -version 1.0.5t [March 4, 2000] - Changed png_jmp_env() migration aiding macro to png_jmpbuf(). - Fixed "interlace" typo (should be "interlaced") in contrib/gregbook/read2-x.c - Fixed bug with use of PNG_BEFORE_IHDR bit in png_ptr->mode, introduced when - PNG_FLAG_HAVE_CHUNK_HEADER was moved into png_ptr->mode in version 1.0.5b - Files in contrib/gregbook were revised to use png_jmpbuf() and to select - a 24-bit visual if one is available, and to allow abbreviated options. - Files in contrib/pngminus were revised to use the png_jmpbuf() macro. - Removed spaces in makefile.linux and makefile.gcmmx, introduced in 1.0.5s -version 1.0.5u [March 5, 2000] - Simplified the code that detects old png.h in png.c and pngtest.c - Renamed png_spalette (_p, _pp) to png_sPLT_t (_tp, _tpp) - Increased precision of rgb_to_gray calculations from 8 to 15 bits and - added png_set_rgb_to_gray_fixed() function. - Added makefile.bc32 (32-bit Borland C++, C mode) -version 1.0.5v [March 11, 2000] - Added some parentheses to the png_jmpbuf macro definition. - Updated references to the zlib home page, which has moved to freesoftware.com. - Corrected bugs in documentation regarding png_read_row() and png_write_row(). - Updated documentation of png_rgb_to_gray calculations in libpng.3/libpng.txt. - Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3, - revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin) - -version 1.0.6 [March 20, 2000] - Minor revisions of makefile.bor, libpng.txt, and gregbook/rpng2-win.c - Added makefile.sggcc (SGI IRIX with gcc) -version 1.0.6d [April 7, 2000] - Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO - Added data_length parameter to png_decompress_chunk() function - Revised documentation to remove reference to abandoned png_free_chnk functions - Fixed an error in png_rgb_to_gray_fixed() - Revised example.c, usage of png_destroy_write_struct(). - Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file - Added a check for info_ptr->free_me&PNG_FREE_TEXT when freeing text in png.c - Simplify png_sig_bytes() function to remove use of non-ISO-C strdup(). -version 1.0.6e [April 9, 2000] - Added png_data_freer() function. - In the code that checks for over-length tRNS chunks, added check of - info_ptr->num_trans as well as png_ptr->num_trans (Matthias Benckmann) - Minor revisions of libpng.txt/libpng.3. - Check for existing data and free it if the free_me flag is set, in png_set_*() - and png_handle_*(). - Only define PNG_WEIGHTED_FILTERS_SUPPORTED when PNG_FLOATING_POINT_SUPPORTED - is defined. - Changed several instances of PNG_NO_CONSOLE_ID to PNG_NO_STDIO in pngrutil.c - and mentioned the purposes of the two macros in libpng.txt/libpng.3. -version 1.0.6f [April 14, 2000] - Revised png_set_iCCP() and png_set_rows() to avoid prematurely freeing data. - Add checks in png_set_text() for NULL members of the input text structure. - Revised libpng.txt/libpng.3. - Removed superfluous prototype for png_set_itxt from png.h - Removed "else" from pngread.c, after png_error(), and changed "0" to "length". - Changed several png_errors about malformed ancillary chunks to png_warnings. -version 1.0.6g [April 24, 2000] - Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined. - Relocated paragraph about png_set_background() in libpng.3/libpng.txt - and other revisions (Matthias Benckmann) - Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and - png_ptr members to restore binary compatibility with libpng-1.0.5 - (breaks compatibility with libpng-1.0.6). -version 1.0.6h [April 24, 2000] - Changed shared library so-number pattern from 2.x.y.z to xy.z (this builds - libpng.so.10 & libpng.so.10.6h instead of libpng.so.2 & libpng.so.2.1.0.6h) - This is a temporary change for test purposes. -version 1.0.6i [May 2, 2000] - Rearranged some members at the end of png_info and png_struct, to put - unknown_chunks_num and free_me within the original size of the png_structs - and free_me, png_read_user_fn, and png_free_fn within the original png_info, - because some old applications allocate the structs directly instead of - using png_create_*(). - Added documentation of user memory functions in libpng.txt/libpng.3 - Modified png_read_png so that it will use user_allocated row_pointers - if present, unless free_me directs that it be freed, and added description - of the use of png_set_rows() and png_get_rows() in libpng.txt/libpng.3. - Added PNG_LEGACY_SUPPORTED macro, and #ifdef out all new (since version - 1.00) members of png_struct and png_info, to regain binary compatibility - when you define this macro. Capabilities lost in this event - are user transforms (new in version 1.0.0),the user transform pointer - (new in version 1.0.2), rgb_to_gray (new in 1.0.5), iCCP, sCAL, sPLT, - the high-level interface, and unknown chunks support (all new in 1.0.6). - This was necessary because of old applications that allocate the structs - directly as authors were instructed to do in libpng-0.88 and earlier, - instead of using png_create_*(). - Added modes PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT which - can be used to detect codes that directly allocate the structs, and - code to check these modes in png_read_init() and png_write_init() and - generate a libpng error if the modes aren't set and PNG_LEGACY_SUPPORTED - was not defined. - Added makefile.intel and updated makefile.watcom (Pawel Mrochen) -version 1.0.6j [May 3, 2000] - Overloaded png_read_init() and png_write_init() with macros that convert - calls to png_read_init_2() or png_write_init_2() that check the version - and structure sizes. -version 1.0.7beta11 [May 7, 2000] - Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes - which are no longer used. - Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is - defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXT_SUPPORTED - is defined. - Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory - overrun when old applications fill the info_ptr->text structure directly. - Added PNGAPI macro, and added it to the definitions of all exported functions. - Relocated version macro definitions ahead of the includes of zlib.h and - pngconf.h in png.h. -version 1.0.7beta12 [May 12, 2000] - Revised pngset.c to avoid a problem with expanding the png_debug macro. - Deleted some extraneous defines from pngconf.h - Made PNG_NO_CONSOLE_IO the default condition when PNG_BUILD_DLL is defined. - Use MSC _RPTn debugging instead of fprintf if _MSC_VER is defined. - Added png_access_version_number() function. - Check for mask&PNG_FREE_CHNK (for TEXT, SCAL, PCAL) in png_free_data(). - Expanded libpng.3/libpng.txt information about png_data_freer(). -version 1.0.7beta14 [May 17, 2000] (beta13 was not published) - Changed pnggccrd.c and pngvcrd.c to handle bad adaptive filter types as - warnings instead of errors, as pngrutil.c does. - Set the PNG_INFO_IDAT valid flag in png_set_rows() so png_write_png() - will actually write IDATs. - Made the default PNG_USE_LOCAL_ARRAYS depend on PNG_DLL instead of WIN32. - Make png_free_data() ignore its final parameter except when freeing data - that can have multiple instances (text, sPLT, unknowns). - Fixed a new bug in png_set_rows(). - Removed info_ptr->valid tests from png_free_data(), as in version 1.0.5. - Added png_set_invalid() function. - Fixed incorrect illustrations of png_destroy_write_struct() in example.c. -version 1.0.7beta15 [May 30, 2000] - Revised the deliberately erroneous Linux setjmp code in pngconf.h to produce - fewer error messages. - Rearranged checks for Z_OK to check the most likely path first in pngpread.c - and pngwutil.c. - Added checks in pngtest.c for png_create_*() returning NULL, and mentioned - in libpng.txt/libpng.3 the need for applications to check this. - Changed names of png_default_*() functions in pngtest to pngtest_*(). - Changed return type of png_get_x|y_offset_*() from png_uint_32 to png_int_32. - Fixed some bugs in the unused PNG_INCH_CONVERSIONS functions in pngget.c - Set each pointer to NULL after freeing it in png_free_data(). - Worked around a problem in pngconf.h; AIX's strings.h defines an "index" - macro that conflicts with libpng's png_color_16.index. (Dimitri Papadapoulos) - Added "msvc" directory with MSVC++ project files (Simon-Pierre Cadieux). -version 1.0.7beta16 [June 4, 2000] - Revised the workaround of AIX string.h "index" bug. - Added a check for overlength PLTE chunk in pngrutil.c. - Added PNG_NO_POINTER_INDEXING macro to use array-indexing instead of pointer - indexing in pngrutil.c and pngwutil.c to accommodate a buggy compiler. - Added a warning in png_decompress_chunk() when it runs out of data, e.g. - when it tries to read an erroneous PhotoShop iCCP chunk. - Added PNG_USE_DLL macro. - Revised the copyright/disclaimer/license notice. - Added contrib/msvctest directory -version 1.0.7rc1 [June 9, 2000] - Corrected the definition of PNG_TRANSFORM_INVERT_ALPHA (0x0400 not 0x0200) - Added contrib/visupng directory (Willem van Schaik) -version 1.0.7beta18 [June 23, 2000] - Revised PNGAPI definition, and pngvcrd.c to work with __GCC__ - and do not redefine PNGAPI if it is passed in via a compiler directive. - Revised visupng/PngFile.c to remove returns from within the Try block. - Removed leading underscores from "_PNG_H" and "_PNG_SAVE_BSD_SOURCE" macros. - Updated contrib/visupng/cexcept.h to version 1.0.0. - Fixed bugs in pngwrite.c and pngwutil.c that prevented writing iCCP chunks. -version 1.0.7rc2 [June 28, 2000] - Updated license to include disclaimers required by UCITA. - Fixed "DJBPP" typo in pnggccrd.c introduced in beta18. - -version 1.0.7 [July 1, 2000] - Revised the definition of "trans_values" in libpng.3/libpng.txt -version 1.0.8beta1 [July 8, 2000] - Added png_free(png_ptr, key) two places in pngpread.c to stop memory leaks. - Changed PNG_NO_STDIO to PNG_NO_CONSOLE_IO, several places in pngrutil.c and - pngwutil.c. - Changed PNG_EXPORT_VAR to use PNG_IMPEXP, in pngconf.h. - Removed unused "#include " from png.c - Added WindowsCE support. - Revised pnggccrd.c to work with gcc-2.95.2 and in the Cygwin environment. -version 1.0.8beta2 [July 10, 2000] - Added project files to the wince directory and made further revisions - of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE. -version 1.0.8beta3 [July 11, 2000] - Only set the PNG_FLAG_FREE_TRNS or PNG_FREE_TRNS flag in png_handle_tRNS() - for indexed-color input files to avoid potential double-freeing trans array - under some unusual conditions; problem was introduced in version 1.0.6f. - Further revisions to pngtest.c and files in the wince subdirectory. -version 1.0.8beta4 [July 14, 2000] - Added the files pngbar.png and pngbar.jpg to the distribution. - Added makefile.cygwin, and cygwin support in pngconf.h - Added PNG_NO_ZALLOC_ZERO macro (makes png_zalloc skip zeroing memory) -version 1.0.8rc1 [July 16, 2000] - Revised png_debug() macros and statements to eliminate compiler warnings. - -version 1.0.8 [July 24, 2000] - Added png_flush() in pngwrite.c, after png_write_IEND(). - Updated makefile.hpux to build a shared library. -version 1.0.9beta1 [November 10, 2000] - Fixed typo in scripts/makefile.hpux - Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser) - Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser) - Changed "cdrom.com" in documentation to "libpng.org" - Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg). - Changed type of "params" from voidp to png_voidp in png_read|write_png(). - Make sure PNGAPI and PNG_IMPEXP are defined in pngconf.h. - Revised the 3 instances of WRITEFILE in pngtest.c. - Relocated "msvc" and "wince" project subdirectories into "dll" subdirectory. - Updated png.rc in dll/msvc project - Revised makefile.dec to define and use LIBPATH and INCPATH - Increased size of global png_libpng_ver[] array from 12 to 18 chars. - Made global png_libpng_ver[], png_sig[] and png_pass_*[] arrays const. - Removed duplicate png_crc_finish() from png_handle_bKGD() function. - Added a warning when application calls png_read_update_info() multiple times. - Revised makefile.cygwin - Fixed bugs in iCCP support in pngrutil.c and pngwutil.c. - Replaced png_set_empty_plte_permitted() with png_permit_mng_features(). -version 1.0.9beta2 [November 19, 2000] - Renamed the "dll" subdirectory "projects". - Added borland project files to "projects" subdirectory. - Set VS_FF_PRERELEASE and VS_FF_PATCHED flags in msvc/png.rc when appropriate. - Add error message in png_set_compression_buffer_size() when malloc fails. -version 1.0.9beta3 [November 23, 2000] - Revised PNG_LIBPNG_BUILD_TYPE macro in png.h, used in the msvc project. - Removed the png_flush() in pngwrite.c that crashes some applications - that don't set png_output_flush_fn. - Added makefile.macosx and makefile.aix to scripts directory. -version 1.0.9beta4 [December 1, 2000] - Change png_chunk_warning to png_warning in png_check_keyword(). - Increased the first part of msg buffer from 16 to 18 in png_chunk_error(). -version 1.0.9beta5 [December 15, 2000] - Added support for filter method 64 (for PNG datastreams embedded in MNG). -version 1.0.9beta6 [December 18, 2000] - Revised png_set_filter() to accept filter method 64 when appropriate. - Added new PNG_HAVE_PNG_SIGNATURE bit to png_ptr->mode and use it to - help prevent applications from using MNG features in PNG datastreams. - Added png_permit_mng_features() function. - Revised libpng.3/libpng.txt. Changed "filter type" to "filter method". -version 1.0.9rc1 [December 23, 2000] - Revised test for PNG_HAVE_PNG_SIGNATURE in pngrutil.c - Fixed error handling of unknown compression type in png_decompress_chunk(). - In pngconf.h, define __cdecl when _MSC_VER is defined. -version 1.0.9beta7 [December 28, 2000] - Changed PNG_TEXT_COMPRESSION_zTXt to PNG_COMPRESSION_TYPE_BASE several places. - Revised memory management in png_set_hIST and png_handle_hIST in a backward - compatible manner. PLTE and tRNS were revised similarly. - Revised the iCCP chunk reader to ignore trailing garbage. -version 1.0.9beta8 [January 12, 2001] - Moved pngasmrd.h into pngconf.h. - Improved handling of out-of-spec garbage iCCP chunks generated by PhotoShop. -version 1.0.9beta9 [January 15, 2001] - Added png_set_invalid, png_permit_mng_features, and png_mmx_supported to - wince and msvc project module definition files. - Minor revision of makefile.cygwin. - Fixed bug with progressive reading of narrow interlaced images in pngpread.c -version 1.0.9beta10 [January 16, 2001] - Do not typedef png_FILE_p in pngconf.h when PNG_NO_STDIO is defined. - Fixed "png_mmx_supported" typo in project definition files. -version 1.0.9beta11 [January 19, 2001] - Updated makefile.sgi to make shared library. - Removed png_mmx_support() function and disabled PNG_MNG_FEATURES_SUPPORTED - by default, for the benefit of DLL forward compatibility. These will - be re-enabled in version 1.2.0. -version 1.0.9rc2 [January 22, 2001] - Revised cygwin support. - -version 1.0.9 [January 31, 2001] - Added check of cygwin's ALL_STATIC in pngconf.h - Added "-nommx" parameter to contrib/gregbook/rpng2-win and rpng2-x demos. -version 1.0.10beta1 [March 14, 2001] - Revised makefile.dec, makefile.sgi, and makefile.sggcc; added makefile.hpgcc. - Reformatted libpng.3 to eliminate bad line breaks. - Added checks for _mmx_supported in the read_filter_row function of pnggccrd.c - Added prototype for png_mmx_support() near the top of pnggccrd.c - Moved some error checking from png_handle_IHDR to png_set_IHDR. - Added PNG_NO_READ_SUPPORTED and PNG_NO_WRITE_SUPPORTED macros. - Revised png_mmx_support() function in pnggccrd.c - Restored version 1.0.8 PNG_WRITE_EMPTY_PLTE_SUPPORTED behavior in pngwutil.c - Fixed memory leak in contrib/visupng/PngFile.c - Fixed bugs in png_combine_row() in pnggccrd.c and pngvcrd.c (C version) - Added warnings when retrieving or setting gamma=0. - Increased the first part of msg buffer from 16 to 18 in png_chunk_warning(). -version 1.0.10rc1 [March 23, 2001] - Changed all instances of memcpy, strcpy, and strlen to png_memcpy, png_strcpy, - and png_strlen. - Revised png_mmx_supported() function in pnggccrd.c to return proper value. - Fixed bug in progressive reading (pngpread.c) with small images (height < 8). - -version 1.0.10 [March 30, 2001] - Deleted extraneous space (introduced in 1.0.9) from line 42 of makefile.cygwin - Added beos project files (Chris Herborth) -version 1.0.11beta1 [April 3, 2001] - Added type casts on several png_malloc() calls (Dimitri Papadapoulos). - Removed a no-longer needed AIX work-around from pngconf.h - Changed several "//" single-line comments to C-style in pnggccrd.c -version 1.0.11beta2 [April 11, 2001] - Removed PNGAPI from several functions whose prototypes did not have PNGAPI. - Updated scripts/pngos2.def -version 1.0.11beta3 [April 14, 2001] - Added checking the results of many instances of png_malloc() for NULL -version 1.0.11beta4 [April 20, 2001] - Undid the changes from version 1.0.11beta3. Added a check for NULL return - from user's malloc_fn(). - Removed some useless type casts of the NULL pointer. - Added makefile.netbsd - -version 1.0.11 [April 27, 2001] - Revised makefile.netbsd -version 1.0.12beta1 [May 14, 2001] - Test for Windows platform in pngconf.h when including malloc.h (Emmanuel Blot) - Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h - Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings. - Eliminated the png_error about apps using png_read|write_init(). Instead, - libpng will reallocate the png_struct and info_struct if they are too small. - This retains future binary compatibility for old applications written for - libpng-0.88 and earlier. -version 1.2.0beta1 [May 6, 2001] - Bumped DLLNUM to 2. - Re-enabled PNG_MNG_FEATURES_SUPPORTED and enabled PNG_ASSEMBLER_CODE_SUPPORTED - by default. - Added runtime selection of MMX features. - Added png_set_strip_error_numbers function and related macros. -version 1.2.0beta2 [May 7, 2001] - Finished merging 1.2.0beta1 with version 1.0.11 - Added a check for attempts to read or write PLTE in grayscale PNG datastreams. -version 1.2.0beta3 [May 17, 2001] - Enabled user memory function by default. - Modified png_create_struct so it passes user mem_ptr to user memory allocator. - Increased png_mng_features flag from png_byte to png_uint_32. - Bumped shared-library (so-number) and dll-number to 3. -version 1.2.0beta4 [June 23, 2001] - Check for missing profile length field in iCCP chunk and free chunk_data - in case of truncated iCCP chunk. - Bumped shared-library number to 3 in makefile.sgi and makefile.sggcc - Bumped dll-number from 2 to 3 in makefile.cygwin - Revised contrib/gregbook/rpng*-x.c to avoid a memory leak and to exit cleanly - if user attempts to run it on an 8-bit display. - Updated contrib/gregbook - Use png_malloc instead of png_zalloc to allocate palette in pngset.c - Updated makefile.ibmc - Added some typecasts to eliminate gcc 3.0 warnings. Changed prototypes - of png_write_oFFS width and height from png_uint_32 to png_int_32. - Updated example.c - Revised prototypes for png_debug_malloc and png_debug_free in pngtest.c -version 1.2.0beta5 [August 8, 2001] - Revised contrib/gregbook - Revised makefile.gcmmx - Revised pnggccrd.c to conditionally compile some thread-unsafe code only - when PNG_THREAD_UNSAFE_OK is defined. - Added tests to prevent pngwutil.c from writing a bKGD or tRNS chunk with - value exceeding 2^bit_depth-1 - Revised makefile.sgi and makefile.sggcc - Replaced calls to fprintf(stderr,...) with png_warning() in pnggccrd.c - Removed restriction that do_invert_mono only operate on 1-bit opaque files - -version 1.2.0 [September 1, 2001] - Changed a png_warning() to png_debug() in pnggccrd.c - Fixed contrib/gregbook/rpng-x.c, rpng2-x.c to avoid crash with XFreeGC(). -version 1.2.1beta1 [October 19, 2001] - Revised makefile.std in contrib/pngminus - Include background_1 in png_struct regardless of gamma support. - Revised makefile.netbsd and makefile.macosx, added makefile.darwin. - Revised example.c to provide more details about using row_callback(). -version 1.2.1beta2 [October 25, 2001] - Added type cast to each NULL appearing in a function call, except for - WINCE functions. - Added makefile.so9. -version 1.2.1beta3 [October 27, 2001] - Removed type casts from all NULLs. - Simplified png_create_struct_2(). -version 1.2.1beta4 [November 7, 2001] - Revised png_create_info_struct() and png_creat_struct_2(). - Added error message if png_write_info() was omitted. - Type cast NULLs appearing in function calls when _NO_PROTO or - PNG_TYPECAST_NULL is defined. -version 1.2.1rc1 [November 24, 2001] - Type cast NULLs appearing in function calls except when PNG_NO_TYPECAST_NULL - is defined. - Changed typecast of "size" argument to png_size_t in pngmem.c calls to - the user malloc_fn, to agree with the prototype in png.h - Added a pop/push operation to pnggccrd.c, to preserve Eflag (Maxim Sobolev) - Updated makefile.sgi to recognize LIBPATH and INCPATH. - Updated various makefiles so "make clean" does not remove previous major - version of the shared library. -version 1.2.1rc2 [December 4, 2001] - Always allocate 256-entry internal palette, hist, and trans arrays, to - avoid out-of-bounds memory reference caused by invalid PNG datastreams. - Added a check for prefix_length > data_length in iCCP chunk handler. - -version 1.2.1 [December 7, 2001] - None. -version 1.2.2beta1 [February 22, 2002] - Fixed a bug with reading the length of iCCP profiles (Larry Reeves). - Revised makefile.linux, makefile.gcmmx, and makefile.sgi to generate - libpng.a, libpng12.so (not libpng.so.3), and libpng12/png.h - Revised makefile.darwin to remove "-undefined suppress" option. - Added checks for gamma and chromaticity values over 21474.83, which exceed - the limit for PNG unsigned 32-bit integers when encoded. - Revised calls to png_create_read_struct() and png_create_write_struct() - for simpler debugging. - Revised png_zalloc() so zlib handles errors (uses PNG_FLAG_MALLOC_NULL_MEM_OK) -version 1.2.2beta2 [February 23, 2002] - Check chunk_length and idat_size for invalid (over PNG_MAX_UINT) lengths. - Check for invalid image dimensions in png_get_IHDR. - Added missing "fi;" in the install target of the SGI makefiles. - Added install-static to all makefiles that make shared libraries. - Always do gamma compensation when image is partially transparent. -version 1.2.2beta3 [March 7, 2002] - Compute background.gray and background_1.gray even when color_type is RGB - in case image gets reduced to gray later. - Modified shared-library makefiles to install pkgconfig/libpngNN.pc. - Export (with PNGAPI) png_zalloc, png_zfree, and png_handle_as_unknown - Removed unused png_write_destroy_info prototype from png.h - Eliminated incorrect use of width_mmx from pnggccrd.c in pixel_bytes == 8 case - Added install-shared target to all makefiles that make shared libraries. - Stopped a double free of palette, hist, and trans when not using free_me. - Added makefile.32sunu for Sun Ultra 32 and makefile.64sunu for Sun Ultra 64. -version 1.2.2beta4 [March 8, 2002] - Compute background.gray and background_1.gray even when color_type is RGB - in case image gets reduced to gray later (Jason Summers). - Relocated a misplaced /bin/rm in the "install-shared" makefile targets - Added PNG_1_0_X macro which can be used to build a 1.0.x-compatible library. -version 1.2.2beta5 [March 26, 2002] - Added missing PNGAPI to several function definitions. - Check for invalid bit_depth or color_type in png_get_IHDR(), and - check for missing PLTE or IHDR in png_push_read_chunk() (Matthias Clasen). - Revised iTXt support to accept NULL for lang and lang_key. - Compute gamma for color components of background even when color_type is gray. - Changed "()" to "{}" in scripts/libpng.pc.in. - Revised makefiles to put png.h and pngconf.h only in $prefix/include/libpngNN - Revised makefiles to make symlink to libpng.so.NN in addition to libpngNN.so -version 1.2.2beta6 [March 31, 2002] -version 1.0.13beta1 [March 31, 2002] - Prevent png_zalloc() from trying to memset memory that it failed to acquire. - Add typecasts of PNG_MAX_UINT in pngset_cHRM_fixed() (Matt Holgate). - Ensure that the right function (user or default) is used to free the - png_struct after an error in png_create_read_struct_2(). -version 1.2.2rc1 [April 7, 2002] -version 1.0.13rc1 [April 7, 2002] - Save the ebx register in pnggccrd.c (Sami Farin) - Add "mem_ptr = png_ptr->mem_ptr" in png_destroy_write_struct() (Paul Gardner). - Updated makefiles to put headers in include/libpng and remove old include/*.h. - -version 1.2.2 [April 15, 2002] -version 1.0.13 [April 15, 2002] - Revised description of png_set_filter() in libpng.3/libpng.txt. - Revised makefile.netbsd and added makefile.neNNbsd and makefile.freebsd -version 1.0.13patch01 [April 17, 2002] -version 1.2.2patch01 [April 17, 2002] - Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and makefile.sggcc - Fixed VER -> PNGVER typo in makefile.macosx and added install-static to install - Added install: target to makefile.32sunu and makefile.64sunu -version 1.0.13patch03 [April 18, 2002] -version 1.2.2patch03 [April 18, 2002] - Revised 15 makefiles to link libpng.a to libpngNN.a and the include libpng - subdirectory to libpngNN subdirectory without the full pathname. - Moved generation of libpng.pc from "install" to "all" in 15 makefiles. -version 1.2.3rc1 [April 28, 2002] - Added install-man target to 15 makefiles (Dimitri Papadopolous-Orfanos). - Added $(DESTDIR) feature to 24 makefiles (Tim Mooney) - Fixed bug with $prefix, should be $(prefix) in makefile.hpux. - Updated cygwin-specific portion of pngconf.h and revised makefile.cygwin - Added a link from libpngNN.pc to libpng.pc in 15 makefiles. - Added links from include/libpngNN/*.h to include/*.h in 24 makefiles. - Revised makefile.darwin to make relative links without full pathname. - Added setjmp() at the end of png_create_*_struct_2() in case user forgets - to put one in their application. - Restored png_zalloc() and png_zfree() prototypes to version 1.2.1 and - removed them from module definition files. -version 1.2.3rc2 [May 1, 2002] - Fixed bug in reporting number of channels in pngget.c and pngset.c, - that was introduced in version 1.2.2beta5. - Exported png_zalloc(), png_zfree(), png_default_read(), png_default_write(), - png_default_flush(), and png_push_fill_buffer() and included them in - module definition files. - Added "libpng.pc" dependency to the "install-shared" target in 15 makefiles. -version 1.2.3rc3 [May 1, 2002] - Revised prototype for png_default_flush() - Remove old libpng.pc and libpngNN.pc before installing new ones. -version 1.2.3rc4 [May 2, 2002] - Typos in *.def files (png_default_read|write -> png_default_read|write_data) - In makefiles, changed rm libpng.NN.pc to rm libpngNN.pc - Added libpng-config and libpngNN-config and modified makefiles to install them. - Changed $(MANPATH) to $(DESTDIR)$(MANPATH) in makefiles - Added "Win32 DLL VB" configuration to projects/msvc/libpng.dsp -version 1.2.3rc5 [May 11, 2002] - Changed "error" and "message" in prototypes to "error_message" and - "warning_message" to avoid namespace conflict. - Revised 15 makefiles to build libpng-config from libpng-config-*.in - Once more restored png_zalloc and png_zfree to regular nonexported form. - Restored png_default_read|write_data, png_default_flush, png_read_fill_buffer - to nonexported form, but with PNGAPI, and removed them from module def files. -version 1.2.3rc6 [May 14, 2002] - Removed "PNGAPI" from png_zalloc() and png_zfree() in png.c - Changed "Gz" to "Gd" in projects/msvc/libpng.dsp and zlib.dsp. - Removed leftover libpng-config "sed" script from four makefiles. - Revised libpng-config creating script in 16 makefiles. - -version 1.2.3 [May 22, 2002] - Revised libpng-config target in makefile.cygwin. - Removed description of png_set_mem_fn() from documentation. - Revised makefile.freebsd. - Minor cosmetic changes to 15 makefiles, e.g., $(DI) = $(DESTDIR)/$(INCDIR). - Revised projects/msvc/README.txt - Changed -lpng to -lpngNN in LDFLAGS in several makefiles. -version 1.2.4beta1 [May 24, 2002] - Added libpng.pc and libpng-config to "all:" target in 16 makefiles. - Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH) - Added missing "\" before closing double quote in makefile.gcmmx. - Plugged various memory leaks; added png_malloc_warn() and png_set_text_2() - functions. -version 1.2.4beta2 [June 25, 2002] - Plugged memory leak of png_ptr->current_text (Matt Holgate). - Check for buffer overflow before reading CRC in pngpread.c (Warwick Allison) - Added -soname to the loader flags in makefile.dec, makefile.sgi, and - makefile.sggcc. - Added "test-installed" target to makefile.linux, makefile.gcmmx, - makefile.sgi, and makefile.sggcc. -version 1.2.4beta3 [June 28, 2002] - Plugged memory leak of row_buf in pngtest.c when there is a png_error(). - Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data. - Added "test-installed" target to makefile.32sunu, makefile.64sunu, - makefile.beos, makefile.darwin, makefile.dec, makefile.macosx, - makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9. -version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002] - Added "test-installed" target to makefile.cygwin and makefile.sco. - Revised pnggccrd.c to be able to back out version 1.0.x via PNG_1_0_X macro. - -version 1.2.4 and 1.0.14 [July 8, 2002] - Changed png_warning() to png_error() when width is too large to process. -version 1.2.4patch01 [July 20, 2002] - Revised makefile.cygwin to use DLL number 12 instead of 13. -version 1.2.5beta1 [August 6, 2002] - Added code to contrib/gregbook/readpng2.c to ignore unused chunks. - Replaced toucan.png in contrib/gregbook (it has been corrupt since 1.0.11) - Removed some stray *.o files from contrib/gregbook. - Changed png_error() to png_warning() about "Too much data" in pngpread.c - and about "Extra compressed data" in pngrutil.c. - Prevent png_ptr->pass from exceeding 7 in png_push_finish_row(). - Updated makefile.hpgcc - Updated png.c and pnggccrd.c handling of return from png_mmx_support() -version 1.2.5beta2 [August 15, 2002] - Only issue png_warning() about "Too much data" in pngpread.c when avail_in - is nonzero. - Updated makefiles to install a separate libpng.so.3 with its own rpath. -version 1.2.5rc1 and 1.0.15rc1 [August 24, 2002] - Revised makefiles to not remove previous minor versions of shared libraries. -version 1.2.5rc2 and 1.0.15rc2 [September 16, 2002] - Revised 13 makefiles to remove "-lz" and "-L$(ZLIBLIB)", etc., from shared - library loader directive. - Added missing "$OBJSDLL" line to makefile.gcmmx. - Added missing "; fi" to makefile.32sunu. -version 1.2.5rc3 and 1.0.15rc3 [September 18, 2002] - Revised libpng-config script. - -version 1.2.5 and 1.0.15 [October 3, 2002] - Revised makefile.macosx, makefile.darwin, makefile.hpgcc, and makefile.hpux, - and makefile.aix. - Relocated two misplaced PNGAPI lines in pngtest.c -version 1.2.6beta1 [October 22, 2002] - Commented out warning about uninitialized mmx_support in pnggccrd.c. - Changed "IBMCPP__" flag to "__IBMCPP__" in pngconf.h. - Relocated two more misplaced PNGAPI lines in pngtest.c - Fixed memory overrun bug in png_do_read_filler() with 16-bit datastreams, - introduced in version 1.0.2. - Revised makefile.macosx, makefile.dec, makefile.aix, and makefile.32sunu. -version 1.2.6beta2 [November 1, 2002] - Added libpng-config "--ldopts" output. - Added "AR=ar" and "ARFLAGS=rc" and changed "ar rc" to "$(AR) $(ARFLAGS)" - in makefiles. -version 1.2.6beta3 [July 18, 2004] - Reverted makefile changes from version 1.2.6beta2 and some of the changes - from version 1.2.6beta1; these will be postponed until version 1.2.7. - Version 1.2.6 is going to be a simple bugfix release. - Changed the one instance of "ln -sf" to "ln -f -s" in each Sun makefile. - Fixed potential overrun in pngerror.c by using strncpy instead of memcpy. - Added "#!/bin/sh" at the top of configure, for recognition of the - 'x' flag under Cygwin (Cosmin). - Optimized vacuous tests that silence compiler warnings, in png.c (Cosmin). - Added support for PNG_USER_CONFIG, in pngconf.h (Cosmin). - Fixed the special memory handler for Borland C under DOS, in pngmem.c - (Cosmin). - Removed some spurious assignments in pngrutil.c (Cosmin). - Replaced 65536 with 65536L, and 0xffff with 0xffffL, to silence warnings - on 16-bit platforms (Cosmin). - Enclosed shift op expressions in parentheses, to silence warnings (Cosmin). - Used proper type png_fixed_point, to avoid problems on 16-bit platforms, - in png_handle_sRGB() (Cosmin). - Added compression_type to png_struct, and optimized the window size - inside the deflate stream (Cosmin). - Fixed definition of isnonalpha(), in pngerror.c and pngrutil.c (Cosmin). - Fixed handling of unknown chunks that come after IDAT (Cosmin). - Allowed png_error() and png_warning() to work even if png_ptr == NULL - (Cosmin). - Replaced row_info->rowbytes with row_bytes in png_write_find_filter() - (Cosmin). - Fixed definition of PNG_LIBPNG_VER_DLLNUM (Simon-Pierre). - Used PNG_LIBPNG_VER and PNG_LIBPNG_VER_STRING instead of the hardcoded - values in png.c (Simon-Pierre, Cosmin). - Initialized png_libpng_ver[] with PNG_LIBPNG_VER_STRING (Simon-Pierre). - Replaced PNG_LIBPNG_VER_MAJOR with PNG_LIBPNG_VER_DLLNUM in png.rc - (Simon-Pierre). - Moved the definition of PNG_HEADER_VERSION_STRING near the definitions - of the other PNG_LIBPNG_VER_... symbols in png.h (Cosmin). - Relocated #ifndef PNGAPI guards in pngconf.h (Simon-Pierre, Cosmin). - Updated scripts/makefile.vc(a)win32 (Cosmin). - Updated the MSVC project (Simon-Pierre, Cosmin). - Updated the Borland C++ Builder project (Cosmin). - Avoided access to asm_flags in pngvcrd.c, if PNG_1_0_X is defined (Cosmin). - Commented out warning about uninitialized mmx_support in pngvcrd.c (Cosmin). - Removed scripts/makefile.bd32 and scripts/pngdef.pas (Cosmin). - Added extra guard around inclusion of Turbo C memory headers, in pngconf.h - (Cosmin). - Renamed projects/msvc/ to projects/visualc6/, and projects/borland/ to - projects/cbuilder5/ (Cosmin). - Moved projects/visualc6/png32ms.def to scripts/pngw32.def, - and projects/visualc6/png.rc to scripts/pngw32.rc (Cosmin). - Added projects/visualc6/pngtest.dsp; removed contrib/msvctest/ (Cosmin). - Changed line endings to DOS style in cbuilder5 and visualc6 files, even - in the tar.* distributions (Cosmin). - Updated contrib/visupng/VisualPng.dsp (Cosmin). - Updated contrib/visupng/cexcept.h to version 2.0.0 (Cosmin). - Added a separate distribution with "configure" and supporting files (Junichi). -version 1.2.6beta4 [July 28, 2004] - Added user ability to change png_size_t via a PNG_SIZE_T macro. - Added png_sizeof() and png_convert_size() functions. - Added PNG_SIZE_MAX (maximum value of a png_size_t variable. - Added check in png_malloc_default() for (size_t)size != (png_uint_32)size - which would indicate an overflow. - Changed sPLT failure action from png_error to png_warning and abandon chunk. - Changed sCAL and iCCP failures from png_error to png_warning and abandon. - Added png_get_uint_31(png_ptr, buf) function. - Added PNG_UINT_32_MAX macro. - Renamed PNG_MAX_UINT to PNG_UINT_31_MAX. - Made png_zalloc() issue a png_warning and return NULL on potential - overflow. - Turn on PNG_NO_ZALLOC_ZERO by default in version 1.2.x - Revised "clobber list" in pnggccrd.c so it will compile under gcc-3.4. - Revised Borland portion of png_malloc() to return NULL or issue - png_error() according to setting of PNG_FLAG_MALLOC_NULL_MEM_OK. - Added PNG_NO_SEQUENTIAL_READ_SUPPORTED macro to conditionally remove - sequential read support. - Added some "#if PNG_WRITE_SUPPORTED" blocks. - #ifdef'ed out some redundancy in png_malloc_default(). - Use png_malloc instead of png_zalloc to allocate the pallete. -version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004] - Fixed buffer overflow vulnerability in png_handle_tRNS() - Fixed integer arithmetic overflow vulnerability in png_read_png(). - Fixed some harmless bugs in png_handle_sBIT, etc, that would cause - duplicate chunk types to go undetected. - Fixed some timestamps in the -config version - Rearranged order of processing of color types in png_handle_tRNS(). - Added ROWBYTES macro to calculate rowbytes without integer overflow. - Updated makefile.darwin and removed makefile.macosx from scripts directory. - Imposed default one million column, one-million row limits on the image - dimensions, and added png_set_user_limits() function to override them. - Revised use of PNG_SET_USER_LIMITS_SUPPORTED macro. - Fixed wrong cast of returns from png_get_user_width|height_max(). - Changed some "keep the compiler happy" from empty statements to returns, - Revised libpng.txt to remove 1.2.x stuff from the 1.0.x distribution -version 1.0.16rc2 and 1.2.6rc2 [August 7, 2004] - Revised makefile.darwin and makefile.solaris. Removed makefile.macosx. - Revised pngtest's png_debug_malloc() to use png_malloc() instead of - png_malloc_default() which is not supposed to be exported. - Fixed off-by-one error in one of the conversions to PNG_ROWBYTES() in - pngpread.c. Bug was introduced in 1.2.6rc1. - Fixed bug in RGB to RGBX transformation introduced in 1.2.6rc1. - Fixed old bug in RGB to Gray transformation. - Fixed problem with 64-bit compilers by casting arguments to abs() - to png_int_32. - Changed "ln -sf" to "ln -f -s" in three makefiles (solaris, sco, so9). - Changed "HANDLE_CHUNK_*" to "PNG_HANDLE_CHUNK_*" (Cosmin) - Added "-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)" to 15 *NIX makefiles. - Added code to update the row_info->colortype in png_do_read_filler() (MSB). -version 1.0.16rc3 and 1.2.6rc3 [August 9, 2004] - Eliminated use of "abs()" in testing cHRM and gAMA values, to avoid - trouble with some 64-bit compilers. Created PNG_OUT_OF_RANGE() macro. - Revised documentation of png_set_keep_unknown_chunks(). - Check handle_as_unknown status in pngpread.c, as in pngread.c previously. - Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_INTERNAL section of png.h - Added "rim" definitions for CONST4 and CONST6 in pnggccrd.c -version 1.0.16rc4 and 1.2.6rc4 [August 10, 2004] - Fixed mistake in pngtest.c introduced in 1.2.6rc2 (declaration of - "pinfo" was out of place). -version 1.0.16rc5 and 1.2.6rc5 [August 10, 2004] - Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_ASSEMBLER_CODE_SUPPORTED - section of png.h where they were inadvertently placed in version rc3. - -version 1.2.6 and 1.0.16 [August 15, 2004] - Revised pngtest so memory allocation testing is only done when PNG_DEBUG==1. -version 1.2.7beta1 [August 26, 2004] - Removed unused pngasmrd.h file. - Removed references to uu.net for archived files. Added references to - PNG Spec (second edition) and the PNG ISO/IEC Standard. - Added "test-dd" target in 15 makefiles, to run pngtest in DESTDIR. - Fixed bug with "optimized window size" in the IDAT datastream, that - causes libpng to write PNG files with incorrect zlib header bytes. -version 1.2.7beta2 [August 28, 2004] - Fixed bug with sCAL chunk and big-endian machines (David Munro). - Undid new code added in 1.2.6rc2 to update the color_type in - png_set_filler(). - Added png_set_add_alpha() that updates color type. -version 1.0.17rc1 and 1.2.7rc1 [September 4, 2004] - Revised png_set_strip_filler() to not remove alpha if color_type has alpha. - -version 1.2.7 and 1.0.17 [September 12, 2004] - Added makefile.hp64 - Changed projects/msvc/png32ms.def to scripts/png32ms.def in makefile.cygwin -version 1.2.8beta1 [November 1, 2004] - Fixed bug in png_text_compress() that would fail to complete a large block. - Fixed bug, introduced in libpng-1.2.7, that overruns a buffer during - strip alpha operation in png_do_strip_filler(). - Added PNG_1_2_X definition in pngconf.h - #ifdef out png_info_init in png.c and png_read_init in pngread.c (as of 1.3.0) -version 1.2.8beta2 [November 2, 2004] - Reduce color_type to a nonalpha type after strip alpha operation in - png_do_strip_filler(). -version 1.2.8beta3 [November 3, 2004] - Revised definitions of PNG_MAX_UINT_32, PNG_MAX_SIZE, and PNG_MAXSUM -version 1.2.8beta4 [November 12, 2004] - Fixed (again) definition of PNG_LIBPNG_VER_DLLNUM in png.h (Cosmin). - Added PNG_LIBPNG_BUILD_PRIVATE in png.h (Cosmin). - Set png_ptr->zstream.data_type to Z_BINARY, to avoid unnecessary detection - of data type in deflate (Cosmin). - Deprecated but continue to support SPECIALBUILD and PRIVATEBUILD in favor of - PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING. -version 1.2.8beta5 [November 20, 2004] - Use png_ptr->flags instead of png_ptr->transformations to pass - PNG_STRIP_ALPHA info to png_do_strip_filler(), to preserve ABI - compatibility. - Revised handling of SPECIALBUILD, PRIVATEBUILD, - PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING. -version 1.2.8rc1 [November 24, 2004] - Moved handling of BUILD macros from pngconf.h to png.h - Added definition of PNG_LIBPNG_BASE_TYPE in png.h, inadvertently - omitted from beta5. - Revised scripts/pngw32.rc - Despammed mailing addresses by masking "@" with "at". - Inadvertently installed a supposedly faster test version of pngrutil.c -version 1.2.8rc2 [November 26, 2004] - Added two missing "\" in png.h - Change tests in pngread.c and pngpread.c to - if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) - png_do_read_transformations(png_ptr); -version 1.2.8rc3 [November 28, 2004] - Reverted pngrutil.c to version libpng-1.2.8beta5. - Added scripts/makefile.elf with supporting code in pngconf.h for symbol - versioning (John Bowler). -version 1.2.8rc4 [November 29, 2004] - Added projects/visualc7 (Simon-pierre). -version 1.2.8rc5 [November 29, 2004] - Fixed new typo in scripts/pngw32.rc - -version 1.2.8 [December 3, 2004] - Removed projects/visualc7, added projects/visualc71. - -version 1.2.9beta1 [February 21, 2006] - - Initialized some structure members in pngwutil.c to avoid gcc-4.0.0 complaints - Revised man page and libpng.txt to make it clear that one should not call - png_read_end or png_write_end after png_read_png or png_write_png. - Updated references to png-mng-implement mailing list. - Fixed an incorrect typecast in pngrutil.c - Added PNG_NO_READ_SUPPORTED conditional for making a write-only library. - Added PNG_NO_WRITE_INTERLACING_SUPPORTED conditional. - Optimized alpha-inversion loops in pngwtran.c - Moved test for nonzero gamma outside of png_build_gamma_table() in pngrtran.c - Make sure num_trans is <= 256 before copying data in png_set_tRNS(). - Make sure num_palette is <= 256 before copying data in png_set_PLTE(). - Interchanged order of write_swap_alpha and write_invert_alpha transforms. - Added parentheses in the definition of PNG_LIBPNG_BUILD_TYPE (Cosmin). - Optimized zlib window flag (CINFO) in contrib/pngsuite/*.png (Cosmin). - Updated scripts/makefile.bc32 for Borland C++ 5.6 (Cosmin). - Exported png_get_uint_32, png_save_uint_32, png_get_uint_16, png_save_uint_16, - png_get_int_32, png_save_int_32, png_get_uint_31 (Cosmin). - Added type cast (png_byte) in png_write_sCAL() (Cosmin). - Fixed scripts/makefile.cygwin (Christian Biesinger, Cosmin). - Default iTXt support was inadvertently enabled. - -version 1.2.9beta2 [February 21, 2006] - - Check for png_rgb_to_gray and png_gray_to_rgb read transformations before - checking for png_read_dither in pngrtran.c - Revised checking of chromaticity limits to accommodate extended RGB - colorspace (John Denker). - Changed line endings in some of the project files to CRLF, even in the - "Unix" tar distributions (Cosmin). - Made png_get_int_32 and png_save_int_32 always available (Cosmin). - Updated scripts/pngos2.def, scripts/pngw32.def and projects/wince/png32ce.def - with the newly exported functions. - Eliminated distributions without the "configure" script. - Updated INSTALL instructions. - -version 1.2.9beta3 [February 24, 2006] - - Fixed CRCRLF line endings in contrib/visupng/VisualPng.dsp - Made libpng.pc respect EXEC_PREFIX (D. P. Kreil, J. Bowler) - Removed reference to pngasmrd.h from Makefile.am - Renamed CHANGES to ChangeLog. - Renamed LICENSE to COPYING. - Renamed ANNOUNCE to NEWS. - Created AUTHORS file. - -version 1.2.9beta4 [March 3, 2006] - - Changed definition of PKGCONFIG from $prefix/lib to $libdir in configure.ac - Reverted to filenames LICENSE and ANNOUNCE; removed AUTHORS and COPYING. - Removed newline from the end of some error and warning messages. - Removed test for sqrt() from configure.ac and configure. - Made swap tables in pngtrans.c PNG_CONST (Carlo Bramix). - Disabled default iTXt support that was inadvertently enabled in - libpng-1.2.9beta1. - Added "OS2" to list of systems that don't need underscores, in pnggccrd.c - Removed libpng version and date from *.c files. - -version 1.2.9beta5 [March 4, 2006] - Removed trailing blanks from source files. - Put version and date of latest change in each source file, and changed - copyright year accordingly. - More cleanup of configure.ac, Makefile.ac, and associated scripts. - Restored scripts/makefile.elf which was inadvertently deleted. - -version 1.2.9beta6 [March 6, 2006] - Fixed typo (16) in configuration files. - -version 1.2.9beta7 [March 7, 2006] - Removed libpng.vers and libpng.sym from libpng12_la_SOURCES in Makefile.am - Fixed inconsistent #ifdef's around png_sig_bytes() and png_set_sCAL_s() - in png.h. - Updated makefile.elf as suggested by debian. - Made cosmetic changes to some makefiles, adding LN_SF and other macros. - Made some makefiles accept "exec_prefix". - -version 1.2.9beta8 [March 9, 2006] - Fixed some "#if defined (..." which should be "#if defined(..." - Bug introduced in libpng-1.2.8. - Fixed inconsistency in definition of png_default_read_data() - Restored blank that was lost from makefile.sggcc "clean" target in beta7. - Revised calculation of "current" and "major" for irix in ltmain.sh - Changed "mkdir" to "MKDIR_P" in some makefiles. - Separated PNG_EXPAND and PNG_EXPAND_tRNS. - Added png_set_expand_gray_1_2_4_to_8() and deprecated - png_set_gray_1_2_4_to_8() which also expands tRNS to alpha. - -version 1.2.9beta9 [March 10, 2006] - Include "config.h" in pngconf.h when available. - Added some checks for NULL png_ptr or NULL info_ptr (timeless) - -version 1.2.9beta10 [March 20, 2006] - Removed extra CR from contrib/visualpng/VisualPng.dsw (Cosmin) - Made pnggccrd.c PIC-compliant (Christian Aichinger). - Added makefile.mingw (Wolfgang Glas). - Revised pngconf.h MMX checking. - -version 1.2.9beta11 [March 22, 2006] - Fixed out-of-order declaration in pngwrite.c that was introduced in beta9 - Simplified some makefiles by using LIBSO, LIBSOMAJ, and LIBSOVER macros. - -version 1.2.9rc1 [March 31, 2006] - Defined PNG_USER_PRIVATEBUILD when including "pngusr.h" (Cosmin). - Removed nonsensical assertion check from pngtest.c (Cosmin). - -version 1.2.9 [April 14, 2006] - Revised makefile.beos and added "none" selector in ltmain.sh - -version 1.2.10beta1 [April 15, 2006] - Renamed "config.h" to "png_conf.h" and revised Makefile.am to add - -DPNG_BUILDING_LIBPNG to compile directive, and modified pngconf.h - to include png_conf.h only when PNG_BUILDING_LIBPNG is defined. - -version 1.2.10beta2 [April 15, 2006] - Manually updated Makefile.in and configure. Changed png_conf.h.in - back to config.h. - -version 1.2.10beta3 [April 15, 2006] - Change png_conf.h back to config.h in pngconf.h. - -version 1.2.10beta4 [April 16, 2006] - Change PNG_BUILDING_LIBPNG to PNG_CONFIGURE_LIBPNG in config/Makefile*. - -version 1.2.10beta5 [April 16, 2006] - Added a configure check for compiling assembler code in pnggccrd.c - -version 1.2.10beta6 [April 17, 2006] - Revised the configure check for pnggccrd.c - Moved -DPNG_CONFIGURE_LIBPNG into @LIBPNG_DEFINES@ - Added @LIBPNG_DEFINES@ to arguments when building libpng.sym - -version 1.2.10beta7 [April 18, 2006] - Change "exec_prefix=$prefix" to "exec_prefix=$(prefix)" in makefiles. - -version 1.2.10rc1 [April 19, 2006] - Ensure pngconf.h doesn't define both PNG_USE_PNGGCCRD and PNG_USE_PNGVCRD - Fixed "LN_FS" typo in makefile.sco and makefile.solaris. - -version 1.2.10rc2 [April 20, 2006] - Added a backslash between -DPNG_CONFIGURE_LIBPNG and -DPNG_NO_ASSEMBLER_CODE - in configure.ac and configure - Made the configure warning about versioned symbols less arrogant. - -version 1.2.10rc3 [April 21, 2006] - Added a note in libpng.txt that png_set_sig_bytes(8) can be used when - writing an embedded PNG without the 8-byte signature. - Revised makefiles and configure to avoid making links to libpng.so.* - -version 1.2.10 [April 23, 2006] - Reverted configure to "rc2" state. - -version 1.2.11beta1 [May 31, 2006] - scripts/libpng.pc.in contained "configure" style version info and would - not work with makefiles. - The shared-library makefiles were linking to libpng.so.0 instead of - libpng.so.3 compatibility as the library. - -version 1.2.11beta2 [June 2, 2006] - Increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid - buffer overflow. - Fixed bug in example.c (png_set_palette_rgb -> png_set_palette_to_rgb) - -version 1.2.11beta3 [June 5, 2006] - Prepended "#! /bin/sh" to ltmail.sh and contrib/pngminus/*.sh (Cosmin). - Removed the accidental leftover Makefile.in~ (Cosmin). - Avoided potential buffer overflow and optimized buffer in - png_write_sCAL(), png_write_sCAL_s() (Cosmin). - Removed the include directories and libraries from CFLAGS and LDFLAGS - in scripts/makefile.gcc (Nelson A. de Oliveira, Cosmin). - -version 1.2.11beta4 [June 6, 2006] - Allow zero-length IDAT chunks after the entire zlib datastream, but not - after another intervening chunk type. - -version 1.0.19rc1, 1.2.11rc1 [June 13, 2006] - Deleted extraneous square brackets from [config.h] in configure.ac - -version 1.0.19rc2, 1.2.11rc2 [June 14, 2006] - Added prototypes for PNG_INCH_CONVERSIONS functions to png.h - Revised INSTALL and autogen.sh - Fixed typo in several makefiles (-W1 should be -Wl) - Added typedef for png_int_32 and png_uint_32 on 64-bit systems. - -version 1.0.19rc3, 1.2.11rc3 [June 15, 2006] - Removed the new typedefs for 64-bit systems (delay until version 1.4.0) - Added one zero element to png_gamma_shift[] array in pngrtran.c to avoid - reading out of bounds. - -version 1.0.19rc4, 1.2.11rc4 [June 15, 2006] - Really removed the new typedefs for 64-bit systems. - -version 1.0.19rc5, 1.2.11rc5 [June 22, 2006] - Removed png_sig_bytes entry from scripts/pngw32.def - -version 1.0.19, 1.2.11 [June 26, 2006] - None. - -version 1.0.20, 1.2.12 [June 27, 2006] - Really increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid - buffer overflow. - -version 1.2.13beta1 [October 2, 2006] - Removed AC_FUNC_MALLOC from configure.ac - Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h - Change "logical" to "bitwise" throughout documentation. - Detect and fix attempt to write wrong iCCP profile length. - -version 1.0.21, 1.2.13 [November 14, 2006] - Fix potential buffer overflow in sPLT chunk handler. - Fix Makefile.am to not try to link to noexistent files. - Check all exported functions for NULL png_ptr. - -version 1.2.14beta1 [November 17, 2006] - Relocated three misplaced tests for NULL png_ptr. - Built Makefile.in with automake-1.9.6 instead of 1.9.2. - Build configure with autoconf-2.60 instead of 2.59 - -version 1.2.14beta2 [November 17, 2006] - Added some typecasts in png_zalloc(). - -version 1.2.14rc1 [November 20, 2006] - Changed "strtod" to "png_strtod" in pngrutil.c - -version 1.0.22, 1.2.14 [November 27, 2006] - Added missing "$(srcdir)" in Makefile.am and Makefile.in - -version 1.2.15beta1 [December 3, 2006] - Generated configure with autoconf-2.61 instead of 2.60 - Revised configure.ac to update libpng.pc and libpng-config. - -version 1.2.15beta2 [December 3, 2006] - Always export MMX asm functions, just stubs if not building pnggccrd.c - -version 1.2.15beta3 [December 4, 2006] - Add "png_bytep" typecast to profile while calculating length in pngwutil.c - -version 1.2.15beta4 [December 7, 2006] - Added scripts/CMakeLists.txt - Changed PNG_NO_ASSEMBLER_CODE to PNG_NO_MMX_CODE in scripts, like 1.4.0beta - -version 1.2.15beta5 [December 7, 2006] - Changed some instances of PNG_ASSEMBLER_* to PNG_MMX_* in pnggccrd.c - Revised scripts/CMakeLists.txt - -version 1.2.15beta6 [December 13, 2006] - Revised scripts/CMakeLists.txt and configure.ac - -version 1.2.15rc1 [December 18, 2006] - Revised scripts/CMakeLists.txt - -version 1.2.15rc2 [December 21, 2006] - Added conditional #undef jmpbuf in pngtest.c to undo #define in AIX headers. - Added scripts/makefile.nommx - -version 1.2.15rc3 [December 25, 2006] - Fixed shared library numbering error that was intruduced in 1.2.15beta6. - -version 1.2.15rc4 [December 27, 2006] - Fixed handling of rgb_to_gray when png_ptr->color.gray isn't set. - -version 1.2.15rc5 [December 31, 2006] - Revised handling of rgb_to_gray. - -version 1.2.15 [January 5, 2007] - Added some (unsigned long) typecasts in pngtest.c to avoid printing errors. - -version 1.2.16beta1 [January 6, 2007] - Fix bugs in makefile.nommx - -version 1.2.16beta2 [January 16, 2007] - Revised scripts/CMakeLists.txt - -version 1.2.16 [January 31, 2007] - No changes. - -Send comments/corrections/commendations to png-mng-implement at lists.sf.net -(subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe) -or to glennrp at users.sourceforge.net - -Glenn R-P + +CHANGES - changes for libpng + +version 0.2 + added reader into png.h + fixed small problems in stub file + +version 0.3 + added pull reader + split up pngwrite.c to several files + added pnglib.txt + added example.c + cleaned up writer, adding a few new transformations + fixed some bugs in writer + interfaced with zlib 0.5 + added K&R support + added check for 64 KB blocks for 16 bit machines + +version 0.4 + cleaned up code and commented code + simplified time handling into png_time + created png_color_16 and png_color_8 to handle color needs + cleaned up color type defines + fixed various bugs + made various names more consistent + interfaced with zlib 0.71 + cleaned up zTXt reader and writer (using zlib's Reset functions) + split transformations into pngrtran.c and pngwtran.c + +version 0.5 + interfaced with zlib 0.8 + fixed many reading and writing bugs + saved using 3 spaces instead of tabs + +version 0.6 + added png_large_malloc() and png_large_free() + added png_size_t + cleaned up some compiler warnings + added png_start_read_image() + +version 0.7 + cleaned up lots of bugs + finished dithering and other stuff + added test program + changed name from pnglib to libpng + +version 0.71 [June, 1995] + changed pngtest.png for zlib 0.93 + fixed error in libpng.txt and example.c + +version 0.8 + cleaned up some bugs + added png_set_filler() + split up pngstub.c into pngmem.c, pngio.c, and pngerror.c + added #define's to remove unwanted code + moved png_info_init() to png.c + added old_size into png_realloc() + added functions to manually set filtering and compression info + changed compression parameters based on image type + optimized filter selection code + added version info + changed external functions passing floats to doubles (k&r problems?) + put all the configurable stuff in pngconf.h + enabled png_set_shift to work with paletted images on read + added png_read_update_info() - updates info structure with + transformations + +version 0.81 [August, 1995] + incorporated Tim Wegner's medium model code (thanks, Tim) + +version 0.82 [September, 1995] + [unspecified changes] + +version 0.85 [December, 1995] + added more medium model code (almost everything's a far) + added i/o, error, and memory callback functions + fixed some bugs (16 bit, 4 bit interlaced, etc.) + added first run progressive reader (barely tested) + +version 0.86 [January, 1996] + fixed bugs + improved documentation + +version 0.87 [January, 1996] + fixed medium model bugs + fixed other bugs introduced in 0.85 and 0.86 + added some minor documentation + +version 0.88 [January, 1996] + fixed progressive bugs + replaced tabs with spaces + cleaned up documentation + added callbacks for read/write and warning/error functions + +version 0.89 [July, 1996] + added new initialization API to make libpng work better with shared libs + we now have png_create_read_struct(), png_create_write_struct(), + png_create_info_struct(), png_destroy_read_struct(), and + png_destroy_write_struct() instead of the separate calls to + malloc and png_read_init(), png_info_init(), and png_write_init() + changed warning/error callback functions to fix bug - this means you + should use the new initialization API if you were using the old + png_set_message_fn() calls, and that the old API no longer exists + so that people are aware that they need to change their code + changed filter selection API to allow selection of multiple filters + since it didn't work in previous versions of libpng anyways + optimized filter selection code + fixed png_set_background() to allow using an arbitrary RGB color for + paletted images + fixed gamma and background correction for paletted images, so + png_correct_palette is not needed unless you are correcting an + external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED + in pngconf.h) - if nobody uses this, it may disappear in the future. + fixed bug with Borland 64K memory allocation (Alexander Lehmann) + fixed bug in interlace handling (Smarasderagd, I think) + added more error checking for writing and image to reduce invalid files + separated read and write functions so that they won't both be linked + into a binary when only reading or writing functionality is used + new pngtest image also has interlacing and zTXt + updated documentation to reflect new API + +version 0.90 [January, 1997] + made CRC errors/warnings on critical and ancillary chunks configurable + libpng will use the zlib CRC routines by (compile-time) default + changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner) + added external C++ wrapper statements to png.h (Gilles Dauphin) + allow PNG file to be read when some or all of file signature has already + been read from the beginning of the stream. ****This affects the size + of info_struct and invalidates all programs that use a shared libpng**** + fixed png_filler() declarations + fixed? background color conversions + fixed order of error function pointers to match documentation + current chunk name is now available in png_struct to reduce the number + of nearly identical error messages (will simplify multi-lingual + support when available) + try to get ready for unknown-chunk callback functions: + - previously read critical chunks are flagged, so the chunk handling + routines can determine if the chunk is in the right place + - all chunk handling routines have the same prototypes, so we will + be able to handle all chunks via a callback mechanism + try to fix Linux "setjmp" buffer size problems + removed png_large_malloc, png_large_free, and png_realloc functions. + +version 0.95 [March, 1997] + fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never + fixed bug in PNG file signature compares when start != 0 + changed parameter type of png_set_filler(...filler...) from png_byte + to png_uint_32 + added test for MACOS to ensure that both math.h and fp.h are not #included + added macros for libpng to be compiled as a Windows DLL (Andreas Kupries) + added "packswap" transformation, which changes the endianness of + packed-pixel bytes (Kevin Bracey) + added "strip_alpha" transformation, which removes the alpha channel of + input images without using it (not necessarily a good idea) + added "swap_alpha" transformation, which puts the alpha channel in front + of the color bytes instead of after + removed all implicit variable tests which assume NULL == 0 (I think) + changed several variables to "png_size_t" to show 16/32-bit limitations + added new pCAL chunk read/write support + added experimental filter selection weighting (Greg Roelofs) + removed old png_set_rgbx() and png_set_xrgb() functions that have been + obsolete for about 2 years now (use png_set_filler() instead) + added macros to read 16- and 32-bit ints directly from buffer, to be + used only on those systems that support it (namely PowerPC and 680x0) + With some testing, this may become the default for MACOS/PPC systems. + only calculate CRC on data if we are going to use it + added macros for zTXt compression type PNG_zTXt_COMPRESSION_??? + added macros for simple libpng debugging output selectable at compile time + removed PNG_READ_END_MODE in progressive reader (Smarasderagd) + more description of info_struct in libpng.txt and png.h + more instructions in example.c + more chunk types tested in pngtest.c + renamed pngrcb.c to pngset.c, and all png_read_ functions to be + png_set_. We now have corresponding png_get_ + functions in pngget.c to get information in info_ptr. This isolates + the application from the internal organization of png_info_struct + (good for shared library implementations). + +version 0.96 [May, 1997] + fixed serious bug with < 8bpp images introduced in 0.95 + fixed 256-color transparency bug (Greg Roelofs) + fixed up documentation (Greg Roelofs, Laszlo Nyul) + fixed "error" in pngconf.h for Linux setjmp() behaviour + fixed DOS medium model support (Tim Wegner) + fixed png_check_keyword() for case with error in static string text + added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul) + added typecasts to quiet compiler errors + added more debugging info + +version 0.97 [January, 1998] + removed PNG_USE_OWN_CRC capability + relocated png_set_crc_action from pngrutil.c to pngrtran.c + fixed typecasts of "new_key", etc. (Andreas Dilger) + added RFC 1152 [sic] date support + fixed bug in gamma handling of 4-bit grayscale + added 2-bit grayscale gamma handling (Glenn R-P) + added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P) + minor corrections in libpng.txt + added simple sRGB support (Glenn R-P) + easier conditional compiling, e.g. define PNG_READ/WRITE_NOT_FULLY_SUPPORTED; + all configurable options can be selected from command-line instead + of having to edit pngconf.h (Glenn R-P) + fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P) + added more conditions for png_do_background, to avoid changing + black pixels to background when a background is supplied and + no pixels are transparent + repaired PNG_NO_STDIO behaviour + tested NODIV support and made it default behaviour (Greg Roelofs) + added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler) + regularized version numbering scheme and bumped shared-library major + version number to 2 to avoid problems with libpng 0.89 apps (Greg Roelofs) + +version 0.98 [January, 1998] + cleaned up some typos in libpng.txt and in code documentation + fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler) + cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c + changed recommendation about file_gamma for PC images to .51 from .45, + in example.c and libpng.txt, added comments to distinguish between + screen_gamma, viewing_gamma, and display_gamma. + changed all references to RFC1152 to read RFC1123 and changed the + PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED + added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent) + changed srgb_intent from png_byte to int to avoid compiler bugs + +version 0.99 [January 30, 1998] + free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler) + fixed a longstanding "packswap" bug in pngtrans.c + fixed some inconsistencies in pngconf.h that prevented compiling with + PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined + fixed some typos and made other minor rearrangement of libpng.txt (Andreas) + changed recommendation about file_gamma for PC images to .50 from .51 in + example.c and libpng.txt, and changed file_gamma for sRGB images to .45 + added a number of functions to access information from the png structure + png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit) + added TARGET_MACOS similar to zlib-1.0.8 + define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined + added type casting to all png_malloc() function calls +version 0.99a [January 31, 1998] + Added type casts and parentheses to all returns that return a value.(Tim W.) +version 0.99b [February 4, 1998] + Added type cast png_uint_32 on malloc function calls where needed. + Changed type of num_hist from png_uint_32 to int (same as num_palette). + Added checks for rowbytes overflow, in case png_size_t is less than 32 bits. + Renamed makefile.elf to makefile.lnx. +version 0.99c [February 7, 1998] + More type casting. Removed erroneous overflow test in pngmem.c. + Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes. + Added UNIX manual pages libpng.3 (incorporating libpng.txt) and png.5. +version 0.99d [February 11, 1998] + Renamed "far_to_near()" "png_far_to_near()" + Revised libpng.3 + Version 99c "buffered" operations didn't work as intended. Replaced them + with png_memcpy_check() and png_memset_check(). + Added many "if (png_ptr == NULL) return" to quell compiler warnings about + unused png_ptr, mostly in pngget.c and pngset.c. + Check for overlength tRNS chunk present when indexed-color PLTE is read. + Cleaned up spelling errors in libpng.3/libpng.txt + Corrected a problem with png_get_tRNS() which returned undefined trans array +version 0.99e [February 28, 1998] + Corrected png_get_tRNS() again. + Add parentheses for easier reading of pngget.c, fixed "||" should be "&&". + Touched up example.c to make more of it compileable, although the entire + file still can't be compiled (Willem van Schaik) + Fixed a bug in png_do_shift() (Bryan Tsai) + Added a space in png.h prototype for png_write_chunk_start() + Replaced pngtest.png with one created with zlib 1.1.1 + Changed pngtest to report PASS even when file size is different (Jean-loup G.) + Corrected some logic errors in png_do_invert_alpha() (Chris Patterson) +version 0.99f [March 5, 1998] + Corrected a bug in pngpread() introduced in version 99c (Kevin Bracey) + Moved makefiles into a "scripts" directory, and added INSTALL instruction file + Added makefile.os2 and pngos2.def (A. Zabolotny) and makefile.s2x (W. Sebok) + Added pointers to "note on libpng versions" in makefile.lnx and README + Added row callback feature when reading and writing nonprogressive rows + and added a test of this feature in pngtest.c + Added user transform callbacks, with test of the feature in pngtest.c +version 0.99g [March 6, 1998, morning] + Minor changes to pngtest.c to suppress compiler warnings. + Removed "beta" language from documentation. +version 0.99h [March 6, 1998, evening] + Minor changes to previous minor changes to pngtest.c + Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED + and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro + Added user transform capability + +version 1.00 [March 7, 1998] + Changed several typedefs in pngrutil.c + Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik) + replaced "while(1)" with "for(;;)" + added PNGARG() to prototypes in pngtest.c and removed some prototypes + updated some of the makefiles (Tom Lane) + changed some typedefs (s_start, etc.) in pngrutil.c + fixed dimensions of "short_months" array in pngwrite.c + Replaced ansi2knr.c with the one from jpeg-v6 + +version 1.0.0 [March 8, 1998] + Changed name from 1.00 to 1.0.0 (Adam Costello) + Added smakefile.ppc (with SCOPTIONS.ppc) for Amiga PPC (Andreas Kleinert) +version 1.0.0a [March 9, 1998] + Fixed three bugs in pngrtran.c to make gamma+background handling consistent + (Greg Roelofs) + Changed format of the PNG_LIBPNG_VER integer to xyyzz instead of xyz + for major, minor, and bugfix releases. This is 10001. (Adam Costello, + Tom Lane) + Make months range from 1-12 in png_convert_to_rfc1123 +version 1.0.0b [March 13, 1998] + Quieted compiler complaints about two empty "for" loops in pngrutil.c + Minor changes to makefile.s2x + Removed #ifdef/#endif around a png_free() in pngread.c + +version 1.0.1 [March 14, 1998] + Changed makefile.s2x to reduce security risk of using a relative pathname + Fixed some typos in the documentation (Greg). + Fixed a problem with value of "channels" returned by png_read_update_info() +version 1.0.1a [April 21, 1998] + Optimized Paeth calculations by replacing abs() function calls with intrinsics + plus other loop optimizations. Improves avg decoding speed by about 20%. + Commented out i386istic "align" compiler flags in makefile.lnx. + Reduced the default warning level in some makefiles, to make them consistent. + Removed references to IJG and JPEG in the ansi2knr.c copyright statement. + Fixed a bug in png_do_strip_filler with XXRRGGBB => RRGGBB transformation. + Added grayscale and 16-bit capability to png_do_read_filler(). + Fixed a bug in pngset.c, introduced in version 0.99c, that sets rowbytes + too large when writing an image with bit_depth < 8 (Bob Dellaca). + Corrected some bugs in the experimental weighted filtering heuristics. + Moved a misplaced pngrutil code block that truncates tRNS if it has more + than num_palette entries -- test was done before num_palette was defined. + Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins). + Changed compiler flags in makefile.wat for better optimization (Pawel Mrochen). +version 1.0.1b [May 2, 1998] + Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg). + Relocated the png_composite macros from pngrtran.c to png.h (Greg). + Added makefile.sco (contributed by Mike Hopkirk). + Fixed two bugs (missing definitions of "istop") introduced in libpng-1.0.1a. + Fixed a bug in pngrtran.c that would set channels=5 under some circumstances. + More work on the Paeth-filtering, achieving imperceptible speedup (A Kleinert). + More work on loop optimization which may help when compiled with C++ compilers. + Added warnings when people try to use transforms they've defined out. + Collapsed 4 "i" and "c" loops into single "i" loops in pngrtran and pngwtran. + Revised paragraph about png_set_expand() in libpng.txt and libpng.3 (Greg) +version 1.0.1c [May 11, 1998] + Fixed a bug in pngrtran.c (introduced in libpng-1.0.1a) where the masks for + filler bytes should have been 0xff instead of 0xf. + Added max_pixel_depth=32 in pngrutil.c when using FILLER with palette images. + Moved PNG_WRITE_WEIGHTED_FILTER_SUPPORTED and PNG_WRITE_FLUSH_SUPPORTED + out of the PNG_WRITE_TRANSFORMS_NOT_SUPPORTED block of pngconf.h + Added "PNG_NO_WRITE_TRANSFORMS" etc., as alternatives for *_NOT_SUPPORTED, + for consistency, in pngconf.h + Added individual "ifndef PNG_NO_[CAPABILITY]" in pngconf.h to make it easier + to remove unwanted capabilities via the compile line + Made some corrections to grammar (which, it's) in documentation (Greg). + Corrected example.c, use of row_pointers in png_write_image(). +version 1.0.1d [May 24, 1998] + Corrected several statements that used side effects illegally in pngrutil.c + and pngtrans.c, that were introduced in version 1.0.1b + Revised png_read_rows() to avoid repeated if-testing for NULL (A Kleinert) + More corrections to example.c, use of row_pointers in png_write_image() + and png_read_rows(). + Added pngdll.mak and pngdef.pas to scripts directory, contributed by + Bob Dellaca, to make a png32bd.dll with Borland C++ 4.5 + Fixed error in example.c with png_set_text: num_text is 3, not 2 (Guido V.) + Changed several loops from count-down to count-up, for consistency. +version 1.0.1e [June 6, 1998] + Revised libpng.txt and libpng.3 description of png_set_read|write_fn(), and + added warnings when people try to set png_read_fn and png_write_fn in + the same structure. + Added a test such that png_do_gamma will be done when num_trans==0 + for truecolor images that have defined a background. This corrects an + error that was introduced in libpng-0.90 that can cause gamma processing + to be skipped. + Added tests in png.h to include "trans" and "trans_values" in structures + when PNG_READ_BACKGROUND_SUPPORTED or PNG_READ_EXPAND_SUPPORTED is defined. + Add png_free(png_ptr->time_buffer) in png_destroy_read_struct() + Moved png_convert_to_rfc_1123() from pngwrite.c to png.c + Added capability for user-provided malloc_fn() and free_fn() functions, + and revised pngtest.c to demonstrate their use, replacing the + PNGTEST_DEBUG_MEM feature. + Added makefile.w32, for Microsoft C++ 4.0 and later (Tim Wegner). + +version 1.0.2 [June 14, 1998] + Fixed two bugs in makefile.bor . +version 1.0.2a [December 30, 1998] + Replaced and extended code that was removed from png_set_filler() in 1.0.1a. + Fixed a bug in png_do_filler() that made it fail to write filler bytes in + the left-most pixel of each row (Kevin Bracey). + Changed "static pngcharp tIME_string" to "static char tIME_string[30]" + in pngtest.c (Duncan Simpson). + Fixed a bug in pngtest.c that caused pngtest to try to write a tIME chunk + even when no tIME chunk was present in the source file. + Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit. + Fixed a problem in png_read_push_finish_row(), which would not skip some + passes that it should skip, for images that are less than 3 pixels high. + Interchanged the order of calls to png_do_swap() and png_do_shift() + in pngwtran.c (John Cromer). + Added #ifdef PNG_DEBUG/#endif surrounding use of PNG_DEBUG in png.h . + Changed "bad adaptive filter type" from error to warning in pngrutil.c . + Fixed a documentation error about default filtering with 8-bit indexed-color. + Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO + (L. Peter Deutsch). + Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions. + Added png_get_copyright() and png_get_header_version() functions. + Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c + Added information about debugging in libpng.txt and libpng.3 . + Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco. + Removed lines after Dynamic Dependencies" in makefile.aco . + Revised makefile.dec to make a shared library (Jeremie Petit). + Removed trailing blanks from all files. +version 1.0.2a [January 6, 1999] + Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h + Added "if" tests to silence complaints about unused png_ptr in png.h and png.c + Changed "check_if_png" function in example.c to return true (nonzero) if PNG. + Changed libpng.txt to demonstrate png_sig_cmp() instead of png_check_sig() + which is obsolete. + +version 1.0.3 [January 14, 1999] + Added makefile.hux, for Hewlett Packard HPUX 10.20 and 11.00 (Jim Rice) + Added a statement of Y2K compliance in png.h, libpng.3, and Y2KINFO. +version 1.0.3a [August 12, 1999] + Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning + if an attempt is made to read an interlaced image when it's not supported. + Added check if png_ptr->trans is defined before freeing it in pngread.c + Modified the Y2K statement to include versions back to version 0.71 + Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c + Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments) + Replaced leading blanks with tab characters in makefile.hux + Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents. + Changed (float)red and (float)green to (double)red, (double)green + in png_set_rgb_to_gray() to avoid "promotion" problems in AIX. + Fixed a bug in pngconf.h that omitted when PNG_DEBUG==0 (K Bracey). + Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt). + Updated documentation to refer to the PNG-1.2 specification. + Removed ansi2knr.c and left pointers to the latest source for ansi2knr.c + in makefile.knr, INSTALL, and README (L. Peter Deutsch) + Fixed bugs in calculation of the length of rowbytes when adding alpha + channels to 16-bit images, in pngrtran.c (Chris Nokleberg) + Added function png_set_user_transform_info() to store user_transform_ptr, + user_depth, and user_channels into the png_struct, and a function + png_get_user_transform_ptr() to retrieve the pointer (Chris Nokleberg) + Added function png_set_empty_plte_permitted() to make libpng useable + in MNG applications. + Corrected the typedef for png_free_ptr in png.h (Jesse Jones). + Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c, to be + consistent with PNG-1.2, and allow variance of 500 before complaining. + Added assembler code contributed by Intel in file pngvcrd.c and modified + makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, Gilles Vollant) + Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy. + Added some aliases for png_set_expand() in pngrtran.c, namely + png_set_expand_PLTE(), png_set_expand_depth(), and png_set_expand_tRNS() + (Greg Roelofs, in "PNG: The Definitive Guide"). + Added makefile.beo for BEOS on X86, contributed by Sander Stok. +version 1.0.3b [August 26, 1999] + Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h + Changed leading blanks to tabs in all makefiles. + Define PNG_USE_PNGVCRD in makefile.w32, to get MMX assembler code. + Made alternate versions of png_set_expand() in pngrtran.c, namely + png_set_gray_1_2_4_to_8, png_set_palette_to_rgb, and png_set_tRNS_to_alpha + (Greg Roelofs, in "PNG: The Definitive Guide"). Deleted the 1.0.3a aliases. + Relocated start of 'extern "C"' block in png.h so it doesn't include pngconf.h + Revised calculation of num_blocks in pngmem.c to avoid a potentially + negative shift distance, whose results are undefined in the C language. + Added a check in pngset.c to prevent writing multiple tIME chunks. + Added a check in pngwrite.c to detect invalid small window_bits sizes. +version 1.0.3d [September 4, 1999] + Fixed type casting of igamma in pngrutil.c + Added new png_expand functions to scripts/pngdef.pas and pngos2.def + Added a demo read_user_transform_fn that examines the row filters in pngtest.c + +version 1.0.4 [September 24, 1999] + Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined + Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h + Made several minor corrections to pngtest.c + Renamed the makefiles with longer but more user friendly extensions. + Copied the PNG copyright and license to a separate LICENSE file. + Revised documentation, png.h, and example.c to remove reference to + "viewing_gamma" which no longer appears in the PNG specification. + Revised pngvcrd.c to use MMX code for interlacing only on the final pass. + Updated pngvcrd.c to use the faster C filter algorithms from libpng-1.0.1a + Split makefile.win32vc into two versions, makefile.vcawin32 (uses MMX + assembler code) and makefile.vcwin32 (doesn't). + Added a CPU timing report to pngtest.c (enabled by defining PNGTEST_TIMING) + Added a copy of pngnow.png to the distribution. +version 1.0.4a [September 25, 1999] + Increase max_pixel_depth in pngrutil.c if a user transform needs it. + Changed several division operations to right-shifts in pngvcrd.c +version 1.0.4b [September 30, 1999] + Added parentheses in line 3732 of pngvcrd.c + Added a comment in makefile.linux warning about buggy -O3 in pgcc 2.95.1 +version 1.0.4c [October 1, 1999] + Added a "png_check_version" function in png.c and pngtest.c that will generate + a helpful compiler error if an old png.h is found in the search path. + Changed type of png_user_transform_depth|channels from int to png_byte. +version 1.0.4d [October 6, 1999] + Changed 0.45 to 0.45455 in png_set_sRGB() + Removed unused PLTE entries from pngnow.png + Re-enabled some parts of pngvcrd.c (png_combine_row) that work properly. +version 1.0.4e [October 10, 1999] + Fixed sign error in pngvcrd.c (Greg Roelofs) + Replaced some instances of memcpy with simple assignments in pngvcrd (GR-P) +version 1.0.4f [October 15, 1999] + Surrounded example.c code with #if 0 .. #endif to prevent people from + inadvertently trying to compile it. + Changed png_get_header_version() from a function to a macro in png.h + Added type casting mostly in pngrtran.c and pngwtran.c + Removed some pointless "ptr = NULL" in pngmem.c + Added a "contrib" directory containing the source code from Greg's book. + +version 1.0.5 [October 15, 1999] + Minor editing of the INSTALL and README files. +version 1.0.5a [October 23, 1999] + Added contrib/pngsuite and contrib/pngminus (Willem van Schaik) + Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans) + Further optimization and bugfix of pngvcrd.c + Revised pngset.c so that it does not allocate or free memory in the user's + text_ptr structure. Instead, it makes its own copy. + Created separate write_end_info_struct in pngtest.c for a more severe test. + Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak. +version 1.0.5b [November 23, 1999] + Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and + PNG_FLAG_WROTE_tIME from flags to mode. + Added png_write_info_before_PLTE() function. + Fixed some typecasting in contrib/gregbook/*.c + Updated scripts/makevms.com and added makevms.com to contrib/gregbook + and contrib/pngminus (Martin Zinser) +version 1.0.5c [November 26, 1999] + Moved png_get_header_version from png.h to png.c, to accommodate ansi2knr. + Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to + accommodate making DLL's: Moved usr_png_ver from global variable to function + png_get_header_ver() in png.c. Moved png_sig to png_sig_bytes in png.c and + eliminated use of png_sig in pngwutil.c. Moved the various png_CHNK arrays + into pngtypes.h. Eliminated use of global png_pass arrays. Declared the + png_CHNK and png_pass arrays to be "const". Made the global arrays + available to applications (although none are used in libpng itself) when + PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined. + Removed some extraneous "-I" from contrib/pngminus/makefile.std + Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2. + Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3 +version 1.0.5d [November 29, 1999] + Add type cast (png_const_charp) two places in png.c + Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays. + Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available + to applications a macro "PNG_USE_LOCAL_ARRAYS". + #ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined. + Added PNG_EXPORT_VAR macro to accommodate making DLL's. +version 1.0.5e [November 30, 1999] + Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text + structure; refactored the inflate/deflate support to make adding new chunks + with trailing compressed parts easier in the future, and added new functions + png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP, + png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond). + NOTE: Applications that write text chunks MUST define png_text->lang + before calling png_set_text(). It must be set to NULL if you want to + write tEXt or zTXt chunks. If you want your application to be able to + run with older versions of libpng, use + + #ifdef PNG_iTXt_SUPPORTED + png_text[i].lang = NULL; + #endif + + Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned + offsets (Eric S. Raymond). + Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into + PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED + macros, leaving the separate macros also available. + Removed comments on #endifs at the end of many short, non-nested #if-blocks. +version 1.0.5f [December 6, 1999] + Changed makefile.solaris to issue a warning about potential problems when + the ucb "ld" is in the path ahead of the ccs "ld". + Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3. + Added sCAL chunk support (Eric S. Raymond). +version 1.0.5g [December 7, 1999] + Fixed "png_free_spallettes" typo in png.h + Added code to handle new chunks in pngpread.c + Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block + Added "translated_key" to png_text structure and png_write_iTXt(). + Added code in pngwrite.c to work around a newly discovered zlib bug. +version 1.0.5h [December 10, 1999] + NOTE: regarding the note for version 1.0.5e, the following must also + be included in your code: + png_text[i].translated_key = NULL; + Unknown chunk handling is now supported. + Option to eliminate all floating point support was added. Some new + fixed-point functions such as png_set_gAMA_fixed() were added. + Expanded tabs and removed trailing blanks in source files. +version 1.0.5i [December 13, 1999] + Added some type casts to silence compiler warnings. + Renamed "png_free_spalette" to "png_free_spalettes" for consistency. + Removed leading blanks from a #define in pngvcrd.c + Added some parameters to the new png_set_keep_unknown_chunks() function. + Added a test for up->location != 0 in the first instance of writing + unknown chunks in pngwrite.c + Changed "num" to "i" in png_free_spalettes() and png_free_unknowns() to + prevent recursion. + Added png_free_hIST() function. + Various patches to fix bugs in the sCAL and integer cHRM processing, + and to add some convenience macros for use with sCAL. +version 1.0.5j [December 21, 1999] + Changed "unit" parameter of png_write_sCAL from png_byte to int, to work + around buggy compilers. + Added new type "png_fixed_point" for integers that hold float*100000 values + Restored backward compatibility of tEXt/zTXt chunk processing: + Restored the first four members of png_text to the same order as v.1.0.5d. + Added members "lang_key" and "itxt_length" to png_text struct. Set + text_length=0 when "text" contains iTXt data. Use the "compression" + member to distinguish among tEXt/zTXt/iTXt types. Added + PNG_ITXT_COMPRESSION_NONE (1) and PNG_ITXT_COMPRESSION_zTXt(2) macros. + The "Note" above, about backward incompatibility of libpng-1.0.5e, no + longer applies. + Fixed png_read|write_iTXt() to read|write parameters in the right order, + and to write the iTXt chunk after IDAT if it appears in the end_ptr. + Added pnggccrd.c, version of pngvcrd.c Intel assembler for gcc (Greg Roelofs) + Reversed the order of trying to write floating-point and fixed-point gAMA. +version 1.0.5k [December 27, 1999] + Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))" + Added png_handle_as_unknown() function (Glenn) + Added png_free_chunk_list() function and chunk_list and num_chunk_list members + of png_ptr. + Eliminated erroneous warnings about multiple sPLT chunks and sPLT-after-PLTE. + Fixed a libpng-1.0.5h bug in pngrutil.c that was issuing erroneous warnings + about ignoring incorrect gAMA with sRGB (gAMA was in fact not ignored) + Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR). + Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is. + Changed type of proflen from png_int_32 to png_uint_32 in png_get_iCCP(). +version 1.0.5l [January 1, 2000] + Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr() + for setting a callback function to handle unknown chunks and for + retrieving the associated user pointer (Glenn). +version 1.0.5m [January 7, 2000] + Added high-level functions png_read_png(), png_write_png(), png_free_pixels(). +version 1.0.5n [January 9, 2000] + Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its + own memory for info_ptr->palette. This makes it safe for the calling + application to free its copy of the palette any time after it calls + png_set_PLTE(). +version 1.0.5o [January 20, 2000] + Cosmetic changes only (removed some trailing blanks and TABs) +version 1.0.5p [January 31, 2000] + Renamed pngdll.mak to makefile.bd32 + Cosmetic changes in pngtest.c +version 1.0.5q [February 5, 2000] + Relocated the makefile.solaris warning about PATH problems. + Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg) + Revised makefile.gcmmx + Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros +version 1.0.5r [February 7, 2000] + Removed superfluous prototype for png_get_itxt from png.h + Fixed a bug in pngrtran.c that improperly expanded the background color. + Return *num_text=0 from png_get_text() when appropriate, and fix documentation + of png_get_text() in libpng.txt/libpng.3. +version 1.0.5s [February 18, 2000] + Added "png_jmp_env()" macro to pngconf.h, to help people migrate to the + new error handler that's planned for the next libpng release, and changed + example.c, pngtest.c, and contrib programs to use this macro. + Revised some of the DLL-export macros in pngconf.h (Greg Roelofs) + Fixed a bug in png_read_png() that caused it to fail to expand some images + that it should have expanded. + Fixed some mistakes in the unused and undocumented INCH_CONVERSIONS functions + in pngget.c + Changed the allocation of palette, history, and trans arrays back to + the version 1.0.5 method (linking instead of copying) which restores + backward compatibility with version 1.0.5. Added some remarks about + that in example.c. Added "free_me" member to info_ptr and png_ptr + and added png_free_data() function. + Updated makefile.linux and makefile.gccmmx to make directories conditionally. + Made cosmetic changes to pngasmrd.h + Added png_set_rows() and png_get_rows(), for use with png_read|write_png(). + Modified png_read_png() to allocate info_ptr->row_pointers only if it + hasn't already been allocated. +version 1.0.5t [March 4, 2000] + Changed png_jmp_env() migration aiding macro to png_jmpbuf(). + Fixed "interlace" typo (should be "interlaced") in contrib/gregbook/read2-x.c + Fixed bug with use of PNG_BEFORE_IHDR bit in png_ptr->mode, introduced when + PNG_FLAG_HAVE_CHUNK_HEADER was moved into png_ptr->mode in version 1.0.5b + Files in contrib/gregbook were revised to use png_jmpbuf() and to select + a 24-bit visual if one is available, and to allow abbreviated options. + Files in contrib/pngminus were revised to use the png_jmpbuf() macro. + Removed spaces in makefile.linux and makefile.gcmmx, introduced in 1.0.5s +version 1.0.5u [March 5, 2000] + Simplified the code that detects old png.h in png.c and pngtest.c + Renamed png_spalette (_p, _pp) to png_sPLT_t (_tp, _tpp) + Increased precision of rgb_to_gray calculations from 8 to 15 bits and + added png_set_rgb_to_gray_fixed() function. + Added makefile.bc32 (32-bit Borland C++, C mode) +version 1.0.5v [March 11, 2000] + Added some parentheses to the png_jmpbuf macro definition. + Updated references to the zlib home page, which has moved to freesoftware.com. + Corrected bugs in documentation regarding png_read_row() and png_write_row(). + Updated documentation of png_rgb_to_gray calculations in libpng.3/libpng.txt. + Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3, + revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin) + +version 1.0.6 [March 20, 2000] + Minor revisions of makefile.bor, libpng.txt, and gregbook/rpng2-win.c + Added makefile.sggcc (SGI IRIX with gcc) +version 1.0.6d [April 7, 2000] + Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO + Added data_length parameter to png_decompress_chunk() function + Revised documentation to remove reference to abandoned png_free_chnk functions + Fixed an error in png_rgb_to_gray_fixed() + Revised example.c, usage of png_destroy_write_struct(). + Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file + Added a check for info_ptr->free_me&PNG_FREE_TEXT when freeing text in png.c + Simplify png_sig_bytes() function to remove use of non-ISO-C strdup(). +version 1.0.6e [April 9, 2000] + Added png_data_freer() function. + In the code that checks for over-length tRNS chunks, added check of + info_ptr->num_trans as well as png_ptr->num_trans (Matthias Benckmann) + Minor revisions of libpng.txt/libpng.3. + Check for existing data and free it if the free_me flag is set, in png_set_*() + and png_handle_*(). + Only define PNG_WEIGHTED_FILTERS_SUPPORTED when PNG_FLOATING_POINT_SUPPORTED + is defined. + Changed several instances of PNG_NO_CONSOLE_ID to PNG_NO_STDIO in pngrutil.c + and mentioned the purposes of the two macros in libpng.txt/libpng.3. +version 1.0.6f [April 14, 2000] + Revised png_set_iCCP() and png_set_rows() to avoid prematurely freeing data. + Add checks in png_set_text() for NULL members of the input text structure. + Revised libpng.txt/libpng.3. + Removed superfluous prototype for png_set_itxt from png.h + Removed "else" from pngread.c, after png_error(), and changed "0" to "length". + Changed several png_errors about malformed ancillary chunks to png_warnings. +version 1.0.6g [April 24, 2000] + Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined. + Relocated paragraph about png_set_background() in libpng.3/libpng.txt + and other revisions (Matthias Benckmann) + Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and + png_ptr members to restore binary compatibility with libpng-1.0.5 + (breaks compatibility with libpng-1.0.6). +version 1.0.6h [April 24, 2000] + Changed shared library so-number pattern from 2.x.y.z to xy.z (this builds + libpng.so.10 & libpng.so.10.6h instead of libpng.so.2 & libpng.so.2.1.0.6h) + This is a temporary change for test purposes. +version 1.0.6i [May 2, 2000] + Rearranged some members at the end of png_info and png_struct, to put + unknown_chunks_num and free_me within the original size of the png_structs + and free_me, png_read_user_fn, and png_free_fn within the original png_info, + because some old applications allocate the structs directly instead of + using png_create_*(). + Added documentation of user memory functions in libpng.txt/libpng.3 + Modified png_read_png so that it will use user_allocated row_pointers + if present, unless free_me directs that it be freed, and added description + of the use of png_set_rows() and png_get_rows() in libpng.txt/libpng.3. + Added PNG_LEGACY_SUPPORTED macro, and #ifdef out all new (since version + 1.00) members of png_struct and png_info, to regain binary compatibility + when you define this macro. Capabilities lost in this event + are user transforms (new in version 1.0.0),the user transform pointer + (new in version 1.0.2), rgb_to_gray (new in 1.0.5), iCCP, sCAL, sPLT, + the high-level interface, and unknown chunks support (all new in 1.0.6). + This was necessary because of old applications that allocate the structs + directly as authors were instructed to do in libpng-0.88 and earlier, + instead of using png_create_*(). + Added modes PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT which + can be used to detect codes that directly allocate the structs, and + code to check these modes in png_read_init() and png_write_init() and + generate a libpng error if the modes aren't set and PNG_LEGACY_SUPPORTED + was not defined. + Added makefile.intel and updated makefile.watcom (Pawel Mrochen) +version 1.0.6j [May 3, 2000] + Overloaded png_read_init() and png_write_init() with macros that convert + calls to png_read_init_2() or png_write_init_2() that check the version + and structure sizes. +version 1.0.7beta11 [May 7, 2000] + Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes + which are no longer used. + Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is + defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXT_SUPPORTED + is defined. + Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory + overrun when old applications fill the info_ptr->text structure directly. + Added PNGAPI macro, and added it to the definitions of all exported functions. + Relocated version macro definitions ahead of the includes of zlib.h and + pngconf.h in png.h. +version 1.0.7beta12 [May 12, 2000] + Revised pngset.c to avoid a problem with expanding the png_debug macro. + Deleted some extraneous defines from pngconf.h + Made PNG_NO_CONSOLE_IO the default condition when PNG_BUILD_DLL is defined. + Use MSC _RPTn debugging instead of fprintf if _MSC_VER is defined. + Added png_access_version_number() function. + Check for mask&PNG_FREE_CHNK (for TEXT, SCAL, PCAL) in png_free_data(). + Expanded libpng.3/libpng.txt information about png_data_freer(). +version 1.0.7beta14 [May 17, 2000] (beta13 was not published) + Changed pnggccrd.c and pngvcrd.c to handle bad adaptive filter types as + warnings instead of errors, as pngrutil.c does. + Set the PNG_INFO_IDAT valid flag in png_set_rows() so png_write_png() + will actually write IDATs. + Made the default PNG_USE_LOCAL_ARRAYS depend on PNG_DLL instead of WIN32. + Make png_free_data() ignore its final parameter except when freeing data + that can have multiple instances (text, sPLT, unknowns). + Fixed a new bug in png_set_rows(). + Removed info_ptr->valid tests from png_free_data(), as in version 1.0.5. + Added png_set_invalid() function. + Fixed incorrect illustrations of png_destroy_write_struct() in example.c. +version 1.0.7beta15 [May 30, 2000] + Revised the deliberately erroneous Linux setjmp code in pngconf.h to produce + fewer error messages. + Rearranged checks for Z_OK to check the most likely path first in pngpread.c + and pngwutil.c. + Added checks in pngtest.c for png_create_*() returning NULL, and mentioned + in libpng.txt/libpng.3 the need for applications to check this. + Changed names of png_default_*() functions in pngtest to pngtest_*(). + Changed return type of png_get_x|y_offset_*() from png_uint_32 to png_int_32. + Fixed some bugs in the unused PNG_INCH_CONVERSIONS functions in pngget.c + Set each pointer to NULL after freeing it in png_free_data(). + Worked around a problem in pngconf.h; AIX's strings.h defines an "index" + macro that conflicts with libpng's png_color_16.index. (Dimitri Papadapoulos) + Added "msvc" directory with MSVC++ project files (Simon-Pierre Cadieux). +version 1.0.7beta16 [June 4, 2000] + Revised the workaround of AIX string.h "index" bug. + Added a check for overlength PLTE chunk in pngrutil.c. + Added PNG_NO_POINTER_INDEXING macro to use array-indexing instead of pointer + indexing in pngrutil.c and pngwutil.c to accommodate a buggy compiler. + Added a warning in png_decompress_chunk() when it runs out of data, e.g. + when it tries to read an erroneous PhotoShop iCCP chunk. + Added PNG_USE_DLL macro. + Revised the copyright/disclaimer/license notice. + Added contrib/msvctest directory +version 1.0.7rc1 [June 9, 2000] + Corrected the definition of PNG_TRANSFORM_INVERT_ALPHA (0x0400 not 0x0200) + Added contrib/visupng directory (Willem van Schaik) +version 1.0.7beta18 [June 23, 2000] + Revised PNGAPI definition, and pngvcrd.c to work with __GCC__ + and do not redefine PNGAPI if it is passed in via a compiler directive. + Revised visupng/PngFile.c to remove returns from within the Try block. + Removed leading underscores from "_PNG_H" and "_PNG_SAVE_BSD_SOURCE" macros. + Updated contrib/visupng/cexcept.h to version 1.0.0. + Fixed bugs in pngwrite.c and pngwutil.c that prevented writing iCCP chunks. +version 1.0.7rc2 [June 28, 2000] + Updated license to include disclaimers required by UCITA. + Fixed "DJBPP" typo in pnggccrd.c introduced in beta18. + +version 1.0.7 [July 1, 2000] + Revised the definition of "trans_values" in libpng.3/libpng.txt +version 1.0.8beta1 [July 8, 2000] + Added png_free(png_ptr, key) two places in pngpread.c to stop memory leaks. + Changed PNG_NO_STDIO to PNG_NO_CONSOLE_IO, several places in pngrutil.c and + pngwutil.c. + Changed PNG_EXPORT_VAR to use PNG_IMPEXP, in pngconf.h. + Removed unused "#include " from png.c + Added WindowsCE support. + Revised pnggccrd.c to work with gcc-2.95.2 and in the Cygwin environment. +version 1.0.8beta2 [July 10, 2000] + Added project files to the wince directory and made further revisions + of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE. +version 1.0.8beta3 [July 11, 2000] + Only set the PNG_FLAG_FREE_TRNS or PNG_FREE_TRNS flag in png_handle_tRNS() + for indexed-color input files to avoid potential double-freeing trans array + under some unusual conditions; problem was introduced in version 1.0.6f. + Further revisions to pngtest.c and files in the wince subdirectory. +version 1.0.8beta4 [July 14, 2000] + Added the files pngbar.png and pngbar.jpg to the distribution. + Added makefile.cygwin, and cygwin support in pngconf.h + Added PNG_NO_ZALLOC_ZERO macro (makes png_zalloc skip zeroing memory) +version 1.0.8rc1 [July 16, 2000] + Revised png_debug() macros and statements to eliminate compiler warnings. + +version 1.0.8 [July 24, 2000] + Added png_flush() in pngwrite.c, after png_write_IEND(). + Updated makefile.hpux to build a shared library. +version 1.0.9beta1 [November 10, 2000] + Fixed typo in scripts/makefile.hpux + Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser) + Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser) + Changed "cdrom.com" in documentation to "libpng.org" + Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg). + Changed type of "params" from voidp to png_voidp in png_read|write_png(). + Make sure PNGAPI and PNG_IMPEXP are defined in pngconf.h. + Revised the 3 instances of WRITEFILE in pngtest.c. + Relocated "msvc" and "wince" project subdirectories into "dll" subdirectory. + Updated png.rc in dll/msvc project + Revised makefile.dec to define and use LIBPATH and INCPATH + Increased size of global png_libpng_ver[] array from 12 to 18 chars. + Made global png_libpng_ver[], png_sig[] and png_pass_*[] arrays const. + Removed duplicate png_crc_finish() from png_handle_bKGD() function. + Added a warning when application calls png_read_update_info() multiple times. + Revised makefile.cygwin + Fixed bugs in iCCP support in pngrutil.c and pngwutil.c. + Replaced png_set_empty_plte_permitted() with png_permit_mng_features(). +version 1.0.9beta2 [November 19, 2000] + Renamed the "dll" subdirectory "projects". + Added borland project files to "projects" subdirectory. + Set VS_FF_PRERELEASE and VS_FF_PATCHED flags in msvc/png.rc when appropriate. + Add error message in png_set_compression_buffer_size() when malloc fails. +version 1.0.9beta3 [November 23, 2000] + Revised PNG_LIBPNG_BUILD_TYPE macro in png.h, used in the msvc project. + Removed the png_flush() in pngwrite.c that crashes some applications + that don't set png_output_flush_fn. + Added makefile.macosx and makefile.aix to scripts directory. +version 1.0.9beta4 [December 1, 2000] + Change png_chunk_warning to png_warning in png_check_keyword(). + Increased the first part of msg buffer from 16 to 18 in png_chunk_error(). +version 1.0.9beta5 [December 15, 2000] + Added support for filter method 64 (for PNG datastreams embedded in MNG). +version 1.0.9beta6 [December 18, 2000] + Revised png_set_filter() to accept filter method 64 when appropriate. + Added new PNG_HAVE_PNG_SIGNATURE bit to png_ptr->mode and use it to + help prevent applications from using MNG features in PNG datastreams. + Added png_permit_mng_features() function. + Revised libpng.3/libpng.txt. Changed "filter type" to "filter method". +version 1.0.9rc1 [December 23, 2000] + Revised test for PNG_HAVE_PNG_SIGNATURE in pngrutil.c + Fixed error handling of unknown compression type in png_decompress_chunk(). + In pngconf.h, define __cdecl when _MSC_VER is defined. +version 1.0.9beta7 [December 28, 2000] + Changed PNG_TEXT_COMPRESSION_zTXt to PNG_COMPRESSION_TYPE_BASE several places. + Revised memory management in png_set_hIST and png_handle_hIST in a backward + compatible manner. PLTE and tRNS were revised similarly. + Revised the iCCP chunk reader to ignore trailing garbage. +version 1.0.9beta8 [January 12, 2001] + Moved pngasmrd.h into pngconf.h. + Improved handling of out-of-spec garbage iCCP chunks generated by PhotoShop. +version 1.0.9beta9 [January 15, 2001] + Added png_set_invalid, png_permit_mng_features, and png_mmx_supported to + wince and msvc project module definition files. + Minor revision of makefile.cygwin. + Fixed bug with progressive reading of narrow interlaced images in pngpread.c +version 1.0.9beta10 [January 16, 2001] + Do not typedef png_FILE_p in pngconf.h when PNG_NO_STDIO is defined. + Fixed "png_mmx_supported" typo in project definition files. +version 1.0.9beta11 [January 19, 2001] + Updated makefile.sgi to make shared library. + Removed png_mmx_support() function and disabled PNG_MNG_FEATURES_SUPPORTED + by default, for the benefit of DLL forward compatibility. These will + be re-enabled in version 1.2.0. +version 1.0.9rc2 [January 22, 2001] + Revised cygwin support. + +version 1.0.9 [January 31, 2001] + Added check of cygwin's ALL_STATIC in pngconf.h + Added "-nommx" parameter to contrib/gregbook/rpng2-win and rpng2-x demos. +version 1.0.10beta1 [March 14, 2001] + Revised makefile.dec, makefile.sgi, and makefile.sggcc; added makefile.hpgcc. + Reformatted libpng.3 to eliminate bad line breaks. + Added checks for _mmx_supported in the read_filter_row function of pnggccrd.c + Added prototype for png_mmx_support() near the top of pnggccrd.c + Moved some error checking from png_handle_IHDR to png_set_IHDR. + Added PNG_NO_READ_SUPPORTED and PNG_NO_WRITE_SUPPORTED macros. + Revised png_mmx_support() function in pnggccrd.c + Restored version 1.0.8 PNG_WRITE_EMPTY_PLTE_SUPPORTED behavior in pngwutil.c + Fixed memory leak in contrib/visupng/PngFile.c + Fixed bugs in png_combine_row() in pnggccrd.c and pngvcrd.c (C version) + Added warnings when retrieving or setting gamma=0. + Increased the first part of msg buffer from 16 to 18 in png_chunk_warning(). +version 1.0.10rc1 [March 23, 2001] + Changed all instances of memcpy, strcpy, and strlen to png_memcpy, png_strcpy, + and png_strlen. + Revised png_mmx_supported() function in pnggccrd.c to return proper value. + Fixed bug in progressive reading (pngpread.c) with small images (height < 8). + +version 1.0.10 [March 30, 2001] + Deleted extraneous space (introduced in 1.0.9) from line 42 of makefile.cygwin + Added beos project files (Chris Herborth) +version 1.0.11beta1 [April 3, 2001] + Added type casts on several png_malloc() calls (Dimitri Papadapoulos). + Removed a no-longer needed AIX work-around from pngconf.h + Changed several "//" single-line comments to C-style in pnggccrd.c +version 1.0.11beta2 [April 11, 2001] + Removed PNGAPI from several functions whose prototypes did not have PNGAPI. + Updated scripts/pngos2.def +version 1.0.11beta3 [April 14, 2001] + Added checking the results of many instances of png_malloc() for NULL +version 1.0.11beta4 [April 20, 2001] + Undid the changes from version 1.0.11beta3. Added a check for NULL return + from user's malloc_fn(). + Removed some useless type casts of the NULL pointer. + Added makefile.netbsd + +version 1.0.11 [April 27, 2001] + Revised makefile.netbsd +version 1.0.12beta1 [May 14, 2001] + Test for Windows platform in pngconf.h when including malloc.h (Emmanuel Blot) + Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h + Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings. + Eliminated the png_error about apps using png_read|write_init(). Instead, + libpng will reallocate the png_struct and info_struct if they are too small. + This retains future binary compatibility for old applications written for + libpng-0.88 and earlier. +version 1.2.0beta1 [May 6, 2001] + Bumped DLLNUM to 2. + Re-enabled PNG_MNG_FEATURES_SUPPORTED and enabled PNG_ASSEMBLER_CODE_SUPPORTED + by default. + Added runtime selection of MMX features. + Added png_set_strip_error_numbers function and related macros. +version 1.2.0beta2 [May 7, 2001] + Finished merging 1.2.0beta1 with version 1.0.11 + Added a check for attempts to read or write PLTE in grayscale PNG datastreams. +version 1.2.0beta3 [May 17, 2001] + Enabled user memory function by default. + Modified png_create_struct so it passes user mem_ptr to user memory allocator. + Increased png_mng_features flag from png_byte to png_uint_32. + Bumped shared-library (so-number) and dll-number to 3. +version 1.2.0beta4 [June 23, 2001] + Check for missing profile length field in iCCP chunk and free chunk_data + in case of truncated iCCP chunk. + Bumped shared-library number to 3 in makefile.sgi and makefile.sggcc + Bumped dll-number from 2 to 3 in makefile.cygwin + Revised contrib/gregbook/rpng*-x.c to avoid a memory leak and to exit cleanly + if user attempts to run it on an 8-bit display. + Updated contrib/gregbook + Use png_malloc instead of png_zalloc to allocate palette in pngset.c + Updated makefile.ibmc + Added some typecasts to eliminate gcc 3.0 warnings. Changed prototypes + of png_write_oFFS width and height from png_uint_32 to png_int_32. + Updated example.c + Revised prototypes for png_debug_malloc and png_debug_free in pngtest.c +version 1.2.0beta5 [August 8, 2001] + Revised contrib/gregbook + Revised makefile.gcmmx + Revised pnggccrd.c to conditionally compile some thread-unsafe code only + when PNG_THREAD_UNSAFE_OK is defined. + Added tests to prevent pngwutil.c from writing a bKGD or tRNS chunk with + value exceeding 2^bit_depth-1 + Revised makefile.sgi and makefile.sggcc + Replaced calls to fprintf(stderr,...) with png_warning() in pnggccrd.c + Removed restriction that do_invert_mono only operate on 1-bit opaque files + +version 1.2.0 [September 1, 2001] + Changed a png_warning() to png_debug() in pnggccrd.c + Fixed contrib/gregbook/rpng-x.c, rpng2-x.c to avoid crash with XFreeGC(). +version 1.2.1beta1 [October 19, 2001] + Revised makefile.std in contrib/pngminus + Include background_1 in png_struct regardless of gamma support. + Revised makefile.netbsd and makefile.macosx, added makefile.darwin. + Revised example.c to provide more details about using row_callback(). +version 1.2.1beta2 [October 25, 2001] + Added type cast to each NULL appearing in a function call, except for + WINCE functions. + Added makefile.so9. +version 1.2.1beta3 [October 27, 2001] + Removed type casts from all NULLs. + Simplified png_create_struct_2(). +version 1.2.1beta4 [November 7, 2001] + Revised png_create_info_struct() and png_creat_struct_2(). + Added error message if png_write_info() was omitted. + Type cast NULLs appearing in function calls when _NO_PROTO or + PNG_TYPECAST_NULL is defined. +version 1.2.1rc1 [November 24, 2001] + Type cast NULLs appearing in function calls except when PNG_NO_TYPECAST_NULL + is defined. + Changed typecast of "size" argument to png_size_t in pngmem.c calls to + the user malloc_fn, to agree with the prototype in png.h + Added a pop/push operation to pnggccrd.c, to preserve Eflag (Maxim Sobolev) + Updated makefile.sgi to recognize LIBPATH and INCPATH. + Updated various makefiles so "make clean" does not remove previous major + version of the shared library. +version 1.2.1rc2 [December 4, 2001] + Always allocate 256-entry internal palette, hist, and trans arrays, to + avoid out-of-bounds memory reference caused by invalid PNG datastreams. + Added a check for prefix_length > data_length in iCCP chunk handler. + +version 1.2.1 [December 7, 2001] + None. +version 1.2.2beta1 [February 22, 2002] + Fixed a bug with reading the length of iCCP profiles (Larry Reeves). + Revised makefile.linux, makefile.gcmmx, and makefile.sgi to generate + libpng.a, libpng12.so (not libpng.so.3), and libpng12/png.h + Revised makefile.darwin to remove "-undefined suppress" option. + Added checks for gamma and chromaticity values over 21474.83, which exceed + the limit for PNG unsigned 32-bit integers when encoded. + Revised calls to png_create_read_struct() and png_create_write_struct() + for simpler debugging. + Revised png_zalloc() so zlib handles errors (uses PNG_FLAG_MALLOC_NULL_MEM_OK) +version 1.2.2beta2 [February 23, 2002] + Check chunk_length and idat_size for invalid (over PNG_MAX_UINT) lengths. + Check for invalid image dimensions in png_get_IHDR. + Added missing "fi;" in the install target of the SGI makefiles. + Added install-static to all makefiles that make shared libraries. + Always do gamma compensation when image is partially transparent. +version 1.2.2beta3 [March 7, 2002] + Compute background.gray and background_1.gray even when color_type is RGB + in case image gets reduced to gray later. + Modified shared-library makefiles to install pkgconfig/libpngNN.pc. + Export (with PNGAPI) png_zalloc, png_zfree, and png_handle_as_unknown + Removed unused png_write_destroy_info prototype from png.h + Eliminated incorrect use of width_mmx from pnggccrd.c in pixel_bytes == 8 case + Added install-shared target to all makefiles that make shared libraries. + Stopped a double free of palette, hist, and trans when not using free_me. + Added makefile.32sunu for Sun Ultra 32 and makefile.64sunu for Sun Ultra 64. +version 1.2.2beta4 [March 8, 2002] + Compute background.gray and background_1.gray even when color_type is RGB + in case image gets reduced to gray later (Jason Summers). + Relocated a misplaced /bin/rm in the "install-shared" makefile targets + Added PNG_1_0_X macro which can be used to build a 1.0.x-compatible library. +version 1.2.2beta5 [March 26, 2002] + Added missing PNGAPI to several function definitions. + Check for invalid bit_depth or color_type in png_get_IHDR(), and + check for missing PLTE or IHDR in png_push_read_chunk() (Matthias Clasen). + Revised iTXt support to accept NULL for lang and lang_key. + Compute gamma for color components of background even when color_type is gray. + Changed "()" to "{}" in scripts/libpng.pc.in. + Revised makefiles to put png.h and pngconf.h only in $prefix/include/libpngNN + Revised makefiles to make symlink to libpng.so.NN in addition to libpngNN.so +version 1.2.2beta6 [March 31, 2002] +version 1.0.13beta1 [March 31, 2002] + Prevent png_zalloc() from trying to memset memory that it failed to acquire. + Add typecasts of PNG_MAX_UINT in pngset_cHRM_fixed() (Matt Holgate). + Ensure that the right function (user or default) is used to free the + png_struct after an error in png_create_read_struct_2(). +version 1.2.2rc1 [April 7, 2002] +version 1.0.13rc1 [April 7, 2002] + Save the ebx register in pnggccrd.c (Sami Farin) + Add "mem_ptr = png_ptr->mem_ptr" in png_destroy_write_struct() (Paul Gardner). + Updated makefiles to put headers in include/libpng and remove old include/*.h. + +version 1.2.2 [April 15, 2002] +version 1.0.13 [April 15, 2002] + Revised description of png_set_filter() in libpng.3/libpng.txt. + Revised makefile.netbsd and added makefile.neNNbsd and makefile.freebsd +version 1.0.13patch01 [April 17, 2002] +version 1.2.2patch01 [April 17, 2002] + Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and makefile.sggcc + Fixed VER -> PNGVER typo in makefile.macosx and added install-static to install + Added install: target to makefile.32sunu and makefile.64sunu +version 1.0.13patch03 [April 18, 2002] +version 1.2.2patch03 [April 18, 2002] + Revised 15 makefiles to link libpng.a to libpngNN.a and the include libpng + subdirectory to libpngNN subdirectory without the full pathname. + Moved generation of libpng.pc from "install" to "all" in 15 makefiles. +version 1.2.3rc1 [April 28, 2002] + Added install-man target to 15 makefiles (Dimitri Papadopolous-Orfanos). + Added $(DESTDIR) feature to 24 makefiles (Tim Mooney) + Fixed bug with $prefix, should be $(prefix) in makefile.hpux. + Updated cygwin-specific portion of pngconf.h and revised makefile.cygwin + Added a link from libpngNN.pc to libpng.pc in 15 makefiles. + Added links from include/libpngNN/*.h to include/*.h in 24 makefiles. + Revised makefile.darwin to make relative links without full pathname. + Added setjmp() at the end of png_create_*_struct_2() in case user forgets + to put one in their application. + Restored png_zalloc() and png_zfree() prototypes to version 1.2.1 and + removed them from module definition files. +version 1.2.3rc2 [May 1, 2002] + Fixed bug in reporting number of channels in pngget.c and pngset.c, + that was introduced in version 1.2.2beta5. + Exported png_zalloc(), png_zfree(), png_default_read(), png_default_write(), + png_default_flush(), and png_push_fill_buffer() and included them in + module definition files. + Added "libpng.pc" dependency to the "install-shared" target in 15 makefiles. +version 1.2.3rc3 [May 1, 2002] + Revised prototype for png_default_flush() + Remove old libpng.pc and libpngNN.pc before installing new ones. +version 1.2.3rc4 [May 2, 2002] + Typos in *.def files (png_default_read|write -> png_default_read|write_data) + In makefiles, changed rm libpng.NN.pc to rm libpngNN.pc + Added libpng-config and libpngNN-config and modified makefiles to install them. + Changed $(MANPATH) to $(DESTDIR)$(MANPATH) in makefiles + Added "Win32 DLL VB" configuration to projects/msvc/libpng.dsp +version 1.2.3rc5 [May 11, 2002] + Changed "error" and "message" in prototypes to "error_message" and + "warning_message" to avoid namespace conflict. + Revised 15 makefiles to build libpng-config from libpng-config-*.in + Once more restored png_zalloc and png_zfree to regular nonexported form. + Restored png_default_read|write_data, png_default_flush, png_read_fill_buffer + to nonexported form, but with PNGAPI, and removed them from module def files. +version 1.2.3rc6 [May 14, 2002] + Removed "PNGAPI" from png_zalloc() and png_zfree() in png.c + Changed "Gz" to "Gd" in projects/msvc/libpng.dsp and zlib.dsp. + Removed leftover libpng-config "sed" script from four makefiles. + Revised libpng-config creating script in 16 makefiles. + +version 1.2.3 [May 22, 2002] + Revised libpng-config target in makefile.cygwin. + Removed description of png_set_mem_fn() from documentation. + Revised makefile.freebsd. + Minor cosmetic changes to 15 makefiles, e.g., $(DI) = $(DESTDIR)/$(INCDIR). + Revised projects/msvc/README.txt + Changed -lpng to -lpngNN in LDFLAGS in several makefiles. +version 1.2.4beta1 [May 24, 2002] + Added libpng.pc and libpng-config to "all:" target in 16 makefiles. + Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH) + Added missing "\" before closing double quote in makefile.gcmmx. + Plugged various memory leaks; added png_malloc_warn() and png_set_text_2() + functions. +version 1.2.4beta2 [June 25, 2002] + Plugged memory leak of png_ptr->current_text (Matt Holgate). + Check for buffer overflow before reading CRC in pngpread.c (Warwick Allison) + Added -soname to the loader flags in makefile.dec, makefile.sgi, and + makefile.sggcc. + Added "test-installed" target to makefile.linux, makefile.gcmmx, + makefile.sgi, and makefile.sggcc. +version 1.2.4beta3 [June 28, 2002] + Plugged memory leak of row_buf in pngtest.c when there is a png_error(). + Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data. + Added "test-installed" target to makefile.32sunu, makefile.64sunu, + makefile.beos, makefile.darwin, makefile.dec, makefile.macosx, + makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9. +version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002] + Added "test-installed" target to makefile.cygwin and makefile.sco. + Revised pnggccrd.c to be able to back out version 1.0.x via PNG_1_0_X macro. + +version 1.2.4 and 1.0.14 [July 8, 2002] + Changed png_warning() to png_error() when width is too large to process. +version 1.2.4patch01 [July 20, 2002] + Revised makefile.cygwin to use DLL number 12 instead of 13. +version 1.2.5beta1 [August 6, 2002] + Added code to contrib/gregbook/readpng2.c to ignore unused chunks. + Replaced toucan.png in contrib/gregbook (it has been corrupt since 1.0.11) + Removed some stray *.o files from contrib/gregbook. + Changed png_error() to png_warning() about "Too much data" in pngpread.c + and about "Extra compressed data" in pngrutil.c. + Prevent png_ptr->pass from exceeding 7 in png_push_finish_row(). + Updated makefile.hpgcc + Updated png.c and pnggccrd.c handling of return from png_mmx_support() +version 1.2.5beta2 [August 15, 2002] + Only issue png_warning() about "Too much data" in pngpread.c when avail_in + is nonzero. + Updated makefiles to install a separate libpng.so.3 with its own rpath. +version 1.2.5rc1 and 1.0.15rc1 [August 24, 2002] + Revised makefiles to not remove previous minor versions of shared libraries. +version 1.2.5rc2 and 1.0.15rc2 [September 16, 2002] + Revised 13 makefiles to remove "-lz" and "-L$(ZLIBLIB)", etc., from shared + library loader directive. + Added missing "$OBJSDLL" line to makefile.gcmmx. + Added missing "; fi" to makefile.32sunu. +version 1.2.5rc3 and 1.0.15rc3 [September 18, 2002] + Revised libpng-config script. + +version 1.2.5 and 1.0.15 [October 3, 2002] + Revised makefile.macosx, makefile.darwin, makefile.hpgcc, and makefile.hpux, + and makefile.aix. + Relocated two misplaced PNGAPI lines in pngtest.c +version 1.2.6beta1 [October 22, 2002] + Commented out warning about uninitialized mmx_support in pnggccrd.c. + Changed "IBMCPP__" flag to "__IBMCPP__" in pngconf.h. + Relocated two more misplaced PNGAPI lines in pngtest.c + Fixed memory overrun bug in png_do_read_filler() with 16-bit datastreams, + introduced in version 1.0.2. + Revised makefile.macosx, makefile.dec, makefile.aix, and makefile.32sunu. +version 1.2.6beta2 [November 1, 2002] + Added libpng-config "--ldopts" output. + Added "AR=ar" and "ARFLAGS=rc" and changed "ar rc" to "$(AR) $(ARFLAGS)" + in makefiles. +version 1.2.6beta3 [July 18, 2004] + Reverted makefile changes from version 1.2.6beta2 and some of the changes + from version 1.2.6beta1; these will be postponed until version 1.2.7. + Version 1.2.6 is going to be a simple bugfix release. + Changed the one instance of "ln -sf" to "ln -f -s" in each Sun makefile. + Fixed potential overrun in pngerror.c by using strncpy instead of memcpy. + Added "#!/bin/sh" at the top of configure, for recognition of the + 'x' flag under Cygwin (Cosmin). + Optimized vacuous tests that silence compiler warnings, in png.c (Cosmin). + Added support for PNG_USER_CONFIG, in pngconf.h (Cosmin). + Fixed the special memory handler for Borland C under DOS, in pngmem.c + (Cosmin). + Removed some spurious assignments in pngrutil.c (Cosmin). + Replaced 65536 with 65536L, and 0xffff with 0xffffL, to silence warnings + on 16-bit platforms (Cosmin). + Enclosed shift op expressions in parentheses, to silence warnings (Cosmin). + Used proper type png_fixed_point, to avoid problems on 16-bit platforms, + in png_handle_sRGB() (Cosmin). + Added compression_type to png_struct, and optimized the window size + inside the deflate stream (Cosmin). + Fixed definition of isnonalpha(), in pngerror.c and pngrutil.c (Cosmin). + Fixed handling of unknown chunks that come after IDAT (Cosmin). + Allowed png_error() and png_warning() to work even if png_ptr == NULL + (Cosmin). + Replaced row_info->rowbytes with row_bytes in png_write_find_filter() + (Cosmin). + Fixed definition of PNG_LIBPNG_VER_DLLNUM (Simon-Pierre). + Used PNG_LIBPNG_VER and PNG_LIBPNG_VER_STRING instead of the hardcoded + values in png.c (Simon-Pierre, Cosmin). + Initialized png_libpng_ver[] with PNG_LIBPNG_VER_STRING (Simon-Pierre). + Replaced PNG_LIBPNG_VER_MAJOR with PNG_LIBPNG_VER_DLLNUM in png.rc + (Simon-Pierre). + Moved the definition of PNG_HEADER_VERSION_STRING near the definitions + of the other PNG_LIBPNG_VER_... symbols in png.h (Cosmin). + Relocated #ifndef PNGAPI guards in pngconf.h (Simon-Pierre, Cosmin). + Updated scripts/makefile.vc(a)win32 (Cosmin). + Updated the MSVC project (Simon-Pierre, Cosmin). + Updated the Borland C++ Builder project (Cosmin). + Avoided access to asm_flags in pngvcrd.c, if PNG_1_0_X is defined (Cosmin). + Commented out warning about uninitialized mmx_support in pngvcrd.c (Cosmin). + Removed scripts/makefile.bd32 and scripts/pngdef.pas (Cosmin). + Added extra guard around inclusion of Turbo C memory headers, in pngconf.h + (Cosmin). + Renamed projects/msvc/ to projects/visualc6/, and projects/borland/ to + projects/cbuilder5/ (Cosmin). + Moved projects/visualc6/png32ms.def to scripts/pngw32.def, + and projects/visualc6/png.rc to scripts/pngw32.rc (Cosmin). + Added projects/visualc6/pngtest.dsp; removed contrib/msvctest/ (Cosmin). + Changed line endings to DOS style in cbuilder5 and visualc6 files, even + in the tar.* distributions (Cosmin). + Updated contrib/visupng/VisualPng.dsp (Cosmin). + Updated contrib/visupng/cexcept.h to version 2.0.0 (Cosmin). + Added a separate distribution with "configure" and supporting files (Junichi). +version 1.2.6beta4 [July 28, 2004] + Added user ability to change png_size_t via a PNG_SIZE_T macro. + Added png_sizeof() and png_convert_size() functions. + Added PNG_SIZE_MAX (maximum value of a png_size_t variable. + Added check in png_malloc_default() for (size_t)size != (png_uint_32)size + which would indicate an overflow. + Changed sPLT failure action from png_error to png_warning and abandon chunk. + Changed sCAL and iCCP failures from png_error to png_warning and abandon. + Added png_get_uint_31(png_ptr, buf) function. + Added PNG_UINT_32_MAX macro. + Renamed PNG_MAX_UINT to PNG_UINT_31_MAX. + Made png_zalloc() issue a png_warning and return NULL on potential + overflow. + Turn on PNG_NO_ZALLOC_ZERO by default in version 1.2.x + Revised "clobber list" in pnggccrd.c so it will compile under gcc-3.4. + Revised Borland portion of png_malloc() to return NULL or issue + png_error() according to setting of PNG_FLAG_MALLOC_NULL_MEM_OK. + Added PNG_NO_SEQUENTIAL_READ_SUPPORTED macro to conditionally remove + sequential read support. + Added some "#if PNG_WRITE_SUPPORTED" blocks. + #ifdef'ed out some redundancy in png_malloc_default(). + Use png_malloc instead of png_zalloc to allocate the pallete. +version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004] + Fixed buffer overflow vulnerability in png_handle_tRNS() + Fixed integer arithmetic overflow vulnerability in png_read_png(). + Fixed some harmless bugs in png_handle_sBIT, etc, that would cause + duplicate chunk types to go undetected. + Fixed some timestamps in the -config version + Rearranged order of processing of color types in png_handle_tRNS(). + Added ROWBYTES macro to calculate rowbytes without integer overflow. + Updated makefile.darwin and removed makefile.macosx from scripts directory. + Imposed default one million column, one-million row limits on the image + dimensions, and added png_set_user_limits() function to override them. + Revised use of PNG_SET_USER_LIMITS_SUPPORTED macro. + Fixed wrong cast of returns from png_get_user_width|height_max(). + Changed some "keep the compiler happy" from empty statements to returns, + Revised libpng.txt to remove 1.2.x stuff from the 1.0.x distribution +version 1.0.16rc2 and 1.2.6rc2 [August 7, 2004] + Revised makefile.darwin and makefile.solaris. Removed makefile.macosx. + Revised pngtest's png_debug_malloc() to use png_malloc() instead of + png_malloc_default() which is not supposed to be exported. + Fixed off-by-one error in one of the conversions to PNG_ROWBYTES() in + pngpread.c. Bug was introduced in 1.2.6rc1. + Fixed bug in RGB to RGBX transformation introduced in 1.2.6rc1. + Fixed old bug in RGB to Gray transformation. + Fixed problem with 64-bit compilers by casting arguments to abs() + to png_int_32. + Changed "ln -sf" to "ln -f -s" in three makefiles (solaris, sco, so9). + Changed "HANDLE_CHUNK_*" to "PNG_HANDLE_CHUNK_*" (Cosmin) + Added "-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)" to 15 *NIX makefiles. + Added code to update the row_info->colortype in png_do_read_filler() (MSB). +version 1.0.16rc3 and 1.2.6rc3 [August 9, 2004] + Eliminated use of "abs()" in testing cHRM and gAMA values, to avoid + trouble with some 64-bit compilers. Created PNG_OUT_OF_RANGE() macro. + Revised documentation of png_set_keep_unknown_chunks(). + Check handle_as_unknown status in pngpread.c, as in pngread.c previously. + Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_INTERNAL section of png.h + Added "rim" definitions for CONST4 and CONST6 in pnggccrd.c +version 1.0.16rc4 and 1.2.6rc4 [August 10, 2004] + Fixed mistake in pngtest.c introduced in 1.2.6rc2 (declaration of + "pinfo" was out of place). +version 1.0.16rc5 and 1.2.6rc5 [August 10, 2004] + Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_ASSEMBLER_CODE_SUPPORTED + section of png.h where they were inadvertently placed in version rc3. + +version 1.2.6 and 1.0.16 [August 15, 2004] + Revised pngtest so memory allocation testing is only done when PNG_DEBUG==1. +version 1.2.7beta1 [August 26, 2004] + Removed unused pngasmrd.h file. + Removed references to uu.net for archived files. Added references to + PNG Spec (second edition) and the PNG ISO/IEC Standard. + Added "test-dd" target in 15 makefiles, to run pngtest in DESTDIR. + Fixed bug with "optimized window size" in the IDAT datastream, that + causes libpng to write PNG files with incorrect zlib header bytes. +version 1.2.7beta2 [August 28, 2004] + Fixed bug with sCAL chunk and big-endian machines (David Munro). + Undid new code added in 1.2.6rc2 to update the color_type in + png_set_filler(). + Added png_set_add_alpha() that updates color type. +version 1.0.17rc1 and 1.2.7rc1 [September 4, 2004] + Revised png_set_strip_filler() to not remove alpha if color_type has alpha. + +version 1.2.7 and 1.0.17 [September 12, 2004] + Added makefile.hp64 + Changed projects/msvc/png32ms.def to scripts/png32ms.def in makefile.cygwin +version 1.2.8beta1 [November 1, 2004] + Fixed bug in png_text_compress() that would fail to complete a large block. + Fixed bug, introduced in libpng-1.2.7, that overruns a buffer during + strip alpha operation in png_do_strip_filler(). + Added PNG_1_2_X definition in pngconf.h + #ifdef out png_info_init in png.c and png_read_init in pngread.c (as of 1.3.0) +version 1.2.8beta2 [November 2, 2004] + Reduce color_type to a nonalpha type after strip alpha operation in + png_do_strip_filler(). +version 1.2.8beta3 [November 3, 2004] + Revised definitions of PNG_MAX_UINT_32, PNG_MAX_SIZE, and PNG_MAXSUM +version 1.2.8beta4 [November 12, 2004] + Fixed (again) definition of PNG_LIBPNG_VER_DLLNUM in png.h (Cosmin). + Added PNG_LIBPNG_BUILD_PRIVATE in png.h (Cosmin). + Set png_ptr->zstream.data_type to Z_BINARY, to avoid unnecessary detection + of data type in deflate (Cosmin). + Deprecated but continue to support SPECIALBUILD and PRIVATEBUILD in favor of + PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING. +version 1.2.8beta5 [November 20, 2004] + Use png_ptr->flags instead of png_ptr->transformations to pass + PNG_STRIP_ALPHA info to png_do_strip_filler(), to preserve ABI + compatibility. + Revised handling of SPECIALBUILD, PRIVATEBUILD, + PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING. +version 1.2.8rc1 [November 24, 2004] + Moved handling of BUILD macros from pngconf.h to png.h + Added definition of PNG_LIBPNG_BASE_TYPE in png.h, inadvertently + omitted from beta5. + Revised scripts/pngw32.rc + Despammed mailing addresses by masking "@" with "at". + Inadvertently installed a supposedly faster test version of pngrutil.c +version 1.2.8rc2 [November 26, 2004] + Added two missing "\" in png.h + Change tests in pngread.c and pngpread.c to + if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) + png_do_read_transformations(png_ptr); +version 1.2.8rc3 [November 28, 2004] + Reverted pngrutil.c to version libpng-1.2.8beta5. + Added scripts/makefile.elf with supporting code in pngconf.h for symbol + versioning (John Bowler). +version 1.2.8rc4 [November 29, 2004] + Added projects/visualc7 (Simon-pierre). +version 1.2.8rc5 [November 29, 2004] + Fixed new typo in scripts/pngw32.rc + +version 1.2.8 [December 3, 2004] + Removed projects/visualc7, added projects/visualc71. + +version 1.2.9beta1 [February 21, 2006] + + Initialized some structure members in pngwutil.c to avoid gcc-4.0.0 complaints + Revised man page and libpng.txt to make it clear that one should not call + png_read_end or png_write_end after png_read_png or png_write_png. + Updated references to png-mng-implement mailing list. + Fixed an incorrect typecast in pngrutil.c + Added PNG_NO_READ_SUPPORTED conditional for making a write-only library. + Added PNG_NO_WRITE_INTERLACING_SUPPORTED conditional. + Optimized alpha-inversion loops in pngwtran.c + Moved test for nonzero gamma outside of png_build_gamma_table() in pngrtran.c + Make sure num_trans is <= 256 before copying data in png_set_tRNS(). + Make sure num_palette is <= 256 before copying data in png_set_PLTE(). + Interchanged order of write_swap_alpha and write_invert_alpha transforms. + Added parentheses in the definition of PNG_LIBPNG_BUILD_TYPE (Cosmin). + Optimized zlib window flag (CINFO) in contrib/pngsuite/*.png (Cosmin). + Updated scripts/makefile.bc32 for Borland C++ 5.6 (Cosmin). + Exported png_get_uint_32, png_save_uint_32, png_get_uint_16, png_save_uint_16, + png_get_int_32, png_save_int_32, png_get_uint_31 (Cosmin). + Added type cast (png_byte) in png_write_sCAL() (Cosmin). + Fixed scripts/makefile.cygwin (Christian Biesinger, Cosmin). + Default iTXt support was inadvertently enabled. + +version 1.2.9beta2 [February 21, 2006] + + Check for png_rgb_to_gray and png_gray_to_rgb read transformations before + checking for png_read_dither in pngrtran.c + Revised checking of chromaticity limits to accommodate extended RGB + colorspace (John Denker). + Changed line endings in some of the project files to CRLF, even in the + "Unix" tar distributions (Cosmin). + Made png_get_int_32 and png_save_int_32 always available (Cosmin). + Updated scripts/pngos2.def, scripts/pngw32.def and projects/wince/png32ce.def + with the newly exported functions. + Eliminated distributions without the "configure" script. + Updated INSTALL instructions. + +version 1.2.9beta3 [February 24, 2006] + + Fixed CRCRLF line endings in contrib/visupng/VisualPng.dsp + Made libpng.pc respect EXEC_PREFIX (D. P. Kreil, J. Bowler) + Removed reference to pngasmrd.h from Makefile.am + Renamed CHANGES to ChangeLog. + Renamed LICENSE to COPYING. + Renamed ANNOUNCE to NEWS. + Created AUTHORS file. + +version 1.2.9beta4 [March 3, 2006] + + Changed definition of PKGCONFIG from $prefix/lib to $libdir in configure.ac + Reverted to filenames LICENSE and ANNOUNCE; removed AUTHORS and COPYING. + Removed newline from the end of some error and warning messages. + Removed test for sqrt() from configure.ac and configure. + Made swap tables in pngtrans.c PNG_CONST (Carlo Bramix). + Disabled default iTXt support that was inadvertently enabled in + libpng-1.2.9beta1. + Added "OS2" to list of systems that don't need underscores, in pnggccrd.c + Removed libpng version and date from *.c files. + +version 1.2.9beta5 [March 4, 2006] + Removed trailing blanks from source files. + Put version and date of latest change in each source file, and changed + copyright year accordingly. + More cleanup of configure.ac, Makefile.ac, and associated scripts. + Restored scripts/makefile.elf which was inadvertently deleted. + +version 1.2.9beta6 [March 6, 2006] + Fixed typo (16) in configuration files. + +version 1.2.9beta7 [March 7, 2006] + Removed libpng.vers and libpng.sym from libpng12_la_SOURCES in Makefile.am + Fixed inconsistent #ifdef's around png_sig_bytes() and png_set_sCAL_s() + in png.h. + Updated makefile.elf as suggested by debian. + Made cosmetic changes to some makefiles, adding LN_SF and other macros. + Made some makefiles accept "exec_prefix". + +version 1.2.9beta8 [March 9, 2006] + Fixed some "#if defined (..." which should be "#if defined(..." + Bug introduced in libpng-1.2.8. + Fixed inconsistency in definition of png_default_read_data() + Restored blank that was lost from makefile.sggcc "clean" target in beta7. + Revised calculation of "current" and "major" for irix in ltmain.sh + Changed "mkdir" to "MKDIR_P" in some makefiles. + Separated PNG_EXPAND and PNG_EXPAND_tRNS. + Added png_set_expand_gray_1_2_4_to_8() and deprecated + png_set_gray_1_2_4_to_8() which also expands tRNS to alpha. + +version 1.2.9beta9 [March 10, 2006] + Include "config.h" in pngconf.h when available. + Added some checks for NULL png_ptr or NULL info_ptr (timeless) + +version 1.2.9beta10 [March 20, 2006] + Removed extra CR from contrib/visualpng/VisualPng.dsw (Cosmin) + Made pnggccrd.c PIC-compliant (Christian Aichinger). + Added makefile.mingw (Wolfgang Glas). + Revised pngconf.h MMX checking. + +version 1.2.9beta11 [March 22, 2006] + Fixed out-of-order declaration in pngwrite.c that was introduced in beta9 + Simplified some makefiles by using LIBSO, LIBSOMAJ, and LIBSOVER macros. + +version 1.2.9rc1 [March 31, 2006] + Defined PNG_USER_PRIVATEBUILD when including "pngusr.h" (Cosmin). + Removed nonsensical assertion check from pngtest.c (Cosmin). + +version 1.2.9 [April 14, 2006] + Revised makefile.beos and added "none" selector in ltmain.sh + +version 1.2.10beta1 [April 15, 2006] + Renamed "config.h" to "png_conf.h" and revised Makefile.am to add + -DPNG_BUILDING_LIBPNG to compile directive, and modified pngconf.h + to include png_conf.h only when PNG_BUILDING_LIBPNG is defined. + +version 1.2.10beta2 [April 15, 2006] + Manually updated Makefile.in and configure. Changed png_conf.h.in + back to config.h. + +version 1.2.10beta3 [April 15, 2006] + Change png_conf.h back to config.h in pngconf.h. + +version 1.2.10beta4 [April 16, 2006] + Change PNG_BUILDING_LIBPNG to PNG_CONFIGURE_LIBPNG in config/Makefile*. + +version 1.2.10beta5 [April 16, 2006] + Added a configure check for compiling assembler code in pnggccrd.c + +version 1.2.10beta6 [April 17, 2006] + Revised the configure check for pnggccrd.c + Moved -DPNG_CONFIGURE_LIBPNG into @LIBPNG_DEFINES@ + Added @LIBPNG_DEFINES@ to arguments when building libpng.sym + +version 1.2.10beta7 [April 18, 2006] + Change "exec_prefix=$prefix" to "exec_prefix=$(prefix)" in makefiles. + +version 1.2.10rc1 [April 19, 2006] + Ensure pngconf.h doesn't define both PNG_USE_PNGGCCRD and PNG_USE_PNGVCRD + Fixed "LN_FS" typo in makefile.sco and makefile.solaris. + +version 1.2.10rc2 [April 20, 2006] + Added a backslash between -DPNG_CONFIGURE_LIBPNG and -DPNG_NO_ASSEMBLER_CODE + in configure.ac and configure + Made the configure warning about versioned symbols less arrogant. + +version 1.2.10rc3 [April 21, 2006] + Added a note in libpng.txt that png_set_sig_bytes(8) can be used when + writing an embedded PNG without the 8-byte signature. + Revised makefiles and configure to avoid making links to libpng.so.* + +version 1.2.10 [April 23, 2006] + Reverted configure to "rc2" state. + +version 1.2.11beta1 [May 31, 2006] + scripts/libpng.pc.in contained "configure" style version info and would + not work with makefiles. + The shared-library makefiles were linking to libpng.so.0 instead of + libpng.so.3 compatibility as the library. + +version 1.2.11beta2 [June 2, 2006] + Increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid + buffer overflow. + Fixed bug in example.c (png_set_palette_rgb -> png_set_palette_to_rgb) + +version 1.2.11beta3 [June 5, 2006] + Prepended "#! /bin/sh" to ltmail.sh and contrib/pngminus/*.sh (Cosmin). + Removed the accidental leftover Makefile.in~ (Cosmin). + Avoided potential buffer overflow and optimized buffer in + png_write_sCAL(), png_write_sCAL_s() (Cosmin). + Removed the include directories and libraries from CFLAGS and LDFLAGS + in scripts/makefile.gcc (Nelson A. de Oliveira, Cosmin). + +version 1.2.11beta4 [June 6, 2006] + Allow zero-length IDAT chunks after the entire zlib datastream, but not + after another intervening chunk type. + +version 1.0.19rc1, 1.2.11rc1 [June 13, 2006] + Deleted extraneous square brackets from [config.h] in configure.ac + +version 1.0.19rc2, 1.2.11rc2 [June 14, 2006] + Added prototypes for PNG_INCH_CONVERSIONS functions to png.h + Revised INSTALL and autogen.sh + Fixed typo in several makefiles (-W1 should be -Wl) + Added typedef for png_int_32 and png_uint_32 on 64-bit systems. + +version 1.0.19rc3, 1.2.11rc3 [June 15, 2006] + Removed the new typedefs for 64-bit systems (delay until version 1.4.0) + Added one zero element to png_gamma_shift[] array in pngrtran.c to avoid + reading out of bounds. + +version 1.0.19rc4, 1.2.11rc4 [June 15, 2006] + Really removed the new typedefs for 64-bit systems. + +version 1.0.19rc5, 1.2.11rc5 [June 22, 2006] + Removed png_sig_bytes entry from scripts/pngw32.def + +version 1.0.19, 1.2.11 [June 26, 2006] + None. + +version 1.0.20, 1.2.12 [June 27, 2006] + Really increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid + buffer overflow. + +version 1.2.13beta1 [October 2, 2006] + Removed AC_FUNC_MALLOC from configure.ac + Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h + Change "logical" to "bitwise" throughout documentation. + Detect and fix attempt to write wrong iCCP profile length. + +version 1.0.21, 1.2.13 [November 14, 2006] + Fix potential buffer overflow in sPLT chunk handler. + Fix Makefile.am to not try to link to noexistent files. + Check all exported functions for NULL png_ptr. + +version 1.2.14beta1 [November 17, 2006] + Relocated three misplaced tests for NULL png_ptr. + Built Makefile.in with automake-1.9.6 instead of 1.9.2. + Build configure with autoconf-2.60 instead of 2.59 + +version 1.2.14beta2 [November 17, 2006] + Added some typecasts in png_zalloc(). + +version 1.2.14rc1 [November 20, 2006] + Changed "strtod" to "png_strtod" in pngrutil.c + +version 1.0.22, 1.2.14 [November 27, 2006] + Added missing "$(srcdir)" in Makefile.am and Makefile.in + +version 1.2.15beta1 [December 3, 2006] + Generated configure with autoconf-2.61 instead of 2.60 + Revised configure.ac to update libpng.pc and libpng-config. + +version 1.2.15beta2 [December 3, 2006] + Always export MMX asm functions, just stubs if not building pnggccrd.c + +version 1.2.15beta3 [December 4, 2006] + Add "png_bytep" typecast to profile while calculating length in pngwutil.c + +version 1.2.15beta4 [December 7, 2006] + Added scripts/CMakeLists.txt + Changed PNG_NO_ASSEMBLER_CODE to PNG_NO_MMX_CODE in scripts, like 1.4.0beta + +version 1.2.15beta5 [December 7, 2006] + Changed some instances of PNG_ASSEMBLER_* to PNG_MMX_* in pnggccrd.c + Revised scripts/CMakeLists.txt + +version 1.2.15beta6 [December 13, 2006] + Revised scripts/CMakeLists.txt and configure.ac + +version 1.2.15rc1 [December 18, 2006] + Revised scripts/CMakeLists.txt + +version 1.2.15rc2 [December 21, 2006] + Added conditional #undef jmpbuf in pngtest.c to undo #define in AIX headers. + Added scripts/makefile.nommx + +version 1.2.15rc3 [December 25, 2006] + Fixed shared library numbering error that was intruduced in 1.2.15beta6. + +version 1.2.15rc4 [December 27, 2006] + Fixed handling of rgb_to_gray when png_ptr->color.gray isn't set. + +version 1.2.15rc5 [December 31, 2006] + Revised handling of rgb_to_gray. + +version 1.2.15 [January 5, 2007] + Added some (unsigned long) typecasts in pngtest.c to avoid printing errors. + +version 1.2.16beta1 [January 6, 2007] + Fix bugs in makefile.nommx + +version 1.2.16beta2 [January 16, 2007] + Revised scripts/CMakeLists.txt + +version 1.2.16 [January 31, 2007] + No changes. + +Send comments/corrections/commendations to png-mng-implement at lists.sf.net +(subscription required; visit +https://lists.sourceforge.net/lists/listinfo/png-mng-implement +to subscribe) +or to glennrp at users.sourceforge.net + +Glenn R-P diff --git a/src/dep/src/irrlicht/libpng/INSTALL b/src/dep/src/irrlicht/libpng/INSTALL index 4edfa79..222a5a4 100644 --- a/src/dep/src/irrlicht/libpng/INSTALL +++ b/src/dep/src/irrlicht/libpng/INSTALL @@ -1,206 +1,206 @@ - -Installing libpng version 1.2.16 - January 31, 2007 - -On Unix/Linux and similar systems, you can simply type - - ./configure [--prefix=/path] - make check - make install - -and ignore the rest of this document. - -If configure does not work on your system and you have a reasonably -up-to-date set of tools, running ./autogen.sh before running ./configure -may fix the problem. You can also run the individual commands in -autogen.sh with the --force option, if supported by your version of -the tools. If you run 'libtoolize --force', though, this will replace -the distributed, patched, version of ltmain.sh with an unpatched version -and your shared library builds may fail to produce libraries with the -correct version numbers. - -Instead, you can use one of the custom-built makefiles in the -"scripts" directory - - cp scripts/makefile.system makefile - make test - make install - -Or you can use one of the "projects" in the "projects" directory. - -If you want to use "cmake" (see www.cmake.org), copy CMakeLists.txt -from the "scripts" directory to this directory and type - - cmake . [-DPNG_MMX=YES] -DCMAKE_INSTALL_PREFIX=/path - make - make install - -Before installing libpng, you must first install zlib, if it -is not already on your system. zlib can usually be found -wherever you got libpng. zlib can be placed in another directory, -at the same level as libpng. - -If your system already has a preinstalled zlib you will still need -to have access to the zlib.h and zconf.h include files that -correspond to the version of zlib that's installed. - -You can rename the directories that you downloaded (they -might be called "libpng-1.2.16" or "lpng109" and "zlib-1.2.1" -or "zlib121") so that you have directories called "zlib" and "libpng". - -Your directory structure should look like this: - - .. (the parent directory) - libpng (this directory) - INSTALL (this file) - README - *.h - *.c - contrib - gregbook - pngminus - pngsuite - visupng - projects - beos - c5builder (Borland) - visualc6 (msvc) - netware.txt - wince.txt - scripts - makefile.* - pngtest.png - etc. - zlib - README - *.h - *.c - contrib - etc. - -If the line endings in the files look funny, you may wish to get the other -distribution of libpng. It is available in both tar.gz (UNIX style line -endings) and zip (DOS style line endings) formats. - -If you are building libpng with MSVC, you can enter the -libpng projects\visualc6 directory and follow the instructions in -projects\visualc6\README.txt. - -You can build libpng for WindowsCE by downloading and installing -the projects\wince directory as instructed in the projects\wince.txt file, and -then following the instructions in the README* files. Similarly, you can -build libpng for Netware or Beos as instructed in projects\netware.txt -or projects\beos. - -Else enter the zlib directory and follow the instructions in zlib/README, -then come back here and run "configure" or choose the appropriate -makefile.sys in the scripts directory. - -The files that are presently available in the scripts directory -include - - CMakeLists.txt => "cmake" script - makefile.std => Generic UNIX makefile (cc, creates static libpng.a) - makefile.elf => Linux/ELF makefile symbol versioning, - gcc, creates libpng12.so.0.1.2.16) - makefile.linux => Linux/ELF makefile - (gcc, creates libpng12.so.0.1.2.16) - makefile.gcmmx => Linux/ELF makefile - (gcc, creates libpng12.so.0.1.2.16, - uses assembler code tuned for Intel MMX platform) - makefile.nommx => Linux/ELF makefile - (gcc, creates libpng12.so.0.1.2.16 - does not use Intel MMX assembler code) - makefile.gcc => Generic makefile (gcc, creates static libpng.a) - makefile.knr => Archaic UNIX Makefile that converts files with - ansi2knr (Requires ansi2knr.c from - ftp://ftp.cs.wisc.edu/ghost) - makefile.aix => AIX/gcc makefile - makefile.cygwin => Cygwin/gcc makefile - makefile.darwin => Darwin makefile, can use on MacosX - makefile.dec => DEC Alpha UNIX makefile - makefile.freebsd => FreeBSD makefile - makefile.hpgcc => HPUX makefile using gcc - makefile.hpux => HPUX (10.20 and 11.00) makefile - makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64-bit - makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) - makefile.intel => Intel C/C++ version 4.0 and later - libpng.icc => Project file for IBM VisualAge/C++ version 4.0 or later - makefile.netbsd => NetBSD/cc makefile, uses PNGGCCRD, makes libpng.so. - makefile.ne12bsd => NetBSD/cc makefile, uses PNGGCCRD, - makes libpng12.so - makefile.openbsd => OpenBSD makefile - makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) - makefile.sggcc => Silicon Graphics (gcc, - creates libpng12.so.0.1.2.16) - makefile.sunos => Sun makefile - makefile.solaris => Solaris 2.X makefile (gcc, - creates libpng12.so.0.1.2.16) - makefile.so9 => Solaris 9 makefile (gcc, - creates libpng12.so.0.1.2.16) - makefile.32sunu => Sun Ultra 32-bit makefile - makefile.64sunu => Sun Ultra 64-bit makefile - makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc - makefile.mips => MIPS makefile - makefile.acorn => Acorn makefile - makefile.amiga => Amiga makefile - smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler - (Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc) - makefile.atari => Atari makefile - makefile.beos => BEOS makefile for X86 - makefile.bor => Borland makefile (uses bcc) - makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode) - makefile.tc3 => Turbo C 3.0 makefile - makefile.dj2 => DJGPP 2 makefile - makefile.msc => Microsoft C makefile - makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and later (uses - assembler code tuned for Intel MMX platform) - makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later (does - not use assembler code) - makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) - pngos2.def => OS/2 module definition file used by makefile.os2 - makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model - makevms.com => VMS build script - descrip.mms => VMS makefile for MMS or MMK - SCOPTIONS.ppc => Used with smakefile.ppc - -Copy the file (or files) that you need from the -scripts directory into this directory, for example - - MSDOS example: copy scripts\makefile.msc makefile - UNIX example: cp scripts/makefile.std makefile - -Read the makefile to see if you need to change any source or -target directories to match your preferences. - -Then read pngconf.h to see if you want to make any configuration -changes. - -Then just run "make" which will create the libpng library in -this directory and "make test" which will run a quick test that reads -the "pngtest.png" file and writes a "pngout.png" file that should be -identical to it. Look for "9782 zero samples" in the output of the -test. For more confidence, you can run another test by typing -"pngtest pngnow.png" and looking for "289 zero samples" in the output. -Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare -your output with the result shown in contrib/pngsuite/README. - -Most of the makefiles will allow you to run "make install" to -put the library in its final resting place (if you want to -do that, run "make install" in the zlib directory first if necessary). -Some also allow you to run "make test-installed" after you have -run "make install". - -If you encounter a compiler error message complaining about the -lines - __png.h__ already includes setjmp.h; - __dont__ include it again.; -This means you have compiled another module that includes setjmp.h, -which is hazardous because the two modules might not include exactly -the same setjmp.h. If you are sure that you know what you are doing -and that they are exactly the same, then you can comment out or -delete the two lines. Better yet, use the cexcept interface -instead, as demonstrated in contrib/visupng of the libpng distribution. - -Further information can be found in the README and libpng.txt -files, in the individual makefiles, in png.h, and the manual pages -libpng.3 and png.5. + +Installing libpng version 1.2.16 - January 31, 2007 + +On Unix/Linux and similar systems, you can simply type + + ./configure [--prefix=/path] + make check + make install + +and ignore the rest of this document. + +If configure does not work on your system and you have a reasonably +up-to-date set of tools, running ./autogen.sh before running ./configure +may fix the problem. You can also run the individual commands in +autogen.sh with the --force option, if supported by your version of +the tools. If you run 'libtoolize --force', though, this will replace +the distributed, patched, version of ltmain.sh with an unpatched version +and your shared library builds may fail to produce libraries with the +correct version numbers. + +Instead, you can use one of the custom-built makefiles in the +"scripts" directory + + cp scripts/makefile.system makefile + make test + make install + +Or you can use one of the "projects" in the "projects" directory. + +If you want to use "cmake" (see www.cmake.org), copy CMakeLists.txt +from the "scripts" directory to this directory and type + + cmake . [-DPNG_MMX=YES] -DCMAKE_INSTALL_PREFIX=/path + make + make install + +Before installing libpng, you must first install zlib, if it +is not already on your system. zlib can usually be found +wherever you got libpng. zlib can be placed in another directory, +at the same level as libpng. + +If your system already has a preinstalled zlib you will still need +to have access to the zlib.h and zconf.h include files that +correspond to the version of zlib that's installed. + +You can rename the directories that you downloaded (they +might be called "libpng-1.2.16" or "lpng109" and "zlib-1.2.1" +or "zlib121") so that you have directories called "zlib" and "libpng". + +Your directory structure should look like this: + + .. (the parent directory) + libpng (this directory) + INSTALL (this file) + README + *.h + *.c + contrib + gregbook + pngminus + pngsuite + visupng + projects + beos + c5builder (Borland) + visualc6 (msvc) + netware.txt + wince.txt + scripts + makefile.* + pngtest.png + etc. + zlib + README + *.h + *.c + contrib + etc. + +If the line endings in the files look funny, you may wish to get the other +distribution of libpng. It is available in both tar.gz (UNIX style line +endings) and zip (DOS style line endings) formats. + +If you are building libpng with MSVC, you can enter the +libpng projects\visualc6 directory and follow the instructions in +projects\visualc6\README.txt. + +You can build libpng for WindowsCE by downloading and installing +the projects\wince directory as instructed in the projects\wince.txt file, and +then following the instructions in the README* files. Similarly, you can +build libpng for Netware or Beos as instructed in projects\netware.txt +or projects\beos. + +Else enter the zlib directory and follow the instructions in zlib/README, +then come back here and run "configure" or choose the appropriate +makefile.sys in the scripts directory. + +The files that are presently available in the scripts directory +include + + CMakeLists.txt => "cmake" script + makefile.std => Generic UNIX makefile (cc, creates static libpng.a) + makefile.elf => Linux/ELF makefile symbol versioning, + gcc, creates libpng12.so.0.1.2.16) + makefile.linux => Linux/ELF makefile + (gcc, creates libpng12.so.0.1.2.16) + makefile.gcmmx => Linux/ELF makefile + (gcc, creates libpng12.so.0.1.2.16, + uses assembler code tuned for Intel MMX platform) + makefile.nommx => Linux/ELF makefile + (gcc, creates libpng12.so.0.1.2.16 + does not use Intel MMX assembler code) + makefile.gcc => Generic makefile (gcc, creates static libpng.a) + makefile.knr => Archaic UNIX Makefile that converts files with + ansi2knr (Requires ansi2knr.c from + ftp://ftp.cs.wisc.edu/ghost) + makefile.aix => AIX/gcc makefile + makefile.cygwin => Cygwin/gcc makefile + makefile.darwin => Darwin makefile, can use on MacosX + makefile.dec => DEC Alpha UNIX makefile + makefile.freebsd => FreeBSD makefile + makefile.hpgcc => HPUX makefile using gcc + makefile.hpux => HPUX (10.20 and 11.00) makefile + makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64-bit + makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) + makefile.intel => Intel C/C++ version 4.0 and later + libpng.icc => Project file for IBM VisualAge/C++ version 4.0 or later + makefile.netbsd => NetBSD/cc makefile, uses PNGGCCRD, makes libpng.so. + makefile.ne12bsd => NetBSD/cc makefile, uses PNGGCCRD, + makes libpng12.so + makefile.openbsd => OpenBSD makefile + makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) + makefile.sggcc => Silicon Graphics (gcc, + creates libpng12.so.0.1.2.16) + makefile.sunos => Sun makefile + makefile.solaris => Solaris 2.X makefile (gcc, + creates libpng12.so.0.1.2.16) + makefile.so9 => Solaris 9 makefile (gcc, + creates libpng12.so.0.1.2.16) + makefile.32sunu => Sun Ultra 32-bit makefile + makefile.64sunu => Sun Ultra 64-bit makefile + makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc + makefile.mips => MIPS makefile + makefile.acorn => Acorn makefile + makefile.amiga => Amiga makefile + smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler + (Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc) + makefile.atari => Atari makefile + makefile.beos => BEOS makefile for X86 + makefile.bor => Borland makefile (uses bcc) + makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode) + makefile.tc3 => Turbo C 3.0 makefile + makefile.dj2 => DJGPP 2 makefile + makefile.msc => Microsoft C makefile + makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and later (uses + assembler code tuned for Intel MMX platform) + makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later (does + not use assembler code) + makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) + pngos2.def => OS/2 module definition file used by makefile.os2 + makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model + makevms.com => VMS build script + descrip.mms => VMS makefile for MMS or MMK + SCOPTIONS.ppc => Used with smakefile.ppc + +Copy the file (or files) that you need from the +scripts directory into this directory, for example + + MSDOS example: copy scripts\makefile.msc makefile + UNIX example: cp scripts/makefile.std makefile + +Read the makefile to see if you need to change any source or +target directories to match your preferences. + +Then read pngconf.h to see if you want to make any configuration +changes. + +Then just run "make" which will create the libpng library in +this directory and "make test" which will run a quick test that reads +the "pngtest.png" file and writes a "pngout.png" file that should be +identical to it. Look for "9782 zero samples" in the output of the +test. For more confidence, you can run another test by typing +"pngtest pngnow.png" and looking for "289 zero samples" in the output. +Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare +your output with the result shown in contrib/pngsuite/README. + +Most of the makefiles will allow you to run "make install" to +put the library in its final resting place (if you want to +do that, run "make install" in the zlib directory first if necessary). +Some also allow you to run "make test-installed" after you have +run "make install". + +If you encounter a compiler error message complaining about the +lines + __png.h__ already includes setjmp.h; + __dont__ include it again.; +This means you have compiled another module that includes setjmp.h, +which is hazardous because the two modules might not include exactly +the same setjmp.h. If you are sure that you know what you are doing +and that they are exactly the same, then you can comment out or +delete the two lines. Better yet, use the cexcept interface +instead, as demonstrated in contrib/visupng of the libpng distribution. + +Further information can be found in the README and libpng.txt +files, in the individual makefiles, in png.h, and the manual pages +libpng.3 and png.5. diff --git a/src/dep/src/irrlicht/libpng/KNOWNBUG b/src/dep/src/irrlicht/libpng/KNOWNBUG index b67757e..e81e7dc 100644 --- a/src/dep/src/irrlicht/libpng/KNOWNBUG +++ b/src/dep/src/irrlicht/libpng/KNOWNBUG @@ -1,23 +1,23 @@ - -Known bugs in libpng version 1.2.16 - -1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when - reading interlaced PNG files, when assembler code is enabled but running - on a non-MMX i386 platform. - - STATUS: Under investigation. The change to pnggccrd.c in libpng-1.2.1 - fixed a problem under FreeBSD but not the problem with NetBSD, which - still fails as of libpng-1.2.2rc1. - -2. February 23, 2006: The custom makefiles don't build libpng with -lz. - - STATUS: This is a subject of debate. The change will probably be made - as a part of a major overhaul of the makefiles in libpng version 1.3.0. - -3. February 24, 2006: The Makefile generated by the "configure" script - fails to install symbolic links - libpng12.so => libpng12.so.0.1.2.9betaN - that are generated by the custom makefiles. - - STATUS: For now, system library builders should use the custom makefiles. - + +Known bugs in libpng version 1.2.16 + +1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when + reading interlaced PNG files, when assembler code is enabled but running + on a non-MMX i386 platform. + + STATUS: Under investigation. The change to pnggccrd.c in libpng-1.2.1 + fixed a problem under FreeBSD but not the problem with NetBSD, which + still fails as of libpng-1.2.2rc1. + +2. February 23, 2006: The custom makefiles don't build libpng with -lz. + + STATUS: This is a subject of debate. The change will probably be made + as a part of a major overhaul of the makefiles in libpng version 1.3.0. + +3. February 24, 2006: The Makefile generated by the "configure" script + fails to install symbolic links + libpng12.so => libpng12.so.0.1.2.9betaN + that are generated by the custom makefiles. + + STATUS: For now, system library builders should use the custom makefiles. + diff --git a/src/dep/src/irrlicht/libpng/LICENSE b/src/dep/src/irrlicht/libpng/LICENSE index 9a28646..597216f 100644 --- a/src/dep/src/irrlicht/libpng/LICENSE +++ b/src/dep/src/irrlicht/libpng/LICENSE @@ -1,109 +1,109 @@ - -This copy of the libpng notices is provided for your convenience. In case of -any discrepancy between this copy and the notices in the file png.h that is -included in the libpng distribution, the latter shall prevail. - -COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: - -If you modify libpng you may insert additional notices immediately following -this sentence. - -libpng versions 1.2.6, August 15, 2004, through 1.2.16, January 31, 2007, are -Copyright (c) 2004, 2006 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-1.2.5 -with the following individual added to the list of Contributing Authors - - Cosmin Truta - -libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are -Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-1.0.6 -with the following individuals added to the list of Contributing Authors - - Simon-Pierre Cadieux - Eric S. Raymond - Gilles Vollant - -and with the following additions to the disclaimer: - - There is no warranty against interference with your enjoyment of the - library or against infringement. There is no warranty that our - efforts or the library will fulfill any of your particular purposes - or needs. This library is provided with all faults, and the entire - risk of satisfactory quality, performance, accuracy, and effort is with - the user. - -libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are -Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-0.96, -with the following individuals added to the list of Contributing Authors: - - Tom Lane - Glenn Randers-Pehrson - Willem van Schaik - -libpng versions 0.89, June 1996, through 0.96, May 1997, are -Copyright (c) 1996, 1997 Andreas Dilger -Distributed according to the same disclaimer and license as libpng-0.88, -with the following individuals added to the list of Contributing Authors: - - John Bowler - Kevin Bracey - Sam Bushell - Magnus Holmgren - Greg Roelofs - Tom Tanner - -libpng versions 0.5, May 1995, through 0.88, January 1996, are -Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. - -For the purposes of this copyright and license, "Contributing Authors" -is defined as the following set of individuals: - - Andreas Dilger - Dave Martindale - Guy Eric Schalnat - Paul Schmidt - Tim Wegner - -The PNG Reference Library is supplied "AS IS". The Contributing Authors -and Group 42, Inc. disclaim all warranties, expressed or implied, -including, without limitation, the warranties of merchantability and of -fitness for any purpose. The Contributing Authors and Group 42, Inc. -assume no liability for direct, indirect, incidental, special, exemplary, -or consequential damages, which may result from the use of the PNG -Reference Library, even if advised of the possibility of such damage. - -Permission is hereby granted to use, copy, modify, and distribute this -source code, or portions hereof, for any purpose, without fee, subject -to the following restrictions: - -1. The origin of this source code must not be misrepresented. - -2. Altered versions must be plainly marked as such and must not - be misrepresented as being the original source. - -3. This Copyright notice may not be removed or altered from any - source or altered source distribution. - -The Contributing Authors and Group 42, Inc. specifically permit, without -fee, and encourage the use of this source code as a component to -supporting the PNG file format in commercial products. If you use this -source code in a product, acknowledgment is not required but would be -appreciated. - - -A "png_get_copyright" function is available, for convenient use in "about" -boxes and the like: - - printf("%s",png_get_copyright(NULL)); - -Also, the PNG logo (in PNG format, of course) is supplied in the -files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - -Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a -certification mark of the Open Source Initiative. - -Glenn Randers-Pehrson -glennrp at users.sourceforge.net -January 31, 2007 + +This copy of the libpng notices is provided for your convenience. In case of +any discrepancy between this copy and the notices in the file png.h that is +included in the libpng distribution, the latter shall prevail. + +COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: + +If you modify libpng you may insert additional notices immediately following +this sentence. + +libpng versions 1.2.6, August 15, 2004, through 1.2.16, January 31, 2007, are +Copyright (c) 2004, 2006 Glenn Randers-Pehrson, and are +distributed according to the same disclaimer and license as libpng-1.2.5 +with the following individual added to the list of Contributing Authors + + Cosmin Truta + +libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are +Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are +distributed according to the same disclaimer and license as libpng-1.0.6 +with the following individuals added to the list of Contributing Authors + + Simon-Pierre Cadieux + Eric S. Raymond + Gilles Vollant + +and with the following additions to the disclaimer: + + There is no warranty against interference with your enjoyment of the + library or against infringement. There is no warranty that our + efforts or the library will fulfill any of your particular purposes + or needs. This library is provided with all faults, and the entire + risk of satisfactory quality, performance, accuracy, and effort is with + the user. + +libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are +Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are +distributed according to the same disclaimer and license as libpng-0.96, +with the following individuals added to the list of Contributing Authors: + + Tom Lane + Glenn Randers-Pehrson + Willem van Schaik + +libpng versions 0.89, June 1996, through 0.96, May 1997, are +Copyright (c) 1996, 1997 Andreas Dilger +Distributed according to the same disclaimer and license as libpng-0.88, +with the following individuals added to the list of Contributing Authors: + + John Bowler + Kevin Bracey + Sam Bushell + Magnus Holmgren + Greg Roelofs + Tom Tanner + +libpng versions 0.5, May 1995, through 0.88, January 1996, are +Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. + +For the purposes of this copyright and license, "Contributing Authors" +is defined as the following set of individuals: + + Andreas Dilger + Dave Martindale + Guy Eric Schalnat + Paul Schmidt + Tim Wegner + +The PNG Reference Library is supplied "AS IS". The Contributing Authors +and Group 42, Inc. disclaim all warranties, expressed or implied, +including, without limitation, the warranties of merchantability and of +fitness for any purpose. The Contributing Authors and Group 42, Inc. +assume no liability for direct, indirect, incidental, special, exemplary, +or consequential damages, which may result from the use of the PNG +Reference Library, even if advised of the possibility of such damage. + +Permission is hereby granted to use, copy, modify, and distribute this +source code, or portions hereof, for any purpose, without fee, subject +to the following restrictions: + +1. The origin of this source code must not be misrepresented. + +2. Altered versions must be plainly marked as such and must not + be misrepresented as being the original source. + +3. This Copyright notice may not be removed or altered from any + source or altered source distribution. + +The Contributing Authors and Group 42, Inc. specifically permit, without +fee, and encourage the use of this source code as a component to +supporting the PNG file format in commercial products. If you use this +source code in a product, acknowledgment is not required but would be +appreciated. + + +A "png_get_copyright" function is available, for convenient use in "about" +boxes and the like: + + printf("%s",png_get_copyright(NULL)); + +Also, the PNG logo (in PNG format, of course) is supplied in the +files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). + +Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a +certification mark of the Open Source Initiative. + +Glenn Randers-Pehrson +glennrp at users.sourceforge.net +January 31, 2007 diff --git a/src/dep/src/irrlicht/libpng/README b/src/dep/src/irrlicht/libpng/README index 9a6fee4..915efcf 100644 --- a/src/dep/src/irrlicht/libpng/README +++ b/src/dep/src/irrlicht/libpng/README @@ -1,263 +1,263 @@ -README for libpng version 1.2.16 - January 31, 2007 (shared library 12.0) -See the note about version numbers near the top of png.h - -See INSTALL for instructions on how to install libpng. - -Libpng comes in several distribution formats. Get libpng-*.tar.gz -or libpng-*.tar.bz2 if you want UNIX-style line endings in the text -files, or lpng*.zip if you want DOS-style line endings. - -Version 0.89 was the first official release of libpng. Don't let the -fact that it's the first release fool you. The libpng library has been in -extensive use and testing since mid-1995. By late 1997 it had -finally gotten to the stage where there hadn't been significant -changes to the API in some time, and people have a bad feeling about -libraries with versions < 1.0. Version 1.0.0 was released in -March 1998. - -**** -Note that some of the changes to the png_info structure render this -version of the library binary incompatible with libpng-0.89 or -earlier versions if you are using a shared library. The type of the -"filler" parameter for png_set_filler() has changed from png_byte to -png_uint_32, which will affect shared-library applications that use -this function. - -To avoid problems with changes to the internals of png_info_struct, -new APIs have been made available in 0.95 to avoid direct application -access to info_ptr. These functions are the png_set_ and -png_get_ functions. These functions should be used when -accessing/storing the info_struct data, rather than manipulating it -directly, to avoid such problems in the future. - -It is important to note that the APIs do not make current programs -that access the info struct directly incompatible with the new -library. However, it is strongly suggested that new programs use -the new APIs (as shown in example.c and pngtest.c), and older programs -be converted to the new format, to facilitate upgrades in the future. -**** - -Additions since 0.90 include the ability to compile libpng as a -Windows DLL, and new APIs for accessing data in the info struct. -Experimental functions include the ability to set weighting and cost -factors for row filter selection, direct reads of integers from buffers -on big-endian processors that support misaligned data access, faster -methods of doing alpha composition, and more accurate 16->8 bit color -conversion. - -The additions since 0.89 include the ability to read from a PNG stream -which has had some (or all) of the signature bytes read by the calling -application. This also allows the reading of embedded PNG streams that -do not have the PNG file signature. As well, it is now possible to set -the library action on the detection of chunk CRC errors. It is possible -to set different actions based on whether the CRC error occurred in a -critical or an ancillary chunk. - -The changes made to the library, and bugs fixed are based on discussions -on the PNG-implement mailing list -and not on material submitted privately to Guy, Andreas, or Glenn. They will -forward any good suggestions to the list. - -For a detailed description on using libpng, read libpng.txt. For -examples of libpng in a program, see example.c and pngtest.c. For usage -information and restrictions (what little they are) on libpng, see -png.h. For a description on using zlib (the compression library used by -libpng) and zlib's restrictions, see zlib.h - -I have included a general makefile, as well as several machine and -compiler specific ones, but you may have to modify one for your own needs. - -You should use zlib 1.0.4 or later to run this, but it MAY work with -versions as old as zlib 0.95. Even so, there are bugs in older zlib -versions which can cause the output of invalid compression streams for -some images. You will definitely need zlib 1.0.4 or later if you are -taking advantage of the MS-DOS "far" structure allocation for the small -and medium memory models. You should also note that zlib is a -compression library that is useful for more things than just PNG files. -You can use zlib as a drop-in replacement for fread() and fwrite() if -you are so inclined. - -zlib should be available at the same place that libpng is, or at. -ftp://ftp.info-zip.org/pub/infozip/zlib - -You may also want a copy of the PNG specification. It is available -as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find -these at http://www.libpng.org/pub/png/documents/ - -This code is currently being archived at libpng.sf.net in the -[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT) -at GO GRAPHSUP. If you can't find it in any of those places, -e-mail me, and I'll help you find it. - -If you have any code changes, requests, problems, etc., please e-mail -them to me. Also, I'd appreciate any make files or project files, -and any modifications you needed to make to get libpng to compile, -along with a #define variable to tell what compiler/system you are on. -If you needed to add transformations to libpng, or wish libpng would -provide the image in a different way, drop me a note (and code, if -possible), so I can consider supporting the transformation. -Finally, if you get any warning messages when compiling libpng -(note: not zlib), and they are easy to fix, I'd appreciate the -fix. Please mention "libpng" somewhere in the subject line. Thanks. - -This release was created and will be supported by myself (of course -based in a large way on Guy's and Andreas' earlier work), and the PNG group. - -Send comments/corrections/commendations to png-mng-implement at lists.sf.net -(subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe) or to glennrp at users.sourceforge.net - -You can't reach Guy, the original libpng author, at the addresses -given in previous versions of this document. He and Andreas will read mail -addressed to the png-implement list, however. - -Please do not send general questions about PNG. Send them to -the (png-list at ccrc.wustl.edu, subscription required, write to -majordomo at ccrc.wustl.edu with "subscribe png-list" in your message). -On the other hand, -please do not send libpng questions to that address, send them to me -or to the png-implement list. I'll -get them in the end anyway. If you have a question about something -in the PNG specification that is related to using libpng, send it -to me. Send me any questions that start with "I was using libpng, -and ...". If in doubt, send questions to me. I'll bounce them -to others, if necessary. - -Please do not send suggestions on how to change PNG. We have -been discussing PNG for nine years now, and it is official and -finished. If you have suggestions for libpng, however, I'll -gladly listen. Even if your suggestion is not used immediately, -it may be used later. - -Files in this distribution: - - ANNOUNCE => Announcement of this version, with recent changes - CHANGES => Description of changes between libpng versions - KNOWNBUG => List of known bugs and deficiencies - LICENSE => License to use and redistribute libpng - README => This file - TODO => Things not implemented in the current library - Y2KINFO => Statement of Y2K compliance - example.c => Example code for using libpng functions - libpng.3 => manual page for libpng (includes libpng.txt) - libpng.txt => Description of libpng and its functions - libpngpf.3 => manual page for libpng's private functions - png.5 => manual page for the PNG format - png.c => Basic interface functions common to library - png.h => Library function and interface declarations - pngconf.h => System specific library configuration - pngasmrd.h => Header file for assembler-coded functions - pngerror.c => Error/warning message I/O functions - pngget.c => Functions for retrieving info from struct - pngmem.c => Memory handling functions - pngbar.png => PNG logo, 88x31 - pngnow.png => PNG logo, 98x31 - pngpread.c => Progressive reading functions - pngread.c => Read data/helper high-level functions - pngrio.c => Lowest-level data read I/O functions - pngrtran.c => Read data transformation functions - pngrutil.c => Read data utility functions - pngset.c => Functions for storing data into the info_struct - pngtest.c => Library test program - pngtest.png => Library test sample image - pngtrans.c => Common data transformation functions - pngwio.c => Lowest-level write I/O functions - pngwrite.c => High-level write functions - pngwtran.c => Write data transformations - pngwutil.c => Write utility functions - contrib => Contributions - gregbook => source code for PNG reading and writing, from - Greg Roelofs' "PNG: The Definitive Guide", - O'Reilly, 1999 - msvctest => Builds and runs pngtest using a MSVC workspace - pngminus => Simple pnm2png and png2pnm programs - pngsuite => Test images - visupng => Contains a MSVC workspace for VisualPng - projects => Contains project files and workspaces for building DLL - beos => Contains a Beos workspace for building libpng - c5builder => Contains a Borland workspace for building libpng - and zlib - visualc6 => Contains a Microsoft Visual C++ (MSVC) workspace - for building libpng and zlib - netware.txt => Contains instructions for downloading a set of - project files for building libpng and zlib on - Netware. - wince.txt => Contains instructions for downloading a Microsoft - Visual C++ (Windows CD Toolkit) workspace for - building libpng and zlib on WindowsCE - scripts => Directory containing scripts for building libpng: - descrip.mms => VMS makefile for MMS or MMK - makefile.std => Generic UNIX makefile (cc, creates static libpng.a) - makefile.elf => Linux/ELF makefile symbol versioning, - gcc, creates libpng12.so.0.1.2.16) - makefile.linux => Linux/ELF makefile - (gcc, creates libpng12.so.0.1.2.16) - makefile.gcmmx => Linux/ELF makefile - (gcc, creates libpng12.so.0.1.2.16, - uses assembler code tuned for Intel MMX platform) - makefile.gcc => Generic makefile (gcc, creates static libpng.a) - makefile.knr => Archaic UNIX Makefile that converts files with - ansi2knr (Requires ansi2knr.c from - ftp://ftp.cs.wisc.edu/ghost) - makefile.aix => AIX makefile - makefile.cygwin => Cygwin/gcc makefile - makefile.darwin => Darwin makefile - makefile.dec => DEC Alpha UNIX makefile - makefile.freebsd => FreeBSD makefile - makefile.hpgcc => HPUX makefile using gcc - makefile.hpux => HPUX (10.20 and 11.00) makefile - makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64 bit - makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) - makefile.intel => Intel C/C++ version 4.0 and later - libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later - makefile.netbsd => NetBSD/cc makefile, PNGGCCRD, makes libpng.so. - makefile.ne12bsd => NetBSD/cc makefile, PNGGCCRD, makes libpng12.so - makefile.openbsd => OpenBSD makefile - makefile.sgi => Silicon Graphics IRIX (cc, creates static lib) - makefile.sggcc => Silicon Graphics - (gcc, creates libpng12.so.0.1.2.16) - makefile.sunos => Sun makefile - makefile.solaris => Solaris 2.X makefile - (gcc, creates libpng12.so.0.1.2.16) - makefile.so9 => Solaris 9 makefile - (gcc, creates libpng12.so.0.1.2.16) - makefile.32sunu => Sun Ultra 32-bit makefile - makefile.64sunu => Sun Ultra 64-bit makefile - makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc - makefile.mips => MIPS makefile - makefile.acorn => Acorn makefile - makefile.amiga => Amiga makefile - smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC - compiler (Requires SCOPTIONS, copied from - scripts/SCOPTIONS.ppc) - makefile.atari => Atari makefile - makefile.beos => BEOS makefile for X86 - makefile.bor => Borland makefile (uses bcc) - makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode) - makefile.tc3 => Turbo C 3.0 makefile - makefile.dj2 => DJGPP 2 makefile - makefile.msc => Microsoft C makefile - makefile.vcawin32=> makefile for Microsoft Visual C++ 5.0 and - later (uses assembler code tuned for Intel MMX - platform) - makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and - later (does not use assembler code) - makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) - pngos2.def => OS/2 module definition file used by makefile.os2 - makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model - makevms.com => VMS build script - SCOPTIONS.ppc => Used with smakefile.ppc - -Good luck, and happy coding. - --Glenn Randers-Pehrson (current maintainer) - Internet: glennrp at users.sourceforge.net - --Andreas Eric Dilger (former maintainer, 1996-1997) - Internet: adilger at enel.ucalgary.ca - Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/ - --Guy Eric Schalnat (original author and former maintainer, 1995-1996) - (formerly of Group 42, Inc) - Internet: gschal at infinet.com +README for libpng version 1.2.16 - January 31, 2007 (shared library 12.0) +See the note about version numbers near the top of png.h + +See INSTALL for instructions on how to install libpng. + +Libpng comes in several distribution formats. Get libpng-*.tar.gz +or libpng-*.tar.bz2 if you want UNIX-style line endings in the text +files, or lpng*.zip if you want DOS-style line endings. + +Version 0.89 was the first official release of libpng. Don't let the +fact that it's the first release fool you. The libpng library has been in +extensive use and testing since mid-1995. By late 1997 it had +finally gotten to the stage where there hadn't been significant +changes to the API in some time, and people have a bad feeling about +libraries with versions < 1.0. Version 1.0.0 was released in +March 1998. + +**** +Note that some of the changes to the png_info structure render this +version of the library binary incompatible with libpng-0.89 or +earlier versions if you are using a shared library. The type of the +"filler" parameter for png_set_filler() has changed from png_byte to +png_uint_32, which will affect shared-library applications that use +this function. + +To avoid problems with changes to the internals of png_info_struct, +new APIs have been made available in 0.95 to avoid direct application +access to info_ptr. These functions are the png_set_ and +png_get_ functions. These functions should be used when +accessing/storing the info_struct data, rather than manipulating it +directly, to avoid such problems in the future. + +It is important to note that the APIs do not make current programs +that access the info struct directly incompatible with the new +library. However, it is strongly suggested that new programs use +the new APIs (as shown in example.c and pngtest.c), and older programs +be converted to the new format, to facilitate upgrades in the future. +**** + +Additions since 0.90 include the ability to compile libpng as a +Windows DLL, and new APIs for accessing data in the info struct. +Experimental functions include the ability to set weighting and cost +factors for row filter selection, direct reads of integers from buffers +on big-endian processors that support misaligned data access, faster +methods of doing alpha composition, and more accurate 16->8 bit color +conversion. + +The additions since 0.89 include the ability to read from a PNG stream +which has had some (or all) of the signature bytes read by the calling +application. This also allows the reading of embedded PNG streams that +do not have the PNG file signature. As well, it is now possible to set +the library action on the detection of chunk CRC errors. It is possible +to set different actions based on whether the CRC error occurred in a +critical or an ancillary chunk. + +The changes made to the library, and bugs fixed are based on discussions +on the PNG-implement mailing list +and not on material submitted privately to Guy, Andreas, or Glenn. They will +forward any good suggestions to the list. + +For a detailed description on using libpng, read libpng.txt. For +examples of libpng in a program, see example.c and pngtest.c. For usage +information and restrictions (what little they are) on libpng, see +png.h. For a description on using zlib (the compression library used by +libpng) and zlib's restrictions, see zlib.h + +I have included a general makefile, as well as several machine and +compiler specific ones, but you may have to modify one for your own needs. + +You should use zlib 1.0.4 or later to run this, but it MAY work with +versions as old as zlib 0.95. Even so, there are bugs in older zlib +versions which can cause the output of invalid compression streams for +some images. You will definitely need zlib 1.0.4 or later if you are +taking advantage of the MS-DOS "far" structure allocation for the small +and medium memory models. You should also note that zlib is a +compression library that is useful for more things than just PNG files. +You can use zlib as a drop-in replacement for fread() and fwrite() if +you are so inclined. + +zlib should be available at the same place that libpng is, or at. +ftp://ftp.info-zip.org/pub/infozip/zlib + +You may also want a copy of the PNG specification. It is available +as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find +these at http://www.libpng.org/pub/png/documents/ + +This code is currently being archived at libpng.sf.net in the +[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT) +at GO GRAPHSUP. If you can't find it in any of those places, +e-mail me, and I'll help you find it. + +If you have any code changes, requests, problems, etc., please e-mail +them to me. Also, I'd appreciate any make files or project files, +and any modifications you needed to make to get libpng to compile, +along with a #define variable to tell what compiler/system you are on. +If you needed to add transformations to libpng, or wish libpng would +provide the image in a different way, drop me a note (and code, if +possible), so I can consider supporting the transformation. +Finally, if you get any warning messages when compiling libpng +(note: not zlib), and they are easy to fix, I'd appreciate the +fix. Please mention "libpng" somewhere in the subject line. Thanks. + +This release was created and will be supported by myself (of course +based in a large way on Guy's and Andreas' earlier work), and the PNG group. + +Send comments/corrections/commendations to png-mng-implement at lists.sf.net +(subscription required; visit +https://lists.sourceforge.net/lists/listinfo/png-mng-implement +to subscribe) or to glennrp at users.sourceforge.net + +You can't reach Guy, the original libpng author, at the addresses +given in previous versions of this document. He and Andreas will read mail +addressed to the png-implement list, however. + +Please do not send general questions about PNG. Send them to +the (png-list at ccrc.wustl.edu, subscription required, write to +majordomo at ccrc.wustl.edu with "subscribe png-list" in your message). +On the other hand, +please do not send libpng questions to that address, send them to me +or to the png-implement list. I'll +get them in the end anyway. If you have a question about something +in the PNG specification that is related to using libpng, send it +to me. Send me any questions that start with "I was using libpng, +and ...". If in doubt, send questions to me. I'll bounce them +to others, if necessary. + +Please do not send suggestions on how to change PNG. We have +been discussing PNG for nine years now, and it is official and +finished. If you have suggestions for libpng, however, I'll +gladly listen. Even if your suggestion is not used immediately, +it may be used later. + +Files in this distribution: + + ANNOUNCE => Announcement of this version, with recent changes + CHANGES => Description of changes between libpng versions + KNOWNBUG => List of known bugs and deficiencies + LICENSE => License to use and redistribute libpng + README => This file + TODO => Things not implemented in the current library + Y2KINFO => Statement of Y2K compliance + example.c => Example code for using libpng functions + libpng.3 => manual page for libpng (includes libpng.txt) + libpng.txt => Description of libpng and its functions + libpngpf.3 => manual page for libpng's private functions + png.5 => manual page for the PNG format + png.c => Basic interface functions common to library + png.h => Library function and interface declarations + pngconf.h => System specific library configuration + pngasmrd.h => Header file for assembler-coded functions + pngerror.c => Error/warning message I/O functions + pngget.c => Functions for retrieving info from struct + pngmem.c => Memory handling functions + pngbar.png => PNG logo, 88x31 + pngnow.png => PNG logo, 98x31 + pngpread.c => Progressive reading functions + pngread.c => Read data/helper high-level functions + pngrio.c => Lowest-level data read I/O functions + pngrtran.c => Read data transformation functions + pngrutil.c => Read data utility functions + pngset.c => Functions for storing data into the info_struct + pngtest.c => Library test program + pngtest.png => Library test sample image + pngtrans.c => Common data transformation functions + pngwio.c => Lowest-level write I/O functions + pngwrite.c => High-level write functions + pngwtran.c => Write data transformations + pngwutil.c => Write utility functions + contrib => Contributions + gregbook => source code for PNG reading and writing, from + Greg Roelofs' "PNG: The Definitive Guide", + O'Reilly, 1999 + msvctest => Builds and runs pngtest using a MSVC workspace + pngminus => Simple pnm2png and png2pnm programs + pngsuite => Test images + visupng => Contains a MSVC workspace for VisualPng + projects => Contains project files and workspaces for building DLL + beos => Contains a Beos workspace for building libpng + c5builder => Contains a Borland workspace for building libpng + and zlib + visualc6 => Contains a Microsoft Visual C++ (MSVC) workspace + for building libpng and zlib + netware.txt => Contains instructions for downloading a set of + project files for building libpng and zlib on + Netware. + wince.txt => Contains instructions for downloading a Microsoft + Visual C++ (Windows CD Toolkit) workspace for + building libpng and zlib on WindowsCE + scripts => Directory containing scripts for building libpng: + descrip.mms => VMS makefile for MMS or MMK + makefile.std => Generic UNIX makefile (cc, creates static libpng.a) + makefile.elf => Linux/ELF makefile symbol versioning, + gcc, creates libpng12.so.0.1.2.16) + makefile.linux => Linux/ELF makefile + (gcc, creates libpng12.so.0.1.2.16) + makefile.gcmmx => Linux/ELF makefile + (gcc, creates libpng12.so.0.1.2.16, + uses assembler code tuned for Intel MMX platform) + makefile.gcc => Generic makefile (gcc, creates static libpng.a) + makefile.knr => Archaic UNIX Makefile that converts files with + ansi2knr (Requires ansi2knr.c from + ftp://ftp.cs.wisc.edu/ghost) + makefile.aix => AIX makefile + makefile.cygwin => Cygwin/gcc makefile + makefile.darwin => Darwin makefile + makefile.dec => DEC Alpha UNIX makefile + makefile.freebsd => FreeBSD makefile + makefile.hpgcc => HPUX makefile using gcc + makefile.hpux => HPUX (10.20 and 11.00) makefile + makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64 bit + makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) + makefile.intel => Intel C/C++ version 4.0 and later + libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later + makefile.netbsd => NetBSD/cc makefile, PNGGCCRD, makes libpng.so. + makefile.ne12bsd => NetBSD/cc makefile, PNGGCCRD, makes libpng12.so + makefile.openbsd => OpenBSD makefile + makefile.sgi => Silicon Graphics IRIX (cc, creates static lib) + makefile.sggcc => Silicon Graphics + (gcc, creates libpng12.so.0.1.2.16) + makefile.sunos => Sun makefile + makefile.solaris => Solaris 2.X makefile + (gcc, creates libpng12.so.0.1.2.16) + makefile.so9 => Solaris 9 makefile + (gcc, creates libpng12.so.0.1.2.16) + makefile.32sunu => Sun Ultra 32-bit makefile + makefile.64sunu => Sun Ultra 64-bit makefile + makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc + makefile.mips => MIPS makefile + makefile.acorn => Acorn makefile + makefile.amiga => Amiga makefile + smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC + compiler (Requires SCOPTIONS, copied from + scripts/SCOPTIONS.ppc) + makefile.atari => Atari makefile + makefile.beos => BEOS makefile for X86 + makefile.bor => Borland makefile (uses bcc) + makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode) + makefile.tc3 => Turbo C 3.0 makefile + makefile.dj2 => DJGPP 2 makefile + makefile.msc => Microsoft C makefile + makefile.vcawin32=> makefile for Microsoft Visual C++ 5.0 and + later (uses assembler code tuned for Intel MMX + platform) + makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and + later (does not use assembler code) + makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) + pngos2.def => OS/2 module definition file used by makefile.os2 + makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model + makevms.com => VMS build script + SCOPTIONS.ppc => Used with smakefile.ppc + +Good luck, and happy coding. + +-Glenn Randers-Pehrson (current maintainer) + Internet: glennrp at users.sourceforge.net + +-Andreas Eric Dilger (former maintainer, 1996-1997) + Internet: adilger at enel.ucalgary.ca + Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/ + +-Guy Eric Schalnat (original author and former maintainer, 1995-1996) + (formerly of Group 42, Inc) + Internet: gschal at infinet.com diff --git a/src/dep/src/irrlicht/libpng/TODO b/src/dep/src/irrlicht/libpng/TODO index 90f945c..a5f6395 100644 --- a/src/dep/src/irrlicht/libpng/TODO +++ b/src/dep/src/irrlicht/libpng/TODO @@ -1,24 +1,24 @@ -TODO - list of things to do for libpng: - -Final bug fixes. -Improve API by hiding the png_struct and png_info structs. -Finish work on the no-floating-point version (including gamma compensation) -Better C++ wrapper/full C++ implementation? -Fix problem with C++ and EXTERN "C". -cHRM transformation. -Improve setjmp/longjmp usage or remove it in favor of returning error codes. -Add "grayscale->palette" transformation and "palette->grayscale" detection. -Improved dithering. -Multi-lingual error and warning message support. -Complete sRGB transformation (presently it simply uses gamma=0.45455). -Man pages for function calls. -Better documentation. -Better filter selection - (counting huffman bits/precompression? filter inertia? filter costs?). -Histogram creation. -Text conversion between different code pages (Latin-1 -> Mac and DOS). -Should we always malloc 2^bit_depth PLTE/tRNS/hIST entries for safety? -Build gamma tables using fixed point (and do away with floating point entirely). -Use greater precision when changing to linear gamma for compositing against - background and doing rgb-to-gray transformation. -Investigate pre-incremented loop counters and other loop constructions. +TODO - list of things to do for libpng: + +Final bug fixes. +Improve API by hiding the png_struct and png_info structs. +Finish work on the no-floating-point version (including gamma compensation) +Better C++ wrapper/full C++ implementation? +Fix problem with C++ and EXTERN "C". +cHRM transformation. +Improve setjmp/longjmp usage or remove it in favor of returning error codes. +Add "grayscale->palette" transformation and "palette->grayscale" detection. +Improved dithering. +Multi-lingual error and warning message support. +Complete sRGB transformation (presently it simply uses gamma=0.45455). +Man pages for function calls. +Better documentation. +Better filter selection + (counting huffman bits/precompression? filter inertia? filter costs?). +Histogram creation. +Text conversion between different code pages (Latin-1 -> Mac and DOS). +Should we always malloc 2^bit_depth PLTE/tRNS/hIST entries for safety? +Build gamma tables using fixed point (and do away with floating point entirely). +Use greater precision when changing to linear gamma for compositing against + background and doing rgb-to-gray transformation. +Investigate pre-incremented loop counters and other loop constructions. diff --git a/src/dep/src/irrlicht/libpng/Y2KINFO b/src/dep/src/irrlicht/libpng/Y2KINFO index 65fc07f..7bf4cb5 100644 --- a/src/dep/src/irrlicht/libpng/Y2KINFO +++ b/src/dep/src/irrlicht/libpng/Y2KINFO @@ -1,55 +1,55 @@ - Y2K compliance in libpng: - ========================= - - January 31, 2007 - - Since the PNG Development group is an ad-hoc body, we can't make - an official declaration. - - This is your unofficial assurance that libpng from version 0.71 and - upward through 1.2.16 are Y2K compliant. It is my belief that earlier - versions were also Y2K compliant. - - Libpng only has three year fields. One is a 2-byte unsigned integer - that will hold years up to 65535. The other two hold the date in text - format, and will hold years up to 9999. - - The integer is - "png_uint_16 year" in png_time_struct. - - The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. - - There are seven time-related functions: - - png_convert_to_rfc_1123() in png.c - (formerly png_convert_to_rfc_1152() in error) - png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c - png_convert_from_time_t() in pngwrite.c - png_get_tIME() in pngget.c - png_handle_tIME() in pngrutil.c, called in pngread.c - png_set_tIME() in pngset.c - png_write_tIME() in pngwutil.c, called in pngwrite.c - - All appear to handle dates properly in a Y2K environment. The - png_convert_from_time_t() function calls gmtime() to convert from system - clock time, which returns (year - 1900), which we properly convert to - the full 4-digit year. There is a possibility that applications using - libpng are not passing 4-digit years into the png_convert_to_rfc_1123() - function, or that they are incorrectly passing only a 2-digit year - instead of "year - 1900" into the png_convert_from_struct_tm() function, - but this is not under our control. The libpng documentation has always - stated that it works with 4-digit years, and the APIs have been - documented as such. - - The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned - integer to hold the year, and can hold years as large as 65535. - - zlib, upon which libpng depends, is also Y2K compliant. It contains - no date-related code. - - - Glenn Randers-Pehrson - libpng maintainer - PNG Development Group + Y2K compliance in libpng: + ========================= + + January 31, 2007 + + Since the PNG Development group is an ad-hoc body, we can't make + an official declaration. + + This is your unofficial assurance that libpng from version 0.71 and + upward through 1.2.16 are Y2K compliant. It is my belief that earlier + versions were also Y2K compliant. + + Libpng only has three year fields. One is a 2-byte unsigned integer + that will hold years up to 65535. The other two hold the date in text + format, and will hold years up to 9999. + + The integer is + "png_uint_16 year" in png_time_struct. + + The strings are + "png_charp time_buffer" in png_struct and + "near_time_buffer", which is a local character string in png.c. + + There are seven time-related functions: + + png_convert_to_rfc_1123() in png.c + (formerly png_convert_to_rfc_1152() in error) + png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c + png_convert_from_time_t() in pngwrite.c + png_get_tIME() in pngget.c + png_handle_tIME() in pngrutil.c, called in pngread.c + png_set_tIME() in pngset.c + png_write_tIME() in pngwutil.c, called in pngwrite.c + + All appear to handle dates properly in a Y2K environment. The + png_convert_from_time_t() function calls gmtime() to convert from system + clock time, which returns (year - 1900), which we properly convert to + the full 4-digit year. There is a possibility that applications using + libpng are not passing 4-digit years into the png_convert_to_rfc_1123() + function, or that they are incorrectly passing only a 2-digit year + instead of "year - 1900" into the png_convert_from_struct_tm() function, + but this is not under our control. The libpng documentation has always + stated that it works with 4-digit years, and the APIs have been + documented as such. + + The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned + integer to hold the year, and can hold years as large as 65535. + + zlib, upon which libpng depends, is also Y2K compliant. It contains + no date-related code. + + + Glenn Randers-Pehrson + libpng maintainer + PNG Development Group diff --git a/src/dep/src/irrlicht/libpng/configure b/src/dep/src/irrlicht/libpng/configure index 59cc881..715bb5b 100644 --- a/src/dep/src/irrlicht/libpng/configure +++ b/src/dep/src/irrlicht/libpng/configure @@ -1,13 +1,13 @@ -#!/bin/sh -echo " - There is no \"configure\" script in this distribution of - libpng-1.2.16. - - Instead, please copy the appropriate makefile for your system from the - \"scripts\" directory. Read the INSTALL file for more details. - - Update, July 2004: you can get a \"configure\" based distribution - from the libpng distribution sites. Download the file - libpng-1.2.16.tar.gz or libpng-1.2.16.tar.bz2 -" - +#!/bin/sh +echo " + There is no \"configure\" script in this distribution of + libpng-1.2.16. + + Instead, please copy the appropriate makefile for your system from the + \"scripts\" directory. Read the INSTALL file for more details. + + Update, July 2004: you can get a \"configure\" based distribution + from the libpng distribution sites. Download the file + libpng-1.2.16.tar.gz or libpng-1.2.16.tar.bz2 +" + diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/LICENSE b/src/dep/src/irrlicht/libpng/contrib/gregbook/LICENSE index f47b7c4..175ebfd 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/LICENSE +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/LICENSE @@ -1,26 +1,26 @@ - --------------------------------------------------------------------------- - - Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - --------------------------------------------------------------------------- + --------------------------------------------------------------------------- + + Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + --------------------------------------------------------------------------- diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/Makefile.sgi b/src/dep/src/irrlicht/libpng/contrib/gregbook/Makefile.sgi index f8f22f9..e3ca6ce 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/Makefile.sgi +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/Makefile.sgi @@ -1,104 +1,104 @@ -# Sample makefile for rpng-x / rpng2-x / wpng for SGI using cc and make. -# Greg Roelofs -# Last modified: 7 March 2002 -# -# The programs built by this makefile are described in the book, -# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and -# Associates, 1999). Go buy a copy, eh? Buy some for friends -# and family, too. (Not that this is a blatant plug or anything.) -# -# Invoke this makefile from a shell prompt in the usual way; for example: -# -# make -f Makefile.sgi -# -# This makefile assumes libpng and zlib have already been built or downloaded -# and are both installed in /usr/local/{include,lib} (as indicated by the -# PNG* and Z* macros below). Edit as appropriate--choose only ONE each of -# the PNGINC, PNGLIB, ZINC and ZLIB lines. -# -# This makefile builds dynamically linked executables (against libpng and zlib, -# that is), but that can be changed by uncommenting the appropriate PNGLIB and -# ZLIB lines. - - -# macros -------------------------------------------------------------------- - -PNGINC = -I/usr/local/include/libpng12 -PNGLIB = -L/usr/local/lib -lpng12 # dynamically linked against libpng -#PNGLIB = /usr/local/lib/libpng12.a # statically linked against libpng -# or: -#PNGINC = -I../.. -#PNGLIB = -L../.. -lpng -#PNGLIB = ../../libpng.a - -ZINC = -I/usr/local/include -ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib -#ZLIB = /usr/local/lib/libz.a # statically linked against zlib -#ZINC = -I../zlib -#ZLIB = -L../zlib -lz -#ZLIB = ../../../zlib/libz.a - -XINC = -I/usr/include/X11 # old-style, stock X distributions -XLIB = -L/usr/lib/X11 -lX11 -#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows) -#XLIB = -L/usr/openwin/lib -lX11 -#XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.) -#XLIB = -L/usr/X11R6/lib -lX11 - -INCS = $(PNGINC) $(ZINC) $(XINC) -RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm -WLIBS = $(PNGLIB) $(ZLIB) - -CC = cc -LD = cc -RM = rm -f -# ABI must be the same as that used to build libpng. -ABI= -CFLAGS = $(ABI) -O -fullwarn $(INCS) -LDFLAGS = $(ABI) -O = .o -E = - -RPNG = rpng-x -RPNG2 = rpng2-x -WPNG = wpng - -ROBJS = $(RPNG)$(O) readpng$(O) -ROBJS2 = $(RPNG2)$(O) readpng2$(O) -WOBJS = $(WPNG)$(O) writepng$(O) - -EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) - - -# implicit make rules ------------------------------------------------------- - -.c$(O): - $(CC) -c $(CFLAGS) $< - - -# dependencies -------------------------------------------------------------- - -all: $(EXES) - -$(RPNG)$(E): $(ROBJS) - $(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBS) - -$(RPNG2)$(E): $(ROBJS2) - $(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBS) - -$(WPNG)$(E): $(WOBJS) - $(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBS) - -$(RPNG)$(O): $(RPNG).c readpng.h -$(RPNG2)$(O): $(RPNG2).c readpng2.h -$(WPNG)$(O): $(WPNG).c writepng.h - -readpng$(O): readpng.c readpng.h -readpng2$(O): readpng2.c readpng2.h -writepng$(O): writepng.c writepng.h - - -# maintenance --------------------------------------------------------------- - -clean: - $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS) +# Sample makefile for rpng-x / rpng2-x / wpng for SGI using cc and make. +# Greg Roelofs +# Last modified: 7 March 2002 +# +# The programs built by this makefile are described in the book, +# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and +# Associates, 1999). Go buy a copy, eh? Buy some for friends +# and family, too. (Not that this is a blatant plug or anything.) +# +# Invoke this makefile from a shell prompt in the usual way; for example: +# +# make -f Makefile.sgi +# +# This makefile assumes libpng and zlib have already been built or downloaded +# and are both installed in /usr/local/{include,lib} (as indicated by the +# PNG* and Z* macros below). Edit as appropriate--choose only ONE each of +# the PNGINC, PNGLIB, ZINC and ZLIB lines. +# +# This makefile builds dynamically linked executables (against libpng and zlib, +# that is), but that can be changed by uncommenting the appropriate PNGLIB and +# ZLIB lines. + + +# macros -------------------------------------------------------------------- + +PNGINC = -I/usr/local/include/libpng12 +PNGLIB = -L/usr/local/lib -lpng12 # dynamically linked against libpng +#PNGLIB = /usr/local/lib/libpng12.a # statically linked against libpng +# or: +#PNGINC = -I../.. +#PNGLIB = -L../.. -lpng +#PNGLIB = ../../libpng.a + +ZINC = -I/usr/local/include +ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib +#ZLIB = /usr/local/lib/libz.a # statically linked against zlib +#ZINC = -I../zlib +#ZLIB = -L../zlib -lz +#ZLIB = ../../../zlib/libz.a + +XINC = -I/usr/include/X11 # old-style, stock X distributions +XLIB = -L/usr/lib/X11 -lX11 +#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows) +#XLIB = -L/usr/openwin/lib -lX11 +#XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.) +#XLIB = -L/usr/X11R6/lib -lX11 + +INCS = $(PNGINC) $(ZINC) $(XINC) +RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm +WLIBS = $(PNGLIB) $(ZLIB) + +CC = cc +LD = cc +RM = rm -f +# ABI must be the same as that used to build libpng. +ABI= +CFLAGS = $(ABI) -O -fullwarn $(INCS) +LDFLAGS = $(ABI) +O = .o +E = + +RPNG = rpng-x +RPNG2 = rpng2-x +WPNG = wpng + +ROBJS = $(RPNG)$(O) readpng$(O) +ROBJS2 = $(RPNG2)$(O) readpng2$(O) +WOBJS = $(WPNG)$(O) writepng$(O) + +EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) + + +# implicit make rules ------------------------------------------------------- + +.c$(O): + $(CC) -c $(CFLAGS) $< + + +# dependencies -------------------------------------------------------------- + +all: $(EXES) + +$(RPNG)$(E): $(ROBJS) + $(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBS) + +$(RPNG2)$(E): $(ROBJS2) + $(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBS) + +$(WPNG)$(E): $(WOBJS) + $(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBS) + +$(RPNG)$(O): $(RPNG).c readpng.h +$(RPNG2)$(O): $(RPNG2).c readpng2.h +$(WPNG)$(O): $(WPNG).c writepng.h + +readpng$(O): readpng.c readpng.h +readpng2$(O): readpng2.c readpng2.h +writepng$(O): writepng.c writepng.h + + +# maintenance --------------------------------------------------------------- + +clean: + $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS) diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/Makefile.unx b/src/dep/src/irrlicht/libpng/contrib/gregbook/Makefile.unx index 3d055d2..c0c3fb1 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/Makefile.unx +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/Makefile.unx @@ -1,104 +1,104 @@ -# Sample makefile for rpng-x / rpng2-x / wpng using gcc and make. -# Greg Roelofs -# Last modified: 7 March 2002 -# -# The programs built by this makefile are described in the book, -# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and -# Associates, 1999). Go buy a copy, eh? Buy some for friends -# and family, too. (Not that this is a blatant plug or anything.) -# -# Invoke this makefile from a shell prompt in the usual way; for example: -# -# make -f Makefile.unx -# -# This makefile assumes libpng and zlib have already been built or downloaded -# and are both installed in /usr/local/{include,lib} (as indicated by the -# PNG* and Z* macros below). Edit as appropriate--choose only ONE each of -# the PNGINC, PNGLIB, ZINC and ZLIB lines. -# -# This makefile builds statically linked executables (against libpng and zlib, -# that is), but that can be changed by uncommenting the appropriate PNGLIB and -# ZLIB lines. - - -# macros -------------------------------------------------------------------- - -PNGINC = -I/usr/local/include/libpng12 -#PNGLIB = -L/usr/local/lib -lpng12 # dynamically linked against libpng -PNGLIB = /usr/local/lib/libpng12.a # statically linked against libpng -# or: -#PNGINC = -I../libpng -#PNGLIB = -L../libpng -lpng -#PNGLIB = ../libpng/libpng.a - -ZINC = -I/usr/local/include -#ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib -ZLIB = /usr/local/lib/libz.a # statically linked against zlib -#ZINC = -I../zlib -#ZLIB = -L../zlib -lz -#ZLIB = ../zlib/libz.a - -#XINC = -I/usr/include # old-style, stock X distributions -#XLIB = -L/usr/lib/X11 -lX11 -#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows) -#XLIB = -L/usr/openwin/lib -lX11 -XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.) -XLIB = -L/usr/X11R6/lib -lX11 - -INCS = $(PNGINC) $(ZINC) $(XINC) -RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm -WLIBS = $(PNGLIB) $(ZLIB) - -CC = gcc -LD = gcc -RM = rm -f -CFLAGS = -O -Wall $(INCS) -# [note that -Wall is a gcc-specific compilation flag ("most warnings on")] -# [-ansi, -pedantic and -W can also be used] -LDFLAGS = -O = .o -E = - -RPNG = rpng-x -RPNG2 = rpng2-x -WPNG = wpng - -ROBJS = $(RPNG)$(O) readpng$(O) -ROBJS2 = $(RPNG2)$(O) readpng2$(O) -WOBJS = $(WPNG)$(O) writepng$(O) - -EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) - - -# implicit make rules ------------------------------------------------------- - -.c$(O): - $(CC) -c $(CFLAGS) $< - - -# dependencies -------------------------------------------------------------- - -all: $(EXES) - -$(RPNG)$(E): $(ROBJS) - $(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBS) - -$(RPNG2)$(E): $(ROBJS2) - $(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBS) - -$(WPNG)$(E): $(WOBJS) - $(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBS) - -$(RPNG)$(O): $(RPNG).c readpng.h -$(RPNG2)$(O): $(RPNG2).c readpng2.h -$(WPNG)$(O): $(WPNG).c writepng.h - -readpng$(O): readpng.c readpng.h -readpng2$(O): readpng2.c readpng2.h -writepng$(O): writepng.c writepng.h - - -# maintenance --------------------------------------------------------------- - -clean: - $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS) +# Sample makefile for rpng-x / rpng2-x / wpng using gcc and make. +# Greg Roelofs +# Last modified: 7 March 2002 +# +# The programs built by this makefile are described in the book, +# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and +# Associates, 1999). Go buy a copy, eh? Buy some for friends +# and family, too. (Not that this is a blatant plug or anything.) +# +# Invoke this makefile from a shell prompt in the usual way; for example: +# +# make -f Makefile.unx +# +# This makefile assumes libpng and zlib have already been built or downloaded +# and are both installed in /usr/local/{include,lib} (as indicated by the +# PNG* and Z* macros below). Edit as appropriate--choose only ONE each of +# the PNGINC, PNGLIB, ZINC and ZLIB lines. +# +# This makefile builds statically linked executables (against libpng and zlib, +# that is), but that can be changed by uncommenting the appropriate PNGLIB and +# ZLIB lines. + + +# macros -------------------------------------------------------------------- + +PNGINC = -I/usr/local/include/libpng12 +#PNGLIB = -L/usr/local/lib -lpng12 # dynamically linked against libpng +PNGLIB = /usr/local/lib/libpng12.a # statically linked against libpng +# or: +#PNGINC = -I../libpng +#PNGLIB = -L../libpng -lpng +#PNGLIB = ../libpng/libpng.a + +ZINC = -I/usr/local/include +#ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib +ZLIB = /usr/local/lib/libz.a # statically linked against zlib +#ZINC = -I../zlib +#ZLIB = -L../zlib -lz +#ZLIB = ../zlib/libz.a + +#XINC = -I/usr/include # old-style, stock X distributions +#XLIB = -L/usr/lib/X11 -lX11 +#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows) +#XLIB = -L/usr/openwin/lib -lX11 +XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.) +XLIB = -L/usr/X11R6/lib -lX11 + +INCS = $(PNGINC) $(ZINC) $(XINC) +RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm +WLIBS = $(PNGLIB) $(ZLIB) + +CC = gcc +LD = gcc +RM = rm -f +CFLAGS = -O -Wall $(INCS) +# [note that -Wall is a gcc-specific compilation flag ("most warnings on")] +# [-ansi, -pedantic and -W can also be used] +LDFLAGS = +O = .o +E = + +RPNG = rpng-x +RPNG2 = rpng2-x +WPNG = wpng + +ROBJS = $(RPNG)$(O) readpng$(O) +ROBJS2 = $(RPNG2)$(O) readpng2$(O) +WOBJS = $(WPNG)$(O) writepng$(O) + +EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) + + +# implicit make rules ------------------------------------------------------- + +.c$(O): + $(CC) -c $(CFLAGS) $< + + +# dependencies -------------------------------------------------------------- + +all: $(EXES) + +$(RPNG)$(E): $(ROBJS) + $(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBS) + +$(RPNG2)$(E): $(ROBJS2) + $(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBS) + +$(WPNG)$(E): $(WOBJS) + $(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBS) + +$(RPNG)$(O): $(RPNG).c readpng.h +$(RPNG2)$(O): $(RPNG2).c readpng2.h +$(WPNG)$(O): $(WPNG).c writepng.h + +readpng$(O): readpng.c readpng.h +readpng2$(O): readpng2.c readpng2.h +writepng$(O): writepng.c writepng.h + + +# maintenance --------------------------------------------------------------- + +clean: + $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS) diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/Makefile.w32 b/src/dep/src/irrlicht/libpng/contrib/gregbook/Makefile.w32 index ceb6a51..62041cd 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/Makefile.w32 +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/Makefile.w32 @@ -1,112 +1,112 @@ -# Sample makefile for rpng-win / rpng2-win / wpng using MSVC and NMAKE. -# Greg Roelofs -# Last modified: 16 February 1999 -# -# The programs built by this makefile are described in the book, -# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and -# Associates, 1999). Go buy a copy, eh? Buy some for friends -# and family, too. (Not that this is a blatant plug or anything.) -# -# Invoke this makefile from a DOS prompt window via: -# -# %devstudio%\vc\bin\vcvars32.bat -# nmake -nologo -f Makefile.w32 -# -# where %devstudio% is the installation directory for MSVC / DevStudio. If -# you get "environment out of space" errors, create a desktop shortcut with -# "c:\windows\command.com /e:4096" as the program command line and set the -# working directory to this directory. Then double-click to open the new -# DOS-prompt window with a bigger environment and retry the commands above. -# -# This makefile assumes libpng and zlib have already been built or downloaded -# and are in subdirectories at the same level as the current subdirectory -# (as indicated by the PNGPATH and ZPATH macros below). Edit as appropriate. -# -# Note that the names of the dynamic and static libpng and zlib libraries -# used below may change in later releases of the libraries. This makefile -# builds statically linked executables, but that can be changed by uncom- -# menting the appropriate PNGLIB and ZLIB lines. - -!include - - -# macros -------------------------------------------------------------------- - -PNGPATH = ../libpng -PNGINC = -I$(PNGPATH) -#PNGLIB = $(PNGPATH)/pngdll.lib -PNGLIB = $(PNGPATH)/libpng.lib - -ZPATH = ../zlib -ZINC = -I$(ZPATH) -#ZLIB = $(ZPATH)/zlibdll.lib -ZLIB = $(ZPATH)/zlibstat.lib - -WINLIBS = -defaultlib:user32.lib gdi32.lib -# ["real" apps may also need comctl32.lib, comdlg32.lib, winmm.lib, etc.] - -INCS = $(PNGINC) $(ZINC) -RLIBS = $(PNGLIB) $(ZLIB) $(WINLIBS) -WLIBS = $(PNGLIB) $(ZLIB) - -CC = cl -LD = link -RM = del -CFLAGS = -nologo -O -W3 $(INCS) $(cvars) -# [note that -Wall is an MSVC-specific compilation flag ("all warnings on")] -# [see %devstudio%\vc\include\win32.mak for cvars macro definition] -O = .obj -E = .exe - -RLDFLAGS = -nologo -subsystem:windows -WLDFLAGS = -nologo - -RPNG = rpng-win -RPNG2 = rpng2-win -WPNG = wpng - -ROBJS = $(RPNG)$(O) readpng$(O) -ROBJS2 = $(RPNG2)$(O) readpng2$(O) -WOBJS = $(WPNG)$(O) writepng$(O) - -EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) - - -# implicit make rules ------------------------------------------------------- - -.c$(O): - $(CC) -c $(CFLAGS) $< - - -# dependencies -------------------------------------------------------------- - -all: $(EXES) - -$(RPNG)$(E): $(ROBJS) - $(LD) $(RLDFLAGS) -out:$@ $(ROBJS) $(RLIBS) - -$(RPNG2)$(E): $(ROBJS2) - $(LD) $(RLDFLAGS) -out:$@ $(ROBJS2) $(RLIBS) - -$(WPNG)$(E): $(WOBJS) - $(LD) $(WLDFLAGS) -out:$@ $(WOBJS) $(WLIBS) - -$(RPNG)$(O): $(RPNG).c readpng.h -$(RPNG2)$(O): $(RPNG2).c readpng2.h -$(WPNG)$(O): $(WPNG).c writepng.h - -readpng$(O): readpng.c readpng.h -readpng2$(O): readpng2.c readpng2.h -writepng$(O): writepng.c writepng.h - - -# maintenance --------------------------------------------------------------- - -clean: -# ideally we could just do this: -# $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS) -# ...but the Windows "DEL" command is none too bright, so: - $(RM) r*$(E) - $(RM) w*$(E) - $(RM) r*$(O) - $(RM) w*$(O) +# Sample makefile for rpng-win / rpng2-win / wpng using MSVC and NMAKE. +# Greg Roelofs +# Last modified: 16 February 1999 +# +# The programs built by this makefile are described in the book, +# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and +# Associates, 1999). Go buy a copy, eh? Buy some for friends +# and family, too. (Not that this is a blatant plug or anything.) +# +# Invoke this makefile from a DOS prompt window via: +# +# %devstudio%\vc\bin\vcvars32.bat +# nmake -nologo -f Makefile.w32 +# +# where %devstudio% is the installation directory for MSVC / DevStudio. If +# you get "environment out of space" errors, create a desktop shortcut with +# "c:\windows\command.com /e:4096" as the program command line and set the +# working directory to this directory. Then double-click to open the new +# DOS-prompt window with a bigger environment and retry the commands above. +# +# This makefile assumes libpng and zlib have already been built or downloaded +# and are in subdirectories at the same level as the current subdirectory +# (as indicated by the PNGPATH and ZPATH macros below). Edit as appropriate. +# +# Note that the names of the dynamic and static libpng and zlib libraries +# used below may change in later releases of the libraries. This makefile +# builds statically linked executables, but that can be changed by uncom- +# menting the appropriate PNGLIB and ZLIB lines. + +!include + + +# macros -------------------------------------------------------------------- + +PNGPATH = ../libpng +PNGINC = -I$(PNGPATH) +#PNGLIB = $(PNGPATH)/pngdll.lib +PNGLIB = $(PNGPATH)/libpng.lib + +ZPATH = ../zlib +ZINC = -I$(ZPATH) +#ZLIB = $(ZPATH)/zlibdll.lib +ZLIB = $(ZPATH)/zlibstat.lib + +WINLIBS = -defaultlib:user32.lib gdi32.lib +# ["real" apps may also need comctl32.lib, comdlg32.lib, winmm.lib, etc.] + +INCS = $(PNGINC) $(ZINC) +RLIBS = $(PNGLIB) $(ZLIB) $(WINLIBS) +WLIBS = $(PNGLIB) $(ZLIB) + +CC = cl +LD = link +RM = del +CFLAGS = -nologo -O -W3 $(INCS) $(cvars) +# [note that -Wall is an MSVC-specific compilation flag ("all warnings on")] +# [see %devstudio%\vc\include\win32.mak for cvars macro definition] +O = .obj +E = .exe + +RLDFLAGS = -nologo -subsystem:windows +WLDFLAGS = -nologo + +RPNG = rpng-win +RPNG2 = rpng2-win +WPNG = wpng + +ROBJS = $(RPNG)$(O) readpng$(O) +ROBJS2 = $(RPNG2)$(O) readpng2$(O) +WOBJS = $(WPNG)$(O) writepng$(O) + +EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) + + +# implicit make rules ------------------------------------------------------- + +.c$(O): + $(CC) -c $(CFLAGS) $< + + +# dependencies -------------------------------------------------------------- + +all: $(EXES) + +$(RPNG)$(E): $(ROBJS) + $(LD) $(RLDFLAGS) -out:$@ $(ROBJS) $(RLIBS) + +$(RPNG2)$(E): $(ROBJS2) + $(LD) $(RLDFLAGS) -out:$@ $(ROBJS2) $(RLIBS) + +$(WPNG)$(E): $(WOBJS) + $(LD) $(WLDFLAGS) -out:$@ $(WOBJS) $(WLIBS) + +$(RPNG)$(O): $(RPNG).c readpng.h +$(RPNG2)$(O): $(RPNG2).c readpng2.h +$(WPNG)$(O): $(WPNG).c writepng.h + +readpng$(O): readpng.c readpng.h +readpng2$(O): readpng2.c readpng2.h +writepng$(O): writepng.c writepng.h + + +# maintenance --------------------------------------------------------------- + +clean: +# ideally we could just do this: +# $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS) +# ...but the Windows "DEL" command is none too bright, so: + $(RM) r*$(E) + $(RM) w*$(E) + $(RM) r*$(O) + $(RM) w*$(O) diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/README b/src/dep/src/irrlicht/libpng/contrib/gregbook/README index d083c76..c67045c 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/README +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/README @@ -1,185 +1,185 @@ - =========================== - PNG: The Definitive Guide - =========================== - - Source Code - -Chapters 13, 14 and 15 of "PNG: The Definitive Guide" discuss three free, -cross-platform demo programs that show how to use the libpng reference -library: rpng, rpng2 and wpng. rpng and rpng2 are viewers; the first is -a very simple example that that shows how a standard file-viewer might use -libpng, while the second is designed to process streaming data and shows -how a web browser might be written. wpng is a simple command-line program -that reads binary PGM and PPM files (the ``raw'' grayscale and RGB subsets -of PBMPLUS/NetPBM) and converts them to PNG. - -The source code for all three demo programs currently compiles under -Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser, -zinser@decus.de, for making the necessary changes for OpenVMS and for -providing an appropriate build script.) Build instructions can be found -below. - -Files: - - README this file - LICENSE terms of distribution and reuse (BSD-like) - - Makefile.unx Unix makefile - Makefile.w32 Windows (MSVC) makefile - makevms.com OpenVMS build script - - rpng-win.c Windows front end for the basic viewer - rpng-x.c X Window System (Unix, OpenVMS) front end - readpng.c generic back end for the basic viewer - readpng.h header file for the basic viewer - - rpng2-win.c Windows front end for the progressive viewer - rpng2-x.c X front end for the progressive viewer - readpng2.c generic back end for the progressive viewer - readpng2.h header file for the progressive viewer - - wpng.c generic (text) front end for the converter - writepng.c generic back end for the converter - writepng.h header file for the converter - - toucan.png transparent PNG for testing (by Stefan Schneider) - -Note that, although the programs are designed to be functional, their -primary purpose is to illustrate how to use libpng to add PNG support to -other programs. As such, their user interfaces are crude and definitely -are not intended for everyday use. - -Please see http://www.libpng.org/pub/png/pngbook.html for further infor- -mation and links to the latest version of the source code, and Chapters -13-15 of the book for detailed discussion of the three programs. - -Greg Roelofs -newt@pobox.com -30 June 2001 - - -BUILD INSTRUCTIONS - - - Prerequisites (in order of compilation): - - - zlib http://www.gzip.org/zlib/ - - libpng http://www.libpng.org/pub/png/libpng.html - - pngbook http://www.libpng.org/pub/png/book/sources.html - - The pngbook demo programs are explicitly designed to demonstrate proper - coding techniques for using the libpng reference library. As a result, - you need to download and build both zlib (on which libpng depends) and - libpng. A common build setup is to place the zlib, libpng and pngbook - subdirectory trees ("folders") in the same parent directory. Then the - libpng build can refer to files in ../zlib (or ..\zlib or [-.zlib]), - and similarly for the pngbook build. - - Note that all three packages are designed to be built from a command - line by default; those who wish to use a graphical or other integrated - development environments are on their own. - - - - Unix: - - Unpack the latest pngbook sources (which should correspond to this - README file) into a directory and change into that directory. - - Copy Makefile.unx to Makefile and edit the PNG* and Z* variables - appropriately (possibly also the X* variables if necessary). - - make - - There is no "install" target, so copy the three executables somewhere - in your path or run them from the current directory. All three will - print a basic usage screen when run without any command-line arguments; - see the book for more details. - - - - Windows: - - Unpack the latest pngbook sources (which should correspond to this - README file) into a folder, open a "DOS shell" or "command prompt" - or equivalent command-line window, and cd into the folder where you - unpacked the source code. - - For MSVC, set up the necessary environment variables by invoking - - %devstudio%\vc\bin\vcvars32.bat - - where where %devstudio% is the installation directory for MSVC / - DevStudio. If you get "environment out of space" errors under 95/98, - create a desktop shortcut with "c:\windows\command.com /e:4096" as - the program command line and set the working directory to the pngbook - directory. Then double-click to open the new DOS-prompt window with - a bigger environment and retry the commands above. - - Copy Makefile.w32 to Makefile and edit the PNGPATH and ZPATH variables - appropriately (possibly also the "INC" and "LIB" variables if needed). - Note that the names of the dynamic and static libpng and zlib libraries - used in the makefile may change in later releases of the libraries. - Also note that, as of libpng version 1.0.5, MSVC DLL builds do not work. - This makefile therefore builds statically linked executables, but if - the DLL problems ever get fixed, uncommenting the appropriate PNGLIB - and ZLIB lines will build dynamically linked executables instead. - - Do the build by typing - - nmake - - The result should be three executables: rpng-win.exe, rpng2-win.exe, - and wpng.exe. Copy them somewhere in your PATH or run them from the - current folder. Like the Unix versions, the two windowed programs - (rpng and rpng2) now display a usage screen in a console window when - invoked without command-line arguments; this is new behavior as of - the June 2001 release. Note that the programs use the Unix-style "-" - character to specify options, instead of the more common DOS/Windows - "/" character. (For example: "rpng2-win -bgpat 4 foo.png", not - "rpng2-win /bgpat 4 foo.png") - - - - OpenVMS: - - Unpack the pngbook sources into a subdirectory and change into that - subdirectory. - - Edit makevms.com appropriately, specifically the zpath and pngpath - variables. - - @makevms - - To run the programs, they probably first need to be set up as "foreign - symbols," with "disk" and "dir" set appropriately: - - $ rpng == "$disk:[dir]rpng-x.exe" - $ rpng2 == "$disk:[dir]rpng2-x.exe" - $ wpng == "$disk:[dir]wpng.exe" - - All three will print a basic usage screen when run without any command- - line arguments; see the book for more details. Note that the options - style is Unix-like, i.e., preceded by "-" rather than "/". - - -RUNNING THE PROGRAMS: (VERY) BRIEF INTRO - - rpng is a simple PNG viewer that can display transparent PNGs with a - specified background color; for example, - - rpng -bgcolor #ff0000 toucan.png - - would display the image with a red background. rpng2 is a progressive - viewer that simulates a web browser in some respects; it can display - images against either a background color or a dynamically generated - background image. For example: - - rpng2 -bgpat 16 toucan.png - - wpng is a purely command-line image converter from binary PBMPLUS/NetPBM - format (.pgm or .ppm) to PNG; for example, - - wpng -time < toucan.ppm > toucan.png - - would convert the specified PPM file (using redirection) to PNG, auto- - matically setting the PNG modification-time chunk. - - All options can be abbreviated to the shortest unique value; for example, - "-bgc" for -bgcolor (versus "-bgp" for -bgpat), or "-g" for -gamma. + =========================== + PNG: The Definitive Guide + =========================== + + Source Code + +Chapters 13, 14 and 15 of "PNG: The Definitive Guide" discuss three free, +cross-platform demo programs that show how to use the libpng reference +library: rpng, rpng2 and wpng. rpng and rpng2 are viewers; the first is +a very simple example that that shows how a standard file-viewer might use +libpng, while the second is designed to process streaming data and shows +how a web browser might be written. wpng is a simple command-line program +that reads binary PGM and PPM files (the ``raw'' grayscale and RGB subsets +of PBMPLUS/NetPBM) and converts them to PNG. + +The source code for all three demo programs currently compiles under +Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser, +zinser@decus.de, for making the necessary changes for OpenVMS and for +providing an appropriate build script.) Build instructions can be found +below. + +Files: + + README this file + LICENSE terms of distribution and reuse (BSD-like) + + Makefile.unx Unix makefile + Makefile.w32 Windows (MSVC) makefile + makevms.com OpenVMS build script + + rpng-win.c Windows front end for the basic viewer + rpng-x.c X Window System (Unix, OpenVMS) front end + readpng.c generic back end for the basic viewer + readpng.h header file for the basic viewer + + rpng2-win.c Windows front end for the progressive viewer + rpng2-x.c X front end for the progressive viewer + readpng2.c generic back end for the progressive viewer + readpng2.h header file for the progressive viewer + + wpng.c generic (text) front end for the converter + writepng.c generic back end for the converter + writepng.h header file for the converter + + toucan.png transparent PNG for testing (by Stefan Schneider) + +Note that, although the programs are designed to be functional, their +primary purpose is to illustrate how to use libpng to add PNG support to +other programs. As such, their user interfaces are crude and definitely +are not intended for everyday use. + +Please see http://www.libpng.org/pub/png/pngbook.html for further infor- +mation and links to the latest version of the source code, and Chapters +13-15 of the book for detailed discussion of the three programs. + +Greg Roelofs +newt@pobox.com +30 June 2001 + + +BUILD INSTRUCTIONS + + - Prerequisites (in order of compilation): + + - zlib http://www.gzip.org/zlib/ + - libpng http://www.libpng.org/pub/png/libpng.html + - pngbook http://www.libpng.org/pub/png/book/sources.html + + The pngbook demo programs are explicitly designed to demonstrate proper + coding techniques for using the libpng reference library. As a result, + you need to download and build both zlib (on which libpng depends) and + libpng. A common build setup is to place the zlib, libpng and pngbook + subdirectory trees ("folders") in the same parent directory. Then the + libpng build can refer to files in ../zlib (or ..\zlib or [-.zlib]), + and similarly for the pngbook build. + + Note that all three packages are designed to be built from a command + line by default; those who wish to use a graphical or other integrated + development environments are on their own. + + + - Unix: + + Unpack the latest pngbook sources (which should correspond to this + README file) into a directory and change into that directory. + + Copy Makefile.unx to Makefile and edit the PNG* and Z* variables + appropriately (possibly also the X* variables if necessary). + + make + + There is no "install" target, so copy the three executables somewhere + in your path or run them from the current directory. All three will + print a basic usage screen when run without any command-line arguments; + see the book for more details. + + + - Windows: + + Unpack the latest pngbook sources (which should correspond to this + README file) into a folder, open a "DOS shell" or "command prompt" + or equivalent command-line window, and cd into the folder where you + unpacked the source code. + + For MSVC, set up the necessary environment variables by invoking + + %devstudio%\vc\bin\vcvars32.bat + + where where %devstudio% is the installation directory for MSVC / + DevStudio. If you get "environment out of space" errors under 95/98, + create a desktop shortcut with "c:\windows\command.com /e:4096" as + the program command line and set the working directory to the pngbook + directory. Then double-click to open the new DOS-prompt window with + a bigger environment and retry the commands above. + + Copy Makefile.w32 to Makefile and edit the PNGPATH and ZPATH variables + appropriately (possibly also the "INC" and "LIB" variables if needed). + Note that the names of the dynamic and static libpng and zlib libraries + used in the makefile may change in later releases of the libraries. + Also note that, as of libpng version 1.0.5, MSVC DLL builds do not work. + This makefile therefore builds statically linked executables, but if + the DLL problems ever get fixed, uncommenting the appropriate PNGLIB + and ZLIB lines will build dynamically linked executables instead. + + Do the build by typing + + nmake + + The result should be three executables: rpng-win.exe, rpng2-win.exe, + and wpng.exe. Copy them somewhere in your PATH or run them from the + current folder. Like the Unix versions, the two windowed programs + (rpng and rpng2) now display a usage screen in a console window when + invoked without command-line arguments; this is new behavior as of + the June 2001 release. Note that the programs use the Unix-style "-" + character to specify options, instead of the more common DOS/Windows + "/" character. (For example: "rpng2-win -bgpat 4 foo.png", not + "rpng2-win /bgpat 4 foo.png") + + + - OpenVMS: + + Unpack the pngbook sources into a subdirectory and change into that + subdirectory. + + Edit makevms.com appropriately, specifically the zpath and pngpath + variables. + + @makevms + + To run the programs, they probably first need to be set up as "foreign + symbols," with "disk" and "dir" set appropriately: + + $ rpng == "$disk:[dir]rpng-x.exe" + $ rpng2 == "$disk:[dir]rpng2-x.exe" + $ wpng == "$disk:[dir]wpng.exe" + + All three will print a basic usage screen when run without any command- + line arguments; see the book for more details. Note that the options + style is Unix-like, i.e., preceded by "-" rather than "/". + + +RUNNING THE PROGRAMS: (VERY) BRIEF INTRO + + rpng is a simple PNG viewer that can display transparent PNGs with a + specified background color; for example, + + rpng -bgcolor #ff0000 toucan.png + + would display the image with a red background. rpng2 is a progressive + viewer that simulates a web browser in some respects; it can display + images against either a background color or a dynamically generated + background image. For example: + + rpng2 -bgpat 16 toucan.png + + wpng is a purely command-line image converter from binary PBMPLUS/NetPBM + format (.pgm or .ppm) to PNG; for example, + + wpng -time < toucan.ppm > toucan.png + + would convert the specified PPM file (using redirection) to PNG, auto- + matically setting the PNG modification-time chunk. + + All options can be abbreviated to the shortest unique value; for example, + "-bgc" for -bgcolor (versus "-bgp" for -bgpat), or "-g" for -gamma. diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/makevms.com b/src/dep/src/irrlicht/libpng/contrib/gregbook/makevms.com index ae1b999..bd37dc0 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/makevms.com +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/makevms.com @@ -1,132 +1,132 @@ -$!------------------------------------------------------------------------------ -$! make "PNG: The Definitive Guide" demo programs (for X) under OpenVMS -$! -$! Script created by Martin Zinser for libpng; modified by Greg Roelofs -$! for standalone pngbook source distribution. -$! -$! -$! Set locations where zlib and libpng sources live. -$! -$ zpath = "" -$ pngpath = "" -$! -$ if f$search("[---.zlib]zlib.h").nes."" then zpath = "[---.zlib]" -$ if f$search("[--]png.h").nes."" then pngpath = "[--]" -$! -$ if f$search("[-.zlib]zlib.h").nes."" then zpath = "[-.zlib]" -$ if f$search("[-.libpng]png.h").nes."" then pngpath = "[-.libpng]" -$! -$ if zpath .eqs. "" -$ then -$ write sys$output "zlib include not found. Exiting..." -$ exit 2 -$ endif -$! -$ if pngpath .eqs. "" -$ then -$ write sys$output "libpng include not found. Exiting..." -$ exit 2 -$ endif -$! -$! Look for the compiler used. -$! -$ ccopt="/include=(''zpath',''pngpath')" -$ if f$getsyi("HW_MODEL").ge.1024 -$ then -$ ccopt = "/prefix=all"+ccopt -$ comp = "__decc__=1" -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ else -$ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" -$ then -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ if f$search("SYS$SYSTEM:VAXC.EXE").eqs."" -$ then -$ comp = "__gcc__=1" -$ CC :== GCC -$ else -$ comp = "__vaxc__=1" -$ endif -$ else -$ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: -$ ccopt = "/decc/prefix=all"+ccopt -$ comp = "__decc__=1" -$ endif -$ endif -$ open/write lopt lib.opt -$ write lopt "''pngpath'libpng.olb/lib" -$ write lopt "''zpath'libz.olb/lib" -$ close lopt -$ open/write xopt x11.opt -$ write xopt "sys$library:decw$xlibshr.exe/share" -$ close xopt -$! -$! Build 'em. -$! -$ write sys$output "Compiling PNG book programs ..." -$ CALL MAKE readpng.OBJ "cc ''CCOPT' readpng" - - readpng.c readpng.h -$ CALL MAKE readpng2.OBJ "cc ''CCOPT' readpng2" - - readpng2.c readpng2.h -$ CALL MAKE writepng.OBJ "cc ''CCOPT' writepng" - - writepng.c writepng.h -$ write sys$output "Building rpng-x..." -$ CALL MAKE rpng-x.OBJ "cc ''CCOPT' rpng-x" - - rpng-x.c readpng.h -$ call make rpng-x.exe - - "LINK rpng-x,readpng,lib.opt/opt,x11.opt/opt" - - rpng-x.obj readpng.obj -$ write sys$output "Building rpng2-x..." -$ CALL MAKE rpng2-x.OBJ "cc ''CCOPT' rpng2-x" - - rpng2-x.c readpng2.h -$ call make rpng2-x.exe - - "LINK rpng2-x,readpng2,lib.opt/opt,x11.opt/opt" - - rpng2-x.obj readpng2.obj -$ write sys$output "Building wpng..." -$ CALL MAKE wpng.OBJ "cc ''CCOPT' wpng" - - wpng.c writepng.h -$ call make wpng.exe - - "LINK wpng,writepng,lib.opt/opt" - - wpng.obj writepng.obj -$ exit -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 - P8 What it depends on -$ -$ If F$Search(P1) .Eqs. "" Then Goto Makeit -$ Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(0) -$ write sys$output P2 -$ 'P2 -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE +$!------------------------------------------------------------------------------ +$! make "PNG: The Definitive Guide" demo programs (for X) under OpenVMS +$! +$! Script created by Martin Zinser for libpng; modified by Greg Roelofs +$! for standalone pngbook source distribution. +$! +$! +$! Set locations where zlib and libpng sources live. +$! +$ zpath = "" +$ pngpath = "" +$! +$ if f$search("[---.zlib]zlib.h").nes."" then zpath = "[---.zlib]" +$ if f$search("[--]png.h").nes."" then pngpath = "[--]" +$! +$ if f$search("[-.zlib]zlib.h").nes."" then zpath = "[-.zlib]" +$ if f$search("[-.libpng]png.h").nes."" then pngpath = "[-.libpng]" +$! +$ if zpath .eqs. "" +$ then +$ write sys$output "zlib include not found. Exiting..." +$ exit 2 +$ endif +$! +$ if pngpath .eqs. "" +$ then +$ write sys$output "libpng include not found. Exiting..." +$ exit 2 +$ endif +$! +$! Look for the compiler used. +$! +$ ccopt="/include=(''zpath',''pngpath')" +$ if f$getsyi("HW_MODEL").ge.1024 +$ then +$ ccopt = "/prefix=all"+ccopt +$ comp = "__decc__=1" +$ if f$trnlnm("SYS").eqs."" then define sys sys$library: +$ else +$ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" +$ then +$ if f$trnlnm("SYS").eqs."" then define sys sys$library: +$ if f$search("SYS$SYSTEM:VAXC.EXE").eqs."" +$ then +$ comp = "__gcc__=1" +$ CC :== GCC +$ else +$ comp = "__vaxc__=1" +$ endif +$ else +$ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: +$ ccopt = "/decc/prefix=all"+ccopt +$ comp = "__decc__=1" +$ endif +$ endif +$ open/write lopt lib.opt +$ write lopt "''pngpath'libpng.olb/lib" +$ write lopt "''zpath'libz.olb/lib" +$ close lopt +$ open/write xopt x11.opt +$ write xopt "sys$library:decw$xlibshr.exe/share" +$ close xopt +$! +$! Build 'em. +$! +$ write sys$output "Compiling PNG book programs ..." +$ CALL MAKE readpng.OBJ "cc ''CCOPT' readpng" - + readpng.c readpng.h +$ CALL MAKE readpng2.OBJ "cc ''CCOPT' readpng2" - + readpng2.c readpng2.h +$ CALL MAKE writepng.OBJ "cc ''CCOPT' writepng" - + writepng.c writepng.h +$ write sys$output "Building rpng-x..." +$ CALL MAKE rpng-x.OBJ "cc ''CCOPT' rpng-x" - + rpng-x.c readpng.h +$ call make rpng-x.exe - + "LINK rpng-x,readpng,lib.opt/opt,x11.opt/opt" - + rpng-x.obj readpng.obj +$ write sys$output "Building rpng2-x..." +$ CALL MAKE rpng2-x.OBJ "cc ''CCOPT' rpng2-x" - + rpng2-x.c readpng2.h +$ call make rpng2-x.exe - + "LINK rpng2-x,readpng2,lib.opt/opt,x11.opt/opt" - + rpng2-x.obj readpng2.obj +$ write sys$output "Building wpng..." +$ CALL MAKE wpng.OBJ "cc ''CCOPT' wpng" - + wpng.c writepng.h +$ call make wpng.exe - + "LINK wpng,writepng,lib.opt/opt" - + wpng.obj writepng.obj +$ exit +$! +$! +$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES +$ V = 'F$Verify(0) +$! P1 = What we are trying to make +$! P2 = Command to make it +$! P3 - P8 What it depends on +$ +$ If F$Search(P1) .Eqs. "" Then Goto Makeit +$ Time = F$CvTime(F$File(P1,"RDT")) +$arg=3 +$Loop: +$ Argument = P'arg +$ If Argument .Eqs. "" Then Goto Exit +$ El=0 +$Loop2: +$ File = F$Element(El," ",Argument) +$ If File .Eqs. " " Then Goto Endl +$ AFile = "" +$Loop3: +$ OFile = AFile +$ AFile = F$Search(File) +$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl +$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit +$ Goto Loop3 +$NextEL: +$ El = El + 1 +$ Goto Loop2 +$EndL: +$ arg=arg+1 +$ If arg .Le. 8 Then Goto Loop +$ Goto Exit +$ +$Makeit: +$ VV=F$VERIFY(0) +$ write sys$output P2 +$ 'P2 +$ VV='F$Verify(VV) +$Exit: +$ If V Then Set Verify +$ENDSUBROUTINE diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng.c b/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng.c index 35d49e9..b8e0904 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng.c +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng.c @@ -1,280 +1,280 @@ -/*--------------------------------------------------------------------------- - - rpng - simple PNG display program readpng.c - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#include -#include - -#include "png.h" /* libpng header; includes zlib.h */ -#include "readpng.h" /* typedefs, common macros, public prototypes */ - -/* future versions of libpng will provide this macro: */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#endif - - -static png_structp png_ptr = NULL; -static png_infop info_ptr = NULL; - -png_uint_32 width, height; -int bit_depth, color_type; -uch *image_data = NULL; - - -void readpng_version_info(void) -{ - fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n", - PNG_LIBPNG_VER_STRING, png_libpng_ver); - fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", - ZLIB_VERSION, zlib_version); -} - - -/* return value = 0 for success, 1 for bad sig, 2 for bad IHDR, 4 for no mem */ - -int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight) -{ - uch sig[8]; - - - /* first do a quick check that the file really is a PNG image; could - * have used slightly more general png_sig_cmp() function instead */ - - fread(sig, 1, 8, infile); - if (!png_check_sig(sig, 8)) - return 1; /* bad signature */ - - - /* could pass pointers to user-defined error handlers instead of NULLs: */ - - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_ptr) - return 4; /* out of memory */ - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { - png_destroy_read_struct(&png_ptr, NULL, NULL); - return 4; /* out of memory */ - } - - - /* we could create a second info struct here (end_info), but it's only - * useful if we want to keep pre- and post-IDAT chunk info separated - * (mainly for PNG-aware image editors and converters) */ - - - /* setjmp() must be called in every function that calls a PNG-reading - * libpng function */ - - if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return 2; - } - - - png_init_io(png_ptr, infile); - png_set_sig_bytes(png_ptr, 8); /* we already read the 8 signature bytes */ - - png_read_info(png_ptr, info_ptr); /* read all PNG info up to image data */ - - - /* alternatively, could make separate calls to png_get_image_width(), - * etc., but want bit_depth and color_type for later [don't care about - * compression_type and filter_type => NULLs] */ - - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - NULL, NULL, NULL); - *pWidth = width; - *pHeight = height; - - - /* OK, that's all we need for now; return happy */ - - return 0; -} - - - - -/* returns 0 if succeeds, 1 if fails due to no bKGD chunk, 2 if libpng error; - * scales values to 8-bit if necessary */ - -int readpng_get_bgcolor(uch *red, uch *green, uch *blue) -{ - png_color_16p pBackground; - - - /* setjmp() must be called in every function that calls a PNG-reading - * libpng function */ - - if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return 2; - } - - - if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD)) - return 1; - - /* it is not obvious from the libpng documentation, but this function - * takes a pointer to a pointer, and it always returns valid red, green - * and blue values, regardless of color_type: */ - - png_get_bKGD(png_ptr, info_ptr, &pBackground); - - - /* however, it always returns the raw bKGD data, regardless of any - * bit-depth transformations, so check depth and adjust if necessary */ - - if (bit_depth == 16) { - *red = pBackground->red >> 8; - *green = pBackground->green >> 8; - *blue = pBackground->blue >> 8; - } else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) { - if (bit_depth == 1) - *red = *green = *blue = pBackground->gray? 255 : 0; - else if (bit_depth == 2) - *red = *green = *blue = (255/3) * pBackground->gray; - else /* bit_depth == 4 */ - *red = *green = *blue = (255/15) * pBackground->gray; - } else { - *red = (uch)pBackground->red; - *green = (uch)pBackground->green; - *blue = (uch)pBackground->blue; - } - - return 0; -} - - - - -/* display_exponent == LUT_exponent * CRT_exponent */ - -uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes) -{ - double gamma; - png_uint_32 i, rowbytes; - png_bytepp row_pointers = NULL; - - - /* setjmp() must be called in every function that calls a PNG-reading - * libpng function */ - - if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return NULL; - } - - - /* expand palette images to RGB, low-bit-depth grayscale images to 8 bits, - * transparency chunks to full alpha channel; strip 16-bit-per-sample - * images to 8 bits per sample; and convert grayscale to RGB[A] */ - - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_expand(png_ptr); - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_expand(png_ptr); - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_expand(png_ptr); - if (bit_depth == 16) - png_set_strip_16(png_ptr); - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - - - /* unlike the example in the libpng documentation, we have *no* idea where - * this file may have come from--so if it doesn't have a file gamma, don't - * do any correction ("do no harm") */ - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, display_exponent, gamma); - - - /* all transformations have been registered; now update info_ptr data, - * get rowbytes and channels, and allocate image memory */ - - png_read_update_info(png_ptr, info_ptr); - - *pRowbytes = rowbytes = png_get_rowbytes(png_ptr, info_ptr); - *pChannels = (int)png_get_channels(png_ptr, info_ptr); - - if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return NULL; - } - if ((row_pointers = (png_bytepp)malloc(height*sizeof(png_bytep))) == NULL) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - free(image_data); - image_data = NULL; - return NULL; - } - - Trace((stderr, "readpng_get_image: channels = %d, rowbytes = %ld, height = %ld\n", *pChannels, rowbytes, height)); - - - /* set the individual row_pointers to point at the correct offsets */ - - for (i = 0; i < height; ++i) - row_pointers[i] = image_data + i*rowbytes; - - - /* now we can go ahead and just read the whole image */ - - png_read_image(png_ptr, row_pointers); - - - /* and we're done! (png_read_end() can be omitted if no processing of - * post-IDAT text/time/etc. is desired) */ - - free(row_pointers); - row_pointers = NULL; - - png_read_end(png_ptr, NULL); - - return image_data; -} - - -void readpng_cleanup(int free_image_data) -{ - if (free_image_data && image_data) { - free(image_data); - image_data = NULL; - } - - if (png_ptr && info_ptr) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - png_ptr = NULL; - info_ptr = NULL; - } -} +/*--------------------------------------------------------------------------- + + rpng - simple PNG display program readpng.c + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + ---------------------------------------------------------------------------*/ + +#include +#include + +#include "png.h" /* libpng header; includes zlib.h */ +#include "readpng.h" /* typedefs, common macros, public prototypes */ + +/* future versions of libpng will provide this macro: */ +#ifndef png_jmpbuf +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#endif + + +static png_structp png_ptr = NULL; +static png_infop info_ptr = NULL; + +png_uint_32 width, height; +int bit_depth, color_type; +uch *image_data = NULL; + + +void readpng_version_info(void) +{ + fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n", + PNG_LIBPNG_VER_STRING, png_libpng_ver); + fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", + ZLIB_VERSION, zlib_version); +} + + +/* return value = 0 for success, 1 for bad sig, 2 for bad IHDR, 4 for no mem */ + +int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight) +{ + uch sig[8]; + + + /* first do a quick check that the file really is a PNG image; could + * have used slightly more general png_sig_cmp() function instead */ + + fread(sig, 1, 8, infile); + if (!png_check_sig(sig, 8)) + return 1; /* bad signature */ + + + /* could pass pointers to user-defined error handlers instead of NULLs: */ + + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!png_ptr) + return 4; /* out of memory */ + + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + png_destroy_read_struct(&png_ptr, NULL, NULL); + return 4; /* out of memory */ + } + + + /* we could create a second info struct here (end_info), but it's only + * useful if we want to keep pre- and post-IDAT chunk info separated + * (mainly for PNG-aware image editors and converters) */ + + + /* setjmp() must be called in every function that calls a PNG-reading + * libpng function */ + + if (setjmp(png_jmpbuf(png_ptr))) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + return 2; + } + + + png_init_io(png_ptr, infile); + png_set_sig_bytes(png_ptr, 8); /* we already read the 8 signature bytes */ + + png_read_info(png_ptr, info_ptr); /* read all PNG info up to image data */ + + + /* alternatively, could make separate calls to png_get_image_width(), + * etc., but want bit_depth and color_type for later [don't care about + * compression_type and filter_type => NULLs] */ + + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, + NULL, NULL, NULL); + *pWidth = width; + *pHeight = height; + + + /* OK, that's all we need for now; return happy */ + + return 0; +} + + + + +/* returns 0 if succeeds, 1 if fails due to no bKGD chunk, 2 if libpng error; + * scales values to 8-bit if necessary */ + +int readpng_get_bgcolor(uch *red, uch *green, uch *blue) +{ + png_color_16p pBackground; + + + /* setjmp() must be called in every function that calls a PNG-reading + * libpng function */ + + if (setjmp(png_jmpbuf(png_ptr))) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + return 2; + } + + + if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD)) + return 1; + + /* it is not obvious from the libpng documentation, but this function + * takes a pointer to a pointer, and it always returns valid red, green + * and blue values, regardless of color_type: */ + + png_get_bKGD(png_ptr, info_ptr, &pBackground); + + + /* however, it always returns the raw bKGD data, regardless of any + * bit-depth transformations, so check depth and adjust if necessary */ + + if (bit_depth == 16) { + *red = pBackground->red >> 8; + *green = pBackground->green >> 8; + *blue = pBackground->blue >> 8; + } else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) { + if (bit_depth == 1) + *red = *green = *blue = pBackground->gray? 255 : 0; + else if (bit_depth == 2) + *red = *green = *blue = (255/3) * pBackground->gray; + else /* bit_depth == 4 */ + *red = *green = *blue = (255/15) * pBackground->gray; + } else { + *red = (uch)pBackground->red; + *green = (uch)pBackground->green; + *blue = (uch)pBackground->blue; + } + + return 0; +} + + + + +/* display_exponent == LUT_exponent * CRT_exponent */ + +uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes) +{ + double gamma; + png_uint_32 i, rowbytes; + png_bytepp row_pointers = NULL; + + + /* setjmp() must be called in every function that calls a PNG-reading + * libpng function */ + + if (setjmp(png_jmpbuf(png_ptr))) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + return NULL; + } + + + /* expand palette images to RGB, low-bit-depth grayscale images to 8 bits, + * transparency chunks to full alpha channel; strip 16-bit-per-sample + * images to 8 bits per sample; and convert grayscale to RGB[A] */ + + if (color_type == PNG_COLOR_TYPE_PALETTE) + png_set_expand(png_ptr); + if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) + png_set_expand(png_ptr); + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) + png_set_expand(png_ptr); + if (bit_depth == 16) + png_set_strip_16(png_ptr); + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png_ptr); + + + /* unlike the example in the libpng documentation, we have *no* idea where + * this file may have come from--so if it doesn't have a file gamma, don't + * do any correction ("do no harm") */ + + if (png_get_gAMA(png_ptr, info_ptr, &gamma)) + png_set_gamma(png_ptr, display_exponent, gamma); + + + /* all transformations have been registered; now update info_ptr data, + * get rowbytes and channels, and allocate image memory */ + + png_read_update_info(png_ptr, info_ptr); + + *pRowbytes = rowbytes = png_get_rowbytes(png_ptr, info_ptr); + *pChannels = (int)png_get_channels(png_ptr, info_ptr); + + if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + return NULL; + } + if ((row_pointers = (png_bytepp)malloc(height*sizeof(png_bytep))) == NULL) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + free(image_data); + image_data = NULL; + return NULL; + } + + Trace((stderr, "readpng_get_image: channels = %d, rowbytes = %ld, height = %ld\n", *pChannels, rowbytes, height)); + + + /* set the individual row_pointers to point at the correct offsets */ + + for (i = 0; i < height; ++i) + row_pointers[i] = image_data + i*rowbytes; + + + /* now we can go ahead and just read the whole image */ + + png_read_image(png_ptr, row_pointers); + + + /* and we're done! (png_read_end() can be omitted if no processing of + * post-IDAT text/time/etc. is desired) */ + + free(row_pointers); + row_pointers = NULL; + + png_read_end(png_ptr, NULL); + + return image_data; +} + + +void readpng_cleanup(int free_image_data) +{ + if (free_image_data && image_data) { + free(image_data); + image_data = NULL; + } + + if (png_ptr && info_ptr) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + png_ptr = NULL; + info_ptr = NULL; + } +} diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng.h b/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng.h index 6e378de..1c19aca 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng.h +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng.h @@ -1,64 +1,64 @@ -/*--------------------------------------------------------------------------- - - rpng - simple PNG display program readpng.h - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#ifndef TRUE -# define TRUE 1 -# define FALSE 0 -#endif - -#ifndef MAX -# define MAX(a,b) ((a) > (b)? (a) : (b)) -# define MIN(a,b) ((a) < (b)? (a) : (b)) -#endif - -#ifdef DEBUG -# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} -#else -# define Trace(x) ; -#endif - -typedef unsigned char uch; -typedef unsigned short ush; -typedef unsigned long ulg; - - -/* prototypes for public functions in readpng.c */ - -void readpng_version_info(void); - -int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight); - -int readpng_get_bgcolor(uch *bg_red, uch *bg_green, uch *bg_blue); - -uch *readpng_get_image(double display_exponent, int *pChannels, - ulg *pRowbytes); - -void readpng_cleanup(int free_image_data); +/*--------------------------------------------------------------------------- + + rpng - simple PNG display program readpng.h + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + ---------------------------------------------------------------------------*/ + +#ifndef TRUE +# define TRUE 1 +# define FALSE 0 +#endif + +#ifndef MAX +# define MAX(a,b) ((a) > (b)? (a) : (b)) +# define MIN(a,b) ((a) < (b)? (a) : (b)) +#endif + +#ifdef DEBUG +# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} +#else +# define Trace(x) ; +#endif + +typedef unsigned char uch; +typedef unsigned short ush; +typedef unsigned long ulg; + + +/* prototypes for public functions in readpng.c */ + +void readpng_version_info(void); + +int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight); + +int readpng_get_bgcolor(uch *bg_red, uch *bg_green, uch *bg_blue); + +uch *readpng_get_image(double display_exponent, int *pChannels, + ulg *pRowbytes); + +void readpng_cleanup(int free_image_data); diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng2.c b/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng2.c index 2f723be..9e66a0b 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng2.c +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng2.c @@ -1,624 +1,624 @@ -/*--------------------------------------------------------------------------- - - rpng2 - progressive-model PNG display program readpng2.c - - --------------------------------------------------------------------------- - - Changelog: - - 1.01: initial public release - - 1.02: added code to skip unused chunks (GR-P) - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2002 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - - -#include /* for exit() prototype */ - -#include "png.h" /* libpng header; includes zlib.h and setjmp.h */ -#include "readpng2.h" /* typedefs, common macros, public prototypes */ - - -/* local prototypes */ - -static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr); -static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass); -static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr); -static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg); - - - - -void readpng2_version_info(void) -{ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \ - (defined(__i386__) || defined(_M_IX86)) && \ - defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - /* - * WARNING: This preprocessor approach means that the following code - * cannot be used with a libpng DLL older than 1.2.0--the - * compiled-in symbols for the new functions will not exist. - * (Could use dlopen() and dlsym() on Unix and corresponding - * calls for Windows, but not portable...) - */ - { - int mmxsupport = png_mmx_support(); - if (mmxsupport < 0) - fprintf(stderr, " Compiled with libpng %s; using libpng %s " - "without MMX support.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver); - else { - int compilerID; - png_uint_32 mmx_mask = png_get_mmx_flagmask( - PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); - - fprintf(stderr, " Compiled with libpng %s; using libpng %s " - "with MMX support\n (%s version).", PNG_LIBPNG_VER_STRING, - png_libpng_ver, compilerID == 1? "MSVC++" : - (compilerID == 2? "GNU C" : "unknown")); - fprintf(stderr, " Processor %s MMX instructions.\n", - mmxsupport? "supports" : "does not support"); - if (mmxsupport > 0) { - int num_optims = 0; - - fprintf(stderr, - " Potential MMX optimizations supported by libpng:\n"); - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) - ++num_optims; - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_UP) - ++num_optims; - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) - ++num_optims; - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) - ++num_optims; - if (num_optims) - fprintf(stderr, - " decoding %s row filters (reading)\n", - (num_optims == 4)? "all non-trivial" : "some"); - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) { - fprintf(stderr, " combining rows (reading)\n"); - ++num_optims; - } - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_INTERLACE) { - fprintf(stderr, - " expanding interlacing (reading)\n"); - ++num_optims; - } - mmx_mask &= ~( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); - if (mmx_mask) { - fprintf(stderr, " other (unknown)\n"); - ++num_optims; - } - if (num_optims == 0) - fprintf(stderr, " (none)\n"); - } - } - } -#else - fprintf(stderr, " Compiled with libpng %s; using libpng %s " - "without MMX support.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver); -#endif - - fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", - ZLIB_VERSION, zlib_version); -} - - - - -int readpng2_check_sig(uch *sig, int num) -{ - return png_check_sig(sig, num); -} - - - - -/* returns 0 for success, 2 for libpng problem, 4 for out of memory */ - -int readpng2_init(mainprog_info *mainprog_ptr) -{ - png_structp png_ptr; /* note: temporary variables! */ - png_infop info_ptr; - - - /* could also replace libpng warning-handler (final NULL), but no need: */ - - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr, - readpng2_error_handler, NULL); - if (!png_ptr) - return 4; /* out of memory */ - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { - png_destroy_read_struct(&png_ptr, NULL, NULL); - return 4; /* out of memory */ - } - - - /* we could create a second info struct here (end_info), but it's only - * useful if we want to keep pre- and post-IDAT chunk info separated - * (mainly for PNG-aware image editors and converters) */ - - - /* setjmp() must be called in every function that calls a PNG-reading - * libpng function, unless an alternate error handler was installed-- - * but compatible error handlers must either use longjmp() themselves - * (as in this program) or exit immediately, so here we are: */ - - if (setjmp(mainprog_ptr->jmpbuf)) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return 2; - } - - /* prepare the reader to ignore all recognized chunks whose data isn't - * going to be used, i.e., all chunks recognized by libpng except for - * IHDR, PLTE, IDAT, IEND, tRNS, bKGD, gAMA, and sRGB : */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - { -#ifndef HANDLE_CHUNK_NEVER -/* prior to libpng-1.2.5, this macro was internal, so we define it here. */ -# define HANDLE_CHUNK_NEVER 1 -#endif - /* these byte strings were copied from png.h. - * If a future libpng version recognizes more chunks, add them - * to this list. If a future version of readpng2.c recognizes - * more chunks, delete them from this list. */ - png_byte png_chunk_types_to_ignore[]= - { 99, 72, 82, 77, '\0', /* cHRM */ - 104, 73, 83, 84, '\0', /* hIST */ - 105, 67, 67, 80, '\0', /* iCCP */ - 105, 84, 88, 116, '\0', /* iTXt */ - 111, 70, 70, 115, '\0', /* oFFs */ - 112, 67, 65, 76, '\0', /* pCAL */ - 115, 67, 65, 76, '\0', /* sCAL */ - 112, 72, 89, 115, '\0', /* pHYs */ - 115, 66, 73, 84, '\0', /* sBIT */ - 115, 80, 76, 84, '\0', /* sPLT */ - 116, 69, 88, 116, '\0', /* tEXt */ - 116, 73, 77, 69, '\0', /* tIME */ - 122, 84, 88, 116, '\0'}; /* zTXt */ -#define NUM_PNG_CHUNK_TYPES_TO_IGNORE 13 - - png_set_keep_unknown_chunks(png_ptr, HANDLE_CHUNK_NEVER, - png_chunk_types_to_ignore, NUM_PNG_CHUNK_TYPES_TO_IGNORE); - } -#endif - - /* instead of doing png_init_io() here, now we set up our callback - * functions for progressive decoding */ - - png_set_progressive_read_fn(png_ptr, mainprog_ptr, - readpng2_info_callback, readpng2_row_callback, readpng2_end_callback); - - - /* - * may as well enable or disable MMX routines here, if supported; - * - * to enable all: mask = png_get_mmx_flagmask ( - * PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); - * flags = png_get_asm_flags (png_ptr); - * flags |= mask; - * png_set_asm_flags (png_ptr, flags); - * - * to disable all: mask = png_get_mmx_flagmask ( - * PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); - * flags = png_get_asm_flags (png_ptr); - * flags &= ~mask; - * png_set_asm_flags (png_ptr, flags); - */ - -#if (defined(__i386__) || defined(_M_IX86)) && \ - defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - /* - * WARNING: This preprocessor approach means that the following code - * cannot be used with a libpng DLL older than 1.2.0--the - * compiled-in symbols for the new functions will not exist. - * (Could use dlopen() and dlsym() on Unix and corresponding - * calls for Windows, but not portable...) - */ - { -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED - png_uint_32 mmx_disable_mask = 0; - png_uint_32 asm_flags, mmx_mask; - int compilerID; - - if (mainprog_ptr->nommxfilters) - mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); - if (mainprog_ptr->nommxcombine) - mmx_disable_mask |= PNG_ASM_FLAG_MMX_READ_COMBINE_ROW; - if (mainprog_ptr->nommxinterlace) - mmx_disable_mask |= PNG_ASM_FLAG_MMX_READ_INTERLACE; - asm_flags = png_get_asm_flags(png_ptr); - png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask); - - - /* Now query libpng's asm settings, just for yuks. Note that this - * differs from the querying of its *potential* MMX capabilities - * in readpng2_version_info(); this is true runtime verification. */ - - asm_flags = png_get_asm_flags(png_ptr); - mmx_mask = png_get_mmx_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE, - &compilerID); - if (asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) - fprintf(stderr, - " MMX support (%s version) is compiled into libpng\n", - compilerID == 1? "MSVC++" : - (compilerID == 2? "GNU C" : "unknown")); - else - fprintf(stderr, " MMX support is not compiled into libpng\n"); - fprintf(stderr, " MMX instructions are %ssupported by CPU\n", - (asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU)? "" : "not "); - fprintf(stderr, " MMX read support for combining rows is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)? "en" : "dis"); - fprintf(stderr, - " MMX read support for expanding interlacing is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE)? "en" : "dis"); - fprintf(stderr, " MMX read support for \"sub\" filter is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "en" : "dis"); - fprintf(stderr, " MMX read support for \"up\" filter is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "en" : "dis"); - fprintf(stderr, " MMX read support for \"avg\" filter is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "en" : "dis"); - fprintf(stderr, " MMX read support for \"Paeth\" filter is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "en" : "dis"); - asm_flags &= (mmx_mask & ~( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH )); - if (asm_flags) - fprintf(stderr, - " additional MMX support is also enabled (0x%02lx)\n", - asm_flags); -#else /* !PNG_ASSEMBLER_CODE_SUPPORTED */ - fprintf(stderr, " MMX querying is disabled in libpng.\n"); -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ - } -#endif - - - /* make sure we save our pointers for use in readpng2_decode_data() */ - - mainprog_ptr->png_ptr = png_ptr; - mainprog_ptr->info_ptr = info_ptr; - - - /* and that's all there is to initialization */ - - return 0; -} - - - - -/* returns 0 for success, 2 for libpng (longjmp) problem */ - -int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length) -{ - png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; - png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; - - - /* setjmp() must be called in every function that calls a PNG-reading - * libpng function */ - - if (setjmp(mainprog_ptr->jmpbuf)) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - mainprog_ptr->png_ptr = NULL; - mainprog_ptr->info_ptr = NULL; - return 2; - } - - - /* hand off the next chunk of input data to libpng for decoding */ - - png_process_data(png_ptr, info_ptr, rawbuf, length); - - return 0; -} - - - - -static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr) -{ - mainprog_info *mainprog_ptr; - int color_type, bit_depth; - double gamma; - - - /* setjmp() doesn't make sense here, because we'd either have to exit(), - * longjmp() ourselves, or return control to libpng, which doesn't want - * to see us again. By not doing anything here, libpng will instead jump - * to readpng2_decode_data(), which can return an error value to the main - * program. */ - - - /* retrieve the pointer to our special-purpose struct, using the png_ptr - * that libpng passed back to us (i.e., not a global this time--there's - * no real difference for a single image, but for a multithreaded browser - * decoding several PNG images at the same time, one needs to avoid mixing - * up different images' structs) */ - - mainprog_ptr = png_get_progressive_ptr(png_ptr); - - if (mainprog_ptr == NULL) { /* we be hosed */ - fprintf(stderr, - "readpng2 error: main struct not recoverable in info_callback.\n"); - fflush(stderr); - return; - /* - * Alternatively, we could call our error-handler just like libpng - * does, which would effectively terminate the program. Since this - * can only happen if png_ptr gets redirected somewhere odd or the - * main PNG struct gets wiped, we're probably toast anyway. (If - * png_ptr itself is NULL, we would not have been called.) - */ - } - - - /* this is just like in the non-progressive case */ - - png_get_IHDR(png_ptr, info_ptr, &mainprog_ptr->width, - &mainprog_ptr->height, &bit_depth, &color_type, NULL, NULL, NULL); - - - /* since we know we've read all of the PNG file's "header" (i.e., up - * to IDAT), we can check for a background color here */ - - if (mainprog_ptr->need_bgcolor && - png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD)) - { - png_color_16p pBackground; - - /* it is not obvious from the libpng documentation, but this function - * takes a pointer to a pointer, and it always returns valid red, - * green and blue values, regardless of color_type: */ - png_get_bKGD(png_ptr, info_ptr, &pBackground); - - /* however, it always returns the raw bKGD data, regardless of any - * bit-depth transformations, so check depth and adjust if necessary */ - if (bit_depth == 16) { - mainprog_ptr->bg_red = pBackground->red >> 8; - mainprog_ptr->bg_green = pBackground->green >> 8; - mainprog_ptr->bg_blue = pBackground->blue >> 8; - } else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) { - if (bit_depth == 1) - mainprog_ptr->bg_red = mainprog_ptr->bg_green = - mainprog_ptr->bg_blue = pBackground->gray? 255 : 0; - else if (bit_depth == 2) - mainprog_ptr->bg_red = mainprog_ptr->bg_green = - mainprog_ptr->bg_blue = (255/3) * pBackground->gray; - else /* bit_depth == 4 */ - mainprog_ptr->bg_red = mainprog_ptr->bg_green = - mainprog_ptr->bg_blue = (255/15) * pBackground->gray; - } else { - mainprog_ptr->bg_red = (uch)pBackground->red; - mainprog_ptr->bg_green = (uch)pBackground->green; - mainprog_ptr->bg_blue = (uch)pBackground->blue; - } - } - - - /* as before, let libpng expand palette images to RGB, low-bit-depth - * grayscale images to 8 bits, transparency chunks to full alpha channel; - * strip 16-bit-per-sample images to 8 bits per sample; and convert - * grayscale to RGB[A] */ - - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_expand(png_ptr); - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_expand(png_ptr); - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_expand(png_ptr); - if (bit_depth == 16) - png_set_strip_16(png_ptr); - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - - - /* Unlike the basic viewer, which was designed to operate on local files, - * this program is intended to simulate a web browser--even though we - * actually read from a local file, too. But because we are pretending - * that most of the images originate on the Internet, we follow the recom- - * mendation of the sRGB proposal and treat unlabelled images (no gAMA - * chunk) as existing in the sRGB color space. That is, we assume that - * such images have a file gamma of 0.45455, which corresponds to a PC-like - * display system. This change in assumptions will have no effect on a - * PC-like system, but on a Mac, SGI, NeXT or other system with a non- - * identity lookup table, it will darken unlabelled images, which effec- - * tively favors images from PC-like systems over those originating on - * the local platform. Note that mainprog_ptr->display_exponent is the - * "gamma" value for the entire display system, i.e., the product of - * LUT_exponent and CRT_exponent. */ - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, mainprog_ptr->display_exponent, gamma); - else - png_set_gamma(png_ptr, mainprog_ptr->display_exponent, 0.45455); - - - /* we'll let libpng expand interlaced images, too */ - - mainprog_ptr->passes = png_set_interlace_handling(png_ptr); - - - /* all transformations have been registered; now update info_ptr data and - * then get rowbytes and channels */ - - png_read_update_info(png_ptr, info_ptr); - - mainprog_ptr->rowbytes = (int)png_get_rowbytes(png_ptr, info_ptr); - mainprog_ptr->channels = png_get_channels(png_ptr, info_ptr); - - - /* Call the main program to allocate memory for the image buffer and - * initialize windows and whatnot. (The old-style function-pointer - * invocation is used for compatibility with a few supposedly ANSI - * compilers that nevertheless barf on "fn_ptr()"-style syntax.) */ - - (*mainprog_ptr->mainprog_init)(); - - - /* and that takes care of initialization */ - - return; -} - - - - - -static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) -{ - mainprog_info *mainprog_ptr; - - - /* first check whether the row differs from the previous pass; if not, - * nothing to combine or display */ - - if (!new_row) - return; - - - /* retrieve the pointer to our special-purpose struct so we can access - * the old rows and image-display callback function */ - - mainprog_ptr = png_get_progressive_ptr(png_ptr); - - - /* save the pass number for optional use by the front end */ - - mainprog_ptr->pass = pass; - - - /* have libpng either combine the new row data with the existing row data - * from previous passes (if interlaced) or else just copy the new row - * into the main program's image buffer */ - - png_progressive_combine_row(png_ptr, mainprog_ptr->row_pointers[row_num], - new_row); - - - /* finally, call the display routine in the main program with the number - * of the row we just updated */ - - (*mainprog_ptr->mainprog_display_row)(row_num); - - - /* and we're ready for more */ - - return; -} - - - - - -static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr) -{ - mainprog_info *mainprog_ptr; - - - /* retrieve the pointer to our special-purpose struct */ - - mainprog_ptr = png_get_progressive_ptr(png_ptr); - - - /* let the main program know that it should flush any buffered image - * data to the display now and set a "done" flag or whatever, but note - * that it SHOULD NOT DESTROY THE PNG STRUCTS YET--in other words, do - * NOT call readpng2_cleanup() either here or in the finish_display() - * routine; wait until control returns to the main program via - * readpng2_decode_data() */ - - (*mainprog_ptr->mainprog_finish_display)(); - - - /* all done */ - - return; -} - - - - - -void readpng2_cleanup(mainprog_info *mainprog_ptr) -{ - png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; - png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; - - if (png_ptr && info_ptr) - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - - mainprog_ptr->png_ptr = NULL; - mainprog_ptr->info_ptr = NULL; -} - - - - - -static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg) -{ - mainprog_info *mainprog_ptr; - - /* This function, aside from the extra step of retrieving the "error - * pointer" (below) and the fact that it exists within the application - * rather than within libpng, is essentially identical to libpng's - * default error handler. The second point is critical: since both - * setjmp() and longjmp() are called from the same code, they are - * guaranteed to have compatible notions of how big a jmp_buf is, - * regardless of whether _BSD_SOURCE or anything else has (or has not) - * been defined. */ - - fprintf(stderr, "readpng2 libpng error: %s\n", msg); - fflush(stderr); - - mainprog_ptr = png_get_error_ptr(png_ptr); - if (mainprog_ptr == NULL) { /* we are completely hosed now */ - fprintf(stderr, - "readpng2 severe error: jmpbuf not recoverable; terminating.\n"); - fflush(stderr); - exit(99); - } - - longjmp(mainprog_ptr->jmpbuf, 1); -} +/*--------------------------------------------------------------------------- + + rpng2 - progressive-model PNG display program readpng2.c + + --------------------------------------------------------------------------- + + Changelog: + - 1.01: initial public release + - 1.02: added code to skip unused chunks (GR-P) + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2002 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + ---------------------------------------------------------------------------*/ + + +#include /* for exit() prototype */ + +#include "png.h" /* libpng header; includes zlib.h and setjmp.h */ +#include "readpng2.h" /* typedefs, common macros, public prototypes */ + + +/* local prototypes */ + +static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr); +static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row, + png_uint_32 row_num, int pass); +static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr); +static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg); + + + + +void readpng2_version_info(void) +{ +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \ + (defined(__i386__) || defined(_M_IX86)) && \ + defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + /* + * WARNING: This preprocessor approach means that the following code + * cannot be used with a libpng DLL older than 1.2.0--the + * compiled-in symbols for the new functions will not exist. + * (Could use dlopen() and dlsym() on Unix and corresponding + * calls for Windows, but not portable...) + */ + { + int mmxsupport = png_mmx_support(); + if (mmxsupport < 0) + fprintf(stderr, " Compiled with libpng %s; using libpng %s " + "without MMX support.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver); + else { + int compilerID; + png_uint_32 mmx_mask = png_get_mmx_flagmask( + PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); + + fprintf(stderr, " Compiled with libpng %s; using libpng %s " + "with MMX support\n (%s version).", PNG_LIBPNG_VER_STRING, + png_libpng_ver, compilerID == 1? "MSVC++" : + (compilerID == 2? "GNU C" : "unknown")); + fprintf(stderr, " Processor %s MMX instructions.\n", + mmxsupport? "supports" : "does not support"); + if (mmxsupport > 0) { + int num_optims = 0; + + fprintf(stderr, + " Potential MMX optimizations supported by libpng:\n"); + if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) + ++num_optims; + if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_UP) + ++num_optims; + if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) + ++num_optims; + if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) + ++num_optims; + if (num_optims) + fprintf(stderr, + " decoding %s row filters (reading)\n", + (num_optims == 4)? "all non-trivial" : "some"); + if (mmx_mask & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) { + fprintf(stderr, " combining rows (reading)\n"); + ++num_optims; + } + if (mmx_mask & PNG_ASM_FLAG_MMX_READ_INTERLACE) { + fprintf(stderr, + " expanding interlacing (reading)\n"); + ++num_optims; + } + mmx_mask &= ~( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ + | PNG_ASM_FLAG_MMX_READ_INTERLACE \ + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ + | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); + if (mmx_mask) { + fprintf(stderr, " other (unknown)\n"); + ++num_optims; + } + if (num_optims == 0) + fprintf(stderr, " (none)\n"); + } + } + } +#else + fprintf(stderr, " Compiled with libpng %s; using libpng %s " + "without MMX support.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver); +#endif + + fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", + ZLIB_VERSION, zlib_version); +} + + + + +int readpng2_check_sig(uch *sig, int num) +{ + return png_check_sig(sig, num); +} + + + + +/* returns 0 for success, 2 for libpng problem, 4 for out of memory */ + +int readpng2_init(mainprog_info *mainprog_ptr) +{ + png_structp png_ptr; /* note: temporary variables! */ + png_infop info_ptr; + + + /* could also replace libpng warning-handler (final NULL), but no need: */ + + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr, + readpng2_error_handler, NULL); + if (!png_ptr) + return 4; /* out of memory */ + + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + png_destroy_read_struct(&png_ptr, NULL, NULL); + return 4; /* out of memory */ + } + + + /* we could create a second info struct here (end_info), but it's only + * useful if we want to keep pre- and post-IDAT chunk info separated + * (mainly for PNG-aware image editors and converters) */ + + + /* setjmp() must be called in every function that calls a PNG-reading + * libpng function, unless an alternate error handler was installed-- + * but compatible error handlers must either use longjmp() themselves + * (as in this program) or exit immediately, so here we are: */ + + if (setjmp(mainprog_ptr->jmpbuf)) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + return 2; + } + + /* prepare the reader to ignore all recognized chunks whose data isn't + * going to be used, i.e., all chunks recognized by libpng except for + * IHDR, PLTE, IDAT, IEND, tRNS, bKGD, gAMA, and sRGB : */ + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + { +#ifndef HANDLE_CHUNK_NEVER +/* prior to libpng-1.2.5, this macro was internal, so we define it here. */ +# define HANDLE_CHUNK_NEVER 1 +#endif + /* these byte strings were copied from png.h. + * If a future libpng version recognizes more chunks, add them + * to this list. If a future version of readpng2.c recognizes + * more chunks, delete them from this list. */ + png_byte png_chunk_types_to_ignore[]= + { 99, 72, 82, 77, '\0', /* cHRM */ + 104, 73, 83, 84, '\0', /* hIST */ + 105, 67, 67, 80, '\0', /* iCCP */ + 105, 84, 88, 116, '\0', /* iTXt */ + 111, 70, 70, 115, '\0', /* oFFs */ + 112, 67, 65, 76, '\0', /* pCAL */ + 115, 67, 65, 76, '\0', /* sCAL */ + 112, 72, 89, 115, '\0', /* pHYs */ + 115, 66, 73, 84, '\0', /* sBIT */ + 115, 80, 76, 84, '\0', /* sPLT */ + 116, 69, 88, 116, '\0', /* tEXt */ + 116, 73, 77, 69, '\0', /* tIME */ + 122, 84, 88, 116, '\0'}; /* zTXt */ +#define NUM_PNG_CHUNK_TYPES_TO_IGNORE 13 + + png_set_keep_unknown_chunks(png_ptr, HANDLE_CHUNK_NEVER, + png_chunk_types_to_ignore, NUM_PNG_CHUNK_TYPES_TO_IGNORE); + } +#endif + + /* instead of doing png_init_io() here, now we set up our callback + * functions for progressive decoding */ + + png_set_progressive_read_fn(png_ptr, mainprog_ptr, + readpng2_info_callback, readpng2_row_callback, readpng2_end_callback); + + + /* + * may as well enable or disable MMX routines here, if supported; + * + * to enable all: mask = png_get_mmx_flagmask ( + * PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); + * flags = png_get_asm_flags (png_ptr); + * flags |= mask; + * png_set_asm_flags (png_ptr, flags); + * + * to disable all: mask = png_get_mmx_flagmask ( + * PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); + * flags = png_get_asm_flags (png_ptr); + * flags &= ~mask; + * png_set_asm_flags (png_ptr, flags); + */ + +#if (defined(__i386__) || defined(_M_IX86)) && \ + defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + /* + * WARNING: This preprocessor approach means that the following code + * cannot be used with a libpng DLL older than 1.2.0--the + * compiled-in symbols for the new functions will not exist. + * (Could use dlopen() and dlsym() on Unix and corresponding + * calls for Windows, but not portable...) + */ + { +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED + png_uint_32 mmx_disable_mask = 0; + png_uint_32 asm_flags, mmx_mask; + int compilerID; + + if (mainprog_ptr->nommxfilters) + mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ + | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); + if (mainprog_ptr->nommxcombine) + mmx_disable_mask |= PNG_ASM_FLAG_MMX_READ_COMBINE_ROW; + if (mainprog_ptr->nommxinterlace) + mmx_disable_mask |= PNG_ASM_FLAG_MMX_READ_INTERLACE; + asm_flags = png_get_asm_flags(png_ptr); + png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask); + + + /* Now query libpng's asm settings, just for yuks. Note that this + * differs from the querying of its *potential* MMX capabilities + * in readpng2_version_info(); this is true runtime verification. */ + + asm_flags = png_get_asm_flags(png_ptr); + mmx_mask = png_get_mmx_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE, + &compilerID); + if (asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) + fprintf(stderr, + " MMX support (%s version) is compiled into libpng\n", + compilerID == 1? "MSVC++" : + (compilerID == 2? "GNU C" : "unknown")); + else + fprintf(stderr, " MMX support is not compiled into libpng\n"); + fprintf(stderr, " MMX instructions are %ssupported by CPU\n", + (asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU)? "" : "not "); + fprintf(stderr, " MMX read support for combining rows is %sabled\n", + (asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)? "en" : "dis"); + fprintf(stderr, + " MMX read support for expanding interlacing is %sabled\n", + (asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE)? "en" : "dis"); + fprintf(stderr, " MMX read support for \"sub\" filter is %sabled\n", + (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "en" : "dis"); + fprintf(stderr, " MMX read support for \"up\" filter is %sabled\n", + (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "en" : "dis"); + fprintf(stderr, " MMX read support for \"avg\" filter is %sabled\n", + (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "en" : "dis"); + fprintf(stderr, " MMX read support for \"Paeth\" filter is %sabled\n", + (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "en" : "dis"); + asm_flags &= (mmx_mask & ~( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ + | PNG_ASM_FLAG_MMX_READ_INTERLACE \ + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ + | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH )); + if (asm_flags) + fprintf(stderr, + " additional MMX support is also enabled (0x%02lx)\n", + asm_flags); +#else /* !PNG_ASSEMBLER_CODE_SUPPORTED */ + fprintf(stderr, " MMX querying is disabled in libpng.\n"); +#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ + } +#endif + + + /* make sure we save our pointers for use in readpng2_decode_data() */ + + mainprog_ptr->png_ptr = png_ptr; + mainprog_ptr->info_ptr = info_ptr; + + + /* and that's all there is to initialization */ + + return 0; +} + + + + +/* returns 0 for success, 2 for libpng (longjmp) problem */ + +int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length) +{ + png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; + png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; + + + /* setjmp() must be called in every function that calls a PNG-reading + * libpng function */ + + if (setjmp(mainprog_ptr->jmpbuf)) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + mainprog_ptr->png_ptr = NULL; + mainprog_ptr->info_ptr = NULL; + return 2; + } + + + /* hand off the next chunk of input data to libpng for decoding */ + + png_process_data(png_ptr, info_ptr, rawbuf, length); + + return 0; +} + + + + +static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr) +{ + mainprog_info *mainprog_ptr; + int color_type, bit_depth; + double gamma; + + + /* setjmp() doesn't make sense here, because we'd either have to exit(), + * longjmp() ourselves, or return control to libpng, which doesn't want + * to see us again. By not doing anything here, libpng will instead jump + * to readpng2_decode_data(), which can return an error value to the main + * program. */ + + + /* retrieve the pointer to our special-purpose struct, using the png_ptr + * that libpng passed back to us (i.e., not a global this time--there's + * no real difference for a single image, but for a multithreaded browser + * decoding several PNG images at the same time, one needs to avoid mixing + * up different images' structs) */ + + mainprog_ptr = png_get_progressive_ptr(png_ptr); + + if (mainprog_ptr == NULL) { /* we be hosed */ + fprintf(stderr, + "readpng2 error: main struct not recoverable in info_callback.\n"); + fflush(stderr); + return; + /* + * Alternatively, we could call our error-handler just like libpng + * does, which would effectively terminate the program. Since this + * can only happen if png_ptr gets redirected somewhere odd or the + * main PNG struct gets wiped, we're probably toast anyway. (If + * png_ptr itself is NULL, we would not have been called.) + */ + } + + + /* this is just like in the non-progressive case */ + + png_get_IHDR(png_ptr, info_ptr, &mainprog_ptr->width, + &mainprog_ptr->height, &bit_depth, &color_type, NULL, NULL, NULL); + + + /* since we know we've read all of the PNG file's "header" (i.e., up + * to IDAT), we can check for a background color here */ + + if (mainprog_ptr->need_bgcolor && + png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD)) + { + png_color_16p pBackground; + + /* it is not obvious from the libpng documentation, but this function + * takes a pointer to a pointer, and it always returns valid red, + * green and blue values, regardless of color_type: */ + png_get_bKGD(png_ptr, info_ptr, &pBackground); + + /* however, it always returns the raw bKGD data, regardless of any + * bit-depth transformations, so check depth and adjust if necessary */ + if (bit_depth == 16) { + mainprog_ptr->bg_red = pBackground->red >> 8; + mainprog_ptr->bg_green = pBackground->green >> 8; + mainprog_ptr->bg_blue = pBackground->blue >> 8; + } else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) { + if (bit_depth == 1) + mainprog_ptr->bg_red = mainprog_ptr->bg_green = + mainprog_ptr->bg_blue = pBackground->gray? 255 : 0; + else if (bit_depth == 2) + mainprog_ptr->bg_red = mainprog_ptr->bg_green = + mainprog_ptr->bg_blue = (255/3) * pBackground->gray; + else /* bit_depth == 4 */ + mainprog_ptr->bg_red = mainprog_ptr->bg_green = + mainprog_ptr->bg_blue = (255/15) * pBackground->gray; + } else { + mainprog_ptr->bg_red = (uch)pBackground->red; + mainprog_ptr->bg_green = (uch)pBackground->green; + mainprog_ptr->bg_blue = (uch)pBackground->blue; + } + } + + + /* as before, let libpng expand palette images to RGB, low-bit-depth + * grayscale images to 8 bits, transparency chunks to full alpha channel; + * strip 16-bit-per-sample images to 8 bits per sample; and convert + * grayscale to RGB[A] */ + + if (color_type == PNG_COLOR_TYPE_PALETTE) + png_set_expand(png_ptr); + if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) + png_set_expand(png_ptr); + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) + png_set_expand(png_ptr); + if (bit_depth == 16) + png_set_strip_16(png_ptr); + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png_ptr); + + + /* Unlike the basic viewer, which was designed to operate on local files, + * this program is intended to simulate a web browser--even though we + * actually read from a local file, too. But because we are pretending + * that most of the images originate on the Internet, we follow the recom- + * mendation of the sRGB proposal and treat unlabelled images (no gAMA + * chunk) as existing in the sRGB color space. That is, we assume that + * such images have a file gamma of 0.45455, which corresponds to a PC-like + * display system. This change in assumptions will have no effect on a + * PC-like system, but on a Mac, SGI, NeXT or other system with a non- + * identity lookup table, it will darken unlabelled images, which effec- + * tively favors images from PC-like systems over those originating on + * the local platform. Note that mainprog_ptr->display_exponent is the + * "gamma" value for the entire display system, i.e., the product of + * LUT_exponent and CRT_exponent. */ + + if (png_get_gAMA(png_ptr, info_ptr, &gamma)) + png_set_gamma(png_ptr, mainprog_ptr->display_exponent, gamma); + else + png_set_gamma(png_ptr, mainprog_ptr->display_exponent, 0.45455); + + + /* we'll let libpng expand interlaced images, too */ + + mainprog_ptr->passes = png_set_interlace_handling(png_ptr); + + + /* all transformations have been registered; now update info_ptr data and + * then get rowbytes and channels */ + + png_read_update_info(png_ptr, info_ptr); + + mainprog_ptr->rowbytes = (int)png_get_rowbytes(png_ptr, info_ptr); + mainprog_ptr->channels = png_get_channels(png_ptr, info_ptr); + + + /* Call the main program to allocate memory for the image buffer and + * initialize windows and whatnot. (The old-style function-pointer + * invocation is used for compatibility with a few supposedly ANSI + * compilers that nevertheless barf on "fn_ptr()"-style syntax.) */ + + (*mainprog_ptr->mainprog_init)(); + + + /* and that takes care of initialization */ + + return; +} + + + + + +static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row, + png_uint_32 row_num, int pass) +{ + mainprog_info *mainprog_ptr; + + + /* first check whether the row differs from the previous pass; if not, + * nothing to combine or display */ + + if (!new_row) + return; + + + /* retrieve the pointer to our special-purpose struct so we can access + * the old rows and image-display callback function */ + + mainprog_ptr = png_get_progressive_ptr(png_ptr); + + + /* save the pass number for optional use by the front end */ + + mainprog_ptr->pass = pass; + + + /* have libpng either combine the new row data with the existing row data + * from previous passes (if interlaced) or else just copy the new row + * into the main program's image buffer */ + + png_progressive_combine_row(png_ptr, mainprog_ptr->row_pointers[row_num], + new_row); + + + /* finally, call the display routine in the main program with the number + * of the row we just updated */ + + (*mainprog_ptr->mainprog_display_row)(row_num); + + + /* and we're ready for more */ + + return; +} + + + + + +static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr) +{ + mainprog_info *mainprog_ptr; + + + /* retrieve the pointer to our special-purpose struct */ + + mainprog_ptr = png_get_progressive_ptr(png_ptr); + + + /* let the main program know that it should flush any buffered image + * data to the display now and set a "done" flag or whatever, but note + * that it SHOULD NOT DESTROY THE PNG STRUCTS YET--in other words, do + * NOT call readpng2_cleanup() either here or in the finish_display() + * routine; wait until control returns to the main program via + * readpng2_decode_data() */ + + (*mainprog_ptr->mainprog_finish_display)(); + + + /* all done */ + + return; +} + + + + + +void readpng2_cleanup(mainprog_info *mainprog_ptr) +{ + png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; + png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; + + if (png_ptr && info_ptr) + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + + mainprog_ptr->png_ptr = NULL; + mainprog_ptr->info_ptr = NULL; +} + + + + + +static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg) +{ + mainprog_info *mainprog_ptr; + + /* This function, aside from the extra step of retrieving the "error + * pointer" (below) and the fact that it exists within the application + * rather than within libpng, is essentially identical to libpng's + * default error handler. The second point is critical: since both + * setjmp() and longjmp() are called from the same code, they are + * guaranteed to have compatible notions of how big a jmp_buf is, + * regardless of whether _BSD_SOURCE or anything else has (or has not) + * been defined. */ + + fprintf(stderr, "readpng2 libpng error: %s\n", msg); + fflush(stderr); + + mainprog_ptr = png_get_error_ptr(png_ptr); + if (mainprog_ptr == NULL) { /* we are completely hosed now */ + fprintf(stderr, + "readpng2 severe error: jmpbuf not recoverable; terminating.\n"); + fflush(stderr); + exit(99); + } + + longjmp(mainprog_ptr->jmpbuf, 1); +} diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng2.h b/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng2.h index 2ed70d4..7caa9d9 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng2.h +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/readpng2.h @@ -1,91 +1,91 @@ -/*--------------------------------------------------------------------------- - - rpng2 - progressive-model PNG display program readpng2.h - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#ifndef TRUE -# define TRUE 1 -# define FALSE 0 -#endif - -#ifndef MAX -# define MAX(a,b) ((a) > (b)? (a) : (b)) -# define MIN(a,b) ((a) < (b)? (a) : (b)) -#endif - -#ifdef DEBUG -# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} -#else -# define Trace(x) ; -#endif - -typedef unsigned char uch; -typedef unsigned short ush; -typedef unsigned long ulg; - -typedef struct _mainprog_info { - double display_exponent; - ulg width; - ulg height; - void *png_ptr; - void *info_ptr; - void (*mainprog_init)(void); - void (*mainprog_display_row)(ulg row_num); - void (*mainprog_finish_display)(void); - uch *image_data; - uch **row_pointers; - jmp_buf jmpbuf; - int passes; /* not used */ - int pass; - int rowbytes; - int channels; - int need_bgcolor; -#if (defined(__i386__) || defined(_M_IX86)) - int nommxfilters; - int nommxcombine; - int nommxinterlace; -#endif - int done; - uch bg_red; - uch bg_green; - uch bg_blue; -} mainprog_info; - - -/* prototypes for public functions in readpng2.c */ - -void readpng2_version_info(void); - -int readpng2_check_sig(uch *sig, int num); - -int readpng2_init(mainprog_info *mainprog_ptr); - -int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length); - -void readpng2_cleanup(mainprog_info *mainprog_ptr); +/*--------------------------------------------------------------------------- + + rpng2 - progressive-model PNG display program readpng2.h + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + ---------------------------------------------------------------------------*/ + +#ifndef TRUE +# define TRUE 1 +# define FALSE 0 +#endif + +#ifndef MAX +# define MAX(a,b) ((a) > (b)? (a) : (b)) +# define MIN(a,b) ((a) < (b)? (a) : (b)) +#endif + +#ifdef DEBUG +# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} +#else +# define Trace(x) ; +#endif + +typedef unsigned char uch; +typedef unsigned short ush; +typedef unsigned long ulg; + +typedef struct _mainprog_info { + double display_exponent; + ulg width; + ulg height; + void *png_ptr; + void *info_ptr; + void (*mainprog_init)(void); + void (*mainprog_display_row)(ulg row_num); + void (*mainprog_finish_display)(void); + uch *image_data; + uch **row_pointers; + jmp_buf jmpbuf; + int passes; /* not used */ + int pass; + int rowbytes; + int channels; + int need_bgcolor; +#if (defined(__i386__) || defined(_M_IX86)) + int nommxfilters; + int nommxcombine; + int nommxinterlace; +#endif + int done; + uch bg_red; + uch bg_green; + uch bg_blue; +} mainprog_info; + + +/* prototypes for public functions in readpng2.c */ + +void readpng2_version_info(void); + +int readpng2_check_sig(uch *sig, int num); + +int readpng2_init(mainprog_info *mainprog_ptr); + +int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length); + +void readpng2_cleanup(mainprog_info *mainprog_ptr); diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng-win.c b/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng-win.c index b35e3ab..b84a7fc 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng-win.c +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng-win.c @@ -1,642 +1,642 @@ -/*--------------------------------------------------------------------------- - - rpng - simple PNG display program rpng-win.c - - This program decodes and displays PNG images, with gamma correction and - optionally with a user-specified background color (in case the image has - transparency). It is very nearly the most basic PNG viewer possible. - This version is for 32-bit Windows; it may compile under 16-bit Windows - with a little tweaking (or maybe not). - - to do: - - handle quoted command-line args (especially filenames with spaces) - - have minimum window width: oh well - - use %.1023s to simplify truncation of title-bar string? - - --------------------------------------------------------------------------- - - Changelog: - - 1.00: initial public release - - 1.01: modified to allow abbreviated options; fixed long/ulong mis- - match; switched to png_jmpbuf() macro - - 1.02: added extra set of parentheses to png_jmpbuf() macro; fixed - command-line parsing bug - - 1.10: enabled "message window"/console (thanks to David Geldreich) - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#define PROGNAME "rpng-win" -#define LONGNAME "Simple PNG Viewer for Windows" -#define VERSION "1.20 of 28 May 2001" - -#include -#include -#include -#include -#include -#include /* only for _getch() */ - -/* #define DEBUG : this enables the Trace() macros */ - -#include "readpng.h" /* typedefs, common macros, readpng prototypes */ - - -/* could just include png.h, but this macro is the only thing we need - * (name and typedefs changed to local versions); note that side effects - * only happen with alpha (which could easily be avoided with - * "ush acopy = (alpha);") */ - -#define alpha_composite(composite, fg, alpha, bg) { \ - ush temp = ((ush)(fg)*(ush)(alpha) + \ - (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \ - (composite) = (uch)((temp + (temp >> 8)) >> 8); \ -} - - -/* local prototypes */ -static int rpng_win_create_window(HINSTANCE hInst, int showmode); -static int rpng_win_display_image(void); -static void rpng_win_cleanup(void); -LRESULT CALLBACK rpng_win_wndproc(HWND, UINT, WPARAM, LPARAM); - - -static char titlebar[1024], *window_name = titlebar; -static char *progname = PROGNAME; -static char *appname = LONGNAME; -static char *icon_name = PROGNAME; /* GRR: not (yet) used */ -static char *filename; -static FILE *infile; - -static char *bgstr; -static uch bg_red=0, bg_green=0, bg_blue=0; - -static double display_exponent; - -static ulg image_width, image_height, image_rowbytes; -static int image_channels; -static uch *image_data; - -/* Windows-specific variables */ -static ulg wimage_rowbytes; -static uch *dib; -static uch *wimage_data; -static BITMAPINFOHEADER *bmih; - -static HWND global_hwnd; - - - - -int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) -{ - char *args[1024]; /* arbitrary limit, but should suffice */ - char *p, *q, **argv = args; - int argc = 0; - int rc, alen, flen; - int error = 0; - int have_bg = FALSE; - double LUT_exponent; /* just the lookup table */ - double CRT_exponent = 2.2; /* just the monitor */ - double default_display_exponent; /* whole display system */ - MSG msg; - - - filename = (char *)NULL; - - - /* First reenable console output, which normally goes to the bit bucket - * for windowed apps. Closing the console window will terminate the - * app. Thanks to David.Geldreich@realviz.com for supplying the magical - * incantation. */ - - AllocConsole(); - freopen("CONOUT$", "a", stderr); - freopen("CONOUT$", "a", stdout); - - - /* Next set the default value for our display-system exponent, i.e., - * the product of the CRT exponent and the exponent corresponding to - * the frame-buffer's lookup table (LUT), if any. This is not an - * exhaustive list of LUT values (e.g., OpenStep has a lot of weird - * ones), but it should cover 99% of the current possibilities. And - * yes, these ifdefs are completely wasted in a Windows program... */ - -#if defined(NeXT) - LUT_exponent = 1.0 / 2.2; - /* - if (some_next_function_that_returns_gamma(&next_gamma)) - LUT_exponent = 1.0 / next_gamma; - */ -#elif defined(sgi) - LUT_exponent = 1.0 / 1.7; - /* there doesn't seem to be any documented function to get the - * "gamma" value, so we do it the hard way */ - infile = fopen("/etc/config/system.glGammaVal", "r"); - if (infile) { - double sgi_gamma; - - fgets(tmpline, 80, infile); - fclose(infile); - sgi_gamma = atof(tmpline); - if (sgi_gamma > 0.0) - LUT_exponent = 1.0 / sgi_gamma; - } -#elif defined(Macintosh) - LUT_exponent = 1.8 / 2.61; - /* - if (some_mac_function_that_returns_gamma(&mac_gamma)) - LUT_exponent = mac_gamma / 2.61; - */ -#else - LUT_exponent = 1.0; /* assume no LUT: most PCs */ -#endif - - /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ - default_display_exponent = LUT_exponent * CRT_exponent; - - - /* If the user has set the SCREEN_GAMMA environment variable as suggested - * (somewhat imprecisely) in the libpng documentation, use that; otherwise - * use the default value we just calculated. Either way, the user may - * override this via a command-line option. */ - - if ((p = getenv("SCREEN_GAMMA")) != NULL) - display_exponent = atof(p); - else - display_exponent = default_display_exponent; - - - /* Windows really hates command lines, so we have to set up our own argv. - * Note that we do NOT bother with quoted arguments here, so don't use - * filenames with spaces in 'em! */ - - argv[argc++] = PROGNAME; - p = cmd; - for (;;) { - if (*p == ' ') - while (*++p == ' ') - ; - /* now p points at the first non-space after some spaces */ - if (*p == '\0') - break; /* nothing after the spaces: done */ - argv[argc++] = q = p; - while (*q && *q != ' ') - ++q; - /* now q points at a space or the end of the string */ - if (*q == '\0') - break; /* last argv already terminated; quit */ - *q = '\0'; /* change space to terminator */ - p = q + 1; - } - argv[argc] = NULL; /* terminate the argv array itself */ - - - /* Now parse the command line for options and the PNG filename. */ - - while (*++argv && !error) { - if (!strncmp(*argv, "-gamma", 2)) { - if (!*++argv) - ++error; - else { - display_exponent = atof(*argv); - if (display_exponent <= 0.0) - ++error; - } - } else if (!strncmp(*argv, "-bgcolor", 2)) { - if (!*++argv) - ++error; - else { - bgstr = *argv; - if (strlen(bgstr) != 7 || bgstr[0] != '#') - ++error; - else - have_bg = TRUE; - } - } else { - if (**argv != '-') { - filename = *argv; - if (argv[1]) /* shouldn't be any more args after filename */ - ++error; - } else - ++error; /* not expecting any other options */ - } - } - - if (!filename) { - ++error; - } else if (!(infile = fopen(filename, "rb"))) { - fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); - ++error; - } else { - if ((rc = readpng_init(infile, &image_width, &image_height)) != 0) { - switch (rc) { - case 1: - fprintf(stderr, PROGNAME - ": [%s] is not a PNG file: incorrect signature\n", - filename); - break; - case 2: - fprintf(stderr, PROGNAME - ": [%s] has bad IHDR (libpng longjmp)\n", - filename); - break; - case 4: - fprintf(stderr, PROGNAME ": insufficient memory\n"); - break; - default: - fprintf(stderr, PROGNAME - ": unknown readpng_init() error\n"); - break; - } - ++error; - } - if (error) - fclose(infile); - } - - - /* usage screen */ - - if (error) { - int ch; - - fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); - readpng_version_info(); - fprintf(stderr, "\n" - "Usage: %s [-gamma exp] [-bgcolor bg] file.png\n" - " exp \ttransfer-function exponent (``gamma'') of the display\n" - "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" - "\t\t to the product of the lookup-table exponent (varies)\n" - "\t\t and the CRT exponent (usually 2.2); must be positive\n" - " bg \tdesired background color in 7-character hex RGB format\n" - "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" - "\t\t used with transparent images\n" - "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" - "Press Q or Esc to quit this usage screen.\n" - "\n", PROGNAME, default_display_exponent); - do - ch = _getch(); - while (ch != 'q' && ch != 'Q' && ch != 0x1B); - exit(1); - } else { - fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); - fprintf(stderr, - "\n [console window: closing this window will terminate %s]\n\n", - PROGNAME); - } - - - /* set the title-bar string, but make sure buffer doesn't overflow */ - - alen = strlen(appname); - flen = strlen(filename); - if (alen + flen + 3 > 1023) - sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); - else - sprintf(titlebar, "%s: %s", appname, filename); - - - /* if the user didn't specify a background color on the command line, - * check for one in the PNG file--if not, the initialized values of 0 - * (black) will be used */ - - if (have_bg) - sscanf(bgstr+1, "%2x%2x%2x", &bg_red, &bg_green, &bg_blue); - else if (readpng_get_bgcolor(&bg_red, &bg_green, &bg_blue) > 1) { - readpng_cleanup(TRUE); - fprintf(stderr, PROGNAME - ": libpng error while checking for background color\n"); - exit(2); - } - - - /* do the basic Windows initialization stuff, make the window and fill it - * with the background color */ - - if (rpng_win_create_window(hInst, showmode)) - exit(2); - - - /* decode the image, all at once */ - - Trace((stderr, "calling readpng_get_image()\n")) - image_data = readpng_get_image(display_exponent, &image_channels, - &image_rowbytes); - Trace((stderr, "done with readpng_get_image()\n")) - - - /* done with PNG file, so clean up to minimize memory usage (but do NOT - * nuke image_data!) */ - - readpng_cleanup(FALSE); - fclose(infile); - - if (!image_data) { - fprintf(stderr, PROGNAME ": unable to decode PNG image\n"); - exit(3); - } - - - /* display image (composite with background if requested) */ - - Trace((stderr, "calling rpng_win_display_image()\n")) - if (rpng_win_display_image()) { - free(image_data); - exit(4); - } - Trace((stderr, "done with rpng_win_display_image()\n")) - - - /* wait for the user to tell us when to quit */ - - printf( - "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); - fflush(stdout); - - while (GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - - /* OK, we're done: clean up all image and Windows resources and go away */ - - rpng_win_cleanup(); - - return msg.wParam; -} - - - - - -static int rpng_win_create_window(HINSTANCE hInst, int showmode) -{ - uch *dest; - int extra_width, extra_height; - ulg i, j; - WNDCLASSEX wndclass; - - -/*--------------------------------------------------------------------------- - Allocate memory for the display-specific version of the image (round up - to multiple of 4 for Windows DIB). - ---------------------------------------------------------------------------*/ - - wimage_rowbytes = ((3*image_width + 3L) >> 2) << 2; - - if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) + - wimage_rowbytes*image_height))) - { - return 4; /* fail */ - } - -/*--------------------------------------------------------------------------- - Initialize the DIB. Negative height means to use top-down BMP ordering - (must be uncompressed, but that's what we want). Bit count of 1, 4 or 8 - implies a colormap of RGBX quads, but 24-bit BMPs just use B,G,R values - directly => wimage_data begins immediately after BMP header. - ---------------------------------------------------------------------------*/ - - memset(dib, 0, sizeof(BITMAPINFOHEADER)); - bmih = (BITMAPINFOHEADER *)dib; - bmih->biSize = sizeof(BITMAPINFOHEADER); - bmih->biWidth = image_width; - bmih->biHeight = -((long)image_height); - bmih->biPlanes = 1; - bmih->biBitCount = 24; - bmih->biCompression = 0; - wimage_data = dib + sizeof(BITMAPINFOHEADER); - -/*--------------------------------------------------------------------------- - Fill in background color (black by default); data are in BGR order. - ---------------------------------------------------------------------------*/ - - for (j = 0; j < image_height; ++j) { - dest = wimage_data + j*wimage_rowbytes; - for (i = image_width; i > 0; --i) { - *dest++ = bg_blue; - *dest++ = bg_green; - *dest++ = bg_red; - } - } - -/*--------------------------------------------------------------------------- - Set the window parameters. - ---------------------------------------------------------------------------*/ - - memset(&wndclass, 0, sizeof(wndclass)); - - wndclass.cbSize = sizeof(wndclass); - wndclass.style = CS_HREDRAW | CS_VREDRAW; - wndclass.lpfnWndProc = rpng_win_wndproc; - wndclass.hInstance = hInst; - wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); - wndclass.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH); - wndclass.lpszMenuName = NULL; - wndclass.lpszClassName = progname; - wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); - - RegisterClassEx(&wndclass); - -/*--------------------------------------------------------------------------- - Finally, create the window. - ---------------------------------------------------------------------------*/ - - extra_width = 2*(GetSystemMetrics(SM_CXBORDER) + - GetSystemMetrics(SM_CXDLGFRAME)); - extra_height = 2*(GetSystemMetrics(SM_CYBORDER) + - GetSystemMetrics(SM_CYDLGFRAME)) + - GetSystemMetrics(SM_CYCAPTION); - - global_hwnd = CreateWindow(progname, titlebar, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, image_width+extra_width, - image_height+extra_height, NULL, NULL, hInst, NULL); - - ShowWindow(global_hwnd, showmode); - UpdateWindow(global_hwnd); - - return 0; - -} /* end function rpng_win_create_window() */ - - - - - -static int rpng_win_display_image() -{ - uch *src, *dest; - uch r, g, b, a; - ulg i, row, lastrow; - RECT rect; - - - Trace((stderr, "beginning display loop (image_channels == %d)\n", - image_channels)) - Trace((stderr, "(width = %ld, rowbytes = %ld, wimage_rowbytes = %d)\n", - image_width, image_rowbytes, wimage_rowbytes)) - - -/*--------------------------------------------------------------------------- - Blast image data to buffer. This whole routine takes place before the - message loop begins, so there's no real point in any pseudo-progressive - display... - ---------------------------------------------------------------------------*/ - - for (lastrow = row = 0; row < image_height; ++row) { - src = image_data + row*image_rowbytes; - dest = wimage_data + row*wimage_rowbytes; - if (image_channels == 3) { - for (i = image_width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - *dest++ = b; - *dest++ = g; /* note reverse order */ - *dest++ = r; - } - } else /* if (image_channels == 4) */ { - for (i = image_width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - a = *src++; - if (a == 255) { - *dest++ = b; - *dest++ = g; - *dest++ = r; - } else if (a == 0) { - *dest++ = bg_blue; - *dest++ = bg_green; - *dest++ = bg_red; - } else { - /* this macro (copied from png.h) composites the - * foreground and background values and puts the - * result into the first argument; there are no - * side effects with the first argument */ - alpha_composite(*dest++, b, a, bg_blue); - alpha_composite(*dest++, g, a, bg_green); - alpha_composite(*dest++, r, a, bg_red); - } - } - } - /* display after every 16 lines */ - if (((row+1) & 0xf) == 0) { - rect.left = 0L; - rect.top = (LONG)lastrow; - rect.right = (LONG)image_width; /* possibly off by one? */ - rect.bottom = (LONG)lastrow + 16L; /* possibly off by one? */ - InvalidateRect(global_hwnd, &rect, FALSE); - UpdateWindow(global_hwnd); /* similar to XFlush() */ - lastrow = row + 1; - } - } - - Trace((stderr, "calling final image-flush routine\n")) - if (lastrow < image_height) { - rect.left = 0L; - rect.top = (LONG)lastrow; - rect.right = (LONG)image_width; /* possibly off by one? */ - rect.bottom = (LONG)image_height; /* possibly off by one? */ - InvalidateRect(global_hwnd, &rect, FALSE); - UpdateWindow(global_hwnd); /* similar to XFlush() */ - } - -/* - last param determines whether or not background is wiped before paint - InvalidateRect(global_hwnd, NULL, TRUE); - UpdateWindow(global_hwnd); - */ - - return 0; -} - - - - - -static void rpng_win_cleanup() -{ - if (image_data) { - free(image_data); - image_data = NULL; - } - - if (dib) { - free(dib); - dib = NULL; - } -} - - - - - -LRESULT CALLBACK rpng_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP) -{ - HDC hdc; - PAINTSTRUCT ps; - int rc; - - switch (iMsg) { - case WM_CREATE: - /* one-time processing here, if any */ - return 0; - - case WM_PAINT: - hdc = BeginPaint(hwnd, &ps); - /* dest */ - rc = StretchDIBits(hdc, 0, 0, image_width, image_height, - /* source */ - 0, 0, image_width, image_height, - wimage_data, (BITMAPINFO *)bmih, - /* iUsage: no clue */ - 0, SRCCOPY); - EndPaint(hwnd, &ps); - return 0; - - /* wait for the user to tell us when to quit */ - case WM_CHAR: - switch (wP) { /* only need one, so ignore repeat count */ - case 'q': - case 'Q': - case 0x1B: /* Esc key */ - PostQuitMessage(0); - } - return 0; - - case WM_LBUTTONDOWN: /* another way of quitting */ - case WM_DESTROY: - PostQuitMessage(0); - return 0; - } - - return DefWindowProc(hwnd, iMsg, wP, lP); -} +/*--------------------------------------------------------------------------- + + rpng - simple PNG display program rpng-win.c + + This program decodes and displays PNG images, with gamma correction and + optionally with a user-specified background color (in case the image has + transparency). It is very nearly the most basic PNG viewer possible. + This version is for 32-bit Windows; it may compile under 16-bit Windows + with a little tweaking (or maybe not). + + to do: + - handle quoted command-line args (especially filenames with spaces) + - have minimum window width: oh well + - use %.1023s to simplify truncation of title-bar string? + + --------------------------------------------------------------------------- + + Changelog: + - 1.00: initial public release + - 1.01: modified to allow abbreviated options; fixed long/ulong mis- + match; switched to png_jmpbuf() macro + - 1.02: added extra set of parentheses to png_jmpbuf() macro; fixed + command-line parsing bug + - 1.10: enabled "message window"/console (thanks to David Geldreich) + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + ---------------------------------------------------------------------------*/ + +#define PROGNAME "rpng-win" +#define LONGNAME "Simple PNG Viewer for Windows" +#define VERSION "1.20 of 28 May 2001" + +#include +#include +#include +#include +#include +#include /* only for _getch() */ + +/* #define DEBUG : this enables the Trace() macros */ + +#include "readpng.h" /* typedefs, common macros, readpng prototypes */ + + +/* could just include png.h, but this macro is the only thing we need + * (name and typedefs changed to local versions); note that side effects + * only happen with alpha (which could easily be avoided with + * "ush acopy = (alpha);") */ + +#define alpha_composite(composite, fg, alpha, bg) { \ + ush temp = ((ush)(fg)*(ush)(alpha) + \ + (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \ + (composite) = (uch)((temp + (temp >> 8)) >> 8); \ +} + + +/* local prototypes */ +static int rpng_win_create_window(HINSTANCE hInst, int showmode); +static int rpng_win_display_image(void); +static void rpng_win_cleanup(void); +LRESULT CALLBACK rpng_win_wndproc(HWND, UINT, WPARAM, LPARAM); + + +static char titlebar[1024], *window_name = titlebar; +static char *progname = PROGNAME; +static char *appname = LONGNAME; +static char *icon_name = PROGNAME; /* GRR: not (yet) used */ +static char *filename; +static FILE *infile; + +static char *bgstr; +static uch bg_red=0, bg_green=0, bg_blue=0; + +static double display_exponent; + +static ulg image_width, image_height, image_rowbytes; +static int image_channels; +static uch *image_data; + +/* Windows-specific variables */ +static ulg wimage_rowbytes; +static uch *dib; +static uch *wimage_data; +static BITMAPINFOHEADER *bmih; + +static HWND global_hwnd; + + + + +int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) +{ + char *args[1024]; /* arbitrary limit, but should suffice */ + char *p, *q, **argv = args; + int argc = 0; + int rc, alen, flen; + int error = 0; + int have_bg = FALSE; + double LUT_exponent; /* just the lookup table */ + double CRT_exponent = 2.2; /* just the monitor */ + double default_display_exponent; /* whole display system */ + MSG msg; + + + filename = (char *)NULL; + + + /* First reenable console output, which normally goes to the bit bucket + * for windowed apps. Closing the console window will terminate the + * app. Thanks to David.Geldreich@realviz.com for supplying the magical + * incantation. */ + + AllocConsole(); + freopen("CONOUT$", "a", stderr); + freopen("CONOUT$", "a", stdout); + + + /* Next set the default value for our display-system exponent, i.e., + * the product of the CRT exponent and the exponent corresponding to + * the frame-buffer's lookup table (LUT), if any. This is not an + * exhaustive list of LUT values (e.g., OpenStep has a lot of weird + * ones), but it should cover 99% of the current possibilities. And + * yes, these ifdefs are completely wasted in a Windows program... */ + +#if defined(NeXT) + LUT_exponent = 1.0 / 2.2; + /* + if (some_next_function_that_returns_gamma(&next_gamma)) + LUT_exponent = 1.0 / next_gamma; + */ +#elif defined(sgi) + LUT_exponent = 1.0 / 1.7; + /* there doesn't seem to be any documented function to get the + * "gamma" value, so we do it the hard way */ + infile = fopen("/etc/config/system.glGammaVal", "r"); + if (infile) { + double sgi_gamma; + + fgets(tmpline, 80, infile); + fclose(infile); + sgi_gamma = atof(tmpline); + if (sgi_gamma > 0.0) + LUT_exponent = 1.0 / sgi_gamma; + } +#elif defined(Macintosh) + LUT_exponent = 1.8 / 2.61; + /* + if (some_mac_function_that_returns_gamma(&mac_gamma)) + LUT_exponent = mac_gamma / 2.61; + */ +#else + LUT_exponent = 1.0; /* assume no LUT: most PCs */ +#endif + + /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ + default_display_exponent = LUT_exponent * CRT_exponent; + + + /* If the user has set the SCREEN_GAMMA environment variable as suggested + * (somewhat imprecisely) in the libpng documentation, use that; otherwise + * use the default value we just calculated. Either way, the user may + * override this via a command-line option. */ + + if ((p = getenv("SCREEN_GAMMA")) != NULL) + display_exponent = atof(p); + else + display_exponent = default_display_exponent; + + + /* Windows really hates command lines, so we have to set up our own argv. + * Note that we do NOT bother with quoted arguments here, so don't use + * filenames with spaces in 'em! */ + + argv[argc++] = PROGNAME; + p = cmd; + for (;;) { + if (*p == ' ') + while (*++p == ' ') + ; + /* now p points at the first non-space after some spaces */ + if (*p == '\0') + break; /* nothing after the spaces: done */ + argv[argc++] = q = p; + while (*q && *q != ' ') + ++q; + /* now q points at a space or the end of the string */ + if (*q == '\0') + break; /* last argv already terminated; quit */ + *q = '\0'; /* change space to terminator */ + p = q + 1; + } + argv[argc] = NULL; /* terminate the argv array itself */ + + + /* Now parse the command line for options and the PNG filename. */ + + while (*++argv && !error) { + if (!strncmp(*argv, "-gamma", 2)) { + if (!*++argv) + ++error; + else { + display_exponent = atof(*argv); + if (display_exponent <= 0.0) + ++error; + } + } else if (!strncmp(*argv, "-bgcolor", 2)) { + if (!*++argv) + ++error; + else { + bgstr = *argv; + if (strlen(bgstr) != 7 || bgstr[0] != '#') + ++error; + else + have_bg = TRUE; + } + } else { + if (**argv != '-') { + filename = *argv; + if (argv[1]) /* shouldn't be any more args after filename */ + ++error; + } else + ++error; /* not expecting any other options */ + } + } + + if (!filename) { + ++error; + } else if (!(infile = fopen(filename, "rb"))) { + fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); + ++error; + } else { + if ((rc = readpng_init(infile, &image_width, &image_height)) != 0) { + switch (rc) { + case 1: + fprintf(stderr, PROGNAME + ": [%s] is not a PNG file: incorrect signature\n", + filename); + break; + case 2: + fprintf(stderr, PROGNAME + ": [%s] has bad IHDR (libpng longjmp)\n", + filename); + break; + case 4: + fprintf(stderr, PROGNAME ": insufficient memory\n"); + break; + default: + fprintf(stderr, PROGNAME + ": unknown readpng_init() error\n"); + break; + } + ++error; + } + if (error) + fclose(infile); + } + + + /* usage screen */ + + if (error) { + int ch; + + fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); + readpng_version_info(); + fprintf(stderr, "\n" + "Usage: %s [-gamma exp] [-bgcolor bg] file.png\n" + " exp \ttransfer-function exponent (``gamma'') of the display\n" + "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" + "\t\t to the product of the lookup-table exponent (varies)\n" + "\t\t and the CRT exponent (usually 2.2); must be positive\n" + " bg \tdesired background color in 7-character hex RGB format\n" + "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" + "\t\t used with transparent images\n" + "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" + "Press Q or Esc to quit this usage screen.\n" + "\n", PROGNAME, default_display_exponent); + do + ch = _getch(); + while (ch != 'q' && ch != 'Q' && ch != 0x1B); + exit(1); + } else { + fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); + fprintf(stderr, + "\n [console window: closing this window will terminate %s]\n\n", + PROGNAME); + } + + + /* set the title-bar string, but make sure buffer doesn't overflow */ + + alen = strlen(appname); + flen = strlen(filename); + if (alen + flen + 3 > 1023) + sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); + else + sprintf(titlebar, "%s: %s", appname, filename); + + + /* if the user didn't specify a background color on the command line, + * check for one in the PNG file--if not, the initialized values of 0 + * (black) will be used */ + + if (have_bg) + sscanf(bgstr+1, "%2x%2x%2x", &bg_red, &bg_green, &bg_blue); + else if (readpng_get_bgcolor(&bg_red, &bg_green, &bg_blue) > 1) { + readpng_cleanup(TRUE); + fprintf(stderr, PROGNAME + ": libpng error while checking for background color\n"); + exit(2); + } + + + /* do the basic Windows initialization stuff, make the window and fill it + * with the background color */ + + if (rpng_win_create_window(hInst, showmode)) + exit(2); + + + /* decode the image, all at once */ + + Trace((stderr, "calling readpng_get_image()\n")) + image_data = readpng_get_image(display_exponent, &image_channels, + &image_rowbytes); + Trace((stderr, "done with readpng_get_image()\n")) + + + /* done with PNG file, so clean up to minimize memory usage (but do NOT + * nuke image_data!) */ + + readpng_cleanup(FALSE); + fclose(infile); + + if (!image_data) { + fprintf(stderr, PROGNAME ": unable to decode PNG image\n"); + exit(3); + } + + + /* display image (composite with background if requested) */ + + Trace((stderr, "calling rpng_win_display_image()\n")) + if (rpng_win_display_image()) { + free(image_data); + exit(4); + } + Trace((stderr, "done with rpng_win_display_image()\n")) + + + /* wait for the user to tell us when to quit */ + + printf( + "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); + fflush(stdout); + + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + + /* OK, we're done: clean up all image and Windows resources and go away */ + + rpng_win_cleanup(); + + return msg.wParam; +} + + + + + +static int rpng_win_create_window(HINSTANCE hInst, int showmode) +{ + uch *dest; + int extra_width, extra_height; + ulg i, j; + WNDCLASSEX wndclass; + + +/*--------------------------------------------------------------------------- + Allocate memory for the display-specific version of the image (round up + to multiple of 4 for Windows DIB). + ---------------------------------------------------------------------------*/ + + wimage_rowbytes = ((3*image_width + 3L) >> 2) << 2; + + if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) + + wimage_rowbytes*image_height))) + { + return 4; /* fail */ + } + +/*--------------------------------------------------------------------------- + Initialize the DIB. Negative height means to use top-down BMP ordering + (must be uncompressed, but that's what we want). Bit count of 1, 4 or 8 + implies a colormap of RGBX quads, but 24-bit BMPs just use B,G,R values + directly => wimage_data begins immediately after BMP header. + ---------------------------------------------------------------------------*/ + + memset(dib, 0, sizeof(BITMAPINFOHEADER)); + bmih = (BITMAPINFOHEADER *)dib; + bmih->biSize = sizeof(BITMAPINFOHEADER); + bmih->biWidth = image_width; + bmih->biHeight = -((long)image_height); + bmih->biPlanes = 1; + bmih->biBitCount = 24; + bmih->biCompression = 0; + wimage_data = dib + sizeof(BITMAPINFOHEADER); + +/*--------------------------------------------------------------------------- + Fill in background color (black by default); data are in BGR order. + ---------------------------------------------------------------------------*/ + + for (j = 0; j < image_height; ++j) { + dest = wimage_data + j*wimage_rowbytes; + for (i = image_width; i > 0; --i) { + *dest++ = bg_blue; + *dest++ = bg_green; + *dest++ = bg_red; + } + } + +/*--------------------------------------------------------------------------- + Set the window parameters. + ---------------------------------------------------------------------------*/ + + memset(&wndclass, 0, sizeof(wndclass)); + + wndclass.cbSize = sizeof(wndclass); + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = rpng_win_wndproc; + wndclass.hInstance = hInst; + wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH); + wndclass.lpszMenuName = NULL; + wndclass.lpszClassName = progname; + wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + + RegisterClassEx(&wndclass); + +/*--------------------------------------------------------------------------- + Finally, create the window. + ---------------------------------------------------------------------------*/ + + extra_width = 2*(GetSystemMetrics(SM_CXBORDER) + + GetSystemMetrics(SM_CXDLGFRAME)); + extra_height = 2*(GetSystemMetrics(SM_CYBORDER) + + GetSystemMetrics(SM_CYDLGFRAME)) + + GetSystemMetrics(SM_CYCAPTION); + + global_hwnd = CreateWindow(progname, titlebar, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, image_width+extra_width, + image_height+extra_height, NULL, NULL, hInst, NULL); + + ShowWindow(global_hwnd, showmode); + UpdateWindow(global_hwnd); + + return 0; + +} /* end function rpng_win_create_window() */ + + + + + +static int rpng_win_display_image() +{ + uch *src, *dest; + uch r, g, b, a; + ulg i, row, lastrow; + RECT rect; + + + Trace((stderr, "beginning display loop (image_channels == %d)\n", + image_channels)) + Trace((stderr, "(width = %ld, rowbytes = %ld, wimage_rowbytes = %d)\n", + image_width, image_rowbytes, wimage_rowbytes)) + + +/*--------------------------------------------------------------------------- + Blast image data to buffer. This whole routine takes place before the + message loop begins, so there's no real point in any pseudo-progressive + display... + ---------------------------------------------------------------------------*/ + + for (lastrow = row = 0; row < image_height; ++row) { + src = image_data + row*image_rowbytes; + dest = wimage_data + row*wimage_rowbytes; + if (image_channels == 3) { + for (i = image_width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + *dest++ = b; + *dest++ = g; /* note reverse order */ + *dest++ = r; + } + } else /* if (image_channels == 4) */ { + for (i = image_width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + a = *src++; + if (a == 255) { + *dest++ = b; + *dest++ = g; + *dest++ = r; + } else if (a == 0) { + *dest++ = bg_blue; + *dest++ = bg_green; + *dest++ = bg_red; + } else { + /* this macro (copied from png.h) composites the + * foreground and background values and puts the + * result into the first argument; there are no + * side effects with the first argument */ + alpha_composite(*dest++, b, a, bg_blue); + alpha_composite(*dest++, g, a, bg_green); + alpha_composite(*dest++, r, a, bg_red); + } + } + } + /* display after every 16 lines */ + if (((row+1) & 0xf) == 0) { + rect.left = 0L; + rect.top = (LONG)lastrow; + rect.right = (LONG)image_width; /* possibly off by one? */ + rect.bottom = (LONG)lastrow + 16L; /* possibly off by one? */ + InvalidateRect(global_hwnd, &rect, FALSE); + UpdateWindow(global_hwnd); /* similar to XFlush() */ + lastrow = row + 1; + } + } + + Trace((stderr, "calling final image-flush routine\n")) + if (lastrow < image_height) { + rect.left = 0L; + rect.top = (LONG)lastrow; + rect.right = (LONG)image_width; /* possibly off by one? */ + rect.bottom = (LONG)image_height; /* possibly off by one? */ + InvalidateRect(global_hwnd, &rect, FALSE); + UpdateWindow(global_hwnd); /* similar to XFlush() */ + } + +/* + last param determines whether or not background is wiped before paint + InvalidateRect(global_hwnd, NULL, TRUE); + UpdateWindow(global_hwnd); + */ + + return 0; +} + + + + + +static void rpng_win_cleanup() +{ + if (image_data) { + free(image_data); + image_data = NULL; + } + + if (dib) { + free(dib); + dib = NULL; + } +} + + + + + +LRESULT CALLBACK rpng_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP) +{ + HDC hdc; + PAINTSTRUCT ps; + int rc; + + switch (iMsg) { + case WM_CREATE: + /* one-time processing here, if any */ + return 0; + + case WM_PAINT: + hdc = BeginPaint(hwnd, &ps); + /* dest */ + rc = StretchDIBits(hdc, 0, 0, image_width, image_height, + /* source */ + 0, 0, image_width, image_height, + wimage_data, (BITMAPINFO *)bmih, + /* iUsage: no clue */ + 0, SRCCOPY); + EndPaint(hwnd, &ps); + return 0; + + /* wait for the user to tell us when to quit */ + case WM_CHAR: + switch (wP) { /* only need one, so ignore repeat count */ + case 'q': + case 'Q': + case 0x1B: /* Esc key */ + PostQuitMessage(0); + } + return 0; + + case WM_LBUTTONDOWN: /* another way of quitting */ + case WM_DESTROY: + PostQuitMessage(0); + return 0; + } + + return DefWindowProc(hwnd, iMsg, wP, lP); +} diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng-x.c b/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng-x.c index 0623397..e787ef1 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng-x.c +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng-x.c @@ -1,858 +1,858 @@ -/*--------------------------------------------------------------------------- - - rpng - simple PNG display program rpng-x.c - - This program decodes and displays PNG images, with gamma correction and - optionally with a user-specified background color (in case the image has - transparency). It is very nearly the most basic PNG viewer possible. - This version is for the X Window System (tested by author under Unix and - by Martin Zinser under OpenVMS; may work under OS/2 with some tweaking). - - to do: - - 8-bit support - - use %.1023s to simplify truncation of title-bar string? - - --------------------------------------------------------------------------- - - Changelog: - - 1.01: initial public release - - 1.02: modified to allow abbreviated options; fixed long/ulong mis- - match; switched to png_jmpbuf() macro - - 1.10: added support for non-default visuals; fixed X pixel-conversion - - 1.11: added extra set of parentheses to png_jmpbuf() macro; fixed - command-line parsing bug - - 1.12: fixed small X memory leak (thanks to Francois Petitjean) - - 1.13: fixed XFreeGC() crash bug - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#define PROGNAME "rpng-x" -#define LONGNAME "Simple PNG Viewer for X" -#define VERSION "1.13 of 16 August 2001" - -#include -#include -#include -#include -#include -#include -#include -#include - -/* #define DEBUG : this enables the Trace() macros */ - -#include "readpng.h" /* typedefs, common macros, readpng prototypes */ - - -/* could just include png.h, but this macro is the only thing we need - * (name and typedefs changed to local versions); note that side effects - * only happen with alpha (which could easily be avoided with - * "ush acopy = (alpha);") */ - -#define alpha_composite(composite, fg, alpha, bg) { \ - ush temp = ((ush)(fg)*(ush)(alpha) + \ - (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \ - (composite) = (uch)((temp + (temp >> 8)) >> 8); \ -} - - -/* local prototypes */ -static int rpng_x_create_window(void); -static int rpng_x_display_image(void); -static void rpng_x_cleanup(void); -static int rpng_x_msb(ulg u32val); - - -static char titlebar[1024], *window_name = titlebar; -static char *appname = LONGNAME; -static char *icon_name = PROGNAME; -static char *filename; -static FILE *infile; - -static char *bgstr; -static uch bg_red=0, bg_green=0, bg_blue=0; - -static double display_exponent; - -static ulg image_width, image_height, image_rowbytes; -static int image_channels; -static uch *image_data; - -/* X-specific variables */ -static char *displayname; -static XImage *ximage; -static Display *display; -static int depth; -static Visual *visual; -static XVisualInfo *visual_list; -static int RShift, GShift, BShift; -static ulg RMask, GMask, BMask; -static Window window; -static GC gc; -static Colormap colormap; - -static int have_nondefault_visual = FALSE; -static int have_colormap = FALSE; -static int have_window = FALSE; -static int have_gc = FALSE; -/* -ulg numcolors=0, pixels[256]; -ush reds[256], greens[256], blues[256]; - */ - - - - -int main(int argc, char **argv) -{ -#ifdef sgi - char tmpline[80]; -#endif - char *p; - int rc, alen, flen; - int error = 0; - int have_bg = FALSE; - double LUT_exponent; /* just the lookup table */ - double CRT_exponent = 2.2; /* just the monitor */ - double default_display_exponent; /* whole display system */ - XEvent e; - KeySym k; - - - displayname = (char *)NULL; - filename = (char *)NULL; - - - /* First set the default value for our display-system exponent, i.e., - * the product of the CRT exponent and the exponent corresponding to - * the frame-buffer's lookup table (LUT), if any. This is not an - * exhaustive list of LUT values (e.g., OpenStep has a lot of weird - * ones), but it should cover 99% of the current possibilities. */ - -#if defined(NeXT) - LUT_exponent = 1.0 / 2.2; - /* - if (some_next_function_that_returns_gamma(&next_gamma)) - LUT_exponent = 1.0 / next_gamma; - */ -#elif defined(sgi) - LUT_exponent = 1.0 / 1.7; - /* there doesn't seem to be any documented function to get the - * "gamma" value, so we do it the hard way */ - infile = fopen("/etc/config/system.glGammaVal", "r"); - if (infile) { - double sgi_gamma; - - fgets(tmpline, 80, infile); - fclose(infile); - sgi_gamma = atof(tmpline); - if (sgi_gamma > 0.0) - LUT_exponent = 1.0 / sgi_gamma; - } -#elif defined(Macintosh) - LUT_exponent = 1.8 / 2.61; - /* - if (some_mac_function_that_returns_gamma(&mac_gamma)) - LUT_exponent = mac_gamma / 2.61; - */ -#else - LUT_exponent = 1.0; /* assume no LUT: most PCs */ -#endif - - /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ - default_display_exponent = LUT_exponent * CRT_exponent; - - - /* If the user has set the SCREEN_GAMMA environment variable as suggested - * (somewhat imprecisely) in the libpng documentation, use that; otherwise - * use the default value we just calculated. Either way, the user may - * override this via a command-line option. */ - - if ((p = getenv("SCREEN_GAMMA")) != NULL) - display_exponent = atof(p); - else - display_exponent = default_display_exponent; - - - /* Now parse the command line for options and the PNG filename. */ - - while (*++argv && !error) { - if (!strncmp(*argv, "-display", 2)) { - if (!*++argv) - ++error; - else - displayname = *argv; - } else if (!strncmp(*argv, "-gamma", 2)) { - if (!*++argv) - ++error; - else { - display_exponent = atof(*argv); - if (display_exponent <= 0.0) - ++error; - } - } else if (!strncmp(*argv, "-bgcolor", 2)) { - if (!*++argv) - ++error; - else { - bgstr = *argv; - if (strlen(bgstr) != 7 || bgstr[0] != '#') - ++error; - else - have_bg = TRUE; - } - } else { - if (**argv != '-') { - filename = *argv; - if (argv[1]) /* shouldn't be any more args after filename */ - ++error; - } else - ++error; /* not expecting any other options */ - } - } - - if (!filename) { - ++error; - } else if (!(infile = fopen(filename, "rb"))) { - fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); - ++error; - } else { - if ((rc = readpng_init(infile, &image_width, &image_height)) != 0) { - switch (rc) { - case 1: - fprintf(stderr, PROGNAME - ": [%s] is not a PNG file: incorrect signature\n", - filename); - break; - case 2: - fprintf(stderr, PROGNAME - ": [%s] has bad IHDR (libpng longjmp)\n", - filename); - break; - case 4: - fprintf(stderr, PROGNAME ": insufficient memory\n"); - break; - default: - fprintf(stderr, PROGNAME - ": unknown readpng_init() error\n"); - break; - } - ++error; - } else { - display = XOpenDisplay(displayname); - if (!display) { - readpng_cleanup(TRUE); - fprintf(stderr, PROGNAME ": can't open X display [%s]\n", - displayname? displayname : "default"); - ++error; - } - } - if (error) - fclose(infile); - } - - - /* usage screen */ - - if (error) { - fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); - readpng_version_info(); - fprintf(stderr, "\n" - "Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n" - " xdpy\tname of the target X display (e.g., ``hostname:0'')\n" - " exp \ttransfer-function exponent (``gamma'') of the display\n" - "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" - "\t\t to the product of the lookup-table exponent (varies)\n" - "\t\t and the CRT exponent (usually 2.2); must be positive\n" - " bg \tdesired background color in 7-character hex RGB format\n" - "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" - "\t\t used with transparent images\n" - "\nPress Q, Esc or mouse button 1 (within image window, after image\n" - "is displayed) to quit.\n" - "\n", PROGNAME, default_display_exponent); - exit(1); - } - - - /* set the title-bar string, but make sure buffer doesn't overflow */ - - alen = strlen(appname); - flen = strlen(filename); - if (alen + flen + 3 > 1023) - sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); - else - sprintf(titlebar, "%s: %s", appname, filename); - - - /* if the user didn't specify a background color on the command line, - * check for one in the PNG file--if not, the initialized values of 0 - * (black) will be used */ - - if (have_bg) { - unsigned r, g, b; /* this approach quiets compiler warnings */ - - sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); - bg_red = (uch)r; - bg_green = (uch)g; - bg_blue = (uch)b; - } else if (readpng_get_bgcolor(&bg_red, &bg_green, &bg_blue) > 1) { - readpng_cleanup(TRUE); - fprintf(stderr, PROGNAME - ": libpng error while checking for background color\n"); - exit(2); - } - - - /* do the basic X initialization stuff, make the window and fill it - * with the background color */ - - if (rpng_x_create_window()) - exit(2); - - - /* decode the image, all at once */ - - Trace((stderr, "calling readpng_get_image()\n")) - image_data = readpng_get_image(display_exponent, &image_channels, - &image_rowbytes); - Trace((stderr, "done with readpng_get_image()\n")) - - - /* done with PNG file, so clean up to minimize memory usage (but do NOT - * nuke image_data!) */ - - readpng_cleanup(FALSE); - fclose(infile); - - if (!image_data) { - fprintf(stderr, PROGNAME ": unable to decode PNG image\n"); - exit(3); - } - - - /* display image (composite with background if requested) */ - - Trace((stderr, "calling rpng_x_display_image()\n")) - if (rpng_x_display_image()) { - free(image_data); - exit(4); - } - Trace((stderr, "done with rpng_x_display_image()\n")) - - - /* wait for the user to tell us when to quit */ - - printf( - "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); - fflush(stdout); - - do - XNextEvent(display, &e); - while (!(e.type == ButtonPress && e.xbutton.button == Button1) && - !(e.type == KeyPress && /* v--- or 1 for shifted keys */ - ((k = XLookupKeysym(&e.xkey, 0)) == XK_q || k == XK_Escape) )); - - - /* OK, we're done: clean up all image and X resources and go away */ - - rpng_x_cleanup(); - - return 0; -} - - - - - -static int rpng_x_create_window(void) -{ - uch *xdata; - int need_colormap = FALSE; - int screen, pad; - ulg bg_pixel = 0L; - ulg attrmask; - Window root; - XEvent e; - XGCValues gcvalues; - XSetWindowAttributes attr; - XSizeHints *size_hints; - XTextProperty windowName, *pWindowName = &windowName; - XTextProperty iconName, *pIconName = &iconName; - XVisualInfo visual_info; - XWMHints *wm_hints; - - - screen = DefaultScreen(display); - depth = DisplayPlanes(display, screen); - root = RootWindow(display, screen); - -#ifdef DEBUG - XSynchronize(display, True); -#endif - -#if 0 -/* GRR: add 8-bit support */ - if (/* depth != 8 && */ depth != 16 && depth != 24 && depth != 32) { - fprintf(stderr, - "screen depth %d not supported (only 16-, 24- or 32-bit TrueColor)\n", - depth); - return 2; - } - - XMatchVisualInfo(display, screen, depth, - (depth == 8)? PseudoColor : TrueColor, &visual_info); - visual = visual_info.visual; -#else - if (depth != 16 && depth != 24 && depth != 32) { - int visuals_matched = 0; - - Trace((stderr, "default depth is %d: checking other visuals\n", - depth)) - - /* 24-bit first */ - visual_info.screen = screen; - visual_info.depth = 24; - visual_list = XGetVisualInfo(display, - VisualScreenMask | VisualDepthMask, &visual_info, &visuals_matched); - if (visuals_matched == 0) { -/* GRR: add 15-, 16- and 32-bit TrueColor visuals (also DirectColor?) */ - fprintf(stderr, "default screen depth %d not supported, and no" - " 24-bit visuals found\n", depth); - return 2; - } - Trace((stderr, "XGetVisualInfo() returned %d 24-bit visuals\n", - visuals_matched)) - visual = visual_list[0].visual; - depth = visual_list[0].depth; -/* - colormap_size = visual_list[0].colormap_size; - visual_class = visual->class; - visualID = XVisualIDFromVisual(visual); - */ - have_nondefault_visual = TRUE; - need_colormap = TRUE; - } else { - XMatchVisualInfo(display, screen, depth, TrueColor, &visual_info); - visual = visual_info.visual; - } -#endif - - RMask = visual->red_mask; - GMask = visual->green_mask; - BMask = visual->blue_mask; - -/* GRR: add/check 8-bit support */ - if (depth == 8 || need_colormap) { - colormap = XCreateColormap(display, root, visual, AllocNone); - if (!colormap) { - fprintf(stderr, "XCreateColormap() failed\n"); - return 2; - } - have_colormap = TRUE; - } - if (depth == 15 || depth == 16) { - RShift = 15 - rpng_x_msb(RMask); /* these are right-shifts */ - GShift = 15 - rpng_x_msb(GMask); - BShift = 15 - rpng_x_msb(BMask); - } else if (depth > 16) { -#define NO_24BIT_MASKS -#ifdef NO_24BIT_MASKS - RShift = rpng_x_msb(RMask) - 7; /* these are left-shifts */ - GShift = rpng_x_msb(GMask) - 7; - BShift = rpng_x_msb(BMask) - 7; -#else - RShift = 7 - rpng_x_msb(RMask); /* these are right-shifts, too */ - GShift = 7 - rpng_x_msb(GMask); - BShift = 7 - rpng_x_msb(BMask); -#endif - } - if (depth >= 15 && (RShift < 0 || GShift < 0 || BShift < 0)) { - fprintf(stderr, "rpng internal logic error: negative X shift(s)!\n"); - return 2; - } - -/*--------------------------------------------------------------------------- - Finally, create the window. - ---------------------------------------------------------------------------*/ - - attr.backing_store = Always; - attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask; - attrmask = CWBackingStore | CWEventMask; - if (have_nondefault_visual) { - attr.colormap = colormap; - attr.background_pixel = 0; - attr.border_pixel = 1; - attrmask |= CWColormap | CWBackPixel | CWBorderPixel; - } - - window = XCreateWindow(display, root, 0, 0, image_width, image_height, 0, - depth, InputOutput, visual, attrmask, &attr); - - if (window == None) { - fprintf(stderr, "XCreateWindow() failed\n"); - return 2; - } else - have_window = TRUE; - - if (depth == 8) - XSetWindowColormap(display, window, colormap); - - if (!XStringListToTextProperty(&window_name, 1, pWindowName)) - pWindowName = NULL; - if (!XStringListToTextProperty(&icon_name, 1, pIconName)) - pIconName = NULL; - - /* OK if either hints allocation fails; XSetWMProperties() allows NULLs */ - - if ((size_hints = XAllocSizeHints()) != NULL) { - /* window will not be resizable */ - size_hints->flags = PMinSize | PMaxSize; - size_hints->min_width = size_hints->max_width = (int)image_width; - size_hints->min_height = size_hints->max_height = (int)image_height; - } - - if ((wm_hints = XAllocWMHints()) != NULL) { - wm_hints->initial_state = NormalState; - wm_hints->input = True; - /* wm_hints->icon_pixmap = icon_pixmap; */ - wm_hints->flags = StateHint | InputHint /* | IconPixmapHint */ ; - } - - XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0, - size_hints, wm_hints, NULL); - - /* various properties and hints no longer needed; free memory */ - if (pWindowName) - XFree(pWindowName->value); - if (pIconName) - XFree(pIconName->value); - if (size_hints) - XFree(size_hints); - if (wm_hints) - XFree(wm_hints); - - XMapWindow(display, window); - - gc = XCreateGC(display, window, 0, &gcvalues); - have_gc = TRUE; - -/*--------------------------------------------------------------------------- - Fill window with the specified background color. - ---------------------------------------------------------------------------*/ - - if (depth == 24 || depth == 32) { - bg_pixel = ((ulg)bg_red << RShift) | - ((ulg)bg_green << GShift) | - ((ulg)bg_blue << BShift); - } else if (depth == 16) { - bg_pixel = ((((ulg)bg_red << 8) >> RShift) & RMask) | - ((((ulg)bg_green << 8) >> GShift) & GMask) | - ((((ulg)bg_blue << 8) >> BShift) & BMask); - } else /* depth == 8 */ { - - /* GRR: add 8-bit support */ - - } - - XSetForeground(display, gc, bg_pixel); - XFillRectangle(display, window, gc, 0, 0, image_width, image_height); - -/*--------------------------------------------------------------------------- - Wait for first Expose event to do any drawing, then flush. - ---------------------------------------------------------------------------*/ - - do - XNextEvent(display, &e); - while (e.type != Expose || e.xexpose.count); - - XFlush(display); - -/*--------------------------------------------------------------------------- - Allocate memory for the X- and display-specific version of the image. - ---------------------------------------------------------------------------*/ - - if (depth == 24 || depth == 32) { - xdata = (uch *)malloc(4*image_width*image_height); - pad = 32; - } else if (depth == 16) { - xdata = (uch *)malloc(2*image_width*image_height); - pad = 16; - } else /* depth == 8 */ { - xdata = (uch *)malloc(image_width*image_height); - pad = 8; - } - - if (!xdata) { - fprintf(stderr, PROGNAME ": unable to allocate image memory\n"); - return 4; - } - - ximage = XCreateImage(display, visual, depth, ZPixmap, 0, - (char *)xdata, image_width, image_height, pad, 0); - - if (!ximage) { - fprintf(stderr, PROGNAME ": XCreateImage() failed\n"); - free(xdata); - return 3; - } - - /* to avoid testing the byte order every pixel (or doubling the size of - * the drawing routine with a giant if-test), we arbitrarily set the byte - * order to MSBFirst and let Xlib worry about inverting things on little- - * endian machines (like Linux/x86, old VAXen, etc.)--this is not the most - * efficient approach (the giant if-test would be better), but in the - * interest of clarity, we take the easy way out... */ - - ximage->byte_order = MSBFirst; - - return 0; - -} /* end function rpng_x_create_window() */ - - - - - -static int rpng_x_display_image(void) -{ - uch *src; - char *dest; - uch r, g, b, a; - ulg i, row, lastrow = 0; - ulg pixel; - int ximage_rowbytes = ximage->bytes_per_line; -/* int bpp = ximage->bits_per_pixel; */ - - - Trace((stderr, "beginning display loop (image_channels == %d)\n", - image_channels)) - Trace((stderr, " (width = %ld, rowbytes = %ld, ximage_rowbytes = %d)\n", - image_width, image_rowbytes, ximage_rowbytes)) - Trace((stderr, " (bpp = %d)\n", ximage->bits_per_pixel)) - Trace((stderr, " (byte_order = %s)\n", ximage->byte_order == MSBFirst? - "MSBFirst" : (ximage->byte_order == LSBFirst? "LSBFirst" : "unknown"))) - - if (depth == 24 || depth == 32) { - ulg red, green, blue; - - for (lastrow = row = 0; row < image_height; ++row) { - src = image_data + row*image_rowbytes; - dest = ximage->data + row*ximage_rowbytes; - if (image_channels == 3) { - for (i = image_width; i > 0; --i) { - red = *src++; - green = *src++; - blue = *src++; -#ifdef NO_24BIT_MASKS - pixel = (red << RShift) | - (green << GShift) | - (blue << BShift); - /* recall that we set ximage->byte_order = MSBFirst above */ - /* GRR BUG: this assumes bpp == 32, but may be 24: */ - *dest++ = (char)((pixel >> 24) & 0xff); - *dest++ = (char)((pixel >> 16) & 0xff); - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); -#else - red = (RShift < 0)? red << (-RShift) : red >> RShift; - green = (GShift < 0)? green << (-GShift) : green >> GShift; - blue = (BShift < 0)? blue << (-BShift) : blue >> BShift; - pixel = (red & RMask) | (green & GMask) | (blue & BMask); - /* recall that we set ximage->byte_order = MSBFirst above */ - *dest++ = (char)((pixel >> 24) & 0xff); - *dest++ = (char)((pixel >> 16) & 0xff); - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); -#endif - } - } else /* if (image_channels == 4) */ { - for (i = image_width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - a = *src++; - if (a == 255) { - red = r; - green = g; - blue = b; - } else if (a == 0) { - red = bg_red; - green = bg_green; - blue = bg_blue; - } else { - /* this macro (from png.h) composites the foreground - * and background values and puts the result into the - * first argument */ - alpha_composite(red, r, a, bg_red); - alpha_composite(green, g, a, bg_green); - alpha_composite(blue, b, a, bg_blue); - } - pixel = (red << RShift) | - (green << GShift) | - (blue << BShift); - /* recall that we set ximage->byte_order = MSBFirst above */ - *dest++ = (char)((pixel >> 24) & 0xff); - *dest++ = (char)((pixel >> 16) & 0xff); - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } - /* display after every 16 lines */ - if (((row+1) & 0xf) == 0) { - XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, - (int)lastrow, image_width, 16); - XFlush(display); - lastrow = row + 1; - } - } - - } else if (depth == 16) { - ush red, green, blue; - - for (lastrow = row = 0; row < image_height; ++row) { - src = image_data + row*image_rowbytes; - dest = ximage->data + row*ximage_rowbytes; - if (image_channels == 3) { - for (i = image_width; i > 0; --i) { - red = ((ush)(*src) << 8); - ++src; - green = ((ush)(*src) << 8); - ++src; - blue = ((ush)(*src) << 8); - ++src; - pixel = ((red >> RShift) & RMask) | - ((green >> GShift) & GMask) | - ((blue >> BShift) & BMask); - /* recall that we set ximage->byte_order = MSBFirst above */ - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } else /* if (image_channels == 4) */ { - for (i = image_width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - a = *src++; - if (a == 255) { - red = ((ush)r << 8); - green = ((ush)g << 8); - blue = ((ush)b << 8); - } else if (a == 0) { - red = ((ush)bg_red << 8); - green = ((ush)bg_green << 8); - blue = ((ush)bg_blue << 8); - } else { - /* this macro (from png.h) composites the foreground - * and background values and puts the result back into - * the first argument (== fg byte here: safe) */ - alpha_composite(r, r, a, bg_red); - alpha_composite(g, g, a, bg_green); - alpha_composite(b, b, a, bg_blue); - red = ((ush)r << 8); - green = ((ush)g << 8); - blue = ((ush)b << 8); - } - pixel = ((red >> RShift) & RMask) | - ((green >> GShift) & GMask) | - ((blue >> BShift) & BMask); - /* recall that we set ximage->byte_order = MSBFirst above */ - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } - /* display after every 16 lines */ - if (((row+1) & 0xf) == 0) { - XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, - (int)lastrow, image_width, 16); - XFlush(display); - lastrow = row + 1; - } - } - - } else /* depth == 8 */ { - - /* GRR: add 8-bit support */ - - } - - Trace((stderr, "calling final XPutImage()\n")) - if (lastrow < image_height) { - XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, - (int)lastrow, image_width, image_height-lastrow); - XFlush(display); - } - - return 0; -} - - - - -static void rpng_x_cleanup(void) -{ - if (image_data) { - free(image_data); - image_data = NULL; - } - - if (ximage) { - if (ximage->data) { - free(ximage->data); /* we allocated it, so we free it */ - ximage->data = (char *)NULL; /* instead of XDestroyImage() */ - } - XDestroyImage(ximage); - ximage = NULL; - } - - if (have_gc) - XFreeGC(display, gc); - - if (have_window) - XDestroyWindow(display, window); - - if (have_colormap) - XFreeColormap(display, colormap); - - if (have_nondefault_visual) - XFree(visual_list); -} - - - - - -static int rpng_x_msb(ulg u32val) -{ - int i; - - for (i = 31; i >= 0; --i) { - if (u32val & 0x80000000L) - break; - u32val <<= 1; - } - return i; -} +/*--------------------------------------------------------------------------- + + rpng - simple PNG display program rpng-x.c + + This program decodes and displays PNG images, with gamma correction and + optionally with a user-specified background color (in case the image has + transparency). It is very nearly the most basic PNG viewer possible. + This version is for the X Window System (tested by author under Unix and + by Martin Zinser under OpenVMS; may work under OS/2 with some tweaking). + + to do: + - 8-bit support + - use %.1023s to simplify truncation of title-bar string? + + --------------------------------------------------------------------------- + + Changelog: + - 1.01: initial public release + - 1.02: modified to allow abbreviated options; fixed long/ulong mis- + match; switched to png_jmpbuf() macro + - 1.10: added support for non-default visuals; fixed X pixel-conversion + - 1.11: added extra set of parentheses to png_jmpbuf() macro; fixed + command-line parsing bug + - 1.12: fixed small X memory leak (thanks to Francois Petitjean) + - 1.13: fixed XFreeGC() crash bug + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + ---------------------------------------------------------------------------*/ + +#define PROGNAME "rpng-x" +#define LONGNAME "Simple PNG Viewer for X" +#define VERSION "1.13 of 16 August 2001" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* #define DEBUG : this enables the Trace() macros */ + +#include "readpng.h" /* typedefs, common macros, readpng prototypes */ + + +/* could just include png.h, but this macro is the only thing we need + * (name and typedefs changed to local versions); note that side effects + * only happen with alpha (which could easily be avoided with + * "ush acopy = (alpha);") */ + +#define alpha_composite(composite, fg, alpha, bg) { \ + ush temp = ((ush)(fg)*(ush)(alpha) + \ + (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \ + (composite) = (uch)((temp + (temp >> 8)) >> 8); \ +} + + +/* local prototypes */ +static int rpng_x_create_window(void); +static int rpng_x_display_image(void); +static void rpng_x_cleanup(void); +static int rpng_x_msb(ulg u32val); + + +static char titlebar[1024], *window_name = titlebar; +static char *appname = LONGNAME; +static char *icon_name = PROGNAME; +static char *filename; +static FILE *infile; + +static char *bgstr; +static uch bg_red=0, bg_green=0, bg_blue=0; + +static double display_exponent; + +static ulg image_width, image_height, image_rowbytes; +static int image_channels; +static uch *image_data; + +/* X-specific variables */ +static char *displayname; +static XImage *ximage; +static Display *display; +static int depth; +static Visual *visual; +static XVisualInfo *visual_list; +static int RShift, GShift, BShift; +static ulg RMask, GMask, BMask; +static Window window; +static GC gc; +static Colormap colormap; + +static int have_nondefault_visual = FALSE; +static int have_colormap = FALSE; +static int have_window = FALSE; +static int have_gc = FALSE; +/* +ulg numcolors=0, pixels[256]; +ush reds[256], greens[256], blues[256]; + */ + + + + +int main(int argc, char **argv) +{ +#ifdef sgi + char tmpline[80]; +#endif + char *p; + int rc, alen, flen; + int error = 0; + int have_bg = FALSE; + double LUT_exponent; /* just the lookup table */ + double CRT_exponent = 2.2; /* just the monitor */ + double default_display_exponent; /* whole display system */ + XEvent e; + KeySym k; + + + displayname = (char *)NULL; + filename = (char *)NULL; + + + /* First set the default value for our display-system exponent, i.e., + * the product of the CRT exponent and the exponent corresponding to + * the frame-buffer's lookup table (LUT), if any. This is not an + * exhaustive list of LUT values (e.g., OpenStep has a lot of weird + * ones), but it should cover 99% of the current possibilities. */ + +#if defined(NeXT) + LUT_exponent = 1.0 / 2.2; + /* + if (some_next_function_that_returns_gamma(&next_gamma)) + LUT_exponent = 1.0 / next_gamma; + */ +#elif defined(sgi) + LUT_exponent = 1.0 / 1.7; + /* there doesn't seem to be any documented function to get the + * "gamma" value, so we do it the hard way */ + infile = fopen("/etc/config/system.glGammaVal", "r"); + if (infile) { + double sgi_gamma; + + fgets(tmpline, 80, infile); + fclose(infile); + sgi_gamma = atof(tmpline); + if (sgi_gamma > 0.0) + LUT_exponent = 1.0 / sgi_gamma; + } +#elif defined(Macintosh) + LUT_exponent = 1.8 / 2.61; + /* + if (some_mac_function_that_returns_gamma(&mac_gamma)) + LUT_exponent = mac_gamma / 2.61; + */ +#else + LUT_exponent = 1.0; /* assume no LUT: most PCs */ +#endif + + /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ + default_display_exponent = LUT_exponent * CRT_exponent; + + + /* If the user has set the SCREEN_GAMMA environment variable as suggested + * (somewhat imprecisely) in the libpng documentation, use that; otherwise + * use the default value we just calculated. Either way, the user may + * override this via a command-line option. */ + + if ((p = getenv("SCREEN_GAMMA")) != NULL) + display_exponent = atof(p); + else + display_exponent = default_display_exponent; + + + /* Now parse the command line for options and the PNG filename. */ + + while (*++argv && !error) { + if (!strncmp(*argv, "-display", 2)) { + if (!*++argv) + ++error; + else + displayname = *argv; + } else if (!strncmp(*argv, "-gamma", 2)) { + if (!*++argv) + ++error; + else { + display_exponent = atof(*argv); + if (display_exponent <= 0.0) + ++error; + } + } else if (!strncmp(*argv, "-bgcolor", 2)) { + if (!*++argv) + ++error; + else { + bgstr = *argv; + if (strlen(bgstr) != 7 || bgstr[0] != '#') + ++error; + else + have_bg = TRUE; + } + } else { + if (**argv != '-') { + filename = *argv; + if (argv[1]) /* shouldn't be any more args after filename */ + ++error; + } else + ++error; /* not expecting any other options */ + } + } + + if (!filename) { + ++error; + } else if (!(infile = fopen(filename, "rb"))) { + fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); + ++error; + } else { + if ((rc = readpng_init(infile, &image_width, &image_height)) != 0) { + switch (rc) { + case 1: + fprintf(stderr, PROGNAME + ": [%s] is not a PNG file: incorrect signature\n", + filename); + break; + case 2: + fprintf(stderr, PROGNAME + ": [%s] has bad IHDR (libpng longjmp)\n", + filename); + break; + case 4: + fprintf(stderr, PROGNAME ": insufficient memory\n"); + break; + default: + fprintf(stderr, PROGNAME + ": unknown readpng_init() error\n"); + break; + } + ++error; + } else { + display = XOpenDisplay(displayname); + if (!display) { + readpng_cleanup(TRUE); + fprintf(stderr, PROGNAME ": can't open X display [%s]\n", + displayname? displayname : "default"); + ++error; + } + } + if (error) + fclose(infile); + } + + + /* usage screen */ + + if (error) { + fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); + readpng_version_info(); + fprintf(stderr, "\n" + "Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n" + " xdpy\tname of the target X display (e.g., ``hostname:0'')\n" + " exp \ttransfer-function exponent (``gamma'') of the display\n" + "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" + "\t\t to the product of the lookup-table exponent (varies)\n" + "\t\t and the CRT exponent (usually 2.2); must be positive\n" + " bg \tdesired background color in 7-character hex RGB format\n" + "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" + "\t\t used with transparent images\n" + "\nPress Q, Esc or mouse button 1 (within image window, after image\n" + "is displayed) to quit.\n" + "\n", PROGNAME, default_display_exponent); + exit(1); + } + + + /* set the title-bar string, but make sure buffer doesn't overflow */ + + alen = strlen(appname); + flen = strlen(filename); + if (alen + flen + 3 > 1023) + sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); + else + sprintf(titlebar, "%s: %s", appname, filename); + + + /* if the user didn't specify a background color on the command line, + * check for one in the PNG file--if not, the initialized values of 0 + * (black) will be used */ + + if (have_bg) { + unsigned r, g, b; /* this approach quiets compiler warnings */ + + sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); + bg_red = (uch)r; + bg_green = (uch)g; + bg_blue = (uch)b; + } else if (readpng_get_bgcolor(&bg_red, &bg_green, &bg_blue) > 1) { + readpng_cleanup(TRUE); + fprintf(stderr, PROGNAME + ": libpng error while checking for background color\n"); + exit(2); + } + + + /* do the basic X initialization stuff, make the window and fill it + * with the background color */ + + if (rpng_x_create_window()) + exit(2); + + + /* decode the image, all at once */ + + Trace((stderr, "calling readpng_get_image()\n")) + image_data = readpng_get_image(display_exponent, &image_channels, + &image_rowbytes); + Trace((stderr, "done with readpng_get_image()\n")) + + + /* done with PNG file, so clean up to minimize memory usage (but do NOT + * nuke image_data!) */ + + readpng_cleanup(FALSE); + fclose(infile); + + if (!image_data) { + fprintf(stderr, PROGNAME ": unable to decode PNG image\n"); + exit(3); + } + + + /* display image (composite with background if requested) */ + + Trace((stderr, "calling rpng_x_display_image()\n")) + if (rpng_x_display_image()) { + free(image_data); + exit(4); + } + Trace((stderr, "done with rpng_x_display_image()\n")) + + + /* wait for the user to tell us when to quit */ + + printf( + "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); + fflush(stdout); + + do + XNextEvent(display, &e); + while (!(e.type == ButtonPress && e.xbutton.button == Button1) && + !(e.type == KeyPress && /* v--- or 1 for shifted keys */ + ((k = XLookupKeysym(&e.xkey, 0)) == XK_q || k == XK_Escape) )); + + + /* OK, we're done: clean up all image and X resources and go away */ + + rpng_x_cleanup(); + + return 0; +} + + + + + +static int rpng_x_create_window(void) +{ + uch *xdata; + int need_colormap = FALSE; + int screen, pad; + ulg bg_pixel = 0L; + ulg attrmask; + Window root; + XEvent e; + XGCValues gcvalues; + XSetWindowAttributes attr; + XSizeHints *size_hints; + XTextProperty windowName, *pWindowName = &windowName; + XTextProperty iconName, *pIconName = &iconName; + XVisualInfo visual_info; + XWMHints *wm_hints; + + + screen = DefaultScreen(display); + depth = DisplayPlanes(display, screen); + root = RootWindow(display, screen); + +#ifdef DEBUG + XSynchronize(display, True); +#endif + +#if 0 +/* GRR: add 8-bit support */ + if (/* depth != 8 && */ depth != 16 && depth != 24 && depth != 32) { + fprintf(stderr, + "screen depth %d not supported (only 16-, 24- or 32-bit TrueColor)\n", + depth); + return 2; + } + + XMatchVisualInfo(display, screen, depth, + (depth == 8)? PseudoColor : TrueColor, &visual_info); + visual = visual_info.visual; +#else + if (depth != 16 && depth != 24 && depth != 32) { + int visuals_matched = 0; + + Trace((stderr, "default depth is %d: checking other visuals\n", + depth)) + + /* 24-bit first */ + visual_info.screen = screen; + visual_info.depth = 24; + visual_list = XGetVisualInfo(display, + VisualScreenMask | VisualDepthMask, &visual_info, &visuals_matched); + if (visuals_matched == 0) { +/* GRR: add 15-, 16- and 32-bit TrueColor visuals (also DirectColor?) */ + fprintf(stderr, "default screen depth %d not supported, and no" + " 24-bit visuals found\n", depth); + return 2; + } + Trace((stderr, "XGetVisualInfo() returned %d 24-bit visuals\n", + visuals_matched)) + visual = visual_list[0].visual; + depth = visual_list[0].depth; +/* + colormap_size = visual_list[0].colormap_size; + visual_class = visual->class; + visualID = XVisualIDFromVisual(visual); + */ + have_nondefault_visual = TRUE; + need_colormap = TRUE; + } else { + XMatchVisualInfo(display, screen, depth, TrueColor, &visual_info); + visual = visual_info.visual; + } +#endif + + RMask = visual->red_mask; + GMask = visual->green_mask; + BMask = visual->blue_mask; + +/* GRR: add/check 8-bit support */ + if (depth == 8 || need_colormap) { + colormap = XCreateColormap(display, root, visual, AllocNone); + if (!colormap) { + fprintf(stderr, "XCreateColormap() failed\n"); + return 2; + } + have_colormap = TRUE; + } + if (depth == 15 || depth == 16) { + RShift = 15 - rpng_x_msb(RMask); /* these are right-shifts */ + GShift = 15 - rpng_x_msb(GMask); + BShift = 15 - rpng_x_msb(BMask); + } else if (depth > 16) { +#define NO_24BIT_MASKS +#ifdef NO_24BIT_MASKS + RShift = rpng_x_msb(RMask) - 7; /* these are left-shifts */ + GShift = rpng_x_msb(GMask) - 7; + BShift = rpng_x_msb(BMask) - 7; +#else + RShift = 7 - rpng_x_msb(RMask); /* these are right-shifts, too */ + GShift = 7 - rpng_x_msb(GMask); + BShift = 7 - rpng_x_msb(BMask); +#endif + } + if (depth >= 15 && (RShift < 0 || GShift < 0 || BShift < 0)) { + fprintf(stderr, "rpng internal logic error: negative X shift(s)!\n"); + return 2; + } + +/*--------------------------------------------------------------------------- + Finally, create the window. + ---------------------------------------------------------------------------*/ + + attr.backing_store = Always; + attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask; + attrmask = CWBackingStore | CWEventMask; + if (have_nondefault_visual) { + attr.colormap = colormap; + attr.background_pixel = 0; + attr.border_pixel = 1; + attrmask |= CWColormap | CWBackPixel | CWBorderPixel; + } + + window = XCreateWindow(display, root, 0, 0, image_width, image_height, 0, + depth, InputOutput, visual, attrmask, &attr); + + if (window == None) { + fprintf(stderr, "XCreateWindow() failed\n"); + return 2; + } else + have_window = TRUE; + + if (depth == 8) + XSetWindowColormap(display, window, colormap); + + if (!XStringListToTextProperty(&window_name, 1, pWindowName)) + pWindowName = NULL; + if (!XStringListToTextProperty(&icon_name, 1, pIconName)) + pIconName = NULL; + + /* OK if either hints allocation fails; XSetWMProperties() allows NULLs */ + + if ((size_hints = XAllocSizeHints()) != NULL) { + /* window will not be resizable */ + size_hints->flags = PMinSize | PMaxSize; + size_hints->min_width = size_hints->max_width = (int)image_width; + size_hints->min_height = size_hints->max_height = (int)image_height; + } + + if ((wm_hints = XAllocWMHints()) != NULL) { + wm_hints->initial_state = NormalState; + wm_hints->input = True; + /* wm_hints->icon_pixmap = icon_pixmap; */ + wm_hints->flags = StateHint | InputHint /* | IconPixmapHint */ ; + } + + XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0, + size_hints, wm_hints, NULL); + + /* various properties and hints no longer needed; free memory */ + if (pWindowName) + XFree(pWindowName->value); + if (pIconName) + XFree(pIconName->value); + if (size_hints) + XFree(size_hints); + if (wm_hints) + XFree(wm_hints); + + XMapWindow(display, window); + + gc = XCreateGC(display, window, 0, &gcvalues); + have_gc = TRUE; + +/*--------------------------------------------------------------------------- + Fill window with the specified background color. + ---------------------------------------------------------------------------*/ + + if (depth == 24 || depth == 32) { + bg_pixel = ((ulg)bg_red << RShift) | + ((ulg)bg_green << GShift) | + ((ulg)bg_blue << BShift); + } else if (depth == 16) { + bg_pixel = ((((ulg)bg_red << 8) >> RShift) & RMask) | + ((((ulg)bg_green << 8) >> GShift) & GMask) | + ((((ulg)bg_blue << 8) >> BShift) & BMask); + } else /* depth == 8 */ { + + /* GRR: add 8-bit support */ + + } + + XSetForeground(display, gc, bg_pixel); + XFillRectangle(display, window, gc, 0, 0, image_width, image_height); + +/*--------------------------------------------------------------------------- + Wait for first Expose event to do any drawing, then flush. + ---------------------------------------------------------------------------*/ + + do + XNextEvent(display, &e); + while (e.type != Expose || e.xexpose.count); + + XFlush(display); + +/*--------------------------------------------------------------------------- + Allocate memory for the X- and display-specific version of the image. + ---------------------------------------------------------------------------*/ + + if (depth == 24 || depth == 32) { + xdata = (uch *)malloc(4*image_width*image_height); + pad = 32; + } else if (depth == 16) { + xdata = (uch *)malloc(2*image_width*image_height); + pad = 16; + } else /* depth == 8 */ { + xdata = (uch *)malloc(image_width*image_height); + pad = 8; + } + + if (!xdata) { + fprintf(stderr, PROGNAME ": unable to allocate image memory\n"); + return 4; + } + + ximage = XCreateImage(display, visual, depth, ZPixmap, 0, + (char *)xdata, image_width, image_height, pad, 0); + + if (!ximage) { + fprintf(stderr, PROGNAME ": XCreateImage() failed\n"); + free(xdata); + return 3; + } + + /* to avoid testing the byte order every pixel (or doubling the size of + * the drawing routine with a giant if-test), we arbitrarily set the byte + * order to MSBFirst and let Xlib worry about inverting things on little- + * endian machines (like Linux/x86, old VAXen, etc.)--this is not the most + * efficient approach (the giant if-test would be better), but in the + * interest of clarity, we take the easy way out... */ + + ximage->byte_order = MSBFirst; + + return 0; + +} /* end function rpng_x_create_window() */ + + + + + +static int rpng_x_display_image(void) +{ + uch *src; + char *dest; + uch r, g, b, a; + ulg i, row, lastrow = 0; + ulg pixel; + int ximage_rowbytes = ximage->bytes_per_line; +/* int bpp = ximage->bits_per_pixel; */ + + + Trace((stderr, "beginning display loop (image_channels == %d)\n", + image_channels)) + Trace((stderr, " (width = %ld, rowbytes = %ld, ximage_rowbytes = %d)\n", + image_width, image_rowbytes, ximage_rowbytes)) + Trace((stderr, " (bpp = %d)\n", ximage->bits_per_pixel)) + Trace((stderr, " (byte_order = %s)\n", ximage->byte_order == MSBFirst? + "MSBFirst" : (ximage->byte_order == LSBFirst? "LSBFirst" : "unknown"))) + + if (depth == 24 || depth == 32) { + ulg red, green, blue; + + for (lastrow = row = 0; row < image_height; ++row) { + src = image_data + row*image_rowbytes; + dest = ximage->data + row*ximage_rowbytes; + if (image_channels == 3) { + for (i = image_width; i > 0; --i) { + red = *src++; + green = *src++; + blue = *src++; +#ifdef NO_24BIT_MASKS + pixel = (red << RShift) | + (green << GShift) | + (blue << BShift); + /* recall that we set ximage->byte_order = MSBFirst above */ + /* GRR BUG: this assumes bpp == 32, but may be 24: */ + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); +#else + red = (RShift < 0)? red << (-RShift) : red >> RShift; + green = (GShift < 0)? green << (-GShift) : green >> GShift; + blue = (BShift < 0)? blue << (-BShift) : blue >> BShift; + pixel = (red & RMask) | (green & GMask) | (blue & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); +#endif + } + } else /* if (image_channels == 4) */ { + for (i = image_width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + a = *src++; + if (a == 255) { + red = r; + green = g; + blue = b; + } else if (a == 0) { + red = bg_red; + green = bg_green; + blue = bg_blue; + } else { + /* this macro (from png.h) composites the foreground + * and background values and puts the result into the + * first argument */ + alpha_composite(red, r, a, bg_red); + alpha_composite(green, g, a, bg_green); + alpha_composite(blue, b, a, bg_blue); + } + pixel = (red << RShift) | + (green << GShift) | + (blue << BShift); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } + /* display after every 16 lines */ + if (((row+1) & 0xf) == 0) { + XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, + (int)lastrow, image_width, 16); + XFlush(display); + lastrow = row + 1; + } + } + + } else if (depth == 16) { + ush red, green, blue; + + for (lastrow = row = 0; row < image_height; ++row) { + src = image_data + row*image_rowbytes; + dest = ximage->data + row*ximage_rowbytes; + if (image_channels == 3) { + for (i = image_width; i > 0; --i) { + red = ((ush)(*src) << 8); + ++src; + green = ((ush)(*src) << 8); + ++src; + blue = ((ush)(*src) << 8); + ++src; + pixel = ((red >> RShift) & RMask) | + ((green >> GShift) & GMask) | + ((blue >> BShift) & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } else /* if (image_channels == 4) */ { + for (i = image_width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + a = *src++; + if (a == 255) { + red = ((ush)r << 8); + green = ((ush)g << 8); + blue = ((ush)b << 8); + } else if (a == 0) { + red = ((ush)bg_red << 8); + green = ((ush)bg_green << 8); + blue = ((ush)bg_blue << 8); + } else { + /* this macro (from png.h) composites the foreground + * and background values and puts the result back into + * the first argument (== fg byte here: safe) */ + alpha_composite(r, r, a, bg_red); + alpha_composite(g, g, a, bg_green); + alpha_composite(b, b, a, bg_blue); + red = ((ush)r << 8); + green = ((ush)g << 8); + blue = ((ush)b << 8); + } + pixel = ((red >> RShift) & RMask) | + ((green >> GShift) & GMask) | + ((blue >> BShift) & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } + /* display after every 16 lines */ + if (((row+1) & 0xf) == 0) { + XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, + (int)lastrow, image_width, 16); + XFlush(display); + lastrow = row + 1; + } + } + + } else /* depth == 8 */ { + + /* GRR: add 8-bit support */ + + } + + Trace((stderr, "calling final XPutImage()\n")) + if (lastrow < image_height) { + XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, + (int)lastrow, image_width, image_height-lastrow); + XFlush(display); + } + + return 0; +} + + + + +static void rpng_x_cleanup(void) +{ + if (image_data) { + free(image_data); + image_data = NULL; + } + + if (ximage) { + if (ximage->data) { + free(ximage->data); /* we allocated it, so we free it */ + ximage->data = (char *)NULL; /* instead of XDestroyImage() */ + } + XDestroyImage(ximage); + ximage = NULL; + } + + if (have_gc) + XFreeGC(display, gc); + + if (have_window) + XDestroyWindow(display, window); + + if (have_colormap) + XFreeColormap(display, colormap); + + if (have_nondefault_visual) + XFree(visual_list); +} + + + + + +static int rpng_x_msb(ulg u32val) +{ + int i; + + for (i = 31; i >= 0; --i) { + if (u32val & 0x80000000L) + break; + u32val <<= 1; + } + return i; +} diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng2-win.c b/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng2-win.c index 46f2191..0c1a9d1 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng2-win.c +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng2-win.c @@ -1,1166 +1,1166 @@ -/*--------------------------------------------------------------------------- - - rpng2 - progressive-model PNG display program rpng2-win.c - - This program decodes and displays PNG files progressively, as if it were - a web browser (though the front end is only set up to read from files). - It supports gamma correction, user-specified background colors, and user- - specified background patterns (for transparent images). This version is - for 32-bit Windows; it may compile under 16-bit Windows with a little - tweaking (or maybe not). Thanks to Adam Costello and Pieter S. van der - Meulen for the "diamond" and "radial waves" patterns, respectively. - - to do: - - handle quoted command-line args (especially filenames with spaces) - - finish resizable checkerboard-gradient (sizes 4-128?) - - use %.1023s to simplify truncation of title-bar string? - - have minimum window width: oh well - - --------------------------------------------------------------------------- - - Changelog: - - 1.01: initial public release - - 1.02: fixed cut-and-paste error in usage screen (oops...) - - 1.03: modified to allow abbreviated options - - 1.04: removed bogus extra argument from usage fprintf() [Glenn R-P?]; - fixed command-line parsing bug - - 1.10: enabled "message window"/console (thanks to David Geldreich) - - 1.20: added runtime MMX-enabling/disabling and new -mmx* options - - 1.21: made minor tweak to usage screen to fit within 25-line console - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#define PROGNAME "rpng2-win" -#define LONGNAME "Progressive PNG Viewer for Windows" -#define VERSION "1.21 of 29 June 2001" - -#include -#include -#include -#include /* for jmpbuf declaration in readpng2.h */ -#include -#include /* only for PvdM background code */ -#include -#include /* only for _getch() */ - -/* all for PvdM background code: */ -#ifndef PI -# define PI 3.141592653589793238 -#endif -#define PI_2 (PI*0.5) -#define INV_PI_360 (360.0 / PI) -#define MAX(a,b) (a>b?a:b) -#define MIN(a,b) (a> 8)) >> 8); \ -} - - -#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this - * block size corresponds roughly to a download - * speed 10% faster than theoretical 33.6K maximum - * (assuming 8 data bits, 1 stop bit and no other - * overhead) */ - -/* local prototypes */ -static void rpng2_win_init(void); -static int rpng2_win_create_window(void); -static int rpng2_win_load_bg_image(void); -static void rpng2_win_display_row(ulg row); -static void rpng2_win_finish_display(void); -static void rpng2_win_cleanup(void); -LRESULT CALLBACK rpng2_win_wndproc(HWND, UINT, WPARAM, LPARAM); - - -static char titlebar[1024], *window_name = titlebar; -static char *progname = PROGNAME; -static char *appname = LONGNAME; -static char *icon_name = PROGNAME; /* GRR: not (yet) used */ -static char *filename; -static FILE *infile; - -static mainprog_info rpng2_info; - -static uch inbuf[INBUFSIZE]; -static int incount; - -static int pat = 6; /* must be less than num_bgpat */ -static int bg_image = 0; -static int bgscale = 16; -static ulg bg_rowbytes; -static uch *bg_data; - -static struct rgb_color { - uch r, g, b; -} rgb[] = { - { 0, 0, 0}, /* 0: black */ - {255, 255, 255}, /* 1: white */ - {173, 132, 57}, /* 2: tan */ - { 64, 132, 0}, /* 3: medium green */ - {189, 117, 1}, /* 4: gold */ - {253, 249, 1}, /* 5: yellow */ - { 0, 0, 255}, /* 6: blue */ - { 0, 0, 120}, /* 7: medium blue */ - {255, 0, 255}, /* 8: magenta */ - { 64, 0, 64}, /* 9: dark magenta */ - {255, 0, 0}, /* 10: red */ - { 64, 0, 0}, /* 11: dark red */ - {255, 127, 0}, /* 12: orange */ - {192, 96, 0}, /* 13: darker orange */ - { 24, 60, 0}, /* 14: dark green-yellow */ - { 85, 125, 200} /* 15: ice blue */ -}; -/* not used for now, but should be for error-checking: -static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color); - */ - -/* - This whole struct is a fairly cheesy way to keep the number of - command-line options to a minimum. The radial-waves background - type is a particularly poor fit to the integer elements of the - struct...but a few macros and a little fixed-point math will do - wonders for ya. - - type bits: - F E D C B A 9 8 7 6 5 4 3 2 1 0 - | | | | | - | | +-+-+-- 0 = sharp-edged checkerboard - | | 1 = soft diamonds - | | 2 = radial waves - | | 3-7 = undefined - | +-- gradient #2 inverted? - +-- alternating columns inverted? - */ -static struct background_pattern { - ush type; - int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */ - int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/ -} bg[] = { - {0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */ - {0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */ - {0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */ - {0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */ - {0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */ - {0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */ - {0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */ - {1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */ - {1, 12,0, 11,0}, /* diamonds: orange vs. dark red */ - {1, 10,0, 7,0}, /* diamonds: red vs. medium blue */ - {1, 4,0, 5,0}, /* diamonds: gold vs. yellow */ - {1, 3,0, 0,0}, /* diamonds: medium green vs. black */ - {2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */ - {2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */ - {2, 16, 256, 100, 250}, /* radial: very tight spiral */ - {2, 10000, 256, 11, 0} /* radial: dipole-moire' (almost fractal) */ -}; -static int num_bgpat = sizeof(bg) / sizeof(struct background_pattern); - - -/* Windows-specific global variables (could go in struct, but messy...) */ -static ulg wimage_rowbytes; -static uch *dib; -static uch *wimage_data; -static BITMAPINFOHEADER *bmih; - -static HWND global_hwnd; -static HINSTANCE global_hInst; -static int global_showmode; - - - - -int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) -{ - char *args[1024]; /* arbitrary limit, but should suffice */ - char **argv = args; - char *p, *q, *bgstr = NULL; - int argc = 0; - int rc, alen, flen; - int error = 0; - int timing = FALSE; - int have_bg = FALSE; - double LUT_exponent; /* just the lookup table */ - double CRT_exponent = 2.2; /* just the monitor */ - double default_display_exponent; /* whole display system */ - MSG msg; - - - /* First initialize a few things, just to be sure--memset takes care of - * default background color (black), booleans (FALSE), pointers (NULL), - * etc. */ - - global_hInst = hInst; - global_showmode = showmode; - filename = (char *)NULL; - memset(&rpng2_info, 0, sizeof(mainprog_info)); - - - /* Next reenable console output, which normally goes to the bit bucket - * for windowed apps. Closing the console window will terminate the - * app. Thanks to David.Geldreich@realviz.com for supplying the magical - * incantation. */ - - AllocConsole(); - freopen("CONOUT$", "a", stderr); - freopen("CONOUT$", "a", stdout); - - - /* Set the default value for our display-system exponent, i.e., the - * product of the CRT exponent and the exponent corresponding to - * the frame-buffer's lookup table (LUT), if any. This is not an - * exhaustive list of LUT values (e.g., OpenStep has a lot of weird - * ones), but it should cover 99% of the current possibilities. And - * yes, these ifdefs are completely wasted in a Windows program... */ - -#if defined(NeXT) - /* third-party utilities can modify the default LUT exponent */ - LUT_exponent = 1.0 / 2.2; - /* - if (some_next_function_that_returns_gamma(&next_gamma)) - LUT_exponent = 1.0 / next_gamma; - */ -#elif defined(sgi) - LUT_exponent = 1.0 / 1.7; - /* there doesn't seem to be any documented function to - * get the "gamma" value, so we do it the hard way */ - infile = fopen("/etc/config/system.glGammaVal", "r"); - if (infile) { - double sgi_gamma; - - fgets(tmpline, 80, infile); - fclose(infile); - sgi_gamma = atof(tmpline); - if (sgi_gamma > 0.0) - LUT_exponent = 1.0 / sgi_gamma; - } -#elif defined(Macintosh) - LUT_exponent = 1.8 / 2.61; - /* - if (some_mac_function_that_returns_gamma(&mac_gamma)) - LUT_exponent = mac_gamma / 2.61; - */ -#else - LUT_exponent = 1.0; /* assume no LUT: most PCs */ -#endif - - /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ - default_display_exponent = LUT_exponent * CRT_exponent; - - - /* If the user has set the SCREEN_GAMMA environment variable as suggested - * (somewhat imprecisely) in the libpng documentation, use that; otherwise - * use the default value we just calculated. Either way, the user may - * override this via a command-line option. */ - - if ((p = getenv("SCREEN_GAMMA")) != NULL) - rpng2_info.display_exponent = atof(p); - else - rpng2_info.display_exponent = default_display_exponent; - - - /* Windows really hates command lines, so we have to set up our own argv. - * Note that we do NOT bother with quoted arguments here, so don't use - * filenames with spaces in 'em! */ - - argv[argc++] = PROGNAME; - p = cmd; - for (;;) { - if (*p == ' ') - while (*++p == ' ') - ; - /* now p points at the first non-space after some spaces */ - if (*p == '\0') - break; /* nothing after the spaces: done */ - argv[argc++] = q = p; - while (*q && *q != ' ') - ++q; - /* now q points at a space or the end of the string */ - if (*q == '\0') - break; /* last argv already terminated; quit */ - *q = '\0'; /* change space to terminator */ - p = q + 1; - } - argv[argc] = NULL; /* terminate the argv array itself */ - - - /* Now parse the command line for options and the PNG filename. */ - - while (*++argv && !error) { - if (!strncmp(*argv, "-gamma", 2)) { - if (!*++argv) - ++error; - else { - rpng2_info.display_exponent = atof(*argv); - if (rpng2_info.display_exponent <= 0.0) - ++error; - } - } else if (!strncmp(*argv, "-bgcolor", 4)) { - if (!*++argv) - ++error; - else { - bgstr = *argv; - if (strlen(bgstr) != 7 || bgstr[0] != '#') - ++error; - else { - have_bg = TRUE; - bg_image = FALSE; - } - } - } else if (!strncmp(*argv, "-bgpat", 4)) { - if (!*++argv) - ++error; - else { - pat = atoi(*argv) - 1; - if (pat < 0 || pat >= num_bgpat) - ++error; - else { - bg_image = TRUE; - have_bg = FALSE; - } - } - } else if (!strncmp(*argv, "-timing", 2)) { - timing = TRUE; -#if (defined(__i386__) || defined(_M_IX86)) - } else if (!strncmp(*argv, "-nommxfilters", 7)) { - rpng2_info.nommxfilters = TRUE; - } else if (!strncmp(*argv, "-nommxcombine", 7)) { - rpng2_info.nommxcombine = TRUE; - } else if (!strncmp(*argv, "-nommxinterlace", 7)) { - rpng2_info.nommxinterlace = TRUE; - } else if (!strcmp(*argv, "-nommx")) { - rpng2_info.nommxfilters = TRUE; - rpng2_info.nommxcombine = TRUE; - rpng2_info.nommxinterlace = TRUE; -#endif - } else { - if (**argv != '-') { - filename = *argv; - if (argv[1]) /* shouldn't be any more args after filename */ - ++error; - } else - ++error; /* not expecting any other options */ - } - } - - if (!filename) { - ++error; - } else if (!(infile = fopen(filename, "rb"))) { - fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); - ++error; - } else { - incount = fread(inbuf, 1, INBUFSIZE, infile); - if (incount < 8 || !readpng2_check_sig(inbuf, 8)) { - fprintf(stderr, PROGNAME - ": [%s] is not a PNG file: incorrect signature\n", - filename); - ++error; - } else if ((rc = readpng2_init(&rpng2_info)) != 0) { - switch (rc) { - case 2: - fprintf(stderr, PROGNAME - ": [%s] has bad IHDR (libpng longjmp)\n", - filename); - break; - case 4: - fprintf(stderr, PROGNAME ": insufficient memory\n"); - break; - default: - fprintf(stderr, PROGNAME - ": unknown readpng2_init() error\n"); - break; - } - ++error; - } - if (error) - fclose(infile); - } - - - /* usage screen */ - - if (error) { - int ch; - - fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); - readpng2_version_info(); - fprintf(stderr, "\n" - "Usage: %s [-gamma exp] [-bgcolor bg | -bgpat pat] [-timing]\n" -#if (defined(__i386__) || defined(_M_IX86)) - " %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n" -#endif - " %*s file.png\n\n" - " exp \ttransfer-function exponent (``gamma'') of the display\n" - "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" - "\t\t to the product of the lookup-table exponent (varies)\n" - "\t\t and the CRT exponent (usually 2.2); must be positive\n" - " bg \tdesired background color in 7-character hex RGB format\n" - "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" - "\t\t used with transparent images; overrides -bgpat option\n" - " pat \tdesired background pattern number (1-%d); used with\n" - "\t\t transparent images; overrides -bgcolor option\n" - " -timing\tenables delay for every block read, to simulate modem\n" - "\t\t download of image (~36 Kbps)\n" -#if (defined(__i386__) || defined(_M_IX86)) - " -nommx*\tdisable optimized MMX routines for decoding row filters,\n" - "\t\t combining rows, and expanding interlacing, respectively\n" -#endif - "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" - "Press Q or Esc to quit this usage screen. ", - PROGNAME, -#if (defined(__i386__) || defined(_M_IX86)) - strlen(PROGNAME), " ", -#endif - strlen(PROGNAME), " ", default_display_exponent, num_bgpat); - fflush(stderr); - do - ch = _getch(); - while (ch != 'q' && ch != 'Q' && ch != 0x1B); - exit(1); - } else { - fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); - fprintf(stderr, - "\n [console window: closing this window will terminate %s]\n\n", - PROGNAME); - fflush(stderr); - } - - - /* set the title-bar string, but make sure buffer doesn't overflow */ - - alen = strlen(appname); - flen = strlen(filename); - if (alen + flen + 3 > 1023) - sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); - else - sprintf(titlebar, "%s: %s", appname, filename); - - - /* set some final rpng2_info variables before entering main data loop */ - - if (have_bg) { - unsigned r, g, b; /* this approach quiets compiler warnings */ - - sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); - rpng2_info.bg_red = (uch)r; - rpng2_info.bg_green = (uch)g; - rpng2_info.bg_blue = (uch)b; - } else - rpng2_info.need_bgcolor = TRUE; - - rpng2_info.done = FALSE; - rpng2_info.mainprog_init = rpng2_win_init; - rpng2_info.mainprog_display_row = rpng2_win_display_row; - rpng2_info.mainprog_finish_display = rpng2_win_finish_display; - - - /* OK, this is the fun part: call readpng2_decode_data() at the start of - * the loop to deal with our first buffer of data (read in above to verify - * that the file is a PNG image), then loop through the file and continue - * calling the same routine to handle each chunk of data. It in turn - * passes the data to libpng, which will invoke one or more of our call- - * backs as decoded data become available. We optionally call Sleep() for - * one second per iteration to simulate downloading the image via an analog - * modem. */ - - for (;;) { - Trace((stderr, "about to call readpng2_decode_data()\n")) - if (readpng2_decode_data(&rpng2_info, inbuf, incount)) - ++error; - Trace((stderr, "done with readpng2_decode_data()\n")) - if (error || feof(infile) || rpng2_info.done) - break; - if (timing) - Sleep(1000L); - incount = fread(inbuf, 1, INBUFSIZE, infile); - } - - - /* clean up PNG stuff and report any decoding errors */ - - fclose(infile); - Trace((stderr, "about to call readpng2_cleanup()\n")) - readpng2_cleanup(&rpng2_info); - - if (error) { - fprintf(stderr, PROGNAME ": libpng error while decoding PNG image\n"); - exit(3); - } - - - /* wait for the user to tell us when to quit */ - - while (GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - - /* we're done: clean up all image and Windows resources and go away */ - - Trace((stderr, "about to call rpng2_win_cleanup()\n")) - rpng2_win_cleanup(); - - return msg.wParam; -} - - - - - -/* this function is called by readpng2_info_callback() in readpng2.c, which - * in turn is called by libpng after all of the pre-IDAT chunks have been - * read and processed--i.e., we now have enough info to finish initializing */ - -static void rpng2_win_init() -{ - ulg i; - ulg rowbytes = rpng2_info.rowbytes; - - Trace((stderr, "beginning rpng2_win_init()\n")) - Trace((stderr, " rowbytes = %ld\n", rpng2_info.rowbytes)) - Trace((stderr, " width = %ld\n", rpng2_info.width)) - Trace((stderr, " height = %ld\n", rpng2_info.height)) - - rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height); - if (!rpng2_info.image_data) { - readpng2_cleanup(&rpng2_info); - return; - } - - rpng2_info.row_pointers = (uch **)malloc(rpng2_info.height * sizeof(uch *)); - if (!rpng2_info.row_pointers) { - free(rpng2_info.image_data); - rpng2_info.image_data = NULL; - readpng2_cleanup(&rpng2_info); - return; - } - - for (i = 0; i < rpng2_info.height; ++i) - rpng2_info.row_pointers[i] = rpng2_info.image_data + i*rowbytes; - -/*--------------------------------------------------------------------------- - Do the basic Windows initialization stuff, make the window, and fill it - with the user-specified, file-specified or default background color. - ---------------------------------------------------------------------------*/ - - if (rpng2_win_create_window()) { - readpng2_cleanup(&rpng2_info); - return; - } -} - - - - - -static int rpng2_win_create_window() -{ - uch bg_red = rpng2_info.bg_red; - uch bg_green = rpng2_info.bg_green; - uch bg_blue = rpng2_info.bg_blue; - uch *dest; - int extra_width, extra_height; - ulg i, j; - WNDCLASSEX wndclass; - RECT rect; - - -/*--------------------------------------------------------------------------- - Allocate memory for the display-specific version of the image (round up - to multiple of 4 for Windows DIB). - ---------------------------------------------------------------------------*/ - - wimage_rowbytes = ((3*rpng2_info.width + 3L) >> 2) << 2; - - if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) + - wimage_rowbytes*rpng2_info.height))) - { - return 4; /* fail */ - } - -/*--------------------------------------------------------------------------- - Initialize the DIB. Negative height means to use top-down BMP ordering - (must be uncompressed, but that's what we want). Bit count of 1, 4 or 8 - implies a colormap of RGBX quads, but 24-bit BMPs just use B,G,R values - directly => wimage_data begins immediately after BMP header. - ---------------------------------------------------------------------------*/ - - memset(dib, 0, sizeof(BITMAPINFOHEADER)); - bmih = (BITMAPINFOHEADER *)dib; - bmih->biSize = sizeof(BITMAPINFOHEADER); - bmih->biWidth = rpng2_info.width; - bmih->biHeight = -((long)rpng2_info.height); - bmih->biPlanes = 1; - bmih->biBitCount = 24; - bmih->biCompression = 0; - wimage_data = dib + sizeof(BITMAPINFOHEADER); - -/*--------------------------------------------------------------------------- - Fill window with the specified background color (default is black), but - defer loading faked "background image" until window is displayed (may be - slow to compute). Data are in BGR order. - ---------------------------------------------------------------------------*/ - - if (bg_image) { /* just fill with black for now */ - memset(wimage_data, 0, wimage_rowbytes*rpng2_info.height); - } else { - for (j = 0; j < rpng2_info.height; ++j) { - dest = wimage_data + j*wimage_rowbytes; - for (i = rpng2_info.width; i > 0; --i) { - *dest++ = bg_blue; - *dest++ = bg_green; - *dest++ = bg_red; - } - } - } - -/*--------------------------------------------------------------------------- - Set the window parameters. - ---------------------------------------------------------------------------*/ - - memset(&wndclass, 0, sizeof(wndclass)); - - wndclass.cbSize = sizeof(wndclass); - wndclass.style = CS_HREDRAW | CS_VREDRAW; - wndclass.lpfnWndProc = rpng2_win_wndproc; - wndclass.hInstance = global_hInst; - wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); - wndclass.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH); - wndclass.lpszMenuName = NULL; - wndclass.lpszClassName = progname; - wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); - - RegisterClassEx(&wndclass); - -/*--------------------------------------------------------------------------- - Finally, create the window. - ---------------------------------------------------------------------------*/ - - extra_width = 2*(GetSystemMetrics(SM_CXBORDER) + - GetSystemMetrics(SM_CXDLGFRAME)); - extra_height = 2*(GetSystemMetrics(SM_CYBORDER) + - GetSystemMetrics(SM_CYDLGFRAME)) + - GetSystemMetrics(SM_CYCAPTION); - - global_hwnd = CreateWindow(progname, titlebar, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, rpng2_info.width+extra_width, - rpng2_info.height+extra_height, NULL, NULL, global_hInst, NULL); - - ShowWindow(global_hwnd, global_showmode); - UpdateWindow(global_hwnd); - -/*--------------------------------------------------------------------------- - Now compute the background image and display it. If it fails (memory - allocation), revert to a plain background color. - ---------------------------------------------------------------------------*/ - - if (bg_image) { - static const char *msg = "Computing background image..."; - int x, y, len = strlen(msg); - HDC hdc = GetDC(global_hwnd); - TEXTMETRIC tm; - - GetTextMetrics(hdc, &tm); - x = (rpng2_info.width - len*tm.tmAveCharWidth)/2; - y = (rpng2_info.height - tm.tmHeight)/2; - SetBkMode(hdc, TRANSPARENT); - SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); - /* this can still begin out of bounds even if x is positive (???): */ - TextOut(hdc, ((x < 0)? 0 : x), ((y < 0)? 0 : y), msg, len); - ReleaseDC(global_hwnd, hdc); - - rpng2_win_load_bg_image(); /* resets bg_image if fails */ - } - - if (!bg_image) { - for (j = 0; j < rpng2_info.height; ++j) { - dest = wimage_data + j*wimage_rowbytes; - for (i = rpng2_info.width; i > 0; --i) { - *dest++ = bg_blue; - *dest++ = bg_green; - *dest++ = bg_red; - } - } - } - - rect.left = 0L; - rect.top = 0L; - rect.right = (LONG)rpng2_info.width; /* possibly off by one? */ - rect.bottom = (LONG)rpng2_info.height; /* possibly off by one? */ - InvalidateRect(global_hwnd, &rect, FALSE); - UpdateWindow(global_hwnd); /* similar to XFlush() */ - - return 0; - -} /* end function rpng2_win_create_window() */ - - - - - -static int rpng2_win_load_bg_image() -{ - uch *src, *dest; - uch r1, r2, g1, g2, b1, b2; - uch r1_inv, r2_inv, g1_inv, g2_inv, b1_inv, b2_inv; - int k, hmax, max; - int xidx, yidx, yidx_max = (bgscale-1); - int even_odd_vert, even_odd_horiz, even_odd; - int invert_gradient2 = (bg[pat].type & 0x08); - int invert_column; - ulg i, row; - -/*--------------------------------------------------------------------------- - Allocate buffer for fake background image to be used with transparent - images; if this fails, revert to plain background color. - ---------------------------------------------------------------------------*/ - - bg_rowbytes = 3 * rpng2_info.width; - bg_data = (uch *)malloc(bg_rowbytes * rpng2_info.height); - if (!bg_data) { - fprintf(stderr, PROGNAME - ": unable to allocate memory for background image\n"); - bg_image = 0; - return 1; - } - -/*--------------------------------------------------------------------------- - Vertical gradients (ramps) in NxN squares, alternating direction and - colors (N == bgscale). - ---------------------------------------------------------------------------*/ - - if ((bg[pat].type & 0x07) == 0) { - uch r1_min = rgb[bg[pat].rgb1_min].r; - uch g1_min = rgb[bg[pat].rgb1_min].g; - uch b1_min = rgb[bg[pat].rgb1_min].b; - uch r2_min = rgb[bg[pat].rgb2_min].r; - uch g2_min = rgb[bg[pat].rgb2_min].g; - uch b2_min = rgb[bg[pat].rgb2_min].b; - int r1_diff = rgb[bg[pat].rgb1_max].r - r1_min; - int g1_diff = rgb[bg[pat].rgb1_max].g - g1_min; - int b1_diff = rgb[bg[pat].rgb1_max].b - b1_min; - int r2_diff = rgb[bg[pat].rgb2_max].r - r2_min; - int g2_diff = rgb[bg[pat].rgb2_max].g - g2_min; - int b2_diff = rgb[bg[pat].rgb2_max].b - b2_min; - - for (row = 0; row < rpng2_info.height; ++row) { - yidx = row % bgscale; - even_odd_vert = (row / bgscale) & 1; - - r1 = r1_min + (r1_diff * yidx) / yidx_max; - g1 = g1_min + (g1_diff * yidx) / yidx_max; - b1 = b1_min + (b1_diff * yidx) / yidx_max; - r1_inv = r1_min + (r1_diff * (yidx_max-yidx)) / yidx_max; - g1_inv = g1_min + (g1_diff * (yidx_max-yidx)) / yidx_max; - b1_inv = b1_min + (b1_diff * (yidx_max-yidx)) / yidx_max; - - r2 = r2_min + (r2_diff * yidx) / yidx_max; - g2 = g2_min + (g2_diff * yidx) / yidx_max; - b2 = b2_min + (b2_diff * yidx) / yidx_max; - r2_inv = r2_min + (r2_diff * (yidx_max-yidx)) / yidx_max; - g2_inv = g2_min + (g2_diff * (yidx_max-yidx)) / yidx_max; - b2_inv = b2_min + (b2_diff * (yidx_max-yidx)) / yidx_max; - - dest = bg_data + row*bg_rowbytes; - for (i = 0; i < rpng2_info.width; ++i) { - even_odd_horiz = (i / bgscale) & 1; - even_odd = even_odd_vert ^ even_odd_horiz; - invert_column = - (even_odd_horiz && (bg[pat].type & 0x10)); - if (even_odd == 0) { /* gradient #1 */ - if (invert_column) { - *dest++ = r1_inv; - *dest++ = g1_inv; - *dest++ = b1_inv; - } else { - *dest++ = r1; - *dest++ = g1; - *dest++ = b1; - } - } else { /* gradient #2 */ - if ((invert_column && invert_gradient2) || - (!invert_column && !invert_gradient2)) - { - *dest++ = r2; /* not inverted or */ - *dest++ = g2; /* doubly inverted */ - *dest++ = b2; - } else { - *dest++ = r2_inv; - *dest++ = g2_inv; /* singly inverted */ - *dest++ = b2_inv; - } - } - } - } - -/*--------------------------------------------------------------------------- - Soft gradient-diamonds with scale = bgscale. Code contributed by Adam - M. Costello. - ---------------------------------------------------------------------------*/ - - } else if ((bg[pat].type & 0x07) == 1) { - - hmax = (bgscale-1)/2; /* half the max weight of a color */ - max = 2*hmax; /* the max weight of a color */ - - r1 = rgb[bg[pat].rgb1_max].r; - g1 = rgb[bg[pat].rgb1_max].g; - b1 = rgb[bg[pat].rgb1_max].b; - r2 = rgb[bg[pat].rgb2_max].r; - g2 = rgb[bg[pat].rgb2_max].g; - b2 = rgb[bg[pat].rgb2_max].b; - - for (row = 0; row < rpng2_info.height; ++row) { - yidx = row % bgscale; - if (yidx > hmax) - yidx = bgscale-1 - yidx; - dest = bg_data + row*bg_rowbytes; - for (i = 0; i < rpng2_info.width; ++i) { - xidx = i % bgscale; - if (xidx > hmax) - xidx = bgscale-1 - xidx; - k = xidx + yidx; - *dest++ = (k*r1 + (max-k)*r2) / max; - *dest++ = (k*g1 + (max-k)*g2) / max; - *dest++ = (k*b1 + (max-k)*b2) / max; - } - } - -/*--------------------------------------------------------------------------- - Radial "starburst" with azimuthal sinusoids; [eventually number of sinu- - soids will equal bgscale?]. This one is slow but very cool. Code con- - tributed by Pieter S. van der Meulen (originally in Smalltalk). - ---------------------------------------------------------------------------*/ - - } else if ((bg[pat].type & 0x07) == 2) { - uch ch; - int ii, x, y, hw, hh, grayspot; - double freq, rotate, saturate, gray, intensity; - double angle=0.0, aoffset=0.0, maxDist, dist; - double red=0.0, green=0.0, blue=0.0, hue, s, v, f, p, q, t; - - fprintf(stderr, "%s: computing radial background...", - PROGNAME); - fflush(stderr); - - hh = rpng2_info.height / 2; - hw = rpng2_info.width / 2; - - /* variables for radial waves: - * aoffset: number of degrees to rotate hue [CURRENTLY NOT USED] - * freq: number of color beams originating from the center - * grayspot: size of the graying center area (anti-alias) - * rotate: rotation of the beams as a function of radius - * saturate: saturation of beams' shape azimuthally - */ - angle = CLIP(angle, 0.0, 360.0); - grayspot = CLIP(bg[pat].bg_gray, 1, (hh + hw)); - freq = MAX((double)bg[pat].bg_freq, 0.0); - saturate = (double)bg[pat].bg_bsat * 0.1; - rotate = (double)bg[pat].bg_brot * 0.1; - gray = 0.0; - intensity = 0.0; - maxDist = (double)((hw*hw) + (hh*hh)); - - for (row = 0; row < rpng2_info.height; ++row) { - y = row - hh; - dest = bg_data + row*bg_rowbytes; - for (i = 0; i < rpng2_info.width; ++i) { - x = i - hw; - angle = (x == 0)? PI_2 : atan((double)y / (double)x); - gray = (double)MAX(ABS(y), ABS(x)) / grayspot; - gray = MIN(1.0, gray); - dist = (double)((x*x) + (y*y)) / maxDist; - intensity = cos((angle+(rotate*dist*PI)) * freq) * - gray * saturate; - intensity = (MAX(MIN(intensity,1.0),-1.0) + 1.0) * 0.5; - hue = (angle + PI) * INV_PI_360 + aoffset; - s = gray * ((double)(ABS(x)+ABS(y)) / (double)(hw + hh)); - s = MIN(MAX(s,0.0), 1.0); - v = MIN(MAX(intensity,0.0), 1.0); - - if (s == 0.0) { - ch = (uch)(v * 255.0); - *dest++ = ch; - *dest++ = ch; - *dest++ = ch; - } else { - if ((hue < 0.0) || (hue >= 360.0)) - hue -= (((int)(hue / 360.0)) * 360.0); - hue /= 60.0; - ii = (int)hue; - f = hue - (double)ii; - p = (1.0 - s) * v; - q = (1.0 - (s * f)) * v; - t = (1.0 - (s * (1.0 - f))) * v; - if (ii == 0) { red = v; green = t; blue = p; } - else if (ii == 1) { red = q; green = v; blue = p; } - else if (ii == 2) { red = p; green = v; blue = t; } - else if (ii == 3) { red = p; green = q; blue = v; } - else if (ii == 4) { red = t; green = p; blue = v; } - else if (ii == 5) { red = v; green = p; blue = q; } - *dest++ = (uch)(red * 255.0); - *dest++ = (uch)(green * 255.0); - *dest++ = (uch)(blue * 255.0); - } - } - } - fprintf(stderr, "done.\n"); - fflush(stderr); - } - -/*--------------------------------------------------------------------------- - Blast background image to display buffer before beginning PNG decode; - calling function will handle invalidation and UpdateWindow() call. - ---------------------------------------------------------------------------*/ - - for (row = 0; row < rpng2_info.height; ++row) { - src = bg_data + row*bg_rowbytes; - dest = wimage_data + row*wimage_rowbytes; - for (i = rpng2_info.width; i > 0; --i) { - r1 = *src++; - g1 = *src++; - b1 = *src++; - *dest++ = b1; - *dest++ = g1; /* note reverse order */ - *dest++ = r1; - } - } - - return 0; - -} /* end function rpng2_win_load_bg_image() */ - - - - - -static void rpng2_win_display_row(ulg row) -{ - uch bg_red = rpng2_info.bg_red; - uch bg_green = rpng2_info.bg_green; - uch bg_blue = rpng2_info.bg_blue; - uch *src, *src2=NULL, *dest; - uch r, g, b, a; - ulg i; - static int rows=0; - static ulg firstrow; - -/*--------------------------------------------------------------------------- - rows and firstrow simply track how many rows (and which ones) have not - yet been displayed; alternatively, we could call InvalidateRect() for - every row and not bother with the records-keeping. - ---------------------------------------------------------------------------*/ - - Trace((stderr, "beginning rpng2_win_display_row()\n")) - - if (rows == 0) - firstrow = row; /* first row not yet displayed */ - - ++rows; /* count of rows received but not yet displayed */ - -/*--------------------------------------------------------------------------- - Aside from the use of the rpng2_info struct and the lack of an outer - loop (over rows), this routine is identical to rpng_win_display_image() - in the non-progressive version of the program. - ---------------------------------------------------------------------------*/ - - src = rpng2_info.image_data + row*rpng2_info.rowbytes; - if (bg_image) - src2 = bg_data + row*bg_rowbytes; - dest = wimage_data + row*wimage_rowbytes; - - if (rpng2_info.channels == 3) { - for (i = rpng2_info.width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - *dest++ = b; - *dest++ = g; /* note reverse order */ - *dest++ = r; - } - } else /* if (rpng2_info.channels == 4) */ { - for (i = rpng2_info.width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - a = *src++; - if (bg_image) { - bg_red = *src2++; - bg_green = *src2++; - bg_blue = *src2++; - } - if (a == 255) { - *dest++ = b; - *dest++ = g; - *dest++ = r; - } else if (a == 0) { - *dest++ = bg_blue; - *dest++ = bg_green; - *dest++ = bg_red; - } else { - /* this macro (copied from png.h) composites the - * foreground and background values and puts the - * result into the first argument; there are no - * side effects with the first argument */ - alpha_composite(*dest++, b, a, bg_blue); - alpha_composite(*dest++, g, a, bg_green); - alpha_composite(*dest++, r, a, bg_red); - } - } - } - -/*--------------------------------------------------------------------------- - Display after every 16 rows or when on last row. (Region may include - previously displayed lines due to interlacing--i.e., not contiguous.) - ---------------------------------------------------------------------------*/ - - if ((rows & 0xf) == 0 || row == rpng2_info.height-1) { - RECT rect; - - rect.left = 0L; - rect.top = (LONG)firstrow; - rect.right = (LONG)rpng2_info.width; /* possibly off by one? */ - rect.bottom = (LONG)row + 1L; /* possibly off by one? */ - InvalidateRect(global_hwnd, &rect, FALSE); - UpdateWindow(global_hwnd); /* similar to XFlush() */ - rows = 0; - } - -} /* end function rpng2_win_display_row() */ - - - - - -static void rpng2_win_finish_display() -{ - Trace((stderr, "beginning rpng2_win_finish_display()\n")) - - /* last row has already been displayed by rpng2_win_display_row(), so - * we have nothing to do here except set a flag and let the user know - * that the image is done */ - - rpng2_info.done = TRUE; - printf( - "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); - fflush(stdout); -} - - - - - -static void rpng2_win_cleanup() -{ - if (bg_image && bg_data) { - free(bg_data); - bg_data = NULL; - } - - if (rpng2_info.image_data) { - free(rpng2_info.image_data); - rpng2_info.image_data = NULL; - } - - if (rpng2_info.row_pointers) { - free(rpng2_info.row_pointers); - rpng2_info.row_pointers = NULL; - } - - if (dib) { - free(dib); - dib = NULL; - } -} - - - - - -LRESULT CALLBACK rpng2_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP) -{ - HDC hdc; - PAINTSTRUCT ps; - int rc; - - switch (iMsg) { - case WM_CREATE: - /* one-time processing here, if any */ - return 0; - - case WM_PAINT: - hdc = BeginPaint(hwnd, &ps); - rc = StretchDIBits(hdc, 0, 0, rpng2_info.width, rpng2_info.height, - 0, 0, rpng2_info.width, rpng2_info.height, - wimage_data, (BITMAPINFO *)bmih, - 0, SRCCOPY); - EndPaint(hwnd, &ps); - return 0; - - /* wait for the user to tell us when to quit */ - case WM_CHAR: - switch (wP) { /* only need one, so ignore repeat count */ - case 'q': - case 'Q': - case 0x1B: /* Esc key */ - PostQuitMessage(0); - } - return 0; - - case WM_LBUTTONDOWN: /* another way of quitting */ - case WM_DESTROY: - PostQuitMessage(0); - return 0; - } - - return DefWindowProc(hwnd, iMsg, wP, lP); -} +/*--------------------------------------------------------------------------- + + rpng2 - progressive-model PNG display program rpng2-win.c + + This program decodes and displays PNG files progressively, as if it were + a web browser (though the front end is only set up to read from files). + It supports gamma correction, user-specified background colors, and user- + specified background patterns (for transparent images). This version is + for 32-bit Windows; it may compile under 16-bit Windows with a little + tweaking (or maybe not). Thanks to Adam Costello and Pieter S. van der + Meulen for the "diamond" and "radial waves" patterns, respectively. + + to do: + - handle quoted command-line args (especially filenames with spaces) + - finish resizable checkerboard-gradient (sizes 4-128?) + - use %.1023s to simplify truncation of title-bar string? + - have minimum window width: oh well + + --------------------------------------------------------------------------- + + Changelog: + - 1.01: initial public release + - 1.02: fixed cut-and-paste error in usage screen (oops...) + - 1.03: modified to allow abbreviated options + - 1.04: removed bogus extra argument from usage fprintf() [Glenn R-P?]; + fixed command-line parsing bug + - 1.10: enabled "message window"/console (thanks to David Geldreich) + - 1.20: added runtime MMX-enabling/disabling and new -mmx* options + - 1.21: made minor tweak to usage screen to fit within 25-line console + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + ---------------------------------------------------------------------------*/ + +#define PROGNAME "rpng2-win" +#define LONGNAME "Progressive PNG Viewer for Windows" +#define VERSION "1.21 of 29 June 2001" + +#include +#include +#include +#include /* for jmpbuf declaration in readpng2.h */ +#include +#include /* only for PvdM background code */ +#include +#include /* only for _getch() */ + +/* all for PvdM background code: */ +#ifndef PI +# define PI 3.141592653589793238 +#endif +#define PI_2 (PI*0.5) +#define INV_PI_360 (360.0 / PI) +#define MAX(a,b) (a>b?a:b) +#define MIN(a,b) (a> 8)) >> 8); \ +} + + +#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this + * block size corresponds roughly to a download + * speed 10% faster than theoretical 33.6K maximum + * (assuming 8 data bits, 1 stop bit and no other + * overhead) */ + +/* local prototypes */ +static void rpng2_win_init(void); +static int rpng2_win_create_window(void); +static int rpng2_win_load_bg_image(void); +static void rpng2_win_display_row(ulg row); +static void rpng2_win_finish_display(void); +static void rpng2_win_cleanup(void); +LRESULT CALLBACK rpng2_win_wndproc(HWND, UINT, WPARAM, LPARAM); + + +static char titlebar[1024], *window_name = titlebar; +static char *progname = PROGNAME; +static char *appname = LONGNAME; +static char *icon_name = PROGNAME; /* GRR: not (yet) used */ +static char *filename; +static FILE *infile; + +static mainprog_info rpng2_info; + +static uch inbuf[INBUFSIZE]; +static int incount; + +static int pat = 6; /* must be less than num_bgpat */ +static int bg_image = 0; +static int bgscale = 16; +static ulg bg_rowbytes; +static uch *bg_data; + +static struct rgb_color { + uch r, g, b; +} rgb[] = { + { 0, 0, 0}, /* 0: black */ + {255, 255, 255}, /* 1: white */ + {173, 132, 57}, /* 2: tan */ + { 64, 132, 0}, /* 3: medium green */ + {189, 117, 1}, /* 4: gold */ + {253, 249, 1}, /* 5: yellow */ + { 0, 0, 255}, /* 6: blue */ + { 0, 0, 120}, /* 7: medium blue */ + {255, 0, 255}, /* 8: magenta */ + { 64, 0, 64}, /* 9: dark magenta */ + {255, 0, 0}, /* 10: red */ + { 64, 0, 0}, /* 11: dark red */ + {255, 127, 0}, /* 12: orange */ + {192, 96, 0}, /* 13: darker orange */ + { 24, 60, 0}, /* 14: dark green-yellow */ + { 85, 125, 200} /* 15: ice blue */ +}; +/* not used for now, but should be for error-checking: +static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color); + */ + +/* + This whole struct is a fairly cheesy way to keep the number of + command-line options to a minimum. The radial-waves background + type is a particularly poor fit to the integer elements of the + struct...but a few macros and a little fixed-point math will do + wonders for ya. + + type bits: + F E D C B A 9 8 7 6 5 4 3 2 1 0 + | | | | | + | | +-+-+-- 0 = sharp-edged checkerboard + | | 1 = soft diamonds + | | 2 = radial waves + | | 3-7 = undefined + | +-- gradient #2 inverted? + +-- alternating columns inverted? + */ +static struct background_pattern { + ush type; + int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */ + int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/ +} bg[] = { + {0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */ + {0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */ + {0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */ + {0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */ + {0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */ + {0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */ + {0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */ + {1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */ + {1, 12,0, 11,0}, /* diamonds: orange vs. dark red */ + {1, 10,0, 7,0}, /* diamonds: red vs. medium blue */ + {1, 4,0, 5,0}, /* diamonds: gold vs. yellow */ + {1, 3,0, 0,0}, /* diamonds: medium green vs. black */ + {2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */ + {2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */ + {2, 16, 256, 100, 250}, /* radial: very tight spiral */ + {2, 10000, 256, 11, 0} /* radial: dipole-moire' (almost fractal) */ +}; +static int num_bgpat = sizeof(bg) / sizeof(struct background_pattern); + + +/* Windows-specific global variables (could go in struct, but messy...) */ +static ulg wimage_rowbytes; +static uch *dib; +static uch *wimage_data; +static BITMAPINFOHEADER *bmih; + +static HWND global_hwnd; +static HINSTANCE global_hInst; +static int global_showmode; + + + + +int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) +{ + char *args[1024]; /* arbitrary limit, but should suffice */ + char **argv = args; + char *p, *q, *bgstr = NULL; + int argc = 0; + int rc, alen, flen; + int error = 0; + int timing = FALSE; + int have_bg = FALSE; + double LUT_exponent; /* just the lookup table */ + double CRT_exponent = 2.2; /* just the monitor */ + double default_display_exponent; /* whole display system */ + MSG msg; + + + /* First initialize a few things, just to be sure--memset takes care of + * default background color (black), booleans (FALSE), pointers (NULL), + * etc. */ + + global_hInst = hInst; + global_showmode = showmode; + filename = (char *)NULL; + memset(&rpng2_info, 0, sizeof(mainprog_info)); + + + /* Next reenable console output, which normally goes to the bit bucket + * for windowed apps. Closing the console window will terminate the + * app. Thanks to David.Geldreich@realviz.com for supplying the magical + * incantation. */ + + AllocConsole(); + freopen("CONOUT$", "a", stderr); + freopen("CONOUT$", "a", stdout); + + + /* Set the default value for our display-system exponent, i.e., the + * product of the CRT exponent and the exponent corresponding to + * the frame-buffer's lookup table (LUT), if any. This is not an + * exhaustive list of LUT values (e.g., OpenStep has a lot of weird + * ones), but it should cover 99% of the current possibilities. And + * yes, these ifdefs are completely wasted in a Windows program... */ + +#if defined(NeXT) + /* third-party utilities can modify the default LUT exponent */ + LUT_exponent = 1.0 / 2.2; + /* + if (some_next_function_that_returns_gamma(&next_gamma)) + LUT_exponent = 1.0 / next_gamma; + */ +#elif defined(sgi) + LUT_exponent = 1.0 / 1.7; + /* there doesn't seem to be any documented function to + * get the "gamma" value, so we do it the hard way */ + infile = fopen("/etc/config/system.glGammaVal", "r"); + if (infile) { + double sgi_gamma; + + fgets(tmpline, 80, infile); + fclose(infile); + sgi_gamma = atof(tmpline); + if (sgi_gamma > 0.0) + LUT_exponent = 1.0 / sgi_gamma; + } +#elif defined(Macintosh) + LUT_exponent = 1.8 / 2.61; + /* + if (some_mac_function_that_returns_gamma(&mac_gamma)) + LUT_exponent = mac_gamma / 2.61; + */ +#else + LUT_exponent = 1.0; /* assume no LUT: most PCs */ +#endif + + /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ + default_display_exponent = LUT_exponent * CRT_exponent; + + + /* If the user has set the SCREEN_GAMMA environment variable as suggested + * (somewhat imprecisely) in the libpng documentation, use that; otherwise + * use the default value we just calculated. Either way, the user may + * override this via a command-line option. */ + + if ((p = getenv("SCREEN_GAMMA")) != NULL) + rpng2_info.display_exponent = atof(p); + else + rpng2_info.display_exponent = default_display_exponent; + + + /* Windows really hates command lines, so we have to set up our own argv. + * Note that we do NOT bother with quoted arguments here, so don't use + * filenames with spaces in 'em! */ + + argv[argc++] = PROGNAME; + p = cmd; + for (;;) { + if (*p == ' ') + while (*++p == ' ') + ; + /* now p points at the first non-space after some spaces */ + if (*p == '\0') + break; /* nothing after the spaces: done */ + argv[argc++] = q = p; + while (*q && *q != ' ') + ++q; + /* now q points at a space or the end of the string */ + if (*q == '\0') + break; /* last argv already terminated; quit */ + *q = '\0'; /* change space to terminator */ + p = q + 1; + } + argv[argc] = NULL; /* terminate the argv array itself */ + + + /* Now parse the command line for options and the PNG filename. */ + + while (*++argv && !error) { + if (!strncmp(*argv, "-gamma", 2)) { + if (!*++argv) + ++error; + else { + rpng2_info.display_exponent = atof(*argv); + if (rpng2_info.display_exponent <= 0.0) + ++error; + } + } else if (!strncmp(*argv, "-bgcolor", 4)) { + if (!*++argv) + ++error; + else { + bgstr = *argv; + if (strlen(bgstr) != 7 || bgstr[0] != '#') + ++error; + else { + have_bg = TRUE; + bg_image = FALSE; + } + } + } else if (!strncmp(*argv, "-bgpat", 4)) { + if (!*++argv) + ++error; + else { + pat = atoi(*argv) - 1; + if (pat < 0 || pat >= num_bgpat) + ++error; + else { + bg_image = TRUE; + have_bg = FALSE; + } + } + } else if (!strncmp(*argv, "-timing", 2)) { + timing = TRUE; +#if (defined(__i386__) || defined(_M_IX86)) + } else if (!strncmp(*argv, "-nommxfilters", 7)) { + rpng2_info.nommxfilters = TRUE; + } else if (!strncmp(*argv, "-nommxcombine", 7)) { + rpng2_info.nommxcombine = TRUE; + } else if (!strncmp(*argv, "-nommxinterlace", 7)) { + rpng2_info.nommxinterlace = TRUE; + } else if (!strcmp(*argv, "-nommx")) { + rpng2_info.nommxfilters = TRUE; + rpng2_info.nommxcombine = TRUE; + rpng2_info.nommxinterlace = TRUE; +#endif + } else { + if (**argv != '-') { + filename = *argv; + if (argv[1]) /* shouldn't be any more args after filename */ + ++error; + } else + ++error; /* not expecting any other options */ + } + } + + if (!filename) { + ++error; + } else if (!(infile = fopen(filename, "rb"))) { + fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); + ++error; + } else { + incount = fread(inbuf, 1, INBUFSIZE, infile); + if (incount < 8 || !readpng2_check_sig(inbuf, 8)) { + fprintf(stderr, PROGNAME + ": [%s] is not a PNG file: incorrect signature\n", + filename); + ++error; + } else if ((rc = readpng2_init(&rpng2_info)) != 0) { + switch (rc) { + case 2: + fprintf(stderr, PROGNAME + ": [%s] has bad IHDR (libpng longjmp)\n", + filename); + break; + case 4: + fprintf(stderr, PROGNAME ": insufficient memory\n"); + break; + default: + fprintf(stderr, PROGNAME + ": unknown readpng2_init() error\n"); + break; + } + ++error; + } + if (error) + fclose(infile); + } + + + /* usage screen */ + + if (error) { + int ch; + + fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); + readpng2_version_info(); + fprintf(stderr, "\n" + "Usage: %s [-gamma exp] [-bgcolor bg | -bgpat pat] [-timing]\n" +#if (defined(__i386__) || defined(_M_IX86)) + " %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n" +#endif + " %*s file.png\n\n" + " exp \ttransfer-function exponent (``gamma'') of the display\n" + "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" + "\t\t to the product of the lookup-table exponent (varies)\n" + "\t\t and the CRT exponent (usually 2.2); must be positive\n" + " bg \tdesired background color in 7-character hex RGB format\n" + "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" + "\t\t used with transparent images; overrides -bgpat option\n" + " pat \tdesired background pattern number (1-%d); used with\n" + "\t\t transparent images; overrides -bgcolor option\n" + " -timing\tenables delay for every block read, to simulate modem\n" + "\t\t download of image (~36 Kbps)\n" +#if (defined(__i386__) || defined(_M_IX86)) + " -nommx*\tdisable optimized MMX routines for decoding row filters,\n" + "\t\t combining rows, and expanding interlacing, respectively\n" +#endif + "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" + "Press Q or Esc to quit this usage screen. ", + PROGNAME, +#if (defined(__i386__) || defined(_M_IX86)) + strlen(PROGNAME), " ", +#endif + strlen(PROGNAME), " ", default_display_exponent, num_bgpat); + fflush(stderr); + do + ch = _getch(); + while (ch != 'q' && ch != 'Q' && ch != 0x1B); + exit(1); + } else { + fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); + fprintf(stderr, + "\n [console window: closing this window will terminate %s]\n\n", + PROGNAME); + fflush(stderr); + } + + + /* set the title-bar string, but make sure buffer doesn't overflow */ + + alen = strlen(appname); + flen = strlen(filename); + if (alen + flen + 3 > 1023) + sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); + else + sprintf(titlebar, "%s: %s", appname, filename); + + + /* set some final rpng2_info variables before entering main data loop */ + + if (have_bg) { + unsigned r, g, b; /* this approach quiets compiler warnings */ + + sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); + rpng2_info.bg_red = (uch)r; + rpng2_info.bg_green = (uch)g; + rpng2_info.bg_blue = (uch)b; + } else + rpng2_info.need_bgcolor = TRUE; + + rpng2_info.done = FALSE; + rpng2_info.mainprog_init = rpng2_win_init; + rpng2_info.mainprog_display_row = rpng2_win_display_row; + rpng2_info.mainprog_finish_display = rpng2_win_finish_display; + + + /* OK, this is the fun part: call readpng2_decode_data() at the start of + * the loop to deal with our first buffer of data (read in above to verify + * that the file is a PNG image), then loop through the file and continue + * calling the same routine to handle each chunk of data. It in turn + * passes the data to libpng, which will invoke one or more of our call- + * backs as decoded data become available. We optionally call Sleep() for + * one second per iteration to simulate downloading the image via an analog + * modem. */ + + for (;;) { + Trace((stderr, "about to call readpng2_decode_data()\n")) + if (readpng2_decode_data(&rpng2_info, inbuf, incount)) + ++error; + Trace((stderr, "done with readpng2_decode_data()\n")) + if (error || feof(infile) || rpng2_info.done) + break; + if (timing) + Sleep(1000L); + incount = fread(inbuf, 1, INBUFSIZE, infile); + } + + + /* clean up PNG stuff and report any decoding errors */ + + fclose(infile); + Trace((stderr, "about to call readpng2_cleanup()\n")) + readpng2_cleanup(&rpng2_info); + + if (error) { + fprintf(stderr, PROGNAME ": libpng error while decoding PNG image\n"); + exit(3); + } + + + /* wait for the user to tell us when to quit */ + + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + + /* we're done: clean up all image and Windows resources and go away */ + + Trace((stderr, "about to call rpng2_win_cleanup()\n")) + rpng2_win_cleanup(); + + return msg.wParam; +} + + + + + +/* this function is called by readpng2_info_callback() in readpng2.c, which + * in turn is called by libpng after all of the pre-IDAT chunks have been + * read and processed--i.e., we now have enough info to finish initializing */ + +static void rpng2_win_init() +{ + ulg i; + ulg rowbytes = rpng2_info.rowbytes; + + Trace((stderr, "beginning rpng2_win_init()\n")) + Trace((stderr, " rowbytes = %ld\n", rpng2_info.rowbytes)) + Trace((stderr, " width = %ld\n", rpng2_info.width)) + Trace((stderr, " height = %ld\n", rpng2_info.height)) + + rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height); + if (!rpng2_info.image_data) { + readpng2_cleanup(&rpng2_info); + return; + } + + rpng2_info.row_pointers = (uch **)malloc(rpng2_info.height * sizeof(uch *)); + if (!rpng2_info.row_pointers) { + free(rpng2_info.image_data); + rpng2_info.image_data = NULL; + readpng2_cleanup(&rpng2_info); + return; + } + + for (i = 0; i < rpng2_info.height; ++i) + rpng2_info.row_pointers[i] = rpng2_info.image_data + i*rowbytes; + +/*--------------------------------------------------------------------------- + Do the basic Windows initialization stuff, make the window, and fill it + with the user-specified, file-specified or default background color. + ---------------------------------------------------------------------------*/ + + if (rpng2_win_create_window()) { + readpng2_cleanup(&rpng2_info); + return; + } +} + + + + + +static int rpng2_win_create_window() +{ + uch bg_red = rpng2_info.bg_red; + uch bg_green = rpng2_info.bg_green; + uch bg_blue = rpng2_info.bg_blue; + uch *dest; + int extra_width, extra_height; + ulg i, j; + WNDCLASSEX wndclass; + RECT rect; + + +/*--------------------------------------------------------------------------- + Allocate memory for the display-specific version of the image (round up + to multiple of 4 for Windows DIB). + ---------------------------------------------------------------------------*/ + + wimage_rowbytes = ((3*rpng2_info.width + 3L) >> 2) << 2; + + if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) + + wimage_rowbytes*rpng2_info.height))) + { + return 4; /* fail */ + } + +/*--------------------------------------------------------------------------- + Initialize the DIB. Negative height means to use top-down BMP ordering + (must be uncompressed, but that's what we want). Bit count of 1, 4 or 8 + implies a colormap of RGBX quads, but 24-bit BMPs just use B,G,R values + directly => wimage_data begins immediately after BMP header. + ---------------------------------------------------------------------------*/ + + memset(dib, 0, sizeof(BITMAPINFOHEADER)); + bmih = (BITMAPINFOHEADER *)dib; + bmih->biSize = sizeof(BITMAPINFOHEADER); + bmih->biWidth = rpng2_info.width; + bmih->biHeight = -((long)rpng2_info.height); + bmih->biPlanes = 1; + bmih->biBitCount = 24; + bmih->biCompression = 0; + wimage_data = dib + sizeof(BITMAPINFOHEADER); + +/*--------------------------------------------------------------------------- + Fill window with the specified background color (default is black), but + defer loading faked "background image" until window is displayed (may be + slow to compute). Data are in BGR order. + ---------------------------------------------------------------------------*/ + + if (bg_image) { /* just fill with black for now */ + memset(wimage_data, 0, wimage_rowbytes*rpng2_info.height); + } else { + for (j = 0; j < rpng2_info.height; ++j) { + dest = wimage_data + j*wimage_rowbytes; + for (i = rpng2_info.width; i > 0; --i) { + *dest++ = bg_blue; + *dest++ = bg_green; + *dest++ = bg_red; + } + } + } + +/*--------------------------------------------------------------------------- + Set the window parameters. + ---------------------------------------------------------------------------*/ + + memset(&wndclass, 0, sizeof(wndclass)); + + wndclass.cbSize = sizeof(wndclass); + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = rpng2_win_wndproc; + wndclass.hInstance = global_hInst; + wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH); + wndclass.lpszMenuName = NULL; + wndclass.lpszClassName = progname; + wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + + RegisterClassEx(&wndclass); + +/*--------------------------------------------------------------------------- + Finally, create the window. + ---------------------------------------------------------------------------*/ + + extra_width = 2*(GetSystemMetrics(SM_CXBORDER) + + GetSystemMetrics(SM_CXDLGFRAME)); + extra_height = 2*(GetSystemMetrics(SM_CYBORDER) + + GetSystemMetrics(SM_CYDLGFRAME)) + + GetSystemMetrics(SM_CYCAPTION); + + global_hwnd = CreateWindow(progname, titlebar, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, rpng2_info.width+extra_width, + rpng2_info.height+extra_height, NULL, NULL, global_hInst, NULL); + + ShowWindow(global_hwnd, global_showmode); + UpdateWindow(global_hwnd); + +/*--------------------------------------------------------------------------- + Now compute the background image and display it. If it fails (memory + allocation), revert to a plain background color. + ---------------------------------------------------------------------------*/ + + if (bg_image) { + static const char *msg = "Computing background image..."; + int x, y, len = strlen(msg); + HDC hdc = GetDC(global_hwnd); + TEXTMETRIC tm; + + GetTextMetrics(hdc, &tm); + x = (rpng2_info.width - len*tm.tmAveCharWidth)/2; + y = (rpng2_info.height - tm.tmHeight)/2; + SetBkMode(hdc, TRANSPARENT); + SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); + /* this can still begin out of bounds even if x is positive (???): */ + TextOut(hdc, ((x < 0)? 0 : x), ((y < 0)? 0 : y), msg, len); + ReleaseDC(global_hwnd, hdc); + + rpng2_win_load_bg_image(); /* resets bg_image if fails */ + } + + if (!bg_image) { + for (j = 0; j < rpng2_info.height; ++j) { + dest = wimage_data + j*wimage_rowbytes; + for (i = rpng2_info.width; i > 0; --i) { + *dest++ = bg_blue; + *dest++ = bg_green; + *dest++ = bg_red; + } + } + } + + rect.left = 0L; + rect.top = 0L; + rect.right = (LONG)rpng2_info.width; /* possibly off by one? */ + rect.bottom = (LONG)rpng2_info.height; /* possibly off by one? */ + InvalidateRect(global_hwnd, &rect, FALSE); + UpdateWindow(global_hwnd); /* similar to XFlush() */ + + return 0; + +} /* end function rpng2_win_create_window() */ + + + + + +static int rpng2_win_load_bg_image() +{ + uch *src, *dest; + uch r1, r2, g1, g2, b1, b2; + uch r1_inv, r2_inv, g1_inv, g2_inv, b1_inv, b2_inv; + int k, hmax, max; + int xidx, yidx, yidx_max = (bgscale-1); + int even_odd_vert, even_odd_horiz, even_odd; + int invert_gradient2 = (bg[pat].type & 0x08); + int invert_column; + ulg i, row; + +/*--------------------------------------------------------------------------- + Allocate buffer for fake background image to be used with transparent + images; if this fails, revert to plain background color. + ---------------------------------------------------------------------------*/ + + bg_rowbytes = 3 * rpng2_info.width; + bg_data = (uch *)malloc(bg_rowbytes * rpng2_info.height); + if (!bg_data) { + fprintf(stderr, PROGNAME + ": unable to allocate memory for background image\n"); + bg_image = 0; + return 1; + } + +/*--------------------------------------------------------------------------- + Vertical gradients (ramps) in NxN squares, alternating direction and + colors (N == bgscale). + ---------------------------------------------------------------------------*/ + + if ((bg[pat].type & 0x07) == 0) { + uch r1_min = rgb[bg[pat].rgb1_min].r; + uch g1_min = rgb[bg[pat].rgb1_min].g; + uch b1_min = rgb[bg[pat].rgb1_min].b; + uch r2_min = rgb[bg[pat].rgb2_min].r; + uch g2_min = rgb[bg[pat].rgb2_min].g; + uch b2_min = rgb[bg[pat].rgb2_min].b; + int r1_diff = rgb[bg[pat].rgb1_max].r - r1_min; + int g1_diff = rgb[bg[pat].rgb1_max].g - g1_min; + int b1_diff = rgb[bg[pat].rgb1_max].b - b1_min; + int r2_diff = rgb[bg[pat].rgb2_max].r - r2_min; + int g2_diff = rgb[bg[pat].rgb2_max].g - g2_min; + int b2_diff = rgb[bg[pat].rgb2_max].b - b2_min; + + for (row = 0; row < rpng2_info.height; ++row) { + yidx = row % bgscale; + even_odd_vert = (row / bgscale) & 1; + + r1 = r1_min + (r1_diff * yidx) / yidx_max; + g1 = g1_min + (g1_diff * yidx) / yidx_max; + b1 = b1_min + (b1_diff * yidx) / yidx_max; + r1_inv = r1_min + (r1_diff * (yidx_max-yidx)) / yidx_max; + g1_inv = g1_min + (g1_diff * (yidx_max-yidx)) / yidx_max; + b1_inv = b1_min + (b1_diff * (yidx_max-yidx)) / yidx_max; + + r2 = r2_min + (r2_diff * yidx) / yidx_max; + g2 = g2_min + (g2_diff * yidx) / yidx_max; + b2 = b2_min + (b2_diff * yidx) / yidx_max; + r2_inv = r2_min + (r2_diff * (yidx_max-yidx)) / yidx_max; + g2_inv = g2_min + (g2_diff * (yidx_max-yidx)) / yidx_max; + b2_inv = b2_min + (b2_diff * (yidx_max-yidx)) / yidx_max; + + dest = bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + even_odd_horiz = (i / bgscale) & 1; + even_odd = even_odd_vert ^ even_odd_horiz; + invert_column = + (even_odd_horiz && (bg[pat].type & 0x10)); + if (even_odd == 0) { /* gradient #1 */ + if (invert_column) { + *dest++ = r1_inv; + *dest++ = g1_inv; + *dest++ = b1_inv; + } else { + *dest++ = r1; + *dest++ = g1; + *dest++ = b1; + } + } else { /* gradient #2 */ + if ((invert_column && invert_gradient2) || + (!invert_column && !invert_gradient2)) + { + *dest++ = r2; /* not inverted or */ + *dest++ = g2; /* doubly inverted */ + *dest++ = b2; + } else { + *dest++ = r2_inv; + *dest++ = g2_inv; /* singly inverted */ + *dest++ = b2_inv; + } + } + } + } + +/*--------------------------------------------------------------------------- + Soft gradient-diamonds with scale = bgscale. Code contributed by Adam + M. Costello. + ---------------------------------------------------------------------------*/ + + } else if ((bg[pat].type & 0x07) == 1) { + + hmax = (bgscale-1)/2; /* half the max weight of a color */ + max = 2*hmax; /* the max weight of a color */ + + r1 = rgb[bg[pat].rgb1_max].r; + g1 = rgb[bg[pat].rgb1_max].g; + b1 = rgb[bg[pat].rgb1_max].b; + r2 = rgb[bg[pat].rgb2_max].r; + g2 = rgb[bg[pat].rgb2_max].g; + b2 = rgb[bg[pat].rgb2_max].b; + + for (row = 0; row < rpng2_info.height; ++row) { + yidx = row % bgscale; + if (yidx > hmax) + yidx = bgscale-1 - yidx; + dest = bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + xidx = i % bgscale; + if (xidx > hmax) + xidx = bgscale-1 - xidx; + k = xidx + yidx; + *dest++ = (k*r1 + (max-k)*r2) / max; + *dest++ = (k*g1 + (max-k)*g2) / max; + *dest++ = (k*b1 + (max-k)*b2) / max; + } + } + +/*--------------------------------------------------------------------------- + Radial "starburst" with azimuthal sinusoids; [eventually number of sinu- + soids will equal bgscale?]. This one is slow but very cool. Code con- + tributed by Pieter S. van der Meulen (originally in Smalltalk). + ---------------------------------------------------------------------------*/ + + } else if ((bg[pat].type & 0x07) == 2) { + uch ch; + int ii, x, y, hw, hh, grayspot; + double freq, rotate, saturate, gray, intensity; + double angle=0.0, aoffset=0.0, maxDist, dist; + double red=0.0, green=0.0, blue=0.0, hue, s, v, f, p, q, t; + + fprintf(stderr, "%s: computing radial background...", + PROGNAME); + fflush(stderr); + + hh = rpng2_info.height / 2; + hw = rpng2_info.width / 2; + + /* variables for radial waves: + * aoffset: number of degrees to rotate hue [CURRENTLY NOT USED] + * freq: number of color beams originating from the center + * grayspot: size of the graying center area (anti-alias) + * rotate: rotation of the beams as a function of radius + * saturate: saturation of beams' shape azimuthally + */ + angle = CLIP(angle, 0.0, 360.0); + grayspot = CLIP(bg[pat].bg_gray, 1, (hh + hw)); + freq = MAX((double)bg[pat].bg_freq, 0.0); + saturate = (double)bg[pat].bg_bsat * 0.1; + rotate = (double)bg[pat].bg_brot * 0.1; + gray = 0.0; + intensity = 0.0; + maxDist = (double)((hw*hw) + (hh*hh)); + + for (row = 0; row < rpng2_info.height; ++row) { + y = row - hh; + dest = bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + x = i - hw; + angle = (x == 0)? PI_2 : atan((double)y / (double)x); + gray = (double)MAX(ABS(y), ABS(x)) / grayspot; + gray = MIN(1.0, gray); + dist = (double)((x*x) + (y*y)) / maxDist; + intensity = cos((angle+(rotate*dist*PI)) * freq) * + gray * saturate; + intensity = (MAX(MIN(intensity,1.0),-1.0) + 1.0) * 0.5; + hue = (angle + PI) * INV_PI_360 + aoffset; + s = gray * ((double)(ABS(x)+ABS(y)) / (double)(hw + hh)); + s = MIN(MAX(s,0.0), 1.0); + v = MIN(MAX(intensity,0.0), 1.0); + + if (s == 0.0) { + ch = (uch)(v * 255.0); + *dest++ = ch; + *dest++ = ch; + *dest++ = ch; + } else { + if ((hue < 0.0) || (hue >= 360.0)) + hue -= (((int)(hue / 360.0)) * 360.0); + hue /= 60.0; + ii = (int)hue; + f = hue - (double)ii; + p = (1.0 - s) * v; + q = (1.0 - (s * f)) * v; + t = (1.0 - (s * (1.0 - f))) * v; + if (ii == 0) { red = v; green = t; blue = p; } + else if (ii == 1) { red = q; green = v; blue = p; } + else if (ii == 2) { red = p; green = v; blue = t; } + else if (ii == 3) { red = p; green = q; blue = v; } + else if (ii == 4) { red = t; green = p; blue = v; } + else if (ii == 5) { red = v; green = p; blue = q; } + *dest++ = (uch)(red * 255.0); + *dest++ = (uch)(green * 255.0); + *dest++ = (uch)(blue * 255.0); + } + } + } + fprintf(stderr, "done.\n"); + fflush(stderr); + } + +/*--------------------------------------------------------------------------- + Blast background image to display buffer before beginning PNG decode; + calling function will handle invalidation and UpdateWindow() call. + ---------------------------------------------------------------------------*/ + + for (row = 0; row < rpng2_info.height; ++row) { + src = bg_data + row*bg_rowbytes; + dest = wimage_data + row*wimage_rowbytes; + for (i = rpng2_info.width; i > 0; --i) { + r1 = *src++; + g1 = *src++; + b1 = *src++; + *dest++ = b1; + *dest++ = g1; /* note reverse order */ + *dest++ = r1; + } + } + + return 0; + +} /* end function rpng2_win_load_bg_image() */ + + + + + +static void rpng2_win_display_row(ulg row) +{ + uch bg_red = rpng2_info.bg_red; + uch bg_green = rpng2_info.bg_green; + uch bg_blue = rpng2_info.bg_blue; + uch *src, *src2=NULL, *dest; + uch r, g, b, a; + ulg i; + static int rows=0; + static ulg firstrow; + +/*--------------------------------------------------------------------------- + rows and firstrow simply track how many rows (and which ones) have not + yet been displayed; alternatively, we could call InvalidateRect() for + every row and not bother with the records-keeping. + ---------------------------------------------------------------------------*/ + + Trace((stderr, "beginning rpng2_win_display_row()\n")) + + if (rows == 0) + firstrow = row; /* first row not yet displayed */ + + ++rows; /* count of rows received but not yet displayed */ + +/*--------------------------------------------------------------------------- + Aside from the use of the rpng2_info struct and the lack of an outer + loop (over rows), this routine is identical to rpng_win_display_image() + in the non-progressive version of the program. + ---------------------------------------------------------------------------*/ + + src = rpng2_info.image_data + row*rpng2_info.rowbytes; + if (bg_image) + src2 = bg_data + row*bg_rowbytes; + dest = wimage_data + row*wimage_rowbytes; + + if (rpng2_info.channels == 3) { + for (i = rpng2_info.width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + *dest++ = b; + *dest++ = g; /* note reverse order */ + *dest++ = r; + } + } else /* if (rpng2_info.channels == 4) */ { + for (i = rpng2_info.width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + a = *src++; + if (bg_image) { + bg_red = *src2++; + bg_green = *src2++; + bg_blue = *src2++; + } + if (a == 255) { + *dest++ = b; + *dest++ = g; + *dest++ = r; + } else if (a == 0) { + *dest++ = bg_blue; + *dest++ = bg_green; + *dest++ = bg_red; + } else { + /* this macro (copied from png.h) composites the + * foreground and background values and puts the + * result into the first argument; there are no + * side effects with the first argument */ + alpha_composite(*dest++, b, a, bg_blue); + alpha_composite(*dest++, g, a, bg_green); + alpha_composite(*dest++, r, a, bg_red); + } + } + } + +/*--------------------------------------------------------------------------- + Display after every 16 rows or when on last row. (Region may include + previously displayed lines due to interlacing--i.e., not contiguous.) + ---------------------------------------------------------------------------*/ + + if ((rows & 0xf) == 0 || row == rpng2_info.height-1) { + RECT rect; + + rect.left = 0L; + rect.top = (LONG)firstrow; + rect.right = (LONG)rpng2_info.width; /* possibly off by one? */ + rect.bottom = (LONG)row + 1L; /* possibly off by one? */ + InvalidateRect(global_hwnd, &rect, FALSE); + UpdateWindow(global_hwnd); /* similar to XFlush() */ + rows = 0; + } + +} /* end function rpng2_win_display_row() */ + + + + + +static void rpng2_win_finish_display() +{ + Trace((stderr, "beginning rpng2_win_finish_display()\n")) + + /* last row has already been displayed by rpng2_win_display_row(), so + * we have nothing to do here except set a flag and let the user know + * that the image is done */ + + rpng2_info.done = TRUE; + printf( + "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); + fflush(stdout); +} + + + + + +static void rpng2_win_cleanup() +{ + if (bg_image && bg_data) { + free(bg_data); + bg_data = NULL; + } + + if (rpng2_info.image_data) { + free(rpng2_info.image_data); + rpng2_info.image_data = NULL; + } + + if (rpng2_info.row_pointers) { + free(rpng2_info.row_pointers); + rpng2_info.row_pointers = NULL; + } + + if (dib) { + free(dib); + dib = NULL; + } +} + + + + + +LRESULT CALLBACK rpng2_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP) +{ + HDC hdc; + PAINTSTRUCT ps; + int rc; + + switch (iMsg) { + case WM_CREATE: + /* one-time processing here, if any */ + return 0; + + case WM_PAINT: + hdc = BeginPaint(hwnd, &ps); + rc = StretchDIBits(hdc, 0, 0, rpng2_info.width, rpng2_info.height, + 0, 0, rpng2_info.width, rpng2_info.height, + wimage_data, (BITMAPINFO *)bmih, + 0, SRCCOPY); + EndPaint(hwnd, &ps); + return 0; + + /* wait for the user to tell us when to quit */ + case WM_CHAR: + switch (wP) { /* only need one, so ignore repeat count */ + case 'q': + case 'Q': + case 0x1B: /* Esc key */ + PostQuitMessage(0); + } + return 0; + + case WM_LBUTTONDOWN: /* another way of quitting */ + case WM_DESTROY: + PostQuitMessage(0); + return 0; + } + + return DefWindowProc(hwnd, iMsg, wP, lP); +} diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng2-x.c b/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng2-x.c index 2e30bd1..5fc29ea 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng2-x.c +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/rpng2-x.c @@ -1,1408 +1,1408 @@ -/*--------------------------------------------------------------------------- - - rpng2 - progressive-model PNG display program rpng2-x.c - - This program decodes and displays PNG files progressively, as if it were - a web browser (though the front end is only set up to read from files). - It supports gamma correction, user-specified background colors, and user- - specified background patterns (for transparent images). This version is - for the X Window System (tested by the author under Unix and by Martin - Zinser under OpenVMS; may work under OS/2 with a little tweaking). - - Thanks to Adam Costello and Pieter S. van der Meulen for the "diamond" - and "radial waves" patterns, respectively. - - to do: - - 8-bit support - - finish resizable checkerboard-gradient (sizes 4-128?) - - use %.1023s to simplify truncation of title-bar string? - - --------------------------------------------------------------------------- - - Changelog: - - 1.01: initial public release - - 1.02: modified to allow abbreviated options; fixed char/uchar mismatch - - 1.10: added support for non-default visuals; fixed X pixel-conversion - - 1.11: added -usleep option for demos; fixed command-line parsing bug - - 1.12: added -pause option for demos and testing - - 1.20: added runtime MMX-enabling/disabling and new -mmx* options - - 1.21: fixed small X memory leak (thanks to Francois Petitjean) - - 1.22: fixed XFreeGC() crash bug - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#define PROGNAME "rpng2-x" -#define LONGNAME "Progressive PNG Viewer for X" -#define VERSION "1.22 of 16 August 2001" - -#include -#include -#include -#include /* for jmpbuf declaration in readpng2.h */ -#include -#include /* only for PvdM background code */ -#include -#include -#include -#include /* defines XK_* macros */ - -#ifdef VMS -# include -#endif - -/* all for PvdM background code: */ -#ifndef PI -# define PI 3.141592653589793238 -#endif -#define PI_2 (PI*0.5) -#define INV_PI_360 (360.0 / PI) -#define MAX(a,b) (a>b?a:b) -#define MIN(a,b) (a> 8)) >> 8); \ -} - - -#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this - * block size corresponds roughly to a download - * speed 10% faster than theoretical 33.6K maximum - * (assuming 8 data bits, 1 stop bit and no other - * overhead) */ - -/* local prototypes */ -static void rpng2_x_init(void); -static int rpng2_x_create_window(void); -static int rpng2_x_load_bg_image(void); -static void rpng2_x_display_row(ulg row); -static void rpng2_x_finish_display(void); -static void rpng2_x_cleanup(void); -static int rpng2_x_msb(ulg u32val); - - -static char titlebar[1024], *window_name = titlebar; -static char *appname = LONGNAME; -static char *icon_name = PROGNAME; -static char *filename; -static FILE *infile; - -static mainprog_info rpng2_info; - -static uch inbuf[INBUFSIZE]; -static int incount; - -static int pat = 6; /* must be less than num_bgpat */ -static int bg_image = 0; -static int bgscale = 16; -static ulg bg_rowbytes; -static uch *bg_data; - -int pause_after_pass = FALSE; -int demo_timing = FALSE; -ulg usleep_duration = 0L; - -static struct rgb_color { - uch r, g, b; -} rgb[] = { - { 0, 0, 0}, /* 0: black */ - {255, 255, 255}, /* 1: white */ - {173, 132, 57}, /* 2: tan */ - { 64, 132, 0}, /* 3: medium green */ - {189, 117, 1}, /* 4: gold */ - {253, 249, 1}, /* 5: yellow */ - { 0, 0, 255}, /* 6: blue */ - { 0, 0, 120}, /* 7: medium blue */ - {255, 0, 255}, /* 8: magenta */ - { 64, 0, 64}, /* 9: dark magenta */ - {255, 0, 0}, /* 10: red */ - { 64, 0, 0}, /* 11: dark red */ - {255, 127, 0}, /* 12: orange */ - {192, 96, 0}, /* 13: darker orange */ - { 24, 60, 0}, /* 14: dark green-yellow */ - { 85, 125, 200} /* 15: ice blue */ -}; -/* not used for now, but should be for error-checking: -static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color); - */ - -/* - This whole struct is a fairly cheesy way to keep the number of - command-line options to a minimum. The radial-waves background - type is a particularly poor fit to the integer elements of the - struct...but a few macros and a little fixed-point math will do - wonders for ya. - - type bits: - F E D C B A 9 8 7 6 5 4 3 2 1 0 - | | | | | - | | +-+-+-- 0 = sharp-edged checkerboard - | | 1 = soft diamonds - | | 2 = radial waves - | | 3-7 = undefined - | +-- gradient #2 inverted? - +-- alternating columns inverted? - */ -static struct background_pattern { - ush type; - int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */ - int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/ -} bg[] = { - {0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */ - {0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */ - {0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */ - {0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */ - {0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */ - {0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */ - {0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */ - {1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */ - {1, 12,0, 11,0}, /* diamonds: orange vs. dark red */ - {1, 10,0, 7,0}, /* diamonds: red vs. medium blue */ - {1, 4,0, 5,0}, /* diamonds: gold vs. yellow */ - {1, 3,0, 0,0}, /* diamonds: medium green vs. black */ - {2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */ - {2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */ - {2, 16, 256, 100, 250}, /* radial: very tight spiral */ - {2, 10000, 256, 11, 0} /* radial: dipole-moire' (almost fractal) */ -}; -static int num_bgpat = sizeof(bg) / sizeof(struct background_pattern); - - -/* X-specific variables */ -static char *displayname; -static XImage *ximage; -static Display *display; -static int depth; -static Visual *visual; -static XVisualInfo *visual_list; -static int RShift, GShift, BShift; -static ulg RMask, GMask, BMask; -static Window window; -static GC gc; -static Colormap colormap; - -static int have_nondefault_visual = FALSE; -static int have_colormap = FALSE; -static int have_window = FALSE; -static int have_gc = FALSE; - - - - -int main(int argc, char **argv) -{ -#ifdef sgi - char tmpline[80]; -#endif - char *p, *bgstr = NULL; - int rc, alen, flen; - int error = 0; - int timing = FALSE; - int have_bg = FALSE; - double LUT_exponent; /* just the lookup table */ - double CRT_exponent = 2.2; /* just the monitor */ - double default_display_exponent; /* whole display system */ - XEvent e; - KeySym k; - - - /* First initialize a few things, just to be sure--memset takes care of - * default background color (black), booleans (FALSE), pointers (NULL), - * etc. */ - - displayname = (char *)NULL; - filename = (char *)NULL; - memset(&rpng2_info, 0, sizeof(mainprog_info)); - - - /* Set the default value for our display-system exponent, i.e., the - * product of the CRT exponent and the exponent corresponding to - * the frame-buffer's lookup table (LUT), if any. This is not an - * exhaustive list of LUT values (e.g., OpenStep has a lot of weird - * ones), but it should cover 99% of the current possibilities. */ - -#if defined(NeXT) - /* third-party utilities can modify the default LUT exponent */ - LUT_exponent = 1.0 / 2.2; - /* - if (some_next_function_that_returns_gamma(&next_gamma)) - LUT_exponent = 1.0 / next_gamma; - */ -#elif defined(sgi) - LUT_exponent = 1.0 / 1.7; - /* there doesn't seem to be any documented function to - * get the "gamma" value, so we do it the hard way */ - infile = fopen("/etc/config/system.glGammaVal", "r"); - if (infile) { - double sgi_gamma; - - fgets(tmpline, 80, infile); - fclose(infile); - sgi_gamma = atof(tmpline); - if (sgi_gamma > 0.0) - LUT_exponent = 1.0 / sgi_gamma; - } -#elif defined(Macintosh) - LUT_exponent = 1.8 / 2.61; - /* - if (some_mac_function_that_returns_gamma(&mac_gamma)) - LUT_exponent = mac_gamma / 2.61; - */ -#else - LUT_exponent = 1.0; /* assume no LUT: most PCs */ -#endif - - /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ - default_display_exponent = LUT_exponent * CRT_exponent; - - - /* If the user has set the SCREEN_GAMMA environment variable as suggested - * (somewhat imprecisely) in the libpng documentation, use that; otherwise - * use the default value we just calculated. Either way, the user may - * override this via a command-line option. */ - - if ((p = getenv("SCREEN_GAMMA")) != NULL) - rpng2_info.display_exponent = atof(p); - else - rpng2_info.display_exponent = default_display_exponent; - - - /* Now parse the command line for options and the PNG filename. */ - - while (*++argv && !error) { - if (!strncmp(*argv, "-display", 2)) { - if (!*++argv) - ++error; - else - displayname = *argv; - } else if (!strncmp(*argv, "-gamma", 2)) { - if (!*++argv) - ++error; - else { - rpng2_info.display_exponent = atof(*argv); - if (rpng2_info.display_exponent <= 0.0) - ++error; - } - } else if (!strncmp(*argv, "-bgcolor", 4)) { - if (!*++argv) - ++error; - else { - bgstr = *argv; - if (strlen(bgstr) != 7 || bgstr[0] != '#') - ++error; - else { - have_bg = TRUE; - bg_image = FALSE; - } - } - } else if (!strncmp(*argv, "-bgpat", 4)) { - if (!*++argv) - ++error; - else { - pat = atoi(*argv) - 1; - if (pat < 0 || pat >= num_bgpat) - ++error; - else { - bg_image = TRUE; - have_bg = FALSE; - } - } - } else if (!strncmp(*argv, "-usleep", 2)) { - if (!*++argv) - ++error; - else { - usleep_duration = (ulg)atol(*argv); - demo_timing = TRUE; - } - } else if (!strncmp(*argv, "-pause", 2)) { - pause_after_pass = TRUE; - } else if (!strncmp(*argv, "-timing", 2)) { - timing = TRUE; -#if (defined(__i386__) || defined(_M_IX86)) - } else if (!strncmp(*argv, "-nommxfilters", 7)) { - rpng2_info.nommxfilters = TRUE; - } else if (!strncmp(*argv, "-nommxcombine", 7)) { - rpng2_info.nommxcombine = TRUE; - } else if (!strncmp(*argv, "-nommxinterlace", 7)) { - rpng2_info.nommxinterlace = TRUE; - } else if (!strcmp(*argv, "-nommx")) { - rpng2_info.nommxfilters = TRUE; - rpng2_info.nommxcombine = TRUE; - rpng2_info.nommxinterlace = TRUE; -#endif - } else { - if (**argv != '-') { - filename = *argv; - if (argv[1]) /* shouldn't be any more args after filename */ - ++error; - } else - ++error; /* not expecting any other options */ - } - } - - if (!filename) { - ++error; - } else if (!(infile = fopen(filename, "rb"))) { - fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); - ++error; - } else { - incount = fread(inbuf, 1, INBUFSIZE, infile); - if (incount < 8 || !readpng2_check_sig(inbuf, 8)) { - fprintf(stderr, PROGNAME - ": [%s] is not a PNG file: incorrect signature\n", - filename); - ++error; - } else if ((rc = readpng2_init(&rpng2_info)) != 0) { - switch (rc) { - case 2: - fprintf(stderr, PROGNAME - ": [%s] has bad IHDR (libpng longjmp)\n", - filename); - break; - case 4: - fprintf(stderr, PROGNAME ": insufficient memory\n"); - break; - default: - fprintf(stderr, PROGNAME - ": unknown readpng2_init() error\n"); - break; - } - ++error; - } else { - display = XOpenDisplay(displayname); - if (!display) { - readpng2_cleanup(&rpng2_info); - fprintf(stderr, PROGNAME ": can't open X display [%s]\n", - displayname? displayname : "default"); - ++error; - } - } - if (error) - fclose(infile); - } - - - /* usage screen */ - - if (error) { - fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); - readpng2_version_info(); - fprintf(stderr, "\n" - "Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n" -#if (defined(__i386__) || defined(_M_IX86)) - " %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n" -#endif - " %*s [-usleep dur | -timing] [-pause] file.png\n\n" - " xdpy\tname of the target X display (e.g., ``hostname:0'')\n" - " exp \ttransfer-function exponent (``gamma'') of the display\n" - "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" - "\t\t to the product of the lookup-table exponent (varies)\n" - "\t\t and the CRT exponent (usually 2.2); must be positive\n" - " bg \tdesired background color in 7-character hex RGB format\n" - "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" - "\t\t used with transparent images; overrides -bgpat\n" - " pat \tdesired background pattern number (1-%d); used with\n" - "\t\t transparent images; overrides -bgcolor\n" -#if (defined(__i386__) || defined(_M_IX86)) - " -nommx*\tdisable optimized MMX routines for decoding row filters,\n" - "\t\t combining rows, and expanding interlacing, respectively\n" -#endif - " dur \tduration in microseconds to wait after displaying each\n" - "\t\t row (for demo purposes)\n" - " -timing\tenables delay for every block read, to simulate modem\n" - "\t\t download of image (~36 Kbps)\n" - " -pause\tpauses after displaying each pass until key pressed\n" - "\nPress Q, Esc or mouse button 1 (within image window, after image\n" - "is displayed) to quit.\n" - "\n", PROGNAME, -#if (defined(__i386__) || defined(_M_IX86)) - strlen(PROGNAME), " ", -#endif - strlen(PROGNAME), " ", default_display_exponent, num_bgpat); - exit(1); - } - - - /* set the title-bar string, but make sure buffer doesn't overflow */ - - alen = strlen(appname); - flen = strlen(filename); - if (alen + flen + 3 > 1023) - sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); - else - sprintf(titlebar, "%s: %s", appname, filename); - - - /* set some final rpng2_info variables before entering main data loop */ - - if (have_bg) { - unsigned r, g, b; /* this approach quiets compiler warnings */ - - sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); - rpng2_info.bg_red = (uch)r; - rpng2_info.bg_green = (uch)g; - rpng2_info.bg_blue = (uch)b; - } else - rpng2_info.need_bgcolor = TRUE; - - rpng2_info.done = FALSE; - rpng2_info.mainprog_init = rpng2_x_init; - rpng2_info.mainprog_display_row = rpng2_x_display_row; - rpng2_info.mainprog_finish_display = rpng2_x_finish_display; - - - /* OK, this is the fun part: call readpng2_decode_data() at the start of - * the loop to deal with our first buffer of data (read in above to verify - * that the file is a PNG image), then loop through the file and continue - * calling the same routine to handle each chunk of data. It in turn - * passes the data to libpng, which will invoke one or more of our call- - * backs as decoded data become available. We optionally call sleep() for - * one second per iteration to simulate downloading the image via an analog - * modem. */ - - for (;;) { - Trace((stderr, "about to call readpng2_decode_data()\n")) - if (readpng2_decode_data(&rpng2_info, inbuf, incount)) - ++error; - Trace((stderr, "done with readpng2_decode_data()\n")) - if (error || feof(infile) || rpng2_info.done) - break; - if (timing) - sleep(1); - incount = fread(inbuf, 1, INBUFSIZE, infile); - } - - - /* clean up PNG stuff and report any decoding errors */ - - fclose(infile); - Trace((stderr, "about to call readpng2_cleanup()\n")) - readpng2_cleanup(&rpng2_info); - - if (error) { - fprintf(stderr, PROGNAME ": libpng error while decoding PNG image\n"); - exit(3); - } - - - /* wait for the user to tell us when to quit */ - - do - XNextEvent(display, &e); - while (!(e.type == ButtonPress && e.xbutton.button == Button1) && - !(e.type == KeyPress && /* v--- or 1 for shifted keys */ - ((k = XLookupKeysym(&e.xkey, 0)) == XK_q || k == XK_Escape) )); - - - /* we're done: clean up all image and X resources and go away */ - - Trace((stderr, "about to call rpng2_x_cleanup()\n")) - rpng2_x_cleanup(); - - return 0; -} - - - - - -/* this function is called by readpng2_info_callback() in readpng2.c, which - * in turn is called by libpng after all of the pre-IDAT chunks have been - * read and processed--i.e., we now have enough info to finish initializing */ - -static void rpng2_x_init(void) -{ - ulg i; - ulg rowbytes = rpng2_info.rowbytes; - - Trace((stderr, "beginning rpng2_x_init()\n")) - Trace((stderr, " rowbytes = %ld\n", rpng2_info.rowbytes)) - Trace((stderr, " width = %ld\n", rpng2_info.width)) - Trace((stderr, " height = %ld\n", rpng2_info.height)) - - rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height); - if (!rpng2_info.image_data) { - readpng2_cleanup(&rpng2_info); - return; - } - - rpng2_info.row_pointers = (uch **)malloc(rpng2_info.height * sizeof(uch *)); - if (!rpng2_info.row_pointers) { - free(rpng2_info.image_data); - rpng2_info.image_data = NULL; - readpng2_cleanup(&rpng2_info); - return; - } - - for (i = 0; i < rpng2_info.height; ++i) - rpng2_info.row_pointers[i] = rpng2_info.image_data + i*rowbytes; - - - /* do the basic X initialization stuff, make the window, and fill it with - * the user-specified, file-specified or default background color or - * pattern */ - - if (rpng2_x_create_window()) { - - /* GRR TEMPORARY HACK: this is fundamentally no different from cases - * above; libpng should longjmp() back to us when png_ptr goes away. - * If we/it segfault instead, seems like a libpng bug... */ - - /* we're here via libpng callback, so if window fails, clean and bail */ -printf("readpng2_cleanup.\n"); - readpng2_cleanup(&rpng2_info); - rpng2_x_cleanup(); - exit(2); - } -} - - - - - -static int rpng2_x_create_window(void) -{ - ulg bg_red = rpng2_info.bg_red; - ulg bg_green = rpng2_info.bg_green; - ulg bg_blue = rpng2_info.bg_blue; - ulg bg_pixel = 0L; - ulg attrmask; - int need_colormap = FALSE; - int screen, pad; - uch *xdata; - Window root; - XEvent e; - XGCValues gcvalues; - XSetWindowAttributes attr; - XSizeHints *size_hints; - XTextProperty windowName, *pWindowName = &windowName; - XTextProperty iconName, *pIconName = &iconName; - XVisualInfo visual_info; - XWMHints *wm_hints; - - - Trace((stderr, "beginning rpng2_x_create_window()\n")) - - screen = DefaultScreen(display); - depth = DisplayPlanes(display, screen); - root = RootWindow(display, screen); - -#ifdef DEBUG - XSynchronize(display, True); -#endif - - if (depth != 16 && depth != 24 && depth != 32) { - int visuals_matched = 0; - - Trace((stderr, "default depth is %d: checking other visuals\n", - depth)) - - /* 24-bit first */ - visual_info.screen = screen; - visual_info.depth = 24; - visual_list = XGetVisualInfo(display, - VisualScreenMask | VisualDepthMask, &visual_info, &visuals_matched); - if (visuals_matched == 0) { -/* GRR: add 15-, 16- and 32-bit TrueColor visuals (also DirectColor?) */ - fprintf(stderr, "default screen depth %d not supported, and no" - " 24-bit visuals found\n", depth); - return 2; - } - Trace((stderr, "XGetVisualInfo() returned %d 24-bit visuals\n", - visuals_matched)) - visual = visual_list[0].visual; - depth = visual_list[0].depth; -/* - colormap_size = visual_list[0].colormap_size; - visual_class = visual->class; - visualID = XVisualIDFromVisual(visual); - */ - have_nondefault_visual = TRUE; - need_colormap = TRUE; - } else { - XMatchVisualInfo(display, screen, depth, TrueColor, &visual_info); - visual = visual_info.visual; - } - - RMask = visual->red_mask; - GMask = visual->green_mask; - BMask = visual->blue_mask; - -/* GRR: add/check 8-bit support */ - if (depth == 8 || need_colormap) { - colormap = XCreateColormap(display, root, visual, AllocNone); - if (!colormap) { - fprintf(stderr, "XCreateColormap() failed\n"); - return 2; - } - have_colormap = TRUE; - if (depth == 8) - bg_image = FALSE; /* gradient just wastes palette entries */ - } - if (depth == 15 || depth == 16) { - RShift = 15 - rpng2_x_msb(RMask); /* these are right-shifts */ - GShift = 15 - rpng2_x_msb(GMask); - BShift = 15 - rpng2_x_msb(BMask); - } else if (depth > 16) { - RShift = rpng2_x_msb(RMask) - 7; /* these are left-shifts */ - GShift = rpng2_x_msb(GMask) - 7; - BShift = rpng2_x_msb(BMask) - 7; - } - if (depth >= 15 && (RShift < 0 || GShift < 0 || BShift < 0)) { - fprintf(stderr, "rpng2 internal logic error: negative X shift(s)!\n"); - return 2; - } - -/*--------------------------------------------------------------------------- - Finally, create the window. - ---------------------------------------------------------------------------*/ - - attr.backing_store = Always; - attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask; - attrmask = CWBackingStore | CWEventMask; - if (have_nondefault_visual) { - attr.colormap = colormap; - attr.background_pixel = 0; - attr.border_pixel = 1; - attrmask |= CWColormap | CWBackPixel | CWBorderPixel; - } - - window = XCreateWindow(display, root, 0, 0, rpng2_info.width, - rpng2_info.height, 0, depth, InputOutput, visual, attrmask, &attr); - - if (window == None) { - fprintf(stderr, "XCreateWindow() failed\n"); - return 2; - } else - have_window = TRUE; - - if (depth == 8) - XSetWindowColormap(display, window, colormap); - - if (!XStringListToTextProperty(&window_name, 1, pWindowName)) - pWindowName = NULL; - if (!XStringListToTextProperty(&icon_name, 1, pIconName)) - pIconName = NULL; - - /* OK if either hints allocation fails; XSetWMProperties() allows NULLs */ - - if ((size_hints = XAllocSizeHints()) != NULL) { - /* window will not be resizable */ - size_hints->flags = PMinSize | PMaxSize; - size_hints->min_width = size_hints->max_width = (int)rpng2_info.width; - size_hints->min_height = size_hints->max_height = - (int)rpng2_info.height; - } - - if ((wm_hints = XAllocWMHints()) != NULL) { - wm_hints->initial_state = NormalState; - wm_hints->input = True; - /* wm_hints->icon_pixmap = icon_pixmap; */ - wm_hints->flags = StateHint | InputHint /* | IconPixmapHint */ ; - } - - XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0, - size_hints, wm_hints, NULL); - - /* various properties and hints no longer needed; free memory */ - if (pWindowName) - XFree(pWindowName->value); - if (pIconName) - XFree(pIconName->value); - if (size_hints) - XFree(size_hints); - if (wm_hints) - XFree(wm_hints); - - XMapWindow(display, window); - - gc = XCreateGC(display, window, 0, &gcvalues); - have_gc = TRUE; - -/*--------------------------------------------------------------------------- - Allocate memory for the X- and display-specific version of the image. - ---------------------------------------------------------------------------*/ - - if (depth == 24 || depth == 32) { - xdata = (uch *)malloc(4*rpng2_info.width*rpng2_info.height); - pad = 32; - } else if (depth == 16) { - xdata = (uch *)malloc(2*rpng2_info.width*rpng2_info.height); - pad = 16; - } else /* depth == 8 */ { - xdata = (uch *)malloc(rpng2_info.width*rpng2_info.height); - pad = 8; - } - - if (!xdata) { - fprintf(stderr, PROGNAME ": unable to allocate image memory\n"); - return 4; - } - - ximage = XCreateImage(display, visual, depth, ZPixmap, 0, - (char *)xdata, rpng2_info.width, rpng2_info.height, pad, 0); - - if (!ximage) { - fprintf(stderr, PROGNAME ": XCreateImage() failed\n"); - free(xdata); - return 3; - } - - /* to avoid testing the byte order every pixel (or doubling the size of - * the drawing routine with a giant if-test), we arbitrarily set the byte - * order to MSBFirst and let Xlib worry about inverting things on little- - * endian machines (e.g., Linux/x86, old VAXen, etc.)--this is not the - * most efficient approach (the giant if-test would be better), but in - * the interest of clarity, we'll take the easy way out... */ - - ximage->byte_order = MSBFirst; - -/*--------------------------------------------------------------------------- - Fill window with the specified background color (default is black) or - faked "background image" (but latter is disabled if 8-bit; gradients - just waste palette entries). - ---------------------------------------------------------------------------*/ - - if (bg_image) - rpng2_x_load_bg_image(); /* resets bg_image if fails */ - - if (!bg_image) { - if (depth == 24 || depth == 32) { - bg_pixel = (bg_red << RShift) | - (bg_green << GShift) | - (bg_blue << BShift); - } else if (depth == 16) { - bg_pixel = (((bg_red << 8) >> RShift) & RMask) | - (((bg_green << 8) >> GShift) & GMask) | - (((bg_blue << 8) >> BShift) & BMask); - } else /* depth == 8 */ { - - /* GRR: add 8-bit support */ - - } - XSetForeground(display, gc, bg_pixel); - XFillRectangle(display, window, gc, 0, 0, rpng2_info.width, - rpng2_info.height); - } - -/*--------------------------------------------------------------------------- - Wait for first Expose event to do any drawing, then flush and return. - ---------------------------------------------------------------------------*/ - - do - XNextEvent(display, &e); - while (e.type != Expose || e.xexpose.count); - - XFlush(display); - - return 0; - -} /* end function rpng2_x_create_window() */ - - - - - -static int rpng2_x_load_bg_image(void) -{ - uch *src; - char *dest; - uch r1, r2, g1, g2, b1, b2; - uch r1_inv, r2_inv, g1_inv, g2_inv, b1_inv, b2_inv; - int k, hmax, max; - int xidx, yidx, yidx_max = (bgscale-1); - int even_odd_vert, even_odd_horiz, even_odd; - int invert_gradient2 = (bg[pat].type & 0x08); - int invert_column; - int ximage_rowbytes = ximage->bytes_per_line; - ulg i, row; - ulg pixel; - -/*--------------------------------------------------------------------------- - Allocate buffer for fake background image to be used with transparent - images; if this fails, revert to plain background color. - ---------------------------------------------------------------------------*/ - - bg_rowbytes = 3 * rpng2_info.width; - bg_data = (uch *)malloc(bg_rowbytes * rpng2_info.height); - if (!bg_data) { - fprintf(stderr, PROGNAME - ": unable to allocate memory for background image\n"); - bg_image = 0; - return 1; - } - -/*--------------------------------------------------------------------------- - Vertical gradients (ramps) in NxN squares, alternating direction and - colors (N == bgscale). - ---------------------------------------------------------------------------*/ - - if ((bg[pat].type & 0x07) == 0) { - uch r1_min = rgb[bg[pat].rgb1_min].r; - uch g1_min = rgb[bg[pat].rgb1_min].g; - uch b1_min = rgb[bg[pat].rgb1_min].b; - uch r2_min = rgb[bg[pat].rgb2_min].r; - uch g2_min = rgb[bg[pat].rgb2_min].g; - uch b2_min = rgb[bg[pat].rgb2_min].b; - int r1_diff = rgb[bg[pat].rgb1_max].r - r1_min; - int g1_diff = rgb[bg[pat].rgb1_max].g - g1_min; - int b1_diff = rgb[bg[pat].rgb1_max].b - b1_min; - int r2_diff = rgb[bg[pat].rgb2_max].r - r2_min; - int g2_diff = rgb[bg[pat].rgb2_max].g - g2_min; - int b2_diff = rgb[bg[pat].rgb2_max].b - b2_min; - - for (row = 0; row < rpng2_info.height; ++row) { - yidx = (int)(row % bgscale); - even_odd_vert = (int)((row / bgscale) & 1); - - r1 = r1_min + (r1_diff * yidx) / yidx_max; - g1 = g1_min + (g1_diff * yidx) / yidx_max; - b1 = b1_min + (b1_diff * yidx) / yidx_max; - r1_inv = r1_min + (r1_diff * (yidx_max-yidx)) / yidx_max; - g1_inv = g1_min + (g1_diff * (yidx_max-yidx)) / yidx_max; - b1_inv = b1_min + (b1_diff * (yidx_max-yidx)) / yidx_max; - - r2 = r2_min + (r2_diff * yidx) / yidx_max; - g2 = g2_min + (g2_diff * yidx) / yidx_max; - b2 = b2_min + (b2_diff * yidx) / yidx_max; - r2_inv = r2_min + (r2_diff * (yidx_max-yidx)) / yidx_max; - g2_inv = g2_min + (g2_diff * (yidx_max-yidx)) / yidx_max; - b2_inv = b2_min + (b2_diff * (yidx_max-yidx)) / yidx_max; - - dest = (char *)bg_data + row*bg_rowbytes; - for (i = 0; i < rpng2_info.width; ++i) { - even_odd_horiz = (int)((i / bgscale) & 1); - even_odd = even_odd_vert ^ even_odd_horiz; - invert_column = - (even_odd_horiz && (bg[pat].type & 0x10)); - if (even_odd == 0) { /* gradient #1 */ - if (invert_column) { - *dest++ = r1_inv; - *dest++ = g1_inv; - *dest++ = b1_inv; - } else { - *dest++ = r1; - *dest++ = g1; - *dest++ = b1; - } - } else { /* gradient #2 */ - if ((invert_column && invert_gradient2) || - (!invert_column && !invert_gradient2)) - { - *dest++ = r2; /* not inverted or */ - *dest++ = g2; /* doubly inverted */ - *dest++ = b2; - } else { - *dest++ = r2_inv; - *dest++ = g2_inv; /* singly inverted */ - *dest++ = b2_inv; - } - } - } - } - -/*--------------------------------------------------------------------------- - Soft gradient-diamonds with scale = bgscale. Code contributed by Adam - M. Costello. - ---------------------------------------------------------------------------*/ - - } else if ((bg[pat].type & 0x07) == 1) { - - hmax = (bgscale-1)/2; /* half the max weight of a color */ - max = 2*hmax; /* the max weight of a color */ - - r1 = rgb[bg[pat].rgb1_max].r; - g1 = rgb[bg[pat].rgb1_max].g; - b1 = rgb[bg[pat].rgb1_max].b; - r2 = rgb[bg[pat].rgb2_max].r; - g2 = rgb[bg[pat].rgb2_max].g; - b2 = rgb[bg[pat].rgb2_max].b; - - for (row = 0; row < rpng2_info.height; ++row) { - yidx = (int)(row % bgscale); - if (yidx > hmax) - yidx = bgscale-1 - yidx; - dest = (char *)bg_data + row*bg_rowbytes; - for (i = 0; i < rpng2_info.width; ++i) { - xidx = (int)(i % bgscale); - if (xidx > hmax) - xidx = bgscale-1 - xidx; - k = xidx + yidx; - *dest++ = (k*r1 + (max-k)*r2) / max; - *dest++ = (k*g1 + (max-k)*g2) / max; - *dest++ = (k*b1 + (max-k)*b2) / max; - } - } - -/*--------------------------------------------------------------------------- - Radial "starburst" with azimuthal sinusoids; [eventually number of sinu- - soids will equal bgscale?]. This one is slow but very cool. Code con- - tributed by Pieter S. van der Meulen (originally in Smalltalk). - ---------------------------------------------------------------------------*/ - - } else if ((bg[pat].type & 0x07) == 2) { - uch ch; - int ii, x, y, hw, hh, grayspot; - double freq, rotate, saturate, gray, intensity; - double angle=0.0, aoffset=0.0, maxDist, dist; - double red=0.0, green=0.0, blue=0.0, hue, s, v, f, p, q, t; - - fprintf(stderr, "%s: computing radial background...", - PROGNAME); - fflush(stderr); - - hh = (int)(rpng2_info.height / 2); - hw = (int)(rpng2_info.width / 2); - - /* variables for radial waves: - * aoffset: number of degrees to rotate hue [CURRENTLY NOT USED] - * freq: number of color beams originating from the center - * grayspot: size of the graying center area (anti-alias) - * rotate: rotation of the beams as a function of radius - * saturate: saturation of beams' shape azimuthally - */ - angle = CLIP(angle, 0.0, 360.0); - grayspot = CLIP(bg[pat].bg_gray, 1, (hh + hw)); - freq = MAX((double)bg[pat].bg_freq, 0.0); - saturate = (double)bg[pat].bg_bsat * 0.1; - rotate = (double)bg[pat].bg_brot * 0.1; - gray = 0.0; - intensity = 0.0; - maxDist = (double)((hw*hw) + (hh*hh)); - - for (row = 0; row < rpng2_info.height; ++row) { - y = (int)(row - hh); - dest = (char *)bg_data + row*bg_rowbytes; - for (i = 0; i < rpng2_info.width; ++i) { - x = (int)(i - hw); - angle = (x == 0)? PI_2 : atan((double)y / (double)x); - gray = (double)MAX(ABS(y), ABS(x)) / grayspot; - gray = MIN(1.0, gray); - dist = (double)((x*x) + (y*y)) / maxDist; - intensity = cos((angle+(rotate*dist*PI)) * freq) * - gray * saturate; - intensity = (MAX(MIN(intensity,1.0),-1.0) + 1.0) * 0.5; - hue = (angle + PI) * INV_PI_360 + aoffset; - s = gray * ((double)(ABS(x)+ABS(y)) / (double)(hw + hh)); - s = MIN(MAX(s,0.0), 1.0); - v = MIN(MAX(intensity,0.0), 1.0); - - if (s == 0.0) { - ch = (uch)(v * 255.0); - *dest++ = ch; - *dest++ = ch; - *dest++ = ch; - } else { - if ((hue < 0.0) || (hue >= 360.0)) - hue -= (((int)(hue / 360.0)) * 360.0); - hue /= 60.0; - ii = (int)hue; - f = hue - (double)ii; - p = (1.0 - s) * v; - q = (1.0 - (s * f)) * v; - t = (1.0 - (s * (1.0 - f))) * v; - if (ii == 0) { red = v; green = t; blue = p; } - else if (ii == 1) { red = q; green = v; blue = p; } - else if (ii == 2) { red = p; green = v; blue = t; } - else if (ii == 3) { red = p; green = q; blue = v; } - else if (ii == 4) { red = t; green = p; blue = v; } - else if (ii == 5) { red = v; green = p; blue = q; } - *dest++ = (uch)(red * 255.0); - *dest++ = (uch)(green * 255.0); - *dest++ = (uch)(blue * 255.0); - } - } - } - fprintf(stderr, "done.\n"); - fflush(stderr); - } - -/*--------------------------------------------------------------------------- - Blast background image to display buffer before beginning PNG decode. - ---------------------------------------------------------------------------*/ - - if (depth == 24 || depth == 32) { - ulg red, green, blue; - - for (row = 0; row < rpng2_info.height; ++row) { - src = bg_data + row*bg_rowbytes; - dest = ximage->data + row*ximage_rowbytes; - for (i = rpng2_info.width; i > 0; --i) { - red = *src++; - green = *src++; - blue = *src++; - pixel = (red << RShift) | - (green << GShift) | - (blue << BShift); - /* recall that we set ximage->byte_order = MSBFirst above */ - /* GRR BUG: this assumes bpp == 32, but may be 24: */ - *dest++ = (char)((pixel >> 24) & 0xff); - *dest++ = (char)((pixel >> 16) & 0xff); - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } - - } else if (depth == 16) { - ush red, green, blue; - - for (row = 0; row < rpng2_info.height; ++row) { - src = bg_data + row*bg_rowbytes; - dest = ximage->data + row*ximage_rowbytes; - for (i = rpng2_info.width; i > 0; --i) { - red = ((ush)(*src) << 8); ++src; - green = ((ush)(*src) << 8); ++src; - blue = ((ush)(*src) << 8); ++src; - pixel = ((red >> RShift) & RMask) | - ((green >> GShift) & GMask) | - ((blue >> BShift) & BMask); - /* recall that we set ximage->byte_order = MSBFirst above */ - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } - - } else /* depth == 8 */ { - - /* GRR: add 8-bit support */ - - } - - XPutImage(display, window, gc, ximage, 0, 0, 0, 0, rpng2_info.width, - rpng2_info.height); - - return 0; - -} /* end function rpng2_x_load_bg_image() */ - - - - - -static void rpng2_x_display_row(ulg row) -{ - uch bg_red = rpng2_info.bg_red; - uch bg_green = rpng2_info.bg_green; - uch bg_blue = rpng2_info.bg_blue; - uch *src, *src2=NULL; - char *dest; - uch r, g, b, a; - int ximage_rowbytes = ximage->bytes_per_line; - ulg i, pixel; - static int rows=0, prevpass=(-1); - static ulg firstrow; - -/*--------------------------------------------------------------------------- - rows and firstrow simply track how many rows (and which ones) have not - yet been displayed; alternatively, we could call XPutImage() for every - row and not bother with the records-keeping. - ---------------------------------------------------------------------------*/ - - Trace((stderr, "beginning rpng2_x_display_row()\n")) - - if (rpng2_info.pass != prevpass) { - if (pause_after_pass && rpng2_info.pass > 0) { - XEvent e; - KeySym k; - - fprintf(stderr, - "%s: end of pass %d of 7; click in image window to continue\n", - PROGNAME, prevpass + 1); - do - XNextEvent(display, &e); - while (!(e.type == ButtonPress && e.xbutton.button == Button1) - && !(e.type == KeyPress && - ((k = XLookupKeysym(&e.xkey, 0)) == XK_q - || k == XK_Escape) )) ; - } - fprintf(stderr, "%s: pass %d of 7\r", PROGNAME, rpng2_info.pass + 1); - fflush(stderr); - prevpass = rpng2_info.pass; - } - - if (rows == 0) - firstrow = row; /* first row that is not yet displayed */ - - ++rows; /* count of rows received but not yet displayed */ - -/*--------------------------------------------------------------------------- - Aside from the use of the rpng2_info struct, the lack of an outer loop - (over rows) and moving the XPutImage() call outside the "if (depth)" - tests, this routine is identical to rpng_x_display_image() in the non- - progressive version of the program. - ---------------------------------------------------------------------------*/ - - if (depth == 24 || depth == 32) { - ulg red, green, blue; - - src = rpng2_info.image_data + row*rpng2_info.rowbytes; - if (bg_image) - src2 = bg_data + row*bg_rowbytes; - dest = ximage->data + row*ximage_rowbytes; - if (rpng2_info.channels == 3) { - for (i = rpng2_info.width; i > 0; --i) { - red = *src++; - green = *src++; - blue = *src++; - pixel = (red << RShift) | - (green << GShift) | - (blue << BShift); - /* recall that we set ximage->byte_order = MSBFirst above */ - /* GRR BUG: this assumes bpp == 32, but may be 24: */ - *dest++ = (char)((pixel >> 24) & 0xff); - *dest++ = (char)((pixel >> 16) & 0xff); - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } else /* if (rpng2_info.channels == 4) */ { - for (i = rpng2_info.width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - a = *src++; - if (bg_image) { - bg_red = *src2++; - bg_green = *src2++; - bg_blue = *src2++; - } - if (a == 255) { - red = r; - green = g; - blue = b; - } else if (a == 0) { - red = bg_red; - green = bg_green; - blue = bg_blue; - } else { - /* this macro (from png.h) composites the foreground - * and background values and puts the result into the - * first argument */ - alpha_composite(red, r, a, bg_red); - alpha_composite(green, g, a, bg_green); - alpha_composite(blue, b, a, bg_blue); - } - pixel = (red << RShift) | - (green << GShift) | - (blue << BShift); - /* recall that we set ximage->byte_order = MSBFirst above */ - /* GRR BUG: this assumes bpp == 32, but may be 24: */ - *dest++ = (char)((pixel >> 24) & 0xff); - *dest++ = (char)((pixel >> 16) & 0xff); - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } - - } else if (depth == 16) { - ush red, green, blue; - - src = rpng2_info.row_pointers[row]; - if (bg_image) - src2 = bg_data + row*bg_rowbytes; - dest = ximage->data + row*ximage_rowbytes; - if (rpng2_info.channels == 3) { - for (i = rpng2_info.width; i > 0; --i) { - red = ((ush)(*src) << 8); - ++src; - green = ((ush)(*src) << 8); - ++src; - blue = ((ush)(*src) << 8); - ++src; - pixel = ((red >> RShift) & RMask) | - ((green >> GShift) & GMask) | - ((blue >> BShift) & BMask); - /* recall that we set ximage->byte_order = MSBFirst above */ - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } else /* if (rpng2_info.channels == 4) */ { - for (i = rpng2_info.width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - a = *src++; - if (bg_image) { - bg_red = *src2++; - bg_green = *src2++; - bg_blue = *src2++; - } - if (a == 255) { - red = ((ush)r << 8); - green = ((ush)g << 8); - blue = ((ush)b << 8); - } else if (a == 0) { - red = ((ush)bg_red << 8); - green = ((ush)bg_green << 8); - blue = ((ush)bg_blue << 8); - } else { - /* this macro (from png.h) composites the foreground - * and background values and puts the result back into - * the first argument (== fg byte here: safe) */ - alpha_composite(r, r, a, bg_red); - alpha_composite(g, g, a, bg_green); - alpha_composite(b, b, a, bg_blue); - red = ((ush)r << 8); - green = ((ush)g << 8); - blue = ((ush)b << 8); - } - pixel = ((red >> RShift) & RMask) | - ((green >> GShift) & GMask) | - ((blue >> BShift) & BMask); - /* recall that we set ximage->byte_order = MSBFirst above */ - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } - - } else /* depth == 8 */ { - - /* GRR: add 8-bit support */ - - } - - -/*--------------------------------------------------------------------------- - Display after every 16 rows or when on one of last two rows. (Region - may include previously displayed lines due to interlacing--i.e., not - contiguous. Also, second-to-last row is final one in interlaced images - with odd number of rows.) For demos, flush (and delay) after every 16th - row so "sparse" passes don't go twice as fast. - ---------------------------------------------------------------------------*/ - - if (demo_timing && (row - firstrow >= 16 || row >= rpng2_info.height-2)) { - XPutImage(display, window, gc, ximage, 0, (int)firstrow, 0, - (int)firstrow, rpng2_info.width, row - firstrow + 1); - XFlush(display); - rows = 0; - usleep(usleep_duration); - } else - if (!demo_timing && ((rows & 0xf) == 0 || row >= rpng2_info.height-2)) { - XPutImage(display, window, gc, ximage, 0, (int)firstrow, 0, - (int)firstrow, rpng2_info.width, row - firstrow + 1); - XFlush(display); - rows = 0; - } - -} - - - - - -static void rpng2_x_finish_display(void) -{ - Trace((stderr, "beginning rpng2_x_finish_display()\n")) - - /* last row has already been displayed by rpng2_x_display_row(), so we - * have nothing to do here except set a flag and let the user know that - * the image is done */ - - rpng2_info.done = TRUE; - printf( - "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); - fflush(stdout); -} - - - - - -static void rpng2_x_cleanup(void) -{ - if (bg_image && bg_data) { - free(bg_data); - bg_data = NULL; - } - - if (rpng2_info.image_data) { - free(rpng2_info.image_data); - rpng2_info.image_data = NULL; - } - - if (rpng2_info.row_pointers) { - free(rpng2_info.row_pointers); - rpng2_info.row_pointers = NULL; - } - - if (ximage) { - if (ximage->data) { - free(ximage->data); /* we allocated it, so we free it */ - ximage->data = (char *)NULL; /* instead of XDestroyImage() */ - } - XDestroyImage(ximage); - ximage = NULL; - } - - if (have_gc) - XFreeGC(display, gc); - - if (have_window) - XDestroyWindow(display, window); - - if (have_colormap) - XFreeColormap(display, colormap); - - if (have_nondefault_visual) - XFree(visual_list); -} - - - - - -static int rpng2_x_msb(ulg u32val) -{ - int i; - - for (i = 31; i >= 0; --i) { - if (u32val & 0x80000000L) - break; - u32val <<= 1; - } - return i; -} +/*--------------------------------------------------------------------------- + + rpng2 - progressive-model PNG display program rpng2-x.c + + This program decodes and displays PNG files progressively, as if it were + a web browser (though the front end is only set up to read from files). + It supports gamma correction, user-specified background colors, and user- + specified background patterns (for transparent images). This version is + for the X Window System (tested by the author under Unix and by Martin + Zinser under OpenVMS; may work under OS/2 with a little tweaking). + + Thanks to Adam Costello and Pieter S. van der Meulen for the "diamond" + and "radial waves" patterns, respectively. + + to do: + - 8-bit support + - finish resizable checkerboard-gradient (sizes 4-128?) + - use %.1023s to simplify truncation of title-bar string? + + --------------------------------------------------------------------------- + + Changelog: + - 1.01: initial public release + - 1.02: modified to allow abbreviated options; fixed char/uchar mismatch + - 1.10: added support for non-default visuals; fixed X pixel-conversion + - 1.11: added -usleep option for demos; fixed command-line parsing bug + - 1.12: added -pause option for demos and testing + - 1.20: added runtime MMX-enabling/disabling and new -mmx* options + - 1.21: fixed small X memory leak (thanks to Francois Petitjean) + - 1.22: fixed XFreeGC() crash bug + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + ---------------------------------------------------------------------------*/ + +#define PROGNAME "rpng2-x" +#define LONGNAME "Progressive PNG Viewer for X" +#define VERSION "1.22 of 16 August 2001" + +#include +#include +#include +#include /* for jmpbuf declaration in readpng2.h */ +#include +#include /* only for PvdM background code */ +#include +#include +#include +#include /* defines XK_* macros */ + +#ifdef VMS +# include +#endif + +/* all for PvdM background code: */ +#ifndef PI +# define PI 3.141592653589793238 +#endif +#define PI_2 (PI*0.5) +#define INV_PI_360 (360.0 / PI) +#define MAX(a,b) (a>b?a:b) +#define MIN(a,b) (a> 8)) >> 8); \ +} + + +#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this + * block size corresponds roughly to a download + * speed 10% faster than theoretical 33.6K maximum + * (assuming 8 data bits, 1 stop bit and no other + * overhead) */ + +/* local prototypes */ +static void rpng2_x_init(void); +static int rpng2_x_create_window(void); +static int rpng2_x_load_bg_image(void); +static void rpng2_x_display_row(ulg row); +static void rpng2_x_finish_display(void); +static void rpng2_x_cleanup(void); +static int rpng2_x_msb(ulg u32val); + + +static char titlebar[1024], *window_name = titlebar; +static char *appname = LONGNAME; +static char *icon_name = PROGNAME; +static char *filename; +static FILE *infile; + +static mainprog_info rpng2_info; + +static uch inbuf[INBUFSIZE]; +static int incount; + +static int pat = 6; /* must be less than num_bgpat */ +static int bg_image = 0; +static int bgscale = 16; +static ulg bg_rowbytes; +static uch *bg_data; + +int pause_after_pass = FALSE; +int demo_timing = FALSE; +ulg usleep_duration = 0L; + +static struct rgb_color { + uch r, g, b; +} rgb[] = { + { 0, 0, 0}, /* 0: black */ + {255, 255, 255}, /* 1: white */ + {173, 132, 57}, /* 2: tan */ + { 64, 132, 0}, /* 3: medium green */ + {189, 117, 1}, /* 4: gold */ + {253, 249, 1}, /* 5: yellow */ + { 0, 0, 255}, /* 6: blue */ + { 0, 0, 120}, /* 7: medium blue */ + {255, 0, 255}, /* 8: magenta */ + { 64, 0, 64}, /* 9: dark magenta */ + {255, 0, 0}, /* 10: red */ + { 64, 0, 0}, /* 11: dark red */ + {255, 127, 0}, /* 12: orange */ + {192, 96, 0}, /* 13: darker orange */ + { 24, 60, 0}, /* 14: dark green-yellow */ + { 85, 125, 200} /* 15: ice blue */ +}; +/* not used for now, but should be for error-checking: +static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color); + */ + +/* + This whole struct is a fairly cheesy way to keep the number of + command-line options to a minimum. The radial-waves background + type is a particularly poor fit to the integer elements of the + struct...but a few macros and a little fixed-point math will do + wonders for ya. + + type bits: + F E D C B A 9 8 7 6 5 4 3 2 1 0 + | | | | | + | | +-+-+-- 0 = sharp-edged checkerboard + | | 1 = soft diamonds + | | 2 = radial waves + | | 3-7 = undefined + | +-- gradient #2 inverted? + +-- alternating columns inverted? + */ +static struct background_pattern { + ush type; + int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */ + int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/ +} bg[] = { + {0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */ + {0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */ + {0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */ + {0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */ + {0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */ + {0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */ + {0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */ + {1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */ + {1, 12,0, 11,0}, /* diamonds: orange vs. dark red */ + {1, 10,0, 7,0}, /* diamonds: red vs. medium blue */ + {1, 4,0, 5,0}, /* diamonds: gold vs. yellow */ + {1, 3,0, 0,0}, /* diamonds: medium green vs. black */ + {2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */ + {2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */ + {2, 16, 256, 100, 250}, /* radial: very tight spiral */ + {2, 10000, 256, 11, 0} /* radial: dipole-moire' (almost fractal) */ +}; +static int num_bgpat = sizeof(bg) / sizeof(struct background_pattern); + + +/* X-specific variables */ +static char *displayname; +static XImage *ximage; +static Display *display; +static int depth; +static Visual *visual; +static XVisualInfo *visual_list; +static int RShift, GShift, BShift; +static ulg RMask, GMask, BMask; +static Window window; +static GC gc; +static Colormap colormap; + +static int have_nondefault_visual = FALSE; +static int have_colormap = FALSE; +static int have_window = FALSE; +static int have_gc = FALSE; + + + + +int main(int argc, char **argv) +{ +#ifdef sgi + char tmpline[80]; +#endif + char *p, *bgstr = NULL; + int rc, alen, flen; + int error = 0; + int timing = FALSE; + int have_bg = FALSE; + double LUT_exponent; /* just the lookup table */ + double CRT_exponent = 2.2; /* just the monitor */ + double default_display_exponent; /* whole display system */ + XEvent e; + KeySym k; + + + /* First initialize a few things, just to be sure--memset takes care of + * default background color (black), booleans (FALSE), pointers (NULL), + * etc. */ + + displayname = (char *)NULL; + filename = (char *)NULL; + memset(&rpng2_info, 0, sizeof(mainprog_info)); + + + /* Set the default value for our display-system exponent, i.e., the + * product of the CRT exponent and the exponent corresponding to + * the frame-buffer's lookup table (LUT), if any. This is not an + * exhaustive list of LUT values (e.g., OpenStep has a lot of weird + * ones), but it should cover 99% of the current possibilities. */ + +#if defined(NeXT) + /* third-party utilities can modify the default LUT exponent */ + LUT_exponent = 1.0 / 2.2; + /* + if (some_next_function_that_returns_gamma(&next_gamma)) + LUT_exponent = 1.0 / next_gamma; + */ +#elif defined(sgi) + LUT_exponent = 1.0 / 1.7; + /* there doesn't seem to be any documented function to + * get the "gamma" value, so we do it the hard way */ + infile = fopen("/etc/config/system.glGammaVal", "r"); + if (infile) { + double sgi_gamma; + + fgets(tmpline, 80, infile); + fclose(infile); + sgi_gamma = atof(tmpline); + if (sgi_gamma > 0.0) + LUT_exponent = 1.0 / sgi_gamma; + } +#elif defined(Macintosh) + LUT_exponent = 1.8 / 2.61; + /* + if (some_mac_function_that_returns_gamma(&mac_gamma)) + LUT_exponent = mac_gamma / 2.61; + */ +#else + LUT_exponent = 1.0; /* assume no LUT: most PCs */ +#endif + + /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ + default_display_exponent = LUT_exponent * CRT_exponent; + + + /* If the user has set the SCREEN_GAMMA environment variable as suggested + * (somewhat imprecisely) in the libpng documentation, use that; otherwise + * use the default value we just calculated. Either way, the user may + * override this via a command-line option. */ + + if ((p = getenv("SCREEN_GAMMA")) != NULL) + rpng2_info.display_exponent = atof(p); + else + rpng2_info.display_exponent = default_display_exponent; + + + /* Now parse the command line for options and the PNG filename. */ + + while (*++argv && !error) { + if (!strncmp(*argv, "-display", 2)) { + if (!*++argv) + ++error; + else + displayname = *argv; + } else if (!strncmp(*argv, "-gamma", 2)) { + if (!*++argv) + ++error; + else { + rpng2_info.display_exponent = atof(*argv); + if (rpng2_info.display_exponent <= 0.0) + ++error; + } + } else if (!strncmp(*argv, "-bgcolor", 4)) { + if (!*++argv) + ++error; + else { + bgstr = *argv; + if (strlen(bgstr) != 7 || bgstr[0] != '#') + ++error; + else { + have_bg = TRUE; + bg_image = FALSE; + } + } + } else if (!strncmp(*argv, "-bgpat", 4)) { + if (!*++argv) + ++error; + else { + pat = atoi(*argv) - 1; + if (pat < 0 || pat >= num_bgpat) + ++error; + else { + bg_image = TRUE; + have_bg = FALSE; + } + } + } else if (!strncmp(*argv, "-usleep", 2)) { + if (!*++argv) + ++error; + else { + usleep_duration = (ulg)atol(*argv); + demo_timing = TRUE; + } + } else if (!strncmp(*argv, "-pause", 2)) { + pause_after_pass = TRUE; + } else if (!strncmp(*argv, "-timing", 2)) { + timing = TRUE; +#if (defined(__i386__) || defined(_M_IX86)) + } else if (!strncmp(*argv, "-nommxfilters", 7)) { + rpng2_info.nommxfilters = TRUE; + } else if (!strncmp(*argv, "-nommxcombine", 7)) { + rpng2_info.nommxcombine = TRUE; + } else if (!strncmp(*argv, "-nommxinterlace", 7)) { + rpng2_info.nommxinterlace = TRUE; + } else if (!strcmp(*argv, "-nommx")) { + rpng2_info.nommxfilters = TRUE; + rpng2_info.nommxcombine = TRUE; + rpng2_info.nommxinterlace = TRUE; +#endif + } else { + if (**argv != '-') { + filename = *argv; + if (argv[1]) /* shouldn't be any more args after filename */ + ++error; + } else + ++error; /* not expecting any other options */ + } + } + + if (!filename) { + ++error; + } else if (!(infile = fopen(filename, "rb"))) { + fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); + ++error; + } else { + incount = fread(inbuf, 1, INBUFSIZE, infile); + if (incount < 8 || !readpng2_check_sig(inbuf, 8)) { + fprintf(stderr, PROGNAME + ": [%s] is not a PNG file: incorrect signature\n", + filename); + ++error; + } else if ((rc = readpng2_init(&rpng2_info)) != 0) { + switch (rc) { + case 2: + fprintf(stderr, PROGNAME + ": [%s] has bad IHDR (libpng longjmp)\n", + filename); + break; + case 4: + fprintf(stderr, PROGNAME ": insufficient memory\n"); + break; + default: + fprintf(stderr, PROGNAME + ": unknown readpng2_init() error\n"); + break; + } + ++error; + } else { + display = XOpenDisplay(displayname); + if (!display) { + readpng2_cleanup(&rpng2_info); + fprintf(stderr, PROGNAME ": can't open X display [%s]\n", + displayname? displayname : "default"); + ++error; + } + } + if (error) + fclose(infile); + } + + + /* usage screen */ + + if (error) { + fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); + readpng2_version_info(); + fprintf(stderr, "\n" + "Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n" +#if (defined(__i386__) || defined(_M_IX86)) + " %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n" +#endif + " %*s [-usleep dur | -timing] [-pause] file.png\n\n" + " xdpy\tname of the target X display (e.g., ``hostname:0'')\n" + " exp \ttransfer-function exponent (``gamma'') of the display\n" + "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" + "\t\t to the product of the lookup-table exponent (varies)\n" + "\t\t and the CRT exponent (usually 2.2); must be positive\n" + " bg \tdesired background color in 7-character hex RGB format\n" + "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" + "\t\t used with transparent images; overrides -bgpat\n" + " pat \tdesired background pattern number (1-%d); used with\n" + "\t\t transparent images; overrides -bgcolor\n" +#if (defined(__i386__) || defined(_M_IX86)) + " -nommx*\tdisable optimized MMX routines for decoding row filters,\n" + "\t\t combining rows, and expanding interlacing, respectively\n" +#endif + " dur \tduration in microseconds to wait after displaying each\n" + "\t\t row (for demo purposes)\n" + " -timing\tenables delay for every block read, to simulate modem\n" + "\t\t download of image (~36 Kbps)\n" + " -pause\tpauses after displaying each pass until key pressed\n" + "\nPress Q, Esc or mouse button 1 (within image window, after image\n" + "is displayed) to quit.\n" + "\n", PROGNAME, +#if (defined(__i386__) || defined(_M_IX86)) + strlen(PROGNAME), " ", +#endif + strlen(PROGNAME), " ", default_display_exponent, num_bgpat); + exit(1); + } + + + /* set the title-bar string, but make sure buffer doesn't overflow */ + + alen = strlen(appname); + flen = strlen(filename); + if (alen + flen + 3 > 1023) + sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); + else + sprintf(titlebar, "%s: %s", appname, filename); + + + /* set some final rpng2_info variables before entering main data loop */ + + if (have_bg) { + unsigned r, g, b; /* this approach quiets compiler warnings */ + + sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); + rpng2_info.bg_red = (uch)r; + rpng2_info.bg_green = (uch)g; + rpng2_info.bg_blue = (uch)b; + } else + rpng2_info.need_bgcolor = TRUE; + + rpng2_info.done = FALSE; + rpng2_info.mainprog_init = rpng2_x_init; + rpng2_info.mainprog_display_row = rpng2_x_display_row; + rpng2_info.mainprog_finish_display = rpng2_x_finish_display; + + + /* OK, this is the fun part: call readpng2_decode_data() at the start of + * the loop to deal with our first buffer of data (read in above to verify + * that the file is a PNG image), then loop through the file and continue + * calling the same routine to handle each chunk of data. It in turn + * passes the data to libpng, which will invoke one or more of our call- + * backs as decoded data become available. We optionally call sleep() for + * one second per iteration to simulate downloading the image via an analog + * modem. */ + + for (;;) { + Trace((stderr, "about to call readpng2_decode_data()\n")) + if (readpng2_decode_data(&rpng2_info, inbuf, incount)) + ++error; + Trace((stderr, "done with readpng2_decode_data()\n")) + if (error || feof(infile) || rpng2_info.done) + break; + if (timing) + sleep(1); + incount = fread(inbuf, 1, INBUFSIZE, infile); + } + + + /* clean up PNG stuff and report any decoding errors */ + + fclose(infile); + Trace((stderr, "about to call readpng2_cleanup()\n")) + readpng2_cleanup(&rpng2_info); + + if (error) { + fprintf(stderr, PROGNAME ": libpng error while decoding PNG image\n"); + exit(3); + } + + + /* wait for the user to tell us when to quit */ + + do + XNextEvent(display, &e); + while (!(e.type == ButtonPress && e.xbutton.button == Button1) && + !(e.type == KeyPress && /* v--- or 1 for shifted keys */ + ((k = XLookupKeysym(&e.xkey, 0)) == XK_q || k == XK_Escape) )); + + + /* we're done: clean up all image and X resources and go away */ + + Trace((stderr, "about to call rpng2_x_cleanup()\n")) + rpng2_x_cleanup(); + + return 0; +} + + + + + +/* this function is called by readpng2_info_callback() in readpng2.c, which + * in turn is called by libpng after all of the pre-IDAT chunks have been + * read and processed--i.e., we now have enough info to finish initializing */ + +static void rpng2_x_init(void) +{ + ulg i; + ulg rowbytes = rpng2_info.rowbytes; + + Trace((stderr, "beginning rpng2_x_init()\n")) + Trace((stderr, " rowbytes = %ld\n", rpng2_info.rowbytes)) + Trace((stderr, " width = %ld\n", rpng2_info.width)) + Trace((stderr, " height = %ld\n", rpng2_info.height)) + + rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height); + if (!rpng2_info.image_data) { + readpng2_cleanup(&rpng2_info); + return; + } + + rpng2_info.row_pointers = (uch **)malloc(rpng2_info.height * sizeof(uch *)); + if (!rpng2_info.row_pointers) { + free(rpng2_info.image_data); + rpng2_info.image_data = NULL; + readpng2_cleanup(&rpng2_info); + return; + } + + for (i = 0; i < rpng2_info.height; ++i) + rpng2_info.row_pointers[i] = rpng2_info.image_data + i*rowbytes; + + + /* do the basic X initialization stuff, make the window, and fill it with + * the user-specified, file-specified or default background color or + * pattern */ + + if (rpng2_x_create_window()) { + + /* GRR TEMPORARY HACK: this is fundamentally no different from cases + * above; libpng should longjmp() back to us when png_ptr goes away. + * If we/it segfault instead, seems like a libpng bug... */ + + /* we're here via libpng callback, so if window fails, clean and bail */ +printf("readpng2_cleanup.\n"); + readpng2_cleanup(&rpng2_info); + rpng2_x_cleanup(); + exit(2); + } +} + + + + + +static int rpng2_x_create_window(void) +{ + ulg bg_red = rpng2_info.bg_red; + ulg bg_green = rpng2_info.bg_green; + ulg bg_blue = rpng2_info.bg_blue; + ulg bg_pixel = 0L; + ulg attrmask; + int need_colormap = FALSE; + int screen, pad; + uch *xdata; + Window root; + XEvent e; + XGCValues gcvalues; + XSetWindowAttributes attr; + XSizeHints *size_hints; + XTextProperty windowName, *pWindowName = &windowName; + XTextProperty iconName, *pIconName = &iconName; + XVisualInfo visual_info; + XWMHints *wm_hints; + + + Trace((stderr, "beginning rpng2_x_create_window()\n")) + + screen = DefaultScreen(display); + depth = DisplayPlanes(display, screen); + root = RootWindow(display, screen); + +#ifdef DEBUG + XSynchronize(display, True); +#endif + + if (depth != 16 && depth != 24 && depth != 32) { + int visuals_matched = 0; + + Trace((stderr, "default depth is %d: checking other visuals\n", + depth)) + + /* 24-bit first */ + visual_info.screen = screen; + visual_info.depth = 24; + visual_list = XGetVisualInfo(display, + VisualScreenMask | VisualDepthMask, &visual_info, &visuals_matched); + if (visuals_matched == 0) { +/* GRR: add 15-, 16- and 32-bit TrueColor visuals (also DirectColor?) */ + fprintf(stderr, "default screen depth %d not supported, and no" + " 24-bit visuals found\n", depth); + return 2; + } + Trace((stderr, "XGetVisualInfo() returned %d 24-bit visuals\n", + visuals_matched)) + visual = visual_list[0].visual; + depth = visual_list[0].depth; +/* + colormap_size = visual_list[0].colormap_size; + visual_class = visual->class; + visualID = XVisualIDFromVisual(visual); + */ + have_nondefault_visual = TRUE; + need_colormap = TRUE; + } else { + XMatchVisualInfo(display, screen, depth, TrueColor, &visual_info); + visual = visual_info.visual; + } + + RMask = visual->red_mask; + GMask = visual->green_mask; + BMask = visual->blue_mask; + +/* GRR: add/check 8-bit support */ + if (depth == 8 || need_colormap) { + colormap = XCreateColormap(display, root, visual, AllocNone); + if (!colormap) { + fprintf(stderr, "XCreateColormap() failed\n"); + return 2; + } + have_colormap = TRUE; + if (depth == 8) + bg_image = FALSE; /* gradient just wastes palette entries */ + } + if (depth == 15 || depth == 16) { + RShift = 15 - rpng2_x_msb(RMask); /* these are right-shifts */ + GShift = 15 - rpng2_x_msb(GMask); + BShift = 15 - rpng2_x_msb(BMask); + } else if (depth > 16) { + RShift = rpng2_x_msb(RMask) - 7; /* these are left-shifts */ + GShift = rpng2_x_msb(GMask) - 7; + BShift = rpng2_x_msb(BMask) - 7; + } + if (depth >= 15 && (RShift < 0 || GShift < 0 || BShift < 0)) { + fprintf(stderr, "rpng2 internal logic error: negative X shift(s)!\n"); + return 2; + } + +/*--------------------------------------------------------------------------- + Finally, create the window. + ---------------------------------------------------------------------------*/ + + attr.backing_store = Always; + attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask; + attrmask = CWBackingStore | CWEventMask; + if (have_nondefault_visual) { + attr.colormap = colormap; + attr.background_pixel = 0; + attr.border_pixel = 1; + attrmask |= CWColormap | CWBackPixel | CWBorderPixel; + } + + window = XCreateWindow(display, root, 0, 0, rpng2_info.width, + rpng2_info.height, 0, depth, InputOutput, visual, attrmask, &attr); + + if (window == None) { + fprintf(stderr, "XCreateWindow() failed\n"); + return 2; + } else + have_window = TRUE; + + if (depth == 8) + XSetWindowColormap(display, window, colormap); + + if (!XStringListToTextProperty(&window_name, 1, pWindowName)) + pWindowName = NULL; + if (!XStringListToTextProperty(&icon_name, 1, pIconName)) + pIconName = NULL; + + /* OK if either hints allocation fails; XSetWMProperties() allows NULLs */ + + if ((size_hints = XAllocSizeHints()) != NULL) { + /* window will not be resizable */ + size_hints->flags = PMinSize | PMaxSize; + size_hints->min_width = size_hints->max_width = (int)rpng2_info.width; + size_hints->min_height = size_hints->max_height = + (int)rpng2_info.height; + } + + if ((wm_hints = XAllocWMHints()) != NULL) { + wm_hints->initial_state = NormalState; + wm_hints->input = True; + /* wm_hints->icon_pixmap = icon_pixmap; */ + wm_hints->flags = StateHint | InputHint /* | IconPixmapHint */ ; + } + + XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0, + size_hints, wm_hints, NULL); + + /* various properties and hints no longer needed; free memory */ + if (pWindowName) + XFree(pWindowName->value); + if (pIconName) + XFree(pIconName->value); + if (size_hints) + XFree(size_hints); + if (wm_hints) + XFree(wm_hints); + + XMapWindow(display, window); + + gc = XCreateGC(display, window, 0, &gcvalues); + have_gc = TRUE; + +/*--------------------------------------------------------------------------- + Allocate memory for the X- and display-specific version of the image. + ---------------------------------------------------------------------------*/ + + if (depth == 24 || depth == 32) { + xdata = (uch *)malloc(4*rpng2_info.width*rpng2_info.height); + pad = 32; + } else if (depth == 16) { + xdata = (uch *)malloc(2*rpng2_info.width*rpng2_info.height); + pad = 16; + } else /* depth == 8 */ { + xdata = (uch *)malloc(rpng2_info.width*rpng2_info.height); + pad = 8; + } + + if (!xdata) { + fprintf(stderr, PROGNAME ": unable to allocate image memory\n"); + return 4; + } + + ximage = XCreateImage(display, visual, depth, ZPixmap, 0, + (char *)xdata, rpng2_info.width, rpng2_info.height, pad, 0); + + if (!ximage) { + fprintf(stderr, PROGNAME ": XCreateImage() failed\n"); + free(xdata); + return 3; + } + + /* to avoid testing the byte order every pixel (or doubling the size of + * the drawing routine with a giant if-test), we arbitrarily set the byte + * order to MSBFirst and let Xlib worry about inverting things on little- + * endian machines (e.g., Linux/x86, old VAXen, etc.)--this is not the + * most efficient approach (the giant if-test would be better), but in + * the interest of clarity, we'll take the easy way out... */ + + ximage->byte_order = MSBFirst; + +/*--------------------------------------------------------------------------- + Fill window with the specified background color (default is black) or + faked "background image" (but latter is disabled if 8-bit; gradients + just waste palette entries). + ---------------------------------------------------------------------------*/ + + if (bg_image) + rpng2_x_load_bg_image(); /* resets bg_image if fails */ + + if (!bg_image) { + if (depth == 24 || depth == 32) { + bg_pixel = (bg_red << RShift) | + (bg_green << GShift) | + (bg_blue << BShift); + } else if (depth == 16) { + bg_pixel = (((bg_red << 8) >> RShift) & RMask) | + (((bg_green << 8) >> GShift) & GMask) | + (((bg_blue << 8) >> BShift) & BMask); + } else /* depth == 8 */ { + + /* GRR: add 8-bit support */ + + } + XSetForeground(display, gc, bg_pixel); + XFillRectangle(display, window, gc, 0, 0, rpng2_info.width, + rpng2_info.height); + } + +/*--------------------------------------------------------------------------- + Wait for first Expose event to do any drawing, then flush and return. + ---------------------------------------------------------------------------*/ + + do + XNextEvent(display, &e); + while (e.type != Expose || e.xexpose.count); + + XFlush(display); + + return 0; + +} /* end function rpng2_x_create_window() */ + + + + + +static int rpng2_x_load_bg_image(void) +{ + uch *src; + char *dest; + uch r1, r2, g1, g2, b1, b2; + uch r1_inv, r2_inv, g1_inv, g2_inv, b1_inv, b2_inv; + int k, hmax, max; + int xidx, yidx, yidx_max = (bgscale-1); + int even_odd_vert, even_odd_horiz, even_odd; + int invert_gradient2 = (bg[pat].type & 0x08); + int invert_column; + int ximage_rowbytes = ximage->bytes_per_line; + ulg i, row; + ulg pixel; + +/*--------------------------------------------------------------------------- + Allocate buffer for fake background image to be used with transparent + images; if this fails, revert to plain background color. + ---------------------------------------------------------------------------*/ + + bg_rowbytes = 3 * rpng2_info.width; + bg_data = (uch *)malloc(bg_rowbytes * rpng2_info.height); + if (!bg_data) { + fprintf(stderr, PROGNAME + ": unable to allocate memory for background image\n"); + bg_image = 0; + return 1; + } + +/*--------------------------------------------------------------------------- + Vertical gradients (ramps) in NxN squares, alternating direction and + colors (N == bgscale). + ---------------------------------------------------------------------------*/ + + if ((bg[pat].type & 0x07) == 0) { + uch r1_min = rgb[bg[pat].rgb1_min].r; + uch g1_min = rgb[bg[pat].rgb1_min].g; + uch b1_min = rgb[bg[pat].rgb1_min].b; + uch r2_min = rgb[bg[pat].rgb2_min].r; + uch g2_min = rgb[bg[pat].rgb2_min].g; + uch b2_min = rgb[bg[pat].rgb2_min].b; + int r1_diff = rgb[bg[pat].rgb1_max].r - r1_min; + int g1_diff = rgb[bg[pat].rgb1_max].g - g1_min; + int b1_diff = rgb[bg[pat].rgb1_max].b - b1_min; + int r2_diff = rgb[bg[pat].rgb2_max].r - r2_min; + int g2_diff = rgb[bg[pat].rgb2_max].g - g2_min; + int b2_diff = rgb[bg[pat].rgb2_max].b - b2_min; + + for (row = 0; row < rpng2_info.height; ++row) { + yidx = (int)(row % bgscale); + even_odd_vert = (int)((row / bgscale) & 1); + + r1 = r1_min + (r1_diff * yidx) / yidx_max; + g1 = g1_min + (g1_diff * yidx) / yidx_max; + b1 = b1_min + (b1_diff * yidx) / yidx_max; + r1_inv = r1_min + (r1_diff * (yidx_max-yidx)) / yidx_max; + g1_inv = g1_min + (g1_diff * (yidx_max-yidx)) / yidx_max; + b1_inv = b1_min + (b1_diff * (yidx_max-yidx)) / yidx_max; + + r2 = r2_min + (r2_diff * yidx) / yidx_max; + g2 = g2_min + (g2_diff * yidx) / yidx_max; + b2 = b2_min + (b2_diff * yidx) / yidx_max; + r2_inv = r2_min + (r2_diff * (yidx_max-yidx)) / yidx_max; + g2_inv = g2_min + (g2_diff * (yidx_max-yidx)) / yidx_max; + b2_inv = b2_min + (b2_diff * (yidx_max-yidx)) / yidx_max; + + dest = (char *)bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + even_odd_horiz = (int)((i / bgscale) & 1); + even_odd = even_odd_vert ^ even_odd_horiz; + invert_column = + (even_odd_horiz && (bg[pat].type & 0x10)); + if (even_odd == 0) { /* gradient #1 */ + if (invert_column) { + *dest++ = r1_inv; + *dest++ = g1_inv; + *dest++ = b1_inv; + } else { + *dest++ = r1; + *dest++ = g1; + *dest++ = b1; + } + } else { /* gradient #2 */ + if ((invert_column && invert_gradient2) || + (!invert_column && !invert_gradient2)) + { + *dest++ = r2; /* not inverted or */ + *dest++ = g2; /* doubly inverted */ + *dest++ = b2; + } else { + *dest++ = r2_inv; + *dest++ = g2_inv; /* singly inverted */ + *dest++ = b2_inv; + } + } + } + } + +/*--------------------------------------------------------------------------- + Soft gradient-diamonds with scale = bgscale. Code contributed by Adam + M. Costello. + ---------------------------------------------------------------------------*/ + + } else if ((bg[pat].type & 0x07) == 1) { + + hmax = (bgscale-1)/2; /* half the max weight of a color */ + max = 2*hmax; /* the max weight of a color */ + + r1 = rgb[bg[pat].rgb1_max].r; + g1 = rgb[bg[pat].rgb1_max].g; + b1 = rgb[bg[pat].rgb1_max].b; + r2 = rgb[bg[pat].rgb2_max].r; + g2 = rgb[bg[pat].rgb2_max].g; + b2 = rgb[bg[pat].rgb2_max].b; + + for (row = 0; row < rpng2_info.height; ++row) { + yidx = (int)(row % bgscale); + if (yidx > hmax) + yidx = bgscale-1 - yidx; + dest = (char *)bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + xidx = (int)(i % bgscale); + if (xidx > hmax) + xidx = bgscale-1 - xidx; + k = xidx + yidx; + *dest++ = (k*r1 + (max-k)*r2) / max; + *dest++ = (k*g1 + (max-k)*g2) / max; + *dest++ = (k*b1 + (max-k)*b2) / max; + } + } + +/*--------------------------------------------------------------------------- + Radial "starburst" with azimuthal sinusoids; [eventually number of sinu- + soids will equal bgscale?]. This one is slow but very cool. Code con- + tributed by Pieter S. van der Meulen (originally in Smalltalk). + ---------------------------------------------------------------------------*/ + + } else if ((bg[pat].type & 0x07) == 2) { + uch ch; + int ii, x, y, hw, hh, grayspot; + double freq, rotate, saturate, gray, intensity; + double angle=0.0, aoffset=0.0, maxDist, dist; + double red=0.0, green=0.0, blue=0.0, hue, s, v, f, p, q, t; + + fprintf(stderr, "%s: computing radial background...", + PROGNAME); + fflush(stderr); + + hh = (int)(rpng2_info.height / 2); + hw = (int)(rpng2_info.width / 2); + + /* variables for radial waves: + * aoffset: number of degrees to rotate hue [CURRENTLY NOT USED] + * freq: number of color beams originating from the center + * grayspot: size of the graying center area (anti-alias) + * rotate: rotation of the beams as a function of radius + * saturate: saturation of beams' shape azimuthally + */ + angle = CLIP(angle, 0.0, 360.0); + grayspot = CLIP(bg[pat].bg_gray, 1, (hh + hw)); + freq = MAX((double)bg[pat].bg_freq, 0.0); + saturate = (double)bg[pat].bg_bsat * 0.1; + rotate = (double)bg[pat].bg_brot * 0.1; + gray = 0.0; + intensity = 0.0; + maxDist = (double)((hw*hw) + (hh*hh)); + + for (row = 0; row < rpng2_info.height; ++row) { + y = (int)(row - hh); + dest = (char *)bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + x = (int)(i - hw); + angle = (x == 0)? PI_2 : atan((double)y / (double)x); + gray = (double)MAX(ABS(y), ABS(x)) / grayspot; + gray = MIN(1.0, gray); + dist = (double)((x*x) + (y*y)) / maxDist; + intensity = cos((angle+(rotate*dist*PI)) * freq) * + gray * saturate; + intensity = (MAX(MIN(intensity,1.0),-1.0) + 1.0) * 0.5; + hue = (angle + PI) * INV_PI_360 + aoffset; + s = gray * ((double)(ABS(x)+ABS(y)) / (double)(hw + hh)); + s = MIN(MAX(s,0.0), 1.0); + v = MIN(MAX(intensity,0.0), 1.0); + + if (s == 0.0) { + ch = (uch)(v * 255.0); + *dest++ = ch; + *dest++ = ch; + *dest++ = ch; + } else { + if ((hue < 0.0) || (hue >= 360.0)) + hue -= (((int)(hue / 360.0)) * 360.0); + hue /= 60.0; + ii = (int)hue; + f = hue - (double)ii; + p = (1.0 - s) * v; + q = (1.0 - (s * f)) * v; + t = (1.0 - (s * (1.0 - f))) * v; + if (ii == 0) { red = v; green = t; blue = p; } + else if (ii == 1) { red = q; green = v; blue = p; } + else if (ii == 2) { red = p; green = v; blue = t; } + else if (ii == 3) { red = p; green = q; blue = v; } + else if (ii == 4) { red = t; green = p; blue = v; } + else if (ii == 5) { red = v; green = p; blue = q; } + *dest++ = (uch)(red * 255.0); + *dest++ = (uch)(green * 255.0); + *dest++ = (uch)(blue * 255.0); + } + } + } + fprintf(stderr, "done.\n"); + fflush(stderr); + } + +/*--------------------------------------------------------------------------- + Blast background image to display buffer before beginning PNG decode. + ---------------------------------------------------------------------------*/ + + if (depth == 24 || depth == 32) { + ulg red, green, blue; + + for (row = 0; row < rpng2_info.height; ++row) { + src = bg_data + row*bg_rowbytes; + dest = ximage->data + row*ximage_rowbytes; + for (i = rpng2_info.width; i > 0; --i) { + red = *src++; + green = *src++; + blue = *src++; + pixel = (red << RShift) | + (green << GShift) | + (blue << BShift); + /* recall that we set ximage->byte_order = MSBFirst above */ + /* GRR BUG: this assumes bpp == 32, but may be 24: */ + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } + + } else if (depth == 16) { + ush red, green, blue; + + for (row = 0; row < rpng2_info.height; ++row) { + src = bg_data + row*bg_rowbytes; + dest = ximage->data + row*ximage_rowbytes; + for (i = rpng2_info.width; i > 0; --i) { + red = ((ush)(*src) << 8); ++src; + green = ((ush)(*src) << 8); ++src; + blue = ((ush)(*src) << 8); ++src; + pixel = ((red >> RShift) & RMask) | + ((green >> GShift) & GMask) | + ((blue >> BShift) & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } + + } else /* depth == 8 */ { + + /* GRR: add 8-bit support */ + + } + + XPutImage(display, window, gc, ximage, 0, 0, 0, 0, rpng2_info.width, + rpng2_info.height); + + return 0; + +} /* end function rpng2_x_load_bg_image() */ + + + + + +static void rpng2_x_display_row(ulg row) +{ + uch bg_red = rpng2_info.bg_red; + uch bg_green = rpng2_info.bg_green; + uch bg_blue = rpng2_info.bg_blue; + uch *src, *src2=NULL; + char *dest; + uch r, g, b, a; + int ximage_rowbytes = ximage->bytes_per_line; + ulg i, pixel; + static int rows=0, prevpass=(-1); + static ulg firstrow; + +/*--------------------------------------------------------------------------- + rows and firstrow simply track how many rows (and which ones) have not + yet been displayed; alternatively, we could call XPutImage() for every + row and not bother with the records-keeping. + ---------------------------------------------------------------------------*/ + + Trace((stderr, "beginning rpng2_x_display_row()\n")) + + if (rpng2_info.pass != prevpass) { + if (pause_after_pass && rpng2_info.pass > 0) { + XEvent e; + KeySym k; + + fprintf(stderr, + "%s: end of pass %d of 7; click in image window to continue\n", + PROGNAME, prevpass + 1); + do + XNextEvent(display, &e); + while (!(e.type == ButtonPress && e.xbutton.button == Button1) + && !(e.type == KeyPress && + ((k = XLookupKeysym(&e.xkey, 0)) == XK_q + || k == XK_Escape) )) ; + } + fprintf(stderr, "%s: pass %d of 7\r", PROGNAME, rpng2_info.pass + 1); + fflush(stderr); + prevpass = rpng2_info.pass; + } + + if (rows == 0) + firstrow = row; /* first row that is not yet displayed */ + + ++rows; /* count of rows received but not yet displayed */ + +/*--------------------------------------------------------------------------- + Aside from the use of the rpng2_info struct, the lack of an outer loop + (over rows) and moving the XPutImage() call outside the "if (depth)" + tests, this routine is identical to rpng_x_display_image() in the non- + progressive version of the program. + ---------------------------------------------------------------------------*/ + + if (depth == 24 || depth == 32) { + ulg red, green, blue; + + src = rpng2_info.image_data + row*rpng2_info.rowbytes; + if (bg_image) + src2 = bg_data + row*bg_rowbytes; + dest = ximage->data + row*ximage_rowbytes; + if (rpng2_info.channels == 3) { + for (i = rpng2_info.width; i > 0; --i) { + red = *src++; + green = *src++; + blue = *src++; + pixel = (red << RShift) | + (green << GShift) | + (blue << BShift); + /* recall that we set ximage->byte_order = MSBFirst above */ + /* GRR BUG: this assumes bpp == 32, but may be 24: */ + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } else /* if (rpng2_info.channels == 4) */ { + for (i = rpng2_info.width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + a = *src++; + if (bg_image) { + bg_red = *src2++; + bg_green = *src2++; + bg_blue = *src2++; + } + if (a == 255) { + red = r; + green = g; + blue = b; + } else if (a == 0) { + red = bg_red; + green = bg_green; + blue = bg_blue; + } else { + /* this macro (from png.h) composites the foreground + * and background values and puts the result into the + * first argument */ + alpha_composite(red, r, a, bg_red); + alpha_composite(green, g, a, bg_green); + alpha_composite(blue, b, a, bg_blue); + } + pixel = (red << RShift) | + (green << GShift) | + (blue << BShift); + /* recall that we set ximage->byte_order = MSBFirst above */ + /* GRR BUG: this assumes bpp == 32, but may be 24: */ + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } + + } else if (depth == 16) { + ush red, green, blue; + + src = rpng2_info.row_pointers[row]; + if (bg_image) + src2 = bg_data + row*bg_rowbytes; + dest = ximage->data + row*ximage_rowbytes; + if (rpng2_info.channels == 3) { + for (i = rpng2_info.width; i > 0; --i) { + red = ((ush)(*src) << 8); + ++src; + green = ((ush)(*src) << 8); + ++src; + blue = ((ush)(*src) << 8); + ++src; + pixel = ((red >> RShift) & RMask) | + ((green >> GShift) & GMask) | + ((blue >> BShift) & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } else /* if (rpng2_info.channels == 4) */ { + for (i = rpng2_info.width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + a = *src++; + if (bg_image) { + bg_red = *src2++; + bg_green = *src2++; + bg_blue = *src2++; + } + if (a == 255) { + red = ((ush)r << 8); + green = ((ush)g << 8); + blue = ((ush)b << 8); + } else if (a == 0) { + red = ((ush)bg_red << 8); + green = ((ush)bg_green << 8); + blue = ((ush)bg_blue << 8); + } else { + /* this macro (from png.h) composites the foreground + * and background values and puts the result back into + * the first argument (== fg byte here: safe) */ + alpha_composite(r, r, a, bg_red); + alpha_composite(g, g, a, bg_green); + alpha_composite(b, b, a, bg_blue); + red = ((ush)r << 8); + green = ((ush)g << 8); + blue = ((ush)b << 8); + } + pixel = ((red >> RShift) & RMask) | + ((green >> GShift) & GMask) | + ((blue >> BShift) & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } + + } else /* depth == 8 */ { + + /* GRR: add 8-bit support */ + + } + + +/*--------------------------------------------------------------------------- + Display after every 16 rows or when on one of last two rows. (Region + may include previously displayed lines due to interlacing--i.e., not + contiguous. Also, second-to-last row is final one in interlaced images + with odd number of rows.) For demos, flush (and delay) after every 16th + row so "sparse" passes don't go twice as fast. + ---------------------------------------------------------------------------*/ + + if (demo_timing && (row - firstrow >= 16 || row >= rpng2_info.height-2)) { + XPutImage(display, window, gc, ximage, 0, (int)firstrow, 0, + (int)firstrow, rpng2_info.width, row - firstrow + 1); + XFlush(display); + rows = 0; + usleep(usleep_duration); + } else + if (!demo_timing && ((rows & 0xf) == 0 || row >= rpng2_info.height-2)) { + XPutImage(display, window, gc, ximage, 0, (int)firstrow, 0, + (int)firstrow, rpng2_info.width, row - firstrow + 1); + XFlush(display); + rows = 0; + } + +} + + + + + +static void rpng2_x_finish_display(void) +{ + Trace((stderr, "beginning rpng2_x_finish_display()\n")) + + /* last row has already been displayed by rpng2_x_display_row(), so we + * have nothing to do here except set a flag and let the user know that + * the image is done */ + + rpng2_info.done = TRUE; + printf( + "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); + fflush(stdout); +} + + + + + +static void rpng2_x_cleanup(void) +{ + if (bg_image && bg_data) { + free(bg_data); + bg_data = NULL; + } + + if (rpng2_info.image_data) { + free(rpng2_info.image_data); + rpng2_info.image_data = NULL; + } + + if (rpng2_info.row_pointers) { + free(rpng2_info.row_pointers); + rpng2_info.row_pointers = NULL; + } + + if (ximage) { + if (ximage->data) { + free(ximage->data); /* we allocated it, so we free it */ + ximage->data = (char *)NULL; /* instead of XDestroyImage() */ + } + XDestroyImage(ximage); + ximage = NULL; + } + + if (have_gc) + XFreeGC(display, gc); + + if (have_window) + XDestroyWindow(display, window); + + if (have_colormap) + XFreeColormap(display, colormap); + + if (have_nondefault_visual) + XFree(visual_list); +} + + + + + +static int rpng2_x_msb(ulg u32val) +{ + int i; + + for (i = 31; i >= 0; --i) { + if (u32val & 0x80000000L) + break; + u32val <<= 1; + } + return i; +} diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/wpng.c b/src/dep/src/irrlicht/libpng/contrib/gregbook/wpng.c index 7aaee11..d6e8514 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/wpng.c +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/wpng.c @@ -1,816 +1,816 @@ -/*--------------------------------------------------------------------------- - - wpng - simple PNG-writing program wpng.c - - This program converts certain NetPBM binary files (grayscale and RGB, - maxval = 255) to PNG. Non-interlaced PNGs are written progressively; - interlaced PNGs are read and written in one memory-intensive blast. - Thanks to Jean-loup Gailly for providing the necessary trick to read - interactive text from the keyboard while stdin is redirected. - - NOTE: includes provisional support for PNM type "8" (portable alphamap) - images, presumed to be a 32-bit interleaved RGBA format; no pro- - vision for possible interleaved grayscale+alpha (16-bit) format. - THIS IS UNLIKELY TO BECOME AN OFFICIAL NETPBM ALPHA FORMAT! - - to do: - - delete output file if quit before calling any writepng routines - - process backspace with -text option under DOS/Win? (currently get ^H) - - --------------------------------------------------------------------------- - - Changelog: - - 1.01: initial public release - - 1.02: modified to allow abbreviated options - - 1.03: removed extraneous character from usage screen; fixed bug in - command-line parsing - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#define PROGNAME "wpng" -#define VERSION "1.03 of 19 March 2000" -#define APPNAME "Simple PGM/PPM/PAM to PNG Converter" - -#if defined(__MSDOS__) || defined(__OS2__) -# define DOS_OS2_W32 -#elif defined(_WIN32) || defined(__WIN32__) -# define DOS_OS2_W32 -#endif - -#include -#include -#include -#include /* for jmpbuf declaration in writepng.h */ -#include - -#ifdef DOS_OS2_W32 -# include /* for isatty(), setmode() prototypes */ -# include /* O_BINARY for fdopen() without text translation */ -# ifdef __EMX__ -# ifndef getch -# define getch() _read_kbd(0, 1, 0) /* need getche() */ -# endif -# else /* !__EMX__ */ -# ifdef __GO32__ -# include -# define getch() getkey() /* GRR: need getche() */ -# else -# include /* for getche() console input */ -# endif -# endif /* ?__EMX__ */ -# define FGETS(buf,len,stream) dos_kbd_gets(buf,len) -#else -# include /* for isatty() prototype */ -# define FGETS fgets -#endif - -/* #define DEBUG : this enables the Trace() macros */ - -/* #define FORBID_LATIN1_CTRL : this requires the user to re-enter any - text that includes control characters discouraged by the PNG spec; text - that includes an escape character (27) must be re-entered regardless */ - -#include "writepng.h" /* typedefs, common macros, writepng prototypes */ - - - -/* local prototypes */ - -static int wpng_isvalid_latin1(uch *p, int len); -static void wpng_cleanup(void); - -#ifdef DOS_OS2_W32 - static char *dos_kbd_gets(char *buf, int len); -#endif - - - -static mainprog_info wpng_info; /* lone global */ - - - -int main(int argc, char **argv) -{ -#ifndef DOS_OS2_W32 - FILE *keybd; -#endif -#ifdef sgi - FILE *tmpfile; /* or we could just use keybd, since no overlap */ - char tmpline[80]; -#endif - char *inname = NULL, outname[256]; - char *p, pnmchar, pnmline[256]; - char *bgstr, *textbuf = NULL; - ulg rowbytes; - int rc, len = 0; - int error = 0; - int text = FALSE; - int maxval; - double LUT_exponent; /* just the lookup table */ - double CRT_exponent = 2.2; /* just the monitor */ - double default_display_exponent; /* whole display system */ - double default_gamma = 0.0; - - - wpng_info.infile = NULL; - wpng_info.outfile = NULL; - wpng_info.image_data = NULL; - wpng_info.row_pointers = NULL; - wpng_info.filter = FALSE; - wpng_info.interlaced = FALSE; - wpng_info.have_bg = FALSE; - wpng_info.have_time = FALSE; - wpng_info.have_text = 0; - wpng_info.gamma = 0.0; - - - /* First get the default value for our display-system exponent, i.e., - * the product of the CRT exponent and the exponent corresponding to - * the frame-buffer's lookup table (LUT), if any. If the PNM image - * looks correct on the user's display system, its file gamma is the - * inverse of this value. (Note that this is not an exhaustive list - * of LUT values--e.g., OpenStep has a lot of weird ones--but it should - * cover 99% of the current possibilities. This section must ensure - * that default_display_exponent is positive.) */ - -#if defined(NeXT) - /* third-party utilities can modify the default LUT exponent */ - LUT_exponent = 1.0 / 2.2; - /* - if (some_next_function_that_returns_gamma(&next_gamma)) - LUT_exponent = 1.0 / next_gamma; - */ -#elif defined(sgi) - LUT_exponent = 1.0 / 1.7; - /* there doesn't seem to be any documented function to - * get the "gamma" value, so we do it the hard way */ - tmpfile = fopen("/etc/config/system.glGammaVal", "r"); - if (tmpfile) { - double sgi_gamma; - - fgets(tmpline, 80, tmpfile); - fclose(tmpfile); - sgi_gamma = atof(tmpline); - if (sgi_gamma > 0.0) - LUT_exponent = 1.0 / sgi_gamma; - } -#elif defined(Macintosh) - LUT_exponent = 1.8 / 2.61; - /* - if (some_mac_function_that_returns_gamma(&mac_gamma)) - LUT_exponent = mac_gamma / 2.61; - */ -#else - LUT_exponent = 1.0; /* assume no LUT: most PCs */ -#endif - - /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ - default_display_exponent = LUT_exponent * CRT_exponent; - - - /* If the user has set the SCREEN_GAMMA environment variable as suggested - * (somewhat imprecisely) in the libpng documentation, use that; otherwise - * use the default value we just calculated. Either way, the user may - * override this via a command-line option. */ - - if ((p = getenv("SCREEN_GAMMA")) != NULL) { - double exponent = atof(p); - - if (exponent > 0.0) - default_gamma = 1.0 / exponent; - } - - if (default_gamma == 0.0) - default_gamma = 1.0 / default_display_exponent; - - - /* Now parse the command line for options and the PNM filename. */ - - while (*++argv && !error) { - if (!strncmp(*argv, "-i", 2)) { - wpng_info.interlaced = TRUE; - } else if (!strncmp(*argv, "-time", 3)) { - wpng_info.modtime = time(NULL); - wpng_info.have_time = TRUE; - } else if (!strncmp(*argv, "-text", 3)) { - text = TRUE; - } else if (!strncmp(*argv, "-gamma", 2)) { - if (!*++argv) - ++error; - else { - wpng_info.gamma = atof(*argv); - if (wpng_info.gamma <= 0.0) - ++error; - else if (wpng_info.gamma > 1.01) - fprintf(stderr, PROGNAME - " warning: file gammas are usually less than 1.0\n"); - } - } else if (!strncmp(*argv, "-bgcolor", 4)) { - if (!*++argv) - ++error; - else { - bgstr = *argv; - if (strlen(bgstr) != 7 || bgstr[0] != '#') - ++error; - else { - unsigned r, g, b; /* this way quiets compiler warnings */ - - sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); - wpng_info.bg_red = (uch)r; - wpng_info.bg_green = (uch)g; - wpng_info.bg_blue = (uch)b; - wpng_info.have_bg = TRUE; - } - } - } else { - if (**argv != '-') { - inname = *argv; - if (argv[1]) /* shouldn't be any more args after filename */ - ++error; - } else - ++error; /* not expecting any other options */ - } - } - - - /* open the input and output files, or register an error and abort */ - - if (!inname) { - if (isatty(0)) { - fprintf(stderr, PROGNAME - ": must give input filename or provide image data via stdin\n"); - ++error; - } else { -#ifdef DOS_OS2_W32 - /* some buggy C libraries require BOTH setmode() and fdopen(bin) */ - setmode(fileno(stdin), O_BINARY); - setmode(fileno(stdout), O_BINARY); -#endif - if ((wpng_info.infile = fdopen(fileno(stdin), "rb")) == NULL) { - fprintf(stderr, PROGNAME - ": unable to reopen stdin in binary mode\n"); - ++error; - } else - if ((wpng_info.outfile = fdopen(fileno(stdout), "wb")) == NULL) { - fprintf(stderr, PROGNAME - ": unable to reopen stdout in binary mode\n"); - fclose(wpng_info.infile); - ++error; - } else - wpng_info.filter = TRUE; - } - } else if ((len = strlen(inname)) > 250) { - fprintf(stderr, PROGNAME ": input filename is too long [%d chars]\n", - len); - ++error; - } else if (!(wpng_info.infile = fopen(inname, "rb"))) { - fprintf(stderr, PROGNAME ": can't open input file [%s]\n", inname); - ++error; - } - - if (!error) { - fgets(pnmline, 256, wpng_info.infile); - if (pnmline[0] != 'P' || ((pnmchar = pnmline[1]) != '5' && - pnmchar != '6' && pnmchar != '8')) - { - fprintf(stderr, PROGNAME - ": input file [%s] is not a binary PGM, PPM or PAM file\n", - inname); - ++error; - } else { - wpng_info.pnmtype = (int)(pnmchar - '0'); - if (wpng_info.pnmtype != 8) - wpng_info.have_bg = FALSE; /* no need for bg if opaque */ - do { - fgets(pnmline, 256, wpng_info.infile); /* lose any comments */ - } while (pnmline[0] == '#'); - sscanf(pnmline, "%ld %ld", &wpng_info.width, &wpng_info.height); - do { - fgets(pnmline, 256, wpng_info.infile); /* more comment lines */ - } while (pnmline[0] == '#'); - sscanf(pnmline, "%d", &maxval); - if (wpng_info.width <= 0L || wpng_info.height <= 0L || - maxval != 255) - { - fprintf(stderr, PROGNAME - ": only positive width/height, maxval == 255 allowed \n"); - ++error; - } - wpng_info.sample_depth = 8; /* <==> maxval 255 */ - - if (!wpng_info.filter) { - /* make outname from inname */ - if ((p = strrchr(inname, '.')) == NULL || - (p - inname) != (len - 4)) - { - strcpy(outname, inname); - strcpy(outname+len, ".png"); - } else { - len -= 4; - strncpy(outname, inname, len); - strcpy(outname+len, ".png"); - } - /* check if outname already exists; if not, open */ - if ((wpng_info.outfile = fopen(outname, "rb")) != NULL) { - fprintf(stderr, PROGNAME ": output file exists [%s]\n", - outname); - fclose(wpng_info.outfile); - ++error; - } else if (!(wpng_info.outfile = fopen(outname, "wb"))) { - fprintf(stderr, PROGNAME ": can't open output file [%s]\n", - outname); - ++error; - } - } - } - if (error) { - fclose(wpng_info.infile); - wpng_info.infile = NULL; - if (wpng_info.filter) { - fclose(wpng_info.outfile); - wpng_info.outfile = NULL; - } - } - } - - - /* if we had any errors, print usage and die horrible death...arrr! */ - - if (error) { - fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, APPNAME); - writepng_version_info(); - fprintf(stderr, "\n" -"Usage: %s [-gamma exp] [-bgcolor bg] [-text] [-time] [-interlace] pnmfile\n" -"or: ... | %s [-gamma exp] [-bgcolor bg] [-text] [-time] [-interlace] | ...\n" - " exp \ttransfer-function exponent (``gamma'') of the image in\n" - "\t\t floating-point format (e.g., ``%.5f''); if image looks\n" - "\t\t correct on given display system, image gamma is equal to\n" - "\t\t inverse of display-system exponent, i.e., 1 / (LUT * CRT)\n" - "\t\t (where LUT = lookup-table exponent and CRT = CRT exponent;\n" - "\t\t first varies, second is usually 2.2, all are positive)\n" - " bg \tdesired background color for alpha-channel images, in\n" - "\t\t 7-character hex RGB format (e.g., ``#ff7700'' for orange:\n" - "\t\t same as HTML colors)\n" - " -text\tprompt interactively for text info (tEXt chunks)\n" - " -time\tinclude a tIME chunk (last modification time)\n" - " -interlace\twrite interlaced PNG image\n" - "\n" -"pnmfile or stdin must be a binary PGM (`P5'), PPM (`P6') or (extremely\n" -"unofficial and unsupported!) PAM (`P8') file. Currently it is required\n" -"to have maxval == 255 (i.e., no scaling). If pnmfile is specified, it\n" -"is converted to the corresponding PNG file with the same base name but a\n" -"``.png'' extension; files read from stdin are converted and sent to stdout.\n" -"The conversion is progressive (low memory usage) unless interlacing is\n" -"requested; in that case the whole image will be buffered in memory and\n" -"written in one call.\n" - "\n", PROGNAME, PROGNAME, default_gamma); - exit(1); - } - - - /* prepare the text buffers for libpng's use; note that even though - * PNG's png_text struct includes a length field, we don't have to fill - * it out */ - - if (text && -#ifndef DOS_OS2_W32 - (keybd = fdopen(fileno(stderr), "r")) != NULL && -#endif - (textbuf = (char *)malloc((5 + 9)*75)) != NULL) - { - int i, valid, result; - - fprintf(stderr, - "Enter text info (no more than 72 characters per line);\n"); - fprintf(stderr, "to skip a field, hit the key.\n"); - /* note: just leaves len == 1 */ - - do { - valid = TRUE; - p = textbuf + TEXT_TITLE_OFFSET; - fprintf(stderr, " Title: "); - fflush(stderr); - if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { - if (p[len-1] == '\n') - p[--len] = '\0'; - wpng_info.title = p; - wpng_info.have_text |= TEXT_TITLE; - if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { - fprintf(stderr, " " PROGNAME " warning: character code" - " %u is %sdiscouraged by the PNG\n specification " - "[first occurrence was at character position #%d]\n", - (unsigned)p[result], (p[result] == 27)? "strongly " : "", - result+1); - fflush(stderr); -#ifdef FORBID_LATIN1_CTRL - wpng_info.have_text &= ~TEXT_TITLE; - valid = FALSE; -#else - if (p[result] == 27) { /* escape character */ - wpng_info.have_text &= ~TEXT_TITLE; - valid = FALSE; - } -#endif - } - } - } while (!valid); - - do { - valid = TRUE; - p = textbuf + TEXT_AUTHOR_OFFSET; - fprintf(stderr, " Author: "); - fflush(stderr); - if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { - if (p[len-1] == '\n') - p[--len] = '\0'; - wpng_info.author = p; - wpng_info.have_text |= TEXT_AUTHOR; - if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { - fprintf(stderr, " " PROGNAME " warning: character code" - " %u is %sdiscouraged by the PNG\n specification " - "[first occurrence was at character position #%d]\n", - (unsigned)p[result], (p[result] == 27)? "strongly " : "", - result+1); - fflush(stderr); -#ifdef FORBID_LATIN1_CTRL - wpng_info.have_text &= ~TEXT_AUTHOR; - valid = FALSE; -#else - if (p[result] == 27) { /* escape character */ - wpng_info.have_text &= ~TEXT_AUTHOR; - valid = FALSE; - } -#endif - } - } - } while (!valid); - - do { - valid = TRUE; - p = textbuf + TEXT_DESC_OFFSET; - fprintf(stderr, " Description (up to 9 lines):\n"); - for (i = 1; i < 10; ++i) { - fprintf(stderr, " [%d] ", i); - fflush(stderr); - if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) - p += len; /* now points at NULL; char before is newline */ - else - break; - } - if ((len = p - (textbuf + TEXT_DESC_OFFSET)) > 1) { - if (p[-1] == '\n') { - p[-1] = '\0'; - --len; - } - wpng_info.desc = textbuf + TEXT_DESC_OFFSET; - wpng_info.have_text |= TEXT_DESC; - p = textbuf + TEXT_DESC_OFFSET; - if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { - fprintf(stderr, " " PROGNAME " warning: character code" - " %u is %sdiscouraged by the PNG\n specification " - "[first occurrence was at character position #%d]\n", - (unsigned)p[result], (p[result] == 27)? "strongly " : "", - result+1); - fflush(stderr); -#ifdef FORBID_LATIN1_CTRL - wpng_info.have_text &= ~TEXT_DESC; - valid = FALSE; -#else - if (p[result] == 27) { /* escape character */ - wpng_info.have_text &= ~TEXT_DESC; - valid = FALSE; - } -#endif - } - } - } while (!valid); - - do { - valid = TRUE; - p = textbuf + TEXT_COPY_OFFSET; - fprintf(stderr, " Copyright: "); - fflush(stderr); - if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { - if (p[len-1] == '\n') - p[--len] = '\0'; - wpng_info.copyright = p; - wpng_info.have_text |= TEXT_COPY; - if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { - fprintf(stderr, " " PROGNAME " warning: character code" - " %u is %sdiscouraged by the PNG\n specification " - "[first occurrence was at character position #%d]\n", - (unsigned)p[result], (p[result] == 27)? "strongly " : "", - result+1); - fflush(stderr); -#ifdef FORBID_LATIN1_CTRL - wpng_info.have_text &= ~TEXT_COPY; - valid = FALSE; -#else - if (p[result] == 27) { /* escape character */ - wpng_info.have_text &= ~TEXT_COPY; - valid = FALSE; - } -#endif - } - } - } while (!valid); - - do { - valid = TRUE; - p = textbuf + TEXT_EMAIL_OFFSET; - fprintf(stderr, " E-mail: "); - fflush(stderr); - if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { - if (p[len-1] == '\n') - p[--len] = '\0'; - wpng_info.email = p; - wpng_info.have_text |= TEXT_EMAIL; - if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { - fprintf(stderr, " " PROGNAME " warning: character code" - " %u is %sdiscouraged by the PNG\n specification " - "[first occurrence was at character position #%d]\n", - (unsigned)p[result], (p[result] == 27)? "strongly " : "", - result+1); - fflush(stderr); -#ifdef FORBID_LATIN1_CTRL - wpng_info.have_text &= ~TEXT_EMAIL; - valid = FALSE; -#else - if (p[result] == 27) { /* escape character */ - wpng_info.have_text &= ~TEXT_EMAIL; - valid = FALSE; - } -#endif - } - } - } while (!valid); - - do { - valid = TRUE; - p = textbuf + TEXT_URL_OFFSET; - fprintf(stderr, " URL: "); - fflush(stderr); - if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { - if (p[len-1] == '\n') - p[--len] = '\0'; - wpng_info.url = p; - wpng_info.have_text |= TEXT_URL; - if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { - fprintf(stderr, " " PROGNAME " warning: character code" - " %u is %sdiscouraged by the PNG\n specification " - "[first occurrence was at character position #%d]\n", - (unsigned)p[result], (p[result] == 27)? "strongly " : "", - result+1); - fflush(stderr); -#ifdef FORBID_LATIN1_CTRL - wpng_info.have_text &= ~TEXT_URL; - valid = FALSE; -#else - if (p[result] == 27) { /* escape character */ - wpng_info.have_text &= ~TEXT_URL; - valid = FALSE; - } -#endif - } - } - } while (!valid); - -#ifndef DOS_OS2_W32 - fclose(keybd); -#endif - - } else if (text) { - fprintf(stderr, PROGNAME ": unable to allocate memory for text\n"); - text = FALSE; - wpng_info.have_text = 0; - } - - - /* allocate libpng stuff, initialize transformations, write pre-IDAT data */ - - if ((rc = writepng_init(&wpng_info)) != 0) { - switch (rc) { - case 2: - fprintf(stderr, PROGNAME - ": libpng initialization problem (longjmp)\n"); - break; - case 4: - fprintf(stderr, PROGNAME ": insufficient memory\n"); - break; - case 11: - fprintf(stderr, PROGNAME - ": internal logic error (unexpected PNM type)\n"); - break; - default: - fprintf(stderr, PROGNAME - ": unknown writepng_init() error\n"); - break; - } - exit(rc); - } - - - /* free textbuf, since it's a completely local variable and all text info - * has just been written to the PNG file */ - - if (text && textbuf) { - free(textbuf); - textbuf = NULL; - } - - - /* calculate rowbytes on basis of image type; note that this becomes much - * more complicated if we choose to support PBM type, ASCII PNM types, or - * 16-bit-per-sample binary data [currently not an official NetPBM type] */ - - if (wpng_info.pnmtype == 5) - rowbytes = wpng_info.width; - else if (wpng_info.pnmtype == 6) - rowbytes = wpng_info.width * 3; - else /* if (wpng_info.pnmtype == 8) */ - rowbytes = wpng_info.width * 4; - - - /* read and write the image, either in its entirety (if writing interlaced - * PNG) or row by row (if non-interlaced) */ - - fprintf(stderr, "Encoding image data...\n"); - fflush(stderr); - - if (wpng_info.interlaced) { - long i; - ulg bytes; - ulg image_bytes = rowbytes * wpng_info.height; /* overflow? */ - - wpng_info.image_data = (uch *)malloc(image_bytes); - wpng_info.row_pointers = (uch **)malloc(wpng_info.height*sizeof(uch *)); - if (wpng_info.image_data == NULL || wpng_info.row_pointers == NULL) { - fprintf(stderr, PROGNAME ": insufficient memory for image data\n"); - writepng_cleanup(&wpng_info); - wpng_cleanup(); - exit(5); - } - for (i = 0; i < wpng_info.height; ++i) - wpng_info.row_pointers[i] = wpng_info.image_data + i*rowbytes; - bytes = fread(wpng_info.image_data, 1, image_bytes, wpng_info.infile); - if (bytes != image_bytes) { - fprintf(stderr, PROGNAME ": expected %lu bytes, got %lu bytes\n", - image_bytes, bytes); - fprintf(stderr, " (continuing anyway)\n"); - } - if (writepng_encode_image(&wpng_info) != 0) { - fprintf(stderr, PROGNAME - ": libpng problem (longjmp) while writing image data\n"); - writepng_cleanup(&wpng_info); - wpng_cleanup(); - exit(2); - } - - } else /* not interlaced: write progressively (row by row) */ { - long j; - ulg bytes; - - wpng_info.image_data = (uch *)malloc(rowbytes); - if (wpng_info.image_data == NULL) { - fprintf(stderr, PROGNAME ": insufficient memory for row data\n"); - writepng_cleanup(&wpng_info); - wpng_cleanup(); - exit(5); - } - error = 0; - for (j = wpng_info.height; j > 0L; --j) { - bytes = fread(wpng_info.image_data, 1, rowbytes, wpng_info.infile); - if (bytes != rowbytes) { - fprintf(stderr, PROGNAME - ": expected %lu bytes, got %lu bytes (row %ld)\n", rowbytes, - bytes, wpng_info.height-j); - ++error; - break; - } - if (writepng_encode_row(&wpng_info) != 0) { - fprintf(stderr, PROGNAME - ": libpng problem (longjmp) while writing row %ld\n", - wpng_info.height-j); - ++error; - break; - } - } - if (error) { - writepng_cleanup(&wpng_info); - wpng_cleanup(); - exit(2); - } - if (writepng_encode_finish(&wpng_info) != 0) { - fprintf(stderr, PROGNAME ": error on final libpng call\n"); - writepng_cleanup(&wpng_info); - wpng_cleanup(); - exit(2); - } - } - - - /* OK, we're done (successfully): clean up all resources and quit */ - - fprintf(stderr, "Done.\n"); - fflush(stderr); - - writepng_cleanup(&wpng_info); - wpng_cleanup(); - - return 0; -} - - - - - -static int wpng_isvalid_latin1(uch *p, int len) -{ - int i, result = -1; - - for (i = 0; i < len; ++i) { - if (p[i] == 10 || (p[i] > 31 && p[i] < 127) || p[i] > 160) - continue; /* character is completely OK */ - if (result < 0 || (p[result] != 27 && p[i] == 27)) - result = i; /* mark location of first questionable one */ - } /* or of first escape character (bad) */ - - return result; -} - - - - - -static void wpng_cleanup(void) -{ - if (wpng_info.outfile) { - fclose(wpng_info.outfile); - wpng_info.outfile = NULL; - } - - if (wpng_info.infile) { - fclose(wpng_info.infile); - wpng_info.infile = NULL; - } - - if (wpng_info.image_data) { - free(wpng_info.image_data); - wpng_info.image_data = NULL; - } - - if (wpng_info.row_pointers) { - free(wpng_info.row_pointers); - wpng_info.row_pointers = NULL; - } -} - - - - -#ifdef DOS_OS2_W32 - -static char *dos_kbd_gets(char *buf, int len) -{ - int ch, count=0; - - do { - buf[count++] = ch = getche(); - } while (ch != '\r' && count < len-1); - - buf[count--] = '\0'; /* terminate string */ - if (buf[count] == '\r') /* Enter key makes CR, so change to newline */ - buf[count] = '\n'; - - fprintf(stderr, "\n"); /* Enter key does *not* cause a newline */ - fflush(stderr); - - return buf; -} - -#endif /* DOS_OS2_W32 */ +/*--------------------------------------------------------------------------- + + wpng - simple PNG-writing program wpng.c + + This program converts certain NetPBM binary files (grayscale and RGB, + maxval = 255) to PNG. Non-interlaced PNGs are written progressively; + interlaced PNGs are read and written in one memory-intensive blast. + Thanks to Jean-loup Gailly for providing the necessary trick to read + interactive text from the keyboard while stdin is redirected. + + NOTE: includes provisional support for PNM type "8" (portable alphamap) + images, presumed to be a 32-bit interleaved RGBA format; no pro- + vision for possible interleaved grayscale+alpha (16-bit) format. + THIS IS UNLIKELY TO BECOME AN OFFICIAL NETPBM ALPHA FORMAT! + + to do: + - delete output file if quit before calling any writepng routines + - process backspace with -text option under DOS/Win? (currently get ^H) + + --------------------------------------------------------------------------- + + Changelog: + - 1.01: initial public release + - 1.02: modified to allow abbreviated options + - 1.03: removed extraneous character from usage screen; fixed bug in + command-line parsing + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + ---------------------------------------------------------------------------*/ + +#define PROGNAME "wpng" +#define VERSION "1.03 of 19 March 2000" +#define APPNAME "Simple PGM/PPM/PAM to PNG Converter" + +#if defined(__MSDOS__) || defined(__OS2__) +# define DOS_OS2_W32 +#elif defined(_WIN32) || defined(__WIN32__) +# define DOS_OS2_W32 +#endif + +#include +#include +#include +#include /* for jmpbuf declaration in writepng.h */ +#include + +#ifdef DOS_OS2_W32 +# include /* for isatty(), setmode() prototypes */ +# include /* O_BINARY for fdopen() without text translation */ +# ifdef __EMX__ +# ifndef getch +# define getch() _read_kbd(0, 1, 0) /* need getche() */ +# endif +# else /* !__EMX__ */ +# ifdef __GO32__ +# include +# define getch() getkey() /* GRR: need getche() */ +# else +# include /* for getche() console input */ +# endif +# endif /* ?__EMX__ */ +# define FGETS(buf,len,stream) dos_kbd_gets(buf,len) +#else +# include /* for isatty() prototype */ +# define FGETS fgets +#endif + +/* #define DEBUG : this enables the Trace() macros */ + +/* #define FORBID_LATIN1_CTRL : this requires the user to re-enter any + text that includes control characters discouraged by the PNG spec; text + that includes an escape character (27) must be re-entered regardless */ + +#include "writepng.h" /* typedefs, common macros, writepng prototypes */ + + + +/* local prototypes */ + +static int wpng_isvalid_latin1(uch *p, int len); +static void wpng_cleanup(void); + +#ifdef DOS_OS2_W32 + static char *dos_kbd_gets(char *buf, int len); +#endif + + + +static mainprog_info wpng_info; /* lone global */ + + + +int main(int argc, char **argv) +{ +#ifndef DOS_OS2_W32 + FILE *keybd; +#endif +#ifdef sgi + FILE *tmpfile; /* or we could just use keybd, since no overlap */ + char tmpline[80]; +#endif + char *inname = NULL, outname[256]; + char *p, pnmchar, pnmline[256]; + char *bgstr, *textbuf = NULL; + ulg rowbytes; + int rc, len = 0; + int error = 0; + int text = FALSE; + int maxval; + double LUT_exponent; /* just the lookup table */ + double CRT_exponent = 2.2; /* just the monitor */ + double default_display_exponent; /* whole display system */ + double default_gamma = 0.0; + + + wpng_info.infile = NULL; + wpng_info.outfile = NULL; + wpng_info.image_data = NULL; + wpng_info.row_pointers = NULL; + wpng_info.filter = FALSE; + wpng_info.interlaced = FALSE; + wpng_info.have_bg = FALSE; + wpng_info.have_time = FALSE; + wpng_info.have_text = 0; + wpng_info.gamma = 0.0; + + + /* First get the default value for our display-system exponent, i.e., + * the product of the CRT exponent and the exponent corresponding to + * the frame-buffer's lookup table (LUT), if any. If the PNM image + * looks correct on the user's display system, its file gamma is the + * inverse of this value. (Note that this is not an exhaustive list + * of LUT values--e.g., OpenStep has a lot of weird ones--but it should + * cover 99% of the current possibilities. This section must ensure + * that default_display_exponent is positive.) */ + +#if defined(NeXT) + /* third-party utilities can modify the default LUT exponent */ + LUT_exponent = 1.0 / 2.2; + /* + if (some_next_function_that_returns_gamma(&next_gamma)) + LUT_exponent = 1.0 / next_gamma; + */ +#elif defined(sgi) + LUT_exponent = 1.0 / 1.7; + /* there doesn't seem to be any documented function to + * get the "gamma" value, so we do it the hard way */ + tmpfile = fopen("/etc/config/system.glGammaVal", "r"); + if (tmpfile) { + double sgi_gamma; + + fgets(tmpline, 80, tmpfile); + fclose(tmpfile); + sgi_gamma = atof(tmpline); + if (sgi_gamma > 0.0) + LUT_exponent = 1.0 / sgi_gamma; + } +#elif defined(Macintosh) + LUT_exponent = 1.8 / 2.61; + /* + if (some_mac_function_that_returns_gamma(&mac_gamma)) + LUT_exponent = mac_gamma / 2.61; + */ +#else + LUT_exponent = 1.0; /* assume no LUT: most PCs */ +#endif + + /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ + default_display_exponent = LUT_exponent * CRT_exponent; + + + /* If the user has set the SCREEN_GAMMA environment variable as suggested + * (somewhat imprecisely) in the libpng documentation, use that; otherwise + * use the default value we just calculated. Either way, the user may + * override this via a command-line option. */ + + if ((p = getenv("SCREEN_GAMMA")) != NULL) { + double exponent = atof(p); + + if (exponent > 0.0) + default_gamma = 1.0 / exponent; + } + + if (default_gamma == 0.0) + default_gamma = 1.0 / default_display_exponent; + + + /* Now parse the command line for options and the PNM filename. */ + + while (*++argv && !error) { + if (!strncmp(*argv, "-i", 2)) { + wpng_info.interlaced = TRUE; + } else if (!strncmp(*argv, "-time", 3)) { + wpng_info.modtime = time(NULL); + wpng_info.have_time = TRUE; + } else if (!strncmp(*argv, "-text", 3)) { + text = TRUE; + } else if (!strncmp(*argv, "-gamma", 2)) { + if (!*++argv) + ++error; + else { + wpng_info.gamma = atof(*argv); + if (wpng_info.gamma <= 0.0) + ++error; + else if (wpng_info.gamma > 1.01) + fprintf(stderr, PROGNAME + " warning: file gammas are usually less than 1.0\n"); + } + } else if (!strncmp(*argv, "-bgcolor", 4)) { + if (!*++argv) + ++error; + else { + bgstr = *argv; + if (strlen(bgstr) != 7 || bgstr[0] != '#') + ++error; + else { + unsigned r, g, b; /* this way quiets compiler warnings */ + + sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); + wpng_info.bg_red = (uch)r; + wpng_info.bg_green = (uch)g; + wpng_info.bg_blue = (uch)b; + wpng_info.have_bg = TRUE; + } + } + } else { + if (**argv != '-') { + inname = *argv; + if (argv[1]) /* shouldn't be any more args after filename */ + ++error; + } else + ++error; /* not expecting any other options */ + } + } + + + /* open the input and output files, or register an error and abort */ + + if (!inname) { + if (isatty(0)) { + fprintf(stderr, PROGNAME + ": must give input filename or provide image data via stdin\n"); + ++error; + } else { +#ifdef DOS_OS2_W32 + /* some buggy C libraries require BOTH setmode() and fdopen(bin) */ + setmode(fileno(stdin), O_BINARY); + setmode(fileno(stdout), O_BINARY); +#endif + if ((wpng_info.infile = fdopen(fileno(stdin), "rb")) == NULL) { + fprintf(stderr, PROGNAME + ": unable to reopen stdin in binary mode\n"); + ++error; + } else + if ((wpng_info.outfile = fdopen(fileno(stdout), "wb")) == NULL) { + fprintf(stderr, PROGNAME + ": unable to reopen stdout in binary mode\n"); + fclose(wpng_info.infile); + ++error; + } else + wpng_info.filter = TRUE; + } + } else if ((len = strlen(inname)) > 250) { + fprintf(stderr, PROGNAME ": input filename is too long [%d chars]\n", + len); + ++error; + } else if (!(wpng_info.infile = fopen(inname, "rb"))) { + fprintf(stderr, PROGNAME ": can't open input file [%s]\n", inname); + ++error; + } + + if (!error) { + fgets(pnmline, 256, wpng_info.infile); + if (pnmline[0] != 'P' || ((pnmchar = pnmline[1]) != '5' && + pnmchar != '6' && pnmchar != '8')) + { + fprintf(stderr, PROGNAME + ": input file [%s] is not a binary PGM, PPM or PAM file\n", + inname); + ++error; + } else { + wpng_info.pnmtype = (int)(pnmchar - '0'); + if (wpng_info.pnmtype != 8) + wpng_info.have_bg = FALSE; /* no need for bg if opaque */ + do { + fgets(pnmline, 256, wpng_info.infile); /* lose any comments */ + } while (pnmline[0] == '#'); + sscanf(pnmline, "%ld %ld", &wpng_info.width, &wpng_info.height); + do { + fgets(pnmline, 256, wpng_info.infile); /* more comment lines */ + } while (pnmline[0] == '#'); + sscanf(pnmline, "%d", &maxval); + if (wpng_info.width <= 0L || wpng_info.height <= 0L || + maxval != 255) + { + fprintf(stderr, PROGNAME + ": only positive width/height, maxval == 255 allowed \n"); + ++error; + } + wpng_info.sample_depth = 8; /* <==> maxval 255 */ + + if (!wpng_info.filter) { + /* make outname from inname */ + if ((p = strrchr(inname, '.')) == NULL || + (p - inname) != (len - 4)) + { + strcpy(outname, inname); + strcpy(outname+len, ".png"); + } else { + len -= 4; + strncpy(outname, inname, len); + strcpy(outname+len, ".png"); + } + /* check if outname already exists; if not, open */ + if ((wpng_info.outfile = fopen(outname, "rb")) != NULL) { + fprintf(stderr, PROGNAME ": output file exists [%s]\n", + outname); + fclose(wpng_info.outfile); + ++error; + } else if (!(wpng_info.outfile = fopen(outname, "wb"))) { + fprintf(stderr, PROGNAME ": can't open output file [%s]\n", + outname); + ++error; + } + } + } + if (error) { + fclose(wpng_info.infile); + wpng_info.infile = NULL; + if (wpng_info.filter) { + fclose(wpng_info.outfile); + wpng_info.outfile = NULL; + } + } + } + + + /* if we had any errors, print usage and die horrible death...arrr! */ + + if (error) { + fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, APPNAME); + writepng_version_info(); + fprintf(stderr, "\n" +"Usage: %s [-gamma exp] [-bgcolor bg] [-text] [-time] [-interlace] pnmfile\n" +"or: ... | %s [-gamma exp] [-bgcolor bg] [-text] [-time] [-interlace] | ...\n" + " exp \ttransfer-function exponent (``gamma'') of the image in\n" + "\t\t floating-point format (e.g., ``%.5f''); if image looks\n" + "\t\t correct on given display system, image gamma is equal to\n" + "\t\t inverse of display-system exponent, i.e., 1 / (LUT * CRT)\n" + "\t\t (where LUT = lookup-table exponent and CRT = CRT exponent;\n" + "\t\t first varies, second is usually 2.2, all are positive)\n" + " bg \tdesired background color for alpha-channel images, in\n" + "\t\t 7-character hex RGB format (e.g., ``#ff7700'' for orange:\n" + "\t\t same as HTML colors)\n" + " -text\tprompt interactively for text info (tEXt chunks)\n" + " -time\tinclude a tIME chunk (last modification time)\n" + " -interlace\twrite interlaced PNG image\n" + "\n" +"pnmfile or stdin must be a binary PGM (`P5'), PPM (`P6') or (extremely\n" +"unofficial and unsupported!) PAM (`P8') file. Currently it is required\n" +"to have maxval == 255 (i.e., no scaling). If pnmfile is specified, it\n" +"is converted to the corresponding PNG file with the same base name but a\n" +"``.png'' extension; files read from stdin are converted and sent to stdout.\n" +"The conversion is progressive (low memory usage) unless interlacing is\n" +"requested; in that case the whole image will be buffered in memory and\n" +"written in one call.\n" + "\n", PROGNAME, PROGNAME, default_gamma); + exit(1); + } + + + /* prepare the text buffers for libpng's use; note that even though + * PNG's png_text struct includes a length field, we don't have to fill + * it out */ + + if (text && +#ifndef DOS_OS2_W32 + (keybd = fdopen(fileno(stderr), "r")) != NULL && +#endif + (textbuf = (char *)malloc((5 + 9)*75)) != NULL) + { + int i, valid, result; + + fprintf(stderr, + "Enter text info (no more than 72 characters per line);\n"); + fprintf(stderr, "to skip a field, hit the key.\n"); + /* note: just leaves len == 1 */ + + do { + valid = TRUE; + p = textbuf + TEXT_TITLE_OFFSET; + fprintf(stderr, " Title: "); + fflush(stderr); + if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { + if (p[len-1] == '\n') + p[--len] = '\0'; + wpng_info.title = p; + wpng_info.have_text |= TEXT_TITLE; + if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { + fprintf(stderr, " " PROGNAME " warning: character code" + " %u is %sdiscouraged by the PNG\n specification " + "[first occurrence was at character position #%d]\n", + (unsigned)p[result], (p[result] == 27)? "strongly " : "", + result+1); + fflush(stderr); +#ifdef FORBID_LATIN1_CTRL + wpng_info.have_text &= ~TEXT_TITLE; + valid = FALSE; +#else + if (p[result] == 27) { /* escape character */ + wpng_info.have_text &= ~TEXT_TITLE; + valid = FALSE; + } +#endif + } + } + } while (!valid); + + do { + valid = TRUE; + p = textbuf + TEXT_AUTHOR_OFFSET; + fprintf(stderr, " Author: "); + fflush(stderr); + if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { + if (p[len-1] == '\n') + p[--len] = '\0'; + wpng_info.author = p; + wpng_info.have_text |= TEXT_AUTHOR; + if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { + fprintf(stderr, " " PROGNAME " warning: character code" + " %u is %sdiscouraged by the PNG\n specification " + "[first occurrence was at character position #%d]\n", + (unsigned)p[result], (p[result] == 27)? "strongly " : "", + result+1); + fflush(stderr); +#ifdef FORBID_LATIN1_CTRL + wpng_info.have_text &= ~TEXT_AUTHOR; + valid = FALSE; +#else + if (p[result] == 27) { /* escape character */ + wpng_info.have_text &= ~TEXT_AUTHOR; + valid = FALSE; + } +#endif + } + } + } while (!valid); + + do { + valid = TRUE; + p = textbuf + TEXT_DESC_OFFSET; + fprintf(stderr, " Description (up to 9 lines):\n"); + for (i = 1; i < 10; ++i) { + fprintf(stderr, " [%d] ", i); + fflush(stderr); + if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) + p += len; /* now points at NULL; char before is newline */ + else + break; + } + if ((len = p - (textbuf + TEXT_DESC_OFFSET)) > 1) { + if (p[-1] == '\n') { + p[-1] = '\0'; + --len; + } + wpng_info.desc = textbuf + TEXT_DESC_OFFSET; + wpng_info.have_text |= TEXT_DESC; + p = textbuf + TEXT_DESC_OFFSET; + if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { + fprintf(stderr, " " PROGNAME " warning: character code" + " %u is %sdiscouraged by the PNG\n specification " + "[first occurrence was at character position #%d]\n", + (unsigned)p[result], (p[result] == 27)? "strongly " : "", + result+1); + fflush(stderr); +#ifdef FORBID_LATIN1_CTRL + wpng_info.have_text &= ~TEXT_DESC; + valid = FALSE; +#else + if (p[result] == 27) { /* escape character */ + wpng_info.have_text &= ~TEXT_DESC; + valid = FALSE; + } +#endif + } + } + } while (!valid); + + do { + valid = TRUE; + p = textbuf + TEXT_COPY_OFFSET; + fprintf(stderr, " Copyright: "); + fflush(stderr); + if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { + if (p[len-1] == '\n') + p[--len] = '\0'; + wpng_info.copyright = p; + wpng_info.have_text |= TEXT_COPY; + if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { + fprintf(stderr, " " PROGNAME " warning: character code" + " %u is %sdiscouraged by the PNG\n specification " + "[first occurrence was at character position #%d]\n", + (unsigned)p[result], (p[result] == 27)? "strongly " : "", + result+1); + fflush(stderr); +#ifdef FORBID_LATIN1_CTRL + wpng_info.have_text &= ~TEXT_COPY; + valid = FALSE; +#else + if (p[result] == 27) { /* escape character */ + wpng_info.have_text &= ~TEXT_COPY; + valid = FALSE; + } +#endif + } + } + } while (!valid); + + do { + valid = TRUE; + p = textbuf + TEXT_EMAIL_OFFSET; + fprintf(stderr, " E-mail: "); + fflush(stderr); + if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { + if (p[len-1] == '\n') + p[--len] = '\0'; + wpng_info.email = p; + wpng_info.have_text |= TEXT_EMAIL; + if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { + fprintf(stderr, " " PROGNAME " warning: character code" + " %u is %sdiscouraged by the PNG\n specification " + "[first occurrence was at character position #%d]\n", + (unsigned)p[result], (p[result] == 27)? "strongly " : "", + result+1); + fflush(stderr); +#ifdef FORBID_LATIN1_CTRL + wpng_info.have_text &= ~TEXT_EMAIL; + valid = FALSE; +#else + if (p[result] == 27) { /* escape character */ + wpng_info.have_text &= ~TEXT_EMAIL; + valid = FALSE; + } +#endif + } + } + } while (!valid); + + do { + valid = TRUE; + p = textbuf + TEXT_URL_OFFSET; + fprintf(stderr, " URL: "); + fflush(stderr); + if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { + if (p[len-1] == '\n') + p[--len] = '\0'; + wpng_info.url = p; + wpng_info.have_text |= TEXT_URL; + if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { + fprintf(stderr, " " PROGNAME " warning: character code" + " %u is %sdiscouraged by the PNG\n specification " + "[first occurrence was at character position #%d]\n", + (unsigned)p[result], (p[result] == 27)? "strongly " : "", + result+1); + fflush(stderr); +#ifdef FORBID_LATIN1_CTRL + wpng_info.have_text &= ~TEXT_URL; + valid = FALSE; +#else + if (p[result] == 27) { /* escape character */ + wpng_info.have_text &= ~TEXT_URL; + valid = FALSE; + } +#endif + } + } + } while (!valid); + +#ifndef DOS_OS2_W32 + fclose(keybd); +#endif + + } else if (text) { + fprintf(stderr, PROGNAME ": unable to allocate memory for text\n"); + text = FALSE; + wpng_info.have_text = 0; + } + + + /* allocate libpng stuff, initialize transformations, write pre-IDAT data */ + + if ((rc = writepng_init(&wpng_info)) != 0) { + switch (rc) { + case 2: + fprintf(stderr, PROGNAME + ": libpng initialization problem (longjmp)\n"); + break; + case 4: + fprintf(stderr, PROGNAME ": insufficient memory\n"); + break; + case 11: + fprintf(stderr, PROGNAME + ": internal logic error (unexpected PNM type)\n"); + break; + default: + fprintf(stderr, PROGNAME + ": unknown writepng_init() error\n"); + break; + } + exit(rc); + } + + + /* free textbuf, since it's a completely local variable and all text info + * has just been written to the PNG file */ + + if (text && textbuf) { + free(textbuf); + textbuf = NULL; + } + + + /* calculate rowbytes on basis of image type; note that this becomes much + * more complicated if we choose to support PBM type, ASCII PNM types, or + * 16-bit-per-sample binary data [currently not an official NetPBM type] */ + + if (wpng_info.pnmtype == 5) + rowbytes = wpng_info.width; + else if (wpng_info.pnmtype == 6) + rowbytes = wpng_info.width * 3; + else /* if (wpng_info.pnmtype == 8) */ + rowbytes = wpng_info.width * 4; + + + /* read and write the image, either in its entirety (if writing interlaced + * PNG) or row by row (if non-interlaced) */ + + fprintf(stderr, "Encoding image data...\n"); + fflush(stderr); + + if (wpng_info.interlaced) { + long i; + ulg bytes; + ulg image_bytes = rowbytes * wpng_info.height; /* overflow? */ + + wpng_info.image_data = (uch *)malloc(image_bytes); + wpng_info.row_pointers = (uch **)malloc(wpng_info.height*sizeof(uch *)); + if (wpng_info.image_data == NULL || wpng_info.row_pointers == NULL) { + fprintf(stderr, PROGNAME ": insufficient memory for image data\n"); + writepng_cleanup(&wpng_info); + wpng_cleanup(); + exit(5); + } + for (i = 0; i < wpng_info.height; ++i) + wpng_info.row_pointers[i] = wpng_info.image_data + i*rowbytes; + bytes = fread(wpng_info.image_data, 1, image_bytes, wpng_info.infile); + if (bytes != image_bytes) { + fprintf(stderr, PROGNAME ": expected %lu bytes, got %lu bytes\n", + image_bytes, bytes); + fprintf(stderr, " (continuing anyway)\n"); + } + if (writepng_encode_image(&wpng_info) != 0) { + fprintf(stderr, PROGNAME + ": libpng problem (longjmp) while writing image data\n"); + writepng_cleanup(&wpng_info); + wpng_cleanup(); + exit(2); + } + + } else /* not interlaced: write progressively (row by row) */ { + long j; + ulg bytes; + + wpng_info.image_data = (uch *)malloc(rowbytes); + if (wpng_info.image_data == NULL) { + fprintf(stderr, PROGNAME ": insufficient memory for row data\n"); + writepng_cleanup(&wpng_info); + wpng_cleanup(); + exit(5); + } + error = 0; + for (j = wpng_info.height; j > 0L; --j) { + bytes = fread(wpng_info.image_data, 1, rowbytes, wpng_info.infile); + if (bytes != rowbytes) { + fprintf(stderr, PROGNAME + ": expected %lu bytes, got %lu bytes (row %ld)\n", rowbytes, + bytes, wpng_info.height-j); + ++error; + break; + } + if (writepng_encode_row(&wpng_info) != 0) { + fprintf(stderr, PROGNAME + ": libpng problem (longjmp) while writing row %ld\n", + wpng_info.height-j); + ++error; + break; + } + } + if (error) { + writepng_cleanup(&wpng_info); + wpng_cleanup(); + exit(2); + } + if (writepng_encode_finish(&wpng_info) != 0) { + fprintf(stderr, PROGNAME ": error on final libpng call\n"); + writepng_cleanup(&wpng_info); + wpng_cleanup(); + exit(2); + } + } + + + /* OK, we're done (successfully): clean up all resources and quit */ + + fprintf(stderr, "Done.\n"); + fflush(stderr); + + writepng_cleanup(&wpng_info); + wpng_cleanup(); + + return 0; +} + + + + + +static int wpng_isvalid_latin1(uch *p, int len) +{ + int i, result = -1; + + for (i = 0; i < len; ++i) { + if (p[i] == 10 || (p[i] > 31 && p[i] < 127) || p[i] > 160) + continue; /* character is completely OK */ + if (result < 0 || (p[result] != 27 && p[i] == 27)) + result = i; /* mark location of first questionable one */ + } /* or of first escape character (bad) */ + + return result; +} + + + + + +static void wpng_cleanup(void) +{ + if (wpng_info.outfile) { + fclose(wpng_info.outfile); + wpng_info.outfile = NULL; + } + + if (wpng_info.infile) { + fclose(wpng_info.infile); + wpng_info.infile = NULL; + } + + if (wpng_info.image_data) { + free(wpng_info.image_data); + wpng_info.image_data = NULL; + } + + if (wpng_info.row_pointers) { + free(wpng_info.row_pointers); + wpng_info.row_pointers = NULL; + } +} + + + + +#ifdef DOS_OS2_W32 + +static char *dos_kbd_gets(char *buf, int len) +{ + int ch, count=0; + + do { + buf[count++] = ch = getche(); + } while (ch != '\r' && count < len-1); + + buf[count--] = '\0'; /* terminate string */ + if (buf[count] == '\r') /* Enter key makes CR, so change to newline */ + buf[count] = '\n'; + + fprintf(stderr, "\n"); /* Enter key does *not* cause a newline */ + fflush(stderr); + + return buf; +} + +#endif /* DOS_OS2_W32 */ diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/writepng.c b/src/dep/src/irrlicht/libpng/contrib/gregbook/writepng.c index 7e1e436..6802b12 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/writepng.c +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/writepng.c @@ -1,368 +1,368 @@ -/*--------------------------------------------------------------------------- - - wpng - simple PNG-writing program writepng.c - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - - -#include /* for exit() prototype */ - -#include "png.h" /* libpng header; includes zlib.h and setjmp.h */ -#include "writepng.h" /* typedefs, common macros, public prototypes */ - - -/* local prototype */ - -static void writepng_error_handler(png_structp png_ptr, png_const_charp msg); - - - -void writepng_version_info(void) -{ - fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n", - PNG_LIBPNG_VER_STRING, png_libpng_ver); - fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", - ZLIB_VERSION, zlib_version); -} - - - - -/* returns 0 for success, 2 for libpng problem, 4 for out of memory, 11 for - * unexpected pnmtype; note that outfile might be stdout */ - -int writepng_init(mainprog_info *mainprog_ptr) -{ - png_structp png_ptr; /* note: temporary variables! */ - png_infop info_ptr; - int color_type, interlace_type; - - - /* could also replace libpng warning-handler (final NULL), but no need: */ - - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr, - writepng_error_handler, NULL); - if (!png_ptr) - return 4; /* out of memory */ - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { - png_destroy_write_struct(&png_ptr, NULL); - return 4; /* out of memory */ - } - - - /* setjmp() must be called in every function that calls a PNG-writing - * libpng function, unless an alternate error handler was installed-- - * but compatible error handlers must either use longjmp() themselves - * (as in this program) or exit immediately, so here we go: */ - - if (setjmp(mainprog_ptr->jmpbuf)) { - png_destroy_write_struct(&png_ptr, &info_ptr); - return 2; - } - - - /* make sure outfile is (re)opened in BINARY mode */ - - png_init_io(png_ptr, mainprog_ptr->outfile); - - - /* set the compression levels--in general, always want to leave filtering - * turned on (except for palette images) and allow all of the filters, - * which is the default; want 32K zlib window, unless entire image buffer - * is 16K or smaller (unknown here)--also the default; usually want max - * compression (NOT the default); and remaining compression flags should - * be left alone */ - - png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); -/* - >> this is default for no filtering; Z_FILTERED is default otherwise: - png_set_compression_strategy(png_ptr, Z_DEFAULT_STRATEGY); - >> these are all defaults: - png_set_compression_mem_level(png_ptr, 8); - png_set_compression_window_bits(png_ptr, 15); - png_set_compression_method(png_ptr, 8); - */ - - - /* set the image parameters appropriately */ - - if (mainprog_ptr->pnmtype == 5) - color_type = PNG_COLOR_TYPE_GRAY; - else if (mainprog_ptr->pnmtype == 6) - color_type = PNG_COLOR_TYPE_RGB; - else if (mainprog_ptr->pnmtype == 8) - color_type = PNG_COLOR_TYPE_RGB_ALPHA; - else { - png_destroy_write_struct(&png_ptr, &info_ptr); - return 11; - } - - interlace_type = mainprog_ptr->interlaced? PNG_INTERLACE_ADAM7 : - PNG_INTERLACE_NONE; - - png_set_IHDR(png_ptr, info_ptr, mainprog_ptr->width, mainprog_ptr->height, - mainprog_ptr->sample_depth, color_type, interlace_type, - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - - if (mainprog_ptr->gamma > 0.0) - png_set_gAMA(png_ptr, info_ptr, mainprog_ptr->gamma); - - if (mainprog_ptr->have_bg) { /* we know it's RGBA, not gray+alpha */ - png_color_16 background; - - background.red = mainprog_ptr->bg_red; - background.green = mainprog_ptr->bg_green; - background.blue = mainprog_ptr->bg_blue; - png_set_bKGD(png_ptr, info_ptr, &background); - } - - if (mainprog_ptr->have_time) { - png_time modtime; - - png_convert_from_time_t(&modtime, mainprog_ptr->modtime); - png_set_tIME(png_ptr, info_ptr, &modtime); - } - - if (mainprog_ptr->have_text) { - png_text text[6]; - int num_text = 0; - - if (mainprog_ptr->have_text & TEXT_TITLE) { - text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; - text[num_text].key = "Title"; - text[num_text].text = mainprog_ptr->title; - ++num_text; - } - if (mainprog_ptr->have_text & TEXT_AUTHOR) { - text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; - text[num_text].key = "Author"; - text[num_text].text = mainprog_ptr->author; - ++num_text; - } - if (mainprog_ptr->have_text & TEXT_DESC) { - text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; - text[num_text].key = "Description"; - text[num_text].text = mainprog_ptr->desc; - ++num_text; - } - if (mainprog_ptr->have_text & TEXT_COPY) { - text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; - text[num_text].key = "Copyright"; - text[num_text].text = mainprog_ptr->copyright; - ++num_text; - } - if (mainprog_ptr->have_text & TEXT_EMAIL) { - text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; - text[num_text].key = "E-mail"; - text[num_text].text = mainprog_ptr->email; - ++num_text; - } - if (mainprog_ptr->have_text & TEXT_URL) { - text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; - text[num_text].key = "URL"; - text[num_text].text = mainprog_ptr->url; - ++num_text; - } - png_set_text(png_ptr, info_ptr, text, num_text); - } - - - /* write all chunks up to (but not including) first IDAT */ - - png_write_info(png_ptr, info_ptr); - - - /* if we wanted to write any more text info *after* the image data, we - * would set up text struct(s) here and call png_set_text() again, with - * just the new data; png_set_tIME() could also go here, but it would - * have no effect since we already called it above (only one tIME chunk - * allowed) */ - - - /* set up the transformations: for now, just pack low-bit-depth pixels - * into bytes (one, two or four pixels per byte) */ - - png_set_packing(png_ptr); -/* png_set_shift(png_ptr, &sig_bit); to scale low-bit-depth values */ - - - /* make sure we save our pointers for use in writepng_encode_image() */ - - mainprog_ptr->png_ptr = png_ptr; - mainprog_ptr->info_ptr = info_ptr; - - - /* OK, that's all we need to do for now; return happy */ - - return 0; -} - - - - - -/* returns 0 for success, 2 for libpng (longjmp) problem */ - -int writepng_encode_image(mainprog_info *mainprog_ptr) -{ - png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; - png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; - - - /* as always, setjmp() must be called in every function that calls a - * PNG-writing libpng function */ - - if (setjmp(mainprog_ptr->jmpbuf)) { - png_destroy_write_struct(&png_ptr, &info_ptr); - mainprog_ptr->png_ptr = NULL; - mainprog_ptr->info_ptr = NULL; - return 2; - } - - - /* and now we just write the whole image; libpng takes care of interlacing - * for us */ - - png_write_image(png_ptr, mainprog_ptr->row_pointers); - - - /* since that's it, we also close out the end of the PNG file now--if we - * had any text or time info to write after the IDATs, second argument - * would be info_ptr, but we optimize slightly by sending NULL pointer: */ - - png_write_end(png_ptr, NULL); - - return 0; -} - - - - - -/* returns 0 if succeeds, 2 if libpng problem */ - -int writepng_encode_row(mainprog_info *mainprog_ptr) /* NON-interlaced only! */ -{ - png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; - png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; - - - /* as always, setjmp() must be called in every function that calls a - * PNG-writing libpng function */ - - if (setjmp(mainprog_ptr->jmpbuf)) { - png_destroy_write_struct(&png_ptr, &info_ptr); - mainprog_ptr->png_ptr = NULL; - mainprog_ptr->info_ptr = NULL; - return 2; - } - - - /* image_data points at our one row of image data */ - - png_write_row(png_ptr, mainprog_ptr->image_data); - - return 0; -} - - - - - -/* returns 0 if succeeds, 2 if libpng problem */ - -int writepng_encode_finish(mainprog_info *mainprog_ptr) /* NON-interlaced! */ -{ - png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; - png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; - - - /* as always, setjmp() must be called in every function that calls a - * PNG-writing libpng function */ - - if (setjmp(mainprog_ptr->jmpbuf)) { - png_destroy_write_struct(&png_ptr, &info_ptr); - mainprog_ptr->png_ptr = NULL; - mainprog_ptr->info_ptr = NULL; - return 2; - } - - - /* close out PNG file; if we had any text or time info to write after - * the IDATs, second argument would be info_ptr: */ - - png_write_end(png_ptr, NULL); - - return 0; -} - - - - - -void writepng_cleanup(mainprog_info *mainprog_ptr) -{ - png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; - png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; - - if (png_ptr && info_ptr) - png_destroy_write_struct(&png_ptr, &info_ptr); -} - - - - - -static void writepng_error_handler(png_structp png_ptr, png_const_charp msg) -{ - mainprog_info *mainprog_ptr; - - /* This function, aside from the extra step of retrieving the "error - * pointer" (below) and the fact that it exists within the application - * rather than within libpng, is essentially identical to libpng's - * default error handler. The second point is critical: since both - * setjmp() and longjmp() are called from the same code, they are - * guaranteed to have compatible notions of how big a jmp_buf is, - * regardless of whether _BSD_SOURCE or anything else has (or has not) - * been defined. */ - - fprintf(stderr, "writepng libpng error: %s\n", msg); - fflush(stderr); - - mainprog_ptr = png_get_error_ptr(png_ptr); - if (mainprog_ptr == NULL) { /* we are completely hosed now */ - fprintf(stderr, - "writepng severe error: jmpbuf not recoverable; terminating.\n"); - fflush(stderr); - exit(99); - } - - longjmp(mainprog_ptr->jmpbuf, 1); -} +/*--------------------------------------------------------------------------- + + wpng - simple PNG-writing program writepng.c + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + ---------------------------------------------------------------------------*/ + + +#include /* for exit() prototype */ + +#include "png.h" /* libpng header; includes zlib.h and setjmp.h */ +#include "writepng.h" /* typedefs, common macros, public prototypes */ + + +/* local prototype */ + +static void writepng_error_handler(png_structp png_ptr, png_const_charp msg); + + + +void writepng_version_info(void) +{ + fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n", + PNG_LIBPNG_VER_STRING, png_libpng_ver); + fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", + ZLIB_VERSION, zlib_version); +} + + + + +/* returns 0 for success, 2 for libpng problem, 4 for out of memory, 11 for + * unexpected pnmtype; note that outfile might be stdout */ + +int writepng_init(mainprog_info *mainprog_ptr) +{ + png_structp png_ptr; /* note: temporary variables! */ + png_infop info_ptr; + int color_type, interlace_type; + + + /* could also replace libpng warning-handler (final NULL), but no need: */ + + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr, + writepng_error_handler, NULL); + if (!png_ptr) + return 4; /* out of memory */ + + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + png_destroy_write_struct(&png_ptr, NULL); + return 4; /* out of memory */ + } + + + /* setjmp() must be called in every function that calls a PNG-writing + * libpng function, unless an alternate error handler was installed-- + * but compatible error handlers must either use longjmp() themselves + * (as in this program) or exit immediately, so here we go: */ + + if (setjmp(mainprog_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr, &info_ptr); + return 2; + } + + + /* make sure outfile is (re)opened in BINARY mode */ + + png_init_io(png_ptr, mainprog_ptr->outfile); + + + /* set the compression levels--in general, always want to leave filtering + * turned on (except for palette images) and allow all of the filters, + * which is the default; want 32K zlib window, unless entire image buffer + * is 16K or smaller (unknown here)--also the default; usually want max + * compression (NOT the default); and remaining compression flags should + * be left alone */ + + png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); +/* + >> this is default for no filtering; Z_FILTERED is default otherwise: + png_set_compression_strategy(png_ptr, Z_DEFAULT_STRATEGY); + >> these are all defaults: + png_set_compression_mem_level(png_ptr, 8); + png_set_compression_window_bits(png_ptr, 15); + png_set_compression_method(png_ptr, 8); + */ + + + /* set the image parameters appropriately */ + + if (mainprog_ptr->pnmtype == 5) + color_type = PNG_COLOR_TYPE_GRAY; + else if (mainprog_ptr->pnmtype == 6) + color_type = PNG_COLOR_TYPE_RGB; + else if (mainprog_ptr->pnmtype == 8) + color_type = PNG_COLOR_TYPE_RGB_ALPHA; + else { + png_destroy_write_struct(&png_ptr, &info_ptr); + return 11; + } + + interlace_type = mainprog_ptr->interlaced? PNG_INTERLACE_ADAM7 : + PNG_INTERLACE_NONE; + + png_set_IHDR(png_ptr, info_ptr, mainprog_ptr->width, mainprog_ptr->height, + mainprog_ptr->sample_depth, color_type, interlace_type, + PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + + if (mainprog_ptr->gamma > 0.0) + png_set_gAMA(png_ptr, info_ptr, mainprog_ptr->gamma); + + if (mainprog_ptr->have_bg) { /* we know it's RGBA, not gray+alpha */ + png_color_16 background; + + background.red = mainprog_ptr->bg_red; + background.green = mainprog_ptr->bg_green; + background.blue = mainprog_ptr->bg_blue; + png_set_bKGD(png_ptr, info_ptr, &background); + } + + if (mainprog_ptr->have_time) { + png_time modtime; + + png_convert_from_time_t(&modtime, mainprog_ptr->modtime); + png_set_tIME(png_ptr, info_ptr, &modtime); + } + + if (mainprog_ptr->have_text) { + png_text text[6]; + int num_text = 0; + + if (mainprog_ptr->have_text & TEXT_TITLE) { + text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; + text[num_text].key = "Title"; + text[num_text].text = mainprog_ptr->title; + ++num_text; + } + if (mainprog_ptr->have_text & TEXT_AUTHOR) { + text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; + text[num_text].key = "Author"; + text[num_text].text = mainprog_ptr->author; + ++num_text; + } + if (mainprog_ptr->have_text & TEXT_DESC) { + text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; + text[num_text].key = "Description"; + text[num_text].text = mainprog_ptr->desc; + ++num_text; + } + if (mainprog_ptr->have_text & TEXT_COPY) { + text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; + text[num_text].key = "Copyright"; + text[num_text].text = mainprog_ptr->copyright; + ++num_text; + } + if (mainprog_ptr->have_text & TEXT_EMAIL) { + text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; + text[num_text].key = "E-mail"; + text[num_text].text = mainprog_ptr->email; + ++num_text; + } + if (mainprog_ptr->have_text & TEXT_URL) { + text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; + text[num_text].key = "URL"; + text[num_text].text = mainprog_ptr->url; + ++num_text; + } + png_set_text(png_ptr, info_ptr, text, num_text); + } + + + /* write all chunks up to (but not including) first IDAT */ + + png_write_info(png_ptr, info_ptr); + + + /* if we wanted to write any more text info *after* the image data, we + * would set up text struct(s) here and call png_set_text() again, with + * just the new data; png_set_tIME() could also go here, but it would + * have no effect since we already called it above (only one tIME chunk + * allowed) */ + + + /* set up the transformations: for now, just pack low-bit-depth pixels + * into bytes (one, two or four pixels per byte) */ + + png_set_packing(png_ptr); +/* png_set_shift(png_ptr, &sig_bit); to scale low-bit-depth values */ + + + /* make sure we save our pointers for use in writepng_encode_image() */ + + mainprog_ptr->png_ptr = png_ptr; + mainprog_ptr->info_ptr = info_ptr; + + + /* OK, that's all we need to do for now; return happy */ + + return 0; +} + + + + + +/* returns 0 for success, 2 for libpng (longjmp) problem */ + +int writepng_encode_image(mainprog_info *mainprog_ptr) +{ + png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; + png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; + + + /* as always, setjmp() must be called in every function that calls a + * PNG-writing libpng function */ + + if (setjmp(mainprog_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr, &info_ptr); + mainprog_ptr->png_ptr = NULL; + mainprog_ptr->info_ptr = NULL; + return 2; + } + + + /* and now we just write the whole image; libpng takes care of interlacing + * for us */ + + png_write_image(png_ptr, mainprog_ptr->row_pointers); + + + /* since that's it, we also close out the end of the PNG file now--if we + * had any text or time info to write after the IDATs, second argument + * would be info_ptr, but we optimize slightly by sending NULL pointer: */ + + png_write_end(png_ptr, NULL); + + return 0; +} + + + + + +/* returns 0 if succeeds, 2 if libpng problem */ + +int writepng_encode_row(mainprog_info *mainprog_ptr) /* NON-interlaced only! */ +{ + png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; + png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; + + + /* as always, setjmp() must be called in every function that calls a + * PNG-writing libpng function */ + + if (setjmp(mainprog_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr, &info_ptr); + mainprog_ptr->png_ptr = NULL; + mainprog_ptr->info_ptr = NULL; + return 2; + } + + + /* image_data points at our one row of image data */ + + png_write_row(png_ptr, mainprog_ptr->image_data); + + return 0; +} + + + + + +/* returns 0 if succeeds, 2 if libpng problem */ + +int writepng_encode_finish(mainprog_info *mainprog_ptr) /* NON-interlaced! */ +{ + png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; + png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; + + + /* as always, setjmp() must be called in every function that calls a + * PNG-writing libpng function */ + + if (setjmp(mainprog_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr, &info_ptr); + mainprog_ptr->png_ptr = NULL; + mainprog_ptr->info_ptr = NULL; + return 2; + } + + + /* close out PNG file; if we had any text or time info to write after + * the IDATs, second argument would be info_ptr: */ + + png_write_end(png_ptr, NULL); + + return 0; +} + + + + + +void writepng_cleanup(mainprog_info *mainprog_ptr) +{ + png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; + png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; + + if (png_ptr && info_ptr) + png_destroy_write_struct(&png_ptr, &info_ptr); +} + + + + + +static void writepng_error_handler(png_structp png_ptr, png_const_charp msg) +{ + mainprog_info *mainprog_ptr; + + /* This function, aside from the extra step of retrieving the "error + * pointer" (below) and the fact that it exists within the application + * rather than within libpng, is essentially identical to libpng's + * default error handler. The second point is critical: since both + * setjmp() and longjmp() are called from the same code, they are + * guaranteed to have compatible notions of how big a jmp_buf is, + * regardless of whether _BSD_SOURCE or anything else has (or has not) + * been defined. */ + + fprintf(stderr, "writepng libpng error: %s\n", msg); + fflush(stderr); + + mainprog_ptr = png_get_error_ptr(png_ptr); + if (mainprog_ptr == NULL) { /* we are completely hosed now */ + fprintf(stderr, + "writepng severe error: jmpbuf not recoverable; terminating.\n"); + fflush(stderr); + exit(99); + } + + longjmp(mainprog_ptr->jmpbuf, 1); +} diff --git a/src/dep/src/irrlicht/libpng/contrib/gregbook/writepng.h b/src/dep/src/irrlicht/libpng/contrib/gregbook/writepng.h index 26d7117..93c3da8 100644 --- a/src/dep/src/irrlicht/libpng/contrib/gregbook/writepng.h +++ b/src/dep/src/irrlicht/libpng/contrib/gregbook/writepng.h @@ -1,109 +1,109 @@ -/*--------------------------------------------------------------------------- - - wpng - simple PNG-writing program writepng.h - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#ifndef TRUE -# define TRUE 1 -# define FALSE 0 -#endif - -#ifndef MAX -# define MAX(a,b) ((a) > (b)? (a) : (b)) -# define MIN(a,b) ((a) < (b)? (a) : (b)) -#endif - -#ifdef DEBUG -# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} -#else -# define Trace(x) ; -#endif - -#define TEXT_TITLE 0x01 -#define TEXT_AUTHOR 0x02 -#define TEXT_DESC 0x04 -#define TEXT_COPY 0x08 -#define TEXT_EMAIL 0x10 -#define TEXT_URL 0x20 - -#define TEXT_TITLE_OFFSET 0 -#define TEXT_AUTHOR_OFFSET 72 -#define TEXT_COPY_OFFSET (2*72) -#define TEXT_EMAIL_OFFSET (3*72) -#define TEXT_URL_OFFSET (4*72) -#define TEXT_DESC_OFFSET (5*72) - -typedef unsigned char uch; -typedef unsigned short ush; -typedef unsigned long ulg; - -typedef struct _mainprog_info { - double gamma; - long width; - long height; - time_t modtime; - FILE *infile; - FILE *outfile; - void *png_ptr; - void *info_ptr; - uch *image_data; - uch **row_pointers; - char *title; - char *author; - char *desc; - char *copyright; - char *email; - char *url; - int filter; /* command-line-filter flag, not PNG row filter! */ - int pnmtype; - int sample_depth; - int interlaced; - int have_bg; - int have_time; - int have_text; - jmp_buf jmpbuf; - uch bg_red; - uch bg_green; - uch bg_blue; -} mainprog_info; - - -/* prototypes for public functions in writepng.c */ - -void writepng_version_info(void); - -int writepng_init(mainprog_info *mainprog_ptr); - -int writepng_encode_image(mainprog_info *mainprog_ptr); - -int writepng_encode_row(mainprog_info *mainprog_ptr); - -int writepng_encode_finish(mainprog_info *mainprog_ptr); - -void writepng_cleanup(mainprog_info *mainprog_ptr); +/*--------------------------------------------------------------------------- + + wpng - simple PNG-writing program writepng.h + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + ---------------------------------------------------------------------------*/ + +#ifndef TRUE +# define TRUE 1 +# define FALSE 0 +#endif + +#ifndef MAX +# define MAX(a,b) ((a) > (b)? (a) : (b)) +# define MIN(a,b) ((a) < (b)? (a) : (b)) +#endif + +#ifdef DEBUG +# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} +#else +# define Trace(x) ; +#endif + +#define TEXT_TITLE 0x01 +#define TEXT_AUTHOR 0x02 +#define TEXT_DESC 0x04 +#define TEXT_COPY 0x08 +#define TEXT_EMAIL 0x10 +#define TEXT_URL 0x20 + +#define TEXT_TITLE_OFFSET 0 +#define TEXT_AUTHOR_OFFSET 72 +#define TEXT_COPY_OFFSET (2*72) +#define TEXT_EMAIL_OFFSET (3*72) +#define TEXT_URL_OFFSET (4*72) +#define TEXT_DESC_OFFSET (5*72) + +typedef unsigned char uch; +typedef unsigned short ush; +typedef unsigned long ulg; + +typedef struct _mainprog_info { + double gamma; + long width; + long height; + time_t modtime; + FILE *infile; + FILE *outfile; + void *png_ptr; + void *info_ptr; + uch *image_data; + uch **row_pointers; + char *title; + char *author; + char *desc; + char *copyright; + char *email; + char *url; + int filter; /* command-line-filter flag, not PNG row filter! */ + int pnmtype; + int sample_depth; + int interlaced; + int have_bg; + int have_time; + int have_text; + jmp_buf jmpbuf; + uch bg_red; + uch bg_green; + uch bg_blue; +} mainprog_info; + + +/* prototypes for public functions in writepng.c */ + +void writepng_version_info(void); + +int writepng_init(mainprog_info *mainprog_ptr); + +int writepng_encode_image(mainprog_info *mainprog_ptr); + +int writepng_encode_row(mainprog_info *mainprog_ptr); + +int writepng_encode_finish(mainprog_info *mainprog_ptr); + +void writepng_cleanup(mainprog_info *mainprog_ptr); diff --git a/src/dep/src/irrlicht/libpng/contrib/pngminus/README b/src/dep/src/irrlicht/libpng/contrib/pngminus/README index b0516ec..bbe7407 100644 --- a/src/dep/src/irrlicht/libpng/contrib/pngminus/README +++ b/src/dep/src/irrlicht/libpng/contrib/pngminus/README @@ -1,153 +1,153 @@ -PngMinus --------- -(copyright Willem van Schaik, 1999) - - -License -------- - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and -that both that copyright notice and this permission notice appear in -supporting documentation. This software is provided "as is" without -express or implied warranty. - - -Some history ------------- -Soon after the creation of PNG in 1995, the need was felt for a set of -pnmtopng / pngtopnm utilities. Independantly Alexander Lehmann and I -(Willem van Schaik) started such a project. Luckily we discovered this -and merged the two together into pnmtopng.tar.gz, which is available -from a/o ftp://ftp.simplesystems.org/pub/libpng/png/. - -These two utilities have many, many options and make use of most of the -features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes -the utilities quite complex and by now not anymore very maintainable. -When we wrote these programs, libpng was still in an early stage. -Therefore, lots of the functionality that we put in our software can now -be done using transform-functions in libpng. - -Finally, to compile these programs, you need to have installed and -compiled three libraries: libpng, zlib and netpbm. Especially the latter -makes the whole setup a bit bulky. But that's unavoidable given the many -features of pnmtopng. - - -What now --------- -At this moment libpng is in a very stable state and can do much of the -work done in pnmtopng. Also, pnmtopng needs to be upgraded to the new -interface of libpng. Hence, it is time for a rewrite from the ground up -of pnmtopng and pngtopnm. This will happen in the near future (stay -tuned). The new package will get a different name to distinguish it from -the old one: PngPlus. - -To experiment a bit with the new interface of libpng, I started off with -a small prototype that contains only the basic functionality. It doesn't -have any of the options to read or write special chunks and it will do -no gamma correction. But this makes it also a simple program that is -quite easy to understand and can serve well as a template for other -software developments. (By now there are of course a couple of programs, -like Greg Roelofs' rpng/wpng, that can be used just as good.) - - -Can and can not ---------------- -As this is the small brother of the future PngPlus, I called this fellow -PngMinus. Because I started this development in good-old Turbo-C, I -avoided the use the netpbm library, which requires DOS extenders. Again, -another reason to call it PngMinus (minus netpbm :-). So, part of the -program are some elementary routines to read / write pgm- and ppm-files. -It does not read b&w pbm-files. - -The downside of this approach is that you can not use them on images -that require blocks of memory bigger than 64k (the DOS version). For -larger images you will get an out-of-memory error. - -As said before, PngMinus doesn't correct for gamma. When reading -png-files you can do this just as well by piping the output of png2pnm -to pnmgamma, one of the standard PbmPlus tools. This same scenario will -most probably also be followed in the full-blown future PngPlus, with -the addition of course of the possibility to create gamma-chunks when -writing png-files. - -On the other hand it supports alpha-channels. When reading a png-image -you can write the alpha-channel into a pgm-file. And when creating an -RGB+A png-image, you just combine a ppm-file with a corresponding -pgm-file containing the alpha-channel. When reading, transparency chunks -are converted into an alpha-channel and from there on treated the same -way. - -Finally you can opt for writing ascii or binary pgm- and ppm-files. When -the bit-depth is 16, the format will always be ascii. - - -Using it --------- -To distinguish them from pnmtopng and PngPlus, the utilities are named -png2pnm and pnm2png (2 instead of to). The input- and output-files can -be given as parameters or through redirection. Therefore the programs -can be part of a pipe. - -To list the options type "png2pnm -h" or "pnm2png -h". - - -Just like Scandinavian furniture --------------------------------- -You have to put it together yourself. I did test the software under -MS-DOS with Turbo-C 3.0 and under RedHat Linux 4.2 with gcc. In both -cases I used libpng-1.0.4 and zlib-1.1.3. Later versions should be OK, -however some older libpng versions have a bug in pngmem.c when using -Turbo-C 3.0 (see below). - -You can build it using one of the two makefiles (make -f makefile.###) -or use the batch/script files pngminus.bat / pngminus.sh. This assumes -that you have built the libraries in ../libpng and ../zlib. Using Linux, -make sure that you have built libpng with makefile.std and not -makefile.linux (also called .lnx in earlier versions of libpng). The -latter creates a .so shared-library, while the PngMinus makefile assumes -a normal .a static library. - -If you create a ../pngsuite directory and then store the basn####.png -files from PngSuite (http://www.schaik.com/pngsuite/) in there, you can -test in one go the proper functioning of PngMinus, see png2pnm.bat and -pnm2png.bat (or the .sh versions). - - -Warranty -------- -Please, remember that this was just a small experiment to learn a few -things. It will have many unforeseen features . Who said bugs? Use -it when you are in need for something simple or when you want to start -developing your own stuff. - - -The Turbo bug -------------- -** pngmem.old - hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); - hptr += 16L; -** pngmem.c - hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); - hptr = hptr + 16L; -** - -** pngmem.old - png_ptr->offset_table_ptr[i] = (png_bytep)hptr; - hptr += (png_uint_32)65536L; -** pngmem.c - png_ptr->offset_table_ptr[i] = (png_bytep)hptr; - hptr = hptr + 65536L; -** - - -The end -------- -Willem van Schaik -mailto:willem@schaik.com -http://www.schaik.com/png/ -------- -Oct 1999 - +PngMinus +-------- +(copyright Willem van Schaik, 1999) + + +License +------- + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and +that both that copyright notice and this permission notice appear in +supporting documentation. This software is provided "as is" without +express or implied warranty. + + +Some history +------------ +Soon after the creation of PNG in 1995, the need was felt for a set of +pnmtopng / pngtopnm utilities. Independantly Alexander Lehmann and I +(Willem van Schaik) started such a project. Luckily we discovered this +and merged the two together into pnmtopng.tar.gz, which is available +from a/o ftp://ftp.simplesystems.org/pub/libpng/png/. + +These two utilities have many, many options and make use of most of the +features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes +the utilities quite complex and by now not anymore very maintainable. +When we wrote these programs, libpng was still in an early stage. +Therefore, lots of the functionality that we put in our software can now +be done using transform-functions in libpng. + +Finally, to compile these programs, you need to have installed and +compiled three libraries: libpng, zlib and netpbm. Especially the latter +makes the whole setup a bit bulky. But that's unavoidable given the many +features of pnmtopng. + + +What now +-------- +At this moment libpng is in a very stable state and can do much of the +work done in pnmtopng. Also, pnmtopng needs to be upgraded to the new +interface of libpng. Hence, it is time for a rewrite from the ground up +of pnmtopng and pngtopnm. This will happen in the near future (stay +tuned). The new package will get a different name to distinguish it from +the old one: PngPlus. + +To experiment a bit with the new interface of libpng, I started off with +a small prototype that contains only the basic functionality. It doesn't +have any of the options to read or write special chunks and it will do +no gamma correction. But this makes it also a simple program that is +quite easy to understand and can serve well as a template for other +software developments. (By now there are of course a couple of programs, +like Greg Roelofs' rpng/wpng, that can be used just as good.) + + +Can and can not +--------------- +As this is the small brother of the future PngPlus, I called this fellow +PngMinus. Because I started this development in good-old Turbo-C, I +avoided the use the netpbm library, which requires DOS extenders. Again, +another reason to call it PngMinus (minus netpbm :-). So, part of the +program are some elementary routines to read / write pgm- and ppm-files. +It does not read b&w pbm-files. + +The downside of this approach is that you can not use them on images +that require blocks of memory bigger than 64k (the DOS version). For +larger images you will get an out-of-memory error. + +As said before, PngMinus doesn't correct for gamma. When reading +png-files you can do this just as well by piping the output of png2pnm +to pnmgamma, one of the standard PbmPlus tools. This same scenario will +most probably also be followed in the full-blown future PngPlus, with +the addition of course of the possibility to create gamma-chunks when +writing png-files. + +On the other hand it supports alpha-channels. When reading a png-image +you can write the alpha-channel into a pgm-file. And when creating an +RGB+A png-image, you just combine a ppm-file with a corresponding +pgm-file containing the alpha-channel. When reading, transparency chunks +are converted into an alpha-channel and from there on treated the same +way. + +Finally you can opt for writing ascii or binary pgm- and ppm-files. When +the bit-depth is 16, the format will always be ascii. + + +Using it +-------- +To distinguish them from pnmtopng and PngPlus, the utilities are named +png2pnm and pnm2png (2 instead of to). The input- and output-files can +be given as parameters or through redirection. Therefore the programs +can be part of a pipe. + +To list the options type "png2pnm -h" or "pnm2png -h". + + +Just like Scandinavian furniture +-------------------------------- +You have to put it together yourself. I did test the software under +MS-DOS with Turbo-C 3.0 and under RedHat Linux 4.2 with gcc. In both +cases I used libpng-1.0.4 and zlib-1.1.3. Later versions should be OK, +however some older libpng versions have a bug in pngmem.c when using +Turbo-C 3.0 (see below). + +You can build it using one of the two makefiles (make -f makefile.###) +or use the batch/script files pngminus.bat / pngminus.sh. This assumes +that you have built the libraries in ../libpng and ../zlib. Using Linux, +make sure that you have built libpng with makefile.std and not +makefile.linux (also called .lnx in earlier versions of libpng). The +latter creates a .so shared-library, while the PngMinus makefile assumes +a normal .a static library. + +If you create a ../pngsuite directory and then store the basn####.png +files from PngSuite (http://www.schaik.com/pngsuite/) in there, you can +test in one go the proper functioning of PngMinus, see png2pnm.bat and +pnm2png.bat (or the .sh versions). + + +Warranty +------- +Please, remember that this was just a small experiment to learn a few +things. It will have many unforeseen features . Who said bugs? Use +it when you are in need for something simple or when you want to start +developing your own stuff. + + +The Turbo bug +------------- +** pngmem.old + hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); + hptr += 16L; +** pngmem.c + hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); + hptr = hptr + 16L; +** + +** pngmem.old + png_ptr->offset_table_ptr[i] = (png_bytep)hptr; + hptr += (png_uint_32)65536L; +** pngmem.c + png_ptr->offset_table_ptr[i] = (png_bytep)hptr; + hptr = hptr + 65536L; +** + + +The end +------- +Willem van Schaik +mailto:willem@schaik.com +http://www.schaik.com/png/ +------- +Oct 1999 + diff --git a/src/dep/src/irrlicht/libpng/contrib/pngminus/makefile.std b/src/dep/src/irrlicht/libpng/contrib/pngminus/makefile.std index afe15c7..2fb061b 100644 --- a/src/dep/src/irrlicht/libpng/contrib/pngminus/makefile.std +++ b/src/dep/src/irrlicht/libpng/contrib/pngminus/makefile.std @@ -1,65 +1,65 @@ -# Makefile for PngMinus (png2pnm and pnm2png) -# Linux / Unix - -#CC=cc -CC=gcc -LD=$(CC) - -RM=rm -f - -#PNGPATH = /usr/local -#PNGINC = -I$(PNGPATH)/include/libpng12 -#PNGLIB = -L$(PNGPATH)/lib -lpng12 -#PNGLIBS = $(PNGPATH)/lib/libpng12.a -PNGINC = -I../.. -PNGLIB = -L../.. -lpng -PNGLIBS = ../../libpng.a - -#ZPATH = /usr/local -#ZINC = -I$(ZPATH)/include -#ZLIB = -L$(ZPATH)/lib -lz -#ZLIBS = $(ZPATH)/lib/libz.a -ZINC = -I../../../zlib -ZLIB = -L../../../zlib -lz -ZLIBS = ../../../zlib/libz.a - -CFLAGS=-O3 $(PNGINC) $(ZINC) -LDFLAGS=$(PNGLIB) $(ZLIB) -LDFLAGSS=$(PNGLIBS) $(ZLIBS) -C=.c -O=.o -L=.a -E= - -# dependencies - -#all: png2pnm$(E) pnm2png$(E) -all: png2pnm$(E) pnm2png$(E) png2pnm-static$(E) pnm2png-static$(E) - -png2pnm$(O): png2pnm$(C) - $(CC) -c $(CFLAGS) png2pnm$(C) - -png2pnm$(E): png2pnm$(O) - $(LD) -o png2pnm$(E) png2pnm$(O) $(LDFLAGS) -lm - -png2pnm-static$(E): png2pnm$(O) - $(LD) -o png2pnm-static$(E) png2pnm$(O) $(LDFLAGSS) -lm - -pnm2png$(O): pnm2png$(C) - $(CC) -c $(CFLAGS) pnm2png$(C) - -pnm2png$(E): pnm2png$(O) - $(LD) -o pnm2png$(E) pnm2png$(O) $(LDFLAGS) -lm - -pnm2png-static$(E): pnm2png$(O) - $(LD) -o pnm2png-static$(E) pnm2png$(O) $(LDFLAGSS) -lm - -clean: - $(RM) png2pnm$(O) - $(RM) pnm2png$(O) - $(RM) png2pnm$(E) - $(RM) pnm2png$(E) - $(RM) png2pnm-static$(E) - $(RM) pnm2png-static$(E) - -# End of makefile for png2pnm / pnm2png +# Makefile for PngMinus (png2pnm and pnm2png) +# Linux / Unix + +#CC=cc +CC=gcc +LD=$(CC) + +RM=rm -f + +#PNGPATH = /usr/local +#PNGINC = -I$(PNGPATH)/include/libpng12 +#PNGLIB = -L$(PNGPATH)/lib -lpng12 +#PNGLIBS = $(PNGPATH)/lib/libpng12.a +PNGINC = -I../.. +PNGLIB = -L../.. -lpng +PNGLIBS = ../../libpng.a + +#ZPATH = /usr/local +#ZINC = -I$(ZPATH)/include +#ZLIB = -L$(ZPATH)/lib -lz +#ZLIBS = $(ZPATH)/lib/libz.a +ZINC = -I../../../zlib +ZLIB = -L../../../zlib -lz +ZLIBS = ../../../zlib/libz.a + +CFLAGS=-O3 $(PNGINC) $(ZINC) +LDFLAGS=$(PNGLIB) $(ZLIB) +LDFLAGSS=$(PNGLIBS) $(ZLIBS) +C=.c +O=.o +L=.a +E= + +# dependencies + +#all: png2pnm$(E) pnm2png$(E) +all: png2pnm$(E) pnm2png$(E) png2pnm-static$(E) pnm2png-static$(E) + +png2pnm$(O): png2pnm$(C) + $(CC) -c $(CFLAGS) png2pnm$(C) + +png2pnm$(E): png2pnm$(O) + $(LD) -o png2pnm$(E) png2pnm$(O) $(LDFLAGS) -lm + +png2pnm-static$(E): png2pnm$(O) + $(LD) -o png2pnm-static$(E) png2pnm$(O) $(LDFLAGSS) -lm + +pnm2png$(O): pnm2png$(C) + $(CC) -c $(CFLAGS) pnm2png$(C) + +pnm2png$(E): pnm2png$(O) + $(LD) -o pnm2png$(E) pnm2png$(O) $(LDFLAGS) -lm + +pnm2png-static$(E): pnm2png$(O) + $(LD) -o pnm2png-static$(E) pnm2png$(O) $(LDFLAGSS) -lm + +clean: + $(RM) png2pnm$(O) + $(RM) pnm2png$(O) + $(RM) png2pnm$(E) + $(RM) pnm2png$(E) + $(RM) png2pnm-static$(E) + $(RM) pnm2png-static$(E) + +# End of makefile for png2pnm / pnm2png diff --git a/src/dep/src/irrlicht/libpng/contrib/pngminus/makefile.tc3 b/src/dep/src/irrlicht/libpng/contrib/pngminus/makefile.tc3 index 01062cc..404f18d 100644 --- a/src/dep/src/irrlicht/libpng/contrib/pngminus/makefile.tc3 +++ b/src/dep/src/irrlicht/libpng/contrib/pngminus/makefile.tc3 @@ -1,38 +1,38 @@ -# Makefile for PngMinus (png2pnm and pnm2png) -# TurboC++ 3.0 - -CC=tcc -Ic:\tc3\inc -LD=tcc -Lc:\tc3\lib -LB=tlib -RM=del -CP=copy -MODEL=l -CCFLAGS=-O -m$(MODEL) -I..\libpng -I..\zlib -LDFLAGS=-m$(MODEL) -L..\libpng -L..\zlib -C=.c -O=.obj -L=.lib -E=.exe - -# dependencies - -all: png2pnm$(E) pnm2png$(E) - -png2pnm$(O): png2pnm$(C) - $(CC) -c $(CCFLAGS) png2pnm$(C) - -png2pnm$(E): png2pnm$(O) - $(LD) $(LDFLAGS) png2pnm$(O) libpng$(L) zlib$(L) - -pnm2png$(O): pnm2png$(C) - $(CC) -c $(CCFLAGS) pnm2png$(C) - -pnm2png$(E): pnm2png$(O) - $(LD) $(LDFLAGS) pnm2png$(O) libpng$(L) zlib$(L) - -clean: - $(RM) *$(O) - $(RM) *$(E) - -# End of makefile for png2pnm / pnm2png - +# Makefile for PngMinus (png2pnm and pnm2png) +# TurboC++ 3.0 + +CC=tcc -Ic:\tc3\inc +LD=tcc -Lc:\tc3\lib +LB=tlib +RM=del +CP=copy +MODEL=l +CCFLAGS=-O -m$(MODEL) -I..\libpng -I..\zlib +LDFLAGS=-m$(MODEL) -L..\libpng -L..\zlib +C=.c +O=.obj +L=.lib +E=.exe + +# dependencies + +all: png2pnm$(E) pnm2png$(E) + +png2pnm$(O): png2pnm$(C) + $(CC) -c $(CCFLAGS) png2pnm$(C) + +png2pnm$(E): png2pnm$(O) + $(LD) $(LDFLAGS) png2pnm$(O) libpng$(L) zlib$(L) + +pnm2png$(O): pnm2png$(C) + $(CC) -c $(CCFLAGS) pnm2png$(C) + +pnm2png$(E): pnm2png$(O) + $(LD) $(LDFLAGS) pnm2png$(O) libpng$(L) zlib$(L) + +clean: + $(RM) *$(O) + $(RM) *$(E) + +# End of makefile for png2pnm / pnm2png + diff --git a/src/dep/src/irrlicht/libpng/contrib/pngminus/makevms.com b/src/dep/src/irrlicht/libpng/contrib/pngminus/makevms.com index 96c3147..00561bc 100644 --- a/src/dep/src/irrlicht/libpng/contrib/pngminus/makevms.com +++ b/src/dep/src/irrlicht/libpng/contrib/pngminus/makevms.com @@ -1,92 +1,92 @@ -$!------------------------------------------------------------------------------ -$! make Contrib programs of libpng under OpenVMS -$! -$! -$! Look for the compiler used -$! -$ zlibsrc = "[---.zlib]" -$ ccopt="/include=(''zlibsrc',[--])" -$ if f$getsyi("HW_MODEL").ge.1024 -$ then -$ ccopt = "/prefix=all"+ccopt -$ comp = "__decc__=1" -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ else -$ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" -$ then -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ if f$search("SYS$SYSTEM:VAXC.EXE").eqs."" -$ then -$ comp = "__gcc__=1" -$ CC :== GCC -$ else -$ comp = "__vaxc__=1" -$ endif -$ else -$ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: -$ ccopt = "/decc/prefix=all"+ccopt -$ comp = "__decc__=1" -$ endif -$ endif -$ open/write lopt lib.opt -$ write lopt "[--]libpng.olb/lib" -$ write lopt "''zlibsrc'libz.olb/lib" -$ close lopt -$ open/write xopt x11.opt -$ write xopt "sys$library:decw$xlibshr.exe/share" -$ close xopt -$ write sys$output "Compiling PNG contrib programs ..." -$ write sys$output "Building pnm2png..." -$ CALL MAKE pnm2png.OBJ "cc ''CCOPT' pnm2png" - - pnm2png.c -$ call make pnm2png.exe - - "LINK pnm2png,lib.opt/opt" - - pnm2png.obj -$ write sys$output "Building png2pnm..." -$ CALL MAKE png2pnm.OBJ "cc ''CCOPT' png2pnm" - - png2pnm.c -$ call make png2pnm.exe - - "LINK png2pnm,lib.opt/opt" - - png2pnm.obj -$ exit -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 - P8 What it depends on -$ -$ If F$Search(P1) .Eqs. "" Then Goto Makeit -$ Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(0) -$ write sys$output P2 -$ 'P2 -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE +$!------------------------------------------------------------------------------ +$! make Contrib programs of libpng under OpenVMS +$! +$! +$! Look for the compiler used +$! +$ zlibsrc = "[---.zlib]" +$ ccopt="/include=(''zlibsrc',[--])" +$ if f$getsyi("HW_MODEL").ge.1024 +$ then +$ ccopt = "/prefix=all"+ccopt +$ comp = "__decc__=1" +$ if f$trnlnm("SYS").eqs."" then define sys sys$library: +$ else +$ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" +$ then +$ if f$trnlnm("SYS").eqs."" then define sys sys$library: +$ if f$search("SYS$SYSTEM:VAXC.EXE").eqs."" +$ then +$ comp = "__gcc__=1" +$ CC :== GCC +$ else +$ comp = "__vaxc__=1" +$ endif +$ else +$ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: +$ ccopt = "/decc/prefix=all"+ccopt +$ comp = "__decc__=1" +$ endif +$ endif +$ open/write lopt lib.opt +$ write lopt "[--]libpng.olb/lib" +$ write lopt "''zlibsrc'libz.olb/lib" +$ close lopt +$ open/write xopt x11.opt +$ write xopt "sys$library:decw$xlibshr.exe/share" +$ close xopt +$ write sys$output "Compiling PNG contrib programs ..." +$ write sys$output "Building pnm2png..." +$ CALL MAKE pnm2png.OBJ "cc ''CCOPT' pnm2png" - + pnm2png.c +$ call make pnm2png.exe - + "LINK pnm2png,lib.opt/opt" - + pnm2png.obj +$ write sys$output "Building png2pnm..." +$ CALL MAKE png2pnm.OBJ "cc ''CCOPT' png2pnm" - + png2pnm.c +$ call make png2pnm.exe - + "LINK png2pnm,lib.opt/opt" - + png2pnm.obj +$ exit +$! +$! +$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES +$ V = 'F$Verify(0) +$! P1 = What we are trying to make +$! P2 = Command to make it +$! P3 - P8 What it depends on +$ +$ If F$Search(P1) .Eqs. "" Then Goto Makeit +$ Time = F$CvTime(F$File(P1,"RDT")) +$arg=3 +$Loop: +$ Argument = P'arg +$ If Argument .Eqs. "" Then Goto Exit +$ El=0 +$Loop2: +$ File = F$Element(El," ",Argument) +$ If File .Eqs. " " Then Goto Endl +$ AFile = "" +$Loop3: +$ OFile = AFile +$ AFile = F$Search(File) +$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl +$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit +$ Goto Loop3 +$NextEL: +$ El = El + 1 +$ Goto Loop2 +$EndL: +$ arg=arg+1 +$ If arg .Le. 8 Then Goto Loop +$ Goto Exit +$ +$Makeit: +$ VV=F$VERIFY(0) +$ write sys$output P2 +$ 'P2 +$ VV='F$Verify(VV) +$Exit: +$ If V Then Set Verify +$ENDSUBROUTINE diff --git a/src/dep/src/irrlicht/libpng/contrib/pngminus/png2pnm.bat b/src/dep/src/irrlicht/libpng/contrib/pngminus/png2pnm.bat index 85abe3c..449cf36 100644 --- a/src/dep/src/irrlicht/libpng/contrib/pngminus/png2pnm.bat +++ b/src/dep/src/irrlicht/libpng/contrib/pngminus/png2pnm.bat @@ -1,41 +1,41 @@ -REM -- grayscale -png2pnm.exe -noraw ..\pngsuite\basn0g01.png basn0g01.pgm -png2pnm.exe -noraw ..\pngsuite\basn0g02.png basn0g02.pgm -png2pnm.exe -noraw ..\pngsuite\basn0g04.png basn0g04.pgm -png2pnm.exe -noraw ..\pngsuite\basn0g08.png basn0g08.pgm -png2pnm.exe -noraw ..\pngsuite\basn0g16.png basn0g16.pgm -REM -- full-color -png2pnm.exe -noraw ..\pngsuite\basn2c08.png basn2c08.ppm -png2pnm.exe -noraw ..\pngsuite\basn2c16.png basn2c16.ppm -REM -- palletted -png2pnm.exe -noraw ..\pngsuite\basn3p01.png basn3p01.ppm -png2pnm.exe -noraw ..\pngsuite\basn3p02.png basn3p02.ppm -png2pnm.exe -noraw ..\pngsuite\basn3p04.png basn3p04.ppm -png2pnm.exe -noraw ..\pngsuite\basn3p08.png basn3p08.ppm -REM -- gray with alpha-channel -png2pnm.exe -noraw ..\pngsuite\basn4a08.png basn4a08.pgm -png2pnm.exe -noraw ..\pngsuite\basn4a16.png basn4a16.pgm -REM -- color with alpha-channel -png2pnm.exe -noraw -alpha basn6a08.pgm ..\pngsuite\basn6a08.png basn6a08.ppm -png2pnm.exe -noraw -alpha basn6a16.pgm ..\pngsuite\basn6a16.png basn6a16.ppm -REM -- grayscale -png2pnm.exe -raw ..\pngsuite\basn0g01.png rawn0g01.pgm -png2pnm.exe -raw ..\pngsuite\basn0g02.png rawn0g02.pgm -png2pnm.exe -raw ..\pngsuite\basn0g04.png rawn0g04.pgm -png2pnm.exe -raw ..\pngsuite\basn0g08.png rawn0g08.pgm -png2pnm.exe -raw ..\pngsuite\basn0g16.png rawn0g16.pgm -REM -- full-color -png2pnm.exe -raw ..\pngsuite\basn2c08.png rawn2c08.ppm -png2pnm.exe -raw ..\pngsuite\basn2c16.png rawn2c16.ppm -REM -- palletted -png2pnm.exe -raw ..\pngsuite\basn3p01.png rawn3p01.ppm -png2pnm.exe -raw ..\pngsuite\basn3p02.png rawn3p02.ppm -png2pnm.exe -raw ..\pngsuite\basn3p04.png rawn3p04.ppm -png2pnm.exe -raw ..\pngsuite\basn3p08.png rawn3p08.ppm -REM -- gray with alpha-channel -png2pnm.exe -raw ..\pngsuite\basn4a08.png rawn4a08.pgm -png2pnm.exe -raw ..\pngsuite\basn4a16.png rawn4a16.pgm -REM -- color with alpha-channel -png2pnm.exe -noraw -alpha rawn6a08.pgm ..\pngsuite\basn6a08.png rawn6a08.ppm -png2pnm.exe -noraw -alpha rawn6a16.pgm ..\pngsuite\basn6a16.png rawn6a16.ppm - +REM -- grayscale +png2pnm.exe -noraw ..\pngsuite\basn0g01.png basn0g01.pgm +png2pnm.exe -noraw ..\pngsuite\basn0g02.png basn0g02.pgm +png2pnm.exe -noraw ..\pngsuite\basn0g04.png basn0g04.pgm +png2pnm.exe -noraw ..\pngsuite\basn0g08.png basn0g08.pgm +png2pnm.exe -noraw ..\pngsuite\basn0g16.png basn0g16.pgm +REM -- full-color +png2pnm.exe -noraw ..\pngsuite\basn2c08.png basn2c08.ppm +png2pnm.exe -noraw ..\pngsuite\basn2c16.png basn2c16.ppm +REM -- palletted +png2pnm.exe -noraw ..\pngsuite\basn3p01.png basn3p01.ppm +png2pnm.exe -noraw ..\pngsuite\basn3p02.png basn3p02.ppm +png2pnm.exe -noraw ..\pngsuite\basn3p04.png basn3p04.ppm +png2pnm.exe -noraw ..\pngsuite\basn3p08.png basn3p08.ppm +REM -- gray with alpha-channel +png2pnm.exe -noraw ..\pngsuite\basn4a08.png basn4a08.pgm +png2pnm.exe -noraw ..\pngsuite\basn4a16.png basn4a16.pgm +REM -- color with alpha-channel +png2pnm.exe -noraw -alpha basn6a08.pgm ..\pngsuite\basn6a08.png basn6a08.ppm +png2pnm.exe -noraw -alpha basn6a16.pgm ..\pngsuite\basn6a16.png basn6a16.ppm +REM -- grayscale +png2pnm.exe -raw ..\pngsuite\basn0g01.png rawn0g01.pgm +png2pnm.exe -raw ..\pngsuite\basn0g02.png rawn0g02.pgm +png2pnm.exe -raw ..\pngsuite\basn0g04.png rawn0g04.pgm +png2pnm.exe -raw ..\pngsuite\basn0g08.png rawn0g08.pgm +png2pnm.exe -raw ..\pngsuite\basn0g16.png rawn0g16.pgm +REM -- full-color +png2pnm.exe -raw ..\pngsuite\basn2c08.png rawn2c08.ppm +png2pnm.exe -raw ..\pngsuite\basn2c16.png rawn2c16.ppm +REM -- palletted +png2pnm.exe -raw ..\pngsuite\basn3p01.png rawn3p01.ppm +png2pnm.exe -raw ..\pngsuite\basn3p02.png rawn3p02.ppm +png2pnm.exe -raw ..\pngsuite\basn3p04.png rawn3p04.ppm +png2pnm.exe -raw ..\pngsuite\basn3p08.png rawn3p08.ppm +REM -- gray with alpha-channel +png2pnm.exe -raw ..\pngsuite\basn4a08.png rawn4a08.pgm +png2pnm.exe -raw ..\pngsuite\basn4a16.png rawn4a16.pgm +REM -- color with alpha-channel +png2pnm.exe -noraw -alpha rawn6a08.pgm ..\pngsuite\basn6a08.png rawn6a08.ppm +png2pnm.exe -noraw -alpha rawn6a16.pgm ..\pngsuite\basn6a16.png rawn6a16.ppm + diff --git a/src/dep/src/irrlicht/libpng/contrib/pngminus/png2pnm.c b/src/dep/src/irrlicht/libpng/contrib/pngminus/png2pnm.c index 6ed477b..010870a 100644 --- a/src/dep/src/irrlicht/libpng/contrib/pngminus/png2pnm.c +++ b/src/dep/src/irrlicht/libpng/contrib/pngminus/png2pnm.c @@ -1,430 +1,430 @@ -/* - * png2pnm.c --- conversion from PNG-file to PGM/PPM-file - * copyright (C) 1999 by Willem van Schaik - * - * version 1.0 - 1999.10.15 - First version. - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear in - * supporting documentation. This software is provided "as is" without - * express or implied warranty. - */ - -#include -#include -#ifdef __TURBOC__ -#include -#include -#endif - -#ifndef BOOL -#define BOOL unsigned char -#endif -#ifndef TRUE -#define TRUE (BOOL) 1 -#endif -#ifndef FALSE -#define FALSE (BOOL) 0 -#endif - -#ifdef __TURBOC__ -#define STDIN 0 -#define STDOUT 1 -#define STDERR 2 -#endif - -/* to make png2pnm verbose so we can find problems (needs to be before png.h) */ -#ifndef PNG_DEBUG -#define PNG_DEBUG 0 -#endif - -#include "png.h" - -/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#endif - -/* function prototypes */ - -int main (int argc, char *argv[]); -void usage (); -BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha); - -/* - * main - */ - -int main(int argc, char *argv[]) -{ - FILE *fp_rd = stdin; - FILE *fp_wr = stdout; - FILE *fp_al = NULL; - BOOL raw = TRUE; - BOOL alpha = FALSE; - int argi; - - for (argi = 1; argi < argc; argi++) - { - if (argv[argi][0] == '-') - { - switch (argv[argi][1]) - { - case 'n': - raw = FALSE; - break; - case 'r': - raw = TRUE; - break; - case 'a': - alpha = TRUE; - argi++; - if ((fp_al = fopen (argv[argi], "wb")) == NULL) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: can not create alpha-channel file %s\n", argv[argi]); - exit (1); - } - break; - case 'h': - case '?': - usage(); - exit(0); - break; - default: - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: unknown option %s\n", argv[argi]); - usage(); - exit(1); - break; - } /* end switch */ - } - else if (fp_rd == stdin) - { - if ((fp_rd = fopen (argv[argi], "rb")) == NULL) - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: file %s does not exist\n", argv[argi]); - exit (1); - } - } - else if (fp_wr == stdout) - { - if ((fp_wr = fopen (argv[argi], "wb")) == NULL) - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: can not create file %s\n", argv[argi]); - exit (1); - } - } - else - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: too many parameters\n"); - usage(); - exit(1); - } - } /* end for */ - -#ifdef __TURBOC__ - /* set stdin/stdout if required to binary */ - if (fp_rd == stdin) - { - setmode (STDIN, O_BINARY); - } - if ((raw) && (fp_wr == stdout)) - { - setmode (STDOUT, O_BINARY); - } -#endif - - /* call the conversion program itself */ - if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE) - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: unsuccessful convertion of PNG-image\n"); - exit(1); - } - - /* close input file */ - fclose (fp_rd); - /* close output file */ - fclose (fp_wr); - /* close alpha file */ - if (alpha) - fclose (fp_al); - - return 0; -} - -/* - * usage - */ - -void usage() -{ - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, " by Willem van Schaik, 1999\n"); -#ifdef __TURBOC__ - fprintf (stderr, " for Turbo-C and Borland-C compilers\n"); -#else - fprintf (stderr, " for Linux (and Unix) compilers\n"); -#endif - fprintf (stderr, "Usage: png2pnm [options] .png [.pnm]\n"); - fprintf (stderr, " or: ... | png2pnm [options]\n"); - fprintf (stderr, "Options:\n"); - fprintf (stderr, " -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n"); - fprintf (stderr, " -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n"); - fprintf (stderr, " -a[lpha] .pgm write PNG alpha channel as pgm-file\n"); - fprintf (stderr, " -h | -? print this help-information\n"); -} - -/* - * png2pnm - */ - -BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha) -{ - png_struct *png_ptr = NULL; - png_info *info_ptr = NULL; - png_byte buf[8]; - png_byte *png_pixels = NULL; - png_byte **row_pointers = NULL; - png_byte *pix_ptr = NULL; - png_uint_32 row_bytes; - - png_uint_32 width; - png_uint_32 height; - int bit_depth; - int channels; - int color_type; - int alpha_present; - int row, col; - int ret; - int i; - long dep_16; - - /* read and check signature in PNG file */ - ret = fread (buf, 1, 8, png_file); - if (ret != 8) - return FALSE; - - ret = png_check_sig (buf, 8); - if (!ret) - return FALSE; - - /* create png and info structures */ - - png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, - NULL, NULL, NULL); - if (!png_ptr) - return FALSE; /* out of memory */ - - info_ptr = png_create_info_struct (png_ptr); - if (!info_ptr) - { - png_destroy_read_struct (&png_ptr, NULL, NULL); - return FALSE; /* out of memory */ - } - - if (setjmp (png_jmpbuf(png_ptr))) - { - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); - return FALSE; - } - - /* set up the input control for C streams */ - png_init_io (png_ptr, png_file); - png_set_sig_bytes (png_ptr, 8); /* we already read the 8 signature bytes */ - - /* read the file information */ - png_read_info (png_ptr, info_ptr); - - /* get size and bit-depth of the PNG-image */ - png_get_IHDR (png_ptr, info_ptr, - &width, &height, &bit_depth, &color_type, - NULL, NULL, NULL); - - /* set-up the transformations */ - - /* transform paletted images into full-color rgb */ - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_expand (png_ptr); - /* expand images to bit-depth 8 (only applicable for grayscale images) */ - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_expand (png_ptr); - /* transform transparency maps into full alpha-channel */ - if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_expand (png_ptr); - -#ifdef NJET - /* downgrade 16-bit images to 8 bit */ - if (bit_depth == 16) - png_set_strip_16 (png_ptr); - /* transform grayscale images into full-color */ - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb (png_ptr); - /* only if file has a file gamma, we do a correction */ - if (png_get_gAMA (png_ptr, info_ptr, &file_gamma)) - png_set_gamma (png_ptr, (double) 2.2, file_gamma); -#endif - - /* all transformations have been registered; now update info_ptr data, - * get rowbytes and channels, and allocate image memory */ - - png_read_update_info (png_ptr, info_ptr); - - /* get the new color-type and bit-depth (after expansion/stripping) */ - png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - NULL, NULL, NULL); - - /* check for 16-bit files */ - if (bit_depth == 16) - { - raw = FALSE; -#ifdef __TURBOC__ - pnm_file->flags &= ~((unsigned) _F_BIN); -#endif - } - - /* calculate new number of channels and store alpha-presence */ - if (color_type == PNG_COLOR_TYPE_GRAY) - channels = 1; - else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - channels = 2; - else if (color_type == PNG_COLOR_TYPE_RGB) - channels = 3; - else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - channels = 4; - else - channels = 0; /* should never happen */ - alpha_present = (channels - 1) % 2; - - /* check if alpha is expected to be present in file */ - if (alpha && !alpha_present) - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: PNG-file doesn't contain alpha channel\n"); - exit (1); - } - - /* row_bytes is the width x number of channels x (bit-depth / 8) */ - row_bytes = png_get_rowbytes (png_ptr, info_ptr); - - if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) { - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); - return FALSE; - } - - if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL) - { - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); - free (png_pixels); - png_pixels = NULL; - return FALSE; - } - - /* set the individual row_pointers to point at the correct offsets */ - for (i = 0; i < (height); i++) - row_pointers[i] = png_pixels + i * row_bytes; - - /* now we can go ahead and just read the whole image */ - png_read_image (png_ptr, row_pointers); - - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ - png_read_end (png_ptr, info_ptr); - - /* clean up after the read, and free any memory allocated - REQUIRED */ - png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp) NULL); - - /* write header of PNM file */ - - if ((color_type == PNG_COLOR_TYPE_GRAY) || - (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) - { - fprintf (pnm_file, "%s\n", (raw) ? "P5" : "P2"); - fprintf (pnm_file, "%d %d\n", (int) width, (int) height); - fprintf (pnm_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); - } - else if ((color_type == PNG_COLOR_TYPE_RGB) || - (color_type == PNG_COLOR_TYPE_RGB_ALPHA)) - { - fprintf (pnm_file, "%s\n", (raw) ? "P6" : "P3"); - fprintf (pnm_file, "%d %d\n", (int) width, (int) height); - fprintf (pnm_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); - } - - /* write header of PGM file with alpha channel */ - - if ((alpha) && - ((color_type == PNG_COLOR_TYPE_GRAY_ALPHA) || - (color_type == PNG_COLOR_TYPE_RGB_ALPHA))) - { - fprintf (alpha_file, "%s\n", (raw) ? "P5" : "P2"); - fprintf (alpha_file, "%d %d\n", (int) width, (int) height); - fprintf (alpha_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); - } - - /* write data to PNM file */ - pix_ptr = png_pixels; - - for (row = 0; row < height; row++) - { - for (col = 0; col < width; col++) - { - for (i = 0; i < (channels - alpha_present); i++) - { - if (raw) - fputc ((int) *pix_ptr++ , pnm_file); - else - if (bit_depth == 16){ - dep_16 = (long) *pix_ptr++; - fprintf (pnm_file, "%ld ", (dep_16 << 8) + ((long) *pix_ptr++)); - } - else - fprintf (pnm_file, "%ld ", (long) *pix_ptr++); - } - if (alpha_present) - { - if (!alpha) - { - pix_ptr++; /* alpha */ - if (bit_depth == 16) - pix_ptr++; - } - else /* output alpha-channel as pgm file */ - { - if (raw) - fputc ((int) *pix_ptr++ , alpha_file); - else - if (bit_depth == 16){ - dep_16 = (long) *pix_ptr++; - fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++); - } - else - fprintf (alpha_file, "%ld ", (long) *pix_ptr++); - } - } /* if alpha_present */ - - if (!raw) - if (col % 4 == 3) - fprintf (pnm_file, "\n"); - } /* end for col */ - - if (!raw) - if (col % 4 != 0) - fprintf (pnm_file, "\n"); - } /* end for row */ - - if (row_pointers != (unsigned char**) NULL) - free (row_pointers); - if (png_pixels != (unsigned char*) NULL) - free (png_pixels); - - return TRUE; - -} /* end of source */ - +/* + * png2pnm.c --- conversion from PNG-file to PGM/PPM-file + * copyright (C) 1999 by Willem van Schaik + * + * version 1.0 - 1999.10.15 - First version. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation. This software is provided "as is" without + * express or implied warranty. + */ + +#include +#include +#ifdef __TURBOC__ +#include +#include +#endif + +#ifndef BOOL +#define BOOL unsigned char +#endif +#ifndef TRUE +#define TRUE (BOOL) 1 +#endif +#ifndef FALSE +#define FALSE (BOOL) 0 +#endif + +#ifdef __TURBOC__ +#define STDIN 0 +#define STDOUT 1 +#define STDERR 2 +#endif + +/* to make png2pnm verbose so we can find problems (needs to be before png.h) */ +#ifndef PNG_DEBUG +#define PNG_DEBUG 0 +#endif + +#include "png.h" + +/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ +#ifndef png_jmpbuf +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#endif + +/* function prototypes */ + +int main (int argc, char *argv[]); +void usage (); +BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha); + +/* + * main + */ + +int main(int argc, char *argv[]) +{ + FILE *fp_rd = stdin; + FILE *fp_wr = stdout; + FILE *fp_al = NULL; + BOOL raw = TRUE; + BOOL alpha = FALSE; + int argi; + + for (argi = 1; argi < argc; argi++) + { + if (argv[argi][0] == '-') + { + switch (argv[argi][1]) + { + case 'n': + raw = FALSE; + break; + case 'r': + raw = TRUE; + break; + case 'a': + alpha = TRUE; + argi++; + if ((fp_al = fopen (argv[argi], "wb")) == NULL) + { + fprintf (stderr, "PNM2PNG\n"); + fprintf (stderr, "Error: can not create alpha-channel file %s\n", argv[argi]); + exit (1); + } + break; + case 'h': + case '?': + usage(); + exit(0); + break; + default: + fprintf (stderr, "PNG2PNM\n"); + fprintf (stderr, "Error: unknown option %s\n", argv[argi]); + usage(); + exit(1); + break; + } /* end switch */ + } + else if (fp_rd == stdin) + { + if ((fp_rd = fopen (argv[argi], "rb")) == NULL) + { + fprintf (stderr, "PNG2PNM\n"); + fprintf (stderr, "Error: file %s does not exist\n", argv[argi]); + exit (1); + } + } + else if (fp_wr == stdout) + { + if ((fp_wr = fopen (argv[argi], "wb")) == NULL) + { + fprintf (stderr, "PNG2PNM\n"); + fprintf (stderr, "Error: can not create file %s\n", argv[argi]); + exit (1); + } + } + else + { + fprintf (stderr, "PNG2PNM\n"); + fprintf (stderr, "Error: too many parameters\n"); + usage(); + exit(1); + } + } /* end for */ + +#ifdef __TURBOC__ + /* set stdin/stdout if required to binary */ + if (fp_rd == stdin) + { + setmode (STDIN, O_BINARY); + } + if ((raw) && (fp_wr == stdout)) + { + setmode (STDOUT, O_BINARY); + } +#endif + + /* call the conversion program itself */ + if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE) + { + fprintf (stderr, "PNG2PNM\n"); + fprintf (stderr, "Error: unsuccessful convertion of PNG-image\n"); + exit(1); + } + + /* close input file */ + fclose (fp_rd); + /* close output file */ + fclose (fp_wr); + /* close alpha file */ + if (alpha) + fclose (fp_al); + + return 0; +} + +/* + * usage + */ + +void usage() +{ + fprintf (stderr, "PNG2PNM\n"); + fprintf (stderr, " by Willem van Schaik, 1999\n"); +#ifdef __TURBOC__ + fprintf (stderr, " for Turbo-C and Borland-C compilers\n"); +#else + fprintf (stderr, " for Linux (and Unix) compilers\n"); +#endif + fprintf (stderr, "Usage: png2pnm [options] .png [.pnm]\n"); + fprintf (stderr, " or: ... | png2pnm [options]\n"); + fprintf (stderr, "Options:\n"); + fprintf (stderr, " -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n"); + fprintf (stderr, " -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n"); + fprintf (stderr, " -a[lpha] .pgm write PNG alpha channel as pgm-file\n"); + fprintf (stderr, " -h | -? print this help-information\n"); +} + +/* + * png2pnm + */ + +BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha) +{ + png_struct *png_ptr = NULL; + png_info *info_ptr = NULL; + png_byte buf[8]; + png_byte *png_pixels = NULL; + png_byte **row_pointers = NULL; + png_byte *pix_ptr = NULL; + png_uint_32 row_bytes; + + png_uint_32 width; + png_uint_32 height; + int bit_depth; + int channels; + int color_type; + int alpha_present; + int row, col; + int ret; + int i; + long dep_16; + + /* read and check signature in PNG file */ + ret = fread (buf, 1, 8, png_file); + if (ret != 8) + return FALSE; + + ret = png_check_sig (buf, 8); + if (!ret) + return FALSE; + + /* create png and info structures */ + + png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, + NULL, NULL, NULL); + if (!png_ptr) + return FALSE; /* out of memory */ + + info_ptr = png_create_info_struct (png_ptr); + if (!info_ptr) + { + png_destroy_read_struct (&png_ptr, NULL, NULL); + return FALSE; /* out of memory */ + } + + if (setjmp (png_jmpbuf(png_ptr))) + { + png_destroy_read_struct (&png_ptr, &info_ptr, NULL); + return FALSE; + } + + /* set up the input control for C streams */ + png_init_io (png_ptr, png_file); + png_set_sig_bytes (png_ptr, 8); /* we already read the 8 signature bytes */ + + /* read the file information */ + png_read_info (png_ptr, info_ptr); + + /* get size and bit-depth of the PNG-image */ + png_get_IHDR (png_ptr, info_ptr, + &width, &height, &bit_depth, &color_type, + NULL, NULL, NULL); + + /* set-up the transformations */ + + /* transform paletted images into full-color rgb */ + if (color_type == PNG_COLOR_TYPE_PALETTE) + png_set_expand (png_ptr); + /* expand images to bit-depth 8 (only applicable for grayscale images) */ + if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) + png_set_expand (png_ptr); + /* transform transparency maps into full alpha-channel */ + if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) + png_set_expand (png_ptr); + +#ifdef NJET + /* downgrade 16-bit images to 8 bit */ + if (bit_depth == 16) + png_set_strip_16 (png_ptr); + /* transform grayscale images into full-color */ + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb (png_ptr); + /* only if file has a file gamma, we do a correction */ + if (png_get_gAMA (png_ptr, info_ptr, &file_gamma)) + png_set_gamma (png_ptr, (double) 2.2, file_gamma); +#endif + + /* all transformations have been registered; now update info_ptr data, + * get rowbytes and channels, and allocate image memory */ + + png_read_update_info (png_ptr, info_ptr); + + /* get the new color-type and bit-depth (after expansion/stripping) */ + png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, + NULL, NULL, NULL); + + /* check for 16-bit files */ + if (bit_depth == 16) + { + raw = FALSE; +#ifdef __TURBOC__ + pnm_file->flags &= ~((unsigned) _F_BIN); +#endif + } + + /* calculate new number of channels and store alpha-presence */ + if (color_type == PNG_COLOR_TYPE_GRAY) + channels = 1; + else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + channels = 2; + else if (color_type == PNG_COLOR_TYPE_RGB) + channels = 3; + else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) + channels = 4; + else + channels = 0; /* should never happen */ + alpha_present = (channels - 1) % 2; + + /* check if alpha is expected to be present in file */ + if (alpha && !alpha_present) + { + fprintf (stderr, "PNG2PNM\n"); + fprintf (stderr, "Error: PNG-file doesn't contain alpha channel\n"); + exit (1); + } + + /* row_bytes is the width x number of channels x (bit-depth / 8) */ + row_bytes = png_get_rowbytes (png_ptr, info_ptr); + + if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) { + png_destroy_read_struct (&png_ptr, &info_ptr, NULL); + return FALSE; + } + + if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL) + { + png_destroy_read_struct (&png_ptr, &info_ptr, NULL); + free (png_pixels); + png_pixels = NULL; + return FALSE; + } + + /* set the individual row_pointers to point at the correct offsets */ + for (i = 0; i < (height); i++) + row_pointers[i] = png_pixels + i * row_bytes; + + /* now we can go ahead and just read the whole image */ + png_read_image (png_ptr, row_pointers); + + /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ + png_read_end (png_ptr, info_ptr); + + /* clean up after the read, and free any memory allocated - REQUIRED */ + png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp) NULL); + + /* write header of PNM file */ + + if ((color_type == PNG_COLOR_TYPE_GRAY) || + (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) + { + fprintf (pnm_file, "%s\n", (raw) ? "P5" : "P2"); + fprintf (pnm_file, "%d %d\n", (int) width, (int) height); + fprintf (pnm_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); + } + else if ((color_type == PNG_COLOR_TYPE_RGB) || + (color_type == PNG_COLOR_TYPE_RGB_ALPHA)) + { + fprintf (pnm_file, "%s\n", (raw) ? "P6" : "P3"); + fprintf (pnm_file, "%d %d\n", (int) width, (int) height); + fprintf (pnm_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); + } + + /* write header of PGM file with alpha channel */ + + if ((alpha) && + ((color_type == PNG_COLOR_TYPE_GRAY_ALPHA) || + (color_type == PNG_COLOR_TYPE_RGB_ALPHA))) + { + fprintf (alpha_file, "%s\n", (raw) ? "P5" : "P2"); + fprintf (alpha_file, "%d %d\n", (int) width, (int) height); + fprintf (alpha_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); + } + + /* write data to PNM file */ + pix_ptr = png_pixels; + + for (row = 0; row < height; row++) + { + for (col = 0; col < width; col++) + { + for (i = 0; i < (channels - alpha_present); i++) + { + if (raw) + fputc ((int) *pix_ptr++ , pnm_file); + else + if (bit_depth == 16){ + dep_16 = (long) *pix_ptr++; + fprintf (pnm_file, "%ld ", (dep_16 << 8) + ((long) *pix_ptr++)); + } + else + fprintf (pnm_file, "%ld ", (long) *pix_ptr++); + } + if (alpha_present) + { + if (!alpha) + { + pix_ptr++; /* alpha */ + if (bit_depth == 16) + pix_ptr++; + } + else /* output alpha-channel as pgm file */ + { + if (raw) + fputc ((int) *pix_ptr++ , alpha_file); + else + if (bit_depth == 16){ + dep_16 = (long) *pix_ptr++; + fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++); + } + else + fprintf (alpha_file, "%ld ", (long) *pix_ptr++); + } + } /* if alpha_present */ + + if (!raw) + if (col % 4 == 3) + fprintf (pnm_file, "\n"); + } /* end for col */ + + if (!raw) + if (col % 4 != 0) + fprintf (pnm_file, "\n"); + } /* end for row */ + + if (row_pointers != (unsigned char**) NULL) + free (row_pointers); + if (png_pixels != (unsigned char*) NULL) + free (png_pixels); + + return TRUE; + +} /* end of source */ + diff --git a/src/dep/src/irrlicht/libpng/contrib/pngminus/png2pnm.sh b/src/dep/src/irrlicht/libpng/contrib/pngminus/png2pnm.sh index ee39664..b1c0537 100644 --- a/src/dep/src/irrlicht/libpng/contrib/pngminus/png2pnm.sh +++ b/src/dep/src/irrlicht/libpng/contrib/pngminus/png2pnm.sh @@ -1,42 +1,42 @@ -#!/bin/sh -# -- grayscale -./png2pnm -noraw ../pngsuite/basn0g01.png basn0g01.pgm -./png2pnm -noraw ../pngsuite/basn0g02.png basn0g02.pgm -./png2pnm -noraw ../pngsuite/basn0g04.png basn0g04.pgm -./png2pnm -noraw ../pngsuite/basn0g08.png basn0g08.pgm -./png2pnm -noraw ../pngsuite/basn0g16.png basn0g16.pgm -# -- full-color -./png2pnm -noraw ../pngsuite/basn2c08.png basn2c08.ppm -./png2pnm -noraw ../pngsuite/basn2c16.png basn2c16.ppm -# -- palletted -./png2pnm -noraw ../pngsuite/basn3p01.png basn3p01.ppm -./png2pnm -noraw ../pngsuite/basn3p02.png basn3p02.ppm -./png2pnm -noraw ../pngsuite/basn3p04.png basn3p04.ppm -./png2pnm -noraw ../pngsuite/basn3p08.png basn3p08.ppm -# -- gray with alpha-channel -./png2pnm -noraw ../pngsuite/basn4a08.png basn4a08.pgm -./png2pnm -noraw ../pngsuite/basn4a16.png basn4a16.pgm -# -- color with alpha-channel -./png2pnm -noraw -alpha basn6a08.pgm ../pngsuite/basn6a08.png basn6a08.ppm -./png2pnm -noraw -alpha basn6a16.pgm ../pngsuite/basn6a16.png basn6a16.ppm -# -- grayscale -./png2pnm -raw ../pngsuite/basn0g01.png rawn0g01.pgm -./png2pnm -raw ../pngsuite/basn0g02.png rawn0g02.pgm -./png2pnm -raw ../pngsuite/basn0g04.png rawn0g04.pgm -./png2pnm -raw ../pngsuite/basn0g08.png rawn0g08.pgm -./png2pnm -raw ../pngsuite/basn0g16.png rawn0g16.pgm -# -- full-color -./png2pnm -raw ../pngsuite/basn2c08.png rawn2c08.ppm -./png2pnm -raw ../pngsuite/basn2c16.png rawn2c16.ppm -# -- palletted -./png2pnm -raw ../pngsuite/basn3p01.png rawn3p01.ppm -./png2pnm -raw ../pngsuite/basn3p02.png rawn3p02.ppm -./png2pnm -raw ../pngsuite/basn3p04.png rawn3p04.ppm -./png2pnm -raw ../pngsuite/basn3p08.png rawn3p08.ppm -# -- gray with alpha-channel -./png2pnm -raw ../pngsuite/basn4a08.png rawn4a08.pgm -./png2pnm -raw ../pngsuite/basn4a16.png rawn4a16.pgm -# -- color with alpha-channel -./png2pnm -noraw -alpha rawn6a08.pgm ../pngsuite/basn6a08.png rawn6a08.ppm -./png2pnm -noraw -alpha rawn6a16.pgm ../pngsuite/basn6a16.png rawn6a16.ppm - +#!/bin/sh +# -- grayscale +./png2pnm -noraw ../pngsuite/basn0g01.png basn0g01.pgm +./png2pnm -noraw ../pngsuite/basn0g02.png basn0g02.pgm +./png2pnm -noraw ../pngsuite/basn0g04.png basn0g04.pgm +./png2pnm -noraw ../pngsuite/basn0g08.png basn0g08.pgm +./png2pnm -noraw ../pngsuite/basn0g16.png basn0g16.pgm +# -- full-color +./png2pnm -noraw ../pngsuite/basn2c08.png basn2c08.ppm +./png2pnm -noraw ../pngsuite/basn2c16.png basn2c16.ppm +# -- palletted +./png2pnm -noraw ../pngsuite/basn3p01.png basn3p01.ppm +./png2pnm -noraw ../pngsuite/basn3p02.png basn3p02.ppm +./png2pnm -noraw ../pngsuite/basn3p04.png basn3p04.ppm +./png2pnm -noraw ../pngsuite/basn3p08.png basn3p08.ppm +# -- gray with alpha-channel +./png2pnm -noraw ../pngsuite/basn4a08.png basn4a08.pgm +./png2pnm -noraw ../pngsuite/basn4a16.png basn4a16.pgm +# -- color with alpha-channel +./png2pnm -noraw -alpha basn6a08.pgm ../pngsuite/basn6a08.png basn6a08.ppm +./png2pnm -noraw -alpha basn6a16.pgm ../pngsuite/basn6a16.png basn6a16.ppm +# -- grayscale +./png2pnm -raw ../pngsuite/basn0g01.png rawn0g01.pgm +./png2pnm -raw ../pngsuite/basn0g02.png rawn0g02.pgm +./png2pnm -raw ../pngsuite/basn0g04.png rawn0g04.pgm +./png2pnm -raw ../pngsuite/basn0g08.png rawn0g08.pgm +./png2pnm -raw ../pngsuite/basn0g16.png rawn0g16.pgm +# -- full-color +./png2pnm -raw ../pngsuite/basn2c08.png rawn2c08.ppm +./png2pnm -raw ../pngsuite/basn2c16.png rawn2c16.ppm +# -- palletted +./png2pnm -raw ../pngsuite/basn3p01.png rawn3p01.ppm +./png2pnm -raw ../pngsuite/basn3p02.png rawn3p02.ppm +./png2pnm -raw ../pngsuite/basn3p04.png rawn3p04.ppm +./png2pnm -raw ../pngsuite/basn3p08.png rawn3p08.ppm +# -- gray with alpha-channel +./png2pnm -raw ../pngsuite/basn4a08.png rawn4a08.pgm +./png2pnm -raw ../pngsuite/basn4a16.png rawn4a16.pgm +# -- color with alpha-channel +./png2pnm -noraw -alpha rawn6a08.pgm ../pngsuite/basn6a08.png rawn6a08.ppm +./png2pnm -noraw -alpha rawn6a16.pgm ../pngsuite/basn6a16.png rawn6a16.ppm + diff --git a/src/dep/src/irrlicht/libpng/contrib/pngminus/pngminus.bat b/src/dep/src/irrlicht/libpng/contrib/pngminus/pngminus.bat index 5f8d2d4..911bb8d 100644 --- a/src/dep/src/irrlicht/libpng/contrib/pngminus/pngminus.bat +++ b/src/dep/src/irrlicht/libpng/contrib/pngminus/pngminus.bat @@ -1,4 +1,4 @@ -make -f makefile.tc3 -call png2pnm.bat -call pnm2png.bat - +make -f makefile.tc3 +call png2pnm.bat +call pnm2png.bat + diff --git a/src/dep/src/irrlicht/libpng/contrib/pngminus/pngminus.sh b/src/dep/src/irrlicht/libpng/contrib/pngminus/pngminus.sh index adcef55..2a0a9d8 100644 --- a/src/dep/src/irrlicht/libpng/contrib/pngminus/pngminus.sh +++ b/src/dep/src/irrlicht/libpng/contrib/pngminus/pngminus.sh @@ -1,5 +1,5 @@ -#!/bin/sh -make -f makefile.std -sh png2pnm.sh -sh pnm2png.sh - +#!/bin/sh +make -f makefile.std +sh png2pnm.sh +sh pnm2png.sh + diff --git a/src/dep/src/irrlicht/libpng/contrib/pngminus/pnm2png.bat b/src/dep/src/irrlicht/libpng/contrib/pngminus/pnm2png.bat index 5b9977a..f756cb8 100644 --- a/src/dep/src/irrlicht/libpng/contrib/pngminus/pnm2png.bat +++ b/src/dep/src/irrlicht/libpng/contrib/pngminus/pnm2png.bat @@ -1,41 +1,41 @@ -REM -- grayscale -pnm2png.exe basn0g01.pgm basn0g01.png -pnm2png.exe basn0g02.pgm basn0g02.png -pnm2png.exe basn0g04.pgm basn0g04.png -pnm2png.exe basn0g08.pgm basn0g08.png -pnm2png.exe basn0g16.pgm basn0g16.png -REM -- full-color -pnm2png.exe basn2c08.ppm basn2c08.png -pnm2png.exe basn2c16.ppm basn2c16.png -REM -- palletted -pnm2png.exe basn3p01.ppm basn3p01.png -pnm2png.exe basn3p02.ppm basn3p02.png -pnm2png.exe basn3p04.ppm basn3p04.png -pnm2png.exe basn3p08.ppm basn3p08.png -REM -- gray with alpha-channel -pnm2png.exe -alpha basn6a08.pgm basn4a08.pgm basn4a08.png -pnm2png.exe -alpha basn6a16.pgm basn4a16.pgm basn4a16.png -REM -- color with alpha-channel -pnm2png.exe -alpha basn6a08.pgm basn6a08.ppm basn6a08.png -pnm2png.exe -alpha basn6a16.pgm basn6a16.ppm basn6a16.png -REM -- grayscale -pnm2png.exe rawn0g01.pgm rawn0g01.png -pnm2png.exe rawn0g02.pgm rawn0g02.png -pnm2png.exe rawn0g04.pgm rawn0g04.png -pnm2png.exe rawn0g08.pgm rawn0g08.png -pnm2png.exe rawn0g16.pgm rawn0g16.png -REM -- full-color -pnm2png.exe rawn2c08.ppm rawn2c08.png -pnm2png.exe rawn2c16.ppm rawn2c16.png -REM -- palletted -pnm2png.exe rawn3p01.ppm rawn3p01.png -pnm2png.exe rawn3p02.ppm rawn3p02.png -pnm2png.exe rawn3p04.ppm rawn3p04.png -pnm2png.exe rawn3p08.ppm rawn3p08.png -REM -- gray with alpha-channel -pnm2png.exe -alpha rawn6a08.pgm rawn4a08.pgm rawn4a08.png -pnm2png.exe -alpha rawn6a16.pgm rawn4a16.pgm rawn4a16.png -REM -- color with alpha-channel -pnm2png.exe -alpha rawn6a08.pgm rawn6a08.ppm rawn6a08.png -pnm2png.exe -alpha rawn6a16.pgm rawn6a16.ppm rawn6a16.png - +REM -- grayscale +pnm2png.exe basn0g01.pgm basn0g01.png +pnm2png.exe basn0g02.pgm basn0g02.png +pnm2png.exe basn0g04.pgm basn0g04.png +pnm2png.exe basn0g08.pgm basn0g08.png +pnm2png.exe basn0g16.pgm basn0g16.png +REM -- full-color +pnm2png.exe basn2c08.ppm basn2c08.png +pnm2png.exe basn2c16.ppm basn2c16.png +REM -- palletted +pnm2png.exe basn3p01.ppm basn3p01.png +pnm2png.exe basn3p02.ppm basn3p02.png +pnm2png.exe basn3p04.ppm basn3p04.png +pnm2png.exe basn3p08.ppm basn3p08.png +REM -- gray with alpha-channel +pnm2png.exe -alpha basn6a08.pgm basn4a08.pgm basn4a08.png +pnm2png.exe -alpha basn6a16.pgm basn4a16.pgm basn4a16.png +REM -- color with alpha-channel +pnm2png.exe -alpha basn6a08.pgm basn6a08.ppm basn6a08.png +pnm2png.exe -alpha basn6a16.pgm basn6a16.ppm basn6a16.png +REM -- grayscale +pnm2png.exe rawn0g01.pgm rawn0g01.png +pnm2png.exe rawn0g02.pgm rawn0g02.png +pnm2png.exe rawn0g04.pgm rawn0g04.png +pnm2png.exe rawn0g08.pgm rawn0g08.png +pnm2png.exe rawn0g16.pgm rawn0g16.png +REM -- full-color +pnm2png.exe rawn2c08.ppm rawn2c08.png +pnm2png.exe rawn2c16.ppm rawn2c16.png +REM -- palletted +pnm2png.exe rawn3p01.ppm rawn3p01.png +pnm2png.exe rawn3p02.ppm rawn3p02.png +pnm2png.exe rawn3p04.ppm rawn3p04.png +pnm2png.exe rawn3p08.ppm rawn3p08.png +REM -- gray with alpha-channel +pnm2png.exe -alpha rawn6a08.pgm rawn4a08.pgm rawn4a08.png +pnm2png.exe -alpha rawn6a16.pgm rawn4a16.pgm rawn4a16.png +REM -- color with alpha-channel +pnm2png.exe -alpha rawn6a08.pgm rawn6a08.ppm rawn6a08.png +pnm2png.exe -alpha rawn6a16.pgm rawn6a16.ppm rawn6a16.png + diff --git a/src/dep/src/irrlicht/libpng/contrib/pngminus/pnm2png.c b/src/dep/src/irrlicht/libpng/contrib/pngminus/pnm2png.c index 2f321cc..4cdfad8 100644 --- a/src/dep/src/irrlicht/libpng/contrib/pngminus/pnm2png.c +++ b/src/dep/src/irrlicht/libpng/contrib/pngminus/pnm2png.c @@ -1,533 +1,533 @@ -/* - * pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file - * copyright (C) 1999 by Willem van Schaik - * - * version 1.0 - 1999.10.15 - First version. - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear in - * supporting documentation. This software is provided "as is" without - * express or implied warranty. - */ - -#include -#include -#ifdef __TURBOC__ -#include -#include -#endif - -#ifndef BOOL -#define BOOL unsigned char -#endif -#ifndef TRUE -#define TRUE (BOOL) 1 -#endif -#ifndef FALSE -#define FALSE (BOOL) 0 -#endif - -#define STDIN 0 -#define STDOUT 1 -#define STDERR 2 - -/* to make pnm2png verbose so we can find problems (needs to be before png.h) */ -#ifndef PNG_DEBUG -#define PNG_DEBUG 0 -#endif - -#include "png.h" - -/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#endif - -/* function prototypes */ - -int main (int argc, char *argv[]); -void usage (); -BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha); -void get_token(FILE *pnm_file, char *token); -png_uint_32 get_data (FILE *pnm_file, int depth); -png_uint_32 get_value (FILE *pnm_file, int depth); - -/* - * main - */ - -int main(int argc, char *argv[]) -{ - FILE *fp_rd = stdin; - FILE *fp_al = NULL; - FILE *fp_wr = stdout; - BOOL interlace = FALSE; - BOOL alpha = FALSE; - int argi; - - for (argi = 1; argi < argc; argi++) - { - if (argv[argi][0] == '-') - { - switch (argv[argi][1]) - { - case 'i': - interlace = TRUE; - break; - case 'a': - alpha = TRUE; - argi++; - if ((fp_al = fopen (argv[argi], "rb")) == NULL) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: alpha-channel file %s does not exist\n", - argv[argi]); - exit (1); - } - break; - case 'h': - case '?': - usage(); - exit(0); - break; - default: - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: unknown option %s\n", argv[argi]); - usage(); - exit(1); - break; - } /* end switch */ - } - else if (fp_rd == stdin) - { - if ((fp_rd = fopen (argv[argi], "rb")) == NULL) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: file %s does not exist\n", argv[argi]); - exit (1); - } - } - else if (fp_wr == stdout) - { - if ((fp_wr = fopen (argv[argi], "wb")) == NULL) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: can not create PNG-file %s\n", argv[argi]); - exit (1); - } - } - else - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: too many parameters\n"); - usage(); - exit (1); - } - } /* end for */ - -#ifdef __TURBOC__ - /* set stdin/stdout to binary, we're reading the PNM always! in binary format */ - if (fp_rd == stdin) - { - setmode (STDIN, O_BINARY); - } - if (fp_wr == stdout) - { - setmode (STDOUT, O_BINARY); - } -#endif - - /* call the conversion program itself */ - if (pnm2png (fp_rd, fp_wr, fp_al, interlace, alpha) == FALSE) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: unsuccessful converting to PNG-image\n"); - exit (1); - } - - /* close input file */ - fclose (fp_rd); - /* close output file */ - fclose (fp_wr); - /* close alpha file */ - if (alpha) - fclose (fp_al); - - return 0; -} - -/* - * usage - */ - -void usage() -{ - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, " by Willem van Schaik, 1999\n"); -#ifdef __TURBOC__ - fprintf (stderr, " for Turbo-C and Borland-C compilers\n"); -#else - fprintf (stderr, " for Linux (and Unix) compilers\n"); -#endif - fprintf (stderr, "Usage: pnm2png [options] . [.png]\n"); - fprintf (stderr, " or: ... | pnm2png [options]\n"); - fprintf (stderr, "Options:\n"); - fprintf (stderr, " -i[nterlace] write png-file with interlacing on\n"); - fprintf (stderr, " -a[lpha] .pgm read PNG alpha channel as pgm-file\n"); - fprintf (stderr, " -h | -? print this help-information\n"); -} - -/* - * pnm2png - */ - -BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha) -{ - png_struct *png_ptr = NULL; - png_info *info_ptr = NULL; - png_byte *png_pixels = NULL; - png_byte **row_pointers = NULL; - png_byte *pix_ptr = NULL; - png_uint_32 row_bytes; - - char type_token[16]; - char width_token[16]; - char height_token[16]; - char maxval_token[16]; - int color_type; - png_uint_32 width, alpha_width; - png_uint_32 height, alpha_height; - png_uint_32 maxval; - int bit_depth = 0; - int channels; - int alpha_depth = 0; - int alpha_present; - int row, col; - BOOL raw, alpha_raw = FALSE; - png_uint_32 tmp16; - int i; - - /* read header of PNM file */ - - get_token(pnm_file, type_token); - if (type_token[0] != 'P') - { - return FALSE; - } - else if ((type_token[1] == '1') || (type_token[1] == '4')) - { - raw = (type_token[1] == '4'); - color_type = PNG_COLOR_TYPE_GRAY; - bit_depth = 1; - } - else if ((type_token[1] == '2') || (type_token[1] == '5')) - { - raw = (type_token[1] == '5'); - color_type = PNG_COLOR_TYPE_GRAY; - get_token(pnm_file, width_token); - sscanf (width_token, "%lu", &width); - get_token(pnm_file, height_token); - sscanf (height_token, "%lu", &height); - get_token(pnm_file, maxval_token); - sscanf (maxval_token, "%lu", &maxval); - if (maxval <= 1) - bit_depth = 1; - else if (maxval <= 3) - bit_depth = 2; - else if (maxval <= 15) - bit_depth = 4; - else if (maxval <= 255) - bit_depth = 8; - else /* if (maxval <= 65535) */ - bit_depth = 16; - } - else if ((type_token[1] == '3') || (type_token[1] == '6')) - { - raw = (type_token[1] == '6'); - color_type = PNG_COLOR_TYPE_RGB; - get_token(pnm_file, width_token); - sscanf (width_token, "%lu", &width); - get_token(pnm_file, height_token); - sscanf (height_token, "%lu", &height); - get_token(pnm_file, maxval_token); - sscanf (maxval_token, "%lu", &maxval); - if (maxval <= 1) - bit_depth = 1; - else if (maxval <= 3) - bit_depth = 2; - else if (maxval <= 15) - bit_depth = 4; - else if (maxval <= 255) - bit_depth = 8; - else /* if (maxval <= 65535) */ - bit_depth = 16; - } - else - { - return FALSE; - } - - /* read header of PGM file with alpha channel */ - - if (alpha) - { - if (color_type == PNG_COLOR_TYPE_GRAY) - color_type = PNG_COLOR_TYPE_GRAY_ALPHA; - if (color_type == PNG_COLOR_TYPE_RGB) - color_type = PNG_COLOR_TYPE_RGB_ALPHA; - - get_token(alpha_file, type_token); - if (type_token[0] != 'P') - { - return FALSE; - } - else if ((type_token[1] == '2') || (type_token[1] == '5')) - { - alpha_raw = (type_token[1] == '5'); - get_token(alpha_file, width_token); - sscanf (width_token, "%lu", &alpha_width); - if (alpha_width != width) - return FALSE; - get_token(alpha_file, height_token); - sscanf (height_token, "%lu", &alpha_height); - if (alpha_height != height) - return FALSE; - get_token(alpha_file, maxval_token); - sscanf (maxval_token, "%lu", &maxval); - if (maxval <= 1) - alpha_depth = 1; - else if (maxval <= 3) - alpha_depth = 2; - else if (maxval <= 15) - alpha_depth = 4; - else if (maxval <= 255) - alpha_depth = 8; - else /* if (maxval <= 65535) */ - alpha_depth = 16; - if (alpha_depth != bit_depth) - return FALSE; - } - else - { - return FALSE; - } - } /* end if alpha */ - - /* calculate the number of channels and store alpha-presence */ - if (color_type == PNG_COLOR_TYPE_GRAY) - channels = 1; - else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - channels = 2; - else if (color_type == PNG_COLOR_TYPE_RGB) - channels = 3; - else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - channels = 4; - else - channels = 0; /* should not happen */ - - alpha_present = (channels - 1) % 2; - - /* row_bytes is the width x number of channels x (bit-depth / 8) */ - row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2); - - if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) - return FALSE; - - /* read data from PNM file */ - pix_ptr = png_pixels; - - for (row = 0; row < height; row++) - { - for (col = 0; col < width; col++) - { - for (i = 0; i < (channels - alpha_present); i++) - { - if (raw) - *pix_ptr++ = get_data (pnm_file, bit_depth); - else - if (bit_depth <= 8) - *pix_ptr++ = get_value (pnm_file, bit_depth); - else - { - tmp16 = get_value (pnm_file, bit_depth); - *pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF); - pix_ptr++; - *pix_ptr = (png_byte) (tmp16 & 0xFF); - pix_ptr++; - } - } - - if (alpha) /* read alpha-channel from pgm file */ - { - if (alpha_raw) - *pix_ptr++ = get_data (alpha_file, alpha_depth); - else - if (alpha_depth <= 8) - *pix_ptr++ = get_value (alpha_file, bit_depth); - else - { - tmp16 = get_value (alpha_file, bit_depth); - *pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF); - *pix_ptr++ = (png_byte) (tmp16 & 0xFF); - } - } /* if alpha */ - - } /* end for col */ - } /* end for row */ - - /* prepare the standard PNG structures */ - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_ptr) - { - return FALSE; - } - info_ptr = png_create_info_struct (png_ptr); - if (!info_ptr) - { - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - return FALSE; - } - - /* setjmp() must be called in every function that calls a PNG-reading libpng function */ - if (setjmp (png_jmpbuf(png_ptr))) - { - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - return FALSE; - } - - /* initialize the png structure */ - png_init_io (png_ptr, png_file); - - /* we're going to write more or less the same PNG as the input file */ - png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type, - (!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - /* write the file header information */ - png_write_info (png_ptr, info_ptr); - - /* if needed we will allocate memory for an new array of row-pointers */ - if (row_pointers == (unsigned char**) NULL) - { - if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL) - { - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - return FALSE; - } - } - - /* set the individual row_pointers to point at the correct offsets */ - for (i = 0; i < (height); i++) - row_pointers[i] = png_pixels + i * row_bytes; - - /* write out the entire image data in one call */ - png_write_image (png_ptr, row_pointers); - - /* write the additional chuncks to the PNG file (not really needed) */ - png_write_end (png_ptr, info_ptr); - - /* clean up after the write, and free any memory allocated */ - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - - if (row_pointers != (unsigned char**) NULL) - free (row_pointers); - if (png_pixels != (unsigned char*) NULL) - free (png_pixels); - - return TRUE; -} /* end of pnm2png */ - -/* - * get_token() - gets the first string after whitespace - */ - -void get_token(FILE *pnm_file, char *token) -{ - int i = 0; - - /* remove white-space */ - do - { - token[i] = (unsigned char) fgetc (pnm_file); - } - while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' ')); - - /* read string */ - do - { - i++; - token[i] = (unsigned char) fgetc (pnm_file); - } - while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' ')); - - token[i] = '\0'; - - return; -} - -/* - * get_data() - takes first byte and converts into next pixel value, - * taking as much bits as defined by bit-depth and - * using the bit-depth to fill up a byte (0Ah -> AAh) - */ - -png_uint_32 get_data (FILE *pnm_file, int depth) -{ - static int bits_left = 0; - static int old_value = 0; - static int mask = 0; - int i; - png_uint_32 ret_value; - - if (mask == 0) - for (i = 0; i < depth; i++) - mask = (mask >> 1) | 0x80; - - if (bits_left <= 0) - { - old_value = fgetc (pnm_file); - bits_left = 8; - } - - ret_value = old_value & mask; - for (i = 1; i < (8 / depth); i++) - ret_value = ret_value || (ret_value >> depth); - - old_value = (old_value << depth) & 0xFF; - bits_left -= depth; - - return ret_value; -} - -/* - * get_value() - takes first (numeric) string and converts into number, - * using the bit-depth to fill up a byte (0Ah -> AAh) - */ - -png_uint_32 get_value (FILE *pnm_file, int depth) -{ - static png_uint_32 mask = 0; - png_byte token[16]; - png_uint_32 ret_value; - int i = 0; - - if (mask == 0) - for (i = 0; i < depth; i++) - mask = (mask << 1) | 0x01; - - get_token (pnm_file, (char *) token); - sscanf ((const char *) token, "%lu", &ret_value); - - ret_value &= mask; - - if (depth < 8) - for (i = 0; i < (8 / depth); i++) - ret_value = (ret_value << depth) || ret_value; - - return ret_value; -} - -/* end of source */ - +/* + * pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file + * copyright (C) 1999 by Willem van Schaik + * + * version 1.0 - 1999.10.15 - First version. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation. This software is provided "as is" without + * express or implied warranty. + */ + +#include +#include +#ifdef __TURBOC__ +#include +#include +#endif + +#ifndef BOOL +#define BOOL unsigned char +#endif +#ifndef TRUE +#define TRUE (BOOL) 1 +#endif +#ifndef FALSE +#define FALSE (BOOL) 0 +#endif + +#define STDIN 0 +#define STDOUT 1 +#define STDERR 2 + +/* to make pnm2png verbose so we can find problems (needs to be before png.h) */ +#ifndef PNG_DEBUG +#define PNG_DEBUG 0 +#endif + +#include "png.h" + +/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ +#ifndef png_jmpbuf +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#endif + +/* function prototypes */ + +int main (int argc, char *argv[]); +void usage (); +BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha); +void get_token(FILE *pnm_file, char *token); +png_uint_32 get_data (FILE *pnm_file, int depth); +png_uint_32 get_value (FILE *pnm_file, int depth); + +/* + * main + */ + +int main(int argc, char *argv[]) +{ + FILE *fp_rd = stdin; + FILE *fp_al = NULL; + FILE *fp_wr = stdout; + BOOL interlace = FALSE; + BOOL alpha = FALSE; + int argi; + + for (argi = 1; argi < argc; argi++) + { + if (argv[argi][0] == '-') + { + switch (argv[argi][1]) + { + case 'i': + interlace = TRUE; + break; + case 'a': + alpha = TRUE; + argi++; + if ((fp_al = fopen (argv[argi], "rb")) == NULL) + { + fprintf (stderr, "PNM2PNG\n"); + fprintf (stderr, "Error: alpha-channel file %s does not exist\n", + argv[argi]); + exit (1); + } + break; + case 'h': + case '?': + usage(); + exit(0); + break; + default: + fprintf (stderr, "PNM2PNG\n"); + fprintf (stderr, "Error: unknown option %s\n", argv[argi]); + usage(); + exit(1); + break; + } /* end switch */ + } + else if (fp_rd == stdin) + { + if ((fp_rd = fopen (argv[argi], "rb")) == NULL) + { + fprintf (stderr, "PNM2PNG\n"); + fprintf (stderr, "Error: file %s does not exist\n", argv[argi]); + exit (1); + } + } + else if (fp_wr == stdout) + { + if ((fp_wr = fopen (argv[argi], "wb")) == NULL) + { + fprintf (stderr, "PNM2PNG\n"); + fprintf (stderr, "Error: can not create PNG-file %s\n", argv[argi]); + exit (1); + } + } + else + { + fprintf (stderr, "PNM2PNG\n"); + fprintf (stderr, "Error: too many parameters\n"); + usage(); + exit (1); + } + } /* end for */ + +#ifdef __TURBOC__ + /* set stdin/stdout to binary, we're reading the PNM always! in binary format */ + if (fp_rd == stdin) + { + setmode (STDIN, O_BINARY); + } + if (fp_wr == stdout) + { + setmode (STDOUT, O_BINARY); + } +#endif + + /* call the conversion program itself */ + if (pnm2png (fp_rd, fp_wr, fp_al, interlace, alpha) == FALSE) + { + fprintf (stderr, "PNM2PNG\n"); + fprintf (stderr, "Error: unsuccessful converting to PNG-image\n"); + exit (1); + } + + /* close input file */ + fclose (fp_rd); + /* close output file */ + fclose (fp_wr); + /* close alpha file */ + if (alpha) + fclose (fp_al); + + return 0; +} + +/* + * usage + */ + +void usage() +{ + fprintf (stderr, "PNM2PNG\n"); + fprintf (stderr, " by Willem van Schaik, 1999\n"); +#ifdef __TURBOC__ + fprintf (stderr, " for Turbo-C and Borland-C compilers\n"); +#else + fprintf (stderr, " for Linux (and Unix) compilers\n"); +#endif + fprintf (stderr, "Usage: pnm2png [options] . [.png]\n"); + fprintf (stderr, " or: ... | pnm2png [options]\n"); + fprintf (stderr, "Options:\n"); + fprintf (stderr, " -i[nterlace] write png-file with interlacing on\n"); + fprintf (stderr, " -a[lpha] .pgm read PNG alpha channel as pgm-file\n"); + fprintf (stderr, " -h | -? print this help-information\n"); +} + +/* + * pnm2png + */ + +BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha) +{ + png_struct *png_ptr = NULL; + png_info *info_ptr = NULL; + png_byte *png_pixels = NULL; + png_byte **row_pointers = NULL; + png_byte *pix_ptr = NULL; + png_uint_32 row_bytes; + + char type_token[16]; + char width_token[16]; + char height_token[16]; + char maxval_token[16]; + int color_type; + png_uint_32 width, alpha_width; + png_uint_32 height, alpha_height; + png_uint_32 maxval; + int bit_depth = 0; + int channels; + int alpha_depth = 0; + int alpha_present; + int row, col; + BOOL raw, alpha_raw = FALSE; + png_uint_32 tmp16; + int i; + + /* read header of PNM file */ + + get_token(pnm_file, type_token); + if (type_token[0] != 'P') + { + return FALSE; + } + else if ((type_token[1] == '1') || (type_token[1] == '4')) + { + raw = (type_token[1] == '4'); + color_type = PNG_COLOR_TYPE_GRAY; + bit_depth = 1; + } + else if ((type_token[1] == '2') || (type_token[1] == '5')) + { + raw = (type_token[1] == '5'); + color_type = PNG_COLOR_TYPE_GRAY; + get_token(pnm_file, width_token); + sscanf (width_token, "%lu", &width); + get_token(pnm_file, height_token); + sscanf (height_token, "%lu", &height); + get_token(pnm_file, maxval_token); + sscanf (maxval_token, "%lu", &maxval); + if (maxval <= 1) + bit_depth = 1; + else if (maxval <= 3) + bit_depth = 2; + else if (maxval <= 15) + bit_depth = 4; + else if (maxval <= 255) + bit_depth = 8; + else /* if (maxval <= 65535) */ + bit_depth = 16; + } + else if ((type_token[1] == '3') || (type_token[1] == '6')) + { + raw = (type_token[1] == '6'); + color_type = PNG_COLOR_TYPE_RGB; + get_token(pnm_file, width_token); + sscanf (width_token, "%lu", &width); + get_token(pnm_file, height_token); + sscanf (height_token, "%lu", &height); + get_token(pnm_file, maxval_token); + sscanf (maxval_token, "%lu", &maxval); + if (maxval <= 1) + bit_depth = 1; + else if (maxval <= 3) + bit_depth = 2; + else if (maxval <= 15) + bit_depth = 4; + else if (maxval <= 255) + bit_depth = 8; + else /* if (maxval <= 65535) */ + bit_depth = 16; + } + else + { + return FALSE; + } + + /* read header of PGM file with alpha channel */ + + if (alpha) + { + if (color_type == PNG_COLOR_TYPE_GRAY) + color_type = PNG_COLOR_TYPE_GRAY_ALPHA; + if (color_type == PNG_COLOR_TYPE_RGB) + color_type = PNG_COLOR_TYPE_RGB_ALPHA; + + get_token(alpha_file, type_token); + if (type_token[0] != 'P') + { + return FALSE; + } + else if ((type_token[1] == '2') || (type_token[1] == '5')) + { + alpha_raw = (type_token[1] == '5'); + get_token(alpha_file, width_token); + sscanf (width_token, "%lu", &alpha_width); + if (alpha_width != width) + return FALSE; + get_token(alpha_file, height_token); + sscanf (height_token, "%lu", &alpha_height); + if (alpha_height != height) + return FALSE; + get_token(alpha_file, maxval_token); + sscanf (maxval_token, "%lu", &maxval); + if (maxval <= 1) + alpha_depth = 1; + else if (maxval <= 3) + alpha_depth = 2; + else if (maxval <= 15) + alpha_depth = 4; + else if (maxval <= 255) + alpha_depth = 8; + else /* if (maxval <= 65535) */ + alpha_depth = 16; + if (alpha_depth != bit_depth) + return FALSE; + } + else + { + return FALSE; + } + } /* end if alpha */ + + /* calculate the number of channels and store alpha-presence */ + if (color_type == PNG_COLOR_TYPE_GRAY) + channels = 1; + else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + channels = 2; + else if (color_type == PNG_COLOR_TYPE_RGB) + channels = 3; + else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) + channels = 4; + else + channels = 0; /* should not happen */ + + alpha_present = (channels - 1) % 2; + + /* row_bytes is the width x number of channels x (bit-depth / 8) */ + row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2); + + if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) + return FALSE; + + /* read data from PNM file */ + pix_ptr = png_pixels; + + for (row = 0; row < height; row++) + { + for (col = 0; col < width; col++) + { + for (i = 0; i < (channels - alpha_present); i++) + { + if (raw) + *pix_ptr++ = get_data (pnm_file, bit_depth); + else + if (bit_depth <= 8) + *pix_ptr++ = get_value (pnm_file, bit_depth); + else + { + tmp16 = get_value (pnm_file, bit_depth); + *pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF); + pix_ptr++; + *pix_ptr = (png_byte) (tmp16 & 0xFF); + pix_ptr++; + } + } + + if (alpha) /* read alpha-channel from pgm file */ + { + if (alpha_raw) + *pix_ptr++ = get_data (alpha_file, alpha_depth); + else + if (alpha_depth <= 8) + *pix_ptr++ = get_value (alpha_file, bit_depth); + else + { + tmp16 = get_value (alpha_file, bit_depth); + *pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF); + *pix_ptr++ = (png_byte) (tmp16 & 0xFF); + } + } /* if alpha */ + + } /* end for col */ + } /* end for row */ + + /* prepare the standard PNG structures */ + png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!png_ptr) + { + return FALSE; + } + info_ptr = png_create_info_struct (png_ptr); + if (!info_ptr) + { + png_destroy_write_struct (&png_ptr, (png_infopp) NULL); + return FALSE; + } + + /* setjmp() must be called in every function that calls a PNG-reading libpng function */ + if (setjmp (png_jmpbuf(png_ptr))) + { + png_destroy_write_struct (&png_ptr, (png_infopp) NULL); + return FALSE; + } + + /* initialize the png structure */ + png_init_io (png_ptr, png_file); + + /* we're going to write more or less the same PNG as the input file */ + png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type, + (!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + + /* write the file header information */ + png_write_info (png_ptr, info_ptr); + + /* if needed we will allocate memory for an new array of row-pointers */ + if (row_pointers == (unsigned char**) NULL) + { + if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL) + { + png_destroy_write_struct (&png_ptr, (png_infopp) NULL); + return FALSE; + } + } + + /* set the individual row_pointers to point at the correct offsets */ + for (i = 0; i < (height); i++) + row_pointers[i] = png_pixels + i * row_bytes; + + /* write out the entire image data in one call */ + png_write_image (png_ptr, row_pointers); + + /* write the additional chuncks to the PNG file (not really needed) */ + png_write_end (png_ptr, info_ptr); + + /* clean up after the write, and free any memory allocated */ + png_destroy_write_struct (&png_ptr, (png_infopp) NULL); + + if (row_pointers != (unsigned char**) NULL) + free (row_pointers); + if (png_pixels != (unsigned char*) NULL) + free (png_pixels); + + return TRUE; +} /* end of pnm2png */ + +/* + * get_token() - gets the first string after whitespace + */ + +void get_token(FILE *pnm_file, char *token) +{ + int i = 0; + + /* remove white-space */ + do + { + token[i] = (unsigned char) fgetc (pnm_file); + } + while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' ')); + + /* read string */ + do + { + i++; + token[i] = (unsigned char) fgetc (pnm_file); + } + while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' ')); + + token[i] = '\0'; + + return; +} + +/* + * get_data() - takes first byte and converts into next pixel value, + * taking as much bits as defined by bit-depth and + * using the bit-depth to fill up a byte (0Ah -> AAh) + */ + +png_uint_32 get_data (FILE *pnm_file, int depth) +{ + static int bits_left = 0; + static int old_value = 0; + static int mask = 0; + int i; + png_uint_32 ret_value; + + if (mask == 0) + for (i = 0; i < depth; i++) + mask = (mask >> 1) | 0x80; + + if (bits_left <= 0) + { + old_value = fgetc (pnm_file); + bits_left = 8; + } + + ret_value = old_value & mask; + for (i = 1; i < (8 / depth); i++) + ret_value = ret_value || (ret_value >> depth); + + old_value = (old_value << depth) & 0xFF; + bits_left -= depth; + + return ret_value; +} + +/* + * get_value() - takes first (numeric) string and converts into number, + * using the bit-depth to fill up a byte (0Ah -> AAh) + */ + +png_uint_32 get_value (FILE *pnm_file, int depth) +{ + static png_uint_32 mask = 0; + png_byte token[16]; + png_uint_32 ret_value; + int i = 0; + + if (mask == 0) + for (i = 0; i < depth; i++) + mask = (mask << 1) | 0x01; + + get_token (pnm_file, (char *) token); + sscanf ((const char *) token, "%lu", &ret_value); + + ret_value &= mask; + + if (depth < 8) + for (i = 0; i < (8 / depth); i++) + ret_value = (ret_value << depth) || ret_value; + + return ret_value; +} + +/* end of source */ + diff --git a/src/dep/src/irrlicht/libpng/contrib/pngminus/pnm2png.sh b/src/dep/src/irrlicht/libpng/contrib/pngminus/pnm2png.sh index 975f047..d79df2f 100644 --- a/src/dep/src/irrlicht/libpng/contrib/pngminus/pnm2png.sh +++ b/src/dep/src/irrlicht/libpng/contrib/pngminus/pnm2png.sh @@ -1,42 +1,42 @@ -#!/bin/sh -# -- grayscale -./pnm2png basn0g01.pgm basn0g01.png -./pnm2png basn0g02.pgm basn0g02.png -./pnm2png basn0g04.pgm basn0g04.png -./pnm2png basn0g08.pgm basn0g08.png -./pnm2png basn0g16.pgm basn0g16.png -# -- full-color -./pnm2png basn2c08.ppm basn2c08.png -./pnm2png basn2c16.ppm basn2c16.png -# -- palletted -./pnm2png basn3p01.ppm basn3p01.png -./pnm2png basn3p02.ppm basn3p02.png -./pnm2png basn3p04.ppm basn3p04.png -./pnm2png basn3p08.ppm basn3p08.png -# -- gray with alpha-channel -./pnm2png -alpha basn6a08.pgm basn4a08.pgm basn4a08.png -./pnm2png -alpha basn6a16.pgm basn4a16.pgm basn4a16.png -# -- color with alpha-channel -./pnm2png -alpha basn6a08.pgm basn6a08.ppm basn6a08.png -./pnm2png -alpha basn6a16.pgm basn6a16.ppm basn6a16.png -# -- grayscale -./pnm2png rawn0g01.pgm rawn0g01.png -./pnm2png rawn0g02.pgm rawn0g02.png -./pnm2png rawn0g04.pgm rawn0g04.png -./pnm2png rawn0g08.pgm rawn0g08.png -./pnm2png rawn0g16.pgm rawn0g16.png -# -- full-color -./pnm2png rawn2c08.ppm rawn2c08.png -./pnm2png rawn2c16.ppm rawn2c16.png -# -- palletted -./pnm2png rawn3p01.ppm rawn3p01.png -./pnm2png rawn3p02.ppm rawn3p02.png -./pnm2png rawn3p04.ppm rawn3p04.png -./pnm2png rawn3p08.ppm rawn3p08.png -# -- gray with alpha-channel -./pnm2png -alpha rawn6a08.pgm rawn4a08.pgm rawn4a08.png -./pnm2png -alpha rawn6a16.pgm rawn4a16.pgm rawn4a16.png -# -- color with alpha-channel -./pnm2png -alpha rawn6a08.pgm rawn6a08.ppm rawn6a08.png -./pnm2png -alpha rawn6a16.pgm rawn6a16.ppm rawn6a16.png - +#!/bin/sh +# -- grayscale +./pnm2png basn0g01.pgm basn0g01.png +./pnm2png basn0g02.pgm basn0g02.png +./pnm2png basn0g04.pgm basn0g04.png +./pnm2png basn0g08.pgm basn0g08.png +./pnm2png basn0g16.pgm basn0g16.png +# -- full-color +./pnm2png basn2c08.ppm basn2c08.png +./pnm2png basn2c16.ppm basn2c16.png +# -- palletted +./pnm2png basn3p01.ppm basn3p01.png +./pnm2png basn3p02.ppm basn3p02.png +./pnm2png basn3p04.ppm basn3p04.png +./pnm2png basn3p08.ppm basn3p08.png +# -- gray with alpha-channel +./pnm2png -alpha basn6a08.pgm basn4a08.pgm basn4a08.png +./pnm2png -alpha basn6a16.pgm basn4a16.pgm basn4a16.png +# -- color with alpha-channel +./pnm2png -alpha basn6a08.pgm basn6a08.ppm basn6a08.png +./pnm2png -alpha basn6a16.pgm basn6a16.ppm basn6a16.png +# -- grayscale +./pnm2png rawn0g01.pgm rawn0g01.png +./pnm2png rawn0g02.pgm rawn0g02.png +./pnm2png rawn0g04.pgm rawn0g04.png +./pnm2png rawn0g08.pgm rawn0g08.png +./pnm2png rawn0g16.pgm rawn0g16.png +# -- full-color +./pnm2png rawn2c08.ppm rawn2c08.png +./pnm2png rawn2c16.ppm rawn2c16.png +# -- palletted +./pnm2png rawn3p01.ppm rawn3p01.png +./pnm2png rawn3p02.ppm rawn3p02.png +./pnm2png rawn3p04.ppm rawn3p04.png +./pnm2png rawn3p08.ppm rawn3p08.png +# -- gray with alpha-channel +./pnm2png -alpha rawn6a08.pgm rawn4a08.pgm rawn4a08.png +./pnm2png -alpha rawn6a16.pgm rawn4a16.pgm rawn4a16.png +# -- color with alpha-channel +./pnm2png -alpha rawn6a08.pgm rawn6a08.ppm rawn6a08.png +./pnm2png -alpha rawn6a16.pgm rawn6a16.ppm rawn6a16.png + diff --git a/src/dep/src/irrlicht/libpng/contrib/visupng/PngFile.c b/src/dep/src/irrlicht/libpng/contrib/visupng/PngFile.c index 94c8fa6..959afe9 100644 --- a/src/dep/src/irrlicht/libpng/contrib/visupng/PngFile.c +++ b/src/dep/src/irrlicht/libpng/contrib/visupng/PngFile.c @@ -1,439 +1,439 @@ -//------------------------------------- -// PNGFILE.C -- Image File Functions -//------------------------------------- - -// Copyright 2000, Willem van Schaik. For conditions of distribution and -// use, see the copyright/license/disclaimer notice in png.h - -#include -#include -#include -#include - -#include "png.h" -#include "pngfile.h" -#include "cexcept.h" - -define_exception_type(const char *); -extern struct exception_context the_exception_context[1]; -struct exception_context the_exception_context[1]; -png_const_charp msg; - -static OPENFILENAME ofn; - -static png_structp png_ptr = NULL; -static png_infop info_ptr = NULL; - - -// cexcept interface - -static void -png_cexcept_error(png_structp png_ptr, png_const_charp msg) -{ - if(png_ptr) - ; -#ifndef PNG_NO_CONSOLE_IO - fprintf(stderr, "libpng error: %s\n", msg); -#endif - { - Throw msg; - } -} - -// Windows open-file functions - -void PngFileInitialize (HWND hwnd) -{ - static TCHAR szFilter[] = TEXT ("PNG Files (*.PNG)\0*.png\0") - TEXT ("All Files (*.*)\0*.*\0\0"); - - ofn.lStructSize = sizeof (OPENFILENAME); - ofn.hwndOwner = hwnd; - ofn.hInstance = NULL; - ofn.lpstrFilter = szFilter; - ofn.lpstrCustomFilter = NULL; - ofn.nMaxCustFilter = 0; - ofn.nFilterIndex = 0; - ofn.lpstrFile = NULL; // Set in Open and Close functions - ofn.nMaxFile = MAX_PATH; - ofn.lpstrFileTitle = NULL; // Set in Open and Close functions - ofn.nMaxFileTitle = MAX_PATH; - ofn.lpstrInitialDir = NULL; - ofn.lpstrTitle = NULL; - ofn.Flags = 0; // Set in Open and Close functions - ofn.nFileOffset = 0; - ofn.nFileExtension = 0; - ofn.lpstrDefExt = TEXT ("png"); - ofn.lCustData = 0; - ofn.lpfnHook = NULL; - ofn.lpTemplateName = NULL; -} - -BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) -{ - ofn.hwndOwner = hwnd; - ofn.lpstrFile = pstrFileName; - ofn.lpstrFileTitle = pstrTitleName; - ofn.Flags = OFN_HIDEREADONLY; - - return GetOpenFileName (&ofn); -} - -BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) -{ - ofn.hwndOwner = hwnd; - ofn.lpstrFile = pstrFileName; - ofn.lpstrFileTitle = pstrTitleName; - ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - - return GetSaveFileName (&ofn); -} - -// PNG image handler functions - -BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData, - int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor) -{ - static FILE *pfFile; - png_byte pbSig[8]; - int iBitDepth; - int iColorType; - double dGamma; - png_color_16 *pBackground; - png_uint_32 ulChannels; - png_uint_32 ulRowBytes; - png_byte *pbImageData = *ppbImageData; - static png_byte **ppbRowPointers = NULL; - int i; - - // open the PNG input file - - if (!pstrFileName) - { - *ppbImageData = pbImageData = NULL; - return FALSE; - } - - if (!(pfFile = fopen(pstrFileName, "rb"))) - { - *ppbImageData = pbImageData = NULL; - return FALSE; - } - - // first check the eight byte PNG signature - - fread(pbSig, 1, 8, pfFile); - if (!png_check_sig(pbSig, 8)) - { - *ppbImageData = pbImageData = NULL; - return FALSE; - } - - // create the two png(-info) structures - - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, - (png_error_ptr)png_cexcept_error, (png_error_ptr)NULL); - if (!png_ptr) - { - *ppbImageData = pbImageData = NULL; - return FALSE; - } - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, NULL, NULL); - *ppbImageData = pbImageData = NULL; - return FALSE; - } - - Try - { - - // initialize the png structure - -#if !defined(PNG_NO_STDIO) - png_init_io(png_ptr, pfFile); -#else - png_set_read_fn(png_ptr, (png_voidp)pfFile, png_read_data); -#endif - - png_set_sig_bytes(png_ptr, 8); - - // read all PNG info up to image data - - png_read_info(png_ptr, info_ptr); - - // get width, height, bit-depth and color-type - - png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth, - &iColorType, NULL, NULL, NULL); - - // expand images of all color-type and bit-depth to 3x8 bit RGB images - // let the library process things like alpha, transparency, background - - if (iBitDepth == 16) - png_set_strip_16(png_ptr); - if (iColorType == PNG_COLOR_TYPE_PALETTE) - png_set_expand(png_ptr); - if (iBitDepth < 8) - png_set_expand(png_ptr); - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_expand(png_ptr); - if (iColorType == PNG_COLOR_TYPE_GRAY || - iColorType == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - - // set the background color to draw transparent and alpha images over. - if (png_get_bKGD(png_ptr, info_ptr, &pBackground)) - { - png_set_background(png_ptr, pBackground, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - pBkgColor->red = (byte) pBackground->red; - pBkgColor->green = (byte) pBackground->green; - pBkgColor->blue = (byte) pBackground->blue; - } - else - { - pBkgColor = NULL; - } - - // if required set gamma conversion - if (png_get_gAMA(png_ptr, info_ptr, &dGamma)) - png_set_gamma(png_ptr, (double) 2.2, dGamma); - - // after the transformations have been registered update info_ptr data - - png_read_update_info(png_ptr, info_ptr); - - // get again width, height and the new bit-depth and color-type - - png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth, - &iColorType, NULL, NULL, NULL); - - - // row_bytes is the width x number of channels - - ulRowBytes = png_get_rowbytes(png_ptr, info_ptr); - ulChannels = png_get_channels(png_ptr, info_ptr); - - *piChannels = ulChannels; - - // now we can allocate memory to store the image - - if (pbImageData) - { - free (pbImageData); - pbImageData = NULL; - } - if ((pbImageData = (png_byte *) malloc(ulRowBytes * (*piHeight) - * sizeof(png_byte))) == NULL) - { - png_error(png_ptr, "Visual PNG: out of memory"); - } - *ppbImageData = pbImageData; - - // and allocate memory for an array of row-pointers - - if ((ppbRowPointers = (png_bytepp) malloc((*piHeight) - * sizeof(png_bytep))) == NULL) - { - png_error(png_ptr, "Visual PNG: out of memory"); - } - - // set the individual row-pointers to point at the correct offsets - - for (i = 0; i < (*piHeight); i++) - ppbRowPointers[i] = pbImageData + i * ulRowBytes; - - // now we can go ahead and just read the whole image - - png_read_image(png_ptr, ppbRowPointers); - - // read the additional chunks in the PNG file (not really needed) - - png_read_end(png_ptr, NULL); - - // and we're done - - free (ppbRowPointers); - ppbRowPointers = NULL; - - // yepp, done - } - - Catch (msg) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - - *ppbImageData = pbImageData = NULL; - - if(ppbRowPointers) - free (ppbRowPointers); - - fclose(pfFile); - - return FALSE; - } - - fclose (pfFile); - - return TRUE; -} - - -BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData, - int iWidth, int iHeight, png_color bkgColor) -{ - const int ciBitDepth = 8; - const int ciChannels = 3; - - static FILE *pfFile; - png_uint_32 ulRowBytes; - static png_byte **ppbRowPointers = NULL; - int i; - - // open the PNG output file - - if (!pstrFileName) - return FALSE; - - if (!(pfFile = fopen(pstrFileName, "wb"))) - return FALSE; - - // prepare the standard PNG structures - - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, - (png_error_ptr)png_cexcept_error, (png_error_ptr)NULL); - if (!png_ptr) - { - fclose(pfFile); - return FALSE; - } - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { - fclose(pfFile); - png_destroy_write_struct(&png_ptr, (png_infopp) NULL); - return FALSE; - } - - Try - { - // initialize the png structure - -#if !defined(PNG_NO_STDIO) - png_init_io(png_ptr, pfFile); -#else - png_set_write_fn(png_ptr, (png_voidp)pfFile, png_write_data, png_flush); -#endif - - // we're going to write a very simple 3x8 bit RGB image - - png_set_IHDR(png_ptr, info_ptr, iWidth, iHeight, ciBitDepth, - PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, - PNG_FILTER_TYPE_BASE); - - // write the file header information - - png_write_info(png_ptr, info_ptr); - - // swap the BGR pixels in the DiData structure to RGB - - png_set_bgr(png_ptr); - - // row_bytes is the width x number of channels - - ulRowBytes = iWidth * ciChannels; - - // we can allocate memory for an array of row-pointers - - if ((ppbRowPointers = (png_bytepp) malloc(iHeight * sizeof(png_bytep))) == NULL) - Throw "Visualpng: Out of memory"; - - // set the individual row-pointers to point at the correct offsets - - for (i = 0; i < iHeight; i++) - ppbRowPointers[i] = pDiData + i * (((ulRowBytes + 3) >> 2) << 2); - - // write out the entire image data in one call - - png_write_image (png_ptr, ppbRowPointers); - - // write the additional chunks to the PNG file (not really needed) - - png_write_end(png_ptr, info_ptr); - - // and we're done - - free (ppbRowPointers); - ppbRowPointers = NULL; - - // clean up after the write, and free any memory allocated - - png_destroy_write_struct(&png_ptr, (png_infopp) NULL); - - // yepp, done - } - - Catch (msg) - { - png_destroy_write_struct(&png_ptr, (png_infopp) NULL); - - if(ppbRowPointers) - free (ppbRowPointers); - - fclose(pfFile); - - return FALSE; - } - - fclose (pfFile); - - return TRUE; -} - -#ifdef PNG_NO_STDIO - -static void -png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - /* fread() returns 0 on error, so it is OK to store this in a png_size_t - * instead of an int, which is what fread() actually returns. - */ - check = (png_size_t)fread(data, (png_size_t)1, length, - (FILE *)png_ptr->io_ptr); - - if (check != length) - { - png_error(png_ptr, "Read Error"); - } -} - -static void -png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - - check = fwrite(data, 1, length, (FILE *)(png_ptr->io_ptr)); - if (check != length) - { - png_error(png_ptr, "Write Error"); - } -} - -static void -png_flush(png_structp png_ptr) -{ - FILE *io_ptr; - io_ptr = (FILE *)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -} - -#endif - -//----------------- -// end of source -//----------------- +//------------------------------------- +// PNGFILE.C -- Image File Functions +//------------------------------------- + +// Copyright 2000, Willem van Schaik. For conditions of distribution and +// use, see the copyright/license/disclaimer notice in png.h + +#include +#include +#include +#include + +#include "png.h" +#include "pngfile.h" +#include "cexcept.h" + +define_exception_type(const char *); +extern struct exception_context the_exception_context[1]; +struct exception_context the_exception_context[1]; +png_const_charp msg; + +static OPENFILENAME ofn; + +static png_structp png_ptr = NULL; +static png_infop info_ptr = NULL; + + +// cexcept interface + +static void +png_cexcept_error(png_structp png_ptr, png_const_charp msg) +{ + if(png_ptr) + ; +#ifndef PNG_NO_CONSOLE_IO + fprintf(stderr, "libpng error: %s\n", msg); +#endif + { + Throw msg; + } +} + +// Windows open-file functions + +void PngFileInitialize (HWND hwnd) +{ + static TCHAR szFilter[] = TEXT ("PNG Files (*.PNG)\0*.png\0") + TEXT ("All Files (*.*)\0*.*\0\0"); + + ofn.lStructSize = sizeof (OPENFILENAME); + ofn.hwndOwner = hwnd; + ofn.hInstance = NULL; + ofn.lpstrFilter = szFilter; + ofn.lpstrCustomFilter = NULL; + ofn.nMaxCustFilter = 0; + ofn.nFilterIndex = 0; + ofn.lpstrFile = NULL; // Set in Open and Close functions + ofn.nMaxFile = MAX_PATH; + ofn.lpstrFileTitle = NULL; // Set in Open and Close functions + ofn.nMaxFileTitle = MAX_PATH; + ofn.lpstrInitialDir = NULL; + ofn.lpstrTitle = NULL; + ofn.Flags = 0; // Set in Open and Close functions + ofn.nFileOffset = 0; + ofn.nFileExtension = 0; + ofn.lpstrDefExt = TEXT ("png"); + ofn.lCustData = 0; + ofn.lpfnHook = NULL; + ofn.lpTemplateName = NULL; +} + +BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) +{ + ofn.hwndOwner = hwnd; + ofn.lpstrFile = pstrFileName; + ofn.lpstrFileTitle = pstrTitleName; + ofn.Flags = OFN_HIDEREADONLY; + + return GetOpenFileName (&ofn); +} + +BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) +{ + ofn.hwndOwner = hwnd; + ofn.lpstrFile = pstrFileName; + ofn.lpstrFileTitle = pstrTitleName; + ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; + + return GetSaveFileName (&ofn); +} + +// PNG image handler functions + +BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData, + int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor) +{ + static FILE *pfFile; + png_byte pbSig[8]; + int iBitDepth; + int iColorType; + double dGamma; + png_color_16 *pBackground; + png_uint_32 ulChannels; + png_uint_32 ulRowBytes; + png_byte *pbImageData = *ppbImageData; + static png_byte **ppbRowPointers = NULL; + int i; + + // open the PNG input file + + if (!pstrFileName) + { + *ppbImageData = pbImageData = NULL; + return FALSE; + } + + if (!(pfFile = fopen(pstrFileName, "rb"))) + { + *ppbImageData = pbImageData = NULL; + return FALSE; + } + + // first check the eight byte PNG signature + + fread(pbSig, 1, 8, pfFile); + if (!png_check_sig(pbSig, 8)) + { + *ppbImageData = pbImageData = NULL; + return FALSE; + } + + // create the two png(-info) structures + + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, + (png_error_ptr)png_cexcept_error, (png_error_ptr)NULL); + if (!png_ptr) + { + *ppbImageData = pbImageData = NULL; + return FALSE; + } + + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + png_destroy_read_struct(&png_ptr, NULL, NULL); + *ppbImageData = pbImageData = NULL; + return FALSE; + } + + Try + { + + // initialize the png structure + +#if !defined(PNG_NO_STDIO) + png_init_io(png_ptr, pfFile); +#else + png_set_read_fn(png_ptr, (png_voidp)pfFile, png_read_data); +#endif + + png_set_sig_bytes(png_ptr, 8); + + // read all PNG info up to image data + + png_read_info(png_ptr, info_ptr); + + // get width, height, bit-depth and color-type + + png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth, + &iColorType, NULL, NULL, NULL); + + // expand images of all color-type and bit-depth to 3x8 bit RGB images + // let the library process things like alpha, transparency, background + + if (iBitDepth == 16) + png_set_strip_16(png_ptr); + if (iColorType == PNG_COLOR_TYPE_PALETTE) + png_set_expand(png_ptr); + if (iBitDepth < 8) + png_set_expand(png_ptr); + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) + png_set_expand(png_ptr); + if (iColorType == PNG_COLOR_TYPE_GRAY || + iColorType == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png_ptr); + + // set the background color to draw transparent and alpha images over. + if (png_get_bKGD(png_ptr, info_ptr, &pBackground)) + { + png_set_background(png_ptr, pBackground, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); + pBkgColor->red = (byte) pBackground->red; + pBkgColor->green = (byte) pBackground->green; + pBkgColor->blue = (byte) pBackground->blue; + } + else + { + pBkgColor = NULL; + } + + // if required set gamma conversion + if (png_get_gAMA(png_ptr, info_ptr, &dGamma)) + png_set_gamma(png_ptr, (double) 2.2, dGamma); + + // after the transformations have been registered update info_ptr data + + png_read_update_info(png_ptr, info_ptr); + + // get again width, height and the new bit-depth and color-type + + png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth, + &iColorType, NULL, NULL, NULL); + + + // row_bytes is the width x number of channels + + ulRowBytes = png_get_rowbytes(png_ptr, info_ptr); + ulChannels = png_get_channels(png_ptr, info_ptr); + + *piChannels = ulChannels; + + // now we can allocate memory to store the image + + if (pbImageData) + { + free (pbImageData); + pbImageData = NULL; + } + if ((pbImageData = (png_byte *) malloc(ulRowBytes * (*piHeight) + * sizeof(png_byte))) == NULL) + { + png_error(png_ptr, "Visual PNG: out of memory"); + } + *ppbImageData = pbImageData; + + // and allocate memory for an array of row-pointers + + if ((ppbRowPointers = (png_bytepp) malloc((*piHeight) + * sizeof(png_bytep))) == NULL) + { + png_error(png_ptr, "Visual PNG: out of memory"); + } + + // set the individual row-pointers to point at the correct offsets + + for (i = 0; i < (*piHeight); i++) + ppbRowPointers[i] = pbImageData + i * ulRowBytes; + + // now we can go ahead and just read the whole image + + png_read_image(png_ptr, ppbRowPointers); + + // read the additional chunks in the PNG file (not really needed) + + png_read_end(png_ptr, NULL); + + // and we're done + + free (ppbRowPointers); + ppbRowPointers = NULL; + + // yepp, done + } + + Catch (msg) + { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + + *ppbImageData = pbImageData = NULL; + + if(ppbRowPointers) + free (ppbRowPointers); + + fclose(pfFile); + + return FALSE; + } + + fclose (pfFile); + + return TRUE; +} + + +BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData, + int iWidth, int iHeight, png_color bkgColor) +{ + const int ciBitDepth = 8; + const int ciChannels = 3; + + static FILE *pfFile; + png_uint_32 ulRowBytes; + static png_byte **ppbRowPointers = NULL; + int i; + + // open the PNG output file + + if (!pstrFileName) + return FALSE; + + if (!(pfFile = fopen(pstrFileName, "wb"))) + return FALSE; + + // prepare the standard PNG structures + + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, + (png_error_ptr)png_cexcept_error, (png_error_ptr)NULL); + if (!png_ptr) + { + fclose(pfFile); + return FALSE; + } + + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + fclose(pfFile); + png_destroy_write_struct(&png_ptr, (png_infopp) NULL); + return FALSE; + } + + Try + { + // initialize the png structure + +#if !defined(PNG_NO_STDIO) + png_init_io(png_ptr, pfFile); +#else + png_set_write_fn(png_ptr, (png_voidp)pfFile, png_write_data, png_flush); +#endif + + // we're going to write a very simple 3x8 bit RGB image + + png_set_IHDR(png_ptr, info_ptr, iWidth, iHeight, ciBitDepth, + PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, + PNG_FILTER_TYPE_BASE); + + // write the file header information + + png_write_info(png_ptr, info_ptr); + + // swap the BGR pixels in the DiData structure to RGB + + png_set_bgr(png_ptr); + + // row_bytes is the width x number of channels + + ulRowBytes = iWidth * ciChannels; + + // we can allocate memory for an array of row-pointers + + if ((ppbRowPointers = (png_bytepp) malloc(iHeight * sizeof(png_bytep))) == NULL) + Throw "Visualpng: Out of memory"; + + // set the individual row-pointers to point at the correct offsets + + for (i = 0; i < iHeight; i++) + ppbRowPointers[i] = pDiData + i * (((ulRowBytes + 3) >> 2) << 2); + + // write out the entire image data in one call + + png_write_image (png_ptr, ppbRowPointers); + + // write the additional chunks to the PNG file (not really needed) + + png_write_end(png_ptr, info_ptr); + + // and we're done + + free (ppbRowPointers); + ppbRowPointers = NULL; + + // clean up after the write, and free any memory allocated + + png_destroy_write_struct(&png_ptr, (png_infopp) NULL); + + // yepp, done + } + + Catch (msg) + { + png_destroy_write_struct(&png_ptr, (png_infopp) NULL); + + if(ppbRowPointers) + free (ppbRowPointers); + + fclose(pfFile); + + return FALSE; + } + + fclose (pfFile); + + return TRUE; +} + +#ifdef PNG_NO_STDIO + +static void +png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_size_t check; + + /* fread() returns 0 on error, so it is OK to store this in a png_size_t + * instead of an int, which is what fread() actually returns. + */ + check = (png_size_t)fread(data, (png_size_t)1, length, + (FILE *)png_ptr->io_ptr); + + if (check != length) + { + png_error(png_ptr, "Read Error"); + } +} + +static void +png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_uint_32 check; + + check = fwrite(data, 1, length, (FILE *)(png_ptr->io_ptr)); + if (check != length) + { + png_error(png_ptr, "Write Error"); + } +} + +static void +png_flush(png_structp png_ptr) +{ + FILE *io_ptr; + io_ptr = (FILE *)CVT_PTR((png_ptr->io_ptr)); + if (io_ptr != NULL) + fflush(io_ptr); +} + +#endif + +//----------------- +// end of source +//----------------- diff --git a/src/dep/src/irrlicht/libpng/contrib/visupng/PngFile.h b/src/dep/src/irrlicht/libpng/contrib/visupng/PngFile.h index f46cd59..a900fd4 100644 --- a/src/dep/src/irrlicht/libpng/contrib/visupng/PngFile.h +++ b/src/dep/src/irrlicht/libpng/contrib/visupng/PngFile.h @@ -1,27 +1,27 @@ -//------------------------------------------ -// PNGFILE.H -- Header File for pngfile.c -//------------------------------------------ - -// Copyright 2000, Willem van Schaik. For conditions of distribution and -// use, see the copyright/license/disclaimer notice in png.h - -#include -#include -#include -#include - -void PngFileInitialize (HWND hwnd) ; -BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ; -BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ; - -BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData, - int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor); -BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData, - int iWidth, int iHeight, png_color BkgColor); - -#if defined(PNG_NO_STDIO) -static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length); -static void png_write_data(png_structp png_ptr, png_bytep data, png_size_t length); -static void png_flush(png_structp png_ptr); -#endif - +//------------------------------------------ +// PNGFILE.H -- Header File for pngfile.c +//------------------------------------------ + +// Copyright 2000, Willem van Schaik. For conditions of distribution and +// use, see the copyright/license/disclaimer notice in png.h + +#include +#include +#include +#include + +void PngFileInitialize (HWND hwnd) ; +BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ; +BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ; + +BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData, + int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor); +BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData, + int iWidth, int iHeight, png_color BkgColor); + +#if defined(PNG_NO_STDIO) +static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length); +static void png_write_data(png_structp png_ptr, png_bytep data, png_size_t length); +static void png_flush(png_structp png_ptr); +#endif + diff --git a/src/dep/src/irrlicht/libpng/contrib/visupng/README.txt b/src/dep/src/irrlicht/libpng/contrib/visupng/README.txt index 7150473..4a753d8 100644 --- a/src/dep/src/irrlicht/libpng/contrib/visupng/README.txt +++ b/src/dep/src/irrlicht/libpng/contrib/visupng/README.txt @@ -1,58 +1,58 @@ -Microsoft Developer Studio Build File, Format Version 6.00 for VisualPng ------------------------------------------------------------------------- - -Copyright 2000, Willem van Schaik. For conditions of distribution and -use, see the copyright/license/disclaimer notice in png.h - -As a PNG .dll demo VisualPng is finished. More features would only hinder -the program's objective. However, further extensions (like support for other -graphics formats) are in development. To get these, or for pre-compiled -binaries, go to "http://www.schaik.com/png/visualpng.html". - ------------------------------------------------------------------------- - -Assumes that - - libpng DLLs and LIBs are in ..\..\projects\msvc\win32\libpng - zlib DLLs and LIBs are in ..\..\projects\msvc\win32\zlib - libpng header files are in ..\..\..\libpng - zlib header files are in ..\..\..\zlib - the pngsuite images are in ..\pngsuite - -To build: - -1) On the main menu Select "Build|Set Active configuration". - Choose the configuration that corresponds to the library you want to test. - This library must have been built using the libpng MS project located in - the "..\..\mscv" subdirectory. - -2) Select "Build|Clean" - -3) Select "Build|Rebuild All" - -4) After compiling and linking VisualPng will be started to view an image - from the PngSuite directory. Press Ctrl-N (and Ctrl-V) for other images. - - -To install: - -When distributing VisualPng (or a further development) the following options -are available: - -1) Build the program with the configuration "Win32 LIB" and you only need to - include the executable from the ./lib directory in your distribution. - -2) Build the program with the configuration "Win32 DLL" and you need to put - in your distribution the executable from the ./dll directory and the dll's - libpng1.dll, zlib.dll and msvcrt.dll. These need to be in the user's PATH. - - -Willem van Schaik -Calgary, June 6th 2000 - -P.S. VisualPng was written based on preliminary work of: - - - Simon-Pierre Cadieux - - Glenn Randers-Pehrson - - Greg Roelofs - +Microsoft Developer Studio Build File, Format Version 6.00 for VisualPng +------------------------------------------------------------------------ + +Copyright 2000, Willem van Schaik. For conditions of distribution and +use, see the copyright/license/disclaimer notice in png.h + +As a PNG .dll demo VisualPng is finished. More features would only hinder +the program's objective. However, further extensions (like support for other +graphics formats) are in development. To get these, or for pre-compiled +binaries, go to "http://www.schaik.com/png/visualpng.html". + +------------------------------------------------------------------------ + +Assumes that + + libpng DLLs and LIBs are in ..\..\projects\msvc\win32\libpng + zlib DLLs and LIBs are in ..\..\projects\msvc\win32\zlib + libpng header files are in ..\..\..\libpng + zlib header files are in ..\..\..\zlib + the pngsuite images are in ..\pngsuite + +To build: + +1) On the main menu Select "Build|Set Active configuration". + Choose the configuration that corresponds to the library you want to test. + This library must have been built using the libpng MS project located in + the "..\..\mscv" subdirectory. + +2) Select "Build|Clean" + +3) Select "Build|Rebuild All" + +4) After compiling and linking VisualPng will be started to view an image + from the PngSuite directory. Press Ctrl-N (and Ctrl-V) for other images. + + +To install: + +When distributing VisualPng (or a further development) the following options +are available: + +1) Build the program with the configuration "Win32 LIB" and you only need to + include the executable from the ./lib directory in your distribution. + +2) Build the program with the configuration "Win32 DLL" and you need to put + in your distribution the executable from the ./dll directory and the dll's + libpng1.dll, zlib.dll and msvcrt.dll. These need to be in the user's PATH. + + +Willem van Schaik +Calgary, June 6th 2000 + +P.S. VisualPng was written based on preliminary work of: + + - Simon-Pierre Cadieux + - Glenn Randers-Pehrson + - Greg Roelofs + diff --git a/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.c b/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.c index df3e4cd..f2cf6ee 100644 --- a/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.c +++ b/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.c @@ -1,961 +1,961 @@ -//------------------------------------ -// VisualPng.C -- Shows a PNG image -//------------------------------------ - -// Copyright 2000, Willem van Schaik. For conditions of distribution and -// use, see the copyright/license/disclaimer notice in png.h - -// switches - -// defines - -#define PROGNAME "VisualPng" -#define LONGNAME "Win32 Viewer for PNG-files" -#define VERSION "1.0 of 2000 June 07" - -// constants - -#define MARGIN 8 - -// standard includes - -#include -#include -#include -#include - -// application includes - -#include "png.h" -#include "pngfile.h" -#include "resource.h" - -// macros - -// function prototypes - -LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK AboutDlgProc (HWND, UINT, WPARAM, LPARAM) ; - -BOOL CenterAbout (HWND hwndChild, HWND hwndParent); - -BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount, - int *pFileIndex); - -BOOL SearchPngList (TCHAR *pFileList, int FileCount, int *pFileIndex, - PTSTR pstrPrevName, PTSTR pstrNextName); - -BOOL LoadImageFile(HWND hwnd, PTSTR pstrPathName, - png_byte **ppbImage, int *pxImgSize, int *pyImgSize, int *piChannels, - png_color *pBkgColor); - -BOOL DisplayImage (HWND hwnd, BYTE **ppDib, - BYTE **ppDiData, int cxWinSize, int cyWinSize, - BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, - BOOL bStretched); - -BOOL InitBitmap ( - BYTE *pDiData, int cxWinSize, int cyWinSize); - -BOOL FillBitmap ( - BYTE *pDiData, int cxWinSize, int cyWinSize, - BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, - BOOL bStretched); - -// a few global variables - -static char *szProgName = PROGNAME; -static char *szAppName = LONGNAME; -static char *szIconName = PROGNAME; -static char szCmdFileName [MAX_PATH]; - -// MAIN routine - -int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, - PSTR szCmdLine, int iCmdShow) -{ - HACCEL hAccel; - HWND hwnd; - MSG msg; - WNDCLASS wndclass; - int ixBorders, iyBorders; - - wndclass.style = CS_HREDRAW | CS_VREDRAW; - wndclass.lpfnWndProc = WndProc; - wndclass.cbClsExtra = 0; - wndclass.cbWndExtra = 0; - wndclass.hInstance = hInstance; - wndclass.hIcon = LoadIcon (hInstance, szIconName) ; - wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); - wndclass.hbrBackground = NULL; // (HBRUSH) GetStockObject (GRAY_BRUSH); - wndclass.lpszMenuName = szProgName; - wndclass.lpszClassName = szProgName; - - if (!RegisterClass (&wndclass)) - { - MessageBox (NULL, TEXT ("Error: this program requires Windows NT!"), - szProgName, MB_ICONERROR); - return 0; - } - - // if filename given on commandline, store it - if ((szCmdLine != NULL) && (*szCmdLine != '\0')) - if (szCmdLine[0] == '"') - strncpy (szCmdFileName, szCmdLine + 1, strlen(szCmdLine) - 2); - else - strcpy (szCmdFileName, szCmdLine); - else - strcpy (szCmdFileName, ""); - - // calculate size of window-borders - ixBorders = 2 * (GetSystemMetrics (SM_CXBORDER) + - GetSystemMetrics (SM_CXDLGFRAME)); - iyBorders = 2 * (GetSystemMetrics (SM_CYBORDER) + - GetSystemMetrics (SM_CYDLGFRAME)) + - GetSystemMetrics (SM_CYCAPTION) + - GetSystemMetrics (SM_CYMENUSIZE) + - 1; /* WvS: don't ask me why? */ - - hwnd = CreateWindow (szProgName, szAppName, - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, - 512 + 2 * MARGIN + ixBorders, 384 + 2 * MARGIN + iyBorders, -// CW_USEDEFAULT, CW_USEDEFAULT, - NULL, NULL, hInstance, NULL); - - ShowWindow (hwnd, iCmdShow); - UpdateWindow (hwnd); - - hAccel = LoadAccelerators (hInstance, szProgName); - - while (GetMessage (&msg, NULL, 0, 0)) - { - if (!TranslateAccelerator (hwnd, hAccel, &msg)) - { - TranslateMessage (&msg); - DispatchMessage (&msg); - } - } - return msg.wParam; -} - -LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, - LPARAM lParam) -{ - static HINSTANCE hInstance ; - static HDC hdc; - static PAINTSTRUCT ps; - static HMENU hMenu; - - static BITMAPFILEHEADER *pbmfh; - static BITMAPINFOHEADER *pbmih; - static BYTE *pbImage; - static int cxWinSize, cyWinSize; - static int cxImgSize, cyImgSize; - static int cImgChannels; - static png_color bkgColor = {127, 127, 127}; - - static BOOL bStretched = TRUE; - - static BYTE *pDib = NULL; - static BYTE *pDiData = NULL; - - static TCHAR szImgPathName [MAX_PATH]; - static TCHAR szTitleName [MAX_PATH]; - - static TCHAR *pPngFileList = NULL; - static int iPngFileCount; - static int iPngFileIndex; - - BOOL bOk; - - switch (message) - { - case WM_CREATE: - hInstance = ((LPCREATESTRUCT) lParam)->hInstance ; - PngFileInitialize (hwnd); - - strcpy (szImgPathName, ""); - - // in case we process file given on command-line - - if (szCmdFileName[0] != '\0') - { - strcpy (szImgPathName, szCmdFileName); - - // read the other png-files in the directory for later - // next/previous commands - - BuildPngList (szImgPathName, &pPngFileList, &iPngFileCount, - &iPngFileIndex); - - // load the image from file - - if (!LoadImageFile (hwnd, szImgPathName, - &pbImage, &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor)) - return 0; - - // invalidate the client area for later update - - InvalidateRect (hwnd, NULL, TRUE); - - // display the PNG into the DIBitmap - - DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, - pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); - } - - return 0; - - case WM_SIZE: - cxWinSize = LOWORD (lParam); - cyWinSize = HIWORD (lParam); - - // invalidate the client area for later update - - InvalidateRect (hwnd, NULL, TRUE); - - // display the PNG into the DIBitmap - - DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, - pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); - - return 0; - - case WM_INITMENUPOPUP: - hMenu = GetMenu (hwnd); - - if (pbImage) - EnableMenuItem (hMenu, IDM_FILE_SAVE, MF_ENABLED); - else - EnableMenuItem (hMenu, IDM_FILE_SAVE, MF_GRAYED); - - return 0; - - case WM_COMMAND: - hMenu = GetMenu (hwnd); - - switch (LOWORD (wParam)) - { - case IDM_FILE_OPEN: - - // show the File Open dialog box - - if (!PngFileOpenDlg (hwnd, szImgPathName, szTitleName)) - return 0; - - // read the other png-files in the directory for later - // next/previous commands - - BuildPngList (szImgPathName, &pPngFileList, &iPngFileCount, - &iPngFileIndex); - - // load the image from file - - if (!LoadImageFile (hwnd, szImgPathName, - &pbImage, &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor)) - return 0; - - // invalidate the client area for later update - - InvalidateRect (hwnd, NULL, TRUE); - - // display the PNG into the DIBitmap - - DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, - pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); - - return 0; - - case IDM_FILE_SAVE: - - // show the File Save dialog box - - if (!PngFileSaveDlg (hwnd, szImgPathName, szTitleName)) - return 0; - - // save the PNG to a disk file - - SetCursor (LoadCursor (NULL, IDC_WAIT)); - ShowCursor (TRUE); - - bOk = PngSaveImage (szImgPathName, pDiData, cxWinSize, cyWinSize, - bkgColor); - - ShowCursor (FALSE); - SetCursor (LoadCursor (NULL, IDC_ARROW)); - - if (!bOk) - MessageBox (hwnd, TEXT ("Error in saving the PNG image"), - szProgName, MB_ICONEXCLAMATION | MB_OK); - return 0; - - case IDM_FILE_NEXT: - - // read next entry in the directory - - if (SearchPngList (pPngFileList, iPngFileCount, &iPngFileIndex, - NULL, szImgPathName)) - { - if (strcmp (szImgPathName, "") == 0) - return 0; - - // load the image from file - - if (!LoadImageFile (hwnd, szImgPathName, &pbImage, - &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor)) - return 0; - - // invalidate the client area for later update - - InvalidateRect (hwnd, NULL, TRUE); - - // display the PNG into the DIBitmap - - DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, - pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); - } - - return 0; - - case IDM_FILE_PREVIOUS: - - // read previous entry in the directory - - if (SearchPngList (pPngFileList, iPngFileCount, &iPngFileIndex, - szImgPathName, NULL)) - { - - if (strcmp (szImgPathName, "") == 0) - return 0; - - // load the image from file - - if (!LoadImageFile (hwnd, szImgPathName, &pbImage, &cxImgSize, - &cyImgSize, &cImgChannels, &bkgColor)) - return 0; - - // invalidate the client area for later update - - InvalidateRect (hwnd, NULL, TRUE); - - // display the PNG into the DIBitmap - - DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, - pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); - } - - return 0; - - case IDM_FILE_EXIT: - - // more cleanup needed... - - // free image buffer - - if (pDib != NULL) - { - free (pDib); - pDib = NULL; - } - - // free file-list - - if (pPngFileList != NULL) - { - free (pPngFileList); - pPngFileList = NULL; - } - - // let's go ... - - exit (0); - - return 0; - - case IDM_OPTIONS_STRETCH: - bStretched = !bStretched; - if (bStretched) - CheckMenuItem (hMenu, IDM_OPTIONS_STRETCH, MF_CHECKED); - else - CheckMenuItem (hMenu, IDM_OPTIONS_STRETCH, MF_UNCHECKED); - - // invalidate the client area for later update - - InvalidateRect (hwnd, NULL, TRUE); - - // display the PNG into the DIBitmap - - DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, - pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); - - return 0; - - case IDM_HELP_ABOUT: - DialogBox (hInstance, TEXT ("AboutBox"), hwnd, AboutDlgProc) ; - return 0; - - } // end switch - - break; - - case WM_PAINT: - hdc = BeginPaint (hwnd, &ps); - - if (pDib) - SetDIBitsToDevice (hdc, 0, 0, cxWinSize, cyWinSize, 0, 0, - 0, cyWinSize, pDiData, (BITMAPINFO *) pDib, DIB_RGB_COLORS); - - EndPaint (hwnd, &ps); - return 0; - - case WM_DESTROY: - if (pbmfh) - { - free (pbmfh); - pbmfh = NULL; - } - - PostQuitMessage (0); - return 0; - } - - return DefWindowProc (hwnd, message, wParam, lParam); -} - -BOOL CALLBACK AboutDlgProc (HWND hDlg, UINT message, - WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG : - ShowWindow (hDlg, SW_HIDE); - CenterAbout (hDlg, GetWindow (hDlg, GW_OWNER)); - ShowWindow (hDlg, SW_SHOW); - return TRUE ; - - case WM_COMMAND : - switch (LOWORD (wParam)) - { - case IDOK : - case IDCANCEL : - EndDialog (hDlg, 0) ; - return TRUE ; - } - break ; - } - return FALSE ; -} - -//--------------- -// CenterAbout -//--------------- - -BOOL CenterAbout (HWND hwndChild, HWND hwndParent) -{ - RECT rChild, rParent, rWorkArea; - int wChild, hChild, wParent, hParent; - int xNew, yNew; - BOOL bResult; - - // Get the Height and Width of the child window - GetWindowRect (hwndChild, &rChild); - wChild = rChild.right - rChild.left; - hChild = rChild.bottom - rChild.top; - - // Get the Height and Width of the parent window - GetWindowRect (hwndParent, &rParent); - wParent = rParent.right - rParent.left; - hParent = rParent.bottom - rParent.top; - - // Get the limits of the 'workarea' - bResult = SystemParametersInfo( - SPI_GETWORKAREA, // system parameter to query or set - sizeof(RECT), - &rWorkArea, - 0); - if (!bResult) { - rWorkArea.left = rWorkArea.top = 0; - rWorkArea.right = GetSystemMetrics(SM_CXSCREEN); - rWorkArea.bottom = GetSystemMetrics(SM_CYSCREEN); - } - - // Calculate new X position, then adjust for workarea - xNew = rParent.left + ((wParent - wChild) /2); - if (xNew < rWorkArea.left) { - xNew = rWorkArea.left; - } else if ((xNew+wChild) > rWorkArea.right) { - xNew = rWorkArea.right - wChild; - } - - // Calculate new Y position, then adjust for workarea - yNew = rParent.top + ((hParent - hChild) /2); - if (yNew < rWorkArea.top) { - yNew = rWorkArea.top; - } else if ((yNew+hChild) > rWorkArea.bottom) { - yNew = rWorkArea.bottom - hChild; - } - - // Set it, and return - return SetWindowPos (hwndChild, NULL, xNew, yNew, 0, 0, SWP_NOSIZE | - SWP_NOZORDER); -} - -//---------------- -// BuildPngList -//---------------- - -BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount, - int *pFileIndex) -{ - static TCHAR szImgPathName [MAX_PATH]; - static TCHAR szImgFileName [MAX_PATH]; - static TCHAR szImgFindName [MAX_PATH]; - - WIN32_FIND_DATA finddata; - HANDLE hFind; - - static TCHAR szTmp [MAX_PATH]; - BOOL bOk; - int i, ii; - int j, jj; - - // free previous file-list - - if (*ppFileList != NULL) - { - free (*ppFileList); - *ppFileList = NULL; - } - - // extract foldername, filename and search-name - - strcpy (szImgPathName, pstrPathName); - strcpy (szImgFileName, strrchr (pstrPathName, '\\') + 1); - - strcpy (szImgFindName, szImgPathName); - *(strrchr (szImgFindName, '\\') + 1) = '\0'; - strcat (szImgFindName, "*.png"); - - // first cycle: count number of files in directory for memory allocation - - *pFileCount = 0; - - hFind = FindFirstFile(szImgFindName, &finddata); - bOk = (hFind != (HANDLE) -1); - - while (bOk) - { - *pFileCount += 1; - bOk = FindNextFile(hFind, &finddata); - } - FindClose(hFind); - - // allocation memory for file-list - - *ppFileList = (TCHAR *) malloc (*pFileCount * MAX_PATH); - - // second cycle: read directory and store filenames in file-list - - hFind = FindFirstFile(szImgFindName, &finddata); - bOk = (hFind != (HANDLE) -1); - - i = 0; - ii = 0; - while (bOk) - { - strcpy (*ppFileList + ii, szImgPathName); - strcpy (strrchr(*ppFileList + ii, '\\') + 1, finddata.cFileName); - - if (strcmp(pstrPathName, *ppFileList + ii) == 0) - *pFileIndex = i; - - ii += MAX_PATH; - i++; - - bOk = FindNextFile(hFind, &finddata); - } - FindClose(hFind); - - // finally we must sort the file-list - - for (i = 0; i < *pFileCount - 1; i++) - { - ii = i * MAX_PATH; - for (j = i+1; j < *pFileCount; j++) - { - jj = j * MAX_PATH; - if (strcmp (*ppFileList + ii, *ppFileList + jj) > 0) - { - strcpy (szTmp, *ppFileList + jj); - strcpy (*ppFileList + jj, *ppFileList + ii); - strcpy (*ppFileList + ii, szTmp); - - // check if this was the current image that we moved - - if (*pFileIndex == i) - *pFileIndex = j; - else - if (*pFileIndex == j) - *pFileIndex = i; - } - } - } - - return TRUE; -} - -//---------------- -// SearchPngList -//---------------- - -BOOL SearchPngList ( - TCHAR *pFileList, int FileCount, int *pFileIndex, - PTSTR pstrPrevName, PTSTR pstrNextName) -{ - if (FileCount > 0) - { - // get previous entry - - if (pstrPrevName != NULL) - { - if (*pFileIndex > 0) - *pFileIndex -= 1; - else - *pFileIndex = FileCount - 1; - - strcpy (pstrPrevName, pFileList + (*pFileIndex * MAX_PATH)); - } - - // get next entry - - if (pstrNextName != NULL) - { - if (*pFileIndex < FileCount - 1) - *pFileIndex += 1; - else - *pFileIndex = 0; - - strcpy (pstrNextName, pFileList + (*pFileIndex * MAX_PATH)); - } - - return TRUE; - } - else - { - return FALSE; - } -} - -//----------------- -// LoadImageFile -//----------------- - -BOOL LoadImageFile (HWND hwnd, PTSTR pstrPathName, - png_byte **ppbImage, int *pxImgSize, int *pyImgSize, - int *piChannels, png_color *pBkgColor) -{ - static TCHAR szTmp [MAX_PATH]; - - // if there's an existing PNG, free the memory - - if (*ppbImage) - { - free (*ppbImage); - *ppbImage = NULL; - } - - // Load the entire PNG into memory - - SetCursor (LoadCursor (NULL, IDC_WAIT)); - ShowCursor (TRUE); - - PngLoadImage (pstrPathName, ppbImage, pxImgSize, pyImgSize, piChannels, - pBkgColor); - - ShowCursor (FALSE); - SetCursor (LoadCursor (NULL, IDC_ARROW)); - - if (*ppbImage != NULL) - { - sprintf (szTmp, "VisualPng - %s", strrchr(pstrPathName, '\\') + 1); - SetWindowText (hwnd, szTmp); - } - else - { - MessageBox (hwnd, TEXT ("Error in loading the PNG image"), - szProgName, MB_ICONEXCLAMATION | MB_OK); - return FALSE; - } - - return TRUE; -} - -//---------------- -// DisplayImage -//---------------- - -BOOL DisplayImage (HWND hwnd, BYTE **ppDib, - BYTE **ppDiData, int cxWinSize, int cyWinSize, - BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, - BOOL bStretched) -{ - BYTE *pDib = *ppDib; - BYTE *pDiData = *ppDiData; - // BITMAPFILEHEADER *pbmfh; - BITMAPINFOHEADER *pbmih; - WORD wDIRowBytes; - png_color bkgBlack = {0, 0, 0}; - png_color bkgGray = {127, 127, 127}; - png_color bkgWhite = {255, 255, 255}; - - // allocate memory for the Device Independant bitmap - - wDIRowBytes = (WORD) ((3 * cxWinSize + 3L) >> 2) << 2; - - if (pDib) - { - free (pDib); - pDib = NULL; - } - - if (!(pDib = (BYTE *) malloc (sizeof(BITMAPINFOHEADER) + - wDIRowBytes * cyWinSize))) - { - MessageBox (hwnd, TEXT ("Error in displaying the PNG image"), - szProgName, MB_ICONEXCLAMATION | MB_OK); - *ppDib = pDib = NULL; - return FALSE; - } - *ppDib = pDib; - memset (pDib, 0, sizeof(BITMAPINFOHEADER)); - - // initialize the dib-structure - - pbmih = (BITMAPINFOHEADER *) pDib; - pbmih->biSize = sizeof(BITMAPINFOHEADER); - pbmih->biWidth = cxWinSize; - pbmih->biHeight = -((long) cyWinSize); - pbmih->biPlanes = 1; - pbmih->biBitCount = 24; - pbmih->biCompression = 0; - pDiData = pDib + sizeof(BITMAPINFOHEADER); - *ppDiData = pDiData; - - // first fill bitmap with gray and image border - - InitBitmap (pDiData, cxWinSize, cyWinSize); - - // then fill bitmap with image - - if (pbImage) - { - FillBitmap ( - pDiData, cxWinSize, cyWinSize, - pbImage, cxImgSize, cyImgSize, cImgChannels, - bStretched); - } - - return TRUE; -} - -//-------------- -// InitBitmap -//-------------- - -BOOL InitBitmap (BYTE *pDiData, int cxWinSize, int cyWinSize) -{ - BYTE *dst; - int x, y, col; - - // initialize the background with gray - - dst = pDiData; - for (y = 0; y < cyWinSize; y++) - { - col = 0; - for (x = 0; x < cxWinSize; x++) - { - // fill with GRAY - *dst++ = 127; - *dst++ = 127; - *dst++ = 127; - col += 3; - } - // rows start on 4 byte boundaries - while ((col % 4) != 0) - { - dst++; - col++; - } - } - - return TRUE; -} - -//-------------- -// FillBitmap -//-------------- - -BOOL FillBitmap ( - BYTE *pDiData, int cxWinSize, int cyWinSize, - BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, - BOOL bStretched) -{ - BYTE *pStretchedImage; - BYTE *pImg; - BYTE *src, *dst; - BYTE r, g, b, a; - const int cDIChannels = 3; - WORD wImgRowBytes; - WORD wDIRowBytes; - int cxNewSize, cyNewSize; - int cxImgPos, cyImgPos; - int xImg, yImg; - int xWin, yWin; - int xOld, yOld; - int xNew, yNew; - - if (bStretched) - { - cxNewSize = cxWinSize - 2 * MARGIN; - cyNewSize = cyWinSize - 2 * MARGIN; - - // stretch the image to it's window determined size - - // the following two are the same, but the first has side-effects - // because of rounding -// if ((cyNewSize / cxNewSize) > (cyImgSize / cxImgSize)) - if ((cyNewSize * cxImgSize) > (cyImgSize * cxNewSize)) - { - cyNewSize = cxNewSize * cyImgSize / cxImgSize; - cxImgPos = MARGIN; - cyImgPos = (cyWinSize - cyNewSize) / 2; - } - else - { - cxNewSize = cyNewSize * cxImgSize / cyImgSize; - cyImgPos = MARGIN; - cxImgPos = (cxWinSize - cxNewSize) / 2; - } - - pStretchedImage = malloc (cImgChannels * cxNewSize * cyNewSize); - pImg = pStretchedImage; - - for (yNew = 0; yNew < cyNewSize; yNew++) - { - yOld = yNew * cyImgSize / cyNewSize; - for (xNew = 0; xNew < cxNewSize; xNew++) - { - xOld = xNew * cxImgSize / cxNewSize; - - r = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 0); - g = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 1); - b = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 2); - *pImg++ = r; - *pImg++ = g; - *pImg++ = b; - if (cImgChannels == 4) - { - a = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) - + 3); - *pImg++ = a; - } - } - } - - // calculate row-bytes - - wImgRowBytes = cImgChannels * cxNewSize; - wDIRowBytes = (WORD) ((cDIChannels * cxWinSize + 3L) >> 2) << 2; - - // copy image to screen - - for (yImg = 0, yWin = cyImgPos; yImg < cyNewSize; yImg++, yWin++) - { - if (yWin >= cyWinSize - cyImgPos) - break; - src = pStretchedImage + yImg * wImgRowBytes; - dst = pDiData + yWin * wDIRowBytes + cxImgPos * cDIChannels; - - for (xImg = 0, xWin = cxImgPos; xImg < cxNewSize; xImg++, xWin++) - { - if (xWin >= cxWinSize - cxImgPos) - break; - r = *src++; - g = *src++; - b = *src++; - *dst++ = b; /* note the reverse order */ - *dst++ = g; - *dst++ = r; - if (cImgChannels == 4) - { - a = *src++; - } - } - } - - // free memory - - if (pStretchedImage != NULL) - { - free (pStretchedImage); - pStretchedImage = NULL; - } - - } - - // process the image not-stretched - - else - { - // calculate the central position - - cxImgPos = (cxWinSize - cxImgSize) / 2; - cyImgPos = (cyWinSize - cyImgSize) / 2; - - // check for image larger than window - - if (cxImgPos < MARGIN) - cxImgPos = MARGIN; - if (cyImgPos < MARGIN) - cyImgPos = MARGIN; - - // calculate both row-bytes - - wImgRowBytes = cImgChannels * cxImgSize; - wDIRowBytes = (WORD) ((cDIChannels * cxWinSize + 3L) >> 2) << 2; - - // copy image to screen - - for (yImg = 0, yWin = cyImgPos; yImg < cyImgSize; yImg++, yWin++) - { - if (yWin >= cyWinSize - MARGIN) - break; - src = pbImage + yImg * wImgRowBytes; - dst = pDiData + yWin * wDIRowBytes + cxImgPos * cDIChannels; - - for (xImg = 0, xWin = cxImgPos; xImg < cxImgSize; xImg++, xWin++) - { - if (xWin >= cxWinSize - MARGIN) - break; - r = *src++; - g = *src++; - b = *src++; - *dst++ = b; /* note the reverse order */ - *dst++ = g; - *dst++ = r; - if (cImgChannels == 4) - { - a = *src++; - } - } - } - } - - return TRUE; -} - -//----------------- -// end of source -//----------------- +//------------------------------------ +// VisualPng.C -- Shows a PNG image +//------------------------------------ + +// Copyright 2000, Willem van Schaik. For conditions of distribution and +// use, see the copyright/license/disclaimer notice in png.h + +// switches + +// defines + +#define PROGNAME "VisualPng" +#define LONGNAME "Win32 Viewer for PNG-files" +#define VERSION "1.0 of 2000 June 07" + +// constants + +#define MARGIN 8 + +// standard includes + +#include +#include +#include +#include + +// application includes + +#include "png.h" +#include "pngfile.h" +#include "resource.h" + +// macros + +// function prototypes + +LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); +BOOL CALLBACK AboutDlgProc (HWND, UINT, WPARAM, LPARAM) ; + +BOOL CenterAbout (HWND hwndChild, HWND hwndParent); + +BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount, + int *pFileIndex); + +BOOL SearchPngList (TCHAR *pFileList, int FileCount, int *pFileIndex, + PTSTR pstrPrevName, PTSTR pstrNextName); + +BOOL LoadImageFile(HWND hwnd, PTSTR pstrPathName, + png_byte **ppbImage, int *pxImgSize, int *pyImgSize, int *piChannels, + png_color *pBkgColor); + +BOOL DisplayImage (HWND hwnd, BYTE **ppDib, + BYTE **ppDiData, int cxWinSize, int cyWinSize, + BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, + BOOL bStretched); + +BOOL InitBitmap ( + BYTE *pDiData, int cxWinSize, int cyWinSize); + +BOOL FillBitmap ( + BYTE *pDiData, int cxWinSize, int cyWinSize, + BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, + BOOL bStretched); + +// a few global variables + +static char *szProgName = PROGNAME; +static char *szAppName = LONGNAME; +static char *szIconName = PROGNAME; +static char szCmdFileName [MAX_PATH]; + +// MAIN routine + +int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, + PSTR szCmdLine, int iCmdShow) +{ + HACCEL hAccel; + HWND hwnd; + MSG msg; + WNDCLASS wndclass; + int ixBorders, iyBorders; + + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = WndProc; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = 0; + wndclass.hInstance = hInstance; + wndclass.hIcon = LoadIcon (hInstance, szIconName) ; + wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); + wndclass.hbrBackground = NULL; // (HBRUSH) GetStockObject (GRAY_BRUSH); + wndclass.lpszMenuName = szProgName; + wndclass.lpszClassName = szProgName; + + if (!RegisterClass (&wndclass)) + { + MessageBox (NULL, TEXT ("Error: this program requires Windows NT!"), + szProgName, MB_ICONERROR); + return 0; + } + + // if filename given on commandline, store it + if ((szCmdLine != NULL) && (*szCmdLine != '\0')) + if (szCmdLine[0] == '"') + strncpy (szCmdFileName, szCmdLine + 1, strlen(szCmdLine) - 2); + else + strcpy (szCmdFileName, szCmdLine); + else + strcpy (szCmdFileName, ""); + + // calculate size of window-borders + ixBorders = 2 * (GetSystemMetrics (SM_CXBORDER) + + GetSystemMetrics (SM_CXDLGFRAME)); + iyBorders = 2 * (GetSystemMetrics (SM_CYBORDER) + + GetSystemMetrics (SM_CYDLGFRAME)) + + GetSystemMetrics (SM_CYCAPTION) + + GetSystemMetrics (SM_CYMENUSIZE) + + 1; /* WvS: don't ask me why? */ + + hwnd = CreateWindow (szProgName, szAppName, + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, + 512 + 2 * MARGIN + ixBorders, 384 + 2 * MARGIN + iyBorders, +// CW_USEDEFAULT, CW_USEDEFAULT, + NULL, NULL, hInstance, NULL); + + ShowWindow (hwnd, iCmdShow); + UpdateWindow (hwnd); + + hAccel = LoadAccelerators (hInstance, szProgName); + + while (GetMessage (&msg, NULL, 0, 0)) + { + if (!TranslateAccelerator (hwnd, hAccel, &msg)) + { + TranslateMessage (&msg); + DispatchMessage (&msg); + } + } + return msg.wParam; +} + +LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, + LPARAM lParam) +{ + static HINSTANCE hInstance ; + static HDC hdc; + static PAINTSTRUCT ps; + static HMENU hMenu; + + static BITMAPFILEHEADER *pbmfh; + static BITMAPINFOHEADER *pbmih; + static BYTE *pbImage; + static int cxWinSize, cyWinSize; + static int cxImgSize, cyImgSize; + static int cImgChannels; + static png_color bkgColor = {127, 127, 127}; + + static BOOL bStretched = TRUE; + + static BYTE *pDib = NULL; + static BYTE *pDiData = NULL; + + static TCHAR szImgPathName [MAX_PATH]; + static TCHAR szTitleName [MAX_PATH]; + + static TCHAR *pPngFileList = NULL; + static int iPngFileCount; + static int iPngFileIndex; + + BOOL bOk; + + switch (message) + { + case WM_CREATE: + hInstance = ((LPCREATESTRUCT) lParam)->hInstance ; + PngFileInitialize (hwnd); + + strcpy (szImgPathName, ""); + + // in case we process file given on command-line + + if (szCmdFileName[0] != '\0') + { + strcpy (szImgPathName, szCmdFileName); + + // read the other png-files in the directory for later + // next/previous commands + + BuildPngList (szImgPathName, &pPngFileList, &iPngFileCount, + &iPngFileIndex); + + // load the image from file + + if (!LoadImageFile (hwnd, szImgPathName, + &pbImage, &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor)) + return 0; + + // invalidate the client area for later update + + InvalidateRect (hwnd, NULL, TRUE); + + // display the PNG into the DIBitmap + + DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, + pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); + } + + return 0; + + case WM_SIZE: + cxWinSize = LOWORD (lParam); + cyWinSize = HIWORD (lParam); + + // invalidate the client area for later update + + InvalidateRect (hwnd, NULL, TRUE); + + // display the PNG into the DIBitmap + + DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, + pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); + + return 0; + + case WM_INITMENUPOPUP: + hMenu = GetMenu (hwnd); + + if (pbImage) + EnableMenuItem (hMenu, IDM_FILE_SAVE, MF_ENABLED); + else + EnableMenuItem (hMenu, IDM_FILE_SAVE, MF_GRAYED); + + return 0; + + case WM_COMMAND: + hMenu = GetMenu (hwnd); + + switch (LOWORD (wParam)) + { + case IDM_FILE_OPEN: + + // show the File Open dialog box + + if (!PngFileOpenDlg (hwnd, szImgPathName, szTitleName)) + return 0; + + // read the other png-files in the directory for later + // next/previous commands + + BuildPngList (szImgPathName, &pPngFileList, &iPngFileCount, + &iPngFileIndex); + + // load the image from file + + if (!LoadImageFile (hwnd, szImgPathName, + &pbImage, &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor)) + return 0; + + // invalidate the client area for later update + + InvalidateRect (hwnd, NULL, TRUE); + + // display the PNG into the DIBitmap + + DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, + pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); + + return 0; + + case IDM_FILE_SAVE: + + // show the File Save dialog box + + if (!PngFileSaveDlg (hwnd, szImgPathName, szTitleName)) + return 0; + + // save the PNG to a disk file + + SetCursor (LoadCursor (NULL, IDC_WAIT)); + ShowCursor (TRUE); + + bOk = PngSaveImage (szImgPathName, pDiData, cxWinSize, cyWinSize, + bkgColor); + + ShowCursor (FALSE); + SetCursor (LoadCursor (NULL, IDC_ARROW)); + + if (!bOk) + MessageBox (hwnd, TEXT ("Error in saving the PNG image"), + szProgName, MB_ICONEXCLAMATION | MB_OK); + return 0; + + case IDM_FILE_NEXT: + + // read next entry in the directory + + if (SearchPngList (pPngFileList, iPngFileCount, &iPngFileIndex, + NULL, szImgPathName)) + { + if (strcmp (szImgPathName, "") == 0) + return 0; + + // load the image from file + + if (!LoadImageFile (hwnd, szImgPathName, &pbImage, + &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor)) + return 0; + + // invalidate the client area for later update + + InvalidateRect (hwnd, NULL, TRUE); + + // display the PNG into the DIBitmap + + DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, + pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); + } + + return 0; + + case IDM_FILE_PREVIOUS: + + // read previous entry in the directory + + if (SearchPngList (pPngFileList, iPngFileCount, &iPngFileIndex, + szImgPathName, NULL)) + { + + if (strcmp (szImgPathName, "") == 0) + return 0; + + // load the image from file + + if (!LoadImageFile (hwnd, szImgPathName, &pbImage, &cxImgSize, + &cyImgSize, &cImgChannels, &bkgColor)) + return 0; + + // invalidate the client area for later update + + InvalidateRect (hwnd, NULL, TRUE); + + // display the PNG into the DIBitmap + + DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, + pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); + } + + return 0; + + case IDM_FILE_EXIT: + + // more cleanup needed... + + // free image buffer + + if (pDib != NULL) + { + free (pDib); + pDib = NULL; + } + + // free file-list + + if (pPngFileList != NULL) + { + free (pPngFileList); + pPngFileList = NULL; + } + + // let's go ... + + exit (0); + + return 0; + + case IDM_OPTIONS_STRETCH: + bStretched = !bStretched; + if (bStretched) + CheckMenuItem (hMenu, IDM_OPTIONS_STRETCH, MF_CHECKED); + else + CheckMenuItem (hMenu, IDM_OPTIONS_STRETCH, MF_UNCHECKED); + + // invalidate the client area for later update + + InvalidateRect (hwnd, NULL, TRUE); + + // display the PNG into the DIBitmap + + DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, + pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); + + return 0; + + case IDM_HELP_ABOUT: + DialogBox (hInstance, TEXT ("AboutBox"), hwnd, AboutDlgProc) ; + return 0; + + } // end switch + + break; + + case WM_PAINT: + hdc = BeginPaint (hwnd, &ps); + + if (pDib) + SetDIBitsToDevice (hdc, 0, 0, cxWinSize, cyWinSize, 0, 0, + 0, cyWinSize, pDiData, (BITMAPINFO *) pDib, DIB_RGB_COLORS); + + EndPaint (hwnd, &ps); + return 0; + + case WM_DESTROY: + if (pbmfh) + { + free (pbmfh); + pbmfh = NULL; + } + + PostQuitMessage (0); + return 0; + } + + return DefWindowProc (hwnd, message, wParam, lParam); +} + +BOOL CALLBACK AboutDlgProc (HWND hDlg, UINT message, + WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_INITDIALOG : + ShowWindow (hDlg, SW_HIDE); + CenterAbout (hDlg, GetWindow (hDlg, GW_OWNER)); + ShowWindow (hDlg, SW_SHOW); + return TRUE ; + + case WM_COMMAND : + switch (LOWORD (wParam)) + { + case IDOK : + case IDCANCEL : + EndDialog (hDlg, 0) ; + return TRUE ; + } + break ; + } + return FALSE ; +} + +//--------------- +// CenterAbout +//--------------- + +BOOL CenterAbout (HWND hwndChild, HWND hwndParent) +{ + RECT rChild, rParent, rWorkArea; + int wChild, hChild, wParent, hParent; + int xNew, yNew; + BOOL bResult; + + // Get the Height and Width of the child window + GetWindowRect (hwndChild, &rChild); + wChild = rChild.right - rChild.left; + hChild = rChild.bottom - rChild.top; + + // Get the Height and Width of the parent window + GetWindowRect (hwndParent, &rParent); + wParent = rParent.right - rParent.left; + hParent = rParent.bottom - rParent.top; + + // Get the limits of the 'workarea' + bResult = SystemParametersInfo( + SPI_GETWORKAREA, // system parameter to query or set + sizeof(RECT), + &rWorkArea, + 0); + if (!bResult) { + rWorkArea.left = rWorkArea.top = 0; + rWorkArea.right = GetSystemMetrics(SM_CXSCREEN); + rWorkArea.bottom = GetSystemMetrics(SM_CYSCREEN); + } + + // Calculate new X position, then adjust for workarea + xNew = rParent.left + ((wParent - wChild) /2); + if (xNew < rWorkArea.left) { + xNew = rWorkArea.left; + } else if ((xNew+wChild) > rWorkArea.right) { + xNew = rWorkArea.right - wChild; + } + + // Calculate new Y position, then adjust for workarea + yNew = rParent.top + ((hParent - hChild) /2); + if (yNew < rWorkArea.top) { + yNew = rWorkArea.top; + } else if ((yNew+hChild) > rWorkArea.bottom) { + yNew = rWorkArea.bottom - hChild; + } + + // Set it, and return + return SetWindowPos (hwndChild, NULL, xNew, yNew, 0, 0, SWP_NOSIZE | + SWP_NOZORDER); +} + +//---------------- +// BuildPngList +//---------------- + +BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount, + int *pFileIndex) +{ + static TCHAR szImgPathName [MAX_PATH]; + static TCHAR szImgFileName [MAX_PATH]; + static TCHAR szImgFindName [MAX_PATH]; + + WIN32_FIND_DATA finddata; + HANDLE hFind; + + static TCHAR szTmp [MAX_PATH]; + BOOL bOk; + int i, ii; + int j, jj; + + // free previous file-list + + if (*ppFileList != NULL) + { + free (*ppFileList); + *ppFileList = NULL; + } + + // extract foldername, filename and search-name + + strcpy (szImgPathName, pstrPathName); + strcpy (szImgFileName, strrchr (pstrPathName, '\\') + 1); + + strcpy (szImgFindName, szImgPathName); + *(strrchr (szImgFindName, '\\') + 1) = '\0'; + strcat (szImgFindName, "*.png"); + + // first cycle: count number of files in directory for memory allocation + + *pFileCount = 0; + + hFind = FindFirstFile(szImgFindName, &finddata); + bOk = (hFind != (HANDLE) -1); + + while (bOk) + { + *pFileCount += 1; + bOk = FindNextFile(hFind, &finddata); + } + FindClose(hFind); + + // allocation memory for file-list + + *ppFileList = (TCHAR *) malloc (*pFileCount * MAX_PATH); + + // second cycle: read directory and store filenames in file-list + + hFind = FindFirstFile(szImgFindName, &finddata); + bOk = (hFind != (HANDLE) -1); + + i = 0; + ii = 0; + while (bOk) + { + strcpy (*ppFileList + ii, szImgPathName); + strcpy (strrchr(*ppFileList + ii, '\\') + 1, finddata.cFileName); + + if (strcmp(pstrPathName, *ppFileList + ii) == 0) + *pFileIndex = i; + + ii += MAX_PATH; + i++; + + bOk = FindNextFile(hFind, &finddata); + } + FindClose(hFind); + + // finally we must sort the file-list + + for (i = 0; i < *pFileCount - 1; i++) + { + ii = i * MAX_PATH; + for (j = i+1; j < *pFileCount; j++) + { + jj = j * MAX_PATH; + if (strcmp (*ppFileList + ii, *ppFileList + jj) > 0) + { + strcpy (szTmp, *ppFileList + jj); + strcpy (*ppFileList + jj, *ppFileList + ii); + strcpy (*ppFileList + ii, szTmp); + + // check if this was the current image that we moved + + if (*pFileIndex == i) + *pFileIndex = j; + else + if (*pFileIndex == j) + *pFileIndex = i; + } + } + } + + return TRUE; +} + +//---------------- +// SearchPngList +//---------------- + +BOOL SearchPngList ( + TCHAR *pFileList, int FileCount, int *pFileIndex, + PTSTR pstrPrevName, PTSTR pstrNextName) +{ + if (FileCount > 0) + { + // get previous entry + + if (pstrPrevName != NULL) + { + if (*pFileIndex > 0) + *pFileIndex -= 1; + else + *pFileIndex = FileCount - 1; + + strcpy (pstrPrevName, pFileList + (*pFileIndex * MAX_PATH)); + } + + // get next entry + + if (pstrNextName != NULL) + { + if (*pFileIndex < FileCount - 1) + *pFileIndex += 1; + else + *pFileIndex = 0; + + strcpy (pstrNextName, pFileList + (*pFileIndex * MAX_PATH)); + } + + return TRUE; + } + else + { + return FALSE; + } +} + +//----------------- +// LoadImageFile +//----------------- + +BOOL LoadImageFile (HWND hwnd, PTSTR pstrPathName, + png_byte **ppbImage, int *pxImgSize, int *pyImgSize, + int *piChannels, png_color *pBkgColor) +{ + static TCHAR szTmp [MAX_PATH]; + + // if there's an existing PNG, free the memory + + if (*ppbImage) + { + free (*ppbImage); + *ppbImage = NULL; + } + + // Load the entire PNG into memory + + SetCursor (LoadCursor (NULL, IDC_WAIT)); + ShowCursor (TRUE); + + PngLoadImage (pstrPathName, ppbImage, pxImgSize, pyImgSize, piChannels, + pBkgColor); + + ShowCursor (FALSE); + SetCursor (LoadCursor (NULL, IDC_ARROW)); + + if (*ppbImage != NULL) + { + sprintf (szTmp, "VisualPng - %s", strrchr(pstrPathName, '\\') + 1); + SetWindowText (hwnd, szTmp); + } + else + { + MessageBox (hwnd, TEXT ("Error in loading the PNG image"), + szProgName, MB_ICONEXCLAMATION | MB_OK); + return FALSE; + } + + return TRUE; +} + +//---------------- +// DisplayImage +//---------------- + +BOOL DisplayImage (HWND hwnd, BYTE **ppDib, + BYTE **ppDiData, int cxWinSize, int cyWinSize, + BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, + BOOL bStretched) +{ + BYTE *pDib = *ppDib; + BYTE *pDiData = *ppDiData; + // BITMAPFILEHEADER *pbmfh; + BITMAPINFOHEADER *pbmih; + WORD wDIRowBytes; + png_color bkgBlack = {0, 0, 0}; + png_color bkgGray = {127, 127, 127}; + png_color bkgWhite = {255, 255, 255}; + + // allocate memory for the Device Independant bitmap + + wDIRowBytes = (WORD) ((3 * cxWinSize + 3L) >> 2) << 2; + + if (pDib) + { + free (pDib); + pDib = NULL; + } + + if (!(pDib = (BYTE *) malloc (sizeof(BITMAPINFOHEADER) + + wDIRowBytes * cyWinSize))) + { + MessageBox (hwnd, TEXT ("Error in displaying the PNG image"), + szProgName, MB_ICONEXCLAMATION | MB_OK); + *ppDib = pDib = NULL; + return FALSE; + } + *ppDib = pDib; + memset (pDib, 0, sizeof(BITMAPINFOHEADER)); + + // initialize the dib-structure + + pbmih = (BITMAPINFOHEADER *) pDib; + pbmih->biSize = sizeof(BITMAPINFOHEADER); + pbmih->biWidth = cxWinSize; + pbmih->biHeight = -((long) cyWinSize); + pbmih->biPlanes = 1; + pbmih->biBitCount = 24; + pbmih->biCompression = 0; + pDiData = pDib + sizeof(BITMAPINFOHEADER); + *ppDiData = pDiData; + + // first fill bitmap with gray and image border + + InitBitmap (pDiData, cxWinSize, cyWinSize); + + // then fill bitmap with image + + if (pbImage) + { + FillBitmap ( + pDiData, cxWinSize, cyWinSize, + pbImage, cxImgSize, cyImgSize, cImgChannels, + bStretched); + } + + return TRUE; +} + +//-------------- +// InitBitmap +//-------------- + +BOOL InitBitmap (BYTE *pDiData, int cxWinSize, int cyWinSize) +{ + BYTE *dst; + int x, y, col; + + // initialize the background with gray + + dst = pDiData; + for (y = 0; y < cyWinSize; y++) + { + col = 0; + for (x = 0; x < cxWinSize; x++) + { + // fill with GRAY + *dst++ = 127; + *dst++ = 127; + *dst++ = 127; + col += 3; + } + // rows start on 4 byte boundaries + while ((col % 4) != 0) + { + dst++; + col++; + } + } + + return TRUE; +} + +//-------------- +// FillBitmap +//-------------- + +BOOL FillBitmap ( + BYTE *pDiData, int cxWinSize, int cyWinSize, + BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, + BOOL bStretched) +{ + BYTE *pStretchedImage; + BYTE *pImg; + BYTE *src, *dst; + BYTE r, g, b, a; + const int cDIChannels = 3; + WORD wImgRowBytes; + WORD wDIRowBytes; + int cxNewSize, cyNewSize; + int cxImgPos, cyImgPos; + int xImg, yImg; + int xWin, yWin; + int xOld, yOld; + int xNew, yNew; + + if (bStretched) + { + cxNewSize = cxWinSize - 2 * MARGIN; + cyNewSize = cyWinSize - 2 * MARGIN; + + // stretch the image to it's window determined size + + // the following two are the same, but the first has side-effects + // because of rounding +// if ((cyNewSize / cxNewSize) > (cyImgSize / cxImgSize)) + if ((cyNewSize * cxImgSize) > (cyImgSize * cxNewSize)) + { + cyNewSize = cxNewSize * cyImgSize / cxImgSize; + cxImgPos = MARGIN; + cyImgPos = (cyWinSize - cyNewSize) / 2; + } + else + { + cxNewSize = cyNewSize * cxImgSize / cyImgSize; + cyImgPos = MARGIN; + cxImgPos = (cxWinSize - cxNewSize) / 2; + } + + pStretchedImage = malloc (cImgChannels * cxNewSize * cyNewSize); + pImg = pStretchedImage; + + for (yNew = 0; yNew < cyNewSize; yNew++) + { + yOld = yNew * cyImgSize / cyNewSize; + for (xNew = 0; xNew < cxNewSize; xNew++) + { + xOld = xNew * cxImgSize / cxNewSize; + + r = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 0); + g = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 1); + b = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 2); + *pImg++ = r; + *pImg++ = g; + *pImg++ = b; + if (cImgChannels == 4) + { + a = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + + 3); + *pImg++ = a; + } + } + } + + // calculate row-bytes + + wImgRowBytes = cImgChannels * cxNewSize; + wDIRowBytes = (WORD) ((cDIChannels * cxWinSize + 3L) >> 2) << 2; + + // copy image to screen + + for (yImg = 0, yWin = cyImgPos; yImg < cyNewSize; yImg++, yWin++) + { + if (yWin >= cyWinSize - cyImgPos) + break; + src = pStretchedImage + yImg * wImgRowBytes; + dst = pDiData + yWin * wDIRowBytes + cxImgPos * cDIChannels; + + for (xImg = 0, xWin = cxImgPos; xImg < cxNewSize; xImg++, xWin++) + { + if (xWin >= cxWinSize - cxImgPos) + break; + r = *src++; + g = *src++; + b = *src++; + *dst++ = b; /* note the reverse order */ + *dst++ = g; + *dst++ = r; + if (cImgChannels == 4) + { + a = *src++; + } + } + } + + // free memory + + if (pStretchedImage != NULL) + { + free (pStretchedImage); + pStretchedImage = NULL; + } + + } + + // process the image not-stretched + + else + { + // calculate the central position + + cxImgPos = (cxWinSize - cxImgSize) / 2; + cyImgPos = (cyWinSize - cyImgSize) / 2; + + // check for image larger than window + + if (cxImgPos < MARGIN) + cxImgPos = MARGIN; + if (cyImgPos < MARGIN) + cyImgPos = MARGIN; + + // calculate both row-bytes + + wImgRowBytes = cImgChannels * cxImgSize; + wDIRowBytes = (WORD) ((cDIChannels * cxWinSize + 3L) >> 2) << 2; + + // copy image to screen + + for (yImg = 0, yWin = cyImgPos; yImg < cyImgSize; yImg++, yWin++) + { + if (yWin >= cyWinSize - MARGIN) + break; + src = pbImage + yImg * wImgRowBytes; + dst = pDiData + yWin * wDIRowBytes + cxImgPos * cDIChannels; + + for (xImg = 0, xWin = cxImgPos; xImg < cxImgSize; xImg++, xWin++) + { + if (xWin >= cxWinSize - MARGIN) + break; + r = *src++; + g = *src++; + b = *src++; + *dst++ = b; /* note the reverse order */ + *dst++ = g; + *dst++ = r; + if (cImgChannels == 4) + { + a = *src++; + } + } + } + } + + return TRUE; +} + +//----------------- +// end of source +//----------------- diff --git a/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.dsp b/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.dsp index 53ef5a2..c13c5a7 100644 --- a/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.dsp +++ b/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.dsp @@ -1,147 +1,147 @@ -# Microsoft Developer Studio Project File - Name="VisualPng" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=VisualPng - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "VisualPng.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "VisualPng.mak" CFG="VisualPng - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "VisualPng - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "VisualPng - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "VisualPng - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 ..\..\projects\visualc6\Win32_LIB_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# Begin Special Build Tool -OutDir=.\Release -SOURCE="$(InputPath)" -PostBuild_Cmds=$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "VisualPng - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ..\..\projects\visualc6\Win32_LIB_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /pdbtype:sept -# Begin Special Build Tool -OutDir=.\Debug -SOURCE="$(InputPath)" -PostBuild_Cmds=$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "VisualPng - Win32 Release" -# Name "VisualPng - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\PngFile.c -# End Source File -# Begin Source File - -SOURCE=.\VisualPng.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\cexcept.h -# End Source File -# Begin Source File - -SOURCE=.\PngFile.h -# End Source File -# Begin Source File - -SOURCE=.\resource.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# Begin Source File - -SOURCE=.\VisualPng.ico -# End Source File -# Begin Source File - -SOURCE=.\VisualPng.rc -# End Source File -# End Group -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="VisualPng" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=VisualPng - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "VisualPng.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "VisualPng.mak" CFG="VisualPng - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "VisualPng - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "VisualPng - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "VisualPng - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c +# SUBTRACT BASE CPP /YX +# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 ..\..\projects\visualc6\Win32_LIB_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# Begin Special Build Tool +OutDir=.\Release +SOURCE="$(InputPath)" +PostBuild_Cmds=$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png +# End Special Build Tool + +!ELSEIF "$(CFG)" == "VisualPng - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c +# SUBTRACT BASE CPP /YX +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 ..\..\projects\visualc6\Win32_LIB_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /pdbtype:sept +# Begin Special Build Tool +OutDir=.\Debug +SOURCE="$(InputPath)" +PostBuild_Cmds=$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "VisualPng - Win32 Release" +# Name "VisualPng - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\PngFile.c +# End Source File +# Begin Source File + +SOURCE=.\VisualPng.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\cexcept.h +# End Source File +# Begin Source File + +SOURCE=.\PngFile.h +# End Source File +# Begin Source File + +SOURCE=.\resource.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\VisualPng.ico +# End Source File +# Begin Source File + +SOURCE=.\VisualPng.rc +# End Source File +# End Group +# End Target +# End Project diff --git a/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.dsw b/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.dsw index a30e1cc..17ad83a 100644 --- a/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.dsw +++ b/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.dsw @@ -1,29 +1,29 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "VisualPng"=.\VisualPng.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "VisualPng"=.\VisualPng.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.rc b/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.rc index 6e0623a..151c68c 100644 --- a/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.rc +++ b/src/dep/src/irrlicht/libpng/contrib/visupng/VisualPng.rc @@ -1,152 +1,152 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -VISUALPNG MENU DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&Open Image...\tCtrl+O", IDM_FILE_OPEN - MENUITEM "Save &As...", IDM_FILE_SAVE - MENUITEM SEPARATOR - MENUITEM "&Next Image\tCtrl+N", IDM_FILE_NEXT - MENUITEM "Pre&vious Image\tCtrl+V", IDM_FILE_PREVIOUS - MENUITEM SEPARATOR - MENUITEM "E&xit\tAlt+X", IDM_FILE_EXIT - END - POPUP "&Options" - BEGIN - MENUITEM "&Stretch", IDM_OPTIONS_STRETCH, CHECKED - END - POPUP "&Help" - BEGIN - MENUITEM "&About", IDM_HELP_ABOUT - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -VISUALPNG ACCELERATORS DISCARDABLE -BEGIN - "N", IDM_FILE_NEXT, VIRTKEY, CONTROL, NOINVERT - "O", IDM_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT - "P", IDM_FILE_PREVIOUS, VIRTKEY, CONTROL, NOINVERT - "V", IDM_FILE_PREVIOUS, VIRTKEY, CONTROL, NOINVERT - "X", IDM_FILE_EXIT, VIRTKEY, ALT, NOINVERT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -VISUALPNG ICON DISCARDABLE "VisualPng.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -ABOUTBOX DIALOG DISCARDABLE 0, 0, 186, 94 -STYLE DS_MODALFRAME | WS_POPUP -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,68,67,50,14 - CTEXT "VisualPng 1.0 - June 2000",IDC_STATIC,49,14,88,8 - LTEXT "a PNG image viewer",IDC_STATIC,60,30,66,8 - LTEXT "(c) Willem van Schaik, 2000",IDC_STATIC,48,52,90,8 - LTEXT "to demonstrate the use of libpng in Visual C", - IDC_STATIC,25,38,136,8 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - "ABOUTBOX", DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 179 - TOPMARGIN, 7 - BOTTOMMARGIN, 87 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +VISUALPNG MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&Open Image...\tCtrl+O", IDM_FILE_OPEN + MENUITEM "Save &As...", IDM_FILE_SAVE + MENUITEM SEPARATOR + MENUITEM "&Next Image\tCtrl+N", IDM_FILE_NEXT + MENUITEM "Pre&vious Image\tCtrl+V", IDM_FILE_PREVIOUS + MENUITEM SEPARATOR + MENUITEM "E&xit\tAlt+X", IDM_FILE_EXIT + END + POPUP "&Options" + BEGIN + MENUITEM "&Stretch", IDM_OPTIONS_STRETCH, CHECKED + END + POPUP "&Help" + BEGIN + MENUITEM "&About", IDM_HELP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +VISUALPNG ACCELERATORS DISCARDABLE +BEGIN + "N", IDM_FILE_NEXT, VIRTKEY, CONTROL, NOINVERT + "O", IDM_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT + "P", IDM_FILE_PREVIOUS, VIRTKEY, CONTROL, NOINVERT + "V", IDM_FILE_PREVIOUS, VIRTKEY, CONTROL, NOINVERT + "X", IDM_FILE_EXIT, VIRTKEY, ALT, NOINVERT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +VISUALPNG ICON DISCARDABLE "VisualPng.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +ABOUTBOX DIALOG DISCARDABLE 0, 0, 186, 94 +STYLE DS_MODALFRAME | WS_POPUP +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,68,67,50,14 + CTEXT "VisualPng 1.0 - June 2000",IDC_STATIC,49,14,88,8 + LTEXT "a PNG image viewer",IDC_STATIC,60,30,66,8 + LTEXT "(c) Willem van Schaik, 2000",IDC_STATIC,48,52,90,8 + LTEXT "to demonstrate the use of libpng in Visual C", + IDC_STATIC,25,38,136,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + "ABOUTBOX", DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 87 + END +END +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/dep/src/irrlicht/libpng/contrib/visupng/cexcept.h b/src/dep/src/irrlicht/libpng/contrib/visupng/cexcept.h index a1a4f83..dbea51e 100644 --- a/src/dep/src/irrlicht/libpng/contrib/visupng/cexcept.h +++ b/src/dep/src/irrlicht/libpng/contrib/visupng/cexcept.h @@ -1,243 +1,243 @@ -/*=== -cexcept.h 2.0.0 (2001-Jul-12-Thu) -Adam M. Costello - -An interface for exception-handling in ANSI C (C89 and subsequent ISO -standards), developed jointly with Cosmin Truta . - - Copyright (c) 2001 Adam M. Costello and Cosmin Truta. Everyone - is hereby granted permission to do whatever they like with this - file, provided that if they modify it they take reasonable steps to - avoid confusing or misleading people about the authors, version, - and terms of use of the derived file. The copyright holders make - no guarantees regarding this file, and are not responsible for any - damage resulting from its use. - -Only user-defined exceptions are supported, not "real" exceptions like -division by zero or memory segmentation violations. - -If this interface is used by multiple .c files, they shouldn't include -this header file directly. Instead, create a wrapper header file that -includes this header file and then invokes the define_exception_type -macro (see below), and let your .c files include that header file. - -The interface consists of one type, one well-known name, and six macros. - - -define_exception_type(type_name); - - This macro is used like an external declaration. It specifies - the type of object that gets copied from the exception thrower to - the exception catcher. The type_name can be any type that can be - assigned to, that is, a non-constant arithmetic type, struct, union, - or pointer. Examples: - - define_exception_type(int); - - enum exception { out_of_memory, bad_arguments, disk_full }; - define_exception_type(enum exception); - - struct exception { int code; const char *msg; }; - define_exception_type(struct exception); - - Because throwing an exception causes the object to be copied (not - just once, but twice), programmers may wish to consider size when - choosing the exception type. - - -struct exception_context; - - This type may be used after the define_exception_type() macro has - been invoked. A struct exception_context must be known to both - the thrower and the catcher. It is expected that there be one - context for each thread that uses exceptions. It would certainly - be dangerous for multiple threads to access the same context. - One thread can use multiple contexts, but that is likely to be - confusing and not typically useful. The application can allocate - this structure in any way it pleases--automatic, static, or dynamic. - The application programmer should pretend not to know the structure - members, which are subject to change. - - -struct exception_context *the_exception_context; - - The Try/Catch and Throw statements (described below) implicitly - refer to a context, using the name the_exception_context. It is - the application's responsibility to make sure that this name yields - the address of a mutable (non-constant) struct exception_context - wherever those statements are used. Subject to that constraint, the - application may declare a variable of this name anywhere it likes - (inside a function, in a parameter list, or externally), and may - use whatever storage class specifiers (static, extern, etc) or type - qualifiers (const, volatile, etc) it likes. Examples: - - static struct exception_context - * const the_exception_context = &foo; - - { struct exception_context *the_exception_context = bar; ... } - - int blah(struct exception_context *the_exception_context, ...); - - extern struct exception_context the_exception_context[1]; - - The last example illustrates a trick that avoids creating a pointer - object separate from the structure object. - - The name could even be a macro, for example: - - struct exception_context ec_array[numthreads]; - #define the_exception_context (ec_array + thread_id) - - Be aware that the_exception_context is used several times by the - Try/Catch/Throw macros, so it shouldn't be expensive or have side - effects. The expansion must be a drop-in replacement for an - identifier, so it's safest to put parentheses around it. - - -void init_exception_context(struct exception_context *ec); - - For context structures allocated statically (by an external - definition or using the "static" keyword), the implicit - initialization to all zeros is sufficient, but contexts allocated - by other means must be initialized using this macro before they - are used by a Try/Catch statement. It does no harm to initialize - a context more than once (by using this macro on a statically - allocated context, or using this macro twice on the same context), - but a context must not be re-initialized after it has been used by a - Try/Catch statement. - - -Try statement -Catch (expression) statement - - The Try/Catch/Throw macros are capitalized in order to avoid - confusion with the C++ keywords, which have subtly different - semantics. - - A Try/Catch statement has a syntax similar to an if/else statement, - except that the parenthesized expression goes after the second - keyword rather than the first. As with if/else, there are two - clauses, each of which may be a simple statement ending with a - semicolon or a brace-enclosed compound statement. But whereas - the else clause is optional, the Catch clause is required. The - expression must be a modifiable lvalue (something capable of being - assigned to) of the same type (disregarding type qualifiers) that - was passed to define_exception_type(). - - If a Throw that uses the same exception context as the Try/Catch is - executed within the Try clause (typically within a function called - by the Try clause), and the exception is not caught by a nested - Try/Catch statement, then a copy of the exception will be assigned - to the expression, and control will jump to the Catch clause. If no - such Throw is executed, then the assignment is not performed, and - the Catch clause is not executed. - - The expression is not evaluated unless and until the exception is - caught, which is significant if it has side effects, for example: - - Try foo(); - Catch (p[++i].e) { ... } - - IMPORTANT: Jumping into or out of a Try clause (for example via - return, break, continue, goto, longjmp) is forbidden--the compiler - will not complain, but bad things will happen at run-time. Jumping - into or out of a Catch clause is okay, and so is jumping around - inside a Try clause. In many cases where one is tempted to return - from a Try clause, it will suffice to use Throw, and then return - from the Catch clause. Another option is to set a flag variable and - use goto to jump to the end of the Try clause, then check the flag - after the Try/Catch statement. - - IMPORTANT: The values of any non-volatile automatic variables - changed within the Try clause are undefined after an exception is - caught. Therefore, variables modified inside the Try block whose - values are needed later outside the Try block must either use static - storage or be declared with the "volatile" type qualifier. - - -Throw expression; - - A Throw statement is very much like a return statement, except that - the expression is required. Whereas return jumps back to the place - where the current function was called, Throw jumps back to the Catch - clause of the innermost enclosing Try clause. The expression must - be compatible with the type passed to define_exception_type(). The - exception must be caught, otherwise the program may crash. - - Slight limitation: If the expression is a comma-expression it must - be enclosed in parentheses. - - -Try statement -Catch_anonymous statement - - When the value of the exception is not needed, a Try/Catch statement - can use Catch_anonymous instead of Catch (expression). - - -Everything below this point is for the benefit of the compiler. The -application programmer should pretend not to know any of it, because it -is subject to change. - -===*/ - - -#ifndef CEXCEPT_H -#define CEXCEPT_H - - -#include - -#define define_exception_type(etype) \ -struct exception_context { \ - jmp_buf *penv; \ - int caught; \ - volatile struct { etype etmp; } v; \ -} - -/* etmp must be volatile because the application might use automatic */ -/* storage for the_exception_context, and etmp is modified between */ -/* the calls to setjmp() and longjmp(). A wrapper struct is used to */ -/* avoid warnings about a duplicate volatile qualifier in case etype */ -/* already includes it. */ - -#define init_exception_context(ec) ((void)((ec)->penv = 0)) - -#define Try \ - { \ - jmp_buf *exception__prev, exception__env; \ - exception__prev = the_exception_context->penv; \ - the_exception_context->penv = &exception__env; \ - if (setjmp(exception__env) == 0) { \ - if (&exception__prev) - -#define exception__catch(action) \ - else { } \ - the_exception_context->caught = 0; \ - } \ - else { \ - the_exception_context->caught = 1; \ - } \ - the_exception_context->penv = exception__prev; \ - } \ - if (!the_exception_context->caught || action) { } \ - else - -#define Catch(e) exception__catch(((e) = the_exception_context->v.etmp, 0)) -#define Catch_anonymous exception__catch(0) - -/* Try ends with if(), and Catch begins and ends with else. This */ -/* ensures that the Try/Catch syntax is really the same as the */ -/* if/else syntax. */ -/* */ -/* We use &exception__prev instead of 1 to appease compilers that */ -/* warn about constant expressions inside if(). Most compilers */ -/* should still recognize that &exception__prev is never zero and */ -/* avoid generating test code. */ - -#define Throw \ - for (;; longjmp(*the_exception_context->penv, 1)) \ - the_exception_context->v.etmp = - - -#endif /* CEXCEPT_H */ +/*=== +cexcept.h 2.0.0 (2001-Jul-12-Thu) +Adam M. Costello + +An interface for exception-handling in ANSI C (C89 and subsequent ISO +standards), developed jointly with Cosmin Truta . + + Copyright (c) 2001 Adam M. Costello and Cosmin Truta. Everyone + is hereby granted permission to do whatever they like with this + file, provided that if they modify it they take reasonable steps to + avoid confusing or misleading people about the authors, version, + and terms of use of the derived file. The copyright holders make + no guarantees regarding this file, and are not responsible for any + damage resulting from its use. + +Only user-defined exceptions are supported, not "real" exceptions like +division by zero or memory segmentation violations. + +If this interface is used by multiple .c files, they shouldn't include +this header file directly. Instead, create a wrapper header file that +includes this header file and then invokes the define_exception_type +macro (see below), and let your .c files include that header file. + +The interface consists of one type, one well-known name, and six macros. + + +define_exception_type(type_name); + + This macro is used like an external declaration. It specifies + the type of object that gets copied from the exception thrower to + the exception catcher. The type_name can be any type that can be + assigned to, that is, a non-constant arithmetic type, struct, union, + or pointer. Examples: + + define_exception_type(int); + + enum exception { out_of_memory, bad_arguments, disk_full }; + define_exception_type(enum exception); + + struct exception { int code; const char *msg; }; + define_exception_type(struct exception); + + Because throwing an exception causes the object to be copied (not + just once, but twice), programmers may wish to consider size when + choosing the exception type. + + +struct exception_context; + + This type may be used after the define_exception_type() macro has + been invoked. A struct exception_context must be known to both + the thrower and the catcher. It is expected that there be one + context for each thread that uses exceptions. It would certainly + be dangerous for multiple threads to access the same context. + One thread can use multiple contexts, but that is likely to be + confusing and not typically useful. The application can allocate + this structure in any way it pleases--automatic, static, or dynamic. + The application programmer should pretend not to know the structure + members, which are subject to change. + + +struct exception_context *the_exception_context; + + The Try/Catch and Throw statements (described below) implicitly + refer to a context, using the name the_exception_context. It is + the application's responsibility to make sure that this name yields + the address of a mutable (non-constant) struct exception_context + wherever those statements are used. Subject to that constraint, the + application may declare a variable of this name anywhere it likes + (inside a function, in a parameter list, or externally), and may + use whatever storage class specifiers (static, extern, etc) or type + qualifiers (const, volatile, etc) it likes. Examples: + + static struct exception_context + * const the_exception_context = &foo; + + { struct exception_context *the_exception_context = bar; ... } + + int blah(struct exception_context *the_exception_context, ...); + + extern struct exception_context the_exception_context[1]; + + The last example illustrates a trick that avoids creating a pointer + object separate from the structure object. + + The name could even be a macro, for example: + + struct exception_context ec_array[numthreads]; + #define the_exception_context (ec_array + thread_id) + + Be aware that the_exception_context is used several times by the + Try/Catch/Throw macros, so it shouldn't be expensive or have side + effects. The expansion must be a drop-in replacement for an + identifier, so it's safest to put parentheses around it. + + +void init_exception_context(struct exception_context *ec); + + For context structures allocated statically (by an external + definition or using the "static" keyword), the implicit + initialization to all zeros is sufficient, but contexts allocated + by other means must be initialized using this macro before they + are used by a Try/Catch statement. It does no harm to initialize + a context more than once (by using this macro on a statically + allocated context, or using this macro twice on the same context), + but a context must not be re-initialized after it has been used by a + Try/Catch statement. + + +Try statement +Catch (expression) statement + + The Try/Catch/Throw macros are capitalized in order to avoid + confusion with the C++ keywords, which have subtly different + semantics. + + A Try/Catch statement has a syntax similar to an if/else statement, + except that the parenthesized expression goes after the second + keyword rather than the first. As with if/else, there are two + clauses, each of which may be a simple statement ending with a + semicolon or a brace-enclosed compound statement. But whereas + the else clause is optional, the Catch clause is required. The + expression must be a modifiable lvalue (something capable of being + assigned to) of the same type (disregarding type qualifiers) that + was passed to define_exception_type(). + + If a Throw that uses the same exception context as the Try/Catch is + executed within the Try clause (typically within a function called + by the Try clause), and the exception is not caught by a nested + Try/Catch statement, then a copy of the exception will be assigned + to the expression, and control will jump to the Catch clause. If no + such Throw is executed, then the assignment is not performed, and + the Catch clause is not executed. + + The expression is not evaluated unless and until the exception is + caught, which is significant if it has side effects, for example: + + Try foo(); + Catch (p[++i].e) { ... } + + IMPORTANT: Jumping into or out of a Try clause (for example via + return, break, continue, goto, longjmp) is forbidden--the compiler + will not complain, but bad things will happen at run-time. Jumping + into or out of a Catch clause is okay, and so is jumping around + inside a Try clause. In many cases where one is tempted to return + from a Try clause, it will suffice to use Throw, and then return + from the Catch clause. Another option is to set a flag variable and + use goto to jump to the end of the Try clause, then check the flag + after the Try/Catch statement. + + IMPORTANT: The values of any non-volatile automatic variables + changed within the Try clause are undefined after an exception is + caught. Therefore, variables modified inside the Try block whose + values are needed later outside the Try block must either use static + storage or be declared with the "volatile" type qualifier. + + +Throw expression; + + A Throw statement is very much like a return statement, except that + the expression is required. Whereas return jumps back to the place + where the current function was called, Throw jumps back to the Catch + clause of the innermost enclosing Try clause. The expression must + be compatible with the type passed to define_exception_type(). The + exception must be caught, otherwise the program may crash. + + Slight limitation: If the expression is a comma-expression it must + be enclosed in parentheses. + + +Try statement +Catch_anonymous statement + + When the value of the exception is not needed, a Try/Catch statement + can use Catch_anonymous instead of Catch (expression). + + +Everything below this point is for the benefit of the compiler. The +application programmer should pretend not to know any of it, because it +is subject to change. + +===*/ + + +#ifndef CEXCEPT_H +#define CEXCEPT_H + + +#include + +#define define_exception_type(etype) \ +struct exception_context { \ + jmp_buf *penv; \ + int caught; \ + volatile struct { etype etmp; } v; \ +} + +/* etmp must be volatile because the application might use automatic */ +/* storage for the_exception_context, and etmp is modified between */ +/* the calls to setjmp() and longjmp(). A wrapper struct is used to */ +/* avoid warnings about a duplicate volatile qualifier in case etype */ +/* already includes it. */ + +#define init_exception_context(ec) ((void)((ec)->penv = 0)) + +#define Try \ + { \ + jmp_buf *exception__prev, exception__env; \ + exception__prev = the_exception_context->penv; \ + the_exception_context->penv = &exception__env; \ + if (setjmp(exception__env) == 0) { \ + if (&exception__prev) + +#define exception__catch(action) \ + else { } \ + the_exception_context->caught = 0; \ + } \ + else { \ + the_exception_context->caught = 1; \ + } \ + the_exception_context->penv = exception__prev; \ + } \ + if (!the_exception_context->caught || action) { } \ + else + +#define Catch(e) exception__catch(((e) = the_exception_context->v.etmp, 0)) +#define Catch_anonymous exception__catch(0) + +/* Try ends with if(), and Catch begins and ends with else. This */ +/* ensures that the Try/Catch syntax is really the same as the */ +/* if/else syntax. */ +/* */ +/* We use &exception__prev instead of 1 to appease compilers that */ +/* warn about constant expressions inside if(). Most compilers */ +/* should still recognize that &exception__prev is never zero and */ +/* avoid generating test code. */ + +#define Throw \ + for (;; longjmp(*the_exception_context->penv, 1)) \ + the_exception_context->v.etmp = + + +#endif /* CEXCEPT_H */ diff --git a/src/dep/src/irrlicht/libpng/contrib/visupng/resource.h b/src/dep/src/irrlicht/libpng/contrib/visupng/resource.h index e222d35..611dd03 100644 --- a/src/dep/src/irrlicht/libpng/contrib/visupng/resource.h +++ b/src/dep/src/irrlicht/libpng/contrib/visupng/resource.h @@ -1,23 +1,23 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by VisualPng.rc -// -#define IDM_FILE_OPEN 40001 -#define IDM_FILE_SAVE 40002 -#define IDM_FILE_NEXT 40003 -#define IDM_FILE_PREVIOUS 40004 -#define IDM_FILE_EXIT 40005 -#define IDM_OPTIONS_BACKGROUND 40006 -#define IDM_OPTIONS_STRETCH 40007 -#define IDM_HELP_ABOUT 40008 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 113 -#define _APS_NEXT_COMMAND_VALUE 40009 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by VisualPng.rc +// +#define IDM_FILE_OPEN 40001 +#define IDM_FILE_SAVE 40002 +#define IDM_FILE_NEXT 40003 +#define IDM_FILE_PREVIOUS 40004 +#define IDM_FILE_EXIT 40005 +#define IDM_OPTIONS_BACKGROUND 40006 +#define IDM_OPTIONS_STRETCH 40007 +#define IDM_HELP_ABOUT 40008 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 113 +#define _APS_NEXT_COMMAND_VALUE 40009 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/dep/src/irrlicht/libpng/example.c b/src/dep/src/irrlicht/libpng/example.c index 2db293a..0815873 100644 --- a/src/dep/src/irrlicht/libpng/example.c +++ b/src/dep/src/irrlicht/libpng/example.c @@ -1,814 +1,814 @@ - -#if 0 /* in case someone actually tries to compile this */ - -/* example.c - an example of using libpng - * Last changed in libpng 1.2.1 December 7, 2001. - * This file has been placed in the public domain by the authors. - * Maintained 1998-2007 Glenn Randers-Pehrson - * Maintained 1996, 1997 Andreas Dilger) - * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -/* This is an example of how to use libpng to read and write PNG files. - * The file libpng.txt is much more verbose then this. If you have not - * read it, do so first. This was designed to be a starting point of an - * implementation. This is not officially part of libpng, is hereby placed - * in the public domain, and therefore does not require a copyright notice. - * - * This file does not currently compile, because it is missing certain - * parts, like allocating memory to hold an image. You will have to - * supply these parts to get it to compile. For an example of a minimal - * working PNG reader/writer, see pngtest.c, included in this distribution; - * see also the programs in the contrib directory. - */ - -#include "png.h" - - /* The png_jmpbuf() macro, used in error handling, became available in - * libpng version 1.0.6. If you want to be able to run your code with older - * versions of libpng, you must define the macro yourself (but only if it - * is not already defined by libpng!). - */ - -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#endif - -/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp() - * returns zero if the image is a PNG and nonzero if it isn't a PNG. - * - * The function check_if_png() shown here, but not used, returns nonzero (true) - * if the file can be opened and is a PNG, 0 (false) otherwise. - * - * If this call is successful, and you are going to keep the file open, - * you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once - * you have created the png_ptr, so that libpng knows your application - * has read that many bytes from the start of the file. Make sure you - * don't call png_set_sig_bytes() with more than 8 bytes read or give it - * an incorrect number of bytes read, or you will either have read too - * many bytes (your fault), or you are telling libpng to read the wrong - * number of magic bytes (also your fault). - * - * Many applications already read the first 2 or 4 bytes from the start - * of the image to determine the file type, so it would be easiest just - * to pass the bytes to png_sig_cmp() or even skip that if you know - * you have a PNG file, and call png_set_sig_bytes(). - */ -#define PNG_BYTES_TO_CHECK 4 -int check_if_png(char *file_name, FILE **fp) -{ - char buf[PNG_BYTES_TO_CHECK]; - - /* Open the prospective PNG file. */ - if ((*fp = fopen(file_name, "rb")) == NULL) - return 0; - - /* Read in some of the signature bytes */ - if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK) - return 0; - - /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. - Return nonzero (true) if they match */ - - return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK)); -} - -/* Read a PNG file. You may want to return an error code if the read - * fails (depending upon the failure). There are two "prototypes" given - * here - one where we are given the filename, and we need to open the - * file, and the other where we are given an open file (possibly with - * some or all of the magic bytes read - see comments above). - */ -#ifdef open_file /* prototype 1 */ -void read_png(char *file_name) /* We need to open the file */ -{ - png_structp png_ptr; - png_infop info_ptr; - unsigned int sig_read = 0; - png_uint_32 width, height; - int bit_depth, color_type, interlace_type; - FILE *fp; - - if ((fp = fopen(file_name, "rb")) == NULL) - return (ERROR); -#else no_open_file /* prototype 2 */ -void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ -{ - png_structp png_ptr; - png_infop info_ptr; - png_uint_32 width, height; - int bit_depth, color_type, interlace_type; -#endif no_open_file /* only use one prototype! */ - - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also supply the - * the compiler header file version, so that we know if the application - * was compiled with a compatible version of the library. REQUIRED - */ - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (png_ptr == NULL) - { - fclose(fp); - return (ERROR); - } - - /* Allocate/initialize the memory for image information. REQUIRED. */ - info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) - { - fclose(fp); - png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL); - return (ERROR); - } - - /* Set error handling if you are using the setjmp/longjmp method (this is - * the normal method of doing things with libpng). REQUIRED unless you - * set up your own error handlers in the png_create_read_struct() earlier. - */ - - if (setjmp(png_jmpbuf(png_ptr))) - { - /* Free all of the memory associated with the png_ptr and info_ptr */ - png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); - fclose(fp); - /* If we get here, we had a problem reading the file */ - return (ERROR); - } - - /* One of the following I/O initialization methods is REQUIRED */ -#ifdef streams /* PNG file I/O method 1 */ - /* Set up the input control if you are using standard C streams */ - png_init_io(png_ptr, fp); - -#else no_streams /* PNG file I/O method 2 */ - /* If you are using replacement read functions, instead of calling - * png_init_io() here you would call: - */ - png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn); - /* where user_io_ptr is a structure you want available to the callbacks */ -#endif no_streams /* Use only one I/O method! */ - - /* If we have already read some of the signature */ - png_set_sig_bytes(png_ptr, sig_read); - -#ifdef hilevel - /* - * If you have enough memory to read in the entire image at once, - * and you need to specify only transforms that can be controlled - * with one of the PNG_TRANSFORM_* bits (this presently excludes - * dithering, filling, setting background, and doing gamma - * adjustment), then you can read the entire image (including - * pixels) into the info structure with this call: - */ - png_read_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); -#else - /* OK, you're doing it the hard way, with the lower-level functions */ - - /* The call to png_read_info() gives us all of the information from the - * PNG file before the first IDAT (image data chunk). REQUIRED - */ - png_read_info(png_ptr, info_ptr); - - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - &interlace_type, int_p_NULL, int_p_NULL); - -/* Set up the data transformations you want. Note that these are all - * optional. Only call them if you want/need them. Many of the - * transformations only work on specific types of images, and many - * are mutually exclusive. - */ - - /* tell libpng to strip 16 bit/color files down to 8 bits/color */ - png_set_strip_16(png_ptr); - - /* Strip alpha bytes from the input data without combining with the - * background (not recommended). - */ - png_set_strip_alpha(png_ptr); - - /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single - * byte into separate bytes (useful for paletted and grayscale images). - */ - png_set_packing(png_ptr); - - /* Change the order of packed pixels to least significant bit first - * (not useful if you are using png_set_packing). */ - png_set_packswap(png_ptr); - - /* Expand paletted colors into true RGB triplets */ - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_gray_1_2_4_to_8(png_ptr); - - /* Expand paletted or RGB images with transparency to full alpha channels - * so the data will be available as RGBA quartets. - */ - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_tRNS_to_alpha(png_ptr); - - /* Set the background color to draw transparent and alpha images over. - * It is possible to set the red, green, and blue components directly - * for paletted images instead of supplying a palette index. Note that - * even if the PNG file supplies a background, you are not required to - * use it - you should use the (solid) application background if it has one. - */ - - png_color_16 my_background, *image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - - /* Some suggestions as to how to get a screen gamma value */ - - /* Note that screen gamma is the display_exponent, which includes - * the CRT_exponent and any correction for viewing conditions */ - if (/* We have a user-defined screen gamma value */) - { - screen_gamma = user-defined screen_gamma; - } - /* This is one way that applications share the same screen gamma value */ - else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL) - { - screen_gamma = atof(gamma_str); - } - /* If we don't have another value */ - else - { - screen_gamma = 2.2; /* A good guess for a PC monitors in a dimly - lit room */ - screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */ - } - - /* Tell libpng to handle the gamma conversion for you. The final call - * is a good guess for PC generated images, but it should be configurable - * by the user at run time by the user. It is strongly suggested that - * your application support gamma correction. - */ - - int intent; - - if (png_get_sRGB(png_ptr, info_ptr, &intent)) - png_set_gamma(png_ptr, screen_gamma, 0.45455); - else - { - double image_gamma; - if (png_get_gAMA(png_ptr, info_ptr, &image_gamma)) - png_set_gamma(png_ptr, screen_gamma, image_gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - } - - /* Dither RGB files down to 8 bit palette or reduce palettes - * to the number of colors available on your screen. - */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - int num_palette; - png_colorp palette; - - /* This reduces the image to the application supplied palette */ - if (/* we have our own palette */) - { - /* An array of colors to which the image should be dithered */ - png_color std_color_cube[MAX_SCREEN_COLORS]; - - png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS, - MAX_SCREEN_COLORS, png_uint_16p_NULL, 0); - } - /* This reduces the image to the palette supplied in the file */ - else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) - { - png_uint_16p histogram = NULL; - - png_get_hIST(png_ptr, info_ptr, &histogram); - - png_set_dither(png_ptr, palette, num_palette, - max_screen_colors, histogram, 0); - } - } - - /* invert monochrome files to have 0 as white and 1 as black */ - png_set_invert_mono(png_ptr); - - /* If you want to shift the pixel values from the range [0,255] or - * [0,65535] to the original [0,7] or [0,31], or whatever range the - * colors were originally in: - */ - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) - { - png_color_8p sig_bit; - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - png_set_shift(png_ptr, sig_bit); - } - - /* flip the RGB pixels to BGR (or RGBA to BGRA) */ - if (color_type & PNG_COLOR_MASK_COLOR) - png_set_bgr(png_ptr); - - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ - png_set_swap_alpha(png_ptr); - - /* swap bytes of 16 bit files to least significant byte first */ - png_set_swap(png_ptr); - - /* Add filler (or alpha) byte (before/after each RGB triplet) */ - png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); - - /* Turn on interlace handling. REQUIRED if you are not using - * png_read_image(). To see how to handle interlacing passes, - * see the png_read_row() method below: - */ - number_passes = png_set_interlace_handling(png_ptr); - - /* Optional call to gamma correct and add the background to the palette - * and update info structure. REQUIRED if you are expecting libpng to - * update the palette for you (ie you selected such a transform above). - */ - png_read_update_info(png_ptr, info_ptr); - - /* Allocate the memory to hold the image using the fields of info_ptr. */ - - /* The easiest way to read the image: */ - png_bytep row_pointers[height]; - - for (row = 0; row < height; row++) - { - row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr, - info_ptr)); - } - - /* Now it's time to read the image. One of these methods is REQUIRED */ -#ifdef entire /* Read the entire image in one go */ - png_read_image(png_ptr, row_pointers); - -#else no_entire /* Read the image one or more scanlines at a time */ - /* The other way to read images - deal with interlacing: */ - - for (pass = 0; pass < number_passes; pass++) - { -#ifdef single /* Read the image a single row at a time */ - for (y = 0; y < height; y++) - { - png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, 1); - } - -#else no_single /* Read the image several rows at a time */ - for (y = 0; y < height; y += number_of_rows) - { -#ifdef sparkle /* Read the image using the "sparkle" effect. */ - png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, - number_of_rows); -#else no_sparkle /* Read the image using the "rectangle" effect */ - png_read_rows(png_ptr, png_bytepp_NULL, &row_pointers[y], - number_of_rows); -#endif no_sparkle /* use only one of these two methods */ - } - - /* if you want to display the image after every pass, do - so here */ -#endif no_single /* use only one of these two methods */ - } -#endif no_entire /* use only one of these two methods */ - - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ - png_read_end(png_ptr, info_ptr); -#endif hilevel - - /* At this point you have read the entire image */ - - /* clean up after the read, and free any memory allocated - REQUIRED */ - png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); - - /* close the file */ - fclose(fp); - - /* that's it */ - return (OK); -} - -/* progressively read a file */ - -int -initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr) -{ - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also check that - * the library version is compatible in case we are using dynamically - * linked libraries. - */ - *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (*png_ptr == NULL) - { - *info_ptr = NULL; - return (ERROR); - } - - *info_ptr = png_create_info_struct(png_ptr); - - if (*info_ptr == NULL) - { - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); - return (ERROR); - } - - if (setjmp(png_jmpbuf((*png_ptr)))) - { - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); - return (ERROR); - } - - /* This one's new. You will need to provide all three - * function callbacks, even if you aren't using them all. - * If you aren't using all functions, you can specify NULL - * parameters. Even when all three functions are NULL, - * you need to call png_set_progressive_read_fn(). - * These functions shouldn't be dependent on global or - * static variables if you are decoding several images - * simultaneously. You should store stream specific data - * in a separate struct, given as the second parameter, - * and retrieve the pointer from inside the callbacks using - * the function png_get_progressive_ptr(png_ptr). - */ - png_set_progressive_read_fn(*png_ptr, (void *)stream_data, - info_callback, row_callback, end_callback); - - return (OK); -} - -int -process_data(png_structp *png_ptr, png_infop *info_ptr, - png_bytep buffer, png_uint_32 length) -{ - if (setjmp(png_jmpbuf((*png_ptr)))) - { - /* Free the png_ptr and info_ptr memory on error */ - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); - return (ERROR); - } - - /* This one's new also. Simply give it chunks of data as - * they arrive from the data stream (in order, of course). - * On Segmented machines, don't give it any more than 64K. - * The library seems to run fine with sizes of 4K, although - * you can give it much less if necessary (I assume you can - * give it chunks of 1 byte, but I haven't tried with less - * than 256 bytes yet). When this function returns, you may - * want to display any rows that were generated in the row - * callback, if you aren't already displaying them there. - */ - png_process_data(*png_ptr, *info_ptr, buffer, length); - return (OK); -} - -info_callback(png_structp png_ptr, png_infop info) -{ -/* do any setup here, including setting any of the transformations - * mentioned in the Reading PNG files section. For now, you _must_ - * call either png_start_read_image() or png_read_update_info() - * after all the transformations are set (even if you don't set - * any). You may start getting rows before png_process_data() - * returns, so this is your last chance to prepare for that. - */ -} - -row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) -{ -/* - * This function is called for every row in the image. If the - * image is interlaced, and you turned on the interlace handler, - * this function will be called for every row in every pass. - * - * In this function you will receive a pointer to new row data from - * libpng called new_row that is to replace a corresponding row (of - * the same data format) in a buffer allocated by your application. - * - * The new row data pointer new_row may be NULL, indicating there is - * no new data to be replaced (in cases of interlace loading). - * - * If new_row is not NULL then you need to call - * png_progressive_combine_row() to replace the corresponding row as - * shown below: - */ - /* Check if row_num is in bounds. */ - if((row_num >= 0) && (row_num < height)) - { - /* Get pointer to corresponding row in our - * PNG read buffer. - */ - png_bytep old_row = ((png_bytep *)our_data)[row_num]; - - /* If both rows are allocated then copy the new row - * data to the corresponding row data. - */ - if((old_row != NULL) && (new_row != NULL)) - png_progressive_combine_row(png_ptr, old_row, new_row); - } -/* - * The rows and passes are called in order, so you don't really - * need the row_num and pass, but I'm supplying them because it - * may make your life easier. - * - * For the non-NULL rows of interlaced images, you must call - * png_progressive_combine_row() passing in the new row and the - * old row, as demonstrated above. You can call this function for - * NULL rows (it will just return) and for non-interlaced images - * (it just does the png_memcpy for you) if it will make the code - * easier. Thus, you can just do this for all cases: - */ - - png_progressive_combine_row(png_ptr, old_row, new_row); - -/* where old_row is what was displayed for previous rows. Note - * that the first pass (pass == 0 really) will completely cover - * the old row, so the rows do not have to be initialized. After - * the first pass (and only for interlaced images), you will have - * to pass the current row as new_row, and the function will combine - * the old row and the new row. - */ -} - -end_callback(png_structp png_ptr, png_infop info) -{ -/* this function is called when the whole image has been read, - * including any chunks after the image (up to and including - * the IEND). You will usually have the same info chunk as you - * had in the header, although some data may have been added - * to the comments and time fields. - * - * Most people won't do much here, perhaps setting a flag that - * marks the image as finished. - */ -} - -/* write a png file */ -void write_png(char *file_name /* , ... other image information ... */) -{ - FILE *fp; - png_structp png_ptr; - png_infop info_ptr; - png_colorp palette; - - /* open the file */ - fp = fopen(file_name, "wb"); - if (fp == NULL) - return (ERROR); - - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also check that - * the library version is compatible with the one used at compile time, - * in case we are using dynamically linked libraries. REQUIRED. - */ - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (png_ptr == NULL) - { - fclose(fp); - return (ERROR); - } - - /* Allocate/initialize the image information data. REQUIRED */ - info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) - { - fclose(fp); - png_destroy_write_struct(&png_ptr, png_infopp_NULL); - return (ERROR); - } - - /* Set error handling. REQUIRED if you aren't supplying your own - * error handling functions in the png_create_write_struct() call. - */ - if (setjmp(png_jmpbuf(png_ptr))) - { - /* If we get here, we had a problem reading the file */ - fclose(fp); - png_destroy_write_struct(&png_ptr, &info_ptr); - return (ERROR); - } - - /* One of the following I/O initialization functions is REQUIRED */ -#ifdef streams /* I/O initialization method 1 */ - /* set up the output control if you are using standard C streams */ - png_init_io(png_ptr, fp); -#else no_streams /* I/O initialization method 2 */ - /* If you are using replacement read functions, instead of calling - * png_init_io() here you would call */ - png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn, - user_IO_flush_function); - /* where user_io_ptr is a structure you want available to the callbacks */ -#endif no_streams /* only use one initialization method */ - -#ifdef hilevel - /* This is the easy way. Use it if you already have all the - * image info living info in the structure. You could "|" many - * PNG_TRANSFORM flags into the png_transforms integer here. - */ - png_write_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); -#else - /* This is the hard way */ - - /* Set the image information here. Width and height are up to 2^31, - * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on - * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY, - * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB, - * or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or - * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST - * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED - */ - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???, - PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - /* set the palette if there is one. REQUIRED for indexed-color images */ - palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH - * png_sizeof (png_color)); - /* ... set palette colors ... */ - png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); - /* You must not free palette here, because png_set_PLTE only makes a link to - the palette that you malloced. Wait until you are about to destroy - the png structure. */ - - /* optional significant bit chunk */ - /* if we are dealing with a grayscale image then */ - sig_bit.gray = true_bit_depth; - /* otherwise, if we are dealing with a color image then */ - sig_bit.red = true_red_bit_depth; - sig_bit.green = true_green_bit_depth; - sig_bit.blue = true_blue_bit_depth; - /* if the image has an alpha channel then */ - sig_bit.alpha = true_alpha_bit_depth; - png_set_sBIT(png_ptr, info_ptr, sig_bit); - - - /* Optional gamma chunk is strongly suggested if you have any guess - * as to the correct gamma of the image. - */ - png_set_gAMA(png_ptr, info_ptr, gamma); - - /* Optionally write comments into the image */ - text_ptr[0].key = "Title"; - text_ptr[0].text = "Mona Lisa"; - text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr[1].key = "Author"; - text_ptr[1].text = "Leonardo DaVinci"; - text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr[2].key = "Description"; - text_ptr[2].text = ""; - text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt; -#ifdef PNG_iTXt_SUPPORTED - text_ptr[0].lang = NULL; - text_ptr[1].lang = NULL; - text_ptr[2].lang = NULL; -#endif - png_set_text(png_ptr, info_ptr, text_ptr, 3); - - /* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */ - /* note that if sRGB is present the gAMA and cHRM chunks must be ignored - * on read and must be written in accordance with the sRGB profile */ - - /* Write the file header information. REQUIRED */ - png_write_info(png_ptr, info_ptr); - - /* If you want, you can write the info in two steps, in case you need to - * write your private chunk ahead of PLTE: - * - * png_write_info_before_PLTE(write_ptr, write_info_ptr); - * write_my_chunk(); - * png_write_info(png_ptr, info_ptr); - * - * However, given the level of known- and unknown-chunk support in 1.1.0 - * and up, this should no longer be necessary. - */ - - /* Once we write out the header, the compression type on the text - * chunks gets changed to PNG_TEXT_COMPRESSION_NONE_WR or - * PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again - * at the end. - */ - - /* set up the transformations you want. Note that these are - * all optional. Only call them if you want them. - */ - - /* invert monochrome pixels */ - png_set_invert_mono(png_ptr); - - /* Shift the pixels up to a legal bit depth and fill in - * as appropriate to correctly scale the image. - */ - png_set_shift(png_ptr, &sig_bit); - - /* pack pixels into bytes */ - png_set_packing(png_ptr); - - /* swap location of alpha bytes from ARGB to RGBA */ - png_set_swap_alpha(png_ptr); - - /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into - * RGB (4 channels -> 3 channels). The second parameter is not used. - */ - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - - /* flip BGR pixels to RGB */ - png_set_bgr(png_ptr); - - /* swap bytes of 16-bit files to most significant byte first */ - png_set_swap(png_ptr); - - /* swap bits of 1, 2, 4 bit packed pixel formats */ - png_set_packswap(png_ptr); - - /* turn on interlace handling if you are not using png_write_image() */ - if (interlacing) - number_passes = png_set_interlace_handling(png_ptr); - else - number_passes = 1; - - /* The easiest way to write the image (you may have a different memory - * layout, however, so choose what fits your needs best). You need to - * use the first method if you aren't handling interlacing yourself. - */ - png_uint_32 k, height, width; - png_byte image[height][width*bytes_per_pixel]; - png_bytep row_pointers[height]; - - if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) - png_error (png_ptr, "Image is too tall to process in memory"); - - for (k = 0; k < height; k++) - row_pointers[k] = image + k*width*bytes_per_pixel; - - /* One of the following output methods is REQUIRED */ -#ifdef entire /* write out the entire image data in one call */ - png_write_image(png_ptr, row_pointers); - - /* the other way to write the image - deal with interlacing */ - -#else no_entire /* write out the image data by one or more scanlines */ - /* The number of passes is either 1 for non-interlaced images, - * or 7 for interlaced images. - */ - for (pass = 0; pass < number_passes; pass++) - { - /* Write a few rows at a time. */ - png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows); - - /* If you are only writing one row at a time, this works */ - for (y = 0; y < height; y++) - { - png_write_rows(png_ptr, &row_pointers[y], 1); - } - } -#endif no_entire /* use only one output method */ - - /* You can write optional chunks like tEXt, zTXt, and tIME at the end - * as well. Shouldn't be necessary in 1.1.0 and up as all the public - * chunks are supported and you can use png_set_unknown_chunks() to - * register unknown chunks into the info structure to be written out. - */ - - /* It is REQUIRED to call this to finish writing the rest of the file */ - png_write_end(png_ptr, info_ptr); -#endif hilevel - - /* If you png_malloced a palette, free it here (don't free info_ptr->palette, - as recommended in versions 1.0.5m and earlier of this example; if - libpng mallocs info_ptr->palette, libpng will free it). If you - allocated it with malloc() instead of png_malloc(), use free() instead - of png_free(). */ - png_free(png_ptr, palette); - palette=NULL; - - /* Similarly, if you png_malloced any data that you passed in with - png_set_something(), such as a hist or trans array, free it here, - when you can be sure that libpng is through with it. */ - png_free(png_ptr, trans); - trans=NULL; - - /* clean up after the write, and free any memory allocated */ - png_destroy_write_struct(&png_ptr, &info_ptr); - - /* close the file */ - fclose(fp); - - /* that's it */ - return (OK); -} - -#endif /* if 0 */ + +#if 0 /* in case someone actually tries to compile this */ + +/* example.c - an example of using libpng + * Last changed in libpng 1.2.1 December 7, 2001. + * This file has been placed in the public domain by the authors. + * Maintained 1998-2007 Glenn Randers-Pehrson + * Maintained 1996, 1997 Andreas Dilger) + * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +/* This is an example of how to use libpng to read and write PNG files. + * The file libpng.txt is much more verbose then this. If you have not + * read it, do so first. This was designed to be a starting point of an + * implementation. This is not officially part of libpng, is hereby placed + * in the public domain, and therefore does not require a copyright notice. + * + * This file does not currently compile, because it is missing certain + * parts, like allocating memory to hold an image. You will have to + * supply these parts to get it to compile. For an example of a minimal + * working PNG reader/writer, see pngtest.c, included in this distribution; + * see also the programs in the contrib directory. + */ + +#include "png.h" + + /* The png_jmpbuf() macro, used in error handling, became available in + * libpng version 1.0.6. If you want to be able to run your code with older + * versions of libpng, you must define the macro yourself (but only if it + * is not already defined by libpng!). + */ + +#ifndef png_jmpbuf +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#endif + +/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp() + * returns zero if the image is a PNG and nonzero if it isn't a PNG. + * + * The function check_if_png() shown here, but not used, returns nonzero (true) + * if the file can be opened and is a PNG, 0 (false) otherwise. + * + * If this call is successful, and you are going to keep the file open, + * you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once + * you have created the png_ptr, so that libpng knows your application + * has read that many bytes from the start of the file. Make sure you + * don't call png_set_sig_bytes() with more than 8 bytes read or give it + * an incorrect number of bytes read, or you will either have read too + * many bytes (your fault), or you are telling libpng to read the wrong + * number of magic bytes (also your fault). + * + * Many applications already read the first 2 or 4 bytes from the start + * of the image to determine the file type, so it would be easiest just + * to pass the bytes to png_sig_cmp() or even skip that if you know + * you have a PNG file, and call png_set_sig_bytes(). + */ +#define PNG_BYTES_TO_CHECK 4 +int check_if_png(char *file_name, FILE **fp) +{ + char buf[PNG_BYTES_TO_CHECK]; + + /* Open the prospective PNG file. */ + if ((*fp = fopen(file_name, "rb")) == NULL) + return 0; + + /* Read in some of the signature bytes */ + if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK) + return 0; + + /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. + Return nonzero (true) if they match */ + + return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK)); +} + +/* Read a PNG file. You may want to return an error code if the read + * fails (depending upon the failure). There are two "prototypes" given + * here - one where we are given the filename, and we need to open the + * file, and the other where we are given an open file (possibly with + * some or all of the magic bytes read - see comments above). + */ +#ifdef open_file /* prototype 1 */ +void read_png(char *file_name) /* We need to open the file */ +{ + png_structp png_ptr; + png_infop info_ptr; + unsigned int sig_read = 0; + png_uint_32 width, height; + int bit_depth, color_type, interlace_type; + FILE *fp; + + if ((fp = fopen(file_name, "rb")) == NULL) + return (ERROR); +#else no_open_file /* prototype 2 */ +void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ +{ + png_structp png_ptr; + png_infop info_ptr; + png_uint_32 width, height; + int bit_depth, color_type, interlace_type; +#endif no_open_file /* only use one prototype! */ + + /* Create and initialize the png_struct with the desired error handler + * functions. If you want to use the default stderr and longjump method, + * you can supply NULL for the last three parameters. We also supply the + * the compiler header file version, so that we know if the application + * was compiled with a compatible version of the library. REQUIRED + */ + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, + png_voidp user_error_ptr, user_error_fn, user_warning_fn); + + if (png_ptr == NULL) + { + fclose(fp); + return (ERROR); + } + + /* Allocate/initialize the memory for image information. REQUIRED. */ + info_ptr = png_create_info_struct(png_ptr); + if (info_ptr == NULL) + { + fclose(fp); + png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL); + return (ERROR); + } + + /* Set error handling if you are using the setjmp/longjmp method (this is + * the normal method of doing things with libpng). REQUIRED unless you + * set up your own error handlers in the png_create_read_struct() earlier. + */ + + if (setjmp(png_jmpbuf(png_ptr))) + { + /* Free all of the memory associated with the png_ptr and info_ptr */ + png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); + fclose(fp); + /* If we get here, we had a problem reading the file */ + return (ERROR); + } + + /* One of the following I/O initialization methods is REQUIRED */ +#ifdef streams /* PNG file I/O method 1 */ + /* Set up the input control if you are using standard C streams */ + png_init_io(png_ptr, fp); + +#else no_streams /* PNG file I/O method 2 */ + /* If you are using replacement read functions, instead of calling + * png_init_io() here you would call: + */ + png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn); + /* where user_io_ptr is a structure you want available to the callbacks */ +#endif no_streams /* Use only one I/O method! */ + + /* If we have already read some of the signature */ + png_set_sig_bytes(png_ptr, sig_read); + +#ifdef hilevel + /* + * If you have enough memory to read in the entire image at once, + * and you need to specify only transforms that can be controlled + * with one of the PNG_TRANSFORM_* bits (this presently excludes + * dithering, filling, setting background, and doing gamma + * adjustment), then you can read the entire image (including + * pixels) into the info structure with this call: + */ + png_read_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); +#else + /* OK, you're doing it the hard way, with the lower-level functions */ + + /* The call to png_read_info() gives us all of the information from the + * PNG file before the first IDAT (image data chunk). REQUIRED + */ + png_read_info(png_ptr, info_ptr); + + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, + &interlace_type, int_p_NULL, int_p_NULL); + +/* Set up the data transformations you want. Note that these are all + * optional. Only call them if you want/need them. Many of the + * transformations only work on specific types of images, and many + * are mutually exclusive. + */ + + /* tell libpng to strip 16 bit/color files down to 8 bits/color */ + png_set_strip_16(png_ptr); + + /* Strip alpha bytes from the input data without combining with the + * background (not recommended). + */ + png_set_strip_alpha(png_ptr); + + /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single + * byte into separate bytes (useful for paletted and grayscale images). + */ + png_set_packing(png_ptr); + + /* Change the order of packed pixels to least significant bit first + * (not useful if you are using png_set_packing). */ + png_set_packswap(png_ptr); + + /* Expand paletted colors into true RGB triplets */ + if (color_type == PNG_COLOR_TYPE_PALETTE) + png_set_palette_to_rgb(png_ptr); + + /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ + if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) + png_set_gray_1_2_4_to_8(png_ptr); + + /* Expand paletted or RGB images with transparency to full alpha channels + * so the data will be available as RGBA quartets. + */ + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) + png_set_tRNS_to_alpha(png_ptr); + + /* Set the background color to draw transparent and alpha images over. + * It is possible to set the red, green, and blue components directly + * for paletted images instead of supplying a palette index. Note that + * even if the PNG file supplies a background, you are not required to + * use it - you should use the (solid) application background if it has one. + */ + + png_color_16 my_background, *image_background; + + if (png_get_bKGD(png_ptr, info_ptr, &image_background)) + png_set_background(png_ptr, image_background, + PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); + else + png_set_background(png_ptr, &my_background, + PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); + + /* Some suggestions as to how to get a screen gamma value */ + + /* Note that screen gamma is the display_exponent, which includes + * the CRT_exponent and any correction for viewing conditions */ + if (/* We have a user-defined screen gamma value */) + { + screen_gamma = user-defined screen_gamma; + } + /* This is one way that applications share the same screen gamma value */ + else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL) + { + screen_gamma = atof(gamma_str); + } + /* If we don't have another value */ + else + { + screen_gamma = 2.2; /* A good guess for a PC monitors in a dimly + lit room */ + screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */ + } + + /* Tell libpng to handle the gamma conversion for you. The final call + * is a good guess for PC generated images, but it should be configurable + * by the user at run time by the user. It is strongly suggested that + * your application support gamma correction. + */ + + int intent; + + if (png_get_sRGB(png_ptr, info_ptr, &intent)) + png_set_gamma(png_ptr, screen_gamma, 0.45455); + else + { + double image_gamma; + if (png_get_gAMA(png_ptr, info_ptr, &image_gamma)) + png_set_gamma(png_ptr, screen_gamma, image_gamma); + else + png_set_gamma(png_ptr, screen_gamma, 0.45455); + } + + /* Dither RGB files down to 8 bit palette or reduce palettes + * to the number of colors available on your screen. + */ + if (color_type & PNG_COLOR_MASK_COLOR) + { + int num_palette; + png_colorp palette; + + /* This reduces the image to the application supplied palette */ + if (/* we have our own palette */) + { + /* An array of colors to which the image should be dithered */ + png_color std_color_cube[MAX_SCREEN_COLORS]; + + png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS, + MAX_SCREEN_COLORS, png_uint_16p_NULL, 0); + } + /* This reduces the image to the palette supplied in the file */ + else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) + { + png_uint_16p histogram = NULL; + + png_get_hIST(png_ptr, info_ptr, &histogram); + + png_set_dither(png_ptr, palette, num_palette, + max_screen_colors, histogram, 0); + } + } + + /* invert monochrome files to have 0 as white and 1 as black */ + png_set_invert_mono(png_ptr); + + /* If you want to shift the pixel values from the range [0,255] or + * [0,65535] to the original [0,7] or [0,31], or whatever range the + * colors were originally in: + */ + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) + { + png_color_8p sig_bit; + + png_get_sBIT(png_ptr, info_ptr, &sig_bit); + png_set_shift(png_ptr, sig_bit); + } + + /* flip the RGB pixels to BGR (or RGBA to BGRA) */ + if (color_type & PNG_COLOR_MASK_COLOR) + png_set_bgr(png_ptr); + + /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ + png_set_swap_alpha(png_ptr); + + /* swap bytes of 16 bit files to least significant byte first */ + png_set_swap(png_ptr); + + /* Add filler (or alpha) byte (before/after each RGB triplet) */ + png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); + + /* Turn on interlace handling. REQUIRED if you are not using + * png_read_image(). To see how to handle interlacing passes, + * see the png_read_row() method below: + */ + number_passes = png_set_interlace_handling(png_ptr); + + /* Optional call to gamma correct and add the background to the palette + * and update info structure. REQUIRED if you are expecting libpng to + * update the palette for you (ie you selected such a transform above). + */ + png_read_update_info(png_ptr, info_ptr); + + /* Allocate the memory to hold the image using the fields of info_ptr. */ + + /* The easiest way to read the image: */ + png_bytep row_pointers[height]; + + for (row = 0; row < height; row++) + { + row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr, + info_ptr)); + } + + /* Now it's time to read the image. One of these methods is REQUIRED */ +#ifdef entire /* Read the entire image in one go */ + png_read_image(png_ptr, row_pointers); + +#else no_entire /* Read the image one or more scanlines at a time */ + /* The other way to read images - deal with interlacing: */ + + for (pass = 0; pass < number_passes; pass++) + { +#ifdef single /* Read the image a single row at a time */ + for (y = 0; y < height; y++) + { + png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, 1); + } + +#else no_single /* Read the image several rows at a time */ + for (y = 0; y < height; y += number_of_rows) + { +#ifdef sparkle /* Read the image using the "sparkle" effect. */ + png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, + number_of_rows); +#else no_sparkle /* Read the image using the "rectangle" effect */ + png_read_rows(png_ptr, png_bytepp_NULL, &row_pointers[y], + number_of_rows); +#endif no_sparkle /* use only one of these two methods */ + } + + /* if you want to display the image after every pass, do + so here */ +#endif no_single /* use only one of these two methods */ + } +#endif no_entire /* use only one of these two methods */ + + /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ + png_read_end(png_ptr, info_ptr); +#endif hilevel + + /* At this point you have read the entire image */ + + /* clean up after the read, and free any memory allocated - REQUIRED */ + png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); + + /* close the file */ + fclose(fp); + + /* that's it */ + return (OK); +} + +/* progressively read a file */ + +int +initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr) +{ + /* Create and initialize the png_struct with the desired error handler + * functions. If you want to use the default stderr and longjump method, + * you can supply NULL for the last three parameters. We also check that + * the library version is compatible in case we are using dynamically + * linked libraries. + */ + *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, + png_voidp user_error_ptr, user_error_fn, user_warning_fn); + + if (*png_ptr == NULL) + { + *info_ptr = NULL; + return (ERROR); + } + + *info_ptr = png_create_info_struct(png_ptr); + + if (*info_ptr == NULL) + { + png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); + return (ERROR); + } + + if (setjmp(png_jmpbuf((*png_ptr)))) + { + png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); + return (ERROR); + } + + /* This one's new. You will need to provide all three + * function callbacks, even if you aren't using them all. + * If you aren't using all functions, you can specify NULL + * parameters. Even when all three functions are NULL, + * you need to call png_set_progressive_read_fn(). + * These functions shouldn't be dependent on global or + * static variables if you are decoding several images + * simultaneously. You should store stream specific data + * in a separate struct, given as the second parameter, + * and retrieve the pointer from inside the callbacks using + * the function png_get_progressive_ptr(png_ptr). + */ + png_set_progressive_read_fn(*png_ptr, (void *)stream_data, + info_callback, row_callback, end_callback); + + return (OK); +} + +int +process_data(png_structp *png_ptr, png_infop *info_ptr, + png_bytep buffer, png_uint_32 length) +{ + if (setjmp(png_jmpbuf((*png_ptr)))) + { + /* Free the png_ptr and info_ptr memory on error */ + png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); + return (ERROR); + } + + /* This one's new also. Simply give it chunks of data as + * they arrive from the data stream (in order, of course). + * On Segmented machines, don't give it any more than 64K. + * The library seems to run fine with sizes of 4K, although + * you can give it much less if necessary (I assume you can + * give it chunks of 1 byte, but I haven't tried with less + * than 256 bytes yet). When this function returns, you may + * want to display any rows that were generated in the row + * callback, if you aren't already displaying them there. + */ + png_process_data(*png_ptr, *info_ptr, buffer, length); + return (OK); +} + +info_callback(png_structp png_ptr, png_infop info) +{ +/* do any setup here, including setting any of the transformations + * mentioned in the Reading PNG files section. For now, you _must_ + * call either png_start_read_image() or png_read_update_info() + * after all the transformations are set (even if you don't set + * any). You may start getting rows before png_process_data() + * returns, so this is your last chance to prepare for that. + */ +} + +row_callback(png_structp png_ptr, png_bytep new_row, + png_uint_32 row_num, int pass) +{ +/* + * This function is called for every row in the image. If the + * image is interlaced, and you turned on the interlace handler, + * this function will be called for every row in every pass. + * + * In this function you will receive a pointer to new row data from + * libpng called new_row that is to replace a corresponding row (of + * the same data format) in a buffer allocated by your application. + * + * The new row data pointer new_row may be NULL, indicating there is + * no new data to be replaced (in cases of interlace loading). + * + * If new_row is not NULL then you need to call + * png_progressive_combine_row() to replace the corresponding row as + * shown below: + */ + /* Check if row_num is in bounds. */ + if((row_num >= 0) && (row_num < height)) + { + /* Get pointer to corresponding row in our + * PNG read buffer. + */ + png_bytep old_row = ((png_bytep *)our_data)[row_num]; + + /* If both rows are allocated then copy the new row + * data to the corresponding row data. + */ + if((old_row != NULL) && (new_row != NULL)) + png_progressive_combine_row(png_ptr, old_row, new_row); + } +/* + * The rows and passes are called in order, so you don't really + * need the row_num and pass, but I'm supplying them because it + * may make your life easier. + * + * For the non-NULL rows of interlaced images, you must call + * png_progressive_combine_row() passing in the new row and the + * old row, as demonstrated above. You can call this function for + * NULL rows (it will just return) and for non-interlaced images + * (it just does the png_memcpy for you) if it will make the code + * easier. Thus, you can just do this for all cases: + */ + + png_progressive_combine_row(png_ptr, old_row, new_row); + +/* where old_row is what was displayed for previous rows. Note + * that the first pass (pass == 0 really) will completely cover + * the old row, so the rows do not have to be initialized. After + * the first pass (and only for interlaced images), you will have + * to pass the current row as new_row, and the function will combine + * the old row and the new row. + */ +} + +end_callback(png_structp png_ptr, png_infop info) +{ +/* this function is called when the whole image has been read, + * including any chunks after the image (up to and including + * the IEND). You will usually have the same info chunk as you + * had in the header, although some data may have been added + * to the comments and time fields. + * + * Most people won't do much here, perhaps setting a flag that + * marks the image as finished. + */ +} + +/* write a png file */ +void write_png(char *file_name /* , ... other image information ... */) +{ + FILE *fp; + png_structp png_ptr; + png_infop info_ptr; + png_colorp palette; + + /* open the file */ + fp = fopen(file_name, "wb"); + if (fp == NULL) + return (ERROR); + + /* Create and initialize the png_struct with the desired error handler + * functions. If you want to use the default stderr and longjump method, + * you can supply NULL for the last three parameters. We also check that + * the library version is compatible with the one used at compile time, + * in case we are using dynamically linked libraries. REQUIRED. + */ + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, + png_voidp user_error_ptr, user_error_fn, user_warning_fn); + + if (png_ptr == NULL) + { + fclose(fp); + return (ERROR); + } + + /* Allocate/initialize the image information data. REQUIRED */ + info_ptr = png_create_info_struct(png_ptr); + if (info_ptr == NULL) + { + fclose(fp); + png_destroy_write_struct(&png_ptr, png_infopp_NULL); + return (ERROR); + } + + /* Set error handling. REQUIRED if you aren't supplying your own + * error handling functions in the png_create_write_struct() call. + */ + if (setjmp(png_jmpbuf(png_ptr))) + { + /* If we get here, we had a problem reading the file */ + fclose(fp); + png_destroy_write_struct(&png_ptr, &info_ptr); + return (ERROR); + } + + /* One of the following I/O initialization functions is REQUIRED */ +#ifdef streams /* I/O initialization method 1 */ + /* set up the output control if you are using standard C streams */ + png_init_io(png_ptr, fp); +#else no_streams /* I/O initialization method 2 */ + /* If you are using replacement read functions, instead of calling + * png_init_io() here you would call */ + png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn, + user_IO_flush_function); + /* where user_io_ptr is a structure you want available to the callbacks */ +#endif no_streams /* only use one initialization method */ + +#ifdef hilevel + /* This is the easy way. Use it if you already have all the + * image info living info in the structure. You could "|" many + * PNG_TRANSFORM flags into the png_transforms integer here. + */ + png_write_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); +#else + /* This is the hard way */ + + /* Set the image information here. Width and height are up to 2^31, + * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on + * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY, + * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB, + * or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or + * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST + * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED + */ + png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???, + PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + + /* set the palette if there is one. REQUIRED for indexed-color images */ + palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH + * png_sizeof (png_color)); + /* ... set palette colors ... */ + png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); + /* You must not free palette here, because png_set_PLTE only makes a link to + the palette that you malloced. Wait until you are about to destroy + the png structure. */ + + /* optional significant bit chunk */ + /* if we are dealing with a grayscale image then */ + sig_bit.gray = true_bit_depth; + /* otherwise, if we are dealing with a color image then */ + sig_bit.red = true_red_bit_depth; + sig_bit.green = true_green_bit_depth; + sig_bit.blue = true_blue_bit_depth; + /* if the image has an alpha channel then */ + sig_bit.alpha = true_alpha_bit_depth; + png_set_sBIT(png_ptr, info_ptr, sig_bit); + + + /* Optional gamma chunk is strongly suggested if you have any guess + * as to the correct gamma of the image. + */ + png_set_gAMA(png_ptr, info_ptr, gamma); + + /* Optionally write comments into the image */ + text_ptr[0].key = "Title"; + text_ptr[0].text = "Mona Lisa"; + text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr[1].key = "Author"; + text_ptr[1].text = "Leonardo DaVinci"; + text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr[2].key = "Description"; + text_ptr[2].text = ""; + text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt; +#ifdef PNG_iTXt_SUPPORTED + text_ptr[0].lang = NULL; + text_ptr[1].lang = NULL; + text_ptr[2].lang = NULL; +#endif + png_set_text(png_ptr, info_ptr, text_ptr, 3); + + /* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */ + /* note that if sRGB is present the gAMA and cHRM chunks must be ignored + * on read and must be written in accordance with the sRGB profile */ + + /* Write the file header information. REQUIRED */ + png_write_info(png_ptr, info_ptr); + + /* If you want, you can write the info in two steps, in case you need to + * write your private chunk ahead of PLTE: + * + * png_write_info_before_PLTE(write_ptr, write_info_ptr); + * write_my_chunk(); + * png_write_info(png_ptr, info_ptr); + * + * However, given the level of known- and unknown-chunk support in 1.1.0 + * and up, this should no longer be necessary. + */ + + /* Once we write out the header, the compression type on the text + * chunks gets changed to PNG_TEXT_COMPRESSION_NONE_WR or + * PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again + * at the end. + */ + + /* set up the transformations you want. Note that these are + * all optional. Only call them if you want them. + */ + + /* invert monochrome pixels */ + png_set_invert_mono(png_ptr); + + /* Shift the pixels up to a legal bit depth and fill in + * as appropriate to correctly scale the image. + */ + png_set_shift(png_ptr, &sig_bit); + + /* pack pixels into bytes */ + png_set_packing(png_ptr); + + /* swap location of alpha bytes from ARGB to RGBA */ + png_set_swap_alpha(png_ptr); + + /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into + * RGB (4 channels -> 3 channels). The second parameter is not used. + */ + png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); + + /* flip BGR pixels to RGB */ + png_set_bgr(png_ptr); + + /* swap bytes of 16-bit files to most significant byte first */ + png_set_swap(png_ptr); + + /* swap bits of 1, 2, 4 bit packed pixel formats */ + png_set_packswap(png_ptr); + + /* turn on interlace handling if you are not using png_write_image() */ + if (interlacing) + number_passes = png_set_interlace_handling(png_ptr); + else + number_passes = 1; + + /* The easiest way to write the image (you may have a different memory + * layout, however, so choose what fits your needs best). You need to + * use the first method if you aren't handling interlacing yourself. + */ + png_uint_32 k, height, width; + png_byte image[height][width*bytes_per_pixel]; + png_bytep row_pointers[height]; + + if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) + png_error (png_ptr, "Image is too tall to process in memory"); + + for (k = 0; k < height; k++) + row_pointers[k] = image + k*width*bytes_per_pixel; + + /* One of the following output methods is REQUIRED */ +#ifdef entire /* write out the entire image data in one call */ + png_write_image(png_ptr, row_pointers); + + /* the other way to write the image - deal with interlacing */ + +#else no_entire /* write out the image data by one or more scanlines */ + /* The number of passes is either 1 for non-interlaced images, + * or 7 for interlaced images. + */ + for (pass = 0; pass < number_passes; pass++) + { + /* Write a few rows at a time. */ + png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows); + + /* If you are only writing one row at a time, this works */ + for (y = 0; y < height; y++) + { + png_write_rows(png_ptr, &row_pointers[y], 1); + } + } +#endif no_entire /* use only one output method */ + + /* You can write optional chunks like tEXt, zTXt, and tIME at the end + * as well. Shouldn't be necessary in 1.1.0 and up as all the public + * chunks are supported and you can use png_set_unknown_chunks() to + * register unknown chunks into the info structure to be written out. + */ + + /* It is REQUIRED to call this to finish writing the rest of the file */ + png_write_end(png_ptr, info_ptr); +#endif hilevel + + /* If you png_malloced a palette, free it here (don't free info_ptr->palette, + as recommended in versions 1.0.5m and earlier of this example; if + libpng mallocs info_ptr->palette, libpng will free it). If you + allocated it with malloc() instead of png_malloc(), use free() instead + of png_free(). */ + png_free(png_ptr, palette); + palette=NULL; + + /* Similarly, if you png_malloced any data that you passed in with + png_set_something(), such as a hist or trans array, free it here, + when you can be sure that libpng is through with it. */ + png_free(png_ptr, trans); + trans=NULL; + + /* clean up after the write, and free any memory allocated */ + png_destroy_write_struct(&png_ptr, &info_ptr); + + /* close the file */ + fclose(fp); + + /* that's it */ + return (OK); +} + +#endif /* if 0 */ diff --git a/src/dep/src/irrlicht/libpng/libpng-1.2.16.txt b/src/dep/src/irrlicht/libpng/libpng-1.2.16.txt index 0b94887..bc8aa76 100644 --- a/src/dep/src/irrlicht/libpng/libpng-1.2.16.txt +++ b/src/dep/src/irrlicht/libpng/libpng-1.2.16.txt @@ -1,2972 +1,2972 @@ -libpng.txt - A description on how to use and modify libpng - - libpng version 1.2.16 - January 31, 2007 - Updated and distributed by Glenn Randers-Pehrson - - Copyright (c) 1998-2005 Glenn Randers-Pehrson - For conditions of distribution and use, see copyright - notice in png.h. - - based on: - - libpng 1.0 beta 6 version 0.96 May 28, 1997 - Updated and distributed by Andreas Dilger - Copyright (c) 1996, 1997 Andreas Dilger - - libpng 1.0 beta 2 - version 0.88 January 26, 1996 - For conditions of distribution and use, see copyright - notice in png.h. Copyright (c) 1995, 1996 Guy Eric - Schalnat, Group 42, Inc. - - Updated/rewritten per request in the libpng FAQ - Copyright (c) 1995, 1996 Frank J. T. Wojcik - December 18, 1995 & January 20, 1996 - -I. Introduction - -This file describes how to use and modify the PNG reference library -(known as libpng) for your own use. There are five sections to this -file: introduction, structures, reading, writing, and modification and -configuration notes for various special platforms. In addition to this -file, example.c is a good starting point for using the library, as -it is heavily commented and should include everything most people -will need. We assume that libpng is already installed; see the -INSTALL file for instructions on how to install libpng. - -Libpng was written as a companion to the PNG specification, as a way -of reducing the amount of time and effort it takes to support the PNG -file format in application programs. - -The PNG specification (second edition), November 2003, is available as -a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at - - -The PNG-1.0 specification is available -as RFC 2083 and as a -W3C Recommendation . Some -additional chunks are described in the special-purpose public chunks -documents at . - -Other information -about PNG, and the latest version of libpng, can be found at the PNG home -page, . - -Most users will not have to modify the library significantly; advanced -users may want to modify it more. All attempts were made to make it as -complete as possible, while keeping the code easy to understand. -Currently, this library only supports C. Support for other languages -is being considered. - -Libpng has been designed to handle multiple sessions at one time, -to be easily modifiable, to be portable to the vast majority of -machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy -to use. The ultimate goal of libpng is to promote the acceptance of -the PNG file format in whatever way possible. While there is still -work to be done (see the TODO file), libpng should cover the -majority of the needs of its users. - -Libpng uses zlib for its compression and decompression of PNG files. -Further information about zlib, and the latest version of zlib, can -be found at the zlib home page, . -The zlib compression utility is a general purpose utility that is -useful for more than PNG files, and can be used without libpng. -See the documentation delivered with zlib for more details. -You can usually find the source files for the zlib utility wherever you -find the libpng source files. - -Libpng is thread safe, provided the threads are using different -instances of the structures. Each thread should have its own -png_struct and png_info instances, and thus its own image. -Libpng does not protect itself against two threads using the -same instance of a structure. Note: thread safety may be defeated -by use of some of the MMX assembler code in pnggccrd.c, which is only -compiled when the user defines PNG_THREAD_UNSAFE_OK. - -II. Structures - -There are two main structures that are important to libpng, png_struct -and png_info. The first, png_struct, is an internal structure that -will not, for the most part, be used by a user except as the first -variable passed to every libpng function call. - -The png_info structure is designed to provide information about the -PNG file. At one time, the fields of png_info were intended to be -directly accessible to the user. However, this tended to cause problems -with applications using dynamically loaded libraries, and as a result -a set of interface functions for png_info (the png_get_*() and png_set_*() -functions) was developed. The fields of png_info are still available for -older applications, but it is suggested that applications use the new -interfaces if at all possible. - -Applications that do make direct access to the members of png_struct (except -for png_ptr->jmpbuf) must be recompiled whenever the library is updated, -and applications that make direct access to the members of png_info must -be recompiled if they were compiled or loaded with libpng version 1.0.6, -in which the members were in a different order. In version 1.0.7, the -members of the png_info structure reverted to the old order, as they were -in versions 0.97c through 1.0.5. Starting with version 2.0.0, both -structures are going to be hidden, and the contents of the structures will -only be accessible through the png_get/png_set functions. - -The png.h header file is an invaluable reference for programming with libpng. -And while I'm on the topic, make sure you include the libpng header file: - -#include - -III. Reading - -We'll now walk you through the possible functions to call when reading -in a PNG file sequentially, briefly explaining the syntax and purpose -of each one. See example.c and png.h for more detail. While -progressive reading is covered in the next section, you will still -need some of the functions discussed in this section to read a PNG -file. - -Setup - -You will want to do the I/O initialization(*) before you get into libpng, -so if it doesn't work, you don't have much to undo. Of course, you -will also want to insure that you are, in fact, dealing with a PNG -file. Libpng provides a simple check to see if a file is a PNG file. -To use it, pass in the first 1 to 8 bytes of the file to the function -png_sig_cmp(), and it will return 0 if the bytes match the corresponding -bytes of the PNG signature, or nonzero otherwise. Of course, the more bytes -you pass in, the greater the accuracy of the prediction. - -If you are intending to keep the file pointer open for use in libpng, -you must ensure you don't read more than 8 bytes from the beginning -of the file, and you also have to make a call to png_set_sig_bytes_read() -with the number of bytes you read from the beginning. Libpng will -then only check the bytes (if any) that your program didn't read. - -(*): If you are not using the standard I/O functions, you will need -to replace them with custom functions. See the discussion under -Customizing libpng. - - - FILE *fp = fopen(file_name, "rb"); - if (!fp) - { - return (ERROR); - } - fread(header, 1, number, fp); - is_png = !png_sig_cmp(header, 0, number); - if (!is_png) - { - return (NOT_PNG); - } - - -Next, png_struct and png_info need to be allocated and initialized. In -order to ensure that the size of these structures is correct even with a -dynamically linked libpng, there are functions to initialize and -allocate the structures. We also pass the library version, optional -pointers to error handling functions, and a pointer to a data struct for -use by the error functions, if necessary (the pointer and functions can -be NULL if the default error handlers are to be used). See the section -on Changes to Libpng below regarding the old initialization functions. -The structure allocation functions quietly return NULL if they fail to -create the structure, so your application should check for that. - - png_structp png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, - (png_infopp)NULL, (png_infopp)NULL); - return (ERROR); - } - - png_infop end_info = png_create_info_struct(png_ptr); - if (!end_info) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_read_struct_2() instead of png_create_read_struct(): - - png_structp png_ptr = png_create_read_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -The error handling routines passed to png_create_read_struct() -and the memory alloc/free routines passed to png_create_struct_2() -are only necessary if you are not using the libpng supplied error -handling and memory alloc/free functions. - -When libpng encounters an error, it expects to longjmp back -to your routine. Therefore, you will need to call setjmp and pass -your png_jmpbuf(png_ptr). If you read the file from different -routines, you will need to update the jmpbuf field every time you enter -a new routine that will call a png_*() function. - -See your documentation of setjmp/longjmp for your compiler for more -information on setjmp/longjmp. See the discussion on libpng error -handling in the Customizing Libpng section below for more information -on the libpng error handling. If an error occurs, and libpng longjmp's -back to your setjmp, you will want to call png_destroy_read_struct() to -free any memory. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - fclose(fp); - return (ERROR); - } - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the input code. The default for libpng is to -use the C function fread(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. If you wish to handle reading data in another -way, you need not call the png_init_io() function, but you must then -implement the libpng I/O methods discussed in the Customizing Libpng -section below. - - png_init_io(png_ptr, fp); - -If you had previously opened the file and read any of the signature from -the beginning in order to see if this was a PNG file, you need to let -libpng know that there are some bytes missing from the start of the file. - - png_set_sig_bytes(png_ptr, number); - -Setting up callback code - -You can set up a callback function to handle any unknown chunks in the -input stream. You must supply the function - - read_chunk_callback(png_ptr ptr, - png_unknown_chunkp chunk); - { - /* The unknown chunk structure contains your - chunk data: */ - png_byte name[5]; - png_byte *data; - png_size_t size; - /* Note that libpng has already taken care of - the CRC handling */ - - /* put your code here. Return one of the - following: */ - - return (-n); /* chunk had an error */ - return (0); /* did not recognize */ - return (n); /* success */ - } - -(You can give your function another name that you like instead of -"read_chunk_callback") - -To inform libpng about your function, use - - png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, - read_chunk_callback); - -This names not only the callback function, but also a user pointer that -you can retrieve with - - png_get_user_chunk_ptr(png_ptr); - -At this point, you can set up a callback function that will be -called after each row has been read, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void read_row_callback(png_ptr ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "read_row_callback") - -To inform libpng about your function, use - - png_set_read_status_fn(png_ptr, read_row_callback); - -Width and height limits - -The PNG specification allows the width and height of an image to be as -large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. -Since very few applications really need to process such large images, -we have imposed an arbitrary 1-million limit on rows and columns. -Larger images will be rejected immediately with a png_error() call. If -you wish to override this limit, you can use - - png_set_user_limits(png_ptr, width_max, height_max); - -to set your own limits, or use width_max = height_max = 0x7fffffffL -to allow all valid dimensions (libpng may reject some very large images -anyway because of potential buffer overflow conditions). - -You should put this statement after you create the PNG structure and -before calling png_read_info(), png_read_png(), or png_process_data(). -If you need to retrieve the limits that are being applied, use - - width_max = png_get_user_width_max(png_ptr); - height_max = png_get_user_height_max(png_ptr); - -Unknown-chunk handling - -Now you get to set the way the library processes unknown chunks in the -input PNG stream. Both known and unknown chunks will be read. Normal -behavior is that known chunks will be parsed into information in -various info_ptr members; unknown chunks will be discarded. To change -this, you can call: - - png_set_keep_unknown_chunks(png_ptr, keep, - chunk_list, num_chunks); - keep - 0: do not handle as unknown - 1: do not keep - 2: keep only if safe-to-copy - 3: keep even if unsafe-to-copy - You can use these definitions: - PNG_HANDLE_CHUNK_AS_DEFAULT 0 - PNG_HANDLE_CHUNK_NEVER 1 - PNG_HANDLE_CHUNK_IF_SAFE 2 - PNG_HANDLE_CHUNK_ALWAYS 3 - chunk_list - list of chunks affected (a byte string, - five bytes per chunk, NULL or '\0' if - num_chunks is 0) - num_chunks - number of chunks affected; if 0, all - unknown chunks are affected. If nonzero, - only the chunks in the list are affected - -Unknown chunks declared in this way will be saved as raw data onto a -list of png_unknown_chunk structures. If a chunk that is normally -known to libpng is named in the list, it will be handled as unknown, -according to the "keep" directive. If a chunk is named in successive -instances of png_set_keep_unknown_chunks(), the final instance will -take precedence. The IHDR and IEND chunks should not be named in -chunk_list; if they are, libpng will process them normally anyway. - -The high-level read interface - -At this point there are two ways to proceed; through the high-level -read interface, or through a sequence of low-level read operations. -You can use the high-level interface if (a) you are willing to read -the entire image into memory, and (b) the input transformations -you want to do are limited to the following set: - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to - 8 bits - PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel - PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit - samples to bytes - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_EXPAND Perform set_expand() - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - -(This excludes setting a background color, doing gamma transformation, -dithering, and setting filler.) If this is the case, simply do this: - - png_read_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the bitwise OR of -some set of transformation flags. This call is equivalent to png_read_info(), -followed the set of transformations indicated by the transform mask, -then png_read_image(), and finally png_read_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future input transform.) - -You must use png_transforms and not call any png_set_transform() functions -when you use png_read_png(). - -After you have called png_read_png(), you can retrieve the image data -with - - row_pointers = png_get_rows(png_ptr, info_ptr); - -where row_pointers is an array of pointers to the pixel data for each row: - - png_bytep row_pointers[height]; - -If you know your image size and pixel size ahead of time, you can allocate -row_pointers prior to calling png_read_png() with - - if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) - png_error (png_ptr, - "Image is too tall to process in memory"); - if (width > PNG_UINT_32_MAX/pixel_size) - png_error (png_ptr, - "Image is too wide to process in memory"); - row_pointers = png_malloc(png_ptr, - height*png_sizeof(png_bytep)); - for (int i=0; i) and -png_get_(png_ptr, info_ptr, ...) functions return non-zero if the -data has been read, or zero if it is missing. The parameters to the -png_get_ are set directly if they are simple data types, or a pointer -into the info_ptr is returned for any complex types. - - png_get_PLTE(png_ptr, info_ptr, &palette, - &num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_get_gAMA(png_ptr, info_ptr, &gamma); - gamma - the gamma the file is written - at (PNG_INFO_gAMA) - - png_get_sRGB(png_ptr, info_ptr, &srgb_intent); - srgb_intent - the rendering intent (PNG_INFO_sRGB) - The presence of the sRGB chunk - means that the pixel data is in the - sRGB color space. This chunk also - implies specific values of gAMA and - cHRM. - - png_get_iCCP(png_ptr, info_ptr, &name, - &compression_type, &profile, &proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, - red, green, and blue channels, - whichever are appropriate for the - given color type (png_color_16) - - png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, - &trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_get_hIST(png_ptr, info_ptr, &hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_get_tIME(png_ptr, info_ptr, &mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_get_bKGD(png_ptr, info_ptr, &background); - background - background color (PNG_VALID_bKGD) - valid 16-bit red, green and blue - values, regardless of color_type - - num_comments = png_get_text(png_ptr, info_ptr, - &text_ptr, &num_text); - num_comments - number of comments - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (empty - string for unknown). - text_ptr[i].lang_key - keyword in UTF-8 - (empty string for unknown). - num_text - number of comments (same as - num_comments; you can put NULL here - to avoid the duplication) - Note while png_set_text() will accept text, language, - and translated keywords that can be NULL pointers, the - structure returned by png_get_text will always contain - regular zero-terminated C strings. They might be - empty strings but they will never be NULL pointers. - - num_spalettes = png_get_sPLT(png_ptr, info_ptr, - &palette_ptr); - palette_ptr - array of palette structures holding - contents of one or more sPLT chunks - read. - num_spalettes - number of sPLT chunks read. - - png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, - &unit_type); - offset_x - positive offset from the left edge - of the screen - offset_y - positive offset from the top edge - of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, - &unit_type); - res_x - pixels/unit physical resolution in - x direction - res_y - pixels/unit physical resolution in - x direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_get_sCAL(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - num_unknown_chunks = png_get_unknown_chunks(png_ptr, - info_ptr, &unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position of chunk in file - - The value of "i" corresponds to the order in which the - chunks were read from the PNG file or inserted with the - png_set_unknown_chunks() function. - -The data from the pHYs chunk can be retrieved in several convenient -forms: - - res_x = png_get_x_pixels_per_meter(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_meter(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_meter(png_ptr, - info_ptr) - res_x = png_get_x_pixels_per_inch(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_inch(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_inch(png_ptr, - info_ptr) - aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, - info_ptr) - - (Each of these returns 0 [signifying "unknown"] if - the data is not present or if res_x is 0; - res_x_and_y is 0 if res_x != res_y) - -The data from the oFFs chunk can be retrieved in several convenient -forms: - - x_offset = png_get_x_offset_microns(png_ptr, info_ptr); - y_offset = png_get_y_offset_microns(png_ptr, info_ptr); - x_offset = png_get_x_offset_inches(png_ptr, info_ptr); - y_offset = png_get_y_offset_inches(png_ptr, info_ptr); - - (Each of these returns 0 [signifying "unknown" if both - x and y are 0] if the data is not present or if the - chunk is present but the unit is the pixel) - -For more information, see the png_info definition in png.h and the -PNG specification for chunk contents. Be careful with trusting -rowbytes, as some of the transformations could increase the space -needed to hold a row (expand, filler, gray_to_rgb, etc.). -See png_read_update_info(), below. - -A quick word about text_ptr and num_text. PNG stores comments in -keyword/text pairs, one pair per chunk, with no limit on the number -of text chunks, and a 2^31 byte limit on their size. While there are -suggested keywords, there is no requirement to restrict the use to these -strings. It is strongly suggested that keywords and text be sensible -to humans (that's the point), so don't use abbreviations. Non-printing -symbols are not allowed. See the PNG specification for more details. -There is also no requirement to have text after the keyword. - -Keywords should be limited to 79 Latin-1 characters without leading or -trailing spaces, but non-consecutive spaces are allowed within the -keyword. It is possible to have the same keyword any number of times. -The text_ptr is an array of png_text structures, each holding a -pointer to a language string, a pointer to a keyword and a pointer to -a text string. The text string, language code, and translated -keyword may be empty or NULL pointers. The keyword/text -pairs are put into the array in the order that they are received. -However, some or all of the text chunks may be after the image, so, to -make sure you have read all the text chunks, don't mess with these -until after you read the stuff after the image. This will be -mentioned again below in the discussion that goes with png_read_end(). - -Input transformations - -After you've read the header information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -The colors used for the background and transparency values should be -supplied in the same format/depth as the current image data. They -are stored in the same format/depth as the image data in a bKGD or tRNS -chunk, so this is what libpng expects for this data. The colors are -transformed to keep in sync with the image data when an application -calls the png_read_update_info() routine (see below). - -Data will be decoded into the supplied row buffers packed into bytes -unless the library has been told to transform it into another format. -For example, 4 bit/pixel paletted or grayscale data will be returned -2 pixels/byte with the leftmost pixel in the high-order bits of the -byte, unless png_set_packing() is called. 8-bit RGB data will be stored -in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha() -is called to insert filler bytes, either before or after each RGB triplet. -16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant -byte of the color value first, unless png_set_strip_16() is called to -transform it to regular RGB RGB triplets, or png_set_filler() or -png_set_add alpha() is called to insert filler bytes, either before or -after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can -be modified with -png_set_filler(), png_set_add_alpha(), or png_set_strip_16(). - -The following code transforms grayscale images of less than 8 to 8 bits, -changes paletted images to RGB, and adds a full alpha channel if there is -transparency information in a tRNS chunk. This is most useful on -grayscale images with bit depths of 2 or 4 or if there is a multiple-image -viewing application that wishes to treat all images in the same way. - - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - if (color_type == PNG_COLOR_TYPE_GRAY && - bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr); - - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); - -These three functions are actually aliases for png_set_expand(), added -in libpng version 1.0.4, with the function names expanded to improve code -readability. In some future version they may actually do different -things. - -As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was -added. It expands the sample depth without changing tRNS to alpha. -At the same time, png_set_gray_1_2_4_to_8() was deprecated, and it -will be removed from a future version. - -PNG can have files with 16 bits per channel. If you only can handle -8 bits per channel, this will strip the pixels down to 8 bit. - - if (bit_depth == 16) - png_set_strip_16(png_ptr); - -If, for some reason, you don't need the alpha channel on an image, -and you want to remove it rather than combining it with the background -(but the image author certainly had in mind that you *would* combine -it with the background, so that's what you should probably do): - - if (color_type & PNG_COLOR_MASK_ALPHA) - png_set_strip_alpha(png_ptr); - -In PNG files, the alpha channel in an image -is the level of opacity. If you need the alpha channel in an image to -be the level of transparency instead of opacity, you can invert the -alpha channel (or the tRNS chunk data) after it's read, so that 0 is -fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit -images) is fully transparent, with - - png_set_invert_alpha(png_ptr); - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit -files. This code expands to 1 pixel per byte without changing the -values of the pixels: - - if (bit_depth < 8) - png_set_packing(png_ptr); - -PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels -stored in a PNG image have been "scaled" or "shifted" up to the next -higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to -8 bits/sample in the range [0, 255]). However, it is also possible to -convert the PNG pixel data back to the original bit depth of the image. -This call reduces the pixels back down to the original bit depth: - - png_color_8p sig_bit; - - if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) - png_set_shift(png_ptr, sig_bit); - -PNG files store 3-color pixels in red, green, blue order. This code -changes the storage of the pixels to blue, green, red: - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_bgr(png_ptr); - -PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them -into 4 or 8 bytes for windowing systems that need them in this format: - - if (color_type == PNG_COLOR_TYPE_RGB) - png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE); - -where "filler" is the 8 or 16-bit number to fill with, and the location is -either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether -you want the filler before the RGB or after. This transformation -does not affect images that already have full alpha channels. To add an -opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which -will generate RGBA pixels. - -Note that png_set_filler() does not change the color type. If you want -to do that, you can add a true alpha channel with - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY) - png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER); - -where "filler" contains the alpha value to assign to each pixel. -This function was added in libpng-1.2.7. - -If you are reading an image with an alpha channel, and you need the -data as ARGB instead of the normal PNG format RGBA: - - if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_swap_alpha(png_ptr); - -For some uses, you may want a grayscale image to be represented as -RGB. This code will do that conversion: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - -Conversely, you can convert an RGB or RGBA image to grayscale or grayscale -with alpha. - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_rgb_to_gray_fixed(png_ptr, error_action, - int red_weight, int green_weight); - - error_action = 1: silently do the conversion - error_action = 2: issue a warning if the original - image has any pixel where - red != green or red != blue - error_action = 3: issue an error and abort the - conversion if the original - image has any pixel where - red != green or red != blue - - red_weight: weight of red component times 100000 - green_weight: weight of green component times 100000 - If either weight is negative, default - weights (21268, 71514) are used. - -If you have set error_action = 1 or 2, you can -later check whether the image really was gray, after processing -the image rows, with the png_get_rgb_to_gray_status(png_ptr) function. -It will return a png_byte that is zero if the image was gray or -1 if there were any non-gray pixels. bKGD and sBIT data -will be silently converted to grayscale, using the green channel -data, regardless of the error_action setting. - -With red_weight+green_weight<=100000, -the normalized graylevel is computed: - - int rw = red_weight * 65536; - int gw = green_weight * 65536; - int bw = 65536 - (rw + gw); - gray = (rw*red + gw*green + bw*blue)/65536; - -The default values approximate those recommended in the Charles -Poynton's Color FAQ, -Copyright (c) 1998-01-04 Charles Poynton - - Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - -Libpng approximates this with - - Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - -which can be expressed with integers as - - Y = (6969 * R + 23434 * G + 2365 * B)/32768 - -The calculation is done in a linear colorspace, if the image gamma -is known. - -If you have a grayscale and you are using png_set_expand_depth(), -png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to -a higher bit-depth, you must either supply the background color as a gray -value at the original file bit-depth (need_expand = 1) or else supply the -background color as an RGB triplet at the final, expanded bit depth -(need_expand = 0). Similarly, if you are reading a paletted image, you -must either supply the background color as a palette index (need_expand = 1) -or as an RGB triplet that may or may not be in the palette (need_expand = 0). - - png_color_16 my_background; - png_color_16p image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - -The png_set_background() function tells libpng to composite images -with alpha or simple transparency against the supplied background -color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid), -you may use this color, or supply another color more suitable for -the current display (e.g., the background color from a web page). You -need to tell libpng whether the color is in the gamma space of the -display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file -(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one -that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't -know why anyone would use this, but it's here). - -To properly display PNG images on any kind of system, the application needs -to know what the display gamma is. Ideally, the user will know this, and -the application will allow them to set it. One method of allowing the user -to set the display gamma separately for each system is to check for a -SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be -correctly set. - -Note that display_gamma is the overall gamma correction required to produce -pleasing results, which depends on the lighting conditions in the surrounding -environment. In a dim or brightly lit room, no compensation other than -the physical gamma exponent of the monitor is needed, while in a dark room -a slightly smaller exponent is better. - - double gamma, screen_gamma; - - if (/* We have a user-defined screen - gamma value */) - { - screen_gamma = user_defined_screen_gamma; - } - /* One way that applications can share the same - screen gamma value */ - else if ((gamma_str = getenv("SCREEN_GAMMA")) - != NULL) - { - screen_gamma = (double)atof(gamma_str); - } - /* If we don't have another value */ - else - { - screen_gamma = 2.2; /* A good guess for a - PC monitor in a bright office or a dim room */ - screen_gamma = 2.0; /* A good guess for a - PC monitor in a dark room */ - screen_gamma = 1.7 or 1.0; /* A good - guess for Mac systems */ - } - -The png_set_gamma() function handles gamma transformations of the data. -Pass both the file gamma and the current screen_gamma. If the file does -not have a gamma value, you can pass one anyway if you have an idea what -it is (usually 0.45455 is a good guess for GIF images on PCs). Note -that file gammas are inverted from screen gammas. See the discussions -on gamma in the PNG specification for an excellent description of what -gamma is, and why all applications should support it. It is strongly -recommended that PNG viewers support gamma correction. - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, screen_gamma, gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - -If you need to reduce an RGB file to a paletted file, or if a paletted -file has more entries then will fit on your screen, png_set_dither() -will do that. Note that this is a simple match dither that merely -finds the closest color available. This should work fairly well with -optimized palettes, and fairly badly with linear color cubes. If you -pass a palette that is larger then maximum_colors, the file will -reduce the number of colors in the palette so it will fit into -maximum_colors. If there is a histogram, it will use it to make -more intelligent choices when reducing the palette. If there is no -histogram, it may not do as good a job. - - if (color_type & PNG_COLOR_MASK_COLOR) - { - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_PLTE)) - { - png_uint_16p histogram = NULL; - - png_get_hIST(png_ptr, info_ptr, - &histogram); - png_set_dither(png_ptr, palette, num_palette, - max_screen_colors, histogram, 1); - } - else - { - png_color std_color_cube[MAX_SCREEN_COLORS] = - { ... colors ... }; - - png_set_dither(png_ptr, std_color_cube, - MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, - NULL,0); - } - } - -PNG files describe monochrome as black being zero and white being one. -The following code will reverse this (make black be one and white be -zero): - - if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY) - png_set_invert_mono(png_ptr); - -This function can also be used to invert grayscale and gray-alpha images: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_invert_mono(png_ptr); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code changes the storage to the -other way (little-endian, i.e. least significant bits first, the -way PCs store them): - - if (bit_depth == 16) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_read_user_transform_fn(png_ptr, - read_transform_fn); - -You must supply the function - - void read_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -after all of the other transformations have been processed. - -You can also set up a pointer to a user structure for use by your -callback function, and you can inform libpng that your transform -function will change the number of channels or bit depth with the -function - - png_set_user_transform_info(png_ptr, user_ptr, - user_depth, user_channels); - -The user's application, not libpng, is responsible for allocating and -freeing any memory required for the user structure. - -You can retrieve the pointer via the function -png_get_user_transform_ptr(). For example: - - voidp read_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -The last thing to handle is interlacing; this is covered in detail below, -but you must call the function here if you want libpng to handle expansion -of the interlaced image. - - number_of_passes = png_set_interlace_handling(png_ptr); - -After setting the transformations, libpng can update your png_info -structure to reflect any transformations you've requested with this -call. This is most useful to update the info structure's rowbytes -field so you can use it to allocate your image memory. This function -will also update your palette with the correct screen_gamma and -background if these have been given with the calls above. - - png_read_update_info(png_ptr, info_ptr); - -After you call png_read_update_info(), you can allocate any -memory you need to hold the image. The row data is simply -raw byte data for all forms of images. As the actual allocation -varies among applications, no example will be given. If you -are allocating one large chunk, you will need to build an -array of pointers to each row, as it will be needed for some -of the functions below. - -Reading image data - -After you've allocated memory, you can read the image data. -The simplest way to do this is in one function call. If you are -allocating enough memory to hold the whole image, you can just -call png_read_image() and libpng will read in all the image data -and put it in the memory area supplied. You will need to pass in -an array of pointers to each row. - -This function automatically handles interlacing, so you don't need -to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_read_rows(). - - png_read_image(png_ptr, row_pointers); - -where row_pointers is: - - png_bytep row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to read in the whole image at once, you can -use png_read_rows() instead. If there is no interlacing (check -interlace_type == PNG_INTERLACE_NONE), this is simple: - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -where row_pointers is the same as in the png_read_image() call. - -If you are doing this just one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - png_read_row(png_ptr, row_pointer, NULL); - -If the file is interlaced (interlace_type != 0 in the IHDR chunk), things -get somewhat harder. The only current (PNG Specification version 1.2) -interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7) -is a somewhat complicated 2D interlace scheme, known as Adam7, that -breaks down an image into seven smaller images of varying size, based -on an 8x8 grid. - -libpng can fill out those images or it can give them to you "as is". -If you want them filled out, there are two ways to do that. The one -mentioned in the PNG specification is to expand each pixel to cover -those pixels that have not been read yet (the "rectangle" method). -This results in a blocky image for the first pass, which gradually -smooths out as more pixels are read. The other method is the "sparkle" -method, where pixels are drawn only in their final locations, with the -rest of the image remaining whatever colors they were initialized to -before the start of the read. The first method usually looks better, -but tends to be slower, as there are more pixels to put in the rows. - -If you don't want libpng to handle the interlacing details, just call -png_read_rows() seven times to read in all seven images. Each of the -images is a valid image by itself, or they can all be combined on an -8x8 grid to form a single image (although if you intend to combine them -you would be far better off using the libpng interlace handling). - -The first pass will return an image 1/8 as wide as the entire image -(every 8th column starting in column 0) and 1/8 as high as the original -(every 8th row starting in row 0), the second will be 1/8 as wide -(starting in column 4) and 1/8 as high (also starting in row 0). The -third pass will be 1/4 as wide (every 4th pixel starting in column 0) and -1/8 as high (every 8th row starting in row 4), and the fourth pass will -be 1/4 as wide and 1/4 as high (every 4th column starting in column 2, -and every 4th row starting in row 0). The fifth pass will return an -image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2), -while the sixth pass will be 1/2 as wide and 1/2 as high as the original -(starting in column 1 and row 0). The seventh and final pass will be as -wide as the original, and 1/2 as high, containing all of the odd -numbered scanlines. Phew! - -If you want libpng to expand the images, call this before calling -png_start_read_image() or png_read_update_info(): - - if (interlace_type == PNG_INTERLACE_ADAM7) - number_of_passes - = png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. -This function can be called even if the file is not interlaced, -where it will return one pass. - -If you are not going to display the image after each pass, but are -going to wait until the entire image is read in, use the sparkle -effect. This effect is faster and the end result of either method -is exactly the same. If you are planning on displaying the image -after each pass, the "rectangle" effect is generally considered the -better looking one. - -If you only want the "sparkle" effect, just call png_read_rows() as -normal, with the third parameter NULL. Make sure you make pass over -the image number_of_passes times, and you don't change the data in the -rows between calls. You can change the locations of the data, just -not the data. Each pass only writes the pixels appropriate for that -pass, and assumes the data from previous passes is still valid. - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -If you only want the first effect (the rectangles), do the same as -before except pass the row buffer in the third parameter, and leave -the second parameter NULL. - - png_read_rows(png_ptr, NULL, row_pointers, - number_of_rows); - -Finishing a sequential read - -After you are finished reading the image through the -low-level interface, you can finish reading the file. If you are -interested in comments or time, which may be stored either before or -after the image data, you should pass the separate png_info struct if -you want to keep the comments from before and after the image -separate. If you are not interested, you can pass NULL. - - png_read_end(png_ptr, end_info); - -When you are done, you can free all memory allocated by libpng like this: - - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the bitwise OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -This function only affects data that has already been allocated. -You can call this function after reading the PNG data but before calling -any png_set_*() functions, to control whether the user or the png_set_*() -function is responsible for freeing any existing data that might be present, -and again after the png_set_*() functions to control whether the user -or png_destroy_*() is supposed to free the data. When the user assumes -responsibility for libpng-allocated data, the application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated your row_pointers in a single block, as suggested above in -the description of the high level read interface, you must not transfer -responsibility for freeing it to the png_set_rows or png_read_destroy function, -because they would also try to free the individual row_pointers[i]. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. - -The png_free_data() function will turn off the "valid" flag for anything -it frees. If you need to turn the flag off for a chunk that was freed by your -application instead of by libpng, you can use - - png_set_invalid(png_ptr, info_ptr, mask); - mask - identifies the chunks to be made invalid, - containing the bitwise OR of one or - more of - PNG_INFO_gAMA, PNG_INFO_sBIT, - PNG_INFO_cHRM, PNG_INFO_PLTE, - PNG_INFO_tRNS, PNG_INFO_bKGD, - PNG_INFO_hIST, PNG_INFO_pHYs, - PNG_INFO_oFFs, PNG_INFO_tIME, - PNG_INFO_pCAL, PNG_INFO_sRGB, - PNG_INFO_iCCP, PNG_INFO_sPLT, - PNG_INFO_sCAL, PNG_INFO_IDAT - -For a more compact example of reading a PNG image, see the file example.c. - -Reading PNG files progressively - -The progressive reader is slightly different then the non-progressive -reader. Instead of calling png_read_info(), png_read_rows(), and -png_read_end(), you make one call to png_process_data(), which calls -callbacks when it has the info, a row, or the end of the image. You -set up these callbacks with png_set_progressive_read_fn(). You don't -have to worry about the input/output functions of libpng, as you are -giving the library the data directly in png_process_data(). I will -assume that you have read the section on reading PNG files above, -so I will only highlight the differences (although I will show -all of the code). - -png_structp png_ptr; -png_infop info_ptr; - - /* An example code fragment of how you would - initialize the progressive reader in your - application. */ - int - initialize_png_reader() - { - png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, (png_infopp)NULL, - (png_infopp)NULL); - return (ERROR); - } - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new. You can provide functions - to be called when the header info is valid, - when each row is completed, and when the image - is finished. If you aren't using all functions, - you can specify NULL parameters. Even when all - three functions are NULL, you need to call - png_set_progressive_read_fn(). You can use - any struct as the user_ptr (cast to a void pointer - for the function call), and retrieve the pointer - from inside the callbacks using the function - - png_get_progressive_ptr(png_ptr); - - which will return a void pointer, which you have - to cast appropriately. - */ - png_set_progressive_read_fn(png_ptr, (void *)user_ptr, - info_callback, row_callback, end_callback); - - return 0; - } - - /* A code fragment that you call as you receive blocks - of data */ - int - process_data(png_bytep buffer, png_uint_32 length) - { - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new also. Simply give it a chunk - of data from the file stream (in order, of - course). On machines with segmented memory - models machines, don't give it any more than - 64K. The library seems to run fine with sizes - of 4K. Although you can give it much less if - necessary (I assume you can give it chunks of - 1 byte, I haven't tried less then 256 bytes - yet). When this function returns, you may - want to display any rows that were generated - in the row callback if you don't already do - so there. - */ - png_process_data(png_ptr, info_ptr, buffer, length); - return 0; - } - - /* This function is called (as set by - png_set_progressive_read_fn() above) when enough data - has been supplied so all of the header has been - read. - */ - void - info_callback(png_structp png_ptr, png_infop info) - { - /* Do any setup here, including setting any of - the transformations mentioned in the Reading - PNG files section. For now, you _must_ call - either png_start_read_image() or - png_read_update_info() after all the - transformations are set (even if you don't set - any). You may start getting rows before - png_process_data() returns, so this is your - last chance to prepare for that. - */ - } - - /* This function is called when each row of image - data is complete */ - void - row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) - { - /* If the image is interlaced, and you turned - on the interlace handler, this function will - be called for every row in every pass. Some - of these rows will not be changed from the - previous pass. When the row is not changed, - the new_row variable will be NULL. The rows - and passes are called in order, so you don't - really need the row_num and pass, but I'm - supplying them because it may make your life - easier. - - For the non-NULL rows of interlaced images, - you must call png_progressive_combine_row() - passing in the row and the old row. You can - call this function for NULL rows (it will just - return) and for non-interlaced images (it just - does the memcpy for you) if it will make the - code easier. Thus, you can just do this for - all cases: - */ - - png_progressive_combine_row(png_ptr, old_row, - new_row); - - /* where old_row is what was displayed for - previously for the row. Note that the first - pass (pass == 0, really) will completely cover - the old row, so the rows do not have to be - initialized. After the first pass (and only - for interlaced images), you will have to pass - the current row, and the function will combine - the old row and the new row. - */ - } - - void - end_callback(png_structp png_ptr, png_infop info) - { - /* This function is called after the whole image - has been read, including any chunks after the - image (up to and including the IEND). You - will usually have the same info chunk as you - had in the header, although some data may have - been added to the comments and time fields. - - Most people won't do much here, perhaps setting - a flag that marks the image as finished. - */ - } - - - -IV. Writing - -Much of this is very similar to reading. However, everything of -importance is repeated here, so you won't have to constantly look -back up in the reading section to understand writing. - -Setup - -You will want to do the I/O initialization before you get into libpng, -so if it doesn't work, you don't have anything to undo. If you are not -using the standard I/O functions, you will need to replace them with -custom writing functions. See the discussion under Customizing libpng. - - FILE *fp = fopen(file_name, "wb"); - if (!fp) - { - return (ERROR); - } - -Next, png_struct and png_info need to be allocated and initialized. -As these can be both relatively large, you may not want to store these -on the stack, unless you have stack space to spare. Of course, you -will want to check if they return NULL. If you are also reading, -you won't want to name your read structure and your write structure -both "png_ptr"; you can call them anything you like, such as -"read_ptr" and "write_ptr". Look at pngtest.c, for example. - - png_structp png_ptr = png_create_write_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_write_struct(&png_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_write_struct_2() instead of png_create_write_struct(): - - png_structp png_ptr = png_create_write_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -After you have these structures, you will need to set up the -error handling. When libpng encounters an error, it expects to -longjmp() back to your routine. Therefore, you will need to call -setjmp() and pass the png_jmpbuf(png_ptr). If you -write the file from different routines, you will need to update -the png_jmpbuf(png_ptr) every time you enter a new routine that will -call a png_*() function. See your documentation of setjmp/longjmp -for your compiler for more information on setjmp/longjmp. See -the discussion on libpng error handling in the Customizing Libpng -section below for more information on the libpng error handling. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(fp); - return (ERROR); - } - ... - return; - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the output code. The default for libpng is to -use the C function fwrite(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. Again, if you wish to handle writing data in -another way, see the discussion on libpng I/O handling in the Customizing -Libpng section below. - - png_init_io(png_ptr, fp); - -If you are embedding your PNG into a datastream such as MNG, and don't -want libpng to write the 8-byte signature, or if you have already -written the signature in your application, use - - png_set_sig_bytes(png_ptr, 8); - -to inform libpng that it should not write a signature. - -Write callbacks - -At this point, you can set up a callback function that will be -called after each row has been written, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void write_row_callback(png_ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "write_row_callback") - -To inform libpng about your function, use - - png_set_write_status_fn(png_ptr, write_row_callback); - -You now have the option of modifying how the compression library will -run. The following functions are mainly for testing, but may be useful -in some cases, like if you need to write PNG files extremely fast and -are willing to give up some compression, or if you want to get the -maximum possible compression at the expense of slower writing. If you -have no special needs in this area, let the library do what it wants by -not calling this function at all, as it has been tuned to deliver a good -speed/compression ratio. The second parameter to png_set_filter() is -the filter method, for which the only valid values are 0 (as of the -July 1999 PNG specification, version 1.2) or 64 (if you are writing -a PNG datastream that is to be embedded in a MNG datastream). The third -parameter is a flag that indicates which filter type(s) are to be tested -for each scanline. See the PNG specification for details on the specific filter -types. - - - /* turn on or off filtering, and/or choose - specific filters. You can use either a single - PNG_FILTER_VALUE_NAME or the bitwise OR of one - or more PNG_FILTER_NAME masks. */ - png_set_filter(png_ptr, 0, - PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | - PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | - PNG_FILTER_UP | PNG_FILTER_VALUE_UP | - PNG_FILTER_AVE | PNG_FILTER_VALUE_AVE | - PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| - PNG_ALL_FILTERS); - -If an application -wants to start and stop using particular filters during compression, -it should start out with all of the filters (to ensure that the previous -row of pixels will be stored in case it's needed later), and then add -and remove them after the start of compression. - -If you are writing a PNG datastream that is to be embedded in a MNG -datastream, the second parameter can be either 0 or 64. - -The png_set_compression_*() functions interface to the zlib compression -library, and should mostly be ignored unless you really know what you are -doing. The only generally useful call is png_set_compression_level() -which changes how much time zlib spends on trying to compress the image -data. See the Compression Library (zlib.h and algorithm.txt, distributed -with zlib) for details on the compression levels. - - /* set the zlib compression level */ - png_set_compression_level(png_ptr, - Z_BEST_COMPRESSION); - - /* set other zlib parameters */ - png_set_compression_mem_level(png_ptr, 8); - png_set_compression_strategy(png_ptr, - Z_DEFAULT_STRATEGY); - png_set_compression_window_bits(png_ptr, 15); - png_set_compression_method(png_ptr, 8); - png_set_compression_buffer_size(png_ptr, 8192) - -extern PNG_EXPORT(void,png_set_zbuf_size) - -Setting the contents of info for output - -You now need to fill in the png_info structure with all the data you -wish to write before the actual image. Note that the only thing you -are allowed to write after the image is the text chunks and the time -chunk (as of PNG Specification 1.2, anyway). See png_write_end() and -the latest PNG specification for more information on that. If you -wish to write them before the image, fill them in now, and flag that -data as being valid. If you want to wait until after the data, don't -fill them until png_write_end(). For all the fields in png_info and -their data types, see png.h. For explanations of what the fields -contain, see the PNG specification. - -Some of the more important parts of the png_info are: - - png_set_IHDR(png_ptr, info_ptr, width, height, - bit_depth, color_type, interlace_type, - compression_type, filter_method) - width - holds the width of the image - in pixels (up to 2^31). - height - holds the height of the image - in pixels (up to 2^31). - bit_depth - holds the bit depth of one of the - image channels. - (valid values are 1, 2, 4, 8, 16 - and depend also on the - color_type. See also significant - bits (sBIT) below). - color_type - describes which color/alpha - channels are present. - PNG_COLOR_TYPE_GRAY - (bit depths 1, 2, 4, 8, 16) - PNG_COLOR_TYPE_GRAY_ALPHA - (bit depths 8, 16) - PNG_COLOR_TYPE_PALETTE - (bit depths 1, 2, 4, 8) - PNG_COLOR_TYPE_RGB - (bit_depths 8, 16) - PNG_COLOR_TYPE_RGB_ALPHA - (bit_depths 8, 16) - - PNG_COLOR_MASK_PALETTE - PNG_COLOR_MASK_COLOR - PNG_COLOR_MASK_ALPHA - - interlace_type - PNG_INTERLACE_NONE or - PNG_INTERLACE_ADAM7 - compression_type - (must be - PNG_COMPRESSION_TYPE_DEFAULT) - filter_method - (must be PNG_FILTER_TYPE_DEFAULT - or, if you are writing a PNG to - be embedded in a MNG datastream, - can also be - PNG_INTRAPIXEL_DIFFERENCING) - - png_set_PLTE(png_ptr, info_ptr, palette, - num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_set_gAMA(png_ptr, info_ptr, gamma); - gamma - the gamma the image was created - at (PNG_INFO_gAMA) - - png_set_sRGB(png_ptr, info_ptr, srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of - the sRGB chunk means that the pixel - data is in the sRGB color space. - This chunk also implies specific - values of gAMA and cHRM. Rendering - intent is the CSS-1 property that - has been defined by the International - Color Consortium - (http://www.color.org). - It can be one of - PNG_sRGB_INTENT_SATURATION, - PNG_sRGB_INTENT_PERCEPTUAL, - PNG_sRGB_INTENT_ABSOLUTE, or - PNG_sRGB_INTENT_RELATIVE. - - - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, - srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of the - sRGB chunk means that the pixel - data is in the sRGB color space. - This function also causes gAMA and - cHRM chunks with the specific values - that are consistent with sRGB to be - written. - - png_set_iCCP(png_ptr, info_ptr, name, compression_type, - profile, proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_set_sBIT(png_ptr, info_ptr, sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, red, - green, and blue channels, whichever are - appropriate for the given color type - (png_color_16) - - png_set_tRNS(png_ptr, info_ptr, trans, num_trans, - trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_set_hIST(png_ptr, info_ptr, hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_set_tIME(png_ptr, info_ptr, mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_set_bKGD(png_ptr, info_ptr, background); - background - background color (PNG_VALID_bKGD) - - png_set_text(png_ptr, info_ptr, text_ptr, num_text); - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be NULL or empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (NULL or - empty for unknown). - text_ptr[i].translated_keyword - keyword in UTF-8 (NULL - or empty for unknown). - num_text - number of comments - - png_set_sPLT(png_ptr, info_ptr, &palette_ptr, - num_spalettes); - palette_ptr - array of png_sPLT_struct structures - to be added to the list of palettes - in the info structure. - num_spalettes - number of palette structures to be - added. - - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, - unit_type); - offset_x - positive offset from the left - edge of the screen - offset_y - positive offset from the top - edge of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, - unit_type); - res_x - pixels/unit physical resolution - in x direction - res_y - pixels/unit physical resolution - in y direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_set_sCAL(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_set_sCAL_s(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, - num_unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position to write chunk in file - 0: do not write chunk - PNG_HAVE_IHDR: before PLTE - PNG_HAVE_PLTE: before IDAT - PNG_AFTER_IDAT: after IDAT - -The "location" member is set automatically according to -what part of the output file has already been written. -You can change its value after calling png_set_unknown_chunks() -as demonstrated in pngtest.c. Within each of the "locations", -the chunks are sequenced according to their position in the -structure (that is, the value of "i", which is the order in which -the chunk was either read from the input file or defined with -png_set_unknown_chunks). - -A quick word about text and num_text. text is an array of png_text -structures. num_text is the number of valid structures in the array. -Each png_text structure holds a language code, a keyword, a text value, -and a compression type. - -The compression types have the same valid numbers as the compression -types of the image data. Currently, the only valid number is zero. -However, you can store text either compressed or uncompressed, unlike -images, which always have to be compressed. So if you don't want the -text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. -Because tEXt and zTXt chunks don't have a language field, if you -specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt -any language code or translated keyword will not be written out. - -Until text gets around 1000 bytes, it is not worth compressing it. -After the text has been written out to the file, the compression type -is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR, -so that it isn't written out again at the end (in case you are calling -png_write_end() with the same struct. - -The keywords that are given in the PNG Specification are: - - Title Short (one line) title or - caption for image - Author Name of image's creator - Description Description of image (possibly long) - Copyright Copyright notice - Creation Time Time of original image creation - (usually RFC 1123 format, see below) - Software Software used to create the image - Disclaimer Legal disclaimer - Warning Warning of nature of content - Source Device used to create the image - Comment Miscellaneous comment; conversion - from other image format - -The keyword-text pairs work like this. Keywords should be short -simple descriptions of what the comment is about. Some typical -keywords are found in the PNG specification, as is some recommendations -on keywords. You can repeat keywords in a file. You can even write -some text before the image and some after. For example, you may want -to put a description of the image before the image, but leave the -disclaimer until after, so viewers working over modem connections -don't have to wait for the disclaimer to go over the modem before -they start seeing the image. Finally, keywords should be full -words, not abbreviations. Keywords and text are in the ISO 8859-1 -(Latin-1) character set (a superset of regular ASCII) and can not -contain NUL characters, and should not contain control or other -unprintable characters. To make the comments widely readable, stick -with basic ASCII, and avoid machine specific character set extensions -like the IBM-PC character set. The keyword must be present, but -you can leave off the text string on non-compressed pairs. -Compressed pairs must have a text string, as only the text string -is compressed anyway, so the compression would be meaningless. - -PNG supports modification time via the png_time structure. Two -conversion routines are provided, png_convert_from_time_t() for -time_t and png_convert_from_struct_tm() for struct tm. The -time_t routine uses gmtime(). You don't have to use either of -these, but if you wish to fill in the png_time structure directly, -you should provide the time in universal time (GMT) if possible -instead of your local time. Note that the year number is the full -year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and -that months start with 1. - -If you want to store the time of the original image creation, you should -use a plain tEXt chunk with the "Creation Time" keyword. This is -necessary because the "creation time" of a PNG image is somewhat vague, -depending on whether you mean the PNG file, the time the image was -created in a non-PNG format, a still photo from which the image was -scanned, or possibly the subject matter itself. In order to facilitate -machine-readable dates, it is recommended that the "Creation Time" -tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), -although this isn't a requirement. Unlike the tIME chunk, the -"Creation Time" tEXt chunk is not expected to be automatically changed -by the software. To facilitate the use of RFC 1123 dates, a function -png_convert_to_rfc1123(png_timep) is provided to convert from PNG -time to an RFC 1123 format string. - -Writing unknown chunks - -You can use the png_set_unknown_chunks function to queue up chunks -for writing. You give it a chunk name, raw data, and a size; that's -all there is to it. The chunks will be written by the next following -png_write_info_before_PLTE, png_write_info, or png_write_end function. -Any chunks previously read into the info structure's unknown-chunk -list will also be written out in a sequence that satisfies the PNG -specification's ordering rules. - -The high-level write interface - -At this point there are two ways to proceed; through the high-level -write interface, or through a sequence of low-level write operations. -You can use the high-level interface if your image data is present -in the info structure. All defined output -transformations are permitted, enabled by the following masks. - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes. - -If you have valid image data in the info structure (you can use -png_set_rows() to put image data in the info structure), simply do this: - - png_write_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the bitwise OR of some set of -transformation flags. This call is equivalent to png_write_info(), -followed the set of transformations indicated by the transform mask, -then png_write_image(), and finally png_write_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future output transform.) - -You must use png_transforms and not call any png_set_transform() functions -when you use png_write_png(). - -The low-level write interface - -If you are going the low-level route instead, you are now ready to -write all the file information up to the actual image data. You do -this with a call to png_write_info(). - - png_write_info(png_ptr, info_ptr); - -Note that there is one transformation you may need to do before -png_write_info(). In PNG files, the alpha channel in an image is the -level of opacity. If your data is supplied as a level of -transparency, you can invert the alpha channel before you write it, so -that 0 is fully transparent and 255 (in 8-bit or paletted images) or -65535 (in 16-bit images) is fully opaque, with - - png_set_invert_alpha(png_ptr); - -This must appear before png_write_info() instead of later with the -other transformations because in the case of paletted images the tRNS -chunk data has to be inverted before the tRNS chunk is written. If -your image is not a paletted image, the tRNS data (which in such cases -represents a single color to be rendered as transparent) won't need to -be changed, and you can safely do this transformation after your -png_write_info() call. - -If you need to write a private chunk that you want to appear before -the PLTE chunk when PLTE is present, you can write the PNG info in -two steps, and insert code to write your own chunk between them: - - png_write_info_before_PLTE(png_ptr, info_ptr); - png_set_unknown_chunks(png_ptr, info_ptr, ...); - png_write_info(png_ptr, info_ptr); - -After you've written the file information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -PNG files store RGB pixels packed into 3 or 6 bytes. This code tells -the library to strip input data that has 4 or 8 bytes per pixel down -to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2 -bytes per pixel). - - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - -where the 0 is unused, and the location is either PNG_FILLER_BEFORE or -PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel -is stored XRGB or RGBX. - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit files. -If the data is supplied at 1 pixel per byte, use this code, which will -correctly pack the pixels into a single byte: - - png_set_packing(png_ptr); - -PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your -data is of another bit depth, you can write an sBIT chunk into the -file so that decoders can recover the original data if desired. - - /* Set the true bit depth of the image data */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit.red = true_bit_depth; - sig_bit.green = true_bit_depth; - sig_bit.blue = true_bit_depth; - } - else - { - sig_bit.gray = true_bit_depth; - } - if (color_type & PNG_COLOR_MASK_ALPHA) - { - sig_bit.alpha = true_bit_depth; - } - - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - -If the data is stored in the row buffer in a bit depth other than -one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG), -this will scale the values to appear to be the correct bit depth as -is required by PNG. - - png_set_shift(png_ptr, &sig_bit); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code would be used if they are -supplied the other way (little-endian, i.e. least significant bits -first, the way PCs store them): - - if (bit_depth > 8) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -PNG files store 3 color pixels in red, green, blue order. This code -would be used if they are supplied as blue, green, red: - - png_set_bgr(png_ptr); - -PNG files describe monochrome as black being zero and white being -one. This code would be used if the pixels are supplied with this reversed -(black being one and white being zero): - - png_set_invert_mono(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_write_user_transform_fn(png_ptr, - write_transform_fn); - -You must supply the function - - void write_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -before any of the other transformations are processed. - -You can also set up a pointer to a user structure for use by your -callback function. - - png_set_user_transform_info(png_ptr, user_ptr, 0, 0); - -The user_channels and user_depth parameters of this function are ignored -when writing; you can set them to zero as shown. - -You can retrieve the pointer via the function png_get_user_transform_ptr(). -For example: - - voidp write_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -It is possible to have libpng flush any pending output, either manually, -or automatically after a certain number of lines have been written. To -flush the output stream a single time call: - - png_write_flush(png_ptr); - -and to have libpng flush the output stream periodically after a certain -number of scanlines have been written, call: - - png_set_flush(png_ptr, nrows); - -Note that the distance between rows is from the last time png_write_flush() -was called, or the first row of the image if it has never been called. -So if you write 50 lines, and then png_set_flush 25, it will flush the -output on the next scanline, and every 25 lines thereafter, unless -png_write_flush() is called before 25 more lines have been written. -If nrows is too small (less than about 10 lines for a 640 pixel wide -RGB image) the image compression may decrease noticeably (although this -may be acceptable for real-time applications). Infrequent flushing will -only degrade the compression performance by a few percent over images -that do not use flushing. - -Writing the image data - -That's it for the transformations. Now you can write the image data. -The simplest way to do this is in one function call. If you have the -whole image in memory, you can just call png_write_image() and libpng -will write the image. You will need to pass in an array of pointers to -each row. This function automatically handles interlacing, so you don't -need to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_write_rows(). - - png_write_image(png_ptr, row_pointers); - -where row_pointers is: - - png_byte *row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to write the whole image at once, you can -use png_write_rows() instead. If the file is not interlaced, -this is simple: - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -row_pointers is the same as in the png_write_image() call. - -If you are just writing one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - - png_write_row(png_ptr, row_pointer); - -When the file is interlaced, things can get a good deal more -complicated. The only currently (as of the PNG Specification -version 1.2, dated July 1999) defined interlacing scheme for PNG files -is the "Adam7" interlace scheme, that breaks down an -image into seven smaller images of varying size. libpng will build -these images for you, or you can do them yourself. If you want to -build them yourself, see the PNG specification for details of which -pixels to write when. - -If you don't want libpng to handle the interlacing details, just -use png_set_interlace_handling() and call png_write_rows() the -correct number of times to write all seven sub-images. - -If you want libpng to build the sub-images, call this before you start -writing any rows: - - number_of_passes = - png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. - -Then write the complete image number_of_passes times. - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -As some of these rows are not used, and thus return immediately, -you may want to read about interlacing in the PNG specification, -and only update the rows that are actually used. - -Finishing a sequential write - -After you are finished writing the image, you should finish writing -the file. If you are interested in writing comments or time, you should -pass an appropriately filled png_info pointer. If you are not interested, -you can pass NULL. - - png_write_end(png_ptr, info_ptr); - -When you are done, you can free all memory used by libpng like this: - - png_destroy_write_struct(&png_ptr, &info_ptr); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the bitwise OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -If you allocated data such as a palette that you passed -in to libpng with png_set_*, you must not free it until just before the call to -png_destroy_write_struct(). - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -For example, to transfer responsibility for some data from a read structure -to a write structure, you could use - - png_data_freer(read_ptr, read_info_ptr, - PNG_USER_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - png_data_freer(write_ptr, write_info_ptr, - PNG_DESTROY_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - -thereby briefly reassigning responsibility for freeing to the user but -immediately afterwards reassigning it once more to the write_destroy -function. Having done this, it would then be safe to destroy the read -structure and continue to use the PLTE, tRNS, and hIST data in the write -structure. - -This function only affects data that has already been allocated. -You can call this function before calling after the png_set_*() functions -to control whether the user or png_destroy_*() is supposed to free the data. -When the user assumes responsibility for libpng-allocated data, the -application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. -For a more compact example of writing a PNG image, see the file example.c. - -V. Modifying/Customizing libpng: - -There are three issues here. The first is changing how libpng does -standard things like memory allocation, input/output, and error handling. -The second deals with more complicated things like adding new chunks, -adding new transformations, and generally changing how libpng works. -Both of those are compile-time issues; that is, they are generally -determined at the time the code is written, and there is rarely a need -to provide the user with a means of changing them. The third is a -run-time issue: choosing between and/or tuning one or more alternate -versions of computationally intensive routines; specifically, optimized -assembly-language (and therefore compiler- and platform-dependent) -versions. - -Memory allocation, input/output, and error handling - -All of the memory allocation, input/output, and error handling in libpng -goes through callbacks that are user-settable. The default routines are -in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change -these functions, call the appropriate png_set_*_fn() function. - -Memory allocation is done through the functions png_malloc() -and png_free(). These currently just call the standard C functions. If -your pointers can't access more then 64K at a time, you will want to set -MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling -memory allocation on a platform will change between applications, these -functions must be modified in the library at compile time. If you prefer -to use a different method of allocating and freeing data, you can use -png_create_read_struct_2() or png_create_write_struct_2() to register -your own functions as described above. -These functions also provide a void pointer that can be retrieved via - - mem_ptr=png_get_mem_ptr(png_ptr); - -Your replacement memory functions must have prototypes as follows: - - png_voidp malloc_fn(png_structp png_ptr, - png_size_t size); - void free_fn(png_structp png_ptr, png_voidp ptr); - -Your malloc_fn() must return NULL in case of failure. The png_malloc() -function will normally call png_error() if it receives a NULL from the -system memory allocator or from your replacement malloc_fn(). - -Input/Output in libpng is done through png_read() and png_write(), -which currently just call fread() and fwrite(). The FILE * is stored in -png_struct and is initialized via png_init_io(). If you wish to change -the method of I/O, the library supplies callbacks that you can set -through the function png_set_read_fn() and png_set_write_fn() at run -time, instead of calling the png_init_io() function. These functions -also provide a void pointer that can be retrieved via the function -png_get_io_ptr(). For example: - - png_set_read_fn(png_structp read_ptr, - voidp read_io_ptr, png_rw_ptr read_data_fn) - - png_set_write_fn(png_structp write_ptr, - voidp write_io_ptr, png_rw_ptr write_data_fn, - png_flush_ptr output_flush_fn); - - voidp read_io_ptr = png_get_io_ptr(read_ptr); - voidp write_io_ptr = png_get_io_ptr(write_ptr); - -The replacement I/O functions must have prototypes as follows: - - void user_read_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_write_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_flush_data(png_structp png_ptr); - -Supplying NULL for the read, write, or flush functions sets them back -to using the default C stream functions. It is an error to read from -a write stream, and vice versa. - -Error handling in libpng is done through png_error() and png_warning(). -Errors handled through png_error() are fatal, meaning that png_error() -should never return to its caller. Currently, this is handled via -setjmp() and longjmp() (unless you have compiled libpng with -PNG_SETJMP_NOT_SUPPORTED, in which case it is handled via PNG_ABORT()), -but you could change this to do things like exit() if you should wish. - -On non-fatal errors, png_warning() is called -to print a warning message, and then control returns to the calling code. -By default png_error() and png_warning() print a message on stderr via -fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined -(because you don't want the messages) or PNG_NO_STDIO defined (because -fprintf() isn't available). If you wish to change the behavior of the error -functions, you will need to set up your own message callbacks. These -functions are normally supplied at the time that the png_struct is created. -It is also possible to redirect errors and warnings to your own replacement -functions after png_create_*_struct() has been called by calling: - - png_set_error_fn(png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warning_fn); - - png_voidp error_ptr = png_get_error_ptr(png_ptr); - -If NULL is supplied for either error_fn or warning_fn, then the libpng -default function will be used, calling fprintf() and/or longjmp() if a -problem is encountered. The replacement error functions should have -parameters as follows: - - void user_error_fn(png_structp png_ptr, - png_const_charp error_msg); - void user_warning_fn(png_structp png_ptr, - png_const_charp warning_msg); - -The motivation behind using setjmp() and longjmp() is the C++ throw and -catch exception handling methods. This makes the code much easier to write, -as there is no need to check every return code of every function call. -However, there are some uncertainties about the status of local variables -after a longjmp, so the user may want to be careful about doing anything after -setjmp returns non-zero besides returning itself. Consult your compiler -documentation for more details. For an alternative approach, you may wish -to use the "cexcept" facility (see http://cexcept.sourceforge.net). - -Custom chunks - -If you need to read or write custom chunks, you may need to get deeper -into the libpng code. The library now has mechanisms for storing -and writing chunks of unknown type; you can even declare callbacks -for custom chunks. However, this may not be good enough if the -library code itself needs to know about interactions between your -chunk and existing `intrinsic' chunks. - -If you need to write a new intrinsic chunk, first read the PNG -specification. Acquire a first level of -understanding of how it works. Pay particular attention to the -sections that describe chunk names, and look at how other chunks were -designed, so you can do things similarly. Second, check out the -sections of libpng that read and write chunks. Try to find a chunk -that is similar to yours and use it as a template. More details can -be found in the comments inside the code. It is best to handle unknown -chunks in a generic method, via callback functions, instead of by -modifying libpng functions. - -If you wish to write your own transformation for the data, look through -the part of the code that does the transformations, and check out some of -the simpler ones to get an idea of how they work. Try to find a similar -transformation to the one you want to add and copy off of it. More details -can be found in the comments inside the code itself. - -Configuring for 16 bit platforms - -You will want to look into zconf.h to tell zlib (and thus libpng) that -it cannot allocate more then 64K at a time. Even if you can, the memory -won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. - -Configuring for DOS - -For DOS users who only have access to the lower 640K, you will -have to limit zlib's memory usage via a png_set_compression_mem_level() -call. See zlib.h or zconf.h in the zlib library for more information. - -Configuring for Medium Model - -Libpng's support for medium model has been tested on most of the popular -compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets -defined, and FAR gets defined to far in pngconf.h, and you should be -all set. Everything in the library (except for zlib's structure) is -expecting far data. You must use the typedefs with the p or pp on -the end for pointers (or at least look at them and be careful). Make -note that the rows of data are defined as png_bytepp, which is an -unsigned char far * far *. - -Configuring for gui/windowing platforms: - -You will need to write new error and warning functions that use the GUI -interface, as described previously, and set them to be the error and -warning functions at the time that png_create_*_struct() is called, -in order to have them available during the structure initialization. -They can be changed later via png_set_error_fn(). On some compilers, -you may also have to change the memory allocators (png_malloc, etc.). - -Configuring for compiler xxx: - -All includes for libpng are in pngconf.h. If you need to add/change/delete -an include, this is the place to do it. The includes that are not -needed outside libpng are protected by the PNG_INTERNAL definition, -which is only defined for those routines inside libpng itself. The -files in libpng proper only include png.h, which includes pngconf.h. - -Configuring zlib: - -There are special functions to configure the compression. Perhaps the -most useful one changes the compression level, which currently uses -input compression values in the range 0 - 9. The library normally -uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests -have shown that for a large majority of images, compression values in -the range 3-6 compress nearly as well as higher levels, and do so much -faster. For online applications it may be desirable to have maximum speed -(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also -specify no compression (Z_NO_COMPRESSION = 0), but this would create -files larger than just storing the raw bitmap. You can specify the -compression level by calling: - - png_set_compression_level(png_ptr, level); - -Another useful one is to reduce the memory level used by the library. -The memory level defaults to 8, but it can be lowered if you are -short on memory (running DOS, for example, where you only have 640K). -Note that the memory level does have an effect on compression; among -other things, lower levels will result in sections of incompressible -data being emitted in smaller stored blocks, with a correspondingly -larger relative overhead of up to 15% in the worst case. - - png_set_compression_mem_level(png_ptr, level); - -The other functions are for configuring zlib. They are not recommended -for normal use and may result in writing an invalid PNG file. See -zlib.h for more information on what these mean. - - png_set_compression_strategy(png_ptr, - strategy); - png_set_compression_window_bits(png_ptr, - window_bits); - png_set_compression_method(png_ptr, method); - png_set_compression_buffer_size(png_ptr, size); - -Controlling row filtering - -If you want to control whether libpng uses filtering or not, which -filters are used, and how it goes about picking row filters, you -can call one of these functions. The selection and configuration -of row filters can have a significant impact on the size and -encoding speed and a somewhat lesser impact on the decoding speed -of an image. Filtering is enabled by default for RGB and grayscale -images (with and without alpha), but not for paletted images nor -for any images with bit depths less than 8 bits/pixel. - -The 'method' parameter sets the main filtering method, which is -currently only '0' in the PNG 1.2 specification. The 'filters' -parameter sets which filter(s), if any, should be used for each -scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS -to turn filtering on and off, respectively. - -Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, -PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise -ORed together with '|' to specify one or more filters to use. -These filters are described in more detail in the PNG specification. -If you intend to change the filter type during the course of writing -the image, you should start with flags set for all of the filters -you intend to use so that libpng can initialize its internal -structures appropriately for all of the filter types. (Note that this -means the first row must always be adaptively filtered, because libpng -currently does not allocate the filter buffers until png_write_row() -is called for the first time.) - - filters = PNG_FILTER_NONE | PNG_FILTER_SUB - PNG_FILTER_UP | PNG_FILTER_AVE | - PNG_FILTER_PAETH | PNG_ALL_FILTERS; - - png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, - filters); - The second parameter can also be - PNG_INTRAPIXEL_DIFFERENCING if you are - writing a PNG to be embedded in a MNG - datastream. This parameter must be the - same as the value of filter_method used - in png_set_IHDR(). - -It is also possible to influence how libpng chooses from among the -available filters. This is done in one or both of two ways - by -telling it how important it is to keep the same filter for successive -rows, and by telling it the relative computational costs of the filters. - - double weights[3] = {1.5, 1.3, 1.1}, - costs[PNG_FILTER_VALUE_LAST] = - {1.0, 1.3, 1.3, 1.5, 1.7}; - - png_set_filter_heuristics(png_ptr, - PNG_FILTER_HEURISTIC_WEIGHTED, 3, - weights, costs); - -The weights are multiplying factors that indicate to libpng that the -row filter should be the same for successive rows unless another row filter -is that many times better than the previous filter. In the above example, -if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a -"sum of absolute differences" 1.5 x 1.3 times higher than other filters -and still be chosen, while the NONE filter could have a sum 1.1 times -higher than other filters and still be chosen. Unspecified weights are -taken to be 1.0, and the specified weights should probably be declining -like those above in order to emphasize recent filters over older filters. - -The filter costs specify for each filter type a relative decoding cost -to be considered when selecting row filters. This means that filters -with higher costs are less likely to be chosen over filters with lower -costs, unless their "sum of absolute differences" is that much smaller. -The costs do not necessarily reflect the exact computational speeds of -the various filters, since this would unduly influence the final image -size. - -Note that the numbers above were invented purely for this example and -are given only to help explain the function usage. Little testing has -been done to find optimum values for either the costs or the weights. - -Removing unwanted object code - -There are a bunch of #define's in pngconf.h that control what parts of -libpng are compiled. All the defines end in _SUPPORTED. If you are -never going to use a capability, you can change the #define to #undef -before recompiling libpng and save yourself code and data space, or -you can turn off individual capabilities with defines that begin with -PNG_NO_. - -You can also turn all of the transforms and ancillary chunk capabilities -off en masse with compiler directives that define -PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, -or all four, -along with directives to turn on any of the capabilities that you do -want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable -the extra transformations but still leave the library fully capable of reading -and writing PNG files with all known public chunks -Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive -produces a library that is incapable of reading or writing ancillary chunks. -If you are not using the progressive reading capability, you can -turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse -this with the INTERLACING capability, which you'll still have). - -All the reading and writing specific code are in separate files, so the -linker should only grab the files it needs. However, if you want to -make sure, or if you are building a stand alone library, all the -reading files start with pngr and all the writing files start with -pngw. The files that don't match either (like png.c, pngtrans.c, etc.) -are used for both reading and writing, and always need to be included. -The progressive reader is in pngpread.c - -If you are creating or distributing a dynamically linked library (a .so -or DLL file), you should not remove or disable any parts of the library, -as this will cause applications linked with different versions of the -library to fail if they call functions not available in your library. -The size of the library itself should not be an issue, because only -those sections that are actually used will be loaded into memory. - -Requesting debug printout - -The macro definition PNG_DEBUG can be used to request debugging -printout. Set it to an integer value in the range 0 to 3. Higher -numbers result in increasing amounts of debugging information. The -information is printed to the "stderr" file, unless another file -name is specified in the PNG_DEBUG_FILE macro definition. - -When PNG_DEBUG > 0, the following functions (macros) become available: - - png_debug(level, message) - png_debug1(level, message, p1) - png_debug2(level, message, p1, p2) - -in which "level" is compared to PNG_DEBUG to decide whether to print -the message, "message" is the formatted string to be printed, -and p1 and p2 are parameters that are to be embedded in the string -according to printf-style formatting directives. For example, - - png_debug1(2, "foo=%d\n", foo); - -is expanded to - - if(PNG_DEBUG > 2) - fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); - -When PNG_DEBUG is defined but is zero, the macros aren't defined, but you -can still use PNG_DEBUG to control your own debugging: - - #ifdef PNG_DEBUG - fprintf(stderr, ... - #endif - -When PNG_DEBUG = 1, the macros are defined, but only png_debug statements -having level = 0 will be printed. There aren't any such statements in -this version of libpng, but if you insert some they will be printed. - -VI. Runtime optimization - -A new feature in libpng 1.2.0 is the ability to dynamically switch between -standard and optimized versions of some routines. Currently these are -limited to three computationally intensive tasks when reading PNG files: -decoding row filters, expanding interlacing, and combining interlaced or -transparent row data with previous row data. Currently the optimized -versions are available only for x86 (Intel, AMD, etc.) platforms with -MMX support, though this may change in future versions. (For example, -the non-MMX assembler optimizations for zlib might become similarly -runtime-selectable in future releases, in which case libpng could be -extended to support them. Alternatively, the compile-time choice of -floating-point versus integer routines for gamma correction might become -runtime-selectable.) - -Because such optimizations tend to be very platform- and compiler-dependent, -both in how they are written and in how they perform, the new runtime code -in libpng has been written to allow programs to query, enable, and disable -either specific optimizations or all such optimizations. For example, to -enable all possible optimizations (bearing in mind that some "optimizations" -may actually run more slowly in rare cases): - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - png_uint_32 mask, flags; - - flags = png_get_asm_flags(png_ptr); - mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); - png_set_asm_flags(png_ptr, flags | mask); - #endif - -To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ -by itself when calling png_get_asm_flagmask(); similarly for optimizing -only writing. To disable all optimizations: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - flags = png_get_asm_flags(png_ptr); - mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); - png_set_asm_flags(png_ptr, flags & ~mask); - #endif - -To enable or disable only MMX-related features, use png_get_mmx_flagmask() -in place of png_get_asm_flagmask(). The mmx version takes one additional -parameter: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - int selection = PNG_SELECT_READ | PNG_SELECT_WRITE; - int compilerID; - - mask = png_get_mmx_flagmask(selection, &compilerID); - #endif - -On return, compilerID will indicate which version of the MMX assembler -optimizations was compiled. Currently two flavors exist: Microsoft -Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2). -On non-x86 platforms or on systems compiled without MMX optimizations, a -value of -1 is used. - -Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return -all valid, settable optimization bits for the version of the library that's -currently in use. In the case of shared (dynamically linked) libraries, -this may include optimizations that did not exist at the time the code was -written and compiled. It is also possible, of course, to enable only known, -specific optimizations; for example: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - flags = PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - png_set_asm_flags(png_ptr, flags); - #endif - -This method would enable only the MMX read-optimizations available at the -time of libpng 1.2.0's release, regardless of whether a later version of -the DLL were actually being used. (Also note that these functions did not -exist in versions older than 1.2.0, so any attempt to run a dynamically -linked app on such an older version would fail.) - -To determine whether the processor supports MMX instructions at all, use -the png_mmx_support() function: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - mmxsupport = png_mmx_support(); - #endif - -It returns -1 if MMX support is not compiled into libpng, 0 if MMX code -is compiled but MMX is not supported by the processor, or 1 if MMX support -is fully available. Note that png_mmx_support(), png_get_mmx_flagmask(), -and png_get_asm_flagmask() all may be called without allocating and ini- -tializing any PNG structures (for example, as part of a usage screen or -"about" box). - -The following code can be used to prevent an application from using the -thread_unsafe features, even if libpng was built with PNG_THREAD_UNSAFE_OK -defined: - -#if defined(PNG_USE_PNGGCCRD) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) \ - && defined(PNG_THREAD_UNSAFE_OK) - /* Disable thread-unsafe features of pnggccrd */ - if (png_access_version_number() >= 10200) - { - png_uint_32 mmx_disable_mask = 0; - png_uint_32 asm_flags; - - mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); - asm_flags = png_get_asm_flags(png_ptr); - png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask); - } -#endif - -For more extensive examples of runtime querying, enabling and disabling -of optimized features, see contrib/gregbook/readpng2.c in the libpng -source-code distribution. - -VII. MNG support - -The MNG specification (available at http://www.libpng.org/pub/mng) allows -certain extensions to PNG for PNG images that are embedded in MNG datastreams. -Libpng can support some of these extensions. To enable them, use the -png_permit_mng_features() function: - - feature_set = png_permit_mng_features(png_ptr, mask) - mask is a png_uint_32 containing the bitwise OR of the - features you want to enable. These include - PNG_FLAG_MNG_EMPTY_PLTE - PNG_FLAG_MNG_FILTER_64 - PNG_ALL_MNG_FEATURES - feature_set is a png_uint_32 that is the bitwise AND of - your mask with the set of MNG features that is - supported by the version of libpng that you are using. - -It is an error to use this function when reading or writing a standalone -PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped -in a MNG datastream. As a minimum, it must have the MNG 8-byte signature -and the MHDR and MEND chunks. Libpng does not provide support for these -or any other MNG chunks; your application must provide its own support for -them. You may wish to consider using libmng (available at -http://www.libmng.com) instead. - -VIII. Changes to Libpng from version 0.88 - -It should be noted that versions of libpng later than 0.96 are not -distributed by the original libpng author, Guy Schalnat, nor by -Andreas Dilger, who had taken over from Guy during 1996 and 1997, and -distributed versions 0.89 through 0.96, but rather by another member -of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are -still alive and well, but they have moved on to other things. - -The old libpng functions png_read_init(), png_write_init(), -png_info_init(), png_read_destroy(), and png_write_destroy() have been -moved to PNG_INTERNAL in version 0.95 to discourage their use. These -functions will be removed from libpng version 2.0.0. - -The preferred method of creating and initializing the libpng structures is -via the png_create_read_struct(), png_create_write_struct(), and -png_create_info_struct() because they isolate the size of the structures -from the application, allow version error checking, and also allow the -use of custom error handling routines during the initialization, which -the old functions do not. The functions png_read_destroy() and -png_write_destroy() do not actually free the memory that libpng -allocated for these structs, but just reset the data structures, so they -can be used instead of png_destroy_read_struct() and -png_destroy_write_struct() if you feel there is too much system overhead -allocating and freeing the png_struct for each image read. - -Setting the error callbacks via png_set_message_fn() before -png_read_init() as was suggested in libpng-0.88 is no longer supported -because this caused applications that do not use custom error functions -to fail if the png_ptr was not initialized to zero. It is still possible -to set the error callbacks AFTER png_read_init(), or to change them with -png_set_error_fn(), which is essentially the same function, but with a new -name to force compilation errors with applications that try to use the old -method. - -Starting with version 1.0.7, you can find out which version of the library -you are using at run-time: - - png_uint_32 libpng_vn = png_access_version_number(); - -The number libpng_vn is constructed from the major version, minor -version with leading zero, and release number with leading zero, -(e.g., libpng_vn for version 1.0.7 is 10007). - -You can also check which version of png.h you used when compiling your -application: - - png_uint_32 application_vn = PNG_LIBPNG_VER; - -IX. Y2K Compliance in libpng - -January 31, 2007 - -Since the PNG Development group is an ad-hoc body, we can't make -an official declaration. - -This is your unofficial assurance that libpng from version 0.71 and -upward through 1.2.16 are Y2K compliant. It is my belief that earlier -versions were also Y2K compliant. - -Libpng only has three year fields. One is a 2-byte unsigned integer that -will hold years up to 65535. The other two hold the date in text -format, and will hold years up to 9999. - -The integer is - "png_uint_16 year" in png_time_struct. - -The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. - -There are seven time-related functions: - - png_convert_to_rfc_1123() in png.c - (formerly png_convert_to_rfc_1152() in error) - png_convert_from_struct_tm() in pngwrite.c, called - in pngwrite.c - png_convert_from_time_t() in pngwrite.c - png_get_tIME() in pngget.c - png_handle_tIME() in pngrutil.c, called in pngread.c - png_set_tIME() in pngset.c - png_write_tIME() in pngwutil.c, called in pngwrite.c - -All appear to handle dates properly in a Y2K environment. The -png_convert_from_time_t() function calls gmtime() to convert from system -clock time, which returns (year - 1900), which we properly convert to -the full 4-digit year. There is a possibility that applications using -libpng are not passing 4-digit years into the png_convert_to_rfc_1123() -function, or that they are incorrectly passing only a 2-digit year -instead of "year - 1900" into the png_convert_from_struct_tm() function, -but this is not under our control. The libpng documentation has always -stated that it works with 4-digit years, and the APIs have been -documented as such. - -The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned -integer to hold the year, and can hold years as large as 65535. - -zlib, upon which libpng depends, is also Y2K compliant. It contains -no date-related code. - - - Glenn Randers-Pehrson - libpng maintainer - PNG Development Group +libpng.txt - A description on how to use and modify libpng + + libpng version 1.2.16 - January 31, 2007 + Updated and distributed by Glenn Randers-Pehrson + + Copyright (c) 1998-2005 Glenn Randers-Pehrson + For conditions of distribution and use, see copyright + notice in png.h. + + based on: + + libpng 1.0 beta 6 version 0.96 May 28, 1997 + Updated and distributed by Andreas Dilger + Copyright (c) 1996, 1997 Andreas Dilger + + libpng 1.0 beta 2 - version 0.88 January 26, 1996 + For conditions of distribution and use, see copyright + notice in png.h. Copyright (c) 1995, 1996 Guy Eric + Schalnat, Group 42, Inc. + + Updated/rewritten per request in the libpng FAQ + Copyright (c) 1995, 1996 Frank J. T. Wojcik + December 18, 1995 & January 20, 1996 + +I. Introduction + +This file describes how to use and modify the PNG reference library +(known as libpng) for your own use. There are five sections to this +file: introduction, structures, reading, writing, and modification and +configuration notes for various special platforms. In addition to this +file, example.c is a good starting point for using the library, as +it is heavily commented and should include everything most people +will need. We assume that libpng is already installed; see the +INSTALL file for instructions on how to install libpng. + +Libpng was written as a companion to the PNG specification, as a way +of reducing the amount of time and effort it takes to support the PNG +file format in application programs. + +The PNG specification (second edition), November 2003, is available as +a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at + + +The PNG-1.0 specification is available +as RFC 2083 and as a +W3C Recommendation . Some +additional chunks are described in the special-purpose public chunks +documents at . + +Other information +about PNG, and the latest version of libpng, can be found at the PNG home +page, . + +Most users will not have to modify the library significantly; advanced +users may want to modify it more. All attempts were made to make it as +complete as possible, while keeping the code easy to understand. +Currently, this library only supports C. Support for other languages +is being considered. + +Libpng has been designed to handle multiple sessions at one time, +to be easily modifiable, to be portable to the vast majority of +machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy +to use. The ultimate goal of libpng is to promote the acceptance of +the PNG file format in whatever way possible. While there is still +work to be done (see the TODO file), libpng should cover the +majority of the needs of its users. + +Libpng uses zlib for its compression and decompression of PNG files. +Further information about zlib, and the latest version of zlib, can +be found at the zlib home page, . +The zlib compression utility is a general purpose utility that is +useful for more than PNG files, and can be used without libpng. +See the documentation delivered with zlib for more details. +You can usually find the source files for the zlib utility wherever you +find the libpng source files. + +Libpng is thread safe, provided the threads are using different +instances of the structures. Each thread should have its own +png_struct and png_info instances, and thus its own image. +Libpng does not protect itself against two threads using the +same instance of a structure. Note: thread safety may be defeated +by use of some of the MMX assembler code in pnggccrd.c, which is only +compiled when the user defines PNG_THREAD_UNSAFE_OK. + +II. Structures + +There are two main structures that are important to libpng, png_struct +and png_info. The first, png_struct, is an internal structure that +will not, for the most part, be used by a user except as the first +variable passed to every libpng function call. + +The png_info structure is designed to provide information about the +PNG file. At one time, the fields of png_info were intended to be +directly accessible to the user. However, this tended to cause problems +with applications using dynamically loaded libraries, and as a result +a set of interface functions for png_info (the png_get_*() and png_set_*() +functions) was developed. The fields of png_info are still available for +older applications, but it is suggested that applications use the new +interfaces if at all possible. + +Applications that do make direct access to the members of png_struct (except +for png_ptr->jmpbuf) must be recompiled whenever the library is updated, +and applications that make direct access to the members of png_info must +be recompiled if they were compiled or loaded with libpng version 1.0.6, +in which the members were in a different order. In version 1.0.7, the +members of the png_info structure reverted to the old order, as they were +in versions 0.97c through 1.0.5. Starting with version 2.0.0, both +structures are going to be hidden, and the contents of the structures will +only be accessible through the png_get/png_set functions. + +The png.h header file is an invaluable reference for programming with libpng. +And while I'm on the topic, make sure you include the libpng header file: + +#include + +III. Reading + +We'll now walk you through the possible functions to call when reading +in a PNG file sequentially, briefly explaining the syntax and purpose +of each one. See example.c and png.h for more detail. While +progressive reading is covered in the next section, you will still +need some of the functions discussed in this section to read a PNG +file. + +Setup + +You will want to do the I/O initialization(*) before you get into libpng, +so if it doesn't work, you don't have much to undo. Of course, you +will also want to insure that you are, in fact, dealing with a PNG +file. Libpng provides a simple check to see if a file is a PNG file. +To use it, pass in the first 1 to 8 bytes of the file to the function +png_sig_cmp(), and it will return 0 if the bytes match the corresponding +bytes of the PNG signature, or nonzero otherwise. Of course, the more bytes +you pass in, the greater the accuracy of the prediction. + +If you are intending to keep the file pointer open for use in libpng, +you must ensure you don't read more than 8 bytes from the beginning +of the file, and you also have to make a call to png_set_sig_bytes_read() +with the number of bytes you read from the beginning. Libpng will +then only check the bytes (if any) that your program didn't read. + +(*): If you are not using the standard I/O functions, you will need +to replace them with custom functions. See the discussion under +Customizing libpng. + + + FILE *fp = fopen(file_name, "rb"); + if (!fp) + { + return (ERROR); + } + fread(header, 1, number, fp); + is_png = !png_sig_cmp(header, 0, number); + if (!is_png) + { + return (NOT_PNG); + } + + +Next, png_struct and png_info need to be allocated and initialized. In +order to ensure that the size of these structures is correct even with a +dynamically linked libpng, there are functions to initialize and +allocate the structures. We also pass the library version, optional +pointers to error handling functions, and a pointer to a data struct for +use by the error functions, if necessary (the pointer and functions can +be NULL if the default error handlers are to be used). See the section +on Changes to Libpng below regarding the old initialization functions. +The structure allocation functions quietly return NULL if they fail to +create the structure, so your application should check for that. + + png_structp png_ptr = png_create_read_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn); + if (!png_ptr) + return (ERROR); + + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + png_destroy_read_struct(&png_ptr, + (png_infopp)NULL, (png_infopp)NULL); + return (ERROR); + } + + png_infop end_info = png_create_info_struct(png_ptr); + if (!end_info) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + (png_infopp)NULL); + return (ERROR); + } + +If you want to use your own memory allocation routines, +define PNG_USER_MEM_SUPPORTED and use +png_create_read_struct_2() instead of png_create_read_struct(): + + png_structp png_ptr = png_create_read_struct_2 + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn, (png_voidp) + user_mem_ptr, user_malloc_fn, user_free_fn); + +The error handling routines passed to png_create_read_struct() +and the memory alloc/free routines passed to png_create_struct_2() +are only necessary if you are not using the libpng supplied error +handling and memory alloc/free functions. + +When libpng encounters an error, it expects to longjmp back +to your routine. Therefore, you will need to call setjmp and pass +your png_jmpbuf(png_ptr). If you read the file from different +routines, you will need to update the jmpbuf field every time you enter +a new routine that will call a png_*() function. + +See your documentation of setjmp/longjmp for your compiler for more +information on setjmp/longjmp. See the discussion on libpng error +handling in the Customizing Libpng section below for more information +on the libpng error handling. If an error occurs, and libpng longjmp's +back to your setjmp, you will want to call png_destroy_read_struct() to +free any memory. + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + &end_info); + fclose(fp); + return (ERROR); + } + +If you would rather avoid the complexity of setjmp/longjmp issues, +you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case +errors will result in a call to PNG_ABORT() which defaults to abort(). + +Now you need to set up the input code. The default for libpng is to +use the C function fread(). If you use this, you will need to pass a +valid FILE * in the function png_init_io(). Be sure that the file is +opened in binary mode. If you wish to handle reading data in another +way, you need not call the png_init_io() function, but you must then +implement the libpng I/O methods discussed in the Customizing Libpng +section below. + + png_init_io(png_ptr, fp); + +If you had previously opened the file and read any of the signature from +the beginning in order to see if this was a PNG file, you need to let +libpng know that there are some bytes missing from the start of the file. + + png_set_sig_bytes(png_ptr, number); + +Setting up callback code + +You can set up a callback function to handle any unknown chunks in the +input stream. You must supply the function + + read_chunk_callback(png_ptr ptr, + png_unknown_chunkp chunk); + { + /* The unknown chunk structure contains your + chunk data: */ + png_byte name[5]; + png_byte *data; + png_size_t size; + /* Note that libpng has already taken care of + the CRC handling */ + + /* put your code here. Return one of the + following: */ + + return (-n); /* chunk had an error */ + return (0); /* did not recognize */ + return (n); /* success */ + } + +(You can give your function another name that you like instead of +"read_chunk_callback") + +To inform libpng about your function, use + + png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, + read_chunk_callback); + +This names not only the callback function, but also a user pointer that +you can retrieve with + + png_get_user_chunk_ptr(png_ptr); + +At this point, you can set up a callback function that will be +called after each row has been read, which you can use to control +a progress meter or the like. It's demonstrated in pngtest.c. +You must supply a function + + void read_row_callback(png_ptr ptr, png_uint_32 row, + int pass); + { + /* put your code here */ + } + +(You can give it another name that you like instead of "read_row_callback") + +To inform libpng about your function, use + + png_set_read_status_fn(png_ptr, read_row_callback); + +Width and height limits + +The PNG specification allows the width and height of an image to be as +large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. +Since very few applications really need to process such large images, +we have imposed an arbitrary 1-million limit on rows and columns. +Larger images will be rejected immediately with a png_error() call. If +you wish to override this limit, you can use + + png_set_user_limits(png_ptr, width_max, height_max); + +to set your own limits, or use width_max = height_max = 0x7fffffffL +to allow all valid dimensions (libpng may reject some very large images +anyway because of potential buffer overflow conditions). + +You should put this statement after you create the PNG structure and +before calling png_read_info(), png_read_png(), or png_process_data(). +If you need to retrieve the limits that are being applied, use + + width_max = png_get_user_width_max(png_ptr); + height_max = png_get_user_height_max(png_ptr); + +Unknown-chunk handling + +Now you get to set the way the library processes unknown chunks in the +input PNG stream. Both known and unknown chunks will be read. Normal +behavior is that known chunks will be parsed into information in +various info_ptr members; unknown chunks will be discarded. To change +this, you can call: + + png_set_keep_unknown_chunks(png_ptr, keep, + chunk_list, num_chunks); + keep - 0: do not handle as unknown + 1: do not keep + 2: keep only if safe-to-copy + 3: keep even if unsafe-to-copy + You can use these definitions: + PNG_HANDLE_CHUNK_AS_DEFAULT 0 + PNG_HANDLE_CHUNK_NEVER 1 + PNG_HANDLE_CHUNK_IF_SAFE 2 + PNG_HANDLE_CHUNK_ALWAYS 3 + chunk_list - list of chunks affected (a byte string, + five bytes per chunk, NULL or '\0' if + num_chunks is 0) + num_chunks - number of chunks affected; if 0, all + unknown chunks are affected. If nonzero, + only the chunks in the list are affected + +Unknown chunks declared in this way will be saved as raw data onto a +list of png_unknown_chunk structures. If a chunk that is normally +known to libpng is named in the list, it will be handled as unknown, +according to the "keep" directive. If a chunk is named in successive +instances of png_set_keep_unknown_chunks(), the final instance will +take precedence. The IHDR and IEND chunks should not be named in +chunk_list; if they are, libpng will process them normally anyway. + +The high-level read interface + +At this point there are two ways to proceed; through the high-level +read interface, or through a sequence of low-level read operations. +You can use the high-level interface if (a) you are willing to read +the entire image into memory, and (b) the input transformations +you want to do are limited to the following set: + + PNG_TRANSFORM_IDENTITY No transformation + PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to + 8 bits + PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel + PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit + samples to bytes + PNG_TRANSFORM_PACKSWAP Change order of packed + pixels to LSB first + PNG_TRANSFORM_EXPAND Perform set_expand() + PNG_TRANSFORM_INVERT_MONO Invert monochrome images + PNG_TRANSFORM_SHIFT Normalize pixels to the + sBIT depth + PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA + to BGRA + PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA + to AG + PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity + to transparency + PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples + +(This excludes setting a background color, doing gamma transformation, +dithering, and setting filler.) If this is the case, simply do this: + + png_read_png(png_ptr, info_ptr, png_transforms, NULL) + +where png_transforms is an integer containing the bitwise OR of +some set of transformation flags. This call is equivalent to png_read_info(), +followed the set of transformations indicated by the transform mask, +then png_read_image(), and finally png_read_end(). + +(The final parameter of this call is not yet used. Someday it might point +to transformation parameters required by some future input transform.) + +You must use png_transforms and not call any png_set_transform() functions +when you use png_read_png(). + +After you have called png_read_png(), you can retrieve the image data +with + + row_pointers = png_get_rows(png_ptr, info_ptr); + +where row_pointers is an array of pointers to the pixel data for each row: + + png_bytep row_pointers[height]; + +If you know your image size and pixel size ahead of time, you can allocate +row_pointers prior to calling png_read_png() with + + if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) + png_error (png_ptr, + "Image is too tall to process in memory"); + if (width > PNG_UINT_32_MAX/pixel_size) + png_error (png_ptr, + "Image is too wide to process in memory"); + row_pointers = png_malloc(png_ptr, + height*png_sizeof(png_bytep)); + for (int i=0; i) and +png_get_(png_ptr, info_ptr, ...) functions return non-zero if the +data has been read, or zero if it is missing. The parameters to the +png_get_ are set directly if they are simple data types, or a pointer +into the info_ptr is returned for any complex types. + + png_get_PLTE(png_ptr, info_ptr, &palette, + &num_palette); + palette - the palette for the file + (array of png_color) + num_palette - number of entries in the palette + + png_get_gAMA(png_ptr, info_ptr, &gamma); + gamma - the gamma the file is written + at (PNG_INFO_gAMA) + + png_get_sRGB(png_ptr, info_ptr, &srgb_intent); + srgb_intent - the rendering intent (PNG_INFO_sRGB) + The presence of the sRGB chunk + means that the pixel data is in the + sRGB color space. This chunk also + implies specific values of gAMA and + cHRM. + + png_get_iCCP(png_ptr, info_ptr, &name, + &compression_type, &profile, &proflen); + name - The profile name. + compression - The compression type; always + PNG_COMPRESSION_TYPE_BASE for PNG 1.0. + You may give NULL to this argument to + ignore it. + profile - International Color Consortium color + profile data. May contain NULs. + proflen - length of profile data in bytes. + + png_get_sBIT(png_ptr, info_ptr, &sig_bit); + sig_bit - the number of significant bits for + (PNG_INFO_sBIT) each of the gray, + red, green, and blue channels, + whichever are appropriate for the + given color type (png_color_16) + + png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, + &trans_values); + trans - array of transparent entries for + palette (PNG_INFO_tRNS) + trans_values - graylevel or color sample values of + the single transparent color for + non-paletted images (PNG_INFO_tRNS) + num_trans - number of transparent entries + (PNG_INFO_tRNS) + + png_get_hIST(png_ptr, info_ptr, &hist); + (PNG_INFO_hIST) + hist - histogram of palette (array of + png_uint_16) + + png_get_tIME(png_ptr, info_ptr, &mod_time); + mod_time - time image was last modified + (PNG_VALID_tIME) + + png_get_bKGD(png_ptr, info_ptr, &background); + background - background color (PNG_VALID_bKGD) + valid 16-bit red, green and blue + values, regardless of color_type + + num_comments = png_get_text(png_ptr, info_ptr, + &text_ptr, &num_text); + num_comments - number of comments + text_ptr - array of png_text holding image + comments + text_ptr[i].compression - type of compression used + on "text" PNG_TEXT_COMPRESSION_NONE + PNG_TEXT_COMPRESSION_zTXt + PNG_ITXT_COMPRESSION_NONE + PNG_ITXT_COMPRESSION_zTXt + text_ptr[i].key - keyword for comment. Must contain + 1-79 characters. + text_ptr[i].text - text comments for current + keyword. Can be empty. + text_ptr[i].text_length - length of text string, + after decompression, 0 for iTXt + text_ptr[i].itxt_length - length of itxt string, + after decompression, 0 for tEXt/zTXt + text_ptr[i].lang - language of comment (empty + string for unknown). + text_ptr[i].lang_key - keyword in UTF-8 + (empty string for unknown). + num_text - number of comments (same as + num_comments; you can put NULL here + to avoid the duplication) + Note while png_set_text() will accept text, language, + and translated keywords that can be NULL pointers, the + structure returned by png_get_text will always contain + regular zero-terminated C strings. They might be + empty strings but they will never be NULL pointers. + + num_spalettes = png_get_sPLT(png_ptr, info_ptr, + &palette_ptr); + palette_ptr - array of palette structures holding + contents of one or more sPLT chunks + read. + num_spalettes - number of sPLT chunks read. + + png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, + &unit_type); + offset_x - positive offset from the left edge + of the screen + offset_y - positive offset from the top edge + of the screen + unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER + + png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, + &unit_type); + res_x - pixels/unit physical resolution in + x direction + res_y - pixels/unit physical resolution in + x direction + unit_type - PNG_RESOLUTION_UNKNOWN, + PNG_RESOLUTION_METER + + png_get_sCAL(png_ptr, info_ptr, &unit, &width, + &height) + unit - physical scale units (an integer) + width - width of a pixel in physical scale units + height - height of a pixel in physical scale units + (width and height are doubles) + + png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, + &height) + unit - physical scale units (an integer) + width - width of a pixel in physical scale units + height - height of a pixel in physical scale units + (width and height are strings like "2.54") + + num_unknown_chunks = png_get_unknown_chunks(png_ptr, + info_ptr, &unknowns) + unknowns - array of png_unknown_chunk + structures holding unknown chunks + unknowns[i].name - name of unknown chunk + unknowns[i].data - data of unknown chunk + unknowns[i].size - size of unknown chunk's data + unknowns[i].location - position of chunk in file + + The value of "i" corresponds to the order in which the + chunks were read from the PNG file or inserted with the + png_set_unknown_chunks() function. + +The data from the pHYs chunk can be retrieved in several convenient +forms: + + res_x = png_get_x_pixels_per_meter(png_ptr, + info_ptr) + res_y = png_get_y_pixels_per_meter(png_ptr, + info_ptr) + res_x_and_y = png_get_pixels_per_meter(png_ptr, + info_ptr) + res_x = png_get_x_pixels_per_inch(png_ptr, + info_ptr) + res_y = png_get_y_pixels_per_inch(png_ptr, + info_ptr) + res_x_and_y = png_get_pixels_per_inch(png_ptr, + info_ptr) + aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, + info_ptr) + + (Each of these returns 0 [signifying "unknown"] if + the data is not present or if res_x is 0; + res_x_and_y is 0 if res_x != res_y) + +The data from the oFFs chunk can be retrieved in several convenient +forms: + + x_offset = png_get_x_offset_microns(png_ptr, info_ptr); + y_offset = png_get_y_offset_microns(png_ptr, info_ptr); + x_offset = png_get_x_offset_inches(png_ptr, info_ptr); + y_offset = png_get_y_offset_inches(png_ptr, info_ptr); + + (Each of these returns 0 [signifying "unknown" if both + x and y are 0] if the data is not present or if the + chunk is present but the unit is the pixel) + +For more information, see the png_info definition in png.h and the +PNG specification for chunk contents. Be careful with trusting +rowbytes, as some of the transformations could increase the space +needed to hold a row (expand, filler, gray_to_rgb, etc.). +See png_read_update_info(), below. + +A quick word about text_ptr and num_text. PNG stores comments in +keyword/text pairs, one pair per chunk, with no limit on the number +of text chunks, and a 2^31 byte limit on their size. While there are +suggested keywords, there is no requirement to restrict the use to these +strings. It is strongly suggested that keywords and text be sensible +to humans (that's the point), so don't use abbreviations. Non-printing +symbols are not allowed. See the PNG specification for more details. +There is also no requirement to have text after the keyword. + +Keywords should be limited to 79 Latin-1 characters without leading or +trailing spaces, but non-consecutive spaces are allowed within the +keyword. It is possible to have the same keyword any number of times. +The text_ptr is an array of png_text structures, each holding a +pointer to a language string, a pointer to a keyword and a pointer to +a text string. The text string, language code, and translated +keyword may be empty or NULL pointers. The keyword/text +pairs are put into the array in the order that they are received. +However, some or all of the text chunks may be after the image, so, to +make sure you have read all the text chunks, don't mess with these +until after you read the stuff after the image. This will be +mentioned again below in the discussion that goes with png_read_end(). + +Input transformations + +After you've read the header information, you can set up the library +to handle any special transformations of the image data. The various +ways to transform the data will be described in the order that they +should occur. This is important, as some of these change the color +type and/or bit depth of the data, and some others only work on +certain color types and bit depths. Even though each transformation +checks to see if it has data that it can do something with, you should +make sure to only enable a transformation if it will be valid for the +data. For example, don't swap red and blue on grayscale data. + +The colors used for the background and transparency values should be +supplied in the same format/depth as the current image data. They +are stored in the same format/depth as the image data in a bKGD or tRNS +chunk, so this is what libpng expects for this data. The colors are +transformed to keep in sync with the image data when an application +calls the png_read_update_info() routine (see below). + +Data will be decoded into the supplied row buffers packed into bytes +unless the library has been told to transform it into another format. +For example, 4 bit/pixel paletted or grayscale data will be returned +2 pixels/byte with the leftmost pixel in the high-order bits of the +byte, unless png_set_packing() is called. 8-bit RGB data will be stored +in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha() +is called to insert filler bytes, either before or after each RGB triplet. +16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant +byte of the color value first, unless png_set_strip_16() is called to +transform it to regular RGB RGB triplets, or png_set_filler() or +png_set_add alpha() is called to insert filler bytes, either before or +after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can +be modified with +png_set_filler(), png_set_add_alpha(), or png_set_strip_16(). + +The following code transforms grayscale images of less than 8 to 8 bits, +changes paletted images to RGB, and adds a full alpha channel if there is +transparency information in a tRNS chunk. This is most useful on +grayscale images with bit depths of 2 or 4 or if there is a multiple-image +viewing application that wishes to treat all images in the same way. + + if (color_type == PNG_COLOR_TYPE_PALETTE) + png_set_palette_to_rgb(png_ptr); + + if (color_type == PNG_COLOR_TYPE_GRAY && + bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr); + + if (png_get_valid(png_ptr, info_ptr, + PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); + +These three functions are actually aliases for png_set_expand(), added +in libpng version 1.0.4, with the function names expanded to improve code +readability. In some future version they may actually do different +things. + +As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was +added. It expands the sample depth without changing tRNS to alpha. +At the same time, png_set_gray_1_2_4_to_8() was deprecated, and it +will be removed from a future version. + +PNG can have files with 16 bits per channel. If you only can handle +8 bits per channel, this will strip the pixels down to 8 bit. + + if (bit_depth == 16) + png_set_strip_16(png_ptr); + +If, for some reason, you don't need the alpha channel on an image, +and you want to remove it rather than combining it with the background +(but the image author certainly had in mind that you *would* combine +it with the background, so that's what you should probably do): + + if (color_type & PNG_COLOR_MASK_ALPHA) + png_set_strip_alpha(png_ptr); + +In PNG files, the alpha channel in an image +is the level of opacity. If you need the alpha channel in an image to +be the level of transparency instead of opacity, you can invert the +alpha channel (or the tRNS chunk data) after it's read, so that 0 is +fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit +images) is fully transparent, with + + png_set_invert_alpha(png_ptr); + +PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as +they can, resulting in, for example, 8 pixels per byte for 1 bit +files. This code expands to 1 pixel per byte without changing the +values of the pixels: + + if (bit_depth < 8) + png_set_packing(png_ptr); + +PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels +stored in a PNG image have been "scaled" or "shifted" up to the next +higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to +8 bits/sample in the range [0, 255]). However, it is also possible to +convert the PNG pixel data back to the original bit depth of the image. +This call reduces the pixels back down to the original bit depth: + + png_color_8p sig_bit; + + if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) + png_set_shift(png_ptr, sig_bit); + +PNG files store 3-color pixels in red, green, blue order. This code +changes the storage of the pixels to blue, green, red: + + if (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_bgr(png_ptr); + +PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them +into 4 or 8 bytes for windowing systems that need them in this format: + + if (color_type == PNG_COLOR_TYPE_RGB) + png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE); + +where "filler" is the 8 or 16-bit number to fill with, and the location is +either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether +you want the filler before the RGB or after. This transformation +does not affect images that already have full alpha channels. To add an +opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which +will generate RGBA pixels. + +Note that png_set_filler() does not change the color type. If you want +to do that, you can add a true alpha channel with + + if (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_GRAY) + png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER); + +where "filler" contains the alpha value to assign to each pixel. +This function was added in libpng-1.2.7. + +If you are reading an image with an alpha channel, and you need the +data as ARGB instead of the normal PNG format RGBA: + + if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_swap_alpha(png_ptr); + +For some uses, you may want a grayscale image to be represented as +RGB. This code will do that conversion: + + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png_ptr); + +Conversely, you can convert an RGB or RGBA image to grayscale or grayscale +with alpha. + + if (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_rgb_to_gray_fixed(png_ptr, error_action, + int red_weight, int green_weight); + + error_action = 1: silently do the conversion + error_action = 2: issue a warning if the original + image has any pixel where + red != green or red != blue + error_action = 3: issue an error and abort the + conversion if the original + image has any pixel where + red != green or red != blue + + red_weight: weight of red component times 100000 + green_weight: weight of green component times 100000 + If either weight is negative, default + weights (21268, 71514) are used. + +If you have set error_action = 1 or 2, you can +later check whether the image really was gray, after processing +the image rows, with the png_get_rgb_to_gray_status(png_ptr) function. +It will return a png_byte that is zero if the image was gray or +1 if there were any non-gray pixels. bKGD and sBIT data +will be silently converted to grayscale, using the green channel +data, regardless of the error_action setting. + +With red_weight+green_weight<=100000, +the normalized graylevel is computed: + + int rw = red_weight * 65536; + int gw = green_weight * 65536; + int bw = 65536 - (rw + gw); + gray = (rw*red + gw*green + bw*blue)/65536; + +The default values approximate those recommended in the Charles +Poynton's Color FAQ, +Copyright (c) 1998-01-04 Charles Poynton + + Y = 0.212671 * R + 0.715160 * G + 0.072169 * B + +Libpng approximates this with + + Y = 0.21268 * R + 0.7151 * G + 0.07217 * B + +which can be expressed with integers as + + Y = (6969 * R + 23434 * G + 2365 * B)/32768 + +The calculation is done in a linear colorspace, if the image gamma +is known. + +If you have a grayscale and you are using png_set_expand_depth(), +png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to +a higher bit-depth, you must either supply the background color as a gray +value at the original file bit-depth (need_expand = 1) or else supply the +background color as an RGB triplet at the final, expanded bit depth +(need_expand = 0). Similarly, if you are reading a paletted image, you +must either supply the background color as a palette index (need_expand = 1) +or as an RGB triplet that may or may not be in the palette (need_expand = 0). + + png_color_16 my_background; + png_color_16p image_background; + + if (png_get_bKGD(png_ptr, info_ptr, &image_background)) + png_set_background(png_ptr, image_background, + PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); + else + png_set_background(png_ptr, &my_background, + PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); + +The png_set_background() function tells libpng to composite images +with alpha or simple transparency against the supplied background +color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid), +you may use this color, or supply another color more suitable for +the current display (e.g., the background color from a web page). You +need to tell libpng whether the color is in the gamma space of the +display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file +(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one +that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't +know why anyone would use this, but it's here). + +To properly display PNG images on any kind of system, the application needs +to know what the display gamma is. Ideally, the user will know this, and +the application will allow them to set it. One method of allowing the user +to set the display gamma separately for each system is to check for a +SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be +correctly set. + +Note that display_gamma is the overall gamma correction required to produce +pleasing results, which depends on the lighting conditions in the surrounding +environment. In a dim or brightly lit room, no compensation other than +the physical gamma exponent of the monitor is needed, while in a dark room +a slightly smaller exponent is better. + + double gamma, screen_gamma; + + if (/* We have a user-defined screen + gamma value */) + { + screen_gamma = user_defined_screen_gamma; + } + /* One way that applications can share the same + screen gamma value */ + else if ((gamma_str = getenv("SCREEN_GAMMA")) + != NULL) + { + screen_gamma = (double)atof(gamma_str); + } + /* If we don't have another value */ + else + { + screen_gamma = 2.2; /* A good guess for a + PC monitor in a bright office or a dim room */ + screen_gamma = 2.0; /* A good guess for a + PC monitor in a dark room */ + screen_gamma = 1.7 or 1.0; /* A good + guess for Mac systems */ + } + +The png_set_gamma() function handles gamma transformations of the data. +Pass both the file gamma and the current screen_gamma. If the file does +not have a gamma value, you can pass one anyway if you have an idea what +it is (usually 0.45455 is a good guess for GIF images on PCs). Note +that file gammas are inverted from screen gammas. See the discussions +on gamma in the PNG specification for an excellent description of what +gamma is, and why all applications should support it. It is strongly +recommended that PNG viewers support gamma correction. + + if (png_get_gAMA(png_ptr, info_ptr, &gamma)) + png_set_gamma(png_ptr, screen_gamma, gamma); + else + png_set_gamma(png_ptr, screen_gamma, 0.45455); + +If you need to reduce an RGB file to a paletted file, or if a paletted +file has more entries then will fit on your screen, png_set_dither() +will do that. Note that this is a simple match dither that merely +finds the closest color available. This should work fairly well with +optimized palettes, and fairly badly with linear color cubes. If you +pass a palette that is larger then maximum_colors, the file will +reduce the number of colors in the palette so it will fit into +maximum_colors. If there is a histogram, it will use it to make +more intelligent choices when reducing the palette. If there is no +histogram, it may not do as good a job. + + if (color_type & PNG_COLOR_MASK_COLOR) + { + if (png_get_valid(png_ptr, info_ptr, + PNG_INFO_PLTE)) + { + png_uint_16p histogram = NULL; + + png_get_hIST(png_ptr, info_ptr, + &histogram); + png_set_dither(png_ptr, palette, num_palette, + max_screen_colors, histogram, 1); + } + else + { + png_color std_color_cube[MAX_SCREEN_COLORS] = + { ... colors ... }; + + png_set_dither(png_ptr, std_color_cube, + MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, + NULL,0); + } + } + +PNG files describe monochrome as black being zero and white being one. +The following code will reverse this (make black be one and white be +zero): + + if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY) + png_set_invert_mono(png_ptr); + +This function can also be used to invert grayscale and gray-alpha images: + + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_invert_mono(png_ptr); + +PNG files store 16 bit pixels in network byte order (big-endian, +ie. most significant bits first). This code changes the storage to the +other way (little-endian, i.e. least significant bits first, the +way PCs store them): + + if (bit_depth == 16) + png_set_swap(png_ptr); + +If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you +need to change the order the pixels are packed into bytes, you can use: + + if (bit_depth < 8) + png_set_packswap(png_ptr); + +Finally, you can write your own transformation function if none of +the existing ones meets your needs. This is done by setting a callback +with + + png_set_read_user_transform_fn(png_ptr, + read_transform_fn); + +You must supply the function + + void read_transform_fn(png_ptr ptr, row_info_ptr + row_info, png_bytep data) + +See pngtest.c for a working example. Your function will be called +after all of the other transformations have been processed. + +You can also set up a pointer to a user structure for use by your +callback function, and you can inform libpng that your transform +function will change the number of channels or bit depth with the +function + + png_set_user_transform_info(png_ptr, user_ptr, + user_depth, user_channels); + +The user's application, not libpng, is responsible for allocating and +freeing any memory required for the user structure. + +You can retrieve the pointer via the function +png_get_user_transform_ptr(). For example: + + voidp read_user_transform_ptr = + png_get_user_transform_ptr(png_ptr); + +The last thing to handle is interlacing; this is covered in detail below, +but you must call the function here if you want libpng to handle expansion +of the interlaced image. + + number_of_passes = png_set_interlace_handling(png_ptr); + +After setting the transformations, libpng can update your png_info +structure to reflect any transformations you've requested with this +call. This is most useful to update the info structure's rowbytes +field so you can use it to allocate your image memory. This function +will also update your palette with the correct screen_gamma and +background if these have been given with the calls above. + + png_read_update_info(png_ptr, info_ptr); + +After you call png_read_update_info(), you can allocate any +memory you need to hold the image. The row data is simply +raw byte data for all forms of images. As the actual allocation +varies among applications, no example will be given. If you +are allocating one large chunk, you will need to build an +array of pointers to each row, as it will be needed for some +of the functions below. + +Reading image data + +After you've allocated memory, you can read the image data. +The simplest way to do this is in one function call. If you are +allocating enough memory to hold the whole image, you can just +call png_read_image() and libpng will read in all the image data +and put it in the memory area supplied. You will need to pass in +an array of pointers to each row. + +This function automatically handles interlacing, so you don't need +to call png_set_interlace_handling() or call this function multiple +times, or any of that other stuff necessary with png_read_rows(). + + png_read_image(png_ptr, row_pointers); + +where row_pointers is: + + png_bytep row_pointers[height]; + +You can point to void or char or whatever you use for pixels. + +If you don't want to read in the whole image at once, you can +use png_read_rows() instead. If there is no interlacing (check +interlace_type == PNG_INTERLACE_NONE), this is simple: + + png_read_rows(png_ptr, row_pointers, NULL, + number_of_rows); + +where row_pointers is the same as in the png_read_image() call. + +If you are doing this just one row at a time, you can do this with +a single row_pointer instead of an array of row_pointers: + + png_bytep row_pointer = row; + png_read_row(png_ptr, row_pointer, NULL); + +If the file is interlaced (interlace_type != 0 in the IHDR chunk), things +get somewhat harder. The only current (PNG Specification version 1.2) +interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7) +is a somewhat complicated 2D interlace scheme, known as Adam7, that +breaks down an image into seven smaller images of varying size, based +on an 8x8 grid. + +libpng can fill out those images or it can give them to you "as is". +If you want them filled out, there are two ways to do that. The one +mentioned in the PNG specification is to expand each pixel to cover +those pixels that have not been read yet (the "rectangle" method). +This results in a blocky image for the first pass, which gradually +smooths out as more pixels are read. The other method is the "sparkle" +method, where pixels are drawn only in their final locations, with the +rest of the image remaining whatever colors they were initialized to +before the start of the read. The first method usually looks better, +but tends to be slower, as there are more pixels to put in the rows. + +If you don't want libpng to handle the interlacing details, just call +png_read_rows() seven times to read in all seven images. Each of the +images is a valid image by itself, or they can all be combined on an +8x8 grid to form a single image (although if you intend to combine them +you would be far better off using the libpng interlace handling). + +The first pass will return an image 1/8 as wide as the entire image +(every 8th column starting in column 0) and 1/8 as high as the original +(every 8th row starting in row 0), the second will be 1/8 as wide +(starting in column 4) and 1/8 as high (also starting in row 0). The +third pass will be 1/4 as wide (every 4th pixel starting in column 0) and +1/8 as high (every 8th row starting in row 4), and the fourth pass will +be 1/4 as wide and 1/4 as high (every 4th column starting in column 2, +and every 4th row starting in row 0). The fifth pass will return an +image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2), +while the sixth pass will be 1/2 as wide and 1/2 as high as the original +(starting in column 1 and row 0). The seventh and final pass will be as +wide as the original, and 1/2 as high, containing all of the odd +numbered scanlines. Phew! + +If you want libpng to expand the images, call this before calling +png_start_read_image() or png_read_update_info(): + + if (interlace_type == PNG_INTERLACE_ADAM7) + number_of_passes + = png_set_interlace_handling(png_ptr); + +This will return the number of passes needed. Currently, this +is seven, but may change if another interlace type is added. +This function can be called even if the file is not interlaced, +where it will return one pass. + +If you are not going to display the image after each pass, but are +going to wait until the entire image is read in, use the sparkle +effect. This effect is faster and the end result of either method +is exactly the same. If you are planning on displaying the image +after each pass, the "rectangle" effect is generally considered the +better looking one. + +If you only want the "sparkle" effect, just call png_read_rows() as +normal, with the third parameter NULL. Make sure you make pass over +the image number_of_passes times, and you don't change the data in the +rows between calls. You can change the locations of the data, just +not the data. Each pass only writes the pixels appropriate for that +pass, and assumes the data from previous passes is still valid. + + png_read_rows(png_ptr, row_pointers, NULL, + number_of_rows); + +If you only want the first effect (the rectangles), do the same as +before except pass the row buffer in the third parameter, and leave +the second parameter NULL. + + png_read_rows(png_ptr, NULL, row_pointers, + number_of_rows); + +Finishing a sequential read + +After you are finished reading the image through the +low-level interface, you can finish reading the file. If you are +interested in comments or time, which may be stored either before or +after the image data, you should pass the separate png_info struct if +you want to keep the comments from before and after the image +separate. If you are not interested, you can pass NULL. + + png_read_end(png_ptr, end_info); + +When you are done, you can free all memory allocated by libpng like this: + + png_destroy_read_struct(&png_ptr, &info_ptr, + &end_info); + +It is also possible to individually free the info_ptr members that +point to libpng-allocated storage with the following function: + + png_free_data(png_ptr, info_ptr, mask, seq) + mask - identifies data to be freed, a mask + containing the bitwise OR of one or + more of + PNG_FREE_PLTE, PNG_FREE_TRNS, + PNG_FREE_HIST, PNG_FREE_ICCP, + PNG_FREE_PCAL, PNG_FREE_ROWS, + PNG_FREE_SCAL, PNG_FREE_SPLT, + PNG_FREE_TEXT, PNG_FREE_UNKN, + or simply PNG_FREE_ALL + seq - sequence number of item to be freed + (-1 for all items) + +This function may be safely called when the relevant storage has +already been freed, or has not yet been allocated, or was allocated +by the user and not by libpng, and will in those +cases do nothing. The "seq" parameter is ignored if only one item +of the selected data type, such as PLTE, is allowed. If "seq" is not +-1, and multiple items are allowed for the data type identified in +the mask, such as text or sPLT, only the n'th item in the structure +is freed, where n is "seq". + +The default behavior is only to free data that was allocated internally +by libpng. This can be changed, so that libpng will not free the data, +or so that it will free data that was allocated by the user with png_malloc() +or png_zalloc() and passed in via a png_set_*() function, with + + png_data_freer(png_ptr, info_ptr, freer, mask) + mask - which data elements are affected + same choices as in png_free_data() + freer - one of + PNG_DESTROY_WILL_FREE_DATA + PNG_SET_WILL_FREE_DATA + PNG_USER_WILL_FREE_DATA + +This function only affects data that has already been allocated. +You can call this function after reading the PNG data but before calling +any png_set_*() functions, to control whether the user or the png_set_*() +function is responsible for freeing any existing data that might be present, +and again after the png_set_*() functions to control whether the user +or png_destroy_*() is supposed to free the data. When the user assumes +responsibility for libpng-allocated data, the application must use +png_free() to free it, and when the user transfers responsibility to libpng +for data that the user has allocated, the user must have used png_malloc() +or png_zalloc() to allocate it. + +If you allocated your row_pointers in a single block, as suggested above in +the description of the high level read interface, you must not transfer +responsibility for freeing it to the png_set_rows or png_read_destroy function, +because they would also try to free the individual row_pointers[i]. + +If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword +separately, do not transfer responsibility for freeing text_ptr to libpng, +because when libpng fills a png_text structure it combines these members with +the key member, and png_free_data() will free only text_ptr.key. Similarly, +if you transfer responsibility for free'ing text_ptr from libpng to your +application, your application must not separately free those members. + +The png_free_data() function will turn off the "valid" flag for anything +it frees. If you need to turn the flag off for a chunk that was freed by your +application instead of by libpng, you can use + + png_set_invalid(png_ptr, info_ptr, mask); + mask - identifies the chunks to be made invalid, + containing the bitwise OR of one or + more of + PNG_INFO_gAMA, PNG_INFO_sBIT, + PNG_INFO_cHRM, PNG_INFO_PLTE, + PNG_INFO_tRNS, PNG_INFO_bKGD, + PNG_INFO_hIST, PNG_INFO_pHYs, + PNG_INFO_oFFs, PNG_INFO_tIME, + PNG_INFO_pCAL, PNG_INFO_sRGB, + PNG_INFO_iCCP, PNG_INFO_sPLT, + PNG_INFO_sCAL, PNG_INFO_IDAT + +For a more compact example of reading a PNG image, see the file example.c. + +Reading PNG files progressively + +The progressive reader is slightly different then the non-progressive +reader. Instead of calling png_read_info(), png_read_rows(), and +png_read_end(), you make one call to png_process_data(), which calls +callbacks when it has the info, a row, or the end of the image. You +set up these callbacks with png_set_progressive_read_fn(). You don't +have to worry about the input/output functions of libpng, as you are +giving the library the data directly in png_process_data(). I will +assume that you have read the section on reading PNG files above, +so I will only highlight the differences (although I will show +all of the code). + +png_structp png_ptr; +png_infop info_ptr; + + /* An example code fragment of how you would + initialize the progressive reader in your + application. */ + int + initialize_png_reader() + { + png_ptr = png_create_read_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn); + if (!png_ptr) + return (ERROR); + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + png_destroy_read_struct(&png_ptr, (png_infopp)NULL, + (png_infopp)NULL); + return (ERROR); + } + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + (png_infopp)NULL); + return (ERROR); + } + + /* This one's new. You can provide functions + to be called when the header info is valid, + when each row is completed, and when the image + is finished. If you aren't using all functions, + you can specify NULL parameters. Even when all + three functions are NULL, you need to call + png_set_progressive_read_fn(). You can use + any struct as the user_ptr (cast to a void pointer + for the function call), and retrieve the pointer + from inside the callbacks using the function + + png_get_progressive_ptr(png_ptr); + + which will return a void pointer, which you have + to cast appropriately. + */ + png_set_progressive_read_fn(png_ptr, (void *)user_ptr, + info_callback, row_callback, end_callback); + + return 0; + } + + /* A code fragment that you call as you receive blocks + of data */ + int + process_data(png_bytep buffer, png_uint_32 length) + { + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + (png_infopp)NULL); + return (ERROR); + } + + /* This one's new also. Simply give it a chunk + of data from the file stream (in order, of + course). On machines with segmented memory + models machines, don't give it any more than + 64K. The library seems to run fine with sizes + of 4K. Although you can give it much less if + necessary (I assume you can give it chunks of + 1 byte, I haven't tried less then 256 bytes + yet). When this function returns, you may + want to display any rows that were generated + in the row callback if you don't already do + so there. + */ + png_process_data(png_ptr, info_ptr, buffer, length); + return 0; + } + + /* This function is called (as set by + png_set_progressive_read_fn() above) when enough data + has been supplied so all of the header has been + read. + */ + void + info_callback(png_structp png_ptr, png_infop info) + { + /* Do any setup here, including setting any of + the transformations mentioned in the Reading + PNG files section. For now, you _must_ call + either png_start_read_image() or + png_read_update_info() after all the + transformations are set (even if you don't set + any). You may start getting rows before + png_process_data() returns, so this is your + last chance to prepare for that. + */ + } + + /* This function is called when each row of image + data is complete */ + void + row_callback(png_structp png_ptr, png_bytep new_row, + png_uint_32 row_num, int pass) + { + /* If the image is interlaced, and you turned + on the interlace handler, this function will + be called for every row in every pass. Some + of these rows will not be changed from the + previous pass. When the row is not changed, + the new_row variable will be NULL. The rows + and passes are called in order, so you don't + really need the row_num and pass, but I'm + supplying them because it may make your life + easier. + + For the non-NULL rows of interlaced images, + you must call png_progressive_combine_row() + passing in the row and the old row. You can + call this function for NULL rows (it will just + return) and for non-interlaced images (it just + does the memcpy for you) if it will make the + code easier. Thus, you can just do this for + all cases: + */ + + png_progressive_combine_row(png_ptr, old_row, + new_row); + + /* where old_row is what was displayed for + previously for the row. Note that the first + pass (pass == 0, really) will completely cover + the old row, so the rows do not have to be + initialized. After the first pass (and only + for interlaced images), you will have to pass + the current row, and the function will combine + the old row and the new row. + */ + } + + void + end_callback(png_structp png_ptr, png_infop info) + { + /* This function is called after the whole image + has been read, including any chunks after the + image (up to and including the IEND). You + will usually have the same info chunk as you + had in the header, although some data may have + been added to the comments and time fields. + + Most people won't do much here, perhaps setting + a flag that marks the image as finished. + */ + } + + + +IV. Writing + +Much of this is very similar to reading. However, everything of +importance is repeated here, so you won't have to constantly look +back up in the reading section to understand writing. + +Setup + +You will want to do the I/O initialization before you get into libpng, +so if it doesn't work, you don't have anything to undo. If you are not +using the standard I/O functions, you will need to replace them with +custom writing functions. See the discussion under Customizing libpng. + + FILE *fp = fopen(file_name, "wb"); + if (!fp) + { + return (ERROR); + } + +Next, png_struct and png_info need to be allocated and initialized. +As these can be both relatively large, you may not want to store these +on the stack, unless you have stack space to spare. Of course, you +will want to check if they return NULL. If you are also reading, +you won't want to name your read structure and your write structure +both "png_ptr"; you can call them anything you like, such as +"read_ptr" and "write_ptr". Look at pngtest.c, for example. + + png_structp png_ptr = png_create_write_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn); + if (!png_ptr) + return (ERROR); + + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + png_destroy_write_struct(&png_ptr, + (png_infopp)NULL); + return (ERROR); + } + +If you want to use your own memory allocation routines, +define PNG_USER_MEM_SUPPORTED and use +png_create_write_struct_2() instead of png_create_write_struct(): + + png_structp png_ptr = png_create_write_struct_2 + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn, (png_voidp) + user_mem_ptr, user_malloc_fn, user_free_fn); + +After you have these structures, you will need to set up the +error handling. When libpng encounters an error, it expects to +longjmp() back to your routine. Therefore, you will need to call +setjmp() and pass the png_jmpbuf(png_ptr). If you +write the file from different routines, you will need to update +the png_jmpbuf(png_ptr) every time you enter a new routine that will +call a png_*() function. See your documentation of setjmp/longjmp +for your compiler for more information on setjmp/longjmp. See +the discussion on libpng error handling in the Customizing Libpng +section below for more information on the libpng error handling. + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_write_struct(&png_ptr, &info_ptr); + fclose(fp); + return (ERROR); + } + ... + return; + +If you would rather avoid the complexity of setjmp/longjmp issues, +you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case +errors will result in a call to PNG_ABORT() which defaults to abort(). + +Now you need to set up the output code. The default for libpng is to +use the C function fwrite(). If you use this, you will need to pass a +valid FILE * in the function png_init_io(). Be sure that the file is +opened in binary mode. Again, if you wish to handle writing data in +another way, see the discussion on libpng I/O handling in the Customizing +Libpng section below. + + png_init_io(png_ptr, fp); + +If you are embedding your PNG into a datastream such as MNG, and don't +want libpng to write the 8-byte signature, or if you have already +written the signature in your application, use + + png_set_sig_bytes(png_ptr, 8); + +to inform libpng that it should not write a signature. + +Write callbacks + +At this point, you can set up a callback function that will be +called after each row has been written, which you can use to control +a progress meter or the like. It's demonstrated in pngtest.c. +You must supply a function + + void write_row_callback(png_ptr, png_uint_32 row, + int pass); + { + /* put your code here */ + } + +(You can give it another name that you like instead of "write_row_callback") + +To inform libpng about your function, use + + png_set_write_status_fn(png_ptr, write_row_callback); + +You now have the option of modifying how the compression library will +run. The following functions are mainly for testing, but may be useful +in some cases, like if you need to write PNG files extremely fast and +are willing to give up some compression, or if you want to get the +maximum possible compression at the expense of slower writing. If you +have no special needs in this area, let the library do what it wants by +not calling this function at all, as it has been tuned to deliver a good +speed/compression ratio. The second parameter to png_set_filter() is +the filter method, for which the only valid values are 0 (as of the +July 1999 PNG specification, version 1.2) or 64 (if you are writing +a PNG datastream that is to be embedded in a MNG datastream). The third +parameter is a flag that indicates which filter type(s) are to be tested +for each scanline. See the PNG specification for details on the specific filter +types. + + + /* turn on or off filtering, and/or choose + specific filters. You can use either a single + PNG_FILTER_VALUE_NAME or the bitwise OR of one + or more PNG_FILTER_NAME masks. */ + png_set_filter(png_ptr, 0, + PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | + PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | + PNG_FILTER_UP | PNG_FILTER_VALUE_UP | + PNG_FILTER_AVE | PNG_FILTER_VALUE_AVE | + PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| + PNG_ALL_FILTERS); + +If an application +wants to start and stop using particular filters during compression, +it should start out with all of the filters (to ensure that the previous +row of pixels will be stored in case it's needed later), and then add +and remove them after the start of compression. + +If you are writing a PNG datastream that is to be embedded in a MNG +datastream, the second parameter can be either 0 or 64. + +The png_set_compression_*() functions interface to the zlib compression +library, and should mostly be ignored unless you really know what you are +doing. The only generally useful call is png_set_compression_level() +which changes how much time zlib spends on trying to compress the image +data. See the Compression Library (zlib.h and algorithm.txt, distributed +with zlib) for details on the compression levels. + + /* set the zlib compression level */ + png_set_compression_level(png_ptr, + Z_BEST_COMPRESSION); + + /* set other zlib parameters */ + png_set_compression_mem_level(png_ptr, 8); + png_set_compression_strategy(png_ptr, + Z_DEFAULT_STRATEGY); + png_set_compression_window_bits(png_ptr, 15); + png_set_compression_method(png_ptr, 8); + png_set_compression_buffer_size(png_ptr, 8192) + +extern PNG_EXPORT(void,png_set_zbuf_size) + +Setting the contents of info for output + +You now need to fill in the png_info structure with all the data you +wish to write before the actual image. Note that the only thing you +are allowed to write after the image is the text chunks and the time +chunk (as of PNG Specification 1.2, anyway). See png_write_end() and +the latest PNG specification for more information on that. If you +wish to write them before the image, fill them in now, and flag that +data as being valid. If you want to wait until after the data, don't +fill them until png_write_end(). For all the fields in png_info and +their data types, see png.h. For explanations of what the fields +contain, see the PNG specification. + +Some of the more important parts of the png_info are: + + png_set_IHDR(png_ptr, info_ptr, width, height, + bit_depth, color_type, interlace_type, + compression_type, filter_method) + width - holds the width of the image + in pixels (up to 2^31). + height - holds the height of the image + in pixels (up to 2^31). + bit_depth - holds the bit depth of one of the + image channels. + (valid values are 1, 2, 4, 8, 16 + and depend also on the + color_type. See also significant + bits (sBIT) below). + color_type - describes which color/alpha + channels are present. + PNG_COLOR_TYPE_GRAY + (bit depths 1, 2, 4, 8, 16) + PNG_COLOR_TYPE_GRAY_ALPHA + (bit depths 8, 16) + PNG_COLOR_TYPE_PALETTE + (bit depths 1, 2, 4, 8) + PNG_COLOR_TYPE_RGB + (bit_depths 8, 16) + PNG_COLOR_TYPE_RGB_ALPHA + (bit_depths 8, 16) + + PNG_COLOR_MASK_PALETTE + PNG_COLOR_MASK_COLOR + PNG_COLOR_MASK_ALPHA + + interlace_type - PNG_INTERLACE_NONE or + PNG_INTERLACE_ADAM7 + compression_type - (must be + PNG_COMPRESSION_TYPE_DEFAULT) + filter_method - (must be PNG_FILTER_TYPE_DEFAULT + or, if you are writing a PNG to + be embedded in a MNG datastream, + can also be + PNG_INTRAPIXEL_DIFFERENCING) + + png_set_PLTE(png_ptr, info_ptr, palette, + num_palette); + palette - the palette for the file + (array of png_color) + num_palette - number of entries in the palette + + png_set_gAMA(png_ptr, info_ptr, gamma); + gamma - the gamma the image was created + at (PNG_INFO_gAMA) + + png_set_sRGB(png_ptr, info_ptr, srgb_intent); + srgb_intent - the rendering intent + (PNG_INFO_sRGB) The presence of + the sRGB chunk means that the pixel + data is in the sRGB color space. + This chunk also implies specific + values of gAMA and cHRM. Rendering + intent is the CSS-1 property that + has been defined by the International + Color Consortium + (http://www.color.org). + It can be one of + PNG_sRGB_INTENT_SATURATION, + PNG_sRGB_INTENT_PERCEPTUAL, + PNG_sRGB_INTENT_ABSOLUTE, or + PNG_sRGB_INTENT_RELATIVE. + + + png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, + srgb_intent); + srgb_intent - the rendering intent + (PNG_INFO_sRGB) The presence of the + sRGB chunk means that the pixel + data is in the sRGB color space. + This function also causes gAMA and + cHRM chunks with the specific values + that are consistent with sRGB to be + written. + + png_set_iCCP(png_ptr, info_ptr, name, compression_type, + profile, proflen); + name - The profile name. + compression - The compression type; always + PNG_COMPRESSION_TYPE_BASE for PNG 1.0. + You may give NULL to this argument to + ignore it. + profile - International Color Consortium color + profile data. May contain NULs. + proflen - length of profile data in bytes. + + png_set_sBIT(png_ptr, info_ptr, sig_bit); + sig_bit - the number of significant bits for + (PNG_INFO_sBIT) each of the gray, red, + green, and blue channels, whichever are + appropriate for the given color type + (png_color_16) + + png_set_tRNS(png_ptr, info_ptr, trans, num_trans, + trans_values); + trans - array of transparent entries for + palette (PNG_INFO_tRNS) + trans_values - graylevel or color sample values of + the single transparent color for + non-paletted images (PNG_INFO_tRNS) + num_trans - number of transparent entries + (PNG_INFO_tRNS) + + png_set_hIST(png_ptr, info_ptr, hist); + (PNG_INFO_hIST) + hist - histogram of palette (array of + png_uint_16) + + png_set_tIME(png_ptr, info_ptr, mod_time); + mod_time - time image was last modified + (PNG_VALID_tIME) + + png_set_bKGD(png_ptr, info_ptr, background); + background - background color (PNG_VALID_bKGD) + + png_set_text(png_ptr, info_ptr, text_ptr, num_text); + text_ptr - array of png_text holding image + comments + text_ptr[i].compression - type of compression used + on "text" PNG_TEXT_COMPRESSION_NONE + PNG_TEXT_COMPRESSION_zTXt + PNG_ITXT_COMPRESSION_NONE + PNG_ITXT_COMPRESSION_zTXt + text_ptr[i].key - keyword for comment. Must contain + 1-79 characters. + text_ptr[i].text - text comments for current + keyword. Can be NULL or empty. + text_ptr[i].text_length - length of text string, + after decompression, 0 for iTXt + text_ptr[i].itxt_length - length of itxt string, + after decompression, 0 for tEXt/zTXt + text_ptr[i].lang - language of comment (NULL or + empty for unknown). + text_ptr[i].translated_keyword - keyword in UTF-8 (NULL + or empty for unknown). + num_text - number of comments + + png_set_sPLT(png_ptr, info_ptr, &palette_ptr, + num_spalettes); + palette_ptr - array of png_sPLT_struct structures + to be added to the list of palettes + in the info structure. + num_spalettes - number of palette structures to be + added. + + png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, + unit_type); + offset_x - positive offset from the left + edge of the screen + offset_y - positive offset from the top + edge of the screen + unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER + + png_set_pHYs(png_ptr, info_ptr, res_x, res_y, + unit_type); + res_x - pixels/unit physical resolution + in x direction + res_y - pixels/unit physical resolution + in y direction + unit_type - PNG_RESOLUTION_UNKNOWN, + PNG_RESOLUTION_METER + + png_set_sCAL(png_ptr, info_ptr, unit, width, height) + unit - physical scale units (an integer) + width - width of a pixel in physical scale units + height - height of a pixel in physical scale units + (width and height are doubles) + + png_set_sCAL_s(png_ptr, info_ptr, unit, width, height) + unit - physical scale units (an integer) + width - width of a pixel in physical scale units + height - height of a pixel in physical scale units + (width and height are strings like "2.54") + + png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, + num_unknowns) + unknowns - array of png_unknown_chunk + structures holding unknown chunks + unknowns[i].name - name of unknown chunk + unknowns[i].data - data of unknown chunk + unknowns[i].size - size of unknown chunk's data + unknowns[i].location - position to write chunk in file + 0: do not write chunk + PNG_HAVE_IHDR: before PLTE + PNG_HAVE_PLTE: before IDAT + PNG_AFTER_IDAT: after IDAT + +The "location" member is set automatically according to +what part of the output file has already been written. +You can change its value after calling png_set_unknown_chunks() +as demonstrated in pngtest.c. Within each of the "locations", +the chunks are sequenced according to their position in the +structure (that is, the value of "i", which is the order in which +the chunk was either read from the input file or defined with +png_set_unknown_chunks). + +A quick word about text and num_text. text is an array of png_text +structures. num_text is the number of valid structures in the array. +Each png_text structure holds a language code, a keyword, a text value, +and a compression type. + +The compression types have the same valid numbers as the compression +types of the image data. Currently, the only valid number is zero. +However, you can store text either compressed or uncompressed, unlike +images, which always have to be compressed. So if you don't want the +text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. +Because tEXt and zTXt chunks don't have a language field, if you +specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt +any language code or translated keyword will not be written out. + +Until text gets around 1000 bytes, it is not worth compressing it. +After the text has been written out to the file, the compression type +is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR, +so that it isn't written out again at the end (in case you are calling +png_write_end() with the same struct. + +The keywords that are given in the PNG Specification are: + + Title Short (one line) title or + caption for image + Author Name of image's creator + Description Description of image (possibly long) + Copyright Copyright notice + Creation Time Time of original image creation + (usually RFC 1123 format, see below) + Software Software used to create the image + Disclaimer Legal disclaimer + Warning Warning of nature of content + Source Device used to create the image + Comment Miscellaneous comment; conversion + from other image format + +The keyword-text pairs work like this. Keywords should be short +simple descriptions of what the comment is about. Some typical +keywords are found in the PNG specification, as is some recommendations +on keywords. You can repeat keywords in a file. You can even write +some text before the image and some after. For example, you may want +to put a description of the image before the image, but leave the +disclaimer until after, so viewers working over modem connections +don't have to wait for the disclaimer to go over the modem before +they start seeing the image. Finally, keywords should be full +words, not abbreviations. Keywords and text are in the ISO 8859-1 +(Latin-1) character set (a superset of regular ASCII) and can not +contain NUL characters, and should not contain control or other +unprintable characters. To make the comments widely readable, stick +with basic ASCII, and avoid machine specific character set extensions +like the IBM-PC character set. The keyword must be present, but +you can leave off the text string on non-compressed pairs. +Compressed pairs must have a text string, as only the text string +is compressed anyway, so the compression would be meaningless. + +PNG supports modification time via the png_time structure. Two +conversion routines are provided, png_convert_from_time_t() for +time_t and png_convert_from_struct_tm() for struct tm. The +time_t routine uses gmtime(). You don't have to use either of +these, but if you wish to fill in the png_time structure directly, +you should provide the time in universal time (GMT) if possible +instead of your local time. Note that the year number is the full +year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and +that months start with 1. + +If you want to store the time of the original image creation, you should +use a plain tEXt chunk with the "Creation Time" keyword. This is +necessary because the "creation time" of a PNG image is somewhat vague, +depending on whether you mean the PNG file, the time the image was +created in a non-PNG format, a still photo from which the image was +scanned, or possibly the subject matter itself. In order to facilitate +machine-readable dates, it is recommended that the "Creation Time" +tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), +although this isn't a requirement. Unlike the tIME chunk, the +"Creation Time" tEXt chunk is not expected to be automatically changed +by the software. To facilitate the use of RFC 1123 dates, a function +png_convert_to_rfc1123(png_timep) is provided to convert from PNG +time to an RFC 1123 format string. + +Writing unknown chunks + +You can use the png_set_unknown_chunks function to queue up chunks +for writing. You give it a chunk name, raw data, and a size; that's +all there is to it. The chunks will be written by the next following +png_write_info_before_PLTE, png_write_info, or png_write_end function. +Any chunks previously read into the info structure's unknown-chunk +list will also be written out in a sequence that satisfies the PNG +specification's ordering rules. + +The high-level write interface + +At this point there are two ways to proceed; through the high-level +write interface, or through a sequence of low-level write operations. +You can use the high-level interface if your image data is present +in the info structure. All defined output +transformations are permitted, enabled by the following masks. + + PNG_TRANSFORM_IDENTITY No transformation + PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples + PNG_TRANSFORM_PACKSWAP Change order of packed + pixels to LSB first + PNG_TRANSFORM_INVERT_MONO Invert monochrome images + PNG_TRANSFORM_SHIFT Normalize pixels to the + sBIT depth + PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA + to BGRA + PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA + to AG + PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity + to transparency + PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples + PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes. + +If you have valid image data in the info structure (you can use +png_set_rows() to put image data in the info structure), simply do this: + + png_write_png(png_ptr, info_ptr, png_transforms, NULL) + +where png_transforms is an integer containing the bitwise OR of some set of +transformation flags. This call is equivalent to png_write_info(), +followed the set of transformations indicated by the transform mask, +then png_write_image(), and finally png_write_end(). + +(The final parameter of this call is not yet used. Someday it might point +to transformation parameters required by some future output transform.) + +You must use png_transforms and not call any png_set_transform() functions +when you use png_write_png(). + +The low-level write interface + +If you are going the low-level route instead, you are now ready to +write all the file information up to the actual image data. You do +this with a call to png_write_info(). + + png_write_info(png_ptr, info_ptr); + +Note that there is one transformation you may need to do before +png_write_info(). In PNG files, the alpha channel in an image is the +level of opacity. If your data is supplied as a level of +transparency, you can invert the alpha channel before you write it, so +that 0 is fully transparent and 255 (in 8-bit or paletted images) or +65535 (in 16-bit images) is fully opaque, with + + png_set_invert_alpha(png_ptr); + +This must appear before png_write_info() instead of later with the +other transformations because in the case of paletted images the tRNS +chunk data has to be inverted before the tRNS chunk is written. If +your image is not a paletted image, the tRNS data (which in such cases +represents a single color to be rendered as transparent) won't need to +be changed, and you can safely do this transformation after your +png_write_info() call. + +If you need to write a private chunk that you want to appear before +the PLTE chunk when PLTE is present, you can write the PNG info in +two steps, and insert code to write your own chunk between them: + + png_write_info_before_PLTE(png_ptr, info_ptr); + png_set_unknown_chunks(png_ptr, info_ptr, ...); + png_write_info(png_ptr, info_ptr); + +After you've written the file information, you can set up the library +to handle any special transformations of the image data. The various +ways to transform the data will be described in the order that they +should occur. This is important, as some of these change the color +type and/or bit depth of the data, and some others only work on +certain color types and bit depths. Even though each transformation +checks to see if it has data that it can do something with, you should +make sure to only enable a transformation if it will be valid for the +data. For example, don't swap red and blue on grayscale data. + +PNG files store RGB pixels packed into 3 or 6 bytes. This code tells +the library to strip input data that has 4 or 8 bytes per pixel down +to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2 +bytes per pixel). + + png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); + +where the 0 is unused, and the location is either PNG_FILLER_BEFORE or +PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel +is stored XRGB or RGBX. + +PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as +they can, resulting in, for example, 8 pixels per byte for 1 bit files. +If the data is supplied at 1 pixel per byte, use this code, which will +correctly pack the pixels into a single byte: + + png_set_packing(png_ptr); + +PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your +data is of another bit depth, you can write an sBIT chunk into the +file so that decoders can recover the original data if desired. + + /* Set the true bit depth of the image data */ + if (color_type & PNG_COLOR_MASK_COLOR) + { + sig_bit.red = true_bit_depth; + sig_bit.green = true_bit_depth; + sig_bit.blue = true_bit_depth; + } + else + { + sig_bit.gray = true_bit_depth; + } + if (color_type & PNG_COLOR_MASK_ALPHA) + { + sig_bit.alpha = true_bit_depth; + } + + png_set_sBIT(png_ptr, info_ptr, &sig_bit); + +If the data is stored in the row buffer in a bit depth other than +one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG), +this will scale the values to appear to be the correct bit depth as +is required by PNG. + + png_set_shift(png_ptr, &sig_bit); + +PNG files store 16 bit pixels in network byte order (big-endian, +ie. most significant bits first). This code would be used if they are +supplied the other way (little-endian, i.e. least significant bits +first, the way PCs store them): + + if (bit_depth > 8) + png_set_swap(png_ptr); + +If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you +need to change the order the pixels are packed into bytes, you can use: + + if (bit_depth < 8) + png_set_packswap(png_ptr); + +PNG files store 3 color pixels in red, green, blue order. This code +would be used if they are supplied as blue, green, red: + + png_set_bgr(png_ptr); + +PNG files describe monochrome as black being zero and white being +one. This code would be used if the pixels are supplied with this reversed +(black being one and white being zero): + + png_set_invert_mono(png_ptr); + +Finally, you can write your own transformation function if none of +the existing ones meets your needs. This is done by setting a callback +with + + png_set_write_user_transform_fn(png_ptr, + write_transform_fn); + +You must supply the function + + void write_transform_fn(png_ptr ptr, row_info_ptr + row_info, png_bytep data) + +See pngtest.c for a working example. Your function will be called +before any of the other transformations are processed. + +You can also set up a pointer to a user structure for use by your +callback function. + + png_set_user_transform_info(png_ptr, user_ptr, 0, 0); + +The user_channels and user_depth parameters of this function are ignored +when writing; you can set them to zero as shown. + +You can retrieve the pointer via the function png_get_user_transform_ptr(). +For example: + + voidp write_user_transform_ptr = + png_get_user_transform_ptr(png_ptr); + +It is possible to have libpng flush any pending output, either manually, +or automatically after a certain number of lines have been written. To +flush the output stream a single time call: + + png_write_flush(png_ptr); + +and to have libpng flush the output stream periodically after a certain +number of scanlines have been written, call: + + png_set_flush(png_ptr, nrows); + +Note that the distance between rows is from the last time png_write_flush() +was called, or the first row of the image if it has never been called. +So if you write 50 lines, and then png_set_flush 25, it will flush the +output on the next scanline, and every 25 lines thereafter, unless +png_write_flush() is called before 25 more lines have been written. +If nrows is too small (less than about 10 lines for a 640 pixel wide +RGB image) the image compression may decrease noticeably (although this +may be acceptable for real-time applications). Infrequent flushing will +only degrade the compression performance by a few percent over images +that do not use flushing. + +Writing the image data + +That's it for the transformations. Now you can write the image data. +The simplest way to do this is in one function call. If you have the +whole image in memory, you can just call png_write_image() and libpng +will write the image. You will need to pass in an array of pointers to +each row. This function automatically handles interlacing, so you don't +need to call png_set_interlace_handling() or call this function multiple +times, or any of that other stuff necessary with png_write_rows(). + + png_write_image(png_ptr, row_pointers); + +where row_pointers is: + + png_byte *row_pointers[height]; + +You can point to void or char or whatever you use for pixels. + +If you don't want to write the whole image at once, you can +use png_write_rows() instead. If the file is not interlaced, +this is simple: + + png_write_rows(png_ptr, row_pointers, + number_of_rows); + +row_pointers is the same as in the png_write_image() call. + +If you are just writing one row at a time, you can do this with +a single row_pointer instead of an array of row_pointers: + + png_bytep row_pointer = row; + + png_write_row(png_ptr, row_pointer); + +When the file is interlaced, things can get a good deal more +complicated. The only currently (as of the PNG Specification +version 1.2, dated July 1999) defined interlacing scheme for PNG files +is the "Adam7" interlace scheme, that breaks down an +image into seven smaller images of varying size. libpng will build +these images for you, or you can do them yourself. If you want to +build them yourself, see the PNG specification for details of which +pixels to write when. + +If you don't want libpng to handle the interlacing details, just +use png_set_interlace_handling() and call png_write_rows() the +correct number of times to write all seven sub-images. + +If you want libpng to build the sub-images, call this before you start +writing any rows: + + number_of_passes = + png_set_interlace_handling(png_ptr); + +This will return the number of passes needed. Currently, this +is seven, but may change if another interlace type is added. + +Then write the complete image number_of_passes times. + + png_write_rows(png_ptr, row_pointers, + number_of_rows); + +As some of these rows are not used, and thus return immediately, +you may want to read about interlacing in the PNG specification, +and only update the rows that are actually used. + +Finishing a sequential write + +After you are finished writing the image, you should finish writing +the file. If you are interested in writing comments or time, you should +pass an appropriately filled png_info pointer. If you are not interested, +you can pass NULL. + + png_write_end(png_ptr, info_ptr); + +When you are done, you can free all memory used by libpng like this: + + png_destroy_write_struct(&png_ptr, &info_ptr); + +It is also possible to individually free the info_ptr members that +point to libpng-allocated storage with the following function: + + png_free_data(png_ptr, info_ptr, mask, seq) + mask - identifies data to be freed, a mask + containing the bitwise OR of one or + more of + PNG_FREE_PLTE, PNG_FREE_TRNS, + PNG_FREE_HIST, PNG_FREE_ICCP, + PNG_FREE_PCAL, PNG_FREE_ROWS, + PNG_FREE_SCAL, PNG_FREE_SPLT, + PNG_FREE_TEXT, PNG_FREE_UNKN, + or simply PNG_FREE_ALL + seq - sequence number of item to be freed + (-1 for all items) + +This function may be safely called when the relevant storage has +already been freed, or has not yet been allocated, or was allocated +by the user and not by libpng, and will in those +cases do nothing. The "seq" parameter is ignored if only one item +of the selected data type, such as PLTE, is allowed. If "seq" is not +-1, and multiple items are allowed for the data type identified in +the mask, such as text or sPLT, only the n'th item in the structure +is freed, where n is "seq". + +If you allocated data such as a palette that you passed +in to libpng with png_set_*, you must not free it until just before the call to +png_destroy_write_struct(). + +The default behavior is only to free data that was allocated internally +by libpng. This can be changed, so that libpng will not free the data, +or so that it will free data that was allocated by the user with png_malloc() +or png_zalloc() and passed in via a png_set_*() function, with + + png_data_freer(png_ptr, info_ptr, freer, mask) + mask - which data elements are affected + same choices as in png_free_data() + freer - one of + PNG_DESTROY_WILL_FREE_DATA + PNG_SET_WILL_FREE_DATA + PNG_USER_WILL_FREE_DATA + +For example, to transfer responsibility for some data from a read structure +to a write structure, you could use + + png_data_freer(read_ptr, read_info_ptr, + PNG_USER_WILL_FREE_DATA, + PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) + png_data_freer(write_ptr, write_info_ptr, + PNG_DESTROY_WILL_FREE_DATA, + PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) + +thereby briefly reassigning responsibility for freeing to the user but +immediately afterwards reassigning it once more to the write_destroy +function. Having done this, it would then be safe to destroy the read +structure and continue to use the PLTE, tRNS, and hIST data in the write +structure. + +This function only affects data that has already been allocated. +You can call this function before calling after the png_set_*() functions +to control whether the user or png_destroy_*() is supposed to free the data. +When the user assumes responsibility for libpng-allocated data, the +application must use +png_free() to free it, and when the user transfers responsibility to libpng +for data that the user has allocated, the user must have used png_malloc() +or png_zalloc() to allocate it. + +If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword +separately, do not transfer responsibility for freeing text_ptr to libpng, +because when libpng fills a png_text structure it combines these members with +the key member, and png_free_data() will free only text_ptr.key. Similarly, +if you transfer responsibility for free'ing text_ptr from libpng to your +application, your application must not separately free those members. +For a more compact example of writing a PNG image, see the file example.c. + +V. Modifying/Customizing libpng: + +There are three issues here. The first is changing how libpng does +standard things like memory allocation, input/output, and error handling. +The second deals with more complicated things like adding new chunks, +adding new transformations, and generally changing how libpng works. +Both of those are compile-time issues; that is, they are generally +determined at the time the code is written, and there is rarely a need +to provide the user with a means of changing them. The third is a +run-time issue: choosing between and/or tuning one or more alternate +versions of computationally intensive routines; specifically, optimized +assembly-language (and therefore compiler- and platform-dependent) +versions. + +Memory allocation, input/output, and error handling + +All of the memory allocation, input/output, and error handling in libpng +goes through callbacks that are user-settable. The default routines are +in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change +these functions, call the appropriate png_set_*_fn() function. + +Memory allocation is done through the functions png_malloc() +and png_free(). These currently just call the standard C functions. If +your pointers can't access more then 64K at a time, you will want to set +MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling +memory allocation on a platform will change between applications, these +functions must be modified in the library at compile time. If you prefer +to use a different method of allocating and freeing data, you can use +png_create_read_struct_2() or png_create_write_struct_2() to register +your own functions as described above. +These functions also provide a void pointer that can be retrieved via + + mem_ptr=png_get_mem_ptr(png_ptr); + +Your replacement memory functions must have prototypes as follows: + + png_voidp malloc_fn(png_structp png_ptr, + png_size_t size); + void free_fn(png_structp png_ptr, png_voidp ptr); + +Your malloc_fn() must return NULL in case of failure. The png_malloc() +function will normally call png_error() if it receives a NULL from the +system memory allocator or from your replacement malloc_fn(). + +Input/Output in libpng is done through png_read() and png_write(), +which currently just call fread() and fwrite(). The FILE * is stored in +png_struct and is initialized via png_init_io(). If you wish to change +the method of I/O, the library supplies callbacks that you can set +through the function png_set_read_fn() and png_set_write_fn() at run +time, instead of calling the png_init_io() function. These functions +also provide a void pointer that can be retrieved via the function +png_get_io_ptr(). For example: + + png_set_read_fn(png_structp read_ptr, + voidp read_io_ptr, png_rw_ptr read_data_fn) + + png_set_write_fn(png_structp write_ptr, + voidp write_io_ptr, png_rw_ptr write_data_fn, + png_flush_ptr output_flush_fn); + + voidp read_io_ptr = png_get_io_ptr(read_ptr); + voidp write_io_ptr = png_get_io_ptr(write_ptr); + +The replacement I/O functions must have prototypes as follows: + + void user_read_data(png_structp png_ptr, + png_bytep data, png_size_t length); + void user_write_data(png_structp png_ptr, + png_bytep data, png_size_t length); + void user_flush_data(png_structp png_ptr); + +Supplying NULL for the read, write, or flush functions sets them back +to using the default C stream functions. It is an error to read from +a write stream, and vice versa. + +Error handling in libpng is done through png_error() and png_warning(). +Errors handled through png_error() are fatal, meaning that png_error() +should never return to its caller. Currently, this is handled via +setjmp() and longjmp() (unless you have compiled libpng with +PNG_SETJMP_NOT_SUPPORTED, in which case it is handled via PNG_ABORT()), +but you could change this to do things like exit() if you should wish. + +On non-fatal errors, png_warning() is called +to print a warning message, and then control returns to the calling code. +By default png_error() and png_warning() print a message on stderr via +fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined +(because you don't want the messages) or PNG_NO_STDIO defined (because +fprintf() isn't available). If you wish to change the behavior of the error +functions, you will need to set up your own message callbacks. These +functions are normally supplied at the time that the png_struct is created. +It is also possible to redirect errors and warnings to your own replacement +functions after png_create_*_struct() has been called by calling: + + png_set_error_fn(png_structp png_ptr, + png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warning_fn); + + png_voidp error_ptr = png_get_error_ptr(png_ptr); + +If NULL is supplied for either error_fn or warning_fn, then the libpng +default function will be used, calling fprintf() and/or longjmp() if a +problem is encountered. The replacement error functions should have +parameters as follows: + + void user_error_fn(png_structp png_ptr, + png_const_charp error_msg); + void user_warning_fn(png_structp png_ptr, + png_const_charp warning_msg); + +The motivation behind using setjmp() and longjmp() is the C++ throw and +catch exception handling methods. This makes the code much easier to write, +as there is no need to check every return code of every function call. +However, there are some uncertainties about the status of local variables +after a longjmp, so the user may want to be careful about doing anything after +setjmp returns non-zero besides returning itself. Consult your compiler +documentation for more details. For an alternative approach, you may wish +to use the "cexcept" facility (see http://cexcept.sourceforge.net). + +Custom chunks + +If you need to read or write custom chunks, you may need to get deeper +into the libpng code. The library now has mechanisms for storing +and writing chunks of unknown type; you can even declare callbacks +for custom chunks. However, this may not be good enough if the +library code itself needs to know about interactions between your +chunk and existing `intrinsic' chunks. + +If you need to write a new intrinsic chunk, first read the PNG +specification. Acquire a first level of +understanding of how it works. Pay particular attention to the +sections that describe chunk names, and look at how other chunks were +designed, so you can do things similarly. Second, check out the +sections of libpng that read and write chunks. Try to find a chunk +that is similar to yours and use it as a template. More details can +be found in the comments inside the code. It is best to handle unknown +chunks in a generic method, via callback functions, instead of by +modifying libpng functions. + +If you wish to write your own transformation for the data, look through +the part of the code that does the transformations, and check out some of +the simpler ones to get an idea of how they work. Try to find a similar +transformation to the one you want to add and copy off of it. More details +can be found in the comments inside the code itself. + +Configuring for 16 bit platforms + +You will want to look into zconf.h to tell zlib (and thus libpng) that +it cannot allocate more then 64K at a time. Even if you can, the memory +won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. + +Configuring for DOS + +For DOS users who only have access to the lower 640K, you will +have to limit zlib's memory usage via a png_set_compression_mem_level() +call. See zlib.h or zconf.h in the zlib library for more information. + +Configuring for Medium Model + +Libpng's support for medium model has been tested on most of the popular +compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets +defined, and FAR gets defined to far in pngconf.h, and you should be +all set. Everything in the library (except for zlib's structure) is +expecting far data. You must use the typedefs with the p or pp on +the end for pointers (or at least look at them and be careful). Make +note that the rows of data are defined as png_bytepp, which is an +unsigned char far * far *. + +Configuring for gui/windowing platforms: + +You will need to write new error and warning functions that use the GUI +interface, as described previously, and set them to be the error and +warning functions at the time that png_create_*_struct() is called, +in order to have them available during the structure initialization. +They can be changed later via png_set_error_fn(). On some compilers, +you may also have to change the memory allocators (png_malloc, etc.). + +Configuring for compiler xxx: + +All includes for libpng are in pngconf.h. If you need to add/change/delete +an include, this is the place to do it. The includes that are not +needed outside libpng are protected by the PNG_INTERNAL definition, +which is only defined for those routines inside libpng itself. The +files in libpng proper only include png.h, which includes pngconf.h. + +Configuring zlib: + +There are special functions to configure the compression. Perhaps the +most useful one changes the compression level, which currently uses +input compression values in the range 0 - 9. The library normally +uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests +have shown that for a large majority of images, compression values in +the range 3-6 compress nearly as well as higher levels, and do so much +faster. For online applications it may be desirable to have maximum speed +(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also +specify no compression (Z_NO_COMPRESSION = 0), but this would create +files larger than just storing the raw bitmap. You can specify the +compression level by calling: + + png_set_compression_level(png_ptr, level); + +Another useful one is to reduce the memory level used by the library. +The memory level defaults to 8, but it can be lowered if you are +short on memory (running DOS, for example, where you only have 640K). +Note that the memory level does have an effect on compression; among +other things, lower levels will result in sections of incompressible +data being emitted in smaller stored blocks, with a correspondingly +larger relative overhead of up to 15% in the worst case. + + png_set_compression_mem_level(png_ptr, level); + +The other functions are for configuring zlib. They are not recommended +for normal use and may result in writing an invalid PNG file. See +zlib.h for more information on what these mean. + + png_set_compression_strategy(png_ptr, + strategy); + png_set_compression_window_bits(png_ptr, + window_bits); + png_set_compression_method(png_ptr, method); + png_set_compression_buffer_size(png_ptr, size); + +Controlling row filtering + +If you want to control whether libpng uses filtering or not, which +filters are used, and how it goes about picking row filters, you +can call one of these functions. The selection and configuration +of row filters can have a significant impact on the size and +encoding speed and a somewhat lesser impact on the decoding speed +of an image. Filtering is enabled by default for RGB and grayscale +images (with and without alpha), but not for paletted images nor +for any images with bit depths less than 8 bits/pixel. + +The 'method' parameter sets the main filtering method, which is +currently only '0' in the PNG 1.2 specification. The 'filters' +parameter sets which filter(s), if any, should be used for each +scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS +to turn filtering on and off, respectively. + +Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, +PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise +ORed together with '|' to specify one or more filters to use. +These filters are described in more detail in the PNG specification. +If you intend to change the filter type during the course of writing +the image, you should start with flags set for all of the filters +you intend to use so that libpng can initialize its internal +structures appropriately for all of the filter types. (Note that this +means the first row must always be adaptively filtered, because libpng +currently does not allocate the filter buffers until png_write_row() +is called for the first time.) + + filters = PNG_FILTER_NONE | PNG_FILTER_SUB + PNG_FILTER_UP | PNG_FILTER_AVE | + PNG_FILTER_PAETH | PNG_ALL_FILTERS; + + png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, + filters); + The second parameter can also be + PNG_INTRAPIXEL_DIFFERENCING if you are + writing a PNG to be embedded in a MNG + datastream. This parameter must be the + same as the value of filter_method used + in png_set_IHDR(). + +It is also possible to influence how libpng chooses from among the +available filters. This is done in one or both of two ways - by +telling it how important it is to keep the same filter for successive +rows, and by telling it the relative computational costs of the filters. + + double weights[3] = {1.5, 1.3, 1.1}, + costs[PNG_FILTER_VALUE_LAST] = + {1.0, 1.3, 1.3, 1.5, 1.7}; + + png_set_filter_heuristics(png_ptr, + PNG_FILTER_HEURISTIC_WEIGHTED, 3, + weights, costs); + +The weights are multiplying factors that indicate to libpng that the +row filter should be the same for successive rows unless another row filter +is that many times better than the previous filter. In the above example, +if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a +"sum of absolute differences" 1.5 x 1.3 times higher than other filters +and still be chosen, while the NONE filter could have a sum 1.1 times +higher than other filters and still be chosen. Unspecified weights are +taken to be 1.0, and the specified weights should probably be declining +like those above in order to emphasize recent filters over older filters. + +The filter costs specify for each filter type a relative decoding cost +to be considered when selecting row filters. This means that filters +with higher costs are less likely to be chosen over filters with lower +costs, unless their "sum of absolute differences" is that much smaller. +The costs do not necessarily reflect the exact computational speeds of +the various filters, since this would unduly influence the final image +size. + +Note that the numbers above were invented purely for this example and +are given only to help explain the function usage. Little testing has +been done to find optimum values for either the costs or the weights. + +Removing unwanted object code + +There are a bunch of #define's in pngconf.h that control what parts of +libpng are compiled. All the defines end in _SUPPORTED. If you are +never going to use a capability, you can change the #define to #undef +before recompiling libpng and save yourself code and data space, or +you can turn off individual capabilities with defines that begin with +PNG_NO_. + +You can also turn all of the transforms and ancillary chunk capabilities +off en masse with compiler directives that define +PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, +or all four, +along with directives to turn on any of the capabilities that you do +want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable +the extra transformations but still leave the library fully capable of reading +and writing PNG files with all known public chunks +Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive +produces a library that is incapable of reading or writing ancillary chunks. +If you are not using the progressive reading capability, you can +turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse +this with the INTERLACING capability, which you'll still have). + +All the reading and writing specific code are in separate files, so the +linker should only grab the files it needs. However, if you want to +make sure, or if you are building a stand alone library, all the +reading files start with pngr and all the writing files start with +pngw. The files that don't match either (like png.c, pngtrans.c, etc.) +are used for both reading and writing, and always need to be included. +The progressive reader is in pngpread.c + +If you are creating or distributing a dynamically linked library (a .so +or DLL file), you should not remove or disable any parts of the library, +as this will cause applications linked with different versions of the +library to fail if they call functions not available in your library. +The size of the library itself should not be an issue, because only +those sections that are actually used will be loaded into memory. + +Requesting debug printout + +The macro definition PNG_DEBUG can be used to request debugging +printout. Set it to an integer value in the range 0 to 3. Higher +numbers result in increasing amounts of debugging information. The +information is printed to the "stderr" file, unless another file +name is specified in the PNG_DEBUG_FILE macro definition. + +When PNG_DEBUG > 0, the following functions (macros) become available: + + png_debug(level, message) + png_debug1(level, message, p1) + png_debug2(level, message, p1, p2) + +in which "level" is compared to PNG_DEBUG to decide whether to print +the message, "message" is the formatted string to be printed, +and p1 and p2 are parameters that are to be embedded in the string +according to printf-style formatting directives. For example, + + png_debug1(2, "foo=%d\n", foo); + +is expanded to + + if(PNG_DEBUG > 2) + fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); + +When PNG_DEBUG is defined but is zero, the macros aren't defined, but you +can still use PNG_DEBUG to control your own debugging: + + #ifdef PNG_DEBUG + fprintf(stderr, ... + #endif + +When PNG_DEBUG = 1, the macros are defined, but only png_debug statements +having level = 0 will be printed. There aren't any such statements in +this version of libpng, but if you insert some they will be printed. + +VI. Runtime optimization + +A new feature in libpng 1.2.0 is the ability to dynamically switch between +standard and optimized versions of some routines. Currently these are +limited to three computationally intensive tasks when reading PNG files: +decoding row filters, expanding interlacing, and combining interlaced or +transparent row data with previous row data. Currently the optimized +versions are available only for x86 (Intel, AMD, etc.) platforms with +MMX support, though this may change in future versions. (For example, +the non-MMX assembler optimizations for zlib might become similarly +runtime-selectable in future releases, in which case libpng could be +extended to support them. Alternatively, the compile-time choice of +floating-point versus integer routines for gamma correction might become +runtime-selectable.) + +Because such optimizations tend to be very platform- and compiler-dependent, +both in how they are written and in how they perform, the new runtime code +in libpng has been written to allow programs to query, enable, and disable +either specific optimizations or all such optimizations. For example, to +enable all possible optimizations (bearing in mind that some "optimizations" +may actually run more slowly in rare cases): + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + png_uint_32 mask, flags; + + flags = png_get_asm_flags(png_ptr); + mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); + png_set_asm_flags(png_ptr, flags | mask); + #endif + +To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ +by itself when calling png_get_asm_flagmask(); similarly for optimizing +only writing. To disable all optimizations: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + flags = png_get_asm_flags(png_ptr); + mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); + png_set_asm_flags(png_ptr, flags & ~mask); + #endif + +To enable or disable only MMX-related features, use png_get_mmx_flagmask() +in place of png_get_asm_flagmask(). The mmx version takes one additional +parameter: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + int selection = PNG_SELECT_READ | PNG_SELECT_WRITE; + int compilerID; + + mask = png_get_mmx_flagmask(selection, &compilerID); + #endif + +On return, compilerID will indicate which version of the MMX assembler +optimizations was compiled. Currently two flavors exist: Microsoft +Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2). +On non-x86 platforms or on systems compiled without MMX optimizations, a +value of -1 is used. + +Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return +all valid, settable optimization bits for the version of the library that's +currently in use. In the case of shared (dynamically linked) libraries, +this may include optimizations that did not exist at the time the code was +written and compiled. It is also possible, of course, to enable only known, +specific optimizations; for example: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + flags = PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ + | PNG_ASM_FLAG_MMX_READ_INTERLACE \ + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ + | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; + png_set_asm_flags(png_ptr, flags); + #endif + +This method would enable only the MMX read-optimizations available at the +time of libpng 1.2.0's release, regardless of whether a later version of +the DLL were actually being used. (Also note that these functions did not +exist in versions older than 1.2.0, so any attempt to run a dynamically +linked app on such an older version would fail.) + +To determine whether the processor supports MMX instructions at all, use +the png_mmx_support() function: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + mmxsupport = png_mmx_support(); + #endif + +It returns -1 if MMX support is not compiled into libpng, 0 if MMX code +is compiled but MMX is not supported by the processor, or 1 if MMX support +is fully available. Note that png_mmx_support(), png_get_mmx_flagmask(), +and png_get_asm_flagmask() all may be called without allocating and ini- +tializing any PNG structures (for example, as part of a usage screen or +"about" box). + +The following code can be used to prevent an application from using the +thread_unsafe features, even if libpng was built with PNG_THREAD_UNSAFE_OK +defined: + +#if defined(PNG_USE_PNGGCCRD) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) \ + && defined(PNG_THREAD_UNSAFE_OK) + /* Disable thread-unsafe features of pnggccrd */ + if (png_access_version_number() >= 10200) + { + png_uint_32 mmx_disable_mask = 0; + png_uint_32 asm_flags; + + mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); + asm_flags = png_get_asm_flags(png_ptr); + png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask); + } +#endif + +For more extensive examples of runtime querying, enabling and disabling +of optimized features, see contrib/gregbook/readpng2.c in the libpng +source-code distribution. + +VII. MNG support + +The MNG specification (available at http://www.libpng.org/pub/mng) allows +certain extensions to PNG for PNG images that are embedded in MNG datastreams. +Libpng can support some of these extensions. To enable them, use the +png_permit_mng_features() function: + + feature_set = png_permit_mng_features(png_ptr, mask) + mask is a png_uint_32 containing the bitwise OR of the + features you want to enable. These include + PNG_FLAG_MNG_EMPTY_PLTE + PNG_FLAG_MNG_FILTER_64 + PNG_ALL_MNG_FEATURES + feature_set is a png_uint_32 that is the bitwise AND of + your mask with the set of MNG features that is + supported by the version of libpng that you are using. + +It is an error to use this function when reading or writing a standalone +PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped +in a MNG datastream. As a minimum, it must have the MNG 8-byte signature +and the MHDR and MEND chunks. Libpng does not provide support for these +or any other MNG chunks; your application must provide its own support for +them. You may wish to consider using libmng (available at +http://www.libmng.com) instead. + +VIII. Changes to Libpng from version 0.88 + +It should be noted that versions of libpng later than 0.96 are not +distributed by the original libpng author, Guy Schalnat, nor by +Andreas Dilger, who had taken over from Guy during 1996 and 1997, and +distributed versions 0.89 through 0.96, but rather by another member +of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are +still alive and well, but they have moved on to other things. + +The old libpng functions png_read_init(), png_write_init(), +png_info_init(), png_read_destroy(), and png_write_destroy() have been +moved to PNG_INTERNAL in version 0.95 to discourage their use. These +functions will be removed from libpng version 2.0.0. + +The preferred method of creating and initializing the libpng structures is +via the png_create_read_struct(), png_create_write_struct(), and +png_create_info_struct() because they isolate the size of the structures +from the application, allow version error checking, and also allow the +use of custom error handling routines during the initialization, which +the old functions do not. The functions png_read_destroy() and +png_write_destroy() do not actually free the memory that libpng +allocated for these structs, but just reset the data structures, so they +can be used instead of png_destroy_read_struct() and +png_destroy_write_struct() if you feel there is too much system overhead +allocating and freeing the png_struct for each image read. + +Setting the error callbacks via png_set_message_fn() before +png_read_init() as was suggested in libpng-0.88 is no longer supported +because this caused applications that do not use custom error functions +to fail if the png_ptr was not initialized to zero. It is still possible +to set the error callbacks AFTER png_read_init(), or to change them with +png_set_error_fn(), which is essentially the same function, but with a new +name to force compilation errors with applications that try to use the old +method. + +Starting with version 1.0.7, you can find out which version of the library +you are using at run-time: + + png_uint_32 libpng_vn = png_access_version_number(); + +The number libpng_vn is constructed from the major version, minor +version with leading zero, and release number with leading zero, +(e.g., libpng_vn for version 1.0.7 is 10007). + +You can also check which version of png.h you used when compiling your +application: + + png_uint_32 application_vn = PNG_LIBPNG_VER; + +IX. Y2K Compliance in libpng + +January 31, 2007 + +Since the PNG Development group is an ad-hoc body, we can't make +an official declaration. + +This is your unofficial assurance that libpng from version 0.71 and +upward through 1.2.16 are Y2K compliant. It is my belief that earlier +versions were also Y2K compliant. + +Libpng only has three year fields. One is a 2-byte unsigned integer that +will hold years up to 65535. The other two hold the date in text +format, and will hold years up to 9999. + +The integer is + "png_uint_16 year" in png_time_struct. + +The strings are + "png_charp time_buffer" in png_struct and + "near_time_buffer", which is a local character string in png.c. + +There are seven time-related functions: + + png_convert_to_rfc_1123() in png.c + (formerly png_convert_to_rfc_1152() in error) + png_convert_from_struct_tm() in pngwrite.c, called + in pngwrite.c + png_convert_from_time_t() in pngwrite.c + png_get_tIME() in pngget.c + png_handle_tIME() in pngrutil.c, called in pngread.c + png_set_tIME() in pngset.c + png_write_tIME() in pngwutil.c, called in pngwrite.c + +All appear to handle dates properly in a Y2K environment. The +png_convert_from_time_t() function calls gmtime() to convert from system +clock time, which returns (year - 1900), which we properly convert to +the full 4-digit year. There is a possibility that applications using +libpng are not passing 4-digit years into the png_convert_to_rfc_1123() +function, or that they are incorrectly passing only a 2-digit year +instead of "year - 1900" into the png_convert_from_struct_tm() function, +but this is not under our control. The libpng documentation has always +stated that it works with 4-digit years, and the APIs have been +documented as such. + +The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned +integer to hold the year, and can hold years as large as 65535. + +zlib, upon which libpng depends, is also Y2K compliant. It contains +no date-related code. + + + Glenn Randers-Pehrson + libpng maintainer + PNG Development Group diff --git a/src/dep/src/irrlicht/libpng/libpng.3 b/src/dep/src/irrlicht/libpng/libpng.3 index ed8242b..07ba888 100644 --- a/src/dep/src/irrlicht/libpng/libpng.3 +++ b/src/dep/src/irrlicht/libpng/libpng.3 @@ -1,3696 +1,3696 @@ -.TH LIBPNG 3 "January 31, 2007" -.SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.2.16 -.SH SYNOPSIS -\fB -#include \fP - -\fBpng_uint_32 png_access_version_number \fI(void\fP\fB);\fP - -\fBint png_check_sig (png_bytep \fP\fIsig\fP\fB, int \fInum\fP\fB);\fP - -\fBvoid png_chunk_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP - -\fBvoid png_chunk_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP - -\fBvoid png_convert_from_struct_tm (png_timep \fP\fIptime\fP\fB, struct tm FAR * \fIttime\fP\fB);\fP - -\fBvoid png_convert_from_time_t (png_timep \fP\fIptime\fP\fB, time_t \fIttime\fP\fB);\fP - -\fBpng_charp png_convert_to_rfc1123 (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fIptime\fP\fB);\fP - -\fBpng_infop png_create_info_struct (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_structp png_create_read_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP - -\fBpng_structp png_create_read_struct_2(png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP - -\fBpng_structp png_create_write_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP - -\fBpng_structp png_create_write_struct_2(png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP - -\fBint png_debug(int \fP\fIlevel\fP\fB, png_const_charp \fImessage\fP\fB);\fP - -\fBint png_debug1(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fIp1\fP\fB);\fP - -\fBint png_debug2(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fP\fIp1\fP\fB, \fIp2\fP\fB);\fP - -\fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP - -\fBvoid png_destroy_read_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fP\fIinfo_ptr_ptr\fP\fB, png_infopp \fIend_info_ptr_ptr\fP\fB);\fP - -\fBvoid png_destroy_write_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP - -\fBvoid png_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP - -\fBvoid png_free (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP - -\fBvoid png_free_chunk_list (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_free_default(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP - -\fBvoid png_free_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fInum\fP\fB);\fP - -\fBpng_byte png_get_bit_depth (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fI*background\fP\fB);\fP - -\fBpng_byte png_get_channels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fI*white_x\fP\fB, double \fP\fI*white_y\fP\fB, double \fP\fI*red_x\fP\fB, double \fP\fI*red_y\fP\fB, double \fP\fI*green_x\fP\fB, double \fP\fI*green_y\fP\fB, double \fP\fI*blue_x\fP\fB, double \fI*blue_y\fP\fB);\fP - -\fBpng_uint_32 png_get_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*white_x\fP\fB, png_uint_32 \fP\fI*white_y\fP\fB, png_uint_32 \fP\fI*red_x\fP\fB, png_uint_32 \fP\fI*red_y\fP\fB, png_uint_32 \fP\fI*green_x\fP\fB, png_uint_32 \fP\fI*green_y\fP\fB, png_uint_32 \fP\fI*blue_x\fP\fB, png_uint_32 \fI*blue_y\fP\fB);\fP - -\fBpng_byte png_get_color_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_byte png_get_compression_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_byte png_get_copyright (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_voidp png_get_error_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_byte png_get_filter_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fI*file_gamma\fP\fB);\fP - -\fBpng_uint_32 png_get_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fI*int_file_gamma\fP\fB);\fP - -\fBpng_byte png_get_header_ver (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_byte png_get_header_version (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fI*hist\fP\fB);\fP - -\fBpng_uint_32 png_get_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charpp \fP\fIname\fP\fB, int \fP\fI*compression_type\fP\fB, png_charpp \fP\fIprofile\fP\fB, png_uint_32 \fI*proflen\fP\fB);\fP - -\fBpng_uint_32 png_get_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*width\fP\fB, png_uint_32 \fP\fI*height\fP\fB, int \fP\fI*bit_depth\fP\fB, int \fP\fI*color_type\fP\fB, int \fP\fI*interlace_type\fP\fB, int \fP\fI*compression_type\fP\fB, int \fI*filter_type\fP\fB);\fP - -\fBpng_uint_32 png_get_image_height (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_image_width (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fB#if !defined(PNG_1_0_X) png_int_32 png_get_int_32 (png_bytep buf); \fI#endif - -\fBpng_byte png_get_interlace_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_voidp png_get_io_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_byte png_get_libpng_ver (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_voidp png_get_mem_ptr(png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*offset_x\fP\fB, png_uint_32 \fP\fI*offset_y\fP\fB, int \fI*unit_type\fP\fB);\fP - -\fBpng_uint_32 png_get_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fI*purpose\fP\fB, png_int_32 \fP\fI*X0\fP\fB, png_int_32 \fP\fI*X1\fP\fB, int \fP\fI*type\fP\fB, int \fP\fI*nparams\fP\fB, png_charp \fP\fI*units\fP\fB, png_charpp \fI*params\fP\fB);\fP - -\fBpng_uint_32 png_get_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*res_x\fP\fB, png_uint_32 \fP\fI*res_y\fP\fB, int \fI*unit_type\fP\fB);\fP - -\fBfloat png_get_pixel_aspect_ratio (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_voidp png_get_progressive_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fI*palette\fP\fB, int \fI*num_palette\fP\fB);\fP - -\fBpng_byte png_get_rgb_to_gray_status (png_structp png_ptr) png_uint_32 png_get_rowbytes (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_bytepp png_get_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fI*sig_bit\fP\fB);\fP - -\fBpng_bytep png_get_signature (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fI*splt_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fI*intent\fP\fB);\fP - -\fBpng_uint_32 png_get_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fI*text_ptr\fP\fB, int \fI*num_text\fP\fB);\fP - -\fBpng_uint_32 png_get_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fI*mod_time\fP\fB);\fP - -\fBpng_uint_32 png_get_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fI*trans\fP\fB, int \fP\fI*num_trans\fP\fB, png_color_16p \fI*trans_values\fP\fB);\fP - -\fB#if !defined(PNG_1_0_X) png_uint_16 png_get_uint_16 (png_bytep \fIbuf\fP\fB);\fP - -\fBpng_uint_32 png_get_uint_31 (png_bytep \fIbuf\fP\fB);\fP - -\fBpng_uint_32 png_get_uint_32 (png_bytep buf); \fI#endif - -\fBpng_uint_32 png_get_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkpp \fIunknowns\fP\fB);\fP - -\fBpng_voidp png_get_user_chunk_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_user_height_max( png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_voidp png_get_user_transform_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_user_width_max (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_valid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIflag\fP\fB);\fP - -\fBpng_int_32 png_get_x_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_int_32 png_get_x_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_x_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_int_32 png_get_y_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_int_32 png_get_y_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_y_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_compression_buffer_size (png_structp \fIpng_ptr\fP\fB);\fP - -\fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP - -\fBvoid png_init_io (png_structp \fP\fIpng_ptr\fP\fB, FILE \fI*fp\fP\fB);\fP - -\fBDEPRECATED: void png_info_init (png_infop \fIinfo_ptr\fP\fB);\fP - -\fBDEPRECATED: void png_info_init_2 (png_infopp \fP\fIptr_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP - -\fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fBpng_voidp png_malloc_default(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fBvoidp png_memcpy (png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_size_t \fIsize\fP\fB);\fP - -\fBpng_voidp png_memcpy_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fBvoidp png_memset (png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_size_t \fIsize\fP\fB);\fP - -\fBpng_voidp png_memset_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fBDEPRECATED: void png_permit_empty_plte (png_structp \fP\fIpng_ptr\fP\fB, int \fIempty_plte_permitted\fP\fB);\fP - -\fBvoid png_process_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_size\fP\fB);\fP - -\fBvoid png_progressive_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIold_row\fP\fB, png_bytep \fInew_row\fP\fB);\fP - -\fBvoid png_read_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_infop \fIend_info_ptr\fP\fB);\fP - -\fBvoid png_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_read_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP - -\fBDEPRECATED: void png_read_init (png_structp \fIpng_ptr\fP\fB);\fP - -\fBDEPRECATED: void png_read_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP - -\fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_read_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP - -\fBvoid png_read_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fIdisplay_row\fP\fB);\fP - -\fBvoid png_read_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_bytepp \fP\fIdisplay_row\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP - -\fBvoid png_read_update_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fB#if !defined(PNG_1_0_X) png_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP - -\fBvoid png_save_uint_16 (png_bytep \fP\fIbuf\fP\fB, unsigned int \fIi\fP\fB);\fP - -\fBvoid png_save_uint_32 (png_bytep \fP\fIbuf\fP\fB, png_uint_32 \fIi\fP\fB);\fP - -\fBvoid png_set_add_alpha (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int flags); \fI#endif - -\fBvoid png_set_background (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIbackground_color\fP\fB, int \fP\fIbackground_gamma_code\fP\fB, int \fP\fIneed_expand\fP\fB, double \fIbackground_gamma\fP\fB);\fP - -\fBvoid png_set_bgr (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fIbackground\fP\fB);\fP - -\fBvoid png_set_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP - -\fBvoid png_set_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP - -\fBvoid png_set_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP - -\fBvoid png_set_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP - -\fBvoid png_set_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP - -\fBvoid png_set_compression_strategy (png_structp \fP\fIpng_ptr\fP\fB, int \fIstrategy\fP\fB);\fP - -\fBvoid png_set_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP - -\fBvoid png_set_crc_action (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcrit_action\fP\fB, int \fIancil_action\fP\fB);\fP - -\fBvoid png_set_dither (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fP\fInum_palette\fP\fB, int \fP\fImaximum_colors\fP\fB, png_uint_16p \fP\fIhistogram\fP\fB, int \fIfull_dither\fP\fB);\fP - -\fBvoid png_set_error_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarning_fn\fP\fB);\fP - -\fBvoid png_set_expand (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_expand_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_filler (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP - -\fBvoid png_set_filter (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImethod\fP\fB, int \fIfilters\fP\fB);\fP - -\fBvoid png_set_filter_heuristics (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIheuristic_method\fP\fB, int \fP\fInum_weights\fP\fB, png_doublep \fP\fIfilter_weights\fP\fB, png_doublep \fIfilter_costs\fP\fB);\fP - -\fBvoid png_set_flush (png_structp \fP\fIpng_ptr\fP\fB, int \fInrows\fP\fB);\fP - -\fBvoid png_set_gamma (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIscreen_gamma\fP\fB, double \fIdefault_file_gamma\fP\fB);\fP - -\fBvoid png_set_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP - -\fBvoid png_set_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIfile_gamma\fP\fB);\fP - -\fBvoid png_set_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_gray_to_rgb (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fIhist\fP\fB);\fP - -\fBvoid png_set_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, png_uint_32 \fIproflen\fP\fB);\fP - -\fBint png_set_interlace_handling (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_invalid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fImask\fP\fB);\fP - -\fBvoid png_set_invert_alpha (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_invert_mono (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIinterlace_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fIfilter_type\fP\fB);\fP - -\fBvoid png_set_keep_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIkeep\fP\fB, png_bytep \fP\fIchunk_list\fP\fB, int \fInum_chunks\fP\fB);\fP - -\fBvoid png_set_mem_fn(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP - -\fBvoid png_set_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIoffset_x\fP\fB, png_uint_32 \fP\fIoffset_y\fP\fB, int \fIunit_type\fP\fB);\fP - -\fBvoid png_set_packing (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_packswap (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_palette_to_rgb(png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP - -\fBvoid png_set_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIres_x\fP\fB, png_uint_32 \fP\fIres_y\fP\fB, int \fIunit_type\fP\fB);\fP - -\fBvoid png_set_progressive_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIprogressive_ptr\fP\fB, png_progressive_info_ptr \fP\fIinfo_fn\fP\fB, png_progressive_row_ptr \fP\fIrow_fn\fP\fB, png_progressive_end_ptr \fIend_fn\fP\fB);\fP - -\fBvoid png_set_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP - -\fBvoid png_set_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIio_ptr\fP\fB, png_rw_ptr \fIread_data_fn\fP\fB);\fP - -\fBvoid png_set_read_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_read_status_ptr \fIread_row_fn\fP\fB);\fP - -\fBvoid png_set_read_user_transform_fn (png_structp \fP\fIpng_ptr\fP\fB, png_user_transform_ptr \fIread_user_transform_fn\fP\fB);\fP - -\fBvoid png_set_rgb_to_gray (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIerror_action\fP\fB, double \fP\fIred\fP\fB, double \fIgreen\fP\fB);\fP - -\fBvoid png_set_rgb_to_gray_fixed (png_structp \fP\fIpng_ptr\fP\fB, int error_action png_fixed_point \fP\fIred\fP\fB, png_fixed_point \fIgreen\fP\fB);\fP - -\fBvoid png_set_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytepp \fIrow_pointers\fP\fB);\fP - -\fBvoid png_set_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fIsig_bit\fP\fB);\fP - -\fBvoid png_set_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP - -\fBvoid png_set_shift (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fItrue_bits\fP\fB);\fP - -\fBvoid png_set_sig_bytes (png_structp \fP\fIpng_ptr\fP\fB, int \fInum_bytes\fP\fB);\fP - -\fBvoid png_set_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fP\fIsplt_ptr\fP\fB, int \fInum_spalettes\fP\fB);\fP - -\fBvoid png_set_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP - -\fBvoid png_set_sRGB_gAMA_and_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP - -\fBvoid png_set_strip_16 (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_strip_alpha (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_swap (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_swap_alpha (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text\fP\fB);\fP - -\fBvoid png_set_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP - -\fBvoid png_set_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fP\fInum_trans\fP\fB, png_color_16p \fItrans_values\fP\fB);\fP - -\fBvoid png_set_tRNS_to_alpha(png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_uint_32 png_set_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkp \fP\fIunknowns\fP\fB, int \fP\fInum\fP\fB, int \fIlocation\fP\fB);\fP - -\fBvoid png_set_unknown_chunk_location(png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIchunk\fP\fB, int \fIlocation\fP\fB);\fP - -\fBvoid png_set_read_user_chunk_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_chunk_ptr\fP\fB, png_user_chunk_ptr \fIread_user_chunk_fn\fP\fB);\fP - -\fBvoid png_set_user_limits (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIuser_width_max\fP\fB, png_uint_32 \fIuser_height_max\fP\fB);\fP - -\fBvoid png_set_user_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_transform_ptr\fP\fB, int \fP\fIuser_transform_depth\fP\fB, int \fIuser_transform_channels\fP\fB);\fP - -\fBvoid png_set_write_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIio_ptr\fP\fB, png_rw_ptr \fP\fIwrite_data_fn\fP\fB, png_flush_ptr \fIoutput_flush_fn\fP\fB);\fP - -\fBvoid png_set_write_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_write_status_ptr \fIwrite_row_fn\fP\fB);\fP - -\fBvoid png_set_write_user_transform_fn (png_structp \fP\fIpng_ptr\fP\fB, png_user_transform_ptr \fIwrite_user_transform_fn\fP\fB);\fP - -\fBvoid png_set_compression_buffer_size(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fBint png_sig_cmp (png_bytep \fP\fIsig\fP\fB, png_size_t \fP\fIstart\fP\fB, png_size_t \fInum_to_check\fP\fB);\fP - -\fBvoid png_start_read_image (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP - -\fBvoid png_write_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIchunk_name\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBvoid png_write_chunk_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBvoid png_write_chunk_end (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_write_chunk_start (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIchunk_name\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_write_destroy (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_write_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_write_flush (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_write_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP - -\fBDEPRECATED: void png_write_init (png_structp \fIpng_ptr\fP\fB);\fP - -\fBDEPRECATED: void png_write_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP - -\fBvoid png_write_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_write_info_before_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_write_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP - -\fBvoid png_write_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_write_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP - -\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP - -\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP - -.SH DESCRIPTION -The -.I libpng -library supports encoding, decoding, and various manipulations of -the Portable Network Graphics (PNG) format image files. It uses the -.IR zlib(3) -compression library. -Following is a copy of the libpng.txt file that accompanies libpng. -.SH LIBPNG.TXT -libpng.txt - A description on how to use and modify libpng - - libpng version 1.2.16 - January 31, 2007 - Updated and distributed by Glenn Randers-Pehrson - - Copyright (c) 1998-2005 Glenn Randers-Pehrson - For conditions of distribution and use, see copyright - notice in png.h. - - based on: - - libpng 1.0 beta 6 version 0.96 May 28, 1997 - Updated and distributed by Andreas Dilger - Copyright (c) 1996, 1997 Andreas Dilger - - libpng 1.0 beta 2 - version 0.88 January 26, 1996 - For conditions of distribution and use, see copyright - notice in png.h. Copyright (c) 1995, 1996 Guy Eric - Schalnat, Group 42, Inc. - - Updated/rewritten per request in the libpng FAQ - Copyright (c) 1995, 1996 Frank J. T. Wojcik - December 18, 1995 & January 20, 1996 - -.SH I. Introduction - -This file describes how to use and modify the PNG reference library -(known as libpng) for your own use. There are five sections to this -file: introduction, structures, reading, writing, and modification and -configuration notes for various special platforms. In addition to this -file, example.c is a good starting point for using the library, as -it is heavily commented and should include everything most people -will need. We assume that libpng is already installed; see the -INSTALL file for instructions on how to install libpng. - -Libpng was written as a companion to the PNG specification, as a way -of reducing the amount of time and effort it takes to support the PNG -file format in application programs. - -The PNG specification (second edition), November 2003, is available as -a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at - - -The PNG-1.0 specification is available -as RFC 2083 and as a -W3C Recommendation . Some -additional chunks are described in the special-purpose public chunks -documents at . - -Other information -about PNG, and the latest version of libpng, can be found at the PNG home -page, . - -Most users will not have to modify the library significantly; advanced -users may want to modify it more. All attempts were made to make it as -complete as possible, while keeping the code easy to understand. -Currently, this library only supports C. Support for other languages -is being considered. - -Libpng has been designed to handle multiple sessions at one time, -to be easily modifiable, to be portable to the vast majority of -machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy -to use. The ultimate goal of libpng is to promote the acceptance of -the PNG file format in whatever way possible. While there is still -work to be done (see the TODO file), libpng should cover the -majority of the needs of its users. - -Libpng uses zlib for its compression and decompression of PNG files. -Further information about zlib, and the latest version of zlib, can -be found at the zlib home page, . -The zlib compression utility is a general purpose utility that is -useful for more than PNG files, and can be used without libpng. -See the documentation delivered with zlib for more details. -You can usually find the source files for the zlib utility wherever you -find the libpng source files. - -Libpng is thread safe, provided the threads are using different -instances of the structures. Each thread should have its own -png_struct and png_info instances, and thus its own image. -Libpng does not protect itself against two threads using the -same instance of a structure. Note: thread safety may be defeated -by use of some of the MMX assembler code in pnggccrd.c, which is only -compiled when the user defines PNG_THREAD_UNSAFE_OK. - -.SH II. Structures - -There are two main structures that are important to libpng, png_struct -and png_info. The first, png_struct, is an internal structure that -will not, for the most part, be used by a user except as the first -variable passed to every libpng function call. - -The png_info structure is designed to provide information about the -PNG file. At one time, the fields of png_info were intended to be -directly accessible to the user. However, this tended to cause problems -with applications using dynamically loaded libraries, and as a result -a set of interface functions for png_info (the png_get_*() and png_set_*() -functions) was developed. The fields of png_info are still available for -older applications, but it is suggested that applications use the new -interfaces if at all possible. - -Applications that do make direct access to the members of png_struct (except -for png_ptr->jmpbuf) must be recompiled whenever the library is updated, -and applications that make direct access to the members of png_info must -be recompiled if they were compiled or loaded with libpng version 1.0.6, -in which the members were in a different order. In version 1.0.7, the -members of the png_info structure reverted to the old order, as they were -in versions 0.97c through 1.0.5. Starting with version 2.0.0, both -structures are going to be hidden, and the contents of the structures will -only be accessible through the png_get/png_set functions. - -The png.h header file is an invaluable reference for programming with libpng. -And while I'm on the topic, make sure you include the libpng header file: - -#include - -.SH III. Reading - -We'll now walk you through the possible functions to call when reading -in a PNG file sequentially, briefly explaining the syntax and purpose -of each one. See example.c and png.h for more detail. While -progressive reading is covered in the next section, you will still -need some of the functions discussed in this section to read a PNG -file. - -.SS Setup - -You will want to do the I/O initialization(*) before you get into libpng, -so if it doesn't work, you don't have much to undo. Of course, you -will also want to insure that you are, in fact, dealing with a PNG -file. Libpng provides a simple check to see if a file is a PNG file. -To use it, pass in the first 1 to 8 bytes of the file to the function -png_sig_cmp(), and it will return 0 if the bytes match the corresponding -bytes of the PNG signature, or nonzero otherwise. Of course, the more bytes -you pass in, the greater the accuracy of the prediction. - -If you are intending to keep the file pointer open for use in libpng, -you must ensure you don't read more than 8 bytes from the beginning -of the file, and you also have to make a call to png_set_sig_bytes_read() -with the number of bytes you read from the beginning. Libpng will -then only check the bytes (if any) that your program didn't read. - -(*): If you are not using the standard I/O functions, you will need -to replace them with custom functions. See the discussion under -Customizing libpng. - - - FILE *fp = fopen(file_name, "rb"); - if (!fp) - { - return (ERROR); - } - fread(header, 1, number, fp); - is_png = !png_sig_cmp(header, 0, number); - if (!is_png) - { - return (NOT_PNG); - } - - -Next, png_struct and png_info need to be allocated and initialized. In -order to ensure that the size of these structures is correct even with a -dynamically linked libpng, there are functions to initialize and -allocate the structures. We also pass the library version, optional -pointers to error handling functions, and a pointer to a data struct for -use by the error functions, if necessary (the pointer and functions can -be NULL if the default error handlers are to be used). See the section -on Changes to Libpng below regarding the old initialization functions. -The structure allocation functions quietly return NULL if they fail to -create the structure, so your application should check for that. - - png_structp png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, - (png_infopp)NULL, (png_infopp)NULL); - return (ERROR); - } - - png_infop end_info = png_create_info_struct(png_ptr); - if (!end_info) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_read_struct_2() instead of png_create_read_struct(): - - png_structp png_ptr = png_create_read_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -The error handling routines passed to png_create_read_struct() -and the memory alloc/free routines passed to png_create_struct_2() -are only necessary if you are not using the libpng supplied error -handling and memory alloc/free functions. - -When libpng encounters an error, it expects to longjmp back -to your routine. Therefore, you will need to call setjmp and pass -your png_jmpbuf(png_ptr). If you read the file from different -routines, you will need to update the jmpbuf field every time you enter -a new routine that will call a png_*() function. - -See your documentation of setjmp/longjmp for your compiler for more -information on setjmp/longjmp. See the discussion on libpng error -handling in the Customizing Libpng section below for more information -on the libpng error handling. If an error occurs, and libpng longjmp's -back to your setjmp, you will want to call png_destroy_read_struct() to -free any memory. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - fclose(fp); - return (ERROR); - } - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the input code. The default for libpng is to -use the C function fread(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. If you wish to handle reading data in another -way, you need not call the png_init_io() function, but you must then -implement the libpng I/O methods discussed in the Customizing Libpng -section below. - - png_init_io(png_ptr, fp); - -If you had previously opened the file and read any of the signature from -the beginning in order to see if this was a PNG file, you need to let -libpng know that there are some bytes missing from the start of the file. - - png_set_sig_bytes(png_ptr, number); - -.SS Setting up callback code - -You can set up a callback function to handle any unknown chunks in the -input stream. You must supply the function - - read_chunk_callback(png_ptr ptr, - png_unknown_chunkp chunk); - { - /* The unknown chunk structure contains your - chunk data: */ - png_byte name[5]; - png_byte *data; - png_size_t size; - /* Note that libpng has already taken care of - the CRC handling */ - - /* put your code here. Return one of the - following: */ - - return (-n); /* chunk had an error */ - return (0); /* did not recognize */ - return (n); /* success */ - } - -(You can give your function another name that you like instead of -"read_chunk_callback") - -To inform libpng about your function, use - - png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, - read_chunk_callback); - -This names not only the callback function, but also a user pointer that -you can retrieve with - - png_get_user_chunk_ptr(png_ptr); - -At this point, you can set up a callback function that will be -called after each row has been read, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void read_row_callback(png_ptr ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "read_row_callback") - -To inform libpng about your function, use - - png_set_read_status_fn(png_ptr, read_row_callback); - -.SS Width and height limits - -The PNG specification allows the width and height of an image to be as -large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. -Since very few applications really need to process such large images, -we have imposed an arbitrary 1-million limit on rows and columns. -Larger images will be rejected immediately with a png_error() call. If -you wish to override this limit, you can use - - png_set_user_limits(png_ptr, width_max, height_max); - -to set your own limits, or use width_max = height_max = 0x7fffffffL -to allow all valid dimensions (libpng may reject some very large images -anyway because of potential buffer overflow conditions). - -You should put this statement after you create the PNG structure and -before calling png_read_info(), png_read_png(), or png_process_data(). -If you need to retrieve the limits that are being applied, use - - width_max = png_get_user_width_max(png_ptr); - height_max = png_get_user_height_max(png_ptr); - -.SS Unknown-chunk handling - -Now you get to set the way the library processes unknown chunks in the -input PNG stream. Both known and unknown chunks will be read. Normal -behavior is that known chunks will be parsed into information in -various info_ptr members; unknown chunks will be discarded. To change -this, you can call: - - png_set_keep_unknown_chunks(png_ptr, keep, - chunk_list, num_chunks); - keep - 0: do not handle as unknown - 1: do not keep - 2: keep only if safe-to-copy - 3: keep even if unsafe-to-copy - You can use these definitions: - PNG_HANDLE_CHUNK_AS_DEFAULT 0 - PNG_HANDLE_CHUNK_NEVER 1 - PNG_HANDLE_CHUNK_IF_SAFE 2 - PNG_HANDLE_CHUNK_ALWAYS 3 - chunk_list - list of chunks affected (a byte string, - five bytes per chunk, NULL or '\0' if - num_chunks is 0) - num_chunks - number of chunks affected; if 0, all - unknown chunks are affected. If nonzero, - only the chunks in the list are affected - -Unknown chunks declared in this way will be saved as raw data onto a -list of png_unknown_chunk structures. If a chunk that is normally -known to libpng is named in the list, it will be handled as unknown, -according to the "keep" directive. If a chunk is named in successive -instances of png_set_keep_unknown_chunks(), the final instance will -take precedence. The IHDR and IEND chunks should not be named in -chunk_list; if they are, libpng will process them normally anyway. - -.SS The high-level read interface - -At this point there are two ways to proceed; through the high-level -read interface, or through a sequence of low-level read operations. -You can use the high-level interface if (a) you are willing to read -the entire image into memory, and (b) the input transformations -you want to do are limited to the following set: - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to - 8 bits - PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel - PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit - samples to bytes - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_EXPAND Perform set_expand() - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - -(This excludes setting a background color, doing gamma transformation, -dithering, and setting filler.) If this is the case, simply do this: - - png_read_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the bitwise OR of -some set of transformation flags. This call is equivalent to png_read_info(), -followed the set of transformations indicated by the transform mask, -then png_read_image(), and finally png_read_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future input transform.) - -You must use png_transforms and not call any png_set_transform() functions -when you use png_read_png(). - -After you have called png_read_png(), you can retrieve the image data -with - - row_pointers = png_get_rows(png_ptr, info_ptr); - -where row_pointers is an array of pointers to the pixel data for each row: - - png_bytep row_pointers[height]; - -If you know your image size and pixel size ahead of time, you can allocate -row_pointers prior to calling png_read_png() with - - if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) - png_error (png_ptr, - "Image is too tall to process in memory"); - if (width > PNG_UINT_32_MAX/pixel_size) - png_error (png_ptr, - "Image is too wide to process in memory"); - row_pointers = png_malloc(png_ptr, - height*png_sizeof(png_bytep)); - for (int i=0; i) and -png_get_(png_ptr, info_ptr, ...) functions return non-zero if the -data has been read, or zero if it is missing. The parameters to the -png_get_ are set directly if they are simple data types, or a pointer -into the info_ptr is returned for any complex types. - - png_get_PLTE(png_ptr, info_ptr, &palette, - &num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_get_gAMA(png_ptr, info_ptr, &gamma); - gamma - the gamma the file is written - at (PNG_INFO_gAMA) - - png_get_sRGB(png_ptr, info_ptr, &srgb_intent); - srgb_intent - the rendering intent (PNG_INFO_sRGB) - The presence of the sRGB chunk - means that the pixel data is in the - sRGB color space. This chunk also - implies specific values of gAMA and - cHRM. - - png_get_iCCP(png_ptr, info_ptr, &name, - &compression_type, &profile, &proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, - red, green, and blue channels, - whichever are appropriate for the - given color type (png_color_16) - - png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, - &trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_get_hIST(png_ptr, info_ptr, &hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_get_tIME(png_ptr, info_ptr, &mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_get_bKGD(png_ptr, info_ptr, &background); - background - background color (PNG_VALID_bKGD) - valid 16-bit red, green and blue - values, regardless of color_type - - num_comments = png_get_text(png_ptr, info_ptr, - &text_ptr, &num_text); - num_comments - number of comments - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (empty - string for unknown). - text_ptr[i].lang_key - keyword in UTF-8 - (empty string for unknown). - num_text - number of comments (same as - num_comments; you can put NULL here - to avoid the duplication) - Note while png_set_text() will accept text, language, - and translated keywords that can be NULL pointers, the - structure returned by png_get_text will always contain - regular zero-terminated C strings. They might be - empty strings but they will never be NULL pointers. - - num_spalettes = png_get_sPLT(png_ptr, info_ptr, - &palette_ptr); - palette_ptr - array of palette structures holding - contents of one or more sPLT chunks - read. - num_spalettes - number of sPLT chunks read. - - png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, - &unit_type); - offset_x - positive offset from the left edge - of the screen - offset_y - positive offset from the top edge - of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, - &unit_type); - res_x - pixels/unit physical resolution in - x direction - res_y - pixels/unit physical resolution in - x direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_get_sCAL(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - num_unknown_chunks = png_get_unknown_chunks(png_ptr, - info_ptr, &unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position of chunk in file - - The value of "i" corresponds to the order in which the - chunks were read from the PNG file or inserted with the - png_set_unknown_chunks() function. - -The data from the pHYs chunk can be retrieved in several convenient -forms: - - res_x = png_get_x_pixels_per_meter(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_meter(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_meter(png_ptr, - info_ptr) - res_x = png_get_x_pixels_per_inch(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_inch(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_inch(png_ptr, - info_ptr) - aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, - info_ptr) - - (Each of these returns 0 [signifying "unknown"] if - the data is not present or if res_x is 0; - res_x_and_y is 0 if res_x != res_y) - -The data from the oFFs chunk can be retrieved in several convenient -forms: - - x_offset = png_get_x_offset_microns(png_ptr, info_ptr); - y_offset = png_get_y_offset_microns(png_ptr, info_ptr); - x_offset = png_get_x_offset_inches(png_ptr, info_ptr); - y_offset = png_get_y_offset_inches(png_ptr, info_ptr); - - (Each of these returns 0 [signifying "unknown" if both - x and y are 0] if the data is not present or if the - chunk is present but the unit is the pixel) - -For more information, see the png_info definition in png.h and the -PNG specification for chunk contents. Be careful with trusting -rowbytes, as some of the transformations could increase the space -needed to hold a row (expand, filler, gray_to_rgb, etc.). -See png_read_update_info(), below. - -A quick word about text_ptr and num_text. PNG stores comments in -keyword/text pairs, one pair per chunk, with no limit on the number -of text chunks, and a 2^31 byte limit on their size. While there are -suggested keywords, there is no requirement to restrict the use to these -strings. It is strongly suggested that keywords and text be sensible -to humans (that's the point), so don't use abbreviations. Non-printing -symbols are not allowed. See the PNG specification for more details. -There is also no requirement to have text after the keyword. - -Keywords should be limited to 79 Latin-1 characters without leading or -trailing spaces, but non-consecutive spaces are allowed within the -keyword. It is possible to have the same keyword any number of times. -The text_ptr is an array of png_text structures, each holding a -pointer to a language string, a pointer to a keyword and a pointer to -a text string. The text string, language code, and translated -keyword may be empty or NULL pointers. The keyword/text -pairs are put into the array in the order that they are received. -However, some or all of the text chunks may be after the image, so, to -make sure you have read all the text chunks, don't mess with these -until after you read the stuff after the image. This will be -mentioned again below in the discussion that goes with png_read_end(). - -.SS Input transformations - -After you've read the header information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -The colors used for the background and transparency values should be -supplied in the same format/depth as the current image data. They -are stored in the same format/depth as the image data in a bKGD or tRNS -chunk, so this is what libpng expects for this data. The colors are -transformed to keep in sync with the image data when an application -calls the png_read_update_info() routine (see below). - -Data will be decoded into the supplied row buffers packed into bytes -unless the library has been told to transform it into another format. -For example, 4 bit/pixel paletted or grayscale data will be returned -2 pixels/byte with the leftmost pixel in the high-order bits of the -byte, unless png_set_packing() is called. 8-bit RGB data will be stored -in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha() -is called to insert filler bytes, either before or after each RGB triplet. -16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant -byte of the color value first, unless png_set_strip_16() is called to -transform it to regular RGB RGB triplets, or png_set_filler() or -png_set_add alpha() is called to insert filler bytes, either before or -after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can -be modified with -png_set_filler(), png_set_add_alpha(), or png_set_strip_16(). - -The following code transforms grayscale images of less than 8 to 8 bits, -changes paletted images to RGB, and adds a full alpha channel if there is -transparency information in a tRNS chunk. This is most useful on -grayscale images with bit depths of 2 or 4 or if there is a multiple-image -viewing application that wishes to treat all images in the same way. - - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - if (color_type == PNG_COLOR_TYPE_GRAY && - bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr); - - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); - -These three functions are actually aliases for png_set_expand(), added -in libpng version 1.0.4, with the function names expanded to improve code -readability. In some future version they may actually do different -things. - -As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was -added. It expands the sample depth without changing tRNS to alpha. -At the same time, png_set_gray_1_2_4_to_8() was deprecated, and it -will be removed from a future version. - -PNG can have files with 16 bits per channel. If you only can handle -8 bits per channel, this will strip the pixels down to 8 bit. - - if (bit_depth == 16) - png_set_strip_16(png_ptr); - -If, for some reason, you don't need the alpha channel on an image, -and you want to remove it rather than combining it with the background -(but the image author certainly had in mind that you *would* combine -it with the background, so that's what you should probably do): - - if (color_type & PNG_COLOR_MASK_ALPHA) - png_set_strip_alpha(png_ptr); - -In PNG files, the alpha channel in an image -is the level of opacity. If you need the alpha channel in an image to -be the level of transparency instead of opacity, you can invert the -alpha channel (or the tRNS chunk data) after it's read, so that 0 is -fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit -images) is fully transparent, with - - png_set_invert_alpha(png_ptr); - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit -files. This code expands to 1 pixel per byte without changing the -values of the pixels: - - if (bit_depth < 8) - png_set_packing(png_ptr); - -PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels -stored in a PNG image have been "scaled" or "shifted" up to the next -higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to -8 bits/sample in the range [0, 255]). However, it is also possible to -convert the PNG pixel data back to the original bit depth of the image. -This call reduces the pixels back down to the original bit depth: - - png_color_8p sig_bit; - - if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) - png_set_shift(png_ptr, sig_bit); - -PNG files store 3-color pixels in red, green, blue order. This code -changes the storage of the pixels to blue, green, red: - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_bgr(png_ptr); - -PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them -into 4 or 8 bytes for windowing systems that need them in this format: - - if (color_type == PNG_COLOR_TYPE_RGB) - png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE); - -where "filler" is the 8 or 16-bit number to fill with, and the location is -either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether -you want the filler before the RGB or after. This transformation -does not affect images that already have full alpha channels. To add an -opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which -will generate RGBA pixels. - -Note that png_set_filler() does not change the color type. If you want -to do that, you can add a true alpha channel with - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY) - png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER); - -where "filler" contains the alpha value to assign to each pixel. -This function was added in libpng-1.2.7. - -If you are reading an image with an alpha channel, and you need the -data as ARGB instead of the normal PNG format RGBA: - - if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_swap_alpha(png_ptr); - -For some uses, you may want a grayscale image to be represented as -RGB. This code will do that conversion: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - -Conversely, you can convert an RGB or RGBA image to grayscale or grayscale -with alpha. - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_rgb_to_gray_fixed(png_ptr, error_action, - int red_weight, int green_weight); - - error_action = 1: silently do the conversion - error_action = 2: issue a warning if the original - image has any pixel where - red != green or red != blue - error_action = 3: issue an error and abort the - conversion if the original - image has any pixel where - red != green or red != blue - - red_weight: weight of red component times 100000 - green_weight: weight of green component times 100000 - If either weight is negative, default - weights (21268, 71514) are used. - -If you have set error_action = 1 or 2, you can -later check whether the image really was gray, after processing -the image rows, with the png_get_rgb_to_gray_status(png_ptr) function. -It will return a png_byte that is zero if the image was gray or -1 if there were any non-gray pixels. bKGD and sBIT data -will be silently converted to grayscale, using the green channel -data, regardless of the error_action setting. - -With red_weight+green_weight<=100000, -the normalized graylevel is computed: - - int rw = red_weight * 65536; - int gw = green_weight * 65536; - int bw = 65536 - (rw + gw); - gray = (rw*red + gw*green + bw*blue)/65536; - -The default values approximate those recommended in the Charles -Poynton's Color FAQ, -Copyright (c) 1998-01-04 Charles Poynton - - Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - -Libpng approximates this with - - Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - -which can be expressed with integers as - - Y = (6969 * R + 23434 * G + 2365 * B)/32768 - -The calculation is done in a linear colorspace, if the image gamma -is known. - -If you have a grayscale and you are using png_set_expand_depth(), -png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to -a higher bit-depth, you must either supply the background color as a gray -value at the original file bit-depth (need_expand = 1) or else supply the -background color as an RGB triplet at the final, expanded bit depth -(need_expand = 0). Similarly, if you are reading a paletted image, you -must either supply the background color as a palette index (need_expand = 1) -or as an RGB triplet that may or may not be in the palette (need_expand = 0). - - png_color_16 my_background; - png_color_16p image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - -The png_set_background() function tells libpng to composite images -with alpha or simple transparency against the supplied background -color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid), -you may use this color, or supply another color more suitable for -the current display (e.g., the background color from a web page). You -need to tell libpng whether the color is in the gamma space of the -display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file -(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one -that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't -know why anyone would use this, but it's here). - -To properly display PNG images on any kind of system, the application needs -to know what the display gamma is. Ideally, the user will know this, and -the application will allow them to set it. One method of allowing the user -to set the display gamma separately for each system is to check for a -SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be -correctly set. - -Note that display_gamma is the overall gamma correction required to produce -pleasing results, which depends on the lighting conditions in the surrounding -environment. In a dim or brightly lit room, no compensation other than -the physical gamma exponent of the monitor is needed, while in a dark room -a slightly smaller exponent is better. - - double gamma, screen_gamma; - - if (/* We have a user-defined screen - gamma value */) - { - screen_gamma = user_defined_screen_gamma; - } - /* One way that applications can share the same - screen gamma value */ - else if ((gamma_str = getenv("SCREEN_GAMMA")) - != NULL) - { - screen_gamma = (double)atof(gamma_str); - } - /* If we don't have another value */ - else - { - screen_gamma = 2.2; /* A good guess for a - PC monitor in a bright office or a dim room */ - screen_gamma = 2.0; /* A good guess for a - PC monitor in a dark room */ - screen_gamma = 1.7 or 1.0; /* A good - guess for Mac systems */ - } - -The png_set_gamma() function handles gamma transformations of the data. -Pass both the file gamma and the current screen_gamma. If the file does -not have a gamma value, you can pass one anyway if you have an idea what -it is (usually 0.45455 is a good guess for GIF images on PCs). Note -that file gammas are inverted from screen gammas. See the discussions -on gamma in the PNG specification for an excellent description of what -gamma is, and why all applications should support it. It is strongly -recommended that PNG viewers support gamma correction. - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, screen_gamma, gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - -If you need to reduce an RGB file to a paletted file, or if a paletted -file has more entries then will fit on your screen, png_set_dither() -will do that. Note that this is a simple match dither that merely -finds the closest color available. This should work fairly well with -optimized palettes, and fairly badly with linear color cubes. If you -pass a palette that is larger then maximum_colors, the file will -reduce the number of colors in the palette so it will fit into -maximum_colors. If there is a histogram, it will use it to make -more intelligent choices when reducing the palette. If there is no -histogram, it may not do as good a job. - - if (color_type & PNG_COLOR_MASK_COLOR) - { - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_PLTE)) - { - png_uint_16p histogram = NULL; - - png_get_hIST(png_ptr, info_ptr, - &histogram); - png_set_dither(png_ptr, palette, num_palette, - max_screen_colors, histogram, 1); - } - else - { - png_color std_color_cube[MAX_SCREEN_COLORS] = - { ... colors ... }; - - png_set_dither(png_ptr, std_color_cube, - MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, - NULL,0); - } - } - -PNG files describe monochrome as black being zero and white being one. -The following code will reverse this (make black be one and white be -zero): - - if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY) - png_set_invert_mono(png_ptr); - -This function can also be used to invert grayscale and gray-alpha images: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_invert_mono(png_ptr); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code changes the storage to the -other way (little-endian, i.e. least significant bits first, the -way PCs store them): - - if (bit_depth == 16) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_read_user_transform_fn(png_ptr, - read_transform_fn); - -You must supply the function - - void read_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -after all of the other transformations have been processed. - -You can also set up a pointer to a user structure for use by your -callback function, and you can inform libpng that your transform -function will change the number of channels or bit depth with the -function - - png_set_user_transform_info(png_ptr, user_ptr, - user_depth, user_channels); - -The user's application, not libpng, is responsible for allocating and -freeing any memory required for the user structure. - -You can retrieve the pointer via the function -png_get_user_transform_ptr(). For example: - - voidp read_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -The last thing to handle is interlacing; this is covered in detail below, -but you must call the function here if you want libpng to handle expansion -of the interlaced image. - - number_of_passes = png_set_interlace_handling(png_ptr); - -After setting the transformations, libpng can update your png_info -structure to reflect any transformations you've requested with this -call. This is most useful to update the info structure's rowbytes -field so you can use it to allocate your image memory. This function -will also update your palette with the correct screen_gamma and -background if these have been given with the calls above. - - png_read_update_info(png_ptr, info_ptr); - -After you call png_read_update_info(), you can allocate any -memory you need to hold the image. The row data is simply -raw byte data for all forms of images. As the actual allocation -varies among applications, no example will be given. If you -are allocating one large chunk, you will need to build an -array of pointers to each row, as it will be needed for some -of the functions below. - -.SS Reading image data - -After you've allocated memory, you can read the image data. -The simplest way to do this is in one function call. If you are -allocating enough memory to hold the whole image, you can just -call png_read_image() and libpng will read in all the image data -and put it in the memory area supplied. You will need to pass in -an array of pointers to each row. - -This function automatically handles interlacing, so you don't need -to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_read_rows(). - - png_read_image(png_ptr, row_pointers); - -where row_pointers is: - - png_bytep row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to read in the whole image at once, you can -use png_read_rows() instead. If there is no interlacing (check -interlace_type == PNG_INTERLACE_NONE), this is simple: - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -where row_pointers is the same as in the png_read_image() call. - -If you are doing this just one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - png_read_row(png_ptr, row_pointer, NULL); - -If the file is interlaced (interlace_type != 0 in the IHDR chunk), things -get somewhat harder. The only current (PNG Specification version 1.2) -interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7) -is a somewhat complicated 2D interlace scheme, known as Adam7, that -breaks down an image into seven smaller images of varying size, based -on an 8x8 grid. - -libpng can fill out those images or it can give them to you "as is". -If you want them filled out, there are two ways to do that. The one -mentioned in the PNG specification is to expand each pixel to cover -those pixels that have not been read yet (the "rectangle" method). -This results in a blocky image for the first pass, which gradually -smooths out as more pixels are read. The other method is the "sparkle" -method, where pixels are drawn only in their final locations, with the -rest of the image remaining whatever colors they were initialized to -before the start of the read. The first method usually looks better, -but tends to be slower, as there are more pixels to put in the rows. - -If you don't want libpng to handle the interlacing details, just call -png_read_rows() seven times to read in all seven images. Each of the -images is a valid image by itself, or they can all be combined on an -8x8 grid to form a single image (although if you intend to combine them -you would be far better off using the libpng interlace handling). - -The first pass will return an image 1/8 as wide as the entire image -(every 8th column starting in column 0) and 1/8 as high as the original -(every 8th row starting in row 0), the second will be 1/8 as wide -(starting in column 4) and 1/8 as high (also starting in row 0). The -third pass will be 1/4 as wide (every 4th pixel starting in column 0) and -1/8 as high (every 8th row starting in row 4), and the fourth pass will -be 1/4 as wide and 1/4 as high (every 4th column starting in column 2, -and every 4th row starting in row 0). The fifth pass will return an -image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2), -while the sixth pass will be 1/2 as wide and 1/2 as high as the original -(starting in column 1 and row 0). The seventh and final pass will be as -wide as the original, and 1/2 as high, containing all of the odd -numbered scanlines. Phew! - -If you want libpng to expand the images, call this before calling -png_start_read_image() or png_read_update_info(): - - if (interlace_type == PNG_INTERLACE_ADAM7) - number_of_passes - = png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. -This function can be called even if the file is not interlaced, -where it will return one pass. - -If you are not going to display the image after each pass, but are -going to wait until the entire image is read in, use the sparkle -effect. This effect is faster and the end result of either method -is exactly the same. If you are planning on displaying the image -after each pass, the "rectangle" effect is generally considered the -better looking one. - -If you only want the "sparkle" effect, just call png_read_rows() as -normal, with the third parameter NULL. Make sure you make pass over -the image number_of_passes times, and you don't change the data in the -rows between calls. You can change the locations of the data, just -not the data. Each pass only writes the pixels appropriate for that -pass, and assumes the data from previous passes is still valid. - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -If you only want the first effect (the rectangles), do the same as -before except pass the row buffer in the third parameter, and leave -the second parameter NULL. - - png_read_rows(png_ptr, NULL, row_pointers, - number_of_rows); - -.SS Finishing a sequential read - -After you are finished reading the image through the -low-level interface, you can finish reading the file. If you are -interested in comments or time, which may be stored either before or -after the image data, you should pass the separate png_info struct if -you want to keep the comments from before and after the image -separate. If you are not interested, you can pass NULL. - - png_read_end(png_ptr, end_info); - -When you are done, you can free all memory allocated by libpng like this: - - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the bitwise OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -This function only affects data that has already been allocated. -You can call this function after reading the PNG data but before calling -any png_set_*() functions, to control whether the user or the png_set_*() -function is responsible for freeing any existing data that might be present, -and again after the png_set_*() functions to control whether the user -or png_destroy_*() is supposed to free the data. When the user assumes -responsibility for libpng-allocated data, the application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated your row_pointers in a single block, as suggested above in -the description of the high level read interface, you must not transfer -responsibility for freeing it to the png_set_rows or png_read_destroy function, -because they would also try to free the individual row_pointers[i]. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. - -The png_free_data() function will turn off the "valid" flag for anything -it frees. If you need to turn the flag off for a chunk that was freed by your -application instead of by libpng, you can use - - png_set_invalid(png_ptr, info_ptr, mask); - mask - identifies the chunks to be made invalid, - containing the bitwise OR of one or - more of - PNG_INFO_gAMA, PNG_INFO_sBIT, - PNG_INFO_cHRM, PNG_INFO_PLTE, - PNG_INFO_tRNS, PNG_INFO_bKGD, - PNG_INFO_hIST, PNG_INFO_pHYs, - PNG_INFO_oFFs, PNG_INFO_tIME, - PNG_INFO_pCAL, PNG_INFO_sRGB, - PNG_INFO_iCCP, PNG_INFO_sPLT, - PNG_INFO_sCAL, PNG_INFO_IDAT - -For a more compact example of reading a PNG image, see the file example.c. - -.SS Reading PNG files progressively - -The progressive reader is slightly different then the non-progressive -reader. Instead of calling png_read_info(), png_read_rows(), and -png_read_end(), you make one call to png_process_data(), which calls -callbacks when it has the info, a row, or the end of the image. You -set up these callbacks with png_set_progressive_read_fn(). You don't -have to worry about the input/output functions of libpng, as you are -giving the library the data directly in png_process_data(). I will -assume that you have read the section on reading PNG files above, -so I will only highlight the differences (although I will show -all of the code). - -png_structp png_ptr; -png_infop info_ptr; - - /* An example code fragment of how you would - initialize the progressive reader in your - application. */ - int - initialize_png_reader() - { - png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, (png_infopp)NULL, - (png_infopp)NULL); - return (ERROR); - } - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new. You can provide functions - to be called when the header info is valid, - when each row is completed, and when the image - is finished. If you aren't using all functions, - you can specify NULL parameters. Even when all - three functions are NULL, you need to call - png_set_progressive_read_fn(). You can use - any struct as the user_ptr (cast to a void pointer - for the function call), and retrieve the pointer - from inside the callbacks using the function - - png_get_progressive_ptr(png_ptr); - - which will return a void pointer, which you have - to cast appropriately. - */ - png_set_progressive_read_fn(png_ptr, (void *)user_ptr, - info_callback, row_callback, end_callback); - - return 0; - } - - /* A code fragment that you call as you receive blocks - of data */ - int - process_data(png_bytep buffer, png_uint_32 length) - { - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new also. Simply give it a chunk - of data from the file stream (in order, of - course). On machines with segmented memory - models machines, don't give it any more than - 64K. The library seems to run fine with sizes - of 4K. Although you can give it much less if - necessary (I assume you can give it chunks of - 1 byte, I haven't tried less then 256 bytes - yet). When this function returns, you may - want to display any rows that were generated - in the row callback if you don't already do - so there. - */ - png_process_data(png_ptr, info_ptr, buffer, length); - return 0; - } - - /* This function is called (as set by - png_set_progressive_read_fn() above) when enough data - has been supplied so all of the header has been - read. - */ - void - info_callback(png_structp png_ptr, png_infop info) - { - /* Do any setup here, including setting any of - the transformations mentioned in the Reading - PNG files section. For now, you _must_ call - either png_start_read_image() or - png_read_update_info() after all the - transformations are set (even if you don't set - any). You may start getting rows before - png_process_data() returns, so this is your - last chance to prepare for that. - */ - } - - /* This function is called when each row of image - data is complete */ - void - row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) - { - /* If the image is interlaced, and you turned - on the interlace handler, this function will - be called for every row in every pass. Some - of these rows will not be changed from the - previous pass. When the row is not changed, - the new_row variable will be NULL. The rows - and passes are called in order, so you don't - really need the row_num and pass, but I'm - supplying them because it may make your life - easier. - - For the non-NULL rows of interlaced images, - you must call png_progressive_combine_row() - passing in the row and the old row. You can - call this function for NULL rows (it will just - return) and for non-interlaced images (it just - does the memcpy for you) if it will make the - code easier. Thus, you can just do this for - all cases: - */ - - png_progressive_combine_row(png_ptr, old_row, - new_row); - - /* where old_row is what was displayed for - previously for the row. Note that the first - pass (pass == 0, really) will completely cover - the old row, so the rows do not have to be - initialized. After the first pass (and only - for interlaced images), you will have to pass - the current row, and the function will combine - the old row and the new row. - */ - } - - void - end_callback(png_structp png_ptr, png_infop info) - { - /* This function is called after the whole image - has been read, including any chunks after the - image (up to and including the IEND). You - will usually have the same info chunk as you - had in the header, although some data may have - been added to the comments and time fields. - - Most people won't do much here, perhaps setting - a flag that marks the image as finished. - */ - } - - - -.SH IV. Writing - -Much of this is very similar to reading. However, everything of -importance is repeated here, so you won't have to constantly look -back up in the reading section to understand writing. - -.SS Setup - -You will want to do the I/O initialization before you get into libpng, -so if it doesn't work, you don't have anything to undo. If you are not -using the standard I/O functions, you will need to replace them with -custom writing functions. See the discussion under Customizing libpng. - - FILE *fp = fopen(file_name, "wb"); - if (!fp) - { - return (ERROR); - } - -Next, png_struct and png_info need to be allocated and initialized. -As these can be both relatively large, you may not want to store these -on the stack, unless you have stack space to spare. Of course, you -will want to check if they return NULL. If you are also reading, -you won't want to name your read structure and your write structure -both "png_ptr"; you can call them anything you like, such as -"read_ptr" and "write_ptr". Look at pngtest.c, for example. - - png_structp png_ptr = png_create_write_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_write_struct(&png_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_write_struct_2() instead of png_create_write_struct(): - - png_structp png_ptr = png_create_write_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -After you have these structures, you will need to set up the -error handling. When libpng encounters an error, it expects to -longjmp() back to your routine. Therefore, you will need to call -setjmp() and pass the png_jmpbuf(png_ptr). If you -write the file from different routines, you will need to update -the png_jmpbuf(png_ptr) every time you enter a new routine that will -call a png_*() function. See your documentation of setjmp/longjmp -for your compiler for more information on setjmp/longjmp. See -the discussion on libpng error handling in the Customizing Libpng -section below for more information on the libpng error handling. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(fp); - return (ERROR); - } - ... - return; - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the output code. The default for libpng is to -use the C function fwrite(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. Again, if you wish to handle writing data in -another way, see the discussion on libpng I/O handling in the Customizing -Libpng section below. - - png_init_io(png_ptr, fp); - -If you are embedding your PNG into a datastream such as MNG, and don't -want libpng to write the 8-byte signature, or if you have already -written the signature in your application, use - - png_set_sig_bytes(png_ptr, 8); - -to inform libpng that it should not write a signature. - -.SS Write callbacks - -At this point, you can set up a callback function that will be -called after each row has been written, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void write_row_callback(png_ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "write_row_callback") - -To inform libpng about your function, use - - png_set_write_status_fn(png_ptr, write_row_callback); - -You now have the option of modifying how the compression library will -run. The following functions are mainly for testing, but may be useful -in some cases, like if you need to write PNG files extremely fast and -are willing to give up some compression, or if you want to get the -maximum possible compression at the expense of slower writing. If you -have no special needs in this area, let the library do what it wants by -not calling this function at all, as it has been tuned to deliver a good -speed/compression ratio. The second parameter to png_set_filter() is -the filter method, for which the only valid values are 0 (as of the -July 1999 PNG specification, version 1.2) or 64 (if you are writing -a PNG datastream that is to be embedded in a MNG datastream). The third -parameter is a flag that indicates which filter type(s) are to be tested -for each scanline. See the PNG specification for details on the specific filter -types. - - - /* turn on or off filtering, and/or choose - specific filters. You can use either a single - PNG_FILTER_VALUE_NAME or the bitwise OR of one - or more PNG_FILTER_NAME masks. */ - png_set_filter(png_ptr, 0, - PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | - PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | - PNG_FILTER_UP | PNG_FILTER_VALUE_UP | - PNG_FILTER_AVE | PNG_FILTER_VALUE_AVE | - PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| - PNG_ALL_FILTERS); - -If an application -wants to start and stop using particular filters during compression, -it should start out with all of the filters (to ensure that the previous -row of pixels will be stored in case it's needed later), and then add -and remove them after the start of compression. - -If you are writing a PNG datastream that is to be embedded in a MNG -datastream, the second parameter can be either 0 or 64. - -The png_set_compression_*() functions interface to the zlib compression -library, and should mostly be ignored unless you really know what you are -doing. The only generally useful call is png_set_compression_level() -which changes how much time zlib spends on trying to compress the image -data. See the Compression Library (zlib.h and algorithm.txt, distributed -with zlib) for details on the compression levels. - - /* set the zlib compression level */ - png_set_compression_level(png_ptr, - Z_BEST_COMPRESSION); - - /* set other zlib parameters */ - png_set_compression_mem_level(png_ptr, 8); - png_set_compression_strategy(png_ptr, - Z_DEFAULT_STRATEGY); - png_set_compression_window_bits(png_ptr, 15); - png_set_compression_method(png_ptr, 8); - png_set_compression_buffer_size(png_ptr, 8192) - -extern PNG_EXPORT(void,png_set_zbuf_size) - -.SS Setting the contents of info for output - -You now need to fill in the png_info structure with all the data you -wish to write before the actual image. Note that the only thing you -are allowed to write after the image is the text chunks and the time -chunk (as of PNG Specification 1.2, anyway). See png_write_end() and -the latest PNG specification for more information on that. If you -wish to write them before the image, fill them in now, and flag that -data as being valid. If you want to wait until after the data, don't -fill them until png_write_end(). For all the fields in png_info and -their data types, see png.h. For explanations of what the fields -contain, see the PNG specification. - -Some of the more important parts of the png_info are: - - png_set_IHDR(png_ptr, info_ptr, width, height, - bit_depth, color_type, interlace_type, - compression_type, filter_method) - width - holds the width of the image - in pixels (up to 2^31). - height - holds the height of the image - in pixels (up to 2^31). - bit_depth - holds the bit depth of one of the - image channels. - (valid values are 1, 2, 4, 8, 16 - and depend also on the - color_type. See also significant - bits (sBIT) below). - color_type - describes which color/alpha - channels are present. - PNG_COLOR_TYPE_GRAY - (bit depths 1, 2, 4, 8, 16) - PNG_COLOR_TYPE_GRAY_ALPHA - (bit depths 8, 16) - PNG_COLOR_TYPE_PALETTE - (bit depths 1, 2, 4, 8) - PNG_COLOR_TYPE_RGB - (bit_depths 8, 16) - PNG_COLOR_TYPE_RGB_ALPHA - (bit_depths 8, 16) - - PNG_COLOR_MASK_PALETTE - PNG_COLOR_MASK_COLOR - PNG_COLOR_MASK_ALPHA - - interlace_type - PNG_INTERLACE_NONE or - PNG_INTERLACE_ADAM7 - compression_type - (must be - PNG_COMPRESSION_TYPE_DEFAULT) - filter_method - (must be PNG_FILTER_TYPE_DEFAULT - or, if you are writing a PNG to - be embedded in a MNG datastream, - can also be - PNG_INTRAPIXEL_DIFFERENCING) - - png_set_PLTE(png_ptr, info_ptr, palette, - num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_set_gAMA(png_ptr, info_ptr, gamma); - gamma - the gamma the image was created - at (PNG_INFO_gAMA) - - png_set_sRGB(png_ptr, info_ptr, srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of - the sRGB chunk means that the pixel - data is in the sRGB color space. - This chunk also implies specific - values of gAMA and cHRM. Rendering - intent is the CSS-1 property that - has been defined by the International - Color Consortium - (http://www.color.org). - It can be one of - PNG_sRGB_INTENT_SATURATION, - PNG_sRGB_INTENT_PERCEPTUAL, - PNG_sRGB_INTENT_ABSOLUTE, or - PNG_sRGB_INTENT_RELATIVE. - - - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, - srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of the - sRGB chunk means that the pixel - data is in the sRGB color space. - This function also causes gAMA and - cHRM chunks with the specific values - that are consistent with sRGB to be - written. - - png_set_iCCP(png_ptr, info_ptr, name, compression_type, - profile, proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_set_sBIT(png_ptr, info_ptr, sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, red, - green, and blue channels, whichever are - appropriate for the given color type - (png_color_16) - - png_set_tRNS(png_ptr, info_ptr, trans, num_trans, - trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_set_hIST(png_ptr, info_ptr, hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_set_tIME(png_ptr, info_ptr, mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_set_bKGD(png_ptr, info_ptr, background); - background - background color (PNG_VALID_bKGD) - - png_set_text(png_ptr, info_ptr, text_ptr, num_text); - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be NULL or empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (NULL or - empty for unknown). - text_ptr[i].translated_keyword - keyword in UTF-8 (NULL - or empty for unknown). - num_text - number of comments - - png_set_sPLT(png_ptr, info_ptr, &palette_ptr, - num_spalettes); - palette_ptr - array of png_sPLT_struct structures - to be added to the list of palettes - in the info structure. - num_spalettes - number of palette structures to be - added. - - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, - unit_type); - offset_x - positive offset from the left - edge of the screen - offset_y - positive offset from the top - edge of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, - unit_type); - res_x - pixels/unit physical resolution - in x direction - res_y - pixels/unit physical resolution - in y direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_set_sCAL(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_set_sCAL_s(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, - num_unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position to write chunk in file - 0: do not write chunk - PNG_HAVE_IHDR: before PLTE - PNG_HAVE_PLTE: before IDAT - PNG_AFTER_IDAT: after IDAT - -The "location" member is set automatically according to -what part of the output file has already been written. -You can change its value after calling png_set_unknown_chunks() -as demonstrated in pngtest.c. Within each of the "locations", -the chunks are sequenced according to their position in the -structure (that is, the value of "i", which is the order in which -the chunk was either read from the input file or defined with -png_set_unknown_chunks). - -A quick word about text and num_text. text is an array of png_text -structures. num_text is the number of valid structures in the array. -Each png_text structure holds a language code, a keyword, a text value, -and a compression type. - -The compression types have the same valid numbers as the compression -types of the image data. Currently, the only valid number is zero. -However, you can store text either compressed or uncompressed, unlike -images, which always have to be compressed. So if you don't want the -text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. -Because tEXt and zTXt chunks don't have a language field, if you -specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt -any language code or translated keyword will not be written out. - -Until text gets around 1000 bytes, it is not worth compressing it. -After the text has been written out to the file, the compression type -is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR, -so that it isn't written out again at the end (in case you are calling -png_write_end() with the same struct. - -The keywords that are given in the PNG Specification are: - - Title Short (one line) title or - caption for image - Author Name of image's creator - Description Description of image (possibly long) - Copyright Copyright notice - Creation Time Time of original image creation - (usually RFC 1123 format, see below) - Software Software used to create the image - Disclaimer Legal disclaimer - Warning Warning of nature of content - Source Device used to create the image - Comment Miscellaneous comment; conversion - from other image format - -The keyword-text pairs work like this. Keywords should be short -simple descriptions of what the comment is about. Some typical -keywords are found in the PNG specification, as is some recommendations -on keywords. You can repeat keywords in a file. You can even write -some text before the image and some after. For example, you may want -to put a description of the image before the image, but leave the -disclaimer until after, so viewers working over modem connections -don't have to wait for the disclaimer to go over the modem before -they start seeing the image. Finally, keywords should be full -words, not abbreviations. Keywords and text are in the ISO 8859-1 -(Latin-1) character set (a superset of regular ASCII) and can not -contain NUL characters, and should not contain control or other -unprintable characters. To make the comments widely readable, stick -with basic ASCII, and avoid machine specific character set extensions -like the IBM-PC character set. The keyword must be present, but -you can leave off the text string on non-compressed pairs. -Compressed pairs must have a text string, as only the text string -is compressed anyway, so the compression would be meaningless. - -PNG supports modification time via the png_time structure. Two -conversion routines are provided, png_convert_from_time_t() for -time_t and png_convert_from_struct_tm() for struct tm. The -time_t routine uses gmtime(). You don't have to use either of -these, but if you wish to fill in the png_time structure directly, -you should provide the time in universal time (GMT) if possible -instead of your local time. Note that the year number is the full -year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and -that months start with 1. - -If you want to store the time of the original image creation, you should -use a plain tEXt chunk with the "Creation Time" keyword. This is -necessary because the "creation time" of a PNG image is somewhat vague, -depending on whether you mean the PNG file, the time the image was -created in a non-PNG format, a still photo from which the image was -scanned, or possibly the subject matter itself. In order to facilitate -machine-readable dates, it is recommended that the "Creation Time" -tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), -although this isn't a requirement. Unlike the tIME chunk, the -"Creation Time" tEXt chunk is not expected to be automatically changed -by the software. To facilitate the use of RFC 1123 dates, a function -png_convert_to_rfc1123(png_timep) is provided to convert from PNG -time to an RFC 1123 format string. - -.SS Writing unknown chunks - -You can use the png_set_unknown_chunks function to queue up chunks -for writing. You give it a chunk name, raw data, and a size; that's -all there is to it. The chunks will be written by the next following -png_write_info_before_PLTE, png_write_info, or png_write_end function. -Any chunks previously read into the info structure's unknown-chunk -list will also be written out in a sequence that satisfies the PNG -specification's ordering rules. - -.SS The high-level write interface - -At this point there are two ways to proceed; through the high-level -write interface, or through a sequence of low-level write operations. -You can use the high-level interface if your image data is present -in the info structure. All defined output -transformations are permitted, enabled by the following masks. - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes. - -If you have valid image data in the info structure (you can use -png_set_rows() to put image data in the info structure), simply do this: - - png_write_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the bitwise OR of some set of -transformation flags. This call is equivalent to png_write_info(), -followed the set of transformations indicated by the transform mask, -then png_write_image(), and finally png_write_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future output transform.) - -You must use png_transforms and not call any png_set_transform() functions -when you use png_write_png(). - -.SS The low-level write interface - -If you are going the low-level route instead, you are now ready to -write all the file information up to the actual image data. You do -this with a call to png_write_info(). - - png_write_info(png_ptr, info_ptr); - -Note that there is one transformation you may need to do before -png_write_info(). In PNG files, the alpha channel in an image is the -level of opacity. If your data is supplied as a level of -transparency, you can invert the alpha channel before you write it, so -that 0 is fully transparent and 255 (in 8-bit or paletted images) or -65535 (in 16-bit images) is fully opaque, with - - png_set_invert_alpha(png_ptr); - -This must appear before png_write_info() instead of later with the -other transformations because in the case of paletted images the tRNS -chunk data has to be inverted before the tRNS chunk is written. If -your image is not a paletted image, the tRNS data (which in such cases -represents a single color to be rendered as transparent) won't need to -be changed, and you can safely do this transformation after your -png_write_info() call. - -If you need to write a private chunk that you want to appear before -the PLTE chunk when PLTE is present, you can write the PNG info in -two steps, and insert code to write your own chunk between them: - - png_write_info_before_PLTE(png_ptr, info_ptr); - png_set_unknown_chunks(png_ptr, info_ptr, ...); - png_write_info(png_ptr, info_ptr); - -After you've written the file information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -PNG files store RGB pixels packed into 3 or 6 bytes. This code tells -the library to strip input data that has 4 or 8 bytes per pixel down -to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2 -bytes per pixel). - - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - -where the 0 is unused, and the location is either PNG_FILLER_BEFORE or -PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel -is stored XRGB or RGBX. - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit files. -If the data is supplied at 1 pixel per byte, use this code, which will -correctly pack the pixels into a single byte: - - png_set_packing(png_ptr); - -PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your -data is of another bit depth, you can write an sBIT chunk into the -file so that decoders can recover the original data if desired. - - /* Set the true bit depth of the image data */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit.red = true_bit_depth; - sig_bit.green = true_bit_depth; - sig_bit.blue = true_bit_depth; - } - else - { - sig_bit.gray = true_bit_depth; - } - if (color_type & PNG_COLOR_MASK_ALPHA) - { - sig_bit.alpha = true_bit_depth; - } - - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - -If the data is stored in the row buffer in a bit depth other than -one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG), -this will scale the values to appear to be the correct bit depth as -is required by PNG. - - png_set_shift(png_ptr, &sig_bit); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code would be used if they are -supplied the other way (little-endian, i.e. least significant bits -first, the way PCs store them): - - if (bit_depth > 8) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -PNG files store 3 color pixels in red, green, blue order. This code -would be used if they are supplied as blue, green, red: - - png_set_bgr(png_ptr); - -PNG files describe monochrome as black being zero and white being -one. This code would be used if the pixels are supplied with this reversed -(black being one and white being zero): - - png_set_invert_mono(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_write_user_transform_fn(png_ptr, - write_transform_fn); - -You must supply the function - - void write_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -before any of the other transformations are processed. - -You can also set up a pointer to a user structure for use by your -callback function. - - png_set_user_transform_info(png_ptr, user_ptr, 0, 0); - -The user_channels and user_depth parameters of this function are ignored -when writing; you can set them to zero as shown. - -You can retrieve the pointer via the function png_get_user_transform_ptr(). -For example: - - voidp write_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -It is possible to have libpng flush any pending output, either manually, -or automatically after a certain number of lines have been written. To -flush the output stream a single time call: - - png_write_flush(png_ptr); - -and to have libpng flush the output stream periodically after a certain -number of scanlines have been written, call: - - png_set_flush(png_ptr, nrows); - -Note that the distance between rows is from the last time png_write_flush() -was called, or the first row of the image if it has never been called. -So if you write 50 lines, and then png_set_flush 25, it will flush the -output on the next scanline, and every 25 lines thereafter, unless -png_write_flush() is called before 25 more lines have been written. -If nrows is too small (less than about 10 lines for a 640 pixel wide -RGB image) the image compression may decrease noticeably (although this -may be acceptable for real-time applications). Infrequent flushing will -only degrade the compression performance by a few percent over images -that do not use flushing. - -.SS Writing the image data - -That's it for the transformations. Now you can write the image data. -The simplest way to do this is in one function call. If you have the -whole image in memory, you can just call png_write_image() and libpng -will write the image. You will need to pass in an array of pointers to -each row. This function automatically handles interlacing, so you don't -need to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_write_rows(). - - png_write_image(png_ptr, row_pointers); - -where row_pointers is: - - png_byte *row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to write the whole image at once, you can -use png_write_rows() instead. If the file is not interlaced, -this is simple: - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -row_pointers is the same as in the png_write_image() call. - -If you are just writing one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - - png_write_row(png_ptr, row_pointer); - -When the file is interlaced, things can get a good deal more -complicated. The only currently (as of the PNG Specification -version 1.2, dated July 1999) defined interlacing scheme for PNG files -is the "Adam7" interlace scheme, that breaks down an -image into seven smaller images of varying size. libpng will build -these images for you, or you can do them yourself. If you want to -build them yourself, see the PNG specification for details of which -pixels to write when. - -If you don't want libpng to handle the interlacing details, just -use png_set_interlace_handling() and call png_write_rows() the -correct number of times to write all seven sub-images. - -If you want libpng to build the sub-images, call this before you start -writing any rows: - - number_of_passes = - png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. - -Then write the complete image number_of_passes times. - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -As some of these rows are not used, and thus return immediately, -you may want to read about interlacing in the PNG specification, -and only update the rows that are actually used. - -.SS Finishing a sequential write - -After you are finished writing the image, you should finish writing -the file. If you are interested in writing comments or time, you should -pass an appropriately filled png_info pointer. If you are not interested, -you can pass NULL. - - png_write_end(png_ptr, info_ptr); - -When you are done, you can free all memory used by libpng like this: - - png_destroy_write_struct(&png_ptr, &info_ptr); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the bitwise OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -If you allocated data such as a palette that you passed -in to libpng with png_set_*, you must not free it until just before the call to -png_destroy_write_struct(). - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -For example, to transfer responsibility for some data from a read structure -to a write structure, you could use - - png_data_freer(read_ptr, read_info_ptr, - PNG_USER_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - png_data_freer(write_ptr, write_info_ptr, - PNG_DESTROY_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - -thereby briefly reassigning responsibility for freeing to the user but -immediately afterwards reassigning it once more to the write_destroy -function. Having done this, it would then be safe to destroy the read -structure and continue to use the PLTE, tRNS, and hIST data in the write -structure. - -This function only affects data that has already been allocated. -You can call this function before calling after the png_set_*() functions -to control whether the user or png_destroy_*() is supposed to free the data. -When the user assumes responsibility for libpng-allocated data, the -application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. -For a more compact example of writing a PNG image, see the file example.c. - -.SH V. Modifying/Customizing libpng: - -There are three issues here. The first is changing how libpng does -standard things like memory allocation, input/output, and error handling. -The second deals with more complicated things like adding new chunks, -adding new transformations, and generally changing how libpng works. -Both of those are compile-time issues; that is, they are generally -determined at the time the code is written, and there is rarely a need -to provide the user with a means of changing them. The third is a -run-time issue: choosing between and/or tuning one or more alternate -versions of computationally intensive routines; specifically, optimized -assembly-language (and therefore compiler- and platform-dependent) -versions. - -Memory allocation, input/output, and error handling - -All of the memory allocation, input/output, and error handling in libpng -goes through callbacks that are user-settable. The default routines are -in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change -these functions, call the appropriate png_set_*_fn() function. - -Memory allocation is done through the functions png_malloc() -and png_free(). These currently just call the standard C functions. If -your pointers can't access more then 64K at a time, you will want to set -MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling -memory allocation on a platform will change between applications, these -functions must be modified in the library at compile time. If you prefer -to use a different method of allocating and freeing data, you can use -png_create_read_struct_2() or png_create_write_struct_2() to register -your own functions as described above. -These functions also provide a void pointer that can be retrieved via - - mem_ptr=png_get_mem_ptr(png_ptr); - -Your replacement memory functions must have prototypes as follows: - - png_voidp malloc_fn(png_structp png_ptr, - png_size_t size); - void free_fn(png_structp png_ptr, png_voidp ptr); - -Your malloc_fn() must return NULL in case of failure. The png_malloc() -function will normally call png_error() if it receives a NULL from the -system memory allocator or from your replacement malloc_fn(). - -Input/Output in libpng is done through png_read() and png_write(), -which currently just call fread() and fwrite(). The FILE * is stored in -png_struct and is initialized via png_init_io(). If you wish to change -the method of I/O, the library supplies callbacks that you can set -through the function png_set_read_fn() and png_set_write_fn() at run -time, instead of calling the png_init_io() function. These functions -also provide a void pointer that can be retrieved via the function -png_get_io_ptr(). For example: - - png_set_read_fn(png_structp read_ptr, - voidp read_io_ptr, png_rw_ptr read_data_fn) - - png_set_write_fn(png_structp write_ptr, - voidp write_io_ptr, png_rw_ptr write_data_fn, - png_flush_ptr output_flush_fn); - - voidp read_io_ptr = png_get_io_ptr(read_ptr); - voidp write_io_ptr = png_get_io_ptr(write_ptr); - -The replacement I/O functions must have prototypes as follows: - - void user_read_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_write_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_flush_data(png_structp png_ptr); - -Supplying NULL for the read, write, or flush functions sets them back -to using the default C stream functions. It is an error to read from -a write stream, and vice versa. - -Error handling in libpng is done through png_error() and png_warning(). -Errors handled through png_error() are fatal, meaning that png_error() -should never return to its caller. Currently, this is handled via -setjmp() and longjmp() (unless you have compiled libpng with -PNG_SETJMP_NOT_SUPPORTED, in which case it is handled via PNG_ABORT()), -but you could change this to do things like exit() if you should wish. - -On non-fatal errors, png_warning() is called -to print a warning message, and then control returns to the calling code. -By default png_error() and png_warning() print a message on stderr via -fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined -(because you don't want the messages) or PNG_NO_STDIO defined (because -fprintf() isn't available). If you wish to change the behavior of the error -functions, you will need to set up your own message callbacks. These -functions are normally supplied at the time that the png_struct is created. -It is also possible to redirect errors and warnings to your own replacement -functions after png_create_*_struct() has been called by calling: - - png_set_error_fn(png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warning_fn); - - png_voidp error_ptr = png_get_error_ptr(png_ptr); - -If NULL is supplied for either error_fn or warning_fn, then the libpng -default function will be used, calling fprintf() and/or longjmp() if a -problem is encountered. The replacement error functions should have -parameters as follows: - - void user_error_fn(png_structp png_ptr, - png_const_charp error_msg); - void user_warning_fn(png_structp png_ptr, - png_const_charp warning_msg); - -The motivation behind using setjmp() and longjmp() is the C++ throw and -catch exception handling methods. This makes the code much easier to write, -as there is no need to check every return code of every function call. -However, there are some uncertainties about the status of local variables -after a longjmp, so the user may want to be careful about doing anything after -setjmp returns non-zero besides returning itself. Consult your compiler -documentation for more details. For an alternative approach, you may wish -to use the "cexcept" facility (see http://cexcept.sourceforge.net). - -.SS Custom chunks - -If you need to read or write custom chunks, you may need to get deeper -into the libpng code. The library now has mechanisms for storing -and writing chunks of unknown type; you can even declare callbacks -for custom chunks. However, this may not be good enough if the -library code itself needs to know about interactions between your -chunk and existing `intrinsic' chunks. - -If you need to write a new intrinsic chunk, first read the PNG -specification. Acquire a first level of -understanding of how it works. Pay particular attention to the -sections that describe chunk names, and look at how other chunks were -designed, so you can do things similarly. Second, check out the -sections of libpng that read and write chunks. Try to find a chunk -that is similar to yours and use it as a template. More details can -be found in the comments inside the code. It is best to handle unknown -chunks in a generic method, via callback functions, instead of by -modifying libpng functions. - -If you wish to write your own transformation for the data, look through -the part of the code that does the transformations, and check out some of -the simpler ones to get an idea of how they work. Try to find a similar -transformation to the one you want to add and copy off of it. More details -can be found in the comments inside the code itself. - -.SS Configuring for 16 bit platforms - -You will want to look into zconf.h to tell zlib (and thus libpng) that -it cannot allocate more then 64K at a time. Even if you can, the memory -won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. - -.SS Configuring for DOS - -For DOS users who only have access to the lower 640K, you will -have to limit zlib's memory usage via a png_set_compression_mem_level() -call. See zlib.h or zconf.h in the zlib library for more information. - -.SS Configuring for Medium Model - -Libpng's support for medium model has been tested on most of the popular -compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets -defined, and FAR gets defined to far in pngconf.h, and you should be -all set. Everything in the library (except for zlib's structure) is -expecting far data. You must use the typedefs with the p or pp on -the end for pointers (or at least look at them and be careful). Make -note that the rows of data are defined as png_bytepp, which is an -unsigned char far * far *. - -.SS Configuring for gui/windowing platforms: - -You will need to write new error and warning functions that use the GUI -interface, as described previously, and set them to be the error and -warning functions at the time that png_create_*_struct() is called, -in order to have them available during the structure initialization. -They can be changed later via png_set_error_fn(). On some compilers, -you may also have to change the memory allocators (png_malloc, etc.). - -.SS Configuring for compiler xxx: - -All includes for libpng are in pngconf.h. If you need to add/change/delete -an include, this is the place to do it. The includes that are not -needed outside libpng are protected by the PNG_INTERNAL definition, -which is only defined for those routines inside libpng itself. The -files in libpng proper only include png.h, which includes pngconf.h. - -.SS Configuring zlib: - -There are special functions to configure the compression. Perhaps the -most useful one changes the compression level, which currently uses -input compression values in the range 0 - 9. The library normally -uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests -have shown that for a large majority of images, compression values in -the range 3-6 compress nearly as well as higher levels, and do so much -faster. For online applications it may be desirable to have maximum speed -(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also -specify no compression (Z_NO_COMPRESSION = 0), but this would create -files larger than just storing the raw bitmap. You can specify the -compression level by calling: - - png_set_compression_level(png_ptr, level); - -Another useful one is to reduce the memory level used by the library. -The memory level defaults to 8, but it can be lowered if you are -short on memory (running DOS, for example, where you only have 640K). -Note that the memory level does have an effect on compression; among -other things, lower levels will result in sections of incompressible -data being emitted in smaller stored blocks, with a correspondingly -larger relative overhead of up to 15% in the worst case. - - png_set_compression_mem_level(png_ptr, level); - -The other functions are for configuring zlib. They are not recommended -for normal use and may result in writing an invalid PNG file. See -zlib.h for more information on what these mean. - - png_set_compression_strategy(png_ptr, - strategy); - png_set_compression_window_bits(png_ptr, - window_bits); - png_set_compression_method(png_ptr, method); - png_set_compression_buffer_size(png_ptr, size); - -.SS Controlling row filtering - -If you want to control whether libpng uses filtering or not, which -filters are used, and how it goes about picking row filters, you -can call one of these functions. The selection and configuration -of row filters can have a significant impact on the size and -encoding speed and a somewhat lesser impact on the decoding speed -of an image. Filtering is enabled by default for RGB and grayscale -images (with and without alpha), but not for paletted images nor -for any images with bit depths less than 8 bits/pixel. - -The 'method' parameter sets the main filtering method, which is -currently only '0' in the PNG 1.2 specification. The 'filters' -parameter sets which filter(s), if any, should be used for each -scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS -to turn filtering on and off, respectively. - -Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, -PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise -ORed together with '|' to specify one or more filters to use. -These filters are described in more detail in the PNG specification. -If you intend to change the filter type during the course of writing -the image, you should start with flags set for all of the filters -you intend to use so that libpng can initialize its internal -structures appropriately for all of the filter types. (Note that this -means the first row must always be adaptively filtered, because libpng -currently does not allocate the filter buffers until png_write_row() -is called for the first time.) - - filters = PNG_FILTER_NONE | PNG_FILTER_SUB - PNG_FILTER_UP | PNG_FILTER_AVE | - PNG_FILTER_PAETH | PNG_ALL_FILTERS; - - png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, - filters); - The second parameter can also be - PNG_INTRAPIXEL_DIFFERENCING if you are - writing a PNG to be embedded in a MNG - datastream. This parameter must be the - same as the value of filter_method used - in png_set_IHDR(). - -It is also possible to influence how libpng chooses from among the -available filters. This is done in one or both of two ways - by -telling it how important it is to keep the same filter for successive -rows, and by telling it the relative computational costs of the filters. - - double weights[3] = {1.5, 1.3, 1.1}, - costs[PNG_FILTER_VALUE_LAST] = - {1.0, 1.3, 1.3, 1.5, 1.7}; - - png_set_filter_heuristics(png_ptr, - PNG_FILTER_HEURISTIC_WEIGHTED, 3, - weights, costs); - -The weights are multiplying factors that indicate to libpng that the -row filter should be the same for successive rows unless another row filter -is that many times better than the previous filter. In the above example, -if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a -"sum of absolute differences" 1.5 x 1.3 times higher than other filters -and still be chosen, while the NONE filter could have a sum 1.1 times -higher than other filters and still be chosen. Unspecified weights are -taken to be 1.0, and the specified weights should probably be declining -like those above in order to emphasize recent filters over older filters. - -The filter costs specify for each filter type a relative decoding cost -to be considered when selecting row filters. This means that filters -with higher costs are less likely to be chosen over filters with lower -costs, unless their "sum of absolute differences" is that much smaller. -The costs do not necessarily reflect the exact computational speeds of -the various filters, since this would unduly influence the final image -size. - -Note that the numbers above were invented purely for this example and -are given only to help explain the function usage. Little testing has -been done to find optimum values for either the costs or the weights. - -.SS Removing unwanted object code - -There are a bunch of #define's in pngconf.h that control what parts of -libpng are compiled. All the defines end in _SUPPORTED. If you are -never going to use a capability, you can change the #define to #undef -before recompiling libpng and save yourself code and data space, or -you can turn off individual capabilities with defines that begin with -PNG_NO_. - -You can also turn all of the transforms and ancillary chunk capabilities -off en masse with compiler directives that define -PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, -or all four, -along with directives to turn on any of the capabilities that you do -want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable -the extra transformations but still leave the library fully capable of reading -and writing PNG files with all known public chunks -Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive -produces a library that is incapable of reading or writing ancillary chunks. -If you are not using the progressive reading capability, you can -turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse -this with the INTERLACING capability, which you'll still have). - -All the reading and writing specific code are in separate files, so the -linker should only grab the files it needs. However, if you want to -make sure, or if you are building a stand alone library, all the -reading files start with pngr and all the writing files start with -pngw. The files that don't match either (like png.c, pngtrans.c, etc.) -are used for both reading and writing, and always need to be included. -The progressive reader is in pngpread.c - -If you are creating or distributing a dynamically linked library (a .so -or DLL file), you should not remove or disable any parts of the library, -as this will cause applications linked with different versions of the -library to fail if they call functions not available in your library. -The size of the library itself should not be an issue, because only -those sections that are actually used will be loaded into memory. - -.SS Requesting debug printout - -The macro definition PNG_DEBUG can be used to request debugging -printout. Set it to an integer value in the range 0 to 3. Higher -numbers result in increasing amounts of debugging information. The -information is printed to the "stderr" file, unless another file -name is specified in the PNG_DEBUG_FILE macro definition. - -When PNG_DEBUG > 0, the following functions (macros) become available: - - png_debug(level, message) - png_debug1(level, message, p1) - png_debug2(level, message, p1, p2) - -in which "level" is compared to PNG_DEBUG to decide whether to print -the message, "message" is the formatted string to be printed, -and p1 and p2 are parameters that are to be embedded in the string -according to printf-style formatting directives. For example, - - png_debug1(2, "foo=%d\n", foo); - -is expanded to - - if(PNG_DEBUG > 2) - fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); - -When PNG_DEBUG is defined but is zero, the macros aren't defined, but you -can still use PNG_DEBUG to control your own debugging: - - #ifdef PNG_DEBUG - fprintf(stderr, ... - #endif - -When PNG_DEBUG = 1, the macros are defined, but only png_debug statements -having level = 0 will be printed. There aren't any such statements in -this version of libpng, but if you insert some they will be printed. - -.SH VI. Runtime optimization - -A new feature in libpng 1.2.0 is the ability to dynamically switch between -standard and optimized versions of some routines. Currently these are -limited to three computationally intensive tasks when reading PNG files: -decoding row filters, expanding interlacing, and combining interlaced or -transparent row data with previous row data. Currently the optimized -versions are available only for x86 (Intel, AMD, etc.) platforms with -MMX support, though this may change in future versions. (For example, -the non-MMX assembler optimizations for zlib might become similarly -runtime-selectable in future releases, in which case libpng could be -extended to support them. Alternatively, the compile-time choice of -floating-point versus integer routines for gamma correction might become -runtime-selectable.) - -Because such optimizations tend to be very platform- and compiler-dependent, -both in how they are written and in how they perform, the new runtime code -in libpng has been written to allow programs to query, enable, and disable -either specific optimizations or all such optimizations. For example, to -enable all possible optimizations (bearing in mind that some "optimizations" -may actually run more slowly in rare cases): - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - png_uint_32 mask, flags; - - flags = png_get_asm_flags(png_ptr); - mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); - png_set_asm_flags(png_ptr, flags | mask); - #endif - -To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ -by itself when calling png_get_asm_flagmask(); similarly for optimizing -only writing. To disable all optimizations: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - flags = png_get_asm_flags(png_ptr); - mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); - png_set_asm_flags(png_ptr, flags & ~mask); - #endif - -To enable or disable only MMX-related features, use png_get_mmx_flagmask() -in place of png_get_asm_flagmask(). The mmx version takes one additional -parameter: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - int selection = PNG_SELECT_READ | PNG_SELECT_WRITE; - int compilerID; - - mask = png_get_mmx_flagmask(selection, &compilerID); - #endif - -On return, compilerID will indicate which version of the MMX assembler -optimizations was compiled. Currently two flavors exist: Microsoft -Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2). -On non-x86 platforms or on systems compiled without MMX optimizations, a -value of -1 is used. - -Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return -all valid, settable optimization bits for the version of the library that's -currently in use. In the case of shared (dynamically linked) libraries, -this may include optimizations that did not exist at the time the code was -written and compiled. It is also possible, of course, to enable only known, -specific optimizations; for example: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - flags = PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - png_set_asm_flags(png_ptr, flags); - #endif - -This method would enable only the MMX read-optimizations available at the -time of libpng 1.2.0's release, regardless of whether a later version of -the DLL were actually being used. (Also note that these functions did not -exist in versions older than 1.2.0, so any attempt to run a dynamically -linked app on such an older version would fail.) - -To determine whether the processor supports MMX instructions at all, use -the png_mmx_support() function: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - mmxsupport = png_mmx_support(); - #endif - -It returns -1 if MMX support is not compiled into libpng, 0 if MMX code -is compiled but MMX is not supported by the processor, or 1 if MMX support -is fully available. Note that png_mmx_support(), png_get_mmx_flagmask(), -and png_get_asm_flagmask() all may be called without allocating and ini- -tializing any PNG structures (for example, as part of a usage screen or -"about" box). - -The following code can be used to prevent an application from using the -thread_unsafe features, even if libpng was built with PNG_THREAD_UNSAFE_OK -defined: - -#if defined(PNG_USE_PNGGCCRD) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) \ - && defined(PNG_THREAD_UNSAFE_OK) - /* Disable thread-unsafe features of pnggccrd */ - if (png_access_version_number() >= 10200) - { - png_uint_32 mmx_disable_mask = 0; - png_uint_32 asm_flags; - - mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); - asm_flags = png_get_asm_flags(png_ptr); - png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask); - } -#endif - -For more extensive examples of runtime querying, enabling and disabling -of optimized features, see contrib/gregbook/readpng2.c in the libpng -source-code distribution. - -.SH VII. MNG support - -The MNG specification (available at http://www.libpng.org/pub/mng) allows -certain extensions to PNG for PNG images that are embedded in MNG datastreams. -Libpng can support some of these extensions. To enable them, use the -png_permit_mng_features() function: - - feature_set = png_permit_mng_features(png_ptr, mask) - mask is a png_uint_32 containing the bitwise OR of the - features you want to enable. These include - PNG_FLAG_MNG_EMPTY_PLTE - PNG_FLAG_MNG_FILTER_64 - PNG_ALL_MNG_FEATURES - feature_set is a png_uint_32 that is the bitwise AND of - your mask with the set of MNG features that is - supported by the version of libpng that you are using. - -It is an error to use this function when reading or writing a standalone -PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped -in a MNG datastream. As a minimum, it must have the MNG 8-byte signature -and the MHDR and MEND chunks. Libpng does not provide support for these -or any other MNG chunks; your application must provide its own support for -them. You may wish to consider using libmng (available at -http://www.libmng.com) instead. - -.SH VIII. Changes to Libpng from version 0.88 - -It should be noted that versions of libpng later than 0.96 are not -distributed by the original libpng author, Guy Schalnat, nor by -Andreas Dilger, who had taken over from Guy during 1996 and 1997, and -distributed versions 0.89 through 0.96, but rather by another member -of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are -still alive and well, but they have moved on to other things. - -The old libpng functions png_read_init(), png_write_init(), -png_info_init(), png_read_destroy(), and png_write_destroy() have been -moved to PNG_INTERNAL in version 0.95 to discourage their use. These -functions will be removed from libpng version 2.0.0. - -The preferred method of creating and initializing the libpng structures is -via the png_create_read_struct(), png_create_write_struct(), and -png_create_info_struct() because they isolate the size of the structures -from the application, allow version error checking, and also allow the -use of custom error handling routines during the initialization, which -the old functions do not. The functions png_read_destroy() and -png_write_destroy() do not actually free the memory that libpng -allocated for these structs, but just reset the data structures, so they -can be used instead of png_destroy_read_struct() and -png_destroy_write_struct() if you feel there is too much system overhead -allocating and freeing the png_struct for each image read. - -Setting the error callbacks via png_set_message_fn() before -png_read_init() as was suggested in libpng-0.88 is no longer supported -because this caused applications that do not use custom error functions -to fail if the png_ptr was not initialized to zero. It is still possible -to set the error callbacks AFTER png_read_init(), or to change them with -png_set_error_fn(), which is essentially the same function, but with a new -name to force compilation errors with applications that try to use the old -method. - -Starting with version 1.0.7, you can find out which version of the library -you are using at run-time: - - png_uint_32 libpng_vn = png_access_version_number(); - -The number libpng_vn is constructed from the major version, minor -version with leading zero, and release number with leading zero, -(e.g., libpng_vn for version 1.0.7 is 10007). - -You can also check which version of png.h you used when compiling your -application: - - png_uint_32 application_vn = PNG_LIBPNG_VER; - -.SH IX. Y2K Compliance in libpng - -January 31, 2007 - -Since the PNG Development group is an ad-hoc body, we can't make -an official declaration. - -This is your unofficial assurance that libpng from version 0.71 and -upward through 1.2.16 are Y2K compliant. It is my belief that earlier -versions were also Y2K compliant. - -Libpng only has three year fields. One is a 2-byte unsigned integer that -will hold years up to 65535. The other two hold the date in text -format, and will hold years up to 9999. - -The integer is - "png_uint_16 year" in png_time_struct. - -The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. - -There are seven time-related functions: - - png_convert_to_rfc_1123() in png.c - (formerly png_convert_to_rfc_1152() in error) - png_convert_from_struct_tm() in pngwrite.c, called - in pngwrite.c - png_convert_from_time_t() in pngwrite.c - png_get_tIME() in pngget.c - png_handle_tIME() in pngrutil.c, called in pngread.c - png_set_tIME() in pngset.c - png_write_tIME() in pngwutil.c, called in pngwrite.c - -All appear to handle dates properly in a Y2K environment. The -png_convert_from_time_t() function calls gmtime() to convert from system -clock time, which returns (year - 1900), which we properly convert to -the full 4-digit year. There is a possibility that applications using -libpng are not passing 4-digit years into the png_convert_to_rfc_1123() -function, or that they are incorrectly passing only a 2-digit year -instead of "year - 1900" into the png_convert_from_struct_tm() function, -but this is not under our control. The libpng documentation has always -stated that it works with 4-digit years, and the APIs have been -documented as such. - -The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned -integer to hold the year, and can hold years as large as 65535. - -zlib, upon which libpng depends, is also Y2K compliant. It contains -no date-related code. - - - Glenn Randers-Pehrson - libpng maintainer - PNG Development Group - -.SH NOTE - -Note about libpng version numbers: - -Due to various miscommunications, unforeseen code incompatibilities -and occasional factors outside the authors' control, version numbering -on the library has not always been consistent and straightforward. -The following table summarizes matters since version 0.89c, which was -the first widely used release: - - source png.h png.h shared-lib - version string int version - ------- ------ ----- ---------- - 0.89c ("beta 3") 0.89 89 1.0.89 - 0.90 ("beta 4") 0.90 90 0.90 - 0.95 ("beta 5") 0.95 95 0.95 - 0.96 ("beta 6") 0.96 96 0.96 - 0.97b ("beta 7") 1.00.97 97 1.0.1 - 0.97c 0.97 97 2.0.97 - 0.98 0.98 98 2.0.98 - 0.99 0.99 98 2.0.99 - 0.99a-m 0.99 99 2.0.99 - 1.00 1.00 100 2.1.0 - 1.0.0 1.0.0 100 2.1.0 - 1.0.0 (from here on, the 100 2.1.0 - 1.0.1 png.h string is 10001 2.1.0 - 1.0.1a-e identical to the 10002 from here on, the - 1.0.2 source version) 10002 shared library is 2.V - 1.0.2a-b 10003 where V is the source - 1.0.1 10001 code version except as - 1.0.1a-e 10002 2.1.0.1a-e noted. - 1.0.2 10002 2.1.0.2 - 1.0.2a-b 10003 2.1.0.2a-b - 1.0.3 10003 2.1.0.3 - 1.0.3a-d 10004 2.1.0.3a-d - 1.0.4 10004 2.1.0.4 - 1.0.4a-f 10005 2.1.0.4a-f - 1.0.5 (+ 2 patches) 10005 2.1.0.5 - 1.0.5a-d 10006 2.1.0.5a-d - 1.0.5e-r 10100 2.1.0.5e-r - 1.0.5s-v 10006 2.1.0.5s-v - 1.0.6 (+ 3 patches) 10006 2.1.0.6 - 1.0.6d-g 10007 2.1.0.6d-g - 1.0.6h 10007 10.6h - 1.0.6i 10007 10.6i - 1.0.6j 10007 2.1.0.6j - 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 - 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 - 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 - 1.0.7 1 10007 2.1.0.7 - 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 - 1.0.8rc1 1 10008 2.1.0.8rc1 - 1.0.8 1 10008 2.1.0.8 - 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 - 1.0.9rc1 1 10009 2.1.0.9rc1 - 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 - 1.0.9rc2 1 10009 2.1.0.9rc2 - 1.0.9 1 10009 2.1.0.9 - 1.0.10beta1 1 10010 2.1.0.10beta1 - 1.0.10rc1 1 10010 2.1.0.10rc1 - 1.0.10 1 10010 2.1.0.10 - 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 - 1.0.11rc1 1 10011 2.1.0.11rc1 - 1.0.11 1 10011 2.1.0.11 - 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 - 1.0.12rc1 2 10012 2.1.0.12rc1 - 1.0.12 2 10012 2.1.0.12 - 1.1.0a-f - 10100 2.1.1.0a-f abandoned - 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 - 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 - 1.2.0rc1 3 10200 3.1.2.0rc1 - 1.2.0 3 10200 3.1.2.0 - 1.2.1beta-4 3 10201 3.1.2.1beta1-4 - 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 - 1.2.1 3 10201 3.1.2.1 - 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 - 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 - 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 - 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 - 1.0.13 10 10013 10.so.0.1.0.13 - 1.2.2 12 10202 12.so.0.1.2.2 - 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 - 1.2.3 12 10203 12.so.0.1.2.3 - 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 - 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 - 1.0.14 10 10014 10.so.0.1.0.14 - 1.2.4 13 10204 12.so.0.1.2.4 - 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 - 1.0.15rc1 10 10015 10.so.0.1.0.15rc1 - 1.0.15 10 10015 10.so.0.1.0.15 - 1.2.5 13 10205 12.so.0.1.2.5 - 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 - 1.2.6rc1-5 13 10206 12.so.0.1.2.6rc1-5 - 1.0.16 10 10016 10.so.0.1.0.16 - 1.2.6 13 10206 12.so.0.1.2.6 - 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 - 1.0.17rc1 10 10017 10.so.0.1.0.17rc1 - 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 - 1.0.17 10 10017 10.so.0.1.0.17 - 1.2.7 13 10207 12.so.0.1.2.7 - 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 - 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5 - 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 - 1.0.18 10 10018 10.so.0.1.0.18 - 1.2.8 13 10208 12.so.0.1.2.8 - 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 - 1.2.9beta4-11 13 10209 12.so.0.9[.0] - 1.2.9rc1 13 10209 12.so.0.9[.0] - 1.2.9 13 10209 12.so.0.9[.0] - 1.2.10beta1-8 13 10210 12.so.0.10[.0] - 1.2.10rc1-3 13 10210 12.so.0.10[.0] - 1.2.10 13 10210 12.so.0.10[.0] - 1.2.11beta1-4 13 10211 12.so.0.11[.0] - 1.0.19rc1-5 10 10019 10.so.0.19[.0] - 1.2.11rc1-5 13 10211 12.so.0.11[.0] - 1.0.19 10 10019 10.so.0.19[.0] - 1.2.11 13 10211 12.so.0.11[.0] - 1.0.20 10 10020 10.so.0.20[.0] - 1.2.12 13 10212 12.so.0.12[.0] - 1.2.13beta1 13 10213 12.so.0.13[.0] - 1.0.21 10 10021 10.so.0.21[.0] - 1.2.13 13 10213 12.so.0.13[.0] - 1.2.14beta1-2 13 10214 12.so.0.14[.0] - 1.0.22rc1 10 10022 10.so.0.22[.0] - 1.2.14rc1 13 10214 12.so.0.14[.0] - 1.2.15beta1-6 13 10215 12.so.0.15[.0] - 1.0.23rc1-5 10 10023 10.so.0.23[.0] - 1.2.15rc1-5 13 10215 12.so.0.15[.0] - 1.0.23 10 10023 10.so.0.23[.0] - 1.2.15 13 10215 12.so.0.15[.0] - 1.2.16beta1-2 13 10216 12.so.0.16[.0] - 1.2.16rc1 13 10216 12.so.0.16[.0] - 1.0.24 10 10024 10.so.0.24[.0] - 1.2.16 13 10216 12.so.0.16[.0] - -Henceforth the source version will match the shared-library minor -and patch numbers; the shared-library major version number will be -used for changes in backward compatibility, as it is intended. The -PNG_PNGLIB_VER macro, which is not used within libpng but is available -for applications, is an unsigned integer of the form xyyzz corresponding -to the source version x.y.z (leading zeros in y and z). Beta versions -were given the previous public release number plus a letter, until -version 1.0.6j; from then on they were given the upcoming public -release number plus "betaNN" or "rcN". - -.SH "SEE ALSO" -libpngpf(3), png(5) -.LP -.IR libpng : -.IP -http://libpng.sourceforge.net (follow the [DOWNLOAD] link) -http://www.libpng.org/pub/png - -.LP -.IR zlib : -.IP -(generally) at the same location as -.I libpng -or at -.br -ftp://ftp.info-zip.org/pub/infozip/zlib - -.LP -.IR PNG specification: RFC 2083 -.IP -(generally) at the same location as -.I libpng -or at -.br -ftp://ds.internic.net/rfc/rfc2083.txt -.br -or (as a W3C Recommendation) at -.br -http://www.w3.org/TR/REC-png.html - -.LP -In the case of any inconsistency between the PNG specification -and this library, the specification takes precedence. - -.SH AUTHORS -This man page: Glenn Randers-Pehrson - - -The contributing authors would like to thank all those who helped -with testing, bug fixes, and patience. This wouldn't have been -possible without all of you. - -Thanks to Frank J. T. Wojcik for helping with the documentation. - -Libpng version 1.2.16 - January 31, 2007: -Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. -Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). - -Supported by the PNG development group -.br -png-mng-implement at lists.sf.net -(subscription required; visit -png-mng-implement at lists.sourceforge.net (subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe). - -.SH COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: - -(This copy of the libpng notices is provided for your convenience. In case of -any discrepancy between this copy and the notices in the file png.h that is -included in the libpng distribution, the latter shall prevail.) - -If you modify libpng you may insert additional notices immediately following -this sentence. - -libpng versions 1.2.6, August 15, 2004, through 1.2.16, January 31, 2007, are -Copyright (c) 2004-2006 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-1.2.5 -with the following individual added to the list of Contributing Authors - - Cosmin Truta - -libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are -Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-1.0.6 -with the following individuals added to the list of Contributing Authors - - Simon-Pierre Cadieux - Eric S. Raymond - Gilles Vollant - -and with the following additions to the disclaimer: - - There is no warranty against interference with your - enjoyment of the library or against infringement. - There is no warranty that our efforts or the library - will fulfill any of your particular purposes or needs. - This library is provided with all faults, and the entire - risk of satisfactory quality, performance, accuracy, and - effort is with the user. - -libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are -Copyright (c) 1998, 1999 Glenn Randers-Pehrson -Distributed according to the same disclaimer and license as libpng-0.96, -with the following individuals added to the list of Contributing Authors: - - Tom Lane - Glenn Randers-Pehrson - Willem van Schaik - -libpng versions 0.89, June 1996, through 0.96, May 1997, are -Copyright (c) 1996, 1997 Andreas Dilger -Distributed according to the same disclaimer and license as libpng-0.88, -with the following individuals added to the list of Contributing Authors: - - John Bowler - Kevin Bracey - Sam Bushell - Magnus Holmgren - Greg Roelofs - Tom Tanner - -libpng versions 0.5, May 1995, through 0.88, January 1996, are -Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. - -For the purposes of this copyright and license, "Contributing Authors" -is defined as the following set of individuals: - - Andreas Dilger - Dave Martindale - Guy Eric Schalnat - Paul Schmidt - Tim Wegner - -The PNG Reference Library is supplied "AS IS". The Contributing Authors -and Group 42, Inc. disclaim all warranties, expressed or implied, -including, without limitation, the warranties of merchantability and of -fitness for any purpose. The Contributing Authors and Group 42, Inc. -assume no liability for direct, indirect, incidental, special, exemplary, -or consequential damages, which may result from the use of the PNG -Reference Library, even if advised of the possibility of such damage. - -Permission is hereby granted to use, copy, modify, and distribute this -source code, or portions hereof, for any purpose, without fee, subject -to the following restrictions: - -1. The origin of this source code must not be misrepresented. - -2. Altered versions must be plainly marked as such and - must not be misrepresented as being the original source. - -3. This Copyright notice may not be removed or altered from - any source or altered source distribution. - -The Contributing Authors and Group 42, Inc. specifically permit, without -fee, and encourage the use of this source code as a component to -supporting the PNG file format in commercial products. If you use this -source code in a product, acknowledgment is not required but would be -appreciated. - - -A "png_get_copyright" function is available, for convenient use in "about" -boxes and the like: - - printf("%s",png_get_copyright(NULL)); - -Also, the PNG logo (in PNG format, of course) is supplied in the -files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - -Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a -certification mark of the Open Source Initiative. - -Glenn Randers-Pehrson -glennrp at users.sourceforge.net -January 31, 2007 - -.\" end of man page - +.TH LIBPNG 3 "January 31, 2007" +.SH NAME +libpng \- Portable Network Graphics (PNG) Reference Library 1.2.16 +.SH SYNOPSIS +\fB +#include \fP + +\fBpng_uint_32 png_access_version_number \fI(void\fP\fB);\fP + +\fBint png_check_sig (png_bytep \fP\fIsig\fP\fB, int \fInum\fP\fB);\fP + +\fBvoid png_chunk_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP + +\fBvoid png_chunk_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP + +\fBvoid png_convert_from_struct_tm (png_timep \fP\fIptime\fP\fB, struct tm FAR * \fIttime\fP\fB);\fP + +\fBvoid png_convert_from_time_t (png_timep \fP\fIptime\fP\fB, time_t \fIttime\fP\fB);\fP + +\fBpng_charp png_convert_to_rfc1123 (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fIptime\fP\fB);\fP + +\fBpng_infop png_create_info_struct (png_structp \fIpng_ptr\fP\fB);\fP + +\fBpng_structp png_create_read_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP + +\fBpng_structp png_create_read_struct_2(png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP + +\fBpng_structp png_create_write_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP + +\fBpng_structp png_create_write_struct_2(png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP + +\fBint png_debug(int \fP\fIlevel\fP\fB, png_const_charp \fImessage\fP\fB);\fP + +\fBint png_debug1(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fIp1\fP\fB);\fP + +\fBint png_debug2(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fP\fIp1\fP\fB, \fIp2\fP\fB);\fP + +\fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP + +\fBvoid png_destroy_read_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fP\fIinfo_ptr_ptr\fP\fB, png_infopp \fIend_info_ptr_ptr\fP\fB);\fP + +\fBvoid png_destroy_write_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP + +\fBvoid png_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP + +\fBvoid png_free (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP + +\fBvoid png_free_chunk_list (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_free_default(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP + +\fBvoid png_free_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fInum\fP\fB);\fP + +\fBpng_byte png_get_bit_depth (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fI*background\fP\fB);\fP + +\fBpng_byte png_get_channels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fI*white_x\fP\fB, double \fP\fI*white_y\fP\fB, double \fP\fI*red_x\fP\fB, double \fP\fI*red_y\fP\fB, double \fP\fI*green_x\fP\fB, double \fP\fI*green_y\fP\fB, double \fP\fI*blue_x\fP\fB, double \fI*blue_y\fP\fB);\fP + +\fBpng_uint_32 png_get_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*white_x\fP\fB, png_uint_32 \fP\fI*white_y\fP\fB, png_uint_32 \fP\fI*red_x\fP\fB, png_uint_32 \fP\fI*red_y\fP\fB, png_uint_32 \fP\fI*green_x\fP\fB, png_uint_32 \fP\fI*green_y\fP\fB, png_uint_32 \fP\fI*blue_x\fP\fB, png_uint_32 \fI*blue_y\fP\fB);\fP + +\fBpng_byte png_get_color_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_byte png_get_compression_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_byte png_get_copyright (png_structp \fIpng_ptr\fP\fB);\fP + +\fBpng_voidp png_get_error_ptr (png_structp \fIpng_ptr\fP\fB);\fP + +\fBpng_byte png_get_filter_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fI*file_gamma\fP\fB);\fP + +\fBpng_uint_32 png_get_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fI*int_file_gamma\fP\fB);\fP + +\fBpng_byte png_get_header_ver (png_structp \fIpng_ptr\fP\fB);\fP + +\fBpng_byte png_get_header_version (png_structp \fIpng_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fI*hist\fP\fB);\fP + +\fBpng_uint_32 png_get_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charpp \fP\fIname\fP\fB, int \fP\fI*compression_type\fP\fB, png_charpp \fP\fIprofile\fP\fB, png_uint_32 \fI*proflen\fP\fB);\fP + +\fBpng_uint_32 png_get_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*width\fP\fB, png_uint_32 \fP\fI*height\fP\fB, int \fP\fI*bit_depth\fP\fB, int \fP\fI*color_type\fP\fB, int \fP\fI*interlace_type\fP\fB, int \fP\fI*compression_type\fP\fB, int \fI*filter_type\fP\fB);\fP + +\fBpng_uint_32 png_get_image_height (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_image_width (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fB#if !defined(PNG_1_0_X) png_int_32 png_get_int_32 (png_bytep buf); \fI#endif + +\fBpng_byte png_get_interlace_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_voidp png_get_io_ptr (png_structp \fIpng_ptr\fP\fB);\fP + +\fBpng_byte png_get_libpng_ver (png_structp \fIpng_ptr\fP\fB);\fP + +\fBpng_voidp png_get_mem_ptr(png_structp \fIpng_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*offset_x\fP\fB, png_uint_32 \fP\fI*offset_y\fP\fB, int \fI*unit_type\fP\fB);\fP + +\fBpng_uint_32 png_get_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fI*purpose\fP\fB, png_int_32 \fP\fI*X0\fP\fB, png_int_32 \fP\fI*X1\fP\fB, int \fP\fI*type\fP\fB, int \fP\fI*nparams\fP\fB, png_charp \fP\fI*units\fP\fB, png_charpp \fI*params\fP\fB);\fP + +\fBpng_uint_32 png_get_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*res_x\fP\fB, png_uint_32 \fP\fI*res_y\fP\fB, int \fI*unit_type\fP\fB);\fP + +\fBfloat png_get_pixel_aspect_ratio (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_voidp png_get_progressive_ptr (png_structp \fIpng_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fI*palette\fP\fB, int \fI*num_palette\fP\fB);\fP + +\fBpng_byte png_get_rgb_to_gray_status (png_structp png_ptr) png_uint_32 png_get_rowbytes (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_bytepp png_get_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fI*sig_bit\fP\fB);\fP + +\fBpng_bytep png_get_signature (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fI*splt_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fI*intent\fP\fB);\fP + +\fBpng_uint_32 png_get_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fI*text_ptr\fP\fB, int \fI*num_text\fP\fB);\fP + +\fBpng_uint_32 png_get_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fI*mod_time\fP\fB);\fP + +\fBpng_uint_32 png_get_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fI*trans\fP\fB, int \fP\fI*num_trans\fP\fB, png_color_16p \fI*trans_values\fP\fB);\fP + +\fB#if !defined(PNG_1_0_X) png_uint_16 png_get_uint_16 (png_bytep \fIbuf\fP\fB);\fP + +\fBpng_uint_32 png_get_uint_31 (png_bytep \fIbuf\fP\fB);\fP + +\fBpng_uint_32 png_get_uint_32 (png_bytep buf); \fI#endif + +\fBpng_uint_32 png_get_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkpp \fIunknowns\fP\fB);\fP + +\fBpng_voidp png_get_user_chunk_ptr (png_structp \fIpng_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_user_height_max( png_structp \fIpng_ptr\fP\fB);\fP + +\fBpng_voidp png_get_user_transform_ptr (png_structp \fIpng_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_user_width_max (png_structp \fIpng_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_valid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIflag\fP\fB);\fP + +\fBpng_int_32 png_get_x_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_int_32 png_get_x_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_x_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_int_32 png_get_y_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_int_32 png_get_y_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_y_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBpng_uint_32 png_get_compression_buffer_size (png_structp \fIpng_ptr\fP\fB);\fP + +\fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP + +\fBvoid png_init_io (png_structp \fP\fIpng_ptr\fP\fB, FILE \fI*fp\fP\fB);\fP + +\fBDEPRECATED: void png_info_init (png_infop \fIinfo_ptr\fP\fB);\fP + +\fBDEPRECATED: void png_info_init_2 (png_infopp \fP\fIptr_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP + +\fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP + +\fBpng_voidp png_malloc_default(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP + +\fBvoidp png_memcpy (png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_size_t \fIsize\fP\fB);\fP + +\fBpng_voidp png_memcpy_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_uint_32 \fIsize\fP\fB);\fP + +\fBvoidp png_memset (png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_size_t \fIsize\fP\fB);\fP + +\fBpng_voidp png_memset_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_uint_32 \fIsize\fP\fB);\fP + +\fBDEPRECATED: void png_permit_empty_plte (png_structp \fP\fIpng_ptr\fP\fB, int \fIempty_plte_permitted\fP\fB);\fP + +\fBvoid png_process_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_size\fP\fB);\fP + +\fBvoid png_progressive_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIold_row\fP\fB, png_bytep \fInew_row\fP\fB);\fP + +\fBvoid png_read_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_infop \fIend_info_ptr\fP\fB);\fP + +\fBvoid png_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_read_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP + +\fBDEPRECATED: void png_read_init (png_structp \fIpng_ptr\fP\fB);\fP + +\fBDEPRECATED: void png_read_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP + +\fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_read_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP + +\fBvoid png_read_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fIdisplay_row\fP\fB);\fP + +\fBvoid png_read_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_bytepp \fP\fIdisplay_row\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP + +\fBvoid png_read_update_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fB#if !defined(PNG_1_0_X) png_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP + +\fBvoid png_save_uint_16 (png_bytep \fP\fIbuf\fP\fB, unsigned int \fIi\fP\fB);\fP + +\fBvoid png_save_uint_32 (png_bytep \fP\fIbuf\fP\fB, png_uint_32 \fIi\fP\fB);\fP + +\fBvoid png_set_add_alpha (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int flags); \fI#endif + +\fBvoid png_set_background (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIbackground_color\fP\fB, int \fP\fIbackground_gamma_code\fP\fB, int \fP\fIneed_expand\fP\fB, double \fIbackground_gamma\fP\fB);\fP + +\fBvoid png_set_bgr (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fIbackground\fP\fB);\fP + +\fBvoid png_set_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP + +\fBvoid png_set_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP + +\fBvoid png_set_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP + +\fBvoid png_set_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP + +\fBvoid png_set_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP + +\fBvoid png_set_compression_strategy (png_structp \fP\fIpng_ptr\fP\fB, int \fIstrategy\fP\fB);\fP + +\fBvoid png_set_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP + +\fBvoid png_set_crc_action (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcrit_action\fP\fB, int \fIancil_action\fP\fB);\fP + +\fBvoid png_set_dither (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fP\fInum_palette\fP\fB, int \fP\fImaximum_colors\fP\fB, png_uint_16p \fP\fIhistogram\fP\fB, int \fIfull_dither\fP\fB);\fP + +\fBvoid png_set_error_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarning_fn\fP\fB);\fP + +\fBvoid png_set_expand (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_expand_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_filler (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP + +\fBvoid png_set_filter (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImethod\fP\fB, int \fIfilters\fP\fB);\fP + +\fBvoid png_set_filter_heuristics (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIheuristic_method\fP\fB, int \fP\fInum_weights\fP\fB, png_doublep \fP\fIfilter_weights\fP\fB, png_doublep \fIfilter_costs\fP\fB);\fP + +\fBvoid png_set_flush (png_structp \fP\fIpng_ptr\fP\fB, int \fInrows\fP\fB);\fP + +\fBvoid png_set_gamma (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIscreen_gamma\fP\fB, double \fIdefault_file_gamma\fP\fB);\fP + +\fBvoid png_set_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP + +\fBvoid png_set_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIfile_gamma\fP\fB);\fP + +\fBvoid png_set_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_gray_to_rgb (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fIhist\fP\fB);\fP + +\fBvoid png_set_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, png_uint_32 \fIproflen\fP\fB);\fP + +\fBint png_set_interlace_handling (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_invalid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fImask\fP\fB);\fP + +\fBvoid png_set_invert_alpha (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_invert_mono (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIinterlace_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fIfilter_type\fP\fB);\fP + +\fBvoid png_set_keep_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIkeep\fP\fB, png_bytep \fP\fIchunk_list\fP\fB, int \fInum_chunks\fP\fB);\fP + +\fBvoid png_set_mem_fn(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP + +\fBvoid png_set_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIoffset_x\fP\fB, png_uint_32 \fP\fIoffset_y\fP\fB, int \fIunit_type\fP\fB);\fP + +\fBvoid png_set_packing (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_packswap (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_palette_to_rgb(png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP + +\fBvoid png_set_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIres_x\fP\fB, png_uint_32 \fP\fIres_y\fP\fB, int \fIunit_type\fP\fB);\fP + +\fBvoid png_set_progressive_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIprogressive_ptr\fP\fB, png_progressive_info_ptr \fP\fIinfo_fn\fP\fB, png_progressive_row_ptr \fP\fIrow_fn\fP\fB, png_progressive_end_ptr \fIend_fn\fP\fB);\fP + +\fBvoid png_set_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP + +\fBvoid png_set_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIio_ptr\fP\fB, png_rw_ptr \fIread_data_fn\fP\fB);\fP + +\fBvoid png_set_read_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_read_status_ptr \fIread_row_fn\fP\fB);\fP + +\fBvoid png_set_read_user_transform_fn (png_structp \fP\fIpng_ptr\fP\fB, png_user_transform_ptr \fIread_user_transform_fn\fP\fB);\fP + +\fBvoid png_set_rgb_to_gray (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIerror_action\fP\fB, double \fP\fIred\fP\fB, double \fIgreen\fP\fB);\fP + +\fBvoid png_set_rgb_to_gray_fixed (png_structp \fP\fIpng_ptr\fP\fB, int error_action png_fixed_point \fP\fIred\fP\fB, png_fixed_point \fIgreen\fP\fB);\fP + +\fBvoid png_set_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytepp \fIrow_pointers\fP\fB);\fP + +\fBvoid png_set_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fIsig_bit\fP\fB);\fP + +\fBvoid png_set_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP + +\fBvoid png_set_shift (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fItrue_bits\fP\fB);\fP + +\fBvoid png_set_sig_bytes (png_structp \fP\fIpng_ptr\fP\fB, int \fInum_bytes\fP\fB);\fP + +\fBvoid png_set_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fP\fIsplt_ptr\fP\fB, int \fInum_spalettes\fP\fB);\fP + +\fBvoid png_set_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP + +\fBvoid png_set_sRGB_gAMA_and_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP + +\fBvoid png_set_strip_16 (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_strip_alpha (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_swap (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_swap_alpha (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_set_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text\fP\fB);\fP + +\fBvoid png_set_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP + +\fBvoid png_set_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fP\fInum_trans\fP\fB, png_color_16p \fItrans_values\fP\fB);\fP + +\fBvoid png_set_tRNS_to_alpha(png_structp \fIpng_ptr\fP\fB);\fP + +\fBpng_uint_32 png_set_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkp \fP\fIunknowns\fP\fB, int \fP\fInum\fP\fB, int \fIlocation\fP\fB);\fP + +\fBvoid png_set_unknown_chunk_location(png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIchunk\fP\fB, int \fIlocation\fP\fB);\fP + +\fBvoid png_set_read_user_chunk_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_chunk_ptr\fP\fB, png_user_chunk_ptr \fIread_user_chunk_fn\fP\fB);\fP + +\fBvoid png_set_user_limits (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIuser_width_max\fP\fB, png_uint_32 \fIuser_height_max\fP\fB);\fP + +\fBvoid png_set_user_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_transform_ptr\fP\fB, int \fP\fIuser_transform_depth\fP\fB, int \fIuser_transform_channels\fP\fB);\fP + +\fBvoid png_set_write_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIio_ptr\fP\fB, png_rw_ptr \fP\fIwrite_data_fn\fP\fB, png_flush_ptr \fIoutput_flush_fn\fP\fB);\fP + +\fBvoid png_set_write_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_write_status_ptr \fIwrite_row_fn\fP\fB);\fP + +\fBvoid png_set_write_user_transform_fn (png_structp \fP\fIpng_ptr\fP\fB, png_user_transform_ptr \fIwrite_user_transform_fn\fP\fB);\fP + +\fBvoid png_set_compression_buffer_size(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP + +\fBint png_sig_cmp (png_bytep \fP\fIsig\fP\fB, png_size_t \fP\fIstart\fP\fB, png_size_t \fInum_to_check\fP\fB);\fP + +\fBvoid png_start_read_image (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP + +\fBvoid png_write_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIchunk_name\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP + +\fBvoid png_write_chunk_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP + +\fBvoid png_write_chunk_end (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_write_chunk_start (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIchunk_name\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_write_destroy (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_write_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_write_flush (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_write_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP + +\fBDEPRECATED: void png_write_init (png_structp \fIpng_ptr\fP\fB);\fP + +\fBDEPRECATED: void png_write_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP + +\fBvoid png_write_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_write_info_before_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_write_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP + +\fBvoid png_write_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fBvoid png_write_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP + +\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP + +\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP + +.SH DESCRIPTION +The +.I libpng +library supports encoding, decoding, and various manipulations of +the Portable Network Graphics (PNG) format image files. It uses the +.IR zlib(3) +compression library. +Following is a copy of the libpng.txt file that accompanies libpng. +.SH LIBPNG.TXT +libpng.txt - A description on how to use and modify libpng + + libpng version 1.2.16 - January 31, 2007 + Updated and distributed by Glenn Randers-Pehrson + + Copyright (c) 1998-2005 Glenn Randers-Pehrson + For conditions of distribution and use, see copyright + notice in png.h. + + based on: + + libpng 1.0 beta 6 version 0.96 May 28, 1997 + Updated and distributed by Andreas Dilger + Copyright (c) 1996, 1997 Andreas Dilger + + libpng 1.0 beta 2 - version 0.88 January 26, 1996 + For conditions of distribution and use, see copyright + notice in png.h. Copyright (c) 1995, 1996 Guy Eric + Schalnat, Group 42, Inc. + + Updated/rewritten per request in the libpng FAQ + Copyright (c) 1995, 1996 Frank J. T. Wojcik + December 18, 1995 & January 20, 1996 + +.SH I. Introduction + +This file describes how to use and modify the PNG reference library +(known as libpng) for your own use. There are five sections to this +file: introduction, structures, reading, writing, and modification and +configuration notes for various special platforms. In addition to this +file, example.c is a good starting point for using the library, as +it is heavily commented and should include everything most people +will need. We assume that libpng is already installed; see the +INSTALL file for instructions on how to install libpng. + +Libpng was written as a companion to the PNG specification, as a way +of reducing the amount of time and effort it takes to support the PNG +file format in application programs. + +The PNG specification (second edition), November 2003, is available as +a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at + + +The PNG-1.0 specification is available +as RFC 2083 and as a +W3C Recommendation . Some +additional chunks are described in the special-purpose public chunks +documents at . + +Other information +about PNG, and the latest version of libpng, can be found at the PNG home +page, . + +Most users will not have to modify the library significantly; advanced +users may want to modify it more. All attempts were made to make it as +complete as possible, while keeping the code easy to understand. +Currently, this library only supports C. Support for other languages +is being considered. + +Libpng has been designed to handle multiple sessions at one time, +to be easily modifiable, to be portable to the vast majority of +machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy +to use. The ultimate goal of libpng is to promote the acceptance of +the PNG file format in whatever way possible. While there is still +work to be done (see the TODO file), libpng should cover the +majority of the needs of its users. + +Libpng uses zlib for its compression and decompression of PNG files. +Further information about zlib, and the latest version of zlib, can +be found at the zlib home page, . +The zlib compression utility is a general purpose utility that is +useful for more than PNG files, and can be used without libpng. +See the documentation delivered with zlib for more details. +You can usually find the source files for the zlib utility wherever you +find the libpng source files. + +Libpng is thread safe, provided the threads are using different +instances of the structures. Each thread should have its own +png_struct and png_info instances, and thus its own image. +Libpng does not protect itself against two threads using the +same instance of a structure. Note: thread safety may be defeated +by use of some of the MMX assembler code in pnggccrd.c, which is only +compiled when the user defines PNG_THREAD_UNSAFE_OK. + +.SH II. Structures + +There are two main structures that are important to libpng, png_struct +and png_info. The first, png_struct, is an internal structure that +will not, for the most part, be used by a user except as the first +variable passed to every libpng function call. + +The png_info structure is designed to provide information about the +PNG file. At one time, the fields of png_info were intended to be +directly accessible to the user. However, this tended to cause problems +with applications using dynamically loaded libraries, and as a result +a set of interface functions for png_info (the png_get_*() and png_set_*() +functions) was developed. The fields of png_info are still available for +older applications, but it is suggested that applications use the new +interfaces if at all possible. + +Applications that do make direct access to the members of png_struct (except +for png_ptr->jmpbuf) must be recompiled whenever the library is updated, +and applications that make direct access to the members of png_info must +be recompiled if they were compiled or loaded with libpng version 1.0.6, +in which the members were in a different order. In version 1.0.7, the +members of the png_info structure reverted to the old order, as they were +in versions 0.97c through 1.0.5. Starting with version 2.0.0, both +structures are going to be hidden, and the contents of the structures will +only be accessible through the png_get/png_set functions. + +The png.h header file is an invaluable reference for programming with libpng. +And while I'm on the topic, make sure you include the libpng header file: + +#include + +.SH III. Reading + +We'll now walk you through the possible functions to call when reading +in a PNG file sequentially, briefly explaining the syntax and purpose +of each one. See example.c and png.h for more detail. While +progressive reading is covered in the next section, you will still +need some of the functions discussed in this section to read a PNG +file. + +.SS Setup + +You will want to do the I/O initialization(*) before you get into libpng, +so if it doesn't work, you don't have much to undo. Of course, you +will also want to insure that you are, in fact, dealing with a PNG +file. Libpng provides a simple check to see if a file is a PNG file. +To use it, pass in the first 1 to 8 bytes of the file to the function +png_sig_cmp(), and it will return 0 if the bytes match the corresponding +bytes of the PNG signature, or nonzero otherwise. Of course, the more bytes +you pass in, the greater the accuracy of the prediction. + +If you are intending to keep the file pointer open for use in libpng, +you must ensure you don't read more than 8 bytes from the beginning +of the file, and you also have to make a call to png_set_sig_bytes_read() +with the number of bytes you read from the beginning. Libpng will +then only check the bytes (if any) that your program didn't read. + +(*): If you are not using the standard I/O functions, you will need +to replace them with custom functions. See the discussion under +Customizing libpng. + + + FILE *fp = fopen(file_name, "rb"); + if (!fp) + { + return (ERROR); + } + fread(header, 1, number, fp); + is_png = !png_sig_cmp(header, 0, number); + if (!is_png) + { + return (NOT_PNG); + } + + +Next, png_struct and png_info need to be allocated and initialized. In +order to ensure that the size of these structures is correct even with a +dynamically linked libpng, there are functions to initialize and +allocate the structures. We also pass the library version, optional +pointers to error handling functions, and a pointer to a data struct for +use by the error functions, if necessary (the pointer and functions can +be NULL if the default error handlers are to be used). See the section +on Changes to Libpng below regarding the old initialization functions. +The structure allocation functions quietly return NULL if they fail to +create the structure, so your application should check for that. + + png_structp png_ptr = png_create_read_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn); + if (!png_ptr) + return (ERROR); + + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + png_destroy_read_struct(&png_ptr, + (png_infopp)NULL, (png_infopp)NULL); + return (ERROR); + } + + png_infop end_info = png_create_info_struct(png_ptr); + if (!end_info) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + (png_infopp)NULL); + return (ERROR); + } + +If you want to use your own memory allocation routines, +define PNG_USER_MEM_SUPPORTED and use +png_create_read_struct_2() instead of png_create_read_struct(): + + png_structp png_ptr = png_create_read_struct_2 + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn, (png_voidp) + user_mem_ptr, user_malloc_fn, user_free_fn); + +The error handling routines passed to png_create_read_struct() +and the memory alloc/free routines passed to png_create_struct_2() +are only necessary if you are not using the libpng supplied error +handling and memory alloc/free functions. + +When libpng encounters an error, it expects to longjmp back +to your routine. Therefore, you will need to call setjmp and pass +your png_jmpbuf(png_ptr). If you read the file from different +routines, you will need to update the jmpbuf field every time you enter +a new routine that will call a png_*() function. + +See your documentation of setjmp/longjmp for your compiler for more +information on setjmp/longjmp. See the discussion on libpng error +handling in the Customizing Libpng section below for more information +on the libpng error handling. If an error occurs, and libpng longjmp's +back to your setjmp, you will want to call png_destroy_read_struct() to +free any memory. + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + &end_info); + fclose(fp); + return (ERROR); + } + +If you would rather avoid the complexity of setjmp/longjmp issues, +you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case +errors will result in a call to PNG_ABORT() which defaults to abort(). + +Now you need to set up the input code. The default for libpng is to +use the C function fread(). If you use this, you will need to pass a +valid FILE * in the function png_init_io(). Be sure that the file is +opened in binary mode. If you wish to handle reading data in another +way, you need not call the png_init_io() function, but you must then +implement the libpng I/O methods discussed in the Customizing Libpng +section below. + + png_init_io(png_ptr, fp); + +If you had previously opened the file and read any of the signature from +the beginning in order to see if this was a PNG file, you need to let +libpng know that there are some bytes missing from the start of the file. + + png_set_sig_bytes(png_ptr, number); + +.SS Setting up callback code + +You can set up a callback function to handle any unknown chunks in the +input stream. You must supply the function + + read_chunk_callback(png_ptr ptr, + png_unknown_chunkp chunk); + { + /* The unknown chunk structure contains your + chunk data: */ + png_byte name[5]; + png_byte *data; + png_size_t size; + /* Note that libpng has already taken care of + the CRC handling */ + + /* put your code here. Return one of the + following: */ + + return (-n); /* chunk had an error */ + return (0); /* did not recognize */ + return (n); /* success */ + } + +(You can give your function another name that you like instead of +"read_chunk_callback") + +To inform libpng about your function, use + + png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, + read_chunk_callback); + +This names not only the callback function, but also a user pointer that +you can retrieve with + + png_get_user_chunk_ptr(png_ptr); + +At this point, you can set up a callback function that will be +called after each row has been read, which you can use to control +a progress meter or the like. It's demonstrated in pngtest.c. +You must supply a function + + void read_row_callback(png_ptr ptr, png_uint_32 row, + int pass); + { + /* put your code here */ + } + +(You can give it another name that you like instead of "read_row_callback") + +To inform libpng about your function, use + + png_set_read_status_fn(png_ptr, read_row_callback); + +.SS Width and height limits + +The PNG specification allows the width and height of an image to be as +large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. +Since very few applications really need to process such large images, +we have imposed an arbitrary 1-million limit on rows and columns. +Larger images will be rejected immediately with a png_error() call. If +you wish to override this limit, you can use + + png_set_user_limits(png_ptr, width_max, height_max); + +to set your own limits, or use width_max = height_max = 0x7fffffffL +to allow all valid dimensions (libpng may reject some very large images +anyway because of potential buffer overflow conditions). + +You should put this statement after you create the PNG structure and +before calling png_read_info(), png_read_png(), or png_process_data(). +If you need to retrieve the limits that are being applied, use + + width_max = png_get_user_width_max(png_ptr); + height_max = png_get_user_height_max(png_ptr); + +.SS Unknown-chunk handling + +Now you get to set the way the library processes unknown chunks in the +input PNG stream. Both known and unknown chunks will be read. Normal +behavior is that known chunks will be parsed into information in +various info_ptr members; unknown chunks will be discarded. To change +this, you can call: + + png_set_keep_unknown_chunks(png_ptr, keep, + chunk_list, num_chunks); + keep - 0: do not handle as unknown + 1: do not keep + 2: keep only if safe-to-copy + 3: keep even if unsafe-to-copy + You can use these definitions: + PNG_HANDLE_CHUNK_AS_DEFAULT 0 + PNG_HANDLE_CHUNK_NEVER 1 + PNG_HANDLE_CHUNK_IF_SAFE 2 + PNG_HANDLE_CHUNK_ALWAYS 3 + chunk_list - list of chunks affected (a byte string, + five bytes per chunk, NULL or '\0' if + num_chunks is 0) + num_chunks - number of chunks affected; if 0, all + unknown chunks are affected. If nonzero, + only the chunks in the list are affected + +Unknown chunks declared in this way will be saved as raw data onto a +list of png_unknown_chunk structures. If a chunk that is normally +known to libpng is named in the list, it will be handled as unknown, +according to the "keep" directive. If a chunk is named in successive +instances of png_set_keep_unknown_chunks(), the final instance will +take precedence. The IHDR and IEND chunks should not be named in +chunk_list; if they are, libpng will process them normally anyway. + +.SS The high-level read interface + +At this point there are two ways to proceed; through the high-level +read interface, or through a sequence of low-level read operations. +You can use the high-level interface if (a) you are willing to read +the entire image into memory, and (b) the input transformations +you want to do are limited to the following set: + + PNG_TRANSFORM_IDENTITY No transformation + PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to + 8 bits + PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel + PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit + samples to bytes + PNG_TRANSFORM_PACKSWAP Change order of packed + pixels to LSB first + PNG_TRANSFORM_EXPAND Perform set_expand() + PNG_TRANSFORM_INVERT_MONO Invert monochrome images + PNG_TRANSFORM_SHIFT Normalize pixels to the + sBIT depth + PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA + to BGRA + PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA + to AG + PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity + to transparency + PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples + +(This excludes setting a background color, doing gamma transformation, +dithering, and setting filler.) If this is the case, simply do this: + + png_read_png(png_ptr, info_ptr, png_transforms, NULL) + +where png_transforms is an integer containing the bitwise OR of +some set of transformation flags. This call is equivalent to png_read_info(), +followed the set of transformations indicated by the transform mask, +then png_read_image(), and finally png_read_end(). + +(The final parameter of this call is not yet used. Someday it might point +to transformation parameters required by some future input transform.) + +You must use png_transforms and not call any png_set_transform() functions +when you use png_read_png(). + +After you have called png_read_png(), you can retrieve the image data +with + + row_pointers = png_get_rows(png_ptr, info_ptr); + +where row_pointers is an array of pointers to the pixel data for each row: + + png_bytep row_pointers[height]; + +If you know your image size and pixel size ahead of time, you can allocate +row_pointers prior to calling png_read_png() with + + if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) + png_error (png_ptr, + "Image is too tall to process in memory"); + if (width > PNG_UINT_32_MAX/pixel_size) + png_error (png_ptr, + "Image is too wide to process in memory"); + row_pointers = png_malloc(png_ptr, + height*png_sizeof(png_bytep)); + for (int i=0; i) and +png_get_(png_ptr, info_ptr, ...) functions return non-zero if the +data has been read, or zero if it is missing. The parameters to the +png_get_ are set directly if they are simple data types, or a pointer +into the info_ptr is returned for any complex types. + + png_get_PLTE(png_ptr, info_ptr, &palette, + &num_palette); + palette - the palette for the file + (array of png_color) + num_palette - number of entries in the palette + + png_get_gAMA(png_ptr, info_ptr, &gamma); + gamma - the gamma the file is written + at (PNG_INFO_gAMA) + + png_get_sRGB(png_ptr, info_ptr, &srgb_intent); + srgb_intent - the rendering intent (PNG_INFO_sRGB) + The presence of the sRGB chunk + means that the pixel data is in the + sRGB color space. This chunk also + implies specific values of gAMA and + cHRM. + + png_get_iCCP(png_ptr, info_ptr, &name, + &compression_type, &profile, &proflen); + name - The profile name. + compression - The compression type; always + PNG_COMPRESSION_TYPE_BASE for PNG 1.0. + You may give NULL to this argument to + ignore it. + profile - International Color Consortium color + profile data. May contain NULs. + proflen - length of profile data in bytes. + + png_get_sBIT(png_ptr, info_ptr, &sig_bit); + sig_bit - the number of significant bits for + (PNG_INFO_sBIT) each of the gray, + red, green, and blue channels, + whichever are appropriate for the + given color type (png_color_16) + + png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, + &trans_values); + trans - array of transparent entries for + palette (PNG_INFO_tRNS) + trans_values - graylevel or color sample values of + the single transparent color for + non-paletted images (PNG_INFO_tRNS) + num_trans - number of transparent entries + (PNG_INFO_tRNS) + + png_get_hIST(png_ptr, info_ptr, &hist); + (PNG_INFO_hIST) + hist - histogram of palette (array of + png_uint_16) + + png_get_tIME(png_ptr, info_ptr, &mod_time); + mod_time - time image was last modified + (PNG_VALID_tIME) + + png_get_bKGD(png_ptr, info_ptr, &background); + background - background color (PNG_VALID_bKGD) + valid 16-bit red, green and blue + values, regardless of color_type + + num_comments = png_get_text(png_ptr, info_ptr, + &text_ptr, &num_text); + num_comments - number of comments + text_ptr - array of png_text holding image + comments + text_ptr[i].compression - type of compression used + on "text" PNG_TEXT_COMPRESSION_NONE + PNG_TEXT_COMPRESSION_zTXt + PNG_ITXT_COMPRESSION_NONE + PNG_ITXT_COMPRESSION_zTXt + text_ptr[i].key - keyword for comment. Must contain + 1-79 characters. + text_ptr[i].text - text comments for current + keyword. Can be empty. + text_ptr[i].text_length - length of text string, + after decompression, 0 for iTXt + text_ptr[i].itxt_length - length of itxt string, + after decompression, 0 for tEXt/zTXt + text_ptr[i].lang - language of comment (empty + string for unknown). + text_ptr[i].lang_key - keyword in UTF-8 + (empty string for unknown). + num_text - number of comments (same as + num_comments; you can put NULL here + to avoid the duplication) + Note while png_set_text() will accept text, language, + and translated keywords that can be NULL pointers, the + structure returned by png_get_text will always contain + regular zero-terminated C strings. They might be + empty strings but they will never be NULL pointers. + + num_spalettes = png_get_sPLT(png_ptr, info_ptr, + &palette_ptr); + palette_ptr - array of palette structures holding + contents of one or more sPLT chunks + read. + num_spalettes - number of sPLT chunks read. + + png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, + &unit_type); + offset_x - positive offset from the left edge + of the screen + offset_y - positive offset from the top edge + of the screen + unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER + + png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, + &unit_type); + res_x - pixels/unit physical resolution in + x direction + res_y - pixels/unit physical resolution in + x direction + unit_type - PNG_RESOLUTION_UNKNOWN, + PNG_RESOLUTION_METER + + png_get_sCAL(png_ptr, info_ptr, &unit, &width, + &height) + unit - physical scale units (an integer) + width - width of a pixel in physical scale units + height - height of a pixel in physical scale units + (width and height are doubles) + + png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, + &height) + unit - physical scale units (an integer) + width - width of a pixel in physical scale units + height - height of a pixel in physical scale units + (width and height are strings like "2.54") + + num_unknown_chunks = png_get_unknown_chunks(png_ptr, + info_ptr, &unknowns) + unknowns - array of png_unknown_chunk + structures holding unknown chunks + unknowns[i].name - name of unknown chunk + unknowns[i].data - data of unknown chunk + unknowns[i].size - size of unknown chunk's data + unknowns[i].location - position of chunk in file + + The value of "i" corresponds to the order in which the + chunks were read from the PNG file or inserted with the + png_set_unknown_chunks() function. + +The data from the pHYs chunk can be retrieved in several convenient +forms: + + res_x = png_get_x_pixels_per_meter(png_ptr, + info_ptr) + res_y = png_get_y_pixels_per_meter(png_ptr, + info_ptr) + res_x_and_y = png_get_pixels_per_meter(png_ptr, + info_ptr) + res_x = png_get_x_pixels_per_inch(png_ptr, + info_ptr) + res_y = png_get_y_pixels_per_inch(png_ptr, + info_ptr) + res_x_and_y = png_get_pixels_per_inch(png_ptr, + info_ptr) + aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, + info_ptr) + + (Each of these returns 0 [signifying "unknown"] if + the data is not present or if res_x is 0; + res_x_and_y is 0 if res_x != res_y) + +The data from the oFFs chunk can be retrieved in several convenient +forms: + + x_offset = png_get_x_offset_microns(png_ptr, info_ptr); + y_offset = png_get_y_offset_microns(png_ptr, info_ptr); + x_offset = png_get_x_offset_inches(png_ptr, info_ptr); + y_offset = png_get_y_offset_inches(png_ptr, info_ptr); + + (Each of these returns 0 [signifying "unknown" if both + x and y are 0] if the data is not present or if the + chunk is present but the unit is the pixel) + +For more information, see the png_info definition in png.h and the +PNG specification for chunk contents. Be careful with trusting +rowbytes, as some of the transformations could increase the space +needed to hold a row (expand, filler, gray_to_rgb, etc.). +See png_read_update_info(), below. + +A quick word about text_ptr and num_text. PNG stores comments in +keyword/text pairs, one pair per chunk, with no limit on the number +of text chunks, and a 2^31 byte limit on their size. While there are +suggested keywords, there is no requirement to restrict the use to these +strings. It is strongly suggested that keywords and text be sensible +to humans (that's the point), so don't use abbreviations. Non-printing +symbols are not allowed. See the PNG specification for more details. +There is also no requirement to have text after the keyword. + +Keywords should be limited to 79 Latin-1 characters without leading or +trailing spaces, but non-consecutive spaces are allowed within the +keyword. It is possible to have the same keyword any number of times. +The text_ptr is an array of png_text structures, each holding a +pointer to a language string, a pointer to a keyword and a pointer to +a text string. The text string, language code, and translated +keyword may be empty or NULL pointers. The keyword/text +pairs are put into the array in the order that they are received. +However, some or all of the text chunks may be after the image, so, to +make sure you have read all the text chunks, don't mess with these +until after you read the stuff after the image. This will be +mentioned again below in the discussion that goes with png_read_end(). + +.SS Input transformations + +After you've read the header information, you can set up the library +to handle any special transformations of the image data. The various +ways to transform the data will be described in the order that they +should occur. This is important, as some of these change the color +type and/or bit depth of the data, and some others only work on +certain color types and bit depths. Even though each transformation +checks to see if it has data that it can do something with, you should +make sure to only enable a transformation if it will be valid for the +data. For example, don't swap red and blue on grayscale data. + +The colors used for the background and transparency values should be +supplied in the same format/depth as the current image data. They +are stored in the same format/depth as the image data in a bKGD or tRNS +chunk, so this is what libpng expects for this data. The colors are +transformed to keep in sync with the image data when an application +calls the png_read_update_info() routine (see below). + +Data will be decoded into the supplied row buffers packed into bytes +unless the library has been told to transform it into another format. +For example, 4 bit/pixel paletted or grayscale data will be returned +2 pixels/byte with the leftmost pixel in the high-order bits of the +byte, unless png_set_packing() is called. 8-bit RGB data will be stored +in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha() +is called to insert filler bytes, either before or after each RGB triplet. +16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant +byte of the color value first, unless png_set_strip_16() is called to +transform it to regular RGB RGB triplets, or png_set_filler() or +png_set_add alpha() is called to insert filler bytes, either before or +after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can +be modified with +png_set_filler(), png_set_add_alpha(), or png_set_strip_16(). + +The following code transforms grayscale images of less than 8 to 8 bits, +changes paletted images to RGB, and adds a full alpha channel if there is +transparency information in a tRNS chunk. This is most useful on +grayscale images with bit depths of 2 or 4 or if there is a multiple-image +viewing application that wishes to treat all images in the same way. + + if (color_type == PNG_COLOR_TYPE_PALETTE) + png_set_palette_to_rgb(png_ptr); + + if (color_type == PNG_COLOR_TYPE_GRAY && + bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr); + + if (png_get_valid(png_ptr, info_ptr, + PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); + +These three functions are actually aliases for png_set_expand(), added +in libpng version 1.0.4, with the function names expanded to improve code +readability. In some future version they may actually do different +things. + +As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was +added. It expands the sample depth without changing tRNS to alpha. +At the same time, png_set_gray_1_2_4_to_8() was deprecated, and it +will be removed from a future version. + +PNG can have files with 16 bits per channel. If you only can handle +8 bits per channel, this will strip the pixels down to 8 bit. + + if (bit_depth == 16) + png_set_strip_16(png_ptr); + +If, for some reason, you don't need the alpha channel on an image, +and you want to remove it rather than combining it with the background +(but the image author certainly had in mind that you *would* combine +it with the background, so that's what you should probably do): + + if (color_type & PNG_COLOR_MASK_ALPHA) + png_set_strip_alpha(png_ptr); + +In PNG files, the alpha channel in an image +is the level of opacity. If you need the alpha channel in an image to +be the level of transparency instead of opacity, you can invert the +alpha channel (or the tRNS chunk data) after it's read, so that 0 is +fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit +images) is fully transparent, with + + png_set_invert_alpha(png_ptr); + +PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as +they can, resulting in, for example, 8 pixels per byte for 1 bit +files. This code expands to 1 pixel per byte without changing the +values of the pixels: + + if (bit_depth < 8) + png_set_packing(png_ptr); + +PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels +stored in a PNG image have been "scaled" or "shifted" up to the next +higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to +8 bits/sample in the range [0, 255]). However, it is also possible to +convert the PNG pixel data back to the original bit depth of the image. +This call reduces the pixels back down to the original bit depth: + + png_color_8p sig_bit; + + if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) + png_set_shift(png_ptr, sig_bit); + +PNG files store 3-color pixels in red, green, blue order. This code +changes the storage of the pixels to blue, green, red: + + if (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_bgr(png_ptr); + +PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them +into 4 or 8 bytes for windowing systems that need them in this format: + + if (color_type == PNG_COLOR_TYPE_RGB) + png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE); + +where "filler" is the 8 or 16-bit number to fill with, and the location is +either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether +you want the filler before the RGB or after. This transformation +does not affect images that already have full alpha channels. To add an +opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which +will generate RGBA pixels. + +Note that png_set_filler() does not change the color type. If you want +to do that, you can add a true alpha channel with + + if (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_GRAY) + png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER); + +where "filler" contains the alpha value to assign to each pixel. +This function was added in libpng-1.2.7. + +If you are reading an image with an alpha channel, and you need the +data as ARGB instead of the normal PNG format RGBA: + + if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_swap_alpha(png_ptr); + +For some uses, you may want a grayscale image to be represented as +RGB. This code will do that conversion: + + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png_ptr); + +Conversely, you can convert an RGB or RGBA image to grayscale or grayscale +with alpha. + + if (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_rgb_to_gray_fixed(png_ptr, error_action, + int red_weight, int green_weight); + + error_action = 1: silently do the conversion + error_action = 2: issue a warning if the original + image has any pixel where + red != green or red != blue + error_action = 3: issue an error and abort the + conversion if the original + image has any pixel where + red != green or red != blue + + red_weight: weight of red component times 100000 + green_weight: weight of green component times 100000 + If either weight is negative, default + weights (21268, 71514) are used. + +If you have set error_action = 1 or 2, you can +later check whether the image really was gray, after processing +the image rows, with the png_get_rgb_to_gray_status(png_ptr) function. +It will return a png_byte that is zero if the image was gray or +1 if there were any non-gray pixels. bKGD and sBIT data +will be silently converted to grayscale, using the green channel +data, regardless of the error_action setting. + +With red_weight+green_weight<=100000, +the normalized graylevel is computed: + + int rw = red_weight * 65536; + int gw = green_weight * 65536; + int bw = 65536 - (rw + gw); + gray = (rw*red + gw*green + bw*blue)/65536; + +The default values approximate those recommended in the Charles +Poynton's Color FAQ, +Copyright (c) 1998-01-04 Charles Poynton + + Y = 0.212671 * R + 0.715160 * G + 0.072169 * B + +Libpng approximates this with + + Y = 0.21268 * R + 0.7151 * G + 0.07217 * B + +which can be expressed with integers as + + Y = (6969 * R + 23434 * G + 2365 * B)/32768 + +The calculation is done in a linear colorspace, if the image gamma +is known. + +If you have a grayscale and you are using png_set_expand_depth(), +png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to +a higher bit-depth, you must either supply the background color as a gray +value at the original file bit-depth (need_expand = 1) or else supply the +background color as an RGB triplet at the final, expanded bit depth +(need_expand = 0). Similarly, if you are reading a paletted image, you +must either supply the background color as a palette index (need_expand = 1) +or as an RGB triplet that may or may not be in the palette (need_expand = 0). + + png_color_16 my_background; + png_color_16p image_background; + + if (png_get_bKGD(png_ptr, info_ptr, &image_background)) + png_set_background(png_ptr, image_background, + PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); + else + png_set_background(png_ptr, &my_background, + PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); + +The png_set_background() function tells libpng to composite images +with alpha or simple transparency against the supplied background +color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid), +you may use this color, or supply another color more suitable for +the current display (e.g., the background color from a web page). You +need to tell libpng whether the color is in the gamma space of the +display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file +(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one +that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't +know why anyone would use this, but it's here). + +To properly display PNG images on any kind of system, the application needs +to know what the display gamma is. Ideally, the user will know this, and +the application will allow them to set it. One method of allowing the user +to set the display gamma separately for each system is to check for a +SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be +correctly set. + +Note that display_gamma is the overall gamma correction required to produce +pleasing results, which depends on the lighting conditions in the surrounding +environment. In a dim or brightly lit room, no compensation other than +the physical gamma exponent of the monitor is needed, while in a dark room +a slightly smaller exponent is better. + + double gamma, screen_gamma; + + if (/* We have a user-defined screen + gamma value */) + { + screen_gamma = user_defined_screen_gamma; + } + /* One way that applications can share the same + screen gamma value */ + else if ((gamma_str = getenv("SCREEN_GAMMA")) + != NULL) + { + screen_gamma = (double)atof(gamma_str); + } + /* If we don't have another value */ + else + { + screen_gamma = 2.2; /* A good guess for a + PC monitor in a bright office or a dim room */ + screen_gamma = 2.0; /* A good guess for a + PC monitor in a dark room */ + screen_gamma = 1.7 or 1.0; /* A good + guess for Mac systems */ + } + +The png_set_gamma() function handles gamma transformations of the data. +Pass both the file gamma and the current screen_gamma. If the file does +not have a gamma value, you can pass one anyway if you have an idea what +it is (usually 0.45455 is a good guess for GIF images on PCs). Note +that file gammas are inverted from screen gammas. See the discussions +on gamma in the PNG specification for an excellent description of what +gamma is, and why all applications should support it. It is strongly +recommended that PNG viewers support gamma correction. + + if (png_get_gAMA(png_ptr, info_ptr, &gamma)) + png_set_gamma(png_ptr, screen_gamma, gamma); + else + png_set_gamma(png_ptr, screen_gamma, 0.45455); + +If you need to reduce an RGB file to a paletted file, or if a paletted +file has more entries then will fit on your screen, png_set_dither() +will do that. Note that this is a simple match dither that merely +finds the closest color available. This should work fairly well with +optimized palettes, and fairly badly with linear color cubes. If you +pass a palette that is larger then maximum_colors, the file will +reduce the number of colors in the palette so it will fit into +maximum_colors. If there is a histogram, it will use it to make +more intelligent choices when reducing the palette. If there is no +histogram, it may not do as good a job. + + if (color_type & PNG_COLOR_MASK_COLOR) + { + if (png_get_valid(png_ptr, info_ptr, + PNG_INFO_PLTE)) + { + png_uint_16p histogram = NULL; + + png_get_hIST(png_ptr, info_ptr, + &histogram); + png_set_dither(png_ptr, palette, num_palette, + max_screen_colors, histogram, 1); + } + else + { + png_color std_color_cube[MAX_SCREEN_COLORS] = + { ... colors ... }; + + png_set_dither(png_ptr, std_color_cube, + MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, + NULL,0); + } + } + +PNG files describe monochrome as black being zero and white being one. +The following code will reverse this (make black be one and white be +zero): + + if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY) + png_set_invert_mono(png_ptr); + +This function can also be used to invert grayscale and gray-alpha images: + + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_invert_mono(png_ptr); + +PNG files store 16 bit pixels in network byte order (big-endian, +ie. most significant bits first). This code changes the storage to the +other way (little-endian, i.e. least significant bits first, the +way PCs store them): + + if (bit_depth == 16) + png_set_swap(png_ptr); + +If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you +need to change the order the pixels are packed into bytes, you can use: + + if (bit_depth < 8) + png_set_packswap(png_ptr); + +Finally, you can write your own transformation function if none of +the existing ones meets your needs. This is done by setting a callback +with + + png_set_read_user_transform_fn(png_ptr, + read_transform_fn); + +You must supply the function + + void read_transform_fn(png_ptr ptr, row_info_ptr + row_info, png_bytep data) + +See pngtest.c for a working example. Your function will be called +after all of the other transformations have been processed. + +You can also set up a pointer to a user structure for use by your +callback function, and you can inform libpng that your transform +function will change the number of channels or bit depth with the +function + + png_set_user_transform_info(png_ptr, user_ptr, + user_depth, user_channels); + +The user's application, not libpng, is responsible for allocating and +freeing any memory required for the user structure. + +You can retrieve the pointer via the function +png_get_user_transform_ptr(). For example: + + voidp read_user_transform_ptr = + png_get_user_transform_ptr(png_ptr); + +The last thing to handle is interlacing; this is covered in detail below, +but you must call the function here if you want libpng to handle expansion +of the interlaced image. + + number_of_passes = png_set_interlace_handling(png_ptr); + +After setting the transformations, libpng can update your png_info +structure to reflect any transformations you've requested with this +call. This is most useful to update the info structure's rowbytes +field so you can use it to allocate your image memory. This function +will also update your palette with the correct screen_gamma and +background if these have been given with the calls above. + + png_read_update_info(png_ptr, info_ptr); + +After you call png_read_update_info(), you can allocate any +memory you need to hold the image. The row data is simply +raw byte data for all forms of images. As the actual allocation +varies among applications, no example will be given. If you +are allocating one large chunk, you will need to build an +array of pointers to each row, as it will be needed for some +of the functions below. + +.SS Reading image data + +After you've allocated memory, you can read the image data. +The simplest way to do this is in one function call. If you are +allocating enough memory to hold the whole image, you can just +call png_read_image() and libpng will read in all the image data +and put it in the memory area supplied. You will need to pass in +an array of pointers to each row. + +This function automatically handles interlacing, so you don't need +to call png_set_interlace_handling() or call this function multiple +times, or any of that other stuff necessary with png_read_rows(). + + png_read_image(png_ptr, row_pointers); + +where row_pointers is: + + png_bytep row_pointers[height]; + +You can point to void or char or whatever you use for pixels. + +If you don't want to read in the whole image at once, you can +use png_read_rows() instead. If there is no interlacing (check +interlace_type == PNG_INTERLACE_NONE), this is simple: + + png_read_rows(png_ptr, row_pointers, NULL, + number_of_rows); + +where row_pointers is the same as in the png_read_image() call. + +If you are doing this just one row at a time, you can do this with +a single row_pointer instead of an array of row_pointers: + + png_bytep row_pointer = row; + png_read_row(png_ptr, row_pointer, NULL); + +If the file is interlaced (interlace_type != 0 in the IHDR chunk), things +get somewhat harder. The only current (PNG Specification version 1.2) +interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7) +is a somewhat complicated 2D interlace scheme, known as Adam7, that +breaks down an image into seven smaller images of varying size, based +on an 8x8 grid. + +libpng can fill out those images or it can give them to you "as is". +If you want them filled out, there are two ways to do that. The one +mentioned in the PNG specification is to expand each pixel to cover +those pixels that have not been read yet (the "rectangle" method). +This results in a blocky image for the first pass, which gradually +smooths out as more pixels are read. The other method is the "sparkle" +method, where pixels are drawn only in their final locations, with the +rest of the image remaining whatever colors they were initialized to +before the start of the read. The first method usually looks better, +but tends to be slower, as there are more pixels to put in the rows. + +If you don't want libpng to handle the interlacing details, just call +png_read_rows() seven times to read in all seven images. Each of the +images is a valid image by itself, or they can all be combined on an +8x8 grid to form a single image (although if you intend to combine them +you would be far better off using the libpng interlace handling). + +The first pass will return an image 1/8 as wide as the entire image +(every 8th column starting in column 0) and 1/8 as high as the original +(every 8th row starting in row 0), the second will be 1/8 as wide +(starting in column 4) and 1/8 as high (also starting in row 0). The +third pass will be 1/4 as wide (every 4th pixel starting in column 0) and +1/8 as high (every 8th row starting in row 4), and the fourth pass will +be 1/4 as wide and 1/4 as high (every 4th column starting in column 2, +and every 4th row starting in row 0). The fifth pass will return an +image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2), +while the sixth pass will be 1/2 as wide and 1/2 as high as the original +(starting in column 1 and row 0). The seventh and final pass will be as +wide as the original, and 1/2 as high, containing all of the odd +numbered scanlines. Phew! + +If you want libpng to expand the images, call this before calling +png_start_read_image() or png_read_update_info(): + + if (interlace_type == PNG_INTERLACE_ADAM7) + number_of_passes + = png_set_interlace_handling(png_ptr); + +This will return the number of passes needed. Currently, this +is seven, but may change if another interlace type is added. +This function can be called even if the file is not interlaced, +where it will return one pass. + +If you are not going to display the image after each pass, but are +going to wait until the entire image is read in, use the sparkle +effect. This effect is faster and the end result of either method +is exactly the same. If you are planning on displaying the image +after each pass, the "rectangle" effect is generally considered the +better looking one. + +If you only want the "sparkle" effect, just call png_read_rows() as +normal, with the third parameter NULL. Make sure you make pass over +the image number_of_passes times, and you don't change the data in the +rows between calls. You can change the locations of the data, just +not the data. Each pass only writes the pixels appropriate for that +pass, and assumes the data from previous passes is still valid. + + png_read_rows(png_ptr, row_pointers, NULL, + number_of_rows); + +If you only want the first effect (the rectangles), do the same as +before except pass the row buffer in the third parameter, and leave +the second parameter NULL. + + png_read_rows(png_ptr, NULL, row_pointers, + number_of_rows); + +.SS Finishing a sequential read + +After you are finished reading the image through the +low-level interface, you can finish reading the file. If you are +interested in comments or time, which may be stored either before or +after the image data, you should pass the separate png_info struct if +you want to keep the comments from before and after the image +separate. If you are not interested, you can pass NULL. + + png_read_end(png_ptr, end_info); + +When you are done, you can free all memory allocated by libpng like this: + + png_destroy_read_struct(&png_ptr, &info_ptr, + &end_info); + +It is also possible to individually free the info_ptr members that +point to libpng-allocated storage with the following function: + + png_free_data(png_ptr, info_ptr, mask, seq) + mask - identifies data to be freed, a mask + containing the bitwise OR of one or + more of + PNG_FREE_PLTE, PNG_FREE_TRNS, + PNG_FREE_HIST, PNG_FREE_ICCP, + PNG_FREE_PCAL, PNG_FREE_ROWS, + PNG_FREE_SCAL, PNG_FREE_SPLT, + PNG_FREE_TEXT, PNG_FREE_UNKN, + or simply PNG_FREE_ALL + seq - sequence number of item to be freed + (-1 for all items) + +This function may be safely called when the relevant storage has +already been freed, or has not yet been allocated, or was allocated +by the user and not by libpng, and will in those +cases do nothing. The "seq" parameter is ignored if only one item +of the selected data type, such as PLTE, is allowed. If "seq" is not +-1, and multiple items are allowed for the data type identified in +the mask, such as text or sPLT, only the n'th item in the structure +is freed, where n is "seq". + +The default behavior is only to free data that was allocated internally +by libpng. This can be changed, so that libpng will not free the data, +or so that it will free data that was allocated by the user with png_malloc() +or png_zalloc() and passed in via a png_set_*() function, with + + png_data_freer(png_ptr, info_ptr, freer, mask) + mask - which data elements are affected + same choices as in png_free_data() + freer - one of + PNG_DESTROY_WILL_FREE_DATA + PNG_SET_WILL_FREE_DATA + PNG_USER_WILL_FREE_DATA + +This function only affects data that has already been allocated. +You can call this function after reading the PNG data but before calling +any png_set_*() functions, to control whether the user or the png_set_*() +function is responsible for freeing any existing data that might be present, +and again after the png_set_*() functions to control whether the user +or png_destroy_*() is supposed to free the data. When the user assumes +responsibility for libpng-allocated data, the application must use +png_free() to free it, and when the user transfers responsibility to libpng +for data that the user has allocated, the user must have used png_malloc() +or png_zalloc() to allocate it. + +If you allocated your row_pointers in a single block, as suggested above in +the description of the high level read interface, you must not transfer +responsibility for freeing it to the png_set_rows or png_read_destroy function, +because they would also try to free the individual row_pointers[i]. + +If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword +separately, do not transfer responsibility for freeing text_ptr to libpng, +because when libpng fills a png_text structure it combines these members with +the key member, and png_free_data() will free only text_ptr.key. Similarly, +if you transfer responsibility for free'ing text_ptr from libpng to your +application, your application must not separately free those members. + +The png_free_data() function will turn off the "valid" flag for anything +it frees. If you need to turn the flag off for a chunk that was freed by your +application instead of by libpng, you can use + + png_set_invalid(png_ptr, info_ptr, mask); + mask - identifies the chunks to be made invalid, + containing the bitwise OR of one or + more of + PNG_INFO_gAMA, PNG_INFO_sBIT, + PNG_INFO_cHRM, PNG_INFO_PLTE, + PNG_INFO_tRNS, PNG_INFO_bKGD, + PNG_INFO_hIST, PNG_INFO_pHYs, + PNG_INFO_oFFs, PNG_INFO_tIME, + PNG_INFO_pCAL, PNG_INFO_sRGB, + PNG_INFO_iCCP, PNG_INFO_sPLT, + PNG_INFO_sCAL, PNG_INFO_IDAT + +For a more compact example of reading a PNG image, see the file example.c. + +.SS Reading PNG files progressively + +The progressive reader is slightly different then the non-progressive +reader. Instead of calling png_read_info(), png_read_rows(), and +png_read_end(), you make one call to png_process_data(), which calls +callbacks when it has the info, a row, or the end of the image. You +set up these callbacks with png_set_progressive_read_fn(). You don't +have to worry about the input/output functions of libpng, as you are +giving the library the data directly in png_process_data(). I will +assume that you have read the section on reading PNG files above, +so I will only highlight the differences (although I will show +all of the code). + +png_structp png_ptr; +png_infop info_ptr; + + /* An example code fragment of how you would + initialize the progressive reader in your + application. */ + int + initialize_png_reader() + { + png_ptr = png_create_read_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn); + if (!png_ptr) + return (ERROR); + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + png_destroy_read_struct(&png_ptr, (png_infopp)NULL, + (png_infopp)NULL); + return (ERROR); + } + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + (png_infopp)NULL); + return (ERROR); + } + + /* This one's new. You can provide functions + to be called when the header info is valid, + when each row is completed, and when the image + is finished. If you aren't using all functions, + you can specify NULL parameters. Even when all + three functions are NULL, you need to call + png_set_progressive_read_fn(). You can use + any struct as the user_ptr (cast to a void pointer + for the function call), and retrieve the pointer + from inside the callbacks using the function + + png_get_progressive_ptr(png_ptr); + + which will return a void pointer, which you have + to cast appropriately. + */ + png_set_progressive_read_fn(png_ptr, (void *)user_ptr, + info_callback, row_callback, end_callback); + + return 0; + } + + /* A code fragment that you call as you receive blocks + of data */ + int + process_data(png_bytep buffer, png_uint_32 length) + { + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + (png_infopp)NULL); + return (ERROR); + } + + /* This one's new also. Simply give it a chunk + of data from the file stream (in order, of + course). On machines with segmented memory + models machines, don't give it any more than + 64K. The library seems to run fine with sizes + of 4K. Although you can give it much less if + necessary (I assume you can give it chunks of + 1 byte, I haven't tried less then 256 bytes + yet). When this function returns, you may + want to display any rows that were generated + in the row callback if you don't already do + so there. + */ + png_process_data(png_ptr, info_ptr, buffer, length); + return 0; + } + + /* This function is called (as set by + png_set_progressive_read_fn() above) when enough data + has been supplied so all of the header has been + read. + */ + void + info_callback(png_structp png_ptr, png_infop info) + { + /* Do any setup here, including setting any of + the transformations mentioned in the Reading + PNG files section. For now, you _must_ call + either png_start_read_image() or + png_read_update_info() after all the + transformations are set (even if you don't set + any). You may start getting rows before + png_process_data() returns, so this is your + last chance to prepare for that. + */ + } + + /* This function is called when each row of image + data is complete */ + void + row_callback(png_structp png_ptr, png_bytep new_row, + png_uint_32 row_num, int pass) + { + /* If the image is interlaced, and you turned + on the interlace handler, this function will + be called for every row in every pass. Some + of these rows will not be changed from the + previous pass. When the row is not changed, + the new_row variable will be NULL. The rows + and passes are called in order, so you don't + really need the row_num and pass, but I'm + supplying them because it may make your life + easier. + + For the non-NULL rows of interlaced images, + you must call png_progressive_combine_row() + passing in the row and the old row. You can + call this function for NULL rows (it will just + return) and for non-interlaced images (it just + does the memcpy for you) if it will make the + code easier. Thus, you can just do this for + all cases: + */ + + png_progressive_combine_row(png_ptr, old_row, + new_row); + + /* where old_row is what was displayed for + previously for the row. Note that the first + pass (pass == 0, really) will completely cover + the old row, so the rows do not have to be + initialized. After the first pass (and only + for interlaced images), you will have to pass + the current row, and the function will combine + the old row and the new row. + */ + } + + void + end_callback(png_structp png_ptr, png_infop info) + { + /* This function is called after the whole image + has been read, including any chunks after the + image (up to and including the IEND). You + will usually have the same info chunk as you + had in the header, although some data may have + been added to the comments and time fields. + + Most people won't do much here, perhaps setting + a flag that marks the image as finished. + */ + } + + + +.SH IV. Writing + +Much of this is very similar to reading. However, everything of +importance is repeated here, so you won't have to constantly look +back up in the reading section to understand writing. + +.SS Setup + +You will want to do the I/O initialization before you get into libpng, +so if it doesn't work, you don't have anything to undo. If you are not +using the standard I/O functions, you will need to replace them with +custom writing functions. See the discussion under Customizing libpng. + + FILE *fp = fopen(file_name, "wb"); + if (!fp) + { + return (ERROR); + } + +Next, png_struct and png_info need to be allocated and initialized. +As these can be both relatively large, you may not want to store these +on the stack, unless you have stack space to spare. Of course, you +will want to check if they return NULL. If you are also reading, +you won't want to name your read structure and your write structure +both "png_ptr"; you can call them anything you like, such as +"read_ptr" and "write_ptr". Look at pngtest.c, for example. + + png_structp png_ptr = png_create_write_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn); + if (!png_ptr) + return (ERROR); + + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + png_destroy_write_struct(&png_ptr, + (png_infopp)NULL); + return (ERROR); + } + +If you want to use your own memory allocation routines, +define PNG_USER_MEM_SUPPORTED and use +png_create_write_struct_2() instead of png_create_write_struct(): + + png_structp png_ptr = png_create_write_struct_2 + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn, (png_voidp) + user_mem_ptr, user_malloc_fn, user_free_fn); + +After you have these structures, you will need to set up the +error handling. When libpng encounters an error, it expects to +longjmp() back to your routine. Therefore, you will need to call +setjmp() and pass the png_jmpbuf(png_ptr). If you +write the file from different routines, you will need to update +the png_jmpbuf(png_ptr) every time you enter a new routine that will +call a png_*() function. See your documentation of setjmp/longjmp +for your compiler for more information on setjmp/longjmp. See +the discussion on libpng error handling in the Customizing Libpng +section below for more information on the libpng error handling. + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_write_struct(&png_ptr, &info_ptr); + fclose(fp); + return (ERROR); + } + ... + return; + +If you would rather avoid the complexity of setjmp/longjmp issues, +you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case +errors will result in a call to PNG_ABORT() which defaults to abort(). + +Now you need to set up the output code. The default for libpng is to +use the C function fwrite(). If you use this, you will need to pass a +valid FILE * in the function png_init_io(). Be sure that the file is +opened in binary mode. Again, if you wish to handle writing data in +another way, see the discussion on libpng I/O handling in the Customizing +Libpng section below. + + png_init_io(png_ptr, fp); + +If you are embedding your PNG into a datastream such as MNG, and don't +want libpng to write the 8-byte signature, or if you have already +written the signature in your application, use + + png_set_sig_bytes(png_ptr, 8); + +to inform libpng that it should not write a signature. + +.SS Write callbacks + +At this point, you can set up a callback function that will be +called after each row has been written, which you can use to control +a progress meter or the like. It's demonstrated in pngtest.c. +You must supply a function + + void write_row_callback(png_ptr, png_uint_32 row, + int pass); + { + /* put your code here */ + } + +(You can give it another name that you like instead of "write_row_callback") + +To inform libpng about your function, use + + png_set_write_status_fn(png_ptr, write_row_callback); + +You now have the option of modifying how the compression library will +run. The following functions are mainly for testing, but may be useful +in some cases, like if you need to write PNG files extremely fast and +are willing to give up some compression, or if you want to get the +maximum possible compression at the expense of slower writing. If you +have no special needs in this area, let the library do what it wants by +not calling this function at all, as it has been tuned to deliver a good +speed/compression ratio. The second parameter to png_set_filter() is +the filter method, for which the only valid values are 0 (as of the +July 1999 PNG specification, version 1.2) or 64 (if you are writing +a PNG datastream that is to be embedded in a MNG datastream). The third +parameter is a flag that indicates which filter type(s) are to be tested +for each scanline. See the PNG specification for details on the specific filter +types. + + + /* turn on or off filtering, and/or choose + specific filters. You can use either a single + PNG_FILTER_VALUE_NAME or the bitwise OR of one + or more PNG_FILTER_NAME masks. */ + png_set_filter(png_ptr, 0, + PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | + PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | + PNG_FILTER_UP | PNG_FILTER_VALUE_UP | + PNG_FILTER_AVE | PNG_FILTER_VALUE_AVE | + PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| + PNG_ALL_FILTERS); + +If an application +wants to start and stop using particular filters during compression, +it should start out with all of the filters (to ensure that the previous +row of pixels will be stored in case it's needed later), and then add +and remove them after the start of compression. + +If you are writing a PNG datastream that is to be embedded in a MNG +datastream, the second parameter can be either 0 or 64. + +The png_set_compression_*() functions interface to the zlib compression +library, and should mostly be ignored unless you really know what you are +doing. The only generally useful call is png_set_compression_level() +which changes how much time zlib spends on trying to compress the image +data. See the Compression Library (zlib.h and algorithm.txt, distributed +with zlib) for details on the compression levels. + + /* set the zlib compression level */ + png_set_compression_level(png_ptr, + Z_BEST_COMPRESSION); + + /* set other zlib parameters */ + png_set_compression_mem_level(png_ptr, 8); + png_set_compression_strategy(png_ptr, + Z_DEFAULT_STRATEGY); + png_set_compression_window_bits(png_ptr, 15); + png_set_compression_method(png_ptr, 8); + png_set_compression_buffer_size(png_ptr, 8192) + +extern PNG_EXPORT(void,png_set_zbuf_size) + +.SS Setting the contents of info for output + +You now need to fill in the png_info structure with all the data you +wish to write before the actual image. Note that the only thing you +are allowed to write after the image is the text chunks and the time +chunk (as of PNG Specification 1.2, anyway). See png_write_end() and +the latest PNG specification for more information on that. If you +wish to write them before the image, fill them in now, and flag that +data as being valid. If you want to wait until after the data, don't +fill them until png_write_end(). For all the fields in png_info and +their data types, see png.h. For explanations of what the fields +contain, see the PNG specification. + +Some of the more important parts of the png_info are: + + png_set_IHDR(png_ptr, info_ptr, width, height, + bit_depth, color_type, interlace_type, + compression_type, filter_method) + width - holds the width of the image + in pixels (up to 2^31). + height - holds the height of the image + in pixels (up to 2^31). + bit_depth - holds the bit depth of one of the + image channels. + (valid values are 1, 2, 4, 8, 16 + and depend also on the + color_type. See also significant + bits (sBIT) below). + color_type - describes which color/alpha + channels are present. + PNG_COLOR_TYPE_GRAY + (bit depths 1, 2, 4, 8, 16) + PNG_COLOR_TYPE_GRAY_ALPHA + (bit depths 8, 16) + PNG_COLOR_TYPE_PALETTE + (bit depths 1, 2, 4, 8) + PNG_COLOR_TYPE_RGB + (bit_depths 8, 16) + PNG_COLOR_TYPE_RGB_ALPHA + (bit_depths 8, 16) + + PNG_COLOR_MASK_PALETTE + PNG_COLOR_MASK_COLOR + PNG_COLOR_MASK_ALPHA + + interlace_type - PNG_INTERLACE_NONE or + PNG_INTERLACE_ADAM7 + compression_type - (must be + PNG_COMPRESSION_TYPE_DEFAULT) + filter_method - (must be PNG_FILTER_TYPE_DEFAULT + or, if you are writing a PNG to + be embedded in a MNG datastream, + can also be + PNG_INTRAPIXEL_DIFFERENCING) + + png_set_PLTE(png_ptr, info_ptr, palette, + num_palette); + palette - the palette for the file + (array of png_color) + num_palette - number of entries in the palette + + png_set_gAMA(png_ptr, info_ptr, gamma); + gamma - the gamma the image was created + at (PNG_INFO_gAMA) + + png_set_sRGB(png_ptr, info_ptr, srgb_intent); + srgb_intent - the rendering intent + (PNG_INFO_sRGB) The presence of + the sRGB chunk means that the pixel + data is in the sRGB color space. + This chunk also implies specific + values of gAMA and cHRM. Rendering + intent is the CSS-1 property that + has been defined by the International + Color Consortium + (http://www.color.org). + It can be one of + PNG_sRGB_INTENT_SATURATION, + PNG_sRGB_INTENT_PERCEPTUAL, + PNG_sRGB_INTENT_ABSOLUTE, or + PNG_sRGB_INTENT_RELATIVE. + + + png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, + srgb_intent); + srgb_intent - the rendering intent + (PNG_INFO_sRGB) The presence of the + sRGB chunk means that the pixel + data is in the sRGB color space. + This function also causes gAMA and + cHRM chunks with the specific values + that are consistent with sRGB to be + written. + + png_set_iCCP(png_ptr, info_ptr, name, compression_type, + profile, proflen); + name - The profile name. + compression - The compression type; always + PNG_COMPRESSION_TYPE_BASE for PNG 1.0. + You may give NULL to this argument to + ignore it. + profile - International Color Consortium color + profile data. May contain NULs. + proflen - length of profile data in bytes. + + png_set_sBIT(png_ptr, info_ptr, sig_bit); + sig_bit - the number of significant bits for + (PNG_INFO_sBIT) each of the gray, red, + green, and blue channels, whichever are + appropriate for the given color type + (png_color_16) + + png_set_tRNS(png_ptr, info_ptr, trans, num_trans, + trans_values); + trans - array of transparent entries for + palette (PNG_INFO_tRNS) + trans_values - graylevel or color sample values of + the single transparent color for + non-paletted images (PNG_INFO_tRNS) + num_trans - number of transparent entries + (PNG_INFO_tRNS) + + png_set_hIST(png_ptr, info_ptr, hist); + (PNG_INFO_hIST) + hist - histogram of palette (array of + png_uint_16) + + png_set_tIME(png_ptr, info_ptr, mod_time); + mod_time - time image was last modified + (PNG_VALID_tIME) + + png_set_bKGD(png_ptr, info_ptr, background); + background - background color (PNG_VALID_bKGD) + + png_set_text(png_ptr, info_ptr, text_ptr, num_text); + text_ptr - array of png_text holding image + comments + text_ptr[i].compression - type of compression used + on "text" PNG_TEXT_COMPRESSION_NONE + PNG_TEXT_COMPRESSION_zTXt + PNG_ITXT_COMPRESSION_NONE + PNG_ITXT_COMPRESSION_zTXt + text_ptr[i].key - keyword for comment. Must contain + 1-79 characters. + text_ptr[i].text - text comments for current + keyword. Can be NULL or empty. + text_ptr[i].text_length - length of text string, + after decompression, 0 for iTXt + text_ptr[i].itxt_length - length of itxt string, + after decompression, 0 for tEXt/zTXt + text_ptr[i].lang - language of comment (NULL or + empty for unknown). + text_ptr[i].translated_keyword - keyword in UTF-8 (NULL + or empty for unknown). + num_text - number of comments + + png_set_sPLT(png_ptr, info_ptr, &palette_ptr, + num_spalettes); + palette_ptr - array of png_sPLT_struct structures + to be added to the list of palettes + in the info structure. + num_spalettes - number of palette structures to be + added. + + png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, + unit_type); + offset_x - positive offset from the left + edge of the screen + offset_y - positive offset from the top + edge of the screen + unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER + + png_set_pHYs(png_ptr, info_ptr, res_x, res_y, + unit_type); + res_x - pixels/unit physical resolution + in x direction + res_y - pixels/unit physical resolution + in y direction + unit_type - PNG_RESOLUTION_UNKNOWN, + PNG_RESOLUTION_METER + + png_set_sCAL(png_ptr, info_ptr, unit, width, height) + unit - physical scale units (an integer) + width - width of a pixel in physical scale units + height - height of a pixel in physical scale units + (width and height are doubles) + + png_set_sCAL_s(png_ptr, info_ptr, unit, width, height) + unit - physical scale units (an integer) + width - width of a pixel in physical scale units + height - height of a pixel in physical scale units + (width and height are strings like "2.54") + + png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, + num_unknowns) + unknowns - array of png_unknown_chunk + structures holding unknown chunks + unknowns[i].name - name of unknown chunk + unknowns[i].data - data of unknown chunk + unknowns[i].size - size of unknown chunk's data + unknowns[i].location - position to write chunk in file + 0: do not write chunk + PNG_HAVE_IHDR: before PLTE + PNG_HAVE_PLTE: before IDAT + PNG_AFTER_IDAT: after IDAT + +The "location" member is set automatically according to +what part of the output file has already been written. +You can change its value after calling png_set_unknown_chunks() +as demonstrated in pngtest.c. Within each of the "locations", +the chunks are sequenced according to their position in the +structure (that is, the value of "i", which is the order in which +the chunk was either read from the input file or defined with +png_set_unknown_chunks). + +A quick word about text and num_text. text is an array of png_text +structures. num_text is the number of valid structures in the array. +Each png_text structure holds a language code, a keyword, a text value, +and a compression type. + +The compression types have the same valid numbers as the compression +types of the image data. Currently, the only valid number is zero. +However, you can store text either compressed or uncompressed, unlike +images, which always have to be compressed. So if you don't want the +text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. +Because tEXt and zTXt chunks don't have a language field, if you +specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt +any language code or translated keyword will not be written out. + +Until text gets around 1000 bytes, it is not worth compressing it. +After the text has been written out to the file, the compression type +is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR, +so that it isn't written out again at the end (in case you are calling +png_write_end() with the same struct. + +The keywords that are given in the PNG Specification are: + + Title Short (one line) title or + caption for image + Author Name of image's creator + Description Description of image (possibly long) + Copyright Copyright notice + Creation Time Time of original image creation + (usually RFC 1123 format, see below) + Software Software used to create the image + Disclaimer Legal disclaimer + Warning Warning of nature of content + Source Device used to create the image + Comment Miscellaneous comment; conversion + from other image format + +The keyword-text pairs work like this. Keywords should be short +simple descriptions of what the comment is about. Some typical +keywords are found in the PNG specification, as is some recommendations +on keywords. You can repeat keywords in a file. You can even write +some text before the image and some after. For example, you may want +to put a description of the image before the image, but leave the +disclaimer until after, so viewers working over modem connections +don't have to wait for the disclaimer to go over the modem before +they start seeing the image. Finally, keywords should be full +words, not abbreviations. Keywords and text are in the ISO 8859-1 +(Latin-1) character set (a superset of regular ASCII) and can not +contain NUL characters, and should not contain control or other +unprintable characters. To make the comments widely readable, stick +with basic ASCII, and avoid machine specific character set extensions +like the IBM-PC character set. The keyword must be present, but +you can leave off the text string on non-compressed pairs. +Compressed pairs must have a text string, as only the text string +is compressed anyway, so the compression would be meaningless. + +PNG supports modification time via the png_time structure. Two +conversion routines are provided, png_convert_from_time_t() for +time_t and png_convert_from_struct_tm() for struct tm. The +time_t routine uses gmtime(). You don't have to use either of +these, but if you wish to fill in the png_time structure directly, +you should provide the time in universal time (GMT) if possible +instead of your local time. Note that the year number is the full +year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and +that months start with 1. + +If you want to store the time of the original image creation, you should +use a plain tEXt chunk with the "Creation Time" keyword. This is +necessary because the "creation time" of a PNG image is somewhat vague, +depending on whether you mean the PNG file, the time the image was +created in a non-PNG format, a still photo from which the image was +scanned, or possibly the subject matter itself. In order to facilitate +machine-readable dates, it is recommended that the "Creation Time" +tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), +although this isn't a requirement. Unlike the tIME chunk, the +"Creation Time" tEXt chunk is not expected to be automatically changed +by the software. To facilitate the use of RFC 1123 dates, a function +png_convert_to_rfc1123(png_timep) is provided to convert from PNG +time to an RFC 1123 format string. + +.SS Writing unknown chunks + +You can use the png_set_unknown_chunks function to queue up chunks +for writing. You give it a chunk name, raw data, and a size; that's +all there is to it. The chunks will be written by the next following +png_write_info_before_PLTE, png_write_info, or png_write_end function. +Any chunks previously read into the info structure's unknown-chunk +list will also be written out in a sequence that satisfies the PNG +specification's ordering rules. + +.SS The high-level write interface + +At this point there are two ways to proceed; through the high-level +write interface, or through a sequence of low-level write operations. +You can use the high-level interface if your image data is present +in the info structure. All defined output +transformations are permitted, enabled by the following masks. + + PNG_TRANSFORM_IDENTITY No transformation + PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples + PNG_TRANSFORM_PACKSWAP Change order of packed + pixels to LSB first + PNG_TRANSFORM_INVERT_MONO Invert monochrome images + PNG_TRANSFORM_SHIFT Normalize pixels to the + sBIT depth + PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA + to BGRA + PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA + to AG + PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity + to transparency + PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples + PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes. + +If you have valid image data in the info structure (you can use +png_set_rows() to put image data in the info structure), simply do this: + + png_write_png(png_ptr, info_ptr, png_transforms, NULL) + +where png_transforms is an integer containing the bitwise OR of some set of +transformation flags. This call is equivalent to png_write_info(), +followed the set of transformations indicated by the transform mask, +then png_write_image(), and finally png_write_end(). + +(The final parameter of this call is not yet used. Someday it might point +to transformation parameters required by some future output transform.) + +You must use png_transforms and not call any png_set_transform() functions +when you use png_write_png(). + +.SS The low-level write interface + +If you are going the low-level route instead, you are now ready to +write all the file information up to the actual image data. You do +this with a call to png_write_info(). + + png_write_info(png_ptr, info_ptr); + +Note that there is one transformation you may need to do before +png_write_info(). In PNG files, the alpha channel in an image is the +level of opacity. If your data is supplied as a level of +transparency, you can invert the alpha channel before you write it, so +that 0 is fully transparent and 255 (in 8-bit or paletted images) or +65535 (in 16-bit images) is fully opaque, with + + png_set_invert_alpha(png_ptr); + +This must appear before png_write_info() instead of later with the +other transformations because in the case of paletted images the tRNS +chunk data has to be inverted before the tRNS chunk is written. If +your image is not a paletted image, the tRNS data (which in such cases +represents a single color to be rendered as transparent) won't need to +be changed, and you can safely do this transformation after your +png_write_info() call. + +If you need to write a private chunk that you want to appear before +the PLTE chunk when PLTE is present, you can write the PNG info in +two steps, and insert code to write your own chunk between them: + + png_write_info_before_PLTE(png_ptr, info_ptr); + png_set_unknown_chunks(png_ptr, info_ptr, ...); + png_write_info(png_ptr, info_ptr); + +After you've written the file information, you can set up the library +to handle any special transformations of the image data. The various +ways to transform the data will be described in the order that they +should occur. This is important, as some of these change the color +type and/or bit depth of the data, and some others only work on +certain color types and bit depths. Even though each transformation +checks to see if it has data that it can do something with, you should +make sure to only enable a transformation if it will be valid for the +data. For example, don't swap red and blue on grayscale data. + +PNG files store RGB pixels packed into 3 or 6 bytes. This code tells +the library to strip input data that has 4 or 8 bytes per pixel down +to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2 +bytes per pixel). + + png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); + +where the 0 is unused, and the location is either PNG_FILLER_BEFORE or +PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel +is stored XRGB or RGBX. + +PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as +they can, resulting in, for example, 8 pixels per byte for 1 bit files. +If the data is supplied at 1 pixel per byte, use this code, which will +correctly pack the pixels into a single byte: + + png_set_packing(png_ptr); + +PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your +data is of another bit depth, you can write an sBIT chunk into the +file so that decoders can recover the original data if desired. + + /* Set the true bit depth of the image data */ + if (color_type & PNG_COLOR_MASK_COLOR) + { + sig_bit.red = true_bit_depth; + sig_bit.green = true_bit_depth; + sig_bit.blue = true_bit_depth; + } + else + { + sig_bit.gray = true_bit_depth; + } + if (color_type & PNG_COLOR_MASK_ALPHA) + { + sig_bit.alpha = true_bit_depth; + } + + png_set_sBIT(png_ptr, info_ptr, &sig_bit); + +If the data is stored in the row buffer in a bit depth other than +one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG), +this will scale the values to appear to be the correct bit depth as +is required by PNG. + + png_set_shift(png_ptr, &sig_bit); + +PNG files store 16 bit pixels in network byte order (big-endian, +ie. most significant bits first). This code would be used if they are +supplied the other way (little-endian, i.e. least significant bits +first, the way PCs store them): + + if (bit_depth > 8) + png_set_swap(png_ptr); + +If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you +need to change the order the pixels are packed into bytes, you can use: + + if (bit_depth < 8) + png_set_packswap(png_ptr); + +PNG files store 3 color pixels in red, green, blue order. This code +would be used if they are supplied as blue, green, red: + + png_set_bgr(png_ptr); + +PNG files describe monochrome as black being zero and white being +one. This code would be used if the pixels are supplied with this reversed +(black being one and white being zero): + + png_set_invert_mono(png_ptr); + +Finally, you can write your own transformation function if none of +the existing ones meets your needs. This is done by setting a callback +with + + png_set_write_user_transform_fn(png_ptr, + write_transform_fn); + +You must supply the function + + void write_transform_fn(png_ptr ptr, row_info_ptr + row_info, png_bytep data) + +See pngtest.c for a working example. Your function will be called +before any of the other transformations are processed. + +You can also set up a pointer to a user structure for use by your +callback function. + + png_set_user_transform_info(png_ptr, user_ptr, 0, 0); + +The user_channels and user_depth parameters of this function are ignored +when writing; you can set them to zero as shown. + +You can retrieve the pointer via the function png_get_user_transform_ptr(). +For example: + + voidp write_user_transform_ptr = + png_get_user_transform_ptr(png_ptr); + +It is possible to have libpng flush any pending output, either manually, +or automatically after a certain number of lines have been written. To +flush the output stream a single time call: + + png_write_flush(png_ptr); + +and to have libpng flush the output stream periodically after a certain +number of scanlines have been written, call: + + png_set_flush(png_ptr, nrows); + +Note that the distance between rows is from the last time png_write_flush() +was called, or the first row of the image if it has never been called. +So if you write 50 lines, and then png_set_flush 25, it will flush the +output on the next scanline, and every 25 lines thereafter, unless +png_write_flush() is called before 25 more lines have been written. +If nrows is too small (less than about 10 lines for a 640 pixel wide +RGB image) the image compression may decrease noticeably (although this +may be acceptable for real-time applications). Infrequent flushing will +only degrade the compression performance by a few percent over images +that do not use flushing. + +.SS Writing the image data + +That's it for the transformations. Now you can write the image data. +The simplest way to do this is in one function call. If you have the +whole image in memory, you can just call png_write_image() and libpng +will write the image. You will need to pass in an array of pointers to +each row. This function automatically handles interlacing, so you don't +need to call png_set_interlace_handling() or call this function multiple +times, or any of that other stuff necessary with png_write_rows(). + + png_write_image(png_ptr, row_pointers); + +where row_pointers is: + + png_byte *row_pointers[height]; + +You can point to void or char or whatever you use for pixels. + +If you don't want to write the whole image at once, you can +use png_write_rows() instead. If the file is not interlaced, +this is simple: + + png_write_rows(png_ptr, row_pointers, + number_of_rows); + +row_pointers is the same as in the png_write_image() call. + +If you are just writing one row at a time, you can do this with +a single row_pointer instead of an array of row_pointers: + + png_bytep row_pointer = row; + + png_write_row(png_ptr, row_pointer); + +When the file is interlaced, things can get a good deal more +complicated. The only currently (as of the PNG Specification +version 1.2, dated July 1999) defined interlacing scheme for PNG files +is the "Adam7" interlace scheme, that breaks down an +image into seven smaller images of varying size. libpng will build +these images for you, or you can do them yourself. If you want to +build them yourself, see the PNG specification for details of which +pixels to write when. + +If you don't want libpng to handle the interlacing details, just +use png_set_interlace_handling() and call png_write_rows() the +correct number of times to write all seven sub-images. + +If you want libpng to build the sub-images, call this before you start +writing any rows: + + number_of_passes = + png_set_interlace_handling(png_ptr); + +This will return the number of passes needed. Currently, this +is seven, but may change if another interlace type is added. + +Then write the complete image number_of_passes times. + + png_write_rows(png_ptr, row_pointers, + number_of_rows); + +As some of these rows are not used, and thus return immediately, +you may want to read about interlacing in the PNG specification, +and only update the rows that are actually used. + +.SS Finishing a sequential write + +After you are finished writing the image, you should finish writing +the file. If you are interested in writing comments or time, you should +pass an appropriately filled png_info pointer. If you are not interested, +you can pass NULL. + + png_write_end(png_ptr, info_ptr); + +When you are done, you can free all memory used by libpng like this: + + png_destroy_write_struct(&png_ptr, &info_ptr); + +It is also possible to individually free the info_ptr members that +point to libpng-allocated storage with the following function: + + png_free_data(png_ptr, info_ptr, mask, seq) + mask - identifies data to be freed, a mask + containing the bitwise OR of one or + more of + PNG_FREE_PLTE, PNG_FREE_TRNS, + PNG_FREE_HIST, PNG_FREE_ICCP, + PNG_FREE_PCAL, PNG_FREE_ROWS, + PNG_FREE_SCAL, PNG_FREE_SPLT, + PNG_FREE_TEXT, PNG_FREE_UNKN, + or simply PNG_FREE_ALL + seq - sequence number of item to be freed + (-1 for all items) + +This function may be safely called when the relevant storage has +already been freed, or has not yet been allocated, or was allocated +by the user and not by libpng, and will in those +cases do nothing. The "seq" parameter is ignored if only one item +of the selected data type, such as PLTE, is allowed. If "seq" is not +-1, and multiple items are allowed for the data type identified in +the mask, such as text or sPLT, only the n'th item in the structure +is freed, where n is "seq". + +If you allocated data such as a palette that you passed +in to libpng with png_set_*, you must not free it until just before the call to +png_destroy_write_struct(). + +The default behavior is only to free data that was allocated internally +by libpng. This can be changed, so that libpng will not free the data, +or so that it will free data that was allocated by the user with png_malloc() +or png_zalloc() and passed in via a png_set_*() function, with + + png_data_freer(png_ptr, info_ptr, freer, mask) + mask - which data elements are affected + same choices as in png_free_data() + freer - one of + PNG_DESTROY_WILL_FREE_DATA + PNG_SET_WILL_FREE_DATA + PNG_USER_WILL_FREE_DATA + +For example, to transfer responsibility for some data from a read structure +to a write structure, you could use + + png_data_freer(read_ptr, read_info_ptr, + PNG_USER_WILL_FREE_DATA, + PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) + png_data_freer(write_ptr, write_info_ptr, + PNG_DESTROY_WILL_FREE_DATA, + PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) + +thereby briefly reassigning responsibility for freeing to the user but +immediately afterwards reassigning it once more to the write_destroy +function. Having done this, it would then be safe to destroy the read +structure and continue to use the PLTE, tRNS, and hIST data in the write +structure. + +This function only affects data that has already been allocated. +You can call this function before calling after the png_set_*() functions +to control whether the user or png_destroy_*() is supposed to free the data. +When the user assumes responsibility for libpng-allocated data, the +application must use +png_free() to free it, and when the user transfers responsibility to libpng +for data that the user has allocated, the user must have used png_malloc() +or png_zalloc() to allocate it. + +If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword +separately, do not transfer responsibility for freeing text_ptr to libpng, +because when libpng fills a png_text structure it combines these members with +the key member, and png_free_data() will free only text_ptr.key. Similarly, +if you transfer responsibility for free'ing text_ptr from libpng to your +application, your application must not separately free those members. +For a more compact example of writing a PNG image, see the file example.c. + +.SH V. Modifying/Customizing libpng: + +There are three issues here. The first is changing how libpng does +standard things like memory allocation, input/output, and error handling. +The second deals with more complicated things like adding new chunks, +adding new transformations, and generally changing how libpng works. +Both of those are compile-time issues; that is, they are generally +determined at the time the code is written, and there is rarely a need +to provide the user with a means of changing them. The third is a +run-time issue: choosing between and/or tuning one or more alternate +versions of computationally intensive routines; specifically, optimized +assembly-language (and therefore compiler- and platform-dependent) +versions. + +Memory allocation, input/output, and error handling + +All of the memory allocation, input/output, and error handling in libpng +goes through callbacks that are user-settable. The default routines are +in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change +these functions, call the appropriate png_set_*_fn() function. + +Memory allocation is done through the functions png_malloc() +and png_free(). These currently just call the standard C functions. If +your pointers can't access more then 64K at a time, you will want to set +MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling +memory allocation on a platform will change between applications, these +functions must be modified in the library at compile time. If you prefer +to use a different method of allocating and freeing data, you can use +png_create_read_struct_2() or png_create_write_struct_2() to register +your own functions as described above. +These functions also provide a void pointer that can be retrieved via + + mem_ptr=png_get_mem_ptr(png_ptr); + +Your replacement memory functions must have prototypes as follows: + + png_voidp malloc_fn(png_structp png_ptr, + png_size_t size); + void free_fn(png_structp png_ptr, png_voidp ptr); + +Your malloc_fn() must return NULL in case of failure. The png_malloc() +function will normally call png_error() if it receives a NULL from the +system memory allocator or from your replacement malloc_fn(). + +Input/Output in libpng is done through png_read() and png_write(), +which currently just call fread() and fwrite(). The FILE * is stored in +png_struct and is initialized via png_init_io(). If you wish to change +the method of I/O, the library supplies callbacks that you can set +through the function png_set_read_fn() and png_set_write_fn() at run +time, instead of calling the png_init_io() function. These functions +also provide a void pointer that can be retrieved via the function +png_get_io_ptr(). For example: + + png_set_read_fn(png_structp read_ptr, + voidp read_io_ptr, png_rw_ptr read_data_fn) + + png_set_write_fn(png_structp write_ptr, + voidp write_io_ptr, png_rw_ptr write_data_fn, + png_flush_ptr output_flush_fn); + + voidp read_io_ptr = png_get_io_ptr(read_ptr); + voidp write_io_ptr = png_get_io_ptr(write_ptr); + +The replacement I/O functions must have prototypes as follows: + + void user_read_data(png_structp png_ptr, + png_bytep data, png_size_t length); + void user_write_data(png_structp png_ptr, + png_bytep data, png_size_t length); + void user_flush_data(png_structp png_ptr); + +Supplying NULL for the read, write, or flush functions sets them back +to using the default C stream functions. It is an error to read from +a write stream, and vice versa. + +Error handling in libpng is done through png_error() and png_warning(). +Errors handled through png_error() are fatal, meaning that png_error() +should never return to its caller. Currently, this is handled via +setjmp() and longjmp() (unless you have compiled libpng with +PNG_SETJMP_NOT_SUPPORTED, in which case it is handled via PNG_ABORT()), +but you could change this to do things like exit() if you should wish. + +On non-fatal errors, png_warning() is called +to print a warning message, and then control returns to the calling code. +By default png_error() and png_warning() print a message on stderr via +fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined +(because you don't want the messages) or PNG_NO_STDIO defined (because +fprintf() isn't available). If you wish to change the behavior of the error +functions, you will need to set up your own message callbacks. These +functions are normally supplied at the time that the png_struct is created. +It is also possible to redirect errors and warnings to your own replacement +functions after png_create_*_struct() has been called by calling: + + png_set_error_fn(png_structp png_ptr, + png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warning_fn); + + png_voidp error_ptr = png_get_error_ptr(png_ptr); + +If NULL is supplied for either error_fn or warning_fn, then the libpng +default function will be used, calling fprintf() and/or longjmp() if a +problem is encountered. The replacement error functions should have +parameters as follows: + + void user_error_fn(png_structp png_ptr, + png_const_charp error_msg); + void user_warning_fn(png_structp png_ptr, + png_const_charp warning_msg); + +The motivation behind using setjmp() and longjmp() is the C++ throw and +catch exception handling methods. This makes the code much easier to write, +as there is no need to check every return code of every function call. +However, there are some uncertainties about the status of local variables +after a longjmp, so the user may want to be careful about doing anything after +setjmp returns non-zero besides returning itself. Consult your compiler +documentation for more details. For an alternative approach, you may wish +to use the "cexcept" facility (see http://cexcept.sourceforge.net). + +.SS Custom chunks + +If you need to read or write custom chunks, you may need to get deeper +into the libpng code. The library now has mechanisms for storing +and writing chunks of unknown type; you can even declare callbacks +for custom chunks. However, this may not be good enough if the +library code itself needs to know about interactions between your +chunk and existing `intrinsic' chunks. + +If you need to write a new intrinsic chunk, first read the PNG +specification. Acquire a first level of +understanding of how it works. Pay particular attention to the +sections that describe chunk names, and look at how other chunks were +designed, so you can do things similarly. Second, check out the +sections of libpng that read and write chunks. Try to find a chunk +that is similar to yours and use it as a template. More details can +be found in the comments inside the code. It is best to handle unknown +chunks in a generic method, via callback functions, instead of by +modifying libpng functions. + +If you wish to write your own transformation for the data, look through +the part of the code that does the transformations, and check out some of +the simpler ones to get an idea of how they work. Try to find a similar +transformation to the one you want to add and copy off of it. More details +can be found in the comments inside the code itself. + +.SS Configuring for 16 bit platforms + +You will want to look into zconf.h to tell zlib (and thus libpng) that +it cannot allocate more then 64K at a time. Even if you can, the memory +won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. + +.SS Configuring for DOS + +For DOS users who only have access to the lower 640K, you will +have to limit zlib's memory usage via a png_set_compression_mem_level() +call. See zlib.h or zconf.h in the zlib library for more information. + +.SS Configuring for Medium Model + +Libpng's support for medium model has been tested on most of the popular +compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets +defined, and FAR gets defined to far in pngconf.h, and you should be +all set. Everything in the library (except for zlib's structure) is +expecting far data. You must use the typedefs with the p or pp on +the end for pointers (or at least look at them and be careful). Make +note that the rows of data are defined as png_bytepp, which is an +unsigned char far * far *. + +.SS Configuring for gui/windowing platforms: + +You will need to write new error and warning functions that use the GUI +interface, as described previously, and set them to be the error and +warning functions at the time that png_create_*_struct() is called, +in order to have them available during the structure initialization. +They can be changed later via png_set_error_fn(). On some compilers, +you may also have to change the memory allocators (png_malloc, etc.). + +.SS Configuring for compiler xxx: + +All includes for libpng are in pngconf.h. If you need to add/change/delete +an include, this is the place to do it. The includes that are not +needed outside libpng are protected by the PNG_INTERNAL definition, +which is only defined for those routines inside libpng itself. The +files in libpng proper only include png.h, which includes pngconf.h. + +.SS Configuring zlib: + +There are special functions to configure the compression. Perhaps the +most useful one changes the compression level, which currently uses +input compression values in the range 0 - 9. The library normally +uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests +have shown that for a large majority of images, compression values in +the range 3-6 compress nearly as well as higher levels, and do so much +faster. For online applications it may be desirable to have maximum speed +(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also +specify no compression (Z_NO_COMPRESSION = 0), but this would create +files larger than just storing the raw bitmap. You can specify the +compression level by calling: + + png_set_compression_level(png_ptr, level); + +Another useful one is to reduce the memory level used by the library. +The memory level defaults to 8, but it can be lowered if you are +short on memory (running DOS, for example, where you only have 640K). +Note that the memory level does have an effect on compression; among +other things, lower levels will result in sections of incompressible +data being emitted in smaller stored blocks, with a correspondingly +larger relative overhead of up to 15% in the worst case. + + png_set_compression_mem_level(png_ptr, level); + +The other functions are for configuring zlib. They are not recommended +for normal use and may result in writing an invalid PNG file. See +zlib.h for more information on what these mean. + + png_set_compression_strategy(png_ptr, + strategy); + png_set_compression_window_bits(png_ptr, + window_bits); + png_set_compression_method(png_ptr, method); + png_set_compression_buffer_size(png_ptr, size); + +.SS Controlling row filtering + +If you want to control whether libpng uses filtering or not, which +filters are used, and how it goes about picking row filters, you +can call one of these functions. The selection and configuration +of row filters can have a significant impact on the size and +encoding speed and a somewhat lesser impact on the decoding speed +of an image. Filtering is enabled by default for RGB and grayscale +images (with and without alpha), but not for paletted images nor +for any images with bit depths less than 8 bits/pixel. + +The 'method' parameter sets the main filtering method, which is +currently only '0' in the PNG 1.2 specification. The 'filters' +parameter sets which filter(s), if any, should be used for each +scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS +to turn filtering on and off, respectively. + +Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, +PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise +ORed together with '|' to specify one or more filters to use. +These filters are described in more detail in the PNG specification. +If you intend to change the filter type during the course of writing +the image, you should start with flags set for all of the filters +you intend to use so that libpng can initialize its internal +structures appropriately for all of the filter types. (Note that this +means the first row must always be adaptively filtered, because libpng +currently does not allocate the filter buffers until png_write_row() +is called for the first time.) + + filters = PNG_FILTER_NONE | PNG_FILTER_SUB + PNG_FILTER_UP | PNG_FILTER_AVE | + PNG_FILTER_PAETH | PNG_ALL_FILTERS; + + png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, + filters); + The second parameter can also be + PNG_INTRAPIXEL_DIFFERENCING if you are + writing a PNG to be embedded in a MNG + datastream. This parameter must be the + same as the value of filter_method used + in png_set_IHDR(). + +It is also possible to influence how libpng chooses from among the +available filters. This is done in one or both of two ways - by +telling it how important it is to keep the same filter for successive +rows, and by telling it the relative computational costs of the filters. + + double weights[3] = {1.5, 1.3, 1.1}, + costs[PNG_FILTER_VALUE_LAST] = + {1.0, 1.3, 1.3, 1.5, 1.7}; + + png_set_filter_heuristics(png_ptr, + PNG_FILTER_HEURISTIC_WEIGHTED, 3, + weights, costs); + +The weights are multiplying factors that indicate to libpng that the +row filter should be the same for successive rows unless another row filter +is that many times better than the previous filter. In the above example, +if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a +"sum of absolute differences" 1.5 x 1.3 times higher than other filters +and still be chosen, while the NONE filter could have a sum 1.1 times +higher than other filters and still be chosen. Unspecified weights are +taken to be 1.0, and the specified weights should probably be declining +like those above in order to emphasize recent filters over older filters. + +The filter costs specify for each filter type a relative decoding cost +to be considered when selecting row filters. This means that filters +with higher costs are less likely to be chosen over filters with lower +costs, unless their "sum of absolute differences" is that much smaller. +The costs do not necessarily reflect the exact computational speeds of +the various filters, since this would unduly influence the final image +size. + +Note that the numbers above were invented purely for this example and +are given only to help explain the function usage. Little testing has +been done to find optimum values for either the costs or the weights. + +.SS Removing unwanted object code + +There are a bunch of #define's in pngconf.h that control what parts of +libpng are compiled. All the defines end in _SUPPORTED. If you are +never going to use a capability, you can change the #define to #undef +before recompiling libpng and save yourself code and data space, or +you can turn off individual capabilities with defines that begin with +PNG_NO_. + +You can also turn all of the transforms and ancillary chunk capabilities +off en masse with compiler directives that define +PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, +or all four, +along with directives to turn on any of the capabilities that you do +want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable +the extra transformations but still leave the library fully capable of reading +and writing PNG files with all known public chunks +Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive +produces a library that is incapable of reading or writing ancillary chunks. +If you are not using the progressive reading capability, you can +turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse +this with the INTERLACING capability, which you'll still have). + +All the reading and writing specific code are in separate files, so the +linker should only grab the files it needs. However, if you want to +make sure, or if you are building a stand alone library, all the +reading files start with pngr and all the writing files start with +pngw. The files that don't match either (like png.c, pngtrans.c, etc.) +are used for both reading and writing, and always need to be included. +The progressive reader is in pngpread.c + +If you are creating or distributing a dynamically linked library (a .so +or DLL file), you should not remove or disable any parts of the library, +as this will cause applications linked with different versions of the +library to fail if they call functions not available in your library. +The size of the library itself should not be an issue, because only +those sections that are actually used will be loaded into memory. + +.SS Requesting debug printout + +The macro definition PNG_DEBUG can be used to request debugging +printout. Set it to an integer value in the range 0 to 3. Higher +numbers result in increasing amounts of debugging information. The +information is printed to the "stderr" file, unless another file +name is specified in the PNG_DEBUG_FILE macro definition. + +When PNG_DEBUG > 0, the following functions (macros) become available: + + png_debug(level, message) + png_debug1(level, message, p1) + png_debug2(level, message, p1, p2) + +in which "level" is compared to PNG_DEBUG to decide whether to print +the message, "message" is the formatted string to be printed, +and p1 and p2 are parameters that are to be embedded in the string +according to printf-style formatting directives. For example, + + png_debug1(2, "foo=%d\n", foo); + +is expanded to + + if(PNG_DEBUG > 2) + fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); + +When PNG_DEBUG is defined but is zero, the macros aren't defined, but you +can still use PNG_DEBUG to control your own debugging: + + #ifdef PNG_DEBUG + fprintf(stderr, ... + #endif + +When PNG_DEBUG = 1, the macros are defined, but only png_debug statements +having level = 0 will be printed. There aren't any such statements in +this version of libpng, but if you insert some they will be printed. + +.SH VI. Runtime optimization + +A new feature in libpng 1.2.0 is the ability to dynamically switch between +standard and optimized versions of some routines. Currently these are +limited to three computationally intensive tasks when reading PNG files: +decoding row filters, expanding interlacing, and combining interlaced or +transparent row data with previous row data. Currently the optimized +versions are available only for x86 (Intel, AMD, etc.) platforms with +MMX support, though this may change in future versions. (For example, +the non-MMX assembler optimizations for zlib might become similarly +runtime-selectable in future releases, in which case libpng could be +extended to support them. Alternatively, the compile-time choice of +floating-point versus integer routines for gamma correction might become +runtime-selectable.) + +Because such optimizations tend to be very platform- and compiler-dependent, +both in how they are written and in how they perform, the new runtime code +in libpng has been written to allow programs to query, enable, and disable +either specific optimizations or all such optimizations. For example, to +enable all possible optimizations (bearing in mind that some "optimizations" +may actually run more slowly in rare cases): + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + png_uint_32 mask, flags; + + flags = png_get_asm_flags(png_ptr); + mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); + png_set_asm_flags(png_ptr, flags | mask); + #endif + +To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ +by itself when calling png_get_asm_flagmask(); similarly for optimizing +only writing. To disable all optimizations: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + flags = png_get_asm_flags(png_ptr); + mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); + png_set_asm_flags(png_ptr, flags & ~mask); + #endif + +To enable or disable only MMX-related features, use png_get_mmx_flagmask() +in place of png_get_asm_flagmask(). The mmx version takes one additional +parameter: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + int selection = PNG_SELECT_READ | PNG_SELECT_WRITE; + int compilerID; + + mask = png_get_mmx_flagmask(selection, &compilerID); + #endif + +On return, compilerID will indicate which version of the MMX assembler +optimizations was compiled. Currently two flavors exist: Microsoft +Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2). +On non-x86 platforms or on systems compiled without MMX optimizations, a +value of -1 is used. + +Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return +all valid, settable optimization bits for the version of the library that's +currently in use. In the case of shared (dynamically linked) libraries, +this may include optimizations that did not exist at the time the code was +written and compiled. It is also possible, of course, to enable only known, +specific optimizations; for example: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + flags = PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ + | PNG_ASM_FLAG_MMX_READ_INTERLACE \ + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ + | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; + png_set_asm_flags(png_ptr, flags); + #endif + +This method would enable only the MMX read-optimizations available at the +time of libpng 1.2.0's release, regardless of whether a later version of +the DLL were actually being used. (Also note that these functions did not +exist in versions older than 1.2.0, so any attempt to run a dynamically +linked app on such an older version would fail.) + +To determine whether the processor supports MMX instructions at all, use +the png_mmx_support() function: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + mmxsupport = png_mmx_support(); + #endif + +It returns -1 if MMX support is not compiled into libpng, 0 if MMX code +is compiled but MMX is not supported by the processor, or 1 if MMX support +is fully available. Note that png_mmx_support(), png_get_mmx_flagmask(), +and png_get_asm_flagmask() all may be called without allocating and ini- +tializing any PNG structures (for example, as part of a usage screen or +"about" box). + +The following code can be used to prevent an application from using the +thread_unsafe features, even if libpng was built with PNG_THREAD_UNSAFE_OK +defined: + +#if defined(PNG_USE_PNGGCCRD) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) \ + && defined(PNG_THREAD_UNSAFE_OK) + /* Disable thread-unsafe features of pnggccrd */ + if (png_access_version_number() >= 10200) + { + png_uint_32 mmx_disable_mask = 0; + png_uint_32 asm_flags; + + mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); + asm_flags = png_get_asm_flags(png_ptr); + png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask); + } +#endif + +For more extensive examples of runtime querying, enabling and disabling +of optimized features, see contrib/gregbook/readpng2.c in the libpng +source-code distribution. + +.SH VII. MNG support + +The MNG specification (available at http://www.libpng.org/pub/mng) allows +certain extensions to PNG for PNG images that are embedded in MNG datastreams. +Libpng can support some of these extensions. To enable them, use the +png_permit_mng_features() function: + + feature_set = png_permit_mng_features(png_ptr, mask) + mask is a png_uint_32 containing the bitwise OR of the + features you want to enable. These include + PNG_FLAG_MNG_EMPTY_PLTE + PNG_FLAG_MNG_FILTER_64 + PNG_ALL_MNG_FEATURES + feature_set is a png_uint_32 that is the bitwise AND of + your mask with the set of MNG features that is + supported by the version of libpng that you are using. + +It is an error to use this function when reading or writing a standalone +PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped +in a MNG datastream. As a minimum, it must have the MNG 8-byte signature +and the MHDR and MEND chunks. Libpng does not provide support for these +or any other MNG chunks; your application must provide its own support for +them. You may wish to consider using libmng (available at +http://www.libmng.com) instead. + +.SH VIII. Changes to Libpng from version 0.88 + +It should be noted that versions of libpng later than 0.96 are not +distributed by the original libpng author, Guy Schalnat, nor by +Andreas Dilger, who had taken over from Guy during 1996 and 1997, and +distributed versions 0.89 through 0.96, but rather by another member +of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are +still alive and well, but they have moved on to other things. + +The old libpng functions png_read_init(), png_write_init(), +png_info_init(), png_read_destroy(), and png_write_destroy() have been +moved to PNG_INTERNAL in version 0.95 to discourage their use. These +functions will be removed from libpng version 2.0.0. + +The preferred method of creating and initializing the libpng structures is +via the png_create_read_struct(), png_create_write_struct(), and +png_create_info_struct() because they isolate the size of the structures +from the application, allow version error checking, and also allow the +use of custom error handling routines during the initialization, which +the old functions do not. The functions png_read_destroy() and +png_write_destroy() do not actually free the memory that libpng +allocated for these structs, but just reset the data structures, so they +can be used instead of png_destroy_read_struct() and +png_destroy_write_struct() if you feel there is too much system overhead +allocating and freeing the png_struct for each image read. + +Setting the error callbacks via png_set_message_fn() before +png_read_init() as was suggested in libpng-0.88 is no longer supported +because this caused applications that do not use custom error functions +to fail if the png_ptr was not initialized to zero. It is still possible +to set the error callbacks AFTER png_read_init(), or to change them with +png_set_error_fn(), which is essentially the same function, but with a new +name to force compilation errors with applications that try to use the old +method. + +Starting with version 1.0.7, you can find out which version of the library +you are using at run-time: + + png_uint_32 libpng_vn = png_access_version_number(); + +The number libpng_vn is constructed from the major version, minor +version with leading zero, and release number with leading zero, +(e.g., libpng_vn for version 1.0.7 is 10007). + +You can also check which version of png.h you used when compiling your +application: + + png_uint_32 application_vn = PNG_LIBPNG_VER; + +.SH IX. Y2K Compliance in libpng + +January 31, 2007 + +Since the PNG Development group is an ad-hoc body, we can't make +an official declaration. + +This is your unofficial assurance that libpng from version 0.71 and +upward through 1.2.16 are Y2K compliant. It is my belief that earlier +versions were also Y2K compliant. + +Libpng only has three year fields. One is a 2-byte unsigned integer that +will hold years up to 65535. The other two hold the date in text +format, and will hold years up to 9999. + +The integer is + "png_uint_16 year" in png_time_struct. + +The strings are + "png_charp time_buffer" in png_struct and + "near_time_buffer", which is a local character string in png.c. + +There are seven time-related functions: + + png_convert_to_rfc_1123() in png.c + (formerly png_convert_to_rfc_1152() in error) + png_convert_from_struct_tm() in pngwrite.c, called + in pngwrite.c + png_convert_from_time_t() in pngwrite.c + png_get_tIME() in pngget.c + png_handle_tIME() in pngrutil.c, called in pngread.c + png_set_tIME() in pngset.c + png_write_tIME() in pngwutil.c, called in pngwrite.c + +All appear to handle dates properly in a Y2K environment. The +png_convert_from_time_t() function calls gmtime() to convert from system +clock time, which returns (year - 1900), which we properly convert to +the full 4-digit year. There is a possibility that applications using +libpng are not passing 4-digit years into the png_convert_to_rfc_1123() +function, or that they are incorrectly passing only a 2-digit year +instead of "year - 1900" into the png_convert_from_struct_tm() function, +but this is not under our control. The libpng documentation has always +stated that it works with 4-digit years, and the APIs have been +documented as such. + +The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned +integer to hold the year, and can hold years as large as 65535. + +zlib, upon which libpng depends, is also Y2K compliant. It contains +no date-related code. + + + Glenn Randers-Pehrson + libpng maintainer + PNG Development Group + +.SH NOTE + +Note about libpng version numbers: + +Due to various miscommunications, unforeseen code incompatibilities +and occasional factors outside the authors' control, version numbering +on the library has not always been consistent and straightforward. +The following table summarizes matters since version 0.89c, which was +the first widely used release: + + source png.h png.h shared-lib + version string int version + ------- ------ ----- ---------- + 0.89c ("beta 3") 0.89 89 1.0.89 + 0.90 ("beta 4") 0.90 90 0.90 + 0.95 ("beta 5") 0.95 95 0.95 + 0.96 ("beta 6") 0.96 96 0.96 + 0.97b ("beta 7") 1.00.97 97 1.0.1 + 0.97c 0.97 97 2.0.97 + 0.98 0.98 98 2.0.98 + 0.99 0.99 98 2.0.99 + 0.99a-m 0.99 99 2.0.99 + 1.00 1.00 100 2.1.0 + 1.0.0 1.0.0 100 2.1.0 + 1.0.0 (from here on, the 100 2.1.0 + 1.0.1 png.h string is 10001 2.1.0 + 1.0.1a-e identical to the 10002 from here on, the + 1.0.2 source version) 10002 shared library is 2.V + 1.0.2a-b 10003 where V is the source + 1.0.1 10001 code version except as + 1.0.1a-e 10002 2.1.0.1a-e noted. + 1.0.2 10002 2.1.0.2 + 1.0.2a-b 10003 2.1.0.2a-b + 1.0.3 10003 2.1.0.3 + 1.0.3a-d 10004 2.1.0.3a-d + 1.0.4 10004 2.1.0.4 + 1.0.4a-f 10005 2.1.0.4a-f + 1.0.5 (+ 2 patches) 10005 2.1.0.5 + 1.0.5a-d 10006 2.1.0.5a-d + 1.0.5e-r 10100 2.1.0.5e-r + 1.0.5s-v 10006 2.1.0.5s-v + 1.0.6 (+ 3 patches) 10006 2.1.0.6 + 1.0.6d-g 10007 2.1.0.6d-g + 1.0.6h 10007 10.6h + 1.0.6i 10007 10.6i + 1.0.6j 10007 2.1.0.6j + 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 + 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 + 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 + 1.0.7 1 10007 2.1.0.7 + 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 + 1.0.8rc1 1 10008 2.1.0.8rc1 + 1.0.8 1 10008 2.1.0.8 + 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 + 1.0.9rc1 1 10009 2.1.0.9rc1 + 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 + 1.0.9rc2 1 10009 2.1.0.9rc2 + 1.0.9 1 10009 2.1.0.9 + 1.0.10beta1 1 10010 2.1.0.10beta1 + 1.0.10rc1 1 10010 2.1.0.10rc1 + 1.0.10 1 10010 2.1.0.10 + 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 + 1.0.11rc1 1 10011 2.1.0.11rc1 + 1.0.11 1 10011 2.1.0.11 + 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 + 1.0.12rc1 2 10012 2.1.0.12rc1 + 1.0.12 2 10012 2.1.0.12 + 1.1.0a-f - 10100 2.1.1.0a-f abandoned + 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 + 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 + 1.2.0rc1 3 10200 3.1.2.0rc1 + 1.2.0 3 10200 3.1.2.0 + 1.2.1beta-4 3 10201 3.1.2.1beta1-4 + 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 + 1.2.1 3 10201 3.1.2.1 + 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 + 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 + 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 + 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 + 1.0.13 10 10013 10.so.0.1.0.13 + 1.2.2 12 10202 12.so.0.1.2.2 + 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 + 1.2.3 12 10203 12.so.0.1.2.3 + 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 + 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 + 1.0.14 10 10014 10.so.0.1.0.14 + 1.2.4 13 10204 12.so.0.1.2.4 + 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 + 1.0.15rc1 10 10015 10.so.0.1.0.15rc1 + 1.0.15 10 10015 10.so.0.1.0.15 + 1.2.5 13 10205 12.so.0.1.2.5 + 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 + 1.2.6rc1-5 13 10206 12.so.0.1.2.6rc1-5 + 1.0.16 10 10016 10.so.0.1.0.16 + 1.2.6 13 10206 12.so.0.1.2.6 + 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 + 1.0.17rc1 10 10017 10.so.0.1.0.17rc1 + 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 + 1.0.17 10 10017 10.so.0.1.0.17 + 1.2.7 13 10207 12.so.0.1.2.7 + 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 + 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5 + 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 + 1.0.18 10 10018 10.so.0.1.0.18 + 1.2.8 13 10208 12.so.0.1.2.8 + 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 + 1.2.9beta4-11 13 10209 12.so.0.9[.0] + 1.2.9rc1 13 10209 12.so.0.9[.0] + 1.2.9 13 10209 12.so.0.9[.0] + 1.2.10beta1-8 13 10210 12.so.0.10[.0] + 1.2.10rc1-3 13 10210 12.so.0.10[.0] + 1.2.10 13 10210 12.so.0.10[.0] + 1.2.11beta1-4 13 10211 12.so.0.11[.0] + 1.0.19rc1-5 10 10019 10.so.0.19[.0] + 1.2.11rc1-5 13 10211 12.so.0.11[.0] + 1.0.19 10 10019 10.so.0.19[.0] + 1.2.11 13 10211 12.so.0.11[.0] + 1.0.20 10 10020 10.so.0.20[.0] + 1.2.12 13 10212 12.so.0.12[.0] + 1.2.13beta1 13 10213 12.so.0.13[.0] + 1.0.21 10 10021 10.so.0.21[.0] + 1.2.13 13 10213 12.so.0.13[.0] + 1.2.14beta1-2 13 10214 12.so.0.14[.0] + 1.0.22rc1 10 10022 10.so.0.22[.0] + 1.2.14rc1 13 10214 12.so.0.14[.0] + 1.2.15beta1-6 13 10215 12.so.0.15[.0] + 1.0.23rc1-5 10 10023 10.so.0.23[.0] + 1.2.15rc1-5 13 10215 12.so.0.15[.0] + 1.0.23 10 10023 10.so.0.23[.0] + 1.2.15 13 10215 12.so.0.15[.0] + 1.2.16beta1-2 13 10216 12.so.0.16[.0] + 1.2.16rc1 13 10216 12.so.0.16[.0] + 1.0.24 10 10024 10.so.0.24[.0] + 1.2.16 13 10216 12.so.0.16[.0] + +Henceforth the source version will match the shared-library minor +and patch numbers; the shared-library major version number will be +used for changes in backward compatibility, as it is intended. The +PNG_PNGLIB_VER macro, which is not used within libpng but is available +for applications, is an unsigned integer of the form xyyzz corresponding +to the source version x.y.z (leading zeros in y and z). Beta versions +were given the previous public release number plus a letter, until +version 1.0.6j; from then on they were given the upcoming public +release number plus "betaNN" or "rcN". + +.SH "SEE ALSO" +libpngpf(3), png(5) +.LP +.IR libpng : +.IP +http://libpng.sourceforge.net (follow the [DOWNLOAD] link) +http://www.libpng.org/pub/png + +.LP +.IR zlib : +.IP +(generally) at the same location as +.I libpng +or at +.br +ftp://ftp.info-zip.org/pub/infozip/zlib + +.LP +.IR PNG specification: RFC 2083 +.IP +(generally) at the same location as +.I libpng +or at +.br +ftp://ds.internic.net/rfc/rfc2083.txt +.br +or (as a W3C Recommendation) at +.br +http://www.w3.org/TR/REC-png.html + +.LP +In the case of any inconsistency between the PNG specification +and this library, the specification takes precedence. + +.SH AUTHORS +This man page: Glenn Randers-Pehrson + + +The contributing authors would like to thank all those who helped +with testing, bug fixes, and patience. This wouldn't have been +possible without all of you. + +Thanks to Frank J. T. Wojcik for helping with the documentation. + +Libpng version 1.2.16 - January 31, 2007: +Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. +Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). + +Supported by the PNG development group +.br +png-mng-implement at lists.sf.net +(subscription required; visit +png-mng-implement at lists.sourceforge.net (subscription required; visit +https://lists.sourceforge.net/lists/listinfo/png-mng-implement +to subscribe). + +.SH COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: + +(This copy of the libpng notices is provided for your convenience. In case of +any discrepancy between this copy and the notices in the file png.h that is +included in the libpng distribution, the latter shall prevail.) + +If you modify libpng you may insert additional notices immediately following +this sentence. + +libpng versions 1.2.6, August 15, 2004, through 1.2.16, January 31, 2007, are +Copyright (c) 2004-2006 Glenn Randers-Pehrson, and are +distributed according to the same disclaimer and license as libpng-1.2.5 +with the following individual added to the list of Contributing Authors + + Cosmin Truta + +libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are +Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are +distributed according to the same disclaimer and license as libpng-1.0.6 +with the following individuals added to the list of Contributing Authors + + Simon-Pierre Cadieux + Eric S. Raymond + Gilles Vollant + +and with the following additions to the disclaimer: + + There is no warranty against interference with your + enjoyment of the library or against infringement. + There is no warranty that our efforts or the library + will fulfill any of your particular purposes or needs. + This library is provided with all faults, and the entire + risk of satisfactory quality, performance, accuracy, and + effort is with the user. + +libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are +Copyright (c) 1998, 1999 Glenn Randers-Pehrson +Distributed according to the same disclaimer and license as libpng-0.96, +with the following individuals added to the list of Contributing Authors: + + Tom Lane + Glenn Randers-Pehrson + Willem van Schaik + +libpng versions 0.89, June 1996, through 0.96, May 1997, are +Copyright (c) 1996, 1997 Andreas Dilger +Distributed according to the same disclaimer and license as libpng-0.88, +with the following individuals added to the list of Contributing Authors: + + John Bowler + Kevin Bracey + Sam Bushell + Magnus Holmgren + Greg Roelofs + Tom Tanner + +libpng versions 0.5, May 1995, through 0.88, January 1996, are +Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. + +For the purposes of this copyright and license, "Contributing Authors" +is defined as the following set of individuals: + + Andreas Dilger + Dave Martindale + Guy Eric Schalnat + Paul Schmidt + Tim Wegner + +The PNG Reference Library is supplied "AS IS". The Contributing Authors +and Group 42, Inc. disclaim all warranties, expressed or implied, +including, without limitation, the warranties of merchantability and of +fitness for any purpose. The Contributing Authors and Group 42, Inc. +assume no liability for direct, indirect, incidental, special, exemplary, +or consequential damages, which may result from the use of the PNG +Reference Library, even if advised of the possibility of such damage. + +Permission is hereby granted to use, copy, modify, and distribute this +source code, or portions hereof, for any purpose, without fee, subject +to the following restrictions: + +1. The origin of this source code must not be misrepresented. + +2. Altered versions must be plainly marked as such and + must not be misrepresented as being the original source. + +3. This Copyright notice may not be removed or altered from + any source or altered source distribution. + +The Contributing Authors and Group 42, Inc. specifically permit, without +fee, and encourage the use of this source code as a component to +supporting the PNG file format in commercial products. If you use this +source code in a product, acknowledgment is not required but would be +appreciated. + + +A "png_get_copyright" function is available, for convenient use in "about" +boxes and the like: + + printf("%s",png_get_copyright(NULL)); + +Also, the PNG logo (in PNG format, of course) is supplied in the +files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). + +Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a +certification mark of the Open Source Initiative. + +Glenn Randers-Pehrson +glennrp at users.sourceforge.net +January 31, 2007 + +.\" end of man page + diff --git a/src/dep/src/irrlicht/libpng/libpngpf.3 b/src/dep/src/irrlicht/libpng/libpngpf.3 index 68c44ee..ec4813b 100644 --- a/src/dep/src/irrlicht/libpng/libpngpf.3 +++ b/src/dep/src/irrlicht/libpng/libpngpf.3 @@ -1,274 +1,274 @@ -.TH LIBPNGPF 3 "January 31, 2007" -.SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.2.16 -(private functions) -.SH SYNOPSIS -\fB#include \fP - -\fBvoid png_build_gamma_table (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_build_grayscale_palette (int \fP\fIbit_depth\fP\fB, png_colorp \fIpalette\fP\fB);\fP - -\fBvoid png_calculate_crc (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIptr\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBvoid png_check_chunk_name (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP - -\fBpng_size_t png_check_keyword (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charpp \fInew_key\fP\fB);\fP - -\fBvoid png_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fImask\fP\fB);\fP - -\fBvoid png_correct_palette (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP - -\fBint png_crc_error (png_structp \fIpng_ptr\fP\fB);\fP - -\fBint png_crc_finish (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIskip\fP\fB);\fP - -\fBvoid png_crc_read (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuf\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBpng_voidp png_create_struct (int \fItype\fP\fB);\fP - -\fBpng_voidp png_create_struct_2 (int \fP\fItype\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP - -\fBpng_charp png_decompress_chunk (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcomp_type\fP\fB, png_charp \fP\fIchunkdata\fP\fB, png_size_t \fP\fIchunklength\fP\fB, png_size_t \fP\fIprefix_length\fP\fB, png_size_t \fI*data_length\fP\fB);\fP - -\fBvoid png_destroy_struct (png_voidp \fIstruct_ptr\fP\fB);\fP - -\fBvoid png_destroy_struct_2 (png_voidp \fP\fIstruct_ptr\fP\fB, png_free_ptr \fP\fIfree_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP - -\fBvoid png_do_background (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fP\fItrans_values\fP\fB, png_color_16p \fP\fIbackground\fP\fB, png_color_16p \fP\fIbackground_1\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_bytep \fP\fIgamma_from_1\fP\fB, png_bytep \fP\fIgamma_to_1\fP\fB, png_uint_16pp \fP\fIgamma_16\fP\fB, png_uint_16pp \fP\fIgamma_16_from_1\fP\fB, png_uint_16pp \fP\fIgamma_16_to_1\fP\fB, int \fIgamma_shift\fP\fB);\fP - -\fBvoid png_do_bgr (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_chop (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_dither (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIpalette_lookup\fP\fB, png_bytep \fIdither_lookup\fP\fB);\fP - -\fBvoid png_do_expand (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fItrans_value\fP\fB);\fP - -\fBvoid png_do_expand_palette (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fInum_trans\fP\fB);\fP - -\fBvoid png_do_gamma (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_uint_16pp \fP\fIgamma_16_table\fP\fB, int \fIgamma_shift\fP\fB);\fP - -\fBvoid png_do_gray_to_rgb (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_invert (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_pack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIbit_depth\fP\fB);\fP - -\fBvoid png_do_packswap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_read_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, png_uint_32 \fIflags\fP\fB);\fP - -\fBvoid png_do_read_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fP\fIpass\fP\fB, png_uint_32 \fItransformations\fP\fB);\fP - -\fBvoid png_do_read_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_read_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP - -\fBint png_do_rgb_to_gray (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_shift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIbit_depth\fP\fB);\fP - -\fBvoid png_do_strip_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIflags\fP\fB);\fP - -\fBvoid png_do_swap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_unpack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_unshift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIsig_bits\fP\fB);\fP - -\fBvoid png_do_write_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fIpass\fP\fB);\fP - -\fBvoid png_do_write_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_write_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_write_transformations (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid *png_far_to_near (png_structp png_ptr,png_voidp \fP\fIptr\fP\fB, int \fIcheck\fP\fB);\fP - -\fBvoid png_flush (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_handle_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_IEND (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_iTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_info_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_init_mmx_flags (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_init_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_process_IDAT_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP - -\fBvoid png_process_some_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_check_crc (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_push_crc_finish (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_push_crc_skip (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_push_fill_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBvoid png_push_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_push_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_push_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_push_have_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_have_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_have_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_push_process_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_push_read_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_read_IDAT (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_push_read_sig (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_read_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_read_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_restore_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP - -\fBvoid png_push_save_buffer (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_read_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBvoid png_read_filter_row (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIprev_row\fP\fB, int \fIfilter\fP\fB);\fP - -\fBvoid png_read_finish_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_read_start_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_read_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_reset_crc (png_structp \fIpng_ptr\fP\fB);\fP - -\fBint png_set_text_2 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text\fP\fB);\fP - -\fBvoid png_write_cHRM (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP - -\fBvoid png_write_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP - -\fBvoid png_write_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBvoid png_write_filtered_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIfiltered_row\fP\fB);\fP - -\fBvoid png_write_find_filter (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fIrow_info\fP\fB);\fP - -\fBvoid png_write_finish_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_write_gAMA (png_structp \fP\fIpng_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP - -\fBvoid png_write_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIint_file_gamma\fP\fB);\fP - -\fBvoid png_write_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_uint_16p \fP\fIhist\fP\fB, int \fInum_hist\fP\fB);\fP - -\fBvoid png_write_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, int \fIproflen\fP\fB);\fP - -\fBvoid png_write_IDAT (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBvoid png_write_IEND (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_write_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fP\fIfilter_type\fP\fB, int \fIinterlace_type\fP\fB);\fP - -\fBvoid png_write_iTXt (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcompression\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fIlang\fP\fB, png_charp \fP\fItranslated_key\fP\fB, png_charp \fItext\fP\fB);\fP - -\fBvoid png_write_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_offset\fP\fB, png_uint_32 \fP\fIy_offset\fP\fB, int \fIunit_type\fP\fB);\fP - -\fBvoid png_write_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP - -\fBvoid png_write_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_pixels_per_unit\fP\fB, png_uint_32 \fP\fIy_pixels_per_unit\fP\fB, int \fIunit_type\fP\fB);\fP - -\fBvoid png_write_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_uint_32 \fInum_pal\fP\fB);\fP - -\fBvoid png_write_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fP\fIsbit\fP\fB, int \fIcolor_type\fP\fB);\fP - -\fBvoid png_write_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP - -\fBvoid png_write_sCAL_s (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, png_charp \fP\fIwidth\fP\fB, png_charp \fIheight\fP\fB);\fP - -\fBvoid png_write_sig (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_write_sRGB (png_structp \fP\fIpng_ptr\fP\fB, int \fIintent\fP\fB);\fP - -\fBvoid png_write_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_spalette_p \fIpalette\fP\fB);\fP - -\fBvoid png_write_start_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_write_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fItext_len\fP\fB);\fP - -\fBvoid png_write_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP - -\fBvoid png_write_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, png_color_16p \fP\fIvalues\fP\fB, int \fP\fInumber\fP\fB, int \fIcolor_type\fP\fB);\fP - -\fBvoid png_write_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fP\fItext_len\fP\fB, int \fIcompression\fP\fB);\fP - -\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP - -\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP - -\fI\fB - -.SH DESCRIPTION -The functions listed above are used privately by libpng -and are not recommended for use by applications. They are -not "exported" to applications using shared libraries. They -are listed alphabetically here as an aid to libpng maintainers. -See png.h for more information on these functions. - -.SH SEE ALSO -libpng(3), png(5) -.SH AUTHOR -Glenn Randers-Pehrson +.TH LIBPNGPF 3 "January 31, 2007" +.SH NAME +libpng \- Portable Network Graphics (PNG) Reference Library 1.2.16 +(private functions) +.SH SYNOPSIS +\fB#include \fP + +\fBvoid png_build_gamma_table (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_build_grayscale_palette (int \fP\fIbit_depth\fP\fB, png_colorp \fIpalette\fP\fB);\fP + +\fBvoid png_calculate_crc (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIptr\fP\fB, png_size_t \fIlength\fP\fB);\fP + +\fBvoid png_check_chunk_name (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP + +\fBpng_size_t png_check_keyword (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charpp \fInew_key\fP\fB);\fP + +\fBvoid png_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fImask\fP\fB);\fP + +\fBvoid png_correct_palette (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP + +\fBint png_crc_error (png_structp \fIpng_ptr\fP\fB);\fP + +\fBint png_crc_finish (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIskip\fP\fB);\fP + +\fBvoid png_crc_read (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuf\fP\fB, png_size_t \fIlength\fP\fB);\fP + +\fBpng_voidp png_create_struct (int \fItype\fP\fB);\fP + +\fBpng_voidp png_create_struct_2 (int \fP\fItype\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP + +\fBpng_charp png_decompress_chunk (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcomp_type\fP\fB, png_charp \fP\fIchunkdata\fP\fB, png_size_t \fP\fIchunklength\fP\fB, png_size_t \fP\fIprefix_length\fP\fB, png_size_t \fI*data_length\fP\fB);\fP + +\fBvoid png_destroy_struct (png_voidp \fIstruct_ptr\fP\fB);\fP + +\fBvoid png_destroy_struct_2 (png_voidp \fP\fIstruct_ptr\fP\fB, png_free_ptr \fP\fIfree_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP + +\fBvoid png_do_background (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fP\fItrans_values\fP\fB, png_color_16p \fP\fIbackground\fP\fB, png_color_16p \fP\fIbackground_1\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_bytep \fP\fIgamma_from_1\fP\fB, png_bytep \fP\fIgamma_to_1\fP\fB, png_uint_16pp \fP\fIgamma_16\fP\fB, png_uint_16pp \fP\fIgamma_16_from_1\fP\fB, png_uint_16pp \fP\fIgamma_16_to_1\fP\fB, int \fIgamma_shift\fP\fB);\fP + +\fBvoid png_do_bgr (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fBvoid png_do_chop (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fBvoid png_do_dither (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIpalette_lookup\fP\fB, png_bytep \fIdither_lookup\fP\fB);\fP + +\fBvoid png_do_expand (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fItrans_value\fP\fB);\fP + +\fBvoid png_do_expand_palette (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fInum_trans\fP\fB);\fP + +\fBvoid png_do_gamma (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_uint_16pp \fP\fIgamma_16_table\fP\fB, int \fIgamma_shift\fP\fB);\fP + +\fBvoid png_do_gray_to_rgb (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fBvoid png_do_invert (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fBvoid png_do_pack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIbit_depth\fP\fB);\fP + +\fBvoid png_do_packswap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fBvoid png_do_read_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, png_uint_32 \fIflags\fP\fB);\fP + +\fBvoid png_do_read_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fP\fIpass\fP\fB, png_uint_32 \fItransformations\fP\fB);\fP + +\fBvoid png_do_read_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fBvoid png_do_read_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fBvoid png_do_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP + +\fBint png_do_rgb_to_gray (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fBvoid png_do_shift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIbit_depth\fP\fB);\fP + +\fBvoid png_do_strip_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIflags\fP\fB);\fP + +\fBvoid png_do_swap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fBvoid png_do_unpack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fBvoid png_do_unshift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIsig_bits\fP\fB);\fP + +\fBvoid png_do_write_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fIpass\fP\fB);\fP + +\fBvoid png_do_write_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fBvoid png_do_write_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fBvoid png_do_write_transformations (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid *png_far_to_near (png_structp png_ptr,png_voidp \fP\fIptr\fP\fB, int \fIcheck\fP\fB);\fP + +\fBvoid png_flush (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_handle_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_IEND (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_iTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_info_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_init_mmx_flags (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_init_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_process_IDAT_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP + +\fBvoid png_process_some_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_push_check_crc (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_push_crc_finish (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_push_crc_skip (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_push_fill_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIlength\fP\fB);\fP + +\fBvoid png_push_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_push_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_push_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fBvoid png_push_have_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_push_have_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_push_have_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fBvoid png_push_process_row (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_push_read_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_push_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_push_read_IDAT (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_push_read_sig (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_push_read_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_push_read_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_push_restore_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP + +\fBvoid png_push_save_buffer (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_read_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP + +\fBvoid png_read_filter_row (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIprev_row\fP\fB, int \fIfilter\fP\fB);\fP + +\fBvoid png_read_finish_row (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_read_start_row (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_read_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fBvoid png_reset_crc (png_structp \fIpng_ptr\fP\fB);\fP + +\fBint png_set_text_2 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text\fP\fB);\fP + +\fBvoid png_write_cHRM (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP + +\fBvoid png_write_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP + +\fBvoid png_write_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP + +\fBvoid png_write_filtered_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIfiltered_row\fP\fB);\fP + +\fBvoid png_write_find_filter (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fIrow_info\fP\fB);\fP + +\fBvoid png_write_finish_row (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_write_gAMA (png_structp \fP\fIpng_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP + +\fBvoid png_write_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIint_file_gamma\fP\fB);\fP + +\fBvoid png_write_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_uint_16p \fP\fIhist\fP\fB, int \fInum_hist\fP\fB);\fP + +\fBvoid png_write_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, int \fIproflen\fP\fB);\fP + +\fBvoid png_write_IDAT (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP + +\fBvoid png_write_IEND (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_write_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fP\fIfilter_type\fP\fB, int \fIinterlace_type\fP\fB);\fP + +\fBvoid png_write_iTXt (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcompression\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fIlang\fP\fB, png_charp \fP\fItranslated_key\fP\fB, png_charp \fItext\fP\fB);\fP + +\fBvoid png_write_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_offset\fP\fB, png_uint_32 \fP\fIy_offset\fP\fB, int \fIunit_type\fP\fB);\fP + +\fBvoid png_write_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP + +\fBvoid png_write_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_pixels_per_unit\fP\fB, png_uint_32 \fP\fIy_pixels_per_unit\fP\fB, int \fIunit_type\fP\fB);\fP + +\fBvoid png_write_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_uint_32 \fInum_pal\fP\fB);\fP + +\fBvoid png_write_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fP\fIsbit\fP\fB, int \fIcolor_type\fP\fB);\fP + +\fBvoid png_write_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP + +\fBvoid png_write_sCAL_s (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, png_charp \fP\fIwidth\fP\fB, png_charp \fIheight\fP\fB);\fP + +\fBvoid png_write_sig (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_write_sRGB (png_structp \fP\fIpng_ptr\fP\fB, int \fIintent\fP\fB);\fP + +\fBvoid png_write_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_spalette_p \fIpalette\fP\fB);\fP + +\fBvoid png_write_start_row (png_structp \fIpng_ptr\fP\fB);\fP + +\fBvoid png_write_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fItext_len\fP\fB);\fP + +\fBvoid png_write_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP + +\fBvoid png_write_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, png_color_16p \fP\fIvalues\fP\fB, int \fP\fInumber\fP\fB, int \fIcolor_type\fP\fB);\fP + +\fBvoid png_write_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fP\fItext_len\fP\fB, int \fIcompression\fP\fB);\fP + +\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP + +\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP + +\fI\fB + +.SH DESCRIPTION +The functions listed above are used privately by libpng +and are not recommended for use by applications. They are +not "exported" to applications using shared libraries. They +are listed alphabetically here as an aid to libpng maintainers. +See png.h for more information on these functions. + +.SH SEE ALSO +libpng(3), png(5) +.SH AUTHOR +Glenn Randers-Pehrson diff --git a/src/dep/src/irrlicht/libpng/png.5 b/src/dep/src/irrlicht/libpng/png.5 index 440afff..5aba7f9 100644 --- a/src/dep/src/irrlicht/libpng/png.5 +++ b/src/dep/src/irrlicht/libpng/png.5 @@ -1,74 +1,74 @@ -.TH PNG 5 "January 31, 2007" -.SH NAME -png \- Portable Network Graphics (PNG) format -.SH DESCRIPTION -PNG (Portable Network Graphics) is an extensible file format for the -lossless, portable, well-compressed storage of raster images. PNG provides -a patent-free replacement for GIF and can also replace many -common uses of TIFF. Indexed-color, grayscale, and truecolor images are -supported, plus an optional alpha channel. Sample depths range from -1 to 16 bits. -.br - -PNG is designed to work well in online viewing applications, such as the -World Wide Web, so it is fully streamable with a progressive display -option. PNG is robust, providing both full file integrity checking and -fast, simple detection of common transmission errors. Also, PNG can store -gamma and chromaticity data for improved color matching on heterogeneous -platforms. - -.SH "SEE ALSO" -.IR libpng(3), zlib(3), deflate(5), and zlib(5) -.LP -PNG specification (second edition), November 2003: -.IP -.br - 8) - png_error(png_ptr, "Too many bytes for PNG signature."); - - png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); -} - -/* Checks whether the supplied bytes match the PNG signature. We allow - * checking less than the full 8-byte signature so that those apps that - * already read the first few bytes of a file to determine the file type - * can simply check the remaining bytes for extra assurance. Returns - * an integer less than, equal to, or greater than zero if sig is found, - * respectively, to be less than, to match, or be greater than the correct - * PNG signature (this is the same behaviour as strcmp, memcmp, etc). - */ -int PNGAPI -png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - if (num_to_check > 8) - num_to_check = 8; - else if (num_to_check < 1) - return (-1); - - if (start > 7) - return (-1); - - if (start + num_to_check > 8) - num_to_check = 8 - start; - - return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check))); -} - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* (Obsolete) function to check signature bytes. It does not allow one - * to check a partial signature. This function might be removed in the - * future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG. - */ -int PNGAPI -png_check_sig(png_bytep sig, int num) -{ - return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num)); -} -#endif -#endif /* PNG_READ_SUPPORTED */ - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -/* Function to allocate memory for zlib and clear it to 0. */ -#ifdef PNG_1_0_X -voidpf PNGAPI -#else -voidpf /* private */ -#endif -png_zalloc(voidpf png_ptr, uInt items, uInt size) -{ - png_voidp ptr; - png_structp p=(png_structp)png_ptr; - png_uint_32 save_flags=p->flags; - png_uint_32 num_bytes; - - if(png_ptr == NULL) return (NULL); - if (items > PNG_UINT_32_MAX/size) - { - png_warning (p, "Potential overflow in png_zalloc()"); - return (NULL); - } - num_bytes = (png_uint_32)items * size; - - p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; - ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); - p->flags=save_flags; - -#if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO) - if (ptr == NULL) - return ((voidpf)ptr); - - if (num_bytes > (png_uint_32)0x8000L) - { - png_memset(ptr, 0, (png_size_t)0x8000L); - png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0, - (png_size_t)(num_bytes - (png_uint_32)0x8000L)); - } - else - { - png_memset(ptr, 0, (png_size_t)num_bytes); - } -#endif - return ((voidpf)ptr); -} - -/* function to free memory for zlib */ -#ifdef PNG_1_0_X -void PNGAPI -#else -void /* private */ -#endif -png_zfree(voidpf png_ptr, voidpf ptr) -{ - png_free((png_structp)png_ptr, (png_voidp)ptr); -} - -/* Reset the CRC variable to 32 bits of 1's. Care must be taken - * in case CRC is > 32 bits to leave the top bits 0. - */ -void /* PRIVATE */ -png_reset_crc(png_structp png_ptr) -{ - png_ptr->crc = crc32(0, Z_NULL, 0); -} - -/* Calculate the CRC over a section of data. We can only pass as - * much data to this routine as the largest single buffer size. We - * also check that this data will actually be used before going to the - * trouble of calculating it. - */ -void /* PRIVATE */ -png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length) -{ - int need_crc = 1; - - if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ - { - if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == - (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) - need_crc = 0; - } - else /* critical */ - { - if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) - need_crc = 0; - } - - if (need_crc) - png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length); -} - -/* Allocate the memory for an info_struct for the application. We don't - * really need the png_ptr, but it could potentially be useful in the - * future. This should be used in favour of malloc(png_sizeof(png_info)) - * and png_info_init() so that applications that want to use a shared - * libpng don't have to be recompiled if png_info changes size. - */ -png_infop PNGAPI -png_create_info_struct(png_structp png_ptr) -{ - png_infop info_ptr; - - png_debug(1, "in png_create_info_struct\n"); - if(png_ptr == NULL) return (NULL); -#ifdef PNG_USER_MEM_SUPPORTED - info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, - png_ptr->malloc_fn, png_ptr->mem_ptr); -#else - info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); -#endif - if (info_ptr != NULL) - png_info_init_3(&info_ptr, png_sizeof(png_info)); - - return (info_ptr); -} - -/* This function frees the memory associated with a single info struct. - * Normally, one would use either png_destroy_read_struct() or - * png_destroy_write_struct() to free an info struct, but this may be - * useful for some applications. - */ -void PNGAPI -png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) -{ - png_infop info_ptr = NULL; - if(png_ptr == NULL) return; - - png_debug(1, "in png_destroy_info_struct\n"); - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (info_ptr != NULL) - { - png_info_destroy(png_ptr, info_ptr); - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn, - png_ptr->mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = NULL; - } -} - -/* Initialize the info structure. This is now an internal function (0.89) - * and applications using it are urged to use png_create_info_struct() - * instead. - */ -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -#undef png_info_init -void PNGAPI -png_info_init(png_infop info_ptr) -{ - /* We only come here via pre-1.0.12-compiled applications */ - png_info_init_3(&info_ptr, 0); -} -#endif - -void PNGAPI -png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) -{ - png_infop info_ptr = *ptr_ptr; - - if(info_ptr == NULL) return; - - png_debug(1, "in png_info_init_3\n"); - - if(png_sizeof(png_info) > png_info_struct_size) - { - png_destroy_struct(info_ptr); - info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); - *ptr_ptr = info_ptr; - } - - /* set everything to 0 */ - png_memset(info_ptr, 0, png_sizeof (png_info)); -} - -#ifdef PNG_FREE_ME_SUPPORTED -void PNGAPI -png_data_freer(png_structp png_ptr, png_infop info_ptr, - int freer, png_uint_32 mask) -{ - png_debug(1, "in png_data_freer\n"); - if (png_ptr == NULL || info_ptr == NULL) - return; - if(freer == PNG_DESTROY_WILL_FREE_DATA) - info_ptr->free_me |= mask; - else if(freer == PNG_USER_WILL_FREE_DATA) - info_ptr->free_me &= ~mask; - else - png_warning(png_ptr, - "Unknown freer parameter in png_data_freer."); -} -#endif - -void PNGAPI -png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, - int num) -{ - png_debug(1, "in png_free_data\n"); - if (png_ptr == NULL || info_ptr == NULL) - return; - -#if defined(PNG_TEXT_SUPPORTED) -/* free text item num or (if num == -1) all text items */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) -#else -if (mask & PNG_FREE_TEXT) -#endif -{ - if (num != -1) - { - if (info_ptr->text && info_ptr->text[num].key) - { - png_free(png_ptr, info_ptr->text[num].key); - info_ptr->text[num].key = NULL; - } - } - else - { - int i; - for (i = 0; i < info_ptr->num_text; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); - png_free(png_ptr, info_ptr->text); - info_ptr->text = NULL; - info_ptr->num_text=0; - } -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -/* free any tRNS entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS)) -#endif -{ - png_free(png_ptr, info_ptr->trans); - info_ptr->valid &= ~PNG_INFO_tRNS; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; -#endif - info_ptr->trans = NULL; -} -#endif - -#if defined(PNG_sCAL_SUPPORTED) -/* free any sCAL entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) -#else -if (mask & PNG_FREE_SCAL) -#endif -{ -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, info_ptr->scal_s_width); - png_free(png_ptr, info_ptr->scal_s_height); - info_ptr->scal_s_width = NULL; - info_ptr->scal_s_height = NULL; -#endif - info_ptr->valid &= ~PNG_INFO_sCAL; -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -/* free any pCAL entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) -#else -if (mask & PNG_FREE_PCAL) -#endif -{ - png_free(png_ptr, info_ptr->pcal_purpose); - png_free(png_ptr, info_ptr->pcal_units); - info_ptr->pcal_purpose = NULL; - info_ptr->pcal_units = NULL; - if (info_ptr->pcal_params != NULL) - { - int i; - for (i = 0; i < (int)info_ptr->pcal_nparams; i++) - { - png_free(png_ptr, info_ptr->pcal_params[i]); - info_ptr->pcal_params[i]=NULL; - } - png_free(png_ptr, info_ptr->pcal_params); - info_ptr->pcal_params = NULL; - } - info_ptr->valid &= ~PNG_INFO_pCAL; -} -#endif - -#if defined(PNG_iCCP_SUPPORTED) -/* free any iCCP entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) -#else -if (mask & PNG_FREE_ICCP) -#endif -{ - png_free(png_ptr, info_ptr->iccp_name); - png_free(png_ptr, info_ptr->iccp_profile); - info_ptr->iccp_name = NULL; - info_ptr->iccp_profile = NULL; - info_ptr->valid &= ~PNG_INFO_iCCP; -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -/* free a given sPLT entry, or (if num == -1) all sPLT entries */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) -#else -if (mask & PNG_FREE_SPLT) -#endif -{ - if (num != -1) - { - if(info_ptr->splt_palettes) - { - png_free(png_ptr, info_ptr->splt_palettes[num].name); - png_free(png_ptr, info_ptr->splt_palettes[num].entries); - info_ptr->splt_palettes[num].name = NULL; - info_ptr->splt_palettes[num].entries = NULL; - } - } - else - { - if(info_ptr->splt_palettes_num) - { - int i; - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i); - - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes = NULL; - info_ptr->splt_palettes_num = 0; - } - info_ptr->valid &= ~PNG_INFO_sPLT; - } -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) -#else -if (mask & PNG_FREE_UNKN) -#endif -{ - if (num != -1) - { - if(info_ptr->unknown_chunks) - { - png_free(png_ptr, info_ptr->unknown_chunks[num].data); - info_ptr->unknown_chunks[num].data = NULL; - } - } - else - { - int i; - - if(info_ptr->unknown_chunks_num) - { - for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); - - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks = NULL; - info_ptr->unknown_chunks_num = 0; - } - } -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -/* free any hIST entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_HIST) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST)) -#endif -{ - png_free(png_ptr, info_ptr->hist); - info_ptr->hist = NULL; - info_ptr->valid &= ~PNG_INFO_hIST; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_HIST; -#endif -} -#endif - -/* free any PLTE entry that was internally allocated */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE)) -#endif -{ - png_zfree(png_ptr, info_ptr->palette); - info_ptr->palette = NULL; - info_ptr->valid &= ~PNG_INFO_PLTE; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; -#endif - info_ptr->num_palette = 0; -} - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* free any image bits attached to the info structure */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) -#else -if (mask & PNG_FREE_ROWS) -#endif -{ - if(info_ptr->row_pointers) - { - int row; - for (row = 0; row < (int)info_ptr->height; row++) - { - png_free(png_ptr, info_ptr->row_pointers[row]); - info_ptr->row_pointers[row]=NULL; - } - png_free(png_ptr, info_ptr->row_pointers); - info_ptr->row_pointers=NULL; - } - info_ptr->valid &= ~PNG_INFO_IDAT; -} -#endif - -#ifdef PNG_FREE_ME_SUPPORTED - if(num == -1) - info_ptr->free_me &= ~mask; - else - info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL); -#endif -} - -/* This is an internal routine to free any memory that the info struct is - * pointing to before re-using it or freeing the struct itself. Recall - * that png_free() checks for NULL pointers for us. - */ -void /* PRIVATE */ -png_info_destroy(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_info_destroy\n"); - - png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->num_chunk_list) - { - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; - } -#endif - - png_info_init_3(&info_ptr, png_sizeof(png_info)); -} -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ - -/* This function returns a pointer to the io_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy() or png_read_destroy() are called. - */ -png_voidp PNGAPI -png_get_io_ptr(png_structp png_ptr) -{ - if(png_ptr == NULL) return (NULL); - return (png_ptr->io_ptr); -} - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#if !defined(PNG_NO_STDIO) -/* Initialize the default input/output functions for the PNG file. If you - * use your own read or write routines, you can call either png_set_read_fn() - * or png_set_write_fn() instead of png_init_io(). If you have defined - * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't - * necessarily available. - */ -void PNGAPI -png_init_io(png_structp png_ptr, png_FILE_p fp) -{ - png_debug(1, "in png_init_io\n"); - if(png_ptr == NULL) return; - png_ptr->io_ptr = (png_voidp)fp; -} -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -/* Convert the supplied time into an RFC 1123 string suitable for use in - * a "Creation Time" or other text-based time string. - */ -png_charp PNGAPI -png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) -{ - static PNG_CONST char short_months[12][4] = - {"Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - - if(png_ptr == NULL) return (NULL); - if (png_ptr->time_buffer == NULL) - { - png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* - png_sizeof(char))); - } - -#if defined(_WIN32_WCE) - { - wchar_t time_buf[29]; - wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); - WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29, - NULL, NULL); - } -#else -#ifdef USE_FAR_KEYWORD - { - char near_time_buf[29]; - sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000", - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); - png_memcpy(png_ptr->time_buffer, near_time_buf, - 29*png_sizeof(char)); - } -#else - sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000", - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); -#endif -#endif /* _WIN32_WCE */ - return ((png_charp)png_ptr->time_buffer); -} -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - -#if 0 -/* Signature string for a PNG file. */ -png_bytep PNGAPI -png_sig_bytes(void) -{ - return ((png_bytep)"\211\120\116\107\015\012\032\012"); -} -#endif -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ - -png_charp PNGAPI -png_get_copyright(png_structp png_ptr) -{ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) "\n libpng version 1.2.16 - January 31, 2007\n\ - Copyright (c) 1998-2007 Glenn Randers-Pehrson\n\ - Copyright (c) 1996-1997 Andreas Dilger\n\ - Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); - return ((png_charp) ""); -} - -/* The following return the library version as a short string in the - * format 1.0.0 through 99.99.99zz. To get the version of *.h files - * used with your application, print out PNG_LIBPNG_VER_STRING, which - * is defined in png.h. - * Note: now there is no difference between png_get_libpng_ver() and - * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard, - * it is guaranteed that png.c uses the correct version of png.h. - */ -png_charp PNGAPI -png_get_libpng_ver(png_structp png_ptr) -{ - /* Version of *.c files used when building libpng */ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) PNG_LIBPNG_VER_STRING); - return ((png_charp) ""); -} - -png_charp PNGAPI -png_get_header_ver(png_structp png_ptr) -{ - /* Version of *.h files used when building libpng */ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) PNG_LIBPNG_VER_STRING); - return ((png_charp) ""); -} - -png_charp PNGAPI -png_get_header_version(png_structp png_ptr) -{ - /* Returns longer string containing both version and date */ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) PNG_HEADER_VERSION_STRING); - return ((png_charp) ""); -} - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -int PNGAPI -png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) -{ - /* check chunk_name and return "keep" value if it's on the list, else 0 */ - int i; - png_bytep p; - if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0) - return 0; - p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5; - for (i = png_ptr->num_chunk_list; i; i--, p-=5) - if (!png_memcmp(chunk_name, p, 4)) - return ((int)*(p+4)); - return 0; -} -#endif - -/* This function, added to libpng-1.0.6g, is untested. */ -int PNGAPI -png_reset_zstream(png_structp png_ptr) -{ - if (png_ptr == NULL) return Z_STREAM_ERROR; - return (inflateReset(&png_ptr->zstream)); -} -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ - -/* This function was added to libpng-1.0.7 */ -png_uint_32 PNGAPI -png_access_version_number(void) -{ - /* Version of *.c files used when building libpng */ - return((png_uint_32) PNG_LIBPNG_VER); -} - - -#if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if !defined(PNG_1_0_X) -#if defined(PNG_MMX_CODE_SUPPORTED) -/* this INTERNAL function was added to libpng 1.2.0 */ -void /* PRIVATE */ -png_init_mmx_flags (png_structp png_ptr) -{ - if(png_ptr == NULL) return; - png_ptr->mmx_rowbytes_threshold = 0; - png_ptr->mmx_bitdepth_threshold = 0; - -# if (defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD)) - - png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_COMPILED; - - if (png_mmx_support() > 0) { - png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU -# ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW - | PNG_ASM_FLAG_MMX_READ_COMBINE_ROW -# endif -# ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE - | PNG_ASM_FLAG_MMX_READ_INTERLACE -# endif -# ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW - ; -# else - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB - | PNG_ASM_FLAG_MMX_READ_FILTER_UP - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - - png_ptr->mmx_rowbytes_threshold = PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT; - png_ptr->mmx_bitdepth_threshold = PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT; -# endif - } else { - png_ptr->asm_flags &= ~( PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU - | PNG_MMX_READ_FLAGS - | PNG_MMX_WRITE_FLAGS ); - } - -# else /* !(PNGVCRD || PNGGCCRD) */ - - /* clear all MMX flags; no support is compiled in */ - png_ptr->asm_flags &= ~( PNG_MMX_FLAGS ); - -# endif /* ?(PNGVCRD || PNGGCCRD) */ -} - -#endif /* !(PNG_MMX_CODE_SUPPORTED) */ - -/* this function was added to libpng 1.2.0 */ -#if !defined(PNG_USE_PNGGCCRD) && \ - !(defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD)) -int PNGAPI -png_mmx_support(void) -{ - return -1; -} -#endif -#endif /* PNG_1_0_X && PNG_ASSEMBLER_CODE_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED */ - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#ifdef PNG_SIZE_T -/* Added at libpng version 1.2.6 */ - PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); -png_size_t PNGAPI -png_convert_size(size_t size) -{ - if (size > (png_size_t)-1) - PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */ - return ((png_size_t)size); -} -#endif /* PNG_SIZE_T */ -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ + +/* png.c - location for general purpose libpng functions + * + * Last changed in libpng 1.2.15 January 5, 2007 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +#define PNG_INTERNAL +#define PNG_NO_EXTERN +#include "png.h" + +/* Generate a compiler error if there is an old png.h in the search path. */ +typedef version_1_2_16 Your_png_h_is_not_version_1_2_16; + +/* Version information for C files. This had better match the version + * string defined in png.h. */ + +#ifdef PNG_USE_GLOBAL_ARRAYS +/* png_libpng_ver was changed to a function in version 1.0.5c */ +const char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING; + +#ifdef PNG_READ_SUPPORTED + +/* png_sig was changed to a function in version 1.0.5c */ +/* Place to hold the signature string for a PNG file. */ +const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; +#endif /* PNG_READ_SUPPORTED */ + +/* Invoke global declarations for constant strings for known chunk types */ +PNG_IHDR; +PNG_IDAT; +PNG_IEND; +PNG_PLTE; +PNG_bKGD; +PNG_cHRM; +PNG_gAMA; +PNG_hIST; +PNG_iCCP; +PNG_iTXt; +PNG_oFFs; +PNG_pCAL; +PNG_sCAL; +PNG_pHYs; +PNG_sBIT; +PNG_sPLT; +PNG_sRGB; +PNG_tEXt; +PNG_tIME; +PNG_tRNS; +PNG_zTXt; + +#ifdef PNG_READ_SUPPORTED +/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + +/* start of interlace block */ +const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; + +/* offset to next interlace block */ +const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; + +/* start of interlace block in the y direction */ +const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; + +/* offset to next interlace block in the y direction */ +const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; + +/* width of interlace block (used in assembler routines only) */ +#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW +const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; +#endif + +/* Height of interlace block. This is not currently used - if you need + * it, uncomment it here and in png.h +const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; +*/ + +/* Mask to determine which pixels are valid in a pass */ +const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; + +/* Mask to determine which pixels to overwrite while displaying */ +const int FARDATA png_pass_dsp_mask[] + = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; + +#endif /* PNG_READ_SUPPORTED */ +#endif /* PNG_USE_GLOBAL_ARRAYS */ + +/* Tells libpng that we have already handled the first "num_bytes" bytes + * of the PNG file signature. If the PNG data is embedded into another + * stream we can set num_bytes = 8 so that libpng will not attempt to read + * or write any of the magic bytes before it starts on the IHDR. + */ + +#ifdef PNG_READ_SUPPORTED +void PNGAPI +png_set_sig_bytes(png_structp png_ptr, int num_bytes) +{ + if(png_ptr == NULL) return; + png_debug(1, "in png_set_sig_bytes\n"); + if (num_bytes > 8) + png_error(png_ptr, "Too many bytes for PNG signature."); + + png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); +} + +/* Checks whether the supplied bytes match the PNG signature. We allow + * checking less than the full 8-byte signature so that those apps that + * already read the first few bytes of a file to determine the file type + * can simply check the remaining bytes for extra assurance. Returns + * an integer less than, equal to, or greater than zero if sig is found, + * respectively, to be less than, to match, or be greater than the correct + * PNG signature (this is the same behaviour as strcmp, memcmp, etc). + */ +int PNGAPI +png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) +{ + png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + if (num_to_check > 8) + num_to_check = 8; + else if (num_to_check < 1) + return (-1); + + if (start > 7) + return (-1); + + if (start + num_to_check > 8) + num_to_check = 8 - start; + + return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check))); +} + +#if defined(PNG_1_0_X) || defined(PNG_1_2_X) +/* (Obsolete) function to check signature bytes. It does not allow one + * to check a partial signature. This function might be removed in the + * future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG. + */ +int PNGAPI +png_check_sig(png_bytep sig, int num) +{ + return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num)); +} +#endif +#endif /* PNG_READ_SUPPORTED */ + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +/* Function to allocate memory for zlib and clear it to 0. */ +#ifdef PNG_1_0_X +voidpf PNGAPI +#else +voidpf /* private */ +#endif +png_zalloc(voidpf png_ptr, uInt items, uInt size) +{ + png_voidp ptr; + png_structp p=(png_structp)png_ptr; + png_uint_32 save_flags=p->flags; + png_uint_32 num_bytes; + + if(png_ptr == NULL) return (NULL); + if (items > PNG_UINT_32_MAX/size) + { + png_warning (p, "Potential overflow in png_zalloc()"); + return (NULL); + } + num_bytes = (png_uint_32)items * size; + + p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; + ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); + p->flags=save_flags; + +#if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO) + if (ptr == NULL) + return ((voidpf)ptr); + + if (num_bytes > (png_uint_32)0x8000L) + { + png_memset(ptr, 0, (png_size_t)0x8000L); + png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0, + (png_size_t)(num_bytes - (png_uint_32)0x8000L)); + } + else + { + png_memset(ptr, 0, (png_size_t)num_bytes); + } +#endif + return ((voidpf)ptr); +} + +/* function to free memory for zlib */ +#ifdef PNG_1_0_X +void PNGAPI +#else +void /* private */ +#endif +png_zfree(voidpf png_ptr, voidpf ptr) +{ + png_free((png_structp)png_ptr, (png_voidp)ptr); +} + +/* Reset the CRC variable to 32 bits of 1's. Care must be taken + * in case CRC is > 32 bits to leave the top bits 0. + */ +void /* PRIVATE */ +png_reset_crc(png_structp png_ptr) +{ + png_ptr->crc = crc32(0, Z_NULL, 0); +} + +/* Calculate the CRC over a section of data. We can only pass as + * much data to this routine as the largest single buffer size. We + * also check that this data will actually be used before going to the + * trouble of calculating it. + */ +void /* PRIVATE */ +png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length) +{ + int need_crc = 1; + + if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ + { + if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == + (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) + need_crc = 0; + } + else /* critical */ + { + if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) + need_crc = 0; + } + + if (need_crc) + png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length); +} + +/* Allocate the memory for an info_struct for the application. We don't + * really need the png_ptr, but it could potentially be useful in the + * future. This should be used in favour of malloc(png_sizeof(png_info)) + * and png_info_init() so that applications that want to use a shared + * libpng don't have to be recompiled if png_info changes size. + */ +png_infop PNGAPI +png_create_info_struct(png_structp png_ptr) +{ + png_infop info_ptr; + + png_debug(1, "in png_create_info_struct\n"); + if(png_ptr == NULL) return (NULL); +#ifdef PNG_USER_MEM_SUPPORTED + info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, + png_ptr->malloc_fn, png_ptr->mem_ptr); +#else + info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); +#endif + if (info_ptr != NULL) + png_info_init_3(&info_ptr, png_sizeof(png_info)); + + return (info_ptr); +} + +/* This function frees the memory associated with a single info struct. + * Normally, one would use either png_destroy_read_struct() or + * png_destroy_write_struct() to free an info struct, but this may be + * useful for some applications. + */ +void PNGAPI +png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) +{ + png_infop info_ptr = NULL; + if(png_ptr == NULL) return; + + png_debug(1, "in png_destroy_info_struct\n"); + if (info_ptr_ptr != NULL) + info_ptr = *info_ptr_ptr; + + if (info_ptr != NULL) + { + png_info_destroy(png_ptr, info_ptr); + +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn, + png_ptr->mem_ptr); +#else + png_destroy_struct((png_voidp)info_ptr); +#endif + *info_ptr_ptr = NULL; + } +} + +/* Initialize the info structure. This is now an internal function (0.89) + * and applications using it are urged to use png_create_info_struct() + * instead. + */ +#if defined(PNG_1_0_X) || defined(PNG_1_2_X) +#undef png_info_init +void PNGAPI +png_info_init(png_infop info_ptr) +{ + /* We only come here via pre-1.0.12-compiled applications */ + png_info_init_3(&info_ptr, 0); +} +#endif + +void PNGAPI +png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) +{ + png_infop info_ptr = *ptr_ptr; + + if(info_ptr == NULL) return; + + png_debug(1, "in png_info_init_3\n"); + + if(png_sizeof(png_info) > png_info_struct_size) + { + png_destroy_struct(info_ptr); + info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); + *ptr_ptr = info_ptr; + } + + /* set everything to 0 */ + png_memset(info_ptr, 0, png_sizeof (png_info)); +} + +#ifdef PNG_FREE_ME_SUPPORTED +void PNGAPI +png_data_freer(png_structp png_ptr, png_infop info_ptr, + int freer, png_uint_32 mask) +{ + png_debug(1, "in png_data_freer\n"); + if (png_ptr == NULL || info_ptr == NULL) + return; + if(freer == PNG_DESTROY_WILL_FREE_DATA) + info_ptr->free_me |= mask; + else if(freer == PNG_USER_WILL_FREE_DATA) + info_ptr->free_me &= ~mask; + else + png_warning(png_ptr, + "Unknown freer parameter in png_data_freer."); +} +#endif + +void PNGAPI +png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, + int num) +{ + png_debug(1, "in png_free_data\n"); + if (png_ptr == NULL || info_ptr == NULL) + return; + +#if defined(PNG_TEXT_SUPPORTED) +/* free text item num or (if num == -1) all text items */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) +#else +if (mask & PNG_FREE_TEXT) +#endif +{ + if (num != -1) + { + if (info_ptr->text && info_ptr->text[num].key) + { + png_free(png_ptr, info_ptr->text[num].key); + info_ptr->text[num].key = NULL; + } + } + else + { + int i; + for (i = 0; i < info_ptr->num_text; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); + png_free(png_ptr, info_ptr->text); + info_ptr->text = NULL; + info_ptr->num_text=0; + } +} +#endif + +#if defined(PNG_tRNS_SUPPORTED) +/* free any tRNS entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) +#else +if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS)) +#endif +{ + png_free(png_ptr, info_ptr->trans); + info_ptr->valid &= ~PNG_INFO_tRNS; +#ifndef PNG_FREE_ME_SUPPORTED + png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; +#endif + info_ptr->trans = NULL; +} +#endif + +#if defined(PNG_sCAL_SUPPORTED) +/* free any sCAL entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) +#else +if (mask & PNG_FREE_SCAL) +#endif +{ +#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) + png_free(png_ptr, info_ptr->scal_s_width); + png_free(png_ptr, info_ptr->scal_s_height); + info_ptr->scal_s_width = NULL; + info_ptr->scal_s_height = NULL; +#endif + info_ptr->valid &= ~PNG_INFO_sCAL; +} +#endif + +#if defined(PNG_pCAL_SUPPORTED) +/* free any pCAL entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) +#else +if (mask & PNG_FREE_PCAL) +#endif +{ + png_free(png_ptr, info_ptr->pcal_purpose); + png_free(png_ptr, info_ptr->pcal_units); + info_ptr->pcal_purpose = NULL; + info_ptr->pcal_units = NULL; + if (info_ptr->pcal_params != NULL) + { + int i; + for (i = 0; i < (int)info_ptr->pcal_nparams; i++) + { + png_free(png_ptr, info_ptr->pcal_params[i]); + info_ptr->pcal_params[i]=NULL; + } + png_free(png_ptr, info_ptr->pcal_params); + info_ptr->pcal_params = NULL; + } + info_ptr->valid &= ~PNG_INFO_pCAL; +} +#endif + +#if defined(PNG_iCCP_SUPPORTED) +/* free any iCCP entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) +#else +if (mask & PNG_FREE_ICCP) +#endif +{ + png_free(png_ptr, info_ptr->iccp_name); + png_free(png_ptr, info_ptr->iccp_profile); + info_ptr->iccp_name = NULL; + info_ptr->iccp_profile = NULL; + info_ptr->valid &= ~PNG_INFO_iCCP; +} +#endif + +#if defined(PNG_sPLT_SUPPORTED) +/* free a given sPLT entry, or (if num == -1) all sPLT entries */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) +#else +if (mask & PNG_FREE_SPLT) +#endif +{ + if (num != -1) + { + if(info_ptr->splt_palettes) + { + png_free(png_ptr, info_ptr->splt_palettes[num].name); + png_free(png_ptr, info_ptr->splt_palettes[num].entries); + info_ptr->splt_palettes[num].name = NULL; + info_ptr->splt_palettes[num].entries = NULL; + } + } + else + { + if(info_ptr->splt_palettes_num) + { + int i; + for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i); + + png_free(png_ptr, info_ptr->splt_palettes); + info_ptr->splt_palettes = NULL; + info_ptr->splt_palettes_num = 0; + } + info_ptr->valid &= ~PNG_INFO_sPLT; + } +} +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) +#else +if (mask & PNG_FREE_UNKN) +#endif +{ + if (num != -1) + { + if(info_ptr->unknown_chunks) + { + png_free(png_ptr, info_ptr->unknown_chunks[num].data); + info_ptr->unknown_chunks[num].data = NULL; + } + } + else + { + int i; + + if(info_ptr->unknown_chunks_num) + { + for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); + + png_free(png_ptr, info_ptr->unknown_chunks); + info_ptr->unknown_chunks = NULL; + info_ptr->unknown_chunks_num = 0; + } + } +} +#endif + +#if defined(PNG_hIST_SUPPORTED) +/* free any hIST entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_HIST) & info_ptr->free_me) +#else +if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST)) +#endif +{ + png_free(png_ptr, info_ptr->hist); + info_ptr->hist = NULL; + info_ptr->valid &= ~PNG_INFO_hIST; +#ifndef PNG_FREE_ME_SUPPORTED + png_ptr->flags &= ~PNG_FLAG_FREE_HIST; +#endif +} +#endif + +/* free any PLTE entry that was internally allocated */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) +#else +if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE)) +#endif +{ + png_zfree(png_ptr, info_ptr->palette); + info_ptr->palette = NULL; + info_ptr->valid &= ~PNG_INFO_PLTE; +#ifndef PNG_FREE_ME_SUPPORTED + png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; +#endif + info_ptr->num_palette = 0; +} + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* free any image bits attached to the info structure */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) +#else +if (mask & PNG_FREE_ROWS) +#endif +{ + if(info_ptr->row_pointers) + { + int row; + for (row = 0; row < (int)info_ptr->height; row++) + { + png_free(png_ptr, info_ptr->row_pointers[row]); + info_ptr->row_pointers[row]=NULL; + } + png_free(png_ptr, info_ptr->row_pointers); + info_ptr->row_pointers=NULL; + } + info_ptr->valid &= ~PNG_INFO_IDAT; +} +#endif + +#ifdef PNG_FREE_ME_SUPPORTED + if(num == -1) + info_ptr->free_me &= ~mask; + else + info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL); +#endif +} + +/* This is an internal routine to free any memory that the info struct is + * pointing to before re-using it or freeing the struct itself. Recall + * that png_free() checks for NULL pointers for us. + */ +void /* PRIVATE */ +png_info_destroy(png_structp png_ptr, png_infop info_ptr) +{ + png_debug(1, "in png_info_destroy\n"); + + png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + if (png_ptr->num_chunk_list) + { + png_free(png_ptr, png_ptr->chunk_list); + png_ptr->chunk_list=NULL; + png_ptr->num_chunk_list=0; + } +#endif + + png_info_init_3(&info_ptr, png_sizeof(png_info)); +} +#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ + +/* This function returns a pointer to the io_ptr associated with the user + * functions. The application should free any memory associated with this + * pointer before png_write_destroy() or png_read_destroy() are called. + */ +png_voidp PNGAPI +png_get_io_ptr(png_structp png_ptr) +{ + if(png_ptr == NULL) return (NULL); + return (png_ptr->io_ptr); +} + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +#if !defined(PNG_NO_STDIO) +/* Initialize the default input/output functions for the PNG file. If you + * use your own read or write routines, you can call either png_set_read_fn() + * or png_set_write_fn() instead of png_init_io(). If you have defined + * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't + * necessarily available. + */ +void PNGAPI +png_init_io(png_structp png_ptr, png_FILE_p fp) +{ + png_debug(1, "in png_init_io\n"); + if(png_ptr == NULL) return; + png_ptr->io_ptr = (png_voidp)fp; +} +#endif + +#if defined(PNG_TIME_RFC1123_SUPPORTED) +/* Convert the supplied time into an RFC 1123 string suitable for use in + * a "Creation Time" or other text-based time string. + */ +png_charp PNGAPI +png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) +{ + static PNG_CONST char short_months[12][4] = + {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + + if(png_ptr == NULL) return (NULL); + if (png_ptr->time_buffer == NULL) + { + png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* + png_sizeof(char))); + } + +#if defined(_WIN32_WCE) + { + wchar_t time_buf[29]; + wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), + ptime->day % 32, short_months[(ptime->month - 1) % 12], + ptime->year, ptime->hour % 24, ptime->minute % 60, + ptime->second % 61); + WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29, + NULL, NULL); + } +#else +#ifdef USE_FAR_KEYWORD + { + char near_time_buf[29]; + sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000", + ptime->day % 32, short_months[(ptime->month - 1) % 12], + ptime->year, ptime->hour % 24, ptime->minute % 60, + ptime->second % 61); + png_memcpy(png_ptr->time_buffer, near_time_buf, + 29*png_sizeof(char)); + } +#else + sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000", + ptime->day % 32, short_months[(ptime->month - 1) % 12], + ptime->year, ptime->hour % 24, ptime->minute % 60, + ptime->second % 61); +#endif +#endif /* _WIN32_WCE */ + return ((png_charp)png_ptr->time_buffer); +} +#endif /* PNG_TIME_RFC1123_SUPPORTED */ + +#if 0 +/* Signature string for a PNG file. */ +png_bytep PNGAPI +png_sig_bytes(void) +{ + return ((png_bytep)"\211\120\116\107\015\012\032\012"); +} +#endif +#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ + +png_charp PNGAPI +png_get_copyright(png_structp png_ptr) +{ + if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ + return ((png_charp) "\n libpng version 1.2.16 - January 31, 2007\n\ + Copyright (c) 1998-2007 Glenn Randers-Pehrson\n\ + Copyright (c) 1996-1997 Andreas Dilger\n\ + Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); + return ((png_charp) ""); +} + +/* The following return the library version as a short string in the + * format 1.0.0 through 99.99.99zz. To get the version of *.h files + * used with your application, print out PNG_LIBPNG_VER_STRING, which + * is defined in png.h. + * Note: now there is no difference between png_get_libpng_ver() and + * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard, + * it is guaranteed that png.c uses the correct version of png.h. + */ +png_charp PNGAPI +png_get_libpng_ver(png_structp png_ptr) +{ + /* Version of *.c files used when building libpng */ + if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ + return ((png_charp) PNG_LIBPNG_VER_STRING); + return ((png_charp) ""); +} + +png_charp PNGAPI +png_get_header_ver(png_structp png_ptr) +{ + /* Version of *.h files used when building libpng */ + if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ + return ((png_charp) PNG_LIBPNG_VER_STRING); + return ((png_charp) ""); +} + +png_charp PNGAPI +png_get_header_version(png_structp png_ptr) +{ + /* Returns longer string containing both version and date */ + if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ + return ((png_charp) PNG_HEADER_VERSION_STRING); + return ((png_charp) ""); +} + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +int PNGAPI +png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) +{ + /* check chunk_name and return "keep" value if it's on the list, else 0 */ + int i; + png_bytep p; + if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0) + return 0; + p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5; + for (i = png_ptr->num_chunk_list; i; i--, p-=5) + if (!png_memcmp(chunk_name, p, 4)) + return ((int)*(p+4)); + return 0; +} +#endif + +/* This function, added to libpng-1.0.6g, is untested. */ +int PNGAPI +png_reset_zstream(png_structp png_ptr) +{ + if (png_ptr == NULL) return Z_STREAM_ERROR; + return (inflateReset(&png_ptr->zstream)); +} +#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ + +/* This function was added to libpng-1.0.7 */ +png_uint_32 PNGAPI +png_access_version_number(void) +{ + /* Version of *.c files used when building libpng */ + return((png_uint_32) PNG_LIBPNG_VER); +} + + +#if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) +#if !defined(PNG_1_0_X) +#if defined(PNG_MMX_CODE_SUPPORTED) +/* this INTERNAL function was added to libpng 1.2.0 */ +void /* PRIVATE */ +png_init_mmx_flags (png_structp png_ptr) +{ + if(png_ptr == NULL) return; + png_ptr->mmx_rowbytes_threshold = 0; + png_ptr->mmx_bitdepth_threshold = 0; + +# if (defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD)) + + png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_COMPILED; + + if (png_mmx_support() > 0) { + png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU +# ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW + | PNG_ASM_FLAG_MMX_READ_COMBINE_ROW +# endif +# ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE + | PNG_ASM_FLAG_MMX_READ_INTERLACE +# endif +# ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW + ; +# else + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB + | PNG_ASM_FLAG_MMX_READ_FILTER_UP + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; + + png_ptr->mmx_rowbytes_threshold = PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT; + png_ptr->mmx_bitdepth_threshold = PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT; +# endif + } else { + png_ptr->asm_flags &= ~( PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU + | PNG_MMX_READ_FLAGS + | PNG_MMX_WRITE_FLAGS ); + } + +# else /* !(PNGVCRD || PNGGCCRD) */ + + /* clear all MMX flags; no support is compiled in */ + png_ptr->asm_flags &= ~( PNG_MMX_FLAGS ); + +# endif /* ?(PNGVCRD || PNGGCCRD) */ +} + +#endif /* !(PNG_MMX_CODE_SUPPORTED) */ + +/* this function was added to libpng 1.2.0 */ +#if !defined(PNG_USE_PNGGCCRD) && \ + !(defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD)) +int PNGAPI +png_mmx_support(void) +{ + return -1; +} +#endif +#endif /* PNG_1_0_X && PNG_ASSEMBLER_CODE_SUPPORTED */ +#endif /* PNG_READ_SUPPORTED */ + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +#ifdef PNG_SIZE_T +/* Added at libpng version 1.2.6 */ + PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); +png_size_t PNGAPI +png_convert_size(size_t size) +{ + if (size > (png_size_t)-1) + PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */ + return ((png_size_t)size); +} +#endif /* PNG_SIZE_T */ +#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ diff --git a/src/dep/src/irrlicht/libpng/png.h b/src/dep/src/irrlicht/libpng/png.h index 888bf4e..1567f9c 100644 --- a/src/dep/src/irrlicht/libpng/png.h +++ b/src/dep/src/irrlicht/libpng/png.h @@ -1,3506 +1,3506 @@ - -/* png.h - header file for PNG reference library - * - * libpng version 1.2.16 - January 31, 2007 - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * Authors and maintainers: - * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat - * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.2.16 - January 31, 2007: Glenn - * See also "Contributing Authors", below. - * - * Note about libpng version numbers: - * - * Due to various miscommunications, unforeseen code incompatibilities - * and occasional factors outside the authors' control, version numbering - * on the library has not always been consistent and straightforward. - * The following table summarizes matters since version 0.89c, which was - * the first widely used release: - * - * source png.h png.h shared-lib - * version string int version - * ------- ------ ----- ---------- - * 0.89c "1.0 beta 3" 0.89 89 1.0.89 - * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] - * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] - * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] - * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] - * 0.97c 0.97 97 2.0.97 - * 0.98 0.98 98 2.0.98 - * 0.99 0.99 98 2.0.99 - * 0.99a-m 0.99 99 2.0.99 - * 1.00 1.00 100 2.1.0 [100 should be 10000] - * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] - * 1.0.1 png.h string is 10001 2.1.0 - * 1.0.1a-e identical to the 10002 from here on, the shared library - * 1.0.2 source version) 10002 is 2.V where V is the source code - * 1.0.2a-b 10003 version, except as noted. - * 1.0.3 10003 - * 1.0.3a-d 10004 - * 1.0.4 10004 - * 1.0.4a-f 10005 - * 1.0.5 (+ 2 patches) 10005 - * 1.0.5a-d 10006 - * 1.0.5e-r 10100 (not source compatible) - * 1.0.5s-v 10006 (not binary compatible) - * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) - * 1.0.6d-f 10007 (still binary incompatible) - * 1.0.6g 10007 - * 1.0.6h 10007 10.6h (testing xy.z so-numbering) - * 1.0.6i 10007 10.6i - * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) - * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) - * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) - * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) - * 1.0.7 1 10007 (still compatible) - * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 - * 1.0.8rc1 1 10008 2.1.0.8rc1 - * 1.0.8 1 10008 2.1.0.8 - * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 - * 1.0.9rc1 1 10009 2.1.0.9rc1 - * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 - * 1.0.9rc2 1 10009 2.1.0.9rc2 - * 1.0.9 1 10009 2.1.0.9 - * 1.0.10beta1 1 10010 2.1.0.10beta1 - * 1.0.10rc1 1 10010 2.1.0.10rc1 - * 1.0.10 1 10010 2.1.0.10 - * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 - * 1.0.11rc1 1 10011 2.1.0.11rc1 - * 1.0.11 1 10011 2.1.0.11 - * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 - * 1.0.12rc1 2 10012 2.1.0.12rc1 - * 1.0.12 2 10012 2.1.0.12 - * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) - * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 - * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 - * 1.2.0rc1 3 10200 3.1.2.0rc1 - * 1.2.0 3 10200 3.1.2.0 - * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 - * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 - * 1.2.1 3 10201 3.1.2.1 - * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 - * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 - * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 - * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 - * 1.0.13 10 10013 10.so.0.1.0.13 - * 1.2.2 12 10202 12.so.0.1.2.2 - * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 - * 1.2.3 12 10203 12.so.0.1.2.3 - * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 - * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 - * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 - * 1.0.14 10 10014 10.so.0.1.0.14 - * 1.2.4 13 10204 12.so.0.1.2.4 - * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 - * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 - * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 - * 1.0.15 10 10015 10.so.0.1.0.15 - * 1.2.5 13 10205 12.so.0.1.2.5 - * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 - * 1.0.16 10 10016 10.so.0.1.0.16 - * 1.2.6 13 10206 12.so.0.1.2.6 - * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 - * 1.0.17rc1 10 10017 10.so.0.1.0.17rc1 - * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 - * 1.0.17 10 10017 10.so.0.1.0.17 - * 1.2.7 13 10207 12.so.0.1.2.7 - * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 - * 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5 - * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 - * 1.0.18 10 10018 10.so.0.1.0.18 - * 1.2.8 13 10208 12.so.0.1.2.8 - * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 - * 1.2.9beta4-11 13 10209 12.so.0.9[.0] - * 1.2.9rc1 13 10209 12.so.0.9[.0] - * 1.2.9 13 10209 12.so.0.9[.0] - * 1.2.10beta1-8 13 10210 12.so.0.10[.0] - * 1.2.10rc1-3 13 10210 12.so.0.10[.0] - * 1.2.10 13 10210 12.so.0.10[.0] - * 1.2.11beta1-4 13 10211 12.so.0.11[.0] - * 1.0.19rc1-5 10 10019 10.so.0.19[.0] - * 1.2.11rc1-5 13 10211 12.so.0.11[.0] - * 1.0.19 10 10019 10.so.0.19[.0] - * 1.2.11 13 10211 12.so.0.11[.0] - * 1.0.20 10 10020 10.so.0.20[.0] - * 1.2.12 13 10212 12.so.0.12[.0] - * 1.2.13beta1 13 10213 12.so.0.13[.0] - * 1.0.21 10 10021 10.so.0.21[.0] - * 1.2.13 13 10213 12.so.0.13[.0] - * 1.2.14beta1-2 13 10214 12.so.0.14[.0] - * 1.0.22rc1 10 10022 10.so.0.22[.0] - * 1.2.14rc1 13 10214 12.so.0.14[.0] - * 1.0.22 10 10022 10.so.0.22[.0] - * 1.2.14 13 10214 12.so.0.14[.0] - * 1.2.15beta1-6 13 10215 12.so.0.15[.0] - * 1.0.23rc1-5 10 10023 10.so.0.23[.0] - * 1.2.15rc1-5 13 10215 12.so.0.15[.0] - * 1.0.23 10 10023 10.so.0.23[.0] - * 1.2.15 13 10215 12.so.0.15[.0] - * 1.2.16beta1-2 13 10216 12.so.0.16[.0] - * 1.2.16rc1 13 10216 12.so.0.16[.0] - * 1.0.24 10 10024 10.so.0.24[.0] - * 1.2.16 13 10216 12.so.0.16[.0] - * - * Henceforth the source version will match the shared-library major - * and minor numbers; the shared-library major version number will be - * used for changes in backward compatibility, as it is intended. The - * PNG_LIBPNG_VER macro, which is not used within libpng but is available - * for applications, is an unsigned integer of the form xyyzz corresponding - * to the source version x.y.z (leading zeros in y and z). Beta versions - * were given the previous public release number plus a letter, until - * version 1.0.6j; from then on they were given the upcoming public - * release number plus "betaNN" or "rcN". - * - * Binary incompatibility exists only when applications make direct access - * to the info_ptr or png_ptr members through png.h, and the compiled - * application is loaded with a different version of the library. - * - * DLLNUM will change each time there are forward or backward changes - * in binary compatibility (e.g., when a new feature is added). - * - * See libpng.txt or libpng.3 for more information. The PNG specification - * is available as a W3C Recommendation and as an ISO Specification, - * defines should NOT be changed. - */ -#define PNG_INFO_gAMA 0x0001 -#define PNG_INFO_sBIT 0x0002 -#define PNG_INFO_cHRM 0x0004 -#define PNG_INFO_PLTE 0x0008 -#define PNG_INFO_tRNS 0x0010 -#define PNG_INFO_bKGD 0x0020 -#define PNG_INFO_hIST 0x0040 -#define PNG_INFO_pHYs 0x0080 -#define PNG_INFO_oFFs 0x0100 -#define PNG_INFO_tIME 0x0200 -#define PNG_INFO_pCAL 0x0400 -#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ -#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ -#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ -#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ -#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ - -/* This is used for the transformation routines, as some of them - * change these values for the row. It also should enable using - * the routines for other purposes. - */ -typedef struct png_row_info_struct -{ - png_uint_32 width; /* width of row */ - png_uint_32 rowbytes; /* number of bytes in row */ - png_byte color_type; /* color type of row */ - png_byte bit_depth; /* bit depth of row */ - png_byte channels; /* number of channels (1, 2, 3, or 4) */ - png_byte pixel_depth; /* bits per pixel (depth * channels) */ -} png_row_info; - -typedef png_row_info FAR * png_row_infop; -typedef png_row_info FAR * FAR * png_row_infopp; - -/* These are the function types for the I/O functions and for the functions - * that allow the user to override the default I/O functions with his or her - * own. The png_error_ptr type should match that of user-supplied warning - * and error functions, while the png_rw_ptr type should match that of the - * user read/write data functions. - */ -typedef struct png_struct_def png_struct; -typedef png_struct FAR * png_structp; - -typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); -typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); -typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); -typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, - int)); -typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, - int)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, - png_uint_32, int)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, - png_row_infop, png_bytep)); -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) -typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); -#endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); -#endif - -/* Transform masks for the high-level interface */ -#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ -#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ -#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ -#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ -#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ -#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ -#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ -#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ -#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ -#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ -#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ -#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ -#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ - -/* Flags for MNG supported features */ -#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 -#define PNG_FLAG_MNG_FILTER_64 0x04 -#define PNG_ALL_MNG_FEATURES 0x05 - -typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); -typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); - -/* The structure that holds the information to read and write PNG files. - * The only people who need to care about what is inside of this are the - * people who will be modifying the library for their own special needs. - * It should NOT be accessed directly by an application, except to store - * the jmp_buf. - */ - -struct png_struct_def -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf jmpbuf; /* used in png_error */ -#endif - png_error_ptr error_fn; /* function for printing errors and aborting */ - png_error_ptr warning_fn; /* function for printing warnings */ - png_voidp error_ptr; /* user supplied struct for error functions */ - png_rw_ptr write_data_fn; /* function for writing output data */ - png_rw_ptr read_data_fn; /* function for reading input data */ - png_voidp io_ptr; /* ptr to application struct for I/O functions */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - png_user_transform_ptr read_user_transform_fn; /* user read transform */ -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_user_transform_ptr write_user_transform_fn; /* user write transform */ -#endif - -/* These were added in libpng-1.0.2 */ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_voidp user_transform_ptr; /* user supplied struct for user transform */ - png_byte user_transform_depth; /* bit depth of user transformed pixels */ - png_byte user_transform_channels; /* channels in user transformed pixels */ -#endif -#endif - - png_uint_32 mode; /* tells us where we are in the PNG file */ - png_uint_32 flags; /* flags indicating various things to libpng */ - png_uint_32 transformations; /* which transformations to perform */ - - z_stream zstream; /* pointer to decompression structure (below) */ - png_bytep zbuf; /* buffer for zlib */ - png_size_t zbuf_size; /* size of zbuf */ - int zlib_level; /* holds zlib compression level */ - int zlib_method; /* holds zlib compression method */ - int zlib_window_bits; /* holds zlib compression window bits */ - int zlib_mem_level; /* holds zlib compression memory level */ - int zlib_strategy; /* holds zlib compression strategy */ - - png_uint_32 width; /* width of image in pixels */ - png_uint_32 height; /* height of image in pixels */ - png_uint_32 num_rows; /* number of rows in current pass */ - png_uint_32 usr_width; /* width of row at start of write */ - png_uint_32 rowbytes; /* size of row in bytes */ - png_uint_32 irowbytes; /* size of current interlaced row in bytes */ - png_uint_32 iwidth; /* width of current interlaced row in pixels */ - png_uint_32 row_number; /* current row in interlace pass */ - png_bytep prev_row; /* buffer to save previous (unfiltered) row */ - png_bytep row_buf; /* buffer to save current (unfiltered) row */ - png_bytep sub_row; /* buffer to save "sub" row when filtering */ - png_bytep up_row; /* buffer to save "up" row when filtering */ - png_bytep avg_row; /* buffer to save "avg" row when filtering */ - png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ - png_row_info row_info; /* used for transformation routines */ - - png_uint_32 idat_size; /* current IDAT size for read */ - png_uint_32 crc; /* current chunk CRC value */ - png_colorp palette; /* palette from the input file */ - png_uint_16 num_palette; /* number of color entries in palette */ - png_uint_16 num_trans; /* number of transparency values */ - png_byte chunk_name[5]; /* null-terminated name of current chunk */ - png_byte compression; /* file compression type (always 0) */ - png_byte filter; /* file filter type (always 0) */ - png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - png_byte pass; /* current interlace pass (0 - 6) */ - png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ - png_byte color_type; /* color type of file */ - png_byte bit_depth; /* bit depth of file */ - png_byte usr_bit_depth; /* bit depth of users row */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte channels; /* number of channels in file */ - png_byte usr_channels; /* channels at start of write */ - png_byte sig_bytes; /* magic bytes read/written from start of file */ - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -#ifdef PNG_LEGACY_SUPPORTED - png_byte filler; /* filler byte for pixel expansion */ -#else - png_uint_16 filler; /* filler bytes for pixel expansion */ -#endif -#endif - -#if defined(PNG_bKGD_SUPPORTED) - png_byte background_gamma_type; -# ifdef PNG_FLOATING_POINT_SUPPORTED - float background_gamma; -# endif - png_color_16 background; /* background color in screen gamma space */ -#if defined(PNG_READ_GAMMA_SUPPORTED) - png_color_16 background_1; /* background normalized to gamma 1.0 */ -#endif -#endif /* PNG_bKGD_SUPPORTED */ - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_flush_ptr output_flush_fn;/* Function for flushing output */ - png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ - png_uint_32 flush_rows; /* number of rows written since last flush */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - float gamma; /* file gamma value */ - float screen_gamma; /* screen gamma value (display_exponent) */ -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep gamma_table; /* gamma table for 8-bit depth files */ - png_bytep gamma_from_1; /* converts from 1.0 to screen */ - png_bytep gamma_to_1; /* converts from file to 1.0 */ - png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ - png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ - png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) - png_color_8 sig_bit; /* significant bits in each available channel */ -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) - png_color_8 shift; /* shift for significant bit tranformation */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ - || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep trans; /* transparency values for paletted files */ - png_color_16 trans_values; /* transparency values for non-paletted files */ -#endif - - png_read_status_ptr read_row_fn; /* called after each row is decoded */ - png_write_status_ptr write_row_fn; /* called after each row is encoded */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_progressive_info_ptr info_fn; /* called after header data fully read */ - png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ - png_progressive_end_ptr end_fn; /* called after image is complete */ - png_bytep save_buffer_ptr; /* current location in save_buffer */ - png_bytep save_buffer; /* buffer for previously read data */ - png_bytep current_buffer_ptr; /* current location in current_buffer */ - png_bytep current_buffer; /* buffer for recently used data */ - png_uint_32 push_length; /* size of current input chunk */ - png_uint_32 skip_length; /* bytes to skip in input data */ - png_size_t save_buffer_size; /* amount of data now in save_buffer */ - png_size_t save_buffer_max; /* total size of save_buffer */ - png_size_t buffer_size; /* total amount of available input data */ - png_size_t current_buffer_size; /* amount of data now in current_buffer */ - int process_mode; /* what push library is currently doing */ - int cur_palette; /* current push library palette index */ - -# if defined(PNG_TEXT_SUPPORTED) - png_size_t current_text_size; /* current size of text input data */ - png_size_t current_text_left; /* how much text left to read in input */ - png_charp current_text; /* current text chunk buffer */ - png_charp current_text_ptr; /* current location in current_text */ -# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */ - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* for the Borland special 64K segment handler */ - png_bytepp offset_table_ptr; - png_bytep offset_table; - png_uint_16 offset_table_number; - png_uint_16 offset_table_count; - png_uint_16 offset_table_count_free; -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - png_bytep palette_lookup; /* lookup table for dithering */ - png_bytep dither_index; /* index translation for palette files */ -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) - png_uint_16p hist; /* histogram */ -#endif - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_byte heuristic_method; /* heuristic for row filter selection */ - png_byte num_prev_filters; /* number of weights for previous rows */ - png_bytep prev_filters; /* filter type(s) of previous row(s) */ - png_uint_16p filter_weights; /* weight(s) for previous line(s) */ - png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ - png_uint_16p filter_costs; /* relative filter calculation cost */ - png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_charp time_buffer; /* String to hold RFC 1123 time text */ -#endif - -/* New members added in libpng-1.0.6 */ - -#ifdef PNG_FREE_ME_SUPPORTED - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) - png_voidp user_chunk_ptr; - png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - int num_chunk_list; - png_bytep chunk_list; -#endif - -/* New members added in libpng-1.0.3 */ -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - png_byte rgb_to_gray_status; - /* These were changed from png_byte in libpng-1.0.6 */ - png_uint_16 rgb_to_gray_red_coeff; - png_uint_16 rgb_to_gray_green_coeff; - png_uint_16 rgb_to_gray_blue_coeff; -#endif - -/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ - defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* changed from png_byte to png_uint_32 at version 1.2.0 */ -#ifdef PNG_1_0_X - png_byte mng_features_permitted; -#else - png_uint_32 mng_features_permitted; -#endif /* PNG_1_0_X */ -#endif - -/* New member added in libpng-1.0.7 */ -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_fixed_point int_gamma; -#endif - -/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_byte filter_type; -#endif - -#if defined(PNG_1_0_X) || (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)) -/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ - png_uint_32 row_buf_size; -#endif - -/* New members added in libpng-1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -# if !defined(PNG_1_0_X) -# if defined(PNG_MMX_CODE_SUPPORTED) - png_byte mmx_bitdepth_threshold; - png_uint_32 mmx_rowbytes_threshold; -# endif - png_uint_32 asm_flags; -# endif -#endif - -/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ -#ifdef PNG_USER_MEM_SUPPORTED - png_voidp mem_ptr; /* user supplied struct for mem functions */ - png_malloc_ptr malloc_fn; /* function for allocating memory */ - png_free_ptr free_fn; /* function for freeing memory */ -#endif - -/* New member added in libpng-1.0.13 and 1.2.0 */ - png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* The following three members were added at version 1.0.14 and 1.2.4 */ - png_bytep dither_sort; /* working sort array */ - png_bytep index_to_palette; /* where the original index currently is */ - /* in the palette */ - png_bytep palette_to_index; /* which original index points to this */ - /* palette color */ -#endif - -/* New members added in libpng-1.0.16 and 1.2.6 */ - png_byte compression_type; - -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_uint_32 user_width_max; - png_uint_32 user_height_max; -#endif - -}; - - -/* This triggers a compiler error in png.c, if png.c and png.h - * do not agree upon the version number. - */ -typedef png_structp version_1_2_16; - -typedef png_struct FAR * FAR * png_structpp; - -/* Here are the function definitions most commonly used. This is not - * the place to find out how to use libpng. See libpng.txt for the - * full explanation, see example.c for the summary. This just provides - * a simple one line description of the use of each function. - */ - -/* Returns the version number of the library */ -extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); - -/* Tell lib we have already handled the first magic bytes. - * Handling more than 8 bytes from the beginning of the file is an error. - */ -extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, - int num_bytes)); - -/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a - * PNG file. Returns zero if the supplied bytes match the 8-byte PNG - * signature, and non-zero otherwise. Having num_to_check == 0 or - * start > 7 will always fail (ie return non-zero). - */ -extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, - png_size_t num_to_check)); - -/* Simple signature checking function. This is the same as calling - * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). - */ -extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); - -/* Allocate and initialize png_ptr struct for reading, and any other memory. */ -extern PNG_EXPORT(png_structp,png_create_read_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)); - -/* Allocate and initialize png_ptr struct for writing, and any other memory */ -extern PNG_EXPORT(png_structp,png_create_write_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)); - -#ifdef PNG_WRITE_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) - PNGARG((png_structp png_ptr)); -#endif - -#ifdef PNG_WRITE_SUPPORTED -extern PNG_EXPORT(void,png_set_compression_buffer_size) - PNGARG((png_structp png_ptr, png_uint_32 size)); -#endif - -/* Reset the compression stream */ -extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); - -/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ -#ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_structp,png_create_read_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -extern PNG_EXPORT(png_structp,png_create_write_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -#endif - -/* Write a PNG chunk - size, type, (optional) data, CRC. */ -extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_bytep data, png_size_t length)); - -/* Write the start of a PNG chunk - length and chunk name. */ -extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_uint_32 length)); - -/* Write the data of a PNG chunk started with png_write_chunk_start(). */ -extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ -extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); - -/* Allocate and initialize the info structure */ -extern PNG_EXPORT(png_infop,png_create_info_struct) - PNGARG((png_structp png_ptr)); - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize the info structure (old interface - DEPRECATED) */ -extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); -#undef png_info_init -#define png_info_init(info_ptr) png_info_init_3(&info_ptr,\ - png_sizeof(png_info)); -#endif - -extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, - png_size_t png_info_struct_size)); - -/* Writes all the PNG information before the image. */ -extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the information before the actual image data. */ -extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) - PNGARG((png_structp png_ptr, png_timep ptime)); -#endif - -#if !defined(_WIN32_WCE) -/* "time.h" functions are not supported on WindowsCE */ -#if defined(PNG_WRITE_tIME_SUPPORTED) -/* convert from a struct tm to png_time */ -extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, - struct tm FAR * ttime)); - -/* convert from time_t to png_time. Uses gmtime() */ -extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, - time_t ttime)); -#endif /* PNG_WRITE_tIME_SUPPORTED */ -#endif /* _WIN32_WCE */ - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ -extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); -#if !defined(PNG_1_0_X) -extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp - png_ptr)); -#endif -extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated */ -extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); -#endif -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* Use blue, green, red order for pixels. */ -extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -/* Expand the grayscale to 24-bit RGB if necessary. */ -extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -/* Reduce RGB to grayscale. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, - int error_action, double red, double green )); -#endif -extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, - int error_action, png_fixed_point red, png_fixed_point green )); -extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp - png_ptr)); -#endif - -extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, - png_colorp palette)); - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ -extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, - png_uint_32 filler, int flags)); -/* The values of the PNG_FILLER_ defines should NOT be changed */ -#define PNG_FILLER_BEFORE 0 -#define PNG_FILLER_AFTER 1 -/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ -#if !defined(PNG_1_0_X) -extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr, - png_uint_32 filler, int flags)); -#endif -#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* Swap bytes in 16-bit depth files. */ -extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ -extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* Swap packing order of pixels in bytes. */ -extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -/* Converts files to legal bit depths. */ -extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, - png_color_8p true_bits)); -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Have the code handle the interlacing. Returns the number of passes. */ -extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -/* Invert monochrome files */ -extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -/* Handle alpha and tRNS by replacing with a background color. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma)); -#endif -#define PNG_BACKGROUND_GAMMA_UNKNOWN 0 -#define PNG_BACKGROUND_GAMMA_SCREEN 1 -#define PNG_BACKGROUND_GAMMA_FILE 2 -#define PNG_BACKGROUND_GAMMA_UNIQUE 3 -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip the second byte of information from a 16-bit depth file. */ -extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* Turn on dithering, and reduce the palette to the number of colors available. */ -extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette, int maximum_colors, - png_uint_16p histogram, int full_dither)); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -/* Handle gamma correction. Screen_gamma=(display_exponent) */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, - double screen_gamma, double default_file_gamma)); -#endif -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ -/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ -extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, - int empty_plte_permitted)); -#endif -#endif - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -/* Set how many lines between output flushes - 0 for no flushing */ -extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); -/* Flush the current PNG output buffer */ -extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); -#endif - -/* optional update palette with requested transformations */ -extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); - -/* optional call to update the users info structure */ -extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read one or more rows of image data. */ -extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); -#endif - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read a row of data. */ -extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, - png_bytep row, - png_bytep display_row)); -#endif - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the whole image into memory at once. */ -extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, - png_bytepp image)); -#endif - -/* write a row of image data */ -extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, - png_bytep row)); - -/* write a few rows of image data */ -extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_uint_32 num_rows)); - -/* write the image data */ -extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, - png_bytepp image)); - -/* writes the end of the PNG file. */ -extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the end of the PNG file. */ -extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -/* free any memory associated with the png_info_struct */ -extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, - png_infopp info_ptr_ptr)); - -/* free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp - png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); - -/* free all memory used by the read (old method - NOT DLL EXPORTED) */ -extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, - png_infop end_info_ptr)); - -/* free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_write_struct) - PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); - -/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ -extern void png_write_destroy PNGARG((png_structp png_ptr)); - -/* set the libpng method of handling chunk CRC errors */ -extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, - int crit_action, int ancil_action)); - -/* Values for png_set_crc_action() to say how to handle CRC errors in - * ancillary and critical chunks, and whether to use the data contained - * therein. Note that it is impossible to "discard" data in a critical - * chunk. For versions prior to 0.90, the action was always error/quit, - * whereas in version 0.90 and later, the action for CRC errors in ancillary - * chunks is warn/discard. These values should NOT be changed. - * - * value action:critical action:ancillary - */ -#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ -#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ -#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ -#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ -#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ -#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ - -/* These functions give the user control over the scan-line filtering in - * libpng and the compression methods used by zlib. These functions are - * mainly useful for testing, as the defaults should work with most users. - * Those users who are tight on memory or want faster performance at the - * expense of compression can modify them. See the compression library - * header file (zlib.h) for an explination of the compression functions. - */ - -/* set the filtering method(s) used by libpng. Currently, the only valid - * value for "method" is 0. - */ -extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, - int filters)); - -/* Flags for png_set_filter() to say which filters to use. The flags - * are chosen so that they don't conflict with real filter types - * below, in case they are supplied instead of the #defined constants. - * These values should NOT be changed. - */ -#define PNG_NO_FILTERS 0x00 -#define PNG_FILTER_NONE 0x08 -#define PNG_FILTER_SUB 0x10 -#define PNG_FILTER_UP 0x20 -#define PNG_FILTER_AVG 0x40 -#define PNG_FILTER_PAETH 0x80 -#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ - PNG_FILTER_AVG | PNG_FILTER_PAETH) - -/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. - * These defines should NOT be changed. - */ -#define PNG_FILTER_VALUE_NONE 0 -#define PNG_FILTER_VALUE_SUB 1 -#define PNG_FILTER_VALUE_UP 2 -#define PNG_FILTER_VALUE_AVG 3 -#define PNG_FILTER_VALUE_PAETH 4 -#define PNG_FILTER_VALUE_LAST 5 - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ -/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ - * defines, either the default (minimum-sum-of-absolute-differences), or - * the experimental method (weighted-minimum-sum-of-absolute-differences). - * - * Weights are factors >= 1.0, indicating how important it is to keep the - * filter type consistent between rows. Larger numbers mean the current - * filter is that many times as likely to be the same as the "num_weights" - * previous filters. This is cumulative for each previous row with a weight. - * There needs to be "num_weights" values in "filter_weights", or it can be - * NULL if the weights aren't being specified. Weights have no influence on - * the selection of the first row filter. Well chosen weights can (in theory) - * improve the compression for a given image. - * - * Costs are factors >= 1.0 indicating the relative decoding costs of a - * filter type. Higher costs indicate more decoding expense, and are - * therefore less likely to be selected over a filter with lower computational - * costs. There needs to be a value in "filter_costs" for each valid filter - * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't - * setting the costs. Costs try to improve the speed of decompression without - * unduly increasing the compressed image size. - * - * A negative weight or cost indicates the default value is to be used, and - * values in the range [0.0, 1.0) indicate the value is to remain unchanged. - * The default values for both weights and costs are currently 1.0, but may - * change if good general weighting/cost heuristics can be found. If both - * the weights and costs are set to 1.0, this degenerates the WEIGHTED method - * to the UNWEIGHTED method, but with added encoding time/computation. - */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, - int heuristic_method, int num_weights, png_doublep filter_weights, - png_doublep filter_costs)); -#endif -#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ - -/* Heuristic used for row filter selection. These defines should NOT be - * changed. - */ -#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ -#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ -#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ -#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ - -/* Set the library compression level. Currently, valid values range from - * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 - * (0 - no compression, 9 - "maximal" compression). Note that tests have - * shown that zlib compression levels 3-6 usually perform as well as level 9 - * for PNG images, and do considerably fewer caclulations. In the future, - * these values may not correspond directly to the zlib compression levels. - */ -extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, - int level)); - -extern PNG_EXPORT(void,png_set_compression_mem_level) - PNGARG((png_structp png_ptr, int mem_level)); - -extern PNG_EXPORT(void,png_set_compression_strategy) - PNGARG((png_structp png_ptr, int strategy)); - -extern PNG_EXPORT(void,png_set_compression_window_bits) - PNGARG((png_structp png_ptr, int window_bits)); - -extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, - int method)); - -/* These next functions are called for input/output, memory, and error - * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, - * and call standard C I/O routines such as fread(), fwrite(), and - * fprintf(). These functions can be made to use other I/O routines - * at run time for those applications that need to handle I/O in a - * different manner by calling png_set_???_fn(). See libpng.txt for - * more information. - */ - -#if !defined(PNG_NO_STDIO) -/* Initialize the input/output for the PNG file to the default functions. */ -extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); -#endif - -/* Replace the (error and abort), and warning functions with user - * supplied functions. If no messages are to be printed you must still - * write and use replacement functions. The replacement error_fn should - * still do a longjmp to the last setjmp location if you are using this - * method of error handling. If error_fn or warning_fn is NULL, the - * default function will be used. - */ - -extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); - -/* Return the user pointer associated with the error functions */ -extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); - -/* Replace the default data output functions with a user supplied one(s). - * If buffered output is not used, then output_flush_fn can be set to NULL. - * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time - * output_flush_fn will be ignored (and thus can be NULL). - */ -extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); - -/* Replace the default data input function with a user supplied one. */ -extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr read_data_fn)); - -/* Return the user pointer associated with the I/O functions */ -extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); - -extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, - png_read_status_ptr read_row_fn)); - -extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, - png_write_status_ptr write_row_fn)); - -#ifdef PNG_USER_MEM_SUPPORTED -/* Replace the default memory allocation functions with user supplied one(s). */ -extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -/* Return the user pointer associated with the memory functions */ -extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr read_user_transform_fn)); -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr write_user_transform_fn)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp - png_ptr, png_voidp user_transform_ptr, int user_transform_depth, - int user_transform_channels)); -/* Return the user pointer associated with the user transform functions */ -extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) - PNGARG((png_structp png_ptr)); -#endif - -#ifdef PNG_USER_CHUNKS_SUPPORTED -extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, - png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); -extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp - png_ptr)); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -/* Sets the function callbacks for the push reader, and a pointer to a - * user-defined structure available to the callback functions. - */ -extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, - png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn)); - -/* returns the user pointer associated with the push read functions */ -extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) - PNGARG((png_structp png_ptr)); - -/* function to be called when data becomes available */ -extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); - -/* function that combines rows. Not very much different than the - * png_combine_row() call. Is this even used????? - */ -extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, - png_bytep old_row, png_bytep new_row)); -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, - png_uint_32 size)); - -#if defined(PNG_1_0_X) -# define png_malloc_warn png_malloc -#else -/* Added at libpng version 1.2.4 */ -extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, - png_uint_32 size)); -#endif - -/* frees a pointer allocated by png_malloc() */ -extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); - -#if defined(PNG_1_0_X) -/* Function to allocate memory for zlib. */ -extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items, - uInt size)); - -/* Function to free memory for zlib */ -extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr)); -#endif - -/* Free data that was allocated internally */ -extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 free_me, int num)); -#ifdef PNG_FREE_ME_SUPPORTED -/* Reassign responsibility for freeing existing data, whether allocated - * by libpng or by the application */ -extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, - png_infop info_ptr, int freer, png_uint_32 mask)); -#endif -/* assignments for png_data_freer */ -#define PNG_DESTROY_WILL_FREE_DATA 1 -#define PNG_SET_WILL_FREE_DATA 1 -#define PNG_USER_WILL_FREE_DATA 2 -/* Flags for png_ptr->free_me and info_ptr->free_me */ -#define PNG_FREE_HIST 0x0008 -#define PNG_FREE_ICCP 0x0010 -#define PNG_FREE_SPLT 0x0020 -#define PNG_FREE_ROWS 0x0040 -#define PNG_FREE_PCAL 0x0080 -#define PNG_FREE_SCAL 0x0100 -#define PNG_FREE_UNKN 0x0200 -#define PNG_FREE_LIST 0x0400 -#define PNG_FREE_PLTE 0x1000 -#define PNG_FREE_TRNS 0x2000 -#define PNG_FREE_TEXT 0x4000 -#define PNG_FREE_ALL 0x7fff -#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ - -#ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, - png_uint_32 size)); -extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, - png_voidp ptr)); -#endif - -extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, - png_voidp s1, png_voidp s2, png_uint_32 size)); - -extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, - png_voidp s1, int value, png_uint_32 size)); - -#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ -extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, - int check)); -#endif /* USE_FAR_KEYWORD */ - -/* Fatal error in PNG image of libpng - can't continue */ -extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, - png_const_charp error_message)); - -/* The same, but the chunk name is prepended to the error string. */ -extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, - png_const_charp error_message)); - -/* Non-fatal error in libpng. Can continue, but may have a problem. */ -extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, - png_const_charp warning_message)); - -/* Non-fatal error in libpng, chunk name is prepended to message. */ -extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, - png_const_charp warning_message)); - -/* The png_set_ functions are for storing values in the png_info_struct. - * Similarly, the png_get_ calls are used to read values from the - * png_info_struct, either storing the parameters in the passed variables, or - * setting pointers into the png_info_struct where the data is stored. The - * png_get_ functions return a non-zero value if the data was available - * in info_ptr, or return zero and do not change any of the parameters if the - * data was not available. - * - * These functions should be used instead of directly accessing png_info - * to avoid problems with future changes in the size and internal layout of - * png_info_struct. - */ -/* Returns "flag" if chunk data is valid in info_ptr. */ -extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, -png_infop info_ptr, png_uint_32 flag)); - -/* Returns number of bytes needed to hold a transformed row. */ -extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* Returns row_pointers, which is an array of pointers to scanlines that was -returned from png_read_png(). */ -extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, -png_infop info_ptr)); -/* Set row_pointers, which is an array of pointers to scanlines for use -by png_write_png(). */ -extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytepp row_pointers)); -#endif - -/* Returns number of color channels in image. */ -extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* Returns image width in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image height in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image bit_depth. */ -extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image color_type. */ -extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image filter_type. */ -extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image interlace_type. */ -extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image compression_type. */ -extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image resolution in pixels per meter, from pHYs chunk data. */ -extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns pixel aspect ratio, computed from pHYs chunk data. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -#endif - -/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ -extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -#endif /* PNG_EASY_ACCESS_SUPPORTED */ - -/* Returns pointer to signature string read from PNG header */ -extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_bKGD_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p *background)); -#endif - -#if defined(PNG_bKGD_SUPPORTED) -extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p background)); -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *white_x, double *white_y, double *red_x, - double *red_y, double *green_x, double *green_y, double *blue_x, - double *blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point - *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, - png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point - *int_blue_x, png_fixed_point *int_blue_y)); -#endif -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, double white_x, double white_y, double red_x, - double red_y, double green_x, double green_y, double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *file_gamma)); -#endif -extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_file_gamma)); -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double file_gamma)); -#endif -extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_file_gamma)); -#endif - -#if defined(PNG_hIST_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p *hist)); -#endif - -#if defined(PNG_hIST_SUPPORTED) -extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p hist)); -#endif - -extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, - int *bit_depth, int *color_type, int *interlace_method, - int *compression_method, int *filter_method)); - -extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_method, int compression_method, - int filter_method)); - -#if defined(PNG_oFFs_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, - int *unit_type)); -#endif - -#if defined(PNG_oFFs_SUPPORTED) -extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, - int unit_type)); -#endif - -#if defined(PNG_pCAL_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, - int *type, int *nparams, png_charp *units, png_charpp *params)); -#endif - -#if defined(PNG_pCAL_SUPPORTED) -extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, - int type, int nparams, png_charp units, png_charpp params)); -#endif - -#if defined(PNG_pHYs_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); -#endif - -#if defined(PNG_pHYs_SUPPORTED) -extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); -#endif - -extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp *palette, int *num_palette)); - -extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp palette, int num_palette)); - -#if defined(PNG_sBIT_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p *sig_bit)); -#endif - -#if defined(PNG_sBIT_SUPPORTED) -extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p sig_bit)); -#endif - -#if defined(PNG_sRGB_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *intent)); -#endif - -#if defined(PNG_sRGB_SUPPORTED) -extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); -extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); -#endif - -#if defined(PNG_iCCP_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen)); - /* Note to maintainer: profile should be png_bytepp */ -#endif - -#if defined(PNG_iCCP_SUPPORTED) -extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen)); - /* Note to maintainer: profile should be png_bytep */ -#endif - -#if defined(PNG_sPLT_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tpp entries)); -#endif - -#if defined(PNG_sPLT_SUPPORTED) -extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries)); -#endif - -#if defined(PNG_TEXT_SUPPORTED) -/* png_get_text also returns the number of text chunks in *num_text */ -extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp *text_ptr, int *num_text)); -#endif - -/* - * Note while png_set_text() will accept a structure whose text, - * language, and translated keywords are NULL pointers, the structure - * returned by png_get_text will always contain regular - * zero-terminated C strings. They might be empty strings but - * they will never be NULL pointers. - */ - -#if defined(PNG_TEXT_SUPPORTED) -extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif - -#if defined(PNG_tIME_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep *mod_time)); -#endif - -#if defined(PNG_tIME_SUPPORTED) -extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep mod_time)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep *trans, int *num_trans, - png_color_16p *trans_values)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep trans, int num_trans, - png_color_16p trans_values)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -#endif - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, double *width, double *height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); -#endif -#endif -#endif /* PNG_sCAL_SUPPORTED */ - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, double width, double height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); -#endif -#endif -#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -/* provide a list of chunks and how they are to be handled, if the built-in - handling or default unknown chunk handling is not desired. Any chunks not - listed will be handled in the default manner. The IHDR and IEND chunks - must not be listed. - keep = 0: follow default behavour - = 1: do not keep - = 2: keep only if safe-to-copy - = 3: keep even if unsafe-to-copy -*/ -extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp - png_ptr, int keep, png_bytep chunk_list, int num_chunks)); -extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); -extern PNG_EXPORT(void, png_set_unknown_chunk_location) - PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); -extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp - png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); -#endif -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep - chunk_name)); -#endif - -/* Png_free_data() will turn off the "valid" flag for anything it frees. - If you need to turn it off for a chunk that your application has freed, - you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ -extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, - png_infop info_ptr, int mask)); - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* The "params" pointer is currently not used and is for future expansion. */ -extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -#endif - -/* Define PNG_DEBUG at compile time for debugging information. Higher - * numbers for PNG_DEBUG mean more debugging information. This has - * only been added since version 0.95 so it is not implemented throughout - * libpng yet, but more support will be added as needed. - */ -#ifdef PNG_DEBUG -#if (PNG_DEBUG > 0) -#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) -#include -#if (PNG_DEBUG > 1) -#define png_debug(l,m) _RPT0(_CRT_WARN,m) -#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) -#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) -#endif -#else /* PNG_DEBUG_FILE || !_MSC_VER */ -#ifndef PNG_DEBUG_FILE -#define PNG_DEBUG_FILE stderr -#endif /* PNG_DEBUG_FILE */ -#if (PNG_DEBUG > 1) -#define png_debug(l,m) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ -} -#define png_debug1(l,m,p1) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ -} -#define png_debug2(l,m,p1,p2) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ -} -#endif /* (PNG_DEBUG > 1) */ -#endif /* _MSC_VER */ -#endif /* (PNG_DEBUG > 0) */ -#endif /* PNG_DEBUG */ -#ifndef png_debug -#define png_debug(l, m) -#endif -#ifndef png_debug1 -#define png_debug1(l, m, p1) -#endif -#ifndef png_debug2 -#define png_debug2(l, m, p1, p2) -#endif - -#if 0 -extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void)); -#endif - -extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); - -#ifdef PNG_MNG_FEATURES_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp - png_ptr, png_uint_32 mng_features_permitted)); -#endif - -/* For use in png_set_keep_unknown, added to version 1.2.6 */ -#define PNG_HANDLE_CHUNK_AS_DEFAULT 0 -#define PNG_HANDLE_CHUNK_NEVER 1 -#define PNG_HANDLE_CHUNK_IF_SAFE 2 -#define PNG_HANDLE_CHUNK_ALWAYS 3 - -/* Added to version 1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if defined(PNG_MMX_CODE_SUPPORTED) -#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ -#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ -#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 -#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 -#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 -#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 -#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 -#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 -#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ - -#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) -#define PNG_MMX_WRITE_FLAGS ( 0 ) - -#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ - | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ - | PNG_MMX_READ_FLAGS \ - | PNG_MMX_WRITE_FLAGS ) - -#define PNG_SELECT_READ 1 -#define PNG_SELECT_WRITE 2 -#endif /* PNG_MMX_CODE_SUPPORTED */ - -#if !defined(PNG_1_0_X) -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) - PNGARG((int flag_select, int *compilerID)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) - PNGARG((int flag_select)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_asm_flags) - PNGARG((png_structp png_ptr)); - -/* pngget.c */ -extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) - PNGARG((png_structp png_ptr)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) - PNGARG((png_structp png_ptr)); - -/* pngset.c */ -extern PNG_EXPORT(void,png_set_asm_flags) - PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); - -/* pngset.c */ -extern PNG_EXPORT(void,png_set_mmx_thresholds) - PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, - png_uint_32 mmx_rowbytes_threshold)); - -#endif /* PNG_1_0_X */ - -#if !defined(PNG_1_0_X) -/* png.c, pnggccrd.c, or pngvcrd.c */ -extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - -/* Strip the prepended error numbers ("#nnn ") from error and warning - * messages before passing them to the error or warning handler. */ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp - png_ptr, png_uint_32 strip_mode)); -#endif - -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp - png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); -extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp - png_ptr)); -extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp - png_ptr)); -#endif - -/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ - -#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED -/* With these routines we avoid an integer divide, which will be slower on - * most machines. However, it does take more operations than the corresponding - * divide method, so it may be slower on a few RISC systems. There are two - * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. - * - * Note that the rounding factors are NOT supposed to be the same! 128 and - * 32768 are correct for the NODIV code; 127 and 32767 are correct for the - * standard method. - * - * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] - */ - - /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ - -# define png_composite(composite, fg, alpha, bg) \ - { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ - + (png_uint_16)(bg)*(png_uint_16)(255 - \ - (png_uint_16)(alpha)) + (png_uint_16)128); \ - (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } - -# define png_composite_16(composite, fg, alpha, bg) \ - { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ - + (png_uint_32)(bg)*(png_uint_32)(65535L - \ - (png_uint_32)(alpha)) + (png_uint_32)32768L); \ - (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } - -#else /* standard method using integer division */ - -# define png_composite(composite, fg, alpha, bg) \ - (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ - (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ - (png_uint_16)127) / 255) - -# define png_composite_16(composite, fg, alpha, bg) \ - (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ - (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ - (png_uint_32)32767) / (png_uint_32)65535L) - -#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ - -/* Inline macros to do direct reads of bytes from the input buffer. These - * require that you are using an architecture that uses PNG byte ordering - * (MSB first) and supports unaligned data storage. I think that PowerPC - * in big-endian mode and 680x0 are the only ones that will support this. - * The x86 line of processors definitely do not. The png_get_int_32() - * routine also assumes we are using two's complement format for negative - * values, which is almost certainly true. - */ -#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) -# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) -# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) -# define png_get_int_32(buf) ( *((png_int_32p) (buf))) -#else -extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf)); -extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf)); -extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf)); -#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ -extern PNG_EXPORT(png_uint_32,png_get_uint_31) - PNGARG((png_structp png_ptr, png_bytep buf)); -/* No png_get_int_16 -- may be added if there's a real need for it. */ - -/* Place a 32-bit number into a buffer in PNG byte order (big-endian). - */ -extern PNG_EXPORT(void,png_save_uint_32) - PNGARG((png_bytep buf, png_uint_32 i)); -extern PNG_EXPORT(void,png_save_int_32) - PNGARG((png_bytep buf, png_int_32 i)); - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -extern PNG_EXPORT(void,png_save_uint_16) - PNGARG((png_bytep buf, unsigned int i)); -/* No png_save_int_16 -- may be added if there's a real need for it. */ - -/* ************************************************************************* */ - -/* These next functions are used internally in the code. They generally - * shouldn't be used unless you are writing code to add or replace some - * functionality in libpng. More information about most functions can - * be found in the files where the functions are located. - */ - -#if defined(PNG_INTERNAL) - -/* Various modes of operation. Note that after an init, mode is set to - * zero automatically when the structure is created. - */ -#define PNG_HAVE_IHDR 0x01 -#define PNG_HAVE_PLTE 0x02 -#define PNG_HAVE_IDAT 0x04 -#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */ -#define PNG_HAVE_IEND 0x10 -#define PNG_HAVE_gAMA 0x20 -#define PNG_HAVE_cHRM 0x40 -#define PNG_HAVE_sRGB 0x80 -#define PNG_HAVE_CHUNK_HEADER 0x100 -#define PNG_WROTE_tIME 0x200 -#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 -#define PNG_BACKGROUND_IS_GRAY 0x800 -#define PNG_HAVE_PNG_SIGNATURE 0x1000 -#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ - -/* flags for the transformations the PNG library does on the image data */ -#define PNG_BGR 0x0001 -#define PNG_INTERLACE 0x0002 -#define PNG_PACK 0x0004 -#define PNG_SHIFT 0x0008 -#define PNG_SWAP_BYTES 0x0010 -#define PNG_INVERT_MONO 0x0020 -#define PNG_DITHER 0x0040 -#define PNG_BACKGROUND 0x0080 -#define PNG_BACKGROUND_EXPAND 0x0100 - /* 0x0200 unused */ -#define PNG_16_TO_8 0x0400 -#define PNG_RGBA 0x0800 -#define PNG_EXPAND 0x1000 -#define PNG_GAMMA 0x2000 -#define PNG_GRAY_TO_RGB 0x4000 -#define PNG_FILLER 0x8000L -#define PNG_PACKSWAP 0x10000L -#define PNG_SWAP_ALPHA 0x20000L -#define PNG_STRIP_ALPHA 0x40000L -#define PNG_INVERT_ALPHA 0x80000L -#define PNG_USER_TRANSFORM 0x100000L -#define PNG_RGB_TO_GRAY_ERR 0x200000L -#define PNG_RGB_TO_GRAY_WARN 0x400000L -#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ - /* 0x800000L Unused */ -#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */ -#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */ - /* 0x4000000L unused */ - /* 0x8000000L unused */ - /* 0x10000000L unused */ - /* 0x20000000L unused */ - /* 0x40000000L unused */ - -/* flags for png_create_struct */ -#define PNG_STRUCT_PNG 0x0001 -#define PNG_STRUCT_INFO 0x0002 - -/* Scaling factor for filter heuristic weighting calculations */ -#define PNG_WEIGHT_SHIFT 8 -#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) -#define PNG_COST_SHIFT 3 -#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) - -/* flags for the png_ptr->flags rather than declaring a byte for each one */ -#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 -#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 -#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 -#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 -#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 -#define PNG_FLAG_ZLIB_FINISHED 0x0020 -#define PNG_FLAG_ROW_INIT 0x0040 -#define PNG_FLAG_FILLER_AFTER 0x0080 -#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 -#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 -#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 -#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 -#define PNG_FLAG_FREE_PLTE 0x1000 -#define PNG_FLAG_FREE_TRNS 0x2000 -#define PNG_FLAG_FREE_HIST 0x4000 -#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L -#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L -#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L -#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L -#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L -#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L -#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */ -#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */ - /* 0x800000L unused */ - /* 0x1000000L unused */ - /* 0x2000000L unused */ - /* 0x4000000L unused */ - /* 0x8000000L unused */ - /* 0x10000000L unused */ - /* 0x20000000L unused */ - /* 0x40000000L unused */ - -#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ - PNG_FLAG_CRC_ANCILLARY_NOWARN) - -#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ - PNG_FLAG_CRC_CRITICAL_IGNORE) - -#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ - PNG_FLAG_CRC_CRITICAL_MASK) - -/* save typing and make code easier to understand */ - -#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ - abs((int)((c1).green) - (int)((c2).green)) + \ - abs((int)((c1).blue) - (int)((c2).blue))) - -/* Added to libpng-1.2.6 JB */ -#define PNG_ROWBYTES(pixel_bits, width) \ - ((pixel_bits) >= 8 ? \ - ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \ - (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) ) - -/* PNG_OUT_OF_RANGE returns true if value is outside the range - ideal-delta..ideal+delta. Each argument is evaluated twice. - "ideal" and "delta" should be constants, normally simple - integers, "value" a variable. Added to libpng-1.2.6 JB */ -#define PNG_OUT_OF_RANGE(value, ideal, delta) \ - ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) - -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ -#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) -/* place to hold the signature string for a PNG file. */ -#ifdef PNG_USE_GLOBAL_ARRAYS - PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8]; -#else -#if 0 -#define png_sig png_sig_bytes(NULL) -#endif -#endif -#endif /* PNG_NO_EXTERN */ - -/* Constant strings for known chunk types. If you need to add a chunk, - * define the name here, and add an invocation of the macro in png.c and - * wherever it's needed. - */ -#define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} -#define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} -#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} -#define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} -#define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} -#define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} -#define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} -#define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} -#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} -#define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} -#define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} -#define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} -#define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} -#define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} -#define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} -#define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} -#define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} -#define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} -#define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} -#define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} -#define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} - -#ifdef PNG_USE_GLOBAL_ARRAYS -PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5]; -#endif /* PNG_USE_GLOBAL_ARRAYS */ - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize png_ptr struct for reading, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_read_struct instead). - */ -extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); -#undef png_read_init -#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); -#endif - -extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize png_ptr struct for writing, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_write_struct instead). - */ -extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); -#undef png_write_init -#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); -#endif - -extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); - -/* Allocate memory for an internal libpng struct */ -PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); - -/* Free memory from internal libpng struct */ -PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); - -PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr - malloc_fn, png_voidp mem_ptr)); -PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, - png_free_ptr free_fn, png_voidp mem_ptr)); - -/* Free any memory that info_ptr points to and reset struct. */ -PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_1_0_X -/* Function to allocate memory for zlib. */ -PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); - -/* Function to free memory for zlib */ -PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); - -#ifdef PNG_SIZE_T -/* Function to convert a sizeof an item to png_sizeof item */ - PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); -#endif - -/* Next four functions are used internally as callbacks. PNGAPI is required - * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ - -PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -#endif - -PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -#if !defined(PNG_NO_STDIO) -PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); -#endif -#endif -#else /* PNG_1_0_X */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -#endif -#endif /* PNG_1_0_X */ - -/* Reset the CRC variable */ -PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); - -/* Write the "data" buffer to whatever output you are using. */ -PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read data from whatever input you are using into the "data" buffer */ -PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read bytes into buf, and update png_ptr->crc */ -PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, - png_size_t length)); - -/* Decompress data in a chunk that uses compression */ -#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ - defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) -PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, - int comp_type, png_charp chunkdata, png_size_t chunklength, - png_size_t prefix_length, png_size_t *data_length)); -#endif - -/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ -PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); - -/* Read the CRC from the file and compare it to the libpng calculated CRC */ -PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); - -/* Calculate the CRC over a section of data. Note that we are only - * passing a maximum of 64K on systems that have this as a memory limit, - * since this is the maximum buffer size we can specify. - */ -PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, - png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); -#endif - -/* simple function to write the signature */ -PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); - -/* write various chunks */ - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. - */ -PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, - png_uint_32 height, - int bit_depth, int color_type, int compression_method, int filter_method, - int interlace_method)); - -PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, - png_uint_32 num_pal)); - -PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); - -#if defined(PNG_WRITE_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point - file_gamma)); -#endif -#endif - -#if defined(PNG_WRITE_sBIT_SUPPORTED) -PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, - int color_type)); -#endif - -#if defined(PNG_WRITE_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, - double white_x, double white_y, - double red_x, double red_y, double green_x, double green_y, - double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, - png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif -#endif - -#if defined(PNG_WRITE_sRGB_SUPPORTED) -PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, - int intent)); -#endif - -#if defined(PNG_WRITE_iCCP_SUPPORTED) -PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, - png_charp name, int compression_type, - png_charp profile, int proflen)); - /* Note to maintainer: profile should be png_bytep */ -#endif - -#if defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, - png_sPLT_tp palette)); -#endif - -#if defined(PNG_WRITE_tRNS_SUPPORTED) -PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, - png_color_16p values, int number, int color_type)); -#endif - -#if defined(PNG_WRITE_bKGD_SUPPORTED) -PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, - png_color_16p values, int color_type)); -#endif - -#if defined(PNG_WRITE_hIST_SUPPORTED) -PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, - int num_hist)); -#endif - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, - png_charp key, png_charpp new_key)); -#endif - -#if defined(PNG_WRITE_tEXt_SUPPORTED) -PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len)); -#endif - -#if defined(PNG_WRITE_zTXt_SUPPORTED) -PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len, int compression)); -#endif - -#if defined(PNG_WRITE_iTXt_SUPPORTED) -PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, - int compression, png_charp key, png_charp lang, png_charp lang_key, - png_charp text)); -#endif - -#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ -PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif - -#if defined(PNG_WRITE_oFFs_SUPPORTED) -PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, - png_int_32 x_offset, png_int_32 y_offset, int unit_type)); -#endif - -#if defined(PNG_WRITE_pCAL_SUPPORTED) -PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, - png_int_32 X0, png_int_32 X1, int type, int nparams, - png_charp units, png_charpp params)); -#endif - -#if defined(PNG_WRITE_pHYs_SUPPORTED) -PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, - png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, - int unit_type)); -#endif - -#if defined(PNG_WRITE_tIME_SUPPORTED) -PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, - png_timep mod_time)); -#endif - -#if defined(PNG_WRITE_sCAL_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) -PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, - int unit, double width, double height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, - int unit, png_charp width, png_charp height)); -#endif -#endif -#endif - -/* Called when finished processing a row of data */ -PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); - -/* Internal use only. Called before first row of data */ -PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); -#endif - -/* combine a row of data, dealing with alpha, etc. if requested */ -PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, - int mask)); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) -/* expand an interlaced row */ -/* OLD pre-1.0.9 interface: -PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass, png_uint_32 transformations)); - */ -PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); -#endif - -/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* grab pixels out of a row for an interlaced pass */ -PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass)); -#endif - -/* unfilter a row */ -PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, - png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); - -/* Choose the best filter to use and filter the row data */ -PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, - png_row_infop row_info)); - -/* Write out the filtered row. */ -PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, - png_bytep filtered_row)); -/* finish a row while reading, dealing with interlacing passes, etc. */ -PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); - -/* initialize the row buffers, etc. */ -PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); -/* optional call to update the users info structure */ -PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* these are the functions that do the transformations */ -#if defined(PNG_READ_FILLER_SUPPORTED) -PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 filler, png_uint_32 flags)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 flags)); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) -PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop - row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) -PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p sig_bits)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, - png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); - -# if defined(PNG_CORRECT_PALETTE_SUPPORTED) -PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette)); -# endif -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_WRITE_PACK_SUPPORTED) -PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 bit_depth)); -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p bit_depth)); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background, - png_color_16p background_1, - png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, - png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift)); -#else -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background)); -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, - int gamma_shift)); -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, - png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); -PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, - png_bytep row, png_color_16p trans_value)); -#endif - -/* The following decodes the appropriate chunks, and does error correction, - * then calls the appropriate callback for the chunk if it is valid. - */ - -/* decode the IHDR chunk */ -PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); - -#if defined(PNG_READ_bKGD_SUPPORTED) -PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_cHRM_SUPPORTED) -PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_gAMA_SUPPORTED) -PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_hIST_SUPPORTED) -PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_iCCP_SUPPORTED) -extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_oFFs_SUPPORTED) -PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pCAL_SUPPORTED) -PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pHYs_SUPPORTED) -PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sBIT_SUPPORTED) -PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) -PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sPLT_SUPPORTED) -extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_sPLT_SUPPORTED */ - -#if defined(PNG_READ_sRGB_SUPPORTED) -PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tIME_SUPPORTED) -PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tRNS_SUPPORTED) -PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); - -PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, - png_bytep chunk_name)); - -/* handle the transformations for reading and writing */ -PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); - -PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, - png_uint_32 length)); -PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); -PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#ifdef PNG_MNG_FEATURES_SUPPORTED -PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if defined(PNG_MMX_CODE_SUPPORTED) -/* png.c */ /* PRIVATE */ -PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); -#endif -#endif - -#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) -PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_pHYs_SUPPORTED) -PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr, -png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); -#endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ - -/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ - -#endif /* PNG_INTERNAL */ - -#ifdef __cplusplus -} -#endif - -#endif /* PNG_VERSION_INFO_ONLY */ -/* do not put anything past this line */ -#endif /* PNG_H */ + +/* png.h - header file for PNG reference library + * + * libpng version 1.2.16 - January 31, 2007 + * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * Authors and maintainers: + * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat + * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger + * libpng versions 0.97, January 1998, through 1.2.16 - January 31, 2007: Glenn + * See also "Contributing Authors", below. + * + * Note about libpng version numbers: + * + * Due to various miscommunications, unforeseen code incompatibilities + * and occasional factors outside the authors' control, version numbering + * on the library has not always been consistent and straightforward. + * The following table summarizes matters since version 0.89c, which was + * the first widely used release: + * + * source png.h png.h shared-lib + * version string int version + * ------- ------ ----- ---------- + * 0.89c "1.0 beta 3" 0.89 89 1.0.89 + * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] + * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] + * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] + * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] + * 0.97c 0.97 97 2.0.97 + * 0.98 0.98 98 2.0.98 + * 0.99 0.99 98 2.0.99 + * 0.99a-m 0.99 99 2.0.99 + * 1.00 1.00 100 2.1.0 [100 should be 10000] + * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] + * 1.0.1 png.h string is 10001 2.1.0 + * 1.0.1a-e identical to the 10002 from here on, the shared library + * 1.0.2 source version) 10002 is 2.V where V is the source code + * 1.0.2a-b 10003 version, except as noted. + * 1.0.3 10003 + * 1.0.3a-d 10004 + * 1.0.4 10004 + * 1.0.4a-f 10005 + * 1.0.5 (+ 2 patches) 10005 + * 1.0.5a-d 10006 + * 1.0.5e-r 10100 (not source compatible) + * 1.0.5s-v 10006 (not binary compatible) + * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) + * 1.0.6d-f 10007 (still binary incompatible) + * 1.0.6g 10007 + * 1.0.6h 10007 10.6h (testing xy.z so-numbering) + * 1.0.6i 10007 10.6i + * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) + * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) + * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) + * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) + * 1.0.7 1 10007 (still compatible) + * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 + * 1.0.8rc1 1 10008 2.1.0.8rc1 + * 1.0.8 1 10008 2.1.0.8 + * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 + * 1.0.9rc1 1 10009 2.1.0.9rc1 + * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 + * 1.0.9rc2 1 10009 2.1.0.9rc2 + * 1.0.9 1 10009 2.1.0.9 + * 1.0.10beta1 1 10010 2.1.0.10beta1 + * 1.0.10rc1 1 10010 2.1.0.10rc1 + * 1.0.10 1 10010 2.1.0.10 + * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 + * 1.0.11rc1 1 10011 2.1.0.11rc1 + * 1.0.11 1 10011 2.1.0.11 + * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 + * 1.0.12rc1 2 10012 2.1.0.12rc1 + * 1.0.12 2 10012 2.1.0.12 + * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) + * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 + * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 + * 1.2.0rc1 3 10200 3.1.2.0rc1 + * 1.2.0 3 10200 3.1.2.0 + * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 + * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 + * 1.2.1 3 10201 3.1.2.1 + * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 + * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 + * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 + * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 + * 1.0.13 10 10013 10.so.0.1.0.13 + * 1.2.2 12 10202 12.so.0.1.2.2 + * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 + * 1.2.3 12 10203 12.so.0.1.2.3 + * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 + * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 + * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 + * 1.0.14 10 10014 10.so.0.1.0.14 + * 1.2.4 13 10204 12.so.0.1.2.4 + * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 + * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 + * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 + * 1.0.15 10 10015 10.so.0.1.0.15 + * 1.2.5 13 10205 12.so.0.1.2.5 + * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 + * 1.0.16 10 10016 10.so.0.1.0.16 + * 1.2.6 13 10206 12.so.0.1.2.6 + * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 + * 1.0.17rc1 10 10017 10.so.0.1.0.17rc1 + * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 + * 1.0.17 10 10017 10.so.0.1.0.17 + * 1.2.7 13 10207 12.so.0.1.2.7 + * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 + * 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5 + * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 + * 1.0.18 10 10018 10.so.0.1.0.18 + * 1.2.8 13 10208 12.so.0.1.2.8 + * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 + * 1.2.9beta4-11 13 10209 12.so.0.9[.0] + * 1.2.9rc1 13 10209 12.so.0.9[.0] + * 1.2.9 13 10209 12.so.0.9[.0] + * 1.2.10beta1-8 13 10210 12.so.0.10[.0] + * 1.2.10rc1-3 13 10210 12.so.0.10[.0] + * 1.2.10 13 10210 12.so.0.10[.0] + * 1.2.11beta1-4 13 10211 12.so.0.11[.0] + * 1.0.19rc1-5 10 10019 10.so.0.19[.0] + * 1.2.11rc1-5 13 10211 12.so.0.11[.0] + * 1.0.19 10 10019 10.so.0.19[.0] + * 1.2.11 13 10211 12.so.0.11[.0] + * 1.0.20 10 10020 10.so.0.20[.0] + * 1.2.12 13 10212 12.so.0.12[.0] + * 1.2.13beta1 13 10213 12.so.0.13[.0] + * 1.0.21 10 10021 10.so.0.21[.0] + * 1.2.13 13 10213 12.so.0.13[.0] + * 1.2.14beta1-2 13 10214 12.so.0.14[.0] + * 1.0.22rc1 10 10022 10.so.0.22[.0] + * 1.2.14rc1 13 10214 12.so.0.14[.0] + * 1.0.22 10 10022 10.so.0.22[.0] + * 1.2.14 13 10214 12.so.0.14[.0] + * 1.2.15beta1-6 13 10215 12.so.0.15[.0] + * 1.0.23rc1-5 10 10023 10.so.0.23[.0] + * 1.2.15rc1-5 13 10215 12.so.0.15[.0] + * 1.0.23 10 10023 10.so.0.23[.0] + * 1.2.15 13 10215 12.so.0.15[.0] + * 1.2.16beta1-2 13 10216 12.so.0.16[.0] + * 1.2.16rc1 13 10216 12.so.0.16[.0] + * 1.0.24 10 10024 10.so.0.24[.0] + * 1.2.16 13 10216 12.so.0.16[.0] + * + * Henceforth the source version will match the shared-library major + * and minor numbers; the shared-library major version number will be + * used for changes in backward compatibility, as it is intended. The + * PNG_LIBPNG_VER macro, which is not used within libpng but is available + * for applications, is an unsigned integer of the form xyyzz corresponding + * to the source version x.y.z (leading zeros in y and z). Beta versions + * were given the previous public release number plus a letter, until + * version 1.0.6j; from then on they were given the upcoming public + * release number plus "betaNN" or "rcN". + * + * Binary incompatibility exists only when applications make direct access + * to the info_ptr or png_ptr members through png.h, and the compiled + * application is loaded with a different version of the library. + * + * DLLNUM will change each time there are forward or backward changes + * in binary compatibility (e.g., when a new feature is added). + * + * See libpng.txt or libpng.3 for more information. The PNG specification + * is available as a W3C Recommendation and as an ISO Specification, + * defines should NOT be changed. + */ +#define PNG_INFO_gAMA 0x0001 +#define PNG_INFO_sBIT 0x0002 +#define PNG_INFO_cHRM 0x0004 +#define PNG_INFO_PLTE 0x0008 +#define PNG_INFO_tRNS 0x0010 +#define PNG_INFO_bKGD 0x0020 +#define PNG_INFO_hIST 0x0040 +#define PNG_INFO_pHYs 0x0080 +#define PNG_INFO_oFFs 0x0100 +#define PNG_INFO_tIME 0x0200 +#define PNG_INFO_pCAL 0x0400 +#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ +#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ +#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ +#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ +#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ + +/* This is used for the transformation routines, as some of them + * change these values for the row. It also should enable using + * the routines for other purposes. + */ +typedef struct png_row_info_struct +{ + png_uint_32 width; /* width of row */ + png_uint_32 rowbytes; /* number of bytes in row */ + png_byte color_type; /* color type of row */ + png_byte bit_depth; /* bit depth of row */ + png_byte channels; /* number of channels (1, 2, 3, or 4) */ + png_byte pixel_depth; /* bits per pixel (depth * channels) */ +} png_row_info; + +typedef png_row_info FAR * png_row_infop; +typedef png_row_info FAR * FAR * png_row_infopp; + +/* These are the function types for the I/O functions and for the functions + * that allow the user to override the default I/O functions with his or her + * own. The png_error_ptr type should match that of user-supplied warning + * and error functions, while the png_rw_ptr type should match that of the + * user read/write data functions. + */ +typedef struct png_struct_def png_struct; +typedef png_struct FAR * png_structp; + +typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); +typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); +typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); +typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, + int)); +typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, + int)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); +typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); +typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, + png_uint_32, int)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, + png_row_infop, png_bytep)); +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) +typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); +#endif +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); +#endif + +/* Transform masks for the high-level interface */ +#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ +#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ +#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ +#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ +#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ +#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ +#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ +#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ +#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ +#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ +#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ +#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ +#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ + +/* Flags for MNG supported features */ +#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 +#define PNG_FLAG_MNG_FILTER_64 0x04 +#define PNG_ALL_MNG_FEATURES 0x05 + +typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); +typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); + +/* The structure that holds the information to read and write PNG files. + * The only people who need to care about what is inside of this are the + * people who will be modifying the library for their own special needs. + * It should NOT be accessed directly by an application, except to store + * the jmp_buf. + */ + +struct png_struct_def +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf jmpbuf; /* used in png_error */ +#endif + png_error_ptr error_fn; /* function for printing errors and aborting */ + png_error_ptr warning_fn; /* function for printing warnings */ + png_voidp error_ptr; /* user supplied struct for error functions */ + png_rw_ptr write_data_fn; /* function for writing output data */ + png_rw_ptr read_data_fn; /* function for reading input data */ + png_voidp io_ptr; /* ptr to application struct for I/O functions */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr read_user_transform_fn; /* user read transform */ +#endif + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr write_user_transform_fn; /* user write transform */ +#endif + +/* These were added in libpng-1.0.2 */ +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_voidp user_transform_ptr; /* user supplied struct for user transform */ + png_byte user_transform_depth; /* bit depth of user transformed pixels */ + png_byte user_transform_channels; /* channels in user transformed pixels */ +#endif +#endif + + png_uint_32 mode; /* tells us where we are in the PNG file */ + png_uint_32 flags; /* flags indicating various things to libpng */ + png_uint_32 transformations; /* which transformations to perform */ + + z_stream zstream; /* pointer to decompression structure (below) */ + png_bytep zbuf; /* buffer for zlib */ + png_size_t zbuf_size; /* size of zbuf */ + int zlib_level; /* holds zlib compression level */ + int zlib_method; /* holds zlib compression method */ + int zlib_window_bits; /* holds zlib compression window bits */ + int zlib_mem_level; /* holds zlib compression memory level */ + int zlib_strategy; /* holds zlib compression strategy */ + + png_uint_32 width; /* width of image in pixels */ + png_uint_32 height; /* height of image in pixels */ + png_uint_32 num_rows; /* number of rows in current pass */ + png_uint_32 usr_width; /* width of row at start of write */ + png_uint_32 rowbytes; /* size of row in bytes */ + png_uint_32 irowbytes; /* size of current interlaced row in bytes */ + png_uint_32 iwidth; /* width of current interlaced row in pixels */ + png_uint_32 row_number; /* current row in interlace pass */ + png_bytep prev_row; /* buffer to save previous (unfiltered) row */ + png_bytep row_buf; /* buffer to save current (unfiltered) row */ + png_bytep sub_row; /* buffer to save "sub" row when filtering */ + png_bytep up_row; /* buffer to save "up" row when filtering */ + png_bytep avg_row; /* buffer to save "avg" row when filtering */ + png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ + png_row_info row_info; /* used for transformation routines */ + + png_uint_32 idat_size; /* current IDAT size for read */ + png_uint_32 crc; /* current chunk CRC value */ + png_colorp palette; /* palette from the input file */ + png_uint_16 num_palette; /* number of color entries in palette */ + png_uint_16 num_trans; /* number of transparency values */ + png_byte chunk_name[5]; /* null-terminated name of current chunk */ + png_byte compression; /* file compression type (always 0) */ + png_byte filter; /* file filter type (always 0) */ + png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + png_byte pass; /* current interlace pass (0 - 6) */ + png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ + png_byte color_type; /* color type of file */ + png_byte bit_depth; /* bit depth of file */ + png_byte usr_bit_depth; /* bit depth of users row */ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte channels; /* number of channels in file */ + png_byte usr_channels; /* channels at start of write */ + png_byte sig_bytes; /* magic bytes read/written from start of file */ + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +#ifdef PNG_LEGACY_SUPPORTED + png_byte filler; /* filler byte for pixel expansion */ +#else + png_uint_16 filler; /* filler bytes for pixel expansion */ +#endif +#endif + +#if defined(PNG_bKGD_SUPPORTED) + png_byte background_gamma_type; +# ifdef PNG_FLOATING_POINT_SUPPORTED + float background_gamma; +# endif + png_color_16 background; /* background color in screen gamma space */ +#if defined(PNG_READ_GAMMA_SUPPORTED) + png_color_16 background_1; /* background normalized to gamma 1.0 */ +#endif +#endif /* PNG_bKGD_SUPPORTED */ + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) + png_flush_ptr output_flush_fn;/* Function for flushing output */ + png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ + png_uint_32 flush_rows; /* number of rows written since last flush */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ +#ifdef PNG_FLOATING_POINT_SUPPORTED + float gamma; /* file gamma value */ + float screen_gamma; /* screen gamma value (display_exponent) */ +#endif +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep gamma_table; /* gamma table for 8-bit depth files */ + png_bytep gamma_from_1; /* converts from 1.0 to screen */ + png_bytep gamma_to_1; /* converts from file to 1.0 */ + png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ + png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ + png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) + png_color_8 sig_bit; /* significant bits in each available channel */ +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) + png_color_8 shift; /* shift for significant bit tranformation */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ + || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep trans; /* transparency values for paletted files */ + png_color_16 trans_values; /* transparency values for non-paletted files */ +#endif + + png_read_status_ptr read_row_fn; /* called after each row is decoded */ + png_write_status_ptr write_row_fn; /* called after each row is encoded */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + png_progressive_info_ptr info_fn; /* called after header data fully read */ + png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ + png_progressive_end_ptr end_fn; /* called after image is complete */ + png_bytep save_buffer_ptr; /* current location in save_buffer */ + png_bytep save_buffer; /* buffer for previously read data */ + png_bytep current_buffer_ptr; /* current location in current_buffer */ + png_bytep current_buffer; /* buffer for recently used data */ + png_uint_32 push_length; /* size of current input chunk */ + png_uint_32 skip_length; /* bytes to skip in input data */ + png_size_t save_buffer_size; /* amount of data now in save_buffer */ + png_size_t save_buffer_max; /* total size of save_buffer */ + png_size_t buffer_size; /* total amount of available input data */ + png_size_t current_buffer_size; /* amount of data now in current_buffer */ + int process_mode; /* what push library is currently doing */ + int cur_palette; /* current push library palette index */ + +# if defined(PNG_TEXT_SUPPORTED) + png_size_t current_text_size; /* current size of text input data */ + png_size_t current_text_left; /* how much text left to read in input */ + png_charp current_text; /* current text chunk buffer */ + png_charp current_text_ptr; /* current location in current_text */ +# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */ + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) +/* for the Borland special 64K segment handler */ + png_bytepp offset_table_ptr; + png_bytep offset_table; + png_uint_16 offset_table_number; + png_uint_16 offset_table_count; + png_uint_16 offset_table_count_free; +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) + png_bytep palette_lookup; /* lookup table for dithering */ + png_bytep dither_index; /* index translation for palette files */ +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) + png_uint_16p hist; /* histogram */ +#endif + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + png_byte heuristic_method; /* heuristic for row filter selection */ + png_byte num_prev_filters; /* number of weights for previous rows */ + png_bytep prev_filters; /* filter type(s) of previous row(s) */ + png_uint_16p filter_weights; /* weight(s) for previous line(s) */ + png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ + png_uint_16p filter_costs; /* relative filter calculation cost */ + png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ +#endif + +#if defined(PNG_TIME_RFC1123_SUPPORTED) + png_charp time_buffer; /* String to hold RFC 1123 time text */ +#endif + +/* New members added in libpng-1.0.6 */ + +#ifdef PNG_FREE_ME_SUPPORTED + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) + png_voidp user_chunk_ptr; + png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + int num_chunk_list; + png_bytep chunk_list; +#endif + +/* New members added in libpng-1.0.3 */ +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + png_byte rgb_to_gray_status; + /* These were changed from png_byte in libpng-1.0.6 */ + png_uint_16 rgb_to_gray_red_coeff; + png_uint_16 rgb_to_gray_green_coeff; + png_uint_16 rgb_to_gray_blue_coeff; +#endif + +/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ + defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +/* changed from png_byte to png_uint_32 at version 1.2.0 */ +#ifdef PNG_1_0_X + png_byte mng_features_permitted; +#else + png_uint_32 mng_features_permitted; +#endif /* PNG_1_0_X */ +#endif + +/* New member added in libpng-1.0.7 */ +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_fixed_point int_gamma; +#endif + +/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) + png_byte filter_type; +#endif + +#if defined(PNG_1_0_X) || (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)) +/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ + png_uint_32 row_buf_size; +#endif + +/* New members added in libpng-1.2.0 */ +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +# if !defined(PNG_1_0_X) +# if defined(PNG_MMX_CODE_SUPPORTED) + png_byte mmx_bitdepth_threshold; + png_uint_32 mmx_rowbytes_threshold; +# endif + png_uint_32 asm_flags; +# endif +#endif + +/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ +#ifdef PNG_USER_MEM_SUPPORTED + png_voidp mem_ptr; /* user supplied struct for mem functions */ + png_malloc_ptr malloc_fn; /* function for allocating memory */ + png_free_ptr free_fn; /* function for freeing memory */ +#endif + +/* New member added in libpng-1.0.13 and 1.2.0 */ + png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ + +#if defined(PNG_READ_DITHER_SUPPORTED) +/* The following three members were added at version 1.0.14 and 1.2.4 */ + png_bytep dither_sort; /* working sort array */ + png_bytep index_to_palette; /* where the original index currently is */ + /* in the palette */ + png_bytep palette_to_index; /* which original index points to this */ + /* palette color */ +#endif + +/* New members added in libpng-1.0.16 and 1.2.6 */ + png_byte compression_type; + +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + png_uint_32 user_width_max; + png_uint_32 user_height_max; +#endif + +}; + + +/* This triggers a compiler error in png.c, if png.c and png.h + * do not agree upon the version number. + */ +typedef png_structp version_1_2_16; + +typedef png_struct FAR * FAR * png_structpp; + +/* Here are the function definitions most commonly used. This is not + * the place to find out how to use libpng. See libpng.txt for the + * full explanation, see example.c for the summary. This just provides + * a simple one line description of the use of each function. + */ + +/* Returns the version number of the library */ +extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); + +/* Tell lib we have already handled the first magic bytes. + * Handling more than 8 bytes from the beginning of the file is an error. + */ +extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, + int num_bytes)); + +/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a + * PNG file. Returns zero if the supplied bytes match the 8-byte PNG + * signature, and non-zero otherwise. Having num_to_check == 0 or + * start > 7 will always fail (ie return non-zero). + */ +extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, + png_size_t num_to_check)); + +/* Simple signature checking function. This is the same as calling + * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). + */ +extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); + +/* Allocate and initialize png_ptr struct for reading, and any other memory. */ +extern PNG_EXPORT(png_structp,png_create_read_struct) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn)); + +/* Allocate and initialize png_ptr struct for writing, and any other memory */ +extern PNG_EXPORT(png_structp,png_create_write_struct) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn)); + +#ifdef PNG_WRITE_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) + PNGARG((png_structp png_ptr)); +#endif + +#ifdef PNG_WRITE_SUPPORTED +extern PNG_EXPORT(void,png_set_compression_buffer_size) + PNGARG((png_structp png_ptr, png_uint_32 size)); +#endif + +/* Reset the compression stream */ +extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); + +/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ +#ifdef PNG_USER_MEM_SUPPORTED +extern PNG_EXPORT(png_structp,png_create_read_struct_2) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +extern PNG_EXPORT(png_structp,png_create_write_struct_2) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +#endif + +/* Write a PNG chunk - size, type, (optional) data, CRC. */ +extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, + png_bytep chunk_name, png_bytep data, png_size_t length)); + +/* Write the start of a PNG chunk - length and chunk name. */ +extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, + png_bytep chunk_name, png_uint_32 length)); + +/* Write the data of a PNG chunk started with png_write_chunk_start(). */ +extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ +extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); + +/* Allocate and initialize the info structure */ +extern PNG_EXPORT(png_infop,png_create_info_struct) + PNGARG((png_structp png_ptr)); + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Initialize the info structure (old interface - DEPRECATED) */ +extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); +#undef png_info_init +#define png_info_init(info_ptr) png_info_init_3(&info_ptr,\ + png_sizeof(png_info)); +#endif + +extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, + png_size_t png_info_struct_size)); + +/* Writes all the PNG information before the image. */ +extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr)); +extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read the information before the actual image data. */ +extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif + +#if defined(PNG_TIME_RFC1123_SUPPORTED) +extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) + PNGARG((png_structp png_ptr, png_timep ptime)); +#endif + +#if !defined(_WIN32_WCE) +/* "time.h" functions are not supported on WindowsCE */ +#if defined(PNG_WRITE_tIME_SUPPORTED) +/* convert from a struct tm to png_time */ +extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, + struct tm FAR * ttime)); + +/* convert from time_t to png_time. Uses gmtime() */ +extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, + time_t ttime)); +#endif /* PNG_WRITE_tIME_SUPPORTED */ +#endif /* _WIN32_WCE */ + +#if defined(PNG_READ_EXPAND_SUPPORTED) +/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ +extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); +#if !defined(PNG_1_0_X) +extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp + png_ptr)); +#endif +extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Deprecated */ +extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); +#endif +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +/* Use blue, green, red order for pixels. */ +extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +/* Expand the grayscale to 24-bit RGB if necessary. */ +extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +/* Reduce RGB to grayscale. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, + int error_action, double red, double green )); +#endif +extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, + int error_action, png_fixed_point red, png_fixed_point green )); +extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp + png_ptr)); +#endif + +extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, + png_colorp palette)); + +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ +extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, + png_uint_32 filler, int flags)); +/* The values of the PNG_FILLER_ defines should NOT be changed */ +#define PNG_FILLER_BEFORE 0 +#define PNG_FILLER_AFTER 1 +/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ +#if !defined(PNG_1_0_X) +extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr, + png_uint_32 filler, int flags)); +#endif +#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +/* Swap bytes in 16-bit depth files. */ +extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) +/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ +extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) +/* Swap packing order of pixels in bytes. */ +extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) +/* Converts files to legal bit depths. */ +extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, + png_color_8p true_bits)); +#endif + +#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ + defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* Have the code handle the interlacing. Returns the number of passes. */ +extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +/* Invert monochrome files */ +extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +/* Handle alpha and tRNS by replacing with a background color. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, + png_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma)); +#endif +#define PNG_BACKGROUND_GAMMA_UNKNOWN 0 +#define PNG_BACKGROUND_GAMMA_SCREEN 1 +#define PNG_BACKGROUND_GAMMA_FILE 2 +#define PNG_BACKGROUND_GAMMA_UNIQUE 3 +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +/* strip the second byte of information from a 16-bit depth file. */ +extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +/* Turn on dithering, and reduce the palette to the number of colors available. */ +extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette, int maximum_colors, + png_uint_16p histogram, int full_dither)); +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +/* Handle gamma correction. Screen_gamma=(display_exponent) */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, + double screen_gamma, double default_file_gamma)); +#endif +#endif + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ +/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ +extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, + int empty_plte_permitted)); +#endif +#endif + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +/* Set how many lines between output flushes - 0 for no flushing */ +extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); +/* Flush the current PNG output buffer */ +extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); +#endif + +/* optional update palette with requested transformations */ +extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); + +/* optional call to update the users info structure */ +extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read one or more rows of image data. */ +extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, + png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); +#endif + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read a row of data. */ +extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, + png_bytep row, + png_bytep display_row)); +#endif + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read the whole image into memory at once. */ +extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, + png_bytepp image)); +#endif + +/* write a row of image data */ +extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, + png_bytep row)); + +/* write a few rows of image data */ +extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, + png_bytepp row, png_uint_32 num_rows)); + +/* write the image data */ +extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, + png_bytepp image)); + +/* writes the end of the PNG file. */ +extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read the end of the PNG file. */ +extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif + +/* free any memory associated with the png_info_struct */ +extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, + png_infopp info_ptr_ptr)); + +/* free any memory associated with the png_struct and the png_info_structs */ +extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp + png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); + +/* free all memory used by the read (old method - NOT DLL EXPORTED) */ +extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, + png_infop end_info_ptr)); + +/* free any memory associated with the png_struct and the png_info_structs */ +extern PNG_EXPORT(void,png_destroy_write_struct) + PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); + +/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ +extern void png_write_destroy PNGARG((png_structp png_ptr)); + +/* set the libpng method of handling chunk CRC errors */ +extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, + int crit_action, int ancil_action)); + +/* Values for png_set_crc_action() to say how to handle CRC errors in + * ancillary and critical chunks, and whether to use the data contained + * therein. Note that it is impossible to "discard" data in a critical + * chunk. For versions prior to 0.90, the action was always error/quit, + * whereas in version 0.90 and later, the action for CRC errors in ancillary + * chunks is warn/discard. These values should NOT be changed. + * + * value action:critical action:ancillary + */ +#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ +#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ +#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ +#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ +#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ +#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ + +/* These functions give the user control over the scan-line filtering in + * libpng and the compression methods used by zlib. These functions are + * mainly useful for testing, as the defaults should work with most users. + * Those users who are tight on memory or want faster performance at the + * expense of compression can modify them. See the compression library + * header file (zlib.h) for an explination of the compression functions. + */ + +/* set the filtering method(s) used by libpng. Currently, the only valid + * value for "method" is 0. + */ +extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, + int filters)); + +/* Flags for png_set_filter() to say which filters to use. The flags + * are chosen so that they don't conflict with real filter types + * below, in case they are supplied instead of the #defined constants. + * These values should NOT be changed. + */ +#define PNG_NO_FILTERS 0x00 +#define PNG_FILTER_NONE 0x08 +#define PNG_FILTER_SUB 0x10 +#define PNG_FILTER_UP 0x20 +#define PNG_FILTER_AVG 0x40 +#define PNG_FILTER_PAETH 0x80 +#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ + PNG_FILTER_AVG | PNG_FILTER_PAETH) + +/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. + * These defines should NOT be changed. + */ +#define PNG_FILTER_VALUE_NONE 0 +#define PNG_FILTER_VALUE_SUB 1 +#define PNG_FILTER_VALUE_UP 2 +#define PNG_FILTER_VALUE_AVG 3 +#define PNG_FILTER_VALUE_PAETH 4 +#define PNG_FILTER_VALUE_LAST 5 + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ +/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ + * defines, either the default (minimum-sum-of-absolute-differences), or + * the experimental method (weighted-minimum-sum-of-absolute-differences). + * + * Weights are factors >= 1.0, indicating how important it is to keep the + * filter type consistent between rows. Larger numbers mean the current + * filter is that many times as likely to be the same as the "num_weights" + * previous filters. This is cumulative for each previous row with a weight. + * There needs to be "num_weights" values in "filter_weights", or it can be + * NULL if the weights aren't being specified. Weights have no influence on + * the selection of the first row filter. Well chosen weights can (in theory) + * improve the compression for a given image. + * + * Costs are factors >= 1.0 indicating the relative decoding costs of a + * filter type. Higher costs indicate more decoding expense, and are + * therefore less likely to be selected over a filter with lower computational + * costs. There needs to be a value in "filter_costs" for each valid filter + * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't + * setting the costs. Costs try to improve the speed of decompression without + * unduly increasing the compressed image size. + * + * A negative weight or cost indicates the default value is to be used, and + * values in the range [0.0, 1.0) indicate the value is to remain unchanged. + * The default values for both weights and costs are currently 1.0, but may + * change if good general weighting/cost heuristics can be found. If both + * the weights and costs are set to 1.0, this degenerates the WEIGHTED method + * to the UNWEIGHTED method, but with added encoding time/computation. + */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, + int heuristic_method, int num_weights, png_doublep filter_weights, + png_doublep filter_costs)); +#endif +#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ + +/* Heuristic used for row filter selection. These defines should NOT be + * changed. + */ +#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ +#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ +#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ +#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ + +/* Set the library compression level. Currently, valid values range from + * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 + * (0 - no compression, 9 - "maximal" compression). Note that tests have + * shown that zlib compression levels 3-6 usually perform as well as level 9 + * for PNG images, and do considerably fewer caclulations. In the future, + * these values may not correspond directly to the zlib compression levels. + */ +extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, + int level)); + +extern PNG_EXPORT(void,png_set_compression_mem_level) + PNGARG((png_structp png_ptr, int mem_level)); + +extern PNG_EXPORT(void,png_set_compression_strategy) + PNGARG((png_structp png_ptr, int strategy)); + +extern PNG_EXPORT(void,png_set_compression_window_bits) + PNGARG((png_structp png_ptr, int window_bits)); + +extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, + int method)); + +/* These next functions are called for input/output, memory, and error + * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, + * and call standard C I/O routines such as fread(), fwrite(), and + * fprintf(). These functions can be made to use other I/O routines + * at run time for those applications that need to handle I/O in a + * different manner by calling png_set_???_fn(). See libpng.txt for + * more information. + */ + +#if !defined(PNG_NO_STDIO) +/* Initialize the input/output for the PNG file to the default functions. */ +extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); +#endif + +/* Replace the (error and abort), and warning functions with user + * supplied functions. If no messages are to be printed you must still + * write and use replacement functions. The replacement error_fn should + * still do a longjmp to the last setjmp location if you are using this + * method of error handling. If error_fn or warning_fn is NULL, the + * default function will be used. + */ + +extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, + png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); + +/* Return the user pointer associated with the error functions */ +extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); + +/* Replace the default data output functions with a user supplied one(s). + * If buffered output is not used, then output_flush_fn can be set to NULL. + * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time + * output_flush_fn will be ignored (and thus can be NULL). + */ +extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, + png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); + +/* Replace the default data input function with a user supplied one. */ +extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, + png_voidp io_ptr, png_rw_ptr read_data_fn)); + +/* Return the user pointer associated with the I/O functions */ +extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); + +extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, + png_read_status_ptr read_row_fn)); + +extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, + png_write_status_ptr write_row_fn)); + +#ifdef PNG_USER_MEM_SUPPORTED +/* Replace the default memory allocation functions with user supplied one(s). */ +extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +/* Return the user pointer associated with the memory functions */ +extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr read_user_transform_fn)); +#endif + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr write_user_transform_fn)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp + png_ptr, png_voidp user_transform_ptr, int user_transform_depth, + int user_transform_channels)); +/* Return the user pointer associated with the user transform functions */ +extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) + PNGARG((png_structp png_ptr)); +#endif + +#ifdef PNG_USER_CHUNKS_SUPPORTED +extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, + png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); +extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp + png_ptr)); +#endif + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +/* Sets the function callbacks for the push reader, and a pointer to a + * user-defined structure available to the callback functions. + */ +extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, + png_voidp progressive_ptr, + png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, + png_progressive_end_ptr end_fn)); + +/* returns the user pointer associated with the push read functions */ +extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) + PNGARG((png_structp png_ptr)); + +/* function to be called when data becomes available */ +extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); + +/* function that combines rows. Not very much different than the + * png_combine_row() call. Is this even used????? + */ +extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, + png_bytep old_row, png_bytep new_row)); +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, + png_uint_32 size)); + +#if defined(PNG_1_0_X) +# define png_malloc_warn png_malloc +#else +/* Added at libpng version 1.2.4 */ +extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, + png_uint_32 size)); +#endif + +/* frees a pointer allocated by png_malloc() */ +extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); + +#if defined(PNG_1_0_X) +/* Function to allocate memory for zlib. */ +extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items, + uInt size)); + +/* Function to free memory for zlib */ +extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr)); +#endif + +/* Free data that was allocated internally */ +extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 free_me, int num)); +#ifdef PNG_FREE_ME_SUPPORTED +/* Reassign responsibility for freeing existing data, whether allocated + * by libpng or by the application */ +extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, + png_infop info_ptr, int freer, png_uint_32 mask)); +#endif +/* assignments for png_data_freer */ +#define PNG_DESTROY_WILL_FREE_DATA 1 +#define PNG_SET_WILL_FREE_DATA 1 +#define PNG_USER_WILL_FREE_DATA 2 +/* Flags for png_ptr->free_me and info_ptr->free_me */ +#define PNG_FREE_HIST 0x0008 +#define PNG_FREE_ICCP 0x0010 +#define PNG_FREE_SPLT 0x0020 +#define PNG_FREE_ROWS 0x0040 +#define PNG_FREE_PCAL 0x0080 +#define PNG_FREE_SCAL 0x0100 +#define PNG_FREE_UNKN 0x0200 +#define PNG_FREE_LIST 0x0400 +#define PNG_FREE_PLTE 0x1000 +#define PNG_FREE_TRNS 0x2000 +#define PNG_FREE_TEXT 0x4000 +#define PNG_FREE_ALL 0x7fff +#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ + +#ifdef PNG_USER_MEM_SUPPORTED +extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, + png_uint_32 size)); +extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, + png_voidp ptr)); +#endif + +extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, + png_voidp s1, png_voidp s2, png_uint_32 size)); + +extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, + png_voidp s1, int value, png_uint_32 size)); + +#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ +extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, + int check)); +#endif /* USE_FAR_KEYWORD */ + +/* Fatal error in PNG image of libpng - can't continue */ +extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, + png_const_charp error_message)); + +/* The same, but the chunk name is prepended to the error string. */ +extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, + png_const_charp error_message)); + +/* Non-fatal error in libpng. Can continue, but may have a problem. */ +extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, + png_const_charp warning_message)); + +/* Non-fatal error in libpng, chunk name is prepended to message. */ +extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, + png_const_charp warning_message)); + +/* The png_set_ functions are for storing values in the png_info_struct. + * Similarly, the png_get_ calls are used to read values from the + * png_info_struct, either storing the parameters in the passed variables, or + * setting pointers into the png_info_struct where the data is stored. The + * png_get_ functions return a non-zero value if the data was available + * in info_ptr, or return zero and do not change any of the parameters if the + * data was not available. + * + * These functions should be used instead of directly accessing png_info + * to avoid problems with future changes in the size and internal layout of + * png_info_struct. + */ +/* Returns "flag" if chunk data is valid in info_ptr. */ +extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, +png_infop info_ptr, png_uint_32 flag)); + +/* Returns number of bytes needed to hold a transformed row. */ +extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* Returns row_pointers, which is an array of pointers to scanlines that was +returned from png_read_png(). */ +extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, +png_infop info_ptr)); +/* Set row_pointers, which is an array of pointers to scanlines for use +by png_write_png(). */ +extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytepp row_pointers)); +#endif + +/* Returns number of color channels in image. */ +extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#ifdef PNG_EASY_ACCESS_SUPPORTED +/* Returns image width in pixels. */ +extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image height in pixels. */ +extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image bit_depth. */ +extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image color_type. */ +extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image filter_type. */ +extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image interlace_type. */ +extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image compression_type. */ +extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image resolution in pixels per meter, from pHYs chunk data. */ +extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns pixel aspect ratio, computed from pHYs chunk data. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +#endif + +/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ +extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +#endif /* PNG_EASY_ACCESS_SUPPORTED */ + +/* Returns pointer to signature string read from PNG header */ +extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_bKGD_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_16p *background)); +#endif + +#if defined(PNG_bKGD_SUPPORTED) +extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_16p background)); +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, double *white_x, double *white_y, double *red_x, + double *red_y, double *green_x, double *green_y, double *blue_x, + double *blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point + *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, + png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point + *int_blue_x, png_fixed_point *int_blue_y)); +#endif +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, double white_x, double white_y, double red_x, + double red_y, double green_x, double green_y, double blue_x, double blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, + png_infop info_ptr, double *file_gamma)); +#endif +extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_file_gamma)); +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, + png_infop info_ptr, double file_gamma)); +#endif +extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_file_gamma)); +#endif + +#if defined(PNG_hIST_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_16p *hist)); +#endif + +#if defined(PNG_hIST_SUPPORTED) +extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_16p hist)); +#endif + +extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, + int *bit_depth, int *color_type, int *interlace_method, + int *compression_method, int *filter_method)); + +extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_method, int compression_method, + int filter_method)); + +#if defined(PNG_oFFs_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, + int *unit_type)); +#endif + +#if defined(PNG_oFFs_SUPPORTED) +extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, + int unit_type)); +#endif + +#if defined(PNG_pCAL_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, + int *type, int *nparams, png_charp *units, png_charpp *params)); +#endif + +#if defined(PNG_pCAL_SUPPORTED) +extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, + int type, int nparams, png_charp units, png_charpp params)); +#endif + +#if defined(PNG_pHYs_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); +#endif + +#if defined(PNG_pHYs_SUPPORTED) +extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); +#endif + +extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_colorp *palette, int *num_palette)); + +extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_colorp palette, int num_palette)); + +#if defined(PNG_sBIT_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_8p *sig_bit)); +#endif + +#if defined(PNG_sBIT_SUPPORTED) +extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_8p sig_bit)); +#endif + +#if defined(PNG_sRGB_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *intent)); +#endif + +#if defined(PNG_sRGB_SUPPORTED) +extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, + png_infop info_ptr, int intent)); +extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, int intent)); +#endif + +#if defined(PNG_iCCP_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charpp name, int *compression_type, + png_charpp profile, png_uint_32 *proflen)); + /* Note to maintainer: profile should be png_bytepp */ +#endif + +#if defined(PNG_iCCP_SUPPORTED) +extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp name, int compression_type, + png_charp profile, png_uint_32 proflen)); + /* Note to maintainer: profile should be png_bytep */ +#endif + +#if defined(PNG_sPLT_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_sPLT_tpp entries)); +#endif + +#if defined(PNG_sPLT_SUPPORTED) +extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_sPLT_tp entries, int nentries)); +#endif + +#if defined(PNG_TEXT_SUPPORTED) +/* png_get_text also returns the number of text chunks in *num_text */ +extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp *text_ptr, int *num_text)); +#endif + +/* + * Note while png_set_text() will accept a structure whose text, + * language, and translated keywords are NULL pointers, the structure + * returned by png_get_text will always contain regular + * zero-terminated C strings. They might be empty strings but + * they will never be NULL pointers. + */ + +#if defined(PNG_TEXT_SUPPORTED) +extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp text_ptr, int num_text)); +#endif + +#if defined(PNG_tIME_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_timep *mod_time)); +#endif + +#if defined(PNG_tIME_SUPPORTED) +extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_timep mod_time)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep *trans, int *num_trans, + png_color_16p *trans_values)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep trans, int num_trans, + png_color_16p trans_values)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +#endif + +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *unit, double *width, double *height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); +#endif +#endif +#endif /* PNG_sCAL_SUPPORTED */ + +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, int unit, double width, double height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, + png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); +#endif +#endif +#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +/* provide a list of chunks and how they are to be handled, if the built-in + handling or default unknown chunk handling is not desired. Any chunks not + listed will be handled in the default manner. The IHDR and IEND chunks + must not be listed. + keep = 0: follow default behavour + = 1: do not keep + = 2: keep only if safe-to-copy + = 3: keep even if unsafe-to-copy +*/ +extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp + png_ptr, int keep, png_bytep chunk_list, int num_chunks)); +extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); +extern PNG_EXPORT(void, png_set_unknown_chunk_location) + PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); +extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp + png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); +#endif +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep + chunk_name)); +#endif + +/* Png_free_data() will turn off the "valid" flag for anything it frees. + If you need to turn it off for a chunk that your application has freed, + you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ +extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, + png_infop info_ptr, int mask)); + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* The "params" pointer is currently not used and is for future expansion. */ +extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, + png_infop info_ptr, + int transforms, + png_voidp params)); +extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, + png_infop info_ptr, + int transforms, + png_voidp params)); +#endif + +/* Define PNG_DEBUG at compile time for debugging information. Higher + * numbers for PNG_DEBUG mean more debugging information. This has + * only been added since version 0.95 so it is not implemented throughout + * libpng yet, but more support will be added as needed. + */ +#ifdef PNG_DEBUG +#if (PNG_DEBUG > 0) +#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) +#include +#if (PNG_DEBUG > 1) +#define png_debug(l,m) _RPT0(_CRT_WARN,m) +#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) +#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) +#endif +#else /* PNG_DEBUG_FILE || !_MSC_VER */ +#ifndef PNG_DEBUG_FILE +#define PNG_DEBUG_FILE stderr +#endif /* PNG_DEBUG_FILE */ +#if (PNG_DEBUG > 1) +#define png_debug(l,m) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ +} +#define png_debug1(l,m,p1) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ +} +#define png_debug2(l,m,p1,p2) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ +} +#endif /* (PNG_DEBUG > 1) */ +#endif /* _MSC_VER */ +#endif /* (PNG_DEBUG > 0) */ +#endif /* PNG_DEBUG */ +#ifndef png_debug +#define png_debug(l, m) +#endif +#ifndef png_debug1 +#define png_debug1(l, m, p1) +#endif +#ifndef png_debug2 +#define png_debug2(l, m, p1, p2) +#endif + +#if 0 +extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void)); +#endif + +extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); + +#ifdef PNG_MNG_FEATURES_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp + png_ptr, png_uint_32 mng_features_permitted)); +#endif + +/* For use in png_set_keep_unknown, added to version 1.2.6 */ +#define PNG_HANDLE_CHUNK_AS_DEFAULT 0 +#define PNG_HANDLE_CHUNK_NEVER 1 +#define PNG_HANDLE_CHUNK_IF_SAFE 2 +#define PNG_HANDLE_CHUNK_ALWAYS 3 + +/* Added to version 1.2.0 */ +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +#if defined(PNG_MMX_CODE_SUPPORTED) +#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ +#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ +#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 +#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 +#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 +#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 +#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 +#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 +#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ + +#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ + | PNG_ASM_FLAG_MMX_READ_INTERLACE \ + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ + | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) +#define PNG_MMX_WRITE_FLAGS ( 0 ) + +#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ + | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ + | PNG_MMX_READ_FLAGS \ + | PNG_MMX_WRITE_FLAGS ) + +#define PNG_SELECT_READ 1 +#define PNG_SELECT_WRITE 2 +#endif /* PNG_MMX_CODE_SUPPORTED */ + +#if !defined(PNG_1_0_X) +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) + PNGARG((int flag_select, int *compilerID)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) + PNGARG((int flag_select)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_asm_flags) + PNGARG((png_structp png_ptr)); + +/* pngget.c */ +extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) + PNGARG((png_structp png_ptr)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) + PNGARG((png_structp png_ptr)); + +/* pngset.c */ +extern PNG_EXPORT(void,png_set_asm_flags) + PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); + +/* pngset.c */ +extern PNG_EXPORT(void,png_set_mmx_thresholds) + PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, + png_uint_32 mmx_rowbytes_threshold)); + +#endif /* PNG_1_0_X */ + +#if !defined(PNG_1_0_X) +/* png.c, pnggccrd.c, or pngvcrd.c */ +extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + +/* Strip the prepended error numbers ("#nnn ") from error and warning + * messages before passing them to the error or warning handler. */ +#ifdef PNG_ERROR_NUMBERS_SUPPORTED +extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp + png_ptr, png_uint_32 strip_mode)); +#endif + +#endif /* PNG_1_0_X */ + +/* Added at libpng-1.2.6 */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED +extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp + png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); +extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp + png_ptr)); +extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp + png_ptr)); +#endif + +/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ + +#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED +/* With these routines we avoid an integer divide, which will be slower on + * most machines. However, it does take more operations than the corresponding + * divide method, so it may be slower on a few RISC systems. There are two + * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. + * + * Note that the rounding factors are NOT supposed to be the same! 128 and + * 32768 are correct for the NODIV code; 127 and 32767 are correct for the + * standard method. + * + * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] + */ + + /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ + +# define png_composite(composite, fg, alpha, bg) \ + { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ + + (png_uint_16)(bg)*(png_uint_16)(255 - \ + (png_uint_16)(alpha)) + (png_uint_16)128); \ + (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } + +# define png_composite_16(composite, fg, alpha, bg) \ + { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ + + (png_uint_32)(bg)*(png_uint_32)(65535L - \ + (png_uint_32)(alpha)) + (png_uint_32)32768L); \ + (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } + +#else /* standard method using integer division */ + +# define png_composite(composite, fg, alpha, bg) \ + (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ + (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ + (png_uint_16)127) / 255) + +# define png_composite_16(composite, fg, alpha, bg) \ + (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ + (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ + (png_uint_32)32767) / (png_uint_32)65535L) + +#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ + +/* Inline macros to do direct reads of bytes from the input buffer. These + * require that you are using an architecture that uses PNG byte ordering + * (MSB first) and supports unaligned data storage. I think that PowerPC + * in big-endian mode and 680x0 are the only ones that will support this. + * The x86 line of processors definitely do not. The png_get_int_32() + * routine also assumes we are using two's complement format for negative + * values, which is almost certainly true. + */ +#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) +# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) +# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) +# define png_get_int_32(buf) ( *((png_int_32p) (buf))) +#else +extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf)); +extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf)); +extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf)); +#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ +extern PNG_EXPORT(png_uint_32,png_get_uint_31) + PNGARG((png_structp png_ptr, png_bytep buf)); +/* No png_get_int_16 -- may be added if there's a real need for it. */ + +/* Place a 32-bit number into a buffer in PNG byte order (big-endian). + */ +extern PNG_EXPORT(void,png_save_uint_32) + PNGARG((png_bytep buf, png_uint_32 i)); +extern PNG_EXPORT(void,png_save_int_32) + PNGARG((png_bytep buf, png_int_32 i)); + +/* Place a 16-bit number into a buffer in PNG byte order. + * The parameter is declared unsigned int, not png_uint_16, + * just to avoid potential problems on pre-ANSI C compilers. + */ +extern PNG_EXPORT(void,png_save_uint_16) + PNGARG((png_bytep buf, unsigned int i)); +/* No png_save_int_16 -- may be added if there's a real need for it. */ + +/* ************************************************************************* */ + +/* These next functions are used internally in the code. They generally + * shouldn't be used unless you are writing code to add or replace some + * functionality in libpng. More information about most functions can + * be found in the files where the functions are located. + */ + +#if defined(PNG_INTERNAL) + +/* Various modes of operation. Note that after an init, mode is set to + * zero automatically when the structure is created. + */ +#define PNG_HAVE_IHDR 0x01 +#define PNG_HAVE_PLTE 0x02 +#define PNG_HAVE_IDAT 0x04 +#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */ +#define PNG_HAVE_IEND 0x10 +#define PNG_HAVE_gAMA 0x20 +#define PNG_HAVE_cHRM 0x40 +#define PNG_HAVE_sRGB 0x80 +#define PNG_HAVE_CHUNK_HEADER 0x100 +#define PNG_WROTE_tIME 0x200 +#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 +#define PNG_BACKGROUND_IS_GRAY 0x800 +#define PNG_HAVE_PNG_SIGNATURE 0x1000 +#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ + +/* flags for the transformations the PNG library does on the image data */ +#define PNG_BGR 0x0001 +#define PNG_INTERLACE 0x0002 +#define PNG_PACK 0x0004 +#define PNG_SHIFT 0x0008 +#define PNG_SWAP_BYTES 0x0010 +#define PNG_INVERT_MONO 0x0020 +#define PNG_DITHER 0x0040 +#define PNG_BACKGROUND 0x0080 +#define PNG_BACKGROUND_EXPAND 0x0100 + /* 0x0200 unused */ +#define PNG_16_TO_8 0x0400 +#define PNG_RGBA 0x0800 +#define PNG_EXPAND 0x1000 +#define PNG_GAMMA 0x2000 +#define PNG_GRAY_TO_RGB 0x4000 +#define PNG_FILLER 0x8000L +#define PNG_PACKSWAP 0x10000L +#define PNG_SWAP_ALPHA 0x20000L +#define PNG_STRIP_ALPHA 0x40000L +#define PNG_INVERT_ALPHA 0x80000L +#define PNG_USER_TRANSFORM 0x100000L +#define PNG_RGB_TO_GRAY_ERR 0x200000L +#define PNG_RGB_TO_GRAY_WARN 0x400000L +#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ + /* 0x800000L Unused */ +#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */ +#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */ + /* 0x4000000L unused */ + /* 0x8000000L unused */ + /* 0x10000000L unused */ + /* 0x20000000L unused */ + /* 0x40000000L unused */ + +/* flags for png_create_struct */ +#define PNG_STRUCT_PNG 0x0001 +#define PNG_STRUCT_INFO 0x0002 + +/* Scaling factor for filter heuristic weighting calculations */ +#define PNG_WEIGHT_SHIFT 8 +#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) +#define PNG_COST_SHIFT 3 +#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) + +/* flags for the png_ptr->flags rather than declaring a byte for each one */ +#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 +#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 +#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 +#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 +#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 +#define PNG_FLAG_ZLIB_FINISHED 0x0020 +#define PNG_FLAG_ROW_INIT 0x0040 +#define PNG_FLAG_FILLER_AFTER 0x0080 +#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 +#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 +#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 +#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 +#define PNG_FLAG_FREE_PLTE 0x1000 +#define PNG_FLAG_FREE_TRNS 0x2000 +#define PNG_FLAG_FREE_HIST 0x4000 +#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L +#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L +#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L +#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L +#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L +#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L +#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */ +#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */ + /* 0x800000L unused */ + /* 0x1000000L unused */ + /* 0x2000000L unused */ + /* 0x4000000L unused */ + /* 0x8000000L unused */ + /* 0x10000000L unused */ + /* 0x20000000L unused */ + /* 0x40000000L unused */ + +#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ + PNG_FLAG_CRC_ANCILLARY_NOWARN) + +#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ + PNG_FLAG_CRC_CRITICAL_IGNORE) + +#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ + PNG_FLAG_CRC_CRITICAL_MASK) + +/* save typing and make code easier to understand */ + +#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ + abs((int)((c1).green) - (int)((c2).green)) + \ + abs((int)((c1).blue) - (int)((c2).blue))) + +/* Added to libpng-1.2.6 JB */ +#define PNG_ROWBYTES(pixel_bits, width) \ + ((pixel_bits) >= 8 ? \ + ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \ + (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) ) + +/* PNG_OUT_OF_RANGE returns true if value is outside the range + ideal-delta..ideal+delta. Each argument is evaluated twice. + "ideal" and "delta" should be constants, normally simple + integers, "value" a variable. Added to libpng-1.2.6 JB */ +#define PNG_OUT_OF_RANGE(value, ideal, delta) \ + ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) + +/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ +#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) +/* place to hold the signature string for a PNG file. */ +#ifdef PNG_USE_GLOBAL_ARRAYS + PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8]; +#else +#if 0 +#define png_sig png_sig_bytes(NULL) +#endif +#endif +#endif /* PNG_NO_EXTERN */ + +/* Constant strings for known chunk types. If you need to add a chunk, + * define the name here, and add an invocation of the macro in png.c and + * wherever it's needed. + */ +#define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} +#define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} +#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} +#define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} +#define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} +#define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} +#define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} +#define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} +#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} +#define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} +#define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} +#define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} +#define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} +#define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} +#define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} +#define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} +#define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} +#define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} +#define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} +#define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} +#define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} + +#ifdef PNG_USE_GLOBAL_ARRAYS +PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5]; +#endif /* PNG_USE_GLOBAL_ARRAYS */ + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Initialize png_ptr struct for reading, and allocate any other memory. + * (old interface - DEPRECATED - use png_create_read_struct instead). + */ +extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); +#undef png_read_init +#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ + PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); +#endif + +extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size)); +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t + png_info_size)); +#endif + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Initialize png_ptr struct for writing, and allocate any other memory. + * (old interface - DEPRECATED - use png_create_write_struct instead). + */ +extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); +#undef png_write_init +#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ + PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); +#endif + +extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size)); +extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t + png_info_size)); + +/* Allocate memory for an internal libpng struct */ +PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); + +/* Free memory from internal libpng struct */ +PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); + +PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr + malloc_fn, png_voidp mem_ptr)); +PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, + png_free_ptr free_fn, png_voidp mem_ptr)); + +/* Free any memory that info_ptr points to and reset struct. */ +PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#ifndef PNG_1_0_X +/* Function to allocate memory for zlib. */ +PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); + +/* Function to free memory for zlib */ +PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); + +#ifdef PNG_SIZE_T +/* Function to convert a sizeof an item to png_sizeof item */ + PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); +#endif + +/* Next four functions are used internally as callbacks. PNGAPI is required + * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ + +PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t length)); +#endif + +PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#if !defined(PNG_NO_STDIO) +PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); +#endif +#endif +#else /* PNG_1_0_X */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t length)); +#endif +#endif /* PNG_1_0_X */ + +/* Reset the CRC variable */ +PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); + +/* Write the "data" buffer to whatever output you are using. */ +PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read data from whatever input you are using into the "data" buffer */ +PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read bytes into buf, and update png_ptr->crc */ +PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, + png_size_t length)); + +/* Decompress data in a chunk that uses compression */ +#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ + defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) +PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, + int comp_type, png_charp chunkdata, png_size_t chunklength, + png_size_t prefix_length, png_size_t *data_length)); +#endif + +/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ +PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); + +/* Read the CRC from the file and compare it to the libpng calculated CRC */ +PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); + +/* Calculate the CRC over a section of data. Note that we are only + * passing a maximum of 64K on systems that have this as a memory limit, + * since this is the maximum buffer size we can specify. + */ +PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, + png_size_t length)); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); +#endif + +/* simple function to write the signature */ +PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); + +/* write various chunks */ + +/* Write the IHDR chunk, and update the png_struct with the necessary + * information. + */ +PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, + png_uint_32 height, + int bit_depth, int color_type, int compression_method, int filter_method, + int interlace_method)); + +PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, + png_uint_32 num_pal)); + +PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); + +#if defined(PNG_WRITE_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point + file_gamma)); +#endif +#endif + +#if defined(PNG_WRITE_sBIT_SUPPORTED) +PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, + int color_type)); +#endif + +#if defined(PNG_WRITE_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, + double white_x, double white_y, + double red_x, double red_y, double green_x, double green_y, + double blue_x, double blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, + png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif +#endif + +#if defined(PNG_WRITE_sRGB_SUPPORTED) +PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, + int intent)); +#endif + +#if defined(PNG_WRITE_iCCP_SUPPORTED) +PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, + png_charp name, int compression_type, + png_charp profile, int proflen)); + /* Note to maintainer: profile should be png_bytep */ +#endif + +#if defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, + png_sPLT_tp palette)); +#endif + +#if defined(PNG_WRITE_tRNS_SUPPORTED) +PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, + png_color_16p values, int number, int color_type)); +#endif + +#if defined(PNG_WRITE_bKGD_SUPPORTED) +PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, + png_color_16p values, int color_type)); +#endif + +#if defined(PNG_WRITE_hIST_SUPPORTED) +PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, + int num_hist)); +#endif + +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ + defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, + png_charp key, png_charpp new_key)); +#endif + +#if defined(PNG_WRITE_tEXt_SUPPORTED) +PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len)); +#endif + +#if defined(PNG_WRITE_zTXt_SUPPORTED) +PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len, int compression)); +#endif + +#if defined(PNG_WRITE_iTXt_SUPPORTED) +PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, + int compression, png_charp key, png_charp lang, png_charp lang_key, + png_charp text)); +#endif + +#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ +PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp text_ptr, int num_text)); +#endif + +#if defined(PNG_WRITE_oFFs_SUPPORTED) +PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, + png_int_32 x_offset, png_int_32 y_offset, int unit_type)); +#endif + +#if defined(PNG_WRITE_pCAL_SUPPORTED) +PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, + png_int_32 X0, png_int_32 X1, int type, int nparams, + png_charp units, png_charpp params)); +#endif + +#if defined(PNG_WRITE_pHYs_SUPPORTED) +PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, + png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, + int unit_type)); +#endif + +#if defined(PNG_WRITE_tIME_SUPPORTED) +PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, + png_timep mod_time)); +#endif + +#if defined(PNG_WRITE_sCAL_SUPPORTED) +#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) +PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, + int unit, double width, double height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, + int unit, png_charp width, png_charp height)); +#endif +#endif +#endif + +/* Called when finished processing a row of data */ +PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); + +/* Internal use only. Called before first row of data */ +PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); +#endif + +/* combine a row of data, dealing with alpha, etc. if requested */ +PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, + int mask)); + +#if defined(PNG_READ_INTERLACING_SUPPORTED) +/* expand an interlaced row */ +/* OLD pre-1.0.9 interface: +PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass, png_uint_32 transformations)); + */ +PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); +#endif + +/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ + +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* grab pixels out of a row for an interlaced pass */ +PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass)); +#endif + +/* unfilter a row */ +PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, + png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); + +/* Choose the best filter to use and filter the row data */ +PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, + png_row_infop row_info)); + +/* Write out the filtered row. */ +PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, + png_bytep filtered_row)); +/* finish a row while reading, dealing with interlacing passes, etc. */ +PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); + +/* initialize the row buffers, etc. */ +PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); +/* optional call to update the users info structure */ +PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* these are the functions that do the transformations */ +#if defined(PNG_READ_FILLER_SUPPORTED) +PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 filler, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ + defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) +PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop + row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) +PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p sig_bits)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, + png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); + +# if defined(PNG_CORRECT_PALETTE_SUPPORTED) +PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette)); +# endif +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_WRITE_PACK_SUPPORTED) +PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 bit_depth)); +#endif + +#if defined(PNG_WRITE_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p bit_depth)); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background, + png_color_16p background_1, + png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, + png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, + png_uint_16pp gamma_16_to_1, int gamma_shift)); +#else +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background)); +#endif +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, + png_bytep gamma_table, png_uint_16pp gamma_16_table, + int gamma_shift)); +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) +PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, + png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); +PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, + png_bytep row, png_color_16p trans_value)); +#endif + +/* The following decodes the appropriate chunks, and does error correction, + * then calls the appropriate callback for the chunk if it is valid. + */ + +/* decode the IHDR chunk */ +PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); + +#if defined(PNG_READ_bKGD_SUPPORTED) +PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_cHRM_SUPPORTED) +PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_gAMA_SUPPORTED) +PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_hIST_SUPPORTED) +PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_iCCP_SUPPORTED) +extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_iCCP_SUPPORTED */ + +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_oFFs_SUPPORTED) +PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pCAL_SUPPORTED) +PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pHYs_SUPPORTED) +PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sBIT_SUPPORTED) +PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sCAL_SUPPORTED) +PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sPLT_SUPPORTED) +extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_sPLT_SUPPORTED */ + +#if defined(PNG_READ_sRGB_SUPPORTED) +PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tIME_SUPPORTED) +PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tRNS_SUPPORTED) +PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); + +PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, + png_bytep chunk_name)); + +/* handle the transformations for reading and writing */ +PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); + +PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, + png_uint_32 length)); +PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); +PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#ifdef PNG_MNG_FEATURES_SUPPORTED +PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +#if defined(PNG_MMX_CODE_SUPPORTED) +/* png.c */ /* PRIVATE */ +PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); +#endif +#endif + +#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) +PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_pHYs_SUPPORTED) +PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr, +png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); +#endif /* PNG_pHYs_SUPPORTED */ +#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ + +/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ + +#endif /* PNG_INTERNAL */ + +#ifdef __cplusplus +} +#endif + +#endif /* PNG_VERSION_INFO_ONLY */ +/* do not put anything past this line */ +#endif /* PNG_H */ diff --git a/src/dep/src/irrlicht/libpng/pngconf.h b/src/dep/src/irrlicht/libpng/pngconf.h index 019dc9e..d71a153 100644 --- a/src/dep/src/irrlicht/libpng/pngconf.h +++ b/src/dep/src/irrlicht/libpng/pngconf.h @@ -1,1483 +1,1483 @@ - -/* pngconf.h - machine configurable file for libpng - * - * libpng version 1.2.16 - January 31, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -/* Any machine specific code is near the front of this file, so if you - * are configuring libpng for a machine, you may want to read the section - * starting here down to where it starts to typedef png_color, png_text, - * and png_info. - */ - -#ifndef PNGCONF_H -#define PNGCONF_H - -#define PNG_1_2_X - -/* - * PNG_USER_CONFIG has to be defined on the compiler command line. This - * includes the resource compiler for Windows DLL configurations. - */ -#ifdef PNG_USER_CONFIG -# ifndef PNG_USER_PRIVATEBUILD -# define PNG_USER_PRIVATEBUILD -# endif -#include "pngusr.h" -#endif - -/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */ -#ifdef PNG_CONFIGURE_LIBPNG -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#endif - -/* - * Added at libpng-1.2.8 - * - * If you create a private DLL you need to define in "pngusr.h" the followings: - * #define PNG_USER_PRIVATEBUILD - * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons." - * #define PNG_USER_DLLFNAME_POSTFIX - * e.g. // private DLL "libpng13gx.dll" - * #define PNG_USER_DLLFNAME_POSTFIX "gx" - * - * The following macros are also at your disposal if you want to complete the - * DLL VERSIONINFO structure. - * - PNG_USER_VERSIONINFO_COMMENTS - * - PNG_USER_VERSIONINFO_COMPANYNAME - * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS - */ - -#ifdef __STDC__ -#ifdef SPECIALBUILD -# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\ - are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.") -#endif - -#ifdef PRIVATEBUILD -# pragma message("PRIVATEBUILD is deprecated.\ - Use PNG_USER_PRIVATEBUILD instead.") -# define PNG_USER_PRIVATEBUILD PRIVATEBUILD -#endif -#endif /* __STDC__ */ - -#ifndef PNG_VERSION_INFO_ONLY - -/* End of material added to libpng-1.2.8 */ - -/* This is the size of the compression buffer, and thus the size of - * an IDAT chunk. Make this whatever size you feel is best for your - * machine. One of these will be allocated per png_struct. When this - * is full, it writes the data to the disk, and does some other - * calculations. Making this an extremely small size will slow - * the library down, but you may want to experiment to determine - * where it becomes significant, if you are concerned with memory - * usage. Note that zlib allocates at least 32Kb also. For readers, - * this describes the size of the buffer available to read the data in. - * Unless this gets smaller than the size of a row (compressed), - * it should not make much difference how big this is. - */ - -#ifndef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 8192 -#endif - -/* Enable if you want a write-only libpng */ - -#ifndef PNG_NO_READ_SUPPORTED -# define PNG_READ_SUPPORTED -#endif - -/* Enable if you want a read-only libpng */ - -#ifndef PNG_NO_WRITE_SUPPORTED -# define PNG_WRITE_SUPPORTED -#endif - -/* Enabled by default in 1.2.0. You can disable this if you don't need to - support PNGs that are embedded in MNG datastreams */ -#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES) -# ifndef PNG_MNG_FEATURES_SUPPORTED -# define PNG_MNG_FEATURES_SUPPORTED -# endif -#endif - -#ifndef PNG_NO_FLOATING_POINT_SUPPORTED -# ifndef PNG_FLOATING_POINT_SUPPORTED -# define PNG_FLOATING_POINT_SUPPORTED -# endif -#endif - -/* If you are running on a machine where you cannot allocate more - * than 64K of memory at once, uncomment this. While libpng will not - * normally need that much memory in a chunk (unless you load up a very - * large file), zlib needs to know how big of a chunk it can use, and - * libpng thus makes sure to check any memory allocation to verify it - * will fit into memory. -#define PNG_MAX_MALLOC_64K - */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) -# define PNG_MAX_MALLOC_64K -#endif - -/* Special munging to support doing things the 'cygwin' way: - * 'Normal' png-on-win32 defines/defaults: - * PNG_BUILD_DLL -- building dll - * PNG_USE_DLL -- building an application, linking to dll - * (no define) -- building static library, or building an - * application and linking to the static lib - * 'Cygwin' defines/defaults: - * PNG_BUILD_DLL -- (ignored) building the dll - * (no define) -- (ignored) building an application, linking to the dll - * PNG_STATIC -- (ignored) building the static lib, or building an - * application that links to the static lib. - * ALL_STATIC -- (ignored) building various static libs, or building an - * application that links to the static libs. - * Thus, - * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and - * this bit of #ifdefs will define the 'correct' config variables based on - * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but - * unnecessary. - * - * Also, the precedence order is: - * ALL_STATIC (since we can't #undef something outside our namespace) - * PNG_BUILD_DLL - * PNG_STATIC - * (nothing) == PNG_USE_DLL - * - * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent - * of auto-import in binutils, we no longer need to worry about - * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, - * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes - * to __declspec() stuff. However, we DO need to worry about - * PNG_BUILD_DLL and PNG_STATIC because those change some defaults - * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. - */ -#if defined(__CYGWIN__) -# if defined(ALL_STATIC) -# if defined(PNG_BUILD_DLL) -# undef PNG_BUILD_DLL -# endif -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if defined(PNG_DLL) -# undef PNG_DLL -# endif -# if !defined(PNG_STATIC) -# define PNG_STATIC -# endif -# else -# if defined (PNG_BUILD_DLL) -# if defined(PNG_STATIC) -# undef PNG_STATIC -# endif -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if !defined(PNG_DLL) -# define PNG_DLL -# endif -# else -# if defined(PNG_STATIC) -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if defined(PNG_DLL) -# undef PNG_DLL -# endif -# else -# if !defined(PNG_USE_DLL) -# define PNG_USE_DLL -# endif -# if !defined(PNG_DLL) -# define PNG_DLL -# endif -# endif -# endif -# endif -#endif - -/* This protects us against compilers that run on a windowing system - * and thus don't have or would rather us not use the stdio types: - * stdin, stdout, and stderr. The only one currently used is stderr - * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will - * prevent these from being compiled and used. #defining PNG_NO_STDIO - * will also prevent these, plus will prevent the entire set of stdio - * macros and functions (FILE *, printf, etc.) from being compiled and used, - * unless (PNG_DEBUG > 0) has been #defined. - * - * #define PNG_NO_CONSOLE_IO - * #define PNG_NO_STDIO - */ - -#if defined(_WIN32_WCE) -# include - /* Console I/O functions are not supported on WindowsCE */ -# define PNG_NO_CONSOLE_IO -# ifdef PNG_DEBUG -# undef PNG_DEBUG -# endif -#endif - -#ifdef PNG_BUILD_DLL -# ifndef PNG_CONSOLE_IO_SUPPORTED -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# endif -#endif - -# ifdef PNG_NO_STDIO -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# ifdef PNG_DEBUG -# if (PNG_DEBUG > 0) -# include -# endif -# endif -# else -# if !defined(_WIN32_WCE) -/* "stdio.h" functions are not supported on WindowsCE */ -# include -# endif -# endif - -/* This macro protects us against machines that don't have function - * prototypes (ie K&R style headers). If your compiler does not handle - * function prototypes, define this macro and use the included ansi2knr. - * I've always been able to use _NO_PROTO as the indicator, but you may - * need to drag the empty declaration out in front of here, or change the - * ifdef to suit your own needs. - */ -#ifndef PNGARG - -#ifdef OF /* zlib prototype munger */ -# define PNGARG(arglist) OF(arglist) -#else - -#ifdef _NO_PROTO -# define PNGARG(arglist) () -# ifndef PNG_TYPECAST_NULL -# define PNG_TYPECAST_NULL -# endif -#else -# define PNGARG(arglist) arglist -#endif /* _NO_PROTO */ - -#endif /* OF */ - -#endif /* PNGARG */ - -/* Try to determine if we are compiling on a Mac. Note that testing for - * just __MWERKS__ is not good enough, because the Codewarrior is now used - * on non-Mac platforms. - */ -#ifndef MACOS -# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ - defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) -# define MACOS -# endif -#endif - -/* enough people need this for various reasons to include it here */ -#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) -# include -#endif - -#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) -# define PNG_SETJMP_SUPPORTED -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* This is an attempt to force a single setjmp behaviour on Linux. If - * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. - */ - -# ifdef __linux__ -# ifdef _BSD_SOURCE -# define PNG_SAVE_BSD_SOURCE -# undef _BSD_SOURCE -# endif -# ifdef _SETJMP_H - /* If you encounter a compiler error here, see the explanation - * near the end of INSTALL. - */ - __png.h__ already includes setjmp.h; - __dont__ include it again.; -# endif -# endif /* __linux__ */ - - /* include setjmp.h for error handling */ -# include - -# ifdef __linux__ -# ifdef PNG_SAVE_BSD_SOURCE -# define _BSD_SOURCE -# undef PNG_SAVE_BSD_SOURCE -# endif -# endif /* __linux__ */ -#endif /* PNG_SETJMP_SUPPORTED */ - -#ifdef BSD -# include -#else -# include -#endif - -/* Other defines for things like memory and the like can go here. */ -#ifdef PNG_INTERNAL - -#include - -/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which - * aren't usually used outside the library (as far as I know), so it is - * debatable if they should be exported at all. In the future, when it is - * possible to have run-time registry of chunk-handling functions, some of - * these will be made available again. -#define PNG_EXTERN extern - */ -#define PNG_EXTERN - -/* Other defines specific to compilers can go here. Try to keep - * them inside an appropriate ifdef/endif pair for portability. - */ - -#if defined(PNG_FLOATING_POINT_SUPPORTED) -# if defined(MACOS) - /* We need to check that hasn't already been included earlier - * as it seems it doesn't agree with , yet we should really use - * if possible. - */ -# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) -# include -# endif -# else -# include -# endif -# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) - /* Amiga SAS/C: We must include builtin FPU functions when compiling using - * MATH=68881 - */ -# include -# endif -#endif - -/* Codewarrior on NT has linking problems without this. */ -#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) -# define PNG_ALWAYS_EXTERN -#endif - -/* This provides the non-ANSI (far) memory allocation routines. */ -#if defined(__TURBOC__) && defined(__MSDOS__) -# include -# include -#endif - -/* I have no idea why is this necessary... */ -#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ - defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) -# include -#endif - -/* This controls how fine the dithering gets. As this allocates - * a largish chunk of memory (32K), those who are not as concerned - * with dithering quality can decrease some or all of these. - */ -#ifndef PNG_DITHER_RED_BITS -# define PNG_DITHER_RED_BITS 5 -#endif -#ifndef PNG_DITHER_GREEN_BITS -# define PNG_DITHER_GREEN_BITS 5 -#endif -#ifndef PNG_DITHER_BLUE_BITS -# define PNG_DITHER_BLUE_BITS 5 -#endif - -/* This controls how fine the gamma correction becomes when you - * are only interested in 8 bits anyway. Increasing this value - * results in more memory being used, and more pow() functions - * being called to fill in the gamma tables. Don't set this value - * less then 8, and even that may not work (I haven't tested it). - */ - -#ifndef PNG_MAX_GAMMA_8 -# define PNG_MAX_GAMMA_8 11 -#endif - -/* This controls how much a difference in gamma we can tolerate before - * we actually start doing gamma conversion. - */ -#ifndef PNG_GAMMA_THRESHOLD -# define PNG_GAMMA_THRESHOLD 0.05 -#endif - -#endif /* PNG_INTERNAL */ - -/* The following uses const char * instead of char * for error - * and warning message functions, so some compilers won't complain. - * If you do not want to use const, define PNG_NO_CONST here. - */ - -#ifndef PNG_NO_CONST -# define PNG_CONST const -#else -# define PNG_CONST -#endif - -/* The following defines give you the ability to remove code from the - * library that you will not be using. I wish I could figure out how to - * automate this, but I can't do that without making it seriously hard - * on the users. So if you are not using an ability, change the #define - * to and #undef, and that part of the library will not be compiled. If - * your linker can't find a function, you may want to make sure the - * ability is defined here. Some of these depend upon some others being - * defined. I haven't figured out all the interactions here, so you may - * have to experiment awhile to get everything to compile. If you are - * creating or using a shared library, you probably shouldn't touch this, - * as it will affect the size of the structures, and this will cause bad - * things to happen if the library and/or application ever change. - */ - -/* Any features you will not be using can be undef'ed here */ - -/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user - * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS - * on the compile line, then pick and choose which ones to define without - * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED - * if you only want to have a png-compliant reader/writer but don't need - * any of the extra transformations. This saves about 80 kbytes in a - * typical installation of the library. (PNG_NO_* form added in version - * 1.0.1c, for consistency) - */ - -/* The size of the png_text structure changed in libpng-1.0.6 when - * iTXt support was added. iTXt support was turned off by default through - * libpng-1.2.x, to support old apps that malloc the png_text structure - * instead of calling png_set_text() and letting libpng malloc it. It - * was turned on by default in libpng-1.3.0. - */ - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -# ifndef PNG_NO_iTXt_SUPPORTED -# define PNG_NO_iTXt_SUPPORTED -# endif -# ifndef PNG_NO_READ_iTXt -# define PNG_NO_READ_iTXt -# endif -# ifndef PNG_NO_WRITE_iTXt -# define PNG_NO_WRITE_iTXt -# endif -#endif - -#if !defined(PNG_NO_iTXt_SUPPORTED) -# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) -# define PNG_READ_iTXt -# endif -# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt) -# define PNG_WRITE_iTXt -# endif -#endif - -/* The following support, added after version 1.0.0, can be turned off here en - * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility - * with old applications that require the length of png_struct and png_info - * to remain unchanged. - */ - -#ifdef PNG_LEGACY_SUPPORTED -# define PNG_NO_FREE_ME -# define PNG_NO_READ_UNKNOWN_CHUNKS -# define PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_NO_READ_USER_CHUNKS -# define PNG_NO_READ_iCCP -# define PNG_NO_WRITE_iCCP -# define PNG_NO_READ_iTXt -# define PNG_NO_WRITE_iTXt -# define PNG_NO_READ_sCAL -# define PNG_NO_WRITE_sCAL -# define PNG_NO_READ_sPLT -# define PNG_NO_WRITE_sPLT -# define PNG_NO_INFO_IMAGE -# define PNG_NO_READ_RGB_TO_GRAY -# define PNG_NO_READ_USER_TRANSFORM -# define PNG_NO_WRITE_USER_TRANSFORM -# define PNG_NO_USER_MEM -# define PNG_NO_READ_EMPTY_PLTE -# define PNG_NO_MNG_FEATURES -# define PNG_NO_FIXED_POINT_SUPPORTED -#endif - -/* Ignore attempt to turn off both floating and fixed point support */ -#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ - !defined(PNG_NO_FIXED_POINT_SUPPORTED) -# define PNG_FIXED_POINT_SUPPORTED -#endif - -#ifndef PNG_NO_FREE_ME -# define PNG_FREE_ME_SUPPORTED -#endif - -#if defined(PNG_READ_SUPPORTED) - -#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_TRANSFORMS) -# define PNG_READ_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_READ_EXPAND -# define PNG_READ_EXPAND_SUPPORTED -# endif -# ifndef PNG_NO_READ_SHIFT -# define PNG_READ_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACK -# define PNG_READ_PACK_SUPPORTED -# endif -# ifndef PNG_NO_READ_BGR -# define PNG_READ_BGR_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP -# define PNG_READ_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACKSWAP -# define PNG_READ_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT -# define PNG_READ_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_READ_DITHER -# define PNG_READ_DITHER_SUPPORTED -# endif -# ifndef PNG_NO_READ_BACKGROUND -# define PNG_READ_BACKGROUND_SUPPORTED -# endif -# ifndef PNG_NO_READ_16_TO_8 -# define PNG_READ_16_TO_8_SUPPORTED -# endif -# ifndef PNG_NO_READ_FILLER -# define PNG_READ_FILLER_SUPPORTED -# endif -# ifndef PNG_NO_READ_GAMMA -# define PNG_READ_GAMMA_SUPPORTED -# endif -# ifndef PNG_NO_READ_GRAY_TO_RGB -# define PNG_READ_GRAY_TO_RGB_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP_ALPHA -# define PNG_READ_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT_ALPHA -# define PNG_READ_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_STRIP_ALPHA -# define PNG_READ_STRIP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_USER_TRANSFORM -# define PNG_READ_USER_TRANSFORM_SUPPORTED -# endif -# ifndef PNG_NO_READ_RGB_TO_GRAY -# define PNG_READ_RGB_TO_GRAY_SUPPORTED -# endif -#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ - -#if !defined(PNG_NO_PROGRESSIVE_READ) && \ - !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */ -# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ -#endif /* about interlacing capability! You'll */ - /* still have interlacing unless you change the following line: */ - -#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ - -#ifndef PNG_NO_READ_COMPOSITE_NODIV -# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ -# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ -# endif -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated, will be removed from version 2.0.0. - Use PNG_MNG_FEATURES_SUPPORTED instead. */ -#ifndef PNG_NO_READ_EMPTY_PLTE -# define PNG_READ_EMPTY_PLTE_SUPPORTED -#endif -#endif - -#endif /* PNG_READ_SUPPORTED */ - -#if defined(PNG_WRITE_SUPPORTED) - -# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_TRANSFORMS) -# define PNG_WRITE_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_WRITE_SHIFT -# define PNG_WRITE_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACK -# define PNG_WRITE_PACK_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_BGR -# define PNG_WRITE_BGR_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_SWAP -# define PNG_WRITE_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACKSWAP -# define PNG_WRITE_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT -# define PNG_WRITE_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_FILLER -# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ -# endif -# ifndef PNG_NO_WRITE_SWAP_ALPHA -# define PNG_WRITE_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT_ALPHA -# define PNG_WRITE_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_USER_TRANSFORM -# define PNG_WRITE_USER_TRANSFORM_SUPPORTED -# endif -#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ - -#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \ - !defined(PNG_WRITE_INTERLACING_SUPPORTED) -#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant - encoders, but can cause trouble - if left undefined */ -#endif - -#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ - !defined(PNG_WRITE_WEIGHTED_FILTER) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) -# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED -#endif - -#ifndef PNG_NO_WRITE_FLUSH -# define PNG_WRITE_FLUSH_SUPPORTED -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ -#ifndef PNG_NO_WRITE_EMPTY_PLTE -# define PNG_WRITE_EMPTY_PLTE_SUPPORTED -#endif -#endif - -#endif /* PNG_WRITE_SUPPORTED */ - -#ifndef PNG_1_0_X -# ifndef PNG_NO_ERROR_NUMBERS -# define PNG_ERROR_NUMBERS_SUPPORTED -# endif -#endif /* PNG_1_0_X */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -# ifndef PNG_NO_USER_TRANSFORM_PTR -# define PNG_USER_TRANSFORM_PTR_SUPPORTED -# endif -#endif - -#ifndef PNG_NO_STDIO -# define PNG_TIME_RFC1123_SUPPORTED -#endif - -/* This adds extra functions in pngget.c for accessing data from the - * info pointer (added in version 0.99) - * png_get_image_width() - * png_get_image_height() - * png_get_bit_depth() - * png_get_color_type() - * png_get_compression_type() - * png_get_filter_type() - * png_get_interlace_type() - * png_get_pixel_aspect_ratio() - * png_get_pixels_per_meter() - * png_get_x_offset_pixels() - * png_get_y_offset_pixels() - * png_get_x_offset_microns() - * png_get_y_offset_microns() - */ -#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) -# define PNG_EASY_ACCESS_SUPPORTED -#endif - -/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 - * even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined. - * - * PNG_NO_ASSEMBLER_CODE disables use of all assembler code and optimized C, - * and removes or includes several functions in the API. - * - * PNG_NO_MMX_CODE disables the use of MMX code without changing the API. - * When MMX code is off, then optimized C replacement functions are used. -*/ -#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) -# ifndef PNG_ASSEMBLER_CODE_SUPPORTED -# define PNG_ASSEMBLER_CODE_SUPPORTED -# endif -# if defined(XP_MACOSX) && !defined(PNG_NO_MMX_CODE) - /* work around Intel-Mac compiler bug */ -# define PNG_NO_MMX_CODE -# endif -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) && \ - defined(__MMX__) -# define PNG_MMX_CODE_SUPPORTED -# endif -# if !defined(PNG_USE_PNGGCCRD) && !defined(PNG_NO_MMX_CODE) && \ - !defined(PNG_USE_PNGVCRD) && defined(__MMX__) -# define PNG_USE_PNGGCCRD -# endif -#endif - -/* If you are sure that you don't need thread safety and you are compiling - with PNG_USE_PNGCCRD for an MMX application, you can define this for - faster execution. See pnggccrd.c. -#define PNG_THREAD_UNSAFE_OK -*/ - -#if !defined(PNG_1_0_X) -#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) -# define PNG_USER_MEM_SUPPORTED -#endif -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.2.6 */ -#if !defined(PNG_1_0_X) -#ifndef PNG_SET_USER_LIMITS_SUPPORTED -#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED) -# define PNG_SET_USER_LIMITS_SUPPORTED -#endif -#endif -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGS no matter - * how large, set these limits to 0x7fffffffL - */ -#ifndef PNG_USER_WIDTH_MAX -# define PNG_USER_WIDTH_MAX 1000000L -#endif -#ifndef PNG_USER_HEIGHT_MAX -# define PNG_USER_HEIGHT_MAX 1000000L -#endif - -/* These are currently experimental features, define them if you want */ - -/* very little testing */ -/* -#ifdef PNG_READ_SUPPORTED -# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# endif -#endif -*/ - -/* This is only for PowerPC big-endian and 680x0 systems */ -/* some testing */ -/* -#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED -# define PNG_READ_BIG_ENDIAN_SUPPORTED -#endif -*/ - -/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ -/* -#define PNG_NO_POINTER_INDEXING -*/ - -/* These functions are turned off by default, as they will be phased out. */ -/* -#define PNG_USELESS_TESTS_SUPPORTED -#define PNG_CORRECT_PALETTE_SUPPORTED -*/ - -/* Any chunks you are not interested in, you can undef here. The - * ones that allocate memory may be expecially important (hIST, - * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info - * a bit smaller. - */ - -#if defined(PNG_READ_SUPPORTED) && \ - !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_ANCILLARY_CHUNKS) -# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED -#endif - -#if defined(PNG_WRITE_SUPPORTED) && \ - !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) -# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED -#endif - -#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_READ_TEXT -# define PNG_NO_READ_iTXt -# define PNG_NO_READ_tEXt -# define PNG_NO_READ_zTXt -#endif -#ifndef PNG_NO_READ_bKGD -# define PNG_READ_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -#endif -#ifndef PNG_NO_READ_cHRM -# define PNG_READ_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -#endif -#ifndef PNG_NO_READ_gAMA -# define PNG_READ_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -#endif -#ifndef PNG_NO_READ_hIST -# define PNG_READ_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -#endif -#ifndef PNG_NO_READ_iCCP -# define PNG_READ_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -#endif -#ifndef PNG_NO_READ_iTXt -# ifndef PNG_READ_iTXt_SUPPORTED -# define PNG_READ_iTXt_SUPPORTED -# endif -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_READ_oFFs -# define PNG_READ_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -#endif -#ifndef PNG_NO_READ_pCAL -# define PNG_READ_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_sCAL -# define PNG_READ_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_pHYs -# define PNG_READ_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -#endif -#ifndef PNG_NO_READ_sBIT -# define PNG_READ_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sPLT -# define PNG_READ_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sRGB -# define PNG_READ_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -#endif -#ifndef PNG_NO_READ_tEXt -# define PNG_READ_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_tIME -# define PNG_READ_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -#endif -#ifndef PNG_NO_READ_tRNS -# define PNG_READ_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -#endif -#ifndef PNG_NO_READ_zTXt -# define PNG_READ_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_UNKNOWN_CHUNKS -# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -#endif -#if !defined(PNG_NO_READ_USER_CHUNKS) && \ - defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) -# define PNG_READ_USER_CHUNKS_SUPPORTED -# define PNG_USER_CHUNKS_SUPPORTED -# ifdef PNG_NO_READ_UNKNOWN_CHUNKS -# undef PNG_NO_READ_UNKNOWN_CHUNKS -# endif -# ifdef PNG_NO_HANDLE_AS_UNKNOWN -# undef PNG_NO_HANDLE_AS_UNKNOWN -# endif -#endif -#ifndef PNG_NO_READ_OPT_PLTE -# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ -#endif /* optional PLTE chunk in RGB and RGBA images */ -#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ - defined(PNG_READ_zTXt_SUPPORTED) -# define PNG_READ_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -#endif - -#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ - -#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_WRITE_TEXT -# define PNG_NO_WRITE_iTXt -# define PNG_NO_WRITE_tEXt -# define PNG_NO_WRITE_zTXt -#endif -#ifndef PNG_NO_WRITE_bKGD -# define PNG_WRITE_bKGD_SUPPORTED -# ifndef PNG_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_cHRM -# define PNG_WRITE_cHRM_SUPPORTED -# ifndef PNG_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_gAMA -# define PNG_WRITE_gAMA_SUPPORTED -# ifndef PNG_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_hIST -# define PNG_WRITE_hIST_SUPPORTED -# ifndef PNG_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iCCP -# define PNG_WRITE_iCCP_SUPPORTED -# ifndef PNG_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iTXt -# ifndef PNG_WRITE_iTXt_SUPPORTED -# define PNG_WRITE_iTXt_SUPPORTED -# endif -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_oFFs -# define PNG_WRITE_oFFs_SUPPORTED -# ifndef PNG_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_pCAL -# define PNG_WRITE_pCAL_SUPPORTED -# ifndef PNG_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sCAL -# define PNG_WRITE_sCAL_SUPPORTED -# ifndef PNG_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_pHYs -# define PNG_WRITE_pHYs_SUPPORTED -# ifndef PNG_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sBIT -# define PNG_WRITE_sBIT_SUPPORTED -# ifndef PNG_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sPLT -# define PNG_WRITE_sPLT_SUPPORTED -# ifndef PNG_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sRGB -# define PNG_WRITE_sRGB_SUPPORTED -# ifndef PNG_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tEXt -# define PNG_WRITE_tEXt_SUPPORTED -# ifndef PNG_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tIME -# define PNG_WRITE_tIME_SUPPORTED -# ifndef PNG_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tRNS -# define PNG_WRITE_tRNS_SUPPORTED -# ifndef PNG_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_zTXt -# define PNG_WRITE_zTXt_SUPPORTED -# ifndef PNG_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -# endif -#endif -#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ - defined(PNG_WRITE_zTXt_SUPPORTED) -# define PNG_WRITE_TEXT_SUPPORTED -# ifndef PNG_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -# endif -#endif - -#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ - -/* Turn this off to disable png_read_png() and - * png_write_png() and leave the row_pointers member - * out of the info structure. - */ -#ifndef PNG_NO_INFO_IMAGE -# define PNG_INFO_IMAGE_SUPPORTED -#endif - -/* need the time information for reading tIME chunks */ -#if defined(PNG_tIME_SUPPORTED) -# if !defined(_WIN32_WCE) - /* "time.h" functions are not supported on WindowsCE */ -# include -# endif -#endif - -/* Some typedefs to get us started. These should be safe on most of the - * common platforms. The typedefs should be at least as large as the - * numbers suggest (a png_uint_32 must be at least 32 bits long), but they - * don't have to be exactly that size. Some compilers dislike passing - * unsigned shorts as function parameters, so you may be better off using - * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may - * want to have unsigned int for png_uint_32 instead of unsigned long. - */ - -typedef unsigned long png_uint_32; -typedef long png_int_32; -typedef unsigned short png_uint_16; -typedef short png_int_16; -typedef unsigned char png_byte; - -/* This is usually size_t. It is typedef'ed just in case you need it to - change (I'm not sure if you will or not, so I thought I'd be safe) */ -#ifdef PNG_SIZE_T - typedef PNG_SIZE_T png_size_t; -# define png_sizeof(x) png_convert_size(sizeof (x)) -#else - typedef size_t png_size_t; -# define png_sizeof(x) sizeof (x) -#endif - -/* The following is needed for medium model support. It cannot be in the - * PNG_INTERNAL section. Needs modification for other compilers besides - * MSC. Model independent support declares all arrays and pointers to be - * large using the far keyword. The zlib version used must also support - * model independent data. As of version zlib 1.0.4, the necessary changes - * have been made in zlib. The USE_FAR_KEYWORD define triggers other - * changes that are needed. (Tim Wegner) - */ - -/* Separate compiler dependencies (problem here is that zlib.h always - defines FAR. (SJT) */ -#ifdef __BORLANDC__ -# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) -# define LDATA 1 -# else -# define LDATA 0 -# endif - /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ -# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) -# define PNG_MAX_MALLOC_64K -# if (LDATA != 1) -# ifndef FAR -# define FAR __far -# endif -# define USE_FAR_KEYWORD -# endif /* LDATA != 1 */ - /* Possibly useful for moving data out of default segment. - * Uncomment it if you want. Could also define FARDATA as - * const if your compiler supports it. (SJT) -# define FARDATA FAR - */ -# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ -#endif /* __BORLANDC__ */ - - -/* Suggest testing for specific compiler first before testing for - * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, - * making reliance oncertain keywords suspect. (SJT) - */ - -/* MSC Medium model */ -#if defined(FAR) -# if defined(M_I86MM) -# define USE_FAR_KEYWORD -# define FARDATA FAR -# include -# endif -#endif - -/* SJT: default case */ -#ifndef FAR -# define FAR -#endif - -/* At this point FAR is always defined */ -#ifndef FARDATA -# define FARDATA -#endif - -/* Typedef for floating-point numbers that are converted - to fixed-point with a multiple of 100,000, e.g., int_gamma */ -typedef png_int_32 png_fixed_point; - -/* Add typedefs for pointers */ -typedef void FAR * png_voidp; -typedef png_byte FAR * png_bytep; -typedef png_uint_32 FAR * png_uint_32p; -typedef png_int_32 FAR * png_int_32p; -typedef png_uint_16 FAR * png_uint_16p; -typedef png_int_16 FAR * png_int_16p; -typedef PNG_CONST char FAR * png_const_charp; -typedef char FAR * png_charp; -typedef png_fixed_point FAR * png_fixed_point_p; - -#ifndef PNG_NO_STDIO -#if defined(_WIN32_WCE) -typedef HANDLE png_FILE_p; -#else -typedef FILE * png_FILE_p; -#endif -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * png_doublep; -#endif - -/* Pointers to pointers; i.e. arrays */ -typedef png_byte FAR * FAR * png_bytepp; -typedef png_uint_32 FAR * FAR * png_uint_32pp; -typedef png_int_32 FAR * FAR * png_int_32pp; -typedef png_uint_16 FAR * FAR * png_uint_16pp; -typedef png_int_16 FAR * FAR * png_int_16pp; -typedef PNG_CONST char FAR * FAR * png_const_charpp; -typedef char FAR * FAR * png_charpp; -typedef png_fixed_point FAR * FAR * png_fixed_point_pp; -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * FAR * png_doublepp; -#endif - -/* Pointers to pointers to pointers; i.e., pointer to array */ -typedef char FAR * FAR * FAR * png_charppp; - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* SPC - Is this stuff deprecated? */ -/* It'll be removed as of libpng-1.3.0 - GR-P */ -/* libpng typedefs for types in zlib. If zlib changes - * or another compression library is used, then change these. - * Eliminates need to change all the source files. - */ -typedef charf * png_zcharp; -typedef charf * FAR * png_zcharpp; -typedef z_stream FAR * png_zstreamp; -#endif /* (PNG_1_0_X) || defined(PNG_1_2_X) */ - -/* - * Define PNG_BUILD_DLL if the module being built is a Windows - * LIBPNG DLL. - * - * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. - * It is equivalent to Microsoft predefined macro _DLL that is - * automatically defined when you compile using the share - * version of the CRT (C Run-Time library) - * - * The cygwin mods make this behavior a little different: - * Define PNG_BUILD_DLL if you are building a dll for use with cygwin - * Define PNG_STATIC if you are building a static library for use with cygwin, - * -or- if you are building an application that you want to link to the - * static library. - * PNG_USE_DLL is defined by default (no user action needed) unless one of - * the other flags is defined. - */ - -#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) -# define PNG_DLL -#endif -/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. - * When building a static lib, default to no GLOBAL ARRAYS, but allow - * command-line override - */ -#if defined(__CYGWIN__) -# if !defined(PNG_STATIC) -# if defined(PNG_USE_GLOBAL_ARRAYS) -# undef PNG_USE_GLOBAL_ARRAYS -# endif -# if !defined(PNG_USE_LOCAL_ARRAYS) -# define PNG_USE_LOCAL_ARRAYS -# endif -# else -# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) -# if defined(PNG_USE_GLOBAL_ARRAYS) -# undef PNG_USE_GLOBAL_ARRAYS -# endif -# endif -# endif -# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# define PNG_USE_LOCAL_ARRAYS -# endif -#endif - -/* Do not use global arrays (helps with building DLL's) - * They are no longer used in libpng itself, since version 1.0.5c, - * but might be required for some pre-1.0.5c applications. - */ -#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL)) -# define PNG_USE_LOCAL_ARRAYS -# else -# define PNG_USE_GLOBAL_ARRAYS -# endif -#endif - -#if defined(__CYGWIN__) -# undef PNGAPI -# define PNGAPI __cdecl -# undef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", - * you may get warnings regarding the linkage of png_zalloc and png_zfree. - * Don't ignore those warnings; you must also reset the default calling - * convention in your compiler to match your PNGAPI, and you must build - * zlib and your applications the same way you build libpng. - */ - -#if defined(__MINGW32__) && !defined(PNG_MODULEDEF) -# ifndef PNG_NO_MODULEDEF -# define PNG_NO_MODULEDEF -# endif -#endif - -#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) -# define PNG_IMPEXP -#endif - -#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ - (( defined(_Windows) || defined(_WINDOWS) || \ - defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) - -# ifndef PNGAPI -# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) -# define PNGAPI __cdecl -# else -# define PNGAPI _cdecl -# endif -# endif - -# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ - 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) -# define PNG_IMPEXP -# endif - -# if !defined(PNG_IMPEXP) - -# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol -# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol - - /* Borland/Microsoft */ -# if defined(_MSC_VER) || defined(__BORLANDC__) -# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) -# define PNG_EXPORT PNG_EXPORT_TYPE1 -# else -# define PNG_EXPORT PNG_EXPORT_TYPE2 -# if defined(PNG_BUILD_DLL) -# define PNG_IMPEXP __export -# else -# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in - VC++ */ -# endif /* Exists in Borland C++ for - C++ classes (== huge) */ -# endif -# endif - -# if !defined(PNG_IMPEXP) -# if defined(PNG_BUILD_DLL) -# define PNG_IMPEXP __declspec(dllexport) -# else -# define PNG_IMPEXP __declspec(dllimport) -# endif -# endif -# endif /* PNG_IMPEXP */ -#else /* !(DLL || non-cygwin WINDOWS) */ -# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) -# ifndef PNGAPI -# define PNGAPI _System -# endif -# else -# if 0 /* ... other platforms, with other meanings */ -# endif -# endif -#endif - -#ifndef PNGAPI -# define PNGAPI -#endif -#ifndef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -#ifdef PNG_BUILDSYMS -# ifndef PNG_EXPORT -# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END -# endif -# ifdef PNG_USE_GLOBAL_ARRAYS -# ifndef PNG_EXPORT_VAR -# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT -# endif -# endif -#endif - -#ifndef PNG_EXPORT -# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol -#endif - -#ifdef PNG_USE_GLOBAL_ARRAYS -# ifndef PNG_EXPORT_VAR -# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type -# endif -#endif - -/* User may want to use these so they are not in PNG_INTERNAL. Any library - * functions that are passed far data must be model independent. - */ - -#ifndef PNG_ABORT -# define PNG_ABORT() abort() -#endif - -#ifdef PNG_SETJMP_SUPPORTED -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#else -# define png_jmpbuf(png_ptr) \ - (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) -#endif - -#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ -/* use this to make far-to-near assignments */ -# define CHECK 1 -# define NOCHECK 0 -# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) -# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) -# define png_strcpy _fstrcpy -# define png_strncpy _fstrncpy /* Added to v 1.2.6 */ -# define png_strlen _fstrlen -# define png_memcmp _fmemcmp /* SJT: added */ -# define png_memcpy _fmemcpy -# define png_memset _fmemset -#else /* use the usual functions */ -# define CVT_PTR(ptr) (ptr) -# define CVT_PTR_NOCHECK(ptr) (ptr) -# define png_strcpy strcpy -# define png_strncpy strncpy /* Added to v 1.2.6 */ -# define png_strlen strlen -# define png_memcmp memcmp /* SJT: added */ -# define png_memcpy memcpy -# define png_memset memset -#endif -/* End of memory model independent support */ - -/* Just a little check that someone hasn't tried to define something - * contradictory. - */ -#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) -# undef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 65536L -#endif - -#ifdef PNG_READ_SUPPORTED -/* Prior to libpng-1.0.9, this block was in pngasmrd.h */ -#if defined(PNG_INTERNAL) - -/* These are the default thresholds before the MMX code kicks in; if either - * rowbytes or bitdepth is below the threshold, plain C code is used. These - * can be overridden at runtime via the png_set_mmx_thresholds() call in - * libpng 1.2.0 and later. The values below were chosen by Intel. - */ - -#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT -# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */ -#endif -#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT -# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */ -#endif - -/* Set this in the makefile for VC++ on Pentium, not here. */ -/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c . - * MMX will be detected at run time and used if present. - */ -#ifdef PNG_USE_PNGVCRD -# define PNG_HAVE_ASSEMBLER_COMBINE_ROW -# define PNG_HAVE_ASSEMBLER_READ_INTERLACE -# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW -#endif - -/* Set this in the makefile for gcc/as on Pentium, not here. */ -/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c . - * MMX will be detected at run time and used if present. - */ -#ifdef PNG_USE_PNGGCCRD -# define PNG_HAVE_ASSEMBLER_COMBINE_ROW -# define PNG_HAVE_ASSEMBLER_READ_INTERLACE -# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW -#endif -/* - see pnggccrd.c for info about what is currently enabled */ - -#endif /* PNG_INTERNAL */ -#endif /* PNG_READ_SUPPORTED */ - -/* Added at libpng-1.2.8 */ -#endif /* PNG_VERSION_INFO_ONLY */ - -#endif /* PNGCONF_H */ + +/* pngconf.h - machine configurable file for libpng + * + * libpng version 1.2.16 - January 31, 2007 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +/* Any machine specific code is near the front of this file, so if you + * are configuring libpng for a machine, you may want to read the section + * starting here down to where it starts to typedef png_color, png_text, + * and png_info. + */ + +#ifndef PNGCONF_H +#define PNGCONF_H + +#define PNG_1_2_X + +/* + * PNG_USER_CONFIG has to be defined on the compiler command line. This + * includes the resource compiler for Windows DLL configurations. + */ +#ifdef PNG_USER_CONFIG +# ifndef PNG_USER_PRIVATEBUILD +# define PNG_USER_PRIVATEBUILD +# endif +#include "pngusr.h" +#endif + +/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */ +#ifdef PNG_CONFIGURE_LIBPNG +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#endif + +/* + * Added at libpng-1.2.8 + * + * If you create a private DLL you need to define in "pngusr.h" the followings: + * #define PNG_USER_PRIVATEBUILD + * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons." + * #define PNG_USER_DLLFNAME_POSTFIX + * e.g. // private DLL "libpng13gx.dll" + * #define PNG_USER_DLLFNAME_POSTFIX "gx" + * + * The following macros are also at your disposal if you want to complete the + * DLL VERSIONINFO structure. + * - PNG_USER_VERSIONINFO_COMMENTS + * - PNG_USER_VERSIONINFO_COMPANYNAME + * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS + */ + +#ifdef __STDC__ +#ifdef SPECIALBUILD +# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\ + are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.") +#endif + +#ifdef PRIVATEBUILD +# pragma message("PRIVATEBUILD is deprecated.\ + Use PNG_USER_PRIVATEBUILD instead.") +# define PNG_USER_PRIVATEBUILD PRIVATEBUILD +#endif +#endif /* __STDC__ */ + +#ifndef PNG_VERSION_INFO_ONLY + +/* End of material added to libpng-1.2.8 */ + +/* This is the size of the compression buffer, and thus the size of + * an IDAT chunk. Make this whatever size you feel is best for your + * machine. One of these will be allocated per png_struct. When this + * is full, it writes the data to the disk, and does some other + * calculations. Making this an extremely small size will slow + * the library down, but you may want to experiment to determine + * where it becomes significant, if you are concerned with memory + * usage. Note that zlib allocates at least 32Kb also. For readers, + * this describes the size of the buffer available to read the data in. + * Unless this gets smaller than the size of a row (compressed), + * it should not make much difference how big this is. + */ + +#ifndef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 8192 +#endif + +/* Enable if you want a write-only libpng */ + +#ifndef PNG_NO_READ_SUPPORTED +# define PNG_READ_SUPPORTED +#endif + +/* Enable if you want a read-only libpng */ + +#ifndef PNG_NO_WRITE_SUPPORTED +# define PNG_WRITE_SUPPORTED +#endif + +/* Enabled by default in 1.2.0. You can disable this if you don't need to + support PNGs that are embedded in MNG datastreams */ +#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES) +# ifndef PNG_MNG_FEATURES_SUPPORTED +# define PNG_MNG_FEATURES_SUPPORTED +# endif +#endif + +#ifndef PNG_NO_FLOATING_POINT_SUPPORTED +# ifndef PNG_FLOATING_POINT_SUPPORTED +# define PNG_FLOATING_POINT_SUPPORTED +# endif +#endif + +/* If you are running on a machine where you cannot allocate more + * than 64K of memory at once, uncomment this. While libpng will not + * normally need that much memory in a chunk (unless you load up a very + * large file), zlib needs to know how big of a chunk it can use, and + * libpng thus makes sure to check any memory allocation to verify it + * will fit into memory. +#define PNG_MAX_MALLOC_64K + */ +#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) +# define PNG_MAX_MALLOC_64K +#endif + +/* Special munging to support doing things the 'cygwin' way: + * 'Normal' png-on-win32 defines/defaults: + * PNG_BUILD_DLL -- building dll + * PNG_USE_DLL -- building an application, linking to dll + * (no define) -- building static library, or building an + * application and linking to the static lib + * 'Cygwin' defines/defaults: + * PNG_BUILD_DLL -- (ignored) building the dll + * (no define) -- (ignored) building an application, linking to the dll + * PNG_STATIC -- (ignored) building the static lib, or building an + * application that links to the static lib. + * ALL_STATIC -- (ignored) building various static libs, or building an + * application that links to the static libs. + * Thus, + * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and + * this bit of #ifdefs will define the 'correct' config variables based on + * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but + * unnecessary. + * + * Also, the precedence order is: + * ALL_STATIC (since we can't #undef something outside our namespace) + * PNG_BUILD_DLL + * PNG_STATIC + * (nothing) == PNG_USE_DLL + * + * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent + * of auto-import in binutils, we no longer need to worry about + * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, + * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes + * to __declspec() stuff. However, we DO need to worry about + * PNG_BUILD_DLL and PNG_STATIC because those change some defaults + * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. + */ +#if defined(__CYGWIN__) +# if defined(ALL_STATIC) +# if defined(PNG_BUILD_DLL) +# undef PNG_BUILD_DLL +# endif +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if defined(PNG_DLL) +# undef PNG_DLL +# endif +# if !defined(PNG_STATIC) +# define PNG_STATIC +# endif +# else +# if defined (PNG_BUILD_DLL) +# if defined(PNG_STATIC) +# undef PNG_STATIC +# endif +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if !defined(PNG_DLL) +# define PNG_DLL +# endif +# else +# if defined(PNG_STATIC) +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if defined(PNG_DLL) +# undef PNG_DLL +# endif +# else +# if !defined(PNG_USE_DLL) +# define PNG_USE_DLL +# endif +# if !defined(PNG_DLL) +# define PNG_DLL +# endif +# endif +# endif +# endif +#endif + +/* This protects us against compilers that run on a windowing system + * and thus don't have or would rather us not use the stdio types: + * stdin, stdout, and stderr. The only one currently used is stderr + * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will + * prevent these from being compiled and used. #defining PNG_NO_STDIO + * will also prevent these, plus will prevent the entire set of stdio + * macros and functions (FILE *, printf, etc.) from being compiled and used, + * unless (PNG_DEBUG > 0) has been #defined. + * + * #define PNG_NO_CONSOLE_IO + * #define PNG_NO_STDIO + */ + +#if defined(_WIN32_WCE) +# include + /* Console I/O functions are not supported on WindowsCE */ +# define PNG_NO_CONSOLE_IO +# ifdef PNG_DEBUG +# undef PNG_DEBUG +# endif +#endif + +#ifdef PNG_BUILD_DLL +# ifndef PNG_CONSOLE_IO_SUPPORTED +# ifndef PNG_NO_CONSOLE_IO +# define PNG_NO_CONSOLE_IO +# endif +# endif +#endif + +# ifdef PNG_NO_STDIO +# ifndef PNG_NO_CONSOLE_IO +# define PNG_NO_CONSOLE_IO +# endif +# ifdef PNG_DEBUG +# if (PNG_DEBUG > 0) +# include +# endif +# endif +# else +# if !defined(_WIN32_WCE) +/* "stdio.h" functions are not supported on WindowsCE */ +# include +# endif +# endif + +/* This macro protects us against machines that don't have function + * prototypes (ie K&R style headers). If your compiler does not handle + * function prototypes, define this macro and use the included ansi2knr. + * I've always been able to use _NO_PROTO as the indicator, but you may + * need to drag the empty declaration out in front of here, or change the + * ifdef to suit your own needs. + */ +#ifndef PNGARG + +#ifdef OF /* zlib prototype munger */ +# define PNGARG(arglist) OF(arglist) +#else + +#ifdef _NO_PROTO +# define PNGARG(arglist) () +# ifndef PNG_TYPECAST_NULL +# define PNG_TYPECAST_NULL +# endif +#else +# define PNGARG(arglist) arglist +#endif /* _NO_PROTO */ + +#endif /* OF */ + +#endif /* PNGARG */ + +/* Try to determine if we are compiling on a Mac. Note that testing for + * just __MWERKS__ is not good enough, because the Codewarrior is now used + * on non-Mac platforms. + */ +#ifndef MACOS +# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ + defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) +# define MACOS +# endif +#endif + +/* enough people need this for various reasons to include it here */ +#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) +# include +#endif + +#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) +# define PNG_SETJMP_SUPPORTED +#endif + +#ifdef PNG_SETJMP_SUPPORTED +/* This is an attempt to force a single setjmp behaviour on Linux. If + * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. + */ + +# ifdef __linux__ +# ifdef _BSD_SOURCE +# define PNG_SAVE_BSD_SOURCE +# undef _BSD_SOURCE +# endif +# ifdef _SETJMP_H + /* If you encounter a compiler error here, see the explanation + * near the end of INSTALL. + */ + __png.h__ already includes setjmp.h; + __dont__ include it again.; +# endif +# endif /* __linux__ */ + + /* include setjmp.h for error handling */ +# include + +# ifdef __linux__ +# ifdef PNG_SAVE_BSD_SOURCE +# define _BSD_SOURCE +# undef PNG_SAVE_BSD_SOURCE +# endif +# endif /* __linux__ */ +#endif /* PNG_SETJMP_SUPPORTED */ + +#ifdef BSD +# include +#else +# include +#endif + +/* Other defines for things like memory and the like can go here. */ +#ifdef PNG_INTERNAL + +#include + +/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which + * aren't usually used outside the library (as far as I know), so it is + * debatable if they should be exported at all. In the future, when it is + * possible to have run-time registry of chunk-handling functions, some of + * these will be made available again. +#define PNG_EXTERN extern + */ +#define PNG_EXTERN + +/* Other defines specific to compilers can go here. Try to keep + * them inside an appropriate ifdef/endif pair for portability. + */ + +#if defined(PNG_FLOATING_POINT_SUPPORTED) +# if defined(MACOS) + /* We need to check that hasn't already been included earlier + * as it seems it doesn't agree with , yet we should really use + * if possible. + */ +# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) +# include +# endif +# else +# include +# endif +# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) + /* Amiga SAS/C: We must include builtin FPU functions when compiling using + * MATH=68881 + */ +# include +# endif +#endif + +/* Codewarrior on NT has linking problems without this. */ +#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) +# define PNG_ALWAYS_EXTERN +#endif + +/* This provides the non-ANSI (far) memory allocation routines. */ +#if defined(__TURBOC__) && defined(__MSDOS__) +# include +# include +#endif + +/* I have no idea why is this necessary... */ +#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ + defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) +# include +#endif + +/* This controls how fine the dithering gets. As this allocates + * a largish chunk of memory (32K), those who are not as concerned + * with dithering quality can decrease some or all of these. + */ +#ifndef PNG_DITHER_RED_BITS +# define PNG_DITHER_RED_BITS 5 +#endif +#ifndef PNG_DITHER_GREEN_BITS +# define PNG_DITHER_GREEN_BITS 5 +#endif +#ifndef PNG_DITHER_BLUE_BITS +# define PNG_DITHER_BLUE_BITS 5 +#endif + +/* This controls how fine the gamma correction becomes when you + * are only interested in 8 bits anyway. Increasing this value + * results in more memory being used, and more pow() functions + * being called to fill in the gamma tables. Don't set this value + * less then 8, and even that may not work (I haven't tested it). + */ + +#ifndef PNG_MAX_GAMMA_8 +# define PNG_MAX_GAMMA_8 11 +#endif + +/* This controls how much a difference in gamma we can tolerate before + * we actually start doing gamma conversion. + */ +#ifndef PNG_GAMMA_THRESHOLD +# define PNG_GAMMA_THRESHOLD 0.05 +#endif + +#endif /* PNG_INTERNAL */ + +/* The following uses const char * instead of char * for error + * and warning message functions, so some compilers won't complain. + * If you do not want to use const, define PNG_NO_CONST here. + */ + +#ifndef PNG_NO_CONST +# define PNG_CONST const +#else +# define PNG_CONST +#endif + +/* The following defines give you the ability to remove code from the + * library that you will not be using. I wish I could figure out how to + * automate this, but I can't do that without making it seriously hard + * on the users. So if you are not using an ability, change the #define + * to and #undef, and that part of the library will not be compiled. If + * your linker can't find a function, you may want to make sure the + * ability is defined here. Some of these depend upon some others being + * defined. I haven't figured out all the interactions here, so you may + * have to experiment awhile to get everything to compile. If you are + * creating or using a shared library, you probably shouldn't touch this, + * as it will affect the size of the structures, and this will cause bad + * things to happen if the library and/or application ever change. + */ + +/* Any features you will not be using can be undef'ed here */ + +/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user + * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS + * on the compile line, then pick and choose which ones to define without + * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED + * if you only want to have a png-compliant reader/writer but don't need + * any of the extra transformations. This saves about 80 kbytes in a + * typical installation of the library. (PNG_NO_* form added in version + * 1.0.1c, for consistency) + */ + +/* The size of the png_text structure changed in libpng-1.0.6 when + * iTXt support was added. iTXt support was turned off by default through + * libpng-1.2.x, to support old apps that malloc the png_text structure + * instead of calling png_set_text() and letting libpng malloc it. It + * was turned on by default in libpng-1.3.0. + */ + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +# ifndef PNG_NO_iTXt_SUPPORTED +# define PNG_NO_iTXt_SUPPORTED +# endif +# ifndef PNG_NO_READ_iTXt +# define PNG_NO_READ_iTXt +# endif +# ifndef PNG_NO_WRITE_iTXt +# define PNG_NO_WRITE_iTXt +# endif +#endif + +#if !defined(PNG_NO_iTXt_SUPPORTED) +# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) +# define PNG_READ_iTXt +# endif +# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt) +# define PNG_WRITE_iTXt +# endif +#endif + +/* The following support, added after version 1.0.0, can be turned off here en + * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility + * with old applications that require the length of png_struct and png_info + * to remain unchanged. + */ + +#ifdef PNG_LEGACY_SUPPORTED +# define PNG_NO_FREE_ME +# define PNG_NO_READ_UNKNOWN_CHUNKS +# define PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_NO_READ_USER_CHUNKS +# define PNG_NO_READ_iCCP +# define PNG_NO_WRITE_iCCP +# define PNG_NO_READ_iTXt +# define PNG_NO_WRITE_iTXt +# define PNG_NO_READ_sCAL +# define PNG_NO_WRITE_sCAL +# define PNG_NO_READ_sPLT +# define PNG_NO_WRITE_sPLT +# define PNG_NO_INFO_IMAGE +# define PNG_NO_READ_RGB_TO_GRAY +# define PNG_NO_READ_USER_TRANSFORM +# define PNG_NO_WRITE_USER_TRANSFORM +# define PNG_NO_USER_MEM +# define PNG_NO_READ_EMPTY_PLTE +# define PNG_NO_MNG_FEATURES +# define PNG_NO_FIXED_POINT_SUPPORTED +#endif + +/* Ignore attempt to turn off both floating and fixed point support */ +#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ + !defined(PNG_NO_FIXED_POINT_SUPPORTED) +# define PNG_FIXED_POINT_SUPPORTED +#endif + +#ifndef PNG_NO_FREE_ME +# define PNG_FREE_ME_SUPPORTED +#endif + +#if defined(PNG_READ_SUPPORTED) + +#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ + !defined(PNG_NO_READ_TRANSFORMS) +# define PNG_READ_TRANSFORMS_SUPPORTED +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +# ifndef PNG_NO_READ_EXPAND +# define PNG_READ_EXPAND_SUPPORTED +# endif +# ifndef PNG_NO_READ_SHIFT +# define PNG_READ_SHIFT_SUPPORTED +# endif +# ifndef PNG_NO_READ_PACK +# define PNG_READ_PACK_SUPPORTED +# endif +# ifndef PNG_NO_READ_BGR +# define PNG_READ_BGR_SUPPORTED +# endif +# ifndef PNG_NO_READ_SWAP +# define PNG_READ_SWAP_SUPPORTED +# endif +# ifndef PNG_NO_READ_PACKSWAP +# define PNG_READ_PACKSWAP_SUPPORTED +# endif +# ifndef PNG_NO_READ_INVERT +# define PNG_READ_INVERT_SUPPORTED +# endif +# ifndef PNG_NO_READ_DITHER +# define PNG_READ_DITHER_SUPPORTED +# endif +# ifndef PNG_NO_READ_BACKGROUND +# define PNG_READ_BACKGROUND_SUPPORTED +# endif +# ifndef PNG_NO_READ_16_TO_8 +# define PNG_READ_16_TO_8_SUPPORTED +# endif +# ifndef PNG_NO_READ_FILLER +# define PNG_READ_FILLER_SUPPORTED +# endif +# ifndef PNG_NO_READ_GAMMA +# define PNG_READ_GAMMA_SUPPORTED +# endif +# ifndef PNG_NO_READ_GRAY_TO_RGB +# define PNG_READ_GRAY_TO_RGB_SUPPORTED +# endif +# ifndef PNG_NO_READ_SWAP_ALPHA +# define PNG_READ_SWAP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_INVERT_ALPHA +# define PNG_READ_INVERT_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_STRIP_ALPHA +# define PNG_READ_STRIP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_USER_TRANSFORM +# define PNG_READ_USER_TRANSFORM_SUPPORTED +# endif +# ifndef PNG_NO_READ_RGB_TO_GRAY +# define PNG_READ_RGB_TO_GRAY_SUPPORTED +# endif +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ + +#if !defined(PNG_NO_PROGRESSIVE_READ) && \ + !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */ +# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ +#endif /* about interlacing capability! You'll */ + /* still have interlacing unless you change the following line: */ + +#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ + +#ifndef PNG_NO_READ_COMPOSITE_NODIV +# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ +# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ +# endif +#endif + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Deprecated, will be removed from version 2.0.0. + Use PNG_MNG_FEATURES_SUPPORTED instead. */ +#ifndef PNG_NO_READ_EMPTY_PLTE +# define PNG_READ_EMPTY_PLTE_SUPPORTED +#endif +#endif + +#endif /* PNG_READ_SUPPORTED */ + +#if defined(PNG_WRITE_SUPPORTED) + +# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ + !defined(PNG_NO_WRITE_TRANSFORMS) +# define PNG_WRITE_TRANSFORMS_SUPPORTED +#endif + +#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED +# ifndef PNG_NO_WRITE_SHIFT +# define PNG_WRITE_SHIFT_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_PACK +# define PNG_WRITE_PACK_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_BGR +# define PNG_WRITE_BGR_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_SWAP +# define PNG_WRITE_SWAP_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_PACKSWAP +# define PNG_WRITE_PACKSWAP_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_INVERT +# define PNG_WRITE_INVERT_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_FILLER +# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ +# endif +# ifndef PNG_NO_WRITE_SWAP_ALPHA +# define PNG_WRITE_SWAP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_INVERT_ALPHA +# define PNG_WRITE_INVERT_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_USER_TRANSFORM +# define PNG_WRITE_USER_TRANSFORM_SUPPORTED +# endif +#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ + +#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \ + !defined(PNG_WRITE_INTERLACING_SUPPORTED) +#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant + encoders, but can cause trouble + if left undefined */ +#endif + +#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ + !defined(PNG_WRITE_WEIGHTED_FILTER) && \ + defined(PNG_FLOATING_POINT_SUPPORTED) +# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#endif + +#ifndef PNG_NO_WRITE_FLUSH +# define PNG_WRITE_FLUSH_SUPPORTED +#endif + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ +#ifndef PNG_NO_WRITE_EMPTY_PLTE +# define PNG_WRITE_EMPTY_PLTE_SUPPORTED +#endif +#endif + +#endif /* PNG_WRITE_SUPPORTED */ + +#ifndef PNG_1_0_X +# ifndef PNG_NO_ERROR_NUMBERS +# define PNG_ERROR_NUMBERS_SUPPORTED +# endif +#endif /* PNG_1_0_X */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +# ifndef PNG_NO_USER_TRANSFORM_PTR +# define PNG_USER_TRANSFORM_PTR_SUPPORTED +# endif +#endif + +#ifndef PNG_NO_STDIO +# define PNG_TIME_RFC1123_SUPPORTED +#endif + +/* This adds extra functions in pngget.c for accessing data from the + * info pointer (added in version 0.99) + * png_get_image_width() + * png_get_image_height() + * png_get_bit_depth() + * png_get_color_type() + * png_get_compression_type() + * png_get_filter_type() + * png_get_interlace_type() + * png_get_pixel_aspect_ratio() + * png_get_pixels_per_meter() + * png_get_x_offset_pixels() + * png_get_y_offset_pixels() + * png_get_x_offset_microns() + * png_get_y_offset_microns() + */ +#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) +# define PNG_EASY_ACCESS_SUPPORTED +#endif + +/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 + * even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined. + * + * PNG_NO_ASSEMBLER_CODE disables use of all assembler code and optimized C, + * and removes or includes several functions in the API. + * + * PNG_NO_MMX_CODE disables the use of MMX code without changing the API. + * When MMX code is off, then optimized C replacement functions are used. +*/ +#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) +# ifndef PNG_ASSEMBLER_CODE_SUPPORTED +# define PNG_ASSEMBLER_CODE_SUPPORTED +# endif +# if defined(XP_MACOSX) && !defined(PNG_NO_MMX_CODE) + /* work around Intel-Mac compiler bug */ +# define PNG_NO_MMX_CODE +# endif +# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) && \ + defined(__MMX__) +# define PNG_MMX_CODE_SUPPORTED +# endif +# if !defined(PNG_USE_PNGGCCRD) && !defined(PNG_NO_MMX_CODE) && \ + !defined(PNG_USE_PNGVCRD) && defined(__MMX__) +# define PNG_USE_PNGGCCRD +# endif +#endif + +/* If you are sure that you don't need thread safety and you are compiling + with PNG_USE_PNGCCRD for an MMX application, you can define this for + faster execution. See pnggccrd.c. +#define PNG_THREAD_UNSAFE_OK +*/ + +#if !defined(PNG_1_0_X) +#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) +# define PNG_USER_MEM_SUPPORTED +#endif +#endif /* PNG_1_0_X */ + +/* Added at libpng-1.2.6 */ +#if !defined(PNG_1_0_X) +#ifndef PNG_SET_USER_LIMITS_SUPPORTED +#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED) +# define PNG_SET_USER_LIMITS_SUPPORTED +#endif +#endif +#endif /* PNG_1_0_X */ + +/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGS no matter + * how large, set these limits to 0x7fffffffL + */ +#ifndef PNG_USER_WIDTH_MAX +# define PNG_USER_WIDTH_MAX 1000000L +#endif +#ifndef PNG_USER_HEIGHT_MAX +# define PNG_USER_HEIGHT_MAX 1000000L +#endif + +/* These are currently experimental features, define them if you want */ + +/* very little testing */ +/* +#ifdef PNG_READ_SUPPORTED +# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# endif +#endif +*/ + +/* This is only for PowerPC big-endian and 680x0 systems */ +/* some testing */ +/* +#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED +# define PNG_READ_BIG_ENDIAN_SUPPORTED +#endif +*/ + +/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ +/* +#define PNG_NO_POINTER_INDEXING +*/ + +/* These functions are turned off by default, as they will be phased out. */ +/* +#define PNG_USELESS_TESTS_SUPPORTED +#define PNG_CORRECT_PALETTE_SUPPORTED +*/ + +/* Any chunks you are not interested in, you can undef here. The + * ones that allocate memory may be expecially important (hIST, + * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info + * a bit smaller. + */ + +#if defined(PNG_READ_SUPPORTED) && \ + !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ + !defined(PNG_NO_READ_ANCILLARY_CHUNKS) +# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED +#endif + +#if defined(PNG_WRITE_SUPPORTED) && \ + !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ + !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) +# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED +#endif + +#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED + +#ifdef PNG_NO_READ_TEXT +# define PNG_NO_READ_iTXt +# define PNG_NO_READ_tEXt +# define PNG_NO_READ_zTXt +#endif +#ifndef PNG_NO_READ_bKGD +# define PNG_READ_bKGD_SUPPORTED +# define PNG_bKGD_SUPPORTED +#endif +#ifndef PNG_NO_READ_cHRM +# define PNG_READ_cHRM_SUPPORTED +# define PNG_cHRM_SUPPORTED +#endif +#ifndef PNG_NO_READ_gAMA +# define PNG_READ_gAMA_SUPPORTED +# define PNG_gAMA_SUPPORTED +#endif +#ifndef PNG_NO_READ_hIST +# define PNG_READ_hIST_SUPPORTED +# define PNG_hIST_SUPPORTED +#endif +#ifndef PNG_NO_READ_iCCP +# define PNG_READ_iCCP_SUPPORTED +# define PNG_iCCP_SUPPORTED +#endif +#ifndef PNG_NO_READ_iTXt +# ifndef PNG_READ_iTXt_SUPPORTED +# define PNG_READ_iTXt_SUPPORTED +# endif +# ifndef PNG_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_READ_oFFs +# define PNG_READ_oFFs_SUPPORTED +# define PNG_oFFs_SUPPORTED +#endif +#ifndef PNG_NO_READ_pCAL +# define PNG_READ_pCAL_SUPPORTED +# define PNG_pCAL_SUPPORTED +#endif +#ifndef PNG_NO_READ_sCAL +# define PNG_READ_sCAL_SUPPORTED +# define PNG_sCAL_SUPPORTED +#endif +#ifndef PNG_NO_READ_pHYs +# define PNG_READ_pHYs_SUPPORTED +# define PNG_pHYs_SUPPORTED +#endif +#ifndef PNG_NO_READ_sBIT +# define PNG_READ_sBIT_SUPPORTED +# define PNG_sBIT_SUPPORTED +#endif +#ifndef PNG_NO_READ_sPLT +# define PNG_READ_sPLT_SUPPORTED +# define PNG_sPLT_SUPPORTED +#endif +#ifndef PNG_NO_READ_sRGB +# define PNG_READ_sRGB_SUPPORTED +# define PNG_sRGB_SUPPORTED +#endif +#ifndef PNG_NO_READ_tEXt +# define PNG_READ_tEXt_SUPPORTED +# define PNG_tEXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_tIME +# define PNG_READ_tIME_SUPPORTED +# define PNG_tIME_SUPPORTED +#endif +#ifndef PNG_NO_READ_tRNS +# define PNG_READ_tRNS_SUPPORTED +# define PNG_tRNS_SUPPORTED +#endif +#ifndef PNG_NO_READ_zTXt +# define PNG_READ_zTXt_SUPPORTED +# define PNG_zTXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_UNKNOWN_CHUNKS +# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +# ifndef PNG_NO_HANDLE_AS_UNKNOWN +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +#endif +#if !defined(PNG_NO_READ_USER_CHUNKS) && \ + defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) +# define PNG_READ_USER_CHUNKS_SUPPORTED +# define PNG_USER_CHUNKS_SUPPORTED +# ifdef PNG_NO_READ_UNKNOWN_CHUNKS +# undef PNG_NO_READ_UNKNOWN_CHUNKS +# endif +# ifdef PNG_NO_HANDLE_AS_UNKNOWN +# undef PNG_NO_HANDLE_AS_UNKNOWN +# endif +#endif +#ifndef PNG_NO_READ_OPT_PLTE +# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ +#endif /* optional PLTE chunk in RGB and RGBA images */ +#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ + defined(PNG_READ_zTXt_SUPPORTED) +# define PNG_READ_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +#endif + +#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ + +#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED + +#ifdef PNG_NO_WRITE_TEXT +# define PNG_NO_WRITE_iTXt +# define PNG_NO_WRITE_tEXt +# define PNG_NO_WRITE_zTXt +#endif +#ifndef PNG_NO_WRITE_bKGD +# define PNG_WRITE_bKGD_SUPPORTED +# ifndef PNG_bKGD_SUPPORTED +# define PNG_bKGD_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_cHRM +# define PNG_WRITE_cHRM_SUPPORTED +# ifndef PNG_cHRM_SUPPORTED +# define PNG_cHRM_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_gAMA +# define PNG_WRITE_gAMA_SUPPORTED +# ifndef PNG_gAMA_SUPPORTED +# define PNG_gAMA_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_hIST +# define PNG_WRITE_hIST_SUPPORTED +# ifndef PNG_hIST_SUPPORTED +# define PNG_hIST_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_iCCP +# define PNG_WRITE_iCCP_SUPPORTED +# ifndef PNG_iCCP_SUPPORTED +# define PNG_iCCP_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_iTXt +# ifndef PNG_WRITE_iTXt_SUPPORTED +# define PNG_WRITE_iTXt_SUPPORTED +# endif +# ifndef PNG_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_oFFs +# define PNG_WRITE_oFFs_SUPPORTED +# ifndef PNG_oFFs_SUPPORTED +# define PNG_oFFs_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_pCAL +# define PNG_WRITE_pCAL_SUPPORTED +# ifndef PNG_pCAL_SUPPORTED +# define PNG_pCAL_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sCAL +# define PNG_WRITE_sCAL_SUPPORTED +# ifndef PNG_sCAL_SUPPORTED +# define PNG_sCAL_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_pHYs +# define PNG_WRITE_pHYs_SUPPORTED +# ifndef PNG_pHYs_SUPPORTED +# define PNG_pHYs_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sBIT +# define PNG_WRITE_sBIT_SUPPORTED +# ifndef PNG_sBIT_SUPPORTED +# define PNG_sBIT_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sPLT +# define PNG_WRITE_sPLT_SUPPORTED +# ifndef PNG_sPLT_SUPPORTED +# define PNG_sPLT_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sRGB +# define PNG_WRITE_sRGB_SUPPORTED +# ifndef PNG_sRGB_SUPPORTED +# define PNG_sRGB_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tEXt +# define PNG_WRITE_tEXt_SUPPORTED +# ifndef PNG_tEXt_SUPPORTED +# define PNG_tEXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tIME +# define PNG_WRITE_tIME_SUPPORTED +# ifndef PNG_tIME_SUPPORTED +# define PNG_tIME_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tRNS +# define PNG_WRITE_tRNS_SUPPORTED +# ifndef PNG_tRNS_SUPPORTED +# define PNG_tRNS_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_zTXt +# define PNG_WRITE_zTXt_SUPPORTED +# ifndef PNG_zTXt_SUPPORTED +# define PNG_zTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +# ifndef PNG_NO_HANDLE_AS_UNKNOWN +# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +# endif +#endif +#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ + defined(PNG_WRITE_zTXt_SUPPORTED) +# define PNG_WRITE_TEXT_SUPPORTED +# ifndef PNG_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +# endif +#endif + +#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ + +/* Turn this off to disable png_read_png() and + * png_write_png() and leave the row_pointers member + * out of the info structure. + */ +#ifndef PNG_NO_INFO_IMAGE +# define PNG_INFO_IMAGE_SUPPORTED +#endif + +/* need the time information for reading tIME chunks */ +#if defined(PNG_tIME_SUPPORTED) +# if !defined(_WIN32_WCE) + /* "time.h" functions are not supported on WindowsCE */ +# include +# endif +#endif + +/* Some typedefs to get us started. These should be safe on most of the + * common platforms. The typedefs should be at least as large as the + * numbers suggest (a png_uint_32 must be at least 32 bits long), but they + * don't have to be exactly that size. Some compilers dislike passing + * unsigned shorts as function parameters, so you may be better off using + * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may + * want to have unsigned int for png_uint_32 instead of unsigned long. + */ + +typedef unsigned long png_uint_32; +typedef long png_int_32; +typedef unsigned short png_uint_16; +typedef short png_int_16; +typedef unsigned char png_byte; + +/* This is usually size_t. It is typedef'ed just in case you need it to + change (I'm not sure if you will or not, so I thought I'd be safe) */ +#ifdef PNG_SIZE_T + typedef PNG_SIZE_T png_size_t; +# define png_sizeof(x) png_convert_size(sizeof (x)) +#else + typedef size_t png_size_t; +# define png_sizeof(x) sizeof (x) +#endif + +/* The following is needed for medium model support. It cannot be in the + * PNG_INTERNAL section. Needs modification for other compilers besides + * MSC. Model independent support declares all arrays and pointers to be + * large using the far keyword. The zlib version used must also support + * model independent data. As of version zlib 1.0.4, the necessary changes + * have been made in zlib. The USE_FAR_KEYWORD define triggers other + * changes that are needed. (Tim Wegner) + */ + +/* Separate compiler dependencies (problem here is that zlib.h always + defines FAR. (SJT) */ +#ifdef __BORLANDC__ +# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) +# define LDATA 1 +# else +# define LDATA 0 +# endif + /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ +# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) +# define PNG_MAX_MALLOC_64K +# if (LDATA != 1) +# ifndef FAR +# define FAR __far +# endif +# define USE_FAR_KEYWORD +# endif /* LDATA != 1 */ + /* Possibly useful for moving data out of default segment. + * Uncomment it if you want. Could also define FARDATA as + * const if your compiler supports it. (SJT) +# define FARDATA FAR + */ +# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ +#endif /* __BORLANDC__ */ + + +/* Suggest testing for specific compiler first before testing for + * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, + * making reliance oncertain keywords suspect. (SJT) + */ + +/* MSC Medium model */ +#if defined(FAR) +# if defined(M_I86MM) +# define USE_FAR_KEYWORD +# define FARDATA FAR +# include +# endif +#endif + +/* SJT: default case */ +#ifndef FAR +# define FAR +#endif + +/* At this point FAR is always defined */ +#ifndef FARDATA +# define FARDATA +#endif + +/* Typedef for floating-point numbers that are converted + to fixed-point with a multiple of 100,000, e.g., int_gamma */ +typedef png_int_32 png_fixed_point; + +/* Add typedefs for pointers */ +typedef void FAR * png_voidp; +typedef png_byte FAR * png_bytep; +typedef png_uint_32 FAR * png_uint_32p; +typedef png_int_32 FAR * png_int_32p; +typedef png_uint_16 FAR * png_uint_16p; +typedef png_int_16 FAR * png_int_16p; +typedef PNG_CONST char FAR * png_const_charp; +typedef char FAR * png_charp; +typedef png_fixed_point FAR * png_fixed_point_p; + +#ifndef PNG_NO_STDIO +#if defined(_WIN32_WCE) +typedef HANDLE png_FILE_p; +#else +typedef FILE * png_FILE_p; +#endif +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double FAR * png_doublep; +#endif + +/* Pointers to pointers; i.e. arrays */ +typedef png_byte FAR * FAR * png_bytepp; +typedef png_uint_32 FAR * FAR * png_uint_32pp; +typedef png_int_32 FAR * FAR * png_int_32pp; +typedef png_uint_16 FAR * FAR * png_uint_16pp; +typedef png_int_16 FAR * FAR * png_int_16pp; +typedef PNG_CONST char FAR * FAR * png_const_charpp; +typedef char FAR * FAR * png_charpp; +typedef png_fixed_point FAR * FAR * png_fixed_point_pp; +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double FAR * FAR * png_doublepp; +#endif + +/* Pointers to pointers to pointers; i.e., pointer to array */ +typedef char FAR * FAR * FAR * png_charppp; + +#if defined(PNG_1_0_X) || defined(PNG_1_2_X) +/* SPC - Is this stuff deprecated? */ +/* It'll be removed as of libpng-1.3.0 - GR-P */ +/* libpng typedefs for types in zlib. If zlib changes + * or another compression library is used, then change these. + * Eliminates need to change all the source files. + */ +typedef charf * png_zcharp; +typedef charf * FAR * png_zcharpp; +typedef z_stream FAR * png_zstreamp; +#endif /* (PNG_1_0_X) || defined(PNG_1_2_X) */ + +/* + * Define PNG_BUILD_DLL if the module being built is a Windows + * LIBPNG DLL. + * + * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. + * It is equivalent to Microsoft predefined macro _DLL that is + * automatically defined when you compile using the share + * version of the CRT (C Run-Time library) + * + * The cygwin mods make this behavior a little different: + * Define PNG_BUILD_DLL if you are building a dll for use with cygwin + * Define PNG_STATIC if you are building a static library for use with cygwin, + * -or- if you are building an application that you want to link to the + * static library. + * PNG_USE_DLL is defined by default (no user action needed) unless one of + * the other flags is defined. + */ + +#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) +# define PNG_DLL +#endif +/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. + * When building a static lib, default to no GLOBAL ARRAYS, but allow + * command-line override + */ +#if defined(__CYGWIN__) +# if !defined(PNG_STATIC) +# if defined(PNG_USE_GLOBAL_ARRAYS) +# undef PNG_USE_GLOBAL_ARRAYS +# endif +# if !defined(PNG_USE_LOCAL_ARRAYS) +# define PNG_USE_LOCAL_ARRAYS +# endif +# else +# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) +# if defined(PNG_USE_GLOBAL_ARRAYS) +# undef PNG_USE_GLOBAL_ARRAYS +# endif +# endif +# endif +# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) +# define PNG_USE_LOCAL_ARRAYS +# endif +#endif + +/* Do not use global arrays (helps with building DLL's) + * They are no longer used in libpng itself, since version 1.0.5c, + * but might be required for some pre-1.0.5c applications. + */ +#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) +# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL)) +# define PNG_USE_LOCAL_ARRAYS +# else +# define PNG_USE_GLOBAL_ARRAYS +# endif +#endif + +#if defined(__CYGWIN__) +# undef PNGAPI +# define PNGAPI __cdecl +# undef PNG_IMPEXP +# define PNG_IMPEXP +#endif + +/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", + * you may get warnings regarding the linkage of png_zalloc and png_zfree. + * Don't ignore those warnings; you must also reset the default calling + * convention in your compiler to match your PNGAPI, and you must build + * zlib and your applications the same way you build libpng. + */ + +#if defined(__MINGW32__) && !defined(PNG_MODULEDEF) +# ifndef PNG_NO_MODULEDEF +# define PNG_NO_MODULEDEF +# endif +#endif + +#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) +# define PNG_IMPEXP +#endif + +#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ + (( defined(_Windows) || defined(_WINDOWS) || \ + defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) + +# ifndef PNGAPI +# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) +# define PNGAPI __cdecl +# else +# define PNGAPI _cdecl +# endif +# endif + +# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ + 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) +# define PNG_IMPEXP +# endif + +# if !defined(PNG_IMPEXP) + +# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol +# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol + + /* Borland/Microsoft */ +# if defined(_MSC_VER) || defined(__BORLANDC__) +# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) +# define PNG_EXPORT PNG_EXPORT_TYPE1 +# else +# define PNG_EXPORT PNG_EXPORT_TYPE2 +# if defined(PNG_BUILD_DLL) +# define PNG_IMPEXP __export +# else +# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in + VC++ */ +# endif /* Exists in Borland C++ for + C++ classes (== huge) */ +# endif +# endif + +# if !defined(PNG_IMPEXP) +# if defined(PNG_BUILD_DLL) +# define PNG_IMPEXP __declspec(dllexport) +# else +# define PNG_IMPEXP __declspec(dllimport) +# endif +# endif +# endif /* PNG_IMPEXP */ +#else /* !(DLL || non-cygwin WINDOWS) */ +# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) +# ifndef PNGAPI +# define PNGAPI _System +# endif +# else +# if 0 /* ... other platforms, with other meanings */ +# endif +# endif +#endif + +#ifndef PNGAPI +# define PNGAPI +#endif +#ifndef PNG_IMPEXP +# define PNG_IMPEXP +#endif + +#ifdef PNG_BUILDSYMS +# ifndef PNG_EXPORT +# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END +# endif +# ifdef PNG_USE_GLOBAL_ARRAYS +# ifndef PNG_EXPORT_VAR +# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT +# endif +# endif +#endif + +#ifndef PNG_EXPORT +# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol +#endif + +#ifdef PNG_USE_GLOBAL_ARRAYS +# ifndef PNG_EXPORT_VAR +# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type +# endif +#endif + +/* User may want to use these so they are not in PNG_INTERNAL. Any library + * functions that are passed far data must be model independent. + */ + +#ifndef PNG_ABORT +# define PNG_ABORT() abort() +#endif + +#ifdef PNG_SETJMP_SUPPORTED +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#else +# define png_jmpbuf(png_ptr) \ + (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) +#endif + +#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ +/* use this to make far-to-near assignments */ +# define CHECK 1 +# define NOCHECK 0 +# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) +# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) +# define png_strcpy _fstrcpy +# define png_strncpy _fstrncpy /* Added to v 1.2.6 */ +# define png_strlen _fstrlen +# define png_memcmp _fmemcmp /* SJT: added */ +# define png_memcpy _fmemcpy +# define png_memset _fmemset +#else /* use the usual functions */ +# define CVT_PTR(ptr) (ptr) +# define CVT_PTR_NOCHECK(ptr) (ptr) +# define png_strcpy strcpy +# define png_strncpy strncpy /* Added to v 1.2.6 */ +# define png_strlen strlen +# define png_memcmp memcmp /* SJT: added */ +# define png_memcpy memcpy +# define png_memset memset +#endif +/* End of memory model independent support */ + +/* Just a little check that someone hasn't tried to define something + * contradictory. + */ +#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) +# undef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 65536L +#endif + +#ifdef PNG_READ_SUPPORTED +/* Prior to libpng-1.0.9, this block was in pngasmrd.h */ +#if defined(PNG_INTERNAL) + +/* These are the default thresholds before the MMX code kicks in; if either + * rowbytes or bitdepth is below the threshold, plain C code is used. These + * can be overridden at runtime via the png_set_mmx_thresholds() call in + * libpng 1.2.0 and later. The values below were chosen by Intel. + */ + +#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT +# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */ +#endif +#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT +# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */ +#endif + +/* Set this in the makefile for VC++ on Pentium, not here. */ +/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c . + * MMX will be detected at run time and used if present. + */ +#ifdef PNG_USE_PNGVCRD +# define PNG_HAVE_ASSEMBLER_COMBINE_ROW +# define PNG_HAVE_ASSEMBLER_READ_INTERLACE +# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW +#endif + +/* Set this in the makefile for gcc/as on Pentium, not here. */ +/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c . + * MMX will be detected at run time and used if present. + */ +#ifdef PNG_USE_PNGGCCRD +# define PNG_HAVE_ASSEMBLER_COMBINE_ROW +# define PNG_HAVE_ASSEMBLER_READ_INTERLACE +# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW +#endif +/* - see pnggccrd.c for info about what is currently enabled */ + +#endif /* PNG_INTERNAL */ +#endif /* PNG_READ_SUPPORTED */ + +/* Added at libpng-1.2.8 */ +#endif /* PNG_VERSION_INFO_ONLY */ + +#endif /* PNGCONF_H */ diff --git a/src/dep/src/irrlicht/libpng/pngerror.c b/src/dep/src/irrlicht/libpng/pngerror.c index 4857133..c8c58b9 100644 --- a/src/dep/src/irrlicht/libpng/pngerror.c +++ b/src/dep/src/irrlicht/libpng/pngerror.c @@ -1,320 +1,320 @@ - -/* pngerror.c - stub functions for i/o and memory allocation - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all error handling. Users who - * need special error handling are expected to write replacement functions - * and use png_set_error_fn() to use those functions. See the instructions - * at each function. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -static void /* PRIVATE */ -png_default_error PNGARG((png_structp png_ptr, - png_const_charp error_message)); -static void /* PRIVATE */ -png_default_warning PNGARG((png_structp png_ptr, - png_const_charp warning_message)); - -/* This function is called whenever there is a fatal error. This function - * should not be changed. If there is a need to handle errors differently, - * you should supply a replacement error function and use png_set_error_fn() - * to replace the error function at run-time. - */ -void PNGAPI -png_error(png_structp png_ptr, png_const_charp error_message) -{ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - char msg[16]; - if (png_ptr != NULL) - { - if (png_ptr->flags& - (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) - { - if (*error_message == '#') - { - int offset; - for (offset=1; offset<15; offset++) - if (*(error_message+offset) == ' ') - break; - if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) - { - int i; - for (i=0; iflags&PNG_FLAG_STRIP_ERROR_TEXT) - { - msg[0]='0'; - msg[1]='\0'; - error_message=msg; - } - } - } - } -#endif - if (png_ptr != NULL && png_ptr->error_fn != NULL) - (*(png_ptr->error_fn))(png_ptr, error_message); - - /* If the custom handler doesn't exist, or if it returns, - use the default handler, which will not return. */ - png_default_error(png_ptr, error_message); -} - -/* This function is called whenever there is a non-fatal error. This function - * should not be changed. If there is a need to handle warnings differently, - * you should supply a replacement warning function and use - * png_set_error_fn() to replace the warning function at run-time. - */ -void PNGAPI -png_warning(png_structp png_ptr, png_const_charp warning_message) -{ - int offset = 0; - if (png_ptr != NULL) - { -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (png_ptr->flags& - (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) -#endif - { - if (*warning_message == '#') - { - for (offset=1; offset<15; offset++) - if (*(warning_message+offset) == ' ') - break; - } - } - if (png_ptr != NULL && png_ptr->warning_fn != NULL) - (*(png_ptr->warning_fn))(png_ptr, warning_message+offset); - } - else - png_default_warning(png_ptr, warning_message+offset); -} - -/* These utilities are used internally to build an error message that relates - * to the current chunk. The chunk name comes from png_ptr->chunk_name, - * this is used to prefix the message. The message is limited in length - * to 63 bytes, the name characters are output as hex digits wrapped in [] - * if the character is invalid. - */ -#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) -static PNG_CONST char png_digit[16] = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'A', 'B', 'C', 'D', 'E', 'F' -}; - -static void /* PRIVATE */ -png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp - error_message) -{ - int iout = 0, iin = 0; - - while (iin < 4) - { - int c = png_ptr->chunk_name[iin++]; - if (isnonalpha(c)) - { - buffer[iout++] = '['; - buffer[iout++] = png_digit[(c & 0xf0) >> 4]; - buffer[iout++] = png_digit[c & 0x0f]; - buffer[iout++] = ']'; - } - else - { - buffer[iout++] = (png_byte)c; - } - } - - if (error_message == NULL) - buffer[iout] = 0; - else - { - buffer[iout++] = ':'; - buffer[iout++] = ' '; - png_strncpy(buffer+iout, error_message, 63); - buffer[iout+63] = 0; - } -} - -void PNGAPI -png_chunk_error(png_structp png_ptr, png_const_charp error_message) -{ - char msg[18+64]; - if (png_ptr == NULL) - png_error(png_ptr, error_message); - else - { - png_format_buffer(png_ptr, msg, error_message); - png_error(png_ptr, msg); - } -} - -void PNGAPI -png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) -{ - char msg[18+64]; - if (png_ptr == NULL) - png_warning(png_ptr, warning_message); - else - { - png_format_buffer(png_ptr, msg, warning_message); - png_warning(png_ptr, msg); - } -} - -/* This is the default error handling function. Note that replacements for - * this function MUST NOT RETURN, or the program will likely crash. This - * function is used by default, or if the program supplies NULL for the - * error function pointer in png_set_error_fn(). - */ -static void /* PRIVATE */ -png_default_error(png_structp png_ptr, png_const_charp error_message) -{ -#ifndef PNG_NO_CONSOLE_IO -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*error_message == '#') - { - int offset; - char error_number[16]; - for (offset=0; offset<15; offset++) - { - error_number[offset] = *(error_message+offset+1); - if (*(error_message+offset) == ' ') - break; - } - if((offset > 1) && (offset < 15)) - { - error_number[offset-1]='\0'; - fprintf(stderr, "libpng error no. %s: %s\n", error_number, - error_message+offset); - } - else - fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); - } - else -#endif - fprintf(stderr, "libpng error: %s\n", error_message); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - if (png_ptr) - { -# ifdef USE_FAR_KEYWORD - { - jmp_buf jmpbuf; - png_memcpy(jmpbuf,png_ptr->jmpbuf,png_sizeof(jmp_buf)); - longjmp(jmpbuf, 1); - } -# else - longjmp(png_ptr->jmpbuf, 1); -# endif - } -#else - PNG_ABORT(); -#endif -#ifdef PNG_NO_CONSOLE_IO - /* make compiler happy */ ; - if (&error_message != NULL) - return; -#endif -} - -/* This function is called when there is a warning, but the library thinks - * it can continue anyway. Replacement functions don't have to do anything - * here if you don't want them to. In the default configuration, png_ptr is - * not used, but it is passed in case it may be useful. - */ -static void /* PRIVATE */ -png_default_warning(png_structp png_ptr, png_const_charp warning_message) -{ -#ifndef PNG_NO_CONSOLE_IO -# ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*warning_message == '#') - { - int offset; - char warning_number[16]; - for (offset=0; offset<15; offset++) - { - warning_number[offset]=*(warning_message+offset+1); - if (*(warning_message+offset) == ' ') - break; - } - if((offset > 1) && (offset < 15)) - { - warning_number[offset-1]='\0'; - fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, - warning_message+offset); - } - else - fprintf(stderr, "libpng warning: %s\n", warning_message); - } - else -# endif - fprintf(stderr, "libpng warning: %s\n", warning_message); -#else - /* make compiler happy */ ; - if (warning_message) - return; -#endif - /* make compiler happy */ ; - if (png_ptr) - return; -} - -/* This function is called when the application wants to use another method - * of handling errors and warnings. Note that the error function MUST NOT - * return to the calling routine or serious problems will occur. The return - * method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) - */ -void PNGAPI -png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warning_fn) -{ - if (png_ptr == NULL) - return; - png_ptr->error_ptr = error_ptr; - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; -} - - -/* This function returns a pointer to the error_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy and png_read_destroy are called. - */ -png_voidp PNGAPI -png_get_error_ptr(png_structp png_ptr) -{ - if (png_ptr == NULL) - return NULL; - return ((png_voidp)png_ptr->error_ptr); -} - - -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -void PNGAPI -png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) -{ - if(png_ptr != NULL) - { - png_ptr->flags &= - ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); - } -} -#endif -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ + +/* pngerror.c - stub functions for i/o and memory allocation + * + * Last changed in libpng 1.2.13 November 13, 2006 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This file provides a location for all error handling. Users who + * need special error handling are expected to write replacement functions + * and use png_set_error_fn() to use those functions. See the instructions + * at each function. + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +static void /* PRIVATE */ +png_default_error PNGARG((png_structp png_ptr, + png_const_charp error_message)); +static void /* PRIVATE */ +png_default_warning PNGARG((png_structp png_ptr, + png_const_charp warning_message)); + +/* This function is called whenever there is a fatal error. This function + * should not be changed. If there is a need to handle errors differently, + * you should supply a replacement error function and use png_set_error_fn() + * to replace the error function at run-time. + */ +void PNGAPI +png_error(png_structp png_ptr, png_const_charp error_message) +{ +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + char msg[16]; + if (png_ptr != NULL) + { + if (png_ptr->flags& + (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) + { + if (*error_message == '#') + { + int offset; + for (offset=1; offset<15; offset++) + if (*(error_message+offset) == ' ') + break; + if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) + { + int i; + for (i=0; iflags&PNG_FLAG_STRIP_ERROR_TEXT) + { + msg[0]='0'; + msg[1]='\0'; + error_message=msg; + } + } + } + } +#endif + if (png_ptr != NULL && png_ptr->error_fn != NULL) + (*(png_ptr->error_fn))(png_ptr, error_message); + + /* If the custom handler doesn't exist, or if it returns, + use the default handler, which will not return. */ + png_default_error(png_ptr, error_message); +} + +/* This function is called whenever there is a non-fatal error. This function + * should not be changed. If there is a need to handle warnings differently, + * you should supply a replacement warning function and use + * png_set_error_fn() to replace the warning function at run-time. + */ +void PNGAPI +png_warning(png_structp png_ptr, png_const_charp warning_message) +{ + int offset = 0; + if (png_ptr != NULL) + { +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + if (png_ptr->flags& + (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) +#endif + { + if (*warning_message == '#') + { + for (offset=1; offset<15; offset++) + if (*(warning_message+offset) == ' ') + break; + } + } + if (png_ptr != NULL && png_ptr->warning_fn != NULL) + (*(png_ptr->warning_fn))(png_ptr, warning_message+offset); + } + else + png_default_warning(png_ptr, warning_message+offset); +} + +/* These utilities are used internally to build an error message that relates + * to the current chunk. The chunk name comes from png_ptr->chunk_name, + * this is used to prefix the message. The message is limited in length + * to 63 bytes, the name characters are output as hex digits wrapped in [] + * if the character is invalid. + */ +#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) +static PNG_CONST char png_digit[16] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F' +}; + +static void /* PRIVATE */ +png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp + error_message) +{ + int iout = 0, iin = 0; + + while (iin < 4) + { + int c = png_ptr->chunk_name[iin++]; + if (isnonalpha(c)) + { + buffer[iout++] = '['; + buffer[iout++] = png_digit[(c & 0xf0) >> 4]; + buffer[iout++] = png_digit[c & 0x0f]; + buffer[iout++] = ']'; + } + else + { + buffer[iout++] = (png_byte)c; + } + } + + if (error_message == NULL) + buffer[iout] = 0; + else + { + buffer[iout++] = ':'; + buffer[iout++] = ' '; + png_strncpy(buffer+iout, error_message, 63); + buffer[iout+63] = 0; + } +} + +void PNGAPI +png_chunk_error(png_structp png_ptr, png_const_charp error_message) +{ + char msg[18+64]; + if (png_ptr == NULL) + png_error(png_ptr, error_message); + else + { + png_format_buffer(png_ptr, msg, error_message); + png_error(png_ptr, msg); + } +} + +void PNGAPI +png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) +{ + char msg[18+64]; + if (png_ptr == NULL) + png_warning(png_ptr, warning_message); + else + { + png_format_buffer(png_ptr, msg, warning_message); + png_warning(png_ptr, msg); + } +} + +/* This is the default error handling function. Note that replacements for + * this function MUST NOT RETURN, or the program will likely crash. This + * function is used by default, or if the program supplies NULL for the + * error function pointer in png_set_error_fn(). + */ +static void /* PRIVATE */ +png_default_error(png_structp png_ptr, png_const_charp error_message) +{ +#ifndef PNG_NO_CONSOLE_IO +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + if (*error_message == '#') + { + int offset; + char error_number[16]; + for (offset=0; offset<15; offset++) + { + error_number[offset] = *(error_message+offset+1); + if (*(error_message+offset) == ' ') + break; + } + if((offset > 1) && (offset < 15)) + { + error_number[offset-1]='\0'; + fprintf(stderr, "libpng error no. %s: %s\n", error_number, + error_message+offset); + } + else + fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); + } + else +#endif + fprintf(stderr, "libpng error: %s\n", error_message); +#endif + +#ifdef PNG_SETJMP_SUPPORTED + if (png_ptr) + { +# ifdef USE_FAR_KEYWORD + { + jmp_buf jmpbuf; + png_memcpy(jmpbuf,png_ptr->jmpbuf,png_sizeof(jmp_buf)); + longjmp(jmpbuf, 1); + } +# else + longjmp(png_ptr->jmpbuf, 1); +# endif + } +#else + PNG_ABORT(); +#endif +#ifdef PNG_NO_CONSOLE_IO + /* make compiler happy */ ; + if (&error_message != NULL) + return; +#endif +} + +/* This function is called when there is a warning, but the library thinks + * it can continue anyway. Replacement functions don't have to do anything + * here if you don't want them to. In the default configuration, png_ptr is + * not used, but it is passed in case it may be useful. + */ +static void /* PRIVATE */ +png_default_warning(png_structp png_ptr, png_const_charp warning_message) +{ +#ifndef PNG_NO_CONSOLE_IO +# ifdef PNG_ERROR_NUMBERS_SUPPORTED + if (*warning_message == '#') + { + int offset; + char warning_number[16]; + for (offset=0; offset<15; offset++) + { + warning_number[offset]=*(warning_message+offset+1); + if (*(warning_message+offset) == ' ') + break; + } + if((offset > 1) && (offset < 15)) + { + warning_number[offset-1]='\0'; + fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, + warning_message+offset); + } + else + fprintf(stderr, "libpng warning: %s\n", warning_message); + } + else +# endif + fprintf(stderr, "libpng warning: %s\n", warning_message); +#else + /* make compiler happy */ ; + if (warning_message) + return; +#endif + /* make compiler happy */ ; + if (png_ptr) + return; +} + +/* This function is called when the application wants to use another method + * of handling errors and warnings. Note that the error function MUST NOT + * return to the calling routine or serious problems will occur. The return + * method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) + */ +void PNGAPI +png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warning_fn) +{ + if (png_ptr == NULL) + return; + png_ptr->error_ptr = error_ptr; + png_ptr->error_fn = error_fn; + png_ptr->warning_fn = warning_fn; +} + + +/* This function returns a pointer to the error_ptr associated with the user + * functions. The application should free any memory associated with this + * pointer before png_write_destroy and png_read_destroy are called. + */ +png_voidp PNGAPI +png_get_error_ptr(png_structp png_ptr) +{ + if (png_ptr == NULL) + return NULL; + return ((png_voidp)png_ptr->error_ptr); +} + + +#ifdef PNG_ERROR_NUMBERS_SUPPORTED +void PNGAPI +png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) +{ + if(png_ptr != NULL) + { + png_ptr->flags &= + ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); + } +} +#endif +#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/pnggccrd.c b/src/dep/src/irrlicht/libpng/pnggccrd.c index 16d1971..7983f8e 100644 --- a/src/dep/src/irrlicht/libpng/pnggccrd.c +++ b/src/dep/src/irrlicht/libpng/pnggccrd.c @@ -1,5420 +1,5420 @@ - -/* pnggccrd.c - mixed C/assembler version of utilities to read a PNG file - * - * For Intel x86 CPU (Pentium-MMX or later) and GNU C compiler. - * - * See http://www.intel.com/drg/pentiumII/appnotes/916/916.htm - * and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm - * for Intel's performance analysis of the MMX vs. non-MMX code. - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * Copyright (c) 1998, Intel Corporation - * - * Based on MSVC code contributed by Nirav Chhatrapati, Intel Corp., 1998. - * Interface to libpng contributed by Gilles Vollant, 1999. - * GNU C port by Greg Roelofs, 1999-2001. - * - * Lines 2350-4300 converted in place with intel2gas 1.3.1: - * - * intel2gas -mdI pnggccrd.c.partially-msvc -o pnggccrd.c - * - * and then cleaned up by hand. See http://hermes.terminal.at/intel2gas/ . - * - * NOTE: A sufficiently recent version of GNU as (or as.exe under DOS/Windows) - * is required to assemble the newer MMX instructions such as movq. - * For djgpp, see - * - * ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bnu281b.zip - * - * (or a later version in the same directory). For Linux, check your - * distribution's web site(s) or try these links: - * - * http://rufus.w3.org/linux/RPM/binutils.html - * http://www.debian.org/Packages/stable/devel/binutils.html - * ftp://ftp.slackware.com/pub/linux/slackware/slackware/slakware/d1/ - * binutils.tgz - * - * For other platforms, see the main GNU site: - * - * ftp://ftp.gnu.org/pub/gnu/binutils/ - * - * Version 2.5.2l.15 is definitely too old... - */ - -/* - * TEMPORARY PORTING NOTES AND CHANGELOG (mostly by Greg Roelofs) - * ===================================== - * - * 19991006: - * - fixed sign error in post-MMX cleanup code (16- & 32-bit cases) - * - * 19991007: - * - additional optimizations (possible or definite): - * x [DONE] write MMX code for 64-bit case (pixel_bytes == 8) [not tested] - * - write MMX code for 48-bit case (pixel_bytes == 6) - * - figure out what's up with 24-bit case (pixel_bytes == 3): - * why subtract 8 from width_mmx in the pass 4/5 case? - * (only width_mmx case) (near line 1606) - * x [DONE] replace pixel_bytes within each block with the true - * constant value (or are compilers smart enough to do that?) - * - rewrite all MMX interlacing code so it's aligned with - * the *beginning* of the row buffer, not the end. This - * would not only allow one to eliminate half of the memory - * writes for odd passes (that is, pass == odd), it may also - * eliminate some unaligned-data-access exceptions (assuming - * there's a penalty for not aligning 64-bit accesses on - * 64-bit boundaries). The only catch is that the "leftover" - * pixel(s) at the end of the row would have to be saved, - * but there are enough unused MMX registers in every case, - * so this is not a problem. A further benefit is that the - * post-MMX cleanup code (C code) in at least some of the - * cases could be done within the assembler block. - * x [DONE] the "v3 v2 v1 v0 v7 v6 v5 v4" comments are confusing, - * inconsistent, and don't match the MMX Programmer's Reference - * Manual conventions anyway. They should be changed to - * "b7 b6 b5 b4 b3 b2 b1 b0," where b0 indicates the byte that - * was lowest in memory (e.g., corresponding to a left pixel) - * and b7 is the byte that was highest (e.g., a right pixel). - * - * 19991016: - * - Brennan's Guide notwithstanding, gcc under Linux does *not* - * want globals prefixed by underscores when referencing them-- - * i.e., if the variable is const4, then refer to it as const4, - * not _const4. This seems to be a djgpp-specific requirement. - * Also, such variables apparently *must* be declared outside - * of functions; neither static nor automatic variables work if - * defined within the scope of a single function, but both - * static and truly global (multi-module) variables work fine. - * - * 19991023: - * - fixed png_combine_row() non-MMX replication bug (odd passes only?) - * - switched from string-concatenation-with-macros to cleaner method of - * renaming global variables for djgpp--i.e., always use prefixes in - * inlined assembler code (== strings) and conditionally rename the - * variables, not the other way around. Hence _const4, _mask8_0, etc. - * - * 19991024: - * - fixed mmxsupport()/png_do_read_interlace() first-row bug - * This one was severely weird: even though mmxsupport() doesn't touch - * ebx (where "row" pointer was stored), it nevertheless managed to zero - * the register (even in static/non-fPIC code--see below), which in turn - * caused png_do_read_interlace() to return prematurely on the first row of - * interlaced images (i.e., without expanding the interlaced pixels). - * Inspection of the generated assembly code didn't turn up any clues, - * although it did point at a minor optimization (i.e., get rid of - * mmx_supported_local variable and just use eax). Possibly the CPUID - * instruction is more destructive than it looks? (Not yet checked.) - * - "info gcc" was next to useless, so compared fPIC and non-fPIC assembly - * listings... Apparently register spillage has to do with ebx, since - * it's used to index the global offset table. Commenting it out of the - * input-reg lists in png_combine_row() eliminated compiler barfage, so - * ifdef'd with __PIC__ macro: if defined, use a global for unmask - * - * 19991107: - * - verified CPUID clobberage: 12-char string constant ("GenuineIntel", - * "AuthenticAMD", etc.) placed in ebx:ecx:edx. Still need to polish. - * - * 19991120: - * - made "diff" variable (now "_dif") global to simplify conversion of - * filtering routines (running out of regs, sigh). "diff" is still used - * in interlacing routines, however. - * - fixed up both versions of mmxsupport() (ORIG_THAT_USED_TO_CLOBBER_EBX - * macro determines which is used); original not yet tested. - * - * 20000213: - * - when compiling with gcc, be sure to use -fomit-frame-pointer - * - * 20000319: - * - fixed a register-name typo in png_do_read_interlace(), default (MMX) case, - * pass == 4 or 5, that caused visible corruption of interlaced images - * - * 20000623: - * - Various problems were reported with gcc 2.95.2 in the Cygwin environment, - * many of the form "forbidden register 0 (ax) was spilled for class AREG." - * This is explained at http://gcc.gnu.org/fom_serv/cache/23.html, and - * Chuck Wilson supplied a patch involving dummy output registers. See - * http://sourceforge.net/bugs/?func=detailbug&bug_id=108741&group_id=5624 - * for the original (anonymous) SourceForge bug report. - * - * 20000706: - * - Chuck Wilson passed along these remaining gcc 2.95.2 errors: - * pnggccrd.c: In function `png_combine_row': - * pnggccrd.c:525: more than 10 operands in `asm' - * pnggccrd.c:669: more than 10 operands in `asm' - * pnggccrd.c:828: more than 10 operands in `asm' - * pnggccrd.c:994: more than 10 operands in `asm' - * pnggccrd.c:1177: more than 10 operands in `asm' - * They are all the same problem and can be worked around by using the - * global _unmask variable unconditionally, not just in the -fPIC case. - * Reportedly earlier versions of gcc also have the problem with more than - * 10 operands; they just don't report it. Much strangeness ensues, etc. - * - * 20000729: - * - enabled png_read_filter_row_mmx_up() (shortest remaining unconverted - * MMX routine); began converting png_read_filter_row_mmx_sub() - * - to finish remaining sections: - * - clean up indentation and comments - * - preload local variables - * - add output and input regs (order of former determines numerical - * mapping of latter) - * - avoid all usage of ebx (including bx, bh, bl) register [20000823] - * - remove "$" from addressing of Shift and Mask variables [20000823] - * - * 20000731: - * - global union vars causing segfaults in png_read_filter_row_mmx_sub()? - * - * 20000822: - * - ARGH, stupid png_read_filter_row_mmx_sub() segfault only happens with - * shared-library (-fPIC) version! Code works just fine as part of static - * library. Damn damn damn damn damn, should have tested that sooner. - * ebx is getting clobbered again (explicitly this time); need to save it - * on stack or rewrite asm code to avoid using it altogether. Blargh! - * - * 20000823: - * - first section was trickiest; all remaining sections have ebx -> edx now. - * (-fPIC works again.) Also added missing underscores to various Shift* - * and *Mask* globals and got rid of leading "$" signs. - * - * 20000826: - * - added visual separators to help navigate microscopic printed copies - * (http://pobox.com/~newt/code/gpr-latest.zip, mode 10); started working - * on png_read_filter_row_mmx_avg() - * - * 20000828: - * - finished png_read_filter_row_mmx_avg(): only Paeth left! (930 lines...) - * What the hell, did png_read_filter_row_mmx_paeth(), too. Comments not - * cleaned up/shortened in either routine, but functionality is complete - * and seems to be working fine. - * - * 20000829: - * - ahhh, figured out last(?) bit of gcc/gas asm-fu: if register is listed - * as an input reg (with dummy output variables, etc.), then it *cannot* - * also appear in the clobber list or gcc 2.95.2 will barf. The solution - * is simple enough... - * - * 20000914: - * - bug in png_read_filter_row_mmx_avg(): 16-bit grayscale not handled - * correctly (but 48-bit RGB just fine) - * - * 20000916: - * - fixed bug in png_read_filter_row_mmx_avg(), bpp == 2 case; three errors: - * - "_ShiftBpp.use = 24;" should have been "_ShiftBpp.use = 16;" - * - "_ShiftRem.use = 40;" should have been "_ShiftRem.use = 48;" - * - "psllq _ShiftRem, %%mm2" should have been "psrlq _ShiftRem, %%mm2" - * - * 20010101: - * - added new png_init_mmx_flags() function (here only because it needs to - * call mmxsupport(), which should probably become global png_mmxsupport()); - * modified other MMX routines to run conditionally (png_ptr->asm_flags) - * - * 20010103: - * - renamed mmxsupport() to png_mmx_support(), with auto-set of mmx_supported, - * and made it public; moved png_init_mmx_flags() to png.c as internal func - * - * 20010104: - * - removed dependency on png_read_filter_row_c() (C code already duplicated - * within MMX version of png_read_filter_row()) so no longer necessary to - * compile it into pngrutil.o - * - * 20010310: - * - fixed buffer-overrun bug in png_combine_row() C code (non-MMX) - * - * 20020304: - * - eliminated incorrect use of width_mmx in pixel_bytes == 8 case - * - * 20040724: - * - more tinkering with clobber list at lines 4529 and 5033, to get - * it to compile on gcc-3.4. - * - * STILL TO DO: - * - test png_do_read_interlace() 64-bit case (pixel_bytes == 8) - * - write MMX code for 48-bit case (pixel_bytes == 6) - * - figure out what's up with 24-bit case (pixel_bytes == 3): - * why subtract 8 from width_mmx in the pass 4/5 case? - * (only width_mmx case) (near line 1606) - * - rewrite all MMX interlacing code so it's aligned with beginning - * of the row buffer, not the end (see 19991007 for details) - * x pick one version of mmxsupport() and get rid of the other - * - add error messages to any remaining bogus default cases - * - enable pixel_depth == 8 cases in png_read_filter_row()? (test speed) - * x add support for runtime enable/disable/query of various MMX routines - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGGCCRD) - -int PNGAPI png_mmx_support(void); - -#ifdef PNG_USE_LOCAL_ARRAYS -static const int FARDATA png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; -static const int FARDATA png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -static const int FARDATA png_pass_width[7] = {8, 4, 4, 2, 2, 1, 1}; -#endif - -#if defined(PNG_MMX_CODE_SUPPORTED) -/* djgpp, Win32, Cygwin, and OS2 add their own underscores to global variables, - * so define them without: */ -#if defined(__DJGPP__) || defined(WIN32) || defined(__CYGWIN__) || \ - defined(__OS2__) -# define _mmx_supported mmx_supported -# define _const4 const4 -# define _const6 const6 -# define _mask8_0 mask8_0 -# define _mask16_1 mask16_1 -# define _mask16_0 mask16_0 -# define _mask24_2 mask24_2 -# define _mask24_1 mask24_1 -# define _mask24_0 mask24_0 -# define _mask32_3 mask32_3 -# define _mask32_2 mask32_2 -# define _mask32_1 mask32_1 -# define _mask32_0 mask32_0 -# define _mask48_5 mask48_5 -# define _mask48_4 mask48_4 -# define _mask48_3 mask48_3 -# define _mask48_2 mask48_2 -# define _mask48_1 mask48_1 -# define _mask48_0 mask48_0 -# define _LBCarryMask LBCarryMask -# define _HBClearMask HBClearMask -# define _ActiveMask ActiveMask -# define _ActiveMask2 ActiveMask2 -# define _ActiveMaskEnd ActiveMaskEnd -# define _ShiftBpp ShiftBpp -# define _ShiftRem ShiftRem -#ifdef PNG_THREAD_UNSAFE_OK -# define _unmask unmask -# define _FullLength FullLength -# define _MMXLength MMXLength -# define _dif dif -# define _patemp patemp -# define _pbtemp pbtemp -# define _pctemp pctemp -#endif -#endif - - -/* These constants are used in the inlined MMX assembly code. - Ignore gcc's "At top level: defined but not used" warnings. */ - -/* GRR 20000706: originally _unmask was needed only when compiling with -fPIC, - * since that case uses the %ebx register for indexing the Global Offset Table - * and there were no other registers available. But gcc 2.95 and later emit - * "more than 10 operands in `asm'" errors when %ebx is used to preload unmask - * in the non-PIC case, so we'll just use the global unconditionally now. - */ -#ifdef PNG_THREAD_UNSAFE_OK -static int _unmask; -#endif - -static unsigned long long _mask8_0 = 0x0102040810204080LL; - -static unsigned long long _mask16_1 = 0x0101020204040808LL; -static unsigned long long _mask16_0 = 0x1010202040408080LL; - -static unsigned long long _mask24_2 = 0x0101010202020404LL; -static unsigned long long _mask24_1 = 0x0408080810101020LL; -static unsigned long long _mask24_0 = 0x2020404040808080LL; - -static unsigned long long _mask32_3 = 0x0101010102020202LL; -static unsigned long long _mask32_2 = 0x0404040408080808LL; -static unsigned long long _mask32_1 = 0x1010101020202020LL; -static unsigned long long _mask32_0 = 0x4040404080808080LL; - -static unsigned long long _mask48_5 = 0x0101010101010202LL; -static unsigned long long _mask48_4 = 0x0202020204040404LL; -static unsigned long long _mask48_3 = 0x0404080808080808LL; -static unsigned long long _mask48_2 = 0x1010101010102020LL; -static unsigned long long _mask48_1 = 0x2020202040404040LL; -static unsigned long long _mask48_0 = 0x4040808080808080LL; - -static unsigned long long _const4 = 0x0000000000FFFFFFLL; -//static unsigned long long _const5 = 0x000000FFFFFF0000LL; // NOT USED -static unsigned long long _const6 = 0x00000000000000FFLL; - -// These are used in the row-filter routines and should/would be local -// variables if not for gcc addressing limitations. -// WARNING: Their presence probably defeats the thread safety of libpng. - -#ifdef PNG_THREAD_UNSAFE_OK -static png_uint_32 _FullLength; -static png_uint_32 _MMXLength; -static int _dif; -static int _patemp; // temp variables for Paeth routine -static int _pbtemp; -static int _pctemp; -#endif - -void /* PRIVATE */ -png_squelch_warnings(void) -{ -#ifdef PNG_THREAD_UNSAFE_OK - _dif = _dif; - _patemp = _patemp; - _pbtemp = _pbtemp; - _pctemp = _pctemp; - _MMXLength = _MMXLength; -#endif - _const4 = _const4; - _const6 = _const6; - _mask8_0 = _mask8_0; - _mask16_1 = _mask16_1; - _mask16_0 = _mask16_0; - _mask24_2 = _mask24_2; - _mask24_1 = _mask24_1; - _mask24_0 = _mask24_0; - _mask32_3 = _mask32_3; - _mask32_2 = _mask32_2; - _mask32_1 = _mask32_1; - _mask32_0 = _mask32_0; - _mask48_5 = _mask48_5; - _mask48_4 = _mask48_4; - _mask48_3 = _mask48_3; - _mask48_2 = _mask48_2; - _mask48_1 = _mask48_1; - _mask48_0 = _mask48_0; -} -#endif /* PNG_MMX_CODE_SUPPORTED */ - - -static int _mmx_supported = 2; - -/*===========================================================================*/ -/* */ -/* P N G _ C O M B I N E _ R O W */ -/* */ -/*===========================================================================*/ - -#if defined(PNG_HAVE_MMX_COMBINE_ROW) - -#define BPP2 2 -#define BPP3 3 /* bytes per pixel (a.k.a. pixel_bytes) */ -#define BPP4 4 -#define BPP6 6 /* (defined only to help avoid cut-and-paste errors) */ -#define BPP8 8 - -/* Combines the row recently read in with the previous row. - This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined; a - zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. - If you want all pixels to be combined, pass 0xff (255) in mask. */ - -/* Use this routine for the x86 platform - it uses a faster MMX routine - if the machine supports MMX. */ - -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ - png_debug(1, "in png_combine_row (pnggccrd.c)\n"); - -#if defined(PNG_MMX_CODE_SUPPORTED) - if (_mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } -#endif - - if (mask == 0xff) - { - png_debug(2,"mask == 0xff: doing single png_memcpy()\n"); - png_memcpy(row, png_ptr->row_buf + 1, - (png_size_t)PNG_ROWBYTES(png_ptr->row_info.pixel_depth,png_ptr->width)); - } - else /* (png_combine_row() is never called with mask == 0) */ - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_inc, s_start, s_end; - int m; - int shift; - png_uint_32 i; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x1; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 2: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x3; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 4: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 8: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask8_0, %%mm0 \n\t" - "pand %%mm7, %%mm0 \n\t" // nonzero if keep byte - "pcmpeqb %%mm6, %%mm0 \n\t" // zeros->1s, v versa - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" // len == 0 ? - "je mainloop8end \n\t" - - "mainloop8: \n\t" - "movq (%%esi), %%mm4 \n\t" // *srcptr - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "pandn (%%edi), %%mm6 \n\t" // *dstptr - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - "addl $8, %%esi \n\t" // inc by 8 bytes processed - "addl $8, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop8 \n\t" - - "mainloop8end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end8 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop8: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip8 \n\t" // if CF = 0 - "movb (%%esi), %%al \n\t" - "movb %%al, (%%edi) \n\t" - - "skip8: \n\t" - "incl %%esi \n\t" - "incl %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop8 \n\t" - - "end8: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm4", "%mm6", "%mm7" // clobber list -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff /* *BPP1 */ ; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - - } /* end of else (_mmx_supported) */ - - break; - } /* end 8 bpp */ - - case 16: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask16_0, %%mm0 \n\t" - "movq _mask16_1, %%mm1 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop16end \n\t" - - "mainloop16: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "addl $16, %%esi \n\t" // inc by 16 bytes processed - "addl $16, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop16 \n\t" - - "mainloop16end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end16 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop16: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip16 \n\t" // if CF = 0 - "movw (%%esi), %%ax \n\t" - "movw %%ax, (%%edi) \n\t" - - "skip16: \n\t" - "addl $2, %%esi \n\t" - "addl $2, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop16 \n\t" - - "end16: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=c" (dummy_value_c), - "=d" (dummy_value_d), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (diff), // eax // input regs -// was (unmask) " " RESERVED // ebx // Global Offset Table idx - "1" (len), // ecx - "2" (mask), // edx - "3" (srcptr), // esi - "4" (dstptr) // edi - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm4" // clobber list - , "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP2 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP2 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP2 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP2 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP2; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 16 bpp */ - - case 24: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask24_0, %%mm0 \n\t" - "movq _mask24_1, %%mm1 \n\t" - "movq _mask24_2, %%mm2 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop24end \n\t" - - "mainloop24: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm4 \n\t" - "movq 16(%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm4 \n\t" - "por %%mm4, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "addl $24, %%esi \n\t" // inc by 24 bytes processed - "addl $24, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - - "ja mainloop24 \n\t" - - "mainloop24end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end24 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop24: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip24 \n\t" // if CF = 0 - "movw (%%esi), %%ax \n\t" - "movw %%ax, (%%edi) \n\t" - "xorl %%eax, %%eax \n\t" - "movb 2(%%esi), %%al \n\t" - "movb %%al, 2(%%edi) \n\t" - - "skip24: \n\t" - "addl $3, %%esi \n\t" - "addl $3, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop24 \n\t" - - "end24: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP3 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP3 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP3 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP3 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP3; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 24 bpp */ - - case 32: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask32_0, %%mm0 \n\t" - "movq _mask32_1, %%mm1 \n\t" - "movq _mask32_2, %%mm2 \n\t" - "movq _mask32_3, %%mm3 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - "pand %%mm7, %%mm3 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - "pcmpeqb %%mm6, %%mm3 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" // lcr - "jz mainloop32end \n\t" - - "mainloop32: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm4 \n\t" - "movq 16(%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm4 \n\t" - "por %%mm4, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "movq 24(%%esi), %%mm7 \n\t" - "pand %%mm3, %%mm7 \n\t" - "movq %%mm3, %%mm5 \n\t" - "movq 24(%%edi), %%mm4 \n\t" - "pandn %%mm4, %%mm5 \n\t" - "por %%mm5, %%mm7 \n\t" - "movq %%mm7, 24(%%edi) \n\t" - - "addl $32, %%esi \n\t" // inc by 32 bytes processed - "addl $32, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop32 \n\t" - - "mainloop32end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end32 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // low byte => high byte - - "secondloop32: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip32 \n\t" // if CF = 0 - "movl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - - "skip32: \n\t" - "addl $4, %%esi \n\t" - "addl $4, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop32 \n\t" - - "end32: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2", "%mm3" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP4 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP4 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP4 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP4 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP4; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 32 bpp */ - - case 48: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask48_0, %%mm0 \n\t" - "movq _mask48_1, %%mm1 \n\t" - "movq _mask48_2, %%mm2 \n\t" - "movq _mask48_3, %%mm3 \n\t" - "movq _mask48_4, %%mm4 \n\t" - "movq _mask48_5, %%mm5 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pand %%mm7, %%mm4 \n\t" - "pand %%mm7, %%mm5 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - "pcmpeqb %%mm6, %%mm3 \n\t" - "pcmpeqb %%mm6, %%mm4 \n\t" - "pcmpeqb %%mm6, %%mm5 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop48end \n\t" - - "mainloop48: \n\t" - "movq (%%esi), %%mm7 \n\t" - "pand %%mm0, %%mm7 \n\t" - "movq %%mm0, %%mm6 \n\t" - "pandn (%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, (%%edi) \n\t" - - "movq 8(%%esi), %%mm6 \n\t" - "pand %%mm1, %%mm6 \n\t" - "movq %%mm1, %%mm7 \n\t" - "pandn 8(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm7 \n\t" - "pandn 16(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "movq 24(%%esi), %%mm7 \n\t" - "pand %%mm3, %%mm7 \n\t" - "movq %%mm3, %%mm6 \n\t" - "pandn 24(%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, 24(%%edi) \n\t" - - "movq 32(%%esi), %%mm6 \n\t" - "pand %%mm4, %%mm6 \n\t" - "movq %%mm4, %%mm7 \n\t" - "pandn 32(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 32(%%edi) \n\t" - - "movq 40(%%esi), %%mm7 \n\t" - "pand %%mm5, %%mm7 \n\t" - "movq %%mm5, %%mm6 \n\t" - "pandn 40(%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, 40(%%edi) \n\t" - - "addl $48, %%esi \n\t" // inc by 48 bytes processed - "addl $48, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - - "ja mainloop48 \n\t" - - "mainloop48end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end48 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop48: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip48 \n\t" // if CF = 0 - "movl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - - "skip48: \n\t" - "addl $4, %%esi \n\t" - "addl $4, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop48 \n\t" - - "end48: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2", "%mm3" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP6 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP6 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP6 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP6 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP6; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 48 bpp */ - - case 64: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - register png_uint_32 i; - png_uint_32 initial_val = BPP8 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP8 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP8 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP8 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP8; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - - break; - } /* end 64 bpp */ - - default: /* png_ptr->row_info.pixel_depth != 1,2,4,8,16,24,32,48,64 */ - { - /* this should never happen */ - png_warning(png_ptr, "Invalid row_info.pixel_depth in pnggccrd"); - break; - } - } /* end switch (png_ptr->row_info.pixel_depth) */ - - } /* end if (non-trivial mask) */ - -} /* end png_combine_row() */ - -#endif /* PNG_HAVE_MMX_COMBINE_ROW */ - - - - -/*===========================================================================*/ -/* */ -/* P N G _ D O _ R E A D _ I N T E R L A C E */ -/* */ -/*===========================================================================*/ - -#if defined(PNG_READ_INTERLACING_SUPPORTED) -#if defined(PNG_HAVE_MMX_READ_INTERLACE) - -/* png_do_read_interlace() is called after any 16-bit to 8-bit conversion - * has taken place. [GRR: what other steps come before and/or after?] - */ - -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - png_uint_32 transformations = png_ptr->transformations; -#endif - - png_debug(1, "in png_do_read_interlace (pnggccrd.c)\n"); - -#if defined(PNG_MMX_CODE_SUPPORTED) - if (_mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } -#endif - - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_byte v; - png_uint_32 i; - int j; - - sp = row + (png_size_t)((row_info->width - 1) >> 3); - dp = row + (png_size_t)((final_width - 1) >> 3); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 7); - dshift = (int)((final_width + 7) & 7); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 7); - dshift = 7 - (int)((final_width + 7) & 7); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = row_info->width; i; i--) - { - v = (png_byte)((*sp >> sshift) & 0x1); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 2: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 2); - dp = row + (png_size_t)((final_width - 1) >> 2); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); - dshift = (png_size_t)(((final_width + 3) & 3) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); - dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 4: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 1); - dp = row + (png_size_t)((final_width - 1) >> 1); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); - dshift = (png_size_t)(((final_width + 1) & 1) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); - dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0xf); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - /*====================================================================*/ - - default: /* 8-bit or larger (this is where the routine is modified) */ - { -#if 0 -// static unsigned long long _const4 = 0x0000000000FFFFFFLL; no good -// static unsigned long long const4 = 0x0000000000FFFFFFLL; no good -// unsigned long long _const4 = 0x0000000000FFFFFFLL; no good -// unsigned long long const4 = 0x0000000000FFFFFFLL; no good -#endif - png_bytep sptr, dp; - png_uint_32 i; - png_size_t pixel_bytes; - int width = (int)row_info->width; - - pixel_bytes = (row_info->pixel_depth >> 3); - - /* point sptr at the last pixel in the pre-expanded row: */ - sptr = row + (width - 1) * pixel_bytes; - - /* point dp at the last pixel position in the expanded row: */ - dp = row + (final_width - 1) * pixel_bytes; - - /* New code by Nirav Chhatrapati - Intel Corporation */ - -#if defined(PNG_MMX_CODE_SUPPORTED) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - //-------------------------------------------------------------- - if (pixel_bytes == 3) - { - if (((pass == 0) || (pass == 1)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - int dummy_value_a; - - __asm__ __volatile__ ( - "subl $21, %%edi \n\t" - // (png_pass_inc[pass] - 1)*pixel_bytes - - ".loop3_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x x 2 1 0 - "pand (%3), %%mm0 \n\t" // z z z z z 2 1 0 - "movq %%mm0, %%mm1 \n\t" // z z z z z 2 1 0 - "psllq $16, %%mm0 \n\t" // z z z 2 1 0 z z - "movq %%mm0, %%mm2 \n\t" // z z z 2 1 0 z z - "psllq $24, %%mm0 \n\t" // 2 1 0 z z z z z - "psrlq $8, %%mm1 \n\t" // z z z z z z 2 1 - "por %%mm2, %%mm0 \n\t" // 2 1 0 2 1 0 z z - "por %%mm1, %%mm0 \n\t" // 2 1 0 2 1 0 2 1 - "movq %%mm0, %%mm3 \n\t" // 2 1 0 2 1 0 2 1 - "psllq $16, %%mm0 \n\t" // 0 2 1 0 2 1 z z - "movq %%mm3, %%mm4 \n\t" // 2 1 0 2 1 0 2 1 - "punpckhdq %%mm0, %%mm3 \n\t" // 0 2 1 0 2 1 0 2 - "movq %%mm4, 16(%%edi) \n\t" - "psrlq $32, %%mm0 \n\t" // z z z z 0 2 1 0 - "movq %%mm3, 8(%%edi) \n\t" - "punpckldq %%mm4, %%mm0 \n\t" // 1 0 2 1 0 2 1 0 - "subl $3, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $24, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop3_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D), - "=a" (dummy_value_a) - - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width), // ecx - "3" (&_const4) // %1(?) (0x0000000000FFFFFFLL) - -#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm3", "%mm4" -#endif - ); - } - else if (((pass == 2) || (pass == 3)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - int dummy_value_a; - - __asm__ __volatile__ ( - "subl $9, %%edi \n\t" - // (png_pass_inc[pass] - 1)*pixel_bytes - - ".loop3_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x x 2 1 0 - "pand (%3), %%mm0 \n\t" // z z z z z 2 1 0 - "movq %%mm0, %%mm1 \n\t" // z z z z z 2 1 0 - "psllq $16, %%mm0 \n\t" // z z z 2 1 0 z z - "movq %%mm0, %%mm2 \n\t" // z z z 2 1 0 z z - "psllq $24, %%mm0 \n\t" // 2 1 0 z z z z z - "psrlq $8, %%mm1 \n\t" // z z z z z z 2 1 - "por %%mm2, %%mm0 \n\t" // 2 1 0 2 1 0 z z - "por %%mm1, %%mm0 \n\t" // 2 1 0 2 1 0 2 1 - "movq %%mm0, 4(%%edi) \n\t" - "psrlq $16, %%mm0 \n\t" // z z 2 1 0 2 1 0 - "subl $3, %%esi \n\t" - "movd %%mm0, (%%edi) \n\t" - "subl $12, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop3_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D), - "=a" (dummy_value_a) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width), // ecx - "3" (&_const4) // (0x0000000000FFFFFFLL) - -#if 0 /* %mm0, ..., %mm2 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list -#endif - ); - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 1) << 1) - 8; // GRR: huh? - if (width_mmx < 0) - width_mmx = 0; - width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes - if (width_mmx) - { - // png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - // sptr points at last pixel in pre-expanded row - // dp points at last pixel position in expanded row - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - int dummy_value_a; - int dummy_value_d; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $9, %%edi \n\t" - // (png_pass_inc[pass] + 1)*pixel_bytes - - ".loop3_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // x x 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // x x 5 4 3 2 1 0 - "movq %%mm0, %%mm2 \n\t" // x x 5 4 3 2 1 0 - "psllq $24, %%mm0 \n\t" // 4 3 2 1 0 z z z - "pand (%3), %%mm1 \n\t" // z z z z z 2 1 0 - "psrlq $24, %%mm2 \n\t" // z z z x x 5 4 3 - "por %%mm1, %%mm0 \n\t" // 4 3 2 1 0 2 1 0 - "movq %%mm2, %%mm3 \n\t" // z z z x x 5 4 3 - "psllq $8, %%mm2 \n\t" // z z x x 5 4 3 z - "movq %%mm0, (%%edi) \n\t" - "psrlq $16, %%mm3 \n\t" // z z z z z x x 5 - "pand (%4), %%mm3 \n\t" // z z z z z z z 5 - "por %%mm3, %%mm2 \n\t" // z z x x 5 4 3 5 - "subl $6, %%esi \n\t" - "movd %%mm2, 8(%%edi) \n\t" - "subl $12, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop3_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D), - "=a" (dummy_value_a), - "=d" (dummy_value_d) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx), // ecx - "3" (&_const4), // 0x0000000000FFFFFFLL - "4" (&_const6) // 0x00000000000000FFLL - -#if 0 /* %mm0, ..., %mm3 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list - , "%mm2", "%mm3" -#endif - ); - } - - sptr -= width_mmx*3; - dp -= width_mmx*6; - for (i = width; i; i--) - { - png_byte v[8]; - int j; - - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - } /* end of pixel_bytes == 3 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 1) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $31, %%edi \n\t" - - ".loop1_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // x x x x 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "movq %%mm0, %%mm2 \n\t" // 3 3 2 2 1 1 0 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 1 1 1 1 0 0 0 0 - "movq %%mm0, %%mm3 \n\t" // 1 1 1 1 0 0 0 0 - "punpckldq %%mm0, %%mm0 \n\t" // 0 0 0 0 0 0 0 0 - "punpckhdq %%mm3, %%mm3 \n\t" // 1 1 1 1 1 1 1 1 - "movq %%mm0, (%%edi) \n\t" - "punpckhwd %%mm2, %%mm2 \n\t" // 3 3 3 3 2 2 2 2 - "movq %%mm3, 8(%%edi) \n\t" - "movq %%mm2, %%mm4 \n\t" // 3 3 3 3 2 2 2 2 - "punpckldq %%mm2, %%mm2 \n\t" // 2 2 2 2 2 2 2 2 - "punpckhdq %%mm4, %%mm4 \n\t" // 3 3 3 3 3 3 3 3 - "movq %%mm2, 16(%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm4, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "subl $4, %%ecx \n\t" - "jnz .loop1_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm3", "%mm4" -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*8; - for (i = width; i; i--) - { - int j; - - /* I simplified this part in version 1.0.4e - * here and in several other instances where - * pixel_bytes == 1 -- GR-P - * - * Original code: - * - * png_byte v[8]; - * png_memcpy(v, sptr, pixel_bytes); - * for (j = 0; j < png_pass_inc[pass]; j++) - * { - * png_memcpy(dp, v, pixel_bytes); - * dp -= pixel_bytes; - * } - * sptr -= pixel_bytes; - * - * Replacement code is in the next three lines: - */ - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $15, %%edi \n\t" - - ".loop1_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "movq %%mm0, %%mm1 \n\t" // 3 3 2 2 1 1 0 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 1 1 1 1 0 0 0 0 - "punpckhwd %%mm1, %%mm1 \n\t" // 3 3 3 3 2 2 2 2 - "movq %%mm0, (%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $4, %%ecx \n\t" - "jnz .loop1_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*4; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 3) << 3); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $7, %%esi \n\t" - "subl $15, %%edi \n\t" - - ".loop1_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "punpckhbw %%mm1, %%mm1 \n\t" // 7 7 6 6 5 5 4 4 - "movq %%mm1, 8(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $8, %%ecx \n\t" - "jnz .loop1_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (none) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*2; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - } /* end of pixel_bytes == 1 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 2) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $30, %%edi \n\t" - - ".loop2_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "movq %%mm0, %%mm1 \n\t" // 3 2 3 2 1 0 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 1 0 1 0 1 0 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 3 2 3 2 3 2 3 2 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm1, 16(%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*16 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $14, %%edi \n\t" - - ".loop2_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "movq %%mm0, %%mm1 \n\t" // 3 2 3 2 1 0 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 1 0 1 0 1 0 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 3 2 3 2 3 2 3 2 - "movq %%mm0, (%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*8 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $6, %%edi \n\t" - - ".loop2_pass4: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "subl $4, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*4 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - } /* end of pixel_bytes == 2 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 4) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $60, %%edi \n\t" - - ".loop4_pass0: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "movq %%mm1, 32(%%edi) \n\t" - "movq %%mm1, 40(%%edi) \n\t" - "movq %%mm1, 48(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm1, 56(%%edi) \n\t" - "subl $64, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*32 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $28, %%edi \n\t" - - ".loop4_pass2: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm1, 16(%%edi) \n\t" - "movq %%mm1, 24(%%edi) \n\t" - "subl $8, %%esi \n\t" - "subl $32, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*16 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $12, %%edi \n\t" - - ".loop4_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*8 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - } /* end of pixel_bytes == 4 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 8) - { -// GRR TEST: should work, but needs testing (special 64-bit version of rpng2?) - // GRR NOTE: no need to combine passes here! - if (((pass == 0) || (pass == 1)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - // source is 8-byte RRGGBBAA - // dest is 64-byte RRGGBBAA RRGGBBAA RRGGBBAA RRGGBBAA ... - __asm__ __volatile__ ( - "subl $56, %%edi \n\t" // start of last block - - ".loop8_pass0: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "movq %%mm0, 32(%%edi) \n\t" - "movq %%mm0, 40(%%edi) \n\t" - "movq %%mm0, 48(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 56(%%edi) \n\t" - "subl $64, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - else if (((pass == 2) || (pass == 3)) && width) - { - // source is 8-byte RRGGBBAA - // dest is 32-byte RRGGBBAA RRGGBBAA RRGGBBAA RRGGBBAA - // (recall that expansion is _in place_: sptr and dp - // both point at locations within same row buffer) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $24, %%edi \n\t" // start of last block - - ".loop8_pass2: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - } - else if (width) // pass == 4 or 5 - { - // source is 8-byte RRGGBBAA - // dest is 16-byte RRGGBBAA RRGGBBAA - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $8, %%edi \n\t" // start of last block - - ".loop8_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - } - - } /* end of pixel_bytes == 8 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } /* end of pixel_bytes == 6 */ - - //-------------------------------------------------------------- - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr-= pixel_bytes; - } - } - } // end of _mmx_supported ======================================== - - else /* MMX not supported: use modified C code - takes advantage - * of inlining of png_memcpy for a constant */ - /* GRR 19991007: does it? or should pixel_bytes in each - * block be replaced with immediate value (e.g., 1)? */ - /* GRR 19991017: replaced with constants in each case */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - if (pixel_bytes == 1) - { - for (i = width; i; i--) - { - int j; - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (pixel_bytes == 3) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - else if (pixel_bytes == 2) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 2); - dp -= 2; - } - sptr -= 2; - } - } - else if (pixel_bytes == 4) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { -#ifdef PNG_DEBUG - if (dp < row || dp+3 > row+png_ptr->row_buf_size) - { - printf("dp out of bounds: row=%d, dp=%d, rp=%d\n", - row, dp, row+png_ptr->row_buf_size); - printf("row_buf=%d\n",png_ptr->row_buf_size); - } -#endif - png_memcpy(dp, v, 4); - dp -= 4; - } - sptr -= 4; - } - } - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } - else if (pixel_bytes == 8) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 8); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 8); - dp -= 8; - } - sptr -= 8; - } - } - else /* GRR: should never be reached */ - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - - } /* end if (MMX not supported) */ - break; - } - } /* end switch (row_info->pixel_depth) */ - - row_info->width = final_width; - - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); - } - -} /* end png_do_read_interlace() */ - -#endif /* PNG_HAVE_MMX_READ_INTERLACE */ -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - - - -#if defined(PNG_HAVE_MMX_READ_FILTER_ROW) -#if defined(PNG_MMX_CODE_SUPPORTED) - -// These variables are utilized in the functions below. They are declared -// globally here to ensure alignment on 8-byte boundaries. - -union uAll { - long long use; - double align; -} _LBCarryMask = {0x0101010101010101LL}, - _HBClearMask = {0x7f7f7f7f7f7f7f7fLL}, - _ActiveMask, _ActiveMask2, _ActiveMaskEnd, _ShiftBpp, _ShiftRem; - -#ifdef PNG_THREAD_UNSAFE_OK -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ A V G // -// // -//===========================================================================// - -// Optimized code for PNG Average filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - int bpp; - int dummy_value_c; // fix 'forbidden register 2 (cx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // get # bytes per pixel - _FullLength = row_info->rowbytes; // # of bytes to filter - - __asm__ __volatile__ ( - // initialize address pointers and offset -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif -//pre "movl row, %%edi \n\t" // edi: Avg(x) - "xorl %%ebx, %%ebx \n\t" // ebx: x - "movl %%edi, %%edx \n\t" -//pre "movl prev_row, %%esi \n\t" // esi: Prior(x) -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - - "xorl %%eax,%%eax \n\t" - - // Compute the Raw value for the first bpp bytes - // Raw(x) = Avg(x) + (Prior(x)/2) - "avg_rlp: \n\t" - "movb (%%esi,%%ebx,),%%al \n\t" // load al with Prior(x) - "incl %%ebx \n\t" - "shrb %%al \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,),%%al \n\t" // add Avg(x); -1 to offset inc ebx -//pre "cmpl bpp, %%ebx \n\t" // (bpp is preloaded into ecx) - "cmpl %%ecx, %%ebx \n\t" - "movb %%al,-1(%%edi,%%ebx,) \n\t" // write Raw(x); -1 to offset inc ebx - "jb avg_rlp \n\t" // mov does not affect flags - - // get # of bytes to alignment - "movl %%edi, _dif \n\t" // take start of row - "addl %%ebx, _dif \n\t" // add bpp - "addl $0xf, _dif \n\t" // add 7+8 to incr past alignment bdry - "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary - "subl %%edi, _dif \n\t" // subtract from start => value ebx at - "jz avg_go \n\t" // alignment - - // fix alignment - // Compute the Raw value for the bytes up to the alignment boundary - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%ecx, %%ecx \n\t" - - "avg_lp1: \n\t" - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset inc ebx - "cmpl _dif, %%ebx \n\t" // check if at alignment boundary - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write Raw(x); -1 to offset inc ebx - "jb avg_lp1 \n\t" // repeat until at alignment boundary - - "avg_go: \n\t" - "movl _FullLength, %%eax \n\t" - "movl %%eax, %%ecx \n\t" - "subl %%ebx, %%eax \n\t" // subtract alignment fix - "andl $0x00000007, %%eax \n\t" // calc bytes over mult of 8 - "subl %%eax, %%ecx \n\t" // drop over bytes from original length - "movl %%ecx, _MMXLength \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - // GRR: INCLUDE "memory" as clobbered? (_dif, _MMXLength) - // (seems to work fine without...) - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000000000ffffffLL; - _ShiftBpp.use = 24; // == 3 * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( - // re-init address pointers and offset - "movq _ActiveMask, %%mm7 \n\t" - "movl _dif, %%ecx \n\t" // ecx: x = offset to - "movq _LBCarryMask, %%mm5 \n\t" // alignment boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (correct pos. in loop below) - "avg_3lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" // load mm0 with Avg(x) - "movq %%mm5, %%mm3 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // correct position Raw(x-bpp) - // data - "movq (%%esi,%%ecx,), %%mm1 \n\t" // load mm1 with Prior(x) - "movq %%mm7, %%mm6 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - // add 1st active group (Raw(x-bpp)/2) to average with LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 1 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 3-5 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - - // add 3rd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift mm6 mask to cover last - // two - // bytes - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "addl $8, %%ecx \n\t" - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // move updated Raw(x) to use as Raw(x-bpp) for next loop - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm0, %%mm2 \n\t" // mov updated Raw(x) to mm2 - "jb avg_3lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 3 bpp - - case 6: - case 4: - //case 7: // who wrote this? PNG doesn't support 5 or 7 bytes/pixel - //case 5: // GRR BOGUS - { - _ActiveMask.use = 0xffffffffffffffffLL; // use shift below to clear - // appropriate inactive bytes - _ShiftBpp.use = bpp << 3; - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( - "movq _HBClearMask, %%mm4 \n\t" - - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x = offset to - // alignment boundary - - // load _ActiveMask and clear all bytes except for 1st active group - "movq _ActiveMask, %%mm7 \n\t" -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "psrlq _ShiftRem, %%mm7 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movq %%mm7, %%mm6 \n\t" - "movq _LBCarryMask, %%mm5 \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // create mask for 2nd active - // group - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (we correct pos. in loop below) - "avg_4lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // shift data to pos. correctly - "movq (%%esi,%%ecx,), %%mm1 \n\t" - // add (Prev_row/2) to average - "movq %%mm5, %%mm3 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - // add 1st active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm7, %%mm2 \n\t" // leave only Active Group 1 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg - // for each Active - // byte - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "addl $8, %%ecx \n\t" - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - "cmpl _MMXLength, %%ecx \n\t" - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // prep Raw(x-bpp) for next loop - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "jb avg_4lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 4,6 bpp - - case 2: - { - _ActiveMask.use = 0x000000000000ffffLL; - _ShiftBpp.use = 16; // == 2 * 8 - _ShiftRem.use = 48; // == 64 - 16 - - __asm__ __volatile__ ( - // load _ActiveMask - "movq _ActiveMask, %%mm7 \n\t" - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x = offset to alignment - // boundary - "movq _LBCarryMask, %%mm5 \n\t" -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (we correct pos. in loop below) - "avg_2lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // shift data to pos. correctly - "movq (%%esi,%%ecx,), %%mm1 \n\t" // (GRR BUGFIX: was psllq) - // add (Prev_row/2) to average - "movq %%mm5, %%mm3 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "movq %%mm7, %%mm6 \n\t" - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - - // add 1st active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid - // for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 1 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg - // for each Active byte - - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 2 & 3 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid - // for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active byte - - // add 3rd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 4 & 5 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both lsb's were == 1 - // (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active byte - - // add 4th active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 6 & 7 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "addl $8, %%ecx \n\t" - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid - // for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active byte - - "cmpl _MMXLength, %%ecx \n\t" - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // prep Raw(x-bpp) for next loop - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "jb avg_2lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 2 bpp - - case 1: - { - __asm__ __volatile__ ( - // re-init address pointers and offset -#ifdef __PIC__ - "pushl %%ebx \n\t" // save Global Offset Table index -#endif - "movl _dif, %%ebx \n\t" // ebx: x = offset to alignment - // boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "cmpl _FullLength, %%ebx \n\t" // test if offset at end of array - "jnb avg_1end \n\t" - // do Paeth decode for remaining bytes -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movl %%edi, %%edx \n\t" -// preload "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx - // in loop below - "avg_1lp: \n\t" - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset - // inc ebx - "cmpl _FullLength, %%ebx \n\t" // check if at end of array - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - "jb avg_1lp \n\t" - - "avg_1end: \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // Global Offset Table index -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - } - return; // end 1 bpp - - case 8: - { - __asm__ __volatile__ ( - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x == offset to alignment - "movq _LBCarryMask, %%mm5 \n\t" // boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (NO NEED to correct pos. in loop below) - - "avg_8lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "movq %%mm5, %%mm3 \n\t" - "movq (%%esi,%%ecx,), %%mm1 \n\t" - "addl $8, %%ecx \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm2, %%mm3 \n\t" // get LBCarrys for each byte - // where both lsb's were == 1 - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7, each byte - "paddb %%mm3, %%mm0 \n\t" // add LBCarrys to Avg, each byte - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7, each byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg, each - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) to Avg for each - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - "movq %%mm0, %%mm2 \n\t" // reuse as Raw(x-bpp) - "jb avg_8lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm5 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2" - , "%mm3", "%mm4", "%mm5" -#endif - ); - } - break; // end 8 bpp - - default: // bpp greater than 8 (!= 1,2,3,4,[5],6,[7],8) - { - -#ifdef PNG_DEBUG - // GRR: PRINT ERROR HERE: SHOULD NEVER BE REACHED - png_debug(1, - "Internal logic error in pnggccrd (png_read_filter_row_mmx_avg())\n"); -#endif - -#if 0 - __asm__ __volatile__ ( - "movq _LBCarryMask, %%mm5 \n\t" - // re-init address pointers and offset - "movl _dif, %%ebx \n\t" // ebx: x = offset to - // alignment boundary - "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" - "movl %%edi, %%edx \n\t" - "movl prev_row, %%esi \n\t" // esi: Prior(x) - "subl bpp, %%edx \n\t" // edx: Raw(x-bpp) - "avg_Alp: \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "movq %%mm5, %%mm3 \n\t" - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "movq (%%edx,%%ebx,), %%mm2 \n\t" - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm2, %%mm3 \n\t" // get LBCarrys for each byte - // where both lsb's were == 1 - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm3, %%mm0 \n\t" // add LBCarrys to Avg for each - // byte - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - "addl $8, %%ebx \n\t" - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) to Avg for each - // byte - "cmpl _MMXLength, %%ebx \n\t" - "movq %%mm0, -8(%%edi,%%ebx,) \n\t" - "jb avg_Alp \n\t" - - : // FIXASM: output regs/vars go here, e.g.: "=m" (memory_var) - - : // FIXASM: input regs, e.g.: "c" (count), "S" (src), "D" (dest) - - : "%ebx", "%edx", "%edi", "%esi" // CHECKASM: clobber list - ); -#endif /* 0 - NEVER REACHED */ - } - break; - - } // end switch (bpp) - - __asm__ __volatile__ ( - // MMX acceleration complete; now do clean-up - // check if any remaining bytes left to decode -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "movl _MMXLength, %%ebx \n\t" // ebx: x == offset bytes after MMX -//pre "movl row, %%edi \n\t" // edi: Avg(x) - "cmpl _FullLength, %%ebx \n\t" // test if offset at end of array - "jnb avg_end \n\t" - - // do Avg decode for remaining bytes -//pre "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movl %%edi, %%edx \n\t" -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx below - - "avg_lp2: \n\t" - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset inc ebx - "cmpl _FullLength, %%ebx \n\t" // check if at end of array - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write back Raw(x) [mov does not - "jb avg_lp2 \n\t" // affect flags; -1 to offset inc ebx] - - "avg_end: \n\t" - "EMMS \n\t" // end MMX; prep for poss. FP instrs. -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - -} /* end png_read_filter_row_mmx_avg() */ -#endif - - - -#ifdef PNG_THREAD_UNSAFE_OK -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ P A E T H // -// // -//===========================================================================// - -// Optimized code for PNG Paeth filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - int bpp; - int dummy_value_c; // fix 'forbidden register 2 (cx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - _FullLength = row_info->rowbytes; // # of bytes to filter - - __asm__ __volatile__ ( -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "xorl %%ebx, %%ebx \n\t" // ebx: x offset -//pre "movl row, %%edi \n\t" - "xorl %%edx, %%edx \n\t" // edx: x-bpp offset -//pre "movl prev_row, %%esi \n\t" - "xorl %%eax, %%eax \n\t" - - // Compute the Raw value for the first bpp bytes - // Note: the formula works out to be always - // Paeth(x) = Raw(x) + Prior(x) where x < bpp - "paeth_rlp: \n\t" - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" -//pre "cmpl bpp, %%ebx \n\t" (bpp is preloaded into ecx) - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" - "jb paeth_rlp \n\t" - // get # of bytes to alignment - "movl %%edi, _dif \n\t" // take start of row - "addl %%ebx, _dif \n\t" // add bpp - "xorl %%ecx, %%ecx \n\t" - "addl $0xf, _dif \n\t" // add 7 + 8 to incr past alignment - // boundary - "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary - "subl %%edi, _dif \n\t" // subtract from start ==> value ebx - // at alignment - "jz paeth_go \n\t" - // fix alignment - - "paeth_lp1: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_pca \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_pca: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_pba \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_pba: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_paa \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_paa: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_abb \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_bbc \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth \n\t" - - "paeth_bbc: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_paeth \n\t" - - "paeth_abb: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_abc \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth \n\t" - - "paeth_abc: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_paeth: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _dif, %%ebx \n\t" - "jb paeth_lp1 \n\t" - - "paeth_go: \n\t" - "movl _FullLength, %%ecx \n\t" - "movl %%ecx, %%eax \n\t" - "subl %%ebx, %%eax \n\t" // subtract alignment fix - "andl $0x00000007, %%eax \n\t" // calc bytes over mult of 8 - "subl %%eax, %%ecx \n\t" // drop over bytes from original length - "movl %%ecx, _MMXLength \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000000000ffffffLL; - _ActiveMaskEnd.use = 0xffff000000000000LL; - _ShiftBpp.use = 24; // == bpp(3) * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "paeth_3lp: \n\t" - "psrlq _ShiftRem, %%mm1 \n\t" // shift last 3 bytes to 1st - // 3 bytes - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // prep c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "psrlq _ShiftRem, %%mm3 \n\t" // shift last 3 bytes to 1st - // 3 bytes - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "movq %%mm3, %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" // now mm1 will be used as - // Raw(x-bpp) - // now do Paeth for 2nd set of bytes (3-5) - "psrlq _ShiftBpp, %%mm2 \n\t" // load b=Prior(x) step 2 - "punpcklbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "pxor %%mm7, %%mm7 \n\t" - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "psubw %%mm3, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = - // pav + pbv = pbv + pav - "movq %%mm5, %%mm6 \n\t" - "paddw %%mm4, %%mm6 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm5, %%mm0 \n\t" // create mask pbv bytes < 0 - "pcmpgtw %%mm4, %%mm7 \n\t" // create mask pav bytes < 0 - "pand %%mm5, %%mm0 \n\t" // only pbv bytes < 0 in mm0 - "pand %%mm4, %%mm7 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm5 \n\t" - "psubw %%mm7, %%mm4 \n\t" - "psubw %%mm0, %%mm5 \n\t" - "psubw %%mm7, %%mm4 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq %%mm2, %%mm3 \n\t" // load c=Prior(x-bpp) step 1 - "pand _ActiveMask, %%mm7 \n\t" - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "psllq _ShiftBpp, %%mm7 \n\t" // shift bytes to 2nd group of - // 3 bytes - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "psllq _ShiftBpp, %%mm3 \n\t" // load c=Prior(x-bpp) step 2 - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "psllq _ShiftBpp, %%mm1 \n\t" // shift bytes - // now mm1 will be used as Raw(x-bpp) - // now do Paeth for 3rd, and final, set of bytes (6-7) - "pxor %%mm7, %%mm7 \n\t" - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "psubw %%mm3, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "paddw %%mm5, %%mm6 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "packuswb %%mm7, %%mm1 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "pand _ActiveMaskEnd, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with - // Raw(x) - - "cmpl _MMXLength, %%ecx \n\t" - "pxor %%mm0, %%mm0 \n\t" // pxor does not affect flags - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - // mm3 ready to be used as Prior(x-bpp) next loop - "jb paeth_3lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 3 bpp - - case 6: - //case 7: // GRR BOGUS - //case 5: // GRR BOGUS - { - _ActiveMask.use = 0x00000000ffffffffLL; - _ActiveMask2.use = 0xffffffff00000000LL; - _ShiftBpp.use = bpp << 3; // == bpp * 8 - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "pxor %%mm0, %%mm0 \n\t" - - "paeth_6lp: \n\t" - // must shift to position Raw(x-bpp) data - "psrlq _ShiftRem, %%mm1 \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - // must shift to position Prior(x-bpp) data - "psrlq _ShiftRem, %%mm3 \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "psrlq _ShiftRem, %%mm3 \n\t" - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor and Raw(x) - "movq %%mm2, %%mm6 \n\t" - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" - "movq %%mm7, %%mm5 \n\t" - "psrlq _ShiftRem, %%mm1 \n\t" - "por %%mm6, %%mm3 \n\t" - "psllq _ShiftBpp, %%mm5 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "por %%mm5, %%mm1 \n\t" - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_6lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 6 bpp - - case 4: - { - _ActiveMask.use = 0x00000000ffffffffLL; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // only time should need to read - // a=Raw(x-bpp) bytes - "paeth_4lp: \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpckhbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "movq %%mm3, %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" // now mm1 will be used as Raw(x-bpp) - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_4lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 4 bpp - - case 8: // bpp == 8 - { - _ActiveMask.use = 0x00000000ffffffffLL; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // only time should need to read - // a=Raw(x-bpp) bytes - "paeth_8lp: \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "pand _ActiveMask, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // read a=Raw(x-bpp) bytes - - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_8lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 8 bpp - - case 1: // bpp = 1 - case 2: // bpp = 2 - default: // bpp > 8 - { - __asm__ __volatile__ ( -#ifdef __PIC__ - "pushl %%ebx \n\t" // save Global Offset Table index -#endif - "movl _dif, %%ebx \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jnb paeth_dend \n\t" - -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - // do Paeth decode for remaining bytes - "movl %%ebx, %%edx \n\t" -// preload "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx = ebx - bpp - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx - - "paeth_dlp: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_dpca \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_dpca: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_dpba \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_dpba: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_dpaa \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_dpaa: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_dabb \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_dbbc \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dbbc: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dabb: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_dabc \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dabc: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_dpaeth: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jb paeth_dlp \n\t" - - "paeth_dend: \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - } - return; // No need to go further with this one - - } // end switch (bpp) - - __asm__ __volatile__ ( - // MMX acceleration complete; now do clean-up - // check if any remaining bytes left to decode -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "movl _MMXLength, %%ebx \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jnb paeth_end \n\t" -//pre "movl row, %%edi \n\t" -//pre "movl prev_row, %%esi \n\t" - // do Paeth decode for remaining bytes - "movl %%ebx, %%edx \n\t" -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx = ebx - bpp - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx below - - "paeth_lp2: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_pca2 \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_pca2: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_pba2 \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_pba2: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_paa2 \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_paa2: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_abb2 \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_bbc2 \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_bbc2: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_abb2: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_abc2 \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_abc2: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_paeth2: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jb paeth_lp2 \n\t" - - "paeth_end: \n\t" - "EMMS \n\t" // end MMX; prep for poss. FP instrs. -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list (no input regs!) -#ifndef __PIC__ - , "%ebx" -#endif - ); - -} /* end png_read_filter_row_mmx_paeth() */ -#endif - - - - -#ifdef PNG_THREAD_UNSAFE_OK -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ S U B // -// // -//===========================================================================// - -// Optimized code for PNG Sub filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) -{ - int bpp; - int dummy_value_a; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // calc number of bytes per pixel - _FullLength = row_info->rowbytes - bpp; // number of bytes to filter - - __asm__ __volatile__ ( -//pre "movl row, %%edi \n\t" - "movl %%edi, %%esi \n\t" // lp = row -//pre "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp -//irr "xorl %%eax, %%eax \n\t" - // get # of bytes to alignment - "movl %%edi, _dif \n\t" // take start of row - "addl $0xf, _dif \n\t" // add 7 + 8 to incr past - // alignment boundary - "xorl %%ecx, %%ecx \n\t" - "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary - "subl %%edi, _dif \n\t" // subtract from start ==> value - "jz sub_go \n\t" // ecx at alignment - - "sub_lp1: \n\t" // fix alignment - "movb (%%esi,%%ecx,), %%al \n\t" - "addb %%al, (%%edi,%%ecx,) \n\t" - "incl %%ecx \n\t" - "cmpl _dif, %%ecx \n\t" - "jb sub_lp1 \n\t" - - "sub_go: \n\t" - "movl _FullLength, %%eax \n\t" - "movl %%eax, %%edx \n\t" - "subl %%ecx, %%edx \n\t" // subtract alignment fix - "andl $0x00000007, %%edx \n\t" // calc bytes over mult of 8 - "subl %%edx, %%eax \n\t" // drop over bytes from length - "movl %%eax, _MMXLength \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%esi", "%ecx", "%edx" // clobber list - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000ffffff000000LL; - _ShiftBpp.use = 24; // == 3 * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movq _ActiveMask, %%mm7 \n\t" // load _ActiveMask for 2nd - // active byte group - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "movq %%mm7, %%mm6 \n\t" - "movl _dif, %%edx \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // move mask in mm6 to cover - // 3rd active byte group - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_3lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - // add 1st active group - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm7, %%mm1 \n\t" // mask to use 2nd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 3rd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm6, %%mm1 \n\t" // mask to use 3rd active group - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // write updated Raws to array - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_3lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm6", "%mm7" -#endif - ); - } - break; - - case 1: - { - __asm__ __volatile__ ( - "movl _dif, %%edx \n\t" -// preload "movl row, %%edi \n\t" - "cmpl _FullLength, %%edx \n\t" - "jnb sub_1end \n\t" - "movl %%edi, %%esi \n\t" // lp = row - "xorl %%eax, %%eax \n\t" -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - "sub_1lp: \n\t" - "movb (%%esi,%%edx,), %%al \n\t" - "addb %%al, (%%edi,%%edx,) \n\t" - "incl %%edx \n\t" - "cmpl _FullLength, %%edx \n\t" - "jb sub_1lp \n\t" - - "sub_1end: \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list - ); - } - return; - - case 6: - case 4: - //case 7: // GRR BOGUS - //case 5: // GRR BOGUS - { - _ShiftBpp.use = bpp << 3; - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movl _dif, %%edx \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_4lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_4lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1" -#endif - ); - } - break; - - case 2: - { - _ActiveMask.use = 0x00000000ffff0000LL; - _ShiftBpp.use = 16; // == 2 * 8 - _ShiftRem.use = 48; // == 64 - 16 - - __asm__ __volatile__ ( - "movq _ActiveMask, %%mm7 \n\t" // load _ActiveMask for 2nd - // active byte group - "movl _dif, %%edx \n\t" - "movq %%mm7, %%mm6 \n\t" -// preload "movl row, %%edi \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // move mask in mm6 to cover - // 3rd active byte group - "movl %%edi, %%esi \n\t" // lp = row - "movq %%mm6, %%mm5 \n\t" -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "psllq _ShiftBpp, %%mm5 \n\t" // move mask in mm5 to cover - // 4th active byte group - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_2lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - // add 1st active group - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm7, %%mm1 \n\t" // mask to use 2nd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 3rd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm6, %%mm1 \n\t" // mask to use 3rd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 4th active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm5, %%mm1 \n\t" // mask to use 4th active group - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // write updated Raws to array - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_2lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; - - case 8: - { - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movl _dif, %%edx \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "movl _MMXLength, %%ecx \n\t" - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm7 \n\t" - "andl $0x0000003f, %%ecx \n\t" // calc bytes over mult of 64 - - "sub_8lp: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" // load Sub(x) for 1st 8 bytes - "paddb %%mm7, %%mm0 \n\t" - "movq 8(%%edi,%%edx,), %%mm1 \n\t" // load Sub(x) for 2nd 8 bytes - "movq %%mm0, (%%edi,%%edx,) \n\t" // write Raw(x) for 1st 8 bytes - - // Now mm0 will be used as Raw(x-bpp) for the 2nd group of 8 bytes. - // This will be repeated for each group of 8 bytes with the 8th - // group being used as the Raw(x-bpp) for the 1st group of the - // next loop. - - "paddb %%mm0, %%mm1 \n\t" - "movq 16(%%edi,%%edx,), %%mm2 \n\t" // load Sub(x) for 3rd 8 bytes - "movq %%mm1, 8(%%edi,%%edx,) \n\t" // write Raw(x) for 2nd 8 bytes - "paddb %%mm1, %%mm2 \n\t" - "movq 24(%%edi,%%edx,), %%mm3 \n\t" // load Sub(x) for 4th 8 bytes - "movq %%mm2, 16(%%edi,%%edx,) \n\t" // write Raw(x) for 3rd 8 bytes - "paddb %%mm2, %%mm3 \n\t" - "movq 32(%%edi,%%edx,), %%mm4 \n\t" // load Sub(x) for 5th 8 bytes - "movq %%mm3, 24(%%edi,%%edx,) \n\t" // write Raw(x) for 4th 8 bytes - "paddb %%mm3, %%mm4 \n\t" - "movq 40(%%edi,%%edx,), %%mm5 \n\t" // load Sub(x) for 6th 8 bytes - "movq %%mm4, 32(%%edi,%%edx,) \n\t" // write Raw(x) for 5th 8 bytes - "paddb %%mm4, %%mm5 \n\t" - "movq 48(%%edi,%%edx,), %%mm6 \n\t" // load Sub(x) for 7th 8 bytes - "movq %%mm5, 40(%%edi,%%edx,) \n\t" // write Raw(x) for 6th 8 bytes - "paddb %%mm5, %%mm6 \n\t" - "movq 56(%%edi,%%edx,), %%mm7 \n\t" // load Sub(x) for 8th 8 bytes - "movq %%mm6, 48(%%edi,%%edx,) \n\t" // write Raw(x) for 7th 8 bytes - "addl $64, %%edx \n\t" - "paddb %%mm6, %%mm7 \n\t" - "cmpl %%ecx, %%edx \n\t" - "movq %%mm7, -8(%%edi,%%edx,) \n\t" // write Raw(x) for 8th 8 bytes - "jb sub_8lp \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "jnb sub_8lt8 \n\t" - - "sub_8lpA: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" - "addl $8, %%edx \n\t" - "paddb %%mm7, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // -8 to offset early addl edx - "movq %%mm0, %%mm7 \n\t" // move calculated Raw(x) data - // to mm1 to be new Raw(x-bpp) - // for next loop - "jb sub_8lpA \n\t" - - "sub_8lt8: \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%ecx", "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; - - default: // bpp greater than 8 bytes GRR BOGUS - { - __asm__ __volatile__ ( - "movl _dif, %%edx \n\t" -// preload "movl row, %%edi \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - "sub_Alp: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" - "movq (%%esi,%%edx,), %%mm1 \n\t" - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // mov does not affect flags; - // -8 to offset addl edx - "jb sub_Alp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1" -#endif - ); - } - break; - - } // end switch (bpp) - - __asm__ __volatile__ ( - "movl _MMXLength, %%edx \n\t" -//pre "movl row, %%edi \n\t" - "cmpl _FullLength, %%edx \n\t" - "jnb sub_end \n\t" - - "movl %%edi, %%esi \n\t" // lp = row -//pre "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "xorl %%eax, %%eax \n\t" - - "sub_lp2: \n\t" - "movb (%%esi,%%edx,), %%al \n\t" - "addb %%al, (%%edi,%%edx,) \n\t" - "incl %%edx \n\t" - "cmpl _FullLength, %%edx \n\t" - "jb sub_lp2 \n\t" - - "sub_end: \n\t" - "EMMS \n\t" // end MMX instructions - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list - ); - -} // end of png_read_filter_row_mmx_sub() -#endif - - - - -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ U P // -// // -//===========================================================================// - -// Optimized code for PNG Up filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 len; - int dummy_value_d; // fix 'forbidden register 3 (dx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - len = row_info->rowbytes; // number of bytes to filter - - __asm__ __volatile__ ( -//pre "movl row, %%edi \n\t" - // get # of bytes to alignment -#ifdef __PIC__ - "pushl %%ebx \n\t" -#endif - "movl %%edi, %%ecx \n\t" - "xorl %%ebx, %%ebx \n\t" - "addl $0x7, %%ecx \n\t" - "xorl %%eax, %%eax \n\t" - "andl $0xfffffff8, %%ecx \n\t" -//pre "movl prev_row, %%esi \n\t" - "subl %%edi, %%ecx \n\t" - "jz up_go \n\t" - - "up_lp1: \n\t" // fix alignment - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" // mov does not affect flags; -1 to - "jb up_lp1 \n\t" // offset incl ebx - - "up_go: \n\t" -//pre "movl len, %%edx \n\t" - "movl %%edx, %%ecx \n\t" - "subl %%ebx, %%edx \n\t" // subtract alignment fix - "andl $0x0000003f, %%edx \n\t" // calc bytes over mult of 64 - "subl %%edx, %%ecx \n\t" // drop over bytes from length - - // unrolled loop - use all MMX registers and interleave to reduce - // number of branch instructions (loops) and reduce partial stalls - "up_loop: \n\t" - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "movq 8(%%esi,%%ebx,), %%mm3 \n\t" - "paddb %%mm1, %%mm0 \n\t" - "movq 8(%%edi,%%ebx,), %%mm2 \n\t" - "movq %%mm0, (%%edi,%%ebx,) \n\t" - "paddb %%mm3, %%mm2 \n\t" - "movq 16(%%esi,%%ebx,), %%mm5 \n\t" - "movq %%mm2, 8(%%edi,%%ebx,) \n\t" - "movq 16(%%edi,%%ebx,), %%mm4 \n\t" - "movq 24(%%esi,%%ebx,), %%mm7 \n\t" - "paddb %%mm5, %%mm4 \n\t" - "movq 24(%%edi,%%ebx,), %%mm6 \n\t" - "movq %%mm4, 16(%%edi,%%ebx,) \n\t" - "paddb %%mm7, %%mm6 \n\t" - "movq 32(%%esi,%%ebx,), %%mm1 \n\t" - "movq %%mm6, 24(%%edi,%%ebx,) \n\t" - "movq 32(%%edi,%%ebx,), %%mm0 \n\t" - "movq 40(%%esi,%%ebx,), %%mm3 \n\t" - "paddb %%mm1, %%mm0 \n\t" - "movq 40(%%edi,%%ebx,), %%mm2 \n\t" - "movq %%mm0, 32(%%edi,%%ebx,) \n\t" - "paddb %%mm3, %%mm2 \n\t" - "movq 48(%%esi,%%ebx,), %%mm5 \n\t" - "movq %%mm2, 40(%%edi,%%ebx,) \n\t" - "movq 48(%%edi,%%ebx,), %%mm4 \n\t" - "movq 56(%%esi,%%ebx,), %%mm7 \n\t" - "paddb %%mm5, %%mm4 \n\t" - "movq 56(%%edi,%%ebx,), %%mm6 \n\t" - "movq %%mm4, 48(%%edi,%%ebx,) \n\t" - "addl $64, %%ebx \n\t" - "paddb %%mm7, %%mm6 \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movq %%mm6, -8(%%edi,%%ebx,) \n\t" // (+56)movq does not affect flags; - "jb up_loop \n\t" // -8 to offset addl ebx - - "cmpl $0, %%edx \n\t" // test for bytes over mult of 64 - "jz up_end \n\t" - - "cmpl $8, %%edx \n\t" // test for less than 8 bytes - "jb up_lt8 \n\t" // [added by lcreeve at netins.net] - - "addl %%edx, %%ecx \n\t" - "andl $0x00000007, %%edx \n\t" // calc bytes over mult of 8 - "subl %%edx, %%ecx \n\t" // drop over bytes from length - "jz up_lt8 \n\t" - - "up_lpA: \n\t" // use MMX regs to update 8 bytes sim. - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "addl $8, %%ebx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movq %%mm0, -8(%%edi,%%ebx,) \n\t" // movq does not affect flags; -8 to - "jb up_lpA \n\t" // offset add ebx - "cmpl $0, %%edx \n\t" // test for bytes over mult of 8 - "jz up_end \n\t" - - "up_lt8: \n\t" - "xorl %%eax, %%eax \n\t" - "addl %%edx, %%ecx \n\t" // move over byte count into counter - - "up_lp2: \n\t" // use x86 regs for remaining bytes - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" // mov does not affect flags; -1 to - "jb up_lp2 \n\t" // offset inc ebx - - "up_end: \n\t" - "EMMS \n\t" // conversion of filtered row complete -#ifdef __PIC__ - "popl %%ebx \n\t" -#endif - - : "=d" (dummy_value_d), // 0 // output regs (dummy) - "=S" (dummy_value_S), // 1 - "=D" (dummy_value_D) // 2 - - : "0" (len), // edx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%ecx" // clobber list (no input regs!) -#ifndef __PIC__ - , "%ebx" -#endif - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - -} // end of png_read_filter_row_mmx_up() - -#endif /* PNG_MMX_CODE_SUPPORTED */ - - - - -/*===========================================================================*/ -/* */ -/* P N G _ R E A D _ F I L T E R _ R O W */ -/* */ -/*===========================================================================*/ - - -/* Optimized png_read_filter_row routines */ - -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep - row, png_bytep prev_row, int filter) -{ -#ifdef PNG_DEBUG - char filnm[10]; -#endif - -#if defined(PNG_MMX_CODE_SUPPORTED) -/* GRR: these are superseded by png_ptr->asm_flags: */ -#define UseMMX_sub 1 // GRR: converted 20000730 -#define UseMMX_up 1 // GRR: converted 20000729 -#define UseMMX_avg 1 // GRR: converted 20000828 (+ 16-bit bugfix 20000916) -#define UseMMX_paeth 1 // GRR: converted 20000828 - - if (_mmx_supported == 2) { - /* this should have happened in png_init_mmx_flags() already */ -#if !defined(PNG_1_0_X) - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } -#endif /* PNG_MMX_CODE_SUPPORTED */ - -#ifdef PNG_DEBUG - png_debug(1, "in png_read_filter_row (pnggccrd.c)\n"); - switch (filter) - { - case 0: sprintf(filnm, "none"); - break; - case 1: sprintf(filnm, "sub-%s", -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : -#endif -#endif -"x86"); - break; - case 2: sprintf(filnm, "up-%s", -#ifdef PNG_MMX_CODE_SUPPORTED -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : -#endif -#endif - "x86"); - break; - case 3: sprintf(filnm, "avg-%s", -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : -#endif -#endif - "x86"); - break; - case 4: sprintf(filnm, "Paeth-%s", -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX": -#endif -#endif -"x86"); - break; - default: sprintf(filnm, "unknw"); - break; - } - png_debug2(0, "row_number=%5ld, %5s, ", png_ptr->row_number, filnm); - png_debug1(0, "row=0x%08lx, ", (unsigned long)row); - png_debug2(0, "pixdepth=%2d, bytes=%d, ", (int)row_info->pixel_depth, - (int)((row_info->pixel_depth + 7) >> 3)); - png_debug1(0,"rowbytes=%8ld\n", row_info->rowbytes); -#endif /* PNG_DEBUG */ - - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - - case PNG_FILTER_VALUE_SUB: -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_sub(row_info, row); - } - else -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - } /* end !UseMMX_sub */ - break; - - case PNG_FILTER_VALUE_UP: -#if defined(PNG_MMX_CODE_SUPPORTED) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_up(row_info, row, prev_row); - } - else -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; ++i) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - } /* end !UseMMX_up */ - break; - - case PNG_FILTER_VALUE_AVG: -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_avg(row_info, row, prev_row); - } - else -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) >> 1)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++ + *lp++) >> 1)) & 0xff); - rp++; - } - } /* end !UseMMX_avg */ - break; - - case PNG_FILTER_VALUE_PAETH: -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_paeth(row_info, row, prev_row); - } - else -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) /* use leftover rp,pp */ - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - } /* end !UseMMX_paeth */ - break; - - default: - png_warning(png_ptr, "Ignoring bad row-filter type"); - *row=0; - break; - } -} - -#endif /* PNG_HAVE_MMX_READ_FILTER_ROW */ - - -/*===========================================================================*/ -/* */ -/* P N G _ M M X _ S U P P O R T */ -/* */ -/*===========================================================================*/ - -/* GRR NOTES: (1) the following code assumes 386 or better (pushfl/popfl) - * (2) all instructions compile with gcc 2.7.2.3 and later - * (3) the function is moved down here to prevent gcc from - * inlining it in multiple places and then barfing be- - * cause the ".NOT_SUPPORTED" label is multiply defined - * [is there a way to signal that a *single* function should - * not be inlined? is there a way to modify the label for - * each inlined instance, e.g., by appending _1, _2, etc.? - * maybe if don't use leading "." in label name? (nope...sigh)] - */ - -int PNGAPI -png_mmx_support(void) -{ -#if defined(PNG_MMX_CODE_SUPPORTED) - int result; - __asm__ __volatile__ ( - "pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction - "pushl %%ecx \n\t" // so does ecx... - "pushl %%edx \n\t" // ...and edx (but ecx & edx safe on Linux) -// ".byte 0x66 \n\t" // convert 16-bit pushf to 32-bit pushfd -// "pushf \n\t" // 16-bit pushf - "pushfl \n\t" // save Eflag to stack - "popl %%eax \n\t" // get Eflag from stack into eax - "movl %%eax, %%ecx \n\t" // make another copy of Eflag in ecx - "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) - "pushl %%eax \n\t" // save modified Eflag back to stack -// ".byte 0x66 \n\t" // convert 16-bit popf to 32-bit popfd -// "popf \n\t" // 16-bit popf - "popfl \n\t" // restore modified value to Eflag reg - "pushfl \n\t" // save Eflag to stack - "popl %%eax \n\t" // get Eflag from stack - "pushl %%ecx \n\t" // save original Eflag to stack - "popfl \n\t" // restore original Eflag - "xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag - "jz 0f \n\t" // if same, CPUID instr. is not supported - - "xorl %%eax, %%eax \n\t" // set eax to zero -// ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode) - "cpuid \n\t" // get the CPU identification info - "cmpl $1, %%eax \n\t" // make sure eax return non-zero value - "jl 0f \n\t" // if eax is zero, MMX is not supported - - "xorl %%eax, %%eax \n\t" // set eax to zero and... - "incl %%eax \n\t" // ...increment eax to 1. This pair is - // faster than the instruction "mov eax, 1" - "cpuid \n\t" // get the CPU identification info again - "andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23) - "cmpl $0, %%edx \n\t" // 0 = MMX not supported - "jz 0f \n\t" // non-zero = yes, MMX IS supported - - "movl $1, %%eax \n\t" // set return value to 1 - "jmp 1f \n\t" // DONE: have MMX support - - "0: \n\t" // .NOT_SUPPORTED: target label for jump instructions - "movl $0, %%eax \n\t" // set return value to 0 - "1: \n\t" // .RETURN: target label for jump instructions - "popl %%edx \n\t" // restore edx - "popl %%ecx \n\t" // restore ecx - "popl %%ebx \n\t" // restore ebx - -// "ret \n\t" // DONE: no MMX support - // (fall through to standard C "ret") - - : "=a" (result) // output list - - : // any variables used on input (none) - - // no clobber list -// , "%ebx", "%ecx", "%edx" // GRR: we handle these manually -// , "memory" // if write to a variable gcc thought was in a reg -// , "cc" // "condition codes" (flag bits) - ); - _mmx_supported = result; -#else - _mmx_supported = 0; -#endif /* PNG_MMX_CODE_SUPPORTED */ - - return _mmx_supported; -} - - -#endif /* PNG_USE_PNGGCCRD */ + +/* pnggccrd.c - mixed C/assembler version of utilities to read a PNG file + * + * For Intel x86 CPU (Pentium-MMX or later) and GNU C compiler. + * + * See http://www.intel.com/drg/pentiumII/appnotes/916/916.htm + * and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm + * for Intel's performance analysis of the MMX vs. non-MMX code. + * + * Last changed in libpng 1.2.15 January 5, 2007 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Copyright (c) 1998, Intel Corporation + * + * Based on MSVC code contributed by Nirav Chhatrapati, Intel Corp., 1998. + * Interface to libpng contributed by Gilles Vollant, 1999. + * GNU C port by Greg Roelofs, 1999-2001. + * + * Lines 2350-4300 converted in place with intel2gas 1.3.1: + * + * intel2gas -mdI pnggccrd.c.partially-msvc -o pnggccrd.c + * + * and then cleaned up by hand. See http://hermes.terminal.at/intel2gas/ . + * + * NOTE: A sufficiently recent version of GNU as (or as.exe under DOS/Windows) + * is required to assemble the newer MMX instructions such as movq. + * For djgpp, see + * + * ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bnu281b.zip + * + * (or a later version in the same directory). For Linux, check your + * distribution's web site(s) or try these links: + * + * http://rufus.w3.org/linux/RPM/binutils.html + * http://www.debian.org/Packages/stable/devel/binutils.html + * ftp://ftp.slackware.com/pub/linux/slackware/slackware/slakware/d1/ + * binutils.tgz + * + * For other platforms, see the main GNU site: + * + * ftp://ftp.gnu.org/pub/gnu/binutils/ + * + * Version 2.5.2l.15 is definitely too old... + */ + +/* + * TEMPORARY PORTING NOTES AND CHANGELOG (mostly by Greg Roelofs) + * ===================================== + * + * 19991006: + * - fixed sign error in post-MMX cleanup code (16- & 32-bit cases) + * + * 19991007: + * - additional optimizations (possible or definite): + * x [DONE] write MMX code for 64-bit case (pixel_bytes == 8) [not tested] + * - write MMX code for 48-bit case (pixel_bytes == 6) + * - figure out what's up with 24-bit case (pixel_bytes == 3): + * why subtract 8 from width_mmx in the pass 4/5 case? + * (only width_mmx case) (near line 1606) + * x [DONE] replace pixel_bytes within each block with the true + * constant value (or are compilers smart enough to do that?) + * - rewrite all MMX interlacing code so it's aligned with + * the *beginning* of the row buffer, not the end. This + * would not only allow one to eliminate half of the memory + * writes for odd passes (that is, pass == odd), it may also + * eliminate some unaligned-data-access exceptions (assuming + * there's a penalty for not aligning 64-bit accesses on + * 64-bit boundaries). The only catch is that the "leftover" + * pixel(s) at the end of the row would have to be saved, + * but there are enough unused MMX registers in every case, + * so this is not a problem. A further benefit is that the + * post-MMX cleanup code (C code) in at least some of the + * cases could be done within the assembler block. + * x [DONE] the "v3 v2 v1 v0 v7 v6 v5 v4" comments are confusing, + * inconsistent, and don't match the MMX Programmer's Reference + * Manual conventions anyway. They should be changed to + * "b7 b6 b5 b4 b3 b2 b1 b0," where b0 indicates the byte that + * was lowest in memory (e.g., corresponding to a left pixel) + * and b7 is the byte that was highest (e.g., a right pixel). + * + * 19991016: + * - Brennan's Guide notwithstanding, gcc under Linux does *not* + * want globals prefixed by underscores when referencing them-- + * i.e., if the variable is const4, then refer to it as const4, + * not _const4. This seems to be a djgpp-specific requirement. + * Also, such variables apparently *must* be declared outside + * of functions; neither static nor automatic variables work if + * defined within the scope of a single function, but both + * static and truly global (multi-module) variables work fine. + * + * 19991023: + * - fixed png_combine_row() non-MMX replication bug (odd passes only?) + * - switched from string-concatenation-with-macros to cleaner method of + * renaming global variables for djgpp--i.e., always use prefixes in + * inlined assembler code (== strings) and conditionally rename the + * variables, not the other way around. Hence _const4, _mask8_0, etc. + * + * 19991024: + * - fixed mmxsupport()/png_do_read_interlace() first-row bug + * This one was severely weird: even though mmxsupport() doesn't touch + * ebx (where "row" pointer was stored), it nevertheless managed to zero + * the register (even in static/non-fPIC code--see below), which in turn + * caused png_do_read_interlace() to return prematurely on the first row of + * interlaced images (i.e., without expanding the interlaced pixels). + * Inspection of the generated assembly code didn't turn up any clues, + * although it did point at a minor optimization (i.e., get rid of + * mmx_supported_local variable and just use eax). Possibly the CPUID + * instruction is more destructive than it looks? (Not yet checked.) + * - "info gcc" was next to useless, so compared fPIC and non-fPIC assembly + * listings... Apparently register spillage has to do with ebx, since + * it's used to index the global offset table. Commenting it out of the + * input-reg lists in png_combine_row() eliminated compiler barfage, so + * ifdef'd with __PIC__ macro: if defined, use a global for unmask + * + * 19991107: + * - verified CPUID clobberage: 12-char string constant ("GenuineIntel", + * "AuthenticAMD", etc.) placed in ebx:ecx:edx. Still need to polish. + * + * 19991120: + * - made "diff" variable (now "_dif") global to simplify conversion of + * filtering routines (running out of regs, sigh). "diff" is still used + * in interlacing routines, however. + * - fixed up both versions of mmxsupport() (ORIG_THAT_USED_TO_CLOBBER_EBX + * macro determines which is used); original not yet tested. + * + * 20000213: + * - when compiling with gcc, be sure to use -fomit-frame-pointer + * + * 20000319: + * - fixed a register-name typo in png_do_read_interlace(), default (MMX) case, + * pass == 4 or 5, that caused visible corruption of interlaced images + * + * 20000623: + * - Various problems were reported with gcc 2.95.2 in the Cygwin environment, + * many of the form "forbidden register 0 (ax) was spilled for class AREG." + * This is explained at http://gcc.gnu.org/fom_serv/cache/23.html, and + * Chuck Wilson supplied a patch involving dummy output registers. See + * http://sourceforge.net/bugs/?func=detailbug&bug_id=108741&group_id=5624 + * for the original (anonymous) SourceForge bug report. + * + * 20000706: + * - Chuck Wilson passed along these remaining gcc 2.95.2 errors: + * pnggccrd.c: In function `png_combine_row': + * pnggccrd.c:525: more than 10 operands in `asm' + * pnggccrd.c:669: more than 10 operands in `asm' + * pnggccrd.c:828: more than 10 operands in `asm' + * pnggccrd.c:994: more than 10 operands in `asm' + * pnggccrd.c:1177: more than 10 operands in `asm' + * They are all the same problem and can be worked around by using the + * global _unmask variable unconditionally, not just in the -fPIC case. + * Reportedly earlier versions of gcc also have the problem with more than + * 10 operands; they just don't report it. Much strangeness ensues, etc. + * + * 20000729: + * - enabled png_read_filter_row_mmx_up() (shortest remaining unconverted + * MMX routine); began converting png_read_filter_row_mmx_sub() + * - to finish remaining sections: + * - clean up indentation and comments + * - preload local variables + * - add output and input regs (order of former determines numerical + * mapping of latter) + * - avoid all usage of ebx (including bx, bh, bl) register [20000823] + * - remove "$" from addressing of Shift and Mask variables [20000823] + * + * 20000731: + * - global union vars causing segfaults in png_read_filter_row_mmx_sub()? + * + * 20000822: + * - ARGH, stupid png_read_filter_row_mmx_sub() segfault only happens with + * shared-library (-fPIC) version! Code works just fine as part of static + * library. Damn damn damn damn damn, should have tested that sooner. + * ebx is getting clobbered again (explicitly this time); need to save it + * on stack or rewrite asm code to avoid using it altogether. Blargh! + * + * 20000823: + * - first section was trickiest; all remaining sections have ebx -> edx now. + * (-fPIC works again.) Also added missing underscores to various Shift* + * and *Mask* globals and got rid of leading "$" signs. + * + * 20000826: + * - added visual separators to help navigate microscopic printed copies + * (http://pobox.com/~newt/code/gpr-latest.zip, mode 10); started working + * on png_read_filter_row_mmx_avg() + * + * 20000828: + * - finished png_read_filter_row_mmx_avg(): only Paeth left! (930 lines...) + * What the hell, did png_read_filter_row_mmx_paeth(), too. Comments not + * cleaned up/shortened in either routine, but functionality is complete + * and seems to be working fine. + * + * 20000829: + * - ahhh, figured out last(?) bit of gcc/gas asm-fu: if register is listed + * as an input reg (with dummy output variables, etc.), then it *cannot* + * also appear in the clobber list or gcc 2.95.2 will barf. The solution + * is simple enough... + * + * 20000914: + * - bug in png_read_filter_row_mmx_avg(): 16-bit grayscale not handled + * correctly (but 48-bit RGB just fine) + * + * 20000916: + * - fixed bug in png_read_filter_row_mmx_avg(), bpp == 2 case; three errors: + * - "_ShiftBpp.use = 24;" should have been "_ShiftBpp.use = 16;" + * - "_ShiftRem.use = 40;" should have been "_ShiftRem.use = 48;" + * - "psllq _ShiftRem, %%mm2" should have been "psrlq _ShiftRem, %%mm2" + * + * 20010101: + * - added new png_init_mmx_flags() function (here only because it needs to + * call mmxsupport(), which should probably become global png_mmxsupport()); + * modified other MMX routines to run conditionally (png_ptr->asm_flags) + * + * 20010103: + * - renamed mmxsupport() to png_mmx_support(), with auto-set of mmx_supported, + * and made it public; moved png_init_mmx_flags() to png.c as internal func + * + * 20010104: + * - removed dependency on png_read_filter_row_c() (C code already duplicated + * within MMX version of png_read_filter_row()) so no longer necessary to + * compile it into pngrutil.o + * + * 20010310: + * - fixed buffer-overrun bug in png_combine_row() C code (non-MMX) + * + * 20020304: + * - eliminated incorrect use of width_mmx in pixel_bytes == 8 case + * + * 20040724: + * - more tinkering with clobber list at lines 4529 and 5033, to get + * it to compile on gcc-3.4. + * + * STILL TO DO: + * - test png_do_read_interlace() 64-bit case (pixel_bytes == 8) + * - write MMX code for 48-bit case (pixel_bytes == 6) + * - figure out what's up with 24-bit case (pixel_bytes == 3): + * why subtract 8 from width_mmx in the pass 4/5 case? + * (only width_mmx case) (near line 1606) + * - rewrite all MMX interlacing code so it's aligned with beginning + * of the row buffer, not the end (see 19991007 for details) + * x pick one version of mmxsupport() and get rid of the other + * - add error messages to any remaining bogus default cases + * - enable pixel_depth == 8 cases in png_read_filter_row()? (test speed) + * x add support for runtime enable/disable/query of various MMX routines + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGGCCRD) + +int PNGAPI png_mmx_support(void); + +#ifdef PNG_USE_LOCAL_ARRAYS +static const int FARDATA png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; +static const int FARDATA png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +static const int FARDATA png_pass_width[7] = {8, 4, 4, 2, 2, 1, 1}; +#endif + +#if defined(PNG_MMX_CODE_SUPPORTED) +/* djgpp, Win32, Cygwin, and OS2 add their own underscores to global variables, + * so define them without: */ +#if defined(__DJGPP__) || defined(WIN32) || defined(__CYGWIN__) || \ + defined(__OS2__) +# define _mmx_supported mmx_supported +# define _const4 const4 +# define _const6 const6 +# define _mask8_0 mask8_0 +# define _mask16_1 mask16_1 +# define _mask16_0 mask16_0 +# define _mask24_2 mask24_2 +# define _mask24_1 mask24_1 +# define _mask24_0 mask24_0 +# define _mask32_3 mask32_3 +# define _mask32_2 mask32_2 +# define _mask32_1 mask32_1 +# define _mask32_0 mask32_0 +# define _mask48_5 mask48_5 +# define _mask48_4 mask48_4 +# define _mask48_3 mask48_3 +# define _mask48_2 mask48_2 +# define _mask48_1 mask48_1 +# define _mask48_0 mask48_0 +# define _LBCarryMask LBCarryMask +# define _HBClearMask HBClearMask +# define _ActiveMask ActiveMask +# define _ActiveMask2 ActiveMask2 +# define _ActiveMaskEnd ActiveMaskEnd +# define _ShiftBpp ShiftBpp +# define _ShiftRem ShiftRem +#ifdef PNG_THREAD_UNSAFE_OK +# define _unmask unmask +# define _FullLength FullLength +# define _MMXLength MMXLength +# define _dif dif +# define _patemp patemp +# define _pbtemp pbtemp +# define _pctemp pctemp +#endif +#endif + + +/* These constants are used in the inlined MMX assembly code. + Ignore gcc's "At top level: defined but not used" warnings. */ + +/* GRR 20000706: originally _unmask was needed only when compiling with -fPIC, + * since that case uses the %ebx register for indexing the Global Offset Table + * and there were no other registers available. But gcc 2.95 and later emit + * "more than 10 operands in `asm'" errors when %ebx is used to preload unmask + * in the non-PIC case, so we'll just use the global unconditionally now. + */ +#ifdef PNG_THREAD_UNSAFE_OK +static int _unmask; +#endif + +static unsigned long long _mask8_0 = 0x0102040810204080LL; + +static unsigned long long _mask16_1 = 0x0101020204040808LL; +static unsigned long long _mask16_0 = 0x1010202040408080LL; + +static unsigned long long _mask24_2 = 0x0101010202020404LL; +static unsigned long long _mask24_1 = 0x0408080810101020LL; +static unsigned long long _mask24_0 = 0x2020404040808080LL; + +static unsigned long long _mask32_3 = 0x0101010102020202LL; +static unsigned long long _mask32_2 = 0x0404040408080808LL; +static unsigned long long _mask32_1 = 0x1010101020202020LL; +static unsigned long long _mask32_0 = 0x4040404080808080LL; + +static unsigned long long _mask48_5 = 0x0101010101010202LL; +static unsigned long long _mask48_4 = 0x0202020204040404LL; +static unsigned long long _mask48_3 = 0x0404080808080808LL; +static unsigned long long _mask48_2 = 0x1010101010102020LL; +static unsigned long long _mask48_1 = 0x2020202040404040LL; +static unsigned long long _mask48_0 = 0x4040808080808080LL; + +static unsigned long long _const4 = 0x0000000000FFFFFFLL; +//static unsigned long long _const5 = 0x000000FFFFFF0000LL; // NOT USED +static unsigned long long _const6 = 0x00000000000000FFLL; + +// These are used in the row-filter routines and should/would be local +// variables if not for gcc addressing limitations. +// WARNING: Their presence probably defeats the thread safety of libpng. + +#ifdef PNG_THREAD_UNSAFE_OK +static png_uint_32 _FullLength; +static png_uint_32 _MMXLength; +static int _dif; +static int _patemp; // temp variables for Paeth routine +static int _pbtemp; +static int _pctemp; +#endif + +void /* PRIVATE */ +png_squelch_warnings(void) +{ +#ifdef PNG_THREAD_UNSAFE_OK + _dif = _dif; + _patemp = _patemp; + _pbtemp = _pbtemp; + _pctemp = _pctemp; + _MMXLength = _MMXLength; +#endif + _const4 = _const4; + _const6 = _const6; + _mask8_0 = _mask8_0; + _mask16_1 = _mask16_1; + _mask16_0 = _mask16_0; + _mask24_2 = _mask24_2; + _mask24_1 = _mask24_1; + _mask24_0 = _mask24_0; + _mask32_3 = _mask32_3; + _mask32_2 = _mask32_2; + _mask32_1 = _mask32_1; + _mask32_0 = _mask32_0; + _mask48_5 = _mask48_5; + _mask48_4 = _mask48_4; + _mask48_3 = _mask48_3; + _mask48_2 = _mask48_2; + _mask48_1 = _mask48_1; + _mask48_0 = _mask48_0; +} +#endif /* PNG_MMX_CODE_SUPPORTED */ + + +static int _mmx_supported = 2; + +/*===========================================================================*/ +/* */ +/* P N G _ C O M B I N E _ R O W */ +/* */ +/*===========================================================================*/ + +#if defined(PNG_HAVE_MMX_COMBINE_ROW) + +#define BPP2 2 +#define BPP3 3 /* bytes per pixel (a.k.a. pixel_bytes) */ +#define BPP4 4 +#define BPP6 6 /* (defined only to help avoid cut-and-paste errors) */ +#define BPP8 8 + +/* Combines the row recently read in with the previous row. + This routine takes care of alpha and transparency if requested. + This routine also handles the two methods of progressive display + of interlaced images, depending on the mask value. + The mask value describes which pixels are to be combined with + the row. The pattern always repeats every 8 pixels, so just 8 + bits are needed. A one indicates the pixel is to be combined; a + zero indicates the pixel is to be skipped. This is in addition + to any alpha or transparency value associated with the pixel. + If you want all pixels to be combined, pass 0xff (255) in mask. */ + +/* Use this routine for the x86 platform - it uses a faster MMX routine + if the machine supports MMX. */ + +void /* PRIVATE */ +png_combine_row(png_structp png_ptr, png_bytep row, int mask) +{ + png_debug(1, "in png_combine_row (pnggccrd.c)\n"); + +#if defined(PNG_MMX_CODE_SUPPORTED) + if (_mmx_supported == 2) { +#if !defined(PNG_1_0_X) + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); +#endif + png_mmx_support(); + } +#endif + + if (mask == 0xff) + { + png_debug(2,"mask == 0xff: doing single png_memcpy()\n"); + png_memcpy(row, png_ptr->row_buf + 1, + (png_size_t)PNG_ROWBYTES(png_ptr->row_info.pixel_depth,png_ptr->width)); + } + else /* (png_combine_row() is never called with mask == 0) */ + { + switch (png_ptr->row_info.pixel_depth) + { + case 1: /* png_ptr->row_info.pixel_depth */ + { + png_bytep sp; + png_bytep dp; + int s_inc, s_start, s_end; + int m; + int shift; + png_uint_32 i; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 7; + s_inc = 1; + } + else +#endif + { + s_start = 7; + s_end = 0; + s_inc = -1; + } + + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + int value; + + value = (*sp >> shift) & 0x1; + *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 2: /* png_ptr->row_info.pixel_depth */ + { + png_bytep sp; + png_bytep dp; + int s_start, s_end, s_inc; + int m; + int shift; + png_uint_32 i; + int value; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 6; + s_inc = 2; + } + else +#endif + { + s_start = 6; + s_end = 0; + s_inc = -2; + } + + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0x3; + *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 4: /* png_ptr->row_info.pixel_depth */ + { + png_bytep sp; + png_bytep dp; + int s_start, s_end, s_inc; + int m; + int shift; + png_uint_32 i; + int value; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 4; + s_inc = 4; + } + else +#endif + { + s_start = 4; + s_end = 0; + s_inc = -4; + } + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0xf; + *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 8: /* png_ptr->row_info.pixel_depth */ + { + png_bytep srcptr; + png_bytep dstptr; + +#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) +#else + if (_mmx_supported) +#endif + { + png_uint_32 len; + int diff; + int dummy_value_a; // fix 'forbidden register spilled' error + int dummy_value_d; + int dummy_value_c; + int dummy_value_S; + int dummy_value_D; + _unmask = ~mask; // global variable for -fPIC version + srcptr = png_ptr->row_buf + 1; + dstptr = row; + len = png_ptr->width &~7; // reduce to multiple of 8 + diff = (int) (png_ptr->width & 7); // amount lost + + __asm__ __volatile__ ( + "movd _unmask, %%mm7 \n\t" // load bit pattern + "psubb %%mm6, %%mm6 \n\t" // zero mm6 + "punpcklbw %%mm7, %%mm7 \n\t" + "punpcklwd %%mm7, %%mm7 \n\t" + "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks + + "movq _mask8_0, %%mm0 \n\t" + "pand %%mm7, %%mm0 \n\t" // nonzero if keep byte + "pcmpeqb %%mm6, %%mm0 \n\t" // zeros->1s, v versa + +// preload "movl len, %%ecx \n\t" // load length of line +// preload "movl srcptr, %%esi \n\t" // load source +// preload "movl dstptr, %%edi \n\t" // load dest + + "cmpl $0, %%ecx \n\t" // len == 0 ? + "je mainloop8end \n\t" + + "mainloop8: \n\t" + "movq (%%esi), %%mm4 \n\t" // *srcptr + "pand %%mm0, %%mm4 \n\t" + "movq %%mm0, %%mm6 \n\t" + "pandn (%%edi), %%mm6 \n\t" // *dstptr + "por %%mm6, %%mm4 \n\t" + "movq %%mm4, (%%edi) \n\t" + "addl $8, %%esi \n\t" // inc by 8 bytes processed + "addl $8, %%edi \n\t" + "subl $8, %%ecx \n\t" // dec by 8 pixels processed + "ja mainloop8 \n\t" + + "mainloop8end: \n\t" +// preload "movl diff, %%ecx \n\t" // (diff is in eax) + "movl %%eax, %%ecx \n\t" + "cmpl $0, %%ecx \n\t" + "jz end8 \n\t" +// preload "movl mask, %%edx \n\t" + "sall $24, %%edx \n\t" // make low byte, high byte + + "secondloop8: \n\t" + "sall %%edx \n\t" // move high bit to CF + "jnc skip8 \n\t" // if CF = 0 + "movb (%%esi), %%al \n\t" + "movb %%al, (%%edi) \n\t" + + "skip8: \n\t" + "incl %%esi \n\t" + "incl %%edi \n\t" + "decl %%ecx \n\t" + "jnz secondloop8 \n\t" + + "end8: \n\t" + "EMMS \n\t" // DONE + + : "=a" (dummy_value_a), // output regs (dummy) + "=d" (dummy_value_d), + "=c" (dummy_value_c), + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "3" (srcptr), // esi // input regs + "4" (dstptr), // edi + "0" (diff), // eax +// was (unmask) "b" RESERVED // ebx // Global Offset Table idx + "2" (len), // ecx + "1" (mask) // edx + +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm4", "%mm6", "%mm7" // clobber list +#endif + ); + } + else /* mmx _not supported - Use modified C routine */ +#endif /* PNG_MMX_CODE_SUPPORTED */ + { + register png_uint_32 i; + png_uint_32 initial_val = png_pass_start[png_ptr->pass]; + /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ + register int stride = png_pass_inc[png_ptr->pass]; + /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ + register int rep_bytes = png_pass_width[png_ptr->pass]; + /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ + png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ + int diff = (int) (png_ptr->width & 7); /* amount lost */ + register png_uint_32 final_val = len; /* GRR bugfix */ + + srcptr = png_ptr->row_buf + 1 + initial_val; + dstptr = row + initial_val; + + for (i = initial_val; i < final_val; i += stride) + { + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + if (diff) /* number of leftover pixels: 3 for pngtest */ + { + final_val+=diff /* *BPP1 */ ; + for (; i < final_val; i += stride) + { + if (rep_bytes > (int)(final_val-i)) + rep_bytes = (int)(final_val-i); + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + } + + } /* end of else (_mmx_supported) */ + + break; + } /* end 8 bpp */ + + case 16: /* png_ptr->row_info.pixel_depth */ + { + png_bytep srcptr; + png_bytep dstptr; + +#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) +#else + if (_mmx_supported) +#endif + { + png_uint_32 len; + int diff; + int dummy_value_a; // fix 'forbidden register spilled' error + int dummy_value_d; + int dummy_value_c; + int dummy_value_S; + int dummy_value_D; + _unmask = ~mask; // global variable for -fPIC version + srcptr = png_ptr->row_buf + 1; + dstptr = row; + len = png_ptr->width &~7; // reduce to multiple of 8 + diff = (int) (png_ptr->width & 7); // amount lost // + + __asm__ __volatile__ ( + "movd _unmask, %%mm7 \n\t" // load bit pattern + "psubb %%mm6, %%mm6 \n\t" // zero mm6 + "punpcklbw %%mm7, %%mm7 \n\t" + "punpcklwd %%mm7, %%mm7 \n\t" + "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks + + "movq _mask16_0, %%mm0 \n\t" + "movq _mask16_1, %%mm1 \n\t" + + "pand %%mm7, %%mm0 \n\t" + "pand %%mm7, %%mm1 \n\t" + + "pcmpeqb %%mm6, %%mm0 \n\t" + "pcmpeqb %%mm6, %%mm1 \n\t" + +// preload "movl len, %%ecx \n\t" // load length of line +// preload "movl srcptr, %%esi \n\t" // load source +// preload "movl dstptr, %%edi \n\t" // load dest + + "cmpl $0, %%ecx \n\t" + "jz mainloop16end \n\t" + + "mainloop16: \n\t" + "movq (%%esi), %%mm4 \n\t" + "pand %%mm0, %%mm4 \n\t" + "movq %%mm0, %%mm6 \n\t" + "movq (%%edi), %%mm7 \n\t" + "pandn %%mm7, %%mm6 \n\t" + "por %%mm6, %%mm4 \n\t" + "movq %%mm4, (%%edi) \n\t" + + "movq 8(%%esi), %%mm5 \n\t" + "pand %%mm1, %%mm5 \n\t" + "movq %%mm1, %%mm7 \n\t" + "movq 8(%%edi), %%mm6 \n\t" + "pandn %%mm6, %%mm7 \n\t" + "por %%mm7, %%mm5 \n\t" + "movq %%mm5, 8(%%edi) \n\t" + + "addl $16, %%esi \n\t" // inc by 16 bytes processed + "addl $16, %%edi \n\t" + "subl $8, %%ecx \n\t" // dec by 8 pixels processed + "ja mainloop16 \n\t" + + "mainloop16end: \n\t" +// preload "movl diff, %%ecx \n\t" // (diff is in eax) + "movl %%eax, %%ecx \n\t" + "cmpl $0, %%ecx \n\t" + "jz end16 \n\t" +// preload "movl mask, %%edx \n\t" + "sall $24, %%edx \n\t" // make low byte, high byte + + "secondloop16: \n\t" + "sall %%edx \n\t" // move high bit to CF + "jnc skip16 \n\t" // if CF = 0 + "movw (%%esi), %%ax \n\t" + "movw %%ax, (%%edi) \n\t" + + "skip16: \n\t" + "addl $2, %%esi \n\t" + "addl $2, %%edi \n\t" + "decl %%ecx \n\t" + "jnz secondloop16 \n\t" + + "end16: \n\t" + "EMMS \n\t" // DONE + + : "=a" (dummy_value_a), // output regs (dummy) + "=c" (dummy_value_c), + "=d" (dummy_value_d), + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "0" (diff), // eax // input regs +// was (unmask) " " RESERVED // ebx // Global Offset Table idx + "1" (len), // ecx + "2" (mask), // edx + "3" (srcptr), // esi + "4" (dstptr) // edi + +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1", "%mm4" // clobber list + , "%mm5", "%mm6", "%mm7" +#endif + ); + } + else /* mmx _not supported - Use modified C routine */ +#endif /* PNG_MMX_CODE_SUPPORTED */ + { + register png_uint_32 i; + png_uint_32 initial_val = BPP2 * png_pass_start[png_ptr->pass]; + /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ + register int stride = BPP2 * png_pass_inc[png_ptr->pass]; + /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ + register int rep_bytes = BPP2 * png_pass_width[png_ptr->pass]; + /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ + png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ + int diff = (int) (png_ptr->width & 7); /* amount lost */ + register png_uint_32 final_val = BPP2 * len; /* GRR bugfix */ + + srcptr = png_ptr->row_buf + 1 + initial_val; + dstptr = row + initial_val; + + for (i = initial_val; i < final_val; i += stride) + { + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + if (diff) /* number of leftover pixels: 3 for pngtest */ + { + final_val+=diff*BPP2; + for (; i < final_val; i += stride) + { + if (rep_bytes > (int)(final_val-i)) + rep_bytes = (int)(final_val-i); + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + } + } /* end of else (_mmx_supported) */ + + break; + } /* end 16 bpp */ + + case 24: /* png_ptr->row_info.pixel_depth */ + { + png_bytep srcptr; + png_bytep dstptr; + +#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) +#else + if (_mmx_supported) +#endif + { + png_uint_32 len; + int diff; + int dummy_value_a; // fix 'forbidden register spilled' error + int dummy_value_d; + int dummy_value_c; + int dummy_value_S; + int dummy_value_D; + _unmask = ~mask; // global variable for -fPIC version + srcptr = png_ptr->row_buf + 1; + dstptr = row; + len = png_ptr->width &~7; // reduce to multiple of 8 + diff = (int) (png_ptr->width & 7); // amount lost // + + __asm__ __volatile__ ( + "movd _unmask, %%mm7 \n\t" // load bit pattern + "psubb %%mm6, %%mm6 \n\t" // zero mm6 + "punpcklbw %%mm7, %%mm7 \n\t" + "punpcklwd %%mm7, %%mm7 \n\t" + "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks + + "movq _mask24_0, %%mm0 \n\t" + "movq _mask24_1, %%mm1 \n\t" + "movq _mask24_2, %%mm2 \n\t" + + "pand %%mm7, %%mm0 \n\t" + "pand %%mm7, %%mm1 \n\t" + "pand %%mm7, %%mm2 \n\t" + + "pcmpeqb %%mm6, %%mm0 \n\t" + "pcmpeqb %%mm6, %%mm1 \n\t" + "pcmpeqb %%mm6, %%mm2 \n\t" + +// preload "movl len, %%ecx \n\t" // load length of line +// preload "movl srcptr, %%esi \n\t" // load source +// preload "movl dstptr, %%edi \n\t" // load dest + + "cmpl $0, %%ecx \n\t" + "jz mainloop24end \n\t" + + "mainloop24: \n\t" + "movq (%%esi), %%mm4 \n\t" + "pand %%mm0, %%mm4 \n\t" + "movq %%mm0, %%mm6 \n\t" + "movq (%%edi), %%mm7 \n\t" + "pandn %%mm7, %%mm6 \n\t" + "por %%mm6, %%mm4 \n\t" + "movq %%mm4, (%%edi) \n\t" + + "movq 8(%%esi), %%mm5 \n\t" + "pand %%mm1, %%mm5 \n\t" + "movq %%mm1, %%mm7 \n\t" + "movq 8(%%edi), %%mm6 \n\t" + "pandn %%mm6, %%mm7 \n\t" + "por %%mm7, %%mm5 \n\t" + "movq %%mm5, 8(%%edi) \n\t" + + "movq 16(%%esi), %%mm6 \n\t" + "pand %%mm2, %%mm6 \n\t" + "movq %%mm2, %%mm4 \n\t" + "movq 16(%%edi), %%mm7 \n\t" + "pandn %%mm7, %%mm4 \n\t" + "por %%mm4, %%mm6 \n\t" + "movq %%mm6, 16(%%edi) \n\t" + + "addl $24, %%esi \n\t" // inc by 24 bytes processed + "addl $24, %%edi \n\t" + "subl $8, %%ecx \n\t" // dec by 8 pixels processed + + "ja mainloop24 \n\t" + + "mainloop24end: \n\t" +// preload "movl diff, %%ecx \n\t" // (diff is in eax) + "movl %%eax, %%ecx \n\t" + "cmpl $0, %%ecx \n\t" + "jz end24 \n\t" +// preload "movl mask, %%edx \n\t" + "sall $24, %%edx \n\t" // make low byte, high byte + + "secondloop24: \n\t" + "sall %%edx \n\t" // move high bit to CF + "jnc skip24 \n\t" // if CF = 0 + "movw (%%esi), %%ax \n\t" + "movw %%ax, (%%edi) \n\t" + "xorl %%eax, %%eax \n\t" + "movb 2(%%esi), %%al \n\t" + "movb %%al, 2(%%edi) \n\t" + + "skip24: \n\t" + "addl $3, %%esi \n\t" + "addl $3, %%edi \n\t" + "decl %%ecx \n\t" + "jnz secondloop24 \n\t" + + "end24: \n\t" + "EMMS \n\t" // DONE + + : "=a" (dummy_value_a), // output regs (dummy) + "=d" (dummy_value_d), + "=c" (dummy_value_c), + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "3" (srcptr), // esi // input regs + "4" (dstptr), // edi + "0" (diff), // eax +// was (unmask) "b" RESERVED // ebx // Global Offset Table idx + "2" (len), // ecx + "1" (mask) // edx + +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1", "%mm2" // clobber list + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + else /* mmx _not supported - Use modified C routine */ +#endif /* PNG_MMX_CODE_SUPPORTED */ + { + register png_uint_32 i; + png_uint_32 initial_val = BPP3 * png_pass_start[png_ptr->pass]; + /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ + register int stride = BPP3 * png_pass_inc[png_ptr->pass]; + /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ + register int rep_bytes = BPP3 * png_pass_width[png_ptr->pass]; + /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ + png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ + int diff = (int) (png_ptr->width & 7); /* amount lost */ + register png_uint_32 final_val = BPP3 * len; /* GRR bugfix */ + + srcptr = png_ptr->row_buf + 1 + initial_val; + dstptr = row + initial_val; + + for (i = initial_val; i < final_val; i += stride) + { + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + if (diff) /* number of leftover pixels: 3 for pngtest */ + { + final_val+=diff*BPP3; + for (; i < final_val; i += stride) + { + if (rep_bytes > (int)(final_val-i)) + rep_bytes = (int)(final_val-i); + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + } + } /* end of else (_mmx_supported) */ + + break; + } /* end 24 bpp */ + + case 32: /* png_ptr->row_info.pixel_depth */ + { + png_bytep srcptr; + png_bytep dstptr; + +#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) +#else + if (_mmx_supported) +#endif + { + png_uint_32 len; + int diff; + int dummy_value_a; // fix 'forbidden register spilled' error + int dummy_value_d; + int dummy_value_c; + int dummy_value_S; + int dummy_value_D; + _unmask = ~mask; // global variable for -fPIC version + srcptr = png_ptr->row_buf + 1; + dstptr = row; + len = png_ptr->width &~7; // reduce to multiple of 8 + diff = (int) (png_ptr->width & 7); // amount lost // + + __asm__ __volatile__ ( + "movd _unmask, %%mm7 \n\t" // load bit pattern + "psubb %%mm6, %%mm6 \n\t" // zero mm6 + "punpcklbw %%mm7, %%mm7 \n\t" + "punpcklwd %%mm7, %%mm7 \n\t" + "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks + + "movq _mask32_0, %%mm0 \n\t" + "movq _mask32_1, %%mm1 \n\t" + "movq _mask32_2, %%mm2 \n\t" + "movq _mask32_3, %%mm3 \n\t" + + "pand %%mm7, %%mm0 \n\t" + "pand %%mm7, %%mm1 \n\t" + "pand %%mm7, %%mm2 \n\t" + "pand %%mm7, %%mm3 \n\t" + + "pcmpeqb %%mm6, %%mm0 \n\t" + "pcmpeqb %%mm6, %%mm1 \n\t" + "pcmpeqb %%mm6, %%mm2 \n\t" + "pcmpeqb %%mm6, %%mm3 \n\t" + +// preload "movl len, %%ecx \n\t" // load length of line +// preload "movl srcptr, %%esi \n\t" // load source +// preload "movl dstptr, %%edi \n\t" // load dest + + "cmpl $0, %%ecx \n\t" // lcr + "jz mainloop32end \n\t" + + "mainloop32: \n\t" + "movq (%%esi), %%mm4 \n\t" + "pand %%mm0, %%mm4 \n\t" + "movq %%mm0, %%mm6 \n\t" + "movq (%%edi), %%mm7 \n\t" + "pandn %%mm7, %%mm6 \n\t" + "por %%mm6, %%mm4 \n\t" + "movq %%mm4, (%%edi) \n\t" + + "movq 8(%%esi), %%mm5 \n\t" + "pand %%mm1, %%mm5 \n\t" + "movq %%mm1, %%mm7 \n\t" + "movq 8(%%edi), %%mm6 \n\t" + "pandn %%mm6, %%mm7 \n\t" + "por %%mm7, %%mm5 \n\t" + "movq %%mm5, 8(%%edi) \n\t" + + "movq 16(%%esi), %%mm6 \n\t" + "pand %%mm2, %%mm6 \n\t" + "movq %%mm2, %%mm4 \n\t" + "movq 16(%%edi), %%mm7 \n\t" + "pandn %%mm7, %%mm4 \n\t" + "por %%mm4, %%mm6 \n\t" + "movq %%mm6, 16(%%edi) \n\t" + + "movq 24(%%esi), %%mm7 \n\t" + "pand %%mm3, %%mm7 \n\t" + "movq %%mm3, %%mm5 \n\t" + "movq 24(%%edi), %%mm4 \n\t" + "pandn %%mm4, %%mm5 \n\t" + "por %%mm5, %%mm7 \n\t" + "movq %%mm7, 24(%%edi) \n\t" + + "addl $32, %%esi \n\t" // inc by 32 bytes processed + "addl $32, %%edi \n\t" + "subl $8, %%ecx \n\t" // dec by 8 pixels processed + "ja mainloop32 \n\t" + + "mainloop32end: \n\t" +// preload "movl diff, %%ecx \n\t" // (diff is in eax) + "movl %%eax, %%ecx \n\t" + "cmpl $0, %%ecx \n\t" + "jz end32 \n\t" +// preload "movl mask, %%edx \n\t" + "sall $24, %%edx \n\t" // low byte => high byte + + "secondloop32: \n\t" + "sall %%edx \n\t" // move high bit to CF + "jnc skip32 \n\t" // if CF = 0 + "movl (%%esi), %%eax \n\t" + "movl %%eax, (%%edi) \n\t" + + "skip32: \n\t" + "addl $4, %%esi \n\t" + "addl $4, %%edi \n\t" + "decl %%ecx \n\t" + "jnz secondloop32 \n\t" + + "end32: \n\t" + "EMMS \n\t" // DONE + + : "=a" (dummy_value_a), // output regs (dummy) + "=d" (dummy_value_d), + "=c" (dummy_value_c), + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "3" (srcptr), // esi // input regs + "4" (dstptr), // edi + "0" (diff), // eax +// was (unmask) "b" RESERVED // ebx // Global Offset Table idx + "2" (len), // ecx + "1" (mask) // edx + +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1", "%mm2", "%mm3" // clobber list + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + else /* mmx _not supported - Use modified C routine */ +#endif /* PNG_MMX_CODE_SUPPORTED */ + { + register png_uint_32 i; + png_uint_32 initial_val = BPP4 * png_pass_start[png_ptr->pass]; + /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ + register int stride = BPP4 * png_pass_inc[png_ptr->pass]; + /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ + register int rep_bytes = BPP4 * png_pass_width[png_ptr->pass]; + /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ + png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ + int diff = (int) (png_ptr->width & 7); /* amount lost */ + register png_uint_32 final_val = BPP4 * len; /* GRR bugfix */ + + srcptr = png_ptr->row_buf + 1 + initial_val; + dstptr = row + initial_val; + + for (i = initial_val; i < final_val; i += stride) + { + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + if (diff) /* number of leftover pixels: 3 for pngtest */ + { + final_val+=diff*BPP4; + for (; i < final_val; i += stride) + { + if (rep_bytes > (int)(final_val-i)) + rep_bytes = (int)(final_val-i); + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + } + } /* end of else (_mmx_supported) */ + + break; + } /* end 32 bpp */ + + case 48: /* png_ptr->row_info.pixel_depth */ + { + png_bytep srcptr; + png_bytep dstptr; + +#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) +#else + if (_mmx_supported) +#endif + { + png_uint_32 len; + int diff; + int dummy_value_a; // fix 'forbidden register spilled' error + int dummy_value_d; + int dummy_value_c; + int dummy_value_S; + int dummy_value_D; + _unmask = ~mask; // global variable for -fPIC version + srcptr = png_ptr->row_buf + 1; + dstptr = row; + len = png_ptr->width &~7; // reduce to multiple of 8 + diff = (int) (png_ptr->width & 7); // amount lost // + + __asm__ __volatile__ ( + "movd _unmask, %%mm7 \n\t" // load bit pattern + "psubb %%mm6, %%mm6 \n\t" // zero mm6 + "punpcklbw %%mm7, %%mm7 \n\t" + "punpcklwd %%mm7, %%mm7 \n\t" + "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks + + "movq _mask48_0, %%mm0 \n\t" + "movq _mask48_1, %%mm1 \n\t" + "movq _mask48_2, %%mm2 \n\t" + "movq _mask48_3, %%mm3 \n\t" + "movq _mask48_4, %%mm4 \n\t" + "movq _mask48_5, %%mm5 \n\t" + + "pand %%mm7, %%mm0 \n\t" + "pand %%mm7, %%mm1 \n\t" + "pand %%mm7, %%mm2 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pand %%mm7, %%mm4 \n\t" + "pand %%mm7, %%mm5 \n\t" + + "pcmpeqb %%mm6, %%mm0 \n\t" + "pcmpeqb %%mm6, %%mm1 \n\t" + "pcmpeqb %%mm6, %%mm2 \n\t" + "pcmpeqb %%mm6, %%mm3 \n\t" + "pcmpeqb %%mm6, %%mm4 \n\t" + "pcmpeqb %%mm6, %%mm5 \n\t" + +// preload "movl len, %%ecx \n\t" // load length of line +// preload "movl srcptr, %%esi \n\t" // load source +// preload "movl dstptr, %%edi \n\t" // load dest + + "cmpl $0, %%ecx \n\t" + "jz mainloop48end \n\t" + + "mainloop48: \n\t" + "movq (%%esi), %%mm7 \n\t" + "pand %%mm0, %%mm7 \n\t" + "movq %%mm0, %%mm6 \n\t" + "pandn (%%edi), %%mm6 \n\t" + "por %%mm6, %%mm7 \n\t" + "movq %%mm7, (%%edi) \n\t" + + "movq 8(%%esi), %%mm6 \n\t" + "pand %%mm1, %%mm6 \n\t" + "movq %%mm1, %%mm7 \n\t" + "pandn 8(%%edi), %%mm7 \n\t" + "por %%mm7, %%mm6 \n\t" + "movq %%mm6, 8(%%edi) \n\t" + + "movq 16(%%esi), %%mm6 \n\t" + "pand %%mm2, %%mm6 \n\t" + "movq %%mm2, %%mm7 \n\t" + "pandn 16(%%edi), %%mm7 \n\t" + "por %%mm7, %%mm6 \n\t" + "movq %%mm6, 16(%%edi) \n\t" + + "movq 24(%%esi), %%mm7 \n\t" + "pand %%mm3, %%mm7 \n\t" + "movq %%mm3, %%mm6 \n\t" + "pandn 24(%%edi), %%mm6 \n\t" + "por %%mm6, %%mm7 \n\t" + "movq %%mm7, 24(%%edi) \n\t" + + "movq 32(%%esi), %%mm6 \n\t" + "pand %%mm4, %%mm6 \n\t" + "movq %%mm4, %%mm7 \n\t" + "pandn 32(%%edi), %%mm7 \n\t" + "por %%mm7, %%mm6 \n\t" + "movq %%mm6, 32(%%edi) \n\t" + + "movq 40(%%esi), %%mm7 \n\t" + "pand %%mm5, %%mm7 \n\t" + "movq %%mm5, %%mm6 \n\t" + "pandn 40(%%edi), %%mm6 \n\t" + "por %%mm6, %%mm7 \n\t" + "movq %%mm7, 40(%%edi) \n\t" + + "addl $48, %%esi \n\t" // inc by 48 bytes processed + "addl $48, %%edi \n\t" + "subl $8, %%ecx \n\t" // dec by 8 pixels processed + + "ja mainloop48 \n\t" + + "mainloop48end: \n\t" +// preload "movl diff, %%ecx \n\t" // (diff is in eax) + "movl %%eax, %%ecx \n\t" + "cmpl $0, %%ecx \n\t" + "jz end48 \n\t" +// preload "movl mask, %%edx \n\t" + "sall $24, %%edx \n\t" // make low byte, high byte + + "secondloop48: \n\t" + "sall %%edx \n\t" // move high bit to CF + "jnc skip48 \n\t" // if CF = 0 + "movl (%%esi), %%eax \n\t" + "movl %%eax, (%%edi) \n\t" + + "skip48: \n\t" + "addl $4, %%esi \n\t" + "addl $4, %%edi \n\t" + "decl %%ecx \n\t" + "jnz secondloop48 \n\t" + + "end48: \n\t" + "EMMS \n\t" // DONE + + : "=a" (dummy_value_a), // output regs (dummy) + "=d" (dummy_value_d), + "=c" (dummy_value_c), + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "3" (srcptr), // esi // input regs + "4" (dstptr), // edi + "0" (diff), // eax +// was (unmask) "b" RESERVED // ebx // Global Offset Table idx + "2" (len), // ecx + "1" (mask) // edx + +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1", "%mm2", "%mm3" // clobber list + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + else /* mmx _not supported - Use modified C routine */ +#endif /* PNG_MMX_CODE_SUPPORTED */ + { + register png_uint_32 i; + png_uint_32 initial_val = BPP6 * png_pass_start[png_ptr->pass]; + /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ + register int stride = BPP6 * png_pass_inc[png_ptr->pass]; + /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ + register int rep_bytes = BPP6 * png_pass_width[png_ptr->pass]; + /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ + png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ + int diff = (int) (png_ptr->width & 7); /* amount lost */ + register png_uint_32 final_val = BPP6 * len; /* GRR bugfix */ + + srcptr = png_ptr->row_buf + 1 + initial_val; + dstptr = row + initial_val; + + for (i = initial_val; i < final_val; i += stride) + { + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + if (diff) /* number of leftover pixels: 3 for pngtest */ + { + final_val+=diff*BPP6; + for (; i < final_val; i += stride) + { + if (rep_bytes > (int)(final_val-i)) + rep_bytes = (int)(final_val-i); + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + } + } /* end of else (_mmx_supported) */ + + break; + } /* end 48 bpp */ + + case 64: /* png_ptr->row_info.pixel_depth */ + { + png_bytep srcptr; + png_bytep dstptr; + register png_uint_32 i; + png_uint_32 initial_val = BPP8 * png_pass_start[png_ptr->pass]; + /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ + register int stride = BPP8 * png_pass_inc[png_ptr->pass]; + /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ + register int rep_bytes = BPP8 * png_pass_width[png_ptr->pass]; + /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ + png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ + int diff = (int) (png_ptr->width & 7); /* amount lost */ + register png_uint_32 final_val = BPP8 * len; /* GRR bugfix */ + + srcptr = png_ptr->row_buf + 1 + initial_val; + dstptr = row + initial_val; + + for (i = initial_val; i < final_val; i += stride) + { + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + if (diff) /* number of leftover pixels: 3 for pngtest */ + { + final_val+=diff*BPP8; + for (; i < final_val; i += stride) + { + if (rep_bytes > (int)(final_val-i)) + rep_bytes = (int)(final_val-i); + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + } + + break; + } /* end 64 bpp */ + + default: /* png_ptr->row_info.pixel_depth != 1,2,4,8,16,24,32,48,64 */ + { + /* this should never happen */ + png_warning(png_ptr, "Invalid row_info.pixel_depth in pnggccrd"); + break; + } + } /* end switch (png_ptr->row_info.pixel_depth) */ + + } /* end if (non-trivial mask) */ + +} /* end png_combine_row() */ + +#endif /* PNG_HAVE_MMX_COMBINE_ROW */ + + + + +/*===========================================================================*/ +/* */ +/* P N G _ D O _ R E A D _ I N T E R L A C E */ +/* */ +/*===========================================================================*/ + +#if defined(PNG_READ_INTERLACING_SUPPORTED) +#if defined(PNG_HAVE_MMX_READ_INTERLACE) + +/* png_do_read_interlace() is called after any 16-bit to 8-bit conversion + * has taken place. [GRR: what other steps come before and/or after?] + */ + +void /* PRIVATE */ +png_do_read_interlace(png_structp png_ptr) +{ + png_row_infop row_info = &(png_ptr->row_info); + png_bytep row = png_ptr->row_buf + 1; + int pass = png_ptr->pass; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + png_uint_32 transformations = png_ptr->transformations; +#endif + + png_debug(1, "in png_do_read_interlace (pnggccrd.c)\n"); + +#if defined(PNG_MMX_CODE_SUPPORTED) + if (_mmx_supported == 2) { +#if !defined(PNG_1_0_X) + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); +#endif + png_mmx_support(); + } +#endif + + if (row != NULL && row_info != NULL) + { + png_uint_32 final_width; + + final_width = row_info->width * png_pass_inc[pass]; + + switch (row_info->pixel_depth) + { + case 1: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_byte v; + png_uint_32 i; + int j; + + sp = row + (png_size_t)((row_info->width - 1) >> 3); + dp = row + (png_size_t)((final_width - 1) >> 3); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (int)((row_info->width + 7) & 7); + dshift = (int)((final_width + 7) & 7); + s_start = 7; + s_end = 0; + s_inc = -1; + } + else +#endif + { + sshift = 7 - (int)((row_info->width + 7) & 7); + dshift = 7 - (int)((final_width + 7) & 7); + s_start = 0; + s_end = 7; + s_inc = 1; + } + + for (i = row_info->width; i; i--) + { + v = (png_byte)((*sp >> sshift) & 0x1); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + case 2: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_uint_32 i; + + sp = row + (png_size_t)((row_info->width - 1) >> 2); + dp = row + (png_size_t)((final_width - 1) >> 2); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); + dshift = (png_size_t)(((final_width + 3) & 3) << 1); + s_start = 6; + s_end = 0; + s_inc = -2; + } + else +#endif + { + sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); + dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); + s_start = 0; + s_end = 6; + s_inc = 2; + } + + for (i = row_info->width; i; i--) + { + png_byte v; + int j; + + v = (png_byte)((*sp >> sshift) & 0x3); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + case 4: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_uint_32 i; + + sp = row + (png_size_t)((row_info->width - 1) >> 1); + dp = row + (png_size_t)((final_width - 1) >> 1); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); + dshift = (png_size_t)(((final_width + 1) & 1) << 2); + s_start = 4; + s_end = 0; + s_inc = -4; + } + else +#endif + { + sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); + dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); + s_start = 0; + s_end = 4; + s_inc = 4; + } + + for (i = row_info->width; i; i--) + { + png_byte v; + int j; + + v = (png_byte)((*sp >> sshift) & 0xf); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + /*====================================================================*/ + + default: /* 8-bit or larger (this is where the routine is modified) */ + { +#if 0 +// static unsigned long long _const4 = 0x0000000000FFFFFFLL; no good +// static unsigned long long const4 = 0x0000000000FFFFFFLL; no good +// unsigned long long _const4 = 0x0000000000FFFFFFLL; no good +// unsigned long long const4 = 0x0000000000FFFFFFLL; no good +#endif + png_bytep sptr, dp; + png_uint_32 i; + png_size_t pixel_bytes; + int width = (int)row_info->width; + + pixel_bytes = (row_info->pixel_depth >> 3); + + /* point sptr at the last pixel in the pre-expanded row: */ + sptr = row + (width - 1) * pixel_bytes; + + /* point dp at the last pixel position in the expanded row: */ + dp = row + (final_width - 1) * pixel_bytes; + + /* New code by Nirav Chhatrapati - Intel Corporation */ + +#if defined(PNG_MMX_CODE_SUPPORTED) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE) + /* && _mmx_supported */ ) +#else + if (_mmx_supported) +#endif + { + //-------------------------------------------------------------- + if (pixel_bytes == 3) + { + if (((pass == 0) || (pass == 1)) && width) + { + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + int dummy_value_a; + + __asm__ __volatile__ ( + "subl $21, %%edi \n\t" + // (png_pass_inc[pass] - 1)*pixel_bytes + + ".loop3_pass0: \n\t" + "movd (%%esi), %%mm0 \n\t" // x x x x x 2 1 0 + "pand (%3), %%mm0 \n\t" // z z z z z 2 1 0 + "movq %%mm0, %%mm1 \n\t" // z z z z z 2 1 0 + "psllq $16, %%mm0 \n\t" // z z z 2 1 0 z z + "movq %%mm0, %%mm2 \n\t" // z z z 2 1 0 z z + "psllq $24, %%mm0 \n\t" // 2 1 0 z z z z z + "psrlq $8, %%mm1 \n\t" // z z z z z z 2 1 + "por %%mm2, %%mm0 \n\t" // 2 1 0 2 1 0 z z + "por %%mm1, %%mm0 \n\t" // 2 1 0 2 1 0 2 1 + "movq %%mm0, %%mm3 \n\t" // 2 1 0 2 1 0 2 1 + "psllq $16, %%mm0 \n\t" // 0 2 1 0 2 1 z z + "movq %%mm3, %%mm4 \n\t" // 2 1 0 2 1 0 2 1 + "punpckhdq %%mm0, %%mm3 \n\t" // 0 2 1 0 2 1 0 2 + "movq %%mm4, 16(%%edi) \n\t" + "psrlq $32, %%mm0 \n\t" // z z z z 0 2 1 0 + "movq %%mm3, 8(%%edi) \n\t" + "punpckldq %%mm4, %%mm0 \n\t" // 1 0 2 1 0 2 1 0 + "subl $3, %%esi \n\t" + "movq %%mm0, (%%edi) \n\t" + "subl $24, %%edi \n\t" + "decl %%ecx \n\t" + "jnz .loop3_pass0 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D), + "=a" (dummy_value_a) + + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width), // ecx + "3" (&_const4) // %1(?) (0x0000000000FFFFFFLL) + +#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1", "%mm2" // clobber list + , "%mm3", "%mm4" +#endif + ); + } + else if (((pass == 2) || (pass == 3)) && width) + { + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + int dummy_value_a; + + __asm__ __volatile__ ( + "subl $9, %%edi \n\t" + // (png_pass_inc[pass] - 1)*pixel_bytes + + ".loop3_pass2: \n\t" + "movd (%%esi), %%mm0 \n\t" // x x x x x 2 1 0 + "pand (%3), %%mm0 \n\t" // z z z z z 2 1 0 + "movq %%mm0, %%mm1 \n\t" // z z z z z 2 1 0 + "psllq $16, %%mm0 \n\t" // z z z 2 1 0 z z + "movq %%mm0, %%mm2 \n\t" // z z z 2 1 0 z z + "psllq $24, %%mm0 \n\t" // 2 1 0 z z z z z + "psrlq $8, %%mm1 \n\t" // z z z z z z 2 1 + "por %%mm2, %%mm0 \n\t" // 2 1 0 2 1 0 z z + "por %%mm1, %%mm0 \n\t" // 2 1 0 2 1 0 2 1 + "movq %%mm0, 4(%%edi) \n\t" + "psrlq $16, %%mm0 \n\t" // z z 2 1 0 2 1 0 + "subl $3, %%esi \n\t" + "movd %%mm0, (%%edi) \n\t" + "subl $12, %%edi \n\t" + "decl %%ecx \n\t" + "jnz .loop3_pass2 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D), + "=a" (dummy_value_a) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width), // ecx + "3" (&_const4) // (0x0000000000FFFFFFLL) + +#if 0 /* %mm0, ..., %mm2 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1", "%mm2" // clobber list +#endif + ); + } + else if (width) /* && ((pass == 4) || (pass == 5)) */ + { + int width_mmx = ((width >> 1) << 1) - 8; // GRR: huh? + if (width_mmx < 0) + width_mmx = 0; + width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes + if (width_mmx) + { + // png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; + // sptr points at last pixel in pre-expanded row + // dp points at last pixel position in expanded row + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + int dummy_value_a; + int dummy_value_d; + + __asm__ __volatile__ ( + "subl $3, %%esi \n\t" + "subl $9, %%edi \n\t" + // (png_pass_inc[pass] + 1)*pixel_bytes + + ".loop3_pass4: \n\t" + "movq (%%esi), %%mm0 \n\t" // x x 5 4 3 2 1 0 + "movq %%mm0, %%mm1 \n\t" // x x 5 4 3 2 1 0 + "movq %%mm0, %%mm2 \n\t" // x x 5 4 3 2 1 0 + "psllq $24, %%mm0 \n\t" // 4 3 2 1 0 z z z + "pand (%3), %%mm1 \n\t" // z z z z z 2 1 0 + "psrlq $24, %%mm2 \n\t" // z z z x x 5 4 3 + "por %%mm1, %%mm0 \n\t" // 4 3 2 1 0 2 1 0 + "movq %%mm2, %%mm3 \n\t" // z z z x x 5 4 3 + "psllq $8, %%mm2 \n\t" // z z x x 5 4 3 z + "movq %%mm0, (%%edi) \n\t" + "psrlq $16, %%mm3 \n\t" // z z z z z x x 5 + "pand (%4), %%mm3 \n\t" // z z z z z z z 5 + "por %%mm3, %%mm2 \n\t" // z z x x 5 4 3 5 + "subl $6, %%esi \n\t" + "movd %%mm2, 8(%%edi) \n\t" + "subl $12, %%edi \n\t" + "subl $2, %%ecx \n\t" + "jnz .loop3_pass4 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D), + "=a" (dummy_value_a), + "=d" (dummy_value_d) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width_mmx), // ecx + "3" (&_const4), // 0x0000000000FFFFFFLL + "4" (&_const6) // 0x00000000000000FFLL + +#if 0 /* %mm0, ..., %mm3 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" // clobber list + , "%mm2", "%mm3" +#endif + ); + } + + sptr -= width_mmx*3; + dp -= width_mmx*6; + for (i = width; i; i--) + { + png_byte v[8]; + int j; + + png_memcpy(v, sptr, 3); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 3); + dp -= 3; + } + sptr -= 3; + } + } + } /* end of pixel_bytes == 3 */ + + //-------------------------------------------------------------- + else if (pixel_bytes == 1) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 2) << 2); + width -= width_mmx; // 0-3 pixels => 0-3 bytes + if (width_mmx) + { + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $3, %%esi \n\t" + "subl $31, %%edi \n\t" + + ".loop1_pass0: \n\t" + "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 + "movq %%mm0, %%mm1 \n\t" // x x x x 3 2 1 0 + "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 + "movq %%mm0, %%mm2 \n\t" // 3 3 2 2 1 1 0 0 + "punpcklwd %%mm0, %%mm0 \n\t" // 1 1 1 1 0 0 0 0 + "movq %%mm0, %%mm3 \n\t" // 1 1 1 1 0 0 0 0 + "punpckldq %%mm0, %%mm0 \n\t" // 0 0 0 0 0 0 0 0 + "punpckhdq %%mm3, %%mm3 \n\t" // 1 1 1 1 1 1 1 1 + "movq %%mm0, (%%edi) \n\t" + "punpckhwd %%mm2, %%mm2 \n\t" // 3 3 3 3 2 2 2 2 + "movq %%mm3, 8(%%edi) \n\t" + "movq %%mm2, %%mm4 \n\t" // 3 3 3 3 2 2 2 2 + "punpckldq %%mm2, %%mm2 \n\t" // 2 2 2 2 2 2 2 2 + "punpckhdq %%mm4, %%mm4 \n\t" // 3 3 3 3 3 3 3 3 + "movq %%mm2, 16(%%edi) \n\t" + "subl $4, %%esi \n\t" + "movq %%mm4, 24(%%edi) \n\t" + "subl $32, %%edi \n\t" + "subl $4, %%ecx \n\t" + "jnz .loop1_pass0 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width_mmx) // ecx + +#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1", "%mm2" // clobber list + , "%mm3", "%mm4" +#endif + ); + } + + sptr -= width_mmx; + dp -= width_mmx*8; + for (i = width; i; i--) + { + int j; + + /* I simplified this part in version 1.0.4e + * here and in several other instances where + * pixel_bytes == 1 -- GR-P + * + * Original code: + * + * png_byte v[8]; + * png_memcpy(v, sptr, pixel_bytes); + * for (j = 0; j < png_pass_inc[pass]; j++) + * { + * png_memcpy(dp, v, pixel_bytes); + * dp -= pixel_bytes; + * } + * sptr -= pixel_bytes; + * + * Replacement code is in the next three lines: + */ + + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp-- = *sptr; + } + --sptr; + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 2) << 2); + width -= width_mmx; // 0-3 pixels => 0-3 bytes + if (width_mmx) + { + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $3, %%esi \n\t" + "subl $15, %%edi \n\t" + + ".loop1_pass2: \n\t" + "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 + "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 + "movq %%mm0, %%mm1 \n\t" // 3 3 2 2 1 1 0 0 + "punpcklwd %%mm0, %%mm0 \n\t" // 1 1 1 1 0 0 0 0 + "punpckhwd %%mm1, %%mm1 \n\t" // 3 3 3 3 2 2 2 2 + "movq %%mm0, (%%edi) \n\t" + "subl $4, %%esi \n\t" + "movq %%mm1, 8(%%edi) \n\t" + "subl $16, %%edi \n\t" + "subl $4, %%ecx \n\t" + "jnz .loop1_pass2 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width_mmx) // ecx + +#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" // clobber list +#endif + ); + } + + sptr -= width_mmx; + dp -= width_mmx*4; + for (i = width; i; i--) + { + int j; + + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp-- = *sptr; + } + --sptr; + } + } + else if (width) /* && ((pass == 4) || (pass == 5)) */ + { + int width_mmx = ((width >> 3) << 3); + width -= width_mmx; // 0-3 pixels => 0-3 bytes + if (width_mmx) + { + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $7, %%esi \n\t" + "subl $15, %%edi \n\t" + + ".loop1_pass4: \n\t" + "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 + "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 + "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 + "punpckhbw %%mm1, %%mm1 \n\t" // 7 7 6 6 5 5 4 4 + "movq %%mm1, 8(%%edi) \n\t" + "subl $8, %%esi \n\t" + "movq %%mm0, (%%edi) \n\t" + "subl $16, %%edi \n\t" + "subl $8, %%ecx \n\t" + "jnz .loop1_pass4 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (none) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width_mmx) // ecx + +#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" // clobber list +#endif + ); + } + + sptr -= width_mmx; + dp -= width_mmx*2; + for (i = width; i; i--) + { + int j; + + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp-- = *sptr; + } + --sptr; + } + } + } /* end of pixel_bytes == 1 */ + + //-------------------------------------------------------------- + else if (pixel_bytes == 2) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 1) << 1); + width -= width_mmx; // 0,1 pixels => 0,2 bytes + if (width_mmx) + { + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $2, %%esi \n\t" + "subl $30, %%edi \n\t" + + ".loop2_pass0: \n\t" + "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 + "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 + "movq %%mm0, %%mm1 \n\t" // 3 2 3 2 1 0 1 0 + "punpckldq %%mm0, %%mm0 \n\t" // 1 0 1 0 1 0 1 0 + "punpckhdq %%mm1, %%mm1 \n\t" // 3 2 3 2 3 2 3 2 + "movq %%mm0, (%%edi) \n\t" + "movq %%mm0, 8(%%edi) \n\t" + "movq %%mm1, 16(%%edi) \n\t" + "subl $4, %%esi \n\t" + "movq %%mm1, 24(%%edi) \n\t" + "subl $32, %%edi \n\t" + "subl $2, %%ecx \n\t" + "jnz .loop2_pass0 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width_mmx) // ecx + +#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" // clobber list +#endif + ); + } + + sptr -= (width_mmx*2 - 2); // sign fixed + dp -= (width_mmx*16 - 2); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; // 0,1 pixels => 0,2 bytes + if (width_mmx) + { + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $2, %%esi \n\t" + "subl $14, %%edi \n\t" + + ".loop2_pass2: \n\t" + "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 + "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 + "movq %%mm0, %%mm1 \n\t" // 3 2 3 2 1 0 1 0 + "punpckldq %%mm0, %%mm0 \n\t" // 1 0 1 0 1 0 1 0 + "punpckhdq %%mm1, %%mm1 \n\t" // 3 2 3 2 3 2 3 2 + "movq %%mm0, (%%edi) \n\t" + "subl $4, %%esi \n\t" + "movq %%mm1, 8(%%edi) \n\t" + "subl $16, %%edi \n\t" + "subl $2, %%ecx \n\t" + "jnz .loop2_pass2 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width_mmx) // ecx + +#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" // clobber list +#endif + ); + } + + sptr -= (width_mmx*2 - 2); // sign fixed + dp -= (width_mmx*8 - 2); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + else if (width) // pass == 4 or 5 + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; // 0,1 pixels => 0,2 bytes + if (width_mmx) + { + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $2, %%esi \n\t" + "subl $6, %%edi \n\t" + + ".loop2_pass4: \n\t" + "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 + "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 + "subl $4, %%esi \n\t" + "movq %%mm0, (%%edi) \n\t" + "subl $8, %%edi \n\t" + "subl $2, %%ecx \n\t" + "jnz .loop2_pass4 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width_mmx) // ecx + +#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0" // clobber list +#endif + ); + } + + sptr -= (width_mmx*2 - 2); // sign fixed + dp -= (width_mmx*4 - 2); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + } /* end of pixel_bytes == 2 */ + + //-------------------------------------------------------------- + else if (pixel_bytes == 4) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 1) << 1); + width -= width_mmx; // 0,1 pixels => 0,4 bytes + if (width_mmx) + { + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $4, %%esi \n\t" + "subl $60, %%edi \n\t" + + ".loop4_pass0: \n\t" + "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 + "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 + "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 + "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 + "movq %%mm0, (%%edi) \n\t" + "movq %%mm0, 8(%%edi) \n\t" + "movq %%mm0, 16(%%edi) \n\t" + "movq %%mm0, 24(%%edi) \n\t" + "movq %%mm1, 32(%%edi) \n\t" + "movq %%mm1, 40(%%edi) \n\t" + "movq %%mm1, 48(%%edi) \n\t" + "subl $8, %%esi \n\t" + "movq %%mm1, 56(%%edi) \n\t" + "subl $64, %%edi \n\t" + "subl $2, %%ecx \n\t" + "jnz .loop4_pass0 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width_mmx) // ecx + +#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" // clobber list +#endif + ); + } + + sptr -= (width_mmx*4 - 4); // sign fixed + dp -= (width_mmx*32 - 4); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 1) << 1); + width -= width_mmx; // 0,1 pixels => 0,4 bytes + if (width_mmx) + { + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $4, %%esi \n\t" + "subl $28, %%edi \n\t" + + ".loop4_pass2: \n\t" + "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 + "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 + "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 + "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 + "movq %%mm0, (%%edi) \n\t" + "movq %%mm0, 8(%%edi) \n\t" + "movq %%mm1, 16(%%edi) \n\t" + "movq %%mm1, 24(%%edi) \n\t" + "subl $8, %%esi \n\t" + "subl $32, %%edi \n\t" + "subl $2, %%ecx \n\t" + "jnz .loop4_pass2 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width_mmx) // ecx + +#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" // clobber list +#endif + ); + } + + sptr -= (width_mmx*4 - 4); // sign fixed + dp -= (width_mmx*16 - 4); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + else if (width) // pass == 4 or 5 + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; // 0,1 pixels => 0,4 bytes + if (width_mmx) + { + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $4, %%esi \n\t" + "subl $12, %%edi \n\t" + + ".loop4_pass4: \n\t" + "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 + "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 + "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 + "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 + "movq %%mm0, (%%edi) \n\t" + "subl $8, %%esi \n\t" + "movq %%mm1, 8(%%edi) \n\t" + "subl $16, %%edi \n\t" + "subl $2, %%ecx \n\t" + "jnz .loop4_pass4 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width_mmx) // ecx + +#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" // clobber list +#endif + ); + } + + sptr -= (width_mmx*4 - 4); // sign fixed + dp -= (width_mmx*8 - 4); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + } /* end of pixel_bytes == 4 */ + + //-------------------------------------------------------------- + else if (pixel_bytes == 8) + { +// GRR TEST: should work, but needs testing (special 64-bit version of rpng2?) + // GRR NOTE: no need to combine passes here! + if (((pass == 0) || (pass == 1)) && width) + { + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + + // source is 8-byte RRGGBBAA + // dest is 64-byte RRGGBBAA RRGGBBAA RRGGBBAA RRGGBBAA ... + __asm__ __volatile__ ( + "subl $56, %%edi \n\t" // start of last block + + ".loop8_pass0: \n\t" + "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 + "movq %%mm0, (%%edi) \n\t" + "movq %%mm0, 8(%%edi) \n\t" + "movq %%mm0, 16(%%edi) \n\t" + "movq %%mm0, 24(%%edi) \n\t" + "movq %%mm0, 32(%%edi) \n\t" + "movq %%mm0, 40(%%edi) \n\t" + "movq %%mm0, 48(%%edi) \n\t" + "subl $8, %%esi \n\t" + "movq %%mm0, 56(%%edi) \n\t" + "subl $64, %%edi \n\t" + "decl %%ecx \n\t" + "jnz .loop8_pass0 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width) // ecx + +#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0" // clobber list +#endif + ); + } + else if (((pass == 2) || (pass == 3)) && width) + { + // source is 8-byte RRGGBBAA + // dest is 32-byte RRGGBBAA RRGGBBAA RRGGBBAA RRGGBBAA + // (recall that expansion is _in place_: sptr and dp + // both point at locations within same row buffer) + { + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $24, %%edi \n\t" // start of last block + + ".loop8_pass2: \n\t" + "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 + "movq %%mm0, (%%edi) \n\t" + "movq %%mm0, 8(%%edi) \n\t" + "movq %%mm0, 16(%%edi) \n\t" + "subl $8, %%esi \n\t" + "movq %%mm0, 24(%%edi) \n\t" + "subl $32, %%edi \n\t" + "decl %%ecx \n\t" + "jnz .loop8_pass2 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width) // ecx + +#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0" // clobber list +#endif + ); + } + } + else if (width) // pass == 4 or 5 + { + // source is 8-byte RRGGBBAA + // dest is 16-byte RRGGBBAA RRGGBBAA + { + int dummy_value_c; // fix 'forbidden register spilled' + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $8, %%edi \n\t" // start of last block + + ".loop8_pass4: \n\t" + "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 + "movq %%mm0, (%%edi) \n\t" + "subl $8, %%esi \n\t" + "movq %%mm0, 8(%%edi) \n\t" + "subl $16, %%edi \n\t" + "decl %%ecx \n\t" + "jnz .loop8_pass4 \n\t" + "EMMS \n\t" // DONE + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width) // ecx + +#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0" // clobber list +#endif + ); + } + } + + } /* end of pixel_bytes == 8 */ + + //-------------------------------------------------------------- + else if (pixel_bytes == 6) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 6); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 6); + dp -= 6; + } + sptr -= 6; + } + } /* end of pixel_bytes == 6 */ + + //-------------------------------------------------------------- + else + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr-= pixel_bytes; + } + } + } // end of _mmx_supported ======================================== + + else /* MMX not supported: use modified C code - takes advantage + * of inlining of png_memcpy for a constant */ + /* GRR 19991007: does it? or should pixel_bytes in each + * block be replaced with immediate value (e.g., 1)? */ + /* GRR 19991017: replaced with constants in each case */ +#endif /* PNG_MMX_CODE_SUPPORTED */ + { + if (pixel_bytes == 1) + { + for (i = width; i; i--) + { + int j; + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp-- = *sptr; + } + --sptr; + } + } + else if (pixel_bytes == 3) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 3); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 3); + dp -= 3; + } + sptr -= 3; + } + } + else if (pixel_bytes == 2) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 2); + dp -= 2; + } + sptr -= 2; + } + } + else if (pixel_bytes == 4) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { +#ifdef PNG_DEBUG + if (dp < row || dp+3 > row+png_ptr->row_buf_size) + { + printf("dp out of bounds: row=%d, dp=%d, rp=%d\n", + row, dp, row+png_ptr->row_buf_size); + printf("row_buf=%d\n",png_ptr->row_buf_size); + } +#endif + png_memcpy(dp, v, 4); + dp -= 4; + } + sptr -= 4; + } + } + else if (pixel_bytes == 6) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 6); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 6); + dp -= 6; + } + sptr -= 6; + } + } + else if (pixel_bytes == 8) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 8); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 8); + dp -= 8; + } + sptr -= 8; + } + } + else /* GRR: should never be reached */ + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + + } /* end if (MMX not supported) */ + break; + } + } /* end switch (row_info->pixel_depth) */ + + row_info->width = final_width; + + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); + } + +} /* end png_do_read_interlace() */ + +#endif /* PNG_HAVE_MMX_READ_INTERLACE */ +#endif /* PNG_READ_INTERLACING_SUPPORTED */ + + + +#if defined(PNG_HAVE_MMX_READ_FILTER_ROW) +#if defined(PNG_MMX_CODE_SUPPORTED) + +// These variables are utilized in the functions below. They are declared +// globally here to ensure alignment on 8-byte boundaries. + +union uAll { + long long use; + double align; +} _LBCarryMask = {0x0101010101010101LL}, + _HBClearMask = {0x7f7f7f7f7f7f7f7fLL}, + _ActiveMask, _ActiveMask2, _ActiveMaskEnd, _ShiftBpp, _ShiftRem; + +#ifdef PNG_THREAD_UNSAFE_OK +//===========================================================================// +// // +// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ A V G // +// // +//===========================================================================// + +// Optimized code for PNG Average filter decoder + +static void /* PRIVATE */ +png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row, + png_bytep prev_row) +{ + int bpp; + int dummy_value_c; // fix 'forbidden register 2 (cx) was spilled' error + int dummy_value_S; + int dummy_value_D; + + bpp = (row_info->pixel_depth + 7) >> 3; // get # bytes per pixel + _FullLength = row_info->rowbytes; // # of bytes to filter + + __asm__ __volatile__ ( + // initialize address pointers and offset +#ifdef __PIC__ + "pushl %%ebx \n\t" // save index to Global Offset Table +#endif +//pre "movl row, %%edi \n\t" // edi: Avg(x) + "xorl %%ebx, %%ebx \n\t" // ebx: x + "movl %%edi, %%edx \n\t" +//pre "movl prev_row, %%esi \n\t" // esi: Prior(x) +//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) + "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) + + "xorl %%eax,%%eax \n\t" + + // Compute the Raw value for the first bpp bytes + // Raw(x) = Avg(x) + (Prior(x)/2) + "avg_rlp: \n\t" + "movb (%%esi,%%ebx,),%%al \n\t" // load al with Prior(x) + "incl %%ebx \n\t" + "shrb %%al \n\t" // divide by 2 + "addb -1(%%edi,%%ebx,),%%al \n\t" // add Avg(x); -1 to offset inc ebx +//pre "cmpl bpp, %%ebx \n\t" // (bpp is preloaded into ecx) + "cmpl %%ecx, %%ebx \n\t" + "movb %%al,-1(%%edi,%%ebx,) \n\t" // write Raw(x); -1 to offset inc ebx + "jb avg_rlp \n\t" // mov does not affect flags + + // get # of bytes to alignment + "movl %%edi, _dif \n\t" // take start of row + "addl %%ebx, _dif \n\t" // add bpp + "addl $0xf, _dif \n\t" // add 7+8 to incr past alignment bdry + "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary + "subl %%edi, _dif \n\t" // subtract from start => value ebx at + "jz avg_go \n\t" // alignment + + // fix alignment + // Compute the Raw value for the bytes up to the alignment boundary + // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) + "xorl %%ecx, %%ecx \n\t" + + "avg_lp1: \n\t" + "xorl %%eax, %%eax \n\t" + "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) + "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) + "addw %%cx, %%ax \n\t" + "incl %%ebx \n\t" + "shrw %%ax \n\t" // divide by 2 + "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset inc ebx + "cmpl _dif, %%ebx \n\t" // check if at alignment boundary + "movb %%al, -1(%%edi,%%ebx,) \n\t" // write Raw(x); -1 to offset inc ebx + "jb avg_lp1 \n\t" // repeat until at alignment boundary + + "avg_go: \n\t" + "movl _FullLength, %%eax \n\t" + "movl %%eax, %%ecx \n\t" + "subl %%ebx, %%eax \n\t" // subtract alignment fix + "andl $0x00000007, %%eax \n\t" // calc bytes over mult of 8 + "subl %%eax, %%ecx \n\t" // drop over bytes from original length + "movl %%ecx, _MMXLength \n\t" +#ifdef __PIC__ + "popl %%ebx \n\t" // restore index to Global Offset Table +#endif + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "0" (bpp), // ecx // input regs + "1" (prev_row), // esi + "2" (row) // edi + + : "%eax", "%edx" // clobber list +#ifndef __PIC__ + , "%ebx" +#endif + // GRR: INCLUDE "memory" as clobbered? (_dif, _MMXLength) + // (seems to work fine without...) + ); + + // now do the math for the rest of the row + switch (bpp) + { + case 3: + { + _ActiveMask.use = 0x0000000000ffffffLL; + _ShiftBpp.use = 24; // == 3 * 8 + _ShiftRem.use = 40; // == 64 - 24 + + __asm__ __volatile__ ( + // re-init address pointers and offset + "movq _ActiveMask, %%mm7 \n\t" + "movl _dif, %%ecx \n\t" // ecx: x = offset to + "movq _LBCarryMask, %%mm5 \n\t" // alignment boundary +// preload "movl row, %%edi \n\t" // edi: Avg(x) + "movq _HBClearMask, %%mm4 \n\t" +// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) + + // prime the pump: load the first Raw(x-bpp) data set + "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes + // (correct pos. in loop below) + "avg_3lp: \n\t" + "movq (%%edi,%%ecx,), %%mm0 \n\t" // load mm0 with Avg(x) + "movq %%mm5, %%mm3 \n\t" + "psrlq _ShiftRem, %%mm2 \n\t" // correct position Raw(x-bpp) + // data + "movq (%%esi,%%ecx,), %%mm1 \n\t" // load mm1 with Prior(x) + "movq %%mm7, %%mm6 \n\t" + "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte + "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 + "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each + // byte + "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for + // each byte + // add 1st active group (Raw(x-bpp)/2) to average with LBCarry + "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting + // LBCarrys + "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte + // where both + // lsb's were == 1 (only valid for active group) + "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 + "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each + // byte + "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) + // for each byte + "pand %%mm6, %%mm2 \n\t" // leave only Active Group 1 + // bytes to add to Avg + "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to + // Avg for each Active + // byte + // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry + "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover + // bytes 3-5 + "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 + "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly + "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting + // LBCarrys + "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte + // where both + // lsb's were == 1 (only valid for active group) + "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 + "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each + // byte + "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) + // for each byte + "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 + // bytes to add to Avg + "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to + // Avg for each Active + // byte + + // add 3rd active group (Raw(x-bpp)/2) to average with _LBCarry + "psllq _ShiftBpp, %%mm6 \n\t" // shift mm6 mask to cover last + // two + // bytes + "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 + "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly + // Data only needs to be shifted once here to + // get the correct x-bpp offset. + "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting + // LBCarrys + "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte + // where both + // lsb's were == 1 (only valid for active group) + "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 + "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each + // byte + "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) + // for each byte + "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 + // bytes to add to Avg + "addl $8, %%ecx \n\t" + "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to + // Avg for each Active + // byte + // now ready to write back to memory + "movq %%mm0, -8(%%edi,%%ecx,) \n\t" + // move updated Raw(x) to use as Raw(x-bpp) for next loop + "cmpl _MMXLength, %%ecx \n\t" + "movq %%mm0, %%mm2 \n\t" // mov updated Raw(x) to mm2 + "jb avg_3lp \n\t" + + : "=S" (dummy_value_S), // output regs (dummy) + "=D" (dummy_value_D) + + : "0" (prev_row), // esi // input regs + "1" (row) // edi + + : "%ecx" // clobber list +#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; // end 3 bpp + + case 6: + case 4: + //case 7: // who wrote this? PNG doesn't support 5 or 7 bytes/pixel + //case 5: // GRR BOGUS + { + _ActiveMask.use = 0xffffffffffffffffLL; // use shift below to clear + // appropriate inactive bytes + _ShiftBpp.use = bpp << 3; + _ShiftRem.use = 64 - _ShiftBpp.use; + + __asm__ __volatile__ ( + "movq _HBClearMask, %%mm4 \n\t" + + // re-init address pointers and offset + "movl _dif, %%ecx \n\t" // ecx: x = offset to + // alignment boundary + + // load _ActiveMask and clear all bytes except for 1st active group + "movq _ActiveMask, %%mm7 \n\t" +// preload "movl row, %%edi \n\t" // edi: Avg(x) + "psrlq _ShiftRem, %%mm7 \n\t" +// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) + "movq %%mm7, %%mm6 \n\t" + "movq _LBCarryMask, %%mm5 \n\t" + "psllq _ShiftBpp, %%mm6 \n\t" // create mask for 2nd active + // group + + // prime the pump: load the first Raw(x-bpp) data set + "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes + // (we correct pos. in loop below) + "avg_4lp: \n\t" + "movq (%%edi,%%ecx,), %%mm0 \n\t" + "psrlq _ShiftRem, %%mm2 \n\t" // shift data to pos. correctly + "movq (%%esi,%%ecx,), %%mm1 \n\t" + // add (Prev_row/2) to average + "movq %%mm5, %%mm3 \n\t" + "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte + "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 + "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each + // byte + "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for + // each byte + // add 1st active group (Raw(x-bpp)/2) to average with _LBCarry + "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting + // LBCarrys + "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte + // where both + // lsb's were == 1 (only valid for active group) + "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 + "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each + // byte + "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) + // for each byte + "pand %%mm7, %%mm2 \n\t" // leave only Active Group 1 + // bytes to add to Avg + "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg + // for each Active + // byte + // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry + "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 + "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly + "addl $8, %%ecx \n\t" + "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting + // LBCarrys + "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte + // where both + // lsb's were == 1 (only valid for active group) + "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 + "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each + // byte + "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) + // for each byte + "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 + // bytes to add to Avg + "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to + // Avg for each Active + // byte + "cmpl _MMXLength, %%ecx \n\t" + // now ready to write back to memory + "movq %%mm0, -8(%%edi,%%ecx,) \n\t" + // prep Raw(x-bpp) for next loop + "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 + "jb avg_4lp \n\t" + + : "=S" (dummy_value_S), // output regs (dummy) + "=D" (dummy_value_D) + + : "0" (prev_row), // esi // input regs + "1" (row) // edi + + : "%ecx" // clobber list +#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; // end 4,6 bpp + + case 2: + { + _ActiveMask.use = 0x000000000000ffffLL; + _ShiftBpp.use = 16; // == 2 * 8 + _ShiftRem.use = 48; // == 64 - 16 + + __asm__ __volatile__ ( + // load _ActiveMask + "movq _ActiveMask, %%mm7 \n\t" + // re-init address pointers and offset + "movl _dif, %%ecx \n\t" // ecx: x = offset to alignment + // boundary + "movq _LBCarryMask, %%mm5 \n\t" +// preload "movl row, %%edi \n\t" // edi: Avg(x) + "movq _HBClearMask, %%mm4 \n\t" +// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) + + // prime the pump: load the first Raw(x-bpp) data set + "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes + // (we correct pos. in loop below) + "avg_2lp: \n\t" + "movq (%%edi,%%ecx,), %%mm0 \n\t" + "psrlq _ShiftRem, %%mm2 \n\t" // shift data to pos. correctly + "movq (%%esi,%%ecx,), %%mm1 \n\t" // (GRR BUGFIX: was psllq) + // add (Prev_row/2) to average + "movq %%mm5, %%mm3 \n\t" + "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte + "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 + "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each + // byte + "movq %%mm7, %%mm6 \n\t" + "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for + // each byte + + // add 1st active group (Raw(x-bpp)/2) to average with _LBCarry + "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting + // LBCarrys + "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte + // where both + // lsb's were == 1 (only valid + // for active group) + "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 + "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each + // byte + "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) + // for each byte + "pand %%mm6, %%mm2 \n\t" // leave only Active Group 1 + // bytes to add to Avg + "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg + // for each Active byte + + // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry + "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover + // bytes 2 & 3 + "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 + "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly + "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting + // LBCarrys + "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte + // where both + // lsb's were == 1 (only valid + // for active group) + "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 + "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each + // byte + "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) + // for each byte + "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 + // bytes to add to Avg + "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to + // Avg for each Active byte + + // add 3rd active group (Raw(x-bpp)/2) to average with _LBCarry + "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover + // bytes 4 & 5 + "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 + "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly + "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting + // LBCarrys + "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte + // where both lsb's were == 1 + // (only valid for active group) + "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 + "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each + // byte + "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) + // for each byte + "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 + // bytes to add to Avg + "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to + // Avg for each Active byte + + // add 4th active group (Raw(x-bpp)/2) to average with _LBCarry + "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover + // bytes 6 & 7 + "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 + "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly + "addl $8, %%ecx \n\t" + "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting + // LBCarrys + "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte + // where both + // lsb's were == 1 (only valid + // for active group) + "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 + "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each + // byte + "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) + // for each byte + "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 + // bytes to add to Avg + "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to + // Avg for each Active byte + + "cmpl _MMXLength, %%ecx \n\t" + // now ready to write back to memory + "movq %%mm0, -8(%%edi,%%ecx,) \n\t" + // prep Raw(x-bpp) for next loop + "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 + "jb avg_2lp \n\t" + + : "=S" (dummy_value_S), // output regs (dummy) + "=D" (dummy_value_D) + + : "0" (prev_row), // esi // input regs + "1" (row) // edi + + : "%ecx" // clobber list +#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; // end 2 bpp + + case 1: + { + __asm__ __volatile__ ( + // re-init address pointers and offset +#ifdef __PIC__ + "pushl %%ebx \n\t" // save Global Offset Table index +#endif + "movl _dif, %%ebx \n\t" // ebx: x = offset to alignment + // boundary +// preload "movl row, %%edi \n\t" // edi: Avg(x) + "cmpl _FullLength, %%ebx \n\t" // test if offset at end of array + "jnb avg_1end \n\t" + // do Paeth decode for remaining bytes +// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) + "movl %%edi, %%edx \n\t" +// preload "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) + "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) + "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx + // in loop below + "avg_1lp: \n\t" + // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) + "xorl %%eax, %%eax \n\t" + "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) + "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) + "addw %%cx, %%ax \n\t" + "incl %%ebx \n\t" + "shrw %%ax \n\t" // divide by 2 + "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset + // inc ebx + "cmpl _FullLength, %%ebx \n\t" // check if at end of array + "movb %%al, -1(%%edi,%%ebx,) \n\t" // write back Raw(x); + // mov does not affect flags; -1 to offset inc ebx + "jb avg_1lp \n\t" + + "avg_1end: \n\t" +#ifdef __PIC__ + "popl %%ebx \n\t" // Global Offset Table index +#endif + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "0" (bpp), // ecx // input regs + "1" (prev_row), // esi + "2" (row) // edi + + : "%eax", "%edx" // clobber list +#ifndef __PIC__ + , "%ebx" +#endif + ); + } + return; // end 1 bpp + + case 8: + { + __asm__ __volatile__ ( + // re-init address pointers and offset + "movl _dif, %%ecx \n\t" // ecx: x == offset to alignment + "movq _LBCarryMask, %%mm5 \n\t" // boundary +// preload "movl row, %%edi \n\t" // edi: Avg(x) + "movq _HBClearMask, %%mm4 \n\t" +// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) + + // prime the pump: load the first Raw(x-bpp) data set + "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes + // (NO NEED to correct pos. in loop below) + + "avg_8lp: \n\t" + "movq (%%edi,%%ecx,), %%mm0 \n\t" + "movq %%mm5, %%mm3 \n\t" + "movq (%%esi,%%ecx,), %%mm1 \n\t" + "addl $8, %%ecx \n\t" + "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte + "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 + "pand %%mm2, %%mm3 \n\t" // get LBCarrys for each byte + // where both lsb's were == 1 + "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 + "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7, each byte + "paddb %%mm3, %%mm0 \n\t" // add LBCarrys to Avg, each byte + "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7, each byte + "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg, each + "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) to Avg for each + "cmpl _MMXLength, %%ecx \n\t" + "movq %%mm0, -8(%%edi,%%ecx,) \n\t" + "movq %%mm0, %%mm2 \n\t" // reuse as Raw(x-bpp) + "jb avg_8lp \n\t" + + : "=S" (dummy_value_S), // output regs (dummy) + "=D" (dummy_value_D) + + : "0" (prev_row), // esi // input regs + "1" (row) // edi + + : "%ecx" // clobber list +#if 0 /* %mm0, ..., %mm5 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2" + , "%mm3", "%mm4", "%mm5" +#endif + ); + } + break; // end 8 bpp + + default: // bpp greater than 8 (!= 1,2,3,4,[5],6,[7],8) + { + +#ifdef PNG_DEBUG + // GRR: PRINT ERROR HERE: SHOULD NEVER BE REACHED + png_debug(1, + "Internal logic error in pnggccrd (png_read_filter_row_mmx_avg())\n"); +#endif + +#if 0 + __asm__ __volatile__ ( + "movq _LBCarryMask, %%mm5 \n\t" + // re-init address pointers and offset + "movl _dif, %%ebx \n\t" // ebx: x = offset to + // alignment boundary + "movl row, %%edi \n\t" // edi: Avg(x) + "movq _HBClearMask, %%mm4 \n\t" + "movl %%edi, %%edx \n\t" + "movl prev_row, %%esi \n\t" // esi: Prior(x) + "subl bpp, %%edx \n\t" // edx: Raw(x-bpp) + "avg_Alp: \n\t" + "movq (%%edi,%%ebx,), %%mm0 \n\t" + "movq %%mm5, %%mm3 \n\t" + "movq (%%esi,%%ebx,), %%mm1 \n\t" + "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte + "movq (%%edx,%%ebx,), %%mm2 \n\t" + "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 + "pand %%mm2, %%mm3 \n\t" // get LBCarrys for each byte + // where both lsb's were == 1 + "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 + "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each + // byte + "paddb %%mm3, %%mm0 \n\t" // add LBCarrys to Avg for each + // byte + "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each + // byte + "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for + // each byte + "addl $8, %%ebx \n\t" + "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) to Avg for each + // byte + "cmpl _MMXLength, %%ebx \n\t" + "movq %%mm0, -8(%%edi,%%ebx,) \n\t" + "jb avg_Alp \n\t" + + : // FIXASM: output regs/vars go here, e.g.: "=m" (memory_var) + + : // FIXASM: input regs, e.g.: "c" (count), "S" (src), "D" (dest) + + : "%ebx", "%edx", "%edi", "%esi" // CHECKASM: clobber list + ); +#endif /* 0 - NEVER REACHED */ + } + break; + + } // end switch (bpp) + + __asm__ __volatile__ ( + // MMX acceleration complete; now do clean-up + // check if any remaining bytes left to decode +#ifdef __PIC__ + "pushl %%ebx \n\t" // save index to Global Offset Table +#endif + "movl _MMXLength, %%ebx \n\t" // ebx: x == offset bytes after MMX +//pre "movl row, %%edi \n\t" // edi: Avg(x) + "cmpl _FullLength, %%ebx \n\t" // test if offset at end of array + "jnb avg_end \n\t" + + // do Avg decode for remaining bytes +//pre "movl prev_row, %%esi \n\t" // esi: Prior(x) + "movl %%edi, %%edx \n\t" +//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) + "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) + "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx below + + "avg_lp2: \n\t" + // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) + "xorl %%eax, %%eax \n\t" + "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) + "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) + "addw %%cx, %%ax \n\t" + "incl %%ebx \n\t" + "shrw %%ax \n\t" // divide by 2 + "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset inc ebx + "cmpl _FullLength, %%ebx \n\t" // check if at end of array + "movb %%al, -1(%%edi,%%ebx,) \n\t" // write back Raw(x) [mov does not + "jb avg_lp2 \n\t" // affect flags; -1 to offset inc ebx] + + "avg_end: \n\t" + "EMMS \n\t" // end MMX; prep for poss. FP instrs. +#ifdef __PIC__ + "popl %%ebx \n\t" // restore index to Global Offset Table +#endif + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "0" (bpp), // ecx // input regs + "1" (prev_row), // esi + "2" (row) // edi + + : "%eax", "%edx" // clobber list +#ifndef __PIC__ + , "%ebx" +#endif + ); + +} /* end png_read_filter_row_mmx_avg() */ +#endif + + + +#ifdef PNG_THREAD_UNSAFE_OK +//===========================================================================// +// // +// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ P A E T H // +// // +//===========================================================================// + +// Optimized code for PNG Paeth filter decoder + +static void /* PRIVATE */ +png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, + png_bytep prev_row) +{ + int bpp; + int dummy_value_c; // fix 'forbidden register 2 (cx) was spilled' error + int dummy_value_S; + int dummy_value_D; + + bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel + _FullLength = row_info->rowbytes; // # of bytes to filter + + __asm__ __volatile__ ( +#ifdef __PIC__ + "pushl %%ebx \n\t" // save index to Global Offset Table +#endif + "xorl %%ebx, %%ebx \n\t" // ebx: x offset +//pre "movl row, %%edi \n\t" + "xorl %%edx, %%edx \n\t" // edx: x-bpp offset +//pre "movl prev_row, %%esi \n\t" + "xorl %%eax, %%eax \n\t" + + // Compute the Raw value for the first bpp bytes + // Note: the formula works out to be always + // Paeth(x) = Raw(x) + Prior(x) where x < bpp + "paeth_rlp: \n\t" + "movb (%%edi,%%ebx,), %%al \n\t" + "addb (%%esi,%%ebx,), %%al \n\t" + "incl %%ebx \n\t" +//pre "cmpl bpp, %%ebx \n\t" (bpp is preloaded into ecx) + "cmpl %%ecx, %%ebx \n\t" + "movb %%al, -1(%%edi,%%ebx,) \n\t" + "jb paeth_rlp \n\t" + // get # of bytes to alignment + "movl %%edi, _dif \n\t" // take start of row + "addl %%ebx, _dif \n\t" // add bpp + "xorl %%ecx, %%ecx \n\t" + "addl $0xf, _dif \n\t" // add 7 + 8 to incr past alignment + // boundary + "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary + "subl %%edi, _dif \n\t" // subtract from start ==> value ebx + // at alignment + "jz paeth_go \n\t" + // fix alignment + + "paeth_lp1: \n\t" + "xorl %%eax, %%eax \n\t" + // pav = p - a = (a + b - c) - a = b - c + "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al + "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl + "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) + "movl %%eax, _patemp \n\t" // Save pav for later use + "xorl %%eax, %%eax \n\t" + // pbv = p - b = (a + b - c) - b = a - c + "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al + "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) + "movl %%eax, %%ecx \n\t" + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + "addl _patemp, %%eax \n\t" // pcv = pav + pbv + // pc = abs(pcv) + "testl $0x80000000, %%eax \n\t" + "jz paeth_pca \n\t" + "negl %%eax \n\t" // reverse sign of neg values + + "paeth_pca: \n\t" + "movl %%eax, _pctemp \n\t" // save pc for later use + // pb = abs(pbv) + "testl $0x80000000, %%ecx \n\t" + "jz paeth_pba \n\t" + "negl %%ecx \n\t" // reverse sign of neg values + + "paeth_pba: \n\t" + "movl %%ecx, _pbtemp \n\t" // save pb for later use + // pa = abs(pav) + "movl _patemp, %%eax \n\t" + "testl $0x80000000, %%eax \n\t" + "jz paeth_paa \n\t" + "negl %%eax \n\t" // reverse sign of neg values + + "paeth_paa: \n\t" + "movl %%eax, _patemp \n\t" // save pa for later use + // test if pa <= pb + "cmpl %%ecx, %%eax \n\t" + "jna paeth_abb \n\t" + // pa > pb; now test if pb <= pc + "cmpl _pctemp, %%ecx \n\t" + "jna paeth_bbc \n\t" + // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl + "jmp paeth_paeth \n\t" + + "paeth_bbc: \n\t" + // pb <= pc; Raw(x) = Paeth(x) + Prior(x) + "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl + "jmp paeth_paeth \n\t" + + "paeth_abb: \n\t" + // pa <= pb; now test if pa <= pc + "cmpl _pctemp, %%eax \n\t" + "jna paeth_abc \n\t" + // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl + "jmp paeth_paeth \n\t" + + "paeth_abc: \n\t" + // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) + "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl + + "paeth_paeth: \n\t" + "incl %%ebx \n\t" + "incl %%edx \n\t" + // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 + "addb %%cl, -1(%%edi,%%ebx,) \n\t" + "cmpl _dif, %%ebx \n\t" + "jb paeth_lp1 \n\t" + + "paeth_go: \n\t" + "movl _FullLength, %%ecx \n\t" + "movl %%ecx, %%eax \n\t" + "subl %%ebx, %%eax \n\t" // subtract alignment fix + "andl $0x00000007, %%eax \n\t" // calc bytes over mult of 8 + "subl %%eax, %%ecx \n\t" // drop over bytes from original length + "movl %%ecx, _MMXLength \n\t" +#ifdef __PIC__ + "popl %%ebx \n\t" // restore index to Global Offset Table +#endif + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "0" (bpp), // ecx // input regs + "1" (prev_row), // esi + "2" (row) // edi + + : "%eax", "%edx" // clobber list +#ifndef __PIC__ + , "%ebx" +#endif + ); + + // now do the math for the rest of the row + switch (bpp) + { + case 3: + { + _ActiveMask.use = 0x0000000000ffffffLL; + _ActiveMaskEnd.use = 0xffff000000000000LL; + _ShiftBpp.use = 24; // == bpp(3) * 8 + _ShiftRem.use = 40; // == 64 - 24 + + __asm__ __volatile__ ( + "movl _dif, %%ecx \n\t" +// preload "movl row, %%edi \n\t" +// preload "movl prev_row, %%esi \n\t" + "pxor %%mm0, %%mm0 \n\t" + // prime the pump: load the first Raw(x-bpp) data set + "movq -8(%%edi,%%ecx,), %%mm1 \n\t" + "paeth_3lp: \n\t" + "psrlq _ShiftRem, %%mm1 \n\t" // shift last 3 bytes to 1st + // 3 bytes + "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) + "punpcklbw %%mm0, %%mm1 \n\t" // unpack High bytes of a + "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // prep c=Prior(x-bpp) bytes + "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b + "psrlq _ShiftRem, %%mm3 \n\t" // shift last 3 bytes to 1st + // 3 bytes + // pav = p - a = (a + b - c) - a = b - c + "movq %%mm2, %%mm4 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c + // pbv = p - b = (a + b - c) - b = a - c + "movq %%mm1, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + "pxor %%mm7, %%mm7 \n\t" + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 + "paddw %%mm5, %%mm6 \n\t" + "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 + "psubw %%mm0, %%mm4 \n\t" + "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 + "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm6 \n\t" + // test pa <= pb + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? + "movq %%mm7, %%mm0 \n\t" + // use mm7 mask to merge pa & pb + "pand %%mm7, %%mm5 \n\t" + // use mm0 mask copy to merge a & b + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + // test ((pa <= pb)? pa:pb) <= pc + "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? + "pxor %%mm1, %%mm1 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "packuswb %%mm1, %%mm7 \n\t" + "movq (%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) + "pand _ActiveMask, %%mm7 \n\t" + "movq %%mm3, %%mm2 \n\t" // load b=Prior(x) step 1 + "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) + "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c + "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value + "movq %%mm7, %%mm1 \n\t" // now mm1 will be used as + // Raw(x-bpp) + // now do Paeth for 2nd set of bytes (3-5) + "psrlq _ShiftBpp, %%mm2 \n\t" // load b=Prior(x) step 2 + "punpcklbw %%mm0, %%mm1 \n\t" // unpack High bytes of a + "pxor %%mm7, %%mm7 \n\t" + "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b + // pbv = p - b = (a + b - c) - b = a - c + "movq %%mm1, %%mm5 \n\t" + // pav = p - a = (a + b - c) - a = b - c + "movq %%mm2, %%mm4 \n\t" + "psubw %%mm3, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = + // pav + pbv = pbv + pav + "movq %%mm5, %%mm6 \n\t" + "paddw %%mm4, %%mm6 \n\t" + + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + "pcmpgtw %%mm5, %%mm0 \n\t" // create mask pbv bytes < 0 + "pcmpgtw %%mm4, %%mm7 \n\t" // create mask pav bytes < 0 + "pand %%mm5, %%mm0 \n\t" // only pbv bytes < 0 in mm0 + "pand %%mm4, %%mm7 \n\t" // only pav bytes < 0 in mm7 + "psubw %%mm0, %%mm5 \n\t" + "psubw %%mm7, %%mm4 \n\t" + "psubw %%mm0, %%mm5 \n\t" + "psubw %%mm7, %%mm4 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 + "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "psubw %%mm0, %%mm6 \n\t" + // test pa <= pb + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? + "movq %%mm7, %%mm0 \n\t" + // use mm7 mask to merge pa & pb + "pand %%mm7, %%mm5 \n\t" + // use mm0 mask copy to merge a & b + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + // test ((pa <= pb)? pa:pb) <= pc + "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? + "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "pxor %%mm1, %%mm1 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "packuswb %%mm1, %%mm7 \n\t" + "movq %%mm2, %%mm3 \n\t" // load c=Prior(x-bpp) step 1 + "pand _ActiveMask, %%mm7 \n\t" + "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b + "psllq _ShiftBpp, %%mm7 \n\t" // shift bytes to 2nd group of + // 3 bytes + // pav = p - a = (a + b - c) - a = b - c + "movq %%mm2, %%mm4 \n\t" + "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) + "psllq _ShiftBpp, %%mm3 \n\t" // load c=Prior(x-bpp) step 2 + "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value + "movq %%mm7, %%mm1 \n\t" + "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c + "psllq _ShiftBpp, %%mm1 \n\t" // shift bytes + // now mm1 will be used as Raw(x-bpp) + // now do Paeth for 3rd, and final, set of bytes (6-7) + "pxor %%mm7, %%mm7 \n\t" + "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a + "psubw %%mm3, %%mm4 \n\t" + // pbv = p - b = (a + b - c) - b = a - c + "movq %%mm1, %%mm5 \n\t" + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "paddw %%mm5, %%mm6 \n\t" + + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 + "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 + "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 + "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "psubw %%mm0, %%mm6 \n\t" + // test pa <= pb + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? + "movq %%mm7, %%mm0 \n\t" + // use mm0 mask copy to merge a & b + "pand %%mm0, %%mm2 \n\t" + // use mm7 mask to merge pa & pb + "pand %%mm7, %%mm5 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + // test ((pa <= pb)? pa:pb) <= pc + "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm1, %%mm1 \n\t" + "packuswb %%mm7, %%mm1 \n\t" + // step ecx to next set of 8 bytes and repeat loop til done + "addl $8, %%ecx \n\t" + "pand _ActiveMaskEnd, %%mm1 \n\t" + "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with + // Raw(x) + + "cmpl _MMXLength, %%ecx \n\t" + "pxor %%mm0, %%mm0 \n\t" // pxor does not affect flags + "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value + // mm1 will be used as Raw(x-bpp) next loop + // mm3 ready to be used as Prior(x-bpp) next loop + "jb paeth_3lp \n\t" + + : "=S" (dummy_value_S), // output regs (dummy) + "=D" (dummy_value_D) + + : "0" (prev_row), // esi // input regs + "1" (row) // edi + + : "%ecx" // clobber list +#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; // end 3 bpp + + case 6: + //case 7: // GRR BOGUS + //case 5: // GRR BOGUS + { + _ActiveMask.use = 0x00000000ffffffffLL; + _ActiveMask2.use = 0xffffffff00000000LL; + _ShiftBpp.use = bpp << 3; // == bpp * 8 + _ShiftRem.use = 64 - _ShiftBpp.use; + + __asm__ __volatile__ ( + "movl _dif, %%ecx \n\t" +// preload "movl row, %%edi \n\t" +// preload "movl prev_row, %%esi \n\t" + // prime the pump: load the first Raw(x-bpp) data set + "movq -8(%%edi,%%ecx,), %%mm1 \n\t" + "pxor %%mm0, %%mm0 \n\t" + + "paeth_6lp: \n\t" + // must shift to position Raw(x-bpp) data + "psrlq _ShiftRem, %%mm1 \n\t" + // do first set of 4 bytes + "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes + "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a + "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) + "punpcklbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b + // must shift to position Prior(x-bpp) data + "psrlq _ShiftRem, %%mm3 \n\t" + // pav = p - a = (a + b - c) - a = b - c + "movq %%mm2, %%mm4 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" // unpack Low bytes of c + // pbv = p - b = (a + b - c) - b = a - c + "movq %%mm1, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + "pxor %%mm7, %%mm7 \n\t" + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 + "paddw %%mm5, %%mm6 \n\t" + "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 + "psubw %%mm0, %%mm4 \n\t" + "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 + "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm6 \n\t" + // test pa <= pb + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? + "movq %%mm7, %%mm0 \n\t" + // use mm7 mask to merge pa & pb + "pand %%mm7, %%mm5 \n\t" + // use mm0 mask copy to merge a & b + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + // test ((pa <= pb)? pa:pb) <= pc + "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? + "pxor %%mm1, %%mm1 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "packuswb %%mm1, %%mm7 \n\t" + "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) + "pand _ActiveMask, %%mm7 \n\t" + "psrlq _ShiftRem, %%mm3 \n\t" + "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) step 1 + "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor and Raw(x) + "movq %%mm2, %%mm6 \n\t" + "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value + "movq -8(%%edi,%%ecx,), %%mm1 \n\t" + "psllq _ShiftBpp, %%mm6 \n\t" + "movq %%mm7, %%mm5 \n\t" + "psrlq _ShiftRem, %%mm1 \n\t" + "por %%mm6, %%mm3 \n\t" + "psllq _ShiftBpp, %%mm5 \n\t" + "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c + "por %%mm5, %%mm1 \n\t" + // do second set of 4 bytes + "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b + "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a + // pav = p - a = (a + b - c) - a = b - c + "movq %%mm2, %%mm4 \n\t" + // pbv = p - b = (a + b - c) - b = a - c + "movq %%mm1, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + "pxor %%mm7, %%mm7 \n\t" + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 + "paddw %%mm5, %%mm6 \n\t" + "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 + "psubw %%mm0, %%mm4 \n\t" + "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 + "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm6 \n\t" + // test pa <= pb + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? + "movq %%mm7, %%mm0 \n\t" + // use mm7 mask to merge pa & pb + "pand %%mm7, %%mm5 \n\t" + // use mm0 mask copy to merge a & b + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + // test ((pa <= pb)? pa:pb) <= pc + "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? + "pxor %%mm1, %%mm1 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "pxor %%mm1, %%mm1 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + // step ecx to next set of 8 bytes and repeat loop til done + "addl $8, %%ecx \n\t" + "packuswb %%mm7, %%mm1 \n\t" + "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with Raw(x) + "cmpl _MMXLength, %%ecx \n\t" + "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value + // mm1 will be used as Raw(x-bpp) next loop + "jb paeth_6lp \n\t" + + : "=S" (dummy_value_S), // output regs (dummy) + "=D" (dummy_value_D) + + : "0" (prev_row), // esi // input regs + "1" (row) // edi + + : "%ecx" // clobber list +#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; // end 6 bpp + + case 4: + { + _ActiveMask.use = 0x00000000ffffffffLL; + + __asm__ __volatile__ ( + "movl _dif, %%ecx \n\t" +// preload "movl row, %%edi \n\t" +// preload "movl prev_row, %%esi \n\t" + "pxor %%mm0, %%mm0 \n\t" + // prime the pump: load the first Raw(x-bpp) data set + "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // only time should need to read + // a=Raw(x-bpp) bytes + "paeth_4lp: \n\t" + // do first set of 4 bytes + "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes + "punpckhbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a + "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) + "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b + // pav = p - a = (a + b - c) - a = b - c + "movq %%mm2, %%mm4 \n\t" + "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c + // pbv = p - b = (a + b - c) - b = a - c + "movq %%mm1, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + "pxor %%mm7, %%mm7 \n\t" + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 + "paddw %%mm5, %%mm6 \n\t" + "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 + "psubw %%mm0, %%mm4 \n\t" + "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 + "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm6 \n\t" + // test pa <= pb + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? + "movq %%mm7, %%mm0 \n\t" + // use mm7 mask to merge pa & pb + "pand %%mm7, %%mm5 \n\t" + // use mm0 mask copy to merge a & b + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + // test ((pa <= pb)? pa:pb) <= pc + "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? + "pxor %%mm1, %%mm1 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "packuswb %%mm1, %%mm7 \n\t" + "movq (%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) + "pand _ActiveMask, %%mm7 \n\t" + "movq %%mm3, %%mm2 \n\t" // load b=Prior(x) step 1 + "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) + "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c + "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value + "movq %%mm7, %%mm1 \n\t" // now mm1 will be used as Raw(x-bpp) + // do second set of 4 bytes + "punpckhbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b + "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a + // pav = p - a = (a + b - c) - a = b - c + "movq %%mm2, %%mm4 \n\t" + // pbv = p - b = (a + b - c) - b = a - c + "movq %%mm1, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + "pxor %%mm7, %%mm7 \n\t" + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 + "paddw %%mm5, %%mm6 \n\t" + "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 + "psubw %%mm0, %%mm4 \n\t" + "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 + "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm6 \n\t" + // test pa <= pb + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? + "movq %%mm7, %%mm0 \n\t" + // use mm7 mask to merge pa & pb + "pand %%mm7, %%mm5 \n\t" + // use mm0 mask copy to merge a & b + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + // test ((pa <= pb)? pa:pb) <= pc + "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? + "pxor %%mm1, %%mm1 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "pxor %%mm1, %%mm1 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + // step ecx to next set of 8 bytes and repeat loop til done + "addl $8, %%ecx \n\t" + "packuswb %%mm7, %%mm1 \n\t" + "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add predictor with Raw(x) + "cmpl _MMXLength, %%ecx \n\t" + "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value + // mm1 will be used as Raw(x-bpp) next loop + "jb paeth_4lp \n\t" + + : "=S" (dummy_value_S), // output regs (dummy) + "=D" (dummy_value_D) + + : "0" (prev_row), // esi // input regs + "1" (row) // edi + + : "%ecx" // clobber list +#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; // end 4 bpp + + case 8: // bpp == 8 + { + _ActiveMask.use = 0x00000000ffffffffLL; + + __asm__ __volatile__ ( + "movl _dif, %%ecx \n\t" +// preload "movl row, %%edi \n\t" +// preload "movl prev_row, %%esi \n\t" + "pxor %%mm0, %%mm0 \n\t" + // prime the pump: load the first Raw(x-bpp) data set + "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // only time should need to read + // a=Raw(x-bpp) bytes + "paeth_8lp: \n\t" + // do first set of 4 bytes + "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes + "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a + "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) + "punpcklbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b + // pav = p - a = (a + b - c) - a = b - c + "movq %%mm2, %%mm4 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" // unpack Low bytes of c + // pbv = p - b = (a + b - c) - b = a - c + "movq %%mm1, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + "pxor %%mm7, %%mm7 \n\t" + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 + "paddw %%mm5, %%mm6 \n\t" + "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 + "psubw %%mm0, %%mm4 \n\t" + "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 + "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm6 \n\t" + // test pa <= pb + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? + "movq %%mm7, %%mm0 \n\t" + // use mm7 mask to merge pa & pb + "pand %%mm7, %%mm5 \n\t" + // use mm0 mask copy to merge a & b + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + // test ((pa <= pb)? pa:pb) <= pc + "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? + "pxor %%mm1, %%mm1 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "packuswb %%mm1, %%mm7 \n\t" + "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes + "pand _ActiveMask, %%mm7 \n\t" + "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) + "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) + "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c + "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value + "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // read a=Raw(x-bpp) bytes + + // do second set of 4 bytes + "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b + "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a + // pav = p - a = (a + b - c) - a = b - c + "movq %%mm2, %%mm4 \n\t" + // pbv = p - b = (a + b - c) - b = a - c + "movq %%mm1, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + "pxor %%mm7, %%mm7 \n\t" + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 + "paddw %%mm5, %%mm6 \n\t" + "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 + "psubw %%mm0, %%mm4 \n\t" + "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 + "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm6 \n\t" + // test pa <= pb + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? + "movq %%mm7, %%mm0 \n\t" + // use mm7 mask to merge pa & pb + "pand %%mm7, %%mm5 \n\t" + // use mm0 mask copy to merge a & b + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + // test ((pa <= pb)? pa:pb) <= pc + "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? + "pxor %%mm1, %%mm1 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "pxor %%mm1, %%mm1 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + // step ecx to next set of 8 bytes and repeat loop til done + "addl $8, %%ecx \n\t" + "packuswb %%mm7, %%mm1 \n\t" + "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with Raw(x) + "cmpl _MMXLength, %%ecx \n\t" + "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value + // mm1 will be used as Raw(x-bpp) next loop + "jb paeth_8lp \n\t" + + : "=S" (dummy_value_S), // output regs (dummy) + "=D" (dummy_value_D) + + : "0" (prev_row), // esi // input regs + "1" (row) // edi + + : "%ecx" // clobber list +#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; // end 8 bpp + + case 1: // bpp = 1 + case 2: // bpp = 2 + default: // bpp > 8 + { + __asm__ __volatile__ ( +#ifdef __PIC__ + "pushl %%ebx \n\t" // save Global Offset Table index +#endif + "movl _dif, %%ebx \n\t" + "cmpl _FullLength, %%ebx \n\t" + "jnb paeth_dend \n\t" + +// preload "movl row, %%edi \n\t" +// preload "movl prev_row, %%esi \n\t" + // do Paeth decode for remaining bytes + "movl %%ebx, %%edx \n\t" +// preload "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) + "subl %%ecx, %%edx \n\t" // edx = ebx - bpp + "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx + + "paeth_dlp: \n\t" + "xorl %%eax, %%eax \n\t" + // pav = p - a = (a + b - c) - a = b - c + "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al + "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl + "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) + "movl %%eax, _patemp \n\t" // Save pav for later use + "xorl %%eax, %%eax \n\t" + // pbv = p - b = (a + b - c) - b = a - c + "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al + "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) + "movl %%eax, %%ecx \n\t" + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + "addl _patemp, %%eax \n\t" // pcv = pav + pbv + // pc = abs(pcv) + "testl $0x80000000, %%eax \n\t" + "jz paeth_dpca \n\t" + "negl %%eax \n\t" // reverse sign of neg values + + "paeth_dpca: \n\t" + "movl %%eax, _pctemp \n\t" // save pc for later use + // pb = abs(pbv) + "testl $0x80000000, %%ecx \n\t" + "jz paeth_dpba \n\t" + "negl %%ecx \n\t" // reverse sign of neg values + + "paeth_dpba: \n\t" + "movl %%ecx, _pbtemp \n\t" // save pb for later use + // pa = abs(pav) + "movl _patemp, %%eax \n\t" + "testl $0x80000000, %%eax \n\t" + "jz paeth_dpaa \n\t" + "negl %%eax \n\t" // reverse sign of neg values + + "paeth_dpaa: \n\t" + "movl %%eax, _patemp \n\t" // save pa for later use + // test if pa <= pb + "cmpl %%ecx, %%eax \n\t" + "jna paeth_dabb \n\t" + // pa > pb; now test if pb <= pc + "cmpl _pctemp, %%ecx \n\t" + "jna paeth_dbbc \n\t" + // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl + "jmp paeth_dpaeth \n\t" + + "paeth_dbbc: \n\t" + // pb <= pc; Raw(x) = Paeth(x) + Prior(x) + "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl + "jmp paeth_dpaeth \n\t" + + "paeth_dabb: \n\t" + // pa <= pb; now test if pa <= pc + "cmpl _pctemp, %%eax \n\t" + "jna paeth_dabc \n\t" + // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl + "jmp paeth_dpaeth \n\t" + + "paeth_dabc: \n\t" + // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) + "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl + + "paeth_dpaeth: \n\t" + "incl %%ebx \n\t" + "incl %%edx \n\t" + // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 + "addb %%cl, -1(%%edi,%%ebx,) \n\t" + "cmpl _FullLength, %%ebx \n\t" + "jb paeth_dlp \n\t" + + "paeth_dend: \n\t" +#ifdef __PIC__ + "popl %%ebx \n\t" // index to Global Offset Table +#endif + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "0" (bpp), // ecx // input regs + "1" (prev_row), // esi + "2" (row) // edi + + : "%eax", "%edx" // clobber list +#ifndef __PIC__ + , "%ebx" +#endif + ); + } + return; // No need to go further with this one + + } // end switch (bpp) + + __asm__ __volatile__ ( + // MMX acceleration complete; now do clean-up + // check if any remaining bytes left to decode +#ifdef __PIC__ + "pushl %%ebx \n\t" // save index to Global Offset Table +#endif + "movl _MMXLength, %%ebx \n\t" + "cmpl _FullLength, %%ebx \n\t" + "jnb paeth_end \n\t" +//pre "movl row, %%edi \n\t" +//pre "movl prev_row, %%esi \n\t" + // do Paeth decode for remaining bytes + "movl %%ebx, %%edx \n\t" +//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) + "subl %%ecx, %%edx \n\t" // edx = ebx - bpp + "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx below + + "paeth_lp2: \n\t" + "xorl %%eax, %%eax \n\t" + // pav = p - a = (a + b - c) - a = b - c + "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al + "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl + "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) + "movl %%eax, _patemp \n\t" // Save pav for later use + "xorl %%eax, %%eax \n\t" + // pbv = p - b = (a + b - c) - b = a - c + "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al + "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) + "movl %%eax, %%ecx \n\t" + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + "addl _patemp, %%eax \n\t" // pcv = pav + pbv + // pc = abs(pcv) + "testl $0x80000000, %%eax \n\t" + "jz paeth_pca2 \n\t" + "negl %%eax \n\t" // reverse sign of neg values + + "paeth_pca2: \n\t" + "movl %%eax, _pctemp \n\t" // save pc for later use + // pb = abs(pbv) + "testl $0x80000000, %%ecx \n\t" + "jz paeth_pba2 \n\t" + "negl %%ecx \n\t" // reverse sign of neg values + + "paeth_pba2: \n\t" + "movl %%ecx, _pbtemp \n\t" // save pb for later use + // pa = abs(pav) + "movl _patemp, %%eax \n\t" + "testl $0x80000000, %%eax \n\t" + "jz paeth_paa2 \n\t" + "negl %%eax \n\t" // reverse sign of neg values + + "paeth_paa2: \n\t" + "movl %%eax, _patemp \n\t" // save pa for later use + // test if pa <= pb + "cmpl %%ecx, %%eax \n\t" + "jna paeth_abb2 \n\t" + // pa > pb; now test if pb <= pc + "cmpl _pctemp, %%ecx \n\t" + "jna paeth_bbc2 \n\t" + // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl + "jmp paeth_paeth2 \n\t" + + "paeth_bbc2: \n\t" + // pb <= pc; Raw(x) = Paeth(x) + Prior(x) + "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl + "jmp paeth_paeth2 \n\t" + + "paeth_abb2: \n\t" + // pa <= pb; now test if pa <= pc + "cmpl _pctemp, %%eax \n\t" + "jna paeth_abc2 \n\t" + // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl + "jmp paeth_paeth2 \n\t" + + "paeth_abc2: \n\t" + // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) + "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl + + "paeth_paeth2: \n\t" + "incl %%ebx \n\t" + "incl %%edx \n\t" + // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 + "addb %%cl, -1(%%edi,%%ebx,) \n\t" + "cmpl _FullLength, %%ebx \n\t" + "jb paeth_lp2 \n\t" + + "paeth_end: \n\t" + "EMMS \n\t" // end MMX; prep for poss. FP instrs. +#ifdef __PIC__ + "popl %%ebx \n\t" // restore index to Global Offset Table +#endif + + : "=c" (dummy_value_c), // output regs (dummy) + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "0" (bpp), // ecx // input regs + "1" (prev_row), // esi + "2" (row) // edi + + : "%eax", "%edx" // clobber list (no input regs!) +#ifndef __PIC__ + , "%ebx" +#endif + ); + +} /* end png_read_filter_row_mmx_paeth() */ +#endif + + + + +#ifdef PNG_THREAD_UNSAFE_OK +//===========================================================================// +// // +// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ S U B // +// // +//===========================================================================// + +// Optimized code for PNG Sub filter decoder + +static void /* PRIVATE */ +png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) +{ + int bpp; + int dummy_value_a; + int dummy_value_D; + + bpp = (row_info->pixel_depth + 7) >> 3; // calc number of bytes per pixel + _FullLength = row_info->rowbytes - bpp; // number of bytes to filter + + __asm__ __volatile__ ( +//pre "movl row, %%edi \n\t" + "movl %%edi, %%esi \n\t" // lp = row +//pre "movl bpp, %%eax \n\t" + "addl %%eax, %%edi \n\t" // rp = row + bpp +//irr "xorl %%eax, %%eax \n\t" + // get # of bytes to alignment + "movl %%edi, _dif \n\t" // take start of row + "addl $0xf, _dif \n\t" // add 7 + 8 to incr past + // alignment boundary + "xorl %%ecx, %%ecx \n\t" + "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary + "subl %%edi, _dif \n\t" // subtract from start ==> value + "jz sub_go \n\t" // ecx at alignment + + "sub_lp1: \n\t" // fix alignment + "movb (%%esi,%%ecx,), %%al \n\t" + "addb %%al, (%%edi,%%ecx,) \n\t" + "incl %%ecx \n\t" + "cmpl _dif, %%ecx \n\t" + "jb sub_lp1 \n\t" + + "sub_go: \n\t" + "movl _FullLength, %%eax \n\t" + "movl %%eax, %%edx \n\t" + "subl %%ecx, %%edx \n\t" // subtract alignment fix + "andl $0x00000007, %%edx \n\t" // calc bytes over mult of 8 + "subl %%edx, %%eax \n\t" // drop over bytes from length + "movl %%eax, _MMXLength \n\t" + + : "=a" (dummy_value_a), // 0 // output regs (dummy) + "=D" (dummy_value_D) // 1 + + : "0" (bpp), // eax // input regs + "1" (row) // edi + + : "%esi", "%ecx", "%edx" // clobber list + +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + + // now do the math for the rest of the row + switch (bpp) + { + case 3: + { + _ActiveMask.use = 0x0000ffffff000000LL; + _ShiftBpp.use = 24; // == 3 * 8 + _ShiftRem.use = 40; // == 64 - 24 + + __asm__ __volatile__ ( +// preload "movl row, %%edi \n\t" + "movq _ActiveMask, %%mm7 \n\t" // load _ActiveMask for 2nd + // active byte group + "movl %%edi, %%esi \n\t" // lp = row +// preload "movl bpp, %%eax \n\t" + "addl %%eax, %%edi \n\t" // rp = row + bpp + "movq %%mm7, %%mm6 \n\t" + "movl _dif, %%edx \n\t" + "psllq _ShiftBpp, %%mm6 \n\t" // move mask in mm6 to cover + // 3rd active byte group + // prime the pump: load the first Raw(x-bpp) data set + "movq -8(%%edi,%%edx,), %%mm1 \n\t" + + "sub_3lp: \n\t" // shift data for adding first + "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; + // shift clears inactive bytes) + // add 1st active group + "movq (%%edi,%%edx,), %%mm0 \n\t" + "paddb %%mm1, %%mm0 \n\t" + + // add 2nd active group + "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 + "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly + "pand %%mm7, %%mm1 \n\t" // mask to use 2nd active group + "paddb %%mm1, %%mm0 \n\t" + + // add 3rd active group + "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 + "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly + "pand %%mm6, %%mm1 \n\t" // mask to use 3rd active group + "addl $8, %%edx \n\t" + "paddb %%mm1, %%mm0 \n\t" + + "cmpl _MMXLength, %%edx \n\t" + "movq %%mm0, -8(%%edi,%%edx,) \n\t" // write updated Raws to array + "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop + "jb sub_3lp \n\t" + + : "=a" (dummy_value_a), // 0 // output regs (dummy) + "=D" (dummy_value_D) // 1 + + : "0" (bpp), // eax // input regs + "1" (row) // edi + + : "%edx", "%esi" // clobber list +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm6", "%mm7" +#endif + ); + } + break; + + case 1: + { + __asm__ __volatile__ ( + "movl _dif, %%edx \n\t" +// preload "movl row, %%edi \n\t" + "cmpl _FullLength, %%edx \n\t" + "jnb sub_1end \n\t" + "movl %%edi, %%esi \n\t" // lp = row + "xorl %%eax, %%eax \n\t" +// preload "movl bpp, %%eax \n\t" + "addl %%eax, %%edi \n\t" // rp = row + bpp + + "sub_1lp: \n\t" + "movb (%%esi,%%edx,), %%al \n\t" + "addb %%al, (%%edi,%%edx,) \n\t" + "incl %%edx \n\t" + "cmpl _FullLength, %%edx \n\t" + "jb sub_1lp \n\t" + + "sub_1end: \n\t" + + : "=a" (dummy_value_a), // 0 // output regs (dummy) + "=D" (dummy_value_D) // 1 + + : "0" (bpp), // eax // input regs + "1" (row) // edi + + : "%edx", "%esi" // clobber list + ); + } + return; + + case 6: + case 4: + //case 7: // GRR BOGUS + //case 5: // GRR BOGUS + { + _ShiftBpp.use = bpp << 3; + _ShiftRem.use = 64 - _ShiftBpp.use; + + __asm__ __volatile__ ( +// preload "movl row, %%edi \n\t" + "movl _dif, %%edx \n\t" + "movl %%edi, %%esi \n\t" // lp = row +// preload "movl bpp, %%eax \n\t" + "addl %%eax, %%edi \n\t" // rp = row + bpp + + // prime the pump: load the first Raw(x-bpp) data set + "movq -8(%%edi,%%edx,), %%mm1 \n\t" + + "sub_4lp: \n\t" // shift data for adding first + "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; + // shift clears inactive bytes) + "movq (%%edi,%%edx,), %%mm0 \n\t" + "paddb %%mm1, %%mm0 \n\t" + + // add 2nd active group + "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 + "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly + "addl $8, %%edx \n\t" + "paddb %%mm1, %%mm0 \n\t" + + "cmpl _MMXLength, %%edx \n\t" + "movq %%mm0, -8(%%edi,%%edx,) \n\t" + "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop + "jb sub_4lp \n\t" + + : "=a" (dummy_value_a), // 0 // output regs (dummy) + "=D" (dummy_value_D) // 1 + + : "0" (bpp), // eax // input regs + "1" (row) // edi + + : "%edx", "%esi" // clobber list +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1" +#endif + ); + } + break; + + case 2: + { + _ActiveMask.use = 0x00000000ffff0000LL; + _ShiftBpp.use = 16; // == 2 * 8 + _ShiftRem.use = 48; // == 64 - 16 + + __asm__ __volatile__ ( + "movq _ActiveMask, %%mm7 \n\t" // load _ActiveMask for 2nd + // active byte group + "movl _dif, %%edx \n\t" + "movq %%mm7, %%mm6 \n\t" +// preload "movl row, %%edi \n\t" + "psllq _ShiftBpp, %%mm6 \n\t" // move mask in mm6 to cover + // 3rd active byte group + "movl %%edi, %%esi \n\t" // lp = row + "movq %%mm6, %%mm5 \n\t" +// preload "movl bpp, %%eax \n\t" + "addl %%eax, %%edi \n\t" // rp = row + bpp + "psllq _ShiftBpp, %%mm5 \n\t" // move mask in mm5 to cover + // 4th active byte group + // prime the pump: load the first Raw(x-bpp) data set + "movq -8(%%edi,%%edx,), %%mm1 \n\t" + + "sub_2lp: \n\t" // shift data for adding first + "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; + // shift clears inactive bytes) + // add 1st active group + "movq (%%edi,%%edx,), %%mm0 \n\t" + "paddb %%mm1, %%mm0 \n\t" + + // add 2nd active group + "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 + "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly + "pand %%mm7, %%mm1 \n\t" // mask to use 2nd active group + "paddb %%mm1, %%mm0 \n\t" + + // add 3rd active group + "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 + "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly + "pand %%mm6, %%mm1 \n\t" // mask to use 3rd active group + "paddb %%mm1, %%mm0 \n\t" + + // add 4th active group + "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 + "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly + "pand %%mm5, %%mm1 \n\t" // mask to use 4th active group + "addl $8, %%edx \n\t" + "paddb %%mm1, %%mm0 \n\t" + "cmpl _MMXLength, %%edx \n\t" + "movq %%mm0, -8(%%edi,%%edx,) \n\t" // write updated Raws to array + "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop + "jb sub_2lp \n\t" + + : "=a" (dummy_value_a), // 0 // output regs (dummy) + "=D" (dummy_value_D) // 1 + + : "0" (bpp), // eax // input regs + "1" (row) // edi + + : "%edx", "%esi" // clobber list +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; + + case 8: + { + __asm__ __volatile__ ( +// preload "movl row, %%edi \n\t" + "movl _dif, %%edx \n\t" + "movl %%edi, %%esi \n\t" // lp = row +// preload "movl bpp, %%eax \n\t" + "addl %%eax, %%edi \n\t" // rp = row + bpp + "movl _MMXLength, %%ecx \n\t" + + // prime the pump: load the first Raw(x-bpp) data set + "movq -8(%%edi,%%edx,), %%mm7 \n\t" + "andl $0x0000003f, %%ecx \n\t" // calc bytes over mult of 64 + + "sub_8lp: \n\t" + "movq (%%edi,%%edx,), %%mm0 \n\t" // load Sub(x) for 1st 8 bytes + "paddb %%mm7, %%mm0 \n\t" + "movq 8(%%edi,%%edx,), %%mm1 \n\t" // load Sub(x) for 2nd 8 bytes + "movq %%mm0, (%%edi,%%edx,) \n\t" // write Raw(x) for 1st 8 bytes + + // Now mm0 will be used as Raw(x-bpp) for the 2nd group of 8 bytes. + // This will be repeated for each group of 8 bytes with the 8th + // group being used as the Raw(x-bpp) for the 1st group of the + // next loop. + + "paddb %%mm0, %%mm1 \n\t" + "movq 16(%%edi,%%edx,), %%mm2 \n\t" // load Sub(x) for 3rd 8 bytes + "movq %%mm1, 8(%%edi,%%edx,) \n\t" // write Raw(x) for 2nd 8 bytes + "paddb %%mm1, %%mm2 \n\t" + "movq 24(%%edi,%%edx,), %%mm3 \n\t" // load Sub(x) for 4th 8 bytes + "movq %%mm2, 16(%%edi,%%edx,) \n\t" // write Raw(x) for 3rd 8 bytes + "paddb %%mm2, %%mm3 \n\t" + "movq 32(%%edi,%%edx,), %%mm4 \n\t" // load Sub(x) for 5th 8 bytes + "movq %%mm3, 24(%%edi,%%edx,) \n\t" // write Raw(x) for 4th 8 bytes + "paddb %%mm3, %%mm4 \n\t" + "movq 40(%%edi,%%edx,), %%mm5 \n\t" // load Sub(x) for 6th 8 bytes + "movq %%mm4, 32(%%edi,%%edx,) \n\t" // write Raw(x) for 5th 8 bytes + "paddb %%mm4, %%mm5 \n\t" + "movq 48(%%edi,%%edx,), %%mm6 \n\t" // load Sub(x) for 7th 8 bytes + "movq %%mm5, 40(%%edi,%%edx,) \n\t" // write Raw(x) for 6th 8 bytes + "paddb %%mm5, %%mm6 \n\t" + "movq 56(%%edi,%%edx,), %%mm7 \n\t" // load Sub(x) for 8th 8 bytes + "movq %%mm6, 48(%%edi,%%edx,) \n\t" // write Raw(x) for 7th 8 bytes + "addl $64, %%edx \n\t" + "paddb %%mm6, %%mm7 \n\t" + "cmpl %%ecx, %%edx \n\t" + "movq %%mm7, -8(%%edi,%%edx,) \n\t" // write Raw(x) for 8th 8 bytes + "jb sub_8lp \n\t" + + "cmpl _MMXLength, %%edx \n\t" + "jnb sub_8lt8 \n\t" + + "sub_8lpA: \n\t" + "movq (%%edi,%%edx,), %%mm0 \n\t" + "addl $8, %%edx \n\t" + "paddb %%mm7, %%mm0 \n\t" + "cmpl _MMXLength, %%edx \n\t" + "movq %%mm0, -8(%%edi,%%edx,) \n\t" // -8 to offset early addl edx + "movq %%mm0, %%mm7 \n\t" // move calculated Raw(x) data + // to mm1 to be new Raw(x-bpp) + // for next loop + "jb sub_8lpA \n\t" + + "sub_8lt8: \n\t" + + : "=a" (dummy_value_a), // 0 // output regs (dummy) + "=D" (dummy_value_D) // 1 + + : "0" (bpp), // eax // input regs + "1" (row) // edi + + : "%ecx", "%edx", "%esi" // clobber list +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; + + default: // bpp greater than 8 bytes GRR BOGUS + { + __asm__ __volatile__ ( + "movl _dif, %%edx \n\t" +// preload "movl row, %%edi \n\t" + "movl %%edi, %%esi \n\t" // lp = row +// preload "movl bpp, %%eax \n\t" + "addl %%eax, %%edi \n\t" // rp = row + bpp + + "sub_Alp: \n\t" + "movq (%%edi,%%edx,), %%mm0 \n\t" + "movq (%%esi,%%edx,), %%mm1 \n\t" + "addl $8, %%edx \n\t" + "paddb %%mm1, %%mm0 \n\t" + "cmpl _MMXLength, %%edx \n\t" + "movq %%mm0, -8(%%edi,%%edx,) \n\t" // mov does not affect flags; + // -8 to offset addl edx + "jb sub_Alp \n\t" + + : "=a" (dummy_value_a), // 0 // output regs (dummy) + "=D" (dummy_value_D) // 1 + + : "0" (bpp), // eax // input regs + "1" (row) // edi + + : "%edx", "%esi" // clobber list +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1" +#endif + ); + } + break; + + } // end switch (bpp) + + __asm__ __volatile__ ( + "movl _MMXLength, %%edx \n\t" +//pre "movl row, %%edi \n\t" + "cmpl _FullLength, %%edx \n\t" + "jnb sub_end \n\t" + + "movl %%edi, %%esi \n\t" // lp = row +//pre "movl bpp, %%eax \n\t" + "addl %%eax, %%edi \n\t" // rp = row + bpp + "xorl %%eax, %%eax \n\t" + + "sub_lp2: \n\t" + "movb (%%esi,%%edx,), %%al \n\t" + "addb %%al, (%%edi,%%edx,) \n\t" + "incl %%edx \n\t" + "cmpl _FullLength, %%edx \n\t" + "jb sub_lp2 \n\t" + + "sub_end: \n\t" + "EMMS \n\t" // end MMX instructions + + : "=a" (dummy_value_a), // 0 // output regs (dummy) + "=D" (dummy_value_D) // 1 + + : "0" (bpp), // eax // input regs + "1" (row) // edi + + : "%edx", "%esi" // clobber list + ); + +} // end of png_read_filter_row_mmx_sub() +#endif + + + + +//===========================================================================// +// // +// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ U P // +// // +//===========================================================================// + +// Optimized code for PNG Up filter decoder + +static void /* PRIVATE */ +png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, + png_bytep prev_row) +{ + png_uint_32 len; + int dummy_value_d; // fix 'forbidden register 3 (dx) was spilled' error + int dummy_value_S; + int dummy_value_D; + + len = row_info->rowbytes; // number of bytes to filter + + __asm__ __volatile__ ( +//pre "movl row, %%edi \n\t" + // get # of bytes to alignment +#ifdef __PIC__ + "pushl %%ebx \n\t" +#endif + "movl %%edi, %%ecx \n\t" + "xorl %%ebx, %%ebx \n\t" + "addl $0x7, %%ecx \n\t" + "xorl %%eax, %%eax \n\t" + "andl $0xfffffff8, %%ecx \n\t" +//pre "movl prev_row, %%esi \n\t" + "subl %%edi, %%ecx \n\t" + "jz up_go \n\t" + + "up_lp1: \n\t" // fix alignment + "movb (%%edi,%%ebx,), %%al \n\t" + "addb (%%esi,%%ebx,), %%al \n\t" + "incl %%ebx \n\t" + "cmpl %%ecx, %%ebx \n\t" + "movb %%al, -1(%%edi,%%ebx,) \n\t" // mov does not affect flags; -1 to + "jb up_lp1 \n\t" // offset incl ebx + + "up_go: \n\t" +//pre "movl len, %%edx \n\t" + "movl %%edx, %%ecx \n\t" + "subl %%ebx, %%edx \n\t" // subtract alignment fix + "andl $0x0000003f, %%edx \n\t" // calc bytes over mult of 64 + "subl %%edx, %%ecx \n\t" // drop over bytes from length + + // unrolled loop - use all MMX registers and interleave to reduce + // number of branch instructions (loops) and reduce partial stalls + "up_loop: \n\t" + "movq (%%esi,%%ebx,), %%mm1 \n\t" + "movq (%%edi,%%ebx,), %%mm0 \n\t" + "movq 8(%%esi,%%ebx,), %%mm3 \n\t" + "paddb %%mm1, %%mm0 \n\t" + "movq 8(%%edi,%%ebx,), %%mm2 \n\t" + "movq %%mm0, (%%edi,%%ebx,) \n\t" + "paddb %%mm3, %%mm2 \n\t" + "movq 16(%%esi,%%ebx,), %%mm5 \n\t" + "movq %%mm2, 8(%%edi,%%ebx,) \n\t" + "movq 16(%%edi,%%ebx,), %%mm4 \n\t" + "movq 24(%%esi,%%ebx,), %%mm7 \n\t" + "paddb %%mm5, %%mm4 \n\t" + "movq 24(%%edi,%%ebx,), %%mm6 \n\t" + "movq %%mm4, 16(%%edi,%%ebx,) \n\t" + "paddb %%mm7, %%mm6 \n\t" + "movq 32(%%esi,%%ebx,), %%mm1 \n\t" + "movq %%mm6, 24(%%edi,%%ebx,) \n\t" + "movq 32(%%edi,%%ebx,), %%mm0 \n\t" + "movq 40(%%esi,%%ebx,), %%mm3 \n\t" + "paddb %%mm1, %%mm0 \n\t" + "movq 40(%%edi,%%ebx,), %%mm2 \n\t" + "movq %%mm0, 32(%%edi,%%ebx,) \n\t" + "paddb %%mm3, %%mm2 \n\t" + "movq 48(%%esi,%%ebx,), %%mm5 \n\t" + "movq %%mm2, 40(%%edi,%%ebx,) \n\t" + "movq 48(%%edi,%%ebx,), %%mm4 \n\t" + "movq 56(%%esi,%%ebx,), %%mm7 \n\t" + "paddb %%mm5, %%mm4 \n\t" + "movq 56(%%edi,%%ebx,), %%mm6 \n\t" + "movq %%mm4, 48(%%edi,%%ebx,) \n\t" + "addl $64, %%ebx \n\t" + "paddb %%mm7, %%mm6 \n\t" + "cmpl %%ecx, %%ebx \n\t" + "movq %%mm6, -8(%%edi,%%ebx,) \n\t" // (+56)movq does not affect flags; + "jb up_loop \n\t" // -8 to offset addl ebx + + "cmpl $0, %%edx \n\t" // test for bytes over mult of 64 + "jz up_end \n\t" + + "cmpl $8, %%edx \n\t" // test for less than 8 bytes + "jb up_lt8 \n\t" // [added by lcreeve at netins.net] + + "addl %%edx, %%ecx \n\t" + "andl $0x00000007, %%edx \n\t" // calc bytes over mult of 8 + "subl %%edx, %%ecx \n\t" // drop over bytes from length + "jz up_lt8 \n\t" + + "up_lpA: \n\t" // use MMX regs to update 8 bytes sim. + "movq (%%esi,%%ebx,), %%mm1 \n\t" + "movq (%%edi,%%ebx,), %%mm0 \n\t" + "addl $8, %%ebx \n\t" + "paddb %%mm1, %%mm0 \n\t" + "cmpl %%ecx, %%ebx \n\t" + "movq %%mm0, -8(%%edi,%%ebx,) \n\t" // movq does not affect flags; -8 to + "jb up_lpA \n\t" // offset add ebx + "cmpl $0, %%edx \n\t" // test for bytes over mult of 8 + "jz up_end \n\t" + + "up_lt8: \n\t" + "xorl %%eax, %%eax \n\t" + "addl %%edx, %%ecx \n\t" // move over byte count into counter + + "up_lp2: \n\t" // use x86 regs for remaining bytes + "movb (%%edi,%%ebx,), %%al \n\t" + "addb (%%esi,%%ebx,), %%al \n\t" + "incl %%ebx \n\t" + "cmpl %%ecx, %%ebx \n\t" + "movb %%al, -1(%%edi,%%ebx,) \n\t" // mov does not affect flags; -1 to + "jb up_lp2 \n\t" // offset inc ebx + + "up_end: \n\t" + "EMMS \n\t" // conversion of filtered row complete +#ifdef __PIC__ + "popl %%ebx \n\t" +#endif + + : "=d" (dummy_value_d), // 0 // output regs (dummy) + "=S" (dummy_value_S), // 1 + "=D" (dummy_value_D) // 2 + + : "0" (len), // edx // input regs + "1" (prev_row), // esi + "2" (row) // edi + + : "%eax", "%ecx" // clobber list (no input regs!) +#ifndef __PIC__ + , "%ebx" +#endif + +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + +} // end of png_read_filter_row_mmx_up() + +#endif /* PNG_MMX_CODE_SUPPORTED */ + + + + +/*===========================================================================*/ +/* */ +/* P N G _ R E A D _ F I L T E R _ R O W */ +/* */ +/*===========================================================================*/ + + +/* Optimized png_read_filter_row routines */ + +void /* PRIVATE */ +png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep + row, png_bytep prev_row, int filter) +{ +#ifdef PNG_DEBUG + char filnm[10]; +#endif + +#if defined(PNG_MMX_CODE_SUPPORTED) +/* GRR: these are superseded by png_ptr->asm_flags: */ +#define UseMMX_sub 1 // GRR: converted 20000730 +#define UseMMX_up 1 // GRR: converted 20000729 +#define UseMMX_avg 1 // GRR: converted 20000828 (+ 16-bit bugfix 20000916) +#define UseMMX_paeth 1 // GRR: converted 20000828 + + if (_mmx_supported == 2) { + /* this should have happened in png_init_mmx_flags() already */ +#if !defined(PNG_1_0_X) + png_warning(png_ptr, "asm_flags may not have been initialized"); +#endif + png_mmx_support(); + } +#endif /* PNG_MMX_CODE_SUPPORTED */ + +#ifdef PNG_DEBUG + png_debug(1, "in png_read_filter_row (pnggccrd.c)\n"); + switch (filter) + { + case 0: sprintf(filnm, "none"); + break; + case 1: sprintf(filnm, "sub-%s", +#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : +#endif +#endif +"x86"); + break; + case 2: sprintf(filnm, "up-%s", +#ifdef PNG_MMX_CODE_SUPPORTED +#if !defined(PNG_1_0_X) + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : +#endif +#endif + "x86"); + break; + case 3: sprintf(filnm, "avg-%s", +#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : +#endif +#endif + "x86"); + break; + case 4: sprintf(filnm, "Paeth-%s", +#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX": +#endif +#endif +"x86"); + break; + default: sprintf(filnm, "unknw"); + break; + } + png_debug2(0, "row_number=%5ld, %5s, ", png_ptr->row_number, filnm); + png_debug1(0, "row=0x%08lx, ", (unsigned long)row); + png_debug2(0, "pixdepth=%2d, bytes=%d, ", (int)row_info->pixel_depth, + (int)((row_info->pixel_depth + 7) >> 3)); + png_debug1(0,"rowbytes=%8ld\n", row_info->rowbytes); +#endif /* PNG_DEBUG */ + + switch (filter) + { + case PNG_FILTER_VALUE_NONE: + break; + + case PNG_FILTER_VALUE_SUB: +#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (_mmx_supported) +#endif + { + png_read_filter_row_mmx_sub(row_info, row); + } + else +#endif /* PNG_MMX_CODE_SUPPORTED */ + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_bytep rp = row + bpp; + png_bytep lp = row; + + for (i = bpp; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); + rp++; + } + } /* end !UseMMX_sub */ + break; + + case PNG_FILTER_VALUE_UP: +#if defined(PNG_MMX_CODE_SUPPORTED) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (_mmx_supported) +#endif + { + png_read_filter_row_mmx_up(row_info, row, prev_row); + } + else +#endif /* PNG_MMX_CODE_SUPPORTED */ + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_bytep rp = row; + png_bytep pp = prev_row; + + for (i = 0; i < istop; ++i) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + } /* end !UseMMX_up */ + break; + + case PNG_FILTER_VALUE_AVG: +#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (_mmx_supported) +#endif + { + png_read_filter_row_mmx_avg(row_info, row, prev_row); + } + else +#endif /* PNG_MMX_CODE_SUPPORTED */ + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop = row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++) >> 1)) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++ + *lp++) >> 1)) & 0xff); + rp++; + } + } /* end !UseMMX_avg */ + break; + + case PNG_FILTER_VALUE_PAETH: +#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (_mmx_supported) +#endif + { + png_read_filter_row_mmx_paeth(row_info, row, prev_row); + } + else +#endif /* PNG_MMX_CODE_SUPPORTED */ + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_bytep cp = prev_row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop = row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) /* use leftover rp,pp */ + { + int a, b, c, pa, pb, pc, p; + + a = *lp++; + b = *pp++; + c = *cp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + /* + if (pa <= pb && pa <= pc) + p = a; + else if (pb <= pc) + p = b; + else + p = c; + */ + + p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c; + + *rp = (png_byte)(((int)(*rp) + p) & 0xff); + rp++; + } + } /* end !UseMMX_paeth */ + break; + + default: + png_warning(png_ptr, "Ignoring bad row-filter type"); + *row=0; + break; + } +} + +#endif /* PNG_HAVE_MMX_READ_FILTER_ROW */ + + +/*===========================================================================*/ +/* */ +/* P N G _ M M X _ S U P P O R T */ +/* */ +/*===========================================================================*/ + +/* GRR NOTES: (1) the following code assumes 386 or better (pushfl/popfl) + * (2) all instructions compile with gcc 2.7.2.3 and later + * (3) the function is moved down here to prevent gcc from + * inlining it in multiple places and then barfing be- + * cause the ".NOT_SUPPORTED" label is multiply defined + * [is there a way to signal that a *single* function should + * not be inlined? is there a way to modify the label for + * each inlined instance, e.g., by appending _1, _2, etc.? + * maybe if don't use leading "." in label name? (nope...sigh)] + */ + +int PNGAPI +png_mmx_support(void) +{ +#if defined(PNG_MMX_CODE_SUPPORTED) + int result; + __asm__ __volatile__ ( + "pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction + "pushl %%ecx \n\t" // so does ecx... + "pushl %%edx \n\t" // ...and edx (but ecx & edx safe on Linux) +// ".byte 0x66 \n\t" // convert 16-bit pushf to 32-bit pushfd +// "pushf \n\t" // 16-bit pushf + "pushfl \n\t" // save Eflag to stack + "popl %%eax \n\t" // get Eflag from stack into eax + "movl %%eax, %%ecx \n\t" // make another copy of Eflag in ecx + "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) + "pushl %%eax \n\t" // save modified Eflag back to stack +// ".byte 0x66 \n\t" // convert 16-bit popf to 32-bit popfd +// "popf \n\t" // 16-bit popf + "popfl \n\t" // restore modified value to Eflag reg + "pushfl \n\t" // save Eflag to stack + "popl %%eax \n\t" // get Eflag from stack + "pushl %%ecx \n\t" // save original Eflag to stack + "popfl \n\t" // restore original Eflag + "xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag + "jz 0f \n\t" // if same, CPUID instr. is not supported + + "xorl %%eax, %%eax \n\t" // set eax to zero +// ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode) + "cpuid \n\t" // get the CPU identification info + "cmpl $1, %%eax \n\t" // make sure eax return non-zero value + "jl 0f \n\t" // if eax is zero, MMX is not supported + + "xorl %%eax, %%eax \n\t" // set eax to zero and... + "incl %%eax \n\t" // ...increment eax to 1. This pair is + // faster than the instruction "mov eax, 1" + "cpuid \n\t" // get the CPU identification info again + "andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23) + "cmpl $0, %%edx \n\t" // 0 = MMX not supported + "jz 0f \n\t" // non-zero = yes, MMX IS supported + + "movl $1, %%eax \n\t" // set return value to 1 + "jmp 1f \n\t" // DONE: have MMX support + + "0: \n\t" // .NOT_SUPPORTED: target label for jump instructions + "movl $0, %%eax \n\t" // set return value to 0 + "1: \n\t" // .RETURN: target label for jump instructions + "popl %%edx \n\t" // restore edx + "popl %%ecx \n\t" // restore ecx + "popl %%ebx \n\t" // restore ebx + +// "ret \n\t" // DONE: no MMX support + // (fall through to standard C "ret") + + : "=a" (result) // output list + + : // any variables used on input (none) + + // no clobber list +// , "%ebx", "%ecx", "%edx" // GRR: we handle these manually +// , "memory" // if write to a variable gcc thought was in a reg +// , "cc" // "condition codes" (flag bits) + ); + _mmx_supported = result; +#else + _mmx_supported = 0; +#endif /* PNG_MMX_CODE_SUPPORTED */ + + return _mmx_supported; +} + + +#endif /* PNG_USE_PNGGCCRD */ diff --git a/src/dep/src/irrlicht/libpng/pngget.c b/src/dep/src/irrlicht/libpng/pngget.c index fc41b9b..036e9af 100644 --- a/src/dep/src/irrlicht/libpng/pngget.c +++ b/src/dep/src/irrlicht/libpng/pngget.c @@ -1,955 +1,955 @@ - -/* pngget.c - retrieval of values from info struct - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -png_uint_32 PNGAPI -png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->valid & flag); - else - return(0); -} - -png_uint_32 PNGAPI -png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->rowbytes); - else - return(0); -} - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -png_bytepp PNGAPI -png_get_rows(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->row_pointers); - else - return(0); -} -#endif - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* easy access to info, added in libpng-0.99 */ -png_uint_32 PNGAPI -png_get_image_width(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->width; - } - return (0); -} - -png_uint_32 PNGAPI -png_get_image_height(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->height; - } - return (0); -} - -png_byte PNGAPI -png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->bit_depth; - } - return (0); -} - -png_byte PNGAPI -png_get_color_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->color_type; - } - return (0); -} - -png_byte PNGAPI -png_get_filter_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->filter_type; - } - return (0); -} - -png_byte PNGAPI -png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->interlace_type; - } - return (0); -} - -png_byte PNGAPI -png_get_compression_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->compression_type; - } - return (0); -} - -png_uint_32 PNGAPI -png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) - return (0); - else return (info_ptr->x_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -png_uint_32 PNGAPI -png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) - return (0); - else return (info_ptr->y_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -png_uint_32 PNGAPI -png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER || - info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) - return (0); - else return (info_ptr->x_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -#ifdef PNG_FLOATING_POINT_SUPPORTED -float PNGAPI -png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) - { - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio"); - if (info_ptr->x_pixels_per_unit == 0) - return ((float)0.0); - else - return ((float)((float)info_ptr->y_pixels_per_unit - /(float)info_ptr->x_pixels_per_unit)); - } -#else - return (0.0); -#endif - return ((float)0.0); -} -#endif - -png_int_32 PNGAPI -png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) - return (0); - else return (info_ptr->x_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) - return (0); - else return (info_ptr->y_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) - return (0); - else return (info_ptr->x_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) - return (0); - else return (info_ptr->y_offset); - } -#else - return (0); -#endif - return (0); -} - -#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) -png_uint_32 PNGAPI -png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -png_uint_32 PNGAPI -png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -png_uint_32 PNGAPI -png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -float PNGAPI -png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr) -{ - return ((float)png_get_x_offset_microns(png_ptr, info_ptr) - *.00003937); -} - -float PNGAPI -png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) -{ - return ((float)png_get_y_offset_microns(png_ptr, info_ptr) - *.00003937); -} - -#if defined(PNG_pHYs_SUPPORTED) -png_uint_32 PNGAPI -png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) -{ - png_uint_32 retval = 0; - - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) - { - png_debug1(1, "in %s retrieval function\n", "pHYs"); - if (res_x != NULL) - { - *res_x = info_ptr->x_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (res_y != NULL) - { - *res_y = info_ptr->y_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (unit_type != NULL) - { - *unit_type = (int)info_ptr->phys_unit_type; - retval |= PNG_INFO_pHYs; - if(*unit_type == 1) - { - if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); - if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); - } - } - } - return (retval); -} -#endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ - -/* png_get_channels really belongs in here, too, but it's been around longer */ - -#endif /* PNG_EASY_ACCESS_SUPPORTED */ - -png_byte PNGAPI -png_get_channels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->channels); - else - return (0); -} - -png_bytep PNGAPI -png_get_signature(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->signature); - else - return (NULL); -} - -#if defined(PNG_bKGD_SUPPORTED) -png_uint_32 PNGAPI -png_get_bKGD(png_structp png_ptr, png_infop info_ptr, - png_color_16p *background) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) - && background != NULL) - { - png_debug1(1, "in %s retrieval function\n", "bKGD"); - *background = &(info_ptr->background); - return (PNG_INFO_bKGD); - } - return (0); -} -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_cHRM(png_structp png_ptr, png_infop info_ptr, - double *white_x, double *white_y, double *red_x, double *red_y, - double *green_x, double *green_y, double *blue_x, double *blue_y) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - { - png_debug1(1, "in %s retrieval function\n", "cHRM"); - if (white_x != NULL) - *white_x = (double)info_ptr->x_white; - if (white_y != NULL) - *white_y = (double)info_ptr->y_white; - if (red_x != NULL) - *red_x = (double)info_ptr->x_red; - if (red_y != NULL) - *red_y = (double)info_ptr->y_red; - if (green_x != NULL) - *green_x = (double)info_ptr->x_green; - if (green_y != NULL) - *green_y = (double)info_ptr->y_green; - if (blue_x != NULL) - *blue_x = (double)info_ptr->x_blue; - if (blue_y != NULL) - *blue_y = (double)info_ptr->y_blue; - return (PNG_INFO_cHRM); - } - return (0); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, - png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, - png_fixed_point *blue_x, png_fixed_point *blue_y) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - { - png_debug1(1, "in %s retrieval function\n", "cHRM"); - if (white_x != NULL) - *white_x = info_ptr->int_x_white; - if (white_y != NULL) - *white_y = info_ptr->int_y_white; - if (red_x != NULL) - *red_x = info_ptr->int_x_red; - if (red_y != NULL) - *red_y = info_ptr->int_y_red; - if (green_x != NULL) - *green_x = info_ptr->int_x_green; - if (green_y != NULL) - *green_y = info_ptr->int_y_green; - if (blue_x != NULL) - *blue_x = info_ptr->int_x_blue; - if (blue_y != NULL) - *blue_y = info_ptr->int_y_blue; - return (PNG_INFO_cHRM); - } - return (0); -} -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) - && file_gamma != NULL) - { - png_debug1(1, "in %s retrieval function\n", "gAMA"); - *file_gamma = (double)info_ptr->gamma; - return (PNG_INFO_gAMA); - } - return (0); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point *int_file_gamma) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) - && int_file_gamma != NULL) - { - png_debug1(1, "in %s retrieval function\n", "gAMA"); - *int_file_gamma = info_ptr->int_gamma; - return (PNG_INFO_gAMA); - } - return (0); -} -#endif -#endif - -#if defined(PNG_sRGB_SUPPORTED) -png_uint_32 PNGAPI -png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) - && file_srgb_intent != NULL) - { - png_debug1(1, "in %s retrieval function\n", "sRGB"); - *file_srgb_intent = (int)info_ptr->srgb_intent; - return (PNG_INFO_sRGB); - } - return (0); -} -#endif - -#if defined(PNG_iCCP_SUPPORTED) -png_uint_32 PNGAPI -png_get_iCCP(png_structp png_ptr, png_infop info_ptr, - png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) - && name != NULL && profile != NULL && proflen != NULL) - { - png_debug1(1, "in %s retrieval function\n", "iCCP"); - *name = info_ptr->iccp_name; - *profile = info_ptr->iccp_profile; - /* compression_type is a dummy so the API won't have to change - if we introduce multiple compression types later. */ - *proflen = (int)info_ptr->iccp_proflen; - *compression_type = (int)info_ptr->iccp_compression; - return (PNG_INFO_iCCP); - } - return (0); -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -png_uint_32 PNGAPI -png_get_sPLT(png_structp png_ptr, png_infop info_ptr, - png_sPLT_tpp spalettes) -{ - if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) - *spalettes = info_ptr->splt_palettes; - return ((png_uint_32)info_ptr->splt_palettes_num); -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -png_uint_32 PNGAPI -png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) - && hist != NULL) - { - png_debug1(1, "in %s retrieval function\n", "hIST"); - *hist = info_ptr->hist; - return (PNG_INFO_hIST); - } - return (0); -} -#endif - -png_uint_32 PNGAPI -png_get_IHDR(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *width, png_uint_32 *height, int *bit_depth, - int *color_type, int *interlace_type, int *compression_type, - int *filter_type) - -{ - if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && - bit_depth != NULL && color_type != NULL) - { - png_debug1(1, "in %s retrieval function\n", "IHDR"); - *width = info_ptr->width; - *height = info_ptr->height; - *bit_depth = info_ptr->bit_depth; - if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) - png_error(png_ptr, "Invalid bit depth"); - *color_type = info_ptr->color_type; - if (info_ptr->color_type > 6) - png_error(png_ptr, "Invalid color type"); - if (compression_type != NULL) - *compression_type = info_ptr->compression_type; - if (filter_type != NULL) - *filter_type = info_ptr->filter_type; - if (interlace_type != NULL) - *interlace_type = info_ptr->interlace_type; - - /* check for potential overflow of rowbytes */ - if (*width == 0 || *width > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image width"); - if (*height == 0 || *height > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image height"); - if (info_ptr->width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 64 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - { - png_warning(png_ptr, - "Width too large for libpng to process image data."); - } - return (1); - } - return (0); -} - -#if defined(PNG_oFFs_SUPPORTED) -png_uint_32 PNGAPI -png_get_oFFs(png_structp png_ptr, png_infop info_ptr, - png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) - && offset_x != NULL && offset_y != NULL && unit_type != NULL) - { - png_debug1(1, "in %s retrieval function\n", "oFFs"); - *offset_x = info_ptr->x_offset; - *offset_y = info_ptr->y_offset; - *unit_type = (int)info_ptr->offset_unit_type; - return (PNG_INFO_oFFs); - } - return (0); -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -png_uint_32 PNGAPI -png_get_pCAL(png_structp png_ptr, png_infop info_ptr, - png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, - png_charp *units, png_charpp *params) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) - && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && - nparams != NULL && units != NULL && params != NULL) - { - png_debug1(1, "in %s retrieval function\n", "pCAL"); - *purpose = info_ptr->pcal_purpose; - *X0 = info_ptr->pcal_X0; - *X1 = info_ptr->pcal_X1; - *type = (int)info_ptr->pcal_type; - *nparams = (int)info_ptr->pcal_nparams; - *units = info_ptr->pcal_units; - *params = info_ptr->pcal_params; - return (PNG_INFO_pCAL); - } - return (0); -} -#endif - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_sCAL(png_structp png_ptr, png_infop info_ptr, - int *unit, double *width, double *height) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - *width = info_ptr->scal_pixel_width; - *height = info_ptr->scal_pixel_height; - return (PNG_INFO_sCAL); - } - return(0); -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, - int *unit, png_charpp width, png_charpp height) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - *width = info_ptr->scal_s_width; - *height = info_ptr->scal_s_height; - return (PNG_INFO_sCAL); - } - return(0); -} -#endif -#endif -#endif - -#if defined(PNG_pHYs_SUPPORTED) -png_uint_32 PNGAPI -png_get_pHYs(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) -{ - png_uint_32 retval = 0; - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pHYs)) - { - png_debug1(1, "in %s retrieval function\n", "pHYs"); - if (res_x != NULL) - { - *res_x = info_ptr->x_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (res_y != NULL) - { - *res_y = info_ptr->y_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (unit_type != NULL) - { - *unit_type = (int)info_ptr->phys_unit_type; - retval |= PNG_INFO_pHYs; - } - } - return (retval); -} -#endif - -png_uint_32 PNGAPI -png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, - int *num_palette) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) - && palette != NULL) - { - png_debug1(1, "in %s retrieval function\n", "PLTE"); - *palette = info_ptr->palette; - *num_palette = info_ptr->num_palette; - png_debug1(3, "num_palette = %d\n", *num_palette); - return (PNG_INFO_PLTE); - } - return (0); -} - -#if defined(PNG_sBIT_SUPPORTED) -png_uint_32 PNGAPI -png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) - && sig_bit != NULL) - { - png_debug1(1, "in %s retrieval function\n", "sBIT"); - *sig_bit = &(info_ptr->sig_bit); - return (PNG_INFO_sBIT); - } - return (0); -} -#endif - -#if defined(PNG_TEXT_SUPPORTED) -png_uint_32 PNGAPI -png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, - int *num_text) -{ - if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) - { - png_debug1(1, "in %s retrieval function\n", - (png_ptr->chunk_name[0] == '\0' ? "text" - : (png_const_charp)png_ptr->chunk_name)); - if (text_ptr != NULL) - *text_ptr = info_ptr->text; - if (num_text != NULL) - *num_text = info_ptr->num_text; - return ((png_uint_32)info_ptr->num_text); - } - if (num_text != NULL) - *num_text = 0; - return(0); -} -#endif - -#if defined(PNG_tIME_SUPPORTED) -png_uint_32 PNGAPI -png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) - && mod_time != NULL) - { - png_debug1(1, "in %s retrieval function\n", "tIME"); - *mod_time = &(info_ptr->mod_time); - return (PNG_INFO_tIME); - } - return (0); -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -png_uint_32 PNGAPI -png_get_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep *trans, int *num_trans, png_color_16p *trans_values) -{ - png_uint_32 retval = 0; - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - png_debug1(1, "in %s retrieval function\n", "tRNS"); - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (trans != NULL) - { - *trans = info_ptr->trans; - retval |= PNG_INFO_tRNS; - } - if (trans_values != NULL) - *trans_values = &(info_ptr->trans_values); - } - else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ - { - if (trans_values != NULL) - { - *trans_values = &(info_ptr->trans_values); - retval |= PNG_INFO_tRNS; - } - if(trans != NULL) - *trans = NULL; - } - if(num_trans != NULL) - { - *num_trans = info_ptr->num_trans; - retval |= PNG_INFO_tRNS; - } - } - return (retval); -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -png_uint_32 PNGAPI -png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, - png_unknown_chunkpp unknowns) -{ - if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) - *unknowns = info_ptr->unknown_chunks; - return ((png_uint_32)info_ptr->unknown_chunks_num); -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -png_byte PNGAPI -png_get_rgb_to_gray_status (png_structp png_ptr) -{ - return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0); -} -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) -png_voidp PNGAPI -png_get_user_chunk_ptr(png_structp png_ptr) -{ - return (png_ptr? png_ptr->user_chunk_ptr : NULL); -} -#endif - -#ifdef PNG_WRITE_SUPPORTED -png_uint_32 PNGAPI -png_get_compression_buffer_size(png_structp png_ptr) -{ - return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); -} -#endif - -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -#ifndef PNG_1_0_X -/* this function was added to libpng 1.2.0 and should exist by default */ -png_uint_32 PNGAPI -png_get_asm_flags (png_structp png_ptr) -{ -#ifdef PNG_MMX_CODE_SUPPORTED - return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L); -#else - return (png_ptr? 0L: 0L); -#endif -} - -/* this function was added to libpng 1.2.0 and should exist by default */ -png_uint_32 PNGAPI -png_get_asm_flagmask (int flag_select) -{ -#ifdef PNG_MMX_CODE_SUPPORTED - png_uint_32 settable_asm_flags = 0; - - if (flag_select & PNG_SELECT_READ) - settable_asm_flags |= - PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | - PNG_ASM_FLAG_MMX_READ_INTERLACE | - PNG_ASM_FLAG_MMX_READ_FILTER_SUB | - PNG_ASM_FLAG_MMX_READ_FILTER_UP | - PNG_ASM_FLAG_MMX_READ_FILTER_AVG | - PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - /* no non-MMX flags yet */ - -#if 0 - /* GRR: no write-flags yet, either, but someday... */ - if (flag_select & PNG_SELECT_WRITE) - settable_asm_flags |= - PNG_ASM_FLAG_MMX_WRITE_ [whatever] ; -#endif /* 0 */ - - return settable_asm_flags; /* _theoretically_ settable capabilities only */ -#else - return (0L); -#endif /* PNG_MMX_CODE_SUPPORTED */ -} - - - /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ -/* this function was added to libpng 1.2.0 */ -png_uint_32 PNGAPI -png_get_mmx_flagmask (int flag_select, int *compilerID) -{ -#if defined(PNG_MMX_CODE_SUPPORTED) - png_uint_32 settable_mmx_flags = 0; - - if (flag_select & PNG_SELECT_READ) - settable_mmx_flags |= - PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | - PNG_ASM_FLAG_MMX_READ_INTERLACE | - PNG_ASM_FLAG_MMX_READ_FILTER_SUB | - PNG_ASM_FLAG_MMX_READ_FILTER_UP | - PNG_ASM_FLAG_MMX_READ_FILTER_AVG | - PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; -#if 0 - /* GRR: no MMX write support yet, but someday... */ - if (flag_select & PNG_SELECT_WRITE) - settable_mmx_flags |= - PNG_ASM_FLAG_MMX_WRITE_ [whatever] ; -#endif /* 0 */ - - if (compilerID != NULL) { -#ifdef PNG_USE_PNGVCRD - *compilerID = 1; /* MSVC */ -#else -#ifdef PNG_USE_PNGGCCRD - *compilerID = 2; /* gcc/gas */ -#else - *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ -#endif -#endif - } - - return settable_mmx_flags; /* _theoretically_ settable capabilities only */ -#else - return (0L); -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} - -/* this function was added to libpng 1.2.0 */ -png_byte PNGAPI -png_get_mmx_bitdepth_threshold (png_structp png_ptr) -{ -#if defined(PNG_MMX_CODE_SUPPORTED) - return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0); -#else - return (png_ptr? 0: 0); -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} - -/* this function was added to libpng 1.2.0 */ -png_uint_32 PNGAPI -png_get_mmx_rowbytes_threshold (png_structp png_ptr) -{ -#if defined(PNG_MMX_CODE_SUPPORTED) - return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L); -#else - return (png_ptr? 0L: 0L); -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} -#endif /* ?PNG_1_0_X */ -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ - -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* these functions were added to libpng 1.2.6 */ -png_uint_32 PNGAPI -png_get_user_width_max (png_structp png_ptr) -{ - return (png_ptr? png_ptr->user_width_max : 0); -} -png_uint_32 PNGAPI -png_get_user_height_max (png_structp png_ptr) -{ - return (png_ptr? png_ptr->user_height_max : 0); -} -#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ - -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ + +/* pngget.c - retrieval of values from info struct + * + * Last changed in libpng 1.2.15 January 5, 2007 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + +png_uint_32 PNGAPI +png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->valid & flag); + else + return(0); +} + +png_uint_32 PNGAPI +png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->rowbytes); + else + return(0); +} + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +png_bytepp PNGAPI +png_get_rows(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->row_pointers); + else + return(0); +} +#endif + +#ifdef PNG_EASY_ACCESS_SUPPORTED +/* easy access to info, added in libpng-0.99 */ +png_uint_32 PNGAPI +png_get_image_width(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + { + return info_ptr->width; + } + return (0); +} + +png_uint_32 PNGAPI +png_get_image_height(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + { + return info_ptr->height; + } + return (0); +} + +png_byte PNGAPI +png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + { + return info_ptr->bit_depth; + } + return (0); +} + +png_byte PNGAPI +png_get_color_type(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + { + return info_ptr->color_type; + } + return (0); +} + +png_byte PNGAPI +png_get_filter_type(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + { + return info_ptr->filter_type; + } + return (0); +} + +png_byte PNGAPI +png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + { + return info_ptr->interlace_type; + } + return (0); +} + +png_byte PNGAPI +png_get_compression_type(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + { + return info_ptr->compression_type; + } + return (0); +} + +png_uint_32 PNGAPI +png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_pHYs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pHYs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); + if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) + return (0); + else return (info_ptr->x_pixels_per_unit); + } +#else + return (0); +#endif + return (0); +} + +png_uint_32 PNGAPI +png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_pHYs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pHYs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); + if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) + return (0); + else return (info_ptr->y_pixels_per_unit); + } +#else + return (0); +#endif + return (0); +} + +png_uint_32 PNGAPI +png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_pHYs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pHYs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); + if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER || + info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) + return (0); + else return (info_ptr->x_pixels_per_unit); + } +#else + return (0); +#endif + return (0); +} + +#ifdef PNG_FLOATING_POINT_SUPPORTED +float PNGAPI +png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) + { + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_pHYs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pHYs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio"); + if (info_ptr->x_pixels_per_unit == 0) + return ((float)0.0); + else + return ((float)((float)info_ptr->y_pixels_per_unit + /(float)info_ptr->x_pixels_per_unit)); + } +#else + return (0.0); +#endif + return ((float)0.0); +} +#endif + +png_int_32 PNGAPI +png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_oFFs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_oFFs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); + if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) + return (0); + else return (info_ptr->x_offset); + } +#else + return (0); +#endif + return (0); +} + +png_int_32 PNGAPI +png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_oFFs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_oFFs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); + if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) + return (0); + else return (info_ptr->y_offset); + } +#else + return (0); +#endif + return (0); +} + +png_int_32 PNGAPI +png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_oFFs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_oFFs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); + if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) + return (0); + else return (info_ptr->x_offset); + } +#else + return (0); +#endif + return (0); +} + +png_int_32 PNGAPI +png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_oFFs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_oFFs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); + if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) + return (0); + else return (info_ptr->y_offset); + } +#else + return (0); +#endif + return (0); +} + +#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) +png_uint_32 PNGAPI +png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) +{ + return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr) + *.0254 +.5)); +} + +png_uint_32 PNGAPI +png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) +{ + return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr) + *.0254 +.5)); +} + +png_uint_32 PNGAPI +png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) +{ + return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr) + *.0254 +.5)); +} + +float PNGAPI +png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr) +{ + return ((float)png_get_x_offset_microns(png_ptr, info_ptr) + *.00003937); +} + +float PNGAPI +png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) +{ + return ((float)png_get_y_offset_microns(png_ptr, info_ptr) + *.00003937); +} + +#if defined(PNG_pHYs_SUPPORTED) +png_uint_32 PNGAPI +png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, + png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) +{ + png_uint_32 retval = 0; + + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) + { + png_debug1(1, "in %s retrieval function\n", "pHYs"); + if (res_x != NULL) + { + *res_x = info_ptr->x_pixels_per_unit; + retval |= PNG_INFO_pHYs; + } + if (res_y != NULL) + { + *res_y = info_ptr->y_pixels_per_unit; + retval |= PNG_INFO_pHYs; + } + if (unit_type != NULL) + { + *unit_type = (int)info_ptr->phys_unit_type; + retval |= PNG_INFO_pHYs; + if(*unit_type == 1) + { + if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); + if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); + } + } + } + return (retval); +} +#endif /* PNG_pHYs_SUPPORTED */ +#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ + +/* png_get_channels really belongs in here, too, but it's been around longer */ + +#endif /* PNG_EASY_ACCESS_SUPPORTED */ + +png_byte PNGAPI +png_get_channels(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->channels); + else + return (0); +} + +png_bytep PNGAPI +png_get_signature(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->signature); + else + return (NULL); +} + +#if defined(PNG_bKGD_SUPPORTED) +png_uint_32 PNGAPI +png_get_bKGD(png_structp png_ptr, png_infop info_ptr, + png_color_16p *background) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) + && background != NULL) + { + png_debug1(1, "in %s retrieval function\n", "bKGD"); + *background = &(info_ptr->background); + return (PNG_INFO_bKGD); + } + return (0); +} +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_cHRM(png_structp png_ptr, png_infop info_ptr, + double *white_x, double *white_y, double *red_x, double *red_y, + double *green_x, double *green_y, double *blue_x, double *blue_y) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) + { + png_debug1(1, "in %s retrieval function\n", "cHRM"); + if (white_x != NULL) + *white_x = (double)info_ptr->x_white; + if (white_y != NULL) + *white_y = (double)info_ptr->y_white; + if (red_x != NULL) + *red_x = (double)info_ptr->x_red; + if (red_y != NULL) + *red_y = (double)info_ptr->y_red; + if (green_x != NULL) + *green_x = (double)info_ptr->x_green; + if (green_y != NULL) + *green_y = (double)info_ptr->y_green; + if (blue_x != NULL) + *blue_x = (double)info_ptr->x_blue; + if (blue_y != NULL) + *blue_y = (double)info_ptr->y_blue; + return (PNG_INFO_cHRM); + } + return (0); +} +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, + png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, + png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, + png_fixed_point *blue_x, png_fixed_point *blue_y) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) + { + png_debug1(1, "in %s retrieval function\n", "cHRM"); + if (white_x != NULL) + *white_x = info_ptr->int_x_white; + if (white_y != NULL) + *white_y = info_ptr->int_y_white; + if (red_x != NULL) + *red_x = info_ptr->int_x_red; + if (red_y != NULL) + *red_y = info_ptr->int_y_red; + if (green_x != NULL) + *green_x = info_ptr->int_x_green; + if (green_y != NULL) + *green_y = info_ptr->int_y_green; + if (blue_x != NULL) + *blue_x = info_ptr->int_x_blue; + if (blue_y != NULL) + *blue_y = info_ptr->int_y_blue; + return (PNG_INFO_cHRM); + } + return (0); +} +#endif +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) + && file_gamma != NULL) + { + png_debug1(1, "in %s retrieval function\n", "gAMA"); + *file_gamma = (double)info_ptr->gamma; + return (PNG_INFO_gAMA); + } + return (0); +} +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, + png_fixed_point *int_file_gamma) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) + && int_file_gamma != NULL) + { + png_debug1(1, "in %s retrieval function\n", "gAMA"); + *int_file_gamma = info_ptr->int_gamma; + return (PNG_INFO_gAMA); + } + return (0); +} +#endif +#endif + +#if defined(PNG_sRGB_SUPPORTED) +png_uint_32 PNGAPI +png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) + && file_srgb_intent != NULL) + { + png_debug1(1, "in %s retrieval function\n", "sRGB"); + *file_srgb_intent = (int)info_ptr->srgb_intent; + return (PNG_INFO_sRGB); + } + return (0); +} +#endif + +#if defined(PNG_iCCP_SUPPORTED) +png_uint_32 PNGAPI +png_get_iCCP(png_structp png_ptr, png_infop info_ptr, + png_charpp name, int *compression_type, + png_charpp profile, png_uint_32 *proflen) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) + && name != NULL && profile != NULL && proflen != NULL) + { + png_debug1(1, "in %s retrieval function\n", "iCCP"); + *name = info_ptr->iccp_name; + *profile = info_ptr->iccp_profile; + /* compression_type is a dummy so the API won't have to change + if we introduce multiple compression types later. */ + *proflen = (int)info_ptr->iccp_proflen; + *compression_type = (int)info_ptr->iccp_compression; + return (PNG_INFO_iCCP); + } + return (0); +} +#endif + +#if defined(PNG_sPLT_SUPPORTED) +png_uint_32 PNGAPI +png_get_sPLT(png_structp png_ptr, png_infop info_ptr, + png_sPLT_tpp spalettes) +{ + if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) + *spalettes = info_ptr->splt_palettes; + return ((png_uint_32)info_ptr->splt_palettes_num); +} +#endif + +#if defined(PNG_hIST_SUPPORTED) +png_uint_32 PNGAPI +png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) + && hist != NULL) + { + png_debug1(1, "in %s retrieval function\n", "hIST"); + *hist = info_ptr->hist; + return (PNG_INFO_hIST); + } + return (0); +} +#endif + +png_uint_32 PNGAPI +png_get_IHDR(png_structp png_ptr, png_infop info_ptr, + png_uint_32 *width, png_uint_32 *height, int *bit_depth, + int *color_type, int *interlace_type, int *compression_type, + int *filter_type) + +{ + if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && + bit_depth != NULL && color_type != NULL) + { + png_debug1(1, "in %s retrieval function\n", "IHDR"); + *width = info_ptr->width; + *height = info_ptr->height; + *bit_depth = info_ptr->bit_depth; + if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) + png_error(png_ptr, "Invalid bit depth"); + *color_type = info_ptr->color_type; + if (info_ptr->color_type > 6) + png_error(png_ptr, "Invalid color type"); + if (compression_type != NULL) + *compression_type = info_ptr->compression_type; + if (filter_type != NULL) + *filter_type = info_ptr->filter_type; + if (interlace_type != NULL) + *interlace_type = info_ptr->interlace_type; + + /* check for potential overflow of rowbytes */ + if (*width == 0 || *width > PNG_UINT_31_MAX) + png_error(png_ptr, "Invalid image width"); + if (*height == 0 || *height > PNG_UINT_31_MAX) + png_error(png_ptr, "Invalid image height"); + if (info_ptr->width > (PNG_UINT_32_MAX + >> 3) /* 8-byte RGBA pixels */ + - 64 /* bigrowbuf hack */ + - 1 /* filter byte */ + - 7*8 /* rounding of width to multiple of 8 pixels */ + - 8) /* extra max_pixel_depth pad */ + { + png_warning(png_ptr, + "Width too large for libpng to process image data."); + } + return (1); + } + return (0); +} + +#if defined(PNG_oFFs_SUPPORTED) +png_uint_32 PNGAPI +png_get_oFFs(png_structp png_ptr, png_infop info_ptr, + png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) + && offset_x != NULL && offset_y != NULL && unit_type != NULL) + { + png_debug1(1, "in %s retrieval function\n", "oFFs"); + *offset_x = info_ptr->x_offset; + *offset_y = info_ptr->y_offset; + *unit_type = (int)info_ptr->offset_unit_type; + return (PNG_INFO_oFFs); + } + return (0); +} +#endif + +#if defined(PNG_pCAL_SUPPORTED) +png_uint_32 PNGAPI +png_get_pCAL(png_structp png_ptr, png_infop info_ptr, + png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, + png_charp *units, png_charpp *params) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) + && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && + nparams != NULL && units != NULL && params != NULL) + { + png_debug1(1, "in %s retrieval function\n", "pCAL"); + *purpose = info_ptr->pcal_purpose; + *X0 = info_ptr->pcal_X0; + *X1 = info_ptr->pcal_X1; + *type = (int)info_ptr->pcal_type; + *nparams = (int)info_ptr->pcal_nparams; + *units = info_ptr->pcal_units; + *params = info_ptr->pcal_params; + return (PNG_INFO_pCAL); + } + return (0); +} +#endif + +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_sCAL(png_structp png_ptr, png_infop info_ptr, + int *unit, double *width, double *height) +{ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_sCAL)) + { + *unit = info_ptr->scal_unit; + *width = info_ptr->scal_pixel_width; + *height = info_ptr->scal_pixel_height; + return (PNG_INFO_sCAL); + } + return(0); +} +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, + int *unit, png_charpp width, png_charpp height) +{ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_sCAL)) + { + *unit = info_ptr->scal_unit; + *width = info_ptr->scal_s_width; + *height = info_ptr->scal_s_height; + return (PNG_INFO_sCAL); + } + return(0); +} +#endif +#endif +#endif + +#if defined(PNG_pHYs_SUPPORTED) +png_uint_32 PNGAPI +png_get_pHYs(png_structp png_ptr, png_infop info_ptr, + png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) +{ + png_uint_32 retval = 0; + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_pHYs)) + { + png_debug1(1, "in %s retrieval function\n", "pHYs"); + if (res_x != NULL) + { + *res_x = info_ptr->x_pixels_per_unit; + retval |= PNG_INFO_pHYs; + } + if (res_y != NULL) + { + *res_y = info_ptr->y_pixels_per_unit; + retval |= PNG_INFO_pHYs; + } + if (unit_type != NULL) + { + *unit_type = (int)info_ptr->phys_unit_type; + retval |= PNG_INFO_pHYs; + } + } + return (retval); +} +#endif + +png_uint_32 PNGAPI +png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, + int *num_palette) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) + && palette != NULL) + { + png_debug1(1, "in %s retrieval function\n", "PLTE"); + *palette = info_ptr->palette; + *num_palette = info_ptr->num_palette; + png_debug1(3, "num_palette = %d\n", *num_palette); + return (PNG_INFO_PLTE); + } + return (0); +} + +#if defined(PNG_sBIT_SUPPORTED) +png_uint_32 PNGAPI +png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) + && sig_bit != NULL) + { + png_debug1(1, "in %s retrieval function\n", "sBIT"); + *sig_bit = &(info_ptr->sig_bit); + return (PNG_INFO_sBIT); + } + return (0); +} +#endif + +#if defined(PNG_TEXT_SUPPORTED) +png_uint_32 PNGAPI +png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, + int *num_text) +{ + if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) + { + png_debug1(1, "in %s retrieval function\n", + (png_ptr->chunk_name[0] == '\0' ? "text" + : (png_const_charp)png_ptr->chunk_name)); + if (text_ptr != NULL) + *text_ptr = info_ptr->text; + if (num_text != NULL) + *num_text = info_ptr->num_text; + return ((png_uint_32)info_ptr->num_text); + } + if (num_text != NULL) + *num_text = 0; + return(0); +} +#endif + +#if defined(PNG_tIME_SUPPORTED) +png_uint_32 PNGAPI +png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) + && mod_time != NULL) + { + png_debug1(1, "in %s retrieval function\n", "tIME"); + *mod_time = &(info_ptr->mod_time); + return (PNG_INFO_tIME); + } + return (0); +} +#endif + +#if defined(PNG_tRNS_SUPPORTED) +png_uint_32 PNGAPI +png_get_tRNS(png_structp png_ptr, png_infop info_ptr, + png_bytep *trans, int *num_trans, png_color_16p *trans_values) +{ + png_uint_32 retval = 0; + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) + { + png_debug1(1, "in %s retrieval function\n", "tRNS"); + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (trans != NULL) + { + *trans = info_ptr->trans; + retval |= PNG_INFO_tRNS; + } + if (trans_values != NULL) + *trans_values = &(info_ptr->trans_values); + } + else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ + { + if (trans_values != NULL) + { + *trans_values = &(info_ptr->trans_values); + retval |= PNG_INFO_tRNS; + } + if(trans != NULL) + *trans = NULL; + } + if(num_trans != NULL) + { + *num_trans = info_ptr->num_trans; + retval |= PNG_INFO_tRNS; + } + } + return (retval); +} +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +png_uint_32 PNGAPI +png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, + png_unknown_chunkpp unknowns) +{ + if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) + *unknowns = info_ptr->unknown_chunks; + return ((png_uint_32)info_ptr->unknown_chunks_num); +} +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +png_byte PNGAPI +png_get_rgb_to_gray_status (png_structp png_ptr) +{ + return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0); +} +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) +png_voidp PNGAPI +png_get_user_chunk_ptr(png_structp png_ptr) +{ + return (png_ptr? png_ptr->user_chunk_ptr : NULL); +} +#endif + +#ifdef PNG_WRITE_SUPPORTED +png_uint_32 PNGAPI +png_get_compression_buffer_size(png_structp png_ptr) +{ + return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); +} +#endif + +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED +#ifndef PNG_1_0_X +/* this function was added to libpng 1.2.0 and should exist by default */ +png_uint_32 PNGAPI +png_get_asm_flags (png_structp png_ptr) +{ +#ifdef PNG_MMX_CODE_SUPPORTED + return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L); +#else + return (png_ptr? 0L: 0L); +#endif +} + +/* this function was added to libpng 1.2.0 and should exist by default */ +png_uint_32 PNGAPI +png_get_asm_flagmask (int flag_select) +{ +#ifdef PNG_MMX_CODE_SUPPORTED + png_uint_32 settable_asm_flags = 0; + + if (flag_select & PNG_SELECT_READ) + settable_asm_flags |= + PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | + PNG_ASM_FLAG_MMX_READ_INTERLACE | + PNG_ASM_FLAG_MMX_READ_FILTER_SUB | + PNG_ASM_FLAG_MMX_READ_FILTER_UP | + PNG_ASM_FLAG_MMX_READ_FILTER_AVG | + PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; + /* no non-MMX flags yet */ + +#if 0 + /* GRR: no write-flags yet, either, but someday... */ + if (flag_select & PNG_SELECT_WRITE) + settable_asm_flags |= + PNG_ASM_FLAG_MMX_WRITE_ [whatever] ; +#endif /* 0 */ + + return settable_asm_flags; /* _theoretically_ settable capabilities only */ +#else + return (0L); +#endif /* PNG_MMX_CODE_SUPPORTED */ +} + + + /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ +/* this function was added to libpng 1.2.0 */ +png_uint_32 PNGAPI +png_get_mmx_flagmask (int flag_select, int *compilerID) +{ +#if defined(PNG_MMX_CODE_SUPPORTED) + png_uint_32 settable_mmx_flags = 0; + + if (flag_select & PNG_SELECT_READ) + settable_mmx_flags |= + PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | + PNG_ASM_FLAG_MMX_READ_INTERLACE | + PNG_ASM_FLAG_MMX_READ_FILTER_SUB | + PNG_ASM_FLAG_MMX_READ_FILTER_UP | + PNG_ASM_FLAG_MMX_READ_FILTER_AVG | + PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; +#if 0 + /* GRR: no MMX write support yet, but someday... */ + if (flag_select & PNG_SELECT_WRITE) + settable_mmx_flags |= + PNG_ASM_FLAG_MMX_WRITE_ [whatever] ; +#endif /* 0 */ + + if (compilerID != NULL) { +#ifdef PNG_USE_PNGVCRD + *compilerID = 1; /* MSVC */ +#else +#ifdef PNG_USE_PNGGCCRD + *compilerID = 2; /* gcc/gas */ +#else + *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ +#endif +#endif + } + + return settable_mmx_flags; /* _theoretically_ settable capabilities only */ +#else + return (0L); +#endif /* ?PNG_MMX_CODE_SUPPORTED */ +} + +/* this function was added to libpng 1.2.0 */ +png_byte PNGAPI +png_get_mmx_bitdepth_threshold (png_structp png_ptr) +{ +#if defined(PNG_MMX_CODE_SUPPORTED) + return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0); +#else + return (png_ptr? 0: 0); +#endif /* ?PNG_MMX_CODE_SUPPORTED */ +} + +/* this function was added to libpng 1.2.0 */ +png_uint_32 PNGAPI +png_get_mmx_rowbytes_threshold (png_structp png_ptr) +{ +#if defined(PNG_MMX_CODE_SUPPORTED) + return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L); +#else + return (png_ptr? 0L: 0L); +#endif /* ?PNG_MMX_CODE_SUPPORTED */ +} +#endif /* ?PNG_1_0_X */ +#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ + +#ifdef PNG_SET_USER_LIMITS_SUPPORTED +/* these functions were added to libpng 1.2.6 */ +png_uint_32 PNGAPI +png_get_user_width_max (png_structp png_ptr) +{ + return (png_ptr? png_ptr->user_width_max : 0); +} +png_uint_32 PNGAPI +png_get_user_height_max (png_structp png_ptr) +{ + return (png_ptr? png_ptr->user_height_max : 0); +} +#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ + +#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/pngmem.c b/src/dep/src/irrlicht/libpng/pngmem.c index 6aa70af..248060f 100644 --- a/src/dep/src/irrlicht/libpng/pngmem.c +++ b/src/dep/src/irrlicht/libpng/pngmem.c @@ -1,608 +1,608 @@ - -/* pngmem.c - stub functions for memory allocation - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all memory allocation. Users who - * need special memory handling are expected to supply replacement - * functions for png_malloc() and png_free(), and to use - * png_create_read_struct_2() and png_create_write_struct_2() to - * identify the replacement functions. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -/* Borland DOS special memory handler */ -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* if you change this, be sure to change the one in png.h also */ - -/* Allocate memory for a png_struct. The malloc and memset can be replaced - by a single call to calloc() if this is thought to improve performance. */ -png_voidp /* PRIVATE */ -png_create_struct(int type) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); -} - -/* Alternate version of png_create_struct, for use with user-defined malloc. */ -png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_size_t size; - png_voidp struct_ptr; - - if (type == PNG_STRUCT_INFO) - size = png_sizeof(png_info); - else if (type == PNG_STRUCT_PNG) - size = png_sizeof(png_struct); - else - return (png_get_copyright(NULL)); - -#ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size); - } - else -#endif /* PNG_USER_MEM_SUPPORTED */ - struct_ptr = (png_voidp)farmalloc(size); - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - return (struct_ptr); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct(png_voidp struct_ptr) -{ -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, - png_voidp mem_ptr) -{ -#endif - if (struct_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - (*(free_fn))(png_ptr, struct_ptr); - return; - } -#endif /* PNG_USER_MEM_SUPPORTED */ - farfree (struct_ptr); - } -} - -/* Allocate memory. For reasonable files, size should never exceed - * 64K. However, zlib may allocate more then 64K if you don't tell - * it not to. See zconf.h and png.h for more information. zlib does - * need to allocate exactly 64K, so whatever you call here must - * have the ability to do that. - * - * Borland seems to have a problem in DOS mode for exactly 64K. - * It gives you a segment with an offset of 8 (perhaps to store its - * memory stuff). zlib doesn't like this at all, so we have to - * detect and deal with it. This code should not be needed in - * Windows or OS/2 modes, and only in 16 bit mode. This code has - * been updated by Alexander Lehmann for version 0.89 to waste less - * memory. - * - * Note that we can't use png_size_t for the "size" declaration, - * since on some systems a png_size_t is a 16-bit quantity, and as a - * result, we would be truncating potentially larger memory requests - * (which should cause a fatal error) and introducing major problems. - */ - -png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; - - if (png_ptr == NULL || size == 0) - return (NULL); - -#ifdef PNG_USER_MEM_SUPPORTED - if(png_ptr->malloc_fn != NULL) - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); - else - ret = (png_malloc_default(png_ptr, size)); - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of memory!"); - return (ret); -} - -png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; -#endif /* PNG_USER_MEM_SUPPORTED */ - - if (png_ptr == NULL || size == 0) - return (NULL); - -#ifdef PNG_MAX_MALLOC_64K - if (size > (png_uint_32)65536L) - { - png_warning(png_ptr, "Cannot Allocate > 64K"); - ret = NULL; - } - else -#endif - - if (size != (size_t)size) - ret = NULL; - else if (size == (png_uint_32)65536L) - { - if (png_ptr->offset_table == NULL) - { - /* try to see if we need to do any of this fancy stuff */ - ret = farmalloc(size); - if (ret == NULL || ((png_size_t)ret & 0xffff)) - { - int num_blocks; - png_uint_32 total_size; - png_bytep table; - int i; - png_byte huge * hptr; - - if (ret != NULL) - { - farfree(ret); - ret = NULL; - } - - if(png_ptr->zlib_window_bits > 14) - num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); - else - num_blocks = 1; - if (png_ptr->zlib_mem_level >= 7) - num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7)); - else - num_blocks++; - - total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16; - - table = farmalloc(total_size); - - if (table == NULL) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */ - else - png_warning(png_ptr, "Out Of Memory."); -#endif - return (NULL); - } - - if ((png_size_t)table & 0xfff0) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, - "Farmalloc didn't return normalized pointer"); - else - png_warning(png_ptr, - "Farmalloc didn't return normalized pointer"); -#endif - return (NULL); - } - - png_ptr->offset_table = table; - png_ptr->offset_table_ptr = farmalloc(num_blocks * - png_sizeof (png_bytep)); - - if (png_ptr->offset_table_ptr == NULL) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */ - else - png_warning(png_ptr, "Out Of memory."); -#endif - return (NULL); - } - - hptr = (png_byte huge *)table; - if ((png_size_t)hptr & 0xf) - { - hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); - hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */ - } - for (i = 0; i < num_blocks; i++) - { - png_ptr->offset_table_ptr[i] = (png_bytep)hptr; - hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */ - } - - png_ptr->offset_table_number = num_blocks; - png_ptr->offset_table_count = 0; - png_ptr->offset_table_count_free = 0; - } - } - - if (png_ptr->offset_table_count >= png_ptr->offset_table_number) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */ - else - png_warning(png_ptr, "Out of Memory."); -#endif - return (NULL); - } - - ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++]; - } - else - ret = farmalloc(size); - -#ifndef PNG_USER_MEM_SUPPORTED - if (ret == NULL) - { - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ - else - png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */ - } -#endif - - return (ret); -} - -/* free a pointer allocated by png_malloc(). In the default - configuration, png_ptr is not used, but is passed in case it - is needed. If ptr is NULL, return without taking any action. */ -void PNGAPI -png_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr->free_fn != NULL) - { - (*(png_ptr->free_fn))(png_ptr, ptr); - return; - } - else png_free_default(png_ptr, ptr); -} - -void PNGAPI -png_free_default(png_structp png_ptr, png_voidp ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - - if(png_ptr == NULL) return; - - if (png_ptr->offset_table != NULL) - { - int i; - - for (i = 0; i < png_ptr->offset_table_count; i++) - { - if (ptr == png_ptr->offset_table_ptr[i]) - { - ptr = NULL; - png_ptr->offset_table_count_free++; - break; - } - } - if (png_ptr->offset_table_count_free == png_ptr->offset_table_count) - { - farfree(png_ptr->offset_table); - farfree(png_ptr->offset_table_ptr); - png_ptr->offset_table = NULL; - png_ptr->offset_table_ptr = NULL; - } - } - - if (ptr != NULL) - { - farfree(ptr); - } -} - -#else /* Not the Borland DOS special memory handler */ - -/* Allocate memory for a png_struct or a png_info. The malloc and - memset can be replaced by a single call to calloc() if this is thought - to improve performance noticably. */ -png_voidp /* PRIVATE */ -png_create_struct(int type) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); -} - -/* Allocate memory for a png_struct or a png_info. The malloc and - memset can be replaced by a single call to calloc() if this is thought - to improve performance noticably. */ -png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_size_t size; - png_voidp struct_ptr; - - if (type == PNG_STRUCT_INFO) - size = png_sizeof(png_info); - else if (type == PNG_STRUCT_PNG) - size = png_sizeof(png_struct); - else - return (NULL); - -#ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - struct_ptr = (*(malloc_fn))(png_ptr, size); - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - return (struct_ptr); - } -#endif /* PNG_USER_MEM_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(__FLAT__) - struct_ptr = (png_voidp)farmalloc(size); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - struct_ptr = (png_voidp)halloc(size,1); -# else - struct_ptr = (png_voidp)malloc(size); -# endif -#endif - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - - return (struct_ptr); -} - - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct(png_voidp struct_ptr) -{ -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, - png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - if (struct_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - (*(free_fn))(png_ptr, struct_ptr); - return; - } -#endif /* PNG_USER_MEM_SUPPORTED */ -#if defined(__TURBOC__) && !defined(__FLAT__) - farfree(struct_ptr); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - hfree(struct_ptr); -# else - free(struct_ptr); -# endif -#endif - } -} - -/* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. */ - -png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; - -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr == NULL || size == 0) - return (NULL); - - if(png_ptr->malloc_fn != NULL) - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); - else - ret = (png_malloc_default(png_ptr, size)); - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory!"); - return (ret); -} - -png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; -#endif /* PNG_USER_MEM_SUPPORTED */ - - if (png_ptr == NULL || size == 0) - return (NULL); - -#ifdef PNG_MAX_MALLOC_64K - if (size > (png_uint_32)65536L) - { -#ifndef PNG_USER_MEM_SUPPORTED - if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Cannot Allocate > 64K"); - else -#endif - return NULL; - } -#endif - - /* Check for overflow */ -#if defined(__TURBOC__) && !defined(__FLAT__) - if (size != (unsigned long)size) - ret = NULL; - else - ret = farmalloc(size); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - if (size != (unsigned long)size) - ret = NULL; - else - ret = halloc(size, 1); -# else - if (size != (size_t)size) - ret = NULL; - else - ret = malloc((size_t)size); -# endif -#endif - -#ifndef PNG_USER_MEM_SUPPORTED - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory"); -#endif - - return (ret); -} - -/* Free a pointer allocated by png_malloc(). If ptr is NULL, return - without taking any action. */ -void PNGAPI -png_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr->free_fn != NULL) - { - (*(png_ptr->free_fn))(png_ptr, ptr); - return; - } - else png_free_default(png_ptr, ptr); -} -void PNGAPI -png_free_default(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#endif /* PNG_USER_MEM_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(__FLAT__) - farfree(ptr); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - hfree(ptr); -# else - free(ptr); -# endif -#endif -} - -#endif /* Not Borland DOS special memory handler */ - -#if defined(PNG_1_0_X) -# define png_malloc_warn png_malloc -#else -/* This function was added at libpng version 1.2.3. The png_malloc_warn() - * function will set up png_malloc() to issue a png_warning and return NULL - * instead of issuing a png_error, if it fails to allocate the requested - * memory. - */ -png_voidp PNGAPI -png_malloc_warn(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ptr; - png_uint_32 save_flags; - if(png_ptr == NULL) return (NULL); - - save_flags=png_ptr->flags; - png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; - ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); - png_ptr->flags=save_flags; - return(ptr); -} -#endif - -png_voidp PNGAPI -png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memcpy_check."); - - return(png_memcpy (s1, s2, size)); -} - -png_voidp PNGAPI -png_memset_check (png_structp png_ptr, png_voidp s1, int value, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memset_check."); - - return (png_memset (s1, value, size)); - -} - -#ifdef PNG_USER_MEM_SUPPORTED -/* This function is called when the application wants to use another method - * of allocating and freeing memory. - */ -void PNGAPI -png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr - malloc_fn, png_free_ptr free_fn) -{ - if(png_ptr != NULL) { - png_ptr->mem_ptr = mem_ptr; - png_ptr->malloc_fn = malloc_fn; - png_ptr->free_fn = free_fn; - } -} - -/* This function returns a pointer to the mem_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy and png_read_destroy are called. - */ -png_voidp PNGAPI -png_get_mem_ptr(png_structp png_ptr) -{ - if(png_ptr == NULL) return (NULL); - return ((png_voidp)png_ptr->mem_ptr); -} -#endif /* PNG_USER_MEM_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ + +/* pngmem.c - stub functions for memory allocation + * + * Last changed in libpng 1.2.13 November 13, 2006 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This file provides a location for all memory allocation. Users who + * need special memory handling are expected to supply replacement + * functions for png_malloc() and png_free(), and to use + * png_create_read_struct_2() and png_create_write_struct_2() to + * identify the replacement functions. + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + +/* Borland DOS special memory handler */ +#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) +/* if you change this, be sure to change the one in png.h also */ + +/* Allocate memory for a png_struct. The malloc and memset can be replaced + by a single call to calloc() if this is thought to improve performance. */ +png_voidp /* PRIVATE */ +png_create_struct(int type) +{ +#ifdef PNG_USER_MEM_SUPPORTED + return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); +} + +/* Alternate version of png_create_struct, for use with user-defined malloc. */ +png_voidp /* PRIVATE */ +png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + png_size_t size; + png_voidp struct_ptr; + + if (type == PNG_STRUCT_INFO) + size = png_sizeof(png_info); + else if (type == PNG_STRUCT_PNG) + size = png_sizeof(png_struct); + else + return (png_get_copyright(NULL)); + +#ifdef PNG_USER_MEM_SUPPORTED + if(malloc_fn != NULL) + { + png_struct dummy_struct; + png_structp png_ptr = &dummy_struct; + png_ptr->mem_ptr=mem_ptr; + struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size); + } + else +#endif /* PNG_USER_MEM_SUPPORTED */ + struct_ptr = (png_voidp)farmalloc(size); + if (struct_ptr != NULL) + png_memset(struct_ptr, 0, size); + return (struct_ptr); +} + +/* Free memory allocated by a png_create_struct() call */ +void /* PRIVATE */ +png_destroy_struct(png_voidp struct_ptr) +{ +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); +} + +/* Free memory allocated by a png_create_struct() call */ +void /* PRIVATE */ +png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, + png_voidp mem_ptr) +{ +#endif + if (struct_ptr != NULL) + { +#ifdef PNG_USER_MEM_SUPPORTED + if(free_fn != NULL) + { + png_struct dummy_struct; + png_structp png_ptr = &dummy_struct; + png_ptr->mem_ptr=mem_ptr; + (*(free_fn))(png_ptr, struct_ptr); + return; + } +#endif /* PNG_USER_MEM_SUPPORTED */ + farfree (struct_ptr); + } +} + +/* Allocate memory. For reasonable files, size should never exceed + * 64K. However, zlib may allocate more then 64K if you don't tell + * it not to. See zconf.h and png.h for more information. zlib does + * need to allocate exactly 64K, so whatever you call here must + * have the ability to do that. + * + * Borland seems to have a problem in DOS mode for exactly 64K. + * It gives you a segment with an offset of 8 (perhaps to store its + * memory stuff). zlib doesn't like this at all, so we have to + * detect and deal with it. This code should not be needed in + * Windows or OS/2 modes, and only in 16 bit mode. This code has + * been updated by Alexander Lehmann for version 0.89 to waste less + * memory. + * + * Note that we can't use png_size_t for the "size" declaration, + * since on some systems a png_size_t is a 16-bit quantity, and as a + * result, we would be truncating potentially larger memory requests + * (which should cause a fatal error) and introducing major problems. + */ + +png_voidp PNGAPI +png_malloc(png_structp png_ptr, png_uint_32 size) +{ + png_voidp ret; + + if (png_ptr == NULL || size == 0) + return (NULL); + +#ifdef PNG_USER_MEM_SUPPORTED + if(png_ptr->malloc_fn != NULL) + ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); + else + ret = (png_malloc_default(png_ptr, size)); + if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of memory!"); + return (ret); +} + +png_voidp PNGAPI +png_malloc_default(png_structp png_ptr, png_uint_32 size) +{ + png_voidp ret; +#endif /* PNG_USER_MEM_SUPPORTED */ + + if (png_ptr == NULL || size == 0) + return (NULL); + +#ifdef PNG_MAX_MALLOC_64K + if (size > (png_uint_32)65536L) + { + png_warning(png_ptr, "Cannot Allocate > 64K"); + ret = NULL; + } + else +#endif + + if (size != (size_t)size) + ret = NULL; + else if (size == (png_uint_32)65536L) + { + if (png_ptr->offset_table == NULL) + { + /* try to see if we need to do any of this fancy stuff */ + ret = farmalloc(size); + if (ret == NULL || ((png_size_t)ret & 0xffff)) + { + int num_blocks; + png_uint_32 total_size; + png_bytep table; + int i; + png_byte huge * hptr; + + if (ret != NULL) + { + farfree(ret); + ret = NULL; + } + + if(png_ptr->zlib_window_bits > 14) + num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); + else + num_blocks = 1; + if (png_ptr->zlib_mem_level >= 7) + num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7)); + else + num_blocks++; + + total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16; + + table = farmalloc(total_size); + + if (table == NULL) + { +#ifndef PNG_USER_MEM_SUPPORTED + if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */ + else + png_warning(png_ptr, "Out Of Memory."); +#endif + return (NULL); + } + + if ((png_size_t)table & 0xfff0) + { +#ifndef PNG_USER_MEM_SUPPORTED + if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, + "Farmalloc didn't return normalized pointer"); + else + png_warning(png_ptr, + "Farmalloc didn't return normalized pointer"); +#endif + return (NULL); + } + + png_ptr->offset_table = table; + png_ptr->offset_table_ptr = farmalloc(num_blocks * + png_sizeof (png_bytep)); + + if (png_ptr->offset_table_ptr == NULL) + { +#ifndef PNG_USER_MEM_SUPPORTED + if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */ + else + png_warning(png_ptr, "Out Of memory."); +#endif + return (NULL); + } + + hptr = (png_byte huge *)table; + if ((png_size_t)hptr & 0xf) + { + hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); + hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */ + } + for (i = 0; i < num_blocks; i++) + { + png_ptr->offset_table_ptr[i] = (png_bytep)hptr; + hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */ + } + + png_ptr->offset_table_number = num_blocks; + png_ptr->offset_table_count = 0; + png_ptr->offset_table_count_free = 0; + } + } + + if (png_ptr->offset_table_count >= png_ptr->offset_table_number) + { +#ifndef PNG_USER_MEM_SUPPORTED + if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */ + else + png_warning(png_ptr, "Out of Memory."); +#endif + return (NULL); + } + + ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++]; + } + else + ret = farmalloc(size); + +#ifndef PNG_USER_MEM_SUPPORTED + if (ret == NULL) + { + if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ + else + png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */ + } +#endif + + return (ret); +} + +/* free a pointer allocated by png_malloc(). In the default + configuration, png_ptr is not used, but is passed in case it + is needed. If ptr is NULL, return without taking any action. */ +void PNGAPI +png_free(png_structp png_ptr, png_voidp ptr) +{ + if (png_ptr == NULL || ptr == NULL) + return; + +#ifdef PNG_USER_MEM_SUPPORTED + if (png_ptr->free_fn != NULL) + { + (*(png_ptr->free_fn))(png_ptr, ptr); + return; + } + else png_free_default(png_ptr, ptr); +} + +void PNGAPI +png_free_default(png_structp png_ptr, png_voidp ptr) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + + if(png_ptr == NULL) return; + + if (png_ptr->offset_table != NULL) + { + int i; + + for (i = 0; i < png_ptr->offset_table_count; i++) + { + if (ptr == png_ptr->offset_table_ptr[i]) + { + ptr = NULL; + png_ptr->offset_table_count_free++; + break; + } + } + if (png_ptr->offset_table_count_free == png_ptr->offset_table_count) + { + farfree(png_ptr->offset_table); + farfree(png_ptr->offset_table_ptr); + png_ptr->offset_table = NULL; + png_ptr->offset_table_ptr = NULL; + } + } + + if (ptr != NULL) + { + farfree(ptr); + } +} + +#else /* Not the Borland DOS special memory handler */ + +/* Allocate memory for a png_struct or a png_info. The malloc and + memset can be replaced by a single call to calloc() if this is thought + to improve performance noticably. */ +png_voidp /* PRIVATE */ +png_create_struct(int type) +{ +#ifdef PNG_USER_MEM_SUPPORTED + return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); +} + +/* Allocate memory for a png_struct or a png_info. The malloc and + memset can be replaced by a single call to calloc() if this is thought + to improve performance noticably. */ +png_voidp /* PRIVATE */ +png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + png_size_t size; + png_voidp struct_ptr; + + if (type == PNG_STRUCT_INFO) + size = png_sizeof(png_info); + else if (type == PNG_STRUCT_PNG) + size = png_sizeof(png_struct); + else + return (NULL); + +#ifdef PNG_USER_MEM_SUPPORTED + if(malloc_fn != NULL) + { + png_struct dummy_struct; + png_structp png_ptr = &dummy_struct; + png_ptr->mem_ptr=mem_ptr; + struct_ptr = (*(malloc_fn))(png_ptr, size); + if (struct_ptr != NULL) + png_memset(struct_ptr, 0, size); + return (struct_ptr); + } +#endif /* PNG_USER_MEM_SUPPORTED */ + +#if defined(__TURBOC__) && !defined(__FLAT__) + struct_ptr = (png_voidp)farmalloc(size); +#else +# if defined(_MSC_VER) && defined(MAXSEG_64K) + struct_ptr = (png_voidp)halloc(size,1); +# else + struct_ptr = (png_voidp)malloc(size); +# endif +#endif + if (struct_ptr != NULL) + png_memset(struct_ptr, 0, size); + + return (struct_ptr); +} + + +/* Free memory allocated by a png_create_struct() call */ +void /* PRIVATE */ +png_destroy_struct(png_voidp struct_ptr) +{ +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); +} + +/* Free memory allocated by a png_create_struct() call */ +void /* PRIVATE */ +png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, + png_voidp mem_ptr) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + if (struct_ptr != NULL) + { +#ifdef PNG_USER_MEM_SUPPORTED + if(free_fn != NULL) + { + png_struct dummy_struct; + png_structp png_ptr = &dummy_struct; + png_ptr->mem_ptr=mem_ptr; + (*(free_fn))(png_ptr, struct_ptr); + return; + } +#endif /* PNG_USER_MEM_SUPPORTED */ +#if defined(__TURBOC__) && !defined(__FLAT__) + farfree(struct_ptr); +#else +# if defined(_MSC_VER) && defined(MAXSEG_64K) + hfree(struct_ptr); +# else + free(struct_ptr); +# endif +#endif + } +} + +/* Allocate memory. For reasonable files, size should never exceed + 64K. However, zlib may allocate more then 64K if you don't tell + it not to. See zconf.h and png.h for more information. zlib does + need to allocate exactly 64K, so whatever you call here must + have the ability to do that. */ + +png_voidp PNGAPI +png_malloc(png_structp png_ptr, png_uint_32 size) +{ + png_voidp ret; + +#ifdef PNG_USER_MEM_SUPPORTED + if (png_ptr == NULL || size == 0) + return (NULL); + + if(png_ptr->malloc_fn != NULL) + ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); + else + ret = (png_malloc_default(png_ptr, size)); + if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of Memory!"); + return (ret); +} + +png_voidp PNGAPI +png_malloc_default(png_structp png_ptr, png_uint_32 size) +{ + png_voidp ret; +#endif /* PNG_USER_MEM_SUPPORTED */ + + if (png_ptr == NULL || size == 0) + return (NULL); + +#ifdef PNG_MAX_MALLOC_64K + if (size > (png_uint_32)65536L) + { +#ifndef PNG_USER_MEM_SUPPORTED + if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Cannot Allocate > 64K"); + else +#endif + return NULL; + } +#endif + + /* Check for overflow */ +#if defined(__TURBOC__) && !defined(__FLAT__) + if (size != (unsigned long)size) + ret = NULL; + else + ret = farmalloc(size); +#else +# if defined(_MSC_VER) && defined(MAXSEG_64K) + if (size != (unsigned long)size) + ret = NULL; + else + ret = halloc(size, 1); +# else + if (size != (size_t)size) + ret = NULL; + else + ret = malloc((size_t)size); +# endif +#endif + +#ifndef PNG_USER_MEM_SUPPORTED + if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of Memory"); +#endif + + return (ret); +} + +/* Free a pointer allocated by png_malloc(). If ptr is NULL, return + without taking any action. */ +void PNGAPI +png_free(png_structp png_ptr, png_voidp ptr) +{ + if (png_ptr == NULL || ptr == NULL) + return; + +#ifdef PNG_USER_MEM_SUPPORTED + if (png_ptr->free_fn != NULL) + { + (*(png_ptr->free_fn))(png_ptr, ptr); + return; + } + else png_free_default(png_ptr, ptr); +} +void PNGAPI +png_free_default(png_structp png_ptr, png_voidp ptr) +{ + if (png_ptr == NULL || ptr == NULL) + return; + +#endif /* PNG_USER_MEM_SUPPORTED */ + +#if defined(__TURBOC__) && !defined(__FLAT__) + farfree(ptr); +#else +# if defined(_MSC_VER) && defined(MAXSEG_64K) + hfree(ptr); +# else + free(ptr); +# endif +#endif +} + +#endif /* Not Borland DOS special memory handler */ + +#if defined(PNG_1_0_X) +# define png_malloc_warn png_malloc +#else +/* This function was added at libpng version 1.2.3. The png_malloc_warn() + * function will set up png_malloc() to issue a png_warning and return NULL + * instead of issuing a png_error, if it fails to allocate the requested + * memory. + */ +png_voidp PNGAPI +png_malloc_warn(png_structp png_ptr, png_uint_32 size) +{ + png_voidp ptr; + png_uint_32 save_flags; + if(png_ptr == NULL) return (NULL); + + save_flags=png_ptr->flags; + png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; + ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); + png_ptr->flags=save_flags; + return(ptr); +} +#endif + +png_voidp PNGAPI +png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, + png_uint_32 length) +{ + png_size_t size; + + size = (png_size_t)length; + if ((png_uint_32)size != length) + png_error(png_ptr,"Overflow in png_memcpy_check."); + + return(png_memcpy (s1, s2, size)); +} + +png_voidp PNGAPI +png_memset_check (png_structp png_ptr, png_voidp s1, int value, + png_uint_32 length) +{ + png_size_t size; + + size = (png_size_t)length; + if ((png_uint_32)size != length) + png_error(png_ptr,"Overflow in png_memset_check."); + + return (png_memset (s1, value, size)); + +} + +#ifdef PNG_USER_MEM_SUPPORTED +/* This function is called when the application wants to use another method + * of allocating and freeing memory. + */ +void PNGAPI +png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr + malloc_fn, png_free_ptr free_fn) +{ + if(png_ptr != NULL) { + png_ptr->mem_ptr = mem_ptr; + png_ptr->malloc_fn = malloc_fn; + png_ptr->free_fn = free_fn; + } +} + +/* This function returns a pointer to the mem_ptr associated with the user + * functions. The application should free any memory associated with this + * pointer before png_write_destroy and png_read_destroy are called. + */ +png_voidp PNGAPI +png_get_mem_ptr(png_structp png_ptr) +{ + if(png_ptr == NULL) return (NULL); + return ((png_voidp)png_ptr->mem_ptr); +} +#endif /* PNG_USER_MEM_SUPPORTED */ +#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/pngpread.c b/src/dep/src/irrlicht/libpng/pngpread.c index d104077..d226c75 100644 --- a/src/dep/src/irrlicht/libpng/pngpread.c +++ b/src/dep/src/irrlicht/libpng/pngpread.c @@ -1,1584 +1,1584 @@ - -/* pngpread.c - read a png file in push mode - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - -/* push model modes */ -#define PNG_READ_SIG_MODE 0 -#define PNG_READ_CHUNK_MODE 1 -#define PNG_READ_IDAT_MODE 2 -#define PNG_SKIP_MODE 3 -#define PNG_READ_tEXt_MODE 4 -#define PNG_READ_zTXt_MODE 5 -#define PNG_READ_DONE_MODE 6 -#define PNG_READ_iTXt_MODE 7 -#define PNG_ERROR_MODE 8 - -void PNGAPI -png_process_data(png_structp png_ptr, png_infop info_ptr, - png_bytep buffer, png_size_t buffer_size) -{ - if(png_ptr == NULL) return; - png_push_restore_buffer(png_ptr, buffer, buffer_size); - - while (png_ptr->buffer_size) - { - png_process_some_data(png_ptr, info_ptr); - } -} - -/* What we do with the incoming data depends on what we were previously - * doing before we ran out of data... - */ -void /* PRIVATE */ -png_process_some_data(png_structp png_ptr, png_infop info_ptr) -{ - if(png_ptr == NULL) return; - switch (png_ptr->process_mode) - { - case PNG_READ_SIG_MODE: - { - png_push_read_sig(png_ptr, info_ptr); - break; - } - case PNG_READ_CHUNK_MODE: - { - png_push_read_chunk(png_ptr, info_ptr); - break; - } - case PNG_READ_IDAT_MODE: - { - png_push_read_IDAT(png_ptr); - break; - } -#if defined(PNG_READ_tEXt_SUPPORTED) - case PNG_READ_tEXt_MODE: - { - png_push_read_tEXt(png_ptr, info_ptr); - break; - } -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - case PNG_READ_zTXt_MODE: - { - png_push_read_zTXt(png_ptr, info_ptr); - break; - } -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - case PNG_READ_iTXt_MODE: - { - png_push_read_iTXt(png_ptr, info_ptr); - break; - } -#endif - case PNG_SKIP_MODE: - { - png_push_crc_finish(png_ptr); - break; - } - default: - { - png_ptr->buffer_size = 0; - break; - } - } -} - -/* Read any remaining signature bytes from the stream and compare them with - * the correct PNG signature. It is possible that this routine is called - * with bytes already read from the signature, either because they have been - * checked by the calling application, or because of multiple calls to this - * routine. - */ -void /* PRIVATE */ -png_push_read_sig(png_structp png_ptr, png_infop info_ptr) -{ - png_size_t num_checked = png_ptr->sig_bytes, - num_to_check = 8 - num_checked; - - if (png_ptr->buffer_size < num_to_check) - { - num_to_check = png_ptr->buffer_size; - } - - png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), - num_to_check); - png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes+num_to_check); - - if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) - { - if (num_checked < 4 && - png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) - png_error(png_ptr, "Not a PNG file"); - else - png_error(png_ptr, "PNG file corrupted by ASCII conversion"); - } - else - { - if (png_ptr->sig_bytes >= 8) - { - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - } - } -} - -void /* PRIVATE */ -png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_USE_LOCAL_ARRAYS */ - /* First we make sure we have enough data for the 4 byte chunk name - * and the 4 byte chunk length before proceeding with decoding the - * chunk data. To fully decode each of these chunks, we also make - * sure we have enough data in the buffer for the 4 byte CRC at the - * end of every chunk (except IDAT, which is handled separately). - */ - if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) - { - png_byte chunk_length[4]; - - if (png_ptr->buffer_size < 8) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; - } - - if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - if(png_ptr->mode & PNG_AFTER_IDAT) - png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); - } - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); - - png_ptr->process_mode = PNG_READ_DONE_MODE; - png_push_have_end(png_ptr, info_ptr); - } -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_ptr->mode |= PNG_HAVE_IDAT; - png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_ptr->mode |= PNG_HAVE_PLTE; - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - } - } -#endif - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); - } - else if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - { - /* If we reach an IDAT chunk, this means we have read all of the - * header chunks, and we can start reading the image (or if this - * is called after the image has been read - we have an error). - */ - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - { - if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - if (png_ptr->push_length == 0) - return; - - if (png_ptr->mode & PNG_AFTER_IDAT) - png_error(png_ptr, "Too many IDAT's found"); - } - - png_ptr->idat_size = png_ptr->push_length; - png_ptr->mode |= PNG_HAVE_IDAT; - png_ptr->process_mode = PNG_READ_IDAT_MODE; - png_push_have_info(png_ptr, info_ptr); - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - png_ptr->zstream.next_out = png_ptr->row_buf; - return; - } -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif - else - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); - } - - png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; -} - -void /* PRIVATE */ -png_push_crc_skip(png_structp png_ptr, png_uint_32 skip) -{ - png_ptr->process_mode = PNG_SKIP_MODE; - png_ptr->skip_length = skip; -} - -void /* PRIVATE */ -png_push_crc_finish(png_structp png_ptr) -{ - if (png_ptr->skip_length && png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (png_ptr->skip_length < (png_uint_32)png_ptr->save_buffer_size) - save_size = (png_size_t)png_ptr->skip_length; - else - save_size = png_ptr->save_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - - png_ptr->skip_length -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (png_ptr->skip_length && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (png_ptr->skip_length < (png_uint_32)png_ptr->current_buffer_size) - save_size = (png_size_t)png_ptr->skip_length; - else - save_size = png_ptr->current_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); - - png_ptr->skip_length -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } - if (!png_ptr->skip_length) - { - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_crc_finish(png_ptr, 0); - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - } -} - -void PNGAPI -png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) -{ - png_bytep ptr; - - if(png_ptr == NULL) return; - ptr = buffer; - if (png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (length < png_ptr->save_buffer_size) - save_size = length; - else - save_size = png_ptr->save_buffer_size; - - png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size); - length -= save_size; - ptr += save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (length && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (length < png_ptr->current_buffer_size) - save_size = length; - else - save_size = png_ptr->current_buffer_size; - - png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size); - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } -} - -void /* PRIVATE */ -png_push_save_buffer(png_structp png_ptr) -{ - if (png_ptr->save_buffer_size) - { - if (png_ptr->save_buffer_ptr != png_ptr->save_buffer) - { - png_size_t i,istop; - png_bytep sp; - png_bytep dp; - - istop = png_ptr->save_buffer_size; - for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer; - i < istop; i++, sp++, dp++) - { - *dp = *sp; - } - } - } - if (png_ptr->save_buffer_size + png_ptr->current_buffer_size > - png_ptr->save_buffer_max) - { - png_size_t new_max; - png_bytep old_buffer; - - if (png_ptr->save_buffer_size > PNG_SIZE_MAX - - (png_ptr->current_buffer_size + 256)) - { - png_error(png_ptr, "Potential overflow of save_buffer"); - } - new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; - old_buffer = png_ptr->save_buffer; - png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, - (png_uint_32)new_max); - png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); - png_free(png_ptr, old_buffer); - png_ptr->save_buffer_max = new_max; - } - if (png_ptr->current_buffer_size) - { - png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size, - png_ptr->current_buffer_ptr, png_ptr->current_buffer_size); - png_ptr->save_buffer_size += png_ptr->current_buffer_size; - png_ptr->current_buffer_size = 0; - } - png_ptr->save_buffer_ptr = png_ptr->save_buffer; - png_ptr->buffer_size = 0; -} - -void /* PRIVATE */ -png_push_restore_buffer(png_structp png_ptr, png_bytep buffer, - png_size_t buffer_length) -{ - png_ptr->current_buffer = buffer; - png_ptr->current_buffer_size = buffer_length; - png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size; - png_ptr->current_buffer_ptr = png_ptr->current_buffer; -} - -void /* PRIVATE */ -png_push_read_IDAT(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) - { - png_byte chunk_length[4]; - - if (png_ptr->buffer_size < 8) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; - - if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - { - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_error(png_ptr, "Not enough compressed data"); - return; - } - - png_ptr->idat_size = png_ptr->push_length; - } - if (png_ptr->idat_size && png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size) - { - save_size = (png_size_t)png_ptr->idat_size; - /* check for overflow */ - if((png_uint_32)save_size != png_ptr->idat_size) - png_error(png_ptr, "save_size overflowed in pngpread"); - } - else - save_size = png_ptr->save_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); - png_ptr->idat_size -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (png_ptr->idat_size && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size) - { - save_size = (png_size_t)png_ptr->idat_size; - /* check for overflow */ - if((png_uint_32)save_size != png_ptr->idat_size) - png_error(png_ptr, "save_size overflowed in pngpread"); - } - else - save_size = png_ptr->current_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size); - - png_ptr->idat_size -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } - if (!png_ptr->idat_size) - { - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_crc_finish(png_ptr, 0); - png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; - png_ptr->mode |= PNG_AFTER_IDAT; - } -} - -void /* PRIVATE */ -png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, - png_size_t buffer_length) -{ - int ret; - - if ((png_ptr->flags & PNG_FLAG_ZLIB_FINISHED) && buffer_length) - png_error(png_ptr, "Extra compression data"); - - png_ptr->zstream.next_in = buffer; - png_ptr->zstream.avail_in = (uInt)buffer_length; - for(;;) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK) - { - if (ret == Z_STREAM_END) - { - if (png_ptr->zstream.avail_in) - png_error(png_ptr, "Extra compressed data"); - if (!(png_ptr->zstream.avail_out)) - { - png_push_process_row(png_ptr); - } - - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - else if (ret == Z_BUF_ERROR) - break; - else - png_error(png_ptr, "Decompression Error"); - } - if (!(png_ptr->zstream.avail_out)) - { - if (( -#if defined(PNG_READ_INTERLACING_SUPPORTED) - png_ptr->interlaced && png_ptr->pass > 6) || - (!png_ptr->interlaced && -#endif - png_ptr->row_number == png_ptr->num_rows)) - { - if (png_ptr->zstream.avail_in) - png_warning(png_ptr, "Too much data in IDAT chunks"); - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - png_push_process_row(png_ptr); - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - png_ptr->zstream.next_out = png_ptr->row_buf; - } - else - break; - } -} - -void /* PRIVATE */ -png_push_process_row(png_structp png_ptr) -{ - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->iwidth; - png_ptr->row_info.channels = png_ptr->channels; - png_ptr->row_info.bit_depth = png_ptr->bit_depth; - png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; - - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); - - png_read_filter_row(png_ptr, &(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->prev_row + 1, - (int)(png_ptr->row_buf[0])); - - png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, - png_ptr->rowbytes + 1); - - if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) - png_do_read_transformations(png_ptr); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* blow up interlaced rows to full size */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - if (png_ptr->pass < 6) -/* old interface (pre-1.0.9): - png_do_read_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); - */ - png_do_read_interlace(png_ptr); - - switch (png_ptr->pass) - { - case 0: - { - int i; - for (i = 0; i < 8 && png_ptr->pass == 0; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); /* updates png_ptr->pass */ - } - if (png_ptr->pass == 2) /* pass 1 might be empty */ - { - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - if (png_ptr->pass == 4 && png_ptr->height <= 4) - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - if (png_ptr->pass == 6 && png_ptr->height <= 4) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 1: - { - int i; - for (i = 0; i < 8 && png_ptr->pass == 1; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 2) /* skip top 4 generated rows */ - { - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 2: - { - int i; - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 4) /* pass 3 might be empty */ - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 3: - { - int i; - for (i = 0; i < 4 && png_ptr->pass == 3; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 4) /* skip top two generated rows */ - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 4: - { - int i; - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 6) /* pass 5 might be empty */ - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 5: - { - int i; - for (i = 0; i < 2 && png_ptr->pass == 5; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 6) /* skip top generated row */ - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 6: - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - if (png_ptr->pass != 6) - break; - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - } - else -#endif - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } -} - -void /* PRIVATE */ -png_read_push_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; - - /* Width of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h - const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; - */ - - /* Height of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h - const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; - */ -#endif - - png_ptr->row_number++; - if (png_ptr->row_number < png_ptr->num_rows) - return; - - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - png_memset_check(png_ptr, png_ptr->prev_row, 0, - png_ptr->rowbytes + 1); - do - { - png_ptr->pass++; - if ((png_ptr->pass == 1 && png_ptr->width < 5) || - (png_ptr->pass == 3 && png_ptr->width < 3) || - (png_ptr->pass == 5 && png_ptr->width < 2)) - png_ptr->pass++; - - if (png_ptr->pass > 7) - png_ptr->pass--; - if (png_ptr->pass >= 7) - break; - - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, - png_ptr->iwidth) + 1; - - if (png_ptr->transformations & PNG_INTERLACE) - break; - - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - - } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); - } -} - -#if defined(PNG_READ_tEXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place tEXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - png_ptr->skip_length = 0; /* This may not be necessary */ - - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ - { - png_warning(png_ptr, "tEXt chunk too large to fit in memory"); - png_ptr->skip_length = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_tEXt_MODE; -} - -void /* PRIVATE */ -png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp text; - png_charp key; - int ret; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - -#if defined(PNG_MAX_MALLOC_64K) - if (png_ptr->skip_length) - return; -#endif - - key = png_ptr->current_text; - - for (text = key; *text; text++) - /* empty loop */ ; - - if (text != key + png_ptr->current_text_size) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; -#endif - text_ptr->text = text; - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - png_ptr->current_text = NULL; - - if (ret) - png_warning(png_ptr, "Insufficient memory to store text chunk."); - } -} -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place zTXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - /* We can't handle zTXt chunks > 64K, since we don't have enough space - * to be able to store the uncompressed data. Actually, the threshold - * is probably around 32K, but it isn't as definite as 64K is. - */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "zTXt chunk too large to fit in memory"); - png_push_crc_skip(png_ptr, length); - return; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_zTXt_MODE; -} - -void /* PRIVATE */ -png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp text; - png_charp key; - int ret; - png_size_t text_size, key_size; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - - key = png_ptr->current_text; - - for (text = key; *text; text++) - /* empty loop */ ; - - /* zTXt can't have zero text */ - if (text == key + png_ptr->current_text_size) - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - return; - } - - text++; - - if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */ - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - return; - } - - text++; - - png_ptr->zstream.next_in = (png_bytep )text; - png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size - - (text - key)); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - key_size = text - key; - text_size = 0; - text = NULL; - ret = Z_STREAM_END; - - while (png_ptr->zstream.avail_in) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK && ret != Z_STREAM_END) - { - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - png_ptr->current_text = NULL; - png_free(png_ptr, key); - png_free(png_ptr, text); - return; - } - if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END) - { - if (text == NULL) - { - text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + key_size + 1)); - png_memcpy(text + key_size, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - png_memcpy(text, key, key_size); - text_size = key_size + png_ptr->zbuf_size - - png_ptr->zstream.avail_out; - *(text + text_size) = '\0'; - } - else - { - png_charp tmp; - - tmp = text; - text = (png_charp)png_malloc(png_ptr, text_size + - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + 1)); - png_memcpy(text, tmp, text_size); - png_free(png_ptr, tmp); - png_memcpy(text + text_size, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; - *(text + text_size) = '\0'; - } - if (ret != Z_STREAM_END) - { - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - else - { - break; - } - - if (ret == Z_STREAM_END) - break; - } - - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - if (ret != Z_STREAM_END) - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - png_free(png_ptr, text); - return; - } - - png_ptr->current_text = NULL; - png_free(png_ptr, key); - key = text; - text += key_size; - - text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; -#endif - text_ptr->text = text; - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - - if (ret) - png_warning(png_ptr, "Insufficient memory to store text chunk."); - } -} -#endif - -#if defined(PNG_READ_iTXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place iTXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - png_ptr->skip_length = 0; /* This may not be necessary */ - - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ - { - png_warning(png_ptr, "iTXt chunk too large to fit in memory"); - png_ptr->skip_length = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_iTXt_MODE; -} - -void /* PRIVATE */ -png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) -{ - - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp key; - int comp_flag; - png_charp lang; - png_charp lang_key; - png_charp text; - int ret; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - -#if defined(PNG_MAX_MALLOC_64K) - if (png_ptr->skip_length) - return; -#endif - - key = png_ptr->current_text; - - for (lang = key; *lang; lang++) - /* empty loop */ ; - - if (lang != key + png_ptr->current_text_size) - lang++; - - comp_flag = *lang++; - lang++; /* skip comp_type, always zero */ - - for (lang_key = lang; *lang_key; lang_key++) - /* empty loop */ ; - lang_key++; /* skip NUL separator */ - - for (text = lang_key; *text; text++) - /* empty loop */ ; - - if (text != key + png_ptr->current_text_size) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); - text_ptr->compression = comp_flag + 2; - text_ptr->key = key; - text_ptr->lang = lang; - text_ptr->lang_key = lang_key; - text_ptr->text = text; - text_ptr->text_length = 0; - text_ptr->itxt_length = png_strlen(text); - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_ptr->current_text = NULL; - - png_free(png_ptr, text_ptr); - if (ret) - png_warning(png_ptr, "Insufficient memory to store iTXt chunk."); - } -} -#endif - -/* This function is called when we haven't found a handler for this - * chunk. If there isn't a problem with the chunk itself (ie a bad chunk - * name or a critical chunk), the chunk is (currently) silently ignored. - */ -void /* PRIVATE */ -png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - png_uint_32 skip=0; - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - - if (!(png_ptr->chunk_name[0] & 0x20)) - { -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL -#endif - ) -#endif - png_chunk_error(png_ptr, "unknown critical chunk"); - - /* to quiet compiler warnings about unused info_ptr */ - if (info_ptr == NULL) - return; - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) - { - png_unknown_chunk chunk; - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "unknown chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); - chunk.data = (png_bytep)png_malloc(png_ptr, length); - png_crc_read(png_ptr, chunk.data, length); - chunk.size = length; -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) - { - /* callback to user unknown chunk handler */ - if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) - { - if (!(png_ptr->chunk_name[0] & 0x20)) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS) - png_chunk_error(png_ptr, "unknown critical chunk"); - } - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - } - else -#endif - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - png_free(png_ptr, chunk.data); - } - else -#endif - skip=length; - png_push_crc_skip(png_ptr, skip); -} - -void /* PRIVATE */ -png_push_have_info(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->info_fn != NULL) - (*(png_ptr->info_fn))(png_ptr, info_ptr); -} - -void /* PRIVATE */ -png_push_have_end(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->end_fn != NULL) - (*(png_ptr->end_fn))(png_ptr, info_ptr); -} - -void /* PRIVATE */ -png_push_have_row(png_structp png_ptr, png_bytep row) -{ - if (png_ptr->row_fn != NULL) - (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number, - (int)png_ptr->pass); -} - -void PNGAPI -png_progressive_combine_row (png_structp png_ptr, - png_bytep old_row, png_bytep new_row) -{ - if(png_ptr == NULL) return; -#ifdef PNG_USE_LOCAL_ARRAYS - const int FARDATA png_pass_dsp_mask[7] = - {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; -#endif - if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ - png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); -} - -void PNGAPI -png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn) -{ - if(png_ptr == NULL) return; - png_ptr->info_fn = info_fn; - png_ptr->row_fn = row_fn; - png_ptr->end_fn = end_fn; - - png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer); -} - -png_voidp PNGAPI -png_get_progressive_ptr(png_structp png_ptr) -{ - if(png_ptr == NULL) return (NULL); - return png_ptr->io_ptr; -} -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +/* pngpread.c - read a png file in push mode + * + * Last changed in libpng 1.2.13 November 13, 2006 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +#define PNG_INTERNAL +#include "png.h" + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + +/* push model modes */ +#define PNG_READ_SIG_MODE 0 +#define PNG_READ_CHUNK_MODE 1 +#define PNG_READ_IDAT_MODE 2 +#define PNG_SKIP_MODE 3 +#define PNG_READ_tEXt_MODE 4 +#define PNG_READ_zTXt_MODE 5 +#define PNG_READ_DONE_MODE 6 +#define PNG_READ_iTXt_MODE 7 +#define PNG_ERROR_MODE 8 + +void PNGAPI +png_process_data(png_structp png_ptr, png_infop info_ptr, + png_bytep buffer, png_size_t buffer_size) +{ + if(png_ptr == NULL) return; + png_push_restore_buffer(png_ptr, buffer, buffer_size); + + while (png_ptr->buffer_size) + { + png_process_some_data(png_ptr, info_ptr); + } +} + +/* What we do with the incoming data depends on what we were previously + * doing before we ran out of data... + */ +void /* PRIVATE */ +png_process_some_data(png_structp png_ptr, png_infop info_ptr) +{ + if(png_ptr == NULL) return; + switch (png_ptr->process_mode) + { + case PNG_READ_SIG_MODE: + { + png_push_read_sig(png_ptr, info_ptr); + break; + } + case PNG_READ_CHUNK_MODE: + { + png_push_read_chunk(png_ptr, info_ptr); + break; + } + case PNG_READ_IDAT_MODE: + { + png_push_read_IDAT(png_ptr); + break; + } +#if defined(PNG_READ_tEXt_SUPPORTED) + case PNG_READ_tEXt_MODE: + { + png_push_read_tEXt(png_ptr, info_ptr); + break; + } +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + case PNG_READ_zTXt_MODE: + { + png_push_read_zTXt(png_ptr, info_ptr); + break; + } +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + case PNG_READ_iTXt_MODE: + { + png_push_read_iTXt(png_ptr, info_ptr); + break; + } +#endif + case PNG_SKIP_MODE: + { + png_push_crc_finish(png_ptr); + break; + } + default: + { + png_ptr->buffer_size = 0; + break; + } + } +} + +/* Read any remaining signature bytes from the stream and compare them with + * the correct PNG signature. It is possible that this routine is called + * with bytes already read from the signature, either because they have been + * checked by the calling application, or because of multiple calls to this + * routine. + */ +void /* PRIVATE */ +png_push_read_sig(png_structp png_ptr, png_infop info_ptr) +{ + png_size_t num_checked = png_ptr->sig_bytes, + num_to_check = 8 - num_checked; + + if (png_ptr->buffer_size < num_to_check) + { + num_to_check = png_ptr->buffer_size; + } + + png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), + num_to_check); + png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes+num_to_check); + + if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) + { + if (num_checked < 4 && + png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) + png_error(png_ptr, "Not a PNG file"); + else + png_error(png_ptr, "PNG file corrupted by ASCII conversion"); + } + else + { + if (png_ptr->sig_bytes >= 8) + { + png_ptr->process_mode = PNG_READ_CHUNK_MODE; + } + } +} + +void /* PRIVATE */ +png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IHDR; + PNG_IDAT; + PNG_IEND; + PNG_PLTE; +#if defined(PNG_READ_bKGD_SUPPORTED) + PNG_bKGD; +#endif +#if defined(PNG_READ_cHRM_SUPPORTED) + PNG_cHRM; +#endif +#if defined(PNG_READ_gAMA_SUPPORTED) + PNG_gAMA; +#endif +#if defined(PNG_READ_hIST_SUPPORTED) + PNG_hIST; +#endif +#if defined(PNG_READ_iCCP_SUPPORTED) + PNG_iCCP; +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + PNG_iTXt; +#endif +#if defined(PNG_READ_oFFs_SUPPORTED) + PNG_oFFs; +#endif +#if defined(PNG_READ_pCAL_SUPPORTED) + PNG_pCAL; +#endif +#if defined(PNG_READ_pHYs_SUPPORTED) + PNG_pHYs; +#endif +#if defined(PNG_READ_sBIT_SUPPORTED) + PNG_sBIT; +#endif +#if defined(PNG_READ_sCAL_SUPPORTED) + PNG_sCAL; +#endif +#if defined(PNG_READ_sRGB_SUPPORTED) + PNG_sRGB; +#endif +#if defined(PNG_READ_sPLT_SUPPORTED) + PNG_sPLT; +#endif +#if defined(PNG_READ_tEXt_SUPPORTED) + PNG_tEXt; +#endif +#if defined(PNG_READ_tIME_SUPPORTED) + PNG_tIME; +#endif +#if defined(PNG_READ_tRNS_SUPPORTED) + PNG_tRNS; +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + PNG_zTXt; +#endif +#endif /* PNG_USE_LOCAL_ARRAYS */ + /* First we make sure we have enough data for the 4 byte chunk name + * and the 4 byte chunk length before proceeding with decoding the + * chunk data. To fully decode each of these chunks, we also make + * sure we have enough data in the buffer for the 4 byte CRC at the + * end of every chunk (except IDAT, which is handled separately). + */ + if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) + { + png_byte chunk_length[4]; + + if (png_ptr->buffer_size < 8) + { + png_push_save_buffer(png_ptr); + return; + } + + png_push_fill_buffer(png_ptr, chunk_length, 4); + png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); + png_reset_crc(png_ptr); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); + png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; + } + + if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) + if(png_ptr->mode & PNG_AFTER_IDAT) + png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; + + if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); + } + else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); + + png_ptr->process_mode = PNG_READ_DONE_MODE; + png_push_have_end(png_ptr, info_ptr); + } +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + png_ptr->mode |= PNG_HAVE_IDAT; + png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); + if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + png_ptr->mode |= PNG_HAVE_PLTE; + else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + { + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before IDAT"); + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing PLTE before IDAT"); + } + } +#endif + else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); + } + else if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) + { + /* If we reach an IDAT chunk, this means we have read all of the + * header chunks, and we can start reading the image (or if this + * is called after the image has been read - we have an error). + */ + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before IDAT"); + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing PLTE before IDAT"); + + if (png_ptr->mode & PNG_HAVE_IDAT) + { + if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) + if (png_ptr->push_length == 0) + return; + + if (png_ptr->mode & PNG_AFTER_IDAT) + png_error(png_ptr, "Too many IDAT's found"); + } + + png_ptr->idat_size = png_ptr->push_length; + png_ptr->mode |= PNG_HAVE_IDAT; + png_ptr->process_mode = PNG_READ_IDAT_MODE; + png_push_have_info(png_ptr, info_ptr); + png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; + png_ptr->zstream.next_out = png_ptr->row_buf; + return; + } +#if defined(PNG_READ_gAMA_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_sBIT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_cHRM_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_sRGB_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_iCCP_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_sPLT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_tRNS_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_bKGD_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_hIST_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_pHYs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_oFFs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_pCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_sCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_tIME_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_tEXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); + } +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); + } +#endif + else + { + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { + png_push_save_buffer(png_ptr); + return; + } + png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); + } + + png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; +} + +void /* PRIVATE */ +png_push_crc_skip(png_structp png_ptr, png_uint_32 skip) +{ + png_ptr->process_mode = PNG_SKIP_MODE; + png_ptr->skip_length = skip; +} + +void /* PRIVATE */ +png_push_crc_finish(png_structp png_ptr) +{ + if (png_ptr->skip_length && png_ptr->save_buffer_size) + { + png_size_t save_size; + + if (png_ptr->skip_length < (png_uint_32)png_ptr->save_buffer_size) + save_size = (png_size_t)png_ptr->skip_length; + else + save_size = png_ptr->save_buffer_size; + + png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); + + png_ptr->skip_length -= save_size; + png_ptr->buffer_size -= save_size; + png_ptr->save_buffer_size -= save_size; + png_ptr->save_buffer_ptr += save_size; + } + if (png_ptr->skip_length && png_ptr->current_buffer_size) + { + png_size_t save_size; + + if (png_ptr->skip_length < (png_uint_32)png_ptr->current_buffer_size) + save_size = (png_size_t)png_ptr->skip_length; + else + save_size = png_ptr->current_buffer_size; + + png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); + + png_ptr->skip_length -= save_size; + png_ptr->buffer_size -= save_size; + png_ptr->current_buffer_size -= save_size; + png_ptr->current_buffer_ptr += save_size; + } + if (!png_ptr->skip_length) + { + if (png_ptr->buffer_size < 4) + { + png_push_save_buffer(png_ptr); + return; + } + + png_crc_finish(png_ptr, 0); + png_ptr->process_mode = PNG_READ_CHUNK_MODE; + } +} + +void PNGAPI +png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) +{ + png_bytep ptr; + + if(png_ptr == NULL) return; + ptr = buffer; + if (png_ptr->save_buffer_size) + { + png_size_t save_size; + + if (length < png_ptr->save_buffer_size) + save_size = length; + else + save_size = png_ptr->save_buffer_size; + + png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size); + length -= save_size; + ptr += save_size; + png_ptr->buffer_size -= save_size; + png_ptr->save_buffer_size -= save_size; + png_ptr->save_buffer_ptr += save_size; + } + if (length && png_ptr->current_buffer_size) + { + png_size_t save_size; + + if (length < png_ptr->current_buffer_size) + save_size = length; + else + save_size = png_ptr->current_buffer_size; + + png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size); + png_ptr->buffer_size -= save_size; + png_ptr->current_buffer_size -= save_size; + png_ptr->current_buffer_ptr += save_size; + } +} + +void /* PRIVATE */ +png_push_save_buffer(png_structp png_ptr) +{ + if (png_ptr->save_buffer_size) + { + if (png_ptr->save_buffer_ptr != png_ptr->save_buffer) + { + png_size_t i,istop; + png_bytep sp; + png_bytep dp; + + istop = png_ptr->save_buffer_size; + for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer; + i < istop; i++, sp++, dp++) + { + *dp = *sp; + } + } + } + if (png_ptr->save_buffer_size + png_ptr->current_buffer_size > + png_ptr->save_buffer_max) + { + png_size_t new_max; + png_bytep old_buffer; + + if (png_ptr->save_buffer_size > PNG_SIZE_MAX - + (png_ptr->current_buffer_size + 256)) + { + png_error(png_ptr, "Potential overflow of save_buffer"); + } + new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; + old_buffer = png_ptr->save_buffer; + png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, + (png_uint_32)new_max); + png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); + png_free(png_ptr, old_buffer); + png_ptr->save_buffer_max = new_max; + } + if (png_ptr->current_buffer_size) + { + png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size, + png_ptr->current_buffer_ptr, png_ptr->current_buffer_size); + png_ptr->save_buffer_size += png_ptr->current_buffer_size; + png_ptr->current_buffer_size = 0; + } + png_ptr->save_buffer_ptr = png_ptr->save_buffer; + png_ptr->buffer_size = 0; +} + +void /* PRIVATE */ +png_push_restore_buffer(png_structp png_ptr, png_bytep buffer, + png_size_t buffer_length) +{ + png_ptr->current_buffer = buffer; + png_ptr->current_buffer_size = buffer_length; + png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size; + png_ptr->current_buffer_ptr = png_ptr->current_buffer; +} + +void /* PRIVATE */ +png_push_read_IDAT(png_structp png_ptr) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IDAT; +#endif + if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) + { + png_byte chunk_length[4]; + + if (png_ptr->buffer_size < 8) + { + png_push_save_buffer(png_ptr); + return; + } + + png_push_fill_buffer(png_ptr, chunk_length, 4); + png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); + png_reset_crc(png_ptr); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); + png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; + + if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) + { + png_ptr->process_mode = PNG_READ_CHUNK_MODE; + if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) + png_error(png_ptr, "Not enough compressed data"); + return; + } + + png_ptr->idat_size = png_ptr->push_length; + } + if (png_ptr->idat_size && png_ptr->save_buffer_size) + { + png_size_t save_size; + + if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size) + { + save_size = (png_size_t)png_ptr->idat_size; + /* check for overflow */ + if((png_uint_32)save_size != png_ptr->idat_size) + png_error(png_ptr, "save_size overflowed in pngpread"); + } + else + save_size = png_ptr->save_buffer_size; + + png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); + if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) + png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); + png_ptr->idat_size -= save_size; + png_ptr->buffer_size -= save_size; + png_ptr->save_buffer_size -= save_size; + png_ptr->save_buffer_ptr += save_size; + } + if (png_ptr->idat_size && png_ptr->current_buffer_size) + { + png_size_t save_size; + + if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size) + { + save_size = (png_size_t)png_ptr->idat_size; + /* check for overflow */ + if((png_uint_32)save_size != png_ptr->idat_size) + png_error(png_ptr, "save_size overflowed in pngpread"); + } + else + save_size = png_ptr->current_buffer_size; + + png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); + if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) + png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size); + + png_ptr->idat_size -= save_size; + png_ptr->buffer_size -= save_size; + png_ptr->current_buffer_size -= save_size; + png_ptr->current_buffer_ptr += save_size; + } + if (!png_ptr->idat_size) + { + if (png_ptr->buffer_size < 4) + { + png_push_save_buffer(png_ptr); + return; + } + + png_crc_finish(png_ptr, 0); + png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; + png_ptr->mode |= PNG_AFTER_IDAT; + } +} + +void /* PRIVATE */ +png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, + png_size_t buffer_length) +{ + int ret; + + if ((png_ptr->flags & PNG_FLAG_ZLIB_FINISHED) && buffer_length) + png_error(png_ptr, "Extra compression data"); + + png_ptr->zstream.next_in = buffer; + png_ptr->zstream.avail_in = (uInt)buffer_length; + for(;;) + { + ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); + if (ret != Z_OK) + { + if (ret == Z_STREAM_END) + { + if (png_ptr->zstream.avail_in) + png_error(png_ptr, "Extra compressed data"); + if (!(png_ptr->zstream.avail_out)) + { + png_push_process_row(png_ptr); + } + + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; + break; + } + else if (ret == Z_BUF_ERROR) + break; + else + png_error(png_ptr, "Decompression Error"); + } + if (!(png_ptr->zstream.avail_out)) + { + if (( +#if defined(PNG_READ_INTERLACING_SUPPORTED) + png_ptr->interlaced && png_ptr->pass > 6) || + (!png_ptr->interlaced && +#endif + png_ptr->row_number == png_ptr->num_rows)) + { + if (png_ptr->zstream.avail_in) + png_warning(png_ptr, "Too much data in IDAT chunks"); + png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; + break; + } + png_push_process_row(png_ptr); + png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; + png_ptr->zstream.next_out = png_ptr->row_buf; + } + else + break; + } +} + +void /* PRIVATE */ +png_push_process_row(png_structp png_ptr) +{ + png_ptr->row_info.color_type = png_ptr->color_type; + png_ptr->row_info.width = png_ptr->iwidth; + png_ptr->row_info.channels = png_ptr->channels; + png_ptr->row_info.bit_depth = png_ptr->bit_depth; + png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; + + png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, + png_ptr->row_info.width); + + png_read_filter_row(png_ptr, &(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->prev_row + 1, + (int)(png_ptr->row_buf[0])); + + png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, + png_ptr->rowbytes + 1); + + if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) + png_do_read_transformations(png_ptr); + +#if defined(PNG_READ_INTERLACING_SUPPORTED) + /* blow up interlaced rows to full size */ + if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) + { + if (png_ptr->pass < 6) +/* old interface (pre-1.0.9): + png_do_read_interlace(&(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); + */ + png_do_read_interlace(png_ptr); + + switch (png_ptr->pass) + { + case 0: + { + int i; + for (i = 0; i < 8 && png_ptr->pass == 0; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); /* updates png_ptr->pass */ + } + if (png_ptr->pass == 2) /* pass 1 might be empty */ + { + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + if (png_ptr->pass == 4 && png_ptr->height <= 4) + { + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + if (png_ptr->pass == 6 && png_ptr->height <= 4) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + break; + } + case 1: + { + int i; + for (i = 0; i < 8 && png_ptr->pass == 1; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + if (png_ptr->pass == 2) /* skip top 4 generated rows */ + { + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + break; + } + case 2: + { + int i; + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + if (png_ptr->pass == 4) /* pass 3 might be empty */ + { + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + break; + } + case 3: + { + int i; + for (i = 0; i < 4 && png_ptr->pass == 3; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + if (png_ptr->pass == 4) /* skip top two generated rows */ + { + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + break; + } + case 4: + { + int i; + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + if (png_ptr->pass == 6) /* pass 5 might be empty */ + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + break; + } + case 5: + { + int i; + for (i = 0; i < 2 && png_ptr->pass == 5; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + if (png_ptr->pass == 6) /* skip top generated row */ + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + break; + } + case 6: + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + if (png_ptr->pass != 6) + break; + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + } + else +#endif + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } +} + +void /* PRIVATE */ +png_read_push_finish_row(png_structp png_ptr) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + + /* start of interlace block */ + const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; + + /* offset to next interlace block */ + const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; + + /* start of interlace block in the y direction */ + const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; + + /* offset to next interlace block in the y direction */ + const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; + + /* Width of interlace block. This is not currently used - if you need + * it, uncomment it here and in png.h + const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; + */ + + /* Height of interlace block. This is not currently used - if you need + * it, uncomment it here and in png.h + const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; + */ +#endif + + png_ptr->row_number++; + if (png_ptr->row_number < png_ptr->num_rows) + return; + + if (png_ptr->interlaced) + { + png_ptr->row_number = 0; + png_memset_check(png_ptr, png_ptr->prev_row, 0, + png_ptr->rowbytes + 1); + do + { + png_ptr->pass++; + if ((png_ptr->pass == 1 && png_ptr->width < 5) || + (png_ptr->pass == 3 && png_ptr->width < 3) || + (png_ptr->pass == 5 && png_ptr->width < 2)) + png_ptr->pass++; + + if (png_ptr->pass > 7) + png_ptr->pass--; + if (png_ptr->pass >= 7) + break; + + png_ptr->iwidth = (png_ptr->width + + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; + + png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, + png_ptr->iwidth) + 1; + + if (png_ptr->transformations & PNG_INTERLACE) + break; + + png_ptr->num_rows = (png_ptr->height + + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; + + } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); + } +} + +#if defined(PNG_READ_tEXt_SUPPORTED) +void /* PRIVATE */ +png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 + length) +{ + if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) + { + png_error(png_ptr, "Out of place tEXt"); + /* to quiet some compiler warnings */ + if(info_ptr == NULL) return; + } + +#ifdef PNG_MAX_MALLOC_64K + png_ptr->skip_length = 0; /* This may not be necessary */ + + if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ + { + png_warning(png_ptr, "tEXt chunk too large to fit in memory"); + png_ptr->skip_length = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + + png_ptr->current_text = (png_charp)png_malloc(png_ptr, + (png_uint_32)(length+1)); + png_ptr->current_text[length] = '\0'; + png_ptr->current_text_ptr = png_ptr->current_text; + png_ptr->current_text_size = (png_size_t)length; + png_ptr->current_text_left = (png_size_t)length; + png_ptr->process_mode = PNG_READ_tEXt_MODE; +} + +void /* PRIVATE */ +png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr->buffer_size && png_ptr->current_text_left) + { + png_size_t text_size; + + if (png_ptr->buffer_size < png_ptr->current_text_left) + text_size = png_ptr->buffer_size; + else + text_size = png_ptr->current_text_left; + png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); + png_ptr->current_text_left -= text_size; + png_ptr->current_text_ptr += text_size; + } + if (!(png_ptr->current_text_left)) + { + png_textp text_ptr; + png_charp text; + png_charp key; + int ret; + + if (png_ptr->buffer_size < 4) + { + png_push_save_buffer(png_ptr); + return; + } + + png_push_crc_finish(png_ptr); + +#if defined(PNG_MAX_MALLOC_64K) + if (png_ptr->skip_length) + return; +#endif + + key = png_ptr->current_text; + + for (text = key; *text; text++) + /* empty loop */ ; + + if (text != key + png_ptr->current_text_size) + text++; + + text_ptr = (png_textp)png_malloc(png_ptr, + (png_uint_32)png_sizeof(png_text)); + text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr->key = key; +#ifdef PNG_iTXt_SUPPORTED + text_ptr->lang = NULL; + text_ptr->lang_key = NULL; +#endif + text_ptr->text = text; + + ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_free(png_ptr, key); + png_free(png_ptr, text_ptr); + png_ptr->current_text = NULL; + + if (ret) + png_warning(png_ptr, "Insufficient memory to store text chunk."); + } +} +#endif + +#if defined(PNG_READ_zTXt_SUPPORTED) +void /* PRIVATE */ +png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 + length) +{ + if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) + { + png_error(png_ptr, "Out of place zTXt"); + /* to quiet some compiler warnings */ + if(info_ptr == NULL) return; + } + +#ifdef PNG_MAX_MALLOC_64K + /* We can't handle zTXt chunks > 64K, since we don't have enough space + * to be able to store the uncompressed data. Actually, the threshold + * is probably around 32K, but it isn't as definite as 64K is. + */ + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr, "zTXt chunk too large to fit in memory"); + png_push_crc_skip(png_ptr, length); + return; + } +#endif + + png_ptr->current_text = (png_charp)png_malloc(png_ptr, + (png_uint_32)(length+1)); + png_ptr->current_text[length] = '\0'; + png_ptr->current_text_ptr = png_ptr->current_text; + png_ptr->current_text_size = (png_size_t)length; + png_ptr->current_text_left = (png_size_t)length; + png_ptr->process_mode = PNG_READ_zTXt_MODE; +} + +void /* PRIVATE */ +png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr->buffer_size && png_ptr->current_text_left) + { + png_size_t text_size; + + if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left) + text_size = png_ptr->buffer_size; + else + text_size = png_ptr->current_text_left; + png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); + png_ptr->current_text_left -= text_size; + png_ptr->current_text_ptr += text_size; + } + if (!(png_ptr->current_text_left)) + { + png_textp text_ptr; + png_charp text; + png_charp key; + int ret; + png_size_t text_size, key_size; + + if (png_ptr->buffer_size < 4) + { + png_push_save_buffer(png_ptr); + return; + } + + png_push_crc_finish(png_ptr); + + key = png_ptr->current_text; + + for (text = key; *text; text++) + /* empty loop */ ; + + /* zTXt can't have zero text */ + if (text == key + png_ptr->current_text_size) + { + png_ptr->current_text = NULL; + png_free(png_ptr, key); + return; + } + + text++; + + if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */ + { + png_ptr->current_text = NULL; + png_free(png_ptr, key); + return; + } + + text++; + + png_ptr->zstream.next_in = (png_bytep )text; + png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size - + (text - key)); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + + key_size = text - key; + text_size = 0; + text = NULL; + ret = Z_STREAM_END; + + while (png_ptr->zstream.avail_in) + { + ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); + if (ret != Z_OK && ret != Z_STREAM_END) + { + inflateReset(&png_ptr->zstream); + png_ptr->zstream.avail_in = 0; + png_ptr->current_text = NULL; + png_free(png_ptr, key); + png_free(png_ptr, text); + return; + } + if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END) + { + if (text == NULL) + { + text = (png_charp)png_malloc(png_ptr, + (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out + + key_size + 1)); + png_memcpy(text + key_size, png_ptr->zbuf, + png_ptr->zbuf_size - png_ptr->zstream.avail_out); + png_memcpy(text, key, key_size); + text_size = key_size + png_ptr->zbuf_size - + png_ptr->zstream.avail_out; + *(text + text_size) = '\0'; + } + else + { + png_charp tmp; + + tmp = text; + text = (png_charp)png_malloc(png_ptr, text_size + + (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out + + 1)); + png_memcpy(text, tmp, text_size); + png_free(png_ptr, tmp); + png_memcpy(text + text_size, png_ptr->zbuf, + png_ptr->zbuf_size - png_ptr->zstream.avail_out); + text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; + *(text + text_size) = '\0'; + } + if (ret != Z_STREAM_END) + { + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + } + } + else + { + break; + } + + if (ret == Z_STREAM_END) + break; + } + + inflateReset(&png_ptr->zstream); + png_ptr->zstream.avail_in = 0; + + if (ret != Z_STREAM_END) + { + png_ptr->current_text = NULL; + png_free(png_ptr, key); + png_free(png_ptr, text); + return; + } + + png_ptr->current_text = NULL; + png_free(png_ptr, key); + key = text; + text += key_size; + + text_ptr = (png_textp)png_malloc(png_ptr, + (png_uint_32)png_sizeof(png_text)); + text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt; + text_ptr->key = key; +#ifdef PNG_iTXt_SUPPORTED + text_ptr->lang = NULL; + text_ptr->lang_key = NULL; +#endif + text_ptr->text = text; + + ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_free(png_ptr, key); + png_free(png_ptr, text_ptr); + + if (ret) + png_warning(png_ptr, "Insufficient memory to store text chunk."); + } +} +#endif + +#if defined(PNG_READ_iTXt_SUPPORTED) +void /* PRIVATE */ +png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 + length) +{ + if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) + { + png_error(png_ptr, "Out of place iTXt"); + /* to quiet some compiler warnings */ + if(info_ptr == NULL) return; + } + +#ifdef PNG_MAX_MALLOC_64K + png_ptr->skip_length = 0; /* This may not be necessary */ + + if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ + { + png_warning(png_ptr, "iTXt chunk too large to fit in memory"); + png_ptr->skip_length = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + + png_ptr->current_text = (png_charp)png_malloc(png_ptr, + (png_uint_32)(length+1)); + png_ptr->current_text[length] = '\0'; + png_ptr->current_text_ptr = png_ptr->current_text; + png_ptr->current_text_size = (png_size_t)length; + png_ptr->current_text_left = (png_size_t)length; + png_ptr->process_mode = PNG_READ_iTXt_MODE; +} + +void /* PRIVATE */ +png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) +{ + + if (png_ptr->buffer_size && png_ptr->current_text_left) + { + png_size_t text_size; + + if (png_ptr->buffer_size < png_ptr->current_text_left) + text_size = png_ptr->buffer_size; + else + text_size = png_ptr->current_text_left; + png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); + png_ptr->current_text_left -= text_size; + png_ptr->current_text_ptr += text_size; + } + if (!(png_ptr->current_text_left)) + { + png_textp text_ptr; + png_charp key; + int comp_flag; + png_charp lang; + png_charp lang_key; + png_charp text; + int ret; + + if (png_ptr->buffer_size < 4) + { + png_push_save_buffer(png_ptr); + return; + } + + png_push_crc_finish(png_ptr); + +#if defined(PNG_MAX_MALLOC_64K) + if (png_ptr->skip_length) + return; +#endif + + key = png_ptr->current_text; + + for (lang = key; *lang; lang++) + /* empty loop */ ; + + if (lang != key + png_ptr->current_text_size) + lang++; + + comp_flag = *lang++; + lang++; /* skip comp_type, always zero */ + + for (lang_key = lang; *lang_key; lang_key++) + /* empty loop */ ; + lang_key++; /* skip NUL separator */ + + for (text = lang_key; *text; text++) + /* empty loop */ ; + + if (text != key + png_ptr->current_text_size) + text++; + + text_ptr = (png_textp)png_malloc(png_ptr, + (png_uint_32)png_sizeof(png_text)); + text_ptr->compression = comp_flag + 2; + text_ptr->key = key; + text_ptr->lang = lang; + text_ptr->lang_key = lang_key; + text_ptr->text = text; + text_ptr->text_length = 0; + text_ptr->itxt_length = png_strlen(text); + + ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_ptr->current_text = NULL; + + png_free(png_ptr, text_ptr); + if (ret) + png_warning(png_ptr, "Insufficient memory to store iTXt chunk."); + } +} +#endif + +/* This function is called when we haven't found a handler for this + * chunk. If there isn't a problem with the chunk itself (ie a bad chunk + * name or a critical chunk), the chunk is (currently) silently ignored. + */ +void /* PRIVATE */ +png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 + length) +{ + png_uint_32 skip=0; + png_check_chunk_name(png_ptr, png_ptr->chunk_name); + + if (!(png_ptr->chunk_name[0] & 0x20)) + { +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != + PNG_HANDLE_CHUNK_ALWAYS +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) + && png_ptr->read_user_chunk_fn == NULL +#endif + ) +#endif + png_chunk_error(png_ptr, "unknown critical chunk"); + + /* to quiet compiler warnings about unused info_ptr */ + if (info_ptr == NULL) + return; + } + +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) + { + png_unknown_chunk chunk; + +#ifdef PNG_MAX_MALLOC_64K + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr, "unknown chunk too large to fit in memory"); + skip = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + + png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); + chunk.data = (png_bytep)png_malloc(png_ptr, length); + png_crc_read(png_ptr, chunk.data, length); + chunk.size = length; +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) + if(png_ptr->read_user_chunk_fn != NULL) + { + /* callback to user unknown chunk handler */ + if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) + { + if (!(png_ptr->chunk_name[0] & 0x20)) + if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != + PNG_HANDLE_CHUNK_ALWAYS) + png_chunk_error(png_ptr, "unknown critical chunk"); + } + png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); + } + else +#endif + png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); + png_free(png_ptr, chunk.data); + } + else +#endif + skip=length; + png_push_crc_skip(png_ptr, skip); +} + +void /* PRIVATE */ +png_push_have_info(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr->info_fn != NULL) + (*(png_ptr->info_fn))(png_ptr, info_ptr); +} + +void /* PRIVATE */ +png_push_have_end(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr->end_fn != NULL) + (*(png_ptr->end_fn))(png_ptr, info_ptr); +} + +void /* PRIVATE */ +png_push_have_row(png_structp png_ptr, png_bytep row) +{ + if (png_ptr->row_fn != NULL) + (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number, + (int)png_ptr->pass); +} + +void PNGAPI +png_progressive_combine_row (png_structp png_ptr, + png_bytep old_row, png_bytep new_row) +{ + if(png_ptr == NULL) return; +#ifdef PNG_USE_LOCAL_ARRAYS + const int FARDATA png_pass_dsp_mask[7] = + {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; +#endif + if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ + png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); +} + +void PNGAPI +png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, + png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, + png_progressive_end_ptr end_fn) +{ + if(png_ptr == NULL) return; + png_ptr->info_fn = info_fn; + png_ptr->row_fn = row_fn; + png_ptr->end_fn = end_fn; + + png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer); +} + +png_voidp PNGAPI +png_get_progressive_ptr(png_structp png_ptr) +{ + if(png_ptr == NULL) return (NULL); + return png_ptr->io_ptr; +} +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/pngread.c b/src/dep/src/irrlicht/libpng/pngread.c index 0d0a7c9..56dac8a 100644 --- a/src/dep/src/irrlicht/libpng/pngread.c +++ b/src/dep/src/irrlicht/libpng/pngread.c @@ -1,1473 +1,1473 @@ - -/* pngread.c - read a PNG file - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains routines that an application calls directly to - * read a PNG file or stream. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) - -/* Create a PNG structure for reading, and allocate any memory needed. */ -png_structp PNGAPI -png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn) -{ - -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); -} - -/* Alternate create PNG structure for reading, and allocate any memory needed. */ -png_structp PNGAPI -png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - - png_structp png_ptr; - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - - int i; - - png_debug(1, "in png_create_read_struct\n"); -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); -#else - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); -#endif - if (png_ptr == NULL) - return (NULL); - -#if !defined(PNG_1_0_X) -#ifdef PNG_MMX_CODE_SUPPORTED - png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ -#endif -#endif /* PNG_1_0_X */ - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_ptr->jmpbuf)) -#endif - { - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, - (png_free_ptr)free_fn, (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - return (NULL); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#endif -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); -#endif - - png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - - i=0; - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - } while (png_libpng_ver[i++]); - - if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) - { - /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so - * we must recompile any applications that use any older library version. - * For versions after libpng 1.0, we will be compatible, so we need - * only check the first digit. - */ - if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || - (user_png_ver[0] == '0' && user_png_ver[2] < '9')) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[80]; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); -#endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "Incompatible libpng version in application and library"); - } - } - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - - switch (inflateInit(&png_ptr->zstream)) - { - case Z_OK: /* Do nothing */ break; - case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; - default: png_error(png_ptr, "Unknown zlib error"); - } - - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); - -#ifdef PNG_SETJMP_SUPPORTED -/* Applications that neglect to set up their own setjmp() and then encounter - a png_error() will longjmp here. Since the jmpbuf is then meaningless we - abort instead of returning. */ -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) - PNG_ABORT(); - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#else - if (setjmp(png_ptr->jmpbuf)) - PNG_ABORT(); -#endif -#endif - return (png_ptr); -} - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Initialize PNG structure for reading, and allocate any memory needed. - This interface is deprecated in favour of the png_create_read_struct(), - and it will disappear as of libpng-1.3.0. */ -#undef png_read_init -void PNGAPI -png_read_init(png_structp png_ptr) -{ - /* We only come here via pre-1.0.7-compiled applications */ - png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0); -} - -void PNGAPI -png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size, png_size_t png_info_size) -{ - /* We only come here via pre-1.0.12-compiled applications */ - if(png_ptr == NULL) return; -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if(png_sizeof(png_struct) > png_struct_size || - png_sizeof(png_info) > png_info_size) - { - char msg[80]; - png_ptr->warning_fn=NULL; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); - } -#endif - if(png_sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The png struct allocated by the application for reading is too small."); - } - if(png_sizeof(png_info) > png_info_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The info struct allocated by application for reading is too small."); - } - png_read_init_3(&png_ptr, user_png_ver, png_struct_size); -} -#endif /* PNG_1_0_X || PNG_1_2_X */ - -void PNGAPI -png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ -#endif - - int i=0; - - png_structp png_ptr=*ptr_ptr; - - if(png_ptr == NULL) return; - - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - { -#ifdef PNG_LEGACY_SUPPORTED - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; -#else - png_ptr->warning_fn=NULL; - png_warning(png_ptr, - "Application uses deprecated png_read_init() and should be recompiled."); - break; -#endif - } - } while (png_libpng_ver[i++]); - - png_debug(1, "in png_read_init_3\n"); - -#ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); -#endif - - if(png_sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - png_ptr = *ptr_ptr; - } - - /* reset all variables to 0 */ - png_memset(png_ptr, 0, png_sizeof (png_struct)); - -#ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - - switch (inflateInit(&png_ptr->zstream)) - { - case Z_OK: /* Do nothing */ break; - case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break; - default: png_error(png_ptr, "Unknown zlib error"); - } - - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); -} - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Read the information before the actual image data. This has been - * changed in v0.90 to allow reading a file that already has the magic - * bytes read from the stream. You can tell libpng how many bytes have - * been read from the beginning of the stream (up to the maximum of 8) - * via png_set_sig_bytes(), and we will only check the remaining bytes - * here. The application can then have access to the signature bytes we - * read if it is determined that this isn't a valid PNG file. - */ -void PNGAPI -png_read_info(png_structp png_ptr, png_infop info_ptr) -{ - if(png_ptr == NULL) return; - png_debug(1, "in png_read_info\n"); - /* If we haven't checked all of the PNG signature bytes, do so now. */ - if (png_ptr->sig_bytes < 8) - { - png_size_t num_checked = png_ptr->sig_bytes, - num_to_check = 8 - num_checked; - - png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); - png_ptr->sig_bytes = 8; - - if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) - { - if (num_checked < 4 && - png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) - png_error(png_ptr, "Not a PNG file"); - else - png_error(png_ptr, "PNG file corrupted by ASCII conversion"); - } - if (num_checked < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; - } - - for(;;) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_USE_LOCAL_ARRAYS */ - png_byte chunk_length[4]; - png_uint_32 length; - - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name, - length); - - /* This should be a binary subdivision search or a hash for - * matching the chunk name rather than a linear search. - */ - if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - if(png_ptr->mode & PNG_AFTER_IDAT) - png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - png_handle_IEND(png_ptr, info_ptr, length); -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) - { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_ptr->mode |= PNG_HAVE_IDAT; - png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_ptr->mode |= PNG_HAVE_PLTE; - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - break; - } - } -#endif - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_handle_PLTE(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - - png_ptr->idat_size = length; - png_ptr->mode |= PNG_HAVE_IDAT; - break; - } -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - png_handle_bKGD(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - png_handle_cHRM(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - png_handle_gAMA(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - png_handle_hIST(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - png_handle_oFFs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - png_handle_pCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - png_handle_sCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - png_handle_pHYs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - png_handle_sBIT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - png_handle_sRGB(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - png_handle_iCCP(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - png_handle_sPLT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - png_handle_tEXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - png_handle_tIME(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - png_handle_tRNS(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - png_handle_zTXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - png_handle_iTXt(png_ptr, info_ptr, length); -#endif - else - png_handle_unknown(png_ptr, info_ptr, length); - } -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -/* optional call to update the users info_ptr structure */ -void PNGAPI -png_read_update_info(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_read_update_info\n"); - if(png_ptr == NULL) return; - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); - else - png_warning(png_ptr, - "Ignoring extra png_read_update_info() call; row buffer not reallocated"); - png_read_transform_info(png_ptr, info_ptr); -} - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Initialize palette, background, etc, after transformations - * are set, but before any reading takes place. This allows - * the user to obtain a gamma-corrected palette, for example. - * If the user doesn't call this, we will do it ourselves. - */ -void PNGAPI -png_start_read_image(png_structp png_ptr) -{ - png_debug(1, "in png_start_read_image\n"); - if(png_ptr == NULL) return; - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -void PNGAPI -png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; - const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; - const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; -#endif - int ret; - if(png_ptr == NULL) return; - png_debug2(1, "in png_read_row (row %lu, pass %d)\n", - png_ptr->row_number, png_ptr->pass); - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); - if (png_ptr->row_number == 0 && png_ptr->pass == 0) - { - /* check for transforms that have been set but were defined out */ -#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && !defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined."); -#endif - } - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* if interlaced and we do not need a new row, combine row and return */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - switch (png_ptr->pass) - { - case 0: - if (png_ptr->row_number & 0x07) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 1: - if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 2: - if ((png_ptr->row_number & 0x07) != 4) - { - if (dsp_row != NULL && (png_ptr->row_number & 4)) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 3: - if ((png_ptr->row_number & 3) || png_ptr->width < 3) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 4: - if ((png_ptr->row_number & 3) != 2) - { - if (dsp_row != NULL && (png_ptr->row_number & 2)) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 5: - if ((png_ptr->row_number & 1) || png_ptr->width < 2) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 6: - if (!(png_ptr->row_number & 1)) - { - png_read_finish_row(png_ptr); - return; - } - break; - } - } -#endif - - if (!(png_ptr->mode & PNG_HAVE_IDAT)) - png_error(png_ptr, "Invalid attempt to read row data"); - - png_ptr->zstream.next_out = png_ptr->row_buf; - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - do - { - if (!(png_ptr->zstream.avail_in)) - { - while (!png_ptr->idat_size) - { - png_byte chunk_length[4]; - - png_crc_finish(png_ptr, 0); - - png_read_data(png_ptr, chunk_length, 4); - png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_error(png_ptr, "Not enough image data"); - } - png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_in = png_ptr->zbuf; - if (png_ptr->zbuf_size > png_ptr->idat_size) - png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; - png_crc_read(png_ptr, png_ptr->zbuf, - (png_size_t)png_ptr->zstream.avail_in); - png_ptr->idat_size -= png_ptr->zstream.avail_in; - } - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret == Z_STREAM_END) - { - if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in || - png_ptr->idat_size) - png_error(png_ptr, "Extra compressed data"); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - if (ret != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : - "Decompression error"); - - } while (png_ptr->zstream.avail_out); - - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->iwidth; - png_ptr->row_info.channels = png_ptr->channels; - png_ptr->row_info.bit_depth = png_ptr->bit_depth; - png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); - - if(png_ptr->row_buf[0]) - png_read_filter_row(png_ptr, &(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->prev_row + 1, - (int)(png_ptr->row_buf[0])); - - png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, - png_ptr->rowbytes + 1); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) - { - /* Intrapixel differencing */ - png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); - } -#endif - - - if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) - png_do_read_transformations(png_ptr); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* blow up interlaced rows to full size */ - if (png_ptr->interlaced && - (png_ptr->transformations & PNG_INTERLACE)) - { - if (png_ptr->pass < 6) -/* old interface (pre-1.0.9): - png_do_read_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); - */ - png_do_read_interlace(png_ptr); - - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - if (row != NULL) - png_combine_row(png_ptr, row, - png_pass_mask[png_ptr->pass]); - } - else -#endif - { - if (row != NULL) - png_combine_row(png_ptr, row, 0xff); - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 0xff); - } - png_read_finish_row(png_ptr); - - if (png_ptr->read_row_fn != NULL) - (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Read one or more rows of image data. If the image is interlaced, - * and png_set_interlace_handling() has been called, the rows need to - * contain the contents of the rows from the previous pass. If the - * image has alpha or transparency, and png_handle_alpha()[*] has been - * called, the rows contents must be initialized to the contents of the - * screen. - * - * "row" holds the actual image, and pixels are placed in it - * as they arrive. If the image is displayed after each pass, it will - * appear to "sparkle" in. "display_row" can be used to display a - * "chunky" progressive image, with finer detail added as it becomes - * available. If you do not want this "chunky" display, you may pass - * NULL for display_row. If you do not want the sparkle display, and - * you have not called png_handle_alpha(), you may pass NULL for rows. - * If you have called png_handle_alpha(), and the image has either an - * alpha channel or a transparency chunk, you must provide a buffer for - * rows. In this case, you do not have to provide a display_row buffer - * also, but you may. If the image is not interlaced, or if you have - * not called png_set_interlace_handling(), the display_row buffer will - * be ignored, so pass NULL to it. - * - * [*] png_handle_alpha() does not exist yet, as of this version of libpng - */ - -void PNGAPI -png_read_rows(png_structp png_ptr, png_bytepp row, - png_bytepp display_row, png_uint_32 num_rows) -{ - png_uint_32 i; - png_bytepp rp; - png_bytepp dp; - - png_debug(1, "in png_read_rows\n"); - if(png_ptr == NULL) return; - rp = row; - dp = display_row; - if (rp != NULL && dp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep rptr = *rp++; - png_bytep dptr = *dp++; - - png_read_row(png_ptr, rptr, dptr); - } - else if(rp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep rptr = *rp; - png_read_row(png_ptr, rptr, png_bytep_NULL); - rp++; - } - else if(dp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep dptr = *dp; - png_read_row(png_ptr, png_bytep_NULL, dptr); - dp++; - } -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Read the entire image. If the image has an alpha channel or a tRNS - * chunk, and you have called png_handle_alpha()[*], you will need to - * initialize the image to the current image that PNG will be overlaying. - * We set the num_rows again here, in case it was incorrectly set in - * png_read_start_row() by a call to png_read_update_info() or - * png_start_read_image() if png_set_interlace_handling() wasn't called - * prior to either of these functions like it should have been. You can - * only call this function once. If you desire to have an image for - * each pass of a interlaced image, use png_read_rows() instead. - * - * [*] png_handle_alpha() does not exist yet, as of this version of libpng - */ -void PNGAPI -png_read_image(png_structp png_ptr, png_bytepp image) -{ - png_uint_32 i,image_height; - int pass, j; - png_bytepp rp; - - png_debug(1, "in png_read_image\n"); - if(png_ptr == NULL) return; - -#ifdef PNG_READ_INTERLACING_SUPPORTED - pass = png_set_interlace_handling(png_ptr); -#else - if (png_ptr->interlaced) - png_error(png_ptr, - "Cannot read interlaced image -- interlace handler disabled."); - pass = 1; -#endif - - - image_height=png_ptr->height; - png_ptr->num_rows = image_height; /* Make sure this is set correctly */ - - for (j = 0; j < pass; j++) - { - rp = image; - for (i = 0; i < image_height; i++) - { - png_read_row(png_ptr, *rp, png_bytep_NULL); - rp++; - } - } -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Read the end of the PNG file. Will not read past the end of the - * file, will verify the end is accurate, and will read any comments - * or time information at the end of the file, if info is not NULL. - */ -void PNGAPI -png_read_end(png_structp png_ptr, png_infop info_ptr) -{ - png_byte chunk_length[4]; - png_uint_32 length; - - png_debug(1, "in png_read_end\n"); - if(png_ptr == NULL) return; - png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ - - do - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_USE_LOCAL_ARRAYS */ - - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name); - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - png_handle_IEND(png_ptr, info_ptr, length); -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) - { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - png_error(png_ptr, "Too many IDAT's found"); - } - png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_ptr->mode |= PNG_HAVE_PLTE; - } -#endif - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - /* Zero length IDATs are legal after the last IDAT has been - * read, but not after other chunks have been read. - */ - if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - png_error(png_ptr, "Too many IDAT's found"); - png_crc_finish(png_ptr, length); - } - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_handle_PLTE(png_ptr, info_ptr, length); -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - png_handle_bKGD(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - png_handle_cHRM(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - png_handle_gAMA(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - png_handle_hIST(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - png_handle_oFFs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - png_handle_pCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - png_handle_sCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - png_handle_pHYs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - png_handle_sBIT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - png_handle_sRGB(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - png_handle_iCCP(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - png_handle_sPLT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - png_handle_tEXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - png_handle_tIME(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - png_handle_tRNS(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - png_handle_zTXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - png_handle_iTXt(png_ptr, info_ptr, length); -#endif - else - png_handle_unknown(png_ptr, info_ptr, length); - } while (!(png_ptr->mode & PNG_HAVE_IEND)); -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -/* free all memory used by the read */ -void PNGAPI -png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, - png_infopp end_info_ptr_ptr) -{ - png_structp png_ptr = NULL; - png_infop info_ptr = NULL, end_info_ptr = NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; - png_voidp mem_ptr; -#endif - - png_debug(1, "in png_destroy_read_struct\n"); - if (png_ptr_ptr != NULL) - png_ptr = *png_ptr_ptr; - - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (end_info_ptr_ptr != NULL) - end_info_ptr = *end_info_ptr_ptr; - -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; - mem_ptr = png_ptr->mem_ptr; -#endif - - png_read_destroy(png_ptr, info_ptr, end_info_ptr); - - if (info_ptr != NULL) - { -#if defined(PNG_TEXT_SUPPORTED) - png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1); -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = NULL; - } - - if (end_info_ptr != NULL) - { -#if defined(PNG_READ_TEXT_SUPPORTED) - png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); -#endif -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)end_info_ptr); -#endif - *end_info_ptr_ptr = NULL; - } - - if (png_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - *png_ptr_ptr = NULL; - } -} - -/* free all memory used by the read (old method) */ -void /* PRIVATE */ -png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; -#endif - png_error_ptr error_fn; - png_error_ptr warning_fn; - png_voidp error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; -#endif - - png_debug(1, "in png_read_destroy\n"); - if (info_ptr != NULL) - png_info_destroy(png_ptr, info_ptr); - - if (end_info_ptr != NULL) - png_info_destroy(png_ptr, end_info_ptr); - - png_free(png_ptr, png_ptr->zbuf); - png_free(png_ptr, png_ptr->big_row_buf); - png_free(png_ptr, png_ptr->prev_row); -#if defined(PNG_READ_DITHER_SUPPORTED) - png_free(png_ptr, png_ptr->palette_lookup); - png_free(png_ptr, png_ptr->dither_index); -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - png_free(png_ptr, png_ptr->gamma_table); -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - png_free(png_ptr, png_ptr->gamma_from_1); - png_free(png_ptr, png_ptr->gamma_to_1); -#endif -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_PLTE) - png_zfree(png_ptr, png_ptr->palette); - png_ptr->free_me &= ~PNG_FREE_PLTE; -#else - if (png_ptr->flags & PNG_FLAG_FREE_PLTE) - png_zfree(png_ptr, png_ptr->palette); - png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; -#endif -#if defined(PNG_tRNS_SUPPORTED) || \ - defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_TRNS) - png_free(png_ptr, png_ptr->trans); - png_ptr->free_me &= ~PNG_FREE_TRNS; -#else - if (png_ptr->flags & PNG_FLAG_FREE_TRNS) - png_free(png_ptr, png_ptr->trans); - png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; -#endif -#endif -#if defined(PNG_READ_hIST_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_HIST) - png_free(png_ptr, png_ptr->hist); - png_ptr->free_me &= ~PNG_FREE_HIST; -#else - if (png_ptr->flags & PNG_FLAG_FREE_HIST) - png_free(png_ptr, png_ptr->hist); - png_ptr->flags &= ~PNG_FLAG_FREE_HIST; -#endif -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->gamma_16_table != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_table[i]); - } - png_free(png_ptr, png_ptr->gamma_16_table); - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_from_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_from_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_from_1); - } - if (png_ptr->gamma_16_to_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_to_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_to_1); - } -#endif -#endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_free(png_ptr, png_ptr->time_buffer); -#endif - - inflateEnd(&png_ptr->zstream); -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_free(png_ptr, png_ptr->save_buffer); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -#ifdef PNG_TEXT_SUPPORTED - png_free(png_ptr, png_ptr->current_text); -#endif /* PNG_TEXT_SUPPORTED */ -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - - /* Save the important info out of the png_struct, in case it is - * being used again. - */ -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); -#endif - - error_fn = png_ptr->error_fn; - warning_fn = png_ptr->warning_fn; - error_ptr = png_ptr->error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; -#endif - - png_memset(png_ptr, 0, png_sizeof (png_struct)); - - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; - png_ptr->error_ptr = error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr->free_fn = free_fn; -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif - -} - -void PNGAPI -png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) -{ - if(png_ptr == NULL) return; - png_ptr->read_row_fn = read_row_fn; -} - - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_read_png(png_structp png_ptr, png_infop info_ptr, - int transforms, - voidp params) -{ - int row; - - if(png_ptr == NULL) return; -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency - */ - if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); -#endif - - /* png_read_info() gives us all of the information from the - * PNG file before the first IDAT (image data chunk). - */ - png_read_info(png_ptr, info_ptr); - if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) - png_error(png_ptr,"Image is too high to process with png_read_png()"); - - /* -------------- image transformations start here ------------------- */ - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - /* tell libpng to strip 16 bit/color files down to 8 bits per color - */ - if (transforms & PNG_TRANSFORM_STRIP_16) - png_set_strip_16(png_ptr); -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - /* Strip alpha bytes from the input data without combining with - * the background (not recommended). - */ - if (transforms & PNG_TRANSFORM_STRIP_ALPHA) - png_set_strip_alpha(png_ptr); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED) - /* Extract multiple pixels with bit depths of 1, 2, or 4 from a single - * byte into separate bytes (useful for paletted and grayscale images). - */ - if (transforms & PNG_TRANSFORM_PACKING) - png_set_packing(png_ptr); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - /* Change the order of packed pixels to least significant bit first - * (not useful if you are using png_set_packing). - */ - if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - /* Expand paletted colors into true RGB triplets - * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel - * Expand paletted or RGB images with transparency to full alpha - * channels so the data will be available as RGBA quartets. - */ - if (transforms & PNG_TRANSFORM_EXPAND) - if ((png_ptr->bit_depth < 8) || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || - (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) - png_set_expand(png_ptr); -#endif - - /* We don't handle background color or gamma transformation or dithering. - */ - -#if defined(PNG_READ_INVERT_SUPPORTED) - /* invert monochrome files to have 0 as white and 1 as black - */ - if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) - /* If you want to shift the pixel values from the range [0,255] or - * [0,65535] to the original [0,7] or [0,31], or whatever range the - * colors were originally in: - */ - if ((transforms & PNG_TRANSFORM_SHIFT) - && png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) - { - png_color_8p sig_bit; - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - png_set_shift(png_ptr, sig_bit); - } -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) - /* flip the RGB pixels to BGR (or RGBA to BGRA) - */ - if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) - */ - if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) - /* swap bytes of 16 bit files to least significant byte first - */ - if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); -#endif - - /* We don't handle adding filler bytes */ - - /* Optional call to gamma correct and add the background to the palette - * and update info structure. REQUIRED if you are expecting libpng to - * update the palette for you (i.e., you selected such a transform above). - */ - png_read_update_info(png_ptr, info_ptr); - - /* -------------- image transformations end here ------------------- */ - -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); -#endif - if(info_ptr->row_pointers == NULL) - { - info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, - info_ptr->height * png_sizeof(png_bytep)); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_ROWS; -#endif - for (row = 0; row < (int)info_ptr->height; row++) - { - info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, - png_get_rowbytes(png_ptr, info_ptr)); - } - } - - png_read_image(png_ptr, info_ptr->row_pointers); - info_ptr->valid |= PNG_INFO_IDAT; - - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ - png_read_end(png_ptr, info_ptr); - - if(transforms == 0 || params == NULL) - /* quiet compiler warnings */ return; - -} -#endif /* PNG_INFO_IMAGE_SUPPORTED */ -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED */ + +/* pngread.c - read a PNG file + * + * Last changed in libpng 1.2.15 January 5, 2007 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This file contains routines that an application calls directly to + * read a PNG file or stream. + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_READ_SUPPORTED) + +/* Create a PNG structure for reading, and allocate any memory needed. */ +png_structp PNGAPI +png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn) +{ + +#ifdef PNG_USER_MEM_SUPPORTED + return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn, + warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); +} + +/* Alternate create PNG structure for reading, and allocate any memory needed. */ +png_structp PNGAPI +png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + + png_structp png_ptr; + +#ifdef PNG_SETJMP_SUPPORTED +#ifdef USE_FAR_KEYWORD + jmp_buf jmpbuf; +#endif +#endif + + int i; + + png_debug(1, "in png_create_read_struct\n"); +#ifdef PNG_USER_MEM_SUPPORTED + png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, + (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); +#else + png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); +#endif + if (png_ptr == NULL) + return (NULL); + +#if !defined(PNG_1_0_X) +#ifdef PNG_MMX_CODE_SUPPORTED + png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ +#endif +#endif /* PNG_1_0_X */ + + /* added at libpng-1.2.6 */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + png_ptr->user_width_max=PNG_USER_WIDTH_MAX; + png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; +#endif + +#ifdef PNG_SETJMP_SUPPORTED +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) +#else + if (setjmp(png_ptr->jmpbuf)) +#endif + { + png_free(png_ptr, png_ptr->zbuf); + png_ptr->zbuf=NULL; +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)png_ptr, + (png_free_ptr)free_fn, (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)png_ptr); +#endif + return (NULL); + } +#ifdef USE_FAR_KEYWORD + png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); +#endif +#endif + +#ifdef PNG_USER_MEM_SUPPORTED + png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); +#endif + + png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); + + i=0; + do + { + if(user_png_ver[i] != png_libpng_ver[i]) + png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; + } while (png_libpng_ver[i++]); + + if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) + { + /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so + * we must recompile any applications that use any older library version. + * For versions after libpng 1.0, we will be compatible, so we need + * only check the first digit. + */ + if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || + (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || + (user_png_ver[0] == '0' && user_png_ver[2] < '9')) + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char msg[80]; + if (user_png_ver) + { + sprintf(msg, "Application was compiled with png.h from libpng-%.20s", + user_png_ver); + png_warning(png_ptr, msg); + } + sprintf(msg, "Application is running with png.c from libpng-%.20s", + png_libpng_ver); + png_warning(png_ptr, msg); +#endif +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "Incompatible libpng version in application and library"); + } + } + + /* initialize zbuf - compression buffer */ + png_ptr->zbuf_size = PNG_ZBUF_SIZE; + png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, + (png_uint_32)png_ptr->zbuf_size); + png_ptr->zstream.zalloc = png_zalloc; + png_ptr->zstream.zfree = png_zfree; + png_ptr->zstream.opaque = (voidpf)png_ptr; + + switch (inflateInit(&png_ptr->zstream)) + { + case Z_OK: /* Do nothing */ break; + case Z_MEM_ERROR: + case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; + case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; + default: png_error(png_ptr, "Unknown zlib error"); + } + + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + + png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); + +#ifdef PNG_SETJMP_SUPPORTED +/* Applications that neglect to set up their own setjmp() and then encounter + a png_error() will longjmp here. Since the jmpbuf is then meaningless we + abort instead of returning. */ +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) + PNG_ABORT(); + png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); +#else + if (setjmp(png_ptr->jmpbuf)) + PNG_ABORT(); +#endif +#endif + return (png_ptr); +} + +#if defined(PNG_1_0_X) || defined(PNG_1_2_X) +/* Initialize PNG structure for reading, and allocate any memory needed. + This interface is deprecated in favour of the png_create_read_struct(), + and it will disappear as of libpng-1.3.0. */ +#undef png_read_init +void PNGAPI +png_read_init(png_structp png_ptr) +{ + /* We only come here via pre-1.0.7-compiled applications */ + png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0); +} + +void PNGAPI +png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, + png_size_t png_struct_size, png_size_t png_info_size) +{ + /* We only come here via pre-1.0.12-compiled applications */ + if(png_ptr == NULL) return; +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + if(png_sizeof(png_struct) > png_struct_size || + png_sizeof(png_info) > png_info_size) + { + char msg[80]; + png_ptr->warning_fn=NULL; + if (user_png_ver) + { + sprintf(msg, "Application was compiled with png.h from libpng-%.20s", + user_png_ver); + png_warning(png_ptr, msg); + } + sprintf(msg, "Application is running with png.c from libpng-%.20s", + png_libpng_ver); + png_warning(png_ptr, msg); + } +#endif + if(png_sizeof(png_struct) > png_struct_size) + { + png_ptr->error_fn=NULL; +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "The png struct allocated by the application for reading is too small."); + } + if(png_sizeof(png_info) > png_info_size) + { + png_ptr->error_fn=NULL; +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "The info struct allocated by application for reading is too small."); + } + png_read_init_3(&png_ptr, user_png_ver, png_struct_size); +} +#endif /* PNG_1_0_X || PNG_1_2_X */ + +void PNGAPI +png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, + png_size_t png_struct_size) +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf tmp_jmp; /* to save current jump buffer */ +#endif + + int i=0; + + png_structp png_ptr=*ptr_ptr; + + if(png_ptr == NULL) return; + + do + { + if(user_png_ver[i] != png_libpng_ver[i]) + { +#ifdef PNG_LEGACY_SUPPORTED + png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; +#else + png_ptr->warning_fn=NULL; + png_warning(png_ptr, + "Application uses deprecated png_read_init() and should be recompiled."); + break; +#endif + } + } while (png_libpng_ver[i++]); + + png_debug(1, "in png_read_init_3\n"); + +#ifdef PNG_SETJMP_SUPPORTED + /* save jump buffer and error functions */ + png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); +#endif + + if(png_sizeof(png_struct) > png_struct_size) + { + png_destroy_struct(png_ptr); + *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); + png_ptr = *ptr_ptr; + } + + /* reset all variables to 0 */ + png_memset(png_ptr, 0, png_sizeof (png_struct)); + +#ifdef PNG_SETJMP_SUPPORTED + /* restore jump buffer */ + png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); +#endif + + /* added at libpng-1.2.6 */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + png_ptr->user_width_max=PNG_USER_WIDTH_MAX; + png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; +#endif + + /* initialize zbuf - compression buffer */ + png_ptr->zbuf_size = PNG_ZBUF_SIZE; + png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, + (png_uint_32)png_ptr->zbuf_size); + png_ptr->zstream.zalloc = png_zalloc; + png_ptr->zstream.zfree = png_zfree; + png_ptr->zstream.opaque = (voidpf)png_ptr; + + switch (inflateInit(&png_ptr->zstream)) + { + case Z_OK: /* Do nothing */ break; + case Z_MEM_ERROR: + case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break; + case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break; + default: png_error(png_ptr, "Unknown zlib error"); + } + + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + + png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); +} + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* Read the information before the actual image data. This has been + * changed in v0.90 to allow reading a file that already has the magic + * bytes read from the stream. You can tell libpng how many bytes have + * been read from the beginning of the stream (up to the maximum of 8) + * via png_set_sig_bytes(), and we will only check the remaining bytes + * here. The application can then have access to the signature bytes we + * read if it is determined that this isn't a valid PNG file. + */ +void PNGAPI +png_read_info(png_structp png_ptr, png_infop info_ptr) +{ + if(png_ptr == NULL) return; + png_debug(1, "in png_read_info\n"); + /* If we haven't checked all of the PNG signature bytes, do so now. */ + if (png_ptr->sig_bytes < 8) + { + png_size_t num_checked = png_ptr->sig_bytes, + num_to_check = 8 - num_checked; + + png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); + png_ptr->sig_bytes = 8; + + if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) + { + if (num_checked < 4 && + png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) + png_error(png_ptr, "Not a PNG file"); + else + png_error(png_ptr, "PNG file corrupted by ASCII conversion"); + } + if (num_checked < 3) + png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; + } + + for(;;) + { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IHDR; + PNG_IDAT; + PNG_IEND; + PNG_PLTE; +#if defined(PNG_READ_bKGD_SUPPORTED) + PNG_bKGD; +#endif +#if defined(PNG_READ_cHRM_SUPPORTED) + PNG_cHRM; +#endif +#if defined(PNG_READ_gAMA_SUPPORTED) + PNG_gAMA; +#endif +#if defined(PNG_READ_hIST_SUPPORTED) + PNG_hIST; +#endif +#if defined(PNG_READ_iCCP_SUPPORTED) + PNG_iCCP; +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + PNG_iTXt; +#endif +#if defined(PNG_READ_oFFs_SUPPORTED) + PNG_oFFs; +#endif +#if defined(PNG_READ_pCAL_SUPPORTED) + PNG_pCAL; +#endif +#if defined(PNG_READ_pHYs_SUPPORTED) + PNG_pHYs; +#endif +#if defined(PNG_READ_sBIT_SUPPORTED) + PNG_sBIT; +#endif +#if defined(PNG_READ_sCAL_SUPPORTED) + PNG_sCAL; +#endif +#if defined(PNG_READ_sPLT_SUPPORTED) + PNG_sPLT; +#endif +#if defined(PNG_READ_sRGB_SUPPORTED) + PNG_sRGB; +#endif +#if defined(PNG_READ_tEXt_SUPPORTED) + PNG_tEXt; +#endif +#if defined(PNG_READ_tIME_SUPPORTED) + PNG_tIME; +#endif +#if defined(PNG_READ_tRNS_SUPPORTED) + PNG_tRNS; +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + PNG_zTXt; +#endif +#endif /* PNG_USE_LOCAL_ARRAYS */ + png_byte chunk_length[4]; + png_uint_32 length; + + png_read_data(png_ptr, chunk_length, 4); + length = png_get_uint_31(png_ptr,chunk_length); + + png_reset_crc(png_ptr); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); + + png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name, + length); + + /* This should be a binary subdivision search or a hash for + * matching the chunk name rather than a linear search. + */ + if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) + if(png_ptr->mode & PNG_AFTER_IDAT) + png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; + + if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) + png_handle_IHDR(png_ptr, info_ptr, length); + else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) + png_handle_IEND(png_ptr, info_ptr, length); +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) + { + if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + png_ptr->mode |= PNG_HAVE_IDAT; + png_handle_unknown(png_ptr, info_ptr, length); + if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + png_ptr->mode |= PNG_HAVE_PLTE; + else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + { + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before IDAT"); + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing PLTE before IDAT"); + break; + } + } +#endif + else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + png_handle_PLTE(png_ptr, info_ptr, length); + else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + { + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before IDAT"); + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing PLTE before IDAT"); + + png_ptr->idat_size = length; + png_ptr->mode |= PNG_HAVE_IDAT; + break; + } +#if defined(PNG_READ_bKGD_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) + png_handle_bKGD(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_cHRM_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) + png_handle_cHRM(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_gAMA_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) + png_handle_gAMA(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_hIST_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) + png_handle_hIST(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_oFFs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) + png_handle_oFFs(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_pCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) + png_handle_pCAL(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) + png_handle_sCAL(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_pHYs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) + png_handle_pHYs(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sBIT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) + png_handle_sBIT(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sRGB_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) + png_handle_sRGB(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_iCCP_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) + png_handle_iCCP(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sPLT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) + png_handle_sPLT(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_tEXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) + png_handle_tEXt(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_tIME_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) + png_handle_tIME(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_tRNS_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) + png_handle_tRNS(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) + png_handle_zTXt(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) + png_handle_iTXt(png_ptr, info_ptr, length); +#endif + else + png_handle_unknown(png_ptr, info_ptr, length); + } +} +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ + +/* optional call to update the users info_ptr structure */ +void PNGAPI +png_read_update_info(png_structp png_ptr, png_infop info_ptr) +{ + png_debug(1, "in png_read_update_info\n"); + if(png_ptr == NULL) return; + if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) + png_read_start_row(png_ptr); + else + png_warning(png_ptr, + "Ignoring extra png_read_update_info() call; row buffer not reallocated"); + png_read_transform_info(png_ptr, info_ptr); +} + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* Initialize palette, background, etc, after transformations + * are set, but before any reading takes place. This allows + * the user to obtain a gamma-corrected palette, for example. + * If the user doesn't call this, we will do it ourselves. + */ +void PNGAPI +png_start_read_image(png_structp png_ptr) +{ + png_debug(1, "in png_start_read_image\n"); + if(png_ptr == NULL) return; + if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) + png_read_start_row(png_ptr); +} +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +void PNGAPI +png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IDAT; + const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; + const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; +#endif + int ret; + if(png_ptr == NULL) return; + png_debug2(1, "in png_read_row (row %lu, pass %d)\n", + png_ptr->row_number, png_ptr->pass); + if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) + png_read_start_row(png_ptr); + if (png_ptr->row_number == 0 && png_ptr->pass == 0) + { + /* check for transforms that have been set but were defined out */ +#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) + if (png_ptr->transformations & PNG_INVERT_MONO) + png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined."); +#endif +#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) + if (png_ptr->transformations & PNG_FILLER) + png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined."); +#endif +#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && !defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined."); +#endif +#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) + if (png_ptr->transformations & PNG_PACK) + png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined."); +#endif +#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) + if (png_ptr->transformations & PNG_SHIFT) + png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined."); +#endif +#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) + if (png_ptr->transformations & PNG_BGR) + png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined."); +#endif +#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) + if (png_ptr->transformations & PNG_SWAP_BYTES) + png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined."); +#endif + } + +#if defined(PNG_READ_INTERLACING_SUPPORTED) + /* if interlaced and we do not need a new row, combine row and return */ + if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) + { + switch (png_ptr->pass) + { + case 0: + if (png_ptr->row_number & 0x07) + { + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); + png_read_finish_row(png_ptr); + return; + } + break; + case 1: + if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) + { + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); + png_read_finish_row(png_ptr); + return; + } + break; + case 2: + if ((png_ptr->row_number & 0x07) != 4) + { + if (dsp_row != NULL && (png_ptr->row_number & 4)) + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); + png_read_finish_row(png_ptr); + return; + } + break; + case 3: + if ((png_ptr->row_number & 3) || png_ptr->width < 3) + { + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); + png_read_finish_row(png_ptr); + return; + } + break; + case 4: + if ((png_ptr->row_number & 3) != 2) + { + if (dsp_row != NULL && (png_ptr->row_number & 2)) + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); + png_read_finish_row(png_ptr); + return; + } + break; + case 5: + if ((png_ptr->row_number & 1) || png_ptr->width < 2) + { + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); + png_read_finish_row(png_ptr); + return; + } + break; + case 6: + if (!(png_ptr->row_number & 1)) + { + png_read_finish_row(png_ptr); + return; + } + break; + } + } +#endif + + if (!(png_ptr->mode & PNG_HAVE_IDAT)) + png_error(png_ptr, "Invalid attempt to read row data"); + + png_ptr->zstream.next_out = png_ptr->row_buf; + png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; + do + { + if (!(png_ptr->zstream.avail_in)) + { + while (!png_ptr->idat_size) + { + png_byte chunk_length[4]; + + png_crc_finish(png_ptr, 0); + + png_read_data(png_ptr, chunk_length, 4); + png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length); + + png_reset_crc(png_ptr); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); + if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + png_error(png_ptr, "Not enough image data"); + } + png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; + png_ptr->zstream.next_in = png_ptr->zbuf; + if (png_ptr->zbuf_size > png_ptr->idat_size) + png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; + png_crc_read(png_ptr, png_ptr->zbuf, + (png_size_t)png_ptr->zstream.avail_in); + png_ptr->idat_size -= png_ptr->zstream.avail_in; + } + ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); + if (ret == Z_STREAM_END) + { + if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in || + png_ptr->idat_size) + png_error(png_ptr, "Extra compressed data"); + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; + break; + } + if (ret != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : + "Decompression error"); + + } while (png_ptr->zstream.avail_out); + + png_ptr->row_info.color_type = png_ptr->color_type; + png_ptr->row_info.width = png_ptr->iwidth; + png_ptr->row_info.channels = png_ptr->channels; + png_ptr->row_info.bit_depth = png_ptr->bit_depth; + png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; + png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, + png_ptr->row_info.width); + + if(png_ptr->row_buf[0]) + png_read_filter_row(png_ptr, &(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->prev_row + 1, + (int)(png_ptr->row_buf[0])); + + png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, + png_ptr->rowbytes + 1); + +#if defined(PNG_MNG_FEATURES_SUPPORTED) + if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) + { + /* Intrapixel differencing */ + png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); + } +#endif + + + if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) + png_do_read_transformations(png_ptr); + +#if defined(PNG_READ_INTERLACING_SUPPORTED) + /* blow up interlaced rows to full size */ + if (png_ptr->interlaced && + (png_ptr->transformations & PNG_INTERLACE)) + { + if (png_ptr->pass < 6) +/* old interface (pre-1.0.9): + png_do_read_interlace(&(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); + */ + png_do_read_interlace(png_ptr); + + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); + if (row != NULL) + png_combine_row(png_ptr, row, + png_pass_mask[png_ptr->pass]); + } + else +#endif + { + if (row != NULL) + png_combine_row(png_ptr, row, 0xff); + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, 0xff); + } + png_read_finish_row(png_ptr); + + if (png_ptr->read_row_fn != NULL) + (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); +} +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* Read one or more rows of image data. If the image is interlaced, + * and png_set_interlace_handling() has been called, the rows need to + * contain the contents of the rows from the previous pass. If the + * image has alpha or transparency, and png_handle_alpha()[*] has been + * called, the rows contents must be initialized to the contents of the + * screen. + * + * "row" holds the actual image, and pixels are placed in it + * as they arrive. If the image is displayed after each pass, it will + * appear to "sparkle" in. "display_row" can be used to display a + * "chunky" progressive image, with finer detail added as it becomes + * available. If you do not want this "chunky" display, you may pass + * NULL for display_row. If you do not want the sparkle display, and + * you have not called png_handle_alpha(), you may pass NULL for rows. + * If you have called png_handle_alpha(), and the image has either an + * alpha channel or a transparency chunk, you must provide a buffer for + * rows. In this case, you do not have to provide a display_row buffer + * also, but you may. If the image is not interlaced, or if you have + * not called png_set_interlace_handling(), the display_row buffer will + * be ignored, so pass NULL to it. + * + * [*] png_handle_alpha() does not exist yet, as of this version of libpng + */ + +void PNGAPI +png_read_rows(png_structp png_ptr, png_bytepp row, + png_bytepp display_row, png_uint_32 num_rows) +{ + png_uint_32 i; + png_bytepp rp; + png_bytepp dp; + + png_debug(1, "in png_read_rows\n"); + if(png_ptr == NULL) return; + rp = row; + dp = display_row; + if (rp != NULL && dp != NULL) + for (i = 0; i < num_rows; i++) + { + png_bytep rptr = *rp++; + png_bytep dptr = *dp++; + + png_read_row(png_ptr, rptr, dptr); + } + else if(rp != NULL) + for (i = 0; i < num_rows; i++) + { + png_bytep rptr = *rp; + png_read_row(png_ptr, rptr, png_bytep_NULL); + rp++; + } + else if(dp != NULL) + for (i = 0; i < num_rows; i++) + { + png_bytep dptr = *dp; + png_read_row(png_ptr, png_bytep_NULL, dptr); + dp++; + } +} +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* Read the entire image. If the image has an alpha channel or a tRNS + * chunk, and you have called png_handle_alpha()[*], you will need to + * initialize the image to the current image that PNG will be overlaying. + * We set the num_rows again here, in case it was incorrectly set in + * png_read_start_row() by a call to png_read_update_info() or + * png_start_read_image() if png_set_interlace_handling() wasn't called + * prior to either of these functions like it should have been. You can + * only call this function once. If you desire to have an image for + * each pass of a interlaced image, use png_read_rows() instead. + * + * [*] png_handle_alpha() does not exist yet, as of this version of libpng + */ +void PNGAPI +png_read_image(png_structp png_ptr, png_bytepp image) +{ + png_uint_32 i,image_height; + int pass, j; + png_bytepp rp; + + png_debug(1, "in png_read_image\n"); + if(png_ptr == NULL) return; + +#ifdef PNG_READ_INTERLACING_SUPPORTED + pass = png_set_interlace_handling(png_ptr); +#else + if (png_ptr->interlaced) + png_error(png_ptr, + "Cannot read interlaced image -- interlace handler disabled."); + pass = 1; +#endif + + + image_height=png_ptr->height; + png_ptr->num_rows = image_height; /* Make sure this is set correctly */ + + for (j = 0; j < pass; j++) + { + rp = image; + for (i = 0; i < image_height; i++) + { + png_read_row(png_ptr, *rp, png_bytep_NULL); + rp++; + } + } +} +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* Read the end of the PNG file. Will not read past the end of the + * file, will verify the end is accurate, and will read any comments + * or time information at the end of the file, if info is not NULL. + */ +void PNGAPI +png_read_end(png_structp png_ptr, png_infop info_ptr) +{ + png_byte chunk_length[4]; + png_uint_32 length; + + png_debug(1, "in png_read_end\n"); + if(png_ptr == NULL) return; + png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ + + do + { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IHDR; + PNG_IDAT; + PNG_IEND; + PNG_PLTE; +#if defined(PNG_READ_bKGD_SUPPORTED) + PNG_bKGD; +#endif +#if defined(PNG_READ_cHRM_SUPPORTED) + PNG_cHRM; +#endif +#if defined(PNG_READ_gAMA_SUPPORTED) + PNG_gAMA; +#endif +#if defined(PNG_READ_hIST_SUPPORTED) + PNG_hIST; +#endif +#if defined(PNG_READ_iCCP_SUPPORTED) + PNG_iCCP; +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + PNG_iTXt; +#endif +#if defined(PNG_READ_oFFs_SUPPORTED) + PNG_oFFs; +#endif +#if defined(PNG_READ_pCAL_SUPPORTED) + PNG_pCAL; +#endif +#if defined(PNG_READ_pHYs_SUPPORTED) + PNG_pHYs; +#endif +#if defined(PNG_READ_sBIT_SUPPORTED) + PNG_sBIT; +#endif +#if defined(PNG_READ_sCAL_SUPPORTED) + PNG_sCAL; +#endif +#if defined(PNG_READ_sPLT_SUPPORTED) + PNG_sPLT; +#endif +#if defined(PNG_READ_sRGB_SUPPORTED) + PNG_sRGB; +#endif +#if defined(PNG_READ_tEXt_SUPPORTED) + PNG_tEXt; +#endif +#if defined(PNG_READ_tIME_SUPPORTED) + PNG_tIME; +#endif +#if defined(PNG_READ_tRNS_SUPPORTED) + PNG_tRNS; +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + PNG_zTXt; +#endif +#endif /* PNG_USE_LOCAL_ARRAYS */ + + png_read_data(png_ptr, chunk_length, 4); + length = png_get_uint_31(png_ptr,chunk_length); + + png_reset_crc(png_ptr); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); + + png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name); + + if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) + png_handle_IHDR(png_ptr, info_ptr, length); + else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) + png_handle_IEND(png_ptr, info_ptr, length); +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) + { + if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + { + if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) + png_error(png_ptr, "Too many IDAT's found"); + } + png_handle_unknown(png_ptr, info_ptr, length); + if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + png_ptr->mode |= PNG_HAVE_PLTE; + } +#endif + else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + { + /* Zero length IDATs are legal after the last IDAT has been + * read, but not after other chunks have been read. + */ + if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) + png_error(png_ptr, "Too many IDAT's found"); + png_crc_finish(png_ptr, length); + } + else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + png_handle_PLTE(png_ptr, info_ptr, length); +#if defined(PNG_READ_bKGD_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) + png_handle_bKGD(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_cHRM_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) + png_handle_cHRM(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_gAMA_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) + png_handle_gAMA(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_hIST_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) + png_handle_hIST(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_oFFs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) + png_handle_oFFs(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_pCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) + png_handle_pCAL(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) + png_handle_sCAL(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_pHYs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) + png_handle_pHYs(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sBIT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) + png_handle_sBIT(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sRGB_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) + png_handle_sRGB(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_iCCP_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) + png_handle_iCCP(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sPLT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) + png_handle_sPLT(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_tEXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) + png_handle_tEXt(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_tIME_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) + png_handle_tIME(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_tRNS_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) + png_handle_tRNS(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) + png_handle_zTXt(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) + png_handle_iTXt(png_ptr, info_ptr, length); +#endif + else + png_handle_unknown(png_ptr, info_ptr, length); + } while (!(png_ptr->mode & PNG_HAVE_IEND)); +} +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ + +/* free all memory used by the read */ +void PNGAPI +png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, + png_infopp end_info_ptr_ptr) +{ + png_structp png_ptr = NULL; + png_infop info_ptr = NULL, end_info_ptr = NULL; +#ifdef PNG_USER_MEM_SUPPORTED + png_free_ptr free_fn; + png_voidp mem_ptr; +#endif + + png_debug(1, "in png_destroy_read_struct\n"); + if (png_ptr_ptr != NULL) + png_ptr = *png_ptr_ptr; + + if (info_ptr_ptr != NULL) + info_ptr = *info_ptr_ptr; + + if (end_info_ptr_ptr != NULL) + end_info_ptr = *end_info_ptr_ptr; + +#ifdef PNG_USER_MEM_SUPPORTED + free_fn = png_ptr->free_fn; + mem_ptr = png_ptr->mem_ptr; +#endif + + png_read_destroy(png_ptr, info_ptr, end_info_ptr); + + if (info_ptr != NULL) + { +#if defined(PNG_TEXT_SUPPORTED) + png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1); +#endif + +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)info_ptr); +#endif + *info_ptr_ptr = NULL; + } + + if (end_info_ptr != NULL) + { +#if defined(PNG_READ_TEXT_SUPPORTED) + png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); +#endif +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)end_info_ptr); +#endif + *end_info_ptr_ptr = NULL; + } + + if (png_ptr != NULL) + { +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)png_ptr); +#endif + *png_ptr_ptr = NULL; + } +} + +/* free all memory used by the read (old method) */ +void /* PRIVATE */ +png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr) +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf tmp_jmp; +#endif + png_error_ptr error_fn; + png_error_ptr warning_fn; + png_voidp error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + png_free_ptr free_fn; +#endif + + png_debug(1, "in png_read_destroy\n"); + if (info_ptr != NULL) + png_info_destroy(png_ptr, info_ptr); + + if (end_info_ptr != NULL) + png_info_destroy(png_ptr, end_info_ptr); + + png_free(png_ptr, png_ptr->zbuf); + png_free(png_ptr, png_ptr->big_row_buf); + png_free(png_ptr, png_ptr->prev_row); +#if defined(PNG_READ_DITHER_SUPPORTED) + png_free(png_ptr, png_ptr->palette_lookup); + png_free(png_ptr, png_ptr->dither_index); +#endif +#if defined(PNG_READ_GAMMA_SUPPORTED) + png_free(png_ptr, png_ptr->gamma_table); +#endif +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + png_free(png_ptr, png_ptr->gamma_from_1); + png_free(png_ptr, png_ptr->gamma_to_1); +#endif +#ifdef PNG_FREE_ME_SUPPORTED + if (png_ptr->free_me & PNG_FREE_PLTE) + png_zfree(png_ptr, png_ptr->palette); + png_ptr->free_me &= ~PNG_FREE_PLTE; +#else + if (png_ptr->flags & PNG_FLAG_FREE_PLTE) + png_zfree(png_ptr, png_ptr->palette); + png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; +#endif +#if defined(PNG_tRNS_SUPPORTED) || \ + defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_FREE_ME_SUPPORTED + if (png_ptr->free_me & PNG_FREE_TRNS) + png_free(png_ptr, png_ptr->trans); + png_ptr->free_me &= ~PNG_FREE_TRNS; +#else + if (png_ptr->flags & PNG_FLAG_FREE_TRNS) + png_free(png_ptr, png_ptr->trans); + png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; +#endif +#endif +#if defined(PNG_READ_hIST_SUPPORTED) +#ifdef PNG_FREE_ME_SUPPORTED + if (png_ptr->free_me & PNG_FREE_HIST) + png_free(png_ptr, png_ptr->hist); + png_ptr->free_me &= ~PNG_FREE_HIST; +#else + if (png_ptr->flags & PNG_FLAG_FREE_HIST) + png_free(png_ptr, png_ptr->hist); + png_ptr->flags &= ~PNG_FLAG_FREE_HIST; +#endif +#endif +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (png_ptr->gamma_16_table != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_table[i]); + } + png_free(png_ptr, png_ptr->gamma_16_table); + } +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_16_from_1 != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_from_1[i]); + } + png_free(png_ptr, png_ptr->gamma_16_from_1); + } + if (png_ptr->gamma_16_to_1 != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_to_1[i]); + } + png_free(png_ptr, png_ptr->gamma_16_to_1); + } +#endif +#endif +#if defined(PNG_TIME_RFC1123_SUPPORTED) + png_free(png_ptr, png_ptr->time_buffer); +#endif + + inflateEnd(&png_ptr->zstream); +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + png_free(png_ptr, png_ptr->save_buffer); +#endif + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +#ifdef PNG_TEXT_SUPPORTED + png_free(png_ptr, png_ptr->current_text); +#endif /* PNG_TEXT_SUPPORTED */ +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + + /* Save the important info out of the png_struct, in case it is + * being used again. + */ +#ifdef PNG_SETJMP_SUPPORTED + png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); +#endif + + error_fn = png_ptr->error_fn; + warning_fn = png_ptr->warning_fn; + error_ptr = png_ptr->error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + free_fn = png_ptr->free_fn; +#endif + + png_memset(png_ptr, 0, png_sizeof (png_struct)); + + png_ptr->error_fn = error_fn; + png_ptr->warning_fn = warning_fn; + png_ptr->error_ptr = error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + png_ptr->free_fn = free_fn; +#endif + +#ifdef PNG_SETJMP_SUPPORTED + png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); +#endif + +} + +void PNGAPI +png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) +{ + if(png_ptr == NULL) return; + png_ptr->read_row_fn = read_row_fn; +} + + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#if defined(PNG_INFO_IMAGE_SUPPORTED) +void PNGAPI +png_read_png(png_structp png_ptr, png_infop info_ptr, + int transforms, + voidp params) +{ + int row; + + if(png_ptr == NULL) return; +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) + /* invert the alpha channel from opacity to transparency + */ + if (transforms & PNG_TRANSFORM_INVERT_ALPHA) + png_set_invert_alpha(png_ptr); +#endif + + /* png_read_info() gives us all of the information from the + * PNG file before the first IDAT (image data chunk). + */ + png_read_info(png_ptr, info_ptr); + if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) + png_error(png_ptr,"Image is too high to process with png_read_png()"); + + /* -------------- image transformations start here ------------------- */ + +#if defined(PNG_READ_16_TO_8_SUPPORTED) + /* tell libpng to strip 16 bit/color files down to 8 bits per color + */ + if (transforms & PNG_TRANSFORM_STRIP_16) + png_set_strip_16(png_ptr); +#endif + +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) + /* Strip alpha bytes from the input data without combining with + * the background (not recommended). + */ + if (transforms & PNG_TRANSFORM_STRIP_ALPHA) + png_set_strip_alpha(png_ptr); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED) + /* Extract multiple pixels with bit depths of 1, 2, or 4 from a single + * byte into separate bytes (useful for paletted and grayscale images). + */ + if (transforms & PNG_TRANSFORM_PACKING) + png_set_packing(png_ptr); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + /* Change the order of packed pixels to least significant bit first + * (not useful if you are using png_set_packing). + */ + if (transforms & PNG_TRANSFORM_PACKSWAP) + png_set_packswap(png_ptr); +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) + /* Expand paletted colors into true RGB triplets + * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel + * Expand paletted or RGB images with transparency to full alpha + * channels so the data will be available as RGBA quartets. + */ + if (transforms & PNG_TRANSFORM_EXPAND) + if ((png_ptr->bit_depth < 8) || + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || + (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) + png_set_expand(png_ptr); +#endif + + /* We don't handle background color or gamma transformation or dithering. + */ + +#if defined(PNG_READ_INVERT_SUPPORTED) + /* invert monochrome files to have 0 as white and 1 as black + */ + if (transforms & PNG_TRANSFORM_INVERT_MONO) + png_set_invert_mono(png_ptr); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) + /* If you want to shift the pixel values from the range [0,255] or + * [0,65535] to the original [0,7] or [0,31], or whatever range the + * colors were originally in: + */ + if ((transforms & PNG_TRANSFORM_SHIFT) + && png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) + { + png_color_8p sig_bit; + + png_get_sBIT(png_ptr, info_ptr, &sig_bit); + png_set_shift(png_ptr, sig_bit); + } +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) + /* flip the RGB pixels to BGR (or RGBA to BGRA) + */ + if (transforms & PNG_TRANSFORM_BGR) + png_set_bgr(png_ptr); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) + /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) + */ + if (transforms & PNG_TRANSFORM_SWAP_ALPHA) + png_set_swap_alpha(png_ptr); +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) + /* swap bytes of 16 bit files to least significant byte first + */ + if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) + png_set_swap(png_ptr); +#endif + + /* We don't handle adding filler bytes */ + + /* Optional call to gamma correct and add the background to the palette + * and update info structure. REQUIRED if you are expecting libpng to + * update the palette for you (i.e., you selected such a transform above). + */ + png_read_update_info(png_ptr, info_ptr); + + /* -------------- image transformations end here ------------------- */ + +#ifdef PNG_FREE_ME_SUPPORTED + png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); +#endif + if(info_ptr->row_pointers == NULL) + { + info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, + info_ptr->height * png_sizeof(png_bytep)); +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_ROWS; +#endif + for (row = 0; row < (int)info_ptr->height; row++) + { + info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, + png_get_rowbytes(png_ptr, info_ptr)); + } + } + + png_read_image(png_ptr, info_ptr->row_pointers); + info_ptr->valid |= PNG_INFO_IDAT; + + /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ + png_read_end(png_ptr, info_ptr); + + if(transforms == 0 || params == NULL) + /* quiet compiler warnings */ return; + +} +#endif /* PNG_INFO_IMAGE_SUPPORTED */ +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_READ_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/pngrio.c b/src/dep/src/irrlicht/libpng/pngrio.c index 2275683..7d2522f 100644 --- a/src/dep/src/irrlicht/libpng/pngrio.c +++ b/src/dep/src/irrlicht/libpng/pngrio.c @@ -1,167 +1,167 @@ - -/* pngrio.c - functions for data input - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all input. Users who need - * special handling are expected to write a function that has the same - * arguments as this and performs a similar function, but that possibly - * has a different input method. Note that you shouldn't change this - * function, but rather write a replacement function and then make - * libpng use it at run time with png_set_read_fn(...). - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) - -/* Read the data from whatever input you are using. The default routine - reads from a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered reads. This should never be asked - to read more then 64K on a 16 bit machine. */ -void /* PRIVATE */ -png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_debug1(4,"reading %d bytes\n", (int)length); - if (png_ptr->read_data_fn != NULL) - (*(png_ptr->read_data_fn))(png_ptr, data, length); - else - png_error(png_ptr, "Call to NULL read function"); -} - -#if !defined(PNG_NO_STDIO) -/* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -void PNGAPI -png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - if(png_ptr == NULL) return; - /* fread() returns 0 on error, so it is OK to store this in a png_size_t - * instead of an int, which is what fread() actually returns. - */ -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = (png_size_t)fread(data, (png_size_t)1, length, - (png_FILE_p)png_ptr->io_ptr); -#endif - - if (check != length) - png_error(png_ptr, "Read Error"); -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void PNGAPI -png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - int check; - png_byte *n_data; - png_FILE_p io_ptr; - - if(png_ptr == NULL) return; - /* Check if data really is near. If so, use usual code. */ - n_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)n_data == data) - { -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = fread(n_data, 1, length, io_ptr); -#endif - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t read, remaining, err; - check = 0; - remaining = length; - do - { - read = MIN(NEAR_BUF_SIZE, remaining); -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) ) - err = 0; -#else - err = fread(buf, (png_size_t)1, read, io_ptr); -#endif - png_memcpy(data, buf, read); /* copy far buffer to near buffer */ - if(err != read) - break; - else - check += err; - data += read; - remaining -= read; - } - while (remaining != 0); - } - if ((png_uint_32)check != (png_uint_32)length) - png_error(png_ptr, "read Error"); -} -#endif -#endif - -/* This function allows the application to supply a new input function - for libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png input data structure - io_ptr - pointer to user supplied structure containing info about - the input functions. May be NULL. - read_data_fn - pointer to a new input function that takes as its - arguments a pointer to a png_struct, a pointer to - a location where input data can be stored, and a 32-bit - unsigned int that is the number of bytes to be read. - To exit and output any fatal error messages the new write - function should call png_error(png_ptr, "Error msg"). */ -void PNGAPI -png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, - png_rw_ptr read_data_fn) -{ - if(png_ptr == NULL) return; - png_ptr->io_ptr = io_ptr; - -#if !defined(PNG_NO_STDIO) - if (read_data_fn != NULL) - png_ptr->read_data_fn = read_data_fn; - else - png_ptr->read_data_fn = png_default_read_data; -#else - png_ptr->read_data_fn = read_data_fn; -#endif - - /* It is an error to write to a read device */ - if (png_ptr->write_data_fn != NULL) - { - png_ptr->write_data_fn = NULL; - png_warning(png_ptr, - "It's an error to set both read_data_fn and write_data_fn in the "); - png_warning(png_ptr, - "same structure. Resetting write_data_fn to NULL."); - } - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_ptr->output_flush_fn = NULL; -#endif -} -#endif /* PNG_READ_SUPPORTED */ + +/* pngrio.c - functions for data input + * + * Last changed in libpng 1.2.13 November 13, 2006 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This file provides a location for all input. Users who need + * special handling are expected to write a function that has the same + * arguments as this and performs a similar function, but that possibly + * has a different input method. Note that you shouldn't change this + * function, but rather write a replacement function and then make + * libpng use it at run time with png_set_read_fn(...). + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_READ_SUPPORTED) + +/* Read the data from whatever input you are using. The default routine + reads from a file pointer. Note that this routine sometimes gets called + with very small lengths, so you should implement some kind of simple + buffering if you are using unbuffered reads. This should never be asked + to read more then 64K on a 16 bit machine. */ +void /* PRIVATE */ +png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_debug1(4,"reading %d bytes\n", (int)length); + if (png_ptr->read_data_fn != NULL) + (*(png_ptr->read_data_fn))(png_ptr, data, length); + else + png_error(png_ptr, "Call to NULL read function"); +} + +#if !defined(PNG_NO_STDIO) +/* This is the function that does the actual reading of data. If you are + not reading from a standard C stream, you should create a replacement + read_data function and use it at run time with png_set_read_fn(), rather + than changing the library. */ +#ifndef USE_FAR_KEYWORD +void PNGAPI +png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_size_t check; + + if(png_ptr == NULL) return; + /* fread() returns 0 on error, so it is OK to store this in a png_size_t + * instead of an int, which is what fread() actually returns. + */ +#if defined(_WIN32_WCE) + if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) + check = 0; +#else + check = (png_size_t)fread(data, (png_size_t)1, length, + (png_FILE_p)png_ptr->io_ptr); +#endif + + if (check != length) + png_error(png_ptr, "Read Error"); +} +#else +/* this is the model-independent version. Since the standard I/O library + can't handle far buffers in the medium and small models, we have to copy + the data. +*/ + +#define NEAR_BUF_SIZE 1024 +#define MIN(a,b) (a <= b ? a : b) + +static void PNGAPI +png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + int check; + png_byte *n_data; + png_FILE_p io_ptr; + + if(png_ptr == NULL) return; + /* Check if data really is near. If so, use usual code. */ + n_data = (png_byte *)CVT_PTR_NOCHECK(data); + io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); + if ((png_bytep)n_data == data) + { +#if defined(_WIN32_WCE) + if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) + check = 0; +#else + check = fread(n_data, 1, length, io_ptr); +#endif + } + else + { + png_byte buf[NEAR_BUF_SIZE]; + png_size_t read, remaining, err; + check = 0; + remaining = length; + do + { + read = MIN(NEAR_BUF_SIZE, remaining); +#if defined(_WIN32_WCE) + if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) ) + err = 0; +#else + err = fread(buf, (png_size_t)1, read, io_ptr); +#endif + png_memcpy(data, buf, read); /* copy far buffer to near buffer */ + if(err != read) + break; + else + check += err; + data += read; + remaining -= read; + } + while (remaining != 0); + } + if ((png_uint_32)check != (png_uint_32)length) + png_error(png_ptr, "read Error"); +} +#endif +#endif + +/* This function allows the application to supply a new input function + for libpng if standard C streams aren't being used. + + This function takes as its arguments: + png_ptr - pointer to a png input data structure + io_ptr - pointer to user supplied structure containing info about + the input functions. May be NULL. + read_data_fn - pointer to a new input function that takes as its + arguments a pointer to a png_struct, a pointer to + a location where input data can be stored, and a 32-bit + unsigned int that is the number of bytes to be read. + To exit and output any fatal error messages the new write + function should call png_error(png_ptr, "Error msg"). */ +void PNGAPI +png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, + png_rw_ptr read_data_fn) +{ + if(png_ptr == NULL) return; + png_ptr->io_ptr = io_ptr; + +#if !defined(PNG_NO_STDIO) + if (read_data_fn != NULL) + png_ptr->read_data_fn = read_data_fn; + else + png_ptr->read_data_fn = png_default_read_data; +#else + png_ptr->read_data_fn = read_data_fn; +#endif + + /* It is an error to write to a read device */ + if (png_ptr->write_data_fn != NULL) + { + png_ptr->write_data_fn = NULL; + png_warning(png_ptr, + "It's an error to set both read_data_fn and write_data_fn in the "); + png_warning(png_ptr, + "same structure. Resetting write_data_fn to NULL."); + } + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) + png_ptr->output_flush_fn = NULL; +#endif +} +#endif /* PNG_READ_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/pngrtran.c b/src/dep/src/irrlicht/libpng/pngrtran.c index 6e1a47b..2fa96f3 100644 --- a/src/dep/src/irrlicht/libpng/pngrtran.c +++ b/src/dep/src/irrlicht/libpng/pngrtran.c @@ -1,4247 +1,4247 @@ - -/* pngrtran.c - transforms the data in a row for PNG readers - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains functions optionally called by an application - * in order to tell libpng how to handle data when reading a PNG. - * Transformations that are used in both reading and writing are - * in pngtrans.c. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) - -/* Set the action on getting a CRC error for an ancillary or critical chunk. */ -void PNGAPI -png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) -{ - png_debug(1, "in png_set_crc_action\n"); - /* Tell libpng how we react to CRC errors in critical chunks */ - if(png_ptr == NULL) return; - switch (crit_action) - { - case PNG_CRC_NO_CHANGE: /* leave setting as is */ - break; - case PNG_CRC_WARN_USE: /* warn/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; - break; - case PNG_CRC_QUIET_USE: /* quiet/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | - PNG_FLAG_CRC_CRITICAL_IGNORE; - break; - case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */ - png_warning(png_ptr, "Can't discard critical data on CRC error."); - case PNG_CRC_ERROR_QUIT: /* error/quit */ - case PNG_CRC_DEFAULT: - default: - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - break; - } - - switch (ancil_action) - { - case PNG_CRC_NO_CHANGE: /* leave setting as is */ - break; - case PNG_CRC_WARN_USE: /* warn/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; - break; - case PNG_CRC_QUIET_USE: /* quiet/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | - PNG_FLAG_CRC_ANCILLARY_NOWARN; - break; - case PNG_CRC_ERROR_QUIT: /* error/quit */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; - break; - case PNG_CRC_WARN_DISCARD: /* warn/discard data */ - case PNG_CRC_DEFAULT: - default: - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - break; - } -} - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) -/* handle alpha and tRNS via a background color */ -void PNGAPI -png_set_background(png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma) -{ - png_debug(1, "in png_set_background\n"); - if(png_ptr == NULL) return; - if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) - { - png_warning(png_ptr, "Application must supply a known background gamma"); - return; - } - - png_ptr->transformations |= PNG_BACKGROUND; - png_memcpy(&(png_ptr->background), background_color, - png_sizeof(png_color_16)); - png_ptr->background_gamma = (float)background_gamma; - png_ptr->background_gamma_type = (png_byte)(background_gamma_code); - png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0); -} -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip 16 bit depth files to 8 bit depth */ -void PNGAPI -png_set_strip_16(png_structp png_ptr) -{ - png_debug(1, "in png_set_strip_16\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_16_TO_8; -} -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -void PNGAPI -png_set_strip_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_strip_alpha\n"); - if(png_ptr == NULL) return; - png_ptr->flags |= PNG_FLAG_STRIP_ALPHA; -} -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* Dither file to 8 bit. Supply a palette, the current number - * of elements in the palette, the maximum number of elements - * allowed, and a histogram if possible. If the current number - * of colors is greater then the maximum number, the palette will be - * modified to fit in the maximum number. "full_dither" indicates - * whether we need a dithering cube set up for RGB images, or if we - * simply are reducing the number of colors in a paletted image. - */ - -typedef struct png_dsort_struct -{ - struct png_dsort_struct FAR * next; - png_byte left; - png_byte right; -} png_dsort; -typedef png_dsort FAR * png_dsortp; -typedef png_dsort FAR * FAR * png_dsortpp; - -void PNGAPI -png_set_dither(png_structp png_ptr, png_colorp palette, - int num_palette, int maximum_colors, png_uint_16p histogram, - int full_dither) -{ - png_debug(1, "in png_set_dither\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_DITHER; - - if (!full_dither) - { - int i; - - png_ptr->dither_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); - for (i = 0; i < num_palette; i++) - png_ptr->dither_index[i] = (png_byte)i; - } - - if (num_palette > maximum_colors) - { - if (histogram != NULL) - { - /* This is easy enough, just throw out the least used colors. - Perhaps not the best solution, but good enough. */ - - int i; - - /* initialize an array to sort colors */ - png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); - - /* initialize the dither_sort array */ - for (i = 0; i < num_palette; i++) - png_ptr->dither_sort[i] = (png_byte)i; - - /* Find the least used palette entries by starting a - bubble sort, and running it until we have sorted - out enough colors. Note that we don't care about - sorting all the colors, just finding which are - least used. */ - - for (i = num_palette - 1; i >= maximum_colors; i--) - { - int done; /* to stop early if the list is pre-sorted */ - int j; - - done = 1; - for (j = 0; j < i; j++) - { - if (histogram[png_ptr->dither_sort[j]] - < histogram[png_ptr->dither_sort[j + 1]]) - { - png_byte t; - - t = png_ptr->dither_sort[j]; - png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1]; - png_ptr->dither_sort[j + 1] = t; - done = 0; - } - } - if (done) - break; - } - - /* swap the palette around, and set up a table, if necessary */ - if (full_dither) - { - int j = num_palette; - - /* put all the useful colors within the max, but don't - move the others */ - for (i = 0; i < maximum_colors; i++) - { - if ((int)png_ptr->dither_sort[i] >= maximum_colors) - { - do - j--; - while ((int)png_ptr->dither_sort[j] >= maximum_colors); - palette[i] = palette[j]; - } - } - } - else - { - int j = num_palette; - - /* move all the used colors inside the max limit, and - develop a translation table */ - for (i = 0; i < maximum_colors; i++) - { - /* only move the colors we need to */ - if ((int)png_ptr->dither_sort[i] >= maximum_colors) - { - png_color tmp_color; - - do - j--; - while ((int)png_ptr->dither_sort[j] >= maximum_colors); - - tmp_color = palette[j]; - palette[j] = palette[i]; - palette[i] = tmp_color; - /* indicate where the color went */ - png_ptr->dither_index[j] = (png_byte)i; - png_ptr->dither_index[i] = (png_byte)j; - } - } - - /* find closest color for those colors we are not using */ - for (i = 0; i < num_palette; i++) - { - if ((int)png_ptr->dither_index[i] >= maximum_colors) - { - int min_d, k, min_k, d_index; - - /* find the closest color to one we threw out */ - d_index = png_ptr->dither_index[i]; - min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); - for (k = 1, min_k = 0; k < maximum_colors; k++) - { - int d; - - d = PNG_COLOR_DIST(palette[d_index], palette[k]); - - if (d < min_d) - { - min_d = d; - min_k = k; - } - } - /* point to closest color */ - png_ptr->dither_index[i] = (png_byte)min_k; - } - } - } - png_free(png_ptr, png_ptr->dither_sort); - png_ptr->dither_sort=NULL; - } - else - { - /* This is much harder to do simply (and quickly). Perhaps - we need to go through a median cut routine, but those - don't always behave themselves with only a few colors - as input. So we will just find the closest two colors, - and throw out one of them (chosen somewhat randomly). - [We don't understand this at all, so if someone wants to - work on improving it, be our guest - AED, GRP] - */ - int i; - int max_d; - int num_new_palette; - png_dsortp t; - png_dsortpp hash; - - t=NULL; - - /* initialize palette index arrays */ - png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); - png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); - - /* initialize the sort array */ - for (i = 0; i < num_palette; i++) - { - png_ptr->index_to_palette[i] = (png_byte)i; - png_ptr->palette_to_index[i] = (png_byte)i; - } - - hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 * - png_sizeof (png_dsortp))); - for (i = 0; i < 769; i++) - hash[i] = NULL; -/* png_memset(hash, 0, 769 * png_sizeof (png_dsortp)); */ - - num_new_palette = num_palette; - - /* initial wild guess at how far apart the farthest pixel - pair we will be eliminating will be. Larger - numbers mean more areas will be allocated, Smaller - numbers run the risk of not saving enough data, and - having to do this all over again. - - I have not done extensive checking on this number. - */ - max_d = 96; - - while (num_new_palette > maximum_colors) - { - for (i = 0; i < num_new_palette - 1; i++) - { - int j; - - for (j = i + 1; j < num_new_palette; j++) - { - int d; - - d = PNG_COLOR_DIST(palette[i], palette[j]); - - if (d <= max_d) - { - - t = (png_dsortp)png_malloc_warn(png_ptr, - (png_uint_32)(png_sizeof(png_dsort))); - if (t == NULL) - break; - t->next = hash[d]; - t->left = (png_byte)i; - t->right = (png_byte)j; - hash[d] = t; - } - } - if (t == NULL) - break; - } - - if (t != NULL) - for (i = 0; i <= max_d; i++) - { - if (hash[i] != NULL) - { - png_dsortp p; - - for (p = hash[i]; p; p = p->next) - { - if ((int)png_ptr->index_to_palette[p->left] - < num_new_palette && - (int)png_ptr->index_to_palette[p->right] - < num_new_palette) - { - int j, next_j; - - if (num_new_palette & 0x01) - { - j = p->left; - next_j = p->right; - } - else - { - j = p->right; - next_j = p->left; - } - - num_new_palette--; - palette[png_ptr->index_to_palette[j]] - = palette[num_new_palette]; - if (!full_dither) - { - int k; - - for (k = 0; k < num_palette; k++) - { - if (png_ptr->dither_index[k] == - png_ptr->index_to_palette[j]) - png_ptr->dither_index[k] = - png_ptr->index_to_palette[next_j]; - if ((int)png_ptr->dither_index[k] == - num_new_palette) - png_ptr->dither_index[k] = - png_ptr->index_to_palette[j]; - } - } - - png_ptr->index_to_palette[png_ptr->palette_to_index - [num_new_palette]] = png_ptr->index_to_palette[j]; - png_ptr->palette_to_index[png_ptr->index_to_palette[j]] - = png_ptr->palette_to_index[num_new_palette]; - - png_ptr->index_to_palette[j] = (png_byte)num_new_palette; - png_ptr->palette_to_index[num_new_palette] = (png_byte)j; - } - if (num_new_palette <= maximum_colors) - break; - } - if (num_new_palette <= maximum_colors) - break; - } - } - - for (i = 0; i < 769; i++) - { - if (hash[i] != NULL) - { - png_dsortp p = hash[i]; - while (p) - { - t = p->next; - png_free(png_ptr, p); - p = t; - } - } - hash[i] = 0; - } - max_d += 96; - } - png_free(png_ptr, hash); - png_free(png_ptr, png_ptr->palette_to_index); - png_free(png_ptr, png_ptr->index_to_palette); - png_ptr->palette_to_index=NULL; - png_ptr->index_to_palette=NULL; - } - num_palette = maximum_colors; - } - if (png_ptr->palette == NULL) - { - png_ptr->palette = palette; - } - png_ptr->num_palette = (png_uint_16)num_palette; - - if (full_dither) - { - int i; - png_bytep distance; - int total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS + - PNG_DITHER_BLUE_BITS; - int num_red = (1 << PNG_DITHER_RED_BITS); - int num_green = (1 << PNG_DITHER_GREEN_BITS); - int num_blue = (1 << PNG_DITHER_BLUE_BITS); - png_size_t num_entries = ((png_size_t)1 << total_bits); - - png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr, - (png_uint_32)(num_entries * png_sizeof (png_byte))); - - png_memset(png_ptr->palette_lookup, 0, num_entries * - png_sizeof (png_byte)); - - distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * - png_sizeof(png_byte))); - - png_memset(distance, 0xff, num_entries * png_sizeof(png_byte)); - - for (i = 0; i < num_palette; i++) - { - int ir, ig, ib; - int r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS)); - int g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS)); - int b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS)); - - for (ir = 0; ir < num_red; ir++) - { - /* int dr = abs(ir - r); */ - int dr = ((ir > r) ? ir - r : r - ir); - int index_r = (ir << (PNG_DITHER_BLUE_BITS + PNG_DITHER_GREEN_BITS)); - - for (ig = 0; ig < num_green; ig++) - { - /* int dg = abs(ig - g); */ - int dg = ((ig > g) ? ig - g : g - ig); - int dt = dr + dg; - int dm = ((dr > dg) ? dr : dg); - int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS); - - for (ib = 0; ib < num_blue; ib++) - { - int d_index = index_g | ib; - /* int db = abs(ib - b); */ - int db = ((ib > b) ? ib - b : b - ib); - int dmax = ((dm > db) ? dm : db); - int d = dmax + dt + db; - - if (d < (int)distance[d_index]) - { - distance[d_index] = (png_byte)d; - png_ptr->palette_lookup[d_index] = (png_byte)i; - } - } - } - } - } - - png_free(png_ptr, distance); - } -} -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) -/* Transform the image from the file_gamma to the screen_gamma. We - * only do transformations on images where the file_gamma and screen_gamma - * are not close reciprocals, otherwise it slows things down slightly, and - * also needlessly introduces small errors. - * - * We will turn off gamma transformation later if no semitransparent entries - * are present in the tRNS array for palette images. We can't do it here - * because we don't necessarily have the tRNS chunk yet. - */ -void PNGAPI -png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) -{ - png_debug(1, "in png_set_gamma\n"); - if(png_ptr == NULL) return; - if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) - png_ptr->transformations |= PNG_GAMMA; - png_ptr->gamma = (float)file_gamma; - png_ptr->screen_gamma = (float)scrn_gamma; -} -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expand paletted images to RGB, expand grayscale images of - * less than 8-bit depth to 8-bit depth, and expand tRNS chunks - * to alpha channels. - */ -void PNGAPI -png_set_expand(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} - -/* GRR 19990627: the following three functions currently are identical - * to png_set_expand(). However, it is entirely reasonable that someone - * might wish to expand an indexed image to RGB but *not* expand a single, - * fully transparent palette entry to a full alpha channel--perhaps instead - * convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace - * the transparent color with a particular RGB value, or drop tRNS entirely. - * IOW, a future version of the library may make the transformations flag - * a bit more fine-grained, with separate bits for each of these three - * functions. - * - * More to the point, these functions make it obvious what libpng will be - * doing, whereas "expand" can (and does) mean any number of things. - * - * GRP 20060307: In libpng-1.4.0, png_set_gray_1_2_4_to_8() was modified - * to expand only the sample depth but not to expand the tRNS to alpha. - */ - -/* Expand paletted images to RGB. */ -void PNGAPI -png_set_palette_to_rgb(png_structp png_ptr) -{ - png_debug(1, "in png_set_palette_to_rgb\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} - -#if !defined(PNG_1_0_X) -/* Expand grayscale images of less than 8-bit depth to 8 bits. */ -void PNGAPI -png_set_expand_gray_1_2_4_to_8(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand_gray_1_2_4_to_8\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_EXPAND_tRNS; -} -#endif - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Expand grayscale images of less than 8-bit depth to 8 bits. */ -/* Deprecated as of libpng-1.2.9 */ -void PNGAPI -png_set_gray_1_2_4_to_8(png_structp png_ptr) -{ - png_debug(1, "in png_set_gray_1_2_4_to_8\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} -#endif - - -/* Expand tRNS chunks to alpha channels. */ -void PNGAPI -png_set_tRNS_to_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand\n"); - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} -#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */ - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -void PNGAPI -png_set_gray_to_rgb(png_structp png_ptr) -{ - png_debug(1, "in png_set_gray_to_rgb\n"); - png_ptr->transformations |= PNG_GRAY_TO_RGB; -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) -/* Convert a RGB image to a grayscale of the same width. This allows us, - * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. - */ - -void PNGAPI -png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, - double green) -{ - int red_fixed = (int)((float)red*100000.0 + 0.5); - int green_fixed = (int)((float)green*100000.0 + 0.5); - if(png_ptr == NULL) return; - png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); -} -#endif - -void PNGAPI -png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, - png_fixed_point red, png_fixed_point green) -{ - png_debug(1, "in png_set_rgb_to_gray\n"); - if(png_ptr == NULL) return; - switch(error_action) - { - case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; - break; - case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; - break; - case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; - } - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#if defined(PNG_READ_EXPAND_SUPPORTED) - png_ptr->transformations |= PNG_EXPAND; -#else - { - png_warning(png_ptr, "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); - png_ptr->transformations &= ~PNG_RGB_TO_GRAY; - } -#endif - { - png_uint_16 red_int, green_int; - if(red < 0 || green < 0) - { - red_int = 6968; /* .212671 * 32768 + .5 */ - green_int = 23434; /* .715160 * 32768 + .5 */ - } - else if(red + green < 100000L) - { - red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L); - green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L); - } - else - { - png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients"); - red_int = 6968; - green_int = 23434; - } - png_ptr->rgb_to_gray_red_coeff = red_int; - png_ptr->rgb_to_gray_green_coeff = green_int; - png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int); - } -} -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -void PNGAPI -png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr - read_user_transform_fn) -{ - png_debug(1, "in png_set_read_user_transform_fn\n"); - if(png_ptr == NULL) return; -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - png_ptr->transformations |= PNG_USER_TRANSFORM; - png_ptr->read_user_transform_fn = read_user_transform_fn; -#endif -#ifdef PNG_LEGACY_SUPPORTED - if(read_user_transform_fn) - png_warning(png_ptr, - "This version of libpng does not support user transforms"); -#endif -} -#endif - -/* Initialize everything needed for the read. This includes modifying - * the palette. - */ -void /* PRIVATE */ -png_init_read_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_init_read_transformations\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if(png_ptr != NULL) -#endif - { -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \ - || defined(PNG_READ_GAMMA_SUPPORTED) - int color_type = png_ptr->color_type; -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* Detect gray background and attempt to enable optimization - * for gray --> RGB case */ - /* Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or - * RGB_ALPHA (in which case need_expand is superfluous anyway), the - * background color might actually be gray yet not be flagged as such. - * This is not a problem for the current code, which uses - * PNG_BACKGROUND_IS_GRAY only to decide when to do the - * png_do_gray_to_rgb() transformation. - */ - if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - !(color_type & PNG_COLOR_MASK_COLOR)) - { - png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; - } else if ((png_ptr->transformations & PNG_BACKGROUND) && - !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - (png_ptr->transformations & PNG_GRAY_TO_RGB) && - png_ptr->background.red == png_ptr->background.green && - png_ptr->background.red == png_ptr->background.blue) - { - png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; - png_ptr->background.gray = png_ptr->background.red; - } -#endif - - if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - (png_ptr->transformations & PNG_EXPAND)) - { - if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */ - { - /* expand background and tRNS chunks */ - switch (png_ptr->bit_depth) - { - case 1: - png_ptr->background.gray *= (png_uint_16)0xff; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) - { - png_ptr->trans_values.gray *= (png_uint_16)0xff; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; - } - break; - case 2: - png_ptr->background.gray *= (png_uint_16)0x55; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) - { - png_ptr->trans_values.gray *= (png_uint_16)0x55; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; - } - break; - case 4: - png_ptr->background.gray *= (png_uint_16)0x11; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) - { - png_ptr->trans_values.gray *= (png_uint_16)0x11; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; - } - break; - case 8: - case 16: - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - break; - } - } - else if (color_type == PNG_COLOR_TYPE_PALETTE) - { - png_ptr->background.red = - png_ptr->palette[png_ptr->background.index].red; - png_ptr->background.green = - png_ptr->palette[png_ptr->background.index].green; - png_ptr->background.blue = - png_ptr->palette[png_ptr->background.index].blue; - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - { -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) -#endif - { - /* invert the alpha channel (in tRNS) unless the pixels are - going to be expanded, in which case leave it for later */ - int i,istop; - istop=(int)png_ptr->num_trans; - for (i=0; itrans[i] = (png_byte)(255 - png_ptr->trans[i]); - } - } -#endif - - } - } -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) - png_ptr->background_1 = png_ptr->background; -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - - if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0) - && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0) - < PNG_GAMMA_THRESHOLD)) - { - int i,k; - k=0; - for (i=0; inum_trans; i++) - { - if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff) - k=1; /* partial transparency is present */ - } - if (k == 0) - png_ptr->transformations &= (~PNG_GAMMA); - } - - if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) && - png_ptr->gamma != 0.0) - { - png_build_gamma_table(png_ptr); -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - /* could skip if no transparency and - */ - png_color back, back_1; - png_colorp palette = png_ptr->palette; - int num_palette = png_ptr->num_palette; - int i; - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) - { - back.red = png_ptr->gamma_table[png_ptr->background.red]; - back.green = png_ptr->gamma_table[png_ptr->background.green]; - back.blue = png_ptr->gamma_table[png_ptr->background.blue]; - - back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; - back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; - back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; - } - else - { - double g, gs; - - switch (png_ptr->background_gamma_type) - { - case PNG_BACKGROUND_GAMMA_SCREEN: - g = (png_ptr->screen_gamma); - gs = 1.0; - break; - case PNG_BACKGROUND_GAMMA_FILE: - g = 1.0 / (png_ptr->gamma); - gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - break; - case PNG_BACKGROUND_GAMMA_UNIQUE: - g = 1.0 / (png_ptr->background_gamma); - gs = 1.0 / (png_ptr->background_gamma * - png_ptr->screen_gamma); - break; - default: - g = 1.0; /* back_1 */ - gs = 1.0; /* back */ - } - - if ( fabs(gs - 1.0) < PNG_GAMMA_THRESHOLD) - { - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - } - else - { - back.red = (png_byte)(pow( - (double)png_ptr->background.red/255, gs) * 255.0 + .5); - back.green = (png_byte)(pow( - (double)png_ptr->background.green/255, gs) * 255.0 + .5); - back.blue = (png_byte)(pow( - (double)png_ptr->background.blue/255, gs) * 255.0 + .5); - } - - back_1.red = (png_byte)(pow( - (double)png_ptr->background.red/255, g) * 255.0 + .5); - back_1.green = (png_byte)(pow( - (double)png_ptr->background.green/255, g) * 255.0 + .5); - back_1.blue = (png_byte)(pow( - (double)png_ptr->background.blue/255, g) * 255.0 + .5); - } - for (i = 0; i < num_palette; i++) - { - if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff) - { - if (png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else /* if (png_ptr->trans[i] != 0xff) */ - { - png_byte v, w; - - v = png_ptr->gamma_to_1[palette[i].red]; - png_composite(w, v, png_ptr->trans[i], back_1.red); - palette[i].red = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[palette[i].green]; - png_composite(w, v, png_ptr->trans[i], back_1.green); - palette[i].green = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[palette[i].blue]; - png_composite(w, v, png_ptr->trans[i], back_1.blue); - palette[i].blue = png_ptr->gamma_from_1[w]; - } - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */ - else - /* color_type != PNG_COLOR_TYPE_PALETTE */ - { - double m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1); - double g = 1.0; - double gs = 1.0; - - switch (png_ptr->background_gamma_type) - { - case PNG_BACKGROUND_GAMMA_SCREEN: - g = (png_ptr->screen_gamma); - gs = 1.0; - break; - case PNG_BACKGROUND_GAMMA_FILE: - g = 1.0 / (png_ptr->gamma); - gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - break; - case PNG_BACKGROUND_GAMMA_UNIQUE: - g = 1.0 / (png_ptr->background_gamma); - gs = 1.0 / (png_ptr->background_gamma * - png_ptr->screen_gamma); - break; - } - - png_ptr->background_1.gray = (png_uint_16)(pow( - (double)png_ptr->background.gray / m, g) * m + .5); - png_ptr->background.gray = (png_uint_16)(pow( - (double)png_ptr->background.gray / m, gs) * m + .5); - - if ((png_ptr->background.red != png_ptr->background.green) || - (png_ptr->background.red != png_ptr->background.blue) || - (png_ptr->background.red != png_ptr->background.gray)) - { - /* RGB or RGBA with color background */ - png_ptr->background_1.red = (png_uint_16)(pow( - (double)png_ptr->background.red / m, g) * m + .5); - png_ptr->background_1.green = (png_uint_16)(pow( - (double)png_ptr->background.green / m, g) * m + .5); - png_ptr->background_1.blue = (png_uint_16)(pow( - (double)png_ptr->background.blue / m, g) * m + .5); - png_ptr->background.red = (png_uint_16)(pow( - (double)png_ptr->background.red / m, gs) * m + .5); - png_ptr->background.green = (png_uint_16)(pow( - (double)png_ptr->background.green / m, gs) * m + .5); - png_ptr->background.blue = (png_uint_16)(pow( - (double)png_ptr->background.blue / m, gs) * m + .5); - } - else - { - /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */ - png_ptr->background_1.red = png_ptr->background_1.green - = png_ptr->background_1.blue = png_ptr->background_1.gray; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - } - } - } - else - /* transformation does not include PNG_BACKGROUND */ -#endif /* PNG_READ_BACKGROUND_SUPPORTED */ - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - png_colorp palette = png_ptr->palette; - int num_palette = png_ptr->num_palette; - int i; - - for (i = 0; i < num_palette; i++) - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - else -#endif -#endif /* PNG_READ_GAMMA_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */ -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - /* No GAMMA transformation */ - if ((png_ptr->transformations & PNG_BACKGROUND) && - (color_type == PNG_COLOR_TYPE_PALETTE)) - { - int i; - int istop = (int)png_ptr->num_trans; - png_color back; - png_colorp palette = png_ptr->palette; - - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - - for (i = 0; i < istop; i++) - { - if (png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else if (png_ptr->trans[i] != 0xff) - { - /* The png_composite() macro is defined in png.h */ - png_composite(palette[i].red, palette[i].red, - png_ptr->trans[i], back.red); - png_composite(palette[i].green, palette[i].green, - png_ptr->trans[i], back.green); - png_composite(palette[i].blue, palette[i].blue, - png_ptr->trans[i], back.blue); - } - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED */ - -#if defined(PNG_READ_SHIFT_SUPPORTED) - if ((png_ptr->transformations & PNG_SHIFT) && - (color_type == PNG_COLOR_TYPE_PALETTE)) - { - png_uint_16 i; - png_uint_16 istop = png_ptr->num_palette; - int sr = 8 - png_ptr->sig_bit.red; - int sg = 8 - png_ptr->sig_bit.green; - int sb = 8 - png_ptr->sig_bit.blue; - - if (sr < 0 || sr > 8) - sr = 0; - if (sg < 0 || sg > 8) - sg = 0; - if (sb < 0 || sb > 8) - sb = 0; - for (i = 0; i < istop; i++) - { - png_ptr->palette[i].red >>= sr; - png_ptr->palette[i].green >>= sg; - png_ptr->palette[i].blue >>= sb; - } - } -#endif /* PNG_READ_SHIFT_SUPPORTED */ - } -#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ - && !defined(PNG_READ_BACKGROUND_SUPPORTED) - if(png_ptr) - return; -#endif -} - -/* Modify the info structure to reflect the transformations. The - * info should be updated so a PNG file could be written with it, - * assuming the transformations result in valid PNG data. - */ -void /* PRIVATE */ -png_read_transform_info(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_read_transform_info\n"); -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS)) - info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA; - else - info_ptr->color_type = PNG_COLOR_TYPE_RGB; - info_ptr->bit_depth = 8; - info_ptr->num_trans = 0; - } - else - { - if (png_ptr->num_trans) - { - if (png_ptr->transformations & PNG_EXPAND_tRNS) - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; - else - info_ptr->color_type |= PNG_COLOR_MASK_COLOR; - } - if (info_ptr->bit_depth < 8) - info_ptr->bit_depth = 8; - info_ptr->num_trans = 0; - } - } -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; - info_ptr->num_trans = 0; - info_ptr->background = png_ptr->background; - } -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->transformations & PNG_GAMMA) - { -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = png_ptr->gamma; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = png_ptr->int_gamma; -#endif - } -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16)) - info_ptr->bit_depth = 8; -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - if (png_ptr->transformations & PNG_GRAY_TO_RGB) - info_ptr->color_type |= PNG_COLOR_MASK_COLOR; -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & PNG_RGB_TO_GRAY) - info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR; -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - if (png_ptr->transformations & PNG_DITHER) - { - if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || - (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && - png_ptr->palette_lookup && info_ptr->bit_depth == 8) - { - info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; - } - } -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) - if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8)) - info_ptr->bit_depth = 8; -#endif - - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - info_ptr->channels = 1; - else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) - info_ptr->channels = 3; - else - info_ptr->channels = 1; - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) - info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; -#endif - - if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) - info_ptr->channels++; - -#if defined(PNG_READ_FILLER_SUPPORTED) - /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */ - if ((png_ptr->transformations & PNG_FILLER) && - ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || - (info_ptr->color_type == PNG_COLOR_TYPE_GRAY))) - { - info_ptr->channels++; - /* if adding a true alpha channel not just filler */ -#if !defined(PNG_1_0_X) - if (png_ptr->transformations & PNG_ADD_ALPHA) - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; -#endif - } -#endif - -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ -defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - if(png_ptr->transformations & PNG_USER_TRANSFORM) - { - if(info_ptr->bit_depth < png_ptr->user_transform_depth) - info_ptr->bit_depth = png_ptr->user_transform_depth; - if(info_ptr->channels < png_ptr->user_transform_channels) - info_ptr->channels = png_ptr->user_transform_channels; - } -#endif - - info_ptr->pixel_depth = (png_byte)(info_ptr->channels * - info_ptr->bit_depth); - - info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,info_ptr->width); - -#if !defined(PNG_READ_EXPAND_SUPPORTED) - if(png_ptr) - return; -#endif -} - -/* Transform the row. The order of transformations is significant, - * and is very touchy. If you add a transformation, take care to - * decide how it fits in with the other transformations here. - */ -void /* PRIVATE */ -png_do_read_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_do_read_transformations\n"); -#if !defined(PNG_USELESS_TESTS_SUPPORTED) - if (png_ptr->row_buf == NULL) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[50]; - - sprintf(msg, "NULL row buffer for row %ld, pass %d", png_ptr->row_number, - png_ptr->pass); - png_error(png_ptr, msg); -#else - png_error(png_ptr, "NULL row buffer"); -#endif - } -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE) - { - png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->palette, png_ptr->trans, png_ptr->num_trans); - } - else - { - if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS)) - png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values)); - else - png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, - NULL); - } - } -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) - png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - PNG_FLAG_FILLER_AFTER | (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & PNG_RGB_TO_GRAY) - { - int rgb_error = - png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1); - if(rgb_error) - { - png_ptr->rgb_to_gray_status=1; - if(png_ptr->transformations == PNG_RGB_TO_GRAY_WARN) - png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - if(png_ptr->transformations == PNG_RGB_TO_GRAY_ERR) - png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - } - } -#endif - -/* -From Andreas Dilger e-mail to png-implement, 26 March 1998: - - In most cases, the "simple transparency" should be done prior to doing - gray-to-RGB, or you will have to test 3x as many bytes to check if a - pixel is transparent. You would also need to make sure that the - transparency information is upgraded to RGB. - - To summarize, the current flow is: - - Gray + simple transparency -> compare 1 or 2 gray bytes and composite - with background "in place" if transparent, - convert to RGB if necessary - - Gray + alpha -> composite with gray background and remove alpha bytes, - convert to RGB if necessary - - To support RGB backgrounds for gray images we need: - - Gray + simple transparency -> convert to RGB + simple transparency, compare - 3 or 6 bytes and composite with background - "in place" if transparent (3x compare/pixel - compared to doing composite with gray bkgrnd) - - Gray + alpha -> convert to RGB + alpha, composite with background and - remove alpha bytes (3x float operations/pixel - compared with composite on gray background) - - Greg's change will do this. The reason it wasn't done before is for - performance, as this increases the per-pixel operations. If we would check - in advance if the background was gray or RGB, and position the gray-to-RGB - transform appropriately, then it would save a lot of work/time. - */ - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if background is non-gray; else do later - * for performance reasons */ - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && - !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) - png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if ((png_ptr->transformations & PNG_BACKGROUND) && - ((png_ptr->num_trans != 0 ) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) - png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values), &(png_ptr->background) -#if defined(PNG_READ_GAMMA_SUPPORTED) - , &(png_ptr->background_1), - png_ptr->gamma_table, png_ptr->gamma_from_1, - png_ptr->gamma_to_1, png_ptr->gamma_16_table, - png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1, - png_ptr->gamma_shift -#endif -); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) - if ((png_ptr->transformations & PNG_GAMMA) && -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - !((png_ptr->transformations & PNG_BACKGROUND) && - ((png_ptr->num_trans != 0) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && -#endif - (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) - png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->gamma_table, png_ptr->gamma_16_table, - png_ptr->gamma_shift); -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - if (png_ptr->transformations & PNG_16_TO_8) - png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - if (png_ptr->transformations & PNG_DITHER) - { - png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->palette_lookup, png_ptr->dither_index); - if(png_ptr->row_info.rowbytes == (png_uint_32)0) - png_error(png_ptr, "png_do_dither returned rowbytes=0"); - } -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_do_unshift(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->shift)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if we did not do so above */ - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && - (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) - png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - (png_uint_32)png_ptr->filler, png_ptr->flags); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - if (png_ptr->transformations & PNG_USER_TRANSFORM) - { - if(png_ptr->read_user_transform_fn != NULL) - (*(png_ptr->read_user_transform_fn)) /* user read transform function */ - (png_ptr, /* png_ptr */ - &(png_ptr->row_info), /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_uint_32 rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if(png_ptr->user_transform_depth) - png_ptr->row_info.bit_depth = png_ptr->user_transform_depth; - if(png_ptr->user_transform_channels) - png_ptr->row_info.channels = png_ptr->user_transform_channels; -#endif - png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * - png_ptr->row_info.channels); - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); - } -#endif - -} - -#if defined(PNG_READ_PACK_SUPPORTED) -/* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel, - * without changing the actual values. Thus, if you had a row with - * a bit depth of 1, you would end up with bytes that only contained - * the numbers 0 or 1. If you would rather they contain 0 and 255, use - * png_do_shift() after this. - */ -void /* PRIVATE */ -png_do_unpack(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_unpack\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && row_info->bit_depth < 8) -#else - if (row_info->bit_depth < 8) -#endif - { - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - switch (row_info->bit_depth) - { - case 1: - { - png_bytep sp = row + (png_size_t)((row_width - 1) >> 3); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x01); - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - - png_bytep sp = row + (png_size_t)((row_width - 1) >> 2); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x03); - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - png_bytep sp = row + (png_size_t)((row_width - 1) >> 1); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x0f); - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift = 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = (png_byte)(8 * row_info->channels); - row_info->rowbytes = row_width * row_info->channels; - } -} -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) -/* Reverse the effects of png_do_shift. This routine merely shifts the - * pixels back to their significant bits values. Thus, if you have - * a row of bit depth 8, but only 5 are significant, this will shift - * the values back to 0 through 31. - */ -void /* PRIVATE */ -png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) -{ - png_debug(1, "in png_do_unshift\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && sig_bits != NULL && -#endif - row_info->color_type != PNG_COLOR_TYPE_PALETTE) - { - int shift[4]; - int channels = 0; - int c; - png_uint_16 value = 0; - png_uint_32 row_width = row_info->width; - - if (row_info->color_type & PNG_COLOR_MASK_COLOR) - { - shift[channels++] = row_info->bit_depth - sig_bits->red; - shift[channels++] = row_info->bit_depth - sig_bits->green; - shift[channels++] = row_info->bit_depth - sig_bits->blue; - } - else - { - shift[channels++] = row_info->bit_depth - sig_bits->gray; - } - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - shift[channels++] = row_info->bit_depth - sig_bits->alpha; - } - - for (c = 0; c < channels; c++) - { - if (shift[c] <= 0) - shift[c] = 0; - else - value = 1; - } - - if (!value) - return; - - switch (row_info->bit_depth) - { - case 2: - { - png_bytep bp; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (bp = row, i = 0; i < istop; i++) - { - *bp >>= 1; - *bp++ &= 0x55; - } - break; - } - case 4: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_byte mask = (png_byte)((((int)0xf0 >> shift[0]) & (int)0xf0) | - (png_byte)((int)0xf >> shift[0])); - - for (i = 0; i < istop; i++) - { - *bp >>= shift[0]; - *bp++ &= mask; - } - break; - } - case 8: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = row_width * channels; - - for (i = 0; i < istop; i++) - { - *bp++ >>= shift[i%channels]; - } - break; - } - case 16: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = channels * row_width; - - for (i = 0; i < istop; i++) - { - value = (png_uint_16)((*bp << 8) + *(bp + 1)); - value >>= shift[i%channels]; - *bp++ = (png_byte)(value >> 8); - *bp++ = (png_byte)(value & 0xff); - } - break; - } - } - } -} -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* chop rows of bit depth 16 down to 8 */ -void /* PRIVATE */ -png_do_chop(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_chop\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && row_info->bit_depth == 16) -#else - if (row_info->bit_depth == 16) -#endif - { - png_bytep sp = row; - png_bytep dp = row; - png_uint_32 i; - png_uint_32 istop = row_info->width * row_info->channels; - - for (i = 0; i> 8)) >> 8; - * - * Approximate calculation with shift/add instead of multiply/divide: - * *dp = ((((png_uint_32)(*sp) << 8) | - * (png_uint_32)((int)(*(sp + 1)) - *sp)) + 128) >> 8; - * - * What we actually do to avoid extra shifting and conversion: - */ - - *dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0); -#else - /* Simply discard the low order byte */ - *dp = *sp; -#endif - } - row_info->bit_depth = 8; - row_info->pixel_depth = (png_byte)(8 * row_info->channels); - row_info->rowbytes = row_info->width * row_info->channels; - } -} -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_swap_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - png_uint_32 row_width = row_info->width; - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This converts from RGBA to ARGB */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save; - } - } - /* This converts from RRGGBBAA to AARRGGBB */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save[2]; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save[0] = *(--sp); - save[1] = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save[0]; - *(--dp) = save[1]; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This converts from GA to AG */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save; - } - } - /* This converts from GGAA to AAGG */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save[2]; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save[0] = *(--sp); - save[1] = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save[0]; - *(--dp) = save[1]; - } - } - } - } -} -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_invert_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - png_uint_32 row_width = row_info->width; - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This inverts the alpha channel in RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: -*/ - sp-=3; - dp=sp; - } - } - /* This inverts the alpha channel in RRGGBBAA */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); - -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: -*/ - sp-=6; - dp=sp; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This inverts the alpha channel in GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = *(--sp); - } - } - /* This inverts the alpha channel in GGAA */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); -/* - *(--dp) = *(--sp); - *(--dp) = *(--sp); -*/ - sp-=2; - dp=sp; - } - } - } - } -} -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) -/* Add filler channel if we have RGB color */ -void /* PRIVATE */ -png_do_read_filler(png_row_infop row_info, png_bytep row, - png_uint_32 filler, png_uint_32 flags) -{ - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - png_byte hi_filler = (png_byte)((filler>>8) & 0xff); - png_byte lo_filler = (png_byte)(filler & 0xff); - - png_debug(1, "in png_do_read_filler\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - if(row_info->bit_depth == 8) - { - /* This changes the data from G to GX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 1; i < row_width; i++) - { - *(--dp) = lo_filler; - *(--dp) = *(--sp); - } - *(--dp) = lo_filler; - row_info->channels = 2; - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - /* This changes the data from G to XG */ - else - { - png_bytep sp = row + (png_size_t)row_width; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = lo_filler; - } - row_info->channels = 2; - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - } - else if(row_info->bit_depth == 16) - { - /* This changes the data from GG to GGXX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width * 2; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 1; i < row_width; i++) - { - *(--dp) = hi_filler; - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = hi_filler; - *(--dp) = lo_filler; - row_info->channels = 2; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - /* This changes the data from GG to XXGG */ - else - { - png_bytep sp = row + (png_size_t)row_width * 2; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = hi_filler; - *(--dp) = lo_filler; - } - row_info->channels = 2; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - } - } /* COLOR_TYPE == GRAY */ - else if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - if(row_info->bit_depth == 8) - { - /* This changes the data from RGB to RGBX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width * 3; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 1; i < row_width; i++) - { - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = lo_filler; - row_info->channels = 4; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - /* This changes the data from RGB to XRGB */ - else - { - png_bytep sp = row + (png_size_t)row_width * 3; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = lo_filler; - } - row_info->channels = 4; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - } - else if(row_info->bit_depth == 16) - { - /* This changes the data from RRGGBB to RRGGBBXX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width * 6; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 1; i < row_width; i++) - { - *(--dp) = hi_filler; - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = hi_filler; - *(--dp) = lo_filler; - row_info->channels = 4; - row_info->pixel_depth = 64; - row_info->rowbytes = row_width * 8; - } - /* This changes the data from RRGGBB to XXRRGGBB */ - else - { - png_bytep sp = row + (png_size_t)row_width * 6; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = hi_filler; - *(--dp) = lo_filler; - } - row_info->channels = 4; - row_info->pixel_depth = 64; - row_info->rowbytes = row_width * 8; - } - } - } /* COLOR_TYPE == RGB */ -} -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -/* expand grayscale files to RGB, with or without alpha */ -void /* PRIVATE */ -png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) -{ - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - png_debug(1, "in png_do_gray_to_rgb\n"); - if (row_info->bit_depth >= 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - !(row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - if (row_info->bit_depth == 8) - { - png_bytep sp = row + (png_size_t)row_width - 1; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(dp--) = *sp; - *(dp--) = *sp; - *(dp--) = *(sp--); - } - } - else - { - png_bytep sp = row + (png_size_t)row_width * 2 - 1; - png_bytep dp = sp + (png_size_t)row_width * 4; - for (i = 0; i < row_width; i++) - { - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *(sp--); - *(dp--) = *(sp--); - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (row_info->bit_depth == 8) - { - png_bytep sp = row + (png_size_t)row_width * 2 - 1; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(dp--) = *(sp--); - *(dp--) = *sp; - *(dp--) = *sp; - *(dp--) = *(sp--); - } - } - else - { - png_bytep sp = row + (png_size_t)row_width * 4 - 1; - png_bytep dp = sp + (png_size_t)row_width * 4; - for (i = 0; i < row_width; i++) - { - *(dp--) = *(sp--); - *(dp--) = *(sp--); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *(sp--); - *(dp--) = *(sp--); - } - } - } - row_info->channels += (png_byte)2; - row_info->color_type |= PNG_COLOR_MASK_COLOR; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -/* reduce RGB files to grayscale, with or without alpha - * using the equation given in Poynton's ColorFAQ at - * - * Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net - * - * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - * - * We approximate this with - * - * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - * - * which can be expressed with integers as - * - * Y = (6969 * R + 23434 * G + 2365 * B)/32768 - * - * The calculation is to be done in a linear colorspace. - * - * Other integer coefficents can be used via png_set_rgb_to_gray(). - */ -int /* PRIVATE */ -png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) - -{ - png_uint_32 i; - - png_uint_32 row_width = row_info->width; - int rgb_error = 0; - - png_debug(1, "in png_do_rgb_to_gray\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; - png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; - png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - - for (i = 0; i < row_width; i++) - { - png_byte red = png_ptr->gamma_to_1[*(sp++)]; - png_byte green = png_ptr->gamma_to_1[*(sp++)]; - png_byte blue = png_ptr->gamma_to_1[*(sp++)]; - if(red != green || red != blue) - { - rgb_error |= 1; - *(dp++) = png_ptr->gamma_from_1[ - (rc*red+gc*green+bc*blue)>>15]; - } - else - *(dp++) = *(sp-1); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - if(red != green || red != blue) - { - rgb_error |= 1; - *(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15); - } - else - *(dp++) = *(sp-1); - } - } - } - - else /* RGB bit_depth == 16 */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_to_1 != NULL && - png_ptr->gamma_16_from_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, w; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red == green && red == blue) - w = red; - else - { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> - png_ptr->gamma_shift][red>>8]; - png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> - png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> - png_ptr->gamma_shift][blue>>8]; - png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 - + bc*blue_1)>>15); - w = png_ptr->gamma_16_from_1[(gray16&0xff) >> - png_ptr->gamma_shift][gray16 >> 8]; - rgb_error |= 1; - } - - *(dp++) = (png_byte)((w>>8) & 0xff); - *(dp++) = (png_byte)(w & 0xff); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, gray16; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red != green || red != blue) - rgb_error |= 1; - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = (png_byte)((gray16>>8) & 0xff); - *(dp++) = (png_byte)(gray16 & 0xff); - } - } - } - } - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = png_ptr->gamma_to_1[*(sp++)]; - png_byte green = png_ptr->gamma_to_1[*(sp++)]; - png_byte blue = png_ptr->gamma_to_1[*(sp++)]; - if(red != green || red != blue) - rgb_error |= 1; - *(dp++) = png_ptr->gamma_from_1 - [(rc*red + gc*green + bc*blue)>>15]; - *(dp++) = *(sp++); /* alpha */ - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - if(red != green || red != blue) - rgb_error |= 1; - *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = *(sp++); /* alpha */ - } - } - } - else /* RGBA bit_depth == 16 */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_to_1 != NULL && - png_ptr->gamma_16_from_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, w; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red == green && red == blue) - w = red; - else - { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> - png_ptr->gamma_shift][red>>8]; - png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> - png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> - png_ptr->gamma_shift][blue>>8]; - png_uint_16 gray16 = (png_uint_16)((rc * red_1 - + gc * green_1 + bc * blue_1)>>15); - w = png_ptr->gamma_16_from_1[(gray16&0xff) >> - png_ptr->gamma_shift][gray16 >> 8]; - rgb_error |= 1; - } - - *(dp++) = (png_byte)((w>>8) & 0xff); - *(dp++) = (png_byte)(w & 0xff); - *(dp++) = *(sp++); /* alpha */ - *(dp++) = *(sp++); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, gray16; - red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - if(red != green || red != blue) - rgb_error |= 1; - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = (png_byte)((gray16>>8) & 0xff); - *(dp++) = (png_byte)(gray16 & 0xff); - *(dp++) = *(sp++); /* alpha */ - *(dp++) = *(sp++); - } - } - } - } - row_info->channels -= (png_byte)2; - row_info->color_type &= ~PNG_COLOR_MASK_COLOR; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - return rgb_error; -} -#endif - -/* Build a grayscale palette. Palette is assumed to be 1 << bit_depth - * large of png_color. This lets grayscale images be treated as - * paletted. Most useful for gamma correction and simplification - * of code. - */ -void PNGAPI -png_build_grayscale_palette(int bit_depth, png_colorp palette) -{ - int num_palette; - int color_inc; - int i; - int v; - - png_debug(1, "in png_do_build_grayscale_palette\n"); - if (palette == NULL) - return; - - switch (bit_depth) - { - case 1: - num_palette = 2; - color_inc = 0xff; - break; - case 2: - num_palette = 4; - color_inc = 0x55; - break; - case 4: - num_palette = 16; - color_inc = 0x11; - break; - case 8: - num_palette = 256; - color_inc = 1; - break; - default: - num_palette = 0; - color_inc = 0; - break; - } - - for (i = 0, v = 0; i < num_palette; i++, v += color_inc) - { - palette[i].red = (png_byte)v; - palette[i].green = (png_byte)v; - palette[i].blue = (png_byte)v; - } -} - -/* This function is currently unused. Do we really need it? */ -#if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED) -void /* PRIVATE */ -png_correct_palette(png_structp png_ptr, png_colorp palette, - int num_palette) -{ - png_debug(1, "in png_correct_palette\n"); -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND)) - { - png_color back, back_1; - - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) - { - back.red = png_ptr->gamma_table[png_ptr->background.red]; - back.green = png_ptr->gamma_table[png_ptr->background.green]; - back.blue = png_ptr->gamma_table[png_ptr->background.blue]; - - back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; - back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; - back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; - } - else - { - double g; - - g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); - - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_SCREEN || - fabs(g - 1.0) < PNG_GAMMA_THRESHOLD) - { - back.red = png_ptr->background.red; - back.green = png_ptr->background.green; - back.blue = png_ptr->background.blue; - } - else - { - back.red = - (png_byte)(pow((double)png_ptr->background.red/255, g) * - 255.0 + 0.5); - back.green = - (png_byte)(pow((double)png_ptr->background.green/255, g) * - 255.0 + 0.5); - back.blue = - (png_byte)(pow((double)png_ptr->background.blue/255, g) * - 255.0 + 0.5); - } - - g = 1.0 / png_ptr->background_gamma; - - back_1.red = - (png_byte)(pow((double)png_ptr->background.red/255, g) * - 255.0 + 0.5); - back_1.green = - (png_byte)(pow((double)png_ptr->background.green/255, g) * - 255.0 + 0.5); - back_1.blue = - (png_byte)(pow((double)png_ptr->background.blue/255, g) * - 255.0 + 0.5); - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_uint_32 i; - - for (i = 0; i < (png_uint_32)num_palette; i++) - { - if (i < png_ptr->num_trans && png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else if (i < png_ptr->num_trans && png_ptr->trans[i] != 0xff) - { - png_byte v, w; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].red]; - png_composite(w, v, png_ptr->trans[i], back_1.red); - palette[i].red = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].green]; - png_composite(w, v, png_ptr->trans[i], back_1.green); - palette[i].green = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].blue]; - png_composite(w, v, png_ptr->trans[i], back_1.blue); - palette[i].blue = png_ptr->gamma_from_1[w]; - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - else - { - int i; - - for (i = 0; i < num_palette; i++) - { - if (palette[i].red == (png_byte)png_ptr->trans_values.gray) - { - palette[i] = back; - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - } - else -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->transformations & PNG_GAMMA) - { - int i; - - for (i = 0; i < num_palette; i++) - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - else -#endif -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_color back; - - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - - for (i = 0; i < (int)png_ptr->num_trans; i++) - { - if (png_ptr->trans[i] == 0) - { - palette[i].red = back.red; - palette[i].green = back.green; - palette[i].blue = back.blue; - } - else if (png_ptr->trans[i] != 0xff) - { - png_composite(palette[i].red, png_ptr->palette[i].red, - png_ptr->trans[i], back.red); - png_composite(palette[i].green, png_ptr->palette[i].green, - png_ptr->trans[i], back.green); - png_composite(palette[i].blue, png_ptr->palette[i].blue, - png_ptr->trans[i], back.blue); - } - } - } - else /* assume grayscale palette (what else could it be?) */ - { - int i; - - for (i = 0; i < num_palette; i++) - { - if (i == (png_byte)png_ptr->trans_values.gray) - { - palette[i].red = (png_byte)png_ptr->background.red; - palette[i].green = (png_byte)png_ptr->background.green; - palette[i].blue = (png_byte)png_ptr->background.blue; - } - } - } - } -#endif -} -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -/* Replace any alpha or transparency with the supplied background color. - * "background" is already in the screen gamma, while "background_1" is - * at a gamma of 1.0. Paletted files have already been taken care of. - */ -void /* PRIVATE */ -png_do_background(png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background -#if defined(PNG_READ_GAMMA_SUPPORTED) - , png_color_16p background_1, - png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, - png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift -#endif - ) -{ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - int shift; - - png_debug(1, "in png_do_background\n"); - if (background != NULL && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (!(row_info->color_type & PNG_COLOR_MASK_ALPHA) || - (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_values))) - { - switch (row_info->color_type) - { - case PNG_COLOR_TYPE_GRAY: - { - switch (row_info->bit_depth) - { - case 1: - { - sp = row; - shift = 7; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x01) - == trans_values->gray) - { - *sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 7; - sp++; - } - else - shift--; - } - break; - } - case 2: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - shift = 6; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x03) - == trans_values->gray) - { - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - else - { - png_byte p = (png_byte)((*sp >> shift) & 0x03); - png_byte g = (png_byte)((gamma_table [p | (p << 2) | - (p << 4) | (p << 6)] >> 6) & 0x03); - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(g << shift); - } - if (!shift) - { - shift = 6; - sp++; - } - else - shift -= 2; - } - } - else -#endif - { - sp = row; - shift = 6; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x03) - == trans_values->gray) - { - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 6; - sp++; - } - else - shift -= 2; - } - } - break; - } - case 4: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - shift = 4; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x0f) - == trans_values->gray) - { - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - else - { - png_byte p = (png_byte)((*sp >> shift) & 0x0f); - png_byte g = (png_byte)((gamma_table[p | - (p << 4)] >> 4) & 0x0f); - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(g << shift); - } - if (!shift) - { - shift = 4; - sp++; - } - else - shift -= 4; - } - } - else -#endif - { - sp = row; - shift = 4; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x0f) - == trans_values->gray) - { - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 4; - sp++; - } - else - shift -= 4; - } - } - break; - } - case 8: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - if (*sp == trans_values->gray) - { - *sp = (png_byte)background->gray; - } - else - { - *sp = gamma_table[*sp]; - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - if (*sp == trans_values->gray) - { - *sp = (png_byte)background->gray; - } - } - } - break; - } - case 16: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 2) - { - png_uint_16 v; - - v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - if (v == trans_values->gray) - { - /* background is already in screen gamma */ - *sp = (png_byte)((background->gray >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->gray & 0xff); - } - else - { - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 2) - { - png_uint_16 v; - - v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - if (v == trans_values->gray) - { - *sp = (png_byte)((background->gray >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->gray & 0xff); - } - } - } - break; - } - } - break; - } - case PNG_COLOR_TYPE_RGB: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 3) - { - if (*sp == trans_values->red && - *(sp + 1) == trans_values->green && - *(sp + 2) == trans_values->blue) - { - *sp = (png_byte)background->red; - *(sp + 1) = (png_byte)background->green; - *(sp + 2) = (png_byte)background->blue; - } - else - { - *sp = gamma_table[*sp]; - *(sp + 1) = gamma_table[*(sp + 1)]; - *(sp + 2) = gamma_table[*(sp + 2)]; - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 3) - { - if (*sp == trans_values->red && - *(sp + 1) == trans_values->green && - *(sp + 2) == trans_values->blue) - { - *sp = (png_byte)background->red; - *(sp + 1) = (png_byte)background->green; - *(sp + 2) = (png_byte)background->blue; - } - } - } - } - else /* if (row_info->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 6) - { - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); - if (r == trans_values->red && g == trans_values->green && - b == trans_values->blue) - { - /* background is already in screen gamma */ - *sp = (png_byte)((background->red >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->red & 0xff); - *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(sp + 3) = (png_byte)(background->green & 0xff); - *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(sp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; - *(sp + 2) = (png_byte)((v >> 8) & 0xff); - *(sp + 3) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; - *(sp + 4) = (png_byte)((v >> 8) & 0xff); - *(sp + 5) = (png_byte)(v & 0xff); - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 6) - { - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp+1)); - png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); - - if (r == trans_values->red && g == trans_values->green && - b == trans_values->blue) - { - *sp = (png_byte)((background->red >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->red & 0xff); - *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(sp + 3) = (png_byte)(background->green & 0xff); - *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(sp + 5) = (png_byte)(background->blue & 0xff); - } - } - } - } - break; - } - case PNG_COLOR_TYPE_GRAY_ALPHA: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_to_1 != NULL && gamma_from_1 != NULL && - gamma_table != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 2, dp++) - { - png_uint_16 a = *(sp + 1); - - if (a == 0xff) - { - *dp = gamma_table[*sp]; - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)background->gray; - } - else - { - png_byte v, w; - - v = gamma_to_1[*sp]; - png_composite(w, v, a, background_1->gray); - *dp = gamma_from_1[w]; - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 2, dp++) - { - png_byte a = *(sp + 1); - - if (a == 0xff) - { - *dp = *sp; - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else if (a == 0) - { - *dp = (png_byte)background->gray; - } - else - { - png_composite(*dp, *sp, a, background_1->gray); - } -#else - *dp = (png_byte)background->gray; -#endif - } - } - } - else /* if (png_ptr->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL && gamma_16_from_1 != NULL && - gamma_16_to_1 != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 2) - { - png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - - if (a == (png_uint_16)0xffff) - { - png_uint_16 v; - - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else if (a == 0) -#else - else -#endif - { - /* background is already in screen gamma */ - *dp = (png_byte)((background->gray >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->gray & 0xff); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else - { - png_uint_16 g, v, w; - - g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(v, g, a, background_1->gray); - w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8]; - *dp = (png_byte)((w >> 8) & 0xff); - *(dp + 1) = (png_byte)(w & 0xff); - } -#endif - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 2) - { - png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - if (a == (png_uint_16)0xffff) - { - png_memcpy(dp, sp, 2); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else if (a == 0) -#else - else -#endif - { - *dp = (png_byte)((background->gray >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->gray & 0xff); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else - { - png_uint_16 g, v; - - g = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_composite_16(v, g, a, background_1->gray); - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - } -#endif - } - } - } - break; - } - case PNG_COLOR_TYPE_RGB_ALPHA: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_to_1 != NULL && gamma_from_1 != NULL && - gamma_table != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 3) - { - png_byte a = *(sp + 3); - - if (a == 0xff) - { - *dp = gamma_table[*sp]; - *(dp + 1) = gamma_table[*(sp + 1)]; - *(dp + 2) = gamma_table[*(sp + 2)]; - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)background->red; - *(dp + 1) = (png_byte)background->green; - *(dp + 2) = (png_byte)background->blue; - } - else - { - png_byte v, w; - - v = gamma_to_1[*sp]; - png_composite(w, v, a, background_1->red); - *dp = gamma_from_1[w]; - v = gamma_to_1[*(sp + 1)]; - png_composite(w, v, a, background_1->green); - *(dp + 1) = gamma_from_1[w]; - v = gamma_to_1[*(sp + 2)]; - png_composite(w, v, a, background_1->blue); - *(dp + 2) = gamma_from_1[w]; - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 3) - { - png_byte a = *(sp + 3); - - if (a == 0xff) - { - *dp = *sp; - *(dp + 1) = *(sp + 1); - *(dp + 2) = *(sp + 2); - } - else if (a == 0) - { - *dp = (png_byte)background->red; - *(dp + 1) = (png_byte)background->green; - *(dp + 2) = (png_byte)background->blue; - } - else - { - png_composite(*dp, *sp, a, background->red); - png_composite(*(dp + 1), *(sp + 1), a, - background->green); - png_composite(*(dp + 2), *(sp + 2), a, - background->blue); - } - } - } - } - else /* if (row_info->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL && gamma_16_from_1 != NULL && - gamma_16_to_1 != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 8, dp += 6) - { - png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) - << 8) + (png_uint_16)(*(sp + 7))); - if (a == (png_uint_16)0xffff) - { - png_uint_16 v; - - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; - *(dp + 2) = (png_byte)((v >> 8) & 0xff); - *(dp + 3) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; - *(dp + 4) = (png_byte)((v >> 8) & 0xff); - *(dp + 5) = (png_byte)(v & 0xff); - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)((background->red >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->red & 0xff); - *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(dp + 3) = (png_byte)(background->green & 0xff); - *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(dp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v, w, x; - - v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(w, v, a, background_1->red); - x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; - *dp = (png_byte)((x >> 8) & 0xff); - *(dp + 1) = (png_byte)(x & 0xff); - v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)]; - png_composite_16(w, v, a, background_1->green); - x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; - *(dp + 2) = (png_byte)((x >> 8) & 0xff); - *(dp + 3) = (png_byte)(x & 0xff); - v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)]; - png_composite_16(w, v, a, background_1->blue); - x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8]; - *(dp + 4) = (png_byte)((x >> 8) & 0xff); - *(dp + 5) = (png_byte)(x & 0xff); - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 8, dp += 6) - { - png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) - << 8) + (png_uint_16)(*(sp + 7))); - if (a == (png_uint_16)0xffff) - { - png_memcpy(dp, sp, 6); - } - else if (a == 0) - { - *dp = (png_byte)((background->red >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->red & 0xff); - *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(dp + 3) = (png_byte)(background->green & 0xff); - *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(dp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v; - - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) - + *(sp + 3)); - png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) - + *(sp + 5)); - - png_composite_16(v, r, a, background->red); - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - png_composite_16(v, g, a, background->green); - *(dp + 2) = (png_byte)((v >> 8) & 0xff); - *(dp + 3) = (png_byte)(v & 0xff); - png_composite_16(v, b, a, background->blue); - *(dp + 4) = (png_byte)((v >> 8) & 0xff); - *(dp + 5) = (png_byte)(v & 0xff); - } - } - } - } - break; - } - } - - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; - row_info->channels--; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - } -} -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -/* Gamma correct the image, avoiding the alpha channel. Make sure - * you do this after you deal with the transparency issue on grayscale - * or RGB images. If your bit depth is 8, use gamma_table, if it - * is 16, use gamma_16_table and gamma_shift. Build these with - * build_gamma_table(). - */ -void /* PRIVATE */ -png_do_gamma(png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, - int gamma_shift) -{ - png_bytep sp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_gamma\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - ((row_info->bit_depth <= 8 && gamma_table != NULL) || - (row_info->bit_depth == 16 && gamma_16_table != NULL))) - { - switch (row_info->color_type) - { - case PNG_COLOR_TYPE_RGB: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v; - - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - } - } - break; - } - case PNG_COLOR_TYPE_RGB_ALPHA: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - sp++; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 4; - } - } - break; - } - case PNG_COLOR_TYPE_GRAY_ALPHA: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp += 2; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 4; - } - } - break; - } - case PNG_COLOR_TYPE_GRAY: - { - if (row_info->bit_depth == 2) - { - sp = row; - for (i = 0; i < row_width; i += 4) - { - int a = *sp & 0xc0; - int b = *sp & 0x30; - int c = *sp & 0x0c; - int d = *sp & 0x03; - - *sp = (png_byte)( - ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)| - ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)| - ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)| - ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); - sp++; - } - } - if (row_info->bit_depth == 4) - { - sp = row; - for (i = 0; i < row_width; i += 2) - { - int msb = *sp & 0xf0; - int lsb = *sp & 0x0f; - - *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0) - | (((int)gamma_table[(lsb << 4) | lsb]) >> 4)); - sp++; - } - } - else if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - } - } - else if (row_info->bit_depth == 16) - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - } - } - break; - } - } - } -} -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expands a palette row to an RGB or RGBA row depending - * upon whether you supply trans and num_trans. - */ -void /* PRIVATE */ -png_do_expand_palette(png_row_infop row_info, png_bytep row, - png_colorp palette, png_bytep trans, int num_trans) -{ - int shift, value; - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_expand_palette\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (row_info->bit_depth < 8) - { - switch (row_info->bit_depth) - { - case 1: - { - sp = row + (png_size_t)((row_width - 1) >> 3); - dp = row + (png_size_t)row_width - 1; - shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - if ((*sp >> shift) & 0x01) - *dp = 1; - else - *dp = 0; - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - sp = row + (png_size_t)((row_width - 1) >> 2); - dp = row + (png_size_t)row_width - 1; - shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x03; - *dp = (png_byte)value; - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - sp = row + (png_size_t)((row_width - 1) >> 1); - dp = row + (png_size_t)row_width - 1; - shift = (int)((row_width & 0x01) << 2); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x0f; - *dp = (png_byte)value; - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift += 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - switch (row_info->bit_depth) - { - case 8: - { - if (trans != NULL) - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width << 2) - 1; - - for (i = 0; i < row_width; i++) - { - if ((int)(*sp) >= num_trans) - *dp-- = 0xff; - else - *dp-- = trans[*sp]; - *dp-- = palette[*sp].blue; - *dp-- = palette[*sp].green; - *dp-- = palette[*sp].red; - sp--; - } - row_info->bit_depth = 8; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - row_info->color_type = 6; - row_info->channels = 4; - } - else - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width * 3) - 1; - - for (i = 0; i < row_width; i++) - { - *dp-- = palette[*sp].blue; - *dp-- = palette[*sp].green; - *dp-- = palette[*sp].red; - sp--; - } - row_info->bit_depth = 8; - row_info->pixel_depth = 24; - row_info->rowbytes = row_width * 3; - row_info->color_type = 2; - row_info->channels = 3; - } - break; - } - } - } -} - -/* If the bit depth < 8, it is expanded to 8. Also, if the already - * expanded transparency value is supplied, an alpha channel is built. - */ -void /* PRIVATE */ -png_do_expand(png_row_infop row_info, png_bytep row, - png_color_16p trans_value) -{ - int shift, value; - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_expand\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0); - - if (row_info->bit_depth < 8) - { - switch (row_info->bit_depth) - { - case 1: - { - gray = (png_uint_16)(gray*0xff); - sp = row + (png_size_t)((row_width - 1) >> 3); - dp = row + (png_size_t)row_width - 1; - shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - if ((*sp >> shift) & 0x01) - *dp = 0xff; - else - *dp = 0; - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - gray = (png_uint_16)(gray*0x55); - sp = row + (png_size_t)((row_width - 1) >> 2); - dp = row + (png_size_t)row_width - 1; - shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x03; - *dp = (png_byte)(value | (value << 2) | (value << 4) | - (value << 6)); - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - gray = (png_uint_16)(gray*0x11); - sp = row + (png_size_t)((row_width - 1) >> 1); - dp = row + (png_size_t)row_width - 1; - shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x0f; - *dp = (png_byte)(value | (value << 4)); - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift = 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - - if (trans_value != NULL) - { - if (row_info->bit_depth == 8) - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width << 1) - 1; - for (i = 0; i < row_width; i++) - { - if (*sp == gray) - *dp-- = 0; - else - *dp-- = 0xff; - *dp-- = *sp--; - } - } - else if (row_info->bit_depth == 16) - { - sp = row + row_info->rowbytes - 1; - dp = row + (row_info->rowbytes << 1) - 1; - for (i = 0; i < row_width; i++) - { - if (((png_uint_16)*(sp) | - ((png_uint_16)*(sp - 1) << 8)) == gray) - { - *dp-- = 0; - *dp-- = 0; - } - else - { - *dp-- = 0xff; - *dp-- = 0xff; - } - *dp-- = *sp--; - *dp-- = *sp--; - } - } - row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA; - row_info->channels = 2; - row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_width); - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value) - { - if (row_info->bit_depth == 8) - { - sp = row + (png_size_t)row_info->rowbytes - 1; - dp = row + (png_size_t)(row_width << 2) - 1; - for (i = 0; i < row_width; i++) - { - if (*(sp - 2) == trans_value->red && - *(sp - 1) == trans_value->green && - *(sp - 0) == trans_value->blue) - *dp-- = 0; - else - *dp-- = 0xff; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - } - } - else if (row_info->bit_depth == 16) - { - sp = row + row_info->rowbytes - 1; - dp = row + (png_size_t)(row_width << 3) - 1; - for (i = 0; i < row_width; i++) - { - if ((((png_uint_16)*(sp - 4) | - ((png_uint_16)*(sp - 5) << 8)) == trans_value->red) && - (((png_uint_16)*(sp - 2) | - ((png_uint_16)*(sp - 3) << 8)) == trans_value->green) && - (((png_uint_16)*(sp - 0) | - ((png_uint_16)*(sp - 1) << 8)) == trans_value->blue)) - { - *dp-- = 0; - *dp-- = 0; - } - else - { - *dp-- = 0xff; - *dp-- = 0xff; - } - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - } - } - row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA; - row_info->channels = 4; - row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - } -} -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -void /* PRIVATE */ -png_do_dither(png_row_infop row_info, png_bytep row, - png_bytep palette_lookup, png_bytep dither_lookup) -{ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_dither\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB && - palette_lookup && row_info->bit_depth == 8) - { - int r, g, b, p; - sp = row; - dp = row; - for (i = 0; i < row_width; i++) - { - r = *sp++; - g = *sp++; - b = *sp++; - - /* this looks real messy, but the compiler will reduce - it down to a reasonable formula. For example, with - 5 bits per color, we get: - p = (((r >> 3) & 0x1f) << 10) | - (((g >> 3) & 0x1f) << 5) | - ((b >> 3) & 0x1f); - */ - p = (((r >> (8 - PNG_DITHER_RED_BITS)) & - ((1 << PNG_DITHER_RED_BITS) - 1)) << - (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | - (((g >> (8 - PNG_DITHER_GREEN_BITS)) & - ((1 << PNG_DITHER_GREEN_BITS) - 1)) << - (PNG_DITHER_BLUE_BITS)) | - ((b >> (8 - PNG_DITHER_BLUE_BITS)) & - ((1 << PNG_DITHER_BLUE_BITS) - 1)); - - *dp++ = palette_lookup[p]; - } - row_info->color_type = PNG_COLOR_TYPE_PALETTE; - row_info->channels = 1; - row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - palette_lookup != NULL && row_info->bit_depth == 8) - { - int r, g, b, p; - sp = row; - dp = row; - for (i = 0; i < row_width; i++) - { - r = *sp++; - g = *sp++; - b = *sp++; - sp++; - - p = (((r >> (8 - PNG_DITHER_RED_BITS)) & - ((1 << PNG_DITHER_RED_BITS) - 1)) << - (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | - (((g >> (8 - PNG_DITHER_GREEN_BITS)) & - ((1 << PNG_DITHER_GREEN_BITS) - 1)) << - (PNG_DITHER_BLUE_BITS)) | - ((b >> (8 - PNG_DITHER_BLUE_BITS)) & - ((1 << PNG_DITHER_BLUE_BITS) - 1)); - - *dp++ = palette_lookup[p]; - } - row_info->color_type = PNG_COLOR_TYPE_PALETTE; - row_info->channels = 1; - row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && - dither_lookup && row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - *sp = dither_lookup[*sp]; - } - } - } -} -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -#if defined(PNG_READ_GAMMA_SUPPORTED) -static int png_gamma_shift[] = - {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00}; - -/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit - * tables, we don't make a full table if we are reducing to 8-bit in - * the future. Note also how the gamma_16 tables are segmented so that - * we don't need to allocate > 64K chunks for a full 16-bit table. - */ -void /* PRIVATE */ -png_build_gamma_table(png_structp png_ptr) -{ - png_debug(1, "in png_build_gamma_table\n"); - - if (png_ptr->bit_depth <= 8) - { - int i; - double g; - - if (png_ptr->screen_gamma > .000001) - g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - else - g = 1.0; - - png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY)) - { - - g = 1.0 / (png_ptr->gamma); - - png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - } - - - png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - if(png_ptr->screen_gamma > 0.000001) - g = 1.0 / png_ptr->screen_gamma; - else - g = png_ptr->gamma; /* probably doing rgb_to_gray */ - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ - } - else - { - double g; - int i, j, shift, num; - int sig_bit; - png_uint_32 ig; - - if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit = (int)png_ptr->sig_bit.red; - if ((int)png_ptr->sig_bit.green > sig_bit) - sig_bit = png_ptr->sig_bit.green; - if ((int)png_ptr->sig_bit.blue > sig_bit) - sig_bit = png_ptr->sig_bit.blue; - } - else - { - sig_bit = (int)png_ptr->sig_bit.gray; - } - - if (sig_bit > 0) - shift = 16 - sig_bit; - else - shift = 0; - - if (png_ptr->transformations & PNG_16_TO_8) - { - if (shift < (16 - PNG_MAX_GAMMA_8)) - shift = (16 - PNG_MAX_GAMMA_8); - } - - if (shift > 8) - shift = 8; - if (shift < 0) - shift = 0; - - png_ptr->gamma_shift = (png_byte)shift; - - num = (1 << (8 - shift)); - - if (png_ptr->screen_gamma > .000001) - g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - else - g = 1.0; - - png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p))); - - if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) - { - double fin, fout; - png_uint_32 last, max; - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - } - - g = 1.0 / g; - last = 0; - for (i = 0; i < 256; i++) - { - fout = ((double)i + 0.5) / 256.0; - fin = pow(fout, g); - max = (png_uint_32)(fin * (double)((png_uint_32)num << 8)); - while (last <= max) - { - png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] - [(int)(last >> (8 - shift))] = (png_uint_16)( - (png_uint_16)i | ((png_uint_16)i << 8)); - last++; - } - } - while (last < ((png_uint_32)num << 8)) - { - png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] - [(int)(last >> (8 - shift))] = (png_uint_16)65535L; - last++; - } - } - else - { - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - - ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_table[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY)) - { - - g = 1.0 / (png_ptr->gamma); - - png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p ))); - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - - ig = (((png_uint_32)i * - (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_to_1[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - - if(png_ptr->screen_gamma > 0.000001) - g = 1.0 / png_ptr->screen_gamma; - else - g = png_ptr->gamma; /* probably doing rgb_to_gray */ - - png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p))); - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - - ig = (((png_uint_32)i * - (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_from_1[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ - } -} -#endif -/* To do: install integer version of png_build_gamma_table here */ -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -/* undoes intrapixel differencing */ -void /* PRIVATE */ -png_do_read_intrapixel(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_intrapixel\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - int bytes_per_pixel; - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 3; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 4; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - *(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff); - *(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff); - } - } - else if (row_info->bit_depth == 16) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 6; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 8; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); - png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); - png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); - png_uint_32 red = (png_uint_32)((s0+s1+65536L) & 0xffffL); - png_uint_32 blue = (png_uint_32)((s2+s1+65536L) & 0xffffL); - *(rp ) = (png_byte)((red >> 8) & 0xff); - *(rp+1) = (png_byte)(red & 0xff); - *(rp+4) = (png_byte)((blue >> 8) & 0xff); - *(rp+5) = (png_byte)(blue & 0xff); - } - } - } -} -#endif /* PNG_MNG_FEATURES_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED */ + +/* pngrtran.c - transforms the data in a row for PNG readers + * + * Last changed in libpng 1.2.15 January 5, 2007 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This file contains functions optionally called by an application + * in order to tell libpng how to handle data when reading a PNG. + * Transformations that are used in both reading and writing are + * in pngtrans.c. + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_READ_SUPPORTED) + +/* Set the action on getting a CRC error for an ancillary or critical chunk. */ +void PNGAPI +png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) +{ + png_debug(1, "in png_set_crc_action\n"); + /* Tell libpng how we react to CRC errors in critical chunks */ + if(png_ptr == NULL) return; + switch (crit_action) + { + case PNG_CRC_NO_CHANGE: /* leave setting as is */ + break; + case PNG_CRC_WARN_USE: /* warn/use data */ + png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; + png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; + break; + case PNG_CRC_QUIET_USE: /* quiet/use data */ + png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; + png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | + PNG_FLAG_CRC_CRITICAL_IGNORE; + break; + case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */ + png_warning(png_ptr, "Can't discard critical data on CRC error."); + case PNG_CRC_ERROR_QUIT: /* error/quit */ + case PNG_CRC_DEFAULT: + default: + png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; + break; + } + + switch (ancil_action) + { + case PNG_CRC_NO_CHANGE: /* leave setting as is */ + break; + case PNG_CRC_WARN_USE: /* warn/use data */ + png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; + png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; + break; + case PNG_CRC_QUIET_USE: /* quiet/use data */ + png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; + png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | + PNG_FLAG_CRC_ANCILLARY_NOWARN; + break; + case PNG_CRC_ERROR_QUIT: /* error/quit */ + png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; + png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; + break; + case PNG_CRC_WARN_DISCARD: /* warn/discard data */ + case PNG_CRC_DEFAULT: + default: + png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; + break; + } +} + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ + defined(PNG_FLOATING_POINT_SUPPORTED) +/* handle alpha and tRNS via a background color */ +void PNGAPI +png_set_background(png_structp png_ptr, + png_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma) +{ + png_debug(1, "in png_set_background\n"); + if(png_ptr == NULL) return; + if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) + { + png_warning(png_ptr, "Application must supply a known background gamma"); + return; + } + + png_ptr->transformations |= PNG_BACKGROUND; + png_memcpy(&(png_ptr->background), background_color, + png_sizeof(png_color_16)); + png_ptr->background_gamma = (float)background_gamma; + png_ptr->background_gamma_type = (png_byte)(background_gamma_code); + png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0); +} +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +/* strip 16 bit depth files to 8 bit depth */ +void PNGAPI +png_set_strip_16(png_structp png_ptr) +{ + png_debug(1, "in png_set_strip_16\n"); + if(png_ptr == NULL) return; + png_ptr->transformations |= PNG_16_TO_8; +} +#endif + +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +void PNGAPI +png_set_strip_alpha(png_structp png_ptr) +{ + png_debug(1, "in png_set_strip_alpha\n"); + if(png_ptr == NULL) return; + png_ptr->flags |= PNG_FLAG_STRIP_ALPHA; +} +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +/* Dither file to 8 bit. Supply a palette, the current number + * of elements in the palette, the maximum number of elements + * allowed, and a histogram if possible. If the current number + * of colors is greater then the maximum number, the palette will be + * modified to fit in the maximum number. "full_dither" indicates + * whether we need a dithering cube set up for RGB images, or if we + * simply are reducing the number of colors in a paletted image. + */ + +typedef struct png_dsort_struct +{ + struct png_dsort_struct FAR * next; + png_byte left; + png_byte right; +} png_dsort; +typedef png_dsort FAR * png_dsortp; +typedef png_dsort FAR * FAR * png_dsortpp; + +void PNGAPI +png_set_dither(png_structp png_ptr, png_colorp palette, + int num_palette, int maximum_colors, png_uint_16p histogram, + int full_dither) +{ + png_debug(1, "in png_set_dither\n"); + if(png_ptr == NULL) return; + png_ptr->transformations |= PNG_DITHER; + + if (!full_dither) + { + int i; + + png_ptr->dither_index = (png_bytep)png_malloc(png_ptr, + (png_uint_32)(num_palette * png_sizeof (png_byte))); + for (i = 0; i < num_palette; i++) + png_ptr->dither_index[i] = (png_byte)i; + } + + if (num_palette > maximum_colors) + { + if (histogram != NULL) + { + /* This is easy enough, just throw out the least used colors. + Perhaps not the best solution, but good enough. */ + + int i; + + /* initialize an array to sort colors */ + png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr, + (png_uint_32)(num_palette * png_sizeof (png_byte))); + + /* initialize the dither_sort array */ + for (i = 0; i < num_palette; i++) + png_ptr->dither_sort[i] = (png_byte)i; + + /* Find the least used palette entries by starting a + bubble sort, and running it until we have sorted + out enough colors. Note that we don't care about + sorting all the colors, just finding which are + least used. */ + + for (i = num_palette - 1; i >= maximum_colors; i--) + { + int done; /* to stop early if the list is pre-sorted */ + int j; + + done = 1; + for (j = 0; j < i; j++) + { + if (histogram[png_ptr->dither_sort[j]] + < histogram[png_ptr->dither_sort[j + 1]]) + { + png_byte t; + + t = png_ptr->dither_sort[j]; + png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1]; + png_ptr->dither_sort[j + 1] = t; + done = 0; + } + } + if (done) + break; + } + + /* swap the palette around, and set up a table, if necessary */ + if (full_dither) + { + int j = num_palette; + + /* put all the useful colors within the max, but don't + move the others */ + for (i = 0; i < maximum_colors; i++) + { + if ((int)png_ptr->dither_sort[i] >= maximum_colors) + { + do + j--; + while ((int)png_ptr->dither_sort[j] >= maximum_colors); + palette[i] = palette[j]; + } + } + } + else + { + int j = num_palette; + + /* move all the used colors inside the max limit, and + develop a translation table */ + for (i = 0; i < maximum_colors; i++) + { + /* only move the colors we need to */ + if ((int)png_ptr->dither_sort[i] >= maximum_colors) + { + png_color tmp_color; + + do + j--; + while ((int)png_ptr->dither_sort[j] >= maximum_colors); + + tmp_color = palette[j]; + palette[j] = palette[i]; + palette[i] = tmp_color; + /* indicate where the color went */ + png_ptr->dither_index[j] = (png_byte)i; + png_ptr->dither_index[i] = (png_byte)j; + } + } + + /* find closest color for those colors we are not using */ + for (i = 0; i < num_palette; i++) + { + if ((int)png_ptr->dither_index[i] >= maximum_colors) + { + int min_d, k, min_k, d_index; + + /* find the closest color to one we threw out */ + d_index = png_ptr->dither_index[i]; + min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); + for (k = 1, min_k = 0; k < maximum_colors; k++) + { + int d; + + d = PNG_COLOR_DIST(palette[d_index], palette[k]); + + if (d < min_d) + { + min_d = d; + min_k = k; + } + } + /* point to closest color */ + png_ptr->dither_index[i] = (png_byte)min_k; + } + } + } + png_free(png_ptr, png_ptr->dither_sort); + png_ptr->dither_sort=NULL; + } + else + { + /* This is much harder to do simply (and quickly). Perhaps + we need to go through a median cut routine, but those + don't always behave themselves with only a few colors + as input. So we will just find the closest two colors, + and throw out one of them (chosen somewhat randomly). + [We don't understand this at all, so if someone wants to + work on improving it, be our guest - AED, GRP] + */ + int i; + int max_d; + int num_new_palette; + png_dsortp t; + png_dsortpp hash; + + t=NULL; + + /* initialize palette index arrays */ + png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, + (png_uint_32)(num_palette * png_sizeof (png_byte))); + png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, + (png_uint_32)(num_palette * png_sizeof (png_byte))); + + /* initialize the sort array */ + for (i = 0; i < num_palette; i++) + { + png_ptr->index_to_palette[i] = (png_byte)i; + png_ptr->palette_to_index[i] = (png_byte)i; + } + + hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 * + png_sizeof (png_dsortp))); + for (i = 0; i < 769; i++) + hash[i] = NULL; +/* png_memset(hash, 0, 769 * png_sizeof (png_dsortp)); */ + + num_new_palette = num_palette; + + /* initial wild guess at how far apart the farthest pixel + pair we will be eliminating will be. Larger + numbers mean more areas will be allocated, Smaller + numbers run the risk of not saving enough data, and + having to do this all over again. + + I have not done extensive checking on this number. + */ + max_d = 96; + + while (num_new_palette > maximum_colors) + { + for (i = 0; i < num_new_palette - 1; i++) + { + int j; + + for (j = i + 1; j < num_new_palette; j++) + { + int d; + + d = PNG_COLOR_DIST(palette[i], palette[j]); + + if (d <= max_d) + { + + t = (png_dsortp)png_malloc_warn(png_ptr, + (png_uint_32)(png_sizeof(png_dsort))); + if (t == NULL) + break; + t->next = hash[d]; + t->left = (png_byte)i; + t->right = (png_byte)j; + hash[d] = t; + } + } + if (t == NULL) + break; + } + + if (t != NULL) + for (i = 0; i <= max_d; i++) + { + if (hash[i] != NULL) + { + png_dsortp p; + + for (p = hash[i]; p; p = p->next) + { + if ((int)png_ptr->index_to_palette[p->left] + < num_new_palette && + (int)png_ptr->index_to_palette[p->right] + < num_new_palette) + { + int j, next_j; + + if (num_new_palette & 0x01) + { + j = p->left; + next_j = p->right; + } + else + { + j = p->right; + next_j = p->left; + } + + num_new_palette--; + palette[png_ptr->index_to_palette[j]] + = palette[num_new_palette]; + if (!full_dither) + { + int k; + + for (k = 0; k < num_palette; k++) + { + if (png_ptr->dither_index[k] == + png_ptr->index_to_palette[j]) + png_ptr->dither_index[k] = + png_ptr->index_to_palette[next_j]; + if ((int)png_ptr->dither_index[k] == + num_new_palette) + png_ptr->dither_index[k] = + png_ptr->index_to_palette[j]; + } + } + + png_ptr->index_to_palette[png_ptr->palette_to_index + [num_new_palette]] = png_ptr->index_to_palette[j]; + png_ptr->palette_to_index[png_ptr->index_to_palette[j]] + = png_ptr->palette_to_index[num_new_palette]; + + png_ptr->index_to_palette[j] = (png_byte)num_new_palette; + png_ptr->palette_to_index[num_new_palette] = (png_byte)j; + } + if (num_new_palette <= maximum_colors) + break; + } + if (num_new_palette <= maximum_colors) + break; + } + } + + for (i = 0; i < 769; i++) + { + if (hash[i] != NULL) + { + png_dsortp p = hash[i]; + while (p) + { + t = p->next; + png_free(png_ptr, p); + p = t; + } + } + hash[i] = 0; + } + max_d += 96; + } + png_free(png_ptr, hash); + png_free(png_ptr, png_ptr->palette_to_index); + png_free(png_ptr, png_ptr->index_to_palette); + png_ptr->palette_to_index=NULL; + png_ptr->index_to_palette=NULL; + } + num_palette = maximum_colors; + } + if (png_ptr->palette == NULL) + { + png_ptr->palette = palette; + } + png_ptr->num_palette = (png_uint_16)num_palette; + + if (full_dither) + { + int i; + png_bytep distance; + int total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS + + PNG_DITHER_BLUE_BITS; + int num_red = (1 << PNG_DITHER_RED_BITS); + int num_green = (1 << PNG_DITHER_GREEN_BITS); + int num_blue = (1 << PNG_DITHER_BLUE_BITS); + png_size_t num_entries = ((png_size_t)1 << total_bits); + + png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr, + (png_uint_32)(num_entries * png_sizeof (png_byte))); + + png_memset(png_ptr->palette_lookup, 0, num_entries * + png_sizeof (png_byte)); + + distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * + png_sizeof(png_byte))); + + png_memset(distance, 0xff, num_entries * png_sizeof(png_byte)); + + for (i = 0; i < num_palette; i++) + { + int ir, ig, ib; + int r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS)); + int g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS)); + int b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS)); + + for (ir = 0; ir < num_red; ir++) + { + /* int dr = abs(ir - r); */ + int dr = ((ir > r) ? ir - r : r - ir); + int index_r = (ir << (PNG_DITHER_BLUE_BITS + PNG_DITHER_GREEN_BITS)); + + for (ig = 0; ig < num_green; ig++) + { + /* int dg = abs(ig - g); */ + int dg = ((ig > g) ? ig - g : g - ig); + int dt = dr + dg; + int dm = ((dr > dg) ? dr : dg); + int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS); + + for (ib = 0; ib < num_blue; ib++) + { + int d_index = index_g | ib; + /* int db = abs(ib - b); */ + int db = ((ib > b) ? ib - b : b - ib); + int dmax = ((dm > db) ? dm : db); + int d = dmax + dt + db; + + if (d < (int)distance[d_index]) + { + distance[d_index] = (png_byte)d; + png_ptr->palette_lookup[d_index] = (png_byte)i; + } + } + } + } + } + + png_free(png_ptr, distance); + } +} +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) +/* Transform the image from the file_gamma to the screen_gamma. We + * only do transformations on images where the file_gamma and screen_gamma + * are not close reciprocals, otherwise it slows things down slightly, and + * also needlessly introduces small errors. + * + * We will turn off gamma transformation later if no semitransparent entries + * are present in the tRNS array for palette images. We can't do it here + * because we don't necessarily have the tRNS chunk yet. + */ +void PNGAPI +png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) +{ + png_debug(1, "in png_set_gamma\n"); + if(png_ptr == NULL) return; + if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) || + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) + png_ptr->transformations |= PNG_GAMMA; + png_ptr->gamma = (float)file_gamma; + png_ptr->screen_gamma = (float)scrn_gamma; +} +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) +/* Expand paletted images to RGB, expand grayscale images of + * less than 8-bit depth to 8-bit depth, and expand tRNS chunks + * to alpha channels. + */ +void PNGAPI +png_set_expand(png_structp png_ptr) +{ + png_debug(1, "in png_set_expand\n"); + if(png_ptr == NULL) return; + png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); +} + +/* GRR 19990627: the following three functions currently are identical + * to png_set_expand(). However, it is entirely reasonable that someone + * might wish to expand an indexed image to RGB but *not* expand a single, + * fully transparent palette entry to a full alpha channel--perhaps instead + * convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace + * the transparent color with a particular RGB value, or drop tRNS entirely. + * IOW, a future version of the library may make the transformations flag + * a bit more fine-grained, with separate bits for each of these three + * functions. + * + * More to the point, these functions make it obvious what libpng will be + * doing, whereas "expand" can (and does) mean any number of things. + * + * GRP 20060307: In libpng-1.4.0, png_set_gray_1_2_4_to_8() was modified + * to expand only the sample depth but not to expand the tRNS to alpha. + */ + +/* Expand paletted images to RGB. */ +void PNGAPI +png_set_palette_to_rgb(png_structp png_ptr) +{ + png_debug(1, "in png_set_palette_to_rgb\n"); + if(png_ptr == NULL) return; + png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); +} + +#if !defined(PNG_1_0_X) +/* Expand grayscale images of less than 8-bit depth to 8 bits. */ +void PNGAPI +png_set_expand_gray_1_2_4_to_8(png_structp png_ptr) +{ + png_debug(1, "in png_set_expand_gray_1_2_4_to_8\n"); + if(png_ptr == NULL) return; + png_ptr->transformations |= PNG_EXPAND_tRNS; +} +#endif + +#if defined(PNG_1_0_X) || defined(PNG_1_2_X) +/* Expand grayscale images of less than 8-bit depth to 8 bits. */ +/* Deprecated as of libpng-1.2.9 */ +void PNGAPI +png_set_gray_1_2_4_to_8(png_structp png_ptr) +{ + png_debug(1, "in png_set_gray_1_2_4_to_8\n"); + if(png_ptr == NULL) return; + png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); +} +#endif + + +/* Expand tRNS chunks to alpha channels. */ +void PNGAPI +png_set_tRNS_to_alpha(png_structp png_ptr) +{ + png_debug(1, "in png_set_expand\n"); + png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); +} +#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */ + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +void PNGAPI +png_set_gray_to_rgb(png_structp png_ptr) +{ + png_debug(1, "in png_set_gray_to_rgb\n"); + png_ptr->transformations |= PNG_GRAY_TO_RGB; +} +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +#if defined(PNG_FLOATING_POINT_SUPPORTED) +/* Convert a RGB image to a grayscale of the same width. This allows us, + * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. + */ + +void PNGAPI +png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, + double green) +{ + int red_fixed = (int)((float)red*100000.0 + 0.5); + int green_fixed = (int)((float)green*100000.0 + 0.5); + if(png_ptr == NULL) return; + png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); +} +#endif + +void PNGAPI +png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, + png_fixed_point red, png_fixed_point green) +{ + png_debug(1, "in png_set_rgb_to_gray\n"); + if(png_ptr == NULL) return; + switch(error_action) + { + case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; + break; + case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; + break; + case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; + } + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) +#if defined(PNG_READ_EXPAND_SUPPORTED) + png_ptr->transformations |= PNG_EXPAND; +#else + { + png_warning(png_ptr, "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); + png_ptr->transformations &= ~PNG_RGB_TO_GRAY; + } +#endif + { + png_uint_16 red_int, green_int; + if(red < 0 || green < 0) + { + red_int = 6968; /* .212671 * 32768 + .5 */ + green_int = 23434; /* .715160 * 32768 + .5 */ + } + else if(red + green < 100000L) + { + red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L); + green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L); + } + else + { + png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients"); + red_int = 6968; + green_int = 23434; + } + png_ptr->rgb_to_gray_red_coeff = red_int; + png_ptr->rgb_to_gray_green_coeff = green_int; + png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int); + } +} +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +void PNGAPI +png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr + read_user_transform_fn) +{ + png_debug(1, "in png_set_read_user_transform_fn\n"); + if(png_ptr == NULL) return; +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + png_ptr->transformations |= PNG_USER_TRANSFORM; + png_ptr->read_user_transform_fn = read_user_transform_fn; +#endif +#ifdef PNG_LEGACY_SUPPORTED + if(read_user_transform_fn) + png_warning(png_ptr, + "This version of libpng does not support user transforms"); +#endif +} +#endif + +/* Initialize everything needed for the read. This includes modifying + * the palette. + */ +void /* PRIVATE */ +png_init_read_transformations(png_structp png_ptr) +{ + png_debug(1, "in png_init_read_transformations\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if(png_ptr != NULL) +#endif + { +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \ + || defined(PNG_READ_GAMMA_SUPPORTED) + int color_type = png_ptr->color_type; +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) + /* Detect gray background and attempt to enable optimization + * for gray --> RGB case */ + /* Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or + * RGB_ALPHA (in which case need_expand is superfluous anyway), the + * background color might actually be gray yet not be flagged as such. + * This is not a problem for the current code, which uses + * PNG_BACKGROUND_IS_GRAY only to decide when to do the + * png_do_gray_to_rgb() transformation. + */ + if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && + !(color_type & PNG_COLOR_MASK_COLOR)) + { + png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; + } else if ((png_ptr->transformations & PNG_BACKGROUND) && + !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) && + (png_ptr->transformations & PNG_GRAY_TO_RGB) && + png_ptr->background.red == png_ptr->background.green && + png_ptr->background.red == png_ptr->background.blue) + { + png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; + png_ptr->background.gray = png_ptr->background.red; + } +#endif + + if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && + (png_ptr->transformations & PNG_EXPAND)) + { + if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */ + { + /* expand background and tRNS chunks */ + switch (png_ptr->bit_depth) + { + case 1: + png_ptr->background.gray *= (png_uint_16)0xff; + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; + if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) + { + png_ptr->trans_values.gray *= (png_uint_16)0xff; + png_ptr->trans_values.red = png_ptr->trans_values.green + = png_ptr->trans_values.blue = png_ptr->trans_values.gray; + } + break; + case 2: + png_ptr->background.gray *= (png_uint_16)0x55; + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; + if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) + { + png_ptr->trans_values.gray *= (png_uint_16)0x55; + png_ptr->trans_values.red = png_ptr->trans_values.green + = png_ptr->trans_values.blue = png_ptr->trans_values.gray; + } + break; + case 4: + png_ptr->background.gray *= (png_uint_16)0x11; + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; + if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) + { + png_ptr->trans_values.gray *= (png_uint_16)0x11; + png_ptr->trans_values.red = png_ptr->trans_values.green + = png_ptr->trans_values.blue = png_ptr->trans_values.gray; + } + break; + case 8: + case 16: + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; + break; + } + } + else if (color_type == PNG_COLOR_TYPE_PALETTE) + { + png_ptr->background.red = + png_ptr->palette[png_ptr->background.index].red; + png_ptr->background.green = + png_ptr->palette[png_ptr->background.index].green; + png_ptr->background.blue = + png_ptr->palette[png_ptr->background.index].blue; + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) + if (png_ptr->transformations & PNG_INVERT_ALPHA) + { +#if defined(PNG_READ_EXPAND_SUPPORTED) + if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) +#endif + { + /* invert the alpha channel (in tRNS) unless the pixels are + going to be expanded, in which case leave it for later */ + int i,istop; + istop=(int)png_ptr->num_trans; + for (i=0; itrans[i] = (png_byte)(255 - png_ptr->trans[i]); + } + } +#endif + + } + } +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) + png_ptr->background_1 = png_ptr->background; +#endif +#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) + + if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0) + && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0) + < PNG_GAMMA_THRESHOLD)) + { + int i,k; + k=0; + for (i=0; inum_trans; i++) + { + if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff) + k=1; /* partial transparency is present */ + } + if (k == 0) + png_ptr->transformations &= (~PNG_GAMMA); + } + + if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) && + png_ptr->gamma != 0.0) + { + png_build_gamma_table(png_ptr); +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->transformations & PNG_BACKGROUND) + { + if (color_type == PNG_COLOR_TYPE_PALETTE) + { + /* could skip if no transparency and + */ + png_color back, back_1; + png_colorp palette = png_ptr->palette; + int num_palette = png_ptr->num_palette; + int i; + if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) + { + back.red = png_ptr->gamma_table[png_ptr->background.red]; + back.green = png_ptr->gamma_table[png_ptr->background.green]; + back.blue = png_ptr->gamma_table[png_ptr->background.blue]; + + back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; + back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; + back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; + } + else + { + double g, gs; + + switch (png_ptr->background_gamma_type) + { + case PNG_BACKGROUND_GAMMA_SCREEN: + g = (png_ptr->screen_gamma); + gs = 1.0; + break; + case PNG_BACKGROUND_GAMMA_FILE: + g = 1.0 / (png_ptr->gamma); + gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + break; + case PNG_BACKGROUND_GAMMA_UNIQUE: + g = 1.0 / (png_ptr->background_gamma); + gs = 1.0 / (png_ptr->background_gamma * + png_ptr->screen_gamma); + break; + default: + g = 1.0; /* back_1 */ + gs = 1.0; /* back */ + } + + if ( fabs(gs - 1.0) < PNG_GAMMA_THRESHOLD) + { + back.red = (png_byte)png_ptr->background.red; + back.green = (png_byte)png_ptr->background.green; + back.blue = (png_byte)png_ptr->background.blue; + } + else + { + back.red = (png_byte)(pow( + (double)png_ptr->background.red/255, gs) * 255.0 + .5); + back.green = (png_byte)(pow( + (double)png_ptr->background.green/255, gs) * 255.0 + .5); + back.blue = (png_byte)(pow( + (double)png_ptr->background.blue/255, gs) * 255.0 + .5); + } + + back_1.red = (png_byte)(pow( + (double)png_ptr->background.red/255, g) * 255.0 + .5); + back_1.green = (png_byte)(pow( + (double)png_ptr->background.green/255, g) * 255.0 + .5); + back_1.blue = (png_byte)(pow( + (double)png_ptr->background.blue/255, g) * 255.0 + .5); + } + for (i = 0; i < num_palette; i++) + { + if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff) + { + if (png_ptr->trans[i] == 0) + { + palette[i] = back; + } + else /* if (png_ptr->trans[i] != 0xff) */ + { + png_byte v, w; + + v = png_ptr->gamma_to_1[palette[i].red]; + png_composite(w, v, png_ptr->trans[i], back_1.red); + palette[i].red = png_ptr->gamma_from_1[w]; + + v = png_ptr->gamma_to_1[palette[i].green]; + png_composite(w, v, png_ptr->trans[i], back_1.green); + palette[i].green = png_ptr->gamma_from_1[w]; + + v = png_ptr->gamma_to_1[palette[i].blue]; + png_composite(w, v, png_ptr->trans[i], back_1.blue); + palette[i].blue = png_ptr->gamma_from_1[w]; + } + } + else + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + } + } + /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */ + else + /* color_type != PNG_COLOR_TYPE_PALETTE */ + { + double m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1); + double g = 1.0; + double gs = 1.0; + + switch (png_ptr->background_gamma_type) + { + case PNG_BACKGROUND_GAMMA_SCREEN: + g = (png_ptr->screen_gamma); + gs = 1.0; + break; + case PNG_BACKGROUND_GAMMA_FILE: + g = 1.0 / (png_ptr->gamma); + gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + break; + case PNG_BACKGROUND_GAMMA_UNIQUE: + g = 1.0 / (png_ptr->background_gamma); + gs = 1.0 / (png_ptr->background_gamma * + png_ptr->screen_gamma); + break; + } + + png_ptr->background_1.gray = (png_uint_16)(pow( + (double)png_ptr->background.gray / m, g) * m + .5); + png_ptr->background.gray = (png_uint_16)(pow( + (double)png_ptr->background.gray / m, gs) * m + .5); + + if ((png_ptr->background.red != png_ptr->background.green) || + (png_ptr->background.red != png_ptr->background.blue) || + (png_ptr->background.red != png_ptr->background.gray)) + { + /* RGB or RGBA with color background */ + png_ptr->background_1.red = (png_uint_16)(pow( + (double)png_ptr->background.red / m, g) * m + .5); + png_ptr->background_1.green = (png_uint_16)(pow( + (double)png_ptr->background.green / m, g) * m + .5); + png_ptr->background_1.blue = (png_uint_16)(pow( + (double)png_ptr->background.blue / m, g) * m + .5); + png_ptr->background.red = (png_uint_16)(pow( + (double)png_ptr->background.red / m, gs) * m + .5); + png_ptr->background.green = (png_uint_16)(pow( + (double)png_ptr->background.green / m, gs) * m + .5); + png_ptr->background.blue = (png_uint_16)(pow( + (double)png_ptr->background.blue / m, gs) * m + .5); + } + else + { + /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */ + png_ptr->background_1.red = png_ptr->background_1.green + = png_ptr->background_1.blue = png_ptr->background_1.gray; + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; + } + } + } + else + /* transformation does not include PNG_BACKGROUND */ +#endif /* PNG_READ_BACKGROUND_SUPPORTED */ + if (color_type == PNG_COLOR_TYPE_PALETTE) + { + png_colorp palette = png_ptr->palette; + int num_palette = png_ptr->num_palette; + int i; + + for (i = 0; i < num_palette; i++) + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + } + } +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + else +#endif +#endif /* PNG_READ_GAMMA_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */ +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + /* No GAMMA transformation */ + if ((png_ptr->transformations & PNG_BACKGROUND) && + (color_type == PNG_COLOR_TYPE_PALETTE)) + { + int i; + int istop = (int)png_ptr->num_trans; + png_color back; + png_colorp palette = png_ptr->palette; + + back.red = (png_byte)png_ptr->background.red; + back.green = (png_byte)png_ptr->background.green; + back.blue = (png_byte)png_ptr->background.blue; + + for (i = 0; i < istop; i++) + { + if (png_ptr->trans[i] == 0) + { + palette[i] = back; + } + else if (png_ptr->trans[i] != 0xff) + { + /* The png_composite() macro is defined in png.h */ + png_composite(palette[i].red, palette[i].red, + png_ptr->trans[i], back.red); + png_composite(palette[i].green, palette[i].green, + png_ptr->trans[i], back.green); + png_composite(palette[i].blue, palette[i].blue, + png_ptr->trans[i], back.blue); + } + } + } +#endif /* PNG_READ_BACKGROUND_SUPPORTED */ + +#if defined(PNG_READ_SHIFT_SUPPORTED) + if ((png_ptr->transformations & PNG_SHIFT) && + (color_type == PNG_COLOR_TYPE_PALETTE)) + { + png_uint_16 i; + png_uint_16 istop = png_ptr->num_palette; + int sr = 8 - png_ptr->sig_bit.red; + int sg = 8 - png_ptr->sig_bit.green; + int sb = 8 - png_ptr->sig_bit.blue; + + if (sr < 0 || sr > 8) + sr = 0; + if (sg < 0 || sg > 8) + sg = 0; + if (sb < 0 || sb > 8) + sb = 0; + for (i = 0; i < istop; i++) + { + png_ptr->palette[i].red >>= sr; + png_ptr->palette[i].green >>= sg; + png_ptr->palette[i].blue >>= sb; + } + } +#endif /* PNG_READ_SHIFT_SUPPORTED */ + } +#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ + && !defined(PNG_READ_BACKGROUND_SUPPORTED) + if(png_ptr) + return; +#endif +} + +/* Modify the info structure to reflect the transformations. The + * info should be updated so a PNG file could be written with it, + * assuming the transformations result in valid PNG data. + */ +void /* PRIVATE */ +png_read_transform_info(png_structp png_ptr, png_infop info_ptr) +{ + png_debug(1, "in png_read_transform_info\n"); +#if defined(PNG_READ_EXPAND_SUPPORTED) + if (png_ptr->transformations & PNG_EXPAND) + { + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS)) + info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA; + else + info_ptr->color_type = PNG_COLOR_TYPE_RGB; + info_ptr->bit_depth = 8; + info_ptr->num_trans = 0; + } + else + { + if (png_ptr->num_trans) + { + if (png_ptr->transformations & PNG_EXPAND_tRNS) + info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; + else + info_ptr->color_type |= PNG_COLOR_MASK_COLOR; + } + if (info_ptr->bit_depth < 8) + info_ptr->bit_depth = 8; + info_ptr->num_trans = 0; + } + } +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->transformations & PNG_BACKGROUND) + { + info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; + info_ptr->num_trans = 0; + info_ptr->background = png_ptr->background; + } +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (png_ptr->transformations & PNG_GAMMA) + { +#ifdef PNG_FLOATING_POINT_SUPPORTED + info_ptr->gamma = png_ptr->gamma; +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + info_ptr->int_gamma = png_ptr->int_gamma; +#endif + } +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) + if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16)) + info_ptr->bit_depth = 8; +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) + if (png_ptr->transformations & PNG_GRAY_TO_RGB) + info_ptr->color_type |= PNG_COLOR_MASK_COLOR; +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & PNG_RGB_TO_GRAY) + info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR; +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) + if (png_ptr->transformations & PNG_DITHER) + { + if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || + (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && + png_ptr->palette_lookup && info_ptr->bit_depth == 8) + { + info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; + } + } +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) + if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8)) + info_ptr->bit_depth = 8; +#endif + + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + info_ptr->channels = 1; + else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) + info_ptr->channels = 3; + else + info_ptr->channels = 1; + +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) + if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) + info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; +#endif + + if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) + info_ptr->channels++; + +#if defined(PNG_READ_FILLER_SUPPORTED) + /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */ + if ((png_ptr->transformations & PNG_FILLER) && + ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || + (info_ptr->color_type == PNG_COLOR_TYPE_GRAY))) + { + info_ptr->channels++; + /* if adding a true alpha channel not just filler */ +#if !defined(PNG_1_0_X) + if (png_ptr->transformations & PNG_ADD_ALPHA) + info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; +#endif + } +#endif + +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ +defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + if(png_ptr->transformations & PNG_USER_TRANSFORM) + { + if(info_ptr->bit_depth < png_ptr->user_transform_depth) + info_ptr->bit_depth = png_ptr->user_transform_depth; + if(info_ptr->channels < png_ptr->user_transform_channels) + info_ptr->channels = png_ptr->user_transform_channels; + } +#endif + + info_ptr->pixel_depth = (png_byte)(info_ptr->channels * + info_ptr->bit_depth); + + info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,info_ptr->width); + +#if !defined(PNG_READ_EXPAND_SUPPORTED) + if(png_ptr) + return; +#endif +} + +/* Transform the row. The order of transformations is significant, + * and is very touchy. If you add a transformation, take care to + * decide how it fits in with the other transformations here. + */ +void /* PRIVATE */ +png_do_read_transformations(png_structp png_ptr) +{ + png_debug(1, "in png_do_read_transformations\n"); +#if !defined(PNG_USELESS_TESTS_SUPPORTED) + if (png_ptr->row_buf == NULL) + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char msg[50]; + + sprintf(msg, "NULL row buffer for row %ld, pass %d", png_ptr->row_number, + png_ptr->pass); + png_error(png_ptr, msg); +#else + png_error(png_ptr, "NULL row buffer"); +#endif + } +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) + if (png_ptr->transformations & PNG_EXPAND) + { + if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE) + { + png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1, + png_ptr->palette, png_ptr->trans, png_ptr->num_trans); + } + else + { + if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS)) + png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, + &(png_ptr->trans_values)); + else + png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, + NULL); + } + } +#endif + +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) + if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) + png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, + PNG_FLAG_FILLER_AFTER | (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & PNG_RGB_TO_GRAY) + { + int rgb_error = + png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1); + if(rgb_error) + { + png_ptr->rgb_to_gray_status=1; + if(png_ptr->transformations == PNG_RGB_TO_GRAY_WARN) + png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); + if(png_ptr->transformations == PNG_RGB_TO_GRAY_ERR) + png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); + } + } +#endif + +/* +From Andreas Dilger e-mail to png-implement, 26 March 1998: + + In most cases, the "simple transparency" should be done prior to doing + gray-to-RGB, or you will have to test 3x as many bytes to check if a + pixel is transparent. You would also need to make sure that the + transparency information is upgraded to RGB. + + To summarize, the current flow is: + - Gray + simple transparency -> compare 1 or 2 gray bytes and composite + with background "in place" if transparent, + convert to RGB if necessary + - Gray + alpha -> composite with gray background and remove alpha bytes, + convert to RGB if necessary + + To support RGB backgrounds for gray images we need: + - Gray + simple transparency -> convert to RGB + simple transparency, compare + 3 or 6 bytes and composite with background + "in place" if transparent (3x compare/pixel + compared to doing composite with gray bkgrnd) + - Gray + alpha -> convert to RGB + alpha, composite with background and + remove alpha bytes (3x float operations/pixel + compared with composite on gray background) + + Greg's change will do this. The reason it wasn't done before is for + performance, as this increases the per-pixel operations. If we would check + in advance if the background was gray or RGB, and position the gray-to-RGB + transform appropriately, then it would save a lot of work/time. + */ + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) + /* if gray -> RGB, do so now only if background is non-gray; else do later + * for performance reasons */ + if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && + !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) + png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if ((png_ptr->transformations & PNG_BACKGROUND) && + ((png_ptr->num_trans != 0 ) || + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) + png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, + &(png_ptr->trans_values), &(png_ptr->background) +#if defined(PNG_READ_GAMMA_SUPPORTED) + , &(png_ptr->background_1), + png_ptr->gamma_table, png_ptr->gamma_from_1, + png_ptr->gamma_to_1, png_ptr->gamma_16_table, + png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1, + png_ptr->gamma_shift +#endif +); +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) + if ((png_ptr->transformations & PNG_GAMMA) && +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + !((png_ptr->transformations & PNG_BACKGROUND) && + ((png_ptr->num_trans != 0) || + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && +#endif + (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) + png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1, + png_ptr->gamma_table, png_ptr->gamma_16_table, + png_ptr->gamma_shift); +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) + if (png_ptr->transformations & PNG_16_TO_8) + png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) + if (png_ptr->transformations & PNG_DITHER) + { + png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, + png_ptr->palette_lookup, png_ptr->dither_index); + if(png_ptr->row_info.rowbytes == (png_uint_32)0) + png_error(png_ptr, "png_do_dither returned rowbytes=0"); + } +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) + if (png_ptr->transformations & PNG_INVERT_MONO) + png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) + if (png_ptr->transformations & PNG_SHIFT) + png_do_unshift(&(png_ptr->row_info), png_ptr->row_buf + 1, + &(png_ptr->shift)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) + if (png_ptr->transformations & PNG_PACK) + png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) + if (png_ptr->transformations & PNG_BGR) + png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) + /* if gray -> RGB, do so now only if we did not do so above */ + if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && + (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) + png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) + if (png_ptr->transformations & PNG_FILLER) + png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, + (png_uint_32)png_ptr->filler, png_ptr->flags); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) + if (png_ptr->transformations & PNG_INVERT_ALPHA) + png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) + if (png_ptr->transformations & PNG_SWAP_ALPHA) + png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) + if (png_ptr->transformations & PNG_SWAP_BYTES) + png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + if (png_ptr->transformations & PNG_USER_TRANSFORM) + { + if(png_ptr->read_user_transform_fn != NULL) + (*(png_ptr->read_user_transform_fn)) /* user read transform function */ + (png_ptr, /* png_ptr */ + &(png_ptr->row_info), /* row_info: */ + /* png_uint_32 width; width of row */ + /* png_uint_32 rowbytes; number of bytes in row */ + /* png_byte color_type; color type of pixels */ + /* png_byte bit_depth; bit depth of samples */ + /* png_byte channels; number of channels (1-4) */ + /* png_byte pixel_depth; bits per pixel (depth*channels) */ + png_ptr->row_buf + 1); /* start of pixel data for row */ +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) + if(png_ptr->user_transform_depth) + png_ptr->row_info.bit_depth = png_ptr->user_transform_depth; + if(png_ptr->user_transform_channels) + png_ptr->row_info.channels = png_ptr->user_transform_channels; +#endif + png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * + png_ptr->row_info.channels); + png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, + png_ptr->row_info.width); + } +#endif + +} + +#if defined(PNG_READ_PACK_SUPPORTED) +/* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel, + * without changing the actual values. Thus, if you had a row with + * a bit depth of 1, you would end up with bytes that only contained + * the numbers 0 or 1. If you would rather they contain 0 and 255, use + * png_do_shift() after this. + */ +void /* PRIVATE */ +png_do_unpack(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_unpack\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL && row_info->bit_depth < 8) +#else + if (row_info->bit_depth < 8) +#endif + { + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + switch (row_info->bit_depth) + { + case 1: + { + png_bytep sp = row + (png_size_t)((row_width - 1) >> 3); + png_bytep dp = row + (png_size_t)row_width - 1; + png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07); + for (i = 0; i < row_width; i++) + { + *dp = (png_byte)((*sp >> shift) & 0x01); + if (shift == 7) + { + shift = 0; + sp--; + } + else + shift++; + + dp--; + } + break; + } + case 2: + { + + png_bytep sp = row + (png_size_t)((row_width - 1) >> 2); + png_bytep dp = row + (png_size_t)row_width - 1; + png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); + for (i = 0; i < row_width; i++) + { + *dp = (png_byte)((*sp >> shift) & 0x03); + if (shift == 6) + { + shift = 0; + sp--; + } + else + shift += 2; + + dp--; + } + break; + } + case 4: + { + png_bytep sp = row + (png_size_t)((row_width - 1) >> 1); + png_bytep dp = row + (png_size_t)row_width - 1; + png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); + for (i = 0; i < row_width; i++) + { + *dp = (png_byte)((*sp >> shift) & 0x0f); + if (shift == 4) + { + shift = 0; + sp--; + } + else + shift = 4; + + dp--; + } + break; + } + } + row_info->bit_depth = 8; + row_info->pixel_depth = (png_byte)(8 * row_info->channels); + row_info->rowbytes = row_width * row_info->channels; + } +} +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) +/* Reverse the effects of png_do_shift. This routine merely shifts the + * pixels back to their significant bits values. Thus, if you have + * a row of bit depth 8, but only 5 are significant, this will shift + * the values back to 0 through 31. + */ +void /* PRIVATE */ +png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) +{ + png_debug(1, "in png_do_unshift\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && sig_bits != NULL && +#endif + row_info->color_type != PNG_COLOR_TYPE_PALETTE) + { + int shift[4]; + int channels = 0; + int c; + png_uint_16 value = 0; + png_uint_32 row_width = row_info->width; + + if (row_info->color_type & PNG_COLOR_MASK_COLOR) + { + shift[channels++] = row_info->bit_depth - sig_bits->red; + shift[channels++] = row_info->bit_depth - sig_bits->green; + shift[channels++] = row_info->bit_depth - sig_bits->blue; + } + else + { + shift[channels++] = row_info->bit_depth - sig_bits->gray; + } + if (row_info->color_type & PNG_COLOR_MASK_ALPHA) + { + shift[channels++] = row_info->bit_depth - sig_bits->alpha; + } + + for (c = 0; c < channels; c++) + { + if (shift[c] <= 0) + shift[c] = 0; + else + value = 1; + } + + if (!value) + return; + + switch (row_info->bit_depth) + { + case 2: + { + png_bytep bp; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + + for (bp = row, i = 0; i < istop; i++) + { + *bp >>= 1; + *bp++ &= 0x55; + } + break; + } + case 4: + { + png_bytep bp = row; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_byte mask = (png_byte)((((int)0xf0 >> shift[0]) & (int)0xf0) | + (png_byte)((int)0xf >> shift[0])); + + for (i = 0; i < istop; i++) + { + *bp >>= shift[0]; + *bp++ &= mask; + } + break; + } + case 8: + { + png_bytep bp = row; + png_uint_32 i; + png_uint_32 istop = row_width * channels; + + for (i = 0; i < istop; i++) + { + *bp++ >>= shift[i%channels]; + } + break; + } + case 16: + { + png_bytep bp = row; + png_uint_32 i; + png_uint_32 istop = channels * row_width; + + for (i = 0; i < istop; i++) + { + value = (png_uint_16)((*bp << 8) + *(bp + 1)); + value >>= shift[i%channels]; + *bp++ = (png_byte)(value >> 8); + *bp++ = (png_byte)(value & 0xff); + } + break; + } + } + } +} +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +/* chop rows of bit depth 16 down to 8 */ +void /* PRIVATE */ +png_do_chop(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_chop\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL && row_info->bit_depth == 16) +#else + if (row_info->bit_depth == 16) +#endif + { + png_bytep sp = row; + png_bytep dp = row; + png_uint_32 i; + png_uint_32 istop = row_info->width * row_info->channels; + + for (i = 0; i> 8)) >> 8; + * + * Approximate calculation with shift/add instead of multiply/divide: + * *dp = ((((png_uint_32)(*sp) << 8) | + * (png_uint_32)((int)(*(sp + 1)) - *sp)) + 128) >> 8; + * + * What we actually do to avoid extra shifting and conversion: + */ + + *dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0); +#else + /* Simply discard the low order byte */ + *dp = *sp; +#endif + } + row_info->bit_depth = 8; + row_info->pixel_depth = (png_byte)(8 * row_info->channels); + row_info->rowbytes = row_info->width * row_info->channels; + } +} +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) +void /* PRIVATE */ +png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_read_swap_alpha\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif + { + png_uint_32 row_width = row_info->width; + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + /* This converts from RGBA to ARGB */ + if (row_info->bit_depth == 8) + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_byte save; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + save = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save; + } + } + /* This converts from RRGGBBAA to AARRGGBB */ + else + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_byte save[2]; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + save[0] = *(--sp); + save[1] = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save[0]; + *(--dp) = save[1]; + } + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + /* This converts from GA to AG */ + if (row_info->bit_depth == 8) + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_byte save; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + save = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save; + } + } + /* This converts from GGAA to AAGG */ + else + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_byte save[2]; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + save[0] = *(--sp); + save[1] = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save[0]; + *(--dp) = save[1]; + } + } + } + } +} +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +void /* PRIVATE */ +png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_read_invert_alpha\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif + { + png_uint_32 row_width = row_info->width; + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + /* This inverts the alpha channel in RGBA */ + if (row_info->bit_depth == 8) + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + +/* This does nothing: + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + We can replace it with: +*/ + sp-=3; + dp=sp; + } + } + /* This inverts the alpha channel in RRGGBBAA */ + else + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = (png_byte)(255 - *(--sp)); + +/* This does nothing: + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + We can replace it with: +*/ + sp-=6; + dp=sp; + } + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + /* This inverts the alpha channel in GA */ + if (row_info->bit_depth == 8) + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = *(--sp); + } + } + /* This inverts the alpha channel in GGAA */ + else + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = (png_byte)(255 - *(--sp)); +/* + *(--dp) = *(--sp); + *(--dp) = *(--sp); +*/ + sp-=2; + dp=sp; + } + } + } + } +} +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) +/* Add filler channel if we have RGB color */ +void /* PRIVATE */ +png_do_read_filler(png_row_infop row_info, png_bytep row, + png_uint_32 filler, png_uint_32 flags) +{ + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + png_byte hi_filler = (png_byte)((filler>>8) & 0xff); + png_byte lo_filler = (png_byte)(filler & 0xff); + + png_debug(1, "in png_do_read_filler\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + row_info->color_type == PNG_COLOR_TYPE_GRAY) + { + if(row_info->bit_depth == 8) + { + /* This changes the data from G to GX */ + if (flags & PNG_FLAG_FILLER_AFTER) + { + png_bytep sp = row + (png_size_t)row_width; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 1; i < row_width; i++) + { + *(--dp) = lo_filler; + *(--dp) = *(--sp); + } + *(--dp) = lo_filler; + row_info->channels = 2; + row_info->pixel_depth = 16; + row_info->rowbytes = row_width * 2; + } + /* This changes the data from G to XG */ + else + { + png_bytep sp = row + (png_size_t)row_width; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 0; i < row_width; i++) + { + *(--dp) = *(--sp); + *(--dp) = lo_filler; + } + row_info->channels = 2; + row_info->pixel_depth = 16; + row_info->rowbytes = row_width * 2; + } + } + else if(row_info->bit_depth == 16) + { + /* This changes the data from GG to GGXX */ + if (flags & PNG_FLAG_FILLER_AFTER) + { + png_bytep sp = row + (png_size_t)row_width * 2; + png_bytep dp = sp + (png_size_t)row_width * 2; + for (i = 1; i < row_width; i++) + { + *(--dp) = hi_filler; + *(--dp) = lo_filler; + *(--dp) = *(--sp); + *(--dp) = *(--sp); + } + *(--dp) = hi_filler; + *(--dp) = lo_filler; + row_info->channels = 2; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + } + /* This changes the data from GG to XXGG */ + else + { + png_bytep sp = row + (png_size_t)row_width * 2; + png_bytep dp = sp + (png_size_t)row_width * 2; + for (i = 0; i < row_width; i++) + { + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = hi_filler; + *(--dp) = lo_filler; + } + row_info->channels = 2; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + } + } + } /* COLOR_TYPE == GRAY */ + else if (row_info->color_type == PNG_COLOR_TYPE_RGB) + { + if(row_info->bit_depth == 8) + { + /* This changes the data from RGB to RGBX */ + if (flags & PNG_FLAG_FILLER_AFTER) + { + png_bytep sp = row + (png_size_t)row_width * 3; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 1; i < row_width; i++) + { + *(--dp) = lo_filler; + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + } + *(--dp) = lo_filler; + row_info->channels = 4; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + } + /* This changes the data from RGB to XRGB */ + else + { + png_bytep sp = row + (png_size_t)row_width * 3; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 0; i < row_width; i++) + { + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = lo_filler; + } + row_info->channels = 4; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + } + } + else if(row_info->bit_depth == 16) + { + /* This changes the data from RRGGBB to RRGGBBXX */ + if (flags & PNG_FLAG_FILLER_AFTER) + { + png_bytep sp = row + (png_size_t)row_width * 6; + png_bytep dp = sp + (png_size_t)row_width * 2; + for (i = 1; i < row_width; i++) + { + *(--dp) = hi_filler; + *(--dp) = lo_filler; + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + } + *(--dp) = hi_filler; + *(--dp) = lo_filler; + row_info->channels = 4; + row_info->pixel_depth = 64; + row_info->rowbytes = row_width * 8; + } + /* This changes the data from RRGGBB to XXRRGGBB */ + else + { + png_bytep sp = row + (png_size_t)row_width * 6; + png_bytep dp = sp + (png_size_t)row_width * 2; + for (i = 0; i < row_width; i++) + { + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = hi_filler; + *(--dp) = lo_filler; + } + row_info->channels = 4; + row_info->pixel_depth = 64; + row_info->rowbytes = row_width * 8; + } + } + } /* COLOR_TYPE == RGB */ +} +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +/* expand grayscale files to RGB, with or without alpha */ +void /* PRIVATE */ +png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) +{ + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + png_debug(1, "in png_do_gray_to_rgb\n"); + if (row_info->bit_depth >= 8 && +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + !(row_info->color_type & PNG_COLOR_MASK_COLOR)) + { + if (row_info->color_type == PNG_COLOR_TYPE_GRAY) + { + if (row_info->bit_depth == 8) + { + png_bytep sp = row + (png_size_t)row_width - 1; + png_bytep dp = sp + (png_size_t)row_width * 2; + for (i = 0; i < row_width; i++) + { + *(dp--) = *sp; + *(dp--) = *sp; + *(dp--) = *(sp--); + } + } + else + { + png_bytep sp = row + (png_size_t)row_width * 2 - 1; + png_bytep dp = sp + (png_size_t)row_width * 4; + for (i = 0; i < row_width; i++) + { + *(dp--) = *sp; + *(dp--) = *(sp - 1); + *(dp--) = *sp; + *(dp--) = *(sp - 1); + *(dp--) = *(sp--); + *(dp--) = *(sp--); + } + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + if (row_info->bit_depth == 8) + { + png_bytep sp = row + (png_size_t)row_width * 2 - 1; + png_bytep dp = sp + (png_size_t)row_width * 2; + for (i = 0; i < row_width; i++) + { + *(dp--) = *(sp--); + *(dp--) = *sp; + *(dp--) = *sp; + *(dp--) = *(sp--); + } + } + else + { + png_bytep sp = row + (png_size_t)row_width * 4 - 1; + png_bytep dp = sp + (png_size_t)row_width * 4; + for (i = 0; i < row_width; i++) + { + *(dp--) = *(sp--); + *(dp--) = *(sp--); + *(dp--) = *sp; + *(dp--) = *(sp - 1); + *(dp--) = *sp; + *(dp--) = *(sp - 1); + *(dp--) = *(sp--); + *(dp--) = *(sp--); + } + } + } + row_info->channels += (png_byte)2; + row_info->color_type |= PNG_COLOR_MASK_COLOR; + row_info->pixel_depth = (png_byte)(row_info->channels * + row_info->bit_depth); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + } +} +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +/* reduce RGB files to grayscale, with or without alpha + * using the equation given in Poynton's ColorFAQ at + * + * Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net + * + * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B + * + * We approximate this with + * + * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B + * + * which can be expressed with integers as + * + * Y = (6969 * R + 23434 * G + 2365 * B)/32768 + * + * The calculation is to be done in a linear colorspace. + * + * Other integer coefficents can be used via png_set_rgb_to_gray(). + */ +int /* PRIVATE */ +png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) + +{ + png_uint_32 i; + + png_uint_32 row_width = row_info->width; + int rgb_error = 0; + + png_debug(1, "in png_do_rgb_to_gray\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + (row_info->color_type & PNG_COLOR_MASK_COLOR)) + { + png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; + png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; + png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff; + + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + { + if (row_info->bit_depth == 8) + { +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) + { + png_bytep sp = row; + png_bytep dp = row; + + for (i = 0; i < row_width; i++) + { + png_byte red = png_ptr->gamma_to_1[*(sp++)]; + png_byte green = png_ptr->gamma_to_1[*(sp++)]; + png_byte blue = png_ptr->gamma_to_1[*(sp++)]; + if(red != green || red != blue) + { + rgb_error |= 1; + *(dp++) = png_ptr->gamma_from_1[ + (rc*red+gc*green+bc*blue)>>15]; + } + else + *(dp++) = *(sp-1); + } + } + else +#endif + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_byte red = *(sp++); + png_byte green = *(sp++); + png_byte blue = *(sp++); + if(red != green || red != blue) + { + rgb_error |= 1; + *(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15); + } + else + *(dp++) = *(sp-1); + } + } + } + + else /* RGB bit_depth == 16 */ + { +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_16_to_1 != NULL && + png_ptr->gamma_16_from_1 != NULL) + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 red, green, blue, w; + + red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + + if(red == green && red == blue) + w = red; + else + { + png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> + png_ptr->gamma_shift][red>>8]; + png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> + png_ptr->gamma_shift][green>>8]; + png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> + png_ptr->gamma_shift][blue>>8]; + png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 + + bc*blue_1)>>15); + w = png_ptr->gamma_16_from_1[(gray16&0xff) >> + png_ptr->gamma_shift][gray16 >> 8]; + rgb_error |= 1; + } + + *(dp++) = (png_byte)((w>>8) & 0xff); + *(dp++) = (png_byte)(w & 0xff); + } + } + else +#endif + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 red, green, blue, gray16; + + red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + + if(red != green || red != blue) + rgb_error |= 1; + gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); + *(dp++) = (png_byte)((gray16>>8) & 0xff); + *(dp++) = (png_byte)(gray16 & 0xff); + } + } + } + } + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + if (row_info->bit_depth == 8) + { +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_byte red = png_ptr->gamma_to_1[*(sp++)]; + png_byte green = png_ptr->gamma_to_1[*(sp++)]; + png_byte blue = png_ptr->gamma_to_1[*(sp++)]; + if(red != green || red != blue) + rgb_error |= 1; + *(dp++) = png_ptr->gamma_from_1 + [(rc*red + gc*green + bc*blue)>>15]; + *(dp++) = *(sp++); /* alpha */ + } + } + else +#endif + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_byte red = *(sp++); + png_byte green = *(sp++); + png_byte blue = *(sp++); + if(red != green || red != blue) + rgb_error |= 1; + *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); + *(dp++) = *(sp++); /* alpha */ + } + } + } + else /* RGBA bit_depth == 16 */ + { +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_16_to_1 != NULL && + png_ptr->gamma_16_from_1 != NULL) + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 red, green, blue, w; + + red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + + if(red == green && red == blue) + w = red; + else + { + png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> + png_ptr->gamma_shift][red>>8]; + png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> + png_ptr->gamma_shift][green>>8]; + png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> + png_ptr->gamma_shift][blue>>8]; + png_uint_16 gray16 = (png_uint_16)((rc * red_1 + + gc * green_1 + bc * blue_1)>>15); + w = png_ptr->gamma_16_from_1[(gray16&0xff) >> + png_ptr->gamma_shift][gray16 >> 8]; + rgb_error |= 1; + } + + *(dp++) = (png_byte)((w>>8) & 0xff); + *(dp++) = (png_byte)(w & 0xff); + *(dp++) = *(sp++); /* alpha */ + *(dp++) = *(sp++); + } + } + else +#endif + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 red, green, blue, gray16; + red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; + green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; + blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; + if(red != green || red != blue) + rgb_error |= 1; + gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); + *(dp++) = (png_byte)((gray16>>8) & 0xff); + *(dp++) = (png_byte)(gray16 & 0xff); + *(dp++) = *(sp++); /* alpha */ + *(dp++) = *(sp++); + } + } + } + } + row_info->channels -= (png_byte)2; + row_info->color_type &= ~PNG_COLOR_MASK_COLOR; + row_info->pixel_depth = (png_byte)(row_info->channels * + row_info->bit_depth); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + } + return rgb_error; +} +#endif + +/* Build a grayscale palette. Palette is assumed to be 1 << bit_depth + * large of png_color. This lets grayscale images be treated as + * paletted. Most useful for gamma correction and simplification + * of code. + */ +void PNGAPI +png_build_grayscale_palette(int bit_depth, png_colorp palette) +{ + int num_palette; + int color_inc; + int i; + int v; + + png_debug(1, "in png_do_build_grayscale_palette\n"); + if (palette == NULL) + return; + + switch (bit_depth) + { + case 1: + num_palette = 2; + color_inc = 0xff; + break; + case 2: + num_palette = 4; + color_inc = 0x55; + break; + case 4: + num_palette = 16; + color_inc = 0x11; + break; + case 8: + num_palette = 256; + color_inc = 1; + break; + default: + num_palette = 0; + color_inc = 0; + break; + } + + for (i = 0, v = 0; i < num_palette; i++, v += color_inc) + { + palette[i].red = (png_byte)v; + palette[i].green = (png_byte)v; + palette[i].blue = (png_byte)v; + } +} + +/* This function is currently unused. Do we really need it? */ +#if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED) +void /* PRIVATE */ +png_correct_palette(png_structp png_ptr, png_colorp palette, + int num_palette) +{ + png_debug(1, "in png_correct_palette\n"); +#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ + defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) + if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND)) + { + png_color back, back_1; + + if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) + { + back.red = png_ptr->gamma_table[png_ptr->background.red]; + back.green = png_ptr->gamma_table[png_ptr->background.green]; + back.blue = png_ptr->gamma_table[png_ptr->background.blue]; + + back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; + back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; + back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; + } + else + { + double g; + + g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); + + if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_SCREEN || + fabs(g - 1.0) < PNG_GAMMA_THRESHOLD) + { + back.red = png_ptr->background.red; + back.green = png_ptr->background.green; + back.blue = png_ptr->background.blue; + } + else + { + back.red = + (png_byte)(pow((double)png_ptr->background.red/255, g) * + 255.0 + 0.5); + back.green = + (png_byte)(pow((double)png_ptr->background.green/255, g) * + 255.0 + 0.5); + back.blue = + (png_byte)(pow((double)png_ptr->background.blue/255, g) * + 255.0 + 0.5); + } + + g = 1.0 / png_ptr->background_gamma; + + back_1.red = + (png_byte)(pow((double)png_ptr->background.red/255, g) * + 255.0 + 0.5); + back_1.green = + (png_byte)(pow((double)png_ptr->background.green/255, g) * + 255.0 + 0.5); + back_1.blue = + (png_byte)(pow((double)png_ptr->background.blue/255, g) * + 255.0 + 0.5); + } + + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_uint_32 i; + + for (i = 0; i < (png_uint_32)num_palette; i++) + { + if (i < png_ptr->num_trans && png_ptr->trans[i] == 0) + { + palette[i] = back; + } + else if (i < png_ptr->num_trans && png_ptr->trans[i] != 0xff) + { + png_byte v, w; + + v = png_ptr->gamma_to_1[png_ptr->palette[i].red]; + png_composite(w, v, png_ptr->trans[i], back_1.red); + palette[i].red = png_ptr->gamma_from_1[w]; + + v = png_ptr->gamma_to_1[png_ptr->palette[i].green]; + png_composite(w, v, png_ptr->trans[i], back_1.green); + palette[i].green = png_ptr->gamma_from_1[w]; + + v = png_ptr->gamma_to_1[png_ptr->palette[i].blue]; + png_composite(w, v, png_ptr->trans[i], back_1.blue); + palette[i].blue = png_ptr->gamma_from_1[w]; + } + else + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + } + } + else + { + int i; + + for (i = 0; i < num_palette; i++) + { + if (palette[i].red == (png_byte)png_ptr->trans_values.gray) + { + palette[i] = back; + } + else + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + } + } + } + else +#endif +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (png_ptr->transformations & PNG_GAMMA) + { + int i; + + for (i = 0; i < num_palette; i++) + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + } +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + else +#endif +#endif +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->transformations & PNG_BACKGROUND) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_color back; + + back.red = (png_byte)png_ptr->background.red; + back.green = (png_byte)png_ptr->background.green; + back.blue = (png_byte)png_ptr->background.blue; + + for (i = 0; i < (int)png_ptr->num_trans; i++) + { + if (png_ptr->trans[i] == 0) + { + palette[i].red = back.red; + palette[i].green = back.green; + palette[i].blue = back.blue; + } + else if (png_ptr->trans[i] != 0xff) + { + png_composite(palette[i].red, png_ptr->palette[i].red, + png_ptr->trans[i], back.red); + png_composite(palette[i].green, png_ptr->palette[i].green, + png_ptr->trans[i], back.green); + png_composite(palette[i].blue, png_ptr->palette[i].blue, + png_ptr->trans[i], back.blue); + } + } + } + else /* assume grayscale palette (what else could it be?) */ + { + int i; + + for (i = 0; i < num_palette; i++) + { + if (i == (png_byte)png_ptr->trans_values.gray) + { + palette[i].red = (png_byte)png_ptr->background.red; + palette[i].green = (png_byte)png_ptr->background.green; + palette[i].blue = (png_byte)png_ptr->background.blue; + } + } + } + } +#endif +} +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +/* Replace any alpha or transparency with the supplied background color. + * "background" is already in the screen gamma, while "background_1" is + * at a gamma of 1.0. Paletted files have already been taken care of. + */ +void /* PRIVATE */ +png_do_background(png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background +#if defined(PNG_READ_GAMMA_SUPPORTED) + , png_color_16p background_1, + png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, + png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, + png_uint_16pp gamma_16_to_1, int gamma_shift +#endif + ) +{ + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + int shift; + + png_debug(1, "in png_do_background\n"); + if (background != NULL && +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + (!(row_info->color_type & PNG_COLOR_MASK_ALPHA) || + (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_values))) + { + switch (row_info->color_type) + { + case PNG_COLOR_TYPE_GRAY: + { + switch (row_info->bit_depth) + { + case 1: + { + sp = row; + shift = 7; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x01) + == trans_values->gray) + { + *sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); + } + if (!shift) + { + shift = 7; + sp++; + } + else + shift--; + } + break; + } + case 2: + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_table != NULL) + { + sp = row; + shift = 6; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x03) + == trans_values->gray) + { + *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); + } + else + { + png_byte p = (png_byte)((*sp >> shift) & 0x03); + png_byte g = (png_byte)((gamma_table [p | (p << 2) | + (p << 4) | (p << 6)] >> 6) & 0x03); + *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *sp |= (png_byte)(g << shift); + } + if (!shift) + { + shift = 6; + sp++; + } + else + shift -= 2; + } + } + else +#endif + { + sp = row; + shift = 6; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x03) + == trans_values->gray) + { + *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); + } + if (!shift) + { + shift = 6; + sp++; + } + else + shift -= 2; + } + } + break; + } + case 4: + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_table != NULL) + { + sp = row; + shift = 4; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x0f) + == trans_values->gray) + { + *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); + } + else + { + png_byte p = (png_byte)((*sp >> shift) & 0x0f); + png_byte g = (png_byte)((gamma_table[p | + (p << 4)] >> 4) & 0x0f); + *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *sp |= (png_byte)(g << shift); + } + if (!shift) + { + shift = 4; + sp++; + } + else + shift -= 4; + } + } + else +#endif + { + sp = row; + shift = 4; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x0f) + == trans_values->gray) + { + *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); + } + if (!shift) + { + shift = 4; + sp++; + } + else + shift -= 4; + } + } + break; + } + case 8: + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_table != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp++) + { + if (*sp == trans_values->gray) + { + *sp = (png_byte)background->gray; + } + else + { + *sp = gamma_table[*sp]; + } + } + } + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp++) + { + if (*sp == trans_values->gray) + { + *sp = (png_byte)background->gray; + } + } + } + break; + } + case 16: + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_16 != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp += 2) + { + png_uint_16 v; + + v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + if (v == trans_values->gray) + { + /* background is already in screen gamma */ + *sp = (png_byte)((background->gray >> 8) & 0xff); + *(sp + 1) = (png_byte)(background->gray & 0xff); + } + else + { + v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + } + } + } + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp += 2) + { + png_uint_16 v; + + v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + if (v == trans_values->gray) + { + *sp = (png_byte)((background->gray >> 8) & 0xff); + *(sp + 1) = (png_byte)(background->gray & 0xff); + } + } + } + break; + } + } + break; + } + case PNG_COLOR_TYPE_RGB: + { + if (row_info->bit_depth == 8) + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_table != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp += 3) + { + if (*sp == trans_values->red && + *(sp + 1) == trans_values->green && + *(sp + 2) == trans_values->blue) + { + *sp = (png_byte)background->red; + *(sp + 1) = (png_byte)background->green; + *(sp + 2) = (png_byte)background->blue; + } + else + { + *sp = gamma_table[*sp]; + *(sp + 1) = gamma_table[*(sp + 1)]; + *(sp + 2) = gamma_table[*(sp + 2)]; + } + } + } + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp += 3) + { + if (*sp == trans_values->red && + *(sp + 1) == trans_values->green && + *(sp + 2) == trans_values->blue) + { + *sp = (png_byte)background->red; + *(sp + 1) = (png_byte)background->green; + *(sp + 2) = (png_byte)background->blue; + } + } + } + } + else /* if (row_info->bit_depth == 16) */ + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_16 != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp += 6) + { + png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); + png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); + if (r == trans_values->red && g == trans_values->green && + b == trans_values->blue) + { + /* background is already in screen gamma */ + *sp = (png_byte)((background->red >> 8) & 0xff); + *(sp + 1) = (png_byte)(background->red & 0xff); + *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); + *(sp + 3) = (png_byte)(background->green & 0xff); + *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); + *(sp + 5) = (png_byte)(background->blue & 0xff); + } + else + { + png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; + *(sp + 2) = (png_byte)((v >> 8) & 0xff); + *(sp + 3) = (png_byte)(v & 0xff); + v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; + *(sp + 4) = (png_byte)((v >> 8) & 0xff); + *(sp + 5) = (png_byte)(v & 0xff); + } + } + } + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp += 6) + { + png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp+1)); + png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); + png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); + + if (r == trans_values->red && g == trans_values->green && + b == trans_values->blue) + { + *sp = (png_byte)((background->red >> 8) & 0xff); + *(sp + 1) = (png_byte)(background->red & 0xff); + *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); + *(sp + 3) = (png_byte)(background->green & 0xff); + *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); + *(sp + 5) = (png_byte)(background->blue & 0xff); + } + } + } + } + break; + } + case PNG_COLOR_TYPE_GRAY_ALPHA: + { + if (row_info->bit_depth == 8) + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_to_1 != NULL && gamma_from_1 != NULL && + gamma_table != NULL) + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 2, dp++) + { + png_uint_16 a = *(sp + 1); + + if (a == 0xff) + { + *dp = gamma_table[*sp]; + } + else if (a == 0) + { + /* background is already in screen gamma */ + *dp = (png_byte)background->gray; + } + else + { + png_byte v, w; + + v = gamma_to_1[*sp]; + png_composite(w, v, a, background_1->gray); + *dp = gamma_from_1[w]; + } + } + } + else +#endif + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 2, dp++) + { + png_byte a = *(sp + 1); + + if (a == 0xff) + { + *dp = *sp; + } +#if defined(PNG_READ_GAMMA_SUPPORTED) + else if (a == 0) + { + *dp = (png_byte)background->gray; + } + else + { + png_composite(*dp, *sp, a, background_1->gray); + } +#else + *dp = (png_byte)background->gray; +#endif + } + } + } + else /* if (png_ptr->bit_depth == 16) */ + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_16 != NULL && gamma_16_from_1 != NULL && + gamma_16_to_1 != NULL) + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 4, dp += 2) + { + png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); + + if (a == (png_uint_16)0xffff) + { + png_uint_16 v; + + v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; + *dp = (png_byte)((v >> 8) & 0xff); + *(dp + 1) = (png_byte)(v & 0xff); + } +#if defined(PNG_READ_GAMMA_SUPPORTED) + else if (a == 0) +#else + else +#endif + { + /* background is already in screen gamma */ + *dp = (png_byte)((background->gray >> 8) & 0xff); + *(dp + 1) = (png_byte)(background->gray & 0xff); + } +#if defined(PNG_READ_GAMMA_SUPPORTED) + else + { + png_uint_16 g, v, w; + + g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; + png_composite_16(v, g, a, background_1->gray); + w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8]; + *dp = (png_byte)((w >> 8) & 0xff); + *(dp + 1) = (png_byte)(w & 0xff); + } +#endif + } + } + else +#endif + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 4, dp += 2) + { + png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); + if (a == (png_uint_16)0xffff) + { + png_memcpy(dp, sp, 2); + } +#if defined(PNG_READ_GAMMA_SUPPORTED) + else if (a == 0) +#else + else +#endif + { + *dp = (png_byte)((background->gray >> 8) & 0xff); + *(dp + 1) = (png_byte)(background->gray & 0xff); + } +#if defined(PNG_READ_GAMMA_SUPPORTED) + else + { + png_uint_16 g, v; + + g = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + png_composite_16(v, g, a, background_1->gray); + *dp = (png_byte)((v >> 8) & 0xff); + *(dp + 1) = (png_byte)(v & 0xff); + } +#endif + } + } + } + break; + } + case PNG_COLOR_TYPE_RGB_ALPHA: + { + if (row_info->bit_depth == 8) + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_to_1 != NULL && gamma_from_1 != NULL && + gamma_table != NULL) + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 4, dp += 3) + { + png_byte a = *(sp + 3); + + if (a == 0xff) + { + *dp = gamma_table[*sp]; + *(dp + 1) = gamma_table[*(sp + 1)]; + *(dp + 2) = gamma_table[*(sp + 2)]; + } + else if (a == 0) + { + /* background is already in screen gamma */ + *dp = (png_byte)background->red; + *(dp + 1) = (png_byte)background->green; + *(dp + 2) = (png_byte)background->blue; + } + else + { + png_byte v, w; + + v = gamma_to_1[*sp]; + png_composite(w, v, a, background_1->red); + *dp = gamma_from_1[w]; + v = gamma_to_1[*(sp + 1)]; + png_composite(w, v, a, background_1->green); + *(dp + 1) = gamma_from_1[w]; + v = gamma_to_1[*(sp + 2)]; + png_composite(w, v, a, background_1->blue); + *(dp + 2) = gamma_from_1[w]; + } + } + } + else +#endif + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 4, dp += 3) + { + png_byte a = *(sp + 3); + + if (a == 0xff) + { + *dp = *sp; + *(dp + 1) = *(sp + 1); + *(dp + 2) = *(sp + 2); + } + else if (a == 0) + { + *dp = (png_byte)background->red; + *(dp + 1) = (png_byte)background->green; + *(dp + 2) = (png_byte)background->blue; + } + else + { + png_composite(*dp, *sp, a, background->red); + png_composite(*(dp + 1), *(sp + 1), a, + background->green); + png_composite(*(dp + 2), *(sp + 2), a, + background->blue); + } + } + } + } + else /* if (row_info->bit_depth == 16) */ + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_16 != NULL && gamma_16_from_1 != NULL && + gamma_16_to_1 != NULL) + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 8, dp += 6) + { + png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) + << 8) + (png_uint_16)(*(sp + 7))); + if (a == (png_uint_16)0xffff) + { + png_uint_16 v; + + v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; + *dp = (png_byte)((v >> 8) & 0xff); + *(dp + 1) = (png_byte)(v & 0xff); + v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; + *(dp + 2) = (png_byte)((v >> 8) & 0xff); + *(dp + 3) = (png_byte)(v & 0xff); + v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; + *(dp + 4) = (png_byte)((v >> 8) & 0xff); + *(dp + 5) = (png_byte)(v & 0xff); + } + else if (a == 0) + { + /* background is already in screen gamma */ + *dp = (png_byte)((background->red >> 8) & 0xff); + *(dp + 1) = (png_byte)(background->red & 0xff); + *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); + *(dp + 3) = (png_byte)(background->green & 0xff); + *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); + *(dp + 5) = (png_byte)(background->blue & 0xff); + } + else + { + png_uint_16 v, w, x; + + v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; + png_composite_16(w, v, a, background_1->red); + x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; + *dp = (png_byte)((x >> 8) & 0xff); + *(dp + 1) = (png_byte)(x & 0xff); + v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)]; + png_composite_16(w, v, a, background_1->green); + x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; + *(dp + 2) = (png_byte)((x >> 8) & 0xff); + *(dp + 3) = (png_byte)(x & 0xff); + v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)]; + png_composite_16(w, v, a, background_1->blue); + x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8]; + *(dp + 4) = (png_byte)((x >> 8) & 0xff); + *(dp + 5) = (png_byte)(x & 0xff); + } + } + } + else +#endif + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 8, dp += 6) + { + png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) + << 8) + (png_uint_16)(*(sp + 7))); + if (a == (png_uint_16)0xffff) + { + png_memcpy(dp, sp, 6); + } + else if (a == 0) + { + *dp = (png_byte)((background->red >> 8) & 0xff); + *(dp + 1) = (png_byte)(background->red & 0xff); + *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); + *(dp + 3) = (png_byte)(background->green & 0xff); + *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); + *(dp + 5) = (png_byte)(background->blue & 0xff); + } + else + { + png_uint_16 v; + + png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) + + *(sp + 3)); + png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) + + *(sp + 5)); + + png_composite_16(v, r, a, background->red); + *dp = (png_byte)((v >> 8) & 0xff); + *(dp + 1) = (png_byte)(v & 0xff); + png_composite_16(v, g, a, background->green); + *(dp + 2) = (png_byte)((v >> 8) & 0xff); + *(dp + 3) = (png_byte)(v & 0xff); + png_composite_16(v, b, a, background->blue); + *(dp + 4) = (png_byte)((v >> 8) & 0xff); + *(dp + 5) = (png_byte)(v & 0xff); + } + } + } + } + break; + } + } + + if (row_info->color_type & PNG_COLOR_MASK_ALPHA) + { + row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; + row_info->channels--; + row_info->pixel_depth = (png_byte)(row_info->channels * + row_info->bit_depth); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + } + } +} +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +/* Gamma correct the image, avoiding the alpha channel. Make sure + * you do this after you deal with the transparency issue on grayscale + * or RGB images. If your bit depth is 8, use gamma_table, if it + * is 16, use gamma_16_table and gamma_shift. Build these with + * build_gamma_table(). + */ +void /* PRIVATE */ +png_do_gamma(png_row_infop row_info, png_bytep row, + png_bytep gamma_table, png_uint_16pp gamma_16_table, + int gamma_shift) +{ + png_bytep sp; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + png_debug(1, "in png_do_gamma\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + ((row_info->bit_depth <= 8 && gamma_table != NULL) || + (row_info->bit_depth == 16 && gamma_16_table != NULL))) + { + switch (row_info->color_type) + { + case PNG_COLOR_TYPE_RGB: + { + if (row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++) + { + *sp = gamma_table[*sp]; + sp++; + *sp = gamma_table[*sp]; + sp++; + *sp = gamma_table[*sp]; + sp++; + } + } + else /* if (row_info->bit_depth == 16) */ + { + sp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 v; + + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + } + } + break; + } + case PNG_COLOR_TYPE_RGB_ALPHA: + { + if (row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++) + { + *sp = gamma_table[*sp]; + sp++; + *sp = gamma_table[*sp]; + sp++; + *sp = gamma_table[*sp]; + sp++; + sp++; + } + } + else /* if (row_info->bit_depth == 16) */ + { + sp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 4; + } + } + break; + } + case PNG_COLOR_TYPE_GRAY_ALPHA: + { + if (row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++) + { + *sp = gamma_table[*sp]; + sp += 2; + } + } + else /* if (row_info->bit_depth == 16) */ + { + sp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 4; + } + } + break; + } + case PNG_COLOR_TYPE_GRAY: + { + if (row_info->bit_depth == 2) + { + sp = row; + for (i = 0; i < row_width; i += 4) + { + int a = *sp & 0xc0; + int b = *sp & 0x30; + int c = *sp & 0x0c; + int d = *sp & 0x03; + + *sp = (png_byte)( + ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)| + ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)| + ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)| + ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); + sp++; + } + } + if (row_info->bit_depth == 4) + { + sp = row; + for (i = 0; i < row_width; i += 2) + { + int msb = *sp & 0xf0; + int lsb = *sp & 0x0f; + + *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0) + | (((int)gamma_table[(lsb << 4) | lsb]) >> 4)); + sp++; + } + } + else if (row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++) + { + *sp = gamma_table[*sp]; + sp++; + } + } + else if (row_info->bit_depth == 16) + { + sp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + } + } + break; + } + } + } +} +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) +/* Expands a palette row to an RGB or RGBA row depending + * upon whether you supply trans and num_trans. + */ +void /* PRIVATE */ +png_do_expand_palette(png_row_infop row_info, png_bytep row, + png_colorp palette, png_bytep trans, int num_trans) +{ + int shift, value; + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + png_debug(1, "in png_do_expand_palette\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + row_info->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (row_info->bit_depth < 8) + { + switch (row_info->bit_depth) + { + case 1: + { + sp = row + (png_size_t)((row_width - 1) >> 3); + dp = row + (png_size_t)row_width - 1; + shift = 7 - (int)((row_width + 7) & 0x07); + for (i = 0; i < row_width; i++) + { + if ((*sp >> shift) & 0x01) + *dp = 1; + else + *dp = 0; + if (shift == 7) + { + shift = 0; + sp--; + } + else + shift++; + + dp--; + } + break; + } + case 2: + { + sp = row + (png_size_t)((row_width - 1) >> 2); + dp = row + (png_size_t)row_width - 1; + shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); + for (i = 0; i < row_width; i++) + { + value = (*sp >> shift) & 0x03; + *dp = (png_byte)value; + if (shift == 6) + { + shift = 0; + sp--; + } + else + shift += 2; + + dp--; + } + break; + } + case 4: + { + sp = row + (png_size_t)((row_width - 1) >> 1); + dp = row + (png_size_t)row_width - 1; + shift = (int)((row_width & 0x01) << 2); + for (i = 0; i < row_width; i++) + { + value = (*sp >> shift) & 0x0f; + *dp = (png_byte)value; + if (shift == 4) + { + shift = 0; + sp--; + } + else + shift += 4; + + dp--; + } + break; + } + } + row_info->bit_depth = 8; + row_info->pixel_depth = 8; + row_info->rowbytes = row_width; + } + switch (row_info->bit_depth) + { + case 8: + { + if (trans != NULL) + { + sp = row + (png_size_t)row_width - 1; + dp = row + (png_size_t)(row_width << 2) - 1; + + for (i = 0; i < row_width; i++) + { + if ((int)(*sp) >= num_trans) + *dp-- = 0xff; + else + *dp-- = trans[*sp]; + *dp-- = palette[*sp].blue; + *dp-- = palette[*sp].green; + *dp-- = palette[*sp].red; + sp--; + } + row_info->bit_depth = 8; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + row_info->color_type = 6; + row_info->channels = 4; + } + else + { + sp = row + (png_size_t)row_width - 1; + dp = row + (png_size_t)(row_width * 3) - 1; + + for (i = 0; i < row_width; i++) + { + *dp-- = palette[*sp].blue; + *dp-- = palette[*sp].green; + *dp-- = palette[*sp].red; + sp--; + } + row_info->bit_depth = 8; + row_info->pixel_depth = 24; + row_info->rowbytes = row_width * 3; + row_info->color_type = 2; + row_info->channels = 3; + } + break; + } + } + } +} + +/* If the bit depth < 8, it is expanded to 8. Also, if the already + * expanded transparency value is supplied, an alpha channel is built. + */ +void /* PRIVATE */ +png_do_expand(png_row_infop row_info, png_bytep row, + png_color_16p trans_value) +{ + int shift, value; + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + png_debug(1, "in png_do_expand\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif + { + if (row_info->color_type == PNG_COLOR_TYPE_GRAY) + { + png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0); + + if (row_info->bit_depth < 8) + { + switch (row_info->bit_depth) + { + case 1: + { + gray = (png_uint_16)(gray*0xff); + sp = row + (png_size_t)((row_width - 1) >> 3); + dp = row + (png_size_t)row_width - 1; + shift = 7 - (int)((row_width + 7) & 0x07); + for (i = 0; i < row_width; i++) + { + if ((*sp >> shift) & 0x01) + *dp = 0xff; + else + *dp = 0; + if (shift == 7) + { + shift = 0; + sp--; + } + else + shift++; + + dp--; + } + break; + } + case 2: + { + gray = (png_uint_16)(gray*0x55); + sp = row + (png_size_t)((row_width - 1) >> 2); + dp = row + (png_size_t)row_width - 1; + shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); + for (i = 0; i < row_width; i++) + { + value = (*sp >> shift) & 0x03; + *dp = (png_byte)(value | (value << 2) | (value << 4) | + (value << 6)); + if (shift == 6) + { + shift = 0; + sp--; + } + else + shift += 2; + + dp--; + } + break; + } + case 4: + { + gray = (png_uint_16)(gray*0x11); + sp = row + (png_size_t)((row_width - 1) >> 1); + dp = row + (png_size_t)row_width - 1; + shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); + for (i = 0; i < row_width; i++) + { + value = (*sp >> shift) & 0x0f; + *dp = (png_byte)(value | (value << 4)); + if (shift == 4) + { + shift = 0; + sp--; + } + else + shift = 4; + + dp--; + } + break; + } + } + row_info->bit_depth = 8; + row_info->pixel_depth = 8; + row_info->rowbytes = row_width; + } + + if (trans_value != NULL) + { + if (row_info->bit_depth == 8) + { + sp = row + (png_size_t)row_width - 1; + dp = row + (png_size_t)(row_width << 1) - 1; + for (i = 0; i < row_width; i++) + { + if (*sp == gray) + *dp-- = 0; + else + *dp-- = 0xff; + *dp-- = *sp--; + } + } + else if (row_info->bit_depth == 16) + { + sp = row + row_info->rowbytes - 1; + dp = row + (row_info->rowbytes << 1) - 1; + for (i = 0; i < row_width; i++) + { + if (((png_uint_16)*(sp) | + ((png_uint_16)*(sp - 1) << 8)) == gray) + { + *dp-- = 0; + *dp-- = 0; + } + else + { + *dp-- = 0xff; + *dp-- = 0xff; + } + *dp-- = *sp--; + *dp-- = *sp--; + } + } + row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA; + row_info->channels = 2; + row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, + row_width); + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value) + { + if (row_info->bit_depth == 8) + { + sp = row + (png_size_t)row_info->rowbytes - 1; + dp = row + (png_size_t)(row_width << 2) - 1; + for (i = 0; i < row_width; i++) + { + if (*(sp - 2) == trans_value->red && + *(sp - 1) == trans_value->green && + *(sp - 0) == trans_value->blue) + *dp-- = 0; + else + *dp-- = 0xff; + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + } + } + else if (row_info->bit_depth == 16) + { + sp = row + row_info->rowbytes - 1; + dp = row + (png_size_t)(row_width << 3) - 1; + for (i = 0; i < row_width; i++) + { + if ((((png_uint_16)*(sp - 4) | + ((png_uint_16)*(sp - 5) << 8)) == trans_value->red) && + (((png_uint_16)*(sp - 2) | + ((png_uint_16)*(sp - 3) << 8)) == trans_value->green) && + (((png_uint_16)*(sp - 0) | + ((png_uint_16)*(sp - 1) << 8)) == trans_value->blue)) + { + *dp-- = 0; + *dp-- = 0; + } + else + { + *dp-- = 0xff; + *dp-- = 0xff; + } + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + } + } + row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA; + row_info->channels = 4; + row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + } + } +} +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +void /* PRIVATE */ +png_do_dither(png_row_infop row_info, png_bytep row, + png_bytep palette_lookup, png_bytep dither_lookup) +{ + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + png_debug(1, "in png_do_dither\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif + { + if (row_info->color_type == PNG_COLOR_TYPE_RGB && + palette_lookup && row_info->bit_depth == 8) + { + int r, g, b, p; + sp = row; + dp = row; + for (i = 0; i < row_width; i++) + { + r = *sp++; + g = *sp++; + b = *sp++; + + /* this looks real messy, but the compiler will reduce + it down to a reasonable formula. For example, with + 5 bits per color, we get: + p = (((r >> 3) & 0x1f) << 10) | + (((g >> 3) & 0x1f) << 5) | + ((b >> 3) & 0x1f); + */ + p = (((r >> (8 - PNG_DITHER_RED_BITS)) & + ((1 << PNG_DITHER_RED_BITS) - 1)) << + (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | + (((g >> (8 - PNG_DITHER_GREEN_BITS)) & + ((1 << PNG_DITHER_GREEN_BITS) - 1)) << + (PNG_DITHER_BLUE_BITS)) | + ((b >> (8 - PNG_DITHER_BLUE_BITS)) & + ((1 << PNG_DITHER_BLUE_BITS) - 1)); + + *dp++ = palette_lookup[p]; + } + row_info->color_type = PNG_COLOR_TYPE_PALETTE; + row_info->channels = 1; + row_info->pixel_depth = row_info->bit_depth; + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + } + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && + palette_lookup != NULL && row_info->bit_depth == 8) + { + int r, g, b, p; + sp = row; + dp = row; + for (i = 0; i < row_width; i++) + { + r = *sp++; + g = *sp++; + b = *sp++; + sp++; + + p = (((r >> (8 - PNG_DITHER_RED_BITS)) & + ((1 << PNG_DITHER_RED_BITS) - 1)) << + (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | + (((g >> (8 - PNG_DITHER_GREEN_BITS)) & + ((1 << PNG_DITHER_GREEN_BITS) - 1)) << + (PNG_DITHER_BLUE_BITS)) | + ((b >> (8 - PNG_DITHER_BLUE_BITS)) & + ((1 << PNG_DITHER_BLUE_BITS) - 1)); + + *dp++ = palette_lookup[p]; + } + row_info->color_type = PNG_COLOR_TYPE_PALETTE; + row_info->channels = 1; + row_info->pixel_depth = row_info->bit_depth; + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + } + else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && + dither_lookup && row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++, sp++) + { + *sp = dither_lookup[*sp]; + } + } + } +} +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) +static int png_gamma_shift[] = + {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00}; + +/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit + * tables, we don't make a full table if we are reducing to 8-bit in + * the future. Note also how the gamma_16 tables are segmented so that + * we don't need to allocate > 64K chunks for a full 16-bit table. + */ +void /* PRIVATE */ +png_build_gamma_table(png_structp png_ptr) +{ + png_debug(1, "in png_build_gamma_table\n"); + + if (png_ptr->bit_depth <= 8) + { + int i; + double g; + + if (png_ptr->screen_gamma > .000001) + g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + else + g = 1.0; + + png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr, + (png_uint_32)256); + + for (i = 0; i < 256; i++) + { + png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0, + g) * 255.0 + .5); + } + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY)) + { + + g = 1.0 / (png_ptr->gamma); + + png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr, + (png_uint_32)256); + + for (i = 0; i < 256; i++) + { + png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0, + g) * 255.0 + .5); + } + + + png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr, + (png_uint_32)256); + + if(png_ptr->screen_gamma > 0.000001) + g = 1.0 / png_ptr->screen_gamma; + else + g = png_ptr->gamma; /* probably doing rgb_to_gray */ + + for (i = 0; i < 256; i++) + { + png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0, + g) * 255.0 + .5); + + } + } +#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ + } + else + { + double g; + int i, j, shift, num; + int sig_bit; + png_uint_32 ig; + + if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) + { + sig_bit = (int)png_ptr->sig_bit.red; + if ((int)png_ptr->sig_bit.green > sig_bit) + sig_bit = png_ptr->sig_bit.green; + if ((int)png_ptr->sig_bit.blue > sig_bit) + sig_bit = png_ptr->sig_bit.blue; + } + else + { + sig_bit = (int)png_ptr->sig_bit.gray; + } + + if (sig_bit > 0) + shift = 16 - sig_bit; + else + shift = 0; + + if (png_ptr->transformations & PNG_16_TO_8) + { + if (shift < (16 - PNG_MAX_GAMMA_8)) + shift = (16 - PNG_MAX_GAMMA_8); + } + + if (shift > 8) + shift = 8; + if (shift < 0) + shift = 0; + + png_ptr->gamma_shift = (png_byte)shift; + + num = (1 << (8 - shift)); + + if (png_ptr->screen_gamma > .000001) + g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + else + g = 1.0; + + png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr, + (png_uint_32)(num * png_sizeof (png_uint_16p))); + + if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) + { + double fin, fout; + png_uint_32 last, max; + + for (i = 0; i < num; i++) + { + png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(256 * png_sizeof (png_uint_16))); + } + + g = 1.0 / g; + last = 0; + for (i = 0; i < 256; i++) + { + fout = ((double)i + 0.5) / 256.0; + fin = pow(fout, g); + max = (png_uint_32)(fin * (double)((png_uint_32)num << 8)); + while (last <= max) + { + png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] + [(int)(last >> (8 - shift))] = (png_uint_16)( + (png_uint_16)i | ((png_uint_16)i << 8)); + last++; + } + } + while (last < ((png_uint_32)num << 8)) + { + png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] + [(int)(last >> (8 - shift))] = (png_uint_16)65535L; + last++; + } + } + else + { + for (i = 0; i < num; i++) + { + png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(256 * png_sizeof (png_uint_16))); + + ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); + for (j = 0; j < 256; j++) + { + png_ptr->gamma_16_table[i][j] = + (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / + 65535.0, g) * 65535.0 + .5); + } + } + } + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY)) + { + + g = 1.0 / (png_ptr->gamma); + + png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr, + (png_uint_32)(num * png_sizeof (png_uint_16p ))); + + for (i = 0; i < num; i++) + { + png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(256 * png_sizeof (png_uint_16))); + + ig = (((png_uint_32)i * + (png_uint_32)png_gamma_shift[shift]) >> 4); + for (j = 0; j < 256; j++) + { + png_ptr->gamma_16_to_1[i][j] = + (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / + 65535.0, g) * 65535.0 + .5); + } + } + + if(png_ptr->screen_gamma > 0.000001) + g = 1.0 / png_ptr->screen_gamma; + else + g = png_ptr->gamma; /* probably doing rgb_to_gray */ + + png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr, + (png_uint_32)(num * png_sizeof (png_uint_16p))); + + for (i = 0; i < num; i++) + { + png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(256 * png_sizeof (png_uint_16))); + + ig = (((png_uint_32)i * + (png_uint_32)png_gamma_shift[shift]) >> 4); + for (j = 0; j < 256; j++) + { + png_ptr->gamma_16_from_1[i][j] = + (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / + 65535.0, g) * 65535.0 + .5); + } + } + } +#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ + } +} +#endif +/* To do: install integer version of png_build_gamma_table here */ +#endif + +#if defined(PNG_MNG_FEATURES_SUPPORTED) +/* undoes intrapixel differencing */ +void /* PRIVATE */ +png_do_read_intrapixel(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_read_intrapixel\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + (row_info->color_type & PNG_COLOR_MASK_COLOR)) + { + int bytes_per_pixel; + png_uint_32 row_width = row_info->width; + if (row_info->bit_depth == 8) + { + png_bytep rp; + png_uint_32 i; + + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + bytes_per_pixel = 3; + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + bytes_per_pixel = 4; + else + return; + + for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) + { + *(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff); + *(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff); + } + } + else if (row_info->bit_depth == 16) + { + png_bytep rp; + png_uint_32 i; + + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + bytes_per_pixel = 6; + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + bytes_per_pixel = 8; + else + return; + + for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) + { + png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); + png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); + png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); + png_uint_32 red = (png_uint_32)((s0+s1+65536L) & 0xffffL); + png_uint_32 blue = (png_uint_32)((s2+s1+65536L) & 0xffffL); + *(rp ) = (png_byte)((red >> 8) & 0xff); + *(rp+1) = (png_byte)(red & 0xff); + *(rp+4) = (png_byte)((blue >> 8) & 0xff); + *(rp+5) = (png_byte)(blue & 0xff); + } + } + } +} +#endif /* PNG_MNG_FEATURES_SUPPORTED */ +#endif /* PNG_READ_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/pngrutil.c b/src/dep/src/irrlicht/libpng/pngrutil.c index a1b42fc..6157b3d 100644 --- a/src/dep/src/irrlicht/libpng/pngrutil.c +++ b/src/dep/src/irrlicht/libpng/pngrutil.c @@ -1,3126 +1,3126 @@ - -/* pngrutil.c - utilities to read a PNG file - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains routines that are only called from within - * libpng itself during the course of reading an image. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) - -#ifdef PNG_FLOATING_POINT_SUPPORTED -# if defined(_WIN32_WCE) -/* strtod() function is not supported on WindowsCE */ -__inline double png_strtod(png_structp png_ptr, const char *nptr, char **endptr) -{ - double result = 0; - int len; - wchar_t *str, *end; - - len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0); - str = (wchar_t *)png_malloc(png_ptr, len * sizeof(wchar_t)); - if ( NULL != str ) - { - MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); - result = wcstod(str, &end); - len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL); - *endptr = (char *)nptr + (png_strlen(nptr) - len + 1); - png_free(str); - } - return result; -} -# else -# define png_strtod(p,a,b) strtod(a,b) -# endif -#endif - -png_uint_32 PNGAPI -png_get_uint_31(png_structp png_ptr, png_bytep buf) -{ - png_uint_32 i = png_get_uint_32(buf); - if (i > PNG_UINT_31_MAX) - png_error(png_ptr, "PNG unsigned integer out of range."); - return (i); -} -#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED -/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ -png_uint_32 PNGAPI -png_get_uint_32(png_bytep buf) -{ - png_uint_32 i = ((png_uint_32)(*buf) << 24) + - ((png_uint_32)(*(buf + 1)) << 16) + - ((png_uint_32)(*(buf + 2)) << 8) + - (png_uint_32)(*(buf + 3)); - - return (i); -} - -/* Grab a signed 32-bit integer from a buffer in big-endian format. The - * data is stored in the PNG file in two's complement format, and it is - * assumed that the machine format for signed integers is the same. */ -png_int_32 PNGAPI -png_get_int_32(png_bytep buf) -{ - png_int_32 i = ((png_int_32)(*buf) << 24) + - ((png_int_32)(*(buf + 1)) << 16) + - ((png_int_32)(*(buf + 2)) << 8) + - (png_int_32)(*(buf + 3)); - - return (i); -} - -/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ -png_uint_16 PNGAPI -png_get_uint_16(png_bytep buf) -{ - png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) + - (png_uint_16)(*(buf + 1))); - - return (i); -} -#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ - -/* Read data, and (optionally) run it through the CRC. */ -void /* PRIVATE */ -png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) -{ - if(png_ptr == NULL) return; - png_read_data(png_ptr, buf, length); - png_calculate_crc(png_ptr, buf, length); -} - -/* Optionally skip data and then check the CRC. Depending on whether we - are reading a ancillary or critical chunk, and how the program has set - things up, we may calculate the CRC on the data and print a message. - Returns '1' if there was a CRC error, '0' otherwise. */ -int /* PRIVATE */ -png_crc_finish(png_structp png_ptr, png_uint_32 skip) -{ - png_size_t i; - png_size_t istop = png_ptr->zbuf_size; - - for (i = (png_size_t)skip; i > istop; i -= istop) - { - png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - } - if (i) - { - png_crc_read(png_ptr, png_ptr->zbuf, i); - } - - if (png_crc_error(png_ptr)) - { - if (((png_ptr->chunk_name[0] & 0x20) && /* Ancillary */ - !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) || - (!(png_ptr->chunk_name[0] & 0x20) && /* Critical */ - (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))) - { - png_chunk_warning(png_ptr, "CRC error"); - } - else - { - png_chunk_error(png_ptr, "CRC error"); - } - return (1); - } - - return (0); -} - -/* Compare the CRC stored in the PNG file with that calculated by libpng from - the data it has read thus far. */ -int /* PRIVATE */ -png_crc_error(png_structp png_ptr) -{ - png_byte crc_bytes[4]; - png_uint_32 crc; - int need_crc = 1; - - if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ - { - if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == - (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) - need_crc = 0; - } - else /* critical */ - { - if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) - need_crc = 0; - } - - png_read_data(png_ptr, crc_bytes, 4); - - if (need_crc) - { - crc = png_get_uint_32(crc_bytes); - return ((int)(crc != png_ptr->crc)); - } - else - return (0); -} - -#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \ - defined(PNG_READ_iCCP_SUPPORTED) -/* - * Decompress trailing data in a chunk. The assumption is that chunkdata - * points at an allocated area holding the contents of a chunk with a - * trailing compressed part. What we get back is an allocated area - * holding the original prefix part and an uncompressed version of the - * trailing part (the malloc area passed in is freed). - */ -png_charp /* PRIVATE */ -png_decompress_chunk(png_structp png_ptr, int comp_type, - png_charp chunkdata, png_size_t chunklength, - png_size_t prefix_size, png_size_t *newlength) -{ - static char msg[] = "Error decoding compressed text"; - png_charp text; - png_size_t text_size; - - if (comp_type == PNG_COMPRESSION_TYPE_BASE) - { - int ret = Z_OK; - png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size); - png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - text_size = 0; - text = NULL; - - while (png_ptr->zstream.avail_in) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK && ret != Z_STREAM_END) - { - if (png_ptr->zstream.msg != NULL) - png_warning(png_ptr, png_ptr->zstream.msg); - else - png_warning(png_ptr, msg); - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - if (text == NULL) - { - text_size = prefix_size + png_sizeof(msg) + 1; - text = (png_charp)png_malloc_warn(png_ptr, text_size); - if (text == NULL) - { - png_free(png_ptr,chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk"); - } - png_memcpy(text, chunkdata, prefix_size); - } - - text[text_size - 1] = 0x00; - - /* Copy what we can of the error message into the text chunk */ - text_size = (png_size_t)(chunklength - (text - chunkdata) - 1); - text_size = png_sizeof(msg) > text_size ? text_size : - png_sizeof(msg); - png_memcpy(text + prefix_size, msg, text_size + 1); - break; - } - if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END) - { - if (text == NULL) - { - text_size = prefix_size + - png_ptr->zbuf_size - png_ptr->zstream.avail_out; - text = (png_charp)png_malloc_warn(png_ptr, text_size + 1); - if (text == NULL) - { - png_free(png_ptr,chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk."); - } - png_memcpy(text + prefix_size, png_ptr->zbuf, - text_size - prefix_size); - png_memcpy(text, chunkdata, prefix_size); - *(text + text_size) = 0x00; - } - else - { - png_charp tmp; - - tmp = text; - text = (png_charp)png_malloc_warn(png_ptr, - (png_uint_32)(text_size + - png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); - if (text == NULL) - { - png_free(png_ptr, tmp); - png_free(png_ptr, chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk.."); - } - png_memcpy(text, tmp, text_size); - png_free(png_ptr, tmp); - png_memcpy(text + text_size, png_ptr->zbuf, - (png_ptr->zbuf_size - png_ptr->zstream.avail_out)); - text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; - *(text + text_size) = 0x00; - } - if (ret == Z_STREAM_END) - break; - else - { - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - } - if (ret != Z_STREAM_END) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char umsg[52]; - - if (ret == Z_BUF_ERROR) - sprintf(umsg,"Buffer error in compressed datastream in %s chunk", - png_ptr->chunk_name); - else if (ret == Z_DATA_ERROR) - sprintf(umsg,"Data error in compressed datastream in %s chunk", - png_ptr->chunk_name); - else - sprintf(umsg,"Incomplete compressed datastream in %s chunk", - png_ptr->chunk_name); - png_warning(png_ptr, umsg); -#else - png_warning(png_ptr, - "Incomplete compressed datastream in chunk other than IDAT"); -#endif - text_size=prefix_size; - if (text == NULL) - { - text = (png_charp)png_malloc_warn(png_ptr, text_size+1); - if (text == NULL) - { - png_free(png_ptr, chunkdata); - png_error(png_ptr,"Not enough memory for text."); - } - png_memcpy(text, chunkdata, prefix_size); - } - *(text + text_size) = 0x00; - } - - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - png_free(png_ptr, chunkdata); - chunkdata = text; - *newlength=text_size; - } - else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */ - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char umsg[50]; - - sprintf(umsg, "Unknown zTXt compression type %d", comp_type); - png_warning(png_ptr, umsg); -#else - png_warning(png_ptr, "Unknown zTXt compression type"); -#endif - - *(chunkdata + prefix_size) = 0x00; - *newlength=prefix_size; - } - - return chunkdata; -} -#endif - -/* read and check the IDHR chunk */ -void /* PRIVATE */ -png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[13]; - png_uint_32 width, height; - int bit_depth, color_type, compression_type, filter_type; - int interlace_type; - - png_debug(1, "in png_handle_IHDR\n"); - - if (png_ptr->mode & PNG_HAVE_IHDR) - png_error(png_ptr, "Out of place IHDR"); - - /* check the length */ - if (length != 13) - png_error(png_ptr, "Invalid IHDR chunk"); - - png_ptr->mode |= PNG_HAVE_IHDR; - - png_crc_read(png_ptr, buf, 13); - png_crc_finish(png_ptr, 0); - - width = png_get_uint_31(png_ptr, buf); - height = png_get_uint_31(png_ptr, buf + 4); - bit_depth = buf[8]; - color_type = buf[9]; - compression_type = buf[10]; - filter_type = buf[11]; - interlace_type = buf[12]; - - /* set internal variables */ - png_ptr->width = width; - png_ptr->height = height; - png_ptr->bit_depth = (png_byte)bit_depth; - png_ptr->interlaced = (png_byte)interlace_type; - png_ptr->color_type = (png_byte)color_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_ptr->filter_type = (png_byte)filter_type; -#endif - png_ptr->compression_type = (png_byte)compression_type; - - /* find number of channels */ - switch (png_ptr->color_type) - { - case PNG_COLOR_TYPE_GRAY: - case PNG_COLOR_TYPE_PALETTE: - png_ptr->channels = 1; - break; - case PNG_COLOR_TYPE_RGB: - png_ptr->channels = 3; - break; - case PNG_COLOR_TYPE_GRAY_ALPHA: - png_ptr->channels = 2; - break; - case PNG_COLOR_TYPE_RGB_ALPHA: - png_ptr->channels = 4; - break; - } - - /* set up other useful info */ - png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * - png_ptr->channels); - png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width); - png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth); - png_debug1(3,"channels = %d\n", png_ptr->channels); - png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes); - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, - color_type, interlace_type, compression_type, filter_type); -} - -/* read and check the palette */ -void /* PRIVATE */ -png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_color palette[PNG_MAX_PALETTE_LENGTH]; - int num, i; -#ifndef PNG_NO_POINTER_INDEXING - png_colorp pal_ptr; -#endif - - png_debug(1, "in png_handle_PLTE\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before PLTE"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid PLTE after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - png_error(png_ptr, "Duplicate PLTE chunk"); - - png_ptr->mode |= PNG_HAVE_PLTE; - - if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) - { - png_warning(png_ptr, - "Ignoring PLTE chunk in grayscale PNG"); - png_crc_finish(png_ptr, length); - return; - } -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - { - png_crc_finish(png_ptr, length); - return; - } -#endif - - if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3) - { - if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - { - png_warning(png_ptr, "Invalid palette chunk"); - png_crc_finish(png_ptr, length); - return; - } - else - { - png_error(png_ptr, "Invalid palette chunk"); - } - } - - num = (int)length / 3; - -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++) - { - png_byte buf[3]; - - png_crc_read(png_ptr, buf, 3); - pal_ptr->red = buf[0]; - pal_ptr->green = buf[1]; - pal_ptr->blue = buf[2]; - } -#else - for (i = 0; i < num; i++) - { - png_byte buf[3]; - - png_crc_read(png_ptr, buf, 3); - /* don't depend upon png_color being any order */ - palette[i].red = buf[0]; - palette[i].green = buf[1]; - palette[i].blue = buf[2]; - } -#endif - - /* If we actually NEED the PLTE chunk (ie for a paletted image), we do - whatever the normal CRC configuration tells us. However, if we - have an RGB image, the PLTE can be considered ancillary, so - we will act as though it is. */ -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#endif - { - png_crc_finish(png_ptr, 0); - } -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */ - { - /* If we don't want to use the data from an ancillary chunk, - we have two options: an error abort, or a warning and we - ignore the data in this chunk (which should be OK, since - it's considered ancillary for a RGB or RGBA image). */ - if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)) - { - if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) - { - png_chunk_error(png_ptr, "CRC error"); - } - else - { - png_chunk_warning(png_ptr, "CRC error"); - return; - } - } - /* Otherwise, we (optionally) emit a warning and use the chunk. */ - else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) - { - png_chunk_warning(png_ptr, "CRC error"); - } - } -#endif - - png_set_PLTE(png_ptr, info_ptr, palette, num); - -#if defined(PNG_READ_tRNS_SUPPORTED) - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - if (png_ptr->num_trans > (png_uint_16)num) - { - png_warning(png_ptr, "Truncating incorrect tRNS chunk length"); - png_ptr->num_trans = (png_uint_16)num; - } - if (info_ptr->num_trans > (png_uint_16)num) - { - png_warning(png_ptr, "Truncating incorrect info tRNS chunk length"); - info_ptr->num_trans = (png_uint_16)num; - } - } - } -#endif - -} - -void /* PRIVATE */ -png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_debug(1, "in png_handle_IEND\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) - { - png_error(png_ptr, "No image in file"); - } - - png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); - - if (length != 0) - { - png_warning(png_ptr, "Incorrect IEND chunk length"); - } - png_crc_finish(png_ptr, length); - - if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */ - return; -} - -#if defined(PNG_READ_gAMA_SUPPORTED) -void /* PRIVATE */ -png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_fixed_point igamma; -#ifdef PNG_FLOATING_POINT_SUPPORTED - float file_gamma; -#endif - png_byte buf[4]; - - png_debug(1, "in png_handle_gAMA\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before gAMA"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid gAMA after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place gAMA chunk"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) -#if defined(PNG_READ_sRGB_SUPPORTED) - && !(info_ptr->valid & PNG_INFO_sRGB) -#endif - ) - { - png_warning(png_ptr, "Duplicate gAMA chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 4) - { - png_warning(png_ptr, "Incorrect gAMA chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 4); - if (png_crc_finish(png_ptr, 0)) - return; - - igamma = (png_fixed_point)png_get_uint_32(buf); - /* check for zero gamma */ - if (igamma == 0) - { - png_warning(png_ptr, - "Ignoring gAMA chunk with gamma=0"); - return; - } - -#if defined(PNG_READ_sRGB_SUPPORTED) - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) - if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) - { - png_warning(png_ptr, - "Ignoring incorrect gAMA value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO - fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma); -#endif - return; - } -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - file_gamma = (float)igamma / (float)100000.0; -# ifdef PNG_READ_GAMMA_SUPPORTED - png_ptr->gamma = file_gamma; -# endif - png_set_gAMA(png_ptr, info_ptr, file_gamma); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_gAMA_fixed(png_ptr, info_ptr, igamma); -#endif -} -#endif - -#if defined(PNG_READ_sBIT_SUPPORTED) -void /* PRIVATE */ -png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_size_t truelen; - png_byte buf[4]; - - png_debug(1, "in png_handle_sBIT\n"); - - buf[0] = buf[1] = buf[2] = buf[3] = 0; - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sBIT"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sBIT after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - { - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place sBIT chunk"); - } - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)) - { - png_warning(png_ptr, "Duplicate sBIT chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - truelen = 3; - else - truelen = (png_size_t)png_ptr->channels; - - if (length != truelen || length > 4) - { - png_warning(png_ptr, "Incorrect sBIT chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, truelen); - if (png_crc_finish(png_ptr, 0)) - return; - - if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - { - png_ptr->sig_bit.red = buf[0]; - png_ptr->sig_bit.green = buf[1]; - png_ptr->sig_bit.blue = buf[2]; - png_ptr->sig_bit.alpha = buf[3]; - } - else - { - png_ptr->sig_bit.gray = buf[0]; - png_ptr->sig_bit.red = buf[0]; - png_ptr->sig_bit.green = buf[0]; - png_ptr->sig_bit.blue = buf[0]; - png_ptr->sig_bit.alpha = buf[1]; - } - png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit)); -} -#endif - -#if defined(PNG_READ_cHRM_SUPPORTED) -void /* PRIVATE */ -png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[4]; -#ifdef PNG_FLOATING_POINT_SUPPORTED - float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; -#endif - png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, - int_y_green, int_x_blue, int_y_blue; - - png_uint_32 uint_x, uint_y; - - png_debug(1, "in png_handle_cHRM\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before cHRM"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid cHRM after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Missing PLTE before cHRM"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM) -#if defined(PNG_READ_sRGB_SUPPORTED) - && !(info_ptr->valid & PNG_INFO_sRGB) -#endif - ) - { - png_warning(png_ptr, "Duplicate cHRM chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 32) - { - png_warning(png_ptr, "Incorrect cHRM chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x > 80000L || uint_y > 80000L || - uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM white point"); - png_crc_finish(png_ptr, 24); - return; - } - int_x_white = (png_fixed_point)uint_x; - int_y_white = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM red point"); - png_crc_finish(png_ptr, 16); - return; - } - int_x_red = (png_fixed_point)uint_x; - int_y_red = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM green point"); - png_crc_finish(png_ptr, 8); - return; - } - int_x_green = (png_fixed_point)uint_x; - int_y_green = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM blue point"); - png_crc_finish(png_ptr, 0); - return; - } - int_x_blue = (png_fixed_point)uint_x; - int_y_blue = (png_fixed_point)uint_y; - -#ifdef PNG_FLOATING_POINT_SUPPORTED - white_x = (float)int_x_white / (float)100000.0; - white_y = (float)int_y_white / (float)100000.0; - red_x = (float)int_x_red / (float)100000.0; - red_y = (float)int_y_red / (float)100000.0; - green_x = (float)int_x_green / (float)100000.0; - green_y = (float)int_y_green / (float)100000.0; - blue_x = (float)int_x_blue / (float)100000.0; - blue_y = (float)int_y_blue / (float)100000.0; -#endif - -#if defined(PNG_READ_sRGB_SUPPORTED) - if ((info_ptr != NULL) && (info_ptr->valid & PNG_INFO_sRGB)) - { - if (PNG_OUT_OF_RANGE(int_x_white, 31270, 1000) || - PNG_OUT_OF_RANGE(int_y_white, 32900, 1000) || - PNG_OUT_OF_RANGE(int_x_red, 64000L, 1000) || - PNG_OUT_OF_RANGE(int_y_red, 33000, 1000) || - PNG_OUT_OF_RANGE(int_x_green, 30000, 1000) || - PNG_OUT_OF_RANGE(int_y_green, 60000L, 1000) || - PNG_OUT_OF_RANGE(int_x_blue, 15000, 1000) || - PNG_OUT_OF_RANGE(int_y_blue, 6000, 1000)) - { - png_warning(png_ptr, - "Ignoring incorrect cHRM value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO -#ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n", - white_x, white_y, red_x, red_y); - fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n", - green_x, green_y, blue_x, blue_y); -#else - fprintf(stderr,"wx=%ld, wy=%ld, rx=%ld, ry=%ld\n", - int_x_white, int_y_white, int_x_red, int_y_red); - fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n", - int_x_green, int_y_green, int_x_blue, int_y_blue); -#endif -#endif /* PNG_NO_CONSOLE_IO */ - } - png_crc_finish(png_ptr, 0); - return; - } -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_cHRM_fixed(png_ptr, info_ptr, - int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, - int_y_green, int_x_blue, int_y_blue); -#endif - if (png_crc_finish(png_ptr, 0)) - return; -} -#endif - -#if defined(PNG_READ_sRGB_SUPPORTED) -void /* PRIVATE */ -png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - int intent; - png_byte buf[1]; - - png_debug(1, "in png_handle_sRGB\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sRGB"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sRGB after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place sRGB chunk"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) - { - png_warning(png_ptr, "Duplicate sRGB chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 1) - { - png_warning(png_ptr, "Incorrect sRGB chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 1); - if (png_crc_finish(png_ptr, 0)) - return; - - intent = buf[0]; - /* check for bad intent */ - if (intent >= PNG_sRGB_INTENT_LAST) - { - png_warning(png_ptr, "Unknown sRGB intent"); - return; - } - -#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)) - { - png_fixed_point igamma; -#ifdef PNG_FIXED_POINT_SUPPORTED - igamma=info_ptr->int_gamma; -#else -# ifdef PNG_FLOATING_POINT_SUPPORTED - igamma=(png_fixed_point)(info_ptr->gamma * 100000.); -# endif -#endif - if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) - { - png_warning(png_ptr, - "Ignoring incorrect gAMA value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO -# ifdef PNG_FIXED_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma); -# else -# ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma); -# endif -# endif -#endif - } - } -#endif /* PNG_READ_gAMA_SUPPORTED */ - -#ifdef PNG_READ_cHRM_SUPPORTED -#ifdef PNG_FIXED_POINT_SUPPORTED - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - if (PNG_OUT_OF_RANGE(info_ptr->int_x_white, 31270, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_white, 32900, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_red, 64000L, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_red, 33000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_green, 30000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_green, 60000L, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_blue, 15000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_blue, 6000, 1000)) - { - png_warning(png_ptr, - "Ignoring incorrect cHRM value when sRGB is also present"); - } -#endif /* PNG_FIXED_POINT_SUPPORTED */ -#endif /* PNG_READ_cHRM_SUPPORTED */ - - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent); -} -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#if defined(PNG_READ_iCCP_SUPPORTED) -void /* PRIVATE */ -png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -{ - png_charp chunkdata; - png_byte compression_type; - png_bytep pC; - png_charp profile; - png_uint_32 skip = 0; - png_uint_32 profile_size, profile_length; - png_size_t slength, prefix_length, data_length; - - png_debug(1, "in png_handle_iCCP\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before iCCP"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid iCCP after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place iCCP chunk"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)) - { - png_warning(png_ptr, "Duplicate iCCP chunk"); - png_crc_finish(png_ptr, length); - return; - } - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "iCCP chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - chunkdata = (png_charp)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (profile = chunkdata; *profile; profile++) - /* empty loop to find end of name */ ; - - ++profile; - - /* there should be at least one zero (the compression type byte) - following the separator, and we should be on it */ - if ( profile >= chunkdata + slength) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Malformed iCCP chunk"); - return; - } - - /* compression_type should always be zero */ - compression_type = *profile++; - if (compression_type) - { - png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk"); - compression_type=0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8 - wrote nonzero) */ - } - - prefix_length = profile - chunkdata; - chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata, - slength, prefix_length, &data_length); - - profile_length = data_length - prefix_length; - - if ( prefix_length > data_length || profile_length < 4) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Profile size field missing from iCCP chunk"); - return; - } - - /* Check the profile_size recorded in the first 32 bits of the ICC profile */ - pC = (png_bytep)(chunkdata+prefix_length); - profile_size = ((*(pC ))<<24) | - ((*(pC+1))<<16) | - ((*(pC+2))<< 8) | - ((*(pC+3)) ); - - if(profile_size < profile_length) - profile_length = profile_size; - - if(profile_size > profile_length) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Ignoring truncated iCCP profile."); - return; - } - - png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type, - chunkdata + prefix_length, profile_length); - png_free(png_ptr, chunkdata); -} -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#if defined(PNG_READ_sPLT_SUPPORTED) -void /* PRIVATE */ -png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -{ - png_bytep chunkdata; - png_bytep entry_start; - png_sPLT_t new_palette; -#ifdef PNG_NO_POINTER_INDEXING - png_sPLT_entryp pp; -#endif - int data_length, entry_size, i; - png_uint_32 skip = 0; - png_size_t slength; - - png_debug(1, "in png_handle_sPLT\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sPLT"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sPLT after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "sPLT chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - chunkdata = (png_bytep)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (entry_start = chunkdata; *entry_start; entry_start++) - /* empty loop to find end of name */ ; - ++entry_start; - - /* a sample depth should follow the separator, and we should be on it */ - if (entry_start > chunkdata + slength) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "malformed sPLT chunk"); - return; - } - - new_palette.depth = *entry_start++; - entry_size = (new_palette.depth == 8 ? 6 : 10); - data_length = (slength - (entry_start - chunkdata)); - - /* integrity-check the data length */ - if (data_length % entry_size) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "sPLT chunk has bad length"); - return; - } - - new_palette.nentries = (png_int_32) ( data_length / entry_size); - if ((png_uint_32) new_palette.nentries > (png_uint_32) (PNG_SIZE_MAX / - png_sizeof(png_sPLT_entry))) - { - png_warning(png_ptr, "sPLT chunk too long"); - return; - } - new_palette.entries = (png_sPLT_entryp)png_malloc_warn( - png_ptr, new_palette.nentries * png_sizeof(png_sPLT_entry)); - if (new_palette.entries == NULL) - { - png_warning(png_ptr, "sPLT chunk requires too much memory"); - return; - } - -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0; i < new_palette.nentries; i++) - { - png_sPLT_entryp pp = new_palette.entries + i; - - if (new_palette.depth == 8) - { - pp->red = *entry_start++; - pp->green = *entry_start++; - pp->blue = *entry_start++; - pp->alpha = *entry_start++; - } - else - { - pp->red = png_get_uint_16(entry_start); entry_start += 2; - pp->green = png_get_uint_16(entry_start); entry_start += 2; - pp->blue = png_get_uint_16(entry_start); entry_start += 2; - pp->alpha = png_get_uint_16(entry_start); entry_start += 2; - } - pp->frequency = png_get_uint_16(entry_start); entry_start += 2; - } -#else - pp = new_palette.entries; - for (i = 0; i < new_palette.nentries; i++) - { - - if (new_palette.depth == 8) - { - pp[i].red = *entry_start++; - pp[i].green = *entry_start++; - pp[i].blue = *entry_start++; - pp[i].alpha = *entry_start++; - } - else - { - pp[i].red = png_get_uint_16(entry_start); entry_start += 2; - pp[i].green = png_get_uint_16(entry_start); entry_start += 2; - pp[i].blue = png_get_uint_16(entry_start); entry_start += 2; - pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2; - } - pp->frequency = png_get_uint_16(entry_start); entry_start += 2; - } -#endif - - /* discard all chunk data except the name and stash that */ - new_palette.name = (png_charp)chunkdata; - - png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); - - png_free(png_ptr, chunkdata); - png_free(png_ptr, new_palette.entries); -} -#endif /* PNG_READ_sPLT_SUPPORTED */ - -#if defined(PNG_READ_tRNS_SUPPORTED) -void /* PRIVATE */ -png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; - - png_debug(1, "in png_handle_tRNS\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before tRNS"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid tRNS after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - png_warning(png_ptr, "Duplicate tRNS chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - png_byte buf[2]; - - if (length != 2) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 2); - png_ptr->num_trans = 1; - png_ptr->trans_values.gray = png_get_uint_16(buf); - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - png_byte buf[6]; - - if (length != 6) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - png_crc_read(png_ptr, buf, (png_size_t)length); - png_ptr->num_trans = 1; - png_ptr->trans_values.red = png_get_uint_16(buf); - png_ptr->trans_values.green = png_get_uint_16(buf + 2); - png_ptr->trans_values.blue = png_get_uint_16(buf + 4); - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (!(png_ptr->mode & PNG_HAVE_PLTE)) - { - /* Should be an error, but we can cope with it. */ - png_warning(png_ptr, "Missing PLTE before tRNS"); - } - if (length > (png_uint_32)png_ptr->num_palette || - length > PNG_MAX_PALETTE_LENGTH) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - if (length == 0) - { - png_warning(png_ptr, "Zero length tRNS chunk"); - png_crc_finish(png_ptr, length); - return; - } - png_crc_read(png_ptr, readbuf, (png_size_t)length); - png_ptr->num_trans = (png_uint_16)length; - } - else - { - png_warning(png_ptr, "tRNS chunk not allowed with alpha channel"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_crc_finish(png_ptr, 0)) - return; - - png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans, - &(png_ptr->trans_values)); -} -#endif - -#if defined(PNG_READ_bKGD_SUPPORTED) -void /* PRIVATE */ -png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_size_t truelen; - png_byte buf[6]; - - png_debug(1, "in png_handle_bKGD\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before bKGD"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid bKGD after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - { - png_warning(png_ptr, "Missing PLTE before bKGD"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)) - { - png_warning(png_ptr, "Duplicate bKGD chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - truelen = 1; - else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - truelen = 6; - else - truelen = 2; - - if (length != truelen) - { - png_warning(png_ptr, "Incorrect bKGD chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, truelen); - if (png_crc_finish(png_ptr, 0)) - return; - - /* We convert the index value into RGB components so that we can allow - * arbitrary RGB values for background when we have transparency, and - * so it is easy to determine the RGB values of the background color - * from the info_ptr struct. */ - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_ptr->background.index = buf[0]; - if(info_ptr->num_palette) - { - if(buf[0] > info_ptr->num_palette) - { - png_warning(png_ptr, "Incorrect bKGD chunk index value"); - return; - } - png_ptr->background.red = - (png_uint_16)png_ptr->palette[buf[0]].red; - png_ptr->background.green = - (png_uint_16)png_ptr->palette[buf[0]].green; - png_ptr->background.blue = - (png_uint_16)png_ptr->palette[buf[0]].blue; - } - } - else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */ - { - png_ptr->background.red = - png_ptr->background.green = - png_ptr->background.blue = - png_ptr->background.gray = png_get_uint_16(buf); - } - else - { - png_ptr->background.red = png_get_uint_16(buf); - png_ptr->background.green = png_get_uint_16(buf + 2); - png_ptr->background.blue = png_get_uint_16(buf + 4); - } - - png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background)); -} -#endif - -#if defined(PNG_READ_hIST_SUPPORTED) -void /* PRIVATE */ -png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - unsigned int num, i; - png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; - - png_debug(1, "in png_handle_hIST\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before hIST"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid hIST after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (!(png_ptr->mode & PNG_HAVE_PLTE)) - { - png_warning(png_ptr, "Missing PLTE before hIST"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)) - { - png_warning(png_ptr, "Duplicate hIST chunk"); - png_crc_finish(png_ptr, length); - return; - } - - num = length / 2 ; - if (num != (unsigned int) png_ptr->num_palette || num > - (unsigned int) PNG_MAX_PALETTE_LENGTH) - { - png_warning(png_ptr, "Incorrect hIST chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - for (i = 0; i < num; i++) - { - png_byte buf[2]; - - png_crc_read(png_ptr, buf, 2); - readbuf[i] = png_get_uint_16(buf); - } - - if (png_crc_finish(png_ptr, 0)) - return; - - png_set_hIST(png_ptr, info_ptr, readbuf); -} -#endif - -#if defined(PNG_READ_pHYs_SUPPORTED) -void /* PRIVATE */ -png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[9]; - png_uint_32 res_x, res_y; - int unit_type; - - png_debug(1, "in png_handle_pHYs\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before pHYs"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid pHYs after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) - { - png_warning(png_ptr, "Duplicate pHYs chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 9) - { - png_warning(png_ptr, "Incorrect pHYs chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 9); - if (png_crc_finish(png_ptr, 0)) - return; - - res_x = png_get_uint_32(buf); - res_y = png_get_uint_32(buf + 4); - unit_type = buf[8]; - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type); -} -#endif - -#if defined(PNG_READ_oFFs_SUPPORTED) -void /* PRIVATE */ -png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[9]; - png_int_32 offset_x, offset_y; - int unit_type; - - png_debug(1, "in png_handle_oFFs\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before oFFs"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid oFFs after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) - { - png_warning(png_ptr, "Duplicate oFFs chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 9) - { - png_warning(png_ptr, "Incorrect oFFs chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 9); - if (png_crc_finish(png_ptr, 0)) - return; - - offset_x = png_get_int_32(buf); - offset_y = png_get_int_32(buf + 4); - unit_type = buf[8]; - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type); -} -#endif - -#if defined(PNG_READ_pCAL_SUPPORTED) -/* read the pCAL chunk (described in the PNG Extensions document) */ -void /* PRIVATE */ -png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_charp purpose; - png_int_32 X0, X1; - png_byte type, nparams; - png_charp buf, units, endptr; - png_charpp params; - png_size_t slength; - int i; - - png_debug(1, "in png_handle_pCAL\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before pCAL"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid pCAL after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)) - { - png_warning(png_ptr, "Duplicate pCAL chunk"); - png_crc_finish(png_ptr, length); - return; - } - - png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n", - length + 1); - purpose = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (purpose == NULL) - { - png_warning(png_ptr, "No memory for pCAL purpose."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)purpose, slength); - - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, purpose); - return; - } - - purpose[slength] = 0x00; /* null terminate the last string */ - - png_debug(3, "Finding end of pCAL purpose string\n"); - for (buf = purpose; *buf; buf++) - /* empty loop */ ; - - endptr = purpose + slength; - - /* We need to have at least 12 bytes after the purpose string - in order to get the parameter information. */ - if (endptr <= buf + 12) - { - png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); - return; - } - - png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n"); - X0 = png_get_int_32((png_bytep)buf+1); - X1 = png_get_int_32((png_bytep)buf+5); - type = buf[9]; - nparams = buf[10]; - units = buf + 11; - - png_debug(3, "Checking pCAL equation type and number of parameters\n"); - /* Check that we have the right number of parameters for known - equation types. */ - if ((type == PNG_EQUATION_LINEAR && nparams != 2) || - (type == PNG_EQUATION_BASE_E && nparams != 3) || - (type == PNG_EQUATION_ARBITRARY && nparams != 3) || - (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) - { - png_warning(png_ptr, "Invalid pCAL parameters for equation type"); - png_free(png_ptr, purpose); - return; - } - else if (type >= PNG_EQUATION_LAST) - { - png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); - } - - for (buf = units; *buf; buf++) - /* Empty loop to move past the units string. */ ; - - png_debug(3, "Allocating pCAL parameters array\n"); - params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams - *png_sizeof(png_charp))) ; - if (params == NULL) - { - png_free(png_ptr, purpose); - png_warning(png_ptr, "No memory for pCAL params."); - return; - } - - /* Get pointers to the start of each parameter string. */ - for (i = 0; i < (int)nparams; i++) - { - buf++; /* Skip the null string terminator from previous parameter. */ - - png_debug1(3, "Reading pCAL parameter %d\n", i); - for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++) - /* Empty loop to move past each parameter string */ ; - - /* Make sure we haven't run out of data yet */ - if (buf > endptr) - { - png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); - png_free(png_ptr, params); - return; - } - } - - png_set_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams, - units, params); - - png_free(png_ptr, purpose); - png_free(png_ptr, params); -} -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) -/* read the sCAL chunk */ -void /* PRIVATE */ -png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_charp buffer, ep; -#ifdef PNG_FLOATING_POINT_SUPPORTED - double width, height; - png_charp vp; -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_charp swidth, sheight; -#endif -#endif - png_size_t slength; - - png_debug(1, "in png_handle_sCAL\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sCAL"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sCAL after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) - { - png_warning(png_ptr, "Duplicate sCAL chunk"); - png_crc_finish(png_ptr, length); - return; - } - - png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n", - length + 1); - buffer = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (buffer == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk"); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)buffer, slength); - - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, buffer); - return; - } - - buffer[slength] = 0x00; /* null terminate the last string */ - - ep = buffer + 1; /* skip unit byte */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - width = png_strtod(png_ptr, ep, &vp); - if (*vp) - { - png_warning(png_ptr, "malformed width string in sCAL chunk"); - return; - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); - if (swidth == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk width"); - return; - } - png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); -#endif -#endif - - for (ep = buffer; *ep; ep++) - /* empty loop */ ; - ep++; - -#ifdef PNG_FLOATING_POINT_SUPPORTED - height = png_strtod(png_ptr, ep, &vp); - if (*vp) - { - png_warning(png_ptr, "malformed height string in sCAL chunk"); - return; - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); - if (swidth == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); - return; - } - png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); -#endif -#endif - - if (buffer + slength < ep -#ifdef PNG_FLOATING_POINT_SUPPORTED - || width <= 0. || height <= 0. -#endif - ) - { - png_warning(png_ptr, "Invalid sCAL data"); - png_free(png_ptr, buffer); -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); - png_free(png_ptr, sheight); -#endif - return; - } - - -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_sCAL(png_ptr, info_ptr, buffer[0], width, height); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_sCAL_s(png_ptr, info_ptr, buffer[0], swidth, sheight); -#endif -#endif - - png_free(png_ptr, buffer); -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); - png_free(png_ptr, sheight); -#endif -} -#endif - -#if defined(PNG_READ_tIME_SUPPORTED) -void /* PRIVATE */ -png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[7]; - png_time mod_time; - - png_debug(1, "in png_handle_tIME\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Out of place tIME chunk"); - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)) - { - png_warning(png_ptr, "Duplicate tIME chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - - if (length != 7) - { - png_warning(png_ptr, "Incorrect tIME chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 7); - if (png_crc_finish(png_ptr, 0)) - return; - - mod_time.second = buf[6]; - mod_time.minute = buf[5]; - mod_time.hour = buf[4]; - mod_time.day = buf[3]; - mod_time.month = buf[2]; - mod_time.year = png_get_uint_16(buf); - - png_set_tIME(png_ptr, info_ptr, &mod_time); -} -#endif - -#if defined(PNG_READ_tEXt_SUPPORTED) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp key; - png_charp text; - png_uint_32 skip = 0; - png_size_t slength; - int ret; - - png_debug(1, "in png_handle_tEXt\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before tEXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "tEXt chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - key = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (key == NULL) - { - png_warning(png_ptr, "No memory to process text chunk."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)key, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, key); - return; - } - - key[slength] = 0x00; - - for (text = key; *text; text++) - /* empty loop to find end of key */ ; - - if (text != key + slength) - text++; - - text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); - if (text_ptr == NULL) - { - png_warning(png_ptr, "Not enough memory to process text chunk."); - png_free(png_ptr, key); - return; - } - text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; - text_ptr->itxt_length = 0; -#endif - text_ptr->text = text; - text_ptr->text_length = png_strlen(text); - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - if (ret) - png_warning(png_ptr, "Insufficient memory to process text chunk."); -} -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -/* note: this does not correctly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp chunkdata; - png_charp text; - int comp_type; - int ret; - png_size_t slength, prefix_len, data_len; - - png_debug(1, "in png_handle_zTXt\n"); - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before zTXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - /* We will no doubt have problems with chunks even half this size, but - there is no hard and fast rule to tell us where to stop. */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr,"zTXt chunk too large to fit in memory"); - png_crc_finish(png_ptr, length); - return; - } -#endif - - chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (chunkdata == NULL) - { - png_warning(png_ptr,"Out of memory processing zTXt chunk."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (text = chunkdata; *text; text++) - /* empty loop */ ; - - /* zTXt must have some text after the chunkdataword */ - if (text == chunkdata + slength) - { - comp_type = PNG_TEXT_COMPRESSION_NONE; - png_warning(png_ptr, "Zero length zTXt chunk"); - } - else - { - comp_type = *(++text); - if (comp_type != PNG_TEXT_COMPRESSION_zTXt) - { - png_warning(png_ptr, "Unknown compression type in zTXt chunk"); - comp_type = PNG_TEXT_COMPRESSION_zTXt; - } - text++; /* skip the compression_method byte */ - } - prefix_len = text - chunkdata; - - chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata, - (png_size_t)length, prefix_len, &data_len); - - text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); - if (text_ptr == NULL) - { - png_warning(png_ptr,"Not enough memory to process zTXt chunk."); - png_free(png_ptr, chunkdata); - return; - } - text_ptr->compression = comp_type; - text_ptr->key = chunkdata; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; - text_ptr->itxt_length = 0; -#endif - text_ptr->text = chunkdata + prefix_len; - text_ptr->text_length = data_len; - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); - if (ret) - png_error(png_ptr, "Insufficient memory to store zTXt chunk."); -} -#endif - -#if defined(PNG_READ_iTXt_SUPPORTED) -/* note: this does not correctly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp chunkdata; - png_charp key, lang, text, lang_key; - int comp_flag; - int comp_type = 0; - int ret; - png_size_t slength, prefix_len, data_len; - - png_debug(1, "in png_handle_iTXt\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before iTXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - /* We will no doubt have problems with chunks even half this size, but - there is no hard and fast rule to tell us where to stop. */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr,"iTXt chunk too large to fit in memory"); - png_crc_finish(png_ptr, length); - return; - } -#endif - - chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (chunkdata == NULL) - { - png_warning(png_ptr, "No memory to process iTXt chunk."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (lang = chunkdata; *lang; lang++) - /* empty loop */ ; - lang++; /* skip NUL separator */ - - /* iTXt must have a language tag (possibly empty), two compression bytes, - translated keyword (possibly empty), and possibly some text after the - keyword */ - - if (lang >= chunkdata + slength) - { - comp_flag = PNG_TEXT_COMPRESSION_NONE; - png_warning(png_ptr, "Zero length iTXt chunk"); - } - else - { - comp_flag = *lang++; - comp_type = *lang++; - } - - for (lang_key = lang; *lang_key; lang_key++) - /* empty loop */ ; - lang_key++; /* skip NUL separator */ - - for (text = lang_key; *text; text++) - /* empty loop */ ; - text++; /* skip NUL separator */ - - prefix_len = text - chunkdata; - - key=chunkdata; - if (comp_flag) - chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata, - (size_t)length, prefix_len, &data_len); - else - data_len=png_strlen(chunkdata + prefix_len); - text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); - if (text_ptr == NULL) - { - png_warning(png_ptr,"Not enough memory to process iTXt chunk."); - png_free(png_ptr, chunkdata); - return; - } - text_ptr->compression = (int)comp_flag + 1; - text_ptr->lang_key = chunkdata+(lang_key-key); - text_ptr->lang = chunkdata+(lang-key); - text_ptr->itxt_length = data_len; - text_ptr->text_length = 0; - text_ptr->key = chunkdata; - text_ptr->text = chunkdata + prefix_len; - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); - if (ret) - png_error(png_ptr, "Insufficient memory to store iTXt chunk."); -} -#endif - -/* This function is called when we haven't found a handler for a - chunk. If there isn't a problem with the chunk itself (ie bad - chunk name, CRC, or a critical chunk), the chunk is silently ignored - -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which - case it will be saved away to be written out later. */ -void /* PRIVATE */ -png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_uint_32 skip = 0; - - png_debug(1, "in png_handle_unknown\n"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */ - png_ptr->mode |= PNG_AFTER_IDAT; - } - - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - - if (!(png_ptr->chunk_name[0] & 0x20)) - { -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL -#endif - ) -#endif - png_chunk_error(png_ptr, "unknown critical chunk"); - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) || - (png_ptr->read_user_chunk_fn != NULL)) - { - png_unknown_chunk chunk; - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "unknown chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); - chunk.data = (png_bytep)png_malloc(png_ptr, length); - chunk.size = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunk.data, length); -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) - { - /* callback to user unknown chunk handler */ - if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) - { - if (!(png_ptr->chunk_name[0] & 0x20)) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS) - { - png_free(png_ptr, chunk.data); - png_chunk_error(png_ptr, "unknown critical chunk"); - } - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - } - } - else -#endif - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - png_free(png_ptr, chunk.data); - } - else -#endif - skip = length; - - png_crc_finish(png_ptr, skip); - -#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */ - return; -#endif -} - -/* This function is called to verify that a chunk name is valid. - This function can't have the "critical chunk check" incorporated - into it, since in the future we will need to be able to call user - functions to handle unknown critical chunks after we check that - the chunk name itself is valid. */ - -#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) - -void /* PRIVATE */ -png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) -{ - png_debug(1, "in png_check_chunk_name\n"); - if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) || - isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3])) - { - png_chunk_error(png_ptr, "invalid chunk type"); - } -} - -/* Combines the row recently read in with the existing pixels in the - row. This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined, - a zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. If - you want all pixels to be combined, pass 0xff (255) in mask. */ -#ifndef PNG_HAVE_MMX_COMBINE_ROW -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ - png_debug(1,"in png_combine_row\n"); - if (mask == 0xff) - { - png_memcpy(row, png_ptr->row_buf + 1, - PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->width)); - } - else - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_inc, s_start, s_end; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x01; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - case 2: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_start, s_end, s_inc; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - int value; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x03; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - case 4: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_start, s_end, s_inc; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - int value; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - default: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - png_byte m = 0x80; - - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - png_memcpy(dp, sp, pixel_bytes); - } - - sp += pixel_bytes; - dp += pixel_bytes; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - } - } -} -#endif /* !PNG_HAVE_MMX_COMBINE_ROW */ - -#ifdef PNG_READ_INTERLACING_SUPPORTED -#ifndef PNG_HAVE_MMX_READ_INTERLACE /* else in pngvcrd.c, pnggccrd.c */ -/* OLD pre-1.0.9 interface: -void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, - png_uint_32 transformations) - */ -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; - png_uint_32 transformations = png_ptr->transformations; -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_do_read_interlace (stock C version)\n"); - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3); - png_bytep dp = row + (png_size_t)((final_width - 1) >> 3); - int sshift, dshift; - int s_start, s_end, s_inc; - int jstop = png_pass_inc[pass]; - png_byte v; - png_uint_32 i; - int j; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 0x07); - dshift = (int)((final_width + 7) & 0x07); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 0x07); - dshift = 7 - (int)((final_width + 7) & 0x07); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = 0; i < row_info->width; i++) - { - v = (png_byte)((*sp >> sshift) & 0x01); - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - case 2: - { - png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); - png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2); - int sshift, dshift; - int s_start, s_end, s_inc; - int jstop = png_pass_inc[pass]; - png_uint_32 i; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)(((row_info->width + 3) & 0x03) << 1); - dshift = (int)(((final_width + 3) & 0x03) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1); - dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = 0; i < row_info->width; i++) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x03); - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - case 4: - { - png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1); - png_bytep dp = row + (png_size_t)((final_width - 1) >> 1); - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - int jstop = png_pass_inc[pass]; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)(((row_info->width + 1) & 0x01) << 2); - dshift = (int)(((final_width + 1) & 0x01) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2); - dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = 0; i < row_info->width; i++) - { - png_byte v = (png_byte)((*sp >> sshift) & 0xf); - int j; - - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - default: - { - png_size_t pixel_bytes = (row_info->pixel_depth >> 3); - png_bytep sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes; - png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes; - - int jstop = png_pass_inc[pass]; - png_uint_32 i; - - for (i = 0; i < row_info->width; i++) - { - png_byte v[8]; - int j; - - png_memcpy(v, sp, pixel_bytes); - for (j = 0; j < jstop; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sp -= pixel_bytes; - } - break; - } - } - row_info->width = final_width; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); - } -#if !defined(PNG_READ_PACKSWAP_SUPPORTED) - if (&transformations == NULL) /* silence compiler warning */ - return; -#endif -} -#endif /* !PNG_HAVE_MMX_READ_INTERLACE */ -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - -#ifndef PNG_HAVE_MMX_READ_FILTER_ROW -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, - png_bytep prev_row, int filter) -{ - png_debug(1, "in png_read_filter_row\n"); - png_debug2(2,"row = %lu, filter = %d\n", png_ptr->row_number, filter); - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - case PNG_FILTER_VALUE_SUB: - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_UP: - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_AVG: - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) / 2 )) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - (int)(*pp++ + *lp++) / 2 ) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_PAETH: - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop=row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) /* use leftover rp,pp */ - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - break; - } - default: - png_warning(png_ptr, "Ignoring bad adaptive filter type"); - *row=0; - break; - } -} -#endif /* !PNG_HAVE_MMX_READ_FILTER_ROW */ - -void /* PRIVATE */ -png_read_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - png_debug(1, "in png_read_finish_row\n"); - png_ptr->row_number++; - if (png_ptr->row_number < png_ptr->num_rows) - return; - - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - do - { - png_ptr->pass++; - if (png_ptr->pass >= 7) - break; - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, - png_ptr->iwidth) + 1; - - if (!(png_ptr->transformations & PNG_INTERLACE)) - { - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - if (!(png_ptr->num_rows)) - continue; - } - else /* if (png_ptr->transformations & PNG_INTERLACE) */ - break; - } while (png_ptr->iwidth == 0); - - if (png_ptr->pass < 7) - return; - } - - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - char extra; - int ret; - - png_ptr->zstream.next_out = (Byte *)&extra; - png_ptr->zstream.avail_out = (uInt)1; - for(;;) - { - if (!(png_ptr->zstream.avail_in)) - { - while (!png_ptr->idat_size) - { - png_byte chunk_length[4]; - - png_crc_finish(png_ptr, 0); - - png_read_data(png_ptr, chunk_length, 4); - png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - png_error(png_ptr, "Not enough image data"); - - } - png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_in = png_ptr->zbuf; - if (png_ptr->zbuf_size > png_ptr->idat_size) - png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; - png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in); - png_ptr->idat_size -= png_ptr->zstream.avail_in; - } - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret == Z_STREAM_END) - { - if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in || - png_ptr->idat_size) - png_warning(png_ptr, "Extra compressed data"); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - if (ret != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : - "Decompression Error"); - - if (!(png_ptr->zstream.avail_out)) - { - png_warning(png_ptr, "Extra compressed data."); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - - } - png_ptr->zstream.avail_out = 0; - } - - if (png_ptr->idat_size || png_ptr->zstream.avail_in) - png_warning(png_ptr, "Extra compression data"); - - inflateReset(&png_ptr->zstream); - - png_ptr->mode |= PNG_AFTER_IDAT; -} - -void /* PRIVATE */ -png_read_start_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - int max_pixel_depth; - png_uint_32 row_bytes; - - png_debug(1, "in png_read_start_row\n"); - png_ptr->zstream.avail_in = 0; - png_init_read_transformations(png_ptr); - if (png_ptr->interlaced) - { - if (!(png_ptr->transformations & PNG_INTERLACE)) - png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; - else - png_ptr->num_rows = png_ptr->height; - - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - row_bytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->iwidth) + 1; - - png_ptr->irowbytes = (png_size_t)row_bytes; - if((png_uint_32)png_ptr->irowbytes != row_bytes) - png_error(png_ptr, "Rowbytes overflow in png_read_start_row"); - } - else - { - png_ptr->num_rows = png_ptr->height; - png_ptr->iwidth = png_ptr->width; - png_ptr->irowbytes = png_ptr->rowbytes + 1; - } - max_pixel_depth = png_ptr->pixel_depth; - -#if defined(PNG_READ_PACK_SUPPORTED) - if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8) - max_pixel_depth = 8; -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (png_ptr->num_trans) - max_pixel_depth = 32; - else - max_pixel_depth = 24; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - if (max_pixel_depth < 8) - max_pixel_depth = 8; - if (png_ptr->num_trans) - max_pixel_depth *= 2; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - if (png_ptr->num_trans) - { - max_pixel_depth *= 4; - max_pixel_depth /= 3; - } - } - } -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & (PNG_FILLER)) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - max_pixel_depth = 32; - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - if (max_pixel_depth <= 8) - max_pixel_depth = 16; - else - max_pixel_depth = 32; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - if (max_pixel_depth <= 32) - max_pixel_depth = 32; - else - max_pixel_depth = 64; - } - } -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - if (png_ptr->transformations & PNG_GRAY_TO_RGB) - { - if ( -#if defined(PNG_READ_EXPAND_SUPPORTED) - (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) || -#endif -#if defined(PNG_READ_FILLER_SUPPORTED) - (png_ptr->transformations & (PNG_FILLER)) || -#endif - png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (max_pixel_depth <= 16) - max_pixel_depth = 32; - else - max_pixel_depth = 64; - } - else - { - if (max_pixel_depth <= 8) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - max_pixel_depth = 32; - else - max_pixel_depth = 24; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - max_pixel_depth = 64; - else - max_pixel_depth = 48; - } - } -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ -defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if(png_ptr->transformations & PNG_USER_TRANSFORM) - { - int user_pixel_depth=png_ptr->user_transform_depth* - png_ptr->user_transform_channels; - if(user_pixel_depth > max_pixel_depth) - max_pixel_depth=user_pixel_depth; - } -#endif - - /* align the width on the next larger 8 pixels. Mainly used - for interlacing */ - row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7)); - /* calculate the maximum bytes needed, adding a byte and a pixel - for safety's sake */ - row_bytes = PNG_ROWBYTES(max_pixel_depth,row_bytes) + - 1 + ((max_pixel_depth + 7) >> 3); -#ifdef PNG_MAX_MALLOC_64K - if (row_bytes > (png_uint_32)65536L) - png_error(png_ptr, "This image requires a row greater than 64KB"); -#endif - png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64); - png_ptr->row_buf = png_ptr->big_row_buf+32; -#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD) - png_ptr->row_buf_size = row_bytes; -#endif - -#ifdef PNG_MAX_MALLOC_64K - if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) - png_error(png_ptr, "This image requires a row greater than 64KB"); -#endif - if ((png_uint_32)png_ptr->rowbytes > (png_uint_32)(PNG_SIZE_MAX - 1)) - png_error(png_ptr, "Row has too many bytes to allocate in memory."); - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)( - png_ptr->rowbytes + 1)); - - png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - - png_debug1(3, "width = %lu,\n", png_ptr->width); - png_debug1(3, "height = %lu,\n", png_ptr->height); - png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth); - png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows); - png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes); - png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes); - - png_ptr->flags |= PNG_FLAG_ROW_INIT; -} -#endif /* PNG_READ_SUPPORTED */ + +/* pngrutil.c - utilities to read a PNG file + * + * Last changed in libpng 1.2.15 January 5, 2007 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This file contains routines that are only called from within + * libpng itself during the course of reading an image. + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_READ_SUPPORTED) + +#ifdef PNG_FLOATING_POINT_SUPPORTED +# if defined(_WIN32_WCE) +/* strtod() function is not supported on WindowsCE */ +__inline double png_strtod(png_structp png_ptr, const char *nptr, char **endptr) +{ + double result = 0; + int len; + wchar_t *str, *end; + + len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0); + str = (wchar_t *)png_malloc(png_ptr, len * sizeof(wchar_t)); + if ( NULL != str ) + { + MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); + result = wcstod(str, &end); + len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL); + *endptr = (char *)nptr + (png_strlen(nptr) - len + 1); + png_free(str); + } + return result; +} +# else +# define png_strtod(p,a,b) strtod(a,b) +# endif +#endif + +png_uint_32 PNGAPI +png_get_uint_31(png_structp png_ptr, png_bytep buf) +{ + png_uint_32 i = png_get_uint_32(buf); + if (i > PNG_UINT_31_MAX) + png_error(png_ptr, "PNG unsigned integer out of range."); + return (i); +} +#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED +/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ +png_uint_32 PNGAPI +png_get_uint_32(png_bytep buf) +{ + png_uint_32 i = ((png_uint_32)(*buf) << 24) + + ((png_uint_32)(*(buf + 1)) << 16) + + ((png_uint_32)(*(buf + 2)) << 8) + + (png_uint_32)(*(buf + 3)); + + return (i); +} + +/* Grab a signed 32-bit integer from a buffer in big-endian format. The + * data is stored in the PNG file in two's complement format, and it is + * assumed that the machine format for signed integers is the same. */ +png_int_32 PNGAPI +png_get_int_32(png_bytep buf) +{ + png_int_32 i = ((png_int_32)(*buf) << 24) + + ((png_int_32)(*(buf + 1)) << 16) + + ((png_int_32)(*(buf + 2)) << 8) + + (png_int_32)(*(buf + 3)); + + return (i); +} + +/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ +png_uint_16 PNGAPI +png_get_uint_16(png_bytep buf) +{ + png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) + + (png_uint_16)(*(buf + 1))); + + return (i); +} +#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ + +/* Read data, and (optionally) run it through the CRC. */ +void /* PRIVATE */ +png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) +{ + if(png_ptr == NULL) return; + png_read_data(png_ptr, buf, length); + png_calculate_crc(png_ptr, buf, length); +} + +/* Optionally skip data and then check the CRC. Depending on whether we + are reading a ancillary or critical chunk, and how the program has set + things up, we may calculate the CRC on the data and print a message. + Returns '1' if there was a CRC error, '0' otherwise. */ +int /* PRIVATE */ +png_crc_finish(png_structp png_ptr, png_uint_32 skip) +{ + png_size_t i; + png_size_t istop = png_ptr->zbuf_size; + + for (i = (png_size_t)skip; i > istop; i -= istop) + { + png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); + } + if (i) + { + png_crc_read(png_ptr, png_ptr->zbuf, i); + } + + if (png_crc_error(png_ptr)) + { + if (((png_ptr->chunk_name[0] & 0x20) && /* Ancillary */ + !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) || + (!(png_ptr->chunk_name[0] & 0x20) && /* Critical */ + (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))) + { + png_chunk_warning(png_ptr, "CRC error"); + } + else + { + png_chunk_error(png_ptr, "CRC error"); + } + return (1); + } + + return (0); +} + +/* Compare the CRC stored in the PNG file with that calculated by libpng from + the data it has read thus far. */ +int /* PRIVATE */ +png_crc_error(png_structp png_ptr) +{ + png_byte crc_bytes[4]; + png_uint_32 crc; + int need_crc = 1; + + if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ + { + if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == + (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) + need_crc = 0; + } + else /* critical */ + { + if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) + need_crc = 0; + } + + png_read_data(png_ptr, crc_bytes, 4); + + if (need_crc) + { + crc = png_get_uint_32(crc_bytes); + return ((int)(crc != png_ptr->crc)); + } + else + return (0); +} + +#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \ + defined(PNG_READ_iCCP_SUPPORTED) +/* + * Decompress trailing data in a chunk. The assumption is that chunkdata + * points at an allocated area holding the contents of a chunk with a + * trailing compressed part. What we get back is an allocated area + * holding the original prefix part and an uncompressed version of the + * trailing part (the malloc area passed in is freed). + */ +png_charp /* PRIVATE */ +png_decompress_chunk(png_structp png_ptr, int comp_type, + png_charp chunkdata, png_size_t chunklength, + png_size_t prefix_size, png_size_t *newlength) +{ + static char msg[] = "Error decoding compressed text"; + png_charp text; + png_size_t text_size; + + if (comp_type == PNG_COMPRESSION_TYPE_BASE) + { + int ret = Z_OK; + png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size); + png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + + text_size = 0; + text = NULL; + + while (png_ptr->zstream.avail_in) + { + ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); + if (ret != Z_OK && ret != Z_STREAM_END) + { + if (png_ptr->zstream.msg != NULL) + png_warning(png_ptr, png_ptr->zstream.msg); + else + png_warning(png_ptr, msg); + inflateReset(&png_ptr->zstream); + png_ptr->zstream.avail_in = 0; + + if (text == NULL) + { + text_size = prefix_size + png_sizeof(msg) + 1; + text = (png_charp)png_malloc_warn(png_ptr, text_size); + if (text == NULL) + { + png_free(png_ptr,chunkdata); + png_error(png_ptr,"Not enough memory to decompress chunk"); + } + png_memcpy(text, chunkdata, prefix_size); + } + + text[text_size - 1] = 0x00; + + /* Copy what we can of the error message into the text chunk */ + text_size = (png_size_t)(chunklength - (text - chunkdata) - 1); + text_size = png_sizeof(msg) > text_size ? text_size : + png_sizeof(msg); + png_memcpy(text + prefix_size, msg, text_size + 1); + break; + } + if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END) + { + if (text == NULL) + { + text_size = prefix_size + + png_ptr->zbuf_size - png_ptr->zstream.avail_out; + text = (png_charp)png_malloc_warn(png_ptr, text_size + 1); + if (text == NULL) + { + png_free(png_ptr,chunkdata); + png_error(png_ptr,"Not enough memory to decompress chunk."); + } + png_memcpy(text + prefix_size, png_ptr->zbuf, + text_size - prefix_size); + png_memcpy(text, chunkdata, prefix_size); + *(text + text_size) = 0x00; + } + else + { + png_charp tmp; + + tmp = text; + text = (png_charp)png_malloc_warn(png_ptr, + (png_uint_32)(text_size + + png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); + if (text == NULL) + { + png_free(png_ptr, tmp); + png_free(png_ptr, chunkdata); + png_error(png_ptr,"Not enough memory to decompress chunk.."); + } + png_memcpy(text, tmp, text_size); + png_free(png_ptr, tmp); + png_memcpy(text + text_size, png_ptr->zbuf, + (png_ptr->zbuf_size - png_ptr->zstream.avail_out)); + text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; + *(text + text_size) = 0x00; + } + if (ret == Z_STREAM_END) + break; + else + { + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + } + } + } + if (ret != Z_STREAM_END) + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char umsg[52]; + + if (ret == Z_BUF_ERROR) + sprintf(umsg,"Buffer error in compressed datastream in %s chunk", + png_ptr->chunk_name); + else if (ret == Z_DATA_ERROR) + sprintf(umsg,"Data error in compressed datastream in %s chunk", + png_ptr->chunk_name); + else + sprintf(umsg,"Incomplete compressed datastream in %s chunk", + png_ptr->chunk_name); + png_warning(png_ptr, umsg); +#else + png_warning(png_ptr, + "Incomplete compressed datastream in chunk other than IDAT"); +#endif + text_size=prefix_size; + if (text == NULL) + { + text = (png_charp)png_malloc_warn(png_ptr, text_size+1); + if (text == NULL) + { + png_free(png_ptr, chunkdata); + png_error(png_ptr,"Not enough memory for text."); + } + png_memcpy(text, chunkdata, prefix_size); + } + *(text + text_size) = 0x00; + } + + inflateReset(&png_ptr->zstream); + png_ptr->zstream.avail_in = 0; + + png_free(png_ptr, chunkdata); + chunkdata = text; + *newlength=text_size; + } + else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */ + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char umsg[50]; + + sprintf(umsg, "Unknown zTXt compression type %d", comp_type); + png_warning(png_ptr, umsg); +#else + png_warning(png_ptr, "Unknown zTXt compression type"); +#endif + + *(chunkdata + prefix_size) = 0x00; + *newlength=prefix_size; + } + + return chunkdata; +} +#endif + +/* read and check the IDHR chunk */ +void /* PRIVATE */ +png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_byte buf[13]; + png_uint_32 width, height; + int bit_depth, color_type, compression_type, filter_type; + int interlace_type; + + png_debug(1, "in png_handle_IHDR\n"); + + if (png_ptr->mode & PNG_HAVE_IHDR) + png_error(png_ptr, "Out of place IHDR"); + + /* check the length */ + if (length != 13) + png_error(png_ptr, "Invalid IHDR chunk"); + + png_ptr->mode |= PNG_HAVE_IHDR; + + png_crc_read(png_ptr, buf, 13); + png_crc_finish(png_ptr, 0); + + width = png_get_uint_31(png_ptr, buf); + height = png_get_uint_31(png_ptr, buf + 4); + bit_depth = buf[8]; + color_type = buf[9]; + compression_type = buf[10]; + filter_type = buf[11]; + interlace_type = buf[12]; + + /* set internal variables */ + png_ptr->width = width; + png_ptr->height = height; + png_ptr->bit_depth = (png_byte)bit_depth; + png_ptr->interlaced = (png_byte)interlace_type; + png_ptr->color_type = (png_byte)color_type; +#if defined(PNG_MNG_FEATURES_SUPPORTED) + png_ptr->filter_type = (png_byte)filter_type; +#endif + png_ptr->compression_type = (png_byte)compression_type; + + /* find number of channels */ + switch (png_ptr->color_type) + { + case PNG_COLOR_TYPE_GRAY: + case PNG_COLOR_TYPE_PALETTE: + png_ptr->channels = 1; + break; + case PNG_COLOR_TYPE_RGB: + png_ptr->channels = 3; + break; + case PNG_COLOR_TYPE_GRAY_ALPHA: + png_ptr->channels = 2; + break; + case PNG_COLOR_TYPE_RGB_ALPHA: + png_ptr->channels = 4; + break; + } + + /* set up other useful info */ + png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * + png_ptr->channels); + png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width); + png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth); + png_debug1(3,"channels = %d\n", png_ptr->channels); + png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes); + png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, + color_type, interlace_type, compression_type, filter_type); +} + +/* read and check the palette */ +void /* PRIVATE */ +png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_color palette[PNG_MAX_PALETTE_LENGTH]; + int num, i; +#ifndef PNG_NO_POINTER_INDEXING + png_colorp pal_ptr; +#endif + + png_debug(1, "in png_handle_PLTE\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before PLTE"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid PLTE after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + png_error(png_ptr, "Duplicate PLTE chunk"); + + png_ptr->mode |= PNG_HAVE_PLTE; + + if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) + { + png_warning(png_ptr, + "Ignoring PLTE chunk in grayscale PNG"); + png_crc_finish(png_ptr, length); + return; + } +#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) + if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) + { + png_crc_finish(png_ptr, length); + return; + } +#endif + + if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3) + { + if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) + { + png_warning(png_ptr, "Invalid palette chunk"); + png_crc_finish(png_ptr, length); + return; + } + else + { + png_error(png_ptr, "Invalid palette chunk"); + } + } + + num = (int)length / 3; + +#ifndef PNG_NO_POINTER_INDEXING + for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++) + { + png_byte buf[3]; + + png_crc_read(png_ptr, buf, 3); + pal_ptr->red = buf[0]; + pal_ptr->green = buf[1]; + pal_ptr->blue = buf[2]; + } +#else + for (i = 0; i < num; i++) + { + png_byte buf[3]; + + png_crc_read(png_ptr, buf, 3); + /* don't depend upon png_color being any order */ + palette[i].red = buf[0]; + palette[i].green = buf[1]; + palette[i].blue = buf[2]; + } +#endif + + /* If we actually NEED the PLTE chunk (ie for a paletted image), we do + whatever the normal CRC configuration tells us. However, if we + have an RGB image, the PLTE can be considered ancillary, so + we will act as though it is. */ +#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) +#endif + { + png_crc_finish(png_ptr, 0); + } +#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) + else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */ + { + /* If we don't want to use the data from an ancillary chunk, + we have two options: an error abort, or a warning and we + ignore the data in this chunk (which should be OK, since + it's considered ancillary for a RGB or RGBA image). */ + if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)) + { + if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) + { + png_chunk_error(png_ptr, "CRC error"); + } + else + { + png_chunk_warning(png_ptr, "CRC error"); + return; + } + } + /* Otherwise, we (optionally) emit a warning and use the chunk. */ + else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) + { + png_chunk_warning(png_ptr, "CRC error"); + } + } +#endif + + png_set_PLTE(png_ptr, info_ptr, palette, num); + +#if defined(PNG_READ_tRNS_SUPPORTED) + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) + { + if (png_ptr->num_trans > (png_uint_16)num) + { + png_warning(png_ptr, "Truncating incorrect tRNS chunk length"); + png_ptr->num_trans = (png_uint_16)num; + } + if (info_ptr->num_trans > (png_uint_16)num) + { + png_warning(png_ptr, "Truncating incorrect info tRNS chunk length"); + info_ptr->num_trans = (png_uint_16)num; + } + } + } +#endif + +} + +void /* PRIVATE */ +png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_debug(1, "in png_handle_IEND\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) + { + png_error(png_ptr, "No image in file"); + } + + png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); + + if (length != 0) + { + png_warning(png_ptr, "Incorrect IEND chunk length"); + } + png_crc_finish(png_ptr, length); + + if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */ + return; +} + +#if defined(PNG_READ_gAMA_SUPPORTED) +void /* PRIVATE */ +png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_fixed_point igamma; +#ifdef PNG_FLOATING_POINT_SUPPORTED + float file_gamma; +#endif + png_byte buf[4]; + + png_debug(1, "in png_handle_gAMA\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before gAMA"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid gAMA after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Out of place gAMA chunk"); + + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) +#if defined(PNG_READ_sRGB_SUPPORTED) + && !(info_ptr->valid & PNG_INFO_sRGB) +#endif + ) + { + png_warning(png_ptr, "Duplicate gAMA chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (length != 4) + { + png_warning(png_ptr, "Incorrect gAMA chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, 4); + if (png_crc_finish(png_ptr, 0)) + return; + + igamma = (png_fixed_point)png_get_uint_32(buf); + /* check for zero gamma */ + if (igamma == 0) + { + png_warning(png_ptr, + "Ignoring gAMA chunk with gamma=0"); + return; + } + +#if defined(PNG_READ_sRGB_SUPPORTED) + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) + if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) + { + png_warning(png_ptr, + "Ignoring incorrect gAMA value when sRGB is also present"); +#ifndef PNG_NO_CONSOLE_IO + fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma); +#endif + return; + } +#endif /* PNG_READ_sRGB_SUPPORTED */ + +#ifdef PNG_FLOATING_POINT_SUPPORTED + file_gamma = (float)igamma / (float)100000.0; +# ifdef PNG_READ_GAMMA_SUPPORTED + png_ptr->gamma = file_gamma; +# endif + png_set_gAMA(png_ptr, info_ptr, file_gamma); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_set_gAMA_fixed(png_ptr, info_ptr, igamma); +#endif +} +#endif + +#if defined(PNG_READ_sBIT_SUPPORTED) +void /* PRIVATE */ +png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_size_t truelen; + png_byte buf[4]; + + png_debug(1, "in png_handle_sBIT\n"); + + buf[0] = buf[1] = buf[2] = buf[3] = 0; + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before sBIT"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid sBIT after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + { + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Out of place sBIT chunk"); + } + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)) + { + png_warning(png_ptr, "Duplicate sBIT chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + truelen = 3; + else + truelen = (png_size_t)png_ptr->channels; + + if (length != truelen || length > 4) + { + png_warning(png_ptr, "Incorrect sBIT chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, truelen); + if (png_crc_finish(png_ptr, 0)) + return; + + if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) + { + png_ptr->sig_bit.red = buf[0]; + png_ptr->sig_bit.green = buf[1]; + png_ptr->sig_bit.blue = buf[2]; + png_ptr->sig_bit.alpha = buf[3]; + } + else + { + png_ptr->sig_bit.gray = buf[0]; + png_ptr->sig_bit.red = buf[0]; + png_ptr->sig_bit.green = buf[0]; + png_ptr->sig_bit.blue = buf[0]; + png_ptr->sig_bit.alpha = buf[1]; + } + png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit)); +} +#endif + +#if defined(PNG_READ_cHRM_SUPPORTED) +void /* PRIVATE */ +png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_byte buf[4]; +#ifdef PNG_FLOATING_POINT_SUPPORTED + float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; +#endif + png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, + int_y_green, int_x_blue, int_y_blue; + + png_uint_32 uint_x, uint_y; + + png_debug(1, "in png_handle_cHRM\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before cHRM"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid cHRM after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Missing PLTE before cHRM"); + + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM) +#if defined(PNG_READ_sRGB_SUPPORTED) + && !(info_ptr->valid & PNG_INFO_sRGB) +#endif + ) + { + png_warning(png_ptr, "Duplicate cHRM chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (length != 32) + { + png_warning(png_ptr, "Incorrect cHRM chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, 4); + uint_x = png_get_uint_32(buf); + + png_crc_read(png_ptr, buf, 4); + uint_y = png_get_uint_32(buf); + + if (uint_x > 80000L || uint_y > 80000L || + uint_x + uint_y > 100000L) + { + png_warning(png_ptr, "Invalid cHRM white point"); + png_crc_finish(png_ptr, 24); + return; + } + int_x_white = (png_fixed_point)uint_x; + int_y_white = (png_fixed_point)uint_y; + + png_crc_read(png_ptr, buf, 4); + uint_x = png_get_uint_32(buf); + + png_crc_read(png_ptr, buf, 4); + uint_y = png_get_uint_32(buf); + + if (uint_x + uint_y > 100000L) + { + png_warning(png_ptr, "Invalid cHRM red point"); + png_crc_finish(png_ptr, 16); + return; + } + int_x_red = (png_fixed_point)uint_x; + int_y_red = (png_fixed_point)uint_y; + + png_crc_read(png_ptr, buf, 4); + uint_x = png_get_uint_32(buf); + + png_crc_read(png_ptr, buf, 4); + uint_y = png_get_uint_32(buf); + + if (uint_x + uint_y > 100000L) + { + png_warning(png_ptr, "Invalid cHRM green point"); + png_crc_finish(png_ptr, 8); + return; + } + int_x_green = (png_fixed_point)uint_x; + int_y_green = (png_fixed_point)uint_y; + + png_crc_read(png_ptr, buf, 4); + uint_x = png_get_uint_32(buf); + + png_crc_read(png_ptr, buf, 4); + uint_y = png_get_uint_32(buf); + + if (uint_x + uint_y > 100000L) + { + png_warning(png_ptr, "Invalid cHRM blue point"); + png_crc_finish(png_ptr, 0); + return; + } + int_x_blue = (png_fixed_point)uint_x; + int_y_blue = (png_fixed_point)uint_y; + +#ifdef PNG_FLOATING_POINT_SUPPORTED + white_x = (float)int_x_white / (float)100000.0; + white_y = (float)int_y_white / (float)100000.0; + red_x = (float)int_x_red / (float)100000.0; + red_y = (float)int_y_red / (float)100000.0; + green_x = (float)int_x_green / (float)100000.0; + green_y = (float)int_y_green / (float)100000.0; + blue_x = (float)int_x_blue / (float)100000.0; + blue_y = (float)int_y_blue / (float)100000.0; +#endif + +#if defined(PNG_READ_sRGB_SUPPORTED) + if ((info_ptr != NULL) && (info_ptr->valid & PNG_INFO_sRGB)) + { + if (PNG_OUT_OF_RANGE(int_x_white, 31270, 1000) || + PNG_OUT_OF_RANGE(int_y_white, 32900, 1000) || + PNG_OUT_OF_RANGE(int_x_red, 64000L, 1000) || + PNG_OUT_OF_RANGE(int_y_red, 33000, 1000) || + PNG_OUT_OF_RANGE(int_x_green, 30000, 1000) || + PNG_OUT_OF_RANGE(int_y_green, 60000L, 1000) || + PNG_OUT_OF_RANGE(int_x_blue, 15000, 1000) || + PNG_OUT_OF_RANGE(int_y_blue, 6000, 1000)) + { + png_warning(png_ptr, + "Ignoring incorrect cHRM value when sRGB is also present"); +#ifndef PNG_NO_CONSOLE_IO +#ifdef PNG_FLOATING_POINT_SUPPORTED + fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n", + white_x, white_y, red_x, red_y); + fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n", + green_x, green_y, blue_x, blue_y); +#else + fprintf(stderr,"wx=%ld, wy=%ld, rx=%ld, ry=%ld\n", + int_x_white, int_y_white, int_x_red, int_y_red); + fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n", + int_x_green, int_y_green, int_x_blue, int_y_blue); +#endif +#endif /* PNG_NO_CONSOLE_IO */ + } + png_crc_finish(png_ptr, 0); + return; + } +#endif /* PNG_READ_sRGB_SUPPORTED */ + +#ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_cHRM(png_ptr, info_ptr, + white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_set_cHRM_fixed(png_ptr, info_ptr, + int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, + int_y_green, int_x_blue, int_y_blue); +#endif + if (png_crc_finish(png_ptr, 0)) + return; +} +#endif + +#if defined(PNG_READ_sRGB_SUPPORTED) +void /* PRIVATE */ +png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + int intent; + png_byte buf[1]; + + png_debug(1, "in png_handle_sRGB\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before sRGB"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid sRGB after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Out of place sRGB chunk"); + + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) + { + png_warning(png_ptr, "Duplicate sRGB chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (length != 1) + { + png_warning(png_ptr, "Incorrect sRGB chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, 1); + if (png_crc_finish(png_ptr, 0)) + return; + + intent = buf[0]; + /* check for bad intent */ + if (intent >= PNG_sRGB_INTENT_LAST) + { + png_warning(png_ptr, "Unknown sRGB intent"); + return; + } + +#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)) + { + png_fixed_point igamma; +#ifdef PNG_FIXED_POINT_SUPPORTED + igamma=info_ptr->int_gamma; +#else +# ifdef PNG_FLOATING_POINT_SUPPORTED + igamma=(png_fixed_point)(info_ptr->gamma * 100000.); +# endif +#endif + if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) + { + png_warning(png_ptr, + "Ignoring incorrect gAMA value when sRGB is also present"); +#ifndef PNG_NO_CONSOLE_IO +# ifdef PNG_FIXED_POINT_SUPPORTED + fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma); +# else +# ifdef PNG_FLOATING_POINT_SUPPORTED + fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma); +# endif +# endif +#endif + } + } +#endif /* PNG_READ_gAMA_SUPPORTED */ + +#ifdef PNG_READ_cHRM_SUPPORTED +#ifdef PNG_FIXED_POINT_SUPPORTED + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) + if (PNG_OUT_OF_RANGE(info_ptr->int_x_white, 31270, 1000) || + PNG_OUT_OF_RANGE(info_ptr->int_y_white, 32900, 1000) || + PNG_OUT_OF_RANGE(info_ptr->int_x_red, 64000L, 1000) || + PNG_OUT_OF_RANGE(info_ptr->int_y_red, 33000, 1000) || + PNG_OUT_OF_RANGE(info_ptr->int_x_green, 30000, 1000) || + PNG_OUT_OF_RANGE(info_ptr->int_y_green, 60000L, 1000) || + PNG_OUT_OF_RANGE(info_ptr->int_x_blue, 15000, 1000) || + PNG_OUT_OF_RANGE(info_ptr->int_y_blue, 6000, 1000)) + { + png_warning(png_ptr, + "Ignoring incorrect cHRM value when sRGB is also present"); + } +#endif /* PNG_FIXED_POINT_SUPPORTED */ +#endif /* PNG_READ_cHRM_SUPPORTED */ + + png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent); +} +#endif /* PNG_READ_sRGB_SUPPORTED */ + +#if defined(PNG_READ_iCCP_SUPPORTED) +void /* PRIVATE */ +png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +/* Note: this does not properly handle chunks that are > 64K under DOS */ +{ + png_charp chunkdata; + png_byte compression_type; + png_bytep pC; + png_charp profile; + png_uint_32 skip = 0; + png_uint_32 profile_size, profile_length; + png_size_t slength, prefix_length, data_length; + + png_debug(1, "in png_handle_iCCP\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before iCCP"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid iCCP after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Out of place iCCP chunk"); + + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)) + { + png_warning(png_ptr, "Duplicate iCCP chunk"); + png_crc_finish(png_ptr, length); + return; + } + +#ifdef PNG_MAX_MALLOC_64K + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr, "iCCP chunk too large to fit in memory"); + skip = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + + chunkdata = (png_charp)png_malloc(png_ptr, length + 1); + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + + if (png_crc_finish(png_ptr, skip)) + { + png_free(png_ptr, chunkdata); + return; + } + + chunkdata[slength] = 0x00; + + for (profile = chunkdata; *profile; profile++) + /* empty loop to find end of name */ ; + + ++profile; + + /* there should be at least one zero (the compression type byte) + following the separator, and we should be on it */ + if ( profile >= chunkdata + slength) + { + png_free(png_ptr, chunkdata); + png_warning(png_ptr, "Malformed iCCP chunk"); + return; + } + + /* compression_type should always be zero */ + compression_type = *profile++; + if (compression_type) + { + png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk"); + compression_type=0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8 + wrote nonzero) */ + } + + prefix_length = profile - chunkdata; + chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata, + slength, prefix_length, &data_length); + + profile_length = data_length - prefix_length; + + if ( prefix_length > data_length || profile_length < 4) + { + png_free(png_ptr, chunkdata); + png_warning(png_ptr, "Profile size field missing from iCCP chunk"); + return; + } + + /* Check the profile_size recorded in the first 32 bits of the ICC profile */ + pC = (png_bytep)(chunkdata+prefix_length); + profile_size = ((*(pC ))<<24) | + ((*(pC+1))<<16) | + ((*(pC+2))<< 8) | + ((*(pC+3)) ); + + if(profile_size < profile_length) + profile_length = profile_size; + + if(profile_size > profile_length) + { + png_free(png_ptr, chunkdata); + png_warning(png_ptr, "Ignoring truncated iCCP profile."); + return; + } + + png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type, + chunkdata + prefix_length, profile_length); + png_free(png_ptr, chunkdata); +} +#endif /* PNG_READ_iCCP_SUPPORTED */ + +#if defined(PNG_READ_sPLT_SUPPORTED) +void /* PRIVATE */ +png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +/* Note: this does not properly handle chunks that are > 64K under DOS */ +{ + png_bytep chunkdata; + png_bytep entry_start; + png_sPLT_t new_palette; +#ifdef PNG_NO_POINTER_INDEXING + png_sPLT_entryp pp; +#endif + int data_length, entry_size, i; + png_uint_32 skip = 0; + png_size_t slength; + + png_debug(1, "in png_handle_sPLT\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before sPLT"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid sPLT after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + +#ifdef PNG_MAX_MALLOC_64K + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr, "sPLT chunk too large to fit in memory"); + skip = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + + chunkdata = (png_bytep)png_malloc(png_ptr, length + 1); + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + + if (png_crc_finish(png_ptr, skip)) + { + png_free(png_ptr, chunkdata); + return; + } + + chunkdata[slength] = 0x00; + + for (entry_start = chunkdata; *entry_start; entry_start++) + /* empty loop to find end of name */ ; + ++entry_start; + + /* a sample depth should follow the separator, and we should be on it */ + if (entry_start > chunkdata + slength) + { + png_free(png_ptr, chunkdata); + png_warning(png_ptr, "malformed sPLT chunk"); + return; + } + + new_palette.depth = *entry_start++; + entry_size = (new_palette.depth == 8 ? 6 : 10); + data_length = (slength - (entry_start - chunkdata)); + + /* integrity-check the data length */ + if (data_length % entry_size) + { + png_free(png_ptr, chunkdata); + png_warning(png_ptr, "sPLT chunk has bad length"); + return; + } + + new_palette.nentries = (png_int_32) ( data_length / entry_size); + if ((png_uint_32) new_palette.nentries > (png_uint_32) (PNG_SIZE_MAX / + png_sizeof(png_sPLT_entry))) + { + png_warning(png_ptr, "sPLT chunk too long"); + return; + } + new_palette.entries = (png_sPLT_entryp)png_malloc_warn( + png_ptr, new_palette.nentries * png_sizeof(png_sPLT_entry)); + if (new_palette.entries == NULL) + { + png_warning(png_ptr, "sPLT chunk requires too much memory"); + return; + } + +#ifndef PNG_NO_POINTER_INDEXING + for (i = 0; i < new_palette.nentries; i++) + { + png_sPLT_entryp pp = new_palette.entries + i; + + if (new_palette.depth == 8) + { + pp->red = *entry_start++; + pp->green = *entry_start++; + pp->blue = *entry_start++; + pp->alpha = *entry_start++; + } + else + { + pp->red = png_get_uint_16(entry_start); entry_start += 2; + pp->green = png_get_uint_16(entry_start); entry_start += 2; + pp->blue = png_get_uint_16(entry_start); entry_start += 2; + pp->alpha = png_get_uint_16(entry_start); entry_start += 2; + } + pp->frequency = png_get_uint_16(entry_start); entry_start += 2; + } +#else + pp = new_palette.entries; + for (i = 0; i < new_palette.nentries; i++) + { + + if (new_palette.depth == 8) + { + pp[i].red = *entry_start++; + pp[i].green = *entry_start++; + pp[i].blue = *entry_start++; + pp[i].alpha = *entry_start++; + } + else + { + pp[i].red = png_get_uint_16(entry_start); entry_start += 2; + pp[i].green = png_get_uint_16(entry_start); entry_start += 2; + pp[i].blue = png_get_uint_16(entry_start); entry_start += 2; + pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2; + } + pp->frequency = png_get_uint_16(entry_start); entry_start += 2; + } +#endif + + /* discard all chunk data except the name and stash that */ + new_palette.name = (png_charp)chunkdata; + + png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); + + png_free(png_ptr, chunkdata); + png_free(png_ptr, new_palette.entries); +} +#endif /* PNG_READ_sPLT_SUPPORTED */ + +#if defined(PNG_READ_tRNS_SUPPORTED) +void /* PRIVATE */ +png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; + + png_debug(1, "in png_handle_tRNS\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before tRNS"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid tRNS after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) + { + png_warning(png_ptr, "Duplicate tRNS chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) + { + png_byte buf[2]; + + if (length != 2) + { + png_warning(png_ptr, "Incorrect tRNS chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, 2); + png_ptr->num_trans = 1; + png_ptr->trans_values.gray = png_get_uint_16(buf); + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) + { + png_byte buf[6]; + + if (length != 6) + { + png_warning(png_ptr, "Incorrect tRNS chunk length"); + png_crc_finish(png_ptr, length); + return; + } + png_crc_read(png_ptr, buf, (png_size_t)length); + png_ptr->num_trans = 1; + png_ptr->trans_values.red = png_get_uint_16(buf); + png_ptr->trans_values.green = png_get_uint_16(buf + 2); + png_ptr->trans_values.blue = png_get_uint_16(buf + 4); + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (!(png_ptr->mode & PNG_HAVE_PLTE)) + { + /* Should be an error, but we can cope with it. */ + png_warning(png_ptr, "Missing PLTE before tRNS"); + } + if (length > (png_uint_32)png_ptr->num_palette || + length > PNG_MAX_PALETTE_LENGTH) + { + png_warning(png_ptr, "Incorrect tRNS chunk length"); + png_crc_finish(png_ptr, length); + return; + } + if (length == 0) + { + png_warning(png_ptr, "Zero length tRNS chunk"); + png_crc_finish(png_ptr, length); + return; + } + png_crc_read(png_ptr, readbuf, (png_size_t)length); + png_ptr->num_trans = (png_uint_16)length; + } + else + { + png_warning(png_ptr, "tRNS chunk not allowed with alpha channel"); + png_crc_finish(png_ptr, length); + return; + } + + if (png_crc_finish(png_ptr, 0)) + return; + + png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans, + &(png_ptr->trans_values)); +} +#endif + +#if defined(PNG_READ_bKGD_SUPPORTED) +void /* PRIVATE */ +png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_size_t truelen; + png_byte buf[6]; + + png_debug(1, "in png_handle_bKGD\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before bKGD"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid bKGD after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + { + png_warning(png_ptr, "Missing PLTE before bKGD"); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)) + { + png_warning(png_ptr, "Duplicate bKGD chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + truelen = 1; + else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) + truelen = 6; + else + truelen = 2; + + if (length != truelen) + { + png_warning(png_ptr, "Incorrect bKGD chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, truelen); + if (png_crc_finish(png_ptr, 0)) + return; + + /* We convert the index value into RGB components so that we can allow + * arbitrary RGB values for background when we have transparency, and + * so it is easy to determine the RGB values of the background color + * from the info_ptr struct. */ + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_ptr->background.index = buf[0]; + if(info_ptr->num_palette) + { + if(buf[0] > info_ptr->num_palette) + { + png_warning(png_ptr, "Incorrect bKGD chunk index value"); + return; + } + png_ptr->background.red = + (png_uint_16)png_ptr->palette[buf[0]].red; + png_ptr->background.green = + (png_uint_16)png_ptr->palette[buf[0]].green; + png_ptr->background.blue = + (png_uint_16)png_ptr->palette[buf[0]].blue; + } + } + else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */ + { + png_ptr->background.red = + png_ptr->background.green = + png_ptr->background.blue = + png_ptr->background.gray = png_get_uint_16(buf); + } + else + { + png_ptr->background.red = png_get_uint_16(buf); + png_ptr->background.green = png_get_uint_16(buf + 2); + png_ptr->background.blue = png_get_uint_16(buf + 4); + } + + png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background)); +} +#endif + +#if defined(PNG_READ_hIST_SUPPORTED) +void /* PRIVATE */ +png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + unsigned int num, i; + png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; + + png_debug(1, "in png_handle_hIST\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before hIST"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid hIST after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (!(png_ptr->mode & PNG_HAVE_PLTE)) + { + png_warning(png_ptr, "Missing PLTE before hIST"); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)) + { + png_warning(png_ptr, "Duplicate hIST chunk"); + png_crc_finish(png_ptr, length); + return; + } + + num = length / 2 ; + if (num != (unsigned int) png_ptr->num_palette || num > + (unsigned int) PNG_MAX_PALETTE_LENGTH) + { + png_warning(png_ptr, "Incorrect hIST chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + for (i = 0; i < num; i++) + { + png_byte buf[2]; + + png_crc_read(png_ptr, buf, 2); + readbuf[i] = png_get_uint_16(buf); + } + + if (png_crc_finish(png_ptr, 0)) + return; + + png_set_hIST(png_ptr, info_ptr, readbuf); +} +#endif + +#if defined(PNG_READ_pHYs_SUPPORTED) +void /* PRIVATE */ +png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_byte buf[9]; + png_uint_32 res_x, res_y; + int unit_type; + + png_debug(1, "in png_handle_pHYs\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before pHYs"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid pHYs after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) + { + png_warning(png_ptr, "Duplicate pHYs chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (length != 9) + { + png_warning(png_ptr, "Incorrect pHYs chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, 9); + if (png_crc_finish(png_ptr, 0)) + return; + + res_x = png_get_uint_32(buf); + res_y = png_get_uint_32(buf + 4); + unit_type = buf[8]; + png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type); +} +#endif + +#if defined(PNG_READ_oFFs_SUPPORTED) +void /* PRIVATE */ +png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_byte buf[9]; + png_int_32 offset_x, offset_y; + int unit_type; + + png_debug(1, "in png_handle_oFFs\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before oFFs"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid oFFs after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) + { + png_warning(png_ptr, "Duplicate oFFs chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (length != 9) + { + png_warning(png_ptr, "Incorrect oFFs chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, 9); + if (png_crc_finish(png_ptr, 0)) + return; + + offset_x = png_get_int_32(buf); + offset_y = png_get_int_32(buf + 4); + unit_type = buf[8]; + png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type); +} +#endif + +#if defined(PNG_READ_pCAL_SUPPORTED) +/* read the pCAL chunk (described in the PNG Extensions document) */ +void /* PRIVATE */ +png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_charp purpose; + png_int_32 X0, X1; + png_byte type, nparams; + png_charp buf, units, endptr; + png_charpp params; + png_size_t slength; + int i; + + png_debug(1, "in png_handle_pCAL\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before pCAL"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid pCAL after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)) + { + png_warning(png_ptr, "Duplicate pCAL chunk"); + png_crc_finish(png_ptr, length); + return; + } + + png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n", + length + 1); + purpose = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (purpose == NULL) + { + png_warning(png_ptr, "No memory for pCAL purpose."); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)purpose, slength); + + if (png_crc_finish(png_ptr, 0)) + { + png_free(png_ptr, purpose); + return; + } + + purpose[slength] = 0x00; /* null terminate the last string */ + + png_debug(3, "Finding end of pCAL purpose string\n"); + for (buf = purpose; *buf; buf++) + /* empty loop */ ; + + endptr = purpose + slength; + + /* We need to have at least 12 bytes after the purpose string + in order to get the parameter information. */ + if (endptr <= buf + 12) + { + png_warning(png_ptr, "Invalid pCAL data"); + png_free(png_ptr, purpose); + return; + } + + png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n"); + X0 = png_get_int_32((png_bytep)buf+1); + X1 = png_get_int_32((png_bytep)buf+5); + type = buf[9]; + nparams = buf[10]; + units = buf + 11; + + png_debug(3, "Checking pCAL equation type and number of parameters\n"); + /* Check that we have the right number of parameters for known + equation types. */ + if ((type == PNG_EQUATION_LINEAR && nparams != 2) || + (type == PNG_EQUATION_BASE_E && nparams != 3) || + (type == PNG_EQUATION_ARBITRARY && nparams != 3) || + (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) + { + png_warning(png_ptr, "Invalid pCAL parameters for equation type"); + png_free(png_ptr, purpose); + return; + } + else if (type >= PNG_EQUATION_LAST) + { + png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); + } + + for (buf = units; *buf; buf++) + /* Empty loop to move past the units string. */ ; + + png_debug(3, "Allocating pCAL parameters array\n"); + params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams + *png_sizeof(png_charp))) ; + if (params == NULL) + { + png_free(png_ptr, purpose); + png_warning(png_ptr, "No memory for pCAL params."); + return; + } + + /* Get pointers to the start of each parameter string. */ + for (i = 0; i < (int)nparams; i++) + { + buf++; /* Skip the null string terminator from previous parameter. */ + + png_debug1(3, "Reading pCAL parameter %d\n", i); + for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++) + /* Empty loop to move past each parameter string */ ; + + /* Make sure we haven't run out of data yet */ + if (buf > endptr) + { + png_warning(png_ptr, "Invalid pCAL data"); + png_free(png_ptr, purpose); + png_free(png_ptr, params); + return; + } + } + + png_set_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams, + units, params); + + png_free(png_ptr, purpose); + png_free(png_ptr, params); +} +#endif + +#if defined(PNG_READ_sCAL_SUPPORTED) +/* read the sCAL chunk */ +void /* PRIVATE */ +png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_charp buffer, ep; +#ifdef PNG_FLOATING_POINT_SUPPORTED + double width, height; + png_charp vp; +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + png_charp swidth, sheight; +#endif +#endif + png_size_t slength; + + png_debug(1, "in png_handle_sCAL\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before sCAL"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid sCAL after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) + { + png_warning(png_ptr, "Duplicate sCAL chunk"); + png_crc_finish(png_ptr, length); + return; + } + + png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n", + length + 1); + buffer = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (buffer == NULL) + { + png_warning(png_ptr, "Out of memory while processing sCAL chunk"); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)buffer, slength); + + if (png_crc_finish(png_ptr, 0)) + { + png_free(png_ptr, buffer); + return; + } + + buffer[slength] = 0x00; /* null terminate the last string */ + + ep = buffer + 1; /* skip unit byte */ + +#ifdef PNG_FLOATING_POINT_SUPPORTED + width = png_strtod(png_ptr, ep, &vp); + if (*vp) + { + png_warning(png_ptr, "malformed width string in sCAL chunk"); + return; + } +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); + if (swidth == NULL) + { + png_warning(png_ptr, "Out of memory while processing sCAL chunk width"); + return; + } + png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); +#endif +#endif + + for (ep = buffer; *ep; ep++) + /* empty loop */ ; + ep++; + +#ifdef PNG_FLOATING_POINT_SUPPORTED + height = png_strtod(png_ptr, ep, &vp); + if (*vp) + { + png_warning(png_ptr, "malformed height string in sCAL chunk"); + return; + } +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); + if (swidth == NULL) + { + png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); + return; + } + png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); +#endif +#endif + + if (buffer + slength < ep +#ifdef PNG_FLOATING_POINT_SUPPORTED + || width <= 0. || height <= 0. +#endif + ) + { + png_warning(png_ptr, "Invalid sCAL data"); + png_free(png_ptr, buffer); +#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) + png_free(png_ptr, swidth); + png_free(png_ptr, sheight); +#endif + return; + } + + +#ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_sCAL(png_ptr, info_ptr, buffer[0], width, height); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + png_set_sCAL_s(png_ptr, info_ptr, buffer[0], swidth, sheight); +#endif +#endif + + png_free(png_ptr, buffer); +#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) + png_free(png_ptr, swidth); + png_free(png_ptr, sheight); +#endif +} +#endif + +#if defined(PNG_READ_tIME_SUPPORTED) +void /* PRIVATE */ +png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_byte buf[7]; + png_time mod_time; + + png_debug(1, "in png_handle_tIME\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Out of place tIME chunk"); + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)) + { + png_warning(png_ptr, "Duplicate tIME chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (png_ptr->mode & PNG_HAVE_IDAT) + png_ptr->mode |= PNG_AFTER_IDAT; + + if (length != 7) + { + png_warning(png_ptr, "Incorrect tIME chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, 7); + if (png_crc_finish(png_ptr, 0)) + return; + + mod_time.second = buf[6]; + mod_time.minute = buf[5]; + mod_time.hour = buf[4]; + mod_time.day = buf[3]; + mod_time.month = buf[2]; + mod_time.year = png_get_uint_16(buf); + + png_set_tIME(png_ptr, info_ptr, &mod_time); +} +#endif + +#if defined(PNG_READ_tEXt_SUPPORTED) +/* Note: this does not properly handle chunks that are > 64K under DOS */ +void /* PRIVATE */ +png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_textp text_ptr; + png_charp key; + png_charp text; + png_uint_32 skip = 0; + png_size_t slength; + int ret; + + png_debug(1, "in png_handle_tEXt\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before tEXt"); + + if (png_ptr->mode & PNG_HAVE_IDAT) + png_ptr->mode |= PNG_AFTER_IDAT; + +#ifdef PNG_MAX_MALLOC_64K + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr, "tEXt chunk too large to fit in memory"); + skip = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + + key = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (key == NULL) + { + png_warning(png_ptr, "No memory to process text chunk."); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)key, slength); + + if (png_crc_finish(png_ptr, skip)) + { + png_free(png_ptr, key); + return; + } + + key[slength] = 0x00; + + for (text = key; *text; text++) + /* empty loop to find end of key */ ; + + if (text != key + slength) + text++; + + text_ptr = (png_textp)png_malloc_warn(png_ptr, + (png_uint_32)png_sizeof(png_text)); + if (text_ptr == NULL) + { + png_warning(png_ptr, "Not enough memory to process text chunk."); + png_free(png_ptr, key); + return; + } + text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr->key = key; +#ifdef PNG_iTXt_SUPPORTED + text_ptr->lang = NULL; + text_ptr->lang_key = NULL; + text_ptr->itxt_length = 0; +#endif + text_ptr->text = text; + text_ptr->text_length = png_strlen(text); + + ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_free(png_ptr, key); + png_free(png_ptr, text_ptr); + if (ret) + png_warning(png_ptr, "Insufficient memory to process text chunk."); +} +#endif + +#if defined(PNG_READ_zTXt_SUPPORTED) +/* note: this does not correctly handle chunks that are > 64K under DOS */ +void /* PRIVATE */ +png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_textp text_ptr; + png_charp chunkdata; + png_charp text; + int comp_type; + int ret; + png_size_t slength, prefix_len, data_len; + + png_debug(1, "in png_handle_zTXt\n"); + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before zTXt"); + + if (png_ptr->mode & PNG_HAVE_IDAT) + png_ptr->mode |= PNG_AFTER_IDAT; + +#ifdef PNG_MAX_MALLOC_64K + /* We will no doubt have problems with chunks even half this size, but + there is no hard and fast rule to tell us where to stop. */ + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr,"zTXt chunk too large to fit in memory"); + png_crc_finish(png_ptr, length); + return; + } +#endif + + chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (chunkdata == NULL) + { + png_warning(png_ptr,"Out of memory processing zTXt chunk."); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + if (png_crc_finish(png_ptr, 0)) + { + png_free(png_ptr, chunkdata); + return; + } + + chunkdata[slength] = 0x00; + + for (text = chunkdata; *text; text++) + /* empty loop */ ; + + /* zTXt must have some text after the chunkdataword */ + if (text == chunkdata + slength) + { + comp_type = PNG_TEXT_COMPRESSION_NONE; + png_warning(png_ptr, "Zero length zTXt chunk"); + } + else + { + comp_type = *(++text); + if (comp_type != PNG_TEXT_COMPRESSION_zTXt) + { + png_warning(png_ptr, "Unknown compression type in zTXt chunk"); + comp_type = PNG_TEXT_COMPRESSION_zTXt; + } + text++; /* skip the compression_method byte */ + } + prefix_len = text - chunkdata; + + chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata, + (png_size_t)length, prefix_len, &data_len); + + text_ptr = (png_textp)png_malloc_warn(png_ptr, + (png_uint_32)png_sizeof(png_text)); + if (text_ptr == NULL) + { + png_warning(png_ptr,"Not enough memory to process zTXt chunk."); + png_free(png_ptr, chunkdata); + return; + } + text_ptr->compression = comp_type; + text_ptr->key = chunkdata; +#ifdef PNG_iTXt_SUPPORTED + text_ptr->lang = NULL; + text_ptr->lang_key = NULL; + text_ptr->itxt_length = 0; +#endif + text_ptr->text = chunkdata + prefix_len; + text_ptr->text_length = data_len; + + ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_free(png_ptr, text_ptr); + png_free(png_ptr, chunkdata); + if (ret) + png_error(png_ptr, "Insufficient memory to store zTXt chunk."); +} +#endif + +#if defined(PNG_READ_iTXt_SUPPORTED) +/* note: this does not correctly handle chunks that are > 64K under DOS */ +void /* PRIVATE */ +png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_textp text_ptr; + png_charp chunkdata; + png_charp key, lang, text, lang_key; + int comp_flag; + int comp_type = 0; + int ret; + png_size_t slength, prefix_len, data_len; + + png_debug(1, "in png_handle_iTXt\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before iTXt"); + + if (png_ptr->mode & PNG_HAVE_IDAT) + png_ptr->mode |= PNG_AFTER_IDAT; + +#ifdef PNG_MAX_MALLOC_64K + /* We will no doubt have problems with chunks even half this size, but + there is no hard and fast rule to tell us where to stop. */ + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr,"iTXt chunk too large to fit in memory"); + png_crc_finish(png_ptr, length); + return; + } +#endif + + chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (chunkdata == NULL) + { + png_warning(png_ptr, "No memory to process iTXt chunk."); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + if (png_crc_finish(png_ptr, 0)) + { + png_free(png_ptr, chunkdata); + return; + } + + chunkdata[slength] = 0x00; + + for (lang = chunkdata; *lang; lang++) + /* empty loop */ ; + lang++; /* skip NUL separator */ + + /* iTXt must have a language tag (possibly empty), two compression bytes, + translated keyword (possibly empty), and possibly some text after the + keyword */ + + if (lang >= chunkdata + slength) + { + comp_flag = PNG_TEXT_COMPRESSION_NONE; + png_warning(png_ptr, "Zero length iTXt chunk"); + } + else + { + comp_flag = *lang++; + comp_type = *lang++; + } + + for (lang_key = lang; *lang_key; lang_key++) + /* empty loop */ ; + lang_key++; /* skip NUL separator */ + + for (text = lang_key; *text; text++) + /* empty loop */ ; + text++; /* skip NUL separator */ + + prefix_len = text - chunkdata; + + key=chunkdata; + if (comp_flag) + chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata, + (size_t)length, prefix_len, &data_len); + else + data_len=png_strlen(chunkdata + prefix_len); + text_ptr = (png_textp)png_malloc_warn(png_ptr, + (png_uint_32)png_sizeof(png_text)); + if (text_ptr == NULL) + { + png_warning(png_ptr,"Not enough memory to process iTXt chunk."); + png_free(png_ptr, chunkdata); + return; + } + text_ptr->compression = (int)comp_flag + 1; + text_ptr->lang_key = chunkdata+(lang_key-key); + text_ptr->lang = chunkdata+(lang-key); + text_ptr->itxt_length = data_len; + text_ptr->text_length = 0; + text_ptr->key = chunkdata; + text_ptr->text = chunkdata + prefix_len; + + ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_free(png_ptr, text_ptr); + png_free(png_ptr, chunkdata); + if (ret) + png_error(png_ptr, "Insufficient memory to store iTXt chunk."); +} +#endif + +/* This function is called when we haven't found a handler for a + chunk. If there isn't a problem with the chunk itself (ie bad + chunk name, CRC, or a critical chunk), the chunk is silently ignored + -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which + case it will be saved away to be written out later. */ +void /* PRIVATE */ +png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_uint_32 skip = 0; + + png_debug(1, "in png_handle_unknown\n"); + + if (png_ptr->mode & PNG_HAVE_IDAT) + { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IDAT; +#endif + if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */ + png_ptr->mode |= PNG_AFTER_IDAT; + } + + png_check_chunk_name(png_ptr, png_ptr->chunk_name); + + if (!(png_ptr->chunk_name[0] & 0x20)) + { +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != + PNG_HANDLE_CHUNK_ALWAYS +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) + && png_ptr->read_user_chunk_fn == NULL +#endif + ) +#endif + png_chunk_error(png_ptr, "unknown critical chunk"); + } + +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) || + (png_ptr->read_user_chunk_fn != NULL)) + { + png_unknown_chunk chunk; + +#ifdef PNG_MAX_MALLOC_64K + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr, "unknown chunk too large to fit in memory"); + skip = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); + chunk.data = (png_bytep)png_malloc(png_ptr, length); + chunk.size = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunk.data, length); +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) + if(png_ptr->read_user_chunk_fn != NULL) + { + /* callback to user unknown chunk handler */ + if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) + { + if (!(png_ptr->chunk_name[0] & 0x20)) + if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != + PNG_HANDLE_CHUNK_ALWAYS) + { + png_free(png_ptr, chunk.data); + png_chunk_error(png_ptr, "unknown critical chunk"); + } + png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); + } + } + else +#endif + png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); + png_free(png_ptr, chunk.data); + } + else +#endif + skip = length; + + png_crc_finish(png_ptr, skip); + +#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED) + if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */ + return; +#endif +} + +/* This function is called to verify that a chunk name is valid. + This function can't have the "critical chunk check" incorporated + into it, since in the future we will need to be able to call user + functions to handle unknown critical chunks after we check that + the chunk name itself is valid. */ + +#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) + +void /* PRIVATE */ +png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) +{ + png_debug(1, "in png_check_chunk_name\n"); + if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) || + isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3])) + { + png_chunk_error(png_ptr, "invalid chunk type"); + } +} + +/* Combines the row recently read in with the existing pixels in the + row. This routine takes care of alpha and transparency if requested. + This routine also handles the two methods of progressive display + of interlaced images, depending on the mask value. + The mask value describes which pixels are to be combined with + the row. The pattern always repeats every 8 pixels, so just 8 + bits are needed. A one indicates the pixel is to be combined, + a zero indicates the pixel is to be skipped. This is in addition + to any alpha or transparency value associated with the pixel. If + you want all pixels to be combined, pass 0xff (255) in mask. */ +#ifndef PNG_HAVE_MMX_COMBINE_ROW +void /* PRIVATE */ +png_combine_row(png_structp png_ptr, png_bytep row, int mask) +{ + png_debug(1,"in png_combine_row\n"); + if (mask == 0xff) + { + png_memcpy(row, png_ptr->row_buf + 1, + PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->width)); + } + else + { + switch (png_ptr->row_info.pixel_depth) + { + case 1: + { + png_bytep sp = png_ptr->row_buf + 1; + png_bytep dp = row; + int s_inc, s_start, s_end; + int m = 0x80; + int shift; + png_uint_32 i; + png_uint_32 row_width = png_ptr->width; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 7; + s_inc = 1; + } + else +#endif + { + s_start = 7; + s_end = 0; + s_inc = -1; + } + + shift = s_start; + + for (i = 0; i < row_width; i++) + { + if (m & mask) + { + int value; + + value = (*sp >> shift) & 0x01; + *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + case 2: + { + png_bytep sp = png_ptr->row_buf + 1; + png_bytep dp = row; + int s_start, s_end, s_inc; + int m = 0x80; + int shift; + png_uint_32 i; + png_uint_32 row_width = png_ptr->width; + int value; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 6; + s_inc = 2; + } + else +#endif + { + s_start = 6; + s_end = 0; + s_inc = -2; + } + + shift = s_start; + + for (i = 0; i < row_width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0x03; + *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + case 4: + { + png_bytep sp = png_ptr->row_buf + 1; + png_bytep dp = row; + int s_start, s_end, s_inc; + int m = 0x80; + int shift; + png_uint_32 i; + png_uint_32 row_width = png_ptr->width; + int value; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 4; + s_inc = 4; + } + else +#endif + { + s_start = 4; + s_end = 0; + s_inc = -4; + } + shift = s_start; + + for (i = 0; i < row_width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0xf; + *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + default: + { + png_bytep sp = png_ptr->row_buf + 1; + png_bytep dp = row; + png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + png_uint_32 i; + png_uint_32 row_width = png_ptr->width; + png_byte m = 0x80; + + + for (i = 0; i < row_width; i++) + { + if (m & mask) + { + png_memcpy(dp, sp, pixel_bytes); + } + + sp += pixel_bytes; + dp += pixel_bytes; + + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + } + } +} +#endif /* !PNG_HAVE_MMX_COMBINE_ROW */ + +#ifdef PNG_READ_INTERLACING_SUPPORTED +#ifndef PNG_HAVE_MMX_READ_INTERLACE /* else in pngvcrd.c, pnggccrd.c */ +/* OLD pre-1.0.9 interface: +void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, + png_uint_32 transformations) + */ +void /* PRIVATE */ +png_do_read_interlace(png_structp png_ptr) +{ + png_row_infop row_info = &(png_ptr->row_info); + png_bytep row = png_ptr->row_buf + 1; + int pass = png_ptr->pass; + png_uint_32 transformations = png_ptr->transformations; +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* offset to next interlace block */ + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +#endif + + png_debug(1,"in png_do_read_interlace (stock C version)\n"); + if (row != NULL && row_info != NULL) + { + png_uint_32 final_width; + + final_width = row_info->width * png_pass_inc[pass]; + + switch (row_info->pixel_depth) + { + case 1: + { + png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3); + png_bytep dp = row + (png_size_t)((final_width - 1) >> 3); + int sshift, dshift; + int s_start, s_end, s_inc; + int jstop = png_pass_inc[pass]; + png_byte v; + png_uint_32 i; + int j; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (int)((row_info->width + 7) & 0x07); + dshift = (int)((final_width + 7) & 0x07); + s_start = 7; + s_end = 0; + s_inc = -1; + } + else +#endif + { + sshift = 7 - (int)((row_info->width + 7) & 0x07); + dshift = 7 - (int)((final_width + 7) & 0x07); + s_start = 0; + s_end = 7; + s_inc = 1; + } + + for (i = 0; i < row_info->width; i++) + { + v = (png_byte)((*sp >> sshift) & 0x01); + for (j = 0; j < jstop; j++) + { + *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + case 2: + { + png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); + png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2); + int sshift, dshift; + int s_start, s_end, s_inc; + int jstop = png_pass_inc[pass]; + png_uint_32 i; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (int)(((row_info->width + 3) & 0x03) << 1); + dshift = (int)(((final_width + 3) & 0x03) << 1); + s_start = 6; + s_end = 0; + s_inc = -2; + } + else +#endif + { + sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1); + dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1); + s_start = 0; + s_end = 6; + s_inc = 2; + } + + for (i = 0; i < row_info->width; i++) + { + png_byte v; + int j; + + v = (png_byte)((*sp >> sshift) & 0x03); + for (j = 0; j < jstop; j++) + { + *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + case 4: + { + png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1); + png_bytep dp = row + (png_size_t)((final_width - 1) >> 1); + int sshift, dshift; + int s_start, s_end, s_inc; + png_uint_32 i; + int jstop = png_pass_inc[pass]; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (int)(((row_info->width + 1) & 0x01) << 2); + dshift = (int)(((final_width + 1) & 0x01) << 2); + s_start = 4; + s_end = 0; + s_inc = -4; + } + else +#endif + { + sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2); + dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2); + s_start = 0; + s_end = 4; + s_inc = 4; + } + + for (i = 0; i < row_info->width; i++) + { + png_byte v = (png_byte)((*sp >> sshift) & 0xf); + int j; + + for (j = 0; j < jstop; j++) + { + *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + default: + { + png_size_t pixel_bytes = (row_info->pixel_depth >> 3); + png_bytep sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes; + png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes; + + int jstop = png_pass_inc[pass]; + png_uint_32 i; + + for (i = 0; i < row_info->width; i++) + { + png_byte v[8]; + int j; + + png_memcpy(v, sp, pixel_bytes); + for (j = 0; j < jstop; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sp -= pixel_bytes; + } + break; + } + } + row_info->width = final_width; + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); + } +#if !defined(PNG_READ_PACKSWAP_SUPPORTED) + if (&transformations == NULL) /* silence compiler warning */ + return; +#endif +} +#endif /* !PNG_HAVE_MMX_READ_INTERLACE */ +#endif /* PNG_READ_INTERLACING_SUPPORTED */ + +#ifndef PNG_HAVE_MMX_READ_FILTER_ROW +void /* PRIVATE */ +png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, + png_bytep prev_row, int filter) +{ + png_debug(1, "in png_read_filter_row\n"); + png_debug2(2,"row = %lu, filter = %d\n", png_ptr->row_number, filter); + switch (filter) + { + case PNG_FILTER_VALUE_NONE: + break; + case PNG_FILTER_VALUE_SUB: + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_bytep rp = row + bpp; + png_bytep lp = row; + + for (i = bpp; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); + rp++; + } + break; + } + case PNG_FILTER_VALUE_UP: + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_bytep rp = row; + png_bytep pp = prev_row; + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + break; + } + case PNG_FILTER_VALUE_AVG: + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop = row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++) / 2 )) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + + (int)(*pp++ + *lp++) / 2 ) & 0xff); + rp++; + } + break; + } + case PNG_FILTER_VALUE_PAETH: + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_bytep cp = prev_row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop=row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) /* use leftover rp,pp */ + { + int a, b, c, pa, pb, pc, p; + + a = *lp++; + b = *pp++; + c = *cp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + /* + if (pa <= pb && pa <= pc) + p = a; + else if (pb <= pc) + p = b; + else + p = c; + */ + + p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; + + *rp = (png_byte)(((int)(*rp) + p) & 0xff); + rp++; + } + break; + } + default: + png_warning(png_ptr, "Ignoring bad adaptive filter type"); + *row=0; + break; + } +} +#endif /* !PNG_HAVE_MMX_READ_FILTER_ROW */ + +void /* PRIVATE */ +png_read_finish_row(png_structp png_ptr) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + + /* start of interlace block */ + const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + + /* offset to next interlace block */ + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + + /* start of interlace block in the y direction */ + const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + + /* offset to next interlace block in the y direction */ + const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; +#endif + + png_debug(1, "in png_read_finish_row\n"); + png_ptr->row_number++; + if (png_ptr->row_number < png_ptr->num_rows) + return; + + if (png_ptr->interlaced) + { + png_ptr->row_number = 0; + png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); + do + { + png_ptr->pass++; + if (png_ptr->pass >= 7) + break; + png_ptr->iwidth = (png_ptr->width + + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; + + png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, + png_ptr->iwidth) + 1; + + if (!(png_ptr->transformations & PNG_INTERLACE)) + { + png_ptr->num_rows = (png_ptr->height + + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; + if (!(png_ptr->num_rows)) + continue; + } + else /* if (png_ptr->transformations & PNG_INTERLACE) */ + break; + } while (png_ptr->iwidth == 0); + + if (png_ptr->pass < 7) + return; + } + + if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) + { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IDAT; +#endif + char extra; + int ret; + + png_ptr->zstream.next_out = (Byte *)&extra; + png_ptr->zstream.avail_out = (uInt)1; + for(;;) + { + if (!(png_ptr->zstream.avail_in)) + { + while (!png_ptr->idat_size) + { + png_byte chunk_length[4]; + + png_crc_finish(png_ptr, 0); + + png_read_data(png_ptr, chunk_length, 4); + png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length); + png_reset_crc(png_ptr); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); + if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) + png_error(png_ptr, "Not enough image data"); + + } + png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; + png_ptr->zstream.next_in = png_ptr->zbuf; + if (png_ptr->zbuf_size > png_ptr->idat_size) + png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; + png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in); + png_ptr->idat_size -= png_ptr->zstream.avail_in; + } + ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); + if (ret == Z_STREAM_END) + { + if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in || + png_ptr->idat_size) + png_warning(png_ptr, "Extra compressed data"); + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; + break; + } + if (ret != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : + "Decompression Error"); + + if (!(png_ptr->zstream.avail_out)) + { + png_warning(png_ptr, "Extra compressed data."); + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; + break; + } + + } + png_ptr->zstream.avail_out = 0; + } + + if (png_ptr->idat_size || png_ptr->zstream.avail_in) + png_warning(png_ptr, "Extra compression data"); + + inflateReset(&png_ptr->zstream); + + png_ptr->mode |= PNG_AFTER_IDAT; +} + +void /* PRIVATE */ +png_read_start_row(png_structp png_ptr) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + + /* start of interlace block */ + const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + + /* offset to next interlace block */ + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + + /* start of interlace block in the y direction */ + const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + + /* offset to next interlace block in the y direction */ + const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; +#endif + + int max_pixel_depth; + png_uint_32 row_bytes; + + png_debug(1, "in png_read_start_row\n"); + png_ptr->zstream.avail_in = 0; + png_init_read_transformations(png_ptr); + if (png_ptr->interlaced) + { + if (!(png_ptr->transformations & PNG_INTERLACE)) + png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - + png_pass_ystart[0]) / png_pass_yinc[0]; + else + png_ptr->num_rows = png_ptr->height; + + png_ptr->iwidth = (png_ptr->width + + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; + + row_bytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->iwidth) + 1; + + png_ptr->irowbytes = (png_size_t)row_bytes; + if((png_uint_32)png_ptr->irowbytes != row_bytes) + png_error(png_ptr, "Rowbytes overflow in png_read_start_row"); + } + else + { + png_ptr->num_rows = png_ptr->height; + png_ptr->iwidth = png_ptr->width; + png_ptr->irowbytes = png_ptr->rowbytes + 1; + } + max_pixel_depth = png_ptr->pixel_depth; + +#if defined(PNG_READ_PACK_SUPPORTED) + if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8) + max_pixel_depth = 8; +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) + if (png_ptr->transformations & PNG_EXPAND) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (png_ptr->num_trans) + max_pixel_depth = 32; + else + max_pixel_depth = 24; + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) + { + if (max_pixel_depth < 8) + max_pixel_depth = 8; + if (png_ptr->num_trans) + max_pixel_depth *= 2; + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) + { + if (png_ptr->num_trans) + { + max_pixel_depth *= 4; + max_pixel_depth /= 3; + } + } + } +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) + if (png_ptr->transformations & (PNG_FILLER)) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + max_pixel_depth = 32; + else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) + { + if (max_pixel_depth <= 8) + max_pixel_depth = 16; + else + max_pixel_depth = 32; + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) + { + if (max_pixel_depth <= 32) + max_pixel_depth = 32; + else + max_pixel_depth = 64; + } + } +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) + if (png_ptr->transformations & PNG_GRAY_TO_RGB) + { + if ( +#if defined(PNG_READ_EXPAND_SUPPORTED) + (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) || +#endif +#if defined(PNG_READ_FILLER_SUPPORTED) + (png_ptr->transformations & (PNG_FILLER)) || +#endif + png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + if (max_pixel_depth <= 16) + max_pixel_depth = 32; + else + max_pixel_depth = 64; + } + else + { + if (max_pixel_depth <= 8) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + max_pixel_depth = 32; + else + max_pixel_depth = 24; + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + max_pixel_depth = 64; + else + max_pixel_depth = 48; + } + } +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ +defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) + if(png_ptr->transformations & PNG_USER_TRANSFORM) + { + int user_pixel_depth=png_ptr->user_transform_depth* + png_ptr->user_transform_channels; + if(user_pixel_depth > max_pixel_depth) + max_pixel_depth=user_pixel_depth; + } +#endif + + /* align the width on the next larger 8 pixels. Mainly used + for interlacing */ + row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7)); + /* calculate the maximum bytes needed, adding a byte and a pixel + for safety's sake */ + row_bytes = PNG_ROWBYTES(max_pixel_depth,row_bytes) + + 1 + ((max_pixel_depth + 7) >> 3); +#ifdef PNG_MAX_MALLOC_64K + if (row_bytes > (png_uint_32)65536L) + png_error(png_ptr, "This image requires a row greater than 64KB"); +#endif + png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64); + png_ptr->row_buf = png_ptr->big_row_buf+32; +#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD) + png_ptr->row_buf_size = row_bytes; +#endif + +#ifdef PNG_MAX_MALLOC_64K + if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) + png_error(png_ptr, "This image requires a row greater than 64KB"); +#endif + if ((png_uint_32)png_ptr->rowbytes > (png_uint_32)(PNG_SIZE_MAX - 1)) + png_error(png_ptr, "Row has too many bytes to allocate in memory."); + png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)( + png_ptr->rowbytes + 1)); + + png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); + + png_debug1(3, "width = %lu,\n", png_ptr->width); + png_debug1(3, "height = %lu,\n", png_ptr->height); + png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth); + png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows); + png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes); + png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes); + + png_ptr->flags |= PNG_FLAG_ROW_INIT; +} +#endif /* PNG_READ_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/pngset.c b/src/dep/src/irrlicht/libpng/pngset.c index 3e80195..24fa24d 100644 --- a/src/dep/src/irrlicht/libpng/pngset.c +++ b/src/dep/src/irrlicht/libpng/pngset.c @@ -1,1269 +1,1269 @@ - -/* pngset.c - storage of image information into info struct - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * The functions here are used during reads to store data from the file - * into the info struct, and during writes to store application data - * into the info struct for writing into the file. This abstracts the - * info struct and allows us to change the structure in the future. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -#if defined(PNG_bKGD_SUPPORTED) -void PNGAPI -png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) -{ - png_debug1(1, "in %s storage function\n", "bKGD"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16)); - info_ptr->valid |= PNG_INFO_bKGD; -} -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_cHRM(png_structp png_ptr, png_infop info_ptr, - double white_x, double white_y, double red_x, double red_y, - double green_x, double green_y, double blue_x, double blue_y) -{ - png_debug1(1, "in %s storage function\n", "cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (white_x < 0.0 || white_y < 0.0 || - red_x < 0.0 || red_y < 0.0 || - green_x < 0.0 || green_y < 0.0 || - blue_x < 0.0 || blue_y < 0.0) - { - png_warning(png_ptr, - "Ignoring attempt to set negative chromaticity value"); - return; - } - if (white_x > 21474.83 || white_y > 21474.83 || - red_x > 21474.83 || red_y > 21474.83 || - green_x > 21474.83 || green_y > 21474.83 || - blue_x > 21474.83 || blue_y > 21474.83) - { - png_warning(png_ptr, - "Ignoring attempt to set chromaticity value exceeding 21474.83"); - return; - } - - info_ptr->x_white = (float)white_x; - info_ptr->y_white = (float)white_y; - info_ptr->x_red = (float)red_x; - info_ptr->y_red = (float)red_y; - info_ptr->x_green = (float)green_x; - info_ptr->y_green = (float)green_y; - info_ptr->x_blue = (float)blue_x; - info_ptr->y_blue = (float)blue_y; -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5); - info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5); - info_ptr->int_x_red = (png_fixed_point)( red_x*100000.+0.5); - info_ptr->int_y_red = (png_fixed_point)( red_y*100000.+0.5); - info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5); - info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5); - info_ptr->int_x_blue = (png_fixed_point)( blue_x*100000.+0.5); - info_ptr->int_y_blue = (png_fixed_point)( blue_y*100000.+0.5); -#endif - info_ptr->valid |= PNG_INFO_cHRM; -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, - png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, - png_fixed_point blue_x, png_fixed_point blue_y) -{ - png_debug1(1, "in %s storage function\n", "cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (white_x < 0 || white_y < 0 || - red_x < 0 || red_y < 0 || - green_x < 0 || green_y < 0 || - blue_x < 0 || blue_y < 0) - { - png_warning(png_ptr, - "Ignoring attempt to set negative chromaticity value"); - return; - } -#ifdef PNG_FLOATING_POINT_SUPPORTED - if (white_x > (double) PNG_UINT_31_MAX || - white_y > (double) PNG_UINT_31_MAX || - red_x > (double) PNG_UINT_31_MAX || - red_y > (double) PNG_UINT_31_MAX || - green_x > (double) PNG_UINT_31_MAX || - green_y > (double) PNG_UINT_31_MAX || - blue_x > (double) PNG_UINT_31_MAX || - blue_y > (double) PNG_UINT_31_MAX) -#else - if (white_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - white_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || - red_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - red_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || - green_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - green_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || - blue_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - blue_y > (png_fixed_point) PNG_UINT_31_MAX/100000L) -#endif - { - png_warning(png_ptr, - "Ignoring attempt to set chromaticity value exceeding 21474.83"); - return; - } - info_ptr->int_x_white = white_x; - info_ptr->int_y_white = white_y; - info_ptr->int_x_red = red_x; - info_ptr->int_y_red = red_y; - info_ptr->int_x_green = green_x; - info_ptr->int_y_green = green_y; - info_ptr->int_x_blue = blue_x; - info_ptr->int_y_blue = blue_y; -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->x_white = (float)(white_x/100000.); - info_ptr->y_white = (float)(white_y/100000.); - info_ptr->x_red = (float)( red_x/100000.); - info_ptr->y_red = (float)( red_y/100000.); - info_ptr->x_green = (float)(green_x/100000.); - info_ptr->y_green = (float)(green_y/100000.); - info_ptr->x_blue = (float)( blue_x/100000.); - info_ptr->y_blue = (float)( blue_y/100000.); -#endif - info_ptr->valid |= PNG_INFO_cHRM; -} -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) -{ - double gamma; - png_debug1(1, "in %s storage function\n", "gAMA"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* Check for overflow */ - if (file_gamma > 21474.83) - { - png_warning(png_ptr, "Limiting gamma to 21474.83"); - gamma=21474.83; - } - else - gamma=file_gamma; - info_ptr->gamma = (float)gamma; -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = (int)(gamma*100000.+.5); -#endif - info_ptr->valid |= PNG_INFO_gAMA; - if(gamma == 0.0) - png_warning(png_ptr, "Setting gamma=0"); -} -#endif -void PNGAPI -png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point - int_gamma) -{ - png_fixed_point gamma; - - png_debug1(1, "in %s storage function\n", "gAMA"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX) - { - png_warning(png_ptr, "Limiting gamma to 21474.83"); - gamma=PNG_UINT_31_MAX; - } - else - { - if (int_gamma < 0) - { - png_warning(png_ptr, "Setting negative gamma to zero"); - gamma=0; - } - else - gamma=int_gamma; - } -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = (float)(gamma/100000.); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = gamma; -#endif - info_ptr->valid |= PNG_INFO_gAMA; - if(gamma == 0) - png_warning(png_ptr, "Setting gamma=0"); -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -void PNGAPI -png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) -{ - int i; - - png_debug1(1, "in %s storage function\n", "hIST"); - if (png_ptr == NULL || info_ptr == NULL) - return; - if (info_ptr->num_palette <= 0 || info_ptr->num_palette - > PNG_MAX_PALETTE_LENGTH) - { - png_warning(png_ptr, - "Invalid palette size, hIST allocation skipped."); - return; - } - -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); -#endif - /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in version - 1.2.1 */ - png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, - (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof (png_uint_16))); - if (png_ptr->hist == NULL) - { - png_warning(png_ptr, "Insufficient memory for hIST chunk data."); - return; - } - - for (i = 0; i < info_ptr->num_palette; i++) - png_ptr->hist[i] = hist[i]; - info_ptr->hist = png_ptr->hist; - info_ptr->valid |= PNG_INFO_hIST; - -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_HIST; -#else - png_ptr->flags |= PNG_FLAG_FREE_HIST; -#endif -} -#endif - -void PNGAPI -png_set_IHDR(png_structp png_ptr, png_infop info_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_type, int compression_type, - int filter_type) -{ - png_debug1(1, "in %s storage function\n", "IHDR"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* check for width and height valid values */ - if (width == 0 || height == 0) - png_error(png_ptr, "Image width or height is zero in IHDR"); -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (width > png_ptr->user_width_max || height > png_ptr->user_height_max) - png_error(png_ptr, "image size exceeds user limits in IHDR"); -#else - if (width > PNG_USER_WIDTH_MAX || height > PNG_USER_HEIGHT_MAX) - png_error(png_ptr, "image size exceeds user limits in IHDR"); -#endif - if (width > PNG_UINT_31_MAX || height > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image size in IHDR"); - if ( width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 64 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - png_warning(png_ptr, "Width is too large for libpng to process pixels"); - - /* check other values */ - if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && - bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth in IHDR"); - - if (color_type < 0 || color_type == 1 || - color_type == 5 || color_type > 6) - png_error(png_ptr, "Invalid color type in IHDR"); - - if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || - ((color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) - png_error(png_ptr, "Invalid color type/bit depth combination in IHDR"); - - if (interlace_type >= PNG_INTERLACE_LAST) - png_error(png_ptr, "Unknown interlace method in IHDR"); - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_error(png_ptr, "Unknown compression method in IHDR"); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - /* Accept filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not read a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream"); - if(filter_type != PNG_FILTER_TYPE_BASE) - { - if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA))) - png_error(png_ptr, "Unknown filter method in IHDR"); - if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) - png_warning(png_ptr, "Invalid filter method in IHDR"); - } -#else - if(filter_type != PNG_FILTER_TYPE_BASE) - png_error(png_ptr, "Unknown filter method in IHDR"); -#endif - - info_ptr->width = width; - info_ptr->height = height; - info_ptr->bit_depth = (png_byte)bit_depth; - info_ptr->color_type =(png_byte) color_type; - info_ptr->compression_type = (png_byte)compression_type; - info_ptr->filter_type = (png_byte)filter_type; - info_ptr->interlace_type = (png_byte)interlace_type; - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - info_ptr->channels = 1; - else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) - info_ptr->channels = 3; - else - info_ptr->channels = 1; - if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) - info_ptr->channels++; - info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); - - /* check for potential overflow */ - if ( width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 64 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - info_ptr->rowbytes = (png_size_t)0; - else - info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,width); -} - -#if defined(PNG_oFFs_SUPPORTED) -void PNGAPI -png_set_oFFs(png_structp png_ptr, png_infop info_ptr, - png_int_32 offset_x, png_int_32 offset_y, int unit_type) -{ - png_debug1(1, "in %s storage function\n", "oFFs"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->x_offset = offset_x; - info_ptr->y_offset = offset_y; - info_ptr->offset_unit_type = (png_byte)unit_type; - info_ptr->valid |= PNG_INFO_oFFs; -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -void PNGAPI -png_set_pCAL(png_structp png_ptr, png_infop info_ptr, - png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, - png_charp units, png_charpp params) -{ - png_uint_32 length; - int i; - - png_debug1(1, "in %s storage function\n", "pCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - length = png_strlen(purpose) + 1; - png_debug1(3, "allocating purpose for info (%lu bytes)\n", length); - info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->pcal_purpose == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL purpose."); - return; - } - png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); - - png_debug(3, "storing X0, X1, type, and nparams in info\n"); - info_ptr->pcal_X0 = X0; - info_ptr->pcal_X1 = X1; - info_ptr->pcal_type = (png_byte)type; - info_ptr->pcal_nparams = (png_byte)nparams; - - length = png_strlen(units) + 1; - png_debug1(3, "allocating units for info (%lu bytes)\n", length); - info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->pcal_units == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL units."); - return; - } - png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); - - info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, - (png_uint_32)((nparams + 1) * png_sizeof(png_charp))); - if (info_ptr->pcal_params == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL params."); - return; - } - - info_ptr->pcal_params[nparams] = NULL; - - for (i = 0; i < nparams; i++) - { - length = png_strlen(params[i]) + 1; - png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length); - info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->pcal_params[i] == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL parameter."); - return; - } - png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); - } - - info_ptr->valid |= PNG_INFO_pCAL; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_PCAL; -#endif -} -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_sCAL(png_structp png_ptr, png_infop info_ptr, - int unit, double width, double height) -{ - png_debug1(1, "in %s storage function\n", "sCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->scal_unit = (png_byte)unit; - info_ptr->scal_pixel_width = width; - info_ptr->scal_pixel_height = height; - - info_ptr->valid |= PNG_INFO_sCAL; -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, - int unit, png_charp swidth, png_charp sheight) -{ - png_uint_32 length; - - png_debug1(1, "in %s storage function\n", "sCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->scal_unit = (png_byte)unit; - - length = png_strlen(swidth) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); - info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->scal_s_width == NULL) - { - png_warning(png_ptr, "Memory allocation failed while processing sCAL."); - } - png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); - - length = png_strlen(sheight) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); - info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->scal_s_height == NULL) - { - png_free (png_ptr, info_ptr->scal_s_width); - png_warning(png_ptr, "Memory allocation failed while processing sCAL."); - } - png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); - - info_ptr->valid |= PNG_INFO_sCAL; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_SCAL; -#endif -} -#endif -#endif -#endif - -#if defined(PNG_pHYs_SUPPORTED) -void PNGAPI -png_set_pHYs(png_structp png_ptr, png_infop info_ptr, - png_uint_32 res_x, png_uint_32 res_y, int unit_type) -{ - png_debug1(1, "in %s storage function\n", "pHYs"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->x_pixels_per_unit = res_x; - info_ptr->y_pixels_per_unit = res_y; - info_ptr->phys_unit_type = (png_byte)unit_type; - info_ptr->valid |= PNG_INFO_pHYs; -} -#endif - -void PNGAPI -png_set_PLTE(png_structp png_ptr, png_infop info_ptr, - png_colorp palette, int num_palette) -{ - - png_debug1(1, "in %s storage function\n", "PLTE"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH) - { - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - png_error(png_ptr, "Invalid palette length"); - else - { - png_warning(png_ptr, "Invalid palette length"); - return; - } - } - - /* - * It may not actually be necessary to set png_ptr->palette here; - * we do it for backward compatibility with the way the png_handle_tRNS - * function used to do the allocation. - */ -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); -#endif - - /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead - of num_palette entries, - in case of an invalid PNG file that has too-large sample values. */ - png_ptr->palette = (png_colorp)png_malloc(png_ptr, - PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); - png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH * - png_sizeof(png_color)); - png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof (png_color)); - info_ptr->palette = png_ptr->palette; - info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; - -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_PLTE; -#else - png_ptr->flags |= PNG_FLAG_FREE_PLTE; -#endif - - info_ptr->valid |= PNG_INFO_PLTE; -} - -#if defined(PNG_sBIT_SUPPORTED) -void PNGAPI -png_set_sBIT(png_structp png_ptr, png_infop info_ptr, - png_color_8p sig_bit) -{ - png_debug1(1, "in %s storage function\n", "sBIT"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof (png_color_8)); - info_ptr->valid |= PNG_INFO_sBIT; -} -#endif - -#if defined(PNG_sRGB_SUPPORTED) -void PNGAPI -png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) -{ - png_debug1(1, "in %s storage function\n", "sRGB"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->srgb_intent = (png_byte)intent; - info_ptr->valid |= PNG_INFO_sRGB; -} - -void PNGAPI -png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, - int intent) -{ -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - float file_gamma; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_fixed_point int_file_gamma; -#endif -#endif -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, - int_green_y, int_blue_x, int_blue_y; -#endif -#endif - png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_set_sRGB(png_ptr, info_ptr, intent); - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - file_gamma = (float).45455; - png_set_gAMA(png_ptr, info_ptr, file_gamma); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - int_file_gamma = 45455L; - png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma); -#endif -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FIXED_POINT_SUPPORTED - int_white_x = 31270L; - int_white_y = 32900L; - int_red_x = 64000L; - int_red_y = 33000L; - int_green_x = 30000L; - int_green_y = 60000L; - int_blue_x = 15000L; - int_blue_y = 6000L; - - png_set_cHRM_fixed(png_ptr, info_ptr, - int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, - int_blue_x, int_blue_y); -#endif -#ifdef PNG_FLOATING_POINT_SUPPORTED - white_x = (float).3127; - white_y = (float).3290; - red_x = (float).64; - red_y = (float).33; - green_x = (float).30; - green_y = (float).60; - blue_x = (float).15; - blue_y = (float).06; - - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); -#endif -#endif -} -#endif - - -#if defined(PNG_iCCP_SUPPORTED) -void PNGAPI -png_set_iCCP(png_structp png_ptr, png_infop info_ptr, - png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen) -{ - png_charp new_iccp_name; - png_charp new_iccp_profile; - - png_debug1(1, "in %s storage function\n", "iCCP"); - if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) - return; - - new_iccp_name = (png_charp)png_malloc_warn(png_ptr, png_strlen(name)+1); - if (new_iccp_name == NULL) - { - png_warning(png_ptr, "Insufficient memory to process iCCP chunk."); - return; - } - png_strcpy(new_iccp_name, name); - new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen); - if (new_iccp_profile == NULL) - { - png_free (png_ptr, new_iccp_name); - png_warning(png_ptr, "Insufficient memory to process iCCP profile."); - return; - } - png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); - - png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); - - info_ptr->iccp_proflen = proflen; - info_ptr->iccp_name = new_iccp_name; - info_ptr->iccp_profile = new_iccp_profile; - /* Compression is always zero but is here so the API and info structure - * does not have to change if we introduce multiple compression types */ - info_ptr->iccp_compression = (png_byte)compression_type; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_ICCP; -#endif - info_ptr->valid |= PNG_INFO_iCCP; -} -#endif - -#if defined(PNG_TEXT_SUPPORTED) -void PNGAPI -png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, - int num_text) -{ - int ret; - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); - if (ret) - png_error(png_ptr, "Insufficient memory to store text"); -} - -int /* PRIVATE */ -png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, - int num_text) -{ - int i; - - png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ? - "text" : (png_const_charp)png_ptr->chunk_name)); - - if (png_ptr == NULL || info_ptr == NULL || num_text == 0) - return(0); - - /* Make sure we have enough space in the "text" array in info_struct - * to hold all of the incoming text_ptr objects. - */ - if (info_ptr->num_text + num_text > info_ptr->max_text) - { - if (info_ptr->text != NULL) - { - png_textp old_text; - int old_max; - - old_max = info_ptr->max_text; - info_ptr->max_text = info_ptr->num_text + num_text + 8; - old_text = info_ptr->text; - info_ptr->text = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); - if (info_ptr->text == NULL) - { - png_free(png_ptr, old_text); - return(1); - } - png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * - png_sizeof(png_text))); - png_free(png_ptr, old_text); - } - else - { - info_ptr->max_text = num_text + 8; - info_ptr->num_text = 0; - info_ptr->text = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); - if (info_ptr->text == NULL) - return(1); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_TEXT; -#endif - } - png_debug1(3, "allocated %d entries for info_ptr->text\n", - info_ptr->max_text); - } - for (i = 0; i < num_text; i++) - { - png_size_t text_length,key_len; - png_size_t lang_len,lang_key_len; - png_textp textp = &(info_ptr->text[info_ptr->num_text]); - - if (text_ptr[i].key == NULL) - continue; - - key_len = png_strlen(text_ptr[i].key); - - if(text_ptr[i].compression <= 0) - { - lang_len = 0; - lang_key_len = 0; - } - else -#ifdef PNG_iTXt_SUPPORTED - { - /* set iTXt data */ - if (text_ptr[i].lang != NULL) - lang_len = png_strlen(text_ptr[i].lang); - else - lang_len = 0; - if (text_ptr[i].lang_key != NULL) - lang_key_len = png_strlen(text_ptr[i].lang_key); - else - lang_key_len = 0; - } -#else - { - png_warning(png_ptr, "iTXt chunk not supported."); - continue; - } -#endif - - if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') - { - text_length = 0; -#ifdef PNG_iTXt_SUPPORTED - if(text_ptr[i].compression > 0) - textp->compression = PNG_ITXT_COMPRESSION_NONE; - else -#endif - textp->compression = PNG_TEXT_COMPRESSION_NONE; - } - else - { - text_length = png_strlen(text_ptr[i].text); - textp->compression = text_ptr[i].compression; - } - - textp->key = (png_charp)png_malloc_warn(png_ptr, - (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); - if (textp->key == NULL) - return(1); - png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", - (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4), - (int)textp->key); - - png_memcpy(textp->key, text_ptr[i].key, - (png_size_t)(key_len)); - *(textp->key+key_len) = '\0'; -#ifdef PNG_iTXt_SUPPORTED - if (text_ptr[i].compression > 0) - { - textp->lang=textp->key + key_len + 1; - png_memcpy(textp->lang, text_ptr[i].lang, lang_len); - *(textp->lang+lang_len) = '\0'; - textp->lang_key=textp->lang + lang_len + 1; - png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); - *(textp->lang_key+lang_key_len) = '\0'; - textp->text=textp->lang_key + lang_key_len + 1; - } - else -#endif - { -#ifdef PNG_iTXt_SUPPORTED - textp->lang=NULL; - textp->lang_key=NULL; -#endif - textp->text=textp->key + key_len + 1; - } - if(text_length) - png_memcpy(textp->text, text_ptr[i].text, - (png_size_t)(text_length)); - *(textp->text+text_length) = '\0'; - -#ifdef PNG_iTXt_SUPPORTED - if(textp->compression > 0) - { - textp->text_length = 0; - textp->itxt_length = text_length; - } - else -#endif - { - textp->text_length = text_length; -#ifdef PNG_iTXt_SUPPORTED - textp->itxt_length = 0; -#endif - } - info_ptr->text[info_ptr->num_text]= *textp; - info_ptr->num_text++; - png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); - } - return(0); -} -#endif - -#if defined(PNG_tIME_SUPPORTED) -void PNGAPI -png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) -{ - png_debug1(1, "in %s storage function\n", "tIME"); - if (png_ptr == NULL || info_ptr == NULL || - (png_ptr->mode & PNG_WROTE_tIME)) - return; - - png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof (png_time)); - info_ptr->valid |= PNG_INFO_tIME; -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -void PNGAPI -png_set_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep trans, int num_trans, png_color_16p trans_values) -{ - png_debug1(1, "in %s storage function\n", "tRNS"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (trans != NULL) - { - /* - * It may not actually be necessary to set png_ptr->trans here; - * we do it for backward compatibility with the way the png_handle_tRNS - * function used to do the allocation. - */ -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); -#endif - /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ - png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, - (png_uint_32)PNG_MAX_PALETTE_LENGTH); - if (num_trans <= PNG_MAX_PALETTE_LENGTH) - png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_TRNS; -#else - png_ptr->flags |= PNG_FLAG_FREE_TRNS; -#endif - } - - if (trans_values != NULL) - { - png_memcpy(&(info_ptr->trans_values), trans_values, - png_sizeof(png_color_16)); - if (num_trans == 0) - num_trans = 1; - } - info_ptr->num_trans = (png_uint_16)num_trans; - info_ptr->valid |= PNG_INFO_tRNS; -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -void PNGAPI -png_set_sPLT(png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries) -{ - png_sPLT_tp np; - int i; - - if (png_ptr == NULL || info_ptr == NULL) - return; - - np = (png_sPLT_tp)png_malloc_warn(png_ptr, - (info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t)); - if (np == NULL) - { - png_warning(png_ptr, "No memory for sPLT palettes."); - return; - } - - png_memcpy(np, info_ptr->splt_palettes, - info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t)); - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes=NULL; - - for (i = 0; i < nentries; i++) - { - png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; - png_sPLT_tp from = entries + i; - - to->name = (png_charp)png_malloc(png_ptr, - png_strlen(from->name) + 1); - /* TODO: use png_malloc_warn */ - png_strcpy(to->name, from->name); - to->entries = (png_sPLT_entryp)png_malloc(png_ptr, - from->nentries * png_sizeof(png_sPLT_entry)); - /* TODO: use png_malloc_warn */ - png_memcpy(to->entries, from->entries, - from->nentries * png_sizeof(png_sPLT_entry)); - to->nentries = from->nentries; - to->depth = from->depth; - } - - info_ptr->splt_palettes = np; - info_ptr->splt_palettes_num += nentries; - info_ptr->valid |= PNG_INFO_sPLT; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_SPLT; -#endif -} -#endif /* PNG_sPLT_SUPPORTED */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -void PNGAPI -png_set_unknown_chunks(png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) -{ - png_unknown_chunkp np; - int i; - - if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) - return; - - np = (png_unknown_chunkp)png_malloc_warn(png_ptr, - (info_ptr->unknown_chunks_num + num_unknowns) * - png_sizeof(png_unknown_chunk)); - if (np == NULL) - { - png_warning(png_ptr, "Out of memory while processing unknown chunk."); - return; - } - - png_memcpy(np, info_ptr->unknown_chunks, - info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk)); - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks=NULL; - - for (i = 0; i < num_unknowns; i++) - { - png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; - png_unknown_chunkp from = unknowns + i; - - png_strncpy((png_charp)to->name, (png_charp)from->name, 5); - to->data = (png_bytep)png_malloc_warn(png_ptr, from->size); - if (to->data == NULL) - { - png_warning(png_ptr, "Out of memory processing unknown chunk."); - } - else - { - png_memcpy(to->data, from->data, from->size); - to->size = from->size; - - /* note our location in the read or write sequence */ - to->location = (png_byte)(png_ptr->mode & 0xff); - } - } - - info_ptr->unknown_chunks = np; - info_ptr->unknown_chunks_num += num_unknowns; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_UNKN; -#endif -} -void PNGAPI -png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, - int chunk, int location) -{ - if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < - (int)info_ptr->unknown_chunks_num) - info_ptr->unknown_chunks[chunk].location = (png_byte)location; -} -#endif - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -void PNGAPI -png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) -{ - /* This function is deprecated in favor of png_permit_mng_features() - and will be removed from libpng-1.3.0 */ - png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n"); - if (png_ptr == NULL) - return; - png_ptr->mng_features_permitted = (png_byte) - ((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) | - ((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE))); -} -#endif -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -png_uint_32 PNGAPI -png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) -{ - png_debug(1, "in png_permit_mng_features\n"); - if (png_ptr == NULL) - return (png_uint_32)0; - png_ptr->mng_features_permitted = - (png_byte)(mng_features & PNG_ALL_MNG_FEATURES); - return (png_uint_32)png_ptr->mng_features_permitted; -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -void PNGAPI -png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep - chunk_list, int num_chunks) -{ - png_bytep new_list, p; - int i, old_num_chunks; - if (png_ptr == NULL) - return; - if (num_chunks == 0) - { - if(keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE) - png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; - else - png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; - - if(keep == PNG_HANDLE_CHUNK_ALWAYS) - png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; - else - png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; - return; - } - if (chunk_list == NULL) - return; - old_num_chunks=png_ptr->num_chunk_list; - new_list=(png_bytep)png_malloc(png_ptr, - (png_uint_32)(5*(num_chunks+old_num_chunks))); - if(png_ptr->chunk_list != NULL) - { - png_memcpy(new_list, png_ptr->chunk_list, - (png_size_t)(5*old_num_chunks)); - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - } - png_memcpy(new_list+5*old_num_chunks, chunk_list, - (png_size_t)(5*num_chunks)); - for (p=new_list+5*old_num_chunks+4, i=0; inum_chunk_list=old_num_chunks+num_chunks; - png_ptr->chunk_list=new_list; -#ifdef PNG_FREE_ME_SUPPORTED - png_ptr->free_me |= PNG_FREE_LIST; -#endif -} -#endif - -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) -void PNGAPI -png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, - png_user_chunk_ptr read_user_chunk_fn) -{ - png_debug(1, "in png_set_read_user_chunk_fn\n"); - if (png_ptr == NULL) - return; - png_ptr->read_user_chunk_fn = read_user_chunk_fn; - png_ptr->user_chunk_ptr = user_chunk_ptr; -} -#endif - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) -{ - png_debug1(1, "in %s storage function\n", "rows"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) - png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); - info_ptr->row_pointers = row_pointers; - if(row_pointers) - info_ptr->valid |= PNG_INFO_IDAT; -} -#endif - -#ifdef PNG_WRITE_SUPPORTED -void PNGAPI -png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) -{ - if (png_ptr == NULL) - return; - if(png_ptr->zbuf) - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf_size = (png_size_t)size; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; -} -#endif - -void PNGAPI -png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask) -{ - if (png_ptr && info_ptr) - info_ptr->valid &= ~(mask); -} - - -#ifndef PNG_1_0_X -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -/* this function was added to libpng 1.2.0 and should always exist by default */ -void PNGAPI -png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags) -{ -#ifdef PNG_MMX_CODE_SUPPORTED - png_uint_32 settable_asm_flags; - png_uint_32 settable_mmx_flags; -#endif - if (png_ptr == NULL) - return; -#ifdef PNG_MMX_CODE_SUPPORTED - - settable_mmx_flags = -#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW - PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | -#endif -#ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE - PNG_ASM_FLAG_MMX_READ_INTERLACE | -#endif -#ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW - PNG_ASM_FLAG_MMX_READ_FILTER_SUB | - PNG_ASM_FLAG_MMX_READ_FILTER_UP | - PNG_ASM_FLAG_MMX_READ_FILTER_AVG | - PNG_ASM_FLAG_MMX_READ_FILTER_PAETH | -#endif - 0; - - /* could be some non-MMX ones in the future, but not currently: */ - settable_asm_flags = settable_mmx_flags; - - if (!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) || - !(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU)) - { - /* clear all MMX flags if MMX isn't supported */ - settable_asm_flags &= ~settable_mmx_flags; - png_ptr->asm_flags &= ~settable_mmx_flags; - } - - /* we're replacing the settable bits with those passed in by the user, - * so first zero them out of the master copy, then bitwise-OR in the - * allowed subset that was requested */ - - png_ptr->asm_flags &= ~settable_asm_flags; /* zero them */ - png_ptr->asm_flags |= (asm_flags & settable_asm_flags); /* set them */ -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} - -/* this function was added to libpng 1.2.0 */ -void PNGAPI -png_set_mmx_thresholds (png_structp png_ptr, - png_byte mmx_bitdepth_threshold, - png_uint_32 mmx_rowbytes_threshold) -{ - if (png_ptr == NULL) - return; -#ifdef PNG_MMX_CODE_SUPPORTED - png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold; - png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold; -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ - -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* this function was added to libpng 1.2.6 */ -void PNGAPI -png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max, - png_uint_32 user_height_max) -{ - /* Images with dimensions larger than these limits will be - * rejected by png_set_IHDR(). To accept any PNG datastream - * regardless of dimensions, set both limits to 0x7ffffffL. - */ - if(png_ptr == NULL) return; - png_ptr->user_width_max = user_width_max; - png_ptr->user_height_max = user_height_max; -} -#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ - -#endif /* ?PNG_1_0_X */ -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ + +/* pngset.c - storage of image information into info struct + * + * Last changed in libpng 1.2.15 January 5, 2007 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * The functions here are used during reads to store data from the file + * into the info struct, and during writes to store application data + * into the info struct for writing into the file. This abstracts the + * info struct and allows us to change the structure in the future. + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + +#if defined(PNG_bKGD_SUPPORTED) +void PNGAPI +png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) +{ + png_debug1(1, "in %s storage function\n", "bKGD"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16)); + info_ptr->valid |= PNG_INFO_bKGD; +} +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_cHRM(png_structp png_ptr, png_infop info_ptr, + double white_x, double white_y, double red_x, double red_y, + double green_x, double green_y, double blue_x, double blue_y) +{ + png_debug1(1, "in %s storage function\n", "cHRM"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (white_x < 0.0 || white_y < 0.0 || + red_x < 0.0 || red_y < 0.0 || + green_x < 0.0 || green_y < 0.0 || + blue_x < 0.0 || blue_y < 0.0) + { + png_warning(png_ptr, + "Ignoring attempt to set negative chromaticity value"); + return; + } + if (white_x > 21474.83 || white_y > 21474.83 || + red_x > 21474.83 || red_y > 21474.83 || + green_x > 21474.83 || green_y > 21474.83 || + blue_x > 21474.83 || blue_y > 21474.83) + { + png_warning(png_ptr, + "Ignoring attempt to set chromaticity value exceeding 21474.83"); + return; + } + + info_ptr->x_white = (float)white_x; + info_ptr->y_white = (float)white_y; + info_ptr->x_red = (float)red_x; + info_ptr->y_red = (float)red_y; + info_ptr->x_green = (float)green_x; + info_ptr->y_green = (float)green_y; + info_ptr->x_blue = (float)blue_x; + info_ptr->y_blue = (float)blue_y; +#ifdef PNG_FIXED_POINT_SUPPORTED + info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5); + info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5); + info_ptr->int_x_red = (png_fixed_point)( red_x*100000.+0.5); + info_ptr->int_y_red = (png_fixed_point)( red_y*100000.+0.5); + info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5); + info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5); + info_ptr->int_x_blue = (png_fixed_point)( blue_x*100000.+0.5); + info_ptr->int_y_blue = (png_fixed_point)( blue_y*100000.+0.5); +#endif + info_ptr->valid |= PNG_INFO_cHRM; +} +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +void PNGAPI +png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, + png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, + png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, + png_fixed_point blue_x, png_fixed_point blue_y) +{ + png_debug1(1, "in %s storage function\n", "cHRM"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (white_x < 0 || white_y < 0 || + red_x < 0 || red_y < 0 || + green_x < 0 || green_y < 0 || + blue_x < 0 || blue_y < 0) + { + png_warning(png_ptr, + "Ignoring attempt to set negative chromaticity value"); + return; + } +#ifdef PNG_FLOATING_POINT_SUPPORTED + if (white_x > (double) PNG_UINT_31_MAX || + white_y > (double) PNG_UINT_31_MAX || + red_x > (double) PNG_UINT_31_MAX || + red_y > (double) PNG_UINT_31_MAX || + green_x > (double) PNG_UINT_31_MAX || + green_y > (double) PNG_UINT_31_MAX || + blue_x > (double) PNG_UINT_31_MAX || + blue_y > (double) PNG_UINT_31_MAX) +#else + if (white_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || + white_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || + red_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || + red_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || + green_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || + green_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || + blue_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || + blue_y > (png_fixed_point) PNG_UINT_31_MAX/100000L) +#endif + { + png_warning(png_ptr, + "Ignoring attempt to set chromaticity value exceeding 21474.83"); + return; + } + info_ptr->int_x_white = white_x; + info_ptr->int_y_white = white_y; + info_ptr->int_x_red = red_x; + info_ptr->int_y_red = red_y; + info_ptr->int_x_green = green_x; + info_ptr->int_y_green = green_y; + info_ptr->int_x_blue = blue_x; + info_ptr->int_y_blue = blue_y; +#ifdef PNG_FLOATING_POINT_SUPPORTED + info_ptr->x_white = (float)(white_x/100000.); + info_ptr->y_white = (float)(white_y/100000.); + info_ptr->x_red = (float)( red_x/100000.); + info_ptr->y_red = (float)( red_y/100000.); + info_ptr->x_green = (float)(green_x/100000.); + info_ptr->y_green = (float)(green_y/100000.); + info_ptr->x_blue = (float)( blue_x/100000.); + info_ptr->y_blue = (float)( blue_y/100000.); +#endif + info_ptr->valid |= PNG_INFO_cHRM; +} +#endif +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) +{ + double gamma; + png_debug1(1, "in %s storage function\n", "gAMA"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + /* Check for overflow */ + if (file_gamma > 21474.83) + { + png_warning(png_ptr, "Limiting gamma to 21474.83"); + gamma=21474.83; + } + else + gamma=file_gamma; + info_ptr->gamma = (float)gamma; +#ifdef PNG_FIXED_POINT_SUPPORTED + info_ptr->int_gamma = (int)(gamma*100000.+.5); +#endif + info_ptr->valid |= PNG_INFO_gAMA; + if(gamma == 0.0) + png_warning(png_ptr, "Setting gamma=0"); +} +#endif +void PNGAPI +png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point + int_gamma) +{ + png_fixed_point gamma; + + png_debug1(1, "in %s storage function\n", "gAMA"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX) + { + png_warning(png_ptr, "Limiting gamma to 21474.83"); + gamma=PNG_UINT_31_MAX; + } + else + { + if (int_gamma < 0) + { + png_warning(png_ptr, "Setting negative gamma to zero"); + gamma=0; + } + else + gamma=int_gamma; + } +#ifdef PNG_FLOATING_POINT_SUPPORTED + info_ptr->gamma = (float)(gamma/100000.); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + info_ptr->int_gamma = gamma; +#endif + info_ptr->valid |= PNG_INFO_gAMA; + if(gamma == 0) + png_warning(png_ptr, "Setting gamma=0"); +} +#endif + +#if defined(PNG_hIST_SUPPORTED) +void PNGAPI +png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) +{ + int i; + + png_debug1(1, "in %s storage function\n", "hIST"); + if (png_ptr == NULL || info_ptr == NULL) + return; + if (info_ptr->num_palette <= 0 || info_ptr->num_palette + > PNG_MAX_PALETTE_LENGTH) + { + png_warning(png_ptr, + "Invalid palette size, hIST allocation skipped."); + return; + } + +#ifdef PNG_FREE_ME_SUPPORTED + png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); +#endif + /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in version + 1.2.1 */ + png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, + (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof (png_uint_16))); + if (png_ptr->hist == NULL) + { + png_warning(png_ptr, "Insufficient memory for hIST chunk data."); + return; + } + + for (i = 0; i < info_ptr->num_palette; i++) + png_ptr->hist[i] = hist[i]; + info_ptr->hist = png_ptr->hist; + info_ptr->valid |= PNG_INFO_hIST; + +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_HIST; +#else + png_ptr->flags |= PNG_FLAG_FREE_HIST; +#endif +} +#endif + +void PNGAPI +png_set_IHDR(png_structp png_ptr, png_infop info_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_type, int compression_type, + int filter_type) +{ + png_debug1(1, "in %s storage function\n", "IHDR"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + /* check for width and height valid values */ + if (width == 0 || height == 0) + png_error(png_ptr, "Image width or height is zero in IHDR"); +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (width > png_ptr->user_width_max || height > png_ptr->user_height_max) + png_error(png_ptr, "image size exceeds user limits in IHDR"); +#else + if (width > PNG_USER_WIDTH_MAX || height > PNG_USER_HEIGHT_MAX) + png_error(png_ptr, "image size exceeds user limits in IHDR"); +#endif + if (width > PNG_UINT_31_MAX || height > PNG_UINT_31_MAX) + png_error(png_ptr, "Invalid image size in IHDR"); + if ( width > (PNG_UINT_32_MAX + >> 3) /* 8-byte RGBA pixels */ + - 64 /* bigrowbuf hack */ + - 1 /* filter byte */ + - 7*8 /* rounding of width to multiple of 8 pixels */ + - 8) /* extra max_pixel_depth pad */ + png_warning(png_ptr, "Width is too large for libpng to process pixels"); + + /* check other values */ + if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && + bit_depth != 8 && bit_depth != 16) + png_error(png_ptr, "Invalid bit depth in IHDR"); + + if (color_type < 0 || color_type == 1 || + color_type == 5 || color_type > 6) + png_error(png_ptr, "Invalid color type in IHDR"); + + if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || + ((color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) + png_error(png_ptr, "Invalid color type/bit depth combination in IHDR"); + + if (interlace_type >= PNG_INTERLACE_LAST) + png_error(png_ptr, "Unknown interlace method in IHDR"); + + if (compression_type != PNG_COMPRESSION_TYPE_BASE) + png_error(png_ptr, "Unknown compression method in IHDR"); + +#if defined(PNG_MNG_FEATURES_SUPPORTED) + /* Accept filter_method 64 (intrapixel differencing) only if + * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and + * 2. Libpng did not read a PNG signature (this filter_method is only + * used in PNG datastreams that are embedded in MNG datastreams) and + * 3. The application called png_permit_mng_features with a mask that + * included PNG_FLAG_MNG_FILTER_64 and + * 4. The filter_method is 64 and + * 5. The color_type is RGB or RGBA + */ + if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) + png_warning(png_ptr,"MNG features are not allowed in a PNG datastream"); + if(filter_type != PNG_FILTER_TYPE_BASE) + { + if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && + ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && + (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA))) + png_error(png_ptr, "Unknown filter method in IHDR"); + if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) + png_warning(png_ptr, "Invalid filter method in IHDR"); + } +#else + if(filter_type != PNG_FILTER_TYPE_BASE) + png_error(png_ptr, "Unknown filter method in IHDR"); +#endif + + info_ptr->width = width; + info_ptr->height = height; + info_ptr->bit_depth = (png_byte)bit_depth; + info_ptr->color_type =(png_byte) color_type; + info_ptr->compression_type = (png_byte)compression_type; + info_ptr->filter_type = (png_byte)filter_type; + info_ptr->interlace_type = (png_byte)interlace_type; + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + info_ptr->channels = 1; + else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) + info_ptr->channels = 3; + else + info_ptr->channels = 1; + if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) + info_ptr->channels++; + info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); + + /* check for potential overflow */ + if ( width > (PNG_UINT_32_MAX + >> 3) /* 8-byte RGBA pixels */ + - 64 /* bigrowbuf hack */ + - 1 /* filter byte */ + - 7*8 /* rounding of width to multiple of 8 pixels */ + - 8) /* extra max_pixel_depth pad */ + info_ptr->rowbytes = (png_size_t)0; + else + info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,width); +} + +#if defined(PNG_oFFs_SUPPORTED) +void PNGAPI +png_set_oFFs(png_structp png_ptr, png_infop info_ptr, + png_int_32 offset_x, png_int_32 offset_y, int unit_type) +{ + png_debug1(1, "in %s storage function\n", "oFFs"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->x_offset = offset_x; + info_ptr->y_offset = offset_y; + info_ptr->offset_unit_type = (png_byte)unit_type; + info_ptr->valid |= PNG_INFO_oFFs; +} +#endif + +#if defined(PNG_pCAL_SUPPORTED) +void PNGAPI +png_set_pCAL(png_structp png_ptr, png_infop info_ptr, + png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, + png_charp units, png_charpp params) +{ + png_uint_32 length; + int i; + + png_debug1(1, "in %s storage function\n", "pCAL"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + length = png_strlen(purpose) + 1; + png_debug1(3, "allocating purpose for info (%lu bytes)\n", length); + info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); + if (info_ptr->pcal_purpose == NULL) + { + png_warning(png_ptr, "Insufficient memory for pCAL purpose."); + return; + } + png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); + + png_debug(3, "storing X0, X1, type, and nparams in info\n"); + info_ptr->pcal_X0 = X0; + info_ptr->pcal_X1 = X1; + info_ptr->pcal_type = (png_byte)type; + info_ptr->pcal_nparams = (png_byte)nparams; + + length = png_strlen(units) + 1; + png_debug1(3, "allocating units for info (%lu bytes)\n", length); + info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); + if (info_ptr->pcal_units == NULL) + { + png_warning(png_ptr, "Insufficient memory for pCAL units."); + return; + } + png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); + + info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, + (png_uint_32)((nparams + 1) * png_sizeof(png_charp))); + if (info_ptr->pcal_params == NULL) + { + png_warning(png_ptr, "Insufficient memory for pCAL params."); + return; + } + + info_ptr->pcal_params[nparams] = NULL; + + for (i = 0; i < nparams; i++) + { + length = png_strlen(params[i]) + 1; + png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length); + info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); + if (info_ptr->pcal_params[i] == NULL) + { + png_warning(png_ptr, "Insufficient memory for pCAL parameter."); + return; + } + png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); + } + + info_ptr->valid |= PNG_INFO_pCAL; +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_PCAL; +#endif +} +#endif + +#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_sCAL(png_structp png_ptr, png_infop info_ptr, + int unit, double width, double height) +{ + png_debug1(1, "in %s storage function\n", "sCAL"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->scal_unit = (png_byte)unit; + info_ptr->scal_pixel_width = width; + info_ptr->scal_pixel_height = height; + + info_ptr->valid |= PNG_INFO_sCAL; +} +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +void PNGAPI +png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, + int unit, png_charp swidth, png_charp sheight) +{ + png_uint_32 length; + + png_debug1(1, "in %s storage function\n", "sCAL"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->scal_unit = (png_byte)unit; + + length = png_strlen(swidth) + 1; + png_debug1(3, "allocating unit for info (%d bytes)\n", length); + info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); + if (info_ptr->scal_s_width == NULL) + { + png_warning(png_ptr, "Memory allocation failed while processing sCAL."); + } + png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); + + length = png_strlen(sheight) + 1; + png_debug1(3, "allocating unit for info (%d bytes)\n", length); + info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); + if (info_ptr->scal_s_height == NULL) + { + png_free (png_ptr, info_ptr->scal_s_width); + png_warning(png_ptr, "Memory allocation failed while processing sCAL."); + } + png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); + + info_ptr->valid |= PNG_INFO_sCAL; +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_SCAL; +#endif +} +#endif +#endif +#endif + +#if defined(PNG_pHYs_SUPPORTED) +void PNGAPI +png_set_pHYs(png_structp png_ptr, png_infop info_ptr, + png_uint_32 res_x, png_uint_32 res_y, int unit_type) +{ + png_debug1(1, "in %s storage function\n", "pHYs"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->x_pixels_per_unit = res_x; + info_ptr->y_pixels_per_unit = res_y; + info_ptr->phys_unit_type = (png_byte)unit_type; + info_ptr->valid |= PNG_INFO_pHYs; +} +#endif + +void PNGAPI +png_set_PLTE(png_structp png_ptr, png_infop info_ptr, + png_colorp palette, int num_palette) +{ + + png_debug1(1, "in %s storage function\n", "PLTE"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH) + { + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + png_error(png_ptr, "Invalid palette length"); + else + { + png_warning(png_ptr, "Invalid palette length"); + return; + } + } + + /* + * It may not actually be necessary to set png_ptr->palette here; + * we do it for backward compatibility with the way the png_handle_tRNS + * function used to do the allocation. + */ +#ifdef PNG_FREE_ME_SUPPORTED + png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); +#endif + + /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead + of num_palette entries, + in case of an invalid PNG file that has too-large sample values. */ + png_ptr->palette = (png_colorp)png_malloc(png_ptr, + PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); + png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH * + png_sizeof(png_color)); + png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof (png_color)); + info_ptr->palette = png_ptr->palette; + info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; + +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_PLTE; +#else + png_ptr->flags |= PNG_FLAG_FREE_PLTE; +#endif + + info_ptr->valid |= PNG_INFO_PLTE; +} + +#if defined(PNG_sBIT_SUPPORTED) +void PNGAPI +png_set_sBIT(png_structp png_ptr, png_infop info_ptr, + png_color_8p sig_bit) +{ + png_debug1(1, "in %s storage function\n", "sBIT"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof (png_color_8)); + info_ptr->valid |= PNG_INFO_sBIT; +} +#endif + +#if defined(PNG_sRGB_SUPPORTED) +void PNGAPI +png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) +{ + png_debug1(1, "in %s storage function\n", "sRGB"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->srgb_intent = (png_byte)intent; + info_ptr->valid |= PNG_INFO_sRGB; +} + +void PNGAPI +png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, + int intent) +{ +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED + float file_gamma; +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_fixed_point int_file_gamma; +#endif +#endif +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED + float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, + int_green_y, int_blue_x, int_blue_y; +#endif +#endif + png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + png_set_sRGB(png_ptr, info_ptr, intent); + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED + file_gamma = (float).45455; + png_set_gAMA(png_ptr, info_ptr, file_gamma); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + int_file_gamma = 45455L; + png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma); +#endif +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FIXED_POINT_SUPPORTED + int_white_x = 31270L; + int_white_y = 32900L; + int_red_x = 64000L; + int_red_y = 33000L; + int_green_x = 30000L; + int_green_y = 60000L; + int_blue_x = 15000L; + int_blue_y = 6000L; + + png_set_cHRM_fixed(png_ptr, info_ptr, + int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, + int_blue_x, int_blue_y); +#endif +#ifdef PNG_FLOATING_POINT_SUPPORTED + white_x = (float).3127; + white_y = (float).3290; + red_x = (float).64; + red_y = (float).33; + green_x = (float).30; + green_y = (float).60; + blue_x = (float).15; + blue_y = (float).06; + + png_set_cHRM(png_ptr, info_ptr, + white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); +#endif +#endif +} +#endif + + +#if defined(PNG_iCCP_SUPPORTED) +void PNGAPI +png_set_iCCP(png_structp png_ptr, png_infop info_ptr, + png_charp name, int compression_type, + png_charp profile, png_uint_32 proflen) +{ + png_charp new_iccp_name; + png_charp new_iccp_profile; + + png_debug1(1, "in %s storage function\n", "iCCP"); + if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) + return; + + new_iccp_name = (png_charp)png_malloc_warn(png_ptr, png_strlen(name)+1); + if (new_iccp_name == NULL) + { + png_warning(png_ptr, "Insufficient memory to process iCCP chunk."); + return; + } + png_strcpy(new_iccp_name, name); + new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen); + if (new_iccp_profile == NULL) + { + png_free (png_ptr, new_iccp_name); + png_warning(png_ptr, "Insufficient memory to process iCCP profile."); + return; + } + png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); + + png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); + + info_ptr->iccp_proflen = proflen; + info_ptr->iccp_name = new_iccp_name; + info_ptr->iccp_profile = new_iccp_profile; + /* Compression is always zero but is here so the API and info structure + * does not have to change if we introduce multiple compression types */ + info_ptr->iccp_compression = (png_byte)compression_type; +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_ICCP; +#endif + info_ptr->valid |= PNG_INFO_iCCP; +} +#endif + +#if defined(PNG_TEXT_SUPPORTED) +void PNGAPI +png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, + int num_text) +{ + int ret; + ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); + if (ret) + png_error(png_ptr, "Insufficient memory to store text"); +} + +int /* PRIVATE */ +png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, + int num_text) +{ + int i; + + png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ? + "text" : (png_const_charp)png_ptr->chunk_name)); + + if (png_ptr == NULL || info_ptr == NULL || num_text == 0) + return(0); + + /* Make sure we have enough space in the "text" array in info_struct + * to hold all of the incoming text_ptr objects. + */ + if (info_ptr->num_text + num_text > info_ptr->max_text) + { + if (info_ptr->text != NULL) + { + png_textp old_text; + int old_max; + + old_max = info_ptr->max_text; + info_ptr->max_text = info_ptr->num_text + num_text + 8; + old_text = info_ptr->text; + info_ptr->text = (png_textp)png_malloc_warn(png_ptr, + (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); + if (info_ptr->text == NULL) + { + png_free(png_ptr, old_text); + return(1); + } + png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * + png_sizeof(png_text))); + png_free(png_ptr, old_text); + } + else + { + info_ptr->max_text = num_text + 8; + info_ptr->num_text = 0; + info_ptr->text = (png_textp)png_malloc_warn(png_ptr, + (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); + if (info_ptr->text == NULL) + return(1); +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_TEXT; +#endif + } + png_debug1(3, "allocated %d entries for info_ptr->text\n", + info_ptr->max_text); + } + for (i = 0; i < num_text; i++) + { + png_size_t text_length,key_len; + png_size_t lang_len,lang_key_len; + png_textp textp = &(info_ptr->text[info_ptr->num_text]); + + if (text_ptr[i].key == NULL) + continue; + + key_len = png_strlen(text_ptr[i].key); + + if(text_ptr[i].compression <= 0) + { + lang_len = 0; + lang_key_len = 0; + } + else +#ifdef PNG_iTXt_SUPPORTED + { + /* set iTXt data */ + if (text_ptr[i].lang != NULL) + lang_len = png_strlen(text_ptr[i].lang); + else + lang_len = 0; + if (text_ptr[i].lang_key != NULL) + lang_key_len = png_strlen(text_ptr[i].lang_key); + else + lang_key_len = 0; + } +#else + { + png_warning(png_ptr, "iTXt chunk not supported."); + continue; + } +#endif + + if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') + { + text_length = 0; +#ifdef PNG_iTXt_SUPPORTED + if(text_ptr[i].compression > 0) + textp->compression = PNG_ITXT_COMPRESSION_NONE; + else +#endif + textp->compression = PNG_TEXT_COMPRESSION_NONE; + } + else + { + text_length = png_strlen(text_ptr[i].text); + textp->compression = text_ptr[i].compression; + } + + textp->key = (png_charp)png_malloc_warn(png_ptr, + (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); + if (textp->key == NULL) + return(1); + png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", + (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4), + (int)textp->key); + + png_memcpy(textp->key, text_ptr[i].key, + (png_size_t)(key_len)); + *(textp->key+key_len) = '\0'; +#ifdef PNG_iTXt_SUPPORTED + if (text_ptr[i].compression > 0) + { + textp->lang=textp->key + key_len + 1; + png_memcpy(textp->lang, text_ptr[i].lang, lang_len); + *(textp->lang+lang_len) = '\0'; + textp->lang_key=textp->lang + lang_len + 1; + png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); + *(textp->lang_key+lang_key_len) = '\0'; + textp->text=textp->lang_key + lang_key_len + 1; + } + else +#endif + { +#ifdef PNG_iTXt_SUPPORTED + textp->lang=NULL; + textp->lang_key=NULL; +#endif + textp->text=textp->key + key_len + 1; + } + if(text_length) + png_memcpy(textp->text, text_ptr[i].text, + (png_size_t)(text_length)); + *(textp->text+text_length) = '\0'; + +#ifdef PNG_iTXt_SUPPORTED + if(textp->compression > 0) + { + textp->text_length = 0; + textp->itxt_length = text_length; + } + else +#endif + { + textp->text_length = text_length; +#ifdef PNG_iTXt_SUPPORTED + textp->itxt_length = 0; +#endif + } + info_ptr->text[info_ptr->num_text]= *textp; + info_ptr->num_text++; + png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); + } + return(0); +} +#endif + +#if defined(PNG_tIME_SUPPORTED) +void PNGAPI +png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) +{ + png_debug1(1, "in %s storage function\n", "tIME"); + if (png_ptr == NULL || info_ptr == NULL || + (png_ptr->mode & PNG_WROTE_tIME)) + return; + + png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof (png_time)); + info_ptr->valid |= PNG_INFO_tIME; +} +#endif + +#if defined(PNG_tRNS_SUPPORTED) +void PNGAPI +png_set_tRNS(png_structp png_ptr, png_infop info_ptr, + png_bytep trans, int num_trans, png_color_16p trans_values) +{ + png_debug1(1, "in %s storage function\n", "tRNS"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (trans != NULL) + { + /* + * It may not actually be necessary to set png_ptr->trans here; + * we do it for backward compatibility with the way the png_handle_tRNS + * function used to do the allocation. + */ +#ifdef PNG_FREE_ME_SUPPORTED + png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); +#endif + /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ + png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, + (png_uint_32)PNG_MAX_PALETTE_LENGTH); + if (num_trans <= PNG_MAX_PALETTE_LENGTH) + png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_TRNS; +#else + png_ptr->flags |= PNG_FLAG_FREE_TRNS; +#endif + } + + if (trans_values != NULL) + { + png_memcpy(&(info_ptr->trans_values), trans_values, + png_sizeof(png_color_16)); + if (num_trans == 0) + num_trans = 1; + } + info_ptr->num_trans = (png_uint_16)num_trans; + info_ptr->valid |= PNG_INFO_tRNS; +} +#endif + +#if defined(PNG_sPLT_SUPPORTED) +void PNGAPI +png_set_sPLT(png_structp png_ptr, + png_infop info_ptr, png_sPLT_tp entries, int nentries) +{ + png_sPLT_tp np; + int i; + + if (png_ptr == NULL || info_ptr == NULL) + return; + + np = (png_sPLT_tp)png_malloc_warn(png_ptr, + (info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t)); + if (np == NULL) + { + png_warning(png_ptr, "No memory for sPLT palettes."); + return; + } + + png_memcpy(np, info_ptr->splt_palettes, + info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t)); + png_free(png_ptr, info_ptr->splt_palettes); + info_ptr->splt_palettes=NULL; + + for (i = 0; i < nentries; i++) + { + png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; + png_sPLT_tp from = entries + i; + + to->name = (png_charp)png_malloc(png_ptr, + png_strlen(from->name) + 1); + /* TODO: use png_malloc_warn */ + png_strcpy(to->name, from->name); + to->entries = (png_sPLT_entryp)png_malloc(png_ptr, + from->nentries * png_sizeof(png_sPLT_entry)); + /* TODO: use png_malloc_warn */ + png_memcpy(to->entries, from->entries, + from->nentries * png_sizeof(png_sPLT_entry)); + to->nentries = from->nentries; + to->depth = from->depth; + } + + info_ptr->splt_palettes = np; + info_ptr->splt_palettes_num += nentries; + info_ptr->valid |= PNG_INFO_sPLT; +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_SPLT; +#endif +} +#endif /* PNG_sPLT_SUPPORTED */ + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +void PNGAPI +png_set_unknown_chunks(png_structp png_ptr, + png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) +{ + png_unknown_chunkp np; + int i; + + if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) + return; + + np = (png_unknown_chunkp)png_malloc_warn(png_ptr, + (info_ptr->unknown_chunks_num + num_unknowns) * + png_sizeof(png_unknown_chunk)); + if (np == NULL) + { + png_warning(png_ptr, "Out of memory while processing unknown chunk."); + return; + } + + png_memcpy(np, info_ptr->unknown_chunks, + info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk)); + png_free(png_ptr, info_ptr->unknown_chunks); + info_ptr->unknown_chunks=NULL; + + for (i = 0; i < num_unknowns; i++) + { + png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; + png_unknown_chunkp from = unknowns + i; + + png_strncpy((png_charp)to->name, (png_charp)from->name, 5); + to->data = (png_bytep)png_malloc_warn(png_ptr, from->size); + if (to->data == NULL) + { + png_warning(png_ptr, "Out of memory processing unknown chunk."); + } + else + { + png_memcpy(to->data, from->data, from->size); + to->size = from->size; + + /* note our location in the read or write sequence */ + to->location = (png_byte)(png_ptr->mode & 0xff); + } + } + + info_ptr->unknown_chunks = np; + info_ptr->unknown_chunks_num += num_unknowns; +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_UNKN; +#endif +} +void PNGAPI +png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, + int chunk, int location) +{ + if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < + (int)info_ptr->unknown_chunks_num) + info_ptr->unknown_chunks[chunk].location = (png_byte)location; +} +#endif + +#if defined(PNG_1_0_X) || defined(PNG_1_2_X) +#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +void PNGAPI +png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) +{ + /* This function is deprecated in favor of png_permit_mng_features() + and will be removed from libpng-1.3.0 */ + png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n"); + if (png_ptr == NULL) + return; + png_ptr->mng_features_permitted = (png_byte) + ((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) | + ((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE))); +} +#endif +#endif + +#if defined(PNG_MNG_FEATURES_SUPPORTED) +png_uint_32 PNGAPI +png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) +{ + png_debug(1, "in png_permit_mng_features\n"); + if (png_ptr == NULL) + return (png_uint_32)0; + png_ptr->mng_features_permitted = + (png_byte)(mng_features & PNG_ALL_MNG_FEATURES); + return (png_uint_32)png_ptr->mng_features_permitted; +} +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +void PNGAPI +png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep + chunk_list, int num_chunks) +{ + png_bytep new_list, p; + int i, old_num_chunks; + if (png_ptr == NULL) + return; + if (num_chunks == 0) + { + if(keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE) + png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; + else + png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; + + if(keep == PNG_HANDLE_CHUNK_ALWAYS) + png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; + else + png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; + return; + } + if (chunk_list == NULL) + return; + old_num_chunks=png_ptr->num_chunk_list; + new_list=(png_bytep)png_malloc(png_ptr, + (png_uint_32)(5*(num_chunks+old_num_chunks))); + if(png_ptr->chunk_list != NULL) + { + png_memcpy(new_list, png_ptr->chunk_list, + (png_size_t)(5*old_num_chunks)); + png_free(png_ptr, png_ptr->chunk_list); + png_ptr->chunk_list=NULL; + } + png_memcpy(new_list+5*old_num_chunks, chunk_list, + (png_size_t)(5*num_chunks)); + for (p=new_list+5*old_num_chunks+4, i=0; inum_chunk_list=old_num_chunks+num_chunks; + png_ptr->chunk_list=new_list; +#ifdef PNG_FREE_ME_SUPPORTED + png_ptr->free_me |= PNG_FREE_LIST; +#endif +} +#endif + +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) +void PNGAPI +png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, + png_user_chunk_ptr read_user_chunk_fn) +{ + png_debug(1, "in png_set_read_user_chunk_fn\n"); + if (png_ptr == NULL) + return; + png_ptr->read_user_chunk_fn = read_user_chunk_fn; + png_ptr->user_chunk_ptr = user_chunk_ptr; +} +#endif + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +void PNGAPI +png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) +{ + png_debug1(1, "in %s storage function\n", "rows"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) + png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); + info_ptr->row_pointers = row_pointers; + if(row_pointers) + info_ptr->valid |= PNG_INFO_IDAT; +} +#endif + +#ifdef PNG_WRITE_SUPPORTED +void PNGAPI +png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) +{ + if (png_ptr == NULL) + return; + if(png_ptr->zbuf) + png_free(png_ptr, png_ptr->zbuf); + png_ptr->zbuf_size = (png_size_t)size; + png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; +} +#endif + +void PNGAPI +png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask) +{ + if (png_ptr && info_ptr) + info_ptr->valid &= ~(mask); +} + + +#ifndef PNG_1_0_X +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED +/* this function was added to libpng 1.2.0 and should always exist by default */ +void PNGAPI +png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags) +{ +#ifdef PNG_MMX_CODE_SUPPORTED + png_uint_32 settable_asm_flags; + png_uint_32 settable_mmx_flags; +#endif + if (png_ptr == NULL) + return; +#ifdef PNG_MMX_CODE_SUPPORTED + + settable_mmx_flags = +#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW + PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | +#endif +#ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE + PNG_ASM_FLAG_MMX_READ_INTERLACE | +#endif +#ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW + PNG_ASM_FLAG_MMX_READ_FILTER_SUB | + PNG_ASM_FLAG_MMX_READ_FILTER_UP | + PNG_ASM_FLAG_MMX_READ_FILTER_AVG | + PNG_ASM_FLAG_MMX_READ_FILTER_PAETH | +#endif + 0; + + /* could be some non-MMX ones in the future, but not currently: */ + settable_asm_flags = settable_mmx_flags; + + if (!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) || + !(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU)) + { + /* clear all MMX flags if MMX isn't supported */ + settable_asm_flags &= ~settable_mmx_flags; + png_ptr->asm_flags &= ~settable_mmx_flags; + } + + /* we're replacing the settable bits with those passed in by the user, + * so first zero them out of the master copy, then bitwise-OR in the + * allowed subset that was requested */ + + png_ptr->asm_flags &= ~settable_asm_flags; /* zero them */ + png_ptr->asm_flags |= (asm_flags & settable_asm_flags); /* set them */ +#endif /* ?PNG_MMX_CODE_SUPPORTED */ +} + +/* this function was added to libpng 1.2.0 */ +void PNGAPI +png_set_mmx_thresholds (png_structp png_ptr, + png_byte mmx_bitdepth_threshold, + png_uint_32 mmx_rowbytes_threshold) +{ + if (png_ptr == NULL) + return; +#ifdef PNG_MMX_CODE_SUPPORTED + png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold; + png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold; +#endif /* ?PNG_MMX_CODE_SUPPORTED */ +} +#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ + +#ifdef PNG_SET_USER_LIMITS_SUPPORTED +/* this function was added to libpng 1.2.6 */ +void PNGAPI +png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max, + png_uint_32 user_height_max) +{ + /* Images with dimensions larger than these limits will be + * rejected by png_set_IHDR(). To accept any PNG datastream + * regardless of dimensions, set both limits to 0x7ffffffL. + */ + if(png_ptr == NULL) return; + png_ptr->user_width_max = user_width_max; + png_ptr->user_height_max = user_height_max; +} +#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ + +#endif /* ?PNG_1_0_X */ +#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/pngtest.c b/src/dep/src/irrlicht/libpng/pngtest.c index 8f0dddb..3d09dee 100644 --- a/src/dep/src/irrlicht/libpng/pngtest.c +++ b/src/dep/src/irrlicht/libpng/pngtest.c @@ -1,1554 +1,1554 @@ - -/* pngtest.c - a simple test program to test libpng - * - * Last changed in libpng 1.2.6 - August 15, 2004 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2004 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This program reads in a PNG image, writes it out again, and then - * compares the two files. If the files are identical, this shows that - * the basic chunk handling, filtering, and (de)compression code is working - * properly. It does not currently test all of the transforms, although - * it probably should. - * - * The program will report "FAIL" in certain legitimate cases: - * 1) when the compression level or filter selection method is changed. - * 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192. - * 3) unknown unsafe-to-copy ancillary chunks or unknown critical chunks - * exist in the input file. - * 4) others not listed here... - * In these cases, it is best to check with another tool such as "pngcheck" - * to see what the differences between the two files are. - * - * If a filename is given on the command-line, then this file is used - * for the input, rather than the default "pngtest.png". This allows - * testing a wide variety of files easily. You can also test a number - * of files at once by typing "pngtest -m file1.png file2.png ..." - */ - -#include "png.h" - -#if defined(_WIN32_WCE) -# if _WIN32_WCE < 211 - __error__ (f|w)printf functions are not supported on old WindowsCE.; -# endif -# include -# include -# define READFILE(file, data, length, check) \ - if (ReadFile(file, data, length, &check,NULL)) check = 0 -# define WRITEFILE(file, data, length, check)) \ - if (WriteFile(file, data, length, &check, NULL)) check = 0 -# define FCLOSE(file) CloseHandle(file) -#else -# include -# include -# define READFILE(file, data, length, check) \ - check=(png_size_t)fread(data,(png_size_t)1,length,file) -# define WRITEFILE(file, data, length, check) \ - check=(png_size_t)fwrite(data,(png_size_t)1, length, file) -# define FCLOSE(file) fclose(file) -#endif - -#if defined(PNG_NO_STDIO) -# if defined(_WIN32_WCE) - typedef HANDLE png_FILE_p; -# else - typedef FILE * png_FILE_p; -# endif -#endif - -/* Makes pngtest verbose so we can find problems (needs to be before png.h) */ -#ifndef PNG_DEBUG -# define PNG_DEBUG 0 -#endif - -#if !PNG_DEBUG -# define SINGLE_ROWBUF_ALLOC /* makes buffer overruns easier to nail */ -#endif - -/* Turn on CPU timing -#define PNGTEST_TIMING -*/ - -#ifdef PNG_NO_FLOATING_POINT_SUPPORTED -#undef PNGTEST_TIMING -#endif - -#ifdef PNGTEST_TIMING -static float t_start, t_stop, t_decode, t_encode, t_misc; -#include -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -static int tIME_chunk_present=0; -static char tIME_string[30] = "no tIME chunk present in file"; -#endif - -static int verbose = 0; - -int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname)); - -#ifdef __TURBOC__ -#include -#endif - -/* defined so I can write to a file on gui/windowing platforms */ -/* #define STDERR stderr */ -#define STDERR stdout /* for DOS */ - -/* example of using row callbacks to make a simple progress meter */ -static int status_pass=1; -static int status_dots_requested=0; -static int status_dots=1; - -/* In case a system header (e.g., on AIX) defined jmpbuf */ -#ifdef jmpbuf -# undef jmpbuf -#endif - -/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) png_ptr->jmpbuf -#endif - -void -#ifdef PNG_1_0_X -PNGAPI -#endif -read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) -{ - if(png_ptr == NULL || row_number > PNG_UINT_31_MAX) return; - if(status_pass != pass) - { - fprintf(stdout,"\n Pass %d: ",pass); - status_pass = pass; - status_dots = 31; - } - status_dots--; - if(status_dots == 0) - { - fprintf(stdout, "\n "); - status_dots=30; - } - fprintf(stdout, "r"); -} - -void -#ifdef PNG_1_0_X -PNGAPI -#endif -write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) -{ - if(png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) return; - fprintf(stdout, "w"); -} - - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) -/* Example of using user transform callback (we don't transform anything, - but merely examine the row filters. We set this to 256 rather than - 5 in case illegal filter values are present.) */ -static png_uint_32 filters_used[256]; -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data) -{ - if(png_ptr != NULL && row_info != NULL) - ++filters_used[*(data-1)]; -} -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -/* example of using user transform callback (we don't transform anything, - but merely count the zero samples) */ - -static png_uint_32 zero_samples; - -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) -{ - png_bytep dp = data; - if(png_ptr == NULL)return; - - /* contents of row_info: - * png_uint_32 width width of row - * png_uint_32 rowbytes number of bytes in row - * png_byte color_type color type of pixels - * png_byte bit_depth bit depth of samples - * png_byte channels number of channels (1-4) - * png_byte pixel_depth bits per pixel (depth*channels) - */ - - - /* counts the number of zero samples (or zero pixels if color_type is 3 */ - - if(row_info->color_type == 0 || row_info->color_type == 3) - { - int pos=0; - png_uint_32 n, nstop; - for (n=0, nstop=row_info->width; nbit_depth == 1) - { - if(((*dp << pos++ ) & 0x80) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 2) - { - if(((*dp << (pos+=2)) & 0xc0) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 4) - { - if(((*dp << (pos+=4)) & 0xf0) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 8) - if(*dp++ == 0) zero_samples++; - if(row_info->bit_depth == 16) - { - if((*dp | *(dp+1)) == 0) zero_samples++; - dp+=2; - } - } - } - else /* other color types */ - { - png_uint_32 n, nstop; - int channel; - int color_channels = row_info->channels; - if(row_info->color_type > 3)color_channels--; - - for (n=0, nstop=row_info->width; nbit_depth == 8) - if(*dp++ == 0) zero_samples++; - if(row_info->bit_depth == 16) - { - if((*dp | *(dp+1)) == 0) zero_samples++; - dp+=2; - } - } - if(row_info->color_type > 3) - { - dp++; - if(row_info->bit_depth == 16)dp++; - } - } - } -} -#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */ - -static int wrote_question = 0; - -#if defined(PNG_NO_STDIO) -/* START of code to validate stdio-free compilation */ -/* These copies of the default read/write functions come from pngrio.c and */ -/* pngwio.c. They allow "don't include stdio" testing of the library. */ -/* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ - -#ifndef USE_FAR_KEYWORD -static void -pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - /* fread() returns 0 on error, so it is OK to store this in a png_size_t - * instead of an int, which is what fread() actually returns. - */ - READFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); - - if (check != length) - { - png_error(png_ptr, "Read Error!"); - } -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void -pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - int check; - png_byte *n_data; - png_FILE_p io_ptr; - - /* Check if data really is near. If so, use usual code. */ - n_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)n_data == data) - { - READFILE(io_ptr, n_data, length, check); - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t read, remaining, err; - check = 0; - remaining = length; - do - { - read = MIN(NEAR_BUF_SIZE, remaining); - READFILE(io_ptr, buf, 1, err); - png_memcpy(data, buf, read); /* copy far buffer to near buffer */ - if(err != read) - break; - else - check += err; - data += read; - remaining -= read; - } - while (remaining != 0); - } - if (check != length) - { - png_error(png_ptr, "read Error"); - } -} -#endif /* USE_FAR_KEYWORD */ - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -static void -pngtest_flush(png_structp png_ptr) -{ -#if !defined(_WIN32_WCE) - png_FILE_p io_ptr; - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -#endif -} -#endif - -/* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -static void -pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - - WRITEFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); - if (check != length) - { - png_error(png_ptr, "Write Error"); - } -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void -pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ - png_FILE_p io_ptr; - - /* Check if data really is near. If so, use usual code. */ - near_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)near_data == data) - { - WRITEFILE(io_ptr, near_data, length, check); - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t written, remaining, err; - check = 0; - remaining = length; - do - { - written = MIN(NEAR_BUF_SIZE, remaining); - png_memcpy(buf, data, written); /* copy far buffer to near buffer */ - WRITEFILE(io_ptr, buf, written, err); - if (err != written) - break; - else - check += err; - data += written; - remaining -= written; - } - while (remaining != 0); - } - if (check != length) - { - png_error(png_ptr, "Write Error"); - } -} - -#endif /* USE_FAR_KEYWORD */ - -/* This function is called when there is a warning, but the library thinks - * it can continue anyway. Replacement functions don't have to do anything - * here if you don't want to. In the default configuration, png_ptr is - * not used, but it is passed in case it may be useful. - */ -static void -pngtest_warning(png_structp png_ptr, png_const_charp message) -{ - PNG_CONST char *name = "UNKNOWN (ERROR!)"; - if (png_ptr != NULL && png_ptr->error_ptr != NULL) - name = png_ptr->error_ptr; - fprintf(STDERR, "%s: libpng warning: %s\n", name, message); -} - -/* This is the default error handling function. Note that replacements for - * this function MUST NOT RETURN, or the program will likely crash. This - * function is used by default, or if the program supplies NULL for the - * error function pointer in png_set_error_fn(). - */ -static void -pngtest_error(png_structp png_ptr, png_const_charp message) -{ - pngtest_warning(png_ptr, message); - /* We can return because png_error calls the default handler, which is - * actually OK in this case. */ -} -#endif /* PNG_NO_STDIO */ -/* END of code to validate stdio-free compilation */ - -/* START of code to validate memory allocation and deallocation */ -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - -/* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. - - This piece of code can be compiled to validate max 64K allocations - by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */ -typedef struct memory_information -{ - png_uint_32 size; - png_voidp pointer; - struct memory_information FAR *next; -} memory_information; -typedef memory_information FAR *memory_infop; - -static memory_infop pinformation = NULL; -static int current_allocation = 0; -static int maximum_allocation = 0; -static int total_allocation = 0; -static int num_allocations = 0; - -png_voidp png_debug_malloc PNGARG((png_structp png_ptr, png_uint_32 size)); -void png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr)); - -png_voidp -png_debug_malloc(png_structp png_ptr, png_uint_32 size) -{ - - /* png_malloc has already tested for NULL; png_create_struct calls - png_debug_malloc directly, with png_ptr == NULL which is OK */ - - if (size == 0) - return (NULL); - - /* This calls the library allocator twice, once to get the requested - buffer and once to get a new free list entry. */ - { - /* Disable malloc_fn and free_fn */ - memory_infop pinfo; - png_set_mem_fn(png_ptr, NULL, NULL, NULL); - pinfo = (memory_infop)png_malloc(png_ptr, - (png_uint_32)png_sizeof (*pinfo)); - pinfo->size = size; - current_allocation += size; - total_allocation += size; - num_allocations ++; - if (current_allocation > maximum_allocation) - maximum_allocation = current_allocation; - pinfo->pointer = (png_voidp)png_malloc(png_ptr, size); - /* Restore malloc_fn and free_fn */ - png_set_mem_fn(png_ptr, png_voidp_NULL, (png_malloc_ptr)png_debug_malloc, - (png_free_ptr)png_debug_free); - if (size != 0 && pinfo->pointer == NULL) - { - current_allocation -= size; - total_allocation -= size; - png_error(png_ptr, - "out of memory in pngtest->png_debug_malloc."); - } - pinfo->next = pinformation; - pinformation = pinfo; - /* Make sure the caller isn't assuming zeroed memory. */ - png_memset(pinfo->pointer, 0xdd, pinfo->size); - if(verbose) - printf("png_malloc %lu bytes at %x\n",(unsigned long)size, - pinfo->pointer); - return (png_voidp)(pinfo->pointer); - } -} - -/* Free a pointer. It is removed from the list at the same time. */ -void -png_debug_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL) - fprintf(STDERR, "NULL pointer to png_debug_free.\n"); - if (ptr == 0) - { -#if 0 /* This happens all the time. */ - fprintf(STDERR, "WARNING: freeing NULL pointer\n"); -#endif - return; - } - - /* Unlink the element from the list. */ - { - memory_infop FAR *ppinfo = &pinformation; - for (;;) - { - memory_infop pinfo = *ppinfo; - if (pinfo->pointer == ptr) - { - *ppinfo = pinfo->next; - current_allocation -= pinfo->size; - if (current_allocation < 0) - fprintf(STDERR, "Duplicate free of memory\n"); - /* We must free the list element too, but first kill - the memory that is to be freed. */ - png_memset(ptr, 0x55, pinfo->size); - png_free_default(png_ptr, pinfo); - pinfo=NULL; - break; - } - if (pinfo->next == NULL) - { - fprintf(STDERR, "Pointer %x not found\n", (unsigned int)ptr); - break; - } - ppinfo = &pinfo->next; - } - } - - /* Finally free the data. */ - if(verbose) - printf("Freeing %x\n",ptr); - png_free_default(png_ptr, ptr); - ptr=NULL; -} -#endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */ -/* END of code to test memory allocation/deallocation */ - -/* Test one file */ -int -test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) -{ - static png_FILE_p fpin; - static png_FILE_p fpout; /* "static" prevents setjmp corruption */ - png_structp read_ptr; - png_infop read_info_ptr, end_info_ptr; -#ifdef PNG_WRITE_SUPPORTED - png_structp write_ptr; - png_infop write_info_ptr; - png_infop write_end_info_ptr; -#else - png_structp write_ptr = NULL; - png_infop write_info_ptr = NULL; - png_infop write_end_info_ptr = NULL; -#endif - png_bytep row_buf; - png_uint_32 y; - png_uint_32 width, height; - int num_pass, pass; - int bit_depth, color_type; -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - -#if defined(_WIN32_WCE) - TCHAR path[MAX_PATH]; -#endif - char inbuf[256], outbuf[256]; - - row_buf = NULL; - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); - if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpin = fopen(inname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find input file %s\n", inname); - return (1); - } - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); - if ((fpout = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpout = fopen(outname, "wb")) == NULL) -#endif - { - fprintf(STDERR, "Could not open output file %s\n", outname); - FCLOSE(fpin); - return (1); - } - - png_debug(0, "Allocating read and write structures\n"); -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, - (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); -#else - read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL); -#endif -#if defined(PNG_NO_STDIO) - png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error, - pngtest_warning); -#endif -#ifdef PNG_WRITE_SUPPORTED -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, - (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); -#else - write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL); -#endif -#if defined(PNG_NO_STDIO) - png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, - pngtest_warning); -#endif -#endif - png_debug(0, "Allocating read_info, write_info and end_info structures\n"); - read_info_ptr = png_create_info_struct(read_ptr); - end_info_ptr = png_create_info_struct(read_ptr); -#ifdef PNG_WRITE_SUPPORTED - write_info_ptr = png_create_info_struct(write_ptr); - write_end_info_ptr = png_create_info_struct(write_ptr); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_debug(0, "Setting jmpbuf for read struct\n"); -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_jmpbuf(read_ptr))) -#endif - { - fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname); - if (row_buf) - png_free(read_ptr, row_buf); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - FCLOSE(fpin); - FCLOSE(fpout); - return (1); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(read_ptr),jmpbuf,png_sizeof(jmp_buf)); -#endif - -#ifdef PNG_WRITE_SUPPORTED - png_debug(0, "Setting jmpbuf for write struct\n"); -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_jmpbuf(write_ptr))) -#endif - { - fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); - png_destroy_info_struct(write_ptr, &write_end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - FCLOSE(fpin); - FCLOSE(fpout); - return (1); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(write_ptr),jmpbuf,png_sizeof(jmp_buf)); -#endif -#endif -#endif - - png_debug(0, "Initializing input and output streams\n"); -#if !defined(PNG_NO_STDIO) - png_init_io(read_ptr, fpin); -# ifdef PNG_WRITE_SUPPORTED - png_init_io(write_ptr, fpout); -# endif -#else - png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data); -# ifdef PNG_WRITE_SUPPORTED - png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data, -# if defined(PNG_WRITE_FLUSH_SUPPORTED) - pngtest_flush); -# else - NULL); -# endif -# endif -#endif - if(status_dots_requested == 1) - { -#ifdef PNG_WRITE_SUPPORTED - png_set_write_status_fn(write_ptr, write_row_callback); -#endif - png_set_read_status_fn(read_ptr, read_row_callback); - } - else - { -#ifdef PNG_WRITE_SUPPORTED - png_set_write_status_fn(write_ptr, png_write_status_ptr_NULL); -#endif - png_set_read_status_fn(read_ptr, png_read_status_ptr_NULL); - } - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - { - int i; - for(i=0; i<256; i++) - filters_used[i]=0; - png_set_read_user_transform_fn(read_ptr, count_filters); - } -#endif -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - zero_samples=0; - png_set_write_user_transform_fn(write_ptr, count_zero_samples); -#endif - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) -# ifndef PNG_HANDLE_CHUNK_ALWAYS -# define PNG_HANDLE_CHUNK_ALWAYS 3 -# endif - png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS, - png_bytep_NULL, 0); -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) -# ifndef PNG_HANDLE_CHUNK_IF_SAFE -# define PNG_HANDLE_CHUNK_IF_SAFE 2 -# endif - png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_IF_SAFE, - png_bytep_NULL, 0); -#endif - - png_debug(0, "Reading info struct\n"); - png_read_info(read_ptr, read_info_ptr); - - png_debug(0, "Transferring info struct\n"); - { - int interlace_type, compression_type, filter_type; - - if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth, - &color_type, &interlace_type, &compression_type, &filter_type)) - { - png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth, -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - color_type, interlace_type, compression_type, filter_type); -#else - color_type, PNG_INTERLACE_NONE, compression_type, filter_type); -#endif - } - } -#if defined(PNG_FIXED_POINT_SUPPORTED) -#if defined(PNG_cHRM_SUPPORTED) - { - png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x, - blue_y; - if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, - &red_y, &green_x, &green_y, &blue_x, &blue_y)) - { - png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x, - red_y, green_x, green_y, blue_x, blue_y); - } - } -#endif -#if defined(PNG_gAMA_SUPPORTED) - { - png_fixed_point gamma; - - if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma)) - { - png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma); - } - } -#endif -#else /* Use floating point versions */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) -#if defined(PNG_cHRM_SUPPORTED) - { - double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, - blue_y; - if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, - &red_y, &green_x, &green_y, &blue_x, &blue_y)) - { - png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x, - red_y, green_x, green_y, blue_x, blue_y); - } - } -#endif -#if defined(PNG_gAMA_SUPPORTED) - { - double gamma; - - if (png_get_gAMA(read_ptr, read_info_ptr, &gamma)) - { - png_set_gAMA(write_ptr, write_info_ptr, gamma); - } - } -#endif -#endif /* floating point */ -#endif /* fixed point */ -#if defined(PNG_iCCP_SUPPORTED) - { - png_charp name; - png_charp profile; - png_uint_32 proflen; - int compression_type; - - if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type, - &profile, &proflen)) - { - png_set_iCCP(write_ptr, write_info_ptr, name, compression_type, - profile, proflen); - } - } -#endif -#if defined(PNG_sRGB_SUPPORTED) - { - int intent; - - if (png_get_sRGB(read_ptr, read_info_ptr, &intent)) - { - png_set_sRGB(write_ptr, write_info_ptr, intent); - } - } -#endif - { - png_colorp palette; - int num_palette; - - if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette)) - { - png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); - } - } -#if defined(PNG_bKGD_SUPPORTED) - { - png_color_16p background; - - if (png_get_bKGD(read_ptr, read_info_ptr, &background)) - { - png_set_bKGD(write_ptr, write_info_ptr, background); - } - } -#endif -#if defined(PNG_hIST_SUPPORTED) - { - png_uint_16p hist; - - if (png_get_hIST(read_ptr, read_info_ptr, &hist)) - { - png_set_hIST(write_ptr, write_info_ptr, hist); - } - } -#endif -#if defined(PNG_oFFs_SUPPORTED) - { - png_int_32 offset_x, offset_y; - int unit_type; - - if (png_get_oFFs(read_ptr, read_info_ptr,&offset_x,&offset_y,&unit_type)) - { - png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type); - } - } -#endif -#if defined(PNG_pCAL_SUPPORTED) - { - png_charp purpose, units; - png_charpp params; - png_int_32 X0, X1; - int type, nparams; - - if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type, - &nparams, &units, ¶ms)) - { - png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type, - nparams, units, params); - } - } -#endif -#if defined(PNG_pHYs_SUPPORTED) - { - png_uint_32 res_x, res_y; - int unit_type; - - if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type)) - { - png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type); - } - } -#endif -#if defined(PNG_sBIT_SUPPORTED) - { - png_color_8p sig_bit; - - if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit)) - { - png_set_sBIT(write_ptr, write_info_ptr, sig_bit); - } - } -#endif -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - { - int unit; - double scal_width, scal_height; - - if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width, - &scal_height)) - { - png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height); - } - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - { - int unit; - png_charp scal_width, scal_height; - - if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width, - &scal_height)) - { - png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width, scal_height); - } - } -#endif -#endif -#endif -#if defined(PNG_TEXT_SUPPORTED) - { - png_textp text_ptr; - int num_text; - - if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0) - { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); - png_set_text(write_ptr, write_info_ptr, text_ptr, num_text); - } - } -#endif -#if defined(PNG_tIME_SUPPORTED) - { - png_timep mod_time; - - if (png_get_tIME(read_ptr, read_info_ptr, &mod_time)) - { - png_set_tIME(write_ptr, write_info_ptr, mod_time); -#if defined(PNG_TIME_RFC1123_SUPPORTED) - /* we have to use png_strcpy instead of "=" because the string - pointed to by png_convert_to_rfc1123() gets free'ed before - we use it */ - png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time)); - tIME_chunk_present++; -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } -#endif -#if defined(PNG_tRNS_SUPPORTED) - { - png_bytep trans; - int num_trans; - png_color_16p trans_values; - - if (png_get_tRNS(read_ptr, read_info_ptr, &trans, &num_trans, - &trans_values)) - { - png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans, - trans_values); - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - { - png_unknown_chunkp unknowns; - int num_unknowns = (int)png_get_unknown_chunks(read_ptr, read_info_ptr, - &unknowns); - if (num_unknowns) - { - png_size_t i; - png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns, - num_unknowns); - /* copy the locations from the read_info_ptr. The automatically - generated locations in write_info_ptr are wrong because we - haven't written anything yet */ - for (i = 0; i < (png_size_t)num_unknowns; i++) - png_set_unknown_chunk_location(write_ptr, write_info_ptr, i, - unknowns[i].location); - } - } -#endif - -#ifdef PNG_WRITE_SUPPORTED - png_debug(0, "\nWriting info struct\n"); - -/* If we wanted, we could write info in two steps: - png_write_info_before_PLTE(write_ptr, write_info_ptr); - */ - png_write_info(write_ptr, write_info_ptr); -#endif - -#ifdef SINGLE_ROWBUF_ALLOC - png_debug(0, "\nAllocating row buffer..."); - row_buf = (png_bytep)png_malloc(read_ptr, - png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug1(0, "0x%08lx\n\n", (unsigned long)row_buf); -#endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(0, "Writing row data\n"); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) - num_pass = png_set_interlace_handling(read_ptr); -# ifdef PNG_WRITE_SUPPORTED - png_set_interlace_handling(write_ptr); -# endif -#else - num_pass=1; -#endif - -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_misc += (t_stop - t_start); - t_start = t_stop; -#endif - for (pass = 0; pass < num_pass; pass++) - { - png_debug1(0, "Writing row data for pass %d\n",pass); - for (y = 0; y < height; y++) - { -#ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "\nAllocating row buffer (pass %d, y = %ld)...", pass,y); - row_buf = (png_bytep)png_malloc(read_ptr, - png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug2(0, "0x%08lx (%ld bytes)\n", (unsigned long)row_buf, - png_get_rowbytes(read_ptr, read_info_ptr)); -#endif /* !SINGLE_ROWBUF_ALLOC */ - png_read_rows(read_ptr, (png_bytepp)&row_buf, png_bytepp_NULL, 1); - -#ifdef PNG_WRITE_SUPPORTED -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_decode += (t_stop - t_start); - t_start = t_stop; -#endif - png_write_rows(write_ptr, (png_bytepp)&row_buf, 1); -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_encode += (t_stop - t_start); - t_start = t_stop; -#endif -#endif /* PNG_WRITE_SUPPORTED */ - -#ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "Freeing row buffer (pass %d, y = %ld)\n\n", pass, y); - png_free(read_ptr, row_buf); -#endif /* !SINGLE_ROWBUF_ALLOC */ - } - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1); -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1); -#endif - - png_debug(0, "Reading and writing end_info data\n"); - - png_read_end(read_ptr, end_info_ptr); -#if defined(PNG_TEXT_SUPPORTED) - { - png_textp text_ptr; - int num_text; - - if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0) - { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); - png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text); - } - } -#endif -#if defined(PNG_tIME_SUPPORTED) - { - png_timep mod_time; - - if (png_get_tIME(read_ptr, end_info_ptr, &mod_time)) - { - png_set_tIME(write_ptr, write_end_info_ptr, mod_time); -#if defined(PNG_TIME_RFC1123_SUPPORTED) - /* we have to use png_strcpy instead of "=" because the string - pointed to by png_convert_to_rfc1123() gets free'ed before - we use it */ - png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time)); - tIME_chunk_present++; -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - { - png_unknown_chunkp unknowns; - int num_unknowns; - num_unknowns = (int)png_get_unknown_chunks(read_ptr, end_info_ptr, - &unknowns); - if (num_unknowns) - { - png_size_t i; - png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns, - num_unknowns); - /* copy the locations from the read_info_ptr. The automatically - generated locations in write_end_info_ptr are wrong because we - haven't written the end_info yet */ - for (i = 0; i < (png_size_t)num_unknowns; i++) - png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i, - unknowns[i].location); - } - } -#endif -#ifdef PNG_WRITE_SUPPORTED - png_write_end(write_ptr, write_end_info_ptr); -#endif - -#ifdef PNG_EASY_ACCESS_SUPPORTED - if(verbose) - { - png_uint_32 iwidth, iheight; - iwidth = png_get_image_width(write_ptr, write_info_ptr); - iheight = png_get_image_height(write_ptr, write_info_ptr); - fprintf(STDERR, "Image width = %lu, height = %lu\n", - (unsigned long)iwidth, (unsigned long)iheight); - } -#endif - - png_debug(0, "Destroying data structs\n"); -#ifdef SINGLE_ROWBUF_ALLOC - png_debug(1, "destroying row_buf for read_ptr\n"); - png_free(read_ptr, row_buf); - row_buf=NULL; -#endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr\n"); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_debug(1, "destroying write_end_info_ptr\n"); - png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_debug(1, "destroying write_ptr, write_info_ptr\n"); - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - png_debug(0, "Destruction complete.\n"); - - FCLOSE(fpin); - FCLOSE(fpout); - - png_debug(0, "Opening files for comparison\n"); -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); - if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpin = fopen(inname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find file %s\n", inname); - return (1); - } - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); - if ((fpout = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpout = fopen(outname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find file %s\n", outname); - FCLOSE(fpin); - return (1); - } - - for(;;) - { - png_size_t num_in, num_out; - - READFILE(fpin, inbuf, 1, num_in); - READFILE(fpout, outbuf, 1, num_out); - - if (num_in != num_out) - { - fprintf(STDERR, "\nFiles %s and %s are of a different size\n", - inname, outname); - if(wrote_question == 0) - { - fprintf(STDERR, - " Was %s written with the same maximum IDAT chunk size (%d bytes),", - inname,PNG_ZBUF_SIZE); - fprintf(STDERR, - "\n filtering heuristic (libpng default), compression"); - fprintf(STDERR, - " level (zlib default),\n and zlib version (%s)?\n\n", - ZLIB_VERSION); - wrote_question=1; - } - FCLOSE(fpin); - FCLOSE(fpout); - return (0); - } - - if (!num_in) - break; - - if (png_memcmp(inbuf, outbuf, num_in)) - { - fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname); - if(wrote_question == 0) - { - fprintf(STDERR, - " Was %s written with the same maximum IDAT chunk size (%d bytes),", - inname,PNG_ZBUF_SIZE); - fprintf(STDERR, - "\n filtering heuristic (libpng default), compression"); - fprintf(STDERR, - " level (zlib default),\n and zlib version (%s)?\n\n", - ZLIB_VERSION); - wrote_question=1; - } - FCLOSE(fpin); - FCLOSE(fpout); - return (0); - } - } - - FCLOSE(fpin); - FCLOSE(fpout); - - return (0); -} - -/* input and output filenames */ -#ifdef RISCOS -static PNG_CONST char *inname = "pngtest/png"; -static PNG_CONST char *outname = "pngout/png"; -#else -static PNG_CONST char *inname = "pngtest.png"; -static PNG_CONST char *outname = "pngout.png"; -#endif - -int -main(int argc, char *argv[]) -{ - int multiple = 0; - int ierror = 0; - - fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); - fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION); - fprintf(STDERR,"%s",png_get_copyright(NULL)); - /* Show the version of libpng used in building the library */ - fprintf(STDERR," library (%lu):%s", - (unsigned long)png_access_version_number(), - png_get_header_version(NULL)); - /* Show the version of libpng used in building the application */ - fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, - PNG_HEADER_VERSION_STRING); - fprintf(STDERR," png_sizeof(png_struct)=%ld, png_sizeof(png_info)=%ld\n", - (long)png_sizeof(png_struct), (long)png_sizeof(png_info)); - - /* Do some consistency checking on the memory allocation settings, I'm - not sure this matters, but it is nice to know, the first of these - tests should be impossible because of the way the macros are set - in pngconf.h */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) - fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n"); -#endif - /* I think the following can happen. */ -#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K) - fprintf(STDERR, " NOTE: libpng compiled for max 64k, zlib not\n"); -#endif - - if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING)) - { - fprintf(STDERR, - "Warning: versions are different between png.h and png.c\n"); - fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING); - fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver); - ++ierror; - } - - if (argc > 1) - { - if (strcmp(argv[1], "-m") == 0) - { - multiple = 1; - status_dots_requested = 0; - } - else if (strcmp(argv[1], "-mv") == 0 || - strcmp(argv[1], "-vm") == 0 ) - { - multiple = 1; - verbose = 1; - status_dots_requested = 1; - } - else if (strcmp(argv[1], "-v") == 0) - { - verbose = 1; - status_dots_requested = 1; - inname = argv[2]; - } - else - { - inname = argv[1]; - status_dots_requested = 0; - } - } - - if (!multiple && argc == 3+verbose) - outname = argv[2+verbose]; - - if ((!multiple && argc > 3+verbose) || (multiple && argc < 2)) - { - fprintf(STDERR, - "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n", - argv[0], argv[0]); - fprintf(STDERR, - " reads/writes one PNG file (without -m) or multiple files (-m)\n"); - fprintf(STDERR, - " with -m %s is used as a temporary file\n", outname); - exit(1); - } - - if (multiple) - { - int i; -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - int allocation_now = current_allocation; -#endif - for (i=2; isize, - (unsigned int) pinfo->pointer); - pinfo = pinfo->next; - } - } -#endif - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - fprintf(STDERR, " Current memory allocation: %10d bytes\n", - current_allocation); - fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", - maximum_allocation); - fprintf(STDERR, " Total memory allocation: %10d bytes\n", - total_allocation); - fprintf(STDERR, " Number of allocations: %10d\n", - num_allocations); -#endif - } - else - { - int i; - for (i=0; i<3; ++i) - { - int kerror; -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - int allocation_now = current_allocation; -#endif - if (i == 1) status_dots_requested = 1; - else if(verbose == 0)status_dots_requested = 0; - if (i == 0 || verbose == 1 || ierror != 0) - fprintf(STDERR, "Testing %s:",inname); - kerror = test_one_file(inname, outname); - if(kerror == 0) - { - if(verbose == 1 || i == 2) - { -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - int k; -#endif -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - fprintf(STDERR, "\n PASS (%lu zero samples)\n", - (unsigned long)zero_samples); -#else - fprintf(STDERR, " PASS\n"); -#endif -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - for (k=0; k<256; k++) - if(filters_used[k]) - fprintf(STDERR, " Filter %d was used %lu times\n", - k,(unsigned long)filters_used[k]); -#endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) - if(tIME_chunk_present != 0) - fprintf(STDERR, " tIME = %s\n",tIME_string); -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } - else - { - if(verbose == 0 && i != 2) - fprintf(STDERR, "Testing %s:",inname); - fprintf(STDERR, " FAIL\n"); - ierror += kerror; - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - if (allocation_now != current_allocation) - fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", - current_allocation-allocation_now); - if (current_allocation != 0) - { - memory_infop pinfo = pinformation; - - fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n", - current_allocation); - while (pinfo != NULL) - { - fprintf(STDERR," %lu bytes at %x\n", - (unsigned long)pinfo->size, (unsigned int)pinfo->pointer); - pinfo = pinfo->next; - } - } -#endif - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - fprintf(STDERR, " Current memory allocation: %10d bytes\n", - current_allocation); - fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", - maximum_allocation); - fprintf(STDERR, " Total memory allocation: %10d bytes\n", - total_allocation); - fprintf(STDERR, " Number of allocations: %10d\n", - num_allocations); -#endif - } - -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_misc += (t_stop - t_start); - t_start = t_stop; - fprintf(STDERR," CPU time used = %.3f seconds", - (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC); - fprintf(STDERR," (decoding %.3f,\n", - t_decode/(float)CLOCKS_PER_SEC); - fprintf(STDERR," encoding %.3f ,", - t_encode/(float)CLOCKS_PER_SEC); - fprintf(STDERR," other %.3f seconds)\n\n", - t_misc/(float)CLOCKS_PER_SEC); -#endif - - if (ierror == 0) - fprintf(STDERR, "libpng passes test\n"); - else - fprintf(STDERR, "libpng FAILS test\n"); - return (int)(ierror != 0); -} - -/* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_16 your_png_h_is_not_version_1_2_16; + +/* pngtest.c - a simple test program to test libpng + * + * Last changed in libpng 1.2.6 - August 15, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This program reads in a PNG image, writes it out again, and then + * compares the two files. If the files are identical, this shows that + * the basic chunk handling, filtering, and (de)compression code is working + * properly. It does not currently test all of the transforms, although + * it probably should. + * + * The program will report "FAIL" in certain legitimate cases: + * 1) when the compression level or filter selection method is changed. + * 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192. + * 3) unknown unsafe-to-copy ancillary chunks or unknown critical chunks + * exist in the input file. + * 4) others not listed here... + * In these cases, it is best to check with another tool such as "pngcheck" + * to see what the differences between the two files are. + * + * If a filename is given on the command-line, then this file is used + * for the input, rather than the default "pngtest.png". This allows + * testing a wide variety of files easily. You can also test a number + * of files at once by typing "pngtest -m file1.png file2.png ..." + */ + +#include "png.h" + +#if defined(_WIN32_WCE) +# if _WIN32_WCE < 211 + __error__ (f|w)printf functions are not supported on old WindowsCE.; +# endif +# include +# include +# define READFILE(file, data, length, check) \ + if (ReadFile(file, data, length, &check,NULL)) check = 0 +# define WRITEFILE(file, data, length, check)) \ + if (WriteFile(file, data, length, &check, NULL)) check = 0 +# define FCLOSE(file) CloseHandle(file) +#else +# include +# include +# define READFILE(file, data, length, check) \ + check=(png_size_t)fread(data,(png_size_t)1,length,file) +# define WRITEFILE(file, data, length, check) \ + check=(png_size_t)fwrite(data,(png_size_t)1, length, file) +# define FCLOSE(file) fclose(file) +#endif + +#if defined(PNG_NO_STDIO) +# if defined(_WIN32_WCE) + typedef HANDLE png_FILE_p; +# else + typedef FILE * png_FILE_p; +# endif +#endif + +/* Makes pngtest verbose so we can find problems (needs to be before png.h) */ +#ifndef PNG_DEBUG +# define PNG_DEBUG 0 +#endif + +#if !PNG_DEBUG +# define SINGLE_ROWBUF_ALLOC /* makes buffer overruns easier to nail */ +#endif + +/* Turn on CPU timing +#define PNGTEST_TIMING +*/ + +#ifdef PNG_NO_FLOATING_POINT_SUPPORTED +#undef PNGTEST_TIMING +#endif + +#ifdef PNGTEST_TIMING +static float t_start, t_stop, t_decode, t_encode, t_misc; +#include +#endif + +#if defined(PNG_TIME_RFC1123_SUPPORTED) +static int tIME_chunk_present=0; +static char tIME_string[30] = "no tIME chunk present in file"; +#endif + +static int verbose = 0; + +int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname)); + +#ifdef __TURBOC__ +#include +#endif + +/* defined so I can write to a file on gui/windowing platforms */ +/* #define STDERR stderr */ +#define STDERR stdout /* for DOS */ + +/* example of using row callbacks to make a simple progress meter */ +static int status_pass=1; +static int status_dots_requested=0; +static int status_dots=1; + +/* In case a system header (e.g., on AIX) defined jmpbuf */ +#ifdef jmpbuf +# undef jmpbuf +#endif + +/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ +#ifndef png_jmpbuf +# define png_jmpbuf(png_ptr) png_ptr->jmpbuf +#endif + +void +#ifdef PNG_1_0_X +PNGAPI +#endif +read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); +void +#ifdef PNG_1_0_X +PNGAPI +#endif +read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) +{ + if(png_ptr == NULL || row_number > PNG_UINT_31_MAX) return; + if(status_pass != pass) + { + fprintf(stdout,"\n Pass %d: ",pass); + status_pass = pass; + status_dots = 31; + } + status_dots--; + if(status_dots == 0) + { + fprintf(stdout, "\n "); + status_dots=30; + } + fprintf(stdout, "r"); +} + +void +#ifdef PNG_1_0_X +PNGAPI +#endif +write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); +void +#ifdef PNG_1_0_X +PNGAPI +#endif +write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) +{ + if(png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) return; + fprintf(stdout, "w"); +} + + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) +/* Example of using user transform callback (we don't transform anything, + but merely examine the row filters. We set this to 256 rather than + 5 in case illegal filter values are present.) */ +static png_uint_32 filters_used[256]; +void +#ifdef PNG_1_0_X +PNGAPI +#endif +count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data); +void +#ifdef PNG_1_0_X +PNGAPI +#endif +count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data) +{ + if(png_ptr != NULL && row_info != NULL) + ++filters_used[*(data-1)]; +} +#endif + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +/* example of using user transform callback (we don't transform anything, + but merely count the zero samples) */ + +static png_uint_32 zero_samples; + +void +#ifdef PNG_1_0_X +PNGAPI +#endif +count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data); +void +#ifdef PNG_1_0_X +PNGAPI +#endif +count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) +{ + png_bytep dp = data; + if(png_ptr == NULL)return; + + /* contents of row_info: + * png_uint_32 width width of row + * png_uint_32 rowbytes number of bytes in row + * png_byte color_type color type of pixels + * png_byte bit_depth bit depth of samples + * png_byte channels number of channels (1-4) + * png_byte pixel_depth bits per pixel (depth*channels) + */ + + + /* counts the number of zero samples (or zero pixels if color_type is 3 */ + + if(row_info->color_type == 0 || row_info->color_type == 3) + { + int pos=0; + png_uint_32 n, nstop; + for (n=0, nstop=row_info->width; nbit_depth == 1) + { + if(((*dp << pos++ ) & 0x80) == 0) zero_samples++; + if(pos == 8) + { + pos = 0; + dp++; + } + } + if(row_info->bit_depth == 2) + { + if(((*dp << (pos+=2)) & 0xc0) == 0) zero_samples++; + if(pos == 8) + { + pos = 0; + dp++; + } + } + if(row_info->bit_depth == 4) + { + if(((*dp << (pos+=4)) & 0xf0) == 0) zero_samples++; + if(pos == 8) + { + pos = 0; + dp++; + } + } + if(row_info->bit_depth == 8) + if(*dp++ == 0) zero_samples++; + if(row_info->bit_depth == 16) + { + if((*dp | *(dp+1)) == 0) zero_samples++; + dp+=2; + } + } + } + else /* other color types */ + { + png_uint_32 n, nstop; + int channel; + int color_channels = row_info->channels; + if(row_info->color_type > 3)color_channels--; + + for (n=0, nstop=row_info->width; nbit_depth == 8) + if(*dp++ == 0) zero_samples++; + if(row_info->bit_depth == 16) + { + if((*dp | *(dp+1)) == 0) zero_samples++; + dp+=2; + } + } + if(row_info->color_type > 3) + { + dp++; + if(row_info->bit_depth == 16)dp++; + } + } + } +} +#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */ + +static int wrote_question = 0; + +#if defined(PNG_NO_STDIO) +/* START of code to validate stdio-free compilation */ +/* These copies of the default read/write functions come from pngrio.c and */ +/* pngwio.c. They allow "don't include stdio" testing of the library. */ +/* This is the function that does the actual reading of data. If you are + not reading from a standard C stream, you should create a replacement + read_data function and use it at run time with png_set_read_fn(), rather + than changing the library. */ + +#ifndef USE_FAR_KEYWORD +static void +pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_size_t check; + + /* fread() returns 0 on error, so it is OK to store this in a png_size_t + * instead of an int, which is what fread() actually returns. + */ + READFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); + + if (check != length) + { + png_error(png_ptr, "Read Error!"); + } +} +#else +/* this is the model-independent version. Since the standard I/O library + can't handle far buffers in the medium and small models, we have to copy + the data. +*/ + +#define NEAR_BUF_SIZE 1024 +#define MIN(a,b) (a <= b ? a : b) + +static void +pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + int check; + png_byte *n_data; + png_FILE_p io_ptr; + + /* Check if data really is near. If so, use usual code. */ + n_data = (png_byte *)CVT_PTR_NOCHECK(data); + io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); + if ((png_bytep)n_data == data) + { + READFILE(io_ptr, n_data, length, check); + } + else + { + png_byte buf[NEAR_BUF_SIZE]; + png_size_t read, remaining, err; + check = 0; + remaining = length; + do + { + read = MIN(NEAR_BUF_SIZE, remaining); + READFILE(io_ptr, buf, 1, err); + png_memcpy(data, buf, read); /* copy far buffer to near buffer */ + if(err != read) + break; + else + check += err; + data += read; + remaining -= read; + } + while (remaining != 0); + } + if (check != length) + { + png_error(png_ptr, "read Error"); + } +} +#endif /* USE_FAR_KEYWORD */ + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +static void +pngtest_flush(png_structp png_ptr) +{ +#if !defined(_WIN32_WCE) + png_FILE_p io_ptr; + io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); + if (io_ptr != NULL) + fflush(io_ptr); +#endif +} +#endif + +/* This is the function that does the actual writing of data. If you are + not writing to a standard C stream, you should create a replacement + write_data function and use it at run time with png_set_write_fn(), rather + than changing the library. */ +#ifndef USE_FAR_KEYWORD +static void +pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_uint_32 check; + + WRITEFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); + if (check != length) + { + png_error(png_ptr, "Write Error"); + } +} +#else +/* this is the model-independent version. Since the standard I/O library + can't handle far buffers in the medium and small models, we have to copy + the data. +*/ + +#define NEAR_BUF_SIZE 1024 +#define MIN(a,b) (a <= b ? a : b) + +static void +pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_uint_32 check; + png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ + png_FILE_p io_ptr; + + /* Check if data really is near. If so, use usual code. */ + near_data = (png_byte *)CVT_PTR_NOCHECK(data); + io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); + if ((png_bytep)near_data == data) + { + WRITEFILE(io_ptr, near_data, length, check); + } + else + { + png_byte buf[NEAR_BUF_SIZE]; + png_size_t written, remaining, err; + check = 0; + remaining = length; + do + { + written = MIN(NEAR_BUF_SIZE, remaining); + png_memcpy(buf, data, written); /* copy far buffer to near buffer */ + WRITEFILE(io_ptr, buf, written, err); + if (err != written) + break; + else + check += err; + data += written; + remaining -= written; + } + while (remaining != 0); + } + if (check != length) + { + png_error(png_ptr, "Write Error"); + } +} + +#endif /* USE_FAR_KEYWORD */ + +/* This function is called when there is a warning, but the library thinks + * it can continue anyway. Replacement functions don't have to do anything + * here if you don't want to. In the default configuration, png_ptr is + * not used, but it is passed in case it may be useful. + */ +static void +pngtest_warning(png_structp png_ptr, png_const_charp message) +{ + PNG_CONST char *name = "UNKNOWN (ERROR!)"; + if (png_ptr != NULL && png_ptr->error_ptr != NULL) + name = png_ptr->error_ptr; + fprintf(STDERR, "%s: libpng warning: %s\n", name, message); +} + +/* This is the default error handling function. Note that replacements for + * this function MUST NOT RETURN, or the program will likely crash. This + * function is used by default, or if the program supplies NULL for the + * error function pointer in png_set_error_fn(). + */ +static void +pngtest_error(png_structp png_ptr, png_const_charp message) +{ + pngtest_warning(png_ptr, message); + /* We can return because png_error calls the default handler, which is + * actually OK in this case. */ +} +#endif /* PNG_NO_STDIO */ +/* END of code to validate stdio-free compilation */ + +/* START of code to validate memory allocation and deallocation */ +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + +/* Allocate memory. For reasonable files, size should never exceed + 64K. However, zlib may allocate more then 64K if you don't tell + it not to. See zconf.h and png.h for more information. zlib does + need to allocate exactly 64K, so whatever you call here must + have the ability to do that. + + This piece of code can be compiled to validate max 64K allocations + by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */ +typedef struct memory_information +{ + png_uint_32 size; + png_voidp pointer; + struct memory_information FAR *next; +} memory_information; +typedef memory_information FAR *memory_infop; + +static memory_infop pinformation = NULL; +static int current_allocation = 0; +static int maximum_allocation = 0; +static int total_allocation = 0; +static int num_allocations = 0; + +png_voidp png_debug_malloc PNGARG((png_structp png_ptr, png_uint_32 size)); +void png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr)); + +png_voidp +png_debug_malloc(png_structp png_ptr, png_uint_32 size) +{ + + /* png_malloc has already tested for NULL; png_create_struct calls + png_debug_malloc directly, with png_ptr == NULL which is OK */ + + if (size == 0) + return (NULL); + + /* This calls the library allocator twice, once to get the requested + buffer and once to get a new free list entry. */ + { + /* Disable malloc_fn and free_fn */ + memory_infop pinfo; + png_set_mem_fn(png_ptr, NULL, NULL, NULL); + pinfo = (memory_infop)png_malloc(png_ptr, + (png_uint_32)png_sizeof (*pinfo)); + pinfo->size = size; + current_allocation += size; + total_allocation += size; + num_allocations ++; + if (current_allocation > maximum_allocation) + maximum_allocation = current_allocation; + pinfo->pointer = (png_voidp)png_malloc(png_ptr, size); + /* Restore malloc_fn and free_fn */ + png_set_mem_fn(png_ptr, png_voidp_NULL, (png_malloc_ptr)png_debug_malloc, + (png_free_ptr)png_debug_free); + if (size != 0 && pinfo->pointer == NULL) + { + current_allocation -= size; + total_allocation -= size; + png_error(png_ptr, + "out of memory in pngtest->png_debug_malloc."); + } + pinfo->next = pinformation; + pinformation = pinfo; + /* Make sure the caller isn't assuming zeroed memory. */ + png_memset(pinfo->pointer, 0xdd, pinfo->size); + if(verbose) + printf("png_malloc %lu bytes at %x\n",(unsigned long)size, + pinfo->pointer); + return (png_voidp)(pinfo->pointer); + } +} + +/* Free a pointer. It is removed from the list at the same time. */ +void +png_debug_free(png_structp png_ptr, png_voidp ptr) +{ + if (png_ptr == NULL) + fprintf(STDERR, "NULL pointer to png_debug_free.\n"); + if (ptr == 0) + { +#if 0 /* This happens all the time. */ + fprintf(STDERR, "WARNING: freeing NULL pointer\n"); +#endif + return; + } + + /* Unlink the element from the list. */ + { + memory_infop FAR *ppinfo = &pinformation; + for (;;) + { + memory_infop pinfo = *ppinfo; + if (pinfo->pointer == ptr) + { + *ppinfo = pinfo->next; + current_allocation -= pinfo->size; + if (current_allocation < 0) + fprintf(STDERR, "Duplicate free of memory\n"); + /* We must free the list element too, but first kill + the memory that is to be freed. */ + png_memset(ptr, 0x55, pinfo->size); + png_free_default(png_ptr, pinfo); + pinfo=NULL; + break; + } + if (pinfo->next == NULL) + { + fprintf(STDERR, "Pointer %x not found\n", (unsigned int)ptr); + break; + } + ppinfo = &pinfo->next; + } + } + + /* Finally free the data. */ + if(verbose) + printf("Freeing %x\n",ptr); + png_free_default(png_ptr, ptr); + ptr=NULL; +} +#endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */ +/* END of code to test memory allocation/deallocation */ + +/* Test one file */ +int +test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) +{ + static png_FILE_p fpin; + static png_FILE_p fpout; /* "static" prevents setjmp corruption */ + png_structp read_ptr; + png_infop read_info_ptr, end_info_ptr; +#ifdef PNG_WRITE_SUPPORTED + png_structp write_ptr; + png_infop write_info_ptr; + png_infop write_end_info_ptr; +#else + png_structp write_ptr = NULL; + png_infop write_info_ptr = NULL; + png_infop write_end_info_ptr = NULL; +#endif + png_bytep row_buf; + png_uint_32 y; + png_uint_32 width, height; + int num_pass, pass; + int bit_depth, color_type; +#ifdef PNG_SETJMP_SUPPORTED +#ifdef USE_FAR_KEYWORD + jmp_buf jmpbuf; +#endif +#endif + +#if defined(_WIN32_WCE) + TCHAR path[MAX_PATH]; +#endif + char inbuf[256], outbuf[256]; + + row_buf = NULL; + +#if defined(_WIN32_WCE) + MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); + if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) +#else + if ((fpin = fopen(inname, "rb")) == NULL) +#endif + { + fprintf(STDERR, "Could not find input file %s\n", inname); + return (1); + } + +#if defined(_WIN32_WCE) + MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); + if ((fpout = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL)) == INVALID_HANDLE_VALUE) +#else + if ((fpout = fopen(outname, "wb")) == NULL) +#endif + { + fprintf(STDERR, "Could not open output file %s\n", outname); + FCLOSE(fpin); + return (1); + } + + png_debug(0, "Allocating read and write structures\n"); +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, + (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); +#else + read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + png_error_ptr_NULL, png_error_ptr_NULL); +#endif +#if defined(PNG_NO_STDIO) + png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error, + pngtest_warning); +#endif +#ifdef PNG_WRITE_SUPPORTED +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, + (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); +#else + write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + png_error_ptr_NULL, png_error_ptr_NULL); +#endif +#if defined(PNG_NO_STDIO) + png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, + pngtest_warning); +#endif +#endif + png_debug(0, "Allocating read_info, write_info and end_info structures\n"); + read_info_ptr = png_create_info_struct(read_ptr); + end_info_ptr = png_create_info_struct(read_ptr); +#ifdef PNG_WRITE_SUPPORTED + write_info_ptr = png_create_info_struct(write_ptr); + write_end_info_ptr = png_create_info_struct(write_ptr); +#endif + +#ifdef PNG_SETJMP_SUPPORTED + png_debug(0, "Setting jmpbuf for read struct\n"); +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) +#else + if (setjmp(png_jmpbuf(read_ptr))) +#endif + { + fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname); + if (row_buf) + png_free(read_ptr, row_buf); + png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); +#ifdef PNG_WRITE_SUPPORTED + png_destroy_info_struct(write_ptr, &write_end_info_ptr); + png_destroy_write_struct(&write_ptr, &write_info_ptr); +#endif + FCLOSE(fpin); + FCLOSE(fpout); + return (1); + } +#ifdef USE_FAR_KEYWORD + png_memcpy(png_jmpbuf(read_ptr),jmpbuf,png_sizeof(jmp_buf)); +#endif + +#ifdef PNG_WRITE_SUPPORTED + png_debug(0, "Setting jmpbuf for write struct\n"); +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) +#else + if (setjmp(png_jmpbuf(write_ptr))) +#endif + { + fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname); + png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); + png_destroy_info_struct(write_ptr, &write_end_info_ptr); +#ifdef PNG_WRITE_SUPPORTED + png_destroy_write_struct(&write_ptr, &write_info_ptr); +#endif + FCLOSE(fpin); + FCLOSE(fpout); + return (1); + } +#ifdef USE_FAR_KEYWORD + png_memcpy(png_jmpbuf(write_ptr),jmpbuf,png_sizeof(jmp_buf)); +#endif +#endif +#endif + + png_debug(0, "Initializing input and output streams\n"); +#if !defined(PNG_NO_STDIO) + png_init_io(read_ptr, fpin); +# ifdef PNG_WRITE_SUPPORTED + png_init_io(write_ptr, fpout); +# endif +#else + png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data); +# ifdef PNG_WRITE_SUPPORTED + png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data, +# if defined(PNG_WRITE_FLUSH_SUPPORTED) + pngtest_flush); +# else + NULL); +# endif +# endif +#endif + if(status_dots_requested == 1) + { +#ifdef PNG_WRITE_SUPPORTED + png_set_write_status_fn(write_ptr, write_row_callback); +#endif + png_set_read_status_fn(read_ptr, read_row_callback); + } + else + { +#ifdef PNG_WRITE_SUPPORTED + png_set_write_status_fn(write_ptr, png_write_status_ptr_NULL); +#endif + png_set_read_status_fn(read_ptr, png_read_status_ptr_NULL); + } + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + { + int i; + for(i=0; i<256; i++) + filters_used[i]=0; + png_set_read_user_transform_fn(read_ptr, count_filters); + } +#endif +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + zero_samples=0; + png_set_write_user_transform_fn(write_ptr, count_zero_samples); +#endif + +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) +# ifndef PNG_HANDLE_CHUNK_ALWAYS +# define PNG_HANDLE_CHUNK_ALWAYS 3 +# endif + png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS, + png_bytep_NULL, 0); +#endif +#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) +# ifndef PNG_HANDLE_CHUNK_IF_SAFE +# define PNG_HANDLE_CHUNK_IF_SAFE 2 +# endif + png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_IF_SAFE, + png_bytep_NULL, 0); +#endif + + png_debug(0, "Reading info struct\n"); + png_read_info(read_ptr, read_info_ptr); + + png_debug(0, "Transferring info struct\n"); + { + int interlace_type, compression_type, filter_type; + + if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth, + &color_type, &interlace_type, &compression_type, &filter_type)) + { + png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth, +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) + color_type, interlace_type, compression_type, filter_type); +#else + color_type, PNG_INTERLACE_NONE, compression_type, filter_type); +#endif + } + } +#if defined(PNG_FIXED_POINT_SUPPORTED) +#if defined(PNG_cHRM_SUPPORTED) + { + png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x, + blue_y; + if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, + &red_y, &green_x, &green_y, &blue_x, &blue_y)) + { + png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x, + red_y, green_x, green_y, blue_x, blue_y); + } + } +#endif +#if defined(PNG_gAMA_SUPPORTED) + { + png_fixed_point gamma; + + if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma)) + { + png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma); + } + } +#endif +#else /* Use floating point versions */ +#if defined(PNG_FLOATING_POINT_SUPPORTED) +#if defined(PNG_cHRM_SUPPORTED) + { + double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, + blue_y; + if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, + &red_y, &green_x, &green_y, &blue_x, &blue_y)) + { + png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x, + red_y, green_x, green_y, blue_x, blue_y); + } + } +#endif +#if defined(PNG_gAMA_SUPPORTED) + { + double gamma; + + if (png_get_gAMA(read_ptr, read_info_ptr, &gamma)) + { + png_set_gAMA(write_ptr, write_info_ptr, gamma); + } + } +#endif +#endif /* floating point */ +#endif /* fixed point */ +#if defined(PNG_iCCP_SUPPORTED) + { + png_charp name; + png_charp profile; + png_uint_32 proflen; + int compression_type; + + if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type, + &profile, &proflen)) + { + png_set_iCCP(write_ptr, write_info_ptr, name, compression_type, + profile, proflen); + } + } +#endif +#if defined(PNG_sRGB_SUPPORTED) + { + int intent; + + if (png_get_sRGB(read_ptr, read_info_ptr, &intent)) + { + png_set_sRGB(write_ptr, write_info_ptr, intent); + } + } +#endif + { + png_colorp palette; + int num_palette; + + if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette)) + { + png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); + } + } +#if defined(PNG_bKGD_SUPPORTED) + { + png_color_16p background; + + if (png_get_bKGD(read_ptr, read_info_ptr, &background)) + { + png_set_bKGD(write_ptr, write_info_ptr, background); + } + } +#endif +#if defined(PNG_hIST_SUPPORTED) + { + png_uint_16p hist; + + if (png_get_hIST(read_ptr, read_info_ptr, &hist)) + { + png_set_hIST(write_ptr, write_info_ptr, hist); + } + } +#endif +#if defined(PNG_oFFs_SUPPORTED) + { + png_int_32 offset_x, offset_y; + int unit_type; + + if (png_get_oFFs(read_ptr, read_info_ptr,&offset_x,&offset_y,&unit_type)) + { + png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type); + } + } +#endif +#if defined(PNG_pCAL_SUPPORTED) + { + png_charp purpose, units; + png_charpp params; + png_int_32 X0, X1; + int type, nparams; + + if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type, + &nparams, &units, ¶ms)) + { + png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type, + nparams, units, params); + } + } +#endif +#if defined(PNG_pHYs_SUPPORTED) + { + png_uint_32 res_x, res_y; + int unit_type; + + if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type)) + { + png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type); + } + } +#endif +#if defined(PNG_sBIT_SUPPORTED) + { + png_color_8p sig_bit; + + if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit)) + { + png_set_sBIT(write_ptr, write_info_ptr, sig_bit); + } + } +#endif +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED + { + int unit; + double scal_width, scal_height; + + if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width, + &scal_height)) + { + png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height); + } + } +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + { + int unit; + png_charp scal_width, scal_height; + + if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width, + &scal_height)) + { + png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width, scal_height); + } + } +#endif +#endif +#endif +#if defined(PNG_TEXT_SUPPORTED) + { + png_textp text_ptr; + int num_text; + + if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0) + { + png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); + png_set_text(write_ptr, write_info_ptr, text_ptr, num_text); + } + } +#endif +#if defined(PNG_tIME_SUPPORTED) + { + png_timep mod_time; + + if (png_get_tIME(read_ptr, read_info_ptr, &mod_time)) + { + png_set_tIME(write_ptr, write_info_ptr, mod_time); +#if defined(PNG_TIME_RFC1123_SUPPORTED) + /* we have to use png_strcpy instead of "=" because the string + pointed to by png_convert_to_rfc1123() gets free'ed before + we use it */ + png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time)); + tIME_chunk_present++; +#endif /* PNG_TIME_RFC1123_SUPPORTED */ + } + } +#endif +#if defined(PNG_tRNS_SUPPORTED) + { + png_bytep trans; + int num_trans; + png_color_16p trans_values; + + if (png_get_tRNS(read_ptr, read_info_ptr, &trans, &num_trans, + &trans_values)) + { + png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans, + trans_values); + } + } +#endif +#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) + { + png_unknown_chunkp unknowns; + int num_unknowns = (int)png_get_unknown_chunks(read_ptr, read_info_ptr, + &unknowns); + if (num_unknowns) + { + png_size_t i; + png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns, + num_unknowns); + /* copy the locations from the read_info_ptr. The automatically + generated locations in write_info_ptr are wrong because we + haven't written anything yet */ + for (i = 0; i < (png_size_t)num_unknowns; i++) + png_set_unknown_chunk_location(write_ptr, write_info_ptr, i, + unknowns[i].location); + } + } +#endif + +#ifdef PNG_WRITE_SUPPORTED + png_debug(0, "\nWriting info struct\n"); + +/* If we wanted, we could write info in two steps: + png_write_info_before_PLTE(write_ptr, write_info_ptr); + */ + png_write_info(write_ptr, write_info_ptr); +#endif + +#ifdef SINGLE_ROWBUF_ALLOC + png_debug(0, "\nAllocating row buffer..."); + row_buf = (png_bytep)png_malloc(read_ptr, + png_get_rowbytes(read_ptr, read_info_ptr)); + png_debug1(0, "0x%08lx\n\n", (unsigned long)row_buf); +#endif /* SINGLE_ROWBUF_ALLOC */ + png_debug(0, "Writing row data\n"); + +#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ + defined(PNG_WRITE_INTERLACING_SUPPORTED) + num_pass = png_set_interlace_handling(read_ptr); +# ifdef PNG_WRITE_SUPPORTED + png_set_interlace_handling(write_ptr); +# endif +#else + num_pass=1; +#endif + +#ifdef PNGTEST_TIMING + t_stop = (float)clock(); + t_misc += (t_stop - t_start); + t_start = t_stop; +#endif + for (pass = 0; pass < num_pass; pass++) + { + png_debug1(0, "Writing row data for pass %d\n",pass); + for (y = 0; y < height; y++) + { +#ifndef SINGLE_ROWBUF_ALLOC + png_debug2(0, "\nAllocating row buffer (pass %d, y = %ld)...", pass,y); + row_buf = (png_bytep)png_malloc(read_ptr, + png_get_rowbytes(read_ptr, read_info_ptr)); + png_debug2(0, "0x%08lx (%ld bytes)\n", (unsigned long)row_buf, + png_get_rowbytes(read_ptr, read_info_ptr)); +#endif /* !SINGLE_ROWBUF_ALLOC */ + png_read_rows(read_ptr, (png_bytepp)&row_buf, png_bytepp_NULL, 1); + +#ifdef PNG_WRITE_SUPPORTED +#ifdef PNGTEST_TIMING + t_stop = (float)clock(); + t_decode += (t_stop - t_start); + t_start = t_stop; +#endif + png_write_rows(write_ptr, (png_bytepp)&row_buf, 1); +#ifdef PNGTEST_TIMING + t_stop = (float)clock(); + t_encode += (t_stop - t_start); + t_start = t_stop; +#endif +#endif /* PNG_WRITE_SUPPORTED */ + +#ifndef SINGLE_ROWBUF_ALLOC + png_debug2(0, "Freeing row buffer (pass %d, y = %ld)\n\n", pass, y); + png_free(read_ptr, row_buf); +#endif /* !SINGLE_ROWBUF_ALLOC */ + } + } + +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1); +#endif +#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) + png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1); +#endif + + png_debug(0, "Reading and writing end_info data\n"); + + png_read_end(read_ptr, end_info_ptr); +#if defined(PNG_TEXT_SUPPORTED) + { + png_textp text_ptr; + int num_text; + + if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0) + { + png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); + png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text); + } + } +#endif +#if defined(PNG_tIME_SUPPORTED) + { + png_timep mod_time; + + if (png_get_tIME(read_ptr, end_info_ptr, &mod_time)) + { + png_set_tIME(write_ptr, write_end_info_ptr, mod_time); +#if defined(PNG_TIME_RFC1123_SUPPORTED) + /* we have to use png_strcpy instead of "=" because the string + pointed to by png_convert_to_rfc1123() gets free'ed before + we use it */ + png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time)); + tIME_chunk_present++; +#endif /* PNG_TIME_RFC1123_SUPPORTED */ + } + } +#endif +#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) + { + png_unknown_chunkp unknowns; + int num_unknowns; + num_unknowns = (int)png_get_unknown_chunks(read_ptr, end_info_ptr, + &unknowns); + if (num_unknowns) + { + png_size_t i; + png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns, + num_unknowns); + /* copy the locations from the read_info_ptr. The automatically + generated locations in write_end_info_ptr are wrong because we + haven't written the end_info yet */ + for (i = 0; i < (png_size_t)num_unknowns; i++) + png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i, + unknowns[i].location); + } + } +#endif +#ifdef PNG_WRITE_SUPPORTED + png_write_end(write_ptr, write_end_info_ptr); +#endif + +#ifdef PNG_EASY_ACCESS_SUPPORTED + if(verbose) + { + png_uint_32 iwidth, iheight; + iwidth = png_get_image_width(write_ptr, write_info_ptr); + iheight = png_get_image_height(write_ptr, write_info_ptr); + fprintf(STDERR, "Image width = %lu, height = %lu\n", + (unsigned long)iwidth, (unsigned long)iheight); + } +#endif + + png_debug(0, "Destroying data structs\n"); +#ifdef SINGLE_ROWBUF_ALLOC + png_debug(1, "destroying row_buf for read_ptr\n"); + png_free(read_ptr, row_buf); + row_buf=NULL; +#endif /* SINGLE_ROWBUF_ALLOC */ + png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr\n"); + png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); +#ifdef PNG_WRITE_SUPPORTED + png_debug(1, "destroying write_end_info_ptr\n"); + png_destroy_info_struct(write_ptr, &write_end_info_ptr); + png_debug(1, "destroying write_ptr, write_info_ptr\n"); + png_destroy_write_struct(&write_ptr, &write_info_ptr); +#endif + png_debug(0, "Destruction complete.\n"); + + FCLOSE(fpin); + FCLOSE(fpout); + + png_debug(0, "Opening files for comparison\n"); +#if defined(_WIN32_WCE) + MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); + if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) +#else + if ((fpin = fopen(inname, "rb")) == NULL) +#endif + { + fprintf(STDERR, "Could not find file %s\n", inname); + return (1); + } + +#if defined(_WIN32_WCE) + MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); + if ((fpout = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) +#else + if ((fpout = fopen(outname, "rb")) == NULL) +#endif + { + fprintf(STDERR, "Could not find file %s\n", outname); + FCLOSE(fpin); + return (1); + } + + for(;;) + { + png_size_t num_in, num_out; + + READFILE(fpin, inbuf, 1, num_in); + READFILE(fpout, outbuf, 1, num_out); + + if (num_in != num_out) + { + fprintf(STDERR, "\nFiles %s and %s are of a different size\n", + inname, outname); + if(wrote_question == 0) + { + fprintf(STDERR, + " Was %s written with the same maximum IDAT chunk size (%d bytes),", + inname,PNG_ZBUF_SIZE); + fprintf(STDERR, + "\n filtering heuristic (libpng default), compression"); + fprintf(STDERR, + " level (zlib default),\n and zlib version (%s)?\n\n", + ZLIB_VERSION); + wrote_question=1; + } + FCLOSE(fpin); + FCLOSE(fpout); + return (0); + } + + if (!num_in) + break; + + if (png_memcmp(inbuf, outbuf, num_in)) + { + fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname); + if(wrote_question == 0) + { + fprintf(STDERR, + " Was %s written with the same maximum IDAT chunk size (%d bytes),", + inname,PNG_ZBUF_SIZE); + fprintf(STDERR, + "\n filtering heuristic (libpng default), compression"); + fprintf(STDERR, + " level (zlib default),\n and zlib version (%s)?\n\n", + ZLIB_VERSION); + wrote_question=1; + } + FCLOSE(fpin); + FCLOSE(fpout); + return (0); + } + } + + FCLOSE(fpin); + FCLOSE(fpout); + + return (0); +} + +/* input and output filenames */ +#ifdef RISCOS +static PNG_CONST char *inname = "pngtest/png"; +static PNG_CONST char *outname = "pngout/png"; +#else +static PNG_CONST char *inname = "pngtest.png"; +static PNG_CONST char *outname = "pngout.png"; +#endif + +int +main(int argc, char *argv[]) +{ + int multiple = 0; + int ierror = 0; + + fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); + fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION); + fprintf(STDERR,"%s",png_get_copyright(NULL)); + /* Show the version of libpng used in building the library */ + fprintf(STDERR," library (%lu):%s", + (unsigned long)png_access_version_number(), + png_get_header_version(NULL)); + /* Show the version of libpng used in building the application */ + fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, + PNG_HEADER_VERSION_STRING); + fprintf(STDERR," png_sizeof(png_struct)=%ld, png_sizeof(png_info)=%ld\n", + (long)png_sizeof(png_struct), (long)png_sizeof(png_info)); + + /* Do some consistency checking on the memory allocation settings, I'm + not sure this matters, but it is nice to know, the first of these + tests should be impossible because of the way the macros are set + in pngconf.h */ +#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) + fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n"); +#endif + /* I think the following can happen. */ +#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K) + fprintf(STDERR, " NOTE: libpng compiled for max 64k, zlib not\n"); +#endif + + if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING)) + { + fprintf(STDERR, + "Warning: versions are different between png.h and png.c\n"); + fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING); + fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver); + ++ierror; + } + + if (argc > 1) + { + if (strcmp(argv[1], "-m") == 0) + { + multiple = 1; + status_dots_requested = 0; + } + else if (strcmp(argv[1], "-mv") == 0 || + strcmp(argv[1], "-vm") == 0 ) + { + multiple = 1; + verbose = 1; + status_dots_requested = 1; + } + else if (strcmp(argv[1], "-v") == 0) + { + verbose = 1; + status_dots_requested = 1; + inname = argv[2]; + } + else + { + inname = argv[1]; + status_dots_requested = 0; + } + } + + if (!multiple && argc == 3+verbose) + outname = argv[2+verbose]; + + if ((!multiple && argc > 3+verbose) || (multiple && argc < 2)) + { + fprintf(STDERR, + "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n", + argv[0], argv[0]); + fprintf(STDERR, + " reads/writes one PNG file (without -m) or multiple files (-m)\n"); + fprintf(STDERR, + " with -m %s is used as a temporary file\n", outname); + exit(1); + } + + if (multiple) + { + int i; +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + int allocation_now = current_allocation; +#endif + for (i=2; isize, + (unsigned int) pinfo->pointer); + pinfo = pinfo->next; + } + } +#endif + } +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + fprintf(STDERR, " Current memory allocation: %10d bytes\n", + current_allocation); + fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", + maximum_allocation); + fprintf(STDERR, " Total memory allocation: %10d bytes\n", + total_allocation); + fprintf(STDERR, " Number of allocations: %10d\n", + num_allocations); +#endif + } + else + { + int i; + for (i=0; i<3; ++i) + { + int kerror; +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + int allocation_now = current_allocation; +#endif + if (i == 1) status_dots_requested = 1; + else if(verbose == 0)status_dots_requested = 0; + if (i == 0 || verbose == 1 || ierror != 0) + fprintf(STDERR, "Testing %s:",inname); + kerror = test_one_file(inname, outname); + if(kerror == 0) + { + if(verbose == 1 || i == 2) + { +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + int k; +#endif +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + fprintf(STDERR, "\n PASS (%lu zero samples)\n", + (unsigned long)zero_samples); +#else + fprintf(STDERR, " PASS\n"); +#endif +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + for (k=0; k<256; k++) + if(filters_used[k]) + fprintf(STDERR, " Filter %d was used %lu times\n", + k,(unsigned long)filters_used[k]); +#endif +#if defined(PNG_TIME_RFC1123_SUPPORTED) + if(tIME_chunk_present != 0) + fprintf(STDERR, " tIME = %s\n",tIME_string); +#endif /* PNG_TIME_RFC1123_SUPPORTED */ + } + } + else + { + if(verbose == 0 && i != 2) + fprintf(STDERR, "Testing %s:",inname); + fprintf(STDERR, " FAIL\n"); + ierror += kerror; + } +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + if (allocation_now != current_allocation) + fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", + current_allocation-allocation_now); + if (current_allocation != 0) + { + memory_infop pinfo = pinformation; + + fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n", + current_allocation); + while (pinfo != NULL) + { + fprintf(STDERR," %lu bytes at %x\n", + (unsigned long)pinfo->size, (unsigned int)pinfo->pointer); + pinfo = pinfo->next; + } + } +#endif + } +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + fprintf(STDERR, " Current memory allocation: %10d bytes\n", + current_allocation); + fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", + maximum_allocation); + fprintf(STDERR, " Total memory allocation: %10d bytes\n", + total_allocation); + fprintf(STDERR, " Number of allocations: %10d\n", + num_allocations); +#endif + } + +#ifdef PNGTEST_TIMING + t_stop = (float)clock(); + t_misc += (t_stop - t_start); + t_start = t_stop; + fprintf(STDERR," CPU time used = %.3f seconds", + (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC); + fprintf(STDERR," (decoding %.3f,\n", + t_decode/(float)CLOCKS_PER_SEC); + fprintf(STDERR," encoding %.3f ,", + t_encode/(float)CLOCKS_PER_SEC); + fprintf(STDERR," other %.3f seconds)\n\n", + t_misc/(float)CLOCKS_PER_SEC); +#endif + + if (ierror == 0) + fprintf(STDERR, "libpng passes test\n"); + else + fprintf(STDERR, "libpng FAILS test\n"); + return (int)(ierror != 0); +} + +/* Generate a compiler error if there is an old png.h in the search path. */ +typedef version_1_2_16 your_png_h_is_not_version_1_2_16; diff --git a/src/dep/src/irrlicht/libpng/pngtrans.c b/src/dep/src/irrlicht/libpng/pngtrans.c index b997003..25f42c8 100644 --- a/src/dep/src/irrlicht/libpng/pngtrans.c +++ b/src/dep/src/irrlicht/libpng/pngtrans.c @@ -1,661 +1,661 @@ - -/* pngtrans.c - transforms the data in a row (used by both readers and writers) - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* turn on BGR-to-RGB mapping */ -void PNGAPI -png_set_bgr(png_structp png_ptr) -{ - png_debug(1, "in png_set_bgr\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_BGR; -} -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* turn on 16 bit byte swapping */ -void PNGAPI -png_set_swap(png_structp png_ptr) -{ - png_debug(1, "in png_set_swap\n"); - if(png_ptr == NULL) return; - if (png_ptr->bit_depth == 16) - png_ptr->transformations |= PNG_SWAP_BYTES; -} -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* turn on pixel packing */ -void PNGAPI -png_set_packing(png_structp png_ptr) -{ - png_debug(1, "in png_set_packing\n"); - if(png_ptr == NULL) return; - if (png_ptr->bit_depth < 8) - { - png_ptr->transformations |= PNG_PACK; - png_ptr->usr_bit_depth = 8; - } -} -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* turn on packed pixel swapping */ -void PNGAPI -png_set_packswap(png_structp png_ptr) -{ - png_debug(1, "in png_set_packswap\n"); - if(png_ptr == NULL) return; - if (png_ptr->bit_depth < 8) - png_ptr->transformations |= PNG_PACKSWAP; -} -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -void PNGAPI -png_set_shift(png_structp png_ptr, png_color_8p true_bits) -{ - png_debug(1, "in png_set_shift\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_SHIFT; - png_ptr->shift = *true_bits; -} -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -int PNGAPI -png_set_interlace_handling(png_structp png_ptr) -{ - png_debug(1, "in png_set_interlace handling\n"); - if (png_ptr && png_ptr->interlaced) - { - png_ptr->transformations |= PNG_INTERLACE; - return (7); - } - - return (1); -} -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte on read, or remove a filler or alpha byte on write. - * The filler type has changed in v0.95 to allow future 2-byte fillers - * for 48-bit input data, as well as to avoid problems with some compilers - * that don't like bytes as parameters. - */ -void PNGAPI -png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) -{ - png_debug(1, "in png_set_filler\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_FILLER; - png_ptr->filler = (png_byte)filler; - if (filler_loc == PNG_FILLER_AFTER) - png_ptr->flags |= PNG_FLAG_FILLER_AFTER; - else - png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; - - /* This should probably go in the "do_read_filler" routine. - * I attempted to do that in libpng-1.0.1a but that caused problems - * so I restored it in libpng-1.0.2a - */ - - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - png_ptr->usr_channels = 4; - } - - /* Also I added this in libpng-1.0.2a (what happens when we expand - * a less-than-8-bit grayscale to GA? */ - - if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8) - { - png_ptr->usr_channels = 2; - } -} - -#if !defined(PNG_1_0_X) -/* Added to libpng-1.2.7 */ -void PNGAPI -png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) -{ - png_debug(1, "in png_set_add_alpha\n"); - if(png_ptr == NULL) return; - png_set_filler(png_ptr, filler, filler_loc); - png_ptr->transformations |= PNG_ADD_ALPHA; -} -#endif - -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -void PNGAPI -png_set_swap_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_swap_alpha\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_SWAP_ALPHA; -} -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -void PNGAPI -png_set_invert_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_invert_alpha\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_INVERT_ALPHA; -} -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -void PNGAPI -png_set_invert_mono(png_structp png_ptr) -{ - png_debug(1, "in png_set_invert_mono\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_INVERT_MONO; -} - -/* invert monochrome grayscale data */ -void /* PRIVATE */ -png_do_invert(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_invert\n"); - /* This test removed from libpng version 1.0.13 and 1.2.0: - * if (row_info->bit_depth == 1 && - */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row == NULL || row_info == NULL) - return; -#endif - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(~(*rp)); - rp++; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - row_info->bit_depth == 8) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (i = 0; i < istop; i+=2) - { - *rp = (png_byte)(~(*rp)); - rp+=2; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - row_info->bit_depth == 16) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (i = 0; i < istop; i+=4) - { - *rp = (png_byte)(~(*rp)); - *(rp+1) = (png_byte)(~(*(rp+1))); - rp+=4; - } - } -} -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* swaps byte order on 16 bit depth images */ -void /* PRIVATE */ -png_do_swap(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_swap\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->bit_depth == 16) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop= row_info->width * row_info->channels; - - for (i = 0; i < istop; i++, rp += 2) - { - png_byte t = *rp; - *rp = *(rp + 1); - *(rp + 1) = t; - } - } -} -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -static PNG_CONST png_byte onebppswaptable[256] = { - 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, - 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, - 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, - 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, - 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, - 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, - 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, - 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, - 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, - 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, - 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, - 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, - 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, - 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, - 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, - 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, - 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, - 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, - 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, - 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, - 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, - 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, - 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, - 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, - 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, - 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, - 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, - 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, - 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, - 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, - 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, - 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF -}; - -static PNG_CONST png_byte twobppswaptable[256] = { - 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0, - 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0, - 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4, - 0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4, - 0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8, - 0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8, - 0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC, - 0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC, - 0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1, - 0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1, - 0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5, - 0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5, - 0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9, - 0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9, - 0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD, - 0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD, - 0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2, - 0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2, - 0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6, - 0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6, - 0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA, - 0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA, - 0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE, - 0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE, - 0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3, - 0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3, - 0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7, - 0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7, - 0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB, - 0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB, - 0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF, - 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF -}; - -static PNG_CONST png_byte fourbppswaptable[256] = { - 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, - 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, - 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, - 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1, - 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, - 0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2, - 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73, - 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3, - 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74, - 0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4, - 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, - 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5, - 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76, - 0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6, - 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, - 0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7, - 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78, - 0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8, - 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79, - 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9, - 0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A, - 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA, - 0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, - 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB, - 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, - 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC, - 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D, - 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD, - 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E, - 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, - 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, - 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF -}; - -/* swaps pixel packing order within bytes */ -void /* PRIVATE */ -png_do_packswap(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_packswap\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->bit_depth < 8) - { - png_bytep rp, end, table; - - end = row + row_info->rowbytes; - - if (row_info->bit_depth == 1) - table = (png_bytep)onebppswaptable; - else if (row_info->bit_depth == 2) - table = (png_bytep)twobppswaptable; - else if (row_info->bit_depth == 4) - table = (png_bytep)fourbppswaptable; - else - return; - - for (rp = row; rp < end; rp++) - *rp = table[*rp]; - } -} -#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */ - -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -/* remove filler or alpha byte(s) */ -void /* PRIVATE */ -png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) -{ - png_debug(1, "in png_do_strip_filler\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - png_bytep sp=row; - png_bytep dp=row; - png_uint_32 row_width=row_info->width; - png_uint_32 i; - - if ((row_info->color_type == PNG_COLOR_TYPE_RGB || - (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - (flags & PNG_FLAG_STRIP_ALPHA))) && - row_info->channels == 4) - { - if (row_info->bit_depth == 8) - { - /* This converts from RGBX or RGBA to RGB */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - dp+=3; sp+=4; - for (i = 1; i < row_width; i++) - { - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - sp++; - } - } - /* This converts from XRGB or ARGB to RGB */ - else - { - for (i = 0; i < row_width; i++) - { - sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 24; - row_info->rowbytes = row_width * 3; - } - else /* if (row_info->bit_depth == 16) */ - { - if (flags & PNG_FLAG_FILLER_AFTER) - { - /* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */ - sp += 8; dp += 6; - for (i = 1; i < row_width; i++) - { - /* This could be (although png_memcpy is probably slower): - png_memcpy(dp, sp, 6); - sp += 8; - dp += 6; - */ - - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - sp += 2; - } - } - else - { - /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */ - for (i = 0; i < row_width; i++) - { - /* This could be (although png_memcpy is probably slower): - png_memcpy(dp, sp, 6); - sp += 8; - dp += 6; - */ - - sp+=2; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 48; - row_info->rowbytes = row_width * 6; - } - row_info->channels = 3; - } - else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY || - (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - (flags & PNG_FLAG_STRIP_ALPHA))) && - row_info->channels == 2) - { - if (row_info->bit_depth == 8) - { - /* This converts from GX or GA to G */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - for (i = 0; i < row_width; i++) - { - *dp++ = *sp++; - sp++; - } - } - /* This converts from XG or AG to G */ - else - { - for (i = 0; i < row_width; i++) - { - sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - else /* if (row_info->bit_depth == 16) */ - { - if (flags & PNG_FLAG_FILLER_AFTER) - { - /* This converts from GGXX or GGAA to GG */ - sp += 4; dp += 2; - for (i = 1; i < row_width; i++) - { - *dp++ = *sp++; - *dp++ = *sp++; - sp += 2; - } - } - else - { - /* This converts from XXGG or AAGG to GG */ - for (i = 0; i < row_width; i++) - { - sp += 2; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - row_info->channels = 1; - } - if (flags & PNG_FLAG_STRIP_ALPHA) - row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; - } -} -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* swaps red and blue bytes within a pixel */ -void /* PRIVATE */ -png_do_bgr(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_bgr\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 3) - { - png_byte save = *rp; - *rp = *(rp + 2); - *(rp + 2) = save; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 4) - { - png_byte save = *rp; - *rp = *(rp + 2); - *(rp + 2) = save; - } - } - } - else if (row_info->bit_depth == 16) - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 6) - { - png_byte save = *rp; - *rp = *(rp + 4); - *(rp + 4) = save; - save = *(rp + 1); - *(rp + 1) = *(rp + 5); - *(rp + 5) = save; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 8) - { - png_byte save = *rp; - *rp = *(rp + 4); - *(rp + 4) = save; - save = *(rp + 1); - *(rp + 1) = *(rp + 5); - *(rp + 5) = save; - } - } - } - } -} -#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -void PNGAPI -png_set_user_transform_info(png_structp png_ptr, png_voidp - user_transform_ptr, int user_transform_depth, int user_transform_channels) -{ - png_debug(1, "in png_set_user_transform_info\n"); - if(png_ptr == NULL) return; -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - png_ptr->user_transform_ptr = user_transform_ptr; - png_ptr->user_transform_depth = (png_byte)user_transform_depth; - png_ptr->user_transform_channels = (png_byte)user_transform_channels; -#else - if(user_transform_ptr || user_transform_depth || user_transform_channels) - png_warning(png_ptr, - "This version of libpng does not support user transform info"); -#endif -} -#endif - -/* This function returns a pointer to the user_transform_ptr associated with - * the user transform functions. The application should free any memory - * associated with this pointer before png_write_destroy and png_read_destroy - * are called. - */ -png_voidp PNGAPI -png_get_user_transform_ptr(png_structp png_ptr) -{ - if (png_ptr == NULL) return (NULL); -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - return ((png_voidp)png_ptr->user_transform_ptr); -#endif - return (NULL); -} -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ + +/* pngtrans.c - transforms the data in a row (used by both readers and writers) + * + * Last changed in libpng 1.2.13 November 13, 2006 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +/* turn on BGR-to-RGB mapping */ +void PNGAPI +png_set_bgr(png_structp png_ptr) +{ + png_debug(1, "in png_set_bgr\n"); + if(png_ptr == NULL) return; + png_ptr->transformations |= PNG_BGR; +} +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +/* turn on 16 bit byte swapping */ +void PNGAPI +png_set_swap(png_structp png_ptr) +{ + png_debug(1, "in png_set_swap\n"); + if(png_ptr == NULL) return; + if (png_ptr->bit_depth == 16) + png_ptr->transformations |= PNG_SWAP_BYTES; +} +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) +/* turn on pixel packing */ +void PNGAPI +png_set_packing(png_structp png_ptr) +{ + png_debug(1, "in png_set_packing\n"); + if(png_ptr == NULL) return; + if (png_ptr->bit_depth < 8) + { + png_ptr->transformations |= PNG_PACK; + png_ptr->usr_bit_depth = 8; + } +} +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) +/* turn on packed pixel swapping */ +void PNGAPI +png_set_packswap(png_structp png_ptr) +{ + png_debug(1, "in png_set_packswap\n"); + if(png_ptr == NULL) return; + if (png_ptr->bit_depth < 8) + png_ptr->transformations |= PNG_PACKSWAP; +} +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) +void PNGAPI +png_set_shift(png_structp png_ptr, png_color_8p true_bits) +{ + png_debug(1, "in png_set_shift\n"); + if(png_ptr == NULL) return; + png_ptr->transformations |= PNG_SHIFT; + png_ptr->shift = *true_bits; +} +#endif + +#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ + defined(PNG_WRITE_INTERLACING_SUPPORTED) +int PNGAPI +png_set_interlace_handling(png_structp png_ptr) +{ + png_debug(1, "in png_set_interlace handling\n"); + if (png_ptr && png_ptr->interlaced) + { + png_ptr->transformations |= PNG_INTERLACE; + return (7); + } + + return (1); +} +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +/* Add a filler byte on read, or remove a filler or alpha byte on write. + * The filler type has changed in v0.95 to allow future 2-byte fillers + * for 48-bit input data, as well as to avoid problems with some compilers + * that don't like bytes as parameters. + */ +void PNGAPI +png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) +{ + png_debug(1, "in png_set_filler\n"); + if(png_ptr == NULL) return; + png_ptr->transformations |= PNG_FILLER; + png_ptr->filler = (png_byte)filler; + if (filler_loc == PNG_FILLER_AFTER) + png_ptr->flags |= PNG_FLAG_FILLER_AFTER; + else + png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; + + /* This should probably go in the "do_read_filler" routine. + * I attempted to do that in libpng-1.0.1a but that caused problems + * so I restored it in libpng-1.0.2a + */ + + if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) + { + png_ptr->usr_channels = 4; + } + + /* Also I added this in libpng-1.0.2a (what happens when we expand + * a less-than-8-bit grayscale to GA? */ + + if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8) + { + png_ptr->usr_channels = 2; + } +} + +#if !defined(PNG_1_0_X) +/* Added to libpng-1.2.7 */ +void PNGAPI +png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) +{ + png_debug(1, "in png_set_add_alpha\n"); + if(png_ptr == NULL) return; + png_set_filler(png_ptr, filler, filler_loc); + png_ptr->transformations |= PNG_ADD_ALPHA; +} +#endif + +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +void PNGAPI +png_set_swap_alpha(png_structp png_ptr) +{ + png_debug(1, "in png_set_swap_alpha\n"); + if(png_ptr == NULL) return; + png_ptr->transformations |= PNG_SWAP_ALPHA; +} +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +void PNGAPI +png_set_invert_alpha(png_structp png_ptr) +{ + png_debug(1, "in png_set_invert_alpha\n"); + if(png_ptr == NULL) return; + png_ptr->transformations |= PNG_INVERT_ALPHA; +} +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +void PNGAPI +png_set_invert_mono(png_structp png_ptr) +{ + png_debug(1, "in png_set_invert_mono\n"); + if(png_ptr == NULL) return; + png_ptr->transformations |= PNG_INVERT_MONO; +} + +/* invert monochrome grayscale data */ +void /* PRIVATE */ +png_do_invert(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_invert\n"); + /* This test removed from libpng version 1.0.13 and 1.2.0: + * if (row_info->bit_depth == 1 && + */ +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row == NULL || row_info == NULL) + return; +#endif + if (row_info->color_type == PNG_COLOR_TYPE_GRAY) + { + png_bytep rp = row; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(~(*rp)); + rp++; + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && + row_info->bit_depth == 8) + { + png_bytep rp = row; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + + for (i = 0; i < istop; i+=2) + { + *rp = (png_byte)(~(*rp)); + rp+=2; + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && + row_info->bit_depth == 16) + { + png_bytep rp = row; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + + for (i = 0; i < istop; i+=4) + { + *rp = (png_byte)(~(*rp)); + *(rp+1) = (png_byte)(~(*(rp+1))); + rp+=4; + } + } +} +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +/* swaps byte order on 16 bit depth images */ +void /* PRIVATE */ +png_do_swap(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_swap\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + row_info->bit_depth == 16) + { + png_bytep rp = row; + png_uint_32 i; + png_uint_32 istop= row_info->width * row_info->channels; + + for (i = 0; i < istop; i++, rp += 2) + { + png_byte t = *rp; + *rp = *(rp + 1); + *(rp + 1) = t; + } + } +} +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) +static PNG_CONST png_byte onebppswaptable[256] = { + 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, + 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, + 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, + 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, + 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, + 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, + 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, + 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, + 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, + 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, + 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, + 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, + 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, + 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, + 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, + 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, + 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, + 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, + 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, + 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, + 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, + 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, + 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, + 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, + 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, + 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, + 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, + 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, + 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, + 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, + 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, + 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF +}; + +static PNG_CONST png_byte twobppswaptable[256] = { + 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0, + 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0, + 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4, + 0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4, + 0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8, + 0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8, + 0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC, + 0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC, + 0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1, + 0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1, + 0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5, + 0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5, + 0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9, + 0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9, + 0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD, + 0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD, + 0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2, + 0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2, + 0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6, + 0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6, + 0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA, + 0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA, + 0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE, + 0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE, + 0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3, + 0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3, + 0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7, + 0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7, + 0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB, + 0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB, + 0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF, + 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF +}; + +static PNG_CONST png_byte fourbppswaptable[256] = { + 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, + 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, + 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, + 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1, + 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, + 0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2, + 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73, + 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3, + 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74, + 0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4, + 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, + 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5, + 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76, + 0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6, + 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, + 0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7, + 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78, + 0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8, + 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79, + 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9, + 0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A, + 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA, + 0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, + 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB, + 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, + 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC, + 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D, + 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD, + 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E, + 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, + 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, + 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF +}; + +/* swaps pixel packing order within bytes */ +void /* PRIVATE */ +png_do_packswap(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_packswap\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + row_info->bit_depth < 8) + { + png_bytep rp, end, table; + + end = row + row_info->rowbytes; + + if (row_info->bit_depth == 1) + table = (png_bytep)onebppswaptable; + else if (row_info->bit_depth == 2) + table = (png_bytep)twobppswaptable; + else if (row_info->bit_depth == 4) + table = (png_bytep)fourbppswaptable; + else + return; + + for (rp = row; rp < end; rp++) + *rp = table[*rp]; + } +} +#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */ + +#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ + defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +/* remove filler or alpha byte(s) */ +void /* PRIVATE */ +png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) +{ + png_debug(1, "in png_do_strip_filler\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif + { + png_bytep sp=row; + png_bytep dp=row; + png_uint_32 row_width=row_info->width; + png_uint_32 i; + + if ((row_info->color_type == PNG_COLOR_TYPE_RGB || + (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && + (flags & PNG_FLAG_STRIP_ALPHA))) && + row_info->channels == 4) + { + if (row_info->bit_depth == 8) + { + /* This converts from RGBX or RGBA to RGB */ + if (flags & PNG_FLAG_FILLER_AFTER) + { + dp+=3; sp+=4; + for (i = 1; i < row_width; i++) + { + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + sp++; + } + } + /* This converts from XRGB or ARGB to RGB */ + else + { + for (i = 0; i < row_width; i++) + { + sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + } + } + row_info->pixel_depth = 24; + row_info->rowbytes = row_width * 3; + } + else /* if (row_info->bit_depth == 16) */ + { + if (flags & PNG_FLAG_FILLER_AFTER) + { + /* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */ + sp += 8; dp += 6; + for (i = 1; i < row_width; i++) + { + /* This could be (although png_memcpy is probably slower): + png_memcpy(dp, sp, 6); + sp += 8; + dp += 6; + */ + + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + sp += 2; + } + } + else + { + /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */ + for (i = 0; i < row_width; i++) + { + /* This could be (although png_memcpy is probably slower): + png_memcpy(dp, sp, 6); + sp += 8; + dp += 6; + */ + + sp+=2; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + } + } + row_info->pixel_depth = 48; + row_info->rowbytes = row_width * 6; + } + row_info->channels = 3; + } + else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY || + (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && + (flags & PNG_FLAG_STRIP_ALPHA))) && + row_info->channels == 2) + { + if (row_info->bit_depth == 8) + { + /* This converts from GX or GA to G */ + if (flags & PNG_FLAG_FILLER_AFTER) + { + for (i = 0; i < row_width; i++) + { + *dp++ = *sp++; + sp++; + } + } + /* This converts from XG or AG to G */ + else + { + for (i = 0; i < row_width; i++) + { + sp++; + *dp++ = *sp++; + } + } + row_info->pixel_depth = 8; + row_info->rowbytes = row_width; + } + else /* if (row_info->bit_depth == 16) */ + { + if (flags & PNG_FLAG_FILLER_AFTER) + { + /* This converts from GGXX or GGAA to GG */ + sp += 4; dp += 2; + for (i = 1; i < row_width; i++) + { + *dp++ = *sp++; + *dp++ = *sp++; + sp += 2; + } + } + else + { + /* This converts from XXGG or AAGG to GG */ + for (i = 0; i < row_width; i++) + { + sp += 2; + *dp++ = *sp++; + *dp++ = *sp++; + } + } + row_info->pixel_depth = 16; + row_info->rowbytes = row_width * 2; + } + row_info->channels = 1; + } + if (flags & PNG_FLAG_STRIP_ALPHA) + row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; + } +} +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +/* swaps red and blue bytes within a pixel */ +void /* PRIVATE */ +png_do_bgr(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_bgr\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + (row_info->color_type & PNG_COLOR_MASK_COLOR)) + { + png_uint_32 row_width = row_info->width; + if (row_info->bit_depth == 8) + { + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + { + png_bytep rp; + png_uint_32 i; + + for (i = 0, rp = row; i < row_width; i++, rp += 3) + { + png_byte save = *rp; + *rp = *(rp + 2); + *(rp + 2) = save; + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + png_bytep rp; + png_uint_32 i; + + for (i = 0, rp = row; i < row_width; i++, rp += 4) + { + png_byte save = *rp; + *rp = *(rp + 2); + *(rp + 2) = save; + } + } + } + else if (row_info->bit_depth == 16) + { + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + { + png_bytep rp; + png_uint_32 i; + + for (i = 0, rp = row; i < row_width; i++, rp += 6) + { + png_byte save = *rp; + *rp = *(rp + 4); + *(rp + 4) = save; + save = *(rp + 1); + *(rp + 1) = *(rp + 5); + *(rp + 5) = save; + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + png_bytep rp; + png_uint_32 i; + + for (i = 0, rp = row; i < row_width; i++, rp += 8) + { + png_byte save = *rp; + *rp = *(rp + 4); + *(rp + 4) = save; + save = *(rp + 1); + *(rp + 1) = *(rp + 5); + *(rp + 5) = save; + } + } + } + } +} +#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +void PNGAPI +png_set_user_transform_info(png_structp png_ptr, png_voidp + user_transform_ptr, int user_transform_depth, int user_transform_channels) +{ + png_debug(1, "in png_set_user_transform_info\n"); + if(png_ptr == NULL) return; +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) + png_ptr->user_transform_ptr = user_transform_ptr; + png_ptr->user_transform_depth = (png_byte)user_transform_depth; + png_ptr->user_transform_channels = (png_byte)user_transform_channels; +#else + if(user_transform_ptr || user_transform_depth || user_transform_channels) + png_warning(png_ptr, + "This version of libpng does not support user transform info"); +#endif +} +#endif + +/* This function returns a pointer to the user_transform_ptr associated with + * the user transform functions. The application should free any memory + * associated with this pointer before png_write_destroy and png_read_destroy + * are called. + */ +png_voidp PNGAPI +png_get_user_transform_ptr(png_structp png_ptr) +{ + if (png_ptr == NULL) return (NULL); +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) + return ((png_voidp)png_ptr->user_transform_ptr); +#endif + return (NULL); +} +#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/pngvcrd.c b/src/dep/src/irrlicht/libpng/pngvcrd.c index 7bb6280..d1c6405 100644 --- a/src/dep/src/irrlicht/libpng/pngvcrd.c +++ b/src/dep/src/irrlicht/libpng/pngvcrd.c @@ -1,3904 +1,3904 @@ - -/* pngvcrd.c - mixed C/assembler version of utilities to read a PNG file - * - * For Intel x86 CPU and Microsoft Visual C++ compiler - * - * Last changed in libpng 1.2.6 - August 15, 2004 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2004 Glenn Randers-Pehrson - * Copyright (c) 1998, Intel Corporation - * - * Contributed by Nirav Chhatrapati, Intel Corporation, 1998 - * Interface to libpng contributed by Gilles Vollant, 1999 - * - * - * In png_do_read_interlace() in libpng versions 1.0.3a through 1.0.4d, - * a sign error in the post-MMX cleanup code for each pixel_depth resulted - * in bad pixels at the beginning of some rows of some images, and also - * (due to out-of-range memory reads and writes) caused heap corruption - * when compiled with MSVC 6.0. The error was fixed in version 1.0.4e. - * - * [png_read_filter_row_mmx_avg() bpp == 2 bugfix, GRR 20000916] - * - * [runtime MMX configuration, GRR 20010102] - * - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD) - -static int mmx_supported=2; - - -int PNGAPI -png_mmx_support(void) -{ - int mmx_supported_local = 0; - _asm { - push ebx //CPUID will trash these - push ecx - push edx - - pushfd //Save Eflag to stack - pop eax //Get Eflag from stack into eax - mov ecx, eax //Make another copy of Eflag in ecx - xor eax, 0x200000 //Toggle ID bit in Eflag [i.e. bit(21)] - push eax //Save modified Eflag back to stack - - popfd //Restored modified value back to Eflag reg - pushfd //Save Eflag to stack - pop eax //Get Eflag from stack - push ecx // save original Eflag to stack - popfd // restore original Eflag - xor eax, ecx //Compare the new Eflag with the original Eflag - jz NOT_SUPPORTED //If the same, CPUID instruction is not supported, - //skip following instructions and jump to - //NOT_SUPPORTED label - - xor eax, eax //Set eax to zero - - _asm _emit 0x0f //CPUID instruction (two bytes opcode) - _asm _emit 0xa2 - - cmp eax, 1 //make sure eax return non-zero value - jl NOT_SUPPORTED //If eax is zero, mmx not supported - - xor eax, eax //set eax to zero - inc eax //Now increment eax to 1. This instruction is - //faster than the instruction "mov eax, 1" - - _asm _emit 0x0f //CPUID instruction - _asm _emit 0xa2 - - and edx, 0x00800000 //mask out all bits but mmx bit(24) - cmp edx, 0 // 0 = mmx not supported - jz NOT_SUPPORTED // non-zero = Yes, mmx IS supported - - mov mmx_supported_local, 1 //set return value to 1 - -NOT_SUPPORTED: - mov eax, mmx_supported_local //move return value to eax - pop edx //CPUID trashed these - pop ecx - pop ebx - } - - //mmx_supported_local=0; // test code for force don't support MMX - //printf("MMX : %u (1=MMX supported)\n",mmx_supported_local); - - mmx_supported = mmx_supported_local; - return mmx_supported_local; -} - -/* Combines the row recently read in with the previous row. - This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined; a - zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. If - you want all pixels to be combined, pass 0xff (255) in mask. */ - -/* Use this routine for x86 platform - uses faster MMX routine if machine - supports MMX */ - -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_combine_row_asm\n"); - - if (mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } - - if (mask == 0xff) - { - png_memcpy(row, png_ptr->row_buf + 1, - (png_size_t)PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->width)); - } - /* GRR: add "else if (mask == 0)" case? - * or does png_combine_row() not even get called in that case? */ - else - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: - { - png_bytep sp; - png_bytep dp; - int s_inc, s_start, s_end; - int m; - int shift; - png_uint_32 i; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x1; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 2: - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x3; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 4: - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 8: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int m; - int diff, unmask; - - __int64 mask0=0x0102040810204080; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - m = 0x80; - unmask = ~mask; - len = png_ptr->width &~7; //reduce to multiple of 8 - diff = png_ptr->width & 7; //amount lost - - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - - pand mm0,mm7 //nonzero if keep byte - pcmpeqb mm0,mm6 //zeros->1s, v versa - - mov ecx,len //load length of line (pixels) - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 //lcr - je mainloop8end - -mainloop8: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - pandn mm6,[ebx] - por mm4,mm6 - movq [ebx],mm4 - - add esi,8 //inc by 8 bytes processed - add ebx,8 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop8 -mainloop8end: - - mov ecx,diff - cmp ecx,0 - jz end8 - - mov edx,mask - sal edx,24 //make low byte the high byte - -secondloop8: - sal edx,1 //move high bit to CF - jnc skip8 //if CF = 0 - mov al,[esi] - mov [ebx],al -skip8: - inc esi - inc ebx - - dec ecx - jnz secondloop8 -end8: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 8 bpp - - case 16: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - __int64 mask1=0x0101020204040808, - mask0=0x1010202040408080; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - - pand mm0,mm7 - pand mm1,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 //lcr - jz mainloop16end - -mainloop16: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - add esi,16 //inc by 16 bytes processed - add ebx,16 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop16 - -mainloop16end: - mov ecx,diff - cmp ecx,0 - jz end16 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop16: - sal edx,1 //move high bit to CF - jnc skip16 //if CF = 0 - mov ax,[esi] - mov [ebx],ax -skip16: - add esi,2 - add ebx,2 - - dec ecx - jnz secondloop16 -end16: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 16 bpp - - case 24: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask2=0x0101010202020404, //24bpp - mask1=0x0408080810101020, - mask0=0x2020404040808080; - - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 - jz mainloop24end - -mainloop24: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm4,mm2 - movq mm7,[ebx+16] - pandn mm4,mm7 - por mm6,mm4 - movq [ebx+16],mm6 - - add esi,24 //inc by 24 bytes processed - add ebx,24 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop24 - -mainloop24end: - mov ecx,diff - cmp ecx,0 - jz end24 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop24: - sal edx,1 //move high bit to CF - jnc skip24 //if CF = 0 - mov ax,[esi] - mov [ebx],ax - xor eax,eax - mov al,[esi+2] - mov [ebx+2],al -skip24: - add esi,3 - add ebx,3 - - dec ecx - jnz secondloop24 - -end24: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 24 bpp - - case 32: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask3=0x0101010102020202, //32bpp - mask2=0x0404040408080808, - mask1=0x1010101020202020, - mask0=0x4040404080808080; - - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - movq mm3,mask3 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - pand mm3,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - pcmpeqb mm3,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - - cmp ecx,0 //lcr - jz mainloop32end - -mainloop32: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm4,mm2 - movq mm7,[ebx+16] - pandn mm4,mm7 - por mm6,mm4 - movq [ebx+16],mm6 - - movq mm7,[esi+24] - pand mm7,mm3 - movq mm5,mm3 - movq mm4,[ebx+24] - pandn mm5,mm4 - por mm7,mm5 - movq [ebx+24],mm7 - - add esi,32 //inc by 32 bytes processed - add ebx,32 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop32 - -mainloop32end: - mov ecx,diff - cmp ecx,0 - jz end32 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop32: - sal edx,1 //move high bit to CF - jnc skip32 //if CF = 0 - mov eax,[esi] - mov [ebx],eax -skip32: - add esi,4 - add ebx,4 - - dec ecx - jnz secondloop32 - -end32: - emms - } - } - else /* mmx _not supported - Use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 32 bpp - - case 48: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask5=0x0101010101010202, - mask4=0x0202020204040404, - mask3=0x0404080808080808, - mask2=0x1010101010102020, - mask1=0x2020202040404040, - mask0=0x4040808080808080; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - movq mm3,mask3 - movq mm4,mask4 - movq mm5,mask5 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - pand mm3,mm7 - pand mm4,mm7 - pand mm5,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - pcmpeqb mm3,mm6 - pcmpeqb mm4,mm6 - pcmpeqb mm5,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - - cmp ecx,0 - jz mainloop48end - -mainloop48: - movq mm7,[esi] - pand mm7,mm0 - movq mm6,mm0 - pandn mm6,[ebx] - por mm7,mm6 - movq [ebx],mm7 - - movq mm6,[esi+8] - pand mm6,mm1 - movq mm7,mm1 - pandn mm7,[ebx+8] - por mm6,mm7 - movq [ebx+8],mm6 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm7,mm2 - pandn mm7,[ebx+16] - por mm6,mm7 - movq [ebx+16],mm6 - - movq mm7,[esi+24] - pand mm7,mm3 - movq mm6,mm3 - pandn mm6,[ebx+24] - por mm7,mm6 - movq [ebx+24],mm7 - - movq mm6,[esi+32] - pand mm6,mm4 - movq mm7,mm4 - pandn mm7,[ebx+32] - por mm6,mm7 - movq [ebx+32],mm6 - - movq mm7,[esi+40] - pand mm7,mm5 - movq mm6,mm5 - pandn mm6,[ebx+40] - por mm7,mm6 - movq [ebx+40],mm7 - - add esi,48 //inc by 32 bytes processed - add ebx,48 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop48 -mainloop48end: - - mov ecx,diff - cmp ecx,0 - jz end48 - - mov edx,mask - sal edx,24 //make low byte the high byte - -secondloop48: - sal edx,1 //move high bit to CF - jnc skip48 //if CF = 0 - mov eax,[esi] - mov [ebx],eax -skip48: - add esi,4 - add ebx,4 - - dec ecx - jnz secondloop48 - -end48: - emms - } - } - else /* mmx _not supported - Use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 48 bpp - - default: - { - png_bytep sptr; - png_bytep dp; - png_size_t pixel_bytes; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - unsigned int i; - register int disp = png_pass_inc[png_ptr->pass]; // get the offset - register unsigned int incr1, initial_val, final_val; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - sptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dp = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dp, sptr, pixel_bytes); - sptr += incr1; - dp += incr1; - } - break; - } - } /* end switch (png_ptr->row_info.pixel_depth) */ - } /* end if (non-trivial mask) */ - -} /* end png_combine_row() */ - - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; - png_uint_32 transformations = png_ptr->transformations; -#ifdef PNG_USE_LOCAL_ARRAYS - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_do_read_interlace\n"); - - if (mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } - - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_byte v; - png_uint_32 i; - int j; - - sp = row + (png_size_t)((row_info->width - 1) >> 3); - dp = row + (png_size_t)((final_width - 1) >> 3); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 7); - dshift = (int)((final_width + 7) & 7); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 7); - dshift = 7 - (int)((final_width + 7) & 7); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = row_info->width; i; i--) - { - v = (png_byte)((*sp >> sshift) & 0x1); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 2: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 2); - dp = row + (png_size_t)((final_width - 1) >> 2); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); - dshift = (png_size_t)(((final_width + 3) & 3) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); - dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 4: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 1); - dp = row + (png_size_t)((final_width - 1) >> 1); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); - dshift = (png_size_t)(((final_width + 1) & 1) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); - dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0xf); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - default: // This is the place where the routine is modified - { - __int64 const4 = 0x0000000000FFFFFF; - // __int64 const5 = 0x000000FFFFFF0000; // unused... - __int64 const6 = 0x00000000000000FF; - png_bytep sptr, dp; - png_uint_32 i; - png_size_t pixel_bytes; - int width = row_info->width; - - pixel_bytes = (row_info->pixel_depth >> 3); - - sptr = row + (width - 1) * pixel_bytes; - dp = row + (final_width - 1) * pixel_bytes; - // New code by Nirav Chhatrapati - Intel Corporation - // sign fix by GRR - // NOTE: there is NO MMX code for 48-bit and 64-bit images - - // use MMX routine if machine supports it -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - if (pixel_bytes == 3) - { - if (((pass == 0) || (pass == 1)) && width) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width - sub edi, 21 // (png_pass_inc[pass] - 1)*pixel_bytes -loop_pass0: - movd mm0, [esi] ; X X X X X v2 v1 v0 - pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 - movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 - psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 - movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 - psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 - psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 - por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 - por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 - movq mm3, mm0 ; v2 v1 v0 v2 v1 v0 v2 v1 - psllq mm0, 16 ; v0 v2 v1 v0 v2 v1 0 0 - movq mm4, mm3 ; v2 v1 v0 v2 v1 v0 v2 v1 - punpckhdq mm3, mm0 ; v0 v2 v1 v0 v2 v1 v0 v2 - movq [edi+16] , mm4 - psrlq mm0, 32 ; 0 0 0 0 v0 v2 v1 v0 - movq [edi+8] , mm3 - punpckldq mm0, mm4 ; v1 v0 v2 v1 v0 v2 v1 v0 - sub esi, 3 - movq [edi], mm0 - sub edi, 24 - //sub esi, 3 - dec ecx - jnz loop_pass0 - EMMS - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width - sub edi, 9 // (png_pass_inc[pass] - 1)*pixel_bytes -loop_pass2: - movd mm0, [esi] ; X X X X X v2 v1 v0 - pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 - movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 - psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 - movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 - psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 - psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 - por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 - por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 - movq [edi+4], mm0 ; move to memory - psrlq mm0, 16 ; 0 0 v2 v1 v0 v2 v1 v0 - movd [edi], mm0 ; move to memory - sub esi, 3 - sub edi, 12 - dec ecx - jnz loop_pass2 - EMMS - } - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 1) << 1) - 8; - if (width_mmx < 0) - width_mmx = 0; - width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 3 - sub edi, 9 -loop_pass4: - movq mm0, [esi] ; X X v2 v1 v0 v5 v4 v3 - movq mm7, mm0 ; X X v2 v1 v0 v5 v4 v3 - movq mm6, mm0 ; X X v2 v1 v0 v5 v4 v3 - psllq mm0, 24 ; v1 v0 v5 v4 v3 0 0 0 - pand mm7, const4 ; 0 0 0 0 0 v5 v4 v3 - psrlq mm6, 24 ; 0 0 0 X X v2 v1 v0 - por mm0, mm7 ; v1 v0 v5 v4 v3 v5 v4 v3 - movq mm5, mm6 ; 0 0 0 X X v2 v1 v0 - psllq mm6, 8 ; 0 0 X X v2 v1 v0 0 - movq [edi], mm0 ; move quad to memory - psrlq mm5, 16 ; 0 0 0 0 0 X X v2 - pand mm5, const6 ; 0 0 0 0 0 0 0 v2 - por mm6, mm5 ; 0 0 X X v2 v1 v0 v2 - movd [edi+8], mm6 ; move double to memory - sub esi, 6 - sub edi, 12 - sub ecx, 2 - jnz loop_pass4 - EMMS - } - } - - sptr -= width_mmx*3; - dp -= width_mmx*6; - for (i = width; i; i--) - { - png_byte v[8]; - int j; - - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - } /* end of pixel_bytes == 3 */ - - else if (pixel_bytes == 1) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 31 - sub esi, 3 -loop1_pass0: - movd mm0, [esi] ; X X X X v0 v1 v2 v3 - movq mm1, mm0 ; X X X X v0 v1 v2 v3 - punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - movq mm2, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - movq mm3, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - punpckldq mm0, mm0 ; v3 v3 v3 v3 v3 v3 v3 v3 - punpckhdq mm3, mm3 ; v2 v2 v2 v2 v2 v2 v2 v2 - movq [edi], mm0 ; move to memory v3 - punpckhwd mm2, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 - movq [edi+8], mm3 ; move to memory v2 - movq mm4, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 - punpckldq mm2, mm2 ; v1 v1 v1 v1 v1 v1 v1 v1 - punpckhdq mm4, mm4 ; v0 v0 v0 v0 v0 v0 v0 v0 - movq [edi+16], mm2 ; move to memory v1 - movq [edi+24], mm4 ; move to memory v0 - sub esi, 4 - sub edi, 32 - sub ecx, 4 - jnz loop1_pass0 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*8; - for (i = width; i; i--) - { - int j; - - /* I simplified this part in version 1.0.4e - * here and in several other instances where - * pixel_bytes == 1 -- GR-P - * - * Original code: - * - * png_byte v[8]; - * png_memcpy(v, sptr, pixel_bytes); - * for (j = 0; j < png_pass_inc[pass]; j++) - * { - * png_memcpy(dp, v, pixel_bytes); - * dp -= pixel_bytes; - * } - * sptr -= pixel_bytes; - * - * Replacement code is in the next three lines: - */ - - for (j = 0; j < png_pass_inc[pass]; j++) - *dp-- = *sptr; - sptr--; - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 15 - sub esi, 3 -loop1_pass2: - movd mm0, [esi] ; X X X X v0 v1 v2 v3 - punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - punpckhwd mm1, mm1 ; v0 v0 v0 v0 v1 v1 v1 v1 - movq [edi], mm0 ; move to memory v2 and v3 - sub esi, 4 - movq [edi+8], mm1 ; move to memory v1 and v0 - sub edi, 16 - sub ecx, 4 - jnz loop1_pass2 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*4; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - sptr --; - } - } - else if (width) /* && ((pass == 4) || (pass == 5))) */ - { - int width_mmx = ((width >> 3) << 3); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 15 - sub esi, 7 -loop1_pass4: - movq mm0, [esi] ; v0 v1 v2 v3 v4 v5 v6 v7 - movq mm1, mm0 ; v0 v1 v2 v3 v4 v5 v6 v7 - punpcklbw mm0, mm0 ; v4 v4 v5 v5 v6 v6 v7 v7 - //movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpckhbw mm1, mm1 ;v0 v0 v1 v1 v2 v2 v3 v3 - movq [edi+8], mm1 ; move to memory v0 v1 v2 and v3 - sub esi, 8 - movq [edi], mm0 ; move to memory v4 v5 v6 and v7 - //sub esi, 4 - sub edi, 16 - sub ecx, 8 - jnz loop1_pass4 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*2; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - sptr --; - } - } - } /* end of pixel_bytes == 1 */ - - else if (pixel_bytes == 2) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 30 -loop2_pass0: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 - punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi + 16], mm1 - movq [edi + 24], mm1 - sub esi, 4 - sub edi, 32 - sub ecx, 2 - jnz loop2_pass0 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*16 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 14 -loop2_pass2: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 - punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 - movq [edi], mm0 - sub esi, 4 - movq [edi + 8], mm1 - //sub esi, 4 - sub edi, 16 - sub ecx, 2 - jnz loop2_pass2 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*8 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 6 -loop2_pass4: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - sub esi, 4 - movq [edi], mm0 - sub edi, 8 - sub ecx, 2 - jnz loop2_pass4 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*4 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - } /* end of pixel_bytes == 2 */ - - else if (pixel_bytes == 4) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 60 -loop4_pass0: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi + 16], mm0 - movq [edi + 24], mm0 - movq [edi+32], mm1 - movq [edi + 40], mm1 - movq [edi+ 48], mm1 - sub esi, 8 - movq [edi + 56], mm1 - sub edi, 64 - sub ecx, 2 - jnz loop4_pass0 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*32 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 28 -loop4_pass2: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi+16], mm1 - movq [edi + 24], mm1 - sub esi, 8 - sub edi, 32 - sub ecx, 2 - jnz loop4_pass2 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*16 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 12 -loop4_pass4: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - sub esi, 8 - movq [edi + 8], mm1 - sub edi, 16 - sub ecx, 2 - jnz loop4_pass4 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*8 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - - } /* end of pixel_bytes == 4 */ - - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } /* end of pixel_bytes == 6 */ - - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr-= pixel_bytes; - } - } - } /* end of mmx_supported */ - - else /* MMX not supported: use modified C code - takes advantage - * of inlining of memcpy for a constant */ - { - if (pixel_bytes == 1) - { - for (i = width; i; i--) - { - int j; - for (j = 0; j < png_pass_inc[pass]; j++) - *dp-- = *sptr; - sptr--; - } - } - else if (pixel_bytes == 3) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 2) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 4) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - - } /* end of MMX not supported */ - break; - } - } /* end switch (row_info->pixel_depth) */ - - row_info->width = final_width; - - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); - } - -} - -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - - -// These variables are utilized in the functions below. They are declared -// globally here to ensure alignment on 8-byte boundaries. - -union uAll { - __int64 use; - double align; -} LBCarryMask = {0x0101010101010101}, - HBClearMask = {0x7f7f7f7f7f7f7f7f}, - ActiveMask, ActiveMask2, ActiveMaskEnd, ShiftBpp, ShiftRem; - - -// Optimized code for PNG Average filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row - , png_bytep prev_row) -{ - int bpp; - png_uint_32 FullLength; - png_uint_32 MMXLength; - //png_uint_32 len; - int diff; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes; // # of bytes to filter - _asm { - // Init address pointers and offset - mov edi, row // edi ==> Avg(x) - xor ebx, ebx // ebx ==> x - mov edx, edi - mov esi, prev_row // esi ==> Prior(x) - sub edx, bpp // edx ==> Raw(x-bpp) - - xor eax, eax - // Compute the Raw value for the first bpp bytes - // Raw(x) = Avg(x) + (Prior(x)/2) -davgrlp: - mov al, [esi + ebx] // Load al with Prior(x) - inc ebx - shr al, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, bpp - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davgrlp - // get # of bytes to alignment - mov diff, edi // take start of row - add diff, ebx // add bpp - add diff, 0xf // add 7 + 8 to incr past alignment boundary - and diff, 0xfffffff8 // mask to alignment boundary - sub diff, edi // subtract from start ==> value ebx at alignment - jz davggo - // fix alignment - // Compute the Raw value for the bytes upto the alignment boundary - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor ecx, ecx -davglp1: - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, diff // Check if at alignment boundary - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davglp1 // Repeat until at alignment boundary -davggo: - mov eax, FullLength - mov ecx, eax - sub eax, ebx // subtract alignment fix - and eax, 0x00000007 // calc bytes over mult of 8 - sub ecx, eax // drop over bytes from original length - mov MMXLength, ecx - } // end _asm block - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000000000ffffff; - ShiftBpp.use = 24; // == 3 * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm { - // Re-init address pointers and offset - movq mm7, ActiveMask - mov ebx, diff // ebx ==> x = offset to alignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg3lp: - movq mm0, [edi + ebx] // Load mm0 with Avg(x) - // Add (Prev_row/2) to Average - movq mm3, mm5 - psrlq mm2, ShiftRem // Correct position Raw(x-bpp) data - movq mm1, [esi + ebx] // Load mm1 with Prior(x) - movq mm6, mm7 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 3-5 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - - // Add 3rd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover the last two - // bytes - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - add ebx, 8 - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Move updated Raw(x) to use as Raw(x-bpp) for next loop - cmp ebx, MMXLength - movq mm2, mm0 // mov updated Raw(x) to mm2 - jb davg3lp - } // end _asm block - } - break; - - case 6: - case 4: - case 7: - case 5: - { - ActiveMask.use = 0xffffffffffffffff; // use shift below to clear - // appropriate inactive bytes - ShiftBpp.use = bpp << 3; - ShiftRem.use = 64 - ShiftBpp.use; - _asm { - movq mm4, HBClearMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - // Load ActiveMask and clear all bytes except for 1st active group - movq mm7, ActiveMask - mov edi, row // edi ==> Avg(x) - psrlq mm7, ShiftRem - mov esi, prev_row // esi ==> Prior(x) - movq mm6, mm7 - movq mm5, LBCarryMask - psllq mm6, ShiftBpp // Create mask for 2nd active group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg4lp: - movq mm0, [edi + ebx] - psrlq mm2, ShiftRem // shift data to position correctly - movq mm1, [esi + ebx] - // Add (Prev_row/2) to Average - movq mm3, mm5 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm7 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - add ebx, 8 - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - cmp ebx, MMXLength - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Prep Raw(x-bpp) for next loop - movq mm2, mm0 // mov updated Raws to mm2 - jb davg4lp - } // end _asm block - } - break; - case 2: - { - ActiveMask.use = 0x000000000000ffff; - ShiftBpp.use = 16; // == 2 * 8 [BUGFIX] - ShiftRem.use = 48; // == 64 - 16 [BUGFIX] - _asm { - // Load ActiveMask - movq mm7, ActiveMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg2lp: - movq mm0, [edi + ebx] - psrlq mm2, ShiftRem // shift data to position correctly [BUGFIX] - movq mm1, [esi + ebx] - // Add (Prev_row/2) to Average - movq mm3, mm5 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - movq mm6, mm7 - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 2 & 3 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - // Add rdd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 4 & 5 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - // Add 4th active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 6 & 7 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - add ebx, 8 - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - cmp ebx, MMXLength - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Prep Raw(x-bpp) for next loop - movq mm2, mm0 // mov updated Raws to mm2 - jb davg2lp - } // end _asm block - } - break; - - case 1: // bpp == 1 - { - _asm { - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - mov edi, row // edi ==> Avg(x) - cmp ebx, FullLength // Test if offset at end of array - jnb davg1end - // Do Paeth decode for remaining bytes - mov esi, prev_row // esi ==> Prior(x) - mov edx, edi - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // edx ==> Raw(x-bpp) -davg1lp: - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, FullLength // Check if at end of array - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davg1lp -davg1end: - } // end _asm block - } - return; - - case 8: // bpp == 8 - { - _asm { - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (NO NEED to correct position in loop below) -davg8lp: - movq mm0, [edi + ebx] - movq mm3, mm5 - movq mm1, [esi + ebx] - add ebx, 8 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm3, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 - psrlq mm2, 1 // divide raw bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm3 // add LBCarrys to Avg for each byte - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - paddb mm0, mm2 // add (Raw/2) to Avg for each byte - cmp ebx, MMXLength - movq [edi + ebx - 8], mm0 - movq mm2, mm0 // reuse as Raw(x-bpp) - jb davg8lp - } // end _asm block - } - break; - default: // bpp greater than 8 - { - _asm { - movq mm5, LBCarryMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov edx, edi - mov esi, prev_row // esi ==> Prior(x) - sub edx, bpp // edx ==> Raw(x-bpp) -davgAlp: - movq mm0, [edi + ebx] - movq mm3, mm5 - movq mm1, [esi + ebx] - pand mm3, mm1 // get lsb for each prev_row byte - movq mm2, [edx + ebx] - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm3, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 - psrlq mm2, 1 // divide raw bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm3 // add LBCarrys to Avg for each byte - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - add ebx, 8 - paddb mm0, mm2 // add (Raw/2) to Avg for each byte - cmp ebx, MMXLength - movq [edi + ebx - 8], mm0 - jb davgAlp - } // end _asm block - } - break; - } // end switch ( bpp ) - - _asm { - // MMX acceleration complete now do clean-up - // Check if any remaining bytes left to decode - mov ebx, MMXLength // ebx ==> x = offset bytes remaining after MMX - mov edi, row // edi ==> Avg(x) - cmp ebx, FullLength // Test if offset at end of array - jnb davgend - // Do Paeth decode for remaining bytes - mov esi, prev_row // esi ==> Prior(x) - mov edx, edi - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // edx ==> Raw(x-bpp) -davglp2: - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, FullLength // Check if at end of array - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davglp2 -davgend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Paeth filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 FullLength; - png_uint_32 MMXLength; - //png_uint_32 len; - int bpp; - int diff; - //int ptemp; - int patemp, pbtemp, pctemp; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes; // # of bytes to filter - _asm - { - xor ebx, ebx // ebx ==> x offset - mov edi, row - xor edx, edx // edx ==> x-bpp offset - mov esi, prev_row - xor eax, eax - - // Compute the Raw value for the first bpp bytes - // Note: the formula works out to be always - // Paeth(x) = Raw(x) + Prior(x) where x < bpp -dpthrlp: - mov al, [edi + ebx] - add al, [esi + ebx] - inc ebx - cmp ebx, bpp - mov [edi + ebx - 1], al - jb dpthrlp - // get # of bytes to alignment - mov diff, edi // take start of row - add diff, ebx // add bpp - xor ecx, ecx - add diff, 0xf // add 7 + 8 to incr past alignment boundary - and diff, 0xfffffff8 // mask to alignment boundary - sub diff, edi // subtract from start ==> value ebx at alignment - jz dpthgo - // fix alignment -dpthlp1: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthpca - neg eax // reverse sign of neg values -dpthpca: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthpba - neg ecx // reverse sign of neg values -dpthpba: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthpaa - neg eax // reverse sign of neg values -dpthpaa: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthabb - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthbbc - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth -dpthbbc: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthpaeth -dpthabb: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthabc - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth -dpthabc: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthpaeth: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, diff - jb dpthlp1 -dpthgo: - mov ecx, FullLength - mov eax, ecx - sub eax, ebx // subtract alignment fix - and eax, 0x00000007 // calc bytes over mult of 8 - sub ecx, eax // drop over bytes from original length - mov MMXLength, ecx - } // end _asm block - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000000000ffffff; - ActiveMaskEnd.use = 0xffff000000000000; - ShiftBpp.use = 24; // == bpp(3) * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm - { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dpth3lp: - psrlq mm1, ShiftRem // shift last 3 bytes to 1st 3 bytes - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm1, mm0 // Unpack High bytes of a - movq mm3, [esi+ebx-8] // Prep c=Prior(x-bpp) bytes - punpcklbw mm2, mm0 // Unpack High bytes of b - psrlq mm3, ShiftRem // shift last 3 bytes to 1st 3 bytes - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx] // load c=Prior(x-bpp) - pand mm7, ActiveMask - movq mm2, mm3 // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpcklbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 // Now mm1 will be used as Raw(x-bpp) - // Now do Paeth for 2nd set of bytes (3-5) - psrlq mm2, ShiftBpp // load b=Prior(x) step 2 - punpcklbw mm1, mm0 // Unpack High bytes of a - pxor mm7, mm7 - punpcklbw mm2, mm0 // Unpack High bytes of b - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - psubw mm5, mm3 - psubw mm4, mm3 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = - // pav + pbv = pbv + pav - movq mm6, mm5 - paddw mm6, mm4 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm5 // Create mask pbv bytes < 0 - pcmpgtw mm7, mm4 // Create mask pav bytes < 0 - pand mm0, mm5 // Only pbv bytes < 0 in mm0 - pand mm7, mm4 // Only pav bytes < 0 in mm7 - psubw mm5, mm0 - psubw mm4, mm7 - psubw mm5, mm0 - psubw mm4, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - movq mm2, [esi + ebx] // load b=Prior(x) - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, mm2 // load c=Prior(x-bpp) step 1 - pand mm7, ActiveMask - punpckhbw mm2, mm0 // Unpack High bytes of b - psllq mm7, ShiftBpp // Shift bytes to 2nd group of 3 bytes - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - psllq mm3, ShiftBpp // load c=Prior(x-bpp) step 2 - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 - punpckhbw mm3, mm0 // Unpack High bytes of c - psllq mm1, ShiftBpp // Shift bytes - // Now mm1 will be used as Raw(x-bpp) - // Now do Paeth for 3rd, and final, set of bytes (6-7) - pxor mm7, mm7 - punpckhbw mm1, mm0 // Unpack High bytes of a - psubw mm4, mm3 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - pxor mm0, mm0 - paddw mm6, mm5 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - pandn mm0, mm1 - pandn mm7, mm4 - paddw mm0, mm2 - paddw mm7, mm5 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm1, mm1 - packuswb mm1, mm7 - // Step ebx to next set of 8 bytes and repeat loop til done - add ebx, 8 - pand mm1, ActiveMaskEnd - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - - cmp ebx, MMXLength - pxor mm0, mm0 // pxor does not affect flags - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - // mm3 ready to be used as Prior(x-bpp) next loop - jb dpth3lp - } // end _asm block - } - break; - - case 6: - case 7: - case 5: - { - ActiveMask.use = 0x00000000ffffffff; - ActiveMask2.use = 0xffffffff00000000; - ShiftBpp.use = bpp << 3; // == bpp * 8 - ShiftRem.use = 64 - ShiftBpp.use; - _asm - { - mov ebx, diff - mov edi, row - mov esi, prev_row - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] - pxor mm0, mm0 -dpth6lp: - // Must shift to position Raw(x-bpp) data - psrlq mm1, ShiftRem - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpcklbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack Low bytes of b - // Must shift to position Prior(x-bpp) data - psrlq mm3, ShiftRem - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx - 8] // load c=Prior(x-bpp) - pand mm7, ActiveMask - psrlq mm3, ShiftRem - movq mm2, [esi + ebx] // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - movq mm6, mm2 - movq [edi + ebx], mm7 // write back updated value - movq mm1, [edi+ebx-8] - psllq mm6, ShiftBpp - movq mm5, mm7 - psrlq mm1, ShiftRem - por mm3, mm6 - psllq mm5, ShiftBpp - punpckhbw mm3, mm0 // Unpack High bytes of c - por mm1, mm5 - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack High bytes of b - punpckhbw mm1, mm0 // Unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth6lp - } // end _asm block - } - break; - - case 4: - { - ActiveMask.use = 0x00000000ffffffff; - _asm { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] // Only time should need to read - // a=Raw(x-bpp) bytes -dpth4lp: - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpckhbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack High bytes of b - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpckhbw mm3, mm0 // Unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx] // load c=Prior(x-bpp) - pand mm7, ActiveMask - movq mm2, mm3 // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpcklbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 // Now mm1 will be used as Raw(x-bpp) - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack Low bytes of b - punpcklbw mm1, mm0 // Unpack Low bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth4lp - } // end _asm block - } - break; - case 8: // bpp == 8 - { - ActiveMask.use = 0x00000000ffffffff; - _asm { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] // Only time should need to read - // a=Raw(x-bpp) bytes -dpth8lp: - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpcklbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack Low bytes of b - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - pand mm7, ActiveMask - movq mm2, [esi + ebx] // load b=Prior(x) - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpckhbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, [edi+ebx-8] // read a=Raw(x-bpp) bytes - - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack High bytes of b - punpckhbw mm1, mm0 // Unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth8lp - } // end _asm block - } - break; - - case 1: // bpp = 1 - case 2: // bpp = 2 - default: // bpp > 8 - { - _asm { - mov ebx, diff - cmp ebx, FullLength - jnb dpthdend - mov edi, row - mov esi, prev_row - // Do Paeth decode for remaining bytes - mov edx, ebx - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // Set edx = ebx - bpp -dpthdlp: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthdpca - neg eax // reverse sign of neg values -dpthdpca: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthdpba - neg ecx // reverse sign of neg values -dpthdpba: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthdpaa - neg eax // reverse sign of neg values -dpthdpaa: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthdabb - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthdbbc - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthdpaeth -dpthdbbc: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthdpaeth -dpthdabb: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthdabc - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthdpaeth -dpthdabc: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthdpaeth: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, FullLength - jb dpthdlp -dpthdend: - } // end _asm block - } - return; // No need to go further with this one - } // end switch ( bpp ) - _asm - { - // MMX acceleration complete now do clean-up - // Check if any remaining bytes left to decode - mov ebx, MMXLength - cmp ebx, FullLength - jnb dpthend - mov edi, row - mov esi, prev_row - // Do Paeth decode for remaining bytes - mov edx, ebx - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // Set edx = ebx - bpp -dpthlp2: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthpca2 - neg eax // reverse sign of neg values -dpthpca2: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthpba2 - neg ecx // reverse sign of neg values -dpthpba2: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthpaa2 - neg eax // reverse sign of neg values -dpthpaa2: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthabb2 - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthbbc2 - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth2 -dpthbbc2: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthpaeth2 -dpthabb2: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthabc2 - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth2 -dpthabc2: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthpaeth2: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, FullLength - jb dpthlp2 -dpthend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Sub filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) -{ - //int test; - int bpp; - png_uint_32 FullLength; - png_uint_32 MMXLength; - int diff; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes - bpp; // # of bytes to filter - _asm { - mov edi, row - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - xor eax, eax - // get # of bytes to alignment - mov diff, edi // take start of row - add diff, 0xf // add 7 + 8 to incr past - // alignment boundary - xor ebx, ebx - and diff, 0xfffffff8 // mask to alignment boundary - sub diff, edi // subtract from start ==> value - // ebx at alignment - jz dsubgo - // fix alignment -dsublp1: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, diff - jb dsublp1 -dsubgo: - mov ecx, FullLength - mov edx, ecx - sub edx, ebx // subtract alignment fix - and edx, 0x00000007 // calc bytes over mult of 8 - sub ecx, edx // drop over bytes from length - mov MMXLength, ecx - } // end _asm block - - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000ffffff000000; - ShiftBpp.use = 24; // == 3 * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm { - mov edi, row - movq mm7, ActiveMask // Load ActiveMask for 2nd active byte group - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - movq mm6, mm7 - mov ebx, diff - psllq mm6, ShiftBpp // Move mask in mm6 to cover 3rd active - // byte group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub3lp: - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive bytes - // Add 1st active group - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm7 // mask to use only 2nd active group - paddb mm0, mm1 - // Add 3rd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm6 // mask to use only 3rd active group - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // Write updated Raws back to array - // Prep for doing 1st add at top of loop - movq mm1, mm0 - jb dsub3lp - } // end _asm block - } - break; - - case 1: - { - // Placed here just in case this is a duplicate of the - // non-MMX code for the SUB filter in png_read_filter_row below - // - // png_bytep rp; - // png_bytep lp; - // png_uint_32 i; - // bpp = (row_info->pixel_depth + 7) >> 3; - // for (i = (png_uint_32)bpp, rp = row + bpp, lp = row; - // i < row_info->rowbytes; i++, rp++, lp++) - // { - // *rp = (png_byte)(((int)(*rp) + (int)(*lp)) & 0xff); - // } - _asm { - mov ebx, diff - mov edi, row - cmp ebx, FullLength - jnb dsub1end - mov esi, edi // lp = row - xor eax, eax - add edi, bpp // rp = row + bpp -dsub1lp: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, FullLength - jb dsub1lp -dsub1end: - } // end _asm block - } - return; - - case 6: - case 7: - case 4: - case 5: - { - ShiftBpp.use = bpp << 3; - ShiftRem.use = 64 - ShiftBpp.use; - _asm { - mov edi, row - mov ebx, diff - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub4lp: - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive bytes - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - // there is no need for any mask - // since shift clears inactive bits/bytes - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 - movq mm1, mm0 // Prep for doing 1st add at top of loop - jb dsub4lp - } // end _asm block - } - break; - - case 2: - { - ActiveMask.use = 0x00000000ffff0000; - ShiftBpp.use = 16; // == 2 * 8 - ShiftRem.use = 48; // == 64 - 16 - _asm { - movq mm7, ActiveMask // Load ActiveMask for 2nd active byte group - mov ebx, diff - movq mm6, mm7 - mov edi, row - psllq mm6, ShiftBpp // Move mask in mm6 to cover 3rd active - // byte group - mov esi, edi // lp = row - movq mm5, mm6 - add edi, bpp // rp = row + bpp - psllq mm5, ShiftBpp // Move mask in mm5 to cover 4th active - // byte group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub2lp: - // Add 1st active group - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive - // bytes - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm7 // mask to use only 2nd active group - paddb mm0, mm1 - // Add 3rd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm6 // mask to use only 3rd active group - paddb mm0, mm1 - // Add 4th active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm5 // mask to use only 4th active group - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // Write updated Raws back to array - movq mm1, mm0 // Prep for doing 1st add at top of loop - jb dsub2lp - } // end _asm block - } - break; - case 8: - { - _asm { - mov edi, row - mov ebx, diff - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - mov ecx, MMXLength - movq mm7, [edi+ebx-8] // PRIME the pump (load the first - // Raw(x-bpp) data set - and ecx, 0x0000003f // calc bytes over mult of 64 -dsub8lp: - movq mm0, [edi+ebx] // Load Sub(x) for 1st 8 bytes - paddb mm0, mm7 - movq mm1, [edi+ebx+8] // Load Sub(x) for 2nd 8 bytes - movq [edi+ebx], mm0 // Write Raw(x) for 1st 8 bytes - // Now mm0 will be used as Raw(x-bpp) for - // the 2nd group of 8 bytes. This will be - // repeated for each group of 8 bytes with - // the 8th group being used as the Raw(x-bpp) - // for the 1st group of the next loop. - paddb mm1, mm0 - movq mm2, [edi+ebx+16] // Load Sub(x) for 3rd 8 bytes - movq [edi+ebx+8], mm1 // Write Raw(x) for 2nd 8 bytes - paddb mm2, mm1 - movq mm3, [edi+ebx+24] // Load Sub(x) for 4th 8 bytes - movq [edi+ebx+16], mm2 // Write Raw(x) for 3rd 8 bytes - paddb mm3, mm2 - movq mm4, [edi+ebx+32] // Load Sub(x) for 5th 8 bytes - movq [edi+ebx+24], mm3 // Write Raw(x) for 4th 8 bytes - paddb mm4, mm3 - movq mm5, [edi+ebx+40] // Load Sub(x) for 6th 8 bytes - movq [edi+ebx+32], mm4 // Write Raw(x) for 5th 8 bytes - paddb mm5, mm4 - movq mm6, [edi+ebx+48] // Load Sub(x) for 7th 8 bytes - movq [edi+ebx+40], mm5 // Write Raw(x) for 6th 8 bytes - paddb mm6, mm5 - movq mm7, [edi+ebx+56] // Load Sub(x) for 8th 8 bytes - movq [edi+ebx+48], mm6 // Write Raw(x) for 7th 8 bytes - add ebx, 64 - paddb mm7, mm6 - cmp ebx, ecx - movq [edi+ebx-8], mm7 // Write Raw(x) for 8th 8 bytes - jb dsub8lp - cmp ebx, MMXLength - jnb dsub8lt8 -dsub8lpA: - movq mm0, [edi+ebx] - add ebx, 8 - paddb mm0, mm7 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // use -8 to offset early add to ebx - movq mm7, mm0 // Move calculated Raw(x) data to mm1 to - // be the new Raw(x-bpp) for the next loop - jb dsub8lpA -dsub8lt8: - } // end _asm block - } - break; - - default: // bpp greater than 8 bytes - { - _asm { - mov ebx, diff - mov edi, row - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp -dsubAlp: - movq mm0, [edi+ebx] - movq mm1, [esi+ebx] - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // mov does not affect flags; -8 to offset - // add ebx - jb dsubAlp - } // end _asm block - } - break; - - } // end switch ( bpp ) - - _asm { - mov ebx, MMXLength - mov edi, row - cmp ebx, FullLength - jnb dsubend - mov esi, edi // lp = row - xor eax, eax - add edi, bpp // rp = row + bpp -dsublp2: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, FullLength - jb dsublp2 -dsubend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Up filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 len; - len = row_info->rowbytes; // # of bytes to filter - _asm { - mov edi, row - // get # of bytes to alignment - mov ecx, edi - xor ebx, ebx - add ecx, 0x7 - xor eax, eax - and ecx, 0xfffffff8 - mov esi, prev_row - sub ecx, edi - jz dupgo - // fix alignment -duplp1: - mov al, [edi+ebx] - add al, [esi+ebx] - inc ebx - cmp ebx, ecx - mov [edi + ebx-1], al // mov does not affect flags; -1 to offset inc ebx - jb duplp1 -dupgo: - mov ecx, len - mov edx, ecx - sub edx, ebx // subtract alignment fix - and edx, 0x0000003f // calc bytes over mult of 64 - sub ecx, edx // drop over bytes from length - // Unrolled loop - use all MMX registers and interleave to reduce - // number of branch instructions (loops) and reduce partial stalls -duploop: - movq mm1, [esi+ebx] - movq mm0, [edi+ebx] - movq mm3, [esi+ebx+8] - paddb mm0, mm1 - movq mm2, [edi+ebx+8] - movq [edi+ebx], mm0 - paddb mm2, mm3 - movq mm5, [esi+ebx+16] - movq [edi+ebx+8], mm2 - movq mm4, [edi+ebx+16] - movq mm7, [esi+ebx+24] - paddb mm4, mm5 - movq mm6, [edi+ebx+24] - movq [edi+ebx+16], mm4 - paddb mm6, mm7 - movq mm1, [esi+ebx+32] - movq [edi+ebx+24], mm6 - movq mm0, [edi+ebx+32] - movq mm3, [esi+ebx+40] - paddb mm0, mm1 - movq mm2, [edi+ebx+40] - movq [edi+ebx+32], mm0 - paddb mm2, mm3 - movq mm5, [esi+ebx+48] - movq [edi+ebx+40], mm2 - movq mm4, [edi+ebx+48] - movq mm7, [esi+ebx+56] - paddb mm4, mm5 - movq mm6, [edi+ebx+56] - movq [edi+ebx+48], mm4 - add ebx, 64 - paddb mm6, mm7 - cmp ebx, ecx - movq [edi+ebx-8], mm6 // (+56)movq does not affect flags; - // -8 to offset add ebx - jb duploop - - cmp edx, 0 // Test for bytes over mult of 64 - jz dupend - - - // 2 lines added by lcreeve at netins.net - // (mail 11 Jul 98 in png-implement list) - cmp edx, 8 //test for less than 8 bytes - jb duplt8 - - - add ecx, edx - and edx, 0x00000007 // calc bytes over mult of 8 - sub ecx, edx // drop over bytes from length - jz duplt8 - // Loop using MMX registers mm0 & mm1 to update 8 bytes simultaneously -duplpA: - movq mm1, [esi+ebx] - movq mm0, [edi+ebx] - add ebx, 8 - paddb mm0, mm1 - cmp ebx, ecx - movq [edi+ebx-8], mm0 // movq does not affect flags; -8 to offset add ebx - jb duplpA - cmp edx, 0 // Test for bytes over mult of 8 - jz dupend -duplt8: - xor eax, eax - add ecx, edx // move over byte count into counter - // Loop using x86 registers to update remaining bytes -duplp2: - mov al, [edi + ebx] - add al, [esi + ebx] - inc ebx - cmp ebx, ecx - mov [edi + ebx-1], al // mov does not affect flags; -1 to offset inc ebx - jb duplp2 -dupend: - // Conversion of filtered row completed - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - - -// Optimized png_read_filter_row routines -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep - row, png_bytep prev_row, int filter) -{ -#ifdef PNG_DEBUG - char filnm[10]; -#endif - - if (mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } - -#ifdef PNG_DEBUG - png_debug(1, "in png_read_filter_row\n"); - switch (filter) - { - case 0: sprintf(filnm, "none"); - break; -#if !defined(PNG_1_0_X) - case 1: sprintf(filnm, "sub-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : "x86"); - break; - case 2: sprintf(filnm, "up-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : "x86"); - break; - case 3: sprintf(filnm, "avg-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : "x86"); - break; - case 4: sprintf(filnm, "Paeth-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX":"x86"); - break; -#else - case 1: sprintf(filnm, "sub"); - break; - case 2: sprintf(filnm, "up"); - break; - case 3: sprintf(filnm, "avg"); - break; - case 4: sprintf(filnm, "Paeth"); - break; -#endif - default: sprintf(filnm, "unknw"); - break; - } - png_debug2(0,"row=%5d, %s, ", png_ptr->row_number, filnm); - png_debug2(0, "pd=%2d, b=%d, ", (int)row_info->pixel_depth, - (int)((row_info->pixel_depth + 7) >> 3)); - png_debug1(0,"len=%8d, ", row_info->rowbytes); -#endif /* PNG_DEBUG */ - - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - - case PNG_FILTER_VALUE_SUB: - { -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (mmx_supported) -#endif - { - png_read_filter_row_mmx_sub(row_info, row); - } - else - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_UP: - { -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (mmx_supported) -#endif - { - png_read_filter_row_mmx_up(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; ++i) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_AVG: - { -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (mmx_supported) -#endif - { - png_read_filter_row_mmx_avg(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) >> 1)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++ + *lp++) >> 1)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_PAETH: - { -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (mmx_supported) -#endif - { - png_read_filter_row_mmx_paeth(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop=row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) // use leftover rp,pp - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - } - break; - } - - default: - png_warning(png_ptr, "Ignoring bad row filter type"); - *row=0; - break; - } -} - -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED && PNG_USE_PNGVCRD */ + +/* pngvcrd.c - mixed C/assembler version of utilities to read a PNG file + * + * For Intel x86 CPU and Microsoft Visual C++ compiler + * + * Last changed in libpng 1.2.6 - August 15, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson + * Copyright (c) 1998, Intel Corporation + * + * Contributed by Nirav Chhatrapati, Intel Corporation, 1998 + * Interface to libpng contributed by Gilles Vollant, 1999 + * + * + * In png_do_read_interlace() in libpng versions 1.0.3a through 1.0.4d, + * a sign error in the post-MMX cleanup code for each pixel_depth resulted + * in bad pixels at the beginning of some rows of some images, and also + * (due to out-of-range memory reads and writes) caused heap corruption + * when compiled with MSVC 6.0. The error was fixed in version 1.0.4e. + * + * [png_read_filter_row_mmx_avg() bpp == 2 bugfix, GRR 20000916] + * + * [runtime MMX configuration, GRR 20010102] + * + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD) + +static int mmx_supported=2; + + +int PNGAPI +png_mmx_support(void) +{ + int mmx_supported_local = 0; + _asm { + push ebx //CPUID will trash these + push ecx + push edx + + pushfd //Save Eflag to stack + pop eax //Get Eflag from stack into eax + mov ecx, eax //Make another copy of Eflag in ecx + xor eax, 0x200000 //Toggle ID bit in Eflag [i.e. bit(21)] + push eax //Save modified Eflag back to stack + + popfd //Restored modified value back to Eflag reg + pushfd //Save Eflag to stack + pop eax //Get Eflag from stack + push ecx // save original Eflag to stack + popfd // restore original Eflag + xor eax, ecx //Compare the new Eflag with the original Eflag + jz NOT_SUPPORTED //If the same, CPUID instruction is not supported, + //skip following instructions and jump to + //NOT_SUPPORTED label + + xor eax, eax //Set eax to zero + + _asm _emit 0x0f //CPUID instruction (two bytes opcode) + _asm _emit 0xa2 + + cmp eax, 1 //make sure eax return non-zero value + jl NOT_SUPPORTED //If eax is zero, mmx not supported + + xor eax, eax //set eax to zero + inc eax //Now increment eax to 1. This instruction is + //faster than the instruction "mov eax, 1" + + _asm _emit 0x0f //CPUID instruction + _asm _emit 0xa2 + + and edx, 0x00800000 //mask out all bits but mmx bit(24) + cmp edx, 0 // 0 = mmx not supported + jz NOT_SUPPORTED // non-zero = Yes, mmx IS supported + + mov mmx_supported_local, 1 //set return value to 1 + +NOT_SUPPORTED: + mov eax, mmx_supported_local //move return value to eax + pop edx //CPUID trashed these + pop ecx + pop ebx + } + + //mmx_supported_local=0; // test code for force don't support MMX + //printf("MMX : %u (1=MMX supported)\n",mmx_supported_local); + + mmx_supported = mmx_supported_local; + return mmx_supported_local; +} + +/* Combines the row recently read in with the previous row. + This routine takes care of alpha and transparency if requested. + This routine also handles the two methods of progressive display + of interlaced images, depending on the mask value. + The mask value describes which pixels are to be combined with + the row. The pattern always repeats every 8 pixels, so just 8 + bits are needed. A one indicates the pixel is to be combined; a + zero indicates the pixel is to be skipped. This is in addition + to any alpha or transparency value associated with the pixel. If + you want all pixels to be combined, pass 0xff (255) in mask. */ + +/* Use this routine for x86 platform - uses faster MMX routine if machine + supports MMX */ + +void /* PRIVATE */ +png_combine_row(png_structp png_ptr, png_bytep row, int mask) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +#endif + + png_debug(1,"in png_combine_row_asm\n"); + + if (mmx_supported == 2) { +#if !defined(PNG_1_0_X) + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); +#endif + png_mmx_support(); + } + + if (mask == 0xff) + { + png_memcpy(row, png_ptr->row_buf + 1, + (png_size_t)PNG_ROWBYTES(png_ptr->row_info.pixel_depth, + png_ptr->width)); + } + /* GRR: add "else if (mask == 0)" case? + * or does png_combine_row() not even get called in that case? */ + else + { + switch (png_ptr->row_info.pixel_depth) + { + case 1: + { + png_bytep sp; + png_bytep dp; + int s_inc, s_start, s_end; + int m; + int shift; + png_uint_32 i; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 7; + s_inc = 1; + } + else +#endif + { + s_start = 7; + s_end = 0; + s_inc = -1; + } + + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + int value; + + value = (*sp >> shift) & 0x1; + *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 2: + { + png_bytep sp; + png_bytep dp; + int s_start, s_end, s_inc; + int m; + int shift; + png_uint_32 i; + int value; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 6; + s_inc = 2; + } + else +#endif + { + s_start = 6; + s_end = 0; + s_inc = -2; + } + + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0x3; + *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 4: + { + png_bytep sp; + png_bytep dp; + int s_start, s_end, s_inc; + int m; + int shift; + png_uint_32 i; + int value; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 4; + s_inc = 4; + } + else +#endif + { + s_start = 4; + s_end = 0; + s_inc = -4; + } + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0xf; + *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 8: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int m; + int diff, unmask; + + __int64 mask0=0x0102040810204080; + +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) +#else + if (mmx_supported) +#endif + { + srcptr = png_ptr->row_buf + 1; + dstptr = row; + m = 0x80; + unmask = ~mask; + len = png_ptr->width &~7; //reduce to multiple of 8 + diff = png_ptr->width & 7; //amount lost + + _asm + { + movd mm7, unmask //load bit pattern + psubb mm6,mm6 //zero mm6 + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 //fill register with 8 masks + + movq mm0,mask0 + + pand mm0,mm7 //nonzero if keep byte + pcmpeqb mm0,mm6 //zeros->1s, v versa + + mov ecx,len //load length of line (pixels) + mov esi,srcptr //load source + mov ebx,dstptr //load dest + cmp ecx,0 //lcr + je mainloop8end + +mainloop8: + movq mm4,[esi] + pand mm4,mm0 + movq mm6,mm0 + pandn mm6,[ebx] + por mm4,mm6 + movq [ebx],mm4 + + add esi,8 //inc by 8 bytes processed + add ebx,8 + sub ecx,8 //dec by 8 pixels processed + + ja mainloop8 +mainloop8end: + + mov ecx,diff + cmp ecx,0 + jz end8 + + mov edx,mask + sal edx,24 //make low byte the high byte + +secondloop8: + sal edx,1 //move high bit to CF + jnc skip8 //if CF = 0 + mov al,[esi] + mov [ebx],al +skip8: + inc esi + inc ebx + + dec ecx + jnz secondloop8 +end8: + emms + } + } + else /* mmx not supported - use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } // end 8 bpp + + case 16: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int unmask, diff; + __int64 mask1=0x0101020204040808, + mask0=0x1010202040408080; + +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) +#else + if (mmx_supported) +#endif + { + srcptr = png_ptr->row_buf + 1; + dstptr = row; + + unmask = ~mask; + len = (png_ptr->width)&~7; + diff = (png_ptr->width)&7; + _asm + { + movd mm7, unmask //load bit pattern + psubb mm6,mm6 //zero mm6 + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 //fill register with 8 masks + + movq mm0,mask0 + movq mm1,mask1 + + pand mm0,mm7 + pand mm1,mm7 + + pcmpeqb mm0,mm6 + pcmpeqb mm1,mm6 + + mov ecx,len //load length of line + mov esi,srcptr //load source + mov ebx,dstptr //load dest + cmp ecx,0 //lcr + jz mainloop16end + +mainloop16: + movq mm4,[esi] + pand mm4,mm0 + movq mm6,mm0 + movq mm7,[ebx] + pandn mm6,mm7 + por mm4,mm6 + movq [ebx],mm4 + + movq mm5,[esi+8] + pand mm5,mm1 + movq mm7,mm1 + movq mm6,[ebx+8] + pandn mm7,mm6 + por mm5,mm7 + movq [ebx+8],mm5 + + add esi,16 //inc by 16 bytes processed + add ebx,16 + sub ecx,8 //dec by 8 pixels processed + + ja mainloop16 + +mainloop16end: + mov ecx,diff + cmp ecx,0 + jz end16 + + mov edx,mask + sal edx,24 //make low byte the high byte +secondloop16: + sal edx,1 //move high bit to CF + jnc skip16 //if CF = 0 + mov ax,[esi] + mov [ebx],ax +skip16: + add esi,2 + add ebx,2 + + dec ecx + jnz secondloop16 +end16: + emms + } + } + else /* mmx not supported - use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } // end 16 bpp + + case 24: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int unmask, diff; + + __int64 mask2=0x0101010202020404, //24bpp + mask1=0x0408080810101020, + mask0=0x2020404040808080; + + srcptr = png_ptr->row_buf + 1; + dstptr = row; + + unmask = ~mask; + len = (png_ptr->width)&~7; + diff = (png_ptr->width)&7; + +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) +#else + if (mmx_supported) +#endif + { + _asm + { + movd mm7, unmask //load bit pattern + psubb mm6,mm6 //zero mm6 + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 //fill register with 8 masks + + movq mm0,mask0 + movq mm1,mask1 + movq mm2,mask2 + + pand mm0,mm7 + pand mm1,mm7 + pand mm2,mm7 + + pcmpeqb mm0,mm6 + pcmpeqb mm1,mm6 + pcmpeqb mm2,mm6 + + mov ecx,len //load length of line + mov esi,srcptr //load source + mov ebx,dstptr //load dest + cmp ecx,0 + jz mainloop24end + +mainloop24: + movq mm4,[esi] + pand mm4,mm0 + movq mm6,mm0 + movq mm7,[ebx] + pandn mm6,mm7 + por mm4,mm6 + movq [ebx],mm4 + + + movq mm5,[esi+8] + pand mm5,mm1 + movq mm7,mm1 + movq mm6,[ebx+8] + pandn mm7,mm6 + por mm5,mm7 + movq [ebx+8],mm5 + + movq mm6,[esi+16] + pand mm6,mm2 + movq mm4,mm2 + movq mm7,[ebx+16] + pandn mm4,mm7 + por mm6,mm4 + movq [ebx+16],mm6 + + add esi,24 //inc by 24 bytes processed + add ebx,24 + sub ecx,8 //dec by 8 pixels processed + + ja mainloop24 + +mainloop24end: + mov ecx,diff + cmp ecx,0 + jz end24 + + mov edx,mask + sal edx,24 //make low byte the high byte +secondloop24: + sal edx,1 //move high bit to CF + jnc skip24 //if CF = 0 + mov ax,[esi] + mov [ebx],ax + xor eax,eax + mov al,[esi+2] + mov [ebx+2],al +skip24: + add esi,3 + add ebx,3 + + dec ecx + jnz secondloop24 + +end24: + emms + } + } + else /* mmx not supported - use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } // end 24 bpp + + case 32: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int unmask, diff; + + __int64 mask3=0x0101010102020202, //32bpp + mask2=0x0404040408080808, + mask1=0x1010101020202020, + mask0=0x4040404080808080; + + srcptr = png_ptr->row_buf + 1; + dstptr = row; + + unmask = ~mask; + len = (png_ptr->width)&~7; + diff = (png_ptr->width)&7; + +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) +#else + if (mmx_supported) +#endif + { + _asm + { + movd mm7, unmask //load bit pattern + psubb mm6,mm6 //zero mm6 + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 //fill register with 8 masks + + movq mm0,mask0 + movq mm1,mask1 + movq mm2,mask2 + movq mm3,mask3 + + pand mm0,mm7 + pand mm1,mm7 + pand mm2,mm7 + pand mm3,mm7 + + pcmpeqb mm0,mm6 + pcmpeqb mm1,mm6 + pcmpeqb mm2,mm6 + pcmpeqb mm3,mm6 + + mov ecx,len //load length of line + mov esi,srcptr //load source + mov ebx,dstptr //load dest + + cmp ecx,0 //lcr + jz mainloop32end + +mainloop32: + movq mm4,[esi] + pand mm4,mm0 + movq mm6,mm0 + movq mm7,[ebx] + pandn mm6,mm7 + por mm4,mm6 + movq [ebx],mm4 + + movq mm5,[esi+8] + pand mm5,mm1 + movq mm7,mm1 + movq mm6,[ebx+8] + pandn mm7,mm6 + por mm5,mm7 + movq [ebx+8],mm5 + + movq mm6,[esi+16] + pand mm6,mm2 + movq mm4,mm2 + movq mm7,[ebx+16] + pandn mm4,mm7 + por mm6,mm4 + movq [ebx+16],mm6 + + movq mm7,[esi+24] + pand mm7,mm3 + movq mm5,mm3 + movq mm4,[ebx+24] + pandn mm5,mm4 + por mm7,mm5 + movq [ebx+24],mm7 + + add esi,32 //inc by 32 bytes processed + add ebx,32 + sub ecx,8 //dec by 8 pixels processed + + ja mainloop32 + +mainloop32end: + mov ecx,diff + cmp ecx,0 + jz end32 + + mov edx,mask + sal edx,24 //make low byte the high byte +secondloop32: + sal edx,1 //move high bit to CF + jnc skip32 //if CF = 0 + mov eax,[esi] + mov [ebx],eax +skip32: + add esi,4 + add ebx,4 + + dec ecx + jnz secondloop32 + +end32: + emms + } + } + else /* mmx _not supported - Use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } // end 32 bpp + + case 48: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int unmask, diff; + + __int64 mask5=0x0101010101010202, + mask4=0x0202020204040404, + mask3=0x0404080808080808, + mask2=0x1010101010102020, + mask1=0x2020202040404040, + mask0=0x4040808080808080; + +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) +#else + if (mmx_supported) +#endif + { + srcptr = png_ptr->row_buf + 1; + dstptr = row; + + unmask = ~mask; + len = (png_ptr->width)&~7; + diff = (png_ptr->width)&7; + _asm + { + movd mm7, unmask //load bit pattern + psubb mm6,mm6 //zero mm6 + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 //fill register with 8 masks + + movq mm0,mask0 + movq mm1,mask1 + movq mm2,mask2 + movq mm3,mask3 + movq mm4,mask4 + movq mm5,mask5 + + pand mm0,mm7 + pand mm1,mm7 + pand mm2,mm7 + pand mm3,mm7 + pand mm4,mm7 + pand mm5,mm7 + + pcmpeqb mm0,mm6 + pcmpeqb mm1,mm6 + pcmpeqb mm2,mm6 + pcmpeqb mm3,mm6 + pcmpeqb mm4,mm6 + pcmpeqb mm5,mm6 + + mov ecx,len //load length of line + mov esi,srcptr //load source + mov ebx,dstptr //load dest + + cmp ecx,0 + jz mainloop48end + +mainloop48: + movq mm7,[esi] + pand mm7,mm0 + movq mm6,mm0 + pandn mm6,[ebx] + por mm7,mm6 + movq [ebx],mm7 + + movq mm6,[esi+8] + pand mm6,mm1 + movq mm7,mm1 + pandn mm7,[ebx+8] + por mm6,mm7 + movq [ebx+8],mm6 + + movq mm6,[esi+16] + pand mm6,mm2 + movq mm7,mm2 + pandn mm7,[ebx+16] + por mm6,mm7 + movq [ebx+16],mm6 + + movq mm7,[esi+24] + pand mm7,mm3 + movq mm6,mm3 + pandn mm6,[ebx+24] + por mm7,mm6 + movq [ebx+24],mm7 + + movq mm6,[esi+32] + pand mm6,mm4 + movq mm7,mm4 + pandn mm7,[ebx+32] + por mm6,mm7 + movq [ebx+32],mm6 + + movq mm7,[esi+40] + pand mm7,mm5 + movq mm6,mm5 + pandn mm6,[ebx+40] + por mm7,mm6 + movq [ebx+40],mm7 + + add esi,48 //inc by 32 bytes processed + add ebx,48 + sub ecx,8 //dec by 8 pixels processed + + ja mainloop48 +mainloop48end: + + mov ecx,diff + cmp ecx,0 + jz end48 + + mov edx,mask + sal edx,24 //make low byte the high byte + +secondloop48: + sal edx,1 //move high bit to CF + jnc skip48 //if CF = 0 + mov eax,[esi] + mov [ebx],eax +skip48: + add esi,4 + add ebx,4 + + dec ecx + jnz secondloop48 + +end48: + emms + } + } + else /* mmx _not supported - Use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } // end 48 bpp + + default: + { + png_bytep sptr; + png_bytep dp; + png_size_t pixel_bytes; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + unsigned int i; + register int disp = png_pass_inc[png_ptr->pass]; // get the offset + register unsigned int incr1, initial_val, final_val; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + sptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dp = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dp, sptr, pixel_bytes); + sptr += incr1; + dp += incr1; + } + break; + } + } /* end switch (png_ptr->row_info.pixel_depth) */ + } /* end if (non-trivial mask) */ + +} /* end png_combine_row() */ + + +#if defined(PNG_READ_INTERLACING_SUPPORTED) + +void /* PRIVATE */ +png_do_read_interlace(png_structp png_ptr) +{ + png_row_infop row_info = &(png_ptr->row_info); + png_bytep row = png_ptr->row_buf + 1; + int pass = png_ptr->pass; + png_uint_32 transformations = png_ptr->transformations; +#ifdef PNG_USE_LOCAL_ARRAYS + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +#endif + + png_debug(1,"in png_do_read_interlace\n"); + + if (mmx_supported == 2) { +#if !defined(PNG_1_0_X) + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); +#endif + png_mmx_support(); + } + + if (row != NULL && row_info != NULL) + { + png_uint_32 final_width; + + final_width = row_info->width * png_pass_inc[pass]; + + switch (row_info->pixel_depth) + { + case 1: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_byte v; + png_uint_32 i; + int j; + + sp = row + (png_size_t)((row_info->width - 1) >> 3); + dp = row + (png_size_t)((final_width - 1) >> 3); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (int)((row_info->width + 7) & 7); + dshift = (int)((final_width + 7) & 7); + s_start = 7; + s_end = 0; + s_inc = -1; + } + else +#endif + { + sshift = 7 - (int)((row_info->width + 7) & 7); + dshift = 7 - (int)((final_width + 7) & 7); + s_start = 0; + s_end = 7; + s_inc = 1; + } + + for (i = row_info->width; i; i--) + { + v = (png_byte)((*sp >> sshift) & 0x1); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + case 2: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_uint_32 i; + + sp = row + (png_size_t)((row_info->width - 1) >> 2); + dp = row + (png_size_t)((final_width - 1) >> 2); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); + dshift = (png_size_t)(((final_width + 3) & 3) << 1); + s_start = 6; + s_end = 0; + s_inc = -2; + } + else +#endif + { + sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); + dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); + s_start = 0; + s_end = 6; + s_inc = 2; + } + + for (i = row_info->width; i; i--) + { + png_byte v; + int j; + + v = (png_byte)((*sp >> sshift) & 0x3); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + case 4: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_uint_32 i; + + sp = row + (png_size_t)((row_info->width - 1) >> 1); + dp = row + (png_size_t)((final_width - 1) >> 1); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); + dshift = (png_size_t)(((final_width + 1) & 1) << 2); + s_start = 4; + s_end = 0; + s_inc = -4; + } + else +#endif + { + sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); + dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); + s_start = 0; + s_end = 4; + s_inc = 4; + } + + for (i = row_info->width; i; i--) + { + png_byte v; + int j; + + v = (png_byte)((*sp >> sshift) & 0xf); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + default: // This is the place where the routine is modified + { + __int64 const4 = 0x0000000000FFFFFF; + // __int64 const5 = 0x000000FFFFFF0000; // unused... + __int64 const6 = 0x00000000000000FF; + png_bytep sptr, dp; + png_uint_32 i; + png_size_t pixel_bytes; + int width = row_info->width; + + pixel_bytes = (row_info->pixel_depth >> 3); + + sptr = row + (width - 1) * pixel_bytes; + dp = row + (final_width - 1) * pixel_bytes; + // New code by Nirav Chhatrapati - Intel Corporation + // sign fix by GRR + // NOTE: there is NO MMX code for 48-bit and 64-bit images + + // use MMX routine if machine supports it +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE) + /* && mmx_supported */ ) +#else + if (mmx_supported) +#endif + { + if (pixel_bytes == 3) + { + if (((pass == 0) || (pass == 1)) && width) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width + sub edi, 21 // (png_pass_inc[pass] - 1)*pixel_bytes +loop_pass0: + movd mm0, [esi] ; X X X X X v2 v1 v0 + pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 + movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 + psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 + movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 + psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 + psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 + por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 + por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 + movq mm3, mm0 ; v2 v1 v0 v2 v1 v0 v2 v1 + psllq mm0, 16 ; v0 v2 v1 v0 v2 v1 0 0 + movq mm4, mm3 ; v2 v1 v0 v2 v1 v0 v2 v1 + punpckhdq mm3, mm0 ; v0 v2 v1 v0 v2 v1 v0 v2 + movq [edi+16] , mm4 + psrlq mm0, 32 ; 0 0 0 0 v0 v2 v1 v0 + movq [edi+8] , mm3 + punpckldq mm0, mm4 ; v1 v0 v2 v1 v0 v2 v1 v0 + sub esi, 3 + movq [edi], mm0 + sub edi, 24 + //sub esi, 3 + dec ecx + jnz loop_pass0 + EMMS + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width + sub edi, 9 // (png_pass_inc[pass] - 1)*pixel_bytes +loop_pass2: + movd mm0, [esi] ; X X X X X v2 v1 v0 + pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 + movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 + psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 + movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 + psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 + psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 + por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 + por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 + movq [edi+4], mm0 ; move to memory + psrlq mm0, 16 ; 0 0 v2 v1 v0 v2 v1 v0 + movd [edi], mm0 ; move to memory + sub esi, 3 + sub edi, 12 + dec ecx + jnz loop_pass2 + EMMS + } + } + else if (width) /* && ((pass == 4) || (pass == 5)) */ + { + int width_mmx = ((width >> 1) << 1) - 8; + if (width_mmx < 0) + width_mmx = 0; + width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 3 + sub edi, 9 +loop_pass4: + movq mm0, [esi] ; X X v2 v1 v0 v5 v4 v3 + movq mm7, mm0 ; X X v2 v1 v0 v5 v4 v3 + movq mm6, mm0 ; X X v2 v1 v0 v5 v4 v3 + psllq mm0, 24 ; v1 v0 v5 v4 v3 0 0 0 + pand mm7, const4 ; 0 0 0 0 0 v5 v4 v3 + psrlq mm6, 24 ; 0 0 0 X X v2 v1 v0 + por mm0, mm7 ; v1 v0 v5 v4 v3 v5 v4 v3 + movq mm5, mm6 ; 0 0 0 X X v2 v1 v0 + psllq mm6, 8 ; 0 0 X X v2 v1 v0 0 + movq [edi], mm0 ; move quad to memory + psrlq mm5, 16 ; 0 0 0 0 0 X X v2 + pand mm5, const6 ; 0 0 0 0 0 0 0 v2 + por mm6, mm5 ; 0 0 X X v2 v1 v0 v2 + movd [edi+8], mm6 ; move double to memory + sub esi, 6 + sub edi, 12 + sub ecx, 2 + jnz loop_pass4 + EMMS + } + } + + sptr -= width_mmx*3; + dp -= width_mmx*6; + for (i = width; i; i--) + { + png_byte v[8]; + int j; + + png_memcpy(v, sptr, 3); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 3); + dp -= 3; + } + sptr -= 3; + } + } + } /* end of pixel_bytes == 3 */ + + else if (pixel_bytes == 1) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 2) << 2); + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub edi, 31 + sub esi, 3 +loop1_pass0: + movd mm0, [esi] ; X X X X v0 v1 v2 v3 + movq mm1, mm0 ; X X X X v0 v1 v2 v3 + punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 + movq mm2, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 + punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 + movq mm3, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 + punpckldq mm0, mm0 ; v3 v3 v3 v3 v3 v3 v3 v3 + punpckhdq mm3, mm3 ; v2 v2 v2 v2 v2 v2 v2 v2 + movq [edi], mm0 ; move to memory v3 + punpckhwd mm2, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 + movq [edi+8], mm3 ; move to memory v2 + movq mm4, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 + punpckldq mm2, mm2 ; v1 v1 v1 v1 v1 v1 v1 v1 + punpckhdq mm4, mm4 ; v0 v0 v0 v0 v0 v0 v0 v0 + movq [edi+16], mm2 ; move to memory v1 + movq [edi+24], mm4 ; move to memory v0 + sub esi, 4 + sub edi, 32 + sub ecx, 4 + jnz loop1_pass0 + EMMS + } + } + + sptr -= width_mmx; + dp -= width_mmx*8; + for (i = width; i; i--) + { + int j; + + /* I simplified this part in version 1.0.4e + * here and in several other instances where + * pixel_bytes == 1 -- GR-P + * + * Original code: + * + * png_byte v[8]; + * png_memcpy(v, sptr, pixel_bytes); + * for (j = 0; j < png_pass_inc[pass]; j++) + * { + * png_memcpy(dp, v, pixel_bytes); + * dp -= pixel_bytes; + * } + * sptr -= pixel_bytes; + * + * Replacement code is in the next three lines: + */ + + for (j = 0; j < png_pass_inc[pass]; j++) + *dp-- = *sptr; + sptr--; + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 2) << 2); + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub edi, 15 + sub esi, 3 +loop1_pass2: + movd mm0, [esi] ; X X X X v0 v1 v2 v3 + punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 + movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 + punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 + punpckhwd mm1, mm1 ; v0 v0 v0 v0 v1 v1 v1 v1 + movq [edi], mm0 ; move to memory v2 and v3 + sub esi, 4 + movq [edi+8], mm1 ; move to memory v1 and v0 + sub edi, 16 + sub ecx, 4 + jnz loop1_pass2 + EMMS + } + } + + sptr -= width_mmx; + dp -= width_mmx*4; + for (i = width; i; i--) + { + int j; + + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp-- = *sptr; + } + sptr --; + } + } + else if (width) /* && ((pass == 4) || (pass == 5))) */ + { + int width_mmx = ((width >> 3) << 3); + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub edi, 15 + sub esi, 7 +loop1_pass4: + movq mm0, [esi] ; v0 v1 v2 v3 v4 v5 v6 v7 + movq mm1, mm0 ; v0 v1 v2 v3 v4 v5 v6 v7 + punpcklbw mm0, mm0 ; v4 v4 v5 v5 v6 v6 v7 v7 + //movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 + punpckhbw mm1, mm1 ;v0 v0 v1 v1 v2 v2 v3 v3 + movq [edi+8], mm1 ; move to memory v0 v1 v2 and v3 + sub esi, 8 + movq [edi], mm0 ; move to memory v4 v5 v6 and v7 + //sub esi, 4 + sub edi, 16 + sub ecx, 8 + jnz loop1_pass4 + EMMS + } + } + + sptr -= width_mmx; + dp -= width_mmx*2; + for (i = width; i; i--) + { + int j; + + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp-- = *sptr; + } + sptr --; + } + } + } /* end of pixel_bytes == 1 */ + + else if (pixel_bytes == 2) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 1) << 1); + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 2 + sub edi, 30 +loop2_pass0: + movd mm0, [esi] ; X X X X v1 v0 v3 v2 + punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 + punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 + movq [edi], mm0 + movq [edi + 8], mm0 + movq [edi + 16], mm1 + movq [edi + 24], mm1 + sub esi, 4 + sub edi, 32 + sub ecx, 2 + jnz loop2_pass0 + EMMS + } + } + + sptr -= (width_mmx*2 - 2); // sign fixed + dp -= (width_mmx*16 - 2); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 2 + sub edi, 14 +loop2_pass2: + movd mm0, [esi] ; X X X X v1 v0 v3 v2 + punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 + punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 + movq [edi], mm0 + sub esi, 4 + movq [edi + 8], mm1 + //sub esi, 4 + sub edi, 16 + sub ecx, 2 + jnz loop2_pass2 + EMMS + } + } + + sptr -= (width_mmx*2 - 2); // sign fixed + dp -= (width_mmx*8 - 2); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + else if (width) // pass == 4 or 5 + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 2 + sub edi, 6 +loop2_pass4: + movd mm0, [esi] ; X X X X v1 v0 v3 v2 + punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + sub esi, 4 + movq [edi], mm0 + sub edi, 8 + sub ecx, 2 + jnz loop2_pass4 + EMMS + } + } + + sptr -= (width_mmx*2 - 2); // sign fixed + dp -= (width_mmx*4 - 2); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + } /* end of pixel_bytes == 2 */ + + else if (pixel_bytes == 4) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 4 + sub edi, 60 +loop4_pass0: + movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 + movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 + punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 + punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 + movq [edi], mm0 + movq [edi + 8], mm0 + movq [edi + 16], mm0 + movq [edi + 24], mm0 + movq [edi+32], mm1 + movq [edi + 40], mm1 + movq [edi+ 48], mm1 + sub esi, 8 + movq [edi + 56], mm1 + sub edi, 64 + sub ecx, 2 + jnz loop4_pass0 + EMMS + } + } + + sptr -= (width_mmx*4 - 4); // sign fixed + dp -= (width_mmx*32 - 4); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 4 + sub edi, 28 +loop4_pass2: + movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 + movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 + punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 + punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 + movq [edi], mm0 + movq [edi + 8], mm0 + movq [edi+16], mm1 + movq [edi + 24], mm1 + sub esi, 8 + sub edi, 32 + sub ecx, 2 + jnz loop4_pass2 + EMMS + } + } + + sptr -= (width_mmx*4 - 4); // sign fixed + dp -= (width_mmx*16 - 4); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + else if (width) // pass == 4 or 5 + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 4 + sub edi, 12 +loop4_pass4: + movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 + movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 + punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 + punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 + movq [edi], mm0 + sub esi, 8 + movq [edi + 8], mm1 + sub edi, 16 + sub ecx, 2 + jnz loop4_pass4 + EMMS + } + } + + sptr -= (width_mmx*4 - 4); // sign fixed + dp -= (width_mmx*8 - 4); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + + } /* end of pixel_bytes == 4 */ + + else if (pixel_bytes == 6) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 6); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 6); + dp -= 6; + } + sptr -= 6; + } + } /* end of pixel_bytes == 6 */ + + else + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr-= pixel_bytes; + } + } + } /* end of mmx_supported */ + + else /* MMX not supported: use modified C code - takes advantage + * of inlining of memcpy for a constant */ + { + if (pixel_bytes == 1) + { + for (i = width; i; i--) + { + int j; + for (j = 0; j < png_pass_inc[pass]; j++) + *dp-- = *sptr; + sptr--; + } + } + else if (pixel_bytes == 3) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + else if (pixel_bytes == 2) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + else if (pixel_bytes == 4) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + else if (pixel_bytes == 6) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + else + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + + } /* end of MMX not supported */ + break; + } + } /* end switch (row_info->pixel_depth) */ + + row_info->width = final_width; + + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); + } + +} + +#endif /* PNG_READ_INTERLACING_SUPPORTED */ + + +// These variables are utilized in the functions below. They are declared +// globally here to ensure alignment on 8-byte boundaries. + +union uAll { + __int64 use; + double align; +} LBCarryMask = {0x0101010101010101}, + HBClearMask = {0x7f7f7f7f7f7f7f7f}, + ActiveMask, ActiveMask2, ActiveMaskEnd, ShiftBpp, ShiftRem; + + +// Optimized code for PNG Average filter decoder +void /* PRIVATE */ +png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row + , png_bytep prev_row) +{ + int bpp; + png_uint_32 FullLength; + png_uint_32 MMXLength; + //png_uint_32 len; + int diff; + + bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel + FullLength = row_info->rowbytes; // # of bytes to filter + _asm { + // Init address pointers and offset + mov edi, row // edi ==> Avg(x) + xor ebx, ebx // ebx ==> x + mov edx, edi + mov esi, prev_row // esi ==> Prior(x) + sub edx, bpp // edx ==> Raw(x-bpp) + + xor eax, eax + // Compute the Raw value for the first bpp bytes + // Raw(x) = Avg(x) + (Prior(x)/2) +davgrlp: + mov al, [esi + ebx] // Load al with Prior(x) + inc ebx + shr al, 1 // divide by 2 + add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx + cmp ebx, bpp + mov [edi+ebx-1], al // Write back Raw(x); + // mov does not affect flags; -1 to offset inc ebx + jb davgrlp + // get # of bytes to alignment + mov diff, edi // take start of row + add diff, ebx // add bpp + add diff, 0xf // add 7 + 8 to incr past alignment boundary + and diff, 0xfffffff8 // mask to alignment boundary + sub diff, edi // subtract from start ==> value ebx at alignment + jz davggo + // fix alignment + // Compute the Raw value for the bytes upto the alignment boundary + // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) + xor ecx, ecx +davglp1: + xor eax, eax + mov cl, [esi + ebx] // load cl with Prior(x) + mov al, [edx + ebx] // load al with Raw(x-bpp) + add ax, cx + inc ebx + shr ax, 1 // divide by 2 + add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx + cmp ebx, diff // Check if at alignment boundary + mov [edi+ebx-1], al // Write back Raw(x); + // mov does not affect flags; -1 to offset inc ebx + jb davglp1 // Repeat until at alignment boundary +davggo: + mov eax, FullLength + mov ecx, eax + sub eax, ebx // subtract alignment fix + and eax, 0x00000007 // calc bytes over mult of 8 + sub ecx, eax // drop over bytes from original length + mov MMXLength, ecx + } // end _asm block + // Now do the math for the rest of the row + switch ( bpp ) + { + case 3: + { + ActiveMask.use = 0x0000000000ffffff; + ShiftBpp.use = 24; // == 3 * 8 + ShiftRem.use = 40; // == 64 - 24 + _asm { + // Re-init address pointers and offset + movq mm7, ActiveMask + mov ebx, diff // ebx ==> x = offset to alignment boundary + movq mm5, LBCarryMask + mov edi, row // edi ==> Avg(x) + movq mm4, HBClearMask + mov esi, prev_row // esi ==> Prior(x) + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes + // (we correct position in loop below) +davg3lp: + movq mm0, [edi + ebx] // Load mm0 with Avg(x) + // Add (Prev_row/2) to Average + movq mm3, mm5 + psrlq mm2, ShiftRem // Correct position Raw(x-bpp) data + movq mm1, [esi + ebx] // Load mm1 with Prior(x) + movq mm6, mm7 + pand mm3, mm1 // get lsb for each prev_row byte + psrlq mm1, 1 // divide prev_row bytes by 2 + pand mm1, mm4 // clear invalid bit 7 of each byte + paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte + // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 1 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active + // byte + // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry + psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 3-5 + movq mm2, mm0 // mov updated Raws to mm2 + psllq mm2, ShiftBpp // shift data to position correctly + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active + // byte + + // Add 3rd active group (Raw(x-bpp)/2) to Average with LBCarry + psllq mm6, ShiftBpp // shift the mm6 mask to cover the last two + // bytes + movq mm2, mm0 // mov updated Raws to mm2 + psllq mm2, ShiftBpp // shift data to position correctly + // Data only needs to be shifted once here to + // get the correct x-bpp offset. + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg + add ebx, 8 + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active + // byte + + // Now ready to write back to memory + movq [edi + ebx - 8], mm0 + // Move updated Raw(x) to use as Raw(x-bpp) for next loop + cmp ebx, MMXLength + movq mm2, mm0 // mov updated Raw(x) to mm2 + jb davg3lp + } // end _asm block + } + break; + + case 6: + case 4: + case 7: + case 5: + { + ActiveMask.use = 0xffffffffffffffff; // use shift below to clear + // appropriate inactive bytes + ShiftBpp.use = bpp << 3; + ShiftRem.use = 64 - ShiftBpp.use; + _asm { + movq mm4, HBClearMask + // Re-init address pointers and offset + mov ebx, diff // ebx ==> x = offset to alignment boundary + // Load ActiveMask and clear all bytes except for 1st active group + movq mm7, ActiveMask + mov edi, row // edi ==> Avg(x) + psrlq mm7, ShiftRem + mov esi, prev_row // esi ==> Prior(x) + movq mm6, mm7 + movq mm5, LBCarryMask + psllq mm6, ShiftBpp // Create mask for 2nd active group + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes + // (we correct position in loop below) +davg4lp: + movq mm0, [edi + ebx] + psrlq mm2, ShiftRem // shift data to position correctly + movq mm1, [esi + ebx] + // Add (Prev_row/2) to Average + movq mm3, mm5 + pand mm3, mm1 // get lsb for each prev_row byte + psrlq mm1, 1 // divide prev_row bytes by 2 + pand mm1, mm4 // clear invalid bit 7 of each byte + paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte + // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm7 // Leave only Active Group 1 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active + // byte + // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry + movq mm2, mm0 // mov updated Raws to mm2 + psllq mm2, ShiftBpp // shift data to position correctly + add ebx, 8 + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active + // byte + cmp ebx, MMXLength + // Now ready to write back to memory + movq [edi + ebx - 8], mm0 + // Prep Raw(x-bpp) for next loop + movq mm2, mm0 // mov updated Raws to mm2 + jb davg4lp + } // end _asm block + } + break; + case 2: + { + ActiveMask.use = 0x000000000000ffff; + ShiftBpp.use = 16; // == 2 * 8 [BUGFIX] + ShiftRem.use = 48; // == 64 - 16 [BUGFIX] + _asm { + // Load ActiveMask + movq mm7, ActiveMask + // Re-init address pointers and offset + mov ebx, diff // ebx ==> x = offset to alignment boundary + movq mm5, LBCarryMask + mov edi, row // edi ==> Avg(x) + movq mm4, HBClearMask + mov esi, prev_row // esi ==> Prior(x) + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes + // (we correct position in loop below) +davg2lp: + movq mm0, [edi + ebx] + psrlq mm2, ShiftRem // shift data to position correctly [BUGFIX] + movq mm1, [esi + ebx] + // Add (Prev_row/2) to Average + movq mm3, mm5 + pand mm3, mm1 // get lsb for each prev_row byte + psrlq mm1, 1 // divide prev_row bytes by 2 + pand mm1, mm4 // clear invalid bit 7 of each byte + movq mm6, mm7 + paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte + // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 1 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte + // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry + psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 2 & 3 + movq mm2, mm0 // mov updated Raws to mm2 + psllq mm2, ShiftBpp // shift data to position correctly + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte + + // Add rdd active group (Raw(x-bpp)/2) to Average with LBCarry + psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 4 & 5 + movq mm2, mm0 // mov updated Raws to mm2 + psllq mm2, ShiftBpp // shift data to position correctly + // Data only needs to be shifted once here to + // get the correct x-bpp offset. + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte + + // Add 4th active group (Raw(x-bpp)/2) to Average with LBCarry + psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 6 & 7 + movq mm2, mm0 // mov updated Raws to mm2 + psllq mm2, ShiftBpp // shift data to position correctly + // Data only needs to be shifted once here to + // get the correct x-bpp offset. + add ebx, 8 + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte + + cmp ebx, MMXLength + // Now ready to write back to memory + movq [edi + ebx - 8], mm0 + // Prep Raw(x-bpp) for next loop + movq mm2, mm0 // mov updated Raws to mm2 + jb davg2lp + } // end _asm block + } + break; + + case 1: // bpp == 1 + { + _asm { + // Re-init address pointers and offset + mov ebx, diff // ebx ==> x = offset to alignment boundary + mov edi, row // edi ==> Avg(x) + cmp ebx, FullLength // Test if offset at end of array + jnb davg1end + // Do Paeth decode for remaining bytes + mov esi, prev_row // esi ==> Prior(x) + mov edx, edi + xor ecx, ecx // zero ecx before using cl & cx in loop below + sub edx, bpp // edx ==> Raw(x-bpp) +davg1lp: + // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) + xor eax, eax + mov cl, [esi + ebx] // load cl with Prior(x) + mov al, [edx + ebx] // load al with Raw(x-bpp) + add ax, cx + inc ebx + shr ax, 1 // divide by 2 + add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx + cmp ebx, FullLength // Check if at end of array + mov [edi+ebx-1], al // Write back Raw(x); + // mov does not affect flags; -1 to offset inc ebx + jb davg1lp +davg1end: + } // end _asm block + } + return; + + case 8: // bpp == 8 + { + _asm { + // Re-init address pointers and offset + mov ebx, diff // ebx ==> x = offset to alignment boundary + movq mm5, LBCarryMask + mov edi, row // edi ==> Avg(x) + movq mm4, HBClearMask + mov esi, prev_row // esi ==> Prior(x) + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes + // (NO NEED to correct position in loop below) +davg8lp: + movq mm0, [edi + ebx] + movq mm3, mm5 + movq mm1, [esi + ebx] + add ebx, 8 + pand mm3, mm1 // get lsb for each prev_row byte + psrlq mm1, 1 // divide prev_row bytes by 2 + pand mm3, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 + psrlq mm2, 1 // divide raw bytes by 2 + pand mm1, mm4 // clear invalid bit 7 of each byte + paddb mm0, mm3 // add LBCarrys to Avg for each byte + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte + paddb mm0, mm2 // add (Raw/2) to Avg for each byte + cmp ebx, MMXLength + movq [edi + ebx - 8], mm0 + movq mm2, mm0 // reuse as Raw(x-bpp) + jb davg8lp + } // end _asm block + } + break; + default: // bpp greater than 8 + { + _asm { + movq mm5, LBCarryMask + // Re-init address pointers and offset + mov ebx, diff // ebx ==> x = offset to alignment boundary + mov edi, row // edi ==> Avg(x) + movq mm4, HBClearMask + mov edx, edi + mov esi, prev_row // esi ==> Prior(x) + sub edx, bpp // edx ==> Raw(x-bpp) +davgAlp: + movq mm0, [edi + ebx] + movq mm3, mm5 + movq mm1, [esi + ebx] + pand mm3, mm1 // get lsb for each prev_row byte + movq mm2, [edx + ebx] + psrlq mm1, 1 // divide prev_row bytes by 2 + pand mm3, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 + psrlq mm2, 1 // divide raw bytes by 2 + pand mm1, mm4 // clear invalid bit 7 of each byte + paddb mm0, mm3 // add LBCarrys to Avg for each byte + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte + add ebx, 8 + paddb mm0, mm2 // add (Raw/2) to Avg for each byte + cmp ebx, MMXLength + movq [edi + ebx - 8], mm0 + jb davgAlp + } // end _asm block + } + break; + } // end switch ( bpp ) + + _asm { + // MMX acceleration complete now do clean-up + // Check if any remaining bytes left to decode + mov ebx, MMXLength // ebx ==> x = offset bytes remaining after MMX + mov edi, row // edi ==> Avg(x) + cmp ebx, FullLength // Test if offset at end of array + jnb davgend + // Do Paeth decode for remaining bytes + mov esi, prev_row // esi ==> Prior(x) + mov edx, edi + xor ecx, ecx // zero ecx before using cl & cx in loop below + sub edx, bpp // edx ==> Raw(x-bpp) +davglp2: + // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) + xor eax, eax + mov cl, [esi + ebx] // load cl with Prior(x) + mov al, [edx + ebx] // load al with Raw(x-bpp) + add ax, cx + inc ebx + shr ax, 1 // divide by 2 + add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx + cmp ebx, FullLength // Check if at end of array + mov [edi+ebx-1], al // Write back Raw(x); + // mov does not affect flags; -1 to offset inc ebx + jb davglp2 +davgend: + emms // End MMX instructions; prep for possible FP instrs. + } // end _asm block +} + +// Optimized code for PNG Paeth filter decoder +void /* PRIVATE */ +png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, + png_bytep prev_row) +{ + png_uint_32 FullLength; + png_uint_32 MMXLength; + //png_uint_32 len; + int bpp; + int diff; + //int ptemp; + int patemp, pbtemp, pctemp; + + bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel + FullLength = row_info->rowbytes; // # of bytes to filter + _asm + { + xor ebx, ebx // ebx ==> x offset + mov edi, row + xor edx, edx // edx ==> x-bpp offset + mov esi, prev_row + xor eax, eax + + // Compute the Raw value for the first bpp bytes + // Note: the formula works out to be always + // Paeth(x) = Raw(x) + Prior(x) where x < bpp +dpthrlp: + mov al, [edi + ebx] + add al, [esi + ebx] + inc ebx + cmp ebx, bpp + mov [edi + ebx - 1], al + jb dpthrlp + // get # of bytes to alignment + mov diff, edi // take start of row + add diff, ebx // add bpp + xor ecx, ecx + add diff, 0xf // add 7 + 8 to incr past alignment boundary + and diff, 0xfffffff8 // mask to alignment boundary + sub diff, edi // subtract from start ==> value ebx at alignment + jz dpthgo + // fix alignment +dpthlp1: + xor eax, eax + // pav = p - a = (a + b - c) - a = b - c + mov al, [esi + ebx] // load Prior(x) into al + mov cl, [esi + edx] // load Prior(x-bpp) into cl + sub eax, ecx // subtract Prior(x-bpp) + mov patemp, eax // Save pav for later use + xor eax, eax + // pbv = p - b = (a + b - c) - b = a - c + mov al, [edi + edx] // load Raw(x-bpp) into al + sub eax, ecx // subtract Prior(x-bpp) + mov ecx, eax + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + add eax, patemp // pcv = pav + pbv + // pc = abs(pcv) + test eax, 0x80000000 + jz dpthpca + neg eax // reverse sign of neg values +dpthpca: + mov pctemp, eax // save pc for later use + // pb = abs(pbv) + test ecx, 0x80000000 + jz dpthpba + neg ecx // reverse sign of neg values +dpthpba: + mov pbtemp, ecx // save pb for later use + // pa = abs(pav) + mov eax, patemp + test eax, 0x80000000 + jz dpthpaa + neg eax // reverse sign of neg values +dpthpaa: + mov patemp, eax // save pa for later use + // test if pa <= pb + cmp eax, ecx + jna dpthabb + // pa > pb; now test if pb <= pc + cmp ecx, pctemp + jna dpthbbc + // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + mov cl, [esi + edx] // load Prior(x-bpp) into cl + jmp dpthpaeth +dpthbbc: + // pb <= pc; Raw(x) = Paeth(x) + Prior(x) + mov cl, [esi + ebx] // load Prior(x) into cl + jmp dpthpaeth +dpthabb: + // pa <= pb; now test if pa <= pc + cmp eax, pctemp + jna dpthabc + // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + mov cl, [esi + edx] // load Prior(x-bpp) into cl + jmp dpthpaeth +dpthabc: + // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) + mov cl, [edi + edx] // load Raw(x-bpp) into cl +dpthpaeth: + inc ebx + inc edx + // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 + add [edi + ebx - 1], cl + cmp ebx, diff + jb dpthlp1 +dpthgo: + mov ecx, FullLength + mov eax, ecx + sub eax, ebx // subtract alignment fix + and eax, 0x00000007 // calc bytes over mult of 8 + sub ecx, eax // drop over bytes from original length + mov MMXLength, ecx + } // end _asm block + // Now do the math for the rest of the row + switch ( bpp ) + { + case 3: + { + ActiveMask.use = 0x0000000000ffffff; + ActiveMaskEnd.use = 0xffff000000000000; + ShiftBpp.use = 24; // == bpp(3) * 8 + ShiftRem.use = 40; // == 64 - 24 + _asm + { + mov ebx, diff + mov edi, row + mov esi, prev_row + pxor mm0, mm0 + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm1, [edi+ebx-8] +dpth3lp: + psrlq mm1, ShiftRem // shift last 3 bytes to 1st 3 bytes + movq mm2, [esi + ebx] // load b=Prior(x) + punpcklbw mm1, mm0 // Unpack High bytes of a + movq mm3, [esi+ebx-8] // Prep c=Prior(x-bpp) bytes + punpcklbw mm2, mm0 // Unpack High bytes of b + psrlq mm3, ShiftRem // shift last 3 bytes to 1st 3 bytes + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + punpcklbw mm3, mm0 // Unpack High bytes of c + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + paddw mm6, mm5 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + psubw mm4, mm0 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm5, mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, [esi + ebx] // load c=Prior(x-bpp) + pand mm7, ActiveMask + movq mm2, mm3 // load b=Prior(x) step 1 + paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) + punpcklbw mm3, mm0 // Unpack High bytes of c + movq [edi + ebx], mm7 // write back updated value + movq mm1, mm7 // Now mm1 will be used as Raw(x-bpp) + // Now do Paeth for 2nd set of bytes (3-5) + psrlq mm2, ShiftBpp // load b=Prior(x) step 2 + punpcklbw mm1, mm0 // Unpack High bytes of a + pxor mm7, mm7 + punpcklbw mm2, mm0 // Unpack High bytes of b + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + psubw mm5, mm3 + psubw mm4, mm3 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = + // pav + pbv = pbv + pav + movq mm6, mm5 + paddw mm6, mm4 + + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm5 // Create mask pbv bytes < 0 + pcmpgtw mm7, mm4 // Create mask pav bytes < 0 + pand mm0, mm5 // Only pbv bytes < 0 in mm0 + pand mm7, mm4 // Only pav bytes < 0 in mm7 + psubw mm5, mm0 + psubw mm4, mm7 + psubw mm5, mm0 + psubw mm4, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + movq mm2, [esi + ebx] // load b=Prior(x) + pand mm3, mm7 + pandn mm7, mm0 + pxor mm1, mm1 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, mm2 // load c=Prior(x-bpp) step 1 + pand mm7, ActiveMask + punpckhbw mm2, mm0 // Unpack High bytes of b + psllq mm7, ShiftBpp // Shift bytes to 2nd group of 3 bytes + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) + psllq mm3, ShiftBpp // load c=Prior(x-bpp) step 2 + movq [edi + ebx], mm7 // write back updated value + movq mm1, mm7 + punpckhbw mm3, mm0 // Unpack High bytes of c + psllq mm1, ShiftBpp // Shift bytes + // Now mm1 will be used as Raw(x-bpp) + // Now do Paeth for 3rd, and final, set of bytes (6-7) + pxor mm7, mm7 + punpckhbw mm1, mm0 // Unpack High bytes of a + psubw mm4, mm3 + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + pxor mm0, mm0 + paddw mm6, mm5 + + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + pandn mm0, mm1 + pandn mm7, mm4 + paddw mm0, mm2 + paddw mm7, mm5 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm1, mm1 + packuswb mm1, mm7 + // Step ebx to next set of 8 bytes and repeat loop til done + add ebx, 8 + pand mm1, ActiveMaskEnd + paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) + + cmp ebx, MMXLength + pxor mm0, mm0 // pxor does not affect flags + movq [edi + ebx - 8], mm1 // write back updated value + // mm1 will be used as Raw(x-bpp) next loop + // mm3 ready to be used as Prior(x-bpp) next loop + jb dpth3lp + } // end _asm block + } + break; + + case 6: + case 7: + case 5: + { + ActiveMask.use = 0x00000000ffffffff; + ActiveMask2.use = 0xffffffff00000000; + ShiftBpp.use = bpp << 3; // == bpp * 8 + ShiftRem.use = 64 - ShiftBpp.use; + _asm + { + mov ebx, diff + mov edi, row + mov esi, prev_row + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm1, [edi+ebx-8] + pxor mm0, mm0 +dpth6lp: + // Must shift to position Raw(x-bpp) data + psrlq mm1, ShiftRem + // Do first set of 4 bytes + movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes + punpcklbw mm1, mm0 // Unpack Low bytes of a + movq mm2, [esi + ebx] // load b=Prior(x) + punpcklbw mm2, mm0 // Unpack Low bytes of b + // Must shift to position Prior(x-bpp) data + psrlq mm3, ShiftRem + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + punpcklbw mm3, mm0 // Unpack Low bytes of c + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + paddw mm6, mm5 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + psubw mm4, mm0 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm5, mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, [esi + ebx - 8] // load c=Prior(x-bpp) + pand mm7, ActiveMask + psrlq mm3, ShiftRem + movq mm2, [esi + ebx] // load b=Prior(x) step 1 + paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) + movq mm6, mm2 + movq [edi + ebx], mm7 // write back updated value + movq mm1, [edi+ebx-8] + psllq mm6, ShiftBpp + movq mm5, mm7 + psrlq mm1, ShiftRem + por mm3, mm6 + psllq mm5, ShiftBpp + punpckhbw mm3, mm0 // Unpack High bytes of c + por mm1, mm5 + // Do second set of 4 bytes + punpckhbw mm2, mm0 // Unpack High bytes of b + punpckhbw mm1, mm0 // Unpack High bytes of a + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + paddw mm6, mm5 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + psubw mm4, mm0 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm5, mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + pxor mm1, mm1 + paddw mm7, mm3 + pxor mm0, mm0 + // Step ex to next set of 8 bytes and repeat loop til done + add ebx, 8 + packuswb mm1, mm7 + paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) + cmp ebx, MMXLength + movq [edi + ebx - 8], mm1 // write back updated value + // mm1 will be used as Raw(x-bpp) next loop + jb dpth6lp + } // end _asm block + } + break; + + case 4: + { + ActiveMask.use = 0x00000000ffffffff; + _asm { + mov ebx, diff + mov edi, row + mov esi, prev_row + pxor mm0, mm0 + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm1, [edi+ebx-8] // Only time should need to read + // a=Raw(x-bpp) bytes +dpth4lp: + // Do first set of 4 bytes + movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes + punpckhbw mm1, mm0 // Unpack Low bytes of a + movq mm2, [esi + ebx] // load b=Prior(x) + punpcklbw mm2, mm0 // Unpack High bytes of b + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + punpckhbw mm3, mm0 // Unpack High bytes of c + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + paddw mm6, mm5 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + psubw mm4, mm0 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm5, mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, [esi + ebx] // load c=Prior(x-bpp) + pand mm7, ActiveMask + movq mm2, mm3 // load b=Prior(x) step 1 + paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) + punpcklbw mm3, mm0 // Unpack High bytes of c + movq [edi + ebx], mm7 // write back updated value + movq mm1, mm7 // Now mm1 will be used as Raw(x-bpp) + // Do second set of 4 bytes + punpckhbw mm2, mm0 // Unpack Low bytes of b + punpcklbw mm1, mm0 // Unpack Low bytes of a + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + paddw mm6, mm5 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + psubw mm4, mm0 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm5, mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + pxor mm1, mm1 + paddw mm7, mm3 + pxor mm0, mm0 + // Step ex to next set of 8 bytes and repeat loop til done + add ebx, 8 + packuswb mm1, mm7 + paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) + cmp ebx, MMXLength + movq [edi + ebx - 8], mm1 // write back updated value + // mm1 will be used as Raw(x-bpp) next loop + jb dpth4lp + } // end _asm block + } + break; + case 8: // bpp == 8 + { + ActiveMask.use = 0x00000000ffffffff; + _asm { + mov ebx, diff + mov edi, row + mov esi, prev_row + pxor mm0, mm0 + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm1, [edi+ebx-8] // Only time should need to read + // a=Raw(x-bpp) bytes +dpth8lp: + // Do first set of 4 bytes + movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes + punpcklbw mm1, mm0 // Unpack Low bytes of a + movq mm2, [esi + ebx] // load b=Prior(x) + punpcklbw mm2, mm0 // Unpack Low bytes of b + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + punpcklbw mm3, mm0 // Unpack Low bytes of c + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + paddw mm6, mm5 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + psubw mm4, mm0 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm5, mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes + pand mm7, ActiveMask + movq mm2, [esi + ebx] // load b=Prior(x) + paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) + punpckhbw mm3, mm0 // Unpack High bytes of c + movq [edi + ebx], mm7 // write back updated value + movq mm1, [edi+ebx-8] // read a=Raw(x-bpp) bytes + + // Do second set of 4 bytes + punpckhbw mm2, mm0 // Unpack High bytes of b + punpckhbw mm1, mm0 // Unpack High bytes of a + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + paddw mm6, mm5 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + psubw mm4, mm0 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm5, mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + pxor mm1, mm1 + paddw mm7, mm3 + pxor mm0, mm0 + // Step ex to next set of 8 bytes and repeat loop til done + add ebx, 8 + packuswb mm1, mm7 + paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) + cmp ebx, MMXLength + movq [edi + ebx - 8], mm1 // write back updated value + // mm1 will be used as Raw(x-bpp) next loop + jb dpth8lp + } // end _asm block + } + break; + + case 1: // bpp = 1 + case 2: // bpp = 2 + default: // bpp > 8 + { + _asm { + mov ebx, diff + cmp ebx, FullLength + jnb dpthdend + mov edi, row + mov esi, prev_row + // Do Paeth decode for remaining bytes + mov edx, ebx + xor ecx, ecx // zero ecx before using cl & cx in loop below + sub edx, bpp // Set edx = ebx - bpp +dpthdlp: + xor eax, eax + // pav = p - a = (a + b - c) - a = b - c + mov al, [esi + ebx] // load Prior(x) into al + mov cl, [esi + edx] // load Prior(x-bpp) into cl + sub eax, ecx // subtract Prior(x-bpp) + mov patemp, eax // Save pav for later use + xor eax, eax + // pbv = p - b = (a + b - c) - b = a - c + mov al, [edi + edx] // load Raw(x-bpp) into al + sub eax, ecx // subtract Prior(x-bpp) + mov ecx, eax + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + add eax, patemp // pcv = pav + pbv + // pc = abs(pcv) + test eax, 0x80000000 + jz dpthdpca + neg eax // reverse sign of neg values +dpthdpca: + mov pctemp, eax // save pc for later use + // pb = abs(pbv) + test ecx, 0x80000000 + jz dpthdpba + neg ecx // reverse sign of neg values +dpthdpba: + mov pbtemp, ecx // save pb for later use + // pa = abs(pav) + mov eax, patemp + test eax, 0x80000000 + jz dpthdpaa + neg eax // reverse sign of neg values +dpthdpaa: + mov patemp, eax // save pa for later use + // test if pa <= pb + cmp eax, ecx + jna dpthdabb + // pa > pb; now test if pb <= pc + cmp ecx, pctemp + jna dpthdbbc + // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + mov cl, [esi + edx] // load Prior(x-bpp) into cl + jmp dpthdpaeth +dpthdbbc: + // pb <= pc; Raw(x) = Paeth(x) + Prior(x) + mov cl, [esi + ebx] // load Prior(x) into cl + jmp dpthdpaeth +dpthdabb: + // pa <= pb; now test if pa <= pc + cmp eax, pctemp + jna dpthdabc + // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + mov cl, [esi + edx] // load Prior(x-bpp) into cl + jmp dpthdpaeth +dpthdabc: + // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) + mov cl, [edi + edx] // load Raw(x-bpp) into cl +dpthdpaeth: + inc ebx + inc edx + // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 + add [edi + ebx - 1], cl + cmp ebx, FullLength + jb dpthdlp +dpthdend: + } // end _asm block + } + return; // No need to go further with this one + } // end switch ( bpp ) + _asm + { + // MMX acceleration complete now do clean-up + // Check if any remaining bytes left to decode + mov ebx, MMXLength + cmp ebx, FullLength + jnb dpthend + mov edi, row + mov esi, prev_row + // Do Paeth decode for remaining bytes + mov edx, ebx + xor ecx, ecx // zero ecx before using cl & cx in loop below + sub edx, bpp // Set edx = ebx - bpp +dpthlp2: + xor eax, eax + // pav = p - a = (a + b - c) - a = b - c + mov al, [esi + ebx] // load Prior(x) into al + mov cl, [esi + edx] // load Prior(x-bpp) into cl + sub eax, ecx // subtract Prior(x-bpp) + mov patemp, eax // Save pav for later use + xor eax, eax + // pbv = p - b = (a + b - c) - b = a - c + mov al, [edi + edx] // load Raw(x-bpp) into al + sub eax, ecx // subtract Prior(x-bpp) + mov ecx, eax + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + add eax, patemp // pcv = pav + pbv + // pc = abs(pcv) + test eax, 0x80000000 + jz dpthpca2 + neg eax // reverse sign of neg values +dpthpca2: + mov pctemp, eax // save pc for later use + // pb = abs(pbv) + test ecx, 0x80000000 + jz dpthpba2 + neg ecx // reverse sign of neg values +dpthpba2: + mov pbtemp, ecx // save pb for later use + // pa = abs(pav) + mov eax, patemp + test eax, 0x80000000 + jz dpthpaa2 + neg eax // reverse sign of neg values +dpthpaa2: + mov patemp, eax // save pa for later use + // test if pa <= pb + cmp eax, ecx + jna dpthabb2 + // pa > pb; now test if pb <= pc + cmp ecx, pctemp + jna dpthbbc2 + // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + mov cl, [esi + edx] // load Prior(x-bpp) into cl + jmp dpthpaeth2 +dpthbbc2: + // pb <= pc; Raw(x) = Paeth(x) + Prior(x) + mov cl, [esi + ebx] // load Prior(x) into cl + jmp dpthpaeth2 +dpthabb2: + // pa <= pb; now test if pa <= pc + cmp eax, pctemp + jna dpthabc2 + // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + mov cl, [esi + edx] // load Prior(x-bpp) into cl + jmp dpthpaeth2 +dpthabc2: + // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) + mov cl, [edi + edx] // load Raw(x-bpp) into cl +dpthpaeth2: + inc ebx + inc edx + // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 + add [edi + ebx - 1], cl + cmp ebx, FullLength + jb dpthlp2 +dpthend: + emms // End MMX instructions; prep for possible FP instrs. + } // end _asm block +} + +// Optimized code for PNG Sub filter decoder +void /* PRIVATE */ +png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) +{ + //int test; + int bpp; + png_uint_32 FullLength; + png_uint_32 MMXLength; + int diff; + + bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel + FullLength = row_info->rowbytes - bpp; // # of bytes to filter + _asm { + mov edi, row + mov esi, edi // lp = row + add edi, bpp // rp = row + bpp + xor eax, eax + // get # of bytes to alignment + mov diff, edi // take start of row + add diff, 0xf // add 7 + 8 to incr past + // alignment boundary + xor ebx, ebx + and diff, 0xfffffff8 // mask to alignment boundary + sub diff, edi // subtract from start ==> value + // ebx at alignment + jz dsubgo + // fix alignment +dsublp1: + mov al, [esi+ebx] + add [edi+ebx], al + inc ebx + cmp ebx, diff + jb dsublp1 +dsubgo: + mov ecx, FullLength + mov edx, ecx + sub edx, ebx // subtract alignment fix + and edx, 0x00000007 // calc bytes over mult of 8 + sub ecx, edx // drop over bytes from length + mov MMXLength, ecx + } // end _asm block + + // Now do the math for the rest of the row + switch ( bpp ) + { + case 3: + { + ActiveMask.use = 0x0000ffffff000000; + ShiftBpp.use = 24; // == 3 * 8 + ShiftRem.use = 40; // == 64 - 24 + _asm { + mov edi, row + movq mm7, ActiveMask // Load ActiveMask for 2nd active byte group + mov esi, edi // lp = row + add edi, bpp // rp = row + bpp + movq mm6, mm7 + mov ebx, diff + psllq mm6, ShiftBpp // Move mask in mm6 to cover 3rd active + // byte group + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm1, [edi+ebx-8] +dsub3lp: + psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes + // no need for mask; shift clears inactive bytes + // Add 1st active group + movq mm0, [edi+ebx] + paddb mm0, mm1 + // Add 2nd active group + movq mm1, mm0 // mov updated Raws to mm1 + psllq mm1, ShiftBpp // shift data to position correctly + pand mm1, mm7 // mask to use only 2nd active group + paddb mm0, mm1 + // Add 3rd active group + movq mm1, mm0 // mov updated Raws to mm1 + psllq mm1, ShiftBpp // shift data to position correctly + pand mm1, mm6 // mask to use only 3rd active group + add ebx, 8 + paddb mm0, mm1 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 // Write updated Raws back to array + // Prep for doing 1st add at top of loop + movq mm1, mm0 + jb dsub3lp + } // end _asm block + } + break; + + case 1: + { + // Placed here just in case this is a duplicate of the + // non-MMX code for the SUB filter in png_read_filter_row below + // + // png_bytep rp; + // png_bytep lp; + // png_uint_32 i; + // bpp = (row_info->pixel_depth + 7) >> 3; + // for (i = (png_uint_32)bpp, rp = row + bpp, lp = row; + // i < row_info->rowbytes; i++, rp++, lp++) + // { + // *rp = (png_byte)(((int)(*rp) + (int)(*lp)) & 0xff); + // } + _asm { + mov ebx, diff + mov edi, row + cmp ebx, FullLength + jnb dsub1end + mov esi, edi // lp = row + xor eax, eax + add edi, bpp // rp = row + bpp +dsub1lp: + mov al, [esi+ebx] + add [edi+ebx], al + inc ebx + cmp ebx, FullLength + jb dsub1lp +dsub1end: + } // end _asm block + } + return; + + case 6: + case 7: + case 4: + case 5: + { + ShiftBpp.use = bpp << 3; + ShiftRem.use = 64 - ShiftBpp.use; + _asm { + mov edi, row + mov ebx, diff + mov esi, edi // lp = row + add edi, bpp // rp = row + bpp + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm1, [edi+ebx-8] +dsub4lp: + psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes + // no need for mask; shift clears inactive bytes + movq mm0, [edi+ebx] + paddb mm0, mm1 + // Add 2nd active group + movq mm1, mm0 // mov updated Raws to mm1 + psllq mm1, ShiftBpp // shift data to position correctly + // there is no need for any mask + // since shift clears inactive bits/bytes + add ebx, 8 + paddb mm0, mm1 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 + movq mm1, mm0 // Prep for doing 1st add at top of loop + jb dsub4lp + } // end _asm block + } + break; + + case 2: + { + ActiveMask.use = 0x00000000ffff0000; + ShiftBpp.use = 16; // == 2 * 8 + ShiftRem.use = 48; // == 64 - 16 + _asm { + movq mm7, ActiveMask // Load ActiveMask for 2nd active byte group + mov ebx, diff + movq mm6, mm7 + mov edi, row + psllq mm6, ShiftBpp // Move mask in mm6 to cover 3rd active + // byte group + mov esi, edi // lp = row + movq mm5, mm6 + add edi, bpp // rp = row + bpp + psllq mm5, ShiftBpp // Move mask in mm5 to cover 4th active + // byte group + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm1, [edi+ebx-8] +dsub2lp: + // Add 1st active group + psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes + // no need for mask; shift clears inactive + // bytes + movq mm0, [edi+ebx] + paddb mm0, mm1 + // Add 2nd active group + movq mm1, mm0 // mov updated Raws to mm1 + psllq mm1, ShiftBpp // shift data to position correctly + pand mm1, mm7 // mask to use only 2nd active group + paddb mm0, mm1 + // Add 3rd active group + movq mm1, mm0 // mov updated Raws to mm1 + psllq mm1, ShiftBpp // shift data to position correctly + pand mm1, mm6 // mask to use only 3rd active group + paddb mm0, mm1 + // Add 4th active group + movq mm1, mm0 // mov updated Raws to mm1 + psllq mm1, ShiftBpp // shift data to position correctly + pand mm1, mm5 // mask to use only 4th active group + add ebx, 8 + paddb mm0, mm1 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 // Write updated Raws back to array + movq mm1, mm0 // Prep for doing 1st add at top of loop + jb dsub2lp + } // end _asm block + } + break; + case 8: + { + _asm { + mov edi, row + mov ebx, diff + mov esi, edi // lp = row + add edi, bpp // rp = row + bpp + mov ecx, MMXLength + movq mm7, [edi+ebx-8] // PRIME the pump (load the first + // Raw(x-bpp) data set + and ecx, 0x0000003f // calc bytes over mult of 64 +dsub8lp: + movq mm0, [edi+ebx] // Load Sub(x) for 1st 8 bytes + paddb mm0, mm7 + movq mm1, [edi+ebx+8] // Load Sub(x) for 2nd 8 bytes + movq [edi+ebx], mm0 // Write Raw(x) for 1st 8 bytes + // Now mm0 will be used as Raw(x-bpp) for + // the 2nd group of 8 bytes. This will be + // repeated for each group of 8 bytes with + // the 8th group being used as the Raw(x-bpp) + // for the 1st group of the next loop. + paddb mm1, mm0 + movq mm2, [edi+ebx+16] // Load Sub(x) for 3rd 8 bytes + movq [edi+ebx+8], mm1 // Write Raw(x) for 2nd 8 bytes + paddb mm2, mm1 + movq mm3, [edi+ebx+24] // Load Sub(x) for 4th 8 bytes + movq [edi+ebx+16], mm2 // Write Raw(x) for 3rd 8 bytes + paddb mm3, mm2 + movq mm4, [edi+ebx+32] // Load Sub(x) for 5th 8 bytes + movq [edi+ebx+24], mm3 // Write Raw(x) for 4th 8 bytes + paddb mm4, mm3 + movq mm5, [edi+ebx+40] // Load Sub(x) for 6th 8 bytes + movq [edi+ebx+32], mm4 // Write Raw(x) for 5th 8 bytes + paddb mm5, mm4 + movq mm6, [edi+ebx+48] // Load Sub(x) for 7th 8 bytes + movq [edi+ebx+40], mm5 // Write Raw(x) for 6th 8 bytes + paddb mm6, mm5 + movq mm7, [edi+ebx+56] // Load Sub(x) for 8th 8 bytes + movq [edi+ebx+48], mm6 // Write Raw(x) for 7th 8 bytes + add ebx, 64 + paddb mm7, mm6 + cmp ebx, ecx + movq [edi+ebx-8], mm7 // Write Raw(x) for 8th 8 bytes + jb dsub8lp + cmp ebx, MMXLength + jnb dsub8lt8 +dsub8lpA: + movq mm0, [edi+ebx] + add ebx, 8 + paddb mm0, mm7 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 // use -8 to offset early add to ebx + movq mm7, mm0 // Move calculated Raw(x) data to mm1 to + // be the new Raw(x-bpp) for the next loop + jb dsub8lpA +dsub8lt8: + } // end _asm block + } + break; + + default: // bpp greater than 8 bytes + { + _asm { + mov ebx, diff + mov edi, row + mov esi, edi // lp = row + add edi, bpp // rp = row + bpp +dsubAlp: + movq mm0, [edi+ebx] + movq mm1, [esi+ebx] + add ebx, 8 + paddb mm0, mm1 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 // mov does not affect flags; -8 to offset + // add ebx + jb dsubAlp + } // end _asm block + } + break; + + } // end switch ( bpp ) + + _asm { + mov ebx, MMXLength + mov edi, row + cmp ebx, FullLength + jnb dsubend + mov esi, edi // lp = row + xor eax, eax + add edi, bpp // rp = row + bpp +dsublp2: + mov al, [esi+ebx] + add [edi+ebx], al + inc ebx + cmp ebx, FullLength + jb dsublp2 +dsubend: + emms // End MMX instructions; prep for possible FP instrs. + } // end _asm block +} + +// Optimized code for PNG Up filter decoder +void /* PRIVATE */ +png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, + png_bytep prev_row) +{ + png_uint_32 len; + len = row_info->rowbytes; // # of bytes to filter + _asm { + mov edi, row + // get # of bytes to alignment + mov ecx, edi + xor ebx, ebx + add ecx, 0x7 + xor eax, eax + and ecx, 0xfffffff8 + mov esi, prev_row + sub ecx, edi + jz dupgo + // fix alignment +duplp1: + mov al, [edi+ebx] + add al, [esi+ebx] + inc ebx + cmp ebx, ecx + mov [edi + ebx-1], al // mov does not affect flags; -1 to offset inc ebx + jb duplp1 +dupgo: + mov ecx, len + mov edx, ecx + sub edx, ebx // subtract alignment fix + and edx, 0x0000003f // calc bytes over mult of 64 + sub ecx, edx // drop over bytes from length + // Unrolled loop - use all MMX registers and interleave to reduce + // number of branch instructions (loops) and reduce partial stalls +duploop: + movq mm1, [esi+ebx] + movq mm0, [edi+ebx] + movq mm3, [esi+ebx+8] + paddb mm0, mm1 + movq mm2, [edi+ebx+8] + movq [edi+ebx], mm0 + paddb mm2, mm3 + movq mm5, [esi+ebx+16] + movq [edi+ebx+8], mm2 + movq mm4, [edi+ebx+16] + movq mm7, [esi+ebx+24] + paddb mm4, mm5 + movq mm6, [edi+ebx+24] + movq [edi+ebx+16], mm4 + paddb mm6, mm7 + movq mm1, [esi+ebx+32] + movq [edi+ebx+24], mm6 + movq mm0, [edi+ebx+32] + movq mm3, [esi+ebx+40] + paddb mm0, mm1 + movq mm2, [edi+ebx+40] + movq [edi+ebx+32], mm0 + paddb mm2, mm3 + movq mm5, [esi+ebx+48] + movq [edi+ebx+40], mm2 + movq mm4, [edi+ebx+48] + movq mm7, [esi+ebx+56] + paddb mm4, mm5 + movq mm6, [edi+ebx+56] + movq [edi+ebx+48], mm4 + add ebx, 64 + paddb mm6, mm7 + cmp ebx, ecx + movq [edi+ebx-8], mm6 // (+56)movq does not affect flags; + // -8 to offset add ebx + jb duploop + + cmp edx, 0 // Test for bytes over mult of 64 + jz dupend + + + // 2 lines added by lcreeve at netins.net + // (mail 11 Jul 98 in png-implement list) + cmp edx, 8 //test for less than 8 bytes + jb duplt8 + + + add ecx, edx + and edx, 0x00000007 // calc bytes over mult of 8 + sub ecx, edx // drop over bytes from length + jz duplt8 + // Loop using MMX registers mm0 & mm1 to update 8 bytes simultaneously +duplpA: + movq mm1, [esi+ebx] + movq mm0, [edi+ebx] + add ebx, 8 + paddb mm0, mm1 + cmp ebx, ecx + movq [edi+ebx-8], mm0 // movq does not affect flags; -8 to offset add ebx + jb duplpA + cmp edx, 0 // Test for bytes over mult of 8 + jz dupend +duplt8: + xor eax, eax + add ecx, edx // move over byte count into counter + // Loop using x86 registers to update remaining bytes +duplp2: + mov al, [edi + ebx] + add al, [esi + ebx] + inc ebx + cmp ebx, ecx + mov [edi + ebx-1], al // mov does not affect flags; -1 to offset inc ebx + jb duplp2 +dupend: + // Conversion of filtered row completed + emms // End MMX instructions; prep for possible FP instrs. + } // end _asm block +} + + +// Optimized png_read_filter_row routines +void /* PRIVATE */ +png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep + row, png_bytep prev_row, int filter) +{ +#ifdef PNG_DEBUG + char filnm[10]; +#endif + + if (mmx_supported == 2) { +#if !defined(PNG_1_0_X) + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); +#endif + png_mmx_support(); + } + +#ifdef PNG_DEBUG + png_debug(1, "in png_read_filter_row\n"); + switch (filter) + { + case 0: sprintf(filnm, "none"); + break; +#if !defined(PNG_1_0_X) + case 1: sprintf(filnm, "sub-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : "x86"); + break; + case 2: sprintf(filnm, "up-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : "x86"); + break; + case 3: sprintf(filnm, "avg-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : "x86"); + break; + case 4: sprintf(filnm, "Paeth-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX":"x86"); + break; +#else + case 1: sprintf(filnm, "sub"); + break; + case 2: sprintf(filnm, "up"); + break; + case 3: sprintf(filnm, "avg"); + break; + case 4: sprintf(filnm, "Paeth"); + break; +#endif + default: sprintf(filnm, "unknw"); + break; + } + png_debug2(0,"row=%5d, %s, ", png_ptr->row_number, filnm); + png_debug2(0, "pd=%2d, b=%d, ", (int)row_info->pixel_depth, + (int)((row_info->pixel_depth + 7) >> 3)); + png_debug1(0,"len=%8d, ", row_info->rowbytes); +#endif /* PNG_DEBUG */ + + switch (filter) + { + case PNG_FILTER_VALUE_NONE: + break; + + case PNG_FILTER_VALUE_SUB: + { +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (mmx_supported) +#endif + { + png_read_filter_row_mmx_sub(row_info, row); + } + else + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_bytep rp = row + bpp; + png_bytep lp = row; + + for (i = bpp; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); + rp++; + } + } + break; + } + + case PNG_FILTER_VALUE_UP: + { +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (mmx_supported) +#endif + { + png_read_filter_row_mmx_up(row_info, row, prev_row); + } + else + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_bytep rp = row; + png_bytep pp = prev_row; + + for (i = 0; i < istop; ++i) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + } + break; + } + + case PNG_FILTER_VALUE_AVG: + { +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (mmx_supported) +#endif + { + png_read_filter_row_mmx_avg(row_info, row, prev_row); + } + else + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop = row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++) >> 1)) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++ + *lp++) >> 1)) & 0xff); + rp++; + } + } + break; + } + + case PNG_FILTER_VALUE_PAETH: + { +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (mmx_supported) +#endif + { + png_read_filter_row_mmx_paeth(row_info, row, prev_row); + } + else + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_bytep cp = prev_row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop=row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) // use leftover rp,pp + { + int a, b, c, pa, pb, pc, p; + + a = *lp++; + b = *pp++; + c = *cp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + /* + if (pa <= pb && pa <= pc) + p = a; + else if (pb <= pc) + p = b; + else + p = c; + */ + + p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; + + *rp = (png_byte)(((int)(*rp) + p) & 0xff); + rp++; + } + } + break; + } + + default: + png_warning(png_ptr, "Ignoring bad row filter type"); + *row=0; + break; + } +} + +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED && PNG_USE_PNGVCRD */ diff --git a/src/dep/src/irrlicht/libpng/pngwio.c b/src/dep/src/irrlicht/libpng/pngwio.c index f40bccb..4d9d57e 100644 --- a/src/dep/src/irrlicht/libpng/pngwio.c +++ b/src/dep/src/irrlicht/libpng/pngwio.c @@ -1,234 +1,234 @@ - -/* pngwio.c - functions for data output - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all output. Users who need - * special handling are expected to write functions that have the same - * arguments as these and perform similar functions, but that possibly - * use different output methods. Note that you shouldn't change these - * functions, but rather write replacement functions and then change - * them at run time with png_set_write_fn(...). - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Write the data to whatever output you are using. The default routine - writes to a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered writes. This should never be asked - to write more than 64K on a 16 bit machine. */ - -void /* PRIVATE */ -png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - if (png_ptr->write_data_fn != NULL ) - (*(png_ptr->write_data_fn))(png_ptr, data, length); - else - png_error(png_ptr, "Call to NULL write function"); -} - -#if !defined(PNG_NO_STDIO) -/* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -void PNGAPI -png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - - if(png_ptr == NULL) return; -#if defined(_WIN32_WCE) - if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); -#endif - if (check != length) - png_error(png_ptr, "Write Error"); -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -void PNGAPI -png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ - png_FILE_p io_ptr; - - if(png_ptr == NULL) return; - /* Check if data really is near. If so, use usual code. */ - near_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)near_data == data) - { -#if defined(_WIN32_WCE) - if ( !WriteFile(io_ptr, near_data, length, &check, NULL) ) - check = 0; -#else - check = fwrite(near_data, 1, length, io_ptr); -#endif - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t written, remaining, err; - check = 0; - remaining = length; - do - { - written = MIN(NEAR_BUF_SIZE, remaining); - png_memcpy(buf, data, written); /* copy far buffer to near buffer */ -#if defined(_WIN32_WCE) - if ( !WriteFile(io_ptr, buf, written, &err, NULL) ) - err = 0; -#else - err = fwrite(buf, 1, written, io_ptr); -#endif - if (err != written) - break; - else - check += err; - data += written; - remaining -= written; - } - while (remaining != 0); - } - if (check != length) - png_error(png_ptr, "Write Error"); -} - -#endif -#endif - -/* This function is called to output any data pending writing (normally - to disk). After png_flush is called, there should be no data pending - writing in any buffers. */ -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -void /* PRIVATE */ -png_flush(png_structp png_ptr) -{ - if (png_ptr->output_flush_fn != NULL) - (*(png_ptr->output_flush_fn))(png_ptr); -} - -#if !defined(PNG_NO_STDIO) -void PNGAPI -png_default_flush(png_structp png_ptr) -{ -#if !defined(_WIN32_WCE) - png_FILE_p io_ptr; -#endif - if(png_ptr == NULL) return; -#if !defined(_WIN32_WCE) - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -#endif -} -#endif -#endif - -/* This function allows the application to supply new output functions for - libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png output data structure - io_ptr - pointer to user supplied structure containing info about - the output functions. May be NULL. - write_data_fn - pointer to a new output function that takes as its - arguments a pointer to a png_struct, a pointer to - data to be written, and a 32-bit unsigned int that is - the number of bytes to be written. The new write - function should call png_error(png_ptr, "Error msg") - to exit and output any fatal error messages. - flush_data_fn - pointer to a new flush function that takes as its - arguments a pointer to a png_struct. After a call to - the flush function, there should be no data in any buffers - or pending transmission. If the output method doesn't do - any buffering of ouput, a function prototype must still be - supplied although it doesn't have to do anything. If - PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile - time, output_flush_fn will be ignored, although it must be - supplied for compatibility. */ -void PNGAPI -png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, - png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) -{ - if(png_ptr == NULL) return; - png_ptr->io_ptr = io_ptr; - -#if !defined(PNG_NO_STDIO) - if (write_data_fn != NULL) - png_ptr->write_data_fn = write_data_fn; - else - png_ptr->write_data_fn = png_default_write_data; -#else - png_ptr->write_data_fn = write_data_fn; -#endif - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -#if !defined(PNG_NO_STDIO) - if (output_flush_fn != NULL) - png_ptr->output_flush_fn = output_flush_fn; - else - png_ptr->output_flush_fn = png_default_flush; -#else - png_ptr->output_flush_fn = output_flush_fn; -#endif -#endif /* PNG_WRITE_FLUSH_SUPPORTED */ - - /* It is an error to read while writing a png file */ - if (png_ptr->read_data_fn != NULL) - { - png_ptr->read_data_fn = NULL; - png_warning(png_ptr, - "Attempted to set both read_data_fn and write_data_fn in"); - png_warning(png_ptr, - "the same structure. Resetting read_data_fn to NULL."); - } -} - -#if defined(USE_FAR_KEYWORD) -#if defined(_MSC_VER) -void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) -{ - void *near_ptr; - void FAR *far_ptr; - FP_OFF(near_ptr) = FP_OFF(ptr); - far_ptr = (void FAR *)near_ptr; - if(check != 0) - if(FP_SEG(ptr) != FP_SEG(far_ptr)) - png_error(png_ptr,"segment lost in conversion"); - return(near_ptr); -} -# else -void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) -{ - void *near_ptr; - void FAR *far_ptr; - near_ptr = (void FAR *)ptr; - far_ptr = (void FAR *)near_ptr; - if(check != 0) - if(far_ptr != ptr) - png_error(png_ptr,"segment lost in conversion"); - return(near_ptr); -} -# endif -# endif -#endif /* PNG_WRITE_SUPPORTED */ + +/* pngwio.c - functions for data output + * + * Last changed in libpng 1.2.13 November 13, 2006 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2002 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This file provides a location for all output. Users who need + * special handling are expected to write functions that have the same + * arguments as these and perform similar functions, but that possibly + * use different output methods. Note that you shouldn't change these + * functions, but rather write replacement functions and then change + * them at run time with png_set_write_fn(...). + */ + +#define PNG_INTERNAL +#include "png.h" +#ifdef PNG_WRITE_SUPPORTED + +/* Write the data to whatever output you are using. The default routine + writes to a file pointer. Note that this routine sometimes gets called + with very small lengths, so you should implement some kind of simple + buffering if you are using unbuffered writes. This should never be asked + to write more than 64K on a 16 bit machine. */ + +void /* PRIVATE */ +png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + if (png_ptr->write_data_fn != NULL ) + (*(png_ptr->write_data_fn))(png_ptr, data, length); + else + png_error(png_ptr, "Call to NULL write function"); +} + +#if !defined(PNG_NO_STDIO) +/* This is the function that does the actual writing of data. If you are + not writing to a standard C stream, you should create a replacement + write_data function and use it at run time with png_set_write_fn(), rather + than changing the library. */ +#ifndef USE_FAR_KEYWORD +void PNGAPI +png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_uint_32 check; + + if(png_ptr == NULL) return; +#if defined(_WIN32_WCE) + if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) + check = 0; +#else + check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); +#endif + if (check != length) + png_error(png_ptr, "Write Error"); +} +#else +/* this is the model-independent version. Since the standard I/O library + can't handle far buffers in the medium and small models, we have to copy + the data. +*/ + +#define NEAR_BUF_SIZE 1024 +#define MIN(a,b) (a <= b ? a : b) + +void PNGAPI +png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_uint_32 check; + png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ + png_FILE_p io_ptr; + + if(png_ptr == NULL) return; + /* Check if data really is near. If so, use usual code. */ + near_data = (png_byte *)CVT_PTR_NOCHECK(data); + io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); + if ((png_bytep)near_data == data) + { +#if defined(_WIN32_WCE) + if ( !WriteFile(io_ptr, near_data, length, &check, NULL) ) + check = 0; +#else + check = fwrite(near_data, 1, length, io_ptr); +#endif + } + else + { + png_byte buf[NEAR_BUF_SIZE]; + png_size_t written, remaining, err; + check = 0; + remaining = length; + do + { + written = MIN(NEAR_BUF_SIZE, remaining); + png_memcpy(buf, data, written); /* copy far buffer to near buffer */ +#if defined(_WIN32_WCE) + if ( !WriteFile(io_ptr, buf, written, &err, NULL) ) + err = 0; +#else + err = fwrite(buf, 1, written, io_ptr); +#endif + if (err != written) + break; + else + check += err; + data += written; + remaining -= written; + } + while (remaining != 0); + } + if (check != length) + png_error(png_ptr, "Write Error"); +} + +#endif +#endif + +/* This function is called to output any data pending writing (normally + to disk). After png_flush is called, there should be no data pending + writing in any buffers. */ +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +void /* PRIVATE */ +png_flush(png_structp png_ptr) +{ + if (png_ptr->output_flush_fn != NULL) + (*(png_ptr->output_flush_fn))(png_ptr); +} + +#if !defined(PNG_NO_STDIO) +void PNGAPI +png_default_flush(png_structp png_ptr) +{ +#if !defined(_WIN32_WCE) + png_FILE_p io_ptr; +#endif + if(png_ptr == NULL) return; +#if !defined(_WIN32_WCE) + io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); + if (io_ptr != NULL) + fflush(io_ptr); +#endif +} +#endif +#endif + +/* This function allows the application to supply new output functions for + libpng if standard C streams aren't being used. + + This function takes as its arguments: + png_ptr - pointer to a png output data structure + io_ptr - pointer to user supplied structure containing info about + the output functions. May be NULL. + write_data_fn - pointer to a new output function that takes as its + arguments a pointer to a png_struct, a pointer to + data to be written, and a 32-bit unsigned int that is + the number of bytes to be written. The new write + function should call png_error(png_ptr, "Error msg") + to exit and output any fatal error messages. + flush_data_fn - pointer to a new flush function that takes as its + arguments a pointer to a png_struct. After a call to + the flush function, there should be no data in any buffers + or pending transmission. If the output method doesn't do + any buffering of ouput, a function prototype must still be + supplied although it doesn't have to do anything. If + PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile + time, output_flush_fn will be ignored, although it must be + supplied for compatibility. */ +void PNGAPI +png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, + png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) +{ + if(png_ptr == NULL) return; + png_ptr->io_ptr = io_ptr; + +#if !defined(PNG_NO_STDIO) + if (write_data_fn != NULL) + png_ptr->write_data_fn = write_data_fn; + else + png_ptr->write_data_fn = png_default_write_data; +#else + png_ptr->write_data_fn = write_data_fn; +#endif + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#if !defined(PNG_NO_STDIO) + if (output_flush_fn != NULL) + png_ptr->output_flush_fn = output_flush_fn; + else + png_ptr->output_flush_fn = png_default_flush; +#else + png_ptr->output_flush_fn = output_flush_fn; +#endif +#endif /* PNG_WRITE_FLUSH_SUPPORTED */ + + /* It is an error to read while writing a png file */ + if (png_ptr->read_data_fn != NULL) + { + png_ptr->read_data_fn = NULL; + png_warning(png_ptr, + "Attempted to set both read_data_fn and write_data_fn in"); + png_warning(png_ptr, + "the same structure. Resetting read_data_fn to NULL."); + } +} + +#if defined(USE_FAR_KEYWORD) +#if defined(_MSC_VER) +void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) +{ + void *near_ptr; + void FAR *far_ptr; + FP_OFF(near_ptr) = FP_OFF(ptr); + far_ptr = (void FAR *)near_ptr; + if(check != 0) + if(FP_SEG(ptr) != FP_SEG(far_ptr)) + png_error(png_ptr,"segment lost in conversion"); + return(near_ptr); +} +# else +void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) +{ + void *near_ptr; + void FAR *far_ptr; + near_ptr = (void FAR *)ptr; + far_ptr = (void FAR *)near_ptr; + if(check != 0) + if(far_ptr != ptr) + png_error(png_ptr,"segment lost in conversion"); + return(near_ptr); +} +# endif +# endif +#endif /* PNG_WRITE_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/pngwrite.c b/src/dep/src/irrlicht/libpng/pngwrite.c index b4fd7df..df7ade3 100644 --- a/src/dep/src/irrlicht/libpng/pngwrite.c +++ b/src/dep/src/irrlicht/libpng/pngwrite.c @@ -1,1518 +1,1518 @@ - -/* pngwrite.c - general routines to write a PNG file - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -/* get internal access to png.h */ -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Writes all the PNG information. This is the suggested way to use the - * library. If you have a new chunk to add, make a function to write it, - * and put it in the correct location here. If you want the chunk written - * after the image data, put it in png_write_end(). I strongly encourage - * you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing - * the chunk, as that will keep the code from breaking if you want to just - * write a plain PNG file. If you have long comments, I suggest writing - * them in png_write_end(), and compressing them. - */ -void PNGAPI -png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_write_info_before_PLTE\n"); - if (png_ptr == NULL || info_ptr == NULL) - return; - if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) - { - png_write_sig(png_ptr); /* write PNG signature */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted)) - { - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream"); - png_ptr->mng_features_permitted=0; - } -#endif - /* write IHDR information. */ - png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, - info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, - info_ptr->filter_type, -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - info_ptr->interlace_type); -#else - 0); -#endif - /* the rest of these check to see if the valid field has the appropriate - flag set, and if it does, writes the chunk. */ -#if defined(PNG_WRITE_gAMA_SUPPORTED) - if (info_ptr->valid & PNG_INFO_gAMA) - { -# ifdef PNG_FLOATING_POINT_SUPPORTED - png_write_gAMA(png_ptr, info_ptr->gamma); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_write_gAMA_fixed(png_ptr, info_ptr->int_gamma); -# endif -#endif - } -#endif -#if defined(PNG_WRITE_sRGB_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sRGB) - png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent); -#endif -#if defined(PNG_WRITE_iCCP_SUPPORTED) - if (info_ptr->valid & PNG_INFO_iCCP) - png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_COMPRESSION_TYPE_BASE, - info_ptr->iccp_profile, (int)info_ptr->iccp_proflen); -#endif -#if defined(PNG_WRITE_sBIT_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sBIT) - png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); -#endif -#if defined(PNG_WRITE_cHRM_SUPPORTED) - if (info_ptr->valid & PNG_INFO_cHRM) - { -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_write_cHRM(png_ptr, - info_ptr->x_white, info_ptr->y_white, - info_ptr->x_red, info_ptr->y_red, - info_ptr->x_green, info_ptr->y_green, - info_ptr->x_blue, info_ptr->y_blue); -#else -# ifdef PNG_FIXED_POINT_SUPPORTED - png_write_cHRM_fixed(png_ptr, - info_ptr->int_x_white, info_ptr->int_y_white, - info_ptr->int_x_red, info_ptr->int_y_red, - info_ptr->int_x_green, info_ptr->int_y_green, - info_ptr->int_x_blue, info_ptr->int_y_blue); -# endif -#endif - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != PNG_HANDLE_CHUNK_NEVER && - up->location && !(up->location & PNG_HAVE_PLTE) && - !(up->location & PNG_HAVE_IDAT) && - ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif - png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE; - } -} - -void PNGAPI -png_write_info(png_structp png_ptr, png_infop info_ptr) -{ -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) - int i; -#endif - - png_debug(1, "in png_write_info\n"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_write_info_before_PLTE(png_ptr, info_ptr); - - if (info_ptr->valid & PNG_INFO_PLTE) - png_write_PLTE(png_ptr, info_ptr->palette, - (png_uint_32)info_ptr->num_palette); - else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - png_error(png_ptr, "Valid palette required for paletted images"); - -#if defined(PNG_WRITE_tRNS_SUPPORTED) - if (info_ptr->valid & PNG_INFO_tRNS) - { -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel (in tRNS) */ - if ((png_ptr->transformations & PNG_INVERT_ALPHA) && - info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - int j; - for (j=0; j<(int)info_ptr->num_trans; j++) - info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]); - } -#endif - png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values), - info_ptr->num_trans, info_ptr->color_type); - } -#endif -#if defined(PNG_WRITE_bKGD_SUPPORTED) - if (info_ptr->valid & PNG_INFO_bKGD) - png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type); -#endif -#if defined(PNG_WRITE_hIST_SUPPORTED) - if (info_ptr->valid & PNG_INFO_hIST) - png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette); -#endif -#if defined(PNG_WRITE_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset, - info_ptr->offset_unit_type); -#endif -#if defined(PNG_WRITE_pCAL_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pCAL) - png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0, - info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, - info_ptr->pcal_units, info_ptr->pcal_params); -#endif -#if defined(PNG_WRITE_sCAL_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sCAL) -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) - png_write_sCAL(png_ptr, (int)info_ptr->scal_unit, - info_ptr->scal_pixel_width, info_ptr->scal_pixel_height); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit, - info_ptr->scal_s_width, info_ptr->scal_s_height); -#else - png_warning(png_ptr, - "png_write_sCAL not supported; sCAL chunk not written."); -#endif -#endif -#endif -#if defined(PNG_WRITE_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit, - info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); -#endif -#if defined(PNG_WRITE_tIME_SUPPORTED) - if (info_ptr->valid & PNG_INFO_tIME) - { - png_write_tIME(png_ptr, &(info_ptr->mod_time)); - png_ptr->mode |= PNG_WROTE_tIME; - } -#endif -#if defined(PNG_WRITE_sPLT_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sPLT) - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); -#endif -#if defined(PNG_WRITE_TEXT_SUPPORTED) - /* Check to see if we need to write text chunks */ - for (i = 0; i < info_ptr->num_text; i++) - { - png_debug2(2, "Writing header text chunk %d, type %d\n", i, - info_ptr->text[i].compression); - /* an internationalized chunk? */ - if (info_ptr->text[i].compression > 0) - { -#if defined(PNG_WRITE_iTXt_SUPPORTED) - /* write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); -#else - png_warning(png_ptr, "Unable to write international text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - /* If we want a compressed text chunk */ - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt) - { -#if defined(PNG_WRITE_zTXt_SUPPORTED) - /* write compressed chunk */ - png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0, - info_ptr->text[i].compression); -#else - png_warning(png_ptr, "Unable to write compressed text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; - } - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) - { -#if defined(PNG_WRITE_tEXt_SUPPORTED) - /* write uncompressed chunk */ - png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, - 0); -#else - png_warning(png_ptr, "Unable to write uncompressed text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != PNG_HANDLE_CHUNK_NEVER && - up->location && (up->location & PNG_HAVE_PLTE) && - !(up->location & PNG_HAVE_IDAT) && - ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif -} - -/* Writes the end of the PNG file. If you don't want to write comments or - * time information, you can pass NULL for info. If you already wrote these - * in png_write_info(), do not write them again here. If you have long - * comments, I suggest writing them here, and compressing them. - */ -void PNGAPI -png_write_end(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_write_end\n"); - if (png_ptr == NULL) - return; - if (!(png_ptr->mode & PNG_HAVE_IDAT)) - png_error(png_ptr, "No IDATs written into file"); - - /* see if user wants us to write information chunks */ - if (info_ptr != NULL) - { -#if defined(PNG_WRITE_TEXT_SUPPORTED) - int i; /* local index variable */ -#endif -#if defined(PNG_WRITE_tIME_SUPPORTED) - /* check to see if user has supplied a time chunk */ - if ((info_ptr->valid & PNG_INFO_tIME) && - !(png_ptr->mode & PNG_WROTE_tIME)) - png_write_tIME(png_ptr, &(info_ptr->mod_time)); -#endif -#if defined(PNG_WRITE_TEXT_SUPPORTED) - /* loop through comment chunks */ - for (i = 0; i < info_ptr->num_text; i++) - { - png_debug2(2, "Writing trailer text chunk %d, type %d\n", i, - info_ptr->text[i].compression); - /* an internationalized chunk? */ - if (info_ptr->text[i].compression > 0) - { -#if defined(PNG_WRITE_iTXt_SUPPORTED) - /* write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); -#else - png_warning(png_ptr, "Unable to write international text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt) - { -#if defined(PNG_WRITE_zTXt_SUPPORTED) - /* write compressed chunk */ - png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0, - info_ptr->text[i].compression); -#else - png_warning(png_ptr, "Unable to write compressed text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; - } - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) - { -#if defined(PNG_WRITE_tEXt_SUPPORTED) - /* write uncompressed chunk */ - png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0); -#else - png_warning(png_ptr, "Unable to write uncompressed text"); -#endif - - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != PNG_HANDLE_CHUNK_NEVER && - up->location && (up->location & PNG_AFTER_IDAT) && - ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif - } - - png_ptr->mode |= PNG_AFTER_IDAT; - - /* write end of PNG file */ - png_write_IEND(png_ptr); -#if 0 -/* This flush, added in libpng-1.0.8, causes some applications to crash - because they do not set png_ptr->output_flush_fn */ - png_flush(png_ptr); -#endif -} - -#if defined(PNG_WRITE_tIME_SUPPORTED) -#if !defined(_WIN32_WCE) -/* "time.h" functions are not supported on WindowsCE */ -void PNGAPI -png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) -{ - png_debug(1, "in png_convert_from_struct_tm\n"); - ptime->year = (png_uint_16)(1900 + ttime->tm_year); - ptime->month = (png_byte)(ttime->tm_mon + 1); - ptime->day = (png_byte)ttime->tm_mday; - ptime->hour = (png_byte)ttime->tm_hour; - ptime->minute = (png_byte)ttime->tm_min; - ptime->second = (png_byte)ttime->tm_sec; -} - -void PNGAPI -png_convert_from_time_t(png_timep ptime, time_t ttime) -{ - struct tm *tbuf; - - png_debug(1, "in png_convert_from_time_t\n"); - tbuf = gmtime(&ttime); - png_convert_from_struct_tm(ptime, tbuf); -} -#endif -#endif - -/* Initialize png_ptr structure, and allocate any memory needed */ -png_structp PNGAPI -png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); -} - -/* Alternate initialize png_ptr structure, and allocate any memory needed */ -png_structp PNGAPI -png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_structp png_ptr; -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - int i; - png_debug(1, "in png_create_write_struct\n"); -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); -#else - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); -#endif /* PNG_USER_MEM_SUPPORTED */ - if (png_ptr == NULL) - return (NULL); - -#if !defined(PNG_1_0_X) -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -#ifdef PNG_MMX_CODE_SUPPORTED - png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ -#endif -#endif -#endif /* PNG_1_0_X */ - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_ptr->jmpbuf)) -#endif - { - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; - png_destroy_struct(png_ptr); - return (NULL); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#endif -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); -#endif /* PNG_USER_MEM_SUPPORTED */ - png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - - i=0; - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - } while (png_libpng_ver[i++]); - - if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) - { - /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so - * we must recompile any applications that use any older library version. - * For versions after libpng 1.0, we will be compatible, so we need - * only check the first digit. - */ - if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || - (user_png_ver[0] == '0' && user_png_ver[2] < '9')) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[80]; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); -#endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "Incompatible libpng version in application and library"); - } - } - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - - png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, - png_flush_ptr_NULL); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, png_doublep_NULL, png_doublep_NULL); -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* Applications that neglect to set up their own setjmp() and then encounter - a png_error() will longjmp here. Since the jmpbuf is then meaningless we - abort instead of returning. */ -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) - PNG_ABORT(); - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#else - if (setjmp(png_ptr->jmpbuf)) - PNG_ABORT(); -#endif -#endif - return (png_ptr); -} - -/* Initialize png_ptr structure, and allocate any memory needed */ -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Deprecated. */ -#undef png_write_init -void PNGAPI -png_write_init(png_structp png_ptr) -{ - /* We only come here via pre-1.0.7-compiled applications */ - png_write_init_2(png_ptr, "1.0.6 or earlier", 0, 0); -} - -void PNGAPI -png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size, png_size_t png_info_size) -{ - /* We only come here via pre-1.0.12-compiled applications */ - if(png_ptr == NULL) return; -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if(png_sizeof(png_struct) > png_struct_size || - png_sizeof(png_info) > png_info_size) - { - char msg[80]; - png_ptr->warning_fn=NULL; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); - } -#endif - if(png_sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The png struct allocated by the application for writing is too small."); - } - if(png_sizeof(png_info) > png_info_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The info struct allocated by the application for writing is too small."); - } - png_write_init_3(&png_ptr, user_png_ver, png_struct_size); -} -#endif /* PNG_1_0_X || PNG_1_2_X */ - - -void PNGAPI -png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ - png_structp png_ptr=*ptr_ptr; -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ -#endif - - int i = 0; - - if (png_ptr == NULL) - return; - - do - { - if (user_png_ver[i] != png_libpng_ver[i]) - { -#ifdef PNG_LEGACY_SUPPORTED - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; -#else - png_ptr->warning_fn=NULL; - png_warning(png_ptr, - "Application uses deprecated png_write_init() and should be recompiled."); - break; -#endif - } - } while (png_libpng_ver[i++]); - - png_debug(1, "in png_write_init_3\n"); - -#ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); -#endif - - if (png_sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - *ptr_ptr = png_ptr; - } - - /* reset all variables to 0 */ - png_memset(png_ptr, 0, png_sizeof (png_struct)); - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - -#if !defined(PNG_1_0_X) -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -#ifdef PNG_MMX_CODE_SUPPORTED - png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ -#endif -#endif -#endif /* PNG_1_0_X */ - -#ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif - - png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, - png_flush_ptr_NULL); - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, png_doublep_NULL, png_doublep_NULL); -#endif -} - -/* Write a few rows of image data. If the image is interlaced, - * either you will have to write the 7 sub images, or, if you - * have called png_set_interlace_handling(), you will have to - * "write" the image seven times. - */ -void PNGAPI -png_write_rows(png_structp png_ptr, png_bytepp row, - png_uint_32 num_rows) -{ - png_uint_32 i; /* row counter */ - png_bytepp rp; /* row pointer */ - - png_debug(1, "in png_write_rows\n"); - - if (png_ptr == NULL) - return; - - /* loop through the rows */ - for (i = 0, rp = row; i < num_rows; i++, rp++) - { - png_write_row(png_ptr, *rp); - } -} - -/* Write the image. You only need to call this function once, even - * if you are writing an interlaced image. - */ -void PNGAPI -png_write_image(png_structp png_ptr, png_bytepp image) -{ - png_uint_32 i; /* row index */ - int pass, num_pass; /* pass variables */ - png_bytepp rp; /* points to current row */ - - if (png_ptr == NULL) - return; - - png_debug(1, "in png_write_image\n"); -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* intialize interlace handling. If image is not interlaced, - this will set pass to 1 */ - num_pass = png_set_interlace_handling(png_ptr); -#else - num_pass = 1; -#endif - /* loop through passes */ - for (pass = 0; pass < num_pass; pass++) - { - /* loop through image */ - for (i = 0, rp = image; i < png_ptr->height; i++, rp++) - { - png_write_row(png_ptr, *rp); - } - } -} - -/* called by user to write a row of image data */ -void PNGAPI -png_write_row(png_structp png_ptr, png_bytep row) -{ - if (png_ptr == NULL) - return; - png_debug2(1, "in png_write_row (row %ld, pass %d)\n", - png_ptr->row_number, png_ptr->pass); - - /* initialize transformations and other stuff if first time */ - if (png_ptr->row_number == 0 && png_ptr->pass == 0) - { - /* make sure we wrote the header info */ - if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) - png_error(png_ptr, - "png_write_info was never called before png_write_row."); - - /* check for transforms that have been set but were defined out */ -#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined."); -#endif - - png_write_start_row(png_ptr); - } - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* if interlaced and not interested in row, return */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - switch (png_ptr->pass) - { - case 0: - if (png_ptr->row_number & 0x07) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 1: - if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 2: - if ((png_ptr->row_number & 0x07) != 4) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 3: - if ((png_ptr->row_number & 0x03) || png_ptr->width < 3) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 4: - if ((png_ptr->row_number & 0x03) != 2) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 5: - if ((png_ptr->row_number & 0x01) || png_ptr->width < 2) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 6: - if (!(png_ptr->row_number & 0x01)) - { - png_write_finish_row(png_ptr); - return; - } - break; - } - } -#endif - - /* set up row info for transformations */ - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->usr_width; - png_ptr->row_info.channels = png_ptr->usr_channels; - png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth; - png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * - png_ptr->row_info.channels); - - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); - - png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type); - png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width); - png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels); - png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth); - png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth); - png_debug1(3, "row_info->rowbytes = %lu\n", png_ptr->row_info.rowbytes); - - /* Copy user's row into buffer, leaving room for filter byte. */ - png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row, - png_ptr->row_info.rowbytes); - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* handle interlacing */ - if (png_ptr->interlaced && png_ptr->pass < 6 && - (png_ptr->transformations & PNG_INTERLACE)) - { - png_do_write_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass); - /* this should always get caught above, but still ... */ - if (!(png_ptr->row_info.width)) - { - png_write_finish_row(png_ptr); - return; - } - } -#endif - - /* handle other transformations */ - if (png_ptr->transformations) - png_do_write_transformations(png_ptr); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - /* Write filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not write a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) - { - /* Intrapixel differencing */ - png_do_write_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); - } -#endif - - /* Find a filter if necessary, filter the row and write it out. */ - png_write_find_filter(png_ptr, &(png_ptr->row_info)); - - if (png_ptr->write_row_fn != NULL) - (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); -} - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -/* Set the automatic flush interval or 0 to turn flushing off */ -void PNGAPI -png_set_flush(png_structp png_ptr, int nrows) -{ - png_debug(1, "in png_set_flush\n"); - if (png_ptr == NULL) - return; - png_ptr->flush_dist = (nrows < 0 ? 0 : nrows); -} - -/* flush the current output buffers now */ -void PNGAPI -png_write_flush(png_structp png_ptr) -{ - int wrote_IDAT; - - png_debug(1, "in png_write_flush\n"); - if (png_ptr == NULL) - return; - /* We have already written out all of the data */ - if (png_ptr->row_number >= png_ptr->num_rows) - return; - - do - { - int ret; - - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_SYNC_FLUSH); - wrote_IDAT = 0; - - /* check for compression errors */ - if (ret != Z_OK) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - - if (!(png_ptr->zstream.avail_out)) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - wrote_IDAT = 1; - } - } while(wrote_IDAT == 1); - - /* If there is any data left to be output, write it into a new IDAT */ - if (png_ptr->zbuf_size != png_ptr->zstream.avail_out) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - png_ptr->flush_rows = 0; - png_flush(png_ptr); -} -#endif /* PNG_WRITE_FLUSH_SUPPORTED */ - -/* free all memory used by the write */ -void PNGAPI -png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) -{ - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn = NULL; - png_voidp mem_ptr = NULL; -#endif - - png_debug(1, "in png_destroy_write_struct\n"); - if (png_ptr_ptr != NULL) - { - png_ptr = *png_ptr_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; - mem_ptr = png_ptr->mem_ptr; -#endif - } - - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (info_ptr != NULL) - { - png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->num_chunk_list) - { - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; - } -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = NULL; - } - - if (png_ptr != NULL) - { - png_write_destroy(png_ptr); -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - *png_ptr_ptr = NULL; - } -} - - -/* Free any memory used in png_ptr struct (old method) */ -void /* PRIVATE */ -png_write_destroy(png_structp png_ptr) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* save jump buffer */ -#endif - png_error_ptr error_fn; - png_error_ptr warning_fn; - png_voidp error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; -#endif - - png_debug(1, "in png_write_destroy\n"); - /* free any memory zlib uses */ - deflateEnd(&png_ptr->zstream); - - /* free our memory. png_free checks NULL for us. */ - png_free(png_ptr, png_ptr->zbuf); - png_free(png_ptr, png_ptr->row_buf); - png_free(png_ptr, png_ptr->prev_row); - png_free(png_ptr, png_ptr->sub_row); - png_free(png_ptr, png_ptr->up_row); - png_free(png_ptr, png_ptr->avg_row); - png_free(png_ptr, png_ptr->paeth_row); - -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_free(png_ptr, png_ptr->time_buffer); -#endif - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_free(png_ptr, png_ptr->prev_filters); - png_free(png_ptr, png_ptr->filter_weights); - png_free(png_ptr, png_ptr->inv_filter_weights); - png_free(png_ptr, png_ptr->filter_costs); - png_free(png_ptr, png_ptr->inv_filter_costs); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - /* reset structure */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); -#endif - - error_fn = png_ptr->error_fn; - warning_fn = png_ptr->warning_fn; - error_ptr = png_ptr->error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; -#endif - - png_memset(png_ptr, 0, png_sizeof (png_struct)); - - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; - png_ptr->error_ptr = error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr->free_fn = free_fn; -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif -} - -/* Allow the application to select one or more row filters to use. */ -void PNGAPI -png_set_filter(png_structp png_ptr, int method, int filters) -{ - png_debug(1, "in png_set_filter\n"); - if (png_ptr == NULL) - return; -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (method == PNG_INTRAPIXEL_DIFFERENCING)) - method = PNG_FILTER_TYPE_BASE; -#endif - if (method == PNG_FILTER_TYPE_BASE) - { - switch (filters & (PNG_ALL_FILTERS | 0x07)) - { - case 5: - case 6: - case 7: png_warning(png_ptr, "Unknown row filter for method 0"); - case PNG_FILTER_VALUE_NONE: png_ptr->do_filter=PNG_FILTER_NONE; break; - case PNG_FILTER_VALUE_SUB: png_ptr->do_filter=PNG_FILTER_SUB; break; - case PNG_FILTER_VALUE_UP: png_ptr->do_filter=PNG_FILTER_UP; break; - case PNG_FILTER_VALUE_AVG: png_ptr->do_filter=PNG_FILTER_AVG; break; - case PNG_FILTER_VALUE_PAETH: png_ptr->do_filter=PNG_FILTER_PAETH;break; - default: png_ptr->do_filter = (png_byte)filters; break; - } - - /* If we have allocated the row_buf, this means we have already started - * with the image and we should have allocated all of the filter buffers - * that have been selected. If prev_row isn't already allocated, then - * it is too late to start using the filters that need it, since we - * will be missing the data in the previous row. If an application - * wants to start and stop using particular filters during compression, - * it should start out with all of the filters, and then add and - * remove them after the start of compression. - */ - if (png_ptr->row_buf != NULL) - { - if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL) - { - png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; - } - - if ((png_ptr->do_filter & PNG_FILTER_UP) && png_ptr->up_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Up filter after starting"); - png_ptr->do_filter &= ~PNG_FILTER_UP; - } - else - { - png_ptr->up_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; - } - } - - if ((png_ptr->do_filter & PNG_FILTER_AVG) && png_ptr->avg_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Average filter after starting"); - png_ptr->do_filter &= ~PNG_FILTER_AVG; - } - else - { - png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; - } - } - - if ((png_ptr->do_filter & PNG_FILTER_PAETH) && - png_ptr->paeth_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Paeth filter after starting"); - png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH); - } - else - { - png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; - } - } - - if (png_ptr->do_filter == PNG_NO_FILTERS) - png_ptr->do_filter = PNG_FILTER_NONE; - } - } - else - png_error(png_ptr, "Unknown custom filter method"); -} - -/* This allows us to influence the way in which libpng chooses the "best" - * filter for the current scanline. While the "minimum-sum-of-absolute- - * differences metric is relatively fast and effective, there is some - * question as to whether it can be improved upon by trying to keep the - * filtered data going to zlib more consistent, hopefully resulting in - * better compression. - */ -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* GRR 970116 */ -void PNGAPI -png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, - int num_weights, png_doublep filter_weights, - png_doublep filter_costs) -{ - int i; - - png_debug(1, "in png_set_filter_heuristics\n"); - if (png_ptr == NULL) - return; - if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST) - { - png_warning(png_ptr, "Unknown filter heuristic method"); - return; - } - - if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT) - { - heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED; - } - - if (num_weights < 0 || filter_weights == NULL || - heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED) - { - num_weights = 0; - } - - png_ptr->num_prev_filters = (png_byte)num_weights; - png_ptr->heuristic_method = (png_byte)heuristic_method; - - if (num_weights > 0) - { - if (png_ptr->prev_filters == NULL) - { - png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_byte) * num_weights)); - - /* To make sure that the weighting starts out fairly */ - for (i = 0; i < num_weights; i++) - { - png_ptr->prev_filters[i] = 255; - } - } - - if (png_ptr->filter_weights == NULL) - { - png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); - - png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); - for (i = 0; i < num_weights; i++) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } - } - - for (i = 0; i < num_weights; i++) - { - if (filter_weights[i] < 0.0) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } - else - { - png_ptr->inv_filter_weights[i] = - (png_uint_16)((double)PNG_WEIGHT_FACTOR*filter_weights[i]+0.5); - png_ptr->filter_weights[i] = - (png_uint_16)((double)PNG_WEIGHT_FACTOR/filter_weights[i]+0.5); - } - } - } - - /* If, in the future, there are other filter methods, this would - * need to be based on png_ptr->filter. - */ - if (png_ptr->filter_costs == NULL) - { - png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); - - png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); - - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) - { - png_ptr->inv_filter_costs[i] = - png_ptr->filter_costs[i] = PNG_COST_FACTOR; - } - } - - /* Here is where we set the relative costs of the different filters. We - * should take the desired compression level into account when setting - * the costs, so that Paeth, for instance, has a high relative cost at low - * compression levels, while it has a lower relative cost at higher - * compression settings. The filter types are in order of increasing - * relative cost, so it would be possible to do this with an algorithm. - */ - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) - { - if (filter_costs == NULL || filter_costs[i] < 0.0) - { - png_ptr->inv_filter_costs[i] = - png_ptr->filter_costs[i] = PNG_COST_FACTOR; - } - else if (filter_costs[i] >= 1.0) - { - png_ptr->inv_filter_costs[i] = - (png_uint_16)((double)PNG_COST_FACTOR / filter_costs[i] + 0.5); - png_ptr->filter_costs[i] = - (png_uint_16)((double)PNG_COST_FACTOR * filter_costs[i] + 0.5); - } - } -} -#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ - -void PNGAPI -png_set_compression_level(png_structp png_ptr, int level) -{ - png_debug(1, "in png_set_compression_level\n"); - if (png_ptr == NULL) - return; - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL; - png_ptr->zlib_level = level; -} - -void PNGAPI -png_set_compression_mem_level(png_structp png_ptr, int mem_level) -{ - png_debug(1, "in png_set_compression_mem_level\n"); - if (png_ptr == NULL) - return; - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL; - png_ptr->zlib_mem_level = mem_level; -} - -void PNGAPI -png_set_compression_strategy(png_structp png_ptr, int strategy) -{ - png_debug(1, "in png_set_compression_strategy\n"); - if (png_ptr == NULL) - return; - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY; - png_ptr->zlib_strategy = strategy; -} - -void PNGAPI -png_set_compression_window_bits(png_structp png_ptr, int window_bits) -{ - if (png_ptr == NULL) - return; - if (window_bits > 15) - png_warning(png_ptr, "Only compression windows <= 32k supported by PNG"); - else if (window_bits < 8) - png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); -#ifndef WBITS_8_OK - /* avoid libpng bug with 256-byte windows */ - if (window_bits == 8) - { - png_warning(png_ptr, "Compression window is being reset to 512"); - window_bits=9; - } -#endif - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS; - png_ptr->zlib_window_bits = window_bits; -} - -void PNGAPI -png_set_compression_method(png_structp png_ptr, int method) -{ - png_debug(1, "in png_set_compression_method\n"); - if (png_ptr == NULL) - return; - if (method != 8) - png_warning(png_ptr, "Only compression method 8 is supported by PNG"); - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD; - png_ptr->zlib_method = method; -} - -void PNGAPI -png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn) -{ - if (png_ptr == NULL) - return; - png_ptr->write_row_fn = write_row_fn; -} - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -void PNGAPI -png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr - write_user_transform_fn) -{ - png_debug(1, "in png_set_write_user_transform_fn\n"); - if (png_ptr == NULL) - return; - png_ptr->transformations |= PNG_USER_TRANSFORM; - png_ptr->write_user_transform_fn = write_user_transform_fn; -} -#endif - - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_write_png(png_structp png_ptr, png_infop info_ptr, - int transforms, voidp params) -{ - if (png_ptr == NULL || info_ptr == NULL) - return; -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency */ - if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); -#endif - - /* Write the file header information. */ - png_write_info(png_ptr, info_ptr); - - /* ------ these transformations don't touch the info structure ------- */ - -#if defined(PNG_WRITE_INVERT_SUPPORTED) - /* invert monochrome pixels */ - if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) - /* Shift the pixels up to a legal bit depth and fill in - * as appropriate to correctly scale the image. - */ - if ((transforms & PNG_TRANSFORM_SHIFT) - && (info_ptr->valid & PNG_INFO_sBIT)) - png_set_shift(png_ptr, &info_ptr->sig_bit); -#endif - -#if defined(PNG_WRITE_PACK_SUPPORTED) - /* pack pixels into bytes */ - if (transforms & PNG_TRANSFORM_PACKING) - png_set_packing(png_ptr); -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) - /* swap location of alpha bytes from ARGB to RGBA */ - if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); -#endif - -#if defined(PNG_WRITE_FILLER_SUPPORTED) - /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into - * RGB (4 channels -> 3 channels). The second parameter is not used. - */ - if (transforms & PNG_TRANSFORM_STRIP_FILLER) - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); -#endif - -#if defined(PNG_WRITE_BGR_SUPPORTED) - /* flip BGR pixels to RGB */ - if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); -#endif - -#if defined(PNG_WRITE_SWAP_SUPPORTED) - /* swap bytes of 16-bit files to most significant byte first */ - if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); -#endif - -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) - /* swap bits of 1, 2, 4 bit packed pixel formats */ - if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); -#endif - - /* ----------------------- end of transformations ------------------- */ - - /* write the bits */ - if (info_ptr->valid & PNG_INFO_IDAT) - png_write_image(png_ptr, info_ptr->row_pointers); - - /* It is REQUIRED to call this to finish writing the rest of the file */ - png_write_end(png_ptr, info_ptr); - - if(transforms == 0 || params == NULL) - /* quiet compiler warnings */ return; -} -#endif -#endif /* PNG_WRITE_SUPPORTED */ + +/* pngwrite.c - general routines to write a PNG file + * + * Last changed in libpng 1.2.15 January 5, 2007 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +/* get internal access to png.h */ +#define PNG_INTERNAL +#include "png.h" +#ifdef PNG_WRITE_SUPPORTED + +/* Writes all the PNG information. This is the suggested way to use the + * library. If you have a new chunk to add, make a function to write it, + * and put it in the correct location here. If you want the chunk written + * after the image data, put it in png_write_end(). I strongly encourage + * you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing + * the chunk, as that will keep the code from breaking if you want to just + * write a plain PNG file. If you have long comments, I suggest writing + * them in png_write_end(), and compressing them. + */ +void PNGAPI +png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) +{ + png_debug(1, "in png_write_info_before_PLTE\n"); + if (png_ptr == NULL || info_ptr == NULL) + return; + if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) + { + png_write_sig(png_ptr); /* write PNG signature */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) + if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted)) + { + png_warning(png_ptr,"MNG features are not allowed in a PNG datastream"); + png_ptr->mng_features_permitted=0; + } +#endif + /* write IHDR information. */ + png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, + info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, + info_ptr->filter_type, +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) + info_ptr->interlace_type); +#else + 0); +#endif + /* the rest of these check to see if the valid field has the appropriate + flag set, and if it does, writes the chunk. */ +#if defined(PNG_WRITE_gAMA_SUPPORTED) + if (info_ptr->valid & PNG_INFO_gAMA) + { +# ifdef PNG_FLOATING_POINT_SUPPORTED + png_write_gAMA(png_ptr, info_ptr->gamma); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + png_write_gAMA_fixed(png_ptr, info_ptr->int_gamma); +# endif +#endif + } +#endif +#if defined(PNG_WRITE_sRGB_SUPPORTED) + if (info_ptr->valid & PNG_INFO_sRGB) + png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent); +#endif +#if defined(PNG_WRITE_iCCP_SUPPORTED) + if (info_ptr->valid & PNG_INFO_iCCP) + png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_COMPRESSION_TYPE_BASE, + info_ptr->iccp_profile, (int)info_ptr->iccp_proflen); +#endif +#if defined(PNG_WRITE_sBIT_SUPPORTED) + if (info_ptr->valid & PNG_INFO_sBIT) + png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); +#endif +#if defined(PNG_WRITE_cHRM_SUPPORTED) + if (info_ptr->valid & PNG_INFO_cHRM) + { +#ifdef PNG_FLOATING_POINT_SUPPORTED + png_write_cHRM(png_ptr, + info_ptr->x_white, info_ptr->y_white, + info_ptr->x_red, info_ptr->y_red, + info_ptr->x_green, info_ptr->y_green, + info_ptr->x_blue, info_ptr->y_blue); +#else +# ifdef PNG_FIXED_POINT_SUPPORTED + png_write_cHRM_fixed(png_ptr, + info_ptr->int_x_white, info_ptr->int_y_white, + info_ptr->int_x_red, info_ptr->int_y_red, + info_ptr->int_x_green, info_ptr->int_y_green, + info_ptr->int_x_blue, info_ptr->int_y_blue); +# endif +#endif + } +#endif +#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) + if (info_ptr->unknown_chunks_num) + { + png_unknown_chunk *up; + + png_debug(5, "writing extra chunks\n"); + + for (up = info_ptr->unknown_chunks; + up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; + up++) + { + int keep=png_handle_as_unknown(png_ptr, up->name); + if (keep != PNG_HANDLE_CHUNK_NEVER && + up->location && !(up->location & PNG_HAVE_PLTE) && + !(up->location & PNG_HAVE_IDAT) && + ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || + (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) + { + png_write_chunk(png_ptr, up->name, up->data, up->size); + } + } + } +#endif + png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE; + } +} + +void PNGAPI +png_write_info(png_structp png_ptr, png_infop info_ptr) +{ +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) + int i; +#endif + + png_debug(1, "in png_write_info\n"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + png_write_info_before_PLTE(png_ptr, info_ptr); + + if (info_ptr->valid & PNG_INFO_PLTE) + png_write_PLTE(png_ptr, info_ptr->palette, + (png_uint_32)info_ptr->num_palette); + else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + png_error(png_ptr, "Valid palette required for paletted images"); + +#if defined(PNG_WRITE_tRNS_SUPPORTED) + if (info_ptr->valid & PNG_INFO_tRNS) + { +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) + /* invert the alpha channel (in tRNS) */ + if ((png_ptr->transformations & PNG_INVERT_ALPHA) && + info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + int j; + for (j=0; j<(int)info_ptr->num_trans; j++) + info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]); + } +#endif + png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values), + info_ptr->num_trans, info_ptr->color_type); + } +#endif +#if defined(PNG_WRITE_bKGD_SUPPORTED) + if (info_ptr->valid & PNG_INFO_bKGD) + png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type); +#endif +#if defined(PNG_WRITE_hIST_SUPPORTED) + if (info_ptr->valid & PNG_INFO_hIST) + png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette); +#endif +#if defined(PNG_WRITE_oFFs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_oFFs) + png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset, + info_ptr->offset_unit_type); +#endif +#if defined(PNG_WRITE_pCAL_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pCAL) + png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0, + info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, + info_ptr->pcal_units, info_ptr->pcal_params); +#endif +#if defined(PNG_WRITE_sCAL_SUPPORTED) + if (info_ptr->valid & PNG_INFO_sCAL) +#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) + png_write_sCAL(png_ptr, (int)info_ptr->scal_unit, + info_ptr->scal_pixel_width, info_ptr->scal_pixel_height); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit, + info_ptr->scal_s_width, info_ptr->scal_s_height); +#else + png_warning(png_ptr, + "png_write_sCAL not supported; sCAL chunk not written."); +#endif +#endif +#endif +#if defined(PNG_WRITE_pHYs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pHYs) + png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit, + info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); +#endif +#if defined(PNG_WRITE_tIME_SUPPORTED) + if (info_ptr->valid & PNG_INFO_tIME) + { + png_write_tIME(png_ptr, &(info_ptr->mod_time)); + png_ptr->mode |= PNG_WROTE_tIME; + } +#endif +#if defined(PNG_WRITE_sPLT_SUPPORTED) + if (info_ptr->valid & PNG_INFO_sPLT) + for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) + png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); +#endif +#if defined(PNG_WRITE_TEXT_SUPPORTED) + /* Check to see if we need to write text chunks */ + for (i = 0; i < info_ptr->num_text; i++) + { + png_debug2(2, "Writing header text chunk %d, type %d\n", i, + info_ptr->text[i].compression); + /* an internationalized chunk? */ + if (info_ptr->text[i].compression > 0) + { +#if defined(PNG_WRITE_iTXt_SUPPORTED) + /* write international chunk */ + png_write_iTXt(png_ptr, + info_ptr->text[i].compression, + info_ptr->text[i].key, + info_ptr->text[i].lang, + info_ptr->text[i].lang_key, + info_ptr->text[i].text); +#else + png_warning(png_ptr, "Unable to write international text"); +#endif + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; + } + /* If we want a compressed text chunk */ + else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt) + { +#if defined(PNG_WRITE_zTXt_SUPPORTED) + /* write compressed chunk */ + png_write_zTXt(png_ptr, info_ptr->text[i].key, + info_ptr->text[i].text, 0, + info_ptr->text[i].compression); +#else + png_warning(png_ptr, "Unable to write compressed text"); +#endif + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; + } + else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) + { +#if defined(PNG_WRITE_tEXt_SUPPORTED) + /* write uncompressed chunk */ + png_write_tEXt(png_ptr, info_ptr->text[i].key, + info_ptr->text[i].text, + 0); +#else + png_warning(png_ptr, "Unable to write uncompressed text"); +#endif + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; + } + } +#endif +#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) + if (info_ptr->unknown_chunks_num) + { + png_unknown_chunk *up; + + png_debug(5, "writing extra chunks\n"); + + for (up = info_ptr->unknown_chunks; + up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; + up++) + { + int keep=png_handle_as_unknown(png_ptr, up->name); + if (keep != PNG_HANDLE_CHUNK_NEVER && + up->location && (up->location & PNG_HAVE_PLTE) && + !(up->location & PNG_HAVE_IDAT) && + ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || + (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) + { + png_write_chunk(png_ptr, up->name, up->data, up->size); + } + } + } +#endif +} + +/* Writes the end of the PNG file. If you don't want to write comments or + * time information, you can pass NULL for info. If you already wrote these + * in png_write_info(), do not write them again here. If you have long + * comments, I suggest writing them here, and compressing them. + */ +void PNGAPI +png_write_end(png_structp png_ptr, png_infop info_ptr) +{ + png_debug(1, "in png_write_end\n"); + if (png_ptr == NULL) + return; + if (!(png_ptr->mode & PNG_HAVE_IDAT)) + png_error(png_ptr, "No IDATs written into file"); + + /* see if user wants us to write information chunks */ + if (info_ptr != NULL) + { +#if defined(PNG_WRITE_TEXT_SUPPORTED) + int i; /* local index variable */ +#endif +#if defined(PNG_WRITE_tIME_SUPPORTED) + /* check to see if user has supplied a time chunk */ + if ((info_ptr->valid & PNG_INFO_tIME) && + !(png_ptr->mode & PNG_WROTE_tIME)) + png_write_tIME(png_ptr, &(info_ptr->mod_time)); +#endif +#if defined(PNG_WRITE_TEXT_SUPPORTED) + /* loop through comment chunks */ + for (i = 0; i < info_ptr->num_text; i++) + { + png_debug2(2, "Writing trailer text chunk %d, type %d\n", i, + info_ptr->text[i].compression); + /* an internationalized chunk? */ + if (info_ptr->text[i].compression > 0) + { +#if defined(PNG_WRITE_iTXt_SUPPORTED) + /* write international chunk */ + png_write_iTXt(png_ptr, + info_ptr->text[i].compression, + info_ptr->text[i].key, + info_ptr->text[i].lang, + info_ptr->text[i].lang_key, + info_ptr->text[i].text); +#else + png_warning(png_ptr, "Unable to write international text"); +#endif + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; + } + else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt) + { +#if defined(PNG_WRITE_zTXt_SUPPORTED) + /* write compressed chunk */ + png_write_zTXt(png_ptr, info_ptr->text[i].key, + info_ptr->text[i].text, 0, + info_ptr->text[i].compression); +#else + png_warning(png_ptr, "Unable to write compressed text"); +#endif + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; + } + else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) + { +#if defined(PNG_WRITE_tEXt_SUPPORTED) + /* write uncompressed chunk */ + png_write_tEXt(png_ptr, info_ptr->text[i].key, + info_ptr->text[i].text, 0); +#else + png_warning(png_ptr, "Unable to write uncompressed text"); +#endif + + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; + } + } +#endif +#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) + if (info_ptr->unknown_chunks_num) + { + png_unknown_chunk *up; + + png_debug(5, "writing extra chunks\n"); + + for (up = info_ptr->unknown_chunks; + up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; + up++) + { + int keep=png_handle_as_unknown(png_ptr, up->name); + if (keep != PNG_HANDLE_CHUNK_NEVER && + up->location && (up->location & PNG_AFTER_IDAT) && + ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || + (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) + { + png_write_chunk(png_ptr, up->name, up->data, up->size); + } + } + } +#endif + } + + png_ptr->mode |= PNG_AFTER_IDAT; + + /* write end of PNG file */ + png_write_IEND(png_ptr); +#if 0 +/* This flush, added in libpng-1.0.8, causes some applications to crash + because they do not set png_ptr->output_flush_fn */ + png_flush(png_ptr); +#endif +} + +#if defined(PNG_WRITE_tIME_SUPPORTED) +#if !defined(_WIN32_WCE) +/* "time.h" functions are not supported on WindowsCE */ +void PNGAPI +png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) +{ + png_debug(1, "in png_convert_from_struct_tm\n"); + ptime->year = (png_uint_16)(1900 + ttime->tm_year); + ptime->month = (png_byte)(ttime->tm_mon + 1); + ptime->day = (png_byte)ttime->tm_mday; + ptime->hour = (png_byte)ttime->tm_hour; + ptime->minute = (png_byte)ttime->tm_min; + ptime->second = (png_byte)ttime->tm_sec; +} + +void PNGAPI +png_convert_from_time_t(png_timep ptime, time_t ttime) +{ + struct tm *tbuf; + + png_debug(1, "in png_convert_from_time_t\n"); + tbuf = gmtime(&ttime); + png_convert_from_struct_tm(ptime, tbuf); +} +#endif +#endif + +/* Initialize png_ptr structure, and allocate any memory needed */ +png_structp PNGAPI +png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn) +{ +#ifdef PNG_USER_MEM_SUPPORTED + return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn, + warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); +} + +/* Alternate initialize png_ptr structure, and allocate any memory needed */ +png_structp PNGAPI +png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + png_structp png_ptr; +#ifdef PNG_SETJMP_SUPPORTED +#ifdef USE_FAR_KEYWORD + jmp_buf jmpbuf; +#endif +#endif + int i; + png_debug(1, "in png_create_write_struct\n"); +#ifdef PNG_USER_MEM_SUPPORTED + png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, + (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); +#else + png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); +#endif /* PNG_USER_MEM_SUPPORTED */ + if (png_ptr == NULL) + return (NULL); + +#if !defined(PNG_1_0_X) +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED +#ifdef PNG_MMX_CODE_SUPPORTED + png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ +#endif +#endif +#endif /* PNG_1_0_X */ + + /* added at libpng-1.2.6 */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + png_ptr->user_width_max=PNG_USER_WIDTH_MAX; + png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; +#endif + +#ifdef PNG_SETJMP_SUPPORTED +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) +#else + if (setjmp(png_ptr->jmpbuf)) +#endif + { + png_free(png_ptr, png_ptr->zbuf); + png_ptr->zbuf=NULL; + png_destroy_struct(png_ptr); + return (NULL); + } +#ifdef USE_FAR_KEYWORD + png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); +#endif +#endif + +#ifdef PNG_USER_MEM_SUPPORTED + png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); +#endif /* PNG_USER_MEM_SUPPORTED */ + png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); + + i=0; + do + { + if(user_png_ver[i] != png_libpng_ver[i]) + png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; + } while (png_libpng_ver[i++]); + + if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) + { + /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so + * we must recompile any applications that use any older library version. + * For versions after libpng 1.0, we will be compatible, so we need + * only check the first digit. + */ + if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || + (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || + (user_png_ver[0] == '0' && user_png_ver[2] < '9')) + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char msg[80]; + if (user_png_ver) + { + sprintf(msg, "Application was compiled with png.h from libpng-%.20s", + user_png_ver); + png_warning(png_ptr, msg); + } + sprintf(msg, "Application is running with png.c from libpng-%.20s", + png_libpng_ver); + png_warning(png_ptr, msg); +#endif +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "Incompatible libpng version in application and library"); + } + } + + /* initialize zbuf - compression buffer */ + png_ptr->zbuf_size = PNG_ZBUF_SIZE; + png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, + (png_uint_32)png_ptr->zbuf_size); + + png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, + png_flush_ptr_NULL); + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, + 1, png_doublep_NULL, png_doublep_NULL); +#endif + +#ifdef PNG_SETJMP_SUPPORTED +/* Applications that neglect to set up their own setjmp() and then encounter + a png_error() will longjmp here. Since the jmpbuf is then meaningless we + abort instead of returning. */ +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) + PNG_ABORT(); + png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); +#else + if (setjmp(png_ptr->jmpbuf)) + PNG_ABORT(); +#endif +#endif + return (png_ptr); +} + +/* Initialize png_ptr structure, and allocate any memory needed */ +#if defined(PNG_1_0_X) || defined(PNG_1_2_X) +/* Deprecated. */ +#undef png_write_init +void PNGAPI +png_write_init(png_structp png_ptr) +{ + /* We only come here via pre-1.0.7-compiled applications */ + png_write_init_2(png_ptr, "1.0.6 or earlier", 0, 0); +} + +void PNGAPI +png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, + png_size_t png_struct_size, png_size_t png_info_size) +{ + /* We only come here via pre-1.0.12-compiled applications */ + if(png_ptr == NULL) return; +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + if(png_sizeof(png_struct) > png_struct_size || + png_sizeof(png_info) > png_info_size) + { + char msg[80]; + png_ptr->warning_fn=NULL; + if (user_png_ver) + { + sprintf(msg, "Application was compiled with png.h from libpng-%.20s", + user_png_ver); + png_warning(png_ptr, msg); + } + sprintf(msg, "Application is running with png.c from libpng-%.20s", + png_libpng_ver); + png_warning(png_ptr, msg); + } +#endif + if(png_sizeof(png_struct) > png_struct_size) + { + png_ptr->error_fn=NULL; +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "The png struct allocated by the application for writing is too small."); + } + if(png_sizeof(png_info) > png_info_size) + { + png_ptr->error_fn=NULL; +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "The info struct allocated by the application for writing is too small."); + } + png_write_init_3(&png_ptr, user_png_ver, png_struct_size); +} +#endif /* PNG_1_0_X || PNG_1_2_X */ + + +void PNGAPI +png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, + png_size_t png_struct_size) +{ + png_structp png_ptr=*ptr_ptr; +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf tmp_jmp; /* to save current jump buffer */ +#endif + + int i = 0; + + if (png_ptr == NULL) + return; + + do + { + if (user_png_ver[i] != png_libpng_ver[i]) + { +#ifdef PNG_LEGACY_SUPPORTED + png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; +#else + png_ptr->warning_fn=NULL; + png_warning(png_ptr, + "Application uses deprecated png_write_init() and should be recompiled."); + break; +#endif + } + } while (png_libpng_ver[i++]); + + png_debug(1, "in png_write_init_3\n"); + +#ifdef PNG_SETJMP_SUPPORTED + /* save jump buffer and error functions */ + png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); +#endif + + if (png_sizeof(png_struct) > png_struct_size) + { + png_destroy_struct(png_ptr); + png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); + *ptr_ptr = png_ptr; + } + + /* reset all variables to 0 */ + png_memset(png_ptr, 0, png_sizeof (png_struct)); + + /* added at libpng-1.2.6 */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + png_ptr->user_width_max=PNG_USER_WIDTH_MAX; + png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; +#endif + +#if !defined(PNG_1_0_X) +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED +#ifdef PNG_MMX_CODE_SUPPORTED + png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ +#endif +#endif +#endif /* PNG_1_0_X */ + +#ifdef PNG_SETJMP_SUPPORTED + /* restore jump buffer */ + png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); +#endif + + png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, + png_flush_ptr_NULL); + + /* initialize zbuf - compression buffer */ + png_ptr->zbuf_size = PNG_ZBUF_SIZE; + png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, + (png_uint_32)png_ptr->zbuf_size); + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, + 1, png_doublep_NULL, png_doublep_NULL); +#endif +} + +/* Write a few rows of image data. If the image is interlaced, + * either you will have to write the 7 sub images, or, if you + * have called png_set_interlace_handling(), you will have to + * "write" the image seven times. + */ +void PNGAPI +png_write_rows(png_structp png_ptr, png_bytepp row, + png_uint_32 num_rows) +{ + png_uint_32 i; /* row counter */ + png_bytepp rp; /* row pointer */ + + png_debug(1, "in png_write_rows\n"); + + if (png_ptr == NULL) + return; + + /* loop through the rows */ + for (i = 0, rp = row; i < num_rows; i++, rp++) + { + png_write_row(png_ptr, *rp); + } +} + +/* Write the image. You only need to call this function once, even + * if you are writing an interlaced image. + */ +void PNGAPI +png_write_image(png_structp png_ptr, png_bytepp image) +{ + png_uint_32 i; /* row index */ + int pass, num_pass; /* pass variables */ + png_bytepp rp; /* points to current row */ + + if (png_ptr == NULL) + return; + + png_debug(1, "in png_write_image\n"); +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) + /* intialize interlace handling. If image is not interlaced, + this will set pass to 1 */ + num_pass = png_set_interlace_handling(png_ptr); +#else + num_pass = 1; +#endif + /* loop through passes */ + for (pass = 0; pass < num_pass; pass++) + { + /* loop through image */ + for (i = 0, rp = image; i < png_ptr->height; i++, rp++) + { + png_write_row(png_ptr, *rp); + } + } +} + +/* called by user to write a row of image data */ +void PNGAPI +png_write_row(png_structp png_ptr, png_bytep row) +{ + if (png_ptr == NULL) + return; + png_debug2(1, "in png_write_row (row %ld, pass %d)\n", + png_ptr->row_number, png_ptr->pass); + + /* initialize transformations and other stuff if first time */ + if (png_ptr->row_number == 0 && png_ptr->pass == 0) + { + /* make sure we wrote the header info */ + if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) + png_error(png_ptr, + "png_write_info was never called before png_write_row."); + + /* check for transforms that have been set but were defined out */ +#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) + if (png_ptr->transformations & PNG_INVERT_MONO) + png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined."); +#endif +#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED) + if (png_ptr->transformations & PNG_FILLER) + png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined."); +#endif +#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined."); +#endif +#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED) + if (png_ptr->transformations & PNG_PACK) + png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined."); +#endif +#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED) + if (png_ptr->transformations & PNG_SHIFT) + png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined."); +#endif +#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED) + if (png_ptr->transformations & PNG_BGR) + png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined."); +#endif +#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED) + if (png_ptr->transformations & PNG_SWAP_BYTES) + png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined."); +#endif + + png_write_start_row(png_ptr); + } + +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) + /* if interlaced and not interested in row, return */ + if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) + { + switch (png_ptr->pass) + { + case 0: + if (png_ptr->row_number & 0x07) + { + png_write_finish_row(png_ptr); + return; + } + break; + case 1: + if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) + { + png_write_finish_row(png_ptr); + return; + } + break; + case 2: + if ((png_ptr->row_number & 0x07) != 4) + { + png_write_finish_row(png_ptr); + return; + } + break; + case 3: + if ((png_ptr->row_number & 0x03) || png_ptr->width < 3) + { + png_write_finish_row(png_ptr); + return; + } + break; + case 4: + if ((png_ptr->row_number & 0x03) != 2) + { + png_write_finish_row(png_ptr); + return; + } + break; + case 5: + if ((png_ptr->row_number & 0x01) || png_ptr->width < 2) + { + png_write_finish_row(png_ptr); + return; + } + break; + case 6: + if (!(png_ptr->row_number & 0x01)) + { + png_write_finish_row(png_ptr); + return; + } + break; + } + } +#endif + + /* set up row info for transformations */ + png_ptr->row_info.color_type = png_ptr->color_type; + png_ptr->row_info.width = png_ptr->usr_width; + png_ptr->row_info.channels = png_ptr->usr_channels; + png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth; + png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * + png_ptr->row_info.channels); + + png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, + png_ptr->row_info.width); + + png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type); + png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width); + png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels); + png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth); + png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth); + png_debug1(3, "row_info->rowbytes = %lu\n", png_ptr->row_info.rowbytes); + + /* Copy user's row into buffer, leaving room for filter byte. */ + png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row, + png_ptr->row_info.rowbytes); + +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) + /* handle interlacing */ + if (png_ptr->interlaced && png_ptr->pass < 6 && + (png_ptr->transformations & PNG_INTERLACE)) + { + png_do_write_interlace(&(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->pass); + /* this should always get caught above, but still ... */ + if (!(png_ptr->row_info.width)) + { + png_write_finish_row(png_ptr); + return; + } + } +#endif + + /* handle other transformations */ + if (png_ptr->transformations) + png_do_write_transformations(png_ptr); + +#if defined(PNG_MNG_FEATURES_SUPPORTED) + /* Write filter_method 64 (intrapixel differencing) only if + * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and + * 2. Libpng did not write a PNG signature (this filter_method is only + * used in PNG datastreams that are embedded in MNG datastreams) and + * 3. The application called png_permit_mng_features with a mask that + * included PNG_FLAG_MNG_FILTER_64 and + * 4. The filter_method is 64 and + * 5. The color_type is RGB or RGBA + */ + if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) + { + /* Intrapixel differencing */ + png_do_write_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); + } +#endif + + /* Find a filter if necessary, filter the row and write it out. */ + png_write_find_filter(png_ptr, &(png_ptr->row_info)); + + if (png_ptr->write_row_fn != NULL) + (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); +} + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +/* Set the automatic flush interval or 0 to turn flushing off */ +void PNGAPI +png_set_flush(png_structp png_ptr, int nrows) +{ + png_debug(1, "in png_set_flush\n"); + if (png_ptr == NULL) + return; + png_ptr->flush_dist = (nrows < 0 ? 0 : nrows); +} + +/* flush the current output buffers now */ +void PNGAPI +png_write_flush(png_structp png_ptr) +{ + int wrote_IDAT; + + png_debug(1, "in png_write_flush\n"); + if (png_ptr == NULL) + return; + /* We have already written out all of the data */ + if (png_ptr->row_number >= png_ptr->num_rows) + return; + + do + { + int ret; + + /* compress the data */ + ret = deflate(&png_ptr->zstream, Z_SYNC_FLUSH); + wrote_IDAT = 0; + + /* check for compression errors */ + if (ret != Z_OK) + { + if (png_ptr->zstream.msg != NULL) + png_error(png_ptr, png_ptr->zstream.msg); + else + png_error(png_ptr, "zlib error"); + } + + if (!(png_ptr->zstream.avail_out)) + { + /* write the IDAT and reset the zlib output buffer */ + png_write_IDAT(png_ptr, png_ptr->zbuf, + png_ptr->zbuf_size); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + wrote_IDAT = 1; + } + } while(wrote_IDAT == 1); + + /* If there is any data left to be output, write it into a new IDAT */ + if (png_ptr->zbuf_size != png_ptr->zstream.avail_out) + { + /* write the IDAT and reset the zlib output buffer */ + png_write_IDAT(png_ptr, png_ptr->zbuf, + png_ptr->zbuf_size - png_ptr->zstream.avail_out); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + } + png_ptr->flush_rows = 0; + png_flush(png_ptr); +} +#endif /* PNG_WRITE_FLUSH_SUPPORTED */ + +/* free all memory used by the write */ +void PNGAPI +png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) +{ + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; +#ifdef PNG_USER_MEM_SUPPORTED + png_free_ptr free_fn = NULL; + png_voidp mem_ptr = NULL; +#endif + + png_debug(1, "in png_destroy_write_struct\n"); + if (png_ptr_ptr != NULL) + { + png_ptr = *png_ptr_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + free_fn = png_ptr->free_fn; + mem_ptr = png_ptr->mem_ptr; +#endif + } + + if (info_ptr_ptr != NULL) + info_ptr = *info_ptr_ptr; + + if (info_ptr != NULL) + { + png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + if (png_ptr->num_chunk_list) + { + png_free(png_ptr, png_ptr->chunk_list); + png_ptr->chunk_list=NULL; + png_ptr->num_chunk_list=0; + } +#endif + +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)info_ptr); +#endif + *info_ptr_ptr = NULL; + } + + if (png_ptr != NULL) + { + png_write_destroy(png_ptr); +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)png_ptr); +#endif + *png_ptr_ptr = NULL; + } +} + + +/* Free any memory used in png_ptr struct (old method) */ +void /* PRIVATE */ +png_write_destroy(png_structp png_ptr) +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf tmp_jmp; /* save jump buffer */ +#endif + png_error_ptr error_fn; + png_error_ptr warning_fn; + png_voidp error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + png_free_ptr free_fn; +#endif + + png_debug(1, "in png_write_destroy\n"); + /* free any memory zlib uses */ + deflateEnd(&png_ptr->zstream); + + /* free our memory. png_free checks NULL for us. */ + png_free(png_ptr, png_ptr->zbuf); + png_free(png_ptr, png_ptr->row_buf); + png_free(png_ptr, png_ptr->prev_row); + png_free(png_ptr, png_ptr->sub_row); + png_free(png_ptr, png_ptr->up_row); + png_free(png_ptr, png_ptr->avg_row); + png_free(png_ptr, png_ptr->paeth_row); + +#if defined(PNG_TIME_RFC1123_SUPPORTED) + png_free(png_ptr, png_ptr->time_buffer); +#endif + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + png_free(png_ptr, png_ptr->prev_filters); + png_free(png_ptr, png_ptr->filter_weights); + png_free(png_ptr, png_ptr->inv_filter_weights); + png_free(png_ptr, png_ptr->filter_costs); + png_free(png_ptr, png_ptr->inv_filter_costs); +#endif + +#ifdef PNG_SETJMP_SUPPORTED + /* reset structure */ + png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); +#endif + + error_fn = png_ptr->error_fn; + warning_fn = png_ptr->warning_fn; + error_ptr = png_ptr->error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + free_fn = png_ptr->free_fn; +#endif + + png_memset(png_ptr, 0, png_sizeof (png_struct)); + + png_ptr->error_fn = error_fn; + png_ptr->warning_fn = warning_fn; + png_ptr->error_ptr = error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + png_ptr->free_fn = free_fn; +#endif + +#ifdef PNG_SETJMP_SUPPORTED + png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); +#endif +} + +/* Allow the application to select one or more row filters to use. */ +void PNGAPI +png_set_filter(png_structp png_ptr, int method, int filters) +{ + png_debug(1, "in png_set_filter\n"); + if (png_ptr == NULL) + return; +#if defined(PNG_MNG_FEATURES_SUPPORTED) + if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (method == PNG_INTRAPIXEL_DIFFERENCING)) + method = PNG_FILTER_TYPE_BASE; +#endif + if (method == PNG_FILTER_TYPE_BASE) + { + switch (filters & (PNG_ALL_FILTERS | 0x07)) + { + case 5: + case 6: + case 7: png_warning(png_ptr, "Unknown row filter for method 0"); + case PNG_FILTER_VALUE_NONE: png_ptr->do_filter=PNG_FILTER_NONE; break; + case PNG_FILTER_VALUE_SUB: png_ptr->do_filter=PNG_FILTER_SUB; break; + case PNG_FILTER_VALUE_UP: png_ptr->do_filter=PNG_FILTER_UP; break; + case PNG_FILTER_VALUE_AVG: png_ptr->do_filter=PNG_FILTER_AVG; break; + case PNG_FILTER_VALUE_PAETH: png_ptr->do_filter=PNG_FILTER_PAETH;break; + default: png_ptr->do_filter = (png_byte)filters; break; + } + + /* If we have allocated the row_buf, this means we have already started + * with the image and we should have allocated all of the filter buffers + * that have been selected. If prev_row isn't already allocated, then + * it is too late to start using the filters that need it, since we + * will be missing the data in the previous row. If an application + * wants to start and stop using particular filters during compression, + * it should start out with all of the filters, and then add and + * remove them after the start of compression. + */ + if (png_ptr->row_buf != NULL) + { + if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL) + { + png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, + (png_ptr->rowbytes + 1)); + png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; + } + + if ((png_ptr->do_filter & PNG_FILTER_UP) && png_ptr->up_row == NULL) + { + if (png_ptr->prev_row == NULL) + { + png_warning(png_ptr, "Can't add Up filter after starting"); + png_ptr->do_filter &= ~PNG_FILTER_UP; + } + else + { + png_ptr->up_row = (png_bytep)png_malloc(png_ptr, + (png_ptr->rowbytes + 1)); + png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; + } + } + + if ((png_ptr->do_filter & PNG_FILTER_AVG) && png_ptr->avg_row == NULL) + { + if (png_ptr->prev_row == NULL) + { + png_warning(png_ptr, "Can't add Average filter after starting"); + png_ptr->do_filter &= ~PNG_FILTER_AVG; + } + else + { + png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, + (png_ptr->rowbytes + 1)); + png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; + } + } + + if ((png_ptr->do_filter & PNG_FILTER_PAETH) && + png_ptr->paeth_row == NULL) + { + if (png_ptr->prev_row == NULL) + { + png_warning(png_ptr, "Can't add Paeth filter after starting"); + png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH); + } + else + { + png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, + (png_ptr->rowbytes + 1)); + png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; + } + } + + if (png_ptr->do_filter == PNG_NO_FILTERS) + png_ptr->do_filter = PNG_FILTER_NONE; + } + } + else + png_error(png_ptr, "Unknown custom filter method"); +} + +/* This allows us to influence the way in which libpng chooses the "best" + * filter for the current scanline. While the "minimum-sum-of-absolute- + * differences metric is relatively fast and effective, there is some + * question as to whether it can be improved upon by trying to keep the + * filtered data going to zlib more consistent, hopefully resulting in + * better compression. + */ +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* GRR 970116 */ +void PNGAPI +png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, + int num_weights, png_doublep filter_weights, + png_doublep filter_costs) +{ + int i; + + png_debug(1, "in png_set_filter_heuristics\n"); + if (png_ptr == NULL) + return; + if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST) + { + png_warning(png_ptr, "Unknown filter heuristic method"); + return; + } + + if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT) + { + heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED; + } + + if (num_weights < 0 || filter_weights == NULL || + heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED) + { + num_weights = 0; + } + + png_ptr->num_prev_filters = (png_byte)num_weights; + png_ptr->heuristic_method = (png_byte)heuristic_method; + + if (num_weights > 0) + { + if (png_ptr->prev_filters == NULL) + { + png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr, + (png_uint_32)(png_sizeof(png_byte) * num_weights)); + + /* To make sure that the weighting starts out fairly */ + for (i = 0; i < num_weights; i++) + { + png_ptr->prev_filters[i] = 255; + } + } + + if (png_ptr->filter_weights == NULL) + { + png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); + + png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); + for (i = 0; i < num_weights; i++) + { + png_ptr->inv_filter_weights[i] = + png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; + } + } + + for (i = 0; i < num_weights; i++) + { + if (filter_weights[i] < 0.0) + { + png_ptr->inv_filter_weights[i] = + png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; + } + else + { + png_ptr->inv_filter_weights[i] = + (png_uint_16)((double)PNG_WEIGHT_FACTOR*filter_weights[i]+0.5); + png_ptr->filter_weights[i] = + (png_uint_16)((double)PNG_WEIGHT_FACTOR/filter_weights[i]+0.5); + } + } + } + + /* If, in the future, there are other filter methods, this would + * need to be based on png_ptr->filter. + */ + if (png_ptr->filter_costs == NULL) + { + png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); + + png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); + + for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) + { + png_ptr->inv_filter_costs[i] = + png_ptr->filter_costs[i] = PNG_COST_FACTOR; + } + } + + /* Here is where we set the relative costs of the different filters. We + * should take the desired compression level into account when setting + * the costs, so that Paeth, for instance, has a high relative cost at low + * compression levels, while it has a lower relative cost at higher + * compression settings. The filter types are in order of increasing + * relative cost, so it would be possible to do this with an algorithm. + */ + for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) + { + if (filter_costs == NULL || filter_costs[i] < 0.0) + { + png_ptr->inv_filter_costs[i] = + png_ptr->filter_costs[i] = PNG_COST_FACTOR; + } + else if (filter_costs[i] >= 1.0) + { + png_ptr->inv_filter_costs[i] = + (png_uint_16)((double)PNG_COST_FACTOR / filter_costs[i] + 0.5); + png_ptr->filter_costs[i] = + (png_uint_16)((double)PNG_COST_FACTOR * filter_costs[i] + 0.5); + } + } +} +#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ + +void PNGAPI +png_set_compression_level(png_structp png_ptr, int level) +{ + png_debug(1, "in png_set_compression_level\n"); + if (png_ptr == NULL) + return; + png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL; + png_ptr->zlib_level = level; +} + +void PNGAPI +png_set_compression_mem_level(png_structp png_ptr, int mem_level) +{ + png_debug(1, "in png_set_compression_mem_level\n"); + if (png_ptr == NULL) + return; + png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL; + png_ptr->zlib_mem_level = mem_level; +} + +void PNGAPI +png_set_compression_strategy(png_structp png_ptr, int strategy) +{ + png_debug(1, "in png_set_compression_strategy\n"); + if (png_ptr == NULL) + return; + png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY; + png_ptr->zlib_strategy = strategy; +} + +void PNGAPI +png_set_compression_window_bits(png_structp png_ptr, int window_bits) +{ + if (png_ptr == NULL) + return; + if (window_bits > 15) + png_warning(png_ptr, "Only compression windows <= 32k supported by PNG"); + else if (window_bits < 8) + png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); +#ifndef WBITS_8_OK + /* avoid libpng bug with 256-byte windows */ + if (window_bits == 8) + { + png_warning(png_ptr, "Compression window is being reset to 512"); + window_bits=9; + } +#endif + png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS; + png_ptr->zlib_window_bits = window_bits; +} + +void PNGAPI +png_set_compression_method(png_structp png_ptr, int method) +{ + png_debug(1, "in png_set_compression_method\n"); + if (png_ptr == NULL) + return; + if (method != 8) + png_warning(png_ptr, "Only compression method 8 is supported by PNG"); + png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD; + png_ptr->zlib_method = method; +} + +void PNGAPI +png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn) +{ + if (png_ptr == NULL) + return; + png_ptr->write_row_fn = write_row_fn; +} + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +void PNGAPI +png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr + write_user_transform_fn) +{ + png_debug(1, "in png_set_write_user_transform_fn\n"); + if (png_ptr == NULL) + return; + png_ptr->transformations |= PNG_USER_TRANSFORM; + png_ptr->write_user_transform_fn = write_user_transform_fn; +} +#endif + + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +void PNGAPI +png_write_png(png_structp png_ptr, png_infop info_ptr, + int transforms, voidp params) +{ + if (png_ptr == NULL || info_ptr == NULL) + return; +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) + /* invert the alpha channel from opacity to transparency */ + if (transforms & PNG_TRANSFORM_INVERT_ALPHA) + png_set_invert_alpha(png_ptr); +#endif + + /* Write the file header information. */ + png_write_info(png_ptr, info_ptr); + + /* ------ these transformations don't touch the info structure ------- */ + +#if defined(PNG_WRITE_INVERT_SUPPORTED) + /* invert monochrome pixels */ + if (transforms & PNG_TRANSFORM_INVERT_MONO) + png_set_invert_mono(png_ptr); +#endif + +#if defined(PNG_WRITE_SHIFT_SUPPORTED) + /* Shift the pixels up to a legal bit depth and fill in + * as appropriate to correctly scale the image. + */ + if ((transforms & PNG_TRANSFORM_SHIFT) + && (info_ptr->valid & PNG_INFO_sBIT)) + png_set_shift(png_ptr, &info_ptr->sig_bit); +#endif + +#if defined(PNG_WRITE_PACK_SUPPORTED) + /* pack pixels into bytes */ + if (transforms & PNG_TRANSFORM_PACKING) + png_set_packing(png_ptr); +#endif + +#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) + /* swap location of alpha bytes from ARGB to RGBA */ + if (transforms & PNG_TRANSFORM_SWAP_ALPHA) + png_set_swap_alpha(png_ptr); +#endif + +#if defined(PNG_WRITE_FILLER_SUPPORTED) + /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into + * RGB (4 channels -> 3 channels). The second parameter is not used. + */ + if (transforms & PNG_TRANSFORM_STRIP_FILLER) + png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); +#endif + +#if defined(PNG_WRITE_BGR_SUPPORTED) + /* flip BGR pixels to RGB */ + if (transforms & PNG_TRANSFORM_BGR) + png_set_bgr(png_ptr); +#endif + +#if defined(PNG_WRITE_SWAP_SUPPORTED) + /* swap bytes of 16-bit files to most significant byte first */ + if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) + png_set_swap(png_ptr); +#endif + +#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) + /* swap bits of 1, 2, 4 bit packed pixel formats */ + if (transforms & PNG_TRANSFORM_PACKSWAP) + png_set_packswap(png_ptr); +#endif + + /* ----------------------- end of transformations ------------------- */ + + /* write the bits */ + if (info_ptr->valid & PNG_INFO_IDAT) + png_write_image(png_ptr, info_ptr->row_pointers); + + /* It is REQUIRED to call this to finish writing the rest of the file */ + png_write_end(png_ptr, info_ptr); + + if(transforms == 0 || params == NULL) + /* quiet compiler warnings */ return; +} +#endif +#endif /* PNG_WRITE_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/pngwtran.c b/src/dep/src/irrlicht/libpng/pngwtran.c index 19b2968..0372fe6 100644 --- a/src/dep/src/irrlicht/libpng/pngwtran.c +++ b/src/dep/src/irrlicht/libpng/pngwtran.c @@ -1,572 +1,572 @@ - -/* pngwtran.c - transforms the data in a row for PNG writers - * - * Last changed in libpng 1.2.9 April 14, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Transform the data according to the user's wishes. The order of - * transformations is significant. - */ -void /* PRIVATE */ -png_do_write_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_do_write_transformations\n"); - - if (png_ptr == NULL) - return; - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - if (png_ptr->transformations & PNG_USER_TRANSFORM) - if(png_ptr->write_user_transform_fn != NULL) - (*(png_ptr->write_user_transform_fn)) /* user write transform function */ - (png_ptr, /* png_ptr */ - &(png_ptr->row_info), /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_uint_32 rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ -#endif -#if defined(PNG_WRITE_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->flags); -#endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1, - (png_uint_32)png_ptr->bit_depth); -#endif -#if defined(PNG_WRITE_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->shift)); -#endif -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -} - -#if defined(PNG_WRITE_PACK_SUPPORTED) -/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The - * row_info bit depth should be 8 (one pixel per byte). The channels - * should be 1 (this only happens on grayscale and paletted images). - */ -void /* PRIVATE */ -png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) -{ - png_debug(1, "in png_do_pack\n"); - if (row_info->bit_depth == 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->channels == 1) - { - switch ((int)bit_depth) - { - case 1: - { - png_bytep sp, dp; - int mask, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - mask = 0x80; - v = 0; - - for (i = 0; i < row_width; i++) - { - if (*sp != 0) - v |= mask; - sp++; - if (mask > 1) - mask >>= 1; - else - { - mask = 0x80; - *dp = (png_byte)v; - dp++; - v = 0; - } - } - if (mask != 0x80) - *dp = (png_byte)v; - break; - } - case 2: - { - png_bytep sp, dp; - int shift, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - shift = 6; - v = 0; - for (i = 0; i < row_width; i++) - { - png_byte value; - - value = (png_byte)(*sp & 0x03); - v |= (value << shift); - if (shift == 0) - { - shift = 6; - *dp = (png_byte)v; - dp++; - v = 0; - } - else - shift -= 2; - sp++; - } - if (shift != 6) - *dp = (png_byte)v; - break; - } - case 4: - { - png_bytep sp, dp; - int shift, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - shift = 4; - v = 0; - for (i = 0; i < row_width; i++) - { - png_byte value; - - value = (png_byte)(*sp & 0x0f); - v |= (value << shift); - - if (shift == 0) - { - shift = 4; - *dp = (png_byte)v; - dp++; - v = 0; - } - else - shift -= 4; - - sp++; - } - if (shift != 4) - *dp = (png_byte)v; - break; - } - } - row_info->bit_depth = (png_byte)bit_depth; - row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_info->width); - } -} -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) -/* Shift pixel values to take advantage of whole range. Pass the - * true number of bits in bit_depth. The row should be packed - * according to row_info->bit_depth. Thus, if you had a row of - * bit depth 4, but the pixels only had values from 0 to 7, you - * would pass 3 as bit_depth, and this routine would translate the - * data to 0 to 15. - */ -void /* PRIVATE */ -png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) -{ - png_debug(1, "in png_do_shift\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && -#else - if ( -#endif - row_info->color_type != PNG_COLOR_TYPE_PALETTE) - { - int shift_start[4], shift_dec[4]; - int channels = 0; - - if (row_info->color_type & PNG_COLOR_MASK_COLOR) - { - shift_start[channels] = row_info->bit_depth - bit_depth->red; - shift_dec[channels] = bit_depth->red; - channels++; - shift_start[channels] = row_info->bit_depth - bit_depth->green; - shift_dec[channels] = bit_depth->green; - channels++; - shift_start[channels] = row_info->bit_depth - bit_depth->blue; - shift_dec[channels] = bit_depth->blue; - channels++; - } - else - { - shift_start[channels] = row_info->bit_depth - bit_depth->gray; - shift_dec[channels] = bit_depth->gray; - channels++; - } - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - shift_start[channels] = row_info->bit_depth - bit_depth->alpha; - shift_dec[channels] = bit_depth->alpha; - channels++; - } - - /* with low row depths, could only be grayscale, so one channel */ - if (row_info->bit_depth < 8) - { - png_bytep bp = row; - png_uint_32 i; - png_byte mask; - png_uint_32 row_bytes = row_info->rowbytes; - - if (bit_depth->gray == 1 && row_info->bit_depth == 2) - mask = 0x55; - else if (row_info->bit_depth == 4 && bit_depth->gray == 3) - mask = 0x11; - else - mask = 0xff; - - for (i = 0; i < row_bytes; i++, bp++) - { - png_uint_16 v; - int j; - - v = *bp; - *bp = 0; - for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0]) - { - if (j > 0) - *bp |= (png_byte)((v << j) & 0xff); - else - *bp |= (png_byte)((v >> (-j)) & mask); - } - } - } - else if (row_info->bit_depth == 8) - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = channels * row_info->width; - - for (i = 0; i < istop; i++, bp++) - { - - png_uint_16 v; - int j; - int c = (int)(i%channels); - - v = *bp; - *bp = 0; - for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) - { - if (j > 0) - *bp |= (png_byte)((v << j) & 0xff); - else - *bp |= (png_byte)((v >> (-j)) & 0xff); - } - } - } - else - { - png_bytep bp; - png_uint_32 i; - png_uint_32 istop = channels * row_info->width; - - for (bp = row, i = 0; i < istop; i++) - { - int c = (int)(i%channels); - png_uint_16 value, v; - int j; - - v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1)); - value = 0; - for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) - { - if (j > 0) - value |= (png_uint_16)((v << j) & (png_uint_16)0xffff); - else - value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff); - } - *bp++ = (png_byte)(value >> 8); - *bp++ = (png_byte)(value & 0xff); - } - } - } -} -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_swap_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This converts from ARGB to RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save; - } - } - /* This converts from AARRGGBB to RRGGBBAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save[2]; - save[0] = *(sp++); - save[1] = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save[0]; - *(dp++) = save[1]; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This converts from AG to GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save; - } - } - /* This converts from AAGG to GGAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save[2]; - save[0] = *(sp++); - save[1] = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save[0]; - *(dp++) = save[1]; - } - } - } - } -} -#endif - -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_invert_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This inverts the alpha channel in RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - for (i = 0, sp = dp = row; i < row_width; i++) - { - /* does nothing - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - */ - sp+=3; dp = sp; - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - /* This inverts the alpha channel in RRGGBBAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - /* does nothing - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - */ - sp+=6; dp = sp; - *(dp++) = (png_byte)(255 - *(sp++)); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This inverts the alpha channel in GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - *(dp++) = *(sp++); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - /* This inverts the alpha channel in GGAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - /* does nothing - *(dp++) = *(sp++); - *(dp++) = *(sp++); - */ - sp+=2; dp = sp; - *(dp++) = (png_byte)(255 - *(sp++)); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - } - } -} -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -/* undoes intrapixel differencing */ -void /* PRIVATE */ -png_do_write_intrapixel(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_intrapixel\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - int bytes_per_pixel; - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 3; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 4; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - *(rp) = (png_byte)((*rp - *(rp+1))&0xff); - *(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff); - } - } - else if (row_info->bit_depth == 16) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 6; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 8; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); - png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); - png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); - png_uint_32 red = (png_uint_32)((s0-s1) & 0xffffL); - png_uint_32 blue = (png_uint_32)((s2-s1) & 0xffffL); - *(rp ) = (png_byte)((red >> 8) & 0xff); - *(rp+1) = (png_byte)(red & 0xff); - *(rp+4) = (png_byte)((blue >> 8) & 0xff); - *(rp+5) = (png_byte)(blue & 0xff); - } - } - } -} -#endif /* PNG_MNG_FEATURES_SUPPORTED */ -#endif /* PNG_WRITE_SUPPORTED */ + +/* pngwtran.c - transforms the data in a row for PNG writers + * + * Last changed in libpng 1.2.9 April 14, 2006 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +#define PNG_INTERNAL +#include "png.h" +#ifdef PNG_WRITE_SUPPORTED + +/* Transform the data according to the user's wishes. The order of + * transformations is significant. + */ +void /* PRIVATE */ +png_do_write_transformations(png_structp png_ptr) +{ + png_debug(1, "in png_do_write_transformations\n"); + + if (png_ptr == NULL) + return; + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + if (png_ptr->transformations & PNG_USER_TRANSFORM) + if(png_ptr->write_user_transform_fn != NULL) + (*(png_ptr->write_user_transform_fn)) /* user write transform function */ + (png_ptr, /* png_ptr */ + &(png_ptr->row_info), /* row_info: */ + /* png_uint_32 width; width of row */ + /* png_uint_32 rowbytes; number of bytes in row */ + /* png_byte color_type; color type of pixels */ + /* png_byte bit_depth; bit depth of samples */ + /* png_byte channels; number of channels (1-4) */ + /* png_byte pixel_depth; bits per pixel (depth*channels) */ + png_ptr->row_buf + 1); /* start of pixel data for row */ +#endif +#if defined(PNG_WRITE_FILLER_SUPPORTED) + if (png_ptr->transformations & PNG_FILLER) + png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, + png_ptr->flags); +#endif +#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif +#if defined(PNG_WRITE_PACK_SUPPORTED) + if (png_ptr->transformations & PNG_PACK) + png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1, + (png_uint_32)png_ptr->bit_depth); +#endif +#if defined(PNG_WRITE_SWAP_SUPPORTED) + if (png_ptr->transformations & PNG_SWAP_BYTES) + png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif +#if defined(PNG_WRITE_SHIFT_SUPPORTED) + if (png_ptr->transformations & PNG_SHIFT) + png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1, + &(png_ptr->shift)); +#endif +#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) + if (png_ptr->transformations & PNG_SWAP_ALPHA) + png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) + if (png_ptr->transformations & PNG_INVERT_ALPHA) + png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif +#if defined(PNG_WRITE_BGR_SUPPORTED) + if (png_ptr->transformations & PNG_BGR) + png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif +#if defined(PNG_WRITE_INVERT_SUPPORTED) + if (png_ptr->transformations & PNG_INVERT_MONO) + png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif +} + +#if defined(PNG_WRITE_PACK_SUPPORTED) +/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The + * row_info bit depth should be 8 (one pixel per byte). The channels + * should be 1 (this only happens on grayscale and paletted images). + */ +void /* PRIVATE */ +png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) +{ + png_debug(1, "in png_do_pack\n"); + if (row_info->bit_depth == 8 && +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + row_info->channels == 1) + { + switch ((int)bit_depth) + { + case 1: + { + png_bytep sp, dp; + int mask, v; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + sp = row; + dp = row; + mask = 0x80; + v = 0; + + for (i = 0; i < row_width; i++) + { + if (*sp != 0) + v |= mask; + sp++; + if (mask > 1) + mask >>= 1; + else + { + mask = 0x80; + *dp = (png_byte)v; + dp++; + v = 0; + } + } + if (mask != 0x80) + *dp = (png_byte)v; + break; + } + case 2: + { + png_bytep sp, dp; + int shift, v; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + sp = row; + dp = row; + shift = 6; + v = 0; + for (i = 0; i < row_width; i++) + { + png_byte value; + + value = (png_byte)(*sp & 0x03); + v |= (value << shift); + if (shift == 0) + { + shift = 6; + *dp = (png_byte)v; + dp++; + v = 0; + } + else + shift -= 2; + sp++; + } + if (shift != 6) + *dp = (png_byte)v; + break; + } + case 4: + { + png_bytep sp, dp; + int shift, v; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + sp = row; + dp = row; + shift = 4; + v = 0; + for (i = 0; i < row_width; i++) + { + png_byte value; + + value = (png_byte)(*sp & 0x0f); + v |= (value << shift); + + if (shift == 0) + { + shift = 4; + *dp = (png_byte)v; + dp++; + v = 0; + } + else + shift -= 4; + + sp++; + } + if (shift != 4) + *dp = (png_byte)v; + break; + } + } + row_info->bit_depth = (png_byte)bit_depth; + row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, + row_info->width); + } +} +#endif + +#if defined(PNG_WRITE_SHIFT_SUPPORTED) +/* Shift pixel values to take advantage of whole range. Pass the + * true number of bits in bit_depth. The row should be packed + * according to row_info->bit_depth. Thus, if you had a row of + * bit depth 4, but the pixels only had values from 0 to 7, you + * would pass 3 as bit_depth, and this routine would translate the + * data to 0 to 15. + */ +void /* PRIVATE */ +png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) +{ + png_debug(1, "in png_do_shift\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL && +#else + if ( +#endif + row_info->color_type != PNG_COLOR_TYPE_PALETTE) + { + int shift_start[4], shift_dec[4]; + int channels = 0; + + if (row_info->color_type & PNG_COLOR_MASK_COLOR) + { + shift_start[channels] = row_info->bit_depth - bit_depth->red; + shift_dec[channels] = bit_depth->red; + channels++; + shift_start[channels] = row_info->bit_depth - bit_depth->green; + shift_dec[channels] = bit_depth->green; + channels++; + shift_start[channels] = row_info->bit_depth - bit_depth->blue; + shift_dec[channels] = bit_depth->blue; + channels++; + } + else + { + shift_start[channels] = row_info->bit_depth - bit_depth->gray; + shift_dec[channels] = bit_depth->gray; + channels++; + } + if (row_info->color_type & PNG_COLOR_MASK_ALPHA) + { + shift_start[channels] = row_info->bit_depth - bit_depth->alpha; + shift_dec[channels] = bit_depth->alpha; + channels++; + } + + /* with low row depths, could only be grayscale, so one channel */ + if (row_info->bit_depth < 8) + { + png_bytep bp = row; + png_uint_32 i; + png_byte mask; + png_uint_32 row_bytes = row_info->rowbytes; + + if (bit_depth->gray == 1 && row_info->bit_depth == 2) + mask = 0x55; + else if (row_info->bit_depth == 4 && bit_depth->gray == 3) + mask = 0x11; + else + mask = 0xff; + + for (i = 0; i < row_bytes; i++, bp++) + { + png_uint_16 v; + int j; + + v = *bp; + *bp = 0; + for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0]) + { + if (j > 0) + *bp |= (png_byte)((v << j) & 0xff); + else + *bp |= (png_byte)((v >> (-j)) & mask); + } + } + } + else if (row_info->bit_depth == 8) + { + png_bytep bp = row; + png_uint_32 i; + png_uint_32 istop = channels * row_info->width; + + for (i = 0; i < istop; i++, bp++) + { + + png_uint_16 v; + int j; + int c = (int)(i%channels); + + v = *bp; + *bp = 0; + for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) + { + if (j > 0) + *bp |= (png_byte)((v << j) & 0xff); + else + *bp |= (png_byte)((v >> (-j)) & 0xff); + } + } + } + else + { + png_bytep bp; + png_uint_32 i; + png_uint_32 istop = channels * row_info->width; + + for (bp = row, i = 0; i < istop; i++) + { + int c = (int)(i%channels); + png_uint_16 value, v; + int j; + + v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1)); + value = 0; + for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) + { + if (j > 0) + value |= (png_uint_16)((v << j) & (png_uint_16)0xffff); + else + value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff); + } + *bp++ = (png_byte)(value >> 8); + *bp++ = (png_byte)(value & 0xff); + } + } + } +} +#endif + +#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +void /* PRIVATE */ +png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_write_swap_alpha\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif + { + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + /* This converts from ARGB to RGBA */ + if (row_info->bit_depth == 8) + { + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + for (i = 0, sp = dp = row; i < row_width; i++) + { + png_byte save = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = save; + } + } + /* This converts from AARRGGBB to RRGGBBAA */ + else + { + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + for (i = 0, sp = dp = row; i < row_width; i++) + { + png_byte save[2]; + save[0] = *(sp++); + save[1] = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = save[0]; + *(dp++) = save[1]; + } + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + /* This converts from AG to GA */ + if (row_info->bit_depth == 8) + { + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + for (i = 0, sp = dp = row; i < row_width; i++) + { + png_byte save = *(sp++); + *(dp++) = *(sp++); + *(dp++) = save; + } + } + /* This converts from AAGG to GGAA */ + else + { + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + for (i = 0, sp = dp = row; i < row_width; i++) + { + png_byte save[2]; + save[0] = *(sp++); + save[1] = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = save[0]; + *(dp++) = save[1]; + } + } + } + } +} +#endif + +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +void /* PRIVATE */ +png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_write_invert_alpha\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif + { + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + /* This inverts the alpha channel in RGBA */ + if (row_info->bit_depth == 8) + { + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + for (i = 0, sp = dp = row; i < row_width; i++) + { + /* does nothing + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + */ + sp+=3; dp = sp; + *(dp++) = (png_byte)(255 - *(sp++)); + } + } + /* This inverts the alpha channel in RRGGBBAA */ + else + { + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + for (i = 0, sp = dp = row; i < row_width; i++) + { + /* does nothing + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + */ + sp+=6; dp = sp; + *(dp++) = (png_byte)(255 - *(sp++)); + *(dp++) = (png_byte)(255 - *(sp++)); + } + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + /* This inverts the alpha channel in GA */ + if (row_info->bit_depth == 8) + { + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + for (i = 0, sp = dp = row; i < row_width; i++) + { + *(dp++) = *(sp++); + *(dp++) = (png_byte)(255 - *(sp++)); + } + } + /* This inverts the alpha channel in GGAA */ + else + { + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + for (i = 0, sp = dp = row; i < row_width; i++) + { + /* does nothing + *(dp++) = *(sp++); + *(dp++) = *(sp++); + */ + sp+=2; dp = sp; + *(dp++) = (png_byte)(255 - *(sp++)); + *(dp++) = (png_byte)(255 - *(sp++)); + } + } + } + } +} +#endif + +#if defined(PNG_MNG_FEATURES_SUPPORTED) +/* undoes intrapixel differencing */ +void /* PRIVATE */ +png_do_write_intrapixel(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_write_intrapixel\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + (row_info->color_type & PNG_COLOR_MASK_COLOR)) + { + int bytes_per_pixel; + png_uint_32 row_width = row_info->width; + if (row_info->bit_depth == 8) + { + png_bytep rp; + png_uint_32 i; + + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + bytes_per_pixel = 3; + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + bytes_per_pixel = 4; + else + return; + + for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) + { + *(rp) = (png_byte)((*rp - *(rp+1))&0xff); + *(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff); + } + } + else if (row_info->bit_depth == 16) + { + png_bytep rp; + png_uint_32 i; + + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + bytes_per_pixel = 6; + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + bytes_per_pixel = 8; + else + return; + + for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) + { + png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); + png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); + png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); + png_uint_32 red = (png_uint_32)((s0-s1) & 0xffffL); + png_uint_32 blue = (png_uint_32)((s2-s1) & 0xffffL); + *(rp ) = (png_byte)((red >> 8) & 0xff); + *(rp+1) = (png_byte)(red & 0xff); + *(rp+4) = (png_byte)((blue >> 8) & 0xff); + *(rp+5) = (png_byte)(blue & 0xff); + } + } + } +} +#endif /* PNG_MNG_FEATURES_SUPPORTED */ +#endif /* PNG_WRITE_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/pngwutil.c b/src/dep/src/irrlicht/libpng/pngwutil.c index ed87b34..e108c61 100644 --- a/src/dep/src/irrlicht/libpng/pngwutil.c +++ b/src/dep/src/irrlicht/libpng/pngwutil.c @@ -1,2777 +1,2777 @@ - -/* pngwutil.c - utilities to write a PNG file - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Place a 32-bit number into a buffer in PNG byte order. We work - * with unsigned numbers for convenience, although one supported - * ancillary chunk uses signed (two's complement) numbers. - */ -void PNGAPI -png_save_uint_32(png_bytep buf, png_uint_32 i) -{ - buf[0] = (png_byte)((i >> 24) & 0xff); - buf[1] = (png_byte)((i >> 16) & 0xff); - buf[2] = (png_byte)((i >> 8) & 0xff); - buf[3] = (png_byte)(i & 0xff); -} - -/* The png_save_int_32 function assumes integers are stored in two's - * complement format. If this isn't the case, then this routine needs to - * be modified to write data in two's complement format. - */ -void PNGAPI -png_save_int_32(png_bytep buf, png_int_32 i) -{ - buf[0] = (png_byte)((i >> 24) & 0xff); - buf[1] = (png_byte)((i >> 16) & 0xff); - buf[2] = (png_byte)((i >> 8) & 0xff); - buf[3] = (png_byte)(i & 0xff); -} - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -void PNGAPI -png_save_uint_16(png_bytep buf, unsigned int i) -{ - buf[0] = (png_byte)((i >> 8) & 0xff); - buf[1] = (png_byte)(i & 0xff); -} - -/* Write a PNG chunk all at once. The type is an array of ASCII characters - * representing the chunk name. The array must be at least 4 bytes in - * length, and does not need to be null terminated. To be safe, pass the - * pre-defined chunk names here, and if you need a new one, define it - * where the others are defined. The length is the length of the data. - * All the data must be present. If that is not possible, use the - * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end() - * functions instead. - */ -void PNGAPI -png_write_chunk(png_structp png_ptr, png_bytep chunk_name, - png_bytep data, png_size_t length) -{ - if(png_ptr == NULL) return; - png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length); - png_write_chunk_data(png_ptr, data, length); - png_write_chunk_end(png_ptr); -} - -/* Write the start of a PNG chunk. The type is the chunk type. - * The total_length is the sum of the lengths of all the data you will be - * passing in png_write_chunk_data(). - */ -void PNGAPI -png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name, - png_uint_32 length) -{ - png_byte buf[4]; - png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length); - if(png_ptr == NULL) return; - - /* write the length */ - png_save_uint_32(buf, length); - png_write_data(png_ptr, buf, (png_size_t)4); - - /* write the chunk name */ - png_write_data(png_ptr, chunk_name, (png_size_t)4); - /* reset the crc and run it over the chunk name */ - png_reset_crc(png_ptr); - png_calculate_crc(png_ptr, chunk_name, (png_size_t)4); -} - -/* Write the data of a PNG chunk started with png_write_chunk_start(). - * Note that multiple calls to this function are allowed, and that the - * sum of the lengths from these calls *must* add up to the total_length - * given to png_write_chunk_start(). - */ -void PNGAPI -png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - /* write the data, and run the CRC over it */ - if(png_ptr == NULL) return; - if (data != NULL && length > 0) - { - png_calculate_crc(png_ptr, data, length); - png_write_data(png_ptr, data, length); - } -} - -/* Finish a chunk started with png_write_chunk_start(). */ -void PNGAPI -png_write_chunk_end(png_structp png_ptr) -{ - png_byte buf[4]; - - if(png_ptr == NULL) return; - - /* write the crc */ - png_save_uint_32(buf, png_ptr->crc); - - png_write_data(png_ptr, buf, (png_size_t)4); -} - -/* Simple function to write the signature. If we have already written - * the magic bytes of the signature, or more likely, the PNG stream is - * being embedded into another stream and doesn't need its own signature, - * we should call png_set_sig_bytes() to tell libpng how many of the - * bytes have already been written. - */ -void /* PRIVATE */ -png_write_sig(png_structp png_ptr) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - /* write the rest of the 8 byte signature */ - png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], - (png_size_t)8 - png_ptr->sig_bytes); - if(png_ptr->sig_bytes < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; -} - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED) -/* - * This pair of functions encapsulates the operation of (a) compressing a - * text string, and (b) issuing it later as a series of chunk data writes. - * The compression_state structure is shared context for these functions - * set up by the caller in order to make the whole mess thread-safe. - */ - -typedef struct -{ - char *input; /* the uncompressed input data */ - int input_len; /* its length */ - int num_output_ptr; /* number of output pointers used */ - int max_output_ptr; /* size of output_ptr */ - png_charpp output_ptr; /* array of pointers to output */ -} compression_state; - -/* compress given text into storage in the png_ptr structure */ -static int /* PRIVATE */ -png_text_compress(png_structp png_ptr, - png_charp text, png_size_t text_len, int compression, - compression_state *comp) -{ - int ret; - - comp->num_output_ptr = 0; - comp->max_output_ptr = 0; - comp->output_ptr = NULL; - comp->input = NULL; - comp->input_len = 0; - - /* we may just want to pass the text right through */ - if (compression == PNG_TEXT_COMPRESSION_NONE) - { - comp->input = text; - comp->input_len = text_len; - return((int)text_len); - } - - if (compression >= PNG_TEXT_COMPRESSION_LAST) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[50]; - sprintf(msg, "Unknown compression type %d", compression); - png_warning(png_ptr, msg); -#else - png_warning(png_ptr, "Unknown compression type"); -#endif - } - - /* We can't write the chunk until we find out how much data we have, - * which means we need to run the compressor first and save the - * output. This shouldn't be a problem, as the vast majority of - * comments should be reasonable, but we will set up an array of - * malloc'd pointers to be sure. - * - * If we knew the application was well behaved, we could simplify this - * greatly by assuming we can always malloc an output buffer large - * enough to hold the compressed text ((1001 * text_len / 1000) + 12) - * and malloc this directly. The only time this would be a bad idea is - * if we can't malloc more than 64K and we have 64K of random input - * data, or if the input string is incredibly large (although this - * wouldn't cause a failure, just a slowdown due to swapping). - */ - - /* set up the compression buffers */ - png_ptr->zstream.avail_in = (uInt)text_len; - png_ptr->zstream.next_in = (Bytef *)text; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf; - - /* this is the same compression loop as in png_write_row() */ - do - { - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); - if (ret != Z_OK) - { - /* error */ - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) - { - /* make sure the output array has room */ - if (comp->num_output_ptr >= comp->max_output_ptr) - { - int old_max; - - old_max = comp->max_output_ptr; - comp->max_output_ptr = comp->num_output_ptr + 4; - if (comp->output_ptr != NULL) - { - png_charpp old_ptr; - - old_ptr = comp->output_ptr; - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charpp))); - png_memcpy(comp->output_ptr, old_ptr, old_max - * png_sizeof (png_charp)); - png_free(png_ptr, old_ptr); - } - else - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charp))); - } - - /* save the data */ - comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, - png_ptr->zbuf_size); - comp->num_output_ptr++; - - /* and reset the buffer */ - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; - } - /* continue until we don't have any more to compress */ - } while (png_ptr->zstream.avail_in); - - /* finish the compression */ - do - { - /* tell zlib we are finished */ - ret = deflate(&png_ptr->zstream, Z_FINISH); - - if (ret == Z_OK) - { - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) - { - /* check to make sure our output array has room */ - if (comp->num_output_ptr >= comp->max_output_ptr) - { - int old_max; - - old_max = comp->max_output_ptr; - comp->max_output_ptr = comp->num_output_ptr + 4; - if (comp->output_ptr != NULL) - { - png_charpp old_ptr; - - old_ptr = comp->output_ptr; - /* This could be optimized to realloc() */ - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charpp))); - png_memcpy(comp->output_ptr, old_ptr, - old_max * png_sizeof (png_charp)); - png_free(png_ptr, old_ptr); - } - else - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charp))); - } - - /* save off the data */ - comp->output_ptr[comp->num_output_ptr] = - (png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); - png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, - png_ptr->zbuf_size); - comp->num_output_ptr++; - - /* and reset the buffer pointers */ - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; - } - } - else if (ret != Z_STREAM_END) - { - /* we got an error */ - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - } while (ret != Z_STREAM_END); - - /* text length is number of buffers plus last buffer */ - text_len = png_ptr->zbuf_size * comp->num_output_ptr; - if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) - text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out; - - return((int)text_len); -} - -/* ship the compressed text out via chunk writes */ -static void /* PRIVATE */ -png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) -{ - int i; - - /* handle the no-compression case */ - if (comp->input) - { - png_write_chunk_data(png_ptr, (png_bytep)comp->input, - (png_size_t)comp->input_len); - return; - } - - /* write saved output buffers, if any */ - for (i = 0; i < comp->num_output_ptr; i++) - { - png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i], - png_ptr->zbuf_size); - png_free(png_ptr, comp->output_ptr[i]); - comp->output_ptr[i]=NULL; - } - if (comp->max_output_ptr != 0) - png_free(png_ptr, comp->output_ptr); - comp->output_ptr=NULL; - /* write anything left in zbuf */ - if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size) - png_write_chunk_data(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - - /* reset zlib for another zTXt/iTXt or image data */ - deflateReset(&png_ptr->zstream); - png_ptr->zstream.data_type = Z_BINARY; -} -#endif - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. Note that the rest of this code depends upon this - * information being correct. - */ -void /* PRIVATE */ -png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, - int bit_depth, int color_type, int compression_type, int filter_type, - int interlace_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; -#endif - png_byte buf[13]; /* buffer to store the IHDR info */ - - png_debug(1, "in png_write_IHDR\n"); - /* Check that we have valid input data from the application info */ - switch (color_type) - { - case PNG_COLOR_TYPE_GRAY: - switch (bit_depth) - { - case 1: - case 2: - case 4: - case 8: - case 16: png_ptr->channels = 1; break; - default: png_error(png_ptr,"Invalid bit depth for grayscale image"); - } - break; - case PNG_COLOR_TYPE_RGB: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for RGB image"); - png_ptr->channels = 3; - break; - case PNG_COLOR_TYPE_PALETTE: - switch (bit_depth) - { - case 1: - case 2: - case 4: - case 8: png_ptr->channels = 1; break; - default: png_error(png_ptr, "Invalid bit depth for paletted image"); - } - break; - case PNG_COLOR_TYPE_GRAY_ALPHA: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for grayscale+alpha image"); - png_ptr->channels = 2; - break; - case PNG_COLOR_TYPE_RGB_ALPHA: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for RGBA image"); - png_ptr->channels = 4; - break; - default: - png_error(png_ptr, "Invalid image color type specified"); - } - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - { - png_warning(png_ptr, "Invalid compression type specified"); - compression_type = PNG_COMPRESSION_TYPE_BASE; - } - - /* Write filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not write a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) && -#endif - filter_type != PNG_FILTER_TYPE_BASE) - { - png_warning(png_ptr, "Invalid filter type specified"); - filter_type = PNG_FILTER_TYPE_BASE; - } - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - if (interlace_type != PNG_INTERLACE_NONE && - interlace_type != PNG_INTERLACE_ADAM7) - { - png_warning(png_ptr, "Invalid interlace type specified"); - interlace_type = PNG_INTERLACE_ADAM7; - } -#else - interlace_type=PNG_INTERLACE_NONE; -#endif - - /* save off the relevent information */ - png_ptr->bit_depth = (png_byte)bit_depth; - png_ptr->color_type = (png_byte)color_type; - png_ptr->interlaced = (png_byte)interlace_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_ptr->filter_type = (png_byte)filter_type; -#endif - png_ptr->compression_type = (png_byte)compression_type; - png_ptr->width = width; - png_ptr->height = height; - - png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels); - png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width); - /* set the usr info, so any transformations can modify it */ - png_ptr->usr_width = png_ptr->width; - png_ptr->usr_bit_depth = png_ptr->bit_depth; - png_ptr->usr_channels = png_ptr->channels; - - /* pack the header information into the buffer */ - png_save_uint_32(buf, width); - png_save_uint_32(buf + 4, height); - buf[8] = (png_byte)bit_depth; - buf[9] = (png_byte)color_type; - buf[10] = (png_byte)compression_type; - buf[11] = (png_byte)filter_type; - buf[12] = (png_byte)interlace_type; - - /* write the chunk */ - png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13); - - /* initialize zlib with PNG info */ - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - if (!(png_ptr->do_filter)) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE || - png_ptr->bit_depth < 8) - png_ptr->do_filter = PNG_FILTER_NONE; - else - png_ptr->do_filter = PNG_ALL_FILTERS; - } - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY)) - { - if (png_ptr->do_filter != PNG_FILTER_NONE) - png_ptr->zlib_strategy = Z_FILTERED; - else - png_ptr->zlib_strategy = Z_DEFAULT_STRATEGY; - } - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_LEVEL)) - png_ptr->zlib_level = Z_DEFAULT_COMPRESSION; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL)) - png_ptr->zlib_mem_level = 8; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS)) - png_ptr->zlib_window_bits = 15; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD)) - png_ptr->zlib_method = 8; - deflateInit2(&png_ptr->zstream, png_ptr->zlib_level, - png_ptr->zlib_method, png_ptr->zlib_window_bits, - png_ptr->zlib_mem_level, png_ptr->zlib_strategy); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - /* libpng is not interested in zstream.data_type */ - /* set it to a predefined value, to avoid its evaluation inside zlib */ - png_ptr->zstream.data_type = Z_BINARY; - - png_ptr->mode = PNG_HAVE_IHDR; -} - -/* write the palette. We are careful not to trust png_color to be in the - * correct order for PNG, so people can redefine it to any convenient - * structure. - */ -void /* PRIVATE */ -png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_PLTE; -#endif - png_uint_32 i; - png_colorp pal_ptr; - png_byte buf[3]; - - png_debug(1, "in png_write_PLTE\n"); - if (( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && -#endif - num_pal == 0) || num_pal > 256) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_error(png_ptr, "Invalid number of colors in palette"); - } - else - { - png_warning(png_ptr, "Invalid number of colors in palette"); - return; - } - } - - if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) - { - png_warning(png_ptr, - "Ignoring request to write a PLTE chunk in grayscale PNG"); - return; - } - - png_ptr->num_palette = (png_uint_16)num_pal; - png_debug1(3, "num_palette = %d\n", png_ptr->num_palette); - - png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, num_pal * 3); -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) - { - buf[0] = pal_ptr->red; - buf[1] = pal_ptr->green; - buf[2] = pal_ptr->blue; - png_write_chunk_data(png_ptr, buf, (png_size_t)3); - } -#else - /* This is a little slower but some buggy compilers need to do this instead */ - pal_ptr=palette; - for (i = 0; i < num_pal; i++) - { - buf[0] = pal_ptr[i].red; - buf[1] = pal_ptr[i].green; - buf[2] = pal_ptr[i].blue; - png_write_chunk_data(png_ptr, buf, (png_size_t)3); - } -#endif - png_write_chunk_end(png_ptr); - png_ptr->mode |= PNG_HAVE_PLTE; -} - -/* write an IDAT chunk */ -void /* PRIVATE */ -png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - png_debug(1, "in png_write_IDAT\n"); - - /* Optimize the CMF field in the zlib stream. */ - /* This hack of the zlib stream is compliant to the stream specification. */ - if (!(png_ptr->mode & PNG_HAVE_IDAT) && - png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) - { - unsigned int z_cmf = data[0]; /* zlib compression method and flags */ - if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70) - { - /* Avoid memory underflows and multiplication overflows. */ - /* The conditions below are practically always satisfied; - however, they still must be checked. */ - if (length >= 2 && - png_ptr->height < 16384 && png_ptr->width < 16384) - { - png_uint_32 uncompressed_idat_size = png_ptr->height * - ((png_ptr->width * - png_ptr->channels * png_ptr->bit_depth + 15) >> 3); - unsigned int z_cinfo = z_cmf >> 4; - unsigned int half_z_window_size = 1 << (z_cinfo + 7); - while (uncompressed_idat_size <= half_z_window_size && - half_z_window_size >= 256) - { - z_cinfo--; - half_z_window_size >>= 1; - } - z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4); - if (data[0] != (png_byte)z_cmf) - { - data[0] = (png_byte)z_cmf; - data[1] &= 0xe0; - data[1] += (png_byte)(0x1f - ((z_cmf << 8) + data[1]) % 0x1f); - } - } - } - else - png_error(png_ptr, - "Invalid zlib compression method or flags in IDAT"); - } - - png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length); - png_ptr->mode |= PNG_HAVE_IDAT; -} - -/* write an IEND chunk */ -void /* PRIVATE */ -png_write_IEND(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IEND; -#endif - png_debug(1, "in png_write_IEND\n"); - png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL, - (png_size_t)0); - png_ptr->mode |= PNG_HAVE_IEND; -} - -#if defined(PNG_WRITE_gAMA_SUPPORTED) -/* write a gAMA chunk */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -void /* PRIVATE */ -png_write_gAMA(png_structp png_ptr, double file_gamma) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_gAMA; -#endif - png_uint_32 igamma; - png_byte buf[4]; - - png_debug(1, "in png_write_gAMA\n"); - /* file_gamma is saved in 1/100,000ths */ - igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5); - png_save_uint_32(buf, igamma); - png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_gAMA; -#endif - png_byte buf[4]; - - png_debug(1, "in png_write_gAMA\n"); - /* file_gamma is saved in 1/100,000ths */ - png_save_uint_32(buf, (png_uint_32)file_gamma); - png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); -} -#endif -#endif - -#if defined(PNG_WRITE_sRGB_SUPPORTED) -/* write a sRGB chunk */ -void /* PRIVATE */ -png_write_sRGB(png_structp png_ptr, int srgb_intent) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sRGB; -#endif - png_byte buf[1]; - - png_debug(1, "in png_write_sRGB\n"); - if(srgb_intent >= PNG_sRGB_INTENT_LAST) - png_warning(png_ptr, - "Invalid sRGB rendering intent specified"); - buf[0]=(png_byte)srgb_intent; - png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1); -} -#endif - -#if defined(PNG_WRITE_iCCP_SUPPORTED) -/* write an iCCP chunk */ -void /* PRIVATE */ -png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, - png_charp profile, int profile_len) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_iCCP; -#endif - png_size_t name_len; - png_charp new_name; - compression_state comp; - int embedded_profile_len = 0; - - png_debug(1, "in png_write_iCCP\n"); - - comp.num_output_ptr = 0; - comp.max_output_ptr = 0; - comp.output_ptr = NULL; - comp.input = NULL; - comp.input_len = 0; - - if (name == NULL || (name_len = png_check_keyword(png_ptr, name, - &new_name)) == 0) - { - png_warning(png_ptr, "Empty keyword in iCCP chunk"); - return; - } - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_warning(png_ptr, "Unknown compression type in iCCP chunk"); - - if (profile == NULL) - profile_len = 0; - - if (profile_len > 3) - embedded_profile_len = - ((*( (png_bytep)profile ))<<24) | - ((*( (png_bytep)profile+1))<<16) | - ((*( (png_bytep)profile+2))<< 8) | - ((*( (png_bytep)profile+3)) ); - - if (profile_len < embedded_profile_len) - { - png_warning(png_ptr, - "Embedded profile length too large in iCCP chunk"); - return; - } - - if (profile_len > embedded_profile_len) - { - png_warning(png_ptr, - "Truncating profile to actual length in iCCP chunk"); - profile_len = embedded_profile_len; - } - - if (profile_len) - profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len, - PNG_COMPRESSION_TYPE_BASE, &comp); - - /* make sure we include the NULL after the name and the compression type */ - png_write_chunk_start(png_ptr, (png_bytep)png_iCCP, - (png_uint_32)name_len+profile_len+2); - new_name[name_len+1]=0x00; - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2); - - if (profile_len) - png_write_compressed_data_out(png_ptr, &comp); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_name); -} -#endif - -#if defined(PNG_WRITE_sPLT_SUPPORTED) -/* write a sPLT chunk */ -void /* PRIVATE */ -png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sPLT; -#endif - png_size_t name_len; - png_charp new_name; - png_byte entrybuf[10]; - int entry_size = (spalette->depth == 8 ? 6 : 10); - int palette_size = entry_size * spalette->nentries; - png_sPLT_entryp ep; -#ifdef PNG_NO_POINTER_INDEXING - int i; -#endif - - png_debug(1, "in png_write_sPLT\n"); - if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, - spalette->name, &new_name))==0) - { - png_warning(png_ptr, "Empty keyword in sPLT chunk"); - return; - } - - /* make sure we include the NULL after the name */ - png_write_chunk_start(png_ptr, (png_bytep)png_sPLT, - (png_uint_32)(name_len + 2 + palette_size)); - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1); - png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1); - - /* loop through each palette entry, writing appropriately */ -#ifndef PNG_NO_POINTER_INDEXING - for (ep = spalette->entries; epentries+spalette->nentries; ep++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep->red; - entrybuf[1] = (png_byte)ep->green; - entrybuf[2] = (png_byte)ep->blue; - entrybuf[3] = (png_byte)ep->alpha; - png_save_uint_16(entrybuf + 4, ep->frequency); - } - else - { - png_save_uint_16(entrybuf + 0, ep->red); - png_save_uint_16(entrybuf + 2, ep->green); - png_save_uint_16(entrybuf + 4, ep->blue); - png_save_uint_16(entrybuf + 6, ep->alpha); - png_save_uint_16(entrybuf + 8, ep->frequency); - } - png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size); - } -#else - ep=spalette->entries; - for (i=0; i>spalette->nentries; i++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep[i].red; - entrybuf[1] = (png_byte)ep[i].green; - entrybuf[2] = (png_byte)ep[i].blue; - entrybuf[3] = (png_byte)ep[i].alpha; - png_save_uint_16(entrybuf + 4, ep[i].frequency); - } - else - { - png_save_uint_16(entrybuf + 0, ep[i].red); - png_save_uint_16(entrybuf + 2, ep[i].green); - png_save_uint_16(entrybuf + 4, ep[i].blue); - png_save_uint_16(entrybuf + 6, ep[i].alpha); - png_save_uint_16(entrybuf + 8, ep[i].frequency); - } - png_write_chunk_data(png_ptr, entrybuf, entry_size); - } -#endif - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_name); -} -#endif - -#if defined(PNG_WRITE_sBIT_SUPPORTED) -/* write the sBIT chunk */ -void /* PRIVATE */ -png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sBIT; -#endif - png_byte buf[4]; - png_size_t size; - - png_debug(1, "in png_write_sBIT\n"); - /* make sure we don't depend upon the order of PNG_COLOR_8 */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - png_byte maxbits; - - maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 : - png_ptr->usr_bit_depth); - if (sbit->red == 0 || sbit->red > maxbits || - sbit->green == 0 || sbit->green > maxbits || - sbit->blue == 0 || sbit->blue > maxbits) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[0] = sbit->red; - buf[1] = sbit->green; - buf[2] = sbit->blue; - size = 3; - } - else - { - if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[0] = sbit->gray; - size = 1; - } - - if (color_type & PNG_COLOR_MASK_ALPHA) - { - if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[size++] = sbit->alpha; - } - - png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size); -} -#endif - -#if defined(PNG_WRITE_cHRM_SUPPORTED) -/* write the cHRM chunk */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -void /* PRIVATE */ -png_write_cHRM(png_structp png_ptr, double white_x, double white_y, - double red_x, double red_y, double green_x, double green_y, - double blue_x, double blue_y) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_cHRM; -#endif - png_byte buf[32]; - png_uint_32 itemp; - - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 || - white_x + white_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%f, white_y=%f\n",white_x, white_y); -#endif - return; - } - itemp = (png_uint_32)(white_x * 100000.0 + 0.5); - png_save_uint_32(buf, itemp); - itemp = (png_uint_32)(white_y * 100000.0 + 0.5); - png_save_uint_32(buf + 4, itemp); - - if (red_x < 0 || red_y < 0 || red_x + red_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM red point specified"); - return; - } - itemp = (png_uint_32)(red_x * 100000.0 + 0.5); - png_save_uint_32(buf + 8, itemp); - itemp = (png_uint_32)(red_y * 100000.0 + 0.5); - png_save_uint_32(buf + 12, itemp); - - if (green_x < 0 || green_y < 0 || green_x + green_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM green point specified"); - return; - } - itemp = (png_uint_32)(green_x * 100000.0 + 0.5); - png_save_uint_32(buf + 16, itemp); - itemp = (png_uint_32)(green_y * 100000.0 + 0.5); - png_save_uint_32(buf + 20, itemp); - - if (blue_x < 0 || blue_y < 0 || blue_x + blue_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM blue point specified"); - return; - } - itemp = (png_uint_32)(blue_x * 100000.0 + 0.5); - png_save_uint_32(buf + 24, itemp); - itemp = (png_uint_32)(blue_y * 100000.0 + 0.5); - png_save_uint_32(buf + 28, itemp); - - png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, - png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, - png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, - png_fixed_point blue_y) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_cHRM; -#endif - png_byte buf[32]; - - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%ld, white_y=%ld\n",white_x, white_y); -#endif - return; - } - png_save_uint_32(buf, (png_uint_32)white_x); - png_save_uint_32(buf + 4, (png_uint_32)white_y); - - if (red_x + red_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM fixed red point specified"); - return; - } - png_save_uint_32(buf + 8, (png_uint_32)red_x); - png_save_uint_32(buf + 12, (png_uint_32)red_y); - - if (green_x + green_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM green point specified"); - return; - } - png_save_uint_32(buf + 16, (png_uint_32)green_x); - png_save_uint_32(buf + 20, (png_uint_32)green_y); - - if (blue_x + blue_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM blue point specified"); - return; - } - png_save_uint_32(buf + 24, (png_uint_32)blue_x); - png_save_uint_32(buf + 28, (png_uint_32)blue_y); - - png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); -} -#endif -#endif - -#if defined(PNG_WRITE_tRNS_SUPPORTED) -/* write the tRNS chunk */ -void /* PRIVATE */ -png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, - int num_trans, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tRNS; -#endif - png_byte buf[6]; - - png_debug(1, "in png_write_tRNS\n"); - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette) - { - png_warning(png_ptr,"Invalid number of transparent colors specified"); - return; - } - /* write the chunk out as it is */ - png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans, (png_size_t)num_trans); - } - else if (color_type == PNG_COLOR_TYPE_GRAY) - { - /* one 16 bit value */ - if(tran->gray >= (1 << png_ptr->bit_depth)) - { - png_warning(png_ptr, - "Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); - return; - } - png_save_uint_16(buf, tran->gray); - png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2); - } - else if (color_type == PNG_COLOR_TYPE_RGB) - { - /* three 16 bit values */ - png_save_uint_16(buf, tran->red); - png_save_uint_16(buf + 2, tran->green); - png_save_uint_16(buf + 4, tran->blue); - if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) - { - png_warning(png_ptr, - "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); - return; - } - png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6); - } - else - { - png_warning(png_ptr, "Can't write tRNS with an alpha channel"); - } -} -#endif - -#if defined(PNG_WRITE_bKGD_SUPPORTED) -/* write the background chunk */ -void /* PRIVATE */ -png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_bKGD; -#endif - png_byte buf[6]; - - png_debug(1, "in png_write_bKGD\n"); - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - (png_ptr->num_palette || - (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) && -#endif - back->index > png_ptr->num_palette) - { - png_warning(png_ptr, "Invalid background palette index"); - return; - } - buf[0] = back->index; - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1); - } - else if (color_type & PNG_COLOR_MASK_COLOR) - { - png_save_uint_16(buf, back->red); - png_save_uint_16(buf + 2, back->green); - png_save_uint_16(buf + 4, back->blue); - if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) - { - png_warning(png_ptr, - "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); - return; - } - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6); - } - else - { - if(back->gray >= (1 << png_ptr->bit_depth)) - { - png_warning(png_ptr, - "Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); - return; - } - png_save_uint_16(buf, back->gray); - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2); - } -} -#endif - -#if defined(PNG_WRITE_hIST_SUPPORTED) -/* write the histogram */ -void /* PRIVATE */ -png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_hIST; -#endif - int i; - png_byte buf[3]; - - png_debug(1, "in png_write_hIST\n"); - if (num_hist > (int)png_ptr->num_palette) - { - png_debug2(3, "num_hist = %d, num_palette = %d\n", num_hist, - png_ptr->num_palette); - png_warning(png_ptr, "Invalid number of histogram entries specified"); - return; - } - - png_write_chunk_start(png_ptr, (png_bytep)png_hIST, (png_uint_32)(num_hist * 2)); - for (i = 0; i < num_hist; i++) - { - png_save_uint_16(buf, hist[i]); - png_write_chunk_data(png_ptr, buf, (png_size_t)2); - } - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, - * and if invalid, correct the keyword rather than discarding the entire - * chunk. The PNG 1.0 specification requires keywords 1-79 characters in - * length, forbids leading or trailing whitespace, multiple internal spaces, - * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. - * - * The new_key is allocated to hold the corrected keyword and must be freed - * by the calling routine. This avoids problems with trying to write to - * static keywords without having to have duplicate copies of the strings. - */ -png_size_t /* PRIVATE */ -png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) -{ - png_size_t key_len; - png_charp kp, dp; - int kflag; - int kwarn=0; - - png_debug(1, "in png_check_keyword\n"); - *new_key = NULL; - - if (key == NULL || (key_len = png_strlen(key)) == 0) - { - png_warning(png_ptr, "zero length keyword"); - return ((png_size_t)0); - } - - png_debug1(2, "Keyword to be checked is '%s'\n", key); - - *new_key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + 2)); - if (*new_key == NULL) - { - png_warning(png_ptr, "Out of memory while procesing keyword"); - return ((png_size_t)0); - } - - /* Replace non-printing characters with a blank and print a warning */ - for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++) - { - if (*kp < 0x20 || (*kp > 0x7E && (png_byte)*kp < 0xA1)) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[40]; - - sprintf(msg, "invalid keyword character 0x%02X", *kp); - png_warning(png_ptr, msg); -#else - png_warning(png_ptr, "invalid character in keyword"); -#endif - *dp = ' '; - } - else - { - *dp = *kp; - } - } - *dp = '\0'; - - /* Remove any trailing white space. */ - kp = *new_key + key_len - 1; - if (*kp == ' ') - { - png_warning(png_ptr, "trailing spaces removed from keyword"); - - while (*kp == ' ') - { - *(kp--) = '\0'; - key_len--; - } - } - - /* Remove any leading white space. */ - kp = *new_key; - if (*kp == ' ') - { - png_warning(png_ptr, "leading spaces removed from keyword"); - - while (*kp == ' ') - { - kp++; - key_len--; - } - } - - png_debug1(2, "Checking for multiple internal spaces in '%s'\n", kp); - - /* Remove multiple internal spaces. */ - for (kflag = 0, dp = *new_key; *kp != '\0'; kp++) - { - if (*kp == ' ' && kflag == 0) - { - *(dp++) = *kp; - kflag = 1; - } - else if (*kp == ' ') - { - key_len--; - kwarn=1; - } - else - { - *(dp++) = *kp; - kflag = 0; - } - } - *dp = '\0'; - if(kwarn) - png_warning(png_ptr, "extra interior spaces removed from keyword"); - - if (key_len == 0) - { - png_free(png_ptr, *new_key); - *new_key=NULL; - png_warning(png_ptr, "Zero length keyword"); - } - - if (key_len > 79) - { - png_warning(png_ptr, "keyword length must be 1 - 79 characters"); - new_key[79] = '\0'; - key_len = 79; - } - - return (key_len); -} -#endif - -#if defined(PNG_WRITE_tEXt_SUPPORTED) -/* write a tEXt chunk */ -void /* PRIVATE */ -png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, - png_size_t text_len) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tEXt; -#endif - png_size_t key_len; - png_charp new_key; - - png_debug(1, "in png_write_tEXt\n"); - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in tEXt chunk"); - return; - } - - if (text == NULL || *text == '\0') - text_len = 0; - else - text_len = png_strlen(text); - - /* make sure we include the 0 after the key */ - png_write_chunk_start(png_ptr, (png_bytep)png_tEXt, (png_uint_32)key_len+text_len+1); - /* - * We leave it to the application to meet PNG-1.0 requirements on the - * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of - * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. - * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. - */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); - if (text_len) - png_write_chunk_data(png_ptr, (png_bytep)text, text_len); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_key); -} -#endif - -#if defined(PNG_WRITE_zTXt_SUPPORTED) -/* write a compressed text chunk */ -void /* PRIVATE */ -png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, - png_size_t text_len, int compression) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_zTXt; -#endif - png_size_t key_len; - char buf[1]; - png_charp new_key; - compression_state comp; - - png_debug(1, "in png_write_zTXt\n"); - - comp.num_output_ptr = 0; - comp.max_output_ptr = 0; - comp.output_ptr = NULL; - comp.input = NULL; - comp.input_len = 0; - - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in zTXt chunk"); - return; - } - - if (text == NULL || *text == '\0' || compression==PNG_TEXT_COMPRESSION_NONE) - { - png_write_tEXt(png_ptr, new_key, text, (png_size_t)0); - png_free(png_ptr, new_key); - return; - } - - text_len = png_strlen(text); - - png_free(png_ptr, new_key); - - /* compute the compressed data; do it now for the length */ - text_len = png_text_compress(png_ptr, text, text_len, compression, - &comp); - - /* write start of chunk */ - png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32) - (key_len+text_len+2)); - /* write key */ - png_write_chunk_data(png_ptr, (png_bytep)key, key_len + 1); - buf[0] = (png_byte)compression; - /* write compression */ - png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1); - /* write the compressed data */ - png_write_compressed_data_out(png_ptr, &comp); - - /* close the chunk */ - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_iTXt_SUPPORTED) -/* write an iTXt chunk */ -void /* PRIVATE */ -png_write_iTXt(png_structp png_ptr, int compression, png_charp key, - png_charp lang, png_charp lang_key, png_charp text) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_iTXt; -#endif - png_size_t lang_len, key_len, lang_key_len, text_len; - png_charp new_lang, new_key; - png_byte cbuf[2]; - compression_state comp; - - png_debug(1, "in png_write_iTXt\n"); - - comp.num_output_ptr = 0; - comp.max_output_ptr = 0; - comp.output_ptr = NULL; - comp.input = NULL; - - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in iTXt chunk"); - return; - } - if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0) - { - png_warning(png_ptr, "Empty language field in iTXt chunk"); - new_lang = NULL; - lang_len = 0; - } - - if (lang_key == NULL) - lang_key_len = 0; - else - lang_key_len = png_strlen(lang_key); - - if (text == NULL) - text_len = 0; - else - text_len = png_strlen(text); - - /* compute the compressed data; do it now for the length */ - text_len = png_text_compress(png_ptr, text, text_len, compression-2, - &comp); - - - /* make sure we include the compression flag, the compression byte, - * and the NULs after the key, lang, and lang_key parts */ - - png_write_chunk_start(png_ptr, (png_bytep)png_iTXt, - (png_uint_32)( - 5 /* comp byte, comp flag, terminators for key, lang and lang_key */ - + key_len - + lang_len - + lang_key_len - + text_len)); - - /* - * We leave it to the application to meet PNG-1.0 requirements on the - * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of - * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. - * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. - */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); - - /* set the compression flag */ - if (compression == PNG_ITXT_COMPRESSION_NONE || \ - compression == PNG_TEXT_COMPRESSION_NONE) - cbuf[0] = 0; - else /* compression == PNG_ITXT_COMPRESSION_zTXt */ - cbuf[0] = 1; - /* set the compression method */ - cbuf[1] = 0; - png_write_chunk_data(png_ptr, cbuf, 2); - - cbuf[0] = 0; - png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), lang_len + 1); - png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), lang_key_len + 1); - png_write_compressed_data_out(png_ptr, &comp); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_key); - if (new_lang) - png_free(png_ptr, new_lang); -} -#endif - -#if defined(PNG_WRITE_oFFs_SUPPORTED) -/* write the oFFs chunk */ -void /* PRIVATE */ -png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, - int unit_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_oFFs; -#endif - png_byte buf[9]; - - png_debug(1, "in png_write_oFFs\n"); - if (unit_type >= PNG_OFFSET_LAST) - png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); - - png_save_int_32(buf, x_offset); - png_save_int_32(buf + 4, y_offset); - buf[8] = (png_byte)unit_type; - - png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9); -} -#endif - -#if defined(PNG_WRITE_pCAL_SUPPORTED) -/* write the pCAL chunk (described in the PNG extensions document) */ -void /* PRIVATE */ -png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, - png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_pCAL; -#endif - png_size_t purpose_len, units_len, total_len; - png_uint_32p params_len; - png_byte buf[10]; - png_charp new_purpose; - int i; - - png_debug1(1, "in png_write_pCAL (%d parameters)\n", nparams); - if (type >= PNG_EQUATION_LAST) - png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); - - purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1; - png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len); - units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); - png_debug1(3, "pCAL units length = %d\n", (int)units_len); - total_len = purpose_len + units_len + 10; - - params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams - *png_sizeof(png_uint_32))); - - /* Find the length of each parameter, making sure we don't count the - null terminator for the last parameter. */ - for (i = 0; i < nparams; i++) - { - params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); - png_debug2(3, "pCAL parameter %d length = %lu\n", i, params_len[i]); - total_len += (png_size_t)params_len[i]; - } - - png_debug1(3, "pCAL total length = %d\n", (int)total_len); - png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len); - png_save_int_32(buf, X0); - png_save_int_32(buf + 4, X1); - buf[8] = (png_byte)type; - buf[9] = (png_byte)nparams; - png_write_chunk_data(png_ptr, buf, (png_size_t)10); - png_write_chunk_data(png_ptr, (png_bytep)units, (png_size_t)units_len); - - png_free(png_ptr, new_purpose); - - for (i = 0; i < nparams; i++) - { - png_write_chunk_data(png_ptr, (png_bytep)params[i], - (png_size_t)params_len[i]); - } - - png_free(png_ptr, params_len); - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_sCAL_SUPPORTED) -/* write the sCAL chunk */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) -void /* PRIVATE */ -png_write_sCAL(png_structp png_ptr, int unit, double width, double height) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sCAL; -#endif - char buf[64]; - png_size_t total_len; - - png_debug(1, "in png_write_sCAL\n"); - - buf[0] = (char)unit; -#if defined(_WIN32_WCE) -/* sprintf() function is not supported on WindowsCE */ - { - wchar_t wc_buf[32]; - size_t wc_len; - swprintf(wc_buf, TEXT("%12.12e"), width); - wc_len = wcslen(wc_buf); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + 1, wc_len, NULL, NULL); - total_len = wc_len + 2; - swprintf(wc_buf, TEXT("%12.12e"), height); - wc_len = wcslen(wc_buf); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + total_len, wc_len, - NULL, NULL); - total_len += wc_len; - } -#else - sprintf(buf + 1, "%12.12e", width); - total_len = 1 + png_strlen(buf + 1) + 1; - sprintf(buf + total_len, "%12.12e", height); - total_len += png_strlen(buf + total_len); -#endif - - png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); - png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len); -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, - png_charp height) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sCAL; -#endif - png_byte buf[64]; - png_size_t wlen, hlen, total_len; - - png_debug(1, "in png_write_sCAL_s\n"); - - wlen = png_strlen(width); - hlen = png_strlen(height); - total_len = wlen + hlen + 2; - if (total_len > 64) - { - png_warning(png_ptr, "Can't write sCAL (buffer too small)"); - return; - } - - buf[0] = (png_byte)unit; - png_memcpy(buf + 1, width, wlen + 1); /* append the '\0' here */ - png_memcpy(buf + wlen + 2, height, hlen); /* do NOT append the '\0' here */ - - png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); - png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len); -} -#endif -#endif -#endif - -#if defined(PNG_WRITE_pHYs_SUPPORTED) -/* write the pHYs chunk */ -void /* PRIVATE */ -png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, - png_uint_32 y_pixels_per_unit, - int unit_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_pHYs; -#endif - png_byte buf[9]; - - png_debug(1, "in png_write_pHYs\n"); - if (unit_type >= PNG_RESOLUTION_LAST) - png_warning(png_ptr, "Unrecognized unit type for pHYs chunk"); - - png_save_uint_32(buf, x_pixels_per_unit); - png_save_uint_32(buf + 4, y_pixels_per_unit); - buf[8] = (png_byte)unit_type; - - png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9); -} -#endif - -#if defined(PNG_WRITE_tIME_SUPPORTED) -/* Write the tIME chunk. Use either png_convert_from_struct_tm() - * or png_convert_from_time_t(), or fill in the structure yourself. - */ -void /* PRIVATE */ -png_write_tIME(png_structp png_ptr, png_timep mod_time) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tIME; -#endif - png_byte buf[7]; - - png_debug(1, "in png_write_tIME\n"); - if (mod_time->month > 12 || mod_time->month < 1 || - mod_time->day > 31 || mod_time->day < 1 || - mod_time->hour > 23 || mod_time->second > 60) - { - png_warning(png_ptr, "Invalid time specified for tIME chunk"); - return; - } - - png_save_uint_16(buf, mod_time->year); - buf[2] = mod_time->month; - buf[3] = mod_time->day; - buf[4] = mod_time->hour; - buf[5] = mod_time->minute; - buf[6] = mod_time->second; - - png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7); -} -#endif - -/* initializes the row writing capability of libpng */ -void /* PRIVATE */ -png_write_start_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - png_size_t buf_size; - - png_debug(1, "in png_write_start_row\n"); - buf_size = (png_size_t)(PNG_ROWBYTES( - png_ptr->usr_channels*png_ptr->usr_bit_depth,png_ptr->width)+1); - - /* set up row buffer */ - png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); - png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; - - /* set up filtering buffer, if using this filter */ - if (png_ptr->do_filter & PNG_FILTER_SUB) - { - png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; - } - - /* We only need to keep the previous row if we are using one of these. */ - if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) - { - /* set up previous row buffer */ - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); - png_memset(png_ptr->prev_row, 0, buf_size); - - if (png_ptr->do_filter & PNG_FILTER_UP) - { - png_ptr->up_row = (png_bytep )png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; - } - - if (png_ptr->do_filter & PNG_FILTER_AVG) - { - png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; - } - - if (png_ptr->do_filter & PNG_FILTER_PAETH) - { - png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; - } - } - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, we need to set up width and height of pass */ - if (png_ptr->interlaced) - { - if (!(png_ptr->transformations & PNG_INTERLACE)) - { - png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; - png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 - - png_pass_start[0]) / png_pass_inc[0]; - } - else - { - png_ptr->num_rows = png_ptr->height; - png_ptr->usr_width = png_ptr->width; - } - } - else -#endif - { - png_ptr->num_rows = png_ptr->height; - png_ptr->usr_width = png_ptr->width; - } - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; -} - -/* Internal use only. Called when finished processing a row of data. */ -void /* PRIVATE */ -png_write_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - int ret; - - png_debug(1, "in png_write_finish_row\n"); - /* next row */ - png_ptr->row_number++; - - /* see if we are done */ - if (png_ptr->row_number < png_ptr->num_rows) - return; - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, go to next pass */ - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - if (png_ptr->transformations & PNG_INTERLACE) - { - png_ptr->pass++; - } - else - { - /* loop until we find a non-zero width or height pass */ - do - { - png_ptr->pass++; - if (png_ptr->pass >= 7) - break; - png_ptr->usr_width = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - if (png_ptr->transformations & PNG_INTERLACE) - break; - } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0); - - } - - /* reset the row above the image for the next pass */ - if (png_ptr->pass < 7) - { - if (png_ptr->prev_row != NULL) - png_memset(png_ptr->prev_row, 0, - (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels* - png_ptr->usr_bit_depth,png_ptr->width))+1); - return; - } - } -#endif - - /* if we get here, we've just written the last row, so we need - to flush the compressor */ - do - { - /* tell the compressor we are done */ - ret = deflate(&png_ptr->zstream, Z_FINISH); - /* check for an error */ - if (ret == Z_OK) - { - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) - { - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - else if (ret != Z_STREAM_END) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - } while (ret != Z_STREAM_END); - - /* write any extra space */ - if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) - { - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size - - png_ptr->zstream.avail_out); - } - - deflateReset(&png_ptr->zstream); - png_ptr->zstream.data_type = Z_BINARY; -} - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Pick out the correct pixels for the interlace pass. - * The basic idea here is to go through the row with a source - * pointer and a destination pointer (sp and dp), and copy the - * correct pixels for the pass. As the row gets compacted, - * sp will always be >= dp, so we should never overwrite anything. - * See the default: case for the easiest code to understand. - */ -void /* PRIVATE */ -png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1, "in png_do_write_interlace\n"); - /* we don't have to do anything on the last pass (6) */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && pass < 6) -#else - if (pass < 6) -#endif - { - /* each pixel depth is handled separately */ - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - d = 0; - shift = 7; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 3); - value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01; - d |= (value << shift); - - if (shift == 0) - { - shift = 7; - *dp++ = (png_byte)d; - d = 0; - } - else - shift--; - - } - if (shift != 7) - *dp = (png_byte)d; - break; - } - case 2: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - shift = 6; - d = 0; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 2); - value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03; - d |= (value << shift); - - if (shift == 0) - { - shift = 6; - *dp++ = (png_byte)d; - d = 0; - } - else - shift -= 2; - } - if (shift != 6) - *dp = (png_byte)d; - break; - } - case 4: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - shift = 4; - d = 0; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 1); - value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f; - d |= (value << shift); - - if (shift == 0) - { - shift = 4; - *dp++ = (png_byte)d; - d = 0; - } - else - shift -= 4; - } - if (shift != 4) - *dp = (png_byte)d; - break; - } - default: - { - png_bytep sp; - png_bytep dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - png_size_t pixel_bytes; - - /* start at the beginning */ - dp = row; - /* find out how many bytes each pixel takes up */ - pixel_bytes = (row_info->pixel_depth >> 3); - /* loop through the row, only looking at the pixels that - matter */ - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - /* find out where the original pixel is */ - sp = row + (png_size_t)i * pixel_bytes; - /* move the pixel */ - if (dp != sp) - png_memcpy(dp, sp, pixel_bytes); - /* next pixel */ - dp += pixel_bytes; - } - break; - } - } - /* set new row width */ - row_info->width = (row_info->width + - png_pass_inc[pass] - 1 - - png_pass_start[pass]) / - png_pass_inc[pass]; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_info->width); - } -} -#endif - -/* This filters the row, chooses which filter to use, if it has not already - * been specified by the application, and then writes the row out with the - * chosen filter. - */ -#define PNG_MAXSUM (((png_uint_32)(-1)) >> 1) -#define PNG_HISHIFT 10 -#define PNG_LOMASK ((png_uint_32)0xffffL) -#define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT)) -void /* PRIVATE */ -png_write_find_filter(png_structp png_ptr, png_row_infop row_info) -{ - png_bytep prev_row, best_row, row_buf; - png_uint_32 mins, bpp; - png_byte filter_to_do = png_ptr->do_filter; - png_uint_32 row_bytes = row_info->rowbytes; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - int num_p_filters = (int)png_ptr->num_prev_filters; -#endif - - png_debug(1, "in png_write_find_filter\n"); - /* find out how many bytes offset each pixel is */ - bpp = (row_info->pixel_depth + 7) >> 3; - - prev_row = png_ptr->prev_row; - best_row = row_buf = png_ptr->row_buf; - mins = PNG_MAXSUM; - - /* The prediction method we use is to find which method provides the - * smallest value when summing the absolute values of the distances - * from zero, using anything >= 128 as negative numbers. This is known - * as the "minimum sum of absolute differences" heuristic. Other - * heuristics are the "weighted minimum sum of absolute differences" - * (experimental and can in theory improve compression), and the "zlib - * predictive" method (not implemented yet), which does test compressions - * of lines using different filter methods, and then chooses the - * (series of) filter(s) that give minimum compressed data size (VERY - * computationally expensive). - * - * GRR 980525: consider also - * (1) minimum sum of absolute differences from running average (i.e., - * keep running sum of non-absolute differences & count of bytes) - * [track dispersion, too? restart average if dispersion too large?] - * (1b) minimum sum of absolute differences from sliding average, probably - * with window size <= deflate window (usually 32K) - * (2) minimum sum of squared differences from zero or running average - * (i.e., ~ root-mean-square approach) - */ - - - /* We don't need to test the 'no filter' case if this is the only filter - * that has been chosen, as it doesn't actually do anything to the data. - */ - if ((filter_to_do & PNG_FILTER_NONE) && - filter_to_do != PNG_FILTER_NONE) - { - png_bytep rp; - png_uint_32 sum = 0; - png_uint_32 i; - int v; - - for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) - { - v = *rp; - sum += (v < 128) ? v : 256 - v; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - png_uint_32 sumhi, sumlo; - int j; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */ - - /* Reduce the sum if we match any of the previous rows */ - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - /* Factor in the cost of this filter (this is here for completeness, - * but it makes no sense to have a "cost" for the NONE filter, as - * it has the minimum possible computational cost - none). - */ - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - mins = sum; - } - - /* sub filter */ - if (filter_to_do == PNG_FILTER_SUB) - /* it's the only filter so no testing is needed */ - { - png_bytep rp, lp, dp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; - i++, rp++, dp++) - { - *dp = *rp; - } - for (lp = row_buf + 1; i < row_bytes; - i++, rp++, lp++, dp++) - { - *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); - } - best_row = png_ptr->sub_row; - } - - else if (filter_to_do & PNG_FILTER_SUB) - { - png_bytep rp, dp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - /* We temporarily increase the "minimum sum" by the factor we - * would reduce the sum of this filter, so that we can do the - * early exit comparison without scaling the sum each time. - */ - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; - i++, rp++, dp++) - { - v = *dp = *rp; - - sum += (v < 128) ? v : 256 - v; - } - for (lp = row_buf + 1; i < row_bytes; - i++, rp++, lp++, dp++) - { - v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) - { - sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->sub_row; - } - } - - /* up filter */ - if (filter_to_do == PNG_FILTER_UP) - { - png_bytep rp, dp, pp; - png_uint_32 i; - - for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, - pp = prev_row + 1; i < row_bytes; - i++, rp++, pp++, dp++) - { - *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); - } - best_row = png_ptr->up_row; - } - - else if (filter_to_do & PNG_FILTER_UP) - { - png_bytep rp, dp, pp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, - pp = prev_row + 1; i < row_bytes; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->up_row; - } - } - - /* avg filter */ - if (filter_to_do == PNG_FILTER_AVG) - { - png_bytep rp, dp, pp, lp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); - } - for (lp = row_buf + 1; i < row_bytes; i++) - { - *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) - & 0xff); - } - best_row = png_ptr->avg_row; - } - - else if (filter_to_do & PNG_FILTER_AVG) - { - png_bytep rp, dp, pp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); - - sum += (v < 128) ? v : 256 - v; - } - for (lp = row_buf + 1; i < row_bytes; i++) - { - v = *dp++ = - (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->avg_row; - } - } - - /* Paeth filter */ - if (filter_to_do == PNG_FILTER_PAETH) - { - png_bytep rp, dp, pp, cp, lp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - } - - for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++) - { - int a, b, c, pa, pb, pc, p; - - b = *pp++; - c = *cp++; - a = *lp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); - } - best_row = png_ptr->paeth_row; - } - - else if (filter_to_do & PNG_FILTER_PAETH) - { - png_bytep rp, dp, pp, cp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - - sum += (v < 128) ? v : 256 - v; - } - - for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++) - { - int a, b, c, pa, pb, pc, p; - - b = *pp++; - c = *cp++; - a = *lp++; - -#ifndef PNG_SLOW_PAETH - p = b - c; - pc = a - c; -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; -#else /* PNG_SLOW_PAETH */ - p = a + b - c; - pa = abs(p - a); - pb = abs(p - b); - pc = abs(p - c); - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; -#endif /* PNG_SLOW_PAETH */ - - v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - best_row = png_ptr->paeth_row; - } - } - - /* Do the actual writing of the filtered row data from the chosen filter. */ - - png_write_filtered_row(png_ptr, best_row); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - /* Save the type of filter we picked this time for future calculations */ - if (png_ptr->num_prev_filters > 0) - { - int j; - for (j = 1; j < num_p_filters; j++) - { - png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1]; - } - png_ptr->prev_filters[j] = best_row[0]; - } -#endif -} - - -/* Do the actual writing of a previously filtered row. */ -void /* PRIVATE */ -png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) -{ - png_debug(1, "in png_write_filtered_row\n"); - png_debug1(2, "filter = %d\n", filtered_row[0]); - /* set up the zlib input buffer */ - - png_ptr->zstream.next_in = filtered_row; - png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1; - /* repeat until we have compressed all the data */ - do - { - int ret; /* return of zlib */ - - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); - /* check for compression errors */ - if (ret != Z_OK) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - - /* see if it is time to write another IDAT */ - if (!(png_ptr->zstream.avail_out)) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - /* repeat until all data has been compressed */ - } while (png_ptr->zstream.avail_in); - - /* swap the current and previous rows */ - if (png_ptr->prev_row != NULL) - { - png_bytep tptr; - - tptr = png_ptr->prev_row; - png_ptr->prev_row = png_ptr->row_buf; - png_ptr->row_buf = tptr; - } - - /* finish row - updates counters and flushes zlib if last row */ - png_write_finish_row(png_ptr); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_ptr->flush_rows++; - - if (png_ptr->flush_dist > 0 && - png_ptr->flush_rows >= png_ptr->flush_dist) - { - png_write_flush(png_ptr); - } -#endif -} -#endif /* PNG_WRITE_SUPPORTED */ + +/* pngwutil.c - utilities to write a PNG file + * + * Last changed in libpng 1.2.15 January 5, 2007 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +#define PNG_INTERNAL +#include "png.h" +#ifdef PNG_WRITE_SUPPORTED + +/* Place a 32-bit number into a buffer in PNG byte order. We work + * with unsigned numbers for convenience, although one supported + * ancillary chunk uses signed (two's complement) numbers. + */ +void PNGAPI +png_save_uint_32(png_bytep buf, png_uint_32 i) +{ + buf[0] = (png_byte)((i >> 24) & 0xff); + buf[1] = (png_byte)((i >> 16) & 0xff); + buf[2] = (png_byte)((i >> 8) & 0xff); + buf[3] = (png_byte)(i & 0xff); +} + +/* The png_save_int_32 function assumes integers are stored in two's + * complement format. If this isn't the case, then this routine needs to + * be modified to write data in two's complement format. + */ +void PNGAPI +png_save_int_32(png_bytep buf, png_int_32 i) +{ + buf[0] = (png_byte)((i >> 24) & 0xff); + buf[1] = (png_byte)((i >> 16) & 0xff); + buf[2] = (png_byte)((i >> 8) & 0xff); + buf[3] = (png_byte)(i & 0xff); +} + +/* Place a 16-bit number into a buffer in PNG byte order. + * The parameter is declared unsigned int, not png_uint_16, + * just to avoid potential problems on pre-ANSI C compilers. + */ +void PNGAPI +png_save_uint_16(png_bytep buf, unsigned int i) +{ + buf[0] = (png_byte)((i >> 8) & 0xff); + buf[1] = (png_byte)(i & 0xff); +} + +/* Write a PNG chunk all at once. The type is an array of ASCII characters + * representing the chunk name. The array must be at least 4 bytes in + * length, and does not need to be null terminated. To be safe, pass the + * pre-defined chunk names here, and if you need a new one, define it + * where the others are defined. The length is the length of the data. + * All the data must be present. If that is not possible, use the + * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end() + * functions instead. + */ +void PNGAPI +png_write_chunk(png_structp png_ptr, png_bytep chunk_name, + png_bytep data, png_size_t length) +{ + if(png_ptr == NULL) return; + png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length); + png_write_chunk_data(png_ptr, data, length); + png_write_chunk_end(png_ptr); +} + +/* Write the start of a PNG chunk. The type is the chunk type. + * The total_length is the sum of the lengths of all the data you will be + * passing in png_write_chunk_data(). + */ +void PNGAPI +png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name, + png_uint_32 length) +{ + png_byte buf[4]; + png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length); + if(png_ptr == NULL) return; + + /* write the length */ + png_save_uint_32(buf, length); + png_write_data(png_ptr, buf, (png_size_t)4); + + /* write the chunk name */ + png_write_data(png_ptr, chunk_name, (png_size_t)4); + /* reset the crc and run it over the chunk name */ + png_reset_crc(png_ptr); + png_calculate_crc(png_ptr, chunk_name, (png_size_t)4); +} + +/* Write the data of a PNG chunk started with png_write_chunk_start(). + * Note that multiple calls to this function are allowed, and that the + * sum of the lengths from these calls *must* add up to the total_length + * given to png_write_chunk_start(). + */ +void PNGAPI +png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + /* write the data, and run the CRC over it */ + if(png_ptr == NULL) return; + if (data != NULL && length > 0) + { + png_calculate_crc(png_ptr, data, length); + png_write_data(png_ptr, data, length); + } +} + +/* Finish a chunk started with png_write_chunk_start(). */ +void PNGAPI +png_write_chunk_end(png_structp png_ptr) +{ + png_byte buf[4]; + + if(png_ptr == NULL) return; + + /* write the crc */ + png_save_uint_32(buf, png_ptr->crc); + + png_write_data(png_ptr, buf, (png_size_t)4); +} + +/* Simple function to write the signature. If we have already written + * the magic bytes of the signature, or more likely, the PNG stream is + * being embedded into another stream and doesn't need its own signature, + * we should call png_set_sig_bytes() to tell libpng how many of the + * bytes have already been written. + */ +void /* PRIVATE */ +png_write_sig(png_structp png_ptr) +{ + png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + /* write the rest of the 8 byte signature */ + png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], + (png_size_t)8 - png_ptr->sig_bytes); + if(png_ptr->sig_bytes < 3) + png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; +} + +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED) +/* + * This pair of functions encapsulates the operation of (a) compressing a + * text string, and (b) issuing it later as a series of chunk data writes. + * The compression_state structure is shared context for these functions + * set up by the caller in order to make the whole mess thread-safe. + */ + +typedef struct +{ + char *input; /* the uncompressed input data */ + int input_len; /* its length */ + int num_output_ptr; /* number of output pointers used */ + int max_output_ptr; /* size of output_ptr */ + png_charpp output_ptr; /* array of pointers to output */ +} compression_state; + +/* compress given text into storage in the png_ptr structure */ +static int /* PRIVATE */ +png_text_compress(png_structp png_ptr, + png_charp text, png_size_t text_len, int compression, + compression_state *comp) +{ + int ret; + + comp->num_output_ptr = 0; + comp->max_output_ptr = 0; + comp->output_ptr = NULL; + comp->input = NULL; + comp->input_len = 0; + + /* we may just want to pass the text right through */ + if (compression == PNG_TEXT_COMPRESSION_NONE) + { + comp->input = text; + comp->input_len = text_len; + return((int)text_len); + } + + if (compression >= PNG_TEXT_COMPRESSION_LAST) + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char msg[50]; + sprintf(msg, "Unknown compression type %d", compression); + png_warning(png_ptr, msg); +#else + png_warning(png_ptr, "Unknown compression type"); +#endif + } + + /* We can't write the chunk until we find out how much data we have, + * which means we need to run the compressor first and save the + * output. This shouldn't be a problem, as the vast majority of + * comments should be reasonable, but we will set up an array of + * malloc'd pointers to be sure. + * + * If we knew the application was well behaved, we could simplify this + * greatly by assuming we can always malloc an output buffer large + * enough to hold the compressed text ((1001 * text_len / 1000) + 12) + * and malloc this directly. The only time this would be a bad idea is + * if we can't malloc more than 64K and we have 64K of random input + * data, or if the input string is incredibly large (although this + * wouldn't cause a failure, just a slowdown due to swapping). + */ + + /* set up the compression buffers */ + png_ptr->zstream.avail_in = (uInt)text_len; + png_ptr->zstream.next_in = (Bytef *)text; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf; + + /* this is the same compression loop as in png_write_row() */ + do + { + /* compress the data */ + ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); + if (ret != Z_OK) + { + /* error */ + if (png_ptr->zstream.msg != NULL) + png_error(png_ptr, png_ptr->zstream.msg); + else + png_error(png_ptr, "zlib error"); + } + /* check to see if we need more room */ + if (!(png_ptr->zstream.avail_out)) + { + /* make sure the output array has room */ + if (comp->num_output_ptr >= comp->max_output_ptr) + { + int old_max; + + old_max = comp->max_output_ptr; + comp->max_output_ptr = comp->num_output_ptr + 4; + if (comp->output_ptr != NULL) + { + png_charpp old_ptr; + + old_ptr = comp->output_ptr; + comp->output_ptr = (png_charpp)png_malloc(png_ptr, + (png_uint_32)(comp->max_output_ptr * + png_sizeof (png_charpp))); + png_memcpy(comp->output_ptr, old_ptr, old_max + * png_sizeof (png_charp)); + png_free(png_ptr, old_ptr); + } + else + comp->output_ptr = (png_charpp)png_malloc(png_ptr, + (png_uint_32)(comp->max_output_ptr * + png_sizeof (png_charp))); + } + + /* save the data */ + comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr, + (png_uint_32)png_ptr->zbuf_size); + png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, + png_ptr->zbuf_size); + comp->num_output_ptr++; + + /* and reset the buffer */ + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + png_ptr->zstream.next_out = png_ptr->zbuf; + } + /* continue until we don't have any more to compress */ + } while (png_ptr->zstream.avail_in); + + /* finish the compression */ + do + { + /* tell zlib we are finished */ + ret = deflate(&png_ptr->zstream, Z_FINISH); + + if (ret == Z_OK) + { + /* check to see if we need more room */ + if (!(png_ptr->zstream.avail_out)) + { + /* check to make sure our output array has room */ + if (comp->num_output_ptr >= comp->max_output_ptr) + { + int old_max; + + old_max = comp->max_output_ptr; + comp->max_output_ptr = comp->num_output_ptr + 4; + if (comp->output_ptr != NULL) + { + png_charpp old_ptr; + + old_ptr = comp->output_ptr; + /* This could be optimized to realloc() */ + comp->output_ptr = (png_charpp)png_malloc(png_ptr, + (png_uint_32)(comp->max_output_ptr * + png_sizeof (png_charpp))); + png_memcpy(comp->output_ptr, old_ptr, + old_max * png_sizeof (png_charp)); + png_free(png_ptr, old_ptr); + } + else + comp->output_ptr = (png_charpp)png_malloc(png_ptr, + (png_uint_32)(comp->max_output_ptr * + png_sizeof (png_charp))); + } + + /* save off the data */ + comp->output_ptr[comp->num_output_ptr] = + (png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); + png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, + png_ptr->zbuf_size); + comp->num_output_ptr++; + + /* and reset the buffer pointers */ + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + png_ptr->zstream.next_out = png_ptr->zbuf; + } + } + else if (ret != Z_STREAM_END) + { + /* we got an error */ + if (png_ptr->zstream.msg != NULL) + png_error(png_ptr, png_ptr->zstream.msg); + else + png_error(png_ptr, "zlib error"); + } + } while (ret != Z_STREAM_END); + + /* text length is number of buffers plus last buffer */ + text_len = png_ptr->zbuf_size * comp->num_output_ptr; + if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) + text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out; + + return((int)text_len); +} + +/* ship the compressed text out via chunk writes */ +static void /* PRIVATE */ +png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) +{ + int i; + + /* handle the no-compression case */ + if (comp->input) + { + png_write_chunk_data(png_ptr, (png_bytep)comp->input, + (png_size_t)comp->input_len); + return; + } + + /* write saved output buffers, if any */ + for (i = 0; i < comp->num_output_ptr; i++) + { + png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i], + png_ptr->zbuf_size); + png_free(png_ptr, comp->output_ptr[i]); + comp->output_ptr[i]=NULL; + } + if (comp->max_output_ptr != 0) + png_free(png_ptr, comp->output_ptr); + comp->output_ptr=NULL; + /* write anything left in zbuf */ + if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size) + png_write_chunk_data(png_ptr, png_ptr->zbuf, + png_ptr->zbuf_size - png_ptr->zstream.avail_out); + + /* reset zlib for another zTXt/iTXt or image data */ + deflateReset(&png_ptr->zstream); + png_ptr->zstream.data_type = Z_BINARY; +} +#endif + +/* Write the IHDR chunk, and update the png_struct with the necessary + * information. Note that the rest of this code depends upon this + * information being correct. + */ +void /* PRIVATE */ +png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, + int bit_depth, int color_type, int compression_type, int filter_type, + int interlace_type) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IHDR; +#endif + png_byte buf[13]; /* buffer to store the IHDR info */ + + png_debug(1, "in png_write_IHDR\n"); + /* Check that we have valid input data from the application info */ + switch (color_type) + { + case PNG_COLOR_TYPE_GRAY: + switch (bit_depth) + { + case 1: + case 2: + case 4: + case 8: + case 16: png_ptr->channels = 1; break; + default: png_error(png_ptr,"Invalid bit depth for grayscale image"); + } + break; + case PNG_COLOR_TYPE_RGB: + if (bit_depth != 8 && bit_depth != 16) + png_error(png_ptr, "Invalid bit depth for RGB image"); + png_ptr->channels = 3; + break; + case PNG_COLOR_TYPE_PALETTE: + switch (bit_depth) + { + case 1: + case 2: + case 4: + case 8: png_ptr->channels = 1; break; + default: png_error(png_ptr, "Invalid bit depth for paletted image"); + } + break; + case PNG_COLOR_TYPE_GRAY_ALPHA: + if (bit_depth != 8 && bit_depth != 16) + png_error(png_ptr, "Invalid bit depth for grayscale+alpha image"); + png_ptr->channels = 2; + break; + case PNG_COLOR_TYPE_RGB_ALPHA: + if (bit_depth != 8 && bit_depth != 16) + png_error(png_ptr, "Invalid bit depth for RGBA image"); + png_ptr->channels = 4; + break; + default: + png_error(png_ptr, "Invalid image color type specified"); + } + + if (compression_type != PNG_COMPRESSION_TYPE_BASE) + { + png_warning(png_ptr, "Invalid compression type specified"); + compression_type = PNG_COMPRESSION_TYPE_BASE; + } + + /* Write filter_method 64 (intrapixel differencing) only if + * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and + * 2. Libpng did not write a PNG signature (this filter_method is only + * used in PNG datastreams that are embedded in MNG datastreams) and + * 3. The application called png_permit_mng_features with a mask that + * included PNG_FLAG_MNG_FILTER_64 and + * 4. The filter_method is 64 and + * 5. The color_type is RGB or RGBA + */ + if ( +#if defined(PNG_MNG_FEATURES_SUPPORTED) + !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && + (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) && + (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) && +#endif + filter_type != PNG_FILTER_TYPE_BASE) + { + png_warning(png_ptr, "Invalid filter type specified"); + filter_type = PNG_FILTER_TYPE_BASE; + } + +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + if (interlace_type != PNG_INTERLACE_NONE && + interlace_type != PNG_INTERLACE_ADAM7) + { + png_warning(png_ptr, "Invalid interlace type specified"); + interlace_type = PNG_INTERLACE_ADAM7; + } +#else + interlace_type=PNG_INTERLACE_NONE; +#endif + + /* save off the relevent information */ + png_ptr->bit_depth = (png_byte)bit_depth; + png_ptr->color_type = (png_byte)color_type; + png_ptr->interlaced = (png_byte)interlace_type; +#if defined(PNG_MNG_FEATURES_SUPPORTED) + png_ptr->filter_type = (png_byte)filter_type; +#endif + png_ptr->compression_type = (png_byte)compression_type; + png_ptr->width = width; + png_ptr->height = height; + + png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels); + png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width); + /* set the usr info, so any transformations can modify it */ + png_ptr->usr_width = png_ptr->width; + png_ptr->usr_bit_depth = png_ptr->bit_depth; + png_ptr->usr_channels = png_ptr->channels; + + /* pack the header information into the buffer */ + png_save_uint_32(buf, width); + png_save_uint_32(buf + 4, height); + buf[8] = (png_byte)bit_depth; + buf[9] = (png_byte)color_type; + buf[10] = (png_byte)compression_type; + buf[11] = (png_byte)filter_type; + buf[12] = (png_byte)interlace_type; + + /* write the chunk */ + png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13); + + /* initialize zlib with PNG info */ + png_ptr->zstream.zalloc = png_zalloc; + png_ptr->zstream.zfree = png_zfree; + png_ptr->zstream.opaque = (voidpf)png_ptr; + if (!(png_ptr->do_filter)) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE || + png_ptr->bit_depth < 8) + png_ptr->do_filter = PNG_FILTER_NONE; + else + png_ptr->do_filter = PNG_ALL_FILTERS; + } + if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY)) + { + if (png_ptr->do_filter != PNG_FILTER_NONE) + png_ptr->zlib_strategy = Z_FILTERED; + else + png_ptr->zlib_strategy = Z_DEFAULT_STRATEGY; + } + if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_LEVEL)) + png_ptr->zlib_level = Z_DEFAULT_COMPRESSION; + if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL)) + png_ptr->zlib_mem_level = 8; + if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS)) + png_ptr->zlib_window_bits = 15; + if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD)) + png_ptr->zlib_method = 8; + deflateInit2(&png_ptr->zstream, png_ptr->zlib_level, + png_ptr->zlib_method, png_ptr->zlib_window_bits, + png_ptr->zlib_mem_level, png_ptr->zlib_strategy); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + /* libpng is not interested in zstream.data_type */ + /* set it to a predefined value, to avoid its evaluation inside zlib */ + png_ptr->zstream.data_type = Z_BINARY; + + png_ptr->mode = PNG_HAVE_IHDR; +} + +/* write the palette. We are careful not to trust png_color to be in the + * correct order for PNG, so people can redefine it to any convenient + * structure. + */ +void /* PRIVATE */ +png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_PLTE; +#endif + png_uint_32 i; + png_colorp pal_ptr; + png_byte buf[3]; + + png_debug(1, "in png_write_PLTE\n"); + if (( +#if defined(PNG_MNG_FEATURES_SUPPORTED) + !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && +#endif + num_pal == 0) || num_pal > 256) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_error(png_ptr, "Invalid number of colors in palette"); + } + else + { + png_warning(png_ptr, "Invalid number of colors in palette"); + return; + } + } + + if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) + { + png_warning(png_ptr, + "Ignoring request to write a PLTE chunk in grayscale PNG"); + return; + } + + png_ptr->num_palette = (png_uint_16)num_pal; + png_debug1(3, "num_palette = %d\n", png_ptr->num_palette); + + png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, num_pal * 3); +#ifndef PNG_NO_POINTER_INDEXING + for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) + { + buf[0] = pal_ptr->red; + buf[1] = pal_ptr->green; + buf[2] = pal_ptr->blue; + png_write_chunk_data(png_ptr, buf, (png_size_t)3); + } +#else + /* This is a little slower but some buggy compilers need to do this instead */ + pal_ptr=palette; + for (i = 0; i < num_pal; i++) + { + buf[0] = pal_ptr[i].red; + buf[1] = pal_ptr[i].green; + buf[2] = pal_ptr[i].blue; + png_write_chunk_data(png_ptr, buf, (png_size_t)3); + } +#endif + png_write_chunk_end(png_ptr); + png_ptr->mode |= PNG_HAVE_PLTE; +} + +/* write an IDAT chunk */ +void /* PRIVATE */ +png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IDAT; +#endif + png_debug(1, "in png_write_IDAT\n"); + + /* Optimize the CMF field in the zlib stream. */ + /* This hack of the zlib stream is compliant to the stream specification. */ + if (!(png_ptr->mode & PNG_HAVE_IDAT) && + png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) + { + unsigned int z_cmf = data[0]; /* zlib compression method and flags */ + if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70) + { + /* Avoid memory underflows and multiplication overflows. */ + /* The conditions below are practically always satisfied; + however, they still must be checked. */ + if (length >= 2 && + png_ptr->height < 16384 && png_ptr->width < 16384) + { + png_uint_32 uncompressed_idat_size = png_ptr->height * + ((png_ptr->width * + png_ptr->channels * png_ptr->bit_depth + 15) >> 3); + unsigned int z_cinfo = z_cmf >> 4; + unsigned int half_z_window_size = 1 << (z_cinfo + 7); + while (uncompressed_idat_size <= half_z_window_size && + half_z_window_size >= 256) + { + z_cinfo--; + half_z_window_size >>= 1; + } + z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4); + if (data[0] != (png_byte)z_cmf) + { + data[0] = (png_byte)z_cmf; + data[1] &= 0xe0; + data[1] += (png_byte)(0x1f - ((z_cmf << 8) + data[1]) % 0x1f); + } + } + } + else + png_error(png_ptr, + "Invalid zlib compression method or flags in IDAT"); + } + + png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length); + png_ptr->mode |= PNG_HAVE_IDAT; +} + +/* write an IEND chunk */ +void /* PRIVATE */ +png_write_IEND(png_structp png_ptr) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IEND; +#endif + png_debug(1, "in png_write_IEND\n"); + png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL, + (png_size_t)0); + png_ptr->mode |= PNG_HAVE_IEND; +} + +#if defined(PNG_WRITE_gAMA_SUPPORTED) +/* write a gAMA chunk */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +void /* PRIVATE */ +png_write_gAMA(png_structp png_ptr, double file_gamma) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_gAMA; +#endif + png_uint_32 igamma; + png_byte buf[4]; + + png_debug(1, "in png_write_gAMA\n"); + /* file_gamma is saved in 1/100,000ths */ + igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5); + png_save_uint_32(buf, igamma); + png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); +} +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +void /* PRIVATE */ +png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_gAMA; +#endif + png_byte buf[4]; + + png_debug(1, "in png_write_gAMA\n"); + /* file_gamma is saved in 1/100,000ths */ + png_save_uint_32(buf, (png_uint_32)file_gamma); + png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); +} +#endif +#endif + +#if defined(PNG_WRITE_sRGB_SUPPORTED) +/* write a sRGB chunk */ +void /* PRIVATE */ +png_write_sRGB(png_structp png_ptr, int srgb_intent) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_sRGB; +#endif + png_byte buf[1]; + + png_debug(1, "in png_write_sRGB\n"); + if(srgb_intent >= PNG_sRGB_INTENT_LAST) + png_warning(png_ptr, + "Invalid sRGB rendering intent specified"); + buf[0]=(png_byte)srgb_intent; + png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1); +} +#endif + +#if defined(PNG_WRITE_iCCP_SUPPORTED) +/* write an iCCP chunk */ +void /* PRIVATE */ +png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, + png_charp profile, int profile_len) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_iCCP; +#endif + png_size_t name_len; + png_charp new_name; + compression_state comp; + int embedded_profile_len = 0; + + png_debug(1, "in png_write_iCCP\n"); + + comp.num_output_ptr = 0; + comp.max_output_ptr = 0; + comp.output_ptr = NULL; + comp.input = NULL; + comp.input_len = 0; + + if (name == NULL || (name_len = png_check_keyword(png_ptr, name, + &new_name)) == 0) + { + png_warning(png_ptr, "Empty keyword in iCCP chunk"); + return; + } + + if (compression_type != PNG_COMPRESSION_TYPE_BASE) + png_warning(png_ptr, "Unknown compression type in iCCP chunk"); + + if (profile == NULL) + profile_len = 0; + + if (profile_len > 3) + embedded_profile_len = + ((*( (png_bytep)profile ))<<24) | + ((*( (png_bytep)profile+1))<<16) | + ((*( (png_bytep)profile+2))<< 8) | + ((*( (png_bytep)profile+3)) ); + + if (profile_len < embedded_profile_len) + { + png_warning(png_ptr, + "Embedded profile length too large in iCCP chunk"); + return; + } + + if (profile_len > embedded_profile_len) + { + png_warning(png_ptr, + "Truncating profile to actual length in iCCP chunk"); + profile_len = embedded_profile_len; + } + + if (profile_len) + profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len, + PNG_COMPRESSION_TYPE_BASE, &comp); + + /* make sure we include the NULL after the name and the compression type */ + png_write_chunk_start(png_ptr, (png_bytep)png_iCCP, + (png_uint_32)name_len+profile_len+2); + new_name[name_len+1]=0x00; + png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2); + + if (profile_len) + png_write_compressed_data_out(png_ptr, &comp); + + png_write_chunk_end(png_ptr); + png_free(png_ptr, new_name); +} +#endif + +#if defined(PNG_WRITE_sPLT_SUPPORTED) +/* write a sPLT chunk */ +void /* PRIVATE */ +png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_sPLT; +#endif + png_size_t name_len; + png_charp new_name; + png_byte entrybuf[10]; + int entry_size = (spalette->depth == 8 ? 6 : 10); + int palette_size = entry_size * spalette->nentries; + png_sPLT_entryp ep; +#ifdef PNG_NO_POINTER_INDEXING + int i; +#endif + + png_debug(1, "in png_write_sPLT\n"); + if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, + spalette->name, &new_name))==0) + { + png_warning(png_ptr, "Empty keyword in sPLT chunk"); + return; + } + + /* make sure we include the NULL after the name */ + png_write_chunk_start(png_ptr, (png_bytep)png_sPLT, + (png_uint_32)(name_len + 2 + palette_size)); + png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1); + png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1); + + /* loop through each palette entry, writing appropriately */ +#ifndef PNG_NO_POINTER_INDEXING + for (ep = spalette->entries; epentries+spalette->nentries; ep++) + { + if (spalette->depth == 8) + { + entrybuf[0] = (png_byte)ep->red; + entrybuf[1] = (png_byte)ep->green; + entrybuf[2] = (png_byte)ep->blue; + entrybuf[3] = (png_byte)ep->alpha; + png_save_uint_16(entrybuf + 4, ep->frequency); + } + else + { + png_save_uint_16(entrybuf + 0, ep->red); + png_save_uint_16(entrybuf + 2, ep->green); + png_save_uint_16(entrybuf + 4, ep->blue); + png_save_uint_16(entrybuf + 6, ep->alpha); + png_save_uint_16(entrybuf + 8, ep->frequency); + } + png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size); + } +#else + ep=spalette->entries; + for (i=0; i>spalette->nentries; i++) + { + if (spalette->depth == 8) + { + entrybuf[0] = (png_byte)ep[i].red; + entrybuf[1] = (png_byte)ep[i].green; + entrybuf[2] = (png_byte)ep[i].blue; + entrybuf[3] = (png_byte)ep[i].alpha; + png_save_uint_16(entrybuf + 4, ep[i].frequency); + } + else + { + png_save_uint_16(entrybuf + 0, ep[i].red); + png_save_uint_16(entrybuf + 2, ep[i].green); + png_save_uint_16(entrybuf + 4, ep[i].blue); + png_save_uint_16(entrybuf + 6, ep[i].alpha); + png_save_uint_16(entrybuf + 8, ep[i].frequency); + } + png_write_chunk_data(png_ptr, entrybuf, entry_size); + } +#endif + + png_write_chunk_end(png_ptr); + png_free(png_ptr, new_name); +} +#endif + +#if defined(PNG_WRITE_sBIT_SUPPORTED) +/* write the sBIT chunk */ +void /* PRIVATE */ +png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_sBIT; +#endif + png_byte buf[4]; + png_size_t size; + + png_debug(1, "in png_write_sBIT\n"); + /* make sure we don't depend upon the order of PNG_COLOR_8 */ + if (color_type & PNG_COLOR_MASK_COLOR) + { + png_byte maxbits; + + maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 : + png_ptr->usr_bit_depth); + if (sbit->red == 0 || sbit->red > maxbits || + sbit->green == 0 || sbit->green > maxbits || + sbit->blue == 0 || sbit->blue > maxbits) + { + png_warning(png_ptr, "Invalid sBIT depth specified"); + return; + } + buf[0] = sbit->red; + buf[1] = sbit->green; + buf[2] = sbit->blue; + size = 3; + } + else + { + if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth) + { + png_warning(png_ptr, "Invalid sBIT depth specified"); + return; + } + buf[0] = sbit->gray; + size = 1; + } + + if (color_type & PNG_COLOR_MASK_ALPHA) + { + if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth) + { + png_warning(png_ptr, "Invalid sBIT depth specified"); + return; + } + buf[size++] = sbit->alpha; + } + + png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size); +} +#endif + +#if defined(PNG_WRITE_cHRM_SUPPORTED) +/* write the cHRM chunk */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +void /* PRIVATE */ +png_write_cHRM(png_structp png_ptr, double white_x, double white_y, + double red_x, double red_y, double green_x, double green_y, + double blue_x, double blue_y) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_cHRM; +#endif + png_byte buf[32]; + png_uint_32 itemp; + + png_debug(1, "in png_write_cHRM\n"); + /* each value is saved in 1/100,000ths */ + if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 || + white_x + white_y > 1.0) + { + png_warning(png_ptr, "Invalid cHRM white point specified"); +#if !defined(PNG_NO_CONSOLE_IO) + fprintf(stderr,"white_x=%f, white_y=%f\n",white_x, white_y); +#endif + return; + } + itemp = (png_uint_32)(white_x * 100000.0 + 0.5); + png_save_uint_32(buf, itemp); + itemp = (png_uint_32)(white_y * 100000.0 + 0.5); + png_save_uint_32(buf + 4, itemp); + + if (red_x < 0 || red_y < 0 || red_x + red_y > 1.0) + { + png_warning(png_ptr, "Invalid cHRM red point specified"); + return; + } + itemp = (png_uint_32)(red_x * 100000.0 + 0.5); + png_save_uint_32(buf + 8, itemp); + itemp = (png_uint_32)(red_y * 100000.0 + 0.5); + png_save_uint_32(buf + 12, itemp); + + if (green_x < 0 || green_y < 0 || green_x + green_y > 1.0) + { + png_warning(png_ptr, "Invalid cHRM green point specified"); + return; + } + itemp = (png_uint_32)(green_x * 100000.0 + 0.5); + png_save_uint_32(buf + 16, itemp); + itemp = (png_uint_32)(green_y * 100000.0 + 0.5); + png_save_uint_32(buf + 20, itemp); + + if (blue_x < 0 || blue_y < 0 || blue_x + blue_y > 1.0) + { + png_warning(png_ptr, "Invalid cHRM blue point specified"); + return; + } + itemp = (png_uint_32)(blue_x * 100000.0 + 0.5); + png_save_uint_32(buf + 24, itemp); + itemp = (png_uint_32)(blue_y * 100000.0 + 0.5); + png_save_uint_32(buf + 28, itemp); + + png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); +} +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +void /* PRIVATE */ +png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, + png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, + png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, + png_fixed_point blue_y) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_cHRM; +#endif + png_byte buf[32]; + + png_debug(1, "in png_write_cHRM\n"); + /* each value is saved in 1/100,000ths */ + if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L) + { + png_warning(png_ptr, "Invalid fixed cHRM white point specified"); +#if !defined(PNG_NO_CONSOLE_IO) + fprintf(stderr,"white_x=%ld, white_y=%ld\n",white_x, white_y); +#endif + return; + } + png_save_uint_32(buf, (png_uint_32)white_x); + png_save_uint_32(buf + 4, (png_uint_32)white_y); + + if (red_x + red_y > 100000L) + { + png_warning(png_ptr, "Invalid cHRM fixed red point specified"); + return; + } + png_save_uint_32(buf + 8, (png_uint_32)red_x); + png_save_uint_32(buf + 12, (png_uint_32)red_y); + + if (green_x + green_y > 100000L) + { + png_warning(png_ptr, "Invalid fixed cHRM green point specified"); + return; + } + png_save_uint_32(buf + 16, (png_uint_32)green_x); + png_save_uint_32(buf + 20, (png_uint_32)green_y); + + if (blue_x + blue_y > 100000L) + { + png_warning(png_ptr, "Invalid fixed cHRM blue point specified"); + return; + } + png_save_uint_32(buf + 24, (png_uint_32)blue_x); + png_save_uint_32(buf + 28, (png_uint_32)blue_y); + + png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); +} +#endif +#endif + +#if defined(PNG_WRITE_tRNS_SUPPORTED) +/* write the tRNS chunk */ +void /* PRIVATE */ +png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, + int num_trans, int color_type) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_tRNS; +#endif + png_byte buf[6]; + + png_debug(1, "in png_write_tRNS\n"); + if (color_type == PNG_COLOR_TYPE_PALETTE) + { + if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette) + { + png_warning(png_ptr,"Invalid number of transparent colors specified"); + return; + } + /* write the chunk out as it is */ + png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans, (png_size_t)num_trans); + } + else if (color_type == PNG_COLOR_TYPE_GRAY) + { + /* one 16 bit value */ + if(tran->gray >= (1 << png_ptr->bit_depth)) + { + png_warning(png_ptr, + "Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); + return; + } + png_save_uint_16(buf, tran->gray); + png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2); + } + else if (color_type == PNG_COLOR_TYPE_RGB) + { + /* three 16 bit values */ + png_save_uint_16(buf, tran->red); + png_save_uint_16(buf + 2, tran->green); + png_save_uint_16(buf + 4, tran->blue); + if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) + { + png_warning(png_ptr, + "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); + return; + } + png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6); + } + else + { + png_warning(png_ptr, "Can't write tRNS with an alpha channel"); + } +} +#endif + +#if defined(PNG_WRITE_bKGD_SUPPORTED) +/* write the background chunk */ +void /* PRIVATE */ +png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_bKGD; +#endif + png_byte buf[6]; + + png_debug(1, "in png_write_bKGD\n"); + if (color_type == PNG_COLOR_TYPE_PALETTE) + { + if ( +#if defined(PNG_MNG_FEATURES_SUPPORTED) + (png_ptr->num_palette || + (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) && +#endif + back->index > png_ptr->num_palette) + { + png_warning(png_ptr, "Invalid background palette index"); + return; + } + buf[0] = back->index; + png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1); + } + else if (color_type & PNG_COLOR_MASK_COLOR) + { + png_save_uint_16(buf, back->red); + png_save_uint_16(buf + 2, back->green); + png_save_uint_16(buf + 4, back->blue); + if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) + { + png_warning(png_ptr, + "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); + return; + } + png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6); + } + else + { + if(back->gray >= (1 << png_ptr->bit_depth)) + { + png_warning(png_ptr, + "Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); + return; + } + png_save_uint_16(buf, back->gray); + png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2); + } +} +#endif + +#if defined(PNG_WRITE_hIST_SUPPORTED) +/* write the histogram */ +void /* PRIVATE */ +png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_hIST; +#endif + int i; + png_byte buf[3]; + + png_debug(1, "in png_write_hIST\n"); + if (num_hist > (int)png_ptr->num_palette) + { + png_debug2(3, "num_hist = %d, num_palette = %d\n", num_hist, + png_ptr->num_palette); + png_warning(png_ptr, "Invalid number of histogram entries specified"); + return; + } + + png_write_chunk_start(png_ptr, (png_bytep)png_hIST, (png_uint_32)(num_hist * 2)); + for (i = 0; i < num_hist; i++) + { + png_save_uint_16(buf, hist[i]); + png_write_chunk_data(png_ptr, buf, (png_size_t)2); + } + png_write_chunk_end(png_ptr); +} +#endif + +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ + defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) +/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, + * and if invalid, correct the keyword rather than discarding the entire + * chunk. The PNG 1.0 specification requires keywords 1-79 characters in + * length, forbids leading or trailing whitespace, multiple internal spaces, + * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. + * + * The new_key is allocated to hold the corrected keyword and must be freed + * by the calling routine. This avoids problems with trying to write to + * static keywords without having to have duplicate copies of the strings. + */ +png_size_t /* PRIVATE */ +png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) +{ + png_size_t key_len; + png_charp kp, dp; + int kflag; + int kwarn=0; + + png_debug(1, "in png_check_keyword\n"); + *new_key = NULL; + + if (key == NULL || (key_len = png_strlen(key)) == 0) + { + png_warning(png_ptr, "zero length keyword"); + return ((png_size_t)0); + } + + png_debug1(2, "Keyword to be checked is '%s'\n", key); + + *new_key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + 2)); + if (*new_key == NULL) + { + png_warning(png_ptr, "Out of memory while procesing keyword"); + return ((png_size_t)0); + } + + /* Replace non-printing characters with a blank and print a warning */ + for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++) + { + if (*kp < 0x20 || (*kp > 0x7E && (png_byte)*kp < 0xA1)) + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char msg[40]; + + sprintf(msg, "invalid keyword character 0x%02X", *kp); + png_warning(png_ptr, msg); +#else + png_warning(png_ptr, "invalid character in keyword"); +#endif + *dp = ' '; + } + else + { + *dp = *kp; + } + } + *dp = '\0'; + + /* Remove any trailing white space. */ + kp = *new_key + key_len - 1; + if (*kp == ' ') + { + png_warning(png_ptr, "trailing spaces removed from keyword"); + + while (*kp == ' ') + { + *(kp--) = '\0'; + key_len--; + } + } + + /* Remove any leading white space. */ + kp = *new_key; + if (*kp == ' ') + { + png_warning(png_ptr, "leading spaces removed from keyword"); + + while (*kp == ' ') + { + kp++; + key_len--; + } + } + + png_debug1(2, "Checking for multiple internal spaces in '%s'\n", kp); + + /* Remove multiple internal spaces. */ + for (kflag = 0, dp = *new_key; *kp != '\0'; kp++) + { + if (*kp == ' ' && kflag == 0) + { + *(dp++) = *kp; + kflag = 1; + } + else if (*kp == ' ') + { + key_len--; + kwarn=1; + } + else + { + *(dp++) = *kp; + kflag = 0; + } + } + *dp = '\0'; + if(kwarn) + png_warning(png_ptr, "extra interior spaces removed from keyword"); + + if (key_len == 0) + { + png_free(png_ptr, *new_key); + *new_key=NULL; + png_warning(png_ptr, "Zero length keyword"); + } + + if (key_len > 79) + { + png_warning(png_ptr, "keyword length must be 1 - 79 characters"); + new_key[79] = '\0'; + key_len = 79; + } + + return (key_len); +} +#endif + +#if defined(PNG_WRITE_tEXt_SUPPORTED) +/* write a tEXt chunk */ +void /* PRIVATE */ +png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, + png_size_t text_len) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_tEXt; +#endif + png_size_t key_len; + png_charp new_key; + + png_debug(1, "in png_write_tEXt\n"); + if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) + { + png_warning(png_ptr, "Empty keyword in tEXt chunk"); + return; + } + + if (text == NULL || *text == '\0') + text_len = 0; + else + text_len = png_strlen(text); + + /* make sure we include the 0 after the key */ + png_write_chunk_start(png_ptr, (png_bytep)png_tEXt, (png_uint_32)key_len+text_len+1); + /* + * We leave it to the application to meet PNG-1.0 requirements on the + * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of + * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. + * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. + */ + png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); + if (text_len) + png_write_chunk_data(png_ptr, (png_bytep)text, text_len); + + png_write_chunk_end(png_ptr); + png_free(png_ptr, new_key); +} +#endif + +#if defined(PNG_WRITE_zTXt_SUPPORTED) +/* write a compressed text chunk */ +void /* PRIVATE */ +png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, + png_size_t text_len, int compression) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_zTXt; +#endif + png_size_t key_len; + char buf[1]; + png_charp new_key; + compression_state comp; + + png_debug(1, "in png_write_zTXt\n"); + + comp.num_output_ptr = 0; + comp.max_output_ptr = 0; + comp.output_ptr = NULL; + comp.input = NULL; + comp.input_len = 0; + + if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) + { + png_warning(png_ptr, "Empty keyword in zTXt chunk"); + return; + } + + if (text == NULL || *text == '\0' || compression==PNG_TEXT_COMPRESSION_NONE) + { + png_write_tEXt(png_ptr, new_key, text, (png_size_t)0); + png_free(png_ptr, new_key); + return; + } + + text_len = png_strlen(text); + + png_free(png_ptr, new_key); + + /* compute the compressed data; do it now for the length */ + text_len = png_text_compress(png_ptr, text, text_len, compression, + &comp); + + /* write start of chunk */ + png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32) + (key_len+text_len+2)); + /* write key */ + png_write_chunk_data(png_ptr, (png_bytep)key, key_len + 1); + buf[0] = (png_byte)compression; + /* write compression */ + png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1); + /* write the compressed data */ + png_write_compressed_data_out(png_ptr, &comp); + + /* close the chunk */ + png_write_chunk_end(png_ptr); +} +#endif + +#if defined(PNG_WRITE_iTXt_SUPPORTED) +/* write an iTXt chunk */ +void /* PRIVATE */ +png_write_iTXt(png_structp png_ptr, int compression, png_charp key, + png_charp lang, png_charp lang_key, png_charp text) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_iTXt; +#endif + png_size_t lang_len, key_len, lang_key_len, text_len; + png_charp new_lang, new_key; + png_byte cbuf[2]; + compression_state comp; + + png_debug(1, "in png_write_iTXt\n"); + + comp.num_output_ptr = 0; + comp.max_output_ptr = 0; + comp.output_ptr = NULL; + comp.input = NULL; + + if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) + { + png_warning(png_ptr, "Empty keyword in iTXt chunk"); + return; + } + if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0) + { + png_warning(png_ptr, "Empty language field in iTXt chunk"); + new_lang = NULL; + lang_len = 0; + } + + if (lang_key == NULL) + lang_key_len = 0; + else + lang_key_len = png_strlen(lang_key); + + if (text == NULL) + text_len = 0; + else + text_len = png_strlen(text); + + /* compute the compressed data; do it now for the length */ + text_len = png_text_compress(png_ptr, text, text_len, compression-2, + &comp); + + + /* make sure we include the compression flag, the compression byte, + * and the NULs after the key, lang, and lang_key parts */ + + png_write_chunk_start(png_ptr, (png_bytep)png_iTXt, + (png_uint_32)( + 5 /* comp byte, comp flag, terminators for key, lang and lang_key */ + + key_len + + lang_len + + lang_key_len + + text_len)); + + /* + * We leave it to the application to meet PNG-1.0 requirements on the + * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of + * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. + * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. + */ + png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); + + /* set the compression flag */ + if (compression == PNG_ITXT_COMPRESSION_NONE || \ + compression == PNG_TEXT_COMPRESSION_NONE) + cbuf[0] = 0; + else /* compression == PNG_ITXT_COMPRESSION_zTXt */ + cbuf[0] = 1; + /* set the compression method */ + cbuf[1] = 0; + png_write_chunk_data(png_ptr, cbuf, 2); + + cbuf[0] = 0; + png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), lang_len + 1); + png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), lang_key_len + 1); + png_write_compressed_data_out(png_ptr, &comp); + + png_write_chunk_end(png_ptr); + png_free(png_ptr, new_key); + if (new_lang) + png_free(png_ptr, new_lang); +} +#endif + +#if defined(PNG_WRITE_oFFs_SUPPORTED) +/* write the oFFs chunk */ +void /* PRIVATE */ +png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, + int unit_type) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_oFFs; +#endif + png_byte buf[9]; + + png_debug(1, "in png_write_oFFs\n"); + if (unit_type >= PNG_OFFSET_LAST) + png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); + + png_save_int_32(buf, x_offset); + png_save_int_32(buf + 4, y_offset); + buf[8] = (png_byte)unit_type; + + png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9); +} +#endif + +#if defined(PNG_WRITE_pCAL_SUPPORTED) +/* write the pCAL chunk (described in the PNG extensions document) */ +void /* PRIVATE */ +png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, + png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_pCAL; +#endif + png_size_t purpose_len, units_len, total_len; + png_uint_32p params_len; + png_byte buf[10]; + png_charp new_purpose; + int i; + + png_debug1(1, "in png_write_pCAL (%d parameters)\n", nparams); + if (type >= PNG_EQUATION_LAST) + png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); + + purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1; + png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len); + units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); + png_debug1(3, "pCAL units length = %d\n", (int)units_len); + total_len = purpose_len + units_len + 10; + + params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams + *png_sizeof(png_uint_32))); + + /* Find the length of each parameter, making sure we don't count the + null terminator for the last parameter. */ + for (i = 0; i < nparams; i++) + { + params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); + png_debug2(3, "pCAL parameter %d length = %lu\n", i, params_len[i]); + total_len += (png_size_t)params_len[i]; + } + + png_debug1(3, "pCAL total length = %d\n", (int)total_len); + png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len); + png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len); + png_save_int_32(buf, X0); + png_save_int_32(buf + 4, X1); + buf[8] = (png_byte)type; + buf[9] = (png_byte)nparams; + png_write_chunk_data(png_ptr, buf, (png_size_t)10); + png_write_chunk_data(png_ptr, (png_bytep)units, (png_size_t)units_len); + + png_free(png_ptr, new_purpose); + + for (i = 0; i < nparams; i++) + { + png_write_chunk_data(png_ptr, (png_bytep)params[i], + (png_size_t)params_len[i]); + } + + png_free(png_ptr, params_len); + png_write_chunk_end(png_ptr); +} +#endif + +#if defined(PNG_WRITE_sCAL_SUPPORTED) +/* write the sCAL chunk */ +#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) +void /* PRIVATE */ +png_write_sCAL(png_structp png_ptr, int unit, double width, double height) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_sCAL; +#endif + char buf[64]; + png_size_t total_len; + + png_debug(1, "in png_write_sCAL\n"); + + buf[0] = (char)unit; +#if defined(_WIN32_WCE) +/* sprintf() function is not supported on WindowsCE */ + { + wchar_t wc_buf[32]; + size_t wc_len; + swprintf(wc_buf, TEXT("%12.12e"), width); + wc_len = wcslen(wc_buf); + WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + 1, wc_len, NULL, NULL); + total_len = wc_len + 2; + swprintf(wc_buf, TEXT("%12.12e"), height); + wc_len = wcslen(wc_buf); + WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + total_len, wc_len, + NULL, NULL); + total_len += wc_len; + } +#else + sprintf(buf + 1, "%12.12e", width); + total_len = 1 + png_strlen(buf + 1) + 1; + sprintf(buf + total_len, "%12.12e", height); + total_len += png_strlen(buf + total_len); +#endif + + png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); + png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len); +} +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +void /* PRIVATE */ +png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, + png_charp height) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_sCAL; +#endif + png_byte buf[64]; + png_size_t wlen, hlen, total_len; + + png_debug(1, "in png_write_sCAL_s\n"); + + wlen = png_strlen(width); + hlen = png_strlen(height); + total_len = wlen + hlen + 2; + if (total_len > 64) + { + png_warning(png_ptr, "Can't write sCAL (buffer too small)"); + return; + } + + buf[0] = (png_byte)unit; + png_memcpy(buf + 1, width, wlen + 1); /* append the '\0' here */ + png_memcpy(buf + wlen + 2, height, hlen); /* do NOT append the '\0' here */ + + png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); + png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len); +} +#endif +#endif +#endif + +#if defined(PNG_WRITE_pHYs_SUPPORTED) +/* write the pHYs chunk */ +void /* PRIVATE */ +png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, + png_uint_32 y_pixels_per_unit, + int unit_type) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_pHYs; +#endif + png_byte buf[9]; + + png_debug(1, "in png_write_pHYs\n"); + if (unit_type >= PNG_RESOLUTION_LAST) + png_warning(png_ptr, "Unrecognized unit type for pHYs chunk"); + + png_save_uint_32(buf, x_pixels_per_unit); + png_save_uint_32(buf + 4, y_pixels_per_unit); + buf[8] = (png_byte)unit_type; + + png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9); +} +#endif + +#if defined(PNG_WRITE_tIME_SUPPORTED) +/* Write the tIME chunk. Use either png_convert_from_struct_tm() + * or png_convert_from_time_t(), or fill in the structure yourself. + */ +void /* PRIVATE */ +png_write_tIME(png_structp png_ptr, png_timep mod_time) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_tIME; +#endif + png_byte buf[7]; + + png_debug(1, "in png_write_tIME\n"); + if (mod_time->month > 12 || mod_time->month < 1 || + mod_time->day > 31 || mod_time->day < 1 || + mod_time->hour > 23 || mod_time->second > 60) + { + png_warning(png_ptr, "Invalid time specified for tIME chunk"); + return; + } + + png_save_uint_16(buf, mod_time->year); + buf[2] = mod_time->month; + buf[3] = mod_time->day; + buf[4] = mod_time->hour; + buf[5] = mod_time->minute; + buf[6] = mod_time->second; + + png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7); +} +#endif + +/* initializes the row writing capability of libpng */ +void /* PRIVATE */ +png_write_start_row(png_structp png_ptr) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + + /* start of interlace block */ + int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + + /* offset to next interlace block */ + int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + + /* start of interlace block in the y direction */ + int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + + /* offset to next interlace block in the y direction */ + int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; +#endif + + png_size_t buf_size; + + png_debug(1, "in png_write_start_row\n"); + buf_size = (png_size_t)(PNG_ROWBYTES( + png_ptr->usr_channels*png_ptr->usr_bit_depth,png_ptr->width)+1); + + /* set up row buffer */ + png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); + png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; + + /* set up filtering buffer, if using this filter */ + if (png_ptr->do_filter & PNG_FILTER_SUB) + { + png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, + (png_ptr->rowbytes + 1)); + png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; + } + + /* We only need to keep the previous row if we are using one of these. */ + if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) + { + /* set up previous row buffer */ + png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); + png_memset(png_ptr->prev_row, 0, buf_size); + + if (png_ptr->do_filter & PNG_FILTER_UP) + { + png_ptr->up_row = (png_bytep )png_malloc(png_ptr, + (png_ptr->rowbytes + 1)); + png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; + } + + if (png_ptr->do_filter & PNG_FILTER_AVG) + { + png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, + (png_ptr->rowbytes + 1)); + png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; + } + + if (png_ptr->do_filter & PNG_FILTER_PAETH) + { + png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr, + (png_ptr->rowbytes + 1)); + png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; + } + } + +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* if interlaced, we need to set up width and height of pass */ + if (png_ptr->interlaced) + { + if (!(png_ptr->transformations & PNG_INTERLACE)) + { + png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - + png_pass_ystart[0]) / png_pass_yinc[0]; + png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 - + png_pass_start[0]) / png_pass_inc[0]; + } + else + { + png_ptr->num_rows = png_ptr->height; + png_ptr->usr_width = png_ptr->width; + } + } + else +#endif + { + png_ptr->num_rows = png_ptr->height; + png_ptr->usr_width = png_ptr->width; + } + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + png_ptr->zstream.next_out = png_ptr->zbuf; +} + +/* Internal use only. Called when finished processing a row of data. */ +void /* PRIVATE */ +png_write_finish_row(png_structp png_ptr) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + + /* start of interlace block */ + int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + + /* offset to next interlace block */ + int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + + /* start of interlace block in the y direction */ + int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + + /* offset to next interlace block in the y direction */ + int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; +#endif + + int ret; + + png_debug(1, "in png_write_finish_row\n"); + /* next row */ + png_ptr->row_number++; + + /* see if we are done */ + if (png_ptr->row_number < png_ptr->num_rows) + return; + +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* if interlaced, go to next pass */ + if (png_ptr->interlaced) + { + png_ptr->row_number = 0; + if (png_ptr->transformations & PNG_INTERLACE) + { + png_ptr->pass++; + } + else + { + /* loop until we find a non-zero width or height pass */ + do + { + png_ptr->pass++; + if (png_ptr->pass >= 7) + break; + png_ptr->usr_width = (png_ptr->width + + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; + png_ptr->num_rows = (png_ptr->height + + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; + if (png_ptr->transformations & PNG_INTERLACE) + break; + } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0); + + } + + /* reset the row above the image for the next pass */ + if (png_ptr->pass < 7) + { + if (png_ptr->prev_row != NULL) + png_memset(png_ptr->prev_row, 0, + (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels* + png_ptr->usr_bit_depth,png_ptr->width))+1); + return; + } + } +#endif + + /* if we get here, we've just written the last row, so we need + to flush the compressor */ + do + { + /* tell the compressor we are done */ + ret = deflate(&png_ptr->zstream, Z_FINISH); + /* check for an error */ + if (ret == Z_OK) + { + /* check to see if we need more room */ + if (!(png_ptr->zstream.avail_out)) + { + png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + } + } + else if (ret != Z_STREAM_END) + { + if (png_ptr->zstream.msg != NULL) + png_error(png_ptr, png_ptr->zstream.msg); + else + png_error(png_ptr, "zlib error"); + } + } while (ret != Z_STREAM_END); + + /* write any extra space */ + if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) + { + png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size - + png_ptr->zstream.avail_out); + } + + deflateReset(&png_ptr->zstream); + png_ptr->zstream.data_type = Z_BINARY; +} + +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* Pick out the correct pixels for the interlace pass. + * The basic idea here is to go through the row with a source + * pointer and a destination pointer (sp and dp), and copy the + * correct pixels for the pass. As the row gets compacted, + * sp will always be >= dp, so we should never overwrite anything. + * See the default: case for the easiest code to understand. + */ +void /* PRIVATE */ +png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + + /* start of interlace block */ + int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + + /* offset to next interlace block */ + int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +#endif + + png_debug(1, "in png_do_write_interlace\n"); + /* we don't have to do anything on the last pass (6) */ +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL && pass < 6) +#else + if (pass < 6) +#endif + { + /* each pixel depth is handled separately */ + switch (row_info->pixel_depth) + { + case 1: + { + png_bytep sp; + png_bytep dp; + int shift; + int d; + int value; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + dp = row; + d = 0; + shift = 7; + for (i = png_pass_start[pass]; i < row_width; + i += png_pass_inc[pass]) + { + sp = row + (png_size_t)(i >> 3); + value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01; + d |= (value << shift); + + if (shift == 0) + { + shift = 7; + *dp++ = (png_byte)d; + d = 0; + } + else + shift--; + + } + if (shift != 7) + *dp = (png_byte)d; + break; + } + case 2: + { + png_bytep sp; + png_bytep dp; + int shift; + int d; + int value; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + dp = row; + shift = 6; + d = 0; + for (i = png_pass_start[pass]; i < row_width; + i += png_pass_inc[pass]) + { + sp = row + (png_size_t)(i >> 2); + value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03; + d |= (value << shift); + + if (shift == 0) + { + shift = 6; + *dp++ = (png_byte)d; + d = 0; + } + else + shift -= 2; + } + if (shift != 6) + *dp = (png_byte)d; + break; + } + case 4: + { + png_bytep sp; + png_bytep dp; + int shift; + int d; + int value; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + dp = row; + shift = 4; + d = 0; + for (i = png_pass_start[pass]; i < row_width; + i += png_pass_inc[pass]) + { + sp = row + (png_size_t)(i >> 1); + value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f; + d |= (value << shift); + + if (shift == 0) + { + shift = 4; + *dp++ = (png_byte)d; + d = 0; + } + else + shift -= 4; + } + if (shift != 4) + *dp = (png_byte)d; + break; + } + default: + { + png_bytep sp; + png_bytep dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + png_size_t pixel_bytes; + + /* start at the beginning */ + dp = row; + /* find out how many bytes each pixel takes up */ + pixel_bytes = (row_info->pixel_depth >> 3); + /* loop through the row, only looking at the pixels that + matter */ + for (i = png_pass_start[pass]; i < row_width; + i += png_pass_inc[pass]) + { + /* find out where the original pixel is */ + sp = row + (png_size_t)i * pixel_bytes; + /* move the pixel */ + if (dp != sp) + png_memcpy(dp, sp, pixel_bytes); + /* next pixel */ + dp += pixel_bytes; + } + break; + } + } + /* set new row width */ + row_info->width = (row_info->width + + png_pass_inc[pass] - 1 - + png_pass_start[pass]) / + png_pass_inc[pass]; + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, + row_info->width); + } +} +#endif + +/* This filters the row, chooses which filter to use, if it has not already + * been specified by the application, and then writes the row out with the + * chosen filter. + */ +#define PNG_MAXSUM (((png_uint_32)(-1)) >> 1) +#define PNG_HISHIFT 10 +#define PNG_LOMASK ((png_uint_32)0xffffL) +#define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT)) +void /* PRIVATE */ +png_write_find_filter(png_structp png_ptr, png_row_infop row_info) +{ + png_bytep prev_row, best_row, row_buf; + png_uint_32 mins, bpp; + png_byte filter_to_do = png_ptr->do_filter; + png_uint_32 row_bytes = row_info->rowbytes; +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + int num_p_filters = (int)png_ptr->num_prev_filters; +#endif + + png_debug(1, "in png_write_find_filter\n"); + /* find out how many bytes offset each pixel is */ + bpp = (row_info->pixel_depth + 7) >> 3; + + prev_row = png_ptr->prev_row; + best_row = row_buf = png_ptr->row_buf; + mins = PNG_MAXSUM; + + /* The prediction method we use is to find which method provides the + * smallest value when summing the absolute values of the distances + * from zero, using anything >= 128 as negative numbers. This is known + * as the "minimum sum of absolute differences" heuristic. Other + * heuristics are the "weighted minimum sum of absolute differences" + * (experimental and can in theory improve compression), and the "zlib + * predictive" method (not implemented yet), which does test compressions + * of lines using different filter methods, and then chooses the + * (series of) filter(s) that give minimum compressed data size (VERY + * computationally expensive). + * + * GRR 980525: consider also + * (1) minimum sum of absolute differences from running average (i.e., + * keep running sum of non-absolute differences & count of bytes) + * [track dispersion, too? restart average if dispersion too large?] + * (1b) minimum sum of absolute differences from sliding average, probably + * with window size <= deflate window (usually 32K) + * (2) minimum sum of squared differences from zero or running average + * (i.e., ~ root-mean-square approach) + */ + + + /* We don't need to test the 'no filter' case if this is the only filter + * that has been chosen, as it doesn't actually do anything to the data. + */ + if ((filter_to_do & PNG_FILTER_NONE) && + filter_to_do != PNG_FILTER_NONE) + { + png_bytep rp; + png_uint_32 sum = 0; + png_uint_32 i; + int v; + + for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) + { + v = *rp; + sum += (v < 128) ? v : 256 - v; + } + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) + { + png_uint_32 sumhi, sumlo; + int j; + sumlo = sum & PNG_LOMASK; + sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */ + + /* Reduce the sum if we match any of the previous rows */ + for (j = 0; j < num_p_filters; j++) + { + if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) + { + sumlo = (sumlo * png_ptr->filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + sumhi = (sumhi * png_ptr->filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + } + } + + /* Factor in the cost of this filter (this is here for completeness, + * but it makes no sense to have a "cost" for the NONE filter, as + * it has the minimum possible computational cost - none). + */ + sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> + PNG_COST_SHIFT; + sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> + PNG_COST_SHIFT; + + if (sumhi > PNG_HIMASK) + sum = PNG_MAXSUM; + else + sum = (sumhi << PNG_HISHIFT) + sumlo; + } +#endif + mins = sum; + } + + /* sub filter */ + if (filter_to_do == PNG_FILTER_SUB) + /* it's the only filter so no testing is needed */ + { + png_bytep rp, lp, dp; + png_uint_32 i; + for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; + i++, rp++, dp++) + { + *dp = *rp; + } + for (lp = row_buf + 1; i < row_bytes; + i++, rp++, lp++, dp++) + { + *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); + } + best_row = png_ptr->sub_row; + } + + else if (filter_to_do & PNG_FILTER_SUB) + { + png_bytep rp, dp, lp; + png_uint_32 sum = 0, lmins = mins; + png_uint_32 i; + int v; + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + /* We temporarily increase the "minimum sum" by the factor we + * would reduce the sum of this filter, so that we can do the + * early exit comparison without scaling the sum each time. + */ + if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) + { + int j; + png_uint_32 lmhi, lmlo; + lmlo = lmins & PNG_LOMASK; + lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; + + for (j = 0; j < num_p_filters; j++) + { + if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) + { + lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + } + } + + lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> + PNG_COST_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> + PNG_COST_SHIFT; + + if (lmhi > PNG_HIMASK) + lmins = PNG_MAXSUM; + else + lmins = (lmhi << PNG_HISHIFT) + lmlo; + } +#endif + + for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; + i++, rp++, dp++) + { + v = *dp = *rp; + + sum += (v < 128) ? v : 256 - v; + } + for (lp = row_buf + 1; i < row_bytes; + i++, rp++, lp++, dp++) + { + v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); + + sum += (v < 128) ? v : 256 - v; + + if (sum > lmins) /* We are already worse, don't continue. */ + break; + } + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) + { + int j; + png_uint_32 sumhi, sumlo; + sumlo = sum & PNG_LOMASK; + sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; + + for (j = 0; j < num_p_filters; j++) + { + if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) + { + sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + } + } + + sumlo = (sumlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> + PNG_COST_SHIFT; + sumhi = (sumhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> + PNG_COST_SHIFT; + + if (sumhi > PNG_HIMASK) + sum = PNG_MAXSUM; + else + sum = (sumhi << PNG_HISHIFT) + sumlo; + } +#endif + + if (sum < mins) + { + mins = sum; + best_row = png_ptr->sub_row; + } + } + + /* up filter */ + if (filter_to_do == PNG_FILTER_UP) + { + png_bytep rp, dp, pp; + png_uint_32 i; + + for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, + pp = prev_row + 1; i < row_bytes; + i++, rp++, pp++, dp++) + { + *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); + } + best_row = png_ptr->up_row; + } + + else if (filter_to_do & PNG_FILTER_UP) + { + png_bytep rp, dp, pp; + png_uint_32 sum = 0, lmins = mins; + png_uint_32 i; + int v; + + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) + { + int j; + png_uint_32 lmhi, lmlo; + lmlo = lmins & PNG_LOMASK; + lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; + + for (j = 0; j < num_p_filters; j++) + { + if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) + { + lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + } + } + + lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> + PNG_COST_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> + PNG_COST_SHIFT; + + if (lmhi > PNG_HIMASK) + lmins = PNG_MAXSUM; + else + lmins = (lmhi << PNG_HISHIFT) + lmlo; + } +#endif + + for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, + pp = prev_row + 1; i < row_bytes; i++) + { + v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); + + sum += (v < 128) ? v : 256 - v; + + if (sum > lmins) /* We are already worse, don't continue. */ + break; + } + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) + { + int j; + png_uint_32 sumhi, sumlo; + sumlo = sum & PNG_LOMASK; + sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; + + for (j = 0; j < num_p_filters; j++) + { + if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) + { + sumlo = (sumlo * png_ptr->filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + sumhi = (sumhi * png_ptr->filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + } + } + + sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> + PNG_COST_SHIFT; + sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> + PNG_COST_SHIFT; + + if (sumhi > PNG_HIMASK) + sum = PNG_MAXSUM; + else + sum = (sumhi << PNG_HISHIFT) + sumlo; + } +#endif + + if (sum < mins) + { + mins = sum; + best_row = png_ptr->up_row; + } + } + + /* avg filter */ + if (filter_to_do == PNG_FILTER_AVG) + { + png_bytep rp, dp, pp, lp; + png_uint_32 i; + for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, + pp = prev_row + 1; i < bpp; i++) + { + *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); + } + for (lp = row_buf + 1; i < row_bytes; i++) + { + *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) + & 0xff); + } + best_row = png_ptr->avg_row; + } + + else if (filter_to_do & PNG_FILTER_AVG) + { + png_bytep rp, dp, pp, lp; + png_uint_32 sum = 0, lmins = mins; + png_uint_32 i; + int v; + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) + { + int j; + png_uint_32 lmhi, lmlo; + lmlo = lmins & PNG_LOMASK; + lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; + + for (j = 0; j < num_p_filters; j++) + { + if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG) + { + lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + } + } + + lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> + PNG_COST_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> + PNG_COST_SHIFT; + + if (lmhi > PNG_HIMASK) + lmins = PNG_MAXSUM; + else + lmins = (lmhi << PNG_HISHIFT) + lmlo; + } +#endif + + for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, + pp = prev_row + 1; i < bpp; i++) + { + v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); + + sum += (v < 128) ? v : 256 - v; + } + for (lp = row_buf + 1; i < row_bytes; i++) + { + v = *dp++ = + (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff); + + sum += (v < 128) ? v : 256 - v; + + if (sum > lmins) /* We are already worse, don't continue. */ + break; + } + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) + { + int j; + png_uint_32 sumhi, sumlo; + sumlo = sum & PNG_LOMASK; + sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; + + for (j = 0; j < num_p_filters; j++) + { + if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) + { + sumlo = (sumlo * png_ptr->filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + sumhi = (sumhi * png_ptr->filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + } + } + + sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> + PNG_COST_SHIFT; + sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> + PNG_COST_SHIFT; + + if (sumhi > PNG_HIMASK) + sum = PNG_MAXSUM; + else + sum = (sumhi << PNG_HISHIFT) + sumlo; + } +#endif + + if (sum < mins) + { + mins = sum; + best_row = png_ptr->avg_row; + } + } + + /* Paeth filter */ + if (filter_to_do == PNG_FILTER_PAETH) + { + png_bytep rp, dp, pp, cp, lp; + png_uint_32 i; + for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, + pp = prev_row + 1; i < bpp; i++) + { + *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); + } + + for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++) + { + int a, b, c, pa, pb, pc, p; + + b = *pp++; + c = *cp++; + a = *lp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; + + *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); + } + best_row = png_ptr->paeth_row; + } + + else if (filter_to_do & PNG_FILTER_PAETH) + { + png_bytep rp, dp, pp, cp, lp; + png_uint_32 sum = 0, lmins = mins; + png_uint_32 i; + int v; + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) + { + int j; + png_uint_32 lmhi, lmlo; + lmlo = lmins & PNG_LOMASK; + lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; + + for (j = 0; j < num_p_filters; j++) + { + if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) + { + lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + } + } + + lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> + PNG_COST_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> + PNG_COST_SHIFT; + + if (lmhi > PNG_HIMASK) + lmins = PNG_MAXSUM; + else + lmins = (lmhi << PNG_HISHIFT) + lmlo; + } +#endif + + for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, + pp = prev_row + 1; i < bpp; i++) + { + v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); + + sum += (v < 128) ? v : 256 - v; + } + + for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++) + { + int a, b, c, pa, pb, pc, p; + + b = *pp++; + c = *cp++; + a = *lp++; + +#ifndef PNG_SLOW_PAETH + p = b - c; + pc = a - c; +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; +#else /* PNG_SLOW_PAETH */ + p = a + b - c; + pa = abs(p - a); + pb = abs(p - b); + pc = abs(p - c); + if (pa <= pb && pa <= pc) + p = a; + else if (pb <= pc) + p = b; + else + p = c; +#endif /* PNG_SLOW_PAETH */ + + v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); + + sum += (v < 128) ? v : 256 - v; + + if (sum > lmins) /* We are already worse, don't continue. */ + break; + } + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) + { + int j; + png_uint_32 sumhi, sumlo; + sumlo = sum & PNG_LOMASK; + sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; + + for (j = 0; j < num_p_filters; j++) + { + if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) + { + sumlo = (sumlo * png_ptr->filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + sumhi = (sumhi * png_ptr->filter_weights[j]) >> + PNG_WEIGHT_SHIFT; + } + } + + sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> + PNG_COST_SHIFT; + sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> + PNG_COST_SHIFT; + + if (sumhi > PNG_HIMASK) + sum = PNG_MAXSUM; + else + sum = (sumhi << PNG_HISHIFT) + sumlo; + } +#endif + + if (sum < mins) + { + best_row = png_ptr->paeth_row; + } + } + + /* Do the actual writing of the filtered row data from the chosen filter. */ + + png_write_filtered_row(png_ptr, best_row); + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + /* Save the type of filter we picked this time for future calculations */ + if (png_ptr->num_prev_filters > 0) + { + int j; + for (j = 1; j < num_p_filters; j++) + { + png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1]; + } + png_ptr->prev_filters[j] = best_row[0]; + } +#endif +} + + +/* Do the actual writing of a previously filtered row. */ +void /* PRIVATE */ +png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) +{ + png_debug(1, "in png_write_filtered_row\n"); + png_debug1(2, "filter = %d\n", filtered_row[0]); + /* set up the zlib input buffer */ + + png_ptr->zstream.next_in = filtered_row; + png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1; + /* repeat until we have compressed all the data */ + do + { + int ret; /* return of zlib */ + + /* compress the data */ + ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); + /* check for compression errors */ + if (ret != Z_OK) + { + if (png_ptr->zstream.msg != NULL) + png_error(png_ptr, png_ptr->zstream.msg); + else + png_error(png_ptr, "zlib error"); + } + + /* see if it is time to write another IDAT */ + if (!(png_ptr->zstream.avail_out)) + { + /* write the IDAT and reset the zlib output buffer */ + png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + } + /* repeat until all data has been compressed */ + } while (png_ptr->zstream.avail_in); + + /* swap the current and previous rows */ + if (png_ptr->prev_row != NULL) + { + png_bytep tptr; + + tptr = png_ptr->prev_row; + png_ptr->prev_row = png_ptr->row_buf; + png_ptr->row_buf = tptr; + } + + /* finish row - updates counters and flushes zlib if last row */ + png_write_finish_row(png_ptr); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) + png_ptr->flush_rows++; + + if (png_ptr->flush_dist > 0 && + png_ptr->flush_rows >= png_ptr->flush_dist) + { + png_write_flush(png_ptr); + } +#endif +} +#endif /* PNG_WRITE_SUPPORTED */ diff --git a/src/dep/src/irrlicht/libpng/projects/beos/x86-shared.txt b/src/dep/src/irrlicht/libpng/projects/beos/x86-shared.txt index ea62d61..0cd4d9d 100644 --- a/src/dep/src/irrlicht/libpng/projects/beos/x86-shared.txt +++ b/src/dep/src/irrlicht/libpng/projects/beos/x86-shared.txt @@ -1,22 +1,22 @@ -This project builds a shared library version of libpng on x86 BeOS. - -It defines PNG_USE_PNGGCCRD, which activates the assembly code in -pnggccrd.c; this hasn't been extensively tested on BeOS. - -To install: - -1) build - - Note: As of version 1.0.10, you'll get a fair number of warnings when - you compile pnggccrd.c. As far as I know, these are harmless, - but it would be better if someone fixed them. - -2) copy and png.h, pngconf.h somewhere; /boot/home/config/include (which - you'll have to make) is a good choice - -3) copy libpng.so to /boot/home/config/lib - -4) build your libpng.so applications (remember to include libz.a as - well when you link) - -- Chris Herborth, March 27, 2001 +This project builds a shared library version of libpng on x86 BeOS. + +It defines PNG_USE_PNGGCCRD, which activates the assembly code in +pnggccrd.c; this hasn't been extensively tested on BeOS. + +To install: + +1) build + + Note: As of version 1.0.10, you'll get a fair number of warnings when + you compile pnggccrd.c. As far as I know, these are harmless, + but it would be better if someone fixed them. + +2) copy and png.h, pngconf.h somewhere; /boot/home/config/include (which + you'll have to make) is a good choice + +3) copy libpng.so to /boot/home/config/lib + +4) build your libpng.so applications (remember to include libz.a as + well when you link) + +- Chris Herborth, March 27, 2001 diff --git a/src/dep/src/irrlicht/libpng/projects/beos/x86-static.txt b/src/dep/src/irrlicht/libpng/projects/beos/x86-static.txt index 6f9ce68..bb80aaa 100644 --- a/src/dep/src/irrlicht/libpng/projects/beos/x86-static.txt +++ b/src/dep/src/irrlicht/libpng/projects/beos/x86-static.txt @@ -1,22 +1,22 @@ -This project builds a static library version of libpng on x86 BeOS. - -It defines PNG_USE_PNGGCCRD, which activates the assembly code in -pnggccrd.c; this hasn't been extensively tested on BeOS. - -To install: - -1) build - - Note: As of version 1.0.10, you'll get a fair number of warnings when - you compile pnggccrd.c. As far as I know, these are harmless, - but it would be better if someone fixed them. - -2) copy and png.h, pngconf.h somewhere; /boot/home/config/include (which - you'll have to make) is a good choice - -3) copy libpng.a to /boot/home/config/lib - -4) build your libpng.a applications (remember to include libz.a as - well when you link) - -- Chris Herborth, March 27, 2001 +This project builds a static library version of libpng on x86 BeOS. + +It defines PNG_USE_PNGGCCRD, which activates the assembly code in +pnggccrd.c; this hasn't been extensively tested on BeOS. + +To install: + +1) build + + Note: As of version 1.0.10, you'll get a fair number of warnings when + you compile pnggccrd.c. As far as I know, these are harmless, + but it would be better if someone fixed them. + +2) copy and png.h, pngconf.h somewhere; /boot/home/config/include (which + you'll have to make) is a good choice + +3) copy libpng.a to /boot/home/config/lib + +4) build your libpng.a applications (remember to include libz.a as + well when you link) + +- Chris Herborth, March 27, 2001 diff --git a/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.bpf b/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.bpf index ee6d929..2af81e7 100644 --- a/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.bpf +++ b/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.bpf @@ -1,22 +1,22 @@ -USEUNIT("libpng.cpp"); -USEUNIT("..\..\png.c"); -USEUNIT("..\..\pngerror.c"); -USEUNIT("..\..\pngget.c"); -USEUNIT("..\..\pngmem.c"); -USEUNIT("..\..\pngpread.c"); -USEUNIT("..\..\pngread.c"); -USEUNIT("..\..\pngrio.c"); -USEUNIT("..\..\pngrtran.c"); -USEUNIT("..\..\pngrutil.c"); -USEUNIT("..\..\pngset.c"); -USEUNIT("..\..\pngtrans.c"); -USEUNIT("..\..\pngwio.c"); -USEUNIT("..\..\pngwrite.c"); -USEUNIT("..\..\pngwtran.c"); -USEUNIT("..\..\pngwutil.c"); -USELIB("..\..\..\zlib\zlib.lib"); -//--------------------------------------------------------------------------- -This file is used by the project manager only and should be treated like the project file - - -DllEntryPoint +USEUNIT("libpng.cpp"); +USEUNIT("..\..\png.c"); +USEUNIT("..\..\pngerror.c"); +USEUNIT("..\..\pngget.c"); +USEUNIT("..\..\pngmem.c"); +USEUNIT("..\..\pngpread.c"); +USEUNIT("..\..\pngread.c"); +USEUNIT("..\..\pngrio.c"); +USEUNIT("..\..\pngrtran.c"); +USEUNIT("..\..\pngrutil.c"); +USEUNIT("..\..\pngset.c"); +USEUNIT("..\..\pngtrans.c"); +USEUNIT("..\..\pngwio.c"); +USEUNIT("..\..\pngwrite.c"); +USEUNIT("..\..\pngwtran.c"); +USEUNIT("..\..\pngwutil.c"); +USELIB("..\..\..\zlib\zlib.lib"); +//--------------------------------------------------------------------------- +This file is used by the project manager only and should be treated like the project file + + +DllEntryPoint diff --git a/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.bpg b/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.bpg index c6c6a4e..80c1977 100644 --- a/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.bpg +++ b/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.bpg @@ -1,25 +1,25 @@ -#------------------------------------------------------------------------------ -VERSION = BWS.01 -#------------------------------------------------------------------------------ -!ifndef ROOT -ROOT = $(MAKEDIR)\.. -!endif -#------------------------------------------------------------------------------ -MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$** -DCC = $(ROOT)\bin\dcc32.exe $** -BRCC = $(ROOT)\bin\brcc32.exe $** -#------------------------------------------------------------------------------ -PROJECTS = libpngstat.lib libpng.dll -#------------------------------------------------------------------------------ -default: $(PROJECTS) -#------------------------------------------------------------------------------ - -libpngstat.lib: libpngstat.bpr - $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $** - $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak - -libpng.dll: libpng.bpr - $(ROOT)\bin\bpr2mak $** - $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak - - +#------------------------------------------------------------------------------ +VERSION = BWS.01 +#------------------------------------------------------------------------------ +!ifndef ROOT +ROOT = $(MAKEDIR)\.. +!endif +#------------------------------------------------------------------------------ +MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$** +DCC = $(ROOT)\bin\dcc32.exe $** +BRCC = $(ROOT)\bin\brcc32.exe $** +#------------------------------------------------------------------------------ +PROJECTS = libpngstat.lib libpng.dll +#------------------------------------------------------------------------------ +default: $(PROJECTS) +#------------------------------------------------------------------------------ + +libpngstat.lib: libpngstat.bpr + $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $** + $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak + +libpng.dll: libpng.bpr + $(ROOT)\bin\bpr2mak $** + $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak + + diff --git a/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.bpr b/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.bpr index 7e09dda..b9fdbe4 100644 --- a/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.bpr +++ b/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.bpr @@ -1,157 +1,157 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=1 -Locale=2057 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion= -Comments= - -[HistoryLists\hlIncludePath] -Count=18 -Item0=..\..;..\..\..\zlib;$(BCB)\include -Item1=..\..;P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include -Item2=..\..;..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include -Item3=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include -Item4=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression;$(BCB)\include -Item5=..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression;$(BCB)\include -Item6=..\Source\ThirdParty\PortableNetworkGraphics;P:\Development\Source\ThirdParty\ZLibCompression;$(BCB)\include -Item7=..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\include -Item8=$(BCB)\include -Item9=..\Source;..\Source\General\Templates;..\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl -Item10=P:\Development\Source\;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl -Item11=P:\Development\Source;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl -Item12=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl -Item13=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl -Item14=P:\Development\Source\General\Templates\;$(BCB)\include;$(BCB)\include\vcl -Item15=P:\Development\Source\General\Templates;$(BCB)\include;$(BCB)\include\vcl -Item16=P:\Development\Source;$(BCB)\include;$(BCB)\include\vcl -Item17=$(BCB)\include;$(BCB)\include\vcl - -[HistoryLists\hlLibraryPath] -Count=10 -Item0=..\..;$(BCB)\lib\obj;$(BCB)\lib -Item1=..\..;..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib -Item2=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib -Item3=..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib -Item4=$(BCB)\lib\obj;$(BCB)\lib -Item5=..\Source\SIMUtilities;..\Source;$(BCB)\lib\obj;$(BCB)\lib -Item6=P:\Development\Source\SIMUtilities\;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib -Item7=P:\Development\Source\SIMUtilities;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib -Item8=P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib -Item9=P:\Development\Source;$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=1 -Item0=$(BCB)\source\vcl - -[HistoryLists\hlConditionals] -Count=20 -Item0=ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF -Item1=_DEBUG;ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF -Item2=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_NO_MODULEDEF -Item3=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_NO_GLOBAL_ARRAYS -Item4=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED;PNG_DEBUG_FILE=stderr -Item5=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED -Item6=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED -Item7=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF -Item8=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5 -Item9=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG -Item10=PNG_BUILD_DLL;ZLIB_DLL -Item11=PNG_BUILD_DLL -Item12=PNG_DLL;PNG_BUILD_DLL;ZLIB_DLL -Item13=PNG_DLL;PNG_BUILD_DLL;PNG_NO_GLOBAL_ARRAYS;ZLIB_DLL -Item14=PNG_DLL;PNG_BUILD_DLL;PNG_NO_GLOBAL_ARRAYS -Item15=PNG_DLL;PNG_BUILD_DLL -Item16=PNG_DLL;PNG_BUILD_DLL;PNG_MODULEDEF -Item17=_HTML_FORM -Item18=_DEBUG;_HTML_FORM -Item19=_DEBUG - -[HistoryLists\hlIntOutputDir] -Count=2 -Item0=..\Obj -Item1=P:\Development\Obj - -[Debugging] -DebugSourceDirs= - -[Parameters] -RunParams= -HostApplication=P:\Development\Executables\LibPNGTestApp.exe -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 -LinkCGLIB=0 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=1 +Locale=2057 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= +Comments= + +[HistoryLists\hlIncludePath] +Count=18 +Item0=..\..;..\..\..\zlib;$(BCB)\include +Item1=..\..;P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include +Item2=..\..;..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include +Item3=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include +Item4=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression;$(BCB)\include +Item5=..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression;$(BCB)\include +Item6=..\Source\ThirdParty\PortableNetworkGraphics;P:\Development\Source\ThirdParty\ZLibCompression;$(BCB)\include +Item7=..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\include +Item8=$(BCB)\include +Item9=..\Source;..\Source\General\Templates;..\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl +Item10=P:\Development\Source\;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl +Item11=P:\Development\Source;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl +Item12=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl +Item13=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl +Item14=P:\Development\Source\General\Templates\;$(BCB)\include;$(BCB)\include\vcl +Item15=P:\Development\Source\General\Templates;$(BCB)\include;$(BCB)\include\vcl +Item16=P:\Development\Source;$(BCB)\include;$(BCB)\include\vcl +Item17=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=10 +Item0=..\..;$(BCB)\lib\obj;$(BCB)\lib +Item1=..\..;..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib +Item2=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib +Item3=..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib +Item4=$(BCB)\lib\obj;$(BCB)\lib +Item5=..\Source\SIMUtilities;..\Source;$(BCB)\lib\obj;$(BCB)\lib +Item6=P:\Development\Source\SIMUtilities\;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib +Item7=P:\Development\Source\SIMUtilities;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib +Item8=P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib +Item9=P:\Development\Source;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=20 +Item0=ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF +Item1=_DEBUG;ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF +Item2=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_NO_MODULEDEF +Item3=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_NO_GLOBAL_ARRAYS +Item4=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED;PNG_DEBUG_FILE=stderr +Item5=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED +Item6=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED +Item7=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF +Item8=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5 +Item9=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG +Item10=PNG_BUILD_DLL;ZLIB_DLL +Item11=PNG_BUILD_DLL +Item12=PNG_DLL;PNG_BUILD_DLL;ZLIB_DLL +Item13=PNG_DLL;PNG_BUILD_DLL;PNG_NO_GLOBAL_ARRAYS;ZLIB_DLL +Item14=PNG_DLL;PNG_BUILD_DLL;PNG_NO_GLOBAL_ARRAYS +Item15=PNG_DLL;PNG_BUILD_DLL +Item16=PNG_DLL;PNG_BUILD_DLL;PNG_MODULEDEF +Item17=_HTML_FORM +Item18=_DEBUG;_HTML_FORM +Item19=_DEBUG + +[HistoryLists\hlIntOutputDir] +Count=2 +Item0=..\Obj +Item1=P:\Development\Obj + +[Debugging] +DebugSourceDirs= + +[Parameters] +RunParams= +HostApplication=P:\Development\Executables\LibPNGTestApp.exe +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + \ No newline at end of file diff --git a/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.cpp b/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.cpp index 97865f5..4e2f274 100644 --- a/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.cpp +++ b/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.cpp @@ -1,29 +1,29 @@ -//--------------------------------------------------------------------------- -#include -//--------------------------------------------------------------------------- -// Important note about DLL memory management when your DLL uses the -// static version of the RunTime Library: -// -// If your DLL exports any functions that pass String objects (or structs/ -// classes containing nested Strings) as parameter or function results, -// you will need to add the library MEMMGR.LIB to both the DLL project and -// any other projects that use the DLL. You will also need to use MEMMGR.LIB -// if any other projects which use the DLL will be performing new or delete -// operations on any non-TObject-derived classes which are exported from the -// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling -// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases, -// the file BORLNDMM.DLL should be deployed along with your DLL. -// -// To avoid using BORLNDMM.DLL, pass string information using "char *" or -// ShortString parameters. -// -// If your DLL uses the dynamic version of the RTL, you do not need to -// explicitly add MEMMGR.LIB as this will be done implicitly for you -//--------------------------------------------------------------------------- - -int WINAPI DllEntryPoint(HINSTANCE, unsigned long, void*) -{ - return 1; -} -//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- +#include +//--------------------------------------------------------------------------- +// Important note about DLL memory management when your DLL uses the +// static version of the RunTime Library: +// +// If your DLL exports any functions that pass String objects (or structs/ +// classes containing nested Strings) as parameter or function results, +// you will need to add the library MEMMGR.LIB to both the DLL project and +// any other projects that use the DLL. You will also need to use MEMMGR.LIB +// if any other projects which use the DLL will be performing new or delete +// operations on any non-TObject-derived classes which are exported from the +// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling +// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases, +// the file BORLNDMM.DLL should be deployed along with your DLL. +// +// To avoid using BORLNDMM.DLL, pass string information using "char *" or +// ShortString parameters. +// +// If your DLL uses the dynamic version of the RTL, you do not need to +// explicitly add MEMMGR.LIB as this will be done implicitly for you +//--------------------------------------------------------------------------- + +int WINAPI DllEntryPoint(HINSTANCE, unsigned long, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- \ No newline at end of file diff --git a/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.readme.txt b/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.readme.txt index 704c121..c99c1e9 100644 --- a/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.readme.txt +++ b/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpng.readme.txt @@ -1,25 +1,25 @@ -Project files to build libpng using Borland C++ Builder v5.0 - -In order to build and use libpng, please follow these steps: - - 1). Install zlib in a directory at the same level with libpng. - - 2). In a console window, go to the zlib directory and type: - make -f win32\Makefile.bor - After performing this step, you should have a file named - zlib.lib in the zlib directory. - - 3). Add the following conditional define to your project: - PNG_USE_DLL - - 4). Add libpng.lib or libpngstat.lib to the project. - Build the project. - - 5). If the build fails, add the paths to png.h and zlib.h to - your include path, and restart the build. - -By default, the libpng project uses zlib as a static library. If -you wish to use zlib as a DLL, please read the important notes from -the zlib DLL FAQ, found inside the zlib distribution. - -See the libpng documentation for instructions on how to use the code. +Project files to build libpng using Borland C++ Builder v5.0 + +In order to build and use libpng, please follow these steps: + + 1). Install zlib in a directory at the same level with libpng. + + 2). In a console window, go to the zlib directory and type: + make -f win32\Makefile.bor + After performing this step, you should have a file named + zlib.lib in the zlib directory. + + 3). Add the following conditional define to your project: + PNG_USE_DLL + + 4). Add libpng.lib or libpngstat.lib to the project. + Build the project. + + 5). If the build fails, add the paths to png.h and zlib.h to + your include path, and restart the build. + +By default, the libpng project uses zlib as a static library. If +you wish to use zlib as a DLL, please read the important notes from +the zlib DLL FAQ, found inside the zlib distribution. + +See the libpng documentation for instructions on how to use the code. diff --git a/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpngstat.bpf b/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpngstat.bpf index f736b62..fbc5c40 100644 --- a/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpngstat.bpf +++ b/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpngstat.bpf @@ -1,22 +1,22 @@ -USEUNIT("..\..\png.c"); -USEUNIT("..\..\pngerror.c"); -USEUNIT("..\..\pngget.c"); -USEUNIT("..\..\pngmem.c"); -USEUNIT("..\..\pngpread.c"); -USEUNIT("..\..\pngread.c"); -USEUNIT("..\..\pngrio.c"); -USEUNIT("..\..\pngrtran.c"); -USEUNIT("..\..\pngrutil.c"); -USEUNIT("..\..\pngset.c"); -USEUNIT("..\..\pngtrans.c"); -USEUNIT("..\..\pngwio.c"); -USEUNIT("..\..\pngwrite.c"); -USEUNIT("..\..\pngwtran.c"); -USEUNIT("..\..\pngwutil.c"); -USELIB("..\..\..\zlib\zlib.lib"); -//--------------------------------------------------------------------------- -#define Library - -// To add a file to the library use the Project menu 'Add to Project'. - +USEUNIT("..\..\png.c"); +USEUNIT("..\..\pngerror.c"); +USEUNIT("..\..\pngget.c"); +USEUNIT("..\..\pngmem.c"); +USEUNIT("..\..\pngpread.c"); +USEUNIT("..\..\pngread.c"); +USEUNIT("..\..\pngrio.c"); +USEUNIT("..\..\pngrtran.c"); +USEUNIT("..\..\pngrutil.c"); +USEUNIT("..\..\pngset.c"); +USEUNIT("..\..\pngtrans.c"); +USEUNIT("..\..\pngwio.c"); +USEUNIT("..\..\pngwrite.c"); +USEUNIT("..\..\pngwtran.c"); +USEUNIT("..\..\pngwutil.c"); +USELIB("..\..\..\zlib\zlib.lib"); +//--------------------------------------------------------------------------- +#define Library + +// To add a file to the library use the Project menu 'Add to Project'. + \ No newline at end of file diff --git a/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpngstat.bpr b/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpngstat.bpr index 68abb8d..9a51ecc 100644 --- a/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpngstat.bpr +++ b/src/dep/src/irrlicht/libpng/projects/cbuilder5/libpngstat.bpr @@ -1,109 +1,109 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=2057 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[HistoryLists\hlIncludePath] -Count=2 -Item0=..\..;P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include -Item1=..\..;$(BCB)\include;$(BCB)\include\vcl - -[HistoryLists\hlLibraryPath] -Count=1 -Item0=..\..;$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=1 -Item0=$(BCB)\source\vcl - -[HistoryLists\hlConditionals] -Count=1 -Item0=_DEBUG - -[HistoryLists\hlTlibPageSize] -Count=1 -Item0=0x0010 - -[Debugging] -DebugSourceDirs=$(BCB)\source\vcl - -[Parameters] -RunParams= -HostApplication= -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 -LinkCGLIB=0 - -[Language] -ActiveLang= -ProjectLang= -RootDir= - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=2057 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=2 +Item0=..\..;P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include +Item1=..\..;$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=..\..;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=1 +Item0=_DEBUG + +[HistoryLists\hlTlibPageSize] +Count=1 +Item0=0x0010 + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + \ No newline at end of file diff --git a/src/dep/src/irrlicht/libpng/projects/cbuilder5/zlib.readme.txt b/src/dep/src/irrlicht/libpng/projects/cbuilder5/zlib.readme.txt index 9fb4557..cb6a7a8 100644 --- a/src/dep/src/irrlicht/libpng/projects/cbuilder5/zlib.readme.txt +++ b/src/dep/src/irrlicht/libpng/projects/cbuilder5/zlib.readme.txt @@ -1,14 +1,14 @@ -The project that builds libpng under Borland C++ Builder does not -explicitly build zlib. By taking this decision, there is no need -to update the libpng project each time when there is a change in -the list of zlib source files. After all, this list is private to -zlib, and applications (such as libpng) should not assume anything -about it. - -If you wish to contribute a project that builds zlib under Borland -C++ Builder, please submit it to the zlib developers, not to the -libpng developers. - -By default, the libpng project uses zlib as a static library. If -you wish to use zlib as a DLL, please read the important notes from -the zlib DLL FAQ, found inside the zlib distribution. +The project that builds libpng under Borland C++ Builder does not +explicitly build zlib. By taking this decision, there is no need +to update the libpng project each time when there is a change in +the list of zlib source files. After all, this list is private to +zlib, and applications (such as libpng) should not assume anything +about it. + +If you wish to contribute a project that builds zlib under Borland +C++ Builder, please submit it to the zlib developers, not to the +libpng developers. + +By default, the libpng project uses zlib as a static library. If +you wish to use zlib as a DLL, please read the important notes from +the zlib DLL FAQ, found inside the zlib distribution. diff --git a/src/dep/src/irrlicht/libpng/projects/netware.txt b/src/dep/src/irrlicht/libpng/projects/netware.txt index 4ba5ba3..178361d 100644 --- a/src/dep/src/irrlicht/libpng/projects/netware.txt +++ b/src/dep/src/irrlicht/libpng/projects/netware.txt @@ -1,6 +1,6 @@ -A set of project files is available for Netware. Get -libpng-1.2.5-project-netware.zip from a libpng distribution -site such as http://libpng.sourceforge.net - -Put the zip file in this directory (projects) and then run -"unzip -a libpng-1.2.5-project-netware.zip" +A set of project files is available for Netware. Get +libpng-1.2.5-project-netware.zip from a libpng distribution +site such as http://libpng.sourceforge.net + +Put the zip file in this directory (projects) and then run +"unzip -a libpng-1.2.5-project-netware.zip" diff --git a/src/dep/src/irrlicht/libpng/projects/visualc6/README.txt b/src/dep/src/irrlicht/libpng/projects/visualc6/README.txt index 863d39b..d34980d 100644 --- a/src/dep/src/irrlicht/libpng/projects/visualc6/README.txt +++ b/src/dep/src/irrlicht/libpng/projects/visualc6/README.txt @@ -1,57 +1,57 @@ -Microsoft Developer Studio Project File, Format Version 6.00 for libpng. - -Copyright (C) 2000-2004 Simon-Pierre Cadieux. -Copyright (C) 2004 Cosmin Truta. -For conditions of distribution and use, see copyright notice in png.h - - -Assumptions: -* The libpng source files are in ..\.. -* The zlib source files are in ..\..\..\zlib -* The zlib project files are in ..\..\..\zlib\projects\visualc6 - - -To use: - -1) On the main menu, select "File | Open Workspace". - Open "libpng.dsw". - -2) Select "Build | Set Active Configuration". - Choose the configuration you wish to build. - (Choose libpng or pngtest; zlib will be built automatically.) - -3) Select "Build | Clean". - -4) Select "Build | Build ... (F7)". Ignore warning messages about - not being able to find certain include files (e.g. alloc.h). - -5) If you built the sample program (pngtest), - select "Build | Execute ... (Ctrl+F5)". - - -This project builds the libpng binaries as follows: - -* Win32_DLL_Release\libpng13.dll DLL build -* Win32_DLL_Debug\libpng13d.dll DLL build (debug version) -* Win32_DLL_ASM_Release\libpng13.dll DLL build using ASM code -* Win32_DLL_ASM_Debug\libpng13d.dll DLL build using ASM (debug version) -* Win32_DLL_VB\libpng13vb.dll DLL build for Visual Basic, using stdcall -* Win32_LIB_Release\libpng.lib static build -* Win32_LIB_Debug\libpngd.lib static build (debug version) -* Win32_LIB_ASM_Release\libpng.lib static build using ASM code -* Win32_LIB_ASM_Debug\libpngd.lib static build using ASM (debug version) - - -Notes: - -If you change anything in the source files, or select different compiler -settings, please change the DLL name to something different than any of -the above names. Also, make sure that in your "pngusr.h" you define -PNG_USER_PRIVATEBUILD and PNG_USER_DLLFNAME_POSTFIX according to the -instructions provided in "pngconf.h". - -All DLLs built by this project use the Microsoft dynamic C runtime library -MSVCRT.DLL (MSVCRTD.DLL for debug versions). If you distribute any of the -above mentioned libraries you should also include this DLL in your package. -For a list of files that are redistributable in Visual C++ 6.0, see -Common\Redist\Redist.txt on Disc 1 of the Visual C++ 6.0 product CDs. +Microsoft Developer Studio Project File, Format Version 6.00 for libpng. + +Copyright (C) 2000-2004 Simon-Pierre Cadieux. +Copyright (C) 2004 Cosmin Truta. +For conditions of distribution and use, see copyright notice in png.h + + +Assumptions: +* The libpng source files are in ..\.. +* The zlib source files are in ..\..\..\zlib +* The zlib project files are in ..\..\..\zlib\projects\visualc6 + + +To use: + +1) On the main menu, select "File | Open Workspace". + Open "libpng.dsw". + +2) Select "Build | Set Active Configuration". + Choose the configuration you wish to build. + (Choose libpng or pngtest; zlib will be built automatically.) + +3) Select "Build | Clean". + +4) Select "Build | Build ... (F7)". Ignore warning messages about + not being able to find certain include files (e.g. alloc.h). + +5) If you built the sample program (pngtest), + select "Build | Execute ... (Ctrl+F5)". + + +This project builds the libpng binaries as follows: + +* Win32_DLL_Release\libpng13.dll DLL build +* Win32_DLL_Debug\libpng13d.dll DLL build (debug version) +* Win32_DLL_ASM_Release\libpng13.dll DLL build using ASM code +* Win32_DLL_ASM_Debug\libpng13d.dll DLL build using ASM (debug version) +* Win32_DLL_VB\libpng13vb.dll DLL build for Visual Basic, using stdcall +* Win32_LIB_Release\libpng.lib static build +* Win32_LIB_Debug\libpngd.lib static build (debug version) +* Win32_LIB_ASM_Release\libpng.lib static build using ASM code +* Win32_LIB_ASM_Debug\libpngd.lib static build using ASM (debug version) + + +Notes: + +If you change anything in the source files, or select different compiler +settings, please change the DLL name to something different than any of +the above names. Also, make sure that in your "pngusr.h" you define +PNG_USER_PRIVATEBUILD and PNG_USER_DLLFNAME_POSTFIX according to the +instructions provided in "pngconf.h". + +All DLLs built by this project use the Microsoft dynamic C runtime library +MSVCRT.DLL (MSVCRTD.DLL for debug versions). If you distribute any of the +above mentioned libraries you should also include this DLL in your package. +For a list of files that are redistributable in Visual C++ 6.0, see +Common\Redist\Redist.txt on Disc 1 of the Visual C++ 6.0 product CDs. diff --git a/src/dep/src/irrlicht/libpng/projects/visualc6/libpng.dsp b/src/dep/src/irrlicht/libpng/projects/visualc6/libpng.dsp index 223362a..1992c2b 100644 --- a/src/dep/src/irrlicht/libpng/projects/visualc6/libpng.dsp +++ b/src/dep/src/irrlicht/libpng/projects/visualc6/libpng.dsp @@ -1,507 +1,507 @@ -# Microsoft Developer Studio Project File - Name="libpng" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=libpng - Win32 DLL Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "libpng.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "libpng.mak" CFG="libpng - Win32 DLL Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "libpng - Win32 DLL Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 DLL ASM Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 DLL ASM Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 DLL VB" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 LIB Release" (based on "Win32 (x86) Static Library") -!MESSAGE "libpng - Win32 LIB Debug" (based on "Win32 (x86) Static Library") -!MESSAGE "libpng - Win32 LIB ASM Release" (based on "Win32 (x86) Static Library") -!MESSAGE "libpng - Win32 LIB ASM Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" - -!IF "$(CFG)" == "libpng - Win32 DLL Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpng___Win32_DLL_Release" -# PROP BASE Intermediate_Dir "libpng___Win32_DLL_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_DLL_Release" -# PROP Intermediate_Dir "Win32_DLL_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /machine:I386 -# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_Release\libpng13.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "libpng___Win32_DLL_Release" -# PROP BASE Intermediate_Dir "libpng___Win32_DLL_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_DLL_Debug" -# PROP Intermediate_Dir "Win32_DLL_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /GZ /c -# SUBTRACT CPP /YX /Yc /Yu -MTL=midl.exe -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 zlib1d.lib /nologo /dll /debug /machine:I386 /out:"Win32_DLL_Debug\libpng13d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpng___Win32_DLL_ASM_Release" -# PROP BASE Intermediate_Dir "libpng___Win32_DLL_ASM_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_DLL_ASM_Release" -# PROP Intermediate_Dir "Win32_DLL_ASM_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D "PNG_LIBPNG_SPECIALBUILD" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /d PNG_LIBPNG_SPECIALBUILD=""""Use MMX instructions"""" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /machine:I386 -# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_ASM_Release\libpng13.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "libpng___Win32_DLL_ASM_Debug" -# PROP BASE Intermediate_Dir "libpng___Win32_DLL_ASM_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_DLL_ASM_Debug" -# PROP Intermediate_Dir "Win32_DLL_ASM_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D "PNG_LIBPNG_SPECIALBUILD" /FD /GZ /c -# SUBTRACT CPP /YX /Yc /Yu -MTL=midl.exe -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1 /d PNG_LIBPNG_SPECIALBUILD=""""Use MMX instructions"""" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 zlib1d.lib /nologo /dll /debug /machine:I386 /out:"Win32_DLL_ASM_Debug\libpng13d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpng___Win32_DLL_VB" -# PROP BASE Intermediate_Dir "libpng___Win32_DLL_VB" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_DLL_VB" -# PROP Intermediate_Dir "Win32_DLL_VB" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D PNGAPI=__stdcall /D "PNG_NO_MODULEDEF" /D "PNG_LIBPNG_SPECIALBUILD" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /dPNG_LIBPNG_DLLFNAME_POSTFIX=""""VB"""" /dPNG_LIBPNG_SPECIALBUILD=""""__stdcall calling convention used for exported functions"""" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /machine:I386 -# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_VB\libpng13vb.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release" -# Begin Special Build Tool -OutDir=.\Win32_DLL_VB -TargetName=libpng13vb -SOURCE="$(InputPath)" -PostBuild_Cmds=echo Deleting $(targetname) import library and export file (Not required for VB projects) del $(outdir)\$(targetname).lib del $(outdir)\$(targetname).exp -# End Special Build Tool - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpng___Win32_LIB_Release" -# PROP BASE Intermediate_Dir "libpng___Win32_LIB_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_LIB_Release" -# PROP Intermediate_Dir "Win32_LIB_Release" -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "libpng___Win32_LIB_Debug" -# PROP BASE Intermediate_Dir "libpng___Win32_LIB_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_LIB_Debug" -# PROP Intermediate_Dir "Win32_LIB_Debug" -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /FD /GZ /c -# SUBTRACT CPP /YX /Yc /Yu -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"Win32_LIB_Debug\libpngd.lib" - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpng___Win32_LIB_ASM_Release" -# PROP BASE Intermediate_Dir "libpng___Win32_LIB_ASM_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_LIB_ASM_Release" -# PROP Intermediate_Dir "Win32_LIB_ASM_Release" -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /D "PNG_LIBPNG_SPECIALBUILD" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "libpng___Win32_LIB_ASM_Debug" -# PROP BASE Intermediate_Dir "libpng___Win32_LIB_ASM_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_LIB_ASM_Debug" -# PROP Intermediate_Dir "Win32_LIB_ASM_Debug" -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /D "PNG_LIBPNG_SPECIALBUILD" /FD /GZ /c -# SUBTRACT CPP /YX /Yc /Yu -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"Win32_LIB_ASM_Debug\libpngd.lib" - -!ENDIF - -# Begin Target - -# Name "libpng - Win32 DLL Release" -# Name "libpng - Win32 DLL Debug" -# Name "libpng - Win32 DLL ASM Release" -# Name "libpng - Win32 DLL ASM Debug" -# Name "libpng - Win32 DLL VB" -# Name "libpng - Win32 LIB Release" -# Name "libpng - Win32 LIB Debug" -# Name "libpng - Win32 LIB ASM Release" -# Name "libpng - Win32 LIB ASM Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=..\..\png.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngerror.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngget.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngmem.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngpread.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngread.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngrio.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngrtran.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngrutil.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngset.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngtrans.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngvcrd.c - -!IF "$(CFG)" == "libpng - Win32 DLL Release" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Debug" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\scripts\pngw32.def - -!IF "$(CFG)" == "libpng - Win32 DLL Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Release" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Debug" - -# PROP Exclude_From_Build 1 - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\pngwio.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngwrite.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngwtran.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngwutil.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=..\..\png.h -# End Source File -# Begin Source File - -SOURCE=..\..\pngconf.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# Begin Source File - -SOURCE=..\..\scripts\pngw32.rc - -!IF "$(CFG)" == "libpng - Win32 DLL Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Release" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Debug" - -# PROP Exclude_From_Build 1 - -!ENDIF - -# End Source File -# End Group -# Begin Source File - -SOURCE=.\README.txt -# End Source File -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="libpng" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=libpng - Win32 DLL Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "libpng.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "libpng.mak" CFG="libpng - Win32 DLL Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "libpng - Win32 DLL Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "libpng - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "libpng - Win32 DLL ASM Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "libpng - Win32 DLL ASM Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "libpng - Win32 DLL VB" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "libpng - Win32 LIB Release" (based on "Win32 (x86) Static Library") +!MESSAGE "libpng - Win32 LIB Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "libpng - Win32 LIB ASM Release" (based on "Win32 (x86) Static Library") +!MESSAGE "libpng - Win32 LIB ASM Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "libpng - Win32 DLL Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "libpng___Win32_DLL_Release" +# PROP BASE Intermediate_Dir "libpng___Win32_DLL_Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Win32_DLL_Release" +# PROP Intermediate_Dir "Win32_DLL_Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +CPP=cl.exe +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c +# SUBTRACT BASE CPP /YX /Yc /Yu +# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /c +# SUBTRACT CPP /YX /Yc /Yu +MTL=midl.exe +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /dll /machine:I386 +# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_Release\libpng13.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "libpng___Win32_DLL_Release" +# PROP BASE Intermediate_Dir "libpng___Win32_DLL_Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Win32_DLL_Debug" +# PROP Intermediate_Dir "Win32_DLL_Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +CPP=cl.exe +# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c +# SUBTRACT BASE CPP /YX /Yc /Yu +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /GZ /c +# SUBTRACT CPP /YX /Yc /Yu +MTL=midl.exe +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 zlib1d.lib /nologo /dll /debug /machine:I386 /out:"Win32_DLL_Debug\libpng13d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Debug" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "libpng___Win32_DLL_ASM_Release" +# PROP BASE Intermediate_Dir "libpng___Win32_DLL_ASM_Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Win32_DLL_ASM_Release" +# PROP Intermediate_Dir "Win32_DLL_ASM_Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +CPP=cl.exe +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c +# SUBTRACT BASE CPP /YX /Yc /Yu +# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D "PNG_LIBPNG_SPECIALBUILD" /FD /c +# SUBTRACT CPP /YX /Yc /Yu +MTL=midl.exe +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /d PNG_LIBPNG_SPECIALBUILD=""""Use MMX instructions"""" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /dll /machine:I386 +# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_ASM_Release\libpng13.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "libpng___Win32_DLL_ASM_Debug" +# PROP BASE Intermediate_Dir "libpng___Win32_DLL_ASM_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Win32_DLL_ASM_Debug" +# PROP Intermediate_Dir "Win32_DLL_ASM_Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +CPP=cl.exe +# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c +# SUBTRACT BASE CPP /YX /Yc /Yu +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D "PNG_LIBPNG_SPECIALBUILD" /FD /GZ /c +# SUBTRACT CPP /YX /Yc /Yu +MTL=midl.exe +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1 /d PNG_LIBPNG_SPECIALBUILD=""""Use MMX instructions"""" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 zlib1d.lib /nologo /dll /debug /machine:I386 /out:"Win32_DLL_ASM_Debug\libpng13d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "libpng___Win32_DLL_VB" +# PROP BASE Intermediate_Dir "libpng___Win32_DLL_VB" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Win32_DLL_VB" +# PROP Intermediate_Dir "Win32_DLL_VB" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +CPP=cl.exe +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c +# SUBTRACT BASE CPP /YX /Yc /Yu +# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D PNGAPI=__stdcall /D "PNG_NO_MODULEDEF" /D "PNG_LIBPNG_SPECIALBUILD" /FD /c +# SUBTRACT CPP /YX /Yc /Yu +MTL=midl.exe +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /dPNG_LIBPNG_DLLFNAME_POSTFIX=""""VB"""" /dPNG_LIBPNG_SPECIALBUILD=""""__stdcall calling convention used for exported functions"""" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /dll /machine:I386 +# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_VB\libpng13vb.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release" +# Begin Special Build Tool +OutDir=.\Win32_DLL_VB +TargetName=libpng13vb +SOURCE="$(InputPath)" +PostBuild_Cmds=echo Deleting $(targetname) import library and export file (Not required for VB projects) del $(outdir)\$(targetname).lib del $(outdir)\$(targetname).exp +# End Special Build Tool + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "libpng___Win32_LIB_Release" +# PROP BASE Intermediate_Dir "libpng___Win32_LIB_Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Win32_LIB_Release" +# PROP Intermediate_Dir "Win32_LIB_Release" +# PROP Target_Dir "" +CPP=cl.exe +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c +# SUBTRACT BASE CPP /YX /Yc /Yu +# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c +# SUBTRACT CPP /YX /Yc /Yu +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "libpng___Win32_LIB_Debug" +# PROP BASE Intermediate_Dir "libpng___Win32_LIB_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Win32_LIB_Debug" +# PROP Intermediate_Dir "Win32_LIB_Debug" +# PROP Target_Dir "" +CPP=cl.exe +# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c +# SUBTRACT BASE CPP /YX /Yc /Yu +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /FD /GZ /c +# SUBTRACT CPP /YX /Yc /Yu +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"Win32_LIB_Debug\libpngd.lib" + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "libpng___Win32_LIB_ASM_Release" +# PROP BASE Intermediate_Dir "libpng___Win32_LIB_ASM_Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Win32_LIB_ASM_Release" +# PROP Intermediate_Dir "Win32_LIB_ASM_Release" +# PROP Target_Dir "" +CPP=cl.exe +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c +# SUBTRACT BASE CPP /YX /Yc /Yu +# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /D "PNG_LIBPNG_SPECIALBUILD" /FD /c +# SUBTRACT CPP /YX /Yc /Yu +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "libpng___Win32_LIB_ASM_Debug" +# PROP BASE Intermediate_Dir "libpng___Win32_LIB_ASM_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Win32_LIB_ASM_Debug" +# PROP Intermediate_Dir "Win32_LIB_ASM_Debug" +# PROP Target_Dir "" +CPP=cl.exe +# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c +# SUBTRACT BASE CPP /YX /Yc /Yu +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /D "PNG_LIBPNG_SPECIALBUILD" /FD /GZ /c +# SUBTRACT CPP /YX /Yc /Yu +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"Win32_LIB_ASM_Debug\libpngd.lib" + +!ENDIF + +# Begin Target + +# Name "libpng - Win32 DLL Release" +# Name "libpng - Win32 DLL Debug" +# Name "libpng - Win32 DLL ASM Release" +# Name "libpng - Win32 DLL ASM Debug" +# Name "libpng - Win32 DLL VB" +# Name "libpng - Win32 LIB Release" +# Name "libpng - Win32 LIB Debug" +# Name "libpng - Win32 LIB ASM Release" +# Name "libpng - Win32 LIB ASM Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\..\png.c +# End Source File +# Begin Source File + +SOURCE=..\..\pngerror.c +# End Source File +# Begin Source File + +SOURCE=..\..\pngget.c +# End Source File +# Begin Source File + +SOURCE=..\..\pngmem.c +# End Source File +# Begin Source File + +SOURCE=..\..\pngpread.c +# End Source File +# Begin Source File + +SOURCE=..\..\pngread.c +# End Source File +# Begin Source File + +SOURCE=..\..\pngrio.c +# End Source File +# Begin Source File + +SOURCE=..\..\pngrtran.c +# End Source File +# Begin Source File + +SOURCE=..\..\pngrutil.c +# End Source File +# Begin Source File + +SOURCE=..\..\pngset.c +# End Source File +# Begin Source File + +SOURCE=..\..\pngtrans.c +# End Source File +# Begin Source File + +SOURCE=..\..\pngvcrd.c + +!IF "$(CFG)" == "libpng - Win32 DLL Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Release" + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Debug" + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=..\..\scripts\pngw32.def + +!IF "$(CFG)" == "libpng - Win32 DLL Release" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Debug" + +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=..\..\pngwio.c +# End Source File +# Begin Source File + +SOURCE=..\..\pngwrite.c +# End Source File +# Begin Source File + +SOURCE=..\..\pngwtran.c +# End Source File +# Begin Source File + +SOURCE=..\..\pngwutil.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\..\png.h +# End Source File +# Begin Source File + +SOURCE=..\..\pngconf.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=..\..\scripts\pngw32.rc + +!IF "$(CFG)" == "libpng - Win32 DLL Release" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Debug" + +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# End Group +# Begin Source File + +SOURCE=.\README.txt +# End Source File +# End Target +# End Project diff --git a/src/dep/src/irrlicht/libpng/projects/visualc6/libpng.dsw b/src/dep/src/irrlicht/libpng/projects/visualc6/libpng.dsw index 2a98646..4f3856f 100644 --- a/src/dep/src/irrlicht/libpng/projects/visualc6/libpng.dsw +++ b/src/dep/src/irrlicht/libpng/projects/visualc6/libpng.dsw @@ -1,59 +1,59 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "libpng"=".\libpng.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name zlib - End Project Dependency -}}} - -############################################################################### - -Project: "pngtest"=".\pngtest.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name libpng - End Project Dependency -}}} - -############################################################################### - -Project: "zlib"="..\..\..\zlib\projects\visualc6\zlib.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "libpng"=".\libpng.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name zlib + End Project Dependency +}}} + +############################################################################### + +Project: "pngtest"=".\pngtest.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name libpng + End Project Dependency +}}} + +############################################################################### + +Project: "zlib"="..\..\..\zlib\projects\visualc6\zlib.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/src/dep/src/irrlicht/libpng/projects/visualc6/pngtest.dsp b/src/dep/src/irrlicht/libpng/projects/visualc6/pngtest.dsp index 2e5845c..a1be73c 100644 --- a/src/dep/src/irrlicht/libpng/projects/visualc6/pngtest.dsp +++ b/src/dep/src/irrlicht/libpng/projects/visualc6/pngtest.dsp @@ -1,314 +1,314 @@ -# Microsoft Developer Studio Project File - Name="pngtest" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=pngtest - Win32 DLL Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pngtest.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pngtest.mak" CFG="pngtest - Win32 DLL Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pngtest - Win32 DLL Release" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 DLL Debug" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 DLL ASM Release" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 DLL ASM Debug" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 LIB Release" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 LIB Debug" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 LIB ASM Release" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 LIB ASM Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pngtest - Win32 DLL Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "pngtest___Win32_DLL_Release" -# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_DLL_Release" -# PROP Intermediate_Dir "Win32_DLL_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 -# ADD LINK32 Win32_DLL_Release\libpng13.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Release\zlib1.lib /nologo /subsystem:console /machine:I386 -# Begin Special Build Tool -OutDir=.\Win32_DLL_Release -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_Release; $(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 DLL Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "pngtest___Win32_DLL_Debug" -# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_DLL_Debug" -# PROP Intermediate_Dir "Win32_DLL_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 Win32_DLL_Debug\libpng13d.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Debug\zlib1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# Begin Special Build Tool -OutDir=.\Win32_DLL_Debug -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_Debug; $(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 DLL ASM Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "pngtest___Win32_DLL_ASM_Release" -# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_ASM_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_DLL_ASM_Release" -# PROP Intermediate_Dir "Win32_DLL_ASM_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 -# ADD LINK32 Win32_DLL_ASM_Release\libpng13.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release\zlib1.lib /nologo /subsystem:console /machine:I386 -# Begin Special Build Tool -OutDir=.\Win32_DLL_ASM_Release -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release; $(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 DLL ASM Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "pngtest___Win32_DLL_ASM_Debug" -# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_ASM_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_DLL_ASM_Debug" -# PROP Intermediate_Dir "Win32_DLL_ASM_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 Win32_DLL_ASM_Debug\libpng13d.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug\zlib1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# Begin Special Build Tool -OutDir=.\Win32_DLL_ASM_Debug -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug; $(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 LIB Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "pngtest___Win32_LIB_Release" -# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_LIB_Release" -# PROP Intermediate_Dir "Win32_LIB_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 -# ADD LINK32 Win32_LIB_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Release\zlib.lib /nologo /subsystem:console /machine:I386 -# Begin Special Build Tool -OutDir=.\Win32_LIB_Release -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 LIB Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "pngtest___Win32_LIB_Debug" -# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_LIB_Debug" -# PROP Intermediate_Dir "Win32_LIB_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 Win32_LIB_Debug\libpngd.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Debug\zlibd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# Begin Special Build Tool -OutDir=.\Win32_LIB_Debug -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 LIB ASM Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "pngtest___Win32_LIB_ASM_Release" -# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_ASM_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_LIB_ASM_Release" -# PROP Intermediate_Dir "Win32_LIB_ASM_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 -# ADD LINK32 Win32_LIB_ASM_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_ASM_Release\zlib.lib /nologo /subsystem:console /machine:I386 -# Begin Special Build Tool -OutDir=.\Win32_LIB_ASM_Release -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 LIB ASM Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "pngtest___Win32_LIB_ASM_Debug" -# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_ASM_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_LIB_ASM_Debug" -# PROP Intermediate_Dir "Win32_LIB_ASM_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 Win32_LIB_ASM_Debug\libpngd.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_ASM_Debug\zlibd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# Begin Special Build Tool -OutDir=.\Win32_LIB_ASM_Debug -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "pngtest - Win32 DLL Release" -# Name "pngtest - Win32 DLL Debug" -# Name "pngtest - Win32 DLL ASM Release" -# Name "pngtest - Win32 DLL ASM Debug" -# Name "pngtest - Win32 LIB Release" -# Name "pngtest - Win32 LIB Debug" -# Name "pngtest - Win32 LIB ASM Release" -# Name "pngtest - Win32 LIB ASM Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=..\..\pngtest.c -# End Source File -# End Group -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="pngtest" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=pngtest - Win32 DLL Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pngtest.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pngtest.mak" CFG="pngtest - Win32 DLL Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pngtest - Win32 DLL Release" (based on "Win32 (x86) Console Application") +!MESSAGE "pngtest - Win32 DLL Debug" (based on "Win32 (x86) Console Application") +!MESSAGE "pngtest - Win32 DLL ASM Release" (based on "Win32 (x86) Console Application") +!MESSAGE "pngtest - Win32 DLL ASM Debug" (based on "Win32 (x86) Console Application") +!MESSAGE "pngtest - Win32 LIB Release" (based on "Win32 (x86) Console Application") +!MESSAGE "pngtest - Win32 LIB Debug" (based on "Win32 (x86) Console Application") +!MESSAGE "pngtest - Win32 LIB ASM Release" (based on "Win32 (x86) Console Application") +!MESSAGE "pngtest - Win32 LIB ASM Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pngtest - Win32 DLL Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "pngtest___Win32_DLL_Release" +# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Win32_DLL_Release" +# PROP Intermediate_Dir "Win32_DLL_Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c +# SUBTRACT BASE CPP /YX +# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 +# ADD LINK32 Win32_DLL_Release\libpng13.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Release\zlib1.lib /nologo /subsystem:console /machine:I386 +# Begin Special Build Tool +OutDir=.\Win32_DLL_Release +SOURCE="$(InputPath)" +PostBuild_Desc=[Run Test] +PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_Release; $(outdir)\pngtest.exe ..\..\pngtest.png +# End Special Build Tool + +!ELSEIF "$(CFG)" == "pngtest - Win32 DLL Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "pngtest___Win32_DLL_Debug" +# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Win32_DLL_Debug" +# PROP Intermediate_Dir "Win32_DLL_Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c +# SUBTRACT BASE CPP /YX +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 Win32_DLL_Debug\libpng13d.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Debug\zlib1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# Begin Special Build Tool +OutDir=.\Win32_DLL_Debug +SOURCE="$(InputPath)" +PostBuild_Desc=[Run Test] +PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_Debug; $(outdir)\pngtest.exe ..\..\pngtest.png +# End Special Build Tool + +!ELSEIF "$(CFG)" == "pngtest - Win32 DLL ASM Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "pngtest___Win32_DLL_ASM_Release" +# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_ASM_Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Win32_DLL_ASM_Release" +# PROP Intermediate_Dir "Win32_DLL_ASM_Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c +# SUBTRACT BASE CPP /YX +# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 +# ADD LINK32 Win32_DLL_ASM_Release\libpng13.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release\zlib1.lib /nologo /subsystem:console /machine:I386 +# Begin Special Build Tool +OutDir=.\Win32_DLL_ASM_Release +SOURCE="$(InputPath)" +PostBuild_Desc=[Run Test] +PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release; $(outdir)\pngtest.exe ..\..\pngtest.png +# End Special Build Tool + +!ELSEIF "$(CFG)" == "pngtest - Win32 DLL ASM Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "pngtest___Win32_DLL_ASM_Debug" +# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_ASM_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Win32_DLL_ASM_Debug" +# PROP Intermediate_Dir "Win32_DLL_ASM_Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c +# SUBTRACT BASE CPP /YX +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 Win32_DLL_ASM_Debug\libpng13d.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug\zlib1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# Begin Special Build Tool +OutDir=.\Win32_DLL_ASM_Debug +SOURCE="$(InputPath)" +PostBuild_Desc=[Run Test] +PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug; $(outdir)\pngtest.exe ..\..\pngtest.png +# End Special Build Tool + +!ELSEIF "$(CFG)" == "pngtest - Win32 LIB Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "pngtest___Win32_LIB_Release" +# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Win32_LIB_Release" +# PROP Intermediate_Dir "Win32_LIB_Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c +# SUBTRACT BASE CPP /YX +# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 +# ADD LINK32 Win32_LIB_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Release\zlib.lib /nologo /subsystem:console /machine:I386 +# Begin Special Build Tool +OutDir=.\Win32_LIB_Release +SOURCE="$(InputPath)" +PostBuild_Desc=[Run Test] +PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png +# End Special Build Tool + +!ELSEIF "$(CFG)" == "pngtest - Win32 LIB Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "pngtest___Win32_LIB_Debug" +# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Win32_LIB_Debug" +# PROP Intermediate_Dir "Win32_LIB_Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c +# SUBTRACT BASE CPP /YX +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 Win32_LIB_Debug\libpngd.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Debug\zlibd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# Begin Special Build Tool +OutDir=.\Win32_LIB_Debug +SOURCE="$(InputPath)" +PostBuild_Desc=[Run Test] +PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png +# End Special Build Tool + +!ELSEIF "$(CFG)" == "pngtest - Win32 LIB ASM Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "pngtest___Win32_LIB_ASM_Release" +# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_ASM_Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Win32_LIB_ASM_Release" +# PROP Intermediate_Dir "Win32_LIB_ASM_Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c +# SUBTRACT BASE CPP /YX +# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 +# ADD LINK32 Win32_LIB_ASM_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_ASM_Release\zlib.lib /nologo /subsystem:console /machine:I386 +# Begin Special Build Tool +OutDir=.\Win32_LIB_ASM_Release +SOURCE="$(InputPath)" +PostBuild_Desc=[Run Test] +PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png +# End Special Build Tool + +!ELSEIF "$(CFG)" == "pngtest - Win32 LIB ASM Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "pngtest___Win32_LIB_ASM_Debug" +# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_ASM_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Win32_LIB_ASM_Debug" +# PROP Intermediate_Dir "Win32_LIB_ASM_Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c +# SUBTRACT BASE CPP /YX +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 Win32_LIB_ASM_Debug\libpngd.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_ASM_Debug\zlibd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# Begin Special Build Tool +OutDir=.\Win32_LIB_ASM_Debug +SOURCE="$(InputPath)" +PostBuild_Desc=[Run Test] +PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "pngtest - Win32 DLL Release" +# Name "pngtest - Win32 DLL Debug" +# Name "pngtest - Win32 DLL ASM Release" +# Name "pngtest - Win32 DLL ASM Debug" +# Name "pngtest - Win32 LIB Release" +# Name "pngtest - Win32 LIB Debug" +# Name "pngtest - Win32 LIB ASM Release" +# Name "pngtest - Win32 LIB ASM Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\..\pngtest.c +# End Source File +# End Group +# End Target +# End Project diff --git a/src/dep/src/irrlicht/libpng/projects/visualc71/README.txt b/src/dep/src/irrlicht/libpng/projects/visualc71/README.txt index e49af14..7bd6332 100644 --- a/src/dep/src/irrlicht/libpng/projects/visualc71/README.txt +++ b/src/dep/src/irrlicht/libpng/projects/visualc71/README.txt @@ -1,57 +1,57 @@ -Microsoft Developer Studio Project File, Format Version 7.10 for libpng. - -Copyright (C) 2004 Simon-Pierre Cadieux. -For conditions of distribution and use, see copyright notice in png.h - -Assumptions: -* The libpng source files are in ..\.. -* The zlib source files are in ..\..\..\zlib -* The zlib project file is in . /* Warning: This is until the zlib project - files get intergrated into the next zlib release. The final zlib project - directory will then be ..\..\..\zlib\projects\visualc71. */ - -To use: - -1) On the main menu, select "File | Open Solution". - Open "libpng.sln". - -2) Display the Solution Explorer view (Ctrl+Alt+L) - -3) Set one of the project as the StartUp project. If you just want to build the - binaries set "libpng" as the startup project (Select "libpng" tree view - item + Project | Set as StartUp project). If you want to build and test the - binaries set it to "pngtest" (Select "pngtest" tree view item + - Project | Set as StartUp project) - -4) Select "Build | Configuration Manager...". - Choose the configuration you wish to build. - -5) Select "Build | Clean Solution". - -6) Select "Build | Build Solution (Ctrl-Shift-B)" - -This project builds the libpng binaries as follows: - -* Win32_DLL_Release\libpng13.dll DLL build -* Win32_DLL_Debug\libpng13d.dll DLL build (debug version) -* Win32_DLL_ASM_Release\libpng13.dll DLL build using ASM code -* Win32_DLL_ASM_Debug\libpng13d.dll DLL build using ASM (debug version) -* Win32_DLL_VB\libpng13vb.dll DLL build for Visual Basic, using stdcall -* Win32_LIB_Release\libpng.lib static build -* Win32_LIB_Debug\libpngd.lib static build (debug version) -* Win32_LIB_ASM_Release\libpng.lib static build using ASM code -* Win32_LIB_ASM_Debug\libpngd.lib static build using ASM (debug version) - -Notes: - -If you change anything in the source files, or select different compiler -settings, please change the DLL name to something different than any of -the above names. Also, make sure that in your "pngusr.h" you define -PNG_USER_PRIVATEBUILD and PNG_USER_DLLFNAME_POSTFIX according to the -instructions provided in "pngconf.h". - -All DLLs built by this project use the Microsoft dynamic C runtime library -MSVCR71.DLL (MSVCR71D.DLL for debug versions). If you distribute any of the -above mentioned libraries you may have to include this DLL in your package. -For a list of files that are redistributable in Visual Studio see -$(VCINSTALLDIR)\redist.txt. +Microsoft Developer Studio Project File, Format Version 7.10 for libpng. + +Copyright (C) 2004 Simon-Pierre Cadieux. +For conditions of distribution and use, see copyright notice in png.h + +Assumptions: +* The libpng source files are in ..\.. +* The zlib source files are in ..\..\..\zlib +* The zlib project file is in . /* Warning: This is until the zlib project + files get intergrated into the next zlib release. The final zlib project + directory will then be ..\..\..\zlib\projects\visualc71. */ + +To use: + +1) On the main menu, select "File | Open Solution". + Open "libpng.sln". + +2) Display the Solution Explorer view (Ctrl+Alt+L) + +3) Set one of the project as the StartUp project. If you just want to build the + binaries set "libpng" as the startup project (Select "libpng" tree view + item + Project | Set as StartUp project). If you want to build and test the + binaries set it to "pngtest" (Select "pngtest" tree view item + + Project | Set as StartUp project) + +4) Select "Build | Configuration Manager...". + Choose the configuration you wish to build. + +5) Select "Build | Clean Solution". + +6) Select "Build | Build Solution (Ctrl-Shift-B)" + +This project builds the libpng binaries as follows: + +* Win32_DLL_Release\libpng13.dll DLL build +* Win32_DLL_Debug\libpng13d.dll DLL build (debug version) +* Win32_DLL_ASM_Release\libpng13.dll DLL build using ASM code +* Win32_DLL_ASM_Debug\libpng13d.dll DLL build using ASM (debug version) +* Win32_DLL_VB\libpng13vb.dll DLL build for Visual Basic, using stdcall +* Win32_LIB_Release\libpng.lib static build +* Win32_LIB_Debug\libpngd.lib static build (debug version) +* Win32_LIB_ASM_Release\libpng.lib static build using ASM code +* Win32_LIB_ASM_Debug\libpngd.lib static build using ASM (debug version) + +Notes: + +If you change anything in the source files, or select different compiler +settings, please change the DLL name to something different than any of +the above names. Also, make sure that in your "pngusr.h" you define +PNG_USER_PRIVATEBUILD and PNG_USER_DLLFNAME_POSTFIX according to the +instructions provided in "pngconf.h". + +All DLLs built by this project use the Microsoft dynamic C runtime library +MSVCR71.DLL (MSVCR71D.DLL for debug versions). If you distribute any of the +above mentioned libraries you may have to include this DLL in your package. +For a list of files that are redistributable in Visual Studio see +$(VCINSTALLDIR)\redist.txt. diff --git a/src/dep/src/irrlicht/libpng/projects/visualc71/README_zlib.txt b/src/dep/src/irrlicht/libpng/projects/visualc71/README_zlib.txt index 589f5f4..ff6a5c7 100644 --- a/src/dep/src/irrlicht/libpng/projects/visualc71/README_zlib.txt +++ b/src/dep/src/irrlicht/libpng/projects/visualc71/README_zlib.txt @@ -1,44 +1,44 @@ -/* WARNING: This file was put in the LibPNG distribution for convenience only. - It is expected to be part of the next zlib release under - "projects\visualc71\README.txt." */ - -Microsoft Developer Studio Project File, Format Version 7.10 for zlib. - -Copyright (C) 2004 Simon-Pierre Cadieux. -Copyright (C) 2004 Cosmin Truta. -For conditions of distribution and use, see copyright notice in zlib.h. - - -To use: - -1) On the main menu, select "File | Open Solution". - Open "zlib.sln". - -2) Display the Solution Explorer view (Ctrl+Alt+L) - -3) Set one of the project as the StartUp project. If you just want to build the - binaries set "zlib" as the startup project (Select "zlib" tree view item + - Project | Set as StartUp project). If you want to build and test the - binaries set it to "example" (Select "example" tree view item + Project | - Set as StartUp project), If you want to build the minigzip utility set it to - "minigzip" (Select "minigzip" tree view item + Project | Set as StartUp - project - -4) Select "Build | Configuration Manager...". - Choose the configuration you wish to build. - -5) Select "Build | Clean Solution". - -6) Select "Build | Build Solution (Ctrl-Shift-B)" - -This project builds the zlib binaries as follows: - -* Win32_DLL_Release\zlib1.dll DLL build -* Win32_DLL_Debug\zlib1d.dll DLL build (debug version) -* Win32_DLL_ASM_Release\zlib1.dll DLL build using ASM code -* Win32_DLL_ASM_Debug\zlib1d.dll DLL build using ASM code (debug version) -* Win32_LIB_Release\zlib.lib static build -* Win32_LIB_Debug\zlibd.lib static build (debug version) -* Win32_LIB_ASM_Release\zlib.lib static build using ASM code -* Win32_LIB_ASM_Debug\zlibd.lib static build using ASM code (debug version) - +/* WARNING: This file was put in the LibPNG distribution for convenience only. + It is expected to be part of the next zlib release under + "projects\visualc71\README.txt." */ + +Microsoft Developer Studio Project File, Format Version 7.10 for zlib. + +Copyright (C) 2004 Simon-Pierre Cadieux. +Copyright (C) 2004 Cosmin Truta. +For conditions of distribution and use, see copyright notice in zlib.h. + + +To use: + +1) On the main menu, select "File | Open Solution". + Open "zlib.sln". + +2) Display the Solution Explorer view (Ctrl+Alt+L) + +3) Set one of the project as the StartUp project. If you just want to build the + binaries set "zlib" as the startup project (Select "zlib" tree view item + + Project | Set as StartUp project). If you want to build and test the + binaries set it to "example" (Select "example" tree view item + Project | + Set as StartUp project), If you want to build the minigzip utility set it to + "minigzip" (Select "minigzip" tree view item + Project | Set as StartUp + project + +4) Select "Build | Configuration Manager...". + Choose the configuration you wish to build. + +5) Select "Build | Clean Solution". + +6) Select "Build | Build Solution (Ctrl-Shift-B)" + +This project builds the zlib binaries as follows: + +* Win32_DLL_Release\zlib1.dll DLL build +* Win32_DLL_Debug\zlib1d.dll DLL build (debug version) +* Win32_DLL_ASM_Release\zlib1.dll DLL build using ASM code +* Win32_DLL_ASM_Debug\zlib1d.dll DLL build using ASM code (debug version) +* Win32_LIB_Release\zlib.lib static build +* Win32_LIB_Debug\zlibd.lib static build (debug version) +* Win32_LIB_ASM_Release\zlib.lib static build using ASM code +* Win32_LIB_ASM_Debug\zlibd.lib static build using ASM code (debug version) + diff --git a/src/dep/src/irrlicht/libpng/projects/visualc71/libpng.sln b/src/dep/src/irrlicht/libpng/projects/visualc71/libpng.sln index 7f75b0c..d49277e 100644 --- a/src/dep/src/irrlicht/libpng/projects/visualc71/libpng.sln +++ b/src/dep/src/irrlicht/libpng/projects/visualc71/libpng.sln @@ -1,88 +1,88 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "libpng.vcproj", "{0008960E-E0DD-41A6-8265-00B31DDB4C21}" - ProjectSection(ProjectDependencies) = postProject - {2D4F8105-7D21-454C-9932-B47CAB71A5C0} = {2D4F8105-7D21-454C-9932-B47CAB71A5C0} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pngtest", "pngtest.vcproj", "{FD1C2F86-9EEF-47BD-95A4-530917E17FDA}" - ProjectSection(ProjectDependencies) = postProject - {0008960E-E0DD-41A6-8265-00B31DDB4C21} = {0008960E-E0DD-41A6-8265-00B31DDB4C21} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib.vcproj", "{2D4F8105-7D21-454C-9932-B47CAB71A5C0}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - DLL ASM Debug = DLL ASM Debug - DLL ASM Release = DLL ASM Release - DLL Debug = DLL Debug - DLL Release = DLL Release - DLL VB = DLL VB - LIB ASM Debug = LIB ASM Debug - LIB ASM Release = LIB ASM Release - LIB Debug = LIB Debug - LIB Release = LIB Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL ASM Debug.ActiveCfg = DLL ASM Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL ASM Debug.Build.0 = DLL ASM Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL ASM Release.ActiveCfg = DLL ASM Release|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL ASM Release.Build.0 = DLL ASM Release|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL Debug.ActiveCfg = DLL Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL Debug.Build.0 = DLL Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL Release.ActiveCfg = DLL Release|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL Release.Build.0 = DLL Release|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL VB.ActiveCfg = DLL VB|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL VB.Build.0 = DLL VB|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB ASM Debug.ActiveCfg = LIB ASM Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB ASM Debug.Build.0 = LIB ASM Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB ASM Release.ActiveCfg = LIB ASM Release|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB ASM Release.Build.0 = LIB ASM Release|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB Debug.ActiveCfg = LIB Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB Debug.Build.0 = LIB Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB Release.ActiveCfg = LIB Release|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB Release.Build.0 = LIB Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL ASM Debug.ActiveCfg = DLL ASM Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL ASM Debug.Build.0 = DLL ASM Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL ASM Release.ActiveCfg = DLL ASM Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL ASM Release.Build.0 = DLL ASM Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL Debug.ActiveCfg = DLL Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL Debug.Build.0 = DLL Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL Release.ActiveCfg = DLL Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL Release.Build.0 = DLL Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL VB.ActiveCfg = DLL VB|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL VB.Build.0 = DLL VB|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB ASM Debug.ActiveCfg = LIB ASM Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB ASM Debug.Build.0 = LIB ASM Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB ASM Release.ActiveCfg = LIB ASM Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB ASM Release.Build.0 = LIB ASM Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB Debug.ActiveCfg = LIB Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB Debug.Build.0 = LIB Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB Release.ActiveCfg = LIB Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB Release.Build.0 = LIB Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL ASM Debug.ActiveCfg = DLL ASM Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL ASM Debug.Build.0 = DLL ASM Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL ASM Release.ActiveCfg = DLL ASM Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL ASM Release.Build.0 = DLL ASM Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL Debug.ActiveCfg = DLL Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL Debug.Build.0 = DLL Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL Release.ActiveCfg = DLL Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL Release.Build.0 = DLL Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL VB.ActiveCfg = DLL Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL VB.Build.0 = DLL Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB ASM Debug.ActiveCfg = LIB ASM Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB ASM Debug.Build.0 = LIB ASM Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB ASM Release.ActiveCfg = LIB ASM Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB ASM Release.Build.0 = LIB ASM Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB Debug.ActiveCfg = LIB Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB Debug.Build.0 = LIB Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB Release.ActiveCfg = LIB Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB Release.Build.0 = LIB Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "libpng.vcproj", "{0008960E-E0DD-41A6-8265-00B31DDB4C21}" + ProjectSection(ProjectDependencies) = postProject + {2D4F8105-7D21-454C-9932-B47CAB71A5C0} = {2D4F8105-7D21-454C-9932-B47CAB71A5C0} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pngtest", "pngtest.vcproj", "{FD1C2F86-9EEF-47BD-95A4-530917E17FDA}" + ProjectSection(ProjectDependencies) = postProject + {0008960E-E0DD-41A6-8265-00B31DDB4C21} = {0008960E-E0DD-41A6-8265-00B31DDB4C21} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib.vcproj", "{2D4F8105-7D21-454C-9932-B47CAB71A5C0}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + DLL ASM Debug = DLL ASM Debug + DLL ASM Release = DLL ASM Release + DLL Debug = DLL Debug + DLL Release = DLL Release + DLL VB = DLL VB + LIB ASM Debug = LIB ASM Debug + LIB ASM Release = LIB ASM Release + LIB Debug = LIB Debug + LIB Release = LIB Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL ASM Debug.ActiveCfg = DLL ASM Debug|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL ASM Debug.Build.0 = DLL ASM Debug|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL ASM Release.ActiveCfg = DLL ASM Release|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL ASM Release.Build.0 = DLL ASM Release|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL Debug.ActiveCfg = DLL Debug|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL Debug.Build.0 = DLL Debug|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL Release.ActiveCfg = DLL Release|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL Release.Build.0 = DLL Release|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL VB.ActiveCfg = DLL VB|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL VB.Build.0 = DLL VB|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB ASM Debug.ActiveCfg = LIB ASM Debug|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB ASM Debug.Build.0 = LIB ASM Debug|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB ASM Release.ActiveCfg = LIB ASM Release|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB ASM Release.Build.0 = LIB ASM Release|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB Debug.ActiveCfg = LIB Debug|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB Debug.Build.0 = LIB Debug|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB Release.ActiveCfg = LIB Release|Win32 + {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB Release.Build.0 = LIB Release|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL ASM Debug.ActiveCfg = DLL ASM Debug|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL ASM Debug.Build.0 = DLL ASM Debug|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL ASM Release.ActiveCfg = DLL ASM Release|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL ASM Release.Build.0 = DLL ASM Release|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL Debug.ActiveCfg = DLL Debug|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL Debug.Build.0 = DLL Debug|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL Release.ActiveCfg = DLL Release|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL Release.Build.0 = DLL Release|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL VB.ActiveCfg = DLL VB|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL VB.Build.0 = DLL VB|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB ASM Debug.ActiveCfg = LIB ASM Debug|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB ASM Debug.Build.0 = LIB ASM Debug|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB ASM Release.ActiveCfg = LIB ASM Release|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB ASM Release.Build.0 = LIB ASM Release|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB Debug.ActiveCfg = LIB Debug|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB Debug.Build.0 = LIB Debug|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB Release.ActiveCfg = LIB Release|Win32 + {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB Release.Build.0 = LIB Release|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL ASM Debug.ActiveCfg = DLL ASM Debug|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL ASM Debug.Build.0 = DLL ASM Debug|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL ASM Release.ActiveCfg = DLL ASM Release|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL ASM Release.Build.0 = DLL ASM Release|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL Debug.ActiveCfg = DLL Debug|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL Debug.Build.0 = DLL Debug|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL Release.ActiveCfg = DLL Release|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL Release.Build.0 = DLL Release|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL VB.ActiveCfg = DLL Release|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL VB.Build.0 = DLL Release|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB ASM Debug.ActiveCfg = LIB ASM Debug|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB ASM Debug.Build.0 = LIB ASM Debug|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB ASM Release.ActiveCfg = LIB ASM Release|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB ASM Release.Build.0 = LIB ASM Release|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB Debug.ActiveCfg = LIB Debug|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB Debug.Build.0 = LIB Debug|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB Release.ActiveCfg = LIB Release|Win32 + {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB Release.Build.0 = LIB Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/src/dep/src/irrlicht/libpng/projects/visualc71/libpng.vcproj b/src/dep/src/irrlicht/libpng/projects/visualc71/libpng.vcproj index 19c631f..76e122a 100644 --- a/src/dep/src/irrlicht/libpng/projects/visualc71/libpng.vcproj +++ b/src/dep/src/irrlicht/libpng/projects/visualc71/libpng.vcproj @@ -1,735 +1,735 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/dep/src/irrlicht/libpng/projects/visualc71/pngtest.vcproj b/src/dep/src/irrlicht/libpng/projects/visualc71/pngtest.vcproj index 210566c..e7a2927 100644 --- a/src/dep/src/irrlicht/libpng/projects/visualc71/pngtest.vcproj +++ b/src/dep/src/irrlicht/libpng/projects/visualc71/pngtest.vcproj @@ -1,459 +1,459 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/dep/src/irrlicht/libpng/projects/visualc71/zlib.vcproj b/src/dep/src/irrlicht/libpng/projects/visualc71/zlib.vcproj index bc0a2bf..5574ae3 100644 --- a/src/dep/src/irrlicht/libpng/projects/visualc71/zlib.vcproj +++ b/src/dep/src/irrlicht/libpng/projects/visualc71/zlib.vcproj @@ -1,670 +1,670 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/dep/src/irrlicht/libpng/projects/wince.txt b/src/dep/src/irrlicht/libpng/projects/wince.txt index 4ccff38..a1a26c0 100644 --- a/src/dep/src/irrlicht/libpng/projects/wince.txt +++ b/src/dep/src/irrlicht/libpng/projects/wince.txt @@ -1,6 +1,6 @@ -A set of project files is available for WinCE. Get -libpng-1.2.5-project-wince.zip from a libpng distribution -site such as http://libpng.sourceforge.net - -Put the zip file in this directory (projects) and then run -"unzip -a libpng-1.2.5-project-wince.zip" +A set of project files is available for WinCE. Get +libpng-1.2.5-project-wince.zip from a libpng distribution +site such as http://libpng.sourceforge.net + +Put the zip file in this directory (projects) and then run +"unzip -a libpng-1.2.5-project-wince.zip" diff --git a/src/dep/src/irrlicht/libpng/scripts/CMakeLists.txt b/src/dep/src/irrlicht/libpng/scripts/CMakeLists.txt index 8a6ff8a..7db0f45 100644 --- a/src/dep/src/irrlicht/libpng/scripts/CMakeLists.txt +++ b/src/dep/src/irrlicht/libpng/scripts/CMakeLists.txt @@ -1,205 +1,205 @@ -project(PNG) - -# Copyright (C) 2007 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h - -set(PNGLIB_MAJOR 1) -set(PNGLIB_MINOR 2) -set(PNGLIB_RELEASE 16) -set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) -set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) - -# needed packages -find_package(ZLIB REQUIRED) -if(NOT WIN32) - find_library(M_LIBRARY - NAMES m - PATHS /usr/lib /usr/local/lib - ) - if(NOT M_LIBRARY) - message(STATUS "math library 'libm' not found - floating point support disabled") - endif(NOT M_LIBRARY) -else(NOT WIN32) - # not needed on windows - set(M_LIBRARY "") -endif(NOT WIN32) - - -# COMMAND LINE OPTIONS -option(PNG_SHARED "Build shared lib" YES) -option(PNG_TESTS "Build pngtest" YES) -option(PNG_NO_CONSOLE_IO "FIXME" YES) -option(PNG_NO_STDIO "FIXME" YES) -option(PNG_DEBUG "Build with debug output" YES) -option(PNGARG "FIXME" YES) -#TODO: -# PNG_CONSOLE_IO_SUPPORTED - -# maybe needs improving, but currently I don't know when we can enable what :) -set(png_asm_tmp "OFF") -if(NOT WIN32) - find_program(uname_executable NAMES uname PATHS /bin /usr/bin /usr/local/bin) - if(uname_executable) - EXEC_PROGRAM(${uname_executable} ARGS --machine OUTPUT_VARIABLE uname_output) - if("uname_output" MATCHES "^.*i[1-9]86.*$") - set(png_asm_tmp "ON") - else("uname_output" MATCHES "^.*i[1-9]86.*$") - set(png_asm_tmp "OFF") - endif("uname_output" MATCHES "^.*i[1-9]86.*$") - endif(uname_executable) -endif(NOT WIN32) - -option(PNG_MMX "Use MMX assembler code (x86 only)" ${png_asm_tmp}) - -# SET LIBNAME -# msvc does not append 'lib' - do it here to have consistent name -if(MSVC) - set(PNG_LIB_NAME lib) -endif(MSVC) -set(PNG_LIB_NAME ${PNG_LIB_NAME}png${PNGLIB_MAJOR}${PNGLIB_MINOR}) - -# to distinguish between debug and release lib -set(CMAKE_DEBUG_POSTFIX "d") - -# append _static to static lib -if(NOT PNG_SHARED) - set(PNG_LIB_NAME ${PNG_LIB_NAME}_static) -endif(NOT PNG_SHARED) - -if(PNG_SHARED) - add_library(${PNG_LIB_NAME} SHARED ${libpng_sources}) -else(PNG_SHARED) - add_library(${PNG_LIB_NAME} STATIC ${libpng_sources}) -endif(PNG_SHARED) - -# OUR SOURCES -set(libpng_sources - png.h - pngconf.h - png.c - pngerror.c - pngget.c - pngmem.c - pngpread.c - pngread.c - pngrio.c - pngrtran.c - pngrutil.c - pngset.c - pngtrans.c - pngwio.c - pngwrite.c - pngwtran.c - pngwutil.c -) -set(pngtest_sources - pngtest.c -) - - -# SOME NEEDED DEFINITIONS -add_definitions(-DZLIB_DLL) - -if(MSVC) - add_definitions(-DPNG_USE_PNGVCRD -DPNG_NO_MODULEDEF -D_CRT_SECURE_NO_DEPRECATE) - set(libpng_sources ${libpng_sources} - pngvcrd.c - ) -else(MSVC) - add_definitions(-DPNG_USE_PNGGCCRD) - set(libpng_sources ${libpng_sources} - pnggccrd.c - ) -endif(MSVC) - -if(NOT MSVC) - if(NOT PNG_MMX) - add_definitions(-DLIBPNG_NO_MMX) - add_definitions(-DPNG_NO_MMX_CODE) - endif(NOT PNG_MMX) -else(NOT MSVC) - if(PNG_MMX) - # maybe add this to pngconf.h ? - add_definitions(-DPNG_MMX_CODE_SUPPORTED) - endif(PNG_MMX) -endif(NOT MSVC) - - -if(PNG_CONSOLE_IO_SUPPORTED) - add_definitions(-DPNG_CONSOLE_IO_SUPPORTED) -endif(PNG_CONSOLE_IO_SUPPORTED) - -if(PNG_NO_CONSOLE_IO) - add_definitions(-DPNG_NO_CONSOLE_IO) -endif(PNG_NO_CONSOLE_IO) - -if(PNG_NO_STDIO) - add_definitions(-DPNG_NO_STDIO) -endif(PNG_NO_STDIO) - -if(PNG_DEBUG) - add_definitions(-DPNG_DEBUG) -endif(PNG_DEBUG) - -if(NOT M_LIBRARY) - add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED) -endif(NOT M_LIBRARY) - -# NOW BUILD OUR TARGET -include_directories(${PNG_SOURCE_DIR} ${ZLIB_INCLUDE_DIR}) - -if(PNG_SHARED) - add_library(${PNG_LIB_NAME} SHARED ${libpng_sources}) -else(PNG_SHARED) - add_library(STATIC ${libpng_sources}) -endif(PNG_SHARED) - -target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY}) -if(PNG_SHARED AND WIN32) - set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) -endif(PNG_SHARED AND WIN32) - -if(PNG_TESTS) -# does not work with msvc due to png_lib_ver issue - add_executable(pngtest ${pngtest_sources}) - target_link_libraries(pngtest ${PNG_LIB_NAME}) -# add_test(pngtest ${PNG_SOURCE_DIR}/pngtest.png) -endif(PNG_TESTS) - - -# CREATE PKGCONFIG FILES -# we use the same files like ./configure, so we have to set its vars -set(prefix ${CMAKE_INSTALL_PREFIX}/bin) -set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin) -set(libdir ${CMAKE_INSTALL_PREFIX}/lib) -set(includedir ${CMAKE_INSTALL_PREFIX}/include) - -configure_file(${PNG_SOURCE_DIR}/scripts/libpng.pc.in ${PNG_BINARY_DIR}/libpng.pc) -configure_file(${PNG_SOURCE_DIR}/scripts/libpng-config.in ${PNG_BINARY_DIR}/libpng-config) -configure_file(${PNG_SOURCE_DIR}/scripts/libpng.pc.in ${PNG_BINARY_DIR}/${PNGLIB_NAME}.pc) -configure_file(${PNG_SOURCE_DIR}/scripts/libpng-config.in ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config) - -# INSTALL -install_targets(/lib ${PNG_LIB_NAME}) -install(FILES png.h pngconf.h DESTINATION include) -install(FILES png.h pngconf.h DESTINATION include/${PNGLIB_NAME}) -install(FILES libpng.3 libpngpf.3 DESTINATION man/man3) -install(FILES png.5 DESTINATION man/man5) -install(FILES ${PNG_BINARY_DIR}/libpng.pc DESTINATION lib/pkgconfig) -install(FILES ${PNG_BINARY_DIR}/libpng-config DESTINATION bin) -install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}.pc DESTINATION lib/pkgconfig) -install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin) - -# what's with libpng.txt and all the extra files? - - -# UNINSTALL -# do we need this? - - -# DIST -# do we need this? - -# to create msvc import lib for mingw compiled shared lib -# pexports libpng.dll > libpng.def -# lib /def:libpng.def /machine:x86 +project(PNG) + +# Copyright (C) 2007 Glenn Randers-Pehrson +# For conditions of distribution and use, see copyright notice in png.h + +set(PNGLIB_MAJOR 1) +set(PNGLIB_MINOR 2) +set(PNGLIB_RELEASE 16) +set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) +set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) + +# needed packages +find_package(ZLIB REQUIRED) +if(NOT WIN32) + find_library(M_LIBRARY + NAMES m + PATHS /usr/lib /usr/local/lib + ) + if(NOT M_LIBRARY) + message(STATUS "math library 'libm' not found - floating point support disabled") + endif(NOT M_LIBRARY) +else(NOT WIN32) + # not needed on windows + set(M_LIBRARY "") +endif(NOT WIN32) + + +# COMMAND LINE OPTIONS +option(PNG_SHARED "Build shared lib" YES) +option(PNG_TESTS "Build pngtest" YES) +option(PNG_NO_CONSOLE_IO "FIXME" YES) +option(PNG_NO_STDIO "FIXME" YES) +option(PNG_DEBUG "Build with debug output" YES) +option(PNGARG "FIXME" YES) +#TODO: +# PNG_CONSOLE_IO_SUPPORTED + +# maybe needs improving, but currently I don't know when we can enable what :) +set(png_asm_tmp "OFF") +if(NOT WIN32) + find_program(uname_executable NAMES uname PATHS /bin /usr/bin /usr/local/bin) + if(uname_executable) + EXEC_PROGRAM(${uname_executable} ARGS --machine OUTPUT_VARIABLE uname_output) + if("uname_output" MATCHES "^.*i[1-9]86.*$") + set(png_asm_tmp "ON") + else("uname_output" MATCHES "^.*i[1-9]86.*$") + set(png_asm_tmp "OFF") + endif("uname_output" MATCHES "^.*i[1-9]86.*$") + endif(uname_executable) +endif(NOT WIN32) + +option(PNG_MMX "Use MMX assembler code (x86 only)" ${png_asm_tmp}) + +# SET LIBNAME +# msvc does not append 'lib' - do it here to have consistent name +if(MSVC) + set(PNG_LIB_NAME lib) +endif(MSVC) +set(PNG_LIB_NAME ${PNG_LIB_NAME}png${PNGLIB_MAJOR}${PNGLIB_MINOR}) + +# to distinguish between debug and release lib +set(CMAKE_DEBUG_POSTFIX "d") + +# append _static to static lib +if(NOT PNG_SHARED) + set(PNG_LIB_NAME ${PNG_LIB_NAME}_static) +endif(NOT PNG_SHARED) + +if(PNG_SHARED) + add_library(${PNG_LIB_NAME} SHARED ${libpng_sources}) +else(PNG_SHARED) + add_library(${PNG_LIB_NAME} STATIC ${libpng_sources}) +endif(PNG_SHARED) + +# OUR SOURCES +set(libpng_sources + png.h + pngconf.h + png.c + pngerror.c + pngget.c + pngmem.c + pngpread.c + pngread.c + pngrio.c + pngrtran.c + pngrutil.c + pngset.c + pngtrans.c + pngwio.c + pngwrite.c + pngwtran.c + pngwutil.c +) +set(pngtest_sources + pngtest.c +) + + +# SOME NEEDED DEFINITIONS +add_definitions(-DZLIB_DLL) + +if(MSVC) + add_definitions(-DPNG_USE_PNGVCRD -DPNG_NO_MODULEDEF -D_CRT_SECURE_NO_DEPRECATE) + set(libpng_sources ${libpng_sources} + pngvcrd.c + ) +else(MSVC) + add_definitions(-DPNG_USE_PNGGCCRD) + set(libpng_sources ${libpng_sources} + pnggccrd.c + ) +endif(MSVC) + +if(NOT MSVC) + if(NOT PNG_MMX) + add_definitions(-DLIBPNG_NO_MMX) + add_definitions(-DPNG_NO_MMX_CODE) + endif(NOT PNG_MMX) +else(NOT MSVC) + if(PNG_MMX) + # maybe add this to pngconf.h ? + add_definitions(-DPNG_MMX_CODE_SUPPORTED) + endif(PNG_MMX) +endif(NOT MSVC) + + +if(PNG_CONSOLE_IO_SUPPORTED) + add_definitions(-DPNG_CONSOLE_IO_SUPPORTED) +endif(PNG_CONSOLE_IO_SUPPORTED) + +if(PNG_NO_CONSOLE_IO) + add_definitions(-DPNG_NO_CONSOLE_IO) +endif(PNG_NO_CONSOLE_IO) + +if(PNG_NO_STDIO) + add_definitions(-DPNG_NO_STDIO) +endif(PNG_NO_STDIO) + +if(PNG_DEBUG) + add_definitions(-DPNG_DEBUG) +endif(PNG_DEBUG) + +if(NOT M_LIBRARY) + add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED) +endif(NOT M_LIBRARY) + +# NOW BUILD OUR TARGET +include_directories(${PNG_SOURCE_DIR} ${ZLIB_INCLUDE_DIR}) + +if(PNG_SHARED) + add_library(${PNG_LIB_NAME} SHARED ${libpng_sources}) +else(PNG_SHARED) + add_library(STATIC ${libpng_sources}) +endif(PNG_SHARED) + +target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY}) +if(PNG_SHARED AND WIN32) + set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) +endif(PNG_SHARED AND WIN32) + +if(PNG_TESTS) +# does not work with msvc due to png_lib_ver issue + add_executable(pngtest ${pngtest_sources}) + target_link_libraries(pngtest ${PNG_LIB_NAME}) +# add_test(pngtest ${PNG_SOURCE_DIR}/pngtest.png) +endif(PNG_TESTS) + + +# CREATE PKGCONFIG FILES +# we use the same files like ./configure, so we have to set its vars +set(prefix ${CMAKE_INSTALL_PREFIX}/bin) +set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin) +set(libdir ${CMAKE_INSTALL_PREFIX}/lib) +set(includedir ${CMAKE_INSTALL_PREFIX}/include) + +configure_file(${PNG_SOURCE_DIR}/scripts/libpng.pc.in ${PNG_BINARY_DIR}/libpng.pc) +configure_file(${PNG_SOURCE_DIR}/scripts/libpng-config.in ${PNG_BINARY_DIR}/libpng-config) +configure_file(${PNG_SOURCE_DIR}/scripts/libpng.pc.in ${PNG_BINARY_DIR}/${PNGLIB_NAME}.pc) +configure_file(${PNG_SOURCE_DIR}/scripts/libpng-config.in ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config) + +# INSTALL +install_targets(/lib ${PNG_LIB_NAME}) +install(FILES png.h pngconf.h DESTINATION include) +install(FILES png.h pngconf.h DESTINATION include/${PNGLIB_NAME}) +install(FILES libpng.3 libpngpf.3 DESTINATION man/man3) +install(FILES png.5 DESTINATION man/man5) +install(FILES ${PNG_BINARY_DIR}/libpng.pc DESTINATION lib/pkgconfig) +install(FILES ${PNG_BINARY_DIR}/libpng-config DESTINATION bin) +install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}.pc DESTINATION lib/pkgconfig) +install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin) + +# what's with libpng.txt and all the extra files? + + +# UNINSTALL +# do we need this? + + +# DIST +# do we need this? + +# to create msvc import lib for mingw compiled shared lib +# pexports libpng.dll > libpng.def +# lib /def:libpng.def /machine:x86 diff --git a/src/dep/src/irrlicht/libpng/scripts/SCOPTIONS.ppc b/src/dep/src/irrlicht/libpng/scripts/SCOPTIONS.ppc index 7090fd4..2c3503e 100644 --- a/src/dep/src/irrlicht/libpng/scripts/SCOPTIONS.ppc +++ b/src/dep/src/irrlicht/libpng/scripts/SCOPTIONS.ppc @@ -1,7 +1,7 @@ -OPTIMIZE -OPTPEEP -OPTTIME -OPTSCHED -AUTOREGISTER -PARMS=REGISTERS -INCLUDEDIR=hlp:ppc/include +OPTIMIZE +OPTPEEP +OPTTIME +OPTSCHED +AUTOREGISTER +PARMS=REGISTERS +INCLUDEDIR=hlp:ppc/include diff --git a/src/dep/src/irrlicht/libpng/scripts/descrip.mms b/src/dep/src/irrlicht/libpng/scripts/descrip.mms index 3879ee6..3584b0d 100644 --- a/src/dep/src/irrlicht/libpng/scripts/descrip.mms +++ b/src/dep/src/irrlicht/libpng/scripts/descrip.mms @@ -1,52 +1,52 @@ - -cc_defs = /inc=$(ZLIBSRC) -c_deb = - -.ifdef __DECC__ -pref = /prefix=all -.endif - - - -OBJS = png.obj, pngset.obj, pngget.obj, pngrutil.obj, pngtrans.obj,\ - pngwutil.obj, pngread.obj, pngmem.obj, pngwrite.obj, pngrtran.obj,\ - pngwtran.obj, pngrio.obj, pngwio.obj, pngerror.obj, pngpread.obj - - -CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF) - -all : pngtest.exe libpng.olb - @ write sys$output " pngtest available" - -libpng.olb : libpng.olb($(OBJS)) - @ write sys$output " Libpng available" - - -pngtest.exe : pngtest.obj libpng.olb - link pngtest,libpng.olb/lib,$(ZLIBSRC)libz.olb/lib - -test : pngtest.exe - run pngtest - -clean : - delete *.obj;*,*.exe;* - - -# Other dependencies. -png.obj : png.h, pngconf.h -pngpread.obj : png.h, pngconf.h -pngset.obj : png.h, pngconf.h -pngget.obj : png.h, pngconf.h -pngread.obj : png.h, pngconf.h -pngrtran.obj : png.h, pngconf.h -pngrutil.obj : png.h, pngconf.h -pngerror.obj : png.h, pngconf.h -pngmem.obj : png.h, pngconf.h -pngrio.obj : png.h, pngconf.h -pngwio.obj : png.h, pngconf.h -pngtest.obj : png.h, pngconf.h -pngtrans.obj : png.h, pngconf.h -pngwrite.obj : png.h, pngconf.h -pngwtran.obj : png.h, pngconf.h -pngwutil.obj : png.h, pngconf.h - + +cc_defs = /inc=$(ZLIBSRC) +c_deb = + +.ifdef __DECC__ +pref = /prefix=all +.endif + + + +OBJS = png.obj, pngset.obj, pngget.obj, pngrutil.obj, pngtrans.obj,\ + pngwutil.obj, pngread.obj, pngmem.obj, pngwrite.obj, pngrtran.obj,\ + pngwtran.obj, pngrio.obj, pngwio.obj, pngerror.obj, pngpread.obj + + +CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF) + +all : pngtest.exe libpng.olb + @ write sys$output " pngtest available" + +libpng.olb : libpng.olb($(OBJS)) + @ write sys$output " Libpng available" + + +pngtest.exe : pngtest.obj libpng.olb + link pngtest,libpng.olb/lib,$(ZLIBSRC)libz.olb/lib + +test : pngtest.exe + run pngtest + +clean : + delete *.obj;*,*.exe;* + + +# Other dependencies. +png.obj : png.h, pngconf.h +pngpread.obj : png.h, pngconf.h +pngset.obj : png.h, pngconf.h +pngget.obj : png.h, pngconf.h +pngread.obj : png.h, pngconf.h +pngrtran.obj : png.h, pngconf.h +pngrutil.obj : png.h, pngconf.h +pngerror.obj : png.h, pngconf.h +pngmem.obj : png.h, pngconf.h +pngrio.obj : png.h, pngconf.h +pngwio.obj : png.h, pngconf.h +pngtest.obj : png.h, pngconf.h +pngtrans.obj : png.h, pngconf.h +pngwrite.obj : png.h, pngconf.h +pngwtran.obj : png.h, pngconf.h +pngwutil.obj : png.h, pngconf.h + diff --git a/src/dep/src/irrlicht/libpng/scripts/libpng-config-body.in b/src/dep/src/irrlicht/libpng/scripts/libpng-config-body.in index 0db8898..b466432 100644 --- a/src/dep/src/irrlicht/libpng/scripts/libpng-config-body.in +++ b/src/dep/src/irrlicht/libpng/scripts/libpng-config-body.in @@ -1,96 +1,96 @@ - -usage() -{ - cat < libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo libdir=\"$(LIBPATH)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-R$(LIBPATH)\"; \ - echo ccopts=\"-xtarget=ultra\"; \ - echo ldopts=\"-xtarget=ultra\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - @case "`type ld`" in *ucb*) \ - echo; \ - echo '## WARNING:'; \ - echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ - echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ - echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ - echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ - echo '## at all. If it is, things are likely to break because of'; \ - echo '## the libucb dependency that is created.'; \ - echo; \ - ;; \ - esac - $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(LIBSOMAJ) \ - -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(OLDSOMAJ) \ - -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOMAJ).$(PNGVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) $(SUN_CC_FLAGS) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtestd -L$(DL) -R$(DL) `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) $(SUN_CC_FLAGS) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h +# makefile for libpng on Solaris 2.x with cc +# Contributed by William L. Sebok, based on makefile.linux +# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 1998 Greg Roelofs +# Copyright (C) 1996, 1997 Andreas Dilger +# For conditions of distribution and use, see copyright notice in png.h + +# Library name: +LIBNAME=libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).so +LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) +LIBSOVER=$(LIBNAME).so.$(PNGVER) +OLDSO=libpng.so +OLDSOMAJ=libpng.so.3 +OLDSOVER=libpng.so.3.$(PNGMIN) + +# Utilities: +CC=cc +AR_RC=ar rc +MKDIR_P=mkdir -p +LN_SF=ln -f -s +RANLIB=echo +RM_F=/bin/rm -f + +SUN_CC_FLAGS=-fast -xtarget=ultra +SUN_LD_FLAGS=-fast -xtarget=ultra + +# where make install puts libpng.a, libpng12.so and libpng12/png.h +prefix=/a +exec_prefix=$(prefix) + +# Where the zlib library and include files are located +# Changing these to ../zlib poses a security risk. If you want +# to have zlib in an adjacent directory, specify the full path instead of "..". +#ZLIBLIB=../zlib +#ZLIBINC=../zlib + +ZLIBLIB=/usr/lib +ZLIBINC=/usr/include + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion +CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \ + # $(WARNMORE) -g -DPNG_DEBUG=5 +LDFLAGS=$(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) libpng.a -lz -lm + +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +.c.pic.o: + $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c + +all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo libdir=\"$(LIBPATH)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo R_opts=\"-R$(LIBPATH)\"; \ + echo ccopts=\"-xtarget=ultra\"; \ + echo ldopts=\"-xtarget=ultra\"; \ + echo libs=\"-lpng12 -lz -lm\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJSDLL) + @case "`type ld`" in *ucb*) \ + echo; \ + echo '## WARNING:'; \ + echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ + echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ + echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ + echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ + echo '## at all. If it is, things are likely to break because of'; \ + echo '## the libucb dependency that is created.'; \ + echo; \ + ;; \ + esac + $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(LIBSOMAJ) \ + -o $(LIBSOVER) $(OBJSDLL) + +$(OLDSOVER): $(OBJSDLL) + $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(OLDSOMAJ) \ + -o $(OLDSOVER) $(OBJSDLL) + +pngtest: pngtest.o $(LIBSO) + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOMAJ).$(PNGVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) $(SUN_CC_FLAGS) -I$(DI) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -o pngtestd -L$(DL) -R$(DL) `$(BINPATH)/$(LIBNAME)-config --ldflags` \ + $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) + ./pngtestd pngtest.png + +test-installed: + echo + echo Testing installed dynamic shared library. + $(CC) $(SUN_CC_FLAGS) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \ + $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ + libpng-config $(LIBSO) $(LIBSOMAJ)* \ + $(OLDSOVER) \ + libpng.pc + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h +pngerror.o pngerror.pic.o: png.h pngconf.h +pngrio.o pngrio.pic.o: png.h pngconf.h +pngwio.o pngwio.pic.o: png.h pngconf.h +pngmem.o pngmem.pic.o: png.h pngconf.h +pngset.o pngset.pic.o: png.h pngconf.h +pngget.o pngget.pic.o: png.h pngconf.h +pngread.o pngread.pic.o: png.h pngconf.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h +pngpread.o pngpread.pic.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.64sunu b/src/dep/src/irrlicht/libpng/scripts/makefile.64sunu index 63f8682..4c3287e 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.64sunu +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.64sunu @@ -1,250 +1,250 @@ -# makefile for libpng on Solaris 2.x with cc -# Contributed by William L. Sebok, based on makefile.linux -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1998 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME=libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -CC=cc -AR_RC=ar rc -MKDIR_P=mkdir -p -LN_SF=ln -f -s -RANLIB=echo -RM_F=/bin/rm -f - -SUN_CC_FLAGS=-fast -xtarget=ultra -xarch=v9 -SUN_LD_FLAGS=-fast -xtarget=ultra -xarch=v9 - -# where make install puts libpng.a, libpng12.so and libpng12/png.h -prefix=/a -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -# Changing these to ../zlib poses a security risk. If you want -# to have zlib in an adjacent directory, specify the full path instead of "..". -#ZLIBLIB=../zlib -#ZLIBINC=../zlib - -ZLIBLIB=/usr/lib -ZLIBINC=/usr/include - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \ - # $(WARNMORE) -g -DPNG_DEBUG=5 -LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo libdir=\"$(LIBPATH)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-R$(LIBPATH)\"; \ - echo ccopts=\"-xtarget=ultra -xarch=v9\"; \ - echo ldopts=\"-xtarget=ultra -xarch=v9\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - @case "`type ld`" in *ucb*) \ - echo; \ - echo '## WARNING:'; \ - echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ - echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ - echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ - echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ - echo '## at all. If it is, things are likely to break because of'; \ - echo '## the libucb dependency that is created.'; \ - echo; \ - ;; \ - esac - $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(LIBSOMAJ) \ - -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(OLDSOMAJ) \ - -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOMAJ).$(PNGVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) $(SUN_CC_FLAGS) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtestd -L$(DL) -R$(DL) `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) $(SUN_CC_FLAGS) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h +# makefile for libpng on Solaris 2.x with cc +# Contributed by William L. Sebok, based on makefile.linux +# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 1998 Greg Roelofs +# Copyright (C) 1996, 1997 Andreas Dilger +# For conditions of distribution and use, see copyright notice in png.h + +# Library name: +LIBNAME=libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).so +LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) +LIBSOVER=$(LIBNAME).so.$(PNGVER) +OLDSO=libpng.so +OLDSOMAJ=libpng.so.3 +OLDSOVER=libpng.so.3.$(PNGMIN) + +# Utilities: +CC=cc +AR_RC=ar rc +MKDIR_P=mkdir -p +LN_SF=ln -f -s +RANLIB=echo +RM_F=/bin/rm -f + +SUN_CC_FLAGS=-fast -xtarget=ultra -xarch=v9 +SUN_LD_FLAGS=-fast -xtarget=ultra -xarch=v9 + +# where make install puts libpng.a, libpng12.so and libpng12/png.h +prefix=/a +exec_prefix=$(prefix) + +# Where the zlib library and include files are located +# Changing these to ../zlib poses a security risk. If you want +# to have zlib in an adjacent directory, specify the full path instead of "..". +#ZLIBLIB=../zlib +#ZLIBINC=../zlib + +ZLIBLIB=/usr/lib +ZLIBINC=/usr/include + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion +CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \ + # $(WARNMORE) -g -DPNG_DEBUG=5 +LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm + +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +.c.pic.o: + $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c + +all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo libdir=\"$(LIBPATH)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo R_opts=\"-R$(LIBPATH)\"; \ + echo ccopts=\"-xtarget=ultra -xarch=v9\"; \ + echo ldopts=\"-xtarget=ultra -xarch=v9\"; \ + echo libs=\"-lpng12 -lz -lm\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJSDLL) + @case "`type ld`" in *ucb*) \ + echo; \ + echo '## WARNING:'; \ + echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ + echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ + echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ + echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ + echo '## at all. If it is, things are likely to break because of'; \ + echo '## the libucb dependency that is created.'; \ + echo; \ + ;; \ + esac + $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(LIBSOMAJ) \ + -o $(LIBSOVER) $(OBJSDLL) + +$(OLDSOVER): $(OBJSDLL) + $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(OLDSOMAJ) \ + -o $(OLDSOVER) $(OBJSDLL) + +pngtest: pngtest.o $(LIBSO) + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOMAJ).$(PNGVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) $(SUN_CC_FLAGS) -I$(DI) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -o pngtestd -L$(DL) -R$(DL) `$(BINPATH)/$(LIBNAME)-config --ldflags` \ + $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) + ./pngtestd pngtest.png + +test-installed: + echo + echo Testing installed dynamic shared library. + $(CC) $(SUN_CC_FLAGS) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \ + $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ + libpng-config $(LIBSO) $(LIBSOMAJ)* \ + $(OLDSOVER) \ + libpng.pc + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h +pngerror.o pngerror.pic.o: png.h pngconf.h +pngrio.o pngrio.pic.o: png.h pngconf.h +pngwio.o pngwio.pic.o: png.h pngconf.h +pngmem.o pngmem.pic.o: png.h pngconf.h +pngset.o pngset.pic.o: png.h pngconf.h +pngget.o pngget.pic.o: png.h pngconf.h +pngread.o pngread.pic.o: png.h pngconf.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h +pngpread.o pngpread.pic.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.acorn b/src/dep/src/irrlicht/libpng/scripts/makefile.acorn index 2cc0f32..470cf89 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.acorn +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.acorn @@ -1,51 +1,51 @@ -# Project: libpng - - -# Toolflags: -CCflags = -c -depend !Depend -IC:,Zlib: -g -throwback -DRISCOS -fnah -C++flags = -c -depend !Depend -IC: -throwback -Linkflags = -aif -c++ -o $@ -ObjAsmflags = -throwback -NoCache -depend !Depend -CMHGflags = -LibFileflags = -c -l -o $@ -Squeezeflags = -o $@ - - -# Final targets: -@.libpng-lib: @.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \ - @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngrtran \ - @.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil - LibFile $(LibFileflags) @.o.png @.o.pngerror @.o.pngrio @.o.pngrtran \ - @.o.pngmem @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngwio \ - @.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil -@.mm-libpng-lib: @.mm.png @.mm.pngerror @.mm.pngrio @.mm.pngwio @.mm.pngmem \ - @.mm.pngpread @.mm.pngset @.mm.pngget @.mm.pngread @.mm.pngrtran \ - @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite @.mm.pngwtran @.mm.pngwutil - LibFile $(LibFileflags) @.mm.png @.mm.pngerror @.mm.pngrio \ - @.mm.pngwio @.mm.pngmem @.mm.pngpread @.mm.pngset @.mm.pngget \ - @.mm.pngread @.mm.pngrtran @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite \ - @.mm.pngwtran @.mm.pngwutil - - -# User-editable dependencies: -# (C) Copyright 1997 Tom Tanner -Test: @.pngtest - .pngtest - @remove .pngtest - -#It would be nice if you could stop "make" listing from here on! -@.pngtest: @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib - Link $(Linkflags) @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib - -.SUFFIXES: .o .mm .c - -.c.mm: - MemCheck.CC cc $(ccflags) -o $@ LibPng:$< -.c.o: - cc $(ccflags) -o $@ $< - - -# Static dependencies: - - -# Dynamic dependencies: +# Project: libpng + + +# Toolflags: +CCflags = -c -depend !Depend -IC:,Zlib: -g -throwback -DRISCOS -fnah +C++flags = -c -depend !Depend -IC: -throwback +Linkflags = -aif -c++ -o $@ +ObjAsmflags = -throwback -NoCache -depend !Depend +CMHGflags = +LibFileflags = -c -l -o $@ +Squeezeflags = -o $@ + + +# Final targets: +@.libpng-lib: @.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \ + @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngrtran \ + @.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil + LibFile $(LibFileflags) @.o.png @.o.pngerror @.o.pngrio @.o.pngrtran \ + @.o.pngmem @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngwio \ + @.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil +@.mm-libpng-lib: @.mm.png @.mm.pngerror @.mm.pngrio @.mm.pngwio @.mm.pngmem \ + @.mm.pngpread @.mm.pngset @.mm.pngget @.mm.pngread @.mm.pngrtran \ + @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite @.mm.pngwtran @.mm.pngwutil + LibFile $(LibFileflags) @.mm.png @.mm.pngerror @.mm.pngrio \ + @.mm.pngwio @.mm.pngmem @.mm.pngpread @.mm.pngset @.mm.pngget \ + @.mm.pngread @.mm.pngrtran @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite \ + @.mm.pngwtran @.mm.pngwutil + + +# User-editable dependencies: +# (C) Copyright 1997 Tom Tanner +Test: @.pngtest + .pngtest + @remove .pngtest + +#It would be nice if you could stop "make" listing from here on! +@.pngtest: @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib + Link $(Linkflags) @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib + +.SUFFIXES: .o .mm .c + +.c.mm: + MemCheck.CC cc $(ccflags) -o $@ LibPng:$< +.c.o: + cc $(ccflags) -o $@ $< + + +# Static dependencies: + + +# Dynamic dependencies: diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.aix b/src/dep/src/irrlicht/libpng/scripts/makefile.aix index 4a9be51..42f04bc 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.aix +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.aix @@ -1,113 +1,113 @@ -# makefile for libpng using gcc (generic, static library) -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 2000 Cosmin Truta -# Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc) -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# Location of the zlib library and include files -ZLIBINC = ../zlib -ZLIBLIB = ../zlib - -# Compiler, linker, lib and other tools -CC = gcc -LD = $(CC) -AR_RC = ar rcs -MKDIR_P = mkdir -p -RANLIB = ranlib -RM_F = rm -f -LN_SF = ln -f -s - -LIBNAME=libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) - -CDEBUG = -g -DPNG_DEBUG=5 -LDDEBUG = -CRELEASE = -O2 -LDRELEASE = -s -WARNMORE=-Wall -CFLAGS = -I$(ZLIBINC) $(WARNMORE) $(CRELEASE) -LDFLAGS = -L. -L$(ZLIBLIB) -lpng12 -lz -lm $(LDRELEASE) - -# File extensions -O=.o -A=.a -E= - -# Variables -OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ - pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ - pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) - -# Targets -all: $(LIBNAME)$(A) pngtest$(E) - -$(LIBNAME)$(A): $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -test: pngtest$(E) - ./pngtest$(E) - -pngtest$(E): pngtest$(O) $(LIBNAME)$(A) - $(LD) -o $@ pngtest$(O) $(LDFLAGS) - -install: $(LIBNAME)$(A) - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DI)/$(LIBNAME)/png.h - -@$(RM_F) $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h - -@$(RM_F) $(DI)/pngconf.h - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h \ - $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) -r $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -@$(RM_F) $(DL)/$(LIBNAME)$(A) - -@$(RM_F) $(DL)/libpng$(A) - cp $(LIBNAME)$(A) $(DL)/$(LIBNAME)$(A) - chmod 644 $(DL)/$(LIBNAME)$(A) - (cd $(DL); $(LN_SF) $(LIBNAME)$(A) libpng$(A)) - (cd $(DI); $(LN_SF) libpng/* .;) - -clean: - $(RM_F) *.o $(LIBNAME)$(A) pngtest pngout.png - -png$(O): png.h pngconf.h -pngerror$(O): png.h pngconf.h -pngget$(O): png.h pngconf.h -pngmem$(O): png.h pngconf.h -pngpread$(O): png.h pngconf.h -pngread$(O): png.h pngconf.h -pngrio$(O): png.h pngconf.h -pngrtran$(O): png.h pngconf.h -pngrutil$(O): png.h pngconf.h -pngset$(O): png.h pngconf.h -pngtest$(O): png.h pngconf.h -pngtrans$(O): png.h pngconf.h -pngwio$(O): png.h pngconf.h -pngwrite$(O): png.h pngconf.h -pngwtran$(O): png.h pngconf.h -pngwutil$(O): png.h pngconf.h - +# makefile for libpng using gcc (generic, static library) +# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 2000 Cosmin Truta +# Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc) +# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. +# For conditions of distribution and use, see copyright notice in png.h + +# Location of the zlib library and include files +ZLIBINC = ../zlib +ZLIBLIB = ../zlib + +# Compiler, linker, lib and other tools +CC = gcc +LD = $(CC) +AR_RC = ar rcs +MKDIR_P = mkdir -p +RANLIB = ranlib +RM_F = rm -f +LN_SF = ln -f -s + +LIBNAME=libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +prefix=/usr/local +INCPATH=$(prefix)/include +LIBPATH=$(prefix)/lib + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) + +CDEBUG = -g -DPNG_DEBUG=5 +LDDEBUG = +CRELEASE = -O2 +LDRELEASE = -s +WARNMORE=-Wall +CFLAGS = -I$(ZLIBINC) $(WARNMORE) $(CRELEASE) +LDFLAGS = -L. -L$(ZLIBLIB) -lpng12 -lz -lm $(LDRELEASE) + +# File extensions +O=.o +A=.a +E= + +# Variables +OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ + pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ + pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) + +# Targets +all: $(LIBNAME)$(A) pngtest$(E) + +$(LIBNAME)$(A): $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +test: pngtest$(E) + ./pngtest$(E) + +pngtest$(E): pngtest$(O) $(LIBNAME)$(A) + $(LD) -o $@ pngtest$(O) $(LDFLAGS) + +install: $(LIBNAME)$(A) + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DI)/$(LIBNAME)/png.h + -@$(RM_F) $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h + -@$(RM_F) $(DI)/pngconf.h + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h \ + $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) -r $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + -@$(RM_F) $(DL)/$(LIBNAME)$(A) + -@$(RM_F) $(DL)/libpng$(A) + cp $(LIBNAME)$(A) $(DL)/$(LIBNAME)$(A) + chmod 644 $(DL)/$(LIBNAME)$(A) + (cd $(DL); $(LN_SF) $(LIBNAME)$(A) libpng$(A)) + (cd $(DI); $(LN_SF) libpng/* .;) + +clean: + $(RM_F) *.o $(LIBNAME)$(A) pngtest pngout.png + +png$(O): png.h pngconf.h +pngerror$(O): png.h pngconf.h +pngget$(O): png.h pngconf.h +pngmem$(O): png.h pngconf.h +pngpread$(O): png.h pngconf.h +pngread$(O): png.h pngconf.h +pngrio$(O): png.h pngconf.h +pngrtran$(O): png.h pngconf.h +pngrutil$(O): png.h pngconf.h +pngset$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h +pngtrans$(O): png.h pngconf.h +pngwio$(O): png.h pngconf.h +pngwrite$(O): png.h pngconf.h +pngwtran$(O): png.h pngconf.h +pngwutil$(O): png.h pngconf.h + diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.amiga b/src/dep/src/irrlicht/libpng/scripts/makefile.amiga index e05b395..79cb424 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.amiga +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.amiga @@ -1,48 +1,48 @@ -# Commodore Amiga Makefile -# makefile for libpng and SAS C V6.5x compiler -# Copyright (C) 1995-2000 Wolf Faust -# For conditions of distribution and use, see copyright notice in png.h -# -# Note: Use #define PNG_READ_BIG_ENDIAN_SUPPORTED in pngconf.h -# -# Location/path of zlib include files -ZLIB=/zlib -#compiler -CC=sc -#compiler flags -# WARNING: a bug in V6.51 causes bad code with OPTGO -# So use V6.55 or set NOOPTGO!!!!!!!!! -CFLAGS= NOSTKCHK PARMS=REG OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL\ - OPTLOOP OPTRDEP=4 OPTDEP=4 OPTCOMP=4 INCLUDEDIR=$(ZLIB) \ - DEFINE=PNG_INTERNAL -#linker flags -LDFLAGS= SD ND BATCH -#link libs -LDLIBS= libpng.lib libgz.lib LIB:scm.lib LIB:sc.lib Lib:amiga.lib -# linker -LN= slink -# file deletion command -RM= delete quiet -# library (.lib) file creation command -AR= oml -# make directory command -MKDIR= makedir - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.lib pngtest - -libpng.lib: $(OBJS) --$(RM) libpng.lib -$(AR) libpng.lib r $(OBJS) - -pngtest: pngtest.o libpng.lib -$(LN) libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo libs=\"-lpng12 -lz \"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - cp $(LIBSO)* /boot/home/config/lib - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(CC) -nostart -Wl,-soname,$(LIBSOMAJ) -o \ - $(LIBSOVER) $(OBJSDLL) $(LDFLAGS) - -$(OLDSOVER): $(OBJSDLL) - $(CC) -nostart -Wl,-soname,$(OLDSOMAJ) -o \ - $(OLDSOVER) $(OBJSDLL) $(LDFLAGS) - -pngtest: pngtest.o $(LIBSO) - $(CC) -L$(ZLIBLIB) -L. -lz -lpng12 -o pngtest pngtest.o - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) $(CFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -Wl,-rpath $(ZLIBLIB):$(DL) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBSO) $(LIBSOMAJ)* pngtesti \ - $(OLDSOVER) \ - libpng.pc - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h -pngtest.o: png.h pngconf.h +# makefile for libpng on BeOS x86 ELF with gcc +# modified from makefile.linux by Sander Stoks +# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 1999 Greg Roelofs +# Copyright (C) 1996, 1997 Andreas Dilger +# For conditions of distribution and use, see copyright notice in png.h + +# Library name: +LIBNAME=libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).so +LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) +LIBSOVER=$(LIBNAME).so.$(PNGVER) +OLDSO=libpng.so +OLDSOMAJ=libpng.so.3 +OLDSOVER=libpng.so.3.$(PNGMIN) + +# Utilities: +CC=gcc +AR_RC=ar rc +MKDIR_P=mkdir -p +LN_SF=ln -sf +RANLIB=ranlib +RM_F=/bin/rm -f + +# Where the zlib library and include files are located +ZLIBLIB=/usr/local/lib +ZLIBINC=/usr/local/include + +ALIGN= +# For i386: +# ALIGN=-malign-loops=2 -malign-functions=2 + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion + +# On BeOS, -O1 is actually better than -O3. This is a known bug but it's +# still here in R4.5 +CFLAGS=-I$(ZLIBINC) -Wall -O1 -funroll-loops \ + $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 +# LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz +LDFLAGS=-L. -Wl,-soname=$(LIBSOMAJ) -L$(ZLIBLIB) -lz + +# where make install puts libpng.a, libpng12.so*, and png.h +prefix=/usr/local +exec_prefix=$(prefix) +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +OBJSDLL = $(OBJS) + +.SUFFIXES: .c .o + +all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo libs=\"-lpng12 -lz \"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + cp $(LIBSO)* /boot/home/config/lib + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJSDLL) + $(CC) -nostart -Wl,-soname,$(LIBSOMAJ) -o \ + $(LIBSOVER) $(OBJSDLL) $(LDFLAGS) + +$(OLDSOVER): $(OBJSDLL) + $(CC) -nostart -Wl,-soname,$(OLDSOMAJ) -o \ + $(OLDSOVER) $(OBJSDLL) $(LDFLAGS) + +pngtest: pngtest.o $(LIBSO) + $(CC) -L$(ZLIBLIB) -L. -lz -lpng12 -o pngtest pngtest.o + +test: pngtest + ./pngtest + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) $(CFLAGS) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) -Wl,-rpath $(ZLIBLIB):$(DL) \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + $(CC) $(CFLAGS) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ + $(LIBSO) $(LIBSOMAJ)* pngtesti \ + $(OLDSOVER) \ + libpng.pc + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h +pngerror.o pngerror.pic.o: png.h pngconf.h +pngrio.o pngrio.pic.o: png.h pngconf.h +pngwio.o pngwio.pic.o: png.h pngconf.h +pngmem.o pngmem.pic.o: png.h pngconf.h +pngset.o pngset.pic.o: png.h pngconf.h +pngget.o pngget.pic.o: png.h pngconf.h +pngread.o pngread.pic.o: png.h pngconf.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h +pngpread.o pngpread.pic.o: png.h pngconf.h +pngtest.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.bor b/src/dep/src/irrlicht/libpng/scripts/makefile.bor index 49d6844..a5651aa 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.bor +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.bor @@ -1,162 +1,162 @@ -# Makefile for libpng -# 16-bit Borland C++ (Note: All modules are compiled in C mode) -# To build the library, do: -# "make -fmakefile.bor -DMODEL=c" -# or: "make -fmakefile.bor -DMODEL=l" -# -# ------------ Borland C++ ------------ - -### Absolutely necessary for this makefile to work -.AUTODEPEND - -## Where zlib.h, zconf.h and zlib_MODEL.lib are -ZLIB_DIR=..\zlib - - -## Compiler, linker and lib stuff -CC=bcc -LD=bcc -LIB=tlib - -!ifndef MODEL -MODEL=l -!endif - -MODEL_ARG=-m$(MODEL) - -#TARGET_CPU=3 -# 2 = 286, 3 = 386, etc. -!ifndef TARGET_CPU -TARGET_CPU=2 -!endif - -# Use this if you don't want Borland's fancy exception handling -# (for Borland C++ 4.0 or later) -#NOEHLIB=noeh$(MODEL).lib - -!ifdef DEBUG -CDEBUG=-v -LDEBUG=-v -!else -CDEBUG= -LDEBUG= -!endif - -# STACKOFLOW=1 -!ifdef STACKOFLOW -CDEBUG=$(CDEBUG) -N -LDEBUG=$(LDEBUG) -N -!endif - -# -X- turn on dependency generation in the object file -# -w set all warnings on -# -O2 optimize for speed -# -Z global optimization -CFLAGS=-O2 -Z -X- -w -I$(ZLIB_DIR) -$(TARGET_CPU) $(MODEL_ARG) $(CDEBUG) - -# -M generate map file -LDFLAGS=-M -L$(ZLIB_DIR) $(MODEL_ARG) $(LDEBUG) - - -## Variables -OBJS = \ - png.obj \ - pngerror.obj \ - pngget.obj \ - pngmem.obj \ - pngpread.obj \ - pngread.obj \ - pngrio.obj \ - pngrtran.obj \ - pngrutil.obj \ - pngset.obj \ - pngtrans.obj \ - pngwio.obj \ - pngwrite.obj \ - pngwtran.obj \ - pngwutil.obj - -LIBOBJS = \ - +png.obj \ - +pngerror.obj \ - +pngget.obj \ - +pngmem.obj \ - +pngpread.obj \ - +pngread.obj \ - +pngrio.obj \ - +pngrtran.obj \ - +pngrutil.obj \ - +pngset.obj \ - +pngtrans.obj \ - +pngwio.obj \ - +pngwrite.obj \ - +pngwtran.obj \ - +pngwutil.obj - -LIBNAME=libpng$(MODEL).lib - - -## Implicit rules -# Braces let make "batch" calls to the compiler, -# 2 calls instead of 12; space is important. -.c.obj: - $(CC) $(CFLAGS) -c {$*.c } - -.c.exe: - $(CC) $(CFLAGS) $(LDFLAGS) $*.c $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB) - - -## Major targets -all: libpng pngtest - -libpng: $(LIBNAME) - -pngtest: pngtest$(MODEL).exe - -test: pngtest$(MODEL).exe - pngtest$(MODEL) - - -## Minor Targets - -png.obj: png.c -pngerror.obj: pngerror.c -pngget.obj: pngget.c -pngmem.obj: pngmem.c -pngpread.obj: pngpread.c -pngread.obj: pngread.c -pngrio.obj: pngrio.c -pngrtran.obj: pngrtran.c -pngrutil.obj: pngrutil.c -pngset.obj: pngset.c -pngtrans.obj: pngtrans.c -pngwio.obj: pngwio.c -pngwrite.obj: pngwrite.c -pngwtran.obj: pngwtran.c -pngwutil.obj: pngwutil.c - - -$(LIBNAME): $(OBJS) - -del $(LIBNAME) - $(LIB) $(LIBNAME) @&&| -$(LIBOBJS), libpng$(MODEL) -| - - -pngtest$(MODEL).obj: pngtest.c - $(CC) $(CFLAGS) -opngtest$(MODEL) -c pngtest.c - -pngtest$(MODEL).exe: pngtest$(MODEL).obj - $(LD) $(LDFLAGS) pngtest$(MODEL).obj $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB) - - -# Clean up anything else you want -clean: - -del *.obj - -del *.exe - -del *.lib - -del *.lst - -del *.map - - -# End of makefile for libpng +# Makefile for libpng +# 16-bit Borland C++ (Note: All modules are compiled in C mode) +# To build the library, do: +# "make -fmakefile.bor -DMODEL=c" +# or: "make -fmakefile.bor -DMODEL=l" +# +# ------------ Borland C++ ------------ + +### Absolutely necessary for this makefile to work +.AUTODEPEND + +## Where zlib.h, zconf.h and zlib_MODEL.lib are +ZLIB_DIR=..\zlib + + +## Compiler, linker and lib stuff +CC=bcc +LD=bcc +LIB=tlib + +!ifndef MODEL +MODEL=l +!endif + +MODEL_ARG=-m$(MODEL) + +#TARGET_CPU=3 +# 2 = 286, 3 = 386, etc. +!ifndef TARGET_CPU +TARGET_CPU=2 +!endif + +# Use this if you don't want Borland's fancy exception handling +# (for Borland C++ 4.0 or later) +#NOEHLIB=noeh$(MODEL).lib + +!ifdef DEBUG +CDEBUG=-v +LDEBUG=-v +!else +CDEBUG= +LDEBUG= +!endif + +# STACKOFLOW=1 +!ifdef STACKOFLOW +CDEBUG=$(CDEBUG) -N +LDEBUG=$(LDEBUG) -N +!endif + +# -X- turn on dependency generation in the object file +# -w set all warnings on +# -O2 optimize for speed +# -Z global optimization +CFLAGS=-O2 -Z -X- -w -I$(ZLIB_DIR) -$(TARGET_CPU) $(MODEL_ARG) $(CDEBUG) + +# -M generate map file +LDFLAGS=-M -L$(ZLIB_DIR) $(MODEL_ARG) $(LDEBUG) + + +## Variables +OBJS = \ + png.obj \ + pngerror.obj \ + pngget.obj \ + pngmem.obj \ + pngpread.obj \ + pngread.obj \ + pngrio.obj \ + pngrtran.obj \ + pngrutil.obj \ + pngset.obj \ + pngtrans.obj \ + pngwio.obj \ + pngwrite.obj \ + pngwtran.obj \ + pngwutil.obj + +LIBOBJS = \ + +png.obj \ + +pngerror.obj \ + +pngget.obj \ + +pngmem.obj \ + +pngpread.obj \ + +pngread.obj \ + +pngrio.obj \ + +pngrtran.obj \ + +pngrutil.obj \ + +pngset.obj \ + +pngtrans.obj \ + +pngwio.obj \ + +pngwrite.obj \ + +pngwtran.obj \ + +pngwutil.obj + +LIBNAME=libpng$(MODEL).lib + + +## Implicit rules +# Braces let make "batch" calls to the compiler, +# 2 calls instead of 12; space is important. +.c.obj: + $(CC) $(CFLAGS) -c {$*.c } + +.c.exe: + $(CC) $(CFLAGS) $(LDFLAGS) $*.c $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB) + + +## Major targets +all: libpng pngtest + +libpng: $(LIBNAME) + +pngtest: pngtest$(MODEL).exe + +test: pngtest$(MODEL).exe + pngtest$(MODEL) + + +## Minor Targets + +png.obj: png.c +pngerror.obj: pngerror.c +pngget.obj: pngget.c +pngmem.obj: pngmem.c +pngpread.obj: pngpread.c +pngread.obj: pngread.c +pngrio.obj: pngrio.c +pngrtran.obj: pngrtran.c +pngrutil.obj: pngrutil.c +pngset.obj: pngset.c +pngtrans.obj: pngtrans.c +pngwio.obj: pngwio.c +pngwrite.obj: pngwrite.c +pngwtran.obj: pngwtran.c +pngwutil.obj: pngwutil.c + + +$(LIBNAME): $(OBJS) + -del $(LIBNAME) + $(LIB) $(LIBNAME) @&&| +$(LIBOBJS), libpng$(MODEL) +| + + +pngtest$(MODEL).obj: pngtest.c + $(CC) $(CFLAGS) -opngtest$(MODEL) -c pngtest.c + +pngtest$(MODEL).exe: pngtest$(MODEL).obj + $(LD) $(LDFLAGS) pngtest$(MODEL).obj $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB) + + +# Clean up anything else you want +clean: + -del *.obj + -del *.exe + -del *.lib + -del *.lst + -del *.map + + +# End of makefile for libpng diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.cygwin b/src/dep/src/irrlicht/libpng/scripts/makefile.cygwin index 5e420a5..a7acdf4 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.cygwin +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.cygwin @@ -1,316 +1,316 @@ -# makefile for cygwin on x86 -# Builds both dll (with import lib) and static lib versions -# of the library, and builds two copies of pngtest: one -# statically linked and one dynamically linked. -# -# Copyright (C) 2002, 2006 Soren Anderson, Charles Wilson, -# and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by: -# Copyright (C) 1998-2000 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# This makefile intends to support building outside the src directory -# if desired. When invoking it, specify an argument to SRCDIR on the -# command line that points to the top of the directory where your source -# is located. - -ifdef SRCDIR -VPATH = $(SRCDIR) -else -SRCDIR = . -endif - -# Override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. - -DESTDIR= - -# To enable assembler optimizations, add '-DPNG_USE_PNGGCCRD' to -# $CFLAGS, and include pnggccrd.o in $OBJS, below, and in the dependency -# list at the bottom of this makefile. - -CC=gcc -ifdef MINGW -MINGW_CCFLAGS=-mno-cygwin -I/usr/include/mingw -MINGW_LDFLAGS=-mno-cygwin -L/usr/lib/mingw -endif - -# Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h -ifndef prefix -prefix=/usr -$(warning You haven't specified a 'prefix=' location. Defaulting to "/usr") -endif -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -ZLIBLIB= /usr/lib -ZLIBINC= -#ZLIBLIB=../zlib -#ZLIBINC=../zlib - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -### if you use the asm, add pnggccrd.o to the OBJS list -### -### if you don't need thread safety, but want the asm accel -#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD \ -# $(addprefix -I,$(ZLIBINC)) -Wall -O3 $(ALIGN) -funroll-loops \ -# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 -### if you need thread safety and want (minimal) asm accel -#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_USE_PNGGCCRD $(addprefix -I,$(ZLIBINC)) \ -# -Wall -O3 $(ALIGN) -funroll-loops \ -# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 -### Normal (non-asm) compilation -CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ - -Wall -O3 $(ALIGN) -funroll-loops \ - -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 - -LIBNAME = libpng12 -PNGMAJ = 0 -CYGDLL = 12 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -SHAREDLIB=cygpng$(CYGDLL).dll -STATLIB=libpng.a -IMPLIB=libpng.dll.a -SHAREDDEF=libpng.def -LIBS=$(SHAREDLIB) $(STATLIB) -EXE=.exe - -LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz) -LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS) -Wl,--export-all) -LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz - -MKDIR_P=/bin/mkdir -pv -RANLIB=ranlib -#RANLIB=echo - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib - -BINPATH=$(exec_prefix)/bin -MANPATH=$(prefix)/man -MAN3PATH=$(MANPATH)/man3 -MAN5PATH=$(MANPATH)/man5 - -# cosmetic: shortened strings: -S =$(SRCDIR) -D =$(DESTDIR) -DB =$(D)$(BINPATH) -DI =$(D)$(INCPATH) -DL =$(D)$(LIBPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o # pnggccrd.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -%.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< -%.pic.o : CFLAGS += -DPNG_BUILD_DLL -%.pic.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< - -all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config - -# Make this to verify that "make [...] install" will do what you want. -buildsetup-tell: - @echo VPATH is set to: \"$(VPATH)\" - @echo prefix is set to: \"$(prefix)\" - @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \ - $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \ - $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n' - -libpng.pc: scripts/libpng.pc.in - @echo -e Making pkg-config file for this libpng installation..'\n' \ - using PREFIX=\"$(prefix)\"'\n' - cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \ - sed -e s/-lm// > libpng.pc - -libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in - @echo -e Making $(LIBNAME) libpng-config file for this libpng \ - installation..'\n' using PREFIX=\"$(prefix)\"'\n' - ( cat $(S)/scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng$(CYGDLL) -lz\"; \ - cat $(S)/scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -static: all-static -shared: all-shared -all-static: $(STATLIB) pngtest-stat$(EXE) -all-shared: $(SHAREDLIB) pngtest$(EXE) - -pnggccrd.o: pnggccrd.c png.h pngconf.h - @echo "" - @echo ' You can ignore the "control reaches end of non-void function"' - @echo ' warning and " defined but not used" warnings:' - @echo "" - $(CC) -c $(CFLAGS) -o $@ $< - -pnggccrd.pic.o: pnggccrd.c png.h pngconf.h - @echo "" - @echo ' You can ignore the "control reaches end of non-void function"' - @echo ' warning and " defined but not used" warnings:' - @echo "" - $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $< - -$(STATLIB): $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -$(SHAREDDEF): scripts/pngw32.def - cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \ - sed -e 's/\([^;]*\);/;/' > $@ - -$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF) - $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA) - -pngtest$(EXE): pngtest.pic.o $(SHAREDLIB) - $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ - -pngtest-stat$(EXE): pngtest.o $(STATLIB) - $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@ - -pngtest.pic.o: pngtest.c - $(CC) $(CFLAGS) -c $< -o $@ - -pngtest.o: pngtest.c - $(CC) $(CFLAGS) -c $< -o $@ - -test: test-static test-shared - -test-static: pngtest-stat$(EXE) - ./pngtest-stat $(S)/pngtest.png - -test-shared: pngtest$(EXE) - ./pngtest $(S)/pngtest.png - -install-static: $(STATLIB) install-headers install-man - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a - -@rm -f $(DL)/$(STATLIB) - (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB)) - -install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a - -@rm -f $(DL)/$(IMPLIB) - (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB)) - install -s -m 755 $(SHAREDLIB) $(DB) - install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-headers: - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - -@rm -f $(DI)/png.h - -@rm -f $(DI)/pngconf.h - install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME) - -@rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-man: - -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR_P) $(D)$(MAN3PATH); fi - -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR_P) $(D)$(MAN5PATH); fi - install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH) - install -m 644 $(S)/png.5 $(D)$(MAN5PATH) - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -# Run this to verify that a future `configure' run will pick up the settings -# you want. -test-config-install: SHELL=/bin/bash -test-config-install: $(DB)/libpng-config - @echo -e Testing libpng-config functions...'\n' - @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \ - do \ - printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \ - "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \ - gytiu=$$(( $$gytiu + 1 )); \ - done - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) $(CFLAGS) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/libpng12-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti$(EXE) `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti$(EXE) pngtest.png - -clean: - /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \ - pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \ - libpng-config libpng.pc pngtesti$(EXE) - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -.PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h png.c -pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c -pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c -pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c -pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c -pngset.o pngset.pic.o: png.h pngconf.h pngset.c -pngget.o pngget.pic.o: png.h pngconf.h pngget.c -pngread.o pngread.pic.o: png.h pngconf.h pngread.c -pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c -pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c -pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c -pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c -pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c -pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c -pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c - -pngtest.o: png.h pngconf.h pngtest.c -pngtest-stat.o: png.h pngconf.h pngtest.c - - - +# makefile for cygwin on x86 +# Builds both dll (with import lib) and static lib versions +# of the library, and builds two copies of pngtest: one +# statically linked and one dynamically linked. +# +# Copyright (C) 2002, 2006 Soren Anderson, Charles Wilson, +# and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by: +# Copyright (C) 1998-2000 Greg Roelofs +# Copyright (C) 1996, 1997 Andreas Dilger +# For conditions of distribution and use, see copyright notice in png.h + +# This makefile intends to support building outside the src directory +# if desired. When invoking it, specify an argument to SRCDIR on the +# command line that points to the top of the directory where your source +# is located. + +ifdef SRCDIR +VPATH = $(SRCDIR) +else +SRCDIR = . +endif + +# Override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. + +DESTDIR= + +# To enable assembler optimizations, add '-DPNG_USE_PNGGCCRD' to +# $CFLAGS, and include pnggccrd.o in $OBJS, below, and in the dependency +# list at the bottom of this makefile. + +CC=gcc +ifdef MINGW +MINGW_CCFLAGS=-mno-cygwin -I/usr/include/mingw +MINGW_LDFLAGS=-mno-cygwin -L/usr/lib/mingw +endif + +# Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h +ifndef prefix +prefix=/usr +$(warning You haven't specified a 'prefix=' location. Defaulting to "/usr") +endif +exec_prefix=$(prefix) + +# Where the zlib library and include files are located +ZLIBLIB= /usr/lib +ZLIBINC= +#ZLIBLIB=../zlib +#ZLIBINC=../zlib + +ALIGN= +# for i386: +#ALIGN=-malign-loops=2 -malign-functions=2 + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion + +### if you use the asm, add pnggccrd.o to the OBJS list +### +### if you don't need thread safety, but want the asm accel +#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD \ +# $(addprefix -I,$(ZLIBINC)) -Wall -O3 $(ALIGN) -funroll-loops \ +# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 +### if you need thread safety and want (minimal) asm accel +#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_USE_PNGGCCRD $(addprefix -I,$(ZLIBINC)) \ +# -Wall -O3 $(ALIGN) -funroll-loops \ +# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 +### Normal (non-asm) compilation +CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ + -Wall -O3 $(ALIGN) -funroll-loops \ + -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 + +LIBNAME = libpng12 +PNGMAJ = 0 +CYGDLL = 12 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +SHAREDLIB=cygpng$(CYGDLL).dll +STATLIB=libpng.a +IMPLIB=libpng.dll.a +SHAREDDEF=libpng.def +LIBS=$(SHAREDLIB) $(STATLIB) +EXE=.exe + +LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz) +LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS) -Wl,--export-all) +LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz + +MKDIR_P=/bin/mkdir -pv +RANLIB=ranlib +#RANLIB=echo + +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib + +BINPATH=$(exec_prefix)/bin +MANPATH=$(prefix)/man +MAN3PATH=$(MANPATH)/man3 +MAN5PATH=$(MANPATH)/man5 + +# cosmetic: shortened strings: +S =$(SRCDIR) +D =$(DESTDIR) +DB =$(D)$(BINPATH) +DI =$(D)$(INCPATH) +DL =$(D)$(LIBPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o # pnggccrd.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +%.o : %.c + $(CC) -c $(CFLAGS) -o $@ $< +%.pic.o : CFLAGS += -DPNG_BUILD_DLL +%.pic.o : %.c + $(CC) -c $(CFLAGS) -o $@ $< + +all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config + +# Make this to verify that "make [...] install" will do what you want. +buildsetup-tell: + @echo VPATH is set to: \"$(VPATH)\" + @echo prefix is set to: \"$(prefix)\" + @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \ + $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \ + $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n' + +libpng.pc: scripts/libpng.pc.in + @echo -e Making pkg-config file for this libpng installation..'\n' \ + using PREFIX=\"$(prefix)\"'\n' + cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \ + sed -e s/-lm// > libpng.pc + +libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in + @echo -e Making $(LIBNAME) libpng-config file for this libpng \ + installation..'\n' using PREFIX=\"$(prefix)\"'\n' + ( cat $(S)/scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo libs=\"-lpng$(CYGDLL) -lz\"; \ + cat $(S)/scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +static: all-static +shared: all-shared +all-static: $(STATLIB) pngtest-stat$(EXE) +all-shared: $(SHAREDLIB) pngtest$(EXE) + +pnggccrd.o: pnggccrd.c png.h pngconf.h + @echo "" + @echo ' You can ignore the "control reaches end of non-void function"' + @echo ' warning and " defined but not used" warnings:' + @echo "" + $(CC) -c $(CFLAGS) -o $@ $< + +pnggccrd.pic.o: pnggccrd.c png.h pngconf.h + @echo "" + @echo ' You can ignore the "control reaches end of non-void function"' + @echo ' warning and " defined but not used" warnings:' + @echo "" + $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $< + +$(STATLIB): $(OBJS) + ar rc $@ $(OBJS) + $(RANLIB) $@ + +$(SHAREDDEF): scripts/pngw32.def + cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \ + sed -e 's/\([^;]*\);/;/' > $@ + +$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF) + $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA) + +pngtest$(EXE): pngtest.pic.o $(SHAREDLIB) + $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ + +pngtest-stat$(EXE): pngtest.o $(STATLIB) + $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@ + +pngtest.pic.o: pngtest.c + $(CC) $(CFLAGS) -c $< -o $@ + +pngtest.o: pngtest.c + $(CC) $(CFLAGS) -c $< -o $@ + +test: test-static test-shared + +test-static: pngtest-stat$(EXE) + ./pngtest-stat $(S)/pngtest.png + +test-shared: pngtest$(EXE) + ./pngtest $(S)/pngtest.png + +install-static: $(STATLIB) install-headers install-man + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a + -@rm -f $(DL)/$(STATLIB) + (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB)) + +install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc + -@/bin/rm -f $(DL)/pkgconfig/libpng.pc + install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a + -@rm -f $(DL)/$(IMPLIB) + (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB)) + install -s -m 755 $(SHAREDLIB) $(DB) + install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) + +install-headers: + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + -@rm -f $(DI)/png.h + -@rm -f $(DI)/pngconf.h + install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME) + -@rm -f $(DI)/libpng + (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) + +install-man: + -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR_P) $(D)$(MAN3PATH); fi + -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR_P) $(D)$(MAN5PATH); fi + install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH) + install -m 644 $(S)/png.5 $(D)$(MAN5PATH) + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@/bin/rm -f $(DB)/libpng-config + -@/bin/rm -f $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) + +# Run this to verify that a future `configure' run will pick up the settings +# you want. +test-config-install: SHELL=/bin/bash +test-config-install: $(DB)/libpng-config + @echo -e Testing libpng-config functions...'\n' + @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \ + do \ + printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \ + "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \ + gytiu=$$(( $$gytiu + 1 )); \ + done + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) $(CFLAGS) \ + `$(BINPATH)/libpng12-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) \ + -o pngtestd `$(BINPATH)/libpng12-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + $(CC) $(CFLAGS) \ + `$(BINPATH)/libpng12-config --cflags` pngtest.c \ + -L$(ZLIBLIB) \ + -o pngtesti$(EXE) `$(BINPATH)/libpng12-config --ldflags` + ./pngtesti$(EXE) pngtest.png + +clean: + /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \ + pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \ + libpng-config libpng.pc pngtesti$(EXE) + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +.PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h png.c +pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c +pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c +pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c +pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c +pngset.o pngset.pic.o: png.h pngconf.h pngset.c +pngget.o pngget.pic.o: png.h pngconf.h pngget.c +pngread.o pngread.pic.o: png.h pngconf.h pngread.c +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c +pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c + +pngtest.o: png.h pngconf.h pngtest.c +pngtest-stat.o: png.h pngconf.h pngtest.c + + + diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.darwin b/src/dep/src/irrlicht/libpng/scripts/makefile.darwin index ba406bf..965a9b5 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.darwin +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.darwin @@ -1,230 +1,230 @@ -# makefile for libpng on Darwin / Mac OS X -# Copyright (C) 2002, 2004, 2006 Glenn Randers-Pehrson -# Copyright (C) 2001 Christoph Pfisterer -# derived from makefile.linux: -# Copyright (C) 1998, 1999 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# where "make install" puts libpng.a, libpng12.dylib, png.h and pngconf.h -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).dylib -LIBSOMAJ=$(LIBNAME).$(PNGMAJ).dylib -LIBSOVER=$(LIBNAME).$(PNGVER).dylib -OLDSO=libpng.dylib -OLDSOMAJ=libpng.3.dylib -OLDSOVER=libpng.3.$(PNGMIN).dylib - -# Utilities: -CC=cc -AR_RC=ar rc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fno-common -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \ - sed -e s/-lm// > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(CC) -dynamiclib \ - -install_name $(LIBPATH)/$(LIBSOMAJ) \ - -current_version $(PNGVER) -compatibility_version $(PNGVER) \ - -o $(LIBSOVER) \ - $(OBJSDLL) -L$(ZLIBLIB) -lz - -$(OLDSOVER): $(OBJSDLL) - $(CC) -dynamiclib \ - -install_name $(LIBPATH)/$(OLDSOMAJ) \ - -current_version 3 -compatibility_version 3 \ - -o $(OLDSOVER) \ - $(OBJSDLL) -L$(ZLIBLIB) -lz - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - $(RANLIB) $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSO) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBNAME).$(PNGVER)*.dylib - -@$(RM_F) $(DL)/$(LIBNAME).$(PNGMAJ)*.dylib - -@$(RM_F) $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/libpng.3.$(PNGMIN)*.dylib - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ - $(OLDSOVER) \ - libpng.pc $(LIBNAME).*dylib pngtesti - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h +# makefile for libpng on Darwin / Mac OS X +# Copyright (C) 2002, 2004, 2006 Glenn Randers-Pehrson +# Copyright (C) 2001 Christoph Pfisterer +# derived from makefile.linux: +# Copyright (C) 1998, 1999 Greg Roelofs +# Copyright (C) 1996, 1997 Andreas Dilger +# For conditions of distribution and use, see copyright notice in png.h + +# where "make install" puts libpng.a, libpng12.dylib, png.h and pngconf.h +prefix=/usr/local +exec_prefix=$(prefix) + +# Where the zlib library and include files are located +#ZLIBLIB=/usr/local/lib +#ZLIBINC=/usr/local/include +ZLIBLIB=../zlib +ZLIBINC=../zlib + +# Library name: +LIBNAME = libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).dylib +LIBSOMAJ=$(LIBNAME).$(PNGMAJ).dylib +LIBSOVER=$(LIBNAME).$(PNGVER).dylib +OLDSO=libpng.dylib +OLDSOMAJ=libpng.3.dylib +OLDSOVER=libpng.3.$(PNGMIN).dylib + +# Utilities: +CC=cc +AR_RC=ar rc +MKDIR_P=mkdir -p +LN_SF=ln -sf +RANLIB=ranlib +RM_F=/bin/rm -f + +CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops +LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz + +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +.c.pic.o: + $(CC) -c $(CFLAGS) -fno-common -o $@ $*.c + +all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \ + sed -e s/-lm// > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo libs=\"-lpng12 -lz\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJSDLL) + $(CC) -dynamiclib \ + -install_name $(LIBPATH)/$(LIBSOMAJ) \ + -current_version $(PNGVER) -compatibility_version $(PNGVER) \ + -o $(LIBSOVER) \ + $(OBJSDLL) -L$(ZLIBLIB) -lz + +$(OLDSOVER): $(OBJSDLL) + $(CC) -dynamiclib \ + -install_name $(LIBPATH)/$(OLDSOMAJ) \ + -current_version 3 -compatibility_version 3 \ + -o $(OLDSOVER) \ + $(OBJSDLL) -L$(ZLIBLIB) -lz + +pngtest: pngtest.o $(LIBSO) + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + $(RANLIB) $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSO) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBNAME).$(PNGVER)*.dylib + -@$(RM_F) $(DL)/$(LIBNAME).$(PNGMAJ)*.dylib + -@$(RM_F) $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/libpng.3.$(PNGMIN)*.dylib + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + $(CC) $(CFLAGS) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(ZLIBLIB) \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ + $(OLDSOVER) \ + libpng.pc $(LIBNAME).*dylib pngtesti + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h +pngerror.o pngerror.pic.o: png.h pngconf.h +pngrio.o pngrio.pic.o: png.h pngconf.h +pngwio.o pngwio.pic.o: png.h pngconf.h +pngmem.o pngmem.pic.o: png.h pngconf.h +pngset.o pngset.pic.o: png.h pngconf.h +pngget.o pngget.pic.o: png.h pngconf.h +pngread.o pngread.pic.o: png.h pngconf.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h +pngpread.o pngpread.pic.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.dec b/src/dep/src/irrlicht/libpng/scripts/makefile.dec index 8fd1a4a..0c49ea5 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.dec +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.dec @@ -1,210 +1,210 @@ -# makefile for libpng on DEC Alpha Unix -# Copyright (C) 2000-2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) -LIBNAME = libpng12 - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=cc -MKDIR_P=mkdir -LN_SF=ln -f -s -RANLIB=ranlib -RM_F=/bin/rm -f - -# where make install puts libpng.a and png.h -prefix=/usr/local -exec_prefix=$(prefix) -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -CFLAGS=-std -w1 -I$(ZLIBINC) -O # -g -DPNG_DEBUG=1 -LDFLAGS=-L$(ZLIBLIB) -rpath $(ZLIBLIB) libpng.a -lz -lm - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: $(LIBSO) libpng.a pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo ccopts=\"-std\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJS) - $(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) \ - -soname $(LIBSOMAJ) - -$(OLDSOVER): $(OBJS) - $(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) \ - -soname $(OLDSOMAJ) - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); $(LN_SF)(LIBNAME) libpng; $(LN_SF)(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); $(LN_SF)(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@/bin/rm -f $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@/bin/rm -f $(DL)/$(LIBSOMAJ) - -@/bin/rm -f $(DL)/$(OLDSO) - -@/bin/rm -f $(DL)/$(OLDSOMAJ) - -@/bin/rm -f $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF)(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF)(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF)(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF)(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -w1 -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -R$(ZLIBLIB) -R$(DL) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -w1 -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -R$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - /bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h - +# makefile for libpng on DEC Alpha Unix +# Copyright (C) 2000-2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. +# For conditions of distribution and use, see copyright notice in png.h + +# Library name: +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) +LIBNAME = libpng12 + +# Shared library names: +LIBSO=$(LIBNAME).so +LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) +LIBSOVER=$(LIBNAME).so.$(PNGVER) +OLDSO=libpng.so +OLDSOMAJ=libpng.so.3 +OLDSOVER=libpng.so.3.$(PNGMIN) + +# Utilities: +AR_RC=ar rc +CC=cc +MKDIR_P=mkdir +LN_SF=ln -f -s +RANLIB=ranlib +RM_F=/bin/rm -f + +# where make install puts libpng.a and png.h +prefix=/usr/local +exec_prefix=$(prefix) +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +# Where the zlib library and include files are located +#ZLIBLIB=/usr/local/lib +#ZLIBINC=/usr/local/include +ZLIBLIB=../zlib +ZLIBINC=../zlib + +CFLAGS=-std -w1 -I$(ZLIBINC) -O # -g -DPNG_DEBUG=1 +LDFLAGS=-L$(ZLIBLIB) -rpath $(ZLIBLIB) libpng.a -lz -lm + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +all: $(LIBSO) libpng.a pngtest libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo ccopts=\"-std\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo libs=\"-lpng12 -lz -lm\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJS) + $(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) \ + -soname $(LIBSOMAJ) + +$(OLDSOVER): $(OBJS) + $(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) \ + -soname $(OLDSOMAJ) + +pngtest: pngtest.o libpng.a + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h + -@/bin/rm -f $(DI)/libpng + (cd $(DI); $(LN_SF)(LIBNAME) libpng; $(LN_SF)(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@/bin/rm -f $(DL)/libpng.a + (cd $(DL); $(LN_SF)(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@/bin/rm -f $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@/bin/rm -f $(DL)/$(LIBSOMAJ) + -@/bin/rm -f $(DL)/$(OLDSO) + -@/bin/rm -f $(DL)/$(OLDSOMAJ) + -@/bin/rm -f $(DL)/$(OLDSOVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF)(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF)(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc + -@/bin/rm -f $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF)(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@/bin/rm -f $(DM)/man3/libpng.3 + -@/bin/rm -f $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@/bin/rm -f $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@/bin/rm -f $(DB)/libpng-config + -@/bin/rm -f $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF)(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -w1 -I$(DI) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) -R$(ZLIBLIB) -R$(DL) \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + echo + echo Testing installed dynamic shared library. + $(CC) -w1 -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(ZLIBLIB) -R$(ZLIBLIB) \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtesti pngtest.png + +clean: + /bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \ + libpng-config $(LIBSO) $(LIBSOMAJ)* \ + $(OLDSOVER) \ + libpng.pc + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o: png.h pngconf.h +pngerror.o: png.h pngconf.h +pngrio.o: png.h pngconf.h +pngwio.o: png.h pngconf.h +pngmem.o: png.h pngconf.h +pngset.o: png.h pngconf.h +pngget.o: png.h pngconf.h +pngread.o: png.h pngconf.h +pngrtran.o: png.h pngconf.h +pngrutil.o: png.h pngconf.h +pngtest.o: png.h pngconf.h +pngtrans.o: png.h pngconf.h +pngwrite.o: png.h pngconf.h +pngwtran.o: png.h pngconf.h +pngwutil.o: png.h pngconf.h +pngpread.o: png.h pngconf.h + diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.dj2 b/src/dep/src/irrlicht/libpng/scripts/makefile.dj2 index 146d409..09045c2 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.dj2 +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.dj2 @@ -1,55 +1,55 @@ -# DJGPP (DOS gcc) makefile for libpng -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# where make install will put libpng.a and png.h -#prefix=/usr/local -prefix=. -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -CC=gcc -CFLAGS=-I../zlib -O -LDFLAGS=-L. -L../zlib/ -lpng -lz -lm - -RANLIB=ranlib - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o pngwtran.o \ - pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - coff2exe pngtest - -test: pngtest - ./pngtest -clean: - rm -f *.o libpng.a pngtest pngout.png - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h - +# DJGPP (DOS gcc) makefile for libpng +# Copyright (C) 2002 Glenn Randers-Pehrson +# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. +# For conditions of distribution and use, see copyright notice in png.h + +# where make install will put libpng.a and png.h +#prefix=/usr/local +prefix=. +INCPATH=$(prefix)/include +LIBPATH=$(prefix)/lib + +CC=gcc +CFLAGS=-I../zlib -O +LDFLAGS=-L. -L../zlib/ -lpng -lz -lm + +RANLIB=ranlib + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o pngwtran.o \ + pngmem.o pngerror.o pngpread.o + +all: libpng.a pngtest + +libpng.a: $(OBJS) + ar rc $@ $(OBJS) + $(RANLIB) $@ + +pngtest: pngtest.o libpng.a + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + coff2exe pngtest + +test: pngtest + ./pngtest +clean: + rm -f *.o libpng.a pngtest pngout.png + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o: png.h pngconf.h +pngerror.o: png.h pngconf.h +pngrio.o: png.h pngconf.h +pngwio.o: png.h pngconf.h +pngmem.o: png.h pngconf.h +pngset.o: png.h pngconf.h +pngget.o: png.h pngconf.h +pngread.o: png.h pngconf.h +pngpread.o: png.h pngconf.h +pngrtran.o: png.h pngconf.h +pngrutil.o: png.h pngconf.h +pngtest.o: png.h pngconf.h +pngtrans.o: png.h pngconf.h +pngwrite.o: png.h pngconf.h +pngwtran.o: png.h pngconf.h +pngwutil.o: png.h pngconf.h + diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.elf b/src/dep/src/irrlicht/libpng/scripts/makefile.elf index 810671f..07203f3 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.elf +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.elf @@ -1,271 +1,271 @@ -# makefile for libpng.a and libpng12.so on Linux ELF with gcc -# Copyright (C) 1998, 1999, 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Modified for Debian by Junichi Uekawa and Josselin Mouette -# Major modifications are: -# * link libpng explicitly with libz and libm -# * $(OLDSO).3 is a symlink rather than a different library -# * versioned symbols - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=gcc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -# where "make install" puts libpng12.a, libpng12.so*, -# libpng12/png.h and libpng12/pngconf.h -# Prefix must be a full pathname. -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located. -ZLIBLIB=/usr/local/lib -ZLIBINC=/usr/local/include -# ZLIBLIB=../zlib -# ZLIBINC=../zlib - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -CFLAGS=-Wall -D_REENTRANT -O2 \ - $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 - -LDFLAGS=-L. -lpng12 -LDFLAGS_A=libpng.a -lz -lm -LIBADDFLAGS=-lz -lm - - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng.syms: png.h pngconf.h - $(CC) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\ - awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG12_%s {global:\n",PNGMAJ)}\ - { for (i=1;i+2<=NF;++i)\ - if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\ - print $$(i+1) ";";\ - for (i=1;i+1<=NF;++i)\ - if ($$(i)=="PNG_DATA_EXPORT")\ - print $$(i+1) ";";}\ - END{print "local: *; };"}' >$@.new - $(RM_F) $@ - mv $@.new $@ - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"\"; \ - echo R_opts=\"\"; \ - echo libs=\"-lpng12\"; \ - echo all_libs=\"-lpng12 $(LIBADDFLAGS)\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) libpng.syms - $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \ - -Wl,-version-script,libpng.syms \ - -o $(LIBSOVER) \ - $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) libpng.syms - $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \ - -Wl,-version-script,libpng.syms \ - -o $(OLDSOVER) \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -pngtest-static: pngtest.o libpng.a - $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) - -test: pngtest pngtest-static - @echo "" - @echo " Running pngtest dynamically linked with $(LIBSO):" - @echo "" - LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" ./pngtest - @echo "" - @echo " Running pngtest statically linked with libpng.a:" - @echo "" - ./pngtest-static - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a libpng.syms pngtest pngout.png libpng-config \ - $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h +# makefile for libpng.a and libpng12.so on Linux ELF with gcc +# Copyright (C) 1998, 1999, 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson +# Copyright (C) 1996, 1997 Andreas Dilger +# For conditions of distribution and use, see copyright notice in png.h + +# Modified for Debian by Junichi Uekawa and Josselin Mouette +# Major modifications are: +# * link libpng explicitly with libz and libm +# * $(OLDSO).3 is a symlink rather than a different library +# * versioned symbols + +# Library name: +LIBNAME = libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).so +LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) +LIBSOVER=$(LIBNAME).so.$(PNGVER) +OLDSO=libpng.so +OLDSOMAJ=libpng.so.3 +OLDSOVER=libpng.so.3.$(PNGMIN) + +# Utilities: +AR_RC=ar rc +CC=gcc +MKDIR_P=mkdir -p +LN_SF=ln -sf +RANLIB=ranlib +RM_F=/bin/rm -f + +# where "make install" puts libpng12.a, libpng12.so*, +# libpng12/png.h and libpng12/pngconf.h +# Prefix must be a full pathname. +prefix=/usr/local +exec_prefix=$(prefix) + +# Where the zlib library and include files are located. +ZLIBLIB=/usr/local/lib +ZLIBINC=/usr/local/include +# ZLIBLIB=../zlib +# ZLIBINC=../zlib + +ALIGN= +# for i386: +#ALIGN=-malign-loops=2 -malign-functions=2 + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion + +# for pgcc version 2.95.1, -O3 is buggy; don't use it. + +CFLAGS=-Wall -D_REENTRANT -O2 \ + $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 + +LDFLAGS=-L. -lpng12 +LDFLAGS_A=libpng.a -lz -lm +LIBADDFLAGS=-lz -lm + + +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +.c.pic.o: + $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c + +all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng.syms: png.h pngconf.h + $(CC) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\ + awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG12_%s {global:\n",PNGMAJ)}\ + { for (i=1;i+2<=NF;++i)\ + if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\ + print $$(i+1) ";";\ + for (i=1;i+1<=NF;++i)\ + if ($$(i)=="PNG_DATA_EXPORT")\ + print $$(i+1) ";";}\ + END{print "local: *; };"}' >$@.new + $(RM_F) $@ + mv $@.new $@ + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo L_opts=\"\"; \ + echo R_opts=\"\"; \ + echo libs=\"-lpng12\"; \ + echo all_libs=\"-lpng12 $(LIBADDFLAGS)\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJSDLL) libpng.syms + $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \ + -Wl,-version-script,libpng.syms \ + -o $(LIBSOVER) \ + $(OBJSDLL) + +$(OLDSOVER): $(OBJSDLL) libpng.syms + $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \ + -Wl,-version-script,libpng.syms \ + -o $(OLDSOVER) \ + $(OBJSDLL) + +pngtest: pngtest.o $(LIBSO) + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +pngtest-static: pngtest.o libpng.a + $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) + +test: pngtest pngtest-static + @echo "" + @echo " Running pngtest dynamically linked with $(LIBSO):" + @echo "" + LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" ./pngtest + @echo "" + @echo " Running pngtest statically linked with libpng.a:" + @echo "" + ./pngtest-static + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + $(CC) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a libpng.syms pngtest pngout.png libpng-config \ + $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ + $(OLDSOVER) \ + libpng.pc + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h +pngerror.o pngerror.pic.o: png.h pngconf.h +pngrio.o pngrio.pic.o: png.h pngconf.h +pngwio.o pngwio.pic.o: png.h pngconf.h +pngmem.o pngmem.pic.o: png.h pngconf.h +pngset.o pngset.pic.o: png.h pngconf.h +pngget.o pngget.pic.o: png.h pngconf.h +pngread.o pngread.pic.o: png.h pngconf.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h +pngpread.o pngpread.pic.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.freebsd b/src/dep/src/irrlicht/libpng/scripts/makefile.freebsd index 8767ce3..7821e38 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.freebsd +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.freebsd @@ -1,48 +1,48 @@ -# makefile for libpng under FreeBSD -# Copyright (C) 2002, 2007 Glenn Randers-Pehrson and Andrey A. Chernov -# For conditions of distribution and use, see copyright notice in png.h - -PREFIX?= /usr/local -SHLIB_VER?= 5 - -LIB= png -SHLIB_MAJOR= ${SHLIB_VER} -SHLIB_MINOR= 0 -NOPROFILE= YES -NOOBJ= YES - -# where make install puts libpng.a and png.h -DESTDIR= ${PREFIX} -LIBDIR= /lib -INCS= png.h pngconf.h -INCSDIR= /include/libpng -INCDIR= ${INCSDIR} # for 4.x bsd.lib.mk -MAN= libpng.3 libpngpf.3 png.5 -MANDIR= /man/man -SYMLINKS= libpng/png.h ${INCSDIR}/../png.h \ - libpng/pngconf.h ${INCSDIR}/../pngconf.h -LDADD+= -lm -lz -DPADD+= ${LIBM} ${LIBZ} - -CFLAGS+= -I. -DPNG_USE_PNGGCCRD -.if (${MACHINE_ARCH} != "i386") -CFLAGS+= -DPNG_NO_MMX_CODE -.endif - -SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ - pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ - pngwtran.c pngmem.c pngerror.c pngpread.c pnggccrd.c - -pngtest: pngtest.o libpng.a - ${CC} ${CFLAGS} -L. -static -o pngtest pngtest.o -lpng -lz -lm - -CLEANFILES= pngtest pngtest.o pngout.png - -test: pngtest - ./pngtest - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -.include +# makefile for libpng under FreeBSD +# Copyright (C) 2002, 2007 Glenn Randers-Pehrson and Andrey A. Chernov +# For conditions of distribution and use, see copyright notice in png.h + +PREFIX?= /usr/local +SHLIB_VER?= 5 + +LIB= png +SHLIB_MAJOR= ${SHLIB_VER} +SHLIB_MINOR= 0 +NOPROFILE= YES +NOOBJ= YES + +# where make install puts libpng.a and png.h +DESTDIR= ${PREFIX} +LIBDIR= /lib +INCS= png.h pngconf.h +INCSDIR= /include/libpng +INCDIR= ${INCSDIR} # for 4.x bsd.lib.mk +MAN= libpng.3 libpngpf.3 png.5 +MANDIR= /man/man +SYMLINKS= libpng/png.h ${INCSDIR}/../png.h \ + libpng/pngconf.h ${INCSDIR}/../pngconf.h +LDADD+= -lm -lz +DPADD+= ${LIBM} ${LIBZ} + +CFLAGS+= -I. -DPNG_USE_PNGGCCRD +.if (${MACHINE_ARCH} != "i386") +CFLAGS+= -DPNG_NO_MMX_CODE +.endif + +SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ + pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ + pngwtran.c pngmem.c pngerror.c pngpread.c pnggccrd.c + +pngtest: pngtest.o libpng.a + ${CC} ${CFLAGS} -L. -static -o pngtest pngtest.o -lpng -lz -lm + +CLEANFILES= pngtest pngtest.o pngout.png + +test: pngtest + ./pngtest + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +.include diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.gcc b/src/dep/src/irrlicht/libpng/scripts/makefile.gcc index 0ca7a86..e899b10 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.gcc +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.gcc @@ -1,79 +1,79 @@ -# makefile for libpng using gcc (generic, static library) -# Copyright (C) 2000 Cosmin Truta -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# Location of the zlib library and include files -ZLIBINC = ../zlib -ZLIBLIB = ../zlib - -# Compiler, linker, lib and other tools -CC = gcc -LD = $(CC) -AR_RC = ar rcs -RANLIB = ranlib -RM_F = rm -f - -CDEBUG = -g -DPNG_DEBUG=5 -LDDEBUG = -CRELEASE = -O2 -LDRELEASE = -s -#CFLAGS = -Wall $(CDEBUG) -CFLAGS = -Wall $(CRELEASE) -#LDFLAGS = $(LDDEBUG) -LDFLAGS = $(LDRELEASE) -LIBS = -lz -lm - -# File extensions -O=.o -A=.a -EXE= - -# Variables -OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ - pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ - pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) - -# Targets -all: static - -.c$(O): - $(CC) -c $(CFLAGS) -I$(ZLIBINC) $< - -static: libpng$(A) pngtest$(EXE) - -shared: - @echo This is a generic makefile that cannot create shared libraries. - @echo Please use a configuration that is specific to your platform. - @false - -libpng$(A): $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -test: pngtest$(EXE) - ./pngtest$(EXE) - -pngtest$(EXE): pngtest$(O) libpng$(A) - $(LD) $(LDFLAGS) -L$(ZLIBLIB) -o $@ pngtest$(O) libpng$(A) $(LIBS) - -clean: - $(RM_F) *$(O) libpng$(A) pngtest$(EXE) pngout.png - -png$(O): png.h pngconf.h -pngerror$(O): png.h pngconf.h -pngget$(O): png.h pngconf.h -pngmem$(O): png.h pngconf.h -pngpread$(O): png.h pngconf.h -pngread$(O): png.h pngconf.h -pngrio$(O): png.h pngconf.h -pngrtran$(O): png.h pngconf.h -pngrutil$(O): png.h pngconf.h -pngset$(O): png.h pngconf.h -pngtest$(O): png.h pngconf.h -pngtrans$(O): png.h pngconf.h -pngwio$(O): png.h pngconf.h -pngwrite$(O): png.h pngconf.h -pngwtran$(O): png.h pngconf.h -pngwutil$(O): png.h pngconf.h - +# makefile for libpng using gcc (generic, static library) +# Copyright (C) 2000 Cosmin Truta +# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. +# For conditions of distribution and use, see copyright notice in png.h + +# Location of the zlib library and include files +ZLIBINC = ../zlib +ZLIBLIB = ../zlib + +# Compiler, linker, lib and other tools +CC = gcc +LD = $(CC) +AR_RC = ar rcs +RANLIB = ranlib +RM_F = rm -f + +CDEBUG = -g -DPNG_DEBUG=5 +LDDEBUG = +CRELEASE = -O2 +LDRELEASE = -s +#CFLAGS = -Wall $(CDEBUG) +CFLAGS = -Wall $(CRELEASE) +#LDFLAGS = $(LDDEBUG) +LDFLAGS = $(LDRELEASE) +LIBS = -lz -lm + +# File extensions +O=.o +A=.a +EXE= + +# Variables +OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ + pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ + pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) + +# Targets +all: static + +.c$(O): + $(CC) -c $(CFLAGS) -I$(ZLIBINC) $< + +static: libpng$(A) pngtest$(EXE) + +shared: + @echo This is a generic makefile that cannot create shared libraries. + @echo Please use a configuration that is specific to your platform. + @false + +libpng$(A): $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +test: pngtest$(EXE) + ./pngtest$(EXE) + +pngtest$(EXE): pngtest$(O) libpng$(A) + $(LD) $(LDFLAGS) -L$(ZLIBLIB) -o $@ pngtest$(O) libpng$(A) $(LIBS) + +clean: + $(RM_F) *$(O) libpng$(A) pngtest$(EXE) pngout.png + +png$(O): png.h pngconf.h +pngerror$(O): png.h pngconf.h +pngget$(O): png.h pngconf.h +pngmem$(O): png.h pngconf.h +pngpread$(O): png.h pngconf.h +pngread$(O): png.h pngconf.h +pngrio$(O): png.h pngconf.h +pngrtran$(O): png.h pngconf.h +pngrutil$(O): png.h pngconf.h +pngset$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h +pngtrans$(O): png.h pngconf.h +pngwio$(O): png.h pngconf.h +pngwrite$(O): png.h pngconf.h +pngwtran$(O): png.h pngconf.h +pngwutil$(O): png.h pngconf.h + diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.gcmmx b/src/dep/src/irrlicht/libpng/scripts/makefile.gcmmx index 92ef2c4..cdd5b93 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.gcmmx +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.gcmmx @@ -1,275 +1,275 @@ -# makefile for libpng.a and libpng12.so on Linux ELF with gcc using MMX -# assembler code -# Copyright 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson -# Copyright 1998-2001 Greg Roelofs -# Copyright 1996-1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier. - -# WARNING: The assembler code in pnggccrd.c may not be thread safe. - -# NOTE: When testing MMX performance on a multitasking system, make sure -# there are no floating-point programs (e.g., SETI@Home) running in -# the background! Context switches between MMX and FPU are expensive. - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -CC = gcc -LD = $(CC) -AR_RC = ar rc -LN_SF = ln -sf -MKDIR_P = mkdir -p -RANLIB = ranlib -RM_F = /bin/rm -f - -# where "make install" puts libpng12.a, libpng12.so*, -# libpng12/png.h and libpng12/pngconf.h -# Prefix must be a full pathname. -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located. -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -# Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety -### for generic gcc: -CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall \ - -O3 $(ALIGN) -funroll-loops \ - -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5 -### for gcc 2.95.2 on 686: -#CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \ -# -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \ -# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer -### for gcc 2.7.2.3 on 486 and up: -#CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \ -# -m486 -malign-double -ffast-math \ -# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer - -LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm -LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm - - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o pnggccrd.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo cppflags=\"-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -pnggccrd.o: pnggccrd.c png.h pngconf.h - $(CC) -c $(CFLAGS) -o $@ $*.c - -pnggccrd.pic.o: pnggccrd.c png.h pngconf.h - $(CC) -c $(CFLAGS) -fPIC -o $@ pnggccrd.c - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \ - -o $(LIBSOVER) \ - $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \ - -o $(OLDSOVER) \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -pngtest-static: pngtest.o libpng.a - $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) - -test: pngtest pngtest-static - @echo "" - @echo " Running pngtest dynamically linked with $(LIBSO):" - @echo "" - ./pngtest - @echo "" - @echo " Running pngtest statically linked with libpng.a:" - @echo "" - ./pngtest-static - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -png.o png.pic.o: png.h pngconf.h png.c -pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c -pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c -pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c -pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c -pngset.o pngset.pic.o: png.h pngconf.h pngset.c -pngget.o pngget.pic.o: png.h pngconf.h pngget.c -pngread.o pngread.pic.o: png.h pngconf.h pngread.c -pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c -pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c -pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c -pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c -pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c -pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c -pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c - -pngtest.o: png.h pngconf.h pngtest.c +# makefile for libpng.a and libpng12.so on Linux ELF with gcc using MMX +# assembler code +# Copyright 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson +# Copyright 1998-2001 Greg Roelofs +# Copyright 1996-1997 Andreas Dilger +# For conditions of distribution and use, see copyright notice in png.h + +# CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier. + +# WARNING: The assembler code in pnggccrd.c may not be thread safe. + +# NOTE: When testing MMX performance on a multitasking system, make sure +# there are no floating-point programs (e.g., SETI@Home) running in +# the background! Context switches between MMX and FPU are expensive. + +# Library name: +LIBNAME = libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).so +LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) +LIBSOVER=$(LIBNAME).so.$(PNGVER) +OLDSO=libpng.so +OLDSOMAJ=libpng.so.3 +OLDSOVER=libpng.so.3.$(PNGMIN) + +# Utilities: +CC = gcc +LD = $(CC) +AR_RC = ar rc +LN_SF = ln -sf +MKDIR_P = mkdir -p +RANLIB = ranlib +RM_F = /bin/rm -f + +# where "make install" puts libpng12.a, libpng12.so*, +# libpng12/png.h and libpng12/pngconf.h +# Prefix must be a full pathname. +prefix=/usr/local +exec_prefix=$(prefix) + +# Where the zlib library and include files are located. +#ZLIBLIB=/usr/local/lib +#ZLIBINC=/usr/local/include +ZLIBLIB=../zlib +ZLIBINC=../zlib + +ALIGN= +# for i386: +#ALIGN=-malign-loops=2 -malign-functions=2 + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion + +# for pgcc version 2.95.1, -O3 is buggy; don't use it. + +# Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety +### for generic gcc: +CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall \ + -O3 $(ALIGN) -funroll-loops \ + -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5 +### for gcc 2.95.2 on 686: +#CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \ +# -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \ +# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer +### for gcc 2.7.2.3 on 486 and up: +#CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \ +# -m486 -malign-double -ffast-math \ +# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer + +LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm +LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm + + +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o pnggccrd.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +.c.pic.o: + $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c + +all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo cppflags=\"-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ + echo libs=\"-lpng12 -lz -lm\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +pnggccrd.o: pnggccrd.c png.h pngconf.h + $(CC) -c $(CFLAGS) -o $@ $*.c + +pnggccrd.pic.o: pnggccrd.c png.h pngconf.h + $(CC) -c $(CFLAGS) -fPIC -o $@ pnggccrd.c + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJSDLL) + $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \ + -o $(LIBSOVER) \ + $(OBJSDLL) + +$(OLDSOVER): $(OBJSDLL) + $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \ + -o $(OLDSOVER) \ + $(OBJSDLL) + +pngtest: pngtest.o $(LIBSO) + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +pngtest-static: pngtest.o libpng.a + $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) + +test: pngtest pngtest-static + @echo "" + @echo " Running pngtest dynamically linked with $(LIBSO):" + @echo "" + ./pngtest + @echo "" + @echo " Running pngtest statically linked with libpng.a:" + @echo "" + ./pngtest-static + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + $(CC) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ + $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ + $(OLDSOVER) \ + libpng.pc + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +png.o png.pic.o: png.h pngconf.h png.c +pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c +pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c +pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c +pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c +pngset.o pngset.pic.o: png.h pngconf.h pngset.c +pngget.o pngget.pic.o: png.h pngconf.h pngget.c +pngread.o pngread.pic.o: png.h pngconf.h pngread.c +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c +pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c + +pngtest.o: png.h pngconf.h pngtest.c diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.hp64 b/src/dep/src/irrlicht/libpng/scripts/makefile.hp64 index 20a7ca6..1e4cbe2 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.hp64 +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.hp64 @@ -1,231 +1,231 @@ -# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product. -# Copyright (C) 1999-2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42 -# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard -# For conditions of distribution and use, see copyright notice in png.h - -# Where the zlib library and include files are located -ZLIBLIB=/opt/zlib/lib -ZLIBINC=/opt/zlib/include - -# Note that if you plan to build a libpng shared library, zlib must also -# be a shared library, which zlib's configure does not do. After running -# zlib's configure, edit the appropriate lines of makefile to read: -# CFLAGS=-O1 -DHAVE_UNISTD -DUSE_MAP -fPIC \ -# LDSHARED=ld -b -# SHAREDLIB=libz.sl - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).sl -LIBSOMAJ=$(LIBNAME).sl.$(PNGMAJ) -LIBSOVER=$(LIBNAME).sl.$(PNGVER) -OLDSO=libpng.sl -OLDSOMAJ=libpng.sl.3 -OLDSOVER=libpng.sl.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=cc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -CFLAGS=-I$(ZLIBINC) -O -Ae -Wl,+vnocompatwarnings +DD64 \ --D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 +Z -DHAVE_UNISTD_H -DUSE_MMAP -# Caution: be sure you have built zlib with the same CFLAGS. -CCFLAGS=-I$(ZLIBINC) -O -Ae -Wl,+vnocompatwarnings +DD64 \ --D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 +Z -DHAVE_UNISTD_H -DUSE_MMAP - -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm - -# where make install puts libpng.a, libpng12.sl, and png.h -prefix=/opt/libpng -exec_prefix=$(prefix) -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) +z -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(LD) -b +s \ - +h $(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(LD) -b +s \ - +h $(OLDSOMAJ) -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) $(CCFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) $(CCFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h +# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product. +# Copyright (C) 1999-2002 Glenn Randers-Pehrson +# Copyright (C) 1995 Guy Eric Schalnat, Group 42 +# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard +# For conditions of distribution and use, see copyright notice in png.h + +# Where the zlib library and include files are located +ZLIBLIB=/opt/zlib/lib +ZLIBINC=/opt/zlib/include + +# Note that if you plan to build a libpng shared library, zlib must also +# be a shared library, which zlib's configure does not do. After running +# zlib's configure, edit the appropriate lines of makefile to read: +# CFLAGS=-O1 -DHAVE_UNISTD -DUSE_MAP -fPIC \ +# LDSHARED=ld -b +# SHAREDLIB=libz.sl + +# Library name: +LIBNAME = libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).sl +LIBSOMAJ=$(LIBNAME).sl.$(PNGMAJ) +LIBSOVER=$(LIBNAME).sl.$(PNGVER) +OLDSO=libpng.sl +OLDSOMAJ=libpng.sl.3 +OLDSOVER=libpng.sl.3.$(PNGMIN) + +# Utilities: +AR_RC=ar rc +CC=cc +MKDIR_P=mkdir -p +LN_SF=ln -sf +RANLIB=ranlib +RM_F=/bin/rm -f + +CFLAGS=-I$(ZLIBINC) -O -Ae -Wl,+vnocompatwarnings +DD64 \ +-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 +Z -DHAVE_UNISTD_H -DUSE_MMAP +# Caution: be sure you have built zlib with the same CFLAGS. +CCFLAGS=-I$(ZLIBINC) -O -Ae -Wl,+vnocompatwarnings +DD64 \ +-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 +Z -DHAVE_UNISTD_H -DUSE_MMAP + +LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm + +# where make install puts libpng.a, libpng12.sl, and png.h +prefix=/opt/libpng +exec_prefix=$(prefix) +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +.c.pic.o: + $(CC) -c $(CFLAGS) +z -o $@ $*.c + +all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo libs=\"-lpng12 -lz -lm\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJSDLL) + $(LD) -b +s \ + +h $(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) + +$(OLDSOVER): $(OBJSDLL) + $(LD) -b +s \ + +h $(OLDSOMAJ) -o $(OLDSOVER) $(OBJSDLL) + +pngtest: pngtest.o libpng.a + $(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) -I$(ZLIBINC) $(CCFLAGS) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + echo + echo Testing installed dynamic shared library. + $(CC) $(CCFLAGS) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(ZLIBLIB) \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ + libpng-config $(LIBSO) $(LIBSOMAJ)* \ + $(OLDSOVER) \ + libpng.pc + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o: png.h pngconf.h +pngerror.o: png.h pngconf.h +pngrio.o: png.h pngconf.h +pngwio.o: png.h pngconf.h +pngmem.o: png.h pngconf.h +pngset.o: png.h pngconf.h +pngget.o: png.h pngconf.h +pngread.o: png.h pngconf.h +pngrtran.o: png.h pngconf.h +pngrutil.o: png.h pngconf.h +pngtest.o: png.h pngconf.h +pngtrans.o: png.h pngconf.h +pngwrite.o: png.h pngconf.h +pngwtran.o: png.h pngconf.h +pngwutil.o: png.h pngconf.h +pngpread.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.hpgcc b/src/dep/src/irrlicht/libpng/scripts/makefile.hpgcc index 2359e7c..99b08f7 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.hpgcc +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.hpgcc @@ -1,241 +1,241 @@ -# makefile for libpng on HP-UX using GCC with the HP ANSI/C linker. -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 2001, Laurent faillie -# Copyright (C) 1998, 1999 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).sl -LIBSOMAJ=$(LIBNAME).sl.$(PNGMAJ) -LIBSOVER=$(LIBNAME).sl.$(PNGVER) -OLDSO=libpng.sl -OLDSOMAJ=libpng.sl.3 -OLDSOVER=libpng.sl.3.$(PNGMIN) - -# Utilities: -CC=gcc -LD=ld -AR_RC=ar rc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -# where "make install" puts libpng.a, $(OLDSO)*, png.h and pngconf.h -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -ZLIBLIB=/opt/zlib/lib -ZLIBINC=/opt/zlib/include - -# Note that if you plan to build a libpng shared library, zlib must also -# be a shared library, which zlib's configure does not do. After running -# zlib's configure, edit the appropriate lines of makefile to read: -# CFLAGS=-O1 -DHAVE_UNISTD -DUSE_MAP -fPIC \ -# LDSHARED=ld -b -# SHAREDLIB=libz.sl - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \ - $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 -#LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm -LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz -lm - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(LD) -b +s \ - +h $(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(LD) -b +s \ - +h $(OLDSOMAJ) -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -Wl,-rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h +# makefile for libpng on HP-UX using GCC with the HP ANSI/C linker. +# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 2001, Laurent faillie +# Copyright (C) 1998, 1999 Greg Roelofs +# Copyright (C) 1996, 1997 Andreas Dilger +# For conditions of distribution and use, see copyright notice in png.h + +# Library name: +LIBNAME = libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).sl +LIBSOMAJ=$(LIBNAME).sl.$(PNGMAJ) +LIBSOVER=$(LIBNAME).sl.$(PNGVER) +OLDSO=libpng.sl +OLDSOMAJ=libpng.sl.3 +OLDSOVER=libpng.sl.3.$(PNGMIN) + +# Utilities: +CC=gcc +LD=ld +AR_RC=ar rc +MKDIR_P=mkdir -p +LN_SF=ln -sf +RANLIB=ranlib +RM_F=/bin/rm -f + +# where "make install" puts libpng.a, $(OLDSO)*, png.h and pngconf.h +prefix=/usr/local +exec_prefix=$(prefix) + +# Where the zlib library and include files are located +ZLIBLIB=/opt/zlib/lib +ZLIBINC=/opt/zlib/include + +# Note that if you plan to build a libpng shared library, zlib must also +# be a shared library, which zlib's configure does not do. After running +# zlib's configure, edit the appropriate lines of makefile to read: +# CFLAGS=-O1 -DHAVE_UNISTD -DUSE_MAP -fPIC \ +# LDSHARED=ld -b +# SHAREDLIB=libz.sl + +ALIGN= +# for i386: +#ALIGN=-malign-loops=2 -malign-functions=2 + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion + +# for pgcc version 2.95.1, -O3 is buggy; don't use it. + +CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \ + $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 +#LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm +LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz -lm + +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +.c.pic.o: + $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c + +all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo libs=\"-lpng12 -lz -lm\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJSDLL) + $(LD) -b +s \ + +h $(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) + +$(OLDSOVER): $(OBJSDLL) + $(LD) -b +s \ + +h $(OLDSOMAJ) -o $(OLDSOVER) $(OBJSDLL) + +pngtest: pngtest.o $(LIBSO) + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) -Wl,-rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + echo + echo Testing installed dynamic shared library. + $(CC) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ + libpng-config $(LIBSO) $(LIBSOMAJ)* \ + $(OLDSOVER) \ + libpng.pc + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h +pngerror.o pngerror.pic.o: png.h pngconf.h +pngrio.o pngrio.pic.o: png.h pngconf.h +pngwio.o pngwio.pic.o: png.h pngconf.h +pngmem.o pngmem.pic.o: png.h pngconf.h +pngset.o pngset.pic.o: png.h pngconf.h +pngget.o pngget.pic.o: png.h pngconf.h +pngread.o pngread.pic.o: png.h pngconf.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h +pngpread.o pngpread.pic.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.hpux b/src/dep/src/irrlicht/libpng/scripts/makefile.hpux index 091884a..5c2eb4c 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.hpux +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.hpux @@ -1,228 +1,228 @@ -# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product. -# Copyright (C) 1999-2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42 -# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard -# For conditions of distribution and use, see copyright notice in png.h - -# Where the zlib library and include files are located -ZLIBLIB=/opt/zlib/lib -ZLIBINC=/opt/zlib/include - -# Note that if you plan to build a libpng shared library, zlib must also -# be a shared library, which zlib's configure does not do. After running -# zlib's configure, edit the appropriate lines of makefile to read: -# CFLAGS=-O1 -DHAVE_UNISTD -DUSE_MAP -fPIC \ -# LDSHARED=ld -b -# SHAREDLIB=libz.sl - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).sl -LIBSOMAJ=$(LIBNAME).sl.$(PNGMAJ) -LIBSOVER=$(LIBNAME).sl.$(PNGVER) -OLDSO=libpng.sl -OLDSOMAJ=libpng.sl.3 -OLDSOVER=libpng.sl.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=cc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -# where make install puts libpng.a, libpng12.sl, and png.h -prefix=/opt/libpng -exec_prefix=$(prefix) -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -CFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0 -# Caution: be sure you have built zlib with the same CFLAGS. -CCFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) +z -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(LD) -b +s \ - +h $(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(LD) -b +s \ - +h $(OLDSOMAJ) -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) $(CCFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) $(CCFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h +# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product. +# Copyright (C) 1999-2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 1995 Guy Eric Schalnat, Group 42 +# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard +# For conditions of distribution and use, see copyright notice in png.h + +# Where the zlib library and include files are located +ZLIBLIB=/opt/zlib/lib +ZLIBINC=/opt/zlib/include + +# Note that if you plan to build a libpng shared library, zlib must also +# be a shared library, which zlib's configure does not do. After running +# zlib's configure, edit the appropriate lines of makefile to read: +# CFLAGS=-O1 -DHAVE_UNISTD -DUSE_MAP -fPIC \ +# LDSHARED=ld -b +# SHAREDLIB=libz.sl + +# Library name: +LIBNAME = libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).sl +LIBSOMAJ=$(LIBNAME).sl.$(PNGMAJ) +LIBSOVER=$(LIBNAME).sl.$(PNGVER) +OLDSO=libpng.sl +OLDSOMAJ=libpng.sl.3 +OLDSOVER=libpng.sl.3.$(PNGMIN) + +# Utilities: +AR_RC=ar rc +CC=cc +MKDIR_P=mkdir -p +LN_SF=ln -sf +RANLIB=ranlib +RM_F=/bin/rm -f + +# where make install puts libpng.a, libpng12.sl, and png.h +prefix=/opt/libpng +exec_prefix=$(prefix) +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +CFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0 +# Caution: be sure you have built zlib with the same CFLAGS. +CCFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0 +LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +.c.pic.o: + $(CC) -c $(CFLAGS) +z -o $@ $*.c + +all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo libs=\"-lpng12 -lz -lm\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJSDLL) + $(LD) -b +s \ + +h $(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) + +$(OLDSOVER): $(OBJSDLL) + $(LD) -b +s \ + +h $(OLDSOMAJ) -o $(OLDSOVER) $(OBJSDLL) + +pngtest: pngtest.o libpng.a + $(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) -I$(ZLIBINC) $(CCFLAGS) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + echo + echo Testing installed dynamic shared library. + $(CC) $(CCFLAGS) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(ZLIBLIB) \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ + libpng-config $(LIBSO) $(LIBSOMAJ)* \ + $(OLDSOVER) \ + libpng.pc + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o: png.h pngconf.h +pngerror.o: png.h pngconf.h +pngrio.o: png.h pngconf.h +pngwio.o: png.h pngconf.h +pngmem.o: png.h pngconf.h +pngset.o: png.h pngconf.h +pngget.o: png.h pngconf.h +pngread.o: png.h pngconf.h +pngrtran.o: png.h pngconf.h +pngrutil.o: png.h pngconf.h +pngtest.o: png.h pngconf.h +pngtrans.o: png.h pngconf.h +pngwrite.o: png.h pngconf.h +pngwtran.o: png.h pngconf.h +pngwutil.o: png.h pngconf.h +pngpread.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.ibmc b/src/dep/src/irrlicht/libpng/scripts/makefile.ibmc index 80929d2..f09a62c 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.ibmc +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.ibmc @@ -1,71 +1,71 @@ -# Makefile for libpng (static) -# IBM C version 3.x for Win32 and OS/2 -# Copyright (C) 2000 Cosmin Truta -# For conditions of distribution and use, see copyright notice in png.h -# Notes: -# Derived from makefile.std -# All modules are compiled in C mode -# Tested under Win32, expected to work under OS/2 -# Can be easily adapted for IBM VisualAge/C++ for AIX - -# Location of the zlib library and include files -ZLIBINC = ../zlib -ZLIBLIB = ../zlib - -# Compiler, linker, lib and other tools -CC = icc -LD = ilink -AR = ilib -RM = del - -CFLAGS = -I$(ZLIBINC) -Mc -O2 -W3 -LDFLAGS = - -# File extensions -O=.obj -A=.lib -E=.exe - -# Variables -OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ - pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ - pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) - -LIBS = libpng$(A) $(ZLIBLIB)/zlib$(A) - -# Targets -all: libpng$(A) pngtest$(E) - -libpng$(A): $(OBJS) - $(AR) -out:$@ $(OBJS) - -test: pngtest$(E) - pngtest$(E) - -pngtest: pngtest$(E) - -pngtest$(E): pngtest$(O) libpng$(A) - $(LD) $(LDFLAGS) pngtest$(O) $(LIBS) - -clean: - $(RM) *$(O) - $(RM) libpng$(A) - $(RM) pngtest$(E) - $(RM) pngout.png - -png$(O): png.h pngconf.h -pngerror$(O): png.h pngconf.h -pngget$(O): png.h pngconf.h -pngmem$(O): png.h pngconf.h -pngpread$(O): png.h pngconf.h -pngread$(O): png.h pngconf.h -pngrio$(O): png.h pngconf.h -pngrtran$(O): png.h pngconf.h -pngrutil$(O): png.h pngconf.h -pngset$(O): png.h pngconf.h -pngtest$(O): png.h pngconf.h -pngtrans$(O): png.h pngconf.h -pngwio$(O): png.h pngconf.h -pngwrite$(O): png.h pngconf.h -pngwtran$(O): png.h pngconf.h -pngwutil$(O): png.h pngconf.h +# Makefile for libpng (static) +# IBM C version 3.x for Win32 and OS/2 +# Copyright (C) 2000 Cosmin Truta +# For conditions of distribution and use, see copyright notice in png.h +# Notes: +# Derived from makefile.std +# All modules are compiled in C mode +# Tested under Win32, expected to work under OS/2 +# Can be easily adapted for IBM VisualAge/C++ for AIX + +# Location of the zlib library and include files +ZLIBINC = ../zlib +ZLIBLIB = ../zlib + +# Compiler, linker, lib and other tools +CC = icc +LD = ilink +AR = ilib +RM = del + +CFLAGS = -I$(ZLIBINC) -Mc -O2 -W3 +LDFLAGS = + +# File extensions +O=.obj +A=.lib +E=.exe + +# Variables +OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ + pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ + pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) + +LIBS = libpng$(A) $(ZLIBLIB)/zlib$(A) + +# Targets +all: libpng$(A) pngtest$(E) + +libpng$(A): $(OBJS) + $(AR) -out:$@ $(OBJS) + +test: pngtest$(E) + pngtest$(E) + +pngtest: pngtest$(E) + +pngtest$(E): pngtest$(O) libpng$(A) + $(LD) $(LDFLAGS) pngtest$(O) $(LIBS) + +clean: + $(RM) *$(O) + $(RM) libpng$(A) + $(RM) pngtest$(E) + $(RM) pngout.png + +png$(O): png.h pngconf.h +pngerror$(O): png.h pngconf.h +pngget$(O): png.h pngconf.h +pngmem$(O): png.h pngconf.h +pngpread$(O): png.h pngconf.h +pngread$(O): png.h pngconf.h +pngrio$(O): png.h pngconf.h +pngrtran$(O): png.h pngconf.h +pngrutil$(O): png.h pngconf.h +pngset$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h +pngtrans$(O): png.h pngconf.h +pngwio$(O): png.h pngconf.h +pngwrite$(O): png.h pngconf.h +pngwtran$(O): png.h pngconf.h +pngwutil$(O): png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.intel b/src/dep/src/irrlicht/libpng/scripts/makefile.intel index 400ca07..1cabe77 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.intel +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.intel @@ -1,114 +1,114 @@ -# Makefile for libpng -# Microsoft Visual C++ with Intel C/C++ Compiler 4.0 and later - -# Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is -# copyright 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# To use, do "nmake /f scripts\makefile.intel" - - -# ------------------- Intel C/C++ Compiler 4.0 and later ------------------- - -# Caution: the assembler code was introduced at libpng version 1.0.4 and has -# not yet been thoroughly tested. - -# Use assembler code -ASMCODE=-DPNG_USE_PNGVCRD - -# Where the zlib library and include files are located -ZLIBLIB=..\zlib -ZLIBINC=..\zlib - -# Target CPU -CPU=6 # Pentium II -#CPU=5 # Pentium - -# Calling convention -CALLING=r # __fastcall -#CALLING=z # __stdcall -#CALLING=d # __cdecl - -# Uncomment next to put error messages in a file -#ERRFILE=>>pngerrs - -# -------------------------------------------------------------------------- - - -CC=icl -c -CFLAGS=-O2 -G$(CPU)$(CALLING) -Qip -Qunroll4 -I$(ZLIBINC) $(ASMCODE) -nologo -LD=link -LDFLAGS=/SUBSYSTEM:CONSOLE /NOLOGO - -O=.obj - -OBJS=png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) \ -pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) \ -pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) pngvcrd$(O) - - -all: test - -png$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngvcrd$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS) - if exist libpng.lib del libpng.lib - lib /NOLOGO /OUT:libpng.lib $(OBJS) - -pngtest.exe: pngtest.obj libpng.lib - $(LD) $(LDFLAGS) /OUT:pngtest.exe pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib - -test: pngtest.exe - pngtest.exe - - -# End of makefile for libpng +# Makefile for libpng +# Microsoft Visual C++ with Intel C/C++ Compiler 4.0 and later + +# Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is +# copyright 1995 Guy Eric Schalnat, Group 42, Inc. +# For conditions of distribution and use, see copyright notice in png.h + +# To use, do "nmake /f scripts\makefile.intel" + + +# ------------------- Intel C/C++ Compiler 4.0 and later ------------------- + +# Caution: the assembler code was introduced at libpng version 1.0.4 and has +# not yet been thoroughly tested. + +# Use assembler code +ASMCODE=-DPNG_USE_PNGVCRD + +# Where the zlib library and include files are located +ZLIBLIB=..\zlib +ZLIBINC=..\zlib + +# Target CPU +CPU=6 # Pentium II +#CPU=5 # Pentium + +# Calling convention +CALLING=r # __fastcall +#CALLING=z # __stdcall +#CALLING=d # __cdecl + +# Uncomment next to put error messages in a file +#ERRFILE=>>pngerrs + +# -------------------------------------------------------------------------- + + +CC=icl -c +CFLAGS=-O2 -G$(CPU)$(CALLING) -Qip -Qunroll4 -I$(ZLIBINC) $(ASMCODE) -nologo +LD=link +LDFLAGS=/SUBSYSTEM:CONSOLE /NOLOGO + +O=.obj + +OBJS=png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) \ +pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) \ +pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) pngvcrd$(O) + + +all: test + +png$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngset$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngget$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngread$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngpread$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngrtran$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngrutil$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngvcrd$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngerror$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngmem$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngrio$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngwio$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngtest$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngtrans$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngwrite$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngwtran$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngwutil$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +libpng.lib: $(OBJS) + if exist libpng.lib del libpng.lib + lib /NOLOGO /OUT:libpng.lib $(OBJS) + +pngtest.exe: pngtest.obj libpng.lib + $(LD) $(LDFLAGS) /OUT:pngtest.exe pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib + +test: pngtest.exe + pngtest.exe + + +# End of makefile for libpng diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.knr b/src/dep/src/irrlicht/libpng/scripts/makefile.knr index 4a8d7d1..44ee538 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.knr +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.knr @@ -1,99 +1,99 @@ -# makefile for libpng -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# This makefile requires the file ansi2knr.c, which you can get -# from the Ghostscript ftp site at ftp://ftp.cs.wisc.edu/ghost/ -# If you have libjpeg, you probably already have ansi2knr.c in the jpeg -# source distribution. - -# where make install puts libpng.a and png.h -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -CC=cc -CFLAGS=-I../zlib -O -LDFLAGS=-L. -L../zlib/ -lpng -lz -lm -# flags for ansi2knr -ANSI2KNRFLAGS= - -RANLIB=ranlib -#RANLIB=echo - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: ansi2knr libpng.a pngtest - -# general rule to allow ansi2knr to work -.c.o: - ./ansi2knr $*.c T$*.c - $(CC) $(CFLAGS) -c T$*.c - rm -f T$*.c $*.o - mv T$*.o $*.o - -ansi2knr: ansi2knr.c - $(CC) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr ansi2knr.c - -libpng.a: ansi2knr $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install: libpng.a - -@mkdir $(DESTDIR)$(INCPATH) - -@mkdir $(DESTDIR)$(INCPATH)/libpng - -@mkdir $(DESTDIR)$(LIBPATH) - -@rm -f $(DESTDIR)$(INCPATH)/png.h - -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h - cp png.h $(DESTDIR)$(INCPATH)/libpng - cp pngconf.h $(DESTDIR)$(INCPATH)/libpng - chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h - chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h - (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) - cp libpng.a $(DESTDIR)$(LIBPATH) - chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a - -clean: - rm -f *.o libpng.a pngtest pngout.png ansi2knr - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h +# makefile for libpng +# Copyright (C) 2002 Glenn Randers-Pehrson +# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. +# For conditions of distribution and use, see copyright notice in png.h + +# This makefile requires the file ansi2knr.c, which you can get +# from the Ghostscript ftp site at ftp://ftp.cs.wisc.edu/ghost/ +# If you have libjpeg, you probably already have ansi2knr.c in the jpeg +# source distribution. + +# where make install puts libpng.a and png.h +prefix=/usr/local +INCPATH=$(prefix)/include +LIBPATH=$(prefix)/lib + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +CC=cc +CFLAGS=-I../zlib -O +LDFLAGS=-L. -L../zlib/ -lpng -lz -lm +# flags for ansi2knr +ANSI2KNRFLAGS= + +RANLIB=ranlib +#RANLIB=echo + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +all: ansi2knr libpng.a pngtest + +# general rule to allow ansi2knr to work +.c.o: + ./ansi2knr $*.c T$*.c + $(CC) $(CFLAGS) -c T$*.c + rm -f T$*.c $*.o + mv T$*.o $*.o + +ansi2knr: ansi2knr.c + $(CC) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr ansi2knr.c + +libpng.a: ansi2knr $(OBJS) + ar rc $@ $(OBJS) + $(RANLIB) $@ + +pngtest: pngtest.o libpng.a + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + +install: libpng.a + -@mkdir $(DESTDIR)$(INCPATH) + -@mkdir $(DESTDIR)$(INCPATH)/libpng + -@mkdir $(DESTDIR)$(LIBPATH) + -@rm -f $(DESTDIR)$(INCPATH)/png.h + -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h + cp png.h $(DESTDIR)$(INCPATH)/libpng + cp pngconf.h $(DESTDIR)$(INCPATH)/libpng + chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h + chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h + (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) + cp libpng.a $(DESTDIR)$(LIBPATH) + chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a + +clean: + rm -f *.o libpng.a pngtest pngout.png ansi2knr + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o: png.h pngconf.h +pngerror.o: png.h pngconf.h +pngrio.o: png.h pngconf.h +pngwio.o: png.h pngconf.h +pngmem.o: png.h pngconf.h +pngset.o: png.h pngconf.h +pngget.o: png.h pngconf.h +pngread.o: png.h pngconf.h +pngpread.o: png.h pngconf.h +pngrtran.o: png.h pngconf.h +pngrutil.o: png.h pngconf.h +pngtest.o: png.h pngconf.h +pngtrans.o: png.h pngconf.h +pngwrite.o: png.h pngconf.h +pngwtran.o: png.h pngconf.h +pngwutil.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.linux b/src/dep/src/irrlicht/libpng/scripts/makefile.linux index 31ae271..deccdda 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.linux +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.linux @@ -1,245 +1,245 @@ -# makefile for libpng.a and libpng12.so on Linux ELF with gcc -# Copyright (C) 1998, 1999, 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=gcc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -# where "make install" puts libpng12.a, libpng12.so*, -# libpng12/png.h and libpng12/pngconf.h -# Prefix must be a full pathname. -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located. -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \ - $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 - -LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm -LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \ - -o $(OLDSOVER) \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -pngtest-static: pngtest.o libpng.a - $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) - -test: pngtest pngtest-static - @echo "" - @echo " Running pngtest dynamically linked with $(LIBSO):" - @echo "" - ./pngtest - @echo "" - @echo " Running pngtest statically linked with libpng.a:" - @echo "" - ./pngtest-static - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h +# makefile for libpng.a and libpng12.so on Linux ELF with gcc +# Copyright (C) 1998, 1999, 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson +# Copyright (C) 1996, 1997 Andreas Dilger +# For conditions of distribution and use, see copyright notice in png.h + +# Library name: +LIBNAME = libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).so +LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) +LIBSOVER=$(LIBNAME).so.$(PNGVER) +OLDSO=libpng.so +OLDSOMAJ=libpng.so.3 +OLDSOVER=libpng.so.3.$(PNGMIN) + +# Utilities: +AR_RC=ar rc +CC=gcc +MKDIR_P=mkdir -p +LN_SF=ln -sf +RANLIB=ranlib +RM_F=/bin/rm -f + +# where "make install" puts libpng12.a, libpng12.so*, +# libpng12/png.h and libpng12/pngconf.h +# Prefix must be a full pathname. +prefix=/usr/local +exec_prefix=$(prefix) + +# Where the zlib library and include files are located. +#ZLIBLIB=/usr/local/lib +#ZLIBINC=/usr/local/include +ZLIBLIB=../zlib +ZLIBINC=../zlib + +ALIGN= +# for i386: +#ALIGN=-malign-loops=2 -malign-functions=2 + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion + +# for pgcc version 2.95.1, -O3 is buggy; don't use it. + +CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \ + $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 + +LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm +LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm + +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +.c.pic.o: + $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c + +all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ + echo libs=\"-lpng12 -lz -lm\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJSDLL) + $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) + +$(OLDSOVER): $(OBJSDLL) + $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \ + -o $(OLDSOVER) \ + $(OBJSDLL) + +pngtest: pngtest.o $(LIBSO) + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +pngtest-static: pngtest.o libpng.a + $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) + +test: pngtest pngtest-static + @echo "" + @echo " Running pngtest dynamically linked with $(LIBSO):" + @echo "" + ./pngtest + @echo "" + @echo " Running pngtest statically linked with libpng.a:" + @echo "" + ./pngtest-static + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + $(CC) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ + $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ + $(OLDSOVER) \ + libpng.pc + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h +pngerror.o pngerror.pic.o: png.h pngconf.h +pngrio.o pngrio.pic.o: png.h pngconf.h +pngwio.o pngwio.pic.o: png.h pngconf.h +pngmem.o pngmem.pic.o: png.h pngconf.h +pngset.o pngset.pic.o: png.h pngconf.h +pngget.o pngget.pic.o: png.h pngconf.h +pngread.o pngread.pic.o: png.h pngconf.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h +pngpread.o pngpread.pic.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.mingw b/src/dep/src/irrlicht/libpng/scripts/makefile.mingw index de67caa..84bed8a 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.mingw +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.mingw @@ -1,312 +1,312 @@ -# makefile for mingw on x86 -# Builds both dll (with import lib) and static lib versions -# of the library, and builds two copies of pngtest: one -# statically linked and one dynamically linked. -# -# Built from makefile.cygwin -# Copyright (C) 2002, 2006 Soren Anderson, Charles Wilson, -# and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by: -# Copyright (C) 1998-2000 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# This makefile intends to support building outside the src directory -# if desired. When invoking it, specify an argument to SRCDIR on the -# command line that points to the top of the directory where your source -# is located. - -ifdef SRCDIR -VPATH = $(SRCDIR) -else -SRCDIR = . -endif - -# Override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. - -DESTDIR= - -# To enable assembler optimizations, add '-DPNG_USE_PNGGCCRD' to -# $CFLAGS, and include pnggccrd.o in $OBJS, below, and in the dependency -# list at the bottom of this makefile. - -CC=gcc - - -# Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h -ifndef prefix -prefix=/usr -$(warning You haven't specified a 'prefix=' location. Defaulting to "/usr") -endif -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -ZLIBLIB= /usr/lib -ZLIBINC= - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -### if you use the asm, add pnggccrd.o to the OBJS list -### -### if you don't need thread safety, but want the asm accel -#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD \ -# $(addprefix -I,$(ZLIBINC)) -Wall -O3 $(ALIGN) -funroll-loops \ -# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 -### if you need thread safety and want (minimal) asm accel -#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_USE_PNGGCCRD $(addprefix -I,$(ZLIBINC)) \ -# -Wall -O3 $(ALIGN) -funroll-loops \ -# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 -### Normal (non-asm) compilation -CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ - -Wall -O3 $(ALIGN) -funroll-loops \ - -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 - -LIBNAME = libpng12 -PNGMAJ = 0 -MINGDLL = 12 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -SHAREDLIB=libpng$(MINGDLL).dll -STATLIB=libpng.a -IMPLIB=libpng.dll.a -SHAREDDEF=libpng.def -LIBS=$(SHAREDLIB) $(STATLIB) -EXE=.exe - -LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz) -LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS)) -LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz - -MKDIR_P=/bin/mkdir -pv -RANLIB=ranlib -#RANLIB=echo - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib - -BINPATH=$(exec_prefix)/bin -MANPATH=$(prefix)/man -MAN3PATH=$(MANPATH)/man3 -MAN5PATH=$(MANPATH)/man5 - -# cosmetic: shortened strings: -S =$(SRCDIR) -D =$(DESTDIR) -DB =$(D)$(BINPATH) -DI =$(D)$(INCPATH) -DL =$(D)$(LIBPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o # pnggccrd.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -%.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< -%.pic.o : CFLAGS += -DPNG_BUILD_DLL -%.pic.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< - -all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config - -# Make this to verify that "make [...] install" will do what you want. -buildsetup-tell: - @echo VPATH is set to: \"$(VPATH)\" - @echo prefix is set to: \"$(prefix)\" - @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \ - $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \ - $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n' - -libpng.pc: scripts/libpng.pc.in - @echo -e Making pkg-config file for this libpng installation..'\n' \ - using PREFIX=\"$(prefix)\"'\n' - cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \ - sed -e s/-lm// > libpng.pc - -libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in - @echo -e Making $(LIBNAME) libpng-config file for this libpng \ - installation..'\n' using PREFIX=\"$(prefix)\"'\n' - ( cat $(S)/scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng$(MINGDLL) -lz\"; \ - cat $(S)/scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -static: all-static -shared: all-shared -all-static: $(STATLIB) pngtest-stat$(EXE) -all-shared: $(SHAREDLIB) pngtest$(EXE) - -pnggccrd.o: pnggccrd.c png.h pngconf.h - @echo "" - @echo ' You can ignore the "control reaches end of non-void function"' - @echo ' warning and " defined but not used" warnings:' - @echo "" - $(CC) -c $(CFLAGS) -o $@ $< - -pnggccrd.pic.o: pnggccrd.c png.h pngconf.h - @echo "" - @echo ' You can ignore the "control reaches end of non-void function"' - @echo ' warning and " defined but not used" warnings:' - @echo "" - $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $< - -$(STATLIB): $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -$(SHAREDDEF): scripts/pngw32.def - cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \ - sed -e 's/\([^;]*\);/;/' > $@ - -$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF) - $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA) - -pngtest$(EXE): pngtest.pic.o $(SHAREDLIB) - $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ - -pngtest-stat$(EXE): pngtest.o $(STATLIB) - $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@ - -pngtest.pic.o: pngtest.c - $(CC) $(CFLAGS) -c $< -o $@ - -pngtest.o: pngtest.c - $(CC) $(CFLAGS) -c $< -o $@ - -test: test-static test-shared - -test-static: pngtest-stat$(EXE) - ./pngtest-stat $(S)/pngtest.png - -test-shared: pngtest$(EXE) - ./pngtest $(S)/pngtest.png - -install-static: $(STATLIB) install-headers install-man - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a - -@rm -f $(DL)/$(STATLIB) - (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB)) - -install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a - -@rm -f $(DL)/$(IMPLIB) - (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB)) - install -s -m 755 $(SHAREDLIB) $(DB) - install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-headers: - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - -@rm -f $(DI)/png.h - -@rm -f $(DI)/pngconf.h - install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME) - -@rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-man: - -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR_P) $(D)$(MAN3PATH); fi - -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR_P) $(D)$(MAN5PATH); fi - install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH) - install -m 644 $(S)/png.5 $(D)$(MAN5PATH) - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -# Run this to verify that a future `configure' run will pick up the settings -# you want. -test-config-install: SHELL=/bin/bash -test-config-install: $(DB)/libpng-config - @echo -e Testing libpng-config functions...'\n' - @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \ - do \ - printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \ - "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \ - gytiu=$$(( $$gytiu + 1 )); \ - done - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) $(CFLAGS) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/libpng12-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti$(EXE) `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti$(EXE) pngtest.png - -clean: - /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \ - pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \ - libpng-config libpng.pc pngtesti$(EXE) - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -.PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h png.c -pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c -pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c -pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c -pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c -pngset.o pngset.pic.o: png.h pngconf.h pngset.c -pngget.o pngget.pic.o: png.h pngconf.h pngget.c -pngread.o pngread.pic.o: png.h pngconf.h pngread.c -pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c -pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c -pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c -pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c -pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c -pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c -pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c - -pngtest.o: png.h pngconf.h pngtest.c -pngtest-stat.o: png.h pngconf.h pngtest.c - - - +# makefile for mingw on x86 +# Builds both dll (with import lib) and static lib versions +# of the library, and builds two copies of pngtest: one +# statically linked and one dynamically linked. +# +# Built from makefile.cygwin +# Copyright (C) 2002, 2006 Soren Anderson, Charles Wilson, +# and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by: +# Copyright (C) 1998-2000 Greg Roelofs +# Copyright (C) 1996, 1997 Andreas Dilger +# For conditions of distribution and use, see copyright notice in png.h + +# This makefile intends to support building outside the src directory +# if desired. When invoking it, specify an argument to SRCDIR on the +# command line that points to the top of the directory where your source +# is located. + +ifdef SRCDIR +VPATH = $(SRCDIR) +else +SRCDIR = . +endif + +# Override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. + +DESTDIR= + +# To enable assembler optimizations, add '-DPNG_USE_PNGGCCRD' to +# $CFLAGS, and include pnggccrd.o in $OBJS, below, and in the dependency +# list at the bottom of this makefile. + +CC=gcc + + +# Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h +ifndef prefix +prefix=/usr +$(warning You haven't specified a 'prefix=' location. Defaulting to "/usr") +endif +exec_prefix=$(prefix) + +# Where the zlib library and include files are located +ZLIBLIB= /usr/lib +ZLIBINC= + +ALIGN= +# for i386: +#ALIGN=-malign-loops=2 -malign-functions=2 + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion + +### if you use the asm, add pnggccrd.o to the OBJS list +### +### if you don't need thread safety, but want the asm accel +#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD \ +# $(addprefix -I,$(ZLIBINC)) -Wall -O3 $(ALIGN) -funroll-loops \ +# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 +### if you need thread safety and want (minimal) asm accel +#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_USE_PNGGCCRD $(addprefix -I,$(ZLIBINC)) \ +# -Wall -O3 $(ALIGN) -funroll-loops \ +# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 +### Normal (non-asm) compilation +CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ + -Wall -O3 $(ALIGN) -funroll-loops \ + -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 + +LIBNAME = libpng12 +PNGMAJ = 0 +MINGDLL = 12 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +SHAREDLIB=libpng$(MINGDLL).dll +STATLIB=libpng.a +IMPLIB=libpng.dll.a +SHAREDDEF=libpng.def +LIBS=$(SHAREDLIB) $(STATLIB) +EXE=.exe + +LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz) +LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS)) +LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz + +MKDIR_P=/bin/mkdir -pv +RANLIB=ranlib +#RANLIB=echo + +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib + +BINPATH=$(exec_prefix)/bin +MANPATH=$(prefix)/man +MAN3PATH=$(MANPATH)/man3 +MAN5PATH=$(MANPATH)/man5 + +# cosmetic: shortened strings: +S =$(SRCDIR) +D =$(DESTDIR) +DB =$(D)$(BINPATH) +DI =$(D)$(INCPATH) +DL =$(D)$(LIBPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o # pnggccrd.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +%.o : %.c + $(CC) -c $(CFLAGS) -o $@ $< +%.pic.o : CFLAGS += -DPNG_BUILD_DLL +%.pic.o : %.c + $(CC) -c $(CFLAGS) -o $@ $< + +all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config + +# Make this to verify that "make [...] install" will do what you want. +buildsetup-tell: + @echo VPATH is set to: \"$(VPATH)\" + @echo prefix is set to: \"$(prefix)\" + @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \ + $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \ + $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n' + +libpng.pc: scripts/libpng.pc.in + @echo -e Making pkg-config file for this libpng installation..'\n' \ + using PREFIX=\"$(prefix)\"'\n' + cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \ + sed -e s/-lm// > libpng.pc + +libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in + @echo -e Making $(LIBNAME) libpng-config file for this libpng \ + installation..'\n' using PREFIX=\"$(prefix)\"'\n' + ( cat $(S)/scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo libs=\"-lpng$(MINGDLL) -lz\"; \ + cat $(S)/scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +static: all-static +shared: all-shared +all-static: $(STATLIB) pngtest-stat$(EXE) +all-shared: $(SHAREDLIB) pngtest$(EXE) + +pnggccrd.o: pnggccrd.c png.h pngconf.h + @echo "" + @echo ' You can ignore the "control reaches end of non-void function"' + @echo ' warning and " defined but not used" warnings:' + @echo "" + $(CC) -c $(CFLAGS) -o $@ $< + +pnggccrd.pic.o: pnggccrd.c png.h pngconf.h + @echo "" + @echo ' You can ignore the "control reaches end of non-void function"' + @echo ' warning and " defined but not used" warnings:' + @echo "" + $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $< + +$(STATLIB): $(OBJS) + ar rc $@ $(OBJS) + $(RANLIB) $@ + +$(SHAREDDEF): scripts/pngw32.def + cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \ + sed -e 's/\([^;]*\);/;/' > $@ + +$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF) + $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA) + +pngtest$(EXE): pngtest.pic.o $(SHAREDLIB) + $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ + +pngtest-stat$(EXE): pngtest.o $(STATLIB) + $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@ + +pngtest.pic.o: pngtest.c + $(CC) $(CFLAGS) -c $< -o $@ + +pngtest.o: pngtest.c + $(CC) $(CFLAGS) -c $< -o $@ + +test: test-static test-shared + +test-static: pngtest-stat$(EXE) + ./pngtest-stat $(S)/pngtest.png + +test-shared: pngtest$(EXE) + ./pngtest $(S)/pngtest.png + +install-static: $(STATLIB) install-headers install-man + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a + -@rm -f $(DL)/$(STATLIB) + (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB)) + +install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc + -@/bin/rm -f $(DL)/pkgconfig/libpng.pc + install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a + -@rm -f $(DL)/$(IMPLIB) + (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB)) + install -s -m 755 $(SHAREDLIB) $(DB) + install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) + +install-headers: + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + -@rm -f $(DI)/png.h + -@rm -f $(DI)/pngconf.h + install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME) + -@rm -f $(DI)/libpng + (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) + +install-man: + -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR_P) $(D)$(MAN3PATH); fi + -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR_P) $(D)$(MAN5PATH); fi + install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH) + install -m 644 $(S)/png.5 $(D)$(MAN5PATH) + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@/bin/rm -f $(DB)/libpng-config + -@/bin/rm -f $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) + +# Run this to verify that a future `configure' run will pick up the settings +# you want. +test-config-install: SHELL=/bin/bash +test-config-install: $(DB)/libpng-config + @echo -e Testing libpng-config functions...'\n' + @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \ + do \ + printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \ + "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \ + gytiu=$$(( $$gytiu + 1 )); \ + done + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) $(CFLAGS) \ + `$(BINPATH)/libpng12-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) \ + -o pngtestd `$(BINPATH)/libpng12-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + $(CC) $(CFLAGS) \ + `$(BINPATH)/libpng12-config --cflags` pngtest.c \ + -L$(ZLIBLIB) \ + -o pngtesti$(EXE) `$(BINPATH)/libpng12-config --ldflags` + ./pngtesti$(EXE) pngtest.png + +clean: + /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \ + pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \ + libpng-config libpng.pc pngtesti$(EXE) + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +.PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h png.c +pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c +pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c +pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c +pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c +pngset.o pngset.pic.o: png.h pngconf.h pngset.c +pngget.o pngget.pic.o: png.h pngconf.h pngget.c +pngread.o pngread.pic.o: png.h pngconf.h pngread.c +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c +pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c + +pngtest.o: png.h pngconf.h pngtest.c +pngtest-stat.o: png.h pngconf.h pngtest.c + + + diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.mips b/src/dep/src/irrlicht/libpng/scripts/makefile.mips index b77e006..f1a557d 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.mips +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.mips @@ -1,83 +1,83 @@ -# makefile for libpng -# Copyright (C) Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# where make install puts libpng.a and png.h -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -CC=cc -CFLAGS=-I../zlib -O -systype sysv -DSYSV -w -Dmips -#CFLAGS=-O -LDFLAGS=-L. -L../zlib/ -lpng -lz -lm - -#RANLIB=ranlib -RANLIB=echo - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install: libpng.a - -@mkdir $(DESTDIR)$(INCPATH) - -@mkdir $(DESTDIR)$(INCPATH)/libpng - -@mkdir $(DESTDIR)$(LIBPATH) - -@rm -f $(DESTDIR)$(INCPATH)/png.h - -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h - cp png.h $(DESTDIR)$(INCPATH)/libpng - cp pngconf.h $(DESTDIR)$(INCPATH)/libpng - chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h - chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h - (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) - cp libpng.a $(DESTDIR)$(LIBPATH) - chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a - -clean: - rm -f *.o libpng.a pngtest pngout.png - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h +# makefile for libpng +# Copyright (C) Glenn Randers-Pehrson +# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. +# For conditions of distribution and use, see copyright notice in png.h + +# where make install puts libpng.a and png.h +prefix=/usr/local +INCPATH=$(prefix)/include +LIBPATH=$(prefix)/lib + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +CC=cc +CFLAGS=-I../zlib -O -systype sysv -DSYSV -w -Dmips +#CFLAGS=-O +LDFLAGS=-L. -L../zlib/ -lpng -lz -lm + +#RANLIB=ranlib +RANLIB=echo + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +all: libpng.a pngtest + +libpng.a: $(OBJS) + ar rc $@ $(OBJS) + $(RANLIB) $@ + +pngtest: pngtest.o libpng.a + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + +install: libpng.a + -@mkdir $(DESTDIR)$(INCPATH) + -@mkdir $(DESTDIR)$(INCPATH)/libpng + -@mkdir $(DESTDIR)$(LIBPATH) + -@rm -f $(DESTDIR)$(INCPATH)/png.h + -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h + cp png.h $(DESTDIR)$(INCPATH)/libpng + cp pngconf.h $(DESTDIR)$(INCPATH)/libpng + chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h + chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h + (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) + cp libpng.a $(DESTDIR)$(LIBPATH) + chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a + +clean: + rm -f *.o libpng.a pngtest pngout.png + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o: png.h pngconf.h +pngerror.o: png.h pngconf.h +pngrio.o: png.h pngconf.h +pngwio.o: png.h pngconf.h +pngmem.o: png.h pngconf.h +pngset.o: png.h pngconf.h +pngget.o: png.h pngconf.h +pngread.o: png.h pngconf.h +pngpread.o: png.h pngconf.h +pngrtran.o: png.h pngconf.h +pngrutil.o: png.h pngconf.h +pngtest.o: png.h pngconf.h +pngtrans.o: png.h pngconf.h +pngwrite.o: png.h pngconf.h +pngwtran.o: png.h pngconf.h +pngwutil.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.msc b/src/dep/src/irrlicht/libpng/scripts/makefile.msc index 1741ed0..1cbfd91 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.msc +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.msc @@ -1,86 +1,86 @@ -# makefile for libpng -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h -# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib - -# -------- Microsoft C 5.1 and later, does not use assembler code -------- -MODEL=L -CFLAGS=-Oait -Gs -nologo -W3 -A$(MODEL) -I..\zlib -#-Ox generates bad code with MSC 5.1 -CC=cl -LD=link -LDFLAGS=/e/st:0x1500/noe -O=.obj - -#uncomment next to put error messages in a file -ERRFILE= >> pngerrs - -# variables -OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) -OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) -OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) - -all: libpng.lib - -png$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) - del libpng.lib - lib libpng $(OBJS1); - lib libpng $(OBJS2); - lib libpng $(OBJS3); - -pngtest.exe: pngtest.obj libpng.lib - $(LD) $(LDFLAGS) pngtest.obj,,,libpng.lib ..\zlib\zlib.lib ; - -test: pngtest.exe - pngtest - -# End of makefile for libpng - +# makefile for libpng +# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. +# For conditions of distribution and use, see copyright notice in png.h +# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib + +# -------- Microsoft C 5.1 and later, does not use assembler code -------- +MODEL=L +CFLAGS=-Oait -Gs -nologo -W3 -A$(MODEL) -I..\zlib +#-Ox generates bad code with MSC 5.1 +CC=cl +LD=link +LDFLAGS=/e/st:0x1500/noe +O=.obj + +#uncomment next to put error messages in a file +ERRFILE= >> pngerrs + +# variables +OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) +OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) +OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) + +all: libpng.lib + +png$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngset$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngget$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngread$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngpread$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngrtran$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngrutil$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngerror$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngmem$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngrio$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngwio$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngtest$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngtrans$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngwrite$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngwtran$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngwutil$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) + del libpng.lib + lib libpng $(OBJS1); + lib libpng $(OBJS2); + lib libpng $(OBJS3); + +pngtest.exe: pngtest.obj libpng.lib + $(LD) $(LDFLAGS) pngtest.obj,,,libpng.lib ..\zlib\zlib.lib ; + +test: pngtest.exe + pngtest + +# End of makefile for libpng + diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.ne12bsd b/src/dep/src/irrlicht/libpng/scripts/makefile.ne12bsd index 299fce6..becd005 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.ne12bsd +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.ne12bsd @@ -1,45 +1,45 @@ -# makefile for libpng for NetBSD for the standard -# make obj && make depend && make && make test -# make includes && make install -# Copyright (C) 2002 Patrick R.L. Welche -# Copyright (C) 2007 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h - -# You should also run makefile.netbsd - -LOCALBASE?=/usr/local -LIBDIR= ${LOCALBASE}/lib -MANDIR= ${LOCALBASE}/man -INCSDIR=${LOCALBASE}/include/libpng12 - -LIB= png12 -SHLIB_MAJOR= 0 -SHLIB_MINOR= 1.2.16 -SRCS= pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ - pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ - pngwtran.c pngmem.c pngerror.c pngpread.c -INCS= png.h pngconf.h -MAN= libpng.3 libpngpf.3 png.5 - -CPPFLAGS+=-I${.CURDIR} -DPNG_USE_PNGGCCRD - -# something like this for mmx assembler, but it core dumps for me at the moment -# .if ${MACHINE_ARCH} == "i386" -# CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK -# MKLINT= no -# .else - CPPFLAGS+=-DPNG_NO_MMX_CODE -# .endif - -CLEANFILES+=pngtest.o pngtest - -pngtest.o: pngtest.c - ${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} - -pngtest: pngtest.o libpng.a - ${CC} ${LDFLAGS} ${.ALLSRC} -o${.TARGET} -lz -lm - -test: pngtest - cd ${.CURDIR} && ${.OBJDIR}/pngtest - -.include +# makefile for libpng for NetBSD for the standard +# make obj && make depend && make && make test +# make includes && make install +# Copyright (C) 2002 Patrick R.L. Welche +# Copyright (C) 2007 Glenn Randers-Pehrson +# For conditions of distribution and use, see copyright notice in png.h + +# You should also run makefile.netbsd + +LOCALBASE?=/usr/local +LIBDIR= ${LOCALBASE}/lib +MANDIR= ${LOCALBASE}/man +INCSDIR=${LOCALBASE}/include/libpng12 + +LIB= png12 +SHLIB_MAJOR= 0 +SHLIB_MINOR= 1.2.16 +SRCS= pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ + pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ + pngwtran.c pngmem.c pngerror.c pngpread.c +INCS= png.h pngconf.h +MAN= libpng.3 libpngpf.3 png.5 + +CPPFLAGS+=-I${.CURDIR} -DPNG_USE_PNGGCCRD + +# something like this for mmx assembler, but it core dumps for me at the moment +# .if ${MACHINE_ARCH} == "i386" +# CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK +# MKLINT= no +# .else + CPPFLAGS+=-DPNG_NO_MMX_CODE +# .endif + +CLEANFILES+=pngtest.o pngtest + +pngtest.o: pngtest.c + ${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} + +pngtest: pngtest.o libpng.a + ${CC} ${LDFLAGS} ${.ALLSRC} -o${.TARGET} -lz -lm + +test: pngtest + cd ${.CURDIR} && ${.OBJDIR}/pngtest + +.include diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.netbsd b/src/dep/src/irrlicht/libpng/scripts/makefile.netbsd index a004c5b..e2aedf7 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.netbsd +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.netbsd @@ -1,45 +1,45 @@ -# makefile for libpng for NetBSD for the standard -# make obj && make depend && make && make test -# make includes && make install -# Copyright (C) 2002 Patrick R.L. Welche -# Copyright (C) 2007 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h - -# You should also run makefile.ne0bsd - -LOCALBASE?=/usr/local -LIBDIR= ${LOCALBASE}/lib -MANDIR= ${LOCALBASE}/man -INCSDIR=${LOCALBASE}/include/libpng - -LIB= png -SHLIB_MAJOR= 3 -SHLIB_MINOR= 1.2.16 -SRCS= pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ - pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ - pngwtran.c pngmem.c pngerror.c pngpread.c -INCS= png.h pngconf.h -MAN= libpng.3 libpngpf.3 png.5 - -CPPFLAGS+=-I${.CURDIR} -DPNG_USE_PNGGCCRD - -# something like this for mmx assembler, but it core dumps for me at the moment -# .if ${MACHINE_ARCH} == "i386" -# CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK -# MKLINT= no -# .else - CPPFLAGS+=-DPNG_NO_MMX_CODE -# .endif - -CLEANFILES+=pngtest.o pngtest - -pngtest.o: pngtest.c - ${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} - -pngtest: pngtest.o libpng.a - ${CC} ${LDFLAGS} ${.ALLSRC} -o${.TARGET} -lz -lm - -test: pngtest - cd ${.CURDIR} && ${.OBJDIR}/pngtest - -.include +# makefile for libpng for NetBSD for the standard +# make obj && make depend && make && make test +# make includes && make install +# Copyright (C) 2002 Patrick R.L. Welche +# Copyright (C) 2007 Glenn Randers-Pehrson +# For conditions of distribution and use, see copyright notice in png.h + +# You should also run makefile.ne0bsd + +LOCALBASE?=/usr/local +LIBDIR= ${LOCALBASE}/lib +MANDIR= ${LOCALBASE}/man +INCSDIR=${LOCALBASE}/include/libpng + +LIB= png +SHLIB_MAJOR= 3 +SHLIB_MINOR= 1.2.16 +SRCS= pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ + pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ + pngwtran.c pngmem.c pngerror.c pngpread.c +INCS= png.h pngconf.h +MAN= libpng.3 libpngpf.3 png.5 + +CPPFLAGS+=-I${.CURDIR} -DPNG_USE_PNGGCCRD + +# something like this for mmx assembler, but it core dumps for me at the moment +# .if ${MACHINE_ARCH} == "i386" +# CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK +# MKLINT= no +# .else + CPPFLAGS+=-DPNG_NO_MMX_CODE +# .endif + +CLEANFILES+=pngtest.o pngtest + +pngtest.o: pngtest.c + ${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} + +pngtest: pngtest.o libpng.a + ${CC} ${LDFLAGS} ${.ALLSRC} -o${.TARGET} -lz -lm + +test: pngtest + cd ${.CURDIR} && ${.OBJDIR}/pngtest + +.include diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.nommx b/src/dep/src/irrlicht/libpng/scripts/makefile.nommx index 1851bdc..f1d0f68 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.nommx +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.nommx @@ -1,248 +1,248 @@ -# makefile for libpng.a and libpng12.so on Linux ELF with gcc -# Copyright (C) 1998, 1999, 2002, 2006, 2007 Greg Roelofs and -# Glenn Randers-Pehrson -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=gcc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -# where "make install" puts libpng12.a, libpng12.so*, -# libpng12/png.h and libpng12/pngconf.h -# Prefix must be a full pathname. -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located. -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \ - -DPNG_NO_MMX_CODE \ - $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 - -LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm -LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s!@PREFIX@!$(prefix)! \ - | sed -e "s!Cflags: !Cflags: -DPNG_NO_MMX_CODE !"> libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME) -DPNG_NO_MMX_CODE\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \ - -o $(OLDSOVER) \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -pngtest-static: pngtest.o libpng.a - $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) - -test: pngtest pngtest-static - @echo "" - @echo " Running pngtest dynamically linked with $(LIBSO):" - @echo "" - ./pngtest - @echo "" - @echo " Running pngtest statically linked with libpng.a:" - @echo "" - ./pngtest-static - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h +# makefile for libpng.a and libpng12.so on Linux ELF with gcc +# Copyright (C) 1998, 1999, 2002, 2006, 2007 Greg Roelofs and +# Glenn Randers-Pehrson +# Copyright (C) 1996, 1997 Andreas Dilger +# For conditions of distribution and use, see copyright notice in png.h + +# Library name: +LIBNAME = libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).so +LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) +LIBSOVER=$(LIBNAME).so.$(PNGVER) +OLDSO=libpng.so +OLDSOMAJ=libpng.so.3 +OLDSOVER=libpng.so.3.$(PNGMIN) + +# Utilities: +AR_RC=ar rc +CC=gcc +MKDIR_P=mkdir -p +LN_SF=ln -sf +RANLIB=ranlib +RM_F=/bin/rm -f + +# where "make install" puts libpng12.a, libpng12.so*, +# libpng12/png.h and libpng12/pngconf.h +# Prefix must be a full pathname. +prefix=/usr/local +exec_prefix=$(prefix) + +# Where the zlib library and include files are located. +#ZLIBLIB=/usr/local/lib +#ZLIBINC=/usr/local/include +ZLIBLIB=../zlib +ZLIBINC=../zlib + +ALIGN= +# for i386: +#ALIGN=-malign-loops=2 -malign-functions=2 + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion + +# for pgcc version 2.95.1, -O3 is buggy; don't use it. + +CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \ + -DPNG_NO_MMX_CODE \ + $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 + +LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm +LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm + +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +.c.pic.o: + $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c + +all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s!@PREFIX@!$(prefix)! \ + | sed -e "s!Cflags: !Cflags: -DPNG_NO_MMX_CODE !"> libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME) -DPNG_NO_MMX_CODE\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ + echo libs=\"-lpng12 -lz -lm\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJSDLL) + $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) + +$(OLDSOVER): $(OBJSDLL) + $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \ + -o $(OLDSOVER) \ + $(OBJSDLL) + +pngtest: pngtest.o $(LIBSO) + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +pngtest-static: pngtest.o libpng.a + $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) + +test: pngtest pngtest-static + @echo "" + @echo " Running pngtest dynamically linked with $(LIBSO):" + @echo "" + ./pngtest + @echo "" + @echo " Running pngtest statically linked with libpng.a:" + @echo "" + ./pngtest-static + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + $(CC) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ + $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ + $(OLDSOVER) \ + libpng.pc + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h +pngerror.o pngerror.pic.o: png.h pngconf.h +pngrio.o pngrio.pic.o: png.h pngconf.h +pngwio.o pngwio.pic.o: png.h pngconf.h +pngmem.o pngmem.pic.o: png.h pngconf.h +pngset.o pngset.pic.o: png.h pngconf.h +pngget.o pngget.pic.o: png.h pngconf.h +pngread.o pngread.pic.o: png.h pngconf.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h +pngpread.o pngpread.pic.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.openbsd b/src/dep/src/irrlicht/libpng/scripts/makefile.openbsd index abd76c6..f67436b 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.openbsd +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.openbsd @@ -1,73 +1,73 @@ -# makefile for libpng -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# Copyright (C) 2007 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h - -PREFIX?= /usr/local -LIBDIR= ${PREFIX}/lib -MANDIR= ${PREFIX}/man/cat - -SHLIB_MAJOR= 0 -SHLIB_MINOR= 1.2.16 - -LIB= png -SRCS= png.c pngerror.c pnggccrd.c pngget.c pngmem.c pngpread.c \ - pngread.c pngrio.c pngrtran.c pngrutil.c pngset.c pngtrans.c \ - pngwio.c pngwrite.c pngwtran.c pngwutil.c - -HDRS= png.h pngconf.h - -CFLAGS+= -Wall -CPPFLAGS+= -I${.CURDIR} -DPNG_NO_MMX_CODE -DPNG_USE_PNGGCCRD - -NOPROFILE= Yes - -CLEANFILES+= pngtest.o pngtest - -MAN= libpng.3 libpngpf.3 png.5 -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO libpng.txt - -pngtest.o: pngtest.c - ${CC} ${CPPFLAGS} ${CFLAGS} -c ${.ALLSRC} -o ${.TARGET} - -pngtest: pngtest.o - ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} -L${.OBJDIR} -lpng -lz -lm - -test: pngtest - cd ${.OBJDIR} && env \ - LD_LIBRARY_PATH="${.OBJDIR}" ${.OBJDIR}/pngtest - -beforeinstall: - if [ ! -d ${DESTDIR}${PREFIX}/include/libpng ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${PREFIX}/include/libpng; \ - fi - if [ ! -d ${DESTDIR}${LIBDIR} ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${LIBDIR}; \ - fi - if [ ! -d ${DESTDIR}${LIBDIR}/debug ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${LIBDIR}/debug; \ - fi - if [ ! -d ${DESTDIR}${MANDIR}3 ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${MANDIR}3; \ - fi - if [ ! -d ${DESTDIR}${MANDIR}5 ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${MANDIR}5; \ - fi - if [ ! -d ${DESTDIR}${PREFIX}/share/doc/png ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${PREFIX}/share/doc/png; \ - fi - -afterinstall: - @rm -f ${DESTDIR}${LIBDIR}/libpng_pic.a - @rm -f ${DESTDIR}${LIBDIR}/debug/libpng.a - @rm -f ${DESTDIR}${PREFIX}/include/png.h - @rm -f ${DESTDIR}${PREFIX}/include/pngconf.h - @rmdir ${DESTDIR}${LIBDIR}/debug 2>/dev/null || true - ${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \ - -m ${NONBINMODE} ${HDRS} ${DESTDIR}${PREFIX}/include/libpng - ${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \ - -m ${NONBINMODE} ${HDRS} ${DESTDIR}${PREFIX}/include - ${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \ - -m ${NONBINMODE} ${DOCS} ${DESTDIR}${PREFIX}/share/doc/png - -.include +# makefile for libpng +# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. +# Copyright (C) 2007 Glenn Randers-Pehrson +# For conditions of distribution and use, see copyright notice in png.h + +PREFIX?= /usr/local +LIBDIR= ${PREFIX}/lib +MANDIR= ${PREFIX}/man/cat + +SHLIB_MAJOR= 0 +SHLIB_MINOR= 1.2.16 + +LIB= png +SRCS= png.c pngerror.c pnggccrd.c pngget.c pngmem.c pngpread.c \ + pngread.c pngrio.c pngrtran.c pngrutil.c pngset.c pngtrans.c \ + pngwio.c pngwrite.c pngwtran.c pngwutil.c + +HDRS= png.h pngconf.h + +CFLAGS+= -Wall +CPPFLAGS+= -I${.CURDIR} -DPNG_NO_MMX_CODE -DPNG_USE_PNGGCCRD + +NOPROFILE= Yes + +CLEANFILES+= pngtest.o pngtest + +MAN= libpng.3 libpngpf.3 png.5 +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO libpng.txt + +pngtest.o: pngtest.c + ${CC} ${CPPFLAGS} ${CFLAGS} -c ${.ALLSRC} -o ${.TARGET} + +pngtest: pngtest.o + ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} -L${.OBJDIR} -lpng -lz -lm + +test: pngtest + cd ${.OBJDIR} && env \ + LD_LIBRARY_PATH="${.OBJDIR}" ${.OBJDIR}/pngtest + +beforeinstall: + if [ ! -d ${DESTDIR}${PREFIX}/include/libpng ]; then \ + ${INSTALL} -d -o root -g wheel ${DESTDIR}${PREFIX}/include/libpng; \ + fi + if [ ! -d ${DESTDIR}${LIBDIR} ]; then \ + ${INSTALL} -d -o root -g wheel ${DESTDIR}${LIBDIR}; \ + fi + if [ ! -d ${DESTDIR}${LIBDIR}/debug ]; then \ + ${INSTALL} -d -o root -g wheel ${DESTDIR}${LIBDIR}/debug; \ + fi + if [ ! -d ${DESTDIR}${MANDIR}3 ]; then \ + ${INSTALL} -d -o root -g wheel ${DESTDIR}${MANDIR}3; \ + fi + if [ ! -d ${DESTDIR}${MANDIR}5 ]; then \ + ${INSTALL} -d -o root -g wheel ${DESTDIR}${MANDIR}5; \ + fi + if [ ! -d ${DESTDIR}${PREFIX}/share/doc/png ]; then \ + ${INSTALL} -d -o root -g wheel ${DESTDIR}${PREFIX}/share/doc/png; \ + fi + +afterinstall: + @rm -f ${DESTDIR}${LIBDIR}/libpng_pic.a + @rm -f ${DESTDIR}${LIBDIR}/debug/libpng.a + @rm -f ${DESTDIR}${PREFIX}/include/png.h + @rm -f ${DESTDIR}${PREFIX}/include/pngconf.h + @rmdir ${DESTDIR}${LIBDIR}/debug 2>/dev/null || true + ${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \ + -m ${NONBINMODE} ${HDRS} ${DESTDIR}${PREFIX}/include/libpng + ${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \ + -m ${NONBINMODE} ${HDRS} ${DESTDIR}${PREFIX}/include + ${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \ + -m ${NONBINMODE} ${DOCS} ${DESTDIR}${PREFIX}/share/doc/png + +.include diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.os2 b/src/dep/src/irrlicht/libpng/scripts/makefile.os2 index e2eed69..588067d 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.os2 +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.os2 @@ -1,69 +1,69 @@ -# makefile for libpng on OS/2 with gcc -# For conditions of distribution and use, see copyright notice in png.h - -# Related files: pngos2.def - -CC=gcc -Zomf -s - -# Where the zlib library and include files are located -ZLIBLIB=../zlib -ZLIBINC=../zlib - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) -Wall -O6 -funroll-loops -malign-loops=2 \ - -malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lzdll -Zcrtdll -AR=emxomfar - -PNGLIB=png.lib -IMPLIB=emximp -SHAREDLIB=png.dll -SHAREDLIBIMP=pngdll.lib - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -.SUFFIXES: .c .o - -all: $(PNGLIB) $(SHAREDLIB) $(SHAREDLIBIMP) - -$(PNGLIB): $(OBJS) - $(AR) rc $@ $(OBJS) - -$(SHAREDLIB): $(OBJS) pngos2.def - $(CC) $(LDFLAGS) -Zdll -o $@ $^ - -$(SHAREDLIBIMP): pngos2.def - $(IMPLIB) -o $@ $^ - -pngtest.exe: pngtest.o png.dll pngdll.lib - $(CC) -o $@ $(CFLAGS) $< $(LDFLAGS) - -test: pngtest.exe - ./pngtest.exe - -clean: - rm -f *.o $(PNGLIB) png.dll pngdll.lib pngtest.exe pngout.png - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h +# makefile for libpng on OS/2 with gcc +# For conditions of distribution and use, see copyright notice in png.h + +# Related files: pngos2.def + +CC=gcc -Zomf -s + +# Where the zlib library and include files are located +ZLIBLIB=../zlib +ZLIBINC=../zlib + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion +CFLAGS=-I$(ZLIBINC) -Wall -O6 -funroll-loops -malign-loops=2 \ + -malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5 +LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lzdll -Zcrtdll +AR=emxomfar + +PNGLIB=png.lib +IMPLIB=emximp +SHAREDLIB=png.dll +SHAREDLIBIMP=pngdll.lib + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +.SUFFIXES: .c .o + +all: $(PNGLIB) $(SHAREDLIB) $(SHAREDLIBIMP) + +$(PNGLIB): $(OBJS) + $(AR) rc $@ $(OBJS) + +$(SHAREDLIB): $(OBJS) pngos2.def + $(CC) $(LDFLAGS) -Zdll -o $@ $^ + +$(SHAREDLIBIMP): pngos2.def + $(IMPLIB) -o $@ $^ + +pngtest.exe: pngtest.o png.dll pngdll.lib + $(CC) -o $@ $(CFLAGS) $< $(LDFLAGS) + +test: pngtest.exe + ./pngtest.exe + +clean: + rm -f *.o $(PNGLIB) png.dll pngdll.lib pngtest.exe pngout.png + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h +pngerror.o pngerror.pic.o: png.h pngconf.h +pngrio.o pngrio.pic.o: png.h pngconf.h +pngwio.o pngwio.pic.o: png.h pngconf.h +pngmem.o pngmem.pic.o: png.h pngconf.h +pngset.o pngset.pic.o: png.h pngconf.h +pngget.o pngget.pic.o: png.h pngconf.h +pngread.o pngread.pic.o: png.h pngconf.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h +pngpread.o pngpread.pic.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.sco b/src/dep/src/irrlicht/libpng/scripts/makefile.sco index 2b93acc..fe98174 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.sco +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.sco @@ -1,225 +1,225 @@ -# makefile for SCO OSr5 ELF and Unixware 7 with Native cc -# Contributed by Mike Hopkirk (hops@sco.com) modified from Makefile.lnx -# force ELF build dynamic linking, SONAME setting in lib and RPATH in app -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1998 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -CC=cc -AR_RC=ar rc -MKDIR_P=mkdir -LN_SF=ln -f -s -RANLIB=echo -RM_F=/bin/rm -f - -# where make install puts libpng.a, $(OLDSO)*, and png.h -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -CFLAGS= -dy -belf -I$(ZLIBINC) -O3 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz -lm - -INCPATH=$(prefix)/include/libpng -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo ccopts=\"-belf\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(CC) -G -Wl,-h,$(LIBSOMAJ) -o $(LIBSOVER) \ - $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(CC) -G -Wl,-h,$(OLDSOMAJ) -o $(OLDSOVER) \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - LD_RUN_PATH=.:$(ZLIBLIB) $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - -@$(RM_F) $(DI)/png.h - -@$(RM_F) $(DI)/pngconf.h - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) $(CFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h +# makefile for SCO OSr5 ELF and Unixware 7 with Native cc +# Contributed by Mike Hopkirk (hops@sco.com) modified from Makefile.lnx +# force ELF build dynamic linking, SONAME setting in lib and RPATH in app +# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 1998 Greg Roelofs +# Copyright (C) 1996, 1997 Andreas Dilger +# For conditions of distribution and use, see copyright notice in png.h + +# Library name: +LIBNAME = libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).so +LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) +LIBSOVER=$(LIBNAME).so.$(PNGVER) +OLDSO=libpng.so +OLDSOMAJ=libpng.so.3 +OLDSOVER=libpng.so.3.$(PNGMIN) + +# Utilities: +CC=cc +AR_RC=ar rc +MKDIR_P=mkdir +LN_SF=ln -f -s +RANLIB=echo +RM_F=/bin/rm -f + +# where make install puts libpng.a, $(OLDSO)*, and png.h +prefix=/usr/local +exec_prefix=$(prefix) + +# Where the zlib library and include files are located +#ZLIBLIB=/usr/local/lib +#ZLIBINC=/usr/local/include +ZLIBLIB=../zlib +ZLIBINC=../zlib + +CFLAGS= -dy -belf -I$(ZLIBINC) -O3 +LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz -lm + +INCPATH=$(prefix)/include/libpng +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +.c.pic.o: + $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c + +all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo ccopts=\"-belf\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo libs=\"-lpng12 -lz -lm\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJSDLL) + $(CC) -G -Wl,-h,$(LIBSOMAJ) -o $(LIBSOVER) \ + $(OBJSDLL) + +$(OLDSOVER): $(OBJSDLL) + $(CC) -G -Wl,-h,$(OLDSOMAJ) -o $(OLDSOVER) \ + $(OBJSDLL) + +pngtest: pngtest.o $(LIBSO) + LD_RUN_PATH=.:$(ZLIBLIB) $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + -@$(RM_F) $(DI)/png.h + -@$(RM_F) $(DI)/pngconf.h + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) $(CFLAGS) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + $(CC) $(CFLAGS) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(ZLIBLIB) \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ + $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ + $(OLDSOVER) \ + libpng.pc + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h +pngerror.o pngerror.pic.o: png.h pngconf.h +pngrio.o pngrio.pic.o: png.h pngconf.h +pngwio.o pngwio.pic.o: png.h pngconf.h +pngmem.o pngmem.pic.o: png.h pngconf.h +pngset.o pngset.pic.o: png.h pngconf.h +pngget.o pngget.pic.o: png.h pngconf.h +pngread.o pngread.pic.o: png.h pngconf.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h +pngpread.o pngpread.pic.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.sggcc b/src/dep/src/irrlicht/libpng/scripts/makefile.sggcc index 4f179dd..55d2fb3 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.sggcc +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.sggcc @@ -1,238 +1,238 @@ -# makefile for libpng.a and libpng12.so, SGI IRIX with 'cc' -# Copyright (C) 2001-2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME=libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=gcc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=echo -RM_F=/bin/rm -f - -# Where make install puts libpng.a, libpng12.so, and libpng12/png.h -# Prefix must be a full pathname. - -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib32 -#ZLIBINC=/usr/local/include -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -# ABI can be blank to use default for your system, -32, -o32, -n32, or -64 -# See "man abi". zlib must be built with the same ABI. -ABI= - -WARNMORE= # -g -DPNG_DEBUG=5 -CFLAGS=$(ABI) -I$(ZLIBINC) -O2 $(WARNMORE) -fPIC -mabi=n32 -LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm -LDSHARED=cc $(ABI) -shared -soname $(LIBSOMAJ) \ - -set_version sgi$(PNGMAJ).0 -LDLEGACY=cc $(ABI) -shared -soname $(OLDSOMAJ) \ - -set_version sgi$3.0 -# See "man dso" for info about shared objects - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -#LIBPATH=$(exec_prefix)/lib32 -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = pnggccrd.o png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest shared libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -shared: $(LIBSOVER) - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo ccopts=\"$(ABI)\"; \ - echo ldopts=\"$(ABI)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libdir=\"$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJS) - $(LDSHARED) -o $@ $(OBJS) - $(RM_F) $(LIBSO) $(LIBSOMAJ) - -$(OLDSOVER): $(OBJS) - $(LDLEGACY) -o $@ $(OBJS) - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - echo - echo Testing local static library. - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -rpath $(ZLIBLIB):$(DL) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -rpath $(ZLIBLIB):`$(BINPATH)/$(LIBNAME)-config --libdir` \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) libpng.a pngtest pngtesti pngout.png libpng.pc libpng-config \ - $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - so_locations - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pnggccrd.o: png.h pngconf.h - +# makefile for libpng.a and libpng12.so, SGI IRIX with 'cc' +# Copyright (C) 2001-2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. +# For conditions of distribution and use, see copyright notice in png.h + +# Library name: +LIBNAME=libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).so +LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) +LIBSOVER=$(LIBNAME).so.$(PNGVER) +OLDSO=libpng.so +OLDSOMAJ=libpng.so.3 +OLDSOVER=libpng.so.3.$(PNGMIN) + +# Utilities: +AR_RC=ar rc +CC=gcc +MKDIR_P=mkdir -p +LN_SF=ln -sf +RANLIB=echo +RM_F=/bin/rm -f + +# Where make install puts libpng.a, libpng12.so, and libpng12/png.h +# Prefix must be a full pathname. + +prefix=/usr/local +exec_prefix=$(prefix) + +# Where the zlib library and include files are located +#ZLIBLIB=/usr/local/lib32 +#ZLIBINC=/usr/local/include +#ZLIBLIB=/usr/local/lib +#ZLIBINC=/usr/local/include +ZLIBLIB=../zlib +ZLIBINC=../zlib + +# ABI can be blank to use default for your system, -32, -o32, -n32, or -64 +# See "man abi". zlib must be built with the same ABI. +ABI= + +WARNMORE= # -g -DPNG_DEBUG=5 +CFLAGS=$(ABI) -I$(ZLIBINC) -O2 $(WARNMORE) -fPIC -mabi=n32 +LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm +LDSHARED=cc $(ABI) -shared -soname $(LIBSOMAJ) \ + -set_version sgi$(PNGMAJ).0 +LDLEGACY=cc $(ABI) -shared -soname $(OLDSOMAJ) \ + -set_version sgi$3.0 +# See "man dso" for info about shared objects + +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +#LIBPATH=$(exec_prefix)/lib32 +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = pnggccrd.o png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +all: libpng.a pngtest shared libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +shared: $(LIBSOVER) + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo ccopts=\"$(ABI)\"; \ + echo ldopts=\"$(ABI)\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo libdir=\"$(LIBPATH)\"; \ + echo libs=\"-lpng12 -lz -lm\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJS) + $(LDSHARED) -o $@ $(OBJS) + $(RM_F) $(LIBSO) $(LIBSOMAJ) + +$(OLDSOVER): $(OBJS) + $(LDLEGACY) -o $@ $(OBJS) + +pngtest: pngtest.o libpng.a + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + echo + echo Testing local static library. + ./pngtest + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) \ + -rpath $(ZLIBLIB):$(DL) \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + echo + echo Testing installed dynamic shared library. + $(CC) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(ZLIBLIB) \ + -rpath $(ZLIBLIB):`$(BINPATH)/$(LIBNAME)-config --libdir` \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtesti pngtest.png + +clean: + $(RM_F) libpng.a pngtest pngtesti pngout.png libpng.pc libpng-config \ + $(LIBSO) $(LIBSOMAJ)* \ + $(OLDSOVER) \ + so_locations + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o: png.h pngconf.h +pngerror.o: png.h pngconf.h +pngrio.o: png.h pngconf.h +pngwio.o: png.h pngconf.h +pngmem.o: png.h pngconf.h +pngset.o: png.h pngconf.h +pngget.o: png.h pngconf.h +pngread.o: png.h pngconf.h +pngrtran.o: png.h pngconf.h +pngrutil.o: png.h pngconf.h +pngtest.o: png.h pngconf.h +pngtrans.o: png.h pngconf.h +pngwrite.o: png.h pngconf.h +pngwtran.o: png.h pngconf.h +pngwutil.o: png.h pngconf.h +pngpread.o: png.h pngconf.h +pnggccrd.o: png.h pngconf.h + diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.sgi b/src/dep/src/irrlicht/libpng/scripts/makefile.sgi index 9b4b009..79e2387 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.sgi +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.sgi @@ -1,243 +1,243 @@ -# makefile for libpng.a and libpng12.so, SGI IRIX with 'cc' -# Copyright (C) 2001-2002, 2006, 2007 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME=libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=cc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=echo -RM_F=/bin/rm -f - -# Where make install puts libpng.a, libpng12.so, and libpng12/png.h -# Prefix must be a full pathname. - -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib32 -#ZLIBINC=/usr/local/include -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -# ABI can be blank to use default for your system, -32, -o32, -n32, or -64 -# See "man abi". zlib must be built with the same ABI. -ABI= - -WARNMORE=-fullwarn -# Note: -KPIC is the default anyhow -#CFLAGS= $(ABI) -I$(ZLIBINC) -O $(WARNMORE) -KPIC -DPNG_USE_PNGGCCRD # -g -DPNG_DEBUG=5 -CFLAGS=$(ABI) -I$(ZLIBINC) -O $(WARNMORE) -DPNG_USE_PNGGCCRD \ - -DPNG_NO_MMX_CODE -LDFLAGS_A=$(ABI) -L. -L$(ZLIBLIB) -lpng12 -lz -lm -LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm -LDSHARED=cc $(ABI) -shared -soname $(LIBSOMAJ) \ - -set_version sgi$(PNGMAJ).0 -LDLEGACY=cc $(ABI) -shared -soname $(OLDSOMAJ) \ - -set_version sgi$3.0 -# See "man dso" for info about shared objects - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -#LIBPATH=$(exec_prefix)/lib32 -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = pnggccrd.o png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest shared libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -shared: $(LIBSOVER) - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo cppflags=\"-DPNG_USE_PNGGCCRD -DPNG_NO_MMX_CODE\"; \ - echo ccopts=\"$(ABI)\"; \ - echo ldopts=\"$(ABI)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libdir=\"$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJS) - $(LDSHARED) -o $@ $(OBJS) - $(RM_F) $(LIBSO) $(LIBSOMAJ) - -$(OLDSOVER): $(OBJS) - $(LDLEGACY) -o $@ $(OBJS) - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - echo - echo Testing local static library. - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -rpath $(ZLIBLIB):$(DL) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -rpath $(ZLIBLIB):`$(BINPATH)/$(LIBNAME)-config --libdir` \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png libpng.pc libpng-config \ - $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - so_locations - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pnggccrd.o: png.h pngconf.h - +# makefile for libpng.a and libpng12.so, SGI IRIX with 'cc' +# Copyright (C) 2001-2002, 2006, 2007 Glenn Randers-Pehrson +# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. +# For conditions of distribution and use, see copyright notice in png.h + +# Library name: +LIBNAME=libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).so +LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) +LIBSOVER=$(LIBNAME).so.$(PNGVER) +OLDSO=libpng.so +OLDSOMAJ=libpng.so.3 +OLDSOVER=libpng.so.3.$(PNGMIN) + +# Utilities: +AR_RC=ar rc +CC=cc +MKDIR_P=mkdir -p +LN_SF=ln -sf +RANLIB=echo +RM_F=/bin/rm -f + +# Where make install puts libpng.a, libpng12.so, and libpng12/png.h +# Prefix must be a full pathname. + +prefix=/usr/local +exec_prefix=$(prefix) + +# Where the zlib library and include files are located +#ZLIBLIB=/usr/local/lib32 +#ZLIBINC=/usr/local/include +#ZLIBLIB=/usr/local/lib +#ZLIBINC=/usr/local/include +ZLIBLIB=../zlib +ZLIBINC=../zlib + +# ABI can be blank to use default for your system, -32, -o32, -n32, or -64 +# See "man abi". zlib must be built with the same ABI. +ABI= + +WARNMORE=-fullwarn +# Note: -KPIC is the default anyhow +#CFLAGS= $(ABI) -I$(ZLIBINC) -O $(WARNMORE) -KPIC -DPNG_USE_PNGGCCRD # -g -DPNG_DEBUG=5 +CFLAGS=$(ABI) -I$(ZLIBINC) -O $(WARNMORE) -DPNG_USE_PNGGCCRD \ + -DPNG_NO_MMX_CODE +LDFLAGS_A=$(ABI) -L. -L$(ZLIBLIB) -lpng12 -lz -lm +LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm +LDSHARED=cc $(ABI) -shared -soname $(LIBSOMAJ) \ + -set_version sgi$(PNGMAJ).0 +LDLEGACY=cc $(ABI) -shared -soname $(OLDSOMAJ) \ + -set_version sgi$3.0 +# See "man dso" for info about shared objects + +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +#LIBPATH=$(exec_prefix)/lib32 +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = pnggccrd.o png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +all: libpng.a pngtest shared libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +shared: $(LIBSOVER) + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo cppflags=\"-DPNG_USE_PNGGCCRD -DPNG_NO_MMX_CODE\"; \ + echo ccopts=\"$(ABI)\"; \ + echo ldopts=\"$(ABI)\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo libdir=\"$(LIBPATH)\"; \ + echo libs=\"-lpng12 -lz -lm\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJS) + $(LDSHARED) -o $@ $(OBJS) + $(RM_F) $(LIBSO) $(LIBSOMAJ) + +$(OLDSOVER): $(OBJS) + $(LDLEGACY) -o $@ $(OBJS) + +pngtest: pngtest.o libpng.a + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + echo + echo Testing local static library. + ./pngtest + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(DL) -L$(ZLIBLIB) \ + -rpath $(ZLIBLIB):$(DL) \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtestd pngtest.png + +test-installed: + echo + echo Testing installed dynamic shared library. + $(CC) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -L$(ZLIBLIB) \ + -rpath $(ZLIBLIB):`$(BINPATH)/$(LIBNAME)-config --libdir` \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a pngtest pngtesti pngout.png libpng.pc libpng-config \ + $(LIBSO) $(LIBSOMAJ)* \ + $(OLDSOVER) \ + so_locations + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o: png.h pngconf.h +pngerror.o: png.h pngconf.h +pngrio.o: png.h pngconf.h +pngwio.o: png.h pngconf.h +pngmem.o: png.h pngconf.h +pngset.o: png.h pngconf.h +pngget.o: png.h pngconf.h +pngread.o: png.h pngconf.h +pngrtran.o: png.h pngconf.h +pngrutil.o: png.h pngconf.h +pngtest.o: png.h pngconf.h +pngtrans.o: png.h pngconf.h +pngwrite.o: png.h pngconf.h +pngwtran.o: png.h pngconf.h +pngwutil.o: png.h pngconf.h +pngpread.o: png.h pngconf.h +pnggccrd.o: png.h pngconf.h + diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.so9 b/src/dep/src/irrlicht/libpng/scripts/makefile.so9 index 7b2b20c..21dbf0e 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.so9 +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.so9 @@ -1,247 +1,247 @@ -# makefile for libpng on Solaris 9 (beta) with Forte cc -# Updated by Chad Schrock for Solaris 9 -# Contributed by William L. Sebok, based on makefile.linux -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1998-2001 Greg Roelofs -# Copyright (C) 1996-1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) -LIBNAME = libpng12 - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -# gcc 2.95 doesn't work. -CC=cc -AR_RC=ar rc -MKDIR_P=mkdir -p -LN_SF=ln -f -s -RANLIB=echo -RM_F=/bin/rm -f - -# Where make install puts libpng.a, $(OLDSO)*, and png.h -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -# Changing these to ../zlib poses a security risk. If you want -# to have zlib in an adjacent directory, specify the full path instead of "..". -#ZLIBLIB=../zlib -#ZLIBINC=../zlib -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -#Use the preinstalled zlib that comes with Solaris 9: -ZLIBLIB=/usr/lib -ZLIBINC=/usr/include - -#WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -#CFLAGS=-I$(ZLIBINC) -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -CFLAGS=-I$(ZLIBINC) -O3 -LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-R$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - @case "`type ld`" in *ucb*) \ - echo; \ - echo '## WARNING:'; \ - echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ - echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ - echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ - echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ - echo '## at all. If it is, things are likely to break because of'; \ - echo '## the libucb dependency that is created.'; \ - echo; \ - ;; \ - esac - $(LD) -G -h $(LIBSOMAJ) \ - -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJS) - $(LD) -G -h $(OLDSOMAJ) \ - -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - -L$(DL) -L$(ZLIBLIB) -R$(ZLIBLIB) -R$(DL) - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h +# makefile for libpng on Solaris 9 (beta) with Forte cc +# Updated by Chad Schrock for Solaris 9 +# Contributed by William L. Sebok, based on makefile.linux +# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 1998-2001 Greg Roelofs +# Copyright (C) 1996-1997 Andreas Dilger +# For conditions of distribution and use, see copyright notice in png.h + +# Library name: +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) +LIBNAME = libpng12 + +# Shared library names: +LIBSO=$(LIBNAME).so +LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) +LIBSOVER=$(LIBNAME).so.$(PNGVER) +OLDSO=libpng.so +OLDSOMAJ=libpng.so.3 +OLDSOVER=libpng.so.3.$(PNGMIN) + +# Utilities: +# gcc 2.95 doesn't work. +CC=cc +AR_RC=ar rc +MKDIR_P=mkdir -p +LN_SF=ln -f -s +RANLIB=echo +RM_F=/bin/rm -f + +# Where make install puts libpng.a, $(OLDSO)*, and png.h +prefix=/usr/local +exec_prefix=$(prefix) + +# Where the zlib library and include files are located +# Changing these to ../zlib poses a security risk. If you want +# to have zlib in an adjacent directory, specify the full path instead of "..". +#ZLIBLIB=../zlib +#ZLIBINC=../zlib +#ZLIBLIB=/usr/local/lib +#ZLIBINC=/usr/local/include +#Use the preinstalled zlib that comes with Solaris 9: +ZLIBLIB=/usr/lib +ZLIBINC=/usr/include + +#WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion +#CFLAGS=-I$(ZLIBINC) -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 +CFLAGS=-I$(ZLIBINC) -O3 +LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm + +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +.c.pic.o: + $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c + +all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo R_opts=\"-R$(LIBPATH)\"; \ + echo libs=\"-lpng12 -lz -lm\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJSDLL) + @case "`type ld`" in *ucb*) \ + echo; \ + echo '## WARNING:'; \ + echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ + echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ + echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ + echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ + echo '## at all. If it is, things are likely to break because of'; \ + echo '## the libucb dependency that is created.'; \ + echo; \ + ;; \ + esac + $(LD) -G -h $(LIBSOMAJ) \ + -o $(LIBSOVER) $(OBJSDLL) + +$(OLDSOVER): $(OBJS) + $(LD) -G -h $(OLDSOMAJ) \ + -o $(OLDSOVER) $(OBJSDLL) + +pngtest: pngtest.o $(LIBSO) + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ + $(LN_SF) $(LIBSOMAJ) $(LIBSO)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` \ + -L$(DL) -L$(ZLIBLIB) -R$(ZLIBLIB) -R$(DL) + ./pngtestd pngtest.png + +test-installed: + echo + echo Testing installed dynamic shared library. + $(CC) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \ + -L$(ZLIBLIB) -R$(ZLIBLIB) + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ + libpng-config $(LIBSO) $(LIBSOMAJ)* \ + $(OLDSOVER) \ + libpng.pc + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h +pngerror.o pngerror.pic.o: png.h pngconf.h +pngrio.o pngrio.pic.o: png.h pngconf.h +pngwio.o pngwio.pic.o: png.h pngconf.h +pngmem.o pngmem.pic.o: png.h pngconf.h +pngset.o pngset.pic.o: png.h pngconf.h +pngget.o pngget.pic.o: png.h pngconf.h +pngread.o pngread.pic.o: png.h pngconf.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h +pngpread.o pngpread.pic.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.solaris b/src/dep/src/irrlicht/libpng/scripts/makefile.solaris index c78cbd8..0c49a11 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.solaris +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.solaris @@ -1,244 +1,244 @@ -# makefile for libpng on Solaris 2.x with gcc -# Copyright (C) 2004, 2006, 2007 Glenn Randers-Pehrson -# Contributed by William L. Sebok, based on makefile.linux -# Copyright (C) 1998 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.16 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=gcc -MKDIR_P=mkdir -p -LN_SF=ln -f -s -RANLIB=echo -RM_F=/bin/rm -f - -# Where make install puts libpng.a, libpng12.so*, and png.h -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -# Changing these to ../zlib poses a security risk. If you want -# to have zlib in an adjacent directory, specify the full path instead of "..". -#ZLIBLIB=../zlib -#ZLIBINC=../zlib - -ZLIBLIB=/usr/local/lib -ZLIBINC=/usr/local/include - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) -Wall -O \ - # $(WARNMORE) -g -DPNG_DEBUG=5 -LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo cppflags=\"-DPNG_USE_PNGGCCRD -DPNG_NO_MMX_CODE\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-R$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - @case "`type ld`" in *ucb*) \ - echo; \ - echo '## WARNING:'; \ - echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ - echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ - echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ - echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ - echo '## at all. If it is, things are likely to break because of'; \ - echo '## the libucb dependency that is created.'; \ - echo; \ - ;; \ - esac - $(LD) -G -h $(LIBSOMAJ) \ - -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJS) - $(LD) -G -h $(OLDSOMAJ) \ - -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - -L$(DL) -L$(ZLIBLIB) -R$(ZLIBLIB) -R$(DL) - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h +# makefile for libpng on Solaris 2.x with gcc +# Copyright (C) 2004, 2006, 2007 Glenn Randers-Pehrson +# Contributed by William L. Sebok, based on makefile.linux +# Copyright (C) 1998 Greg Roelofs +# Copyright (C) 1996, 1997 Andreas Dilger +# For conditions of distribution and use, see copyright notice in png.h + +# Library name: +LIBNAME = libpng12 +PNGMAJ = 0 +PNGMIN = 1.2.16 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# Shared library names: +LIBSO=$(LIBNAME).so +LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) +LIBSOVER=$(LIBNAME).so.$(PNGVER) +OLDSO=libpng.so +OLDSOMAJ=libpng.so.3 +OLDSOVER=libpng.so.3.$(PNGMIN) + +# Utilities: +AR_RC=ar rc +CC=gcc +MKDIR_P=mkdir -p +LN_SF=ln -f -s +RANLIB=echo +RM_F=/bin/rm -f + +# Where make install puts libpng.a, libpng12.so*, and png.h +prefix=/usr/local +exec_prefix=$(prefix) + +# Where the zlib library and include files are located +# Changing these to ../zlib poses a security risk. If you want +# to have zlib in an adjacent directory, specify the full path instead of "..". +#ZLIBLIB=../zlib +#ZLIBINC=../zlib + +ZLIBLIB=/usr/local/lib +ZLIBINC=/usr/local/include + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion +CFLAGS=-I$(ZLIBINC) -Wall -O \ + # $(WARNMORE) -g -DPNG_DEBUG=5 +LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm + +INCPATH=$(prefix)/include +LIBPATH=$(exec_prefix)/lib +MANPATH=$(prefix)/man +BINPATH=$(exec_prefix)/bin + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +DB=$(DESTDIR)$(BINPATH) +DI=$(DESTDIR)$(INCPATH) +DL=$(DESTDIR)$(LIBPATH) +DM=$(DESTDIR)$(MANPATH) + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +.c.pic.o: + $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c + +all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +libpng.pc: + cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc + +libpng-config: + ( cat scripts/libpng-config-head.in; \ + echo prefix=\"$(prefix)\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ + echo cppflags=\"-DPNG_USE_PNGGCCRD -DPNG_NO_MMX_CODE\"; \ + echo L_opts=\"-L$(LIBPATH)\"; \ + echo R_opts=\"-R$(LIBPATH)\"; \ + echo libs=\"-lpng12 -lz -lm\"; \ + cat scripts/libpng-config-body.in ) > libpng-config + chmod +x libpng-config + +$(LIBSO): $(LIBSOMAJ) + $(LN_SF) $(LIBSOMAJ) $(LIBSO) + +$(LIBSOMAJ): $(LIBSOVER) + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) + +$(LIBSOVER): $(OBJSDLL) + @case "`type ld`" in *ucb*) \ + echo; \ + echo '## WARNING:'; \ + echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ + echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ + echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ + echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ + echo '## at all. If it is, things are likely to break because of'; \ + echo '## the libucb dependency that is created.'; \ + echo; \ + ;; \ + esac + $(LD) -G -h $(LIBSOMAJ) \ + -o $(LIBSOVER) $(OBJSDLL) + +$(OLDSOVER): $(OBJS) + $(LD) -G -h $(OLDSOMAJ) \ + -o $(OLDSOVER) $(OBJSDLL) + +pngtest: pngtest.o $(LIBSO) + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + +install-headers: png.h pngconf.h + -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi + -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi + cp png.h pngconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h + -@$(RM_F) $(DI)/libpng + (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) + +install-static: install-headers libpng.a + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + cp libpng.a $(DL)/$(LIBNAME).a + chmod 644 $(DL)/$(LIBNAME).a + -@$(RM_F) $(DL)/libpng.a + (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) + +install-shared: install-headers $(LIBSOVER) libpng.pc \ + $(OLDSOVER) + -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi + -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) + -@$(RM_F) $(DL)/$(LIBSOMAJ) + -@$(RM_F) $(DL)/$(OLDSO) + -@$(RM_F) $(DL)/$(OLDSOMAJ) + -@$(RM_F) $(DL)/$(OLDSOVER)* + cp $(LIBSOVER) $(DL) + cp $(OLDSOVER) $(DL) + chmod 755 $(DL)/$(LIBSOVER) + chmod 755 $(DL)/$(OLDSOVER) + (cd $(DL); \ + $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ + $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSO); \ + $(LN_SF) $(LIBSOVER) $(LIBSOMAJ)) + -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi + -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc + -@$(RM_F) $(DL)/pkgconfig/libpng.pc + cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc + chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc + (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) + +install-man: libpng.3 libpngpf.3 png.5 + -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi + -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi + -@$(RM_F) $(DM)/man3/libpng.3 + -@$(RM_F) $(DM)/man3/libpngpf.3 + cp libpng.3 $(DM)/man3 + cp libpngpf.3 $(DM)/man3 + -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi + -@$(RM_F) $(DM)/man5/png.5 + cp png.5 $(DM)/man5 + +install-config: libpng-config + -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi + -@$(RM_F) $(DB)/libpng-config + -@$(RM_F) $(DB)/$(LIBNAME)-config + cp libpng-config $(DB)/$(LIBNAME)-config + chmod 755 $(DB)/$(LIBNAME)-config + (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) + +install: install-static install-shared install-man install-config + +# If you installed in $(DESTDIR), test-installed won't work until you +# move the library to its final location. Use test-dd to test it +# before then. + +test-dd: + echo + echo Testing installed dynamic shared library in $(DL). + $(CC) -I$(DI) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` \ + -L$(DL) -L$(ZLIBLIB) -R$(ZLIBLIB) -R$(DL) + ./pngtestd pngtest.png + +test-installed: + echo + echo Testing installed dynamic shared library. + $(CC) -I$(ZLIBINC) \ + `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ + -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \ + -L$(ZLIBLIB) -R$(ZLIBLIB) + ./pngtesti pngtest.png + +clean: + $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ + libpng-config $(LIBSO) $(LIBSOMAJ)* \ + $(OLDSOVER) \ + libpng.pc + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h +pngerror.o pngerror.pic.o: png.h pngconf.h +pngrio.o pngrio.pic.o: png.h pngconf.h +pngwio.o pngwio.pic.o: png.h pngconf.h +pngmem.o pngmem.pic.o: png.h pngconf.h +pngset.o pngset.pic.o: png.h pngconf.h +pngget.o pngget.pic.o: png.h pngconf.h +pngread.o pngread.pic.o: png.h pngconf.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h +pngpread.o pngpread.pic.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.std b/src/dep/src/irrlicht/libpng/scripts/makefile.std index eb0aea3..9b1925d 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.std +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.std @@ -1,92 +1,92 @@ -# makefile for libpng -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# where make install puts libpng.a and png.h -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -CC=cc -AR_RC=ar rc -MKDIR_P=mkdir -LN_SF=ln -sf -RANLIB=ranlib -RM_F=rm -f - -CFLAGS=-I$(ZLIBINC) -O # -g -DPNG_DEBUG=5 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install: libpng.a - -@$(MKDIR_P) $(DESTDIR)$(INCPATH) - -@$(MKDIR_P) $(DESTDIR)$(INCPATH)/libpng - -@$(MKDIR_P) $(DESTDIR)$(LIBPATH) - -@$(RM_F) $(DESTDIR)$(INCPATH)/png.h - -@$(RM_F) $(DESTDIR)$(INCPATH)/pngconf.h - cp png.h $(DESTDIR)$(INCPATH)/libpng - cp pngconf.h $(DESTDIR)$(INCPATH)/libpng - chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h - chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h - (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) - cp libpng.a $(DESTDIR)$(LIBPATH) - chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h - +# makefile for libpng +# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. +# For conditions of distribution and use, see copyright notice in png.h + +# where make install puts libpng.a and png.h +prefix=/usr/local +INCPATH=$(prefix)/include +LIBPATH=$(prefix)/lib + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +# Where the zlib library and include files are located +#ZLIBLIB=/usr/local/lib +#ZLIBINC=/usr/local/include +ZLIBLIB=../zlib +ZLIBINC=../zlib + +CC=cc +AR_RC=ar rc +MKDIR_P=mkdir +LN_SF=ln -sf +RANLIB=ranlib +RM_F=rm -f + +CFLAGS=-I$(ZLIBINC) -O # -g -DPNG_DEBUG=5 +LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +all: libpng.a pngtest + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +pngtest: pngtest.o libpng.a + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + +install: libpng.a + -@$(MKDIR_P) $(DESTDIR)$(INCPATH) + -@$(MKDIR_P) $(DESTDIR)$(INCPATH)/libpng + -@$(MKDIR_P) $(DESTDIR)$(LIBPATH) + -@$(RM_F) $(DESTDIR)$(INCPATH)/png.h + -@$(RM_F) $(DESTDIR)$(INCPATH)/pngconf.h + cp png.h $(DESTDIR)$(INCPATH)/libpng + cp pngconf.h $(DESTDIR)$(INCPATH)/libpng + chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h + chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h + (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) + cp libpng.a $(DESTDIR)$(LIBPATH) + chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a + +clean: + $(RM_F) *.o libpng.a pngtest pngout.png + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o: png.h pngconf.h +pngerror.o: png.h pngconf.h +pngrio.o: png.h pngconf.h +pngwio.o: png.h pngconf.h +pngmem.o: png.h pngconf.h +pngset.o: png.h pngconf.h +pngget.o: png.h pngconf.h +pngread.o: png.h pngconf.h +pngrtran.o: png.h pngconf.h +pngrutil.o: png.h pngconf.h +pngtest.o: png.h pngconf.h +pngtrans.o: png.h pngconf.h +pngwrite.o: png.h pngconf.h +pngwtran.o: png.h pngconf.h +pngwutil.o: png.h pngconf.h +pngpread.o: png.h pngconf.h + diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.sunos b/src/dep/src/irrlicht/libpng/scripts/makefile.sunos index fad81fc..ff19591 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.sunos +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.sunos @@ -1,97 +1,97 @@ -# makefile for libpng -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# where make install puts libpng.a and png.h -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow -Wconversion \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes - -CC=gcc -AR_RC=ar rc -MKDIR_P=mkdir -p -LN_SF=ln -f -s -RANLIB=ranlib -RM_F=/bin/rm -f - -CFLAGS=-I$(ZLIBINC) -O # $(WARNMORE) -DPNG_DEBUG=5 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install: libpng.a - -@$(MKDIR_P) $(DESTDIR)$(INCPATH) - -@$(MKDIR_P) $(DESTDIR)$(INCPATH)/libpng - -@$(MKDIR_P) $(DESTDIR)$(LIBPATH) - -@$(RM_F) $(DESTDIR)$(INCPATH)/png.h - -@$(RM_F) $(DESTDIR)$(INCPATH)/pngconf.h - cp png.h $(DESTDIR)$(INCPATH)/libpng - cp pngconf.h $(DESTDIR)$(INCPATH)/libpng - chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h - chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h - (cd $(DESTDIR)$(INCPATH); $(LN_SF) libpng/* .) - cp libpng.a $(DESTDIR)$(LIBPATH) - chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h - +# makefile for libpng +# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. +# For conditions of distribution and use, see copyright notice in png.h + +# where make install puts libpng.a and png.h +prefix=/usr/local +INCPATH=$(prefix)/include +LIBPATH=$(prefix)/lib + +# override DESTDIR= on the make install command line to easily support +# installing into a temporary location. Example: +# +# make install DESTDIR=/tmp/build/libpng +# +# If you're going to install into a temporary location +# via DESTDIR, $(DESTDIR)$(prefix) must already exist before +# you execute make install. +DESTDIR= + +# Where the zlib library and include files are located +#ZLIBLIB=/usr/local/lib +#ZLIBINC=/usr/local/include +ZLIBLIB=../zlib +ZLIBINC=../zlib + + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow -Wconversion \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes + +CC=gcc +AR_RC=ar rc +MKDIR_P=mkdir -p +LN_SF=ln -f -s +RANLIB=ranlib +RM_F=/bin/rm -f + +CFLAGS=-I$(ZLIBINC) -O # $(WARNMORE) -DPNG_DEBUG=5 +LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +all: libpng.a pngtest + +libpng.a: $(OBJS) + $(AR_RC) $@ $(OBJS) + $(RANLIB) $@ + +pngtest: pngtest.o libpng.a + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + +install: libpng.a + -@$(MKDIR_P) $(DESTDIR)$(INCPATH) + -@$(MKDIR_P) $(DESTDIR)$(INCPATH)/libpng + -@$(MKDIR_P) $(DESTDIR)$(LIBPATH) + -@$(RM_F) $(DESTDIR)$(INCPATH)/png.h + -@$(RM_F) $(DESTDIR)$(INCPATH)/pngconf.h + cp png.h $(DESTDIR)$(INCPATH)/libpng + cp pngconf.h $(DESTDIR)$(INCPATH)/libpng + chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h + chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h + (cd $(DESTDIR)$(INCPATH); $(LN_SF) libpng/* .) + cp libpng.a $(DESTDIR)$(LIBPATH) + chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a + +clean: + $(RM_F) *.o libpng.a pngtest pngout.png + +DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO +writelock: + chmod a-w *.[ch35] $(DOCS) scripts/* + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o: png.h pngconf.h +pngerror.o: png.h pngconf.h +pngrio.o: png.h pngconf.h +pngwio.o: png.h pngconf.h +pngmem.o: png.h pngconf.h +pngset.o: png.h pngconf.h +pngget.o: png.h pngconf.h +pngread.o: png.h pngconf.h +pngrtran.o: png.h pngconf.h +pngrutil.o: png.h pngconf.h +pngtest.o: png.h pngconf.h +pngtrans.o: png.h pngconf.h +pngwrite.o: png.h pngconf.h +pngwtran.o: png.h pngconf.h +pngwutil.o: png.h pngconf.h +pngpread.o: png.h pngconf.h + diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.tc3 b/src/dep/src/irrlicht/libpng/scripts/makefile.tc3 index cedefc4..21435a6 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.tc3 +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.tc3 @@ -1,89 +1,89 @@ -# Makefile for libpng -# TurboC/C++ (Note: All modules are compiled in C mode) - -# To use, do "make -fmakefile.tc3" - -# ----- Turbo C 3.00 (can be modified to work with earlier versions) ----- - -MODEL=l -CFLAGS=-O2 -Z -m$(MODEL) -I..\zlib -#CFLAGS=-D_NO_PROTO -O2 -Z -m$(MODEL) -I..\zlib # Turbo C older than 3.00 -CC=tcc -LD=tcc -LIB=tlib -LDFLAGS=-m$(MODEL) -L..\zlib -O=.obj -E=.exe - -# variables -OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) -OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) -OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) -OBJSL1 = +png$(O) +pngset$(O) +pngget$(O) +pngrutil$(O) +pngtrans$(O) -OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O) +pngerror$(O) -OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) +pngwio$(O) - -all: libpng$(MODEL).lib pngtest$(E) - -pngtest: pngtest$(E) - -test: pngtest$(E) - pngtest$(E) - -png$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngset$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngget$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngpread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngrtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngrutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngerror$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngmem$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngrio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngwio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngtrans$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngwrite$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngwutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -libpng$(MODEL).lib: $(OBJS1) $(OBJS2) $(OBJS3) - $(LIB) libpng$(MODEL) +$(OBJSL1) - $(LIB) libpng$(MODEL) +$(OBJSL2) - $(LIB) libpng$(MODEL) +$(OBJSL3) - -pngtest$(E): pngtest$(O) libpng$(MODEL).lib - $(LD) $(LDFLAGS) pngtest.obj libpng$(MODEL).lib zlib_$(MODEL).lib - -# End of makefile for libpng +# Makefile for libpng +# TurboC/C++ (Note: All modules are compiled in C mode) + +# To use, do "make -fmakefile.tc3" + +# ----- Turbo C 3.00 (can be modified to work with earlier versions) ----- + +MODEL=l +CFLAGS=-O2 -Z -m$(MODEL) -I..\zlib +#CFLAGS=-D_NO_PROTO -O2 -Z -m$(MODEL) -I..\zlib # Turbo C older than 3.00 +CC=tcc +LD=tcc +LIB=tlib +LDFLAGS=-m$(MODEL) -L..\zlib +O=.obj +E=.exe + +# variables +OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) +OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) +OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) +OBJSL1 = +png$(O) +pngset$(O) +pngget$(O) +pngrutil$(O) +pngtrans$(O) +OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O) +pngerror$(O) +OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) +pngwio$(O) + +all: libpng$(MODEL).lib pngtest$(E) + +pngtest: pngtest$(E) + +test: pngtest$(E) + pngtest$(E) + +png$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngset$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngget$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngread$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngpread$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngrtran$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngrutil$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngerror$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngmem$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngrio$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngwio$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngtest$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngtrans$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngwrite$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngwtran$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +pngwutil$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c + +libpng$(MODEL).lib: $(OBJS1) $(OBJS2) $(OBJS3) + $(LIB) libpng$(MODEL) +$(OBJSL1) + $(LIB) libpng$(MODEL) +$(OBJSL2) + $(LIB) libpng$(MODEL) +$(OBJSL3) + +pngtest$(E): pngtest$(O) libpng$(MODEL).lib + $(LD) $(LDFLAGS) pngtest.obj libpng$(MODEL).lib zlib_$(MODEL).lib + +# End of makefile for libpng diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.vcawin32 b/src/dep/src/irrlicht/libpng/scripts/makefile.vcawin32 index 89effe5..4c2f3cc 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.vcawin32 +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.vcawin32 @@ -1,103 +1,103 @@ -# makefile for libpng -# Copyright (C) 1998 Tim Wegner -# For conditions of distribution and use, see copyright notice in png.h -# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib -# To use, do "nmake /f scripts\makefile.vcawin32" - -# -------- Microsoft Visual C++ 5.0 and later, uses assembler code -------- -# If you don't want to use assembler (MMX) code, use makefile.vcwin32 instead. - -# Compiler, linker, librarian, and other tools -CC = cl -LD = link -AR = lib -CFLAGS = -DPNG_USE_PNGVCRD -nologo -MD -O2 -W3 -I..\zlib -LDFLAGS = -nologo -ARFLAGS = -nologo -RM = del - -# File extensions -O=.obj - -#uncomment next to put error messages in a file -#ERRFILE= >> pngerrs.log - -# Variables -OBJS1 = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) -OBJS2 = pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) -OBJS3 = pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) -OBJS4 = pngvcrd$(O) -OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) - -# Targets -all: libpng.lib - -png$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngvcrd$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS) - -$(RM) $@ - $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE) - -pngtest.exe: pngtest$(O) libpng.lib - $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE) - -test: pngtest.exe - pngtest - -clean: - -$(RM) *$(O) - -$(RM) libpng.lib - -$(RM) pngtest.exe - -$(RM) pngout.png - -# End of makefile for libpng - +# makefile for libpng +# Copyright (C) 1998 Tim Wegner +# For conditions of distribution and use, see copyright notice in png.h +# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib +# To use, do "nmake /f scripts\makefile.vcawin32" + +# -------- Microsoft Visual C++ 5.0 and later, uses assembler code -------- +# If you don't want to use assembler (MMX) code, use makefile.vcwin32 instead. + +# Compiler, linker, librarian, and other tools +CC = cl +LD = link +AR = lib +CFLAGS = -DPNG_USE_PNGVCRD -nologo -MD -O2 -W3 -I..\zlib +LDFLAGS = -nologo +ARFLAGS = -nologo +RM = del + +# File extensions +O=.obj + +#uncomment next to put error messages in a file +#ERRFILE= >> pngerrs.log + +# Variables +OBJS1 = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) +OBJS2 = pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) +OBJS3 = pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) +OBJS4 = pngvcrd$(O) +OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) + +# Targets +all: libpng.lib + +png$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngset$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngget$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngread$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngpread$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngrtran$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngrutil$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngerror$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngmem$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngrio$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngwio$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngtest$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngtrans$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngwrite$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngwtran$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngwutil$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngvcrd$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +libpng.lib: $(OBJS) + -$(RM) $@ + $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE) + +pngtest.exe: pngtest$(O) libpng.lib + $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE) + +test: pngtest.exe + pngtest + +clean: + -$(RM) *$(O) + -$(RM) libpng.lib + -$(RM) pngtest.exe + -$(RM) pngout.png + +# End of makefile for libpng + diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.vcwin32 b/src/dep/src/irrlicht/libpng/scripts/makefile.vcwin32 index 6148c83..d23d812 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.vcwin32 +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.vcwin32 @@ -1,99 +1,99 @@ -# makefile for libpng -# Copyright (C) 1998 Tim Wegner -# For conditions of distribution and use, see copyright notice in png.h -# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib -# To use, do "nmake /f scripts\makefile.vcwin32" - -# -------- Microsoft Visual C++ 2.0 and later, no assembler code -------- -# If you want to use assembler (MMX) code, use makefile.vcawin32 instead. - -# Compiler, linker, librarian, and other tools -CC = cl -LD = link -AR = lib -CFLAGS = -nologo -MD -O2 -W3 -I..\zlib -LDFLAGS = -nologo -ARFLAGS = -nologo -RM = del - -# File extensions -O=.obj - -#uncomment next to put error messages in a file -#ERRFILE= >> pngerrs.log - -# Variables -OBJS1 = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) -OBJS2 = pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) -OBJS3 = pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) -OBJS = $(OBJS1) $(OBJS2) $(OBJS3) - -# Targets -all: libpng.lib - -png$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS) - -$(RM) $@ - $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE) - -pngtest.exe: pngtest$(O) libpng.lib - $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE) - -test: pngtest.exe - pngtest - -clean: - -$(RM) *$(O) - -$(RM) libpng.lib - -$(RM) pngtest.exe - -$(RM) pngout.png - -# End of makefile for libpng - +# makefile for libpng +# Copyright (C) 1998 Tim Wegner +# For conditions of distribution and use, see copyright notice in png.h +# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib +# To use, do "nmake /f scripts\makefile.vcwin32" + +# -------- Microsoft Visual C++ 2.0 and later, no assembler code -------- +# If you want to use assembler (MMX) code, use makefile.vcawin32 instead. + +# Compiler, linker, librarian, and other tools +CC = cl +LD = link +AR = lib +CFLAGS = -nologo -MD -O2 -W3 -I..\zlib +LDFLAGS = -nologo +ARFLAGS = -nologo +RM = del + +# File extensions +O=.obj + +#uncomment next to put error messages in a file +#ERRFILE= >> pngerrs.log + +# Variables +OBJS1 = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) +OBJS2 = pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) +OBJS3 = pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) +OBJS = $(OBJS1) $(OBJS2) $(OBJS3) + +# Targets +all: libpng.lib + +png$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngset$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngget$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngread$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngpread$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngrtran$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngrutil$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngerror$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngmem$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngrio$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngwio$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngtest$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngtrans$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngwrite$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngwtran$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +pngwutil$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + +libpng.lib: $(OBJS) + -$(RM) $@ + $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE) + +pngtest.exe: pngtest$(O) libpng.lib + $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE) + +test: pngtest.exe + pngtest + +clean: + -$(RM) *$(O) + -$(RM) libpng.lib + -$(RM) pngtest.exe + -$(RM) pngout.png + +# End of makefile for libpng + diff --git a/src/dep/src/irrlicht/libpng/scripts/makefile.watcom b/src/dep/src/irrlicht/libpng/scripts/makefile.watcom index 32cd333..5e860fc 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makefile.watcom +++ b/src/dep/src/irrlicht/libpng/scripts/makefile.watcom @@ -1,109 +1,109 @@ -# Makefile for libpng -# Watcom C/C++ 10.0 and later, 32-bit protected mode, flat memory model - -# Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is -# copyright 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# To use, do "wmake /f scripts\makefile.watcom" - - -# ---------------------- Watcom C/C++ 10.0 and later ----------------------- - -# Where the zlib library and include files are located -ZLIBLIB=..\zlib -ZLIBINC=..\zlib - -# Target OS -OS=DOS -#OS=NT - -# Target CPU -CPU=6 # Pentium Pro -#CPU=5 # Pentium - -# Calling convention -CALLING=r # registers -#CALLING=s # stack - -# Uncomment next to put error messages in a file -#ERRFILE=>>pngerrs - -# -------------------------------------------------------------------------- - - -CC=wcc386 -CFLAGS=-$(CPU)$(CALLING) -fp$(CPU) -fpi87 -oneatx -mf -bt=$(OS) -i=$(ZLIBINC) -zq -LD=wcl386 -LDFLAGS=-zq - -O=.obj - -OBJS1=png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) -OBJS2=pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) -OBJS3=pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) - - -all: test - -png$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) - wlib -b -c -n -q libpng.lib $(OBJS1) - wlib -b -c -q libpng.lib $(OBJS2) - wlib -b -c -q libpng.lib $(OBJS3) - -pngtest.exe: pngtest.obj libpng.lib - $(LD) $(LDFLAGS) pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib - -test: pngtest.exe .symbolic - pngtest.exe - - -# End of makefile for libpng +# Makefile for libpng +# Watcom C/C++ 10.0 and later, 32-bit protected mode, flat memory model + +# Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is +# copyright 1995 Guy Eric Schalnat, Group 42, Inc. +# For conditions of distribution and use, see copyright notice in png.h + +# To use, do "wmake /f scripts\makefile.watcom" + + +# ---------------------- Watcom C/C++ 10.0 and later ----------------------- + +# Where the zlib library and include files are located +ZLIBLIB=..\zlib +ZLIBINC=..\zlib + +# Target OS +OS=DOS +#OS=NT + +# Target CPU +CPU=6 # Pentium Pro +#CPU=5 # Pentium + +# Calling convention +CALLING=r # registers +#CALLING=s # stack + +# Uncomment next to put error messages in a file +#ERRFILE=>>pngerrs + +# -------------------------------------------------------------------------- + + +CC=wcc386 +CFLAGS=-$(CPU)$(CALLING) -fp$(CPU) -fpi87 -oneatx -mf -bt=$(OS) -i=$(ZLIBINC) -zq +LD=wcl386 +LDFLAGS=-zq + +O=.obj + +OBJS1=png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) +OBJS2=pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) +OBJS3=pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) + + +all: test + +png$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngset$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngget$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngread$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngpread$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngrtran$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngrutil$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngerror$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngmem$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngrio$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngwio$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngtest$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngtrans$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngwrite$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngwtran$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngwutil$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) + wlib -b -c -n -q libpng.lib $(OBJS1) + wlib -b -c -q libpng.lib $(OBJS2) + wlib -b -c -q libpng.lib $(OBJS3) + +pngtest.exe: pngtest.obj libpng.lib + $(LD) $(LDFLAGS) pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib + +test: pngtest.exe .symbolic + pngtest.exe + + +# End of makefile for libpng diff --git a/src/dep/src/irrlicht/libpng/scripts/makevms.com b/src/dep/src/irrlicht/libpng/scripts/makevms.com index 8061ba8..b9e3895 100644 --- a/src/dep/src/irrlicht/libpng/scripts/makevms.com +++ b/src/dep/src/irrlicht/libpng/scripts/makevms.com @@ -1,144 +1,144 @@ -$! make libpng under VMS -$! -$! -$! Check for MMK/MMS -$! -$! This procedure accepts one parameter (contrib), which causes it to build -$! the programs from the contrib directory instead of libpng. -$! -$ p1 = f$edit(p1,"UPCASE") -$ if p1 .eqs. "CONTRIB" -$ then -$ set def [.contrib.gregbook] -$ @makevms -$ set def [-.pngminus] -$ @makevms -$ set def [--] -$ exit -$ endif -$ Make = "" -$ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS" -$ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK" -$! -$! Look for the compiler used -$! -$ zlibsrc = "[-.zlib]" -$ ccopt="/include=''zlibsrc'" -$ if f$getsyi("HW_MODEL").ge.1024 -$ then -$ ccopt = "/prefix=all"+ccopt -$ comp = "__decc__=1" -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ else -$ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" -$ then -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ if f$search("SYS$SYSTEM:VAXC.EXE").eqs."" -$ then -$ comp = "__gcc__=1" -$ CC :== GCC -$ else -$ comp = "__vaxc__=1" -$ endif -$ else -$ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: -$ ccopt = "/decc/prefix=all"+ccopt -$ comp = "__decc__=1" -$ endif -$ endif -$! -$! Build the thing plain or with mms/mmk -$! -$ write sys$output "Compiling Libpng sources ..." -$ if make.eqs."" -$ then -$ dele pngtest.obj;* -$ CALL MAKE png.OBJ "cc ''CCOPT' png" - - png.c png.h pngconf.h -$ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" - - pngpread.c png.h pngconf.h -$ CALL MAKE pngset.OBJ "cc ''CCOPT' pngset" - - pngset.c png.h pngconf.h -$ CALL MAKE pngget.OBJ "cc ''CCOPT' pngget" - - pngget.c png.h pngconf.h -$ CALL MAKE pngread.OBJ "cc ''CCOPT' pngread" - - pngread.c png.h pngconf.h -$ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" - - pngpread.c png.h pngconf.h -$ CALL MAKE pngrtran.OBJ "cc ''CCOPT' pngrtran" - - pngrtran.c png.h pngconf.h -$ CALL MAKE pngrutil.OBJ "cc ''CCOPT' pngrutil" - - pngrutil.c png.h pngconf.h -$ CALL MAKE pngerror.OBJ "cc ''CCOPT' pngerror" - - pngerror.c png.h pngconf.h -$ CALL MAKE pngmem.OBJ "cc ''CCOPT' pngmem" - - pngmem.c png.h pngconf.h -$ CALL MAKE pngrio.OBJ "cc ''CCOPT' pngrio" - - pngrio.c png.h pngconf.h -$ CALL MAKE pngwio.OBJ "cc ''CCOPT' pngwio" - - pngwio.c png.h pngconf.h -$ CALL MAKE pngtrans.OBJ "cc ''CCOPT' pngtrans" - - pngtrans.c png.h pngconf.h -$ CALL MAKE pngwrite.OBJ "cc ''CCOPT' pngwrite" - - pngwrite.c png.h pngconf.h -$ CALL MAKE pngwtran.OBJ "cc ''CCOPT' pngwtran" - - pngwtran.c png.h pngconf.h -$ CALL MAKE pngwutil.OBJ "cc ''CCOPT' pngwutil" - - pngwutil.c png.h pngconf.h -$ write sys$output "Building Libpng ..." -$ CALL MAKE libpng.OLB "lib/crea libpng.olb *.obj" *.OBJ -$ write sys$output "Building pngtest..." -$ CALL MAKE pngtest.OBJ "cc ''CCOPT' pngtest" - - pngtest.c png.h pngconf.h -$ call make pngtest.exe - - "LINK pngtest,libpng.olb/lib,''zlibsrc'libz.olb/lib" - - pngtest.obj libpng.olb -$ write sys$output "Testing Libpng..." -$ run pngtest -$ else -$ if f$search("DESCRIP.MMS") .eqs. "" then copy/nolog [.SCRIPTS]DESCRIP.MMS [] -$ 'make'/macro=('comp',zlibsrc='zlibsrc') -$ endif -$ write sys$output "Libpng build completed" -$ exit -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 - P8 What it depends on -$ -$ If F$Search(P1) .Eqs. "" Then Goto Makeit -$ Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(0) -$ write sys$output P2 -$ 'P2 -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE +$! make libpng under VMS +$! +$! +$! Check for MMK/MMS +$! +$! This procedure accepts one parameter (contrib), which causes it to build +$! the programs from the contrib directory instead of libpng. +$! +$ p1 = f$edit(p1,"UPCASE") +$ if p1 .eqs. "CONTRIB" +$ then +$ set def [.contrib.gregbook] +$ @makevms +$ set def [-.pngminus] +$ @makevms +$ set def [--] +$ exit +$ endif +$ Make = "" +$ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS" +$ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK" +$! +$! Look for the compiler used +$! +$ zlibsrc = "[-.zlib]" +$ ccopt="/include=''zlibsrc'" +$ if f$getsyi("HW_MODEL").ge.1024 +$ then +$ ccopt = "/prefix=all"+ccopt +$ comp = "__decc__=1" +$ if f$trnlnm("SYS").eqs."" then define sys sys$library: +$ else +$ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" +$ then +$ if f$trnlnm("SYS").eqs."" then define sys sys$library: +$ if f$search("SYS$SYSTEM:VAXC.EXE").eqs."" +$ then +$ comp = "__gcc__=1" +$ CC :== GCC +$ else +$ comp = "__vaxc__=1" +$ endif +$ else +$ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: +$ ccopt = "/decc/prefix=all"+ccopt +$ comp = "__decc__=1" +$ endif +$ endif +$! +$! Build the thing plain or with mms/mmk +$! +$ write sys$output "Compiling Libpng sources ..." +$ if make.eqs."" +$ then +$ dele pngtest.obj;* +$ CALL MAKE png.OBJ "cc ''CCOPT' png" - + png.c png.h pngconf.h +$ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" - + pngpread.c png.h pngconf.h +$ CALL MAKE pngset.OBJ "cc ''CCOPT' pngset" - + pngset.c png.h pngconf.h +$ CALL MAKE pngget.OBJ "cc ''CCOPT' pngget" - + pngget.c png.h pngconf.h +$ CALL MAKE pngread.OBJ "cc ''CCOPT' pngread" - + pngread.c png.h pngconf.h +$ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" - + pngpread.c png.h pngconf.h +$ CALL MAKE pngrtran.OBJ "cc ''CCOPT' pngrtran" - + pngrtran.c png.h pngconf.h +$ CALL MAKE pngrutil.OBJ "cc ''CCOPT' pngrutil" - + pngrutil.c png.h pngconf.h +$ CALL MAKE pngerror.OBJ "cc ''CCOPT' pngerror" - + pngerror.c png.h pngconf.h +$ CALL MAKE pngmem.OBJ "cc ''CCOPT' pngmem" - + pngmem.c png.h pngconf.h +$ CALL MAKE pngrio.OBJ "cc ''CCOPT' pngrio" - + pngrio.c png.h pngconf.h +$ CALL MAKE pngwio.OBJ "cc ''CCOPT' pngwio" - + pngwio.c png.h pngconf.h +$ CALL MAKE pngtrans.OBJ "cc ''CCOPT' pngtrans" - + pngtrans.c png.h pngconf.h +$ CALL MAKE pngwrite.OBJ "cc ''CCOPT' pngwrite" - + pngwrite.c png.h pngconf.h +$ CALL MAKE pngwtran.OBJ "cc ''CCOPT' pngwtran" - + pngwtran.c png.h pngconf.h +$ CALL MAKE pngwutil.OBJ "cc ''CCOPT' pngwutil" - + pngwutil.c png.h pngconf.h +$ write sys$output "Building Libpng ..." +$ CALL MAKE libpng.OLB "lib/crea libpng.olb *.obj" *.OBJ +$ write sys$output "Building pngtest..." +$ CALL MAKE pngtest.OBJ "cc ''CCOPT' pngtest" - + pngtest.c png.h pngconf.h +$ call make pngtest.exe - + "LINK pngtest,libpng.olb/lib,''zlibsrc'libz.olb/lib" - + pngtest.obj libpng.olb +$ write sys$output "Testing Libpng..." +$ run pngtest +$ else +$ if f$search("DESCRIP.MMS") .eqs. "" then copy/nolog [.SCRIPTS]DESCRIP.MMS [] +$ 'make'/macro=('comp',zlibsrc='zlibsrc') +$ endif +$ write sys$output "Libpng build completed" +$ exit +$! +$! +$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES +$ V = 'F$Verify(0) +$! P1 = What we are trying to make +$! P2 = Command to make it +$! P3 - P8 What it depends on +$ +$ If F$Search(P1) .Eqs. "" Then Goto Makeit +$ Time = F$CvTime(F$File(P1,"RDT")) +$arg=3 +$Loop: +$ Argument = P'arg +$ If Argument .Eqs. "" Then Goto Exit +$ El=0 +$Loop2: +$ File = F$Element(El," ",Argument) +$ If File .Eqs. " " Then Goto Endl +$ AFile = "" +$Loop3: +$ OFile = AFile +$ AFile = F$Search(File) +$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl +$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit +$ Goto Loop3 +$NextEL: +$ El = El + 1 +$ Goto Loop2 +$EndL: +$ arg=arg+1 +$ If arg .Le. 8 Then Goto Loop +$ Goto Exit +$ +$Makeit: +$ VV=F$VERIFY(0) +$ write sys$output P2 +$ 'P2 +$ VV='F$Verify(VV) +$Exit: +$ If V Then Set Verify +$ENDSUBROUTINE diff --git a/src/dep/src/irrlicht/libpng/scripts/pngos2.def b/src/dep/src/irrlicht/libpng/scripts/pngos2.def index 8c63aeb..20f5efd 100644 --- a/src/dep/src/irrlicht/libpng/scripts/pngos2.def +++ b/src/dep/src/irrlicht/libpng/scripts/pngos2.def @@ -1,258 +1,258 @@ -;---------------------------------------- -; PNG.LIB module definition file for OS/2 -;---------------------------------------- - -; Version 1.2.16 - -LIBRARY PNG -DESCRIPTION "PNG image compression library for OS/2" -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE MULTIPLE - -EXPORTS - - - png_build_grayscale_palette - png_check_sig - png_chunk_error - png_chunk_warning - png_convert_from_struct_tm - png_convert_from_time_t - png_create_info_struct - png_create_read_struct - png_create_write_struct - png_data_freer - png_destroy_info_struct - png_destroy_read_struct - png_destroy_write_struct - png_error - png_free - png_free_data - png_get_IHDR - png_get_PLTE - png_get_bKGD - png_get_bit_depth - png_get_cHRM - png_get_cHRM_fixed - png_get_channels - png_get_color_type - png_get_compression_buffer_size - png_get_compression_type - png_get_copyright - png_get_error_ptr - png_get_filter_type - png_get_gAMA - png_get_gAMA_fixed - png_get_hIST - png_get_header_ver - png_get_header_version - png_get_iCCP - png_get_image_height - png_get_image_width - png_get_interlace_type - png_get_io_ptr - png_get_libpng_ver - png_get_oFFs - png_get_pCAL - png_get_pHYs - png_get_pixel_aspect_ratio - png_get_pixels_per_meter - png_get_progressive_ptr - png_get_rgb_to_gray_status - png_get_rowbytes - png_get_rows - png_get_sBIT - png_get_sCAL - png_get_sPLT - png_get_sRGB - png_get_signature - png_get_tIME - png_get_tRNS - png_get_text - png_get_unknown_chunks - png_get_user_chunk_ptr - png_get_user_transform_ptr - png_get_valid - png_get_x_offset_microns - png_get_x_offset_pixels - png_get_x_pixels_per_meter - png_get_y_offset_microns - png_get_y_offset_pixels - png_get_y_pixels_per_meter - png_malloc - png_memcpy_check - png_memset_check - png_permit_empty_plte - png_process_data - png_progressive_combine_row - png_read_end - png_read_image - png_read_info -; png_read_init ; deprecated - png_read_png - png_read_row - png_read_rows - png_read_update_info - png_reset_zstream - png_set_IHDR - png_set_PLTE - png_set_bKGD - png_set_background - png_set_bgr - png_set_cHRM - png_set_cHRM_fixed - png_set_compression_buffer_size - png_set_compression_level - png_set_compression_mem_level - png_set_compression_method - png_set_compression_strategy - png_set_compression_window_bits - png_set_crc_action - png_set_dither - png_set_error_fn - png_set_expand - png_set_filler - png_set_filter - png_set_filter_heuristics - png_set_flush - png_set_gAMA - png_set_gAMA_fixed - png_set_gamma -; png_set_gray_1_2_4_to_8 ; deprecated as of libpng-1.2.9 - png_set_gray_to_rgb - png_set_hIST - png_set_iCCP - png_set_interlace_handling - png_set_invert_alpha - png_set_invert_mono - png_set_keep_unknown_chunks - png_set_oFFs - png_set_pCAL - png_set_pHYs - png_set_packing - png_set_packswap - png_set_palette_to_rgb - png_set_progressive_read_fn - png_set_read_fn - png_set_read_status_fn - png_set_read_user_chunk_fn - png_set_read_user_transform_fn - png_set_rgb_to_gray - png_set_rgb_to_gray_fixed - png_set_rows - png_set_sBIT - png_set_sCAL - png_set_sPLT - png_set_sRGB - png_set_sRGB_gAMA_and_cHRM - png_set_shift - png_set_sig_bytes - png_set_strip_16 - png_set_strip_alpha - png_set_swap - png_set_swap_alpha - png_set_tIME - png_set_tRNS - png_set_tRNS_to_alpha - png_set_text - png_set_unknown_chunk_location - png_set_unknown_chunks - png_set_user_transform_info - png_set_write_fn - png_set_write_status_fn - png_set_write_user_transform_fn - png_sig_cmp - png_start_read_image - png_warning - png_write_chunk - png_write_chunk_data - png_write_chunk_end - png_write_chunk_start - png_write_end - png_write_flush - png_write_image - png_write_info - png_write_info_before_PLTE -; png_write_init ; deprecated - png_write_png - png_write_row - png_write_rows - png_read_init_2 - png_write_init_2 - png_access_version_number - png_init_io - png_convert_to_rfc1123 - png_set_invalid - -; Added at version 1.2.0: - png_mmx_support - png_permit_empty_plte - png_permit_mng_features - png_get_mmx_flagmask - png_get_asm_flagmask - png_get_asm_flags - png_get_mmx_bitdepth_threshold - png_get_mmx_rowbytes_threshold - png_set_asm_flags - png_init_mmx_flags - -; Added at version 1.2.2: - png_handle_as_unknown - -; Added at version 1.2.2 and deleted from 1.2.3: -; png_zalloc -; png_zfree - -; Added at version 1.2.4 - png_malloc_warn - -; Added at version 1.2.6 - png_set_user_limits - png_get_user_height_max - png_get_user_width_max -; Added at version 1.2.7 - png_set_add_alpha - -; Added at version 1.2.9 - png_get_uint_32 - png_save_uint_32 - png_get_uint_16 - png_save_uint_16 - png_get_int_32 - png_save_int_32 - png_get_uint_31 - png_set_expand_gray_1_2_4_to_8 - -; These are not present when libpng is compiled with PNG_NO_GLOBAL_ARRAYS - png_libpng_ver - png_pass_start - png_pass_inc - png_pass_ystart - png_pass_yinc - png_pass_mask - png_pass_dsp_mask -; png_pass_width -; png_pass_height - -; These are not present when libpng is compiled with PNG_NO_GLOBAL_ARRAYS - png_IHDR - png_IDAT - png_IEND - png_PLTE - png_bKGD - png_cHRM - png_gAMA - png_hIST - png_iCCP - png_iTXt - png_oFFs - png_pCAL - png_pHYs - png_sBIT - png_sCAL - png_sPLT - png_sRGB - png_tEXt - png_tIME - png_tRNS - png_zTXt +;---------------------------------------- +; PNG.LIB module definition file for OS/2 +;---------------------------------------- + +; Version 1.2.16 + +LIBRARY PNG +DESCRIPTION "PNG image compression library for OS/2" +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE MULTIPLE + +EXPORTS + + + png_build_grayscale_palette + png_check_sig + png_chunk_error + png_chunk_warning + png_convert_from_struct_tm + png_convert_from_time_t + png_create_info_struct + png_create_read_struct + png_create_write_struct + png_data_freer + png_destroy_info_struct + png_destroy_read_struct + png_destroy_write_struct + png_error + png_free + png_free_data + png_get_IHDR + png_get_PLTE + png_get_bKGD + png_get_bit_depth + png_get_cHRM + png_get_cHRM_fixed + png_get_channels + png_get_color_type + png_get_compression_buffer_size + png_get_compression_type + png_get_copyright + png_get_error_ptr + png_get_filter_type + png_get_gAMA + png_get_gAMA_fixed + png_get_hIST + png_get_header_ver + png_get_header_version + png_get_iCCP + png_get_image_height + png_get_image_width + png_get_interlace_type + png_get_io_ptr + png_get_libpng_ver + png_get_oFFs + png_get_pCAL + png_get_pHYs + png_get_pixel_aspect_ratio + png_get_pixels_per_meter + png_get_progressive_ptr + png_get_rgb_to_gray_status + png_get_rowbytes + png_get_rows + png_get_sBIT + png_get_sCAL + png_get_sPLT + png_get_sRGB + png_get_signature + png_get_tIME + png_get_tRNS + png_get_text + png_get_unknown_chunks + png_get_user_chunk_ptr + png_get_user_transform_ptr + png_get_valid + png_get_x_offset_microns + png_get_x_offset_pixels + png_get_x_pixels_per_meter + png_get_y_offset_microns + png_get_y_offset_pixels + png_get_y_pixels_per_meter + png_malloc + png_memcpy_check + png_memset_check + png_permit_empty_plte + png_process_data + png_progressive_combine_row + png_read_end + png_read_image + png_read_info +; png_read_init ; deprecated + png_read_png + png_read_row + png_read_rows + png_read_update_info + png_reset_zstream + png_set_IHDR + png_set_PLTE + png_set_bKGD + png_set_background + png_set_bgr + png_set_cHRM + png_set_cHRM_fixed + png_set_compression_buffer_size + png_set_compression_level + png_set_compression_mem_level + png_set_compression_method + png_set_compression_strategy + png_set_compression_window_bits + png_set_crc_action + png_set_dither + png_set_error_fn + png_set_expand + png_set_filler + png_set_filter + png_set_filter_heuristics + png_set_flush + png_set_gAMA + png_set_gAMA_fixed + png_set_gamma +; png_set_gray_1_2_4_to_8 ; deprecated as of libpng-1.2.9 + png_set_gray_to_rgb + png_set_hIST + png_set_iCCP + png_set_interlace_handling + png_set_invert_alpha + png_set_invert_mono + png_set_keep_unknown_chunks + png_set_oFFs + png_set_pCAL + png_set_pHYs + png_set_packing + png_set_packswap + png_set_palette_to_rgb + png_set_progressive_read_fn + png_set_read_fn + png_set_read_status_fn + png_set_read_user_chunk_fn + png_set_read_user_transform_fn + png_set_rgb_to_gray + png_set_rgb_to_gray_fixed + png_set_rows + png_set_sBIT + png_set_sCAL + png_set_sPLT + png_set_sRGB + png_set_sRGB_gAMA_and_cHRM + png_set_shift + png_set_sig_bytes + png_set_strip_16 + png_set_strip_alpha + png_set_swap + png_set_swap_alpha + png_set_tIME + png_set_tRNS + png_set_tRNS_to_alpha + png_set_text + png_set_unknown_chunk_location + png_set_unknown_chunks + png_set_user_transform_info + png_set_write_fn + png_set_write_status_fn + png_set_write_user_transform_fn + png_sig_cmp + png_start_read_image + png_warning + png_write_chunk + png_write_chunk_data + png_write_chunk_end + png_write_chunk_start + png_write_end + png_write_flush + png_write_image + png_write_info + png_write_info_before_PLTE +; png_write_init ; deprecated + png_write_png + png_write_row + png_write_rows + png_read_init_2 + png_write_init_2 + png_access_version_number + png_init_io + png_convert_to_rfc1123 + png_set_invalid + +; Added at version 1.2.0: + png_mmx_support + png_permit_empty_plte + png_permit_mng_features + png_get_mmx_flagmask + png_get_asm_flagmask + png_get_asm_flags + png_get_mmx_bitdepth_threshold + png_get_mmx_rowbytes_threshold + png_set_asm_flags + png_init_mmx_flags + +; Added at version 1.2.2: + png_handle_as_unknown + +; Added at version 1.2.2 and deleted from 1.2.3: +; png_zalloc +; png_zfree + +; Added at version 1.2.4 + png_malloc_warn + +; Added at version 1.2.6 + png_set_user_limits + png_get_user_height_max + png_get_user_width_max +; Added at version 1.2.7 + png_set_add_alpha + +; Added at version 1.2.9 + png_get_uint_32 + png_save_uint_32 + png_get_uint_16 + png_save_uint_16 + png_get_int_32 + png_save_int_32 + png_get_uint_31 + png_set_expand_gray_1_2_4_to_8 + +; These are not present when libpng is compiled with PNG_NO_GLOBAL_ARRAYS + png_libpng_ver + png_pass_start + png_pass_inc + png_pass_ystart + png_pass_yinc + png_pass_mask + png_pass_dsp_mask +; png_pass_width +; png_pass_height + +; These are not present when libpng is compiled with PNG_NO_GLOBAL_ARRAYS + png_IHDR + png_IDAT + png_IEND + png_PLTE + png_bKGD + png_cHRM + png_gAMA + png_hIST + png_iCCP + png_iTXt + png_oFFs + png_pCAL + png_pHYs + png_sBIT + png_sCAL + png_sPLT + png_sRGB + png_tEXt + png_tIME + png_tRNS + png_zTXt diff --git a/src/dep/src/irrlicht/libpng/scripts/pngw32.def b/src/dep/src/irrlicht/libpng/scripts/pngw32.def index 2209ba2..eb8ad7a 100644 --- a/src/dep/src/irrlicht/libpng/scripts/pngw32.def +++ b/src/dep/src/irrlicht/libpng/scripts/pngw32.def @@ -1,236 +1,236 @@ -;------------------------------------------ -; LIBPNG module definition file for Windows -;------------------------------------------ - -LIBRARY - -EXPORTS -;Version 1.2.16 - png_build_grayscale_palette @1 - png_check_sig @2 - png_chunk_error @3 - png_chunk_warning @4 - png_convert_from_struct_tm @5 - png_convert_from_time_t @6 - png_create_info_struct @7 - png_create_read_struct @8 - png_create_write_struct @9 - png_data_freer @10 - png_destroy_info_struct @11 - png_destroy_read_struct @12 - png_destroy_write_struct @13 - png_error @14 - png_free @15 - png_free_data @16 - png_get_IHDR @17 - png_get_PLTE @18 - png_get_bKGD @19 - png_get_bit_depth @20 - png_get_cHRM @21 - png_get_cHRM_fixed @22 - png_get_channels @23 - png_get_color_type @24 - png_get_compression_buffer_size @25 - png_get_compression_type @26 - png_get_copyright @27 - png_get_error_ptr @28 - png_get_filter_type @29 - png_get_gAMA @30 - png_get_gAMA_fixed @31 - png_get_hIST @32 - png_get_header_ver @33 - png_get_header_version @34 - png_get_iCCP @35 - png_get_image_height @36 - png_get_image_width @37 - png_get_interlace_type @38 - png_get_io_ptr @39 - png_get_libpng_ver @40 - png_get_oFFs @41 - png_get_pCAL @42 - png_get_pHYs @43 - png_get_pixel_aspect_ratio @44 - png_get_pixels_per_meter @45 - png_get_progressive_ptr @46 - png_get_rgb_to_gray_status @47 - png_get_rowbytes @48 - png_get_rows @49 - png_get_sBIT @50 - png_get_sCAL @51 - png_get_sPLT @52 - png_get_sRGB @53 - png_get_signature @54 - png_get_tIME @55 - png_get_tRNS @56 - png_get_text @57 - png_get_unknown_chunks @58 - png_get_user_chunk_ptr @59 - png_get_user_transform_ptr @60 - png_get_valid @61 - png_get_x_offset_microns @62 - png_get_x_offset_pixels @63 - png_get_x_pixels_per_meter @64 - png_get_y_offset_microns @65 - png_get_y_offset_pixels @66 - png_get_y_pixels_per_meter @67 - png_malloc @68 - png_memcpy_check @69 - png_memset_check @70 -; png_permit_empty_plte is deprecated - png_permit_empty_plte @71 - png_process_data @72 - png_progressive_combine_row @73 - png_read_end @74 - png_read_image @75 - png_read_info @76 -; png_read_init is deprecated - png_read_init @77 - png_read_png @78 - png_read_row @79 - png_read_rows @80 - png_read_update_info @81 - png_reset_zstream @82 - png_set_IHDR @83 - png_set_PLTE @84 - png_set_bKGD @85 - png_set_background @86 - png_set_bgr @87 - png_set_cHRM @88 - png_set_cHRM_fixed @89 - png_set_compression_buffer_size @90 - png_set_compression_level @91 - png_set_compression_mem_level @92 - png_set_compression_method @93 - png_set_compression_strategy @94 - png_set_compression_window_bits @95 - png_set_crc_action @96 - png_set_dither @97 - png_set_error_fn @98 - png_set_expand @99 - png_set_filler @100 - png_set_filter @101 - png_set_filter_heuristics @102 - png_set_flush @103 - png_set_gAMA @104 - png_set_gAMA_fixed @105 - png_set_gamma @106 -; png_set_gray_1_2_4_to_8 is deprecated - png_set_gray_1_2_4_to_8 @107 - png_set_gray_to_rgb @108 - png_set_hIST @109 - png_set_iCCP @110 - png_set_interlace_handling @111 - png_set_invert_alpha @112 - png_set_invert_mono @113 - png_set_keep_unknown_chunks @114 - png_set_oFFs @115 - png_set_pCAL @116 - png_set_pHYs @117 - png_set_packing @118 - png_set_packswap @119 - png_set_palette_to_rgb @120 - png_set_progressive_read_fn @121 - png_set_read_fn @122 - png_set_read_status_fn @123 - png_set_read_user_chunk_fn @124 - png_set_read_user_transform_fn @125 - png_set_rgb_to_gray @126 - png_set_rgb_to_gray_fixed @127 - png_set_rows @128 - png_set_sBIT @129 - png_set_sCAL @130 - png_set_sPLT @131 - png_set_sRGB @132 - png_set_sRGB_gAMA_and_cHRM @133 - png_set_shift @134 - png_set_sig_bytes @135 - png_set_strip_16 @136 - png_set_strip_alpha @137 - png_set_swap @138 - png_set_swap_alpha @139 - png_set_tIME @140 - png_set_tRNS @141 - png_set_tRNS_to_alpha @142 - png_set_text @143 - png_set_unknown_chunk_location @144 - png_set_unknown_chunks @145 - png_set_user_transform_info @146 - png_set_write_fn @147 - png_set_write_status_fn @148 - png_set_write_user_transform_fn @149 - png_sig_cmp @150 - png_start_read_image @151 - png_warning @152 - png_write_chunk @153 - png_write_chunk_data @154 - png_write_chunk_end @155 - png_write_chunk_start @156 - png_write_end @157 - png_write_flush @158 - png_write_image @159 - png_write_info @160 - png_write_info_before_PLTE @161 -; png_write_init is deprecated - png_write_init @162 - png_write_png @163 - png_write_row @164 - png_write_rows @165 -; png_read_init_2 and png_write_init_2 are deprecated. - png_read_init_2 @166 - png_write_init_2 @167 - png_access_version_number @168 -; png_sig_bytes @169 - png_libpng_ver @170 - png_init_io @171 - png_convert_to_rfc1123 @172 - png_set_invalid @173 -; Added at version 1.0.12 -; For compatibility with 1.0.7-1.0.11 -; png_info_init @174 - png_read_init_3 @175 - png_write_init_3 @176 - png_info_init_3 @177 - png_destroy_struct @178 -; Added at version 1.2.0 -; For use with PNG_USER_MEM_SUPPORTED - png_destroy_struct_2 @179 - png_create_read_struct_2 @180 - png_create_write_struct_2 @181 - png_malloc_default @182 - png_free_default @183 -; MNG features - png_permit_mng_features @184 -; MMX support - png_mmx_support @185 -; png_get_mmx_flagmask @186 - png_get_asm_flagmask @187 - png_get_asm_flags @188 -; png_get_mmx_bitdepth_threshold @189 -; png_get_mmx_rowbytes_threshold @190 - png_set_asm_flags @191 -; png_init_mmx_flags @192 -; Strip error numbers - png_set_strip_error_numbers @193 -; Added at version 1.2.2 - png_handle_as_unknown @194 -; Added at version 1.2.2 and deleted from 1.2.3 -; png_zalloc @195 -; png_zfree @196 -; Added at version 1.2.4 - png_malloc_warn @195 -; Added at version 1.2.6 - png_malloc_warn @195 - png_get_user_height_max @196 - png_get_user_width_max @197 - png_set_user_limits @198 -; Added at version 1.2.7 - png_set_add_alpha @199 -; Added at version 1.2.9 - png_get_uint_32 @200 - png_save_uint_32 @201 - png_get_uint_16 @202 - png_save_uint_16 @203 - png_get_int_32 @204 - png_save_int_32 @205 - png_get_uint_31 @206 - png_set_expand_gray_1_2_4_to_8 @207 +;------------------------------------------ +; LIBPNG module definition file for Windows +;------------------------------------------ + +LIBRARY + +EXPORTS +;Version 1.2.16 + png_build_grayscale_palette @1 + png_check_sig @2 + png_chunk_error @3 + png_chunk_warning @4 + png_convert_from_struct_tm @5 + png_convert_from_time_t @6 + png_create_info_struct @7 + png_create_read_struct @8 + png_create_write_struct @9 + png_data_freer @10 + png_destroy_info_struct @11 + png_destroy_read_struct @12 + png_destroy_write_struct @13 + png_error @14 + png_free @15 + png_free_data @16 + png_get_IHDR @17 + png_get_PLTE @18 + png_get_bKGD @19 + png_get_bit_depth @20 + png_get_cHRM @21 + png_get_cHRM_fixed @22 + png_get_channels @23 + png_get_color_type @24 + png_get_compression_buffer_size @25 + png_get_compression_type @26 + png_get_copyright @27 + png_get_error_ptr @28 + png_get_filter_type @29 + png_get_gAMA @30 + png_get_gAMA_fixed @31 + png_get_hIST @32 + png_get_header_ver @33 + png_get_header_version @34 + png_get_iCCP @35 + png_get_image_height @36 + png_get_image_width @37 + png_get_interlace_type @38 + png_get_io_ptr @39 + png_get_libpng_ver @40 + png_get_oFFs @41 + png_get_pCAL @42 + png_get_pHYs @43 + png_get_pixel_aspect_ratio @44 + png_get_pixels_per_meter @45 + png_get_progressive_ptr @46 + png_get_rgb_to_gray_status @47 + png_get_rowbytes @48 + png_get_rows @49 + png_get_sBIT @50 + png_get_sCAL @51 + png_get_sPLT @52 + png_get_sRGB @53 + png_get_signature @54 + png_get_tIME @55 + png_get_tRNS @56 + png_get_text @57 + png_get_unknown_chunks @58 + png_get_user_chunk_ptr @59 + png_get_user_transform_ptr @60 + png_get_valid @61 + png_get_x_offset_microns @62 + png_get_x_offset_pixels @63 + png_get_x_pixels_per_meter @64 + png_get_y_offset_microns @65 + png_get_y_offset_pixels @66 + png_get_y_pixels_per_meter @67 + png_malloc @68 + png_memcpy_check @69 + png_memset_check @70 +; png_permit_empty_plte is deprecated + png_permit_empty_plte @71 + png_process_data @72 + png_progressive_combine_row @73 + png_read_end @74 + png_read_image @75 + png_read_info @76 +; png_read_init is deprecated + png_read_init @77 + png_read_png @78 + png_read_row @79 + png_read_rows @80 + png_read_update_info @81 + png_reset_zstream @82 + png_set_IHDR @83 + png_set_PLTE @84 + png_set_bKGD @85 + png_set_background @86 + png_set_bgr @87 + png_set_cHRM @88 + png_set_cHRM_fixed @89 + png_set_compression_buffer_size @90 + png_set_compression_level @91 + png_set_compression_mem_level @92 + png_set_compression_method @93 + png_set_compression_strategy @94 + png_set_compression_window_bits @95 + png_set_crc_action @96 + png_set_dither @97 + png_set_error_fn @98 + png_set_expand @99 + png_set_filler @100 + png_set_filter @101 + png_set_filter_heuristics @102 + png_set_flush @103 + png_set_gAMA @104 + png_set_gAMA_fixed @105 + png_set_gamma @106 +; png_set_gray_1_2_4_to_8 is deprecated + png_set_gray_1_2_4_to_8 @107 + png_set_gray_to_rgb @108 + png_set_hIST @109 + png_set_iCCP @110 + png_set_interlace_handling @111 + png_set_invert_alpha @112 + png_set_invert_mono @113 + png_set_keep_unknown_chunks @114 + png_set_oFFs @115 + png_set_pCAL @116 + png_set_pHYs @117 + png_set_packing @118 + png_set_packswap @119 + png_set_palette_to_rgb @120 + png_set_progressive_read_fn @121 + png_set_read_fn @122 + png_set_read_status_fn @123 + png_set_read_user_chunk_fn @124 + png_set_read_user_transform_fn @125 + png_set_rgb_to_gray @126 + png_set_rgb_to_gray_fixed @127 + png_set_rows @128 + png_set_sBIT @129 + png_set_sCAL @130 + png_set_sPLT @131 + png_set_sRGB @132 + png_set_sRGB_gAMA_and_cHRM @133 + png_set_shift @134 + png_set_sig_bytes @135 + png_set_strip_16 @136 + png_set_strip_alpha @137 + png_set_swap @138 + png_set_swap_alpha @139 + png_set_tIME @140 + png_set_tRNS @141 + png_set_tRNS_to_alpha @142 + png_set_text @143 + png_set_unknown_chunk_location @144 + png_set_unknown_chunks @145 + png_set_user_transform_info @146 + png_set_write_fn @147 + png_set_write_status_fn @148 + png_set_write_user_transform_fn @149 + png_sig_cmp @150 + png_start_read_image @151 + png_warning @152 + png_write_chunk @153 + png_write_chunk_data @154 + png_write_chunk_end @155 + png_write_chunk_start @156 + png_write_end @157 + png_write_flush @158 + png_write_image @159 + png_write_info @160 + png_write_info_before_PLTE @161 +; png_write_init is deprecated + png_write_init @162 + png_write_png @163 + png_write_row @164 + png_write_rows @165 +; png_read_init_2 and png_write_init_2 are deprecated. + png_read_init_2 @166 + png_write_init_2 @167 + png_access_version_number @168 +; png_sig_bytes @169 + png_libpng_ver @170 + png_init_io @171 + png_convert_to_rfc1123 @172 + png_set_invalid @173 +; Added at version 1.0.12 +; For compatibility with 1.0.7-1.0.11 +; png_info_init @174 + png_read_init_3 @175 + png_write_init_3 @176 + png_info_init_3 @177 + png_destroy_struct @178 +; Added at version 1.2.0 +; For use with PNG_USER_MEM_SUPPORTED + png_destroy_struct_2 @179 + png_create_read_struct_2 @180 + png_create_write_struct_2 @181 + png_malloc_default @182 + png_free_default @183 +; MNG features + png_permit_mng_features @184 +; MMX support + png_mmx_support @185 +; png_get_mmx_flagmask @186 + png_get_asm_flagmask @187 + png_get_asm_flags @188 +; png_get_mmx_bitdepth_threshold @189 +; png_get_mmx_rowbytes_threshold @190 + png_set_asm_flags @191 +; png_init_mmx_flags @192 +; Strip error numbers + png_set_strip_error_numbers @193 +; Added at version 1.2.2 + png_handle_as_unknown @194 +; Added at version 1.2.2 and deleted from 1.2.3 +; png_zalloc @195 +; png_zfree @196 +; Added at version 1.2.4 + png_malloc_warn @195 +; Added at version 1.2.6 + png_malloc_warn @195 + png_get_user_height_max @196 + png_get_user_width_max @197 + png_set_user_limits @198 +; Added at version 1.2.7 + png_set_add_alpha @199 +; Added at version 1.2.9 + png_get_uint_32 @200 + png_save_uint_32 @201 + png_get_uint_16 @202 + png_save_uint_16 @203 + png_get_int_32 @204 + png_save_int_32 @205 + png_get_uint_31 @206 + png_set_expand_gray_1_2_4_to_8 @207 diff --git a/src/dep/src/irrlicht/libpng/scripts/pngw32.rc b/src/dep/src/irrlicht/libpng/scripts/pngw32.rc index f6cb0f0..02e30e2 100644 --- a/src/dep/src/irrlicht/libpng/scripts/pngw32.rc +++ b/src/dep/src/irrlicht/libpng/scripts/pngw32.rc @@ -1,112 +1,112 @@ -#define PNG_VERSION_INFO_ONLY - -#include -#include "../png.h" - -#define _QUOTE(x) # x -#define QUOTE(x) _QUOTE(x) - -#define PNG_LIBPNG_DLLFNAME "LIBPNG" - -/* Support deprecated PRIVATEBUILD macro */ -#if defined(PRIVATEBUILD) && !defined(PNG_USER_PRIVATEBUILD) -# define PNG_USER_PRIVATEBUILD PRIVATEBUILD -#endif - -#if defined(PNG_USER_DLLFNAME_POSTFIX) && !defined(PNG_USER_PRIVATEBUILD) -# error "PNG_USER_PRIVATEBUILD must be defined as a string describing the\ - custom changes made to the library." -#endif - -/* Prioritize PNG_USER_x over PNG_LIBPNG_x */ -#ifdef PNG_USER_DLLFNAME_POSTFIX -# undef PNG_LIBPNG_DLLFNAME_POSTFIX -# define PNG_LIBPNG_DLLFNAME_POSTFIX PNG_USER_DLLFNAME_POSTFIX -#endif - -#ifdef PNG_USER_VERSIONINFO_COMMENTS -# undef PNG_LIBPNG_VERSIONINFO_COMMENTS -# define PNG_LIBPNG_VERSIONINFO_COMMENTS PNG_USER_VERSIONINFO_COMMENTS -#endif - -#if defined(PNG_DEBUG) && (PNG_DEBUG > 0) -# define VS_DEBUG VS_FF_DEBUG -# ifndef PNG_LIBPNG_DLLFNAME_POSTFIX -# define PNG_LIBPNG_DLLFNAME_POSTFIX "D" -# endif /* PNG_LIBPNG_DLLFNAME_POSTFIX */ -# ifndef PNG_LIBPNG_VERSIONINFO_COMMENTS -# define PNG_LIBPNG_VERSIONINFO_COMMENTS "PNG_DEBUG=" QUOTE(PNG_DEBUG) -# endif /* PNG_LIBPNG_VERSIONINFO_COMMENTS */ -#else -# define VS_DEBUG 0 -# ifndef PNG_LIBPNG_DLLFNAME_POSTFIX -# define PNG_LIBPNG_DLLFNAME_POSTFIX -# endif /* PNG_LIBPNG_DLLFNAME_POSTFIX */ -#endif /* defined(DEBUG)... */ - -#ifdef PNG_USER_PRIVATEBUILD -# define VS_PRIVATEBUILD VS_FF_PRIVATEBUILD -#else -# define VS_PRIVATEBUILD 0 -#endif /* PNG_USER_PRIVATEBUILD */ - -#ifdef PNG_LIBPNG_SPECIALBUILD -# define VS_SPECIALBUILD VS_FF_SPECIALBUILD -#else -# define VS_SPECIALBUILD 0 -#endif /* PNG_LIBPNG_BUILD_SPECIAL */ - -#if ((PNG_LIBPNG_BUILD_BASE_TYPE & PNG_LIBPNG_RELEASE_STATUS_MASK) !=\ - PNG_LIBPNG_BUILD_STABLE) -# define VS_PRERELEASE VS_FF_PRERELEASE -# define VS_PATCHED 0 -#else -# define VS_PRERELEASE 0 -# if (PNG_LIBPNG_BUILD_BASE_TYPE & PNG_LIBPNG_BUILD_PATCHED) -# define VS_PATCHED VS_FF_PATCHED -# else -# define VS_PATCHED 0 -# endif -#endif - -VS_VERSION_INFO VERSIONINFO -FILEVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD -PRODUCTVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD -FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -FILEFLAGS VS_DEBUG | VS_PRIVATEBUILD | VS_SPECIALBUILD | VS_PRERELEASE | VS_PATCHED -FILEOS VOS__WINDOWS32 -FILETYPE VFT_DLL -FILESUBTYPE VFT2_UNKNOWN -BEGIN - BLOCK "StringFileInfo" - BEGIN BLOCK "040904E4" /* Language type = U.S English(0x0409) and Character Set = Windows, Multilingual(0x04E4) */ - BEGIN -#ifdef PNG_LIBPNG_VERSIONINFO_COMMENTS - VALUE "Comments", PNG_LIBPNG_VERSIONINFO_COMMENTS "\000" -#endif /* PNG_LIBPNG_VERSIONINFO_COMMENTS */ -#ifdef PNG_USER_VERSIONINFO_COMPANYNAME - VALUE "CompanyName", PNG_USER_VERSIONINFO_COMPANYNAME "\000" -#endif /* PNG_USER_VERSIONINFO_COMPANYNAME */ - VALUE "FileDescription", "PNG image compression library\000" - VALUE "FileVersion", PNG_LIBPNG_VER_STRING "\000" - VALUE "InternalName", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_DLLNUM) PNG_LIBPNG_DLLFNAME_POSTFIX " (Windows 32 bit)\000" - VALUE "LegalCopyright", "\251 1998-2004 Glenn Randers-Pehrson et al.\000" -#ifdef PNG_USER_VERSIONINFO_LEGALTRADEMARKS - VALUE "LegalTrademarks", PNG_USER_VERSIONINFO_LEGALTRADEMARKS "\000" -#endif /* PNG_USER_VERSIONINFO_LEGALTRADEMARKS */ - VALUE "OriginalFilename", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_DLLNUM) PNG_LIBPNG_DLLFNAME_POSTFIX ".DLL\000" -#ifdef PNG_USER_PRIVATEBUILD - VALUE "PrivateBuild", PNG_USER_PRIVATEBUILD "\000" -#endif /* PNG_USER_PRIVATEBUILD */ - VALUE "ProductName", "LibPNG\000" - VALUE "ProductVersion", "1\000" -#ifdef PNG_LIBPNG_SPECIALBUILD - VALUE "SpecialBuild", PNG_LIBPNG_SPECIALBUILD "\000" -#endif /* PNG_LIBPNG_SPECIALBUILD */ - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 0x04E4 - END -END +#define PNG_VERSION_INFO_ONLY + +#include +#include "../png.h" + +#define _QUOTE(x) # x +#define QUOTE(x) _QUOTE(x) + +#define PNG_LIBPNG_DLLFNAME "LIBPNG" + +/* Support deprecated PRIVATEBUILD macro */ +#if defined(PRIVATEBUILD) && !defined(PNG_USER_PRIVATEBUILD) +# define PNG_USER_PRIVATEBUILD PRIVATEBUILD +#endif + +#if defined(PNG_USER_DLLFNAME_POSTFIX) && !defined(PNG_USER_PRIVATEBUILD) +# error "PNG_USER_PRIVATEBUILD must be defined as a string describing the\ + custom changes made to the library." +#endif + +/* Prioritize PNG_USER_x over PNG_LIBPNG_x */ +#ifdef PNG_USER_DLLFNAME_POSTFIX +# undef PNG_LIBPNG_DLLFNAME_POSTFIX +# define PNG_LIBPNG_DLLFNAME_POSTFIX PNG_USER_DLLFNAME_POSTFIX +#endif + +#ifdef PNG_USER_VERSIONINFO_COMMENTS +# undef PNG_LIBPNG_VERSIONINFO_COMMENTS +# define PNG_LIBPNG_VERSIONINFO_COMMENTS PNG_USER_VERSIONINFO_COMMENTS +#endif + +#if defined(PNG_DEBUG) && (PNG_DEBUG > 0) +# define VS_DEBUG VS_FF_DEBUG +# ifndef PNG_LIBPNG_DLLFNAME_POSTFIX +# define PNG_LIBPNG_DLLFNAME_POSTFIX "D" +# endif /* PNG_LIBPNG_DLLFNAME_POSTFIX */ +# ifndef PNG_LIBPNG_VERSIONINFO_COMMENTS +# define PNG_LIBPNG_VERSIONINFO_COMMENTS "PNG_DEBUG=" QUOTE(PNG_DEBUG) +# endif /* PNG_LIBPNG_VERSIONINFO_COMMENTS */ +#else +# define VS_DEBUG 0 +# ifndef PNG_LIBPNG_DLLFNAME_POSTFIX +# define PNG_LIBPNG_DLLFNAME_POSTFIX +# endif /* PNG_LIBPNG_DLLFNAME_POSTFIX */ +#endif /* defined(DEBUG)... */ + +#ifdef PNG_USER_PRIVATEBUILD +# define VS_PRIVATEBUILD VS_FF_PRIVATEBUILD +#else +# define VS_PRIVATEBUILD 0 +#endif /* PNG_USER_PRIVATEBUILD */ + +#ifdef PNG_LIBPNG_SPECIALBUILD +# define VS_SPECIALBUILD VS_FF_SPECIALBUILD +#else +# define VS_SPECIALBUILD 0 +#endif /* PNG_LIBPNG_BUILD_SPECIAL */ + +#if ((PNG_LIBPNG_BUILD_BASE_TYPE & PNG_LIBPNG_RELEASE_STATUS_MASK) !=\ + PNG_LIBPNG_BUILD_STABLE) +# define VS_PRERELEASE VS_FF_PRERELEASE +# define VS_PATCHED 0 +#else +# define VS_PRERELEASE 0 +# if (PNG_LIBPNG_BUILD_BASE_TYPE & PNG_LIBPNG_BUILD_PATCHED) +# define VS_PATCHED VS_FF_PATCHED +# else +# define VS_PATCHED 0 +# endif +#endif + +VS_VERSION_INFO VERSIONINFO +FILEVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD +PRODUCTVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS VS_DEBUG | VS_PRIVATEBUILD | VS_SPECIALBUILD | VS_PRERELEASE | VS_PATCHED +FILEOS VOS__WINDOWS32 +FILETYPE VFT_DLL +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN BLOCK "040904E4" /* Language type = U.S English(0x0409) and Character Set = Windows, Multilingual(0x04E4) */ + BEGIN +#ifdef PNG_LIBPNG_VERSIONINFO_COMMENTS + VALUE "Comments", PNG_LIBPNG_VERSIONINFO_COMMENTS "\000" +#endif /* PNG_LIBPNG_VERSIONINFO_COMMENTS */ +#ifdef PNG_USER_VERSIONINFO_COMPANYNAME + VALUE "CompanyName", PNG_USER_VERSIONINFO_COMPANYNAME "\000" +#endif /* PNG_USER_VERSIONINFO_COMPANYNAME */ + VALUE "FileDescription", "PNG image compression library\000" + VALUE "FileVersion", PNG_LIBPNG_VER_STRING "\000" + VALUE "InternalName", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_DLLNUM) PNG_LIBPNG_DLLFNAME_POSTFIX " (Windows 32 bit)\000" + VALUE "LegalCopyright", "\251 1998-2004 Glenn Randers-Pehrson et al.\000" +#ifdef PNG_USER_VERSIONINFO_LEGALTRADEMARKS + VALUE "LegalTrademarks", PNG_USER_VERSIONINFO_LEGALTRADEMARKS "\000" +#endif /* PNG_USER_VERSIONINFO_LEGALTRADEMARKS */ + VALUE "OriginalFilename", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_DLLNUM) PNG_LIBPNG_DLLFNAME_POSTFIX ".DLL\000" +#ifdef PNG_USER_PRIVATEBUILD + VALUE "PrivateBuild", PNG_USER_PRIVATEBUILD "\000" +#endif /* PNG_USER_PRIVATEBUILD */ + VALUE "ProductName", "LibPNG\000" + VALUE "ProductVersion", "1\000" +#ifdef PNG_LIBPNG_SPECIALBUILD + VALUE "SpecialBuild", PNG_LIBPNG_SPECIALBUILD "\000" +#endif /* PNG_LIBPNG_SPECIALBUILD */ + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x04E4 + END +END diff --git a/src/dep/src/irrlicht/libpng/scripts/smakefile.ppc b/src/dep/src/irrlicht/libpng/scripts/smakefile.ppc index 2bc2178..e5c0278 100644 --- a/src/dep/src/irrlicht/libpng/scripts/smakefile.ppc +++ b/src/dep/src/irrlicht/libpng/scripts/smakefile.ppc @@ -1,30 +1,30 @@ -# Amiga powerUP (TM) Makefile -# makefile for libpng and SAS C V6.58/7.00 PPC compiler -# Copyright (C) 1998 by Andreas R. Kleinert -# For conditions of distribution and use, see copyright notice in png.h - -CC = scppc -CFLAGS = NOSTKCHK NOSINT OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL IDIR /zlib \ - OPTLOOP OPTRDEP=8 OPTDEP=8 OPTCOMP=8 -LIBNAME = libpng.a -AR = ppc-amigaos-ar -AR_FLAGS = cr -RANLIB = ppc-amigaos-ranlib -LDFLAGS = -r -o -LDLIBS = ../zlib/libzip.a LIB:scppc.a -LN = ppc-amigaos-ld -RM = delete quiet -MKDIR = makedir - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o pngread.o \ -pngerror.o pngpread.o pngwrite.o pngrtran.o pngwtran.o pngrio.o pngwio.o pngmem.o - -all: $(LIBNAME) pngtest - -$(LIBNAME): $(OBJS) - $(AR) $(AR_FLAGS) $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o $(LIBNAME) - $(LN) $(LDFLAGS) pngtest LIB:c_ppc.o pngtest.o $(LIBNAME) $(LDLIBS) \ -LIB:end.o +# Amiga powerUP (TM) Makefile +# makefile for libpng and SAS C V6.58/7.00 PPC compiler +# Copyright (C) 1998 by Andreas R. Kleinert +# For conditions of distribution and use, see copyright notice in png.h + +CC = scppc +CFLAGS = NOSTKCHK NOSINT OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL IDIR /zlib \ + OPTLOOP OPTRDEP=8 OPTDEP=8 OPTCOMP=8 +LIBNAME = libpng.a +AR = ppc-amigaos-ar +AR_FLAGS = cr +RANLIB = ppc-amigaos-ranlib +LDFLAGS = -r -o +LDLIBS = ../zlib/libzip.a LIB:scppc.a +LN = ppc-amigaos-ld +RM = delete quiet +MKDIR = makedir + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o pngread.o \ +pngerror.o pngpread.o pngwrite.o pngrtran.o pngwtran.o pngrio.o pngwio.o pngmem.o + +all: $(LIBNAME) pngtest + +$(LIBNAME): $(OBJS) + $(AR) $(AR_FLAGS) $@ $(OBJS) + $(RANLIB) $@ + +pngtest: pngtest.o $(LIBNAME) + $(LN) $(LDFLAGS) pngtest LIB:c_ppc.o pngtest.o $(LIBNAME) $(LDLIBS) \ +LIB:end.o diff --git a/src/dep/src/irrlicht/os.cpp b/src/dep/src/irrlicht/os.cpp index 2cb1ea9..a43c523 100644 --- a/src/dep/src/irrlicht/os.cpp +++ b/src/dep/src/irrlicht/os.cpp @@ -1,275 +1,275 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "os.h" -#include "irrString.h" -#include "IrrCompileConfig.h" -#include "irrMath.h" - -#ifdef _IRR_WINDOWS_ - #if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER < 1299)) - #define bswap_16(X) ((((X)&0xFF) << 8) | (((X)&=0xFF00) >> 8)) - #define bswap_32(X) ( (((X)&0x000000FF)<<24) | (((X)&0xFF000000) >> 24) | (((X)&0x0000FF00) << 8) | (((X) &0x00FF0000) >> 8)) - #else - #include - #define bswap_16(X) _byteswap_ushort(X) - #define bswap_32(X) _byteswap_ulong(X) - #endif -#else - #ifdef MACOSX - #define bswap_16(X) OSReadSwapInt16(&X,0) - #define bswap_32(X) OSReadSwapInt32(&X,0) - #elif defined(__FreeBSD__) - #include - #define bswap_16(X) bswap16(X) - #define bswap_32(X) bswap32(X) - #elif !defined(__sun__) && !defined(__PPC__) - #include - #else - #define bswap_16(X) ((((X)&0xFF) << 8) | (((X)&=0xFF00) >> 8)) - #define bswap_32(X) ( (((X)&0x000000FF)<<24) | (((X)&0xFF000000) >> 24) | (((X)&0x0000FF00) << 8) | (((X) &0x00FF0000) >> 8)) - #endif -#endif - -namespace irr -{ -namespace os -{ - u16 Byteswap::byteswap(u16 num) {return bswap_16(num);} - s16 Byteswap::byteswap(s16 num) {return bswap_16(num);} - u32 Byteswap::byteswap(u32 num) {return bswap_32(num);} - s32 Byteswap::byteswap(s32 num) {return bswap_32(num);} - f32 Byteswap::byteswap(f32 num) {u32 tmp=bswap_32(*((u32*)&num)); return *((f32*)&tmp);} -} -} - -#if defined(_IRR_WINDOWS_) || defined(_XBOX) -// ---------------------------------------------------------------- -// Windows specific functions -// ---------------------------------------------------------------- - -#ifdef _IRR_WINDOWS_ -#define WIN32_LEAN_AND_MEAN -#include -#endif -#ifdef _XBOX -#include -#endif - -namespace irr -{ -namespace os -{ - //! prints a debuginfo string - void Printer::print(const c8* message) - { - c8* tmp = new c8[strlen(message) + 2]; - sprintf(tmp, "%s\n", message); - OutputDebugString(tmp); - printf(tmp); - delete [] tmp; - } - - - LARGE_INTEGER HighPerformanceFreq; - BOOL HighPerformanceTimerSupport = FALSE; - - - void Timer::initTimer() - { - HighPerformanceTimerSupport = QueryPerformanceFrequency(&HighPerformanceFreq); - initVirtualTimer(); - } - - u32 Timer::getRealTime() - { - if (HighPerformanceTimerSupport) - { - LARGE_INTEGER nTime; - QueryPerformanceCounter(&nTime); - return u32((nTime.QuadPart) * 1000 / HighPerformanceFreq.QuadPart); - } - return GetTickCount(); - } - -} // end namespace os - - -#else - -// ---------------------------------------------------------------- -// linux/ansi version -// ---------------------------------------------------------------- - -#include -#include -#include - -namespace irr -{ -namespace os -{ - - //! prints a debuginfo string - void Printer::print(const c8* message) - { - printf("%s\n", message); - } - - void Timer::initTimer() - { - initVirtualTimer(); - } - - u32 Timer::getRealTime() - { - static timeval tv; - gettimeofday(&tv, 0); - return (u32)(tv.tv_sec * 1000) + (tv.tv_usec / 1000); - } - -} // end namespace os - -#endif // end linux / windows - -namespace os -{ - // The platform independent implementation of the printer - ILogger* Printer::Logger = 0; - - void Printer::log(const c8* message, ELOG_LEVEL ll) - { - if (Logger) - Logger->log(message, ll); - } - - void Printer::log(const c8* message, const c8* hint, ELOG_LEVEL ll) - { - if (!Logger) - return; - - Logger->log(message, hint, ll); - } - - void Printer::log(const wchar_t* message, ELOG_LEVEL ll) - { - if (Logger) - Logger->log(message, ll); - } - - - // our Randomizer is not really os specific, so we - // code one for all, which should work on every platform the same, - // which is desireable. - - s32 Randomizer::seed = 0x0f0f0f0f; - - //! generates a pseudo random number - s32 Randomizer::rand() - { - const s32 m = 2147483399; // a non-Mersenne prime - const s32 a = 40692; // another spectral success story - const s32 q = m/a; - const s32 r = m%a; // again less than q - - seed = a * (seed%q) - r* (seed/q); - if (seed<0) seed += m; - - return seed; - } - - //! resets the randomizer - void Randomizer::reset() - { - seed = 0x0f0f0f0f; - } - - - // ------------------------------------------------------ - // virtual timer implementation - - f32 Timer::VirtualTimerSpeed = 1.0f; - s32 Timer::VirtualTimerStopCounter = 0; - u32 Timer::LastVirtualTime = 0; - u32 Timer::StartRealTime = 0; - u32 Timer::StaticTime = 0; - - //! returns current virtual time - u32 Timer::getTime() - { - if (isStopped()) - return LastVirtualTime; - - return LastVirtualTime + (u32)((StaticTime - StartRealTime) * VirtualTimerSpeed); - } - - //! ticks, advances the virtual timer - void Timer::tick() - { - StaticTime = getRealTime(); - } - - //! sets the current virtual time - void Timer::setTime(u32 time) - { - StaticTime = getRealTime(); - LastVirtualTime = time; - StartRealTime = StaticTime; - } - - //! stops the virtual timer - void Timer::stopTimer() - { - if (!isStopped()) - { - // stop the virtual timer - LastVirtualTime = getTime(); - } - - --VirtualTimerStopCounter; - } - - //! starts the virtual timer - void Timer::startTimer() - { - ++VirtualTimerStopCounter; - - if (!isStopped()) - { - // restart virtual timer - setTime(LastVirtualTime); - } - } - - //! sets the speed of the virtual timer - void Timer::setSpeed(f32 speed) - { - setTime(getTime()); - - VirtualTimerSpeed = speed; - if (VirtualTimerSpeed < 0.0f) - VirtualTimerSpeed = 0.0f; - } - - //! gets the speed of the virtual timer - f32 Timer::getSpeed() - { - return VirtualTimerSpeed; - } - - //! returns if the timer currently is stopped - bool Timer::isStopped() - { - return VirtualTimerStopCounter != 0; - } - - void Timer::initVirtualTimer() - { - StaticTime = getRealTime(); - StartRealTime = StaticTime; - } - -} // end namespace os -} // end namespace irr - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "os.h" +#include "irrString.h" +#include "IrrCompileConfig.h" +#include "irrMath.h" + +#ifdef _IRR_WINDOWS_ + #if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER < 1299)) + #define bswap_16(X) ((((X)&0xFF) << 8) | (((X)&=0xFF00) >> 8)) + #define bswap_32(X) ( (((X)&0x000000FF)<<24) | (((X)&0xFF000000) >> 24) | (((X)&0x0000FF00) << 8) | (((X) &0x00FF0000) >> 8)) + #else + #include + #define bswap_16(X) _byteswap_ushort(X) + #define bswap_32(X) _byteswap_ulong(X) + #endif +#else + #ifdef MACOSX + #define bswap_16(X) OSReadSwapInt16(&X,0) + #define bswap_32(X) OSReadSwapInt32(&X,0) + #elif defined(__FreeBSD__) + #include + #define bswap_16(X) bswap16(X) + #define bswap_32(X) bswap32(X) + #elif !defined(__sun__) && !defined(__PPC__) + #include + #else + #define bswap_16(X) ((((X)&0xFF) << 8) | (((X)&=0xFF00) >> 8)) + #define bswap_32(X) ( (((X)&0x000000FF)<<24) | (((X)&0xFF000000) >> 24) | (((X)&0x0000FF00) << 8) | (((X) &0x00FF0000) >> 8)) + #endif +#endif + +namespace irr +{ +namespace os +{ + u16 Byteswap::byteswap(u16 num) {return bswap_16(num);} + s16 Byteswap::byteswap(s16 num) {return bswap_16(num);} + u32 Byteswap::byteswap(u32 num) {return bswap_32(num);} + s32 Byteswap::byteswap(s32 num) {return bswap_32(num);} + f32 Byteswap::byteswap(f32 num) {u32 tmp=bswap_32(*((u32*)&num)); return *((f32*)&tmp);} +} +} + +#if defined(_IRR_WINDOWS_) || defined(_XBOX) +// ---------------------------------------------------------------- +// Windows specific functions +// ---------------------------------------------------------------- + +#ifdef _IRR_WINDOWS_ +#define WIN32_LEAN_AND_MEAN +#include +#endif +#ifdef _XBOX +#include +#endif + +namespace irr +{ +namespace os +{ + //! prints a debuginfo string + void Printer::print(const c8* message) + { + c8* tmp = new c8[strlen(message) + 2]; + sprintf(tmp, "%s\n", message); + OutputDebugString(tmp); + printf(tmp); + delete [] tmp; + } + + + LARGE_INTEGER HighPerformanceFreq; + BOOL HighPerformanceTimerSupport = FALSE; + + + void Timer::initTimer() + { + HighPerformanceTimerSupport = QueryPerformanceFrequency(&HighPerformanceFreq); + initVirtualTimer(); + } + + u32 Timer::getRealTime() + { + if (HighPerformanceTimerSupport) + { + LARGE_INTEGER nTime; + QueryPerformanceCounter(&nTime); + return u32((nTime.QuadPart) * 1000 / HighPerformanceFreq.QuadPart); + } + return GetTickCount(); + } + +} // end namespace os + + +#else + +// ---------------------------------------------------------------- +// linux/ansi version +// ---------------------------------------------------------------- + +#include +#include +#include + +namespace irr +{ +namespace os +{ + + //! prints a debuginfo string + void Printer::print(const c8* message) + { + printf("%s\n", message); + } + + void Timer::initTimer() + { + initVirtualTimer(); + } + + u32 Timer::getRealTime() + { + static timeval tv; + gettimeofday(&tv, 0); + return (u32)(tv.tv_sec * 1000) + (tv.tv_usec / 1000); + } + +} // end namespace os + +#endif // end linux / windows + +namespace os +{ + // The platform independent implementation of the printer + ILogger* Printer::Logger = 0; + + void Printer::log(const c8* message, ELOG_LEVEL ll) + { + if (Logger) + Logger->log(message, ll); + } + + void Printer::log(const c8* message, const c8* hint, ELOG_LEVEL ll) + { + if (!Logger) + return; + + Logger->log(message, hint, ll); + } + + void Printer::log(const wchar_t* message, ELOG_LEVEL ll) + { + if (Logger) + Logger->log(message, ll); + } + + + // our Randomizer is not really os specific, so we + // code one for all, which should work on every platform the same, + // which is desireable. + + s32 Randomizer::seed = 0x0f0f0f0f; + + //! generates a pseudo random number + s32 Randomizer::rand() + { + const s32 m = 2147483399; // a non-Mersenne prime + const s32 a = 40692; // another spectral success story + const s32 q = m/a; + const s32 r = m%a; // again less than q + + seed = a * (seed%q) - r* (seed/q); + if (seed<0) seed += m; + + return seed; + } + + //! resets the randomizer + void Randomizer::reset() + { + seed = 0x0f0f0f0f; + } + + + // ------------------------------------------------------ + // virtual timer implementation + + f32 Timer::VirtualTimerSpeed = 1.0f; + s32 Timer::VirtualTimerStopCounter = 0; + u32 Timer::LastVirtualTime = 0; + u32 Timer::StartRealTime = 0; + u32 Timer::StaticTime = 0; + + //! returns current virtual time + u32 Timer::getTime() + { + if (isStopped()) + return LastVirtualTime; + + return LastVirtualTime + (u32)((StaticTime - StartRealTime) * VirtualTimerSpeed); + } + + //! ticks, advances the virtual timer + void Timer::tick() + { + StaticTime = getRealTime(); + } + + //! sets the current virtual time + void Timer::setTime(u32 time) + { + StaticTime = getRealTime(); + LastVirtualTime = time; + StartRealTime = StaticTime; + } + + //! stops the virtual timer + void Timer::stopTimer() + { + if (!isStopped()) + { + // stop the virtual timer + LastVirtualTime = getTime(); + } + + --VirtualTimerStopCounter; + } + + //! starts the virtual timer + void Timer::startTimer() + { + ++VirtualTimerStopCounter; + + if (!isStopped()) + { + // restart virtual timer + setTime(LastVirtualTime); + } + } + + //! sets the speed of the virtual timer + void Timer::setSpeed(f32 speed) + { + setTime(getTime()); + + VirtualTimerSpeed = speed; + if (VirtualTimerSpeed < 0.0f) + VirtualTimerSpeed = 0.0f; + } + + //! gets the speed of the virtual timer + f32 Timer::getSpeed() + { + return VirtualTimerSpeed; + } + + //! returns if the timer currently is stopped + bool Timer::isStopped() + { + return VirtualTimerStopCounter != 0; + } + + void Timer::initVirtualTimer() + { + StaticTime = getRealTime(); + StartRealTime = StaticTime; + } + +} // end namespace os +} // end namespace irr + diff --git a/src/dep/src/irrlicht/os.h b/src/dep/src/irrlicht/os.h index 5c3b8c2..6d03811 100644 --- a/src/dep/src/irrlicht/os.h +++ b/src/dep/src/irrlicht/os.h @@ -1,107 +1,107 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_OS_H_INCLUDED__ -#define __IRR_OS_H_INCLUDED__ - -#include "IrrCompileConfig.h" // for endian check -#include "irrTypes.h" -#include "ILogger.h" - -namespace irr -{ - -namespace os -{ - class Byteswap - { - public: - static u16 byteswap(u16 num); - static s16 byteswap(s16 num); - static u32 byteswap(u32 num); - static s32 byteswap(s32 num); - static f32 byteswap(f32 num); - }; - - class Printer - { - public: - // prints out a string to the console out stdout or debug log or whatever - static void print(const c8* message); - static void log(const c8* message, ELOG_LEVEL ll = ELL_INFORMATION); - static void log(const c8* message, const c8* hint, ELOG_LEVEL ll = ELL_INFORMATION); - static void log(const wchar_t* message, ELOG_LEVEL ll = ELL_INFORMATION); - static ILogger* Logger; - }; - - - class Randomizer - { - public: - - //! resets the randomizer - static void reset(); - - //! generates a pseudo random number - static s32 rand(); - - private: - - static s32 seed; - }; - - - - - class Timer - { - public: - - //! returns the current time in milliseconds - static u32 getTime(); - - //! initializes the real timer - static void initTimer(); - - //! sets the current virtual (game) time - static void setTime(u32 time); - - //! stops the virtual (game) timer - static void stopTimer(); - - //! starts the game timer - static void startTimer(); - - //! sets the speed of the virtual timer - static void setSpeed(f32 speed); - - //! gets the speed of the virtual timer - static f32 getSpeed(); - - //! returns if the timer currently is stopped - static bool isStopped(); - - //! makes the virtual timer update the time value based on the real time - static void tick(); - - //! returns the current real time in milliseconds - static u32 getRealTime(); - - private: - - static void initVirtualTimer(); - - static f32 VirtualTimerSpeed; - static s32 VirtualTimerStopCounter; - static u32 StartRealTime; - static u32 LastVirtualTime; - static u32 StaticTime; - }; - -} // end namespace os -} // end namespace irr - - -#endif - +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __IRR_OS_H_INCLUDED__ +#define __IRR_OS_H_INCLUDED__ + +#include "IrrCompileConfig.h" // for endian check +#include "irrTypes.h" +#include "ILogger.h" + +namespace irr +{ + +namespace os +{ + class Byteswap + { + public: + static u16 byteswap(u16 num); + static s16 byteswap(s16 num); + static u32 byteswap(u32 num); + static s32 byteswap(s32 num); + static f32 byteswap(f32 num); + }; + + class Printer + { + public: + // prints out a string to the console out stdout or debug log or whatever + static void print(const c8* message); + static void log(const c8* message, ELOG_LEVEL ll = ELL_INFORMATION); + static void log(const c8* message, const c8* hint, ELOG_LEVEL ll = ELL_INFORMATION); + static void log(const wchar_t* message, ELOG_LEVEL ll = ELL_INFORMATION); + static ILogger* Logger; + }; + + + class Randomizer + { + public: + + //! resets the randomizer + static void reset(); + + //! generates a pseudo random number + static s32 rand(); + + private: + + static s32 seed; + }; + + + + + class Timer + { + public: + + //! returns the current time in milliseconds + static u32 getTime(); + + //! initializes the real timer + static void initTimer(); + + //! sets the current virtual (game) time + static void setTime(u32 time); + + //! stops the virtual (game) timer + static void stopTimer(); + + //! starts the game timer + static void startTimer(); + + //! sets the speed of the virtual timer + static void setSpeed(f32 speed); + + //! gets the speed of the virtual timer + static f32 getSpeed(); + + //! returns if the timer currently is stopped + static bool isStopped(); + + //! makes the virtual timer update the time value based on the real time + static void tick(); + + //! returns the current real time in milliseconds + static u32 getRealTime(); + + private: + + static void initVirtualTimer(); + + static f32 VirtualTimerSpeed; + static s32 VirtualTimerStopCounter; + static u32 StartRealTime; + static u32 LastVirtualTime; + static u32 StaticTime; + }; + +} // end namespace os +} // end namespace irr + + +#endif + diff --git a/src/shared.vcproj b/src/shared.vcproj index 7bccfdb..ed5cdc5 100644 --- a/src/shared.vcproj +++ b/src/shared.vcproj @@ -1,328 +1,328 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/shared/ADTFile.cpp b/src/shared/ADTFile.cpp index 2950bcd..e2fcbc0 100644 --- a/src/shared/ADTFile.cpp +++ b/src/shared/ADTFile.cpp @@ -1,348 +1,348 @@ -#include -#include "common.h" -#include "ADTFile.h" - - -inline void flipcc(uint8 *fcc) -{ - char t; - t=fcc[0]; - fcc[0]=fcc[3]; - fcc[3]=t; - t=fcc[1]; - fcc[1]=fcc[2]; - fcc[2]=t; -} - -bool ADTFile::Load(std::string fn) -{ - try - { - uint32 fs = GetFileSize(fn.c_str()); - if(!fs) - return false; - std::fstream fh; - fh.open(fn.c_str(), std::ios_base::in | std::ios_base::binary); - if(!fh.is_open()) - return false; - - ByteBuffer buf(fs); - buf.resize(fs); - fh.read((char*)buf.contents(),fs); - fh.close(); - buf.rpos(0); - return LoadMem(buf); - } - catch (...) - { - printf("ADTFile::Load() Exception\n"); - return false; - } - -} - -bool ADTFile::LoadMem(ByteBuffer& buf) -{ - uint32 texturecnt=0,modelcnt=0,wmocnt=0; - uint32 size; // used for every chunk - uint32 mcnkid=0; - uint8 _cc[5]; - uint8 *fourcc = &_cc[0]; - fourcc[4]=0; - - while(buf.rpos() < buf.size()) - { - buf.read(fourcc,4); flipcc(fourcc); - buf.read((uint8*)&size,4); - //DEBUG(printf("ADT: reading '%s' size %u\n",fourcc,size)); - - if(!strcmp((char*)fourcc,"MVER")) - { - buf >> _version; - } - else if(!strcmp((char*)fourcc,"MHDR")) - { - mhdr = buf.read(); - } - else if(!strcmp((char*)fourcc,"MCIN")) - { - for(uint32 i = 0; i < CHUNKS_PER_TILE; i++) - { - mcin[i] = buf.read(); - //DEBUG(printf("ADT chunk %u at offset %u, size %u flags %X async %u\n",i,mcin[i].offset,mcin[i].size,mcin[i].flags,mcin[i].async)); - if(!mcin[i].offset) - { - printf("ADT: ERROR: chunk offset is NULL! Not loading.\n"); - return false; - } - } - } - else if(!strcmp((char*)fourcc,"MTEX")) - { - for(uint32 i=0;;i++) - { - std::string tex; - memcpy(fourcc,buf.contents()+buf.rpos(),4); - flipcc(fourcc); - if(!memcmp(fourcc,"MMDX",4)) - break; - buf >> tex; - //DEBUG(printf("MTEX offset %u \"%s\"\n",buf.rpos(),tex.c_str())); - _textures.push_back(tex); - texturecnt++; - } - //DEBUG(printf("ADT: loaded %u textures\n",texturecnt)); - } - else if(!strcmp((char*)fourcc,"MMDX")) - { - for(uint32 i=0;;i++) - { - std::string model; - memcpy(fourcc,buf.contents()+buf.rpos(),4); - flipcc(fourcc); - if(!memcmp(fourcc,"MMID",4)) - break; - buf >> model; - //DEBUG(printf("MMDX offset %u \"%s\"\n",buf.rpos(),model.c_str())); - _models.push_back(model); - modelcnt++; - } - //DEBUG(printf("ADT: loaded %u models\n",modelcnt)); - } - /*else if(!strcmp((char*)fourcc,"MMID")) - { - for(uint32 i = 0; i <= modelcnt; i++) - { - uint32 offs; - buf >> offs; // we dont really need those offsets - } - }*/ - else if(!strcmp((char*)fourcc,"MWMO")) - { - for(uint32 i=0;;i++) - { - std::string wmo; - memcpy(fourcc,buf.contents()+buf.rpos(),4); - flipcc(fourcc); - if(!memcmp(fourcc,"MWID",4)) - break; - buf >> wmo; - //DEBUG(printf("MWMO offset %u \"%s\"\n",buf.rpos(),wmo.c_str())); - _wmos.push_back(wmo); - wmocnt++; - } - } - /*else if(!strcmp((char*)fourcc,"MWID")) - { - for(uint32 i = 0; i <= wmocnt; i++) - { - uint32 offs; - buf >> offs; // we dont really need those offsets - } - }*/ - else if(!strcmp((char*)fourcc,"MDDF")) - { - uint32 ndoodads = size / 36; - //DEBUG(printf("ADT: Loading %u doodads.\n",ndoodads)); - for(uint32 i = 0; i()); - } - } - else if(!strcmp((char*)fourcc,"MODF")) - { - uint32 nwmos = size / 64; - //DEBUG(printf("ADT: Loading %u wmos.\n",nwmos)); - for(uint32 i = 0; i()); - } - } - else if(!strcmp((char*)fourcc,"MCNK")) - { - _chunks[mcnkid].hdr = buf.read(); - uint8 _cc2[5]; - uint8 *mfcc = &_cc2[0]; - mfcc[4]=0; - uint32 msize; - while(buf.rpos()>_chunks[mcnkid].vertices[i]; - } - } - else if(!strcmp((char*)mfcc,"MCNR")) - { - for(uint32 i = 0; i < 145; i++) - { - _chunks[mcnkid].normalvecs[i] = buf.read(); - } - // HACK: skip unk junk bytes - if(msize==0x1B3) - buf.rpos(buf.rpos()+0xD); - } - else if(!strcmp((char*)mfcc,"MCLY")) - { - _chunks[mcnkid].nTextures = msize / 16; - ASSERT(msize/16 == _chunks[mcnkid].hdr.nLayers); - for(uint32 i = 0; i < _chunks[mcnkid].nTextures; i++) - { - _chunks[mcnkid].layer[i] = buf.read(); - } - } - else if(!strcmp((char*)mfcc,"MCSH")) - { - buf.read((uint8*)&(_chunks[mcnkid].shadowmap),512); - } - else if(!strcmp((char*)mfcc,"MCAL")) - { - for(uint32 i = 0; i < (_chunks[mcnkid].hdr.sizeAlpha - 8) / 2048; i++) - { - buf.read((uint8*)(_chunks[mcnkid].alphamap[i]),2048); - } - } - else if(!strcmp((char*)mfcc,"MCLQ")) - { - uint8 _cc3[5]; - uint8 *fcc1 = &_cc3[0]; - buf.read(fcc1,4); - flipcc(fcc1); - fcc1[4]=0; - if (!strcmp((char*)fcc1,"MCSE")) - { - _chunks[mcnkid].haswater = false; - //DEBUG(printf("ADT: MCNK: MCLQ not present\n")); - buf.rpos(buf.rpos()-4); - continue; // next block read will be the MCSE block - } - else - { - _chunks[mcnkid].haswater = true; - float tmp; - buf.rpos(buf.rpos()-4); - uint32 bufpos=buf.rpos(); - uint32 rbytes,diffbytes; - buf >> _chunks[mcnkid].waterlevel; - buf >> tmp; - //DEBUG(printf("ADT: MCNK: MCLQ base floats: %f %f\n",_chunks[mcnkid].waterlevel,tmp)); - //buf.rpos(buf.rpos()+4); // base height?? - if(msize > 8) // just to be sure - { - for(uint32 i = 0; i < 81; i++) - { - _chunks[mcnkid].lqvertex[i] = buf.read(); - } - for(uint32 i = 0; i < 64; i++) - { - buf >> _chunks[mcnkid].lqflags[i]; - } - rbytes = buf.rpos() - bufpos; - //DEBUG(printf("ADT: MCNK: MCLQ block loaded. %u / %u bytes.\n",rbytes,msize)); - } - else - { - //DEBUG(printf("ADT: MCNK: MCLQ block has only %u bytes\n",msize)); - } - // HACK: skip some unk junk bytes - diffbytes = (msize-8) - rbytes; // dont forget to skip the 8 initial bytes - buf.rpos(buf.rpos()+diffbytes); - //DEBUG(printf("ADT: MCNK: MCLQ - %u junk bytes skipped\n",diffbytes)); - } - } - else if(!strcmp((char*)mfcc,"MCSE")) - { - uint32 emm = _chunks[mcnkid].hdr.nSndEmitters; - for(uint32 i = 0; i < emm; i++) - { - _soundemm.push_back(buf.read()); - } - break; - } - else - { - //DEBUG(printf("ADT: MCNK: '%s' block unhandled, skipping %u bytes\n",mfcc,msize)); - if(!(isalnum(mfcc[0]) && isalnum(mfcc[1]) && isalnum(mfcc[2]) && isalnum(mfcc[3]))) - { - printf("Error loading ADT file (chunk %u error).\n",mcnkid); - return false; - } - - buf.rpos(buf.rpos()+msize); - } - - } - mcnkid++; - } - else - { - //DEBUG(printf("ADT: '%s' block unhandled, skipping %u bytes\n",fourcc,size)); - if(!(isalnum(fourcc[0]) && isalnum(fourcc[1]) && isalnum(fourcc[2]) && isalnum(fourcc[3]))) - { - printf("Error loading ADT file.\n"); - return false; - } - buf.rpos(buf.rpos()+size); - } - - } - return true; -} - - - - - - -void ADT_ExportStringSetByOffset(const uint8* data, uint32 off, std::set& st, char* stop) -{ - data += ((uint32*)data)[off]; // seek to correct absolute offset - data += 28; // move ptr to real start of data - uint32 offset=0; - std::string s; - char c; - while(memcmp(data+offset,stop,4)) - { - c = data[offset]; - if(!c) - { - if(s.length()) - { - DEBUG(printf("DEP: %s\n",s.c_str())); - st.insert(s); - s.clear(); - } - } - else - s += c; - offset++; - } -} - -void ADT_FillTextureData(const uint8* data,std::set& st) -{ - ADT_ExportStringSetByOffset(data,OFFSET_TEXTURES,st,"XDMM"); -} - -void ADT_FillWMOData(const uint8* data,std::set& st) -{ - ADT_ExportStringSetByOffset(data,OFFSET_WMOS,st,"DIWM"); -} - -void ADT_FillModelData(const uint8* data,std::set& st) -{ - ADT_ExportStringSetByOffset(data,OFFSET_MODELS,st,"DIMM"); -} +#include +#include "common.h" +#include "ADTFile.h" + + +inline void flipcc(uint8 *fcc) +{ + char t; + t=fcc[0]; + fcc[0]=fcc[3]; + fcc[3]=t; + t=fcc[1]; + fcc[1]=fcc[2]; + fcc[2]=t; +} + +bool ADTFile::Load(std::string fn) +{ + try + { + uint32 fs = GetFileSize(fn.c_str()); + if(!fs) + return false; + std::fstream fh; + fh.open(fn.c_str(), std::ios_base::in | std::ios_base::binary); + if(!fh.is_open()) + return false; + + ByteBuffer buf(fs); + buf.resize(fs); + fh.read((char*)buf.contents(),fs); + fh.close(); + buf.rpos(0); + return LoadMem(buf); + } + catch (...) + { + printf("ADTFile::Load() Exception\n"); + return false; + } + +} + +bool ADTFile::LoadMem(ByteBuffer& buf) +{ + uint32 texturecnt=0,modelcnt=0,wmocnt=0; + uint32 size; // used for every chunk + uint32 mcnkid=0; + uint8 _cc[5]; + uint8 *fourcc = &_cc[0]; + fourcc[4]=0; + + while(buf.rpos() < buf.size()) + { + buf.read(fourcc,4); flipcc(fourcc); + buf.read((uint8*)&size,4); + //DEBUG(printf("ADT: reading '%s' size %u\n",fourcc,size)); + + if(!strcmp((char*)fourcc,"MVER")) + { + buf >> _version; + } + else if(!strcmp((char*)fourcc,"MHDR")) + { + mhdr = buf.read(); + } + else if(!strcmp((char*)fourcc,"MCIN")) + { + for(uint32 i = 0; i < CHUNKS_PER_TILE; i++) + { + mcin[i] = buf.read(); + //DEBUG(printf("ADT chunk %u at offset %u, size %u flags %X async %u\n",i,mcin[i].offset,mcin[i].size,mcin[i].flags,mcin[i].async)); + if(!mcin[i].offset) + { + printf("ADT: ERROR: chunk offset is NULL! Not loading.\n"); + return false; + } + } + } + else if(!strcmp((char*)fourcc,"MTEX")) + { + for(uint32 i=0;;i++) + { + std::string tex; + memcpy(fourcc,buf.contents()+buf.rpos(),4); + flipcc(fourcc); + if(!memcmp(fourcc,"MMDX",4)) + break; + buf >> tex; + //DEBUG(printf("MTEX offset %u \"%s\"\n",buf.rpos(),tex.c_str())); + _textures.push_back(tex); + texturecnt++; + } + //DEBUG(printf("ADT: loaded %u textures\n",texturecnt)); + } + else if(!strcmp((char*)fourcc,"MMDX")) + { + for(uint32 i=0;;i++) + { + std::string model; + memcpy(fourcc,buf.contents()+buf.rpos(),4); + flipcc(fourcc); + if(!memcmp(fourcc,"MMID",4)) + break; + buf >> model; + //DEBUG(printf("MMDX offset %u \"%s\"\n",buf.rpos(),model.c_str())); + _models.push_back(model); + modelcnt++; + } + //DEBUG(printf("ADT: loaded %u models\n",modelcnt)); + } + /*else if(!strcmp((char*)fourcc,"MMID")) + { + for(uint32 i = 0; i <= modelcnt; i++) + { + uint32 offs; + buf >> offs; // we dont really need those offsets + } + }*/ + else if(!strcmp((char*)fourcc,"MWMO")) + { + for(uint32 i=0;;i++) + { + std::string wmo; + memcpy(fourcc,buf.contents()+buf.rpos(),4); + flipcc(fourcc); + if(!memcmp(fourcc,"MWID",4)) + break; + buf >> wmo; + //DEBUG(printf("MWMO offset %u \"%s\"\n",buf.rpos(),wmo.c_str())); + _wmos.push_back(wmo); + wmocnt++; + } + } + /*else if(!strcmp((char*)fourcc,"MWID")) + { + for(uint32 i = 0; i <= wmocnt; i++) + { + uint32 offs; + buf >> offs; // we dont really need those offsets + } + }*/ + else if(!strcmp((char*)fourcc,"MDDF")) + { + uint32 ndoodads = size / 36; + //DEBUG(printf("ADT: Loading %u doodads.\n",ndoodads)); + for(uint32 i = 0; i()); + } + } + else if(!strcmp((char*)fourcc,"MODF")) + { + uint32 nwmos = size / 64; + //DEBUG(printf("ADT: Loading %u wmos.\n",nwmos)); + for(uint32 i = 0; i()); + } + } + else if(!strcmp((char*)fourcc,"MCNK")) + { + _chunks[mcnkid].hdr = buf.read(); + uint8 _cc2[5]; + uint8 *mfcc = &_cc2[0]; + mfcc[4]=0; + uint32 msize; + while(buf.rpos()>_chunks[mcnkid].vertices[i]; + } + } + else if(!strcmp((char*)mfcc,"MCNR")) + { + for(uint32 i = 0; i < 145; i++) + { + _chunks[mcnkid].normalvecs[i] = buf.read(); + } + // HACK: skip unk junk bytes + if(msize==0x1B3) + buf.rpos(buf.rpos()+0xD); + } + else if(!strcmp((char*)mfcc,"MCLY")) + { + _chunks[mcnkid].nTextures = msize / 16; + ASSERT(msize/16 == _chunks[mcnkid].hdr.nLayers); + for(uint32 i = 0; i < _chunks[mcnkid].nTextures; i++) + { + _chunks[mcnkid].layer[i] = buf.read(); + } + } + else if(!strcmp((char*)mfcc,"MCSH")) + { + buf.read((uint8*)&(_chunks[mcnkid].shadowmap),512); + } + else if(!strcmp((char*)mfcc,"MCAL")) + { + for(uint32 i = 0; i < (_chunks[mcnkid].hdr.sizeAlpha - 8) / 2048; i++) + { + buf.read((uint8*)(_chunks[mcnkid].alphamap[i]),2048); + } + } + else if(!strcmp((char*)mfcc,"MCLQ")) + { + uint8 _cc3[5]; + uint8 *fcc1 = &_cc3[0]; + buf.read(fcc1,4); + flipcc(fcc1); + fcc1[4]=0; + if (!strcmp((char*)fcc1,"MCSE")) + { + _chunks[mcnkid].haswater = false; + //DEBUG(printf("ADT: MCNK: MCLQ not present\n")); + buf.rpos(buf.rpos()-4); + continue; // next block read will be the MCSE block + } + else + { + _chunks[mcnkid].haswater = true; + float tmp; + buf.rpos(buf.rpos()-4); + uint32 bufpos=buf.rpos(); + uint32 rbytes,diffbytes; + buf >> _chunks[mcnkid].waterlevel; + buf >> tmp; + //DEBUG(printf("ADT: MCNK: MCLQ base floats: %f %f\n",_chunks[mcnkid].waterlevel,tmp)); + //buf.rpos(buf.rpos()+4); // base height?? + if(msize > 8) // just to be sure + { + for(uint32 i = 0; i < 81; i++) + { + _chunks[mcnkid].lqvertex[i] = buf.read(); + } + for(uint32 i = 0; i < 64; i++) + { + buf >> _chunks[mcnkid].lqflags[i]; + } + rbytes = buf.rpos() - bufpos; + //DEBUG(printf("ADT: MCNK: MCLQ block loaded. %u / %u bytes.\n",rbytes,msize)); + } + else + { + //DEBUG(printf("ADT: MCNK: MCLQ block has only %u bytes\n",msize)); + } + // HACK: skip some unk junk bytes + diffbytes = (msize-8) - rbytes; // dont forget to skip the 8 initial bytes + buf.rpos(buf.rpos()+diffbytes); + //DEBUG(printf("ADT: MCNK: MCLQ - %u junk bytes skipped\n",diffbytes)); + } + } + else if(!strcmp((char*)mfcc,"MCSE")) + { + uint32 emm = _chunks[mcnkid].hdr.nSndEmitters; + for(uint32 i = 0; i < emm; i++) + { + _soundemm.push_back(buf.read()); + } + break; + } + else + { + //DEBUG(printf("ADT: MCNK: '%s' block unhandled, skipping %u bytes\n",mfcc,msize)); + if(!(isalnum(mfcc[0]) && isalnum(mfcc[1]) && isalnum(mfcc[2]) && isalnum(mfcc[3]))) + { + printf("Error loading ADT file (chunk %u error).\n",mcnkid); + return false; + } + + buf.rpos(buf.rpos()+msize); + } + + } + mcnkid++; + } + else + { + //DEBUG(printf("ADT: '%s' block unhandled, skipping %u bytes\n",fourcc,size)); + if(!(isalnum(fourcc[0]) && isalnum(fourcc[1]) && isalnum(fourcc[2]) && isalnum(fourcc[3]))) + { + printf("Error loading ADT file.\n"); + return false; + } + buf.rpos(buf.rpos()+size); + } + + } + return true; +} + + + + + + +void ADT_ExportStringSetByOffset(const uint8* data, uint32 off, std::set& st, char* stop) +{ + data += ((uint32*)data)[off]; // seek to correct absolute offset + data += 28; // move ptr to real start of data + uint32 offset=0; + std::string s; + char c; + while(memcmp(data+offset,stop,4)) + { + c = data[offset]; + if(!c) + { + if(s.length()) + { + DEBUG(printf("DEP: %s\n",s.c_str())); + st.insert(s); + s.clear(); + } + } + else + s += c; + offset++; + } +} + +void ADT_FillTextureData(const uint8* data,std::set& st) +{ + ADT_ExportStringSetByOffset(data,OFFSET_TEXTURES,st,"XDMM"); +} + +void ADT_FillWMOData(const uint8* data,std::set& st) +{ + ADT_ExportStringSetByOffset(data,OFFSET_WMOS,st,"DIWM"); +} + +void ADT_FillModelData(const uint8* data,std::set& st) +{ + ADT_ExportStringSetByOffset(data,OFFSET_MODELS,st,"DIMM"); +} diff --git a/src/shared/ADTFile.h b/src/shared/ADTFile.h index 3e8b4fc..4d66642 100644 --- a/src/shared/ADTFile.h +++ b/src/shared/ADTFile.h @@ -1,33 +1,33 @@ -#ifndef ADTFILE_H -#define ADTFILE_H - -#include - -#define CHUNKS_PER_TILE 256 - -#include "ADTFileStructs.h" - -class ADTFile -{ -public: - bool Load(std::string); - bool LoadMem(ByteBuffer&); - - ADTMapChunk _chunks[CHUNKS_PER_TILE]; // 16x16 - std::vector _textures; - std::vector _wmos; - std::vector _models; - std::vector _doodadsp; - std::vector _wmosp; - std::vector _soundemm; - MHDR_chunk mhdr; - MCIN_chunk mcin[CHUNKS_PER_TILE]; - uint32 _version; -}; - -void ADT_ExportStringSetByOffset(const uint8*, uint32, std::set&, char*); -void ADT_FillTextureData(const uint8*,std::set&); -void ADT_FillWMOData(const uint8*,std::set&); -void ADT_FillModelData(const uint8*,std::set&); - -#endif +#ifndef ADTFILE_H +#define ADTFILE_H + +#include + +#define CHUNKS_PER_TILE 256 + +#include "ADTFileStructs.h" + +class ADTFile +{ +public: + bool Load(std::string); + bool LoadMem(ByteBuffer&); + + ADTMapChunk _chunks[CHUNKS_PER_TILE]; // 16x16 + std::vector _textures; + std::vector _wmos; + std::vector _models; + std::vector _doodadsp; + std::vector _wmosp; + std::vector _soundemm; + MHDR_chunk mhdr; + MCIN_chunk mcin[CHUNKS_PER_TILE]; + uint32 _version; +}; + +void ADT_ExportStringSetByOffset(const uint8*, uint32, std::set&, char*); +void ADT_FillTextureData(const uint8*,std::set&); +void ADT_FillWMOData(const uint8*,std::set&); +void ADT_FillModelData(const uint8*,std::set&); + +#endif diff --git a/src/shared/Auth/MD5Hash.h b/src/shared/Auth/MD5Hash.h index 9a6339d..da8395d 100644 --- a/src/shared/Auth/MD5Hash.h +++ b/src/shared/Auth/MD5Hash.h @@ -1,45 +1,45 @@ -#ifndef MD5HASH_H -#define MD5HASH_H - -#define MD5_DIGEST_LENGTH 16 - -#include "Auth/md5.h" - -class MD5Hash -{ -public: - MD5Hash() - { - md5_init(&_state); - memset(_digest,0,MD5_DIGEST_LENGTH); - } - - - void Update(uint8 *buf,uint32 len) - { - md5_append(&_state,buf,len); - } - - void Update(std::string s) - { - Update((uint8*)s.c_str(),s.length()); - } - - void Finalize(void) - { - md5_finish(&_state,_digest); - } - - uint8 *GetDigest(void) - { - return _digest; - } - - uint8 GetLength(void) { return MD5_DIGEST_LENGTH; } - -private: - md5_state_t _state; - uint8 _digest[MD5_DIGEST_LENGTH]; -}; - -#endif +#ifndef MD5HASH_H +#define MD5HASH_H + +#define MD5_DIGEST_LENGTH 16 + +#include "Auth/md5.h" + +class MD5Hash +{ +public: + MD5Hash() + { + md5_init(&_state); + memset(_digest,0,MD5_DIGEST_LENGTH); + } + + + void Update(uint8 *buf,uint32 len) + { + md5_append(&_state,buf,len); + } + + void Update(std::string s) + { + Update((uint8*)s.c_str(),s.length()); + } + + void Finalize(void) + { + md5_finish(&_state,_digest); + } + + uint8 *GetDigest(void) + { + return _digest; + } + + uint8 GetLength(void) { return MD5_DIGEST_LENGTH; } + +private: + md5_state_t _state; + uint8 _digest[MD5_DIGEST_LENGTH]; +}; + +#endif diff --git a/src/shared/DebugStuff.h b/src/shared/DebugStuff.h index 4f39d9f..41fb5d3 100644 --- a/src/shared/DebugStuff.h +++ b/src/shared/DebugStuff.h @@ -1,19 +1,19 @@ -#ifndef _DEBUGSTUFF_H -#define _DEBUGSTUFF_H - - -#ifdef _DEBUG - #define DEBUG(code) code; - #define DEBUG_APPENDIX " - DEBUG" - #define CODEDEB(code) fprintf(stderr,"[[ %s ]]\n",#code); code; -#else - #define DEBUG(code) /* code */ - #define DEBUG_APPENDIX - #define CODEDEB(code) (code;) -#endif - -#define ASSERT( assertion ) { if( !(assertion) ) { fprintf( stderr, "\n%s:%i ASSERTION FAILED:\n %s\n", __FILE__, __LINE__, #assertion ); throw "Assertion Failed"; }} - - - -#endif +#ifndef _DEBUGSTUFF_H +#define _DEBUGSTUFF_H + + +#ifdef _DEBUG + #define DEBUG(code) code; + #define DEBUG_APPENDIX " - DEBUG" + #define CODEDEB(code) fprintf(stderr,"[[ %s ]]\n",#code); code; +#else + #define DEBUG(code) /* code */ + #define DEBUG_APPENDIX + #define CODEDEB(code) (code;) +#endif + +#define ASSERT( assertion ) { if( !(assertion) ) { fprintf( stderr, "\n%s:%i ASSERTION FAILED:\n %s\n", __FILE__, __LINE__, #assertion ); throw "Assertion Failed"; }} + + + +#endif diff --git a/src/shared/MapTile.cpp b/src/shared/MapTile.cpp index 2062098..fcbce71 100644 --- a/src/shared/MapTile.cpp +++ b/src/shared/MapTile.cpp @@ -1,130 +1,130 @@ -#include "common.h" -#include "MapTile.h" -#include "log.h" - -MapTile::MapTile() -{ -} - -MapTile::~MapTile() -{ -} - -void MapTile::ImportFromADT(ADTFile *adt) -{ - // strip the path name from the dependency files, just store the plain filename - for(std::vector::iterator it = adt->_textures.begin(); it != adt->_textures.end(); it++) - this->_textures.push_back(_PathToFileName(*it)); - for(std::vector::iterator it = adt->_models.begin(); it != adt->_models.end(); it++) - this->_models.push_back(_PathToFileName(*it)); - for(std::vector::iterator it = adt->_wmos.begin(); it != adt->_wmos.end(); it++) - this->_wmos.push_back(_PathToFileName(*it)); - - // import the height map - for(uint32 ch=0; ch_chunks[ch].hdr.zbase; // ADT files store (x/z) as ground coords and (y) as the height! - _chunks[ch].basex = adt->_chunks[ch].hdr.xbase; // here converting it to (x/y) on ground and basehight as actual height. - _chunks[ch].basey = adt->_chunks[ch].hdr.ybase; // strange coords they use... :S - uint32 fcnt=0, rcnt=0; - while(true) //9*9 + 8*8 - { - for(uint32 h=0; h<9; h++) - { - _chunks[ch].hmap_rough[rcnt] = adt->_chunks[ch].vertices[fcnt+rcnt]; - rcnt++; - } - if(rcnt+fcnt >= 145) - break; - for(uint32 h=0; h<8; h++) - { - _chunks[ch].hmap_fine[fcnt] = adt->_chunks[ch].vertices[fcnt+rcnt]; - fcnt++; - } - } - } - _xbase = _chunks[0].basex; - _ybase = _chunks[0].basey; - _hbase = _chunks[0].baseheight; - DEBUG(logdebug("MapTile first chunk base: h=%f x=%f y=%f",_hbase,_xbase,_ybase)); -} - -void MapTileStorage::_DebugDump(void) -{ - std::string out; - for(uint32 i=0; i<64; i++) - { - for(uint32 j=0; j<64; j++) - { - - out += (_hasTile[i*64 + j] ? "1" : "0"); - } - out += "\n"; - } - printf("MAP TILE MAP DEBUG DUMP, 64x64 TILES:\n"); - printf(out.c_str()); -} - -// get approx Z position for world position (x,y). -// TODO: use inner vertices also -// TODO: interpolate values instead of choosing closest vertex -// formula taken from BoogieBot, thx! -/*float MapTile::GetZ(float x, float y) -{ - float bx,by; - bx = _chunks[0].basex; // world base coords of tile - by = _chunks[0].basey; - uint32 chx = (uint32)fabs((bx - x) / CHUNKSIZE); // get chunk id for given coords - uint32 chy = (uint32)fabs((by - y) / CHUNKSIZE); - if( chx > 15 || chy > 15) - { - logerror("MapTile::GetZ() wrong chunk indexes (%d, %d) for (%f, %f)",chx,chy,x,y); - logerror(" - These coords are NOT on this tile!"); - return 0; - } - MapChunk& ch = _chunks[chy*16 + chx]; - uint32 vx,vy; // get vertex position (0,0) ... (8,8); - vx = (uint32)floor((fabs(ch.basex - x) / UNITSIZE) + 0.5f); - vy = (uint32)floor((fabs(ch.basey - y) / UNITSIZE) + 0.5f); - if(vx > 8 || vy > 8) - { - logerror("MapTile::GetZ() wrong vertex indexes (%d, %d) for chunk (%d, %d) for (%f, %f)",vx,vy,chx,chy,x,y); - return 0; - } - - float real_z = ch.hmap_rough[vy*9 + vx] + ch.baseheight; - - return real_z; -}*/ - -void MapTile::DebugDumpToFile(void) -{ - const char *f = "0123456789abcdefghijklmnopqrstuvwxyz"; - float z; - uint32 p; - std::string out; - for(uint32 cy=0;cy<16;cy++) - { - for(uint32 vy=0;vy<9;vy++) - { - for(uint32 cx=0;cx<16;cx++) - { - for(uint32 vx=0;vx<9;vx++) - { - z = _chunks[cy*16 + cx].hmap_rough[vy*9 + vx] + _chunks[cy*16 + cx].baseheight; - p = (uint32)z; - uint32 pos = 17 + (p/10); - if(pos > strlen(f)-1) - pos=strlen(f)-1; - char c = f[pos]; - out += c; - } - } - out += "\n"; - } - } - FILE *fh; - fh = fopen("map_dump.txt","w"); - fprintf(fh, out.c_str()); - fclose(fh); -} +#include "common.h" +#include "MapTile.h" +#include "log.h" + +MapTile::MapTile() +{ +} + +MapTile::~MapTile() +{ +} + +void MapTile::ImportFromADT(ADTFile *adt) +{ + // strip the path name from the dependency files, just store the plain filename + for(std::vector::iterator it = adt->_textures.begin(); it != adt->_textures.end(); it++) + this->_textures.push_back(_PathToFileName(*it)); + for(std::vector::iterator it = adt->_models.begin(); it != adt->_models.end(); it++) + this->_models.push_back(_PathToFileName(*it)); + for(std::vector::iterator it = adt->_wmos.begin(); it != adt->_wmos.end(); it++) + this->_wmos.push_back(_PathToFileName(*it)); + + // import the height map + for(uint32 ch=0; ch_chunks[ch].hdr.zbase; // ADT files store (x/z) as ground coords and (y) as the height! + _chunks[ch].basex = adt->_chunks[ch].hdr.xbase; // here converting it to (x/y) on ground and basehight as actual height. + _chunks[ch].basey = adt->_chunks[ch].hdr.ybase; // strange coords they use... :S + uint32 fcnt=0, rcnt=0; + while(true) //9*9 + 8*8 + { + for(uint32 h=0; h<9; h++) + { + _chunks[ch].hmap_rough[rcnt] = adt->_chunks[ch].vertices[fcnt+rcnt]; + rcnt++; + } + if(rcnt+fcnt >= 145) + break; + for(uint32 h=0; h<8; h++) + { + _chunks[ch].hmap_fine[fcnt] = adt->_chunks[ch].vertices[fcnt+rcnt]; + fcnt++; + } + } + } + _xbase = _chunks[0].basex; + _ybase = _chunks[0].basey; + _hbase = _chunks[0].baseheight; + DEBUG(logdebug("MapTile first chunk base: h=%f x=%f y=%f",_hbase,_xbase,_ybase)); +} + +void MapTileStorage::_DebugDump(void) +{ + std::string out; + for(uint32 i=0; i<64; i++) + { + for(uint32 j=0; j<64; j++) + { + + out += (_hasTile[i*64 + j] ? "1" : "0"); + } + out += "\n"; + } + printf("MAP TILE MAP DEBUG DUMP, 64x64 TILES:\n"); + printf(out.c_str()); +} + +// get approx Z position for world position (x,y). +// TODO: use inner vertices also +// TODO: interpolate values instead of choosing closest vertex +// formula taken from BoogieBot, thx! +/*float MapTile::GetZ(float x, float y) +{ + float bx,by; + bx = _chunks[0].basex; // world base coords of tile + by = _chunks[0].basey; + uint32 chx = (uint32)fabs((bx - x) / CHUNKSIZE); // get chunk id for given coords + uint32 chy = (uint32)fabs((by - y) / CHUNKSIZE); + if( chx > 15 || chy > 15) + { + logerror("MapTile::GetZ() wrong chunk indexes (%d, %d) for (%f, %f)",chx,chy,x,y); + logerror(" - These coords are NOT on this tile!"); + return 0; + } + MapChunk& ch = _chunks[chy*16 + chx]; + uint32 vx,vy; // get vertex position (0,0) ... (8,8); + vx = (uint32)floor((fabs(ch.basex - x) / UNITSIZE) + 0.5f); + vy = (uint32)floor((fabs(ch.basey - y) / UNITSIZE) + 0.5f); + if(vx > 8 || vy > 8) + { + logerror("MapTile::GetZ() wrong vertex indexes (%d, %d) for chunk (%d, %d) for (%f, %f)",vx,vy,chx,chy,x,y); + return 0; + } + + float real_z = ch.hmap_rough[vy*9 + vx] + ch.baseheight; + + return real_z; +}*/ + +void MapTile::DebugDumpToFile(void) +{ + const char *f = "0123456789abcdefghijklmnopqrstuvwxyz"; + float z; + uint32 p; + std::string out; + for(uint32 cy=0;cy<16;cy++) + { + for(uint32 vy=0;vy<9;vy++) + { + for(uint32 cx=0;cx<16;cx++) + { + for(uint32 vx=0;vx<9;vx++) + { + z = _chunks[cy*16 + cx].hmap_rough[vy*9 + vx] + _chunks[cy*16 + cx].baseheight; + p = (uint32)z; + uint32 pos = 17 + (p/10); + if(pos > strlen(f)-1) + pos=strlen(f)-1; + char c = f[pos]; + out += c; + } + } + out += "\n"; + } + } + FILE *fh; + fh = fopen("map_dump.txt","w"); + fprintf(fh, out.c_str()); + fclose(fh); +} diff --git a/src/shared/MapTile.h b/src/shared/MapTile.h index d7ca372..7ea185e 100644 --- a/src/shared/MapTile.h +++ b/src/shared/MapTile.h @@ -1,110 +1,110 @@ -#ifndef MAPTILE_H -#define MAPTILE_H - -#include - -#include "WDTFile.h" -#include "ADTFile.h" - -#define TILESIZE (533.33333f) -#define CHUNKSIZE ((TILESIZE) / 16.0f) -#define UNITSIZE (CHUNKSIZE / 8.0f) -#define ZEROPOINT (32.0f * (TILESIZE)) - -// individual chunks of a map -class MapChunk -{ -public: - float hmap_rough[9*9]; - float hmap_fine[8*8]; - float hmap[17*17]; // combined rough and fine hmap - float basex,basey,baseheight; - //... TODO: implement the rest of this -}; - -// generic map tile class. stores the information previously stored in an ADT file -// in an easier to use form. -class MapTile -{ -public: - MapTile(); - ~MapTile(); - void ImportFromADT(ADTFile*); - float GetZ(float,float); - void DebugDumpToFile(void); - inline MapChunk *GetChunk(uint32 x, uint32 y) { return &_chunks[y * 16 + x]; } - inline float GetBaseX(void) { return _xbase; } - inline float GetBaseY(void) { return _ybase; } - inline float GetBaseHeight(void) { return _hbase; } - -private: - MapChunk _chunks[256]; // 16x16 - std::vector _textures; - std::vector _wmos; - std::vector _models; - - float _xbase,_ybase,_hbase; - -}; - -// store which map tiles are present in the world -class MapTileStorage -{ -public: - inline MapTileStorage() - { - memset(_tiles,0,sizeof(MapTile*)*4096); - } - inline ~MapTileStorage() - { - for(uint32 i=0; i<4096; i++) - UnloadMapTile(i); - } - inline void ImportTileMap(WDTFile* w) - { - _hasTile.reset(); - for(uint32 i=0; i<64; i++) - { - for(uint32 j=0; j<64; j++) - { - if(w->_main.tiles[i*64 + j]) - _hasTile[i*64 + j] = true; - } - - } - } - inline void SetTile(MapTile* tile, uint32 x, uint32 y) { SetTile(tile, y*64 + x); } - inline void SetTile(MapTile* tile, uint32 pos) - { - if(pos < 4096) - _tiles[pos] = tile; - } - inline void UnloadMapTile(uint32 x, uint32 y) { UnloadMapTile(y*64 + x); } - inline void UnloadMapTile(uint32 pos) - { - if(pos < 4096 && _tiles[pos]) - { - delete _tiles[pos]; - _tiles[pos] = NULL; - } - } - inline bool TileExists(uint32 x, uint32 y) { return TileExists(y*64 + x); } - inline bool TileExists(uint32 pos) - { - return pos < 4096 ? _hasTile[pos] : false; - } - inline MapTile *GetTile(uint32 x, uint32 y) { return GetTile(y*64 + x); } - inline MapTile *GetTile(uint32 pos) - { - return pos < 4096 ? _tiles[pos] : NULL; - } - void _DebugDump(void); - -private: - MapTile *_tiles[4096]; //64x64 - std::bitset<4096> _hasTile; -}; - - - -#endif +#ifndef MAPTILE_H +#define MAPTILE_H + +#include + +#include "WDTFile.h" +#include "ADTFile.h" + +#define TILESIZE (533.33333f) +#define CHUNKSIZE ((TILESIZE) / 16.0f) +#define UNITSIZE (CHUNKSIZE / 8.0f) +#define ZEROPOINT (32.0f * (TILESIZE)) + +// individual chunks of a map +class MapChunk +{ +public: + float hmap_rough[9*9]; + float hmap_fine[8*8]; + float hmap[17*17]; // combined rough and fine hmap + float basex,basey,baseheight; + //... TODO: implement the rest of this +}; + +// generic map tile class. stores the information previously stored in an ADT file +// in an easier to use form. +class MapTile +{ +public: + MapTile(); + ~MapTile(); + void ImportFromADT(ADTFile*); + float GetZ(float,float); + void DebugDumpToFile(void); + inline MapChunk *GetChunk(uint32 x, uint32 y) { return &_chunks[y * 16 + x]; } + inline float GetBaseX(void) { return _xbase; } + inline float GetBaseY(void) { return _ybase; } + inline float GetBaseHeight(void) { return _hbase; } + +private: + MapChunk _chunks[256]; // 16x16 + std::vector _textures; + std::vector _wmos; + std::vector _models; + + float _xbase,_ybase,_hbase; + +}; + +// store which map tiles are present in the world +class MapTileStorage +{ +public: + inline MapTileStorage() + { + memset(_tiles,0,sizeof(MapTile*)*4096); + } + inline ~MapTileStorage() + { + for(uint32 i=0; i<4096; i++) + UnloadMapTile(i); + } + inline void ImportTileMap(WDTFile* w) + { + _hasTile.reset(); + for(uint32 i=0; i<64; i++) + { + for(uint32 j=0; j<64; j++) + { + if(w->_main.tiles[i*64 + j]) + _hasTile[i*64 + j] = true; + } + + } + } + inline void SetTile(MapTile* tile, uint32 x, uint32 y) { SetTile(tile, y*64 + x); } + inline void SetTile(MapTile* tile, uint32 pos) + { + if(pos < 4096) + _tiles[pos] = tile; + } + inline void UnloadMapTile(uint32 x, uint32 y) { UnloadMapTile(y*64 + x); } + inline void UnloadMapTile(uint32 pos) + { + if(pos < 4096 && _tiles[pos]) + { + delete _tiles[pos]; + _tiles[pos] = NULL; + } + } + inline bool TileExists(uint32 x, uint32 y) { return TileExists(y*64 + x); } + inline bool TileExists(uint32 pos) + { + return pos < 4096 ? _hasTile[pos] : false; + } + inline MapTile *GetTile(uint32 x, uint32 y) { return GetTile(y*64 + x); } + inline MapTile *GetTile(uint32 pos) + { + return pos < 4096 ? _tiles[pos] : NULL; + } + void _DebugDump(void); + +private: + MapTile *_tiles[4096]; //64x64 + std::bitset<4096> _hasTile; +}; + + + +#endif diff --git a/src/shared/SysDefs.h b/src/shared/SysDefs.h index 24475f7..c4beba3 100644 --- a/src/shared/SysDefs.h +++ b/src/shared/SysDefs.h @@ -1,148 +1,148 @@ -#ifndef _SYSDEFS_H -#define _SYSDEFS_H - -////////////////////////////////////// -// Platform defines -////////////////////////////////////// - -#define PLATFORM_WIN32 0 -#define PLATFORM_UNIX 1 -#define PLATFORM_APPLE 2 -#define PLATFORM_INTEL 3 - -#if defined( __WIN32__ ) || defined( WIN32 ) || defined( _WIN32 ) -# define PLATFORM PLATFORM_WIN32 -#elif defined( __APPLE_CC__ ) -# define PLATFORM PLATFORM_APPLE -#elif defined( __INTEL_COMPILER ) -# define PLATFORM PLATFORM_INTEL -#else -# define PLATFORM PLATFORM_UNIX -#endif - -#define COMPILER_MICROSOFT 0 -#define COMPILER_GNU 1 -#define COMPILER_BORLAND 2 -#define COMPILER_INTEL 3 - -#ifdef _MSC_VER -# define COMPILER COMPILER_MICROSOFT -#elif defined( __BORLANDC__ ) -# define COMPILER COMPILER_BORLAND -#elif defined( __INTEL_COMPILER ) -# define COMPILER COMPILER_INTEL -#elif defined( __GNUC__ ) -# define COMPILER COMPILER_GNU -#else -# pragma error "FATAL ERROR: Unknown compiler." -#endif - -#if COMPILER == COMPILER_MICROSOFT -# pragma warning( disable : 4267 ) // conversion from 'size_t' to 'int', possible loss of data -# pragma warning( disable : 4786 ) // identifier was truncated to '255' characters in the debug information -# pragma warning( disable : 4800 ) // conversion to bool, performance warning -# pragma warning( disable : 4244 ) // conversion from 'uint64' to 'int16', possible loss of data -# pragma warning( disable : 4996 ) // disable warning for "too old" functions (VC80) -#endif - -//////////////////////////////////// -// Compiler defines -//////////////////////////////////// - -#if COMPILER == COMPILER_MICROSOFT - #define I64FMT "%016I64X" - #define I64FMTD "%I64u" - #define SI64FMTD "%I64d" - #define snprintf _snprintf - #define atoll __atoi64 - #define vsnprintf _vsnprintf - #define strdup _strdup - typedef __int64 int64; - typedef long int32; - typedef short int16; - typedef char int8; - typedef unsigned __int64 uint64; - typedef unsigned long uint32; - typedef unsigned short uint16; - typedef unsigned char uint8; -#else - #define stricmp strcasecmp - #define strnicmp strncasecmp - #define I64FMT "%016llX" - #define I64FMTD "%llu" - #define SI64FMTD "%lld" -# if PLATFORM == PLATFORM_UNIX - typedef __int64_t int64; - typedef __int32_t int32; - typedef __int16_t int16; - typedef __int8_t int8; - typedef __uint64_t uint64; - typedef __uint32_t uint32; - typedef __uint16_t uint16; - typedef __uint8_t uint8; - typedef uint16 WORD; - typedef uint32 DWORD; -# else - typedef long long int64; - typedef long int32; - typedef short int16; - typedef char int8; - typedef unsigned long long uint64; - typedef unsigned long uint32; - typedef unsigned short uint16; - typedef unsigned char uint8; - typedef unsigned short WORD; - typedef uint32 DWORD; -# endif -#endif - -#ifndef SIGQUIT -#define SIGQUIT 3 -#endif - -#ifdef min -#undef min -#endif - -#ifdef max -#undef max -#endif - -#if COMPILER == COMPILER_MICROSOFT -# if _MSC_VER >= 1500 -# define COMPILER_NAME "VC90" -# elif _MSC_VER >= 1400 -# define COMPILER_NAME "VC80" -# elif _MSC_VER >= 1310 -# define COMPILER_NAME "VC71" -# endif -# define COMPILER_VERSION _MSC_VER -# define COMPILER_VERSION_OUT "%u" -#elif COMPILER == COMPILER_GNU -# define COMPILER_NAME "GCC" -# ifdef __GNUC_PATCHLEVEL__ -# define COMPILER_VERSION STRINGIZE(__GNUC__) "." STRINGIZE(__GNUC_MINOR__) "." STRINGIZE(__GNUC_PATCHLEVEL__) -# else -# define COMPILER_VERSION STRINGIZE(__GNUC__) "." STRINGIZE(__GNUC_MINOR__) -# endif -# define COMPILER_VERSION_OUT "%s" -// TODO: add more compilers here when necessary -#else -# define COMPILER_NAME "unknown" -# define COMPILER_VERSION "unk" -# define COMPILER_VERSION_OUT "%s" -#endif - -#if PLATFORM == PLATFORM_UNIX -# define PLATFORM_NAME "Unix" -#elif PLATFORM == PLATFORM_WIN32 -# define PLATFORM_NAME "Win32" -#elif PLATFORM == PLATFORM_APPLE -# define PLATFORM_NAME "Apple" -// TODO: add more platforms here when necessary -#else -# define PLATFORM_NAME "unknown" -#endif - - -#endif +#ifndef _SYSDEFS_H +#define _SYSDEFS_H + +////////////////////////////////////// +// Platform defines +////////////////////////////////////// + +#define PLATFORM_WIN32 0 +#define PLATFORM_UNIX 1 +#define PLATFORM_APPLE 2 +#define PLATFORM_INTEL 3 + +#if defined( __WIN32__ ) || defined( WIN32 ) || defined( _WIN32 ) +# define PLATFORM PLATFORM_WIN32 +#elif defined( __APPLE_CC__ ) +# define PLATFORM PLATFORM_APPLE +#elif defined( __INTEL_COMPILER ) +# define PLATFORM PLATFORM_INTEL +#else +# define PLATFORM PLATFORM_UNIX +#endif + +#define COMPILER_MICROSOFT 0 +#define COMPILER_GNU 1 +#define COMPILER_BORLAND 2 +#define COMPILER_INTEL 3 + +#ifdef _MSC_VER +# define COMPILER COMPILER_MICROSOFT +#elif defined( __BORLANDC__ ) +# define COMPILER COMPILER_BORLAND +#elif defined( __INTEL_COMPILER ) +# define COMPILER COMPILER_INTEL +#elif defined( __GNUC__ ) +# define COMPILER COMPILER_GNU +#else +# pragma error "FATAL ERROR: Unknown compiler." +#endif + +#if COMPILER == COMPILER_MICROSOFT +# pragma warning( disable : 4267 ) // conversion from 'size_t' to 'int', possible loss of data +# pragma warning( disable : 4786 ) // identifier was truncated to '255' characters in the debug information +# pragma warning( disable : 4800 ) // conversion to bool, performance warning +# pragma warning( disable : 4244 ) // conversion from 'uint64' to 'int16', possible loss of data +# pragma warning( disable : 4996 ) // disable warning for "too old" functions (VC80) +#endif + +//////////////////////////////////// +// Compiler defines +//////////////////////////////////// + +#if COMPILER == COMPILER_MICROSOFT + #define I64FMT "%016I64X" + #define I64FMTD "%I64u" + #define SI64FMTD "%I64d" + #define snprintf _snprintf + #define atoll __atoi64 + #define vsnprintf _vsnprintf + #define strdup _strdup + typedef __int64 int64; + typedef long int32; + typedef short int16; + typedef char int8; + typedef unsigned __int64 uint64; + typedef unsigned long uint32; + typedef unsigned short uint16; + typedef unsigned char uint8; +#else + #define stricmp strcasecmp + #define strnicmp strncasecmp + #define I64FMT "%016llX" + #define I64FMTD "%llu" + #define SI64FMTD "%lld" +# if PLATFORM == PLATFORM_UNIX + typedef __int64_t int64; + typedef __int32_t int32; + typedef __int16_t int16; + typedef __int8_t int8; + typedef __uint64_t uint64; + typedef __uint32_t uint32; + typedef __uint16_t uint16; + typedef __uint8_t uint8; + typedef uint16 WORD; + typedef uint32 DWORD; +# else + typedef long long int64; + typedef long int32; + typedef short int16; + typedef char int8; + typedef unsigned long long uint64; + typedef unsigned long uint32; + typedef unsigned short uint16; + typedef unsigned char uint8; + typedef unsigned short WORD; + typedef uint32 DWORD; +# endif +#endif + +#ifndef SIGQUIT +#define SIGQUIT 3 +#endif + +#ifdef min +#undef min +#endif + +#ifdef max +#undef max +#endif + +#if COMPILER == COMPILER_MICROSOFT +# if _MSC_VER >= 1500 +# define COMPILER_NAME "VC90" +# elif _MSC_VER >= 1400 +# define COMPILER_NAME "VC80" +# elif _MSC_VER >= 1310 +# define COMPILER_NAME "VC71" +# endif +# define COMPILER_VERSION _MSC_VER +# define COMPILER_VERSION_OUT "%u" +#elif COMPILER == COMPILER_GNU +# define COMPILER_NAME "GCC" +# ifdef __GNUC_PATCHLEVEL__ +# define COMPILER_VERSION STRINGIZE(__GNUC__) "." STRINGIZE(__GNUC_MINOR__) "." STRINGIZE(__GNUC_PATCHLEVEL__) +# else +# define COMPILER_VERSION STRINGIZE(__GNUC__) "." STRINGIZE(__GNUC_MINOR__) +# endif +# define COMPILER_VERSION_OUT "%s" +// TODO: add more compilers here when necessary +#else +# define COMPILER_NAME "unknown" +# define COMPILER_VERSION "unk" +# define COMPILER_VERSION_OUT "%s" +#endif + +#if PLATFORM == PLATFORM_UNIX +# define PLATFORM_NAME "Unix" +#elif PLATFORM == PLATFORM_WIN32 +# define PLATFORM_NAME "Win32" +#elif PLATFORM == PLATFORM_APPLE +# define PLATFORM_NAME "Apple" +// TODO: add more platforms here when necessary +#else +# define PLATFORM_NAME "unknown" +#endif + + +#endif diff --git a/src/shared/WDTFile.cpp b/src/shared/WDTFile.cpp index 3954c10..8b0f35d 100644 --- a/src/shared/WDTFile.cpp +++ b/src/shared/WDTFile.cpp @@ -1,87 +1,87 @@ -#include -#include "common.h" -#include "ByteBuffer.h" -#include "WDTFile.h" - -inline void flipcc(uint8 *fcc) -{ - char t; - t=fcc[0]; - fcc[0]=fcc[3]; - fcc[3]=t; - t=fcc[1]; - fcc[1]=fcc[2]; - fcc[2]=t; -} - -bool WDTFile::Load(std::string fn) -{ - std::fstream fh; - fh.open(fn.c_str(),std::ios_base::in | std::ios_base::binary); - if(!fh.is_open()) - return false; - uint32 fs = GetFileSize(fn.c_str()); - ByteBuffer bb(fs); - bb.resize(fs); - fh.read((char*)bb.contents(),fs); - fh.close(); - bb.rpos(0); - return LoadMem(bb); -} - -bool WDTFile::LoadMem(ByteBuffer& buf) -{ - uint8 *fourcc = new uint8[5]; - fourcc[4] = 0; - uint32 size; - - while(buf.rpos() < buf.size()) - { - buf.read(fourcc,4); flipcc(fourcc); - buf >> size; - - if(!strcmp((char*)fourcc,"MVER")) - { - _mver = buf.read(); - } - else if(!strcmp((char*)fourcc,"MPHD")) - { - _mphd = buf.read(); - } - else if(!strcmp((char*)fourcc,"MAIN")) - { - _main = buf.read(); - } - else if(!strcmp((char*)fourcc,"MWMO")) - { - if(size) - { - DEBUG(printf("WDTFile::LoadMem() abort load, MWMO block isnt empty\n")); - break; - } - } - else if(!strcmp((char*)fourcc,"MODF")) - { - DEBUG(printf("WDTFile::LoadMem() abort load, MODF block exists\n")); - break; - } - } - delete [] fourcc; - return true; -} - -void WDTFile::_DebugDump(void) -{ - std::string out; - for(uint32 i=0; i<64; i++) - { - for(uint32 j=0; j<64; j++) - { - out += (_main.tiles[i*64+j] ? "1" : "0"); - } - out += "\n"; - } - printf("WDT DEBUG DUMP, 64x64 TILES:\n"); - printf(out.c_str()); -} - +#include +#include "common.h" +#include "ByteBuffer.h" +#include "WDTFile.h" + +inline void flipcc(uint8 *fcc) +{ + char t; + t=fcc[0]; + fcc[0]=fcc[3]; + fcc[3]=t; + t=fcc[1]; + fcc[1]=fcc[2]; + fcc[2]=t; +} + +bool WDTFile::Load(std::string fn) +{ + std::fstream fh; + fh.open(fn.c_str(),std::ios_base::in | std::ios_base::binary); + if(!fh.is_open()) + return false; + uint32 fs = GetFileSize(fn.c_str()); + ByteBuffer bb(fs); + bb.resize(fs); + fh.read((char*)bb.contents(),fs); + fh.close(); + bb.rpos(0); + return LoadMem(bb); +} + +bool WDTFile::LoadMem(ByteBuffer& buf) +{ + uint8 *fourcc = new uint8[5]; + fourcc[4] = 0; + uint32 size; + + while(buf.rpos() < buf.size()) + { + buf.read(fourcc,4); flipcc(fourcc); + buf >> size; + + if(!strcmp((char*)fourcc,"MVER")) + { + _mver = buf.read(); + } + else if(!strcmp((char*)fourcc,"MPHD")) + { + _mphd = buf.read(); + } + else if(!strcmp((char*)fourcc,"MAIN")) + { + _main = buf.read(); + } + else if(!strcmp((char*)fourcc,"MWMO")) + { + if(size) + { + DEBUG(printf("WDTFile::LoadMem() abort load, MWMO block isnt empty\n")); + break; + } + } + else if(!strcmp((char*)fourcc,"MODF")) + { + DEBUG(printf("WDTFile::LoadMem() abort load, MODF block exists\n")); + break; + } + } + delete [] fourcc; + return true; +} + +void WDTFile::_DebugDump(void) +{ + std::string out; + for(uint32 i=0; i<64; i++) + { + for(uint32 j=0; j<64; j++) + { + out += (_main.tiles[i*64+j] ? "1" : "0"); + } + out += "\n"; + } + printf("WDT DEBUG DUMP, 64x64 TILES:\n"); + printf(out.c_str()); +} + diff --git a/src/shared/WDTFile.h b/src/shared/WDTFile.h index 20bdb06..7484013 100644 --- a/src/shared/WDTFile.h +++ b/src/shared/WDTFile.h @@ -1,43 +1,43 @@ -#ifndef WDTFILE_H -#define WDTFILE_H - -struct WDT_MVER_Chunk -{ - uint32 ver; -}; - -struct WDT_MPHD_Chunk -{ - uint32 noTerrain; - uint32 unk2; - uint32 unk3; - uint32 unk4; - uint32 unk5; - uint32 unk6; - uint32 unk7; - uint32 unk8; -}; - -struct WDT_MAIN_Chunk -{ - uint64 tiles[4096]; //64x64 -}; - - -class WDTFile -{ -public: - bool Load(std::string); - bool LoadMem(ByteBuffer&); - void _DebugDump(void); - WDT_MVER_Chunk _mver; - WDT_MPHD_Chunk _mphd; - WDT_MAIN_Chunk _main; - // TODO: implement support for MWMO & MODF chunks (see ADT) -}; - - - - - -#endif +#ifndef WDTFILE_H +#define WDTFILE_H + +struct WDT_MVER_Chunk +{ + uint32 ver; +}; + +struct WDT_MPHD_Chunk +{ + uint32 noTerrain; + uint32 unk2; + uint32 unk3; + uint32 unk4; + uint32 unk5; + uint32 unk6; + uint32 unk7; + uint32 unk8; +}; + +struct WDT_MAIN_Chunk +{ + uint64 tiles[4096]; //64x64 +}; + + +class WDTFile +{ +public: + bool Load(std::string); + bool LoadMem(ByteBuffer&); + void _DebugDump(void); + WDT_MVER_Chunk _mver; + WDT_MPHD_Chunk _mphd; + WDT_MAIN_Chunk _main; + // TODO: implement support for MWMO & MODF chunks (see ADT) +}; + + + + + +#endif diff --git a/src/shared/Widen.h b/src/shared/Widen.h index 52ccf19..ef96fb1 100644 --- a/src/shared/Widen.h +++ b/src/shared/Widen.h @@ -1,45 +1,45 @@ -#ifndef _WIDEN_H -#define _WIDEN_H - -#include -#include -#include -#include -#include - -// Put this class in your personal toolbox... -template, -class A = std::allocator > - -class Widen : public std::unary_function< - const std::string&, std::basic_string > -{ - std::locale loc_; - const std::ctype* pCType_; - - // No copy-constructor, no assignment operator... - Widen(const Widen&); - Widen& operator= (const Widen&); - -public: - // Constructor... - Widen(const std::locale& loc = std::locale()) : loc_(loc) - { - pCType_ = &std::use_facet >(loc); - } - - // Conversion... - std::basic_string operator() (const std::string& str) const - { - typename std::basic_string::size_type srcLen = - str.length(); - const char* pSrcBeg = str.c_str(); - std::vector tmp(srcLen); - - pCType_->widen(pSrcBeg, pSrcBeg + srcLen, &tmp[0]); - return std::basic_string(&tmp[0], srcLen); - } -}; - -#endif +#ifndef _WIDEN_H +#define _WIDEN_H + +#include +#include +#include +#include +#include + +// Put this class in your personal toolbox... +template, +class A = std::allocator > + +class Widen : public std::unary_function< + const std::string&, std::basic_string > +{ + std::locale loc_; + const std::ctype* pCType_; + + // No copy-constructor, no assignment operator... + Widen(const Widen&); + Widen& operator= (const Widen&); + +public: + // Constructor... + Widen(const std::locale& loc = std::locale()) : loc_(loc) + { + pCType_ = &std::use_facet >(loc); + } + + // Conversion... + std::basic_string operator() (const std::string& str) const + { + typename std::basic_string::size_type srcLen = + str.length(); + const char* pSrcBeg = str.c_str(); + std::vector tmp(srcLen); + + pCType_->widen(pSrcBeg, pSrcBeg + srcLen, &tmp[0]); + return std::basic_string(&tmp[0], srcLen); + } +}; + +#endif diff --git a/src/shared/common.h b/src/shared/common.h index d783a03..a20f001 100644 --- a/src/shared/common.h +++ b/src/shared/common.h @@ -1,42 +1,42 @@ -#ifndef _COMMON_H -#define _COMMON_H - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef _COMMON_SKIP_THREADS -# include "zthread/FastMutex.h" -# include "zthread/LockedQueue.h" -# include "zthread/Runnable.h" -# include "zthread/Thread.h" -#endif - -#define STRINGIZE(a) #a - -#include "SysDefs.h" -#include "DebugStuff.h" -#include "Widen.h" -#include "tools.h" -#include "log.h" - -#include "ByteBuffer.h" - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - - -#endif - +#ifndef _COMMON_H +#define _COMMON_H + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef _COMMON_SKIP_THREADS +# include "zthread/FastMutex.h" +# include "zthread/LockedQueue.h" +# include "zthread/Runnable.h" +# include "zthread/Thread.h" +#endif + +#define STRINGIZE(a) #a + +#include "SysDefs.h" +#include "DebugStuff.h" +#include "Widen.h" +#include "tools.h" +#include "log.h" + +#include "ByteBuffer.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + + +#endif + diff --git a/src/shared/log.cpp b/src/shared/log.cpp index 2b9fed8..da82d43 100644 --- a/src/shared/log.cpp +++ b/src/shared/log.cpp @@ -1,292 +1,292 @@ -#include -#include "common.h" -#include "log.h" - -#if PLATFORM == PLATFORM_WIN32 -#include -#endif - -FILE *logfile=NULL; -uint8 loglevel=0; - - -void log_prepare(char *fn, char *mode = NULL) -{ - if(!mode) - mode = "a"; - if(logfile) - { - fflush(logfile); - fclose(logfile); - } - logfile = fopen(fn,mode); -} - -void log_setloglevel(uint8 lvl) -{ - loglevel = lvl; -} - -void log(const char *str, ...) -{ - if(!str) - return; - va_list ap; - _log_setcolor(true,GREY); - va_start(ap, str); - vprintf( str, ap ); - va_end(ap); - _log_resetcolor(true); - - printf("\n"); - - if(logfile) - { - fprintf(logfile, getDateString().c_str()); - va_start(ap, str); - vfprintf(logfile, str, ap); - fprintf(logfile, "\n" ); - va_end(ap); - fflush(logfile); - } - fflush(stdout); -} - -void logdetail(const char *str, ...) -{ - if(!str || loglevel < 1) - return; - va_list ap; - _log_setcolor(true,LCYAN); - va_start(ap, str); - vprintf( str, ap ); - va_end(ap); - _log_resetcolor(true); - - printf("\n"); - - if(logfile) - { - fprintf(logfile, getDateString().c_str()); - va_start(ap, str); - vfprintf(logfile, str, ap); - fprintf(logfile, "\n" ); - va_end(ap); - fflush(logfile); - } - fflush(stdout); -} - -void logdebug(const char *str, ...) -{ - if(!str || loglevel < 2) - return; - va_list ap; - _log_setcolor(true,LBLUE); - va_start(ap, str); - vprintf( str, ap ); - va_end(ap); - _log_resetcolor(true); - - - printf("\n"); - - if(logfile) - { - fprintf(logfile, getDateString().c_str()); - va_start(ap, str); - vfprintf(logfile, str, ap); - fprintf(logfile, "\n" ); - va_end(ap); - fflush(logfile); - } - fflush(stdout); -} - -void logdev(const char *str, ...) -{ - if(!str || loglevel < 3) - return; - va_list ap; - _log_setcolor(true,LMAGENTA); - va_start(ap, str); - vprintf( str, ap ); - va_end(ap); - _log_resetcolor(true); - - - printf("\n"); - - if(logfile) - { - fprintf(logfile, getDateString().c_str()); - va_start(ap, str); - vfprintf(logfile, str, ap); - fprintf(logfile, "\n" ); - va_end(ap); - fflush(logfile); - } - fflush(stdout); -} - -void logerror(const char *str, ...) -{ - va_list ap; - _log_setcolor(false,LRED); - va_start(ap, str); - vfprintf( stderr, str, ap ); - va_end(ap); - _log_resetcolor(false); - - fprintf(stderr,"\n"); - - if(logfile) - { - fprintf(logfile, getDateString().c_str()); - va_start(ap, str); - vfprintf(logfile, str, ap); - fprintf(logfile, "\n" ); - va_end(ap); - fflush(logfile); - } - fflush(stdout); -} - -void logcritical(const char *str, ...) -{ - va_list ap; - _log_setcolor(false,RED); - va_start(ap, str); - vfprintf( stderr, str, ap ); - va_end(ap); - _log_resetcolor(false); - - fprintf(stderr,"\n"); - - if(logfile) - { - fprintf(logfile, getDateString().c_str()); - va_start(ap, str); - vfprintf(logfile, str, ap); - fprintf(logfile, "\n" ); - va_end(ap); - fflush(logfile); - } - fflush(stdout); -} - -void logcustom(uint8 lvl, Color color, const char *str, ...) -{ - if(!str || loglevel < lvl) - return; - va_list ap; - _log_setcolor(true,color); - va_start(ap, str); - vprintf( str, ap ); - va_end(ap); - _log_resetcolor(true); - - printf("\n"); - - if(logfile) - { - fprintf(logfile, getDateString().c_str()); - va_start(ap, str); - vfprintf(logfile, str, ap); - fprintf(logfile, "\n" ); - va_end(ap); - fflush(logfile); - } - fflush(stdout); -} - -void log_close() -{ - fclose(logfile); -} - -void _log_setcolor(bool stdout_stream, Color color) -{ -#if PLATFORM == PLATFORM_WIN32 - - static WORD WinColorFG[Color_count] = - { - 0, // BLACK - FOREGROUND_RED, // RED - FOREGROUND_GREEN, // GREEN - FOREGROUND_RED | FOREGROUND_GREEN, // BROWN - FOREGROUND_BLUE, // BLUE - FOREGROUND_RED | FOREGROUND_BLUE,// MAGENTA - FOREGROUND_GREEN | FOREGROUND_BLUE, // CYAN - FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,// WHITE - // YELLOW - FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY, - // RED_BOLD - FOREGROUND_RED | FOREGROUND_INTENSITY, - // GREEN_BOLD - FOREGROUND_GREEN | FOREGROUND_INTENSITY, - FOREGROUND_BLUE | FOREGROUND_INTENSITY, // BLUE_BOLD - // MAGENTA_BOLD - FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY, - // CYAN_BOLD - FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY, - // WHITE_BOLD - FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY - }; - - HANDLE hConsole = GetStdHandle(stdout_stream ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE ); - SetConsoleTextAttribute(hConsole, WinColorFG[color]); -#else - - enum ANSITextAttr - { - TA_NORMAL=0, - TA_BOLD=1, - TA_BLINK=5, - TA_REVERSE=7 - }; - - enum ANSIFgTextAttr - { - FG_BLACK=30, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE, - FG_MAGENTA, FG_CYAN, FG_WHITE, FG_YELLOW - }; - - enum ANSIBgTextAttr - { - BG_BLACK=40, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE, - BG_MAGENTA, BG_CYAN, BG_WHITE - }; - - static uint8 UnixColorFG[Color_count] = - { - FG_BLACK, // BLACK - FG_RED, // RED - FG_GREEN, // GREEN - FG_BROWN, // BROWN - FG_BLUE, // BLUE - FG_MAGENTA, // MAGENTA - FG_CYAN, // CYAN - FG_WHITE, // WHITE - FG_YELLOW, // YELLOW - FG_RED, // LRED - FG_GREEN, // LGREEN - FG_BLUE, // LBLUE - FG_MAGENTA, // LMAGENTA - FG_CYAN, // LCYAN - FG_WHITE // LWHITE - }; - - fprintf((stdout_stream? stdout : stderr), "\x1b[%d%sm",UnixColorFG[color],(color>=YELLOW&&color +#include "common.h" +#include "log.h" + +#if PLATFORM == PLATFORM_WIN32 +#include +#endif + +FILE *logfile=NULL; +uint8 loglevel=0; + + +void log_prepare(char *fn, char *mode = NULL) +{ + if(!mode) + mode = "a"; + if(logfile) + { + fflush(logfile); + fclose(logfile); + } + logfile = fopen(fn,mode); +} + +void log_setloglevel(uint8 lvl) +{ + loglevel = lvl; +} + +void log(const char *str, ...) +{ + if(!str) + return; + va_list ap; + _log_setcolor(true,GREY); + va_start(ap, str); + vprintf( str, ap ); + va_end(ap); + _log_resetcolor(true); + + printf("\n"); + + if(logfile) + { + fprintf(logfile, getDateString().c_str()); + va_start(ap, str); + vfprintf(logfile, str, ap); + fprintf(logfile, "\n" ); + va_end(ap); + fflush(logfile); + } + fflush(stdout); +} + +void logdetail(const char *str, ...) +{ + if(!str || loglevel < 1) + return; + va_list ap; + _log_setcolor(true,LCYAN); + va_start(ap, str); + vprintf( str, ap ); + va_end(ap); + _log_resetcolor(true); + + printf("\n"); + + if(logfile) + { + fprintf(logfile, getDateString().c_str()); + va_start(ap, str); + vfprintf(logfile, str, ap); + fprintf(logfile, "\n" ); + va_end(ap); + fflush(logfile); + } + fflush(stdout); +} + +void logdebug(const char *str, ...) +{ + if(!str || loglevel < 2) + return; + va_list ap; + _log_setcolor(true,LBLUE); + va_start(ap, str); + vprintf( str, ap ); + va_end(ap); + _log_resetcolor(true); + + + printf("\n"); + + if(logfile) + { + fprintf(logfile, getDateString().c_str()); + va_start(ap, str); + vfprintf(logfile, str, ap); + fprintf(logfile, "\n" ); + va_end(ap); + fflush(logfile); + } + fflush(stdout); +} + +void logdev(const char *str, ...) +{ + if(!str || loglevel < 3) + return; + va_list ap; + _log_setcolor(true,LMAGENTA); + va_start(ap, str); + vprintf( str, ap ); + va_end(ap); + _log_resetcolor(true); + + + printf("\n"); + + if(logfile) + { + fprintf(logfile, getDateString().c_str()); + va_start(ap, str); + vfprintf(logfile, str, ap); + fprintf(logfile, "\n" ); + va_end(ap); + fflush(logfile); + } + fflush(stdout); +} + +void logerror(const char *str, ...) +{ + va_list ap; + _log_setcolor(false,LRED); + va_start(ap, str); + vfprintf( stderr, str, ap ); + va_end(ap); + _log_resetcolor(false); + + fprintf(stderr,"\n"); + + if(logfile) + { + fprintf(logfile, getDateString().c_str()); + va_start(ap, str); + vfprintf(logfile, str, ap); + fprintf(logfile, "\n" ); + va_end(ap); + fflush(logfile); + } + fflush(stdout); +} + +void logcritical(const char *str, ...) +{ + va_list ap; + _log_setcolor(false,RED); + va_start(ap, str); + vfprintf( stderr, str, ap ); + va_end(ap); + _log_resetcolor(false); + + fprintf(stderr,"\n"); + + if(logfile) + { + fprintf(logfile, getDateString().c_str()); + va_start(ap, str); + vfprintf(logfile, str, ap); + fprintf(logfile, "\n" ); + va_end(ap); + fflush(logfile); + } + fflush(stdout); +} + +void logcustom(uint8 lvl, Color color, const char *str, ...) +{ + if(!str || loglevel < lvl) + return; + va_list ap; + _log_setcolor(true,color); + va_start(ap, str); + vprintf( str, ap ); + va_end(ap); + _log_resetcolor(true); + + printf("\n"); + + if(logfile) + { + fprintf(logfile, getDateString().c_str()); + va_start(ap, str); + vfprintf(logfile, str, ap); + fprintf(logfile, "\n" ); + va_end(ap); + fflush(logfile); + } + fflush(stdout); +} + +void log_close() +{ + fclose(logfile); +} + +void _log_setcolor(bool stdout_stream, Color color) +{ +#if PLATFORM == PLATFORM_WIN32 + + static WORD WinColorFG[Color_count] = + { + 0, // BLACK + FOREGROUND_RED, // RED + FOREGROUND_GREEN, // GREEN + FOREGROUND_RED | FOREGROUND_GREEN, // BROWN + FOREGROUND_BLUE, // BLUE + FOREGROUND_RED | FOREGROUND_BLUE,// MAGENTA + FOREGROUND_GREEN | FOREGROUND_BLUE, // CYAN + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,// WHITE + // YELLOW + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY, + // RED_BOLD + FOREGROUND_RED | FOREGROUND_INTENSITY, + // GREEN_BOLD + FOREGROUND_GREEN | FOREGROUND_INTENSITY, + FOREGROUND_BLUE | FOREGROUND_INTENSITY, // BLUE_BOLD + // MAGENTA_BOLD + FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY, + // CYAN_BOLD + FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY, + // WHITE_BOLD + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY + }; + + HANDLE hConsole = GetStdHandle(stdout_stream ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE ); + SetConsoleTextAttribute(hConsole, WinColorFG[color]); +#else + + enum ANSITextAttr + { + TA_NORMAL=0, + TA_BOLD=1, + TA_BLINK=5, + TA_REVERSE=7 + }; + + enum ANSIFgTextAttr + { + FG_BLACK=30, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE, + FG_MAGENTA, FG_CYAN, FG_WHITE, FG_YELLOW + }; + + enum ANSIBgTextAttr + { + BG_BLACK=40, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE, + BG_MAGENTA, BG_CYAN, BG_WHITE + }; + + static uint8 UnixColorFG[Color_count] = + { + FG_BLACK, // BLACK + FG_RED, // RED + FG_GREEN, // GREEN + FG_BROWN, // BROWN + FG_BLUE, // BLUE + FG_MAGENTA, // MAGENTA + FG_CYAN, // CYAN + FG_WHITE, // WHITE + FG_YELLOW, // YELLOW + FG_RED, // LRED + FG_GREEN, // LGREEN + FG_BLUE, // LBLUE + FG_MAGENTA, // LMAGENTA + FG_CYAN, // LCYAN + FG_WHITE // LWHITE + }; + + fprintf((stdout_stream? stdout : stderr), "\x1b[%d%sm",UnixColorFG[color],(color>=YELLOW&&color GetFileList(std::string); -bool FileExists(std::string); -bool CreateDir(const char*); -uint32 getMSTime(void); -uint32 GetFileSize(const char*); -void _FixFileName(std::string&); -std::string _PathToFileName(std::string); - -#endif +#ifndef _TOOLS_H +#define _TOOLS_H + +#include "common.h" + +#define M_SETBIT(var,bit) ( (var)|=(1<<(bit)) ) +#define M_UNSETBIT(var,bit) ( (var)&=(~(1<<(bit))) ) +#define M_HASBIT(var,bit) ( (var)&(1<<(bit)) ) + +void printchex(std::string,bool); +void printchex(char *in, uint32 len, bool); +std::string stringToUpper(std::string); +std::string stringToLower(std::string); +std::string toString(uint64); +std::string getDateString(void); +uint64 toInt(std::string); +std::string toHexDump(uint8* array,uint32 size,bool spaces=true); +std::deque GetFileList(std::string); +bool FileExists(std::string); +bool CreateDir(const char*); +uint32 getMSTime(void); +uint32 GetFileSize(const char*); +void _FixFileName(std::string&); +std::string _PathToFileName(std::string); + +#endif diff --git a/src/shared_VC80.vcproj b/src/shared_VC80.vcproj index 8614d83..0ee2dfc 100644 --- a/src/shared_VC80.vcproj +++ b/src/shared_VC80.vcproj @@ -1,433 +1,433 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/tools/PseuWoWConsole/PseuWoWConsole ReadMe.txt b/src/tools/PseuWoWConsole/PseuWoWConsole ReadMe.txt index bdea331..992e1ce 100644 --- a/src/tools/PseuWoWConsole/PseuWoWConsole ReadMe.txt +++ b/src/tools/PseuWoWConsole/PseuWoWConsole ReadMe.txt @@ -1,45 +1,45 @@ -======================================================= -PseuWoWConsole - Version 2.2.0 -======================================================= -"If at first you don't succeed, sky diving is not for you" - -======================================================= -Greetings from TheTourist -======================================================= - -This app is a wrapper for PseuWow. -What it does is open a port on 8095 on the machine, and anything written to this port will treated as if you inputted it in the console. - -Try this from HyperTerm: -SAY Hello Bitches -to port 8095, your Bot will say -Hello Bitches! - -Thus from code, script or external app you can make calls to your bot. - -======================================================= -Code -======================================================= - -I can't profess to be a trained developer, I am entirely self taught. So any advice or corrections are welcome. Code was written in Delphi 6 with the JEDI VCL suite installed. Feel Free to modify and share as needed. - -This is all released under the GNU General Public License, which you review at: http://www.gnu.org/copyleft/gpl.html -As I feel it's better to share, we all get along better that way. - -======================================================= -Changes -======================================================= -Version 2.0.0 - * Added Nifty Icon Feature - Basically If you run more than one session you now tell which one is which! - * Display of Char Name - * Started Work on reading the colors from input - -Version 2.1.0 - * Fixed a problem due to failed recompile - -Version 2.2.0 - * Redirected Input capture is now Handled in a Thread. Meaning a more responsive output - * Checking for |r in sysmessages, if |r is not found then don't clear our buffer - * There is a Check Box for Clean Up - which basically toggles all text post formatting. If you're - having problem disable it. Else it will highlight in a very pretty manner! +======================================================= +PseuWoWConsole - Version 2.2.0 +======================================================= +"If at first you don't succeed, sky diving is not for you" + +======================================================= +Greetings from TheTourist +======================================================= + +This app is a wrapper for PseuWow. +What it does is open a port on 8095 on the machine, and anything written to this port will treated as if you inputted it in the console. + +Try this from HyperTerm: +SAY Hello Bitches +to port 8095, your Bot will say +Hello Bitches! + +Thus from code, script or external app you can make calls to your bot. + +======================================================= +Code +======================================================= + +I can't profess to be a trained developer, I am entirely self taught. So any advice or corrections are welcome. Code was written in Delphi 6 with the JEDI VCL suite installed. Feel Free to modify and share as needed. + +This is all released under the GNU General Public License, which you review at: http://www.gnu.org/copyleft/gpl.html +As I feel it's better to share, we all get along better that way. + +======================================================= +Changes +======================================================= +Version 2.0.0 + * Added Nifty Icon Feature - Basically If you run more than one session you now tell which one is which! + * Display of Char Name + * Started Work on reading the colors from input + +Version 2.1.0 + * Fixed a problem due to failed recompile + +Version 2.2.0 + * Redirected Input capture is now Handled in a Thread. Meaning a more responsive output + * Checking for |r in sysmessages, if |r is not found then don't clear our buffer + * There is a Check Box for Clean Up - which basically toggles all text post formatting. If you're + having problem disable it. Else it will highlight in a very pretty manner! * Started Adding Colour Coding for .lookup* MaNGOS commands \ No newline at end of file diff --git a/src/tools/PseuWoWConsole/src/PseuWoWConsole.cfg b/src/tools/PseuWoWConsole/src/PseuWoWConsole.cfg index fb2c17e..4e1c601 100644 --- a/src/tools/PseuWoWConsole/src/PseuWoWConsole.cfg +++ b/src/tools/PseuWoWConsole/src/PseuWoWConsole.cfg @@ -1,41 +1,41 @@ --$A8 --$B- --$C+ --$D+ --$E- --$F- --$G+ --$H+ --$I+ --$J+ --$K- --$L+ --$M- --$N+ --$O+ --$P+ --$Q- --$R- --$S- --$T- --$U- --$V+ --$W- --$X+ --$YD --$Z1 --GD --cg --AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; --H+ --W+ --M --$M16384,1048576 --K$00400000 --E"M:\Mangos\PseudoWoWGM" --LE"c:\program files\borland\delphi6\Projects\Bpl" --LN"c:\program files\borland\delphi6\Projects\Bpl" --U"E:\Coding\Delphi\rutinas\fastlib" --O"E:\Coding\Delphi\rutinas\fastlib" --I"E:\Coding\Delphi\rutinas\fastlib" --R"E:\Coding\Delphi\rutinas\fastlib" +-$A8 +-$B- +-$C+ +-$D+ +-$E- +-$F- +-$G+ +-$H+ +-$I+ +-$J+ +-$K- +-$L+ +-$M- +-$N+ +-$O+ +-$P+ +-$Q- +-$R- +-$S- +-$T- +-$U- +-$V+ +-$W- +-$X+ +-$YD +-$Z1 +-GD +-cg +-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; +-H+ +-W+ +-M +-$M16384,1048576 +-K$00400000 +-E"M:\Mangos\PseudoWoWGM" +-LE"c:\program files\borland\delphi6\Projects\Bpl" +-LN"c:\program files\borland\delphi6\Projects\Bpl" +-U"E:\Coding\Delphi\rutinas\fastlib" +-O"E:\Coding\Delphi\rutinas\fastlib" +-I"E:\Coding\Delphi\rutinas\fastlib" +-R"E:\Coding\Delphi\rutinas\fastlib" diff --git a/src/tools/PseuWoWConsole/src/PseuWoWConsole.dof b/src/tools/PseuWoWConsole/src/PseuWoWConsole.dof index 4aa3d91..4f3bf27 100644 --- a/src/tools/PseuWoWConsole/src/PseuWoWConsole.dof +++ b/src/tools/PseuWoWConsole/src/PseuWoWConsole.dof @@ -1,583 +1,583 @@ -[FileVersion] -Version=6.0 -[Compiler] -A=8 -B=0 -C=1 -D=1 -E=0 -F=0 -G=1 -H=1 -I=1 -J=1 -K=0 -L=1 -M=0 -N=1 -O=1 -P=1 -Q=0 -R=0 -S=0 -T=0 -U=0 -V=1 -W=0 -X=1 -Y=1 -Z=1 -ShowHints=1 -ShowWarnings=1 -UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; -[Linker] -MapFile=3 -OutputObjs=0 -ConsoleApp=1 -DebugInfo=0 -RemoteSymbols=0 -MinStackSize=16384 -MaxStackSize=1048576 -ImageBase=4194304 -ExeDescription= -[Directories] -OutputDir=M:\Mangos\PseudoWoWGM -UnitOutputDir= -PackageDLLOutputDir= -PackageDCPOutputDir= -SearchPath=E:\Coding\Delphi\rutinas\fastlib -Packages=Vcl50;Vclx50;VclSmp50;Vcldb50;vclado50;ibevnt50;Vclbde50;vcldbx50;Qrpt50;TeeUI50;TeeDB50;Tee50;Dss50;TeeQR50;VCLIB50;Vclmid50;vclie50;Inetdb50;Inet50;NMFast50;webmid50;dclocx50;dclaxserver50 -Conditionals= -DebugSourceDirs= -UsePackages=0 -[Parameters] -RunParams= -HostApplication= -Launcher= -UseLauncher=0 -DebugCWD= -[Language] -ActiveLang= -ProjectLang=$00000C0A -RootDir= -[Version Info] -IncludeVerInfo=1 -AutoIncBuild=0 -MajorVer=2 -MinorVer=2 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=3082 -CodePage=1252 -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=2.2.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= -[Excluded Packages] -c:\program files\borland\delphi6\Projects\Bpl\ThirdParty2000.bpl=3rd Party Components -c:\program files\borland\delphi6\Projects\Bpl\SweetControls6.bpl=CA SweetControls -[HistoryLists\hlUnitAliases] -Count=1 -Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; -[HistoryLists\hlSearchPath] -Count=1 -Item0=E:\Coding\Delphi\rutinas\fastlib -[HistoryLists\hlOutputDirectorry] -Count=2 -Item0=M:\Mangos\PseudoWoWGM -Item1=F:\ttWoWEmu\pseuwow\ -[Exception Log] -EurekaLog Version=6003 -Activate=0 -Activate Handle=1 -Save Log File=1 -Foreground Tab=0 -Freeze Activate=0 -Freeze Timeout=0 -SMTP From=eurekalog@email.com -SMTP Host= -SMTP Port=25 -SMTP UserID= -SMTP Password= -Append to Log=0 -TerminateBtn Operation=2 -Errors Number=32 -Errors Terminate=3 -Email Address= -Email Object= -Email Send Options=0 -Output Path= -Encrypt Password= -AutoCloseDialogSecs=0 -WebSendMode=0 -SupportULR= -HTMLLayout Count=15 -HTMLLine0="%3Chtml%3E" -HTMLLine1=" %3Chead%3E" -HTMLLine2=" %3C/head%3E" -HTMLLine3=" %3Cbody TopMargin=10 LeftMargin=10%3E" -HTMLLine4=" %3Ctable width="100%%" border="0"%3E" -HTMLLine5=" %3Ctr%3E" -HTMLLine6=" %3Ctd nowrap%3E" -HTMLLine7=" %3Cfont face="Lucida Console, Courier" size="2"%3E" -HTMLLine8=" %3C%%HTML_TAG%%%3E" -HTMLLine9=" %3C/font%3E" -HTMLLine10=" %3C/td%3E" -HTMLLine11=" %3C/tr%3E" -HTMLLine12=" %3C/table%3E" -HTMLLine13=" %3C/body%3E" -HTMLLine14="%3C/html%3E" -AutoCrashOperation=2 -AutoCrashNumber=10 -AutoCrashMinutes=1 -WebURL= -WebUserID= -WebPassword= -WebPort=0 -AttachedFiles= -ProxyURL= -ProxyUser= -ProxyPassword= -ProxyPort=8080 -TrakerUser= -TrakerPassword= -TrakerAssignTo= -TrakerProject= -TrakerCategory= -TrakerTrialID= -ZipPassword= -PreBuildEvent= -PostSuccessfulBuildEvent= -PostFailureBuildEvent= -ExceptionDialogType=2 -Count=0 -EMail Message Line Count=0 -loNoDuplicateErrors=0 -loAppendReproduceText=0 -loDeleteLogAtVersionChange=0 -loAddComputerNameInLogFileName=0 -loSaveModulesAndProcessesSections=1 -loSaveAssemblerAndCPUSections=1 -soAppStartDate=1 -soAppName=1 -soAppVersionNumber=1 -soAppParameters=1 -soAppCompilationDate=1 -soAppUpTime=1 -soExcDate=1 -soExcAddress=1 -soExcModuleName=1 -soExcModuleVersion=1 -soExcType=1 -soExcMessage=1 -soExcID=1 -soExcCount=1 -soExcStatus=1 -soExcNote=1 -soUserID=1 -soUserName=1 -soUserEmail=1 -soUserPrivileges=1 -soUserCompany=1 -soActCtlsFormClass=1 -soActCtlsFormText=1 -soActCtlsControlClass=1 -soActCtlsControlText=1 -soCmpName=1 -soCmpTotalMemory=1 -soCmpFreeMemory=1 -soCmpTotalDisk=1 -soCmpFreeDisk=1 -soCmpSysUpTime=1 -soCmpProcessor=1 -soCmpDisplayMode=1 -soCmpDisplayDPI=1 -soCmpVideoCard=1 -soCmpPrinter=1 -soOSType=1 -soOSBuildN=1 -soOSUpdate=1 -soOSLanguage=1 -soOSCharset=1 -soNetIP=1 -soNetSubmask=1 -soNetGateway=1 -soNetDNS1=1 -soNetDNS2=1 -soNetDHCP=1 -soCustomData=1 -sndShowSendDialog=1 -sndShowSuccessFailureMsg=0 -sndSendEntireLog=0 -sndSendXMLLogCopy=0 -sndSendScreenshot=1 -sndUseOnlyActiveWindow=0 -sndSendLastHTMLPage=1 -sndSendInSeparatedThread=0 -sndAddDateInFileName=0 -sndAddComputerNameInFileName=0 -edoSendErrorReportChecked=1 -edoAttachScreenshotChecked=1 -edoShowCopyToClipOption=1 -edoShowDetailsButton=1 -edoShowInDetailedMode=0 -edoShowInTopMostMode=0 -edoUseEurekaLogLookAndFeel=0 -edoShowSendErrorReportOption=1 -edoShowAttachScreenshotOption=1 -edoShowCustomButton=0 -csoShowDLLs=1 -csoShowBPLs=1 -csoShowBorlandThreads=1 -csoShowWindowsThreads=1 -csoDoNotStoreProcNames=0 -boPauseBorlandThreads=0 -boDoNotPauseMainThread=0 -boPauseWindowsThreads=0 -boUseMainModuleOptions=1 -boCopyLogInCaseOfError=1 -boSaveCompressedCopyInCaseOfError=0 -boHandleSafeCallExceptions=0 -boCallRTLExceptionEvent=0 -boCatchHandledExceptions=0 -loCatchLeaks=0 -loGroupsSonLeaks=1 -loHideBorlandLeaks=1 -loFreeAllLeaks=1 -loCatchLeaksExceptions=1 -cfoReduceFileSize=1 -cfoCheckFileCorruption=0 -Count mtInformationMsgCaption=1 -mtInformationMsgCaption0="Information." -Count mtQuestionMsgCaption=1 -mtQuestionMsgCaption0="Question." -Count mtErrorMsgCaption=1 -mtErrorMsgCaption0="Error." -Count mtDialog_Caption=1 -mtDialog_Caption0="Error occurred" -Count mtDialog_ErrorMsgCaption=2 -mtDialog_ErrorMsgCaption0="An error has occurred during program execution." -mtDialog_ErrorMsgCaption1="Please read the following information for further details." -Count mtDialog_GeneralCaption=1 -mtDialog_GeneralCaption0="General" -Count mtDialog_GeneralHeader=1 -mtDialog_GeneralHeader0="General Information" -Count mtDialog_CallStackCaption=1 -mtDialog_CallStackCaption0="Call Stack" -Count mtDialog_CallStackHeader=1 -mtDialog_CallStackHeader0="Call Stack Information" -Count mtDialog_ModulesCaption=1 -mtDialog_ModulesCaption0="Modules" -Count mtDialog_ModulesHeader=1 -mtDialog_ModulesHeader0="Modules Information" -Count mtDialog_ProcessesCaption=1 -mtDialog_ProcessesCaption0="Processes" -Count mtDialog_ProcessesHeader=1 -mtDialog_ProcessesHeader0="Processes Information" -Count mtDialog_AsmCaption=1 -mtDialog_AsmCaption0="Assembler" -Count mtDialog_AsmHeader=1 -mtDialog_AsmHeader0="Assembler Information" -Count mtDialog_CPUCaption=1 -mtDialog_CPUCaption0="CPU" -Count mtDialog_CPUHeader=1 -mtDialog_CPUHeader0="CPU Information" -Count mtDialog_OKButtonCaption=1 -mtDialog_OKButtonCaption0="%26OK" -Count mtDialog_TerminateButtonCaption=1 -mtDialog_TerminateButtonCaption0="%26Terminate" -Count mtDialog_RestartButtonCaption=1 -mtDialog_RestartButtonCaption0="%26Restart" -Count mtDialog_DetailsButtonCaption=1 -mtDialog_DetailsButtonCaption0="%26Details" -Count mtDialog_CustomButtonCaption=1 -mtDialog_CustomButtonCaption0="%26Help" -Count mtDialog_SendMessage=1 -mtDialog_SendMessage0="%26Send this error via Internet" -Count mtDialog_ScreenshotMessage=1 -mtDialog_ScreenshotMessage0="%26Attach a Screenshot image" -Count mtDialog_CopyMessage=1 -mtDialog_CopyMessage0="%26Copy to Clipboard" -Count mtDialog_SupportMessage=1 -mtDialog_SupportMessage0="Go to the Support Page" -Count mtMSDialog_ErrorMsgCaption=1 -mtMSDialog_ErrorMsgCaption0="The application has encountered a problem. We are sorry for the inconvenience." -Count mtMSDialog_RestartCaption=1 -mtMSDialog_RestartCaption0="Restart application." -Count mtMSDialog_TerminateCaption=1 -mtMSDialog_TerminateCaption0="Terminate application." -Count mtMSDialog_PleaseCaption=1 -mtMSDialog_PleaseCaption0="Please tell us about this problem." -Count mtMSDialog_DescriptionCaption=1 -mtMSDialog_DescriptionCaption0="We have created an error report that you can send to us. We will treat this report as confidential and anonymous." -Count mtMSDialog_SeeDetailsCaption=1 -mtMSDialog_SeeDetailsCaption0="To see what data the error report contains," -Count mtMSDialog_SeeClickCaption=1 -mtMSDialog_SeeClickCaption0="click here." -Count mtMSDialog_HowToReproduceCaption=1 -mtMSDialog_HowToReproduceCaption0="What were you doing when the problem happended (optional)?" -Count mtMSDialog_EmailCaption=1 -mtMSDialog_EmailCaption0="Email address (optional):" -Count mtMSDialog_SendButtonCaption=1 -mtMSDialog_SendButtonCaption0="%26Send Error Report" -Count mtMSDialog_NoSendButtonCaption=1 -mtMSDialog_NoSendButtonCaption0="%26Don't Send" -Count mtLog_AppHeader=1 -mtLog_AppHeader0="Application" -Count mtLog_AppStartDate=1 -mtLog_AppStartDate0="Start Date" -Count mtLog_AppName=1 -mtLog_AppName0="Name/Description" -Count mtLog_AppVersionNumber=1 -mtLog_AppVersionNumber0="Version Number" -Count mtLog_AppParameters=1 -mtLog_AppParameters0="Parameters" -Count mtLog_AppCompilationDate=1 -mtLog_AppCompilationDate0="Compilation Date" -Count mtLog_AppUpTime=1 -mtLog_AppUpTime0="Up Time" -Count mtLog_ExcHeader=1 -mtLog_ExcHeader0="Exception" -Count mtLog_ExcDate=1 -mtLog_ExcDate0="Date" -Count mtLog_ExcAddress=1 -mtLog_ExcAddress0="Address" -Count mtLog_ExcModuleName=1 -mtLog_ExcModuleName0="Module Name" -Count mtLog_ExcModuleVersion=1 -mtLog_ExcModuleVersion0="Module Version" -Count mtLog_ExcType=1 -mtLog_ExcType0="Type" -Count mtLog_ExcMessage=1 -mtLog_ExcMessage0="Message" -Count mtLog_ExcID=1 -mtLog_ExcID0="ID" -Count mtLog_ExcCount=1 -mtLog_ExcCount0="Count" -Count mtLog_ExcStatus=1 -mtLog_ExcStatus0="Status" -Count mtLog_ExcNote=1 -mtLog_ExcNote0="Note" -Count mtLog_UserHeader=1 -mtLog_UserHeader0="User" -Count mtLog_UserID=1 -mtLog_UserID0="ID" -Count mtLog_UserName=1 -mtLog_UserName0="Name" -Count mtLog_UserEmail=1 -mtLog_UserEmail0="Email" -Count mtLog_UserCompany=1 -mtLog_UserCompany0="Company" -Count mtLog_UserPrivileges=1 -mtLog_UserPrivileges0="Privileges" -Count mtLog_ActCtrlsHeader=1 -mtLog_ActCtrlsHeader0="Active Controls" -Count mtLog_ActCtrlsFormClass=1 -mtLog_ActCtrlsFormClass0="Form Class" -Count mtLog_ActCtrlsFormText=1 -mtLog_ActCtrlsFormText0="Form Text" -Count mtLog_ActCtrlsControlClass=1 -mtLog_ActCtrlsControlClass0="Control Class" -Count mtLog_ActCtrlsControlText=1 -mtLog_ActCtrlsControlText0="Control Text" -Count mtLog_CmpHeader=1 -mtLog_CmpHeader0="Computer" -Count mtLog_CmpName=1 -mtLog_CmpName0="Name" -Count mtLog_CmpTotalMemory=1 -mtLog_CmpTotalMemory0="Total Memory" -Count mtLog_CmpFreeMemory=1 -mtLog_CmpFreeMemory0="Free Memory" -Count mtLog_CmpTotalDisk=1 -mtLog_CmpTotalDisk0="Total Disk" -Count mtLog_CmpFreeDisk=1 -mtLog_CmpFreeDisk0="Free Disk" -Count mtLog_CmpSystemUpTime=1 -mtLog_CmpSystemUpTime0="System Up Time" -Count mtLog_CmpProcessor=1 -mtLog_CmpProcessor0="Processor" -Count mtLog_CmpDisplayMode=1 -mtLog_CmpDisplayMode0="Display Mode" -Count mtLog_CmpDisplayDPI=1 -mtLog_CmpDisplayDPI0="Display DPI" -Count mtLog_CmpVideoCard=1 -mtLog_CmpVideoCard0="Video Card" -Count mtLog_CmpPrinter=1 -mtLog_CmpPrinter0="Printer" -Count mtLog_OSHeader=1 -mtLog_OSHeader0="Operating System" -Count mtLog_OSType=1 -mtLog_OSType0="Type" -Count mtLog_OSBuildN=1 -mtLog_OSBuildN0="Build #" -Count mtLog_OSUpdate=1 -mtLog_OSUpdate0="Update" -Count mtLog_OSLanguage=1 -mtLog_OSLanguage0="Language" -Count mtLog_OSCharset=1 -mtLog_OSCharset0="Charset" -Count mtLog_NetHeader=1 -mtLog_NetHeader0="Network" -Count mtLog_NetIP=1 -mtLog_NetIP0="IP Address" -Count mtLog_NetSubmask=1 -mtLog_NetSubmask0="Submask" -Count mtLog_NetGateway=1 -mtLog_NetGateway0="Gateway" -Count mtLog_NetDNS1=1 -mtLog_NetDNS10="DNS 1" -Count mtLog_NetDNS2=1 -mtLog_NetDNS20="DNS 2" -Count mtLog_NetDHCP=1 -mtLog_NetDHCP0="DHCP" -Count mtLog_CustInfoHeader=1 -mtLog_CustInfoHeader0="Custom Information" -Count mtCallStack_Address=1 -mtCallStack_Address0="Address" -Count mtCallStack_Name=1 -mtCallStack_Name0="Module" -Count mtCallStack_Unit=1 -mtCallStack_Unit0="Unit" -Count mtCallStack_Class=1 -mtCallStack_Class0="Class" -Count mtCallStack_Procedure=1 -mtCallStack_Procedure0="Procedure/Method" -Count mtCallStack_Line=1 -mtCallStack_Line0="Line" -Count mtCallStack_MainThread=1 -mtCallStack_MainThread0="Main" -Count mtCallStack_ExceptionThread=1 -mtCallStack_ExceptionThread0="Exception Thread" -Count mtCallStack_RunningThread=1 -mtCallStack_RunningThread0="Running Thread" -Count mtCallStack_CallingThread=1 -mtCallStack_CallingThread0="Calling Thread" -Count mtCallStack_ThreadID=1 -mtCallStack_ThreadID0="ID" -Count mtCallStack_ThreadPriority=1 -mtCallStack_ThreadPriority0="Priority" -Count mtCallStack_ThreadClass=1 -mtCallStack_ThreadClass0="Class" -Count mtCallStack_LeakCaption=1 -mtCallStack_LeakCaption0="Memory Leak" -Count mtCallStack_LeakData=1 -mtCallStack_LeakData0="Data" -Count mtCallStack_LeakType=1 -mtCallStack_LeakType0="Type" -Count mtCallStack_LeakSize=1 -mtCallStack_LeakSize0="Total size" -Count mtCallStack_LeakCount=1 -mtCallStack_LeakCount0="Count" -Count mtSendDialog_Caption=1 -mtSendDialog_Caption0="Send." -Count mtSendDialog_Message=1 -mtSendDialog_Message0="Message" -Count mtSendDialog_Resolving=1 -mtSendDialog_Resolving0="Resolving DNS..." -Count mtSendDialog_Login=1 -mtSendDialog_Login0="Login..." -Count mtSendDialog_Connecting=1 -mtSendDialog_Connecting0="Connecting with server..." -Count mtSendDialog_Connected=1 -mtSendDialog_Connected0="Connected with server." -Count mtSendDialog_Sending=1 -mtSendDialog_Sending0="Sending message..." -Count mtSendDialog_Sent=1 -mtSendDialog_Sent0="Message sent." -Count mtSendDialog_SelectProject=1 -mtSendDialog_SelectProject0="Select project..." -Count mtSendDialog_Searching=1 -mtSendDialog_Searching0="Searching..." -Count mtSendDialog_Modifying=1 -mtSendDialog_Modifying0="Modifying..." -Count mtSendDialog_Disconnecting=1 -mtSendDialog_Disconnecting0="Disconnecting..." -Count mtSendDialog_Disconnected=1 -mtSendDialog_Disconnected0="Disconnected." -Count mtReproduceDialog_Caption=1 -mtReproduceDialog_Caption0="Request" -Count mtReproduceDialog_Request=1 -mtReproduceDialog_Request0="Please describe the steps to reproduce the error:" -Count mtReproduceDialog_OKButtonCaption=1 -mtReproduceDialog_OKButtonCaption0="%26OK" -Count mtModules_Handle=1 -mtModules_Handle0="Handle" -Count mtModules_Name=1 -mtModules_Name0="Name" -Count mtModules_Description=1 -mtModules_Description0="Description" -Count mtModules_Version=1 -mtModules_Version0="Version" -Count mtModules_Size=1 -mtModules_Size0="Size" -Count mtModules_LastModified=1 -mtModules_LastModified0="Modified" -Count mtModules_Path=1 -mtModules_Path0="Path" -Count mtProcesses_ID=1 -mtProcesses_ID0="ID" -Count mtProcesses_Name=1 -mtProcesses_Name0="Name" -Count mtProcesses_Description=1 -mtProcesses_Description0="Description" -Count mtProcesses_Version=1 -mtProcesses_Version0="Version" -Count mtProcesses_Memory=1 -mtProcesses_Memory0="Memory" -Count mtProcesses_Priority=1 -mtProcesses_Priority0="Priority" -Count mtProcesses_Threads=1 -mtProcesses_Threads0="Threads" -Count mtProcesses_Path=1 -mtProcesses_Path0="Path" -Count mtCPU_Registers=1 -mtCPU_Registers0="Registers" -Count mtCPU_Stack=1 -mtCPU_Stack0="Stack" -Count mtCPU_MemoryDump=1 -mtCPU_MemoryDump0="Memory Dump" -Count mtSend_SuccessMsg=1 -mtSend_SuccessMsg0="The message was sent successfully." -Count mtSend_FailureMsg=1 -mtSend_FailureMsg0="Sorry, sending the message didn't work." -Count mtSend_BugClosedMsg=2 -mtSend_BugClosedMsg0="These BUG is just closed." -mtSend_BugClosedMsg1="Contact the program support to obtain an update." -Count mtSend_UnknownErrorMsg=1 -mtSend_UnknownErrorMsg0="Unknown error." -Count mtSend_InvalidLoginMsg=1 -mtSend_InvalidLoginMsg0="Invalid login request." -Count mtSend_InvalidSearchMsg=1 -mtSend_InvalidSearchMsg0="Invalid search request." -Count mtSend_InvalidSelectionMsg=1 -mtSend_InvalidSelectionMsg0="Invalid selection request." -Count mtSend_InvalidInsertMsg=1 -mtSend_InvalidInsertMsg0="Invalid insert request." -Count mtSend_InvalidModifyMsg=1 -mtSend_InvalidModifyMsg0="Invalid modify request." -Count mtFileCrackedMsg=2 -mtFileCrackedMsg0="This file is cracked." -mtFileCrackedMsg1="The application will be closed." -Count mtException_LeakMultiFree=1 -mtException_LeakMultiFree0="Multi Free memory leak." -Count mtException_LeakMemoryOverrun=1 -mtException_LeakMemoryOverrun0="Memory Overrun leak." -Count mtException_AntiFreeze=1 -mtException_AntiFreeze0="The application seems to be frozen." -Count mtInvalidEmailMsg=1 -mtInvalidEmailMsg0="Invalid email." -TextsCollection=English - - +[FileVersion] +Version=6.0 +[Compiler] +A=8 +B=0 +C=1 +D=1 +E=0 +F=0 +G=1 +H=1 +I=1 +J=1 +K=0 +L=1 +M=0 +N=1 +O=1 +P=1 +Q=0 +R=0 +S=0 +T=0 +U=0 +V=1 +W=0 +X=1 +Y=1 +Z=1 +ShowHints=1 +ShowWarnings=1 +UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; +[Linker] +MapFile=3 +OutputObjs=0 +ConsoleApp=1 +DebugInfo=0 +RemoteSymbols=0 +MinStackSize=16384 +MaxStackSize=1048576 +ImageBase=4194304 +ExeDescription= +[Directories] +OutputDir=M:\Mangos\PseudoWoWGM +UnitOutputDir= +PackageDLLOutputDir= +PackageDCPOutputDir= +SearchPath=E:\Coding\Delphi\rutinas\fastlib +Packages=Vcl50;Vclx50;VclSmp50;Vcldb50;vclado50;ibevnt50;Vclbde50;vcldbx50;Qrpt50;TeeUI50;TeeDB50;Tee50;Dss50;TeeQR50;VCLIB50;Vclmid50;vclie50;Inetdb50;Inet50;NMFast50;webmid50;dclocx50;dclaxserver50 +Conditionals= +DebugSourceDirs= +UsePackages=0 +[Parameters] +RunParams= +HostApplication= +Launcher= +UseLauncher=0 +DebugCWD= +[Language] +ActiveLang= +ProjectLang=$00000C0A +RootDir= +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=2 +MinorVer=2 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=3082 +CodePage=1252 +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=2.2.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= +[Excluded Packages] +c:\program files\borland\delphi6\Projects\Bpl\ThirdParty2000.bpl=3rd Party Components +c:\program files\borland\delphi6\Projects\Bpl\SweetControls6.bpl=CA SweetControls +[HistoryLists\hlUnitAliases] +Count=1 +Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; +[HistoryLists\hlSearchPath] +Count=1 +Item0=E:\Coding\Delphi\rutinas\fastlib +[HistoryLists\hlOutputDirectorry] +Count=2 +Item0=M:\Mangos\PseudoWoWGM +Item1=F:\ttWoWEmu\pseuwow\ +[Exception Log] +EurekaLog Version=6003 +Activate=0 +Activate Handle=1 +Save Log File=1 +Foreground Tab=0 +Freeze Activate=0 +Freeze Timeout=0 +SMTP From=eurekalog@email.com +SMTP Host= +SMTP Port=25 +SMTP UserID= +SMTP Password= +Append to Log=0 +TerminateBtn Operation=2 +Errors Number=32 +Errors Terminate=3 +Email Address= +Email Object= +Email Send Options=0 +Output Path= +Encrypt Password= +AutoCloseDialogSecs=0 +WebSendMode=0 +SupportULR= +HTMLLayout Count=15 +HTMLLine0="%3Chtml%3E" +HTMLLine1=" %3Chead%3E" +HTMLLine2=" %3C/head%3E" +HTMLLine3=" %3Cbody TopMargin=10 LeftMargin=10%3E" +HTMLLine4=" %3Ctable width="100%%" border="0"%3E" +HTMLLine5=" %3Ctr%3E" +HTMLLine6=" %3Ctd nowrap%3E" +HTMLLine7=" %3Cfont face="Lucida Console, Courier" size="2"%3E" +HTMLLine8=" %3C%%HTML_TAG%%%3E" +HTMLLine9=" %3C/font%3E" +HTMLLine10=" %3C/td%3E" +HTMLLine11=" %3C/tr%3E" +HTMLLine12=" %3C/table%3E" +HTMLLine13=" %3C/body%3E" +HTMLLine14="%3C/html%3E" +AutoCrashOperation=2 +AutoCrashNumber=10 +AutoCrashMinutes=1 +WebURL= +WebUserID= +WebPassword= +WebPort=0 +AttachedFiles= +ProxyURL= +ProxyUser= +ProxyPassword= +ProxyPort=8080 +TrakerUser= +TrakerPassword= +TrakerAssignTo= +TrakerProject= +TrakerCategory= +TrakerTrialID= +ZipPassword= +PreBuildEvent= +PostSuccessfulBuildEvent= +PostFailureBuildEvent= +ExceptionDialogType=2 +Count=0 +EMail Message Line Count=0 +loNoDuplicateErrors=0 +loAppendReproduceText=0 +loDeleteLogAtVersionChange=0 +loAddComputerNameInLogFileName=0 +loSaveModulesAndProcessesSections=1 +loSaveAssemblerAndCPUSections=1 +soAppStartDate=1 +soAppName=1 +soAppVersionNumber=1 +soAppParameters=1 +soAppCompilationDate=1 +soAppUpTime=1 +soExcDate=1 +soExcAddress=1 +soExcModuleName=1 +soExcModuleVersion=1 +soExcType=1 +soExcMessage=1 +soExcID=1 +soExcCount=1 +soExcStatus=1 +soExcNote=1 +soUserID=1 +soUserName=1 +soUserEmail=1 +soUserPrivileges=1 +soUserCompany=1 +soActCtlsFormClass=1 +soActCtlsFormText=1 +soActCtlsControlClass=1 +soActCtlsControlText=1 +soCmpName=1 +soCmpTotalMemory=1 +soCmpFreeMemory=1 +soCmpTotalDisk=1 +soCmpFreeDisk=1 +soCmpSysUpTime=1 +soCmpProcessor=1 +soCmpDisplayMode=1 +soCmpDisplayDPI=1 +soCmpVideoCard=1 +soCmpPrinter=1 +soOSType=1 +soOSBuildN=1 +soOSUpdate=1 +soOSLanguage=1 +soOSCharset=1 +soNetIP=1 +soNetSubmask=1 +soNetGateway=1 +soNetDNS1=1 +soNetDNS2=1 +soNetDHCP=1 +soCustomData=1 +sndShowSendDialog=1 +sndShowSuccessFailureMsg=0 +sndSendEntireLog=0 +sndSendXMLLogCopy=0 +sndSendScreenshot=1 +sndUseOnlyActiveWindow=0 +sndSendLastHTMLPage=1 +sndSendInSeparatedThread=0 +sndAddDateInFileName=0 +sndAddComputerNameInFileName=0 +edoSendErrorReportChecked=1 +edoAttachScreenshotChecked=1 +edoShowCopyToClipOption=1 +edoShowDetailsButton=1 +edoShowInDetailedMode=0 +edoShowInTopMostMode=0 +edoUseEurekaLogLookAndFeel=0 +edoShowSendErrorReportOption=1 +edoShowAttachScreenshotOption=1 +edoShowCustomButton=0 +csoShowDLLs=1 +csoShowBPLs=1 +csoShowBorlandThreads=1 +csoShowWindowsThreads=1 +csoDoNotStoreProcNames=0 +boPauseBorlandThreads=0 +boDoNotPauseMainThread=0 +boPauseWindowsThreads=0 +boUseMainModuleOptions=1 +boCopyLogInCaseOfError=1 +boSaveCompressedCopyInCaseOfError=0 +boHandleSafeCallExceptions=0 +boCallRTLExceptionEvent=0 +boCatchHandledExceptions=0 +loCatchLeaks=0 +loGroupsSonLeaks=1 +loHideBorlandLeaks=1 +loFreeAllLeaks=1 +loCatchLeaksExceptions=1 +cfoReduceFileSize=1 +cfoCheckFileCorruption=0 +Count mtInformationMsgCaption=1 +mtInformationMsgCaption0="Information." +Count mtQuestionMsgCaption=1 +mtQuestionMsgCaption0="Question." +Count mtErrorMsgCaption=1 +mtErrorMsgCaption0="Error." +Count mtDialog_Caption=1 +mtDialog_Caption0="Error occurred" +Count mtDialog_ErrorMsgCaption=2 +mtDialog_ErrorMsgCaption0="An error has occurred during program execution." +mtDialog_ErrorMsgCaption1="Please read the following information for further details." +Count mtDialog_GeneralCaption=1 +mtDialog_GeneralCaption0="General" +Count mtDialog_GeneralHeader=1 +mtDialog_GeneralHeader0="General Information" +Count mtDialog_CallStackCaption=1 +mtDialog_CallStackCaption0="Call Stack" +Count mtDialog_CallStackHeader=1 +mtDialog_CallStackHeader0="Call Stack Information" +Count mtDialog_ModulesCaption=1 +mtDialog_ModulesCaption0="Modules" +Count mtDialog_ModulesHeader=1 +mtDialog_ModulesHeader0="Modules Information" +Count mtDialog_ProcessesCaption=1 +mtDialog_ProcessesCaption0="Processes" +Count mtDialog_ProcessesHeader=1 +mtDialog_ProcessesHeader0="Processes Information" +Count mtDialog_AsmCaption=1 +mtDialog_AsmCaption0="Assembler" +Count mtDialog_AsmHeader=1 +mtDialog_AsmHeader0="Assembler Information" +Count mtDialog_CPUCaption=1 +mtDialog_CPUCaption0="CPU" +Count mtDialog_CPUHeader=1 +mtDialog_CPUHeader0="CPU Information" +Count mtDialog_OKButtonCaption=1 +mtDialog_OKButtonCaption0="%26OK" +Count mtDialog_TerminateButtonCaption=1 +mtDialog_TerminateButtonCaption0="%26Terminate" +Count mtDialog_RestartButtonCaption=1 +mtDialog_RestartButtonCaption0="%26Restart" +Count mtDialog_DetailsButtonCaption=1 +mtDialog_DetailsButtonCaption0="%26Details" +Count mtDialog_CustomButtonCaption=1 +mtDialog_CustomButtonCaption0="%26Help" +Count mtDialog_SendMessage=1 +mtDialog_SendMessage0="%26Send this error via Internet" +Count mtDialog_ScreenshotMessage=1 +mtDialog_ScreenshotMessage0="%26Attach a Screenshot image" +Count mtDialog_CopyMessage=1 +mtDialog_CopyMessage0="%26Copy to Clipboard" +Count mtDialog_SupportMessage=1 +mtDialog_SupportMessage0="Go to the Support Page" +Count mtMSDialog_ErrorMsgCaption=1 +mtMSDialog_ErrorMsgCaption0="The application has encountered a problem. We are sorry for the inconvenience." +Count mtMSDialog_RestartCaption=1 +mtMSDialog_RestartCaption0="Restart application." +Count mtMSDialog_TerminateCaption=1 +mtMSDialog_TerminateCaption0="Terminate application." +Count mtMSDialog_PleaseCaption=1 +mtMSDialog_PleaseCaption0="Please tell us about this problem." +Count mtMSDialog_DescriptionCaption=1 +mtMSDialog_DescriptionCaption0="We have created an error report that you can send to us. We will treat this report as confidential and anonymous." +Count mtMSDialog_SeeDetailsCaption=1 +mtMSDialog_SeeDetailsCaption0="To see what data the error report contains," +Count mtMSDialog_SeeClickCaption=1 +mtMSDialog_SeeClickCaption0="click here." +Count mtMSDialog_HowToReproduceCaption=1 +mtMSDialog_HowToReproduceCaption0="What were you doing when the problem happended (optional)?" +Count mtMSDialog_EmailCaption=1 +mtMSDialog_EmailCaption0="Email address (optional):" +Count mtMSDialog_SendButtonCaption=1 +mtMSDialog_SendButtonCaption0="%26Send Error Report" +Count mtMSDialog_NoSendButtonCaption=1 +mtMSDialog_NoSendButtonCaption0="%26Don't Send" +Count mtLog_AppHeader=1 +mtLog_AppHeader0="Application" +Count mtLog_AppStartDate=1 +mtLog_AppStartDate0="Start Date" +Count mtLog_AppName=1 +mtLog_AppName0="Name/Description" +Count mtLog_AppVersionNumber=1 +mtLog_AppVersionNumber0="Version Number" +Count mtLog_AppParameters=1 +mtLog_AppParameters0="Parameters" +Count mtLog_AppCompilationDate=1 +mtLog_AppCompilationDate0="Compilation Date" +Count mtLog_AppUpTime=1 +mtLog_AppUpTime0="Up Time" +Count mtLog_ExcHeader=1 +mtLog_ExcHeader0="Exception" +Count mtLog_ExcDate=1 +mtLog_ExcDate0="Date" +Count mtLog_ExcAddress=1 +mtLog_ExcAddress0="Address" +Count mtLog_ExcModuleName=1 +mtLog_ExcModuleName0="Module Name" +Count mtLog_ExcModuleVersion=1 +mtLog_ExcModuleVersion0="Module Version" +Count mtLog_ExcType=1 +mtLog_ExcType0="Type" +Count mtLog_ExcMessage=1 +mtLog_ExcMessage0="Message" +Count mtLog_ExcID=1 +mtLog_ExcID0="ID" +Count mtLog_ExcCount=1 +mtLog_ExcCount0="Count" +Count mtLog_ExcStatus=1 +mtLog_ExcStatus0="Status" +Count mtLog_ExcNote=1 +mtLog_ExcNote0="Note" +Count mtLog_UserHeader=1 +mtLog_UserHeader0="User" +Count mtLog_UserID=1 +mtLog_UserID0="ID" +Count mtLog_UserName=1 +mtLog_UserName0="Name" +Count mtLog_UserEmail=1 +mtLog_UserEmail0="Email" +Count mtLog_UserCompany=1 +mtLog_UserCompany0="Company" +Count mtLog_UserPrivileges=1 +mtLog_UserPrivileges0="Privileges" +Count mtLog_ActCtrlsHeader=1 +mtLog_ActCtrlsHeader0="Active Controls" +Count mtLog_ActCtrlsFormClass=1 +mtLog_ActCtrlsFormClass0="Form Class" +Count mtLog_ActCtrlsFormText=1 +mtLog_ActCtrlsFormText0="Form Text" +Count mtLog_ActCtrlsControlClass=1 +mtLog_ActCtrlsControlClass0="Control Class" +Count mtLog_ActCtrlsControlText=1 +mtLog_ActCtrlsControlText0="Control Text" +Count mtLog_CmpHeader=1 +mtLog_CmpHeader0="Computer" +Count mtLog_CmpName=1 +mtLog_CmpName0="Name" +Count mtLog_CmpTotalMemory=1 +mtLog_CmpTotalMemory0="Total Memory" +Count mtLog_CmpFreeMemory=1 +mtLog_CmpFreeMemory0="Free Memory" +Count mtLog_CmpTotalDisk=1 +mtLog_CmpTotalDisk0="Total Disk" +Count mtLog_CmpFreeDisk=1 +mtLog_CmpFreeDisk0="Free Disk" +Count mtLog_CmpSystemUpTime=1 +mtLog_CmpSystemUpTime0="System Up Time" +Count mtLog_CmpProcessor=1 +mtLog_CmpProcessor0="Processor" +Count mtLog_CmpDisplayMode=1 +mtLog_CmpDisplayMode0="Display Mode" +Count mtLog_CmpDisplayDPI=1 +mtLog_CmpDisplayDPI0="Display DPI" +Count mtLog_CmpVideoCard=1 +mtLog_CmpVideoCard0="Video Card" +Count mtLog_CmpPrinter=1 +mtLog_CmpPrinter0="Printer" +Count mtLog_OSHeader=1 +mtLog_OSHeader0="Operating System" +Count mtLog_OSType=1 +mtLog_OSType0="Type" +Count mtLog_OSBuildN=1 +mtLog_OSBuildN0="Build #" +Count mtLog_OSUpdate=1 +mtLog_OSUpdate0="Update" +Count mtLog_OSLanguage=1 +mtLog_OSLanguage0="Language" +Count mtLog_OSCharset=1 +mtLog_OSCharset0="Charset" +Count mtLog_NetHeader=1 +mtLog_NetHeader0="Network" +Count mtLog_NetIP=1 +mtLog_NetIP0="IP Address" +Count mtLog_NetSubmask=1 +mtLog_NetSubmask0="Submask" +Count mtLog_NetGateway=1 +mtLog_NetGateway0="Gateway" +Count mtLog_NetDNS1=1 +mtLog_NetDNS10="DNS 1" +Count mtLog_NetDNS2=1 +mtLog_NetDNS20="DNS 2" +Count mtLog_NetDHCP=1 +mtLog_NetDHCP0="DHCP" +Count mtLog_CustInfoHeader=1 +mtLog_CustInfoHeader0="Custom Information" +Count mtCallStack_Address=1 +mtCallStack_Address0="Address" +Count mtCallStack_Name=1 +mtCallStack_Name0="Module" +Count mtCallStack_Unit=1 +mtCallStack_Unit0="Unit" +Count mtCallStack_Class=1 +mtCallStack_Class0="Class" +Count mtCallStack_Procedure=1 +mtCallStack_Procedure0="Procedure/Method" +Count mtCallStack_Line=1 +mtCallStack_Line0="Line" +Count mtCallStack_MainThread=1 +mtCallStack_MainThread0="Main" +Count mtCallStack_ExceptionThread=1 +mtCallStack_ExceptionThread0="Exception Thread" +Count mtCallStack_RunningThread=1 +mtCallStack_RunningThread0="Running Thread" +Count mtCallStack_CallingThread=1 +mtCallStack_CallingThread0="Calling Thread" +Count mtCallStack_ThreadID=1 +mtCallStack_ThreadID0="ID" +Count mtCallStack_ThreadPriority=1 +mtCallStack_ThreadPriority0="Priority" +Count mtCallStack_ThreadClass=1 +mtCallStack_ThreadClass0="Class" +Count mtCallStack_LeakCaption=1 +mtCallStack_LeakCaption0="Memory Leak" +Count mtCallStack_LeakData=1 +mtCallStack_LeakData0="Data" +Count mtCallStack_LeakType=1 +mtCallStack_LeakType0="Type" +Count mtCallStack_LeakSize=1 +mtCallStack_LeakSize0="Total size" +Count mtCallStack_LeakCount=1 +mtCallStack_LeakCount0="Count" +Count mtSendDialog_Caption=1 +mtSendDialog_Caption0="Send." +Count mtSendDialog_Message=1 +mtSendDialog_Message0="Message" +Count mtSendDialog_Resolving=1 +mtSendDialog_Resolving0="Resolving DNS..." +Count mtSendDialog_Login=1 +mtSendDialog_Login0="Login..." +Count mtSendDialog_Connecting=1 +mtSendDialog_Connecting0="Connecting with server..." +Count mtSendDialog_Connected=1 +mtSendDialog_Connected0="Connected with server." +Count mtSendDialog_Sending=1 +mtSendDialog_Sending0="Sending message..." +Count mtSendDialog_Sent=1 +mtSendDialog_Sent0="Message sent." +Count mtSendDialog_SelectProject=1 +mtSendDialog_SelectProject0="Select project..." +Count mtSendDialog_Searching=1 +mtSendDialog_Searching0="Searching..." +Count mtSendDialog_Modifying=1 +mtSendDialog_Modifying0="Modifying..." +Count mtSendDialog_Disconnecting=1 +mtSendDialog_Disconnecting0="Disconnecting..." +Count mtSendDialog_Disconnected=1 +mtSendDialog_Disconnected0="Disconnected." +Count mtReproduceDialog_Caption=1 +mtReproduceDialog_Caption0="Request" +Count mtReproduceDialog_Request=1 +mtReproduceDialog_Request0="Please describe the steps to reproduce the error:" +Count mtReproduceDialog_OKButtonCaption=1 +mtReproduceDialog_OKButtonCaption0="%26OK" +Count mtModules_Handle=1 +mtModules_Handle0="Handle" +Count mtModules_Name=1 +mtModules_Name0="Name" +Count mtModules_Description=1 +mtModules_Description0="Description" +Count mtModules_Version=1 +mtModules_Version0="Version" +Count mtModules_Size=1 +mtModules_Size0="Size" +Count mtModules_LastModified=1 +mtModules_LastModified0="Modified" +Count mtModules_Path=1 +mtModules_Path0="Path" +Count mtProcesses_ID=1 +mtProcesses_ID0="ID" +Count mtProcesses_Name=1 +mtProcesses_Name0="Name" +Count mtProcesses_Description=1 +mtProcesses_Description0="Description" +Count mtProcesses_Version=1 +mtProcesses_Version0="Version" +Count mtProcesses_Memory=1 +mtProcesses_Memory0="Memory" +Count mtProcesses_Priority=1 +mtProcesses_Priority0="Priority" +Count mtProcesses_Threads=1 +mtProcesses_Threads0="Threads" +Count mtProcesses_Path=1 +mtProcesses_Path0="Path" +Count mtCPU_Registers=1 +mtCPU_Registers0="Registers" +Count mtCPU_Stack=1 +mtCPU_Stack0="Stack" +Count mtCPU_MemoryDump=1 +mtCPU_MemoryDump0="Memory Dump" +Count mtSend_SuccessMsg=1 +mtSend_SuccessMsg0="The message was sent successfully." +Count mtSend_FailureMsg=1 +mtSend_FailureMsg0="Sorry, sending the message didn't work." +Count mtSend_BugClosedMsg=2 +mtSend_BugClosedMsg0="These BUG is just closed." +mtSend_BugClosedMsg1="Contact the program support to obtain an update." +Count mtSend_UnknownErrorMsg=1 +mtSend_UnknownErrorMsg0="Unknown error." +Count mtSend_InvalidLoginMsg=1 +mtSend_InvalidLoginMsg0="Invalid login request." +Count mtSend_InvalidSearchMsg=1 +mtSend_InvalidSearchMsg0="Invalid search request." +Count mtSend_InvalidSelectionMsg=1 +mtSend_InvalidSelectionMsg0="Invalid selection request." +Count mtSend_InvalidInsertMsg=1 +mtSend_InvalidInsertMsg0="Invalid insert request." +Count mtSend_InvalidModifyMsg=1 +mtSend_InvalidModifyMsg0="Invalid modify request." +Count mtFileCrackedMsg=2 +mtFileCrackedMsg0="This file is cracked." +mtFileCrackedMsg1="The application will be closed." +Count mtException_LeakMultiFree=1 +mtException_LeakMultiFree0="Multi Free memory leak." +Count mtException_LeakMemoryOverrun=1 +mtException_LeakMemoryOverrun0="Memory Overrun leak." +Count mtException_AntiFreeze=1 +mtException_AntiFreeze0="The application seems to be frozen." +Count mtInvalidEmailMsg=1 +mtInvalidEmailMsg0="Invalid email." +TextsCollection=English + + diff --git a/src/tools/PseuWoWConsole/src/PseuWoWConsole.dpr b/src/tools/PseuWoWConsole/src/PseuWoWConsole.dpr index 095312e..1c170fd 100644 --- a/src/tools/PseuWoWConsole/src/PseuWoWConsole.dpr +++ b/src/tools/PseuWoWConsole/src/PseuWoWConsole.dpr @@ -1,17 +1,17 @@ -program PseuWoWConsole; - -uses - Forms, - fMain in 'fMain.pas' {frmMain}, - RedirectConsole in 'RedirectConsole.pas', - modRichEdit in 'modRichEdit.pas', - modSCPUtils in 'modSCPUtils.pas'; - -{$R *.RES} - -begin - Application.Initialize; - Application.Title := 'PseWoW Console'; - Application.CreateForm(TfrmMain, frmMain); - Application.Run; -end. +program PseuWoWConsole; + +uses + Forms, + fMain in 'fMain.pas' {frmMain}, + RedirectConsole in 'RedirectConsole.pas', + modRichEdit in 'modRichEdit.pas', + modSCPUtils in 'modSCPUtils.pas'; + +{$R *.RES} + +begin + Application.Initialize; + Application.Title := 'PseWoW Console'; + Application.CreateForm(TfrmMain, frmMain); + Application.Run; +end. diff --git a/src/tools/PseuWoWConsole/src/PseuWoWConsole.drc b/src/tools/PseuWoWConsole/src/PseuWoWConsole.drc index 32eb315..267017e 100644 --- a/src/tools/PseuWoWConsole/src/PseuWoWConsole.drc +++ b/src/tools/PseuWoWConsole/src/PseuWoWConsole.drc @@ -1,744 +1,744 @@ -/* VER140 - Generated by the Borland Delphi Pascal Compiler - because -GD or --drc was supplied to the compiler. - - This file contains compiler-generated resources that - were bound to the executable. - If this file is empty, then no compiler-generated - resources were bound to the produced executable. -*/ - -#define JclResources_RsIntelCacheDescr7C 65168 -#define JclResources_RsIntelCacheDescr7D 65169 -#define JclResources_RsIntelCacheDescr7F 65170 -#define JclResources_RsIntelCacheDescr82 65171 -#define JclResources_RsIntelCacheDescr83 65172 -#define JclResources_RsIntelCacheDescr84 65173 -#define JclResources_RsIntelCacheDescr85 65174 -#define JclResources_RsIntelCacheDescr86 65175 -#define JclResources_RsIntelCacheDescr87 65176 -#define JclResources_RsIntelCacheDescrB0 65177 -#define JclResources_RsIntelCacheDescrB3 65178 -#define JclResources_RsIntelCacheDescrF0 65179 -#define JclResources_RsIntelCacheDescrF1 65180 -#define JclResources_RsIntelCacheDescr51 65184 -#define JclResources_RsIntelCacheDescr52 65185 -#define JclResources_RsIntelCacheDescr5B 65186 -#define JclResources_RsIntelCacheDescr5C 65187 -#define JclResources_RsIntelCacheDescr5D 65188 -#define JclResources_RsIntelCacheDescr60 65189 -#define JclResources_RsIntelCacheDescr66 65190 -#define JclResources_RsIntelCacheDescr67 65191 -#define JclResources_RsIntelCacheDescr68 65192 -#define JclResources_RsIntelCacheDescr70 65193 -#define JclResources_RsIntelCacheDescr71 65194 -#define JclResources_RsIntelCacheDescr72 65195 -#define JclResources_RsIntelCacheDescr78 65196 -#define JclResources_RsIntelCacheDescr79 65197 -#define JclResources_RsIntelCacheDescr7A 65198 -#define JclResources_RsIntelCacheDescr7B 65199 -#define JclResources_RsIntelCacheDescr08 65200 -#define JclResources_RsIntelCacheDescr0A 65201 -#define JclResources_RsIntelCacheDescr0C 65202 -#define JclResources_RsIntelCacheDescr22 65203 -#define JclResources_RsIntelCacheDescr23 65204 -#define JclResources_RsIntelCacheDescr25 65205 -#define JclResources_RsIntelCacheDescr29 65206 -#define JclResources_RsIntelCacheDescr2C 65207 -#define JclResources_RsIntelCacheDescr30 65208 -#define JclResources_RsIntelCacheDescr40 65209 -#define JclResources_RsIntelCacheDescr41 65210 -#define JclResources_RsIntelCacheDescr42 65211 -#define JclResources_RsIntelCacheDescr43 65212 -#define JclResources_RsIntelCacheDescr44 65213 -#define JclResources_RsIntelCacheDescr45 65214 -#define JclResources_RsIntelCacheDescr50 65215 -#define JvResources_RsClInfoBk 65216 -#define JvResources_RsGradientActiveCaption 65217 -#define JvResources_RsGradientInactiveCaption 65218 -#define JvResources_RsHotLight 65219 -#define JvResources_RsMenuBar 65220 -#define JvResources_RsMenuHighlight 65221 -#define ComConst_SOleError 65222 -#define ComConst_SNoMethod 65223 -#define ComConst_SVarNotObject 65224 -#define ComConst_STooManyParams 65225 -#define JclResources_RsIntelCacheDescr00 65226 -#define JclResources_RsIntelCacheDescr01 65227 -#define JclResources_RsIntelCacheDescr02 65228 -#define JclResources_RsIntelCacheDescr03 65229 -#define JclResources_RsIntelCacheDescr04 65230 -#define JclResources_RsIntelCacheDescr06 65231 -#define JvResources_RsClWindowText 65232 -#define JvResources_RsClCaptionText 65233 -#define JvResources_RsClActiveBorder 65234 -#define JvResources_RsClInactiveBorder 65235 -#define JvResources_RsClAppWorkSpace 65236 -#define JvResources_RsClHighlight 65237 -#define JvResources_RsClHighlightText 65238 -#define JvResources_RsClBtnFace 65239 -#define JvResources_RsClBtnShadow 65240 -#define JvResources_RsClGrayText 65241 -#define JvResources_RsClBtnText 65242 -#define JvResources_RsClInactiveCaptionText 65243 -#define JvResources_RsClBtnHighlight 65244 -#define JvResources_RsCl3DDkShadow 65245 -#define JvResources_RsCl3DLight 65246 -#define JvResources_RsClInfoText 65247 -#define JvResources_RsClGray25 65248 -#define JvResources_RsClRose 65249 -#define JvResources_RsClTan 65250 -#define JvResources_RsClLightYellow 65251 -#define JvResources_RsClLightGreen 65252 -#define JvResources_RsClLightTurquoise 65253 -#define JvResources_RsClPaleBlue 65254 -#define JvResources_RsClLavender 65255 -#define JvResources_RsClScrollBar 65256 -#define JvResources_RsClBackground 65257 -#define JvResources_RsClActiveCaption 65258 -#define JvResources_RsClInactiveCaption 65259 -#define JvResources_RsClMenu 65260 -#define JvResources_RsClWindow 65261 -#define JvResources_RsClWindowFrame 65262 -#define JvResources_RsClMenuText 65263 -#define JvResources_RsClGray80 65264 -#define JvResources_RsClDarkRed 65265 -#define JvResources_RsClOrange 65266 -#define JvResources_RsClDarkYellow 65267 -#define JvResources_RsClBlueGray 65268 -#define JvResources_RsClGray50 65269 -#define JvResources_RsClLightOrange 65270 -#define JvResources_RsClSeaGreen 65271 -#define JvResources_RsClLightBlue 65272 -#define JvResources_RsClViolet 65273 -#define JvResources_RsClGray40 65274 -#define JvResources_RsClPink 65275 -#define JvResources_RsClGold 65276 -#define JvResources_RsClBrightGreen 65277 -#define JvResources_RsClTurquoise 65278 -#define JvResources_RsClPlum 65279 -#define JvResources_RsClLime 65280 -#define JvResources_RsClYellow 65281 -#define JvResources_RsClBlue 65282 -#define JvResources_RsClFuchsia 65283 -#define JvResources_RsClAqua 65284 -#define JvResources_RsClWhite 65285 -#define JvResources_RsClMoneyGreen 65286 -#define JvResources_RsClSkyBlue 65287 -#define JvResources_RsClCream 65288 -#define JvResources_RsClMedGray 65289 -#define JvResources_RsClBrown 65290 -#define JvResources_RsClOliveGreen 65291 -#define JvResources_RsClDarkGreen 65292 -#define JvResources_RsClDarkTeal 65293 -#define JvResources_RsClDarkBlue 65294 -#define JvResources_RsClIndigo 65295 -#define HelpIntfs_hNoTopics 65296 -#define ComStrs_sInvalidOwner 65297 -#define ComStrs_sRichEditInsertError 65298 -#define ComStrs_sRichEditLoadFail 65299 -#define ComStrs_sRichEditSaveFail 65300 -#define ComStrs_sInvalidComCtl32 65301 -#define JvResources_RsClBlack 65302 -#define JvResources_RsClMaroon 65303 -#define JvResources_RsClGreen 65304 -#define JvResources_RsClOlive 65305 -#define JvResources_RsClNavy 65306 -#define JvResources_RsClPurple 65307 -#define JvResources_RsClTeal 65308 -#define JvResources_RsClGray 65309 -#define JvResources_RsClSilver 65310 -#define JvResources_RsClRed 65311 -#define Consts_SmkcDel 65312 -#define Consts_SmkcShift 65313 -#define Consts_SmkcCtrl 65314 -#define Consts_SmkcAlt 65315 -#define Consts_SInsertLineError 65316 -#define Consts_SIconToClipboard 65317 -#define Consts_SInvalidMemoSize 65318 -#define Consts_SNoDefaultPrinter 65319 -#define Consts_SDuplicateMenus 65320 -#define Consts_SDockedCtlNeedsName 65321 -#define Consts_SDockTreeRemoveError 65322 -#define Consts_SDockZoneNotFound 65323 -#define Consts_SDockZoneHasNoCtl 65324 -#define HelpIntfs_hNoTableOfContents 65325 -#define HelpIntfs_hNothingFound 65326 -#define HelpIntfs_hNoContext 65327 -#define Consts_SMsgDlgNoToAll 65328 -#define Consts_SMsgDlgYesToAll 65329 -#define Consts_SmkcBkSp 65330 -#define Consts_SmkcTab 65331 -#define Consts_SmkcEsc 65332 -#define Consts_SmkcEnter 65333 -#define Consts_SmkcSpace 65334 -#define Consts_SmkcPgUp 65335 -#define Consts_SmkcPgDn 65336 -#define Consts_SmkcEnd 65337 -#define Consts_SmkcHome 65338 -#define Consts_SmkcLeft 65339 -#define Consts_SmkcUp 65340 -#define Consts_SmkcRight 65341 -#define Consts_SmkcDown 65342 -#define Consts_SmkcIns 65343 -#define Consts_SAbortButton 65344 -#define Consts_SAllButton 65345 -#define Consts_SCannotDragForm 65346 -#define Consts_SMsgDlgWarning 65347 -#define Consts_SMsgDlgError 65348 -#define Consts_SMsgDlgInformation 65349 -#define Consts_SMsgDlgConfirm 65350 -#define Consts_SMsgDlgYes 65351 -#define Consts_SMsgDlgNo 65352 -#define Consts_SMsgDlgOK 65353 -#define Consts_SMsgDlgCancel 65354 -#define Consts_SMsgDlgHelp 65355 -#define Consts_SMsgDlgAbort 65356 -#define Consts_SMsgDlgRetry 65357 -#define Consts_SMsgDlgIgnore 65358 -#define Consts_SMsgDlgAll 65359 -#define Consts_SNoTimers 65360 -#define Consts_SNotPrinting 65361 -#define Consts_SPrinting 65362 -#define Consts_SInvalidPrinter 65363 -#define Consts_SDeviceOnPort 65364 -#define Consts_SGroupIndexTooLow 65365 -#define Consts_SNoMDIForm 65366 -#define Consts_SControlParentSetToSelf 65367 -#define Consts_SOKButton 65368 -#define Consts_SCancelButton 65369 -#define Consts_SYesButton 65370 -#define Consts_SNoButton 65371 -#define Consts_SHelpButton 65372 -#define Consts_SCloseButton 65373 -#define Consts_SIgnoreButton 65374 -#define Consts_SRetryButton 65375 -#define Consts_SNoCanvasHandle 65376 -#define Consts_SInvalidImageSize 65377 -#define Consts_SInvalidImageList 65378 -#define Consts_SImageIndexError 65379 -#define Consts_SImageReadFail 65380 -#define Consts_SImageWriteFail 65381 -#define Consts_SWindowDCError 65382 -#define Consts_SWindowClass 65383 -#define Consts_SCannotFocus 65384 -#define Consts_SParentRequired 65385 -#define Consts_SMDIChildNotVisible 65386 -#define Consts_SVisibleChanged 65387 -#define Consts_SCannotShowModal 65388 -#define Consts_SMenuIndexError 65389 -#define Consts_SMenuReinserted 65390 -#define Consts_SMenuNotFound 65391 -#define RTLConsts_SUnknownProperty 65392 -#define RTLConsts_SWriteError 65393 -#define RTLConsts_SThreadCreateError 65394 -#define RTLConsts_SThreadError 65395 -#define RTLConsts_sWindowsSocketError 65396 -#define RTLConsts_sAsyncSocketError 65397 -#define RTLConsts_sNoAddress 65398 -#define RTLConsts_sCannotListenOnOpen 65399 -#define RTLConsts_sCannotCreateSocket 65400 -#define RTLConsts_sSocketAlreadyOpen 65401 -#define RTLConsts_sCantChangeWhileActive 65402 -#define Consts_SInvalidBitmap 65403 -#define Consts_SInvalidIcon 65404 -#define Consts_SChangeIconSize 65405 -#define Consts_SUnknownClipboardFormat 65406 -#define Consts_SOutOfResources 65407 -#define RTLConsts_SInvalidImage 65408 -#define RTLConsts_SInvalidName 65409 -#define RTLConsts_SInvalidProperty 65410 -#define RTLConsts_SInvalidPropertyPath 65411 -#define RTLConsts_SInvalidPropertyValue 65412 -#define RTLConsts_SListCapacityError 65413 -#define RTLConsts_SListCountError 65414 -#define RTLConsts_SListIndexError 65415 -#define RTLConsts_SMemoryStreamError 65416 -#define RTLConsts_SPropertyException 65417 -#define RTLConsts_SReadError 65418 -#define RTLConsts_SReadOnlyProperty 65419 -#define RTLConsts_SResNotFound 65420 -#define RTLConsts_SSeekNotImplemented 65421 -#define RTLConsts_SSortedListError 65422 -#define RTLConsts_SUnknownGroup 65423 -#define SysConst_SLongDayNameThu 65424 -#define SysConst_SLongDayNameFri 65425 -#define SysConst_SLongDayNameSat 65426 -#define RTLConsts_SAncestorNotFound 65427 -#define RTLConsts_SAssignError 65428 -#define RTLConsts_SBitsIndexError 65429 -#define RTLConsts_SCantWriteResourceStreamError 65430 -#define RTLConsts_SCheckSynchronizeError 65431 -#define RTLConsts_SClassNotFound 65432 -#define RTLConsts_SDuplicateClass 65433 -#define RTLConsts_SDuplicateItem 65434 -#define RTLConsts_SDuplicateName 65435 -#define RTLConsts_SDuplicateString 65436 -#define RTLConsts_SFCreateError 65437 -#define RTLConsts_SFOpenError 65438 -#define RTLConsts_SIniFileWriteError 65439 -#define SysConst_SLongMonthNameAug 65440 -#define SysConst_SLongMonthNameSep 65441 -#define SysConst_SLongMonthNameOct 65442 -#define SysConst_SLongMonthNameNov 65443 -#define SysConst_SLongMonthNameDec 65444 -#define SysConst_SShortDayNameSun 65445 -#define SysConst_SShortDayNameMon 65446 -#define SysConst_SShortDayNameTue 65447 -#define SysConst_SShortDayNameWed 65448 -#define SysConst_SShortDayNameThu 65449 -#define SysConst_SShortDayNameFri 65450 -#define SysConst_SShortDayNameSat 65451 -#define SysConst_SLongDayNameSun 65452 -#define SysConst_SLongDayNameMon 65453 -#define SysConst_SLongDayNameTue 65454 -#define SysConst_SLongDayNameWed 65455 -#define SysConst_SShortMonthNameApr 65456 -#define SysConst_SShortMonthNameMay 65457 -#define SysConst_SShortMonthNameJun 65458 -#define SysConst_SShortMonthNameJul 65459 -#define SysConst_SShortMonthNameAug 65460 -#define SysConst_SShortMonthNameSep 65461 -#define SysConst_SShortMonthNameOct 65462 -#define SysConst_SShortMonthNameNov 65463 -#define SysConst_SShortMonthNameDec 65464 -#define SysConst_SLongMonthNameJan 65465 -#define SysConst_SLongMonthNameFeb 65466 -#define SysConst_SLongMonthNameMar 65467 -#define SysConst_SLongMonthNameApr 65468 -#define SysConst_SLongMonthNameMay 65469 -#define SysConst_SLongMonthNameJun 65470 -#define SysConst_SLongMonthNameJul 65471 -#define SysConst_SVarInvalid 65472 -#define SysConst_SVarBadType 65473 -#define SysConst_SVarNotImplemented 65474 -#define SysConst_SVarUnexpected 65475 -#define SysConst_SExternalException 65476 -#define SysConst_SAssertionFailed 65477 -#define SysConst_SIntfCastError 65478 -#define SysConst_SSafecallException 65479 -#define SysConst_SAssertError 65480 -#define SysConst_SAbstractError 65481 -#define SysConst_SModuleAccessViolation 65482 -#define SysConst_SOSError 65483 -#define SysConst_SUnkOSError 65484 -#define SysConst_SShortMonthNameJan 65485 -#define SysConst_SShortMonthNameFeb 65486 -#define SysConst_SShortMonthNameMar 65487 -#define SysConst_SInvalidFormat 65488 -#define SysConst_SArgumentMissing 65489 -#define SysConst_SDispatchError 65490 -#define SysConst_SReadAccess 65491 -#define SysConst_SWriteAccess 65492 -#define SysConst_SVarArrayCreate 65493 -#define SysConst_SVarArrayBounds 65494 -#define SysConst_SVarArrayLocked 65495 -#define SysConst_SInvalidVarCast 65496 -#define SysConst_SInvalidVarOp 65497 -#define SysConst_SInvalidVarOpWithHResult 65498 -#define SysConst_SVarNotArray 65499 -#define SysConst_SInvalidVarNullOp 65500 -#define SysConst_SVarTypeCouldNotConvert 65501 -#define SysConst_SVarTypeConvertOverflow 65502 -#define SysConst_SVarOverflow 65503 -#define SysConst_SDivByZero 65504 -#define SysConst_SRangeError 65505 -#define SysConst_SIntOverflow 65506 -#define SysConst_SInvalidOp 65507 -#define SysConst_SZeroDivide 65508 -#define SysConst_SOverflow 65509 -#define SysConst_SUnderflow 65510 -#define SysConst_SInvalidPointer 65511 -#define SysConst_SInvalidCast 65512 -#define SysConst_SAccessViolation 65513 -#define SysConst_SStackOverflow 65514 -#define SysConst_SControlC 65515 -#define SysConst_SPrivilege 65516 -#define SysConst_SOperationAborted 65517 -#define SysConst_SException 65518 -#define SysConst_SExceptTitle 65519 -#define SysConst_SInvalidInteger 65520 -#define SysConst_SInvalidFloat 65521 -#define SysConst_SInvalidDate 65522 -#define SysConst_SInvalidTime 65523 -#define SysConst_SInvalidDateTime 65524 -#define SysConst_STimeEncodeError 65525 -#define SysConst_SDateEncodeError 65526 -#define SysConst_SOutOfMemory 65527 -#define SysConst_SInOutError 65528 -#define SysConst_SFileNotFound 65529 -#define SysConst_SInvalidFilename 65530 -#define SysConst_STooManyOpenFiles 65531 -#define SysConst_SAccessDenied 65532 -#define SysConst_SEndOfFile 65533 -#define SysConst_SDiskFull 65534 -#define SysConst_SInvalidInput 65535 -STRINGTABLE -BEGIN - JclResources_RsIntelCacheDescr7C, "2° Level cache, 1 MBytes, 8-way set associative, dual-sectored line, 64 Bytes sector size" - JclResources_RsIntelCacheDescr7D, "2° Level cache, 2 MByte, 8-way set associative, 64byte line size" - JclResources_RsIntelCacheDescr7F, "2° Level cache, 512 KByte, 2-way set associative, 64-byte line size" - JclResources_RsIntelCacheDescr82, "2° Level cache, 256 KBytes, 8-way associative, 32 Bytes line size" - JclResources_RsIntelCacheDescr83, "2° Level cache, 512 KBytes, 8-way associative, 32 Bytes line size" - JclResources_RsIntelCacheDescr84, "2° Level cache, 1 MBytes, 8-way associative, 32 Bytes line size" - JclResources_RsIntelCacheDescr85, "2° Level cache, 2 MBytes, 8-way associative, 32 Bytes line size" - JclResources_RsIntelCacheDescr86, "2° Level cache, 512 KByte, 4-way set associative, 64 byte line size" - JclResources_RsIntelCacheDescr87, "2° Level cache, 1 MByte, 8-way set associative, 64 byte line size" - JclResources_RsIntelCacheDescrB0, "Instruction TLB, 4 KByte Pages, 4-way set associative, 128 entries" - JclResources_RsIntelCacheDescrB3, "Data TLB, 4 KByte Pages, 4-way set associative, 128 entries" - JclResources_RsIntelCacheDescrF0, "64-Byte Prefetching" - JclResources_RsIntelCacheDescrF1, "128-Byte Prefetching" - JclResources_RsIntelCacheDescr51, "Instruction TLB, 4 KBytes and 2 MBytes or 4 MBytes pages, 128 Entries" - JclResources_RsIntelCacheDescr52, "Instruction TLB, 4 KBytes and 2 MBytes or 4 MBytes pages, 256 Entries" - JclResources_RsIntelCacheDescr5B, "Data TLB, 4 KBytes and 4 MBytes pages, 64 Entries" - JclResources_RsIntelCacheDescr5C, "Data TLB, 4 KBytes and 4 MBytes pages, 128 Entries" - JclResources_RsIntelCacheDescr5D, "Data TLB, 4 KBytes and 4 MBytes pages, 256 Entries" - JclResources_RsIntelCacheDescr60, "1° Level data cache: 16 KByte, 8-way set associative, 64 byte line size" - JclResources_RsIntelCacheDescr66, "1° Level Data cache, 8 KBytes, 4-way set associative, 64 Bytes line size" - JclResources_RsIntelCacheDescr67, "1° Level Data cache, 16 KBytes, 4-way set associative, 64 Bytes line size" - JclResources_RsIntelCacheDescr68, "1° Level Data cache, 32 KBytes, 4-way set associative, 64 Bytes line size" - JclResources_RsIntelCacheDescr70, "Trace cache, 12 KµOps, 8-way set associative" - JclResources_RsIntelCacheDescr71, "Trace cache, 16 KµOps, 8-way set associative" - JclResources_RsIntelCacheDescr72, "Trace cache, 32 KµOps, 8-way set associative" - JclResources_RsIntelCacheDescr78, "2° Level cache, 1 MBytes, 4-way set associative, 64 Bytes line size" - JclResources_RsIntelCacheDescr79, "2° Level cache, 128 KBytes, 8-way set associative, dual-sectored line, 64 Bytes sector size" - JclResources_RsIntelCacheDescr7A, "2° Level cache, 256 KBytes, 8-way set associative, dual-sectored line, 64 Bytes sector size" - JclResources_RsIntelCacheDescr7B, "2° Level cache, 512 KBytes, 8-way set associative, dual-sectored line, 64 Bytes sector size" - JclResources_RsIntelCacheDescr08, "16KB instruction cache, 4-way set associative, 32 byte line size" - JclResources_RsIntelCacheDescr0A, "8KB data cache 2-way set associative, 32 byte line size" - JclResources_RsIntelCacheDescr0C, "16KB data cache, 4-way set associative, 32 byte line size" - JclResources_RsIntelCacheDescr22, "3° Level cache, 512 KBytes, 4-way set associative, 2 lines per sector, 128 byte sector size" - JclResources_RsIntelCacheDescr23, "3° Level cache, 1 MBytes, 8-way set associative, 2 lines per sector, 128 byte sector size" - JclResources_RsIntelCacheDescr25, "3° Level cache, 2 MBytes, 8-way set associative, 2 lines per sector, 128 byte line size" - JclResources_RsIntelCacheDescr29, "3° Level cache, 4M Bytes, 8-way set associative, 2 lines per sector, 128 byte line size" - JclResources_RsIntelCacheDescr2C, "1° Level data cache: 32K Bytes, 8-way set associative, 64 byte line size" - JclResources_RsIntelCacheDescr30, "1° Level instruction cache: 32K Bytes, 8-way set associative, 64 byte line size" - JclResources_RsIntelCacheDescr40, "No L2 cache" - JclResources_RsIntelCacheDescr41, "Unified cache, 32 byte cache line, 4-way set associative, 128Kb" - JclResources_RsIntelCacheDescr42, "Unified cache, 32 byte cache line, 4-way set associative, 256Kb" - JclResources_RsIntelCacheDescr43, "Unified cache, 32 byte cache line, 4-way set associative, 512Kb" - JclResources_RsIntelCacheDescr44, "Unified cache, 32 byte cache line, 4-way set associative, 1Mb" - JclResources_RsIntelCacheDescr45, "Unified cache, 32 byte cache line, 4-way set associative, 2Mb" - JclResources_RsIntelCacheDescr50, "Instruction TLB, 4 KBytes and 2 MBytes or 4 MBytes pages, 64 Entries" - JvResources_RsClInfoBk, "Tooltip background" - JvResources_RsGradientActiveCaption, "Gradient Active Caption" - JvResources_RsGradientInactiveCaption, "Gradient Inactive Caption" - JvResources_RsHotLight, "Hot Light" - JvResources_RsMenuBar, "Menu Bar" - JvResources_RsMenuHighlight, "Menu Highlight" - ComConst_SOleError, "OLE error %.8x" - ComConst_SNoMethod, "Method '%s' not supported by automation object" - ComConst_SVarNotObject, "Variant does not reference an automation object" - ComConst_STooManyParams, "Dispatch methods do not support more than 64 parameters" - JclResources_RsIntelCacheDescr00, "Null descriptor" - JclResources_RsIntelCacheDescr01, "Instruction TLB, 4Kb pages, 4-way set associative, 32 entries" - JclResources_RsIntelCacheDescr02, "Instruction TLB, 4Mb pages, fully associative, 2 entries" - JclResources_RsIntelCacheDescr03, "Data TLB, 4Kb pages, 4-way set associative, 64 entries" - JclResources_RsIntelCacheDescr04, "Data TLB, 4Mb pages, 4-way set associative, 8 entries" - JclResources_RsIntelCacheDescr06, "8KB instruction cache, 4-way set associative, 32 byte line size" - JvResources_RsClWindowText, "Window text" - JvResources_RsClCaptionText, "Active window title bar text" - JvResources_RsClActiveBorder, "Active window border" - JvResources_RsClInactiveBorder, "Inactive window border" - JvResources_RsClAppWorkSpace, "Application workspace" - JvResources_RsClHighlight, "Selection background" - JvResources_RsClHighlightText, "Selection text" - JvResources_RsClBtnFace, "Button face" - JvResources_RsClBtnShadow, "Button shadow" - JvResources_RsClGrayText, "Dimmed text" - JvResources_RsClBtnText, "Button text" - JvResources_RsClInactiveCaptionText, "Inactive window title bar text" - JvResources_RsClBtnHighlight, "Button highlight" - JvResources_RsCl3DDkShadow, "Dark shadow 3D elements" - JvResources_RsCl3DLight, "Highlight 3D elements" - JvResources_RsClInfoText, "Tooltip text" - JvResources_RsClGray25, "Gray 25%" - JvResources_RsClRose, "Rose" - JvResources_RsClTan, "Tan" - JvResources_RsClLightYellow, "Light Yellow" - JvResources_RsClLightGreen, "Light Green" - JvResources_RsClLightTurquoise, "Light Turquoise" - JvResources_RsClPaleBlue, "Pale Blue" - JvResources_RsClLavender, "Lavender" - JvResources_RsClScrollBar, "Scrollbar" - JvResources_RsClBackground, "Desktop background" - JvResources_RsClActiveCaption, "Active window title bar" - JvResources_RsClInactiveCaption, "Inactive window title bar" - JvResources_RsClMenu, "Menu background" - JvResources_RsClWindow, "Window background" - JvResources_RsClWindowFrame, "Window frame" - JvResources_RsClMenuText, "Menu text" - JvResources_RsClGray80, "Gray 80%" - JvResources_RsClDarkRed, "Dark Red" - JvResources_RsClOrange, "Orange" - JvResources_RsClDarkYellow, "Dark Yellow" - JvResources_RsClBlueGray, "Blue Gray" - JvResources_RsClGray50, "Gray 50%" - JvResources_RsClLightOrange, "Light Orange" - JvResources_RsClSeaGreen, "Sea Green" - JvResources_RsClLightBlue, "Light Blue" - JvResources_RsClViolet, "Violet" - JvResources_RsClGray40, "Gray 40%" - JvResources_RsClPink, "Pink" - JvResources_RsClGold, "Gold" - JvResources_RsClBrightGreen, "Bright Green" - JvResources_RsClTurquoise, "Turquoise" - JvResources_RsClPlum, "Plum" - JvResources_RsClLime, "Lime" - JvResources_RsClYellow, "Yellow" - JvResources_RsClBlue, "Blue" - JvResources_RsClFuchsia, "Fuchsia" - JvResources_RsClAqua, "Aqua" - JvResources_RsClWhite, "White" - JvResources_RsClMoneyGreen, "Money green" - JvResources_RsClSkyBlue, "Sky blue" - JvResources_RsClCream, "Cream" - JvResources_RsClMedGray, "Medium gray" - JvResources_RsClBrown, "Brown" - JvResources_RsClOliveGreen, "Olive Green" - JvResources_RsClDarkGreen, "Dark Green" - JvResources_RsClDarkTeal, "Dark Teal" - JvResources_RsClDarkBlue, "Dark Blue" - JvResources_RsClIndigo, "Indigo" - HelpIntfs_hNoTopics, "No topic-based help system installed" - ComStrs_sInvalidOwner, "Invalid owner" - ComStrs_sRichEditInsertError, "RichEdit line insertion error" - ComStrs_sRichEditLoadFail, "Failed to Load Stream" - ComStrs_sRichEditSaveFail, "Failed to Save Stream" - ComStrs_sInvalidComCtl32, "This control requires version 4.70 or greater of COMCTL32.DLL" - JvResources_RsClBlack, "Black" - JvResources_RsClMaroon, "Maroon" - JvResources_RsClGreen, "Green" - JvResources_RsClOlive, "Olive green" - JvResources_RsClNavy, "Navy blue" - JvResources_RsClPurple, "Purple" - JvResources_RsClTeal, "Teal" - JvResources_RsClGray, "Gray" - JvResources_RsClSilver, "Silver" - JvResources_RsClRed, "Red" - Consts_SmkcDel, "Del" - Consts_SmkcShift, "Shift+" - Consts_SmkcCtrl, "Ctrl+" - Consts_SmkcAlt, "Alt+" - Consts_SInsertLineError, "Unable to insert a line" - Consts_SIconToClipboard, "Clipboard does not support Icons" - Consts_SInvalidMemoSize, "Text exceeds memo capacity" - Consts_SNoDefaultPrinter, "There is no default printer currently selected" - Consts_SDuplicateMenus, "Menu '%s' is already being used by another form" - Consts_SDockedCtlNeedsName, "Docked control must have a name" - Consts_SDockTreeRemoveError, "Error removing control from dock tree" - Consts_SDockZoneNotFound, " - Dock zone not found" - Consts_SDockZoneHasNoCtl, " - Dock zone has no control" - HelpIntfs_hNoTableOfContents, "Unable to find a Table of Contents" - HelpIntfs_hNothingFound, "No help found for %s" - HelpIntfs_hNoContext, "No context-sensitive help installed" - Consts_SMsgDlgNoToAll, "N&o to All" - Consts_SMsgDlgYesToAll, "Yes to &All" - Consts_SmkcBkSp, "BkSp" - Consts_SmkcTab, "Tab" - Consts_SmkcEsc, "Esc" - Consts_SmkcEnter, "Enter" - Consts_SmkcSpace, "Space" - Consts_SmkcPgUp, "PgUp" - Consts_SmkcPgDn, "PgDn" - Consts_SmkcEnd, "End" - Consts_SmkcHome, "Home" - Consts_SmkcLeft, "Left" - Consts_SmkcUp, "Up" - Consts_SmkcRight, "Right" - Consts_SmkcDown, "Down" - Consts_SmkcIns, "Ins" - Consts_SAbortButton, "Abort" - Consts_SAllButton, "&All" - Consts_SCannotDragForm, "Cannot drag a form" - Consts_SMsgDlgWarning, "Warning" - Consts_SMsgDlgError, "Error" - Consts_SMsgDlgInformation, "Information" - Consts_SMsgDlgConfirm, "Confirm" - Consts_SMsgDlgYes, "&Yes" - Consts_SMsgDlgNo, "&No" - Consts_SMsgDlgOK, "OK" - Consts_SMsgDlgCancel, "Cancel" - Consts_SMsgDlgHelp, "&Help" - Consts_SMsgDlgAbort, "&Abort" - Consts_SMsgDlgRetry, "&Retry" - Consts_SMsgDlgIgnore, "&Ignore" - Consts_SMsgDlgAll, "&All" - Consts_SNoTimers, "Not enough timers available" - Consts_SNotPrinting, "Printer is not currently printing" - Consts_SPrinting, "Printing in progress" - Consts_SInvalidPrinter, "Printer selected is not valid" - Consts_SDeviceOnPort, "%s on %s" - Consts_SGroupIndexTooLow, "GroupIndex cannot be less than a previous menu item's GroupIndex" - Consts_SNoMDIForm, "Cannot create form. No MDI forms are currently active" - Consts_SControlParentSetToSelf, "A control cannot have itself as its parent" - Consts_SOKButton, "OK" - Consts_SCancelButton, "Cancel" - Consts_SYesButton, "&Yes" - Consts_SNoButton, "&No" - Consts_SHelpButton, "&Help" - Consts_SCloseButton, "&Close" - Consts_SIgnoreButton, "&Ignore" - Consts_SRetryButton, "&Retry" - Consts_SNoCanvasHandle, "Canvas does not allow drawing" - Consts_SInvalidImageSize, "Invalid image size" - Consts_SInvalidImageList, "Invalid ImageList" - Consts_SImageIndexError, "Invalid ImageList Index" - Consts_SImageReadFail, "Failed to read ImageList data from stream" - Consts_SImageWriteFail, "Failed to write ImageList data to stream" - Consts_SWindowDCError, "Error creating window device context" - Consts_SWindowClass, "Error creating window class" - Consts_SCannotFocus, "Cannot focus a disabled or invisible window" - Consts_SParentRequired, "Control '%s' has no parent window" - Consts_SMDIChildNotVisible, "Cannot hide an MDI Child Form" - Consts_SVisibleChanged, "Cannot change Visible in OnShow or OnHide" - Consts_SCannotShowModal, "Cannot make a visible window modal" - Consts_SMenuIndexError, "Menu index out of range" - Consts_SMenuReinserted, "Menu inserted twice" - Consts_SMenuNotFound, "Sub-menu is not in menu" - RTLConsts_SUnknownProperty, "Property %s does not exist" - RTLConsts_SWriteError, "Stream write error" - RTLConsts_SThreadCreateError, "Thread creation error: %s" - RTLConsts_SThreadError, "Thread Error: %s (%d)" - RTLConsts_sWindowsSocketError, "Windows socket error: %s (%d), on API '%s'" - RTLConsts_sAsyncSocketError, "Asynchronous socket error %d" - RTLConsts_sNoAddress, "No address specified" - RTLConsts_sCannotListenOnOpen, "Can't listen on an open socket" - RTLConsts_sCannotCreateSocket, "Can't create new socket" - RTLConsts_sSocketAlreadyOpen, "Socket already open" - RTLConsts_sCantChangeWhileActive, "Can't change value while socket is active" - Consts_SInvalidBitmap, "Bitmap image is not valid" - Consts_SInvalidIcon, "Icon image is not valid" - Consts_SChangeIconSize, "Cannot change the size of an icon" - Consts_SUnknownClipboardFormat, "Unsupported clipboard format" - Consts_SOutOfResources, "Out of system resources" - RTLConsts_SInvalidImage, "Invalid stream format" - RTLConsts_SInvalidName, "''%s'' is not a valid component name" - RTLConsts_SInvalidProperty, "Invalid property value" - RTLConsts_SInvalidPropertyPath, "Invalid property path" - RTLConsts_SInvalidPropertyValue, "Invalid property value" - RTLConsts_SListCapacityError, "List capacity out of bounds (%d)" - RTLConsts_SListCountError, "List count out of bounds (%d)" - RTLConsts_SListIndexError, "List index out of bounds (%d)" - RTLConsts_SMemoryStreamError, "Out of memory while expanding memory stream" - RTLConsts_SPropertyException, "Error reading %s%s%s: %s" - RTLConsts_SReadError, "Stream read error" - RTLConsts_SReadOnlyProperty, "Property is read-only" - RTLConsts_SResNotFound, "Resource %s not found" - RTLConsts_SSeekNotImplemented, "%s.Seek not implemented" - RTLConsts_SSortedListError, "Operation not allowed on sorted list" - RTLConsts_SUnknownGroup, "%s not in a class registration group" - SysConst_SLongDayNameThu, "Thursday" - SysConst_SLongDayNameFri, "Friday" - SysConst_SLongDayNameSat, "Saturday" - RTLConsts_SAncestorNotFound, "Ancestor for '%s' not found" - RTLConsts_SAssignError, "Cannot assign a %s to a %s" - RTLConsts_SBitsIndexError, "Bits index out of range" - RTLConsts_SCantWriteResourceStreamError, "Can't write to a read-only resource stream" - RTLConsts_SCheckSynchronizeError, "CheckSynchronize called from thread $%x, which is NOT the main thread" - RTLConsts_SClassNotFound, "Class %s not found" - RTLConsts_SDuplicateClass, "A class named %s already exists" - RTLConsts_SDuplicateItem, "List does not allow duplicates ($0%x)" - RTLConsts_SDuplicateName, "A component named %s already exists" - RTLConsts_SDuplicateString, "String list does not allow duplicates" - RTLConsts_SFCreateError, "Cannot create file %s" - RTLConsts_SFOpenError, "Cannot open file %s" - RTLConsts_SIniFileWriteError, "Unable to write to %s" - SysConst_SLongMonthNameAug, "August" - SysConst_SLongMonthNameSep, "September" - SysConst_SLongMonthNameOct, "October" - SysConst_SLongMonthNameNov, "November" - SysConst_SLongMonthNameDec, "December" - SysConst_SShortDayNameSun, "Sun" - SysConst_SShortDayNameMon, "Mon" - SysConst_SShortDayNameTue, "Tue" - SysConst_SShortDayNameWed, "Wed" - SysConst_SShortDayNameThu, "Thu" - SysConst_SShortDayNameFri, "Fri" - SysConst_SShortDayNameSat, "Sat" - SysConst_SLongDayNameSun, "Sunday" - SysConst_SLongDayNameMon, "Monday" - SysConst_SLongDayNameTue, "Tuesday" - SysConst_SLongDayNameWed, "Wednesday" - SysConst_SShortMonthNameApr, "Apr" - SysConst_SShortMonthNameMay, "May" - SysConst_SShortMonthNameJun, "Jun" - SysConst_SShortMonthNameJul, "Jul" - SysConst_SShortMonthNameAug, "Aug" - SysConst_SShortMonthNameSep, "Sep" - SysConst_SShortMonthNameOct, "Oct" - SysConst_SShortMonthNameNov, "Nov" - SysConst_SShortMonthNameDec, "Dec" - SysConst_SLongMonthNameJan, "January" - SysConst_SLongMonthNameFeb, "February" - SysConst_SLongMonthNameMar, "March" - SysConst_SLongMonthNameApr, "April" - SysConst_SLongMonthNameMay, "May" - SysConst_SLongMonthNameJun, "June" - SysConst_SLongMonthNameJul, "July" - SysConst_SVarInvalid, "Invalid argument" - SysConst_SVarBadType, "Invalid variant type" - SysConst_SVarNotImplemented, "Operation not supported" - SysConst_SVarUnexpected, "Unexpected variant error" - SysConst_SExternalException, "External exception %x" - SysConst_SAssertionFailed, "Assertion failed" - SysConst_SIntfCastError, "Interface not supported" - SysConst_SSafecallException, "Exception in safecall method" - SysConst_SAssertError, "%s (%s, line %d)" - SysConst_SAbstractError, "Abstract Error" - SysConst_SModuleAccessViolation, "Access violation at address %p in module '%s'. %s of address %p" - SysConst_SOSError, "System Error. Code: %d.\r\n%s" - SysConst_SUnkOSError, "A call to an OS function failed" - SysConst_SShortMonthNameJan, "Jan" - SysConst_SShortMonthNameFeb, "Feb" - SysConst_SShortMonthNameMar, "Mar" - SysConst_SInvalidFormat, "Format '%s' invalid or incompatible with argument" - SysConst_SArgumentMissing, "No argument for format '%s'" - SysConst_SDispatchError, "Variant method calls not supported" - SysConst_SReadAccess, "Read" - SysConst_SWriteAccess, "Write" - SysConst_SVarArrayCreate, "Error creating variant array" - SysConst_SVarArrayBounds, "Variant array index out of bounds" - SysConst_SVarArrayLocked, "Variant array is locked" - SysConst_SInvalidVarCast, "Invalid variant type conversion" - SysConst_SInvalidVarOp, "Invalid variant operation" - SysConst_SInvalidVarOpWithHResult, "Invalid variant operation ($%.8x)" - SysConst_SVarNotArray, "Variant is not an array" - SysConst_SInvalidVarNullOp, "Invalid NULL variant operation" - SysConst_SVarTypeCouldNotConvert, "Could not convert variant of type (%s) into type (%s)" - SysConst_SVarTypeConvertOverflow, "Overflow while converting variant of type (%s) into type (%s)" - SysConst_SVarOverflow, "Variant overflow" - SysConst_SDivByZero, "Division by zero" - SysConst_SRangeError, "Range check error" - SysConst_SIntOverflow, "Integer overflow" - SysConst_SInvalidOp, "Invalid floating point operation" - SysConst_SZeroDivide, "Floating point division by zero" - SysConst_SOverflow, "Floating point overflow" - SysConst_SUnderflow, "Floating point underflow" - SysConst_SInvalidPointer, "Invalid pointer operation" - SysConst_SInvalidCast, "Invalid class typecast" - SysConst_SAccessViolation, "Access violation at address %p. %s of address %p" - SysConst_SStackOverflow, "Stack overflow" - SysConst_SControlC, "Control-C hit" - SysConst_SPrivilege, "Privileged instruction" - SysConst_SOperationAborted, "Operation aborted" - SysConst_SException, "Exception %s in module %s at %p.\r\n%s%s\r\n" - SysConst_SExceptTitle, "Application Error" - SysConst_SInvalidInteger, "'%s' is not a valid integer value" - SysConst_SInvalidFloat, "'%s' is not a valid floating point value" - SysConst_SInvalidDate, "'%s' is not a valid date" - SysConst_SInvalidTime, "'%s' is not a valid time" - SysConst_SInvalidDateTime, "'%s' is not a valid date and time" - SysConst_STimeEncodeError, "Invalid argument to time encode" - SysConst_SDateEncodeError, "Invalid argument to date encode" - SysConst_SOutOfMemory, "Out of memory" - SysConst_SInOutError, "I/O error %d" - SysConst_SFileNotFound, "File not found" - SysConst_SInvalidFilename, "Invalid filename" - SysConst_STooManyOpenFiles, "Too many open files" - SysConst_SAccessDenied, "File access denied" - SysConst_SEndOfFile, "Read beyond end of file" - SysConst_SDiskFull, "Disk full" - SysConst_SInvalidInput, "Invalid numeric input" -END - +/* VER140 + Generated by the Borland Delphi Pascal Compiler + because -GD or --drc was supplied to the compiler. + + This file contains compiler-generated resources that + were bound to the executable. + If this file is empty, then no compiler-generated + resources were bound to the produced executable. +*/ + +#define JclResources_RsIntelCacheDescr7C 65168 +#define JclResources_RsIntelCacheDescr7D 65169 +#define JclResources_RsIntelCacheDescr7F 65170 +#define JclResources_RsIntelCacheDescr82 65171 +#define JclResources_RsIntelCacheDescr83 65172 +#define JclResources_RsIntelCacheDescr84 65173 +#define JclResources_RsIntelCacheDescr85 65174 +#define JclResources_RsIntelCacheDescr86 65175 +#define JclResources_RsIntelCacheDescr87 65176 +#define JclResources_RsIntelCacheDescrB0 65177 +#define JclResources_RsIntelCacheDescrB3 65178 +#define JclResources_RsIntelCacheDescrF0 65179 +#define JclResources_RsIntelCacheDescrF1 65180 +#define JclResources_RsIntelCacheDescr51 65184 +#define JclResources_RsIntelCacheDescr52 65185 +#define JclResources_RsIntelCacheDescr5B 65186 +#define JclResources_RsIntelCacheDescr5C 65187 +#define JclResources_RsIntelCacheDescr5D 65188 +#define JclResources_RsIntelCacheDescr60 65189 +#define JclResources_RsIntelCacheDescr66 65190 +#define JclResources_RsIntelCacheDescr67 65191 +#define JclResources_RsIntelCacheDescr68 65192 +#define JclResources_RsIntelCacheDescr70 65193 +#define JclResources_RsIntelCacheDescr71 65194 +#define JclResources_RsIntelCacheDescr72 65195 +#define JclResources_RsIntelCacheDescr78 65196 +#define JclResources_RsIntelCacheDescr79 65197 +#define JclResources_RsIntelCacheDescr7A 65198 +#define JclResources_RsIntelCacheDescr7B 65199 +#define JclResources_RsIntelCacheDescr08 65200 +#define JclResources_RsIntelCacheDescr0A 65201 +#define JclResources_RsIntelCacheDescr0C 65202 +#define JclResources_RsIntelCacheDescr22 65203 +#define JclResources_RsIntelCacheDescr23 65204 +#define JclResources_RsIntelCacheDescr25 65205 +#define JclResources_RsIntelCacheDescr29 65206 +#define JclResources_RsIntelCacheDescr2C 65207 +#define JclResources_RsIntelCacheDescr30 65208 +#define JclResources_RsIntelCacheDescr40 65209 +#define JclResources_RsIntelCacheDescr41 65210 +#define JclResources_RsIntelCacheDescr42 65211 +#define JclResources_RsIntelCacheDescr43 65212 +#define JclResources_RsIntelCacheDescr44 65213 +#define JclResources_RsIntelCacheDescr45 65214 +#define JclResources_RsIntelCacheDescr50 65215 +#define JvResources_RsClInfoBk 65216 +#define JvResources_RsGradientActiveCaption 65217 +#define JvResources_RsGradientInactiveCaption 65218 +#define JvResources_RsHotLight 65219 +#define JvResources_RsMenuBar 65220 +#define JvResources_RsMenuHighlight 65221 +#define ComConst_SOleError 65222 +#define ComConst_SNoMethod 65223 +#define ComConst_SVarNotObject 65224 +#define ComConst_STooManyParams 65225 +#define JclResources_RsIntelCacheDescr00 65226 +#define JclResources_RsIntelCacheDescr01 65227 +#define JclResources_RsIntelCacheDescr02 65228 +#define JclResources_RsIntelCacheDescr03 65229 +#define JclResources_RsIntelCacheDescr04 65230 +#define JclResources_RsIntelCacheDescr06 65231 +#define JvResources_RsClWindowText 65232 +#define JvResources_RsClCaptionText 65233 +#define JvResources_RsClActiveBorder 65234 +#define JvResources_RsClInactiveBorder 65235 +#define JvResources_RsClAppWorkSpace 65236 +#define JvResources_RsClHighlight 65237 +#define JvResources_RsClHighlightText 65238 +#define JvResources_RsClBtnFace 65239 +#define JvResources_RsClBtnShadow 65240 +#define JvResources_RsClGrayText 65241 +#define JvResources_RsClBtnText 65242 +#define JvResources_RsClInactiveCaptionText 65243 +#define JvResources_RsClBtnHighlight 65244 +#define JvResources_RsCl3DDkShadow 65245 +#define JvResources_RsCl3DLight 65246 +#define JvResources_RsClInfoText 65247 +#define JvResources_RsClGray25 65248 +#define JvResources_RsClRose 65249 +#define JvResources_RsClTan 65250 +#define JvResources_RsClLightYellow 65251 +#define JvResources_RsClLightGreen 65252 +#define JvResources_RsClLightTurquoise 65253 +#define JvResources_RsClPaleBlue 65254 +#define JvResources_RsClLavender 65255 +#define JvResources_RsClScrollBar 65256 +#define JvResources_RsClBackground 65257 +#define JvResources_RsClActiveCaption 65258 +#define JvResources_RsClInactiveCaption 65259 +#define JvResources_RsClMenu 65260 +#define JvResources_RsClWindow 65261 +#define JvResources_RsClWindowFrame 65262 +#define JvResources_RsClMenuText 65263 +#define JvResources_RsClGray80 65264 +#define JvResources_RsClDarkRed 65265 +#define JvResources_RsClOrange 65266 +#define JvResources_RsClDarkYellow 65267 +#define JvResources_RsClBlueGray 65268 +#define JvResources_RsClGray50 65269 +#define JvResources_RsClLightOrange 65270 +#define JvResources_RsClSeaGreen 65271 +#define JvResources_RsClLightBlue 65272 +#define JvResources_RsClViolet 65273 +#define JvResources_RsClGray40 65274 +#define JvResources_RsClPink 65275 +#define JvResources_RsClGold 65276 +#define JvResources_RsClBrightGreen 65277 +#define JvResources_RsClTurquoise 65278 +#define JvResources_RsClPlum 65279 +#define JvResources_RsClLime 65280 +#define JvResources_RsClYellow 65281 +#define JvResources_RsClBlue 65282 +#define JvResources_RsClFuchsia 65283 +#define JvResources_RsClAqua 65284 +#define JvResources_RsClWhite 65285 +#define JvResources_RsClMoneyGreen 65286 +#define JvResources_RsClSkyBlue 65287 +#define JvResources_RsClCream 65288 +#define JvResources_RsClMedGray 65289 +#define JvResources_RsClBrown 65290 +#define JvResources_RsClOliveGreen 65291 +#define JvResources_RsClDarkGreen 65292 +#define JvResources_RsClDarkTeal 65293 +#define JvResources_RsClDarkBlue 65294 +#define JvResources_RsClIndigo 65295 +#define HelpIntfs_hNoTopics 65296 +#define ComStrs_sInvalidOwner 65297 +#define ComStrs_sRichEditInsertError 65298 +#define ComStrs_sRichEditLoadFail 65299 +#define ComStrs_sRichEditSaveFail 65300 +#define ComStrs_sInvalidComCtl32 65301 +#define JvResources_RsClBlack 65302 +#define JvResources_RsClMaroon 65303 +#define JvResources_RsClGreen 65304 +#define JvResources_RsClOlive 65305 +#define JvResources_RsClNavy 65306 +#define JvResources_RsClPurple 65307 +#define JvResources_RsClTeal 65308 +#define JvResources_RsClGray 65309 +#define JvResources_RsClSilver 65310 +#define JvResources_RsClRed 65311 +#define Consts_SmkcDel 65312 +#define Consts_SmkcShift 65313 +#define Consts_SmkcCtrl 65314 +#define Consts_SmkcAlt 65315 +#define Consts_SInsertLineError 65316 +#define Consts_SIconToClipboard 65317 +#define Consts_SInvalidMemoSize 65318 +#define Consts_SNoDefaultPrinter 65319 +#define Consts_SDuplicateMenus 65320 +#define Consts_SDockedCtlNeedsName 65321 +#define Consts_SDockTreeRemoveError 65322 +#define Consts_SDockZoneNotFound 65323 +#define Consts_SDockZoneHasNoCtl 65324 +#define HelpIntfs_hNoTableOfContents 65325 +#define HelpIntfs_hNothingFound 65326 +#define HelpIntfs_hNoContext 65327 +#define Consts_SMsgDlgNoToAll 65328 +#define Consts_SMsgDlgYesToAll 65329 +#define Consts_SmkcBkSp 65330 +#define Consts_SmkcTab 65331 +#define Consts_SmkcEsc 65332 +#define Consts_SmkcEnter 65333 +#define Consts_SmkcSpace 65334 +#define Consts_SmkcPgUp 65335 +#define Consts_SmkcPgDn 65336 +#define Consts_SmkcEnd 65337 +#define Consts_SmkcHome 65338 +#define Consts_SmkcLeft 65339 +#define Consts_SmkcUp 65340 +#define Consts_SmkcRight 65341 +#define Consts_SmkcDown 65342 +#define Consts_SmkcIns 65343 +#define Consts_SAbortButton 65344 +#define Consts_SAllButton 65345 +#define Consts_SCannotDragForm 65346 +#define Consts_SMsgDlgWarning 65347 +#define Consts_SMsgDlgError 65348 +#define Consts_SMsgDlgInformation 65349 +#define Consts_SMsgDlgConfirm 65350 +#define Consts_SMsgDlgYes 65351 +#define Consts_SMsgDlgNo 65352 +#define Consts_SMsgDlgOK 65353 +#define Consts_SMsgDlgCancel 65354 +#define Consts_SMsgDlgHelp 65355 +#define Consts_SMsgDlgAbort 65356 +#define Consts_SMsgDlgRetry 65357 +#define Consts_SMsgDlgIgnore 65358 +#define Consts_SMsgDlgAll 65359 +#define Consts_SNoTimers 65360 +#define Consts_SNotPrinting 65361 +#define Consts_SPrinting 65362 +#define Consts_SInvalidPrinter 65363 +#define Consts_SDeviceOnPort 65364 +#define Consts_SGroupIndexTooLow 65365 +#define Consts_SNoMDIForm 65366 +#define Consts_SControlParentSetToSelf 65367 +#define Consts_SOKButton 65368 +#define Consts_SCancelButton 65369 +#define Consts_SYesButton 65370 +#define Consts_SNoButton 65371 +#define Consts_SHelpButton 65372 +#define Consts_SCloseButton 65373 +#define Consts_SIgnoreButton 65374 +#define Consts_SRetryButton 65375 +#define Consts_SNoCanvasHandle 65376 +#define Consts_SInvalidImageSize 65377 +#define Consts_SInvalidImageList 65378 +#define Consts_SImageIndexError 65379 +#define Consts_SImageReadFail 65380 +#define Consts_SImageWriteFail 65381 +#define Consts_SWindowDCError 65382 +#define Consts_SWindowClass 65383 +#define Consts_SCannotFocus 65384 +#define Consts_SParentRequired 65385 +#define Consts_SMDIChildNotVisible 65386 +#define Consts_SVisibleChanged 65387 +#define Consts_SCannotShowModal 65388 +#define Consts_SMenuIndexError 65389 +#define Consts_SMenuReinserted 65390 +#define Consts_SMenuNotFound 65391 +#define RTLConsts_SUnknownProperty 65392 +#define RTLConsts_SWriteError 65393 +#define RTLConsts_SThreadCreateError 65394 +#define RTLConsts_SThreadError 65395 +#define RTLConsts_sWindowsSocketError 65396 +#define RTLConsts_sAsyncSocketError 65397 +#define RTLConsts_sNoAddress 65398 +#define RTLConsts_sCannotListenOnOpen 65399 +#define RTLConsts_sCannotCreateSocket 65400 +#define RTLConsts_sSocketAlreadyOpen 65401 +#define RTLConsts_sCantChangeWhileActive 65402 +#define Consts_SInvalidBitmap 65403 +#define Consts_SInvalidIcon 65404 +#define Consts_SChangeIconSize 65405 +#define Consts_SUnknownClipboardFormat 65406 +#define Consts_SOutOfResources 65407 +#define RTLConsts_SInvalidImage 65408 +#define RTLConsts_SInvalidName 65409 +#define RTLConsts_SInvalidProperty 65410 +#define RTLConsts_SInvalidPropertyPath 65411 +#define RTLConsts_SInvalidPropertyValue 65412 +#define RTLConsts_SListCapacityError 65413 +#define RTLConsts_SListCountError 65414 +#define RTLConsts_SListIndexError 65415 +#define RTLConsts_SMemoryStreamError 65416 +#define RTLConsts_SPropertyException 65417 +#define RTLConsts_SReadError 65418 +#define RTLConsts_SReadOnlyProperty 65419 +#define RTLConsts_SResNotFound 65420 +#define RTLConsts_SSeekNotImplemented 65421 +#define RTLConsts_SSortedListError 65422 +#define RTLConsts_SUnknownGroup 65423 +#define SysConst_SLongDayNameThu 65424 +#define SysConst_SLongDayNameFri 65425 +#define SysConst_SLongDayNameSat 65426 +#define RTLConsts_SAncestorNotFound 65427 +#define RTLConsts_SAssignError 65428 +#define RTLConsts_SBitsIndexError 65429 +#define RTLConsts_SCantWriteResourceStreamError 65430 +#define RTLConsts_SCheckSynchronizeError 65431 +#define RTLConsts_SClassNotFound 65432 +#define RTLConsts_SDuplicateClass 65433 +#define RTLConsts_SDuplicateItem 65434 +#define RTLConsts_SDuplicateName 65435 +#define RTLConsts_SDuplicateString 65436 +#define RTLConsts_SFCreateError 65437 +#define RTLConsts_SFOpenError 65438 +#define RTLConsts_SIniFileWriteError 65439 +#define SysConst_SLongMonthNameAug 65440 +#define SysConst_SLongMonthNameSep 65441 +#define SysConst_SLongMonthNameOct 65442 +#define SysConst_SLongMonthNameNov 65443 +#define SysConst_SLongMonthNameDec 65444 +#define SysConst_SShortDayNameSun 65445 +#define SysConst_SShortDayNameMon 65446 +#define SysConst_SShortDayNameTue 65447 +#define SysConst_SShortDayNameWed 65448 +#define SysConst_SShortDayNameThu 65449 +#define SysConst_SShortDayNameFri 65450 +#define SysConst_SShortDayNameSat 65451 +#define SysConst_SLongDayNameSun 65452 +#define SysConst_SLongDayNameMon 65453 +#define SysConst_SLongDayNameTue 65454 +#define SysConst_SLongDayNameWed 65455 +#define SysConst_SShortMonthNameApr 65456 +#define SysConst_SShortMonthNameMay 65457 +#define SysConst_SShortMonthNameJun 65458 +#define SysConst_SShortMonthNameJul 65459 +#define SysConst_SShortMonthNameAug 65460 +#define SysConst_SShortMonthNameSep 65461 +#define SysConst_SShortMonthNameOct 65462 +#define SysConst_SShortMonthNameNov 65463 +#define SysConst_SShortMonthNameDec 65464 +#define SysConst_SLongMonthNameJan 65465 +#define SysConst_SLongMonthNameFeb 65466 +#define SysConst_SLongMonthNameMar 65467 +#define SysConst_SLongMonthNameApr 65468 +#define SysConst_SLongMonthNameMay 65469 +#define SysConst_SLongMonthNameJun 65470 +#define SysConst_SLongMonthNameJul 65471 +#define SysConst_SVarInvalid 65472 +#define SysConst_SVarBadType 65473 +#define SysConst_SVarNotImplemented 65474 +#define SysConst_SVarUnexpected 65475 +#define SysConst_SExternalException 65476 +#define SysConst_SAssertionFailed 65477 +#define SysConst_SIntfCastError 65478 +#define SysConst_SSafecallException 65479 +#define SysConst_SAssertError 65480 +#define SysConst_SAbstractError 65481 +#define SysConst_SModuleAccessViolation 65482 +#define SysConst_SOSError 65483 +#define SysConst_SUnkOSError 65484 +#define SysConst_SShortMonthNameJan 65485 +#define SysConst_SShortMonthNameFeb 65486 +#define SysConst_SShortMonthNameMar 65487 +#define SysConst_SInvalidFormat 65488 +#define SysConst_SArgumentMissing 65489 +#define SysConst_SDispatchError 65490 +#define SysConst_SReadAccess 65491 +#define SysConst_SWriteAccess 65492 +#define SysConst_SVarArrayCreate 65493 +#define SysConst_SVarArrayBounds 65494 +#define SysConst_SVarArrayLocked 65495 +#define SysConst_SInvalidVarCast 65496 +#define SysConst_SInvalidVarOp 65497 +#define SysConst_SInvalidVarOpWithHResult 65498 +#define SysConst_SVarNotArray 65499 +#define SysConst_SInvalidVarNullOp 65500 +#define SysConst_SVarTypeCouldNotConvert 65501 +#define SysConst_SVarTypeConvertOverflow 65502 +#define SysConst_SVarOverflow 65503 +#define SysConst_SDivByZero 65504 +#define SysConst_SRangeError 65505 +#define SysConst_SIntOverflow 65506 +#define SysConst_SInvalidOp 65507 +#define SysConst_SZeroDivide 65508 +#define SysConst_SOverflow 65509 +#define SysConst_SUnderflow 65510 +#define SysConst_SInvalidPointer 65511 +#define SysConst_SInvalidCast 65512 +#define SysConst_SAccessViolation 65513 +#define SysConst_SStackOverflow 65514 +#define SysConst_SControlC 65515 +#define SysConst_SPrivilege 65516 +#define SysConst_SOperationAborted 65517 +#define SysConst_SException 65518 +#define SysConst_SExceptTitle 65519 +#define SysConst_SInvalidInteger 65520 +#define SysConst_SInvalidFloat 65521 +#define SysConst_SInvalidDate 65522 +#define SysConst_SInvalidTime 65523 +#define SysConst_SInvalidDateTime 65524 +#define SysConst_STimeEncodeError 65525 +#define SysConst_SDateEncodeError 65526 +#define SysConst_SOutOfMemory 65527 +#define SysConst_SInOutError 65528 +#define SysConst_SFileNotFound 65529 +#define SysConst_SInvalidFilename 65530 +#define SysConst_STooManyOpenFiles 65531 +#define SysConst_SAccessDenied 65532 +#define SysConst_SEndOfFile 65533 +#define SysConst_SDiskFull 65534 +#define SysConst_SInvalidInput 65535 +STRINGTABLE +BEGIN + JclResources_RsIntelCacheDescr7C, "2° Level cache, 1 MBytes, 8-way set associative, dual-sectored line, 64 Bytes sector size" + JclResources_RsIntelCacheDescr7D, "2° Level cache, 2 MByte, 8-way set associative, 64byte line size" + JclResources_RsIntelCacheDescr7F, "2° Level cache, 512 KByte, 2-way set associative, 64-byte line size" + JclResources_RsIntelCacheDescr82, "2° Level cache, 256 KBytes, 8-way associative, 32 Bytes line size" + JclResources_RsIntelCacheDescr83, "2° Level cache, 512 KBytes, 8-way associative, 32 Bytes line size" + JclResources_RsIntelCacheDescr84, "2° Level cache, 1 MBytes, 8-way associative, 32 Bytes line size" + JclResources_RsIntelCacheDescr85, "2° Level cache, 2 MBytes, 8-way associative, 32 Bytes line size" + JclResources_RsIntelCacheDescr86, "2° Level cache, 512 KByte, 4-way set associative, 64 byte line size" + JclResources_RsIntelCacheDescr87, "2° Level cache, 1 MByte, 8-way set associative, 64 byte line size" + JclResources_RsIntelCacheDescrB0, "Instruction TLB, 4 KByte Pages, 4-way set associative, 128 entries" + JclResources_RsIntelCacheDescrB3, "Data TLB, 4 KByte Pages, 4-way set associative, 128 entries" + JclResources_RsIntelCacheDescrF0, "64-Byte Prefetching" + JclResources_RsIntelCacheDescrF1, "128-Byte Prefetching" + JclResources_RsIntelCacheDescr51, "Instruction TLB, 4 KBytes and 2 MBytes or 4 MBytes pages, 128 Entries" + JclResources_RsIntelCacheDescr52, "Instruction TLB, 4 KBytes and 2 MBytes or 4 MBytes pages, 256 Entries" + JclResources_RsIntelCacheDescr5B, "Data TLB, 4 KBytes and 4 MBytes pages, 64 Entries" + JclResources_RsIntelCacheDescr5C, "Data TLB, 4 KBytes and 4 MBytes pages, 128 Entries" + JclResources_RsIntelCacheDescr5D, "Data TLB, 4 KBytes and 4 MBytes pages, 256 Entries" + JclResources_RsIntelCacheDescr60, "1° Level data cache: 16 KByte, 8-way set associative, 64 byte line size" + JclResources_RsIntelCacheDescr66, "1° Level Data cache, 8 KBytes, 4-way set associative, 64 Bytes line size" + JclResources_RsIntelCacheDescr67, "1° Level Data cache, 16 KBytes, 4-way set associative, 64 Bytes line size" + JclResources_RsIntelCacheDescr68, "1° Level Data cache, 32 KBytes, 4-way set associative, 64 Bytes line size" + JclResources_RsIntelCacheDescr70, "Trace cache, 12 KµOps, 8-way set associative" + JclResources_RsIntelCacheDescr71, "Trace cache, 16 KµOps, 8-way set associative" + JclResources_RsIntelCacheDescr72, "Trace cache, 32 KµOps, 8-way set associative" + JclResources_RsIntelCacheDescr78, "2° Level cache, 1 MBytes, 4-way set associative, 64 Bytes line size" + JclResources_RsIntelCacheDescr79, "2° Level cache, 128 KBytes, 8-way set associative, dual-sectored line, 64 Bytes sector size" + JclResources_RsIntelCacheDescr7A, "2° Level cache, 256 KBytes, 8-way set associative, dual-sectored line, 64 Bytes sector size" + JclResources_RsIntelCacheDescr7B, "2° Level cache, 512 KBytes, 8-way set associative, dual-sectored line, 64 Bytes sector size" + JclResources_RsIntelCacheDescr08, "16KB instruction cache, 4-way set associative, 32 byte line size" + JclResources_RsIntelCacheDescr0A, "8KB data cache 2-way set associative, 32 byte line size" + JclResources_RsIntelCacheDescr0C, "16KB data cache, 4-way set associative, 32 byte line size" + JclResources_RsIntelCacheDescr22, "3° Level cache, 512 KBytes, 4-way set associative, 2 lines per sector, 128 byte sector size" + JclResources_RsIntelCacheDescr23, "3° Level cache, 1 MBytes, 8-way set associative, 2 lines per sector, 128 byte sector size" + JclResources_RsIntelCacheDescr25, "3° Level cache, 2 MBytes, 8-way set associative, 2 lines per sector, 128 byte line size" + JclResources_RsIntelCacheDescr29, "3° Level cache, 4M Bytes, 8-way set associative, 2 lines per sector, 128 byte line size" + JclResources_RsIntelCacheDescr2C, "1° Level data cache: 32K Bytes, 8-way set associative, 64 byte line size" + JclResources_RsIntelCacheDescr30, "1° Level instruction cache: 32K Bytes, 8-way set associative, 64 byte line size" + JclResources_RsIntelCacheDescr40, "No L2 cache" + JclResources_RsIntelCacheDescr41, "Unified cache, 32 byte cache line, 4-way set associative, 128Kb" + JclResources_RsIntelCacheDescr42, "Unified cache, 32 byte cache line, 4-way set associative, 256Kb" + JclResources_RsIntelCacheDescr43, "Unified cache, 32 byte cache line, 4-way set associative, 512Kb" + JclResources_RsIntelCacheDescr44, "Unified cache, 32 byte cache line, 4-way set associative, 1Mb" + JclResources_RsIntelCacheDescr45, "Unified cache, 32 byte cache line, 4-way set associative, 2Mb" + JclResources_RsIntelCacheDescr50, "Instruction TLB, 4 KBytes and 2 MBytes or 4 MBytes pages, 64 Entries" + JvResources_RsClInfoBk, "Tooltip background" + JvResources_RsGradientActiveCaption, "Gradient Active Caption" + JvResources_RsGradientInactiveCaption, "Gradient Inactive Caption" + JvResources_RsHotLight, "Hot Light" + JvResources_RsMenuBar, "Menu Bar" + JvResources_RsMenuHighlight, "Menu Highlight" + ComConst_SOleError, "OLE error %.8x" + ComConst_SNoMethod, "Method '%s' not supported by automation object" + ComConst_SVarNotObject, "Variant does not reference an automation object" + ComConst_STooManyParams, "Dispatch methods do not support more than 64 parameters" + JclResources_RsIntelCacheDescr00, "Null descriptor" + JclResources_RsIntelCacheDescr01, "Instruction TLB, 4Kb pages, 4-way set associative, 32 entries" + JclResources_RsIntelCacheDescr02, "Instruction TLB, 4Mb pages, fully associative, 2 entries" + JclResources_RsIntelCacheDescr03, "Data TLB, 4Kb pages, 4-way set associative, 64 entries" + JclResources_RsIntelCacheDescr04, "Data TLB, 4Mb pages, 4-way set associative, 8 entries" + JclResources_RsIntelCacheDescr06, "8KB instruction cache, 4-way set associative, 32 byte line size" + JvResources_RsClWindowText, "Window text" + JvResources_RsClCaptionText, "Active window title bar text" + JvResources_RsClActiveBorder, "Active window border" + JvResources_RsClInactiveBorder, "Inactive window border" + JvResources_RsClAppWorkSpace, "Application workspace" + JvResources_RsClHighlight, "Selection background" + JvResources_RsClHighlightText, "Selection text" + JvResources_RsClBtnFace, "Button face" + JvResources_RsClBtnShadow, "Button shadow" + JvResources_RsClGrayText, "Dimmed text" + JvResources_RsClBtnText, "Button text" + JvResources_RsClInactiveCaptionText, "Inactive window title bar text" + JvResources_RsClBtnHighlight, "Button highlight" + JvResources_RsCl3DDkShadow, "Dark shadow 3D elements" + JvResources_RsCl3DLight, "Highlight 3D elements" + JvResources_RsClInfoText, "Tooltip text" + JvResources_RsClGray25, "Gray 25%" + JvResources_RsClRose, "Rose" + JvResources_RsClTan, "Tan" + JvResources_RsClLightYellow, "Light Yellow" + JvResources_RsClLightGreen, "Light Green" + JvResources_RsClLightTurquoise, "Light Turquoise" + JvResources_RsClPaleBlue, "Pale Blue" + JvResources_RsClLavender, "Lavender" + JvResources_RsClScrollBar, "Scrollbar" + JvResources_RsClBackground, "Desktop background" + JvResources_RsClActiveCaption, "Active window title bar" + JvResources_RsClInactiveCaption, "Inactive window title bar" + JvResources_RsClMenu, "Menu background" + JvResources_RsClWindow, "Window background" + JvResources_RsClWindowFrame, "Window frame" + JvResources_RsClMenuText, "Menu text" + JvResources_RsClGray80, "Gray 80%" + JvResources_RsClDarkRed, "Dark Red" + JvResources_RsClOrange, "Orange" + JvResources_RsClDarkYellow, "Dark Yellow" + JvResources_RsClBlueGray, "Blue Gray" + JvResources_RsClGray50, "Gray 50%" + JvResources_RsClLightOrange, "Light Orange" + JvResources_RsClSeaGreen, "Sea Green" + JvResources_RsClLightBlue, "Light Blue" + JvResources_RsClViolet, "Violet" + JvResources_RsClGray40, "Gray 40%" + JvResources_RsClPink, "Pink" + JvResources_RsClGold, "Gold" + JvResources_RsClBrightGreen, "Bright Green" + JvResources_RsClTurquoise, "Turquoise" + JvResources_RsClPlum, "Plum" + JvResources_RsClLime, "Lime" + JvResources_RsClYellow, "Yellow" + JvResources_RsClBlue, "Blue" + JvResources_RsClFuchsia, "Fuchsia" + JvResources_RsClAqua, "Aqua" + JvResources_RsClWhite, "White" + JvResources_RsClMoneyGreen, "Money green" + JvResources_RsClSkyBlue, "Sky blue" + JvResources_RsClCream, "Cream" + JvResources_RsClMedGray, "Medium gray" + JvResources_RsClBrown, "Brown" + JvResources_RsClOliveGreen, "Olive Green" + JvResources_RsClDarkGreen, "Dark Green" + JvResources_RsClDarkTeal, "Dark Teal" + JvResources_RsClDarkBlue, "Dark Blue" + JvResources_RsClIndigo, "Indigo" + HelpIntfs_hNoTopics, "No topic-based help system installed" + ComStrs_sInvalidOwner, "Invalid owner" + ComStrs_sRichEditInsertError, "RichEdit line insertion error" + ComStrs_sRichEditLoadFail, "Failed to Load Stream" + ComStrs_sRichEditSaveFail, "Failed to Save Stream" + ComStrs_sInvalidComCtl32, "This control requires version 4.70 or greater of COMCTL32.DLL" + JvResources_RsClBlack, "Black" + JvResources_RsClMaroon, "Maroon" + JvResources_RsClGreen, "Green" + JvResources_RsClOlive, "Olive green" + JvResources_RsClNavy, "Navy blue" + JvResources_RsClPurple, "Purple" + JvResources_RsClTeal, "Teal" + JvResources_RsClGray, "Gray" + JvResources_RsClSilver, "Silver" + JvResources_RsClRed, "Red" + Consts_SmkcDel, "Del" + Consts_SmkcShift, "Shift+" + Consts_SmkcCtrl, "Ctrl+" + Consts_SmkcAlt, "Alt+" + Consts_SInsertLineError, "Unable to insert a line" + Consts_SIconToClipboard, "Clipboard does not support Icons" + Consts_SInvalidMemoSize, "Text exceeds memo capacity" + Consts_SNoDefaultPrinter, "There is no default printer currently selected" + Consts_SDuplicateMenus, "Menu '%s' is already being used by another form" + Consts_SDockedCtlNeedsName, "Docked control must have a name" + Consts_SDockTreeRemoveError, "Error removing control from dock tree" + Consts_SDockZoneNotFound, " - Dock zone not found" + Consts_SDockZoneHasNoCtl, " - Dock zone has no control" + HelpIntfs_hNoTableOfContents, "Unable to find a Table of Contents" + HelpIntfs_hNothingFound, "No help found for %s" + HelpIntfs_hNoContext, "No context-sensitive help installed" + Consts_SMsgDlgNoToAll, "N&o to All" + Consts_SMsgDlgYesToAll, "Yes to &All" + Consts_SmkcBkSp, "BkSp" + Consts_SmkcTab, "Tab" + Consts_SmkcEsc, "Esc" + Consts_SmkcEnter, "Enter" + Consts_SmkcSpace, "Space" + Consts_SmkcPgUp, "PgUp" + Consts_SmkcPgDn, "PgDn" + Consts_SmkcEnd, "End" + Consts_SmkcHome, "Home" + Consts_SmkcLeft, "Left" + Consts_SmkcUp, "Up" + Consts_SmkcRight, "Right" + Consts_SmkcDown, "Down" + Consts_SmkcIns, "Ins" + Consts_SAbortButton, "Abort" + Consts_SAllButton, "&All" + Consts_SCannotDragForm, "Cannot drag a form" + Consts_SMsgDlgWarning, "Warning" + Consts_SMsgDlgError, "Error" + Consts_SMsgDlgInformation, "Information" + Consts_SMsgDlgConfirm, "Confirm" + Consts_SMsgDlgYes, "&Yes" + Consts_SMsgDlgNo, "&No" + Consts_SMsgDlgOK, "OK" + Consts_SMsgDlgCancel, "Cancel" + Consts_SMsgDlgHelp, "&Help" + Consts_SMsgDlgAbort, "&Abort" + Consts_SMsgDlgRetry, "&Retry" + Consts_SMsgDlgIgnore, "&Ignore" + Consts_SMsgDlgAll, "&All" + Consts_SNoTimers, "Not enough timers available" + Consts_SNotPrinting, "Printer is not currently printing" + Consts_SPrinting, "Printing in progress" + Consts_SInvalidPrinter, "Printer selected is not valid" + Consts_SDeviceOnPort, "%s on %s" + Consts_SGroupIndexTooLow, "GroupIndex cannot be less than a previous menu item's GroupIndex" + Consts_SNoMDIForm, "Cannot create form. No MDI forms are currently active" + Consts_SControlParentSetToSelf, "A control cannot have itself as its parent" + Consts_SOKButton, "OK" + Consts_SCancelButton, "Cancel" + Consts_SYesButton, "&Yes" + Consts_SNoButton, "&No" + Consts_SHelpButton, "&Help" + Consts_SCloseButton, "&Close" + Consts_SIgnoreButton, "&Ignore" + Consts_SRetryButton, "&Retry" + Consts_SNoCanvasHandle, "Canvas does not allow drawing" + Consts_SInvalidImageSize, "Invalid image size" + Consts_SInvalidImageList, "Invalid ImageList" + Consts_SImageIndexError, "Invalid ImageList Index" + Consts_SImageReadFail, "Failed to read ImageList data from stream" + Consts_SImageWriteFail, "Failed to write ImageList data to stream" + Consts_SWindowDCError, "Error creating window device context" + Consts_SWindowClass, "Error creating window class" + Consts_SCannotFocus, "Cannot focus a disabled or invisible window" + Consts_SParentRequired, "Control '%s' has no parent window" + Consts_SMDIChildNotVisible, "Cannot hide an MDI Child Form" + Consts_SVisibleChanged, "Cannot change Visible in OnShow or OnHide" + Consts_SCannotShowModal, "Cannot make a visible window modal" + Consts_SMenuIndexError, "Menu index out of range" + Consts_SMenuReinserted, "Menu inserted twice" + Consts_SMenuNotFound, "Sub-menu is not in menu" + RTLConsts_SUnknownProperty, "Property %s does not exist" + RTLConsts_SWriteError, "Stream write error" + RTLConsts_SThreadCreateError, "Thread creation error: %s" + RTLConsts_SThreadError, "Thread Error: %s (%d)" + RTLConsts_sWindowsSocketError, "Windows socket error: %s (%d), on API '%s'" + RTLConsts_sAsyncSocketError, "Asynchronous socket error %d" + RTLConsts_sNoAddress, "No address specified" + RTLConsts_sCannotListenOnOpen, "Can't listen on an open socket" + RTLConsts_sCannotCreateSocket, "Can't create new socket" + RTLConsts_sSocketAlreadyOpen, "Socket already open" + RTLConsts_sCantChangeWhileActive, "Can't change value while socket is active" + Consts_SInvalidBitmap, "Bitmap image is not valid" + Consts_SInvalidIcon, "Icon image is not valid" + Consts_SChangeIconSize, "Cannot change the size of an icon" + Consts_SUnknownClipboardFormat, "Unsupported clipboard format" + Consts_SOutOfResources, "Out of system resources" + RTLConsts_SInvalidImage, "Invalid stream format" + RTLConsts_SInvalidName, "''%s'' is not a valid component name" + RTLConsts_SInvalidProperty, "Invalid property value" + RTLConsts_SInvalidPropertyPath, "Invalid property path" + RTLConsts_SInvalidPropertyValue, "Invalid property value" + RTLConsts_SListCapacityError, "List capacity out of bounds (%d)" + RTLConsts_SListCountError, "List count out of bounds (%d)" + RTLConsts_SListIndexError, "List index out of bounds (%d)" + RTLConsts_SMemoryStreamError, "Out of memory while expanding memory stream" + RTLConsts_SPropertyException, "Error reading %s%s%s: %s" + RTLConsts_SReadError, "Stream read error" + RTLConsts_SReadOnlyProperty, "Property is read-only" + RTLConsts_SResNotFound, "Resource %s not found" + RTLConsts_SSeekNotImplemented, "%s.Seek not implemented" + RTLConsts_SSortedListError, "Operation not allowed on sorted list" + RTLConsts_SUnknownGroup, "%s not in a class registration group" + SysConst_SLongDayNameThu, "Thursday" + SysConst_SLongDayNameFri, "Friday" + SysConst_SLongDayNameSat, "Saturday" + RTLConsts_SAncestorNotFound, "Ancestor for '%s' not found" + RTLConsts_SAssignError, "Cannot assign a %s to a %s" + RTLConsts_SBitsIndexError, "Bits index out of range" + RTLConsts_SCantWriteResourceStreamError, "Can't write to a read-only resource stream" + RTLConsts_SCheckSynchronizeError, "CheckSynchronize called from thread $%x, which is NOT the main thread" + RTLConsts_SClassNotFound, "Class %s not found" + RTLConsts_SDuplicateClass, "A class named %s already exists" + RTLConsts_SDuplicateItem, "List does not allow duplicates ($0%x)" + RTLConsts_SDuplicateName, "A component named %s already exists" + RTLConsts_SDuplicateString, "String list does not allow duplicates" + RTLConsts_SFCreateError, "Cannot create file %s" + RTLConsts_SFOpenError, "Cannot open file %s" + RTLConsts_SIniFileWriteError, "Unable to write to %s" + SysConst_SLongMonthNameAug, "August" + SysConst_SLongMonthNameSep, "September" + SysConst_SLongMonthNameOct, "October" + SysConst_SLongMonthNameNov, "November" + SysConst_SLongMonthNameDec, "December" + SysConst_SShortDayNameSun, "Sun" + SysConst_SShortDayNameMon, "Mon" + SysConst_SShortDayNameTue, "Tue" + SysConst_SShortDayNameWed, "Wed" + SysConst_SShortDayNameThu, "Thu" + SysConst_SShortDayNameFri, "Fri" + SysConst_SShortDayNameSat, "Sat" + SysConst_SLongDayNameSun, "Sunday" + SysConst_SLongDayNameMon, "Monday" + SysConst_SLongDayNameTue, "Tuesday" + SysConst_SLongDayNameWed, "Wednesday" + SysConst_SShortMonthNameApr, "Apr" + SysConst_SShortMonthNameMay, "May" + SysConst_SShortMonthNameJun, "Jun" + SysConst_SShortMonthNameJul, "Jul" + SysConst_SShortMonthNameAug, "Aug" + SysConst_SShortMonthNameSep, "Sep" + SysConst_SShortMonthNameOct, "Oct" + SysConst_SShortMonthNameNov, "Nov" + SysConst_SShortMonthNameDec, "Dec" + SysConst_SLongMonthNameJan, "January" + SysConst_SLongMonthNameFeb, "February" + SysConst_SLongMonthNameMar, "March" + SysConst_SLongMonthNameApr, "April" + SysConst_SLongMonthNameMay, "May" + SysConst_SLongMonthNameJun, "June" + SysConst_SLongMonthNameJul, "July" + SysConst_SVarInvalid, "Invalid argument" + SysConst_SVarBadType, "Invalid variant type" + SysConst_SVarNotImplemented, "Operation not supported" + SysConst_SVarUnexpected, "Unexpected variant error" + SysConst_SExternalException, "External exception %x" + SysConst_SAssertionFailed, "Assertion failed" + SysConst_SIntfCastError, "Interface not supported" + SysConst_SSafecallException, "Exception in safecall method" + SysConst_SAssertError, "%s (%s, line %d)" + SysConst_SAbstractError, "Abstract Error" + SysConst_SModuleAccessViolation, "Access violation at address %p in module '%s'. %s of address %p" + SysConst_SOSError, "System Error. Code: %d.\r\n%s" + SysConst_SUnkOSError, "A call to an OS function failed" + SysConst_SShortMonthNameJan, "Jan" + SysConst_SShortMonthNameFeb, "Feb" + SysConst_SShortMonthNameMar, "Mar" + SysConst_SInvalidFormat, "Format '%s' invalid or incompatible with argument" + SysConst_SArgumentMissing, "No argument for format '%s'" + SysConst_SDispatchError, "Variant method calls not supported" + SysConst_SReadAccess, "Read" + SysConst_SWriteAccess, "Write" + SysConst_SVarArrayCreate, "Error creating variant array" + SysConst_SVarArrayBounds, "Variant array index out of bounds" + SysConst_SVarArrayLocked, "Variant array is locked" + SysConst_SInvalidVarCast, "Invalid variant type conversion" + SysConst_SInvalidVarOp, "Invalid variant operation" + SysConst_SInvalidVarOpWithHResult, "Invalid variant operation ($%.8x)" + SysConst_SVarNotArray, "Variant is not an array" + SysConst_SInvalidVarNullOp, "Invalid NULL variant operation" + SysConst_SVarTypeCouldNotConvert, "Could not convert variant of type (%s) into type (%s)" + SysConst_SVarTypeConvertOverflow, "Overflow while converting variant of type (%s) into type (%s)" + SysConst_SVarOverflow, "Variant overflow" + SysConst_SDivByZero, "Division by zero" + SysConst_SRangeError, "Range check error" + SysConst_SIntOverflow, "Integer overflow" + SysConst_SInvalidOp, "Invalid floating point operation" + SysConst_SZeroDivide, "Floating point division by zero" + SysConst_SOverflow, "Floating point overflow" + SysConst_SUnderflow, "Floating point underflow" + SysConst_SInvalidPointer, "Invalid pointer operation" + SysConst_SInvalidCast, "Invalid class typecast" + SysConst_SAccessViolation, "Access violation at address %p. %s of address %p" + SysConst_SStackOverflow, "Stack overflow" + SysConst_SControlC, "Control-C hit" + SysConst_SPrivilege, "Privileged instruction" + SysConst_SOperationAborted, "Operation aborted" + SysConst_SException, "Exception %s in module %s at %p.\r\n%s%s\r\n" + SysConst_SExceptTitle, "Application Error" + SysConst_SInvalidInteger, "'%s' is not a valid integer value" + SysConst_SInvalidFloat, "'%s' is not a valid floating point value" + SysConst_SInvalidDate, "'%s' is not a valid date" + SysConst_SInvalidTime, "'%s' is not a valid time" + SysConst_SInvalidDateTime, "'%s' is not a valid date and time" + SysConst_STimeEncodeError, "Invalid argument to time encode" + SysConst_SDateEncodeError, "Invalid argument to date encode" + SysConst_SOutOfMemory, "Out of memory" + SysConst_SInOutError, "I/O error %d" + SysConst_SFileNotFound, "File not found" + SysConst_SInvalidFilename, "Invalid filename" + SysConst_STooManyOpenFiles, "Too many open files" + SysConst_SAccessDenied, "File access denied" + SysConst_SEndOfFile, "Read beyond end of file" + SysConst_SDiskFull, "Disk full" + SysConst_SInvalidInput, "Invalid numeric input" +END + diff --git a/src/tools/PseuWoWConsole/src/PseuWoWConsole.map b/src/tools/PseuWoWConsole/src/PseuWoWConsole.map index a8fd870..019e119 100644 --- a/src/tools/PseuWoWConsole/src/PseuWoWConsole.map +++ b/src/tools/PseuWoWConsole/src/PseuWoWConsole.map @@ -1,10832 +1,10832 @@ - - Start Length Name Class - 0001:00000000 0007A814H .text CODE - 0002:00000000 00002070H .data DATA - 0002:00002070 00001481H .bss BSS - - -Detailed map of segments - - 0001:00000000 00005A1B C=CODE S=.text G=(none) M=System ACBP=A9 - 0001:00005A1C 00000140 C=CODE S=.text G=(none) M=SysInit ACBP=A9 - 0001:00005B5C 00000134 C=CODE S=.text G=(none) M=Types ACBP=A9 - 0001:00005C90 00000BFC C=CODE S=.text G=(none) M=Windows ACBP=A9 - 0001:0000688C 00000038 C=CODE S=.text G=(none) M=Messages ACBP=A9 - 0001:000068C4 00000350 C=CODE S=.text G=(none) M=SysConst ACBP=A9 - 0001:00006C14 00006960 C=CODE S=.text G=(none) M=SysUtils ACBP=A9 - 0001:0000D574 0000099F C=CODE S=.text G=(none) M=VarUtils ACBP=A9 - 0001:0000DF14 000092AC C=CODE S=.text G=(none) M=Variants ACBP=A9 - 0001:000171C0 00000178 C=CODE S=.text G=(none) M=RTLConsts ACBP=A9 - 0001:00017338 00000DCC C=CODE S=.text G=(none) M=TypInfo ACBP=A9 - 0001:00018104 00000098 C=CODE S=.text G=(none) M=ActiveX ACBP=A9 - 0001:0001819C 0000C5DA C=CODE S=.text G=(none) M=Classes ACBP=A9 - 0001:00024778 000002C8 C=CODE S=.text G=(none) M=Consts ACBP=A9 - 0001:00024A40 00007407 C=CODE S=.text G=(none) M=Graphics ACBP=A9 - 0001:0002BE48 00000048 C=CODE S=.text G=(none) M=Math ACBP=A9 - 0001:0002BE90 000002B8 C=CODE S=.text G=(none) M=Contnrs ACBP=A9 - 0001:0002C148 000005A8 C=CODE S=.text G=(none) M=CommCtrl ACBP=A9 - 0001:0002C6F0 00000787 C=CODE S=.text G=(none) M=MultiMon ACBP=A9 - 0001:0002CE78 00000038 C=CODE S=.text G=(none) M=Imm ACBP=A9 - 0001:0002CEB0 00001098 C=CODE S=.text G=(none) M=HelpIntfs ACBP=A9 - 0001:0002DF48 00000058 C=CODE S=.text G=(none) M=WinSpool ACBP=A9 - 0001:0002DFA0 00000F80 C=CODE S=.text G=(none) M=Printers ACBP=A9 - 0001:0002EF20 0000031F C=CODE S=.text G=(none) M=FlatSB ACBP=A9 - 0001:0002F240 00008050 C=CODE S=.text G=(none) M=StdCtrls ACBP=A9 - 0001:00037290 00000040 C=CODE S=.text G=(none) M=ShellAPI ACBP=A9 - 0001:000372D0 00000038 C=CODE S=.text G=(none) M=RegStr ACBP=A9 - 0001:00037308 00000038 C=CODE S=.text G=(none) M=WinInet ACBP=A9 - 0001:00037340 00000038 C=CODE S=.text G=(none) M=UrlMon ACBP=A9 - 0001:00037378 00000038 C=CODE S=.text G=(none) M=ShlObj ACBP=A9 - 0001:000373B0 00000038 C=CODE S=.text G=(none) M=CommDlg ACBP=A9 - 0001:000373E8 00001500 C=CODE S=.text G=(none) M=ExtCtrls ACBP=A9 - 0001:000388E8 00000038 C=CODE S=.text G=(none) M=Dlgs ACBP=A9 - 0001:00038920 00000659 C=CODE S=.text G=(none) M=Dialogs ACBP=A9 - 0001:00038F7C 00000094 C=CODE S=.text G=(none) M=Clipbrd ACBP=A9 - 0001:00039010 00000114 C=CODE S=.text G=(none) M=StrUtils ACBP=A9 - 0001:00039124 00000168 C=CODE S=.text G=(none) M=StdActns ACBP=A9 - 0001:0003928C 00000CC4 C=CODE S=.text G=(none) M=WinHelpViewer ACBP=A9 - 0001:00039F50 00010AEB C=CODE S=.text G=(none) M=Controls ACBP=A9 - 0001:0004AA3C 0000130E C=CODE S=.text G=(none) M=ActnList ACBP=A9 - 0001:0004BD4C 000017D0 C=CODE S=.text G=(none) M=ImgList ACBP=A9 - 0001:0004D51C 000064CD C=CODE S=.text G=(none) M=Menus ACBP=A9 - 0001:000539EC 0000CC1C C=CODE S=.text G=(none) M=Forms ACBP=A9 - 0001:00060608 00000550 C=CODE S=.text G=(none) M=RedirectConsole ACBP=A9 - 0001:00060B58 00001018 C=CODE S=.text G=(none) M=IniFiles ACBP=A9 - 0001:00061B70 00000110 C=CODE S=.text G=(none) M=WinSock ACBP=A9 - 0001:00061C80 000003F0 C=CODE S=.text G=(none) M=SyncObjs ACBP=A9 - 0001:00062070 000035E4 C=CODE S=.text G=(none) M=ScktComp ACBP=A9 - 0001:00065654 00000038 C=CODE S=.text G=(none) M=JvWin32 ACBP=A9 - 0001:0006568C 00000038 C=CODE S=.text G=(none) M=JvConsts ACBP=A9 - 0001:000656C4 0000006C C=CODE S=.text G=(none) M=JVCLVer ACBP=A9 - 0001:00065730 00000118 C=CODE S=.text G=(none) M=JvComponentBase ACBP=A9 - 0001:00065848 000000C8 C=CODE S=.text G=(none) M=DateUtils ACBP=A9 - 0001:00065910 000002B8 C=CODE S=.text G=(none) M=JvResources ACBP=A9 - 0001:00065BC8 00000AA8 C=CODE S=.text G=(none) M=JvTypes ACBP=A9 - 0001:00066670 00000038 C=CODE S=.text G=(none) M=JvVCL5Utils ACBP=A9 - 0001:000666A8 00000058 C=CODE S=.text G=(none) M=ComConst ACBP=A9 - 0001:00066700 00000E65 C=CODE S=.text G=(none) M=ComObj ACBP=A9 - 0001:00067568 00000038 C=CODE S=.text G=(none) M=MMSystem ACBP=A9 - 0001:000675A0 00000068 C=CODE S=.text G=(none) M=Registry ACBP=A9 - 0001:00067608 00000354 C=CODE S=.text G=(none) M=JvJCLUtils ACBP=A9 - 0001:0006795C 00000038 C=CODE S=.text G=(none) M=RichEdit ACBP=A9 - 0001:00067994 00000038 C=CODE S=.text G=(none) M=ToolWin ACBP=A9 - 0001:000679CC 00000060 C=CODE S=.text G=(none) M=ComStrs ACBP=A9 - 0001:00067A2C 000000F5 C=CODE S=.text G=(none) M=Buttons ACBP=A9 - 0001:00067B24 00000038 C=CODE S=.text G=(none) M=ExtDlgs ACBP=A9 - 0001:00067B5C 0000006C C=CODE S=.text G=(none) M=Mapi ACBP=A9 - 0001:00067BC8 00000058 C=CODE S=.text G=(none) M=ExtActns ACBP=A9 - 0001:00067C20 00001AF8 C=CODE S=.text G=(none) M=ListActns ACBP=A9 - 0001:00069718 0000B6E8 C=CODE S=.text G=(none) M=ComCtrls ACBP=A9 - 0001:00074E00 00000038 C=CODE S=.text G=(none) M=MaskUtils ACBP=A9 - 0001:00074E38 00000038 C=CODE S=.text G=(none) M=Mask ACBP=A9 - 0001:00074E70 00000038 C=CODE S=.text G=(none) M=Grids ACBP=A9 - 0001:00074EA8 000001D0 C=CODE S=.text G=(none) M=JclResources ACBP=A9 - 0001:00075078 00000038 C=CODE S=.text G=(none) M=JclBase ACBP=A9 - 0001:000750B0 00000038 C=CODE S=.text G=(none) M=AccCtrl ACBP=A9 - 0001:000750E8 00000040 C=CODE S=.text G=(none) M=JclWin32 ACBP=A9 - 0001:00075128 00000038 C=CODE S=.text G=(none) M=JclConsole ACBP=A9 - 0001:00075160 00000068 C=CODE S=.text G=(none) M=JclWideStrings ACBP=A9 - 0001:000751C8 00000038 C=CODE S=.text G=(none) M=JclLogic ACBP=A9 - 0001:00075200 00000158 C=CODE S=.text G=(none) M=JclStrings ACBP=A9 - 0001:00075358 00000038 C=CODE S=.text G=(none) M=Jcl8087 ACBP=A9 - 0001:00075390 00000038 C=CODE S=.text G=(none) M=JclMath ACBP=A9 - 0001:000753C8 00000084 C=CODE S=.text G=(none) M=JclSysUtils ACBP=A9 - 0001:0007544C 00000038 C=CODE S=.text G=(none) M=Snmp ACBP=A9 - 0001:00075484 00000038 C=CODE S=.text G=(none) M=TlHelp32 ACBP=A9 - 0001:000754BC 00000038 C=CODE S=.text G=(none) M=PsAPI ACBP=A9 - 0001:000754F4 00000038 C=CODE S=.text G=(none) M=JclRegistry ACBP=A9 - 0001:0007552C 00000038 C=CODE S=.text G=(none) M=JclIniFiles ACBP=A9 - 0001:00075564 000006B5 C=CODE S=.text G=(none) M=JclSysInfo ACBP=A9 - 0001:00075C1C 00000044 C=CODE S=.text G=(none) M=JclShell ACBP=A9 - 0001:00075C60 00000038 C=CODE S=.text G=(none) M=JclSecurity ACBP=A9 - 0001:00075C98 00000038 C=CODE S=.text G=(none) M=JclDateTime ACBP=A9 - 0001:00075CD0 00000124 C=CODE S=.text G=(none) M=JclFileUtils ACBP=A9 - 0001:00075DF4 000001BF C=CODE S=.text G=(none) M=JclRTTI ACBP=A9 - 0001:00075FB4 00000038 C=CODE S=.text G=(none) M=JclMime ACBP=A9 - 0001:00075FEC 000001D0 C=CODE S=.text G=(none) M=JvPropertyStore ACBP=A9 - 0001:000761BC 0000013B C=CODE S=.text G=(none) M=JvAppStorage ACBP=A9 - 0001:000762F8 00000044 C=CODE S=.text G=(none) M=JvProgressUtils ACBP=A9 - 0001:0007633C 0000034B C=CODE S=.text G=(none) M=JvJVCLUtils ACBP=A9 - 0001:00076688 00001BF0 C=CODE S=.text G=(none) M=JvTrayIcon ACBP=A9 - 0001:00078278 00000474 C=CODE S=.text G=(none) M=modRichEdit ACBP=A9 - 0001:000786EC 00000114 C=CODE S=.text G=(none) M=modSCPUtils ACBP=A9 - 0001:00078800 00001C2C C=CODE S=.text G=(none) M=fMain ACBP=A9 - 0001:0007A42C 000003E8 C=CODE S=.text G=(none) M=PseuWoWConsole ACBP=A9 - 0002:00000000 0000008C C=DATA S=.data G=DGROUP M=System ACBP=A9 - 0002:0000008C 00000018 C=DATA S=.data G=DGROUP M=SysInit ACBP=A9 - 0002:000000A4 00000254 C=DATA S=.data G=DGROUP M=SysUtils ACBP=A9 - 0002:000002F8 00000110 C=DATA S=.data G=DGROUP M=VarUtils ACBP=A9 - 0002:00000408 00000186 C=DATA S=.data G=DGROUP M=Variants ACBP=A9 - 0002:00000590 0000000C C=DATA S=.data G=DGROUP M=TypInfo ACBP=A9 - 0002:0000059C 00000010 C=DATA S=.data G=DGROUP M=ActiveX ACBP=A9 - 0002:000005AC 00000100 C=DATA S=.data G=DGROUP M=Classes ACBP=A9 - 0002:000006AC 00000304 C=DATA S=.data G=DGROUP M=Graphics ACBP=A9 - 0002:000009B0 00000004 C=DATA S=.data G=DGROUP M=Printers ACBP=A9 - 0002:000009B4 00000104 C=DATA S=.data G=DGROUP M=StdCtrls ACBP=A9 - 0002:00000AB8 00000014 C=DATA S=.data G=DGROUP M=ExtCtrls ACBP=A9 - 0002:00000ACC 00000074 C=DATA S=.data G=DGROUP M=Dialogs ACBP=A9 - 0002:00000B40 0000013C C=DATA S=.data G=DGROUP M=Controls ACBP=A9 - 0002:00000C7C 00000020 C=DATA S=.data G=DGROUP M=ImgList ACBP=A9 - 0002:00000C9C 000000EC C=DATA S=.data G=DGROUP M=Menus ACBP=A9 - 0002:00000D88 00000124 C=DATA S=.data G=DGROUP M=Forms ACBP=A9 - 0002:00000EAC 00000008 C=DATA S=.data G=DGROUP M=IniFiles ACBP=A9 - 0002:00000EB4 0000000E C=DATA S=.data G=DGROUP M=JvConsts ACBP=A9 - 0002:00000EC4 00000438 C=DATA S=.data G=DGROUP M=JvTypes ACBP=A9 - 0002:000012FC 00000030 C=DATA S=.data G=DGROUP M=ComObj ACBP=A9 - 0002:0000132C 00000008 C=DATA S=.data G=DGROUP M=Registry ACBP=A9 - 0002:00001334 00000048 C=DATA S=.data G=DGROUP M=JvJCLUtils ACBP=A9 - 0002:0000137C 0000002C C=DATA S=.data G=DGROUP M=Buttons ACBP=A9 - 0002:000013A8 00000008 C=DATA S=.data G=DGROUP M=Mapi ACBP=A9 - 0002:000013B0 00000110 C=DATA S=.data G=DGROUP M=ComCtrls ACBP=A9 - 0002:000014C0 00000004 C=DATA S=.data G=DGROUP M=JclWideStrings ACBP=A9 - 0002:000014C4 0000000C C=DATA S=.data G=DGROUP M=JclStrings ACBP=A9 - 0002:000014D0 00000008 C=DATA S=.data G=DGROUP M=JclSysUtils ACBP=A9 - 0002:000014D8 00000450 C=DATA S=.data G=DGROUP M=JclSysInfo ACBP=A9 - 0002:00001928 00000004 C=DATA S=.data G=DGROUP M=JclShell ACBP=A9 - 0002:0000192C 00000040 C=DATA S=.data G=DGROUP M=JvPropertyStore ACBP=A9 - 0002:0000196C 00000004 C=DATA S=.data G=DGROUP M=JvProgressUtils ACBP=A9 - 0002:00001970 0000005C C=DATA S=.data G=DGROUP M=JvJVCLUtils ACBP=A9 - 0002:000019CC 00000024 C=DATA S=.data G=DGROUP M=JvTrayIcon ACBP=A9 - 0002:00003000 0000070C C=BSS S=.bss G=DGROUP M=System ACBP=A9 - 0002:0000370C 00000018 C=BSS S=.bss G=DGROUP M=SysInit ACBP=A9 - 0002:00003724 00000004 C=BSS S=.bss G=DGROUP M=Types ACBP=A9 - 0002:00003728 00000004 C=BSS S=.bss G=DGROUP M=Windows ACBP=A9 - 0002:0000372C 00000004 C=BSS S=.bss G=DGROUP M=Messages ACBP=A9 - 0002:00003730 00000004 C=BSS S=.bss G=DGROUP M=SysConst ACBP=A9 - 0002:00003734 00000120 C=BSS S=.bss G=DGROUP M=SysUtils ACBP=A9 - 0002:00003854 0000005C C=BSS S=.bss G=DGROUP M=VarUtils ACBP=A9 - 0002:000038B0 00000184 C=BSS S=.bss G=DGROUP M=Variants ACBP=A9 - 0002:00003A34 00000004 C=BSS S=.bss G=DGROUP M=RTLConsts ACBP=A9 - 0002:00003A38 00000004 C=BSS S=.bss G=DGROUP M=TypInfo ACBP=A9 - 0002:00003A3C 00000004 C=BSS S=.bss G=DGROUP M=ActiveX ACBP=A9 - 0002:00003A40 00000044 C=BSS S=.bss G=DGROUP M=Classes ACBP=A9 - 0002:00003A84 00000004 C=BSS S=.bss G=DGROUP M=Consts ACBP=A9 - 0002:00003A88 00000060 C=BSS S=.bss G=DGROUP M=Graphics ACBP=A9 - 0002:00003AE8 00000004 C=BSS S=.bss G=DGROUP M=Math ACBP=A9 - 0002:00003AEC 00000004 C=BSS S=.bss G=DGROUP M=Contnrs ACBP=A9 - 0002:00003AF0 0000000C C=BSS S=.bss G=DGROUP M=CommCtrl ACBP=A9 - 0002:00003AFC 00000031 C=BSS S=.bss G=DGROUP M=MultiMon ACBP=A9 - 0002:00003B30 00000004 C=BSS S=.bss G=DGROUP M=Imm ACBP=A9 - 0002:00003B34 00000008 C=BSS S=.bss G=DGROUP M=HelpIntfs ACBP=A9 - 0002:00003B3C 00000004 C=BSS S=.bss G=DGROUP M=WinSpool ACBP=A9 - 0002:00003B40 00000004 C=BSS S=.bss G=DGROUP M=Printers ACBP=A9 - 0002:00003B44 00000034 C=BSS S=.bss G=DGROUP M=FlatSB ACBP=A9 - 0002:00003B78 00000004 C=BSS S=.bss G=DGROUP M=StdCtrls ACBP=A9 - 0002:00003B7C 00000004 C=BSS S=.bss G=DGROUP M=ShellAPI ACBP=A9 - 0002:00003B80 00000004 C=BSS S=.bss G=DGROUP M=RegStr ACBP=A9 - 0002:00003B84 00000004 C=BSS S=.bss G=DGROUP M=WinInet ACBP=A9 - 0002:00003B88 00000004 C=BSS S=.bss G=DGROUP M=UrlMon ACBP=A9 - 0002:00003B8C 00000004 C=BSS S=.bss G=DGROUP M=ShlObj ACBP=A9 - 0002:00003B90 00000004 C=BSS S=.bss G=DGROUP M=CommDlg ACBP=A9 - 0002:00003B94 00000004 C=BSS S=.bss G=DGROUP M=ExtCtrls ACBP=A9 - 0002:00003B98 00000004 C=BSS S=.bss G=DGROUP M=Dlgs ACBP=A9 - 0002:00003B9C 0000000C C=BSS S=.bss G=DGROUP M=Dialogs ACBP=A9 - 0002:00003BA8 0000000C C=BSS S=.bss G=DGROUP M=Clipbrd ACBP=A9 - 0002:00003BB4 00000004 C=BSS S=.bss G=DGROUP M=StrUtils ACBP=A9 - 0002:00003BB8 00000004 C=BSS S=.bss G=DGROUP M=StdActns ACBP=A9 - 0002:00003BBC 00000010 C=BSS S=.bss G=DGROUP M=WinHelpViewer ACBP=A9 - 0002:00003BCC 00000080 C=BSS S=.bss G=DGROUP M=Controls ACBP=A9 - 0002:00003C4C 00000004 C=BSS S=.bss G=DGROUP M=ActnList ACBP=A9 - 0002:00003C50 00000004 C=BSS S=.bss G=DGROUP M=ImgList ACBP=A9 - 0002:00003C54 00000010 C=BSS S=.bss G=DGROUP M=Menus ACBP=A9 - 0002:00003C64 00000020 C=BSS S=.bss G=DGROUP M=Forms ACBP=A9 - 0002:00003C84 00000014 C=BSS S=.bss G=DGROUP M=RedirectConsole ACBP=A9 - 0002:00003C98 00000004 C=BSS S=.bss G=DGROUP M=IniFiles ACBP=A9 - 0002:00003C9C 00000004 C=BSS S=.bss G=DGROUP M=WinSock ACBP=A9 - 0002:00003CA0 00000004 C=BSS S=.bss G=DGROUP M=SyncObjs ACBP=A9 - 0002:00003CA4 00000194 C=BSS S=.bss G=DGROUP M=ScktComp ACBP=A9 - 0002:00003E38 00000004 C=BSS S=.bss G=DGROUP M=JvWin32 ACBP=A9 - 0002:00003E3C 00000004 C=BSS S=.bss G=DGROUP M=JvConsts ACBP=A9 - 0002:00003E40 00000004 C=BSS S=.bss G=DGROUP M=JVCLVer ACBP=A9 - 0002:00003E44 00000004 C=BSS S=.bss G=DGROUP M=JvComponentBase ACBP=A9 - 0002:00003E48 00000004 C=BSS S=.bss G=DGROUP M=DateUtils ACBP=A9 - 0002:00003E4C 00000004 C=BSS S=.bss G=DGROUP M=JvResources ACBP=A9 - 0002:00003E50 00000004 C=BSS S=.bss G=DGROUP M=JvTypes ACBP=A9 - 0002:00003E54 00000004 C=BSS S=.bss G=DGROUP M=JvVCL5Utils ACBP=A9 - 0002:00003E58 00000004 C=BSS S=.bss G=DGROUP M=ComConst ACBP=A9 - 0002:00003E5C 00000011 C=BSS S=.bss G=DGROUP M=ComObj ACBP=A9 - 0002:00003E70 00000004 C=BSS S=.bss G=DGROUP M=MMSystem ACBP=A9 - 0002:00003E74 00000004 C=BSS S=.bss G=DGROUP M=Registry ACBP=A9 - 0002:00003E78 00000008 C=BSS S=.bss G=DGROUP M=JvJCLUtils ACBP=A9 - 0002:00003E80 00000004 C=BSS S=.bss G=DGROUP M=RichEdit ACBP=A9 - 0002:00003E84 00000004 C=BSS S=.bss G=DGROUP M=ToolWin ACBP=A9 - 0002:00003E88 00000004 C=BSS S=.bss G=DGROUP M=ComStrs ACBP=A9 - 0002:00003E8C 00000030 C=BSS S=.bss G=DGROUP M=Buttons ACBP=A9 - 0002:00003EBC 00000004 C=BSS S=.bss G=DGROUP M=ExtDlgs ACBP=A9 - 0002:00003EC0 00000004 C=BSS S=.bss G=DGROUP M=Mapi ACBP=A9 - 0002:00003EC4 00000009 C=BSS S=.bss G=DGROUP M=ExtActns ACBP=A9 - 0002:00003ED0 00000004 C=BSS S=.bss G=DGROUP M=ListActns ACBP=A9 - 0002:00003ED4 0000000C C=BSS S=.bss G=DGROUP M=ComCtrls ACBP=A9 - 0002:00003EE0 00000004 C=BSS S=.bss G=DGROUP M=MaskUtils ACBP=A9 - 0002:00003EE4 00000004 C=BSS S=.bss G=DGROUP M=Mask ACBP=A9 - 0002:00003EE8 00000004 C=BSS S=.bss G=DGROUP M=Grids ACBP=A9 - 0002:00003EEC 00000004 C=BSS S=.bss G=DGROUP M=JclResources ACBP=A9 - 0002:00003EF0 00000004 C=BSS S=.bss G=DGROUP M=JclBase ACBP=A9 - 0002:00003EF4 00000004 C=BSS S=.bss G=DGROUP M=AccCtrl ACBP=A9 - 0002:00003EF8 00000004 C=BSS S=.bss G=DGROUP M=JclWin32 ACBP=A9 - 0002:00003EFC 00000004 C=BSS S=.bss G=DGROUP M=JclConsole ACBP=A9 - 0002:00003F00 00000004 C=BSS S=.bss G=DGROUP M=JclWideStrings ACBP=A9 - 0002:00003F04 00000004 C=BSS S=.bss G=DGROUP M=JclLogic ACBP=A9 - 0002:00003F08 00000504 C=BSS S=.bss G=DGROUP M=JclStrings ACBP=A9 - 0002:0000440C 00000004 C=BSS S=.bss G=DGROUP M=Jcl8087 ACBP=A9 - 0002:00004410 00000004 C=BSS S=.bss G=DGROUP M=JclMath ACBP=A9 - 0002:00004414 00000004 C=BSS S=.bss G=DGROUP M=JclSysUtils ACBP=A9 - 0002:00004418 00000004 C=BSS S=.bss G=DGROUP M=Snmp ACBP=A9 - 0002:0000441C 00000004 C=BSS S=.bss G=DGROUP M=TlHelp32 ACBP=A9 - 0002:00004420 00000004 C=BSS S=.bss G=DGROUP M=PsAPI ACBP=A9 - 0002:00004424 00000004 C=BSS S=.bss G=DGROUP M=JclRegistry ACBP=A9 - 0002:00004428 00000004 C=BSS S=.bss G=DGROUP M=JclIniFiles ACBP=A9 - 0002:0000442C 00000010 C=BSS S=.bss G=DGROUP M=JclSysInfo ACBP=A9 - 0002:0000443C 00000004 C=BSS S=.bss G=DGROUP M=JclShell ACBP=A9 - 0002:00004440 00000004 C=BSS S=.bss G=DGROUP M=JclSecurity ACBP=A9 - 0002:00004444 00000004 C=BSS S=.bss G=DGROUP M=JclDateTime ACBP=A9 - 0002:00004448 00000004 C=BSS S=.bss G=DGROUP M=JclFileUtils ACBP=A9 - 0002:0000444C 00000008 C=BSS S=.bss G=DGROUP M=JclRTTI ACBP=A9 - 0002:00004454 00000004 C=BSS S=.bss G=DGROUP M=JclMime ACBP=A9 - 0002:00004458 00000004 C=BSS S=.bss G=DGROUP M=JvPropertyStore ACBP=A9 - 0002:0000445C 00000008 C=BSS S=.bss G=DGROUP M=JvAppStorage ACBP=A9 - 0002:00004464 00000004 C=BSS S=.bss G=DGROUP M=JvProgressUtils ACBP=A9 - 0002:00004468 00000004 C=BSS S=.bss G=DGROUP M=JvJVCLUtils ACBP=A9 - 0002:0000446C 00000004 C=BSS S=.bss G=DGROUP M=JvTrayIcon ACBP=A9 - 0002:00004470 00000004 C=BSS S=.bss G=DGROUP M=modRichEdit ACBP=A9 - 0002:00004474 00000004 C=BSS S=.bss G=DGROUP M=modSCPUtils ACBP=A9 - 0002:00004478 00000008 C=BSS S=.bss G=DGROUP M=fMain ACBP=A9 - - - Address Publics by Name - - 0002:00003B9C .01 - 0002:0000445C .01 - 0002:00003EFC .01 - 0002:00003B7C .1 - 0002:00003B8C .1 - 0002:00003B90 .1 - 0002:00003EF4 .1 - 0002:00003B98 .1 - 0002:00004470 .1 - 0002:00003BB4 .1 - 0002:00003EEC .1 - 0002:00003BC4 .1 - 0002:00004418 .1 - 0002:00004428 .1 - 0002:0000372C .1 - 0002:00003724 .1 - 0002:00003730 .1 - 0002:00003EC0 .1 - 0002:0000371C .1 - 0002:00003E88 .1 - 0002:00003E80 .1 - 0002:00003E78 .1 - 0002:0000440C .1 - 0002:00003E58 .1 - 0002:00003E54 .1 - 0002:0000443C .1 - 0002:00004440 .1 - 0002:00003E4C .1 - 0002:00003E48 .1 - 0002:00003F08 .1 - 0002:00003F04 .1 - 0002:00003E40 .1 - 0002:00003E3C .1 - 0002:00003E38 .1 - 0002:00003AF0 .1 - 0002:00003B1C .1 - 0002:00004420 .1 - 0002:00003854 .1 - 0002:00003B30 .1 - 0002:0000441C .1 - 0002:00004454 .1 - 0002:00003C9C .1 - 0002:00003C94 .1 - 0002:00004464 .1 - 0002:00003B64 .1 - 0002:00003A84 .1 - 0002:00004474 .1 - 0002:00003A34 .1 - 0002:00003B80 .1 - 0002:00003B84 .1 - 0002:00003B88 .1 - 0002:00003EE8 .11 - 0002:00003A8C .12 - 0002:00003B94 .12 - 0002:00003BAC .2 - 0002:0000446C .2 - 0002:00003B34 .2 - 0002:00003AE8 .2 - 0002:00004444 .2 - 0002:00003E44 .2 - 0002:0000442C .2 - 0002:00003EE0 .2 - 0002:00003EF8 .2 - 0002:00004424 .2 - 0002:00003AEC .21 - 0002:00003EBC .3 - 0002:00003B40 .3 - 0002:00003F00 .3 - 0002:00003B3C .3 - 0002:00003A3C .3 - 0002:00003728 .3 - 0002:00003C50 .3 - 0002:00003A48 .35 - 0002:00003ED4 .36 - 0002:00004458 .4 - 0002:00003EF0 .4 - 0002:0000447C .4 - 0002:0000444C .4 - 0002:00003E8C .4 - 0002:00003E84 .4 - 0002:00003C6C .41 - 0002:00003E5C .41 - 0002:00003CA4 .41 - 0002:00003B78 .42 - 0002:00004448 .42 - 0002:00004414 .5 - 0002:000035BC .5 - 0002:00003EE4 .5 - 0002:00003E74 .5 - 0002:00003A38 .6 - 0002:00003CA0 .6 - 0002:00004468 .6 - 0002:00003BB8 .63 - 0002:00003E70 .7 - 0002:00003E50 .7 - 0002:00004410 .7 - 0002:00003BD4 .72 - 0002:00003EC4 .72 - 0002:00003C98 .8 - 0002:00003ED0 .8 - 0002:00003C4C .8 - 0002:000038D0 .81 - 0002:00003C5C .9 - 0002:00003844 .94 - 0001:00001B00 @AbstractError - 0001:00002CA8 @AfterConstruction - 0001:00002AB4 @AsClass - 0001:00001DE4 @Assign - 0001:00001FA4 @AStrCmp - 0001:00002CB8 @BeforeDestruction - 0001:00002844 @BoundErr - 0001:00002B00 @CallDynaInst - 0001:00002C50 @ClassCreate - 0001:00002CA0 @ClassDestroy - 0001:00001EAC @Close - 0001:000018D4 @Copy - 0001:000043E0 @CopyArray - 0001:000042C4 @CopyRecord - 0001:00004670 @DispCallByIDError - 0001:00003134 @DoneExcept - 0001:00004DAC @DynArrayAsg - 0001:00004D70 @DynArrayClear - 0001:00004C5C @DynArrayCopy - 0001:00004C7C @DynArrayCopyRange - 0001:00004A9C @DynArrayHigh - 0001:00004A94 @DynArrayLength - 0001:00004C50 @DynArraySetLength - 0001:00002014 @EofText - 0001:0000321C @ExceptionHandler - 0001:0000204C @FillChar - 0001:000042B8 @Finalize - 0001:000041CC @FinalizeArray - 0001:00004198 @FinalizeRecord - 0001:00001EA0 @Flush - 0001:00002838 @FpuInit - 0001:00002774 @FpuMaskInit - 0001:0000175C @FreeMem - 0001:0000173C @GetMem - 0001:00005A94 @GetTls - 0001:0000365C @Halt - 0001:00003584 @Halt0 - 0001:00002DCC @HandleAnyException - 0001:00003080 @HandleFinally - 0001:00002EF8 @HandleOnException - 0001:00005AE0 @InitExe - 0001:00004104 @InitializeArray - 0001:000040D4 @InitializeRecord - 0001:0000342C @InitImports - 0001:00003404 @InitResStringImports - 0001:00003450 @InitWideStrings - 0001:0000548C @IntfAddRef - 0001:00005460 @IntfCast - 0001:0000541C @IntfClear - 0001:00005434 @IntfCopy - 0001:00002A90 @IsClass - 0001:00002744 @isNECWindows - 0001:00003B98 @LStrAddRef - 0001:0000371C @LStrArrayClr - 0001:0000374C @LStrAsg - 0001:000039B8 @LStrCat - 0001:000039FC @LStrCat3 - 0001:00003A70 @LStrCatN - 0001:000036F8 @LStrClr - 0001:00003AF4 @LStrCmp - 0001:00003C08 @LStrCopy - 0001:00003C48 @LStrDelete - 0001:00003960 @LStrFromArray - 0001:000038D8 @LStrFromChar - 0001:000038E8 @LStrFromPChar - 0001:000037E8 @LStrFromPCharLen - 0001:00003918 @LStrFromPWChar - 0001:0000384C @LStrFromPWCharLen - 0001:00003954 @LStrFromString - 0001:00003978 @LStrFromWStr - 0001:00003C90 @LStrInsert - 0001:00003790 @LStrLAsg - 0001:000039B0 @LStrLen - 0001:00003CEC @LStrPos - 0001:00003D34 @LStrSetLength - 0001:00003BA8 @LStrToPChar - 0001:0000398C @LStrToString - 0001:000037BC @NewAnsiString - 0001:00003DC0 @NewWideString - 0001:0000245C @Pow10 - 0001:00001F20 @PStrCmp - 0001:00001F04 @PStrNCpy - 0001:000030E0 @RaiseAgain - 0001:000030B8 @RaiseExcept - 0001:000020A8 @ReadChar - 0001:00002200 @ReadLn - 0001:00002194 @ReadLString - 0001:00002188 @ReadString - 0001:0000177C @ReallocMem - 0001:00001B74 @ResetText - 0001:00001B80 @RewritText - 0001:00001AD0 @ROUND - 0001:00003668 @RunError - 0001:00002440 @SetEq - 0001:000033C4 @StartExe - 0001:00000330 @strlen - 0001:00001ADC @TRUNC - 0001:00003164 @TryFinallyExit - 0001:00003C00 @UniqueStringA - 0001:00004870 @ValInt64 - 0001:00002230 @ValLong - 0001:000045A0 @VarCast - 0001:00004590 @VarClear - 0001:00004668 @VarClr - 0001:0000464C @VarCmpEQ - 0001:00004598 @VarCopy - 0001:0000460C @VarFromBool - 0001:00004624 @VarFromCurr - 0001:00004644 @VarFromDisp - 0001:000045F0 @VarFromInt - 0001:000045F8 @VarFromInt64 - 0001:0000463C @VarFromIntf - 0001:0000462C @VarFromLStr - 0001:00004614 @VarFromReal - 0001:0000461C @VarFromTDateTime - 0001:00004634 @VarFromWStr - 0001:00004658 @VarNeg - 0001:00004660 @VarNot - 0001:000045B8 @VarToBool - 0001:000045C8 @VarToCurr - 0001:000045E8 @VarToDisp - 0001:000045A8 @VarToInt - 0001:000045B0 @VarToInt64 - 0001:000045E0 @VarToIntf - 0001:000045D0 @VarToLStr - 0001:000045C0 @VarToReal - 0001:000045D8 @VarToWStr - 0001:00002340 @WriteBytes - 0001:00003D98 @WriteLString - 0001:00002394 @WriteSpaces - 0001:00003E00 @WStrArrayClr - 0001:00003E24 @WStrAsg - 0001:00003F60 @WStrCat - 0001:00003DE8 @WStrClr - 0001:00003FC0 @WStrCmp - 0001:00004044 @WStrCopy - 0001:00003F34 @WStrFromLStr - 0001:00003E48 @WStrFromPCharLen - 0001:00003EF8 @WStrFromPWChar - 0001:00003ED4 @WStrFromPWCharLen - 0001:00003F54 @WStrLen - 0001:00004090 @WStrSetLength - 0001:00003F44 @WStrToPWChar - 0001:0000241C @_CLenToPasStr - 0001:00002410 @_CToPasStr - 0001:000018A4 @_IOTest - 0001:0000469C @_lldiv - 0001:00004764 @_llmod - 0001:00004678 @_llmul - 0001:00004830 @_llshl - 0001:00004718 @_lludiv - 0001:000047E0 @_llumod - 0001:00004850 @_llushr - 0001:0000B4D4 Abort - 0001:0002E0AC AbortProc - 0001:0003CD74 AbsMin - 0001:0000B8DC AbstractErrorHandler - 0002:0000302C AbstractErrorProc - 0001:000750E0 AccCtrl - 0001:00061B88 accept - 0002:00000128 AccessMode - 0001:0000180C AcquireExceptionObject - 0001:0001A764 ActivateClassGroup - 0001:00006150 ActivateKeyboardLayout - 0002:00003C08 ActiveDrag - 0001:00018194 ActiveX - 0001:0004BD20 ActnList - 0001:00000454 AddBlockAfter - 0001:00078278 AddColouredLine - 0001:00078318 AddColourToLine - 0002:000005AC AddDataModule - 0001:00007848 AddExitProc - 0001:0001E20C AddFinished - 0001:00078584 AddHilightedItem - 0001:0004F114 AddIn - 0001:000052B0 AddModuleUnloadProc - 0001:000052C0 AddModuleUnloadProc - 0001:0001E244 AddNotFinished - 0001:00022DA8 AddThread - 0001:000281E4 AdjustColor - 0001:000384A0 AdjustColors - 0001:0006CFAC AdjustLineBreaks - 0001:00007B20 AdjustLineBreaks - 0001:00056834 Adjustment - 0001:00006158 AdjustWindowRectEx - 0002:00000D60 Alignments - 0002:00000D70 Alignments - 0002:00000A94 Alignments - 0002:00000A84 Alignments - 0002:00000AC0 Alignments - 0002:000009EC Alignments - 0001:0005D730 AlignWork - 0001:00042400 AlignWork - 0001:00024590 AllocateHWnd - 0001:00076454 AllocateHWndEx - 0002:00001920 AllocGranularity - 0001:000077FC AllocMem - 0002:000035B4 AllocMemCount - 0002:000035B8 AllocMemSize - 0001:0002BC40 AllocPatternBitmap - 0001:00005A3C AllocTlsBuffer - 0001:000217C4 AncestorValid - 0002:00000B4C AnchorAlign - 0001:00076C90 AnimateFromTray - 0001:00076C54 AnimateToTray - 0002:00000B40 AnimateWindowProc - 0002:00000C48 AnimationStyle - 0002:00003F0C AnsiCaseMap - 0002:000014C4 AnsiCaseMapReady - 0002:0000420C AnsiCharTypes - 0001:00007A28 AnsiCompareStr - 0001:00007A60 AnsiCompareText - 0001:00039010 AnsiContainsText - 0001:0000816C AnsiLastChar - 0001:00006160 AnsiLower - 0001:000079F4 AnsiLowerCase - 0001:0000C0FC AnsiLowerCaseFileName - 0001:0000C0C4 AnsiPos - 0001:00039080 AnsiReplaceText - 0001:000537F8 AnsiSameCaption - 0001:00007A98 AnsiSameText - 0001:00007AB0 AnsiStrLIComp - 0001:0000C188 AnsiStrPos - 0001:0000C228 AnsiStrRScan - 0001:0000C250 AnsiStrScan - 0001:00005898 AnsiToUtf8 - 0001:000079C0 AnsiUpperCase - 0001:00013CA8 AnyOp - 0001:000130D4 AnyToIntf - 0001:00009760 AppendChars - 0001:00009B24 AppendFormat - 0001:000097C4 AppendNumber - 0001:000097A4 AppendString - 0002:00003C64 Application - 0002:000005BC ApplicationHandleException - 0002:000005C4 ApplicationShowException - 0002:00000EA4 AppVisible - 0002:00001414 Arrangements - 0001:0000B8C0 AssertErrorHandler - 0002:00003024 AssertErrorProc - 0001:000177CC AssignLongStr - 0001:00017E48 AssignVariant - 0002:0000141C AutoArrange - 0002:00003608 avail - 0001:000082A0 BackfillGetDiskFreeSpaceEx - 0001:0003F8F0 BackgroundClipped - 0001:0000D80C BackupVarBoolFromStr - 0001:0000D96C BackupVarBStrFromBool - 0001:0000D88C BackupVarBStrFromCy - 0001:0000D8FC BackupVarBStrFromDate - 0001:0000D7A0 BackupVarCyFromStr - 0001:0000D734 BackupVarDateFromStr - 0001:0000D5F0 BackupVarI4FromStr - 0001:0000D59C BackupVariantChangeTypeEx - 0001:0000D65C BackupVarR4FromStr - 0001:0000D6C8 BackupVarR8FromStr - 0002:00000420 BaseTypeMap - 0001:0001AB38 BeginGlobalLoading - 0001:00006168 BeginPaint - 0001:000036AC BeginThread - 0001:000281F0 BetterSize - 0001:0004FEF8 BiDiDraw - 0001:00061B90 bind - 0001:00022D14 BinToHex - 0001:00005F48 BitBlt - 0002:0000137C BitBtnCaptions - 0002:00003E90 BitBtnGlyphs - 0002:00000964 BitmapCanvasList - 0002:00003AA4 BitmapImageLock - 0001:0000D5D8 BiUnimplemented - 0002:00000680 BlockCode - 0002:000035E0 blockDescBlockList - 0002:000035E4 blockDescFreeList - 0002:00000590 BooleanIdents - 0002:0000041C BooleanToStringRule - 0002:000014C8 Bools - 0001:00007F88 BoolToStr - 0001:00012190 BoolToWStrViaOS - 0002:00000AAC Borders - 0002:000013F4 BorderStyles - 0002:00000DEC BorderStyles - 0002:000009B4 BorderStyles - 0002:00000AB8 BorderStyles - 0001:00005C10 Bounds - 0001:00019A80 Bounds - 0002:00000D08 Breaks - 0002:00003ADC BrushManager - 0001:00052608 BuildImage - 0002:00000B14 ButtonCaptions - 0002:00001978 ButtonNames - 0002:00000AE8 ButtonNames - 0002:00000D84 Buttons - 0001:00067AFC Buttons - 0002:00000A7C ButtonStyles - 0001:000279D0 BytesPerScanline - 0001:00027D28 ByteSwapColors - 0001:0000BE78 ByteToCharIndex - 0001:0000BE50 ByteToCharLen - 0001:0000BE14 ByteType - 0001:0000BD9C ByteTypeTest - 0001:000244CC CalcJmpOffset - 0001:00049D10 CalcSplitterPos - 0001:00006170 CallNextHookEx - 0001:0000CA50 CallTerminateProcs - 0001:00006178 CallWindowProc - 0001:0003DD94 CancelDrag - 0002:00003C1C CanvasList - 0002:00003AE0 CanvasList - 0002:00000AD4 Captions - 0002:00000C04 CaptureControl - 0002:00000CA8 cBooleanToItemAutoFlag - 0002:000004B4 CBooleanToRelationship - 0001:00005C2C CenterPoint - 0002:00003BAA CF_COMPONENT - 0002:00003BA8 CF_PICTURE - 0002:000038C8 ChangeAnyProc - 0002:00000A30 CharCases - 0002:000009CC CharCases - 0001:00003818 CharFromWChar - 0001:000752B4 CharIsLower - 0001:000752C8 CharIsUpper - 0001:0000C04C CharLength - 0001:00006180 CharLowerBuff - 0001:00006188 CharNext - 0001:00000298 CharNext - 0001:000261D8 CharsetToIdent - 0001:0000BF60 CharToByteIndex - 0001:0000BFC4 CharToByteLen - 0001:00006190 CharUpperBuff - 0001:000287A0 CheckBool - 0001:0006BF40 CheckCommonControl - 0001:00063420 CheckError - 0001:00002D48 CheckJmp - 0001:00006198 CheckMenuItem - 0002:00000CF8 Checks - 0001:00062E54 CheckSocketResult - 0001:00022E54 CheckSynchronize - 0001:00056270 CheckTaskWindow - 0001:00013D34 CheckType - 0001:0001492C CheckType - 0001:0003DA48 CheckUndock - 0001:0000BD7C CheckWin32Version - 0001:000061A0 ChildWindowFromPoint - 0002:000019CC cHintSize - 0002:000019E0 cInfoFlagValues - 0002:00000438 CInvalidCustomVariantType - 0002:00000CAC cItemAutoFlagToBoolean - 0002:00000CA4 cItemAutoFlagToMenu - 0001:00024714 Classes - 0001:0001A528 ClassNotFound - 0001:00062FB8 Cleanup - 0002:000038C4 ClearAnyProc - 0001:00025A68 ClearColor - 0001:00067248 ClearExcepInfo - 0001:00075E68 ClearInfoList - 0001:00016AE8 ClearVariantTypeList - 0001:000061A8 ClientToScreen - 0001:000472B4 ClientToWindow - 0002:0000095C ClipboardFormats - 0001:00038FB8 Clipbrd - 0001:00000238 CloseHandle - 0001:00005CB8 CloseHandle - 0001:0002DF48 ClosePrinter - 0001:00061B98 closesocket - 0002:00003040 CmdLine - 0002:0000303C CmdShow - 0002:00000CA0 cMenuAutoFlagToItem - 0002:000004C0 CmpTypeMap - 0001:0000D5E4 CmpUnimplemented - 0002:00001304 CoAddRefServerProcess - 0002:000012FC CoCreateInstanceEx - 0002:00001470 Codes - 0002:000013E4 Codes - 0002:00001314 CoInitFlags - 0001:00018138 CoInitialize - 0002:00001300 CoInitializeEx - 0001:0001ADF4 CollectionsEqual - 0002:000006DC Colors - 0001:00025FD0 ColorToIdent - 0001:00025FC0 ColorToRGB - 0002:00000EC4 ColorValues - 0002:00001444 ColumnClicks - 0002:000014A0 ComboBoxExStyles - 0002:00000A1C ComboBoxStyles - 0002:000014AC ComboExStyles - 0002:00003E64 ComClassManagerVar - 0001:000666F8 ComConst - 0002:00003AF4 ComCtl32DLL - 0001:00074DF8 ComCtrls - 0002:00003C60 CommandPool - 0001:0002C6E8 CommCtrl - 0001:000373E0 CommDlg - 0001:00000734 Commit - 0002:00003624 committedRoot - 0001:00067510 ComObj - 0001:0004E6F8 CompareFront - 0001:00007928 CompareMem - 0001:000078F8 CompareStr - 0001:00005CC0 CompareString - 0001:00007948 CompareText - 0001:00007EB0 CompareWith - 0001:0001EC2C ComponentCreated - 0001:00067A24 ComStrs - 0001:00061BA0 connect - 0001:00024A38 Consts - 0001:0002C140 Contnrs - 0002:00003BDA ControlAtom - 0002:00003BE0 ControlAtomString - 0001:0005B018 ControlHasHelp - 0001:0004A9AC Controls - 0002:000013C8 ConversionFormatList - 0002:000005F0 Convert - 0002:000005E0 Convert - 0001:0000B284 ConvertAddr - 0001:000098B4 ConvertEraString - 0001:000077C0 ConvertError - 0001:000077D8 ConvertErrorFmt - 0001:000714C0 ConvertFlags - 0001:00071330 ConvertMask - 0001:000714E4 ConvertStates - 0001:00009A1C ConvertYearString - 0001:00004AA4 CopyArray - 0001:0002927C CopyBitmap - 0001:00029944 CopyBitmapAsMask - 0001:000298E0 CopyPalette - 0001:000516B4 CopyToBest - 0002:00001308 CoReleaseServerProcess - 0002:0000130C CoResumeClassObjects - 0002:00001310 CoSuspendClassObjects - 0001:00018140 CoUninitialize - 0001:0000BED0 CountChars - 0002:00003ABC CounterLock - 0002:0000043C CRangeToType - 0002:00000EB8 crDragAlt - 0001:00076288 CreateAppStoragePropertyEngineList - 0001:0000B804 CreateAssertException - 0001:0000B98C CreateAVObject - 0001:00005F50 CreateBitmap - 0001:00005F58 CreateBrushIndirect - 0001:00005F60 CreateCompatibleBitmap - 0001:00005F68 CreateCompatibleDC - 0001:0001ECAC CreateComponent - 0001:00005F70 CreateDC - 0001:00005F80 CreateDIBitmap - 0001:00005F78 CreateDIBSection - 0001:00005CC8 CreateEvent - 0001:00005CD0 CreateFile - 0001:00000240 CreateFileA - 0001:00005F88 CreateFontIndirect - 0001:00005F90 CreateHalftonePalette - 0001:00005F98 CreateIC - 0001:000061B0 CreateIcon - 0001:0000B730 CreateInOutError - 0001:000061B8 CreateMenu - 0001:00005FA0 CreatePalette - 0001:00005FA8 CreatePenIndirect - 0001:00005CD8 CreatePipe - 0001:000061C0 CreatePopupMenu - 0001:00005CE0 CreateProcess - 0001:00005FB0 CreateSolidBrush - 0001:00027D80 CreateSystemPalette - 0001:000002A0 CreateThread - 0001:00005CE8 CreateThread - 0001:00006728 CreateWindow - 0001:000061C8 CreateWindowEx - 0002:00000B44 CreationControl - 0002:00000ACC CreationControl - 0002:0000057C CRelationshipToBoolean - 0002:00000400 CResult - 0002:00000EBC crMultiDragAlt - 0002:00000EB4 crMultiDragLink - 0002:00000EC0 crMultiDragLinkAlt - 0002:00000120 cSimpleBoolStrs - 0002:00000528 CText - 0002:00000C40 Ctl3DStyles - 0002:00000A74 Ctl3DStyles - 0002:00000524 CTruth - 0002:0000361C curAlloc - 0001:000149F0 CurrCompare - 0002:0000373C CurrencyDecimals - 0002:00003738 CurrencyFormat - 0002:00003734 CurrencyString - 0001:0000974C CurrentYear - 0001:000091E8 CurrToStr - 0001:00012128 CurrToWStrViaOS - 0002:00000E28 CursorMap - 0002:00000B54 Cursors - 0001:0003C648 CursorToIdent - 0002:00000E18 cUseAlpha - 0002:00000E20 cUseColorKey - 0002:000019A4 cUtilWindowExClass - 0002:000002F8 CVarTypeToElementInfo - 0002:00000160 CWNear - 0001:000149C8 DateCompare - 0001:00013DF8 DateOp - 0002:0000373D DateSeparator - 0001:0000A340 DateTimeToStr - 0001:0000A2B4 DateTimeToString - 0001:000092E4 DateTimeToTimeStamp - 0001:0000A310 DateToStr - 0001:0001215C DateToWStrViaOS - 0001:00065908 DateUtils - 0002:00001334 Day - 0001:000096D4 DayOfWeek - 0002:0000015C DCon10 - 0002:000006D8 DDBsOnly - 0001:00024644 DeallocateHWnd - 0001:00076538 DeallocateHWndEx - 0002:00000014 DebugHook - 0002:0000373B DecimalSeparator - 0001:000163C8 DecIndices - 0001:000096B4 DecodeDate - 0001:00009568 DecodeDateFully - 0001:000093D8 DecodeTime - 0001:000007C8 Decommit - 0001:00000DE4 DecommitFree - 0002:000035F8 decommittedRoot - 0001:0005E2F4 Default - 0001:00058D6C Default - 0002:0000000C Default8087CW - 0002:00000B48 DefaultDockTreeClass - 0001:0006FE9C DefaultListViewSort - 0002:00000020 DefaultTextLineBreakStyle - 0002:0000092C DefBrushData - 0002:00001970 DefCompanyName - 0002:000006AC DefFontData - 0001:000061D0 DefFrameProc - 0002:000001EC DefLongDayNames - 0002:000001A0 DefLongMonthNames - 0001:000061D8 DefMDIChildProc - 0002:0000090C DefPenData - 0002:000001D0 DefShortDayNames - 0002:00000170 DefShortMonthNames - 0001:000061E0 DefWindowProc - 0001:00004E04 DelayLoadResourceModule - 0001:00000484 DeleteBlock - 0001:00005CF0 DeleteCriticalSection - 0001:000003F4 DeleteCriticalSection - 0001:00005FB8 DeleteDC - 0001:00000C2C DeleteFree - 0001:000061E8 DeleteMenu - 0001:00005FC0 DeleteObject - 0001:00035D10 DeleteSelectedText - 0001:00075E44 DeleteType - 0001:00028E38 DeselectBitmap - 0001:0007629C DestroyAppStoragePropertyEngineList - 0001:000061F0 DestroyCursor - 0001:000061F8 DestroyIcon - 0001:00067A2C DestroyLocals - 0001:00006200 DestroyMenu - 0001:00006208 DestroyWindow - 0001:00039C48 DialogEnumerationTester - 0001:00038F50 Dialogs - 0002:00000968 DIBPalSizes - 0002:0000007C dig - 0002:0000145C Directions - 0001:000560C4 DisableTaskWindows - 0001:00066C5C DispatchInvoke - 0001:0006723C DispatchInvokeError - 0001:00006210 DispatchMessage - 0001:0005C280 DispatchShortCut - 0001:00067258 DispCall - 0001:0006733C DispCallByID - 0002:00003000 DispCallByIDProc - 0001:00067168 DispCallError - 0001:000077A4 DivMod - 0001:00038918 Dlgs - 0001:0005D5E4 DoAlign - 0001:00042290 DoAlign - 0001:00046230 DoCalcConstraints - 0002:00003C10 DockSiteList - 0001:000522D4 DoClick - 0001:00043918 DoControlMsg - 0001:0002DF50 DocumentProperties - 0001:00056074 DoDisableWindow - 0001:0003D374 DoDragOver - 0001:0000781C DoExitProc - 0001:00047FE4 DoFindControlZone - 0001:000561B0 DoFindWindow - 0001:00048570 DoFindZone - 0001:00048068 DoForEach - 0001:00049974 DoGetNextLimit - 0001:0005603C DoneApplication - 0001:0004A6D4 DoneControls - 0001:0000BCB8 DoneExceptions - 0001:0005A674 DoNestedActivation - 0001:0005D434 DoPosition - 0001:00041E50 DoPosition - 0001:00048F9C DoPrune - 0001:00037F60 DoRect - 0001:00049474 DoSaveZone - 0001:00049678 DoSetNewBounds - 0002:00000598 DotSep - 0001:0001C340 DoWrite - 0001:0004CE5C DoWrite - 0001:000289F8 DoWrite - 0001:00042F88 DoWriteDesignSize - 0001:00040A28 DoWriteIsControl - 0002:00003BF4 DragCapture - 0002:00003BE8 DragControl - 0001:0003DABC DragDone - 0001:0003D324 DragFindTarget - 0001:0003D2F8 DragFindWindow - 0002:00003C0C DragImageList - 0001:0003D714 DragInit - 0001:0003D884 DragInitControl - 0002:00003BF0 DragInternalObject - 0001:0003D258 DragMessage - 0002:00003BEC DragObject - 0002:00003C18 DragSave - 0002:00003C00 DragSaveCursor - 0002:00003BF8 DragStartPos - 0002:00003C04 DragThreshold - 0001:0003D444 DragTo - 0001:00006218 DrawAnimatedRects - 0001:0005E330 DrawAppIcon - 0002:00001974 DrawBitmap - 0001:00048B08 DrawCloseButton - 0001:00006220 DrawEdge - 0001:00006228 DrawFocusRect - 0001:00006230 DrawFrameControl - 0001:00048B60 DrawGrabberLine - 0001:00006238 DrawIcon - 0001:00006240 DrawIconEx - 0002:00000C7C DrawingStyles - 0001:00006248 DrawMenuBar - 0001:00053614 DrawMenuItem - 0001:00006250 DrawText - 0001:00063B8C DropStream - 0001:00027850 DupBits - 0001:00016374 DynArrayBounds - 0001:00004ABC DynArrayClear - 0001:000162EC DynArrayDim - 0001:000162D0 DynArrayElTypeInfo - 0001:000167F4 DynArrayFromVariant - 0001:00016290 DynArrayIndex - 0001:00004AC4 DynArraySetLength - 0001:00016304 DynArraySize - 0001:000164D4 DynArrayToVariant - 0001:00016434 DynArrayVariantBounds - 0001:0001648C DynArrayVarType - 0002:00000D68 EdgeStyle - 0002:00000C30 EdgeStyles - 0002:00000A64 EdgeStyles - 0002:000013FC EditStyles - 0001:0000B704 EHeapException.FreeInstance - 0002:000009E8 Empty - 0002:000013CC Empty - 0001:00014830 EmptyCompare - 0001:000141E8 EmptyOp - 0002:000038B0 EmptyParam - 0002:000000A4 EmptyStr - 0002:000000A8 EmptyWideStr - 0001:00006258 EnableMenuItem - 0002:00000D00 Enables - 0001:00006260 EnableScrollBar - 0001:00056178 EnableTaskWindows - 0001:00006268 EnableWindow - 0001:00009538 EncodeDate - 0001:00009398 EncodeTime - 0001:00005FC8 EndDoc - 0001:0001ABC0 EndGlobalLoading - 0001:00005FD0 EndPage - 0001:00006270 EndPaint - 0001:000036F0 EndThread - 0001:00005CF8 EnterCriticalSection - 0001:000003E4 EnterCriticalSection - 0001:00005D00 EnumCalendarInfoA - 0002:00003B18 EnumDisplayMonitors - 0001:0000AEF8 EnumEraNames - 0001:0000AF34 EnumEraYearOffsets - 0001:00059268 EnumMonitorsProc - 0001:0002DF58 EnumPrinters - 0001:00006278 EnumThreadWindows - 0001:00006280 EnumWindows - 0001:0006698C EOleException.Create - 0001:000668BC EOleSysError.Create - 0001:00006288 EqualRect - 0002:00003804 EraNames - 0001:0000A5B8 EraToYear - 0002:00003820 EraYearOffsets - 0002:00000074 errCaption - 0001:00001898 Error - 0001:0004E448 Error - 0001:0001A0EC Error - 0001:0001DD98 Error - 0002:00000004 ErrorAddr - 0001:0000184C ErrorAt - 0001:0000B7B0 ErrorHandler - 0002:00000208 ErrorMap - 0002:00003008 ErrorProc - 0002:000033E8 ErrOutput - 0001:000786EC EvaluateProperty - 0001:000017EC ExceptAddr - 0002:0000300C ExceptClsProc - 0001:0000BC24 ExceptHandler - 0001:0000B530 Exception.Create - 0001:0000B56C Exception.CreateFmt - 0001:0000B6BC Exception.CreateHelp - 0001:0000B5EC Exception.CreateRes - 0001:0000B628 Exception.CreateResFmt - 0002:0000301C ExceptionClass - 0001:0000B290 ExceptionErrorMessage - 0002:00000240 ExceptMap - 0001:000017CC ExceptObject - 0002:00003010 ExceptObjProc - 0002:00003004 ExceptProc - 0001:00005FD8 ExcludeClipRect - 0002:00000000 ExitCode - 0001:000034C8 ExitDll - 0002:00003048 ExitProc - 0001:000002B0 ExitProcess - 0002:00003028 ExitProcessProc - 0002:0000011C ExitProcList - 0001:000002A8 ExitThread - 0001:00067C18 ExtActns - 0001:000388C4 ExtCtrls - 0001:00067B54 ExtDlgs - 0001:00008258 ExtractFileExt - 0001:00008220 ExtractFileName - 0001:000081EC ExtractFilePath - 0001:00005FE0 ExtTextOut - 0002:00003840 FalseBoolStrs - 0002:00003BB0 FClipboard - 0002:00000150 FCon1E18 - 0001:00061B70 FD_SET - 0001:00061B80 FD_ZERO - 0001:0002E060 FetchStr - 0001:000080F4 FileAge - 0001:000080EC FileClose - 0001:00008054 FileCreate - 0001:00008030 FileCreate - 0001:0000815C FileExists - 0002:00000960 FileFormats - 0002:00000008 FileMode - 0001:00001BC8 FileNOPProc - 0001:00007FD4 FileOpen - 0001:0000805C FileRead - 0002:000005D4 FilerSignature - 0001:000080B4 FileSeek - 0001:00005D08 FileTimeToDosDateTime - 0001:00005D10 FileTimeToLocalFileTime - 0001:00008088 FileWrite - 0001:00000D14 FillAfterGap - 0001:00000CC0 FillBeforeGap - 0001:00000DAC FillerSizeAfterGap - 0001:00000D3C FillerSizeBeforeGap - 0001:00006290 FillRect - 0001:000666C8 Finalization - 0001:0002C6B8 Finalization - 0001:00075BB4 Finalization - 0001:00066318 Finalization - 0001:00075C1C Finalization - 0001:00075C60 Finalization - 0001:00067490 Finalization - 0001:00065B90 Finalization - 0001:00067568 Finalization - 0001:000675B8 Finalization - 0001:000658D8 Finalization - 0001:00065810 Finalization - 0001:0002CE38 Finalization - 0001:000656F8 Finalization - 0001:00075C98 Finalization - 0001:000678B8 Finalization - 0001:0006568C Finalization - 0001:0006795C Finalization - 0001:0002CE78 Finalization - 0001:00067994 Finalization - 0001:000679F4 Finalization - 0001:0002C110 Finalization - 0001:00065654 Finalization - 0001:0006561C Finalization - 0001:00005940 Finalization - 0001:0002BE58 Finalization - 0001:0000D374 Finalization - 0001:0002BC78 Finalization - 0001:0002DF00 Finalization - 0001:00062038 Finalization - 0001:00061C48 Finalization - 0001:00067AC4 Finalization - 0001:00075DBC Finalization - 0001:00075F58 Finalization - 0001:0002DF68 Finalization - 0001:00067B24 Finalization - 0001:00075FB4 Finalization - 0001:00067B70 Finalization - 0001:00067BC8 Finalization - 0001:000696E0 Finalization - 0001:0007616C Finalization - 0001:00005B24 Finalization - 0001:00006BDC Finalization - 0001:00061B20 Finalization - 0001:0002EEDC Finalization - 0001:0000688C Finalization - 0001:00060B14 Finalization - 0001:00006854 Finalization - 0001:00060568 Finalization - 0001:0000DED4 Finalization - 0001:000762B0 Finalization - 0001:000787C8 Finalization - 0001:000762F8 Finalization - 0001:00005C58 Finalization - 0001:0002F200 Finalization - 0001:0007552C Finalization - 0001:00074D80 Finalization - 0001:00074E00 Finalization - 0001:00074E38 Finalization - 0001:00074E70 Finalization - 0001:00075040 Finalization - 0001:00075078 Finalization - 0001:000750B0 Finalization - 0001:000538F4 Finalization - 0001:00024A08 Finalization - 0001:0007A3F4 Finalization - 0001:0007661C Finalization - 0001:00037258 Finalization - 0001:0004D4E4 Finalization - 0001:0004BCF0 Finalization - 0001:00037298 Finalization - 0001:0004A944 Finalization - 0001:000372D0 Finalization - 0001:00037308 Finalization - 0001:00037340 Finalization - 0001:00037378 Finalization - 0001:000373B0 Finalization - 0001:00038894 Finalization - 0001:000388E8 Finalization - 0001:000786B4 Finalization - 0001:000750F0 Finalization - 0001:00075128 Finalization - 0001:0002466C Finalization - 0001:0007516C Finalization - 0001:00078238 Finalization - 0001:000751C8 Finalization - 0001:0007A42C Finalization - 0001:000752FC Finalization - 0001:00016F38 Finalization - 0001:00038EF4 Finalization - 0001:00017300 Finalization - 0001:00075358 Finalization - 0001:00075390 Finalization - 0001:000753FC Finalization - 0001:0007544C Finalization - 0001:00075484 Finalization - 0001:000754BC Finalization - 0001:000180AC Finalization - 0001:000754F4 Finalization - 0001:00018164 Finalization - 0001:00038F7C Finalization - 0001:00039E78 Finalization - 0001:00039254 Finalization - 0001:000390EC Finalization - 0001:00066670 Finalization - 0001:00004AB4 FinalizeArray - 0001:00075A10 FinalizeSysInfo - 0001:00003304 FinalizeUnits - 0001:00052094 Find - 0001:00020F34 FindAncestor - 0001:00004E74 FindBS - 0001:0001A5E8 FindClass - 0001:00004DFC FindClassHInstance - 0001:00005D18 FindClose - 0001:000002C0 FindClose - 0001:00000C90 FindCommitted - 0001:0003C448 FindControl - 0001:0004879C FindControlAtPos - 0001:00016D90 FindCustomVariantType - 0001:00016E48 FindCustomVariantType - 0001:0003DDE0 FindDragTarget - 0001:0001EE5C FindExistingComponent - 0001:000002C8 FindFirstFile - 0001:00005D20 FindFirstFile - 0001:0001AA50 FindGlobalComponent - 0001:000562BC FindGlobalComponent - 0002:00003A54 FindGlobalComponentProcs - 0001:00004DD4 FindHInstance - 0001:0001A8F8 FindIdentToInt - 0001:0001A87C FindIntToIdent - 0002:00003BA4 FindMsg - 0001:0001E144 FindNestedComponent - 0001:0004E410 FindPopupControl - 0001:0000DB9C FindProc - 0001:00005D28 FindResource - 0001:00004E4C FindResourceHInstance - 0001:0005FDD0 FindScanline - 0001:00056214 FindTopMostWindow - 0001:0001FCCC FindUniqueName - 0001:00015BD8 FindVarData - 0001:0003DDAC FindVCLWindow - 0001:00006298 FindWindow - 0001:000062A0 FindWindowEx - 0001:00039CA0 FindWinHelp - 0001:00029230 FixupBitFields - 0002:00000D78 Flags - 0002:00003850 FLanguages - 0001:0002F230 FlatSB - 0002:00003B44 FlatSB_EnableScrollBar - 0002:00003B50 FlatSB_GetScrollInfo - 0002:00003B54 FlatSB_GetScrollPos - 0002:00003B4C FlatSB_GetScrollRange - 0002:00003B5C FlatSB_SetScrollInfo - 0002:00003B58 FlatSB_SetScrollPos - 0001:0002EF20 FlatSB_SetScrollProp - 0002:00003B60 FlatSB_SetScrollRange - 0002:00003B48 FlatSB_ShowScrollBar - 0001:00008E78 FloatToDecimal - 0001:000091B8 FloatToStr - 0001:00008BA0 FloatToText - 0001:00001E94 Flush - 0001:0007A424 fMain - 0002:00000164 FMSecsPerDay - 0001:00008A9C FmtStr - 0002:00000D90 FocusCount - 0002:00000D8C FocusMessages - 0002:0000087C FontCharsets - 0002:00003AD4 FontManager - 0001:00056290 ForegroundTask - 0001:00008A88 Format - 0002:0000016C Format - 0001:000085F4 FormatBuf - 0001:000085E8 FormatClearStr - 0001:0000857C FormatError - 0002:00000148 FormatErrorStrs - 0001:00005D30 FormatMessage - 0001:000085D4 FormatVarToStr - 0001:000605C4 Forms - 0001:00002454 FPower10 - 0002:000009B0 FPrinter - 0001:00038024 Frame3D - 0001:000062A8 FrameRect - 0001:0000CF54 FreeAndNil - 0001:000009FC FreeCommitted - 0001:00000F1C FreeCurAlloc - 0001:0003DEA0 FreeDeviceContext - 0001:0003DF5C FreeDeviceContexts - 0001:00024438 FreeIntConstList - 0001:000002D0 FreeLibrary - 0001:00005D38 FreeLibrary - 0001:00028D8C FreeMemoryContexts - 0001:0002456C FreeObjectInstance - 0001:00005D40 FreeResource - 0001:0000067C FreeSpace - 0001:0000CA6C FreeTerminateProcs - 0001:00075DF4 FreeTypeData - 0002:00003EDC FRichEditModule - 0002:00004478 frmMain - 0001:00027840 GDICheck - 0001:00027798 GDIError - 0001:00005D48 GetACP - 0001:000062B0 GetActiveWindow - 0001:0005DAC0 GetAnimation - 0001:00067830 GetAnimation - 0001:00005FE8 GetBitmapBits - 0001:000003FC GetBlockDesc - 0001:00005FF0 GetBrushOrgEx - 0001:000062B8 GetCapture - 0001:0003C6F0 GetCaptureControl - 0001:0001A594 GetClass - 0001:000062C0 GetClassInfo - 0001:000062C8 GetClassName - 0001:000062D0 GetClientRect - 0001:00005FF8 GetClipBox - 0001:00000398 GetCmdShow - 0001:0004BF40 GetColor - 0001:000002D8 GetCommandLine - 0001:00000848 GetCommitted - 0001:000008D8 GetCommittedAt - 0001:00021D7C GetComponentValue - 0001:000434CC GetControlAtPos - 0001:00009810 GetCount - 0001:00005D50 GetCPInfo - 0001:00006000 GetCurrentPositionEx - 0001:00005D58 GetCurrentProcessId - 0001:00005D60 GetCurrentThreadId - 0001:00000390 GetCurrentThreadId - 0001:00006680 GetCurrentTime - 0001:000062D8 GetCursor - 0001:0005FDE0 GetCursorHeightMargin - 0001:000062E0 GetCursorPos - 0001:0000983C GetDate - 0001:00005D68 GetDateFormat - 0001:0000A4D0 GetDateOrder - 0001:000062E8 GetDC - 0001:000062F0 GetDCEx - 0001:00006008 GetDCOrgEx - 0001:0002B888 GetDefFontCharSet - 0001:0001B8F0 GetDesigner - 0001:000062F8 GetDesktopWindow - 0001:00006020 GetDeviceCaps - 0001:00028788 GetDIB - 0001:00006010 GetDIBColorTable - 0001:00006018 GetDIBits - 0001:000286D0 GetDIBSizes - 0001:000279B0 GetDInColors - 0001:00005D70 GetDiskFreeSpaceA - 0002:00000118 GetDiskFreeSpaceEx - 0001:00049A54 GetDockAlign - 0001:0003D09C GetDockSiteAtPos - 0001:00006300 GetDoubleClickTime - 0001:0003D3B0 GetDropCtl - 0001:00002AD0 GetDynaMethod - 0001:00017370 GetEnumName - 0001:00017464 GetEnumNameValue - 0001:000174B0 GetEnumValue - 0001:0000AFAC GetEraNamesAndYearOffsets - 0001:0000A564 GetEraYearOffset - 0001:00018150 GetErrorInfo - 0001:0000B974 GetExceptionClass - 0001:0000BB58 GetExceptionObject - 0001:00005D78 GetExitCodeProcess - 0001:00005D80 GetExitCodeThread - 0001:0001A51C GetFieldClassTable - 0001:00000250 GetFileSize - 0001:00000248 GetFileType - 0001:000676D4 GetFileVersion - 0001:00005F30 GetFileVersionInfo - 0001:00005F38 GetFileVersionInfoSize - 0001:00017B38 GetFloatProp - 0001:00006308 GetFocus - 0001:000261F8 GetFontData - 0001:00006310 GetForegroundWindow - 0001:0000C4F0 GetFormatSettings - 0001:00025764 GetHashCode - 0001:0005B050 GetHelpInfo - 0001:0002D30C GetHelpSystem - 0001:0005D8A4 GetHint - 0001:0005D8DC GetHintControl - 0001:00061C00 gethostbyname - 0001:00053794 GetHotkey - 0001:00006318 GetIconInfo - 0001:00066FD4 GetIDsOfNames - 0001:00017F54 GetInt64Prop - 0001:00017FB8 GetInterfaceProp - 0001:00006330 GetKeyboardLayout - 0001:00006338 GetKeyboardLayoutList - 0001:00006340 GetKeyboardState - 0001:0000273C GetKeyboardType - 0001:00006320 GetKeyNameText - 0001:00006328 GetKeyState - 0001:00006348 GetLastActivePopup - 0001:00047D1C GetLastChildZone - 0001:00005D88 GetLastError - 0001:000002E0 GetLastError - 0001:0006FAF8 GetLength - 0001:0000AD70 GetLocaleChar - 0001:00005D98 GetLocaleInfo - 0001:000002E8 GetLocaleInfo - 0001:0000AD24 GetLocaleStr - 0001:00005D90 GetLocalTime - 0001:0003C6AC GetLongHint - 0001:000177E0 GetLongStrProp - 0001:00006350 GetMenu - 0001:0005AFD8 GetMenuHelpContext - 0001:00006358 GetMenuItemCount - 0001:00006360 GetMenuItemID - 0001:00006368 GetMenuItemInfo - 0001:000508E0 GetMenuSize - 0001:00006370 GetMenuState - 0001:00006378 GetMenuString - 0001:00006380 GetMessagePos - 0001:00017EDC GetMethodProp - 0001:000002F0 GetModuleFileName - 0001:00005DA0 GetModuleFileName - 0001:000002F8 GetModuleHandle - 0001:00005A1C GetModuleHandle - 0001:00005DA8 GetModuleHandle - 0001:00075CD0 GetModulePath - 0002:00003B0C GetMonitorInfo - 0002:00003B10 GetMonitorInfoA - 0002:00003B14 GetMonitorInfoW - 0001:0000ADD4 GetMonthDayNames - 0001:00075770 GetNativeSystemInfo - 0001:00006388 GetNextWindow - 0001:00006028 GetObject - 0001:00017608 GetOrdProp - 0001:00006030 GetPaletteEntries - 0001:00001978 GetParamStr - 0001:00006390 GetParent - 0001:00056488 GetParentForm - 0001:00006038 GetPixel - 0001:00005DB0 GetPrivateProfileString - 0001:00000300 GetProcAddress - 0001:00005DB8 GetProcAddress - 0001:00005DC0 GetProfileString - 0001:00006398 GetProp - 0001:00017514 GetPropInfo - 0001:00017584 GetPropInfos - 0001:00056948 GetRealScrollPosition - 0001:0004BF20 GetRGBColor - 0001:000063A0 GetScrollInfo - 0001:000063A8 GetScrollPos - 0001:000063B0 GetScrollRange - 0001:00061C08 getservbyname - 0001:000677BC GetShellVersion - 0001:0003C668 GetShortHint - 0001:000176D8 GetShortStrProp - 0001:00017770 GetShortStrPropAsLongStr - 0001:00061BA8 getsockopt - 0001:000005A0 GetSpace - 0001:00000604 GetSpaceAt - 0001:0004E4A0 GetSpecialName - 0001:00000308 GetStartupInfo - 0001:00005DC8 GetStartupInfo - 0001:00000258 GetStdHandle - 0001:00005DD0 GetStdHandle - 0001:00006040 GetStockObject - 0001:00005DD8 GetStringTypeEx - 0001:00005DE0 GetStringTypeExA - 0001:00017910 GetStrProp - 0001:000063B8 GetSubMenu - 0001:000063C0 GetSysColor - 0001:00005DE8 GetSystemInfo - 0001:000063C8 GetSystemMenu - 0001:000063D0 GetSystemMetrics - 0002:00003AFC GetSystemMetrics - 0001:00006048 GetSystemPaletteEntries - 0001:00006050 GetTextExtentPoint32 - 0001:00006058 GetTextMetrics - 0001:00005DF0 GetThreadLocale - 0001:00000310 GetThreadLocale - 0001:00005DF8 GetTickCount - 0001:00009874 GetTime - 0001:00005A48 GetTlsSize - 0001:0005E064 GetTopMostWindows - 0001:0003C7F8 GetTopParent - 0001:000063D8 GetTopWindow - 0001:00076C10 GetTrayHandle - 0001:00017364 GetTypeData - 0001:000063E0 GetUpdateRect - 0001:00015F0C GetVarArray - 0001:00015DC8 GetVarDataArrayInfo - 0001:00004568 GetVariantManager - 0001:00017E5C GetVariantProp - 0001:00005E00 GetVersion - 0001:00005E08 GetVersionEx - 0001:000750E8 GetVersionEx - 0001:0001797C GetWideStrProp - 0001:00017860 GetWideStrPropAsLongStr - 0001:000063E8 GetWindow - 0001:000063F0 GetWindowDC - 0001:000063F8 GetWindowLong - 0001:00006060 GetWindowOrgEx - 0001:00006400 GetWindowPlacement - 0001:00006408 GetWindowRect - 0001:00075584 GetWindowsVersion - 0001:00006410 GetWindowText - 0001:00006418 GetWindowThreadProcessId - 0001:00006420 GetWindowThreadProcessId - 0002:000019D4 GKernel32Handle - 0001:00005E10 GlobalAddAtom - 0001:00005E18 GlobalAlloc - 0001:0000668C GlobalAllocPtr - 0001:00005E20 GlobalDeleteAtom - 0001:00005E28 GlobalFindAtom - 0002:00003A58 GlobalFixupList - 0001:0001E28C GlobalFixupReferences - 0001:00005E30 GlobalFree - 0001:000066B8 GlobalFreePtr - 0001:00005E40 GlobalHandle - 0001:00005E38 GlobalLock - 0002:00003A40 GlobalNameSpace - 0001:00005E48 GlobalReAlloc - 0001:0000669C GlobalReAllocPtr - 0001:00005E50 GlobalUnlock - 0002:00003980 GOldVariantManager - 0001:0002BD4C Graphics - 0001:00074EA0 Grids - 0001:0001A710 GroupDescendentsWith - 0002:000019D8 GTriedLoadKernel32Dll - 0002:0000059C GUID_NULL - 0002:000038D4 GVariantManager - 0001:0000EA44 HandleConversionException - 0001:0001F524 HandleException - 0001:0007739C HasDoubleClickFunctionality - 0001:000331D8 HasPopup - 0001:00035CE4 HasSelectedText - 0001:00077340 HasSingleClickFunctionality - 0002:00000010 HeapAllocFlags - 0002:000035C4 heapErrorCode - 0002:000035C8 heapLock - 0001:0002DF40 HelpIntfs - 0002:00003B38 HelpManager - 0002:00003BA0 HelpMsg - 0002:00003BC8 HelpViewer - 0002:00000114 HexDisplayPrefix - 0001:00022D50 HexToBin - 0001:0007847C HexToColor - 0002:000013D0 HideScrollBars - 0002:000009D8 HideSelections - 0002:0000140C HideSelections - 0002:000013D8 HideSelections - 0001:00049AD0 HideZone - 0002:00003718 HInstance - 0002:00003C78 HintDoneEvent - 0001:0005D9AC HintGetMsgHook - 0002:00003C7C HintHook - 0001:0005D950 HintMouseThread - 0002:00003C80 HintThread - 0002:00003C74 HintThreadID - 0001:0005D8FC HintTimerProc - 0002:00000D88 HintWindowClass - 0001:0000667C HiWord - 0001:0005D9F0 HookHintHooks - 0001:00061BB0 htons - 0001:0000675C HwndMSWheel - 0002:00001488 IAlignment - 0002:00000D1C IBreaks - 0002:00000D28 IChecks - 0002:00000D30 IDefaults - 0001:000261E8 IdentToCharset - 0001:00025FE0 IdentToColor - 0001:0003C658 IdentToCursor - 0001:0001A974 IdentToInt - 0002:00000D38 IEnables - 0001:00051684 IfHotkeyAvailable - 0002:0000192C IgnorePropertyList - 0001:0002C1FC ImageList_Add - 0001:0002C21C ImageList_AddIcon - 0001:0002C24C ImageList_BeginDrag - 0001:0002C1E4 ImageList_Create - 0001:0002C1EC ImageList_Destroy - 0001:0002C25C ImageList_DragEnter - 0001:0002C264 ImageList_DragLeave - 0001:0002C26C ImageList_DragMove - 0001:0002C27C ImageList_DragShowNolock - 0001:0002C22C ImageList_Draw - 0001:0002C234 ImageList_DrawEx - 0001:0002C254 ImageList_EndDrag - 0001:0002C214 ImageList_GetBkColor - 0001:0002C284 ImageList_GetDragImage - 0001:0002C244 ImageList_GetIcon - 0001:0002C29C ImageList_GetIconSize - 0001:0002C1F4 ImageList_GetImageCount - 0001:0002C28C ImageList_Read - 0001:0002C23C ImageList_Remove - 0001:0002C204 ImageList_ReplaceIcon - 0001:0002C20C ImageList_SetBkColor - 0001:0002C274 ImageList_SetDragCursorImage - 0001:0002C2A4 ImageList_SetIconSize - 0001:0002C294 ImageList_Write - 0002:00000C8C Images - 0001:0004D514 ImgList - 0001:0002CEA8 Imm - 0002:00000C70 IMM32DLL - 0001:0004A6C0 Imm32IsIME - 0002:00000168 IMSecsPerDay - 0001:0000EB30 InBounds - 0001:0000EECC InBounds - 0001:0000EEFC Increment - 0001:0000EB60 Increment - 0001:0002C228 IndexToOverlayMask - 0001:0002C2F0 IndexToStateImageMask - 0001:00061BB8 inet_addr - 0001:00006428 InflateRect - 0002:000014D0 InfMantissa - 0001:00061B68 IniFiles - 0001:00000A88 InitAllocator - 0001:0002C6F0 InitAnApi - 0002:00003B24 InitApis - 0001:0002C150 InitComCtl - 0001:0006BF14 InitCommonControl - 0001:0002C148 InitCommonControls - 0001:0002C1B0 InitCommonControlsEx - 0001:00067418 InitComObj - 0001:0001AC1C InitComponent - 0002:00003634 InitContext - 0001:0004A75C InitControls - 0001:0002B8CC InitDefFontData - 0001:0000CA8C InitDriveSpacePtr - 0001:0000BC34 InitExceptions - 0001:0002EF7C InitFlatSB - 0001:00038DA0 InitGlobals - 0001:00028588 InitializeBitmapInfoHeader - 0001:000003DC InitializeCriticalSection - 0001:00005E58 InitializeCriticalSection - 0002:000035C0 initialized - 0001:0002EF54 InitializeFlatSB - 0001:00005AD4 InitializeModule - 0001:00005C90 InitializeSecurityDescriptor - 0001:0000DBC8 InitializeVarUtils - 0001:0004A360 InitIMM32 - 0001:0001ACC4 InitInheritedComponent - 0001:0000C304 InitLeadBytes - 0001:0002CDCC InitMultiMonStubs - 0001:0000BD24 InitPlatformId - 0002:00003044 InitProc - 0001:000604DC InitProcs - 0001:00076540 InitScreenCursors - 0001:0002B850 InitScreenLogPixels - 0001:00075834 InitSysInfo - 0001:0000C37C InitSysLocale - 0001:00005A50 InitThreadTLS - 0001:00003364 InitUnits - 0001:00004548 InitVariantManager - 0001:0003C360 InitWndProc - 0002:00000C10 InnerStyles - 0002:00000A44 InnerStyles - 0002:00003050 Input - 0001:00041DC4 InsertBefore - 0001:0005D3D4 InsertBefore - 0001:00000E94 InsertFree - 0001:00051738 InsertHotkeyFarEastFormat - 0001:00006430 InsertMenu - 0001:00006438 InsertMenuItem - 0002:00003A7C InstBlockList - 0002:00003A80 InstFreeList - 0001:00014964 Int64Compare - 0001:00013F60 Int64Op - 0001:00014950 IntCompare - 0002:00003A4C IntConstList - 0002:00001520 IntelCacheDescription - 0001:00000388 InterlockedDecrement - 0001:0000CAF4 InterlockedDecrement - 0001:0000CB00 InterlockedExchange - 0001:0000CB08 InterlockedExchangeAdd - 0001:00000380 InterlockedIncrement - 0001:0000CAE8 InterlockedIncrement - 0001:00001C08 InternalClose - 0001:000256F0 InternalDeletePalette - 0001:00001E4C InternalFlush - 0001:00000CF0 InternalFreeMem - 0001:000286D8 InternalGetDIB - 0001:0002866C InternalGetDIBSizes - 0001:0001AAB4 InternalReadComponentRes - 0001:00003BB4 InternalUniqueString - 0001:00006068 IntersectClipRect - 0001:00005B80 IntersectRect - 0001:00006440 IntersectRect - 0001:00013E54 IntOp - 0001:00007D50 IntToHex - 0001:0001A9B4 IntToIdent - 0001:00007D1C IntToStr - 0001:00007CEC IntToStr - 0001:00006448 InvalidateRect - 0001:0002772C InvalidBitmap - 0001:00027714 InvalidGraphic - 0001:00027738 InvalidIcon - 0001:000276FC InvalidOperation - 0001:00019AA8 InvalidPoint - 0001:00019ABC InvalidPoint - 0002:0000384C InvalidPointer - 0001:00002988 InvokeImplGetter - 0001:00061BC0 ioctlsocket - 0001:00001918 IOResult - 0002:00000D58 IOwnerDraw - 0002:00000D40 IRadios - 0002:00000D50 IRTL - 0001:00056418 IsAccel - 0001:000528E8 IsAccelChar - 0001:00076B6C IsApplicationMinimized - 0001:0003CE54 IsBeforeTargetWindow - 0001:00006450 IsChild - 0002:0000304C IsConsole - 0001:00021EEC IsDefault - 0001:00021C70 IsDefault - 0001:000224A8 IsDefaultValue - 0001:00022370 IsDefaultValue - 0001:0002217C IsDefaultValue - 0001:00021BD8 IsDefaultValue - 0001:00021B34 IsDefaultValue - 0001:00021A04 IsDefaultValue - 0001:0003D2B0 IsDelphiHandle - 0001:00006458 IsDialogMessage - 0001:0001630C IsDynArrayRectangular - 0002:00000D48 ISeparators - 0001:00006460 IsIconic - 0001:00052944 IsInitialChar - 0001:00009434 IsLeapYear - 0002:00003038 IsLibrary - 0002:0000304D IsMultiThread - 0001:00047780 IsOrientationSet - 0001:00005BE0 IsRectEmpty - 0001:00006468 IsRectEmpty - 0001:0003D058 IsSiteChildOfClient - 0001:000175D8 IsStoredProp - 0001:0001AA90 IsUniqueGlobalComponentName - 0002:00003A44 IsUniqueGlobalComponentNameProc - 0001:00007C88 IsValidIdent - 0001:0000C364 IsWesternGroup - 0002:0000150C IsWin2003 - 0002:00001514 IsWin2003R2 - 0002:00001504 IsWin2K - 0002:000014D8 IsWin95 - 0002:000014DC IsWin95OSR2 - 0002:000014E0 IsWin98 - 0002:000014E4 IsWin98SE - 0001:00006470 IsWindow - 0001:00006478 IsWindowEnabled - 0001:00006480 IsWindowVisible - 0002:0000151C IsWinLonghorn - 0002:000014E8 IsWinME - 0002:000014EC IsWinNT - 0001:00060670 IsWinNT - 0002:000014F0 IsWinNT3 - 0002:000014F4 IsWinNT31 - 0002:000014F8 IsWinNT35 - 0002:000014FC IsWinNT351 - 0002:00001500 IsWinNT4 - 0002:00001518 IsWinVista - 0002:00001508 IsWinXP - 0002:00001510 IsWinXP64 - 0001:00006488 IsZoomed - 0001:0004E86C Iterate - 0001:0004E8CC IterateMenus - 0001:00075388 Jcl8087 - 0001:000750A8 JclBase - 0001:00075158 JclConsole - 0001:00075CC8 JclDateTime - 0001:00075DEC JclFileUtils - 0001:0007555C JclIniFiles - 0001:000751F8 JclLogic - 0001:000753C0 JclMath - 0001:00075FE4 JclMime - 0001:00075524 JclRegistry - 0001:00075070 JclResources - 0001:00075F98 JclRTTI - 0001:00075C90 JclSecurity - 0001:00075C58 JclShell - 0001:00075344 JclStrings - 0001:00075C00 JclSysInfo - 0001:00075444 JclSysUtils - 0001:000751B4 JclWideStrings - 0001:00075120 JclWin32 - 0002:00000018 JITEnable - 0001:000762E8 JvAppStorage - 0001:00065728 JVCLVer - 0001:00065840 JvComponentBase - 0001:000656BC JvConsts - 0001:00067954 JvJCLUtils - 0001:00076678 JvJVCLUtils - 0001:00076334 JvProgressUtils - 0001:000761B4 JvPropertyStore - 0001:00065BC0 JvResources - 0001:00078270 JvTrayIcon - 0001:0006665C JvTypes - 0001:000666A0 JvVCL5Utils - 0001:00065684 JvWin32 - 0002:00004430 KernelVersionHi - 0001:000563CC KeyboardStateToShiftState - 0001:00056390 KeyDataToShiftState - 0001:0005633C KeysToShiftState - 0001:00006490 KillTimer - 0001:0000819C LastDelimiter - 0001:0000C290 LCIDToCodePage - 0002:000000F4 LeadBytes - 0001:000003EC LeaveCriticalSection - 0001:00005E60 LeaveCriticalSection - 0001:000390AC LeftStr - 0002:00000024 LibModuleList - 0001:00006070 LineTo - 0001:00069710 ListActns - 0001:0003DE28 ListAdd - 0001:00061BC8 listen - 0001:00068A28 ListItemsCompare - 0001:0003DE50 ListRemove - 0002:00003802 ListSeparator - 0001:0002C404 ListView_Arrange - 0001:0002C4B0 ListView_CreateDragImage - 0001:0002C354 ListView_DeleteAllItems - 0001:0002C45C ListView_DeleteColumn - 0001:0002C33C ListView_DeleteItem - 0001:0002C38C ListView_FindItem - 0001:0002C584 ListView_GetCheckState - 0001:0002C680 ListView_GetColumnOrderArray - 0001:0002C474 ListView_GetColumnWidth - 0001:0002C41C ListView_GetEditControl - 0001:0002C2F4 ListView_GetItem - 0001:0002C2E0 ListView_GetItemCount - 0001:0002C39C ListView_GetItemRect - 0001:0002C574 ListView_GetItemState - 0001:0002C368 ListView_GetNextItem - 0001:0002C50C ListView_GetOrigin - 0001:0002C63C ListView_GetSelectedCount - 0001:0002C4FC ListView_GetTopIndex - 0001:0002C3D8 ListView_HitTest - 0001:0002C44C ListView_InsertColumn - 0001:0002C324 ListView_InsertItem - 0001:0002C3E8 ListView_RedrawItems - 0001:0002C2AC ListView_SetBkColor - 0001:0002C5A4 ListView_SetCheckState - 0001:0002C430 ListView_SetColumn - 0001:0002C664 ListView_SetColumnOrderArray - 0001:0002C48C ListView_SetColumnWidth - 0001:0002C64C ListView_SetExtendedListViewStyle - 0001:0002C2C4 ListView_SetImageList - 0001:0002C30C ListView_SetItem - 0001:0002C600 ListView_SetItemCount - 0001:0002C610 ListView_SetItemCountEx - 0001:0002C544 ListView_SetItemState - 0001:0002C5D0 ListView_SetItemText - 0001:0002C4E4 ListView_SetTextBkColor - 0001:0002C4CC ListView_SetTextColor - 0001:0002C69C ListView_SetWorkAreas - 0001:0002C620 ListView_SortItems - 0001:0002C524 ListView_Update - 0001:00006498 LoadBitmap - 0001:00075238 LoadCaseMap - 0001:00075200 LoadCharTypes - 0001:00066A58 LoadComExProcs - 0001:000064A0 LoadCursor - 0001:000064A8 LoadIcon - 0001:00076BA8 LoadKernel32Dll - 0001:000064B0 LoadKeyboardLayout - 0001:00005E68 LoadLibrary - 0001:00000318 LoadLibraryEx - 0001:00005E70 LoadResource - 0001:00005040 LoadResourceModule - 0001:000058E8 LoadResString - 0001:000064B8 LoadString - 0001:00000320 LoadString - 0001:000003BC LocalAlloc - 0001:00005A24 LocalAlloc - 0001:000003C4 LocalFree - 0001:0000AD98 LocalGetLocaleStr - 0001:00005E78 LockResource - 0002:00003744 LongDateFormat - 0002:000037D8 LongDayNames - 0002:0000378C LongMonthNames - 0002:00003758 LongTimeFormat - 0001:000078BC LowerCase - 0001:00005F20 lstrcmp - 0001:00005F28 lstrcpy - 0001:00000328 lstrcpyn - 0002:00003A2C LVarTypes - 0002:00003A30 LVarTypeSync - 0002:00003030 MainInstance - 0002:00003034 MainThreadID - 0001:0000044C MakeEmpty - 0001:0000346C MakeErrorMessage - 0002:00000C5C MakeLast - 0001:00006670 MakeLong - 0001:00006720 MakeLParam - 0001:000244D4 MakeObjectInstance - 0001:000066CC MakeROP4 - 0001:0000B8F4 MapException - 0001:00067BC0 Mapi - 0002:000013A8 MAPIDLL - 0002:000013AC MAPIModule - 0001:0000317C MapToRunError - 0001:000064C0 MapVirtualKey - 0001:000064C8 MapWindowPoints - 0001:00074E68 Mask - 0002:00000C94 Mask - 0001:00006078 MaskBlt - 0001:00074E30 MaskUtils - 0001:0002BE88 Math - 0001:0002BE50 Max - 0001:00058DB8 MaximizedChildren - 0002:0000002C MemoryManager - 0002:00000CB0 MenuKeyCaps - 0001:00053964 Menus - 0001:0000049C MergeBlockAfter - 0001:00000F68 MergeCommit - 0001:000002B8 MessageBox - 0001:000064D0 MessageBox - 0001:000068BC Messages - 0001:0002BE48 Min - 0001:0001B514 Min - 0001:0004170C MinVar - 0002:00003B2C MMAvailable - 0001:00067598 MMSystem - 0002:00000C74 ModeMap - 0001:0005A9E4 ModifySystemMenu - 0001:000786E4 modRichEdit - 0001:000787F8 modSCPUtils - 0002:0000008C Module - 0002:0000370D ModuleIsCpp - 0002:0000370C ModuleIsLib - 0001:000244A4 ModuleUnload - 0002:00000028 ModuleUnloadList - 0002:00003B08 MonitorFromPoint - 0002:00003B04 MonitorFromRect - 0002:00003B00 MonitorFromWindow - 0002:00001340 Month - 0002:000000C4 MonthDays - 0002:00003BCC Mouse - 0001:00001938 Move - 0001:00006080 MoveToEx - 0001:0003DE70 MoveWindowOrg - 0001:000064D8 MsgWaitForMultipleObjects - 0001:00005E80 MulDiv - 0001:00005E88 MultiByteToWideChar - 0001:00000338 MultiByteToWideChar - 0001:0005FF94 MultiLineWidth - 0001:0002CE68 MultiMon - 0002:00001404 MultiSelections - 0002:00004438 MyGetFreeSystemResources - 0001:00078CD0 MyLineOut - 0002:00003E6C NeedToUninitialize - 0001:00015178 NegateAny - 0001:000150C8 NegateAsDouble - 0001:00015120 NegateByte - 0001:0001518C NegateCustom - 0001:00015144 NegateLongWord - 0001:000150F4 NegateVariant - 0001:000150E0 NegateViaOS - 0001:00015134 NegateWord - 0002:00003739 NegCurrFormat - 0001:00000FF4 NewCommit - 0001:00001020 NewCommitAt - 0002:00003BD0 NewStyleControls - 0001:0000C088 NextCharIndex - 0001:00047764 NextVisibleZone - 0002:000005D8 NilMethod - 0002:0000001C NoErrMsg - 0001:0004F680 NormalDraw - 0001:00015620 NotAny - 0001:00015578 NotAsOrdinal - 0001:000154A8 NotAsString - 0001:00015634 NotCustom - 0001:00002D34 NotifyAnyExcept - 0001:0001B988 NotifyDesigner - 0001:00002D08 NotifyExcept - 0001:00002D68 NotifyExceptFinally - 0001:0001AB90 NotifyGlobalLoading - 0001:00005340 NotifyModuleUnload - 0001:00002CE4 NotifyNonDelphiException - 0001:00002D20 NotifyOnExcept - 0001:00002CC8 NotifyReRaise - 0001:00002D90 NotifyTerminate - 0001:00002DAC NotifyUnhandled - 0001:000155F4 NotVariant - 0001:000155E0 NotViaOS - 0001:000096FC Now - 0001:000522C4 NthParentOf - 0001:00061BD0 ntohs - 0001:00016F30 Null - 0002:00000414 NullAsStringValue - 0001:00014844 NullCompare - 0002:00000408 NullEqualityRule - 0002:0000040C NullMagnitudeRule - 0001:0001413C NullOp - 0002:00000410 NullStrictConvert - 0001:00021EA4 ObjectAncestorMatch - 0001:0003C418 ObjectFromHWnd - 0002:000009E0 OEMConverts - 0001:000064E0 OemToAnsi - 0001:00005BF8 OffsetRect - 0001:000064E8 OffsetRect - 0001:00066A40 OleCheck - 0001:00066A24 OleError - 0001:000044E0 OleStrToStrVar - 0002:00003E60 OleUninitializing - 0001:000136EC OleVarFromAny - 0001:00013750 OleVarFromVarArrayProc - 0001:0002DF60 OpenPrinter - 0001:00001B1C OpenText - 0002:00000450 OpTypeMap - 0002:00000C54 OrientArray - 0002:00000C20 OuterStyles - 0002:00000A54 OuterStyles - 0002:00003848 OutOfMemory - 0001:00027744 OutOfResources - 0002:0000321C Output - 0001:00021D64 OwnedBy - 0002:00000418 PackVarCreation - 0002:00001924 PageSize - 0002:000013E0 Painting - 0002:00000970 Pal16 - 0001:00025AD4 PaletteChanged - 0001:00027F30 PaletteFromDIBColorTable - 0001:00027FD4 PaletteToDIBColorTable - 0002:0000096C PalSize - 0001:00001A64 ParamStr - 0001:00047B48 ParentNotLast - 0002:000009BC Passwords - 0001:00006088 PatBlt - 0002:00003AE4 PatternManager - 0001:000064F0 PeekMessage - 0001:00005E90 PeekNamedPipe - 0002:00003AD8 PenManager - 0002:0000093C PenModes - 0002:0000091C PenStyles - 0001:00019A30 Point - 0001:00005B78 Point - 0001:00019E84 PointerInModule - 0001:00042F74 PointsEqual - 0001:00006708 PointToSmallPoint - 0001:00006090 Polyline - 0002:00003C54 PopupList - 0001:000064F8 PostMessage - 0001:00006500 PostQuitMessage - 0001:0002EEBC Printer - 0001:0002EF18 Printers - 0002:00000664 Priorities - 0001:0005C080 ProcessExecute - 0001:00056648 ProcessHorz - 0002:0000191C ProcessorCount - 0001:0005C180 ProcessUpdate - 0001:000566B4 ProcessVert - 0002:00003A5C ProcPosted - 0002:0000196C ProgressList - 0001:0001E588 PropertyNotFound - 0001:0001F624 PropPathError - 0002:00000DB8 Props - 0001:0001E57C PropValueError - 0001:000754EC PsAPI - 0001:0007A7A4 PseuWoWConsole - 0001:00006508 PtInRect - 0001:00008B5C PutExponent - 0002:00003C14 QualifyingSites - 0001:0000B8B0 RaiseAssertException - 0001:0002E094 RaiseError - 0001:00000260 RaiseException - 0001:000670B4 RaiseException - 0001:0001D5C0 RaiseException - 0002:00003014 RaiseExceptionProc - 0001:0000C9A4 RaiseLastOSError - 0001:00066FA0 RaiseNameException - 0002:00003C88 RC_End - 0002:00003C8C RC_ExitCode - 0001:00060608 RC_LineIn - 0002:00003C90 RC_LineOut - 0001:0006075C RC_Run - 0002:00003C84 RC_SendBuf - 0001:0007031C ReadCols - 0001:000488B8 ReadControlName - 0001:00020880 ReadCustomVariant - 0001:0001E564 ReadError - 0001:00000268 ReadFile - 0001:00005E98 ReadFile - 0001:00028280 ReadIcon - 0001:00002114 ReadLine - 0002:000009C4 ReadOnlys - 0001:000149A0 RealCompare - 0001:00006098 RealizePalette - 0001:00013D7C RealOp - 0001:0001EC4C Recover - 0001:00005B5C Rect - 0001:00019A58 Rect - 0001:000060A8 Rectangle - 0001:000060A0 RectVisible - 0001:00061BD8 recv - 0001:00060B50 RedirectConsole - 0001:00006510 RedrawWindow - 0002:000038CC RefAnyProc - 0001:00005C98 RegCloseKey - 0001:00000340 RegCloseKey - 0002:00003A50 RegGroups - 0001:0001A608 RegisterClass - 0001:00006518 RegisterClass - 0001:00006520 RegisterClipboardFormat - 0001:0003D1F8 RegisterDockSite - 0002:00004460 RegisteredAppStoragePropertyEngineList - 0001:0001A9F8 RegisterFindGlobalComponentProc - 0001:0001A850 RegisterIntegerConsts - 0001:0000539C RegisterModule - 0002:000019DC RegisterServiceProcess - 0001:0002D274 RegisterViewer - 0001:00006528 RegisterWindowMessage - 0001:00067600 Registry - 0001:00005CA0 RegOpenKeyEx - 0001:00000348 RegOpenKeyEx - 0001:00000350 RegQueryValueEx - 0001:00005CA8 RegQueryValueEx - 0001:00037300 RegStr - 0001:00006530 ReleaseCapture - 0001:00006538 ReleaseDC - 0002:00000038 reMap - 0002:00003618 remBytes - 0001:0000050C RemoveBlock - 0002:000005B4 RemoveDataModule - 0001:0001E434 RemoveFixupReferences - 0001:0001E4E0 RemoveFixups - 0001:0001E7C0 RemoveGlobalFixup - 0001:00006540 RemoveMenu - 0001:000052B8 RemoveModuleUnloadProc - 0001:000052E0 RemoveModuleUnloadProc - 0001:00006548 RemoveProp - 0001:00022E10 RemoveThread - 0001:00075EC4 RemoveTypeInfo - 0001:00005EA0 ResetEvent - 0001:000014A8 ResizeInPlace - 0002:00004434 ResmeterLibHandle - 0001:000060B0 RestoreDC - 0001:00055FE8 RestoreFocusState - 0001:00005EA8 ResumeThread - 0001:0004E440 ReturnAddr - 0001:0001C4A0 ReturnAddr - 0001:0001AFE4 ReturnAddr - 0001:0000B4D0 ReturnAddr - 0001:000066D8 RGB - 0001:00027CB0 RGBQuadToTriple - 0001:00027C78 RGBTripleToQuad - 0001:0006798C RichEdit - 0001:000390C8 RightStr - 0002:00003BE4 RM_GetObjectInstance - 0002:00003C70 RM_TaskbarCreated - 0002:00003614 rover - 0002:00001928 RtdlMsiLibHandle - 0002:000013B0 RTFConversionFormat - 0001:00017330 RTLConsts - 0001:00000270 RtlUnwind - 0002:00003018 RTLUnwindProc - 0002:00000054 runErrMsg - 0001:00001840 RunErrorAt - 0001:0000D9E0 SafeArrayCreate - 0001:0000DA00 SafeArrayGetElement - 0001:0000D9F0 SafeArrayGetLBound - 0001:0000D9F8 SafeArrayGetUBound - 0001:0000DA10 SafeArrayPtrOfIndex - 0001:0000DA08 SafeArrayPutElement - 0001:0000D9E8 SafeArrayRedim - 0001:00066B5C SafeCallError - 0002:00003020 SafeCallErrorProc - 0001:0000D020 SafeLoadLibrary - 0001:0000799C SameText - 0001:000060B8 SaveDC - 0001:00055FE0 SaveFocusState - 0002:00003E68 SaveInitProc - 0001:0000A354 ScanBlanks - 0001:0000A498 ScanChar - 0001:0000A614 ScanDate - 0001:0000A378 ScanNumber - 0001:0000A40C ScanString - 0001:0000A950 ScanTime - 0001:0000A51C ScanToNumber - 0001:0006564C ScktComp - 0002:00003C68 Screen - 0002:00003A90 ScreenLogPixels - 0001:00006550 ScreenToClient - 0002:00000A04 ScrollBar - 0001:00056800 ScrollBarVisible - 0001:00006558 ScrollWindow - 0001:00001054 SearchSmallBlocks - 0001:00065848 SecondsBetween - 0001:000658A8 SecondSpan - 0001:00061BE0 select - 0001:000060C0 SelectObject - 0001:000060C8 SelectPalette - 0001:00061BE8 send - 0001:0003C484 SendAppMessage - 0001:00056250 SendFocusMessage - 0001:00006560 SendMessage - 0002:00000D14 Separators - 0001:000060D0 SetAbortProc - 0001:00006568 SetActiveWindow - 0001:00067860 SetAnimation - 0001:0005DAF0 SetAnimation - 0001:000060D8 SetBkColor - 0001:000060E0 SetBkMode - 0001:000060E8 SetBrushOrgEx - 0001:00006570 SetCapture - 0001:0003C718 SetCaptureControl - 0001:00006578 SetClassLong - 0001:00015D50 SetClearVarToEmptyParam - 0001:0001EDBC SetCompName - 0001:00006580 SetCursor - 0001:000060F0 SetDIBColorTable - 0001:00000278 SetEndOfFile - 0001:00005EB0 SetEndOfFile - 0001:00005EB8 SetErrorMode - 0001:00005EC0 SetEvent - 0001:000032BC SetExceptionHandler - 0001:00000280 SetFilePointer - 0001:00005EC8 SetFilePointer - 0001:00017C50 SetFloatProp - 0001:00006588 SetFocus - 0001:00006590 SetForegroundWindow - 0001:0004A5E4 SetImeMode - 0001:000018C4 SetInOutRes - 0001:00017F7C SetInt64Prop - 0001:00018038 SetInterfaceProp - 0001:0001F904 SetInterfaceReference - 0001:0001F820 SetIntIdent - 0002:00000D94 SetLayeredWindowAttributes - 0001:00017820 SetLongStrProp - 0001:000060F8 SetMapMode - 0001:00006598 SetMenu - 0001:000065A0 SetMenuItemInfo - 0001:00017F1C SetMethodProp - 0001:0001F868 SetObjectIdent - 0001:0001767C SetOrdProp - 0001:00006100 SetPixel - 0001:000065A8 SetProp - 0001:000065B0 SetRect - 0001:00006108 SetROP2 - 0001:000065B8 SetScrollInfo - 0001:000065C0 SetScrollPos - 0001:000065C8 SetScrollRange - 0001:00005CB0 SetSecurityDescriptorDacl - 0001:0001771C SetShortStrProp - 0001:00017798 SetShortStrPropAsLongStr - 0001:00061BF0 setsockopt - 0001:00006110 SetStretchBltMode - 0001:00017950 SetStrProp - 0001:00006118 SetTextColor - 0001:00005ED0 SetThreadLocale - 0001:00005ED8 SetThreadPriority - 0001:000065D0 SetTimer - 0001:00015D38 SetVarAsError - 0001:0000457C SetVariantManager - 0001:00017E9C SetVariantProp - 0001:0001F8A8 SetVariantReference - 0001:00006120 SetViewportOrgEx - 0001:0005FAA4 SetVisible - 0001:00017A64 SetWideStrProp - 0001:000178B8 SetWideStrPropAsLongStr - 0001:000065D8 SetWindowLong - 0001:00006128 SetWindowOrgEx - 0001:000065E0 SetWindowPlacement - 0001:000065E8 SetWindowPos - 0001:000065F8 SetWindowsHookEx - 0001:000065F0 SetWindowText - 0002:00000134 ShareMode - 0001:000372C8 ShellAPI - 0002:00003ED8 ShellModule - 0002:00003E7C ShellVersion - 0001:00037290 Shell_NotifyIcon - 0001:000373A8 ShlObj - 0001:0004E468 ShortCut - 0002:00003C58 ShortCutItems - 0001:0004E4F4 ShortCutToText - 0002:00003740 ShortDateFormat - 0002:000037BC ShortDayNames - 0002:0000375C ShortMonthNames - 0002:00003754 ShortTimeFormat - 0002:0000143C ShowColumns - 0002:00000E00 ShowCommands - 0002:00000E0C ShowCommands - 0002:00000DF4 ShowCommands - 0001:00006600 ShowCursor - 0001:0000B418 ShowException - 0002:00000C08 ShowFlags - 0002:00000EA8 ShowFlags - 0001:00055FF0 ShowMDIClientEdge - 0001:00006608 ShowOwnedPopups - 0001:00006610 ShowScrollBar - 0001:00006618 ShowWindow - 0001:00067888 ShowWinNoAnimate - 0001:0005DB18 ShowWinNoAnimate - 0001:00049B50 ShowZone - 0001:00014280 SimpleVarOp - 0002:00000C68 SizeCursors - 0001:00005EE0 SizeofResource - 0001:000203B4 SkipBinary - 0001:000203E4 SkipCollection - 0001:0002038C SkipList - 0001:00005EE8 Sleep - 0001:0000C99C Sleep - 0001:00005EF0 SleepEx - 0001:00019A48 SmallPoint - 0001:000066F4 SmallPointToPoint - 0002:00003620 smallTab - 0001:0007547C Snmp - 0001:00061BF8 socket - 0002:00000A3C Sorts - 0002:000035E8 spaceRoot - 0001:00065878 SpanOfNowAndThen - 0001:00060694 SplitLines - 0002:00000FB4 StandardColorValues - 0001:0001A6C4 StartClassGroup - 0001:00006130 StartDoc - 0001:00006138 StartPage - 0001:00062F0C Startup - 0001:00039284 StdActns - 0001:00037288 StdCtrls - 0001:000244AC StdWndProc - 0001:000763F0 StdWndProc - 0002:00003A98 StockBrush - 0002:00003A9C StockFont - 0002:00003AA0 StockIcon - 0002:00003A94 StockPen - 0001:00008520 StrAlloc - 0001:00008534 StrBufSize - 0001:0000BE38 StrByteType - 0001:0000C024 StrCharLength - 0001:000083F0 StrComp - 0001:00008350 StrCopy - 0001:0000856C StrDispose - 0001:0006D040 StreamLoad - 0001:0006CFE0 StreamSave - 0001:0004CD24 StreamsEqual - 0001:0000832C StrEnd - 0001:00006140 StretchBlt - 0001:00008A08 StrFmt - 0001:00008414 StrIComp - 0001:00014A1C StringCompare - 0001:0001D45C StringListCompareStrings - 0001:0000C868 StringReplace - 0001:00004504 StringToOleStr - 0001:000536FC StripHotkey - 0001:00008378 StrLCopy - 0001:00008314 StrLen - 0001:00008A48 StrLFmt - 0001:00008454 StrLIComp - 0001:00008340 StrMove - 0001:00008540 StrNew - 0001:0000C044 StrNextChar - 0001:0000850C StrPas - 0001:000083AC StrPCopy - 0001:000083D0 StrPLCopy - 0001:000084B8 StrPos - 0001:00008498 StrScan - 0001:0000AB48 StrToDate - 0001:0000AC18 StrToDateTime - 0001:00009218 StrToFloat - 0001:00007D8C StrToInt - 0001:00007DC8 StrToIntDef - 0001:0000ABB0 StrToTime - 0001:0003911C StrUtils - 0002:00000DE0 Styles - 0001:00018158 Succeeded - 0001:0000CF64 Supports - 0001:0000CF88 Supports - 0002:00000660 SyncList - 0001:00062068 SyncObjs - 0001:00000368 SysAllocStringLen - 0002:00001194 SysColorValues - 0001:00006C0C SysConst - 0002:00000DA8 SysConsts - 0002:00000DB0 SysConsts - 0001:0000ACD8 SysErrorMessage - 0001:00001304 SysFreeMem - 0001:00000378 SysFreeString - 0001:00018148 SysFreeString - 0001:00001174 SysGetMem - 0001:00005B54 SysInit - 0002:000037F4 SysLocale - 0001:00001678 SysReallocMem - 0001:00000370 SysReAllocStringLen - 0001:00005994 System - 0002:00003A88 SystemPalette16 - 0001:00027E98 SystemPaletteOverride - 0001:00006620 SystemParametersInfo - 0001:0000D4F4 SysUtils - 0001:00064ECC TAbstractSocket.DoError - 0001:00064EB8 TAbstractSocket.DoEvent - 0001:00064F04 TAbstractSocket.InitSocket - 0001:00064F1C TAbstractSocket.Loaded - 0001:000650E0 TAbstractSocket.Open - 0001:00064EE4 TAbstractSocket.SetActive - 0001:00064F34 TAbstractSocket.SetAddress - 0001:00064FB4 TAbstractSocket.SetHost - 0001:00065034 TAbstractSocket.SetPort - 0001:00065060 TAbstractSocket.SetService - 0001:0004B4C8 TActionLink.IsCaptionLinked - 0001:0004B4DC TActionLink.IsCheckedLinked - 0001:0004B4F0 TActionLink.IsEnabledLinked - 0001:0004B504 TActionLink.IsGroupIndexLinked - 0001:0004B518 TActionLink.IsHelpContextLinked - 0001:0004B52C TActionLink.IsHelpLinked - 0001:0004B540 TActionLink.IsHintLinked - 0001:0004B554 TActionLink.IsImageIndexLinked - 0001:0004B568 TActionLink.IsShortCutLinked - 0001:0004B57C TActionLink.IsVisibleLinked - 0001:0004B590 TActionLink.SetAutoCheck - 0001:0004B594 TActionLink.SetCaption - 0001:0004B598 TActionLink.SetChecked - 0001:0004B59C TActionLink.SetEnabled - 0001:0004B5A0 TActionLink.SetGroupIndex - 0001:0004B5A4 TActionLink.SetHelpContext - 0001:0004B5A8 TActionLink.SetHelpKeyword - 0001:0004B5AC TActionLink.SetHelpType - 0001:0004B5B0 TActionLink.SetHint - 0001:0004B5B4 TActionLink.SetImageIndex - 0001:0004B5B8 TActionLink.SetShortCut - 0001:0004B5BC TActionLink.SetVisible - 0001:0006002C TApplication.ActivateHint - 0001:0005EC20 TApplication.BringToFront - 0001:0005FDA8 TApplication.CancelHint - 0001:0005E230 TApplication.CheckIniChange - 0001:0005E004 TApplication.ControlDestroyed - 0001:0005DB58 TApplication.Create - 0001:0005F0B4 TApplication.CreateForm - 0001:0005DE60 TApplication.CreateHandle - 0001:0005DD44 TApplication.Destroy - 0001:000603FC TApplication.DispatchAction - 0001:0005F76C TApplication.DoActionIdle - 0001:0005F7D0 TApplication.DoMouseIdle - 0001:0005E0D4 TApplication.DoNormalizeTopMosts - 0001:0006048C TApplication.ExecuteAction - 0001:000603C0 TApplication.GetCurrentHelpFile - 0001:0005F70C TApplication.GetExeName - 0001:0005EA54 TApplication.GetIconHandle - 0001:0005EC5C TApplication.GetTitle - 0001:0005F234 TApplication.HandleException - 0001:0005EFA0 TApplication.HandleMessage - 0001:0005F704 TApplication.HelpCommand - 0001:0005F69C TApplication.HelpContext - 0001:0005F634 TApplication.HelpKeyword - 0001:0005FD64 TApplication.HideHint - 0001:0005FC1C TApplication.HintMouseMessage - 0001:0005FD2C TApplication.HintTimerExpired - 0001:0005EFC4 TApplication.HookMainWindow - 0001:00060538 TApplication.HookSynchronizeWakeup - 0001:0005F9AC TApplication.IconChanged - 0001:0005F854 TApplication.Idle - 0001:0005F09C TApplication.Initialize - 0001:0005F504 TApplication.InvokeHelp - 0001:0005ED38 TApplication.IsDlgMsg - 0001:0005EE50 TApplication.IsHintMsg - 0001:0005ED98 TApplication.IsKeyMsg - 0001:0005ED5C TApplication.IsMDIMsg - 0001:0005EE84 TApplication.IsShortCut - 0001:0005F2C4 TApplication.MessageBox - 0001:0005EA70 TApplication.Minimize - 0001:0005E18C TApplication.NormalizeAllTopMosts - 0001:0005E184 TApplication.NormalizeTopMosts - 0001:0005F970 TApplication.NotifyForms - 0001:0005EEF0 TApplication.ProcessMessage - 0001:0005EF88 TApplication.ProcessMessages - 0001:0005EB20 TApplication.Restore - 0001:0005E194 TApplication.RestoreTopMosts - 0001:0005F134 TApplication.Run - 0001:0005FA10 TApplication.SetHint - 0001:0005F71C TApplication.SetShowHint - 0001:0005E288 TApplication.SettingChange - 0001:0005ECA8 TApplication.SetTitle - 0001:0005F42C TApplication.ShowException - 0001:0005FBB0 TApplication.StartHintTimer - 0001:0005FBF4 TApplication.StopHintTimer - 0001:0005F220 TApplication.Terminate - 0001:0005F020 TApplication.UnhookMainWindow - 0001:00060548 TApplication.UnhookSynchronizeWakeup - 0001:000604B4 TApplication.UpdateAction - 0001:0005FB00 TApplication.UpdateVisible - 0001:0005E218 TApplication.UseRightToLeftAlignment - 0001:0005E200 TApplication.UseRightToLeftReading - 0001:0005FB88 TApplication.ValidateHelpSystem - 0001:00060528 TApplication.WakeMainThread - 0001:0005E37C TApplication.WndProc - 0002:00000D98 TaskActiveWindow - 0002:00000DA0 TaskFirstTopMost - 0002:00000D9C TaskFirstWindow - 0002:00000DA4 TaskWindowList - 0001:0003CB6C TBaseDragControlObject.Assign - 0001:0003CB48 TBaseDragControlObject.Create - 0001:0003CB98 TBaseDragControlObject.EndDrag - 0001:0003CBC4 TBaseDragControlObject.Finished - 0001:00023EDC TBasicAction.Change - 0001:00023D78 TBasicAction.Create - 0001:00023DBC TBasicAction.Destroy - 0001:00023E48 TBasicAction.Execute - 0001:00023E18 TBasicAction.ExecuteTarget - 0001:00023E14 TBasicAction.HandlesTarget - 0001:00023E1C TBasicAction.Notification - 0001:00023EF0 TBasicAction.RegisterChanges - 0001:00023E80 TBasicAction.SetOnExecute - 0001:00023EFC TBasicAction.UnRegisterChanges - 0001:00023E64 TBasicAction.Update - 0001:00023E44 TBasicAction.UpdateTarget - 0001:00023CA8 TBasicActionLink.AssignClient - 0001:00023CE0 TBasicActionLink.Change - 0001:00023C64 TBasicActionLink.Create - 0001:00023CAC TBasicActionLink.Destroy - 0001:00023CF8 TBasicActionLink.Execute - 0001:00023D60 TBasicActionLink.IsOnExecuteLinked - 0001:00023D34 TBasicActionLink.SetAction - 0001:00023D64 TBasicActionLink.SetOnExecute - 0001:00023D6C TBasicActionLink.Update - 0001:00029BF4 TBitmap.Assign - 0001:00029DC8 TBitmap.Changed - 0001:00029DA4 TBitmap.Changing - 0001:00029CE4 TBitmap.CopyImage - 0001:00029B50 TBitmap.Create - 0001:00029BB8 TBitmap.Destroy - 0001:0002A254 TBitmap.DIBNeeded - 0001:00029DD4 TBitmap.Dormant - 0001:00029E48 TBitmap.Draw - 0001:0002A2C8 TBitmap.FreeContext - 0001:0002A098 TBitmap.FreeImage - 0001:0002A118 TBitmap.GetCanvas - 0001:0002A0FC TBitmap.GetEmpty - 0001:0002A160 TBitmap.GetHandle - 0001:0002A184 TBitmap.GetHandleType - 0001:0002A1B0 TBitmap.GetHeight - 0001:0002A1C0 TBitmap.GetMaskHandle - 0001:0002A1D4 TBitmap.GetMonochrome - 0001:0002A1F0 TBitmap.GetPalette - 0001:0002A204 TBitmap.GetTransparentColor - 0001:0002A24C TBitmap.GetWidth - 0001:0002A2D8 TBitmap.HandleNeeded - 0001:0002A490 TBitmap.LoadFromClipboardFormat - 0001:0002A514 TBitmap.LoadFromStream - 0001:0002A378 TBitmap.MaskHandleNeeded - 0001:0002A538 TBitmap.NewImage - 0001:0002A3D8 TBitmap.PaletteNeeded - 0001:0002A638 TBitmap.ReadData - 0001:0002A660 TBitmap.ReadDIB - 0001:0002ABC8 TBitmap.ReadStream - 0001:0002B2F8 TBitmap.SaveToClipboardFormat - 0001:0002B2F0 TBitmap.SaveToStream - 0001:0002AC38 TBitmap.SetHandle - 0001:0002ACFC TBitmap.SetHandleType - 0001:0002AE34 TBitmap.SetHeight - 0001:0002AE88 TBitmap.SetMonochrome - 0001:0002AF08 TBitmap.SetPalette - 0001:0002AFDC TBitmap.SetWidth - 0001:0002B030 TBitmap.WriteData - 0001:0002B038 TBitmap.WriteStream - 0001:00028EB4 TBitmapCanvas.Create - 0001:00028FBC TBitmapCanvas.CreateHandle - 0001:00028EF0 TBitmapCanvas.Destroy - 0001:00028F1C TBitmapCanvas.FreeContext - 0001:000290CC TBitmapImage.Destroy - 0001:00029128 TBitmapImage.FreeHandle - 0001:0001B4CC TBits.Destroy - 0001:0001B4FC TBits.Error - 0001:0001B5F0 TBits.OpenBit - 0001:0001B5C4 TBits.SetBit - 0001:0001B520 TBits.SetSize - 0001:00026B0C TBrush.Assign - 0001:00026AA4 TBrush.Create - 0001:00026AE4 TBrush.Destroy - 0001:00026C44 TBrush.GetColor - 0001:00026BB4 TBrush.GetData - 0001:00026C80 TBrush.GetHandle - 0001:00026D60 TBrush.GetStyle - 0001:00026C20 TBrush.SetBitmap - 0001:00026C4C TBrush.SetColor - 0001:00026BD0 TBrush.SetData - 0001:00026D68 TBrush.SetStyle - 0001:000369D0 TButton.Click - 0001:00036B58 TButton.CMDialogChar - 0001:00036AE8 TButton.CMDialogKey - 0001:00036BDC TButton.CMFocusChanged - 0001:00036AD4 TButton.CNCommand - 0001:0003696C TButton.Create - 0001:00036A80 TButton.CreateParams - 0001:00036ABC TButton.CreateWnd - 0001:000369F8 TButton.SetButtonStyle - 0001:00036A4C TButton.SetDefault - 0001:000369F4 TButton.UseRightToLeftAlignment - 0001:00036C30 TButton.WMEraseBkgnd - 0001:00036768 TButtonActionLink.AssignClient - 0001:0003678C TButtonActionLink.IsCheckedLinked - 0001:000367C4 TButtonActionLink.SetChecked - 0001:0003687C TButtonControl.ActionChange - 0001:00036828 TButtonControl.Create - 0001:000368C4 TButtonControl.GetActionLinkClass - 0001:000368CC TButtonControl.GetChecked - 0001:000368D0 TButtonControl.IsCheckedStored - 0001:000368F0 TButtonControl.SetChecked - 0001:000368F4 TButtonControl.WndProc - 0001:000276DC TCanvas.BrushChanged - 0001:000275B0 TCanvas.Changed - 0001:0002759C TCanvas.Changing - 0001:00026EBC TCanvas.CopyRect - 0001:00026D9C TCanvas.Create - 0001:00027620 TCanvas.CreateBrush - 0001:000275C4 TCanvas.CreateFont - 0001:000274D0 TCanvas.CreateHandle - 0001:000275F0 TCanvas.CreatePen - 0001:00027474 TCanvas.DeselectHandles - 0001:00026E60 TCanvas.Destroy - 0001:00026F44 TCanvas.Draw - 0001:00026FF0 TCanvas.FillRect - 0001:0002769C TCanvas.FontChanged - 0001:0002702C TCanvas.FrameRect - 0001:000271B8 TCanvas.GetCanvasOrientation - 0001:00027454 TCanvas.GetHandle - 0001:0002739C TCanvas.GetPenPos - 0001:000273E0 TCanvas.GetPixel - 0001:00027068 TCanvas.LineTo - 0001:000270A0 TCanvas.Lock - 0001:000270C8 TCanvas.MoveTo - 0001:000276BC TCanvas.PenChanged - 0001:000270F4 TCanvas.Polyline - 0001:0002712C TCanvas.Rectangle - 0001:00027174 TCanvas.Refresh - 0001:00027528 TCanvas.RequiredState - 0001:00027390 TCanvas.SetBrush - 0001:00027374 TCanvas.SetFont - 0001:000274D4 TCanvas.SetHandle - 0001:00027384 TCanvas.SetPen - 0001:000273C0 TCanvas.SetPenPos - 0001:0002740C TCanvas.SetPixel - 0001:0002717C TCanvas.StretchDraw - 0001:00027270 TCanvas.TextExtent - 0001:000272D0 TCanvas.TextHeight - 0001:000271E4 TCanvas.TextOut - 0001:000272B4 TCanvas.TextWidth - 0001:000272F0 TCanvas.TryLock - 0001:0002734C TCanvas.Unlock - 0001:0004D4CC TChangeLink.Change - 0001:0004D498 TChangeLink.Destroy - 0001:0001A338 TClassFinder.Create - 0001:0001A464 TClassFinder.Destroy - 0001:0001A494 TClassFinder.GetClass - 0001:00065214 TClientSocket.Create - 0001:00065274 TClientSocket.Destroy - 0001:000652A4 TClientSocket.DoActivate - 0001:000652F4 TClientSocket.GetClientType - 0001:00065300 TClientSocket.SetClientType - 0001:00064124 TClientWinSocket.Connect - 0001:00064138 TClientWinSocket.SetClientType - 0001:0001BC68 TCollection.Add - 0001:0001C0F4 TCollection.Added - 0001:0001BC88 TCollection.Assign - 0001:0001BD20 TCollection.BeginUpdate - 0001:0001BD24 TCollection.Changed - 0001:0001BD34 TCollection.Clear - 0001:0001BBD0 TCollection.Create - 0001:0001C0B8 TCollection.Delete - 0001:0001C0F8 TCollection.Deleting - 0001:0001BC1C TCollection.Destroy - 0001:0001BD9C TCollection.EndUpdate - 0001:0001BDAC TCollection.GetAttr - 0001:0001BDA8 TCollection.GetAttrCount - 0001:0001BDD8 TCollection.GetCount - 0001:0001BDE0 TCollection.GetItem - 0001:0001BDB8 TCollection.GetItemAttr - 0001:0001BDF4 TCollection.GetNamePath - 0001:0001BEBC TCollection.GetPropName - 0001:0001BFD8 TCollection.Insert - 0001:0001BFF4 TCollection.InsertItem - 0001:0001C0FC TCollection.Notify - 0001:0001C0E8 TCollection.Owner - 0001:0001C05C TCollection.RemoveItem - 0001:0001C0B0 TCollection.SetItemName - 0001:0001C0B4 TCollection.Update - 0001:0001BA54 TCollectionItem.Changed - 0001:0001B9EC TCollectionItem.Create - 0001:0001BA24 TCollectionItem.Destroy - 0001:0001BA90 TCollectionItem.GetDisplayName - 0001:0001BA78 TCollectionItem.GetIndex - 0001:0001BAB8 TCollectionItem.GetNamePath - 0001:0001BB6C TCollectionItem.GetOwner - 0001:0001BB70 TCollectionItem.SetCollection - 0001:0001BB98 TCollectionItem.SetDisplayName - 0001:0001BBA0 TCollectionItem.SetIndex - 0001:00074CDC TComboBoxExActionLink.AddItem - 0001:00074D4C TComboBoxExActionLink.AddItem - 0001:00074804 TComboBoxExStrings.Add - 0001:00074828 TComboBoxExStrings.AddObject - 0001:00074858 TComboBoxExStrings.Clear - 0001:000748C0 TComboBoxExStrings.Create - 0001:0007494C TComboBoxExStrings.Delete - 0001:0007491C TComboBoxExStrings.Destroy - 0001:00074958 TComboBoxExStrings.Exchange - 0001:00074AA4 TComboBoxExStrings.Get - 0001:00074AC8 TComboBoxExStrings.GetCapacity - 0001:00074AD4 TComboBoxExStrings.GetCount - 0001:00074BF0 TComboBoxExStrings.GetItemClass - 0001:00074BE8 TComboBoxExStrings.GetItemsClass - 0001:00074AE0 TComboBoxExStrings.GetObject - 0001:00074AF8 TComboBoxExStrings.IndexOf - 0001:00074B44 TComboBoxExStrings.IndexOfName - 0001:00074B4C TComboBoxExStrings.Insert - 0001:00074B60 TComboBoxExStrings.Move - 0001:00074B80 TComboBoxExStrings.Put - 0001:00074B94 TComboBoxExStrings.PutObject - 0001:00074BA8 TComboBoxExStrings.SetUpdateState - 0001:00034A30 TComboBoxStrings.Add - 0001:00034AB4 TComboBoxStrings.Insert - 0001:00073BEC TComboExItem.Assign - 0001:00073C38 TComboExItem.SetCaption - 0001:00073C6C TComboExItem.SetData - 0001:00073CA0 TComboExItem.SetDisplayName - 0001:00073CC0 TComboExItem.SetImageIndex - 0001:00073CF0 TComboExItem.SetIndex - 0001:00073D0C TComboExItem.SetOverlayImageIndex - 0001:00073D28 TComboExItem.SetSelectedImageIndex - 0001:00073D44 TComboExItems.Add - 0001:00073D50 TComboExItems.AddItem - 0001:00073DB8 TComboExItems.GetComboItem - 0001:00073DCC TComboExItems.Insert - 0001:00073DE0 TComboExItems.Notify - 0001:00073E50 TComboExItems.SetItem - 0001:00038A8C TCommonDialog.Create - 0001:00038B30 TCommonDialog.DefaultHandler - 0001:00038AD4 TCommonDialog.Destroy - 0001:00038CD4 TCommonDialog.DoClose - 0001:00038CE8 TCommonDialog.DoShow - 0001:00038B68 TCommonDialog.MainWndProc - 0001:00038B08 TCommonDialog.MessageHook - 0001:00038C00 TCommonDialog.TaskModalDialog - 0001:00038BBC TCommonDialog.WMDestroy - 0001:00038BD4 TCommonDialog.WMInitDialog - 0001:00038BEC TCommonDialog.WMNCDestroy - 0001:00038BB4 TCommonDialog.WndProc - 0001:00023514 TComponent.BeforeDestruction - 0001:00023A34 TComponent.ChangeName - 0001:00023450 TComponent.Create - 0001:000237C8 TComponent.DefineProperties - 0001:0002349C TComponent.Destroy - 0001:00023698 TComponent.DestroyComponents - 0001:000236F0 TComponent.Destroying - 0001:00023B70 TComponent.ExecuteAction - 0001:00023958 TComponent.FindComponent - 0001:00023520 TComponent.FreeNotification - 0001:0002385C TComponent.GetChildOwner - 0001:00023860 TComponent.GetChildParent - 0001:00023854 TComponent.GetChildren - 0001:00023A48 TComponent.GetComponent - 0001:00023A74 TComponent.GetComponentCount - 0001:00023864 TComponent.GetNamePath - 0001:00023878 TComponent.GetOwner - 0001:00023880 TComponent.GetParentComponent - 0001:00023850 TComponent.HasParent - 0001:000235B4 TComponent.Insert - 0001:00023608 TComponent.InsertComponent - 0001:00023C60 TComponent.IntfGetComponent - 0001:000238A0 TComponent.Loaded - 0001:0002376C TComponent.Notification - 0001:000238AC TComponent.PaletteCreated - 0001:00023BE0 TComponent.QueryInterface - 0001:00023574 TComponent.ReadLeft - 0001:000238B0 TComponent.ReadState - 0001:00023588 TComponent.ReadTop - 0001:000235E0 TComponent.Remove - 0001:00023660 TComponent.RemoveComponent - 0001:00023750 TComponent.RemoveFreeNotification - 0001:0002372C TComponent.RemoveNotification - 0001:00023BC0 TComponent.SafeCallException - 0001:0002387C TComponent.SetChildOrder - 0001:00023A84 TComponent.SetComponentIndex - 0001:00023AD8 TComponent.SetDesigning - 0001:000239A8 TComponent.SetName - 0001:00023884 TComponent.SetParentComponent - 0001:00023B28 TComponent.SetReference - 0001:00023B98 TComponent.UpdateAction - 0001:00023894 TComponent.Updated - 0001:00023BD8 TComponent.UpdateRegistry - 0001:00023888 TComponent.Updating - 0001:00023940 TComponent.ValidateContainer - 0001:00023954 TComponent.ValidateInsert - 0001:000238C0 TComponent.ValidateRename - 0001:0002359C TComponent.WriteLeft - 0001:000238B8 TComponent.WriteState - 0001:000235A8 TComponent.WriteTop - 0001:00023C20 TComponent._AddRef - 0001:00023C40 TComponent._Release - 0001:0004AF64 TContainedAction.Destroy - 0001:0004B0D0 TContainedAction.Execute - 0001:0004AF98 TContainedAction.GetIndex - 0001:0004AFB4 TContainedAction.GetParentComponent - 0001:0004AFC4 TContainedAction.HasParent - 0001:0004AFB0 TContainedAction.IsCategoryStored - 0001:0004AFD4 TContainedAction.ReadState - 0001:0004B07C TContainedAction.SetActionList - 0001:0004B050 TContainedAction.SetCategory - 0001:0004B008 TContainedAction.SetIndex - 0001:0004B0A4 TContainedAction.SetParentComponent - 0001:0004B128 TContainedAction.Update - 0001:00041440 TControl.ActionChange - 0001:0004182C TControl.AdjustSize - 0001:00041660 TControl.AssignTo - 0001:0003FBFC TControl.BeginAutoDrag - 0001:0003FC14 TControl.BeginDrag - 0001:0003F794 TControl.BringToFront - 0001:000405EC TControl.CalcCursorPos - 0001:00040754 TControl.CalcDockSizes - 0001:000404EC TControl.CanAutoSize - 0001:000404F0 TControl.CanResize - 0001:0003F140 TControl.Changed - 0001:0003F150 TControl.ChangeScale - 0001:00040CB0 TControl.CheckNewSize - 0001:00040AA8 TControl.Click - 0001:0003F04C TControl.ClientToScreen - 0001:000411F4 TControl.CMBiDiModeChanged - 0001:0004113C TControl.CMColorChanged - 0001:000412C8 TControl.CMDesignHitTest - 0001:0004112C TControl.CMEnabledChanged - 0001:000413E0 TControl.CMFloat - 0001:00041134 TControl.CMFontChanged - 0001:000418B8 TControl.CMHintShow - 0001:00041290 TControl.CMHitTest - 0001:00041298 TControl.CMMouseEnter - 0001:000412B0 TControl.CMMouseLeave - 0001:00041198 TControl.CMMouseWheel - 0001:00041174 TControl.CMParentBiDiModeChanged - 0001:00041144 TControl.CMParentColorChanged - 0001:0004123C TControl.CMParentFontChanged - 0001:00041214 TControl.CMParentShowHintChanged - 0001:0004126C TControl.CMSysFontChanged - 0001:00041104 TControl.CMVisibleChanged - 0001:000405BC TControl.ConstrainedResize - 0001:0003E634 TControl.Create - 0001:000412D0 TControl.CreateFloatingDockSite - 0001:00040B14 TControl.DblClick - 0001:00040028 TControl.DefaultDockImage - 0001:00040980 TControl.DefaultHandler - 0001:00040A58 TControl.DefineProperties - 0001:00040618 TControl.DesignWndProc - 0001:0003E70C TControl.Destroy - 0001:0004153C TControl.DoActionChange - 0001:00040520 TControl.DoCanAutoSize - 0001:0004058C TControl.DoCanResize - 0001:0003ED38 TControl.Dock - 0001:0003FE6C TControl.DockTrackNoTarget - 0001:0004064C TControl.DoConstrainedResize - 0001:000404E0 TControl.DoConstraintsChange - 0001:00041A0C TControl.DoContextPopup - 0001:0003EE44 TControl.DoDock - 0001:0004017C TControl.DoDragMsg - 0001:0003FE80 TControl.DoEndDock - 0001:0003FD70 TControl.DoEndDrag - 0001:00040B6C TControl.DoMouseDown - 0001:00040ECC TControl.DoMouseUp - 0001:0003FECC TControl.DoMouseWheel - 0001:0003FF90 TControl.DoMouseWheelDown - 0001:0003FFDC TControl.DoMouseWheelUp - 0001:0003FEAC TControl.DoStartDock - 0001:0003FD50 TControl.DoStartDrag - 0001:0003FCD8 TControl.DragCanceled - 0001:0003FD24 TControl.DragDrop - 0001:0003FCDC TControl.Dragging - 0001:0003FCE8 TControl.DragOver - 0001:00040154 TControl.DrawDragDockImage - 0001:0004184C TControl.DrawTextBiDiModeFlags - 0001:0004188C TControl.DrawTextBiDiModeFlagsReadingOnly - 0001:00040168 TControl.EraseDragDockImage - 0001:0003F5E4 TControl.FontChanged - 0001:0003E878 TControl.GetAction - 0001:00041560 TControl.GetActionLinkClass - 0001:0003EED4 TControl.GetBoundsRect - 0001:0003EF7C TControl.GetClientHeight - 0001:0003EFBC TControl.GetClientOrigin - 0001:0003EF20 TControl.GetClientRect - 0001:0003EF38 TControl.GetClientWidth - 0001:0003FBAC TControl.GetControlsAlignment - 0001:0003F848 TControl.GetDeviceContext - 0001:00041748 TControl.GetDockEdge - 0001:0003E7C0 TControl.GetDragImages - 0001:0003E7C4 TControl.GetEnabled - 0001:000417F8 TControl.GetFloating - 0001:00041824 TControl.GetFloatingDockSiteClass - 0001:0003F75C TControl.GetMouseCapture - 0001:0003E7C8 TControl.GetPalette - 0001:0003E7D4 TControl.GetParentComponent - 0001:00040CAC TControl.GetPopupMenu - 0001:0003F534 TControl.GetText - 0001:0003F4B8 TControl.GetTextBuf - 0001:0003F4A8 TControl.GetTextLen - 0001:0003F4C4 TControl.GetUndockHeight - 0001:0003F4D8 TControl.GetUndockWidth - 0001:0003E7CC TControl.HasParent - 0001:0003FA5C TControl.Hide - 0001:000418A8 TControl.InitiateAction - 0001:0003FA08 TControl.Invalidate - 0001:0003F97C TControl.InvalidateControl - 0001:0003E924 TControl.IsAnchorsStored - 0001:0003F658 TControl.IsBiDiModeStored - 0001:00041568 TControl.IsCaptionStored - 0001:0003F6F0 TControl.IsColorStored - 0001:00041588 TControl.IsEnabledStored - 0001:0003F638 TControl.IsFontStored - 0001:000415C8 TControl.IsHelpContextStored - 0001:000415A8 TControl.IsHintStored - 0001:00041608 TControl.IsOnClickStored - 0001:0003F64C TControl.IsShowHintStored - 0001:000415E8 TControl.IsVisibleStored - 0001:00041628 TControl.Loaded - 0001:0004026C TControl.ManualDock - 0001:0004044C TControl.ManualFloat - 0001:00040B34 TControl.MouseDown - 0001:00040DEC TControl.MouseMove - 0001:00040E94 TControl.MouseUp - 0001:0003FA18 TControl.MouseWheelHandler - 0001:0003EA04 TControl.Notification - 0001:0003E800 TControl.PaletteChanged - 0001:00040720 TControl.Perform - 0001:0003FD9C TControl.PositionDockRect - 0001:00040A08 TControl.ReadIsControl - 0001:0003E970 TControl.ReadState - 0001:0003FAA8 TControl.Refresh - 0001:0003FAB4 TControl.Repaint - 0001:0003E940 TControl.RequestAlign - 0001:0003E950 TControl.Resize - 0001:0003F078 TControl.ScreenToClient - 0001:0003F0A4 TControl.SendCancelMode - 0001:0003F0D4 TControl.SendDockNotification - 0001:0003E8A8 TControl.SetAction - 0001:0003EA48 TControl.SetAlign - 0001:0003E888 TControl.SetAnchors - 0001:0003F304 TControl.SetAutoSize - 0001:0003F5C8 TControl.SetBiDiMode - 0001:0003EAF0 TControl.SetBounds - 0001:0003EEF4 TControl.SetBoundsRect - 0001:0003EF94 TControl.SetClientHeight - 0001:0003F3C0 TControl.SetClientSize - 0001:0003EF50 TControl.SetClientWidth - 0001:0003F6D4 TControl.SetColor - 0001:00041A40 TControl.SetConstraints - 0001:0003F740 TControl.SetCursor - 0001:0003E93C TControl.SetDragMode - 0001:0003F490 TControl.SetEnabled - 0001:0003F628 TControl.SetFont - 0001:0003ED14 TControl.SetHeight - 0001:0003EE9C TControl.SetHelpContext - 0001:0003EEB0 TControl.SetHelpKeyword - 0001:0003ECA4 TControl.SetLeft - 0001:0003F76C TControl.SetMouseCapture - 0001:0003F31C TControl.SetName - 0001:0003F408 TControl.SetParent - 0001:0003F71C TControl.SetParentBiDiMode - 0001:0003F6F8 TControl.SetParentColor - 0001:0003E7D8 TControl.SetParentComponent - 0001:0003F660 TControl.SetParentFont - 0001:0003F6A8 TControl.SetParentShowHint - 0001:0003F4EC TControl.SetPopupMenu - 0001:0003F684 TControl.SetShowHint - 0001:0003F564 TControl.SetText - 0001:0003F510 TControl.SetTextBuf - 0001:0003ECC8 TControl.SetTop - 0001:0003F454 TControl.SetVisible - 0001:0003ECF0 TControl.SetWidth - 0001:0003F824 TControl.SetZOrder - 0001:0003F7A4 TControl.SetZOrderPosition - 0001:0003FA64 TControl.Show - 0001:0003FA94 TControl.Update - 0001:0003EB88 TControl.UpdateAnchorRules - 0001:000407C4 TControl.UpdateBoundsRect - 0001:0003FBC8 TControl.UseRightToLeftAlignment - 0001:0003FBB0 TControl.UseRightToLeftReading - 0001:0003FBE0 TControl.UseRightToLeftScrollBar - 0001:000407E8 TControl.VisibleChanging - 0001:00041014 TControl.WMCancelMode - 0001:000418E4 TControl.WMContextMenu - 0001:00040C58 TControl.WMLButtonDblClk - 0001:00040BF0 TControl.WMLButtonDown - 0001:00040F04 TControl.WMLButtonUp - 0001:00040DC4 TControl.WMMButtonDblClk - 0001:00040D9C TControl.WMMButtonDown - 0001:00040F9C TControl.WMMButtonUp - 0001:00040E1C TControl.WMMouseMove - 0001:00040FBC TControl.WMMouseWheel - 0001:00040C3C TControl.WMNCLButtonDown - 0001:00040D74 TControl.WMRButtonDblClk - 0001:00040D4C TControl.WMRButtonDown - 0001:00040F7C TControl.WMRButtonUp - 0001:00041054 TControl.WMWindowPosChanged - 0001:000407EC TControl.WndProc - 0001:00040A1C TControl.WriteIsControl - 0001:0003E278 TControlActionLink.AssignClient - 0001:0003E294 TControlActionLink.DoShowHint - 0001:0003E384 TControlActionLink.IsCaptionLinked - 0001:0003E3F8 TControlActionLink.IsEnabledLinked - 0001:0003E570 TControlActionLink.IsHelpLinked - 0001:0003E42C TControlActionLink.IsHintLinked - 0001:0003E498 TControlActionLink.IsOnExecuteLinked - 0001:0003E464 TControlActionLink.IsVisibleLinked - 0001:0003E4C0 TControlActionLink.SetCaption - 0001:0003E4E0 TControlActionLink.SetEnabled - 0001:0003E5F4 TControlActionLink.SetHelpContext - 0001:0003E5D4 TControlActionLink.SetHelpKeyword - 0001:0003E614 TControlActionLink.SetHelpType - 0001:0003E500 TControlActionLink.SetHint - 0001:0003E544 TControlActionLink.SetOnExecute - 0001:0003E524 TControlActionLink.SetVisible - 0001:0003E034 TControlCanvas.CreateHandle - 0001:0003E008 TControlCanvas.Destroy - 0001:0003E0DC TControlCanvas.FreeHandle - 0001:0003E110 TControlCanvas.SetControl - 0001:0003E128 TControlCanvas.UpdateTextFlags - 0001:000565C0 TControlScrollBar.Assign - 0001:0005671C TControlScrollBar.CalcAutoRange - 0001:00056610 TControlScrollBar.ChangeBiDiPosition - 0001:000568B0 TControlScrollBar.ControlSize - 0001:00056530 TControlScrollBar.Create - 0001:00056E50 TControlScrollBar.DoSetRange - 0001:000565B8 TControlScrollBar.IsIncrementStored - 0001:00056E7C TControlScrollBar.IsRangeStored - 0001:000567C8 TControlScrollBar.IsScrollBarVisible - 0001:00056930 TControlScrollBar.NeedsScrollBarVisible - 0001:000569A8 TControlScrollBar.ScrollMessage - 0001:00056CA0 TControlScrollBar.SetButtonSize - 0001:00056CE4 TControlScrollBar.SetColor - 0001:00056D00 TControlScrollBar.SetParentColor - 0001:00056D18 TControlScrollBar.SetPosition - 0001:00056E68 TControlScrollBar.SetRange - 0001:00056DDC TControlScrollBar.SetSize - 0001:00056E20 TControlScrollBar.SetStyle - 0001:00056E38 TControlScrollBar.SetThumbSize - 0001:00056E88 TControlScrollBar.SetVisible - 0001:00056F9C TControlScrollBar.Update - 0001:0006C954 TConversion.ConvertReadStream - 0001:0006C968 TConversion.ConvertWriteStream - 0001:00062010 TCriticalSection.Acquire - 0001:00061FA0 TCriticalSection.Create - 0001:00061FE0 TCriticalSection.Destroy - 0001:00062028 TCriticalSection.Enter - 0001:00062030 TCriticalSection.Leave - 0001:0006201C TCriticalSection.Release - 0001:0004B664 TCustomAction.AssignTo - 0001:0004B5C0 TCustomAction.Create - 0001:0004B614 TCustomAction.Destroy - 0001:0004BB7C TCustomAction.DoHint - 0001:0004BBA4 TCustomAction.Execute - 0001:0004BBF4 TCustomAction.GetSecondaryShortCuts - 0001:0004BC74 TCustomAction.HandleShortCut - 0001:0004BC50 TCustomAction.IsSecondaryShortCutsStored - 0001:0004B710 TCustomAction.SetCaption - 0001:0004B770 TCustomAction.SetChecked - 0001:0004B878 TCustomAction.SetEnabled - 0001:0004B958 TCustomAction.SetHelpContext - 0001:0004B8F0 TCustomAction.SetHelpKeyword - 0001:0004B9B0 TCustomAction.SetHint - 0001:0004BA10 TCustomAction.SetImageIndex - 0001:0004BB30 TCustomAction.SetName - 0001:0004BC1C TCustomAction.SetSecondaryShortCuts - 0001:0004BA6C TCustomAction.SetShortCut - 0001:0004BAD0 TCustomAction.SetVisible - 0001:0004B358 TCustomActionList.AddAction - 0001:0004B394 TCustomActionList.Change - 0001:0004B180 TCustomActionList.Create - 0001:0004B1EC TCustomActionList.Destroy - 0001:0004B488 TCustomActionList.ExecuteAction - 0001:0004B2B4 TCustomActionList.GetAction - 0001:0004B2C8 TCustomActionList.GetActionCount - 0001:0004B23C TCustomActionList.GetChildren - 0001:0004B304 TCustomActionList.ImageListChange - 0001:0004B3FC TCustomActionList.IsShortCut - 0001:0004B310 TCustomActionList.Notification - 0001:0004B378 TCustomActionList.RemoveAction - 0001:0004B284 TCustomActionList.SetChildOrder - 0001:0004B2D0 TCustomActionList.SetImages - 0001:0004B4A8 TCustomActionList.UpdateAction - 0001:00036D1C TCustomCheckBox.Click - 0001:00036E54 TCustomCheckBox.CMCtl3DChanged - 0001:00036E5C TCustomCheckBox.CMDialogChar - 0001:00036EF8 TCustomCheckBox.CNCommand - 0001:00036C44 TCustomCheckBox.Create - 0001:00036DB8 TCustomCheckBox.CreateParams - 0001:00036E14 TCustomCheckBox.CreateWnd - 0001:00036D30 TCustomCheckBox.GetChecked - 0001:00036CB0 TCustomCheckBox.GetControlsAlignment - 0001:00036D3C TCustomCheckBox.SetAlignment - 0001:00036D50 TCustomCheckBox.SetChecked - 0001:00036D64 TCustomCheckBox.SetState - 0001:00036CDC TCustomCheckBox.Toggle - 0001:00036E40 TCustomCheckBox.WMSize - 0001:00035918 TCustomCombo.AddItem - 0001:00035760 TCustomCombo.AdjustDropDown - 0001:00035580 TCustomCombo.Change - 0001:00034C84 TCustomCombo.Clear - 0001:00035840 TCustomCombo.ClearSelection - 0001:000356DC TCustomCombo.CloseUp - 0001:00034E9C TCustomCombo.CMCancelMode - 0001:00034EB0 TCustomCombo.CMCtl3DChanged - 0001:00035414 TCustomCombo.CNCommand - 0001:00035028 TCustomCombo.ComboWndProc - 0001:0003584C TCustomCombo.CopySelection - 0001:00034B34 TCustomCombo.Create - 0001:00035728 TCustomCombo.CreateWnd - 0001:000358D8 TCustomCombo.DeleteSelected - 0001:00034C28 TCustomCombo.Destroy - 0001:00034CB0 TCustomCombo.DestroyWindowHandle - 0001:00035660 TCustomCombo.DropDown - 0001:00034EFC TCustomCombo.EditWndProc - 0001:000356A8 TCustomCombo.Focused - 0001:00035904 TCustomCombo.GetCount - 0001:00034CF4 TCustomCombo.GetDroppedDown - 0001:00034D60 TCustomCombo.GetItemIndex - 0001:00034FF4 TCustomCombo.ListWndProc - 0001:00035680 TCustomCombo.Loaded - 0001:000356FC TCustomCombo.Select - 0001:00034CD4 TCustomCombo.SelectAll - 0001:00035910 TCustomCombo.SetDropDownCount - 0001:00034D18 TCustomCombo.SetDroppedDown - 0001:00034E08 TCustomCombo.SetItemHeight - 0001:00034D8C TCustomCombo.SetItemIndex - 0001:0003581C TCustomCombo.SetItems - 0001:00034DC8 TCustomCombo.SetMaxLength - 0001:00034E18 TCustomCombo.WMCreate - 0001:00034E64 TCustomCombo.WMDeleteItem - 0001:00034E3C TCustomCombo.WMDrawItem - 0001:00034E78 TCustomCombo.WMGetDlgCode - 0001:00034E50 TCustomCombo.WMMeasureItem - 0001:00035304 TCustomCombo.WndProc - 0001:00034ED4 TCustomComboBox.CMParentColorChanged - 0001:00036354 TCustomComboBox.CNDrawItem - 0001:0003642C TCustomComboBox.CNMeasureItem - 0001:00035970 TCustomComboBox.Create - 0001:00035A9C TCustomComboBox.CreateParams - 0001:00035B00 TCustomComboBox.CreateWnd - 0001:000359E8 TCustomComboBox.Destroy - 0001:00035C40 TCustomComboBox.DestroyWnd - 0001:000355A4 TCustomComboBox.DrawItem - 0001:00036518 TCustomComboBox.GetItemCount - 0001:00035A78 TCustomComboBox.GetItemHt - 0001:00036524 TCustomComboBox.GetItemsClass - 0001:00035DD8 TCustomComboBox.KeyPress - 0001:00036334 TCustomComboBox.MeasureItem - 0001:000361A0 TCustomComboBox.SelectItem - 0001:00035014 TCustomComboBox.SetCharCase - 0001:00035A24 TCustomComboBox.SetSorted - 0001:00035A38 TCustomComboBox.SetStyle - 0001:00035C90 TCustomComboBox.WMEraseBkgnd - 0001:00036458 TCustomComboBox.WMLButtonDown - 0001:00036764 TCustomComboBox.WMNCCalcSize - 0001:0003652C TCustomComboBox.WMPaint - 0001:000364D0 TCustomComboBox.WndProc - 0001:000746C8 TCustomComboBoxEx.ActionChange - 0001:000742BC TCustomComboBoxEx.CMColorChanged - 0001:00074294 TCustomComboBoxEx.CMParentColorChanged - 0001:0007404C TCustomComboBoxEx.CNNotify - 0001:00074394 TCustomComboBoxEx.ComboExWndProc - 0001:00073F34 TCustomComboBoxEx.Create - 0001:0007409C TCustomComboBoxEx.CreateParams - 0001:000743B4 TCustomComboBoxEx.CreateWnd - 0001:00073FE4 TCustomComboBoxEx.Destroy - 0001:00074778 TCustomComboBoxEx.DestroyWnd - 0001:000747C8 TCustomComboBoxEx.Focused - 0001:00074628 TCustomComboBoxEx.GetActionLinkClass - 0001:00074768 TCustomComboBoxEx.GetDropDownCount - 0001:00074604 TCustomComboBoxEx.GetItemCount - 0001:00074770 TCustomComboBoxEx.GetItemHt - 0001:00074610 TCustomComboBoxEx.GetItemsClass - 0001:000741A8 TCustomComboBoxEx.ImageListChange - 0001:00074690 TCustomComboBoxEx.IsItemsExStored - 0001:0007421C TCustomComboBoxEx.Notification - 0001:0007472C TCustomComboBoxEx.SetDropDownCount - 0001:00074114 TCustomComboBoxEx.SetImages - 0001:00074618 TCustomComboBoxEx.SetItemsEx - 0001:0007424C TCustomComboBoxEx.SetStyle - 0001:00074630 TCustomComboBoxEx.SetStyleEx - 0001:0007431C TCustomComboBoxEx.WMLButtonDown - 0001:000741D4 TCustomComboBoxEx.WndProc - 0001:00034944 TCustomComboBoxStrings.Clear - 0001:000349B4 TCustomComboBoxStrings.Delete - 0001:00034900 TCustomComboBoxStrings.Get - 0001:00034848 TCustomComboBoxStrings.GetCount - 0001:00034864 TCustomComboBoxStrings.GetObject - 0001:000349D4 TCustomComboBoxStrings.IndexOf - 0001:000348DC TCustomComboBoxStrings.PutObject - 0001:000349FC TCustomComboBoxStrings.SetUpdateState - 0001:00047608 TCustomControl.Create - 0001:00047664 TCustomControl.Destroy - 0001:00047760 TCustomControl.Paint - 0001:000476B4 TCustomControl.PaintWindow - 0001:00047694 TCustomControl.WMPaint - 0001:0005C7CC TCustomDockForm.CMControlListChange - 0001:0005C824 TCustomDockForm.CMDockNotification - 0001:0005C8F8 TCustomDockForm.CMUnDockClient - 0001:0005C910 TCustomDockForm.CMVisibleChanged - 0001:0005C528 TCustomDockForm.Create - 0001:0005C590 TCustomDockForm.DoAddDockClient - 0001:0005C674 TCustomDockForm.DoRemoveDockClient - 0001:0005C6E0 TCustomDockForm.GetSiteInfo - 0001:0005C694 TCustomDockForm.Loaded - 0001:0005C70C TCustomDockForm.WMNCHitTest - 0001:0005C734 TCustomDockForm.WMNCLButtonDown - 0001:00033EA8 TCustomEdit.AdjustHeight - 0001:00033F50 TCustomEdit.Change - 0001:00033B10 TCustomEdit.Clear - 0001:00033FEC TCustomEdit.CMCtl3DChanged - 0001:00034068 TCustomEdit.CMEnter - 0001:00034020 TCustomEdit.CMFontChanged - 0001:000340A4 TCustomEdit.CMTextChanged - 0001:00034048 TCustomEdit.CNCommand - 0001:00033798 TCustomEdit.Create - 0001:00033C80 TCustomEdit.CreateParams - 0001:00033D3C TCustomEdit.CreateWindowHandle - 0001:00033DAC TCustomEdit.CreateWnd - 0001:00033F74 TCustomEdit.DefaultHandler - 0001:00033E50 TCustomEdit.DestroyWnd - 0001:00033840 TCustomEdit.DoSetMaxLength - 0001:00033904 TCustomEdit.GetModified - 0001:00033A7C TCustomEdit.GetSelLength - 0001:00033A38 TCustomEdit.GetSelStart - 0001:00033BE4 TCustomEdit.GetSelText - 0001:00033B48 TCustomEdit.GetSelTextBuf - 0001:00033B2C TCustomEdit.SelectAll - 0001:00033860 TCustomEdit.SetAutoSize - 0001:00033874 TCustomEdit.SetBorderStyle - 0001:00033898 TCustomEdit.SetCharCase - 0001:000338AC TCustomEdit.SetHideSelection - 0001:000338C0 TCustomEdit.SetMaxLength - 0001:0003393C TCustomEdit.SetModified - 0001:000338F0 TCustomEdit.SetOEMConvert - 0001:00033974 TCustomEdit.SetPasswordChar - 0001:000339FC TCustomEdit.SetReadOnly - 0001:00033AAC TCustomEdit.SetSelLength - 0001:00033A5C TCustomEdit.SetSelStart - 0001:00033E6C TCustomEdit.UpdateHeight - 0001:000340DC TCustomEdit.WMContextMenu - 0001:00033FAC TCustomEdit.WMSetFont - 0001:0005A6C0 TCustomForm.Activate - 0001:0005A4C4 TCustomForm.ActiveChanged - 0001:00057B64 TCustomForm.AfterConstruction - 0001:00058F40 TCustomForm.AlignControls - 0001:00057D0C TCustomForm.BeforeDestruction - 0001:00058428 TCustomForm.BeginAutoDrag - 0001:0005842C TCustomForm.ChangeScale - 0001:00058DF8 TCustomForm.ClientWndProc - 0001:0005BA70 TCustomForm.Close - 0001:0005BB78 TCustomForm.CloseModal - 0001:0005BB14 TCustomForm.CloseQuery - 0001:0005C12C TCustomForm.CMActionExecute - 0001:0005C22C TCustomForm.CMActionUpdate - 0001:0005B2FC TCustomForm.CMActivate - 0001:0005ADBC TCustomForm.CMAppSysCommand - 0001:00058F7C TCustomForm.CMBiDiModeChanged - 0001:00059780 TCustomForm.CMColorChanged - 0001:000597BC TCustomForm.CMCtl3DChanged - 0001:0005B320 TCustomForm.CMDeactivate - 0001:0005B344 TCustomForm.CMDialogKey - 0001:00059804 TCustomForm.CMFontChanged - 0001:0005B958 TCustomForm.CMIconChanged - 0001:0005BA44 TCustomForm.CMIsShortCut - 0001:00059824 TCustomForm.CMMenuChanged - 0001:00059014 TCustomForm.CMParentBiDiModeChanged - 0001:0005B9D8 TCustomForm.CMParentFontChanged - 0001:0005B978 TCustomForm.CMRelease - 0001:0005B3E0 TCustomForm.CMShowingChanged - 0001:0005B980 TCustomForm.CMTextChanged - 0001:0005B9D0 TCustomForm.CMUIActivate - 0001:000579D8 TCustomForm.Create - 0001:00057B9C TCustomForm.CreateNew - 0001:00059BD4 TCustomForm.CreateParams - 0001:00059F30 TCustomForm.CreateWindowHandle - 0001:00059DF0 TCustomForm.CreateWnd - 0001:0005A6F0 TCustomForm.Deactivate - 0001:0005A0AC TCustomForm.DefaultHandler - 0001:000582E4 TCustomForm.DefineProperties - 0001:0005A1C8 TCustomForm.DefocusControl - 0001:00057D74 TCustomForm.Destroy - 0001:0005A068 TCustomForm.DestroyWindowHandle - 0001:00059100 TCustomForm.Dock - 0001:00058574 TCustomForm.DoClose - 0001:00057E58 TCustomForm.DoCreate - 0001:00057ED4 TCustomForm.DoDestroy - 0001:00059144 TCustomForm.DoDock - 0001:00058594 TCustomForm.DoHide - 0001:000585B4 TCustomForm.DoShow - 0001:0005A210 TCustomForm.FocusControl - 0001:00059198 TCustomForm.GetActiveMDIChild - 0001:00059380 TCustomForm.GetCanvas - 0001:0005865C TCustomForm.GetChildren - 0001:000585D4 TCustomForm.GetClientRect - 0001:000586C8 TCustomForm.GetFloating - 0001:0005A740 TCustomForm.GetIconHandle - 0001:000591CC TCustomForm.GetMDIChildCount - 0001:00059218 TCustomForm.GetMDIChildren - 0001:00059298 TCustomForm.GetMonitor - 0001:000596E0 TCustomForm.GetPixelsPerInch - 0001:00059744 TCustomForm.GetScaled - 0001:00058404 TCustomForm.GetTextHeight - 0001:0005C3C4 TCustomForm.HandleCreateException - 0001:0005BC10 TCustomForm.Hide - 0001:000584AC TCustomForm.IconChanged - 0001:0005C4FC TCustomForm.InitAlphaBlending - 0001:00058540 TCustomForm.IsAutoScrollStored - 0001:00058508 TCustomForm.IsClientSizeStored - 0001:00059394 TCustomForm.IsForm - 0001:00058518 TCustomForm.IsFormSizeStored - 0001:0005939C TCustomForm.IsIconStored - 0001:0005C2D4 TCustomForm.IsShortCut - 0001:00057F34 TCustomForm.Loaded - 0001:0005A5CC TCustomForm.MergeMenu - 0001:0005C38C TCustomForm.MouseWheelHandler - 0001:000597A4 TCustomForm.NormalColor - 0001:00057F70 TCustomForm.Notification - 0001:0005A720 TCustomForm.Paint - 0001:0005A75C TCustomForm.PaintWindow - 0001:0005A818 TCustomForm.PaletteChanged - 0001:0005C350 TCustomForm.QueryInterface - 0001:00058394 TCustomForm.ReadIgnoreFontProperty - 0001:0005807C TCustomForm.ReadState - 0001:000583B4 TCustomForm.ReadTextHeight - 0001:00059444 TCustomForm.RefreshMDIMenu - 0001:0005BCAC TCustomForm.Release - 0001:0005C040 TCustomForm.RequestAlign - 0001:0005AD50 TCustomForm.Resizing - 0001:0005A57C TCustomForm.SendCancelMode - 0001:0005A518 TCustomForm.SetActive - 0001:0005A110 TCustomForm.SetActiveControl - 0001:0005C4AC TCustomForm.SetAlphaBlend - 0001:0005C4C0 TCustomForm.SetAlphaBlendValue - 0001:0005909C TCustomForm.SetBorderIcons - 0001:000590C8 TCustomForm.SetBorderStyle - 0001:000586F4 TCustomForm.SetChildOrder - 0001:000587E0 TCustomForm.SetClientHeight - 0001:000587B0 TCustomForm.SetClientWidth - 0001:0005BC30 TCustomForm.SetFocus - 0001:0005A234 TCustomForm.SetFocusedControl - 0001:000593C4 TCustomForm.SetFormStyle - 0001:00059388 TCustomForm.SetIcon - 0001:0005C3D4 TCustomForm.SetLayeredAttribs - 0001:0005950C TCustomForm.SetMenu - 0001:000594C0 TCustomForm.SetObjectMenuItem - 0001:000588BC TCustomForm.SetParent - 0001:00058788 TCustomForm.SetParentBiDiMode - 0001:000596F4 TCustomForm.SetPixelsPerInch - 0001:00059728 TCustomForm.SetPosition - 0001:00059750 TCustomForm.SetScaled - 0001:0005C4E8 TCustomForm.SetTransparentColor - 0001:0005C4D4 TCustomForm.SetTransparentColorValue - 0001:00058810 TCustomForm.SetVisible - 0001:0005A4C8 TCustomForm.SetWindowFocus - 0001:000594E4 TCustomForm.SetWindowMenu - 0001:00059840 TCustomForm.SetWindowState - 0001:00059880 TCustomForm.SetWindowToMonitor - 0001:0005BC18 TCustomForm.Show - 0001:0005BCC8 TCustomForm.ShowModal - 0001:0005BFD8 TCustomForm.UpdateActions - 0001:000588F4 TCustomForm.ValidateRename - 0001:00058854 TCustomForm.VisibleChanging - 0001:000588B8 TCustomForm.WantChildKey - 0001:0005AD30 TCustomForm.WMActivate - 0001:0005AD88 TCustomForm.WMClose - 0001:0005AC04 TCustomForm.WMCommand - 0001:0005ABA4 TCustomForm.WMDestroy - 0001:0005AFBC TCustomForm.WMEnterMenuLoop - 0001:0005A998 TCustomForm.WMEraseBkgnd - 0001:0005B1F0 TCustomForm.WMGetMinMaxInfo - 0001:0005B084 TCustomForm.WMHelp - 0001:0005A938 TCustomForm.WMIconEraseBkgnd - 0001:0005AC38 TCustomForm.WMInitMenuPopup - 0001:0005AF38 TCustomForm.WMMDIActivate - 0001:0005AC50 TCustomForm.WMMenuChar - 0001:0005AC88 TCustomForm.WMMenuSelect - 0001:0005AAE0 TCustomForm.WMNCCreate - 0001:0005AB14 TCustomForm.WMNCLButtonDown - 0001:0005AF90 TCustomForm.WMNextDlgCtl - 0001:0005A8B8 TCustomForm.WMPaint - 0001:0005A9D0 TCustomForm.WMQueryDragIcon - 0001:0005AD90 TCustomForm.WMQueryEndSession - 0001:0005C05C TCustomForm.WMSettingChange - 0001:0005AEA0 TCustomForm.WMShowWindow - 0001:0005AE14 TCustomForm.WMSysCommand - 0001:0005B264 TCustomForm.WMWindowPosChanging - 0001:00058934 TCustomForm.WndProc - 0001:000583E8 TCustomForm.WritePixelsPerInch - 0001:000583CC TCustomForm.WriteTextHeight - 0001:0003345C TCustomGroupBox.AdjustClientRect - 0001:00033768 TCustomGroupBox.CMCtl3DChanged - 0001:000336D4 TCustomGroupBox.CMDialogChar - 0001:00033754 TCustomGroupBox.CMTextChanged - 0001:00033400 TCustomGroupBox.Create - 0001:000334B8 TCustomGroupBox.CreateParams - 0001:000334C8 TCustomGroupBox.Paint - 0001:00033784 TCustomGroupBox.WMSize - 0001:0004C424 TCustomImageList.Add - 0001:0004CA4C TCustomImageList.AddImages - 0001:0004CA6C TCustomImageList.Assign - 0001:0004CB2C TCustomImageList.AssignTo - 0001:0004D474 TCustomImageList.BeginUpdate - 0001:0004CC7C TCustomImageList.Change - 0001:0004CBDC TCustomImageList.CheckImage - 0001:0004C604 TCustomImageList.Clear - 0001:0004C8B4 TCustomImageList.CopyImages - 0001:0004BF60 TCustomImageList.Create - 0001:0004C384 TCustomImageList.CreateImageList - 0001:0004BFAC TCustomImageList.CreateSize - 0001:0004CEB8 TCustomImageList.DefineProperties - 0001:0004C578 TCustomImageList.Delete - 0001:0004C000 TCustomImageList.Destroy - 0001:0004C670 TCustomImageList.DoDraw - 0001:0004C844 TCustomImageList.Draw - 0001:0004C868 TCustomImageList.Draw - 0001:0004D478 TCustomImageList.EndUpdate - 0001:0004CD6C TCustomImageList.Equal - 0001:0004C34C TCustomImageList.FreeHandle - 0001:0004C648 TCustomImageList.GetBkColor - 0001:0004C554 TCustomImageList.GetCount - 0001:0004C2E8 TCustomImageList.GetHandle - 0001:0004CC6C TCustomImageList.GetHotSpot - 0001:0004C500 TCustomImageList.GetIcon - 0001:0004C4F0 TCustomImageList.GetIcon - 0001:0004C2F8 TCustomImageList.GetImageHandle - 0001:0004C124 TCustomImageList.HandleAllocated - 0001:0004C12C TCustomImageList.HandleNeeded - 0001:0004C138 TCustomImageList.InitBitmap - 0001:0004C06C TCustomImageList.Initialize - 0001:0004CF10 TCustomImageList.ReadD2Stream - 0001:0004D1A4 TCustomImageList.ReadD3Stream - 0001:0004D36C TCustomImageList.ReadData - 0001:0004CD10 TCustomImageList.RegisterChanges - 0001:0004C610 TCustomImageList.SetBkColor - 0001:0004CC54 TCustomImageList.SetDrawingStyle - 0001:0004C2BC TCustomImageList.SetHandle - 0001:0004C278 TCustomImageList.SetHeight - 0001:0004C1FC TCustomImageList.SetNewDimensions - 0001:0004C234 TCustomImageList.SetWidth - 0001:0004CCCC TCustomImageList.UnRegisterChanges - 0001:0004D3F8 TCustomImageList.WriteData - 0001:00060D30 TCustomIniFile.Create - 0001:00061350 TCustomIniFile.ReadBinaryStream - 0001:00060E8C TCustomIniFile.ReadBool - 0001:00060EB8 TCustomIniFile.ReadDate - 0001:00060F70 TCustomIniFile.ReadDateTime - 0001:00061028 TCustomIniFile.ReadFloat - 0001:00060D6C TCustomIniFile.ReadInteger - 0001:000610E0 TCustomIniFile.ReadTime - 0001:000614C0 TCustomIniFile.WriteBinaryStream - 0001:00061334 TCustomIniFile.WriteBool - 0001:00061198 TCustomIniFile.WriteDate - 0001:000611F8 TCustomIniFile.WriteDateTime - 0001:00061258 TCustomIniFile.WriteFloat - 0001:00060E30 TCustomIniFile.WriteInteger - 0001:000612BC TCustomIniFile.WriteTime - 0001:00068BF8 TCustomListAction.Create - 0001:00068C50 TCustomListAction.ExecuteTarget - 0001:00068D78 TCustomListAction.GetCount - 0001:00068DA4 TCustomListAction.GetString - 0001:00068DB0 TCustomListAction.HandlesTarget - 0001:00068DB4 TCustomListAction.Loaded - 0001:00068DE8 TCustomListAction.SetActive - 0001:00068EE8 TCustomListAction.SetImages - 0001:00068F54 TCustomListAction.SetItemIndex - 0001:00068FB0 TCustomListAction.SetString - 0001:0004A928 TCustomListControl.MoveSelection - 0001:00073B88 TCustomListView.ActionChange - 0001:000722D4 TCustomListView.AddItem - 0001:000727F8 TCustomListView.AlphaSort - 0001:00072CA0 TCustomListView.Arrange - 0001:0007233C TCustomListView.CanChange - 0001:000723F4 TCustomListView.CanEdit - 0001:000732AC TCustomListView.CanvasChanged - 0001:00072384 TCustomListView.Change - 0001:000721F0 TCustomListView.ChangeScale - 0001:00073B28 TCustomListView.Clear - 0001:00073988 TCustomListView.ClearSelection - 0001:00070E40 TCustomListView.CMColorChanged - 0001:00070E64 TCustomListView.CMCtl3DChanged - 0001:0007263C TCustomListView.CMDrag - 0001:000710C4 TCustomListView.CMFontChanged - 0001:00073748 TCustomListView.CMHintShow - 0001:0007317C TCustomListView.CNDrawItem - 0001:00071530 TCustomListView.CNNotify - 0001:00072264 TCustomListView.ColClick - 0001:00072284 TCustomListView.ColRightClick - 0001:000710AC TCustomListView.ColumnsShowing - 0001:000739C4 TCustomListView.CopySelection - 0001:0006FF08 TCustomListView.Create - 0001:000712E4 TCustomListView.CreateListItem - 0001:00071320 TCustomListView.CreateListItems - 0001:000701F0 TCustomListView.CreateParams - 0001:000703D0 TCustomListView.CreateWnd - 0001:000733BC TCustomListView.CustomDraw - 0001:00073414 TCustomListView.CustomDrawItem - 0001:00073484 TCustomListView.CustomDrawSubItem - 0001:000723BC TCustomListView.Delete - 0001:00073A38 TCustomListView.DeleteSelected - 0001:000700F0 TCustomListView.Destroy - 0001:000705B8 TCustomListView.DestroyWnd - 0001:00072FB4 TCustomListView.DoAutoSize - 0001:00072770 TCustomListView.DoDragOver - 0001:00072610 TCustomListView.DoEndDrag - 0001:00073870 TCustomListView.DoInfoTip - 0001:0007253C TCustomListView.DoStartDrag - 0001:000734FC TCustomListView.DrawItem - 0001:000735B8 TCustomListView.DrawWorkAreas - 0001:00072420 TCustomListView.Edit - 0001:00070978 TCustomListView.EditWndProc - 0001:00073B80 TCustomListView.GetActionLinkClass - 0001:00072A54 TCustomListView.GetColumnFromIndex - 0001:000738D4 TCustomListView.GetColumnFromTag - 0001:00073AE0 TCustomListView.GetCount - 0001:000724A0 TCustomListView.GetDragImages - 0001:00072A78 TCustomListView.GetDropTarget - 0001:00072AE0 TCustomListView.GetImageIndex - 0001:0007137C TCustomListView.GetItem - 0001:00072C3C TCustomListView.GetItemAt - 0001:000711EC TCustomListView.GetItemIndex - 0001:00072BD4 TCustomListView.GetNearestItem - 0001:00072B00 TCustomListView.GetNextItem - 0001:000714AC TCustomListView.GetSelCount - 0001:00072A60 TCustomListView.GetSelected - 0001:00073574 TCustomListView.GetSubItemImage - 0001:00072878 TCustomListView.GetTopItem - 0001:00072860 TCustomListView.GetViewOrigin - 0001:00070880 TCustomListView.HeaderWndProc - 0001:0007065C TCustomListView.ImageListChange - 0001:000722B4 TCustomListView.InsertItem - 0001:000732B4 TCustomListView.IsCustomDrawn - 0001:00073890 TCustomListView.MouseUp - 0001:000706D0 TCustomListView.Notification - 0001:00071214 TCustomListView.OwnerDataFetch - 0001:0007123C TCustomListView.OwnerDataFind - 0001:00071288 TCustomListView.OwnerDataHint - 0001:000712B0 TCustomListView.OwnerDataStateChange - 0001:00070A98 TCustomListView.ResetExStyles - 0001:00070B94 TCustomListView.RestoreChecks - 0001:00070C20 TCustomListView.SaveChecks - 0001:00073AEC TCustomListView.SelectAll - 0001:00070E10 TCustomListView.SetAllocBy - 0001:00070D24 TCustomListView.SetBorderStyle - 0001:00070CA4 TCustomListView.SetCheckboxes - 0001:00070D38 TCustomListView.SetColumnClick - 0001:00070DA8 TCustomListView.SetColumnHeaders - 0001:00072A9C TCustomListView.SetDropTarget - 0001:00071104 TCustomListView.SetHideSelection - 0001:00070634 TCustomListView.SetImageList - 0001:00070D4C TCustomListView.SetItemIndex - 0001:000728B0 TCustomListView.SetLargeImages - 0001:00070D94 TCustomListView.SetMultiSelect - 0001:00072920 TCustomListView.SetSmallImages - 0001:00072828 TCustomListView.SetSortType - 0001:00072998 TCustomListView.SetStateImages - 0001:00070DDC TCustomListView.SetTextBkColor - 0001:00070DBC TCustomListView.SetTextColor - 0001:00071118 TCustomListView.SetViewStyle - 0001:00072D00 TCustomListView.UpdateColumn - 0001:00072CC0 TCustomListView.UpdateColumns - 0001:00070A78 TCustomListView.UpdateItems - 0001:000710B8 TCustomListView.ValidHeaderHandle - 0001:00073910 TCustomListView.WMContextMenu - 0001:00072E50 TCustomListView.WMLButtonDown - 0001:00070E88 TCustomListView.WMNotify - 0001:00073720 TCustomListView.WMPaint - 0001:0007119C TCustomListView.WMParentNotify - 0001:00073148 TCustomListView.WMWindowPosChanged - 0001:000724BC TCustomListView.WndProc - 0001:00034508 TCustomMemo.Create - 0001:000345BC TCustomMemo.CreateParams - 0001:00034620 TCustomMemo.CreateWindowHandle - 0001:0003458C TCustomMemo.Destroy - 0001:000346F4 TCustomMemo.GetCaretPos - 0001:0003478C TCustomMemo.GetControlsAlignment - 0001:00034824 TCustomMemo.KeyPress - 0001:00034794 TCustomMemo.Loaded - 0001:000347AC TCustomMemo.SetAlignment - 0001:00034750 TCustomMemo.SetCaretPos - 0001:000347C0 TCustomMemo.SetScrollBars - 0001:000347D4 TCustomMemo.SetWordWrap - 0001:000347E8 TCustomMemo.WMGetDlgCode - 0001:0003481C TCustomMemo.WMNCDestroy - 0001:0001DB38 TCustomMemoryStream.Read - 0001:0001DB70 TCustomMemoryStream.Seek - 0001:0001DB30 TCustomMemoryStream.SetPointer - 0001:000386D4 TCustomPanel.AdjustClientRect - 0001:00038868 TCustomPanel.CanAutoSize - 0001:00038344 TCustomPanel.CMBorderChanged - 0001:00038360 TCustomPanel.CMCtl3DChanged - 0001:0003872C TCustomPanel.CMDockClient - 0001:0003838C TCustomPanel.CMIsToolControl - 0001:00038358 TCustomPanel.CMTextChanged - 0001:00038258 TCustomPanel.Create - 0001:000382F0 TCustomPanel.CreateParams - 0001:000386CC TCustomPanel.GetControlsAlignment - 0001:000384D8 TCustomPanel.Paint - 0001:0003863C TCustomPanel.SetAlignment - 0001:00038648 TCustomPanel.SetBevelInner - 0001:00038664 TCustomPanel.SetBevelOuter - 0001:00038680 TCustomPanel.SetBevelWidth - 0001:000386B8 TCustomPanel.SetBorderStyle - 0001:0003869C TCustomPanel.SetBorderWidth - 0001:000383A0 TCustomPanel.WMWindowPosChanged - 0001:0006D71C TCustomRichEdit.Clear - 0001:0006DC04 TCustomRichEdit.CMBiDiModeChanged - 0001:0006DD14 TCustomRichEdit.CMColorChanged - 0001:0006DA24 TCustomRichEdit.CMFontChanged - 0001:0006E0A0 TCustomRichEdit.CNNotify - 0001:0006D5A4 TCustomRichEdit.Create - 0001:0006D734 TCustomRichEdit.CreateParams - 0001:0006D7C0 TCustomRichEdit.CreateWnd - 0001:0006D6C0 TCustomRichEdit.Destroy - 0001:0006D8E8 TCustomRichEdit.DestroyWnd - 0001:0006DA34 TCustomRichEdit.DoSetMaxLength - 0001:0006DA54 TCustomRichEdit.GetCaretPos - 0001:0006DCFC TCustomRichEdit.GetPlainText - 0001:0006DB00 TCustomRichEdit.GetSelLength - 0001:0006DB28 TCustomRichEdit.GetSelStart - 0001:0006DBC0 TCustomRichEdit.GetSelText - 0001:0006DB4C TCustomRichEdit.GetSelTextBuf - 0001:0006DD78 TCustomRichEdit.Print - 0001:0006E14C TCustomRichEdit.ProtectChange - 0001:0006E19C TCustomRichEdit.RequestSize - 0001:0006E11C TCustomRichEdit.SaveClipboard - 0001:0006E17C TCustomRichEdit.SelectionChange - 0001:0006DAB4 TCustomRichEdit.SetCaretPos - 0001:0006DC5C TCustomRichEdit.SetHideScrollBars - 0001:0006DC70 TCustomRichEdit.SetHideSelection - 0001:0006DD08 TCustomRichEdit.SetPlainText - 0001:0006DD40 TCustomRichEdit.SetRichEditStrings - 0001:0006DCA0 TCustomRichEdit.SetSelLength - 0001:0006DD50 TCustomRichEdit.SetSelStart - 0001:0006D9B4 TCustomRichEdit.WMNCDestroy - 0001:0006DF50 TCustomRichEdit.WMPaint - 0001:0006D9CC TCustomRichEdit.WMRButtonUp - 0001:0006E010 TCustomRichEdit.WMSetCursor - 0001:0006D9BC TCustomRichEdit.WMSetFont - 0001:0006530C TCustomServerSocket.Destroy - 0001:0006533C TCustomServerSocket.DoActivate - 0001:000653C8 TCustomServerSocket.GetGetSocketEvent - 0001:00065398 TCustomServerSocket.GetGetThreadEvent - 0001:00065574 TCustomServerSocket.GetOnClientError - 0001:00065480 TCustomServerSocket.GetOnClientEvent - 0001:00065428 TCustomServerSocket.GetOnThreadEnd - 0001:00065410 TCustomServerSocket.GetOnThreadStart - 0001:00065380 TCustomServerSocket.GetServerType - 0001:000653F8 TCustomServerSocket.GetThreadCacheSize - 0001:000653DC TCustomServerSocket.SetGetSocketEvent - 0001:000653AC TCustomServerSocket.SetGetThreadEvent - 0001:0006558C TCustomServerSocket.SetOnClientError - 0001:000654F8 TCustomServerSocket.SetOnClientEvent - 0001:00065460 TCustomServerSocket.SetOnThreadEnd - 0001:00065440 TCustomServerSocket.SetOnThreadStart - 0001:0006538C TCustomServerSocket.SetServerType - 0001:00065404 TCustomServerSocket.SetThreadCacheSize - 0001:000651E8 TCustomSocket.Error - 0001:000650E8 TCustomSocket.Event - 0001:000370D8 TCustomStaticText.AdjustBounds - 0001:00036FF8 TCustomStaticText.CMDialogChar - 0001:00037094 TCustomStaticText.CMFontChanged - 0001:000370A8 TCustomStaticText.CMTextChanged - 0001:00036F08 TCustomStaticText.Create - 0001:00036F78 TCustomStaticText.CreateParams - 0001:000370C4 TCustomStaticText.Loaded - 0001:000371C0 TCustomStaticText.Notification - 0001:000371F0 TCustomStaticText.SetAlignment - 0001:00037204 TCustomStaticText.SetAutoSize - 0001:0003721C TCustomStaticText.SetBorderStyle - 0001:00037230 TCustomStaticText.SetFocusControl - 0001:00037244 TCustomStaticText.SetShowAccelChar - 0001:00016B58 TCustomVariantType.BinaryOp - 0001:00016B64 TCustomVariantType.Cast - 0001:00016B9C TCustomVariantType.CastTo - 0001:00016C28 TCustomVariantType.CastToOle - 0001:00016BE4 TCustomVariantType.Compare - 0001:00016BF0 TCustomVariantType.CompareOp - 0001:00016C64 TCustomVariantType.Destroy - 0001:00016D44 TCustomVariantType.DispInvoke - 0001:00016CF0 TCustomVariantType.IsClear - 0001:00016CF4 TCustomVariantType.LeftPromotion - 0001:00016D08 TCustomVariantType.OlePromotion - 0001:00016D68 TCustomVariantType.QueryInterface - 0001:00016D10 TCustomVariantType.RaiseCastError - 0001:00016D20 TCustomVariantType.RaiseDispError - 0001:00016D18 TCustomVariantType.RaiseInvalidOp - 0001:00016D28 TCustomVariantType.RightPromotion - 0001:00016D3C TCustomVariantType.UnaryOp - 0001:00016D50 TCustomVariantType._AddRef - 0001:00016D5C TCustomVariantType._Release - 0001:0006313C TCustomWinSocket.Accept - 0001:00063140 TCustomWinSocket.AsyncInitSocket - 0001:000633F8 TCustomWinSocket.Close - 0001:00063564 TCustomWinSocket.CMDeferFree - 0001:00063FCC TCustomWinSocket.CMLookupComplete - 0001:000634D8 TCustomWinSocket.CMSocketMessage - 0001:00063404 TCustomWinSocket.Connect - 0001:00063058 TCustomWinSocket.Create - 0001:00063B24 TCustomWinSocket.DefaultHandler - 0001:0006356C TCustomWinSocket.DeferFree - 0001:000630D0 TCustomWinSocket.Destroy - 0001:00063A18 TCustomWinSocket.Disconnect - 0001:000635E0 TCustomWinSocket.DoListen - 0001:00063660 TCustomWinSocket.DoOpen - 0001:00063584 TCustomWinSocket.DoSetAsyncStyles - 0001:00063B68 TCustomWinSocket.Error - 0001:00063B50 TCustomWinSocket.Event - 0001:000636CC TCustomWinSocket.GetHandle - 0001:00063778 TCustomWinSocket.InitSocket - 0001:00063810 TCustomWinSocket.Listen - 0001:00063408 TCustomWinSocket.Lock - 0001:000636E8 TCustomWinSocket.LookupName - 0001:00063744 TCustomWinSocket.LookupService - 0001:00063918 TCustomWinSocket.Open - 0001:00063D84 TCustomWinSocket.Read - 0001:00063DA0 TCustomWinSocket.ReceiveBuf - 0001:00063F0C TCustomWinSocket.ReceiveText - 0001:00063BD4 TCustomWinSocket.SendStreamPiece - 0001:00063D5C TCustomWinSocket.SetAsyncStyles - 0001:00063414 TCustomWinSocket.Unlock - 0001:00063F48 TCustomWinSocket.WndProc - 0001:00063F9C TCustomWinSocket.Write - 0001:00047FB8 TDockTree.AdjustDockRect - 0001:00047FCC TDockTree.BeginUpdate - 0001:00049C88 TDockTree.ControlVisibilityChanged - 0001:00047DFC TDockTree.Create - 0001:00047F64 TDockTree.Destroy - 0001:00049888 TDockTree.DrawSizeSplitter - 0001:00047FD0 TDockTree.EndUpdate - 0001:0004803C TDockTree.FindControlZone - 0001:000480A4 TDockTree.ForEachAt - 0001:000480BC TDockTree.GetControlBounds - 0001:00049A04 TDockTree.GetNextLimit - 0001:00048130 TDockTree.HitTest - 0001:00048140 TDockTree.InsertControl - 0001:00048350 TDockTree.InsertNewParent - 0001:000484F8 TDockTree.InsertSibling - 0001:00048830 TDockTree.InternalHitTest - 0001:00048900 TDockTree.LoadFromStream - 0001:00048BE8 TDockTree.PaintDockFrame - 0001:00048CC4 TDockTree.PaintSite - 0001:00048E28 TDockTree.PositionDockRect - 0001:00048FD0 TDockTree.PruneZone - 0001:0004902C TDockTree.RemoveControl - 0001:00049068 TDockTree.RemoveZone - 0001:000492E4 TDockTree.ResetBounds - 0001:00049530 TDockTree.SaveToStream - 0001:000493C0 TDockTree.ScaleZone - 0001:00049700 TDockTree.SetNewBounds - 0001:0004972C TDockTree.SetReplacingControl - 0001:00049744 TDockTree.ShiftZone - 0001:00049774 TDockTree.SplitterMouseDown - 0001:000497D4 TDockTree.SplitterMouseUp - 0001:00049850 TDockTree.UpdateAll - 0001:00049878 TDockTree.UpdateZone - 0001:00049DA0 TDockTree.WindowProc - 0001:000477A4 TDockZone.Create - 0001:00047D2C TDockZone.ExpandZoneLimit - 0001:00047DF0 TDockZone.FirstVisibleChild - 0001:000477C8 TDockZone.GetChildCount - 0001:00047A80 TDockZone.GetControlName - 0001:00047928 TDockZone.GetHeightWidth - 0001:0004782C TDockZone.GetLimitBegin - 0001:00047874 TDockZone.GetLimitSize - 0001:000478BC TDockZone.GetTopLeft - 0001:000477F8 TDockZone.GetVisible - 0001:000477DC TDockZone.GetVisibleChildCount - 0001:00047CF0 TDockZone.GetZoneLimit - 0001:00047DC8 TDockZone.NextVisible - 0001:00047DD4 TDockZone.PrevVisible - 0001:000479D8 TDockZone.ResetChildren - 0001:00047D68 TDockZone.ResetZoneLimits - 0001:00047AC4 TDockZone.SetControlName - 0001:00047D18 TDockZone.SetZoneLimit - 0001:00047B78 TDockZone.Update - 0001:0003CBF8 TDragControlObject.GetDragCursor - 0001:0003CC10 TDragControlObject.GetDragImages - 0001:0003CC1C TDragControlObject.HideDragImage - 0001:0003CC3C TDragControlObject.ShowDragImage - 0001:0003CC5C TDragControlObjectEx.BeforeDestruction - 0001:0003CD98 TDragDockObject.AdjustDockRect - 0001:0003CCF4 TDragDockObject.Assign - 0001:0003CC60 TDragDockObject.Create - 0001:0003CCC4 TDragDockObject.Destroy - 0001:0003CE14 TDragDockObject.DrawDragDockImage - 0001:0003CD50 TDragDockObject.EndDrag - 0001:0003CE28 TDragDockObject.EraseDragDockImage - 0001:0003CE3C TDragDockObject.GetDragCursor - 0001:0003CE48 TDragDockObject.GetFrameWidth - 0001:0003CE50 TDragDockObjectEx.BeforeDestruction - 0001:00047464 TDragImageList.BeginDrag - 0001:0004730C TDragImageList.CombineDragCursor - 0001:000474C4 TDragImageList.DragLock - 0001:0004754C TDragImageList.DragMove - 0001:00047528 TDragImageList.DragUnlock - 0001:000475C0 TDragImageList.EndDrag - 0001:00047438 TDragImageList.GetHotSpot - 0001:000475A8 TDragImageList.HideDragImage - 0001:000472F4 TDragImageList.Initialize - 0001:00047420 TDragImageList.SetDragCursor - 0001:000473D8 TDragImageList.SetDragImage - 0001:00047590 TDragImageList.ShowDragImage - 0001:0003CB34 TDragObject.AfterConstruction - 0001:0003C914 TDragObject.Assign - 0001:0003CB24 TDragObject.BeforeDestruction - 0001:0003C954 TDragObject.Capture - 0001:0003C96C TDragObject.Finished - 0001:0003CAB0 TDragObject.GetDragCursor - 0001:0003CAAC TDragObject.GetDragImages - 0001:0003C974 TDragObject.GetName - 0001:0003CAC8 TDragObject.HideDragImage - 0001:0003CACC TDragObject.Instance - 0001:0003CAD8 TDragObject.MainWndProc - 0001:0003C99C TDragObject.ReleaseCapture - 0001:0003CAD4 TDragObject.ShowDragImage - 0001:0003C9B0 TDragObject.WndProc - 0001:0003CB44 TDragObjectEx.BeforeDestruction - 0002:00003864 TempVarAdd - 0002:0000387C TempVarAnd - 0002:000038A0 TempVarBoolFromStr - 0002:000038AC TempVarBstrFromBool - 0002:000038A4 TempVarBstrFromCy - 0002:000038A8 TempVarBstrFromDate - 0002:00003888 TempVarCmp - 0002:0000389C TempVarCyFromStr - 0002:00003898 TempVarDateFromStr - 0002:00003870 TempVarDiv - 0002:0000388C TempVarI4FromStr - 0002:00003858 TempVariantChangeTypeEx - 0002:00003874 TempVarIDiv - 0002:00003878 TempVarMod - 0002:0000386C TempVarMul - 0002:0000385C TempVarNeg - 0002:00003860 TempVarNot - 0002:00003880 TempVarOr - 0002:00003890 TempVarR4FromStr - 0002:00003894 TempVarR8FromStr - 0002:00003868 TempVarSub - 0002:00003884 TempVarXor - 0002:000002F4 TerminateProcList - 0002:0000304E Test8086 - 0001:00061EA8 TEvent.Create - 0001:00061F54 TEvent.ResetEvent - 0001:00061F48 TEvent.SetEvent - 0001:00061F00 TEvent.WaitFor - 0001:00001C18 TextClose - 0002:000013BC TextConversionFormat - 0001:00001B8C TextIn - 0001:00001C38 TextOpen - 0001:00001BCC TextOut - 0001:000090A4 TextToFloat - 0001:0004E754 TextToShortCut - 0001:0001DEC4 TFiler.Create - 0001:0001DF0C TFiler.Destroy - 0001:0001DF34 TFiler.SetRoot - 0001:0001DA34 TFileStream.Create - 0001:0001D9F0 TFileStream.Create - 0001:0001DAFC TFileStream.Destroy - 0001:00026344 TFont.Assign - 0001:00026328 TFont.Changed - 0001:000262AC TFont.Create - 0001:00026300 TFont.Destroy - 0001:000267A8 TFont.GetCharset - 0001:00026418 TFont.GetData - 0001:00026494 TFont.GetHandle - 0001:00026660 TFont.GetHeight - 0001:00026690 TFont.GetName - 0001:00026778 TFont.GetPitch - 0001:00026704 TFont.GetSize - 0001:00026740 TFont.GetStyle - 0001:000267B0 TFont.SetCharset - 0001:00026480 TFont.SetColor - 0001:00026430 TFont.SetData - 0001:0002663C TFont.SetHandle - 0001:00026668 TFont.SetHeight - 0001:000266A8 TFont.SetName - 0001:00026780 TFont.SetPitch - 0001:00026720 TFont.SetSize - 0001:0002674C TFont.SetStyle - 0001:00079D2C TfrmMain.AddHistoryItem - 0001:000796C4 TfrmMain.btnExitClick - 0001:000795B4 TfrmMain.btnRunClick - 0001:0007A228 TfrmMain.cbexIconChange - 0001:00079950 TfrmMain.clientSockConnect - 0001:00079C94 TfrmMain.clientSockConnecting - 0001:00079A14 TfrmMain.clientSockError - 0001:00079BE0 TfrmMain.comCommandKeyDown - 0001:00079D94 TfrmMain.ConsoleCommand - 0001:00079B94 TfrmMain.ConsoleResizeRequest - 0001:0007973C TfrmMain.Execute - 0001:0007980C TfrmMain.FormCloseQuery - 0001:00079570 TfrmMain.FormCreate - 0001:00079928 TfrmMain.FormDestroy - 0001:00079AC4 TfrmMain.Launch - 0001:0007A250 TfrmMain.LoadPseuSettings - 0001:0007A008 TfrmMain.LoadSettings - 0001:00079B0C TfrmMain.Log - 0001:0007986C TfrmMain.servRemoteClientRead - 0001:00079EA4 TfrmMain.SetIcon - 0001:00079E58 TfrmMain.SetupIcons - 0001:000796CC TfrmMain.ShutDown - 0001:00079828 TfrmMain.timerStartTimer - 0001:000289E0 TGraphic.Changed - 0001:000289A8 TGraphic.Create - 0001:00028A50 TGraphic.DefineProperties - 0001:00028A9C TGraphic.Equals - 0001:00028BE8 TGraphic.GetPalette - 0001:00028BEC TGraphic.GetTransparent - 0001:00028BF0 TGraphic.LoadFromFile - 0001:00028C44 TGraphic.Progress - 0001:00028C6C TGraphic.ReadData - 0001:00028C78 TGraphic.SaveToFile - 0001:00028CD0 TGraphic.SetPalette - 0001:00028CD4 TGraphic.SetTransparent - 0001:00028CE4 TGraphic.WriteData - 0001:00025FF0 TGraphicsObject.Changed - 0001:00026004 TGraphicsObject.Lock - 0001:00026014 TGraphicsObject.Unlock - 0001:00061E78 THandleObject.Destroy - 0001:0001D92C THandleStream.Create - 0001:0001D968 THandleStream.Read - 0001:0001D988 THandleStream.Seek - 0001:0001D9B4 THandleStream.SetSize - 0001:0001D9C8 THandleStream.SetSize - 0001:0001D978 THandleStream.Write - 0001:0002DCE4 THelpManager.AssignHelpSelector - 0001:0002D7B0 THelpManager.CallSpecialWinHelp - 0001:0002D3EC THelpManager.Create - 0001:0002DEAC THelpManager.Destroy - 0001:0002D5E0 THelpManager.DoSoftShutDown - 0001:0002D610 THelpManager.DoTableOfContents - 0001:0002DE04 THelpManager.GetHandle - 0001:0002DE08 THelpManager.GetHelpFile - 0001:0002DD48 THelpManager.Hook - 0001:0002D460 THelpManager.RegisterViewer - 0001:0002DE1C THelpManager.Release - 0001:0002DACC THelpManager.ShowContextHelp - 0001:0002D8B8 THelpManager.ShowHelp - 0001:0002DBE0 THelpManager.ShowTableOfContents - 0001:0002DBE8 THelpManager.ShowTopicHelp - 0001:0002D598 THelpManager.UnloadAllViewers - 0001:0002D370 THelpViewerNode.Create - 0001:00039218 THintAction.Create - 0001:00047000 THintWindow.ActivateHint - 0001:000471D8 THintWindow.ActivateHintData - 0001:00047200 THintWindow.CalcHintRect - 0001:00046F68 THintWindow.CMTextChanged - 0001:00046D40 THintWindow.Create - 0001:00046DAC THintWindow.CreateParams - 0001:00046EFC THintWindow.IsHintMsg - 0001:0004725C THintWindow.NCPaint - 0001:00046E54 THintWindow.Paint - 0001:00046F60 THintWindow.ReleaseHandle - 0001:00046DE8 THintWindow.WMNCHitTest - 0001:00046DF0 THintWindow.WMNCPaint - 0001:00047290 THintWindow.WMPrint - 0002:0000373A ThousandSeparator - 0002:00003A78 ThreadCount - 0002:00003A60 ThreadLock - 0001:00022F80 ThreadProc - 0002:00001318 ThreadStrs - 0001:00003674 ThreadWrapper - 0001:0002B464 TIcon.Assign - 0001:0002B3E0 TIcon.Create - 0001:0002B434 TIcon.Destroy - 0001:0002B4C4 TIcon.Draw - 0001:0002B504 TIcon.GetEmpty - 0001:0002B51C TIcon.GetHandle - 0001:0002B530 TIcon.GetHeight - 0001:0002B544 TIcon.GetWidth - 0001:0002B558 TIcon.HandleNeeded - 0001:0002B5D0 TIcon.ImageNeeded - 0001:0002B828 TIcon.LoadFromClipboardFormat - 0001:0002B684 TIcon.LoadFromStream - 0001:0002B73C TIcon.NewImage - 0001:0002B83C TIcon.SaveToClipboardFormat - 0001:0002B7FC TIcon.SaveToStream - 0001:0002B7B0 TIcon.SetHandle - 0001:0002B7C8 TIcon.SetHeight - 0001:0002B7E0 TIcon.SetTransparent - 0001:0002B7E4 TIcon.SetWidth - 0001:0002B398 TIconImage.Destroy - 0001:0002B3C8 TIconImage.FreeHandle - 0001:0006FDEC TIconOptions.Create - 0001:0006FE60 TIconOptions.SetArrangement - 0001:0006FE74 TIconOptions.SetAutoArrange - 0001:0006FE88 TIconOptions.SetWrapText - 0002:0000374C TimeAMString - 0002:00003750 TimePMString - 0002:00003748 TimeSeparator - 0001:0000A328 TimeToStr - 0001:00061AD4 TIniFile.DeleteKey - 0001:00061634 TIniFile.Destroy - 0001:00061A80 TIniFile.EraseSection - 0001:0006182C TIniFile.ReadSection - 0001:0006172C TIniFile.ReadSections - 0001:00061934 TIniFile.ReadSectionValues - 0001:00061660 TIniFile.ReadString - 0001:00061B04 TIniFile.UpdateFile - 0001:000616C0 TIniFile.WriteString - 0001:0001A818 TIntConst.Create - 0001:00005498 TInterfacedObject.AfterConstruction - 0001:000054A4 TInterfacedObject.BeforeDestruction - 0001:000054B4 TInterfacedObject.NewInstance - 0001:000054C4 TInterfacedObject.QueryInterface - 0001:000054EC TInterfacedObject._AddRef - 0001:00005500 TInterfacedObject._Release - 0001:0001B838 TInterfacedPersistent.AfterConstruction - 0001:0001B8C8 TInterfacedPersistent.QueryInterface - 0001:0001B888 TInterfacedPersistent._AddRef - 0001:0001B8A8 TInterfacedPersistent._Release - 0001:00076238 TJvAppStoragePropertyEngineList.Destroy - 0001:00076E28 TJvTrayIcon.AcceptBalloons - 0001:00076E38 TJvTrayIcon.ApplicationHook - 0001:00076E60 TJvTrayIcon.BalloonHint - 0001:00076CC8 TJvTrayIcon.Create - 0001:00076DB0 TJvTrayIcon.Destroy - 0001:00076FB4 TJvTrayIcon.DoAnimation - 0001:00077028 TJvTrayIcon.DoClick - 0001:000770CC TJvTrayIcon.DoCloseBalloon - 0001:000770E4 TJvTrayIcon.DoContextPopup - 0001:00077164 TJvTrayIcon.DoDoubleClick - 0001:00077240 TJvTrayIcon.DoMouseDown - 0001:00077280 TJvTrayIcon.DoMouseMove - 0001:000773E0 TJvTrayIcon.DoMouseUp - 0001:000774D8 TJvTrayIcon.DoTimerDblClick - 0001:00077514 TJvTrayIcon.EndAnimation - 0001:00077530 TJvTrayIcon.GetApplicationVisible - 0001:0007754C TJvTrayIcon.GetSystemMinimumBalloonDelay - 0001:00077554 TJvTrayIcon.HideApplication - 0001:000775F4 TJvTrayIcon.HideBalloon - 0001:00077620 TJvTrayIcon.HideTrayIcon - 0001:00077644 TJvTrayIcon.Hook - 0001:0007766C TJvTrayIcon.IconChanged - 0001:00077674 TJvTrayIcon.IconPropertyChanged - 0001:00077738 TJvTrayIcon.InitIconData - 0001:00077814 TJvTrayIcon.Loaded - 0001:00077894 TJvTrayIcon.Notification - 0001:000778E4 TJvTrayIcon.NotifyIcon - 0001:00077900 TJvTrayIcon.SetActive - 0001:0007795C TJvTrayIcon.SetAnimated - 0001:00077980 TJvTrayIcon.SetCurrentIcon - 0001:000779B0 TJvTrayIcon.SetDelay - 0001:00077A1C TJvTrayIcon.SetHint - 0001:00077ADC TJvTrayIcon.SetIcon - 0001:00077AE8 TJvTrayIcon.SetIconIndex - 0001:00077AFC TJvTrayIcon.SetIcons - 0001:00077B10 TJvTrayIcon.SetTask - 0001:00077B60 TJvTrayIcon.SetVisibility - 0001:00077C50 TJvTrayIcon.ShowApplication - 0001:00077D18 TJvTrayIcon.ShowTrayIcon - 0001:00077D8C TJvTrayIcon.StartAnimation - 0001:00077DC8 TJvTrayIcon.StopTimer - 0001:00077DDC TJvTrayIcon.Unhook - 0001:00077E00 TJvTrayIcon.WndProc - 0001:000754B4 TlHelp32 - 0001:0001AF38 TList.Add - 0001:0001AF6C TList.Clear - 0001:0001AF84 TList.Delete - 0001:0001AF18 TList.Destroy - 0001:0001B020 TList.Error - 0001:0001AFE8 TList.Error - 0001:0001B074 TList.Expand - 0001:0001B08C TList.First - 0001:0001B094 TList.Get - 0001:0001B0BC TList.Grow - 0001:0001B0F0 TList.IndexOf - 0001:0001B110 TList.Insert - 0001:0001B17C TList.Last - 0001:0001B188 TList.Move - 0001:0001B300 TList.Notify - 0001:0001B1E0 TList.Put - 0001:0001B234 TList.Remove - 0001:0001B254 TList.SetCapacity - 0001:0001B290 TList.SetCount - 0001:0006967C TListActionLink.AddItem - 0001:00069678 TListActionLink.AddItem - 0001:00069430 TListActionLink.IsActiveLinked - 0001:00069444 TListActionLink.IsImagesLinked - 0001:00069524 TListActionLink.RefreshControl - 0001:00069470 TListActionLink.SetAction - 0001:000694B4 TListActionLink.SetActive - 0001:00069520 TListActionLink.SetImages - 0001:000696A8 TListActionLink.SetItemIndex - 0001:0006E6A8 TListColumn.Assign - 0001:0006E1BC TListColumn.Create - 0001:0006E2C4 TListColumn.DefineProperties - 0001:0006E264 TListColumn.Destroy - 0001:0006E454 TListColumn.DoChange - 0001:0006E71C TListColumn.GetDisplayName - 0001:0006E5AC TListColumn.GetWidth - 0001:0006E5D8 TListColumn.IsWidthStored - 0001:0006E30C TListColumn.ReadData - 0001:0006E60C TListColumn.SetAlignment - 0001:0006E644 TListColumn.SetAutoSize - 0001:0006E584 TListColumn.SetCaption - 0001:0006E678 TListColumn.SetImageIndex - 0001:0006E4D4 TListColumn.SetIndex - 0001:0006E688 TListColumn.SetMaxWidth - 0001:0006E698 TListColumn.SetMinWidth - 0001:0006E5E0 TListColumn.SetWidth - 0001:0006E334 TListColumn.WriteData - 0001:0006E740 TListColumns.Create - 0001:0006E784 TListColumns.GetItem - 0001:0006E79C TListColumns.GetOwner - 0001:0006E798 TListColumns.Owner - 0001:0006E7A0 TListColumns.Update - 0001:0006E7D4 TListColumns.UpdateCols - 0001:000688F4 TListControlItem.Assign - 0001:0006897C TListControlItem.Changed - 0001:0006898C TListControlItem.Create - 0001:000689C8 TListControlItem.GetDisplayName - 0001:000689F4 TListControlItem.SetCaption - 0001:00068A10 TListControlItem.SetData - 0001:00068A1C TListControlItem.SetImageIndex - 0001:00068A54 TListControlItems.Add - 0001:00068A94 TListControlItems.CompareItems - 0001:00068A64 TListControlItems.CustomSort - 0001:00068AD0 TListControlItems.ExchangeItems - 0001:00068BC0 TListControlItems.GetListItem - 0001:00068B2C TListControlItems.QuickSort - 0001:00068BD4 TListControlItems.SetSortType - 0001:00068BEC TListControlItems.Sort - 0001:0006F258 TListItem.Assign - 0001:0006ED50 TListItem.Create - 0001:0006EE14 TListItem.Delete - 0001:0006EDA0 TListItem.Destroy - 0001:0006F348 TListItem.DisplayRect - 0001:0006EE4C TListItem.GetChecked - 0001:0006EE38 TListItem.GetHandle - 0001:0006F32C TListItem.GetIndex - 0001:0006EE0C TListItem.GetListView - 0001:0006EFD8 TListItem.GetState - 0001:0006F378 TListItem.GetSubItemImage - 0001:0006F2F0 TListItem.IsEqual - 0001:0006EEF8 TListItem.SetCaption - 0001:0006EE90 TListItem.SetChecked - 0001:0006EFA8 TListItem.SetData - 0001:0006F0B0 TListItem.SetImage - 0001:0006F1EC TListItem.SetIndent - 0001:0006F040 TListItem.SetState - 0001:0006F384 TListItem.SetSubItemImage - 0001:0006F318 TListItem.SetSubItems - 0001:0006EEDC TListItem.Update - 0001:0006F458 TListItems.Add - 0001:0006F464 TListItems.AddItem - 0001:0006F7B8 TListItems.Assign - 0001:0006F5C8 TListItems.BeginUpdate - 0001:0006F5A8 TListItems.Clear - 0001:0006F3F0 TListItems.Create - 0001:0006FDC8 TListItems.CreateItem - 0001:0006F8A8 TListItems.DefineProperties - 0001:0006FDB0 TListItems.Delete - 0001:0006F42C TListItems.Destroy - 0001:0006F7A4 TListItems.EndUpdate - 0001:0006F4B4 TListItems.GetCount - 0001:0006F4D8 TListItems.GetHandle - 0001:0006F4E4 TListItems.GetItem - 0001:0006F564 TListItems.IndexOf - 0001:0006F900 TListItems.ReadData - 0001:0006F58C TListItems.SetCount - 0001:0006F5E0 TListItems.SetUpdateState - 0001:0006FB0C TListItems.WriteData - 0001:00074C70 TListViewActionLink.AddItem - 0001:00074BF8 TListViewActionLink.AddItem - 0001:00074CA8 TListViewActionLink.SetImages - 0001:00078D20 TLogThread.AddMessage - 0001:00078D8C TLogThread.Create - 0001:00078DE8 TLogThread.Destroy - 0001:00078E20 TLogThread.Execute - 0001:00078EEC TLogThread.SyncWrite - 0001:00078F0C TLogThread.WriteFromPseWow - 0002:00003720 tlsBuffer - 0001:00005A2C TlsGetValue - 0002:00003710 TlsIndex - 0002:FFB84014 TlsLast - 0001:00005A34 TlsSetValue - 0001:00052DE0 TMainMenu.GetHandle - 0001:00052DB4 TMainMenu.ItemChanged - 0001:00052D24 TMainMenu.MenuChanged - 0001:00052D7C TMainMenu.Merge - 0001:00052D04 TMainMenu.SetAutoMerge - 0001:00052D98 TMainMenu.Unmerge - 0001:0001DBC0 TMemoryStream.Clear - 0001:0001DB94 TMemoryStream.Destroy - 0001:0001DBD8 TMemoryStream.LoadFromStream - 0001:0001DC64 TMemoryStream.Realloc - 0001:0001DC10 TMemoryStream.SetCapacity - 0001:0001DC38 TMemoryStream.SetSize - 0001:0001DCF0 TMemoryStream.Write - 0001:000343BC TMemoStrings.Clear - 0001:0003432C TMemoStrings.Delete - 0001:00034168 TMemoStrings.Get - 0001:000340F8 TMemoStrings.GetCount - 0001:0003441C TMemoStrings.GetTextStr - 0001:00034220 TMemoStrings.Insert - 0001:000341AC TMemoStrings.Put - 0001:00034430 TMemoStrings.SetTextStr - 0001:000343CC TMemoStrings.SetUpdateState - 0001:0005273C TMenu.AdjustBiDiBehavior - 0001:00051F44 TMenu.Create - 0001:00051FE0 TMenu.Destroy - 0001:000521CC TMenu.DispatchCommand - 0001:000521E8 TMenu.DispatchPopup - 0001:0005254C TMenu.DoBiDiModeChanged - 0001:000527F0 TMenu.DoChange - 0001:00052BA4 TMenu.DoGetMenuString - 0001:0005212C TMenu.FindItem - 0001:00052CC4 TMenu.GetAutoHotkeys - 0001:00052CE4 TMenu.GetAutoLineReduction - 0001:00052018 TMenu.GetChildren - 0001:00052034 TMenu.GetHandle - 0001:0005215C TMenu.GetHelpContext - 0001:0005285C TMenu.ImageListChange - 0001:00052544 TMenu.IsBiDiModeStored - 0001:000522B0 TMenu.IsOwnerDraw - 0001:000528D0 TMenu.IsRightToLeft - 0001:00052428 TMenu.IsShortCut - 0001:00052808 TMenu.Loaded - 0001:00052820 TMenu.MenuChanged - 0001:000528A4 TMenu.Notification - 0001:00052C98 TMenu.ParentBiDiModeChanged - 0001:00052C70 TMenu.ParentBiDiModeChanged - 0001:00052A2C TMenu.ProcessMenuChar - 0001:00052CD4 TMenu.SetAutoHotkeys - 0001:00052CF4 TMenu.SetAutoLineReduction - 0001:00052C4C TMenu.SetBiDiMode - 0001:00052040 TMenu.SetChildOrder - 0001:00052868 TMenu.SetImages - 0001:0005272C TMenu.SetOwnerDraw - 0001:00052C60 TMenu.SetParentBiDiMode - 0001:000527B8 TMenu.SetWindowHandle - 0001:000526A8 TMenu.UpdateImage - 0001:0005207C TMenu.UpdateItems - 0001:0004E9D4 TMenuActionLink.AssignClient - 0001:0004E9F0 TMenuActionLink.IsAutoCheckLinked - 0001:0004EA18 TMenuActionLink.IsCaptionLinked - 0001:0004EA50 TMenuActionLink.IsCheckedLinked - 0001:0004EA80 TMenuActionLink.IsEnabledLinked - 0001:0004EB14 TMenuActionLink.IsGroupIndexLinked - 0001:0004EAB0 TMenuActionLink.IsHelpContextLinked - 0001:0004EAE0 TMenuActionLink.IsHintLinked - 0001:0004EB50 TMenuActionLink.IsImageIndexLinked - 0001:0004EBEC TMenuActionLink.IsOnExecuteLinked - 0001:0004EB84 TMenuActionLink.IsShortCutLinked - 0001:0004EBB8 TMenuActionLink.IsVisibleLinked - 0001:0004EC14 TMenuActionLink.SetAutoCheck - 0001:0004EC34 TMenuActionLink.SetCaption - 0001:0004EC54 TMenuActionLink.SetChecked - 0001:0004EC74 TMenuActionLink.SetEnabled - 0001:0004EC94 TMenuActionLink.SetHelpContext - 0001:0004ECB0 TMenuActionLink.SetHint - 0001:0004ECD4 TMenuActionLink.SetImageIndex - 0001:0004ED34 TMenuActionLink.SetOnExecute - 0001:0004ECF4 TMenuActionLink.SetShortCut - 0001:0004ED14 TMenuActionLink.SetVisible - 0001:000512D0 TMenuItem.ActionChange - 0001:00051054 TMenuItem.Add - 0001:00050798 TMenuItem.AdvancedDrawItem - 0001:0004EE90 TMenuItem.AppendTo - 0001:00051534 TMenuItem.AssignTo - 0001:00050F8C TMenuItem.Click - 0001:0004ED60 TMenuItem.Create - 0001:0004F3EC TMenuItem.DefineProperties - 0001:00050F18 TMenuItem.Delete - 0001:0004EDDC TMenuItem.Destroy - 0001:000513F0 TMenuItem.DoActionChange - 0001:0004F430 TMenuItem.DoDrawText - 0001:0004F640 TMenuItem.DrawItem - 0001:00050CC0 TMenuItem.GetAction - 0001:00050CD0 TMenuItem.GetActionLinkClass - 0001:00051EEC TMenuItem.GetAutoHotkeys - 0001:00051F18 TMenuItem.GetAutoLineReduction - 0001:00051134 TMenuItem.GetBitmap - 0001:00050DA0 TMenuItem.GetChildren - 0001:00050CD8 TMenuItem.GetCount - 0001:0004F3A0 TMenuItem.GetHandle - 0001:000508B0 TMenuItem.GetImageList - 0001:00050CE8 TMenuItem.GetItem - 0001:00050D40 TMenuItem.GetMenuIndex - 0001:0005122C TMenuItem.GetParentComponent - 0001:00051294 TMenuItem.GetParentMenu - 0001:00050B2C TMenuItem.HasParent - 0001:0005163C TMenuItem.ImageListChange - 0001:0005103C TMenuItem.IndexOf - 0001:00050E54 TMenuItem.InitiateAction - 0001:00051200 TMenuItem.InitiateActions - 0001:00050E64 TMenuItem.Insert - 0001:00051898 TMenuItem.InternalRethinkHotkeys - 0001:00051D94 TMenuItem.InternalRethinkLines - 0001:00051414 TMenuItem.IsCaptionStored - 0001:00051434 TMenuItem.IsCheckedStored - 0001:00051454 TMenuItem.IsEnabledStored - 0001:00051494 TMenuItem.IsHelpContextStored - 0001:00051474 TMenuItem.IsHintStored - 0001:000514B4 TMenuItem.IsImageIndexStored - 0001:00051D70 TMenuItem.IsLine - 0001:00051514 TMenuItem.IsOnClickStored - 0001:000514D4 TMenuItem.IsShortCutStored - 0001:000514F4 TMenuItem.IsVisibleStored - 0001:0004F234 TMenuItem.Loaded - 0001:0005092C TMenuItem.MeasureItem - 0001:00051098 TMenuItem.MenuChanged - 0001:0004F1F8 TMenuItem.MergeWith - 0001:000515AC TMenuItem.Notification - 0001:0004F130 TMenuItem.PopulateMenu - 0001:0004F1A0 TMenuItem.ReadShortCutText - 0001:0004F270 TMenuItem.RebuildHandle - 0001:00051070 TMenuItem.Remove - 0001:0005115C TMenuItem.SetAction - 0001:00051D60 TMenuItem.SetAutoHotkeys - 0001:00051EDC TMenuItem.SetAutoLineReduction - 0001:000511CC TMenuItem.SetBitmap - 0001:00050B30 TMenuItem.SetBreak - 0001:00050B40 TMenuItem.SetCaption - 0001:00050BB0 TMenuItem.SetChecked - 0001:00050DD8 TMenuItem.SetChildOrder - 0001:00050DF8 TMenuItem.SetDefault - 0001:00050C04 TMenuItem.SetEnabled - 0001:00050C7C TMenuItem.SetGroupIndex - 0001:00050D30 TMenuItem.SetImageIndex - 0001:00050D58 TMenuItem.SetMenuIndex - 0001:00051240 TMenuItem.SetParentComponent - 0001:000512A4 TMenuItem.SetRadioItem - 0001:00050D0C TMenuItem.SetShortCut - 0001:00051600 TMenuItem.SetSubMenuImages - 0001:00050D20 TMenuItem.SetVisible - 0001:000510DC TMenuItem.SubItemChanged - 0001:00050B68 TMenuItem.TurnSiblingsOff - 0001:00051670 TMenuItem.UpdateItems - 0001:0004F340 TMenuItem.VerifyGroupIndex - 0001:000535D8 TMenuItemStack.ClearItem - 0001:0005C9B4 TMonitor.GetBoundsRect - 0001:0005C964 TMonitor.GetHeight - 0001:0005C94C TMonitor.GetLeft - 0001:0005C980 TMonitor.GetTop - 0001:0005C998 TMonitor.GetWidth - 0001:0004A188 TMouse.Create - 0001:0004A218 TMouse.Destroy - 0001:0004A248 TMouse.GetCapture - 0001:0004A250 TMouse.GetCursorPos - 0001:0004A260 TMouse.GetMouseData - 0001:0004A27C TMouse.GetNativeData - 0001:0004A2AC TMouse.GetRegisteredData - 0001:0004A2D4 TMouse.SetCapture - 0001:0004A2FC TMouse.SettingChanged - 0001:0000CE90 TMultiReadExclusiveWriteSynchronizer.BeginRead - 0001:0000CDA4 TMultiReadExclusiveWriteSynchronizer.BeginWrite - 0001:0000CD60 TMultiReadExclusiveWriteSynchronizer.BlockReaders - 0001:0000CCA4 TMultiReadExclusiveWriteSynchronizer.Create - 0001:0000CD18 TMultiReadExclusiveWriteSynchronizer.Destroy - 0001:0000CEEC TMultiReadExclusiveWriteSynchronizer.EndRead - 0001:0000CE40 TMultiReadExclusiveWriteSynchronizer.EndWrite - 0001:0000CD78 TMultiReadExclusiveWriteSynchronizer.UnblockOneWriter - 0001:0000CD6C TMultiReadExclusiveWriteSynchronizer.UnblockReaders - 0001:0000CD84 TMultiReadExclusiveWriteSynchronizer.WaitForReadSignal - 0001:0000CD94 TMultiReadExclusiveWriteSynchronizer.WaitForWriteSignal - 0001:00002B40 TObject.AfterConstruction - 0001:00002B44 TObject.BeforeDestruction - 0001:00002B2C TObject.ClassInfo - 0001:00002854 TObject.ClassName - 0001:00002868 TObject.ClassNameIs - 0001:00002890 TObject.ClassParent - 0001:0000284C TObject.ClassType - 0001:00002968 TObject.CleanupInstance - 0001:000028D4 TObject.Create - 0001:00002B3C TObject.DefaultHandler - 0001:000028F4 TObject.Destroy - 0001:00002B48 TObject.Dispatch - 0001:00002C00 TObject.FieldAddress - 0001:00002904 TObject.Free - 0001:000028B8 TObject.FreeInstance - 0001:000029B8 TObject.GetInterface - 0001:00002A4C TObject.GetInterfaceEntry - 0001:00002B18 TObject.InheritsFrom - 0001:00002910 TObject.InitInstance - 0001:000028CC TObject.InstanceSize - 0001:00002B70 TObject.MethodAddress - 0001:00002BC0 TObject.MethodName - 0001:0000289C TObject.NewInstance - 0001:00002B34 TObject.SafeCallException - 0001:0002BFC0 TObjectList.Create - 0001:0002BFFC TObjectList.GetItem - 0001:0002C010 TObjectList.Insert - 0001:0002C018 TObjectList.Notify - 0001:00004E88 ToLongPath - 0001:000679C4 ToolWin - 0001:0002C05C TOrderedList.Create - 0001:0002C0A0 TOrderedList.Destroy - 0001:0002C0D0 TOrderedList.PeekItem - 0001:0002C044 TOrderedList.Pop - 0001:0002C0E4 TOrderedList.PopItem - 0001:0002C04C TOrderedList.Push - 0001:0001C120 TOwnedCollection.Create - 0001:0001C164 TOwnedCollection.GetOwner - 0001:0006C8B8 TParaAttributes.Assign - 0001:0006C564 TParaAttributes.Create - 0001:0006C654 TParaAttributes.GetAlignment - 0001:0006C5BC TParaAttributes.GetAttributes - 0001:0006C728 TParaAttributes.GetFirstIndent - 0001:0006C784 TParaAttributes.GetLeftIndent - 0001:0006C6AC TParaAttributes.GetNumbering - 0001:0006C7E0 TParaAttributes.GetRightIndent - 0001:0006C83C TParaAttributes.GetTab - 0001:0006C5A0 TParaAttributes.InitPara - 0001:0006C670 TParaAttributes.SetAlignment - 0001:0006C5F0 TParaAttributes.SetAttributes - 0001:0006C748 TParaAttributes.SetFirstIndent - 0001:0006C7A4 TParaAttributes.SetLeftIndent - 0001:0006C6C4 TParaAttributes.SetNumbering - 0001:0006C800 TParaAttributes.SetRightIndent - 0001:0006C864 TParaAttributes.SetTab - 0001:0002BA14 TPatternManager.AllocPattern - 0001:0002B998 TPatternManager.Create - 0001:0002BAC8 TPatternManager.CreateBitmap - 0001:0002B9D0 TPatternManager.Destroy - 0001:0002BBC8 TPatternManager.FreePatterns - 0001:0002B9FC TPatternManager.Lock - 0001:0002BA08 TPatternManager.Unlock - 0001:00026844 TPen.Assign - 0001:000267D8 TPen.Create - 0001:0002681C TPen.Destroy - 0001:00026964 TPen.GetColor - 0001:000268FC TPen.GetData - 0001:00026994 TPen.GetHandle - 0001:00026A40 TPen.GetStyle - 0001:00026A70 TPen.GetWidth - 0001:0002696C TPen.SetColor - 0001:00026914 TPen.SetData - 0001:00026A2C TPen.SetMode - 0001:00026A48 TPen.SetStyle - 0001:00026A78 TPen.SetWidth - 0001:0001B694 TPersistent.Assign - 0001:0001B6A8 TPersistent.AssignError - 0001:0001B778 TPersistent.AssignTo - 0001:0001B780 TPersistent.DefineProperties - 0001:0001B668 TPersistent.Destroy - 0001:0001B784 TPersistent.GetNamePath - 0001:0001B834 TPersistent.GetOwner - 0001:00053380 TPopupList.Add - 0001:00052DF0 TPopupList.MainWndProc - 0001:000533A8 TPopupList.Remove - 0001:00052E3C TPopupList.WndProc - 0001:000533C4 TPopupMenu.Create - 0001:00053438 TPopupMenu.Destroy - 0001:0005346C TPopupMenu.DoPopup - 0001:00053480 TPopupMenu.GetHelpContext - 0001:00053524 TPopupMenu.Popup - 0001:00053490 TPopupMenu.SetBiDiModeFromPopupControl - 0001:00053488 TPopupMenu.SetHelpContext - 0001:000534D8 TPopupMenu.UseRightToLeftAlignment - 0001:0002E640 TPrinter.BeginDoc - 0001:0002E5D0 TPrinter.CheckPrinting - 0001:0002E3EC TPrinter.Create - 0001:0002E428 TPrinter.Destroy - 0001:0002E6C8 TPrinter.EndDoc - 0001:0002EEB0 TPrinter.FreeFonts - 0001:0002EE74 TPrinter.FreePrinters - 0001:0002E9B0 TPrinter.GetCanvas - 0001:0002E9D0 TPrinter.GetHandle - 0001:0002E9E4 TPrinter.GetPageHeight - 0001:0002EA00 TPrinter.GetPageWidth - 0001:0002EA1C TPrinter.GetPrinterIndex - 0001:0002EA34 TPrinter.GetPrinters - 0001:0002E6FC TPrinter.NewPage - 0001:0002E768 TPrinter.SetPrinter - 0001:0002E72C TPrinter.SetPrinterCapabilities - 0001:0002E4A4 TPrinter.SetState - 0001:0002EC74 TPrinter.SetToDefaultPrinter - 0001:0002E384 TPrinterCanvas.Changing - 0001:0002E324 TPrinterCanvas.Create - 0001:0002E360 TPrinterCanvas.CreateHandle - 0001:0002E3A4 TPrinterCanvas.UpdateFont - 0001:0002E150 TPrinterDevice.Create - 0001:0002E1B0 TPrinterDevice.IsEqual - 0001:0001E010 TPropFixup.Create - 0001:0001E068 TPropFixup.MakeGlobalReference - 0001:0001E0B0 TPropFixup.ResolveReference - 0001:0001E0C0 TPropIntfFixup.ResolveReference - 0001:00006628 TrackPopupMenu - 0001:0000B05C TranslateDateFormat - 0001:00006630 TranslateMDISysAccel - 0001:00006638 TranslateMessage - 0001:0000E7DC TranslateResult - 0001:000279E4 TransparentStretchBlt - 0001:0005C0B0 TraverseClients - 0001:0005BF68 TraverseClients - 0001:0005C1B0 TraverseClients - 0001:00044CD0 TraverseControls - 0001:0001E5F0 TReader.CheckValue - 0001:0001E648 TReader.DefineBinaryProperty - 0001:0001E614 TReader.DefineProperty - 0001:0001E5B4 TReader.Destroy - 0001:0001E83C TReader.DoFixupReferences - 0001:0001E724 TReader.EndOfList - 0001:0001E738 TReader.Error - 0001:000206CC TReader.FindAncestorComponent - 0001:000207C4 TReader.FindComponentClass - 0001:0001E758 TReader.FindMethod - 0001:0001E95C TReader.FlushBuffer - 0001:0001E980 TReader.FreeFixups - 0001:0001E9BC TReader.GetFieldClass - 0001:0001EA50 TReader.GetPosition - 0001:0001EA68 TReader.NextValue - 0001:0001EA78 TReader.PropertyError - 0001:0001EA8C TReader.Read - 0001:0001EB14 TReader.ReadBoolean - 0001:0001EAD8 TReader.ReadBuffer - 0001:0001EB28 TReader.ReadChar - 0001:0001EB80 TReader.ReadCollection - 0001:0001EF00 TReader.ReadComponent - 0001:0001F298 TReader.ReadCurrency - 0001:0001F0D8 TReader.ReadData - 0001:0001F148 TReader.ReadDataInner - 0001:0001F2E4 TReader.ReadDate - 0001:0001F218 TReader.ReadFloat - 0001:0001F324 TReader.ReadIdent - 0001:0001F490 TReader.ReadInt64 - 0001:0001F424 TReader.ReadInteger - 0001:0001F4D4 TReader.ReadListBegin - 0001:0001F4DC TReader.ReadListEnd - 0001:0001F4E4 TReader.ReadPrefix - 0001:0001F640 TReader.ReadProperty - 0001:0001F9C4 TReader.ReadPropValue - 0001:0001FD2C TReader.ReadRootComponent - 0001:00020074 TReader.ReadSet - 0001:00020130 TReader.ReadSignature - 0001:0001F258 TReader.ReadSingle - 0001:00020154 TReader.ReadStr - 0001:00020190 TReader.ReadString - 0001:00020330 TReader.ReadValue - 0001:00020A40 TReader.ReadVariant - 0001:0002024C TReader.ReadWideString - 0001:00020784 TReader.ReferenceName - 0001:0002079C TReader.SetName - 0001:00020838 TReader.SkipBytes - 0001:00020624 TReader.SkipComponent - 0001:000205DC TReader.SkipProperty - 0001:00020344 TReader.SkipSetBody - 0001:00020440 TReader.SkipValue - 0002:00000C64 TreeStreamEndFlag - 0001:00019B88 TRegGroup.AddClass - 0001:00019B94 TRegGroup.BestClass - 0001:00019BF4 TRegGroup.BestGroup - 0001:00019C64 TRegGroup.Create - 0001:00019CE0 TRegGroup.Destroy - 0001:00019D20 TRegGroup.GetClass - 0001:00019D80 TRegGroup.InGroup - 0001:00019DC4 TRegGroup.RegisterClass - 0001:00019E6C TRegGroup.Registered - 0001:00019EA4 TRegGroup.UnregisterModuleClasses - 0001:00019F48 TRegGroups.Activate - 0001:00019F94 TRegGroups.Create - 0001:0001A008 TRegGroups.Destroy - 0001:0001A064 TRegGroups.FindGroup - 0001:0001A0A8 TRegGroups.GetClass - 0001:0001A17C TRegGroups.GroupWith - 0001:0001A244 TRegGroups.Lock - 0001:0001A250 TRegGroups.RegisterClass - 0001:0001A268 TRegGroups.Registered - 0001:0001A2AC TRegGroups.StartGroup - 0001:0001A2FC TRegGroups.Unlock - 0001:0001A308 TRegGroups.UnregisterModuleClasses - 0001:000257F0 TResourceManager.AllocResource - 0001:000259FC TResourceManager.AssignResource - 0001:00025984 TResourceManager.ChangeResource - 0001:00025778 TResourceManager.Create - 0001:000257B4 TResourceManager.Destroy - 0001:000258D4 TResourceManager.FreeResource - 0001:000257D8 TResourceManager.Lock - 0001:000257E4 TResourceManager.Unlock - 0001:0001DD40 TResourceStream.Create - 0001:0001DE74 TResourceStream.Destroy - 0001:0001DE08 TResourceStream.Initialize - 0001:0001DEAC TResourceStream.Write - 0001:0006CAB8 TRichEditStrings.AddStrings - 0001:0006CEA0 TRichEditStrings.Clear - 0001:0006CDF4 TRichEditStrings.Delete - 0001:0006CA88 TRichEditStrings.Destroy - 0001:0006CF00 TRichEditStrings.EnableChange - 0001:0006CB88 TRichEditStrings.Get - 0001:0006CB30 TRichEditStrings.GetCount - 0001:0006CC68 TRichEditStrings.Insert - 0001:0006D3A8 TRichEditStrings.LoadFromFile - 0001:0006D134 TRichEditStrings.LoadFromStream - 0001:0006CBDC TRichEditStrings.Put - 0001:0006D4B0 TRichEditStrings.SaveToFile - 0001:0006D298 TRichEditStrings.SaveToStream - 0001:0006CF5C TRichEditStrings.SetTextStr - 0001:0006CEB0 TRichEditStrings.SetUpdateState - 0001:00007AD0 Trim - 0001:0006686C TrimPunctuation - 0002:0000383C TrueBoolStrs - 0002:00001368 TRUE_STRINGS - 0001:00009470 TryEncodeDate - 0001:00009328 TryEncodeTime - 0001:00001080 TryHarder - 0001:0000206C TryOpenForInput - 0001:000022FC TryOpenForOutput - 0001:00007EEC TryStrToBool - 0001:000092C8 TryStrToCurr - 0001:0000AB7C TryStrToDate - 0001:0000AC4C TryStrToDateTime - 0001:0000929C TryStrToFloat - 0001:00009270 TryStrToFloat - 0001:00009254 TryStrToFloat - 0001:00007DE0 TryStrToInt - 0001:00007E00 TryStrToInt64 - 0001:0000ABE4 TryStrToTime - 0001:0005CD88 TScreen.AddDataModule - 0001:0005CD00 TScreen.AddForm - 0001:0005D810 TScreen.AlignForm - 0001:0005D788 TScreen.AlignForms - 0001:0005C9E4 TScreen.Create - 0001:0005CDA0 TScreen.CreateCursors - 0001:0005CE58 TScreen.DeleteCursor - 0001:0005CB3C TScreen.Destroy - 0001:0005CDFC TScreen.DestroyCursors - 0001:0005D3A4 TScreen.DisableAlign - 0001:0005D3AC TScreen.EnableAlign - 0001:0005D150 TScreen.GetCursors - 0001:0005CCAC TScreen.GetCustomFormCount - 0001:0005CC98 TScreen.GetCustomForms - 0001:0005D134 TScreen.GetDataModule - 0001:0005D148 TScreen.GetDataModuleCount - 0001:0005D0C8 TScreen.GetDefaultIME - 0001:0005CC34 TScreen.GetDesktopHeight - 0001:0005CC28 TScreen.GetDesktopLeft - 0001:0005CC1C TScreen.GetDesktopTop - 0001:0005CC40 TScreen.GetDesktopWidth - 0001:0005CC7C TScreen.GetForm - 0001:0005CC90 TScreen.GetFormCount - 0001:0005CC04 TScreen.GetHeight - 0001:0005CEC8 TScreen.GetImes - 0001:0005D250 TScreen.GetMetricSettings - 0001:0005CC4C TScreen.GetMonitor - 0001:0005CC60 TScreen.GetMonitorCount - 0001:0005CC10 TScreen.GetWidth - 0001:0005D0E4 TScreen.IconFontChanged - 0001:0005CEA0 TScreen.InsertCursor - 0001:0005D3CC TScreen.Realign - 0001:0005CD94 TScreen.RemoveDataModule - 0001:0005CD38 TScreen.RemoveForm - 0001:0005D898 TScreen.ResetFonts - 0001:0005D178 TScreen.SetCursor - 0001:0005D208 TScreen.SetCursors - 0001:0005CCB4 TScreen.UpdateLastActive - 0001:000579AC TScrollBox.CMCtl3DChanged - 0001:000578D4 TScrollBox.Create - 0001:00057934 TScrollBox.CreateParams - 0001:00057984 TScrollBox.SetBorderStyle - 0001:00057998 TScrollBox.WMNCHitTest - 0001:000577D4 TScrollingWinControl.AdjustClientRect - 0001:000571A8 TScrollingWinControl.AlignControls - 0001:000571C8 TScrollingWinControl.AutoScrollEnabled - 0001:00057478 TScrollingWinControl.AutoScrollInView - 0001:00057300 TScrollingWinControl.CalcAutoRange - 0001:00057688 TScrollingWinControl.ChangeScale - 0001:00057844 TScrollingWinControl.CMBiDiModeChanged - 0001:000570B4 TScrollingWinControl.Create - 0001:00057158 TScrollingWinControl.CreateParams - 0001:00057168 TScrollingWinControl.CreateWnd - 0001:0005711C TScrollingWinControl.Destroy - 0001:000571E8 TScrollingWinControl.DoFlipChildren - 0001:000576AC TScrollingWinControl.Resizing - 0001:000575E4 TScrollingWinControl.ScaleScrollBars - 0001:00057490 TScrollingWinControl.ScrollInView - 0001:00057324 TScrollingWinControl.SetAutoScroll - 0001:00057360 TScrollingWinControl.SetHorzScrollBar - 0001:00057370 TScrollingWinControl.SetVertScrollBar - 0001:00057380 TScrollingWinControl.UpdateScrollBars - 0001:0005778C TScrollingWinControl.WMHScroll - 0001:000576B0 TScrollingWinControl.WMSize - 0001:000577B0 TScrollingWinControl.WMVScroll - 0001:00064A8C TServerAcceptThread.Create - 0001:00064AD0 TServerAcceptThread.Execute - 0001:00064DC8 TServerClientThread.ClientExecute - 0001:00064AEC TServerClientThread.Create - 0001:00064B64 TServerClientThread.Destroy - 0001:00064BD8 TServerClientThread.DoHandleException - 0001:00064C24 TServerClientThread.DoRead - 0001:00064C40 TServerClientThread.DoTerminate - 0001:00064C5C TServerClientThread.DoWrite - 0001:00064E94 TServerClientThread.EndConnect - 0001:00064CA4 TServerClientThread.Error - 0001:00064C94 TServerClientThread.Event - 0001:00064D20 TServerClientThread.Execute - 0001:00064C80 TServerClientThread.HandleError - 0001:00064C70 TServerClientThread.HandleEvent - 0001:00064CB8 TServerClientThread.HandleException - 0001:00064B9C TServerClientThread.ReActivate - 0001:00064E70 TServerClientThread.StartConnect - 0001:00064188 TServerClientWinSocket.Create - 0001:00064234 TServerClientWinSocket.Destroy - 0001:000655AC TServerSocket.Create - 0001:00064518 TServerWinSocket.Accept - 0001:0006431C TServerWinSocket.AddClient - 0001:000643D8 TServerWinSocket.AddThread - 0001:000649D0 TServerWinSocket.ClientConnect - 0001:000649F0 TServerWinSocket.ClientDisconnect - 0001:000644FC TServerWinSocket.ClientError - 0001:00064A60 TServerWinSocket.ClientErrorEvent - 0001:000644A8 TServerWinSocket.ClientEvent - 0001:00064A20 TServerWinSocket.ClientRead - 0001:00064A40 TServerWinSocket.ClientWrite - 0001:00064268 TServerWinSocket.Create - 0001:000642DC TServerWinSocket.Destroy - 0001:0006461C TServerWinSocket.Disconnect - 0001:00064734 TServerWinSocket.DoCreateThread - 0001:0006487C TServerWinSocket.GetClientSocket - 0001:000648FC TServerWinSocket.GetServerThread - 0001:00064744 TServerWinSocket.Listen - 0001:00064384 TServerWinSocket.RemoveClient - 0001:00064454 TServerWinSocket.RemoveThread - 0001:00064790 TServerWinSocket.SetServerType - 0001:000647E0 TServerWinSocket.SetThreadCacheSize - 0001:000648BC TServerWinSocket.ThreadEnd - 0001:000648DC TServerWinSocket.ThreadStart - 0001:000290A8 TSharedImage.Reference - 0001:000290AC TSharedImage.Release - 0001:0004BC80 TShortCutList.Add - 0001:0004BCAC TShortCutList.IndexOfShortCut - 0001:00061F60 TSimpleEvent.Create - 0001:0003C820 TSiteList.AddSite - 0001:0003C87C TSiteList.Clear - 0001:0003C7C4 TSiteList.Find - 0001:0003C8B0 TSiteList.GetTopSite - 0001:0003E190 TSizeConstraints.AssignTo - 0001:0003E264 TSizeConstraints.Change - 0001:0003E154 TSizeConstraints.Create - 0001:0003E1D8 TSizeConstraints.SetConstraints - 0001:0002C104 TStack.PushItem - 0001:000692D0 TStaticListAction.Create - 0001:00069330 TStaticListAction.Destroy - 0001:00069360 TStaticListAction.GetCount - 0001:0006936C TStaticListAction.GetItem - 0001:000693D0 TStaticListAction.GetItemClass - 0001:000693D8 TStaticListAction.GetString - 0001:000693FC TStaticListAction.SetListitems - 0001:0006940C TStaticListAction.SetString - 0001:00069004 TStaticListItems.Notify - 0001:000691B4 TStaticListItems.Update - 0001:0001D770 TStream.CopyFrom - 0001:0001D4D4 TStream.GetPosition - 0001:0001D508 TStream.GetSize - 0001:0001D700 TStream.ReadBuffer - 0001:0001D864 TStream.ReadComponent - 0001:0001D60C TStream.Seek - 0001:0001D690 TStream.Seek - 0001:0001D4F4 TStream.SetPosition - 0001:0001D56C TStream.SetSize - 0001:0001D554 TStream.SetSize - 0001:0001D558 TStream.SetSize64 - 0001:0001D738 TStream.WriteBuffer - 0001:0001D8C4 TStream.WriteComponent - 0001:0001D8D0 TStream.WriteDescendent - 0001:00024420 TStreamAdapter.Clone - 0001:00024374 TStreamAdapter.Commit - 0001:00024174 TStreamAdapter.CopyTo - 0001:00023F3C TStreamAdapter.Create - 0001:00023F84 TStreamAdapter.Destroy - 0001:0002438C TStreamAdapter.LockRegion - 0001:00023FBC TStreamAdapter.Read - 0001:00024380 TStreamAdapter.Revert - 0001:0002408C TStreamAdapter.Seek - 0001:00024110 TStreamAdapter.SetSize - 0001:000243A4 TStreamAdapter.Stat - 0001:00024398 TStreamAdapter.UnlockRegion - 0001:00024024 TStreamAdapter.Write - 0001:0001CEDC TStringList.Add - 0001:0001CEE8 TStringList.AddObject - 0001:0001CF4C TStringList.Changed - 0001:0001CF68 TStringList.Changing - 0001:0001CF84 TStringList.Clear - 0001:0001D4B8 TStringList.CompareStrings - 0001:0001D480 TStringList.CustomSort - 0001:0001CFC4 TStringList.Delete - 0001:0001CE80 TStringList.Destroy - 0001:0001D030 TStringList.Exchange - 0001:0001D08C TStringList.ExchangeItems - 0001:0001D0B0 TStringList.Find - 0001:0001D128 TStringList.Get - 0001:0001D15C TStringList.GetCapacity - 0001:0001D160 TStringList.GetCount - 0001:0001D164 TStringList.GetObject - 0001:0001D18C TStringList.Grow - 0001:0001D1C0 TStringList.IndexOf - 0001:0001D1FC TStringList.Insert - 0001:0001D260 TStringList.InsertItem - 0001:0001D20C TStringList.InsertObject - 0001:0001D2D8 TStringList.Put - 0001:0001D334 TStringList.PutObject - 0001:0001D374 TStringList.QuickSort - 0001:0001D408 TStringList.SetCapacity - 0001:0001D424 TStringList.SetSorted - 0001:0001D444 TStringList.SetUpdateState - 0001:0001D470 TStringList.Sort - 0001:0001C198 TStrings.Add - 0001:0001C1BC TStrings.AddObject - 0001:0001C1E0 TStrings.AddStrings - 0001:0001C298 TStrings.Assign - 0001:0001C328 TStrings.BeginUpdate - 0001:0001CE74 TStrings.CompareStrings - 0001:0001C398 TStrings.DefineProperties - 0001:0001C168 TStrings.Destroy - 0001:0001C3E4 TStrings.EndUpdate - 0001:0001C3F8 TStrings.Equals - 0001:0001C4A4 TStrings.Error - 0001:0001C4DC TStrings.Error - 0001:0001C534 TStrings.Exchange - 0001:0001C61C TStrings.GetCapacity - 0001:0001C624 TStrings.GetObject - 0001:0001C628 TStrings.GetText - 0001:0001C67C TStrings.GetTextStr - 0001:0001C7A4 TStrings.IndexOf - 0001:0001C830 TStrings.IndexOfName - 0001:0001C8F8 TStrings.IndexOfObject - 0001:0001C92C TStrings.InsertObject - 0001:0001C95C TStrings.LoadFromFile - 0001:0001C9B0 TStrings.LoadFromStream - 0001:0001CA5C TStrings.Move - 0001:0001CB0C TStrings.Put - 0001:0001CB3C TStrings.PutObject - 0001:0001CB40 TStrings.ReadData - 0001:0001CBF0 TStrings.SaveToFile - 0001:0001CC48 TStrings.SaveToStream - 0001:0001CCA4 TStrings.SetCapacity - 0001:0001CCA8 TStrings.SetStringsAdapter - 0001:0001CCDC TStrings.SetText - 0001:0001CD2C TStrings.SetTextStr - 0001:0001CDEC TStrings.SetUpdateState - 0001:0001CDF0 TStrings.WriteData - 0001:0006EBC4 TSubItems.Add - 0001:0006EBEC TSubItems.AddObject - 0001:0006EC14 TSubItems.Clear - 0001:0006EB48 TSubItems.Create - 0001:0006EC28 TSubItems.Delete - 0001:0006EB94 TSubItems.Destroy - 0001:0006EC4C TSubItems.GetHandle - 0001:0006ED30 TSubItems.GetImageIndex - 0001:0006EC9C TSubItems.Insert - 0001:0006ECDC TSubItems.Put - 0001:0006ECF8 TSubItems.RefreshItem - 0001:0006EC58 TSubItems.SetColumnWidth - 0001:0006ED44 TSubItems.SetImageIndex - 0001:0006ED24 TSubItems.SetUpdateState - 0001:00061E70 TSynchroObject.Acquire - 0001:00061E74 TSynchroObject.Release - 0001:0006C2F4 TTextAttributes.Assign - 0001:0006C434 TTextAttributes.AssignTo - 0001:0006BF68 TTextAttributes.Create - 0001:0006BFCC TTextAttributes.GetAttributes - 0001:0006C048 TTextAttributes.GetCharset - 0001:0006C08C TTextAttributes.GetColor - 0001:0006C0F4 TTextAttributes.GetName - 0001:0006C284 TTextAttributes.GetPitch - 0001:0006C230 TTextAttributes.GetSize - 0001:0006C188 TTextAttributes.GetStyle - 0001:0006BFB0 TTextAttributes.InitFormat - 0001:0006C00C TTextAttributes.SetAttributes - 0001:0006C05C TTextAttributes.SetCharset - 0001:0006C0AC TTextAttributes.SetColor - 0001:0006C118 TTextAttributes.SetName - 0001:0006C2B4 TTextAttributes.SetPitch - 0001:0006C24C TTextAttributes.SetSize - 0001:0006C1D8 TTextAttributes.SetStyle - 0001:00023158 TThread.AfterConstruction - 0001:000231F8 TThread.CallOnTerminate - 0001:000231E0 TThread.CheckThreadError - 0001:00023164 TThread.CheckThreadError - 0001:00023020 TThread.Create - 0001:000230F0 TThread.Destroy - 0001:0002320C TThread.DoTerminate - 0001:00023388 TThread.Resume - 0001:00023220 TThread.SetPriority - 0001:0002324C TThread.Synchronize - 0001:000233B0 TThread.Terminate - 0001:000233B8 TThread.WaitFor - 0001:0001B3D4 TThreadList.Add - 0001:0001B304 TThreadList.Create - 0001:0001B358 TThreadList.Destroy - 0001:0001B45C TThreadList.LockList - 0001:0001B470 TThreadList.Remove - 0001:0001B4C0 TThreadList.UnlockList - 0001:0000CC54 TThreadLocalCounter2.Delete - 0001:0000CB74 TThreadLocalCounter2.Destroy - 0001:0000CBC4 TThreadLocalCounter2.HashIndex - 0001:0000CBDC TThreadLocalCounter2.Open - 0001:0000CC64 TThreadLocalCounter2.Recycle - 0001:00038084 TTimer.Create - 0001:000380D4 TTimer.Destroy - 0001:0003820C TTimer.SetEnabled - 0001:0003821C TTimer.SetInterval - 0001:0003822C TTimer.SetOnTimer - 0001:00038244 TTimer.Timer - 0001:00038180 TTimer.UpdateTimer - 0001:0003810C TTimer.WndProc - 0001:00068FB4 TVirtualListAction.GetItem - 0001:000466CC TWinControl.ActionChange - 0001:00042B78 TWinControl.AddBiDiModeExStyle - 0001:00041DC0 TWinControl.AdjustClientRect - 0001:00045CDC TWinControl.AdjustSize - 0001:00042558 TWinControl.AlignControl - 0001:00042454 TWinControl.AlignControls - 0001:00046714 TWinControl.AssignTo - 0001:00042AA4 TWinControl.Broadcast - 0001:000462B4 TWinControl.CalcConstraints - 0001:00046744 TWinControl.CanAutoSize - 0001:00045B3C TWinControl.CanFocus - 0001:00046228 TWinControl.CanResize - 0001:00045748 TWinControl.ChangeScale - 0001:00044FC4 TWinControl.CMBiDiModeChanged - 0001:00045220 TWinControl.CMBorderChanged - 0001:0004509C TWinControl.CMChanged - 0001:000450B0 TWinControl.CMChildKey - 0001:0004517C TWinControl.CMColorChanged - 0001:0004535C TWinControl.CMControlListChange - 0001:00045260 TWinControl.CMCtl3DChanged - 0001:000451E0 TWinControl.CMCursorChanged - 0001:0004507C TWinControl.CMDesignHitTest - 0001:000450CC TWinControl.CMDialogChar - 0001:000450C4 TWinControl.CMDialogKey - 0001:000448F4 TWinControl.CMDockClient - 0001:00045300 TWinControl.CMDrag - 0001:00045134 TWinControl.CMEnabledChanged - 0001:00044FFC TWinControl.CMEnter - 0001:00045070 TWinControl.CMExit - 0001:00044A08 TWinControl.CMFloat - 0001:000450D4 TWinControl.CMFocusChanged - 0001:000452F0 TWinControl.CMFontChange - 0001:000451A4 TWinControl.CMFontChanged - 0001:00045A80 TWinControl.CMInvalidate - 0001:000452A0 TWinControl.CMParentCtl3DChanged - 0001:000432D8 TWinControl.CMRecreateWnd - 0001:00044FAC TWinControl.CMShowHintChanged - 0001:0004510C TWinControl.CMShowingChanged - 0001:000452E0 TWinControl.CMSysColorChange - 0001:00045370 TWinControl.CMSysFontChanged - 0001:000452F8 TWinControl.CMTimeChange - 0001:000449E0 TWinControl.CMUnDockClient - 0001:000450DC TWinControl.CMVisibleChanged - 0001:000452E8 TWinControl.CMWinIniChange - 0001:0004554C TWinControl.CNChar - 0001:00045420 TWinControl.CNKeyDown - 0001:000454F8 TWinControl.CNKeyUp - 0001:000455F4 TWinControl.CNSysChar - 0001:00045598 TWinControl.CNSysKeyDown - 0001:00046690 TWinControl.ConstrainedResize - 0001:00042830 TWinControl.ContainsControl - 0001:00043584 TWinControl.ControlAtPos - 0001:000447CC TWinControl.ControlsAligned - 0001:00041A80 TWinControl.Create - 0001:000447D0 TWinControl.CreateDockManager - 0001:000431C0 TWinControl.CreateHandle - 0001:00042BE0 TWinControl.CreateParams - 0001:00042B0C TWinControl.CreateSubClass - 0001:00042EA4 TWinControl.CreateWindowHandle - 0001:00042D0C TWinControl.CreateWnd - 0001:00043258 TWinControl.CustomAlignInsertBefore - 0001:0004325C TWinControl.CustomAlignPosition - 0001:00043810 TWinControl.DefaultHandler - 0001:00043060 TWinControl.DefineProperties - 0001:00041BA4 TWinControl.Destroy - 0001:00043278 TWinControl.DestroyHandle - 0001:00043114 TWinControl.DestroyWindowHandle - 0001:000430BC TWinControl.DestroyWnd - 0001:000425EC TWinControl.DisableAlign - 0001:00044568 TWinControl.DoAddDockClient - 0001:000445BC TWinControl.DockDrop - 0001:00044640 TWinControl.DockOver - 0001:0004460C TWinControl.DoDockOver - 0001:0004457C TWinControl.DoEnter - 0001:0004459C TWinControl.DoExit - 0001:0004261C TWinControl.DoFlipChildren - 0001:00044AB4 TWinControl.DoKeyDown - 0001:00044C4C TWinControl.DoKeyPress - 0001:00044B84 TWinControl.DoKeyUp - 0001:00044578 TWinControl.DoRemoveDockClient - 0001:00044680 TWinControl.DoUnDock - 0001:000425F4 TWinControl.EnableAlign - 0001:00046024 TWinControl.FindNextControl - 0001:00041C74 TWinControl.FixupTabList - 0001:000426F0 TWinControl.FlipChildren - 0001:00045BB4 TWinControl.Focused - 0001:0004670C TWinControl.GetActionLinkClass - 0001:000461A0 TWinControl.GetChildren - 0001:00045CA4 TWinControl.GetClientOrigin - 0001:00045CC4 TWinControl.GetClientRect - 0001:00042A48 TWinControl.GetControl - 0001:00042A84 TWinControl.GetControlCount - 0001:00045C10 TWinControl.GetControlExtents - 0001:00045A1C TWinControl.GetDeviceContext - 0001:000446FC TWinControl.GetDockClientCount - 0001:00044710 TWinControl.GetDockClients - 0001:00045BFC TWinControl.GetHandle - 0001:00044734 TWinControl.GetSiteInfo - 0001:00045D98 TWinControl.GetTabOrder - 0001:00045FC4 TWinControl.GetTabOrderList - 0001:00044790 TWinControl.GetVisibleDockClientCount - 0001:00045F00 TWinControl.HandleAllocated - 0001:00045BD8 TWinControl.HandleNeeded - 0001:00042864 TWinControl.Insert - 0001:000428F8 TWinControl.InsertControl - 0001:00045A70 TWinControl.Invalidate - 0001:00045B04 TWinControl.InvalidateFrame - 0001:00043618 TWinControl.IsControlMouseMsg - 0001:00045D60 TWinControl.IsCtl3DStored - 0001:0004538C TWinControl.IsMenuKey - 0001:00044A8C TWinControl.KeyDown - 0001:00044C2C TWinControl.KeyPress - 0001:00044B5C TWinControl.KeyUp - 0001:00043454 TWinControl.MainWndProc - 0001:00042AE4 TWinControl.NotifyControls - 0001:00043AA8 TWinControl.PaintControls - 0001:0004394C TWinControl.PaintHandler - 0001:00043CD8 TWinControl.PaintTo - 0001:00043A7C TWinControl.PaintWindow - 0001:00044F10 TWinControl.PaletteChanged - 0001:00043178 TWinControl.PrecedingWindow - 0001:00042EE8 TWinControl.ReadDesignSize - 0001:00041D48 TWinControl.ReadState - 0001:00042614 TWinControl.Realign - 0001:000432C0 TWinControl.RecreateWnd - 0001:000446D8 TWinControl.ReloadDockedControl - 0001:000428B0 TWinControl.Remove - 0001:000429CC TWinControl.RemoveControl - 0001:00042844 TWinControl.RemoveFocus - 0001:00045AEC TWinControl.Repaint - 0001:000444D0 TWinControl.ResetIme - 0001:00045700 TWinControl.ScaleControls - 0001:000457F4 TWinControl.ScrollBy - 0001:0004615C TWinControl.SelectFirst - 0001:00046130 TWinControl.SelectNext - 0001:00046910 TWinControl.SetBevelCut - 0001:00046954 TWinControl.SetBevelEdges - 0001:00046984 TWinControl.SetBevelKind - 0001:000469A4 TWinControl.SetBevelWidth - 0001:00045D1C TWinControl.SetBorderWidth - 0001:00045628 TWinControl.SetBounds - 0001:000461E8 TWinControl.SetChildOrder - 0001:00045D3C TWinControl.SetCtl3D - 0001:0004483C TWinControl.SetDockSite - 0001:00045B7C TWinControl.SetFocus - 0001:000443E4 TWinControl.SetIme - 0001:00045D6C TWinControl.SetParentCtl3D - 0001:00045E18 TWinControl.SetTabOrder - 0001:00045E30 TWinControl.SetTabStop - 0001:00045E90 TWinControl.SetUseDockManager - 0001:000459BC TWinControl.SetZOrder - 0001:000458E4 TWinControl.SetZOrderPosition - 0001:000458CC TWinControl.ShowControl - 0001:00045AD0 TWinControl.Update - 0001:00045F0C TWinControl.UpdateBounds - 0001:00043414 TWinControl.UpdateControlState - 0001:00043318 TWinControl.UpdateShowing - 0001:00045DBC TWinControl.UpdateTabOrder - 0001:00044CB0 TWinControl.WMChar - 0001:00044E28 TWinControl.WMCharToItem - 0001:00043F8C TWinControl.WMCommand - 0001:00044060 TWinControl.WMCompareItem - 0001:00046CD4 TWinControl.WMContextMenu - 0001:00044084 TWinControl.WMDeleteItem - 0001:00044E9C TWinControl.WMDestroy - 0001:000440A8 TWinControl.WMDrawItem - 0001:000440F0 TWinControl.WMEraseBkgnd - 0001:00044000 TWinControl.WMFontChange - 0001:00044020 TWinControl.WMHScroll - 0001:000443D0 TWinControl.WMIMEEndComp - 0001:000443BC TWinControl.WMIMEStartComp - 0001:00044B1C TWinControl.WMKeyDown - 0001:00044BEC TWinControl.WMKeyUp - 0001:000443A8 TWinControl.WMKillFocus - 0001:000440CC TWinControl.WMMeasureItem - 0001:00044280 TWinControl.WMMove - 0001:000469C4 TWinControl.WMNCCalcSize - 0001:00044ED0 TWinControl.WMNCDestroy - 0001:00044EEC TWinControl.WMNCHitTest - 0001:00046A54 TWinControl.WMNCPaint - 0001:00043FAC TWinControl.WMNotify - 0001:00043E2C TWinControl.WMPaint - 0001:00044F8C TWinControl.WMPaletteChanged - 0001:00044E48 TWinControl.WMParentNotify - 0001:00044F68 TWinControl.WMQueryNewPalette - 0001:00044294 TWinControl.WMSetCursor - 0001:00044394 TWinControl.WMSetFocus - 0001:0004424C TWinControl.WMSize - 0001:00043FD0 TWinControl.WMSysColorChange - 0001:00044D80 TWinControl.WMSysCommand - 0001:00044B3C TWinControl.WMSysKeyDown - 0001:00044C0C TWinControl.WMSysKeyUp - 0001:00044010 TWinControl.WMTimeChange - 0001:00044E7C TWinControl.WMVKeyToItem - 0001:00044040 TWinControl.WMVScroll - 0001:0004413C TWinControl.WMWindowPosChanged - 0001:000441FC TWinControl.WMWindowPosChanging - 0001:00043FEC TWinControl.WMWinIniChange - 0001:000436AC TWinControl.WndProc - 0001:00042F20 TWinControl.WriteDesignSize - 0001:00041A4C TWinControlActionLink.AssignClient - 0001:00041A70 TWinControlActionLink.IsHelpContextLinked - 0001:00041A78 TWinControlActionLink.SetHelpContext - 0001:00039ADC TWinHelpViewer.CallWinHelp - 0001:00039654 TWinHelpViewer.CanShowTableOfContents - 0001:00039D4C TWinHelpViewer.CouldBeUnstableWindow - 0001:00039430 TWinHelpViewer.Create - 0001:00039E50 TWinHelpViewer.Destroy - 0001:00039A4C TWinHelpViewer.DisplayHelpByContext - 0001:000398C4 TWinHelpViewer.DisplayTopic - 0001:000395B0 TWinHelpViewer.GetHelpStrings - 0001:00039524 TWinHelpViewer.GetViewerName - 0001:00039468 TWinHelpViewer.HelpFile - 0001:000394F8 TWinHelpViewer.InternalShutDown - 0001:00039D48 TWinHelpViewer.IsBusyWindow - 0001:00039CBC TWinHelpViewer.IsNewQuery - 0001:00039D6C TWinHelpViewer.MakeWinHelpHappy - 0001:0003980C TWinHelpViewer.NotifyID - 0001:00039DC4 TWinHelpViewer.RestartWinHelp - 0001:000396E0 TWinHelpViewer.ShowHelp - 0001:00039658 TWinHelpViewer.ShowTableOfContents - 0001:0003982C TWinHelpViewer.ShutDown - 0001:00039810 TWinHelpViewer.SoftShutDown - 0001:000399D8 TWinHelpViewer.UnderstandsContext - 0001:00039538 TWinHelpViewer.UnderstandsKeyword - 0001:0003985C TWinHelpViewer.UnderstandsTopic - 0001:00028028 TwoBitsFromDIB - 0002:000000C0 TwoDigitYearCenturyWindow - 0001:0006E8C0 TWorkArea.Create - 0001:0006E904 TWorkArea.GetDisplayName - 0001:0006E918 TWorkArea.SetDisplayName - 0001:0006EA20 TWorkAreas.GetItem - 0001:0006E958 TWorkAreas.Update - 0001:00020C78 TWriter.AddAncestor - 0001:00020CAC TWriter.DefineBinaryProperty - 0001:00020C84 TWriter.DefineProperty - 0001:00020C4C TWriter.Destroy - 0001:00020CE8 TWriter.FlushBuffer - 0001:00020CD8 TWriter.GetPosition - 0001:00020CF0 TWriter.SetPosition - 0001:00020D2C TWriter.SetRoot - 0001:00020D44 TWriter.Write - 0001:00020D90 TWriter.WriteBinary - 0001:00020E30 TWriter.WriteBoolean - 0001:00020E18 TWriter.WriteBuffer - 0001:00020E44 TWriter.WriteChar - 0001:00020E94 TWriter.WriteCollection - 0001:00020F84 TWriter.WriteComponent - 0001:000214D0 TWriter.WriteCurrency - 0001:00021060 TWriter.WriteData - 0001:000214F4 TWriter.WriteDate - 0001:00021460 TWriter.WriteDescendent - 0001:00021488 TWriter.WriteFloat - 0001:00021518 TWriter.WriteIdent - 0001:000215DC TWriter.WriteInteger - 0001:00021650 TWriter.WriteInteger - 0001:000216A8 TWriter.WriteListBegin - 0001:000216B0 TWriter.WriteListEnd - 0001:00022B60 TWriter.WriteMinStr - 0001:000216B8 TWriter.WritePrefix - 0001:000216FC TWriter.WriteProperties - 0001:000225A4 TWriter.WriteProperty - 0001:00022AB4 TWriter.WritePropName - 0001:00022B08 TWriter.WriteSignature - 0001:000214AC TWriter.WriteSingle - 0001:00022B18 TWriter.WriteStr - 0001:00022BF8 TWriter.WriteString - 0001:00022D00 TWriter.WriteValue - 0001:000226BC TWriter.WriteVariant - 0001:00022C4C TWriter.WriteWideString - 0002:00004450 TypeList - 0001:00005C88 Types - 0001:000180FC TypInfo - 0001:00000288 UnhandledExceptionFilter - 0001:0005DA64 UnhookHintHooks - 0001:00006640 UnhookWindowsHookEx - 0001:00005528 UnicodeToUtf8 - 0001:00000B4C UninitAllocator - 0001:0004E84C UniqueCommand - 0001:00003BF8 UniqueString - 0001:0000D5CC UniUnimplemented - 0001:00076B84 UnloadKernel32Dll - 0001:000753E4 UnloadModule - 0001:00075810 UnloadSystemResourcesMeterLib - 0001:00006688 UnlockResource - 0001:00006148 UnrealizeObject - 0001:00006648 UnregisterClass - 0001:0001AA38 UnregisterFindGlobalComponentProc - 0001:000053AC UnregisterModule - 0001:0001A678 UnRegisterModuleClasses - 0001:000032DC UnsetExceptionHandler - 0001:00001AC4 UpCase - 0001:00070744 UpdateColumnOrder - 0001:00029174 UpdateDIBColorTable - 0001:00041354 UpdateFloatingDockSitePos - 0001:00051648 UpdateItem - 0001:00052054 UpdateItem - 0001:00056E94 UpdateScrollProperties - 0001:00006650 UpdateWindow - 0001:00007880 UpperCase - 0001:00037370 UrlMon - 0002:00003EC8 UrlMonHandle - 0002:00003ECC UrlMonInitialized - 0002:00003B20 User32Dll - 0001:000057F4 UTF8Decode - 0001:00005748 UTF8Encode - 0001:00005604 Utf8ToUnicode - 0002:00000684 UtilWindowClass - 0001:0005FF34 ValidateHintWindow - 0001:0003CEC0 ValidDockTarget - 0002:00000C9C ValidMenuHotkeys - 0001:000564B0 ValidParentForm - 0002:0000132C Values - 0002:00000EAC Values - 0001:0000EBBC VarArrayClear - 0001:0000EF58 VarArrayCopyForEach - 0001:00015E0C VarArrayCreate - 0001:0000E788 VarArrayCreateError - 0001:00015F34 VarArrayDimCount - 0001:000160FC VarArrayGet - 0001:00015F80 VarArrayHighBound - 0001:00015F5C VarArrayLowBound - 0001:00016268 VarArrayPut - 0001:0000DAEC VarBoolFromStr - 0001:0000DB6C VarBstrFromBool - 0001:0000DB0C VarBstrFromCy - 0001:0000DB3C VarBstrFromDate - 0001:0000F494 VarCastAsAny - 0001:0000F598 VarCastAsDispatch - 0001:0000F5E4 VarCastAsInterface - 0001:0000F500 VarCastAsOleStr - 0001:0000F54C VarCastAsString - 0001:0000E5A8 VarCastError - 0001:0000E554 VarCastError - 0001:0000F6A8 VarCastRare - 0001:0000F630 VarCastViaOS - 0001:0000ED38 VarClearDeep - 0001:00015040 VarCompare - 0001:0001475C VarCompareAny - 0001:00014C20 VarCompareRare - 0001:00014A88 VarCompareSimple - 0001:0000F280 VarCopyByRef - 0001:0000F124 VarCopyCopyProc - 0001:0000F12C VarCopyDeep - 0001:0000F244 VarCopyNoIndCopyProc - 0001:0000F24C VarCopyNoIndDeep - 0001:0000F23C VarCopyNoIndOleStr - 0001:0000F21C VarCopyNoIndViaOS - 0001:0000DACC VarCyFromStr - 0001:0000DAAC VarDateFromStr - 0001:000670CC VarDispInvoke - 0002:000038C0 VarDispProc - 0001:0000DA6C VarI4FromStr - 0001:0000D594 VariantChangeType - 0001:0000DA18 VariantChangeTypeEx - 0001:0000D57C VariantClear - 0001:0000D584 VariantCopy - 0001:0000D58C VariantCopyInd - 0001:0000D574 VariantInit - 0002:00003660 VariantManager - 0001:00016FBC Variants - 0001:00004530 VariantSystemDefaultVarClear - 0001:00004528 VariantSystemUndefinedError - 0001:0000E698 VarInvalidNullOp - 0001:0000E644 VarInvalidOp - 0001:00015FAC VarIsArray - 0001:00015FA4 VarIsArray - 0001:00015BE8 VarIsClear - 0001:00015C68 VarIsNull - 0001:0000DA3C VarNeg - 0001:0000DA54 VarNot - 0001:0001395C VarOpRare - 0001:0000E6EC VarOverflowError - 0001:0000DA8C VarR8FromStr - 0001:0000EA04 VarResultCheck - 0001:0000EA10 VarResultCheck - 0001:00015CC0 VarSameValue - 0001:000138A8 VarStrCat - 0001:0000F48C VarStringToOleStr - 0001:00010AE0 VarToBoolAny - 0001:000109E0 VarToBoolAsString - 0001:00010B44 VarToBoolCustom - 0001:00010AA4 VarToBoolViaOS - 0001:00011CAC VarToCurrencyAny - 0001:00011C08 VarToCurrencyAsDouble - 0001:00011B50 VarToCurrencyAsString - 0001:00011D10 VarToCurrencyCustom - 0001:00011C64 VarToCurrencyViaOS - 0001:00011750 VarToDateAny - 0001:000116AC VarToDateAsDouble - 0001:000115C4 VarToDateAsString - 0001:000117B4 VarToDateCustom - 0001:00011708 VarToDateViaOS - 0001:00010FEC VarToDoubleAny - 0001:00010EE4 VarToDoubleAsString - 0001:00011050 VarToDoubleCustom - 0001:00010FA4 VarToDoubleViaOS - 0001:000104E4 VarToInt64Any - 0001:000103EC VarToInt64AsString - 0001:00010550 VarToInt64Custom - 0001:00010348 VarToInt64ViaOS - 0001:0000FA94 VarToIntAny - 0001:0000F9AC VarToIntAsString - 0001:0000FAF8 VarToIntCustom - 0001:0000FA5C VarToIntViaOS - 0001:00012318 VarToLStrAny - 0001:0001237C VarToLStrCustom - 0001:00012250 VarToLStrViaOS - 0001:00015C7C VarToStr - 0001:00015C94 VarToStrDef - 0001:00012A48 VarToWStrAny - 0001:00012AAC VarToWStrCustom - 0001:00012994 VarToWStrViaOS - 0001:00015BD4 VarType - 0001:00015A64 VarTypeAsText - 0001:00015C5C VarTypeIsCustom - 0001:00015FD4 VarTypeIsValidArrayType - 0001:00015FF4 VarTypeIsValidElementType - 0001:0000DF04 VarUtils - 0001:00007E20 VerifyBoolStrArray - 0001:00005F40 VerQueryValue - 0001:00075D00 VersionFixedFileInfo - 0002:00003BC0 ViewerName - 0002:0000144C ViewStyles - 0002:0000142C ViewStyles - 0001:00005EF8 VirtualAlloc - 0001:000003CC VirtualAlloc - 0001:000003D4 VirtualFree - 0001:00005F00 VirtualQuery - 0001:00000360 VirtualQuery - 0001:00005F08 WaitForSingleObject - 0001:00006658 WaitMessage - 0002:000005CC WakeMainThread - 0001:00003834 WCharFromChar - 0002:00001358 Week - 0002:000002F0 WesternGroups - 0001:000044D4 WideCharLenToStrVar - 0001:00000358 WideCharToMultiByte - 0002:000014C0 WideCRLF - 0002:000000B8 Win32BuildNumber - 0001:0000CA40 Win32Check - 0002:000000BC Win32CSDVersion - 0002:000000B0 Win32MajorVersion - 0002:000000B4 Win32MinorVersion - 0001:0004A5C8 Win32NLSEnableIME - 0002:000000AC Win32Platform - 0002:00003BD8 WindowAtom - 0002:00003BDC WindowAtomString - 0002:00000E7C WindowClass - 0001:00039BEC WindowEnumerationTester - 0001:00006668 WindowFromPoint - 0002:00000C0C WindowPos - 0001:00006884 Windows - 0001:0002879C WinError - 0001:00006660 WinHelp - 0002:00003BBC WinHelpTester - 0001:00039EE4 WinHelpViewer - 0001:00037338 WinInet - 0001:00061C78 WinSock - 0001:0002DF98 WinSpool - 0002:00000AD0 WndProcPtrAtom - 0002:00000A14 WordWraps - 0002:00001424 WrapText - 0001:0001AD88 WriteCollection - 0001:00021960 WriteCollectionProp - 0001:0006E358 WriteCols - 0001:000493FC WriteControlName - 0001:000034F8 WriteErrorMessage - 0001:00005F10 WriteFile - 0001:00000290 WriteFile - 0001:00021B8C WriteFloatProp - 0001:000287AC WriteIcon - 0001:00021C28 WriteInt64Prop - 0001:00022250 WriteInterfaceProp - 0001:000218F4 WriteIntProp - 0001:0006F818 WriteItems - 0001:000223F4 WriteMethodProp - 0001:00021F4C WriteObjectProp - 0001:00021A60 WriteOrdProp - 0001:00005F18 WritePrivateProfileString - 0001:0002180C WritePropPath - 0001:00021860 WriteSet - 0001:00021CF8 WriteStrProp - 0001:00022534 WriteVariantProp - 0001:00061C18 WSAAsyncGetHostByName - 0001:00061C20 WSAAsyncGetServByName - 0001:00061C10 WSAAsyncSelect - 0001:00061C28 WSACancelAsyncRequest - 0001:00061C40 WSACleanup - 0002:00003CA8 WSAData - 0001:00061C30 WSAGetLastError - 0001:00061C38 WSAStartup - 0001:00003DB8 WStrError - 0001:00003DD8 WStrSet - 0001:0002CC9C xEnumDisplayMonitors - 0001:0002CA20 xGetMonitorInfo - 0001:0002CAF4 xGetMonitorInfoA - 0001:0002CBC8 xGetMonitorInfoW - 0001:0002C988 xMonitorFromPoint - 0001:0002C860 xMonitorFromRect - 0001:0002C8F0 xMonitorFromWindow - 0002:0000134C Year - 0001:0000EDC8 _DispInvoke - 0001:0000EAC8 _DispInvokeError - 0002:00003B68 _FlatSB_GetScrollProp - 0002:00003B6C _FlatSB_SetScrollProp - 0001:0002C7D8 _GetSystemMetrics - 0002:00003C40 _ImmGetCompositionString - 0002:00003C24 _ImmGetContext - 0002:00003C2C _ImmGetConversionStatus - 0002:00003C44 _ImmIsIME - 0002:00003C48 _ImmNotifyIME - 0002:00003C28 _ImmReleaseContext - 0002:00003C3C _ImmSetCompositionFont - 0002:00003C38 _ImmSetCompositionWindow - 0002:00003C30 _ImmSetConversionStatus - 0002:00003C34 _ImmSetOpenStatus - 0002:00003AF8 _InitCommonControlsEx - 0002:00003B70 _InitializeFlatSB - 0001:00013334 _OleVarFromInt - 0001:0001364C _OleVarFromLStr - 0001:0001369C _OleVarFromPStr - 0001:00013758 _OleVarFromVar - 0002:00003B74 _UninitializeFlatSB - 0001:000158E0 _VarAddRef - 0001:00016030 _VarArrayGet - 0001:00016120 _VarArrayPut - 0001:00015EB4 _VarArrayRedim - 0001:0000F714 _VarCast - 0001:0000F940 _VarCastOle - 0001:0000EDB4 _VarClear - 0001:000150C0 _VarCmp - 0001:0000F1D8 _VarCopy - 0001:0000F458 _VarCopyNoInd - 0001:000134C8 _VarFromBool - 0001:00013354 _VarFromByte - 0001:00013518 _VarFromCurr - 0001:00013470 _VarFromCurrency - 0001:0001349C _VarFromDate - 0001:0001360C _VarFromDisp - 0001:00013444 _VarFromDouble - 0001:00013638 _VarFromDynArray - 0001:000132D4 _VarFromInt - 0001:000133F4 _VarFromInt64 - 0001:00013314 _VarFromInteger - 0001:000135E0 _VarFromIntf - 0001:00013394 _VarFromLongWord - 0001:0001352C _VarFromLStr - 0001:00013558 _VarFromPStr - 0001:000134F0 _VarFromReal - 0001:000133B4 _VarFromShortInt - 0001:00013420 _VarFromSingle - 0001:000133D4 _VarFromSmallInt - 0001:00013504 _VarFromTDateTime - 0001:00013374 _VarFromWord - 0001:000135A8 _VarFromWStr - 0001:000151B8 _VarNeg - 0001:00015660 _VarNot - 0001:0000EB1C _VarNull - 0001:000146CC _VarOp - 0001:0000F46C _VarStringToOleStr - 0001:00010B90 _VarToBool - 0001:00010ED8 _VarToBoolWithFix - 0001:0000FFE8 _VarToByte - 0001:00011D5C _VarToCurrency - 0001:00011800 _VarToDate - 0001:00013218 _VarToDisp - 0001:0001109C _VarToDouble - 0001:000132C4 _VarToDynArray - 0001:00011418 _VarToExtended - 0001:0001059C _VarToInt64 - 0001:0000FB3C _VarToInteger - 0001:0001314C _VarToIntf - 0001:00010260 _VarToLongWord - 0001:00012400 _VarToLStr - 0001:00012944 _VarToPStr - 0001:0000FF38 _VarToShortInt - 0001:00011434 _VarToSingle - 0001:00010090 _VarToSmallInt - 0001:00010188 _VarToWord - 0001:00012B74 _VarToWStr - 0002:00003C20 _WINNLSEnableIME - 0001:00015DC0 _Write0Variant - 0001:00015D5C _WriteVariant - - - Address Publics by Value - - 0002:FFB84014 TlsLast - 0001:00000238 CloseHandle - 0001:00000240 CreateFileA - 0001:00000248 GetFileType - 0001:00000250 GetFileSize - 0001:00000258 GetStdHandle - 0001:00000260 RaiseException - 0001:00000268 ReadFile - 0001:00000270 RtlUnwind - 0001:00000278 SetEndOfFile - 0001:00000280 SetFilePointer - 0001:00000288 UnhandledExceptionFilter - 0001:00000290 WriteFile - 0001:00000298 CharNext - 0001:000002A0 CreateThread - 0001:000002A8 ExitThread - 0001:000002B0 ExitProcess - 0001:000002B8 MessageBox - 0001:000002C0 FindClose - 0001:000002C8 FindFirstFile - 0001:000002D0 FreeLibrary - 0001:000002D8 GetCommandLine - 0001:000002E0 GetLastError - 0001:000002E8 GetLocaleInfo - 0001:000002F0 GetModuleFileName - 0001:000002F8 GetModuleHandle - 0001:00000300 GetProcAddress - 0001:00000308 GetStartupInfo - 0001:00000310 GetThreadLocale - 0001:00000318 LoadLibraryEx - 0001:00000320 LoadString - 0001:00000328 lstrcpyn - 0001:00000330 @strlen - 0001:00000338 MultiByteToWideChar - 0001:00000340 RegCloseKey - 0001:00000348 RegOpenKeyEx - 0001:00000350 RegQueryValueEx - 0001:00000358 WideCharToMultiByte - 0001:00000360 VirtualQuery - 0001:00000368 SysAllocStringLen - 0001:00000370 SysReAllocStringLen - 0001:00000378 SysFreeString - 0001:00000380 InterlockedIncrement - 0001:00000388 InterlockedDecrement - 0001:00000390 GetCurrentThreadId - 0001:00000398 GetCmdShow - 0001:000003BC LocalAlloc - 0001:000003C4 LocalFree - 0001:000003CC VirtualAlloc - 0001:000003D4 VirtualFree - 0001:000003DC InitializeCriticalSection - 0001:000003E4 EnterCriticalSection - 0001:000003EC LeaveCriticalSection - 0001:000003F4 DeleteCriticalSection - 0001:000003FC GetBlockDesc - 0001:0000044C MakeEmpty - 0001:00000454 AddBlockAfter - 0001:00000484 DeleteBlock - 0001:0000049C MergeBlockAfter - 0001:0000050C RemoveBlock - 0001:000005A0 GetSpace - 0001:00000604 GetSpaceAt - 0001:0000067C FreeSpace - 0001:00000734 Commit - 0001:000007C8 Decommit - 0001:00000848 GetCommitted - 0001:000008D8 GetCommittedAt - 0001:000009FC FreeCommitted - 0001:00000A88 InitAllocator - 0001:00000B4C UninitAllocator - 0001:00000C2C DeleteFree - 0001:00000C90 FindCommitted - 0001:00000CC0 FillBeforeGap - 0001:00000CF0 InternalFreeMem - 0001:00000D14 FillAfterGap - 0001:00000D3C FillerSizeBeforeGap - 0001:00000DAC FillerSizeAfterGap - 0001:00000DE4 DecommitFree - 0001:00000E94 InsertFree - 0001:00000F1C FreeCurAlloc - 0001:00000F68 MergeCommit - 0001:00000FF4 NewCommit - 0001:00001020 NewCommitAt - 0001:00001054 SearchSmallBlocks - 0001:00001080 TryHarder - 0001:00001174 SysGetMem - 0001:00001304 SysFreeMem - 0001:000014A8 ResizeInPlace - 0001:00001678 SysReallocMem - 0001:0000173C @GetMem - 0001:0000175C @FreeMem - 0001:0000177C @ReallocMem - 0001:000017CC ExceptObject - 0001:000017EC ExceptAddr - 0001:0000180C AcquireExceptionObject - 0001:00001840 RunErrorAt - 0001:0000184C ErrorAt - 0001:00001898 Error - 0001:000018A4 @_IOTest - 0001:000018C4 SetInOutRes - 0001:000018D4 @Copy - 0001:00001918 IOResult - 0001:00001938 Move - 0001:00001978 GetParamStr - 0001:00001A64 ParamStr - 0001:00001AC4 UpCase - 0001:00001AD0 @ROUND - 0001:00001ADC @TRUNC - 0001:00001B00 @AbstractError - 0001:00001B1C OpenText - 0001:00001B74 @ResetText - 0001:00001B80 @RewritText - 0001:00001B8C TextIn - 0001:00001BC8 FileNOPProc - 0001:00001BCC TextOut - 0001:00001C08 InternalClose - 0001:00001C18 TextClose - 0001:00001C38 TextOpen - 0001:00001DE4 @Assign - 0001:00001E4C InternalFlush - 0001:00001E94 Flush - 0001:00001EA0 @Flush - 0001:00001EAC @Close - 0001:00001F04 @PStrNCpy - 0001:00001F20 @PStrCmp - 0001:00001FA4 @AStrCmp - 0001:00002014 @EofText - 0001:0000204C @FillChar - 0001:0000206C TryOpenForInput - 0001:000020A8 @ReadChar - 0001:00002114 ReadLine - 0001:00002188 @ReadString - 0001:00002194 @ReadLString - 0001:00002200 @ReadLn - 0001:00002230 @ValLong - 0001:000022FC TryOpenForOutput - 0001:00002340 @WriteBytes - 0001:00002394 @WriteSpaces - 0001:00002410 @_CToPasStr - 0001:0000241C @_CLenToPasStr - 0001:00002440 @SetEq - 0001:00002454 FPower10 - 0001:0000245C @Pow10 - 0001:0000273C GetKeyboardType - 0001:00002744 @isNECWindows - 0001:00002774 @FpuMaskInit - 0001:00002838 @FpuInit - 0001:00002844 @BoundErr - 0001:0000284C TObject.ClassType - 0001:00002854 TObject.ClassName - 0001:00002868 TObject.ClassNameIs - 0001:00002890 TObject.ClassParent - 0001:0000289C TObject.NewInstance - 0001:000028B8 TObject.FreeInstance - 0001:000028CC TObject.InstanceSize - 0001:000028D4 TObject.Create - 0001:000028F4 TObject.Destroy - 0001:00002904 TObject.Free - 0001:00002910 TObject.InitInstance - 0001:00002968 TObject.CleanupInstance - 0001:00002988 InvokeImplGetter - 0001:000029B8 TObject.GetInterface - 0001:00002A4C TObject.GetInterfaceEntry - 0001:00002A90 @IsClass - 0001:00002AB4 @AsClass - 0001:00002AD0 GetDynaMethod - 0001:00002B00 @CallDynaInst - 0001:00002B18 TObject.InheritsFrom - 0001:00002B2C TObject.ClassInfo - 0001:00002B34 TObject.SafeCallException - 0001:00002B3C TObject.DefaultHandler - 0001:00002B40 TObject.AfterConstruction - 0001:00002B44 TObject.BeforeDestruction - 0001:00002B48 TObject.Dispatch - 0001:00002B70 TObject.MethodAddress - 0001:00002BC0 TObject.MethodName - 0001:00002C00 TObject.FieldAddress - 0001:00002C50 @ClassCreate - 0001:00002CA0 @ClassDestroy - 0001:00002CA8 @AfterConstruction - 0001:00002CB8 @BeforeDestruction - 0001:00002CC8 NotifyReRaise - 0001:00002CE4 NotifyNonDelphiException - 0001:00002D08 NotifyExcept - 0001:00002D20 NotifyOnExcept - 0001:00002D34 NotifyAnyExcept - 0001:00002D48 CheckJmp - 0001:00002D68 NotifyExceptFinally - 0001:00002D90 NotifyTerminate - 0001:00002DAC NotifyUnhandled - 0001:00002DCC @HandleAnyException - 0001:00002EF8 @HandleOnException - 0001:00003080 @HandleFinally - 0001:000030B8 @RaiseExcept - 0001:000030E0 @RaiseAgain - 0001:00003134 @DoneExcept - 0001:00003164 @TryFinallyExit - 0001:0000317C MapToRunError - 0001:0000321C @ExceptionHandler - 0001:000032BC SetExceptionHandler - 0001:000032DC UnsetExceptionHandler - 0001:00003304 FinalizeUnits - 0001:00003364 InitUnits - 0001:000033C4 @StartExe - 0001:00003404 @InitResStringImports - 0001:0000342C @InitImports - 0001:00003450 @InitWideStrings - 0001:0000346C MakeErrorMessage - 0001:000034C8 ExitDll - 0001:000034F8 WriteErrorMessage - 0001:00003584 @Halt0 - 0001:0000365C @Halt - 0001:00003668 @RunError - 0001:00003674 ThreadWrapper - 0001:000036AC BeginThread - 0001:000036F0 EndThread - 0001:000036F8 @LStrClr - 0001:0000371C @LStrArrayClr - 0001:0000374C @LStrAsg - 0001:00003790 @LStrLAsg - 0001:000037BC @NewAnsiString - 0001:000037E8 @LStrFromPCharLen - 0001:00003818 CharFromWChar - 0001:00003834 WCharFromChar - 0001:0000384C @LStrFromPWCharLen - 0001:000038D8 @LStrFromChar - 0001:000038E8 @LStrFromPChar - 0001:00003918 @LStrFromPWChar - 0001:00003954 @LStrFromString - 0001:00003960 @LStrFromArray - 0001:00003978 @LStrFromWStr - 0001:0000398C @LStrToString - 0001:000039B0 @LStrLen - 0001:000039B8 @LStrCat - 0001:000039FC @LStrCat3 - 0001:00003A70 @LStrCatN - 0001:00003AF4 @LStrCmp - 0001:00003B98 @LStrAddRef - 0001:00003BA8 @LStrToPChar - 0001:00003BB4 InternalUniqueString - 0001:00003BF8 UniqueString - 0001:00003C00 @UniqueStringA - 0001:00003C08 @LStrCopy - 0001:00003C48 @LStrDelete - 0001:00003C90 @LStrInsert - 0001:00003CEC @LStrPos - 0001:00003D34 @LStrSetLength - 0001:00003D98 @WriteLString - 0001:00003DB8 WStrError - 0001:00003DC0 @NewWideString - 0001:00003DD8 WStrSet - 0001:00003DE8 @WStrClr - 0001:00003E00 @WStrArrayClr - 0001:00003E24 @WStrAsg - 0001:00003E48 @WStrFromPCharLen - 0001:00003ED4 @WStrFromPWCharLen - 0001:00003EF8 @WStrFromPWChar - 0001:00003F34 @WStrFromLStr - 0001:00003F44 @WStrToPWChar - 0001:00003F54 @WStrLen - 0001:00003F60 @WStrCat - 0001:00003FC0 @WStrCmp - 0001:00004044 @WStrCopy - 0001:00004090 @WStrSetLength - 0001:000040D4 @InitializeRecord - 0001:00004104 @InitializeArray - 0001:00004198 @FinalizeRecord - 0001:000041CC @FinalizeArray - 0001:000042B8 @Finalize - 0001:000042C4 @CopyRecord - 0001:000043E0 @CopyArray - 0001:000044D4 WideCharLenToStrVar - 0001:000044E0 OleStrToStrVar - 0001:00004504 StringToOleStr - 0001:00004528 VariantSystemUndefinedError - 0001:00004530 VariantSystemDefaultVarClear - 0001:00004548 InitVariantManager - 0001:00004568 GetVariantManager - 0001:0000457C SetVariantManager - 0001:00004590 @VarClear - 0001:00004598 @VarCopy - 0001:000045A0 @VarCast - 0001:000045A8 @VarToInt - 0001:000045B0 @VarToInt64 - 0001:000045B8 @VarToBool - 0001:000045C0 @VarToReal - 0001:000045C8 @VarToCurr - 0001:000045D0 @VarToLStr - 0001:000045D8 @VarToWStr - 0001:000045E0 @VarToIntf - 0001:000045E8 @VarToDisp - 0001:000045F0 @VarFromInt - 0001:000045F8 @VarFromInt64 - 0001:0000460C @VarFromBool - 0001:00004614 @VarFromReal - 0001:0000461C @VarFromTDateTime - 0001:00004624 @VarFromCurr - 0001:0000462C @VarFromLStr - 0001:00004634 @VarFromWStr - 0001:0000463C @VarFromIntf - 0001:00004644 @VarFromDisp - 0001:0000464C @VarCmpEQ - 0001:00004658 @VarNeg - 0001:00004660 @VarNot - 0001:00004668 @VarClr - 0001:00004670 @DispCallByIDError - 0001:00004678 @_llmul - 0001:0000469C @_lldiv - 0001:00004718 @_lludiv - 0001:00004764 @_llmod - 0001:000047E0 @_llumod - 0001:00004830 @_llshl - 0001:00004850 @_llushr - 0001:00004870 @ValInt64 - 0001:00004A94 @DynArrayLength - 0001:00004A9C @DynArrayHigh - 0001:00004AA4 CopyArray - 0001:00004AB4 FinalizeArray - 0001:00004ABC DynArrayClear - 0001:00004AC4 DynArraySetLength - 0001:00004C50 @DynArraySetLength - 0001:00004C5C @DynArrayCopy - 0001:00004C7C @DynArrayCopyRange - 0001:00004D70 @DynArrayClear - 0001:00004DAC @DynArrayAsg - 0001:00004DD4 FindHInstance - 0001:00004DFC FindClassHInstance - 0001:00004E04 DelayLoadResourceModule - 0001:00004E4C FindResourceHInstance - 0001:00004E74 FindBS - 0001:00004E88 ToLongPath - 0001:00005040 LoadResourceModule - 0001:000052B0 AddModuleUnloadProc - 0001:000052B8 RemoveModuleUnloadProc - 0001:000052C0 AddModuleUnloadProc - 0001:000052E0 RemoveModuleUnloadProc - 0001:00005340 NotifyModuleUnload - 0001:0000539C RegisterModule - 0001:000053AC UnregisterModule - 0001:0000541C @IntfClear - 0001:00005434 @IntfCopy - 0001:00005460 @IntfCast - 0001:0000548C @IntfAddRef - 0001:00005498 TInterfacedObject.AfterConstruction - 0001:000054A4 TInterfacedObject.BeforeDestruction - 0001:000054B4 TInterfacedObject.NewInstance - 0001:000054C4 TInterfacedObject.QueryInterface - 0001:000054EC TInterfacedObject._AddRef - 0001:00005500 TInterfacedObject._Release - 0001:00005528 UnicodeToUtf8 - 0001:00005604 Utf8ToUnicode - 0001:00005748 UTF8Encode - 0001:000057F4 UTF8Decode - 0001:00005898 AnsiToUtf8 - 0001:000058E8 LoadResString - 0001:00005940 Finalization - 0001:00005994 System - 0001:00005A1C GetModuleHandle - 0001:00005A24 LocalAlloc - 0001:00005A2C TlsGetValue - 0001:00005A34 TlsSetValue - 0001:00005A3C AllocTlsBuffer - 0001:00005A48 GetTlsSize - 0001:00005A50 InitThreadTLS - 0001:00005A94 @GetTls - 0001:00005AD4 InitializeModule - 0001:00005AE0 @InitExe - 0001:00005B24 Finalization - 0001:00005B54 SysInit - 0001:00005B5C Rect - 0001:00005B78 Point - 0001:00005B80 IntersectRect - 0001:00005BE0 IsRectEmpty - 0001:00005BF8 OffsetRect - 0001:00005C10 Bounds - 0001:00005C2C CenterPoint - 0001:00005C58 Finalization - 0001:00005C88 Types - 0001:00005C90 InitializeSecurityDescriptor - 0001:00005C98 RegCloseKey - 0001:00005CA0 RegOpenKeyEx - 0001:00005CA8 RegQueryValueEx - 0001:00005CB0 SetSecurityDescriptorDacl - 0001:00005CB8 CloseHandle - 0001:00005CC0 CompareString - 0001:00005CC8 CreateEvent - 0001:00005CD0 CreateFile - 0001:00005CD8 CreatePipe - 0001:00005CE0 CreateProcess - 0001:00005CE8 CreateThread - 0001:00005CF0 DeleteCriticalSection - 0001:00005CF8 EnterCriticalSection - 0001:00005D00 EnumCalendarInfoA - 0001:00005D08 FileTimeToDosDateTime - 0001:00005D10 FileTimeToLocalFileTime - 0001:00005D18 FindClose - 0001:00005D20 FindFirstFile - 0001:00005D28 FindResource - 0001:00005D30 FormatMessage - 0001:00005D38 FreeLibrary - 0001:00005D40 FreeResource - 0001:00005D48 GetACP - 0001:00005D50 GetCPInfo - 0001:00005D58 GetCurrentProcessId - 0001:00005D60 GetCurrentThreadId - 0001:00005D68 GetDateFormat - 0001:00005D70 GetDiskFreeSpaceA - 0001:00005D78 GetExitCodeProcess - 0001:00005D80 GetExitCodeThread - 0001:00005D88 GetLastError - 0001:00005D90 GetLocalTime - 0001:00005D98 GetLocaleInfo - 0001:00005DA0 GetModuleFileName - 0001:00005DA8 GetModuleHandle - 0001:00005DB0 GetPrivateProfileString - 0001:00005DB8 GetProcAddress - 0001:00005DC0 GetProfileString - 0001:00005DC8 GetStartupInfo - 0001:00005DD0 GetStdHandle - 0001:00005DD8 GetStringTypeEx - 0001:00005DE0 GetStringTypeExA - 0001:00005DE8 GetSystemInfo - 0001:00005DF0 GetThreadLocale - 0001:00005DF8 GetTickCount - 0001:00005E00 GetVersion - 0001:00005E08 GetVersionEx - 0001:00005E10 GlobalAddAtom - 0001:00005E18 GlobalAlloc - 0001:00005E20 GlobalDeleteAtom - 0001:00005E28 GlobalFindAtom - 0001:00005E30 GlobalFree - 0001:00005E38 GlobalLock - 0001:00005E40 GlobalHandle - 0001:00005E48 GlobalReAlloc - 0001:00005E50 GlobalUnlock - 0001:00005E58 InitializeCriticalSection - 0001:00005E60 LeaveCriticalSection - 0001:00005E68 LoadLibrary - 0001:00005E70 LoadResource - 0001:00005E78 LockResource - 0001:00005E80 MulDiv - 0001:00005E88 MultiByteToWideChar - 0001:00005E90 PeekNamedPipe - 0001:00005E98 ReadFile - 0001:00005EA0 ResetEvent - 0001:00005EA8 ResumeThread - 0001:00005EB0 SetEndOfFile - 0001:00005EB8 SetErrorMode - 0001:00005EC0 SetEvent - 0001:00005EC8 SetFilePointer - 0001:00005ED0 SetThreadLocale - 0001:00005ED8 SetThreadPriority - 0001:00005EE0 SizeofResource - 0001:00005EE8 Sleep - 0001:00005EF0 SleepEx - 0001:00005EF8 VirtualAlloc - 0001:00005F00 VirtualQuery - 0001:00005F08 WaitForSingleObject - 0001:00005F10 WriteFile - 0001:00005F18 WritePrivateProfileString - 0001:00005F20 lstrcmp - 0001:00005F28 lstrcpy - 0001:00005F30 GetFileVersionInfo - 0001:00005F38 GetFileVersionInfoSize - 0001:00005F40 VerQueryValue - 0001:00005F48 BitBlt - 0001:00005F50 CreateBitmap - 0001:00005F58 CreateBrushIndirect - 0001:00005F60 CreateCompatibleBitmap - 0001:00005F68 CreateCompatibleDC - 0001:00005F70 CreateDC - 0001:00005F78 CreateDIBSection - 0001:00005F80 CreateDIBitmap - 0001:00005F88 CreateFontIndirect - 0001:00005F90 CreateHalftonePalette - 0001:00005F98 CreateIC - 0001:00005FA0 CreatePalette - 0001:00005FA8 CreatePenIndirect - 0001:00005FB0 CreateSolidBrush - 0001:00005FB8 DeleteDC - 0001:00005FC0 DeleteObject - 0001:00005FC8 EndDoc - 0001:00005FD0 EndPage - 0001:00005FD8 ExcludeClipRect - 0001:00005FE0 ExtTextOut - 0001:00005FE8 GetBitmapBits - 0001:00005FF0 GetBrushOrgEx - 0001:00005FF8 GetClipBox - 0001:00006000 GetCurrentPositionEx - 0001:00006008 GetDCOrgEx - 0001:00006010 GetDIBColorTable - 0001:00006018 GetDIBits - 0001:00006020 GetDeviceCaps - 0001:00006028 GetObject - 0001:00006030 GetPaletteEntries - 0001:00006038 GetPixel - 0001:00006040 GetStockObject - 0001:00006048 GetSystemPaletteEntries - 0001:00006050 GetTextExtentPoint32 - 0001:00006058 GetTextMetrics - 0001:00006060 GetWindowOrgEx - 0001:00006068 IntersectClipRect - 0001:00006070 LineTo - 0001:00006078 MaskBlt - 0001:00006080 MoveToEx - 0001:00006088 PatBlt - 0001:00006090 Polyline - 0001:00006098 RealizePalette - 0001:000060A0 RectVisible - 0001:000060A8 Rectangle - 0001:000060B0 RestoreDC - 0001:000060B8 SaveDC - 0001:000060C0 SelectObject - 0001:000060C8 SelectPalette - 0001:000060D0 SetAbortProc - 0001:000060D8 SetBkColor - 0001:000060E0 SetBkMode - 0001:000060E8 SetBrushOrgEx - 0001:000060F0 SetDIBColorTable - 0001:000060F8 SetMapMode - 0001:00006100 SetPixel - 0001:00006108 SetROP2 - 0001:00006110 SetStretchBltMode - 0001:00006118 SetTextColor - 0001:00006120 SetViewportOrgEx - 0001:00006128 SetWindowOrgEx - 0001:00006130 StartDoc - 0001:00006138 StartPage - 0001:00006140 StretchBlt - 0001:00006148 UnrealizeObject - 0001:00006150 ActivateKeyboardLayout - 0001:00006158 AdjustWindowRectEx - 0001:00006160 AnsiLower - 0001:00006168 BeginPaint - 0001:00006170 CallNextHookEx - 0001:00006178 CallWindowProc - 0001:00006180 CharLowerBuff - 0001:00006188 CharNext - 0001:00006190 CharUpperBuff - 0001:00006198 CheckMenuItem - 0001:000061A0 ChildWindowFromPoint - 0001:000061A8 ClientToScreen - 0001:000061B0 CreateIcon - 0001:000061B8 CreateMenu - 0001:000061C0 CreatePopupMenu - 0001:000061C8 CreateWindowEx - 0001:000061D0 DefFrameProc - 0001:000061D8 DefMDIChildProc - 0001:000061E0 DefWindowProc - 0001:000061E8 DeleteMenu - 0001:000061F0 DestroyCursor - 0001:000061F8 DestroyIcon - 0001:00006200 DestroyMenu - 0001:00006208 DestroyWindow - 0001:00006210 DispatchMessage - 0001:00006218 DrawAnimatedRects - 0001:00006220 DrawEdge - 0001:00006228 DrawFocusRect - 0001:00006230 DrawFrameControl - 0001:00006238 DrawIcon - 0001:00006240 DrawIconEx - 0001:00006248 DrawMenuBar - 0001:00006250 DrawText - 0001:00006258 EnableMenuItem - 0001:00006260 EnableScrollBar - 0001:00006268 EnableWindow - 0001:00006270 EndPaint - 0001:00006278 EnumThreadWindows - 0001:00006280 EnumWindows - 0001:00006288 EqualRect - 0001:00006290 FillRect - 0001:00006298 FindWindow - 0001:000062A0 FindWindowEx - 0001:000062A8 FrameRect - 0001:000062B0 GetActiveWindow - 0001:000062B8 GetCapture - 0001:000062C0 GetClassInfo - 0001:000062C8 GetClassName - 0001:000062D0 GetClientRect - 0001:000062D8 GetCursor - 0001:000062E0 GetCursorPos - 0001:000062E8 GetDC - 0001:000062F0 GetDCEx - 0001:000062F8 GetDesktopWindow - 0001:00006300 GetDoubleClickTime - 0001:00006308 GetFocus - 0001:00006310 GetForegroundWindow - 0001:00006318 GetIconInfo - 0001:00006320 GetKeyNameText - 0001:00006328 GetKeyState - 0001:00006330 GetKeyboardLayout - 0001:00006338 GetKeyboardLayoutList - 0001:00006340 GetKeyboardState - 0001:00006348 GetLastActivePopup - 0001:00006350 GetMenu - 0001:00006358 GetMenuItemCount - 0001:00006360 GetMenuItemID - 0001:00006368 GetMenuItemInfo - 0001:00006370 GetMenuState - 0001:00006378 GetMenuString - 0001:00006380 GetMessagePos - 0001:00006388 GetNextWindow - 0001:00006390 GetParent - 0001:00006398 GetProp - 0001:000063A0 GetScrollInfo - 0001:000063A8 GetScrollPos - 0001:000063B0 GetScrollRange - 0001:000063B8 GetSubMenu - 0001:000063C0 GetSysColor - 0001:000063C8 GetSystemMenu - 0001:000063D0 GetSystemMetrics - 0001:000063D8 GetTopWindow - 0001:000063E0 GetUpdateRect - 0001:000063E8 GetWindow - 0001:000063F0 GetWindowDC - 0001:000063F8 GetWindowLong - 0001:00006400 GetWindowPlacement - 0001:00006408 GetWindowRect - 0001:00006410 GetWindowText - 0001:00006418 GetWindowThreadProcessId - 0001:00006420 GetWindowThreadProcessId - 0001:00006428 InflateRect - 0001:00006430 InsertMenu - 0001:00006438 InsertMenuItem - 0001:00006440 IntersectRect - 0001:00006448 InvalidateRect - 0001:00006450 IsChild - 0001:00006458 IsDialogMessage - 0001:00006460 IsIconic - 0001:00006468 IsRectEmpty - 0001:00006470 IsWindow - 0001:00006478 IsWindowEnabled - 0001:00006480 IsWindowVisible - 0001:00006488 IsZoomed - 0001:00006490 KillTimer - 0001:00006498 LoadBitmap - 0001:000064A0 LoadCursor - 0001:000064A8 LoadIcon - 0001:000064B0 LoadKeyboardLayout - 0001:000064B8 LoadString - 0001:000064C0 MapVirtualKey - 0001:000064C8 MapWindowPoints - 0001:000064D0 MessageBox - 0001:000064D8 MsgWaitForMultipleObjects - 0001:000064E0 OemToAnsi - 0001:000064E8 OffsetRect - 0001:000064F0 PeekMessage - 0001:000064F8 PostMessage - 0001:00006500 PostQuitMessage - 0001:00006508 PtInRect - 0001:00006510 RedrawWindow - 0001:00006518 RegisterClass - 0001:00006520 RegisterClipboardFormat - 0001:00006528 RegisterWindowMessage - 0001:00006530 ReleaseCapture - 0001:00006538 ReleaseDC - 0001:00006540 RemoveMenu - 0001:00006548 RemoveProp - 0001:00006550 ScreenToClient - 0001:00006558 ScrollWindow - 0001:00006560 SendMessage - 0001:00006568 SetActiveWindow - 0001:00006570 SetCapture - 0001:00006578 SetClassLong - 0001:00006580 SetCursor - 0001:00006588 SetFocus - 0001:00006590 SetForegroundWindow - 0001:00006598 SetMenu - 0001:000065A0 SetMenuItemInfo - 0001:000065A8 SetProp - 0001:000065B0 SetRect - 0001:000065B8 SetScrollInfo - 0001:000065C0 SetScrollPos - 0001:000065C8 SetScrollRange - 0001:000065D0 SetTimer - 0001:000065D8 SetWindowLong - 0001:000065E0 SetWindowPlacement - 0001:000065E8 SetWindowPos - 0001:000065F0 SetWindowText - 0001:000065F8 SetWindowsHookEx - 0001:00006600 ShowCursor - 0001:00006608 ShowOwnedPopups - 0001:00006610 ShowScrollBar - 0001:00006618 ShowWindow - 0001:00006620 SystemParametersInfo - 0001:00006628 TrackPopupMenu - 0001:00006630 TranslateMDISysAccel - 0001:00006638 TranslateMessage - 0001:00006640 UnhookWindowsHookEx - 0001:00006648 UnregisterClass - 0001:00006650 UpdateWindow - 0001:00006658 WaitMessage - 0001:00006660 WinHelp - 0001:00006668 WindowFromPoint - 0001:00006670 MakeLong - 0001:0000667C HiWord - 0001:00006680 GetCurrentTime - 0001:00006688 UnlockResource - 0001:0000668C GlobalAllocPtr - 0001:0000669C GlobalReAllocPtr - 0001:000066B8 GlobalFreePtr - 0001:000066CC MakeROP4 - 0001:000066D8 RGB - 0001:000066F4 SmallPointToPoint - 0001:00006708 PointToSmallPoint - 0001:00006720 MakeLParam - 0001:00006728 CreateWindow - 0001:0000675C HwndMSWheel - 0001:00006854 Finalization - 0001:00006884 Windows - 0001:0000688C Finalization - 0001:000068BC Messages - 0001:00006BDC Finalization - 0001:00006C0C SysConst - 0001:000077A4 DivMod - 0001:000077C0 ConvertError - 0001:000077D8 ConvertErrorFmt - 0001:000077FC AllocMem - 0001:0000781C DoExitProc - 0001:00007848 AddExitProc - 0001:00007880 UpperCase - 0001:000078BC LowerCase - 0001:000078F8 CompareStr - 0001:00007928 CompareMem - 0001:00007948 CompareText - 0001:0000799C SameText - 0001:000079C0 AnsiUpperCase - 0001:000079F4 AnsiLowerCase - 0001:00007A28 AnsiCompareStr - 0001:00007A60 AnsiCompareText - 0001:00007A98 AnsiSameText - 0001:00007AB0 AnsiStrLIComp - 0001:00007AD0 Trim - 0001:00007B20 AdjustLineBreaks - 0001:00007C88 IsValidIdent - 0001:00007CEC IntToStr - 0001:00007D1C IntToStr - 0001:00007D50 IntToHex - 0001:00007D8C StrToInt - 0001:00007DC8 StrToIntDef - 0001:00007DE0 TryStrToInt - 0001:00007E00 TryStrToInt64 - 0001:00007E20 VerifyBoolStrArray - 0001:00007EB0 CompareWith - 0001:00007EEC TryStrToBool - 0001:00007F88 BoolToStr - 0001:00007FD4 FileOpen - 0001:00008030 FileCreate - 0001:00008054 FileCreate - 0001:0000805C FileRead - 0001:00008088 FileWrite - 0001:000080B4 FileSeek - 0001:000080EC FileClose - 0001:000080F4 FileAge - 0001:0000815C FileExists - 0001:0000816C AnsiLastChar - 0001:0000819C LastDelimiter - 0001:000081EC ExtractFilePath - 0001:00008220 ExtractFileName - 0001:00008258 ExtractFileExt - 0001:000082A0 BackfillGetDiskFreeSpaceEx - 0001:00008314 StrLen - 0001:0000832C StrEnd - 0001:00008340 StrMove - 0001:00008350 StrCopy - 0001:00008378 StrLCopy - 0001:000083AC StrPCopy - 0001:000083D0 StrPLCopy - 0001:000083F0 StrComp - 0001:00008414 StrIComp - 0001:00008454 StrLIComp - 0001:00008498 StrScan - 0001:000084B8 StrPos - 0001:0000850C StrPas - 0001:00008520 StrAlloc - 0001:00008534 StrBufSize - 0001:00008540 StrNew - 0001:0000856C StrDispose - 0001:0000857C FormatError - 0001:000085D4 FormatVarToStr - 0001:000085E8 FormatClearStr - 0001:000085F4 FormatBuf - 0001:00008A08 StrFmt - 0001:00008A48 StrLFmt - 0001:00008A88 Format - 0001:00008A9C FmtStr - 0001:00008B5C PutExponent - 0001:00008BA0 FloatToText - 0001:00008E78 FloatToDecimal - 0001:000090A4 TextToFloat - 0001:000091B8 FloatToStr - 0001:000091E8 CurrToStr - 0001:00009218 StrToFloat - 0001:00009254 TryStrToFloat - 0001:00009270 TryStrToFloat - 0001:0000929C TryStrToFloat - 0001:000092C8 TryStrToCurr - 0001:000092E4 DateTimeToTimeStamp - 0001:00009328 TryEncodeTime - 0001:00009398 EncodeTime - 0001:000093D8 DecodeTime - 0001:00009434 IsLeapYear - 0001:00009470 TryEncodeDate - 0001:00009538 EncodeDate - 0001:00009568 DecodeDateFully - 0001:000096B4 DecodeDate - 0001:000096D4 DayOfWeek - 0001:000096FC Now - 0001:0000974C CurrentYear - 0001:00009760 AppendChars - 0001:000097A4 AppendString - 0001:000097C4 AppendNumber - 0001:00009810 GetCount - 0001:0000983C GetDate - 0001:00009874 GetTime - 0001:000098B4 ConvertEraString - 0001:00009A1C ConvertYearString - 0001:00009B24 AppendFormat - 0001:0000A2B4 DateTimeToString - 0001:0000A310 DateToStr - 0001:0000A328 TimeToStr - 0001:0000A340 DateTimeToStr - 0001:0000A354 ScanBlanks - 0001:0000A378 ScanNumber - 0001:0000A40C ScanString - 0001:0000A498 ScanChar - 0001:0000A4D0 GetDateOrder - 0001:0000A51C ScanToNumber - 0001:0000A564 GetEraYearOffset - 0001:0000A5B8 EraToYear - 0001:0000A614 ScanDate - 0001:0000A950 ScanTime - 0001:0000AB48 StrToDate - 0001:0000AB7C TryStrToDate - 0001:0000ABB0 StrToTime - 0001:0000ABE4 TryStrToTime - 0001:0000AC18 StrToDateTime - 0001:0000AC4C TryStrToDateTime - 0001:0000ACD8 SysErrorMessage - 0001:0000AD24 GetLocaleStr - 0001:0000AD70 GetLocaleChar - 0001:0000AD98 LocalGetLocaleStr - 0001:0000ADD4 GetMonthDayNames - 0001:0000AEF8 EnumEraNames - 0001:0000AF34 EnumEraYearOffsets - 0001:0000AFAC GetEraNamesAndYearOffsets - 0001:0000B05C TranslateDateFormat - 0001:0000B284 ConvertAddr - 0001:0000B290 ExceptionErrorMessage - 0001:0000B418 ShowException - 0001:0000B4D0 ReturnAddr - 0001:0000B4D4 Abort - 0001:0000B530 Exception.Create - 0001:0000B56C Exception.CreateFmt - 0001:0000B5EC Exception.CreateRes - 0001:0000B628 Exception.CreateResFmt - 0001:0000B6BC Exception.CreateHelp - 0001:0000B704 EHeapException.FreeInstance - 0001:0000B730 CreateInOutError - 0001:0000B7B0 ErrorHandler - 0001:0000B804 CreateAssertException - 0001:0000B8B0 RaiseAssertException - 0001:0000B8C0 AssertErrorHandler - 0001:0000B8DC AbstractErrorHandler - 0001:0000B8F4 MapException - 0001:0000B974 GetExceptionClass - 0001:0000B98C CreateAVObject - 0001:0000BB58 GetExceptionObject - 0001:0000BC24 ExceptHandler - 0001:0000BC34 InitExceptions - 0001:0000BCB8 DoneExceptions - 0001:0000BD24 InitPlatformId - 0001:0000BD7C CheckWin32Version - 0001:0000BD9C ByteTypeTest - 0001:0000BE14 ByteType - 0001:0000BE38 StrByteType - 0001:0000BE50 ByteToCharLen - 0001:0000BE78 ByteToCharIndex - 0001:0000BED0 CountChars - 0001:0000BF60 CharToByteIndex - 0001:0000BFC4 CharToByteLen - 0001:0000C024 StrCharLength - 0001:0000C044 StrNextChar - 0001:0000C04C CharLength - 0001:0000C088 NextCharIndex - 0001:0000C0C4 AnsiPos - 0001:0000C0FC AnsiLowerCaseFileName - 0001:0000C188 AnsiStrPos - 0001:0000C228 AnsiStrRScan - 0001:0000C250 AnsiStrScan - 0001:0000C290 LCIDToCodePage - 0001:0000C304 InitLeadBytes - 0001:0000C364 IsWesternGroup - 0001:0000C37C InitSysLocale - 0001:0000C4F0 GetFormatSettings - 0001:0000C868 StringReplace - 0001:0000C99C Sleep - 0001:0000C9A4 RaiseLastOSError - 0001:0000CA40 Win32Check - 0001:0000CA50 CallTerminateProcs - 0001:0000CA6C FreeTerminateProcs - 0001:0000CA8C InitDriveSpacePtr - 0001:0000CAE8 InterlockedIncrement - 0001:0000CAF4 InterlockedDecrement - 0001:0000CB00 InterlockedExchange - 0001:0000CB08 InterlockedExchangeAdd - 0001:0000CB74 TThreadLocalCounter2.Destroy - 0001:0000CBC4 TThreadLocalCounter2.HashIndex - 0001:0000CBDC TThreadLocalCounter2.Open - 0001:0000CC54 TThreadLocalCounter2.Delete - 0001:0000CC64 TThreadLocalCounter2.Recycle - 0001:0000CCA4 TMultiReadExclusiveWriteSynchronizer.Create - 0001:0000CD18 TMultiReadExclusiveWriteSynchronizer.Destroy - 0001:0000CD60 TMultiReadExclusiveWriteSynchronizer.BlockReaders - 0001:0000CD6C TMultiReadExclusiveWriteSynchronizer.UnblockReaders - 0001:0000CD78 TMultiReadExclusiveWriteSynchronizer.UnblockOneWriter - 0001:0000CD84 TMultiReadExclusiveWriteSynchronizer.WaitForReadSignal - 0001:0000CD94 TMultiReadExclusiveWriteSynchronizer.WaitForWriteSignal - 0001:0000CDA4 TMultiReadExclusiveWriteSynchronizer.BeginWrite - 0001:0000CE40 TMultiReadExclusiveWriteSynchronizer.EndWrite - 0001:0000CE90 TMultiReadExclusiveWriteSynchronizer.BeginRead - 0001:0000CEEC TMultiReadExclusiveWriteSynchronizer.EndRead - 0001:0000CF54 FreeAndNil - 0001:0000CF64 Supports - 0001:0000CF88 Supports - 0001:0000D020 SafeLoadLibrary - 0001:0000D374 Finalization - 0001:0000D4F4 SysUtils - 0001:0000D574 VariantInit - 0001:0000D57C VariantClear - 0001:0000D584 VariantCopy - 0001:0000D58C VariantCopyInd - 0001:0000D594 VariantChangeType - 0001:0000D59C BackupVariantChangeTypeEx - 0001:0000D5CC UniUnimplemented - 0001:0000D5D8 BiUnimplemented - 0001:0000D5E4 CmpUnimplemented - 0001:0000D5F0 BackupVarI4FromStr - 0001:0000D65C BackupVarR4FromStr - 0001:0000D6C8 BackupVarR8FromStr - 0001:0000D734 BackupVarDateFromStr - 0001:0000D7A0 BackupVarCyFromStr - 0001:0000D80C BackupVarBoolFromStr - 0001:0000D88C BackupVarBStrFromCy - 0001:0000D8FC BackupVarBStrFromDate - 0001:0000D96C BackupVarBStrFromBool - 0001:0000D9E0 SafeArrayCreate - 0001:0000D9E8 SafeArrayRedim - 0001:0000D9F0 SafeArrayGetLBound - 0001:0000D9F8 SafeArrayGetUBound - 0001:0000DA00 SafeArrayGetElement - 0001:0000DA08 SafeArrayPutElement - 0001:0000DA10 SafeArrayPtrOfIndex - 0001:0000DA18 VariantChangeTypeEx - 0001:0000DA3C VarNeg - 0001:0000DA54 VarNot - 0001:0000DA6C VarI4FromStr - 0001:0000DA8C VarR8FromStr - 0001:0000DAAC VarDateFromStr - 0001:0000DACC VarCyFromStr - 0001:0000DAEC VarBoolFromStr - 0001:0000DB0C VarBstrFromCy - 0001:0000DB3C VarBstrFromDate - 0001:0000DB6C VarBstrFromBool - 0001:0000DB9C FindProc - 0001:0000DBC8 InitializeVarUtils - 0001:0000DED4 Finalization - 0001:0000DF04 VarUtils - 0001:0000E554 VarCastError - 0001:0000E5A8 VarCastError - 0001:0000E644 VarInvalidOp - 0001:0000E698 VarInvalidNullOp - 0001:0000E6EC VarOverflowError - 0001:0000E788 VarArrayCreateError - 0001:0000E7DC TranslateResult - 0001:0000EA04 VarResultCheck - 0001:0000EA10 VarResultCheck - 0001:0000EA44 HandleConversionException - 0001:0000EAC8 _DispInvokeError - 0001:0000EB1C _VarNull - 0001:0000EB30 InBounds - 0001:0000EB60 Increment - 0001:0000EBBC VarArrayClear - 0001:0000ED38 VarClearDeep - 0001:0000EDB4 _VarClear - 0001:0000EDC8 _DispInvoke - 0001:0000EECC InBounds - 0001:0000EEFC Increment - 0001:0000EF58 VarArrayCopyForEach - 0001:0000F124 VarCopyCopyProc - 0001:0000F12C VarCopyDeep - 0001:0000F1D8 _VarCopy - 0001:0000F21C VarCopyNoIndViaOS - 0001:0000F23C VarCopyNoIndOleStr - 0001:0000F244 VarCopyNoIndCopyProc - 0001:0000F24C VarCopyNoIndDeep - 0001:0000F280 VarCopyByRef - 0001:0000F458 _VarCopyNoInd - 0001:0000F46C _VarStringToOleStr - 0001:0000F48C VarStringToOleStr - 0001:0000F494 VarCastAsAny - 0001:0000F500 VarCastAsOleStr - 0001:0000F54C VarCastAsString - 0001:0000F598 VarCastAsDispatch - 0001:0000F5E4 VarCastAsInterface - 0001:0000F630 VarCastViaOS - 0001:0000F6A8 VarCastRare - 0001:0000F714 _VarCast - 0001:0000F940 _VarCastOle - 0001:0000F9AC VarToIntAsString - 0001:0000FA5C VarToIntViaOS - 0001:0000FA94 VarToIntAny - 0001:0000FAF8 VarToIntCustom - 0001:0000FB3C _VarToInteger - 0001:0000FF38 _VarToShortInt - 0001:0000FFE8 _VarToByte - 0001:00010090 _VarToSmallInt - 0001:00010188 _VarToWord - 0001:00010260 _VarToLongWord - 0001:00010348 VarToInt64ViaOS - 0001:000103EC VarToInt64AsString - 0001:000104E4 VarToInt64Any - 0001:00010550 VarToInt64Custom - 0001:0001059C _VarToInt64 - 0001:000109E0 VarToBoolAsString - 0001:00010AA4 VarToBoolViaOS - 0001:00010AE0 VarToBoolAny - 0001:00010B44 VarToBoolCustom - 0001:00010B90 _VarToBool - 0001:00010ED8 _VarToBoolWithFix - 0001:00010EE4 VarToDoubleAsString - 0001:00010FA4 VarToDoubleViaOS - 0001:00010FEC VarToDoubleAny - 0001:00011050 VarToDoubleCustom - 0001:0001109C _VarToDouble - 0001:00011418 _VarToExtended - 0001:00011434 _VarToSingle - 0001:000115C4 VarToDateAsString - 0001:000116AC VarToDateAsDouble - 0001:00011708 VarToDateViaOS - 0001:00011750 VarToDateAny - 0001:000117B4 VarToDateCustom - 0001:00011800 _VarToDate - 0001:00011B50 VarToCurrencyAsString - 0001:00011C08 VarToCurrencyAsDouble - 0001:00011C64 VarToCurrencyViaOS - 0001:00011CAC VarToCurrencyAny - 0001:00011D10 VarToCurrencyCustom - 0001:00011D5C _VarToCurrency - 0001:00012128 CurrToWStrViaOS - 0001:0001215C DateToWStrViaOS - 0001:00012190 BoolToWStrViaOS - 0001:00012250 VarToLStrViaOS - 0001:00012318 VarToLStrAny - 0001:0001237C VarToLStrCustom - 0001:00012400 _VarToLStr - 0001:00012944 _VarToPStr - 0001:00012994 VarToWStrViaOS - 0001:00012A48 VarToWStrAny - 0001:00012AAC VarToWStrCustom - 0001:00012B74 _VarToWStr - 0001:000130D4 AnyToIntf - 0001:0001314C _VarToIntf - 0001:00013218 _VarToDisp - 0001:000132C4 _VarToDynArray - 0001:000132D4 _VarFromInt - 0001:00013314 _VarFromInteger - 0001:00013334 _OleVarFromInt - 0001:00013354 _VarFromByte - 0001:00013374 _VarFromWord - 0001:00013394 _VarFromLongWord - 0001:000133B4 _VarFromShortInt - 0001:000133D4 _VarFromSmallInt - 0001:000133F4 _VarFromInt64 - 0001:00013420 _VarFromSingle - 0001:00013444 _VarFromDouble - 0001:00013470 _VarFromCurrency - 0001:0001349C _VarFromDate - 0001:000134C8 _VarFromBool - 0001:000134F0 _VarFromReal - 0001:00013504 _VarFromTDateTime - 0001:00013518 _VarFromCurr - 0001:0001352C _VarFromLStr - 0001:00013558 _VarFromPStr - 0001:000135A8 _VarFromWStr - 0001:000135E0 _VarFromIntf - 0001:0001360C _VarFromDisp - 0001:00013638 _VarFromDynArray - 0001:0001364C _OleVarFromLStr - 0001:0001369C _OleVarFromPStr - 0001:000136EC OleVarFromAny - 0001:00013750 OleVarFromVarArrayProc - 0001:00013758 _OleVarFromVar - 0001:000138A8 VarStrCat - 0001:0001395C VarOpRare - 0001:00013CA8 AnyOp - 0001:00013D34 CheckType - 0001:00013D7C RealOp - 0001:00013DF8 DateOp - 0001:00013E54 IntOp - 0001:00013F60 Int64Op - 0001:0001413C NullOp - 0001:000141E8 EmptyOp - 0001:00014280 SimpleVarOp - 0001:000146CC _VarOp - 0001:0001475C VarCompareAny - 0001:00014830 EmptyCompare - 0001:00014844 NullCompare - 0001:0001492C CheckType - 0001:00014950 IntCompare - 0001:00014964 Int64Compare - 0001:000149A0 RealCompare - 0001:000149C8 DateCompare - 0001:000149F0 CurrCompare - 0001:00014A1C StringCompare - 0001:00014A88 VarCompareSimple - 0001:00014C20 VarCompareRare - 0001:00015040 VarCompare - 0001:000150C0 _VarCmp - 0001:000150C8 NegateAsDouble - 0001:000150E0 NegateViaOS - 0001:000150F4 NegateVariant - 0001:00015120 NegateByte - 0001:00015134 NegateWord - 0001:00015144 NegateLongWord - 0001:00015178 NegateAny - 0001:0001518C NegateCustom - 0001:000151B8 _VarNeg - 0001:000154A8 NotAsString - 0001:00015578 NotAsOrdinal - 0001:000155E0 NotViaOS - 0001:000155F4 NotVariant - 0001:00015620 NotAny - 0001:00015634 NotCustom - 0001:00015660 _VarNot - 0001:000158E0 _VarAddRef - 0001:00015A64 VarTypeAsText - 0001:00015BD4 VarType - 0001:00015BD8 FindVarData - 0001:00015BE8 VarIsClear - 0001:00015C5C VarTypeIsCustom - 0001:00015C68 VarIsNull - 0001:00015C7C VarToStr - 0001:00015C94 VarToStrDef - 0001:00015CC0 VarSameValue - 0001:00015D38 SetVarAsError - 0001:00015D50 SetClearVarToEmptyParam - 0001:00015D5C _WriteVariant - 0001:00015DC0 _Write0Variant - 0001:00015DC8 GetVarDataArrayInfo - 0001:00015E0C VarArrayCreate - 0001:00015EB4 _VarArrayRedim - 0001:00015F0C GetVarArray - 0001:00015F34 VarArrayDimCount - 0001:00015F5C VarArrayLowBound - 0001:00015F80 VarArrayHighBound - 0001:00015FA4 VarIsArray - 0001:00015FAC VarIsArray - 0001:00015FD4 VarTypeIsValidArrayType - 0001:00015FF4 VarTypeIsValidElementType - 0001:00016030 _VarArrayGet - 0001:000160FC VarArrayGet - 0001:00016120 _VarArrayPut - 0001:00016268 VarArrayPut - 0001:00016290 DynArrayIndex - 0001:000162D0 DynArrayElTypeInfo - 0001:000162EC DynArrayDim - 0001:00016304 DynArraySize - 0001:0001630C IsDynArrayRectangular - 0001:00016374 DynArrayBounds - 0001:000163C8 DecIndices - 0001:00016434 DynArrayVariantBounds - 0001:0001648C DynArrayVarType - 0001:000164D4 DynArrayToVariant - 0001:000167F4 DynArrayFromVariant - 0001:00016AE8 ClearVariantTypeList - 0001:00016B58 TCustomVariantType.BinaryOp - 0001:00016B64 TCustomVariantType.Cast - 0001:00016B9C TCustomVariantType.CastTo - 0001:00016BE4 TCustomVariantType.Compare - 0001:00016BF0 TCustomVariantType.CompareOp - 0001:00016C28 TCustomVariantType.CastToOle - 0001:00016C64 TCustomVariantType.Destroy - 0001:00016CF0 TCustomVariantType.IsClear - 0001:00016CF4 TCustomVariantType.LeftPromotion - 0001:00016D08 TCustomVariantType.OlePromotion - 0001:00016D10 TCustomVariantType.RaiseCastError - 0001:00016D18 TCustomVariantType.RaiseInvalidOp - 0001:00016D20 TCustomVariantType.RaiseDispError - 0001:00016D28 TCustomVariantType.RightPromotion - 0001:00016D3C TCustomVariantType.UnaryOp - 0001:00016D44 TCustomVariantType.DispInvoke - 0001:00016D50 TCustomVariantType._AddRef - 0001:00016D5C TCustomVariantType._Release - 0001:00016D68 TCustomVariantType.QueryInterface - 0001:00016D90 FindCustomVariantType - 0001:00016E48 FindCustomVariantType - 0001:00016F30 Null - 0001:00016F38 Finalization - 0001:00016FBC Variants - 0001:00017300 Finalization - 0001:00017330 RTLConsts - 0001:00017364 GetTypeData - 0001:00017370 GetEnumName - 0001:00017464 GetEnumNameValue - 0001:000174B0 GetEnumValue - 0001:00017514 GetPropInfo - 0001:00017584 GetPropInfos - 0001:000175D8 IsStoredProp - 0001:00017608 GetOrdProp - 0001:0001767C SetOrdProp - 0001:000176D8 GetShortStrProp - 0001:0001771C SetShortStrProp - 0001:00017770 GetShortStrPropAsLongStr - 0001:00017798 SetShortStrPropAsLongStr - 0001:000177CC AssignLongStr - 0001:000177E0 GetLongStrProp - 0001:00017820 SetLongStrProp - 0001:00017860 GetWideStrPropAsLongStr - 0001:000178B8 SetWideStrPropAsLongStr - 0001:00017910 GetStrProp - 0001:00017950 SetStrProp - 0001:0001797C GetWideStrProp - 0001:00017A64 SetWideStrProp - 0001:00017B38 GetFloatProp - 0001:00017C50 SetFloatProp - 0001:00017E48 AssignVariant - 0001:00017E5C GetVariantProp - 0001:00017E9C SetVariantProp - 0001:00017EDC GetMethodProp - 0001:00017F1C SetMethodProp - 0001:00017F54 GetInt64Prop - 0001:00017F7C SetInt64Prop - 0001:00017FB8 GetInterfaceProp - 0001:00018038 SetInterfaceProp - 0001:000180AC Finalization - 0001:000180FC TypInfo - 0001:00018138 CoInitialize - 0001:00018140 CoUninitialize - 0001:00018148 SysFreeString - 0001:00018150 GetErrorInfo - 0001:00018158 Succeeded - 0001:00018164 Finalization - 0001:00018194 ActiveX - 0001:00019A30 Point - 0001:00019A48 SmallPoint - 0001:00019A58 Rect - 0001:00019A80 Bounds - 0001:00019AA8 InvalidPoint - 0001:00019ABC InvalidPoint - 0001:00019B88 TRegGroup.AddClass - 0001:00019B94 TRegGroup.BestClass - 0001:00019BF4 TRegGroup.BestGroup - 0001:00019C64 TRegGroup.Create - 0001:00019CE0 TRegGroup.Destroy - 0001:00019D20 TRegGroup.GetClass - 0001:00019D80 TRegGroup.InGroup - 0001:00019DC4 TRegGroup.RegisterClass - 0001:00019E6C TRegGroup.Registered - 0001:00019E84 PointerInModule - 0001:00019EA4 TRegGroup.UnregisterModuleClasses - 0001:00019F48 TRegGroups.Activate - 0001:00019F94 TRegGroups.Create - 0001:0001A008 TRegGroups.Destroy - 0001:0001A064 TRegGroups.FindGroup - 0001:0001A0A8 TRegGroups.GetClass - 0001:0001A0EC Error - 0001:0001A17C TRegGroups.GroupWith - 0001:0001A244 TRegGroups.Lock - 0001:0001A250 TRegGroups.RegisterClass - 0001:0001A268 TRegGroups.Registered - 0001:0001A2AC TRegGroups.StartGroup - 0001:0001A2FC TRegGroups.Unlock - 0001:0001A308 TRegGroups.UnregisterModuleClasses - 0001:0001A338 TClassFinder.Create - 0001:0001A464 TClassFinder.Destroy - 0001:0001A494 TClassFinder.GetClass - 0001:0001A51C GetFieldClassTable - 0001:0001A528 ClassNotFound - 0001:0001A594 GetClass - 0001:0001A5E8 FindClass - 0001:0001A608 RegisterClass - 0001:0001A678 UnRegisterModuleClasses - 0001:0001A6C4 StartClassGroup - 0001:0001A710 GroupDescendentsWith - 0001:0001A764 ActivateClassGroup - 0001:0001A818 TIntConst.Create - 0001:0001A850 RegisterIntegerConsts - 0001:0001A87C FindIntToIdent - 0001:0001A8F8 FindIdentToInt - 0001:0001A974 IdentToInt - 0001:0001A9B4 IntToIdent - 0001:0001A9F8 RegisterFindGlobalComponentProc - 0001:0001AA38 UnregisterFindGlobalComponentProc - 0001:0001AA50 FindGlobalComponent - 0001:0001AA90 IsUniqueGlobalComponentName - 0001:0001AAB4 InternalReadComponentRes - 0001:0001AB38 BeginGlobalLoading - 0001:0001AB90 NotifyGlobalLoading - 0001:0001ABC0 EndGlobalLoading - 0001:0001AC1C InitComponent - 0001:0001ACC4 InitInheritedComponent - 0001:0001AD88 WriteCollection - 0001:0001ADF4 CollectionsEqual - 0001:0001AF18 TList.Destroy - 0001:0001AF38 TList.Add - 0001:0001AF6C TList.Clear - 0001:0001AF84 TList.Delete - 0001:0001AFE4 ReturnAddr - 0001:0001AFE8 TList.Error - 0001:0001B020 TList.Error - 0001:0001B074 TList.Expand - 0001:0001B08C TList.First - 0001:0001B094 TList.Get - 0001:0001B0BC TList.Grow - 0001:0001B0F0 TList.IndexOf - 0001:0001B110 TList.Insert - 0001:0001B17C TList.Last - 0001:0001B188 TList.Move - 0001:0001B1E0 TList.Put - 0001:0001B234 TList.Remove - 0001:0001B254 TList.SetCapacity - 0001:0001B290 TList.SetCount - 0001:0001B300 TList.Notify - 0001:0001B304 TThreadList.Create - 0001:0001B358 TThreadList.Destroy - 0001:0001B3D4 TThreadList.Add - 0001:0001B45C TThreadList.LockList - 0001:0001B470 TThreadList.Remove - 0001:0001B4C0 TThreadList.UnlockList - 0001:0001B4CC TBits.Destroy - 0001:0001B4FC TBits.Error - 0001:0001B514 Min - 0001:0001B520 TBits.SetSize - 0001:0001B5C4 TBits.SetBit - 0001:0001B5F0 TBits.OpenBit - 0001:0001B668 TPersistent.Destroy - 0001:0001B694 TPersistent.Assign - 0001:0001B6A8 TPersistent.AssignError - 0001:0001B778 TPersistent.AssignTo - 0001:0001B780 TPersistent.DefineProperties - 0001:0001B784 TPersistent.GetNamePath - 0001:0001B834 TPersistent.GetOwner - 0001:0001B838 TInterfacedPersistent.AfterConstruction - 0001:0001B888 TInterfacedPersistent._AddRef - 0001:0001B8A8 TInterfacedPersistent._Release - 0001:0001B8C8 TInterfacedPersistent.QueryInterface - 0001:0001B8F0 GetDesigner - 0001:0001B988 NotifyDesigner - 0001:0001B9EC TCollectionItem.Create - 0001:0001BA24 TCollectionItem.Destroy - 0001:0001BA54 TCollectionItem.Changed - 0001:0001BA78 TCollectionItem.GetIndex - 0001:0001BA90 TCollectionItem.GetDisplayName - 0001:0001BAB8 TCollectionItem.GetNamePath - 0001:0001BB6C TCollectionItem.GetOwner - 0001:0001BB70 TCollectionItem.SetCollection - 0001:0001BB98 TCollectionItem.SetDisplayName - 0001:0001BBA0 TCollectionItem.SetIndex - 0001:0001BBD0 TCollection.Create - 0001:0001BC1C TCollection.Destroy - 0001:0001BC68 TCollection.Add - 0001:0001BC88 TCollection.Assign - 0001:0001BD20 TCollection.BeginUpdate - 0001:0001BD24 TCollection.Changed - 0001:0001BD34 TCollection.Clear - 0001:0001BD9C TCollection.EndUpdate - 0001:0001BDA8 TCollection.GetAttrCount - 0001:0001BDAC TCollection.GetAttr - 0001:0001BDB8 TCollection.GetItemAttr - 0001:0001BDD8 TCollection.GetCount - 0001:0001BDE0 TCollection.GetItem - 0001:0001BDF4 TCollection.GetNamePath - 0001:0001BEBC TCollection.GetPropName - 0001:0001BFD8 TCollection.Insert - 0001:0001BFF4 TCollection.InsertItem - 0001:0001C05C TCollection.RemoveItem - 0001:0001C0B0 TCollection.SetItemName - 0001:0001C0B4 TCollection.Update - 0001:0001C0B8 TCollection.Delete - 0001:0001C0E8 TCollection.Owner - 0001:0001C0F4 TCollection.Added - 0001:0001C0F8 TCollection.Deleting - 0001:0001C0FC TCollection.Notify - 0001:0001C120 TOwnedCollection.Create - 0001:0001C164 TOwnedCollection.GetOwner - 0001:0001C168 TStrings.Destroy - 0001:0001C198 TStrings.Add - 0001:0001C1BC TStrings.AddObject - 0001:0001C1E0 TStrings.AddStrings - 0001:0001C298 TStrings.Assign - 0001:0001C328 TStrings.BeginUpdate - 0001:0001C340 DoWrite - 0001:0001C398 TStrings.DefineProperties - 0001:0001C3E4 TStrings.EndUpdate - 0001:0001C3F8 TStrings.Equals - 0001:0001C4A0 ReturnAddr - 0001:0001C4A4 TStrings.Error - 0001:0001C4DC TStrings.Error - 0001:0001C534 TStrings.Exchange - 0001:0001C61C TStrings.GetCapacity - 0001:0001C624 TStrings.GetObject - 0001:0001C628 TStrings.GetText - 0001:0001C67C TStrings.GetTextStr - 0001:0001C7A4 TStrings.IndexOf - 0001:0001C830 TStrings.IndexOfName - 0001:0001C8F8 TStrings.IndexOfObject - 0001:0001C92C TStrings.InsertObject - 0001:0001C95C TStrings.LoadFromFile - 0001:0001C9B0 TStrings.LoadFromStream - 0001:0001CA5C TStrings.Move - 0001:0001CB0C TStrings.Put - 0001:0001CB3C TStrings.PutObject - 0001:0001CB40 TStrings.ReadData - 0001:0001CBF0 TStrings.SaveToFile - 0001:0001CC48 TStrings.SaveToStream - 0001:0001CCA4 TStrings.SetCapacity - 0001:0001CCA8 TStrings.SetStringsAdapter - 0001:0001CCDC TStrings.SetText - 0001:0001CD2C TStrings.SetTextStr - 0001:0001CDEC TStrings.SetUpdateState - 0001:0001CDF0 TStrings.WriteData - 0001:0001CE74 TStrings.CompareStrings - 0001:0001CE80 TStringList.Destroy - 0001:0001CEDC TStringList.Add - 0001:0001CEE8 TStringList.AddObject - 0001:0001CF4C TStringList.Changed - 0001:0001CF68 TStringList.Changing - 0001:0001CF84 TStringList.Clear - 0001:0001CFC4 TStringList.Delete - 0001:0001D030 TStringList.Exchange - 0001:0001D08C TStringList.ExchangeItems - 0001:0001D0B0 TStringList.Find - 0001:0001D128 TStringList.Get - 0001:0001D15C TStringList.GetCapacity - 0001:0001D160 TStringList.GetCount - 0001:0001D164 TStringList.GetObject - 0001:0001D18C TStringList.Grow - 0001:0001D1C0 TStringList.IndexOf - 0001:0001D1FC TStringList.Insert - 0001:0001D20C TStringList.InsertObject - 0001:0001D260 TStringList.InsertItem - 0001:0001D2D8 TStringList.Put - 0001:0001D334 TStringList.PutObject - 0001:0001D374 TStringList.QuickSort - 0001:0001D408 TStringList.SetCapacity - 0001:0001D424 TStringList.SetSorted - 0001:0001D444 TStringList.SetUpdateState - 0001:0001D45C StringListCompareStrings - 0001:0001D470 TStringList.Sort - 0001:0001D480 TStringList.CustomSort - 0001:0001D4B8 TStringList.CompareStrings - 0001:0001D4D4 TStream.GetPosition - 0001:0001D4F4 TStream.SetPosition - 0001:0001D508 TStream.GetSize - 0001:0001D554 TStream.SetSize - 0001:0001D558 TStream.SetSize64 - 0001:0001D56C TStream.SetSize - 0001:0001D5C0 RaiseException - 0001:0001D60C TStream.Seek - 0001:0001D690 TStream.Seek - 0001:0001D700 TStream.ReadBuffer - 0001:0001D738 TStream.WriteBuffer - 0001:0001D770 TStream.CopyFrom - 0001:0001D864 TStream.ReadComponent - 0001:0001D8C4 TStream.WriteComponent - 0001:0001D8D0 TStream.WriteDescendent - 0001:0001D92C THandleStream.Create - 0001:0001D968 THandleStream.Read - 0001:0001D978 THandleStream.Write - 0001:0001D988 THandleStream.Seek - 0001:0001D9B4 THandleStream.SetSize - 0001:0001D9C8 THandleStream.SetSize - 0001:0001D9F0 TFileStream.Create - 0001:0001DA34 TFileStream.Create - 0001:0001DAFC TFileStream.Destroy - 0001:0001DB30 TCustomMemoryStream.SetPointer - 0001:0001DB38 TCustomMemoryStream.Read - 0001:0001DB70 TCustomMemoryStream.Seek - 0001:0001DB94 TMemoryStream.Destroy - 0001:0001DBC0 TMemoryStream.Clear - 0001:0001DBD8 TMemoryStream.LoadFromStream - 0001:0001DC10 TMemoryStream.SetCapacity - 0001:0001DC38 TMemoryStream.SetSize - 0001:0001DC64 TMemoryStream.Realloc - 0001:0001DCF0 TMemoryStream.Write - 0001:0001DD40 TResourceStream.Create - 0001:0001DD98 Error - 0001:0001DE08 TResourceStream.Initialize - 0001:0001DE74 TResourceStream.Destroy - 0001:0001DEAC TResourceStream.Write - 0001:0001DEC4 TFiler.Create - 0001:0001DF0C TFiler.Destroy - 0001:0001DF34 TFiler.SetRoot - 0001:0001E010 TPropFixup.Create - 0001:0001E068 TPropFixup.MakeGlobalReference - 0001:0001E0B0 TPropFixup.ResolveReference - 0001:0001E0C0 TPropIntfFixup.ResolveReference - 0001:0001E144 FindNestedComponent - 0001:0001E20C AddFinished - 0001:0001E244 AddNotFinished - 0001:0001E28C GlobalFixupReferences - 0001:0001E434 RemoveFixupReferences - 0001:0001E4E0 RemoveFixups - 0001:0001E564 ReadError - 0001:0001E57C PropValueError - 0001:0001E588 PropertyNotFound - 0001:0001E5B4 TReader.Destroy - 0001:0001E5F0 TReader.CheckValue - 0001:0001E614 TReader.DefineProperty - 0001:0001E648 TReader.DefineBinaryProperty - 0001:0001E724 TReader.EndOfList - 0001:0001E738 TReader.Error - 0001:0001E758 TReader.FindMethod - 0001:0001E7C0 RemoveGlobalFixup - 0001:0001E83C TReader.DoFixupReferences - 0001:0001E95C TReader.FlushBuffer - 0001:0001E980 TReader.FreeFixups - 0001:0001E9BC TReader.GetFieldClass - 0001:0001EA50 TReader.GetPosition - 0001:0001EA68 TReader.NextValue - 0001:0001EA78 TReader.PropertyError - 0001:0001EA8C TReader.Read - 0001:0001EAD8 TReader.ReadBuffer - 0001:0001EB14 TReader.ReadBoolean - 0001:0001EB28 TReader.ReadChar - 0001:0001EB80 TReader.ReadCollection - 0001:0001EC2C ComponentCreated - 0001:0001EC4C Recover - 0001:0001ECAC CreateComponent - 0001:0001EDBC SetCompName - 0001:0001EE5C FindExistingComponent - 0001:0001EF00 TReader.ReadComponent - 0001:0001F0D8 TReader.ReadData - 0001:0001F148 TReader.ReadDataInner - 0001:0001F218 TReader.ReadFloat - 0001:0001F258 TReader.ReadSingle - 0001:0001F298 TReader.ReadCurrency - 0001:0001F2E4 TReader.ReadDate - 0001:0001F324 TReader.ReadIdent - 0001:0001F424 TReader.ReadInteger - 0001:0001F490 TReader.ReadInt64 - 0001:0001F4D4 TReader.ReadListBegin - 0001:0001F4DC TReader.ReadListEnd - 0001:0001F4E4 TReader.ReadPrefix - 0001:0001F524 HandleException - 0001:0001F624 PropPathError - 0001:0001F640 TReader.ReadProperty - 0001:0001F820 SetIntIdent - 0001:0001F868 SetObjectIdent - 0001:0001F8A8 SetVariantReference - 0001:0001F904 SetInterfaceReference - 0001:0001F9C4 TReader.ReadPropValue - 0001:0001FCCC FindUniqueName - 0001:0001FD2C TReader.ReadRootComponent - 0001:00020074 TReader.ReadSet - 0001:00020130 TReader.ReadSignature - 0001:00020154 TReader.ReadStr - 0001:00020190 TReader.ReadString - 0001:0002024C TReader.ReadWideString - 0001:00020330 TReader.ReadValue - 0001:00020344 TReader.SkipSetBody - 0001:0002038C SkipList - 0001:000203B4 SkipBinary - 0001:000203E4 SkipCollection - 0001:00020440 TReader.SkipValue - 0001:000205DC TReader.SkipProperty - 0001:00020624 TReader.SkipComponent - 0001:000206CC TReader.FindAncestorComponent - 0001:00020784 TReader.ReferenceName - 0001:0002079C TReader.SetName - 0001:000207C4 TReader.FindComponentClass - 0001:00020838 TReader.SkipBytes - 0001:00020880 ReadCustomVariant - 0001:00020A40 TReader.ReadVariant - 0001:00020C4C TWriter.Destroy - 0001:00020C78 TWriter.AddAncestor - 0001:00020C84 TWriter.DefineProperty - 0001:00020CAC TWriter.DefineBinaryProperty - 0001:00020CD8 TWriter.GetPosition - 0001:00020CE8 TWriter.FlushBuffer - 0001:00020CF0 TWriter.SetPosition - 0001:00020D2C TWriter.SetRoot - 0001:00020D44 TWriter.Write - 0001:00020D90 TWriter.WriteBinary - 0001:00020E18 TWriter.WriteBuffer - 0001:00020E30 TWriter.WriteBoolean - 0001:00020E44 TWriter.WriteChar - 0001:00020E94 TWriter.WriteCollection - 0001:00020F34 FindAncestor - 0001:00020F84 TWriter.WriteComponent - 0001:00021060 TWriter.WriteData - 0001:00021460 TWriter.WriteDescendent - 0001:00021488 TWriter.WriteFloat - 0001:000214AC TWriter.WriteSingle - 0001:000214D0 TWriter.WriteCurrency - 0001:000214F4 TWriter.WriteDate - 0001:00021518 TWriter.WriteIdent - 0001:000215DC TWriter.WriteInteger - 0001:00021650 TWriter.WriteInteger - 0001:000216A8 TWriter.WriteListBegin - 0001:000216B0 TWriter.WriteListEnd - 0001:000216B8 TWriter.WritePrefix - 0001:000216FC TWriter.WriteProperties - 0001:000217C4 AncestorValid - 0001:0002180C WritePropPath - 0001:00021860 WriteSet - 0001:000218F4 WriteIntProp - 0001:00021960 WriteCollectionProp - 0001:00021A04 IsDefaultValue - 0001:00021A60 WriteOrdProp - 0001:00021B34 IsDefaultValue - 0001:00021B8C WriteFloatProp - 0001:00021BD8 IsDefaultValue - 0001:00021C28 WriteInt64Prop - 0001:00021C70 IsDefault - 0001:00021CF8 WriteStrProp - 0001:00021D64 OwnedBy - 0001:00021D7C GetComponentValue - 0001:00021EA4 ObjectAncestorMatch - 0001:00021EEC IsDefault - 0001:00021F4C WriteObjectProp - 0001:0002217C IsDefaultValue - 0001:00022250 WriteInterfaceProp - 0001:00022370 IsDefaultValue - 0001:000223F4 WriteMethodProp - 0001:000224A8 IsDefaultValue - 0001:00022534 WriteVariantProp - 0001:000225A4 TWriter.WriteProperty - 0001:000226BC TWriter.WriteVariant - 0001:00022AB4 TWriter.WritePropName - 0001:00022B08 TWriter.WriteSignature - 0001:00022B18 TWriter.WriteStr - 0001:00022B60 TWriter.WriteMinStr - 0001:00022BF8 TWriter.WriteString - 0001:00022C4C TWriter.WriteWideString - 0001:00022D00 TWriter.WriteValue - 0001:00022D14 BinToHex - 0001:00022D50 HexToBin - 0001:00022DA8 AddThread - 0001:00022E10 RemoveThread - 0001:00022E54 CheckSynchronize - 0001:00022F80 ThreadProc - 0001:00023020 TThread.Create - 0001:000230F0 TThread.Destroy - 0001:00023158 TThread.AfterConstruction - 0001:00023164 TThread.CheckThreadError - 0001:000231E0 TThread.CheckThreadError - 0001:000231F8 TThread.CallOnTerminate - 0001:0002320C TThread.DoTerminate - 0001:00023220 TThread.SetPriority - 0001:0002324C TThread.Synchronize - 0001:00023388 TThread.Resume - 0001:000233B0 TThread.Terminate - 0001:000233B8 TThread.WaitFor - 0001:00023450 TComponent.Create - 0001:0002349C TComponent.Destroy - 0001:00023514 TComponent.BeforeDestruction - 0001:00023520 TComponent.FreeNotification - 0001:00023574 TComponent.ReadLeft - 0001:00023588 TComponent.ReadTop - 0001:0002359C TComponent.WriteLeft - 0001:000235A8 TComponent.WriteTop - 0001:000235B4 TComponent.Insert - 0001:000235E0 TComponent.Remove - 0001:00023608 TComponent.InsertComponent - 0001:00023660 TComponent.RemoveComponent - 0001:00023698 TComponent.DestroyComponents - 0001:000236F0 TComponent.Destroying - 0001:0002372C TComponent.RemoveNotification - 0001:00023750 TComponent.RemoveFreeNotification - 0001:0002376C TComponent.Notification - 0001:000237C8 TComponent.DefineProperties - 0001:00023850 TComponent.HasParent - 0001:00023854 TComponent.GetChildren - 0001:0002385C TComponent.GetChildOwner - 0001:00023860 TComponent.GetChildParent - 0001:00023864 TComponent.GetNamePath - 0001:00023878 TComponent.GetOwner - 0001:0002387C TComponent.SetChildOrder - 0001:00023880 TComponent.GetParentComponent - 0001:00023884 TComponent.SetParentComponent - 0001:00023888 TComponent.Updating - 0001:00023894 TComponent.Updated - 0001:000238A0 TComponent.Loaded - 0001:000238AC TComponent.PaletteCreated - 0001:000238B0 TComponent.ReadState - 0001:000238B8 TComponent.WriteState - 0001:000238C0 TComponent.ValidateRename - 0001:00023940 TComponent.ValidateContainer - 0001:00023954 TComponent.ValidateInsert - 0001:00023958 TComponent.FindComponent - 0001:000239A8 TComponent.SetName - 0001:00023A34 TComponent.ChangeName - 0001:00023A48 TComponent.GetComponent - 0001:00023A74 TComponent.GetComponentCount - 0001:00023A84 TComponent.SetComponentIndex - 0001:00023AD8 TComponent.SetDesigning - 0001:00023B28 TComponent.SetReference - 0001:00023B70 TComponent.ExecuteAction - 0001:00023B98 TComponent.UpdateAction - 0001:00023BC0 TComponent.SafeCallException - 0001:00023BD8 TComponent.UpdateRegistry - 0001:00023BE0 TComponent.QueryInterface - 0001:00023C20 TComponent._AddRef - 0001:00023C40 TComponent._Release - 0001:00023C60 TComponent.IntfGetComponent - 0001:00023C64 TBasicActionLink.Create - 0001:00023CA8 TBasicActionLink.AssignClient - 0001:00023CAC TBasicActionLink.Destroy - 0001:00023CE0 TBasicActionLink.Change - 0001:00023CF8 TBasicActionLink.Execute - 0001:00023D34 TBasicActionLink.SetAction - 0001:00023D60 TBasicActionLink.IsOnExecuteLinked - 0001:00023D64 TBasicActionLink.SetOnExecute - 0001:00023D6C TBasicActionLink.Update - 0001:00023D78 TBasicAction.Create - 0001:00023DBC TBasicAction.Destroy - 0001:00023E14 TBasicAction.HandlesTarget - 0001:00023E18 TBasicAction.ExecuteTarget - 0001:00023E1C TBasicAction.Notification - 0001:00023E44 TBasicAction.UpdateTarget - 0001:00023E48 TBasicAction.Execute - 0001:00023E64 TBasicAction.Update - 0001:00023E80 TBasicAction.SetOnExecute - 0001:00023EDC TBasicAction.Change - 0001:00023EF0 TBasicAction.RegisterChanges - 0001:00023EFC TBasicAction.UnRegisterChanges - 0001:00023F3C TStreamAdapter.Create - 0001:00023F84 TStreamAdapter.Destroy - 0001:00023FBC TStreamAdapter.Read - 0001:00024024 TStreamAdapter.Write - 0001:0002408C TStreamAdapter.Seek - 0001:00024110 TStreamAdapter.SetSize - 0001:00024174 TStreamAdapter.CopyTo - 0001:00024374 TStreamAdapter.Commit - 0001:00024380 TStreamAdapter.Revert - 0001:0002438C TStreamAdapter.LockRegion - 0001:00024398 TStreamAdapter.UnlockRegion - 0001:000243A4 TStreamAdapter.Stat - 0001:00024420 TStreamAdapter.Clone - 0001:00024438 FreeIntConstList - 0001:000244A4 ModuleUnload - 0001:000244AC StdWndProc - 0001:000244CC CalcJmpOffset - 0001:000244D4 MakeObjectInstance - 0001:0002456C FreeObjectInstance - 0001:00024590 AllocateHWnd - 0001:00024644 DeallocateHWnd - 0001:0002466C Finalization - 0001:00024714 Classes - 0001:00024A08 Finalization - 0001:00024A38 Consts - 0001:000256F0 InternalDeletePalette - 0001:00025764 GetHashCode - 0001:00025778 TResourceManager.Create - 0001:000257B4 TResourceManager.Destroy - 0001:000257D8 TResourceManager.Lock - 0001:000257E4 TResourceManager.Unlock - 0001:000257F0 TResourceManager.AllocResource - 0001:000258D4 TResourceManager.FreeResource - 0001:00025984 TResourceManager.ChangeResource - 0001:000259FC TResourceManager.AssignResource - 0001:00025A68 ClearColor - 0001:00025AD4 PaletteChanged - 0001:00025FC0 ColorToRGB - 0001:00025FD0 ColorToIdent - 0001:00025FE0 IdentToColor - 0001:00025FF0 TGraphicsObject.Changed - 0001:00026004 TGraphicsObject.Lock - 0001:00026014 TGraphicsObject.Unlock - 0001:000261D8 CharsetToIdent - 0001:000261E8 IdentToCharset - 0001:000261F8 GetFontData - 0001:000262AC TFont.Create - 0001:00026300 TFont.Destroy - 0001:00026328 TFont.Changed - 0001:00026344 TFont.Assign - 0001:00026418 TFont.GetData - 0001:00026430 TFont.SetData - 0001:00026480 TFont.SetColor - 0001:00026494 TFont.GetHandle - 0001:0002663C TFont.SetHandle - 0001:00026660 TFont.GetHeight - 0001:00026668 TFont.SetHeight - 0001:00026690 TFont.GetName - 0001:000266A8 TFont.SetName - 0001:00026704 TFont.GetSize - 0001:00026720 TFont.SetSize - 0001:00026740 TFont.GetStyle - 0001:0002674C TFont.SetStyle - 0001:00026778 TFont.GetPitch - 0001:00026780 TFont.SetPitch - 0001:000267A8 TFont.GetCharset - 0001:000267B0 TFont.SetCharset - 0001:000267D8 TPen.Create - 0001:0002681C TPen.Destroy - 0001:00026844 TPen.Assign - 0001:000268FC TPen.GetData - 0001:00026914 TPen.SetData - 0001:00026964 TPen.GetColor - 0001:0002696C TPen.SetColor - 0001:00026994 TPen.GetHandle - 0001:00026A2C TPen.SetMode - 0001:00026A40 TPen.GetStyle - 0001:00026A48 TPen.SetStyle - 0001:00026A70 TPen.GetWidth - 0001:00026A78 TPen.SetWidth - 0001:00026AA4 TBrush.Create - 0001:00026AE4 TBrush.Destroy - 0001:00026B0C TBrush.Assign - 0001:00026BB4 TBrush.GetData - 0001:00026BD0 TBrush.SetData - 0001:00026C20 TBrush.SetBitmap - 0001:00026C44 TBrush.GetColor - 0001:00026C4C TBrush.SetColor - 0001:00026C80 TBrush.GetHandle - 0001:00026D60 TBrush.GetStyle - 0001:00026D68 TBrush.SetStyle - 0001:00026D9C TCanvas.Create - 0001:00026E60 TCanvas.Destroy - 0001:00026EBC TCanvas.CopyRect - 0001:00026F44 TCanvas.Draw - 0001:00026FF0 TCanvas.FillRect - 0001:0002702C TCanvas.FrameRect - 0001:00027068 TCanvas.LineTo - 0001:000270A0 TCanvas.Lock - 0001:000270C8 TCanvas.MoveTo - 0001:000270F4 TCanvas.Polyline - 0001:0002712C TCanvas.Rectangle - 0001:00027174 TCanvas.Refresh - 0001:0002717C TCanvas.StretchDraw - 0001:000271B8 TCanvas.GetCanvasOrientation - 0001:000271E4 TCanvas.TextOut - 0001:00027270 TCanvas.TextExtent - 0001:000272B4 TCanvas.TextWidth - 0001:000272D0 TCanvas.TextHeight - 0001:000272F0 TCanvas.TryLock - 0001:0002734C TCanvas.Unlock - 0001:00027374 TCanvas.SetFont - 0001:00027384 TCanvas.SetPen - 0001:00027390 TCanvas.SetBrush - 0001:0002739C TCanvas.GetPenPos - 0001:000273C0 TCanvas.SetPenPos - 0001:000273E0 TCanvas.GetPixel - 0001:0002740C TCanvas.SetPixel - 0001:00027454 TCanvas.GetHandle - 0001:00027474 TCanvas.DeselectHandles - 0001:000274D0 TCanvas.CreateHandle - 0001:000274D4 TCanvas.SetHandle - 0001:00027528 TCanvas.RequiredState - 0001:0002759C TCanvas.Changing - 0001:000275B0 TCanvas.Changed - 0001:000275C4 TCanvas.CreateFont - 0001:000275F0 TCanvas.CreatePen - 0001:00027620 TCanvas.CreateBrush - 0001:0002769C TCanvas.FontChanged - 0001:000276BC TCanvas.PenChanged - 0001:000276DC TCanvas.BrushChanged - 0001:000276FC InvalidOperation - 0001:00027714 InvalidGraphic - 0001:0002772C InvalidBitmap - 0001:00027738 InvalidIcon - 0001:00027744 OutOfResources - 0001:00027798 GDIError - 0001:00027840 GDICheck - 0001:00027850 DupBits - 0001:000279B0 GetDInColors - 0001:000279D0 BytesPerScanline - 0001:000279E4 TransparentStretchBlt - 0001:00027C78 RGBTripleToQuad - 0001:00027CB0 RGBQuadToTriple - 0001:00027D28 ByteSwapColors - 0001:00027D80 CreateSystemPalette - 0001:00027E98 SystemPaletteOverride - 0001:00027F30 PaletteFromDIBColorTable - 0001:00027FD4 PaletteToDIBColorTable - 0001:00028028 TwoBitsFromDIB - 0001:000281E4 AdjustColor - 0001:000281F0 BetterSize - 0001:00028280 ReadIcon - 0001:00028588 InitializeBitmapInfoHeader - 0001:0002866C InternalGetDIBSizes - 0001:000286D0 GetDIBSizes - 0001:000286D8 InternalGetDIB - 0001:00028788 GetDIB - 0001:0002879C WinError - 0001:000287A0 CheckBool - 0001:000287AC WriteIcon - 0001:000289A8 TGraphic.Create - 0001:000289E0 TGraphic.Changed - 0001:000289F8 DoWrite - 0001:00028A50 TGraphic.DefineProperties - 0001:00028A9C TGraphic.Equals - 0001:00028BE8 TGraphic.GetPalette - 0001:00028BEC TGraphic.GetTransparent - 0001:00028BF0 TGraphic.LoadFromFile - 0001:00028C44 TGraphic.Progress - 0001:00028C6C TGraphic.ReadData - 0001:00028C78 TGraphic.SaveToFile - 0001:00028CD0 TGraphic.SetPalette - 0001:00028CD4 TGraphic.SetTransparent - 0001:00028CE4 TGraphic.WriteData - 0001:00028D8C FreeMemoryContexts - 0001:00028E38 DeselectBitmap - 0001:00028EB4 TBitmapCanvas.Create - 0001:00028EF0 TBitmapCanvas.Destroy - 0001:00028F1C TBitmapCanvas.FreeContext - 0001:00028FBC TBitmapCanvas.CreateHandle - 0001:000290A8 TSharedImage.Reference - 0001:000290AC TSharedImage.Release - 0001:000290CC TBitmapImage.Destroy - 0001:00029128 TBitmapImage.FreeHandle - 0001:00029174 UpdateDIBColorTable - 0001:00029230 FixupBitFields - 0001:0002927C CopyBitmap - 0001:000298E0 CopyPalette - 0001:00029944 CopyBitmapAsMask - 0001:00029B50 TBitmap.Create - 0001:00029BB8 TBitmap.Destroy - 0001:00029BF4 TBitmap.Assign - 0001:00029CE4 TBitmap.CopyImage - 0001:00029DA4 TBitmap.Changing - 0001:00029DC8 TBitmap.Changed - 0001:00029DD4 TBitmap.Dormant - 0001:00029E48 TBitmap.Draw - 0001:0002A098 TBitmap.FreeImage - 0001:0002A0FC TBitmap.GetEmpty - 0001:0002A118 TBitmap.GetCanvas - 0001:0002A160 TBitmap.GetHandle - 0001:0002A184 TBitmap.GetHandleType - 0001:0002A1B0 TBitmap.GetHeight - 0001:0002A1C0 TBitmap.GetMaskHandle - 0001:0002A1D4 TBitmap.GetMonochrome - 0001:0002A1F0 TBitmap.GetPalette - 0001:0002A204 TBitmap.GetTransparentColor - 0001:0002A24C TBitmap.GetWidth - 0001:0002A254 TBitmap.DIBNeeded - 0001:0002A2C8 TBitmap.FreeContext - 0001:0002A2D8 TBitmap.HandleNeeded - 0001:0002A378 TBitmap.MaskHandleNeeded - 0001:0002A3D8 TBitmap.PaletteNeeded - 0001:0002A490 TBitmap.LoadFromClipboardFormat - 0001:0002A514 TBitmap.LoadFromStream - 0001:0002A538 TBitmap.NewImage - 0001:0002A638 TBitmap.ReadData - 0001:0002A660 TBitmap.ReadDIB - 0001:0002ABC8 TBitmap.ReadStream - 0001:0002AC38 TBitmap.SetHandle - 0001:0002ACFC TBitmap.SetHandleType - 0001:0002AE34 TBitmap.SetHeight - 0001:0002AE88 TBitmap.SetMonochrome - 0001:0002AF08 TBitmap.SetPalette - 0001:0002AFDC TBitmap.SetWidth - 0001:0002B030 TBitmap.WriteData - 0001:0002B038 TBitmap.WriteStream - 0001:0002B2F0 TBitmap.SaveToStream - 0001:0002B2F8 TBitmap.SaveToClipboardFormat - 0001:0002B398 TIconImage.Destroy - 0001:0002B3C8 TIconImage.FreeHandle - 0001:0002B3E0 TIcon.Create - 0001:0002B434 TIcon.Destroy - 0001:0002B464 TIcon.Assign - 0001:0002B4C4 TIcon.Draw - 0001:0002B504 TIcon.GetEmpty - 0001:0002B51C TIcon.GetHandle - 0001:0002B530 TIcon.GetHeight - 0001:0002B544 TIcon.GetWidth - 0001:0002B558 TIcon.HandleNeeded - 0001:0002B5D0 TIcon.ImageNeeded - 0001:0002B684 TIcon.LoadFromStream - 0001:0002B73C TIcon.NewImage - 0001:0002B7B0 TIcon.SetHandle - 0001:0002B7C8 TIcon.SetHeight - 0001:0002B7E0 TIcon.SetTransparent - 0001:0002B7E4 TIcon.SetWidth - 0001:0002B7FC TIcon.SaveToStream - 0001:0002B828 TIcon.LoadFromClipboardFormat - 0001:0002B83C TIcon.SaveToClipboardFormat - 0001:0002B850 InitScreenLogPixels - 0001:0002B888 GetDefFontCharSet - 0001:0002B8CC InitDefFontData - 0001:0002B998 TPatternManager.Create - 0001:0002B9D0 TPatternManager.Destroy - 0001:0002B9FC TPatternManager.Lock - 0001:0002BA08 TPatternManager.Unlock - 0001:0002BA14 TPatternManager.AllocPattern - 0001:0002BAC8 TPatternManager.CreateBitmap - 0001:0002BBC8 TPatternManager.FreePatterns - 0001:0002BC40 AllocPatternBitmap - 0001:0002BC78 Finalization - 0001:0002BD4C Graphics - 0001:0002BE48 Min - 0001:0002BE50 Max - 0001:0002BE58 Finalization - 0001:0002BE88 Math - 0001:0002BFC0 TObjectList.Create - 0001:0002BFFC TObjectList.GetItem - 0001:0002C010 TObjectList.Insert - 0001:0002C018 TObjectList.Notify - 0001:0002C044 TOrderedList.Pop - 0001:0002C04C TOrderedList.Push - 0001:0002C05C TOrderedList.Create - 0001:0002C0A0 TOrderedList.Destroy - 0001:0002C0D0 TOrderedList.PeekItem - 0001:0002C0E4 TOrderedList.PopItem - 0001:0002C104 TStack.PushItem - 0001:0002C110 Finalization - 0001:0002C140 Contnrs - 0001:0002C148 InitCommonControls - 0001:0002C150 InitComCtl - 0001:0002C1B0 InitCommonControlsEx - 0001:0002C1E4 ImageList_Create - 0001:0002C1EC ImageList_Destroy - 0001:0002C1F4 ImageList_GetImageCount - 0001:0002C1FC ImageList_Add - 0001:0002C204 ImageList_ReplaceIcon - 0001:0002C20C ImageList_SetBkColor - 0001:0002C214 ImageList_GetBkColor - 0001:0002C21C ImageList_AddIcon - 0001:0002C228 IndexToOverlayMask - 0001:0002C22C ImageList_Draw - 0001:0002C234 ImageList_DrawEx - 0001:0002C23C ImageList_Remove - 0001:0002C244 ImageList_GetIcon - 0001:0002C24C ImageList_BeginDrag - 0001:0002C254 ImageList_EndDrag - 0001:0002C25C ImageList_DragEnter - 0001:0002C264 ImageList_DragLeave - 0001:0002C26C ImageList_DragMove - 0001:0002C274 ImageList_SetDragCursorImage - 0001:0002C27C ImageList_DragShowNolock - 0001:0002C284 ImageList_GetDragImage - 0001:0002C28C ImageList_Read - 0001:0002C294 ImageList_Write - 0001:0002C29C ImageList_GetIconSize - 0001:0002C2A4 ImageList_SetIconSize - 0001:0002C2AC ListView_SetBkColor - 0001:0002C2C4 ListView_SetImageList - 0001:0002C2E0 ListView_GetItemCount - 0001:0002C2F0 IndexToStateImageMask - 0001:0002C2F4 ListView_GetItem - 0001:0002C30C ListView_SetItem - 0001:0002C324 ListView_InsertItem - 0001:0002C33C ListView_DeleteItem - 0001:0002C354 ListView_DeleteAllItems - 0001:0002C368 ListView_GetNextItem - 0001:0002C38C ListView_FindItem - 0001:0002C39C ListView_GetItemRect - 0001:0002C3D8 ListView_HitTest - 0001:0002C3E8 ListView_RedrawItems - 0001:0002C404 ListView_Arrange - 0001:0002C41C ListView_GetEditControl - 0001:0002C430 ListView_SetColumn - 0001:0002C44C ListView_InsertColumn - 0001:0002C45C ListView_DeleteColumn - 0001:0002C474 ListView_GetColumnWidth - 0001:0002C48C ListView_SetColumnWidth - 0001:0002C4B0 ListView_CreateDragImage - 0001:0002C4CC ListView_SetTextColor - 0001:0002C4E4 ListView_SetTextBkColor - 0001:0002C4FC ListView_GetTopIndex - 0001:0002C50C ListView_GetOrigin - 0001:0002C524 ListView_Update - 0001:0002C544 ListView_SetItemState - 0001:0002C574 ListView_GetItemState - 0001:0002C584 ListView_GetCheckState - 0001:0002C5A4 ListView_SetCheckState - 0001:0002C5D0 ListView_SetItemText - 0001:0002C600 ListView_SetItemCount - 0001:0002C610 ListView_SetItemCountEx - 0001:0002C620 ListView_SortItems - 0001:0002C63C ListView_GetSelectedCount - 0001:0002C64C ListView_SetExtendedListViewStyle - 0001:0002C664 ListView_SetColumnOrderArray - 0001:0002C680 ListView_GetColumnOrderArray - 0001:0002C69C ListView_SetWorkAreas - 0001:0002C6B8 Finalization - 0001:0002C6E8 CommCtrl - 0001:0002C6F0 InitAnApi - 0001:0002C7D8 _GetSystemMetrics - 0001:0002C860 xMonitorFromRect - 0001:0002C8F0 xMonitorFromWindow - 0001:0002C988 xMonitorFromPoint - 0001:0002CA20 xGetMonitorInfo - 0001:0002CAF4 xGetMonitorInfoA - 0001:0002CBC8 xGetMonitorInfoW - 0001:0002CC9C xEnumDisplayMonitors - 0001:0002CDCC InitMultiMonStubs - 0001:0002CE38 Finalization - 0001:0002CE68 MultiMon - 0001:0002CE78 Finalization - 0001:0002CEA8 Imm - 0001:0002D274 RegisterViewer - 0001:0002D30C GetHelpSystem - 0001:0002D370 THelpViewerNode.Create - 0001:0002D3EC THelpManager.Create - 0001:0002D460 THelpManager.RegisterViewer - 0001:0002D598 THelpManager.UnloadAllViewers - 0001:0002D5E0 THelpManager.DoSoftShutDown - 0001:0002D610 THelpManager.DoTableOfContents - 0001:0002D7B0 THelpManager.CallSpecialWinHelp - 0001:0002D8B8 THelpManager.ShowHelp - 0001:0002DACC THelpManager.ShowContextHelp - 0001:0002DBE0 THelpManager.ShowTableOfContents - 0001:0002DBE8 THelpManager.ShowTopicHelp - 0001:0002DCE4 THelpManager.AssignHelpSelector - 0001:0002DD48 THelpManager.Hook - 0001:0002DE04 THelpManager.GetHandle - 0001:0002DE08 THelpManager.GetHelpFile - 0001:0002DE1C THelpManager.Release - 0001:0002DEAC THelpManager.Destroy - 0001:0002DF00 Finalization - 0001:0002DF40 HelpIntfs - 0001:0002DF48 ClosePrinter - 0001:0002DF50 DocumentProperties - 0001:0002DF58 EnumPrinters - 0001:0002DF60 OpenPrinter - 0001:0002DF68 Finalization - 0001:0002DF98 WinSpool - 0001:0002E060 FetchStr - 0001:0002E094 RaiseError - 0001:0002E0AC AbortProc - 0001:0002E150 TPrinterDevice.Create - 0001:0002E1B0 TPrinterDevice.IsEqual - 0001:0002E324 TPrinterCanvas.Create - 0001:0002E360 TPrinterCanvas.CreateHandle - 0001:0002E384 TPrinterCanvas.Changing - 0001:0002E3A4 TPrinterCanvas.UpdateFont - 0001:0002E3EC TPrinter.Create - 0001:0002E428 TPrinter.Destroy - 0001:0002E4A4 TPrinter.SetState - 0001:0002E5D0 TPrinter.CheckPrinting - 0001:0002E640 TPrinter.BeginDoc - 0001:0002E6C8 TPrinter.EndDoc - 0001:0002E6FC TPrinter.NewPage - 0001:0002E72C TPrinter.SetPrinterCapabilities - 0001:0002E768 TPrinter.SetPrinter - 0001:0002E9B0 TPrinter.GetCanvas - 0001:0002E9D0 TPrinter.GetHandle - 0001:0002E9E4 TPrinter.GetPageHeight - 0001:0002EA00 TPrinter.GetPageWidth - 0001:0002EA1C TPrinter.GetPrinterIndex - 0001:0002EA34 TPrinter.GetPrinters - 0001:0002EC74 TPrinter.SetToDefaultPrinter - 0001:0002EE74 TPrinter.FreePrinters - 0001:0002EEB0 TPrinter.FreeFonts - 0001:0002EEBC Printer - 0001:0002EEDC Finalization - 0001:0002EF18 Printers - 0001:0002EF20 FlatSB_SetScrollProp - 0001:0002EF54 InitializeFlatSB - 0001:0002EF7C InitFlatSB - 0001:0002F200 Finalization - 0001:0002F230 FlatSB - 0001:000331D8 HasPopup - 0001:00033400 TCustomGroupBox.Create - 0001:0003345C TCustomGroupBox.AdjustClientRect - 0001:000334B8 TCustomGroupBox.CreateParams - 0001:000334C8 TCustomGroupBox.Paint - 0001:000336D4 TCustomGroupBox.CMDialogChar - 0001:00033754 TCustomGroupBox.CMTextChanged - 0001:00033768 TCustomGroupBox.CMCtl3DChanged - 0001:00033784 TCustomGroupBox.WMSize - 0001:00033798 TCustomEdit.Create - 0001:00033840 TCustomEdit.DoSetMaxLength - 0001:00033860 TCustomEdit.SetAutoSize - 0001:00033874 TCustomEdit.SetBorderStyle - 0001:00033898 TCustomEdit.SetCharCase - 0001:000338AC TCustomEdit.SetHideSelection - 0001:000338C0 TCustomEdit.SetMaxLength - 0001:000338F0 TCustomEdit.SetOEMConvert - 0001:00033904 TCustomEdit.GetModified - 0001:0003393C TCustomEdit.SetModified - 0001:00033974 TCustomEdit.SetPasswordChar - 0001:000339FC TCustomEdit.SetReadOnly - 0001:00033A38 TCustomEdit.GetSelStart - 0001:00033A5C TCustomEdit.SetSelStart - 0001:00033A7C TCustomEdit.GetSelLength - 0001:00033AAC TCustomEdit.SetSelLength - 0001:00033B10 TCustomEdit.Clear - 0001:00033B2C TCustomEdit.SelectAll - 0001:00033B48 TCustomEdit.GetSelTextBuf - 0001:00033BE4 TCustomEdit.GetSelText - 0001:00033C80 TCustomEdit.CreateParams - 0001:00033D3C TCustomEdit.CreateWindowHandle - 0001:00033DAC TCustomEdit.CreateWnd - 0001:00033E50 TCustomEdit.DestroyWnd - 0001:00033E6C TCustomEdit.UpdateHeight - 0001:00033EA8 TCustomEdit.AdjustHeight - 0001:00033F50 TCustomEdit.Change - 0001:00033F74 TCustomEdit.DefaultHandler - 0001:00033FAC TCustomEdit.WMSetFont - 0001:00033FEC TCustomEdit.CMCtl3DChanged - 0001:00034020 TCustomEdit.CMFontChanged - 0001:00034048 TCustomEdit.CNCommand - 0001:00034068 TCustomEdit.CMEnter - 0001:000340A4 TCustomEdit.CMTextChanged - 0001:000340DC TCustomEdit.WMContextMenu - 0001:000340F8 TMemoStrings.GetCount - 0001:00034168 TMemoStrings.Get - 0001:000341AC TMemoStrings.Put - 0001:00034220 TMemoStrings.Insert - 0001:0003432C TMemoStrings.Delete - 0001:000343BC TMemoStrings.Clear - 0001:000343CC TMemoStrings.SetUpdateState - 0001:0003441C TMemoStrings.GetTextStr - 0001:00034430 TMemoStrings.SetTextStr - 0001:00034508 TCustomMemo.Create - 0001:0003458C TCustomMemo.Destroy - 0001:000345BC TCustomMemo.CreateParams - 0001:00034620 TCustomMemo.CreateWindowHandle - 0001:000346F4 TCustomMemo.GetCaretPos - 0001:00034750 TCustomMemo.SetCaretPos - 0001:0003478C TCustomMemo.GetControlsAlignment - 0001:00034794 TCustomMemo.Loaded - 0001:000347AC TCustomMemo.SetAlignment - 0001:000347C0 TCustomMemo.SetScrollBars - 0001:000347D4 TCustomMemo.SetWordWrap - 0001:000347E8 TCustomMemo.WMGetDlgCode - 0001:0003481C TCustomMemo.WMNCDestroy - 0001:00034824 TCustomMemo.KeyPress - 0001:00034848 TCustomComboBoxStrings.GetCount - 0001:00034864 TCustomComboBoxStrings.GetObject - 0001:000348DC TCustomComboBoxStrings.PutObject - 0001:00034900 TCustomComboBoxStrings.Get - 0001:00034944 TCustomComboBoxStrings.Clear - 0001:000349B4 TCustomComboBoxStrings.Delete - 0001:000349D4 TCustomComboBoxStrings.IndexOf - 0001:000349FC TCustomComboBoxStrings.SetUpdateState - 0001:00034A30 TComboBoxStrings.Add - 0001:00034AB4 TComboBoxStrings.Insert - 0001:00034B34 TCustomCombo.Create - 0001:00034C28 TCustomCombo.Destroy - 0001:00034C84 TCustomCombo.Clear - 0001:00034CB0 TCustomCombo.DestroyWindowHandle - 0001:00034CD4 TCustomCombo.SelectAll - 0001:00034CF4 TCustomCombo.GetDroppedDown - 0001:00034D18 TCustomCombo.SetDroppedDown - 0001:00034D60 TCustomCombo.GetItemIndex - 0001:00034D8C TCustomCombo.SetItemIndex - 0001:00034DC8 TCustomCombo.SetMaxLength - 0001:00034E08 TCustomCombo.SetItemHeight - 0001:00034E18 TCustomCombo.WMCreate - 0001:00034E3C TCustomCombo.WMDrawItem - 0001:00034E50 TCustomCombo.WMMeasureItem - 0001:00034E64 TCustomCombo.WMDeleteItem - 0001:00034E78 TCustomCombo.WMGetDlgCode - 0001:00034E9C TCustomCombo.CMCancelMode - 0001:00034EB0 TCustomCombo.CMCtl3DChanged - 0001:00034ED4 TCustomComboBox.CMParentColorChanged - 0001:00034EFC TCustomCombo.EditWndProc - 0001:00034FF4 TCustomCombo.ListWndProc - 0001:00035014 TCustomComboBox.SetCharCase - 0001:00035028 TCustomCombo.ComboWndProc - 0001:00035304 TCustomCombo.WndProc - 0001:00035414 TCustomCombo.CNCommand - 0001:00035580 TCustomCombo.Change - 0001:000355A4 TCustomComboBox.DrawItem - 0001:00035660 TCustomCombo.DropDown - 0001:00035680 TCustomCombo.Loaded - 0001:000356A8 TCustomCombo.Focused - 0001:000356DC TCustomCombo.CloseUp - 0001:000356FC TCustomCombo.Select - 0001:00035728 TCustomCombo.CreateWnd - 0001:00035760 TCustomCombo.AdjustDropDown - 0001:0003581C TCustomCombo.SetItems - 0001:00035840 TCustomCombo.ClearSelection - 0001:0003584C TCustomCombo.CopySelection - 0001:000358D8 TCustomCombo.DeleteSelected - 0001:00035904 TCustomCombo.GetCount - 0001:00035910 TCustomCombo.SetDropDownCount - 0001:00035918 TCustomCombo.AddItem - 0001:00035970 TCustomComboBox.Create - 0001:000359E8 TCustomComboBox.Destroy - 0001:00035A24 TCustomComboBox.SetSorted - 0001:00035A38 TCustomComboBox.SetStyle - 0001:00035A78 TCustomComboBox.GetItemHt - 0001:00035A9C TCustomComboBox.CreateParams - 0001:00035B00 TCustomComboBox.CreateWnd - 0001:00035C40 TCustomComboBox.DestroyWnd - 0001:00035C90 TCustomComboBox.WMEraseBkgnd - 0001:00035CE4 HasSelectedText - 0001:00035D10 DeleteSelectedText - 0001:00035DD8 TCustomComboBox.KeyPress - 0001:000361A0 TCustomComboBox.SelectItem - 0001:00036334 TCustomComboBox.MeasureItem - 0001:00036354 TCustomComboBox.CNDrawItem - 0001:0003642C TCustomComboBox.CNMeasureItem - 0001:00036458 TCustomComboBox.WMLButtonDown - 0001:000364D0 TCustomComboBox.WndProc - 0001:00036518 TCustomComboBox.GetItemCount - 0001:00036524 TCustomComboBox.GetItemsClass - 0001:0003652C TCustomComboBox.WMPaint - 0001:00036764 TCustomComboBox.WMNCCalcSize - 0001:00036768 TButtonActionLink.AssignClient - 0001:0003678C TButtonActionLink.IsCheckedLinked - 0001:000367C4 TButtonActionLink.SetChecked - 0001:00036828 TButtonControl.Create - 0001:0003687C TButtonControl.ActionChange - 0001:000368C4 TButtonControl.GetActionLinkClass - 0001:000368CC TButtonControl.GetChecked - 0001:000368D0 TButtonControl.IsCheckedStored - 0001:000368F0 TButtonControl.SetChecked - 0001:000368F4 TButtonControl.WndProc - 0001:0003696C TButton.Create - 0001:000369D0 TButton.Click - 0001:000369F4 TButton.UseRightToLeftAlignment - 0001:000369F8 TButton.SetButtonStyle - 0001:00036A4C TButton.SetDefault - 0001:00036A80 TButton.CreateParams - 0001:00036ABC TButton.CreateWnd - 0001:00036AD4 TButton.CNCommand - 0001:00036AE8 TButton.CMDialogKey - 0001:00036B58 TButton.CMDialogChar - 0001:00036BDC TButton.CMFocusChanged - 0001:00036C30 TButton.WMEraseBkgnd - 0001:00036C44 TCustomCheckBox.Create - 0001:00036CB0 TCustomCheckBox.GetControlsAlignment - 0001:00036CDC TCustomCheckBox.Toggle - 0001:00036D1C TCustomCheckBox.Click - 0001:00036D30 TCustomCheckBox.GetChecked - 0001:00036D3C TCustomCheckBox.SetAlignment - 0001:00036D50 TCustomCheckBox.SetChecked - 0001:00036D64 TCustomCheckBox.SetState - 0001:00036DB8 TCustomCheckBox.CreateParams - 0001:00036E14 TCustomCheckBox.CreateWnd - 0001:00036E40 TCustomCheckBox.WMSize - 0001:00036E54 TCustomCheckBox.CMCtl3DChanged - 0001:00036E5C TCustomCheckBox.CMDialogChar - 0001:00036EF8 TCustomCheckBox.CNCommand - 0001:00036F08 TCustomStaticText.Create - 0001:00036F78 TCustomStaticText.CreateParams - 0001:00036FF8 TCustomStaticText.CMDialogChar - 0001:00037094 TCustomStaticText.CMFontChanged - 0001:000370A8 TCustomStaticText.CMTextChanged - 0001:000370C4 TCustomStaticText.Loaded - 0001:000370D8 TCustomStaticText.AdjustBounds - 0001:000371C0 TCustomStaticText.Notification - 0001:000371F0 TCustomStaticText.SetAlignment - 0001:00037204 TCustomStaticText.SetAutoSize - 0001:0003721C TCustomStaticText.SetBorderStyle - 0001:00037230 TCustomStaticText.SetFocusControl - 0001:00037244 TCustomStaticText.SetShowAccelChar - 0001:00037258 Finalization - 0001:00037288 StdCtrls - 0001:00037290 Shell_NotifyIcon - 0001:00037298 Finalization - 0001:000372C8 ShellAPI - 0001:000372D0 Finalization - 0001:00037300 RegStr - 0001:00037308 Finalization - 0001:00037338 WinInet - 0001:00037340 Finalization - 0001:00037370 UrlMon - 0001:00037378 Finalization - 0001:000373A8 ShlObj - 0001:000373B0 Finalization - 0001:000373E0 CommDlg - 0001:00037F60 DoRect - 0001:00038024 Frame3D - 0001:00038084 TTimer.Create - 0001:000380D4 TTimer.Destroy - 0001:0003810C TTimer.WndProc - 0001:00038180 TTimer.UpdateTimer - 0001:0003820C TTimer.SetEnabled - 0001:0003821C TTimer.SetInterval - 0001:0003822C TTimer.SetOnTimer - 0001:00038244 TTimer.Timer - 0001:00038258 TCustomPanel.Create - 0001:000382F0 TCustomPanel.CreateParams - 0001:00038344 TCustomPanel.CMBorderChanged - 0001:00038358 TCustomPanel.CMTextChanged - 0001:00038360 TCustomPanel.CMCtl3DChanged - 0001:0003838C TCustomPanel.CMIsToolControl - 0001:000383A0 TCustomPanel.WMWindowPosChanged - 0001:000384A0 AdjustColors - 0001:000384D8 TCustomPanel.Paint - 0001:0003863C TCustomPanel.SetAlignment - 0001:00038648 TCustomPanel.SetBevelInner - 0001:00038664 TCustomPanel.SetBevelOuter - 0001:00038680 TCustomPanel.SetBevelWidth - 0001:0003869C TCustomPanel.SetBorderWidth - 0001:000386B8 TCustomPanel.SetBorderStyle - 0001:000386CC TCustomPanel.GetControlsAlignment - 0001:000386D4 TCustomPanel.AdjustClientRect - 0001:0003872C TCustomPanel.CMDockClient - 0001:00038868 TCustomPanel.CanAutoSize - 0001:00038894 Finalization - 0001:000388C4 ExtCtrls - 0001:000388E8 Finalization - 0001:00038918 Dlgs - 0001:00038A8C TCommonDialog.Create - 0001:00038AD4 TCommonDialog.Destroy - 0001:00038B08 TCommonDialog.MessageHook - 0001:00038B30 TCommonDialog.DefaultHandler - 0001:00038B68 TCommonDialog.MainWndProc - 0001:00038BB4 TCommonDialog.WndProc - 0001:00038BBC TCommonDialog.WMDestroy - 0001:00038BD4 TCommonDialog.WMInitDialog - 0001:00038BEC TCommonDialog.WMNCDestroy - 0001:00038C00 TCommonDialog.TaskModalDialog - 0001:00038CD4 TCommonDialog.DoClose - 0001:00038CE8 TCommonDialog.DoShow - 0001:00038DA0 InitGlobals - 0001:00038EF4 Finalization - 0001:00038F50 Dialogs - 0001:00038F7C Finalization - 0001:00038FB8 Clipbrd - 0001:00039010 AnsiContainsText - 0001:00039080 AnsiReplaceText - 0001:000390AC LeftStr - 0001:000390C8 RightStr - 0001:000390EC Finalization - 0001:0003911C StrUtils - 0001:00039218 THintAction.Create - 0001:00039254 Finalization - 0001:00039284 StdActns - 0001:00039430 TWinHelpViewer.Create - 0001:00039468 TWinHelpViewer.HelpFile - 0001:000394F8 TWinHelpViewer.InternalShutDown - 0001:00039524 TWinHelpViewer.GetViewerName - 0001:00039538 TWinHelpViewer.UnderstandsKeyword - 0001:000395B0 TWinHelpViewer.GetHelpStrings - 0001:00039654 TWinHelpViewer.CanShowTableOfContents - 0001:00039658 TWinHelpViewer.ShowTableOfContents - 0001:000396E0 TWinHelpViewer.ShowHelp - 0001:0003980C TWinHelpViewer.NotifyID - 0001:00039810 TWinHelpViewer.SoftShutDown - 0001:0003982C TWinHelpViewer.ShutDown - 0001:0003985C TWinHelpViewer.UnderstandsTopic - 0001:000398C4 TWinHelpViewer.DisplayTopic - 0001:000399D8 TWinHelpViewer.UnderstandsContext - 0001:00039A4C TWinHelpViewer.DisplayHelpByContext - 0001:00039ADC TWinHelpViewer.CallWinHelp - 0001:00039BEC WindowEnumerationTester - 0001:00039C48 DialogEnumerationTester - 0001:00039CA0 FindWinHelp - 0001:00039CBC TWinHelpViewer.IsNewQuery - 0001:00039D48 TWinHelpViewer.IsBusyWindow - 0001:00039D4C TWinHelpViewer.CouldBeUnstableWindow - 0001:00039D6C TWinHelpViewer.MakeWinHelpHappy - 0001:00039DC4 TWinHelpViewer.RestartWinHelp - 0001:00039E50 TWinHelpViewer.Destroy - 0001:00039E78 Finalization - 0001:00039EE4 WinHelpViewer - 0001:0003C360 InitWndProc - 0001:0003C418 ObjectFromHWnd - 0001:0003C448 FindControl - 0001:0003C484 SendAppMessage - 0001:0003C648 CursorToIdent - 0001:0003C658 IdentToCursor - 0001:0003C668 GetShortHint - 0001:0003C6AC GetLongHint - 0001:0003C6F0 GetCaptureControl - 0001:0003C718 SetCaptureControl - 0001:0003C7C4 TSiteList.Find - 0001:0003C7F8 GetTopParent - 0001:0003C820 TSiteList.AddSite - 0001:0003C87C TSiteList.Clear - 0001:0003C8B0 TSiteList.GetTopSite - 0001:0003C914 TDragObject.Assign - 0001:0003C954 TDragObject.Capture - 0001:0003C96C TDragObject.Finished - 0001:0003C974 TDragObject.GetName - 0001:0003C99C TDragObject.ReleaseCapture - 0001:0003C9B0 TDragObject.WndProc - 0001:0003CAAC TDragObject.GetDragImages - 0001:0003CAB0 TDragObject.GetDragCursor - 0001:0003CAC8 TDragObject.HideDragImage - 0001:0003CACC TDragObject.Instance - 0001:0003CAD4 TDragObject.ShowDragImage - 0001:0003CAD8 TDragObject.MainWndProc - 0001:0003CB24 TDragObject.BeforeDestruction - 0001:0003CB34 TDragObject.AfterConstruction - 0001:0003CB44 TDragObjectEx.BeforeDestruction - 0001:0003CB48 TBaseDragControlObject.Create - 0001:0003CB6C TBaseDragControlObject.Assign - 0001:0003CB98 TBaseDragControlObject.EndDrag - 0001:0003CBC4 TBaseDragControlObject.Finished - 0001:0003CBF8 TDragControlObject.GetDragCursor - 0001:0003CC10 TDragControlObject.GetDragImages - 0001:0003CC1C TDragControlObject.HideDragImage - 0001:0003CC3C TDragControlObject.ShowDragImage - 0001:0003CC5C TDragControlObjectEx.BeforeDestruction - 0001:0003CC60 TDragDockObject.Create - 0001:0003CCC4 TDragDockObject.Destroy - 0001:0003CCF4 TDragDockObject.Assign - 0001:0003CD50 TDragDockObject.EndDrag - 0001:0003CD74 AbsMin - 0001:0003CD98 TDragDockObject.AdjustDockRect - 0001:0003CE14 TDragDockObject.DrawDragDockImage - 0001:0003CE28 TDragDockObject.EraseDragDockImage - 0001:0003CE3C TDragDockObject.GetDragCursor - 0001:0003CE48 TDragDockObject.GetFrameWidth - 0001:0003CE50 TDragDockObjectEx.BeforeDestruction - 0001:0003CE54 IsBeforeTargetWindow - 0001:0003CEC0 ValidDockTarget - 0001:0003D058 IsSiteChildOfClient - 0001:0003D09C GetDockSiteAtPos - 0001:0003D1F8 RegisterDockSite - 0001:0003D258 DragMessage - 0001:0003D2B0 IsDelphiHandle - 0001:0003D2F8 DragFindWindow - 0001:0003D324 DragFindTarget - 0001:0003D374 DoDragOver - 0001:0003D3B0 GetDropCtl - 0001:0003D444 DragTo - 0001:0003D714 DragInit - 0001:0003D884 DragInitControl - 0001:0003DA48 CheckUndock - 0001:0003DABC DragDone - 0001:0003DD94 CancelDrag - 0001:0003DDAC FindVCLWindow - 0001:0003DDE0 FindDragTarget - 0001:0003DE28 ListAdd - 0001:0003DE50 ListRemove - 0001:0003DE70 MoveWindowOrg - 0001:0003DEA0 FreeDeviceContext - 0001:0003DF5C FreeDeviceContexts - 0001:0003E008 TControlCanvas.Destroy - 0001:0003E034 TControlCanvas.CreateHandle - 0001:0003E0DC TControlCanvas.FreeHandle - 0001:0003E110 TControlCanvas.SetControl - 0001:0003E128 TControlCanvas.UpdateTextFlags - 0001:0003E154 TSizeConstraints.Create - 0001:0003E190 TSizeConstraints.AssignTo - 0001:0003E1D8 TSizeConstraints.SetConstraints - 0001:0003E264 TSizeConstraints.Change - 0001:0003E278 TControlActionLink.AssignClient - 0001:0003E294 TControlActionLink.DoShowHint - 0001:0003E384 TControlActionLink.IsCaptionLinked - 0001:0003E3F8 TControlActionLink.IsEnabledLinked - 0001:0003E42C TControlActionLink.IsHintLinked - 0001:0003E464 TControlActionLink.IsVisibleLinked - 0001:0003E498 TControlActionLink.IsOnExecuteLinked - 0001:0003E4C0 TControlActionLink.SetCaption - 0001:0003E4E0 TControlActionLink.SetEnabled - 0001:0003E500 TControlActionLink.SetHint - 0001:0003E524 TControlActionLink.SetVisible - 0001:0003E544 TControlActionLink.SetOnExecute - 0001:0003E570 TControlActionLink.IsHelpLinked - 0001:0003E5D4 TControlActionLink.SetHelpKeyword - 0001:0003E5F4 TControlActionLink.SetHelpContext - 0001:0003E614 TControlActionLink.SetHelpType - 0001:0003E634 TControl.Create - 0001:0003E70C TControl.Destroy - 0001:0003E7C0 TControl.GetDragImages - 0001:0003E7C4 TControl.GetEnabled - 0001:0003E7C8 TControl.GetPalette - 0001:0003E7CC TControl.HasParent - 0001:0003E7D4 TControl.GetParentComponent - 0001:0003E7D8 TControl.SetParentComponent - 0001:0003E800 TControl.PaletteChanged - 0001:0003E878 TControl.GetAction - 0001:0003E888 TControl.SetAnchors - 0001:0003E8A8 TControl.SetAction - 0001:0003E924 TControl.IsAnchorsStored - 0001:0003E93C TControl.SetDragMode - 0001:0003E940 TControl.RequestAlign - 0001:0003E950 TControl.Resize - 0001:0003E970 TControl.ReadState - 0001:0003EA04 TControl.Notification - 0001:0003EA48 TControl.SetAlign - 0001:0003EAF0 TControl.SetBounds - 0001:0003EB88 TControl.UpdateAnchorRules - 0001:0003ECA4 TControl.SetLeft - 0001:0003ECC8 TControl.SetTop - 0001:0003ECF0 TControl.SetWidth - 0001:0003ED14 TControl.SetHeight - 0001:0003ED38 TControl.Dock - 0001:0003EE44 TControl.DoDock - 0001:0003EE9C TControl.SetHelpContext - 0001:0003EEB0 TControl.SetHelpKeyword - 0001:0003EED4 TControl.GetBoundsRect - 0001:0003EEF4 TControl.SetBoundsRect - 0001:0003EF20 TControl.GetClientRect - 0001:0003EF38 TControl.GetClientWidth - 0001:0003EF50 TControl.SetClientWidth - 0001:0003EF7C TControl.GetClientHeight - 0001:0003EF94 TControl.SetClientHeight - 0001:0003EFBC TControl.GetClientOrigin - 0001:0003F04C TControl.ClientToScreen - 0001:0003F078 TControl.ScreenToClient - 0001:0003F0A4 TControl.SendCancelMode - 0001:0003F0D4 TControl.SendDockNotification - 0001:0003F140 TControl.Changed - 0001:0003F150 TControl.ChangeScale - 0001:0003F304 TControl.SetAutoSize - 0001:0003F31C TControl.SetName - 0001:0003F3C0 TControl.SetClientSize - 0001:0003F408 TControl.SetParent - 0001:0003F454 TControl.SetVisible - 0001:0003F490 TControl.SetEnabled - 0001:0003F4A8 TControl.GetTextLen - 0001:0003F4B8 TControl.GetTextBuf - 0001:0003F4C4 TControl.GetUndockHeight - 0001:0003F4D8 TControl.GetUndockWidth - 0001:0003F4EC TControl.SetPopupMenu - 0001:0003F510 TControl.SetTextBuf - 0001:0003F534 TControl.GetText - 0001:0003F564 TControl.SetText - 0001:0003F5C8 TControl.SetBiDiMode - 0001:0003F5E4 TControl.FontChanged - 0001:0003F628 TControl.SetFont - 0001:0003F638 TControl.IsFontStored - 0001:0003F64C TControl.IsShowHintStored - 0001:0003F658 TControl.IsBiDiModeStored - 0001:0003F660 TControl.SetParentFont - 0001:0003F684 TControl.SetShowHint - 0001:0003F6A8 TControl.SetParentShowHint - 0001:0003F6D4 TControl.SetColor - 0001:0003F6F0 TControl.IsColorStored - 0001:0003F6F8 TControl.SetParentColor - 0001:0003F71C TControl.SetParentBiDiMode - 0001:0003F740 TControl.SetCursor - 0001:0003F75C TControl.GetMouseCapture - 0001:0003F76C TControl.SetMouseCapture - 0001:0003F794 TControl.BringToFront - 0001:0003F7A4 TControl.SetZOrderPosition - 0001:0003F824 TControl.SetZOrder - 0001:0003F848 TControl.GetDeviceContext - 0001:0003F8F0 BackgroundClipped - 0001:0003F97C TControl.InvalidateControl - 0001:0003FA08 TControl.Invalidate - 0001:0003FA18 TControl.MouseWheelHandler - 0001:0003FA5C TControl.Hide - 0001:0003FA64 TControl.Show - 0001:0003FA94 TControl.Update - 0001:0003FAA8 TControl.Refresh - 0001:0003FAB4 TControl.Repaint - 0001:0003FBAC TControl.GetControlsAlignment - 0001:0003FBB0 TControl.UseRightToLeftReading - 0001:0003FBC8 TControl.UseRightToLeftAlignment - 0001:0003FBE0 TControl.UseRightToLeftScrollBar - 0001:0003FBFC TControl.BeginAutoDrag - 0001:0003FC14 TControl.BeginDrag - 0001:0003FCD8 TControl.DragCanceled - 0001:0003FCDC TControl.Dragging - 0001:0003FCE8 TControl.DragOver - 0001:0003FD24 TControl.DragDrop - 0001:0003FD50 TControl.DoStartDrag - 0001:0003FD70 TControl.DoEndDrag - 0001:0003FD9C TControl.PositionDockRect - 0001:0003FE6C TControl.DockTrackNoTarget - 0001:0003FE80 TControl.DoEndDock - 0001:0003FEAC TControl.DoStartDock - 0001:0003FECC TControl.DoMouseWheel - 0001:0003FF90 TControl.DoMouseWheelDown - 0001:0003FFDC TControl.DoMouseWheelUp - 0001:00040028 TControl.DefaultDockImage - 0001:00040154 TControl.DrawDragDockImage - 0001:00040168 TControl.EraseDragDockImage - 0001:0004017C TControl.DoDragMsg - 0001:0004026C TControl.ManualDock - 0001:0004044C TControl.ManualFloat - 0001:000404E0 TControl.DoConstraintsChange - 0001:000404EC TControl.CanAutoSize - 0001:000404F0 TControl.CanResize - 0001:00040520 TControl.DoCanAutoSize - 0001:0004058C TControl.DoCanResize - 0001:000405BC TControl.ConstrainedResize - 0001:000405EC TControl.CalcCursorPos - 0001:00040618 TControl.DesignWndProc - 0001:0004064C TControl.DoConstrainedResize - 0001:00040720 TControl.Perform - 0001:00040754 TControl.CalcDockSizes - 0001:000407C4 TControl.UpdateBoundsRect - 0001:000407E8 TControl.VisibleChanging - 0001:000407EC TControl.WndProc - 0001:00040980 TControl.DefaultHandler - 0001:00040A08 TControl.ReadIsControl - 0001:00040A1C TControl.WriteIsControl - 0001:00040A28 DoWriteIsControl - 0001:00040A58 TControl.DefineProperties - 0001:00040AA8 TControl.Click - 0001:00040B14 TControl.DblClick - 0001:00040B34 TControl.MouseDown - 0001:00040B6C TControl.DoMouseDown - 0001:00040BF0 TControl.WMLButtonDown - 0001:00040C3C TControl.WMNCLButtonDown - 0001:00040C58 TControl.WMLButtonDblClk - 0001:00040CAC TControl.GetPopupMenu - 0001:00040CB0 TControl.CheckNewSize - 0001:00040D4C TControl.WMRButtonDown - 0001:00040D74 TControl.WMRButtonDblClk - 0001:00040D9C TControl.WMMButtonDown - 0001:00040DC4 TControl.WMMButtonDblClk - 0001:00040DEC TControl.MouseMove - 0001:00040E1C TControl.WMMouseMove - 0001:00040E94 TControl.MouseUp - 0001:00040ECC TControl.DoMouseUp - 0001:00040F04 TControl.WMLButtonUp - 0001:00040F7C TControl.WMRButtonUp - 0001:00040F9C TControl.WMMButtonUp - 0001:00040FBC TControl.WMMouseWheel - 0001:00041014 TControl.WMCancelMode - 0001:00041054 TControl.WMWindowPosChanged - 0001:00041104 TControl.CMVisibleChanged - 0001:0004112C TControl.CMEnabledChanged - 0001:00041134 TControl.CMFontChanged - 0001:0004113C TControl.CMColorChanged - 0001:00041144 TControl.CMParentColorChanged - 0001:00041174 TControl.CMParentBiDiModeChanged - 0001:00041198 TControl.CMMouseWheel - 0001:000411F4 TControl.CMBiDiModeChanged - 0001:00041214 TControl.CMParentShowHintChanged - 0001:0004123C TControl.CMParentFontChanged - 0001:0004126C TControl.CMSysFontChanged - 0001:00041290 TControl.CMHitTest - 0001:00041298 TControl.CMMouseEnter - 0001:000412B0 TControl.CMMouseLeave - 0001:000412C8 TControl.CMDesignHitTest - 0001:000412D0 TControl.CreateFloatingDockSite - 0001:00041354 UpdateFloatingDockSitePos - 0001:000413E0 TControl.CMFloat - 0001:00041440 TControl.ActionChange - 0001:0004153C TControl.DoActionChange - 0001:00041560 TControl.GetActionLinkClass - 0001:00041568 TControl.IsCaptionStored - 0001:00041588 TControl.IsEnabledStored - 0001:000415A8 TControl.IsHintStored - 0001:000415C8 TControl.IsHelpContextStored - 0001:000415E8 TControl.IsVisibleStored - 0001:00041608 TControl.IsOnClickStored - 0001:00041628 TControl.Loaded - 0001:00041660 TControl.AssignTo - 0001:0004170C MinVar - 0001:00041748 TControl.GetDockEdge - 0001:000417F8 TControl.GetFloating - 0001:00041824 TControl.GetFloatingDockSiteClass - 0001:0004182C TControl.AdjustSize - 0001:0004184C TControl.DrawTextBiDiModeFlags - 0001:0004188C TControl.DrawTextBiDiModeFlagsReadingOnly - 0001:000418A8 TControl.InitiateAction - 0001:000418B8 TControl.CMHintShow - 0001:000418E4 TControl.WMContextMenu - 0001:00041A0C TControl.DoContextPopup - 0001:00041A40 TControl.SetConstraints - 0001:00041A4C TWinControlActionLink.AssignClient - 0001:00041A70 TWinControlActionLink.IsHelpContextLinked - 0001:00041A78 TWinControlActionLink.SetHelpContext - 0001:00041A80 TWinControl.Create - 0001:00041BA4 TWinControl.Destroy - 0001:00041C74 TWinControl.FixupTabList - 0001:00041D48 TWinControl.ReadState - 0001:00041DC0 TWinControl.AdjustClientRect - 0001:00041DC4 InsertBefore - 0001:00041E50 DoPosition - 0001:00042290 DoAlign - 0001:00042400 AlignWork - 0001:00042454 TWinControl.AlignControls - 0001:00042558 TWinControl.AlignControl - 0001:000425EC TWinControl.DisableAlign - 0001:000425F4 TWinControl.EnableAlign - 0001:00042614 TWinControl.Realign - 0001:0004261C TWinControl.DoFlipChildren - 0001:000426F0 TWinControl.FlipChildren - 0001:00042830 TWinControl.ContainsControl - 0001:00042844 TWinControl.RemoveFocus - 0001:00042864 TWinControl.Insert - 0001:000428B0 TWinControl.Remove - 0001:000428F8 TWinControl.InsertControl - 0001:000429CC TWinControl.RemoveControl - 0001:00042A48 TWinControl.GetControl - 0001:00042A84 TWinControl.GetControlCount - 0001:00042AA4 TWinControl.Broadcast - 0001:00042AE4 TWinControl.NotifyControls - 0001:00042B0C TWinControl.CreateSubClass - 0001:00042B78 TWinControl.AddBiDiModeExStyle - 0001:00042BE0 TWinControl.CreateParams - 0001:00042D0C TWinControl.CreateWnd - 0001:00042EA4 TWinControl.CreateWindowHandle - 0001:00042EE8 TWinControl.ReadDesignSize - 0001:00042F20 TWinControl.WriteDesignSize - 0001:00042F74 PointsEqual - 0001:00042F88 DoWriteDesignSize - 0001:00043060 TWinControl.DefineProperties - 0001:000430BC TWinControl.DestroyWnd - 0001:00043114 TWinControl.DestroyWindowHandle - 0001:00043178 TWinControl.PrecedingWindow - 0001:000431C0 TWinControl.CreateHandle - 0001:00043258 TWinControl.CustomAlignInsertBefore - 0001:0004325C TWinControl.CustomAlignPosition - 0001:00043278 TWinControl.DestroyHandle - 0001:000432C0 TWinControl.RecreateWnd - 0001:000432D8 TWinControl.CMRecreateWnd - 0001:00043318 TWinControl.UpdateShowing - 0001:00043414 TWinControl.UpdateControlState - 0001:00043454 TWinControl.MainWndProc - 0001:000434CC GetControlAtPos - 0001:00043584 TWinControl.ControlAtPos - 0001:00043618 TWinControl.IsControlMouseMsg - 0001:000436AC TWinControl.WndProc - 0001:00043810 TWinControl.DefaultHandler - 0001:00043918 DoControlMsg - 0001:0004394C TWinControl.PaintHandler - 0001:00043A7C TWinControl.PaintWindow - 0001:00043AA8 TWinControl.PaintControls - 0001:00043CD8 TWinControl.PaintTo - 0001:00043E2C TWinControl.WMPaint - 0001:00043F8C TWinControl.WMCommand - 0001:00043FAC TWinControl.WMNotify - 0001:00043FD0 TWinControl.WMSysColorChange - 0001:00043FEC TWinControl.WMWinIniChange - 0001:00044000 TWinControl.WMFontChange - 0001:00044010 TWinControl.WMTimeChange - 0001:00044020 TWinControl.WMHScroll - 0001:00044040 TWinControl.WMVScroll - 0001:00044060 TWinControl.WMCompareItem - 0001:00044084 TWinControl.WMDeleteItem - 0001:000440A8 TWinControl.WMDrawItem - 0001:000440CC TWinControl.WMMeasureItem - 0001:000440F0 TWinControl.WMEraseBkgnd - 0001:0004413C TWinControl.WMWindowPosChanged - 0001:000441FC TWinControl.WMWindowPosChanging - 0001:0004424C TWinControl.WMSize - 0001:00044280 TWinControl.WMMove - 0001:00044294 TWinControl.WMSetCursor - 0001:00044394 TWinControl.WMSetFocus - 0001:000443A8 TWinControl.WMKillFocus - 0001:000443BC TWinControl.WMIMEStartComp - 0001:000443D0 TWinControl.WMIMEEndComp - 0001:000443E4 TWinControl.SetIme - 0001:000444D0 TWinControl.ResetIme - 0001:00044568 TWinControl.DoAddDockClient - 0001:00044578 TWinControl.DoRemoveDockClient - 0001:0004457C TWinControl.DoEnter - 0001:0004459C TWinControl.DoExit - 0001:000445BC TWinControl.DockDrop - 0001:0004460C TWinControl.DoDockOver - 0001:00044640 TWinControl.DockOver - 0001:00044680 TWinControl.DoUnDock - 0001:000446D8 TWinControl.ReloadDockedControl - 0001:000446FC TWinControl.GetDockClientCount - 0001:00044710 TWinControl.GetDockClients - 0001:00044734 TWinControl.GetSiteInfo - 0001:00044790 TWinControl.GetVisibleDockClientCount - 0001:000447CC TWinControl.ControlsAligned - 0001:000447D0 TWinControl.CreateDockManager - 0001:0004483C TWinControl.SetDockSite - 0001:000448F4 TWinControl.CMDockClient - 0001:000449E0 TWinControl.CMUnDockClient - 0001:00044A08 TWinControl.CMFloat - 0001:00044A8C TWinControl.KeyDown - 0001:00044AB4 TWinControl.DoKeyDown - 0001:00044B1C TWinControl.WMKeyDown - 0001:00044B3C TWinControl.WMSysKeyDown - 0001:00044B5C TWinControl.KeyUp - 0001:00044B84 TWinControl.DoKeyUp - 0001:00044BEC TWinControl.WMKeyUp - 0001:00044C0C TWinControl.WMSysKeyUp - 0001:00044C2C TWinControl.KeyPress - 0001:00044C4C TWinControl.DoKeyPress - 0001:00044CB0 TWinControl.WMChar - 0001:00044CD0 TraverseControls - 0001:00044D80 TWinControl.WMSysCommand - 0001:00044E28 TWinControl.WMCharToItem - 0001:00044E48 TWinControl.WMParentNotify - 0001:00044E7C TWinControl.WMVKeyToItem - 0001:00044E9C TWinControl.WMDestroy - 0001:00044ED0 TWinControl.WMNCDestroy - 0001:00044EEC TWinControl.WMNCHitTest - 0001:00044F10 TWinControl.PaletteChanged - 0001:00044F68 TWinControl.WMQueryNewPalette - 0001:00044F8C TWinControl.WMPaletteChanged - 0001:00044FAC TWinControl.CMShowHintChanged - 0001:00044FC4 TWinControl.CMBiDiModeChanged - 0001:00044FFC TWinControl.CMEnter - 0001:00045070 TWinControl.CMExit - 0001:0004507C TWinControl.CMDesignHitTest - 0001:0004509C TWinControl.CMChanged - 0001:000450B0 TWinControl.CMChildKey - 0001:000450C4 TWinControl.CMDialogKey - 0001:000450CC TWinControl.CMDialogChar - 0001:000450D4 TWinControl.CMFocusChanged - 0001:000450DC TWinControl.CMVisibleChanged - 0001:0004510C TWinControl.CMShowingChanged - 0001:00045134 TWinControl.CMEnabledChanged - 0001:0004517C TWinControl.CMColorChanged - 0001:000451A4 TWinControl.CMFontChanged - 0001:000451E0 TWinControl.CMCursorChanged - 0001:00045220 TWinControl.CMBorderChanged - 0001:00045260 TWinControl.CMCtl3DChanged - 0001:000452A0 TWinControl.CMParentCtl3DChanged - 0001:000452E0 TWinControl.CMSysColorChange - 0001:000452E8 TWinControl.CMWinIniChange - 0001:000452F0 TWinControl.CMFontChange - 0001:000452F8 TWinControl.CMTimeChange - 0001:00045300 TWinControl.CMDrag - 0001:0004535C TWinControl.CMControlListChange - 0001:00045370 TWinControl.CMSysFontChanged - 0001:0004538C TWinControl.IsMenuKey - 0001:00045420 TWinControl.CNKeyDown - 0001:000454F8 TWinControl.CNKeyUp - 0001:0004554C TWinControl.CNChar - 0001:00045598 TWinControl.CNSysKeyDown - 0001:000455F4 TWinControl.CNSysChar - 0001:00045628 TWinControl.SetBounds - 0001:00045700 TWinControl.ScaleControls - 0001:00045748 TWinControl.ChangeScale - 0001:000457F4 TWinControl.ScrollBy - 0001:000458CC TWinControl.ShowControl - 0001:000458E4 TWinControl.SetZOrderPosition - 0001:000459BC TWinControl.SetZOrder - 0001:00045A1C TWinControl.GetDeviceContext - 0001:00045A70 TWinControl.Invalidate - 0001:00045A80 TWinControl.CMInvalidate - 0001:00045AD0 TWinControl.Update - 0001:00045AEC TWinControl.Repaint - 0001:00045B04 TWinControl.InvalidateFrame - 0001:00045B3C TWinControl.CanFocus - 0001:00045B7C TWinControl.SetFocus - 0001:00045BB4 TWinControl.Focused - 0001:00045BD8 TWinControl.HandleNeeded - 0001:00045BFC TWinControl.GetHandle - 0001:00045C10 TWinControl.GetControlExtents - 0001:00045CA4 TWinControl.GetClientOrigin - 0001:00045CC4 TWinControl.GetClientRect - 0001:00045CDC TWinControl.AdjustSize - 0001:00045D1C TWinControl.SetBorderWidth - 0001:00045D3C TWinControl.SetCtl3D - 0001:00045D60 TWinControl.IsCtl3DStored - 0001:00045D6C TWinControl.SetParentCtl3D - 0001:00045D98 TWinControl.GetTabOrder - 0001:00045DBC TWinControl.UpdateTabOrder - 0001:00045E18 TWinControl.SetTabOrder - 0001:00045E30 TWinControl.SetTabStop - 0001:00045E90 TWinControl.SetUseDockManager - 0001:00045F00 TWinControl.HandleAllocated - 0001:00045F0C TWinControl.UpdateBounds - 0001:00045FC4 TWinControl.GetTabOrderList - 0001:00046024 TWinControl.FindNextControl - 0001:00046130 TWinControl.SelectNext - 0001:0004615C TWinControl.SelectFirst - 0001:000461A0 TWinControl.GetChildren - 0001:000461E8 TWinControl.SetChildOrder - 0001:00046228 TWinControl.CanResize - 0001:00046230 DoCalcConstraints - 0001:000462B4 TWinControl.CalcConstraints - 0001:00046690 TWinControl.ConstrainedResize - 0001:000466CC TWinControl.ActionChange - 0001:0004670C TWinControl.GetActionLinkClass - 0001:00046714 TWinControl.AssignTo - 0001:00046744 TWinControl.CanAutoSize - 0001:00046910 TWinControl.SetBevelCut - 0001:00046954 TWinControl.SetBevelEdges - 0001:00046984 TWinControl.SetBevelKind - 0001:000469A4 TWinControl.SetBevelWidth - 0001:000469C4 TWinControl.WMNCCalcSize - 0001:00046A54 TWinControl.WMNCPaint - 0001:00046CD4 TWinControl.WMContextMenu - 0001:00046D40 THintWindow.Create - 0001:00046DAC THintWindow.CreateParams - 0001:00046DE8 THintWindow.WMNCHitTest - 0001:00046DF0 THintWindow.WMNCPaint - 0001:00046E54 THintWindow.Paint - 0001:00046EFC THintWindow.IsHintMsg - 0001:00046F60 THintWindow.ReleaseHandle - 0001:00046F68 THintWindow.CMTextChanged - 0001:00047000 THintWindow.ActivateHint - 0001:000471D8 THintWindow.ActivateHintData - 0001:00047200 THintWindow.CalcHintRect - 0001:0004725C THintWindow.NCPaint - 0001:00047290 THintWindow.WMPrint - 0001:000472B4 ClientToWindow - 0001:000472F4 TDragImageList.Initialize - 0001:0004730C TDragImageList.CombineDragCursor - 0001:000473D8 TDragImageList.SetDragImage - 0001:00047420 TDragImageList.SetDragCursor - 0001:00047438 TDragImageList.GetHotSpot - 0001:00047464 TDragImageList.BeginDrag - 0001:000474C4 TDragImageList.DragLock - 0001:00047528 TDragImageList.DragUnlock - 0001:0004754C TDragImageList.DragMove - 0001:00047590 TDragImageList.ShowDragImage - 0001:000475A8 TDragImageList.HideDragImage - 0001:000475C0 TDragImageList.EndDrag - 0001:00047608 TCustomControl.Create - 0001:00047664 TCustomControl.Destroy - 0001:00047694 TCustomControl.WMPaint - 0001:000476B4 TCustomControl.PaintWindow - 0001:00047760 TCustomControl.Paint - 0001:00047764 NextVisibleZone - 0001:00047780 IsOrientationSet - 0001:000477A4 TDockZone.Create - 0001:000477C8 TDockZone.GetChildCount - 0001:000477DC TDockZone.GetVisibleChildCount - 0001:000477F8 TDockZone.GetVisible - 0001:0004782C TDockZone.GetLimitBegin - 0001:00047874 TDockZone.GetLimitSize - 0001:000478BC TDockZone.GetTopLeft - 0001:00047928 TDockZone.GetHeightWidth - 0001:000479D8 TDockZone.ResetChildren - 0001:00047A80 TDockZone.GetControlName - 0001:00047AC4 TDockZone.SetControlName - 0001:00047B48 ParentNotLast - 0001:00047B78 TDockZone.Update - 0001:00047CF0 TDockZone.GetZoneLimit - 0001:00047D18 TDockZone.SetZoneLimit - 0001:00047D1C GetLastChildZone - 0001:00047D2C TDockZone.ExpandZoneLimit - 0001:00047D68 TDockZone.ResetZoneLimits - 0001:00047DC8 TDockZone.NextVisible - 0001:00047DD4 TDockZone.PrevVisible - 0001:00047DF0 TDockZone.FirstVisibleChild - 0001:00047DFC TDockTree.Create - 0001:00047F64 TDockTree.Destroy - 0001:00047FB8 TDockTree.AdjustDockRect - 0001:00047FCC TDockTree.BeginUpdate - 0001:00047FD0 TDockTree.EndUpdate - 0001:00047FE4 DoFindControlZone - 0001:0004803C TDockTree.FindControlZone - 0001:00048068 DoForEach - 0001:000480A4 TDockTree.ForEachAt - 0001:000480BC TDockTree.GetControlBounds - 0001:00048130 TDockTree.HitTest - 0001:00048140 TDockTree.InsertControl - 0001:00048350 TDockTree.InsertNewParent - 0001:000484F8 TDockTree.InsertSibling - 0001:00048570 DoFindZone - 0001:0004879C FindControlAtPos - 0001:00048830 TDockTree.InternalHitTest - 0001:000488B8 ReadControlName - 0001:00048900 TDockTree.LoadFromStream - 0001:00048B08 DrawCloseButton - 0001:00048B60 DrawGrabberLine - 0001:00048BE8 TDockTree.PaintDockFrame - 0001:00048CC4 TDockTree.PaintSite - 0001:00048E28 TDockTree.PositionDockRect - 0001:00048F9C DoPrune - 0001:00048FD0 TDockTree.PruneZone - 0001:0004902C TDockTree.RemoveControl - 0001:00049068 TDockTree.RemoveZone - 0001:000492E4 TDockTree.ResetBounds - 0001:000493C0 TDockTree.ScaleZone - 0001:000493FC WriteControlName - 0001:00049474 DoSaveZone - 0001:00049530 TDockTree.SaveToStream - 0001:00049678 DoSetNewBounds - 0001:00049700 TDockTree.SetNewBounds - 0001:0004972C TDockTree.SetReplacingControl - 0001:00049744 TDockTree.ShiftZone - 0001:00049774 TDockTree.SplitterMouseDown - 0001:000497D4 TDockTree.SplitterMouseUp - 0001:00049850 TDockTree.UpdateAll - 0001:00049878 TDockTree.UpdateZone - 0001:00049888 TDockTree.DrawSizeSplitter - 0001:00049974 DoGetNextLimit - 0001:00049A04 TDockTree.GetNextLimit - 0001:00049A54 GetDockAlign - 0001:00049AD0 HideZone - 0001:00049B50 ShowZone - 0001:00049C88 TDockTree.ControlVisibilityChanged - 0001:00049D10 CalcSplitterPos - 0001:00049DA0 TDockTree.WindowProc - 0001:0004A188 TMouse.Create - 0001:0004A218 TMouse.Destroy - 0001:0004A248 TMouse.GetCapture - 0001:0004A250 TMouse.GetCursorPos - 0001:0004A260 TMouse.GetMouseData - 0001:0004A27C TMouse.GetNativeData - 0001:0004A2AC TMouse.GetRegisteredData - 0001:0004A2D4 TMouse.SetCapture - 0001:0004A2FC TMouse.SettingChanged - 0001:0004A360 InitIMM32 - 0001:0004A5C8 Win32NLSEnableIME - 0001:0004A5E4 SetImeMode - 0001:0004A6C0 Imm32IsIME - 0001:0004A6D4 DoneControls - 0001:0004A75C InitControls - 0001:0004A928 TCustomListControl.MoveSelection - 0001:0004A944 Finalization - 0001:0004A9AC Controls - 0001:0004AF64 TContainedAction.Destroy - 0001:0004AF98 TContainedAction.GetIndex - 0001:0004AFB0 TContainedAction.IsCategoryStored - 0001:0004AFB4 TContainedAction.GetParentComponent - 0001:0004AFC4 TContainedAction.HasParent - 0001:0004AFD4 TContainedAction.ReadState - 0001:0004B008 TContainedAction.SetIndex - 0001:0004B050 TContainedAction.SetCategory - 0001:0004B07C TContainedAction.SetActionList - 0001:0004B0A4 TContainedAction.SetParentComponent - 0001:0004B0D0 TContainedAction.Execute - 0001:0004B128 TContainedAction.Update - 0001:0004B180 TCustomActionList.Create - 0001:0004B1EC TCustomActionList.Destroy - 0001:0004B23C TCustomActionList.GetChildren - 0001:0004B284 TCustomActionList.SetChildOrder - 0001:0004B2B4 TCustomActionList.GetAction - 0001:0004B2C8 TCustomActionList.GetActionCount - 0001:0004B2D0 TCustomActionList.SetImages - 0001:0004B304 TCustomActionList.ImageListChange - 0001:0004B310 TCustomActionList.Notification - 0001:0004B358 TCustomActionList.AddAction - 0001:0004B378 TCustomActionList.RemoveAction - 0001:0004B394 TCustomActionList.Change - 0001:0004B3FC TCustomActionList.IsShortCut - 0001:0004B488 TCustomActionList.ExecuteAction - 0001:0004B4A8 TCustomActionList.UpdateAction - 0001:0004B4C8 TActionLink.IsCaptionLinked - 0001:0004B4DC TActionLink.IsCheckedLinked - 0001:0004B4F0 TActionLink.IsEnabledLinked - 0001:0004B504 TActionLink.IsGroupIndexLinked - 0001:0004B518 TActionLink.IsHelpContextLinked - 0001:0004B52C TActionLink.IsHelpLinked - 0001:0004B540 TActionLink.IsHintLinked - 0001:0004B554 TActionLink.IsImageIndexLinked - 0001:0004B568 TActionLink.IsShortCutLinked - 0001:0004B57C TActionLink.IsVisibleLinked - 0001:0004B590 TActionLink.SetAutoCheck - 0001:0004B594 TActionLink.SetCaption - 0001:0004B598 TActionLink.SetChecked - 0001:0004B59C TActionLink.SetEnabled - 0001:0004B5A0 TActionLink.SetGroupIndex - 0001:0004B5A4 TActionLink.SetHelpContext - 0001:0004B5A8 TActionLink.SetHelpKeyword - 0001:0004B5AC TActionLink.SetHelpType - 0001:0004B5B0 TActionLink.SetHint - 0001:0004B5B4 TActionLink.SetImageIndex - 0001:0004B5B8 TActionLink.SetShortCut - 0001:0004B5BC TActionLink.SetVisible - 0001:0004B5C0 TCustomAction.Create - 0001:0004B614 TCustomAction.Destroy - 0001:0004B664 TCustomAction.AssignTo - 0001:0004B710 TCustomAction.SetCaption - 0001:0004B770 TCustomAction.SetChecked - 0001:0004B878 TCustomAction.SetEnabled - 0001:0004B8F0 TCustomAction.SetHelpKeyword - 0001:0004B958 TCustomAction.SetHelpContext - 0001:0004B9B0 TCustomAction.SetHint - 0001:0004BA10 TCustomAction.SetImageIndex - 0001:0004BA6C TCustomAction.SetShortCut - 0001:0004BAD0 TCustomAction.SetVisible - 0001:0004BB30 TCustomAction.SetName - 0001:0004BB7C TCustomAction.DoHint - 0001:0004BBA4 TCustomAction.Execute - 0001:0004BBF4 TCustomAction.GetSecondaryShortCuts - 0001:0004BC1C TCustomAction.SetSecondaryShortCuts - 0001:0004BC50 TCustomAction.IsSecondaryShortCutsStored - 0001:0004BC74 TCustomAction.HandleShortCut - 0001:0004BC80 TShortCutList.Add - 0001:0004BCAC TShortCutList.IndexOfShortCut - 0001:0004BCF0 Finalization - 0001:0004BD20 ActnList - 0001:0004BF20 GetRGBColor - 0001:0004BF40 GetColor - 0001:0004BF60 TCustomImageList.Create - 0001:0004BFAC TCustomImageList.CreateSize - 0001:0004C000 TCustomImageList.Destroy - 0001:0004C06C TCustomImageList.Initialize - 0001:0004C124 TCustomImageList.HandleAllocated - 0001:0004C12C TCustomImageList.HandleNeeded - 0001:0004C138 TCustomImageList.InitBitmap - 0001:0004C1FC TCustomImageList.SetNewDimensions - 0001:0004C234 TCustomImageList.SetWidth - 0001:0004C278 TCustomImageList.SetHeight - 0001:0004C2BC TCustomImageList.SetHandle - 0001:0004C2E8 TCustomImageList.GetHandle - 0001:0004C2F8 TCustomImageList.GetImageHandle - 0001:0004C34C TCustomImageList.FreeHandle - 0001:0004C384 TCustomImageList.CreateImageList - 0001:0004C424 TCustomImageList.Add - 0001:0004C4F0 TCustomImageList.GetIcon - 0001:0004C500 TCustomImageList.GetIcon - 0001:0004C554 TCustomImageList.GetCount - 0001:0004C578 TCustomImageList.Delete - 0001:0004C604 TCustomImageList.Clear - 0001:0004C610 TCustomImageList.SetBkColor - 0001:0004C648 TCustomImageList.GetBkColor - 0001:0004C670 TCustomImageList.DoDraw - 0001:0004C844 TCustomImageList.Draw - 0001:0004C868 TCustomImageList.Draw - 0001:0004C8B4 TCustomImageList.CopyImages - 0001:0004CA4C TCustomImageList.AddImages - 0001:0004CA6C TCustomImageList.Assign - 0001:0004CB2C TCustomImageList.AssignTo - 0001:0004CBDC TCustomImageList.CheckImage - 0001:0004CC54 TCustomImageList.SetDrawingStyle - 0001:0004CC6C TCustomImageList.GetHotSpot - 0001:0004CC7C TCustomImageList.Change - 0001:0004CCCC TCustomImageList.UnRegisterChanges - 0001:0004CD10 TCustomImageList.RegisterChanges - 0001:0004CD24 StreamsEqual - 0001:0004CD6C TCustomImageList.Equal - 0001:0004CE5C DoWrite - 0001:0004CEB8 TCustomImageList.DefineProperties - 0001:0004CF10 TCustomImageList.ReadD2Stream - 0001:0004D1A4 TCustomImageList.ReadD3Stream - 0001:0004D36C TCustomImageList.ReadData - 0001:0004D3F8 TCustomImageList.WriteData - 0001:0004D474 TCustomImageList.BeginUpdate - 0001:0004D478 TCustomImageList.EndUpdate - 0001:0004D498 TChangeLink.Destroy - 0001:0004D4CC TChangeLink.Change - 0001:0004D4E4 Finalization - 0001:0004D514 ImgList - 0001:0004E410 FindPopupControl - 0001:0004E440 ReturnAddr - 0001:0004E448 Error - 0001:0004E468 ShortCut - 0001:0004E4A0 GetSpecialName - 0001:0004E4F4 ShortCutToText - 0001:0004E6F8 CompareFront - 0001:0004E754 TextToShortCut - 0001:0004E84C UniqueCommand - 0001:0004E86C Iterate - 0001:0004E8CC IterateMenus - 0001:0004E9D4 TMenuActionLink.AssignClient - 0001:0004E9F0 TMenuActionLink.IsAutoCheckLinked - 0001:0004EA18 TMenuActionLink.IsCaptionLinked - 0001:0004EA50 TMenuActionLink.IsCheckedLinked - 0001:0004EA80 TMenuActionLink.IsEnabledLinked - 0001:0004EAB0 TMenuActionLink.IsHelpContextLinked - 0001:0004EAE0 TMenuActionLink.IsHintLinked - 0001:0004EB14 TMenuActionLink.IsGroupIndexLinked - 0001:0004EB50 TMenuActionLink.IsImageIndexLinked - 0001:0004EB84 TMenuActionLink.IsShortCutLinked - 0001:0004EBB8 TMenuActionLink.IsVisibleLinked - 0001:0004EBEC TMenuActionLink.IsOnExecuteLinked - 0001:0004EC14 TMenuActionLink.SetAutoCheck - 0001:0004EC34 TMenuActionLink.SetCaption - 0001:0004EC54 TMenuActionLink.SetChecked - 0001:0004EC74 TMenuActionLink.SetEnabled - 0001:0004EC94 TMenuActionLink.SetHelpContext - 0001:0004ECB0 TMenuActionLink.SetHint - 0001:0004ECD4 TMenuActionLink.SetImageIndex - 0001:0004ECF4 TMenuActionLink.SetShortCut - 0001:0004ED14 TMenuActionLink.SetVisible - 0001:0004ED34 TMenuActionLink.SetOnExecute - 0001:0004ED60 TMenuItem.Create - 0001:0004EDDC TMenuItem.Destroy - 0001:0004EE90 TMenuItem.AppendTo - 0001:0004F114 AddIn - 0001:0004F130 TMenuItem.PopulateMenu - 0001:0004F1A0 TMenuItem.ReadShortCutText - 0001:0004F1F8 TMenuItem.MergeWith - 0001:0004F234 TMenuItem.Loaded - 0001:0004F270 TMenuItem.RebuildHandle - 0001:0004F340 TMenuItem.VerifyGroupIndex - 0001:0004F3A0 TMenuItem.GetHandle - 0001:0004F3EC TMenuItem.DefineProperties - 0001:0004F430 TMenuItem.DoDrawText - 0001:0004F640 TMenuItem.DrawItem - 0001:0004F680 NormalDraw - 0001:0004FEF8 BiDiDraw - 0001:00050798 TMenuItem.AdvancedDrawItem - 0001:000508B0 TMenuItem.GetImageList - 0001:000508E0 GetMenuSize - 0001:0005092C TMenuItem.MeasureItem - 0001:00050B2C TMenuItem.HasParent - 0001:00050B30 TMenuItem.SetBreak - 0001:00050B40 TMenuItem.SetCaption - 0001:00050B68 TMenuItem.TurnSiblingsOff - 0001:00050BB0 TMenuItem.SetChecked - 0001:00050C04 TMenuItem.SetEnabled - 0001:00050C7C TMenuItem.SetGroupIndex - 0001:00050CC0 TMenuItem.GetAction - 0001:00050CD0 TMenuItem.GetActionLinkClass - 0001:00050CD8 TMenuItem.GetCount - 0001:00050CE8 TMenuItem.GetItem - 0001:00050D0C TMenuItem.SetShortCut - 0001:00050D20 TMenuItem.SetVisible - 0001:00050D30 TMenuItem.SetImageIndex - 0001:00050D40 TMenuItem.GetMenuIndex - 0001:00050D58 TMenuItem.SetMenuIndex - 0001:00050DA0 TMenuItem.GetChildren - 0001:00050DD8 TMenuItem.SetChildOrder - 0001:00050DF8 TMenuItem.SetDefault - 0001:00050E54 TMenuItem.InitiateAction - 0001:00050E64 TMenuItem.Insert - 0001:00050F18 TMenuItem.Delete - 0001:00050F8C TMenuItem.Click - 0001:0005103C TMenuItem.IndexOf - 0001:00051054 TMenuItem.Add - 0001:00051070 TMenuItem.Remove - 0001:00051098 TMenuItem.MenuChanged - 0001:000510DC TMenuItem.SubItemChanged - 0001:00051134 TMenuItem.GetBitmap - 0001:0005115C TMenuItem.SetAction - 0001:000511CC TMenuItem.SetBitmap - 0001:00051200 TMenuItem.InitiateActions - 0001:0005122C TMenuItem.GetParentComponent - 0001:00051240 TMenuItem.SetParentComponent - 0001:00051294 TMenuItem.GetParentMenu - 0001:000512A4 TMenuItem.SetRadioItem - 0001:000512D0 TMenuItem.ActionChange - 0001:000513F0 TMenuItem.DoActionChange - 0001:00051414 TMenuItem.IsCaptionStored - 0001:00051434 TMenuItem.IsCheckedStored - 0001:00051454 TMenuItem.IsEnabledStored - 0001:00051474 TMenuItem.IsHintStored - 0001:00051494 TMenuItem.IsHelpContextStored - 0001:000514B4 TMenuItem.IsImageIndexStored - 0001:000514D4 TMenuItem.IsShortCutStored - 0001:000514F4 TMenuItem.IsVisibleStored - 0001:00051514 TMenuItem.IsOnClickStored - 0001:00051534 TMenuItem.AssignTo - 0001:000515AC TMenuItem.Notification - 0001:00051600 TMenuItem.SetSubMenuImages - 0001:0005163C TMenuItem.ImageListChange - 0001:00051648 UpdateItem - 0001:00051670 TMenuItem.UpdateItems - 0001:00051684 IfHotkeyAvailable - 0001:000516B4 CopyToBest - 0001:00051738 InsertHotkeyFarEastFormat - 0001:00051898 TMenuItem.InternalRethinkHotkeys - 0001:00051D60 TMenuItem.SetAutoHotkeys - 0001:00051D70 TMenuItem.IsLine - 0001:00051D94 TMenuItem.InternalRethinkLines - 0001:00051EDC TMenuItem.SetAutoLineReduction - 0001:00051EEC TMenuItem.GetAutoHotkeys - 0001:00051F18 TMenuItem.GetAutoLineReduction - 0001:00051F44 TMenu.Create - 0001:00051FE0 TMenu.Destroy - 0001:00052018 TMenu.GetChildren - 0001:00052034 TMenu.GetHandle - 0001:00052040 TMenu.SetChildOrder - 0001:00052054 UpdateItem - 0001:0005207C TMenu.UpdateItems - 0001:00052094 Find - 0001:0005212C TMenu.FindItem - 0001:0005215C TMenu.GetHelpContext - 0001:000521CC TMenu.DispatchCommand - 0001:000521E8 TMenu.DispatchPopup - 0001:000522B0 TMenu.IsOwnerDraw - 0001:000522C4 NthParentOf - 0001:000522D4 DoClick - 0001:00052428 TMenu.IsShortCut - 0001:00052544 TMenu.IsBiDiModeStored - 0001:0005254C TMenu.DoBiDiModeChanged - 0001:00052608 BuildImage - 0001:000526A8 TMenu.UpdateImage - 0001:0005272C TMenu.SetOwnerDraw - 0001:0005273C TMenu.AdjustBiDiBehavior - 0001:000527B8 TMenu.SetWindowHandle - 0001:000527F0 TMenu.DoChange - 0001:00052808 TMenu.Loaded - 0001:00052820 TMenu.MenuChanged - 0001:0005285C TMenu.ImageListChange - 0001:00052868 TMenu.SetImages - 0001:000528A4 TMenu.Notification - 0001:000528D0 TMenu.IsRightToLeft - 0001:000528E8 IsAccelChar - 0001:00052944 IsInitialChar - 0001:00052A2C TMenu.ProcessMenuChar - 0001:00052BA4 TMenu.DoGetMenuString - 0001:00052C4C TMenu.SetBiDiMode - 0001:00052C60 TMenu.SetParentBiDiMode - 0001:00052C70 TMenu.ParentBiDiModeChanged - 0001:00052C98 TMenu.ParentBiDiModeChanged - 0001:00052CC4 TMenu.GetAutoHotkeys - 0001:00052CD4 TMenu.SetAutoHotkeys - 0001:00052CE4 TMenu.GetAutoLineReduction - 0001:00052CF4 TMenu.SetAutoLineReduction - 0001:00052D04 TMainMenu.SetAutoMerge - 0001:00052D24 TMainMenu.MenuChanged - 0001:00052D7C TMainMenu.Merge - 0001:00052D98 TMainMenu.Unmerge - 0001:00052DB4 TMainMenu.ItemChanged - 0001:00052DE0 TMainMenu.GetHandle - 0001:00052DF0 TPopupList.MainWndProc - 0001:00052E3C TPopupList.WndProc - 0001:00053380 TPopupList.Add - 0001:000533A8 TPopupList.Remove - 0001:000533C4 TPopupMenu.Create - 0001:00053438 TPopupMenu.Destroy - 0001:0005346C TPopupMenu.DoPopup - 0001:00053480 TPopupMenu.GetHelpContext - 0001:00053488 TPopupMenu.SetHelpContext - 0001:00053490 TPopupMenu.SetBiDiModeFromPopupControl - 0001:000534D8 TPopupMenu.UseRightToLeftAlignment - 0001:00053524 TPopupMenu.Popup - 0001:000535D8 TMenuItemStack.ClearItem - 0001:00053614 DrawMenuItem - 0001:000536FC StripHotkey - 0001:00053794 GetHotkey - 0001:000537F8 AnsiSameCaption - 0001:000538F4 Finalization - 0001:00053964 Menus - 0001:00055FE0 SaveFocusState - 0001:00055FE8 RestoreFocusState - 0001:00055FF0 ShowMDIClientEdge - 0001:0005603C DoneApplication - 0001:00056074 DoDisableWindow - 0001:000560C4 DisableTaskWindows - 0001:00056178 EnableTaskWindows - 0001:000561B0 DoFindWindow - 0001:00056214 FindTopMostWindow - 0001:00056250 SendFocusMessage - 0001:00056270 CheckTaskWindow - 0001:00056290 ForegroundTask - 0001:000562BC FindGlobalComponent - 0001:0005633C KeysToShiftState - 0001:00056390 KeyDataToShiftState - 0001:000563CC KeyboardStateToShiftState - 0001:00056418 IsAccel - 0001:00056488 GetParentForm - 0001:000564B0 ValidParentForm - 0001:00056530 TControlScrollBar.Create - 0001:000565B8 TControlScrollBar.IsIncrementStored - 0001:000565C0 TControlScrollBar.Assign - 0001:00056610 TControlScrollBar.ChangeBiDiPosition - 0001:00056648 ProcessHorz - 0001:000566B4 ProcessVert - 0001:0005671C TControlScrollBar.CalcAutoRange - 0001:000567C8 TControlScrollBar.IsScrollBarVisible - 0001:00056800 ScrollBarVisible - 0001:00056834 Adjustment - 0001:000568B0 TControlScrollBar.ControlSize - 0001:00056930 TControlScrollBar.NeedsScrollBarVisible - 0001:00056948 GetRealScrollPosition - 0001:000569A8 TControlScrollBar.ScrollMessage - 0001:00056CA0 TControlScrollBar.SetButtonSize - 0001:00056CE4 TControlScrollBar.SetColor - 0001:00056D00 TControlScrollBar.SetParentColor - 0001:00056D18 TControlScrollBar.SetPosition - 0001:00056DDC TControlScrollBar.SetSize - 0001:00056E20 TControlScrollBar.SetStyle - 0001:00056E38 TControlScrollBar.SetThumbSize - 0001:00056E50 TControlScrollBar.DoSetRange - 0001:00056E68 TControlScrollBar.SetRange - 0001:00056E7C TControlScrollBar.IsRangeStored - 0001:00056E88 TControlScrollBar.SetVisible - 0001:00056E94 UpdateScrollProperties - 0001:00056F9C TControlScrollBar.Update - 0001:000570B4 TScrollingWinControl.Create - 0001:0005711C TScrollingWinControl.Destroy - 0001:00057158 TScrollingWinControl.CreateParams - 0001:00057168 TScrollingWinControl.CreateWnd - 0001:000571A8 TScrollingWinControl.AlignControls - 0001:000571C8 TScrollingWinControl.AutoScrollEnabled - 0001:000571E8 TScrollingWinControl.DoFlipChildren - 0001:00057300 TScrollingWinControl.CalcAutoRange - 0001:00057324 TScrollingWinControl.SetAutoScroll - 0001:00057360 TScrollingWinControl.SetHorzScrollBar - 0001:00057370 TScrollingWinControl.SetVertScrollBar - 0001:00057380 TScrollingWinControl.UpdateScrollBars - 0001:00057478 TScrollingWinControl.AutoScrollInView - 0001:00057490 TScrollingWinControl.ScrollInView - 0001:000575E4 TScrollingWinControl.ScaleScrollBars - 0001:00057688 TScrollingWinControl.ChangeScale - 0001:000576AC TScrollingWinControl.Resizing - 0001:000576B0 TScrollingWinControl.WMSize - 0001:0005778C TScrollingWinControl.WMHScroll - 0001:000577B0 TScrollingWinControl.WMVScroll - 0001:000577D4 TScrollingWinControl.AdjustClientRect - 0001:00057844 TScrollingWinControl.CMBiDiModeChanged - 0001:000578D4 TScrollBox.Create - 0001:00057934 TScrollBox.CreateParams - 0001:00057984 TScrollBox.SetBorderStyle - 0001:00057998 TScrollBox.WMNCHitTest - 0001:000579AC TScrollBox.CMCtl3DChanged - 0001:000579D8 TCustomForm.Create - 0001:00057B64 TCustomForm.AfterConstruction - 0001:00057B9C TCustomForm.CreateNew - 0001:00057D0C TCustomForm.BeforeDestruction - 0001:00057D74 TCustomForm.Destroy - 0001:00057E58 TCustomForm.DoCreate - 0001:00057ED4 TCustomForm.DoDestroy - 0001:00057F34 TCustomForm.Loaded - 0001:00057F70 TCustomForm.Notification - 0001:0005807C TCustomForm.ReadState - 0001:000582E4 TCustomForm.DefineProperties - 0001:00058394 TCustomForm.ReadIgnoreFontProperty - 0001:000583B4 TCustomForm.ReadTextHeight - 0001:000583CC TCustomForm.WriteTextHeight - 0001:000583E8 TCustomForm.WritePixelsPerInch - 0001:00058404 TCustomForm.GetTextHeight - 0001:00058428 TCustomForm.BeginAutoDrag - 0001:0005842C TCustomForm.ChangeScale - 0001:000584AC TCustomForm.IconChanged - 0001:00058508 TCustomForm.IsClientSizeStored - 0001:00058518 TCustomForm.IsFormSizeStored - 0001:00058540 TCustomForm.IsAutoScrollStored - 0001:00058574 TCustomForm.DoClose - 0001:00058594 TCustomForm.DoHide - 0001:000585B4 TCustomForm.DoShow - 0001:000585D4 TCustomForm.GetClientRect - 0001:0005865C TCustomForm.GetChildren - 0001:000586C8 TCustomForm.GetFloating - 0001:000586F4 TCustomForm.SetChildOrder - 0001:00058788 TCustomForm.SetParentBiDiMode - 0001:000587B0 TCustomForm.SetClientWidth - 0001:000587E0 TCustomForm.SetClientHeight - 0001:00058810 TCustomForm.SetVisible - 0001:00058854 TCustomForm.VisibleChanging - 0001:000588B8 TCustomForm.WantChildKey - 0001:000588BC TCustomForm.SetParent - 0001:000588F4 TCustomForm.ValidateRename - 0001:00058934 TCustomForm.WndProc - 0001:00058D6C Default - 0001:00058DB8 MaximizedChildren - 0001:00058DF8 TCustomForm.ClientWndProc - 0001:00058F40 TCustomForm.AlignControls - 0001:00058F7C TCustomForm.CMBiDiModeChanged - 0001:00059014 TCustomForm.CMParentBiDiModeChanged - 0001:0005909C TCustomForm.SetBorderIcons - 0001:000590C8 TCustomForm.SetBorderStyle - 0001:00059100 TCustomForm.Dock - 0001:00059144 TCustomForm.DoDock - 0001:00059198 TCustomForm.GetActiveMDIChild - 0001:000591CC TCustomForm.GetMDIChildCount - 0001:00059218 TCustomForm.GetMDIChildren - 0001:00059268 EnumMonitorsProc - 0001:00059298 TCustomForm.GetMonitor - 0001:00059380 TCustomForm.GetCanvas - 0001:00059388 TCustomForm.SetIcon - 0001:00059394 TCustomForm.IsForm - 0001:0005939C TCustomForm.IsIconStored - 0001:000593C4 TCustomForm.SetFormStyle - 0001:00059444 TCustomForm.RefreshMDIMenu - 0001:000594C0 TCustomForm.SetObjectMenuItem - 0001:000594E4 TCustomForm.SetWindowMenu - 0001:0005950C TCustomForm.SetMenu - 0001:000596E0 TCustomForm.GetPixelsPerInch - 0001:000596F4 TCustomForm.SetPixelsPerInch - 0001:00059728 TCustomForm.SetPosition - 0001:00059744 TCustomForm.GetScaled - 0001:00059750 TCustomForm.SetScaled - 0001:00059780 TCustomForm.CMColorChanged - 0001:000597A4 TCustomForm.NormalColor - 0001:000597BC TCustomForm.CMCtl3DChanged - 0001:00059804 TCustomForm.CMFontChanged - 0001:00059824 TCustomForm.CMMenuChanged - 0001:00059840 TCustomForm.SetWindowState - 0001:00059880 TCustomForm.SetWindowToMonitor - 0001:00059BD4 TCustomForm.CreateParams - 0001:00059DF0 TCustomForm.CreateWnd - 0001:00059F30 TCustomForm.CreateWindowHandle - 0001:0005A068 TCustomForm.DestroyWindowHandle - 0001:0005A0AC TCustomForm.DefaultHandler - 0001:0005A110 TCustomForm.SetActiveControl - 0001:0005A1C8 TCustomForm.DefocusControl - 0001:0005A210 TCustomForm.FocusControl - 0001:0005A234 TCustomForm.SetFocusedControl - 0001:0005A4C4 TCustomForm.ActiveChanged - 0001:0005A4C8 TCustomForm.SetWindowFocus - 0001:0005A518 TCustomForm.SetActive - 0001:0005A57C TCustomForm.SendCancelMode - 0001:0005A5CC TCustomForm.MergeMenu - 0001:0005A674 DoNestedActivation - 0001:0005A6C0 TCustomForm.Activate - 0001:0005A6F0 TCustomForm.Deactivate - 0001:0005A720 TCustomForm.Paint - 0001:0005A740 TCustomForm.GetIconHandle - 0001:0005A75C TCustomForm.PaintWindow - 0001:0005A818 TCustomForm.PaletteChanged - 0001:0005A8B8 TCustomForm.WMPaint - 0001:0005A938 TCustomForm.WMIconEraseBkgnd - 0001:0005A998 TCustomForm.WMEraseBkgnd - 0001:0005A9D0 TCustomForm.WMQueryDragIcon - 0001:0005A9E4 ModifySystemMenu - 0001:0005AAE0 TCustomForm.WMNCCreate - 0001:0005AB14 TCustomForm.WMNCLButtonDown - 0001:0005ABA4 TCustomForm.WMDestroy - 0001:0005AC04 TCustomForm.WMCommand - 0001:0005AC38 TCustomForm.WMInitMenuPopup - 0001:0005AC50 TCustomForm.WMMenuChar - 0001:0005AC88 TCustomForm.WMMenuSelect - 0001:0005AD30 TCustomForm.WMActivate - 0001:0005AD50 TCustomForm.Resizing - 0001:0005AD88 TCustomForm.WMClose - 0001:0005AD90 TCustomForm.WMQueryEndSession - 0001:0005ADBC TCustomForm.CMAppSysCommand - 0001:0005AE14 TCustomForm.WMSysCommand - 0001:0005AEA0 TCustomForm.WMShowWindow - 0001:0005AF38 TCustomForm.WMMDIActivate - 0001:0005AF90 TCustomForm.WMNextDlgCtl - 0001:0005AFBC TCustomForm.WMEnterMenuLoop - 0001:0005AFD8 GetMenuHelpContext - 0001:0005B018 ControlHasHelp - 0001:0005B050 GetHelpInfo - 0001:0005B084 TCustomForm.WMHelp - 0001:0005B1F0 TCustomForm.WMGetMinMaxInfo - 0001:0005B264 TCustomForm.WMWindowPosChanging - 0001:0005B2FC TCustomForm.CMActivate - 0001:0005B320 TCustomForm.CMDeactivate - 0001:0005B344 TCustomForm.CMDialogKey - 0001:0005B3E0 TCustomForm.CMShowingChanged - 0001:0005B958 TCustomForm.CMIconChanged - 0001:0005B978 TCustomForm.CMRelease - 0001:0005B980 TCustomForm.CMTextChanged - 0001:0005B9D0 TCustomForm.CMUIActivate - 0001:0005B9D8 TCustomForm.CMParentFontChanged - 0001:0005BA44 TCustomForm.CMIsShortCut - 0001:0005BA70 TCustomForm.Close - 0001:0005BB14 TCustomForm.CloseQuery - 0001:0005BB78 TCustomForm.CloseModal - 0001:0005BC10 TCustomForm.Hide - 0001:0005BC18 TCustomForm.Show - 0001:0005BC30 TCustomForm.SetFocus - 0001:0005BCAC TCustomForm.Release - 0001:0005BCC8 TCustomForm.ShowModal - 0001:0005BF68 TraverseClients - 0001:0005BFD8 TCustomForm.UpdateActions - 0001:0005C040 TCustomForm.RequestAlign - 0001:0005C05C TCustomForm.WMSettingChange - 0001:0005C080 ProcessExecute - 0001:0005C0B0 TraverseClients - 0001:0005C12C TCustomForm.CMActionExecute - 0001:0005C180 ProcessUpdate - 0001:0005C1B0 TraverseClients - 0001:0005C22C TCustomForm.CMActionUpdate - 0001:0005C280 DispatchShortCut - 0001:0005C2D4 TCustomForm.IsShortCut - 0001:0005C350 TCustomForm.QueryInterface - 0001:0005C38C TCustomForm.MouseWheelHandler - 0001:0005C3C4 TCustomForm.HandleCreateException - 0001:0005C3D4 TCustomForm.SetLayeredAttribs - 0001:0005C4AC TCustomForm.SetAlphaBlend - 0001:0005C4C0 TCustomForm.SetAlphaBlendValue - 0001:0005C4D4 TCustomForm.SetTransparentColorValue - 0001:0005C4E8 TCustomForm.SetTransparentColor - 0001:0005C4FC TCustomForm.InitAlphaBlending - 0001:0005C528 TCustomDockForm.Create - 0001:0005C590 TCustomDockForm.DoAddDockClient - 0001:0005C674 TCustomDockForm.DoRemoveDockClient - 0001:0005C694 TCustomDockForm.Loaded - 0001:0005C6E0 TCustomDockForm.GetSiteInfo - 0001:0005C70C TCustomDockForm.WMNCHitTest - 0001:0005C734 TCustomDockForm.WMNCLButtonDown - 0001:0005C7CC TCustomDockForm.CMControlListChange - 0001:0005C824 TCustomDockForm.CMDockNotification - 0001:0005C8F8 TCustomDockForm.CMUnDockClient - 0001:0005C910 TCustomDockForm.CMVisibleChanged - 0001:0005C94C TMonitor.GetLeft - 0001:0005C964 TMonitor.GetHeight - 0001:0005C980 TMonitor.GetTop - 0001:0005C998 TMonitor.GetWidth - 0001:0005C9B4 TMonitor.GetBoundsRect - 0001:0005C9E4 TScreen.Create - 0001:0005CB3C TScreen.Destroy - 0001:0005CC04 TScreen.GetHeight - 0001:0005CC10 TScreen.GetWidth - 0001:0005CC1C TScreen.GetDesktopTop - 0001:0005CC28 TScreen.GetDesktopLeft - 0001:0005CC34 TScreen.GetDesktopHeight - 0001:0005CC40 TScreen.GetDesktopWidth - 0001:0005CC4C TScreen.GetMonitor - 0001:0005CC60 TScreen.GetMonitorCount - 0001:0005CC7C TScreen.GetForm - 0001:0005CC90 TScreen.GetFormCount - 0001:0005CC98 TScreen.GetCustomForms - 0001:0005CCAC TScreen.GetCustomFormCount - 0001:0005CCB4 TScreen.UpdateLastActive - 0001:0005CD00 TScreen.AddForm - 0001:0005CD38 TScreen.RemoveForm - 0001:0005CD88 TScreen.AddDataModule - 0001:0005CD94 TScreen.RemoveDataModule - 0001:0005CDA0 TScreen.CreateCursors - 0001:0005CDFC TScreen.DestroyCursors - 0001:0005CE58 TScreen.DeleteCursor - 0001:0005CEA0 TScreen.InsertCursor - 0001:0005CEC8 TScreen.GetImes - 0001:0005D0C8 TScreen.GetDefaultIME - 0001:0005D0E4 TScreen.IconFontChanged - 0001:0005D134 TScreen.GetDataModule - 0001:0005D148 TScreen.GetDataModuleCount - 0001:0005D150 TScreen.GetCursors - 0001:0005D178 TScreen.SetCursor - 0001:0005D208 TScreen.SetCursors - 0001:0005D250 TScreen.GetMetricSettings - 0001:0005D3A4 TScreen.DisableAlign - 0001:0005D3AC TScreen.EnableAlign - 0001:0005D3CC TScreen.Realign - 0001:0005D3D4 InsertBefore - 0001:0005D434 DoPosition - 0001:0005D5E4 DoAlign - 0001:0005D730 AlignWork - 0001:0005D788 TScreen.AlignForms - 0001:0005D810 TScreen.AlignForm - 0001:0005D898 TScreen.ResetFonts - 0001:0005D8A4 GetHint - 0001:0005D8DC GetHintControl - 0001:0005D8FC HintTimerProc - 0001:0005D950 HintMouseThread - 0001:0005D9AC HintGetMsgHook - 0001:0005D9F0 HookHintHooks - 0001:0005DA64 UnhookHintHooks - 0001:0005DAC0 GetAnimation - 0001:0005DAF0 SetAnimation - 0001:0005DB18 ShowWinNoAnimate - 0001:0005DB58 TApplication.Create - 0001:0005DD44 TApplication.Destroy - 0001:0005DE60 TApplication.CreateHandle - 0001:0005E004 TApplication.ControlDestroyed - 0001:0005E064 GetTopMostWindows - 0001:0005E0D4 TApplication.DoNormalizeTopMosts - 0001:0005E184 TApplication.NormalizeTopMosts - 0001:0005E18C TApplication.NormalizeAllTopMosts - 0001:0005E194 TApplication.RestoreTopMosts - 0001:0005E200 TApplication.UseRightToLeftReading - 0001:0005E218 TApplication.UseRightToLeftAlignment - 0001:0005E230 TApplication.CheckIniChange - 0001:0005E288 TApplication.SettingChange - 0001:0005E2F4 Default - 0001:0005E330 DrawAppIcon - 0001:0005E37C TApplication.WndProc - 0001:0005EA54 TApplication.GetIconHandle - 0001:0005EA70 TApplication.Minimize - 0001:0005EB20 TApplication.Restore - 0001:0005EC20 TApplication.BringToFront - 0001:0005EC5C TApplication.GetTitle - 0001:0005ECA8 TApplication.SetTitle - 0001:0005ED38 TApplication.IsDlgMsg - 0001:0005ED5C TApplication.IsMDIMsg - 0001:0005ED98 TApplication.IsKeyMsg - 0001:0005EE50 TApplication.IsHintMsg - 0001:0005EE84 TApplication.IsShortCut - 0001:0005EEF0 TApplication.ProcessMessage - 0001:0005EF88 TApplication.ProcessMessages - 0001:0005EFA0 TApplication.HandleMessage - 0001:0005EFC4 TApplication.HookMainWindow - 0001:0005F020 TApplication.UnhookMainWindow - 0001:0005F09C TApplication.Initialize - 0001:0005F0B4 TApplication.CreateForm - 0001:0005F134 TApplication.Run - 0001:0005F220 TApplication.Terminate - 0001:0005F234 TApplication.HandleException - 0001:0005F2C4 TApplication.MessageBox - 0001:0005F42C TApplication.ShowException - 0001:0005F504 TApplication.InvokeHelp - 0001:0005F634 TApplication.HelpKeyword - 0001:0005F69C TApplication.HelpContext - 0001:0005F704 TApplication.HelpCommand - 0001:0005F70C TApplication.GetExeName - 0001:0005F71C TApplication.SetShowHint - 0001:0005F76C TApplication.DoActionIdle - 0001:0005F7D0 TApplication.DoMouseIdle - 0001:0005F854 TApplication.Idle - 0001:0005F970 TApplication.NotifyForms - 0001:0005F9AC TApplication.IconChanged - 0001:0005FA10 TApplication.SetHint - 0001:0005FAA4 SetVisible - 0001:0005FB00 TApplication.UpdateVisible - 0001:0005FB88 TApplication.ValidateHelpSystem - 0001:0005FBB0 TApplication.StartHintTimer - 0001:0005FBF4 TApplication.StopHintTimer - 0001:0005FC1C TApplication.HintMouseMessage - 0001:0005FD2C TApplication.HintTimerExpired - 0001:0005FD64 TApplication.HideHint - 0001:0005FDA8 TApplication.CancelHint - 0001:0005FDD0 FindScanline - 0001:0005FDE0 GetCursorHeightMargin - 0001:0005FF34 ValidateHintWindow - 0001:0005FF94 MultiLineWidth - 0001:0006002C TApplication.ActivateHint - 0001:000603C0 TApplication.GetCurrentHelpFile - 0001:000603FC TApplication.DispatchAction - 0001:0006048C TApplication.ExecuteAction - 0001:000604B4 TApplication.UpdateAction - 0001:000604DC InitProcs - 0001:00060528 TApplication.WakeMainThread - 0001:00060538 TApplication.HookSynchronizeWakeup - 0001:00060548 TApplication.UnhookSynchronizeWakeup - 0001:00060568 Finalization - 0001:000605C4 Forms - 0001:00060608 RC_LineIn - 0001:00060670 IsWinNT - 0001:00060694 SplitLines - 0001:0006075C RC_Run - 0001:00060B14 Finalization - 0001:00060B50 RedirectConsole - 0001:00060D30 TCustomIniFile.Create - 0001:00060D6C TCustomIniFile.ReadInteger - 0001:00060E30 TCustomIniFile.WriteInteger - 0001:00060E8C TCustomIniFile.ReadBool - 0001:00060EB8 TCustomIniFile.ReadDate - 0001:00060F70 TCustomIniFile.ReadDateTime - 0001:00061028 TCustomIniFile.ReadFloat - 0001:000610E0 TCustomIniFile.ReadTime - 0001:00061198 TCustomIniFile.WriteDate - 0001:000611F8 TCustomIniFile.WriteDateTime - 0001:00061258 TCustomIniFile.WriteFloat - 0001:000612BC TCustomIniFile.WriteTime - 0001:00061334 TCustomIniFile.WriteBool - 0001:00061350 TCustomIniFile.ReadBinaryStream - 0001:000614C0 TCustomIniFile.WriteBinaryStream - 0001:00061634 TIniFile.Destroy - 0001:00061660 TIniFile.ReadString - 0001:000616C0 TIniFile.WriteString - 0001:0006172C TIniFile.ReadSections - 0001:0006182C TIniFile.ReadSection - 0001:00061934 TIniFile.ReadSectionValues - 0001:00061A80 TIniFile.EraseSection - 0001:00061AD4 TIniFile.DeleteKey - 0001:00061B04 TIniFile.UpdateFile - 0001:00061B20 Finalization - 0001:00061B68 IniFiles - 0001:00061B70 FD_SET - 0001:00061B80 FD_ZERO - 0001:00061B88 accept - 0001:00061B90 bind - 0001:00061B98 closesocket - 0001:00061BA0 connect - 0001:00061BA8 getsockopt - 0001:00061BB0 htons - 0001:00061BB8 inet_addr - 0001:00061BC0 ioctlsocket - 0001:00061BC8 listen - 0001:00061BD0 ntohs - 0001:00061BD8 recv - 0001:00061BE0 select - 0001:00061BE8 send - 0001:00061BF0 setsockopt - 0001:00061BF8 socket - 0001:00061C00 gethostbyname - 0001:00061C08 getservbyname - 0001:00061C10 WSAAsyncSelect - 0001:00061C18 WSAAsyncGetHostByName - 0001:00061C20 WSAAsyncGetServByName - 0001:00061C28 WSACancelAsyncRequest - 0001:00061C30 WSAGetLastError - 0001:00061C38 WSAStartup - 0001:00061C40 WSACleanup - 0001:00061C48 Finalization - 0001:00061C78 WinSock - 0001:00061E70 TSynchroObject.Acquire - 0001:00061E74 TSynchroObject.Release - 0001:00061E78 THandleObject.Destroy - 0001:00061EA8 TEvent.Create - 0001:00061F00 TEvent.WaitFor - 0001:00061F48 TEvent.SetEvent - 0001:00061F54 TEvent.ResetEvent - 0001:00061F60 TSimpleEvent.Create - 0001:00061FA0 TCriticalSection.Create - 0001:00061FE0 TCriticalSection.Destroy - 0001:00062010 TCriticalSection.Acquire - 0001:0006201C TCriticalSection.Release - 0001:00062028 TCriticalSection.Enter - 0001:00062030 TCriticalSection.Leave - 0001:00062038 Finalization - 0001:00062068 SyncObjs - 0001:00062E54 CheckSocketResult - 0001:00062F0C Startup - 0001:00062FB8 Cleanup - 0001:00063058 TCustomWinSocket.Create - 0001:000630D0 TCustomWinSocket.Destroy - 0001:0006313C TCustomWinSocket.Accept - 0001:00063140 TCustomWinSocket.AsyncInitSocket - 0001:000633F8 TCustomWinSocket.Close - 0001:00063404 TCustomWinSocket.Connect - 0001:00063408 TCustomWinSocket.Lock - 0001:00063414 TCustomWinSocket.Unlock - 0001:00063420 CheckError - 0001:000634D8 TCustomWinSocket.CMSocketMessage - 0001:00063564 TCustomWinSocket.CMDeferFree - 0001:0006356C TCustomWinSocket.DeferFree - 0001:00063584 TCustomWinSocket.DoSetAsyncStyles - 0001:000635E0 TCustomWinSocket.DoListen - 0001:00063660 TCustomWinSocket.DoOpen - 0001:000636CC TCustomWinSocket.GetHandle - 0001:000636E8 TCustomWinSocket.LookupName - 0001:00063744 TCustomWinSocket.LookupService - 0001:00063778 TCustomWinSocket.InitSocket - 0001:00063810 TCustomWinSocket.Listen - 0001:00063918 TCustomWinSocket.Open - 0001:00063A18 TCustomWinSocket.Disconnect - 0001:00063B24 TCustomWinSocket.DefaultHandler - 0001:00063B50 TCustomWinSocket.Event - 0001:00063B68 TCustomWinSocket.Error - 0001:00063B8C DropStream - 0001:00063BD4 TCustomWinSocket.SendStreamPiece - 0001:00063D5C TCustomWinSocket.SetAsyncStyles - 0001:00063D84 TCustomWinSocket.Read - 0001:00063DA0 TCustomWinSocket.ReceiveBuf - 0001:00063F0C TCustomWinSocket.ReceiveText - 0001:00063F48 TCustomWinSocket.WndProc - 0001:00063F9C TCustomWinSocket.Write - 0001:00063FCC TCustomWinSocket.CMLookupComplete - 0001:00064124 TClientWinSocket.Connect - 0001:00064138 TClientWinSocket.SetClientType - 0001:00064188 TServerClientWinSocket.Create - 0001:00064234 TServerClientWinSocket.Destroy - 0001:00064268 TServerWinSocket.Create - 0001:000642DC TServerWinSocket.Destroy - 0001:0006431C TServerWinSocket.AddClient - 0001:00064384 TServerWinSocket.RemoveClient - 0001:000643D8 TServerWinSocket.AddThread - 0001:00064454 TServerWinSocket.RemoveThread - 0001:000644A8 TServerWinSocket.ClientEvent - 0001:000644FC TServerWinSocket.ClientError - 0001:00064518 TServerWinSocket.Accept - 0001:0006461C TServerWinSocket.Disconnect - 0001:00064734 TServerWinSocket.DoCreateThread - 0001:00064744 TServerWinSocket.Listen - 0001:00064790 TServerWinSocket.SetServerType - 0001:000647E0 TServerWinSocket.SetThreadCacheSize - 0001:0006487C TServerWinSocket.GetClientSocket - 0001:000648BC TServerWinSocket.ThreadEnd - 0001:000648DC TServerWinSocket.ThreadStart - 0001:000648FC TServerWinSocket.GetServerThread - 0001:000649D0 TServerWinSocket.ClientConnect - 0001:000649F0 TServerWinSocket.ClientDisconnect - 0001:00064A20 TServerWinSocket.ClientRead - 0001:00064A40 TServerWinSocket.ClientWrite - 0001:00064A60 TServerWinSocket.ClientErrorEvent - 0001:00064A8C TServerAcceptThread.Create - 0001:00064AD0 TServerAcceptThread.Execute - 0001:00064AEC TServerClientThread.Create - 0001:00064B64 TServerClientThread.Destroy - 0001:00064B9C TServerClientThread.ReActivate - 0001:00064BD8 TServerClientThread.DoHandleException - 0001:00064C24 TServerClientThread.DoRead - 0001:00064C40 TServerClientThread.DoTerminate - 0001:00064C5C TServerClientThread.DoWrite - 0001:00064C70 TServerClientThread.HandleEvent - 0001:00064C80 TServerClientThread.HandleError - 0001:00064C94 TServerClientThread.Event - 0001:00064CA4 TServerClientThread.Error - 0001:00064CB8 TServerClientThread.HandleException - 0001:00064D20 TServerClientThread.Execute - 0001:00064DC8 TServerClientThread.ClientExecute - 0001:00064E70 TServerClientThread.StartConnect - 0001:00064E94 TServerClientThread.EndConnect - 0001:00064EB8 TAbstractSocket.DoEvent - 0001:00064ECC TAbstractSocket.DoError - 0001:00064EE4 TAbstractSocket.SetActive - 0001:00064F04 TAbstractSocket.InitSocket - 0001:00064F1C TAbstractSocket.Loaded - 0001:00064F34 TAbstractSocket.SetAddress - 0001:00064FB4 TAbstractSocket.SetHost - 0001:00065034 TAbstractSocket.SetPort - 0001:00065060 TAbstractSocket.SetService - 0001:000650E0 TAbstractSocket.Open - 0001:000650E8 TCustomSocket.Event - 0001:000651E8 TCustomSocket.Error - 0001:00065214 TClientSocket.Create - 0001:00065274 TClientSocket.Destroy - 0001:000652A4 TClientSocket.DoActivate - 0001:000652F4 TClientSocket.GetClientType - 0001:00065300 TClientSocket.SetClientType - 0001:0006530C TCustomServerSocket.Destroy - 0001:0006533C TCustomServerSocket.DoActivate - 0001:00065380 TCustomServerSocket.GetServerType - 0001:0006538C TCustomServerSocket.SetServerType - 0001:00065398 TCustomServerSocket.GetGetThreadEvent - 0001:000653AC TCustomServerSocket.SetGetThreadEvent - 0001:000653C8 TCustomServerSocket.GetGetSocketEvent - 0001:000653DC TCustomServerSocket.SetGetSocketEvent - 0001:000653F8 TCustomServerSocket.GetThreadCacheSize - 0001:00065404 TCustomServerSocket.SetThreadCacheSize - 0001:00065410 TCustomServerSocket.GetOnThreadStart - 0001:00065428 TCustomServerSocket.GetOnThreadEnd - 0001:00065440 TCustomServerSocket.SetOnThreadStart - 0001:00065460 TCustomServerSocket.SetOnThreadEnd - 0001:00065480 TCustomServerSocket.GetOnClientEvent - 0001:000654F8 TCustomServerSocket.SetOnClientEvent - 0001:00065574 TCustomServerSocket.GetOnClientError - 0001:0006558C TCustomServerSocket.SetOnClientError - 0001:000655AC TServerSocket.Create - 0001:0006561C Finalization - 0001:0006564C ScktComp - 0001:00065654 Finalization - 0001:00065684 JvWin32 - 0001:0006568C Finalization - 0001:000656BC JvConsts - 0001:000656F8 Finalization - 0001:00065728 JVCLVer - 0001:00065810 Finalization - 0001:00065840 JvComponentBase - 0001:00065848 SecondsBetween - 0001:00065878 SpanOfNowAndThen - 0001:000658A8 SecondSpan - 0001:000658D8 Finalization - 0001:00065908 DateUtils - 0001:00065B90 Finalization - 0001:00065BC0 JvResources - 0001:00066318 Finalization - 0001:0006665C JvTypes - 0001:00066670 Finalization - 0001:000666A0 JvVCL5Utils - 0001:000666C8 Finalization - 0001:000666F8 ComConst - 0001:0006686C TrimPunctuation - 0001:000668BC EOleSysError.Create - 0001:0006698C EOleException.Create - 0001:00066A24 OleError - 0001:00066A40 OleCheck - 0001:00066A58 LoadComExProcs - 0001:00066B5C SafeCallError - 0001:00066C5C DispatchInvoke - 0001:00066FA0 RaiseNameException - 0001:00066FD4 GetIDsOfNames - 0001:000670B4 RaiseException - 0001:000670CC VarDispInvoke - 0001:00067168 DispCallError - 0001:0006723C DispatchInvokeError - 0001:00067248 ClearExcepInfo - 0001:00067258 DispCall - 0001:0006733C DispCallByID - 0001:00067418 InitComObj - 0001:00067490 Finalization - 0001:00067510 ComObj - 0001:00067568 Finalization - 0001:00067598 MMSystem - 0001:000675B8 Finalization - 0001:00067600 Registry - 0001:000676D4 GetFileVersion - 0001:000677BC GetShellVersion - 0001:00067830 GetAnimation - 0001:00067860 SetAnimation - 0001:00067888 ShowWinNoAnimate - 0001:000678B8 Finalization - 0001:00067954 JvJCLUtils - 0001:0006795C Finalization - 0001:0006798C RichEdit - 0001:00067994 Finalization - 0001:000679C4 ToolWin - 0001:000679F4 Finalization - 0001:00067A24 ComStrs - 0001:00067A2C DestroyLocals - 0001:00067AC4 Finalization - 0001:00067AFC Buttons - 0001:00067B24 Finalization - 0001:00067B54 ExtDlgs - 0001:00067B70 Finalization - 0001:00067BC0 Mapi - 0001:00067BC8 Finalization - 0001:00067C18 ExtActns - 0001:000688F4 TListControlItem.Assign - 0001:0006897C TListControlItem.Changed - 0001:0006898C TListControlItem.Create - 0001:000689C8 TListControlItem.GetDisplayName - 0001:000689F4 TListControlItem.SetCaption - 0001:00068A10 TListControlItem.SetData - 0001:00068A1C TListControlItem.SetImageIndex - 0001:00068A28 ListItemsCompare - 0001:00068A54 TListControlItems.Add - 0001:00068A64 TListControlItems.CustomSort - 0001:00068A94 TListControlItems.CompareItems - 0001:00068AD0 TListControlItems.ExchangeItems - 0001:00068B2C TListControlItems.QuickSort - 0001:00068BC0 TListControlItems.GetListItem - 0001:00068BD4 TListControlItems.SetSortType - 0001:00068BEC TListControlItems.Sort - 0001:00068BF8 TCustomListAction.Create - 0001:00068C50 TCustomListAction.ExecuteTarget - 0001:00068D78 TCustomListAction.GetCount - 0001:00068DA4 TCustomListAction.GetString - 0001:00068DB0 TCustomListAction.HandlesTarget - 0001:00068DB4 TCustomListAction.Loaded - 0001:00068DE8 TCustomListAction.SetActive - 0001:00068EE8 TCustomListAction.SetImages - 0001:00068F54 TCustomListAction.SetItemIndex - 0001:00068FB0 TCustomListAction.SetString - 0001:00068FB4 TVirtualListAction.GetItem - 0001:00069004 TStaticListItems.Notify - 0001:000691B4 TStaticListItems.Update - 0001:000692D0 TStaticListAction.Create - 0001:00069330 TStaticListAction.Destroy - 0001:00069360 TStaticListAction.GetCount - 0001:0006936C TStaticListAction.GetItem - 0001:000693D0 TStaticListAction.GetItemClass - 0001:000693D8 TStaticListAction.GetString - 0001:000693FC TStaticListAction.SetListitems - 0001:0006940C TStaticListAction.SetString - 0001:00069430 TListActionLink.IsActiveLinked - 0001:00069444 TListActionLink.IsImagesLinked - 0001:00069470 TListActionLink.SetAction - 0001:000694B4 TListActionLink.SetActive - 0001:00069520 TListActionLink.SetImages - 0001:00069524 TListActionLink.RefreshControl - 0001:00069678 TListActionLink.AddItem - 0001:0006967C TListActionLink.AddItem - 0001:000696A8 TListActionLink.SetItemIndex - 0001:000696E0 Finalization - 0001:00069710 ListActns - 0001:0006BF14 InitCommonControl - 0001:0006BF40 CheckCommonControl - 0001:0006BF68 TTextAttributes.Create - 0001:0006BFB0 TTextAttributes.InitFormat - 0001:0006BFCC TTextAttributes.GetAttributes - 0001:0006C00C TTextAttributes.SetAttributes - 0001:0006C048 TTextAttributes.GetCharset - 0001:0006C05C TTextAttributes.SetCharset - 0001:0006C08C TTextAttributes.GetColor - 0001:0006C0AC TTextAttributes.SetColor - 0001:0006C0F4 TTextAttributes.GetName - 0001:0006C118 TTextAttributes.SetName - 0001:0006C188 TTextAttributes.GetStyle - 0001:0006C1D8 TTextAttributes.SetStyle - 0001:0006C230 TTextAttributes.GetSize - 0001:0006C24C TTextAttributes.SetSize - 0001:0006C284 TTextAttributes.GetPitch - 0001:0006C2B4 TTextAttributes.SetPitch - 0001:0006C2F4 TTextAttributes.Assign - 0001:0006C434 TTextAttributes.AssignTo - 0001:0006C564 TParaAttributes.Create - 0001:0006C5A0 TParaAttributes.InitPara - 0001:0006C5BC TParaAttributes.GetAttributes - 0001:0006C5F0 TParaAttributes.SetAttributes - 0001:0006C654 TParaAttributes.GetAlignment - 0001:0006C670 TParaAttributes.SetAlignment - 0001:0006C6AC TParaAttributes.GetNumbering - 0001:0006C6C4 TParaAttributes.SetNumbering - 0001:0006C728 TParaAttributes.GetFirstIndent - 0001:0006C748 TParaAttributes.SetFirstIndent - 0001:0006C784 TParaAttributes.GetLeftIndent - 0001:0006C7A4 TParaAttributes.SetLeftIndent - 0001:0006C7E0 TParaAttributes.GetRightIndent - 0001:0006C800 TParaAttributes.SetRightIndent - 0001:0006C83C TParaAttributes.GetTab - 0001:0006C864 TParaAttributes.SetTab - 0001:0006C8B8 TParaAttributes.Assign - 0001:0006C954 TConversion.ConvertReadStream - 0001:0006C968 TConversion.ConvertWriteStream - 0001:0006CA88 TRichEditStrings.Destroy - 0001:0006CAB8 TRichEditStrings.AddStrings - 0001:0006CB30 TRichEditStrings.GetCount - 0001:0006CB88 TRichEditStrings.Get - 0001:0006CBDC TRichEditStrings.Put - 0001:0006CC68 TRichEditStrings.Insert - 0001:0006CDF4 TRichEditStrings.Delete - 0001:0006CEA0 TRichEditStrings.Clear - 0001:0006CEB0 TRichEditStrings.SetUpdateState - 0001:0006CF00 TRichEditStrings.EnableChange - 0001:0006CF5C TRichEditStrings.SetTextStr - 0001:0006CFAC AdjustLineBreaks - 0001:0006CFE0 StreamSave - 0001:0006D040 StreamLoad - 0001:0006D134 TRichEditStrings.LoadFromStream - 0001:0006D298 TRichEditStrings.SaveToStream - 0001:0006D3A8 TRichEditStrings.LoadFromFile - 0001:0006D4B0 TRichEditStrings.SaveToFile - 0001:0006D5A4 TCustomRichEdit.Create - 0001:0006D6C0 TCustomRichEdit.Destroy - 0001:0006D71C TCustomRichEdit.Clear - 0001:0006D734 TCustomRichEdit.CreateParams - 0001:0006D7C0 TCustomRichEdit.CreateWnd - 0001:0006D8E8 TCustomRichEdit.DestroyWnd - 0001:0006D9B4 TCustomRichEdit.WMNCDestroy - 0001:0006D9BC TCustomRichEdit.WMSetFont - 0001:0006D9CC TCustomRichEdit.WMRButtonUp - 0001:0006DA24 TCustomRichEdit.CMFontChanged - 0001:0006DA34 TCustomRichEdit.DoSetMaxLength - 0001:0006DA54 TCustomRichEdit.GetCaretPos - 0001:0006DAB4 TCustomRichEdit.SetCaretPos - 0001:0006DB00 TCustomRichEdit.GetSelLength - 0001:0006DB28 TCustomRichEdit.GetSelStart - 0001:0006DB4C TCustomRichEdit.GetSelTextBuf - 0001:0006DBC0 TCustomRichEdit.GetSelText - 0001:0006DC04 TCustomRichEdit.CMBiDiModeChanged - 0001:0006DC5C TCustomRichEdit.SetHideScrollBars - 0001:0006DC70 TCustomRichEdit.SetHideSelection - 0001:0006DCA0 TCustomRichEdit.SetSelLength - 0001:0006DCFC TCustomRichEdit.GetPlainText - 0001:0006DD08 TCustomRichEdit.SetPlainText - 0001:0006DD14 TCustomRichEdit.CMColorChanged - 0001:0006DD40 TCustomRichEdit.SetRichEditStrings - 0001:0006DD50 TCustomRichEdit.SetSelStart - 0001:0006DD78 TCustomRichEdit.Print - 0001:0006DF50 TCustomRichEdit.WMPaint - 0001:0006E010 TCustomRichEdit.WMSetCursor - 0001:0006E0A0 TCustomRichEdit.CNNotify - 0001:0006E11C TCustomRichEdit.SaveClipboard - 0001:0006E14C TCustomRichEdit.ProtectChange - 0001:0006E17C TCustomRichEdit.SelectionChange - 0001:0006E19C TCustomRichEdit.RequestSize - 0001:0006E1BC TListColumn.Create - 0001:0006E264 TListColumn.Destroy - 0001:0006E2C4 TListColumn.DefineProperties - 0001:0006E30C TListColumn.ReadData - 0001:0006E334 TListColumn.WriteData - 0001:0006E358 WriteCols - 0001:0006E454 TListColumn.DoChange - 0001:0006E4D4 TListColumn.SetIndex - 0001:0006E584 TListColumn.SetCaption - 0001:0006E5AC TListColumn.GetWidth - 0001:0006E5D8 TListColumn.IsWidthStored - 0001:0006E5E0 TListColumn.SetWidth - 0001:0006E60C TListColumn.SetAlignment - 0001:0006E644 TListColumn.SetAutoSize - 0001:0006E678 TListColumn.SetImageIndex - 0001:0006E688 TListColumn.SetMaxWidth - 0001:0006E698 TListColumn.SetMinWidth - 0001:0006E6A8 TListColumn.Assign - 0001:0006E71C TListColumn.GetDisplayName - 0001:0006E740 TListColumns.Create - 0001:0006E784 TListColumns.GetItem - 0001:0006E798 TListColumns.Owner - 0001:0006E79C TListColumns.GetOwner - 0001:0006E7A0 TListColumns.Update - 0001:0006E7D4 TListColumns.UpdateCols - 0001:0006E8C0 TWorkArea.Create - 0001:0006E904 TWorkArea.GetDisplayName - 0001:0006E918 TWorkArea.SetDisplayName - 0001:0006E958 TWorkAreas.Update - 0001:0006EA20 TWorkAreas.GetItem - 0001:0006EB48 TSubItems.Create - 0001:0006EB94 TSubItems.Destroy - 0001:0006EBC4 TSubItems.Add - 0001:0006EBEC TSubItems.AddObject - 0001:0006EC14 TSubItems.Clear - 0001:0006EC28 TSubItems.Delete - 0001:0006EC4C TSubItems.GetHandle - 0001:0006EC58 TSubItems.SetColumnWidth - 0001:0006EC9C TSubItems.Insert - 0001:0006ECDC TSubItems.Put - 0001:0006ECF8 TSubItems.RefreshItem - 0001:0006ED24 TSubItems.SetUpdateState - 0001:0006ED30 TSubItems.GetImageIndex - 0001:0006ED44 TSubItems.SetImageIndex - 0001:0006ED50 TListItem.Create - 0001:0006EDA0 TListItem.Destroy - 0001:0006EE0C TListItem.GetListView - 0001:0006EE14 TListItem.Delete - 0001:0006EE38 TListItem.GetHandle - 0001:0006EE4C TListItem.GetChecked - 0001:0006EE90 TListItem.SetChecked - 0001:0006EEDC TListItem.Update - 0001:0006EEF8 TListItem.SetCaption - 0001:0006EFA8 TListItem.SetData - 0001:0006EFD8 TListItem.GetState - 0001:0006F040 TListItem.SetState - 0001:0006F0B0 TListItem.SetImage - 0001:0006F1EC TListItem.SetIndent - 0001:0006F258 TListItem.Assign - 0001:0006F2F0 TListItem.IsEqual - 0001:0006F318 TListItem.SetSubItems - 0001:0006F32C TListItem.GetIndex - 0001:0006F348 TListItem.DisplayRect - 0001:0006F378 TListItem.GetSubItemImage - 0001:0006F384 TListItem.SetSubItemImage - 0001:0006F3F0 TListItems.Create - 0001:0006F42C TListItems.Destroy - 0001:0006F458 TListItems.Add - 0001:0006F464 TListItems.AddItem - 0001:0006F4B4 TListItems.GetCount - 0001:0006F4D8 TListItems.GetHandle - 0001:0006F4E4 TListItems.GetItem - 0001:0006F564 TListItems.IndexOf - 0001:0006F58C TListItems.SetCount - 0001:0006F5A8 TListItems.Clear - 0001:0006F5C8 TListItems.BeginUpdate - 0001:0006F5E0 TListItems.SetUpdateState - 0001:0006F7A4 TListItems.EndUpdate - 0001:0006F7B8 TListItems.Assign - 0001:0006F818 WriteItems - 0001:0006F8A8 TListItems.DefineProperties - 0001:0006F900 TListItems.ReadData - 0001:0006FAF8 GetLength - 0001:0006FB0C TListItems.WriteData - 0001:0006FDB0 TListItems.Delete - 0001:0006FDC8 TListItems.CreateItem - 0001:0006FDEC TIconOptions.Create - 0001:0006FE60 TIconOptions.SetArrangement - 0001:0006FE74 TIconOptions.SetAutoArrange - 0001:0006FE88 TIconOptions.SetWrapText - 0001:0006FE9C DefaultListViewSort - 0001:0006FF08 TCustomListView.Create - 0001:000700F0 TCustomListView.Destroy - 0001:000701F0 TCustomListView.CreateParams - 0001:0007031C ReadCols - 0001:000703D0 TCustomListView.CreateWnd - 0001:000705B8 TCustomListView.DestroyWnd - 0001:00070634 TCustomListView.SetImageList - 0001:0007065C TCustomListView.ImageListChange - 0001:000706D0 TCustomListView.Notification - 0001:00070744 UpdateColumnOrder - 0001:00070880 TCustomListView.HeaderWndProc - 0001:00070978 TCustomListView.EditWndProc - 0001:00070A78 TCustomListView.UpdateItems - 0001:00070A98 TCustomListView.ResetExStyles - 0001:00070B94 TCustomListView.RestoreChecks - 0001:00070C20 TCustomListView.SaveChecks - 0001:00070CA4 TCustomListView.SetCheckboxes - 0001:00070D24 TCustomListView.SetBorderStyle - 0001:00070D38 TCustomListView.SetColumnClick - 0001:00070D4C TCustomListView.SetItemIndex - 0001:00070D94 TCustomListView.SetMultiSelect - 0001:00070DA8 TCustomListView.SetColumnHeaders - 0001:00070DBC TCustomListView.SetTextColor - 0001:00070DDC TCustomListView.SetTextBkColor - 0001:00070E10 TCustomListView.SetAllocBy - 0001:00070E40 TCustomListView.CMColorChanged - 0001:00070E64 TCustomListView.CMCtl3DChanged - 0001:00070E88 TCustomListView.WMNotify - 0001:000710AC TCustomListView.ColumnsShowing - 0001:000710B8 TCustomListView.ValidHeaderHandle - 0001:000710C4 TCustomListView.CMFontChanged - 0001:00071104 TCustomListView.SetHideSelection - 0001:00071118 TCustomListView.SetViewStyle - 0001:0007119C TCustomListView.WMParentNotify - 0001:000711EC TCustomListView.GetItemIndex - 0001:00071214 TCustomListView.OwnerDataFetch - 0001:0007123C TCustomListView.OwnerDataFind - 0001:00071288 TCustomListView.OwnerDataHint - 0001:000712B0 TCustomListView.OwnerDataStateChange - 0001:000712E4 TCustomListView.CreateListItem - 0001:00071320 TCustomListView.CreateListItems - 0001:00071330 ConvertMask - 0001:0007137C TCustomListView.GetItem - 0001:000714AC TCustomListView.GetSelCount - 0001:000714C0 ConvertFlags - 0001:000714E4 ConvertStates - 0001:00071530 TCustomListView.CNNotify - 0001:000721F0 TCustomListView.ChangeScale - 0001:00072264 TCustomListView.ColClick - 0001:00072284 TCustomListView.ColRightClick - 0001:000722B4 TCustomListView.InsertItem - 0001:000722D4 TCustomListView.AddItem - 0001:0007233C TCustomListView.CanChange - 0001:00072384 TCustomListView.Change - 0001:000723BC TCustomListView.Delete - 0001:000723F4 TCustomListView.CanEdit - 0001:00072420 TCustomListView.Edit - 0001:000724A0 TCustomListView.GetDragImages - 0001:000724BC TCustomListView.WndProc - 0001:0007253C TCustomListView.DoStartDrag - 0001:00072610 TCustomListView.DoEndDrag - 0001:0007263C TCustomListView.CMDrag - 0001:00072770 TCustomListView.DoDragOver - 0001:000727F8 TCustomListView.AlphaSort - 0001:00072828 TCustomListView.SetSortType - 0001:00072860 TCustomListView.GetViewOrigin - 0001:00072878 TCustomListView.GetTopItem - 0001:000728B0 TCustomListView.SetLargeImages - 0001:00072920 TCustomListView.SetSmallImages - 0001:00072998 TCustomListView.SetStateImages - 0001:00072A54 TCustomListView.GetColumnFromIndex - 0001:00072A60 TCustomListView.GetSelected - 0001:00072A78 TCustomListView.GetDropTarget - 0001:00072A9C TCustomListView.SetDropTarget - 0001:00072AE0 TCustomListView.GetImageIndex - 0001:00072B00 TCustomListView.GetNextItem - 0001:00072BD4 TCustomListView.GetNearestItem - 0001:00072C3C TCustomListView.GetItemAt - 0001:00072CA0 TCustomListView.Arrange - 0001:00072CC0 TCustomListView.UpdateColumns - 0001:00072D00 TCustomListView.UpdateColumn - 0001:00072E50 TCustomListView.WMLButtonDown - 0001:00072FB4 TCustomListView.DoAutoSize - 0001:00073148 TCustomListView.WMWindowPosChanged - 0001:0007317C TCustomListView.CNDrawItem - 0001:000732AC TCustomListView.CanvasChanged - 0001:000732B4 TCustomListView.IsCustomDrawn - 0001:000733BC TCustomListView.CustomDraw - 0001:00073414 TCustomListView.CustomDrawItem - 0001:00073484 TCustomListView.CustomDrawSubItem - 0001:000734FC TCustomListView.DrawItem - 0001:00073574 TCustomListView.GetSubItemImage - 0001:000735B8 TCustomListView.DrawWorkAreas - 0001:00073720 TCustomListView.WMPaint - 0001:00073748 TCustomListView.CMHintShow - 0001:00073870 TCustomListView.DoInfoTip - 0001:00073890 TCustomListView.MouseUp - 0001:000738D4 TCustomListView.GetColumnFromTag - 0001:00073910 TCustomListView.WMContextMenu - 0001:00073988 TCustomListView.ClearSelection - 0001:000739C4 TCustomListView.CopySelection - 0001:00073A38 TCustomListView.DeleteSelected - 0001:00073AE0 TCustomListView.GetCount - 0001:00073AEC TCustomListView.SelectAll - 0001:00073B28 TCustomListView.Clear - 0001:00073B80 TCustomListView.GetActionLinkClass - 0001:00073B88 TCustomListView.ActionChange - 0001:00073BEC TComboExItem.Assign - 0001:00073C38 TComboExItem.SetCaption - 0001:00073C6C TComboExItem.SetData - 0001:00073CA0 TComboExItem.SetDisplayName - 0001:00073CC0 TComboExItem.SetImageIndex - 0001:00073CF0 TComboExItem.SetIndex - 0001:00073D0C TComboExItem.SetOverlayImageIndex - 0001:00073D28 TComboExItem.SetSelectedImageIndex - 0001:00073D44 TComboExItems.Add - 0001:00073D50 TComboExItems.AddItem - 0001:00073DB8 TComboExItems.GetComboItem - 0001:00073DCC TComboExItems.Insert - 0001:00073DE0 TComboExItems.Notify - 0001:00073E50 TComboExItems.SetItem - 0001:00073F34 TCustomComboBoxEx.Create - 0001:00073FE4 TCustomComboBoxEx.Destroy - 0001:0007404C TCustomComboBoxEx.CNNotify - 0001:0007409C TCustomComboBoxEx.CreateParams - 0001:00074114 TCustomComboBoxEx.SetImages - 0001:000741A8 TCustomComboBoxEx.ImageListChange - 0001:000741D4 TCustomComboBoxEx.WndProc - 0001:0007421C TCustomComboBoxEx.Notification - 0001:0007424C TCustomComboBoxEx.SetStyle - 0001:00074294 TCustomComboBoxEx.CMParentColorChanged - 0001:000742BC TCustomComboBoxEx.CMColorChanged - 0001:0007431C TCustomComboBoxEx.WMLButtonDown - 0001:00074394 TCustomComboBoxEx.ComboExWndProc - 0001:000743B4 TCustomComboBoxEx.CreateWnd - 0001:00074604 TCustomComboBoxEx.GetItemCount - 0001:00074610 TCustomComboBoxEx.GetItemsClass - 0001:00074618 TCustomComboBoxEx.SetItemsEx - 0001:00074628 TCustomComboBoxEx.GetActionLinkClass - 0001:00074630 TCustomComboBoxEx.SetStyleEx - 0001:00074690 TCustomComboBoxEx.IsItemsExStored - 0001:000746C8 TCustomComboBoxEx.ActionChange - 0001:0007472C TCustomComboBoxEx.SetDropDownCount - 0001:00074768 TCustomComboBoxEx.GetDropDownCount - 0001:00074770 TCustomComboBoxEx.GetItemHt - 0001:00074778 TCustomComboBoxEx.DestroyWnd - 0001:000747C8 TCustomComboBoxEx.Focused - 0001:00074804 TComboBoxExStrings.Add - 0001:00074828 TComboBoxExStrings.AddObject - 0001:00074858 TComboBoxExStrings.Clear - 0001:000748C0 TComboBoxExStrings.Create - 0001:0007491C TComboBoxExStrings.Destroy - 0001:0007494C TComboBoxExStrings.Delete - 0001:00074958 TComboBoxExStrings.Exchange - 0001:00074AA4 TComboBoxExStrings.Get - 0001:00074AC8 TComboBoxExStrings.GetCapacity - 0001:00074AD4 TComboBoxExStrings.GetCount - 0001:00074AE0 TComboBoxExStrings.GetObject - 0001:00074AF8 TComboBoxExStrings.IndexOf - 0001:00074B44 TComboBoxExStrings.IndexOfName - 0001:00074B4C TComboBoxExStrings.Insert - 0001:00074B60 TComboBoxExStrings.Move - 0001:00074B80 TComboBoxExStrings.Put - 0001:00074B94 TComboBoxExStrings.PutObject - 0001:00074BA8 TComboBoxExStrings.SetUpdateState - 0001:00074BE8 TComboBoxExStrings.GetItemsClass - 0001:00074BF0 TComboBoxExStrings.GetItemClass - 0001:00074BF8 TListViewActionLink.AddItem - 0001:00074C70 TListViewActionLink.AddItem - 0001:00074CA8 TListViewActionLink.SetImages - 0001:00074CDC TComboBoxExActionLink.AddItem - 0001:00074D4C TComboBoxExActionLink.AddItem - 0001:00074D80 Finalization - 0001:00074DF8 ComCtrls - 0001:00074E00 Finalization - 0001:00074E30 MaskUtils - 0001:00074E38 Finalization - 0001:00074E68 Mask - 0001:00074E70 Finalization - 0001:00074EA0 Grids - 0001:00075040 Finalization - 0001:00075070 JclResources - 0001:00075078 Finalization - 0001:000750A8 JclBase - 0001:000750B0 Finalization - 0001:000750E0 AccCtrl - 0001:000750E8 GetVersionEx - 0001:000750F0 Finalization - 0001:00075120 JclWin32 - 0001:00075128 Finalization - 0001:00075158 JclConsole - 0001:0007516C Finalization - 0001:000751B4 JclWideStrings - 0001:000751C8 Finalization - 0001:000751F8 JclLogic - 0001:00075200 LoadCharTypes - 0001:00075238 LoadCaseMap - 0001:000752B4 CharIsLower - 0001:000752C8 CharIsUpper - 0001:000752FC Finalization - 0001:00075344 JclStrings - 0001:00075358 Finalization - 0001:00075388 Jcl8087 - 0001:00075390 Finalization - 0001:000753C0 JclMath - 0001:000753E4 UnloadModule - 0001:000753FC Finalization - 0001:00075444 JclSysUtils - 0001:0007544C Finalization - 0001:0007547C Snmp - 0001:00075484 Finalization - 0001:000754B4 TlHelp32 - 0001:000754BC Finalization - 0001:000754EC PsAPI - 0001:000754F4 Finalization - 0001:00075524 JclRegistry - 0001:0007552C Finalization - 0001:0007555C JclIniFiles - 0001:00075584 GetWindowsVersion - 0001:00075770 GetNativeSystemInfo - 0001:00075810 UnloadSystemResourcesMeterLib - 0001:00075834 InitSysInfo - 0001:00075A10 FinalizeSysInfo - 0001:00075BB4 Finalization - 0001:00075C00 JclSysInfo - 0001:00075C1C Finalization - 0001:00075C58 JclShell - 0001:00075C60 Finalization - 0001:00075C90 JclSecurity - 0001:00075C98 Finalization - 0001:00075CC8 JclDateTime - 0001:00075CD0 GetModulePath - 0001:00075D00 VersionFixedFileInfo - 0001:00075DBC Finalization - 0001:00075DEC JclFileUtils - 0001:00075DF4 FreeTypeData - 0001:00075E44 DeleteType - 0001:00075E68 ClearInfoList - 0001:00075EC4 RemoveTypeInfo - 0001:00075F58 Finalization - 0001:00075F98 JclRTTI - 0001:00075FB4 Finalization - 0001:00075FE4 JclMime - 0001:0007616C Finalization - 0001:000761B4 JvPropertyStore - 0001:00076238 TJvAppStoragePropertyEngineList.Destroy - 0001:00076288 CreateAppStoragePropertyEngineList - 0001:0007629C DestroyAppStoragePropertyEngineList - 0001:000762B0 Finalization - 0001:000762E8 JvAppStorage - 0001:000762F8 Finalization - 0001:00076334 JvProgressUtils - 0001:000763F0 StdWndProc - 0001:00076454 AllocateHWndEx - 0001:00076538 DeallocateHWndEx - 0001:00076540 InitScreenCursors - 0001:0007661C Finalization - 0001:00076678 JvJVCLUtils - 0001:00076B6C IsApplicationMinimized - 0001:00076B84 UnloadKernel32Dll - 0001:00076BA8 LoadKernel32Dll - 0001:00076C10 GetTrayHandle - 0001:00076C54 AnimateToTray - 0001:00076C90 AnimateFromTray - 0001:00076CC8 TJvTrayIcon.Create - 0001:00076DB0 TJvTrayIcon.Destroy - 0001:00076E28 TJvTrayIcon.AcceptBalloons - 0001:00076E38 TJvTrayIcon.ApplicationHook - 0001:00076E60 TJvTrayIcon.BalloonHint - 0001:00076FB4 TJvTrayIcon.DoAnimation - 0001:00077028 TJvTrayIcon.DoClick - 0001:000770CC TJvTrayIcon.DoCloseBalloon - 0001:000770E4 TJvTrayIcon.DoContextPopup - 0001:00077164 TJvTrayIcon.DoDoubleClick - 0001:00077240 TJvTrayIcon.DoMouseDown - 0001:00077280 TJvTrayIcon.DoMouseMove - 0001:00077340 HasSingleClickFunctionality - 0001:0007739C HasDoubleClickFunctionality - 0001:000773E0 TJvTrayIcon.DoMouseUp - 0001:000774D8 TJvTrayIcon.DoTimerDblClick - 0001:00077514 TJvTrayIcon.EndAnimation - 0001:00077530 TJvTrayIcon.GetApplicationVisible - 0001:0007754C TJvTrayIcon.GetSystemMinimumBalloonDelay - 0001:00077554 TJvTrayIcon.HideApplication - 0001:000775F4 TJvTrayIcon.HideBalloon - 0001:00077620 TJvTrayIcon.HideTrayIcon - 0001:00077644 TJvTrayIcon.Hook - 0001:0007766C TJvTrayIcon.IconChanged - 0001:00077674 TJvTrayIcon.IconPropertyChanged - 0001:00077738 TJvTrayIcon.InitIconData - 0001:00077814 TJvTrayIcon.Loaded - 0001:00077894 TJvTrayIcon.Notification - 0001:000778E4 TJvTrayIcon.NotifyIcon - 0001:00077900 TJvTrayIcon.SetActive - 0001:0007795C TJvTrayIcon.SetAnimated - 0001:00077980 TJvTrayIcon.SetCurrentIcon - 0001:000779B0 TJvTrayIcon.SetDelay - 0001:00077A1C TJvTrayIcon.SetHint - 0001:00077ADC TJvTrayIcon.SetIcon - 0001:00077AE8 TJvTrayIcon.SetIconIndex - 0001:00077AFC TJvTrayIcon.SetIcons - 0001:00077B10 TJvTrayIcon.SetTask - 0001:00077B60 TJvTrayIcon.SetVisibility - 0001:00077C50 TJvTrayIcon.ShowApplication - 0001:00077D18 TJvTrayIcon.ShowTrayIcon - 0001:00077D8C TJvTrayIcon.StartAnimation - 0001:00077DC8 TJvTrayIcon.StopTimer - 0001:00077DDC TJvTrayIcon.Unhook - 0001:00077E00 TJvTrayIcon.WndProc - 0001:00078238 Finalization - 0001:00078270 JvTrayIcon - 0001:00078278 AddColouredLine - 0001:00078318 AddColourToLine - 0001:0007847C HexToColor - 0001:00078584 AddHilightedItem - 0001:000786B4 Finalization - 0001:000786E4 modRichEdit - 0001:000786EC EvaluateProperty - 0001:000787C8 Finalization - 0001:000787F8 modSCPUtils - 0001:00078CD0 MyLineOut - 0001:00078D20 TLogThread.AddMessage - 0001:00078D8C TLogThread.Create - 0001:00078DE8 TLogThread.Destroy - 0001:00078E20 TLogThread.Execute - 0001:00078EEC TLogThread.SyncWrite - 0001:00078F0C TLogThread.WriteFromPseWow - 0001:00079570 TfrmMain.FormCreate - 0001:000795B4 TfrmMain.btnRunClick - 0001:000796C4 TfrmMain.btnExitClick - 0001:000796CC TfrmMain.ShutDown - 0001:0007973C TfrmMain.Execute - 0001:0007980C TfrmMain.FormCloseQuery - 0001:00079828 TfrmMain.timerStartTimer - 0001:0007986C TfrmMain.servRemoteClientRead - 0001:00079928 TfrmMain.FormDestroy - 0001:00079950 TfrmMain.clientSockConnect - 0001:00079A14 TfrmMain.clientSockError - 0001:00079AC4 TfrmMain.Launch - 0001:00079B0C TfrmMain.Log - 0001:00079B94 TfrmMain.ConsoleResizeRequest - 0001:00079BE0 TfrmMain.comCommandKeyDown - 0001:00079C94 TfrmMain.clientSockConnecting - 0001:00079D2C TfrmMain.AddHistoryItem - 0001:00079D94 TfrmMain.ConsoleCommand - 0001:00079E58 TfrmMain.SetupIcons - 0001:00079EA4 TfrmMain.SetIcon - 0001:0007A008 TfrmMain.LoadSettings - 0001:0007A228 TfrmMain.cbexIconChange - 0001:0007A250 TfrmMain.LoadPseuSettings - 0001:0007A3F4 Finalization - 0001:0007A424 fMain - 0001:0007A42C Finalization - 0001:0007A7A4 PseuWoWConsole - 0002:00000000 ExitCode - 0002:00000004 ErrorAddr - 0002:00000008 FileMode - 0002:0000000C Default8087CW - 0002:00000010 HeapAllocFlags - 0002:00000014 DebugHook - 0002:00000018 JITEnable - 0002:0000001C NoErrMsg - 0002:00000020 DefaultTextLineBreakStyle - 0002:00000024 LibModuleList - 0002:00000028 ModuleUnloadList - 0002:0000002C MemoryManager - 0002:00000038 reMap - 0002:00000054 runErrMsg - 0002:00000074 errCaption - 0002:0000007C dig - 0002:0000008C Module - 0002:000000A4 EmptyStr - 0002:000000A8 EmptyWideStr - 0002:000000AC Win32Platform - 0002:000000B0 Win32MajorVersion - 0002:000000B4 Win32MinorVersion - 0002:000000B8 Win32BuildNumber - 0002:000000BC Win32CSDVersion - 0002:000000C0 TwoDigitYearCenturyWindow - 0002:000000C4 MonthDays - 0002:000000F4 LeadBytes - 0002:00000114 HexDisplayPrefix - 0002:00000118 GetDiskFreeSpaceEx - 0002:0000011C ExitProcList - 0002:00000120 cSimpleBoolStrs - 0002:00000128 AccessMode - 0002:00000134 ShareMode - 0002:00000148 FormatErrorStrs - 0002:00000150 FCon1E18 - 0002:0000015C DCon10 - 0002:00000160 CWNear - 0002:00000164 FMSecsPerDay - 0002:00000168 IMSecsPerDay - 0002:0000016C Format - 0002:00000170 DefShortMonthNames - 0002:000001A0 DefLongMonthNames - 0002:000001D0 DefShortDayNames - 0002:000001EC DefLongDayNames - 0002:00000208 ErrorMap - 0002:00000240 ExceptMap - 0002:000002F0 WesternGroups - 0002:000002F4 TerminateProcList - 0002:000002F8 CVarTypeToElementInfo - 0002:00000400 CResult - 0002:00000408 NullEqualityRule - 0002:0000040C NullMagnitudeRule - 0002:00000410 NullStrictConvert - 0002:00000414 NullAsStringValue - 0002:00000418 PackVarCreation - 0002:0000041C BooleanToStringRule - 0002:00000420 BaseTypeMap - 0002:00000438 CInvalidCustomVariantType - 0002:0000043C CRangeToType - 0002:00000450 OpTypeMap - 0002:000004B4 CBooleanToRelationship - 0002:000004C0 CmpTypeMap - 0002:00000524 CTruth - 0002:00000528 CText - 0002:0000057C CRelationshipToBoolean - 0002:00000590 BooleanIdents - 0002:00000598 DotSep - 0002:0000059C GUID_NULL - 0002:000005AC AddDataModule - 0002:000005B4 RemoveDataModule - 0002:000005BC ApplicationHandleException - 0002:000005C4 ApplicationShowException - 0002:000005CC WakeMainThread - 0002:000005D4 FilerSignature - 0002:000005D8 NilMethod - 0002:000005E0 Convert - 0002:000005F0 Convert - 0002:00000660 SyncList - 0002:00000664 Priorities - 0002:00000680 BlockCode - 0002:00000684 UtilWindowClass - 0002:000006AC DefFontData - 0002:000006D8 DDBsOnly - 0002:000006DC Colors - 0002:0000087C FontCharsets - 0002:0000090C DefPenData - 0002:0000091C PenStyles - 0002:0000092C DefBrushData - 0002:0000093C PenModes - 0002:0000095C ClipboardFormats - 0002:00000960 FileFormats - 0002:00000964 BitmapCanvasList - 0002:00000968 DIBPalSizes - 0002:0000096C PalSize - 0002:00000970 Pal16 - 0002:000009B0 FPrinter - 0002:000009B4 BorderStyles - 0002:000009BC Passwords - 0002:000009C4 ReadOnlys - 0002:000009CC CharCases - 0002:000009D8 HideSelections - 0002:000009E0 OEMConverts - 0002:000009E8 Empty - 0002:000009EC Alignments - 0002:00000A04 ScrollBar - 0002:00000A14 WordWraps - 0002:00000A1C ComboBoxStyles - 0002:00000A30 CharCases - 0002:00000A3C Sorts - 0002:00000A44 InnerStyles - 0002:00000A54 OuterStyles - 0002:00000A64 EdgeStyles - 0002:00000A74 Ctl3DStyles - 0002:00000A7C ButtonStyles - 0002:00000A84 Alignments - 0002:00000A94 Alignments - 0002:00000AAC Borders - 0002:00000AB8 BorderStyles - 0002:00000AC0 Alignments - 0002:00000ACC CreationControl - 0002:00000AD0 WndProcPtrAtom - 0002:00000AD4 Captions - 0002:00000AE8 ButtonNames - 0002:00000B14 ButtonCaptions - 0002:00000B40 AnimateWindowProc - 0002:00000B44 CreationControl - 0002:00000B48 DefaultDockTreeClass - 0002:00000B4C AnchorAlign - 0002:00000B54 Cursors - 0002:00000C04 CaptureControl - 0002:00000C08 ShowFlags - 0002:00000C0C WindowPos - 0002:00000C10 InnerStyles - 0002:00000C20 OuterStyles - 0002:00000C30 EdgeStyles - 0002:00000C40 Ctl3DStyles - 0002:00000C48 AnimationStyle - 0002:00000C54 OrientArray - 0002:00000C5C MakeLast - 0002:00000C64 TreeStreamEndFlag - 0002:00000C68 SizeCursors - 0002:00000C70 IMM32DLL - 0002:00000C74 ModeMap - 0002:00000C7C DrawingStyles - 0002:00000C8C Images - 0002:00000C94 Mask - 0002:00000C9C ValidMenuHotkeys - 0002:00000CA0 cMenuAutoFlagToItem - 0002:00000CA4 cItemAutoFlagToMenu - 0002:00000CA8 cBooleanToItemAutoFlag - 0002:00000CAC cItemAutoFlagToBoolean - 0002:00000CB0 MenuKeyCaps - 0002:00000CF8 Checks - 0002:00000D00 Enables - 0002:00000D08 Breaks - 0002:00000D14 Separators - 0002:00000D1C IBreaks - 0002:00000D28 IChecks - 0002:00000D30 IDefaults - 0002:00000D38 IEnables - 0002:00000D40 IRadios - 0002:00000D48 ISeparators - 0002:00000D50 IRTL - 0002:00000D58 IOwnerDraw - 0002:00000D60 Alignments - 0002:00000D68 EdgeStyle - 0002:00000D70 Alignments - 0002:00000D78 Flags - 0002:00000D84 Buttons - 0002:00000D88 HintWindowClass - 0002:00000D8C FocusMessages - 0002:00000D90 FocusCount - 0002:00000D94 SetLayeredWindowAttributes - 0002:00000D98 TaskActiveWindow - 0002:00000D9C TaskFirstWindow - 0002:00000DA0 TaskFirstTopMost - 0002:00000DA4 TaskWindowList - 0002:00000DA8 SysConsts - 0002:00000DB0 SysConsts - 0002:00000DB8 Props - 0002:00000DE0 Styles - 0002:00000DEC BorderStyles - 0002:00000DF4 ShowCommands - 0002:00000E00 ShowCommands - 0002:00000E0C ShowCommands - 0002:00000E18 cUseAlpha - 0002:00000E20 cUseColorKey - 0002:00000E28 CursorMap - 0002:00000E7C WindowClass - 0002:00000EA4 AppVisible - 0002:00000EA8 ShowFlags - 0002:00000EAC Values - 0002:00000EB4 crMultiDragLink - 0002:00000EB8 crDragAlt - 0002:00000EBC crMultiDragAlt - 0002:00000EC0 crMultiDragLinkAlt - 0002:00000EC4 ColorValues - 0002:00000FB4 StandardColorValues - 0002:00001194 SysColorValues - 0002:000012FC CoCreateInstanceEx - 0002:00001300 CoInitializeEx - 0002:00001304 CoAddRefServerProcess - 0002:00001308 CoReleaseServerProcess - 0002:0000130C CoResumeClassObjects - 0002:00001310 CoSuspendClassObjects - 0002:00001314 CoInitFlags - 0002:00001318 ThreadStrs - 0002:0000132C Values - 0002:00001334 Day - 0002:00001340 Month - 0002:0000134C Year - 0002:00001358 Week - 0002:00001368 TRUE_STRINGS - 0002:0000137C BitBtnCaptions - 0002:000013A8 MAPIDLL - 0002:000013AC MAPIModule - 0002:000013B0 RTFConversionFormat - 0002:000013BC TextConversionFormat - 0002:000013C8 ConversionFormatList - 0002:000013CC Empty - 0002:000013D0 HideScrollBars - 0002:000013D8 HideSelections - 0002:000013E0 Painting - 0002:000013E4 Codes - 0002:000013F4 BorderStyles - 0002:000013FC EditStyles - 0002:00001404 MultiSelections - 0002:0000140C HideSelections - 0002:00001414 Arrangements - 0002:0000141C AutoArrange - 0002:00001424 WrapText - 0002:0000142C ViewStyles - 0002:0000143C ShowColumns - 0002:00001444 ColumnClicks - 0002:0000144C ViewStyles - 0002:0000145C Directions - 0002:00001470 Codes - 0002:00001488 IAlignment - 0002:000014A0 ComboBoxExStyles - 0002:000014AC ComboExStyles - 0002:000014C0 WideCRLF - 0002:000014C4 AnsiCaseMapReady - 0002:000014C8 Bools - 0002:000014D0 InfMantissa - 0002:000014D8 IsWin95 - 0002:000014DC IsWin95OSR2 - 0002:000014E0 IsWin98 - 0002:000014E4 IsWin98SE - 0002:000014E8 IsWinME - 0002:000014EC IsWinNT - 0002:000014F0 IsWinNT3 - 0002:000014F4 IsWinNT31 - 0002:000014F8 IsWinNT35 - 0002:000014FC IsWinNT351 - 0002:00001500 IsWinNT4 - 0002:00001504 IsWin2K - 0002:00001508 IsWinXP - 0002:0000150C IsWin2003 - 0002:00001510 IsWinXP64 - 0002:00001514 IsWin2003R2 - 0002:00001518 IsWinVista - 0002:0000151C IsWinLonghorn - 0002:00001520 IntelCacheDescription - 0002:0000191C ProcessorCount - 0002:00001920 AllocGranularity - 0002:00001924 PageSize - 0002:00001928 RtdlMsiLibHandle - 0002:0000192C IgnorePropertyList - 0002:0000196C ProgressList - 0002:00001970 DefCompanyName - 0002:00001974 DrawBitmap - 0002:00001978 ButtonNames - 0002:000019A4 cUtilWindowExClass - 0002:000019CC cHintSize - 0002:000019D4 GKernel32Handle - 0002:000019D8 GTriedLoadKernel32Dll - 0002:000019DC RegisterServiceProcess - 0002:000019E0 cInfoFlagValues - 0002:00003000 DispCallByIDProc - 0002:00003004 ExceptProc - 0002:00003008 ErrorProc - 0002:0000300C ExceptClsProc - 0002:00003010 ExceptObjProc - 0002:00003014 RaiseExceptionProc - 0002:00003018 RTLUnwindProc - 0002:0000301C ExceptionClass - 0002:00003020 SafeCallErrorProc - 0002:00003024 AssertErrorProc - 0002:00003028 ExitProcessProc - 0002:0000302C AbstractErrorProc - 0002:00003030 MainInstance - 0002:00003034 MainThreadID - 0002:00003038 IsLibrary - 0002:0000303C CmdShow - 0002:00003040 CmdLine - 0002:00003044 InitProc - 0002:00003048 ExitProc - 0002:0000304C IsConsole - 0002:0000304D IsMultiThread - 0002:0000304E Test8086 - 0002:00003050 Input - 0002:0000321C Output - 0002:000033E8 ErrOutput - 0002:000035B4 AllocMemCount - 0002:000035B8 AllocMemSize - 0002:000035BC .5 - 0002:000035C0 initialized - 0002:000035C4 heapErrorCode - 0002:000035C8 heapLock - 0002:000035E0 blockDescBlockList - 0002:000035E4 blockDescFreeList - 0002:000035E8 spaceRoot - 0002:000035F8 decommittedRoot - 0002:00003608 avail - 0002:00003614 rover - 0002:00003618 remBytes - 0002:0000361C curAlloc - 0002:00003620 smallTab - 0002:00003624 committedRoot - 0002:00003634 InitContext - 0002:00003660 VariantManager - 0002:0000370C ModuleIsLib - 0002:0000370D ModuleIsCpp - 0002:00003710 TlsIndex - 0002:00003718 HInstance - 0002:0000371C .1 - 0002:00003720 tlsBuffer - 0002:00003724 .1 - 0002:00003728 .3 - 0002:0000372C .1 - 0002:00003730 .1 - 0002:00003734 CurrencyString - 0002:00003738 CurrencyFormat - 0002:00003739 NegCurrFormat - 0002:0000373A ThousandSeparator - 0002:0000373B DecimalSeparator - 0002:0000373C CurrencyDecimals - 0002:0000373D DateSeparator - 0002:00003740 ShortDateFormat - 0002:00003744 LongDateFormat - 0002:00003748 TimeSeparator - 0002:0000374C TimeAMString - 0002:00003750 TimePMString - 0002:00003754 ShortTimeFormat - 0002:00003758 LongTimeFormat - 0002:0000375C ShortMonthNames - 0002:0000378C LongMonthNames - 0002:000037BC ShortDayNames - 0002:000037D8 LongDayNames - 0002:000037F4 SysLocale - 0002:00003802 ListSeparator - 0002:00003804 EraNames - 0002:00003820 EraYearOffsets - 0002:0000383C TrueBoolStrs - 0002:00003840 FalseBoolStrs - 0002:00003844 .94 - 0002:00003848 OutOfMemory - 0002:0000384C InvalidPointer - 0002:00003850 FLanguages - 0002:00003854 .1 - 0002:00003858 TempVariantChangeTypeEx - 0002:0000385C TempVarNeg - 0002:00003860 TempVarNot - 0002:00003864 TempVarAdd - 0002:00003868 TempVarSub - 0002:0000386C TempVarMul - 0002:00003870 TempVarDiv - 0002:00003874 TempVarIDiv - 0002:00003878 TempVarMod - 0002:0000387C TempVarAnd - 0002:00003880 TempVarOr - 0002:00003884 TempVarXor - 0002:00003888 TempVarCmp - 0002:0000388C TempVarI4FromStr - 0002:00003890 TempVarR4FromStr - 0002:00003894 TempVarR8FromStr - 0002:00003898 TempVarDateFromStr - 0002:0000389C TempVarCyFromStr - 0002:000038A0 TempVarBoolFromStr - 0002:000038A4 TempVarBstrFromCy - 0002:000038A8 TempVarBstrFromDate - 0002:000038AC TempVarBstrFromBool - 0002:000038B0 EmptyParam - 0002:000038C0 VarDispProc - 0002:000038C4 ClearAnyProc - 0002:000038C8 ChangeAnyProc - 0002:000038CC RefAnyProc - 0002:000038D0 .81 - 0002:000038D4 GVariantManager - 0002:00003980 GOldVariantManager - 0002:00003A2C LVarTypes - 0002:00003A30 LVarTypeSync - 0002:00003A34 .1 - 0002:00003A38 .6 - 0002:00003A3C .3 - 0002:00003A40 GlobalNameSpace - 0002:00003A44 IsUniqueGlobalComponentNameProc - 0002:00003A48 .35 - 0002:00003A4C IntConstList - 0002:00003A50 RegGroups - 0002:00003A54 FindGlobalComponentProcs - 0002:00003A58 GlobalFixupList - 0002:00003A5C ProcPosted - 0002:00003A60 ThreadLock - 0002:00003A78 ThreadCount - 0002:00003A7C InstBlockList - 0002:00003A80 InstFreeList - 0002:00003A84 .1 - 0002:00003A88 SystemPalette16 - 0002:00003A8C .12 - 0002:00003A90 ScreenLogPixels - 0002:00003A94 StockPen - 0002:00003A98 StockBrush - 0002:00003A9C StockFont - 0002:00003AA0 StockIcon - 0002:00003AA4 BitmapImageLock - 0002:00003ABC CounterLock - 0002:00003AD4 FontManager - 0002:00003AD8 PenManager - 0002:00003ADC BrushManager - 0002:00003AE0 CanvasList - 0002:00003AE4 PatternManager - 0002:00003AE8 .2 - 0002:00003AEC .21 - 0002:00003AF0 .1 - 0002:00003AF4 ComCtl32DLL - 0002:00003AF8 _InitCommonControlsEx - 0002:00003AFC GetSystemMetrics - 0002:00003B00 MonitorFromWindow - 0002:00003B04 MonitorFromRect - 0002:00003B08 MonitorFromPoint - 0002:00003B0C GetMonitorInfo - 0002:00003B10 GetMonitorInfoA - 0002:00003B14 GetMonitorInfoW - 0002:00003B18 EnumDisplayMonitors - 0002:00003B1C .1 - 0002:00003B20 User32Dll - 0002:00003B24 InitApis - 0002:00003B2C MMAvailable - 0002:00003B30 .1 - 0002:00003B34 .2 - 0002:00003B38 HelpManager - 0002:00003B3C .3 - 0002:00003B40 .3 - 0002:00003B44 FlatSB_EnableScrollBar - 0002:00003B48 FlatSB_ShowScrollBar - 0002:00003B4C FlatSB_GetScrollRange - 0002:00003B50 FlatSB_GetScrollInfo - 0002:00003B54 FlatSB_GetScrollPos - 0002:00003B58 FlatSB_SetScrollPos - 0002:00003B5C FlatSB_SetScrollInfo - 0002:00003B60 FlatSB_SetScrollRange - 0002:00003B64 .1 - 0002:00003B68 _FlatSB_GetScrollProp - 0002:00003B6C _FlatSB_SetScrollProp - 0002:00003B70 _InitializeFlatSB - 0002:00003B74 _UninitializeFlatSB - 0002:00003B78 .42 - 0002:00003B7C .1 - 0002:00003B80 .1 - 0002:00003B84 .1 - 0002:00003B88 .1 - 0002:00003B8C .1 - 0002:00003B90 .1 - 0002:00003B94 .12 - 0002:00003B98 .1 - 0002:00003B9C .01 - 0002:00003BA0 HelpMsg - 0002:00003BA4 FindMsg - 0002:00003BA8 CF_PICTURE - 0002:00003BAA CF_COMPONENT - 0002:00003BAC .2 - 0002:00003BB0 FClipboard - 0002:00003BB4 .1 - 0002:00003BB8 .63 - 0002:00003BBC WinHelpTester - 0002:00003BC0 ViewerName - 0002:00003BC4 .1 - 0002:00003BC8 HelpViewer - 0002:00003BCC Mouse - 0002:00003BD0 NewStyleControls - 0002:00003BD4 .72 - 0002:00003BD8 WindowAtom - 0002:00003BDA ControlAtom - 0002:00003BDC WindowAtomString - 0002:00003BE0 ControlAtomString - 0002:00003BE4 RM_GetObjectInstance - 0002:00003BE8 DragControl - 0002:00003BEC DragObject - 0002:00003BF0 DragInternalObject - 0002:00003BF4 DragCapture - 0002:00003BF8 DragStartPos - 0002:00003C00 DragSaveCursor - 0002:00003C04 DragThreshold - 0002:00003C08 ActiveDrag - 0002:00003C0C DragImageList - 0002:00003C10 DockSiteList - 0002:00003C14 QualifyingSites - 0002:00003C18 DragSave - 0002:00003C1C CanvasList - 0002:00003C20 _WINNLSEnableIME - 0002:00003C24 _ImmGetContext - 0002:00003C28 _ImmReleaseContext - 0002:00003C2C _ImmGetConversionStatus - 0002:00003C30 _ImmSetConversionStatus - 0002:00003C34 _ImmSetOpenStatus - 0002:00003C38 _ImmSetCompositionWindow - 0002:00003C3C _ImmSetCompositionFont - 0002:00003C40 _ImmGetCompositionString - 0002:00003C44 _ImmIsIME - 0002:00003C48 _ImmNotifyIME - 0002:00003C4C .8 - 0002:00003C50 .3 - 0002:00003C54 PopupList - 0002:00003C58 ShortCutItems - 0002:00003C5C .9 - 0002:00003C60 CommandPool - 0002:00003C64 Application - 0002:00003C68 Screen - 0002:00003C6C .41 - 0002:00003C70 RM_TaskbarCreated - 0002:00003C74 HintThreadID - 0002:00003C78 HintDoneEvent - 0002:00003C7C HintHook - 0002:00003C80 HintThread - 0002:00003C84 RC_SendBuf - 0002:00003C88 RC_End - 0002:00003C8C RC_ExitCode - 0002:00003C90 RC_LineOut - 0002:00003C94 .1 - 0002:00003C98 .8 - 0002:00003C9C .1 - 0002:00003CA0 .6 - 0002:00003CA4 .41 - 0002:00003CA8 WSAData - 0002:00003E38 .1 - 0002:00003E3C .1 - 0002:00003E40 .1 - 0002:00003E44 .2 - 0002:00003E48 .1 - 0002:00003E4C .1 - 0002:00003E50 .7 - 0002:00003E54 .1 - 0002:00003E58 .1 - 0002:00003E5C .41 - 0002:00003E60 OleUninitializing - 0002:00003E64 ComClassManagerVar - 0002:00003E68 SaveInitProc - 0002:00003E6C NeedToUninitialize - 0002:00003E70 .7 - 0002:00003E74 .5 - 0002:00003E78 .1 - 0002:00003E7C ShellVersion - 0002:00003E80 .1 - 0002:00003E84 .4 - 0002:00003E88 .1 - 0002:00003E8C .4 - 0002:00003E90 BitBtnGlyphs - 0002:00003EBC .3 - 0002:00003EC0 .1 - 0002:00003EC4 .72 - 0002:00003EC8 UrlMonHandle - 0002:00003ECC UrlMonInitialized - 0002:00003ED0 .8 - 0002:00003ED4 .36 - 0002:00003ED8 ShellModule - 0002:00003EDC FRichEditModule - 0002:00003EE0 .2 - 0002:00003EE4 .5 - 0002:00003EE8 .11 - 0002:00003EEC .1 - 0002:00003EF0 .4 - 0002:00003EF4 .1 - 0002:00003EF8 .2 - 0002:00003EFC .01 - 0002:00003F00 .3 - 0002:00003F04 .1 - 0002:00003F08 .1 - 0002:00003F0C AnsiCaseMap - 0002:0000420C AnsiCharTypes - 0002:0000440C .1 - 0002:00004410 .7 - 0002:00004414 .5 - 0002:00004418 .1 - 0002:0000441C .1 - 0002:00004420 .1 - 0002:00004424 .2 - 0002:00004428 .1 - 0002:0000442C .2 - 0002:00004430 KernelVersionHi - 0002:00004434 ResmeterLibHandle - 0002:00004438 MyGetFreeSystemResources - 0002:0000443C .1 - 0002:00004440 .1 - 0002:00004444 .2 - 0002:00004448 .42 - 0002:0000444C .4 - 0002:00004450 TypeList - 0002:00004454 .1 - 0002:00004458 .4 - 0002:0000445C .01 - 0002:00004460 RegisteredAppStoragePropertyEngineList - 0002:00004464 .1 - 0002:00004468 .6 - 0002:0000446C .2 - 0002:00004470 .1 - 0002:00004474 .1 - 0002:00004478 frmMain - 0002:0000447C .4 - - -Line numbers for RedirectConsole(RedirectConsole.pas) segment .text - - 36 0001:00060608 37 0001:00060625 38 0001:0006065F 42 0001:00060670 - 43 0001:00060676 44 0001:0006067D 45 0001:00060683 46 0001:0006068B - 50 0001:00060694 52 0001:000606BA 53 0001:000606DB 54 0001:000606E4 - 51 0001:00060701 56 0001:00060712 57 0001:00060749 69 0001:0006075C - 71 0001:000607A3 72 0001:000607AC 73 0001:000607BA 74 0001:000607CC - 75 0001:000607DA 77 0001:000607E2 78 0001:000607FC 79 0001:00060807 - 82 0001:0006080C 83 0001:00060826 84 0001:00060831 85 0001:0006083A - 86 0001:00060843 89 0001:00060848 90 0001:00060854 91 0001:0006085E - 92 0001:00060867 93 0001:00060870 94 0001:00060879 96 0001:00060882 - 98 0001:000608B0 99 0001:000608CF 100 0001:000608D8 101 0001:000608E1 - 102 0001:000608EA 103 0001:000608F3 106 0001:000608F8 107 0001:00060906 - 108 0001:0006090D 111 0001:00060914 112 0001:00060920 113 0001:00060931 - 114 0001:00060944 116 0001:0006095A 117 0001:00060963 118 0001:00060971 - 119 0001:0006097A 120 0001:00060986 121 0001:00060998 122 0001:000609B5 - 119 0001:000609C3 125 0001:000609CD 126 0001:000609DF 131 0001:000609FE - 132 0001:00060A14 130 0001:00060A25 134 0001:00060A30 136 0001:00060A3D - 137 0001:00060A49 138 0001:00060A55 139 0001:00060A5E 140 0001:00060A67 - 141 0001:00060A70 142 0001:00060AA6 144 0001:00060B50 144 0001:00060B57 - -Line numbers for JvWin32(JvWin32.pas) segment .text - - 334 0001:00065684 334 0001:0006568B - -Line numbers for JvConsts(JvConsts.pas) segment .text - - 273 0001:000656BC 273 0001:000656C3 - -Line numbers for modRichEdit(modRichEdit.pas) segment .text - - 15 0001:00078278 18 0001:000782A2 19 0001:000782C0 20 0001:000782CD - 21 0001:000782DD 23 0001:00078310 30 0001:00078318 31 0001:0007834B - 33 0001:0007834D 37 0001:00078367 39 0001:0007836F 44 0001:000783A0 - 45 0001:000783B3 47 0001:000783D1 48 0001:000783DB 56 0001:00078407 - 37 0001:00078421 62 0001:00078429 63 0001:00078457 66 0001:0007847C - 67 0001:000784A3 68 0001:000784B9 73 0001:00078572 78 0001:00078584 - 79 0001:000785BC 81 0001:000785DB 82 0001:000785F8 84 0001:00078607 - 86 0001:00078615 88 0001:00078624 89 0001:0007863E 92 0001:0007867C - 95 0001:000786E4 95 0001:000786EB - -Line numbers for modSCPUtils(modSCPUtils.pas) segment .text - - 88 0001:000786EC 89 0001:00078726 91 0001:0007872D 92 0001:00078737 - 94 0001:00078739 96 0001:0007876E 97 0001:00078770 99 0001:000787C0 - 600 0001:000787F8 600 0001:000787FF - -Line numbers for fMain(fMain.pas) segment .text - - 109 0001:00078CD0 110 0001:00078CED 111 0001:00078D1D 119 0001:00078D20 - 120 0001:00078D41 121 0001:00078D4F 122 0001:00078D53 124 0001:00078D5E - 125 0001:00078D85 128 0001:00078D8C 129 0001:00078D9E 131 0001:00078DA9 - 133 0001:00078DAD 134 0001:00078DBC 135 0001:00078DE2 138 0001:00078DE8 - 139 0001:00078DF3 140 0001:00078DFB 141 0001:00078E03 142 0001:00078E1A - 148 0001:00078E20 149 0001:00078E25 153 0001:00078E32 154 0001:00078E3C - 158 0001:00078E46 164 0001:00078E51 166 0001:00078E68 167 0001:00078E75 - 168 0001:00078E82 171 0001:00078E8A 172 0001:00078E95 174 0001:00078EA2 - 175 0001:00078EAC 156 0001:00078EB3 178 0001:00078EB9 151 0001:00078EC2 - 180 0001:00078ECC 183 0001:00078EEC 184 0001:00078EEF 185 0001:00078EF6 - 186 0001:00078F00 187 0001:00078F08 195 0001:00078F0C 197 0001:00078F39 - 198 0001:00078F3D 201 0001:00078F3F 204 0001:00078F56 205 0001:00078F67 - 212 0001:00078F69 215 0001:00078F76 216 0001:00078F7F 219 0001:00078F94 - 222 0001:00078F9A 223 0001:00078FA8 226 0001:00078FBD 229 0001:00078FE0 - 231 0001:00078FF1 232 0001:00078FF5 235 0001:00078FFF 238 0001:0007901D - 240 0001:00079034 241 0001:00079052 245 0001:00079070 247 0001:0007908B - 249 0001:0007909C 252 0001:000790B7 254 0001:000790C8 257 0001:000790E3 - 259 0001:000790F4 265 0001:0007910F 266 0001:00079127 269 0001:00079131 - 270 0001:00079148 272 0001:00079166 274 0001:00079184 276 0001:000791A3 - 277 0001:000791BA 279 0001:000791D8 280 0001:000791F0 284 0001:000791FA - 286 0001:00079211 290 0001:00079224 292 0001:00079243 293 0001:0007925A - 294 0001:00079278 295 0001:00079290 298 0001:0007929A 300 0001:000792B9 - 301 0001:000792D0 303 0001:000792EE 304 0001:00079306 307 0001:00079310 - 309 0001:0007932F 310 0001:00079346 311 0001:00079364 312 0001:0007937C - 315 0001:00079386 317 0001:000793A5 318 0001:000793BC 320 0001:000793DA - 321 0001:000793F2 325 0001:000793F9 328 0001:0007941E 329 0001:00079424 - 331 0001:00079461 338 0001:00079570 339 0001:00079574 341 0001:0007957F - 342 0001:00079593 344 0001:0007959A 345 0001:000795A1 346 0001:000795A8 - 347 0001:000795AF 352 0001:000795B4 353 0001:000795D0 354 0001:00079608 - 355 0001:0007962B 356 0001:00079632 357 0001:00079639 358 0001:0007967E - 362 0001:000796C4 363 0001:000796C9 367 0001:000796CC 368 0001:000796DB - 369 0001:000796E5 370 0001:000796EF 371 0001:000796F9 374 0001:0007973C - 376 0001:00079764 379 0001:00079786 381 0001:0007978C 382 0001:00079798 - 386 0001:0007979F 387 0001:000797A6 388 0001:000797B1 389 0001:000797BF - 391 0001:000797E9 394 0001:0007980C 395 0001:0007980F 397 0001:0007981D - 398 0001:00079822 400 0001:00079825 403 0001:00079828 404 0001:0007982B - 405 0001:00079838 408 0001:00079841 409 0001:00079848 413 0001:0007984A - 414 0001:00079856 417 0001:0007985D 418 0001:0007986A 422 0001:0007986C - 423 0001:00079889 424 0001:00079893 425 0001:000798A5 426 0001:000798F0 - 429 0001:00079928 430 0001:0007992B 431 0001:00079936 433 0001:00079941 - 434 0001:0007994E 438 0001:00079950 441 0001:00079953 443 0001:00079962 - 444 0001:00079969 445 0001:00079976 446 0001:00079987 450 0001:0007998E - 452 0001:0007999D 453 0001:000799AE 456 0001:000799BB 461 0001:00079A14 - 463 0001:00079A1E 465 0001:00079A2D 466 0001:00079A34 467 0001:00079A41 - 468 0001:00079A52 472 0001:00079A58 473 0001:00079A69 474 0001:00079A76 - 476 0001:00079A7A 482 0001:00079AC4 483 0001:00079AC7 486 0001:00079AD0 - 487 0001:00079AD7 489 0001:00079AE4 490 0001:00079AED 493 0001:00079AFC - 495 0001:00079B09 499 0001:00079B0C 500 0001:00079B33 501 0001:00079B7A - 508 0001:00079B94 509 0001:00079B9E 511 0001:00079BA4 513 0001:00079BBC - 514 0001:00079BC2 515 0001:00079BC8 511 0001:00079BD5 517 0001:00079BD8 - 521 0001:00079BE0 522 0001:00079BFD 524 0001:00079C03 526 0001:00079C22 - 527 0001:00079C27 531 0001:00079C29 532 0001:00079C3F 533 0001:00079C57 - 534 0001:00079C64 536 0001:00079C8B 540 0001:00079C94 541 0001:00079C97 - 543 0001:00079CA6 546 0001:00079CB7 548 0001:00079CC6 550 0001:00079CD7 - 553 0001:00079D2C 554 0001:00079D4C 556 0001:00079D52 558 0001:00079D63 - 561 0001:00079D8E 564 0001:00079D94 565 0001:00079DBC 566 0001:00079DBE - 568 0001:00079DD4 570 0001:00079DF2 571 0001:00079DF4 572 0001:00079DFB - 573 0001:00079E05 576 0001:00079E30 581 0001:00079E58 582 0001:00079E5D - 584 0001:00079E6B 586 0001:00079E80 587 0001:00079E9B 584 0001:00079E9C - 589 0001:00079E9F 594 0001:00079EA4 595 0001:00079ECA 596 0001:00079ED8 - 597 0001:00079F11 598 0001:00079F17 600 0001:00079F2A 602 0001:00079F33 - 603 0001:00079F48 605 0001:00079F58 607 0001:00079F78 609 0001:00079F7E - 610 0001:00079F86 612 0001:00079F97 614 0001:00079FC9 620 0001:0007A008 - 621 0001:0007A028 623 0001:0007A036 624 0001:0007A06F 625 0001:0007A094 - 627 0001:0007A09D 629 0001:0007A0D0 630 0001:0007A0FD 633 0001:0007A10A - 635 0001:0007A115 638 0001:0007A12E 640 0001:0007A144 641 0001:0007A149 - 643 0001:0007A15D 646 0001:0007A175 647 0001:0007A17D 649 0001:0007A1AF - 652 0001:0007A228 653 0001:0007A22B 654 0001:0007A234 655 0001:0007A24D - 662 0001:0007A250 663 0001:0007A289 665 0001:0007A299 666 0001:0007A2A7 - 670 0001:0007A2BC 672 0001:0007A2C4 674 0001:0007A2E2 676 0001:0007A2F6 - 677 0001:0007A304 678 0001:0007A329 668 0001:0007A34C 682 0001:0007A364 - 684 0001:0007A374 685 0001:0007A3B4 687 0001:0007A424 687 0001:0007A42B - -Line numbers for PseuWoWConsole(M:\Mangos\PseudoWoWGM\src\PseuWoWConsole.dpr) segment .text - - 12 0001:0007A7A4 13 0001:0007A7B4 14 0001:0007A7C0 15 0001:0007A7D1 - 16 0001:0007A7E9 17 0001:0007A7F5 - -Bound resource files - -c:\program files\borland\delphi6\Lib\CONTROLS.RES -c:\program files\borland\delphi6\Lib\BUTTONS.RES -c:\program files\borland\delphi6\Lib\EXTDLGS.RES -F:\Delphi Updates\jedi vcl\Resources\JvConsts.res -fMain.DFM -PseuWoWConsole.RES -PseuWoWConsole.drf - - -Program entry point at 0001:0007A7A4 + + Start Length Name Class + 0001:00000000 0007A814H .text CODE + 0002:00000000 00002070H .data DATA + 0002:00002070 00001481H .bss BSS + + +Detailed map of segments + + 0001:00000000 00005A1B C=CODE S=.text G=(none) M=System ACBP=A9 + 0001:00005A1C 00000140 C=CODE S=.text G=(none) M=SysInit ACBP=A9 + 0001:00005B5C 00000134 C=CODE S=.text G=(none) M=Types ACBP=A9 + 0001:00005C90 00000BFC C=CODE S=.text G=(none) M=Windows ACBP=A9 + 0001:0000688C 00000038 C=CODE S=.text G=(none) M=Messages ACBP=A9 + 0001:000068C4 00000350 C=CODE S=.text G=(none) M=SysConst ACBP=A9 + 0001:00006C14 00006960 C=CODE S=.text G=(none) M=SysUtils ACBP=A9 + 0001:0000D574 0000099F C=CODE S=.text G=(none) M=VarUtils ACBP=A9 + 0001:0000DF14 000092AC C=CODE S=.text G=(none) M=Variants ACBP=A9 + 0001:000171C0 00000178 C=CODE S=.text G=(none) M=RTLConsts ACBP=A9 + 0001:00017338 00000DCC C=CODE S=.text G=(none) M=TypInfo ACBP=A9 + 0001:00018104 00000098 C=CODE S=.text G=(none) M=ActiveX ACBP=A9 + 0001:0001819C 0000C5DA C=CODE S=.text G=(none) M=Classes ACBP=A9 + 0001:00024778 000002C8 C=CODE S=.text G=(none) M=Consts ACBP=A9 + 0001:00024A40 00007407 C=CODE S=.text G=(none) M=Graphics ACBP=A9 + 0001:0002BE48 00000048 C=CODE S=.text G=(none) M=Math ACBP=A9 + 0001:0002BE90 000002B8 C=CODE S=.text G=(none) M=Contnrs ACBP=A9 + 0001:0002C148 000005A8 C=CODE S=.text G=(none) M=CommCtrl ACBP=A9 + 0001:0002C6F0 00000787 C=CODE S=.text G=(none) M=MultiMon ACBP=A9 + 0001:0002CE78 00000038 C=CODE S=.text G=(none) M=Imm ACBP=A9 + 0001:0002CEB0 00001098 C=CODE S=.text G=(none) M=HelpIntfs ACBP=A9 + 0001:0002DF48 00000058 C=CODE S=.text G=(none) M=WinSpool ACBP=A9 + 0001:0002DFA0 00000F80 C=CODE S=.text G=(none) M=Printers ACBP=A9 + 0001:0002EF20 0000031F C=CODE S=.text G=(none) M=FlatSB ACBP=A9 + 0001:0002F240 00008050 C=CODE S=.text G=(none) M=StdCtrls ACBP=A9 + 0001:00037290 00000040 C=CODE S=.text G=(none) M=ShellAPI ACBP=A9 + 0001:000372D0 00000038 C=CODE S=.text G=(none) M=RegStr ACBP=A9 + 0001:00037308 00000038 C=CODE S=.text G=(none) M=WinInet ACBP=A9 + 0001:00037340 00000038 C=CODE S=.text G=(none) M=UrlMon ACBP=A9 + 0001:00037378 00000038 C=CODE S=.text G=(none) M=ShlObj ACBP=A9 + 0001:000373B0 00000038 C=CODE S=.text G=(none) M=CommDlg ACBP=A9 + 0001:000373E8 00001500 C=CODE S=.text G=(none) M=ExtCtrls ACBP=A9 + 0001:000388E8 00000038 C=CODE S=.text G=(none) M=Dlgs ACBP=A9 + 0001:00038920 00000659 C=CODE S=.text G=(none) M=Dialogs ACBP=A9 + 0001:00038F7C 00000094 C=CODE S=.text G=(none) M=Clipbrd ACBP=A9 + 0001:00039010 00000114 C=CODE S=.text G=(none) M=StrUtils ACBP=A9 + 0001:00039124 00000168 C=CODE S=.text G=(none) M=StdActns ACBP=A9 + 0001:0003928C 00000CC4 C=CODE S=.text G=(none) M=WinHelpViewer ACBP=A9 + 0001:00039F50 00010AEB C=CODE S=.text G=(none) M=Controls ACBP=A9 + 0001:0004AA3C 0000130E C=CODE S=.text G=(none) M=ActnList ACBP=A9 + 0001:0004BD4C 000017D0 C=CODE S=.text G=(none) M=ImgList ACBP=A9 + 0001:0004D51C 000064CD C=CODE S=.text G=(none) M=Menus ACBP=A9 + 0001:000539EC 0000CC1C C=CODE S=.text G=(none) M=Forms ACBP=A9 + 0001:00060608 00000550 C=CODE S=.text G=(none) M=RedirectConsole ACBP=A9 + 0001:00060B58 00001018 C=CODE S=.text G=(none) M=IniFiles ACBP=A9 + 0001:00061B70 00000110 C=CODE S=.text G=(none) M=WinSock ACBP=A9 + 0001:00061C80 000003F0 C=CODE S=.text G=(none) M=SyncObjs ACBP=A9 + 0001:00062070 000035E4 C=CODE S=.text G=(none) M=ScktComp ACBP=A9 + 0001:00065654 00000038 C=CODE S=.text G=(none) M=JvWin32 ACBP=A9 + 0001:0006568C 00000038 C=CODE S=.text G=(none) M=JvConsts ACBP=A9 + 0001:000656C4 0000006C C=CODE S=.text G=(none) M=JVCLVer ACBP=A9 + 0001:00065730 00000118 C=CODE S=.text G=(none) M=JvComponentBase ACBP=A9 + 0001:00065848 000000C8 C=CODE S=.text G=(none) M=DateUtils ACBP=A9 + 0001:00065910 000002B8 C=CODE S=.text G=(none) M=JvResources ACBP=A9 + 0001:00065BC8 00000AA8 C=CODE S=.text G=(none) M=JvTypes ACBP=A9 + 0001:00066670 00000038 C=CODE S=.text G=(none) M=JvVCL5Utils ACBP=A9 + 0001:000666A8 00000058 C=CODE S=.text G=(none) M=ComConst ACBP=A9 + 0001:00066700 00000E65 C=CODE S=.text G=(none) M=ComObj ACBP=A9 + 0001:00067568 00000038 C=CODE S=.text G=(none) M=MMSystem ACBP=A9 + 0001:000675A0 00000068 C=CODE S=.text G=(none) M=Registry ACBP=A9 + 0001:00067608 00000354 C=CODE S=.text G=(none) M=JvJCLUtils ACBP=A9 + 0001:0006795C 00000038 C=CODE S=.text G=(none) M=RichEdit ACBP=A9 + 0001:00067994 00000038 C=CODE S=.text G=(none) M=ToolWin ACBP=A9 + 0001:000679CC 00000060 C=CODE S=.text G=(none) M=ComStrs ACBP=A9 + 0001:00067A2C 000000F5 C=CODE S=.text G=(none) M=Buttons ACBP=A9 + 0001:00067B24 00000038 C=CODE S=.text G=(none) M=ExtDlgs ACBP=A9 + 0001:00067B5C 0000006C C=CODE S=.text G=(none) M=Mapi ACBP=A9 + 0001:00067BC8 00000058 C=CODE S=.text G=(none) M=ExtActns ACBP=A9 + 0001:00067C20 00001AF8 C=CODE S=.text G=(none) M=ListActns ACBP=A9 + 0001:00069718 0000B6E8 C=CODE S=.text G=(none) M=ComCtrls ACBP=A9 + 0001:00074E00 00000038 C=CODE S=.text G=(none) M=MaskUtils ACBP=A9 + 0001:00074E38 00000038 C=CODE S=.text G=(none) M=Mask ACBP=A9 + 0001:00074E70 00000038 C=CODE S=.text G=(none) M=Grids ACBP=A9 + 0001:00074EA8 000001D0 C=CODE S=.text G=(none) M=JclResources ACBP=A9 + 0001:00075078 00000038 C=CODE S=.text G=(none) M=JclBase ACBP=A9 + 0001:000750B0 00000038 C=CODE S=.text G=(none) M=AccCtrl ACBP=A9 + 0001:000750E8 00000040 C=CODE S=.text G=(none) M=JclWin32 ACBP=A9 + 0001:00075128 00000038 C=CODE S=.text G=(none) M=JclConsole ACBP=A9 + 0001:00075160 00000068 C=CODE S=.text G=(none) M=JclWideStrings ACBP=A9 + 0001:000751C8 00000038 C=CODE S=.text G=(none) M=JclLogic ACBP=A9 + 0001:00075200 00000158 C=CODE S=.text G=(none) M=JclStrings ACBP=A9 + 0001:00075358 00000038 C=CODE S=.text G=(none) M=Jcl8087 ACBP=A9 + 0001:00075390 00000038 C=CODE S=.text G=(none) M=JclMath ACBP=A9 + 0001:000753C8 00000084 C=CODE S=.text G=(none) M=JclSysUtils ACBP=A9 + 0001:0007544C 00000038 C=CODE S=.text G=(none) M=Snmp ACBP=A9 + 0001:00075484 00000038 C=CODE S=.text G=(none) M=TlHelp32 ACBP=A9 + 0001:000754BC 00000038 C=CODE S=.text G=(none) M=PsAPI ACBP=A9 + 0001:000754F4 00000038 C=CODE S=.text G=(none) M=JclRegistry ACBP=A9 + 0001:0007552C 00000038 C=CODE S=.text G=(none) M=JclIniFiles ACBP=A9 + 0001:00075564 000006B5 C=CODE S=.text G=(none) M=JclSysInfo ACBP=A9 + 0001:00075C1C 00000044 C=CODE S=.text G=(none) M=JclShell ACBP=A9 + 0001:00075C60 00000038 C=CODE S=.text G=(none) M=JclSecurity ACBP=A9 + 0001:00075C98 00000038 C=CODE S=.text G=(none) M=JclDateTime ACBP=A9 + 0001:00075CD0 00000124 C=CODE S=.text G=(none) M=JclFileUtils ACBP=A9 + 0001:00075DF4 000001BF C=CODE S=.text G=(none) M=JclRTTI ACBP=A9 + 0001:00075FB4 00000038 C=CODE S=.text G=(none) M=JclMime ACBP=A9 + 0001:00075FEC 000001D0 C=CODE S=.text G=(none) M=JvPropertyStore ACBP=A9 + 0001:000761BC 0000013B C=CODE S=.text G=(none) M=JvAppStorage ACBP=A9 + 0001:000762F8 00000044 C=CODE S=.text G=(none) M=JvProgressUtils ACBP=A9 + 0001:0007633C 0000034B C=CODE S=.text G=(none) M=JvJVCLUtils ACBP=A9 + 0001:00076688 00001BF0 C=CODE S=.text G=(none) M=JvTrayIcon ACBP=A9 + 0001:00078278 00000474 C=CODE S=.text G=(none) M=modRichEdit ACBP=A9 + 0001:000786EC 00000114 C=CODE S=.text G=(none) M=modSCPUtils ACBP=A9 + 0001:00078800 00001C2C C=CODE S=.text G=(none) M=fMain ACBP=A9 + 0001:0007A42C 000003E8 C=CODE S=.text G=(none) M=PseuWoWConsole ACBP=A9 + 0002:00000000 0000008C C=DATA S=.data G=DGROUP M=System ACBP=A9 + 0002:0000008C 00000018 C=DATA S=.data G=DGROUP M=SysInit ACBP=A9 + 0002:000000A4 00000254 C=DATA S=.data G=DGROUP M=SysUtils ACBP=A9 + 0002:000002F8 00000110 C=DATA S=.data G=DGROUP M=VarUtils ACBP=A9 + 0002:00000408 00000186 C=DATA S=.data G=DGROUP M=Variants ACBP=A9 + 0002:00000590 0000000C C=DATA S=.data G=DGROUP M=TypInfo ACBP=A9 + 0002:0000059C 00000010 C=DATA S=.data G=DGROUP M=ActiveX ACBP=A9 + 0002:000005AC 00000100 C=DATA S=.data G=DGROUP M=Classes ACBP=A9 + 0002:000006AC 00000304 C=DATA S=.data G=DGROUP M=Graphics ACBP=A9 + 0002:000009B0 00000004 C=DATA S=.data G=DGROUP M=Printers ACBP=A9 + 0002:000009B4 00000104 C=DATA S=.data G=DGROUP M=StdCtrls ACBP=A9 + 0002:00000AB8 00000014 C=DATA S=.data G=DGROUP M=ExtCtrls ACBP=A9 + 0002:00000ACC 00000074 C=DATA S=.data G=DGROUP M=Dialogs ACBP=A9 + 0002:00000B40 0000013C C=DATA S=.data G=DGROUP M=Controls ACBP=A9 + 0002:00000C7C 00000020 C=DATA S=.data G=DGROUP M=ImgList ACBP=A9 + 0002:00000C9C 000000EC C=DATA S=.data G=DGROUP M=Menus ACBP=A9 + 0002:00000D88 00000124 C=DATA S=.data G=DGROUP M=Forms ACBP=A9 + 0002:00000EAC 00000008 C=DATA S=.data G=DGROUP M=IniFiles ACBP=A9 + 0002:00000EB4 0000000E C=DATA S=.data G=DGROUP M=JvConsts ACBP=A9 + 0002:00000EC4 00000438 C=DATA S=.data G=DGROUP M=JvTypes ACBP=A9 + 0002:000012FC 00000030 C=DATA S=.data G=DGROUP M=ComObj ACBP=A9 + 0002:0000132C 00000008 C=DATA S=.data G=DGROUP M=Registry ACBP=A9 + 0002:00001334 00000048 C=DATA S=.data G=DGROUP M=JvJCLUtils ACBP=A9 + 0002:0000137C 0000002C C=DATA S=.data G=DGROUP M=Buttons ACBP=A9 + 0002:000013A8 00000008 C=DATA S=.data G=DGROUP M=Mapi ACBP=A9 + 0002:000013B0 00000110 C=DATA S=.data G=DGROUP M=ComCtrls ACBP=A9 + 0002:000014C0 00000004 C=DATA S=.data G=DGROUP M=JclWideStrings ACBP=A9 + 0002:000014C4 0000000C C=DATA S=.data G=DGROUP M=JclStrings ACBP=A9 + 0002:000014D0 00000008 C=DATA S=.data G=DGROUP M=JclSysUtils ACBP=A9 + 0002:000014D8 00000450 C=DATA S=.data G=DGROUP M=JclSysInfo ACBP=A9 + 0002:00001928 00000004 C=DATA S=.data G=DGROUP M=JclShell ACBP=A9 + 0002:0000192C 00000040 C=DATA S=.data G=DGROUP M=JvPropertyStore ACBP=A9 + 0002:0000196C 00000004 C=DATA S=.data G=DGROUP M=JvProgressUtils ACBP=A9 + 0002:00001970 0000005C C=DATA S=.data G=DGROUP M=JvJVCLUtils ACBP=A9 + 0002:000019CC 00000024 C=DATA S=.data G=DGROUP M=JvTrayIcon ACBP=A9 + 0002:00003000 0000070C C=BSS S=.bss G=DGROUP M=System ACBP=A9 + 0002:0000370C 00000018 C=BSS S=.bss G=DGROUP M=SysInit ACBP=A9 + 0002:00003724 00000004 C=BSS S=.bss G=DGROUP M=Types ACBP=A9 + 0002:00003728 00000004 C=BSS S=.bss G=DGROUP M=Windows ACBP=A9 + 0002:0000372C 00000004 C=BSS S=.bss G=DGROUP M=Messages ACBP=A9 + 0002:00003730 00000004 C=BSS S=.bss G=DGROUP M=SysConst ACBP=A9 + 0002:00003734 00000120 C=BSS S=.bss G=DGROUP M=SysUtils ACBP=A9 + 0002:00003854 0000005C C=BSS S=.bss G=DGROUP M=VarUtils ACBP=A9 + 0002:000038B0 00000184 C=BSS S=.bss G=DGROUP M=Variants ACBP=A9 + 0002:00003A34 00000004 C=BSS S=.bss G=DGROUP M=RTLConsts ACBP=A9 + 0002:00003A38 00000004 C=BSS S=.bss G=DGROUP M=TypInfo ACBP=A9 + 0002:00003A3C 00000004 C=BSS S=.bss G=DGROUP M=ActiveX ACBP=A9 + 0002:00003A40 00000044 C=BSS S=.bss G=DGROUP M=Classes ACBP=A9 + 0002:00003A84 00000004 C=BSS S=.bss G=DGROUP M=Consts ACBP=A9 + 0002:00003A88 00000060 C=BSS S=.bss G=DGROUP M=Graphics ACBP=A9 + 0002:00003AE8 00000004 C=BSS S=.bss G=DGROUP M=Math ACBP=A9 + 0002:00003AEC 00000004 C=BSS S=.bss G=DGROUP M=Contnrs ACBP=A9 + 0002:00003AF0 0000000C C=BSS S=.bss G=DGROUP M=CommCtrl ACBP=A9 + 0002:00003AFC 00000031 C=BSS S=.bss G=DGROUP M=MultiMon ACBP=A9 + 0002:00003B30 00000004 C=BSS S=.bss G=DGROUP M=Imm ACBP=A9 + 0002:00003B34 00000008 C=BSS S=.bss G=DGROUP M=HelpIntfs ACBP=A9 + 0002:00003B3C 00000004 C=BSS S=.bss G=DGROUP M=WinSpool ACBP=A9 + 0002:00003B40 00000004 C=BSS S=.bss G=DGROUP M=Printers ACBP=A9 + 0002:00003B44 00000034 C=BSS S=.bss G=DGROUP M=FlatSB ACBP=A9 + 0002:00003B78 00000004 C=BSS S=.bss G=DGROUP M=StdCtrls ACBP=A9 + 0002:00003B7C 00000004 C=BSS S=.bss G=DGROUP M=ShellAPI ACBP=A9 + 0002:00003B80 00000004 C=BSS S=.bss G=DGROUP M=RegStr ACBP=A9 + 0002:00003B84 00000004 C=BSS S=.bss G=DGROUP M=WinInet ACBP=A9 + 0002:00003B88 00000004 C=BSS S=.bss G=DGROUP M=UrlMon ACBP=A9 + 0002:00003B8C 00000004 C=BSS S=.bss G=DGROUP M=ShlObj ACBP=A9 + 0002:00003B90 00000004 C=BSS S=.bss G=DGROUP M=CommDlg ACBP=A9 + 0002:00003B94 00000004 C=BSS S=.bss G=DGROUP M=ExtCtrls ACBP=A9 + 0002:00003B98 00000004 C=BSS S=.bss G=DGROUP M=Dlgs ACBP=A9 + 0002:00003B9C 0000000C C=BSS S=.bss G=DGROUP M=Dialogs ACBP=A9 + 0002:00003BA8 0000000C C=BSS S=.bss G=DGROUP M=Clipbrd ACBP=A9 + 0002:00003BB4 00000004 C=BSS S=.bss G=DGROUP M=StrUtils ACBP=A9 + 0002:00003BB8 00000004 C=BSS S=.bss G=DGROUP M=StdActns ACBP=A9 + 0002:00003BBC 00000010 C=BSS S=.bss G=DGROUP M=WinHelpViewer ACBP=A9 + 0002:00003BCC 00000080 C=BSS S=.bss G=DGROUP M=Controls ACBP=A9 + 0002:00003C4C 00000004 C=BSS S=.bss G=DGROUP M=ActnList ACBP=A9 + 0002:00003C50 00000004 C=BSS S=.bss G=DGROUP M=ImgList ACBP=A9 + 0002:00003C54 00000010 C=BSS S=.bss G=DGROUP M=Menus ACBP=A9 + 0002:00003C64 00000020 C=BSS S=.bss G=DGROUP M=Forms ACBP=A9 + 0002:00003C84 00000014 C=BSS S=.bss G=DGROUP M=RedirectConsole ACBP=A9 + 0002:00003C98 00000004 C=BSS S=.bss G=DGROUP M=IniFiles ACBP=A9 + 0002:00003C9C 00000004 C=BSS S=.bss G=DGROUP M=WinSock ACBP=A9 + 0002:00003CA0 00000004 C=BSS S=.bss G=DGROUP M=SyncObjs ACBP=A9 + 0002:00003CA4 00000194 C=BSS S=.bss G=DGROUP M=ScktComp ACBP=A9 + 0002:00003E38 00000004 C=BSS S=.bss G=DGROUP M=JvWin32 ACBP=A9 + 0002:00003E3C 00000004 C=BSS S=.bss G=DGROUP M=JvConsts ACBP=A9 + 0002:00003E40 00000004 C=BSS S=.bss G=DGROUP M=JVCLVer ACBP=A9 + 0002:00003E44 00000004 C=BSS S=.bss G=DGROUP M=JvComponentBase ACBP=A9 + 0002:00003E48 00000004 C=BSS S=.bss G=DGROUP M=DateUtils ACBP=A9 + 0002:00003E4C 00000004 C=BSS S=.bss G=DGROUP M=JvResources ACBP=A9 + 0002:00003E50 00000004 C=BSS S=.bss G=DGROUP M=JvTypes ACBP=A9 + 0002:00003E54 00000004 C=BSS S=.bss G=DGROUP M=JvVCL5Utils ACBP=A9 + 0002:00003E58 00000004 C=BSS S=.bss G=DGROUP M=ComConst ACBP=A9 + 0002:00003E5C 00000011 C=BSS S=.bss G=DGROUP M=ComObj ACBP=A9 + 0002:00003E70 00000004 C=BSS S=.bss G=DGROUP M=MMSystem ACBP=A9 + 0002:00003E74 00000004 C=BSS S=.bss G=DGROUP M=Registry ACBP=A9 + 0002:00003E78 00000008 C=BSS S=.bss G=DGROUP M=JvJCLUtils ACBP=A9 + 0002:00003E80 00000004 C=BSS S=.bss G=DGROUP M=RichEdit ACBP=A9 + 0002:00003E84 00000004 C=BSS S=.bss G=DGROUP M=ToolWin ACBP=A9 + 0002:00003E88 00000004 C=BSS S=.bss G=DGROUP M=ComStrs ACBP=A9 + 0002:00003E8C 00000030 C=BSS S=.bss G=DGROUP M=Buttons ACBP=A9 + 0002:00003EBC 00000004 C=BSS S=.bss G=DGROUP M=ExtDlgs ACBP=A9 + 0002:00003EC0 00000004 C=BSS S=.bss G=DGROUP M=Mapi ACBP=A9 + 0002:00003EC4 00000009 C=BSS S=.bss G=DGROUP M=ExtActns ACBP=A9 + 0002:00003ED0 00000004 C=BSS S=.bss G=DGROUP M=ListActns ACBP=A9 + 0002:00003ED4 0000000C C=BSS S=.bss G=DGROUP M=ComCtrls ACBP=A9 + 0002:00003EE0 00000004 C=BSS S=.bss G=DGROUP M=MaskUtils ACBP=A9 + 0002:00003EE4 00000004 C=BSS S=.bss G=DGROUP M=Mask ACBP=A9 + 0002:00003EE8 00000004 C=BSS S=.bss G=DGROUP M=Grids ACBP=A9 + 0002:00003EEC 00000004 C=BSS S=.bss G=DGROUP M=JclResources ACBP=A9 + 0002:00003EF0 00000004 C=BSS S=.bss G=DGROUP M=JclBase ACBP=A9 + 0002:00003EF4 00000004 C=BSS S=.bss G=DGROUP M=AccCtrl ACBP=A9 + 0002:00003EF8 00000004 C=BSS S=.bss G=DGROUP M=JclWin32 ACBP=A9 + 0002:00003EFC 00000004 C=BSS S=.bss G=DGROUP M=JclConsole ACBP=A9 + 0002:00003F00 00000004 C=BSS S=.bss G=DGROUP M=JclWideStrings ACBP=A9 + 0002:00003F04 00000004 C=BSS S=.bss G=DGROUP M=JclLogic ACBP=A9 + 0002:00003F08 00000504 C=BSS S=.bss G=DGROUP M=JclStrings ACBP=A9 + 0002:0000440C 00000004 C=BSS S=.bss G=DGROUP M=Jcl8087 ACBP=A9 + 0002:00004410 00000004 C=BSS S=.bss G=DGROUP M=JclMath ACBP=A9 + 0002:00004414 00000004 C=BSS S=.bss G=DGROUP M=JclSysUtils ACBP=A9 + 0002:00004418 00000004 C=BSS S=.bss G=DGROUP M=Snmp ACBP=A9 + 0002:0000441C 00000004 C=BSS S=.bss G=DGROUP M=TlHelp32 ACBP=A9 + 0002:00004420 00000004 C=BSS S=.bss G=DGROUP M=PsAPI ACBP=A9 + 0002:00004424 00000004 C=BSS S=.bss G=DGROUP M=JclRegistry ACBP=A9 + 0002:00004428 00000004 C=BSS S=.bss G=DGROUP M=JclIniFiles ACBP=A9 + 0002:0000442C 00000010 C=BSS S=.bss G=DGROUP M=JclSysInfo ACBP=A9 + 0002:0000443C 00000004 C=BSS S=.bss G=DGROUP M=JclShell ACBP=A9 + 0002:00004440 00000004 C=BSS S=.bss G=DGROUP M=JclSecurity ACBP=A9 + 0002:00004444 00000004 C=BSS S=.bss G=DGROUP M=JclDateTime ACBP=A9 + 0002:00004448 00000004 C=BSS S=.bss G=DGROUP M=JclFileUtils ACBP=A9 + 0002:0000444C 00000008 C=BSS S=.bss G=DGROUP M=JclRTTI ACBP=A9 + 0002:00004454 00000004 C=BSS S=.bss G=DGROUP M=JclMime ACBP=A9 + 0002:00004458 00000004 C=BSS S=.bss G=DGROUP M=JvPropertyStore ACBP=A9 + 0002:0000445C 00000008 C=BSS S=.bss G=DGROUP M=JvAppStorage ACBP=A9 + 0002:00004464 00000004 C=BSS S=.bss G=DGROUP M=JvProgressUtils ACBP=A9 + 0002:00004468 00000004 C=BSS S=.bss G=DGROUP M=JvJVCLUtils ACBP=A9 + 0002:0000446C 00000004 C=BSS S=.bss G=DGROUP M=JvTrayIcon ACBP=A9 + 0002:00004470 00000004 C=BSS S=.bss G=DGROUP M=modRichEdit ACBP=A9 + 0002:00004474 00000004 C=BSS S=.bss G=DGROUP M=modSCPUtils ACBP=A9 + 0002:00004478 00000008 C=BSS S=.bss G=DGROUP M=fMain ACBP=A9 + + + Address Publics by Name + + 0002:00003B9C .01 + 0002:0000445C .01 + 0002:00003EFC .01 + 0002:00003B7C .1 + 0002:00003B8C .1 + 0002:00003B90 .1 + 0002:00003EF4 .1 + 0002:00003B98 .1 + 0002:00004470 .1 + 0002:00003BB4 .1 + 0002:00003EEC .1 + 0002:00003BC4 .1 + 0002:00004418 .1 + 0002:00004428 .1 + 0002:0000372C .1 + 0002:00003724 .1 + 0002:00003730 .1 + 0002:00003EC0 .1 + 0002:0000371C .1 + 0002:00003E88 .1 + 0002:00003E80 .1 + 0002:00003E78 .1 + 0002:0000440C .1 + 0002:00003E58 .1 + 0002:00003E54 .1 + 0002:0000443C .1 + 0002:00004440 .1 + 0002:00003E4C .1 + 0002:00003E48 .1 + 0002:00003F08 .1 + 0002:00003F04 .1 + 0002:00003E40 .1 + 0002:00003E3C .1 + 0002:00003E38 .1 + 0002:00003AF0 .1 + 0002:00003B1C .1 + 0002:00004420 .1 + 0002:00003854 .1 + 0002:00003B30 .1 + 0002:0000441C .1 + 0002:00004454 .1 + 0002:00003C9C .1 + 0002:00003C94 .1 + 0002:00004464 .1 + 0002:00003B64 .1 + 0002:00003A84 .1 + 0002:00004474 .1 + 0002:00003A34 .1 + 0002:00003B80 .1 + 0002:00003B84 .1 + 0002:00003B88 .1 + 0002:00003EE8 .11 + 0002:00003A8C .12 + 0002:00003B94 .12 + 0002:00003BAC .2 + 0002:0000446C .2 + 0002:00003B34 .2 + 0002:00003AE8 .2 + 0002:00004444 .2 + 0002:00003E44 .2 + 0002:0000442C .2 + 0002:00003EE0 .2 + 0002:00003EF8 .2 + 0002:00004424 .2 + 0002:00003AEC .21 + 0002:00003EBC .3 + 0002:00003B40 .3 + 0002:00003F00 .3 + 0002:00003B3C .3 + 0002:00003A3C .3 + 0002:00003728 .3 + 0002:00003C50 .3 + 0002:00003A48 .35 + 0002:00003ED4 .36 + 0002:00004458 .4 + 0002:00003EF0 .4 + 0002:0000447C .4 + 0002:0000444C .4 + 0002:00003E8C .4 + 0002:00003E84 .4 + 0002:00003C6C .41 + 0002:00003E5C .41 + 0002:00003CA4 .41 + 0002:00003B78 .42 + 0002:00004448 .42 + 0002:00004414 .5 + 0002:000035BC .5 + 0002:00003EE4 .5 + 0002:00003E74 .5 + 0002:00003A38 .6 + 0002:00003CA0 .6 + 0002:00004468 .6 + 0002:00003BB8 .63 + 0002:00003E70 .7 + 0002:00003E50 .7 + 0002:00004410 .7 + 0002:00003BD4 .72 + 0002:00003EC4 .72 + 0002:00003C98 .8 + 0002:00003ED0 .8 + 0002:00003C4C .8 + 0002:000038D0 .81 + 0002:00003C5C .9 + 0002:00003844 .94 + 0001:00001B00 @AbstractError + 0001:00002CA8 @AfterConstruction + 0001:00002AB4 @AsClass + 0001:00001DE4 @Assign + 0001:00001FA4 @AStrCmp + 0001:00002CB8 @BeforeDestruction + 0001:00002844 @BoundErr + 0001:00002B00 @CallDynaInst + 0001:00002C50 @ClassCreate + 0001:00002CA0 @ClassDestroy + 0001:00001EAC @Close + 0001:000018D4 @Copy + 0001:000043E0 @CopyArray + 0001:000042C4 @CopyRecord + 0001:00004670 @DispCallByIDError + 0001:00003134 @DoneExcept + 0001:00004DAC @DynArrayAsg + 0001:00004D70 @DynArrayClear + 0001:00004C5C @DynArrayCopy + 0001:00004C7C @DynArrayCopyRange + 0001:00004A9C @DynArrayHigh + 0001:00004A94 @DynArrayLength + 0001:00004C50 @DynArraySetLength + 0001:00002014 @EofText + 0001:0000321C @ExceptionHandler + 0001:0000204C @FillChar + 0001:000042B8 @Finalize + 0001:000041CC @FinalizeArray + 0001:00004198 @FinalizeRecord + 0001:00001EA0 @Flush + 0001:00002838 @FpuInit + 0001:00002774 @FpuMaskInit + 0001:0000175C @FreeMem + 0001:0000173C @GetMem + 0001:00005A94 @GetTls + 0001:0000365C @Halt + 0001:00003584 @Halt0 + 0001:00002DCC @HandleAnyException + 0001:00003080 @HandleFinally + 0001:00002EF8 @HandleOnException + 0001:00005AE0 @InitExe + 0001:00004104 @InitializeArray + 0001:000040D4 @InitializeRecord + 0001:0000342C @InitImports + 0001:00003404 @InitResStringImports + 0001:00003450 @InitWideStrings + 0001:0000548C @IntfAddRef + 0001:00005460 @IntfCast + 0001:0000541C @IntfClear + 0001:00005434 @IntfCopy + 0001:00002A90 @IsClass + 0001:00002744 @isNECWindows + 0001:00003B98 @LStrAddRef + 0001:0000371C @LStrArrayClr + 0001:0000374C @LStrAsg + 0001:000039B8 @LStrCat + 0001:000039FC @LStrCat3 + 0001:00003A70 @LStrCatN + 0001:000036F8 @LStrClr + 0001:00003AF4 @LStrCmp + 0001:00003C08 @LStrCopy + 0001:00003C48 @LStrDelete + 0001:00003960 @LStrFromArray + 0001:000038D8 @LStrFromChar + 0001:000038E8 @LStrFromPChar + 0001:000037E8 @LStrFromPCharLen + 0001:00003918 @LStrFromPWChar + 0001:0000384C @LStrFromPWCharLen + 0001:00003954 @LStrFromString + 0001:00003978 @LStrFromWStr + 0001:00003C90 @LStrInsert + 0001:00003790 @LStrLAsg + 0001:000039B0 @LStrLen + 0001:00003CEC @LStrPos + 0001:00003D34 @LStrSetLength + 0001:00003BA8 @LStrToPChar + 0001:0000398C @LStrToString + 0001:000037BC @NewAnsiString + 0001:00003DC0 @NewWideString + 0001:0000245C @Pow10 + 0001:00001F20 @PStrCmp + 0001:00001F04 @PStrNCpy + 0001:000030E0 @RaiseAgain + 0001:000030B8 @RaiseExcept + 0001:000020A8 @ReadChar + 0001:00002200 @ReadLn + 0001:00002194 @ReadLString + 0001:00002188 @ReadString + 0001:0000177C @ReallocMem + 0001:00001B74 @ResetText + 0001:00001B80 @RewritText + 0001:00001AD0 @ROUND + 0001:00003668 @RunError + 0001:00002440 @SetEq + 0001:000033C4 @StartExe + 0001:00000330 @strlen + 0001:00001ADC @TRUNC + 0001:00003164 @TryFinallyExit + 0001:00003C00 @UniqueStringA + 0001:00004870 @ValInt64 + 0001:00002230 @ValLong + 0001:000045A0 @VarCast + 0001:00004590 @VarClear + 0001:00004668 @VarClr + 0001:0000464C @VarCmpEQ + 0001:00004598 @VarCopy + 0001:0000460C @VarFromBool + 0001:00004624 @VarFromCurr + 0001:00004644 @VarFromDisp + 0001:000045F0 @VarFromInt + 0001:000045F8 @VarFromInt64 + 0001:0000463C @VarFromIntf + 0001:0000462C @VarFromLStr + 0001:00004614 @VarFromReal + 0001:0000461C @VarFromTDateTime + 0001:00004634 @VarFromWStr + 0001:00004658 @VarNeg + 0001:00004660 @VarNot + 0001:000045B8 @VarToBool + 0001:000045C8 @VarToCurr + 0001:000045E8 @VarToDisp + 0001:000045A8 @VarToInt + 0001:000045B0 @VarToInt64 + 0001:000045E0 @VarToIntf + 0001:000045D0 @VarToLStr + 0001:000045C0 @VarToReal + 0001:000045D8 @VarToWStr + 0001:00002340 @WriteBytes + 0001:00003D98 @WriteLString + 0001:00002394 @WriteSpaces + 0001:00003E00 @WStrArrayClr + 0001:00003E24 @WStrAsg + 0001:00003F60 @WStrCat + 0001:00003DE8 @WStrClr + 0001:00003FC0 @WStrCmp + 0001:00004044 @WStrCopy + 0001:00003F34 @WStrFromLStr + 0001:00003E48 @WStrFromPCharLen + 0001:00003EF8 @WStrFromPWChar + 0001:00003ED4 @WStrFromPWCharLen + 0001:00003F54 @WStrLen + 0001:00004090 @WStrSetLength + 0001:00003F44 @WStrToPWChar + 0001:0000241C @_CLenToPasStr + 0001:00002410 @_CToPasStr + 0001:000018A4 @_IOTest + 0001:0000469C @_lldiv + 0001:00004764 @_llmod + 0001:00004678 @_llmul + 0001:00004830 @_llshl + 0001:00004718 @_lludiv + 0001:000047E0 @_llumod + 0001:00004850 @_llushr + 0001:0000B4D4 Abort + 0001:0002E0AC AbortProc + 0001:0003CD74 AbsMin + 0001:0000B8DC AbstractErrorHandler + 0002:0000302C AbstractErrorProc + 0001:000750E0 AccCtrl + 0001:00061B88 accept + 0002:00000128 AccessMode + 0001:0000180C AcquireExceptionObject + 0001:0001A764 ActivateClassGroup + 0001:00006150 ActivateKeyboardLayout + 0002:00003C08 ActiveDrag + 0001:00018194 ActiveX + 0001:0004BD20 ActnList + 0001:00000454 AddBlockAfter + 0001:00078278 AddColouredLine + 0001:00078318 AddColourToLine + 0002:000005AC AddDataModule + 0001:00007848 AddExitProc + 0001:0001E20C AddFinished + 0001:00078584 AddHilightedItem + 0001:0004F114 AddIn + 0001:000052B0 AddModuleUnloadProc + 0001:000052C0 AddModuleUnloadProc + 0001:0001E244 AddNotFinished + 0001:00022DA8 AddThread + 0001:000281E4 AdjustColor + 0001:000384A0 AdjustColors + 0001:0006CFAC AdjustLineBreaks + 0001:00007B20 AdjustLineBreaks + 0001:00056834 Adjustment + 0001:00006158 AdjustWindowRectEx + 0002:00000D60 Alignments + 0002:00000D70 Alignments + 0002:00000A94 Alignments + 0002:00000A84 Alignments + 0002:00000AC0 Alignments + 0002:000009EC Alignments + 0001:0005D730 AlignWork + 0001:00042400 AlignWork + 0001:00024590 AllocateHWnd + 0001:00076454 AllocateHWndEx + 0002:00001920 AllocGranularity + 0001:000077FC AllocMem + 0002:000035B4 AllocMemCount + 0002:000035B8 AllocMemSize + 0001:0002BC40 AllocPatternBitmap + 0001:00005A3C AllocTlsBuffer + 0001:000217C4 AncestorValid + 0002:00000B4C AnchorAlign + 0001:00076C90 AnimateFromTray + 0001:00076C54 AnimateToTray + 0002:00000B40 AnimateWindowProc + 0002:00000C48 AnimationStyle + 0002:00003F0C AnsiCaseMap + 0002:000014C4 AnsiCaseMapReady + 0002:0000420C AnsiCharTypes + 0001:00007A28 AnsiCompareStr + 0001:00007A60 AnsiCompareText + 0001:00039010 AnsiContainsText + 0001:0000816C AnsiLastChar + 0001:00006160 AnsiLower + 0001:000079F4 AnsiLowerCase + 0001:0000C0FC AnsiLowerCaseFileName + 0001:0000C0C4 AnsiPos + 0001:00039080 AnsiReplaceText + 0001:000537F8 AnsiSameCaption + 0001:00007A98 AnsiSameText + 0001:00007AB0 AnsiStrLIComp + 0001:0000C188 AnsiStrPos + 0001:0000C228 AnsiStrRScan + 0001:0000C250 AnsiStrScan + 0001:00005898 AnsiToUtf8 + 0001:000079C0 AnsiUpperCase + 0001:00013CA8 AnyOp + 0001:000130D4 AnyToIntf + 0001:00009760 AppendChars + 0001:00009B24 AppendFormat + 0001:000097C4 AppendNumber + 0001:000097A4 AppendString + 0002:00003C64 Application + 0002:000005BC ApplicationHandleException + 0002:000005C4 ApplicationShowException + 0002:00000EA4 AppVisible + 0002:00001414 Arrangements + 0001:0000B8C0 AssertErrorHandler + 0002:00003024 AssertErrorProc + 0001:000177CC AssignLongStr + 0001:00017E48 AssignVariant + 0002:0000141C AutoArrange + 0002:00003608 avail + 0001:000082A0 BackfillGetDiskFreeSpaceEx + 0001:0003F8F0 BackgroundClipped + 0001:0000D80C BackupVarBoolFromStr + 0001:0000D96C BackupVarBStrFromBool + 0001:0000D88C BackupVarBStrFromCy + 0001:0000D8FC BackupVarBStrFromDate + 0001:0000D7A0 BackupVarCyFromStr + 0001:0000D734 BackupVarDateFromStr + 0001:0000D5F0 BackupVarI4FromStr + 0001:0000D59C BackupVariantChangeTypeEx + 0001:0000D65C BackupVarR4FromStr + 0001:0000D6C8 BackupVarR8FromStr + 0002:00000420 BaseTypeMap + 0001:0001AB38 BeginGlobalLoading + 0001:00006168 BeginPaint + 0001:000036AC BeginThread + 0001:000281F0 BetterSize + 0001:0004FEF8 BiDiDraw + 0001:00061B90 bind + 0001:00022D14 BinToHex + 0001:00005F48 BitBlt + 0002:0000137C BitBtnCaptions + 0002:00003E90 BitBtnGlyphs + 0002:00000964 BitmapCanvasList + 0002:00003AA4 BitmapImageLock + 0001:0000D5D8 BiUnimplemented + 0002:00000680 BlockCode + 0002:000035E0 blockDescBlockList + 0002:000035E4 blockDescFreeList + 0002:00000590 BooleanIdents + 0002:0000041C BooleanToStringRule + 0002:000014C8 Bools + 0001:00007F88 BoolToStr + 0001:00012190 BoolToWStrViaOS + 0002:00000AAC Borders + 0002:000013F4 BorderStyles + 0002:00000DEC BorderStyles + 0002:000009B4 BorderStyles + 0002:00000AB8 BorderStyles + 0001:00005C10 Bounds + 0001:00019A80 Bounds + 0002:00000D08 Breaks + 0002:00003ADC BrushManager + 0001:00052608 BuildImage + 0002:00000B14 ButtonCaptions + 0002:00001978 ButtonNames + 0002:00000AE8 ButtonNames + 0002:00000D84 Buttons + 0001:00067AFC Buttons + 0002:00000A7C ButtonStyles + 0001:000279D0 BytesPerScanline + 0001:00027D28 ByteSwapColors + 0001:0000BE78 ByteToCharIndex + 0001:0000BE50 ByteToCharLen + 0001:0000BE14 ByteType + 0001:0000BD9C ByteTypeTest + 0001:000244CC CalcJmpOffset + 0001:00049D10 CalcSplitterPos + 0001:00006170 CallNextHookEx + 0001:0000CA50 CallTerminateProcs + 0001:00006178 CallWindowProc + 0001:0003DD94 CancelDrag + 0002:00003C1C CanvasList + 0002:00003AE0 CanvasList + 0002:00000AD4 Captions + 0002:00000C04 CaptureControl + 0002:00000CA8 cBooleanToItemAutoFlag + 0002:000004B4 CBooleanToRelationship + 0001:00005C2C CenterPoint + 0002:00003BAA CF_COMPONENT + 0002:00003BA8 CF_PICTURE + 0002:000038C8 ChangeAnyProc + 0002:00000A30 CharCases + 0002:000009CC CharCases + 0001:00003818 CharFromWChar + 0001:000752B4 CharIsLower + 0001:000752C8 CharIsUpper + 0001:0000C04C CharLength + 0001:00006180 CharLowerBuff + 0001:00006188 CharNext + 0001:00000298 CharNext + 0001:000261D8 CharsetToIdent + 0001:0000BF60 CharToByteIndex + 0001:0000BFC4 CharToByteLen + 0001:00006190 CharUpperBuff + 0001:000287A0 CheckBool + 0001:0006BF40 CheckCommonControl + 0001:00063420 CheckError + 0001:00002D48 CheckJmp + 0001:00006198 CheckMenuItem + 0002:00000CF8 Checks + 0001:00062E54 CheckSocketResult + 0001:00022E54 CheckSynchronize + 0001:00056270 CheckTaskWindow + 0001:00013D34 CheckType + 0001:0001492C CheckType + 0001:0003DA48 CheckUndock + 0001:0000BD7C CheckWin32Version + 0001:000061A0 ChildWindowFromPoint + 0002:000019CC cHintSize + 0002:000019E0 cInfoFlagValues + 0002:00000438 CInvalidCustomVariantType + 0002:00000CAC cItemAutoFlagToBoolean + 0002:00000CA4 cItemAutoFlagToMenu + 0001:00024714 Classes + 0001:0001A528 ClassNotFound + 0001:00062FB8 Cleanup + 0002:000038C4 ClearAnyProc + 0001:00025A68 ClearColor + 0001:00067248 ClearExcepInfo + 0001:00075E68 ClearInfoList + 0001:00016AE8 ClearVariantTypeList + 0001:000061A8 ClientToScreen + 0001:000472B4 ClientToWindow + 0002:0000095C ClipboardFormats + 0001:00038FB8 Clipbrd + 0001:00000238 CloseHandle + 0001:00005CB8 CloseHandle + 0001:0002DF48 ClosePrinter + 0001:00061B98 closesocket + 0002:00003040 CmdLine + 0002:0000303C CmdShow + 0002:00000CA0 cMenuAutoFlagToItem + 0002:000004C0 CmpTypeMap + 0001:0000D5E4 CmpUnimplemented + 0002:00001304 CoAddRefServerProcess + 0002:000012FC CoCreateInstanceEx + 0002:00001470 Codes + 0002:000013E4 Codes + 0002:00001314 CoInitFlags + 0001:00018138 CoInitialize + 0002:00001300 CoInitializeEx + 0001:0001ADF4 CollectionsEqual + 0002:000006DC Colors + 0001:00025FD0 ColorToIdent + 0001:00025FC0 ColorToRGB + 0002:00000EC4 ColorValues + 0002:00001444 ColumnClicks + 0002:000014A0 ComboBoxExStyles + 0002:00000A1C ComboBoxStyles + 0002:000014AC ComboExStyles + 0002:00003E64 ComClassManagerVar + 0001:000666F8 ComConst + 0002:00003AF4 ComCtl32DLL + 0001:00074DF8 ComCtrls + 0002:00003C60 CommandPool + 0001:0002C6E8 CommCtrl + 0001:000373E0 CommDlg + 0001:00000734 Commit + 0002:00003624 committedRoot + 0001:00067510 ComObj + 0001:0004E6F8 CompareFront + 0001:00007928 CompareMem + 0001:000078F8 CompareStr + 0001:00005CC0 CompareString + 0001:00007948 CompareText + 0001:00007EB0 CompareWith + 0001:0001EC2C ComponentCreated + 0001:00067A24 ComStrs + 0001:00061BA0 connect + 0001:00024A38 Consts + 0001:0002C140 Contnrs + 0002:00003BDA ControlAtom + 0002:00003BE0 ControlAtomString + 0001:0005B018 ControlHasHelp + 0001:0004A9AC Controls + 0002:000013C8 ConversionFormatList + 0002:000005F0 Convert + 0002:000005E0 Convert + 0001:0000B284 ConvertAddr + 0001:000098B4 ConvertEraString + 0001:000077C0 ConvertError + 0001:000077D8 ConvertErrorFmt + 0001:000714C0 ConvertFlags + 0001:00071330 ConvertMask + 0001:000714E4 ConvertStates + 0001:00009A1C ConvertYearString + 0001:00004AA4 CopyArray + 0001:0002927C CopyBitmap + 0001:00029944 CopyBitmapAsMask + 0001:000298E0 CopyPalette + 0001:000516B4 CopyToBest + 0002:00001308 CoReleaseServerProcess + 0002:0000130C CoResumeClassObjects + 0002:00001310 CoSuspendClassObjects + 0001:00018140 CoUninitialize + 0001:0000BED0 CountChars + 0002:00003ABC CounterLock + 0002:0000043C CRangeToType + 0002:00000EB8 crDragAlt + 0001:00076288 CreateAppStoragePropertyEngineList + 0001:0000B804 CreateAssertException + 0001:0000B98C CreateAVObject + 0001:00005F50 CreateBitmap + 0001:00005F58 CreateBrushIndirect + 0001:00005F60 CreateCompatibleBitmap + 0001:00005F68 CreateCompatibleDC + 0001:0001ECAC CreateComponent + 0001:00005F70 CreateDC + 0001:00005F80 CreateDIBitmap + 0001:00005F78 CreateDIBSection + 0001:00005CC8 CreateEvent + 0001:00005CD0 CreateFile + 0001:00000240 CreateFileA + 0001:00005F88 CreateFontIndirect + 0001:00005F90 CreateHalftonePalette + 0001:00005F98 CreateIC + 0001:000061B0 CreateIcon + 0001:0000B730 CreateInOutError + 0001:000061B8 CreateMenu + 0001:00005FA0 CreatePalette + 0001:00005FA8 CreatePenIndirect + 0001:00005CD8 CreatePipe + 0001:000061C0 CreatePopupMenu + 0001:00005CE0 CreateProcess + 0001:00005FB0 CreateSolidBrush + 0001:00027D80 CreateSystemPalette + 0001:000002A0 CreateThread + 0001:00005CE8 CreateThread + 0001:00006728 CreateWindow + 0001:000061C8 CreateWindowEx + 0002:00000B44 CreationControl + 0002:00000ACC CreationControl + 0002:0000057C CRelationshipToBoolean + 0002:00000400 CResult + 0002:00000EBC crMultiDragAlt + 0002:00000EB4 crMultiDragLink + 0002:00000EC0 crMultiDragLinkAlt + 0002:00000120 cSimpleBoolStrs + 0002:00000528 CText + 0002:00000C40 Ctl3DStyles + 0002:00000A74 Ctl3DStyles + 0002:00000524 CTruth + 0002:0000361C curAlloc + 0001:000149F0 CurrCompare + 0002:0000373C CurrencyDecimals + 0002:00003738 CurrencyFormat + 0002:00003734 CurrencyString + 0001:0000974C CurrentYear + 0001:000091E8 CurrToStr + 0001:00012128 CurrToWStrViaOS + 0002:00000E28 CursorMap + 0002:00000B54 Cursors + 0001:0003C648 CursorToIdent + 0002:00000E18 cUseAlpha + 0002:00000E20 cUseColorKey + 0002:000019A4 cUtilWindowExClass + 0002:000002F8 CVarTypeToElementInfo + 0002:00000160 CWNear + 0001:000149C8 DateCompare + 0001:00013DF8 DateOp + 0002:0000373D DateSeparator + 0001:0000A340 DateTimeToStr + 0001:0000A2B4 DateTimeToString + 0001:000092E4 DateTimeToTimeStamp + 0001:0000A310 DateToStr + 0001:0001215C DateToWStrViaOS + 0001:00065908 DateUtils + 0002:00001334 Day + 0001:000096D4 DayOfWeek + 0002:0000015C DCon10 + 0002:000006D8 DDBsOnly + 0001:00024644 DeallocateHWnd + 0001:00076538 DeallocateHWndEx + 0002:00000014 DebugHook + 0002:0000373B DecimalSeparator + 0001:000163C8 DecIndices + 0001:000096B4 DecodeDate + 0001:00009568 DecodeDateFully + 0001:000093D8 DecodeTime + 0001:000007C8 Decommit + 0001:00000DE4 DecommitFree + 0002:000035F8 decommittedRoot + 0001:0005E2F4 Default + 0001:00058D6C Default + 0002:0000000C Default8087CW + 0002:00000B48 DefaultDockTreeClass + 0001:0006FE9C DefaultListViewSort + 0002:00000020 DefaultTextLineBreakStyle + 0002:0000092C DefBrushData + 0002:00001970 DefCompanyName + 0002:000006AC DefFontData + 0001:000061D0 DefFrameProc + 0002:000001EC DefLongDayNames + 0002:000001A0 DefLongMonthNames + 0001:000061D8 DefMDIChildProc + 0002:0000090C DefPenData + 0002:000001D0 DefShortDayNames + 0002:00000170 DefShortMonthNames + 0001:000061E0 DefWindowProc + 0001:00004E04 DelayLoadResourceModule + 0001:00000484 DeleteBlock + 0001:00005CF0 DeleteCriticalSection + 0001:000003F4 DeleteCriticalSection + 0001:00005FB8 DeleteDC + 0001:00000C2C DeleteFree + 0001:000061E8 DeleteMenu + 0001:00005FC0 DeleteObject + 0001:00035D10 DeleteSelectedText + 0001:00075E44 DeleteType + 0001:00028E38 DeselectBitmap + 0001:0007629C DestroyAppStoragePropertyEngineList + 0001:000061F0 DestroyCursor + 0001:000061F8 DestroyIcon + 0001:00067A2C DestroyLocals + 0001:00006200 DestroyMenu + 0001:00006208 DestroyWindow + 0001:00039C48 DialogEnumerationTester + 0001:00038F50 Dialogs + 0002:00000968 DIBPalSizes + 0002:0000007C dig + 0002:0000145C Directions + 0001:000560C4 DisableTaskWindows + 0001:00066C5C DispatchInvoke + 0001:0006723C DispatchInvokeError + 0001:00006210 DispatchMessage + 0001:0005C280 DispatchShortCut + 0001:00067258 DispCall + 0001:0006733C DispCallByID + 0002:00003000 DispCallByIDProc + 0001:00067168 DispCallError + 0001:000077A4 DivMod + 0001:00038918 Dlgs + 0001:0005D5E4 DoAlign + 0001:00042290 DoAlign + 0001:00046230 DoCalcConstraints + 0002:00003C10 DockSiteList + 0001:000522D4 DoClick + 0001:00043918 DoControlMsg + 0001:0002DF50 DocumentProperties + 0001:00056074 DoDisableWindow + 0001:0003D374 DoDragOver + 0001:0000781C DoExitProc + 0001:00047FE4 DoFindControlZone + 0001:000561B0 DoFindWindow + 0001:00048570 DoFindZone + 0001:00048068 DoForEach + 0001:00049974 DoGetNextLimit + 0001:0005603C DoneApplication + 0001:0004A6D4 DoneControls + 0001:0000BCB8 DoneExceptions + 0001:0005A674 DoNestedActivation + 0001:0005D434 DoPosition + 0001:00041E50 DoPosition + 0001:00048F9C DoPrune + 0001:00037F60 DoRect + 0001:00049474 DoSaveZone + 0001:00049678 DoSetNewBounds + 0002:00000598 DotSep + 0001:0001C340 DoWrite + 0001:0004CE5C DoWrite + 0001:000289F8 DoWrite + 0001:00042F88 DoWriteDesignSize + 0001:00040A28 DoWriteIsControl + 0002:00003BF4 DragCapture + 0002:00003BE8 DragControl + 0001:0003DABC DragDone + 0001:0003D324 DragFindTarget + 0001:0003D2F8 DragFindWindow + 0002:00003C0C DragImageList + 0001:0003D714 DragInit + 0001:0003D884 DragInitControl + 0002:00003BF0 DragInternalObject + 0001:0003D258 DragMessage + 0002:00003BEC DragObject + 0002:00003C18 DragSave + 0002:00003C00 DragSaveCursor + 0002:00003BF8 DragStartPos + 0002:00003C04 DragThreshold + 0001:0003D444 DragTo + 0001:00006218 DrawAnimatedRects + 0001:0005E330 DrawAppIcon + 0002:00001974 DrawBitmap + 0001:00048B08 DrawCloseButton + 0001:00006220 DrawEdge + 0001:00006228 DrawFocusRect + 0001:00006230 DrawFrameControl + 0001:00048B60 DrawGrabberLine + 0001:00006238 DrawIcon + 0001:00006240 DrawIconEx + 0002:00000C7C DrawingStyles + 0001:00006248 DrawMenuBar + 0001:00053614 DrawMenuItem + 0001:00006250 DrawText + 0001:00063B8C DropStream + 0001:00027850 DupBits + 0001:00016374 DynArrayBounds + 0001:00004ABC DynArrayClear + 0001:000162EC DynArrayDim + 0001:000162D0 DynArrayElTypeInfo + 0001:000167F4 DynArrayFromVariant + 0001:00016290 DynArrayIndex + 0001:00004AC4 DynArraySetLength + 0001:00016304 DynArraySize + 0001:000164D4 DynArrayToVariant + 0001:00016434 DynArrayVariantBounds + 0001:0001648C DynArrayVarType + 0002:00000D68 EdgeStyle + 0002:00000C30 EdgeStyles + 0002:00000A64 EdgeStyles + 0002:000013FC EditStyles + 0001:0000B704 EHeapException.FreeInstance + 0002:000009E8 Empty + 0002:000013CC Empty + 0001:00014830 EmptyCompare + 0001:000141E8 EmptyOp + 0002:000038B0 EmptyParam + 0002:000000A4 EmptyStr + 0002:000000A8 EmptyWideStr + 0001:00006258 EnableMenuItem + 0002:00000D00 Enables + 0001:00006260 EnableScrollBar + 0001:00056178 EnableTaskWindows + 0001:00006268 EnableWindow + 0001:00009538 EncodeDate + 0001:00009398 EncodeTime + 0001:00005FC8 EndDoc + 0001:0001ABC0 EndGlobalLoading + 0001:00005FD0 EndPage + 0001:00006270 EndPaint + 0001:000036F0 EndThread + 0001:00005CF8 EnterCriticalSection + 0001:000003E4 EnterCriticalSection + 0001:00005D00 EnumCalendarInfoA + 0002:00003B18 EnumDisplayMonitors + 0001:0000AEF8 EnumEraNames + 0001:0000AF34 EnumEraYearOffsets + 0001:00059268 EnumMonitorsProc + 0001:0002DF58 EnumPrinters + 0001:00006278 EnumThreadWindows + 0001:00006280 EnumWindows + 0001:0006698C EOleException.Create + 0001:000668BC EOleSysError.Create + 0001:00006288 EqualRect + 0002:00003804 EraNames + 0001:0000A5B8 EraToYear + 0002:00003820 EraYearOffsets + 0002:00000074 errCaption + 0001:00001898 Error + 0001:0004E448 Error + 0001:0001A0EC Error + 0001:0001DD98 Error + 0002:00000004 ErrorAddr + 0001:0000184C ErrorAt + 0001:0000B7B0 ErrorHandler + 0002:00000208 ErrorMap + 0002:00003008 ErrorProc + 0002:000033E8 ErrOutput + 0001:000786EC EvaluateProperty + 0001:000017EC ExceptAddr + 0002:0000300C ExceptClsProc + 0001:0000BC24 ExceptHandler + 0001:0000B530 Exception.Create + 0001:0000B56C Exception.CreateFmt + 0001:0000B6BC Exception.CreateHelp + 0001:0000B5EC Exception.CreateRes + 0001:0000B628 Exception.CreateResFmt + 0002:0000301C ExceptionClass + 0001:0000B290 ExceptionErrorMessage + 0002:00000240 ExceptMap + 0001:000017CC ExceptObject + 0002:00003010 ExceptObjProc + 0002:00003004 ExceptProc + 0001:00005FD8 ExcludeClipRect + 0002:00000000 ExitCode + 0001:000034C8 ExitDll + 0002:00003048 ExitProc + 0001:000002B0 ExitProcess + 0002:00003028 ExitProcessProc + 0002:0000011C ExitProcList + 0001:000002A8 ExitThread + 0001:00067C18 ExtActns + 0001:000388C4 ExtCtrls + 0001:00067B54 ExtDlgs + 0001:00008258 ExtractFileExt + 0001:00008220 ExtractFileName + 0001:000081EC ExtractFilePath + 0001:00005FE0 ExtTextOut + 0002:00003840 FalseBoolStrs + 0002:00003BB0 FClipboard + 0002:00000150 FCon1E18 + 0001:00061B70 FD_SET + 0001:00061B80 FD_ZERO + 0001:0002E060 FetchStr + 0001:000080F4 FileAge + 0001:000080EC FileClose + 0001:00008054 FileCreate + 0001:00008030 FileCreate + 0001:0000815C FileExists + 0002:00000960 FileFormats + 0002:00000008 FileMode + 0001:00001BC8 FileNOPProc + 0001:00007FD4 FileOpen + 0001:0000805C FileRead + 0002:000005D4 FilerSignature + 0001:000080B4 FileSeek + 0001:00005D08 FileTimeToDosDateTime + 0001:00005D10 FileTimeToLocalFileTime + 0001:00008088 FileWrite + 0001:00000D14 FillAfterGap + 0001:00000CC0 FillBeforeGap + 0001:00000DAC FillerSizeAfterGap + 0001:00000D3C FillerSizeBeforeGap + 0001:00006290 FillRect + 0001:000666C8 Finalization + 0001:0002C6B8 Finalization + 0001:00075BB4 Finalization + 0001:00066318 Finalization + 0001:00075C1C Finalization + 0001:00075C60 Finalization + 0001:00067490 Finalization + 0001:00065B90 Finalization + 0001:00067568 Finalization + 0001:000675B8 Finalization + 0001:000658D8 Finalization + 0001:00065810 Finalization + 0001:0002CE38 Finalization + 0001:000656F8 Finalization + 0001:00075C98 Finalization + 0001:000678B8 Finalization + 0001:0006568C Finalization + 0001:0006795C Finalization + 0001:0002CE78 Finalization + 0001:00067994 Finalization + 0001:000679F4 Finalization + 0001:0002C110 Finalization + 0001:00065654 Finalization + 0001:0006561C Finalization + 0001:00005940 Finalization + 0001:0002BE58 Finalization + 0001:0000D374 Finalization + 0001:0002BC78 Finalization + 0001:0002DF00 Finalization + 0001:00062038 Finalization + 0001:00061C48 Finalization + 0001:00067AC4 Finalization + 0001:00075DBC Finalization + 0001:00075F58 Finalization + 0001:0002DF68 Finalization + 0001:00067B24 Finalization + 0001:00075FB4 Finalization + 0001:00067B70 Finalization + 0001:00067BC8 Finalization + 0001:000696E0 Finalization + 0001:0007616C Finalization + 0001:00005B24 Finalization + 0001:00006BDC Finalization + 0001:00061B20 Finalization + 0001:0002EEDC Finalization + 0001:0000688C Finalization + 0001:00060B14 Finalization + 0001:00006854 Finalization + 0001:00060568 Finalization + 0001:0000DED4 Finalization + 0001:000762B0 Finalization + 0001:000787C8 Finalization + 0001:000762F8 Finalization + 0001:00005C58 Finalization + 0001:0002F200 Finalization + 0001:0007552C Finalization + 0001:00074D80 Finalization + 0001:00074E00 Finalization + 0001:00074E38 Finalization + 0001:00074E70 Finalization + 0001:00075040 Finalization + 0001:00075078 Finalization + 0001:000750B0 Finalization + 0001:000538F4 Finalization + 0001:00024A08 Finalization + 0001:0007A3F4 Finalization + 0001:0007661C Finalization + 0001:00037258 Finalization + 0001:0004D4E4 Finalization + 0001:0004BCF0 Finalization + 0001:00037298 Finalization + 0001:0004A944 Finalization + 0001:000372D0 Finalization + 0001:00037308 Finalization + 0001:00037340 Finalization + 0001:00037378 Finalization + 0001:000373B0 Finalization + 0001:00038894 Finalization + 0001:000388E8 Finalization + 0001:000786B4 Finalization + 0001:000750F0 Finalization + 0001:00075128 Finalization + 0001:0002466C Finalization + 0001:0007516C Finalization + 0001:00078238 Finalization + 0001:000751C8 Finalization + 0001:0007A42C Finalization + 0001:000752FC Finalization + 0001:00016F38 Finalization + 0001:00038EF4 Finalization + 0001:00017300 Finalization + 0001:00075358 Finalization + 0001:00075390 Finalization + 0001:000753FC Finalization + 0001:0007544C Finalization + 0001:00075484 Finalization + 0001:000754BC Finalization + 0001:000180AC Finalization + 0001:000754F4 Finalization + 0001:00018164 Finalization + 0001:00038F7C Finalization + 0001:00039E78 Finalization + 0001:00039254 Finalization + 0001:000390EC Finalization + 0001:00066670 Finalization + 0001:00004AB4 FinalizeArray + 0001:00075A10 FinalizeSysInfo + 0001:00003304 FinalizeUnits + 0001:00052094 Find + 0001:00020F34 FindAncestor + 0001:00004E74 FindBS + 0001:0001A5E8 FindClass + 0001:00004DFC FindClassHInstance + 0001:00005D18 FindClose + 0001:000002C0 FindClose + 0001:00000C90 FindCommitted + 0001:0003C448 FindControl + 0001:0004879C FindControlAtPos + 0001:00016D90 FindCustomVariantType + 0001:00016E48 FindCustomVariantType + 0001:0003DDE0 FindDragTarget + 0001:0001EE5C FindExistingComponent + 0001:000002C8 FindFirstFile + 0001:00005D20 FindFirstFile + 0001:0001AA50 FindGlobalComponent + 0001:000562BC FindGlobalComponent + 0002:00003A54 FindGlobalComponentProcs + 0001:00004DD4 FindHInstance + 0001:0001A8F8 FindIdentToInt + 0001:0001A87C FindIntToIdent + 0002:00003BA4 FindMsg + 0001:0001E144 FindNestedComponent + 0001:0004E410 FindPopupControl + 0001:0000DB9C FindProc + 0001:00005D28 FindResource + 0001:00004E4C FindResourceHInstance + 0001:0005FDD0 FindScanline + 0001:00056214 FindTopMostWindow + 0001:0001FCCC FindUniqueName + 0001:00015BD8 FindVarData + 0001:0003DDAC FindVCLWindow + 0001:00006298 FindWindow + 0001:000062A0 FindWindowEx + 0001:00039CA0 FindWinHelp + 0001:00029230 FixupBitFields + 0002:00000D78 Flags + 0002:00003850 FLanguages + 0001:0002F230 FlatSB + 0002:00003B44 FlatSB_EnableScrollBar + 0002:00003B50 FlatSB_GetScrollInfo + 0002:00003B54 FlatSB_GetScrollPos + 0002:00003B4C FlatSB_GetScrollRange + 0002:00003B5C FlatSB_SetScrollInfo + 0002:00003B58 FlatSB_SetScrollPos + 0001:0002EF20 FlatSB_SetScrollProp + 0002:00003B60 FlatSB_SetScrollRange + 0002:00003B48 FlatSB_ShowScrollBar + 0001:00008E78 FloatToDecimal + 0001:000091B8 FloatToStr + 0001:00008BA0 FloatToText + 0001:00001E94 Flush + 0001:0007A424 fMain + 0002:00000164 FMSecsPerDay + 0001:00008A9C FmtStr + 0002:00000D90 FocusCount + 0002:00000D8C FocusMessages + 0002:0000087C FontCharsets + 0002:00003AD4 FontManager + 0001:00056290 ForegroundTask + 0001:00008A88 Format + 0002:0000016C Format + 0001:000085F4 FormatBuf + 0001:000085E8 FormatClearStr + 0001:0000857C FormatError + 0002:00000148 FormatErrorStrs + 0001:00005D30 FormatMessage + 0001:000085D4 FormatVarToStr + 0001:000605C4 Forms + 0001:00002454 FPower10 + 0002:000009B0 FPrinter + 0001:00038024 Frame3D + 0001:000062A8 FrameRect + 0001:0000CF54 FreeAndNil + 0001:000009FC FreeCommitted + 0001:00000F1C FreeCurAlloc + 0001:0003DEA0 FreeDeviceContext + 0001:0003DF5C FreeDeviceContexts + 0001:00024438 FreeIntConstList + 0001:000002D0 FreeLibrary + 0001:00005D38 FreeLibrary + 0001:00028D8C FreeMemoryContexts + 0001:0002456C FreeObjectInstance + 0001:00005D40 FreeResource + 0001:0000067C FreeSpace + 0001:0000CA6C FreeTerminateProcs + 0001:00075DF4 FreeTypeData + 0002:00003EDC FRichEditModule + 0002:00004478 frmMain + 0001:00027840 GDICheck + 0001:00027798 GDIError + 0001:00005D48 GetACP + 0001:000062B0 GetActiveWindow + 0001:0005DAC0 GetAnimation + 0001:00067830 GetAnimation + 0001:00005FE8 GetBitmapBits + 0001:000003FC GetBlockDesc + 0001:00005FF0 GetBrushOrgEx + 0001:000062B8 GetCapture + 0001:0003C6F0 GetCaptureControl + 0001:0001A594 GetClass + 0001:000062C0 GetClassInfo + 0001:000062C8 GetClassName + 0001:000062D0 GetClientRect + 0001:00005FF8 GetClipBox + 0001:00000398 GetCmdShow + 0001:0004BF40 GetColor + 0001:000002D8 GetCommandLine + 0001:00000848 GetCommitted + 0001:000008D8 GetCommittedAt + 0001:00021D7C GetComponentValue + 0001:000434CC GetControlAtPos + 0001:00009810 GetCount + 0001:00005D50 GetCPInfo + 0001:00006000 GetCurrentPositionEx + 0001:00005D58 GetCurrentProcessId + 0001:00005D60 GetCurrentThreadId + 0001:00000390 GetCurrentThreadId + 0001:00006680 GetCurrentTime + 0001:000062D8 GetCursor + 0001:0005FDE0 GetCursorHeightMargin + 0001:000062E0 GetCursorPos + 0001:0000983C GetDate + 0001:00005D68 GetDateFormat + 0001:0000A4D0 GetDateOrder + 0001:000062E8 GetDC + 0001:000062F0 GetDCEx + 0001:00006008 GetDCOrgEx + 0001:0002B888 GetDefFontCharSet + 0001:0001B8F0 GetDesigner + 0001:000062F8 GetDesktopWindow + 0001:00006020 GetDeviceCaps + 0001:00028788 GetDIB + 0001:00006010 GetDIBColorTable + 0001:00006018 GetDIBits + 0001:000286D0 GetDIBSizes + 0001:000279B0 GetDInColors + 0001:00005D70 GetDiskFreeSpaceA + 0002:00000118 GetDiskFreeSpaceEx + 0001:00049A54 GetDockAlign + 0001:0003D09C GetDockSiteAtPos + 0001:00006300 GetDoubleClickTime + 0001:0003D3B0 GetDropCtl + 0001:00002AD0 GetDynaMethod + 0001:00017370 GetEnumName + 0001:00017464 GetEnumNameValue + 0001:000174B0 GetEnumValue + 0001:0000AFAC GetEraNamesAndYearOffsets + 0001:0000A564 GetEraYearOffset + 0001:00018150 GetErrorInfo + 0001:0000B974 GetExceptionClass + 0001:0000BB58 GetExceptionObject + 0001:00005D78 GetExitCodeProcess + 0001:00005D80 GetExitCodeThread + 0001:0001A51C GetFieldClassTable + 0001:00000250 GetFileSize + 0001:00000248 GetFileType + 0001:000676D4 GetFileVersion + 0001:00005F30 GetFileVersionInfo + 0001:00005F38 GetFileVersionInfoSize + 0001:00017B38 GetFloatProp + 0001:00006308 GetFocus + 0001:000261F8 GetFontData + 0001:00006310 GetForegroundWindow + 0001:0000C4F0 GetFormatSettings + 0001:00025764 GetHashCode + 0001:0005B050 GetHelpInfo + 0001:0002D30C GetHelpSystem + 0001:0005D8A4 GetHint + 0001:0005D8DC GetHintControl + 0001:00061C00 gethostbyname + 0001:00053794 GetHotkey + 0001:00006318 GetIconInfo + 0001:00066FD4 GetIDsOfNames + 0001:00017F54 GetInt64Prop + 0001:00017FB8 GetInterfaceProp + 0001:00006330 GetKeyboardLayout + 0001:00006338 GetKeyboardLayoutList + 0001:00006340 GetKeyboardState + 0001:0000273C GetKeyboardType + 0001:00006320 GetKeyNameText + 0001:00006328 GetKeyState + 0001:00006348 GetLastActivePopup + 0001:00047D1C GetLastChildZone + 0001:00005D88 GetLastError + 0001:000002E0 GetLastError + 0001:0006FAF8 GetLength + 0001:0000AD70 GetLocaleChar + 0001:00005D98 GetLocaleInfo + 0001:000002E8 GetLocaleInfo + 0001:0000AD24 GetLocaleStr + 0001:00005D90 GetLocalTime + 0001:0003C6AC GetLongHint + 0001:000177E0 GetLongStrProp + 0001:00006350 GetMenu + 0001:0005AFD8 GetMenuHelpContext + 0001:00006358 GetMenuItemCount + 0001:00006360 GetMenuItemID + 0001:00006368 GetMenuItemInfo + 0001:000508E0 GetMenuSize + 0001:00006370 GetMenuState + 0001:00006378 GetMenuString + 0001:00006380 GetMessagePos + 0001:00017EDC GetMethodProp + 0001:000002F0 GetModuleFileName + 0001:00005DA0 GetModuleFileName + 0001:000002F8 GetModuleHandle + 0001:00005A1C GetModuleHandle + 0001:00005DA8 GetModuleHandle + 0001:00075CD0 GetModulePath + 0002:00003B0C GetMonitorInfo + 0002:00003B10 GetMonitorInfoA + 0002:00003B14 GetMonitorInfoW + 0001:0000ADD4 GetMonthDayNames + 0001:00075770 GetNativeSystemInfo + 0001:00006388 GetNextWindow + 0001:00006028 GetObject + 0001:00017608 GetOrdProp + 0001:00006030 GetPaletteEntries + 0001:00001978 GetParamStr + 0001:00006390 GetParent + 0001:00056488 GetParentForm + 0001:00006038 GetPixel + 0001:00005DB0 GetPrivateProfileString + 0001:00000300 GetProcAddress + 0001:00005DB8 GetProcAddress + 0001:00005DC0 GetProfileString + 0001:00006398 GetProp + 0001:00017514 GetPropInfo + 0001:00017584 GetPropInfos + 0001:00056948 GetRealScrollPosition + 0001:0004BF20 GetRGBColor + 0001:000063A0 GetScrollInfo + 0001:000063A8 GetScrollPos + 0001:000063B0 GetScrollRange + 0001:00061C08 getservbyname + 0001:000677BC GetShellVersion + 0001:0003C668 GetShortHint + 0001:000176D8 GetShortStrProp + 0001:00017770 GetShortStrPropAsLongStr + 0001:00061BA8 getsockopt + 0001:000005A0 GetSpace + 0001:00000604 GetSpaceAt + 0001:0004E4A0 GetSpecialName + 0001:00000308 GetStartupInfo + 0001:00005DC8 GetStartupInfo + 0001:00000258 GetStdHandle + 0001:00005DD0 GetStdHandle + 0001:00006040 GetStockObject + 0001:00005DD8 GetStringTypeEx + 0001:00005DE0 GetStringTypeExA + 0001:00017910 GetStrProp + 0001:000063B8 GetSubMenu + 0001:000063C0 GetSysColor + 0001:00005DE8 GetSystemInfo + 0001:000063C8 GetSystemMenu + 0001:000063D0 GetSystemMetrics + 0002:00003AFC GetSystemMetrics + 0001:00006048 GetSystemPaletteEntries + 0001:00006050 GetTextExtentPoint32 + 0001:00006058 GetTextMetrics + 0001:00005DF0 GetThreadLocale + 0001:00000310 GetThreadLocale + 0001:00005DF8 GetTickCount + 0001:00009874 GetTime + 0001:00005A48 GetTlsSize + 0001:0005E064 GetTopMostWindows + 0001:0003C7F8 GetTopParent + 0001:000063D8 GetTopWindow + 0001:00076C10 GetTrayHandle + 0001:00017364 GetTypeData + 0001:000063E0 GetUpdateRect + 0001:00015F0C GetVarArray + 0001:00015DC8 GetVarDataArrayInfo + 0001:00004568 GetVariantManager + 0001:00017E5C GetVariantProp + 0001:00005E00 GetVersion + 0001:00005E08 GetVersionEx + 0001:000750E8 GetVersionEx + 0001:0001797C GetWideStrProp + 0001:00017860 GetWideStrPropAsLongStr + 0001:000063E8 GetWindow + 0001:000063F0 GetWindowDC + 0001:000063F8 GetWindowLong + 0001:00006060 GetWindowOrgEx + 0001:00006400 GetWindowPlacement + 0001:00006408 GetWindowRect + 0001:00075584 GetWindowsVersion + 0001:00006410 GetWindowText + 0001:00006418 GetWindowThreadProcessId + 0001:00006420 GetWindowThreadProcessId + 0002:000019D4 GKernel32Handle + 0001:00005E10 GlobalAddAtom + 0001:00005E18 GlobalAlloc + 0001:0000668C GlobalAllocPtr + 0001:00005E20 GlobalDeleteAtom + 0001:00005E28 GlobalFindAtom + 0002:00003A58 GlobalFixupList + 0001:0001E28C GlobalFixupReferences + 0001:00005E30 GlobalFree + 0001:000066B8 GlobalFreePtr + 0001:00005E40 GlobalHandle + 0001:00005E38 GlobalLock + 0002:00003A40 GlobalNameSpace + 0001:00005E48 GlobalReAlloc + 0001:0000669C GlobalReAllocPtr + 0001:00005E50 GlobalUnlock + 0002:00003980 GOldVariantManager + 0001:0002BD4C Graphics + 0001:00074EA0 Grids + 0001:0001A710 GroupDescendentsWith + 0002:000019D8 GTriedLoadKernel32Dll + 0002:0000059C GUID_NULL + 0002:000038D4 GVariantManager + 0001:0000EA44 HandleConversionException + 0001:0001F524 HandleException + 0001:0007739C HasDoubleClickFunctionality + 0001:000331D8 HasPopup + 0001:00035CE4 HasSelectedText + 0001:00077340 HasSingleClickFunctionality + 0002:00000010 HeapAllocFlags + 0002:000035C4 heapErrorCode + 0002:000035C8 heapLock + 0001:0002DF40 HelpIntfs + 0002:00003B38 HelpManager + 0002:00003BA0 HelpMsg + 0002:00003BC8 HelpViewer + 0002:00000114 HexDisplayPrefix + 0001:00022D50 HexToBin + 0001:0007847C HexToColor + 0002:000013D0 HideScrollBars + 0002:000009D8 HideSelections + 0002:0000140C HideSelections + 0002:000013D8 HideSelections + 0001:00049AD0 HideZone + 0002:00003718 HInstance + 0002:00003C78 HintDoneEvent + 0001:0005D9AC HintGetMsgHook + 0002:00003C7C HintHook + 0001:0005D950 HintMouseThread + 0002:00003C80 HintThread + 0002:00003C74 HintThreadID + 0001:0005D8FC HintTimerProc + 0002:00000D88 HintWindowClass + 0001:0000667C HiWord + 0001:0005D9F0 HookHintHooks + 0001:00061BB0 htons + 0001:0000675C HwndMSWheel + 0002:00001488 IAlignment + 0002:00000D1C IBreaks + 0002:00000D28 IChecks + 0002:00000D30 IDefaults + 0001:000261E8 IdentToCharset + 0001:00025FE0 IdentToColor + 0001:0003C658 IdentToCursor + 0001:0001A974 IdentToInt + 0002:00000D38 IEnables + 0001:00051684 IfHotkeyAvailable + 0002:0000192C IgnorePropertyList + 0001:0002C1FC ImageList_Add + 0001:0002C21C ImageList_AddIcon + 0001:0002C24C ImageList_BeginDrag + 0001:0002C1E4 ImageList_Create + 0001:0002C1EC ImageList_Destroy + 0001:0002C25C ImageList_DragEnter + 0001:0002C264 ImageList_DragLeave + 0001:0002C26C ImageList_DragMove + 0001:0002C27C ImageList_DragShowNolock + 0001:0002C22C ImageList_Draw + 0001:0002C234 ImageList_DrawEx + 0001:0002C254 ImageList_EndDrag + 0001:0002C214 ImageList_GetBkColor + 0001:0002C284 ImageList_GetDragImage + 0001:0002C244 ImageList_GetIcon + 0001:0002C29C ImageList_GetIconSize + 0001:0002C1F4 ImageList_GetImageCount + 0001:0002C28C ImageList_Read + 0001:0002C23C ImageList_Remove + 0001:0002C204 ImageList_ReplaceIcon + 0001:0002C20C ImageList_SetBkColor + 0001:0002C274 ImageList_SetDragCursorImage + 0001:0002C2A4 ImageList_SetIconSize + 0001:0002C294 ImageList_Write + 0002:00000C8C Images + 0001:0004D514 ImgList + 0001:0002CEA8 Imm + 0002:00000C70 IMM32DLL + 0001:0004A6C0 Imm32IsIME + 0002:00000168 IMSecsPerDay + 0001:0000EB30 InBounds + 0001:0000EECC InBounds + 0001:0000EEFC Increment + 0001:0000EB60 Increment + 0001:0002C228 IndexToOverlayMask + 0001:0002C2F0 IndexToStateImageMask + 0001:00061BB8 inet_addr + 0001:00006428 InflateRect + 0002:000014D0 InfMantissa + 0001:00061B68 IniFiles + 0001:00000A88 InitAllocator + 0001:0002C6F0 InitAnApi + 0002:00003B24 InitApis + 0001:0002C150 InitComCtl + 0001:0006BF14 InitCommonControl + 0001:0002C148 InitCommonControls + 0001:0002C1B0 InitCommonControlsEx + 0001:00067418 InitComObj + 0001:0001AC1C InitComponent + 0002:00003634 InitContext + 0001:0004A75C InitControls + 0001:0002B8CC InitDefFontData + 0001:0000CA8C InitDriveSpacePtr + 0001:0000BC34 InitExceptions + 0001:0002EF7C InitFlatSB + 0001:00038DA0 InitGlobals + 0001:00028588 InitializeBitmapInfoHeader + 0001:000003DC InitializeCriticalSection + 0001:00005E58 InitializeCriticalSection + 0002:000035C0 initialized + 0001:0002EF54 InitializeFlatSB + 0001:00005AD4 InitializeModule + 0001:00005C90 InitializeSecurityDescriptor + 0001:0000DBC8 InitializeVarUtils + 0001:0004A360 InitIMM32 + 0001:0001ACC4 InitInheritedComponent + 0001:0000C304 InitLeadBytes + 0001:0002CDCC InitMultiMonStubs + 0001:0000BD24 InitPlatformId + 0002:00003044 InitProc + 0001:000604DC InitProcs + 0001:00076540 InitScreenCursors + 0001:0002B850 InitScreenLogPixels + 0001:00075834 InitSysInfo + 0001:0000C37C InitSysLocale + 0001:00005A50 InitThreadTLS + 0001:00003364 InitUnits + 0001:00004548 InitVariantManager + 0001:0003C360 InitWndProc + 0002:00000C10 InnerStyles + 0002:00000A44 InnerStyles + 0002:00003050 Input + 0001:00041DC4 InsertBefore + 0001:0005D3D4 InsertBefore + 0001:00000E94 InsertFree + 0001:00051738 InsertHotkeyFarEastFormat + 0001:00006430 InsertMenu + 0001:00006438 InsertMenuItem + 0002:00003A7C InstBlockList + 0002:00003A80 InstFreeList + 0001:00014964 Int64Compare + 0001:00013F60 Int64Op + 0001:00014950 IntCompare + 0002:00003A4C IntConstList + 0002:00001520 IntelCacheDescription + 0001:00000388 InterlockedDecrement + 0001:0000CAF4 InterlockedDecrement + 0001:0000CB00 InterlockedExchange + 0001:0000CB08 InterlockedExchangeAdd + 0001:00000380 InterlockedIncrement + 0001:0000CAE8 InterlockedIncrement + 0001:00001C08 InternalClose + 0001:000256F0 InternalDeletePalette + 0001:00001E4C InternalFlush + 0001:00000CF0 InternalFreeMem + 0001:000286D8 InternalGetDIB + 0001:0002866C InternalGetDIBSizes + 0001:0001AAB4 InternalReadComponentRes + 0001:00003BB4 InternalUniqueString + 0001:00006068 IntersectClipRect + 0001:00005B80 IntersectRect + 0001:00006440 IntersectRect + 0001:00013E54 IntOp + 0001:00007D50 IntToHex + 0001:0001A9B4 IntToIdent + 0001:00007D1C IntToStr + 0001:00007CEC IntToStr + 0001:00006448 InvalidateRect + 0001:0002772C InvalidBitmap + 0001:00027714 InvalidGraphic + 0001:00027738 InvalidIcon + 0001:000276FC InvalidOperation + 0001:00019AA8 InvalidPoint + 0001:00019ABC InvalidPoint + 0002:0000384C InvalidPointer + 0001:00002988 InvokeImplGetter + 0001:00061BC0 ioctlsocket + 0001:00001918 IOResult + 0002:00000D58 IOwnerDraw + 0002:00000D40 IRadios + 0002:00000D50 IRTL + 0001:00056418 IsAccel + 0001:000528E8 IsAccelChar + 0001:00076B6C IsApplicationMinimized + 0001:0003CE54 IsBeforeTargetWindow + 0001:00006450 IsChild + 0002:0000304C IsConsole + 0001:00021EEC IsDefault + 0001:00021C70 IsDefault + 0001:000224A8 IsDefaultValue + 0001:00022370 IsDefaultValue + 0001:0002217C IsDefaultValue + 0001:00021BD8 IsDefaultValue + 0001:00021B34 IsDefaultValue + 0001:00021A04 IsDefaultValue + 0001:0003D2B0 IsDelphiHandle + 0001:00006458 IsDialogMessage + 0001:0001630C IsDynArrayRectangular + 0002:00000D48 ISeparators + 0001:00006460 IsIconic + 0001:00052944 IsInitialChar + 0001:00009434 IsLeapYear + 0002:00003038 IsLibrary + 0002:0000304D IsMultiThread + 0001:00047780 IsOrientationSet + 0001:00005BE0 IsRectEmpty + 0001:00006468 IsRectEmpty + 0001:0003D058 IsSiteChildOfClient + 0001:000175D8 IsStoredProp + 0001:0001AA90 IsUniqueGlobalComponentName + 0002:00003A44 IsUniqueGlobalComponentNameProc + 0001:00007C88 IsValidIdent + 0001:0000C364 IsWesternGroup + 0002:0000150C IsWin2003 + 0002:00001514 IsWin2003R2 + 0002:00001504 IsWin2K + 0002:000014D8 IsWin95 + 0002:000014DC IsWin95OSR2 + 0002:000014E0 IsWin98 + 0002:000014E4 IsWin98SE + 0001:00006470 IsWindow + 0001:00006478 IsWindowEnabled + 0001:00006480 IsWindowVisible + 0002:0000151C IsWinLonghorn + 0002:000014E8 IsWinME + 0002:000014EC IsWinNT + 0001:00060670 IsWinNT + 0002:000014F0 IsWinNT3 + 0002:000014F4 IsWinNT31 + 0002:000014F8 IsWinNT35 + 0002:000014FC IsWinNT351 + 0002:00001500 IsWinNT4 + 0002:00001518 IsWinVista + 0002:00001508 IsWinXP + 0002:00001510 IsWinXP64 + 0001:00006488 IsZoomed + 0001:0004E86C Iterate + 0001:0004E8CC IterateMenus + 0001:00075388 Jcl8087 + 0001:000750A8 JclBase + 0001:00075158 JclConsole + 0001:00075CC8 JclDateTime + 0001:00075DEC JclFileUtils + 0001:0007555C JclIniFiles + 0001:000751F8 JclLogic + 0001:000753C0 JclMath + 0001:00075FE4 JclMime + 0001:00075524 JclRegistry + 0001:00075070 JclResources + 0001:00075F98 JclRTTI + 0001:00075C90 JclSecurity + 0001:00075C58 JclShell + 0001:00075344 JclStrings + 0001:00075C00 JclSysInfo + 0001:00075444 JclSysUtils + 0001:000751B4 JclWideStrings + 0001:00075120 JclWin32 + 0002:00000018 JITEnable + 0001:000762E8 JvAppStorage + 0001:00065728 JVCLVer + 0001:00065840 JvComponentBase + 0001:000656BC JvConsts + 0001:00067954 JvJCLUtils + 0001:00076678 JvJVCLUtils + 0001:00076334 JvProgressUtils + 0001:000761B4 JvPropertyStore + 0001:00065BC0 JvResources + 0001:00078270 JvTrayIcon + 0001:0006665C JvTypes + 0001:000666A0 JvVCL5Utils + 0001:00065684 JvWin32 + 0002:00004430 KernelVersionHi + 0001:000563CC KeyboardStateToShiftState + 0001:00056390 KeyDataToShiftState + 0001:0005633C KeysToShiftState + 0001:00006490 KillTimer + 0001:0000819C LastDelimiter + 0001:0000C290 LCIDToCodePage + 0002:000000F4 LeadBytes + 0001:000003EC LeaveCriticalSection + 0001:00005E60 LeaveCriticalSection + 0001:000390AC LeftStr + 0002:00000024 LibModuleList + 0001:00006070 LineTo + 0001:00069710 ListActns + 0001:0003DE28 ListAdd + 0001:00061BC8 listen + 0001:00068A28 ListItemsCompare + 0001:0003DE50 ListRemove + 0002:00003802 ListSeparator + 0001:0002C404 ListView_Arrange + 0001:0002C4B0 ListView_CreateDragImage + 0001:0002C354 ListView_DeleteAllItems + 0001:0002C45C ListView_DeleteColumn + 0001:0002C33C ListView_DeleteItem + 0001:0002C38C ListView_FindItem + 0001:0002C584 ListView_GetCheckState + 0001:0002C680 ListView_GetColumnOrderArray + 0001:0002C474 ListView_GetColumnWidth + 0001:0002C41C ListView_GetEditControl + 0001:0002C2F4 ListView_GetItem + 0001:0002C2E0 ListView_GetItemCount + 0001:0002C39C ListView_GetItemRect + 0001:0002C574 ListView_GetItemState + 0001:0002C368 ListView_GetNextItem + 0001:0002C50C ListView_GetOrigin + 0001:0002C63C ListView_GetSelectedCount + 0001:0002C4FC ListView_GetTopIndex + 0001:0002C3D8 ListView_HitTest + 0001:0002C44C ListView_InsertColumn + 0001:0002C324 ListView_InsertItem + 0001:0002C3E8 ListView_RedrawItems + 0001:0002C2AC ListView_SetBkColor + 0001:0002C5A4 ListView_SetCheckState + 0001:0002C430 ListView_SetColumn + 0001:0002C664 ListView_SetColumnOrderArray + 0001:0002C48C ListView_SetColumnWidth + 0001:0002C64C ListView_SetExtendedListViewStyle + 0001:0002C2C4 ListView_SetImageList + 0001:0002C30C ListView_SetItem + 0001:0002C600 ListView_SetItemCount + 0001:0002C610 ListView_SetItemCountEx + 0001:0002C544 ListView_SetItemState + 0001:0002C5D0 ListView_SetItemText + 0001:0002C4E4 ListView_SetTextBkColor + 0001:0002C4CC ListView_SetTextColor + 0001:0002C69C ListView_SetWorkAreas + 0001:0002C620 ListView_SortItems + 0001:0002C524 ListView_Update + 0001:00006498 LoadBitmap + 0001:00075238 LoadCaseMap + 0001:00075200 LoadCharTypes + 0001:00066A58 LoadComExProcs + 0001:000064A0 LoadCursor + 0001:000064A8 LoadIcon + 0001:00076BA8 LoadKernel32Dll + 0001:000064B0 LoadKeyboardLayout + 0001:00005E68 LoadLibrary + 0001:00000318 LoadLibraryEx + 0001:00005E70 LoadResource + 0001:00005040 LoadResourceModule + 0001:000058E8 LoadResString + 0001:000064B8 LoadString + 0001:00000320 LoadString + 0001:000003BC LocalAlloc + 0001:00005A24 LocalAlloc + 0001:000003C4 LocalFree + 0001:0000AD98 LocalGetLocaleStr + 0001:00005E78 LockResource + 0002:00003744 LongDateFormat + 0002:000037D8 LongDayNames + 0002:0000378C LongMonthNames + 0002:00003758 LongTimeFormat + 0001:000078BC LowerCase + 0001:00005F20 lstrcmp + 0001:00005F28 lstrcpy + 0001:00000328 lstrcpyn + 0002:00003A2C LVarTypes + 0002:00003A30 LVarTypeSync + 0002:00003030 MainInstance + 0002:00003034 MainThreadID + 0001:0000044C MakeEmpty + 0001:0000346C MakeErrorMessage + 0002:00000C5C MakeLast + 0001:00006670 MakeLong + 0001:00006720 MakeLParam + 0001:000244D4 MakeObjectInstance + 0001:000066CC MakeROP4 + 0001:0000B8F4 MapException + 0001:00067BC0 Mapi + 0002:000013A8 MAPIDLL + 0002:000013AC MAPIModule + 0001:0000317C MapToRunError + 0001:000064C0 MapVirtualKey + 0001:000064C8 MapWindowPoints + 0001:00074E68 Mask + 0002:00000C94 Mask + 0001:00006078 MaskBlt + 0001:00074E30 MaskUtils + 0001:0002BE88 Math + 0001:0002BE50 Max + 0001:00058DB8 MaximizedChildren + 0002:0000002C MemoryManager + 0002:00000CB0 MenuKeyCaps + 0001:00053964 Menus + 0001:0000049C MergeBlockAfter + 0001:00000F68 MergeCommit + 0001:000002B8 MessageBox + 0001:000064D0 MessageBox + 0001:000068BC Messages + 0001:0002BE48 Min + 0001:0001B514 Min + 0001:0004170C MinVar + 0002:00003B2C MMAvailable + 0001:00067598 MMSystem + 0002:00000C74 ModeMap + 0001:0005A9E4 ModifySystemMenu + 0001:000786E4 modRichEdit + 0001:000787F8 modSCPUtils + 0002:0000008C Module + 0002:0000370D ModuleIsCpp + 0002:0000370C ModuleIsLib + 0001:000244A4 ModuleUnload + 0002:00000028 ModuleUnloadList + 0002:00003B08 MonitorFromPoint + 0002:00003B04 MonitorFromRect + 0002:00003B00 MonitorFromWindow + 0002:00001340 Month + 0002:000000C4 MonthDays + 0002:00003BCC Mouse + 0001:00001938 Move + 0001:00006080 MoveToEx + 0001:0003DE70 MoveWindowOrg + 0001:000064D8 MsgWaitForMultipleObjects + 0001:00005E80 MulDiv + 0001:00005E88 MultiByteToWideChar + 0001:00000338 MultiByteToWideChar + 0001:0005FF94 MultiLineWidth + 0001:0002CE68 MultiMon + 0002:00001404 MultiSelections + 0002:00004438 MyGetFreeSystemResources + 0001:00078CD0 MyLineOut + 0002:00003E6C NeedToUninitialize + 0001:00015178 NegateAny + 0001:000150C8 NegateAsDouble + 0001:00015120 NegateByte + 0001:0001518C NegateCustom + 0001:00015144 NegateLongWord + 0001:000150F4 NegateVariant + 0001:000150E0 NegateViaOS + 0001:00015134 NegateWord + 0002:00003739 NegCurrFormat + 0001:00000FF4 NewCommit + 0001:00001020 NewCommitAt + 0002:00003BD0 NewStyleControls + 0001:0000C088 NextCharIndex + 0001:00047764 NextVisibleZone + 0002:000005D8 NilMethod + 0002:0000001C NoErrMsg + 0001:0004F680 NormalDraw + 0001:00015620 NotAny + 0001:00015578 NotAsOrdinal + 0001:000154A8 NotAsString + 0001:00015634 NotCustom + 0001:00002D34 NotifyAnyExcept + 0001:0001B988 NotifyDesigner + 0001:00002D08 NotifyExcept + 0001:00002D68 NotifyExceptFinally + 0001:0001AB90 NotifyGlobalLoading + 0001:00005340 NotifyModuleUnload + 0001:00002CE4 NotifyNonDelphiException + 0001:00002D20 NotifyOnExcept + 0001:00002CC8 NotifyReRaise + 0001:00002D90 NotifyTerminate + 0001:00002DAC NotifyUnhandled + 0001:000155F4 NotVariant + 0001:000155E0 NotViaOS + 0001:000096FC Now + 0001:000522C4 NthParentOf + 0001:00061BD0 ntohs + 0001:00016F30 Null + 0002:00000414 NullAsStringValue + 0001:00014844 NullCompare + 0002:00000408 NullEqualityRule + 0002:0000040C NullMagnitudeRule + 0001:0001413C NullOp + 0002:00000410 NullStrictConvert + 0001:00021EA4 ObjectAncestorMatch + 0001:0003C418 ObjectFromHWnd + 0002:000009E0 OEMConverts + 0001:000064E0 OemToAnsi + 0001:00005BF8 OffsetRect + 0001:000064E8 OffsetRect + 0001:00066A40 OleCheck + 0001:00066A24 OleError + 0001:000044E0 OleStrToStrVar + 0002:00003E60 OleUninitializing + 0001:000136EC OleVarFromAny + 0001:00013750 OleVarFromVarArrayProc + 0001:0002DF60 OpenPrinter + 0001:00001B1C OpenText + 0002:00000450 OpTypeMap + 0002:00000C54 OrientArray + 0002:00000C20 OuterStyles + 0002:00000A54 OuterStyles + 0002:00003848 OutOfMemory + 0001:00027744 OutOfResources + 0002:0000321C Output + 0001:00021D64 OwnedBy + 0002:00000418 PackVarCreation + 0002:00001924 PageSize + 0002:000013E0 Painting + 0002:00000970 Pal16 + 0001:00025AD4 PaletteChanged + 0001:00027F30 PaletteFromDIBColorTable + 0001:00027FD4 PaletteToDIBColorTable + 0002:0000096C PalSize + 0001:00001A64 ParamStr + 0001:00047B48 ParentNotLast + 0002:000009BC Passwords + 0001:00006088 PatBlt + 0002:00003AE4 PatternManager + 0001:000064F0 PeekMessage + 0001:00005E90 PeekNamedPipe + 0002:00003AD8 PenManager + 0002:0000093C PenModes + 0002:0000091C PenStyles + 0001:00019A30 Point + 0001:00005B78 Point + 0001:00019E84 PointerInModule + 0001:00042F74 PointsEqual + 0001:00006708 PointToSmallPoint + 0001:00006090 Polyline + 0002:00003C54 PopupList + 0001:000064F8 PostMessage + 0001:00006500 PostQuitMessage + 0001:0002EEBC Printer + 0001:0002EF18 Printers + 0002:00000664 Priorities + 0001:0005C080 ProcessExecute + 0001:00056648 ProcessHorz + 0002:0000191C ProcessorCount + 0001:0005C180 ProcessUpdate + 0001:000566B4 ProcessVert + 0002:00003A5C ProcPosted + 0002:0000196C ProgressList + 0001:0001E588 PropertyNotFound + 0001:0001F624 PropPathError + 0002:00000DB8 Props + 0001:0001E57C PropValueError + 0001:000754EC PsAPI + 0001:0007A7A4 PseuWoWConsole + 0001:00006508 PtInRect + 0001:00008B5C PutExponent + 0002:00003C14 QualifyingSites + 0001:0000B8B0 RaiseAssertException + 0001:0002E094 RaiseError + 0001:00000260 RaiseException + 0001:000670B4 RaiseException + 0001:0001D5C0 RaiseException + 0002:00003014 RaiseExceptionProc + 0001:0000C9A4 RaiseLastOSError + 0001:00066FA0 RaiseNameException + 0002:00003C88 RC_End + 0002:00003C8C RC_ExitCode + 0001:00060608 RC_LineIn + 0002:00003C90 RC_LineOut + 0001:0006075C RC_Run + 0002:00003C84 RC_SendBuf + 0001:0007031C ReadCols + 0001:000488B8 ReadControlName + 0001:00020880 ReadCustomVariant + 0001:0001E564 ReadError + 0001:00000268 ReadFile + 0001:00005E98 ReadFile + 0001:00028280 ReadIcon + 0001:00002114 ReadLine + 0002:000009C4 ReadOnlys + 0001:000149A0 RealCompare + 0001:00006098 RealizePalette + 0001:00013D7C RealOp + 0001:0001EC4C Recover + 0001:00005B5C Rect + 0001:00019A58 Rect + 0001:000060A8 Rectangle + 0001:000060A0 RectVisible + 0001:00061BD8 recv + 0001:00060B50 RedirectConsole + 0001:00006510 RedrawWindow + 0002:000038CC RefAnyProc + 0001:00005C98 RegCloseKey + 0001:00000340 RegCloseKey + 0002:00003A50 RegGroups + 0001:0001A608 RegisterClass + 0001:00006518 RegisterClass + 0001:00006520 RegisterClipboardFormat + 0001:0003D1F8 RegisterDockSite + 0002:00004460 RegisteredAppStoragePropertyEngineList + 0001:0001A9F8 RegisterFindGlobalComponentProc + 0001:0001A850 RegisterIntegerConsts + 0001:0000539C RegisterModule + 0002:000019DC RegisterServiceProcess + 0001:0002D274 RegisterViewer + 0001:00006528 RegisterWindowMessage + 0001:00067600 Registry + 0001:00005CA0 RegOpenKeyEx + 0001:00000348 RegOpenKeyEx + 0001:00000350 RegQueryValueEx + 0001:00005CA8 RegQueryValueEx + 0001:00037300 RegStr + 0001:00006530 ReleaseCapture + 0001:00006538 ReleaseDC + 0002:00000038 reMap + 0002:00003618 remBytes + 0001:0000050C RemoveBlock + 0002:000005B4 RemoveDataModule + 0001:0001E434 RemoveFixupReferences + 0001:0001E4E0 RemoveFixups + 0001:0001E7C0 RemoveGlobalFixup + 0001:00006540 RemoveMenu + 0001:000052B8 RemoveModuleUnloadProc + 0001:000052E0 RemoveModuleUnloadProc + 0001:00006548 RemoveProp + 0001:00022E10 RemoveThread + 0001:00075EC4 RemoveTypeInfo + 0001:00005EA0 ResetEvent + 0001:000014A8 ResizeInPlace + 0002:00004434 ResmeterLibHandle + 0001:000060B0 RestoreDC + 0001:00055FE8 RestoreFocusState + 0001:00005EA8 ResumeThread + 0001:0004E440 ReturnAddr + 0001:0001C4A0 ReturnAddr + 0001:0001AFE4 ReturnAddr + 0001:0000B4D0 ReturnAddr + 0001:000066D8 RGB + 0001:00027CB0 RGBQuadToTriple + 0001:00027C78 RGBTripleToQuad + 0001:0006798C RichEdit + 0001:000390C8 RightStr + 0002:00003BE4 RM_GetObjectInstance + 0002:00003C70 RM_TaskbarCreated + 0002:00003614 rover + 0002:00001928 RtdlMsiLibHandle + 0002:000013B0 RTFConversionFormat + 0001:00017330 RTLConsts + 0001:00000270 RtlUnwind + 0002:00003018 RTLUnwindProc + 0002:00000054 runErrMsg + 0001:00001840 RunErrorAt + 0001:0000D9E0 SafeArrayCreate + 0001:0000DA00 SafeArrayGetElement + 0001:0000D9F0 SafeArrayGetLBound + 0001:0000D9F8 SafeArrayGetUBound + 0001:0000DA10 SafeArrayPtrOfIndex + 0001:0000DA08 SafeArrayPutElement + 0001:0000D9E8 SafeArrayRedim + 0001:00066B5C SafeCallError + 0002:00003020 SafeCallErrorProc + 0001:0000D020 SafeLoadLibrary + 0001:0000799C SameText + 0001:000060B8 SaveDC + 0001:00055FE0 SaveFocusState + 0002:00003E68 SaveInitProc + 0001:0000A354 ScanBlanks + 0001:0000A498 ScanChar + 0001:0000A614 ScanDate + 0001:0000A378 ScanNumber + 0001:0000A40C ScanString + 0001:0000A950 ScanTime + 0001:0000A51C ScanToNumber + 0001:0006564C ScktComp + 0002:00003C68 Screen + 0002:00003A90 ScreenLogPixels + 0001:00006550 ScreenToClient + 0002:00000A04 ScrollBar + 0001:00056800 ScrollBarVisible + 0001:00006558 ScrollWindow + 0001:00001054 SearchSmallBlocks + 0001:00065848 SecondsBetween + 0001:000658A8 SecondSpan + 0001:00061BE0 select + 0001:000060C0 SelectObject + 0001:000060C8 SelectPalette + 0001:00061BE8 send + 0001:0003C484 SendAppMessage + 0001:00056250 SendFocusMessage + 0001:00006560 SendMessage + 0002:00000D14 Separators + 0001:000060D0 SetAbortProc + 0001:00006568 SetActiveWindow + 0001:00067860 SetAnimation + 0001:0005DAF0 SetAnimation + 0001:000060D8 SetBkColor + 0001:000060E0 SetBkMode + 0001:000060E8 SetBrushOrgEx + 0001:00006570 SetCapture + 0001:0003C718 SetCaptureControl + 0001:00006578 SetClassLong + 0001:00015D50 SetClearVarToEmptyParam + 0001:0001EDBC SetCompName + 0001:00006580 SetCursor + 0001:000060F0 SetDIBColorTable + 0001:00000278 SetEndOfFile + 0001:00005EB0 SetEndOfFile + 0001:00005EB8 SetErrorMode + 0001:00005EC0 SetEvent + 0001:000032BC SetExceptionHandler + 0001:00000280 SetFilePointer + 0001:00005EC8 SetFilePointer + 0001:00017C50 SetFloatProp + 0001:00006588 SetFocus + 0001:00006590 SetForegroundWindow + 0001:0004A5E4 SetImeMode + 0001:000018C4 SetInOutRes + 0001:00017F7C SetInt64Prop + 0001:00018038 SetInterfaceProp + 0001:0001F904 SetInterfaceReference + 0001:0001F820 SetIntIdent + 0002:00000D94 SetLayeredWindowAttributes + 0001:00017820 SetLongStrProp + 0001:000060F8 SetMapMode + 0001:00006598 SetMenu + 0001:000065A0 SetMenuItemInfo + 0001:00017F1C SetMethodProp + 0001:0001F868 SetObjectIdent + 0001:0001767C SetOrdProp + 0001:00006100 SetPixel + 0001:000065A8 SetProp + 0001:000065B0 SetRect + 0001:00006108 SetROP2 + 0001:000065B8 SetScrollInfo + 0001:000065C0 SetScrollPos + 0001:000065C8 SetScrollRange + 0001:00005CB0 SetSecurityDescriptorDacl + 0001:0001771C SetShortStrProp + 0001:00017798 SetShortStrPropAsLongStr + 0001:00061BF0 setsockopt + 0001:00006110 SetStretchBltMode + 0001:00017950 SetStrProp + 0001:00006118 SetTextColor + 0001:00005ED0 SetThreadLocale + 0001:00005ED8 SetThreadPriority + 0001:000065D0 SetTimer + 0001:00015D38 SetVarAsError + 0001:0000457C SetVariantManager + 0001:00017E9C SetVariantProp + 0001:0001F8A8 SetVariantReference + 0001:00006120 SetViewportOrgEx + 0001:0005FAA4 SetVisible + 0001:00017A64 SetWideStrProp + 0001:000178B8 SetWideStrPropAsLongStr + 0001:000065D8 SetWindowLong + 0001:00006128 SetWindowOrgEx + 0001:000065E0 SetWindowPlacement + 0001:000065E8 SetWindowPos + 0001:000065F8 SetWindowsHookEx + 0001:000065F0 SetWindowText + 0002:00000134 ShareMode + 0001:000372C8 ShellAPI + 0002:00003ED8 ShellModule + 0002:00003E7C ShellVersion + 0001:00037290 Shell_NotifyIcon + 0001:000373A8 ShlObj + 0001:0004E468 ShortCut + 0002:00003C58 ShortCutItems + 0001:0004E4F4 ShortCutToText + 0002:00003740 ShortDateFormat + 0002:000037BC ShortDayNames + 0002:0000375C ShortMonthNames + 0002:00003754 ShortTimeFormat + 0002:0000143C ShowColumns + 0002:00000E00 ShowCommands + 0002:00000E0C ShowCommands + 0002:00000DF4 ShowCommands + 0001:00006600 ShowCursor + 0001:0000B418 ShowException + 0002:00000C08 ShowFlags + 0002:00000EA8 ShowFlags + 0001:00055FF0 ShowMDIClientEdge + 0001:00006608 ShowOwnedPopups + 0001:00006610 ShowScrollBar + 0001:00006618 ShowWindow + 0001:00067888 ShowWinNoAnimate + 0001:0005DB18 ShowWinNoAnimate + 0001:00049B50 ShowZone + 0001:00014280 SimpleVarOp + 0002:00000C68 SizeCursors + 0001:00005EE0 SizeofResource + 0001:000203B4 SkipBinary + 0001:000203E4 SkipCollection + 0001:0002038C SkipList + 0001:00005EE8 Sleep + 0001:0000C99C Sleep + 0001:00005EF0 SleepEx + 0001:00019A48 SmallPoint + 0001:000066F4 SmallPointToPoint + 0002:00003620 smallTab + 0001:0007547C Snmp + 0001:00061BF8 socket + 0002:00000A3C Sorts + 0002:000035E8 spaceRoot + 0001:00065878 SpanOfNowAndThen + 0001:00060694 SplitLines + 0002:00000FB4 StandardColorValues + 0001:0001A6C4 StartClassGroup + 0001:00006130 StartDoc + 0001:00006138 StartPage + 0001:00062F0C Startup + 0001:00039284 StdActns + 0001:00037288 StdCtrls + 0001:000244AC StdWndProc + 0001:000763F0 StdWndProc + 0002:00003A98 StockBrush + 0002:00003A9C StockFont + 0002:00003AA0 StockIcon + 0002:00003A94 StockPen + 0001:00008520 StrAlloc + 0001:00008534 StrBufSize + 0001:0000BE38 StrByteType + 0001:0000C024 StrCharLength + 0001:000083F0 StrComp + 0001:00008350 StrCopy + 0001:0000856C StrDispose + 0001:0006D040 StreamLoad + 0001:0006CFE0 StreamSave + 0001:0004CD24 StreamsEqual + 0001:0000832C StrEnd + 0001:00006140 StretchBlt + 0001:00008A08 StrFmt + 0001:00008414 StrIComp + 0001:00014A1C StringCompare + 0001:0001D45C StringListCompareStrings + 0001:0000C868 StringReplace + 0001:00004504 StringToOleStr + 0001:000536FC StripHotkey + 0001:00008378 StrLCopy + 0001:00008314 StrLen + 0001:00008A48 StrLFmt + 0001:00008454 StrLIComp + 0001:00008340 StrMove + 0001:00008540 StrNew + 0001:0000C044 StrNextChar + 0001:0000850C StrPas + 0001:000083AC StrPCopy + 0001:000083D0 StrPLCopy + 0001:000084B8 StrPos + 0001:00008498 StrScan + 0001:0000AB48 StrToDate + 0001:0000AC18 StrToDateTime + 0001:00009218 StrToFloat + 0001:00007D8C StrToInt + 0001:00007DC8 StrToIntDef + 0001:0000ABB0 StrToTime + 0001:0003911C StrUtils + 0002:00000DE0 Styles + 0001:00018158 Succeeded + 0001:0000CF64 Supports + 0001:0000CF88 Supports + 0002:00000660 SyncList + 0001:00062068 SyncObjs + 0001:00000368 SysAllocStringLen + 0002:00001194 SysColorValues + 0001:00006C0C SysConst + 0002:00000DA8 SysConsts + 0002:00000DB0 SysConsts + 0001:0000ACD8 SysErrorMessage + 0001:00001304 SysFreeMem + 0001:00000378 SysFreeString + 0001:00018148 SysFreeString + 0001:00001174 SysGetMem + 0001:00005B54 SysInit + 0002:000037F4 SysLocale + 0001:00001678 SysReallocMem + 0001:00000370 SysReAllocStringLen + 0001:00005994 System + 0002:00003A88 SystemPalette16 + 0001:00027E98 SystemPaletteOverride + 0001:00006620 SystemParametersInfo + 0001:0000D4F4 SysUtils + 0001:00064ECC TAbstractSocket.DoError + 0001:00064EB8 TAbstractSocket.DoEvent + 0001:00064F04 TAbstractSocket.InitSocket + 0001:00064F1C TAbstractSocket.Loaded + 0001:000650E0 TAbstractSocket.Open + 0001:00064EE4 TAbstractSocket.SetActive + 0001:00064F34 TAbstractSocket.SetAddress + 0001:00064FB4 TAbstractSocket.SetHost + 0001:00065034 TAbstractSocket.SetPort + 0001:00065060 TAbstractSocket.SetService + 0001:0004B4C8 TActionLink.IsCaptionLinked + 0001:0004B4DC TActionLink.IsCheckedLinked + 0001:0004B4F0 TActionLink.IsEnabledLinked + 0001:0004B504 TActionLink.IsGroupIndexLinked + 0001:0004B518 TActionLink.IsHelpContextLinked + 0001:0004B52C TActionLink.IsHelpLinked + 0001:0004B540 TActionLink.IsHintLinked + 0001:0004B554 TActionLink.IsImageIndexLinked + 0001:0004B568 TActionLink.IsShortCutLinked + 0001:0004B57C TActionLink.IsVisibleLinked + 0001:0004B590 TActionLink.SetAutoCheck + 0001:0004B594 TActionLink.SetCaption + 0001:0004B598 TActionLink.SetChecked + 0001:0004B59C TActionLink.SetEnabled + 0001:0004B5A0 TActionLink.SetGroupIndex + 0001:0004B5A4 TActionLink.SetHelpContext + 0001:0004B5A8 TActionLink.SetHelpKeyword + 0001:0004B5AC TActionLink.SetHelpType + 0001:0004B5B0 TActionLink.SetHint + 0001:0004B5B4 TActionLink.SetImageIndex + 0001:0004B5B8 TActionLink.SetShortCut + 0001:0004B5BC TActionLink.SetVisible + 0001:0006002C TApplication.ActivateHint + 0001:0005EC20 TApplication.BringToFront + 0001:0005FDA8 TApplication.CancelHint + 0001:0005E230 TApplication.CheckIniChange + 0001:0005E004 TApplication.ControlDestroyed + 0001:0005DB58 TApplication.Create + 0001:0005F0B4 TApplication.CreateForm + 0001:0005DE60 TApplication.CreateHandle + 0001:0005DD44 TApplication.Destroy + 0001:000603FC TApplication.DispatchAction + 0001:0005F76C TApplication.DoActionIdle + 0001:0005F7D0 TApplication.DoMouseIdle + 0001:0005E0D4 TApplication.DoNormalizeTopMosts + 0001:0006048C TApplication.ExecuteAction + 0001:000603C0 TApplication.GetCurrentHelpFile + 0001:0005F70C TApplication.GetExeName + 0001:0005EA54 TApplication.GetIconHandle + 0001:0005EC5C TApplication.GetTitle + 0001:0005F234 TApplication.HandleException + 0001:0005EFA0 TApplication.HandleMessage + 0001:0005F704 TApplication.HelpCommand + 0001:0005F69C TApplication.HelpContext + 0001:0005F634 TApplication.HelpKeyword + 0001:0005FD64 TApplication.HideHint + 0001:0005FC1C TApplication.HintMouseMessage + 0001:0005FD2C TApplication.HintTimerExpired + 0001:0005EFC4 TApplication.HookMainWindow + 0001:00060538 TApplication.HookSynchronizeWakeup + 0001:0005F9AC TApplication.IconChanged + 0001:0005F854 TApplication.Idle + 0001:0005F09C TApplication.Initialize + 0001:0005F504 TApplication.InvokeHelp + 0001:0005ED38 TApplication.IsDlgMsg + 0001:0005EE50 TApplication.IsHintMsg + 0001:0005ED98 TApplication.IsKeyMsg + 0001:0005ED5C TApplication.IsMDIMsg + 0001:0005EE84 TApplication.IsShortCut + 0001:0005F2C4 TApplication.MessageBox + 0001:0005EA70 TApplication.Minimize + 0001:0005E18C TApplication.NormalizeAllTopMosts + 0001:0005E184 TApplication.NormalizeTopMosts + 0001:0005F970 TApplication.NotifyForms + 0001:0005EEF0 TApplication.ProcessMessage + 0001:0005EF88 TApplication.ProcessMessages + 0001:0005EB20 TApplication.Restore + 0001:0005E194 TApplication.RestoreTopMosts + 0001:0005F134 TApplication.Run + 0001:0005FA10 TApplication.SetHint + 0001:0005F71C TApplication.SetShowHint + 0001:0005E288 TApplication.SettingChange + 0001:0005ECA8 TApplication.SetTitle + 0001:0005F42C TApplication.ShowException + 0001:0005FBB0 TApplication.StartHintTimer + 0001:0005FBF4 TApplication.StopHintTimer + 0001:0005F220 TApplication.Terminate + 0001:0005F020 TApplication.UnhookMainWindow + 0001:00060548 TApplication.UnhookSynchronizeWakeup + 0001:000604B4 TApplication.UpdateAction + 0001:0005FB00 TApplication.UpdateVisible + 0001:0005E218 TApplication.UseRightToLeftAlignment + 0001:0005E200 TApplication.UseRightToLeftReading + 0001:0005FB88 TApplication.ValidateHelpSystem + 0001:00060528 TApplication.WakeMainThread + 0001:0005E37C TApplication.WndProc + 0002:00000D98 TaskActiveWindow + 0002:00000DA0 TaskFirstTopMost + 0002:00000D9C TaskFirstWindow + 0002:00000DA4 TaskWindowList + 0001:0003CB6C TBaseDragControlObject.Assign + 0001:0003CB48 TBaseDragControlObject.Create + 0001:0003CB98 TBaseDragControlObject.EndDrag + 0001:0003CBC4 TBaseDragControlObject.Finished + 0001:00023EDC TBasicAction.Change + 0001:00023D78 TBasicAction.Create + 0001:00023DBC TBasicAction.Destroy + 0001:00023E48 TBasicAction.Execute + 0001:00023E18 TBasicAction.ExecuteTarget + 0001:00023E14 TBasicAction.HandlesTarget + 0001:00023E1C TBasicAction.Notification + 0001:00023EF0 TBasicAction.RegisterChanges + 0001:00023E80 TBasicAction.SetOnExecute + 0001:00023EFC TBasicAction.UnRegisterChanges + 0001:00023E64 TBasicAction.Update + 0001:00023E44 TBasicAction.UpdateTarget + 0001:00023CA8 TBasicActionLink.AssignClient + 0001:00023CE0 TBasicActionLink.Change + 0001:00023C64 TBasicActionLink.Create + 0001:00023CAC TBasicActionLink.Destroy + 0001:00023CF8 TBasicActionLink.Execute + 0001:00023D60 TBasicActionLink.IsOnExecuteLinked + 0001:00023D34 TBasicActionLink.SetAction + 0001:00023D64 TBasicActionLink.SetOnExecute + 0001:00023D6C TBasicActionLink.Update + 0001:00029BF4 TBitmap.Assign + 0001:00029DC8 TBitmap.Changed + 0001:00029DA4 TBitmap.Changing + 0001:00029CE4 TBitmap.CopyImage + 0001:00029B50 TBitmap.Create + 0001:00029BB8 TBitmap.Destroy + 0001:0002A254 TBitmap.DIBNeeded + 0001:00029DD4 TBitmap.Dormant + 0001:00029E48 TBitmap.Draw + 0001:0002A2C8 TBitmap.FreeContext + 0001:0002A098 TBitmap.FreeImage + 0001:0002A118 TBitmap.GetCanvas + 0001:0002A0FC TBitmap.GetEmpty + 0001:0002A160 TBitmap.GetHandle + 0001:0002A184 TBitmap.GetHandleType + 0001:0002A1B0 TBitmap.GetHeight + 0001:0002A1C0 TBitmap.GetMaskHandle + 0001:0002A1D4 TBitmap.GetMonochrome + 0001:0002A1F0 TBitmap.GetPalette + 0001:0002A204 TBitmap.GetTransparentColor + 0001:0002A24C TBitmap.GetWidth + 0001:0002A2D8 TBitmap.HandleNeeded + 0001:0002A490 TBitmap.LoadFromClipboardFormat + 0001:0002A514 TBitmap.LoadFromStream + 0001:0002A378 TBitmap.MaskHandleNeeded + 0001:0002A538 TBitmap.NewImage + 0001:0002A3D8 TBitmap.PaletteNeeded + 0001:0002A638 TBitmap.ReadData + 0001:0002A660 TBitmap.ReadDIB + 0001:0002ABC8 TBitmap.ReadStream + 0001:0002B2F8 TBitmap.SaveToClipboardFormat + 0001:0002B2F0 TBitmap.SaveToStream + 0001:0002AC38 TBitmap.SetHandle + 0001:0002ACFC TBitmap.SetHandleType + 0001:0002AE34 TBitmap.SetHeight + 0001:0002AE88 TBitmap.SetMonochrome + 0001:0002AF08 TBitmap.SetPalette + 0001:0002AFDC TBitmap.SetWidth + 0001:0002B030 TBitmap.WriteData + 0001:0002B038 TBitmap.WriteStream + 0001:00028EB4 TBitmapCanvas.Create + 0001:00028FBC TBitmapCanvas.CreateHandle + 0001:00028EF0 TBitmapCanvas.Destroy + 0001:00028F1C TBitmapCanvas.FreeContext + 0001:000290CC TBitmapImage.Destroy + 0001:00029128 TBitmapImage.FreeHandle + 0001:0001B4CC TBits.Destroy + 0001:0001B4FC TBits.Error + 0001:0001B5F0 TBits.OpenBit + 0001:0001B5C4 TBits.SetBit + 0001:0001B520 TBits.SetSize + 0001:00026B0C TBrush.Assign + 0001:00026AA4 TBrush.Create + 0001:00026AE4 TBrush.Destroy + 0001:00026C44 TBrush.GetColor + 0001:00026BB4 TBrush.GetData + 0001:00026C80 TBrush.GetHandle + 0001:00026D60 TBrush.GetStyle + 0001:00026C20 TBrush.SetBitmap + 0001:00026C4C TBrush.SetColor + 0001:00026BD0 TBrush.SetData + 0001:00026D68 TBrush.SetStyle + 0001:000369D0 TButton.Click + 0001:00036B58 TButton.CMDialogChar + 0001:00036AE8 TButton.CMDialogKey + 0001:00036BDC TButton.CMFocusChanged + 0001:00036AD4 TButton.CNCommand + 0001:0003696C TButton.Create + 0001:00036A80 TButton.CreateParams + 0001:00036ABC TButton.CreateWnd + 0001:000369F8 TButton.SetButtonStyle + 0001:00036A4C TButton.SetDefault + 0001:000369F4 TButton.UseRightToLeftAlignment + 0001:00036C30 TButton.WMEraseBkgnd + 0001:00036768 TButtonActionLink.AssignClient + 0001:0003678C TButtonActionLink.IsCheckedLinked + 0001:000367C4 TButtonActionLink.SetChecked + 0001:0003687C TButtonControl.ActionChange + 0001:00036828 TButtonControl.Create + 0001:000368C4 TButtonControl.GetActionLinkClass + 0001:000368CC TButtonControl.GetChecked + 0001:000368D0 TButtonControl.IsCheckedStored + 0001:000368F0 TButtonControl.SetChecked + 0001:000368F4 TButtonControl.WndProc + 0001:000276DC TCanvas.BrushChanged + 0001:000275B0 TCanvas.Changed + 0001:0002759C TCanvas.Changing + 0001:00026EBC TCanvas.CopyRect + 0001:00026D9C TCanvas.Create + 0001:00027620 TCanvas.CreateBrush + 0001:000275C4 TCanvas.CreateFont + 0001:000274D0 TCanvas.CreateHandle + 0001:000275F0 TCanvas.CreatePen + 0001:00027474 TCanvas.DeselectHandles + 0001:00026E60 TCanvas.Destroy + 0001:00026F44 TCanvas.Draw + 0001:00026FF0 TCanvas.FillRect + 0001:0002769C TCanvas.FontChanged + 0001:0002702C TCanvas.FrameRect + 0001:000271B8 TCanvas.GetCanvasOrientation + 0001:00027454 TCanvas.GetHandle + 0001:0002739C TCanvas.GetPenPos + 0001:000273E0 TCanvas.GetPixel + 0001:00027068 TCanvas.LineTo + 0001:000270A0 TCanvas.Lock + 0001:000270C8 TCanvas.MoveTo + 0001:000276BC TCanvas.PenChanged + 0001:000270F4 TCanvas.Polyline + 0001:0002712C TCanvas.Rectangle + 0001:00027174 TCanvas.Refresh + 0001:00027528 TCanvas.RequiredState + 0001:00027390 TCanvas.SetBrush + 0001:00027374 TCanvas.SetFont + 0001:000274D4 TCanvas.SetHandle + 0001:00027384 TCanvas.SetPen + 0001:000273C0 TCanvas.SetPenPos + 0001:0002740C TCanvas.SetPixel + 0001:0002717C TCanvas.StretchDraw + 0001:00027270 TCanvas.TextExtent + 0001:000272D0 TCanvas.TextHeight + 0001:000271E4 TCanvas.TextOut + 0001:000272B4 TCanvas.TextWidth + 0001:000272F0 TCanvas.TryLock + 0001:0002734C TCanvas.Unlock + 0001:0004D4CC TChangeLink.Change + 0001:0004D498 TChangeLink.Destroy + 0001:0001A338 TClassFinder.Create + 0001:0001A464 TClassFinder.Destroy + 0001:0001A494 TClassFinder.GetClass + 0001:00065214 TClientSocket.Create + 0001:00065274 TClientSocket.Destroy + 0001:000652A4 TClientSocket.DoActivate + 0001:000652F4 TClientSocket.GetClientType + 0001:00065300 TClientSocket.SetClientType + 0001:00064124 TClientWinSocket.Connect + 0001:00064138 TClientWinSocket.SetClientType + 0001:0001BC68 TCollection.Add + 0001:0001C0F4 TCollection.Added + 0001:0001BC88 TCollection.Assign + 0001:0001BD20 TCollection.BeginUpdate + 0001:0001BD24 TCollection.Changed + 0001:0001BD34 TCollection.Clear + 0001:0001BBD0 TCollection.Create + 0001:0001C0B8 TCollection.Delete + 0001:0001C0F8 TCollection.Deleting + 0001:0001BC1C TCollection.Destroy + 0001:0001BD9C TCollection.EndUpdate + 0001:0001BDAC TCollection.GetAttr + 0001:0001BDA8 TCollection.GetAttrCount + 0001:0001BDD8 TCollection.GetCount + 0001:0001BDE0 TCollection.GetItem + 0001:0001BDB8 TCollection.GetItemAttr + 0001:0001BDF4 TCollection.GetNamePath + 0001:0001BEBC TCollection.GetPropName + 0001:0001BFD8 TCollection.Insert + 0001:0001BFF4 TCollection.InsertItem + 0001:0001C0FC TCollection.Notify + 0001:0001C0E8 TCollection.Owner + 0001:0001C05C TCollection.RemoveItem + 0001:0001C0B0 TCollection.SetItemName + 0001:0001C0B4 TCollection.Update + 0001:0001BA54 TCollectionItem.Changed + 0001:0001B9EC TCollectionItem.Create + 0001:0001BA24 TCollectionItem.Destroy + 0001:0001BA90 TCollectionItem.GetDisplayName + 0001:0001BA78 TCollectionItem.GetIndex + 0001:0001BAB8 TCollectionItem.GetNamePath + 0001:0001BB6C TCollectionItem.GetOwner + 0001:0001BB70 TCollectionItem.SetCollection + 0001:0001BB98 TCollectionItem.SetDisplayName + 0001:0001BBA0 TCollectionItem.SetIndex + 0001:00074CDC TComboBoxExActionLink.AddItem + 0001:00074D4C TComboBoxExActionLink.AddItem + 0001:00074804 TComboBoxExStrings.Add + 0001:00074828 TComboBoxExStrings.AddObject + 0001:00074858 TComboBoxExStrings.Clear + 0001:000748C0 TComboBoxExStrings.Create + 0001:0007494C TComboBoxExStrings.Delete + 0001:0007491C TComboBoxExStrings.Destroy + 0001:00074958 TComboBoxExStrings.Exchange + 0001:00074AA4 TComboBoxExStrings.Get + 0001:00074AC8 TComboBoxExStrings.GetCapacity + 0001:00074AD4 TComboBoxExStrings.GetCount + 0001:00074BF0 TComboBoxExStrings.GetItemClass + 0001:00074BE8 TComboBoxExStrings.GetItemsClass + 0001:00074AE0 TComboBoxExStrings.GetObject + 0001:00074AF8 TComboBoxExStrings.IndexOf + 0001:00074B44 TComboBoxExStrings.IndexOfName + 0001:00074B4C TComboBoxExStrings.Insert + 0001:00074B60 TComboBoxExStrings.Move + 0001:00074B80 TComboBoxExStrings.Put + 0001:00074B94 TComboBoxExStrings.PutObject + 0001:00074BA8 TComboBoxExStrings.SetUpdateState + 0001:00034A30 TComboBoxStrings.Add + 0001:00034AB4 TComboBoxStrings.Insert + 0001:00073BEC TComboExItem.Assign + 0001:00073C38 TComboExItem.SetCaption + 0001:00073C6C TComboExItem.SetData + 0001:00073CA0 TComboExItem.SetDisplayName + 0001:00073CC0 TComboExItem.SetImageIndex + 0001:00073CF0 TComboExItem.SetIndex + 0001:00073D0C TComboExItem.SetOverlayImageIndex + 0001:00073D28 TComboExItem.SetSelectedImageIndex + 0001:00073D44 TComboExItems.Add + 0001:00073D50 TComboExItems.AddItem + 0001:00073DB8 TComboExItems.GetComboItem + 0001:00073DCC TComboExItems.Insert + 0001:00073DE0 TComboExItems.Notify + 0001:00073E50 TComboExItems.SetItem + 0001:00038A8C TCommonDialog.Create + 0001:00038B30 TCommonDialog.DefaultHandler + 0001:00038AD4 TCommonDialog.Destroy + 0001:00038CD4 TCommonDialog.DoClose + 0001:00038CE8 TCommonDialog.DoShow + 0001:00038B68 TCommonDialog.MainWndProc + 0001:00038B08 TCommonDialog.MessageHook + 0001:00038C00 TCommonDialog.TaskModalDialog + 0001:00038BBC TCommonDialog.WMDestroy + 0001:00038BD4 TCommonDialog.WMInitDialog + 0001:00038BEC TCommonDialog.WMNCDestroy + 0001:00038BB4 TCommonDialog.WndProc + 0001:00023514 TComponent.BeforeDestruction + 0001:00023A34 TComponent.ChangeName + 0001:00023450 TComponent.Create + 0001:000237C8 TComponent.DefineProperties + 0001:0002349C TComponent.Destroy + 0001:00023698 TComponent.DestroyComponents + 0001:000236F0 TComponent.Destroying + 0001:00023B70 TComponent.ExecuteAction + 0001:00023958 TComponent.FindComponent + 0001:00023520 TComponent.FreeNotification + 0001:0002385C TComponent.GetChildOwner + 0001:00023860 TComponent.GetChildParent + 0001:00023854 TComponent.GetChildren + 0001:00023A48 TComponent.GetComponent + 0001:00023A74 TComponent.GetComponentCount + 0001:00023864 TComponent.GetNamePath + 0001:00023878 TComponent.GetOwner + 0001:00023880 TComponent.GetParentComponent + 0001:00023850 TComponent.HasParent + 0001:000235B4 TComponent.Insert + 0001:00023608 TComponent.InsertComponent + 0001:00023C60 TComponent.IntfGetComponent + 0001:000238A0 TComponent.Loaded + 0001:0002376C TComponent.Notification + 0001:000238AC TComponent.PaletteCreated + 0001:00023BE0 TComponent.QueryInterface + 0001:00023574 TComponent.ReadLeft + 0001:000238B0 TComponent.ReadState + 0001:00023588 TComponent.ReadTop + 0001:000235E0 TComponent.Remove + 0001:00023660 TComponent.RemoveComponent + 0001:00023750 TComponent.RemoveFreeNotification + 0001:0002372C TComponent.RemoveNotification + 0001:00023BC0 TComponent.SafeCallException + 0001:0002387C TComponent.SetChildOrder + 0001:00023A84 TComponent.SetComponentIndex + 0001:00023AD8 TComponent.SetDesigning + 0001:000239A8 TComponent.SetName + 0001:00023884 TComponent.SetParentComponent + 0001:00023B28 TComponent.SetReference + 0001:00023B98 TComponent.UpdateAction + 0001:00023894 TComponent.Updated + 0001:00023BD8 TComponent.UpdateRegistry + 0001:00023888 TComponent.Updating + 0001:00023940 TComponent.ValidateContainer + 0001:00023954 TComponent.ValidateInsert + 0001:000238C0 TComponent.ValidateRename + 0001:0002359C TComponent.WriteLeft + 0001:000238B8 TComponent.WriteState + 0001:000235A8 TComponent.WriteTop + 0001:00023C20 TComponent._AddRef + 0001:00023C40 TComponent._Release + 0001:0004AF64 TContainedAction.Destroy + 0001:0004B0D0 TContainedAction.Execute + 0001:0004AF98 TContainedAction.GetIndex + 0001:0004AFB4 TContainedAction.GetParentComponent + 0001:0004AFC4 TContainedAction.HasParent + 0001:0004AFB0 TContainedAction.IsCategoryStored + 0001:0004AFD4 TContainedAction.ReadState + 0001:0004B07C TContainedAction.SetActionList + 0001:0004B050 TContainedAction.SetCategory + 0001:0004B008 TContainedAction.SetIndex + 0001:0004B0A4 TContainedAction.SetParentComponent + 0001:0004B128 TContainedAction.Update + 0001:00041440 TControl.ActionChange + 0001:0004182C TControl.AdjustSize + 0001:00041660 TControl.AssignTo + 0001:0003FBFC TControl.BeginAutoDrag + 0001:0003FC14 TControl.BeginDrag + 0001:0003F794 TControl.BringToFront + 0001:000405EC TControl.CalcCursorPos + 0001:00040754 TControl.CalcDockSizes + 0001:000404EC TControl.CanAutoSize + 0001:000404F0 TControl.CanResize + 0001:0003F140 TControl.Changed + 0001:0003F150 TControl.ChangeScale + 0001:00040CB0 TControl.CheckNewSize + 0001:00040AA8 TControl.Click + 0001:0003F04C TControl.ClientToScreen + 0001:000411F4 TControl.CMBiDiModeChanged + 0001:0004113C TControl.CMColorChanged + 0001:000412C8 TControl.CMDesignHitTest + 0001:0004112C TControl.CMEnabledChanged + 0001:000413E0 TControl.CMFloat + 0001:00041134 TControl.CMFontChanged + 0001:000418B8 TControl.CMHintShow + 0001:00041290 TControl.CMHitTest + 0001:00041298 TControl.CMMouseEnter + 0001:000412B0 TControl.CMMouseLeave + 0001:00041198 TControl.CMMouseWheel + 0001:00041174 TControl.CMParentBiDiModeChanged + 0001:00041144 TControl.CMParentColorChanged + 0001:0004123C TControl.CMParentFontChanged + 0001:00041214 TControl.CMParentShowHintChanged + 0001:0004126C TControl.CMSysFontChanged + 0001:00041104 TControl.CMVisibleChanged + 0001:000405BC TControl.ConstrainedResize + 0001:0003E634 TControl.Create + 0001:000412D0 TControl.CreateFloatingDockSite + 0001:00040B14 TControl.DblClick + 0001:00040028 TControl.DefaultDockImage + 0001:00040980 TControl.DefaultHandler + 0001:00040A58 TControl.DefineProperties + 0001:00040618 TControl.DesignWndProc + 0001:0003E70C TControl.Destroy + 0001:0004153C TControl.DoActionChange + 0001:00040520 TControl.DoCanAutoSize + 0001:0004058C TControl.DoCanResize + 0001:0003ED38 TControl.Dock + 0001:0003FE6C TControl.DockTrackNoTarget + 0001:0004064C TControl.DoConstrainedResize + 0001:000404E0 TControl.DoConstraintsChange + 0001:00041A0C TControl.DoContextPopup + 0001:0003EE44 TControl.DoDock + 0001:0004017C TControl.DoDragMsg + 0001:0003FE80 TControl.DoEndDock + 0001:0003FD70 TControl.DoEndDrag + 0001:00040B6C TControl.DoMouseDown + 0001:00040ECC TControl.DoMouseUp + 0001:0003FECC TControl.DoMouseWheel + 0001:0003FF90 TControl.DoMouseWheelDown + 0001:0003FFDC TControl.DoMouseWheelUp + 0001:0003FEAC TControl.DoStartDock + 0001:0003FD50 TControl.DoStartDrag + 0001:0003FCD8 TControl.DragCanceled + 0001:0003FD24 TControl.DragDrop + 0001:0003FCDC TControl.Dragging + 0001:0003FCE8 TControl.DragOver + 0001:00040154 TControl.DrawDragDockImage + 0001:0004184C TControl.DrawTextBiDiModeFlags + 0001:0004188C TControl.DrawTextBiDiModeFlagsReadingOnly + 0001:00040168 TControl.EraseDragDockImage + 0001:0003F5E4 TControl.FontChanged + 0001:0003E878 TControl.GetAction + 0001:00041560 TControl.GetActionLinkClass + 0001:0003EED4 TControl.GetBoundsRect + 0001:0003EF7C TControl.GetClientHeight + 0001:0003EFBC TControl.GetClientOrigin + 0001:0003EF20 TControl.GetClientRect + 0001:0003EF38 TControl.GetClientWidth + 0001:0003FBAC TControl.GetControlsAlignment + 0001:0003F848 TControl.GetDeviceContext + 0001:00041748 TControl.GetDockEdge + 0001:0003E7C0 TControl.GetDragImages + 0001:0003E7C4 TControl.GetEnabled + 0001:000417F8 TControl.GetFloating + 0001:00041824 TControl.GetFloatingDockSiteClass + 0001:0003F75C TControl.GetMouseCapture + 0001:0003E7C8 TControl.GetPalette + 0001:0003E7D4 TControl.GetParentComponent + 0001:00040CAC TControl.GetPopupMenu + 0001:0003F534 TControl.GetText + 0001:0003F4B8 TControl.GetTextBuf + 0001:0003F4A8 TControl.GetTextLen + 0001:0003F4C4 TControl.GetUndockHeight + 0001:0003F4D8 TControl.GetUndockWidth + 0001:0003E7CC TControl.HasParent + 0001:0003FA5C TControl.Hide + 0001:000418A8 TControl.InitiateAction + 0001:0003FA08 TControl.Invalidate + 0001:0003F97C TControl.InvalidateControl + 0001:0003E924 TControl.IsAnchorsStored + 0001:0003F658 TControl.IsBiDiModeStored + 0001:00041568 TControl.IsCaptionStored + 0001:0003F6F0 TControl.IsColorStored + 0001:00041588 TControl.IsEnabledStored + 0001:0003F638 TControl.IsFontStored + 0001:000415C8 TControl.IsHelpContextStored + 0001:000415A8 TControl.IsHintStored + 0001:00041608 TControl.IsOnClickStored + 0001:0003F64C TControl.IsShowHintStored + 0001:000415E8 TControl.IsVisibleStored + 0001:00041628 TControl.Loaded + 0001:0004026C TControl.ManualDock + 0001:0004044C TControl.ManualFloat + 0001:00040B34 TControl.MouseDown + 0001:00040DEC TControl.MouseMove + 0001:00040E94 TControl.MouseUp + 0001:0003FA18 TControl.MouseWheelHandler + 0001:0003EA04 TControl.Notification + 0001:0003E800 TControl.PaletteChanged + 0001:00040720 TControl.Perform + 0001:0003FD9C TControl.PositionDockRect + 0001:00040A08 TControl.ReadIsControl + 0001:0003E970 TControl.ReadState + 0001:0003FAA8 TControl.Refresh + 0001:0003FAB4 TControl.Repaint + 0001:0003E940 TControl.RequestAlign + 0001:0003E950 TControl.Resize + 0001:0003F078 TControl.ScreenToClient + 0001:0003F0A4 TControl.SendCancelMode + 0001:0003F0D4 TControl.SendDockNotification + 0001:0003E8A8 TControl.SetAction + 0001:0003EA48 TControl.SetAlign + 0001:0003E888 TControl.SetAnchors + 0001:0003F304 TControl.SetAutoSize + 0001:0003F5C8 TControl.SetBiDiMode + 0001:0003EAF0 TControl.SetBounds + 0001:0003EEF4 TControl.SetBoundsRect + 0001:0003EF94 TControl.SetClientHeight + 0001:0003F3C0 TControl.SetClientSize + 0001:0003EF50 TControl.SetClientWidth + 0001:0003F6D4 TControl.SetColor + 0001:00041A40 TControl.SetConstraints + 0001:0003F740 TControl.SetCursor + 0001:0003E93C TControl.SetDragMode + 0001:0003F490 TControl.SetEnabled + 0001:0003F628 TControl.SetFont + 0001:0003ED14 TControl.SetHeight + 0001:0003EE9C TControl.SetHelpContext + 0001:0003EEB0 TControl.SetHelpKeyword + 0001:0003ECA4 TControl.SetLeft + 0001:0003F76C TControl.SetMouseCapture + 0001:0003F31C TControl.SetName + 0001:0003F408 TControl.SetParent + 0001:0003F71C TControl.SetParentBiDiMode + 0001:0003F6F8 TControl.SetParentColor + 0001:0003E7D8 TControl.SetParentComponent + 0001:0003F660 TControl.SetParentFont + 0001:0003F6A8 TControl.SetParentShowHint + 0001:0003F4EC TControl.SetPopupMenu + 0001:0003F684 TControl.SetShowHint + 0001:0003F564 TControl.SetText + 0001:0003F510 TControl.SetTextBuf + 0001:0003ECC8 TControl.SetTop + 0001:0003F454 TControl.SetVisible + 0001:0003ECF0 TControl.SetWidth + 0001:0003F824 TControl.SetZOrder + 0001:0003F7A4 TControl.SetZOrderPosition + 0001:0003FA64 TControl.Show + 0001:0003FA94 TControl.Update + 0001:0003EB88 TControl.UpdateAnchorRules + 0001:000407C4 TControl.UpdateBoundsRect + 0001:0003FBC8 TControl.UseRightToLeftAlignment + 0001:0003FBB0 TControl.UseRightToLeftReading + 0001:0003FBE0 TControl.UseRightToLeftScrollBar + 0001:000407E8 TControl.VisibleChanging + 0001:00041014 TControl.WMCancelMode + 0001:000418E4 TControl.WMContextMenu + 0001:00040C58 TControl.WMLButtonDblClk + 0001:00040BF0 TControl.WMLButtonDown + 0001:00040F04 TControl.WMLButtonUp + 0001:00040DC4 TControl.WMMButtonDblClk + 0001:00040D9C TControl.WMMButtonDown + 0001:00040F9C TControl.WMMButtonUp + 0001:00040E1C TControl.WMMouseMove + 0001:00040FBC TControl.WMMouseWheel + 0001:00040C3C TControl.WMNCLButtonDown + 0001:00040D74 TControl.WMRButtonDblClk + 0001:00040D4C TControl.WMRButtonDown + 0001:00040F7C TControl.WMRButtonUp + 0001:00041054 TControl.WMWindowPosChanged + 0001:000407EC TControl.WndProc + 0001:00040A1C TControl.WriteIsControl + 0001:0003E278 TControlActionLink.AssignClient + 0001:0003E294 TControlActionLink.DoShowHint + 0001:0003E384 TControlActionLink.IsCaptionLinked + 0001:0003E3F8 TControlActionLink.IsEnabledLinked + 0001:0003E570 TControlActionLink.IsHelpLinked + 0001:0003E42C TControlActionLink.IsHintLinked + 0001:0003E498 TControlActionLink.IsOnExecuteLinked + 0001:0003E464 TControlActionLink.IsVisibleLinked + 0001:0003E4C0 TControlActionLink.SetCaption + 0001:0003E4E0 TControlActionLink.SetEnabled + 0001:0003E5F4 TControlActionLink.SetHelpContext + 0001:0003E5D4 TControlActionLink.SetHelpKeyword + 0001:0003E614 TControlActionLink.SetHelpType + 0001:0003E500 TControlActionLink.SetHint + 0001:0003E544 TControlActionLink.SetOnExecute + 0001:0003E524 TControlActionLink.SetVisible + 0001:0003E034 TControlCanvas.CreateHandle + 0001:0003E008 TControlCanvas.Destroy + 0001:0003E0DC TControlCanvas.FreeHandle + 0001:0003E110 TControlCanvas.SetControl + 0001:0003E128 TControlCanvas.UpdateTextFlags + 0001:000565C0 TControlScrollBar.Assign + 0001:0005671C TControlScrollBar.CalcAutoRange + 0001:00056610 TControlScrollBar.ChangeBiDiPosition + 0001:000568B0 TControlScrollBar.ControlSize + 0001:00056530 TControlScrollBar.Create + 0001:00056E50 TControlScrollBar.DoSetRange + 0001:000565B8 TControlScrollBar.IsIncrementStored + 0001:00056E7C TControlScrollBar.IsRangeStored + 0001:000567C8 TControlScrollBar.IsScrollBarVisible + 0001:00056930 TControlScrollBar.NeedsScrollBarVisible + 0001:000569A8 TControlScrollBar.ScrollMessage + 0001:00056CA0 TControlScrollBar.SetButtonSize + 0001:00056CE4 TControlScrollBar.SetColor + 0001:00056D00 TControlScrollBar.SetParentColor + 0001:00056D18 TControlScrollBar.SetPosition + 0001:00056E68 TControlScrollBar.SetRange + 0001:00056DDC TControlScrollBar.SetSize + 0001:00056E20 TControlScrollBar.SetStyle + 0001:00056E38 TControlScrollBar.SetThumbSize + 0001:00056E88 TControlScrollBar.SetVisible + 0001:00056F9C TControlScrollBar.Update + 0001:0006C954 TConversion.ConvertReadStream + 0001:0006C968 TConversion.ConvertWriteStream + 0001:00062010 TCriticalSection.Acquire + 0001:00061FA0 TCriticalSection.Create + 0001:00061FE0 TCriticalSection.Destroy + 0001:00062028 TCriticalSection.Enter + 0001:00062030 TCriticalSection.Leave + 0001:0006201C TCriticalSection.Release + 0001:0004B664 TCustomAction.AssignTo + 0001:0004B5C0 TCustomAction.Create + 0001:0004B614 TCustomAction.Destroy + 0001:0004BB7C TCustomAction.DoHint + 0001:0004BBA4 TCustomAction.Execute + 0001:0004BBF4 TCustomAction.GetSecondaryShortCuts + 0001:0004BC74 TCustomAction.HandleShortCut + 0001:0004BC50 TCustomAction.IsSecondaryShortCutsStored + 0001:0004B710 TCustomAction.SetCaption + 0001:0004B770 TCustomAction.SetChecked + 0001:0004B878 TCustomAction.SetEnabled + 0001:0004B958 TCustomAction.SetHelpContext + 0001:0004B8F0 TCustomAction.SetHelpKeyword + 0001:0004B9B0 TCustomAction.SetHint + 0001:0004BA10 TCustomAction.SetImageIndex + 0001:0004BB30 TCustomAction.SetName + 0001:0004BC1C TCustomAction.SetSecondaryShortCuts + 0001:0004BA6C TCustomAction.SetShortCut + 0001:0004BAD0 TCustomAction.SetVisible + 0001:0004B358 TCustomActionList.AddAction + 0001:0004B394 TCustomActionList.Change + 0001:0004B180 TCustomActionList.Create + 0001:0004B1EC TCustomActionList.Destroy + 0001:0004B488 TCustomActionList.ExecuteAction + 0001:0004B2B4 TCustomActionList.GetAction + 0001:0004B2C8 TCustomActionList.GetActionCount + 0001:0004B23C TCustomActionList.GetChildren + 0001:0004B304 TCustomActionList.ImageListChange + 0001:0004B3FC TCustomActionList.IsShortCut + 0001:0004B310 TCustomActionList.Notification + 0001:0004B378 TCustomActionList.RemoveAction + 0001:0004B284 TCustomActionList.SetChildOrder + 0001:0004B2D0 TCustomActionList.SetImages + 0001:0004B4A8 TCustomActionList.UpdateAction + 0001:00036D1C TCustomCheckBox.Click + 0001:00036E54 TCustomCheckBox.CMCtl3DChanged + 0001:00036E5C TCustomCheckBox.CMDialogChar + 0001:00036EF8 TCustomCheckBox.CNCommand + 0001:00036C44 TCustomCheckBox.Create + 0001:00036DB8 TCustomCheckBox.CreateParams + 0001:00036E14 TCustomCheckBox.CreateWnd + 0001:00036D30 TCustomCheckBox.GetChecked + 0001:00036CB0 TCustomCheckBox.GetControlsAlignment + 0001:00036D3C TCustomCheckBox.SetAlignment + 0001:00036D50 TCustomCheckBox.SetChecked + 0001:00036D64 TCustomCheckBox.SetState + 0001:00036CDC TCustomCheckBox.Toggle + 0001:00036E40 TCustomCheckBox.WMSize + 0001:00035918 TCustomCombo.AddItem + 0001:00035760 TCustomCombo.AdjustDropDown + 0001:00035580 TCustomCombo.Change + 0001:00034C84 TCustomCombo.Clear + 0001:00035840 TCustomCombo.ClearSelection + 0001:000356DC TCustomCombo.CloseUp + 0001:00034E9C TCustomCombo.CMCancelMode + 0001:00034EB0 TCustomCombo.CMCtl3DChanged + 0001:00035414 TCustomCombo.CNCommand + 0001:00035028 TCustomCombo.ComboWndProc + 0001:0003584C TCustomCombo.CopySelection + 0001:00034B34 TCustomCombo.Create + 0001:00035728 TCustomCombo.CreateWnd + 0001:000358D8 TCustomCombo.DeleteSelected + 0001:00034C28 TCustomCombo.Destroy + 0001:00034CB0 TCustomCombo.DestroyWindowHandle + 0001:00035660 TCustomCombo.DropDown + 0001:00034EFC TCustomCombo.EditWndProc + 0001:000356A8 TCustomCombo.Focused + 0001:00035904 TCustomCombo.GetCount + 0001:00034CF4 TCustomCombo.GetDroppedDown + 0001:00034D60 TCustomCombo.GetItemIndex + 0001:00034FF4 TCustomCombo.ListWndProc + 0001:00035680 TCustomCombo.Loaded + 0001:000356FC TCustomCombo.Select + 0001:00034CD4 TCustomCombo.SelectAll + 0001:00035910 TCustomCombo.SetDropDownCount + 0001:00034D18 TCustomCombo.SetDroppedDown + 0001:00034E08 TCustomCombo.SetItemHeight + 0001:00034D8C TCustomCombo.SetItemIndex + 0001:0003581C TCustomCombo.SetItems + 0001:00034DC8 TCustomCombo.SetMaxLength + 0001:00034E18 TCustomCombo.WMCreate + 0001:00034E64 TCustomCombo.WMDeleteItem + 0001:00034E3C TCustomCombo.WMDrawItem + 0001:00034E78 TCustomCombo.WMGetDlgCode + 0001:00034E50 TCustomCombo.WMMeasureItem + 0001:00035304 TCustomCombo.WndProc + 0001:00034ED4 TCustomComboBox.CMParentColorChanged + 0001:00036354 TCustomComboBox.CNDrawItem + 0001:0003642C TCustomComboBox.CNMeasureItem + 0001:00035970 TCustomComboBox.Create + 0001:00035A9C TCustomComboBox.CreateParams + 0001:00035B00 TCustomComboBox.CreateWnd + 0001:000359E8 TCustomComboBox.Destroy + 0001:00035C40 TCustomComboBox.DestroyWnd + 0001:000355A4 TCustomComboBox.DrawItem + 0001:00036518 TCustomComboBox.GetItemCount + 0001:00035A78 TCustomComboBox.GetItemHt + 0001:00036524 TCustomComboBox.GetItemsClass + 0001:00035DD8 TCustomComboBox.KeyPress + 0001:00036334 TCustomComboBox.MeasureItem + 0001:000361A0 TCustomComboBox.SelectItem + 0001:00035014 TCustomComboBox.SetCharCase + 0001:00035A24 TCustomComboBox.SetSorted + 0001:00035A38 TCustomComboBox.SetStyle + 0001:00035C90 TCustomComboBox.WMEraseBkgnd + 0001:00036458 TCustomComboBox.WMLButtonDown + 0001:00036764 TCustomComboBox.WMNCCalcSize + 0001:0003652C TCustomComboBox.WMPaint + 0001:000364D0 TCustomComboBox.WndProc + 0001:000746C8 TCustomComboBoxEx.ActionChange + 0001:000742BC TCustomComboBoxEx.CMColorChanged + 0001:00074294 TCustomComboBoxEx.CMParentColorChanged + 0001:0007404C TCustomComboBoxEx.CNNotify + 0001:00074394 TCustomComboBoxEx.ComboExWndProc + 0001:00073F34 TCustomComboBoxEx.Create + 0001:0007409C TCustomComboBoxEx.CreateParams + 0001:000743B4 TCustomComboBoxEx.CreateWnd + 0001:00073FE4 TCustomComboBoxEx.Destroy + 0001:00074778 TCustomComboBoxEx.DestroyWnd + 0001:000747C8 TCustomComboBoxEx.Focused + 0001:00074628 TCustomComboBoxEx.GetActionLinkClass + 0001:00074768 TCustomComboBoxEx.GetDropDownCount + 0001:00074604 TCustomComboBoxEx.GetItemCount + 0001:00074770 TCustomComboBoxEx.GetItemHt + 0001:00074610 TCustomComboBoxEx.GetItemsClass + 0001:000741A8 TCustomComboBoxEx.ImageListChange + 0001:00074690 TCustomComboBoxEx.IsItemsExStored + 0001:0007421C TCustomComboBoxEx.Notification + 0001:0007472C TCustomComboBoxEx.SetDropDownCount + 0001:00074114 TCustomComboBoxEx.SetImages + 0001:00074618 TCustomComboBoxEx.SetItemsEx + 0001:0007424C TCustomComboBoxEx.SetStyle + 0001:00074630 TCustomComboBoxEx.SetStyleEx + 0001:0007431C TCustomComboBoxEx.WMLButtonDown + 0001:000741D4 TCustomComboBoxEx.WndProc + 0001:00034944 TCustomComboBoxStrings.Clear + 0001:000349B4 TCustomComboBoxStrings.Delete + 0001:00034900 TCustomComboBoxStrings.Get + 0001:00034848 TCustomComboBoxStrings.GetCount + 0001:00034864 TCustomComboBoxStrings.GetObject + 0001:000349D4 TCustomComboBoxStrings.IndexOf + 0001:000348DC TCustomComboBoxStrings.PutObject + 0001:000349FC TCustomComboBoxStrings.SetUpdateState + 0001:00047608 TCustomControl.Create + 0001:00047664 TCustomControl.Destroy + 0001:00047760 TCustomControl.Paint + 0001:000476B4 TCustomControl.PaintWindow + 0001:00047694 TCustomControl.WMPaint + 0001:0005C7CC TCustomDockForm.CMControlListChange + 0001:0005C824 TCustomDockForm.CMDockNotification + 0001:0005C8F8 TCustomDockForm.CMUnDockClient + 0001:0005C910 TCustomDockForm.CMVisibleChanged + 0001:0005C528 TCustomDockForm.Create + 0001:0005C590 TCustomDockForm.DoAddDockClient + 0001:0005C674 TCustomDockForm.DoRemoveDockClient + 0001:0005C6E0 TCustomDockForm.GetSiteInfo + 0001:0005C694 TCustomDockForm.Loaded + 0001:0005C70C TCustomDockForm.WMNCHitTest + 0001:0005C734 TCustomDockForm.WMNCLButtonDown + 0001:00033EA8 TCustomEdit.AdjustHeight + 0001:00033F50 TCustomEdit.Change + 0001:00033B10 TCustomEdit.Clear + 0001:00033FEC TCustomEdit.CMCtl3DChanged + 0001:00034068 TCustomEdit.CMEnter + 0001:00034020 TCustomEdit.CMFontChanged + 0001:000340A4 TCustomEdit.CMTextChanged + 0001:00034048 TCustomEdit.CNCommand + 0001:00033798 TCustomEdit.Create + 0001:00033C80 TCustomEdit.CreateParams + 0001:00033D3C TCustomEdit.CreateWindowHandle + 0001:00033DAC TCustomEdit.CreateWnd + 0001:00033F74 TCustomEdit.DefaultHandler + 0001:00033E50 TCustomEdit.DestroyWnd + 0001:00033840 TCustomEdit.DoSetMaxLength + 0001:00033904 TCustomEdit.GetModified + 0001:00033A7C TCustomEdit.GetSelLength + 0001:00033A38 TCustomEdit.GetSelStart + 0001:00033BE4 TCustomEdit.GetSelText + 0001:00033B48 TCustomEdit.GetSelTextBuf + 0001:00033B2C TCustomEdit.SelectAll + 0001:00033860 TCustomEdit.SetAutoSize + 0001:00033874 TCustomEdit.SetBorderStyle + 0001:00033898 TCustomEdit.SetCharCase + 0001:000338AC TCustomEdit.SetHideSelection + 0001:000338C0 TCustomEdit.SetMaxLength + 0001:0003393C TCustomEdit.SetModified + 0001:000338F0 TCustomEdit.SetOEMConvert + 0001:00033974 TCustomEdit.SetPasswordChar + 0001:000339FC TCustomEdit.SetReadOnly + 0001:00033AAC TCustomEdit.SetSelLength + 0001:00033A5C TCustomEdit.SetSelStart + 0001:00033E6C TCustomEdit.UpdateHeight + 0001:000340DC TCustomEdit.WMContextMenu + 0001:00033FAC TCustomEdit.WMSetFont + 0001:0005A6C0 TCustomForm.Activate + 0001:0005A4C4 TCustomForm.ActiveChanged + 0001:00057B64 TCustomForm.AfterConstruction + 0001:00058F40 TCustomForm.AlignControls + 0001:00057D0C TCustomForm.BeforeDestruction + 0001:00058428 TCustomForm.BeginAutoDrag + 0001:0005842C TCustomForm.ChangeScale + 0001:00058DF8 TCustomForm.ClientWndProc + 0001:0005BA70 TCustomForm.Close + 0001:0005BB78 TCustomForm.CloseModal + 0001:0005BB14 TCustomForm.CloseQuery + 0001:0005C12C TCustomForm.CMActionExecute + 0001:0005C22C TCustomForm.CMActionUpdate + 0001:0005B2FC TCustomForm.CMActivate + 0001:0005ADBC TCustomForm.CMAppSysCommand + 0001:00058F7C TCustomForm.CMBiDiModeChanged + 0001:00059780 TCustomForm.CMColorChanged + 0001:000597BC TCustomForm.CMCtl3DChanged + 0001:0005B320 TCustomForm.CMDeactivate + 0001:0005B344 TCustomForm.CMDialogKey + 0001:00059804 TCustomForm.CMFontChanged + 0001:0005B958 TCustomForm.CMIconChanged + 0001:0005BA44 TCustomForm.CMIsShortCut + 0001:00059824 TCustomForm.CMMenuChanged + 0001:00059014 TCustomForm.CMParentBiDiModeChanged + 0001:0005B9D8 TCustomForm.CMParentFontChanged + 0001:0005B978 TCustomForm.CMRelease + 0001:0005B3E0 TCustomForm.CMShowingChanged + 0001:0005B980 TCustomForm.CMTextChanged + 0001:0005B9D0 TCustomForm.CMUIActivate + 0001:000579D8 TCustomForm.Create + 0001:00057B9C TCustomForm.CreateNew + 0001:00059BD4 TCustomForm.CreateParams + 0001:00059F30 TCustomForm.CreateWindowHandle + 0001:00059DF0 TCustomForm.CreateWnd + 0001:0005A6F0 TCustomForm.Deactivate + 0001:0005A0AC TCustomForm.DefaultHandler + 0001:000582E4 TCustomForm.DefineProperties + 0001:0005A1C8 TCustomForm.DefocusControl + 0001:00057D74 TCustomForm.Destroy + 0001:0005A068 TCustomForm.DestroyWindowHandle + 0001:00059100 TCustomForm.Dock + 0001:00058574 TCustomForm.DoClose + 0001:00057E58 TCustomForm.DoCreate + 0001:00057ED4 TCustomForm.DoDestroy + 0001:00059144 TCustomForm.DoDock + 0001:00058594 TCustomForm.DoHide + 0001:000585B4 TCustomForm.DoShow + 0001:0005A210 TCustomForm.FocusControl + 0001:00059198 TCustomForm.GetActiveMDIChild + 0001:00059380 TCustomForm.GetCanvas + 0001:0005865C TCustomForm.GetChildren + 0001:000585D4 TCustomForm.GetClientRect + 0001:000586C8 TCustomForm.GetFloating + 0001:0005A740 TCustomForm.GetIconHandle + 0001:000591CC TCustomForm.GetMDIChildCount + 0001:00059218 TCustomForm.GetMDIChildren + 0001:00059298 TCustomForm.GetMonitor + 0001:000596E0 TCustomForm.GetPixelsPerInch + 0001:00059744 TCustomForm.GetScaled + 0001:00058404 TCustomForm.GetTextHeight + 0001:0005C3C4 TCustomForm.HandleCreateException + 0001:0005BC10 TCustomForm.Hide + 0001:000584AC TCustomForm.IconChanged + 0001:0005C4FC TCustomForm.InitAlphaBlending + 0001:00058540 TCustomForm.IsAutoScrollStored + 0001:00058508 TCustomForm.IsClientSizeStored + 0001:00059394 TCustomForm.IsForm + 0001:00058518 TCustomForm.IsFormSizeStored + 0001:0005939C TCustomForm.IsIconStored + 0001:0005C2D4 TCustomForm.IsShortCut + 0001:00057F34 TCustomForm.Loaded + 0001:0005A5CC TCustomForm.MergeMenu + 0001:0005C38C TCustomForm.MouseWheelHandler + 0001:000597A4 TCustomForm.NormalColor + 0001:00057F70 TCustomForm.Notification + 0001:0005A720 TCustomForm.Paint + 0001:0005A75C TCustomForm.PaintWindow + 0001:0005A818 TCustomForm.PaletteChanged + 0001:0005C350 TCustomForm.QueryInterface + 0001:00058394 TCustomForm.ReadIgnoreFontProperty + 0001:0005807C TCustomForm.ReadState + 0001:000583B4 TCustomForm.ReadTextHeight + 0001:00059444 TCustomForm.RefreshMDIMenu + 0001:0005BCAC TCustomForm.Release + 0001:0005C040 TCustomForm.RequestAlign + 0001:0005AD50 TCustomForm.Resizing + 0001:0005A57C TCustomForm.SendCancelMode + 0001:0005A518 TCustomForm.SetActive + 0001:0005A110 TCustomForm.SetActiveControl + 0001:0005C4AC TCustomForm.SetAlphaBlend + 0001:0005C4C0 TCustomForm.SetAlphaBlendValue + 0001:0005909C TCustomForm.SetBorderIcons + 0001:000590C8 TCustomForm.SetBorderStyle + 0001:000586F4 TCustomForm.SetChildOrder + 0001:000587E0 TCustomForm.SetClientHeight + 0001:000587B0 TCustomForm.SetClientWidth + 0001:0005BC30 TCustomForm.SetFocus + 0001:0005A234 TCustomForm.SetFocusedControl + 0001:000593C4 TCustomForm.SetFormStyle + 0001:00059388 TCustomForm.SetIcon + 0001:0005C3D4 TCustomForm.SetLayeredAttribs + 0001:0005950C TCustomForm.SetMenu + 0001:000594C0 TCustomForm.SetObjectMenuItem + 0001:000588BC TCustomForm.SetParent + 0001:00058788 TCustomForm.SetParentBiDiMode + 0001:000596F4 TCustomForm.SetPixelsPerInch + 0001:00059728 TCustomForm.SetPosition + 0001:00059750 TCustomForm.SetScaled + 0001:0005C4E8 TCustomForm.SetTransparentColor + 0001:0005C4D4 TCustomForm.SetTransparentColorValue + 0001:00058810 TCustomForm.SetVisible + 0001:0005A4C8 TCustomForm.SetWindowFocus + 0001:000594E4 TCustomForm.SetWindowMenu + 0001:00059840 TCustomForm.SetWindowState + 0001:00059880 TCustomForm.SetWindowToMonitor + 0001:0005BC18 TCustomForm.Show + 0001:0005BCC8 TCustomForm.ShowModal + 0001:0005BFD8 TCustomForm.UpdateActions + 0001:000588F4 TCustomForm.ValidateRename + 0001:00058854 TCustomForm.VisibleChanging + 0001:000588B8 TCustomForm.WantChildKey + 0001:0005AD30 TCustomForm.WMActivate + 0001:0005AD88 TCustomForm.WMClose + 0001:0005AC04 TCustomForm.WMCommand + 0001:0005ABA4 TCustomForm.WMDestroy + 0001:0005AFBC TCustomForm.WMEnterMenuLoop + 0001:0005A998 TCustomForm.WMEraseBkgnd + 0001:0005B1F0 TCustomForm.WMGetMinMaxInfo + 0001:0005B084 TCustomForm.WMHelp + 0001:0005A938 TCustomForm.WMIconEraseBkgnd + 0001:0005AC38 TCustomForm.WMInitMenuPopup + 0001:0005AF38 TCustomForm.WMMDIActivate + 0001:0005AC50 TCustomForm.WMMenuChar + 0001:0005AC88 TCustomForm.WMMenuSelect + 0001:0005AAE0 TCustomForm.WMNCCreate + 0001:0005AB14 TCustomForm.WMNCLButtonDown + 0001:0005AF90 TCustomForm.WMNextDlgCtl + 0001:0005A8B8 TCustomForm.WMPaint + 0001:0005A9D0 TCustomForm.WMQueryDragIcon + 0001:0005AD90 TCustomForm.WMQueryEndSession + 0001:0005C05C TCustomForm.WMSettingChange + 0001:0005AEA0 TCustomForm.WMShowWindow + 0001:0005AE14 TCustomForm.WMSysCommand + 0001:0005B264 TCustomForm.WMWindowPosChanging + 0001:00058934 TCustomForm.WndProc + 0001:000583E8 TCustomForm.WritePixelsPerInch + 0001:000583CC TCustomForm.WriteTextHeight + 0001:0003345C TCustomGroupBox.AdjustClientRect + 0001:00033768 TCustomGroupBox.CMCtl3DChanged + 0001:000336D4 TCustomGroupBox.CMDialogChar + 0001:00033754 TCustomGroupBox.CMTextChanged + 0001:00033400 TCustomGroupBox.Create + 0001:000334B8 TCustomGroupBox.CreateParams + 0001:000334C8 TCustomGroupBox.Paint + 0001:00033784 TCustomGroupBox.WMSize + 0001:0004C424 TCustomImageList.Add + 0001:0004CA4C TCustomImageList.AddImages + 0001:0004CA6C TCustomImageList.Assign + 0001:0004CB2C TCustomImageList.AssignTo + 0001:0004D474 TCustomImageList.BeginUpdate + 0001:0004CC7C TCustomImageList.Change + 0001:0004CBDC TCustomImageList.CheckImage + 0001:0004C604 TCustomImageList.Clear + 0001:0004C8B4 TCustomImageList.CopyImages + 0001:0004BF60 TCustomImageList.Create + 0001:0004C384 TCustomImageList.CreateImageList + 0001:0004BFAC TCustomImageList.CreateSize + 0001:0004CEB8 TCustomImageList.DefineProperties + 0001:0004C578 TCustomImageList.Delete + 0001:0004C000 TCustomImageList.Destroy + 0001:0004C670 TCustomImageList.DoDraw + 0001:0004C844 TCustomImageList.Draw + 0001:0004C868 TCustomImageList.Draw + 0001:0004D478 TCustomImageList.EndUpdate + 0001:0004CD6C TCustomImageList.Equal + 0001:0004C34C TCustomImageList.FreeHandle + 0001:0004C648 TCustomImageList.GetBkColor + 0001:0004C554 TCustomImageList.GetCount + 0001:0004C2E8 TCustomImageList.GetHandle + 0001:0004CC6C TCustomImageList.GetHotSpot + 0001:0004C500 TCustomImageList.GetIcon + 0001:0004C4F0 TCustomImageList.GetIcon + 0001:0004C2F8 TCustomImageList.GetImageHandle + 0001:0004C124 TCustomImageList.HandleAllocated + 0001:0004C12C TCustomImageList.HandleNeeded + 0001:0004C138 TCustomImageList.InitBitmap + 0001:0004C06C TCustomImageList.Initialize + 0001:0004CF10 TCustomImageList.ReadD2Stream + 0001:0004D1A4 TCustomImageList.ReadD3Stream + 0001:0004D36C TCustomImageList.ReadData + 0001:0004CD10 TCustomImageList.RegisterChanges + 0001:0004C610 TCustomImageList.SetBkColor + 0001:0004CC54 TCustomImageList.SetDrawingStyle + 0001:0004C2BC TCustomImageList.SetHandle + 0001:0004C278 TCustomImageList.SetHeight + 0001:0004C1FC TCustomImageList.SetNewDimensions + 0001:0004C234 TCustomImageList.SetWidth + 0001:0004CCCC TCustomImageList.UnRegisterChanges + 0001:0004D3F8 TCustomImageList.WriteData + 0001:00060D30 TCustomIniFile.Create + 0001:00061350 TCustomIniFile.ReadBinaryStream + 0001:00060E8C TCustomIniFile.ReadBool + 0001:00060EB8 TCustomIniFile.ReadDate + 0001:00060F70 TCustomIniFile.ReadDateTime + 0001:00061028 TCustomIniFile.ReadFloat + 0001:00060D6C TCustomIniFile.ReadInteger + 0001:000610E0 TCustomIniFile.ReadTime + 0001:000614C0 TCustomIniFile.WriteBinaryStream + 0001:00061334 TCustomIniFile.WriteBool + 0001:00061198 TCustomIniFile.WriteDate + 0001:000611F8 TCustomIniFile.WriteDateTime + 0001:00061258 TCustomIniFile.WriteFloat + 0001:00060E30 TCustomIniFile.WriteInteger + 0001:000612BC TCustomIniFile.WriteTime + 0001:00068BF8 TCustomListAction.Create + 0001:00068C50 TCustomListAction.ExecuteTarget + 0001:00068D78 TCustomListAction.GetCount + 0001:00068DA4 TCustomListAction.GetString + 0001:00068DB0 TCustomListAction.HandlesTarget + 0001:00068DB4 TCustomListAction.Loaded + 0001:00068DE8 TCustomListAction.SetActive + 0001:00068EE8 TCustomListAction.SetImages + 0001:00068F54 TCustomListAction.SetItemIndex + 0001:00068FB0 TCustomListAction.SetString + 0001:0004A928 TCustomListControl.MoveSelection + 0001:00073B88 TCustomListView.ActionChange + 0001:000722D4 TCustomListView.AddItem + 0001:000727F8 TCustomListView.AlphaSort + 0001:00072CA0 TCustomListView.Arrange + 0001:0007233C TCustomListView.CanChange + 0001:000723F4 TCustomListView.CanEdit + 0001:000732AC TCustomListView.CanvasChanged + 0001:00072384 TCustomListView.Change + 0001:000721F0 TCustomListView.ChangeScale + 0001:00073B28 TCustomListView.Clear + 0001:00073988 TCustomListView.ClearSelection + 0001:00070E40 TCustomListView.CMColorChanged + 0001:00070E64 TCustomListView.CMCtl3DChanged + 0001:0007263C TCustomListView.CMDrag + 0001:000710C4 TCustomListView.CMFontChanged + 0001:00073748 TCustomListView.CMHintShow + 0001:0007317C TCustomListView.CNDrawItem + 0001:00071530 TCustomListView.CNNotify + 0001:00072264 TCustomListView.ColClick + 0001:00072284 TCustomListView.ColRightClick + 0001:000710AC TCustomListView.ColumnsShowing + 0001:000739C4 TCustomListView.CopySelection + 0001:0006FF08 TCustomListView.Create + 0001:000712E4 TCustomListView.CreateListItem + 0001:00071320 TCustomListView.CreateListItems + 0001:000701F0 TCustomListView.CreateParams + 0001:000703D0 TCustomListView.CreateWnd + 0001:000733BC TCustomListView.CustomDraw + 0001:00073414 TCustomListView.CustomDrawItem + 0001:00073484 TCustomListView.CustomDrawSubItem + 0001:000723BC TCustomListView.Delete + 0001:00073A38 TCustomListView.DeleteSelected + 0001:000700F0 TCustomListView.Destroy + 0001:000705B8 TCustomListView.DestroyWnd + 0001:00072FB4 TCustomListView.DoAutoSize + 0001:00072770 TCustomListView.DoDragOver + 0001:00072610 TCustomListView.DoEndDrag + 0001:00073870 TCustomListView.DoInfoTip + 0001:0007253C TCustomListView.DoStartDrag + 0001:000734FC TCustomListView.DrawItem + 0001:000735B8 TCustomListView.DrawWorkAreas + 0001:00072420 TCustomListView.Edit + 0001:00070978 TCustomListView.EditWndProc + 0001:00073B80 TCustomListView.GetActionLinkClass + 0001:00072A54 TCustomListView.GetColumnFromIndex + 0001:000738D4 TCustomListView.GetColumnFromTag + 0001:00073AE0 TCustomListView.GetCount + 0001:000724A0 TCustomListView.GetDragImages + 0001:00072A78 TCustomListView.GetDropTarget + 0001:00072AE0 TCustomListView.GetImageIndex + 0001:0007137C TCustomListView.GetItem + 0001:00072C3C TCustomListView.GetItemAt + 0001:000711EC TCustomListView.GetItemIndex + 0001:00072BD4 TCustomListView.GetNearestItem + 0001:00072B00 TCustomListView.GetNextItem + 0001:000714AC TCustomListView.GetSelCount + 0001:00072A60 TCustomListView.GetSelected + 0001:00073574 TCustomListView.GetSubItemImage + 0001:00072878 TCustomListView.GetTopItem + 0001:00072860 TCustomListView.GetViewOrigin + 0001:00070880 TCustomListView.HeaderWndProc + 0001:0007065C TCustomListView.ImageListChange + 0001:000722B4 TCustomListView.InsertItem + 0001:000732B4 TCustomListView.IsCustomDrawn + 0001:00073890 TCustomListView.MouseUp + 0001:000706D0 TCustomListView.Notification + 0001:00071214 TCustomListView.OwnerDataFetch + 0001:0007123C TCustomListView.OwnerDataFind + 0001:00071288 TCustomListView.OwnerDataHint + 0001:000712B0 TCustomListView.OwnerDataStateChange + 0001:00070A98 TCustomListView.ResetExStyles + 0001:00070B94 TCustomListView.RestoreChecks + 0001:00070C20 TCustomListView.SaveChecks + 0001:00073AEC TCustomListView.SelectAll + 0001:00070E10 TCustomListView.SetAllocBy + 0001:00070D24 TCustomListView.SetBorderStyle + 0001:00070CA4 TCustomListView.SetCheckboxes + 0001:00070D38 TCustomListView.SetColumnClick + 0001:00070DA8 TCustomListView.SetColumnHeaders + 0001:00072A9C TCustomListView.SetDropTarget + 0001:00071104 TCustomListView.SetHideSelection + 0001:00070634 TCustomListView.SetImageList + 0001:00070D4C TCustomListView.SetItemIndex + 0001:000728B0 TCustomListView.SetLargeImages + 0001:00070D94 TCustomListView.SetMultiSelect + 0001:00072920 TCustomListView.SetSmallImages + 0001:00072828 TCustomListView.SetSortType + 0001:00072998 TCustomListView.SetStateImages + 0001:00070DDC TCustomListView.SetTextBkColor + 0001:00070DBC TCustomListView.SetTextColor + 0001:00071118 TCustomListView.SetViewStyle + 0001:00072D00 TCustomListView.UpdateColumn + 0001:00072CC0 TCustomListView.UpdateColumns + 0001:00070A78 TCustomListView.UpdateItems + 0001:000710B8 TCustomListView.ValidHeaderHandle + 0001:00073910 TCustomListView.WMContextMenu + 0001:00072E50 TCustomListView.WMLButtonDown + 0001:00070E88 TCustomListView.WMNotify + 0001:00073720 TCustomListView.WMPaint + 0001:0007119C TCustomListView.WMParentNotify + 0001:00073148 TCustomListView.WMWindowPosChanged + 0001:000724BC TCustomListView.WndProc + 0001:00034508 TCustomMemo.Create + 0001:000345BC TCustomMemo.CreateParams + 0001:00034620 TCustomMemo.CreateWindowHandle + 0001:0003458C TCustomMemo.Destroy + 0001:000346F4 TCustomMemo.GetCaretPos + 0001:0003478C TCustomMemo.GetControlsAlignment + 0001:00034824 TCustomMemo.KeyPress + 0001:00034794 TCustomMemo.Loaded + 0001:000347AC TCustomMemo.SetAlignment + 0001:00034750 TCustomMemo.SetCaretPos + 0001:000347C0 TCustomMemo.SetScrollBars + 0001:000347D4 TCustomMemo.SetWordWrap + 0001:000347E8 TCustomMemo.WMGetDlgCode + 0001:0003481C TCustomMemo.WMNCDestroy + 0001:0001DB38 TCustomMemoryStream.Read + 0001:0001DB70 TCustomMemoryStream.Seek + 0001:0001DB30 TCustomMemoryStream.SetPointer + 0001:000386D4 TCustomPanel.AdjustClientRect + 0001:00038868 TCustomPanel.CanAutoSize + 0001:00038344 TCustomPanel.CMBorderChanged + 0001:00038360 TCustomPanel.CMCtl3DChanged + 0001:0003872C TCustomPanel.CMDockClient + 0001:0003838C TCustomPanel.CMIsToolControl + 0001:00038358 TCustomPanel.CMTextChanged + 0001:00038258 TCustomPanel.Create + 0001:000382F0 TCustomPanel.CreateParams + 0001:000386CC TCustomPanel.GetControlsAlignment + 0001:000384D8 TCustomPanel.Paint + 0001:0003863C TCustomPanel.SetAlignment + 0001:00038648 TCustomPanel.SetBevelInner + 0001:00038664 TCustomPanel.SetBevelOuter + 0001:00038680 TCustomPanel.SetBevelWidth + 0001:000386B8 TCustomPanel.SetBorderStyle + 0001:0003869C TCustomPanel.SetBorderWidth + 0001:000383A0 TCustomPanel.WMWindowPosChanged + 0001:0006D71C TCustomRichEdit.Clear + 0001:0006DC04 TCustomRichEdit.CMBiDiModeChanged + 0001:0006DD14 TCustomRichEdit.CMColorChanged + 0001:0006DA24 TCustomRichEdit.CMFontChanged + 0001:0006E0A0 TCustomRichEdit.CNNotify + 0001:0006D5A4 TCustomRichEdit.Create + 0001:0006D734 TCustomRichEdit.CreateParams + 0001:0006D7C0 TCustomRichEdit.CreateWnd + 0001:0006D6C0 TCustomRichEdit.Destroy + 0001:0006D8E8 TCustomRichEdit.DestroyWnd + 0001:0006DA34 TCustomRichEdit.DoSetMaxLength + 0001:0006DA54 TCustomRichEdit.GetCaretPos + 0001:0006DCFC TCustomRichEdit.GetPlainText + 0001:0006DB00 TCustomRichEdit.GetSelLength + 0001:0006DB28 TCustomRichEdit.GetSelStart + 0001:0006DBC0 TCustomRichEdit.GetSelText + 0001:0006DB4C TCustomRichEdit.GetSelTextBuf + 0001:0006DD78 TCustomRichEdit.Print + 0001:0006E14C TCustomRichEdit.ProtectChange + 0001:0006E19C TCustomRichEdit.RequestSize + 0001:0006E11C TCustomRichEdit.SaveClipboard + 0001:0006E17C TCustomRichEdit.SelectionChange + 0001:0006DAB4 TCustomRichEdit.SetCaretPos + 0001:0006DC5C TCustomRichEdit.SetHideScrollBars + 0001:0006DC70 TCustomRichEdit.SetHideSelection + 0001:0006DD08 TCustomRichEdit.SetPlainText + 0001:0006DD40 TCustomRichEdit.SetRichEditStrings + 0001:0006DCA0 TCustomRichEdit.SetSelLength + 0001:0006DD50 TCustomRichEdit.SetSelStart + 0001:0006D9B4 TCustomRichEdit.WMNCDestroy + 0001:0006DF50 TCustomRichEdit.WMPaint + 0001:0006D9CC TCustomRichEdit.WMRButtonUp + 0001:0006E010 TCustomRichEdit.WMSetCursor + 0001:0006D9BC TCustomRichEdit.WMSetFont + 0001:0006530C TCustomServerSocket.Destroy + 0001:0006533C TCustomServerSocket.DoActivate + 0001:000653C8 TCustomServerSocket.GetGetSocketEvent + 0001:00065398 TCustomServerSocket.GetGetThreadEvent + 0001:00065574 TCustomServerSocket.GetOnClientError + 0001:00065480 TCustomServerSocket.GetOnClientEvent + 0001:00065428 TCustomServerSocket.GetOnThreadEnd + 0001:00065410 TCustomServerSocket.GetOnThreadStart + 0001:00065380 TCustomServerSocket.GetServerType + 0001:000653F8 TCustomServerSocket.GetThreadCacheSize + 0001:000653DC TCustomServerSocket.SetGetSocketEvent + 0001:000653AC TCustomServerSocket.SetGetThreadEvent + 0001:0006558C TCustomServerSocket.SetOnClientError + 0001:000654F8 TCustomServerSocket.SetOnClientEvent + 0001:00065460 TCustomServerSocket.SetOnThreadEnd + 0001:00065440 TCustomServerSocket.SetOnThreadStart + 0001:0006538C TCustomServerSocket.SetServerType + 0001:00065404 TCustomServerSocket.SetThreadCacheSize + 0001:000651E8 TCustomSocket.Error + 0001:000650E8 TCustomSocket.Event + 0001:000370D8 TCustomStaticText.AdjustBounds + 0001:00036FF8 TCustomStaticText.CMDialogChar + 0001:00037094 TCustomStaticText.CMFontChanged + 0001:000370A8 TCustomStaticText.CMTextChanged + 0001:00036F08 TCustomStaticText.Create + 0001:00036F78 TCustomStaticText.CreateParams + 0001:000370C4 TCustomStaticText.Loaded + 0001:000371C0 TCustomStaticText.Notification + 0001:000371F0 TCustomStaticText.SetAlignment + 0001:00037204 TCustomStaticText.SetAutoSize + 0001:0003721C TCustomStaticText.SetBorderStyle + 0001:00037230 TCustomStaticText.SetFocusControl + 0001:00037244 TCustomStaticText.SetShowAccelChar + 0001:00016B58 TCustomVariantType.BinaryOp + 0001:00016B64 TCustomVariantType.Cast + 0001:00016B9C TCustomVariantType.CastTo + 0001:00016C28 TCustomVariantType.CastToOle + 0001:00016BE4 TCustomVariantType.Compare + 0001:00016BF0 TCustomVariantType.CompareOp + 0001:00016C64 TCustomVariantType.Destroy + 0001:00016D44 TCustomVariantType.DispInvoke + 0001:00016CF0 TCustomVariantType.IsClear + 0001:00016CF4 TCustomVariantType.LeftPromotion + 0001:00016D08 TCustomVariantType.OlePromotion + 0001:00016D68 TCustomVariantType.QueryInterface + 0001:00016D10 TCustomVariantType.RaiseCastError + 0001:00016D20 TCustomVariantType.RaiseDispError + 0001:00016D18 TCustomVariantType.RaiseInvalidOp + 0001:00016D28 TCustomVariantType.RightPromotion + 0001:00016D3C TCustomVariantType.UnaryOp + 0001:00016D50 TCustomVariantType._AddRef + 0001:00016D5C TCustomVariantType._Release + 0001:0006313C TCustomWinSocket.Accept + 0001:00063140 TCustomWinSocket.AsyncInitSocket + 0001:000633F8 TCustomWinSocket.Close + 0001:00063564 TCustomWinSocket.CMDeferFree + 0001:00063FCC TCustomWinSocket.CMLookupComplete + 0001:000634D8 TCustomWinSocket.CMSocketMessage + 0001:00063404 TCustomWinSocket.Connect + 0001:00063058 TCustomWinSocket.Create + 0001:00063B24 TCustomWinSocket.DefaultHandler + 0001:0006356C TCustomWinSocket.DeferFree + 0001:000630D0 TCustomWinSocket.Destroy + 0001:00063A18 TCustomWinSocket.Disconnect + 0001:000635E0 TCustomWinSocket.DoListen + 0001:00063660 TCustomWinSocket.DoOpen + 0001:00063584 TCustomWinSocket.DoSetAsyncStyles + 0001:00063B68 TCustomWinSocket.Error + 0001:00063B50 TCustomWinSocket.Event + 0001:000636CC TCustomWinSocket.GetHandle + 0001:00063778 TCustomWinSocket.InitSocket + 0001:00063810 TCustomWinSocket.Listen + 0001:00063408 TCustomWinSocket.Lock + 0001:000636E8 TCustomWinSocket.LookupName + 0001:00063744 TCustomWinSocket.LookupService + 0001:00063918 TCustomWinSocket.Open + 0001:00063D84 TCustomWinSocket.Read + 0001:00063DA0 TCustomWinSocket.ReceiveBuf + 0001:00063F0C TCustomWinSocket.ReceiveText + 0001:00063BD4 TCustomWinSocket.SendStreamPiece + 0001:00063D5C TCustomWinSocket.SetAsyncStyles + 0001:00063414 TCustomWinSocket.Unlock + 0001:00063F48 TCustomWinSocket.WndProc + 0001:00063F9C TCustomWinSocket.Write + 0001:00047FB8 TDockTree.AdjustDockRect + 0001:00047FCC TDockTree.BeginUpdate + 0001:00049C88 TDockTree.ControlVisibilityChanged + 0001:00047DFC TDockTree.Create + 0001:00047F64 TDockTree.Destroy + 0001:00049888 TDockTree.DrawSizeSplitter + 0001:00047FD0 TDockTree.EndUpdate + 0001:0004803C TDockTree.FindControlZone + 0001:000480A4 TDockTree.ForEachAt + 0001:000480BC TDockTree.GetControlBounds + 0001:00049A04 TDockTree.GetNextLimit + 0001:00048130 TDockTree.HitTest + 0001:00048140 TDockTree.InsertControl + 0001:00048350 TDockTree.InsertNewParent + 0001:000484F8 TDockTree.InsertSibling + 0001:00048830 TDockTree.InternalHitTest + 0001:00048900 TDockTree.LoadFromStream + 0001:00048BE8 TDockTree.PaintDockFrame + 0001:00048CC4 TDockTree.PaintSite + 0001:00048E28 TDockTree.PositionDockRect + 0001:00048FD0 TDockTree.PruneZone + 0001:0004902C TDockTree.RemoveControl + 0001:00049068 TDockTree.RemoveZone + 0001:000492E4 TDockTree.ResetBounds + 0001:00049530 TDockTree.SaveToStream + 0001:000493C0 TDockTree.ScaleZone + 0001:00049700 TDockTree.SetNewBounds + 0001:0004972C TDockTree.SetReplacingControl + 0001:00049744 TDockTree.ShiftZone + 0001:00049774 TDockTree.SplitterMouseDown + 0001:000497D4 TDockTree.SplitterMouseUp + 0001:00049850 TDockTree.UpdateAll + 0001:00049878 TDockTree.UpdateZone + 0001:00049DA0 TDockTree.WindowProc + 0001:000477A4 TDockZone.Create + 0001:00047D2C TDockZone.ExpandZoneLimit + 0001:00047DF0 TDockZone.FirstVisibleChild + 0001:000477C8 TDockZone.GetChildCount + 0001:00047A80 TDockZone.GetControlName + 0001:00047928 TDockZone.GetHeightWidth + 0001:0004782C TDockZone.GetLimitBegin + 0001:00047874 TDockZone.GetLimitSize + 0001:000478BC TDockZone.GetTopLeft + 0001:000477F8 TDockZone.GetVisible + 0001:000477DC TDockZone.GetVisibleChildCount + 0001:00047CF0 TDockZone.GetZoneLimit + 0001:00047DC8 TDockZone.NextVisible + 0001:00047DD4 TDockZone.PrevVisible + 0001:000479D8 TDockZone.ResetChildren + 0001:00047D68 TDockZone.ResetZoneLimits + 0001:00047AC4 TDockZone.SetControlName + 0001:00047D18 TDockZone.SetZoneLimit + 0001:00047B78 TDockZone.Update + 0001:0003CBF8 TDragControlObject.GetDragCursor + 0001:0003CC10 TDragControlObject.GetDragImages + 0001:0003CC1C TDragControlObject.HideDragImage + 0001:0003CC3C TDragControlObject.ShowDragImage + 0001:0003CC5C TDragControlObjectEx.BeforeDestruction + 0001:0003CD98 TDragDockObject.AdjustDockRect + 0001:0003CCF4 TDragDockObject.Assign + 0001:0003CC60 TDragDockObject.Create + 0001:0003CCC4 TDragDockObject.Destroy + 0001:0003CE14 TDragDockObject.DrawDragDockImage + 0001:0003CD50 TDragDockObject.EndDrag + 0001:0003CE28 TDragDockObject.EraseDragDockImage + 0001:0003CE3C TDragDockObject.GetDragCursor + 0001:0003CE48 TDragDockObject.GetFrameWidth + 0001:0003CE50 TDragDockObjectEx.BeforeDestruction + 0001:00047464 TDragImageList.BeginDrag + 0001:0004730C TDragImageList.CombineDragCursor + 0001:000474C4 TDragImageList.DragLock + 0001:0004754C TDragImageList.DragMove + 0001:00047528 TDragImageList.DragUnlock + 0001:000475C0 TDragImageList.EndDrag + 0001:00047438 TDragImageList.GetHotSpot + 0001:000475A8 TDragImageList.HideDragImage + 0001:000472F4 TDragImageList.Initialize + 0001:00047420 TDragImageList.SetDragCursor + 0001:000473D8 TDragImageList.SetDragImage + 0001:00047590 TDragImageList.ShowDragImage + 0001:0003CB34 TDragObject.AfterConstruction + 0001:0003C914 TDragObject.Assign + 0001:0003CB24 TDragObject.BeforeDestruction + 0001:0003C954 TDragObject.Capture + 0001:0003C96C TDragObject.Finished + 0001:0003CAB0 TDragObject.GetDragCursor + 0001:0003CAAC TDragObject.GetDragImages + 0001:0003C974 TDragObject.GetName + 0001:0003CAC8 TDragObject.HideDragImage + 0001:0003CACC TDragObject.Instance + 0001:0003CAD8 TDragObject.MainWndProc + 0001:0003C99C TDragObject.ReleaseCapture + 0001:0003CAD4 TDragObject.ShowDragImage + 0001:0003C9B0 TDragObject.WndProc + 0001:0003CB44 TDragObjectEx.BeforeDestruction + 0002:00003864 TempVarAdd + 0002:0000387C TempVarAnd + 0002:000038A0 TempVarBoolFromStr + 0002:000038AC TempVarBstrFromBool + 0002:000038A4 TempVarBstrFromCy + 0002:000038A8 TempVarBstrFromDate + 0002:00003888 TempVarCmp + 0002:0000389C TempVarCyFromStr + 0002:00003898 TempVarDateFromStr + 0002:00003870 TempVarDiv + 0002:0000388C TempVarI4FromStr + 0002:00003858 TempVariantChangeTypeEx + 0002:00003874 TempVarIDiv + 0002:00003878 TempVarMod + 0002:0000386C TempVarMul + 0002:0000385C TempVarNeg + 0002:00003860 TempVarNot + 0002:00003880 TempVarOr + 0002:00003890 TempVarR4FromStr + 0002:00003894 TempVarR8FromStr + 0002:00003868 TempVarSub + 0002:00003884 TempVarXor + 0002:000002F4 TerminateProcList + 0002:0000304E Test8086 + 0001:00061EA8 TEvent.Create + 0001:00061F54 TEvent.ResetEvent + 0001:00061F48 TEvent.SetEvent + 0001:00061F00 TEvent.WaitFor + 0001:00001C18 TextClose + 0002:000013BC TextConversionFormat + 0001:00001B8C TextIn + 0001:00001C38 TextOpen + 0001:00001BCC TextOut + 0001:000090A4 TextToFloat + 0001:0004E754 TextToShortCut + 0001:0001DEC4 TFiler.Create + 0001:0001DF0C TFiler.Destroy + 0001:0001DF34 TFiler.SetRoot + 0001:0001DA34 TFileStream.Create + 0001:0001D9F0 TFileStream.Create + 0001:0001DAFC TFileStream.Destroy + 0001:00026344 TFont.Assign + 0001:00026328 TFont.Changed + 0001:000262AC TFont.Create + 0001:00026300 TFont.Destroy + 0001:000267A8 TFont.GetCharset + 0001:00026418 TFont.GetData + 0001:00026494 TFont.GetHandle + 0001:00026660 TFont.GetHeight + 0001:00026690 TFont.GetName + 0001:00026778 TFont.GetPitch + 0001:00026704 TFont.GetSize + 0001:00026740 TFont.GetStyle + 0001:000267B0 TFont.SetCharset + 0001:00026480 TFont.SetColor + 0001:00026430 TFont.SetData + 0001:0002663C TFont.SetHandle + 0001:00026668 TFont.SetHeight + 0001:000266A8 TFont.SetName + 0001:00026780 TFont.SetPitch + 0001:00026720 TFont.SetSize + 0001:0002674C TFont.SetStyle + 0001:00079D2C TfrmMain.AddHistoryItem + 0001:000796C4 TfrmMain.btnExitClick + 0001:000795B4 TfrmMain.btnRunClick + 0001:0007A228 TfrmMain.cbexIconChange + 0001:00079950 TfrmMain.clientSockConnect + 0001:00079C94 TfrmMain.clientSockConnecting + 0001:00079A14 TfrmMain.clientSockError + 0001:00079BE0 TfrmMain.comCommandKeyDown + 0001:00079D94 TfrmMain.ConsoleCommand + 0001:00079B94 TfrmMain.ConsoleResizeRequest + 0001:0007973C TfrmMain.Execute + 0001:0007980C TfrmMain.FormCloseQuery + 0001:00079570 TfrmMain.FormCreate + 0001:00079928 TfrmMain.FormDestroy + 0001:00079AC4 TfrmMain.Launch + 0001:0007A250 TfrmMain.LoadPseuSettings + 0001:0007A008 TfrmMain.LoadSettings + 0001:00079B0C TfrmMain.Log + 0001:0007986C TfrmMain.servRemoteClientRead + 0001:00079EA4 TfrmMain.SetIcon + 0001:00079E58 TfrmMain.SetupIcons + 0001:000796CC TfrmMain.ShutDown + 0001:00079828 TfrmMain.timerStartTimer + 0001:000289E0 TGraphic.Changed + 0001:000289A8 TGraphic.Create + 0001:00028A50 TGraphic.DefineProperties + 0001:00028A9C TGraphic.Equals + 0001:00028BE8 TGraphic.GetPalette + 0001:00028BEC TGraphic.GetTransparent + 0001:00028BF0 TGraphic.LoadFromFile + 0001:00028C44 TGraphic.Progress + 0001:00028C6C TGraphic.ReadData + 0001:00028C78 TGraphic.SaveToFile + 0001:00028CD0 TGraphic.SetPalette + 0001:00028CD4 TGraphic.SetTransparent + 0001:00028CE4 TGraphic.WriteData + 0001:00025FF0 TGraphicsObject.Changed + 0001:00026004 TGraphicsObject.Lock + 0001:00026014 TGraphicsObject.Unlock + 0001:00061E78 THandleObject.Destroy + 0001:0001D92C THandleStream.Create + 0001:0001D968 THandleStream.Read + 0001:0001D988 THandleStream.Seek + 0001:0001D9B4 THandleStream.SetSize + 0001:0001D9C8 THandleStream.SetSize + 0001:0001D978 THandleStream.Write + 0001:0002DCE4 THelpManager.AssignHelpSelector + 0001:0002D7B0 THelpManager.CallSpecialWinHelp + 0001:0002D3EC THelpManager.Create + 0001:0002DEAC THelpManager.Destroy + 0001:0002D5E0 THelpManager.DoSoftShutDown + 0001:0002D610 THelpManager.DoTableOfContents + 0001:0002DE04 THelpManager.GetHandle + 0001:0002DE08 THelpManager.GetHelpFile + 0001:0002DD48 THelpManager.Hook + 0001:0002D460 THelpManager.RegisterViewer + 0001:0002DE1C THelpManager.Release + 0001:0002DACC THelpManager.ShowContextHelp + 0001:0002D8B8 THelpManager.ShowHelp + 0001:0002DBE0 THelpManager.ShowTableOfContents + 0001:0002DBE8 THelpManager.ShowTopicHelp + 0001:0002D598 THelpManager.UnloadAllViewers + 0001:0002D370 THelpViewerNode.Create + 0001:00039218 THintAction.Create + 0001:00047000 THintWindow.ActivateHint + 0001:000471D8 THintWindow.ActivateHintData + 0001:00047200 THintWindow.CalcHintRect + 0001:00046F68 THintWindow.CMTextChanged + 0001:00046D40 THintWindow.Create + 0001:00046DAC THintWindow.CreateParams + 0001:00046EFC THintWindow.IsHintMsg + 0001:0004725C THintWindow.NCPaint + 0001:00046E54 THintWindow.Paint + 0001:00046F60 THintWindow.ReleaseHandle + 0001:00046DE8 THintWindow.WMNCHitTest + 0001:00046DF0 THintWindow.WMNCPaint + 0001:00047290 THintWindow.WMPrint + 0002:0000373A ThousandSeparator + 0002:00003A78 ThreadCount + 0002:00003A60 ThreadLock + 0001:00022F80 ThreadProc + 0002:00001318 ThreadStrs + 0001:00003674 ThreadWrapper + 0001:0002B464 TIcon.Assign + 0001:0002B3E0 TIcon.Create + 0001:0002B434 TIcon.Destroy + 0001:0002B4C4 TIcon.Draw + 0001:0002B504 TIcon.GetEmpty + 0001:0002B51C TIcon.GetHandle + 0001:0002B530 TIcon.GetHeight + 0001:0002B544 TIcon.GetWidth + 0001:0002B558 TIcon.HandleNeeded + 0001:0002B5D0 TIcon.ImageNeeded + 0001:0002B828 TIcon.LoadFromClipboardFormat + 0001:0002B684 TIcon.LoadFromStream + 0001:0002B73C TIcon.NewImage + 0001:0002B83C TIcon.SaveToClipboardFormat + 0001:0002B7FC TIcon.SaveToStream + 0001:0002B7B0 TIcon.SetHandle + 0001:0002B7C8 TIcon.SetHeight + 0001:0002B7E0 TIcon.SetTransparent + 0001:0002B7E4 TIcon.SetWidth + 0001:0002B398 TIconImage.Destroy + 0001:0002B3C8 TIconImage.FreeHandle + 0001:0006FDEC TIconOptions.Create + 0001:0006FE60 TIconOptions.SetArrangement + 0001:0006FE74 TIconOptions.SetAutoArrange + 0001:0006FE88 TIconOptions.SetWrapText + 0002:0000374C TimeAMString + 0002:00003750 TimePMString + 0002:00003748 TimeSeparator + 0001:0000A328 TimeToStr + 0001:00061AD4 TIniFile.DeleteKey + 0001:00061634 TIniFile.Destroy + 0001:00061A80 TIniFile.EraseSection + 0001:0006182C TIniFile.ReadSection + 0001:0006172C TIniFile.ReadSections + 0001:00061934 TIniFile.ReadSectionValues + 0001:00061660 TIniFile.ReadString + 0001:00061B04 TIniFile.UpdateFile + 0001:000616C0 TIniFile.WriteString + 0001:0001A818 TIntConst.Create + 0001:00005498 TInterfacedObject.AfterConstruction + 0001:000054A4 TInterfacedObject.BeforeDestruction + 0001:000054B4 TInterfacedObject.NewInstance + 0001:000054C4 TInterfacedObject.QueryInterface + 0001:000054EC TInterfacedObject._AddRef + 0001:00005500 TInterfacedObject._Release + 0001:0001B838 TInterfacedPersistent.AfterConstruction + 0001:0001B8C8 TInterfacedPersistent.QueryInterface + 0001:0001B888 TInterfacedPersistent._AddRef + 0001:0001B8A8 TInterfacedPersistent._Release + 0001:00076238 TJvAppStoragePropertyEngineList.Destroy + 0001:00076E28 TJvTrayIcon.AcceptBalloons + 0001:00076E38 TJvTrayIcon.ApplicationHook + 0001:00076E60 TJvTrayIcon.BalloonHint + 0001:00076CC8 TJvTrayIcon.Create + 0001:00076DB0 TJvTrayIcon.Destroy + 0001:00076FB4 TJvTrayIcon.DoAnimation + 0001:00077028 TJvTrayIcon.DoClick + 0001:000770CC TJvTrayIcon.DoCloseBalloon + 0001:000770E4 TJvTrayIcon.DoContextPopup + 0001:00077164 TJvTrayIcon.DoDoubleClick + 0001:00077240 TJvTrayIcon.DoMouseDown + 0001:00077280 TJvTrayIcon.DoMouseMove + 0001:000773E0 TJvTrayIcon.DoMouseUp + 0001:000774D8 TJvTrayIcon.DoTimerDblClick + 0001:00077514 TJvTrayIcon.EndAnimation + 0001:00077530 TJvTrayIcon.GetApplicationVisible + 0001:0007754C TJvTrayIcon.GetSystemMinimumBalloonDelay + 0001:00077554 TJvTrayIcon.HideApplication + 0001:000775F4 TJvTrayIcon.HideBalloon + 0001:00077620 TJvTrayIcon.HideTrayIcon + 0001:00077644 TJvTrayIcon.Hook + 0001:0007766C TJvTrayIcon.IconChanged + 0001:00077674 TJvTrayIcon.IconPropertyChanged + 0001:00077738 TJvTrayIcon.InitIconData + 0001:00077814 TJvTrayIcon.Loaded + 0001:00077894 TJvTrayIcon.Notification + 0001:000778E4 TJvTrayIcon.NotifyIcon + 0001:00077900 TJvTrayIcon.SetActive + 0001:0007795C TJvTrayIcon.SetAnimated + 0001:00077980 TJvTrayIcon.SetCurrentIcon + 0001:000779B0 TJvTrayIcon.SetDelay + 0001:00077A1C TJvTrayIcon.SetHint + 0001:00077ADC TJvTrayIcon.SetIcon + 0001:00077AE8 TJvTrayIcon.SetIconIndex + 0001:00077AFC TJvTrayIcon.SetIcons + 0001:00077B10 TJvTrayIcon.SetTask + 0001:00077B60 TJvTrayIcon.SetVisibility + 0001:00077C50 TJvTrayIcon.ShowApplication + 0001:00077D18 TJvTrayIcon.ShowTrayIcon + 0001:00077D8C TJvTrayIcon.StartAnimation + 0001:00077DC8 TJvTrayIcon.StopTimer + 0001:00077DDC TJvTrayIcon.Unhook + 0001:00077E00 TJvTrayIcon.WndProc + 0001:000754B4 TlHelp32 + 0001:0001AF38 TList.Add + 0001:0001AF6C TList.Clear + 0001:0001AF84 TList.Delete + 0001:0001AF18 TList.Destroy + 0001:0001B020 TList.Error + 0001:0001AFE8 TList.Error + 0001:0001B074 TList.Expand + 0001:0001B08C TList.First + 0001:0001B094 TList.Get + 0001:0001B0BC TList.Grow + 0001:0001B0F0 TList.IndexOf + 0001:0001B110 TList.Insert + 0001:0001B17C TList.Last + 0001:0001B188 TList.Move + 0001:0001B300 TList.Notify + 0001:0001B1E0 TList.Put + 0001:0001B234 TList.Remove + 0001:0001B254 TList.SetCapacity + 0001:0001B290 TList.SetCount + 0001:0006967C TListActionLink.AddItem + 0001:00069678 TListActionLink.AddItem + 0001:00069430 TListActionLink.IsActiveLinked + 0001:00069444 TListActionLink.IsImagesLinked + 0001:00069524 TListActionLink.RefreshControl + 0001:00069470 TListActionLink.SetAction + 0001:000694B4 TListActionLink.SetActive + 0001:00069520 TListActionLink.SetImages + 0001:000696A8 TListActionLink.SetItemIndex + 0001:0006E6A8 TListColumn.Assign + 0001:0006E1BC TListColumn.Create + 0001:0006E2C4 TListColumn.DefineProperties + 0001:0006E264 TListColumn.Destroy + 0001:0006E454 TListColumn.DoChange + 0001:0006E71C TListColumn.GetDisplayName + 0001:0006E5AC TListColumn.GetWidth + 0001:0006E5D8 TListColumn.IsWidthStored + 0001:0006E30C TListColumn.ReadData + 0001:0006E60C TListColumn.SetAlignment + 0001:0006E644 TListColumn.SetAutoSize + 0001:0006E584 TListColumn.SetCaption + 0001:0006E678 TListColumn.SetImageIndex + 0001:0006E4D4 TListColumn.SetIndex + 0001:0006E688 TListColumn.SetMaxWidth + 0001:0006E698 TListColumn.SetMinWidth + 0001:0006E5E0 TListColumn.SetWidth + 0001:0006E334 TListColumn.WriteData + 0001:0006E740 TListColumns.Create + 0001:0006E784 TListColumns.GetItem + 0001:0006E79C TListColumns.GetOwner + 0001:0006E798 TListColumns.Owner + 0001:0006E7A0 TListColumns.Update + 0001:0006E7D4 TListColumns.UpdateCols + 0001:000688F4 TListControlItem.Assign + 0001:0006897C TListControlItem.Changed + 0001:0006898C TListControlItem.Create + 0001:000689C8 TListControlItem.GetDisplayName + 0001:000689F4 TListControlItem.SetCaption + 0001:00068A10 TListControlItem.SetData + 0001:00068A1C TListControlItem.SetImageIndex + 0001:00068A54 TListControlItems.Add + 0001:00068A94 TListControlItems.CompareItems + 0001:00068A64 TListControlItems.CustomSort + 0001:00068AD0 TListControlItems.ExchangeItems + 0001:00068BC0 TListControlItems.GetListItem + 0001:00068B2C TListControlItems.QuickSort + 0001:00068BD4 TListControlItems.SetSortType + 0001:00068BEC TListControlItems.Sort + 0001:0006F258 TListItem.Assign + 0001:0006ED50 TListItem.Create + 0001:0006EE14 TListItem.Delete + 0001:0006EDA0 TListItem.Destroy + 0001:0006F348 TListItem.DisplayRect + 0001:0006EE4C TListItem.GetChecked + 0001:0006EE38 TListItem.GetHandle + 0001:0006F32C TListItem.GetIndex + 0001:0006EE0C TListItem.GetListView + 0001:0006EFD8 TListItem.GetState + 0001:0006F378 TListItem.GetSubItemImage + 0001:0006F2F0 TListItem.IsEqual + 0001:0006EEF8 TListItem.SetCaption + 0001:0006EE90 TListItem.SetChecked + 0001:0006EFA8 TListItem.SetData + 0001:0006F0B0 TListItem.SetImage + 0001:0006F1EC TListItem.SetIndent + 0001:0006F040 TListItem.SetState + 0001:0006F384 TListItem.SetSubItemImage + 0001:0006F318 TListItem.SetSubItems + 0001:0006EEDC TListItem.Update + 0001:0006F458 TListItems.Add + 0001:0006F464 TListItems.AddItem + 0001:0006F7B8 TListItems.Assign + 0001:0006F5C8 TListItems.BeginUpdate + 0001:0006F5A8 TListItems.Clear + 0001:0006F3F0 TListItems.Create + 0001:0006FDC8 TListItems.CreateItem + 0001:0006F8A8 TListItems.DefineProperties + 0001:0006FDB0 TListItems.Delete + 0001:0006F42C TListItems.Destroy + 0001:0006F7A4 TListItems.EndUpdate + 0001:0006F4B4 TListItems.GetCount + 0001:0006F4D8 TListItems.GetHandle + 0001:0006F4E4 TListItems.GetItem + 0001:0006F564 TListItems.IndexOf + 0001:0006F900 TListItems.ReadData + 0001:0006F58C TListItems.SetCount + 0001:0006F5E0 TListItems.SetUpdateState + 0001:0006FB0C TListItems.WriteData + 0001:00074C70 TListViewActionLink.AddItem + 0001:00074BF8 TListViewActionLink.AddItem + 0001:00074CA8 TListViewActionLink.SetImages + 0001:00078D20 TLogThread.AddMessage + 0001:00078D8C TLogThread.Create + 0001:00078DE8 TLogThread.Destroy + 0001:00078E20 TLogThread.Execute + 0001:00078EEC TLogThread.SyncWrite + 0001:00078F0C TLogThread.WriteFromPseWow + 0002:00003720 tlsBuffer + 0001:00005A2C TlsGetValue + 0002:00003710 TlsIndex + 0002:FFB84014 TlsLast + 0001:00005A34 TlsSetValue + 0001:00052DE0 TMainMenu.GetHandle + 0001:00052DB4 TMainMenu.ItemChanged + 0001:00052D24 TMainMenu.MenuChanged + 0001:00052D7C TMainMenu.Merge + 0001:00052D04 TMainMenu.SetAutoMerge + 0001:00052D98 TMainMenu.Unmerge + 0001:0001DBC0 TMemoryStream.Clear + 0001:0001DB94 TMemoryStream.Destroy + 0001:0001DBD8 TMemoryStream.LoadFromStream + 0001:0001DC64 TMemoryStream.Realloc + 0001:0001DC10 TMemoryStream.SetCapacity + 0001:0001DC38 TMemoryStream.SetSize + 0001:0001DCF0 TMemoryStream.Write + 0001:000343BC TMemoStrings.Clear + 0001:0003432C TMemoStrings.Delete + 0001:00034168 TMemoStrings.Get + 0001:000340F8 TMemoStrings.GetCount + 0001:0003441C TMemoStrings.GetTextStr + 0001:00034220 TMemoStrings.Insert + 0001:000341AC TMemoStrings.Put + 0001:00034430 TMemoStrings.SetTextStr + 0001:000343CC TMemoStrings.SetUpdateState + 0001:0005273C TMenu.AdjustBiDiBehavior + 0001:00051F44 TMenu.Create + 0001:00051FE0 TMenu.Destroy + 0001:000521CC TMenu.DispatchCommand + 0001:000521E8 TMenu.DispatchPopup + 0001:0005254C TMenu.DoBiDiModeChanged + 0001:000527F0 TMenu.DoChange + 0001:00052BA4 TMenu.DoGetMenuString + 0001:0005212C TMenu.FindItem + 0001:00052CC4 TMenu.GetAutoHotkeys + 0001:00052CE4 TMenu.GetAutoLineReduction + 0001:00052018 TMenu.GetChildren + 0001:00052034 TMenu.GetHandle + 0001:0005215C TMenu.GetHelpContext + 0001:0005285C TMenu.ImageListChange + 0001:00052544 TMenu.IsBiDiModeStored + 0001:000522B0 TMenu.IsOwnerDraw + 0001:000528D0 TMenu.IsRightToLeft + 0001:00052428 TMenu.IsShortCut + 0001:00052808 TMenu.Loaded + 0001:00052820 TMenu.MenuChanged + 0001:000528A4 TMenu.Notification + 0001:00052C98 TMenu.ParentBiDiModeChanged + 0001:00052C70 TMenu.ParentBiDiModeChanged + 0001:00052A2C TMenu.ProcessMenuChar + 0001:00052CD4 TMenu.SetAutoHotkeys + 0001:00052CF4 TMenu.SetAutoLineReduction + 0001:00052C4C TMenu.SetBiDiMode + 0001:00052040 TMenu.SetChildOrder + 0001:00052868 TMenu.SetImages + 0001:0005272C TMenu.SetOwnerDraw + 0001:00052C60 TMenu.SetParentBiDiMode + 0001:000527B8 TMenu.SetWindowHandle + 0001:000526A8 TMenu.UpdateImage + 0001:0005207C TMenu.UpdateItems + 0001:0004E9D4 TMenuActionLink.AssignClient + 0001:0004E9F0 TMenuActionLink.IsAutoCheckLinked + 0001:0004EA18 TMenuActionLink.IsCaptionLinked + 0001:0004EA50 TMenuActionLink.IsCheckedLinked + 0001:0004EA80 TMenuActionLink.IsEnabledLinked + 0001:0004EB14 TMenuActionLink.IsGroupIndexLinked + 0001:0004EAB0 TMenuActionLink.IsHelpContextLinked + 0001:0004EAE0 TMenuActionLink.IsHintLinked + 0001:0004EB50 TMenuActionLink.IsImageIndexLinked + 0001:0004EBEC TMenuActionLink.IsOnExecuteLinked + 0001:0004EB84 TMenuActionLink.IsShortCutLinked + 0001:0004EBB8 TMenuActionLink.IsVisibleLinked + 0001:0004EC14 TMenuActionLink.SetAutoCheck + 0001:0004EC34 TMenuActionLink.SetCaption + 0001:0004EC54 TMenuActionLink.SetChecked + 0001:0004EC74 TMenuActionLink.SetEnabled + 0001:0004EC94 TMenuActionLink.SetHelpContext + 0001:0004ECB0 TMenuActionLink.SetHint + 0001:0004ECD4 TMenuActionLink.SetImageIndex + 0001:0004ED34 TMenuActionLink.SetOnExecute + 0001:0004ECF4 TMenuActionLink.SetShortCut + 0001:0004ED14 TMenuActionLink.SetVisible + 0001:000512D0 TMenuItem.ActionChange + 0001:00051054 TMenuItem.Add + 0001:00050798 TMenuItem.AdvancedDrawItem + 0001:0004EE90 TMenuItem.AppendTo + 0001:00051534 TMenuItem.AssignTo + 0001:00050F8C TMenuItem.Click + 0001:0004ED60 TMenuItem.Create + 0001:0004F3EC TMenuItem.DefineProperties + 0001:00050F18 TMenuItem.Delete + 0001:0004EDDC TMenuItem.Destroy + 0001:000513F0 TMenuItem.DoActionChange + 0001:0004F430 TMenuItem.DoDrawText + 0001:0004F640 TMenuItem.DrawItem + 0001:00050CC0 TMenuItem.GetAction + 0001:00050CD0 TMenuItem.GetActionLinkClass + 0001:00051EEC TMenuItem.GetAutoHotkeys + 0001:00051F18 TMenuItem.GetAutoLineReduction + 0001:00051134 TMenuItem.GetBitmap + 0001:00050DA0 TMenuItem.GetChildren + 0001:00050CD8 TMenuItem.GetCount + 0001:0004F3A0 TMenuItem.GetHandle + 0001:000508B0 TMenuItem.GetImageList + 0001:00050CE8 TMenuItem.GetItem + 0001:00050D40 TMenuItem.GetMenuIndex + 0001:0005122C TMenuItem.GetParentComponent + 0001:00051294 TMenuItem.GetParentMenu + 0001:00050B2C TMenuItem.HasParent + 0001:0005163C TMenuItem.ImageListChange + 0001:0005103C TMenuItem.IndexOf + 0001:00050E54 TMenuItem.InitiateAction + 0001:00051200 TMenuItem.InitiateActions + 0001:00050E64 TMenuItem.Insert + 0001:00051898 TMenuItem.InternalRethinkHotkeys + 0001:00051D94 TMenuItem.InternalRethinkLines + 0001:00051414 TMenuItem.IsCaptionStored + 0001:00051434 TMenuItem.IsCheckedStored + 0001:00051454 TMenuItem.IsEnabledStored + 0001:00051494 TMenuItem.IsHelpContextStored + 0001:00051474 TMenuItem.IsHintStored + 0001:000514B4 TMenuItem.IsImageIndexStored + 0001:00051D70 TMenuItem.IsLine + 0001:00051514 TMenuItem.IsOnClickStored + 0001:000514D4 TMenuItem.IsShortCutStored + 0001:000514F4 TMenuItem.IsVisibleStored + 0001:0004F234 TMenuItem.Loaded + 0001:0005092C TMenuItem.MeasureItem + 0001:00051098 TMenuItem.MenuChanged + 0001:0004F1F8 TMenuItem.MergeWith + 0001:000515AC TMenuItem.Notification + 0001:0004F130 TMenuItem.PopulateMenu + 0001:0004F1A0 TMenuItem.ReadShortCutText + 0001:0004F270 TMenuItem.RebuildHandle + 0001:00051070 TMenuItem.Remove + 0001:0005115C TMenuItem.SetAction + 0001:00051D60 TMenuItem.SetAutoHotkeys + 0001:00051EDC TMenuItem.SetAutoLineReduction + 0001:000511CC TMenuItem.SetBitmap + 0001:00050B30 TMenuItem.SetBreak + 0001:00050B40 TMenuItem.SetCaption + 0001:00050BB0 TMenuItem.SetChecked + 0001:00050DD8 TMenuItem.SetChildOrder + 0001:00050DF8 TMenuItem.SetDefault + 0001:00050C04 TMenuItem.SetEnabled + 0001:00050C7C TMenuItem.SetGroupIndex + 0001:00050D30 TMenuItem.SetImageIndex + 0001:00050D58 TMenuItem.SetMenuIndex + 0001:00051240 TMenuItem.SetParentComponent + 0001:000512A4 TMenuItem.SetRadioItem + 0001:00050D0C TMenuItem.SetShortCut + 0001:00051600 TMenuItem.SetSubMenuImages + 0001:00050D20 TMenuItem.SetVisible + 0001:000510DC TMenuItem.SubItemChanged + 0001:00050B68 TMenuItem.TurnSiblingsOff + 0001:00051670 TMenuItem.UpdateItems + 0001:0004F340 TMenuItem.VerifyGroupIndex + 0001:000535D8 TMenuItemStack.ClearItem + 0001:0005C9B4 TMonitor.GetBoundsRect + 0001:0005C964 TMonitor.GetHeight + 0001:0005C94C TMonitor.GetLeft + 0001:0005C980 TMonitor.GetTop + 0001:0005C998 TMonitor.GetWidth + 0001:0004A188 TMouse.Create + 0001:0004A218 TMouse.Destroy + 0001:0004A248 TMouse.GetCapture + 0001:0004A250 TMouse.GetCursorPos + 0001:0004A260 TMouse.GetMouseData + 0001:0004A27C TMouse.GetNativeData + 0001:0004A2AC TMouse.GetRegisteredData + 0001:0004A2D4 TMouse.SetCapture + 0001:0004A2FC TMouse.SettingChanged + 0001:0000CE90 TMultiReadExclusiveWriteSynchronizer.BeginRead + 0001:0000CDA4 TMultiReadExclusiveWriteSynchronizer.BeginWrite + 0001:0000CD60 TMultiReadExclusiveWriteSynchronizer.BlockReaders + 0001:0000CCA4 TMultiReadExclusiveWriteSynchronizer.Create + 0001:0000CD18 TMultiReadExclusiveWriteSynchronizer.Destroy + 0001:0000CEEC TMultiReadExclusiveWriteSynchronizer.EndRead + 0001:0000CE40 TMultiReadExclusiveWriteSynchronizer.EndWrite + 0001:0000CD78 TMultiReadExclusiveWriteSynchronizer.UnblockOneWriter + 0001:0000CD6C TMultiReadExclusiveWriteSynchronizer.UnblockReaders + 0001:0000CD84 TMultiReadExclusiveWriteSynchronizer.WaitForReadSignal + 0001:0000CD94 TMultiReadExclusiveWriteSynchronizer.WaitForWriteSignal + 0001:00002B40 TObject.AfterConstruction + 0001:00002B44 TObject.BeforeDestruction + 0001:00002B2C TObject.ClassInfo + 0001:00002854 TObject.ClassName + 0001:00002868 TObject.ClassNameIs + 0001:00002890 TObject.ClassParent + 0001:0000284C TObject.ClassType + 0001:00002968 TObject.CleanupInstance + 0001:000028D4 TObject.Create + 0001:00002B3C TObject.DefaultHandler + 0001:000028F4 TObject.Destroy + 0001:00002B48 TObject.Dispatch + 0001:00002C00 TObject.FieldAddress + 0001:00002904 TObject.Free + 0001:000028B8 TObject.FreeInstance + 0001:000029B8 TObject.GetInterface + 0001:00002A4C TObject.GetInterfaceEntry + 0001:00002B18 TObject.InheritsFrom + 0001:00002910 TObject.InitInstance + 0001:000028CC TObject.InstanceSize + 0001:00002B70 TObject.MethodAddress + 0001:00002BC0 TObject.MethodName + 0001:0000289C TObject.NewInstance + 0001:00002B34 TObject.SafeCallException + 0001:0002BFC0 TObjectList.Create + 0001:0002BFFC TObjectList.GetItem + 0001:0002C010 TObjectList.Insert + 0001:0002C018 TObjectList.Notify + 0001:00004E88 ToLongPath + 0001:000679C4 ToolWin + 0001:0002C05C TOrderedList.Create + 0001:0002C0A0 TOrderedList.Destroy + 0001:0002C0D0 TOrderedList.PeekItem + 0001:0002C044 TOrderedList.Pop + 0001:0002C0E4 TOrderedList.PopItem + 0001:0002C04C TOrderedList.Push + 0001:0001C120 TOwnedCollection.Create + 0001:0001C164 TOwnedCollection.GetOwner + 0001:0006C8B8 TParaAttributes.Assign + 0001:0006C564 TParaAttributes.Create + 0001:0006C654 TParaAttributes.GetAlignment + 0001:0006C5BC TParaAttributes.GetAttributes + 0001:0006C728 TParaAttributes.GetFirstIndent + 0001:0006C784 TParaAttributes.GetLeftIndent + 0001:0006C6AC TParaAttributes.GetNumbering + 0001:0006C7E0 TParaAttributes.GetRightIndent + 0001:0006C83C TParaAttributes.GetTab + 0001:0006C5A0 TParaAttributes.InitPara + 0001:0006C670 TParaAttributes.SetAlignment + 0001:0006C5F0 TParaAttributes.SetAttributes + 0001:0006C748 TParaAttributes.SetFirstIndent + 0001:0006C7A4 TParaAttributes.SetLeftIndent + 0001:0006C6C4 TParaAttributes.SetNumbering + 0001:0006C800 TParaAttributes.SetRightIndent + 0001:0006C864 TParaAttributes.SetTab + 0001:0002BA14 TPatternManager.AllocPattern + 0001:0002B998 TPatternManager.Create + 0001:0002BAC8 TPatternManager.CreateBitmap + 0001:0002B9D0 TPatternManager.Destroy + 0001:0002BBC8 TPatternManager.FreePatterns + 0001:0002B9FC TPatternManager.Lock + 0001:0002BA08 TPatternManager.Unlock + 0001:00026844 TPen.Assign + 0001:000267D8 TPen.Create + 0001:0002681C TPen.Destroy + 0001:00026964 TPen.GetColor + 0001:000268FC TPen.GetData + 0001:00026994 TPen.GetHandle + 0001:00026A40 TPen.GetStyle + 0001:00026A70 TPen.GetWidth + 0001:0002696C TPen.SetColor + 0001:00026914 TPen.SetData + 0001:00026A2C TPen.SetMode + 0001:00026A48 TPen.SetStyle + 0001:00026A78 TPen.SetWidth + 0001:0001B694 TPersistent.Assign + 0001:0001B6A8 TPersistent.AssignError + 0001:0001B778 TPersistent.AssignTo + 0001:0001B780 TPersistent.DefineProperties + 0001:0001B668 TPersistent.Destroy + 0001:0001B784 TPersistent.GetNamePath + 0001:0001B834 TPersistent.GetOwner + 0001:00053380 TPopupList.Add + 0001:00052DF0 TPopupList.MainWndProc + 0001:000533A8 TPopupList.Remove + 0001:00052E3C TPopupList.WndProc + 0001:000533C4 TPopupMenu.Create + 0001:00053438 TPopupMenu.Destroy + 0001:0005346C TPopupMenu.DoPopup + 0001:00053480 TPopupMenu.GetHelpContext + 0001:00053524 TPopupMenu.Popup + 0001:00053490 TPopupMenu.SetBiDiModeFromPopupControl + 0001:00053488 TPopupMenu.SetHelpContext + 0001:000534D8 TPopupMenu.UseRightToLeftAlignment + 0001:0002E640 TPrinter.BeginDoc + 0001:0002E5D0 TPrinter.CheckPrinting + 0001:0002E3EC TPrinter.Create + 0001:0002E428 TPrinter.Destroy + 0001:0002E6C8 TPrinter.EndDoc + 0001:0002EEB0 TPrinter.FreeFonts + 0001:0002EE74 TPrinter.FreePrinters + 0001:0002E9B0 TPrinter.GetCanvas + 0001:0002E9D0 TPrinter.GetHandle + 0001:0002E9E4 TPrinter.GetPageHeight + 0001:0002EA00 TPrinter.GetPageWidth + 0001:0002EA1C TPrinter.GetPrinterIndex + 0001:0002EA34 TPrinter.GetPrinters + 0001:0002E6FC TPrinter.NewPage + 0001:0002E768 TPrinter.SetPrinter + 0001:0002E72C TPrinter.SetPrinterCapabilities + 0001:0002E4A4 TPrinter.SetState + 0001:0002EC74 TPrinter.SetToDefaultPrinter + 0001:0002E384 TPrinterCanvas.Changing + 0001:0002E324 TPrinterCanvas.Create + 0001:0002E360 TPrinterCanvas.CreateHandle + 0001:0002E3A4 TPrinterCanvas.UpdateFont + 0001:0002E150 TPrinterDevice.Create + 0001:0002E1B0 TPrinterDevice.IsEqual + 0001:0001E010 TPropFixup.Create + 0001:0001E068 TPropFixup.MakeGlobalReference + 0001:0001E0B0 TPropFixup.ResolveReference + 0001:0001E0C0 TPropIntfFixup.ResolveReference + 0001:00006628 TrackPopupMenu + 0001:0000B05C TranslateDateFormat + 0001:00006630 TranslateMDISysAccel + 0001:00006638 TranslateMessage + 0001:0000E7DC TranslateResult + 0001:000279E4 TransparentStretchBlt + 0001:0005C0B0 TraverseClients + 0001:0005BF68 TraverseClients + 0001:0005C1B0 TraverseClients + 0001:00044CD0 TraverseControls + 0001:0001E5F0 TReader.CheckValue + 0001:0001E648 TReader.DefineBinaryProperty + 0001:0001E614 TReader.DefineProperty + 0001:0001E5B4 TReader.Destroy + 0001:0001E83C TReader.DoFixupReferences + 0001:0001E724 TReader.EndOfList + 0001:0001E738 TReader.Error + 0001:000206CC TReader.FindAncestorComponent + 0001:000207C4 TReader.FindComponentClass + 0001:0001E758 TReader.FindMethod + 0001:0001E95C TReader.FlushBuffer + 0001:0001E980 TReader.FreeFixups + 0001:0001E9BC TReader.GetFieldClass + 0001:0001EA50 TReader.GetPosition + 0001:0001EA68 TReader.NextValue + 0001:0001EA78 TReader.PropertyError + 0001:0001EA8C TReader.Read + 0001:0001EB14 TReader.ReadBoolean + 0001:0001EAD8 TReader.ReadBuffer + 0001:0001EB28 TReader.ReadChar + 0001:0001EB80 TReader.ReadCollection + 0001:0001EF00 TReader.ReadComponent + 0001:0001F298 TReader.ReadCurrency + 0001:0001F0D8 TReader.ReadData + 0001:0001F148 TReader.ReadDataInner + 0001:0001F2E4 TReader.ReadDate + 0001:0001F218 TReader.ReadFloat + 0001:0001F324 TReader.ReadIdent + 0001:0001F490 TReader.ReadInt64 + 0001:0001F424 TReader.ReadInteger + 0001:0001F4D4 TReader.ReadListBegin + 0001:0001F4DC TReader.ReadListEnd + 0001:0001F4E4 TReader.ReadPrefix + 0001:0001F640 TReader.ReadProperty + 0001:0001F9C4 TReader.ReadPropValue + 0001:0001FD2C TReader.ReadRootComponent + 0001:00020074 TReader.ReadSet + 0001:00020130 TReader.ReadSignature + 0001:0001F258 TReader.ReadSingle + 0001:00020154 TReader.ReadStr + 0001:00020190 TReader.ReadString + 0001:00020330 TReader.ReadValue + 0001:00020A40 TReader.ReadVariant + 0001:0002024C TReader.ReadWideString + 0001:00020784 TReader.ReferenceName + 0001:0002079C TReader.SetName + 0001:00020838 TReader.SkipBytes + 0001:00020624 TReader.SkipComponent + 0001:000205DC TReader.SkipProperty + 0001:00020344 TReader.SkipSetBody + 0001:00020440 TReader.SkipValue + 0002:00000C64 TreeStreamEndFlag + 0001:00019B88 TRegGroup.AddClass + 0001:00019B94 TRegGroup.BestClass + 0001:00019BF4 TRegGroup.BestGroup + 0001:00019C64 TRegGroup.Create + 0001:00019CE0 TRegGroup.Destroy + 0001:00019D20 TRegGroup.GetClass + 0001:00019D80 TRegGroup.InGroup + 0001:00019DC4 TRegGroup.RegisterClass + 0001:00019E6C TRegGroup.Registered + 0001:00019EA4 TRegGroup.UnregisterModuleClasses + 0001:00019F48 TRegGroups.Activate + 0001:00019F94 TRegGroups.Create + 0001:0001A008 TRegGroups.Destroy + 0001:0001A064 TRegGroups.FindGroup + 0001:0001A0A8 TRegGroups.GetClass + 0001:0001A17C TRegGroups.GroupWith + 0001:0001A244 TRegGroups.Lock + 0001:0001A250 TRegGroups.RegisterClass + 0001:0001A268 TRegGroups.Registered + 0001:0001A2AC TRegGroups.StartGroup + 0001:0001A2FC TRegGroups.Unlock + 0001:0001A308 TRegGroups.UnregisterModuleClasses + 0001:000257F0 TResourceManager.AllocResource + 0001:000259FC TResourceManager.AssignResource + 0001:00025984 TResourceManager.ChangeResource + 0001:00025778 TResourceManager.Create + 0001:000257B4 TResourceManager.Destroy + 0001:000258D4 TResourceManager.FreeResource + 0001:000257D8 TResourceManager.Lock + 0001:000257E4 TResourceManager.Unlock + 0001:0001DD40 TResourceStream.Create + 0001:0001DE74 TResourceStream.Destroy + 0001:0001DE08 TResourceStream.Initialize + 0001:0001DEAC TResourceStream.Write + 0001:0006CAB8 TRichEditStrings.AddStrings + 0001:0006CEA0 TRichEditStrings.Clear + 0001:0006CDF4 TRichEditStrings.Delete + 0001:0006CA88 TRichEditStrings.Destroy + 0001:0006CF00 TRichEditStrings.EnableChange + 0001:0006CB88 TRichEditStrings.Get + 0001:0006CB30 TRichEditStrings.GetCount + 0001:0006CC68 TRichEditStrings.Insert + 0001:0006D3A8 TRichEditStrings.LoadFromFile + 0001:0006D134 TRichEditStrings.LoadFromStream + 0001:0006CBDC TRichEditStrings.Put + 0001:0006D4B0 TRichEditStrings.SaveToFile + 0001:0006D298 TRichEditStrings.SaveToStream + 0001:0006CF5C TRichEditStrings.SetTextStr + 0001:0006CEB0 TRichEditStrings.SetUpdateState + 0001:00007AD0 Trim + 0001:0006686C TrimPunctuation + 0002:0000383C TrueBoolStrs + 0002:00001368 TRUE_STRINGS + 0001:00009470 TryEncodeDate + 0001:00009328 TryEncodeTime + 0001:00001080 TryHarder + 0001:0000206C TryOpenForInput + 0001:000022FC TryOpenForOutput + 0001:00007EEC TryStrToBool + 0001:000092C8 TryStrToCurr + 0001:0000AB7C TryStrToDate + 0001:0000AC4C TryStrToDateTime + 0001:0000929C TryStrToFloat + 0001:00009270 TryStrToFloat + 0001:00009254 TryStrToFloat + 0001:00007DE0 TryStrToInt + 0001:00007E00 TryStrToInt64 + 0001:0000ABE4 TryStrToTime + 0001:0005CD88 TScreen.AddDataModule + 0001:0005CD00 TScreen.AddForm + 0001:0005D810 TScreen.AlignForm + 0001:0005D788 TScreen.AlignForms + 0001:0005C9E4 TScreen.Create + 0001:0005CDA0 TScreen.CreateCursors + 0001:0005CE58 TScreen.DeleteCursor + 0001:0005CB3C TScreen.Destroy + 0001:0005CDFC TScreen.DestroyCursors + 0001:0005D3A4 TScreen.DisableAlign + 0001:0005D3AC TScreen.EnableAlign + 0001:0005D150 TScreen.GetCursors + 0001:0005CCAC TScreen.GetCustomFormCount + 0001:0005CC98 TScreen.GetCustomForms + 0001:0005D134 TScreen.GetDataModule + 0001:0005D148 TScreen.GetDataModuleCount + 0001:0005D0C8 TScreen.GetDefaultIME + 0001:0005CC34 TScreen.GetDesktopHeight + 0001:0005CC28 TScreen.GetDesktopLeft + 0001:0005CC1C TScreen.GetDesktopTop + 0001:0005CC40 TScreen.GetDesktopWidth + 0001:0005CC7C TScreen.GetForm + 0001:0005CC90 TScreen.GetFormCount + 0001:0005CC04 TScreen.GetHeight + 0001:0005CEC8 TScreen.GetImes + 0001:0005D250 TScreen.GetMetricSettings + 0001:0005CC4C TScreen.GetMonitor + 0001:0005CC60 TScreen.GetMonitorCount + 0001:0005CC10 TScreen.GetWidth + 0001:0005D0E4 TScreen.IconFontChanged + 0001:0005CEA0 TScreen.InsertCursor + 0001:0005D3CC TScreen.Realign + 0001:0005CD94 TScreen.RemoveDataModule + 0001:0005CD38 TScreen.RemoveForm + 0001:0005D898 TScreen.ResetFonts + 0001:0005D178 TScreen.SetCursor + 0001:0005D208 TScreen.SetCursors + 0001:0005CCB4 TScreen.UpdateLastActive + 0001:000579AC TScrollBox.CMCtl3DChanged + 0001:000578D4 TScrollBox.Create + 0001:00057934 TScrollBox.CreateParams + 0001:00057984 TScrollBox.SetBorderStyle + 0001:00057998 TScrollBox.WMNCHitTest + 0001:000577D4 TScrollingWinControl.AdjustClientRect + 0001:000571A8 TScrollingWinControl.AlignControls + 0001:000571C8 TScrollingWinControl.AutoScrollEnabled + 0001:00057478 TScrollingWinControl.AutoScrollInView + 0001:00057300 TScrollingWinControl.CalcAutoRange + 0001:00057688 TScrollingWinControl.ChangeScale + 0001:00057844 TScrollingWinControl.CMBiDiModeChanged + 0001:000570B4 TScrollingWinControl.Create + 0001:00057158 TScrollingWinControl.CreateParams + 0001:00057168 TScrollingWinControl.CreateWnd + 0001:0005711C TScrollingWinControl.Destroy + 0001:000571E8 TScrollingWinControl.DoFlipChildren + 0001:000576AC TScrollingWinControl.Resizing + 0001:000575E4 TScrollingWinControl.ScaleScrollBars + 0001:00057490 TScrollingWinControl.ScrollInView + 0001:00057324 TScrollingWinControl.SetAutoScroll + 0001:00057360 TScrollingWinControl.SetHorzScrollBar + 0001:00057370 TScrollingWinControl.SetVertScrollBar + 0001:00057380 TScrollingWinControl.UpdateScrollBars + 0001:0005778C TScrollingWinControl.WMHScroll + 0001:000576B0 TScrollingWinControl.WMSize + 0001:000577B0 TScrollingWinControl.WMVScroll + 0001:00064A8C TServerAcceptThread.Create + 0001:00064AD0 TServerAcceptThread.Execute + 0001:00064DC8 TServerClientThread.ClientExecute + 0001:00064AEC TServerClientThread.Create + 0001:00064B64 TServerClientThread.Destroy + 0001:00064BD8 TServerClientThread.DoHandleException + 0001:00064C24 TServerClientThread.DoRead + 0001:00064C40 TServerClientThread.DoTerminate + 0001:00064C5C TServerClientThread.DoWrite + 0001:00064E94 TServerClientThread.EndConnect + 0001:00064CA4 TServerClientThread.Error + 0001:00064C94 TServerClientThread.Event + 0001:00064D20 TServerClientThread.Execute + 0001:00064C80 TServerClientThread.HandleError + 0001:00064C70 TServerClientThread.HandleEvent + 0001:00064CB8 TServerClientThread.HandleException + 0001:00064B9C TServerClientThread.ReActivate + 0001:00064E70 TServerClientThread.StartConnect + 0001:00064188 TServerClientWinSocket.Create + 0001:00064234 TServerClientWinSocket.Destroy + 0001:000655AC TServerSocket.Create + 0001:00064518 TServerWinSocket.Accept + 0001:0006431C TServerWinSocket.AddClient + 0001:000643D8 TServerWinSocket.AddThread + 0001:000649D0 TServerWinSocket.ClientConnect + 0001:000649F0 TServerWinSocket.ClientDisconnect + 0001:000644FC TServerWinSocket.ClientError + 0001:00064A60 TServerWinSocket.ClientErrorEvent + 0001:000644A8 TServerWinSocket.ClientEvent + 0001:00064A20 TServerWinSocket.ClientRead + 0001:00064A40 TServerWinSocket.ClientWrite + 0001:00064268 TServerWinSocket.Create + 0001:000642DC TServerWinSocket.Destroy + 0001:0006461C TServerWinSocket.Disconnect + 0001:00064734 TServerWinSocket.DoCreateThread + 0001:0006487C TServerWinSocket.GetClientSocket + 0001:000648FC TServerWinSocket.GetServerThread + 0001:00064744 TServerWinSocket.Listen + 0001:00064384 TServerWinSocket.RemoveClient + 0001:00064454 TServerWinSocket.RemoveThread + 0001:00064790 TServerWinSocket.SetServerType + 0001:000647E0 TServerWinSocket.SetThreadCacheSize + 0001:000648BC TServerWinSocket.ThreadEnd + 0001:000648DC TServerWinSocket.ThreadStart + 0001:000290A8 TSharedImage.Reference + 0001:000290AC TSharedImage.Release + 0001:0004BC80 TShortCutList.Add + 0001:0004BCAC TShortCutList.IndexOfShortCut + 0001:00061F60 TSimpleEvent.Create + 0001:0003C820 TSiteList.AddSite + 0001:0003C87C TSiteList.Clear + 0001:0003C7C4 TSiteList.Find + 0001:0003C8B0 TSiteList.GetTopSite + 0001:0003E190 TSizeConstraints.AssignTo + 0001:0003E264 TSizeConstraints.Change + 0001:0003E154 TSizeConstraints.Create + 0001:0003E1D8 TSizeConstraints.SetConstraints + 0001:0002C104 TStack.PushItem + 0001:000692D0 TStaticListAction.Create + 0001:00069330 TStaticListAction.Destroy + 0001:00069360 TStaticListAction.GetCount + 0001:0006936C TStaticListAction.GetItem + 0001:000693D0 TStaticListAction.GetItemClass + 0001:000693D8 TStaticListAction.GetString + 0001:000693FC TStaticListAction.SetListitems + 0001:0006940C TStaticListAction.SetString + 0001:00069004 TStaticListItems.Notify + 0001:000691B4 TStaticListItems.Update + 0001:0001D770 TStream.CopyFrom + 0001:0001D4D4 TStream.GetPosition + 0001:0001D508 TStream.GetSize + 0001:0001D700 TStream.ReadBuffer + 0001:0001D864 TStream.ReadComponent + 0001:0001D60C TStream.Seek + 0001:0001D690 TStream.Seek + 0001:0001D4F4 TStream.SetPosition + 0001:0001D56C TStream.SetSize + 0001:0001D554 TStream.SetSize + 0001:0001D558 TStream.SetSize64 + 0001:0001D738 TStream.WriteBuffer + 0001:0001D8C4 TStream.WriteComponent + 0001:0001D8D0 TStream.WriteDescendent + 0001:00024420 TStreamAdapter.Clone + 0001:00024374 TStreamAdapter.Commit + 0001:00024174 TStreamAdapter.CopyTo + 0001:00023F3C TStreamAdapter.Create + 0001:00023F84 TStreamAdapter.Destroy + 0001:0002438C TStreamAdapter.LockRegion + 0001:00023FBC TStreamAdapter.Read + 0001:00024380 TStreamAdapter.Revert + 0001:0002408C TStreamAdapter.Seek + 0001:00024110 TStreamAdapter.SetSize + 0001:000243A4 TStreamAdapter.Stat + 0001:00024398 TStreamAdapter.UnlockRegion + 0001:00024024 TStreamAdapter.Write + 0001:0001CEDC TStringList.Add + 0001:0001CEE8 TStringList.AddObject + 0001:0001CF4C TStringList.Changed + 0001:0001CF68 TStringList.Changing + 0001:0001CF84 TStringList.Clear + 0001:0001D4B8 TStringList.CompareStrings + 0001:0001D480 TStringList.CustomSort + 0001:0001CFC4 TStringList.Delete + 0001:0001CE80 TStringList.Destroy + 0001:0001D030 TStringList.Exchange + 0001:0001D08C TStringList.ExchangeItems + 0001:0001D0B0 TStringList.Find + 0001:0001D128 TStringList.Get + 0001:0001D15C TStringList.GetCapacity + 0001:0001D160 TStringList.GetCount + 0001:0001D164 TStringList.GetObject + 0001:0001D18C TStringList.Grow + 0001:0001D1C0 TStringList.IndexOf + 0001:0001D1FC TStringList.Insert + 0001:0001D260 TStringList.InsertItem + 0001:0001D20C TStringList.InsertObject + 0001:0001D2D8 TStringList.Put + 0001:0001D334 TStringList.PutObject + 0001:0001D374 TStringList.QuickSort + 0001:0001D408 TStringList.SetCapacity + 0001:0001D424 TStringList.SetSorted + 0001:0001D444 TStringList.SetUpdateState + 0001:0001D470 TStringList.Sort + 0001:0001C198 TStrings.Add + 0001:0001C1BC TStrings.AddObject + 0001:0001C1E0 TStrings.AddStrings + 0001:0001C298 TStrings.Assign + 0001:0001C328 TStrings.BeginUpdate + 0001:0001CE74 TStrings.CompareStrings + 0001:0001C398 TStrings.DefineProperties + 0001:0001C168 TStrings.Destroy + 0001:0001C3E4 TStrings.EndUpdate + 0001:0001C3F8 TStrings.Equals + 0001:0001C4A4 TStrings.Error + 0001:0001C4DC TStrings.Error + 0001:0001C534 TStrings.Exchange + 0001:0001C61C TStrings.GetCapacity + 0001:0001C624 TStrings.GetObject + 0001:0001C628 TStrings.GetText + 0001:0001C67C TStrings.GetTextStr + 0001:0001C7A4 TStrings.IndexOf + 0001:0001C830 TStrings.IndexOfName + 0001:0001C8F8 TStrings.IndexOfObject + 0001:0001C92C TStrings.InsertObject + 0001:0001C95C TStrings.LoadFromFile + 0001:0001C9B0 TStrings.LoadFromStream + 0001:0001CA5C TStrings.Move + 0001:0001CB0C TStrings.Put + 0001:0001CB3C TStrings.PutObject + 0001:0001CB40 TStrings.ReadData + 0001:0001CBF0 TStrings.SaveToFile + 0001:0001CC48 TStrings.SaveToStream + 0001:0001CCA4 TStrings.SetCapacity + 0001:0001CCA8 TStrings.SetStringsAdapter + 0001:0001CCDC TStrings.SetText + 0001:0001CD2C TStrings.SetTextStr + 0001:0001CDEC TStrings.SetUpdateState + 0001:0001CDF0 TStrings.WriteData + 0001:0006EBC4 TSubItems.Add + 0001:0006EBEC TSubItems.AddObject + 0001:0006EC14 TSubItems.Clear + 0001:0006EB48 TSubItems.Create + 0001:0006EC28 TSubItems.Delete + 0001:0006EB94 TSubItems.Destroy + 0001:0006EC4C TSubItems.GetHandle + 0001:0006ED30 TSubItems.GetImageIndex + 0001:0006EC9C TSubItems.Insert + 0001:0006ECDC TSubItems.Put + 0001:0006ECF8 TSubItems.RefreshItem + 0001:0006EC58 TSubItems.SetColumnWidth + 0001:0006ED44 TSubItems.SetImageIndex + 0001:0006ED24 TSubItems.SetUpdateState + 0001:00061E70 TSynchroObject.Acquire + 0001:00061E74 TSynchroObject.Release + 0001:0006C2F4 TTextAttributes.Assign + 0001:0006C434 TTextAttributes.AssignTo + 0001:0006BF68 TTextAttributes.Create + 0001:0006BFCC TTextAttributes.GetAttributes + 0001:0006C048 TTextAttributes.GetCharset + 0001:0006C08C TTextAttributes.GetColor + 0001:0006C0F4 TTextAttributes.GetName + 0001:0006C284 TTextAttributes.GetPitch + 0001:0006C230 TTextAttributes.GetSize + 0001:0006C188 TTextAttributes.GetStyle + 0001:0006BFB0 TTextAttributes.InitFormat + 0001:0006C00C TTextAttributes.SetAttributes + 0001:0006C05C TTextAttributes.SetCharset + 0001:0006C0AC TTextAttributes.SetColor + 0001:0006C118 TTextAttributes.SetName + 0001:0006C2B4 TTextAttributes.SetPitch + 0001:0006C24C TTextAttributes.SetSize + 0001:0006C1D8 TTextAttributes.SetStyle + 0001:00023158 TThread.AfterConstruction + 0001:000231F8 TThread.CallOnTerminate + 0001:000231E0 TThread.CheckThreadError + 0001:00023164 TThread.CheckThreadError + 0001:00023020 TThread.Create + 0001:000230F0 TThread.Destroy + 0001:0002320C TThread.DoTerminate + 0001:00023388 TThread.Resume + 0001:00023220 TThread.SetPriority + 0001:0002324C TThread.Synchronize + 0001:000233B0 TThread.Terminate + 0001:000233B8 TThread.WaitFor + 0001:0001B3D4 TThreadList.Add + 0001:0001B304 TThreadList.Create + 0001:0001B358 TThreadList.Destroy + 0001:0001B45C TThreadList.LockList + 0001:0001B470 TThreadList.Remove + 0001:0001B4C0 TThreadList.UnlockList + 0001:0000CC54 TThreadLocalCounter2.Delete + 0001:0000CB74 TThreadLocalCounter2.Destroy + 0001:0000CBC4 TThreadLocalCounter2.HashIndex + 0001:0000CBDC TThreadLocalCounter2.Open + 0001:0000CC64 TThreadLocalCounter2.Recycle + 0001:00038084 TTimer.Create + 0001:000380D4 TTimer.Destroy + 0001:0003820C TTimer.SetEnabled + 0001:0003821C TTimer.SetInterval + 0001:0003822C TTimer.SetOnTimer + 0001:00038244 TTimer.Timer + 0001:00038180 TTimer.UpdateTimer + 0001:0003810C TTimer.WndProc + 0001:00068FB4 TVirtualListAction.GetItem + 0001:000466CC TWinControl.ActionChange + 0001:00042B78 TWinControl.AddBiDiModeExStyle + 0001:00041DC0 TWinControl.AdjustClientRect + 0001:00045CDC TWinControl.AdjustSize + 0001:00042558 TWinControl.AlignControl + 0001:00042454 TWinControl.AlignControls + 0001:00046714 TWinControl.AssignTo + 0001:00042AA4 TWinControl.Broadcast + 0001:000462B4 TWinControl.CalcConstraints + 0001:00046744 TWinControl.CanAutoSize + 0001:00045B3C TWinControl.CanFocus + 0001:00046228 TWinControl.CanResize + 0001:00045748 TWinControl.ChangeScale + 0001:00044FC4 TWinControl.CMBiDiModeChanged + 0001:00045220 TWinControl.CMBorderChanged + 0001:0004509C TWinControl.CMChanged + 0001:000450B0 TWinControl.CMChildKey + 0001:0004517C TWinControl.CMColorChanged + 0001:0004535C TWinControl.CMControlListChange + 0001:00045260 TWinControl.CMCtl3DChanged + 0001:000451E0 TWinControl.CMCursorChanged + 0001:0004507C TWinControl.CMDesignHitTest + 0001:000450CC TWinControl.CMDialogChar + 0001:000450C4 TWinControl.CMDialogKey + 0001:000448F4 TWinControl.CMDockClient + 0001:00045300 TWinControl.CMDrag + 0001:00045134 TWinControl.CMEnabledChanged + 0001:00044FFC TWinControl.CMEnter + 0001:00045070 TWinControl.CMExit + 0001:00044A08 TWinControl.CMFloat + 0001:000450D4 TWinControl.CMFocusChanged + 0001:000452F0 TWinControl.CMFontChange + 0001:000451A4 TWinControl.CMFontChanged + 0001:00045A80 TWinControl.CMInvalidate + 0001:000452A0 TWinControl.CMParentCtl3DChanged + 0001:000432D8 TWinControl.CMRecreateWnd + 0001:00044FAC TWinControl.CMShowHintChanged + 0001:0004510C TWinControl.CMShowingChanged + 0001:000452E0 TWinControl.CMSysColorChange + 0001:00045370 TWinControl.CMSysFontChanged + 0001:000452F8 TWinControl.CMTimeChange + 0001:000449E0 TWinControl.CMUnDockClient + 0001:000450DC TWinControl.CMVisibleChanged + 0001:000452E8 TWinControl.CMWinIniChange + 0001:0004554C TWinControl.CNChar + 0001:00045420 TWinControl.CNKeyDown + 0001:000454F8 TWinControl.CNKeyUp + 0001:000455F4 TWinControl.CNSysChar + 0001:00045598 TWinControl.CNSysKeyDown + 0001:00046690 TWinControl.ConstrainedResize + 0001:00042830 TWinControl.ContainsControl + 0001:00043584 TWinControl.ControlAtPos + 0001:000447CC TWinControl.ControlsAligned + 0001:00041A80 TWinControl.Create + 0001:000447D0 TWinControl.CreateDockManager + 0001:000431C0 TWinControl.CreateHandle + 0001:00042BE0 TWinControl.CreateParams + 0001:00042B0C TWinControl.CreateSubClass + 0001:00042EA4 TWinControl.CreateWindowHandle + 0001:00042D0C TWinControl.CreateWnd + 0001:00043258 TWinControl.CustomAlignInsertBefore + 0001:0004325C TWinControl.CustomAlignPosition + 0001:00043810 TWinControl.DefaultHandler + 0001:00043060 TWinControl.DefineProperties + 0001:00041BA4 TWinControl.Destroy + 0001:00043278 TWinControl.DestroyHandle + 0001:00043114 TWinControl.DestroyWindowHandle + 0001:000430BC TWinControl.DestroyWnd + 0001:000425EC TWinControl.DisableAlign + 0001:00044568 TWinControl.DoAddDockClient + 0001:000445BC TWinControl.DockDrop + 0001:00044640 TWinControl.DockOver + 0001:0004460C TWinControl.DoDockOver + 0001:0004457C TWinControl.DoEnter + 0001:0004459C TWinControl.DoExit + 0001:0004261C TWinControl.DoFlipChildren + 0001:00044AB4 TWinControl.DoKeyDown + 0001:00044C4C TWinControl.DoKeyPress + 0001:00044B84 TWinControl.DoKeyUp + 0001:00044578 TWinControl.DoRemoveDockClient + 0001:00044680 TWinControl.DoUnDock + 0001:000425F4 TWinControl.EnableAlign + 0001:00046024 TWinControl.FindNextControl + 0001:00041C74 TWinControl.FixupTabList + 0001:000426F0 TWinControl.FlipChildren + 0001:00045BB4 TWinControl.Focused + 0001:0004670C TWinControl.GetActionLinkClass + 0001:000461A0 TWinControl.GetChildren + 0001:00045CA4 TWinControl.GetClientOrigin + 0001:00045CC4 TWinControl.GetClientRect + 0001:00042A48 TWinControl.GetControl + 0001:00042A84 TWinControl.GetControlCount + 0001:00045C10 TWinControl.GetControlExtents + 0001:00045A1C TWinControl.GetDeviceContext + 0001:000446FC TWinControl.GetDockClientCount + 0001:00044710 TWinControl.GetDockClients + 0001:00045BFC TWinControl.GetHandle + 0001:00044734 TWinControl.GetSiteInfo + 0001:00045D98 TWinControl.GetTabOrder + 0001:00045FC4 TWinControl.GetTabOrderList + 0001:00044790 TWinControl.GetVisibleDockClientCount + 0001:00045F00 TWinControl.HandleAllocated + 0001:00045BD8 TWinControl.HandleNeeded + 0001:00042864 TWinControl.Insert + 0001:000428F8 TWinControl.InsertControl + 0001:00045A70 TWinControl.Invalidate + 0001:00045B04 TWinControl.InvalidateFrame + 0001:00043618 TWinControl.IsControlMouseMsg + 0001:00045D60 TWinControl.IsCtl3DStored + 0001:0004538C TWinControl.IsMenuKey + 0001:00044A8C TWinControl.KeyDown + 0001:00044C2C TWinControl.KeyPress + 0001:00044B5C TWinControl.KeyUp + 0001:00043454 TWinControl.MainWndProc + 0001:00042AE4 TWinControl.NotifyControls + 0001:00043AA8 TWinControl.PaintControls + 0001:0004394C TWinControl.PaintHandler + 0001:00043CD8 TWinControl.PaintTo + 0001:00043A7C TWinControl.PaintWindow + 0001:00044F10 TWinControl.PaletteChanged + 0001:00043178 TWinControl.PrecedingWindow + 0001:00042EE8 TWinControl.ReadDesignSize + 0001:00041D48 TWinControl.ReadState + 0001:00042614 TWinControl.Realign + 0001:000432C0 TWinControl.RecreateWnd + 0001:000446D8 TWinControl.ReloadDockedControl + 0001:000428B0 TWinControl.Remove + 0001:000429CC TWinControl.RemoveControl + 0001:00042844 TWinControl.RemoveFocus + 0001:00045AEC TWinControl.Repaint + 0001:000444D0 TWinControl.ResetIme + 0001:00045700 TWinControl.ScaleControls + 0001:000457F4 TWinControl.ScrollBy + 0001:0004615C TWinControl.SelectFirst + 0001:00046130 TWinControl.SelectNext + 0001:00046910 TWinControl.SetBevelCut + 0001:00046954 TWinControl.SetBevelEdges + 0001:00046984 TWinControl.SetBevelKind + 0001:000469A4 TWinControl.SetBevelWidth + 0001:00045D1C TWinControl.SetBorderWidth + 0001:00045628 TWinControl.SetBounds + 0001:000461E8 TWinControl.SetChildOrder + 0001:00045D3C TWinControl.SetCtl3D + 0001:0004483C TWinControl.SetDockSite + 0001:00045B7C TWinControl.SetFocus + 0001:000443E4 TWinControl.SetIme + 0001:00045D6C TWinControl.SetParentCtl3D + 0001:00045E18 TWinControl.SetTabOrder + 0001:00045E30 TWinControl.SetTabStop + 0001:00045E90 TWinControl.SetUseDockManager + 0001:000459BC TWinControl.SetZOrder + 0001:000458E4 TWinControl.SetZOrderPosition + 0001:000458CC TWinControl.ShowControl + 0001:00045AD0 TWinControl.Update + 0001:00045F0C TWinControl.UpdateBounds + 0001:00043414 TWinControl.UpdateControlState + 0001:00043318 TWinControl.UpdateShowing + 0001:00045DBC TWinControl.UpdateTabOrder + 0001:00044CB0 TWinControl.WMChar + 0001:00044E28 TWinControl.WMCharToItem + 0001:00043F8C TWinControl.WMCommand + 0001:00044060 TWinControl.WMCompareItem + 0001:00046CD4 TWinControl.WMContextMenu + 0001:00044084 TWinControl.WMDeleteItem + 0001:00044E9C TWinControl.WMDestroy + 0001:000440A8 TWinControl.WMDrawItem + 0001:000440F0 TWinControl.WMEraseBkgnd + 0001:00044000 TWinControl.WMFontChange + 0001:00044020 TWinControl.WMHScroll + 0001:000443D0 TWinControl.WMIMEEndComp + 0001:000443BC TWinControl.WMIMEStartComp + 0001:00044B1C TWinControl.WMKeyDown + 0001:00044BEC TWinControl.WMKeyUp + 0001:000443A8 TWinControl.WMKillFocus + 0001:000440CC TWinControl.WMMeasureItem + 0001:00044280 TWinControl.WMMove + 0001:000469C4 TWinControl.WMNCCalcSize + 0001:00044ED0 TWinControl.WMNCDestroy + 0001:00044EEC TWinControl.WMNCHitTest + 0001:00046A54 TWinControl.WMNCPaint + 0001:00043FAC TWinControl.WMNotify + 0001:00043E2C TWinControl.WMPaint + 0001:00044F8C TWinControl.WMPaletteChanged + 0001:00044E48 TWinControl.WMParentNotify + 0001:00044F68 TWinControl.WMQueryNewPalette + 0001:00044294 TWinControl.WMSetCursor + 0001:00044394 TWinControl.WMSetFocus + 0001:0004424C TWinControl.WMSize + 0001:00043FD0 TWinControl.WMSysColorChange + 0001:00044D80 TWinControl.WMSysCommand + 0001:00044B3C TWinControl.WMSysKeyDown + 0001:00044C0C TWinControl.WMSysKeyUp + 0001:00044010 TWinControl.WMTimeChange + 0001:00044E7C TWinControl.WMVKeyToItem + 0001:00044040 TWinControl.WMVScroll + 0001:0004413C TWinControl.WMWindowPosChanged + 0001:000441FC TWinControl.WMWindowPosChanging + 0001:00043FEC TWinControl.WMWinIniChange + 0001:000436AC TWinControl.WndProc + 0001:00042F20 TWinControl.WriteDesignSize + 0001:00041A4C TWinControlActionLink.AssignClient + 0001:00041A70 TWinControlActionLink.IsHelpContextLinked + 0001:00041A78 TWinControlActionLink.SetHelpContext + 0001:00039ADC TWinHelpViewer.CallWinHelp + 0001:00039654 TWinHelpViewer.CanShowTableOfContents + 0001:00039D4C TWinHelpViewer.CouldBeUnstableWindow + 0001:00039430 TWinHelpViewer.Create + 0001:00039E50 TWinHelpViewer.Destroy + 0001:00039A4C TWinHelpViewer.DisplayHelpByContext + 0001:000398C4 TWinHelpViewer.DisplayTopic + 0001:000395B0 TWinHelpViewer.GetHelpStrings + 0001:00039524 TWinHelpViewer.GetViewerName + 0001:00039468 TWinHelpViewer.HelpFile + 0001:000394F8 TWinHelpViewer.InternalShutDown + 0001:00039D48 TWinHelpViewer.IsBusyWindow + 0001:00039CBC TWinHelpViewer.IsNewQuery + 0001:00039D6C TWinHelpViewer.MakeWinHelpHappy + 0001:0003980C TWinHelpViewer.NotifyID + 0001:00039DC4 TWinHelpViewer.RestartWinHelp + 0001:000396E0 TWinHelpViewer.ShowHelp + 0001:00039658 TWinHelpViewer.ShowTableOfContents + 0001:0003982C TWinHelpViewer.ShutDown + 0001:00039810 TWinHelpViewer.SoftShutDown + 0001:000399D8 TWinHelpViewer.UnderstandsContext + 0001:00039538 TWinHelpViewer.UnderstandsKeyword + 0001:0003985C TWinHelpViewer.UnderstandsTopic + 0001:00028028 TwoBitsFromDIB + 0002:000000C0 TwoDigitYearCenturyWindow + 0001:0006E8C0 TWorkArea.Create + 0001:0006E904 TWorkArea.GetDisplayName + 0001:0006E918 TWorkArea.SetDisplayName + 0001:0006EA20 TWorkAreas.GetItem + 0001:0006E958 TWorkAreas.Update + 0001:00020C78 TWriter.AddAncestor + 0001:00020CAC TWriter.DefineBinaryProperty + 0001:00020C84 TWriter.DefineProperty + 0001:00020C4C TWriter.Destroy + 0001:00020CE8 TWriter.FlushBuffer + 0001:00020CD8 TWriter.GetPosition + 0001:00020CF0 TWriter.SetPosition + 0001:00020D2C TWriter.SetRoot + 0001:00020D44 TWriter.Write + 0001:00020D90 TWriter.WriteBinary + 0001:00020E30 TWriter.WriteBoolean + 0001:00020E18 TWriter.WriteBuffer + 0001:00020E44 TWriter.WriteChar + 0001:00020E94 TWriter.WriteCollection + 0001:00020F84 TWriter.WriteComponent + 0001:000214D0 TWriter.WriteCurrency + 0001:00021060 TWriter.WriteData + 0001:000214F4 TWriter.WriteDate + 0001:00021460 TWriter.WriteDescendent + 0001:00021488 TWriter.WriteFloat + 0001:00021518 TWriter.WriteIdent + 0001:000215DC TWriter.WriteInteger + 0001:00021650 TWriter.WriteInteger + 0001:000216A8 TWriter.WriteListBegin + 0001:000216B0 TWriter.WriteListEnd + 0001:00022B60 TWriter.WriteMinStr + 0001:000216B8 TWriter.WritePrefix + 0001:000216FC TWriter.WriteProperties + 0001:000225A4 TWriter.WriteProperty + 0001:00022AB4 TWriter.WritePropName + 0001:00022B08 TWriter.WriteSignature + 0001:000214AC TWriter.WriteSingle + 0001:00022B18 TWriter.WriteStr + 0001:00022BF8 TWriter.WriteString + 0001:00022D00 TWriter.WriteValue + 0001:000226BC TWriter.WriteVariant + 0001:00022C4C TWriter.WriteWideString + 0002:00004450 TypeList + 0001:00005C88 Types + 0001:000180FC TypInfo + 0001:00000288 UnhandledExceptionFilter + 0001:0005DA64 UnhookHintHooks + 0001:00006640 UnhookWindowsHookEx + 0001:00005528 UnicodeToUtf8 + 0001:00000B4C UninitAllocator + 0001:0004E84C UniqueCommand + 0001:00003BF8 UniqueString + 0001:0000D5CC UniUnimplemented + 0001:00076B84 UnloadKernel32Dll + 0001:000753E4 UnloadModule + 0001:00075810 UnloadSystemResourcesMeterLib + 0001:00006688 UnlockResource + 0001:00006148 UnrealizeObject + 0001:00006648 UnregisterClass + 0001:0001AA38 UnregisterFindGlobalComponentProc + 0001:000053AC UnregisterModule + 0001:0001A678 UnRegisterModuleClasses + 0001:000032DC UnsetExceptionHandler + 0001:00001AC4 UpCase + 0001:00070744 UpdateColumnOrder + 0001:00029174 UpdateDIBColorTable + 0001:00041354 UpdateFloatingDockSitePos + 0001:00051648 UpdateItem + 0001:00052054 UpdateItem + 0001:00056E94 UpdateScrollProperties + 0001:00006650 UpdateWindow + 0001:00007880 UpperCase + 0001:00037370 UrlMon + 0002:00003EC8 UrlMonHandle + 0002:00003ECC UrlMonInitialized + 0002:00003B20 User32Dll + 0001:000057F4 UTF8Decode + 0001:00005748 UTF8Encode + 0001:00005604 Utf8ToUnicode + 0002:00000684 UtilWindowClass + 0001:0005FF34 ValidateHintWindow + 0001:0003CEC0 ValidDockTarget + 0002:00000C9C ValidMenuHotkeys + 0001:000564B0 ValidParentForm + 0002:0000132C Values + 0002:00000EAC Values + 0001:0000EBBC VarArrayClear + 0001:0000EF58 VarArrayCopyForEach + 0001:00015E0C VarArrayCreate + 0001:0000E788 VarArrayCreateError + 0001:00015F34 VarArrayDimCount + 0001:000160FC VarArrayGet + 0001:00015F80 VarArrayHighBound + 0001:00015F5C VarArrayLowBound + 0001:00016268 VarArrayPut + 0001:0000DAEC VarBoolFromStr + 0001:0000DB6C VarBstrFromBool + 0001:0000DB0C VarBstrFromCy + 0001:0000DB3C VarBstrFromDate + 0001:0000F494 VarCastAsAny + 0001:0000F598 VarCastAsDispatch + 0001:0000F5E4 VarCastAsInterface + 0001:0000F500 VarCastAsOleStr + 0001:0000F54C VarCastAsString + 0001:0000E5A8 VarCastError + 0001:0000E554 VarCastError + 0001:0000F6A8 VarCastRare + 0001:0000F630 VarCastViaOS + 0001:0000ED38 VarClearDeep + 0001:00015040 VarCompare + 0001:0001475C VarCompareAny + 0001:00014C20 VarCompareRare + 0001:00014A88 VarCompareSimple + 0001:0000F280 VarCopyByRef + 0001:0000F124 VarCopyCopyProc + 0001:0000F12C VarCopyDeep + 0001:0000F244 VarCopyNoIndCopyProc + 0001:0000F24C VarCopyNoIndDeep + 0001:0000F23C VarCopyNoIndOleStr + 0001:0000F21C VarCopyNoIndViaOS + 0001:0000DACC VarCyFromStr + 0001:0000DAAC VarDateFromStr + 0001:000670CC VarDispInvoke + 0002:000038C0 VarDispProc + 0001:0000DA6C VarI4FromStr + 0001:0000D594 VariantChangeType + 0001:0000DA18 VariantChangeTypeEx + 0001:0000D57C VariantClear + 0001:0000D584 VariantCopy + 0001:0000D58C VariantCopyInd + 0001:0000D574 VariantInit + 0002:00003660 VariantManager + 0001:00016FBC Variants + 0001:00004530 VariantSystemDefaultVarClear + 0001:00004528 VariantSystemUndefinedError + 0001:0000E698 VarInvalidNullOp + 0001:0000E644 VarInvalidOp + 0001:00015FAC VarIsArray + 0001:00015FA4 VarIsArray + 0001:00015BE8 VarIsClear + 0001:00015C68 VarIsNull + 0001:0000DA3C VarNeg + 0001:0000DA54 VarNot + 0001:0001395C VarOpRare + 0001:0000E6EC VarOverflowError + 0001:0000DA8C VarR8FromStr + 0001:0000EA04 VarResultCheck + 0001:0000EA10 VarResultCheck + 0001:00015CC0 VarSameValue + 0001:000138A8 VarStrCat + 0001:0000F48C VarStringToOleStr + 0001:00010AE0 VarToBoolAny + 0001:000109E0 VarToBoolAsString + 0001:00010B44 VarToBoolCustom + 0001:00010AA4 VarToBoolViaOS + 0001:00011CAC VarToCurrencyAny + 0001:00011C08 VarToCurrencyAsDouble + 0001:00011B50 VarToCurrencyAsString + 0001:00011D10 VarToCurrencyCustom + 0001:00011C64 VarToCurrencyViaOS + 0001:00011750 VarToDateAny + 0001:000116AC VarToDateAsDouble + 0001:000115C4 VarToDateAsString + 0001:000117B4 VarToDateCustom + 0001:00011708 VarToDateViaOS + 0001:00010FEC VarToDoubleAny + 0001:00010EE4 VarToDoubleAsString + 0001:00011050 VarToDoubleCustom + 0001:00010FA4 VarToDoubleViaOS + 0001:000104E4 VarToInt64Any + 0001:000103EC VarToInt64AsString + 0001:00010550 VarToInt64Custom + 0001:00010348 VarToInt64ViaOS + 0001:0000FA94 VarToIntAny + 0001:0000F9AC VarToIntAsString + 0001:0000FAF8 VarToIntCustom + 0001:0000FA5C VarToIntViaOS + 0001:00012318 VarToLStrAny + 0001:0001237C VarToLStrCustom + 0001:00012250 VarToLStrViaOS + 0001:00015C7C VarToStr + 0001:00015C94 VarToStrDef + 0001:00012A48 VarToWStrAny + 0001:00012AAC VarToWStrCustom + 0001:00012994 VarToWStrViaOS + 0001:00015BD4 VarType + 0001:00015A64 VarTypeAsText + 0001:00015C5C VarTypeIsCustom + 0001:00015FD4 VarTypeIsValidArrayType + 0001:00015FF4 VarTypeIsValidElementType + 0001:0000DF04 VarUtils + 0001:00007E20 VerifyBoolStrArray + 0001:00005F40 VerQueryValue + 0001:00075D00 VersionFixedFileInfo + 0002:00003BC0 ViewerName + 0002:0000144C ViewStyles + 0002:0000142C ViewStyles + 0001:00005EF8 VirtualAlloc + 0001:000003CC VirtualAlloc + 0001:000003D4 VirtualFree + 0001:00005F00 VirtualQuery + 0001:00000360 VirtualQuery + 0001:00005F08 WaitForSingleObject + 0001:00006658 WaitMessage + 0002:000005CC WakeMainThread + 0001:00003834 WCharFromChar + 0002:00001358 Week + 0002:000002F0 WesternGroups + 0001:000044D4 WideCharLenToStrVar + 0001:00000358 WideCharToMultiByte + 0002:000014C0 WideCRLF + 0002:000000B8 Win32BuildNumber + 0001:0000CA40 Win32Check + 0002:000000BC Win32CSDVersion + 0002:000000B0 Win32MajorVersion + 0002:000000B4 Win32MinorVersion + 0001:0004A5C8 Win32NLSEnableIME + 0002:000000AC Win32Platform + 0002:00003BD8 WindowAtom + 0002:00003BDC WindowAtomString + 0002:00000E7C WindowClass + 0001:00039BEC WindowEnumerationTester + 0001:00006668 WindowFromPoint + 0002:00000C0C WindowPos + 0001:00006884 Windows + 0001:0002879C WinError + 0001:00006660 WinHelp + 0002:00003BBC WinHelpTester + 0001:00039EE4 WinHelpViewer + 0001:00037338 WinInet + 0001:00061C78 WinSock + 0001:0002DF98 WinSpool + 0002:00000AD0 WndProcPtrAtom + 0002:00000A14 WordWraps + 0002:00001424 WrapText + 0001:0001AD88 WriteCollection + 0001:00021960 WriteCollectionProp + 0001:0006E358 WriteCols + 0001:000493FC WriteControlName + 0001:000034F8 WriteErrorMessage + 0001:00005F10 WriteFile + 0001:00000290 WriteFile + 0001:00021B8C WriteFloatProp + 0001:000287AC WriteIcon + 0001:00021C28 WriteInt64Prop + 0001:00022250 WriteInterfaceProp + 0001:000218F4 WriteIntProp + 0001:0006F818 WriteItems + 0001:000223F4 WriteMethodProp + 0001:00021F4C WriteObjectProp + 0001:00021A60 WriteOrdProp + 0001:00005F18 WritePrivateProfileString + 0001:0002180C WritePropPath + 0001:00021860 WriteSet + 0001:00021CF8 WriteStrProp + 0001:00022534 WriteVariantProp + 0001:00061C18 WSAAsyncGetHostByName + 0001:00061C20 WSAAsyncGetServByName + 0001:00061C10 WSAAsyncSelect + 0001:00061C28 WSACancelAsyncRequest + 0001:00061C40 WSACleanup + 0002:00003CA8 WSAData + 0001:00061C30 WSAGetLastError + 0001:00061C38 WSAStartup + 0001:00003DB8 WStrError + 0001:00003DD8 WStrSet + 0001:0002CC9C xEnumDisplayMonitors + 0001:0002CA20 xGetMonitorInfo + 0001:0002CAF4 xGetMonitorInfoA + 0001:0002CBC8 xGetMonitorInfoW + 0001:0002C988 xMonitorFromPoint + 0001:0002C860 xMonitorFromRect + 0001:0002C8F0 xMonitorFromWindow + 0002:0000134C Year + 0001:0000EDC8 _DispInvoke + 0001:0000EAC8 _DispInvokeError + 0002:00003B68 _FlatSB_GetScrollProp + 0002:00003B6C _FlatSB_SetScrollProp + 0001:0002C7D8 _GetSystemMetrics + 0002:00003C40 _ImmGetCompositionString + 0002:00003C24 _ImmGetContext + 0002:00003C2C _ImmGetConversionStatus + 0002:00003C44 _ImmIsIME + 0002:00003C48 _ImmNotifyIME + 0002:00003C28 _ImmReleaseContext + 0002:00003C3C _ImmSetCompositionFont + 0002:00003C38 _ImmSetCompositionWindow + 0002:00003C30 _ImmSetConversionStatus + 0002:00003C34 _ImmSetOpenStatus + 0002:00003AF8 _InitCommonControlsEx + 0002:00003B70 _InitializeFlatSB + 0001:00013334 _OleVarFromInt + 0001:0001364C _OleVarFromLStr + 0001:0001369C _OleVarFromPStr + 0001:00013758 _OleVarFromVar + 0002:00003B74 _UninitializeFlatSB + 0001:000158E0 _VarAddRef + 0001:00016030 _VarArrayGet + 0001:00016120 _VarArrayPut + 0001:00015EB4 _VarArrayRedim + 0001:0000F714 _VarCast + 0001:0000F940 _VarCastOle + 0001:0000EDB4 _VarClear + 0001:000150C0 _VarCmp + 0001:0000F1D8 _VarCopy + 0001:0000F458 _VarCopyNoInd + 0001:000134C8 _VarFromBool + 0001:00013354 _VarFromByte + 0001:00013518 _VarFromCurr + 0001:00013470 _VarFromCurrency + 0001:0001349C _VarFromDate + 0001:0001360C _VarFromDisp + 0001:00013444 _VarFromDouble + 0001:00013638 _VarFromDynArray + 0001:000132D4 _VarFromInt + 0001:000133F4 _VarFromInt64 + 0001:00013314 _VarFromInteger + 0001:000135E0 _VarFromIntf + 0001:00013394 _VarFromLongWord + 0001:0001352C _VarFromLStr + 0001:00013558 _VarFromPStr + 0001:000134F0 _VarFromReal + 0001:000133B4 _VarFromShortInt + 0001:00013420 _VarFromSingle + 0001:000133D4 _VarFromSmallInt + 0001:00013504 _VarFromTDateTime + 0001:00013374 _VarFromWord + 0001:000135A8 _VarFromWStr + 0001:000151B8 _VarNeg + 0001:00015660 _VarNot + 0001:0000EB1C _VarNull + 0001:000146CC _VarOp + 0001:0000F46C _VarStringToOleStr + 0001:00010B90 _VarToBool + 0001:00010ED8 _VarToBoolWithFix + 0001:0000FFE8 _VarToByte + 0001:00011D5C _VarToCurrency + 0001:00011800 _VarToDate + 0001:00013218 _VarToDisp + 0001:0001109C _VarToDouble + 0001:000132C4 _VarToDynArray + 0001:00011418 _VarToExtended + 0001:0001059C _VarToInt64 + 0001:0000FB3C _VarToInteger + 0001:0001314C _VarToIntf + 0001:00010260 _VarToLongWord + 0001:00012400 _VarToLStr + 0001:00012944 _VarToPStr + 0001:0000FF38 _VarToShortInt + 0001:00011434 _VarToSingle + 0001:00010090 _VarToSmallInt + 0001:00010188 _VarToWord + 0001:00012B74 _VarToWStr + 0002:00003C20 _WINNLSEnableIME + 0001:00015DC0 _Write0Variant + 0001:00015D5C _WriteVariant + + + Address Publics by Value + + 0002:FFB84014 TlsLast + 0001:00000238 CloseHandle + 0001:00000240 CreateFileA + 0001:00000248 GetFileType + 0001:00000250 GetFileSize + 0001:00000258 GetStdHandle + 0001:00000260 RaiseException + 0001:00000268 ReadFile + 0001:00000270 RtlUnwind + 0001:00000278 SetEndOfFile + 0001:00000280 SetFilePointer + 0001:00000288 UnhandledExceptionFilter + 0001:00000290 WriteFile + 0001:00000298 CharNext + 0001:000002A0 CreateThread + 0001:000002A8 ExitThread + 0001:000002B0 ExitProcess + 0001:000002B8 MessageBox + 0001:000002C0 FindClose + 0001:000002C8 FindFirstFile + 0001:000002D0 FreeLibrary + 0001:000002D8 GetCommandLine + 0001:000002E0 GetLastError + 0001:000002E8 GetLocaleInfo + 0001:000002F0 GetModuleFileName + 0001:000002F8 GetModuleHandle + 0001:00000300 GetProcAddress + 0001:00000308 GetStartupInfo + 0001:00000310 GetThreadLocale + 0001:00000318 LoadLibraryEx + 0001:00000320 LoadString + 0001:00000328 lstrcpyn + 0001:00000330 @strlen + 0001:00000338 MultiByteToWideChar + 0001:00000340 RegCloseKey + 0001:00000348 RegOpenKeyEx + 0001:00000350 RegQueryValueEx + 0001:00000358 WideCharToMultiByte + 0001:00000360 VirtualQuery + 0001:00000368 SysAllocStringLen + 0001:00000370 SysReAllocStringLen + 0001:00000378 SysFreeString + 0001:00000380 InterlockedIncrement + 0001:00000388 InterlockedDecrement + 0001:00000390 GetCurrentThreadId + 0001:00000398 GetCmdShow + 0001:000003BC LocalAlloc + 0001:000003C4 LocalFree + 0001:000003CC VirtualAlloc + 0001:000003D4 VirtualFree + 0001:000003DC InitializeCriticalSection + 0001:000003E4 EnterCriticalSection + 0001:000003EC LeaveCriticalSection + 0001:000003F4 DeleteCriticalSection + 0001:000003FC GetBlockDesc + 0001:0000044C MakeEmpty + 0001:00000454 AddBlockAfter + 0001:00000484 DeleteBlock + 0001:0000049C MergeBlockAfter + 0001:0000050C RemoveBlock + 0001:000005A0 GetSpace + 0001:00000604 GetSpaceAt + 0001:0000067C FreeSpace + 0001:00000734 Commit + 0001:000007C8 Decommit + 0001:00000848 GetCommitted + 0001:000008D8 GetCommittedAt + 0001:000009FC FreeCommitted + 0001:00000A88 InitAllocator + 0001:00000B4C UninitAllocator + 0001:00000C2C DeleteFree + 0001:00000C90 FindCommitted + 0001:00000CC0 FillBeforeGap + 0001:00000CF0 InternalFreeMem + 0001:00000D14 FillAfterGap + 0001:00000D3C FillerSizeBeforeGap + 0001:00000DAC FillerSizeAfterGap + 0001:00000DE4 DecommitFree + 0001:00000E94 InsertFree + 0001:00000F1C FreeCurAlloc + 0001:00000F68 MergeCommit + 0001:00000FF4 NewCommit + 0001:00001020 NewCommitAt + 0001:00001054 SearchSmallBlocks + 0001:00001080 TryHarder + 0001:00001174 SysGetMem + 0001:00001304 SysFreeMem + 0001:000014A8 ResizeInPlace + 0001:00001678 SysReallocMem + 0001:0000173C @GetMem + 0001:0000175C @FreeMem + 0001:0000177C @ReallocMem + 0001:000017CC ExceptObject + 0001:000017EC ExceptAddr + 0001:0000180C AcquireExceptionObject + 0001:00001840 RunErrorAt + 0001:0000184C ErrorAt + 0001:00001898 Error + 0001:000018A4 @_IOTest + 0001:000018C4 SetInOutRes + 0001:000018D4 @Copy + 0001:00001918 IOResult + 0001:00001938 Move + 0001:00001978 GetParamStr + 0001:00001A64 ParamStr + 0001:00001AC4 UpCase + 0001:00001AD0 @ROUND + 0001:00001ADC @TRUNC + 0001:00001B00 @AbstractError + 0001:00001B1C OpenText + 0001:00001B74 @ResetText + 0001:00001B80 @RewritText + 0001:00001B8C TextIn + 0001:00001BC8 FileNOPProc + 0001:00001BCC TextOut + 0001:00001C08 InternalClose + 0001:00001C18 TextClose + 0001:00001C38 TextOpen + 0001:00001DE4 @Assign + 0001:00001E4C InternalFlush + 0001:00001E94 Flush + 0001:00001EA0 @Flush + 0001:00001EAC @Close + 0001:00001F04 @PStrNCpy + 0001:00001F20 @PStrCmp + 0001:00001FA4 @AStrCmp + 0001:00002014 @EofText + 0001:0000204C @FillChar + 0001:0000206C TryOpenForInput + 0001:000020A8 @ReadChar + 0001:00002114 ReadLine + 0001:00002188 @ReadString + 0001:00002194 @ReadLString + 0001:00002200 @ReadLn + 0001:00002230 @ValLong + 0001:000022FC TryOpenForOutput + 0001:00002340 @WriteBytes + 0001:00002394 @WriteSpaces + 0001:00002410 @_CToPasStr + 0001:0000241C @_CLenToPasStr + 0001:00002440 @SetEq + 0001:00002454 FPower10 + 0001:0000245C @Pow10 + 0001:0000273C GetKeyboardType + 0001:00002744 @isNECWindows + 0001:00002774 @FpuMaskInit + 0001:00002838 @FpuInit + 0001:00002844 @BoundErr + 0001:0000284C TObject.ClassType + 0001:00002854 TObject.ClassName + 0001:00002868 TObject.ClassNameIs + 0001:00002890 TObject.ClassParent + 0001:0000289C TObject.NewInstance + 0001:000028B8 TObject.FreeInstance + 0001:000028CC TObject.InstanceSize + 0001:000028D4 TObject.Create + 0001:000028F4 TObject.Destroy + 0001:00002904 TObject.Free + 0001:00002910 TObject.InitInstance + 0001:00002968 TObject.CleanupInstance + 0001:00002988 InvokeImplGetter + 0001:000029B8 TObject.GetInterface + 0001:00002A4C TObject.GetInterfaceEntry + 0001:00002A90 @IsClass + 0001:00002AB4 @AsClass + 0001:00002AD0 GetDynaMethod + 0001:00002B00 @CallDynaInst + 0001:00002B18 TObject.InheritsFrom + 0001:00002B2C TObject.ClassInfo + 0001:00002B34 TObject.SafeCallException + 0001:00002B3C TObject.DefaultHandler + 0001:00002B40 TObject.AfterConstruction + 0001:00002B44 TObject.BeforeDestruction + 0001:00002B48 TObject.Dispatch + 0001:00002B70 TObject.MethodAddress + 0001:00002BC0 TObject.MethodName + 0001:00002C00 TObject.FieldAddress + 0001:00002C50 @ClassCreate + 0001:00002CA0 @ClassDestroy + 0001:00002CA8 @AfterConstruction + 0001:00002CB8 @BeforeDestruction + 0001:00002CC8 NotifyReRaise + 0001:00002CE4 NotifyNonDelphiException + 0001:00002D08 NotifyExcept + 0001:00002D20 NotifyOnExcept + 0001:00002D34 NotifyAnyExcept + 0001:00002D48 CheckJmp + 0001:00002D68 NotifyExceptFinally + 0001:00002D90 NotifyTerminate + 0001:00002DAC NotifyUnhandled + 0001:00002DCC @HandleAnyException + 0001:00002EF8 @HandleOnException + 0001:00003080 @HandleFinally + 0001:000030B8 @RaiseExcept + 0001:000030E0 @RaiseAgain + 0001:00003134 @DoneExcept + 0001:00003164 @TryFinallyExit + 0001:0000317C MapToRunError + 0001:0000321C @ExceptionHandler + 0001:000032BC SetExceptionHandler + 0001:000032DC UnsetExceptionHandler + 0001:00003304 FinalizeUnits + 0001:00003364 InitUnits + 0001:000033C4 @StartExe + 0001:00003404 @InitResStringImports + 0001:0000342C @InitImports + 0001:00003450 @InitWideStrings + 0001:0000346C MakeErrorMessage + 0001:000034C8 ExitDll + 0001:000034F8 WriteErrorMessage + 0001:00003584 @Halt0 + 0001:0000365C @Halt + 0001:00003668 @RunError + 0001:00003674 ThreadWrapper + 0001:000036AC BeginThread + 0001:000036F0 EndThread + 0001:000036F8 @LStrClr + 0001:0000371C @LStrArrayClr + 0001:0000374C @LStrAsg + 0001:00003790 @LStrLAsg + 0001:000037BC @NewAnsiString + 0001:000037E8 @LStrFromPCharLen + 0001:00003818 CharFromWChar + 0001:00003834 WCharFromChar + 0001:0000384C @LStrFromPWCharLen + 0001:000038D8 @LStrFromChar + 0001:000038E8 @LStrFromPChar + 0001:00003918 @LStrFromPWChar + 0001:00003954 @LStrFromString + 0001:00003960 @LStrFromArray + 0001:00003978 @LStrFromWStr + 0001:0000398C @LStrToString + 0001:000039B0 @LStrLen + 0001:000039B8 @LStrCat + 0001:000039FC @LStrCat3 + 0001:00003A70 @LStrCatN + 0001:00003AF4 @LStrCmp + 0001:00003B98 @LStrAddRef + 0001:00003BA8 @LStrToPChar + 0001:00003BB4 InternalUniqueString + 0001:00003BF8 UniqueString + 0001:00003C00 @UniqueStringA + 0001:00003C08 @LStrCopy + 0001:00003C48 @LStrDelete + 0001:00003C90 @LStrInsert + 0001:00003CEC @LStrPos + 0001:00003D34 @LStrSetLength + 0001:00003D98 @WriteLString + 0001:00003DB8 WStrError + 0001:00003DC0 @NewWideString + 0001:00003DD8 WStrSet + 0001:00003DE8 @WStrClr + 0001:00003E00 @WStrArrayClr + 0001:00003E24 @WStrAsg + 0001:00003E48 @WStrFromPCharLen + 0001:00003ED4 @WStrFromPWCharLen + 0001:00003EF8 @WStrFromPWChar + 0001:00003F34 @WStrFromLStr + 0001:00003F44 @WStrToPWChar + 0001:00003F54 @WStrLen + 0001:00003F60 @WStrCat + 0001:00003FC0 @WStrCmp + 0001:00004044 @WStrCopy + 0001:00004090 @WStrSetLength + 0001:000040D4 @InitializeRecord + 0001:00004104 @InitializeArray + 0001:00004198 @FinalizeRecord + 0001:000041CC @FinalizeArray + 0001:000042B8 @Finalize + 0001:000042C4 @CopyRecord + 0001:000043E0 @CopyArray + 0001:000044D4 WideCharLenToStrVar + 0001:000044E0 OleStrToStrVar + 0001:00004504 StringToOleStr + 0001:00004528 VariantSystemUndefinedError + 0001:00004530 VariantSystemDefaultVarClear + 0001:00004548 InitVariantManager + 0001:00004568 GetVariantManager + 0001:0000457C SetVariantManager + 0001:00004590 @VarClear + 0001:00004598 @VarCopy + 0001:000045A0 @VarCast + 0001:000045A8 @VarToInt + 0001:000045B0 @VarToInt64 + 0001:000045B8 @VarToBool + 0001:000045C0 @VarToReal + 0001:000045C8 @VarToCurr + 0001:000045D0 @VarToLStr + 0001:000045D8 @VarToWStr + 0001:000045E0 @VarToIntf + 0001:000045E8 @VarToDisp + 0001:000045F0 @VarFromInt + 0001:000045F8 @VarFromInt64 + 0001:0000460C @VarFromBool + 0001:00004614 @VarFromReal + 0001:0000461C @VarFromTDateTime + 0001:00004624 @VarFromCurr + 0001:0000462C @VarFromLStr + 0001:00004634 @VarFromWStr + 0001:0000463C @VarFromIntf + 0001:00004644 @VarFromDisp + 0001:0000464C @VarCmpEQ + 0001:00004658 @VarNeg + 0001:00004660 @VarNot + 0001:00004668 @VarClr + 0001:00004670 @DispCallByIDError + 0001:00004678 @_llmul + 0001:0000469C @_lldiv + 0001:00004718 @_lludiv + 0001:00004764 @_llmod + 0001:000047E0 @_llumod + 0001:00004830 @_llshl + 0001:00004850 @_llushr + 0001:00004870 @ValInt64 + 0001:00004A94 @DynArrayLength + 0001:00004A9C @DynArrayHigh + 0001:00004AA4 CopyArray + 0001:00004AB4 FinalizeArray + 0001:00004ABC DynArrayClear + 0001:00004AC4 DynArraySetLength + 0001:00004C50 @DynArraySetLength + 0001:00004C5C @DynArrayCopy + 0001:00004C7C @DynArrayCopyRange + 0001:00004D70 @DynArrayClear + 0001:00004DAC @DynArrayAsg + 0001:00004DD4 FindHInstance + 0001:00004DFC FindClassHInstance + 0001:00004E04 DelayLoadResourceModule + 0001:00004E4C FindResourceHInstance + 0001:00004E74 FindBS + 0001:00004E88 ToLongPath + 0001:00005040 LoadResourceModule + 0001:000052B0 AddModuleUnloadProc + 0001:000052B8 RemoveModuleUnloadProc + 0001:000052C0 AddModuleUnloadProc + 0001:000052E0 RemoveModuleUnloadProc + 0001:00005340 NotifyModuleUnload + 0001:0000539C RegisterModule + 0001:000053AC UnregisterModule + 0001:0000541C @IntfClear + 0001:00005434 @IntfCopy + 0001:00005460 @IntfCast + 0001:0000548C @IntfAddRef + 0001:00005498 TInterfacedObject.AfterConstruction + 0001:000054A4 TInterfacedObject.BeforeDestruction + 0001:000054B4 TInterfacedObject.NewInstance + 0001:000054C4 TInterfacedObject.QueryInterface + 0001:000054EC TInterfacedObject._AddRef + 0001:00005500 TInterfacedObject._Release + 0001:00005528 UnicodeToUtf8 + 0001:00005604 Utf8ToUnicode + 0001:00005748 UTF8Encode + 0001:000057F4 UTF8Decode + 0001:00005898 AnsiToUtf8 + 0001:000058E8 LoadResString + 0001:00005940 Finalization + 0001:00005994 System + 0001:00005A1C GetModuleHandle + 0001:00005A24 LocalAlloc + 0001:00005A2C TlsGetValue + 0001:00005A34 TlsSetValue + 0001:00005A3C AllocTlsBuffer + 0001:00005A48 GetTlsSize + 0001:00005A50 InitThreadTLS + 0001:00005A94 @GetTls + 0001:00005AD4 InitializeModule + 0001:00005AE0 @InitExe + 0001:00005B24 Finalization + 0001:00005B54 SysInit + 0001:00005B5C Rect + 0001:00005B78 Point + 0001:00005B80 IntersectRect + 0001:00005BE0 IsRectEmpty + 0001:00005BF8 OffsetRect + 0001:00005C10 Bounds + 0001:00005C2C CenterPoint + 0001:00005C58 Finalization + 0001:00005C88 Types + 0001:00005C90 InitializeSecurityDescriptor + 0001:00005C98 RegCloseKey + 0001:00005CA0 RegOpenKeyEx + 0001:00005CA8 RegQueryValueEx + 0001:00005CB0 SetSecurityDescriptorDacl + 0001:00005CB8 CloseHandle + 0001:00005CC0 CompareString + 0001:00005CC8 CreateEvent + 0001:00005CD0 CreateFile + 0001:00005CD8 CreatePipe + 0001:00005CE0 CreateProcess + 0001:00005CE8 CreateThread + 0001:00005CF0 DeleteCriticalSection + 0001:00005CF8 EnterCriticalSection + 0001:00005D00 EnumCalendarInfoA + 0001:00005D08 FileTimeToDosDateTime + 0001:00005D10 FileTimeToLocalFileTime + 0001:00005D18 FindClose + 0001:00005D20 FindFirstFile + 0001:00005D28 FindResource + 0001:00005D30 FormatMessage + 0001:00005D38 FreeLibrary + 0001:00005D40 FreeResource + 0001:00005D48 GetACP + 0001:00005D50 GetCPInfo + 0001:00005D58 GetCurrentProcessId + 0001:00005D60 GetCurrentThreadId + 0001:00005D68 GetDateFormat + 0001:00005D70 GetDiskFreeSpaceA + 0001:00005D78 GetExitCodeProcess + 0001:00005D80 GetExitCodeThread + 0001:00005D88 GetLastError + 0001:00005D90 GetLocalTime + 0001:00005D98 GetLocaleInfo + 0001:00005DA0 GetModuleFileName + 0001:00005DA8 GetModuleHandle + 0001:00005DB0 GetPrivateProfileString + 0001:00005DB8 GetProcAddress + 0001:00005DC0 GetProfileString + 0001:00005DC8 GetStartupInfo + 0001:00005DD0 GetStdHandle + 0001:00005DD8 GetStringTypeEx + 0001:00005DE0 GetStringTypeExA + 0001:00005DE8 GetSystemInfo + 0001:00005DF0 GetThreadLocale + 0001:00005DF8 GetTickCount + 0001:00005E00 GetVersion + 0001:00005E08 GetVersionEx + 0001:00005E10 GlobalAddAtom + 0001:00005E18 GlobalAlloc + 0001:00005E20 GlobalDeleteAtom + 0001:00005E28 GlobalFindAtom + 0001:00005E30 GlobalFree + 0001:00005E38 GlobalLock + 0001:00005E40 GlobalHandle + 0001:00005E48 GlobalReAlloc + 0001:00005E50 GlobalUnlock + 0001:00005E58 InitializeCriticalSection + 0001:00005E60 LeaveCriticalSection + 0001:00005E68 LoadLibrary + 0001:00005E70 LoadResource + 0001:00005E78 LockResource + 0001:00005E80 MulDiv + 0001:00005E88 MultiByteToWideChar + 0001:00005E90 PeekNamedPipe + 0001:00005E98 ReadFile + 0001:00005EA0 ResetEvent + 0001:00005EA8 ResumeThread + 0001:00005EB0 SetEndOfFile + 0001:00005EB8 SetErrorMode + 0001:00005EC0 SetEvent + 0001:00005EC8 SetFilePointer + 0001:00005ED0 SetThreadLocale + 0001:00005ED8 SetThreadPriority + 0001:00005EE0 SizeofResource + 0001:00005EE8 Sleep + 0001:00005EF0 SleepEx + 0001:00005EF8 VirtualAlloc + 0001:00005F00 VirtualQuery + 0001:00005F08 WaitForSingleObject + 0001:00005F10 WriteFile + 0001:00005F18 WritePrivateProfileString + 0001:00005F20 lstrcmp + 0001:00005F28 lstrcpy + 0001:00005F30 GetFileVersionInfo + 0001:00005F38 GetFileVersionInfoSize + 0001:00005F40 VerQueryValue + 0001:00005F48 BitBlt + 0001:00005F50 CreateBitmap + 0001:00005F58 CreateBrushIndirect + 0001:00005F60 CreateCompatibleBitmap + 0001:00005F68 CreateCompatibleDC + 0001:00005F70 CreateDC + 0001:00005F78 CreateDIBSection + 0001:00005F80 CreateDIBitmap + 0001:00005F88 CreateFontIndirect + 0001:00005F90 CreateHalftonePalette + 0001:00005F98 CreateIC + 0001:00005FA0 CreatePalette + 0001:00005FA8 CreatePenIndirect + 0001:00005FB0 CreateSolidBrush + 0001:00005FB8 DeleteDC + 0001:00005FC0 DeleteObject + 0001:00005FC8 EndDoc + 0001:00005FD0 EndPage + 0001:00005FD8 ExcludeClipRect + 0001:00005FE0 ExtTextOut + 0001:00005FE8 GetBitmapBits + 0001:00005FF0 GetBrushOrgEx + 0001:00005FF8 GetClipBox + 0001:00006000 GetCurrentPositionEx + 0001:00006008 GetDCOrgEx + 0001:00006010 GetDIBColorTable + 0001:00006018 GetDIBits + 0001:00006020 GetDeviceCaps + 0001:00006028 GetObject + 0001:00006030 GetPaletteEntries + 0001:00006038 GetPixel + 0001:00006040 GetStockObject + 0001:00006048 GetSystemPaletteEntries + 0001:00006050 GetTextExtentPoint32 + 0001:00006058 GetTextMetrics + 0001:00006060 GetWindowOrgEx + 0001:00006068 IntersectClipRect + 0001:00006070 LineTo + 0001:00006078 MaskBlt + 0001:00006080 MoveToEx + 0001:00006088 PatBlt + 0001:00006090 Polyline + 0001:00006098 RealizePalette + 0001:000060A0 RectVisible + 0001:000060A8 Rectangle + 0001:000060B0 RestoreDC + 0001:000060B8 SaveDC + 0001:000060C0 SelectObject + 0001:000060C8 SelectPalette + 0001:000060D0 SetAbortProc + 0001:000060D8 SetBkColor + 0001:000060E0 SetBkMode + 0001:000060E8 SetBrushOrgEx + 0001:000060F0 SetDIBColorTable + 0001:000060F8 SetMapMode + 0001:00006100 SetPixel + 0001:00006108 SetROP2 + 0001:00006110 SetStretchBltMode + 0001:00006118 SetTextColor + 0001:00006120 SetViewportOrgEx + 0001:00006128 SetWindowOrgEx + 0001:00006130 StartDoc + 0001:00006138 StartPage + 0001:00006140 StretchBlt + 0001:00006148 UnrealizeObject + 0001:00006150 ActivateKeyboardLayout + 0001:00006158 AdjustWindowRectEx + 0001:00006160 AnsiLower + 0001:00006168 BeginPaint + 0001:00006170 CallNextHookEx + 0001:00006178 CallWindowProc + 0001:00006180 CharLowerBuff + 0001:00006188 CharNext + 0001:00006190 CharUpperBuff + 0001:00006198 CheckMenuItem + 0001:000061A0 ChildWindowFromPoint + 0001:000061A8 ClientToScreen + 0001:000061B0 CreateIcon + 0001:000061B8 CreateMenu + 0001:000061C0 CreatePopupMenu + 0001:000061C8 CreateWindowEx + 0001:000061D0 DefFrameProc + 0001:000061D8 DefMDIChildProc + 0001:000061E0 DefWindowProc + 0001:000061E8 DeleteMenu + 0001:000061F0 DestroyCursor + 0001:000061F8 DestroyIcon + 0001:00006200 DestroyMenu + 0001:00006208 DestroyWindow + 0001:00006210 DispatchMessage + 0001:00006218 DrawAnimatedRects + 0001:00006220 DrawEdge + 0001:00006228 DrawFocusRect + 0001:00006230 DrawFrameControl + 0001:00006238 DrawIcon + 0001:00006240 DrawIconEx + 0001:00006248 DrawMenuBar + 0001:00006250 DrawText + 0001:00006258 EnableMenuItem + 0001:00006260 EnableScrollBar + 0001:00006268 EnableWindow + 0001:00006270 EndPaint + 0001:00006278 EnumThreadWindows + 0001:00006280 EnumWindows + 0001:00006288 EqualRect + 0001:00006290 FillRect + 0001:00006298 FindWindow + 0001:000062A0 FindWindowEx + 0001:000062A8 FrameRect + 0001:000062B0 GetActiveWindow + 0001:000062B8 GetCapture + 0001:000062C0 GetClassInfo + 0001:000062C8 GetClassName + 0001:000062D0 GetClientRect + 0001:000062D8 GetCursor + 0001:000062E0 GetCursorPos + 0001:000062E8 GetDC + 0001:000062F0 GetDCEx + 0001:000062F8 GetDesktopWindow + 0001:00006300 GetDoubleClickTime + 0001:00006308 GetFocus + 0001:00006310 GetForegroundWindow + 0001:00006318 GetIconInfo + 0001:00006320 GetKeyNameText + 0001:00006328 GetKeyState + 0001:00006330 GetKeyboardLayout + 0001:00006338 GetKeyboardLayoutList + 0001:00006340 GetKeyboardState + 0001:00006348 GetLastActivePopup + 0001:00006350 GetMenu + 0001:00006358 GetMenuItemCount + 0001:00006360 GetMenuItemID + 0001:00006368 GetMenuItemInfo + 0001:00006370 GetMenuState + 0001:00006378 GetMenuString + 0001:00006380 GetMessagePos + 0001:00006388 GetNextWindow + 0001:00006390 GetParent + 0001:00006398 GetProp + 0001:000063A0 GetScrollInfo + 0001:000063A8 GetScrollPos + 0001:000063B0 GetScrollRange + 0001:000063B8 GetSubMenu + 0001:000063C0 GetSysColor + 0001:000063C8 GetSystemMenu + 0001:000063D0 GetSystemMetrics + 0001:000063D8 GetTopWindow + 0001:000063E0 GetUpdateRect + 0001:000063E8 GetWindow + 0001:000063F0 GetWindowDC + 0001:000063F8 GetWindowLong + 0001:00006400 GetWindowPlacement + 0001:00006408 GetWindowRect + 0001:00006410 GetWindowText + 0001:00006418 GetWindowThreadProcessId + 0001:00006420 GetWindowThreadProcessId + 0001:00006428 InflateRect + 0001:00006430 InsertMenu + 0001:00006438 InsertMenuItem + 0001:00006440 IntersectRect + 0001:00006448 InvalidateRect + 0001:00006450 IsChild + 0001:00006458 IsDialogMessage + 0001:00006460 IsIconic + 0001:00006468 IsRectEmpty + 0001:00006470 IsWindow + 0001:00006478 IsWindowEnabled + 0001:00006480 IsWindowVisible + 0001:00006488 IsZoomed + 0001:00006490 KillTimer + 0001:00006498 LoadBitmap + 0001:000064A0 LoadCursor + 0001:000064A8 LoadIcon + 0001:000064B0 LoadKeyboardLayout + 0001:000064B8 LoadString + 0001:000064C0 MapVirtualKey + 0001:000064C8 MapWindowPoints + 0001:000064D0 MessageBox + 0001:000064D8 MsgWaitForMultipleObjects + 0001:000064E0 OemToAnsi + 0001:000064E8 OffsetRect + 0001:000064F0 PeekMessage + 0001:000064F8 PostMessage + 0001:00006500 PostQuitMessage + 0001:00006508 PtInRect + 0001:00006510 RedrawWindow + 0001:00006518 RegisterClass + 0001:00006520 RegisterClipboardFormat + 0001:00006528 RegisterWindowMessage + 0001:00006530 ReleaseCapture + 0001:00006538 ReleaseDC + 0001:00006540 RemoveMenu + 0001:00006548 RemoveProp + 0001:00006550 ScreenToClient + 0001:00006558 ScrollWindow + 0001:00006560 SendMessage + 0001:00006568 SetActiveWindow + 0001:00006570 SetCapture + 0001:00006578 SetClassLong + 0001:00006580 SetCursor + 0001:00006588 SetFocus + 0001:00006590 SetForegroundWindow + 0001:00006598 SetMenu + 0001:000065A0 SetMenuItemInfo + 0001:000065A8 SetProp + 0001:000065B0 SetRect + 0001:000065B8 SetScrollInfo + 0001:000065C0 SetScrollPos + 0001:000065C8 SetScrollRange + 0001:000065D0 SetTimer + 0001:000065D8 SetWindowLong + 0001:000065E0 SetWindowPlacement + 0001:000065E8 SetWindowPos + 0001:000065F0 SetWindowText + 0001:000065F8 SetWindowsHookEx + 0001:00006600 ShowCursor + 0001:00006608 ShowOwnedPopups + 0001:00006610 ShowScrollBar + 0001:00006618 ShowWindow + 0001:00006620 SystemParametersInfo + 0001:00006628 TrackPopupMenu + 0001:00006630 TranslateMDISysAccel + 0001:00006638 TranslateMessage + 0001:00006640 UnhookWindowsHookEx + 0001:00006648 UnregisterClass + 0001:00006650 UpdateWindow + 0001:00006658 WaitMessage + 0001:00006660 WinHelp + 0001:00006668 WindowFromPoint + 0001:00006670 MakeLong + 0001:0000667C HiWord + 0001:00006680 GetCurrentTime + 0001:00006688 UnlockResource + 0001:0000668C GlobalAllocPtr + 0001:0000669C GlobalReAllocPtr + 0001:000066B8 GlobalFreePtr + 0001:000066CC MakeROP4 + 0001:000066D8 RGB + 0001:000066F4 SmallPointToPoint + 0001:00006708 PointToSmallPoint + 0001:00006720 MakeLParam + 0001:00006728 CreateWindow + 0001:0000675C HwndMSWheel + 0001:00006854 Finalization + 0001:00006884 Windows + 0001:0000688C Finalization + 0001:000068BC Messages + 0001:00006BDC Finalization + 0001:00006C0C SysConst + 0001:000077A4 DivMod + 0001:000077C0 ConvertError + 0001:000077D8 ConvertErrorFmt + 0001:000077FC AllocMem + 0001:0000781C DoExitProc + 0001:00007848 AddExitProc + 0001:00007880 UpperCase + 0001:000078BC LowerCase + 0001:000078F8 CompareStr + 0001:00007928 CompareMem + 0001:00007948 CompareText + 0001:0000799C SameText + 0001:000079C0 AnsiUpperCase + 0001:000079F4 AnsiLowerCase + 0001:00007A28 AnsiCompareStr + 0001:00007A60 AnsiCompareText + 0001:00007A98 AnsiSameText + 0001:00007AB0 AnsiStrLIComp + 0001:00007AD0 Trim + 0001:00007B20 AdjustLineBreaks + 0001:00007C88 IsValidIdent + 0001:00007CEC IntToStr + 0001:00007D1C IntToStr + 0001:00007D50 IntToHex + 0001:00007D8C StrToInt + 0001:00007DC8 StrToIntDef + 0001:00007DE0 TryStrToInt + 0001:00007E00 TryStrToInt64 + 0001:00007E20 VerifyBoolStrArray + 0001:00007EB0 CompareWith + 0001:00007EEC TryStrToBool + 0001:00007F88 BoolToStr + 0001:00007FD4 FileOpen + 0001:00008030 FileCreate + 0001:00008054 FileCreate + 0001:0000805C FileRead + 0001:00008088 FileWrite + 0001:000080B4 FileSeek + 0001:000080EC FileClose + 0001:000080F4 FileAge + 0001:0000815C FileExists + 0001:0000816C AnsiLastChar + 0001:0000819C LastDelimiter + 0001:000081EC ExtractFilePath + 0001:00008220 ExtractFileName + 0001:00008258 ExtractFileExt + 0001:000082A0 BackfillGetDiskFreeSpaceEx + 0001:00008314 StrLen + 0001:0000832C StrEnd + 0001:00008340 StrMove + 0001:00008350 StrCopy + 0001:00008378 StrLCopy + 0001:000083AC StrPCopy + 0001:000083D0 StrPLCopy + 0001:000083F0 StrComp + 0001:00008414 StrIComp + 0001:00008454 StrLIComp + 0001:00008498 StrScan + 0001:000084B8 StrPos + 0001:0000850C StrPas + 0001:00008520 StrAlloc + 0001:00008534 StrBufSize + 0001:00008540 StrNew + 0001:0000856C StrDispose + 0001:0000857C FormatError + 0001:000085D4 FormatVarToStr + 0001:000085E8 FormatClearStr + 0001:000085F4 FormatBuf + 0001:00008A08 StrFmt + 0001:00008A48 StrLFmt + 0001:00008A88 Format + 0001:00008A9C FmtStr + 0001:00008B5C PutExponent + 0001:00008BA0 FloatToText + 0001:00008E78 FloatToDecimal + 0001:000090A4 TextToFloat + 0001:000091B8 FloatToStr + 0001:000091E8 CurrToStr + 0001:00009218 StrToFloat + 0001:00009254 TryStrToFloat + 0001:00009270 TryStrToFloat + 0001:0000929C TryStrToFloat + 0001:000092C8 TryStrToCurr + 0001:000092E4 DateTimeToTimeStamp + 0001:00009328 TryEncodeTime + 0001:00009398 EncodeTime + 0001:000093D8 DecodeTime + 0001:00009434 IsLeapYear + 0001:00009470 TryEncodeDate + 0001:00009538 EncodeDate + 0001:00009568 DecodeDateFully + 0001:000096B4 DecodeDate + 0001:000096D4 DayOfWeek + 0001:000096FC Now + 0001:0000974C CurrentYear + 0001:00009760 AppendChars + 0001:000097A4 AppendString + 0001:000097C4 AppendNumber + 0001:00009810 GetCount + 0001:0000983C GetDate + 0001:00009874 GetTime + 0001:000098B4 ConvertEraString + 0001:00009A1C ConvertYearString + 0001:00009B24 AppendFormat + 0001:0000A2B4 DateTimeToString + 0001:0000A310 DateToStr + 0001:0000A328 TimeToStr + 0001:0000A340 DateTimeToStr + 0001:0000A354 ScanBlanks + 0001:0000A378 ScanNumber + 0001:0000A40C ScanString + 0001:0000A498 ScanChar + 0001:0000A4D0 GetDateOrder + 0001:0000A51C ScanToNumber + 0001:0000A564 GetEraYearOffset + 0001:0000A5B8 EraToYear + 0001:0000A614 ScanDate + 0001:0000A950 ScanTime + 0001:0000AB48 StrToDate + 0001:0000AB7C TryStrToDate + 0001:0000ABB0 StrToTime + 0001:0000ABE4 TryStrToTime + 0001:0000AC18 StrToDateTime + 0001:0000AC4C TryStrToDateTime + 0001:0000ACD8 SysErrorMessage + 0001:0000AD24 GetLocaleStr + 0001:0000AD70 GetLocaleChar + 0001:0000AD98 LocalGetLocaleStr + 0001:0000ADD4 GetMonthDayNames + 0001:0000AEF8 EnumEraNames + 0001:0000AF34 EnumEraYearOffsets + 0001:0000AFAC GetEraNamesAndYearOffsets + 0001:0000B05C TranslateDateFormat + 0001:0000B284 ConvertAddr + 0001:0000B290 ExceptionErrorMessage + 0001:0000B418 ShowException + 0001:0000B4D0 ReturnAddr + 0001:0000B4D4 Abort + 0001:0000B530 Exception.Create + 0001:0000B56C Exception.CreateFmt + 0001:0000B5EC Exception.CreateRes + 0001:0000B628 Exception.CreateResFmt + 0001:0000B6BC Exception.CreateHelp + 0001:0000B704 EHeapException.FreeInstance + 0001:0000B730 CreateInOutError + 0001:0000B7B0 ErrorHandler + 0001:0000B804 CreateAssertException + 0001:0000B8B0 RaiseAssertException + 0001:0000B8C0 AssertErrorHandler + 0001:0000B8DC AbstractErrorHandler + 0001:0000B8F4 MapException + 0001:0000B974 GetExceptionClass + 0001:0000B98C CreateAVObject + 0001:0000BB58 GetExceptionObject + 0001:0000BC24 ExceptHandler + 0001:0000BC34 InitExceptions + 0001:0000BCB8 DoneExceptions + 0001:0000BD24 InitPlatformId + 0001:0000BD7C CheckWin32Version + 0001:0000BD9C ByteTypeTest + 0001:0000BE14 ByteType + 0001:0000BE38 StrByteType + 0001:0000BE50 ByteToCharLen + 0001:0000BE78 ByteToCharIndex + 0001:0000BED0 CountChars + 0001:0000BF60 CharToByteIndex + 0001:0000BFC4 CharToByteLen + 0001:0000C024 StrCharLength + 0001:0000C044 StrNextChar + 0001:0000C04C CharLength + 0001:0000C088 NextCharIndex + 0001:0000C0C4 AnsiPos + 0001:0000C0FC AnsiLowerCaseFileName + 0001:0000C188 AnsiStrPos + 0001:0000C228 AnsiStrRScan + 0001:0000C250 AnsiStrScan + 0001:0000C290 LCIDToCodePage + 0001:0000C304 InitLeadBytes + 0001:0000C364 IsWesternGroup + 0001:0000C37C InitSysLocale + 0001:0000C4F0 GetFormatSettings + 0001:0000C868 StringReplace + 0001:0000C99C Sleep + 0001:0000C9A4 RaiseLastOSError + 0001:0000CA40 Win32Check + 0001:0000CA50 CallTerminateProcs + 0001:0000CA6C FreeTerminateProcs + 0001:0000CA8C InitDriveSpacePtr + 0001:0000CAE8 InterlockedIncrement + 0001:0000CAF4 InterlockedDecrement + 0001:0000CB00 InterlockedExchange + 0001:0000CB08 InterlockedExchangeAdd + 0001:0000CB74 TThreadLocalCounter2.Destroy + 0001:0000CBC4 TThreadLocalCounter2.HashIndex + 0001:0000CBDC TThreadLocalCounter2.Open + 0001:0000CC54 TThreadLocalCounter2.Delete + 0001:0000CC64 TThreadLocalCounter2.Recycle + 0001:0000CCA4 TMultiReadExclusiveWriteSynchronizer.Create + 0001:0000CD18 TMultiReadExclusiveWriteSynchronizer.Destroy + 0001:0000CD60 TMultiReadExclusiveWriteSynchronizer.BlockReaders + 0001:0000CD6C TMultiReadExclusiveWriteSynchronizer.UnblockReaders + 0001:0000CD78 TMultiReadExclusiveWriteSynchronizer.UnblockOneWriter + 0001:0000CD84 TMultiReadExclusiveWriteSynchronizer.WaitForReadSignal + 0001:0000CD94 TMultiReadExclusiveWriteSynchronizer.WaitForWriteSignal + 0001:0000CDA4 TMultiReadExclusiveWriteSynchronizer.BeginWrite + 0001:0000CE40 TMultiReadExclusiveWriteSynchronizer.EndWrite + 0001:0000CE90 TMultiReadExclusiveWriteSynchronizer.BeginRead + 0001:0000CEEC TMultiReadExclusiveWriteSynchronizer.EndRead + 0001:0000CF54 FreeAndNil + 0001:0000CF64 Supports + 0001:0000CF88 Supports + 0001:0000D020 SafeLoadLibrary + 0001:0000D374 Finalization + 0001:0000D4F4 SysUtils + 0001:0000D574 VariantInit + 0001:0000D57C VariantClear + 0001:0000D584 VariantCopy + 0001:0000D58C VariantCopyInd + 0001:0000D594 VariantChangeType + 0001:0000D59C BackupVariantChangeTypeEx + 0001:0000D5CC UniUnimplemented + 0001:0000D5D8 BiUnimplemented + 0001:0000D5E4 CmpUnimplemented + 0001:0000D5F0 BackupVarI4FromStr + 0001:0000D65C BackupVarR4FromStr + 0001:0000D6C8 BackupVarR8FromStr + 0001:0000D734 BackupVarDateFromStr + 0001:0000D7A0 BackupVarCyFromStr + 0001:0000D80C BackupVarBoolFromStr + 0001:0000D88C BackupVarBStrFromCy + 0001:0000D8FC BackupVarBStrFromDate + 0001:0000D96C BackupVarBStrFromBool + 0001:0000D9E0 SafeArrayCreate + 0001:0000D9E8 SafeArrayRedim + 0001:0000D9F0 SafeArrayGetLBound + 0001:0000D9F8 SafeArrayGetUBound + 0001:0000DA00 SafeArrayGetElement + 0001:0000DA08 SafeArrayPutElement + 0001:0000DA10 SafeArrayPtrOfIndex + 0001:0000DA18 VariantChangeTypeEx + 0001:0000DA3C VarNeg + 0001:0000DA54 VarNot + 0001:0000DA6C VarI4FromStr + 0001:0000DA8C VarR8FromStr + 0001:0000DAAC VarDateFromStr + 0001:0000DACC VarCyFromStr + 0001:0000DAEC VarBoolFromStr + 0001:0000DB0C VarBstrFromCy + 0001:0000DB3C VarBstrFromDate + 0001:0000DB6C VarBstrFromBool + 0001:0000DB9C FindProc + 0001:0000DBC8 InitializeVarUtils + 0001:0000DED4 Finalization + 0001:0000DF04 VarUtils + 0001:0000E554 VarCastError + 0001:0000E5A8 VarCastError + 0001:0000E644 VarInvalidOp + 0001:0000E698 VarInvalidNullOp + 0001:0000E6EC VarOverflowError + 0001:0000E788 VarArrayCreateError + 0001:0000E7DC TranslateResult + 0001:0000EA04 VarResultCheck + 0001:0000EA10 VarResultCheck + 0001:0000EA44 HandleConversionException + 0001:0000EAC8 _DispInvokeError + 0001:0000EB1C _VarNull + 0001:0000EB30 InBounds + 0001:0000EB60 Increment + 0001:0000EBBC VarArrayClear + 0001:0000ED38 VarClearDeep + 0001:0000EDB4 _VarClear + 0001:0000EDC8 _DispInvoke + 0001:0000EECC InBounds + 0001:0000EEFC Increment + 0001:0000EF58 VarArrayCopyForEach + 0001:0000F124 VarCopyCopyProc + 0001:0000F12C VarCopyDeep + 0001:0000F1D8 _VarCopy + 0001:0000F21C VarCopyNoIndViaOS + 0001:0000F23C VarCopyNoIndOleStr + 0001:0000F244 VarCopyNoIndCopyProc + 0001:0000F24C VarCopyNoIndDeep + 0001:0000F280 VarCopyByRef + 0001:0000F458 _VarCopyNoInd + 0001:0000F46C _VarStringToOleStr + 0001:0000F48C VarStringToOleStr + 0001:0000F494 VarCastAsAny + 0001:0000F500 VarCastAsOleStr + 0001:0000F54C VarCastAsString + 0001:0000F598 VarCastAsDispatch + 0001:0000F5E4 VarCastAsInterface + 0001:0000F630 VarCastViaOS + 0001:0000F6A8 VarCastRare + 0001:0000F714 _VarCast + 0001:0000F940 _VarCastOle + 0001:0000F9AC VarToIntAsString + 0001:0000FA5C VarToIntViaOS + 0001:0000FA94 VarToIntAny + 0001:0000FAF8 VarToIntCustom + 0001:0000FB3C _VarToInteger + 0001:0000FF38 _VarToShortInt + 0001:0000FFE8 _VarToByte + 0001:00010090 _VarToSmallInt + 0001:00010188 _VarToWord + 0001:00010260 _VarToLongWord + 0001:00010348 VarToInt64ViaOS + 0001:000103EC VarToInt64AsString + 0001:000104E4 VarToInt64Any + 0001:00010550 VarToInt64Custom + 0001:0001059C _VarToInt64 + 0001:000109E0 VarToBoolAsString + 0001:00010AA4 VarToBoolViaOS + 0001:00010AE0 VarToBoolAny + 0001:00010B44 VarToBoolCustom + 0001:00010B90 _VarToBool + 0001:00010ED8 _VarToBoolWithFix + 0001:00010EE4 VarToDoubleAsString + 0001:00010FA4 VarToDoubleViaOS + 0001:00010FEC VarToDoubleAny + 0001:00011050 VarToDoubleCustom + 0001:0001109C _VarToDouble + 0001:00011418 _VarToExtended + 0001:00011434 _VarToSingle + 0001:000115C4 VarToDateAsString + 0001:000116AC VarToDateAsDouble + 0001:00011708 VarToDateViaOS + 0001:00011750 VarToDateAny + 0001:000117B4 VarToDateCustom + 0001:00011800 _VarToDate + 0001:00011B50 VarToCurrencyAsString + 0001:00011C08 VarToCurrencyAsDouble + 0001:00011C64 VarToCurrencyViaOS + 0001:00011CAC VarToCurrencyAny + 0001:00011D10 VarToCurrencyCustom + 0001:00011D5C _VarToCurrency + 0001:00012128 CurrToWStrViaOS + 0001:0001215C DateToWStrViaOS + 0001:00012190 BoolToWStrViaOS + 0001:00012250 VarToLStrViaOS + 0001:00012318 VarToLStrAny + 0001:0001237C VarToLStrCustom + 0001:00012400 _VarToLStr + 0001:00012944 _VarToPStr + 0001:00012994 VarToWStrViaOS + 0001:00012A48 VarToWStrAny + 0001:00012AAC VarToWStrCustom + 0001:00012B74 _VarToWStr + 0001:000130D4 AnyToIntf + 0001:0001314C _VarToIntf + 0001:00013218 _VarToDisp + 0001:000132C4 _VarToDynArray + 0001:000132D4 _VarFromInt + 0001:00013314 _VarFromInteger + 0001:00013334 _OleVarFromInt + 0001:00013354 _VarFromByte + 0001:00013374 _VarFromWord + 0001:00013394 _VarFromLongWord + 0001:000133B4 _VarFromShortInt + 0001:000133D4 _VarFromSmallInt + 0001:000133F4 _VarFromInt64 + 0001:00013420 _VarFromSingle + 0001:00013444 _VarFromDouble + 0001:00013470 _VarFromCurrency + 0001:0001349C _VarFromDate + 0001:000134C8 _VarFromBool + 0001:000134F0 _VarFromReal + 0001:00013504 _VarFromTDateTime + 0001:00013518 _VarFromCurr + 0001:0001352C _VarFromLStr + 0001:00013558 _VarFromPStr + 0001:000135A8 _VarFromWStr + 0001:000135E0 _VarFromIntf + 0001:0001360C _VarFromDisp + 0001:00013638 _VarFromDynArray + 0001:0001364C _OleVarFromLStr + 0001:0001369C _OleVarFromPStr + 0001:000136EC OleVarFromAny + 0001:00013750 OleVarFromVarArrayProc + 0001:00013758 _OleVarFromVar + 0001:000138A8 VarStrCat + 0001:0001395C VarOpRare + 0001:00013CA8 AnyOp + 0001:00013D34 CheckType + 0001:00013D7C RealOp + 0001:00013DF8 DateOp + 0001:00013E54 IntOp + 0001:00013F60 Int64Op + 0001:0001413C NullOp + 0001:000141E8 EmptyOp + 0001:00014280 SimpleVarOp + 0001:000146CC _VarOp + 0001:0001475C VarCompareAny + 0001:00014830 EmptyCompare + 0001:00014844 NullCompare + 0001:0001492C CheckType + 0001:00014950 IntCompare + 0001:00014964 Int64Compare + 0001:000149A0 RealCompare + 0001:000149C8 DateCompare + 0001:000149F0 CurrCompare + 0001:00014A1C StringCompare + 0001:00014A88 VarCompareSimple + 0001:00014C20 VarCompareRare + 0001:00015040 VarCompare + 0001:000150C0 _VarCmp + 0001:000150C8 NegateAsDouble + 0001:000150E0 NegateViaOS + 0001:000150F4 NegateVariant + 0001:00015120 NegateByte + 0001:00015134 NegateWord + 0001:00015144 NegateLongWord + 0001:00015178 NegateAny + 0001:0001518C NegateCustom + 0001:000151B8 _VarNeg + 0001:000154A8 NotAsString + 0001:00015578 NotAsOrdinal + 0001:000155E0 NotViaOS + 0001:000155F4 NotVariant + 0001:00015620 NotAny + 0001:00015634 NotCustom + 0001:00015660 _VarNot + 0001:000158E0 _VarAddRef + 0001:00015A64 VarTypeAsText + 0001:00015BD4 VarType + 0001:00015BD8 FindVarData + 0001:00015BE8 VarIsClear + 0001:00015C5C VarTypeIsCustom + 0001:00015C68 VarIsNull + 0001:00015C7C VarToStr + 0001:00015C94 VarToStrDef + 0001:00015CC0 VarSameValue + 0001:00015D38 SetVarAsError + 0001:00015D50 SetClearVarToEmptyParam + 0001:00015D5C _WriteVariant + 0001:00015DC0 _Write0Variant + 0001:00015DC8 GetVarDataArrayInfo + 0001:00015E0C VarArrayCreate + 0001:00015EB4 _VarArrayRedim + 0001:00015F0C GetVarArray + 0001:00015F34 VarArrayDimCount + 0001:00015F5C VarArrayLowBound + 0001:00015F80 VarArrayHighBound + 0001:00015FA4 VarIsArray + 0001:00015FAC VarIsArray + 0001:00015FD4 VarTypeIsValidArrayType + 0001:00015FF4 VarTypeIsValidElementType + 0001:00016030 _VarArrayGet + 0001:000160FC VarArrayGet + 0001:00016120 _VarArrayPut + 0001:00016268 VarArrayPut + 0001:00016290 DynArrayIndex + 0001:000162D0 DynArrayElTypeInfo + 0001:000162EC DynArrayDim + 0001:00016304 DynArraySize + 0001:0001630C IsDynArrayRectangular + 0001:00016374 DynArrayBounds + 0001:000163C8 DecIndices + 0001:00016434 DynArrayVariantBounds + 0001:0001648C DynArrayVarType + 0001:000164D4 DynArrayToVariant + 0001:000167F4 DynArrayFromVariant + 0001:00016AE8 ClearVariantTypeList + 0001:00016B58 TCustomVariantType.BinaryOp + 0001:00016B64 TCustomVariantType.Cast + 0001:00016B9C TCustomVariantType.CastTo + 0001:00016BE4 TCustomVariantType.Compare + 0001:00016BF0 TCustomVariantType.CompareOp + 0001:00016C28 TCustomVariantType.CastToOle + 0001:00016C64 TCustomVariantType.Destroy + 0001:00016CF0 TCustomVariantType.IsClear + 0001:00016CF4 TCustomVariantType.LeftPromotion + 0001:00016D08 TCustomVariantType.OlePromotion + 0001:00016D10 TCustomVariantType.RaiseCastError + 0001:00016D18 TCustomVariantType.RaiseInvalidOp + 0001:00016D20 TCustomVariantType.RaiseDispError + 0001:00016D28 TCustomVariantType.RightPromotion + 0001:00016D3C TCustomVariantType.UnaryOp + 0001:00016D44 TCustomVariantType.DispInvoke + 0001:00016D50 TCustomVariantType._AddRef + 0001:00016D5C TCustomVariantType._Release + 0001:00016D68 TCustomVariantType.QueryInterface + 0001:00016D90 FindCustomVariantType + 0001:00016E48 FindCustomVariantType + 0001:00016F30 Null + 0001:00016F38 Finalization + 0001:00016FBC Variants + 0001:00017300 Finalization + 0001:00017330 RTLConsts + 0001:00017364 GetTypeData + 0001:00017370 GetEnumName + 0001:00017464 GetEnumNameValue + 0001:000174B0 GetEnumValue + 0001:00017514 GetPropInfo + 0001:00017584 GetPropInfos + 0001:000175D8 IsStoredProp + 0001:00017608 GetOrdProp + 0001:0001767C SetOrdProp + 0001:000176D8 GetShortStrProp + 0001:0001771C SetShortStrProp + 0001:00017770 GetShortStrPropAsLongStr + 0001:00017798 SetShortStrPropAsLongStr + 0001:000177CC AssignLongStr + 0001:000177E0 GetLongStrProp + 0001:00017820 SetLongStrProp + 0001:00017860 GetWideStrPropAsLongStr + 0001:000178B8 SetWideStrPropAsLongStr + 0001:00017910 GetStrProp + 0001:00017950 SetStrProp + 0001:0001797C GetWideStrProp + 0001:00017A64 SetWideStrProp + 0001:00017B38 GetFloatProp + 0001:00017C50 SetFloatProp + 0001:00017E48 AssignVariant + 0001:00017E5C GetVariantProp + 0001:00017E9C SetVariantProp + 0001:00017EDC GetMethodProp + 0001:00017F1C SetMethodProp + 0001:00017F54 GetInt64Prop + 0001:00017F7C SetInt64Prop + 0001:00017FB8 GetInterfaceProp + 0001:00018038 SetInterfaceProp + 0001:000180AC Finalization + 0001:000180FC TypInfo + 0001:00018138 CoInitialize + 0001:00018140 CoUninitialize + 0001:00018148 SysFreeString + 0001:00018150 GetErrorInfo + 0001:00018158 Succeeded + 0001:00018164 Finalization + 0001:00018194 ActiveX + 0001:00019A30 Point + 0001:00019A48 SmallPoint + 0001:00019A58 Rect + 0001:00019A80 Bounds + 0001:00019AA8 InvalidPoint + 0001:00019ABC InvalidPoint + 0001:00019B88 TRegGroup.AddClass + 0001:00019B94 TRegGroup.BestClass + 0001:00019BF4 TRegGroup.BestGroup + 0001:00019C64 TRegGroup.Create + 0001:00019CE0 TRegGroup.Destroy + 0001:00019D20 TRegGroup.GetClass + 0001:00019D80 TRegGroup.InGroup + 0001:00019DC4 TRegGroup.RegisterClass + 0001:00019E6C TRegGroup.Registered + 0001:00019E84 PointerInModule + 0001:00019EA4 TRegGroup.UnregisterModuleClasses + 0001:00019F48 TRegGroups.Activate + 0001:00019F94 TRegGroups.Create + 0001:0001A008 TRegGroups.Destroy + 0001:0001A064 TRegGroups.FindGroup + 0001:0001A0A8 TRegGroups.GetClass + 0001:0001A0EC Error + 0001:0001A17C TRegGroups.GroupWith + 0001:0001A244 TRegGroups.Lock + 0001:0001A250 TRegGroups.RegisterClass + 0001:0001A268 TRegGroups.Registered + 0001:0001A2AC TRegGroups.StartGroup + 0001:0001A2FC TRegGroups.Unlock + 0001:0001A308 TRegGroups.UnregisterModuleClasses + 0001:0001A338 TClassFinder.Create + 0001:0001A464 TClassFinder.Destroy + 0001:0001A494 TClassFinder.GetClass + 0001:0001A51C GetFieldClassTable + 0001:0001A528 ClassNotFound + 0001:0001A594 GetClass + 0001:0001A5E8 FindClass + 0001:0001A608 RegisterClass + 0001:0001A678 UnRegisterModuleClasses + 0001:0001A6C4 StartClassGroup + 0001:0001A710 GroupDescendentsWith + 0001:0001A764 ActivateClassGroup + 0001:0001A818 TIntConst.Create + 0001:0001A850 RegisterIntegerConsts + 0001:0001A87C FindIntToIdent + 0001:0001A8F8 FindIdentToInt + 0001:0001A974 IdentToInt + 0001:0001A9B4 IntToIdent + 0001:0001A9F8 RegisterFindGlobalComponentProc + 0001:0001AA38 UnregisterFindGlobalComponentProc + 0001:0001AA50 FindGlobalComponent + 0001:0001AA90 IsUniqueGlobalComponentName + 0001:0001AAB4 InternalReadComponentRes + 0001:0001AB38 BeginGlobalLoading + 0001:0001AB90 NotifyGlobalLoading + 0001:0001ABC0 EndGlobalLoading + 0001:0001AC1C InitComponent + 0001:0001ACC4 InitInheritedComponent + 0001:0001AD88 WriteCollection + 0001:0001ADF4 CollectionsEqual + 0001:0001AF18 TList.Destroy + 0001:0001AF38 TList.Add + 0001:0001AF6C TList.Clear + 0001:0001AF84 TList.Delete + 0001:0001AFE4 ReturnAddr + 0001:0001AFE8 TList.Error + 0001:0001B020 TList.Error + 0001:0001B074 TList.Expand + 0001:0001B08C TList.First + 0001:0001B094 TList.Get + 0001:0001B0BC TList.Grow + 0001:0001B0F0 TList.IndexOf + 0001:0001B110 TList.Insert + 0001:0001B17C TList.Last + 0001:0001B188 TList.Move + 0001:0001B1E0 TList.Put + 0001:0001B234 TList.Remove + 0001:0001B254 TList.SetCapacity + 0001:0001B290 TList.SetCount + 0001:0001B300 TList.Notify + 0001:0001B304 TThreadList.Create + 0001:0001B358 TThreadList.Destroy + 0001:0001B3D4 TThreadList.Add + 0001:0001B45C TThreadList.LockList + 0001:0001B470 TThreadList.Remove + 0001:0001B4C0 TThreadList.UnlockList + 0001:0001B4CC TBits.Destroy + 0001:0001B4FC TBits.Error + 0001:0001B514 Min + 0001:0001B520 TBits.SetSize + 0001:0001B5C4 TBits.SetBit + 0001:0001B5F0 TBits.OpenBit + 0001:0001B668 TPersistent.Destroy + 0001:0001B694 TPersistent.Assign + 0001:0001B6A8 TPersistent.AssignError + 0001:0001B778 TPersistent.AssignTo + 0001:0001B780 TPersistent.DefineProperties + 0001:0001B784 TPersistent.GetNamePath + 0001:0001B834 TPersistent.GetOwner + 0001:0001B838 TInterfacedPersistent.AfterConstruction + 0001:0001B888 TInterfacedPersistent._AddRef + 0001:0001B8A8 TInterfacedPersistent._Release + 0001:0001B8C8 TInterfacedPersistent.QueryInterface + 0001:0001B8F0 GetDesigner + 0001:0001B988 NotifyDesigner + 0001:0001B9EC TCollectionItem.Create + 0001:0001BA24 TCollectionItem.Destroy + 0001:0001BA54 TCollectionItem.Changed + 0001:0001BA78 TCollectionItem.GetIndex + 0001:0001BA90 TCollectionItem.GetDisplayName + 0001:0001BAB8 TCollectionItem.GetNamePath + 0001:0001BB6C TCollectionItem.GetOwner + 0001:0001BB70 TCollectionItem.SetCollection + 0001:0001BB98 TCollectionItem.SetDisplayName + 0001:0001BBA0 TCollectionItem.SetIndex + 0001:0001BBD0 TCollection.Create + 0001:0001BC1C TCollection.Destroy + 0001:0001BC68 TCollection.Add + 0001:0001BC88 TCollection.Assign + 0001:0001BD20 TCollection.BeginUpdate + 0001:0001BD24 TCollection.Changed + 0001:0001BD34 TCollection.Clear + 0001:0001BD9C TCollection.EndUpdate + 0001:0001BDA8 TCollection.GetAttrCount + 0001:0001BDAC TCollection.GetAttr + 0001:0001BDB8 TCollection.GetItemAttr + 0001:0001BDD8 TCollection.GetCount + 0001:0001BDE0 TCollection.GetItem + 0001:0001BDF4 TCollection.GetNamePath + 0001:0001BEBC TCollection.GetPropName + 0001:0001BFD8 TCollection.Insert + 0001:0001BFF4 TCollection.InsertItem + 0001:0001C05C TCollection.RemoveItem + 0001:0001C0B0 TCollection.SetItemName + 0001:0001C0B4 TCollection.Update + 0001:0001C0B8 TCollection.Delete + 0001:0001C0E8 TCollection.Owner + 0001:0001C0F4 TCollection.Added + 0001:0001C0F8 TCollection.Deleting + 0001:0001C0FC TCollection.Notify + 0001:0001C120 TOwnedCollection.Create + 0001:0001C164 TOwnedCollection.GetOwner + 0001:0001C168 TStrings.Destroy + 0001:0001C198 TStrings.Add + 0001:0001C1BC TStrings.AddObject + 0001:0001C1E0 TStrings.AddStrings + 0001:0001C298 TStrings.Assign + 0001:0001C328 TStrings.BeginUpdate + 0001:0001C340 DoWrite + 0001:0001C398 TStrings.DefineProperties + 0001:0001C3E4 TStrings.EndUpdate + 0001:0001C3F8 TStrings.Equals + 0001:0001C4A0 ReturnAddr + 0001:0001C4A4 TStrings.Error + 0001:0001C4DC TStrings.Error + 0001:0001C534 TStrings.Exchange + 0001:0001C61C TStrings.GetCapacity + 0001:0001C624 TStrings.GetObject + 0001:0001C628 TStrings.GetText + 0001:0001C67C TStrings.GetTextStr + 0001:0001C7A4 TStrings.IndexOf + 0001:0001C830 TStrings.IndexOfName + 0001:0001C8F8 TStrings.IndexOfObject + 0001:0001C92C TStrings.InsertObject + 0001:0001C95C TStrings.LoadFromFile + 0001:0001C9B0 TStrings.LoadFromStream + 0001:0001CA5C TStrings.Move + 0001:0001CB0C TStrings.Put + 0001:0001CB3C TStrings.PutObject + 0001:0001CB40 TStrings.ReadData + 0001:0001CBF0 TStrings.SaveToFile + 0001:0001CC48 TStrings.SaveToStream + 0001:0001CCA4 TStrings.SetCapacity + 0001:0001CCA8 TStrings.SetStringsAdapter + 0001:0001CCDC TStrings.SetText + 0001:0001CD2C TStrings.SetTextStr + 0001:0001CDEC TStrings.SetUpdateState + 0001:0001CDF0 TStrings.WriteData + 0001:0001CE74 TStrings.CompareStrings + 0001:0001CE80 TStringList.Destroy + 0001:0001CEDC TStringList.Add + 0001:0001CEE8 TStringList.AddObject + 0001:0001CF4C TStringList.Changed + 0001:0001CF68 TStringList.Changing + 0001:0001CF84 TStringList.Clear + 0001:0001CFC4 TStringList.Delete + 0001:0001D030 TStringList.Exchange + 0001:0001D08C TStringList.ExchangeItems + 0001:0001D0B0 TStringList.Find + 0001:0001D128 TStringList.Get + 0001:0001D15C TStringList.GetCapacity + 0001:0001D160 TStringList.GetCount + 0001:0001D164 TStringList.GetObject + 0001:0001D18C TStringList.Grow + 0001:0001D1C0 TStringList.IndexOf + 0001:0001D1FC TStringList.Insert + 0001:0001D20C TStringList.InsertObject + 0001:0001D260 TStringList.InsertItem + 0001:0001D2D8 TStringList.Put + 0001:0001D334 TStringList.PutObject + 0001:0001D374 TStringList.QuickSort + 0001:0001D408 TStringList.SetCapacity + 0001:0001D424 TStringList.SetSorted + 0001:0001D444 TStringList.SetUpdateState + 0001:0001D45C StringListCompareStrings + 0001:0001D470 TStringList.Sort + 0001:0001D480 TStringList.CustomSort + 0001:0001D4B8 TStringList.CompareStrings + 0001:0001D4D4 TStream.GetPosition + 0001:0001D4F4 TStream.SetPosition + 0001:0001D508 TStream.GetSize + 0001:0001D554 TStream.SetSize + 0001:0001D558 TStream.SetSize64 + 0001:0001D56C TStream.SetSize + 0001:0001D5C0 RaiseException + 0001:0001D60C TStream.Seek + 0001:0001D690 TStream.Seek + 0001:0001D700 TStream.ReadBuffer + 0001:0001D738 TStream.WriteBuffer + 0001:0001D770 TStream.CopyFrom + 0001:0001D864 TStream.ReadComponent + 0001:0001D8C4 TStream.WriteComponent + 0001:0001D8D0 TStream.WriteDescendent + 0001:0001D92C THandleStream.Create + 0001:0001D968 THandleStream.Read + 0001:0001D978 THandleStream.Write + 0001:0001D988 THandleStream.Seek + 0001:0001D9B4 THandleStream.SetSize + 0001:0001D9C8 THandleStream.SetSize + 0001:0001D9F0 TFileStream.Create + 0001:0001DA34 TFileStream.Create + 0001:0001DAFC TFileStream.Destroy + 0001:0001DB30 TCustomMemoryStream.SetPointer + 0001:0001DB38 TCustomMemoryStream.Read + 0001:0001DB70 TCustomMemoryStream.Seek + 0001:0001DB94 TMemoryStream.Destroy + 0001:0001DBC0 TMemoryStream.Clear + 0001:0001DBD8 TMemoryStream.LoadFromStream + 0001:0001DC10 TMemoryStream.SetCapacity + 0001:0001DC38 TMemoryStream.SetSize + 0001:0001DC64 TMemoryStream.Realloc + 0001:0001DCF0 TMemoryStream.Write + 0001:0001DD40 TResourceStream.Create + 0001:0001DD98 Error + 0001:0001DE08 TResourceStream.Initialize + 0001:0001DE74 TResourceStream.Destroy + 0001:0001DEAC TResourceStream.Write + 0001:0001DEC4 TFiler.Create + 0001:0001DF0C TFiler.Destroy + 0001:0001DF34 TFiler.SetRoot + 0001:0001E010 TPropFixup.Create + 0001:0001E068 TPropFixup.MakeGlobalReference + 0001:0001E0B0 TPropFixup.ResolveReference + 0001:0001E0C0 TPropIntfFixup.ResolveReference + 0001:0001E144 FindNestedComponent + 0001:0001E20C AddFinished + 0001:0001E244 AddNotFinished + 0001:0001E28C GlobalFixupReferences + 0001:0001E434 RemoveFixupReferences + 0001:0001E4E0 RemoveFixups + 0001:0001E564 ReadError + 0001:0001E57C PropValueError + 0001:0001E588 PropertyNotFound + 0001:0001E5B4 TReader.Destroy + 0001:0001E5F0 TReader.CheckValue + 0001:0001E614 TReader.DefineProperty + 0001:0001E648 TReader.DefineBinaryProperty + 0001:0001E724 TReader.EndOfList + 0001:0001E738 TReader.Error + 0001:0001E758 TReader.FindMethod + 0001:0001E7C0 RemoveGlobalFixup + 0001:0001E83C TReader.DoFixupReferences + 0001:0001E95C TReader.FlushBuffer + 0001:0001E980 TReader.FreeFixups + 0001:0001E9BC TReader.GetFieldClass + 0001:0001EA50 TReader.GetPosition + 0001:0001EA68 TReader.NextValue + 0001:0001EA78 TReader.PropertyError + 0001:0001EA8C TReader.Read + 0001:0001EAD8 TReader.ReadBuffer + 0001:0001EB14 TReader.ReadBoolean + 0001:0001EB28 TReader.ReadChar + 0001:0001EB80 TReader.ReadCollection + 0001:0001EC2C ComponentCreated + 0001:0001EC4C Recover + 0001:0001ECAC CreateComponent + 0001:0001EDBC SetCompName + 0001:0001EE5C FindExistingComponent + 0001:0001EF00 TReader.ReadComponent + 0001:0001F0D8 TReader.ReadData + 0001:0001F148 TReader.ReadDataInner + 0001:0001F218 TReader.ReadFloat + 0001:0001F258 TReader.ReadSingle + 0001:0001F298 TReader.ReadCurrency + 0001:0001F2E4 TReader.ReadDate + 0001:0001F324 TReader.ReadIdent + 0001:0001F424 TReader.ReadInteger + 0001:0001F490 TReader.ReadInt64 + 0001:0001F4D4 TReader.ReadListBegin + 0001:0001F4DC TReader.ReadListEnd + 0001:0001F4E4 TReader.ReadPrefix + 0001:0001F524 HandleException + 0001:0001F624 PropPathError + 0001:0001F640 TReader.ReadProperty + 0001:0001F820 SetIntIdent + 0001:0001F868 SetObjectIdent + 0001:0001F8A8 SetVariantReference + 0001:0001F904 SetInterfaceReference + 0001:0001F9C4 TReader.ReadPropValue + 0001:0001FCCC FindUniqueName + 0001:0001FD2C TReader.ReadRootComponent + 0001:00020074 TReader.ReadSet + 0001:00020130 TReader.ReadSignature + 0001:00020154 TReader.ReadStr + 0001:00020190 TReader.ReadString + 0001:0002024C TReader.ReadWideString + 0001:00020330 TReader.ReadValue + 0001:00020344 TReader.SkipSetBody + 0001:0002038C SkipList + 0001:000203B4 SkipBinary + 0001:000203E4 SkipCollection + 0001:00020440 TReader.SkipValue + 0001:000205DC TReader.SkipProperty + 0001:00020624 TReader.SkipComponent + 0001:000206CC TReader.FindAncestorComponent + 0001:00020784 TReader.ReferenceName + 0001:0002079C TReader.SetName + 0001:000207C4 TReader.FindComponentClass + 0001:00020838 TReader.SkipBytes + 0001:00020880 ReadCustomVariant + 0001:00020A40 TReader.ReadVariant + 0001:00020C4C TWriter.Destroy + 0001:00020C78 TWriter.AddAncestor + 0001:00020C84 TWriter.DefineProperty + 0001:00020CAC TWriter.DefineBinaryProperty + 0001:00020CD8 TWriter.GetPosition + 0001:00020CE8 TWriter.FlushBuffer + 0001:00020CF0 TWriter.SetPosition + 0001:00020D2C TWriter.SetRoot + 0001:00020D44 TWriter.Write + 0001:00020D90 TWriter.WriteBinary + 0001:00020E18 TWriter.WriteBuffer + 0001:00020E30 TWriter.WriteBoolean + 0001:00020E44 TWriter.WriteChar + 0001:00020E94 TWriter.WriteCollection + 0001:00020F34 FindAncestor + 0001:00020F84 TWriter.WriteComponent + 0001:00021060 TWriter.WriteData + 0001:00021460 TWriter.WriteDescendent + 0001:00021488 TWriter.WriteFloat + 0001:000214AC TWriter.WriteSingle + 0001:000214D0 TWriter.WriteCurrency + 0001:000214F4 TWriter.WriteDate + 0001:00021518 TWriter.WriteIdent + 0001:000215DC TWriter.WriteInteger + 0001:00021650 TWriter.WriteInteger + 0001:000216A8 TWriter.WriteListBegin + 0001:000216B0 TWriter.WriteListEnd + 0001:000216B8 TWriter.WritePrefix + 0001:000216FC TWriter.WriteProperties + 0001:000217C4 AncestorValid + 0001:0002180C WritePropPath + 0001:00021860 WriteSet + 0001:000218F4 WriteIntProp + 0001:00021960 WriteCollectionProp + 0001:00021A04 IsDefaultValue + 0001:00021A60 WriteOrdProp + 0001:00021B34 IsDefaultValue + 0001:00021B8C WriteFloatProp + 0001:00021BD8 IsDefaultValue + 0001:00021C28 WriteInt64Prop + 0001:00021C70 IsDefault + 0001:00021CF8 WriteStrProp + 0001:00021D64 OwnedBy + 0001:00021D7C GetComponentValue + 0001:00021EA4 ObjectAncestorMatch + 0001:00021EEC IsDefault + 0001:00021F4C WriteObjectProp + 0001:0002217C IsDefaultValue + 0001:00022250 WriteInterfaceProp + 0001:00022370 IsDefaultValue + 0001:000223F4 WriteMethodProp + 0001:000224A8 IsDefaultValue + 0001:00022534 WriteVariantProp + 0001:000225A4 TWriter.WriteProperty + 0001:000226BC TWriter.WriteVariant + 0001:00022AB4 TWriter.WritePropName + 0001:00022B08 TWriter.WriteSignature + 0001:00022B18 TWriter.WriteStr + 0001:00022B60 TWriter.WriteMinStr + 0001:00022BF8 TWriter.WriteString + 0001:00022C4C TWriter.WriteWideString + 0001:00022D00 TWriter.WriteValue + 0001:00022D14 BinToHex + 0001:00022D50 HexToBin + 0001:00022DA8 AddThread + 0001:00022E10 RemoveThread + 0001:00022E54 CheckSynchronize + 0001:00022F80 ThreadProc + 0001:00023020 TThread.Create + 0001:000230F0 TThread.Destroy + 0001:00023158 TThread.AfterConstruction + 0001:00023164 TThread.CheckThreadError + 0001:000231E0 TThread.CheckThreadError + 0001:000231F8 TThread.CallOnTerminate + 0001:0002320C TThread.DoTerminate + 0001:00023220 TThread.SetPriority + 0001:0002324C TThread.Synchronize + 0001:00023388 TThread.Resume + 0001:000233B0 TThread.Terminate + 0001:000233B8 TThread.WaitFor + 0001:00023450 TComponent.Create + 0001:0002349C TComponent.Destroy + 0001:00023514 TComponent.BeforeDestruction + 0001:00023520 TComponent.FreeNotification + 0001:00023574 TComponent.ReadLeft + 0001:00023588 TComponent.ReadTop + 0001:0002359C TComponent.WriteLeft + 0001:000235A8 TComponent.WriteTop + 0001:000235B4 TComponent.Insert + 0001:000235E0 TComponent.Remove + 0001:00023608 TComponent.InsertComponent + 0001:00023660 TComponent.RemoveComponent + 0001:00023698 TComponent.DestroyComponents + 0001:000236F0 TComponent.Destroying + 0001:0002372C TComponent.RemoveNotification + 0001:00023750 TComponent.RemoveFreeNotification + 0001:0002376C TComponent.Notification + 0001:000237C8 TComponent.DefineProperties + 0001:00023850 TComponent.HasParent + 0001:00023854 TComponent.GetChildren + 0001:0002385C TComponent.GetChildOwner + 0001:00023860 TComponent.GetChildParent + 0001:00023864 TComponent.GetNamePath + 0001:00023878 TComponent.GetOwner + 0001:0002387C TComponent.SetChildOrder + 0001:00023880 TComponent.GetParentComponent + 0001:00023884 TComponent.SetParentComponent + 0001:00023888 TComponent.Updating + 0001:00023894 TComponent.Updated + 0001:000238A0 TComponent.Loaded + 0001:000238AC TComponent.PaletteCreated + 0001:000238B0 TComponent.ReadState + 0001:000238B8 TComponent.WriteState + 0001:000238C0 TComponent.ValidateRename + 0001:00023940 TComponent.ValidateContainer + 0001:00023954 TComponent.ValidateInsert + 0001:00023958 TComponent.FindComponent + 0001:000239A8 TComponent.SetName + 0001:00023A34 TComponent.ChangeName + 0001:00023A48 TComponent.GetComponent + 0001:00023A74 TComponent.GetComponentCount + 0001:00023A84 TComponent.SetComponentIndex + 0001:00023AD8 TComponent.SetDesigning + 0001:00023B28 TComponent.SetReference + 0001:00023B70 TComponent.ExecuteAction + 0001:00023B98 TComponent.UpdateAction + 0001:00023BC0 TComponent.SafeCallException + 0001:00023BD8 TComponent.UpdateRegistry + 0001:00023BE0 TComponent.QueryInterface + 0001:00023C20 TComponent._AddRef + 0001:00023C40 TComponent._Release + 0001:00023C60 TComponent.IntfGetComponent + 0001:00023C64 TBasicActionLink.Create + 0001:00023CA8 TBasicActionLink.AssignClient + 0001:00023CAC TBasicActionLink.Destroy + 0001:00023CE0 TBasicActionLink.Change + 0001:00023CF8 TBasicActionLink.Execute + 0001:00023D34 TBasicActionLink.SetAction + 0001:00023D60 TBasicActionLink.IsOnExecuteLinked + 0001:00023D64 TBasicActionLink.SetOnExecute + 0001:00023D6C TBasicActionLink.Update + 0001:00023D78 TBasicAction.Create + 0001:00023DBC TBasicAction.Destroy + 0001:00023E14 TBasicAction.HandlesTarget + 0001:00023E18 TBasicAction.ExecuteTarget + 0001:00023E1C TBasicAction.Notification + 0001:00023E44 TBasicAction.UpdateTarget + 0001:00023E48 TBasicAction.Execute + 0001:00023E64 TBasicAction.Update + 0001:00023E80 TBasicAction.SetOnExecute + 0001:00023EDC TBasicAction.Change + 0001:00023EF0 TBasicAction.RegisterChanges + 0001:00023EFC TBasicAction.UnRegisterChanges + 0001:00023F3C TStreamAdapter.Create + 0001:00023F84 TStreamAdapter.Destroy + 0001:00023FBC TStreamAdapter.Read + 0001:00024024 TStreamAdapter.Write + 0001:0002408C TStreamAdapter.Seek + 0001:00024110 TStreamAdapter.SetSize + 0001:00024174 TStreamAdapter.CopyTo + 0001:00024374 TStreamAdapter.Commit + 0001:00024380 TStreamAdapter.Revert + 0001:0002438C TStreamAdapter.LockRegion + 0001:00024398 TStreamAdapter.UnlockRegion + 0001:000243A4 TStreamAdapter.Stat + 0001:00024420 TStreamAdapter.Clone + 0001:00024438 FreeIntConstList + 0001:000244A4 ModuleUnload + 0001:000244AC StdWndProc + 0001:000244CC CalcJmpOffset + 0001:000244D4 MakeObjectInstance + 0001:0002456C FreeObjectInstance + 0001:00024590 AllocateHWnd + 0001:00024644 DeallocateHWnd + 0001:0002466C Finalization + 0001:00024714 Classes + 0001:00024A08 Finalization + 0001:00024A38 Consts + 0001:000256F0 InternalDeletePalette + 0001:00025764 GetHashCode + 0001:00025778 TResourceManager.Create + 0001:000257B4 TResourceManager.Destroy + 0001:000257D8 TResourceManager.Lock + 0001:000257E4 TResourceManager.Unlock + 0001:000257F0 TResourceManager.AllocResource + 0001:000258D4 TResourceManager.FreeResource + 0001:00025984 TResourceManager.ChangeResource + 0001:000259FC TResourceManager.AssignResource + 0001:00025A68 ClearColor + 0001:00025AD4 PaletteChanged + 0001:00025FC0 ColorToRGB + 0001:00025FD0 ColorToIdent + 0001:00025FE0 IdentToColor + 0001:00025FF0 TGraphicsObject.Changed + 0001:00026004 TGraphicsObject.Lock + 0001:00026014 TGraphicsObject.Unlock + 0001:000261D8 CharsetToIdent + 0001:000261E8 IdentToCharset + 0001:000261F8 GetFontData + 0001:000262AC TFont.Create + 0001:00026300 TFont.Destroy + 0001:00026328 TFont.Changed + 0001:00026344 TFont.Assign + 0001:00026418 TFont.GetData + 0001:00026430 TFont.SetData + 0001:00026480 TFont.SetColor + 0001:00026494 TFont.GetHandle + 0001:0002663C TFont.SetHandle + 0001:00026660 TFont.GetHeight + 0001:00026668 TFont.SetHeight + 0001:00026690 TFont.GetName + 0001:000266A8 TFont.SetName + 0001:00026704 TFont.GetSize + 0001:00026720 TFont.SetSize + 0001:00026740 TFont.GetStyle + 0001:0002674C TFont.SetStyle + 0001:00026778 TFont.GetPitch + 0001:00026780 TFont.SetPitch + 0001:000267A8 TFont.GetCharset + 0001:000267B0 TFont.SetCharset + 0001:000267D8 TPen.Create + 0001:0002681C TPen.Destroy + 0001:00026844 TPen.Assign + 0001:000268FC TPen.GetData + 0001:00026914 TPen.SetData + 0001:00026964 TPen.GetColor + 0001:0002696C TPen.SetColor + 0001:00026994 TPen.GetHandle + 0001:00026A2C TPen.SetMode + 0001:00026A40 TPen.GetStyle + 0001:00026A48 TPen.SetStyle + 0001:00026A70 TPen.GetWidth + 0001:00026A78 TPen.SetWidth + 0001:00026AA4 TBrush.Create + 0001:00026AE4 TBrush.Destroy + 0001:00026B0C TBrush.Assign + 0001:00026BB4 TBrush.GetData + 0001:00026BD0 TBrush.SetData + 0001:00026C20 TBrush.SetBitmap + 0001:00026C44 TBrush.GetColor + 0001:00026C4C TBrush.SetColor + 0001:00026C80 TBrush.GetHandle + 0001:00026D60 TBrush.GetStyle + 0001:00026D68 TBrush.SetStyle + 0001:00026D9C TCanvas.Create + 0001:00026E60 TCanvas.Destroy + 0001:00026EBC TCanvas.CopyRect + 0001:00026F44 TCanvas.Draw + 0001:00026FF0 TCanvas.FillRect + 0001:0002702C TCanvas.FrameRect + 0001:00027068 TCanvas.LineTo + 0001:000270A0 TCanvas.Lock + 0001:000270C8 TCanvas.MoveTo + 0001:000270F4 TCanvas.Polyline + 0001:0002712C TCanvas.Rectangle + 0001:00027174 TCanvas.Refresh + 0001:0002717C TCanvas.StretchDraw + 0001:000271B8 TCanvas.GetCanvasOrientation + 0001:000271E4 TCanvas.TextOut + 0001:00027270 TCanvas.TextExtent + 0001:000272B4 TCanvas.TextWidth + 0001:000272D0 TCanvas.TextHeight + 0001:000272F0 TCanvas.TryLock + 0001:0002734C TCanvas.Unlock + 0001:00027374 TCanvas.SetFont + 0001:00027384 TCanvas.SetPen + 0001:00027390 TCanvas.SetBrush + 0001:0002739C TCanvas.GetPenPos + 0001:000273C0 TCanvas.SetPenPos + 0001:000273E0 TCanvas.GetPixel + 0001:0002740C TCanvas.SetPixel + 0001:00027454 TCanvas.GetHandle + 0001:00027474 TCanvas.DeselectHandles + 0001:000274D0 TCanvas.CreateHandle + 0001:000274D4 TCanvas.SetHandle + 0001:00027528 TCanvas.RequiredState + 0001:0002759C TCanvas.Changing + 0001:000275B0 TCanvas.Changed + 0001:000275C4 TCanvas.CreateFont + 0001:000275F0 TCanvas.CreatePen + 0001:00027620 TCanvas.CreateBrush + 0001:0002769C TCanvas.FontChanged + 0001:000276BC TCanvas.PenChanged + 0001:000276DC TCanvas.BrushChanged + 0001:000276FC InvalidOperation + 0001:00027714 InvalidGraphic + 0001:0002772C InvalidBitmap + 0001:00027738 InvalidIcon + 0001:00027744 OutOfResources + 0001:00027798 GDIError + 0001:00027840 GDICheck + 0001:00027850 DupBits + 0001:000279B0 GetDInColors + 0001:000279D0 BytesPerScanline + 0001:000279E4 TransparentStretchBlt + 0001:00027C78 RGBTripleToQuad + 0001:00027CB0 RGBQuadToTriple + 0001:00027D28 ByteSwapColors + 0001:00027D80 CreateSystemPalette + 0001:00027E98 SystemPaletteOverride + 0001:00027F30 PaletteFromDIBColorTable + 0001:00027FD4 PaletteToDIBColorTable + 0001:00028028 TwoBitsFromDIB + 0001:000281E4 AdjustColor + 0001:000281F0 BetterSize + 0001:00028280 ReadIcon + 0001:00028588 InitializeBitmapInfoHeader + 0001:0002866C InternalGetDIBSizes + 0001:000286D0 GetDIBSizes + 0001:000286D8 InternalGetDIB + 0001:00028788 GetDIB + 0001:0002879C WinError + 0001:000287A0 CheckBool + 0001:000287AC WriteIcon + 0001:000289A8 TGraphic.Create + 0001:000289E0 TGraphic.Changed + 0001:000289F8 DoWrite + 0001:00028A50 TGraphic.DefineProperties + 0001:00028A9C TGraphic.Equals + 0001:00028BE8 TGraphic.GetPalette + 0001:00028BEC TGraphic.GetTransparent + 0001:00028BF0 TGraphic.LoadFromFile + 0001:00028C44 TGraphic.Progress + 0001:00028C6C TGraphic.ReadData + 0001:00028C78 TGraphic.SaveToFile + 0001:00028CD0 TGraphic.SetPalette + 0001:00028CD4 TGraphic.SetTransparent + 0001:00028CE4 TGraphic.WriteData + 0001:00028D8C FreeMemoryContexts + 0001:00028E38 DeselectBitmap + 0001:00028EB4 TBitmapCanvas.Create + 0001:00028EF0 TBitmapCanvas.Destroy + 0001:00028F1C TBitmapCanvas.FreeContext + 0001:00028FBC TBitmapCanvas.CreateHandle + 0001:000290A8 TSharedImage.Reference + 0001:000290AC TSharedImage.Release + 0001:000290CC TBitmapImage.Destroy + 0001:00029128 TBitmapImage.FreeHandle + 0001:00029174 UpdateDIBColorTable + 0001:00029230 FixupBitFields + 0001:0002927C CopyBitmap + 0001:000298E0 CopyPalette + 0001:00029944 CopyBitmapAsMask + 0001:00029B50 TBitmap.Create + 0001:00029BB8 TBitmap.Destroy + 0001:00029BF4 TBitmap.Assign + 0001:00029CE4 TBitmap.CopyImage + 0001:00029DA4 TBitmap.Changing + 0001:00029DC8 TBitmap.Changed + 0001:00029DD4 TBitmap.Dormant + 0001:00029E48 TBitmap.Draw + 0001:0002A098 TBitmap.FreeImage + 0001:0002A0FC TBitmap.GetEmpty + 0001:0002A118 TBitmap.GetCanvas + 0001:0002A160 TBitmap.GetHandle + 0001:0002A184 TBitmap.GetHandleType + 0001:0002A1B0 TBitmap.GetHeight + 0001:0002A1C0 TBitmap.GetMaskHandle + 0001:0002A1D4 TBitmap.GetMonochrome + 0001:0002A1F0 TBitmap.GetPalette + 0001:0002A204 TBitmap.GetTransparentColor + 0001:0002A24C TBitmap.GetWidth + 0001:0002A254 TBitmap.DIBNeeded + 0001:0002A2C8 TBitmap.FreeContext + 0001:0002A2D8 TBitmap.HandleNeeded + 0001:0002A378 TBitmap.MaskHandleNeeded + 0001:0002A3D8 TBitmap.PaletteNeeded + 0001:0002A490 TBitmap.LoadFromClipboardFormat + 0001:0002A514 TBitmap.LoadFromStream + 0001:0002A538 TBitmap.NewImage + 0001:0002A638 TBitmap.ReadData + 0001:0002A660 TBitmap.ReadDIB + 0001:0002ABC8 TBitmap.ReadStream + 0001:0002AC38 TBitmap.SetHandle + 0001:0002ACFC TBitmap.SetHandleType + 0001:0002AE34 TBitmap.SetHeight + 0001:0002AE88 TBitmap.SetMonochrome + 0001:0002AF08 TBitmap.SetPalette + 0001:0002AFDC TBitmap.SetWidth + 0001:0002B030 TBitmap.WriteData + 0001:0002B038 TBitmap.WriteStream + 0001:0002B2F0 TBitmap.SaveToStream + 0001:0002B2F8 TBitmap.SaveToClipboardFormat + 0001:0002B398 TIconImage.Destroy + 0001:0002B3C8 TIconImage.FreeHandle + 0001:0002B3E0 TIcon.Create + 0001:0002B434 TIcon.Destroy + 0001:0002B464 TIcon.Assign + 0001:0002B4C4 TIcon.Draw + 0001:0002B504 TIcon.GetEmpty + 0001:0002B51C TIcon.GetHandle + 0001:0002B530 TIcon.GetHeight + 0001:0002B544 TIcon.GetWidth + 0001:0002B558 TIcon.HandleNeeded + 0001:0002B5D0 TIcon.ImageNeeded + 0001:0002B684 TIcon.LoadFromStream + 0001:0002B73C TIcon.NewImage + 0001:0002B7B0 TIcon.SetHandle + 0001:0002B7C8 TIcon.SetHeight + 0001:0002B7E0 TIcon.SetTransparent + 0001:0002B7E4 TIcon.SetWidth + 0001:0002B7FC TIcon.SaveToStream + 0001:0002B828 TIcon.LoadFromClipboardFormat + 0001:0002B83C TIcon.SaveToClipboardFormat + 0001:0002B850 InitScreenLogPixels + 0001:0002B888 GetDefFontCharSet + 0001:0002B8CC InitDefFontData + 0001:0002B998 TPatternManager.Create + 0001:0002B9D0 TPatternManager.Destroy + 0001:0002B9FC TPatternManager.Lock + 0001:0002BA08 TPatternManager.Unlock + 0001:0002BA14 TPatternManager.AllocPattern + 0001:0002BAC8 TPatternManager.CreateBitmap + 0001:0002BBC8 TPatternManager.FreePatterns + 0001:0002BC40 AllocPatternBitmap + 0001:0002BC78 Finalization + 0001:0002BD4C Graphics + 0001:0002BE48 Min + 0001:0002BE50 Max + 0001:0002BE58 Finalization + 0001:0002BE88 Math + 0001:0002BFC0 TObjectList.Create + 0001:0002BFFC TObjectList.GetItem + 0001:0002C010 TObjectList.Insert + 0001:0002C018 TObjectList.Notify + 0001:0002C044 TOrderedList.Pop + 0001:0002C04C TOrderedList.Push + 0001:0002C05C TOrderedList.Create + 0001:0002C0A0 TOrderedList.Destroy + 0001:0002C0D0 TOrderedList.PeekItem + 0001:0002C0E4 TOrderedList.PopItem + 0001:0002C104 TStack.PushItem + 0001:0002C110 Finalization + 0001:0002C140 Contnrs + 0001:0002C148 InitCommonControls + 0001:0002C150 InitComCtl + 0001:0002C1B0 InitCommonControlsEx + 0001:0002C1E4 ImageList_Create + 0001:0002C1EC ImageList_Destroy + 0001:0002C1F4 ImageList_GetImageCount + 0001:0002C1FC ImageList_Add + 0001:0002C204 ImageList_ReplaceIcon + 0001:0002C20C ImageList_SetBkColor + 0001:0002C214 ImageList_GetBkColor + 0001:0002C21C ImageList_AddIcon + 0001:0002C228 IndexToOverlayMask + 0001:0002C22C ImageList_Draw + 0001:0002C234 ImageList_DrawEx + 0001:0002C23C ImageList_Remove + 0001:0002C244 ImageList_GetIcon + 0001:0002C24C ImageList_BeginDrag + 0001:0002C254 ImageList_EndDrag + 0001:0002C25C ImageList_DragEnter + 0001:0002C264 ImageList_DragLeave + 0001:0002C26C ImageList_DragMove + 0001:0002C274 ImageList_SetDragCursorImage + 0001:0002C27C ImageList_DragShowNolock + 0001:0002C284 ImageList_GetDragImage + 0001:0002C28C ImageList_Read + 0001:0002C294 ImageList_Write + 0001:0002C29C ImageList_GetIconSize + 0001:0002C2A4 ImageList_SetIconSize + 0001:0002C2AC ListView_SetBkColor + 0001:0002C2C4 ListView_SetImageList + 0001:0002C2E0 ListView_GetItemCount + 0001:0002C2F0 IndexToStateImageMask + 0001:0002C2F4 ListView_GetItem + 0001:0002C30C ListView_SetItem + 0001:0002C324 ListView_InsertItem + 0001:0002C33C ListView_DeleteItem + 0001:0002C354 ListView_DeleteAllItems + 0001:0002C368 ListView_GetNextItem + 0001:0002C38C ListView_FindItem + 0001:0002C39C ListView_GetItemRect + 0001:0002C3D8 ListView_HitTest + 0001:0002C3E8 ListView_RedrawItems + 0001:0002C404 ListView_Arrange + 0001:0002C41C ListView_GetEditControl + 0001:0002C430 ListView_SetColumn + 0001:0002C44C ListView_InsertColumn + 0001:0002C45C ListView_DeleteColumn + 0001:0002C474 ListView_GetColumnWidth + 0001:0002C48C ListView_SetColumnWidth + 0001:0002C4B0 ListView_CreateDragImage + 0001:0002C4CC ListView_SetTextColor + 0001:0002C4E4 ListView_SetTextBkColor + 0001:0002C4FC ListView_GetTopIndex + 0001:0002C50C ListView_GetOrigin + 0001:0002C524 ListView_Update + 0001:0002C544 ListView_SetItemState + 0001:0002C574 ListView_GetItemState + 0001:0002C584 ListView_GetCheckState + 0001:0002C5A4 ListView_SetCheckState + 0001:0002C5D0 ListView_SetItemText + 0001:0002C600 ListView_SetItemCount + 0001:0002C610 ListView_SetItemCountEx + 0001:0002C620 ListView_SortItems + 0001:0002C63C ListView_GetSelectedCount + 0001:0002C64C ListView_SetExtendedListViewStyle + 0001:0002C664 ListView_SetColumnOrderArray + 0001:0002C680 ListView_GetColumnOrderArray + 0001:0002C69C ListView_SetWorkAreas + 0001:0002C6B8 Finalization + 0001:0002C6E8 CommCtrl + 0001:0002C6F0 InitAnApi + 0001:0002C7D8 _GetSystemMetrics + 0001:0002C860 xMonitorFromRect + 0001:0002C8F0 xMonitorFromWindow + 0001:0002C988 xMonitorFromPoint + 0001:0002CA20 xGetMonitorInfo + 0001:0002CAF4 xGetMonitorInfoA + 0001:0002CBC8 xGetMonitorInfoW + 0001:0002CC9C xEnumDisplayMonitors + 0001:0002CDCC InitMultiMonStubs + 0001:0002CE38 Finalization + 0001:0002CE68 MultiMon + 0001:0002CE78 Finalization + 0001:0002CEA8 Imm + 0001:0002D274 RegisterViewer + 0001:0002D30C GetHelpSystem + 0001:0002D370 THelpViewerNode.Create + 0001:0002D3EC THelpManager.Create + 0001:0002D460 THelpManager.RegisterViewer + 0001:0002D598 THelpManager.UnloadAllViewers + 0001:0002D5E0 THelpManager.DoSoftShutDown + 0001:0002D610 THelpManager.DoTableOfContents + 0001:0002D7B0 THelpManager.CallSpecialWinHelp + 0001:0002D8B8 THelpManager.ShowHelp + 0001:0002DACC THelpManager.ShowContextHelp + 0001:0002DBE0 THelpManager.ShowTableOfContents + 0001:0002DBE8 THelpManager.ShowTopicHelp + 0001:0002DCE4 THelpManager.AssignHelpSelector + 0001:0002DD48 THelpManager.Hook + 0001:0002DE04 THelpManager.GetHandle + 0001:0002DE08 THelpManager.GetHelpFile + 0001:0002DE1C THelpManager.Release + 0001:0002DEAC THelpManager.Destroy + 0001:0002DF00 Finalization + 0001:0002DF40 HelpIntfs + 0001:0002DF48 ClosePrinter + 0001:0002DF50 DocumentProperties + 0001:0002DF58 EnumPrinters + 0001:0002DF60 OpenPrinter + 0001:0002DF68 Finalization + 0001:0002DF98 WinSpool + 0001:0002E060 FetchStr + 0001:0002E094 RaiseError + 0001:0002E0AC AbortProc + 0001:0002E150 TPrinterDevice.Create + 0001:0002E1B0 TPrinterDevice.IsEqual + 0001:0002E324 TPrinterCanvas.Create + 0001:0002E360 TPrinterCanvas.CreateHandle + 0001:0002E384 TPrinterCanvas.Changing + 0001:0002E3A4 TPrinterCanvas.UpdateFont + 0001:0002E3EC TPrinter.Create + 0001:0002E428 TPrinter.Destroy + 0001:0002E4A4 TPrinter.SetState + 0001:0002E5D0 TPrinter.CheckPrinting + 0001:0002E640 TPrinter.BeginDoc + 0001:0002E6C8 TPrinter.EndDoc + 0001:0002E6FC TPrinter.NewPage + 0001:0002E72C TPrinter.SetPrinterCapabilities + 0001:0002E768 TPrinter.SetPrinter + 0001:0002E9B0 TPrinter.GetCanvas + 0001:0002E9D0 TPrinter.GetHandle + 0001:0002E9E4 TPrinter.GetPageHeight + 0001:0002EA00 TPrinter.GetPageWidth + 0001:0002EA1C TPrinter.GetPrinterIndex + 0001:0002EA34 TPrinter.GetPrinters + 0001:0002EC74 TPrinter.SetToDefaultPrinter + 0001:0002EE74 TPrinter.FreePrinters + 0001:0002EEB0 TPrinter.FreeFonts + 0001:0002EEBC Printer + 0001:0002EEDC Finalization + 0001:0002EF18 Printers + 0001:0002EF20 FlatSB_SetScrollProp + 0001:0002EF54 InitializeFlatSB + 0001:0002EF7C InitFlatSB + 0001:0002F200 Finalization + 0001:0002F230 FlatSB + 0001:000331D8 HasPopup + 0001:00033400 TCustomGroupBox.Create + 0001:0003345C TCustomGroupBox.AdjustClientRect + 0001:000334B8 TCustomGroupBox.CreateParams + 0001:000334C8 TCustomGroupBox.Paint + 0001:000336D4 TCustomGroupBox.CMDialogChar + 0001:00033754 TCustomGroupBox.CMTextChanged + 0001:00033768 TCustomGroupBox.CMCtl3DChanged + 0001:00033784 TCustomGroupBox.WMSize + 0001:00033798 TCustomEdit.Create + 0001:00033840 TCustomEdit.DoSetMaxLength + 0001:00033860 TCustomEdit.SetAutoSize + 0001:00033874 TCustomEdit.SetBorderStyle + 0001:00033898 TCustomEdit.SetCharCase + 0001:000338AC TCustomEdit.SetHideSelection + 0001:000338C0 TCustomEdit.SetMaxLength + 0001:000338F0 TCustomEdit.SetOEMConvert + 0001:00033904 TCustomEdit.GetModified + 0001:0003393C TCustomEdit.SetModified + 0001:00033974 TCustomEdit.SetPasswordChar + 0001:000339FC TCustomEdit.SetReadOnly + 0001:00033A38 TCustomEdit.GetSelStart + 0001:00033A5C TCustomEdit.SetSelStart + 0001:00033A7C TCustomEdit.GetSelLength + 0001:00033AAC TCustomEdit.SetSelLength + 0001:00033B10 TCustomEdit.Clear + 0001:00033B2C TCustomEdit.SelectAll + 0001:00033B48 TCustomEdit.GetSelTextBuf + 0001:00033BE4 TCustomEdit.GetSelText + 0001:00033C80 TCustomEdit.CreateParams + 0001:00033D3C TCustomEdit.CreateWindowHandle + 0001:00033DAC TCustomEdit.CreateWnd + 0001:00033E50 TCustomEdit.DestroyWnd + 0001:00033E6C TCustomEdit.UpdateHeight + 0001:00033EA8 TCustomEdit.AdjustHeight + 0001:00033F50 TCustomEdit.Change + 0001:00033F74 TCustomEdit.DefaultHandler + 0001:00033FAC TCustomEdit.WMSetFont + 0001:00033FEC TCustomEdit.CMCtl3DChanged + 0001:00034020 TCustomEdit.CMFontChanged + 0001:00034048 TCustomEdit.CNCommand + 0001:00034068 TCustomEdit.CMEnter + 0001:000340A4 TCustomEdit.CMTextChanged + 0001:000340DC TCustomEdit.WMContextMenu + 0001:000340F8 TMemoStrings.GetCount + 0001:00034168 TMemoStrings.Get + 0001:000341AC TMemoStrings.Put + 0001:00034220 TMemoStrings.Insert + 0001:0003432C TMemoStrings.Delete + 0001:000343BC TMemoStrings.Clear + 0001:000343CC TMemoStrings.SetUpdateState + 0001:0003441C TMemoStrings.GetTextStr + 0001:00034430 TMemoStrings.SetTextStr + 0001:00034508 TCustomMemo.Create + 0001:0003458C TCustomMemo.Destroy + 0001:000345BC TCustomMemo.CreateParams + 0001:00034620 TCustomMemo.CreateWindowHandle + 0001:000346F4 TCustomMemo.GetCaretPos + 0001:00034750 TCustomMemo.SetCaretPos + 0001:0003478C TCustomMemo.GetControlsAlignment + 0001:00034794 TCustomMemo.Loaded + 0001:000347AC TCustomMemo.SetAlignment + 0001:000347C0 TCustomMemo.SetScrollBars + 0001:000347D4 TCustomMemo.SetWordWrap + 0001:000347E8 TCustomMemo.WMGetDlgCode + 0001:0003481C TCustomMemo.WMNCDestroy + 0001:00034824 TCustomMemo.KeyPress + 0001:00034848 TCustomComboBoxStrings.GetCount + 0001:00034864 TCustomComboBoxStrings.GetObject + 0001:000348DC TCustomComboBoxStrings.PutObject + 0001:00034900 TCustomComboBoxStrings.Get + 0001:00034944 TCustomComboBoxStrings.Clear + 0001:000349B4 TCustomComboBoxStrings.Delete + 0001:000349D4 TCustomComboBoxStrings.IndexOf + 0001:000349FC TCustomComboBoxStrings.SetUpdateState + 0001:00034A30 TComboBoxStrings.Add + 0001:00034AB4 TComboBoxStrings.Insert + 0001:00034B34 TCustomCombo.Create + 0001:00034C28 TCustomCombo.Destroy + 0001:00034C84 TCustomCombo.Clear + 0001:00034CB0 TCustomCombo.DestroyWindowHandle + 0001:00034CD4 TCustomCombo.SelectAll + 0001:00034CF4 TCustomCombo.GetDroppedDown + 0001:00034D18 TCustomCombo.SetDroppedDown + 0001:00034D60 TCustomCombo.GetItemIndex + 0001:00034D8C TCustomCombo.SetItemIndex + 0001:00034DC8 TCustomCombo.SetMaxLength + 0001:00034E08 TCustomCombo.SetItemHeight + 0001:00034E18 TCustomCombo.WMCreate + 0001:00034E3C TCustomCombo.WMDrawItem + 0001:00034E50 TCustomCombo.WMMeasureItem + 0001:00034E64 TCustomCombo.WMDeleteItem + 0001:00034E78 TCustomCombo.WMGetDlgCode + 0001:00034E9C TCustomCombo.CMCancelMode + 0001:00034EB0 TCustomCombo.CMCtl3DChanged + 0001:00034ED4 TCustomComboBox.CMParentColorChanged + 0001:00034EFC TCustomCombo.EditWndProc + 0001:00034FF4 TCustomCombo.ListWndProc + 0001:00035014 TCustomComboBox.SetCharCase + 0001:00035028 TCustomCombo.ComboWndProc + 0001:00035304 TCustomCombo.WndProc + 0001:00035414 TCustomCombo.CNCommand + 0001:00035580 TCustomCombo.Change + 0001:000355A4 TCustomComboBox.DrawItem + 0001:00035660 TCustomCombo.DropDown + 0001:00035680 TCustomCombo.Loaded + 0001:000356A8 TCustomCombo.Focused + 0001:000356DC TCustomCombo.CloseUp + 0001:000356FC TCustomCombo.Select + 0001:00035728 TCustomCombo.CreateWnd + 0001:00035760 TCustomCombo.AdjustDropDown + 0001:0003581C TCustomCombo.SetItems + 0001:00035840 TCustomCombo.ClearSelection + 0001:0003584C TCustomCombo.CopySelection + 0001:000358D8 TCustomCombo.DeleteSelected + 0001:00035904 TCustomCombo.GetCount + 0001:00035910 TCustomCombo.SetDropDownCount + 0001:00035918 TCustomCombo.AddItem + 0001:00035970 TCustomComboBox.Create + 0001:000359E8 TCustomComboBox.Destroy + 0001:00035A24 TCustomComboBox.SetSorted + 0001:00035A38 TCustomComboBox.SetStyle + 0001:00035A78 TCustomComboBox.GetItemHt + 0001:00035A9C TCustomComboBox.CreateParams + 0001:00035B00 TCustomComboBox.CreateWnd + 0001:00035C40 TCustomComboBox.DestroyWnd + 0001:00035C90 TCustomComboBox.WMEraseBkgnd + 0001:00035CE4 HasSelectedText + 0001:00035D10 DeleteSelectedText + 0001:00035DD8 TCustomComboBox.KeyPress + 0001:000361A0 TCustomComboBox.SelectItem + 0001:00036334 TCustomComboBox.MeasureItem + 0001:00036354 TCustomComboBox.CNDrawItem + 0001:0003642C TCustomComboBox.CNMeasureItem + 0001:00036458 TCustomComboBox.WMLButtonDown + 0001:000364D0 TCustomComboBox.WndProc + 0001:00036518 TCustomComboBox.GetItemCount + 0001:00036524 TCustomComboBox.GetItemsClass + 0001:0003652C TCustomComboBox.WMPaint + 0001:00036764 TCustomComboBox.WMNCCalcSize + 0001:00036768 TButtonActionLink.AssignClient + 0001:0003678C TButtonActionLink.IsCheckedLinked + 0001:000367C4 TButtonActionLink.SetChecked + 0001:00036828 TButtonControl.Create + 0001:0003687C TButtonControl.ActionChange + 0001:000368C4 TButtonControl.GetActionLinkClass + 0001:000368CC TButtonControl.GetChecked + 0001:000368D0 TButtonControl.IsCheckedStored + 0001:000368F0 TButtonControl.SetChecked + 0001:000368F4 TButtonControl.WndProc + 0001:0003696C TButton.Create + 0001:000369D0 TButton.Click + 0001:000369F4 TButton.UseRightToLeftAlignment + 0001:000369F8 TButton.SetButtonStyle + 0001:00036A4C TButton.SetDefault + 0001:00036A80 TButton.CreateParams + 0001:00036ABC TButton.CreateWnd + 0001:00036AD4 TButton.CNCommand + 0001:00036AE8 TButton.CMDialogKey + 0001:00036B58 TButton.CMDialogChar + 0001:00036BDC TButton.CMFocusChanged + 0001:00036C30 TButton.WMEraseBkgnd + 0001:00036C44 TCustomCheckBox.Create + 0001:00036CB0 TCustomCheckBox.GetControlsAlignment + 0001:00036CDC TCustomCheckBox.Toggle + 0001:00036D1C TCustomCheckBox.Click + 0001:00036D30 TCustomCheckBox.GetChecked + 0001:00036D3C TCustomCheckBox.SetAlignment + 0001:00036D50 TCustomCheckBox.SetChecked + 0001:00036D64 TCustomCheckBox.SetState + 0001:00036DB8 TCustomCheckBox.CreateParams + 0001:00036E14 TCustomCheckBox.CreateWnd + 0001:00036E40 TCustomCheckBox.WMSize + 0001:00036E54 TCustomCheckBox.CMCtl3DChanged + 0001:00036E5C TCustomCheckBox.CMDialogChar + 0001:00036EF8 TCustomCheckBox.CNCommand + 0001:00036F08 TCustomStaticText.Create + 0001:00036F78 TCustomStaticText.CreateParams + 0001:00036FF8 TCustomStaticText.CMDialogChar + 0001:00037094 TCustomStaticText.CMFontChanged + 0001:000370A8 TCustomStaticText.CMTextChanged + 0001:000370C4 TCustomStaticText.Loaded + 0001:000370D8 TCustomStaticText.AdjustBounds + 0001:000371C0 TCustomStaticText.Notification + 0001:000371F0 TCustomStaticText.SetAlignment + 0001:00037204 TCustomStaticText.SetAutoSize + 0001:0003721C TCustomStaticText.SetBorderStyle + 0001:00037230 TCustomStaticText.SetFocusControl + 0001:00037244 TCustomStaticText.SetShowAccelChar + 0001:00037258 Finalization + 0001:00037288 StdCtrls + 0001:00037290 Shell_NotifyIcon + 0001:00037298 Finalization + 0001:000372C8 ShellAPI + 0001:000372D0 Finalization + 0001:00037300 RegStr + 0001:00037308 Finalization + 0001:00037338 WinInet + 0001:00037340 Finalization + 0001:00037370 UrlMon + 0001:00037378 Finalization + 0001:000373A8 ShlObj + 0001:000373B0 Finalization + 0001:000373E0 CommDlg + 0001:00037F60 DoRect + 0001:00038024 Frame3D + 0001:00038084 TTimer.Create + 0001:000380D4 TTimer.Destroy + 0001:0003810C TTimer.WndProc + 0001:00038180 TTimer.UpdateTimer + 0001:0003820C TTimer.SetEnabled + 0001:0003821C TTimer.SetInterval + 0001:0003822C TTimer.SetOnTimer + 0001:00038244 TTimer.Timer + 0001:00038258 TCustomPanel.Create + 0001:000382F0 TCustomPanel.CreateParams + 0001:00038344 TCustomPanel.CMBorderChanged + 0001:00038358 TCustomPanel.CMTextChanged + 0001:00038360 TCustomPanel.CMCtl3DChanged + 0001:0003838C TCustomPanel.CMIsToolControl + 0001:000383A0 TCustomPanel.WMWindowPosChanged + 0001:000384A0 AdjustColors + 0001:000384D8 TCustomPanel.Paint + 0001:0003863C TCustomPanel.SetAlignment + 0001:00038648 TCustomPanel.SetBevelInner + 0001:00038664 TCustomPanel.SetBevelOuter + 0001:00038680 TCustomPanel.SetBevelWidth + 0001:0003869C TCustomPanel.SetBorderWidth + 0001:000386B8 TCustomPanel.SetBorderStyle + 0001:000386CC TCustomPanel.GetControlsAlignment + 0001:000386D4 TCustomPanel.AdjustClientRect + 0001:0003872C TCustomPanel.CMDockClient + 0001:00038868 TCustomPanel.CanAutoSize + 0001:00038894 Finalization + 0001:000388C4 ExtCtrls + 0001:000388E8 Finalization + 0001:00038918 Dlgs + 0001:00038A8C TCommonDialog.Create + 0001:00038AD4 TCommonDialog.Destroy + 0001:00038B08 TCommonDialog.MessageHook + 0001:00038B30 TCommonDialog.DefaultHandler + 0001:00038B68 TCommonDialog.MainWndProc + 0001:00038BB4 TCommonDialog.WndProc + 0001:00038BBC TCommonDialog.WMDestroy + 0001:00038BD4 TCommonDialog.WMInitDialog + 0001:00038BEC TCommonDialog.WMNCDestroy + 0001:00038C00 TCommonDialog.TaskModalDialog + 0001:00038CD4 TCommonDialog.DoClose + 0001:00038CE8 TCommonDialog.DoShow + 0001:00038DA0 InitGlobals + 0001:00038EF4 Finalization + 0001:00038F50 Dialogs + 0001:00038F7C Finalization + 0001:00038FB8 Clipbrd + 0001:00039010 AnsiContainsText + 0001:00039080 AnsiReplaceText + 0001:000390AC LeftStr + 0001:000390C8 RightStr + 0001:000390EC Finalization + 0001:0003911C StrUtils + 0001:00039218 THintAction.Create + 0001:00039254 Finalization + 0001:00039284 StdActns + 0001:00039430 TWinHelpViewer.Create + 0001:00039468 TWinHelpViewer.HelpFile + 0001:000394F8 TWinHelpViewer.InternalShutDown + 0001:00039524 TWinHelpViewer.GetViewerName + 0001:00039538 TWinHelpViewer.UnderstandsKeyword + 0001:000395B0 TWinHelpViewer.GetHelpStrings + 0001:00039654 TWinHelpViewer.CanShowTableOfContents + 0001:00039658 TWinHelpViewer.ShowTableOfContents + 0001:000396E0 TWinHelpViewer.ShowHelp + 0001:0003980C TWinHelpViewer.NotifyID + 0001:00039810 TWinHelpViewer.SoftShutDown + 0001:0003982C TWinHelpViewer.ShutDown + 0001:0003985C TWinHelpViewer.UnderstandsTopic + 0001:000398C4 TWinHelpViewer.DisplayTopic + 0001:000399D8 TWinHelpViewer.UnderstandsContext + 0001:00039A4C TWinHelpViewer.DisplayHelpByContext + 0001:00039ADC TWinHelpViewer.CallWinHelp + 0001:00039BEC WindowEnumerationTester + 0001:00039C48 DialogEnumerationTester + 0001:00039CA0 FindWinHelp + 0001:00039CBC TWinHelpViewer.IsNewQuery + 0001:00039D48 TWinHelpViewer.IsBusyWindow + 0001:00039D4C TWinHelpViewer.CouldBeUnstableWindow + 0001:00039D6C TWinHelpViewer.MakeWinHelpHappy + 0001:00039DC4 TWinHelpViewer.RestartWinHelp + 0001:00039E50 TWinHelpViewer.Destroy + 0001:00039E78 Finalization + 0001:00039EE4 WinHelpViewer + 0001:0003C360 InitWndProc + 0001:0003C418 ObjectFromHWnd + 0001:0003C448 FindControl + 0001:0003C484 SendAppMessage + 0001:0003C648 CursorToIdent + 0001:0003C658 IdentToCursor + 0001:0003C668 GetShortHint + 0001:0003C6AC GetLongHint + 0001:0003C6F0 GetCaptureControl + 0001:0003C718 SetCaptureControl + 0001:0003C7C4 TSiteList.Find + 0001:0003C7F8 GetTopParent + 0001:0003C820 TSiteList.AddSite + 0001:0003C87C TSiteList.Clear + 0001:0003C8B0 TSiteList.GetTopSite + 0001:0003C914 TDragObject.Assign + 0001:0003C954 TDragObject.Capture + 0001:0003C96C TDragObject.Finished + 0001:0003C974 TDragObject.GetName + 0001:0003C99C TDragObject.ReleaseCapture + 0001:0003C9B0 TDragObject.WndProc + 0001:0003CAAC TDragObject.GetDragImages + 0001:0003CAB0 TDragObject.GetDragCursor + 0001:0003CAC8 TDragObject.HideDragImage + 0001:0003CACC TDragObject.Instance + 0001:0003CAD4 TDragObject.ShowDragImage + 0001:0003CAD8 TDragObject.MainWndProc + 0001:0003CB24 TDragObject.BeforeDestruction + 0001:0003CB34 TDragObject.AfterConstruction + 0001:0003CB44 TDragObjectEx.BeforeDestruction + 0001:0003CB48 TBaseDragControlObject.Create + 0001:0003CB6C TBaseDragControlObject.Assign + 0001:0003CB98 TBaseDragControlObject.EndDrag + 0001:0003CBC4 TBaseDragControlObject.Finished + 0001:0003CBF8 TDragControlObject.GetDragCursor + 0001:0003CC10 TDragControlObject.GetDragImages + 0001:0003CC1C TDragControlObject.HideDragImage + 0001:0003CC3C TDragControlObject.ShowDragImage + 0001:0003CC5C TDragControlObjectEx.BeforeDestruction + 0001:0003CC60 TDragDockObject.Create + 0001:0003CCC4 TDragDockObject.Destroy + 0001:0003CCF4 TDragDockObject.Assign + 0001:0003CD50 TDragDockObject.EndDrag + 0001:0003CD74 AbsMin + 0001:0003CD98 TDragDockObject.AdjustDockRect + 0001:0003CE14 TDragDockObject.DrawDragDockImage + 0001:0003CE28 TDragDockObject.EraseDragDockImage + 0001:0003CE3C TDragDockObject.GetDragCursor + 0001:0003CE48 TDragDockObject.GetFrameWidth + 0001:0003CE50 TDragDockObjectEx.BeforeDestruction + 0001:0003CE54 IsBeforeTargetWindow + 0001:0003CEC0 ValidDockTarget + 0001:0003D058 IsSiteChildOfClient + 0001:0003D09C GetDockSiteAtPos + 0001:0003D1F8 RegisterDockSite + 0001:0003D258 DragMessage + 0001:0003D2B0 IsDelphiHandle + 0001:0003D2F8 DragFindWindow + 0001:0003D324 DragFindTarget + 0001:0003D374 DoDragOver + 0001:0003D3B0 GetDropCtl + 0001:0003D444 DragTo + 0001:0003D714 DragInit + 0001:0003D884 DragInitControl + 0001:0003DA48 CheckUndock + 0001:0003DABC DragDone + 0001:0003DD94 CancelDrag + 0001:0003DDAC FindVCLWindow + 0001:0003DDE0 FindDragTarget + 0001:0003DE28 ListAdd + 0001:0003DE50 ListRemove + 0001:0003DE70 MoveWindowOrg + 0001:0003DEA0 FreeDeviceContext + 0001:0003DF5C FreeDeviceContexts + 0001:0003E008 TControlCanvas.Destroy + 0001:0003E034 TControlCanvas.CreateHandle + 0001:0003E0DC TControlCanvas.FreeHandle + 0001:0003E110 TControlCanvas.SetControl + 0001:0003E128 TControlCanvas.UpdateTextFlags + 0001:0003E154 TSizeConstraints.Create + 0001:0003E190 TSizeConstraints.AssignTo + 0001:0003E1D8 TSizeConstraints.SetConstraints + 0001:0003E264 TSizeConstraints.Change + 0001:0003E278 TControlActionLink.AssignClient + 0001:0003E294 TControlActionLink.DoShowHint + 0001:0003E384 TControlActionLink.IsCaptionLinked + 0001:0003E3F8 TControlActionLink.IsEnabledLinked + 0001:0003E42C TControlActionLink.IsHintLinked + 0001:0003E464 TControlActionLink.IsVisibleLinked + 0001:0003E498 TControlActionLink.IsOnExecuteLinked + 0001:0003E4C0 TControlActionLink.SetCaption + 0001:0003E4E0 TControlActionLink.SetEnabled + 0001:0003E500 TControlActionLink.SetHint + 0001:0003E524 TControlActionLink.SetVisible + 0001:0003E544 TControlActionLink.SetOnExecute + 0001:0003E570 TControlActionLink.IsHelpLinked + 0001:0003E5D4 TControlActionLink.SetHelpKeyword + 0001:0003E5F4 TControlActionLink.SetHelpContext + 0001:0003E614 TControlActionLink.SetHelpType + 0001:0003E634 TControl.Create + 0001:0003E70C TControl.Destroy + 0001:0003E7C0 TControl.GetDragImages + 0001:0003E7C4 TControl.GetEnabled + 0001:0003E7C8 TControl.GetPalette + 0001:0003E7CC TControl.HasParent + 0001:0003E7D4 TControl.GetParentComponent + 0001:0003E7D8 TControl.SetParentComponent + 0001:0003E800 TControl.PaletteChanged + 0001:0003E878 TControl.GetAction + 0001:0003E888 TControl.SetAnchors + 0001:0003E8A8 TControl.SetAction + 0001:0003E924 TControl.IsAnchorsStored + 0001:0003E93C TControl.SetDragMode + 0001:0003E940 TControl.RequestAlign + 0001:0003E950 TControl.Resize + 0001:0003E970 TControl.ReadState + 0001:0003EA04 TControl.Notification + 0001:0003EA48 TControl.SetAlign + 0001:0003EAF0 TControl.SetBounds + 0001:0003EB88 TControl.UpdateAnchorRules + 0001:0003ECA4 TControl.SetLeft + 0001:0003ECC8 TControl.SetTop + 0001:0003ECF0 TControl.SetWidth + 0001:0003ED14 TControl.SetHeight + 0001:0003ED38 TControl.Dock + 0001:0003EE44 TControl.DoDock + 0001:0003EE9C TControl.SetHelpContext + 0001:0003EEB0 TControl.SetHelpKeyword + 0001:0003EED4 TControl.GetBoundsRect + 0001:0003EEF4 TControl.SetBoundsRect + 0001:0003EF20 TControl.GetClientRect + 0001:0003EF38 TControl.GetClientWidth + 0001:0003EF50 TControl.SetClientWidth + 0001:0003EF7C TControl.GetClientHeight + 0001:0003EF94 TControl.SetClientHeight + 0001:0003EFBC TControl.GetClientOrigin + 0001:0003F04C TControl.ClientToScreen + 0001:0003F078 TControl.ScreenToClient + 0001:0003F0A4 TControl.SendCancelMode + 0001:0003F0D4 TControl.SendDockNotification + 0001:0003F140 TControl.Changed + 0001:0003F150 TControl.ChangeScale + 0001:0003F304 TControl.SetAutoSize + 0001:0003F31C TControl.SetName + 0001:0003F3C0 TControl.SetClientSize + 0001:0003F408 TControl.SetParent + 0001:0003F454 TControl.SetVisible + 0001:0003F490 TControl.SetEnabled + 0001:0003F4A8 TControl.GetTextLen + 0001:0003F4B8 TControl.GetTextBuf + 0001:0003F4C4 TControl.GetUndockHeight + 0001:0003F4D8 TControl.GetUndockWidth + 0001:0003F4EC TControl.SetPopupMenu + 0001:0003F510 TControl.SetTextBuf + 0001:0003F534 TControl.GetText + 0001:0003F564 TControl.SetText + 0001:0003F5C8 TControl.SetBiDiMode + 0001:0003F5E4 TControl.FontChanged + 0001:0003F628 TControl.SetFont + 0001:0003F638 TControl.IsFontStored + 0001:0003F64C TControl.IsShowHintStored + 0001:0003F658 TControl.IsBiDiModeStored + 0001:0003F660 TControl.SetParentFont + 0001:0003F684 TControl.SetShowHint + 0001:0003F6A8 TControl.SetParentShowHint + 0001:0003F6D4 TControl.SetColor + 0001:0003F6F0 TControl.IsColorStored + 0001:0003F6F8 TControl.SetParentColor + 0001:0003F71C TControl.SetParentBiDiMode + 0001:0003F740 TControl.SetCursor + 0001:0003F75C TControl.GetMouseCapture + 0001:0003F76C TControl.SetMouseCapture + 0001:0003F794 TControl.BringToFront + 0001:0003F7A4 TControl.SetZOrderPosition + 0001:0003F824 TControl.SetZOrder + 0001:0003F848 TControl.GetDeviceContext + 0001:0003F8F0 BackgroundClipped + 0001:0003F97C TControl.InvalidateControl + 0001:0003FA08 TControl.Invalidate + 0001:0003FA18 TControl.MouseWheelHandler + 0001:0003FA5C TControl.Hide + 0001:0003FA64 TControl.Show + 0001:0003FA94 TControl.Update + 0001:0003FAA8 TControl.Refresh + 0001:0003FAB4 TControl.Repaint + 0001:0003FBAC TControl.GetControlsAlignment + 0001:0003FBB0 TControl.UseRightToLeftReading + 0001:0003FBC8 TControl.UseRightToLeftAlignment + 0001:0003FBE0 TControl.UseRightToLeftScrollBar + 0001:0003FBFC TControl.BeginAutoDrag + 0001:0003FC14 TControl.BeginDrag + 0001:0003FCD8 TControl.DragCanceled + 0001:0003FCDC TControl.Dragging + 0001:0003FCE8 TControl.DragOver + 0001:0003FD24 TControl.DragDrop + 0001:0003FD50 TControl.DoStartDrag + 0001:0003FD70 TControl.DoEndDrag + 0001:0003FD9C TControl.PositionDockRect + 0001:0003FE6C TControl.DockTrackNoTarget + 0001:0003FE80 TControl.DoEndDock + 0001:0003FEAC TControl.DoStartDock + 0001:0003FECC TControl.DoMouseWheel + 0001:0003FF90 TControl.DoMouseWheelDown + 0001:0003FFDC TControl.DoMouseWheelUp + 0001:00040028 TControl.DefaultDockImage + 0001:00040154 TControl.DrawDragDockImage + 0001:00040168 TControl.EraseDragDockImage + 0001:0004017C TControl.DoDragMsg + 0001:0004026C TControl.ManualDock + 0001:0004044C TControl.ManualFloat + 0001:000404E0 TControl.DoConstraintsChange + 0001:000404EC TControl.CanAutoSize + 0001:000404F0 TControl.CanResize + 0001:00040520 TControl.DoCanAutoSize + 0001:0004058C TControl.DoCanResize + 0001:000405BC TControl.ConstrainedResize + 0001:000405EC TControl.CalcCursorPos + 0001:00040618 TControl.DesignWndProc + 0001:0004064C TControl.DoConstrainedResize + 0001:00040720 TControl.Perform + 0001:00040754 TControl.CalcDockSizes + 0001:000407C4 TControl.UpdateBoundsRect + 0001:000407E8 TControl.VisibleChanging + 0001:000407EC TControl.WndProc + 0001:00040980 TControl.DefaultHandler + 0001:00040A08 TControl.ReadIsControl + 0001:00040A1C TControl.WriteIsControl + 0001:00040A28 DoWriteIsControl + 0001:00040A58 TControl.DefineProperties + 0001:00040AA8 TControl.Click + 0001:00040B14 TControl.DblClick + 0001:00040B34 TControl.MouseDown + 0001:00040B6C TControl.DoMouseDown + 0001:00040BF0 TControl.WMLButtonDown + 0001:00040C3C TControl.WMNCLButtonDown + 0001:00040C58 TControl.WMLButtonDblClk + 0001:00040CAC TControl.GetPopupMenu + 0001:00040CB0 TControl.CheckNewSize + 0001:00040D4C TControl.WMRButtonDown + 0001:00040D74 TControl.WMRButtonDblClk + 0001:00040D9C TControl.WMMButtonDown + 0001:00040DC4 TControl.WMMButtonDblClk + 0001:00040DEC TControl.MouseMove + 0001:00040E1C TControl.WMMouseMove + 0001:00040E94 TControl.MouseUp + 0001:00040ECC TControl.DoMouseUp + 0001:00040F04 TControl.WMLButtonUp + 0001:00040F7C TControl.WMRButtonUp + 0001:00040F9C TControl.WMMButtonUp + 0001:00040FBC TControl.WMMouseWheel + 0001:00041014 TControl.WMCancelMode + 0001:00041054 TControl.WMWindowPosChanged + 0001:00041104 TControl.CMVisibleChanged + 0001:0004112C TControl.CMEnabledChanged + 0001:00041134 TControl.CMFontChanged + 0001:0004113C TControl.CMColorChanged + 0001:00041144 TControl.CMParentColorChanged + 0001:00041174 TControl.CMParentBiDiModeChanged + 0001:00041198 TControl.CMMouseWheel + 0001:000411F4 TControl.CMBiDiModeChanged + 0001:00041214 TControl.CMParentShowHintChanged + 0001:0004123C TControl.CMParentFontChanged + 0001:0004126C TControl.CMSysFontChanged + 0001:00041290 TControl.CMHitTest + 0001:00041298 TControl.CMMouseEnter + 0001:000412B0 TControl.CMMouseLeave + 0001:000412C8 TControl.CMDesignHitTest + 0001:000412D0 TControl.CreateFloatingDockSite + 0001:00041354 UpdateFloatingDockSitePos + 0001:000413E0 TControl.CMFloat + 0001:00041440 TControl.ActionChange + 0001:0004153C TControl.DoActionChange + 0001:00041560 TControl.GetActionLinkClass + 0001:00041568 TControl.IsCaptionStored + 0001:00041588 TControl.IsEnabledStored + 0001:000415A8 TControl.IsHintStored + 0001:000415C8 TControl.IsHelpContextStored + 0001:000415E8 TControl.IsVisibleStored + 0001:00041608 TControl.IsOnClickStored + 0001:00041628 TControl.Loaded + 0001:00041660 TControl.AssignTo + 0001:0004170C MinVar + 0001:00041748 TControl.GetDockEdge + 0001:000417F8 TControl.GetFloating + 0001:00041824 TControl.GetFloatingDockSiteClass + 0001:0004182C TControl.AdjustSize + 0001:0004184C TControl.DrawTextBiDiModeFlags + 0001:0004188C TControl.DrawTextBiDiModeFlagsReadingOnly + 0001:000418A8 TControl.InitiateAction + 0001:000418B8 TControl.CMHintShow + 0001:000418E4 TControl.WMContextMenu + 0001:00041A0C TControl.DoContextPopup + 0001:00041A40 TControl.SetConstraints + 0001:00041A4C TWinControlActionLink.AssignClient + 0001:00041A70 TWinControlActionLink.IsHelpContextLinked + 0001:00041A78 TWinControlActionLink.SetHelpContext + 0001:00041A80 TWinControl.Create + 0001:00041BA4 TWinControl.Destroy + 0001:00041C74 TWinControl.FixupTabList + 0001:00041D48 TWinControl.ReadState + 0001:00041DC0 TWinControl.AdjustClientRect + 0001:00041DC4 InsertBefore + 0001:00041E50 DoPosition + 0001:00042290 DoAlign + 0001:00042400 AlignWork + 0001:00042454 TWinControl.AlignControls + 0001:00042558 TWinControl.AlignControl + 0001:000425EC TWinControl.DisableAlign + 0001:000425F4 TWinControl.EnableAlign + 0001:00042614 TWinControl.Realign + 0001:0004261C TWinControl.DoFlipChildren + 0001:000426F0 TWinControl.FlipChildren + 0001:00042830 TWinControl.ContainsControl + 0001:00042844 TWinControl.RemoveFocus + 0001:00042864 TWinControl.Insert + 0001:000428B0 TWinControl.Remove + 0001:000428F8 TWinControl.InsertControl + 0001:000429CC TWinControl.RemoveControl + 0001:00042A48 TWinControl.GetControl + 0001:00042A84 TWinControl.GetControlCount + 0001:00042AA4 TWinControl.Broadcast + 0001:00042AE4 TWinControl.NotifyControls + 0001:00042B0C TWinControl.CreateSubClass + 0001:00042B78 TWinControl.AddBiDiModeExStyle + 0001:00042BE0 TWinControl.CreateParams + 0001:00042D0C TWinControl.CreateWnd + 0001:00042EA4 TWinControl.CreateWindowHandle + 0001:00042EE8 TWinControl.ReadDesignSize + 0001:00042F20 TWinControl.WriteDesignSize + 0001:00042F74 PointsEqual + 0001:00042F88 DoWriteDesignSize + 0001:00043060 TWinControl.DefineProperties + 0001:000430BC TWinControl.DestroyWnd + 0001:00043114 TWinControl.DestroyWindowHandle + 0001:00043178 TWinControl.PrecedingWindow + 0001:000431C0 TWinControl.CreateHandle + 0001:00043258 TWinControl.CustomAlignInsertBefore + 0001:0004325C TWinControl.CustomAlignPosition + 0001:00043278 TWinControl.DestroyHandle + 0001:000432C0 TWinControl.RecreateWnd + 0001:000432D8 TWinControl.CMRecreateWnd + 0001:00043318 TWinControl.UpdateShowing + 0001:00043414 TWinControl.UpdateControlState + 0001:00043454 TWinControl.MainWndProc + 0001:000434CC GetControlAtPos + 0001:00043584 TWinControl.ControlAtPos + 0001:00043618 TWinControl.IsControlMouseMsg + 0001:000436AC TWinControl.WndProc + 0001:00043810 TWinControl.DefaultHandler + 0001:00043918 DoControlMsg + 0001:0004394C TWinControl.PaintHandler + 0001:00043A7C TWinControl.PaintWindow + 0001:00043AA8 TWinControl.PaintControls + 0001:00043CD8 TWinControl.PaintTo + 0001:00043E2C TWinControl.WMPaint + 0001:00043F8C TWinControl.WMCommand + 0001:00043FAC TWinControl.WMNotify + 0001:00043FD0 TWinControl.WMSysColorChange + 0001:00043FEC TWinControl.WMWinIniChange + 0001:00044000 TWinControl.WMFontChange + 0001:00044010 TWinControl.WMTimeChange + 0001:00044020 TWinControl.WMHScroll + 0001:00044040 TWinControl.WMVScroll + 0001:00044060 TWinControl.WMCompareItem + 0001:00044084 TWinControl.WMDeleteItem + 0001:000440A8 TWinControl.WMDrawItem + 0001:000440CC TWinControl.WMMeasureItem + 0001:000440F0 TWinControl.WMEraseBkgnd + 0001:0004413C TWinControl.WMWindowPosChanged + 0001:000441FC TWinControl.WMWindowPosChanging + 0001:0004424C TWinControl.WMSize + 0001:00044280 TWinControl.WMMove + 0001:00044294 TWinControl.WMSetCursor + 0001:00044394 TWinControl.WMSetFocus + 0001:000443A8 TWinControl.WMKillFocus + 0001:000443BC TWinControl.WMIMEStartComp + 0001:000443D0 TWinControl.WMIMEEndComp + 0001:000443E4 TWinControl.SetIme + 0001:000444D0 TWinControl.ResetIme + 0001:00044568 TWinControl.DoAddDockClient + 0001:00044578 TWinControl.DoRemoveDockClient + 0001:0004457C TWinControl.DoEnter + 0001:0004459C TWinControl.DoExit + 0001:000445BC TWinControl.DockDrop + 0001:0004460C TWinControl.DoDockOver + 0001:00044640 TWinControl.DockOver + 0001:00044680 TWinControl.DoUnDock + 0001:000446D8 TWinControl.ReloadDockedControl + 0001:000446FC TWinControl.GetDockClientCount + 0001:00044710 TWinControl.GetDockClients + 0001:00044734 TWinControl.GetSiteInfo + 0001:00044790 TWinControl.GetVisibleDockClientCount + 0001:000447CC TWinControl.ControlsAligned + 0001:000447D0 TWinControl.CreateDockManager + 0001:0004483C TWinControl.SetDockSite + 0001:000448F4 TWinControl.CMDockClient + 0001:000449E0 TWinControl.CMUnDockClient + 0001:00044A08 TWinControl.CMFloat + 0001:00044A8C TWinControl.KeyDown + 0001:00044AB4 TWinControl.DoKeyDown + 0001:00044B1C TWinControl.WMKeyDown + 0001:00044B3C TWinControl.WMSysKeyDown + 0001:00044B5C TWinControl.KeyUp + 0001:00044B84 TWinControl.DoKeyUp + 0001:00044BEC TWinControl.WMKeyUp + 0001:00044C0C TWinControl.WMSysKeyUp + 0001:00044C2C TWinControl.KeyPress + 0001:00044C4C TWinControl.DoKeyPress + 0001:00044CB0 TWinControl.WMChar + 0001:00044CD0 TraverseControls + 0001:00044D80 TWinControl.WMSysCommand + 0001:00044E28 TWinControl.WMCharToItem + 0001:00044E48 TWinControl.WMParentNotify + 0001:00044E7C TWinControl.WMVKeyToItem + 0001:00044E9C TWinControl.WMDestroy + 0001:00044ED0 TWinControl.WMNCDestroy + 0001:00044EEC TWinControl.WMNCHitTest + 0001:00044F10 TWinControl.PaletteChanged + 0001:00044F68 TWinControl.WMQueryNewPalette + 0001:00044F8C TWinControl.WMPaletteChanged + 0001:00044FAC TWinControl.CMShowHintChanged + 0001:00044FC4 TWinControl.CMBiDiModeChanged + 0001:00044FFC TWinControl.CMEnter + 0001:00045070 TWinControl.CMExit + 0001:0004507C TWinControl.CMDesignHitTest + 0001:0004509C TWinControl.CMChanged + 0001:000450B0 TWinControl.CMChildKey + 0001:000450C4 TWinControl.CMDialogKey + 0001:000450CC TWinControl.CMDialogChar + 0001:000450D4 TWinControl.CMFocusChanged + 0001:000450DC TWinControl.CMVisibleChanged + 0001:0004510C TWinControl.CMShowingChanged + 0001:00045134 TWinControl.CMEnabledChanged + 0001:0004517C TWinControl.CMColorChanged + 0001:000451A4 TWinControl.CMFontChanged + 0001:000451E0 TWinControl.CMCursorChanged + 0001:00045220 TWinControl.CMBorderChanged + 0001:00045260 TWinControl.CMCtl3DChanged + 0001:000452A0 TWinControl.CMParentCtl3DChanged + 0001:000452E0 TWinControl.CMSysColorChange + 0001:000452E8 TWinControl.CMWinIniChange + 0001:000452F0 TWinControl.CMFontChange + 0001:000452F8 TWinControl.CMTimeChange + 0001:00045300 TWinControl.CMDrag + 0001:0004535C TWinControl.CMControlListChange + 0001:00045370 TWinControl.CMSysFontChanged + 0001:0004538C TWinControl.IsMenuKey + 0001:00045420 TWinControl.CNKeyDown + 0001:000454F8 TWinControl.CNKeyUp + 0001:0004554C TWinControl.CNChar + 0001:00045598 TWinControl.CNSysKeyDown + 0001:000455F4 TWinControl.CNSysChar + 0001:00045628 TWinControl.SetBounds + 0001:00045700 TWinControl.ScaleControls + 0001:00045748 TWinControl.ChangeScale + 0001:000457F4 TWinControl.ScrollBy + 0001:000458CC TWinControl.ShowControl + 0001:000458E4 TWinControl.SetZOrderPosition + 0001:000459BC TWinControl.SetZOrder + 0001:00045A1C TWinControl.GetDeviceContext + 0001:00045A70 TWinControl.Invalidate + 0001:00045A80 TWinControl.CMInvalidate + 0001:00045AD0 TWinControl.Update + 0001:00045AEC TWinControl.Repaint + 0001:00045B04 TWinControl.InvalidateFrame + 0001:00045B3C TWinControl.CanFocus + 0001:00045B7C TWinControl.SetFocus + 0001:00045BB4 TWinControl.Focused + 0001:00045BD8 TWinControl.HandleNeeded + 0001:00045BFC TWinControl.GetHandle + 0001:00045C10 TWinControl.GetControlExtents + 0001:00045CA4 TWinControl.GetClientOrigin + 0001:00045CC4 TWinControl.GetClientRect + 0001:00045CDC TWinControl.AdjustSize + 0001:00045D1C TWinControl.SetBorderWidth + 0001:00045D3C TWinControl.SetCtl3D + 0001:00045D60 TWinControl.IsCtl3DStored + 0001:00045D6C TWinControl.SetParentCtl3D + 0001:00045D98 TWinControl.GetTabOrder + 0001:00045DBC TWinControl.UpdateTabOrder + 0001:00045E18 TWinControl.SetTabOrder + 0001:00045E30 TWinControl.SetTabStop + 0001:00045E90 TWinControl.SetUseDockManager + 0001:00045F00 TWinControl.HandleAllocated + 0001:00045F0C TWinControl.UpdateBounds + 0001:00045FC4 TWinControl.GetTabOrderList + 0001:00046024 TWinControl.FindNextControl + 0001:00046130 TWinControl.SelectNext + 0001:0004615C TWinControl.SelectFirst + 0001:000461A0 TWinControl.GetChildren + 0001:000461E8 TWinControl.SetChildOrder + 0001:00046228 TWinControl.CanResize + 0001:00046230 DoCalcConstraints + 0001:000462B4 TWinControl.CalcConstraints + 0001:00046690 TWinControl.ConstrainedResize + 0001:000466CC TWinControl.ActionChange + 0001:0004670C TWinControl.GetActionLinkClass + 0001:00046714 TWinControl.AssignTo + 0001:00046744 TWinControl.CanAutoSize + 0001:00046910 TWinControl.SetBevelCut + 0001:00046954 TWinControl.SetBevelEdges + 0001:00046984 TWinControl.SetBevelKind + 0001:000469A4 TWinControl.SetBevelWidth + 0001:000469C4 TWinControl.WMNCCalcSize + 0001:00046A54 TWinControl.WMNCPaint + 0001:00046CD4 TWinControl.WMContextMenu + 0001:00046D40 THintWindow.Create + 0001:00046DAC THintWindow.CreateParams + 0001:00046DE8 THintWindow.WMNCHitTest + 0001:00046DF0 THintWindow.WMNCPaint + 0001:00046E54 THintWindow.Paint + 0001:00046EFC THintWindow.IsHintMsg + 0001:00046F60 THintWindow.ReleaseHandle + 0001:00046F68 THintWindow.CMTextChanged + 0001:00047000 THintWindow.ActivateHint + 0001:000471D8 THintWindow.ActivateHintData + 0001:00047200 THintWindow.CalcHintRect + 0001:0004725C THintWindow.NCPaint + 0001:00047290 THintWindow.WMPrint + 0001:000472B4 ClientToWindow + 0001:000472F4 TDragImageList.Initialize + 0001:0004730C TDragImageList.CombineDragCursor + 0001:000473D8 TDragImageList.SetDragImage + 0001:00047420 TDragImageList.SetDragCursor + 0001:00047438 TDragImageList.GetHotSpot + 0001:00047464 TDragImageList.BeginDrag + 0001:000474C4 TDragImageList.DragLock + 0001:00047528 TDragImageList.DragUnlock + 0001:0004754C TDragImageList.DragMove + 0001:00047590 TDragImageList.ShowDragImage + 0001:000475A8 TDragImageList.HideDragImage + 0001:000475C0 TDragImageList.EndDrag + 0001:00047608 TCustomControl.Create + 0001:00047664 TCustomControl.Destroy + 0001:00047694 TCustomControl.WMPaint + 0001:000476B4 TCustomControl.PaintWindow + 0001:00047760 TCustomControl.Paint + 0001:00047764 NextVisibleZone + 0001:00047780 IsOrientationSet + 0001:000477A4 TDockZone.Create + 0001:000477C8 TDockZone.GetChildCount + 0001:000477DC TDockZone.GetVisibleChildCount + 0001:000477F8 TDockZone.GetVisible + 0001:0004782C TDockZone.GetLimitBegin + 0001:00047874 TDockZone.GetLimitSize + 0001:000478BC TDockZone.GetTopLeft + 0001:00047928 TDockZone.GetHeightWidth + 0001:000479D8 TDockZone.ResetChildren + 0001:00047A80 TDockZone.GetControlName + 0001:00047AC4 TDockZone.SetControlName + 0001:00047B48 ParentNotLast + 0001:00047B78 TDockZone.Update + 0001:00047CF0 TDockZone.GetZoneLimit + 0001:00047D18 TDockZone.SetZoneLimit + 0001:00047D1C GetLastChildZone + 0001:00047D2C TDockZone.ExpandZoneLimit + 0001:00047D68 TDockZone.ResetZoneLimits + 0001:00047DC8 TDockZone.NextVisible + 0001:00047DD4 TDockZone.PrevVisible + 0001:00047DF0 TDockZone.FirstVisibleChild + 0001:00047DFC TDockTree.Create + 0001:00047F64 TDockTree.Destroy + 0001:00047FB8 TDockTree.AdjustDockRect + 0001:00047FCC TDockTree.BeginUpdate + 0001:00047FD0 TDockTree.EndUpdate + 0001:00047FE4 DoFindControlZone + 0001:0004803C TDockTree.FindControlZone + 0001:00048068 DoForEach + 0001:000480A4 TDockTree.ForEachAt + 0001:000480BC TDockTree.GetControlBounds + 0001:00048130 TDockTree.HitTest + 0001:00048140 TDockTree.InsertControl + 0001:00048350 TDockTree.InsertNewParent + 0001:000484F8 TDockTree.InsertSibling + 0001:00048570 DoFindZone + 0001:0004879C FindControlAtPos + 0001:00048830 TDockTree.InternalHitTest + 0001:000488B8 ReadControlName + 0001:00048900 TDockTree.LoadFromStream + 0001:00048B08 DrawCloseButton + 0001:00048B60 DrawGrabberLine + 0001:00048BE8 TDockTree.PaintDockFrame + 0001:00048CC4 TDockTree.PaintSite + 0001:00048E28 TDockTree.PositionDockRect + 0001:00048F9C DoPrune + 0001:00048FD0 TDockTree.PruneZone + 0001:0004902C TDockTree.RemoveControl + 0001:00049068 TDockTree.RemoveZone + 0001:000492E4 TDockTree.ResetBounds + 0001:000493C0 TDockTree.ScaleZone + 0001:000493FC WriteControlName + 0001:00049474 DoSaveZone + 0001:00049530 TDockTree.SaveToStream + 0001:00049678 DoSetNewBounds + 0001:00049700 TDockTree.SetNewBounds + 0001:0004972C TDockTree.SetReplacingControl + 0001:00049744 TDockTree.ShiftZone + 0001:00049774 TDockTree.SplitterMouseDown + 0001:000497D4 TDockTree.SplitterMouseUp + 0001:00049850 TDockTree.UpdateAll + 0001:00049878 TDockTree.UpdateZone + 0001:00049888 TDockTree.DrawSizeSplitter + 0001:00049974 DoGetNextLimit + 0001:00049A04 TDockTree.GetNextLimit + 0001:00049A54 GetDockAlign + 0001:00049AD0 HideZone + 0001:00049B50 ShowZone + 0001:00049C88 TDockTree.ControlVisibilityChanged + 0001:00049D10 CalcSplitterPos + 0001:00049DA0 TDockTree.WindowProc + 0001:0004A188 TMouse.Create + 0001:0004A218 TMouse.Destroy + 0001:0004A248 TMouse.GetCapture + 0001:0004A250 TMouse.GetCursorPos + 0001:0004A260 TMouse.GetMouseData + 0001:0004A27C TMouse.GetNativeData + 0001:0004A2AC TMouse.GetRegisteredData + 0001:0004A2D4 TMouse.SetCapture + 0001:0004A2FC TMouse.SettingChanged + 0001:0004A360 InitIMM32 + 0001:0004A5C8 Win32NLSEnableIME + 0001:0004A5E4 SetImeMode + 0001:0004A6C0 Imm32IsIME + 0001:0004A6D4 DoneControls + 0001:0004A75C InitControls + 0001:0004A928 TCustomListControl.MoveSelection + 0001:0004A944 Finalization + 0001:0004A9AC Controls + 0001:0004AF64 TContainedAction.Destroy + 0001:0004AF98 TContainedAction.GetIndex + 0001:0004AFB0 TContainedAction.IsCategoryStored + 0001:0004AFB4 TContainedAction.GetParentComponent + 0001:0004AFC4 TContainedAction.HasParent + 0001:0004AFD4 TContainedAction.ReadState + 0001:0004B008 TContainedAction.SetIndex + 0001:0004B050 TContainedAction.SetCategory + 0001:0004B07C TContainedAction.SetActionList + 0001:0004B0A4 TContainedAction.SetParentComponent + 0001:0004B0D0 TContainedAction.Execute + 0001:0004B128 TContainedAction.Update + 0001:0004B180 TCustomActionList.Create + 0001:0004B1EC TCustomActionList.Destroy + 0001:0004B23C TCustomActionList.GetChildren + 0001:0004B284 TCustomActionList.SetChildOrder + 0001:0004B2B4 TCustomActionList.GetAction + 0001:0004B2C8 TCustomActionList.GetActionCount + 0001:0004B2D0 TCustomActionList.SetImages + 0001:0004B304 TCustomActionList.ImageListChange + 0001:0004B310 TCustomActionList.Notification + 0001:0004B358 TCustomActionList.AddAction + 0001:0004B378 TCustomActionList.RemoveAction + 0001:0004B394 TCustomActionList.Change + 0001:0004B3FC TCustomActionList.IsShortCut + 0001:0004B488 TCustomActionList.ExecuteAction + 0001:0004B4A8 TCustomActionList.UpdateAction + 0001:0004B4C8 TActionLink.IsCaptionLinked + 0001:0004B4DC TActionLink.IsCheckedLinked + 0001:0004B4F0 TActionLink.IsEnabledLinked + 0001:0004B504 TActionLink.IsGroupIndexLinked + 0001:0004B518 TActionLink.IsHelpContextLinked + 0001:0004B52C TActionLink.IsHelpLinked + 0001:0004B540 TActionLink.IsHintLinked + 0001:0004B554 TActionLink.IsImageIndexLinked + 0001:0004B568 TActionLink.IsShortCutLinked + 0001:0004B57C TActionLink.IsVisibleLinked + 0001:0004B590 TActionLink.SetAutoCheck + 0001:0004B594 TActionLink.SetCaption + 0001:0004B598 TActionLink.SetChecked + 0001:0004B59C TActionLink.SetEnabled + 0001:0004B5A0 TActionLink.SetGroupIndex + 0001:0004B5A4 TActionLink.SetHelpContext + 0001:0004B5A8 TActionLink.SetHelpKeyword + 0001:0004B5AC TActionLink.SetHelpType + 0001:0004B5B0 TActionLink.SetHint + 0001:0004B5B4 TActionLink.SetImageIndex + 0001:0004B5B8 TActionLink.SetShortCut + 0001:0004B5BC TActionLink.SetVisible + 0001:0004B5C0 TCustomAction.Create + 0001:0004B614 TCustomAction.Destroy + 0001:0004B664 TCustomAction.AssignTo + 0001:0004B710 TCustomAction.SetCaption + 0001:0004B770 TCustomAction.SetChecked + 0001:0004B878 TCustomAction.SetEnabled + 0001:0004B8F0 TCustomAction.SetHelpKeyword + 0001:0004B958 TCustomAction.SetHelpContext + 0001:0004B9B0 TCustomAction.SetHint + 0001:0004BA10 TCustomAction.SetImageIndex + 0001:0004BA6C TCustomAction.SetShortCut + 0001:0004BAD0 TCustomAction.SetVisible + 0001:0004BB30 TCustomAction.SetName + 0001:0004BB7C TCustomAction.DoHint + 0001:0004BBA4 TCustomAction.Execute + 0001:0004BBF4 TCustomAction.GetSecondaryShortCuts + 0001:0004BC1C TCustomAction.SetSecondaryShortCuts + 0001:0004BC50 TCustomAction.IsSecondaryShortCutsStored + 0001:0004BC74 TCustomAction.HandleShortCut + 0001:0004BC80 TShortCutList.Add + 0001:0004BCAC TShortCutList.IndexOfShortCut + 0001:0004BCF0 Finalization + 0001:0004BD20 ActnList + 0001:0004BF20 GetRGBColor + 0001:0004BF40 GetColor + 0001:0004BF60 TCustomImageList.Create + 0001:0004BFAC TCustomImageList.CreateSize + 0001:0004C000 TCustomImageList.Destroy + 0001:0004C06C TCustomImageList.Initialize + 0001:0004C124 TCustomImageList.HandleAllocated + 0001:0004C12C TCustomImageList.HandleNeeded + 0001:0004C138 TCustomImageList.InitBitmap + 0001:0004C1FC TCustomImageList.SetNewDimensions + 0001:0004C234 TCustomImageList.SetWidth + 0001:0004C278 TCustomImageList.SetHeight + 0001:0004C2BC TCustomImageList.SetHandle + 0001:0004C2E8 TCustomImageList.GetHandle + 0001:0004C2F8 TCustomImageList.GetImageHandle + 0001:0004C34C TCustomImageList.FreeHandle + 0001:0004C384 TCustomImageList.CreateImageList + 0001:0004C424 TCustomImageList.Add + 0001:0004C4F0 TCustomImageList.GetIcon + 0001:0004C500 TCustomImageList.GetIcon + 0001:0004C554 TCustomImageList.GetCount + 0001:0004C578 TCustomImageList.Delete + 0001:0004C604 TCustomImageList.Clear + 0001:0004C610 TCustomImageList.SetBkColor + 0001:0004C648 TCustomImageList.GetBkColor + 0001:0004C670 TCustomImageList.DoDraw + 0001:0004C844 TCustomImageList.Draw + 0001:0004C868 TCustomImageList.Draw + 0001:0004C8B4 TCustomImageList.CopyImages + 0001:0004CA4C TCustomImageList.AddImages + 0001:0004CA6C TCustomImageList.Assign + 0001:0004CB2C TCustomImageList.AssignTo + 0001:0004CBDC TCustomImageList.CheckImage + 0001:0004CC54 TCustomImageList.SetDrawingStyle + 0001:0004CC6C TCustomImageList.GetHotSpot + 0001:0004CC7C TCustomImageList.Change + 0001:0004CCCC TCustomImageList.UnRegisterChanges + 0001:0004CD10 TCustomImageList.RegisterChanges + 0001:0004CD24 StreamsEqual + 0001:0004CD6C TCustomImageList.Equal + 0001:0004CE5C DoWrite + 0001:0004CEB8 TCustomImageList.DefineProperties + 0001:0004CF10 TCustomImageList.ReadD2Stream + 0001:0004D1A4 TCustomImageList.ReadD3Stream + 0001:0004D36C TCustomImageList.ReadData + 0001:0004D3F8 TCustomImageList.WriteData + 0001:0004D474 TCustomImageList.BeginUpdate + 0001:0004D478 TCustomImageList.EndUpdate + 0001:0004D498 TChangeLink.Destroy + 0001:0004D4CC TChangeLink.Change + 0001:0004D4E4 Finalization + 0001:0004D514 ImgList + 0001:0004E410 FindPopupControl + 0001:0004E440 ReturnAddr + 0001:0004E448 Error + 0001:0004E468 ShortCut + 0001:0004E4A0 GetSpecialName + 0001:0004E4F4 ShortCutToText + 0001:0004E6F8 CompareFront + 0001:0004E754 TextToShortCut + 0001:0004E84C UniqueCommand + 0001:0004E86C Iterate + 0001:0004E8CC IterateMenus + 0001:0004E9D4 TMenuActionLink.AssignClient + 0001:0004E9F0 TMenuActionLink.IsAutoCheckLinked + 0001:0004EA18 TMenuActionLink.IsCaptionLinked + 0001:0004EA50 TMenuActionLink.IsCheckedLinked + 0001:0004EA80 TMenuActionLink.IsEnabledLinked + 0001:0004EAB0 TMenuActionLink.IsHelpContextLinked + 0001:0004EAE0 TMenuActionLink.IsHintLinked + 0001:0004EB14 TMenuActionLink.IsGroupIndexLinked + 0001:0004EB50 TMenuActionLink.IsImageIndexLinked + 0001:0004EB84 TMenuActionLink.IsShortCutLinked + 0001:0004EBB8 TMenuActionLink.IsVisibleLinked + 0001:0004EBEC TMenuActionLink.IsOnExecuteLinked + 0001:0004EC14 TMenuActionLink.SetAutoCheck + 0001:0004EC34 TMenuActionLink.SetCaption + 0001:0004EC54 TMenuActionLink.SetChecked + 0001:0004EC74 TMenuActionLink.SetEnabled + 0001:0004EC94 TMenuActionLink.SetHelpContext + 0001:0004ECB0 TMenuActionLink.SetHint + 0001:0004ECD4 TMenuActionLink.SetImageIndex + 0001:0004ECF4 TMenuActionLink.SetShortCut + 0001:0004ED14 TMenuActionLink.SetVisible + 0001:0004ED34 TMenuActionLink.SetOnExecute + 0001:0004ED60 TMenuItem.Create + 0001:0004EDDC TMenuItem.Destroy + 0001:0004EE90 TMenuItem.AppendTo + 0001:0004F114 AddIn + 0001:0004F130 TMenuItem.PopulateMenu + 0001:0004F1A0 TMenuItem.ReadShortCutText + 0001:0004F1F8 TMenuItem.MergeWith + 0001:0004F234 TMenuItem.Loaded + 0001:0004F270 TMenuItem.RebuildHandle + 0001:0004F340 TMenuItem.VerifyGroupIndex + 0001:0004F3A0 TMenuItem.GetHandle + 0001:0004F3EC TMenuItem.DefineProperties + 0001:0004F430 TMenuItem.DoDrawText + 0001:0004F640 TMenuItem.DrawItem + 0001:0004F680 NormalDraw + 0001:0004FEF8 BiDiDraw + 0001:00050798 TMenuItem.AdvancedDrawItem + 0001:000508B0 TMenuItem.GetImageList + 0001:000508E0 GetMenuSize + 0001:0005092C TMenuItem.MeasureItem + 0001:00050B2C TMenuItem.HasParent + 0001:00050B30 TMenuItem.SetBreak + 0001:00050B40 TMenuItem.SetCaption + 0001:00050B68 TMenuItem.TurnSiblingsOff + 0001:00050BB0 TMenuItem.SetChecked + 0001:00050C04 TMenuItem.SetEnabled + 0001:00050C7C TMenuItem.SetGroupIndex + 0001:00050CC0 TMenuItem.GetAction + 0001:00050CD0 TMenuItem.GetActionLinkClass + 0001:00050CD8 TMenuItem.GetCount + 0001:00050CE8 TMenuItem.GetItem + 0001:00050D0C TMenuItem.SetShortCut + 0001:00050D20 TMenuItem.SetVisible + 0001:00050D30 TMenuItem.SetImageIndex + 0001:00050D40 TMenuItem.GetMenuIndex + 0001:00050D58 TMenuItem.SetMenuIndex + 0001:00050DA0 TMenuItem.GetChildren + 0001:00050DD8 TMenuItem.SetChildOrder + 0001:00050DF8 TMenuItem.SetDefault + 0001:00050E54 TMenuItem.InitiateAction + 0001:00050E64 TMenuItem.Insert + 0001:00050F18 TMenuItem.Delete + 0001:00050F8C TMenuItem.Click + 0001:0005103C TMenuItem.IndexOf + 0001:00051054 TMenuItem.Add + 0001:00051070 TMenuItem.Remove + 0001:00051098 TMenuItem.MenuChanged + 0001:000510DC TMenuItem.SubItemChanged + 0001:00051134 TMenuItem.GetBitmap + 0001:0005115C TMenuItem.SetAction + 0001:000511CC TMenuItem.SetBitmap + 0001:00051200 TMenuItem.InitiateActions + 0001:0005122C TMenuItem.GetParentComponent + 0001:00051240 TMenuItem.SetParentComponent + 0001:00051294 TMenuItem.GetParentMenu + 0001:000512A4 TMenuItem.SetRadioItem + 0001:000512D0 TMenuItem.ActionChange + 0001:000513F0 TMenuItem.DoActionChange + 0001:00051414 TMenuItem.IsCaptionStored + 0001:00051434 TMenuItem.IsCheckedStored + 0001:00051454 TMenuItem.IsEnabledStored + 0001:00051474 TMenuItem.IsHintStored + 0001:00051494 TMenuItem.IsHelpContextStored + 0001:000514B4 TMenuItem.IsImageIndexStored + 0001:000514D4 TMenuItem.IsShortCutStored + 0001:000514F4 TMenuItem.IsVisibleStored + 0001:00051514 TMenuItem.IsOnClickStored + 0001:00051534 TMenuItem.AssignTo + 0001:000515AC TMenuItem.Notification + 0001:00051600 TMenuItem.SetSubMenuImages + 0001:0005163C TMenuItem.ImageListChange + 0001:00051648 UpdateItem + 0001:00051670 TMenuItem.UpdateItems + 0001:00051684 IfHotkeyAvailable + 0001:000516B4 CopyToBest + 0001:00051738 InsertHotkeyFarEastFormat + 0001:00051898 TMenuItem.InternalRethinkHotkeys + 0001:00051D60 TMenuItem.SetAutoHotkeys + 0001:00051D70 TMenuItem.IsLine + 0001:00051D94 TMenuItem.InternalRethinkLines + 0001:00051EDC TMenuItem.SetAutoLineReduction + 0001:00051EEC TMenuItem.GetAutoHotkeys + 0001:00051F18 TMenuItem.GetAutoLineReduction + 0001:00051F44 TMenu.Create + 0001:00051FE0 TMenu.Destroy + 0001:00052018 TMenu.GetChildren + 0001:00052034 TMenu.GetHandle + 0001:00052040 TMenu.SetChildOrder + 0001:00052054 UpdateItem + 0001:0005207C TMenu.UpdateItems + 0001:00052094 Find + 0001:0005212C TMenu.FindItem + 0001:0005215C TMenu.GetHelpContext + 0001:000521CC TMenu.DispatchCommand + 0001:000521E8 TMenu.DispatchPopup + 0001:000522B0 TMenu.IsOwnerDraw + 0001:000522C4 NthParentOf + 0001:000522D4 DoClick + 0001:00052428 TMenu.IsShortCut + 0001:00052544 TMenu.IsBiDiModeStored + 0001:0005254C TMenu.DoBiDiModeChanged + 0001:00052608 BuildImage + 0001:000526A8 TMenu.UpdateImage + 0001:0005272C TMenu.SetOwnerDraw + 0001:0005273C TMenu.AdjustBiDiBehavior + 0001:000527B8 TMenu.SetWindowHandle + 0001:000527F0 TMenu.DoChange + 0001:00052808 TMenu.Loaded + 0001:00052820 TMenu.MenuChanged + 0001:0005285C TMenu.ImageListChange + 0001:00052868 TMenu.SetImages + 0001:000528A4 TMenu.Notification + 0001:000528D0 TMenu.IsRightToLeft + 0001:000528E8 IsAccelChar + 0001:00052944 IsInitialChar + 0001:00052A2C TMenu.ProcessMenuChar + 0001:00052BA4 TMenu.DoGetMenuString + 0001:00052C4C TMenu.SetBiDiMode + 0001:00052C60 TMenu.SetParentBiDiMode + 0001:00052C70 TMenu.ParentBiDiModeChanged + 0001:00052C98 TMenu.ParentBiDiModeChanged + 0001:00052CC4 TMenu.GetAutoHotkeys + 0001:00052CD4 TMenu.SetAutoHotkeys + 0001:00052CE4 TMenu.GetAutoLineReduction + 0001:00052CF4 TMenu.SetAutoLineReduction + 0001:00052D04 TMainMenu.SetAutoMerge + 0001:00052D24 TMainMenu.MenuChanged + 0001:00052D7C TMainMenu.Merge + 0001:00052D98 TMainMenu.Unmerge + 0001:00052DB4 TMainMenu.ItemChanged + 0001:00052DE0 TMainMenu.GetHandle + 0001:00052DF0 TPopupList.MainWndProc + 0001:00052E3C TPopupList.WndProc + 0001:00053380 TPopupList.Add + 0001:000533A8 TPopupList.Remove + 0001:000533C4 TPopupMenu.Create + 0001:00053438 TPopupMenu.Destroy + 0001:0005346C TPopupMenu.DoPopup + 0001:00053480 TPopupMenu.GetHelpContext + 0001:00053488 TPopupMenu.SetHelpContext + 0001:00053490 TPopupMenu.SetBiDiModeFromPopupControl + 0001:000534D8 TPopupMenu.UseRightToLeftAlignment + 0001:00053524 TPopupMenu.Popup + 0001:000535D8 TMenuItemStack.ClearItem + 0001:00053614 DrawMenuItem + 0001:000536FC StripHotkey + 0001:00053794 GetHotkey + 0001:000537F8 AnsiSameCaption + 0001:000538F4 Finalization + 0001:00053964 Menus + 0001:00055FE0 SaveFocusState + 0001:00055FE8 RestoreFocusState + 0001:00055FF0 ShowMDIClientEdge + 0001:0005603C DoneApplication + 0001:00056074 DoDisableWindow + 0001:000560C4 DisableTaskWindows + 0001:00056178 EnableTaskWindows + 0001:000561B0 DoFindWindow + 0001:00056214 FindTopMostWindow + 0001:00056250 SendFocusMessage + 0001:00056270 CheckTaskWindow + 0001:00056290 ForegroundTask + 0001:000562BC FindGlobalComponent + 0001:0005633C KeysToShiftState + 0001:00056390 KeyDataToShiftState + 0001:000563CC KeyboardStateToShiftState + 0001:00056418 IsAccel + 0001:00056488 GetParentForm + 0001:000564B0 ValidParentForm + 0001:00056530 TControlScrollBar.Create + 0001:000565B8 TControlScrollBar.IsIncrementStored + 0001:000565C0 TControlScrollBar.Assign + 0001:00056610 TControlScrollBar.ChangeBiDiPosition + 0001:00056648 ProcessHorz + 0001:000566B4 ProcessVert + 0001:0005671C TControlScrollBar.CalcAutoRange + 0001:000567C8 TControlScrollBar.IsScrollBarVisible + 0001:00056800 ScrollBarVisible + 0001:00056834 Adjustment + 0001:000568B0 TControlScrollBar.ControlSize + 0001:00056930 TControlScrollBar.NeedsScrollBarVisible + 0001:00056948 GetRealScrollPosition + 0001:000569A8 TControlScrollBar.ScrollMessage + 0001:00056CA0 TControlScrollBar.SetButtonSize + 0001:00056CE4 TControlScrollBar.SetColor + 0001:00056D00 TControlScrollBar.SetParentColor + 0001:00056D18 TControlScrollBar.SetPosition + 0001:00056DDC TControlScrollBar.SetSize + 0001:00056E20 TControlScrollBar.SetStyle + 0001:00056E38 TControlScrollBar.SetThumbSize + 0001:00056E50 TControlScrollBar.DoSetRange + 0001:00056E68 TControlScrollBar.SetRange + 0001:00056E7C TControlScrollBar.IsRangeStored + 0001:00056E88 TControlScrollBar.SetVisible + 0001:00056E94 UpdateScrollProperties + 0001:00056F9C TControlScrollBar.Update + 0001:000570B4 TScrollingWinControl.Create + 0001:0005711C TScrollingWinControl.Destroy + 0001:00057158 TScrollingWinControl.CreateParams + 0001:00057168 TScrollingWinControl.CreateWnd + 0001:000571A8 TScrollingWinControl.AlignControls + 0001:000571C8 TScrollingWinControl.AutoScrollEnabled + 0001:000571E8 TScrollingWinControl.DoFlipChildren + 0001:00057300 TScrollingWinControl.CalcAutoRange + 0001:00057324 TScrollingWinControl.SetAutoScroll + 0001:00057360 TScrollingWinControl.SetHorzScrollBar + 0001:00057370 TScrollingWinControl.SetVertScrollBar + 0001:00057380 TScrollingWinControl.UpdateScrollBars + 0001:00057478 TScrollingWinControl.AutoScrollInView + 0001:00057490 TScrollingWinControl.ScrollInView + 0001:000575E4 TScrollingWinControl.ScaleScrollBars + 0001:00057688 TScrollingWinControl.ChangeScale + 0001:000576AC TScrollingWinControl.Resizing + 0001:000576B0 TScrollingWinControl.WMSize + 0001:0005778C TScrollingWinControl.WMHScroll + 0001:000577B0 TScrollingWinControl.WMVScroll + 0001:000577D4 TScrollingWinControl.AdjustClientRect + 0001:00057844 TScrollingWinControl.CMBiDiModeChanged + 0001:000578D4 TScrollBox.Create + 0001:00057934 TScrollBox.CreateParams + 0001:00057984 TScrollBox.SetBorderStyle + 0001:00057998 TScrollBox.WMNCHitTest + 0001:000579AC TScrollBox.CMCtl3DChanged + 0001:000579D8 TCustomForm.Create + 0001:00057B64 TCustomForm.AfterConstruction + 0001:00057B9C TCustomForm.CreateNew + 0001:00057D0C TCustomForm.BeforeDestruction + 0001:00057D74 TCustomForm.Destroy + 0001:00057E58 TCustomForm.DoCreate + 0001:00057ED4 TCustomForm.DoDestroy + 0001:00057F34 TCustomForm.Loaded + 0001:00057F70 TCustomForm.Notification + 0001:0005807C TCustomForm.ReadState + 0001:000582E4 TCustomForm.DefineProperties + 0001:00058394 TCustomForm.ReadIgnoreFontProperty + 0001:000583B4 TCustomForm.ReadTextHeight + 0001:000583CC TCustomForm.WriteTextHeight + 0001:000583E8 TCustomForm.WritePixelsPerInch + 0001:00058404 TCustomForm.GetTextHeight + 0001:00058428 TCustomForm.BeginAutoDrag + 0001:0005842C TCustomForm.ChangeScale + 0001:000584AC TCustomForm.IconChanged + 0001:00058508 TCustomForm.IsClientSizeStored + 0001:00058518 TCustomForm.IsFormSizeStored + 0001:00058540 TCustomForm.IsAutoScrollStored + 0001:00058574 TCustomForm.DoClose + 0001:00058594 TCustomForm.DoHide + 0001:000585B4 TCustomForm.DoShow + 0001:000585D4 TCustomForm.GetClientRect + 0001:0005865C TCustomForm.GetChildren + 0001:000586C8 TCustomForm.GetFloating + 0001:000586F4 TCustomForm.SetChildOrder + 0001:00058788 TCustomForm.SetParentBiDiMode + 0001:000587B0 TCustomForm.SetClientWidth + 0001:000587E0 TCustomForm.SetClientHeight + 0001:00058810 TCustomForm.SetVisible + 0001:00058854 TCustomForm.VisibleChanging + 0001:000588B8 TCustomForm.WantChildKey + 0001:000588BC TCustomForm.SetParent + 0001:000588F4 TCustomForm.ValidateRename + 0001:00058934 TCustomForm.WndProc + 0001:00058D6C Default + 0001:00058DB8 MaximizedChildren + 0001:00058DF8 TCustomForm.ClientWndProc + 0001:00058F40 TCustomForm.AlignControls + 0001:00058F7C TCustomForm.CMBiDiModeChanged + 0001:00059014 TCustomForm.CMParentBiDiModeChanged + 0001:0005909C TCustomForm.SetBorderIcons + 0001:000590C8 TCustomForm.SetBorderStyle + 0001:00059100 TCustomForm.Dock + 0001:00059144 TCustomForm.DoDock + 0001:00059198 TCustomForm.GetActiveMDIChild + 0001:000591CC TCustomForm.GetMDIChildCount + 0001:00059218 TCustomForm.GetMDIChildren + 0001:00059268 EnumMonitorsProc + 0001:00059298 TCustomForm.GetMonitor + 0001:00059380 TCustomForm.GetCanvas + 0001:00059388 TCustomForm.SetIcon + 0001:00059394 TCustomForm.IsForm + 0001:0005939C TCustomForm.IsIconStored + 0001:000593C4 TCustomForm.SetFormStyle + 0001:00059444 TCustomForm.RefreshMDIMenu + 0001:000594C0 TCustomForm.SetObjectMenuItem + 0001:000594E4 TCustomForm.SetWindowMenu + 0001:0005950C TCustomForm.SetMenu + 0001:000596E0 TCustomForm.GetPixelsPerInch + 0001:000596F4 TCustomForm.SetPixelsPerInch + 0001:00059728 TCustomForm.SetPosition + 0001:00059744 TCustomForm.GetScaled + 0001:00059750 TCustomForm.SetScaled + 0001:00059780 TCustomForm.CMColorChanged + 0001:000597A4 TCustomForm.NormalColor + 0001:000597BC TCustomForm.CMCtl3DChanged + 0001:00059804 TCustomForm.CMFontChanged + 0001:00059824 TCustomForm.CMMenuChanged + 0001:00059840 TCustomForm.SetWindowState + 0001:00059880 TCustomForm.SetWindowToMonitor + 0001:00059BD4 TCustomForm.CreateParams + 0001:00059DF0 TCustomForm.CreateWnd + 0001:00059F30 TCustomForm.CreateWindowHandle + 0001:0005A068 TCustomForm.DestroyWindowHandle + 0001:0005A0AC TCustomForm.DefaultHandler + 0001:0005A110 TCustomForm.SetActiveControl + 0001:0005A1C8 TCustomForm.DefocusControl + 0001:0005A210 TCustomForm.FocusControl + 0001:0005A234 TCustomForm.SetFocusedControl + 0001:0005A4C4 TCustomForm.ActiveChanged + 0001:0005A4C8 TCustomForm.SetWindowFocus + 0001:0005A518 TCustomForm.SetActive + 0001:0005A57C TCustomForm.SendCancelMode + 0001:0005A5CC TCustomForm.MergeMenu + 0001:0005A674 DoNestedActivation + 0001:0005A6C0 TCustomForm.Activate + 0001:0005A6F0 TCustomForm.Deactivate + 0001:0005A720 TCustomForm.Paint + 0001:0005A740 TCustomForm.GetIconHandle + 0001:0005A75C TCustomForm.PaintWindow + 0001:0005A818 TCustomForm.PaletteChanged + 0001:0005A8B8 TCustomForm.WMPaint + 0001:0005A938 TCustomForm.WMIconEraseBkgnd + 0001:0005A998 TCustomForm.WMEraseBkgnd + 0001:0005A9D0 TCustomForm.WMQueryDragIcon + 0001:0005A9E4 ModifySystemMenu + 0001:0005AAE0 TCustomForm.WMNCCreate + 0001:0005AB14 TCustomForm.WMNCLButtonDown + 0001:0005ABA4 TCustomForm.WMDestroy + 0001:0005AC04 TCustomForm.WMCommand + 0001:0005AC38 TCustomForm.WMInitMenuPopup + 0001:0005AC50 TCustomForm.WMMenuChar + 0001:0005AC88 TCustomForm.WMMenuSelect + 0001:0005AD30 TCustomForm.WMActivate + 0001:0005AD50 TCustomForm.Resizing + 0001:0005AD88 TCustomForm.WMClose + 0001:0005AD90 TCustomForm.WMQueryEndSession + 0001:0005ADBC TCustomForm.CMAppSysCommand + 0001:0005AE14 TCustomForm.WMSysCommand + 0001:0005AEA0 TCustomForm.WMShowWindow + 0001:0005AF38 TCustomForm.WMMDIActivate + 0001:0005AF90 TCustomForm.WMNextDlgCtl + 0001:0005AFBC TCustomForm.WMEnterMenuLoop + 0001:0005AFD8 GetMenuHelpContext + 0001:0005B018 ControlHasHelp + 0001:0005B050 GetHelpInfo + 0001:0005B084 TCustomForm.WMHelp + 0001:0005B1F0 TCustomForm.WMGetMinMaxInfo + 0001:0005B264 TCustomForm.WMWindowPosChanging + 0001:0005B2FC TCustomForm.CMActivate + 0001:0005B320 TCustomForm.CMDeactivate + 0001:0005B344 TCustomForm.CMDialogKey + 0001:0005B3E0 TCustomForm.CMShowingChanged + 0001:0005B958 TCustomForm.CMIconChanged + 0001:0005B978 TCustomForm.CMRelease + 0001:0005B980 TCustomForm.CMTextChanged + 0001:0005B9D0 TCustomForm.CMUIActivate + 0001:0005B9D8 TCustomForm.CMParentFontChanged + 0001:0005BA44 TCustomForm.CMIsShortCut + 0001:0005BA70 TCustomForm.Close + 0001:0005BB14 TCustomForm.CloseQuery + 0001:0005BB78 TCustomForm.CloseModal + 0001:0005BC10 TCustomForm.Hide + 0001:0005BC18 TCustomForm.Show + 0001:0005BC30 TCustomForm.SetFocus + 0001:0005BCAC TCustomForm.Release + 0001:0005BCC8 TCustomForm.ShowModal + 0001:0005BF68 TraverseClients + 0001:0005BFD8 TCustomForm.UpdateActions + 0001:0005C040 TCustomForm.RequestAlign + 0001:0005C05C TCustomForm.WMSettingChange + 0001:0005C080 ProcessExecute + 0001:0005C0B0 TraverseClients + 0001:0005C12C TCustomForm.CMActionExecute + 0001:0005C180 ProcessUpdate + 0001:0005C1B0 TraverseClients + 0001:0005C22C TCustomForm.CMActionUpdate + 0001:0005C280 DispatchShortCut + 0001:0005C2D4 TCustomForm.IsShortCut + 0001:0005C350 TCustomForm.QueryInterface + 0001:0005C38C TCustomForm.MouseWheelHandler + 0001:0005C3C4 TCustomForm.HandleCreateException + 0001:0005C3D4 TCustomForm.SetLayeredAttribs + 0001:0005C4AC TCustomForm.SetAlphaBlend + 0001:0005C4C0 TCustomForm.SetAlphaBlendValue + 0001:0005C4D4 TCustomForm.SetTransparentColorValue + 0001:0005C4E8 TCustomForm.SetTransparentColor + 0001:0005C4FC TCustomForm.InitAlphaBlending + 0001:0005C528 TCustomDockForm.Create + 0001:0005C590 TCustomDockForm.DoAddDockClient + 0001:0005C674 TCustomDockForm.DoRemoveDockClient + 0001:0005C694 TCustomDockForm.Loaded + 0001:0005C6E0 TCustomDockForm.GetSiteInfo + 0001:0005C70C TCustomDockForm.WMNCHitTest + 0001:0005C734 TCustomDockForm.WMNCLButtonDown + 0001:0005C7CC TCustomDockForm.CMControlListChange + 0001:0005C824 TCustomDockForm.CMDockNotification + 0001:0005C8F8 TCustomDockForm.CMUnDockClient + 0001:0005C910 TCustomDockForm.CMVisibleChanged + 0001:0005C94C TMonitor.GetLeft + 0001:0005C964 TMonitor.GetHeight + 0001:0005C980 TMonitor.GetTop + 0001:0005C998 TMonitor.GetWidth + 0001:0005C9B4 TMonitor.GetBoundsRect + 0001:0005C9E4 TScreen.Create + 0001:0005CB3C TScreen.Destroy + 0001:0005CC04 TScreen.GetHeight + 0001:0005CC10 TScreen.GetWidth + 0001:0005CC1C TScreen.GetDesktopTop + 0001:0005CC28 TScreen.GetDesktopLeft + 0001:0005CC34 TScreen.GetDesktopHeight + 0001:0005CC40 TScreen.GetDesktopWidth + 0001:0005CC4C TScreen.GetMonitor + 0001:0005CC60 TScreen.GetMonitorCount + 0001:0005CC7C TScreen.GetForm + 0001:0005CC90 TScreen.GetFormCount + 0001:0005CC98 TScreen.GetCustomForms + 0001:0005CCAC TScreen.GetCustomFormCount + 0001:0005CCB4 TScreen.UpdateLastActive + 0001:0005CD00 TScreen.AddForm + 0001:0005CD38 TScreen.RemoveForm + 0001:0005CD88 TScreen.AddDataModule + 0001:0005CD94 TScreen.RemoveDataModule + 0001:0005CDA0 TScreen.CreateCursors + 0001:0005CDFC TScreen.DestroyCursors + 0001:0005CE58 TScreen.DeleteCursor + 0001:0005CEA0 TScreen.InsertCursor + 0001:0005CEC8 TScreen.GetImes + 0001:0005D0C8 TScreen.GetDefaultIME + 0001:0005D0E4 TScreen.IconFontChanged + 0001:0005D134 TScreen.GetDataModule + 0001:0005D148 TScreen.GetDataModuleCount + 0001:0005D150 TScreen.GetCursors + 0001:0005D178 TScreen.SetCursor + 0001:0005D208 TScreen.SetCursors + 0001:0005D250 TScreen.GetMetricSettings + 0001:0005D3A4 TScreen.DisableAlign + 0001:0005D3AC TScreen.EnableAlign + 0001:0005D3CC TScreen.Realign + 0001:0005D3D4 InsertBefore + 0001:0005D434 DoPosition + 0001:0005D5E4 DoAlign + 0001:0005D730 AlignWork + 0001:0005D788 TScreen.AlignForms + 0001:0005D810 TScreen.AlignForm + 0001:0005D898 TScreen.ResetFonts + 0001:0005D8A4 GetHint + 0001:0005D8DC GetHintControl + 0001:0005D8FC HintTimerProc + 0001:0005D950 HintMouseThread + 0001:0005D9AC HintGetMsgHook + 0001:0005D9F0 HookHintHooks + 0001:0005DA64 UnhookHintHooks + 0001:0005DAC0 GetAnimation + 0001:0005DAF0 SetAnimation + 0001:0005DB18 ShowWinNoAnimate + 0001:0005DB58 TApplication.Create + 0001:0005DD44 TApplication.Destroy + 0001:0005DE60 TApplication.CreateHandle + 0001:0005E004 TApplication.ControlDestroyed + 0001:0005E064 GetTopMostWindows + 0001:0005E0D4 TApplication.DoNormalizeTopMosts + 0001:0005E184 TApplication.NormalizeTopMosts + 0001:0005E18C TApplication.NormalizeAllTopMosts + 0001:0005E194 TApplication.RestoreTopMosts + 0001:0005E200 TApplication.UseRightToLeftReading + 0001:0005E218 TApplication.UseRightToLeftAlignment + 0001:0005E230 TApplication.CheckIniChange + 0001:0005E288 TApplication.SettingChange + 0001:0005E2F4 Default + 0001:0005E330 DrawAppIcon + 0001:0005E37C TApplication.WndProc + 0001:0005EA54 TApplication.GetIconHandle + 0001:0005EA70 TApplication.Minimize + 0001:0005EB20 TApplication.Restore + 0001:0005EC20 TApplication.BringToFront + 0001:0005EC5C TApplication.GetTitle + 0001:0005ECA8 TApplication.SetTitle + 0001:0005ED38 TApplication.IsDlgMsg + 0001:0005ED5C TApplication.IsMDIMsg + 0001:0005ED98 TApplication.IsKeyMsg + 0001:0005EE50 TApplication.IsHintMsg + 0001:0005EE84 TApplication.IsShortCut + 0001:0005EEF0 TApplication.ProcessMessage + 0001:0005EF88 TApplication.ProcessMessages + 0001:0005EFA0 TApplication.HandleMessage + 0001:0005EFC4 TApplication.HookMainWindow + 0001:0005F020 TApplication.UnhookMainWindow + 0001:0005F09C TApplication.Initialize + 0001:0005F0B4 TApplication.CreateForm + 0001:0005F134 TApplication.Run + 0001:0005F220 TApplication.Terminate + 0001:0005F234 TApplication.HandleException + 0001:0005F2C4 TApplication.MessageBox + 0001:0005F42C TApplication.ShowException + 0001:0005F504 TApplication.InvokeHelp + 0001:0005F634 TApplication.HelpKeyword + 0001:0005F69C TApplication.HelpContext + 0001:0005F704 TApplication.HelpCommand + 0001:0005F70C TApplication.GetExeName + 0001:0005F71C TApplication.SetShowHint + 0001:0005F76C TApplication.DoActionIdle + 0001:0005F7D0 TApplication.DoMouseIdle + 0001:0005F854 TApplication.Idle + 0001:0005F970 TApplication.NotifyForms + 0001:0005F9AC TApplication.IconChanged + 0001:0005FA10 TApplication.SetHint + 0001:0005FAA4 SetVisible + 0001:0005FB00 TApplication.UpdateVisible + 0001:0005FB88 TApplication.ValidateHelpSystem + 0001:0005FBB0 TApplication.StartHintTimer + 0001:0005FBF4 TApplication.StopHintTimer + 0001:0005FC1C TApplication.HintMouseMessage + 0001:0005FD2C TApplication.HintTimerExpired + 0001:0005FD64 TApplication.HideHint + 0001:0005FDA8 TApplication.CancelHint + 0001:0005FDD0 FindScanline + 0001:0005FDE0 GetCursorHeightMargin + 0001:0005FF34 ValidateHintWindow + 0001:0005FF94 MultiLineWidth + 0001:0006002C TApplication.ActivateHint + 0001:000603C0 TApplication.GetCurrentHelpFile + 0001:000603FC TApplication.DispatchAction + 0001:0006048C TApplication.ExecuteAction + 0001:000604B4 TApplication.UpdateAction + 0001:000604DC InitProcs + 0001:00060528 TApplication.WakeMainThread + 0001:00060538 TApplication.HookSynchronizeWakeup + 0001:00060548 TApplication.UnhookSynchronizeWakeup + 0001:00060568 Finalization + 0001:000605C4 Forms + 0001:00060608 RC_LineIn + 0001:00060670 IsWinNT + 0001:00060694 SplitLines + 0001:0006075C RC_Run + 0001:00060B14 Finalization + 0001:00060B50 RedirectConsole + 0001:00060D30 TCustomIniFile.Create + 0001:00060D6C TCustomIniFile.ReadInteger + 0001:00060E30 TCustomIniFile.WriteInteger + 0001:00060E8C TCustomIniFile.ReadBool + 0001:00060EB8 TCustomIniFile.ReadDate + 0001:00060F70 TCustomIniFile.ReadDateTime + 0001:00061028 TCustomIniFile.ReadFloat + 0001:000610E0 TCustomIniFile.ReadTime + 0001:00061198 TCustomIniFile.WriteDate + 0001:000611F8 TCustomIniFile.WriteDateTime + 0001:00061258 TCustomIniFile.WriteFloat + 0001:000612BC TCustomIniFile.WriteTime + 0001:00061334 TCustomIniFile.WriteBool + 0001:00061350 TCustomIniFile.ReadBinaryStream + 0001:000614C0 TCustomIniFile.WriteBinaryStream + 0001:00061634 TIniFile.Destroy + 0001:00061660 TIniFile.ReadString + 0001:000616C0 TIniFile.WriteString + 0001:0006172C TIniFile.ReadSections + 0001:0006182C TIniFile.ReadSection + 0001:00061934 TIniFile.ReadSectionValues + 0001:00061A80 TIniFile.EraseSection + 0001:00061AD4 TIniFile.DeleteKey + 0001:00061B04 TIniFile.UpdateFile + 0001:00061B20 Finalization + 0001:00061B68 IniFiles + 0001:00061B70 FD_SET + 0001:00061B80 FD_ZERO + 0001:00061B88 accept + 0001:00061B90 bind + 0001:00061B98 closesocket + 0001:00061BA0 connect + 0001:00061BA8 getsockopt + 0001:00061BB0 htons + 0001:00061BB8 inet_addr + 0001:00061BC0 ioctlsocket + 0001:00061BC8 listen + 0001:00061BD0 ntohs + 0001:00061BD8 recv + 0001:00061BE0 select + 0001:00061BE8 send + 0001:00061BF0 setsockopt + 0001:00061BF8 socket + 0001:00061C00 gethostbyname + 0001:00061C08 getservbyname + 0001:00061C10 WSAAsyncSelect + 0001:00061C18 WSAAsyncGetHostByName + 0001:00061C20 WSAAsyncGetServByName + 0001:00061C28 WSACancelAsyncRequest + 0001:00061C30 WSAGetLastError + 0001:00061C38 WSAStartup + 0001:00061C40 WSACleanup + 0001:00061C48 Finalization + 0001:00061C78 WinSock + 0001:00061E70 TSynchroObject.Acquire + 0001:00061E74 TSynchroObject.Release + 0001:00061E78 THandleObject.Destroy + 0001:00061EA8 TEvent.Create + 0001:00061F00 TEvent.WaitFor + 0001:00061F48 TEvent.SetEvent + 0001:00061F54 TEvent.ResetEvent + 0001:00061F60 TSimpleEvent.Create + 0001:00061FA0 TCriticalSection.Create + 0001:00061FE0 TCriticalSection.Destroy + 0001:00062010 TCriticalSection.Acquire + 0001:0006201C TCriticalSection.Release + 0001:00062028 TCriticalSection.Enter + 0001:00062030 TCriticalSection.Leave + 0001:00062038 Finalization + 0001:00062068 SyncObjs + 0001:00062E54 CheckSocketResult + 0001:00062F0C Startup + 0001:00062FB8 Cleanup + 0001:00063058 TCustomWinSocket.Create + 0001:000630D0 TCustomWinSocket.Destroy + 0001:0006313C TCustomWinSocket.Accept + 0001:00063140 TCustomWinSocket.AsyncInitSocket + 0001:000633F8 TCustomWinSocket.Close + 0001:00063404 TCustomWinSocket.Connect + 0001:00063408 TCustomWinSocket.Lock + 0001:00063414 TCustomWinSocket.Unlock + 0001:00063420 CheckError + 0001:000634D8 TCustomWinSocket.CMSocketMessage + 0001:00063564 TCustomWinSocket.CMDeferFree + 0001:0006356C TCustomWinSocket.DeferFree + 0001:00063584 TCustomWinSocket.DoSetAsyncStyles + 0001:000635E0 TCustomWinSocket.DoListen + 0001:00063660 TCustomWinSocket.DoOpen + 0001:000636CC TCustomWinSocket.GetHandle + 0001:000636E8 TCustomWinSocket.LookupName + 0001:00063744 TCustomWinSocket.LookupService + 0001:00063778 TCustomWinSocket.InitSocket + 0001:00063810 TCustomWinSocket.Listen + 0001:00063918 TCustomWinSocket.Open + 0001:00063A18 TCustomWinSocket.Disconnect + 0001:00063B24 TCustomWinSocket.DefaultHandler + 0001:00063B50 TCustomWinSocket.Event + 0001:00063B68 TCustomWinSocket.Error + 0001:00063B8C DropStream + 0001:00063BD4 TCustomWinSocket.SendStreamPiece + 0001:00063D5C TCustomWinSocket.SetAsyncStyles + 0001:00063D84 TCustomWinSocket.Read + 0001:00063DA0 TCustomWinSocket.ReceiveBuf + 0001:00063F0C TCustomWinSocket.ReceiveText + 0001:00063F48 TCustomWinSocket.WndProc + 0001:00063F9C TCustomWinSocket.Write + 0001:00063FCC TCustomWinSocket.CMLookupComplete + 0001:00064124 TClientWinSocket.Connect + 0001:00064138 TClientWinSocket.SetClientType + 0001:00064188 TServerClientWinSocket.Create + 0001:00064234 TServerClientWinSocket.Destroy + 0001:00064268 TServerWinSocket.Create + 0001:000642DC TServerWinSocket.Destroy + 0001:0006431C TServerWinSocket.AddClient + 0001:00064384 TServerWinSocket.RemoveClient + 0001:000643D8 TServerWinSocket.AddThread + 0001:00064454 TServerWinSocket.RemoveThread + 0001:000644A8 TServerWinSocket.ClientEvent + 0001:000644FC TServerWinSocket.ClientError + 0001:00064518 TServerWinSocket.Accept + 0001:0006461C TServerWinSocket.Disconnect + 0001:00064734 TServerWinSocket.DoCreateThread + 0001:00064744 TServerWinSocket.Listen + 0001:00064790 TServerWinSocket.SetServerType + 0001:000647E0 TServerWinSocket.SetThreadCacheSize + 0001:0006487C TServerWinSocket.GetClientSocket + 0001:000648BC TServerWinSocket.ThreadEnd + 0001:000648DC TServerWinSocket.ThreadStart + 0001:000648FC TServerWinSocket.GetServerThread + 0001:000649D0 TServerWinSocket.ClientConnect + 0001:000649F0 TServerWinSocket.ClientDisconnect + 0001:00064A20 TServerWinSocket.ClientRead + 0001:00064A40 TServerWinSocket.ClientWrite + 0001:00064A60 TServerWinSocket.ClientErrorEvent + 0001:00064A8C TServerAcceptThread.Create + 0001:00064AD0 TServerAcceptThread.Execute + 0001:00064AEC TServerClientThread.Create + 0001:00064B64 TServerClientThread.Destroy + 0001:00064B9C TServerClientThread.ReActivate + 0001:00064BD8 TServerClientThread.DoHandleException + 0001:00064C24 TServerClientThread.DoRead + 0001:00064C40 TServerClientThread.DoTerminate + 0001:00064C5C TServerClientThread.DoWrite + 0001:00064C70 TServerClientThread.HandleEvent + 0001:00064C80 TServerClientThread.HandleError + 0001:00064C94 TServerClientThread.Event + 0001:00064CA4 TServerClientThread.Error + 0001:00064CB8 TServerClientThread.HandleException + 0001:00064D20 TServerClientThread.Execute + 0001:00064DC8 TServerClientThread.ClientExecute + 0001:00064E70 TServerClientThread.StartConnect + 0001:00064E94 TServerClientThread.EndConnect + 0001:00064EB8 TAbstractSocket.DoEvent + 0001:00064ECC TAbstractSocket.DoError + 0001:00064EE4 TAbstractSocket.SetActive + 0001:00064F04 TAbstractSocket.InitSocket + 0001:00064F1C TAbstractSocket.Loaded + 0001:00064F34 TAbstractSocket.SetAddress + 0001:00064FB4 TAbstractSocket.SetHost + 0001:00065034 TAbstractSocket.SetPort + 0001:00065060 TAbstractSocket.SetService + 0001:000650E0 TAbstractSocket.Open + 0001:000650E8 TCustomSocket.Event + 0001:000651E8 TCustomSocket.Error + 0001:00065214 TClientSocket.Create + 0001:00065274 TClientSocket.Destroy + 0001:000652A4 TClientSocket.DoActivate + 0001:000652F4 TClientSocket.GetClientType + 0001:00065300 TClientSocket.SetClientType + 0001:0006530C TCustomServerSocket.Destroy + 0001:0006533C TCustomServerSocket.DoActivate + 0001:00065380 TCustomServerSocket.GetServerType + 0001:0006538C TCustomServerSocket.SetServerType + 0001:00065398 TCustomServerSocket.GetGetThreadEvent + 0001:000653AC TCustomServerSocket.SetGetThreadEvent + 0001:000653C8 TCustomServerSocket.GetGetSocketEvent + 0001:000653DC TCustomServerSocket.SetGetSocketEvent + 0001:000653F8 TCustomServerSocket.GetThreadCacheSize + 0001:00065404 TCustomServerSocket.SetThreadCacheSize + 0001:00065410 TCustomServerSocket.GetOnThreadStart + 0001:00065428 TCustomServerSocket.GetOnThreadEnd + 0001:00065440 TCustomServerSocket.SetOnThreadStart + 0001:00065460 TCustomServerSocket.SetOnThreadEnd + 0001:00065480 TCustomServerSocket.GetOnClientEvent + 0001:000654F8 TCustomServerSocket.SetOnClientEvent + 0001:00065574 TCustomServerSocket.GetOnClientError + 0001:0006558C TCustomServerSocket.SetOnClientError + 0001:000655AC TServerSocket.Create + 0001:0006561C Finalization + 0001:0006564C ScktComp + 0001:00065654 Finalization + 0001:00065684 JvWin32 + 0001:0006568C Finalization + 0001:000656BC JvConsts + 0001:000656F8 Finalization + 0001:00065728 JVCLVer + 0001:00065810 Finalization + 0001:00065840 JvComponentBase + 0001:00065848 SecondsBetween + 0001:00065878 SpanOfNowAndThen + 0001:000658A8 SecondSpan + 0001:000658D8 Finalization + 0001:00065908 DateUtils + 0001:00065B90 Finalization + 0001:00065BC0 JvResources + 0001:00066318 Finalization + 0001:0006665C JvTypes + 0001:00066670 Finalization + 0001:000666A0 JvVCL5Utils + 0001:000666C8 Finalization + 0001:000666F8 ComConst + 0001:0006686C TrimPunctuation + 0001:000668BC EOleSysError.Create + 0001:0006698C EOleException.Create + 0001:00066A24 OleError + 0001:00066A40 OleCheck + 0001:00066A58 LoadComExProcs + 0001:00066B5C SafeCallError + 0001:00066C5C DispatchInvoke + 0001:00066FA0 RaiseNameException + 0001:00066FD4 GetIDsOfNames + 0001:000670B4 RaiseException + 0001:000670CC VarDispInvoke + 0001:00067168 DispCallError + 0001:0006723C DispatchInvokeError + 0001:00067248 ClearExcepInfo + 0001:00067258 DispCall + 0001:0006733C DispCallByID + 0001:00067418 InitComObj + 0001:00067490 Finalization + 0001:00067510 ComObj + 0001:00067568 Finalization + 0001:00067598 MMSystem + 0001:000675B8 Finalization + 0001:00067600 Registry + 0001:000676D4 GetFileVersion + 0001:000677BC GetShellVersion + 0001:00067830 GetAnimation + 0001:00067860 SetAnimation + 0001:00067888 ShowWinNoAnimate + 0001:000678B8 Finalization + 0001:00067954 JvJCLUtils + 0001:0006795C Finalization + 0001:0006798C RichEdit + 0001:00067994 Finalization + 0001:000679C4 ToolWin + 0001:000679F4 Finalization + 0001:00067A24 ComStrs + 0001:00067A2C DestroyLocals + 0001:00067AC4 Finalization + 0001:00067AFC Buttons + 0001:00067B24 Finalization + 0001:00067B54 ExtDlgs + 0001:00067B70 Finalization + 0001:00067BC0 Mapi + 0001:00067BC8 Finalization + 0001:00067C18 ExtActns + 0001:000688F4 TListControlItem.Assign + 0001:0006897C TListControlItem.Changed + 0001:0006898C TListControlItem.Create + 0001:000689C8 TListControlItem.GetDisplayName + 0001:000689F4 TListControlItem.SetCaption + 0001:00068A10 TListControlItem.SetData + 0001:00068A1C TListControlItem.SetImageIndex + 0001:00068A28 ListItemsCompare + 0001:00068A54 TListControlItems.Add + 0001:00068A64 TListControlItems.CustomSort + 0001:00068A94 TListControlItems.CompareItems + 0001:00068AD0 TListControlItems.ExchangeItems + 0001:00068B2C TListControlItems.QuickSort + 0001:00068BC0 TListControlItems.GetListItem + 0001:00068BD4 TListControlItems.SetSortType + 0001:00068BEC TListControlItems.Sort + 0001:00068BF8 TCustomListAction.Create + 0001:00068C50 TCustomListAction.ExecuteTarget + 0001:00068D78 TCustomListAction.GetCount + 0001:00068DA4 TCustomListAction.GetString + 0001:00068DB0 TCustomListAction.HandlesTarget + 0001:00068DB4 TCustomListAction.Loaded + 0001:00068DE8 TCustomListAction.SetActive + 0001:00068EE8 TCustomListAction.SetImages + 0001:00068F54 TCustomListAction.SetItemIndex + 0001:00068FB0 TCustomListAction.SetString + 0001:00068FB4 TVirtualListAction.GetItem + 0001:00069004 TStaticListItems.Notify + 0001:000691B4 TStaticListItems.Update + 0001:000692D0 TStaticListAction.Create + 0001:00069330 TStaticListAction.Destroy + 0001:00069360 TStaticListAction.GetCount + 0001:0006936C TStaticListAction.GetItem + 0001:000693D0 TStaticListAction.GetItemClass + 0001:000693D8 TStaticListAction.GetString + 0001:000693FC TStaticListAction.SetListitems + 0001:0006940C TStaticListAction.SetString + 0001:00069430 TListActionLink.IsActiveLinked + 0001:00069444 TListActionLink.IsImagesLinked + 0001:00069470 TListActionLink.SetAction + 0001:000694B4 TListActionLink.SetActive + 0001:00069520 TListActionLink.SetImages + 0001:00069524 TListActionLink.RefreshControl + 0001:00069678 TListActionLink.AddItem + 0001:0006967C TListActionLink.AddItem + 0001:000696A8 TListActionLink.SetItemIndex + 0001:000696E0 Finalization + 0001:00069710 ListActns + 0001:0006BF14 InitCommonControl + 0001:0006BF40 CheckCommonControl + 0001:0006BF68 TTextAttributes.Create + 0001:0006BFB0 TTextAttributes.InitFormat + 0001:0006BFCC TTextAttributes.GetAttributes + 0001:0006C00C TTextAttributes.SetAttributes + 0001:0006C048 TTextAttributes.GetCharset + 0001:0006C05C TTextAttributes.SetCharset + 0001:0006C08C TTextAttributes.GetColor + 0001:0006C0AC TTextAttributes.SetColor + 0001:0006C0F4 TTextAttributes.GetName + 0001:0006C118 TTextAttributes.SetName + 0001:0006C188 TTextAttributes.GetStyle + 0001:0006C1D8 TTextAttributes.SetStyle + 0001:0006C230 TTextAttributes.GetSize + 0001:0006C24C TTextAttributes.SetSize + 0001:0006C284 TTextAttributes.GetPitch + 0001:0006C2B4 TTextAttributes.SetPitch + 0001:0006C2F4 TTextAttributes.Assign + 0001:0006C434 TTextAttributes.AssignTo + 0001:0006C564 TParaAttributes.Create + 0001:0006C5A0 TParaAttributes.InitPara + 0001:0006C5BC TParaAttributes.GetAttributes + 0001:0006C5F0 TParaAttributes.SetAttributes + 0001:0006C654 TParaAttributes.GetAlignment + 0001:0006C670 TParaAttributes.SetAlignment + 0001:0006C6AC TParaAttributes.GetNumbering + 0001:0006C6C4 TParaAttributes.SetNumbering + 0001:0006C728 TParaAttributes.GetFirstIndent + 0001:0006C748 TParaAttributes.SetFirstIndent + 0001:0006C784 TParaAttributes.GetLeftIndent + 0001:0006C7A4 TParaAttributes.SetLeftIndent + 0001:0006C7E0 TParaAttributes.GetRightIndent + 0001:0006C800 TParaAttributes.SetRightIndent + 0001:0006C83C TParaAttributes.GetTab + 0001:0006C864 TParaAttributes.SetTab + 0001:0006C8B8 TParaAttributes.Assign + 0001:0006C954 TConversion.ConvertReadStream + 0001:0006C968 TConversion.ConvertWriteStream + 0001:0006CA88 TRichEditStrings.Destroy + 0001:0006CAB8 TRichEditStrings.AddStrings + 0001:0006CB30 TRichEditStrings.GetCount + 0001:0006CB88 TRichEditStrings.Get + 0001:0006CBDC TRichEditStrings.Put + 0001:0006CC68 TRichEditStrings.Insert + 0001:0006CDF4 TRichEditStrings.Delete + 0001:0006CEA0 TRichEditStrings.Clear + 0001:0006CEB0 TRichEditStrings.SetUpdateState + 0001:0006CF00 TRichEditStrings.EnableChange + 0001:0006CF5C TRichEditStrings.SetTextStr + 0001:0006CFAC AdjustLineBreaks + 0001:0006CFE0 StreamSave + 0001:0006D040 StreamLoad + 0001:0006D134 TRichEditStrings.LoadFromStream + 0001:0006D298 TRichEditStrings.SaveToStream + 0001:0006D3A8 TRichEditStrings.LoadFromFile + 0001:0006D4B0 TRichEditStrings.SaveToFile + 0001:0006D5A4 TCustomRichEdit.Create + 0001:0006D6C0 TCustomRichEdit.Destroy + 0001:0006D71C TCustomRichEdit.Clear + 0001:0006D734 TCustomRichEdit.CreateParams + 0001:0006D7C0 TCustomRichEdit.CreateWnd + 0001:0006D8E8 TCustomRichEdit.DestroyWnd + 0001:0006D9B4 TCustomRichEdit.WMNCDestroy + 0001:0006D9BC TCustomRichEdit.WMSetFont + 0001:0006D9CC TCustomRichEdit.WMRButtonUp + 0001:0006DA24 TCustomRichEdit.CMFontChanged + 0001:0006DA34 TCustomRichEdit.DoSetMaxLength + 0001:0006DA54 TCustomRichEdit.GetCaretPos + 0001:0006DAB4 TCustomRichEdit.SetCaretPos + 0001:0006DB00 TCustomRichEdit.GetSelLength + 0001:0006DB28 TCustomRichEdit.GetSelStart + 0001:0006DB4C TCustomRichEdit.GetSelTextBuf + 0001:0006DBC0 TCustomRichEdit.GetSelText + 0001:0006DC04 TCustomRichEdit.CMBiDiModeChanged + 0001:0006DC5C TCustomRichEdit.SetHideScrollBars + 0001:0006DC70 TCustomRichEdit.SetHideSelection + 0001:0006DCA0 TCustomRichEdit.SetSelLength + 0001:0006DCFC TCustomRichEdit.GetPlainText + 0001:0006DD08 TCustomRichEdit.SetPlainText + 0001:0006DD14 TCustomRichEdit.CMColorChanged + 0001:0006DD40 TCustomRichEdit.SetRichEditStrings + 0001:0006DD50 TCustomRichEdit.SetSelStart + 0001:0006DD78 TCustomRichEdit.Print + 0001:0006DF50 TCustomRichEdit.WMPaint + 0001:0006E010 TCustomRichEdit.WMSetCursor + 0001:0006E0A0 TCustomRichEdit.CNNotify + 0001:0006E11C TCustomRichEdit.SaveClipboard + 0001:0006E14C TCustomRichEdit.ProtectChange + 0001:0006E17C TCustomRichEdit.SelectionChange + 0001:0006E19C TCustomRichEdit.RequestSize + 0001:0006E1BC TListColumn.Create + 0001:0006E264 TListColumn.Destroy + 0001:0006E2C4 TListColumn.DefineProperties + 0001:0006E30C TListColumn.ReadData + 0001:0006E334 TListColumn.WriteData + 0001:0006E358 WriteCols + 0001:0006E454 TListColumn.DoChange + 0001:0006E4D4 TListColumn.SetIndex + 0001:0006E584 TListColumn.SetCaption + 0001:0006E5AC TListColumn.GetWidth + 0001:0006E5D8 TListColumn.IsWidthStored + 0001:0006E5E0 TListColumn.SetWidth + 0001:0006E60C TListColumn.SetAlignment + 0001:0006E644 TListColumn.SetAutoSize + 0001:0006E678 TListColumn.SetImageIndex + 0001:0006E688 TListColumn.SetMaxWidth + 0001:0006E698 TListColumn.SetMinWidth + 0001:0006E6A8 TListColumn.Assign + 0001:0006E71C TListColumn.GetDisplayName + 0001:0006E740 TListColumns.Create + 0001:0006E784 TListColumns.GetItem + 0001:0006E798 TListColumns.Owner + 0001:0006E79C TListColumns.GetOwner + 0001:0006E7A0 TListColumns.Update + 0001:0006E7D4 TListColumns.UpdateCols + 0001:0006E8C0 TWorkArea.Create + 0001:0006E904 TWorkArea.GetDisplayName + 0001:0006E918 TWorkArea.SetDisplayName + 0001:0006E958 TWorkAreas.Update + 0001:0006EA20 TWorkAreas.GetItem + 0001:0006EB48 TSubItems.Create + 0001:0006EB94 TSubItems.Destroy + 0001:0006EBC4 TSubItems.Add + 0001:0006EBEC TSubItems.AddObject + 0001:0006EC14 TSubItems.Clear + 0001:0006EC28 TSubItems.Delete + 0001:0006EC4C TSubItems.GetHandle + 0001:0006EC58 TSubItems.SetColumnWidth + 0001:0006EC9C TSubItems.Insert + 0001:0006ECDC TSubItems.Put + 0001:0006ECF8 TSubItems.RefreshItem + 0001:0006ED24 TSubItems.SetUpdateState + 0001:0006ED30 TSubItems.GetImageIndex + 0001:0006ED44 TSubItems.SetImageIndex + 0001:0006ED50 TListItem.Create + 0001:0006EDA0 TListItem.Destroy + 0001:0006EE0C TListItem.GetListView + 0001:0006EE14 TListItem.Delete + 0001:0006EE38 TListItem.GetHandle + 0001:0006EE4C TListItem.GetChecked + 0001:0006EE90 TListItem.SetChecked + 0001:0006EEDC TListItem.Update + 0001:0006EEF8 TListItem.SetCaption + 0001:0006EFA8 TListItem.SetData + 0001:0006EFD8 TListItem.GetState + 0001:0006F040 TListItem.SetState + 0001:0006F0B0 TListItem.SetImage + 0001:0006F1EC TListItem.SetIndent + 0001:0006F258 TListItem.Assign + 0001:0006F2F0 TListItem.IsEqual + 0001:0006F318 TListItem.SetSubItems + 0001:0006F32C TListItem.GetIndex + 0001:0006F348 TListItem.DisplayRect + 0001:0006F378 TListItem.GetSubItemImage + 0001:0006F384 TListItem.SetSubItemImage + 0001:0006F3F0 TListItems.Create + 0001:0006F42C TListItems.Destroy + 0001:0006F458 TListItems.Add + 0001:0006F464 TListItems.AddItem + 0001:0006F4B4 TListItems.GetCount + 0001:0006F4D8 TListItems.GetHandle + 0001:0006F4E4 TListItems.GetItem + 0001:0006F564 TListItems.IndexOf + 0001:0006F58C TListItems.SetCount + 0001:0006F5A8 TListItems.Clear + 0001:0006F5C8 TListItems.BeginUpdate + 0001:0006F5E0 TListItems.SetUpdateState + 0001:0006F7A4 TListItems.EndUpdate + 0001:0006F7B8 TListItems.Assign + 0001:0006F818 WriteItems + 0001:0006F8A8 TListItems.DefineProperties + 0001:0006F900 TListItems.ReadData + 0001:0006FAF8 GetLength + 0001:0006FB0C TListItems.WriteData + 0001:0006FDB0 TListItems.Delete + 0001:0006FDC8 TListItems.CreateItem + 0001:0006FDEC TIconOptions.Create + 0001:0006FE60 TIconOptions.SetArrangement + 0001:0006FE74 TIconOptions.SetAutoArrange + 0001:0006FE88 TIconOptions.SetWrapText + 0001:0006FE9C DefaultListViewSort + 0001:0006FF08 TCustomListView.Create + 0001:000700F0 TCustomListView.Destroy + 0001:000701F0 TCustomListView.CreateParams + 0001:0007031C ReadCols + 0001:000703D0 TCustomListView.CreateWnd + 0001:000705B8 TCustomListView.DestroyWnd + 0001:00070634 TCustomListView.SetImageList + 0001:0007065C TCustomListView.ImageListChange + 0001:000706D0 TCustomListView.Notification + 0001:00070744 UpdateColumnOrder + 0001:00070880 TCustomListView.HeaderWndProc + 0001:00070978 TCustomListView.EditWndProc + 0001:00070A78 TCustomListView.UpdateItems + 0001:00070A98 TCustomListView.ResetExStyles + 0001:00070B94 TCustomListView.RestoreChecks + 0001:00070C20 TCustomListView.SaveChecks + 0001:00070CA4 TCustomListView.SetCheckboxes + 0001:00070D24 TCustomListView.SetBorderStyle + 0001:00070D38 TCustomListView.SetColumnClick + 0001:00070D4C TCustomListView.SetItemIndex + 0001:00070D94 TCustomListView.SetMultiSelect + 0001:00070DA8 TCustomListView.SetColumnHeaders + 0001:00070DBC TCustomListView.SetTextColor + 0001:00070DDC TCustomListView.SetTextBkColor + 0001:00070E10 TCustomListView.SetAllocBy + 0001:00070E40 TCustomListView.CMColorChanged + 0001:00070E64 TCustomListView.CMCtl3DChanged + 0001:00070E88 TCustomListView.WMNotify + 0001:000710AC TCustomListView.ColumnsShowing + 0001:000710B8 TCustomListView.ValidHeaderHandle + 0001:000710C4 TCustomListView.CMFontChanged + 0001:00071104 TCustomListView.SetHideSelection + 0001:00071118 TCustomListView.SetViewStyle + 0001:0007119C TCustomListView.WMParentNotify + 0001:000711EC TCustomListView.GetItemIndex + 0001:00071214 TCustomListView.OwnerDataFetch + 0001:0007123C TCustomListView.OwnerDataFind + 0001:00071288 TCustomListView.OwnerDataHint + 0001:000712B0 TCustomListView.OwnerDataStateChange + 0001:000712E4 TCustomListView.CreateListItem + 0001:00071320 TCustomListView.CreateListItems + 0001:00071330 ConvertMask + 0001:0007137C TCustomListView.GetItem + 0001:000714AC TCustomListView.GetSelCount + 0001:000714C0 ConvertFlags + 0001:000714E4 ConvertStates + 0001:00071530 TCustomListView.CNNotify + 0001:000721F0 TCustomListView.ChangeScale + 0001:00072264 TCustomListView.ColClick + 0001:00072284 TCustomListView.ColRightClick + 0001:000722B4 TCustomListView.InsertItem + 0001:000722D4 TCustomListView.AddItem + 0001:0007233C TCustomListView.CanChange + 0001:00072384 TCustomListView.Change + 0001:000723BC TCustomListView.Delete + 0001:000723F4 TCustomListView.CanEdit + 0001:00072420 TCustomListView.Edit + 0001:000724A0 TCustomListView.GetDragImages + 0001:000724BC TCustomListView.WndProc + 0001:0007253C TCustomListView.DoStartDrag + 0001:00072610 TCustomListView.DoEndDrag + 0001:0007263C TCustomListView.CMDrag + 0001:00072770 TCustomListView.DoDragOver + 0001:000727F8 TCustomListView.AlphaSort + 0001:00072828 TCustomListView.SetSortType + 0001:00072860 TCustomListView.GetViewOrigin + 0001:00072878 TCustomListView.GetTopItem + 0001:000728B0 TCustomListView.SetLargeImages + 0001:00072920 TCustomListView.SetSmallImages + 0001:00072998 TCustomListView.SetStateImages + 0001:00072A54 TCustomListView.GetColumnFromIndex + 0001:00072A60 TCustomListView.GetSelected + 0001:00072A78 TCustomListView.GetDropTarget + 0001:00072A9C TCustomListView.SetDropTarget + 0001:00072AE0 TCustomListView.GetImageIndex + 0001:00072B00 TCustomListView.GetNextItem + 0001:00072BD4 TCustomListView.GetNearestItem + 0001:00072C3C TCustomListView.GetItemAt + 0001:00072CA0 TCustomListView.Arrange + 0001:00072CC0 TCustomListView.UpdateColumns + 0001:00072D00 TCustomListView.UpdateColumn + 0001:00072E50 TCustomListView.WMLButtonDown + 0001:00072FB4 TCustomListView.DoAutoSize + 0001:00073148 TCustomListView.WMWindowPosChanged + 0001:0007317C TCustomListView.CNDrawItem + 0001:000732AC TCustomListView.CanvasChanged + 0001:000732B4 TCustomListView.IsCustomDrawn + 0001:000733BC TCustomListView.CustomDraw + 0001:00073414 TCustomListView.CustomDrawItem + 0001:00073484 TCustomListView.CustomDrawSubItem + 0001:000734FC TCustomListView.DrawItem + 0001:00073574 TCustomListView.GetSubItemImage + 0001:000735B8 TCustomListView.DrawWorkAreas + 0001:00073720 TCustomListView.WMPaint + 0001:00073748 TCustomListView.CMHintShow + 0001:00073870 TCustomListView.DoInfoTip + 0001:00073890 TCustomListView.MouseUp + 0001:000738D4 TCustomListView.GetColumnFromTag + 0001:00073910 TCustomListView.WMContextMenu + 0001:00073988 TCustomListView.ClearSelection + 0001:000739C4 TCustomListView.CopySelection + 0001:00073A38 TCustomListView.DeleteSelected + 0001:00073AE0 TCustomListView.GetCount + 0001:00073AEC TCustomListView.SelectAll + 0001:00073B28 TCustomListView.Clear + 0001:00073B80 TCustomListView.GetActionLinkClass + 0001:00073B88 TCustomListView.ActionChange + 0001:00073BEC TComboExItem.Assign + 0001:00073C38 TComboExItem.SetCaption + 0001:00073C6C TComboExItem.SetData + 0001:00073CA0 TComboExItem.SetDisplayName + 0001:00073CC0 TComboExItem.SetImageIndex + 0001:00073CF0 TComboExItem.SetIndex + 0001:00073D0C TComboExItem.SetOverlayImageIndex + 0001:00073D28 TComboExItem.SetSelectedImageIndex + 0001:00073D44 TComboExItems.Add + 0001:00073D50 TComboExItems.AddItem + 0001:00073DB8 TComboExItems.GetComboItem + 0001:00073DCC TComboExItems.Insert + 0001:00073DE0 TComboExItems.Notify + 0001:00073E50 TComboExItems.SetItem + 0001:00073F34 TCustomComboBoxEx.Create + 0001:00073FE4 TCustomComboBoxEx.Destroy + 0001:0007404C TCustomComboBoxEx.CNNotify + 0001:0007409C TCustomComboBoxEx.CreateParams + 0001:00074114 TCustomComboBoxEx.SetImages + 0001:000741A8 TCustomComboBoxEx.ImageListChange + 0001:000741D4 TCustomComboBoxEx.WndProc + 0001:0007421C TCustomComboBoxEx.Notification + 0001:0007424C TCustomComboBoxEx.SetStyle + 0001:00074294 TCustomComboBoxEx.CMParentColorChanged + 0001:000742BC TCustomComboBoxEx.CMColorChanged + 0001:0007431C TCustomComboBoxEx.WMLButtonDown + 0001:00074394 TCustomComboBoxEx.ComboExWndProc + 0001:000743B4 TCustomComboBoxEx.CreateWnd + 0001:00074604 TCustomComboBoxEx.GetItemCount + 0001:00074610 TCustomComboBoxEx.GetItemsClass + 0001:00074618 TCustomComboBoxEx.SetItemsEx + 0001:00074628 TCustomComboBoxEx.GetActionLinkClass + 0001:00074630 TCustomComboBoxEx.SetStyleEx + 0001:00074690 TCustomComboBoxEx.IsItemsExStored + 0001:000746C8 TCustomComboBoxEx.ActionChange + 0001:0007472C TCustomComboBoxEx.SetDropDownCount + 0001:00074768 TCustomComboBoxEx.GetDropDownCount + 0001:00074770 TCustomComboBoxEx.GetItemHt + 0001:00074778 TCustomComboBoxEx.DestroyWnd + 0001:000747C8 TCustomComboBoxEx.Focused + 0001:00074804 TComboBoxExStrings.Add + 0001:00074828 TComboBoxExStrings.AddObject + 0001:00074858 TComboBoxExStrings.Clear + 0001:000748C0 TComboBoxExStrings.Create + 0001:0007491C TComboBoxExStrings.Destroy + 0001:0007494C TComboBoxExStrings.Delete + 0001:00074958 TComboBoxExStrings.Exchange + 0001:00074AA4 TComboBoxExStrings.Get + 0001:00074AC8 TComboBoxExStrings.GetCapacity + 0001:00074AD4 TComboBoxExStrings.GetCount + 0001:00074AE0 TComboBoxExStrings.GetObject + 0001:00074AF8 TComboBoxExStrings.IndexOf + 0001:00074B44 TComboBoxExStrings.IndexOfName + 0001:00074B4C TComboBoxExStrings.Insert + 0001:00074B60 TComboBoxExStrings.Move + 0001:00074B80 TComboBoxExStrings.Put + 0001:00074B94 TComboBoxExStrings.PutObject + 0001:00074BA8 TComboBoxExStrings.SetUpdateState + 0001:00074BE8 TComboBoxExStrings.GetItemsClass + 0001:00074BF0 TComboBoxExStrings.GetItemClass + 0001:00074BF8 TListViewActionLink.AddItem + 0001:00074C70 TListViewActionLink.AddItem + 0001:00074CA8 TListViewActionLink.SetImages + 0001:00074CDC TComboBoxExActionLink.AddItem + 0001:00074D4C TComboBoxExActionLink.AddItem + 0001:00074D80 Finalization + 0001:00074DF8 ComCtrls + 0001:00074E00 Finalization + 0001:00074E30 MaskUtils + 0001:00074E38 Finalization + 0001:00074E68 Mask + 0001:00074E70 Finalization + 0001:00074EA0 Grids + 0001:00075040 Finalization + 0001:00075070 JclResources + 0001:00075078 Finalization + 0001:000750A8 JclBase + 0001:000750B0 Finalization + 0001:000750E0 AccCtrl + 0001:000750E8 GetVersionEx + 0001:000750F0 Finalization + 0001:00075120 JclWin32 + 0001:00075128 Finalization + 0001:00075158 JclConsole + 0001:0007516C Finalization + 0001:000751B4 JclWideStrings + 0001:000751C8 Finalization + 0001:000751F8 JclLogic + 0001:00075200 LoadCharTypes + 0001:00075238 LoadCaseMap + 0001:000752B4 CharIsLower + 0001:000752C8 CharIsUpper + 0001:000752FC Finalization + 0001:00075344 JclStrings + 0001:00075358 Finalization + 0001:00075388 Jcl8087 + 0001:00075390 Finalization + 0001:000753C0 JclMath + 0001:000753E4 UnloadModule + 0001:000753FC Finalization + 0001:00075444 JclSysUtils + 0001:0007544C Finalization + 0001:0007547C Snmp + 0001:00075484 Finalization + 0001:000754B4 TlHelp32 + 0001:000754BC Finalization + 0001:000754EC PsAPI + 0001:000754F4 Finalization + 0001:00075524 JclRegistry + 0001:0007552C Finalization + 0001:0007555C JclIniFiles + 0001:00075584 GetWindowsVersion + 0001:00075770 GetNativeSystemInfo + 0001:00075810 UnloadSystemResourcesMeterLib + 0001:00075834 InitSysInfo + 0001:00075A10 FinalizeSysInfo + 0001:00075BB4 Finalization + 0001:00075C00 JclSysInfo + 0001:00075C1C Finalization + 0001:00075C58 JclShell + 0001:00075C60 Finalization + 0001:00075C90 JclSecurity + 0001:00075C98 Finalization + 0001:00075CC8 JclDateTime + 0001:00075CD0 GetModulePath + 0001:00075D00 VersionFixedFileInfo + 0001:00075DBC Finalization + 0001:00075DEC JclFileUtils + 0001:00075DF4 FreeTypeData + 0001:00075E44 DeleteType + 0001:00075E68 ClearInfoList + 0001:00075EC4 RemoveTypeInfo + 0001:00075F58 Finalization + 0001:00075F98 JclRTTI + 0001:00075FB4 Finalization + 0001:00075FE4 JclMime + 0001:0007616C Finalization + 0001:000761B4 JvPropertyStore + 0001:00076238 TJvAppStoragePropertyEngineList.Destroy + 0001:00076288 CreateAppStoragePropertyEngineList + 0001:0007629C DestroyAppStoragePropertyEngineList + 0001:000762B0 Finalization + 0001:000762E8 JvAppStorage + 0001:000762F8 Finalization + 0001:00076334 JvProgressUtils + 0001:000763F0 StdWndProc + 0001:00076454 AllocateHWndEx + 0001:00076538 DeallocateHWndEx + 0001:00076540 InitScreenCursors + 0001:0007661C Finalization + 0001:00076678 JvJVCLUtils + 0001:00076B6C IsApplicationMinimized + 0001:00076B84 UnloadKernel32Dll + 0001:00076BA8 LoadKernel32Dll + 0001:00076C10 GetTrayHandle + 0001:00076C54 AnimateToTray + 0001:00076C90 AnimateFromTray + 0001:00076CC8 TJvTrayIcon.Create + 0001:00076DB0 TJvTrayIcon.Destroy + 0001:00076E28 TJvTrayIcon.AcceptBalloons + 0001:00076E38 TJvTrayIcon.ApplicationHook + 0001:00076E60 TJvTrayIcon.BalloonHint + 0001:00076FB4 TJvTrayIcon.DoAnimation + 0001:00077028 TJvTrayIcon.DoClick + 0001:000770CC TJvTrayIcon.DoCloseBalloon + 0001:000770E4 TJvTrayIcon.DoContextPopup + 0001:00077164 TJvTrayIcon.DoDoubleClick + 0001:00077240 TJvTrayIcon.DoMouseDown + 0001:00077280 TJvTrayIcon.DoMouseMove + 0001:00077340 HasSingleClickFunctionality + 0001:0007739C HasDoubleClickFunctionality + 0001:000773E0 TJvTrayIcon.DoMouseUp + 0001:000774D8 TJvTrayIcon.DoTimerDblClick + 0001:00077514 TJvTrayIcon.EndAnimation + 0001:00077530 TJvTrayIcon.GetApplicationVisible + 0001:0007754C TJvTrayIcon.GetSystemMinimumBalloonDelay + 0001:00077554 TJvTrayIcon.HideApplication + 0001:000775F4 TJvTrayIcon.HideBalloon + 0001:00077620 TJvTrayIcon.HideTrayIcon + 0001:00077644 TJvTrayIcon.Hook + 0001:0007766C TJvTrayIcon.IconChanged + 0001:00077674 TJvTrayIcon.IconPropertyChanged + 0001:00077738 TJvTrayIcon.InitIconData + 0001:00077814 TJvTrayIcon.Loaded + 0001:00077894 TJvTrayIcon.Notification + 0001:000778E4 TJvTrayIcon.NotifyIcon + 0001:00077900 TJvTrayIcon.SetActive + 0001:0007795C TJvTrayIcon.SetAnimated + 0001:00077980 TJvTrayIcon.SetCurrentIcon + 0001:000779B0 TJvTrayIcon.SetDelay + 0001:00077A1C TJvTrayIcon.SetHint + 0001:00077ADC TJvTrayIcon.SetIcon + 0001:00077AE8 TJvTrayIcon.SetIconIndex + 0001:00077AFC TJvTrayIcon.SetIcons + 0001:00077B10 TJvTrayIcon.SetTask + 0001:00077B60 TJvTrayIcon.SetVisibility + 0001:00077C50 TJvTrayIcon.ShowApplication + 0001:00077D18 TJvTrayIcon.ShowTrayIcon + 0001:00077D8C TJvTrayIcon.StartAnimation + 0001:00077DC8 TJvTrayIcon.StopTimer + 0001:00077DDC TJvTrayIcon.Unhook + 0001:00077E00 TJvTrayIcon.WndProc + 0001:00078238 Finalization + 0001:00078270 JvTrayIcon + 0001:00078278 AddColouredLine + 0001:00078318 AddColourToLine + 0001:0007847C HexToColor + 0001:00078584 AddHilightedItem + 0001:000786B4 Finalization + 0001:000786E4 modRichEdit + 0001:000786EC EvaluateProperty + 0001:000787C8 Finalization + 0001:000787F8 modSCPUtils + 0001:00078CD0 MyLineOut + 0001:00078D20 TLogThread.AddMessage + 0001:00078D8C TLogThread.Create + 0001:00078DE8 TLogThread.Destroy + 0001:00078E20 TLogThread.Execute + 0001:00078EEC TLogThread.SyncWrite + 0001:00078F0C TLogThread.WriteFromPseWow + 0001:00079570 TfrmMain.FormCreate + 0001:000795B4 TfrmMain.btnRunClick + 0001:000796C4 TfrmMain.btnExitClick + 0001:000796CC TfrmMain.ShutDown + 0001:0007973C TfrmMain.Execute + 0001:0007980C TfrmMain.FormCloseQuery + 0001:00079828 TfrmMain.timerStartTimer + 0001:0007986C TfrmMain.servRemoteClientRead + 0001:00079928 TfrmMain.FormDestroy + 0001:00079950 TfrmMain.clientSockConnect + 0001:00079A14 TfrmMain.clientSockError + 0001:00079AC4 TfrmMain.Launch + 0001:00079B0C TfrmMain.Log + 0001:00079B94 TfrmMain.ConsoleResizeRequest + 0001:00079BE0 TfrmMain.comCommandKeyDown + 0001:00079C94 TfrmMain.clientSockConnecting + 0001:00079D2C TfrmMain.AddHistoryItem + 0001:00079D94 TfrmMain.ConsoleCommand + 0001:00079E58 TfrmMain.SetupIcons + 0001:00079EA4 TfrmMain.SetIcon + 0001:0007A008 TfrmMain.LoadSettings + 0001:0007A228 TfrmMain.cbexIconChange + 0001:0007A250 TfrmMain.LoadPseuSettings + 0001:0007A3F4 Finalization + 0001:0007A424 fMain + 0001:0007A42C Finalization + 0001:0007A7A4 PseuWoWConsole + 0002:00000000 ExitCode + 0002:00000004 ErrorAddr + 0002:00000008 FileMode + 0002:0000000C Default8087CW + 0002:00000010 HeapAllocFlags + 0002:00000014 DebugHook + 0002:00000018 JITEnable + 0002:0000001C NoErrMsg + 0002:00000020 DefaultTextLineBreakStyle + 0002:00000024 LibModuleList + 0002:00000028 ModuleUnloadList + 0002:0000002C MemoryManager + 0002:00000038 reMap + 0002:00000054 runErrMsg + 0002:00000074 errCaption + 0002:0000007C dig + 0002:0000008C Module + 0002:000000A4 EmptyStr + 0002:000000A8 EmptyWideStr + 0002:000000AC Win32Platform + 0002:000000B0 Win32MajorVersion + 0002:000000B4 Win32MinorVersion + 0002:000000B8 Win32BuildNumber + 0002:000000BC Win32CSDVersion + 0002:000000C0 TwoDigitYearCenturyWindow + 0002:000000C4 MonthDays + 0002:000000F4 LeadBytes + 0002:00000114 HexDisplayPrefix + 0002:00000118 GetDiskFreeSpaceEx + 0002:0000011C ExitProcList + 0002:00000120 cSimpleBoolStrs + 0002:00000128 AccessMode + 0002:00000134 ShareMode + 0002:00000148 FormatErrorStrs + 0002:00000150 FCon1E18 + 0002:0000015C DCon10 + 0002:00000160 CWNear + 0002:00000164 FMSecsPerDay + 0002:00000168 IMSecsPerDay + 0002:0000016C Format + 0002:00000170 DefShortMonthNames + 0002:000001A0 DefLongMonthNames + 0002:000001D0 DefShortDayNames + 0002:000001EC DefLongDayNames + 0002:00000208 ErrorMap + 0002:00000240 ExceptMap + 0002:000002F0 WesternGroups + 0002:000002F4 TerminateProcList + 0002:000002F8 CVarTypeToElementInfo + 0002:00000400 CResult + 0002:00000408 NullEqualityRule + 0002:0000040C NullMagnitudeRule + 0002:00000410 NullStrictConvert + 0002:00000414 NullAsStringValue + 0002:00000418 PackVarCreation + 0002:0000041C BooleanToStringRule + 0002:00000420 BaseTypeMap + 0002:00000438 CInvalidCustomVariantType + 0002:0000043C CRangeToType + 0002:00000450 OpTypeMap + 0002:000004B4 CBooleanToRelationship + 0002:000004C0 CmpTypeMap + 0002:00000524 CTruth + 0002:00000528 CText + 0002:0000057C CRelationshipToBoolean + 0002:00000590 BooleanIdents + 0002:00000598 DotSep + 0002:0000059C GUID_NULL + 0002:000005AC AddDataModule + 0002:000005B4 RemoveDataModule + 0002:000005BC ApplicationHandleException + 0002:000005C4 ApplicationShowException + 0002:000005CC WakeMainThread + 0002:000005D4 FilerSignature + 0002:000005D8 NilMethod + 0002:000005E0 Convert + 0002:000005F0 Convert + 0002:00000660 SyncList + 0002:00000664 Priorities + 0002:00000680 BlockCode + 0002:00000684 UtilWindowClass + 0002:000006AC DefFontData + 0002:000006D8 DDBsOnly + 0002:000006DC Colors + 0002:0000087C FontCharsets + 0002:0000090C DefPenData + 0002:0000091C PenStyles + 0002:0000092C DefBrushData + 0002:0000093C PenModes + 0002:0000095C ClipboardFormats + 0002:00000960 FileFormats + 0002:00000964 BitmapCanvasList + 0002:00000968 DIBPalSizes + 0002:0000096C PalSize + 0002:00000970 Pal16 + 0002:000009B0 FPrinter + 0002:000009B4 BorderStyles + 0002:000009BC Passwords + 0002:000009C4 ReadOnlys + 0002:000009CC CharCases + 0002:000009D8 HideSelections + 0002:000009E0 OEMConverts + 0002:000009E8 Empty + 0002:000009EC Alignments + 0002:00000A04 ScrollBar + 0002:00000A14 WordWraps + 0002:00000A1C ComboBoxStyles + 0002:00000A30 CharCases + 0002:00000A3C Sorts + 0002:00000A44 InnerStyles + 0002:00000A54 OuterStyles + 0002:00000A64 EdgeStyles + 0002:00000A74 Ctl3DStyles + 0002:00000A7C ButtonStyles + 0002:00000A84 Alignments + 0002:00000A94 Alignments + 0002:00000AAC Borders + 0002:00000AB8 BorderStyles + 0002:00000AC0 Alignments + 0002:00000ACC CreationControl + 0002:00000AD0 WndProcPtrAtom + 0002:00000AD4 Captions + 0002:00000AE8 ButtonNames + 0002:00000B14 ButtonCaptions + 0002:00000B40 AnimateWindowProc + 0002:00000B44 CreationControl + 0002:00000B48 DefaultDockTreeClass + 0002:00000B4C AnchorAlign + 0002:00000B54 Cursors + 0002:00000C04 CaptureControl + 0002:00000C08 ShowFlags + 0002:00000C0C WindowPos + 0002:00000C10 InnerStyles + 0002:00000C20 OuterStyles + 0002:00000C30 EdgeStyles + 0002:00000C40 Ctl3DStyles + 0002:00000C48 AnimationStyle + 0002:00000C54 OrientArray + 0002:00000C5C MakeLast + 0002:00000C64 TreeStreamEndFlag + 0002:00000C68 SizeCursors + 0002:00000C70 IMM32DLL + 0002:00000C74 ModeMap + 0002:00000C7C DrawingStyles + 0002:00000C8C Images + 0002:00000C94 Mask + 0002:00000C9C ValidMenuHotkeys + 0002:00000CA0 cMenuAutoFlagToItem + 0002:00000CA4 cItemAutoFlagToMenu + 0002:00000CA8 cBooleanToItemAutoFlag + 0002:00000CAC cItemAutoFlagToBoolean + 0002:00000CB0 MenuKeyCaps + 0002:00000CF8 Checks + 0002:00000D00 Enables + 0002:00000D08 Breaks + 0002:00000D14 Separators + 0002:00000D1C IBreaks + 0002:00000D28 IChecks + 0002:00000D30 IDefaults + 0002:00000D38 IEnables + 0002:00000D40 IRadios + 0002:00000D48 ISeparators + 0002:00000D50 IRTL + 0002:00000D58 IOwnerDraw + 0002:00000D60 Alignments + 0002:00000D68 EdgeStyle + 0002:00000D70 Alignments + 0002:00000D78 Flags + 0002:00000D84 Buttons + 0002:00000D88 HintWindowClass + 0002:00000D8C FocusMessages + 0002:00000D90 FocusCount + 0002:00000D94 SetLayeredWindowAttributes + 0002:00000D98 TaskActiveWindow + 0002:00000D9C TaskFirstWindow + 0002:00000DA0 TaskFirstTopMost + 0002:00000DA4 TaskWindowList + 0002:00000DA8 SysConsts + 0002:00000DB0 SysConsts + 0002:00000DB8 Props + 0002:00000DE0 Styles + 0002:00000DEC BorderStyles + 0002:00000DF4 ShowCommands + 0002:00000E00 ShowCommands + 0002:00000E0C ShowCommands + 0002:00000E18 cUseAlpha + 0002:00000E20 cUseColorKey + 0002:00000E28 CursorMap + 0002:00000E7C WindowClass + 0002:00000EA4 AppVisible + 0002:00000EA8 ShowFlags + 0002:00000EAC Values + 0002:00000EB4 crMultiDragLink + 0002:00000EB8 crDragAlt + 0002:00000EBC crMultiDragAlt + 0002:00000EC0 crMultiDragLinkAlt + 0002:00000EC4 ColorValues + 0002:00000FB4 StandardColorValues + 0002:00001194 SysColorValues + 0002:000012FC CoCreateInstanceEx + 0002:00001300 CoInitializeEx + 0002:00001304 CoAddRefServerProcess + 0002:00001308 CoReleaseServerProcess + 0002:0000130C CoResumeClassObjects + 0002:00001310 CoSuspendClassObjects + 0002:00001314 CoInitFlags + 0002:00001318 ThreadStrs + 0002:0000132C Values + 0002:00001334 Day + 0002:00001340 Month + 0002:0000134C Year + 0002:00001358 Week + 0002:00001368 TRUE_STRINGS + 0002:0000137C BitBtnCaptions + 0002:000013A8 MAPIDLL + 0002:000013AC MAPIModule + 0002:000013B0 RTFConversionFormat + 0002:000013BC TextConversionFormat + 0002:000013C8 ConversionFormatList + 0002:000013CC Empty + 0002:000013D0 HideScrollBars + 0002:000013D8 HideSelections + 0002:000013E0 Painting + 0002:000013E4 Codes + 0002:000013F4 BorderStyles + 0002:000013FC EditStyles + 0002:00001404 MultiSelections + 0002:0000140C HideSelections + 0002:00001414 Arrangements + 0002:0000141C AutoArrange + 0002:00001424 WrapText + 0002:0000142C ViewStyles + 0002:0000143C ShowColumns + 0002:00001444 ColumnClicks + 0002:0000144C ViewStyles + 0002:0000145C Directions + 0002:00001470 Codes + 0002:00001488 IAlignment + 0002:000014A0 ComboBoxExStyles + 0002:000014AC ComboExStyles + 0002:000014C0 WideCRLF + 0002:000014C4 AnsiCaseMapReady + 0002:000014C8 Bools + 0002:000014D0 InfMantissa + 0002:000014D8 IsWin95 + 0002:000014DC IsWin95OSR2 + 0002:000014E0 IsWin98 + 0002:000014E4 IsWin98SE + 0002:000014E8 IsWinME + 0002:000014EC IsWinNT + 0002:000014F0 IsWinNT3 + 0002:000014F4 IsWinNT31 + 0002:000014F8 IsWinNT35 + 0002:000014FC IsWinNT351 + 0002:00001500 IsWinNT4 + 0002:00001504 IsWin2K + 0002:00001508 IsWinXP + 0002:0000150C IsWin2003 + 0002:00001510 IsWinXP64 + 0002:00001514 IsWin2003R2 + 0002:00001518 IsWinVista + 0002:0000151C IsWinLonghorn + 0002:00001520 IntelCacheDescription + 0002:0000191C ProcessorCount + 0002:00001920 AllocGranularity + 0002:00001924 PageSize + 0002:00001928 RtdlMsiLibHandle + 0002:0000192C IgnorePropertyList + 0002:0000196C ProgressList + 0002:00001970 DefCompanyName + 0002:00001974 DrawBitmap + 0002:00001978 ButtonNames + 0002:000019A4 cUtilWindowExClass + 0002:000019CC cHintSize + 0002:000019D4 GKernel32Handle + 0002:000019D8 GTriedLoadKernel32Dll + 0002:000019DC RegisterServiceProcess + 0002:000019E0 cInfoFlagValues + 0002:00003000 DispCallByIDProc + 0002:00003004 ExceptProc + 0002:00003008 ErrorProc + 0002:0000300C ExceptClsProc + 0002:00003010 ExceptObjProc + 0002:00003014 RaiseExceptionProc + 0002:00003018 RTLUnwindProc + 0002:0000301C ExceptionClass + 0002:00003020 SafeCallErrorProc + 0002:00003024 AssertErrorProc + 0002:00003028 ExitProcessProc + 0002:0000302C AbstractErrorProc + 0002:00003030 MainInstance + 0002:00003034 MainThreadID + 0002:00003038 IsLibrary + 0002:0000303C CmdShow + 0002:00003040 CmdLine + 0002:00003044 InitProc + 0002:00003048 ExitProc + 0002:0000304C IsConsole + 0002:0000304D IsMultiThread + 0002:0000304E Test8086 + 0002:00003050 Input + 0002:0000321C Output + 0002:000033E8 ErrOutput + 0002:000035B4 AllocMemCount + 0002:000035B8 AllocMemSize + 0002:000035BC .5 + 0002:000035C0 initialized + 0002:000035C4 heapErrorCode + 0002:000035C8 heapLock + 0002:000035E0 blockDescBlockList + 0002:000035E4 blockDescFreeList + 0002:000035E8 spaceRoot + 0002:000035F8 decommittedRoot + 0002:00003608 avail + 0002:00003614 rover + 0002:00003618 remBytes + 0002:0000361C curAlloc + 0002:00003620 smallTab + 0002:00003624 committedRoot + 0002:00003634 InitContext + 0002:00003660 VariantManager + 0002:0000370C ModuleIsLib + 0002:0000370D ModuleIsCpp + 0002:00003710 TlsIndex + 0002:00003718 HInstance + 0002:0000371C .1 + 0002:00003720 tlsBuffer + 0002:00003724 .1 + 0002:00003728 .3 + 0002:0000372C .1 + 0002:00003730 .1 + 0002:00003734 CurrencyString + 0002:00003738 CurrencyFormat + 0002:00003739 NegCurrFormat + 0002:0000373A ThousandSeparator + 0002:0000373B DecimalSeparator + 0002:0000373C CurrencyDecimals + 0002:0000373D DateSeparator + 0002:00003740 ShortDateFormat + 0002:00003744 LongDateFormat + 0002:00003748 TimeSeparator + 0002:0000374C TimeAMString + 0002:00003750 TimePMString + 0002:00003754 ShortTimeFormat + 0002:00003758 LongTimeFormat + 0002:0000375C ShortMonthNames + 0002:0000378C LongMonthNames + 0002:000037BC ShortDayNames + 0002:000037D8 LongDayNames + 0002:000037F4 SysLocale + 0002:00003802 ListSeparator + 0002:00003804 EraNames + 0002:00003820 EraYearOffsets + 0002:0000383C TrueBoolStrs + 0002:00003840 FalseBoolStrs + 0002:00003844 .94 + 0002:00003848 OutOfMemory + 0002:0000384C InvalidPointer + 0002:00003850 FLanguages + 0002:00003854 .1 + 0002:00003858 TempVariantChangeTypeEx + 0002:0000385C TempVarNeg + 0002:00003860 TempVarNot + 0002:00003864 TempVarAdd + 0002:00003868 TempVarSub + 0002:0000386C TempVarMul + 0002:00003870 TempVarDiv + 0002:00003874 TempVarIDiv + 0002:00003878 TempVarMod + 0002:0000387C TempVarAnd + 0002:00003880 TempVarOr + 0002:00003884 TempVarXor + 0002:00003888 TempVarCmp + 0002:0000388C TempVarI4FromStr + 0002:00003890 TempVarR4FromStr + 0002:00003894 TempVarR8FromStr + 0002:00003898 TempVarDateFromStr + 0002:0000389C TempVarCyFromStr + 0002:000038A0 TempVarBoolFromStr + 0002:000038A4 TempVarBstrFromCy + 0002:000038A8 TempVarBstrFromDate + 0002:000038AC TempVarBstrFromBool + 0002:000038B0 EmptyParam + 0002:000038C0 VarDispProc + 0002:000038C4 ClearAnyProc + 0002:000038C8 ChangeAnyProc + 0002:000038CC RefAnyProc + 0002:000038D0 .81 + 0002:000038D4 GVariantManager + 0002:00003980 GOldVariantManager + 0002:00003A2C LVarTypes + 0002:00003A30 LVarTypeSync + 0002:00003A34 .1 + 0002:00003A38 .6 + 0002:00003A3C .3 + 0002:00003A40 GlobalNameSpace + 0002:00003A44 IsUniqueGlobalComponentNameProc + 0002:00003A48 .35 + 0002:00003A4C IntConstList + 0002:00003A50 RegGroups + 0002:00003A54 FindGlobalComponentProcs + 0002:00003A58 GlobalFixupList + 0002:00003A5C ProcPosted + 0002:00003A60 ThreadLock + 0002:00003A78 ThreadCount + 0002:00003A7C InstBlockList + 0002:00003A80 InstFreeList + 0002:00003A84 .1 + 0002:00003A88 SystemPalette16 + 0002:00003A8C .12 + 0002:00003A90 ScreenLogPixels + 0002:00003A94 StockPen + 0002:00003A98 StockBrush + 0002:00003A9C StockFont + 0002:00003AA0 StockIcon + 0002:00003AA4 BitmapImageLock + 0002:00003ABC CounterLock + 0002:00003AD4 FontManager + 0002:00003AD8 PenManager + 0002:00003ADC BrushManager + 0002:00003AE0 CanvasList + 0002:00003AE4 PatternManager + 0002:00003AE8 .2 + 0002:00003AEC .21 + 0002:00003AF0 .1 + 0002:00003AF4 ComCtl32DLL + 0002:00003AF8 _InitCommonControlsEx + 0002:00003AFC GetSystemMetrics + 0002:00003B00 MonitorFromWindow + 0002:00003B04 MonitorFromRect + 0002:00003B08 MonitorFromPoint + 0002:00003B0C GetMonitorInfo + 0002:00003B10 GetMonitorInfoA + 0002:00003B14 GetMonitorInfoW + 0002:00003B18 EnumDisplayMonitors + 0002:00003B1C .1 + 0002:00003B20 User32Dll + 0002:00003B24 InitApis + 0002:00003B2C MMAvailable + 0002:00003B30 .1 + 0002:00003B34 .2 + 0002:00003B38 HelpManager + 0002:00003B3C .3 + 0002:00003B40 .3 + 0002:00003B44 FlatSB_EnableScrollBar + 0002:00003B48 FlatSB_ShowScrollBar + 0002:00003B4C FlatSB_GetScrollRange + 0002:00003B50 FlatSB_GetScrollInfo + 0002:00003B54 FlatSB_GetScrollPos + 0002:00003B58 FlatSB_SetScrollPos + 0002:00003B5C FlatSB_SetScrollInfo + 0002:00003B60 FlatSB_SetScrollRange + 0002:00003B64 .1 + 0002:00003B68 _FlatSB_GetScrollProp + 0002:00003B6C _FlatSB_SetScrollProp + 0002:00003B70 _InitializeFlatSB + 0002:00003B74 _UninitializeFlatSB + 0002:00003B78 .42 + 0002:00003B7C .1 + 0002:00003B80 .1 + 0002:00003B84 .1 + 0002:00003B88 .1 + 0002:00003B8C .1 + 0002:00003B90 .1 + 0002:00003B94 .12 + 0002:00003B98 .1 + 0002:00003B9C .01 + 0002:00003BA0 HelpMsg + 0002:00003BA4 FindMsg + 0002:00003BA8 CF_PICTURE + 0002:00003BAA CF_COMPONENT + 0002:00003BAC .2 + 0002:00003BB0 FClipboard + 0002:00003BB4 .1 + 0002:00003BB8 .63 + 0002:00003BBC WinHelpTester + 0002:00003BC0 ViewerName + 0002:00003BC4 .1 + 0002:00003BC8 HelpViewer + 0002:00003BCC Mouse + 0002:00003BD0 NewStyleControls + 0002:00003BD4 .72 + 0002:00003BD8 WindowAtom + 0002:00003BDA ControlAtom + 0002:00003BDC WindowAtomString + 0002:00003BE0 ControlAtomString + 0002:00003BE4 RM_GetObjectInstance + 0002:00003BE8 DragControl + 0002:00003BEC DragObject + 0002:00003BF0 DragInternalObject + 0002:00003BF4 DragCapture + 0002:00003BF8 DragStartPos + 0002:00003C00 DragSaveCursor + 0002:00003C04 DragThreshold + 0002:00003C08 ActiveDrag + 0002:00003C0C DragImageList + 0002:00003C10 DockSiteList + 0002:00003C14 QualifyingSites + 0002:00003C18 DragSave + 0002:00003C1C CanvasList + 0002:00003C20 _WINNLSEnableIME + 0002:00003C24 _ImmGetContext + 0002:00003C28 _ImmReleaseContext + 0002:00003C2C _ImmGetConversionStatus + 0002:00003C30 _ImmSetConversionStatus + 0002:00003C34 _ImmSetOpenStatus + 0002:00003C38 _ImmSetCompositionWindow + 0002:00003C3C _ImmSetCompositionFont + 0002:00003C40 _ImmGetCompositionString + 0002:00003C44 _ImmIsIME + 0002:00003C48 _ImmNotifyIME + 0002:00003C4C .8 + 0002:00003C50 .3 + 0002:00003C54 PopupList + 0002:00003C58 ShortCutItems + 0002:00003C5C .9 + 0002:00003C60 CommandPool + 0002:00003C64 Application + 0002:00003C68 Screen + 0002:00003C6C .41 + 0002:00003C70 RM_TaskbarCreated + 0002:00003C74 HintThreadID + 0002:00003C78 HintDoneEvent + 0002:00003C7C HintHook + 0002:00003C80 HintThread + 0002:00003C84 RC_SendBuf + 0002:00003C88 RC_End + 0002:00003C8C RC_ExitCode + 0002:00003C90 RC_LineOut + 0002:00003C94 .1 + 0002:00003C98 .8 + 0002:00003C9C .1 + 0002:00003CA0 .6 + 0002:00003CA4 .41 + 0002:00003CA8 WSAData + 0002:00003E38 .1 + 0002:00003E3C .1 + 0002:00003E40 .1 + 0002:00003E44 .2 + 0002:00003E48 .1 + 0002:00003E4C .1 + 0002:00003E50 .7 + 0002:00003E54 .1 + 0002:00003E58 .1 + 0002:00003E5C .41 + 0002:00003E60 OleUninitializing + 0002:00003E64 ComClassManagerVar + 0002:00003E68 SaveInitProc + 0002:00003E6C NeedToUninitialize + 0002:00003E70 .7 + 0002:00003E74 .5 + 0002:00003E78 .1 + 0002:00003E7C ShellVersion + 0002:00003E80 .1 + 0002:00003E84 .4 + 0002:00003E88 .1 + 0002:00003E8C .4 + 0002:00003E90 BitBtnGlyphs + 0002:00003EBC .3 + 0002:00003EC0 .1 + 0002:00003EC4 .72 + 0002:00003EC8 UrlMonHandle + 0002:00003ECC UrlMonInitialized + 0002:00003ED0 .8 + 0002:00003ED4 .36 + 0002:00003ED8 ShellModule + 0002:00003EDC FRichEditModule + 0002:00003EE0 .2 + 0002:00003EE4 .5 + 0002:00003EE8 .11 + 0002:00003EEC .1 + 0002:00003EF0 .4 + 0002:00003EF4 .1 + 0002:00003EF8 .2 + 0002:00003EFC .01 + 0002:00003F00 .3 + 0002:00003F04 .1 + 0002:00003F08 .1 + 0002:00003F0C AnsiCaseMap + 0002:0000420C AnsiCharTypes + 0002:0000440C .1 + 0002:00004410 .7 + 0002:00004414 .5 + 0002:00004418 .1 + 0002:0000441C .1 + 0002:00004420 .1 + 0002:00004424 .2 + 0002:00004428 .1 + 0002:0000442C .2 + 0002:00004430 KernelVersionHi + 0002:00004434 ResmeterLibHandle + 0002:00004438 MyGetFreeSystemResources + 0002:0000443C .1 + 0002:00004440 .1 + 0002:00004444 .2 + 0002:00004448 .42 + 0002:0000444C .4 + 0002:00004450 TypeList + 0002:00004454 .1 + 0002:00004458 .4 + 0002:0000445C .01 + 0002:00004460 RegisteredAppStoragePropertyEngineList + 0002:00004464 .1 + 0002:00004468 .6 + 0002:0000446C .2 + 0002:00004470 .1 + 0002:00004474 .1 + 0002:00004478 frmMain + 0002:0000447C .4 + + +Line numbers for RedirectConsole(RedirectConsole.pas) segment .text + + 36 0001:00060608 37 0001:00060625 38 0001:0006065F 42 0001:00060670 + 43 0001:00060676 44 0001:0006067D 45 0001:00060683 46 0001:0006068B + 50 0001:00060694 52 0001:000606BA 53 0001:000606DB 54 0001:000606E4 + 51 0001:00060701 56 0001:00060712 57 0001:00060749 69 0001:0006075C + 71 0001:000607A3 72 0001:000607AC 73 0001:000607BA 74 0001:000607CC + 75 0001:000607DA 77 0001:000607E2 78 0001:000607FC 79 0001:00060807 + 82 0001:0006080C 83 0001:00060826 84 0001:00060831 85 0001:0006083A + 86 0001:00060843 89 0001:00060848 90 0001:00060854 91 0001:0006085E + 92 0001:00060867 93 0001:00060870 94 0001:00060879 96 0001:00060882 + 98 0001:000608B0 99 0001:000608CF 100 0001:000608D8 101 0001:000608E1 + 102 0001:000608EA 103 0001:000608F3 106 0001:000608F8 107 0001:00060906 + 108 0001:0006090D 111 0001:00060914 112 0001:00060920 113 0001:00060931 + 114 0001:00060944 116 0001:0006095A 117 0001:00060963 118 0001:00060971 + 119 0001:0006097A 120 0001:00060986 121 0001:00060998 122 0001:000609B5 + 119 0001:000609C3 125 0001:000609CD 126 0001:000609DF 131 0001:000609FE + 132 0001:00060A14 130 0001:00060A25 134 0001:00060A30 136 0001:00060A3D + 137 0001:00060A49 138 0001:00060A55 139 0001:00060A5E 140 0001:00060A67 + 141 0001:00060A70 142 0001:00060AA6 144 0001:00060B50 144 0001:00060B57 + +Line numbers for JvWin32(JvWin32.pas) segment .text + + 334 0001:00065684 334 0001:0006568B + +Line numbers for JvConsts(JvConsts.pas) segment .text + + 273 0001:000656BC 273 0001:000656C3 + +Line numbers for modRichEdit(modRichEdit.pas) segment .text + + 15 0001:00078278 18 0001:000782A2 19 0001:000782C0 20 0001:000782CD + 21 0001:000782DD 23 0001:00078310 30 0001:00078318 31 0001:0007834B + 33 0001:0007834D 37 0001:00078367 39 0001:0007836F 44 0001:000783A0 + 45 0001:000783B3 47 0001:000783D1 48 0001:000783DB 56 0001:00078407 + 37 0001:00078421 62 0001:00078429 63 0001:00078457 66 0001:0007847C + 67 0001:000784A3 68 0001:000784B9 73 0001:00078572 78 0001:00078584 + 79 0001:000785BC 81 0001:000785DB 82 0001:000785F8 84 0001:00078607 + 86 0001:00078615 88 0001:00078624 89 0001:0007863E 92 0001:0007867C + 95 0001:000786E4 95 0001:000786EB + +Line numbers for modSCPUtils(modSCPUtils.pas) segment .text + + 88 0001:000786EC 89 0001:00078726 91 0001:0007872D 92 0001:00078737 + 94 0001:00078739 96 0001:0007876E 97 0001:00078770 99 0001:000787C0 + 600 0001:000787F8 600 0001:000787FF + +Line numbers for fMain(fMain.pas) segment .text + + 109 0001:00078CD0 110 0001:00078CED 111 0001:00078D1D 119 0001:00078D20 + 120 0001:00078D41 121 0001:00078D4F 122 0001:00078D53 124 0001:00078D5E + 125 0001:00078D85 128 0001:00078D8C 129 0001:00078D9E 131 0001:00078DA9 + 133 0001:00078DAD 134 0001:00078DBC 135 0001:00078DE2 138 0001:00078DE8 + 139 0001:00078DF3 140 0001:00078DFB 141 0001:00078E03 142 0001:00078E1A + 148 0001:00078E20 149 0001:00078E25 153 0001:00078E32 154 0001:00078E3C + 158 0001:00078E46 164 0001:00078E51 166 0001:00078E68 167 0001:00078E75 + 168 0001:00078E82 171 0001:00078E8A 172 0001:00078E95 174 0001:00078EA2 + 175 0001:00078EAC 156 0001:00078EB3 178 0001:00078EB9 151 0001:00078EC2 + 180 0001:00078ECC 183 0001:00078EEC 184 0001:00078EEF 185 0001:00078EF6 + 186 0001:00078F00 187 0001:00078F08 195 0001:00078F0C 197 0001:00078F39 + 198 0001:00078F3D 201 0001:00078F3F 204 0001:00078F56 205 0001:00078F67 + 212 0001:00078F69 215 0001:00078F76 216 0001:00078F7F 219 0001:00078F94 + 222 0001:00078F9A 223 0001:00078FA8 226 0001:00078FBD 229 0001:00078FE0 + 231 0001:00078FF1 232 0001:00078FF5 235 0001:00078FFF 238 0001:0007901D + 240 0001:00079034 241 0001:00079052 245 0001:00079070 247 0001:0007908B + 249 0001:0007909C 252 0001:000790B7 254 0001:000790C8 257 0001:000790E3 + 259 0001:000790F4 265 0001:0007910F 266 0001:00079127 269 0001:00079131 + 270 0001:00079148 272 0001:00079166 274 0001:00079184 276 0001:000791A3 + 277 0001:000791BA 279 0001:000791D8 280 0001:000791F0 284 0001:000791FA + 286 0001:00079211 290 0001:00079224 292 0001:00079243 293 0001:0007925A + 294 0001:00079278 295 0001:00079290 298 0001:0007929A 300 0001:000792B9 + 301 0001:000792D0 303 0001:000792EE 304 0001:00079306 307 0001:00079310 + 309 0001:0007932F 310 0001:00079346 311 0001:00079364 312 0001:0007937C + 315 0001:00079386 317 0001:000793A5 318 0001:000793BC 320 0001:000793DA + 321 0001:000793F2 325 0001:000793F9 328 0001:0007941E 329 0001:00079424 + 331 0001:00079461 338 0001:00079570 339 0001:00079574 341 0001:0007957F + 342 0001:00079593 344 0001:0007959A 345 0001:000795A1 346 0001:000795A8 + 347 0001:000795AF 352 0001:000795B4 353 0001:000795D0 354 0001:00079608 + 355 0001:0007962B 356 0001:00079632 357 0001:00079639 358 0001:0007967E + 362 0001:000796C4 363 0001:000796C9 367 0001:000796CC 368 0001:000796DB + 369 0001:000796E5 370 0001:000796EF 371 0001:000796F9 374 0001:0007973C + 376 0001:00079764 379 0001:00079786 381 0001:0007978C 382 0001:00079798 + 386 0001:0007979F 387 0001:000797A6 388 0001:000797B1 389 0001:000797BF + 391 0001:000797E9 394 0001:0007980C 395 0001:0007980F 397 0001:0007981D + 398 0001:00079822 400 0001:00079825 403 0001:00079828 404 0001:0007982B + 405 0001:00079838 408 0001:00079841 409 0001:00079848 413 0001:0007984A + 414 0001:00079856 417 0001:0007985D 418 0001:0007986A 422 0001:0007986C + 423 0001:00079889 424 0001:00079893 425 0001:000798A5 426 0001:000798F0 + 429 0001:00079928 430 0001:0007992B 431 0001:00079936 433 0001:00079941 + 434 0001:0007994E 438 0001:00079950 441 0001:00079953 443 0001:00079962 + 444 0001:00079969 445 0001:00079976 446 0001:00079987 450 0001:0007998E + 452 0001:0007999D 453 0001:000799AE 456 0001:000799BB 461 0001:00079A14 + 463 0001:00079A1E 465 0001:00079A2D 466 0001:00079A34 467 0001:00079A41 + 468 0001:00079A52 472 0001:00079A58 473 0001:00079A69 474 0001:00079A76 + 476 0001:00079A7A 482 0001:00079AC4 483 0001:00079AC7 486 0001:00079AD0 + 487 0001:00079AD7 489 0001:00079AE4 490 0001:00079AED 493 0001:00079AFC + 495 0001:00079B09 499 0001:00079B0C 500 0001:00079B33 501 0001:00079B7A + 508 0001:00079B94 509 0001:00079B9E 511 0001:00079BA4 513 0001:00079BBC + 514 0001:00079BC2 515 0001:00079BC8 511 0001:00079BD5 517 0001:00079BD8 + 521 0001:00079BE0 522 0001:00079BFD 524 0001:00079C03 526 0001:00079C22 + 527 0001:00079C27 531 0001:00079C29 532 0001:00079C3F 533 0001:00079C57 + 534 0001:00079C64 536 0001:00079C8B 540 0001:00079C94 541 0001:00079C97 + 543 0001:00079CA6 546 0001:00079CB7 548 0001:00079CC6 550 0001:00079CD7 + 553 0001:00079D2C 554 0001:00079D4C 556 0001:00079D52 558 0001:00079D63 + 561 0001:00079D8E 564 0001:00079D94 565 0001:00079DBC 566 0001:00079DBE + 568 0001:00079DD4 570 0001:00079DF2 571 0001:00079DF4 572 0001:00079DFB + 573 0001:00079E05 576 0001:00079E30 581 0001:00079E58 582 0001:00079E5D + 584 0001:00079E6B 586 0001:00079E80 587 0001:00079E9B 584 0001:00079E9C + 589 0001:00079E9F 594 0001:00079EA4 595 0001:00079ECA 596 0001:00079ED8 + 597 0001:00079F11 598 0001:00079F17 600 0001:00079F2A 602 0001:00079F33 + 603 0001:00079F48 605 0001:00079F58 607 0001:00079F78 609 0001:00079F7E + 610 0001:00079F86 612 0001:00079F97 614 0001:00079FC9 620 0001:0007A008 + 621 0001:0007A028 623 0001:0007A036 624 0001:0007A06F 625 0001:0007A094 + 627 0001:0007A09D 629 0001:0007A0D0 630 0001:0007A0FD 633 0001:0007A10A + 635 0001:0007A115 638 0001:0007A12E 640 0001:0007A144 641 0001:0007A149 + 643 0001:0007A15D 646 0001:0007A175 647 0001:0007A17D 649 0001:0007A1AF + 652 0001:0007A228 653 0001:0007A22B 654 0001:0007A234 655 0001:0007A24D + 662 0001:0007A250 663 0001:0007A289 665 0001:0007A299 666 0001:0007A2A7 + 670 0001:0007A2BC 672 0001:0007A2C4 674 0001:0007A2E2 676 0001:0007A2F6 + 677 0001:0007A304 678 0001:0007A329 668 0001:0007A34C 682 0001:0007A364 + 684 0001:0007A374 685 0001:0007A3B4 687 0001:0007A424 687 0001:0007A42B + +Line numbers for PseuWoWConsole(M:\Mangos\PseudoWoWGM\src\PseuWoWConsole.dpr) segment .text + + 12 0001:0007A7A4 13 0001:0007A7B4 14 0001:0007A7C0 15 0001:0007A7D1 + 16 0001:0007A7E9 17 0001:0007A7F5 + +Bound resource files + +c:\program files\borland\delphi6\Lib\CONTROLS.RES +c:\program files\borland\delphi6\Lib\BUTTONS.RES +c:\program files\borland\delphi6\Lib\EXTDLGS.RES +F:\Delphi Updates\jedi vcl\Resources\JvConsts.res +fMain.DFM +PseuWoWConsole.RES +PseuWoWConsole.drf + + +Program entry point at 0001:0007A7A4 diff --git a/src/tools/PseuWoWConsole/src/RedirectConsole.pas b/src/tools/PseuWoWConsole/src/RedirectConsole.pas index cc0270b..1c70b96 100644 --- a/src/tools/PseuWoWConsole/src/RedirectConsole.pas +++ b/src/tools/PseuWoWConsole/src/RedirectConsole.pas @@ -1,144 +1,144 @@ -///////////////////////////////////////////////////// -// // -// UNiT REDiRECT CONSOLE by SONiC // -// // -// Console input/output redirection with pipes // -// Last revision: 02/SEPT/02 // -// // -// Bugs/comments to: Sonic1980@msn.com // -// Home page: http://sonic.rulestheweb.com // -// // -// Freeware // -// // -///////////////////////////////////////////////////// - -unit RedirectConsole; - -interface - -const - CRLF=#13#10; - -var - RC_SendBuf: string; - RC_End: Boolean; - RC_ExitCode: Cardinal; - -procedure RC_Run(Command: string); -procedure RC_LineIn(s: string); -var RC_LineOut: procedure(s: string); - -implementation - -uses Windows, Forms; - -procedure RC_LineIn(s: string); -begin - RC_SendBuf:=RC_SendBuf+s+CRLF; -end; // RC_LineIn; - -function IsWinNT: Boolean; -var osv: tOSVERSIONINFO; -begin - osv.dwOSVersionInfoSize:=sizeof(osv); - GetVersionEx(osv); - result:=osv.dwPlatformID=VER_PLATFORM_WIN32_NT; -end; // IsWinNT - -procedure SplitLines(s: string); -var t: string; -begin - while pos(CRLF, s)<>0 do begin - t:=copy(s, 1, pos(CRLF, s)-1); - RC_LineOut(t); - delete(s, 1, pos(CRLF, s)+1); - end; - if length(s)>0 then RC_LineOut(s); -end; // SplitLines - -procedure RC_Run(Command: string); -const bufsize=1024; // 1KByte buffer -var - buf: array [0..bufsize-1] of char; - si: tSTARTUPINFO; - sa: tSECURITYATTRIBUTES; - sd: tSECURITYDESCRIPTOR; - pi: tPROCESSINFORMATION; - newstdin, newstdout, read_stdout, write_stdin: tHandle; - bread, avail: dword; -begin - // Configuraciones de seguridad para WinNT - if IsWinNT then begin - InitializeSecurityDescriptor(@sd, SECURITY_DESCRIPTOR_REVISION); - SetSecurityDescriptorDacl(@sd, true, nil, false); - sa.lpSecurityDescriptor:=@sd; - end else sa.lpSecurityDescriptor:=nil; - // Creamos Pipe A - if not CreatePipe(newstdin, write_stdin, @sa, 0) then begin - RC_LineOut('Error creating Pipe A'); - exit; - end; - // Creamos Pipe B - if not CreatePipe(read_stdout, newstdout, @sa, 0) then begin - RC_LineOut('Error creating Pipe B'); - CloseHandle(newstdin); - CloseHandle(write_stdin); - exit; - end; - // Configuramos si - GetStartupInfo(si); - si.dwFlags:=STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW; - si.wShowWindow:=SW_HIDE; - si.hStdOutput:=newstdout; - si.hStdError:=newstdout; - si.hStdInput:=newstdin; - // Creamos proceso - if not CreateProcess(pchar(command), nil, nil, nil, true, - CREATE_NEW_CONSOLE, nil, nil, si, pi) then begin - RC_LineOut('Error creating process: '+command); - CloseHandle(newstdin); - CloseHandle(newstdout); - CloseHandle(read_stdout); - CloseHandle(write_stdin); - exit; - end; - // Loop principal - fillchar(buf, sizeof(buf), 0); - RC_End:=false; - RC_SendBuf:=''; - repeat - // application.processmessages; - Application.HandleMessage; - GetExitCodeProcess(pi.hProcess, RC_ExitCode); - if (RC_ExitCode<>STILL_ACTIVE) then RC_End:=True; - PeekNamedPipe(read_stdout, @buf, bufsize, @bread, @avail, nil); - // Comprobamos texto de salida - if (bread<>0) then begin - fillchar(buf, bufsize, 0); - if (avail>bufsize) then - while (bread>=bufsize) do begin - ReadFile(read_stdout, buf, bufsize, bread, nil); - SplitLines(buf); - fillchar(buf, bufsize, 0); - end - else begin - ReadFile(read_stdout, buf, bufsize, bread, nil); - SplitLines(buf); - end; - end; - // Comprobamos texto de entrada - while (Length(RC_SendBuf)>0) do begin - WriteFile(write_stdin, RC_SendBuf[1], 1, bread, nil); - Delete(RC_SendBuf, 1, 1); - end; - until RC_End; - // Cerramos las cosas - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); - CloseHandle(newstdin); - CloseHandle(newstdout); - CloseHandle(read_stdout); - CloseHandle(write_stdin); -end; // RC_Run - -end. +///////////////////////////////////////////////////// +// // +// UNiT REDiRECT CONSOLE by SONiC // +// // +// Console input/output redirection with pipes // +// Last revision: 02/SEPT/02 // +// // +// Bugs/comments to: Sonic1980@msn.com // +// Home page: http://sonic.rulestheweb.com // +// // +// Freeware // +// // +///////////////////////////////////////////////////// + +unit RedirectConsole; + +interface + +const + CRLF=#13#10; + +var + RC_SendBuf: string; + RC_End: Boolean; + RC_ExitCode: Cardinal; + +procedure RC_Run(Command: string); +procedure RC_LineIn(s: string); +var RC_LineOut: procedure(s: string); + +implementation + +uses Windows, Forms; + +procedure RC_LineIn(s: string); +begin + RC_SendBuf:=RC_SendBuf+s+CRLF; +end; // RC_LineIn; + +function IsWinNT: Boolean; +var osv: tOSVERSIONINFO; +begin + osv.dwOSVersionInfoSize:=sizeof(osv); + GetVersionEx(osv); + result:=osv.dwPlatformID=VER_PLATFORM_WIN32_NT; +end; // IsWinNT + +procedure SplitLines(s: string); +var t: string; +begin + while pos(CRLF, s)<>0 do begin + t:=copy(s, 1, pos(CRLF, s)-1); + RC_LineOut(t); + delete(s, 1, pos(CRLF, s)+1); + end; + if length(s)>0 then RC_LineOut(s); +end; // SplitLines + +procedure RC_Run(Command: string); +const bufsize=1024; // 1KByte buffer +var + buf: array [0..bufsize-1] of char; + si: tSTARTUPINFO; + sa: tSECURITYATTRIBUTES; + sd: tSECURITYDESCRIPTOR; + pi: tPROCESSINFORMATION; + newstdin, newstdout, read_stdout, write_stdin: tHandle; + bread, avail: dword; +begin + // Configuraciones de seguridad para WinNT + if IsWinNT then begin + InitializeSecurityDescriptor(@sd, SECURITY_DESCRIPTOR_REVISION); + SetSecurityDescriptorDacl(@sd, true, nil, false); + sa.lpSecurityDescriptor:=@sd; + end else sa.lpSecurityDescriptor:=nil; + // Creamos Pipe A + if not CreatePipe(newstdin, write_stdin, @sa, 0) then begin + RC_LineOut('Error creating Pipe A'); + exit; + end; + // Creamos Pipe B + if not CreatePipe(read_stdout, newstdout, @sa, 0) then begin + RC_LineOut('Error creating Pipe B'); + CloseHandle(newstdin); + CloseHandle(write_stdin); + exit; + end; + // Configuramos si + GetStartupInfo(si); + si.dwFlags:=STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW; + si.wShowWindow:=SW_HIDE; + si.hStdOutput:=newstdout; + si.hStdError:=newstdout; + si.hStdInput:=newstdin; + // Creamos proceso + if not CreateProcess(pchar(command), nil, nil, nil, true, + CREATE_NEW_CONSOLE, nil, nil, si, pi) then begin + RC_LineOut('Error creating process: '+command); + CloseHandle(newstdin); + CloseHandle(newstdout); + CloseHandle(read_stdout); + CloseHandle(write_stdin); + exit; + end; + // Loop principal + fillchar(buf, sizeof(buf), 0); + RC_End:=false; + RC_SendBuf:=''; + repeat + // application.processmessages; + Application.HandleMessage; + GetExitCodeProcess(pi.hProcess, RC_ExitCode); + if (RC_ExitCode<>STILL_ACTIVE) then RC_End:=True; + PeekNamedPipe(read_stdout, @buf, bufsize, @bread, @avail, nil); + // Comprobamos texto de salida + if (bread<>0) then begin + fillchar(buf, bufsize, 0); + if (avail>bufsize) then + while (bread>=bufsize) do begin + ReadFile(read_stdout, buf, bufsize, bread, nil); + SplitLines(buf); + fillchar(buf, bufsize, 0); + end + else begin + ReadFile(read_stdout, buf, bufsize, bread, nil); + SplitLines(buf); + end; + end; + // Comprobamos texto de entrada + while (Length(RC_SendBuf)>0) do begin + WriteFile(write_stdin, RC_SendBuf[1], 1, bread, nil); + Delete(RC_SendBuf, 1, 1); + end; + until RC_End; + // Cerramos las cosas + CloseHandle(pi.hThread); + CloseHandle(pi.hProcess); + CloseHandle(newstdin); + CloseHandle(newstdout); + CloseHandle(read_stdout); + CloseHandle(write_stdin); +end; // RC_Run + +end. diff --git a/src/tools/PseuWoWConsole/src/Unit1.~pas b/src/tools/PseuWoWConsole/src/Unit1.~pas index 26c9b48..96a9555 100644 --- a/src/tools/PseuWoWConsole/src/Unit1.~pas +++ b/src/tools/PseuWoWConsole/src/Unit1.~pas @@ -1,66 +1,66 @@ -unit Unit1; - -interface - -uses - Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, - StdCtrls, RedirectConsole, ExtCtrls; - -type - TForm1 = class(TForm) - Memo1: TMemo; - Edit2: TEdit; - Panel1: TPanel; - Edit1: TEdit; - Button2: TButton; - Button3: TButton; - procedure Button2Click(Sender: TObject); - procedure Button3Click(Sender: TObject); - procedure Edit2KeyPress(Sender: TObject; var Key: Char); - procedure FormCreate(Sender: TObject); - private - { Private declarations } - public - { Public declarations } - end; - -var - Form1: TForm1; - -implementation -{$R *.DFM} - - -procedure MyLineOut(s: string); // Output procedure -begin - form1.memo1.lines.add(s); -end; - -procedure TForm1.FormCreate(Sender: TObject); -begin - RC_LineOut:=MyLineOut; // set Output - edit2.align:=albottom; -end; - -procedure TForm1.Button2Click(Sender: TObject); -begin - RC_Run(Edit1.text); // run console program -end; - -procedure TForm1.Button3Click(Sender: TObject); -begin - RC_LineIn('exit'); - Close; -end; - -procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char); -const EnterKey=#13; NoKey=#00; -begin - if key=EnterKey then begin // send command line on Enter Key - RC_LineIn(edit2.text); - edit2.text:=''; - key:=NoKey; - end; -end; - -end. +unit Unit1; + +interface + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, RedirectConsole, ExtCtrls; + +type + TForm1 = class(TForm) + Memo1: TMemo; + Edit2: TEdit; + Panel1: TPanel; + Edit1: TEdit; + Button2: TButton; + Button3: TButton; + procedure Button2Click(Sender: TObject); + procedure Button3Click(Sender: TObject); + procedure Edit2KeyPress(Sender: TObject; var Key: Char); + procedure FormCreate(Sender: TObject); + private + { Private declarations } + public + { Public declarations } + end; + +var + Form1: TForm1; + +implementation +{$R *.DFM} + + +procedure MyLineOut(s: string); // Output procedure +begin + form1.memo1.lines.add(s); +end; + +procedure TForm1.FormCreate(Sender: TObject); +begin + RC_LineOut:=MyLineOut; // set Output + edit2.align:=albottom; +end; + +procedure TForm1.Button2Click(Sender: TObject); +begin + RC_Run(Edit1.text); // run console program +end; + +procedure TForm1.Button3Click(Sender: TObject); +begin + RC_LineIn('exit'); + Close; +end; + +procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char); +const EnterKey=#13; NoKey=#00; +begin + if key=EnterKey then begin // send command line on Enter Key + RC_LineIn(edit2.text); + edit2.text:=''; + key:=NoKey; + end; +end; + +end. diff --git a/src/tools/PseuWoWConsole/src/fMain.dfm b/src/tools/PseuWoWConsole/src/fMain.dfm index a46ca31..fb62d48 100644 --- a/src/tools/PseuWoWConsole/src/fMain.dfm +++ b/src/tools/PseuWoWConsole/src/fMain.dfm @@ -1,2879 +1,2879 @@ -object frmMain: TfrmMain - Left = 459 - Top = 296 - Width = 537 - Height = 411 - Caption = 'PseuWoW Console' - Color = clBtnFace - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Fixedsys' - Font.Style = [] - OldCreateOrder = False - Position = poDesktopCenter - OnCloseQuery = FormCloseQuery - OnCreate = FormCreate - OnDestroy = FormDestroy - PixelsPerInch = 96 - TextHeight = 15 - object pnlTop: TPanel - Left = 0 - Top = 0 - Width = 529 - Height = 73 - Align = alTop - BevelOuter = bvNone - TabOrder = 0 - Visible = False - DesignSize = ( - 529 - 73) - object txtExe: TEdit - Left = 8 - Top = 10 - Width = 513 - Height = 23 - Anchors = [akLeft, akTop, akRight] - Color = clBlack - Font.Charset = DEFAULT_CHARSET - Font.Color = 16744576 - Font.Height = -11 - Font.Name = 'Fixedsys' - Font.Style = [] - ParentFont = False - TabOrder = 0 - Text = '[enter path to pseuwow bin]' - end - object btnRun: TButton - Left = 8 - Top = 40 - Width = 75 - Height = 25 - Caption = 'RUN' - TabOrder = 1 - OnClick = btnRunClick - end - object btnExit: TButton - Left = 88 - Top = 40 - Width = 75 - Height = 25 - Caption = 'Exit' - TabOrder = 2 - OnClick = btnExitClick - end - end - object Console: TRichEdit - Left = 0 - Top = 123 - Width = 529 - Height = 197 - Align = alClient - Color = clBlack - Font.Charset = DEFAULT_CHARSET - Font.Color = clWhite - Font.Height = -11 - Font.Name = 'Fixedsys' - Font.Style = [] - Lines.Strings = ( - '') - ParentFont = False - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 1 - OnResizeRequest = ConsoleResizeRequest - end - object pnlBottom: TPanel - Left = 0 - Top = 320 - Width = 529 - Height = 64 - Align = alBottom - BevelOuter = bvLowered - TabOrder = 2 - object grpCmd: TGroupBox - Left = 1 - Top = 1 - Width = 527 - Height = 62 - Align = alClient - Caption = 'Command' - TabOrder = 0 - DesignSize = ( - 527 - 62) - object comCommand: TComboBox - Left = 8 - Top = 19 - Width = 513 - Height = 23 - AutoDropDown = True - Anchors = [akLeft, akTop, akRight] - Color = clBlack - Font.Charset = DEFAULT_CHARSET - Font.Color = 16744576 - Font.Height = -11 - Font.Name = 'Fixedsys' - Font.Style = [] - ItemHeight = 15 - ParentFont = False - TabOrder = 0 - OnKeyDown = comCommandKeyDown - Items.Strings = ( - '!' - '!SAY' - '!QUIT') - end - end - end - object pnlSessionTop: TPanel - Left = 0 - Top = 73 - Width = 529 - Height = 50 - Align = alTop - BevelInner = bvRaised - TabOrder = 3 - DesignSize = ( - 529 - 50) - object cbexIcon: TComboBoxEx - Left = 464 - Top = 5 - Width = 55 - Height = 38 - ItemsEx.CaseSensitive = False - ItemsEx.SortType = stNone - ItemsEx = <> - Style = csExDropDownList - StyleEx = [] - Anchors = [akTop, akRight] - ItemHeight = 16 - TabOrder = 0 - OnChange = cbexIconChange - Images = imgList - DropDownCount = 8 - end - object txtChar: TStaticText - Left = 16 - Top = 16 - Width = 22 - Height = 22 - Caption = '...' - Font.Charset = ANSI_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Verdana' - Font.Style = [fsBold] - ParentFont = False - TabOrder = 1 - end - object chkCleanMessages: TCheckBox - Left = 360 - Top = 16 - Width = 97 - Height = 17 - Anchors = [akTop, akRight] - Caption = 'Clean Up' - Checked = True - State = cbChecked - TabOrder = 2 - end - object pnlTestColor: TPanel - Left = 208 - Top = 16 - Width = 25 - Height = 25 - Color = clYellow - TabOrder = 3 - Visible = False - end - end - object servRemote: TServerSocket - Active = False - Port = 8089 - ServerType = stNonBlocking - OnClientRead = servRemoteClientRead - Left = 432 - Top = 32 - end - object timerStart: TTimer - Interval = 3000 - OnTimer = timerStartTimer - Left = 472 - Top = 32 - end - object clientSock: TClientSocket - Active = False - ClientType = ctNonBlocking - Host = '127.0.0.1' - Port = 8085 - OnConnecting = clientSockConnecting - OnConnect = clientSockConnect - OnError = clientSockError - Left = 400 - Top = 32 - end - object TrayIcon: TJvTrayIcon - Active = True - IconIndex = 0 - Icons = imgList - Visibility = [tvVisibleTaskBar, tvVisibleTaskList, tvAutoHide, tvRestoreClick, tvMinimizeClick] - Left = 360 - Top = 32 - end - object imgList: TImageList - Height = 32 - Width = 32 - Left = 312 - Top = 40 - Bitmap = { - 494C010111001300040020002000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 - 000000000000360000002800000080000000A000000001002000000000000040 - 0100000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000066990000339900003399000033 - 6600003366000000000000000000006699000033990000336600003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000003399000033 - 6600003366000000000000000000000000000066990000339900003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 2200003366000000000000000000000000000000000000002200003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000444444002222220000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000033 - 6600003366000000000000000000000000000000000000336600003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000044444400FFFFFF0022222200000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000003366000000000000000000000000000000000000000000003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000044444400EEEEEE00222222000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000066000000000000000000000000000000000000000000000066000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000044444400DDDDDD002222220000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000066 - 99000099CC0000666600000000000000000000000000006699000099CC000066 - 6600000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000044444400DDDDDD0022222200000000000000 - 0000000000000000000000000000000000000000000000000000000000000066 - 99000099CC0000666600000000000000000000000000006699000099CC000066 - 6600000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000044444400BBBBBB00222222000000 - 0000000000000000000000000000000000000000000000000000000000000033 - 0000003300000033000000000000000000000000000000330000003300000033 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000044444400999999002222 - 2200000000000000000000000000000000000000000000000000000000000066 - 3300006633000066330000000000000000006633330066333300663333009900 - 3300000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000444444009999 - 9900222222000000000000000000000000000000000000000000000000000066 - 33000066330000663300003300006633330066663300FF666600FF6666006666 - 3300990033000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000004444 - 4400999999002222220000000000000000000000000000000000000000000000 - 000000663300006633006633330066663300FF666600CC336600CC336600FF66 - 6600666633009900330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000444444000000000000000000000000000000000000000000000000000000 - 0000006699000066330066333300FF666600CC336600FFCCCC00FFCCCC00CC33 - 6600FF6666009900330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000099FF0000000000222222000000000000000000000000000000 - 000000CCFF0000CCFF0066333300FF666600CC336600FFCCCC00FFCCCC00CC33 - 6600FF6666009900330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000022222200000000000000000000000000000000000000 - 0000006699000066990099666600FF666600FF666600FF666600FF666600FF66 - 6600666633009900330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000336600003366000000000000000000FFFF - FF000000000000CCFF0000336600FFCCCC00FF666600FF666600FF6666006666 - 3300990033000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000033660000336600000000000000 - 000000CCFF000033660000CCFF0000336600FFCCCC00FFCCCC00FFCCCC00FFCC - CC000000000000336600FFCCCC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000CCFF00999999000000 - 00000033660000CCFF0000336600003366000000660000000000000000000000 - 00000000000000CCFF00FFCCCC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000FFCCCC000000 - 0000006699000066990000669900006699000066990000336600000000000000 - 00000000000099999900FFCCCC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000FFCCCC002222 - 2200006699000066990000669900006699000066990000336600000000000000 - 000099999900FFCCCC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000FFCCCC002222 - 22000066990000669900006699000066990000669900000022006699CC000000 - 220099666600CC99990000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000006699 - CC0022222200222222000099FF0000CCFF000099FF0000669900006699006699 - CC00000022000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00006699CC000066990000336600003366002222220000000000006699000066 - 99006699CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000006699CC006699 - CC00006699000000000022222200006699000033660022222200000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000033660000002200000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000330000002200003366000033660000002200000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000330033669900336699000033660000336600000022000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000330000336600000022003366990000336600000033000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000220033669900336699000033660000003300000022000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000220000336600003366000033660000336600000022000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000002200000022000000220000002200000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000003366 - 6600336666000033330000333300000000000000000000000000000000000000 - 0000336666000033330000333300000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00006666660066666600AAAAAA00000000000000000000000000666666006666 - 6600AAAAAA00AAAAAA00DDDDDD00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000222222002222 - 2200222222002222220000000000222222002222220022222200000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000222222002222220022222200222222002222 - 2200000000000000000000000000000000002222220022222200222222000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000003366660000333300000000000000000000000000000000000000 - 0000000000003366660000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000066666600AAAAAA00AAAAAA00000000000000000000000000666666006666 - 6600AAAAAA000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000444444002222220000000000444444004444440022222200000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000044444400222222002222 - 2200000000000000000000000000000000004444440000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000333300000000000000000000000000000000000000 - 0000000000000033330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000666666003333330000000000000000000000000000000000666666003333 - 3300000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000002222220000000000000000002222220000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000222222000000 - 0000000000000000000000000000000000002222220022222200000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000333300000000000000000000000000000000000000 - 0000000000000033330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000006666660066666600000000000000000000000000000000006666 - 6600000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000222222000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000002222 - 2200000000000000000000000000000000002222220000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000FFFFFF00CCCC9900999966000000000000000000000000000000 - 0000FFFFFF00CCCC990099996600000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000066666600AAAAAA00000000000000000000000000000000006666 - 6600666666000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000002222220000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000002222220000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000AAAAAA0066666600000000000000000000000000000000006666 - 6600AAAAAA000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000002222220000000000444444000000000022222200000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000222222002222 - 2200000000000000000000000000222222002222220000000000000000000000 - 0000000000000000000044444400222222000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000006666660099999900666666000000000000000000000000009999 - 9900666666006666660000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00006666660066666600AAAAAA0066666600000000000000000000000000AAAA - AA0066666600666666000000000000000000000000000000000000000000FFCC - CC00FFCCCC00FFCCCC00FFCCCC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000004444440000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000002222220000000000000000000000 - 0000000000007777770022222200000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000003333006666660099999900666666004444440000000000999999006666 - 6600003333000033330000333300336666000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000AAAAAA00555555000099CC000099CC0000000000000000000000 - 0000666666000099CC000099CC000000000000000000FFCCCC00FFCCCC00FFCC - CC00FF663300FF663300FFCCCC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000004444440000000000666666006666660022222200000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000444444004444 - 4400000000000000000000000000444444000000000000000000000000000000 - 0000777777002222220000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000777777000033330066666600666666004444440000000000CCCCCC000033 - 3300336666003366660033666600336666000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000555555000099CC000099CC0000000000000000000000 - 0000666666000099CC000099CC0000000000FFCCCC00FFCCCC00FF663300FF66 - 3300FFCC9900FF663300FFCCCC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000222222000000000000000000000000000000000000000000000000000000 - 99000033CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000666666004444 - 4400000000000000000066666600444444000000000000000000000033003366 - 9900222222000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000669999000033330066666600999999004444440044444400999999000033 - 3300777777003366660033666600336666000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000055555500555555000000000000000000000000005555 - 5500666666006666660000000000FFCCCC00FFCCCC00FF663300FFCC9900FFCC - 9900FF663300FFCCCC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000006699CC000000000099CCFF006699CC0000000000000099000000 - 99000033CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000999999004444 - 4400000000000000000044444400444444000000000000003300336699000033 - 6600000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000777777006699990000333300999999004444440099999900666666000033 - 33003399CC007777770033666600336666000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000066666600777777007777770000000000666666007777 - 7700777777000000000000000000FFCCCC00FF663300FFCC9900FF663300FF66 - 3300FFCCCC0000000000FFCCCC00FFCCCC00FFCCCC00FFCCCC00FFCCCC00FFCC - CC00000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00006699CC0099CCFF000000000099CCFF0099CCFF006699CC00000000000000 - 99000033CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000666666004444 - 4400000000006666660044444400000000000000330033669900003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000003399CC00003333009999990066666600CCCCCC00003333006699 - 9900669999006699990077777700000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000336600003366000033660000000000003366000033 - 6600003366000000000000000000FFCCCC00FF663300FFFFCC00FF663300FFCC - CC0000000000FFCCCC00FFCCCC00FF663300FF663300FF663300FF663300FFCC - CC00FFCCCC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000099CCFF0099CCFF000000000099CCFF0099CCFF006699CC00000000000000 - 99000033CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000444444000000 - 0000000000006666660044444400000000000000000000336600000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000006699990000333300CC999900CCCCCC00CC999900003333003399 - CC00669999007777770033666600000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000336600006699000033660000000000003366000066 - 9900000000000000000000000000FFCCCC00FF663300FFFFCC00FF663300FFCC - CC0000000000FFCCCC00FF663300FFCC9900FFCC9900FFCC9900FFCC9900FF66 - 3300FF663300FFCCCC00FFCCCC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000099CCFF006699CC00000000006699CC0099CCFF006699CC00000000000000 - 99000033CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000444444006666 - 6600666666004444440000003300000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000003399CC0000333300666666009999990066666600003333003399 - CC00336666003366660033666600000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000336600003366000000000000110000000000000066 - 9900000000000000000000000000FFCCCC00FF663300FFFFCC00FF663300FFCC - CC0000000000FFCCCC00FF663300FFCC9900FF663300FF663300FF663300FFCC - 9900FFCC9900FF663300FFCCCC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000099CCFF000000000088888800000000006699CC006699CC00000000000000 - 99000033CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000099999900000000000000 - 0000666666000000330033669900003366000000000022222200000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000003366000000330000333300333399003333990033339900003333000000 - 3300000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000011000000110000000000000033 - 660000000000006699000099CC00FFCCCC00FF663300FFFFCC00FF663300FFCC - CC0000000000FF663300FFCC9900FF663300FFCCCC00FFCCCC00FFCCCC00FF66 - 3300FFCC9900FF663300FFCCCC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00006699CC000000000044444400888888000000000000000000000000000000 - 99000033CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000004444 - 4400000033003366990000336600000000000000000000000000222222000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000009966 - 660099CCFF006699CC00003366003366CC003366CC00000033006699CC006699 - CC00996666009999660000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000FFCCCC00FF663300FFFFCC00FF663300FFCC - CC0000000000FF663300FFCC9900FF663300FFCCCC000000000000000000FF66 - 3300FFCC9900FF663300FFCCCC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000004444440088888800444444008888880000000000000000000000 - 99000033CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000222222000000 - 33003399CC000033660000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000009999 - 660099CCFF0099CCFF0099CCFF00333399003333990099CCFF0099CCFF006699 - CC0099666600CCCC9900CCCC9900999966009999660000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000077777700555555005555550055555500444444004444 - 4400444444003333330033333300FFCCCC00FFCCCC00FF663300FFFFCC00FF66 - 330000000000FF663300FFCC9900FF663300FFCCCC000000000000000000FF66 - 3300FFCC9900FF663300FFCCCC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000008888880022222200888888004444440000000000000099000000 - 99000033CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000033003399 - CC000033660066999900336666000000000000000000000000000000000099CC - FF00000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000009999 - 660099CCFF0000003300000033003366CC003366CC00003366000000330099CC - FF0099996600CCCC9900CCCC9900CCCC99009999660099996600000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000066CCFF0055555500777777007777770077777700777777007777 - 770077777700777777007777770077777700FFCCCC00FF663300FFFFCC00FF66 - 3300FFCCCC00FF663300FFFFCC00FF663300FFCCCC000000000000000000FF66 - 3300FFCC9900FF663300FFCCCC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 99000033CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000033003399CC000033 - 660099CCFF0066999900000000002222220000000000000000000000000099CC - FF00000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000000000000000CCCC - 99000033660066CCFF0000333300CCCCCC00EEEEEE00003333003399CC000033 - 66003399CC000000000000000000CCCC9900CCCC9900CCCC9900000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000066CCFF005555550066CCFF00111111001111110055555500111111000000 - 00000099CC000099CC0066CCFF0066CCFF00FFCCCC00FF663300FFFFCC00FF66 - 3300FFCCCC00FFCCCC00FF663300FFFFCC00FF663300FFCCCC0000000000FF66 - 3300FF663300FFCCCC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000006699CC0099CC - FF006699CC003366990000000000336699006699CC0099CCFF006699CC000000 - 00000033CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000669999000000000000000000000033003399CC000033660099CC - FF006699990099CCFF0000000000222222000000000000000000669999006699 - 9900000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000003333006699990000333300CCCCCC00EEEEEE00EEEEEE00003333003399 - CC006699990000000000CCCC990099996600CCCC990000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00007777770066CCFF0011111100555555009999990011111100555555009999 - 990011111100666666008888880000000000FFCCCC00FF663300FFFFCC00FF66 - 3300FFCCCC00FFCCCC00FF663300FFFFCC00FF663300FFCCCC00FFCCCC00FFCC - CC00FFCCCC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000000099CCFF006699 - CC00003366000033660099CCFF006699CC00336699000033660099CCFF000000 - 00000033CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000099CCFF00000033003399CC0000336600000000003366 - 6600669999003366660000000000222222000000000000000000669999000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000033330066CCFF00003333009999990066666600666666000033330066CC - FF003399CC0000000000CCCC9900CCCC99009999660000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000022222200222222002222220099999900DDDDDD005555550099999900DDDD - DD00111111008888880000000000FFCCCC00FF663300FFCC9900FF663300FFCC - CC00FFCCCC00FFCCCC00FFCCCC00FF663300FFFFCC00FF663300FF663300FF66 - 3300FF663300FFCCCC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000000099CC - FF00000000006699CC0000000000000000000000000099CCFF000000000099CC - FF00000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000003300336699000033660000000000000000006699 - 99006699990099CCFF0000000000000000006666660099999900000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000003399CC0066CCFF00003333006666660099CCFF00666666000033 - 330066CCFF006699990000000000999966000000000000000000000000000000 - 000000000000000000000000000000000000000000000000000000000000CCCC - CC00BBBBBB00BBBBBB0066666600999999004444440066666600999999001111 - 11006666660000000000FFCCCC00FF663300FFCC9900FF663300FF663300FF66 - 3300FF663300FFCCCC00FFCCCC00FF663300FFFFCC00FFFFCC00FFFFCC00FFFF - CC00FF663300FFCCCC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000003366000033660033CCFF00000000003399CC000000 - 0000000099000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000033003399CC00003366000000000022222200444444000033 - 330099CCFF0099CCFF0000000000DDDDDD002222220022222200666666000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000066CCFF006699990000333300666666006699CC00336699000033 - 330066CCFF0066CCFF0066999900000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000000000000000CCCC - CC00BBBBBB00BBBBBB0066666600444444003366990044444400111111006666 - 6600CCCCCC00DDDDDD00FFCCCC00FF663300FFCC9900FFCC9900FFCC9900FF66 - 3300FFCCCC0000000000FFCCCC00FF663300FFFFCC00FF663300FF663300FFFF - CC00FF663300FFCCCC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000000033CC - FF003399CC00003366006699CC0099CCFF00003366003399CC0033CCFF003399 - CC00000000000000000000000000000000000000000077777700000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00002222220000000000003366000000000022222200DDDDDD00222222000000 - 0000CCCCCC006699990066999900000000009999990044444400222222000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000066CCFF003399CC000033660000336600000033003366 - 9900003333003399CC0066CCFF003399CC000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000003366000033660033669900000000000000 - 00000000000000000000FFCCCC00FF663300FF663300FF663300FF663300FFCC - CC0000000000FFCCCC00FF663300FF663300FF663300FFCCCC00FF663300FFFF - CC00FF663300FFCCCC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000330099CCFF006699CC003366990033669900000000000033 - 6600000000000000000000000000000000002222220000009900000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 3300000000000000000000000000000000000000000022222200222222002222 - 22002222220099CCFF0066999900222222002222220022222200000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000033006699CC0000669900006699000033 - 66000033330066CCFF003399CC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000003366000000220000000000000000000000 - 00000000000000000000FFCCCC00FFCCCC00FFCCCC00FFCCCC00FFCCCC000000 - 000000000000FFCCCC00FFCCCC00FFCCCC00FFCCCC00FF663300FFFFCC00FFFF - CC00FF663300FFCCCC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000006699CC00000000000033CC000000 - 0000000000000000000000000000000000002222220000009900444444000000 - 0000000000000000000000000000000000000000000000000000000033003399 - CC00003366000000000000000000000000000000000000000000000000000000 - 000000000000000000006699990000333300CC99990066333300000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000033000066990099CCFF006699CC006699 - CC00000033000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000003333000033660000333300000033000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000FFCCCC00FF663300FFFFCC00FF66 - 3300FFCCCC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000033003366990099CCFF006699CC00000000000033CC000000 - 0000000000000000000000000000000000002222220077777700777777000000 - 0000000000000000000000000000000000000000000000000000336699000033 - 6600000000000000000000000000000000000000000000000000000000000033 - 330033666600669999006699990000333300CC99990066333300000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000033006699CC0000336600336699003366 - 9900000033000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000003300003333000033660000336600000033000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000FFCCCC00FF663300FFCC9900FFCC - 9900FF663300FFCCCC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000330099CCFF0099CCFF006699CC0099CCFF00000000000000 - 0000000000000000000000000000000000000000000022222200777777000000 - 99000000000000000000000000000000000000000000AAAAAA00000000000000 - 0000000000000000000000000000000000000000000000000000000000000033 - 330099CCFF0099CCFF006699990099CCFF000033330066333300000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000336666003366660000333300003333000033 - 3300003333000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000330000001100003366000000330000333300000033000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000FFCCCC00FF663300FFCC - 9900FF663300FF663300FFCCCC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000033006699CC000033660099CCFF000033CC000033CC000000 - 0000000000000000000000000000000000000000000022222200444444007777 - 7700444444000000000000000000444444004444440000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000033 - 3300CC9999006633330099CCFF00CC999900CC99990066333300000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000006699990099CCCC0066999900336666003366 - 6600003333000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000110000003300000033000033660000336600000033000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000FFCCCC00FF663300FF66 - 3300FFCC9900FFCC9900FF663300FFCCCC000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000002222220022222200222222002222220022222200222222000000 - 000000000000000000000000000000000000000000000000000022222200AAAA - AA00777777004444440044444400777777007777770022222200000000000000 - 0000000000000000000000000000000000000000000000000000000000000033 - 330099CCFF0099CCFF0099CCFF00FFCCCC006633330000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000003366660099CCCC00669999003366 - 6600000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000110000001100000011000000330000003300000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000FFCCCC00FFCCCC00FFCC - CC00FF663300FF663300FF663300FFCCCC000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000003366FF000033CC000033CC000033CC00000000000000 - 0000000000000000000000000000000000000000000000000000000000002222 - 2200222222004444440077777700AAAAAA002222220000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000066333300EEEEEE00FFCCCC00CCCCCC006633330000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000FFCCCC00FFCCCC00FFCCCC00FFCCCC000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000002222220022222200222222000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000006633330066333300663333000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000003366 - 9900003366003366990000336600000033003366990000336600000033000000 - 6600000033000000990000000000000000000000000000339900003399000033 - 9900003366000033660000000000000000000033990000336600003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 330000000000CC99990099666600996666006633330066333300000000009966 - 6600CC9999009966660066333300663333000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000336600003366000033 - 6600003366000033660000000000000000000000000000336600003366000033 - 6600000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000003366000033660000336600000033000000 - 3300000000000000000000000000000000000000000000000000000000000000 - 0000003366000033660000336600000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00006699CC000033660033669900003366006699CC0000336600000033000000 - 9900000033000000990000000000000000000000000000000000000000003366 - 9900003366000033660000000000000000003366990000339900003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 3300666699000000000000000000000000000000000000000000000000000000 - 000000000000CC99990099666600663333000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000003366 - 9900003366000033660000000000000000000000000033669900000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000339900000033000000 - 3300000000000000000000000000000000000000000000000000000000000000 - 0000003399000000330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000033660000000000000000000000000000000000003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000033006666 - 9900000033000000000000000000000000006633330066333300663333006633 - 3300663333000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000336699000000000000000000000000000000000000000000003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 3300000000000000000000000000000000000000000000000000000000000000 - 0000000033000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000222222004444440044444400222222002222 - 2200000000000000000000000000000000000000000000000000000000000000 - 0000003399000033660000000000000000000000000000339900003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000033006666 - 9900000033000000000000000000000000009966660099666600FF9966009966 - 6600996666006633330099666600663333000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000033 - 3300000000000033660000000000000000000000000000000000336699000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000003366000000 - 3300000000000000000000000000000000000000000000000000000000000000 - 0000000033000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000444444004444440022222200222222000000 - 6600000000000000000000000000000000000000000000000000000000000000 - 0000000000000033990000000000000000000000000000000000003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000033006666 - 99000000330000000000000000006633330099666600CC999900FF996600CC99 - 9900996666009966330099666600663333000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000003333000033 - 3300000000000000000000000000000000000000000000000000003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000033 - 6600000000000000000000000000000000000000000000000000000000000000 - 0000003366000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000002222220000006600000099000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000033660000000000000000000000000000000000003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000033006666 - 99000000330000000000000000006633330099666600CC999900FF996600CC99 - 9900996666009966330099666600663333000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000033 - 3300000000000000000000000000000000000000000000333300003333000000 - 0000336699000033660000000000000000000000000033669900336699000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000033 - 6600000033000000000000000000000000000000000000000000000000000000 - 3300003366000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000002222220022222200222222000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000003399000033990000000000000000000000000000339900003399000033 - 6600000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000003300666699000000 - 33000000000000000000000000006633330099666600CC999900FFCC9900CC99 - 9900996666009966660099666600663333000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000033330000000000003333000033 - 3300003333000033330000333300003333000033330000333300336666000000 - 0000000000000000000000000000000000000000000000000000003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000033 - 9900003366000000000000000000000000000000000000000000000000000033 - 6600000033000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000022222200222222002222220022222200000066000000 - 6600000066000000990000000000000000000000000000000000000000000000 - 0000003399000033660000000000000000000000000000339900003366000033 - 6600000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000003300666699000000 - 33000000000000000000000000006633330099666600CC999900FFCC9900CC99 - 99009966990099666600CC999900663333000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000033330000333300003333003366 - 6600336666000033330033666600003333000033330033666600003333000000 - 0000333399003333990000000000000000000000000033339900000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000003366000000330000000000000000000000000000000000003399000033 - 6600000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000007777 - 770022222200AAAAAA0088888800777777005555550044444400444444004444 - 4400222222000000990000000000000000000000000000000000000000000000 - 0000000033000000330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000003300666699000000 - 33000000000000000000000000006633330099666600CC999900FFCC9900CC99 - 9900CC99660099666600CC999900663333000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000003333003366660000333300336666003366 - 6600669999003366660033666600336666003366660000333300000000000000 - 00003366CC003366CC0000000000000000003366CC003366CC00000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000003399000000000000000000003300000033000000000000000000000033 - 9900000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 33000033CC00000099000000000000000000000099000033CC00000099000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000033006699CC00003333000000 - 00000000000000000000000000006633330099666600CC999900FFCCCC00CC99 - 9900CC99660099666600CC999900663333000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000003333000033330000333300336666003366 - 6600669999006699990066999900669999000000000000000000000000000000 - 00003366CC003333990000000000000000003366CC0033339900000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000006699CC00000000000000000000000000000000006699CC000000 - 0000000000000033000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000033CC00000099000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000033006699CC00003333000000 - 00000000000000000000000000006633330099666600CC999900FFCCCC00CC99 - 9900CC9999006633330000003300663333000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000333300336666000033330033666600336666003366 - 6600669999006699990000000000000000000000000000000000000000000000 - 0000333399000000000066999900000000003333990000000000336666000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000099CCFF006699CC000000000000000000000000006699CC0099CCFF006699 - CC00000000000033000033663300000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000044444400222222004444440022222200000000000033CC00000099000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000033006699CC00000000000000 - 00000000000000000000000000006633330099666600CC999900FFCCCC00CC99 - 9900996666003333660033336600000033000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000033330000333300003333003366660033666600669999003366 - 6600336666000000000000000000000000000000000000000000000000003366 - 6600333399000000000066999900000000003333990000000000336666000000 - 0000000000000000000000336600000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000099CCFF0099CCFF006699CC00000000000000000099CCFF0099CCFF000000 - 0000000000000000000000330000336633000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000003366990000336600000000000000 - 000066666600222222002222220044444400000000000033CC00000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000033000000330000003300000000009966 - 66000000000000000000000000000000000099666600CC999900FFCCCC00CC99 - 9900FF6666003333660066669900333366000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000003333000000 - 0000003333000033330000333300336666006699990000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000006699 - 9900000000003366660066999900003333000000000066999900336666000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00006699CC0099CCFF006699CC00000000006699CC0099CCFF0099CCFF000000 - 0000000000000000000000000000000000000033660000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000222222000000000000000000000000000000 - 0000444444004444440022222200222222000000000000009900000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000033006666990000003300333366006633 - 33000000000000000000000000000000000099666600CC999900CC999900CC99 - 99009966660000000000CC999900663333006633330000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000003333 - FF00003333000033330033666600000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000006699 - 9900336666006699990066999900336666006699990033666600000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000099CCFF0000000000003366000000000099CCFF006699CC000000 - 0000000000000000000000000000000000000000000033663300000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000022222200000000000000000000000000000000000000 - 0000444444002222220044444400222222000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000033000000000066669900000000009966 - 660000000000000000000000000000000000000000003366CC003399FF003366 - 9900003366000033660000000000FFCCCC00CC99990000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000003333000000000000000000000000000000000000000000000000000000 - 0000000000000000000000336600336699000000000000000000000000000000 - 0000003333006699990066999900336666006699990033666600000000000000 - 0000000000000000000000336600000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000033 - 6600000000006699CC000000000000336600000000006699CC00000000003366 - 6600000000000000000000000000003366000000000000330000669966000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000003366990000000000666666002222220000000000000000000000 - 0000000000000000000000000000000000000000000000000000666666004444 - 4400000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000033006699CC000033330000000000CC999900CC99 - 99009966660000000000000000000000000000000000CC999900996666006633 - 3300003366000033660000000000FFCCCC00CC99990000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000336699000033660000000000000000000000 - 0000003366000033660000336600003366000033660000000000000000000000 - 0000000000000000000000336600000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000003366000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000336666000000000000000000003399000000000000000000003300006699 - 6600000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000222222000000 - 0000336699000033660000000000000000004444440022222200000000000000 - 0000003366003366990000336600003366000033660000000000000000000000 - 0000666666004444440000000000000000000000000000000000000000000000 - 000000000000000033006699CC00003333000000000000000000000000009966 - 6600CC99990066333300000000000000000000000000CC999900996666003366 - CC000033660066CCFF000033660000000000FFCCCC00CC999900000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000006699CC00000000000000 - 00003399CC003366CC003399CC003366CC003399CC0000336600000000000000 - 0000000000000000000099CCFF00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000339900003399000000 - 0000000000000000000000336600000033000033660000336600000000000000 - 0000000000000000000000336600000000000000000000000000000000000033 - 0000003300000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000666666002222 - 2200000000000000000000000000000000000000000099CCFF00336699000000 - 0000000000000000000022222200000000000000000000000000000000000000 - 000000000000222222006699CC00000000000000000000000000000000000000 - 330000003300000033006699CC00003333000000000000000000000000000000 - 000099666600CC99990066333300000000009966660099666600663333000033 - 66003366CC003366CC000033660022222200FFCCCC00CC999900000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000099CCFF006699CC000000 - 0000003366000033660000336600003366000033660000003300000000000000 - 0000000000000000000099CCFF00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000033003300330033003300330000003300000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000003300000033000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000004444 - 44002222220000000000000000000000000000000000000000006699CC000000 - 0000444444002222220022222200444444002222220022222200000000000000 - 0000000000006699CC006699CC00000000000000000000000000000033006699 - CC006699CC006699CC0000333300000000000000000000000000000000000000 - 000000000000996666006633330066333300CC9999009966660000336600CC99 - 6600CC999900CC9966009966660022222200CC999900CC999900000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000006699CC000000 - 0000669999000033330066999900003333006699990033666600000000000000 - 0000000000006699CC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000099CCFF006699CC000000 - 0000000000000000000000003300000033000000000000000000000000000000 - 00000000000099CCFF0000000000336666000000000000000000000000000000 - 0000003300000033000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000000099CCFF002222 - 2200666666004444440066666600444444004444440000000000000000000000 - 00006699CC006699CC00000000000000000000000000000033006699CC000033 - 3300003333000033330000000000000000000000000000000000000000000000 - 000000000000000000009966660099666600993333006633330000336600CC99 - 6600CC9999009966660022222200CC999900CC99990000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000000099CCFF000000 - 0000336666000033330066999900003333000033330033666600003333000033 - 3300003333006699CC0000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000006699CC006699 - CC00000000000033990000336600000000000033990000336600000000000000 - 00000000000099CCFF0000000000000000003366660000000000000000000000 - 0000000000000033000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000006699CC002222 - 220066666600666666004444440066666600000000006699CC00336699000033 - 660099CCFF006699CC00000000000000000000000000000033006699CC000033 - 3300000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000CC999900CC33330000336600CC333300CC99 - 6600CC9999009966660000000000FFCCCC00CC99990000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000033 - 33000033330000333300336666006699990000333300003333003399CC003399 - CC003399CC0000000000FFCCCC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000006699 - CC00000000000000000000339900000000000000000000339900000000000033 - 6600000000000000000000000000000000000000000066999900000000000000 - 0000000000000033000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000006699 - CC002222220022222200222222002222220000000000336699006699CC006699 - CC006699CC0000000000000000000000000000000000000033006699CC000033 - 3300000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000996666009966330022222200222222002222 - 220099666600FFCCCC0099666600FFCCCC00CC99990000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000003399CC003399 - CC003399CC000033330099CCFF0033666600003333003399CC003399CC003399 - CC003399CC00FFFFFF0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000033990000336600000000006699CC0099CCFF0000000000000000000033 - 9900003366000000000000000000000000000000000000000000669999000000 - 0000000000000033000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000002222220099CC - FF006699CC00000000006699CC006699CC0022222200000000006699CC0099CC - FF006699CC0000000000000000000000000000000000000033006699CC000033 - 3300000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000002222220033666600336666003366 - 66000000000099666600FFCCCC00FFCCCC000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000222222003399 - CC003399CC00003333006699CC0099CCFF00003333003399CC003399CC003399 - CC00000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000033000000 - 330033669900336699000000000099CCFF006699CC0099CCFF00000000003366 - 9900336699000000330000003300000033000000000000000000000000006699 - 9900000000000033000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000002222 - 220022222200000000002222220099CCFF006699CC0022222200000000000000 - 00000000000000000000000000000000000000000000000033006699CC000033 - 3300000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000006633330022222200666699002222 - 2200336666000000000099666600CC9999000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000003366CC00000000000000000000000000000000002222 - 220022222200222222002222220099CCFF006699CC0022222200222222002222 - 2200000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000033000000330000003300336699000033660000336600000033000000 - 3300000033000000000000000000000000000000000000000000000000000000 - 0000669999000033000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000006699CC0000336600336666000033 - 3300000000000000000000000000000000000000000000000000000033006699 - CC00003333000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000333366006666 - 9900336666003366660000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000003399CC003399CC000000000000000000000000000000 - 0000000000000000000000000000000000006699CC0000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000099CCFF00000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000033000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000033003366990099CCFF006699CC00003366003399CC000033 - 3300000000000000000000000000000000000000000000000000000033006699 - CC00003333000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000FFFFFF00666699006666 - 9900000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000003399CC003399CC00000000000000 - 000000000000000000006699CC0099CCFF006699CC0000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000003366990099CCFF006699CC00000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000330000003300000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000330099CCFF0099CCFF006699CC0099CCFF00336666000033 - 3300000000000000000000000000000000000000000000000000000033006699 - CC00003333000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000666699009999CC006666 - 9900333366000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000003399CC003399 - CC003366CC000000000099CCFF0099CCFF006699CC006699CC00000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000099CCFF0099CCFF006699CC0099CCFF000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000033006699CC000033660099CCFF00336666003399CC000033 - 33000000000000000000000000000000000000000000000033006699CC000033 - 3300000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000009999CC00006699006666 - 9900BBBBBB00BBBBBB0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00003399CC0000336600CC999900663333006699CC003366CC00000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000003300003366000033660099CCFF00000033000000 - 0000000000000000000000003300000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000002222220099CCFF0099CCFF003399CC003399CC0066CCFF000033 - 33000000000000000000000000000000000000000000000033006699CC000033 - 3300000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000009999CC0066669900FFFF - FF00FFFFFF00BBBBBB0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000033660099CCFF0099CCFF006699CC003366CC00000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000330099CCFF0099CCFF0000003300336699000000 - 3300000000000033660000003300000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000336666003399CC003399CC0066CCFF003399CC003399CC000033 - 330000000000000000000000000000000000000033006699CC00003333000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000009999CC006666 - 9900666699000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000003399CC003399CC003366CC003399CC00000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000003300000033000000330033669900000033000000 - 0000336699000000330000003300000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000033666600336666003366660033666600003333000000 - 0000000000000000000000000000000000000033330000333300000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000033000000330000003300000033000000 - 0000000033000000330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000660033006600 - 3300660033006600330000001100660033006600330066003300660033000000 - 1100660033006600330066003300000011000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000033CC000033CC000033 - CC00000099000000990000000000000000000000000000000000000000000033 - CC000033CC000033CC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000222222002222 - 2200222222002222220022222200000000000000000000000000000000000000 - 0000000000002222220022222200222222000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000033660000339900003366000033330000333300000033000000 - 3300000033000000000000000000000000003366990000339900003366000033 - 9900003333000000330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000990033009900330000001100990033009900330099003300000011009900 - 3300660033006600330000001100000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000003333 - FF00000099000000990000000000000000000000000000000000000000003333 - FF00000099000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000444444002222220022222200000000000000000000000000000000000000 - 0000000000004444440044444400222222000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000003366990000336600003399000033660000003300003333000000 - 3300000033000000000000000000000000003366990000339900336699000033 - 6600000033000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000006600660066006600000011006600660066006600000011006600 - 6600990033000000110000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000990000000000000000000000000000000000000000000000 - 9900000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000022222200000000000000000000000000000000000000 - 0000000000000000000022222200222222000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000330000333300000033000033 - 3300000033000000000000000000000000000000000000000000000000000000 - 000000003300CC99990066333300333399000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000009900330099003300000011009900330099003300990033009900 - 3300000011000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000033CC000000990000000000000000000000000033666600000000000033 - CC00000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000004444440022222200000000000000000000000000000000000000 - 0000000000000000000022222200000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000033990000336600333333000000 - 3300000033000000000000000000000000000000000033669900003399000033 - 6600003333006633330099666600996666009966660000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000066003300000011006600330066003300660033006600 - 3300000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000033CC0000000000000000003366660000003300000000000033 - CC00000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000044444400000000000000000000000000000000000000 - 0000000000000000000044444400000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000003300000033000033 - 3300000033000000000000000000000000000000000000336600003333000033 - 330000000000CC99990033339900CC9999003333990000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000003300330000002200FF00660000003300000033000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000990000000000336666000000330000000000000099000033 - CC00000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000022222200222222000000000000000000000000000000 - 0000000000000000000022222200000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000003366990000339900000033000000 - 0000000000000000000000000000000000000000000033669900000000000000 - 00006633330099666600CC999900CC999900CC99990099666600000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000033003300330000002200FF00660000003300000033000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000033CC000033CC00000000000000330000000000000000000033CC000000 - 9900000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000007777770077777700777777000000000000000000000000000000 - 0000000000007777770077777700000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000330000003300000033000000 - 3300000000000000000000000000000000000000000000003300000000006699 - FF0000000000CC999900CCCCCC00996666000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000033003300330000002200FF00660000003300000033000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000033CC00000099000000000000000000000000003333FF000033CC000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000555555000000 - 00000000000000000000AAAAAA00777777000000000000000000000000000000 - 000000000000AAAAAA0077777700000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000006699CC00336699006699 - CC0033669900000000000000000000000000336699006699CC00336699000000 - 00003366CC000000000099666600000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000033003300330000003300FF00660000003300000033000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00003333FF0000003300000000000000000000000000000033006666FF000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000005555550000000000555555000000 - 0000000000000000000044444400222222000000000000000000000000000000 - 0000000000004444440022222200000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000006699CC006699CC003366 - 99003366990000000000000000000000000099CCFF00CCFFFF00000000009966 - 6600000000003366CC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000033003300330000003300FF00330000003300000033000000 - 0000CC0099000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000003333 - FF00000033006699CC000000000000000000000000006699CC00000033003333 - FF00000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000555555000000000055555500000000005555 - 5500000000000000000000000000000000002222220000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000099000000660000000000000000000000 - 00003366990000000000000000003366990099CCFF0099CCFF006699CC000000 - 000000000000000000003366CC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000CC009900000033003300330000003300FF00330000003300000033000000 - 0000CC0099000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000336666000000 - 000099CCFF000000330000003300000000006699CC0099CCFF006699CC000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000555555000000000055555500000000005555 - 5500000000000000000000000000222222003366660000000000000000000000 - 0000336666002222220022222200000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00006699CC006699CC006699CC00000000000000990000009900000099000000 - 6600000000000000000000000000336699006699CC0099CCFF006699CC000000 - 0000000000000000000000000000003399000000000033669900000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000CC0099000000330000003300000033000000330000003300000033000000 - 0000CC0099000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000033666600000033000000 - 000099CCFF00000033000033CC00000000006699CC0099CCFF00000000000000 - 0000000000000000330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000005555550000000000555555000000 - 000000000000000000000000000099CCFF006699CC0000000000222222000000 - 000099CCFF006699CC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00006699CC00000000006699CC00000000000000000000006600000066000000 - 990000006600000066000000000000000000336699006699CC00336699000000 - 0000000000000000000000000000000000006699CC0033669900336699000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000CC009900000033003366990099CCFF0099CCFF0000000000110000000000 - 0000CC0099000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000003366990000003300000000000000 - 000099CCFF00000033003333FF000000000099CCFF0099CCFF00000000000000 - 00000000330099CCFF0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000005555550022222200000000002222 - 22000000000000000000000000000000000099CCFF0000000000222222000000 - 00006699CC0099CCFF0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00006699CC006699CC0000000000000000000000000000006600000066000000 - 6600000099000000990000006600000033000000000000000000000000000000 - 00000000000000000000000000006699CC006699CC006699CC00336699000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000CC0099000000330099CCFF0099CCFF0099CCFF0099CCFF0099CCFF001100 - 0000CC0099000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000003366000000330000000000000000000000 - 000099CCFF00000033000033CC000000000099CCFF006699CC00000000000000 - 0000000033006699CC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000055555500222222000000 - 00000000000000000000000000000000000099CCFF0000000000222222000000 - 00006699CC006699CC0000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000003399CC000000 - 0000000000000000000000006600000033000033660000000000000066000000 - 33000000000000000000000099003333CC000000990000006600000033000000 - 000000000000000000000000000000000000336699006699CC00336699000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000099CCFF003366990011000000110000000000000099CCFF0099CC - FF00000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000033006699CC0000000000000033000000000000000000000000000000 - 00006699CC00000033003333FF00000033006699CC0000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000002222 - 2200222222000000000000000000000000000000000000000000777777000000 - 0000000000000000000022222200000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000003399CC000000 - 3300000000000000660000006600000033000000330000000000000033000033 - 9900003399003399FF0000000000000099000000990000006600000033000000 - 0000000000000000000000000000336699003366990033669900000000003366 - CC00000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000099CCFF0033669900110000000099990000999900000033000000000099CC - FF0099CCFF000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000006699CC00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000033CC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000099CCFF000000000000000000000000000000000077777700222222007777 - 7700000000004444440044444400222222000000000000000000000000000000 - 000000000000000000000000000000000000000000000000000033CCFF000000 - 3300003399000000330000003300336699003366990000000000000000000033 - 9900000000000033990000000000000000000000000000000000000000000000 - 00000000000000000000336699006699CC009966330066330000000000000000 - 00003366CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000099CCFF000000000000003300009999000099990000003300000022000000 - 000099CCFF006600660000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000033669900000033000033CC00000000000000000000000000000000000000 - 0000000000000033CC00000099000033CC000033CC0000000000000000000000 - 0000000000000033CC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000099CCFF0000000000000000000000000000000000000000000000 - 0000000000000000000000000000444444000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000003399CC000000 - 33000033660000003300336699006699CC003366990033669900000000003399 - FF00003399000033990000336600336699006699CC0033669900003366000033 - 6600000000000033660033669900336699009966330066330000000000000000 - 0000000000000033990000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000000099CC - FF00000000000000330000003300000033000000330000003300000022000000 - 220066006600CC00990000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000003366 - 99000000330000000000000000000033CC000000990000000000000000000000 - 000000000000000099000033CC000033CC000000990000000000000000000000 - 000099CCFF000000330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000099CCFF0000000000000000000000000000000000222222002222 - 2200222222000000000000000000000000006699CC0099CCFF006699CC000000 - 0000000000000000000000000000000000000000000000000000000000003399 - CC000000330000339900000000003366990033669900000000006699CC000000 - 3300000033000033660033669900336699003366990033669900336699000000 - 0000336699006699CC006699CC006699CC003366990000000000000000000000 - 0000000000000000000033339900000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000000099CC - FF00000000000000330066003300000033006600330066003300000033000000 - 2200CC009900CC00990000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000003366CC000000 - 3300000000000000000000000000000000000000330000003300000000000000 - 0000000000000000000000009900000000000000000000009900000000000000 - 000099CCFF000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000099CCFF000000000000000000222222006699CC002222 - 2200000000002222220000000000000000000000000099CCFF0099CCFF000000 - 00000000000000000000000000000000000000000000000000000000000033CC - FF000000330000336600000000006699CC006699CC0000000000003366000033 - 6600000033000000330000003300000066000000330000336600336699003366 - 99006699CC003366990033669900336699006699CC0000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000000099CC - FF0000000000660066006600660066003300660066000000330000003300CC00 - 9900CC009900CC00990000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000003399CC00000033000000 - 0000000000000000000000000000000000000000000099CCFF006699CC000000 - 00000033CC0000009900000000000033CC000000990000000000000000006699 - CC006699CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000006699CC0000000000222222000000000099CCFF000000 - 0000222222000000000000000000000000006699CC006699CC00000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00003399CC0000000000000000000000000000000000336699006699CC000000 - 3300336699006699CC0000339900000033006699CC0000000000003333000033 - 3300003333000000000000000000336699003366990000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000000099CC - FF0099CCFF00660066006600660099CCFF00660066006600660000003300CC00 - 9900CC0099000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000336600000000006699FF0000003300000000000000 - 000000000000000000000000000000000000000000000000000099CCFF000000 - 00003333FF000033CC00000099003333FF000033CC0000003300000033006699 - CC00000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000033669900336699006699 - CC00003366000000000077777700000000006699CC0000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000CCCCCC00CCCCCC0000333300000000000000000099CC - FF00CC99660099CCFF0099CCFF00003399000000660000333300CCCCCC00CCCC - CC00CCCCCC00CCCCCC0066999900000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000099CCFF003366990099CCFF0099CCFF0099CCFF006699FF00CC009900FF33 - CC00FF33CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000003399FF000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000033 - CC0000000000000099003333FF0000009900000000003333FF000033CC000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000007777770077777700000000006699CC0099CC - FF00000000007777770077777700AAAAAA000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000006699990066999900CCCCCC0066999900003333006699 - CC0099CCFF0099663300CC99660099CCFF0099CCFF0000333300669999006699 - 9900336666003366660033666600CCCCCC006699990000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000099CCFF0099CCFF003366990099CCFF00669933006699FF00CC009900CC33 - 9900CC3399000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000003366000000000033669900000000000033660000000000000000000000 - 0000000000000000000000000000000000000000000000000000000033003333 - FF000033CC00000000000000330000003300000000000033CC003333FF000033 - CC00000033000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000022222200DDDDDD00AAAAAA007777770077777700000000000000 - 000000000000AAAAAA00DDDDDD0077777700DDDDDD0077777700222222000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000099CCCC0099CCCC006699990033666600336666000000 - 00006699CC0099CCFF00996633009966330099CCFF006699CC000033330099CC - CC0099CCCC006699990033666600336666003366660000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000099CCFF00000000000000330099CCFF006699FF0066006600CC00 - 9900000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000222222000000 - 0000000000003399FF0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 330000003300000033000000330099CCFF006699CC0000003300000033000000 - 3300000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000002222220022222200222222002222220044444400AAAA - AA00777777002222220022222200222222002222220022222200000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000CCFFFF0099CCCC0066999900336666000000 - 0000000000000000000000000000336699006699CC0000000000000000000033 - 3300CCFFFF0099CCCC0066999900000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000CC00990000000000000033006699FF0066006600CC00 - 9900000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000222222002222 - 2200666666000000000000336600000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000006699CC0000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000033 - 66006699CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000996633006699CC006699CC003366990000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000CC009900CC009900000000003366990099CCFF006699FF0066006600CC00 - 9900000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000022222200999999006666 - 6600222222000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000033003366990099CCFF006699CC0000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000336699006699 - CC006699CC000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000006633000099CCFF006699CC00336699006699CC00000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000CC0099000000000099CCFF0099CCFF0066006600CC009900CC00 - 9900000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000022222200DDDDDD009999 - 9900222222002222220000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000330099CCFF0099CCFF006699CC0099CCFF00003333000000 - 0000000000000033330000333300000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000000099CCFF0099CC - FF006699CC006699CC0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000099CCFF006699CC0099CCFF006699CC0000336600000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000006699CC000033660066006600CC0099000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000002222220099999900222222002222 - 2200000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000033006699CC000033660099CCFF0033666600003333000000 - 0000003333003366660000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000003300003366000033 - 66006699CC003366660000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000336600000000000033660099CCFF006699CC00000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000006600660066006600FF33CC00CC0099000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000002222220022222200000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000002222220022222200222222002222220022222200222222000033 - 33003399CC003366660000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000330099CCFF0099CC - FF00333366000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000009966330099CCFF0099CCFF006699CC006699CC00000000000000 - 0000000000006633330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000CC009900CC009900CC009900FF33CC000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000033666600CCFFFF0066CCFF0066CCFF003399CC000033330066CC - FF00336666000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000333366003333 - 6600000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000CC99660099CCFF006699CC0000336600663333000000 - 0000663333000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000033666600336666003366660033666600000000003366 - 6600336666000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000006666FF004848 - FF002525FF002525FF002525FF002525FF002525FF000000DC000000DC000000 - 96000000960000000000D4FFFF00000000000000000000000000000000000000 - 0000D4FFFF00D4FFFF00D4FFFF00000000002525FF006B6BFF006B6BFF004848 - FF004848FF000000FF002525FF002525FF000000000000000000000000000000 - 0000000000000000000000000000000000009999FF009999FF00000000000000 - 000000000000000000006666FF006666FF006666FF006666FF006666FF000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000009999FF00000000000000000000000000000000000000 - 000000000000000000000000000000000000FFCC9900FFCC9900FFCC9900FFCC - 99000000000000000000FF663300FF663300FF663300FF663300FF6633000000 - 00000000000000000000000000000000000000000000FFCC9900000000000000 - 00000000000000000000FFCC9900000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000006666FF004848 - FF002525FF002525FF002525FF002525FF002525FF002525FF000000DC000000 - DC000000960000009600000000005B5BFF000000FF000000FF000000B9000000 - B900000000000000000000000000000000004848FF008E8EFF006B6BFF006B6B - FF006B6BFF004848FF002525FF002525FF009999FF0000000000000000000000 - 000000000000000000009999FF009999FF00CCCCFF00CCCCFF009999FF000000 - 00006666FF006666FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF006666 - FF006666FF00000000009999FF000000000000000000000000009999FF009999 - FF009999FF009999FF0000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000FFCC9900FFFFFF00FFCC9900FFFF - FF00FF663300FF663300FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FF66 - 3300FF6633000000000000000000000000000000000000000000000000000000 - 000000000000FFCC990000000000000000000000000000000000000000000000 - 0000000000000000000000000000006699000033660000669900000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000003366000033660000336600006699000000000000000000000000000000 - 00003300330000000000000000000000000000000000000000008E8EFF006666 - FF004848FF004848FF002525FF002525FF002525FF002525FF002525FF000000 - DC0000009600000000000000000000000000000000005B5BFF000000FF000000 - FF002525FF000000B9000000B900000000004848FF004848FF008E8EFF008E8E - FF006B6BFF006B6BFF004848FF002525FF00000000009999FF009999FF000000 - 000000000000000000009999FF00CCCCFF00FFFFFF00CCCCFF00CCCCFF00CCCC - FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF006666FF0000000000000000009999FF009999FF00CCCCFF00FFFF - FF00CCCCFF009999FF0000000000000000000000000000000000000000000000 - 00000000000000000000FFCC9900FFCC9900FFCC9900FFFFFF00FFFFFF00FFCC - CC00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF00FF6633000000000000000000FFCC99000000000000000000FFCC - 9900FFCC99000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000006699000066990000669900000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000006699000066990000000000000000000000000000000000000000000066 - 9900330033000000000000000000000000000000000000000000000000000000 - 0000000000004848FF004848FF004848FF002525FF002525FF002525FF002525 - FF0000000000FFFFFF00CECECE00FFFFFF00FFFFFF0000000000000000005B5B - FF002525FF002525FF000000B9000000B900000000004848FF004848FF004848 - FF008E8EFF006B6BFF006B6BFF006B6BFF00000000009999FF00CCCCFF009999 - FF009999FF009999FF009999FF00CCCCFF00FFFFFF00FFFFFF00CCCCFF00FFFF - FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF00FFFFFF006666FF00000000009999FF00FFFFFF00FFFFFF00CCCC - FF009999FF000000000000000000000000000000000000000000000000000000 - 000000000000FFCC9900FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFCCCC00FFFF - FF00FFFFFF00FFFFFF00FFFFFF009900000099000000CC999900FFFFFF00FFFF - FF00FFFFFF00FFFFFF00FF6633000000000000000000FFCC9900FFCC9900FFCC - CC00FFCC99000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000CCFF0000CCFF000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000CCFF000000000000000000000000000000000000000000006699003300 - 330000000000000000000000000000000000000000000000000000000000B3D7 - D700B3D7D700000000002525FF004848FF004848FF004848FF004848FF004848 - FF000000000000007300000000000000000000000000FFFFFF00FFFFFF000000 - 0000000000005B5BFF002525FF000000B9000000000000000000000000000000 - FF004848FF008E8EFF008E8EFF004848FF00000000009999FF00CCCCFF00CCCC - FF00CCCCFF00CCCCFF00CCCCFF00FFFFFF00FFFFFF00CCCCFF00FFFFFF00FFFF - FF00FFFFFF00FFFFFF009966CC000000DD000000EE000066FF003366FF00CCCC - FF00FFFFFF00FFFFFF00FFFFFF006666FF00FFFFFF00FFFFFF00CCCCFF009999 - FF00000000000000000000000000000000000000000000000000000000000000 - 000000000000FFCC9900FFFFFF00FFFFFF00FFFFFF00FFCCCC00FFFFFF00FFFF - FF00FFFFFF00FFFFFF00FFCC9900FF993300CC33330099000000FF333300FFFF - FF00FFFFFF00FFFFFF00FFFFFF00FFFFCC00FFCC9900FFCCCC00FFFFFF00FFCC - 9900000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000099FF000099 - FF00000000000000000000000000000000000000000000000000000000000000 - 00000099FF000000000000000000000000000000000000669900330033000000 - 0000000000000000000000000000000000000000000000000000D4FFFF00D4FF - FF00B3D7D700000000007575FF006666FF006666FF005757FF005757FF000000 - 0000000073000000B9000000B900000000000000FF000000000000000000FFFF - FF00FFFFFF00000000002525FF000000B90000000000C0C0C000C0C0C0000000 - 0000000000002525FF004848FF004848FF0000000000000000009999FF009999 - FF00CCCCFF00CCCCFF00CCCCFF00FFFFFF00FFFFFF00CCCCFF00FFFFFF00FFFF - FF0099CCFF000066FF000000BB000000BB000000BB000066FF000066FF000066 - FF00EEEEEE00FFFFFF00FFFFFF006666FF00FFFFFF00CCCCFF00CCCCFF00CCCC - FF009999FF000000000000000000000000000000000000000000FFCC99000000 - 00000000000000000000FFCC9900FFCC9900FFFFFF00FFCCCC00FFFFFF00FFFF - FF00FFFFFF00FFCC9900FFFFFF00FFFFFF00FFCCCC00FFFFFF00FF333300FF33 - 3300FFFFFF00FFFFFF00FFFFFF00FFFFCC00FFFFFF00FFFFFF00FFCC99000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000099 - FF00000000000000000000000000000000000000000000000000000000000000 - 00000099FF000000000000000000000000000066990033003300000000000000 - 0000000000000000000000000000000000000000000000000000D4FFFF000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 73000000B9000000B9000000730000007300000000000000FF000000FF000000 - 0000FFFFFF00000000002525FF000000B90000000000D4FFFF00D4FFFF00C0C0 - C000C0C0C000000000004848FF002525FF000000000000000000000000000000 - 00009999FF00CCCCFF00CCCCFF00CCCCFF00CCCCFF00FFFFFF00FFFFFF00EEEE - EE000066FF000066FF000033FF000000BB000000EE000000EE000066FF000066 - FF003366FF00FFFFFF00FFFFFF00CCCCFF00CCCCFF00CCCCFF00FFFFFF00FFFF - FF009999FF009999FF0000000000000000000000000000000000000000000000 - 0000FFCC9900000000000000000000000000FFCCCC00FFFFFF00FFFFFF00FFFF - FF00FFFFCC00FFFFFF00FFFFFF00FFCCCC00FF996600FF336600FF996600FFCC - 9900FFFFCC00FFFFFF00FFFFFF00FFFFFF00FFFFCC00FFCCCC00FFCC9900FFCC - 9900FFCC9900FFCC990000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000000000CC - FF0000CCFF000000000000000000000000000000000000000000000000000000 - 000000CCFF0000CCFF0000000000006699003300330000000000000000000000 - 00000000000000000000000000000000000000000000F0FBFF00000000000000 - 0000000000000000000000000000000000000000000000000000FFFFFF000000 - 00000000B900000073000000730000007300000000000000FF000000FF000000 - FF0000000000000000002525FF000000B9000000B90000000000F0FBFF000000 - 0000000000004848FF004848FF002525FF000000000000000000000000009999 - FF009999FF00CCCCFF00CCCCFF00CCCCFF00CCCCFF00CCCCFF00FFFFFF006699 - FF000066FF000033FF000033FF000000BB000000BB000000BB000000FF000066 - FF000066FF0099CCFF00FFFFFF00CCCCFF00CCCCFF00CCCCFF00FFFFFF00CCCC - FF00FFFFFF009999FF0000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000FF663300FFFFFF00FFFFFF00FFFF - CC00FFFFFF00FFFFCC00FFFFFF00FFFFFF00FFCCCC00FFCCCC00FF999900FF99 - 9900FFCC9900FFFFFF00FFFFFF00FFFFFF00FFFFCC00FFFFFF00FFCCCC00FFCC - CC00FFCCCC00FFCCCC00FFCC9900000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000066 - 9900006699000066990000000000000000000000000000000000000000000066 - 9900006699003300330000669900330033000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000FFFFFF00FFFFFF000000 - 00000000000000000000000000000000730000000000000000000000FF000000 - FF00000000006B6BFF002424EB000000B9000000B90000000000000000002525 - FF004848FF004848FF002525FF002525FF000000000000000000000000009999 - FF00FFFFFF00FFFFFF00CCCCFF00CCCCFF00FFFFFF00CCCCFF00FFFFFF000066 - FF000066FF000033FF000033FF000033FF000033FF000000EE000000EE000033 - FF000066FF000066FF00EEEEEE00CCCCFF00CCCCFF00CCCCFF00CCCCFF00FFFF - FF00FFFFFF009999FF000000000000000000FFCC9900FFCC9900FFCC9900FFCC - 9900FFCC9900FFCC9900FFCC9900FF663300FFFFFF00FFFFFF00FFFFFF00FF99 - 6600FFCC9900FFFFFF00FFFFCC00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF00FFCCCC00FFFFFF00FFFFFF00FFFFFF00FFFFCC00FFFFFF00FFFF - FF00FFFFFF00FFFFFF00FFCC9900000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00006699FF006699FF006699FF00000000000000000000000000000000006699 - FF00330033000066990033003300000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000FFFFFF00FFFFFF00CECE - CE00FFFFFF00CECECE00FFFFFF000000000000000000FFFFFF00000000000000 - 00006B6BFF002525FF002424EB000000B90000000000000096000000B9004848 - FF004848FF0000009600000096004848FF0000000000000000009999FF00FFFF - FF00FFFFFF00FFFFFF00FFFFFF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000033 - FF000066FF000033FF000033FF000000990000007700000099000000EE000000 - EE000066FF000033FF006699FF00FFFFFF00CCCCFF00CCCCFF00FFFFFF009999 - FF009999FF009999FF000000000000000000FFCC9900FFCC9900FFCCCC00FFFF - CC00FFFFCC00FFCCCC00FFCCCC00FFCCCC00FFFFFF00FFFFFF00FFFFFF00FF66 - 0000FF660000FF996600FF999900FFFFFF00FFFFFF00FFFFFF00FF999900FF99 - 9900FF333300FF660000FFFFFF00FFFFFF00FFFFFF00FFFFCC00FFCCCC00FFCC - 9900FFCC9900FFCCCC00FFFFFF00FFCC99000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000006699FF006699FF00000000000000000000000000000000003300 - 3300006699006600330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000C0C0C00000000000000000000000 - 00000000000000000000FFFFFF00CECECE00FFFFFF00FFFFFF00000000000000 - 00000000FF002424EB000000B9000000B90000000000000096000000B9002525 - FF0000009600000096004848FF004848FF0000000000000000009999FF009999 - FF00FFFFFF00FFFFFF00FFFFFF00CCCCFF00FFFFFF00FFFFFF009999CC000033 - FF000033FF000033FF0000009900000077000000770000339900000099000000 - EE000066FF000066FF000066FF00FFFFFF00FFFFFF00FFFFFF006666FF000000 - 000000000000000000009999FF00000000000000000000000000FFCC9900FFCC - CC00FFFFCC00FFFFCC00FFFFCC00FFFFCC00FFFFFF00FFFFFF00FFCC9900FF66 - 0000FF660000FF663300FF336600FF336600CC00000099000000CC000000CC33 - 3300FF336600FF333300FFCC9900FFFFFF00FFFFFF00FFFFFF00FF6633000000 - 000000000000FFCC9900FFCC9900FFCC99000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000006699FF006699FF006699FF000000000000000000330033000066 - 9900660033006666990066669900000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000004949FF004949FF002222 - EA001F1FD5004949FF000000000000000000FFFFFF00FFFFFF00000000004949 - FF002424EB002222D7000000B9000000000000009600000096000000B9000000 - B900000096004848FF004848FF002525FF00000000009999FF00000000000000 - 00009999FF006666FF006666FF00FFFFFF00FFFFFF00FFFFFF006633CC000033 - FF000033FF000000DD0000007700000077000000660000007700003399000000 - DD000033FF000066FF000066FF00FFFFFF00FFFFFF00FFFFFF006666FF000000 - 000000000000000000000000000000000000000000000000000000000000FFCC - 9900FFCC9900FFFFCC00FFFFCC00FFFFFF00FFCCCC00FFFFFF00FFFFFF00FF66 - 0000FF660000FF333300FF336600FF336600CC0000009900000099000000CC00 - 0000FF336600FF336600FF996600FFFFFF00FFFFFF00FFFFFF00FF6633000000 - 0000000000000000000000000000FFCC99000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000666699006666990066669900330033006699CC001100 - 000000CCFF0000CCFF0000CCFF00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000006B6BFF002222D7002222D7002525FF002525FF002222 - EA001F1FD5002525FF002525FF004949FF000000000000000000000000004949 - FF002222D7002020C3000000B900000000000000960000009600000096000000 - 9600000096004848FF004848FF00000096000000000000000000000000000000 - 000000000000000000006666FF00FFFFFF00FFFFFF00FFFFFF006633CC000033 - FF000033FF000000990000007700000066000000550000006600000077000000 - 99000000EE000033FF000066FF00FFFFFF00FFFFFF00FFFFFF006666FF000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000FFCC9900FFCCCC00FFFFCC00FFFFFF00FFCCCC00FFFFFF00FFFFCC00FFCC - 9900FF660000FF333300FF336600FF336600CC0000009900000099000000CC00 - 0000CC333300FF336600FF666600FFFFFF00FFFFFF00FFFFFF00FF6633000000 - 000000000000FFCC990000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000CCFF000099990000CCFF00330033006699CC006600330000CC - FF00110000001100000011000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000000000000000C0C0 - C000C0C0C000000000006B6BFF002525FF002222D7002222D7002525FF002222 - EA001F1FD5002525FF002525FF002222D7001C1CC0002222D7004949FF002222 - D7002222D7002222D7000000B900000000000000960000009600000096000000 - 96000000B9000000960000009600000096000000000000000000000000000000 - 000000000000000000006666FF00FFFFFF00FFFFFF00FFFFFF000000DD000033 - FF000033FF000000990000006600000055000000440000005500000066000000 - 99000000EE000000EE000000DD00FFFFFF00FFFFFF00FFFFFF006666FF009999 - FF00000000000000000000000000000000000000000000000000000000000000 - 0000FFCC9900FFCCCC00FF663300FFCCCC00FFCCCC00FFFFFF00FFFFFF00FFFF - FF00FFCC9900FF336600FF336600FF336600CC000000CC000000990000009900 - 0000CC000000FF336600FF336600FFFFFF00FFFFFF00FFFFFF00FF6633000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000110000001100000033003300006699006600330000CCFF000033 - 6600110000001100000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000C0C0C000D4FFFF00B3D7 - D700D4FFFF00000000006B6BFF002424EB002525FF0010106B0010106B002525 - FF0010106B0010106B001C1CC0001C1CC0002222D7002525FF002424EB002222 - D7002222D7002424EB000000B900000000000000000000000000000000000000 - 960000009600000096000000B9002525FF000000000000000000000000000000 - 00009999FF009999FF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000066FF000000 - BB000033FF000000770000339900000055000000440000005500000066000000 - 77000000EE000000EE000000EE00FFFFFF00FFFFFF00FFFFFF006666FF000000 - 000000000000000000000000000000000000FFCC990000000000FFCC9900FFCC - 9900FFCCCC00FFCCCC00FF663300FFCCCC00FFCCCC00FFFFFF00FFCC9900FFFF - FF00FF999900FF669900FF336600FF336600CC000000CC000000990000009900 - 0000CC000000FF336600FF336600FFFFFF00FFFFFF00FFFFFF00FF6633000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000066990066003300110000000066990000CC - FF00006699001100000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000F0FBFF00000000000000 - 0000F0FBFF00000000002424EB001F1FD5006D6DFF001C1CC000000000002525 - FF000000000010106B002222D7002424EB002525FF002525FF002424EB002222 - D7002424EB000000000000000000C0C0C000C0C0C000C0C0C000C0C0C0000000 - 00000000000000009600000096000000B90000000000000000009999FF000000 - 00009999FF00FFFFFF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000066FF000066 - FF000066FF000033990000006600000055000000440000005500000066000000 - 77000000EE000000EE000000EE00FFFFFF00FFFFFF00FFFFFF006666FF000000 - 000000000000000000000000000000000000000000000000000000000000FFCC - 9900FFCCCC00FFCCCC00FF663300FFCCCC00FFCCCC00FFFFFF00FF660000FF99 - 6600FFFFFF00FF999900FF999900FF336600CC000000CC000000990000009900 - 0000CC000000FF336600FF333300FFFFFF00FFFFFF00FFFFFF00FF6633000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000669900660033000099990011000000110000000000 - 000000CCFF000066990000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000002424EB001C1CC0001C1CC0001C1CC0006D6DFF00131380002525 - FF00131380002525FF001F1FD5001C1CC0001C1CC0001F1FD5002222EA002424 - EB0000000000D4FFFF00D4FFFF00C0C0C000D4FFFF00D4FFFF00C0C0C000C0C0 - C000C0C0C0000000000000009600000096000000000000000000000000009999 - FF00FFFFFF00FFFFFF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000066FF000066 - FF000066FF000066FF000033CC00000055000000440000005500000066000000 - 77000000EE000000EE000000EE00FFFFFF00FFFFFF00FFFFFF00CCCCFF009999 - FF0000000000000000000000000000000000000000000000000000000000FFCC - 9900FFCCCC00FFCCCC00FF663300FFCCCC00EEEEEE00FFFFFF00FF660000CC00 - 0000CC000000FF999900CC000000FF999900FF33660099000000990000009900 - 0000CC000000FF336600FF333300FFFFFF00FFFFFF00FFFFFF00FF663300FFCC - 9900000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000066990066003300000000006633330066333300110000001100 - 00000000000000CCFF0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000001C1CC0000000000000000000000000006D6DFF006D6DFF006D6D - FF004949FF001F1FD5000000000000000000000000001C1CC0001F1FD5000000 - FF0000000000D4FFFF00D4FFFF00C4EBEB00D4FFFF00C4EBEB00D4FFFF00D4FF - FF00C0C0C000C0C0C00000000000000096000000000000000000000000009999 - FF00CCCCFF00CCCCFF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000066FF000066 - FF000066FF000066FF0000006600000055000000440000005500000077000000 - 99000000EE000000EE000033FF00FFFFFF00FFFFFF00FFFFFF00CCCCFF009999 - FF0000000000000000000000000000000000000000000000000000000000FFCC - 9900FFCCCC00FFCCCC00FF663300FFCCCC00EEEEEE00FFFFFF00FF660000FF66 - 3300FF33660099000000FF9999009900000099000000FF33660099000000CC00 - 0000CC333300FF336600FF663300FFFFFF00FFFFFF00FFFFFF00FF999900FFFF - CC00FFCC99000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000006699006600330000000000000000006699FF006699FF006699FF00CCCC - FF00000000000000000000669900006699000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00001F1FD5000000000000EAEA000095FF0000D5D500000000006D6DFF006D6D - FF004949FF000000000000D5D50000D5D50000D5D500000000001F1FD5000000 - 0000D4FFFF00C0C0C00000000000000000000000000000000000F0FBFF00C4EB - EB00D4FFFF00C0C0C00000000000000096000000000000000000000000000000 - 00009999FF00FFFFFF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000066FF000066 - FF000066FF000033CC0000339900000066000000550000006600000077000000 - 99000000EE000033FF000066FF00FFFFFF00FFFFFF00FFFFFF00CCCCFF00CCCC - FF009999FF000000000000000000000000000000000000000000FFCC9900FFCC - CC00FFCCCC00FFCCCC00FF663300FFCCCC00EEEEEE00FFFFFF00FF660000FF66 - 3300CC333300CC33000099000000990000009900000099000000CC000000CC33 - 3300FF336600FF336600FF999900FFFFFF00FFFFFF00FFFFFF00FF999900FFFF - CC00FFCC990000000000FFCC9900000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000066 - 9900660033000000000000000000000000006699FF00666699006699FF006699 - FF00000000000000000000000000669900000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000002525 - FF0000000000D4FFFF0000FFFF000E0E0E000095FF000000000010106B001010 - 6B0000000000D4FFFF0000EAEA000095FF0000D5D50000D5D500000000000000 - 0000D4FFFF0000000000000096002525FF002525FF002525FF0000000000D4FF - FF00D4FFFF00C0C0C000C0C0C00000000000000000009999FF009999FF009999 - FF00FFFFFF00CCCCFF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000066FF000066 - FF000033FF000000DD0000007700000077000000660000007700000077000000 - DD000000EE000033FF000066FF00FFFFFF00FFFFFF00FFFFFF00CCCCFF00CCCC - FF009999FF0000000000000000000000000000000000FFCC9900FFCCCC00FFCC - CC00FFCCCC00FFCCCC00FF663300FFCCCC00FFFFFF00FFFFFF00FF996600FF66 - 3300FF336600FF333300CC333300990000009900000099000000CC000000FF33 - 6600FF336600FF333300FF996600FFFFFF00FFFFFF00FFFFFF00FF999900FFFF - CC00FFCCCC00FFCC990000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000006699003300 - 330066990000000000000000000000000000333300006699FF00333300003333 - 0000669900000000000000000000669900000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000FF002525 - FF0000000000F0FBFF00D4FFFF00D4FFFF00000000001313800010106B001313 - 800000000000F0FBFF0000FFFF000E0E0E000095FF0000D5D500000000000000 - 0000D4FFFF0000000000000096002525FF002525FF002525FF0000000000F0FB - FF00C4EBEB00D4FFFF00C0C0C0000000000000000000000000009999FF00CCCC - FF00CCCCFF00CCCCFF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000066FF000066 - FF000033FF000033FF0000009900000077000000770000007700000099000000 - EE000033FF000066FF003333CC00FFFFFF00FFFFFF00FFFFFF00CCCCFF00CCCC - FF00CCCCFF009999FF009999FF0000000000FFCC9900FFCCCC00FFCCCC00FFCC - CC00FFCCCC00FFCCCC00FF663300FFCCCC00FFFFFF00FFFFFF00FF996600FF33 - 3300FF336600FF336600FF336600CC33330099000000CC000000CC333300FF33 - 6600FF336600FF999900FF999900FFFFFF00FFFFFF00FFFFFF00FF999900FFFF - CC00FFFFCC00FFCCCC00FFCC9900000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000669900330033000000 - 000066990000669900000000000066CC0000669900003333000066CC00006699 - 0000669900003333000066990000669900000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000006D6DFF000000 - 0000000000000000000000000000000000001F1FD5002222D700131380001F1F - D5001F1FD50000000000F0FBFF0000FFFF0000EAEA0000D5D500000000001F1F - D500000000000000000000000000000096002525FF002525FF00000000000000 - 0000D4FFFF00D4FFFF00C0C0C000000000000000000000000000000000009999 - FF00FFFFFF00FFFFFF00FFFFFF00CCCCFF00FFFFFF00FFFFFF009999CC000033 - FF000033FF000033FF000033FF000000990000007700000099000000EE000000 - EE000000EE000033FF009999CC00FFFFFF00FFFFFF00CCCCFF00CCCCFF00FFFF - FF00CCCCFF00CCCCFF009999FF009999FF0000000000FFCC9900FFCC9900FFCC - 9900FFCCCC00FFCCCC00FFCCCC00FF663300FFCCCC00FFFFFF00FFCC9900FF66 - 3300FF336600FF336600FF333300FF33330099000000CC000000FF336600FF33 - 6600FF333300FF993300FFCCCC00FFFFFF00FFFFFF00FF999900FFFFCC00FFFF - CC00FFCCCC00FFCC990000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000066990033003300000000000000 - 000000000000669900000000000099CC330066CC00006699000099CC330066CC - 0000333300003333000066990000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000006D6DFF004848 - FF001F1FD5001F1FD5001F1FD5001F1FD5002525FF002222D700131380002525 - FF002525FF001F1FD50000000000F0FBFF00D4FFFF00D4FFFF00000000000000 - 00001F1FD5001F1FD500000000000000000000000000000000002222EA000000 - 0000C4EBEB00C0C0C000C0C0C000000000000000000000000000000000000000 - 00009999FF009999FF009999FF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000033 - FF000033FF000033FF000000EE000000CC000000BB000000CC000000DD000000 - EE000000EE000000EE00FFFFFF00FFFFFF00FFFFFF00CCCCFF00FFFFFF00FFFF - FF00CCCCFF00CCCCFF009999FF00000000000000000000000000000000000000 - 0000FFCC9900FFCCCC00FFCCCC00FF663300FFCCCC00EEEEEE00FFFFFF00FF66 - 0000FF336600FF336600FF336600FF33330099000000CC000000FF336600FF99 - 9900FF993300FFCCCC00FFFFFF00FFFFFF00FFFFFF00FF999900FFFFCC00FFCC - CC00FFCC990000000000FFCC9900000000000000000000000000000000000000 - 0000000000000000000000000000006699003300330000000000000000000000 - 6600000066000000000033330000333300006699000099CC3300669900003333 - 00006699000066CC000033330000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000008E8EFF004848 - FF004848FF004848FF002525FF002525FF002525FF001C1CC000000000002525 - FF004848FF004848FF001F1FD500000000000000000000000000000000000000 - 00001F1FD5001F1FD50000000000000096002222EA002222EA002222EA000000 - 0000D4FFFF00D4FFFF00C0C0C000000000000000000000000000000000000000 - 00000000000000000000000000006666FF00FFFFFF00FFFFFF00FFFFFF006633 - CC000033FF000000DD000000CC000000BB000000BB000000BB000000BB000000 - BB000000EE006633CC00FFFFFF00FFFFFF00FFFFFF006666FF00FFFFFF00FFFF - FF00CCCCFF00CCCCFF009999FF00000000000000000000000000FFCC9900FFCC - 9900FFFFFF00FFCC9900FFCCCC00FF663300FFCCCC00FFCCCC00FFFFFF00FF99 - 6600FF663300FF663300FF336600FF336600CC000000FF336600FF336600FF33 - 3300FFCCCC00FFCCCC00FFFFFF00FFFFFF00FFFFFF00FFCCCC00FFFFCC00FFCC - 9900000000000000000000000000FFCC99000000000000000000000000000000 - 0000000000000000000000669900330033000000330000000000000066000000 - 6600000066000000000066990000669900003333000066336600663366000000 - 0000669900006699000066CC0000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000008E8E - FF006B6BFF004848FF004848FF004848FF0000000000000000002222D7000000 - 00008E8EFF004848FF004848FF002222EA002222EA002222EA002222EA002222 - EA002222EA001F1FD5000000000000000000000000000000000000000000C0C0 - C000C4EBEB00D4FFFF00C0C0C000000000000000000000000000000000000000 - 0000000000000000000000000000000000006666FF00FFFFFF00FFFFFF00DDDD - DD000000EE000000BB000000BB000000BB000000BB000000BB000000BB000000 - CC000000EE00DDDDDD00FFFFFF00FFFFFF006666FF00000000009999FF009999 - FF009999FF00CCCCFF00CCCCFF009999FF000000000000000000000000000000 - 0000FFCC9900FFCC9900FFCCCC00FFCCCC00FF663300FFCCCC00FFCCCC00EEEE - EE00FF663300FF663300FF336600FF333300CC333300FF336600FF336600FF99 - 9900FFCCCC00EEEEEE00FFFFFF00FFFFFF00FFCCCC00FFFFCC00FFCCCC00FFCC - 9900000000000000000000000000000000000000000000000000000000000000 - 0000000000000066990033003300000033000000000000006600000066000000 - 66000000660000000000669900006699000000000000000033006699FF006699 - FF00000033000000330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000002222D70000000000000000000000 - 0000000000008E8EFF004848FF004848FF004848FF004848FF004848FF004848 - FF004848FF001F1FD5000000000000000000C0C0C000C0C0C000C0C0C000C4EB - EB00B3D7D700C4EBEB0000000000D4FFFF000000000000000000000000000000 - 0000000000000000000000000000000000006666FF00FFFFFF00FFFFFF00FFFF - FF009966CC000000EE000000CC000000BB000000BB000000BB000000BB000000 - EE009966CC00FFFFFF00FFFFFF00FFFFFF006666FF0000000000000000000000 - 0000000000009999FF00CCCCFF009999FF00000000000000000000000000FFCC - 99000000000000000000FFCC9900FFCCCC00FF663300FFCCCC00FFCCCC00EEEE - EE00FFCC9900FF663300FF663300FF336600FF336600FF336600FF660000FF66 - 0000FFCCCC00EEEEEE00FFFFFF00FFFFFF00FFCCCC00FFFFCC00FFCC99000000 - 0000FFCC99000000000000000000000000000000000000000000000000000000 - 0000003366003300330000000000000000000000000000006600000066000000 - 6600000066000000000000000000000000000000660000000000000033006699 - FF00000033000000660000003300000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000C0C0C000C0C0C0000000 - 00002525FF000000000000000000000000006D6DFF006B6BFF004848FF004848 - FF004848FF00000000000000000000000000D4FFFF00D4FFFF00D4FFFF00D4FF - FF00D4FFFF00C0C0C00000000000D4FFFF000000000000000000000000000000 - 00000000000000000000000000009999FF00000000006666FF00FFFFFF00FFFF - FF00FFFFFF006633CC000000EE000000DD000000BB000000BB000000DD006633 - CC00FFFFFF00FFFFFF00FFFFFF006666FF000000000000000000000000000000 - 000000000000000000009999FF009999FF000000000000000000000000000000 - 00000000000000000000FFCC9900FFCCCC00FFCCCC00FF663300FFCCCC00FFCC - CC00FFFFFF00FF996600FF660000FF663300FF336600FF663300FF660000FF99 - 6600FFFFFF00FFFFFF00FFFFFF00FFCCCC00FFFFCC00FFCCCC00FFCC99000000 - 0000000000000000000000000000000000000000000000000000000000000033 - 6600330033000000000000000000000000000000000000000000000000000000 - 000000006600000066000000660000006600000000003366990099CCFF006699 - FF00000033000000660000003300000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000D4FFFF00C0C0C0000000 - 00002525FF002525FF00000000002525FF000000000000000000000000000000 - 000000000000000000002525FF0000000000F0FBFF00F0FBFF00F0FBFF00F0FB - FF00000000000000000000000000D4FFFF000000000000000000000000000000 - 00000000000000000000CCCCFF0000000000000000006666FF00FFFFFF00FFFF - FF00FFFFFF00FFFFFF009966CC000000DD000000EE000000DD009966CC00FFFF - FF00FFFFFF00FFFFFF00FFFFFF006666FF009999FF009999FF00000000000000 - 00000000000000000000000000009999FF000000000000000000000000000000 - 0000000000000000000000000000FFCC9900FFFFCC00FF663300FFCCCC00FFCC - CC00FFCCCC00FFFFFF00FFCC9900FF660000FF660000FF660000FFCC9900FFFF - FF00FFFFFF00FFFFFF00FFFFFF00FFCCCC00FFFFCC00FFCC9900000000000000 - 0000000000000000000000000000000000000000000000669900003366003300 - 3300000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000006600000066000000000099CCFF0099CCFF006699 - FF0099CCFF000000660000003300000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000F0FBFF00D4FFFF000000 - 00000000000000000000000000000000000000000000000000002525FF002525 - FF002525FF002525FF0000000000000000000000000000000000000000000000 - 0000000000000000000000000000D4FFFF000000000000000000000000000000 - 000000000000CCCCFF0000000000000000009999FF00000000006666FF00FFFF - FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF00FFFFFF006666FF00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000FFCC9900FFFFCC00FFFFCC00FF663300FFCC - CC00FFCCCC00EEEEEE00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF00FFFFFF00FF999900FFFFCC00FFCCCC00FFCC9900000000000000 - 0000000000000000000000000000000000000000000000999900006699003300 - 3300000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000006600000000006699CC000033660099CC - FF00000033000000330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000F0FBFF000000 - 000000000000000000000000000000000000D4FFFF00C0C0C000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000CCCCFF000000000000000000000000006666 - FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF006666FF00000000009999FF000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000FFCC9900FFCC9900FFCC9900FFCC9900FF66 - 3300FFCCCC00FFCCCC00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF00FF999900FFCC9900FFCC9900FFFFCC00FFCC9900000000000000 - 0000FFCC99000000000000000000000000000000000033003300330033000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000033009999CC00000033000000 - 33000099FF000000330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000D4FFFF00000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000009999FF000000 - 00006666FF006666FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF006666 - FF006666FF00000000000000000000000000CCCCFF0000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000FFCC9900FFCC9900FFCC9900000000000000000000000000000000000000 - 0000FF663300FF663300FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FF66 - 3300FF663300000000000000000000000000FFCC9900FFCC9900FFCC9900FFCC - 990000000000FFCC990000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000003300000033009999CC000000 - 33000099FF000000330000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000006666FF006666FF006666FF006666FF006666FF000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000FF663300FF663300FF663300FF663300FF6633000000 - 000000000000000000000000000000000000000000000000000000000000FFCC - 9900000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000003300000033000000 - 3300000033000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000424D3E000000000000003E000000 - 2800000080000000A00000000100010000000000000A00000000000000000000 - 000000000000000000000000FFFFFF00FD280002000000000000000000000000 - FFFE000F000000000000000000000000FFFF020F000000000000000000000000 - FFFFC30F000000000000000000000000F3FFC30F000000000000000000000000 - F1FFE38F000000000000000000000000F8FFE38F000000000000000000000000 - FC7FC107000000000000000000000000FE3FC107000000000000000000000000 - FF1FC107000000000000000000000000FF8FC00F000000000000000000000000 - FFC4C007000000000000000000000000FFE1E003000000000000000000000000 - FFF0E003000000000000000000000000FFF06003000000000000000000000000 - FFE06003000000000000000000000000FFEC2001000000000000000000000000 - FFFE0000000000000000000000000000FFFF0000000000000000000000000000 - FFFF8010000000000000000000000000FFFF8001000000000000000000000000 - FFFF8001000000000000000000000000FFFFC003000000000000000000000000 - FFFFC003000000000000000000000000FFFF8001000000000000000000000000 - FFFF043F000000000000000000000000FFFFF83F000000000000000000000000 - FFFFF81F000000000000000000000000FFFFF81F000000000000000000000000 - FFFFF81F000000000000000000000000FFFFF81F000000000000000000000000 - FFFFFC3F000000000000000000000000F2004057408028DFFB940002FFA00205 - FFC0E0FFE080FFFFFFFF801FFFFC060FFFE0F0FFE081FFFFFFFFC01FFFFE060F - FFF8F1FFE187FFFFFFFFF03FFFFF861FFFF8F1FFF0C7FFFFFFFFF83FFFFFC63F - FFF060FFF0C3FFFFFFFFF83FFFFFC63CFFF061FFF0C3FFFFFFFFF01FFFFF8438 - FFE0407FE040E1FFFFFFF03FFFFF8431FFE0007FE02081FFFFFFF003FFFF8423 - FFE0007FE82001FFFFFFE003FFFF8047FFE0007FF84003FFFFFFF003FFFF800F - FFE0007FF802040FFFFFE003FFFF001FFFF000FFF8020807FFFFE003FFFF003F - FFF000FFF8060801FFFFE003FFFF003FFFF000FFF8000801FFFFE003FFFF000F - FFE000FFF8000801FFFFE003FFFF808FFFC0007FFC000861FFFFF003FFFF80C7 - FFC0001FF8000861FFFFF003FFFFC047FFC0001FF0000061FFFFC003FFF38047 - FFC0001FE0000023FFFF8003EFF00007FFE0003FE0000007FFFF8003DFE0000F - FFE0003FE0000003FFFFC0039FE4000FFFF0007FC0000003FFFFC0039FE0000F - FFF0007FC0000403FFFFC0071FE1000FFFF8007FE0000803FFFF80031FE3803F - FFFC00FFFC3C1803FFFFFC0F0FC7F03FFFFE01FFFC1FFF07FFFFF80F0F8FE03F - FFFE07FFF81FFF03FFFFF80F861FE03FFFFC03FFF01FFF81FFFFF80F803FE03F - FFFC03FFF01FFF80FFFFF80FC03FE07FFFFE07FFF01FFF80FFFFF81FE07FF07F - FFFF0FFFF83FFFF0FFFFFC3FF8FFF8FF00000002E9400012D00A01012000805F - C001000FFFE0007FFC9F0107FC07E0FFE001800FFFE0007FFEDF0107FE07E0FF - E003E10FFFC6007FFEDF418FFF87E1FFFC07E10FFFC6007FFEDE418FFF87E3FF - FC07F18FFFC4007FFE4C810FFFC7E3FFFE0FF18FFFC4007FFE40010FFFC3C3FF - F803E107FF8C007FFE00010FFFC3C3FFE001E107FF8C007FFE00011FFFE187FF - C001C107FF8C007FFC00001FFFE007FF8001E00FFF1C007FCC002009FFE181FF - FFFFE00FFF1C007FE000C00CFFE100FFFFFF200FFF0C007F1003C008FFE00C3F - FFFC201FFE06003F8002C00CFFE00E1FFFF8601FFE06003FC070C01CFFC00E1F - FFF8600FFE07003FC1F86018FFC00C0FFFD02003FC03003FD7FC2038FF801447 - FF820001F8C1001FF7FE0018FF0818E7FF870030E0E0001FFFFF0010FF0818F3 - FFC38010C1F0001FFFFF8001FF0010F3FFE3800183F8003FFFFF8001FF80017B - FFFF80018FFC003FFFFE8000FFC003BBFFFFC0038FFC003FFFFD8001FFE001DB - FFFFC0038FFE007FFFF5C003FFC000EBFFFFE0078FFE007FFFF0E00FFFF007F3 - FFFFFC0FC7FF00FFFFF83C3FFFFE1FFBFFFFF80FC7FF01FFFFFC003FFFFC1FFC - FFFFF80FC7FF03FFFFFF001FFFFC0CFFFFFFF80F8FFF01FFFFFFC01FFFFC09FF - FFFFF80F8FFF01FFFFFFF01FFFFC01FFFFFFF80F1FFF83FFFFFFF81FFFFC01FF - FFFFFC1F3FFFC7FFFFFFFC3FFFFE13FFFF80007FFE900040A400200B40020045 - FF80007FFFFF01C1FF80F07FF00201FFFFC000FFFFFF81C1FFC0F07FF00200FF - FFF001FFFFFFE183FFF0F87FF803007FFFF003FFFFFFE107FFF0F8FFFE03003F - FFF807FFFFFFF007FFF8F8FFFF03003FFFF80FFFFFFFF007FFF878FFFE07001F - FFF00FFFFFFFE087FFF070FFFE07001FFFF00FFFFFFFE10FFFD870FFFF0200DF - FFF003FFFFFFE10FFF5830FFFE0201FFFFE003FFFFFFC107FEA830FFF000003F - FFE003FFFFFF800FFEAC00FFE0000C1FFFE003FFFFFF0019FF4C01FFC0000C0F - FFE003FFFFFE2011FF0601FFC0000C0FFFE003FFFFF86011FF8601FF80000E0F - FFE003FFFFF0E039FFC300FF00000C07FFE003FFFFF0F031FFE3007F80000803 - FFE001FFFFE07031FFF1801F80000011FFC001FFFFC43021FFF1820F00000038 - FFC001FFFF8E0003FFF8010FC000003CFFC001FFFF1F0003FFF8001FE000003F - FFC003FFFC3F8007FFFC003FD000007FFFE003FFFC7FC007FFFC003FF800003F - FFE003FFF07FC007FFF8001FF800003FFFF007FFD1FFE00FFFFC003FFC00007F - FFF007FFC1FFFC3FFFFFC3FFFE1031FFFFE007FF87FFF83FFFFF81FFFFF01FFF - FFF007FF83FFF819FFFF81FFFFF01FFFFFF80FFF0FFFF813FFFF81FFFFF011FF - FFFC0FFF3FFFF803FFFF81FFFFF010FFFFFC0FFFFFFFF807FFFF81FFFFF803FF - FFFE1FFFFFFFFC27FFFFC3FFFFFC07FF80000000FF3C1FFDFF0C1FBDA0058012 - 800000007C1005C3FF0007FBFC1FE067800000009C000303FC000367FC1FE0C7 - C000000080000107F8000187FE0FE38FC00000008000000FF800000FFF87E31F - 80000000C0000007DC00001FFFC7E23F80000000F0000003F7000003FFC3E07F - 0F800000E0000003FF000001FFC1C0FF3F000000E000000300000001FFA0C1FF - 7F000000C000000300000000FFF0C1FFFE000000C000001DC0000018FFF040FF - FC000000B000001FE000001EFFF800FFE0000000FC00001FF000001BFFF000FF - 80000000FC00000FF000001FFFF001FF00000000F000001F4000001FFFF801FF - 00000000D000001FE000001FFFF803FF30000000E000000FE000000FFFF000FF - 70000000E000000FE0000007FFE2007FE0000000F0000007C0000005FFC6047F - C00000008000000780000003FF82007F80000000C000000100000001FF00007F - 80000000E000000080000003FC3000FF80000000F0000001F0000005FC6000FF - 80000000FE000001C000000EF84000FFC0000000FF000040F000000FF08001FF - E0000000FF000078EC000017E38001FFFE000000FE8000FCFC00001F87F001FF - FF000000FD80003EFE00003F0FFC01FFFF00000CFB4001FFFE00003F0FFE03FF - FF8E03FEFEE002FFFE0000379FFF03FFFFCF1FFEFFD0077FF1F0070BFFFF03FF - FFFF9FFFFFFC1FFFFFFC1FEFFFFF87FF00000000000000000000000000000000 - 000000000000} - end -end +object frmMain: TfrmMain + Left = 459 + Top = 296 + Width = 537 + Height = 411 + Caption = 'PseuWoW Console' + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Fixedsys' + Font.Style = [] + OldCreateOrder = False + Position = poDesktopCenter + OnCloseQuery = FormCloseQuery + OnCreate = FormCreate + OnDestroy = FormDestroy + PixelsPerInch = 96 + TextHeight = 15 + object pnlTop: TPanel + Left = 0 + Top = 0 + Width = 529 + Height = 73 + Align = alTop + BevelOuter = bvNone + TabOrder = 0 + Visible = False + DesignSize = ( + 529 + 73) + object txtExe: TEdit + Left = 8 + Top = 10 + Width = 513 + Height = 23 + Anchors = [akLeft, akTop, akRight] + Color = clBlack + Font.Charset = DEFAULT_CHARSET + Font.Color = 16744576 + Font.Height = -11 + Font.Name = 'Fixedsys' + Font.Style = [] + ParentFont = False + TabOrder = 0 + Text = '[enter path to pseuwow bin]' + end + object btnRun: TButton + Left = 8 + Top = 40 + Width = 75 + Height = 25 + Caption = 'RUN' + TabOrder = 1 + OnClick = btnRunClick + end + object btnExit: TButton + Left = 88 + Top = 40 + Width = 75 + Height = 25 + Caption = 'Exit' + TabOrder = 2 + OnClick = btnExitClick + end + end + object Console: TRichEdit + Left = 0 + Top = 123 + Width = 529 + Height = 197 + Align = alClient + Color = clBlack + Font.Charset = DEFAULT_CHARSET + Font.Color = clWhite + Font.Height = -11 + Font.Name = 'Fixedsys' + Font.Style = [] + Lines.Strings = ( + '') + ParentFont = False + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 1 + OnResizeRequest = ConsoleResizeRequest + end + object pnlBottom: TPanel + Left = 0 + Top = 320 + Width = 529 + Height = 64 + Align = alBottom + BevelOuter = bvLowered + TabOrder = 2 + object grpCmd: TGroupBox + Left = 1 + Top = 1 + Width = 527 + Height = 62 + Align = alClient + Caption = 'Command' + TabOrder = 0 + DesignSize = ( + 527 + 62) + object comCommand: TComboBox + Left = 8 + Top = 19 + Width = 513 + Height = 23 + AutoDropDown = True + Anchors = [akLeft, akTop, akRight] + Color = clBlack + Font.Charset = DEFAULT_CHARSET + Font.Color = 16744576 + Font.Height = -11 + Font.Name = 'Fixedsys' + Font.Style = [] + ItemHeight = 15 + ParentFont = False + TabOrder = 0 + OnKeyDown = comCommandKeyDown + Items.Strings = ( + '!' + '!SAY' + '!QUIT') + end + end + end + object pnlSessionTop: TPanel + Left = 0 + Top = 73 + Width = 529 + Height = 50 + Align = alTop + BevelInner = bvRaised + TabOrder = 3 + DesignSize = ( + 529 + 50) + object cbexIcon: TComboBoxEx + Left = 464 + Top = 5 + Width = 55 + Height = 38 + ItemsEx.CaseSensitive = False + ItemsEx.SortType = stNone + ItemsEx = <> + Style = csExDropDownList + StyleEx = [] + Anchors = [akTop, akRight] + ItemHeight = 16 + TabOrder = 0 + OnChange = cbexIconChange + Images = imgList + DropDownCount = 8 + end + object txtChar: TStaticText + Left = 16 + Top = 16 + Width = 22 + Height = 22 + Caption = '...' + Font.Charset = ANSI_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Verdana' + Font.Style = [fsBold] + ParentFont = False + TabOrder = 1 + end + object chkCleanMessages: TCheckBox + Left = 360 + Top = 16 + Width = 97 + Height = 17 + Anchors = [akTop, akRight] + Caption = 'Clean Up' + Checked = True + State = cbChecked + TabOrder = 2 + end + object pnlTestColor: TPanel + Left = 208 + Top = 16 + Width = 25 + Height = 25 + Color = clYellow + TabOrder = 3 + Visible = False + end + end + object servRemote: TServerSocket + Active = False + Port = 8089 + ServerType = stNonBlocking + OnClientRead = servRemoteClientRead + Left = 432 + Top = 32 + end + object timerStart: TTimer + Interval = 3000 + OnTimer = timerStartTimer + Left = 472 + Top = 32 + end + object clientSock: TClientSocket + Active = False + ClientType = ctNonBlocking + Host = '127.0.0.1' + Port = 8085 + OnConnecting = clientSockConnecting + OnConnect = clientSockConnect + OnError = clientSockError + Left = 400 + Top = 32 + end + object TrayIcon: TJvTrayIcon + Active = True + IconIndex = 0 + Icons = imgList + Visibility = [tvVisibleTaskBar, tvVisibleTaskList, tvAutoHide, tvRestoreClick, tvMinimizeClick] + Left = 360 + Top = 32 + end + object imgList: TImageList + Height = 32 + Width = 32 + Left = 312 + Top = 40 + Bitmap = { + 494C010111001300040020002000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 000000000000360000002800000080000000A000000001002000000000000040 + 0100000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000066990000339900003399000033 + 6600003366000000000000000000006699000033990000336600003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000003399000033 + 6600003366000000000000000000000000000066990000339900003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 2200003366000000000000000000000000000000000000002200003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000444444002222220000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000033 + 6600003366000000000000000000000000000000000000336600003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000044444400FFFFFF0022222200000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000003366000000000000000000000000000000000000000000003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000044444400EEEEEE00222222000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000066000000000000000000000000000000000000000000000066000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000044444400DDDDDD002222220000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000066 + 99000099CC0000666600000000000000000000000000006699000099CC000066 + 6600000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000044444400DDDDDD0022222200000000000000 + 0000000000000000000000000000000000000000000000000000000000000066 + 99000099CC0000666600000000000000000000000000006699000099CC000066 + 6600000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000044444400BBBBBB00222222000000 + 0000000000000000000000000000000000000000000000000000000000000033 + 0000003300000033000000000000000000000000000000330000003300000033 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000044444400999999002222 + 2200000000000000000000000000000000000000000000000000000000000066 + 3300006633000066330000000000000000006633330066333300663333009900 + 3300000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000444444009999 + 9900222222000000000000000000000000000000000000000000000000000066 + 33000066330000663300003300006633330066663300FF666600FF6666006666 + 3300990033000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000004444 + 4400999999002222220000000000000000000000000000000000000000000000 + 000000663300006633006633330066663300FF666600CC336600CC336600FF66 + 6600666633009900330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000444444000000000000000000000000000000000000000000000000000000 + 0000006699000066330066333300FF666600CC336600FFCCCC00FFCCCC00CC33 + 6600FF6666009900330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000099FF0000000000222222000000000000000000000000000000 + 000000CCFF0000CCFF0066333300FF666600CC336600FFCCCC00FFCCCC00CC33 + 6600FF6666009900330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000022222200000000000000000000000000000000000000 + 0000006699000066990099666600FF666600FF666600FF666600FF666600FF66 + 6600666633009900330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000336600003366000000000000000000FFFF + FF000000000000CCFF0000336600FFCCCC00FF666600FF666600FF6666006666 + 3300990033000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000033660000336600000000000000 + 000000CCFF000033660000CCFF0000336600FFCCCC00FFCCCC00FFCCCC00FFCC + CC000000000000336600FFCCCC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000CCFF00999999000000 + 00000033660000CCFF0000336600003366000000660000000000000000000000 + 00000000000000CCFF00FFCCCC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000FFCCCC000000 + 0000006699000066990000669900006699000066990000336600000000000000 + 00000000000099999900FFCCCC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000FFCCCC002222 + 2200006699000066990000669900006699000066990000336600000000000000 + 000099999900FFCCCC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000FFCCCC002222 + 22000066990000669900006699000066990000669900000022006699CC000000 + 220099666600CC99990000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000006699 + CC0022222200222222000099FF0000CCFF000099FF0000669900006699006699 + CC00000022000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00006699CC000066990000336600003366002222220000000000006699000066 + 99006699CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000006699CC006699 + CC00006699000000000022222200006699000033660022222200000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000033660000002200000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000330000002200003366000033660000002200000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000330033669900336699000033660000336600000022000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000330000336600000022003366990000336600000033000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000220033669900336699000033660000003300000022000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000220000336600003366000033660000336600000022000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000002200000022000000220000002200000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000003366 + 6600336666000033330000333300000000000000000000000000000000000000 + 0000336666000033330000333300000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00006666660066666600AAAAAA00000000000000000000000000666666006666 + 6600AAAAAA00AAAAAA00DDDDDD00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000222222002222 + 2200222222002222220000000000222222002222220022222200000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000222222002222220022222200222222002222 + 2200000000000000000000000000000000002222220022222200222222000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000003366660000333300000000000000000000000000000000000000 + 0000000000003366660000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000066666600AAAAAA00AAAAAA00000000000000000000000000666666006666 + 6600AAAAAA000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000444444002222220000000000444444004444440022222200000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000044444400222222002222 + 2200000000000000000000000000000000004444440000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000333300000000000000000000000000000000000000 + 0000000000000033330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000666666003333330000000000000000000000000000000000666666003333 + 3300000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000002222220000000000000000002222220000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000222222000000 + 0000000000000000000000000000000000002222220022222200000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000333300000000000000000000000000000000000000 + 0000000000000033330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000006666660066666600000000000000000000000000000000006666 + 6600000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000222222000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000002222 + 2200000000000000000000000000000000002222220000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000FFFFFF00CCCC9900999966000000000000000000000000000000 + 0000FFFFFF00CCCC990099996600000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000066666600AAAAAA00000000000000000000000000000000006666 + 6600666666000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000002222220000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000002222220000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000AAAAAA0066666600000000000000000000000000000000006666 + 6600AAAAAA000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000002222220000000000444444000000000022222200000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000222222002222 + 2200000000000000000000000000222222002222220000000000000000000000 + 0000000000000000000044444400222222000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000006666660099999900666666000000000000000000000000009999 + 9900666666006666660000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00006666660066666600AAAAAA0066666600000000000000000000000000AAAA + AA0066666600666666000000000000000000000000000000000000000000FFCC + CC00FFCCCC00FFCCCC00FFCCCC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000004444440000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000002222220000000000000000000000 + 0000000000007777770022222200000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000003333006666660099999900666666004444440000000000999999006666 + 6600003333000033330000333300336666000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000AAAAAA00555555000099CC000099CC0000000000000000000000 + 0000666666000099CC000099CC000000000000000000FFCCCC00FFCCCC00FFCC + CC00FF663300FF663300FFCCCC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000004444440000000000666666006666660022222200000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000444444004444 + 4400000000000000000000000000444444000000000000000000000000000000 + 0000777777002222220000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000777777000033330066666600666666004444440000000000CCCCCC000033 + 3300336666003366660033666600336666000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000555555000099CC000099CC0000000000000000000000 + 0000666666000099CC000099CC0000000000FFCCCC00FFCCCC00FF663300FF66 + 3300FFCC9900FF663300FFCCCC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000222222000000000000000000000000000000000000000000000000000000 + 99000033CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000666666004444 + 4400000000000000000066666600444444000000000000000000000033003366 + 9900222222000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000669999000033330066666600999999004444440044444400999999000033 + 3300777777003366660033666600336666000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000055555500555555000000000000000000000000005555 + 5500666666006666660000000000FFCCCC00FFCCCC00FF663300FFCC9900FFCC + 9900FF663300FFCCCC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000006699CC000000000099CCFF006699CC0000000000000099000000 + 99000033CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000999999004444 + 4400000000000000000044444400444444000000000000003300336699000033 + 6600000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000777777006699990000333300999999004444440099999900666666000033 + 33003399CC007777770033666600336666000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000066666600777777007777770000000000666666007777 + 7700777777000000000000000000FFCCCC00FF663300FFCC9900FF663300FF66 + 3300FFCCCC0000000000FFCCCC00FFCCCC00FFCCCC00FFCCCC00FFCCCC00FFCC + CC00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00006699CC0099CCFF000000000099CCFF0099CCFF006699CC00000000000000 + 99000033CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000666666004444 + 4400000000006666660044444400000000000000330033669900003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000003399CC00003333009999990066666600CCCCCC00003333006699 + 9900669999006699990077777700000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000336600003366000033660000000000003366000033 + 6600003366000000000000000000FFCCCC00FF663300FFFFCC00FF663300FFCC + CC0000000000FFCCCC00FFCCCC00FF663300FF663300FF663300FF663300FFCC + CC00FFCCCC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000099CCFF0099CCFF000000000099CCFF0099CCFF006699CC00000000000000 + 99000033CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000444444000000 + 0000000000006666660044444400000000000000000000336600000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000006699990000333300CC999900CCCCCC00CC999900003333003399 + CC00669999007777770033666600000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000336600006699000033660000000000003366000066 + 9900000000000000000000000000FFCCCC00FF663300FFFFCC00FF663300FFCC + CC0000000000FFCCCC00FF663300FFCC9900FFCC9900FFCC9900FFCC9900FF66 + 3300FF663300FFCCCC00FFCCCC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000099CCFF006699CC00000000006699CC0099CCFF006699CC00000000000000 + 99000033CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000444444006666 + 6600666666004444440000003300000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000003399CC0000333300666666009999990066666600003333003399 + CC00336666003366660033666600000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000336600003366000000000000110000000000000066 + 9900000000000000000000000000FFCCCC00FF663300FFFFCC00FF663300FFCC + CC0000000000FFCCCC00FF663300FFCC9900FF663300FF663300FF663300FFCC + 9900FFCC9900FF663300FFCCCC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000099CCFF000000000088888800000000006699CC006699CC00000000000000 + 99000033CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000099999900000000000000 + 0000666666000000330033669900003366000000000022222200000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000003366000000330000333300333399003333990033339900003333000000 + 3300000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000011000000110000000000000033 + 660000000000006699000099CC00FFCCCC00FF663300FFFFCC00FF663300FFCC + CC0000000000FF663300FFCC9900FF663300FFCCCC00FFCCCC00FFCCCC00FF66 + 3300FFCC9900FF663300FFCCCC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00006699CC000000000044444400888888000000000000000000000000000000 + 99000033CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000004444 + 4400000033003366990000336600000000000000000000000000222222000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000009966 + 660099CCFF006699CC00003366003366CC003366CC00000033006699CC006699 + CC00996666009999660000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000FFCCCC00FF663300FFFFCC00FF663300FFCC + CC0000000000FF663300FFCC9900FF663300FFCCCC000000000000000000FF66 + 3300FFCC9900FF663300FFCCCC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000004444440088888800444444008888880000000000000000000000 + 99000033CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000222222000000 + 33003399CC000033660000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000009999 + 660099CCFF0099CCFF0099CCFF00333399003333990099CCFF0099CCFF006699 + CC0099666600CCCC9900CCCC9900999966009999660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000077777700555555005555550055555500444444004444 + 4400444444003333330033333300FFCCCC00FFCCCC00FF663300FFFFCC00FF66 + 330000000000FF663300FFCC9900FF663300FFCCCC000000000000000000FF66 + 3300FFCC9900FF663300FFCCCC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000008888880022222200888888004444440000000000000099000000 + 99000033CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000033003399 + CC000033660066999900336666000000000000000000000000000000000099CC + FF00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000009999 + 660099CCFF0000003300000033003366CC003366CC00003366000000330099CC + FF0099996600CCCC9900CCCC9900CCCC99009999660099996600000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000066CCFF0055555500777777007777770077777700777777007777 + 770077777700777777007777770077777700FFCCCC00FF663300FFFFCC00FF66 + 3300FFCCCC00FF663300FFFFCC00FF663300FFCCCC000000000000000000FF66 + 3300FFCC9900FF663300FFCCCC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 99000033CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000033003399CC000033 + 660099CCFF0066999900000000002222220000000000000000000000000099CC + FF00000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000CCCC + 99000033660066CCFF0000333300CCCCCC00EEEEEE00003333003399CC000033 + 66003399CC000000000000000000CCCC9900CCCC9900CCCC9900000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000066CCFF005555550066CCFF00111111001111110055555500111111000000 + 00000099CC000099CC0066CCFF0066CCFF00FFCCCC00FF663300FFFFCC00FF66 + 3300FFCCCC00FFCCCC00FF663300FFFFCC00FF663300FFCCCC0000000000FF66 + 3300FF663300FFCCCC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000006699CC0099CC + FF006699CC003366990000000000336699006699CC0099CCFF006699CC000000 + 00000033CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000669999000000000000000000000033003399CC000033660099CC + FF006699990099CCFF0000000000222222000000000000000000669999006699 + 9900000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000003333006699990000333300CCCCCC00EEEEEE00EEEEEE00003333003399 + CC006699990000000000CCCC990099996600CCCC990000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00007777770066CCFF0011111100555555009999990011111100555555009999 + 990011111100666666008888880000000000FFCCCC00FF663300FFFFCC00FF66 + 3300FFCCCC00FFCCCC00FF663300FFFFCC00FF663300FFCCCC00FFCCCC00FFCC + CC00FFCCCC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000099CCFF006699 + CC00003366000033660099CCFF006699CC00336699000033660099CCFF000000 + 00000033CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000099CCFF00000033003399CC0000336600000000003366 + 6600669999003366660000000000222222000000000000000000669999000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000033330066CCFF00003333009999990066666600666666000033330066CC + FF003399CC0000000000CCCC9900CCCC99009999660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000022222200222222002222220099999900DDDDDD005555550099999900DDDD + DD00111111008888880000000000FFCCCC00FF663300FFCC9900FF663300FFCC + CC00FFCCCC00FFCCCC00FFCCCC00FF663300FFFFCC00FF663300FF663300FF66 + 3300FF663300FFCCCC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000000099CC + FF00000000006699CC0000000000000000000000000099CCFF000000000099CC + FF00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000003300336699000033660000000000000000006699 + 99006699990099CCFF0000000000000000006666660099999900000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000003399CC0066CCFF00003333006666660099CCFF00666666000033 + 330066CCFF006699990000000000999966000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000CCCC + CC00BBBBBB00BBBBBB0066666600999999004444440066666600999999001111 + 11006666660000000000FFCCCC00FF663300FFCC9900FF663300FF663300FF66 + 3300FF663300FFCCCC00FFCCCC00FF663300FFFFCC00FFFFCC00FFFFCC00FFFF + CC00FF663300FFCCCC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000003366000033660033CCFF00000000003399CC000000 + 0000000099000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000033003399CC00003366000000000022222200444444000033 + 330099CCFF0099CCFF0000000000DDDDDD002222220022222200666666000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000066CCFF006699990000333300666666006699CC00336699000033 + 330066CCFF0066CCFF0066999900000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000CCCC + CC00BBBBBB00BBBBBB0066666600444444003366990044444400111111006666 + 6600CCCCCC00DDDDDD00FFCCCC00FF663300FFCC9900FFCC9900FFCC9900FF66 + 3300FFCCCC0000000000FFCCCC00FF663300FFFFCC00FF663300FF663300FFFF + CC00FF663300FFCCCC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000000033CC + FF003399CC00003366006699CC0099CCFF00003366003399CC0033CCFF003399 + CC00000000000000000000000000000000000000000077777700000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00002222220000000000003366000000000022222200DDDDDD00222222000000 + 0000CCCCCC006699990066999900000000009999990044444400222222000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000066CCFF003399CC000033660000336600000033003366 + 9900003333003399CC0066CCFF003399CC000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000003366000033660033669900000000000000 + 00000000000000000000FFCCCC00FF663300FF663300FF663300FF663300FFCC + CC0000000000FFCCCC00FF663300FF663300FF663300FFCCCC00FF663300FFFF + CC00FF663300FFCCCC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000330099CCFF006699CC003366990033669900000000000033 + 6600000000000000000000000000000000002222220000009900000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 3300000000000000000000000000000000000000000022222200222222002222 + 22002222220099CCFF0066999900222222002222220022222200000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000033006699CC0000669900006699000033 + 66000033330066CCFF003399CC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000003366000000220000000000000000000000 + 00000000000000000000FFCCCC00FFCCCC00FFCCCC00FFCCCC00FFCCCC000000 + 000000000000FFCCCC00FFCCCC00FFCCCC00FFCCCC00FF663300FFFFCC00FFFF + CC00FF663300FFCCCC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000006699CC00000000000033CC000000 + 0000000000000000000000000000000000002222220000009900444444000000 + 0000000000000000000000000000000000000000000000000000000033003399 + CC00003366000000000000000000000000000000000000000000000000000000 + 000000000000000000006699990000333300CC99990066333300000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000033000066990099CCFF006699CC006699 + CC00000033000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000003333000033660000333300000033000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000FFCCCC00FF663300FFFFCC00FF66 + 3300FFCCCC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000033003366990099CCFF006699CC00000000000033CC000000 + 0000000000000000000000000000000000002222220077777700777777000000 + 0000000000000000000000000000000000000000000000000000336699000033 + 6600000000000000000000000000000000000000000000000000000000000033 + 330033666600669999006699990000333300CC99990066333300000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000033006699CC0000336600336699003366 + 9900000033000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000003300003333000033660000336600000033000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000FFCCCC00FF663300FFCC9900FFCC + 9900FF663300FFCCCC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000330099CCFF0099CCFF006699CC0099CCFF00000000000000 + 0000000000000000000000000000000000000000000022222200777777000000 + 99000000000000000000000000000000000000000000AAAAAA00000000000000 + 0000000000000000000000000000000000000000000000000000000000000033 + 330099CCFF0099CCFF006699990099CCFF000033330066333300000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000336666003366660000333300003333000033 + 3300003333000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000330000001100003366000000330000333300000033000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000FFCCCC00FF663300FFCC + 9900FF663300FF663300FFCCCC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000033006699CC000033660099CCFF000033CC000033CC000000 + 0000000000000000000000000000000000000000000022222200444444007777 + 7700444444000000000000000000444444004444440000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000033 + 3300CC9999006633330099CCFF00CC999900CC99990066333300000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000006699990099CCCC0066999900336666003366 + 6600003333000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000110000003300000033000033660000336600000033000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000FFCCCC00FF663300FF66 + 3300FFCC9900FFCC9900FF663300FFCCCC000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000002222220022222200222222002222220022222200222222000000 + 000000000000000000000000000000000000000000000000000022222200AAAA + AA00777777004444440044444400777777007777770022222200000000000000 + 0000000000000000000000000000000000000000000000000000000000000033 + 330099CCFF0099CCFF0099CCFF00FFCCCC006633330000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000003366660099CCCC00669999003366 + 6600000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000110000001100000011000000330000003300000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000FFCCCC00FFCCCC00FFCC + CC00FF663300FF663300FF663300FFCCCC000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000003366FF000033CC000033CC000033CC00000000000000 + 0000000000000000000000000000000000000000000000000000000000002222 + 2200222222004444440077777700AAAAAA002222220000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000066333300EEEEEE00FFCCCC00CCCCCC006633330000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000FFCCCC00FFCCCC00FFCCCC00FFCCCC000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000002222220022222200222222000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000006633330066333300663333000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000003366 + 9900003366003366990000336600000033003366990000336600000033000000 + 6600000033000000990000000000000000000000000000339900003399000033 + 9900003366000033660000000000000000000033990000336600003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 330000000000CC99990099666600996666006633330066333300000000009966 + 6600CC9999009966660066333300663333000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000336600003366000033 + 6600003366000033660000000000000000000000000000336600003366000033 + 6600000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000003366000033660000336600000033000000 + 3300000000000000000000000000000000000000000000000000000000000000 + 0000003366000033660000336600000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00006699CC000033660033669900003366006699CC0000336600000033000000 + 9900000033000000990000000000000000000000000000000000000000003366 + 9900003366000033660000000000000000003366990000339900003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 3300666699000000000000000000000000000000000000000000000000000000 + 000000000000CC99990099666600663333000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000003366 + 9900003366000033660000000000000000000000000033669900000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000339900000033000000 + 3300000000000000000000000000000000000000000000000000000000000000 + 0000003399000000330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000033660000000000000000000000000000000000003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000033006666 + 9900000033000000000000000000000000006633330066333300663333006633 + 3300663333000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000336699000000000000000000000000000000000000000000003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 3300000000000000000000000000000000000000000000000000000000000000 + 0000000033000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000222222004444440044444400222222002222 + 2200000000000000000000000000000000000000000000000000000000000000 + 0000003399000033660000000000000000000000000000339900003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000033006666 + 9900000033000000000000000000000000009966660099666600FF9966009966 + 6600996666006633330099666600663333000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000033 + 3300000000000033660000000000000000000000000000000000336699000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000003366000000 + 3300000000000000000000000000000000000000000000000000000000000000 + 0000000033000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000444444004444440022222200222222000000 + 6600000000000000000000000000000000000000000000000000000000000000 + 0000000000000033990000000000000000000000000000000000003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000033006666 + 99000000330000000000000000006633330099666600CC999900FF996600CC99 + 9900996666009966330099666600663333000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000003333000033 + 3300000000000000000000000000000000000000000000000000003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000033 + 6600000000000000000000000000000000000000000000000000000000000000 + 0000003366000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000002222220000006600000099000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000033660000000000000000000000000000000000003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000033006666 + 99000000330000000000000000006633330099666600CC999900FF996600CC99 + 9900996666009966330099666600663333000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000033 + 3300000000000000000000000000000000000000000000333300003333000000 + 0000336699000033660000000000000000000000000033669900336699000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000033 + 6600000033000000000000000000000000000000000000000000000000000000 + 3300003366000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000002222220022222200222222000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000003399000033990000000000000000000000000000339900003399000033 + 6600000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000003300666699000000 + 33000000000000000000000000006633330099666600CC999900FFCC9900CC99 + 9900996666009966660099666600663333000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000033330000000000003333000033 + 3300003333000033330000333300003333000033330000333300336666000000 + 0000000000000000000000000000000000000000000000000000003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000033 + 9900003366000000000000000000000000000000000000000000000000000033 + 6600000033000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000022222200222222002222220022222200000066000000 + 6600000066000000990000000000000000000000000000000000000000000000 + 0000003399000033660000000000000000000000000000339900003366000033 + 6600000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000003300666699000000 + 33000000000000000000000000006633330099666600CC999900FFCC9900CC99 + 99009966990099666600CC999900663333000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000033330000333300003333003366 + 6600336666000033330033666600003333000033330033666600003333000000 + 0000333399003333990000000000000000000000000033339900000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000003366000000330000000000000000000000000000000000003399000033 + 6600000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000007777 + 770022222200AAAAAA0088888800777777005555550044444400444444004444 + 4400222222000000990000000000000000000000000000000000000000000000 + 0000000033000000330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000003300666699000000 + 33000000000000000000000000006633330099666600CC999900FFCC9900CC99 + 9900CC99660099666600CC999900663333000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000003333003366660000333300336666003366 + 6600669999003366660033666600336666003366660000333300000000000000 + 00003366CC003366CC0000000000000000003366CC003366CC00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000003399000000000000000000003300000033000000000000000000000033 + 9900000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 33000033CC00000099000000000000000000000099000033CC00000099000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000033006699CC00003333000000 + 00000000000000000000000000006633330099666600CC999900FFCCCC00CC99 + 9900CC99660099666600CC999900663333000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000003333000033330000333300336666003366 + 6600669999006699990066999900669999000000000000000000000000000000 + 00003366CC003333990000000000000000003366CC0033339900000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000006699CC00000000000000000000000000000000006699CC000000 + 0000000000000033000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000033CC00000099000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000033006699CC00003333000000 + 00000000000000000000000000006633330099666600CC999900FFCCCC00CC99 + 9900CC9999006633330000003300663333000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000333300336666000033330033666600336666003366 + 6600669999006699990000000000000000000000000000000000000000000000 + 0000333399000000000066999900000000003333990000000000336666000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000099CCFF006699CC000000000000000000000000006699CC0099CCFF006699 + CC00000000000033000033663300000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000044444400222222004444440022222200000000000033CC00000099000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000033006699CC00000000000000 + 00000000000000000000000000006633330099666600CC999900FFCCCC00CC99 + 9900996666003333660033336600000033000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000033330000333300003333003366660033666600669999003366 + 6600336666000000000000000000000000000000000000000000000000003366 + 6600333399000000000066999900000000003333990000000000336666000000 + 0000000000000000000000336600000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000099CCFF0099CCFF006699CC00000000000000000099CCFF0099CCFF000000 + 0000000000000000000000330000336633000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000003366990000336600000000000000 + 000066666600222222002222220044444400000000000033CC00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000033000000330000003300000000009966 + 66000000000000000000000000000000000099666600CC999900FFCCCC00CC99 + 9900FF6666003333660066669900333366000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000003333000000 + 0000003333000033330000333300336666006699990000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000006699 + 9900000000003366660066999900003333000000000066999900336666000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00006699CC0099CCFF006699CC00000000006699CC0099CCFF0099CCFF000000 + 0000000000000000000000000000000000000033660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000222222000000000000000000000000000000 + 0000444444004444440022222200222222000000000000009900000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000033006666990000003300333366006633 + 33000000000000000000000000000000000099666600CC999900CC999900CC99 + 99009966660000000000CC999900663333006633330000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000003333 + FF00003333000033330033666600000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000006699 + 9900336666006699990066999900336666006699990033666600000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000099CCFF0000000000003366000000000099CCFF006699CC000000 + 0000000000000000000000000000000000000000000033663300000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000022222200000000000000000000000000000000000000 + 0000444444002222220044444400222222000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000033000000000066669900000000009966 + 660000000000000000000000000000000000000000003366CC003399FF003366 + 9900003366000033660000000000FFCCCC00CC99990000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000003333000000000000000000000000000000000000000000000000000000 + 0000000000000000000000336600336699000000000000000000000000000000 + 0000003333006699990066999900336666006699990033666600000000000000 + 0000000000000000000000336600000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000033 + 6600000000006699CC000000000000336600000000006699CC00000000003366 + 6600000000000000000000000000003366000000000000330000669966000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000003366990000000000666666002222220000000000000000000000 + 0000000000000000000000000000000000000000000000000000666666004444 + 4400000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000033006699CC000033330000000000CC999900CC99 + 99009966660000000000000000000000000000000000CC999900996666006633 + 3300003366000033660000000000FFCCCC00CC99990000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000336699000033660000000000000000000000 + 0000003366000033660000336600003366000033660000000000000000000000 + 0000000000000000000000336600000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000003366000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000336666000000000000000000003399000000000000000000003300006699 + 6600000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000222222000000 + 0000336699000033660000000000000000004444440022222200000000000000 + 0000003366003366990000336600003366000033660000000000000000000000 + 0000666666004444440000000000000000000000000000000000000000000000 + 000000000000000033006699CC00003333000000000000000000000000009966 + 6600CC99990066333300000000000000000000000000CC999900996666003366 + CC000033660066CCFF000033660000000000FFCCCC00CC999900000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000006699CC00000000000000 + 00003399CC003366CC003399CC003366CC003399CC0000336600000000000000 + 0000000000000000000099CCFF00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000339900003399000000 + 0000000000000000000000336600000033000033660000336600000000000000 + 0000000000000000000000336600000000000000000000000000000000000033 + 0000003300000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000666666002222 + 2200000000000000000000000000000000000000000099CCFF00336699000000 + 0000000000000000000022222200000000000000000000000000000000000000 + 000000000000222222006699CC00000000000000000000000000000000000000 + 330000003300000033006699CC00003333000000000000000000000000000000 + 000099666600CC99990066333300000000009966660099666600663333000033 + 66003366CC003366CC000033660022222200FFCCCC00CC999900000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000099CCFF006699CC000000 + 0000003366000033660000336600003366000033660000003300000000000000 + 0000000000000000000099CCFF00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000033003300330033003300330000003300000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000003300000033000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000004444 + 44002222220000000000000000000000000000000000000000006699CC000000 + 0000444444002222220022222200444444002222220022222200000000000000 + 0000000000006699CC006699CC00000000000000000000000000000033006699 + CC006699CC006699CC0000333300000000000000000000000000000000000000 + 000000000000996666006633330066333300CC9999009966660000336600CC99 + 6600CC999900CC9966009966660022222200CC999900CC999900000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000006699CC000000 + 0000669999000033330066999900003333006699990033666600000000000000 + 0000000000006699CC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000099CCFF006699CC000000 + 0000000000000000000000003300000033000000000000000000000000000000 + 00000000000099CCFF0000000000336666000000000000000000000000000000 + 0000003300000033000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000099CCFF002222 + 2200666666004444440066666600444444004444440000000000000000000000 + 00006699CC006699CC00000000000000000000000000000033006699CC000033 + 3300003333000033330000000000000000000000000000000000000000000000 + 000000000000000000009966660099666600993333006633330000336600CC99 + 6600CC9999009966660022222200CC999900CC99990000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000099CCFF000000 + 0000336666000033330066999900003333000033330033666600003333000033 + 3300003333006699CC0000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000006699CC006699 + CC00000000000033990000336600000000000033990000336600000000000000 + 00000000000099CCFF0000000000000000003366660000000000000000000000 + 0000000000000033000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000006699CC002222 + 220066666600666666004444440066666600000000006699CC00336699000033 + 660099CCFF006699CC00000000000000000000000000000033006699CC000033 + 3300000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000CC999900CC33330000336600CC333300CC99 + 6600CC9999009966660000000000FFCCCC00CC99990000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000033 + 33000033330000333300336666006699990000333300003333003399CC003399 + CC003399CC0000000000FFCCCC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000006699 + CC00000000000000000000339900000000000000000000339900000000000033 + 6600000000000000000000000000000000000000000066999900000000000000 + 0000000000000033000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000006699 + CC002222220022222200222222002222220000000000336699006699CC006699 + CC006699CC0000000000000000000000000000000000000033006699CC000033 + 3300000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000996666009966330022222200222222002222 + 220099666600FFCCCC0099666600FFCCCC00CC99990000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000003399CC003399 + CC003399CC000033330099CCFF0033666600003333003399CC003399CC003399 + CC003399CC00FFFFFF0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000033990000336600000000006699CC0099CCFF0000000000000000000033 + 9900003366000000000000000000000000000000000000000000669999000000 + 0000000000000033000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000002222220099CC + FF006699CC00000000006699CC006699CC0022222200000000006699CC0099CC + FF006699CC0000000000000000000000000000000000000033006699CC000033 + 3300000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000002222220033666600336666003366 + 66000000000099666600FFCCCC00FFCCCC000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000222222003399 + CC003399CC00003333006699CC0099CCFF00003333003399CC003399CC003399 + CC00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000033000000 + 330033669900336699000000000099CCFF006699CC0099CCFF00000000003366 + 9900336699000000330000003300000033000000000000000000000000006699 + 9900000000000033000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000002222 + 220022222200000000002222220099CCFF006699CC0022222200000000000000 + 00000000000000000000000000000000000000000000000033006699CC000033 + 3300000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000006633330022222200666699002222 + 2200336666000000000099666600CC9999000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000003366CC00000000000000000000000000000000002222 + 220022222200222222002222220099CCFF006699CC0022222200222222002222 + 2200000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000033000000330000003300336699000033660000336600000033000000 + 3300000033000000000000000000000000000000000000000000000000000000 + 0000669999000033000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000006699CC0000336600336666000033 + 3300000000000000000000000000000000000000000000000000000033006699 + CC00003333000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000333366006666 + 9900336666003366660000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000003399CC003399CC000000000000000000000000000000 + 0000000000000000000000000000000000006699CC0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000099CCFF00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000033000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000033003366990099CCFF006699CC00003366003399CC000033 + 3300000000000000000000000000000000000000000000000000000033006699 + CC00003333000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000FFFFFF00666699006666 + 9900000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000003399CC003399CC00000000000000 + 000000000000000000006699CC0099CCFF006699CC0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000003366990099CCFF006699CC00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000330000003300000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000330099CCFF0099CCFF006699CC0099CCFF00336666000033 + 3300000000000000000000000000000000000000000000000000000033006699 + CC00003333000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000666699009999CC006666 + 9900333366000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000003399CC003399 + CC003366CC000000000099CCFF0099CCFF006699CC006699CC00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000099CCFF0099CCFF006699CC0099CCFF000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000033006699CC000033660099CCFF00336666003399CC000033 + 33000000000000000000000000000000000000000000000033006699CC000033 + 3300000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000009999CC00006699006666 + 9900BBBBBB00BBBBBB0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00003399CC0000336600CC999900663333006699CC003366CC00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000003300003366000033660099CCFF00000033000000 + 0000000000000000000000003300000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000002222220099CCFF0099CCFF003399CC003399CC0066CCFF000033 + 33000000000000000000000000000000000000000000000033006699CC000033 + 3300000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000009999CC0066669900FFFF + FF00FFFFFF00BBBBBB0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000033660099CCFF0099CCFF006699CC003366CC00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000330099CCFF0099CCFF0000003300336699000000 + 3300000000000033660000003300000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000336666003399CC003399CC0066CCFF003399CC003399CC000033 + 330000000000000000000000000000000000000033006699CC00003333000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000009999CC006666 + 9900666699000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000003399CC003399CC003366CC003399CC00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000003300000033000000330033669900000033000000 + 0000336699000000330000003300000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000033666600336666003366660033666600003333000000 + 0000000000000000000000000000000000000033330000333300000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000033000000330000003300000033000000 + 0000000033000000330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000660033006600 + 3300660033006600330000001100660033006600330066003300660033000000 + 1100660033006600330066003300000011000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000033CC000033CC000033 + CC00000099000000990000000000000000000000000000000000000000000033 + CC000033CC000033CC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000222222002222 + 2200222222002222220022222200000000000000000000000000000000000000 + 0000000000002222220022222200222222000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000033660000339900003366000033330000333300000033000000 + 3300000033000000000000000000000000003366990000339900003366000033 + 9900003333000000330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000990033009900330000001100990033009900330099003300000011009900 + 3300660033006600330000001100000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000003333 + FF00000099000000990000000000000000000000000000000000000000003333 + FF00000099000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000444444002222220022222200000000000000000000000000000000000000 + 0000000000004444440044444400222222000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000003366990000336600003399000033660000003300003333000000 + 3300000033000000000000000000000000003366990000339900336699000033 + 6600000033000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000006600660066006600000011006600660066006600000011006600 + 6600990033000000110000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000990000000000000000000000000000000000000000000000 + 9900000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000022222200000000000000000000000000000000000000 + 0000000000000000000022222200222222000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000330000333300000033000033 + 3300000033000000000000000000000000000000000000000000000000000000 + 000000003300CC99990066333300333399000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000009900330099003300000011009900330099003300990033009900 + 3300000011000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000033CC000000990000000000000000000000000033666600000000000033 + CC00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000004444440022222200000000000000000000000000000000000000 + 0000000000000000000022222200000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000033990000336600333333000000 + 3300000033000000000000000000000000000000000033669900003399000033 + 6600003333006633330099666600996666009966660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000066003300000011006600330066003300660033006600 + 3300000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000033CC0000000000000000003366660000003300000000000033 + CC00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000044444400000000000000000000000000000000000000 + 0000000000000000000044444400000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000003300000033000033 + 3300000033000000000000000000000000000000000000336600003333000033 + 330000000000CC99990033339900CC9999003333990000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000003300330000002200FF00660000003300000033000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000990000000000336666000000330000000000000099000033 + CC00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000022222200222222000000000000000000000000000000 + 0000000000000000000022222200000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000003366990000339900000033000000 + 0000000000000000000000000000000000000000000033669900000000000000 + 00006633330099666600CC999900CC999900CC99990099666600000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000033003300330000002200FF00660000003300000033000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000033CC000033CC00000000000000330000000000000000000033CC000000 + 9900000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000007777770077777700777777000000000000000000000000000000 + 0000000000007777770077777700000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000330000003300000033000000 + 3300000000000000000000000000000000000000000000003300000000006699 + FF0000000000CC999900CCCCCC00996666000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000033003300330000002200FF00660000003300000033000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000033CC00000099000000000000000000000000003333FF000033CC000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000555555000000 + 00000000000000000000AAAAAA00777777000000000000000000000000000000 + 000000000000AAAAAA0077777700000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000006699CC00336699006699 + CC0033669900000000000000000000000000336699006699CC00336699000000 + 00003366CC000000000099666600000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000033003300330000003300FF00660000003300000033000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00003333FF0000003300000000000000000000000000000033006666FF000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000005555550000000000555555000000 + 0000000000000000000044444400222222000000000000000000000000000000 + 0000000000004444440022222200000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000006699CC006699CC003366 + 99003366990000000000000000000000000099CCFF00CCFFFF00000000009966 + 6600000000003366CC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000033003300330000003300FF00330000003300000033000000 + 0000CC0099000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000003333 + FF00000033006699CC000000000000000000000000006699CC00000033003333 + FF00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000555555000000000055555500000000005555 + 5500000000000000000000000000000000002222220000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000099000000660000000000000000000000 + 00003366990000000000000000003366990099CCFF0099CCFF006699CC000000 + 000000000000000000003366CC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000CC009900000033003300330000003300FF00330000003300000033000000 + 0000CC0099000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000336666000000 + 000099CCFF000000330000003300000000006699CC0099CCFF006699CC000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000555555000000000055555500000000005555 + 5500000000000000000000000000222222003366660000000000000000000000 + 0000336666002222220022222200000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00006699CC006699CC006699CC00000000000000990000009900000099000000 + 6600000000000000000000000000336699006699CC0099CCFF006699CC000000 + 0000000000000000000000000000003399000000000033669900000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000CC0099000000330000003300000033000000330000003300000033000000 + 0000CC0099000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000033666600000033000000 + 000099CCFF00000033000033CC00000000006699CC0099CCFF00000000000000 + 0000000000000000330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000005555550000000000555555000000 + 000000000000000000000000000099CCFF006699CC0000000000222222000000 + 000099CCFF006699CC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00006699CC00000000006699CC00000000000000000000006600000066000000 + 990000006600000066000000000000000000336699006699CC00336699000000 + 0000000000000000000000000000000000006699CC0033669900336699000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000CC009900000033003366990099CCFF0099CCFF0000000000110000000000 + 0000CC0099000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000003366990000003300000000000000 + 000099CCFF00000033003333FF000000000099CCFF0099CCFF00000000000000 + 00000000330099CCFF0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000005555550022222200000000002222 + 22000000000000000000000000000000000099CCFF0000000000222222000000 + 00006699CC0099CCFF0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00006699CC006699CC0000000000000000000000000000006600000066000000 + 6600000099000000990000006600000033000000000000000000000000000000 + 00000000000000000000000000006699CC006699CC006699CC00336699000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000CC0099000000330099CCFF0099CCFF0099CCFF0099CCFF0099CCFF001100 + 0000CC0099000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000003366000000330000000000000000000000 + 000099CCFF00000033000033CC000000000099CCFF006699CC00000000000000 + 0000000033006699CC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000055555500222222000000 + 00000000000000000000000000000000000099CCFF0000000000222222000000 + 00006699CC006699CC0000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000003399CC000000 + 0000000000000000000000006600000033000033660000000000000066000000 + 33000000000000000000000099003333CC000000990000006600000033000000 + 000000000000000000000000000000000000336699006699CC00336699000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000099CCFF003366990011000000110000000000000099CCFF0099CC + FF00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000033006699CC0000000000000033000000000000000000000000000000 + 00006699CC00000033003333FF00000033006699CC0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000002222 + 2200222222000000000000000000000000000000000000000000777777000000 + 0000000000000000000022222200000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000003399CC000000 + 3300000000000000660000006600000033000000330000000000000033000033 + 9900003399003399FF0000000000000099000000990000006600000033000000 + 0000000000000000000000000000336699003366990033669900000000003366 + CC00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000099CCFF0033669900110000000099990000999900000033000000000099CC + FF0099CCFF000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000006699CC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000033CC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000099CCFF000000000000000000000000000000000077777700222222007777 + 7700000000004444440044444400222222000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000033CCFF000000 + 3300003399000000330000003300336699003366990000000000000000000033 + 9900000000000033990000000000000000000000000000000000000000000000 + 00000000000000000000336699006699CC009966330066330000000000000000 + 00003366CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000099CCFF000000000000003300009999000099990000003300000022000000 + 000099CCFF006600660000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000033669900000033000033CC00000000000000000000000000000000000000 + 0000000000000033CC00000099000033CC000033CC0000000000000000000000 + 0000000000000033CC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000099CCFF0000000000000000000000000000000000000000000000 + 0000000000000000000000000000444444000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000003399CC000000 + 33000033660000003300336699006699CC003366990033669900000000003399 + FF00003399000033990000336600336699006699CC0033669900003366000033 + 6600000000000033660033669900336699009966330066330000000000000000 + 0000000000000033990000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000000099CC + FF00000000000000330000003300000033000000330000003300000022000000 + 220066006600CC00990000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000003366 + 99000000330000000000000000000033CC000000990000000000000000000000 + 000000000000000099000033CC000033CC000000990000000000000000000000 + 000099CCFF000000330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000099CCFF0000000000000000000000000000000000222222002222 + 2200222222000000000000000000000000006699CC0099CCFF006699CC000000 + 0000000000000000000000000000000000000000000000000000000000003399 + CC000000330000339900000000003366990033669900000000006699CC000000 + 3300000033000033660033669900336699003366990033669900336699000000 + 0000336699006699CC006699CC006699CC003366990000000000000000000000 + 0000000000000000000033339900000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000000099CC + FF00000000000000330066003300000033006600330066003300000033000000 + 2200CC009900CC00990000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000003366CC000000 + 3300000000000000000000000000000000000000330000003300000000000000 + 0000000000000000000000009900000000000000000000009900000000000000 + 000099CCFF000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000099CCFF000000000000000000222222006699CC002222 + 2200000000002222220000000000000000000000000099CCFF0099CCFF000000 + 00000000000000000000000000000000000000000000000000000000000033CC + FF000000330000336600000000006699CC006699CC0000000000003366000033 + 6600000033000000330000003300000066000000330000336600336699003366 + 99006699CC003366990033669900336699006699CC0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000000099CC + FF0000000000660066006600660066003300660066000000330000003300CC00 + 9900CC009900CC00990000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000003399CC00000033000000 + 0000000000000000000000000000000000000000000099CCFF006699CC000000 + 00000033CC0000009900000000000033CC000000990000000000000000006699 + CC006699CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000006699CC0000000000222222000000000099CCFF000000 + 0000222222000000000000000000000000006699CC006699CC00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00003399CC0000000000000000000000000000000000336699006699CC000000 + 3300336699006699CC0000339900000033006699CC0000000000003333000033 + 3300003333000000000000000000336699003366990000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000000099CC + FF0099CCFF00660066006600660099CCFF00660066006600660000003300CC00 + 9900CC0099000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000336600000000006699FF0000003300000000000000 + 000000000000000000000000000000000000000000000000000099CCFF000000 + 00003333FF000033CC00000099003333FF000033CC0000003300000033006699 + CC00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000033669900336699006699 + CC00003366000000000077777700000000006699CC0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000CCCCCC00CCCCCC0000333300000000000000000099CC + FF00CC99660099CCFF0099CCFF00003399000000660000333300CCCCCC00CCCC + CC00CCCCCC00CCCCCC0066999900000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000099CCFF003366990099CCFF0099CCFF0099CCFF006699FF00CC009900FF33 + CC00FF33CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000003399FF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000033 + CC0000000000000099003333FF0000009900000000003333FF000033CC000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000007777770077777700000000006699CC0099CC + FF00000000007777770077777700AAAAAA000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000006699990066999900CCCCCC0066999900003333006699 + CC0099CCFF0099663300CC99660099CCFF0099CCFF0000333300669999006699 + 9900336666003366660033666600CCCCCC006699990000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000099CCFF0099CCFF003366990099CCFF00669933006699FF00CC009900CC33 + 9900CC3399000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000003366000000000033669900000000000033660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000033003333 + FF000033CC00000000000000330000003300000000000033CC003333FF000033 + CC00000033000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000022222200DDDDDD00AAAAAA007777770077777700000000000000 + 000000000000AAAAAA00DDDDDD0077777700DDDDDD0077777700222222000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000099CCCC0099CCCC006699990033666600336666000000 + 00006699CC0099CCFF00996633009966330099CCFF006699CC000033330099CC + CC0099CCCC006699990033666600336666003366660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000099CCFF00000000000000330099CCFF006699FF0066006600CC00 + 9900000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000222222000000 + 0000000000003399FF0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 330000003300000033000000330099CCFF006699CC0000003300000033000000 + 3300000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000002222220022222200222222002222220044444400AAAA + AA00777777002222220022222200222222002222220022222200000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000CCFFFF0099CCCC0066999900336666000000 + 0000000000000000000000000000336699006699CC0000000000000000000033 + 3300CCFFFF0099CCCC0066999900000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000CC00990000000000000033006699FF0066006600CC00 + 9900000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000222222002222 + 2200666666000000000000336600000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000006699CC0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000033 + 66006699CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000996633006699CC006699CC003366990000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000CC009900CC009900000000003366990099CCFF006699FF0066006600CC00 + 9900000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000022222200999999006666 + 6600222222000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000033003366990099CCFF006699CC0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000336699006699 + CC006699CC000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000006633000099CCFF006699CC00336699006699CC00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000CC0099000000000099CCFF0099CCFF0066006600CC009900CC00 + 9900000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000022222200DDDDDD009999 + 9900222222002222220000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000330099CCFF0099CCFF006699CC0099CCFF00003333000000 + 0000000000000033330000333300000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000099CCFF0099CC + FF006699CC006699CC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000099CCFF006699CC0099CCFF006699CC0000336600000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000006699CC000033660066006600CC0099000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000002222220099999900222222002222 + 2200000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000033006699CC000033660099CCFF0033666600003333000000 + 0000003333003366660000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000003300003366000033 + 66006699CC003366660000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000336600000000000033660099CCFF006699CC00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000006600660066006600FF33CC00CC0099000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000002222220022222200000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000002222220022222200222222002222220022222200222222000033 + 33003399CC003366660000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000330099CCFF0099CC + FF00333366000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000009966330099CCFF0099CCFF006699CC006699CC00000000000000 + 0000000000006633330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000CC009900CC009900CC009900FF33CC000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000033666600CCFFFF0066CCFF0066CCFF003399CC000033330066CC + FF00336666000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000333366003333 + 6600000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000CC99660099CCFF006699CC0000336600663333000000 + 0000663333000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000033666600336666003366660033666600000000003366 + 6600336666000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000006666FF004848 + FF002525FF002525FF002525FF002525FF002525FF000000DC000000DC000000 + 96000000960000000000D4FFFF00000000000000000000000000000000000000 + 0000D4FFFF00D4FFFF00D4FFFF00000000002525FF006B6BFF006B6BFF004848 + FF004848FF000000FF002525FF002525FF000000000000000000000000000000 + 0000000000000000000000000000000000009999FF009999FF00000000000000 + 000000000000000000006666FF006666FF006666FF006666FF006666FF000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000009999FF00000000000000000000000000000000000000 + 000000000000000000000000000000000000FFCC9900FFCC9900FFCC9900FFCC + 99000000000000000000FF663300FF663300FF663300FF663300FF6633000000 + 00000000000000000000000000000000000000000000FFCC9900000000000000 + 00000000000000000000FFCC9900000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000006666FF004848 + FF002525FF002525FF002525FF002525FF002525FF002525FF000000DC000000 + DC000000960000009600000000005B5BFF000000FF000000FF000000B9000000 + B900000000000000000000000000000000004848FF008E8EFF006B6BFF006B6B + FF006B6BFF004848FF002525FF002525FF009999FF0000000000000000000000 + 000000000000000000009999FF009999FF00CCCCFF00CCCCFF009999FF000000 + 00006666FF006666FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF006666 + FF006666FF00000000009999FF000000000000000000000000009999FF009999 + FF009999FF009999FF0000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000FFCC9900FFFFFF00FFCC9900FFFF + FF00FF663300FF663300FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FF66 + 3300FF6633000000000000000000000000000000000000000000000000000000 + 000000000000FFCC990000000000000000000000000000000000000000000000 + 0000000000000000000000000000006699000033660000669900000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000003366000033660000336600006699000000000000000000000000000000 + 00003300330000000000000000000000000000000000000000008E8EFF006666 + FF004848FF004848FF002525FF002525FF002525FF002525FF002525FF000000 + DC0000009600000000000000000000000000000000005B5BFF000000FF000000 + FF002525FF000000B9000000B900000000004848FF004848FF008E8EFF008E8E + FF006B6BFF006B6BFF004848FF002525FF00000000009999FF009999FF000000 + 000000000000000000009999FF00CCCCFF00FFFFFF00CCCCFF00CCCCFF00CCCC + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF006666FF0000000000000000009999FF009999FF00CCCCFF00FFFF + FF00CCCCFF009999FF0000000000000000000000000000000000000000000000 + 00000000000000000000FFCC9900FFCC9900FFCC9900FFFFFF00FFFFFF00FFCC + CC00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FF6633000000000000000000FFCC99000000000000000000FFCC + 9900FFCC99000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000006699000066990000669900000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000006699000066990000000000000000000000000000000000000000000066 + 9900330033000000000000000000000000000000000000000000000000000000 + 0000000000004848FF004848FF004848FF002525FF002525FF002525FF002525 + FF0000000000FFFFFF00CECECE00FFFFFF00FFFFFF0000000000000000005B5B + FF002525FF002525FF000000B9000000B900000000004848FF004848FF004848 + FF008E8EFF006B6BFF006B6BFF006B6BFF00000000009999FF00CCCCFF009999 + FF009999FF009999FF009999FF00CCCCFF00FFFFFF00FFFFFF00CCCCFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF006666FF00000000009999FF00FFFFFF00FFFFFF00CCCC + FF009999FF000000000000000000000000000000000000000000000000000000 + 000000000000FFCC9900FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFCCCC00FFFF + FF00FFFFFF00FFFFFF00FFFFFF009900000099000000CC999900FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FF6633000000000000000000FFCC9900FFCC9900FFCC + CC00FFCC99000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000CCFF0000CCFF000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000CCFF000000000000000000000000000000000000000000006699003300 + 330000000000000000000000000000000000000000000000000000000000B3D7 + D700B3D7D700000000002525FF004848FF004848FF004848FF004848FF004848 + FF000000000000007300000000000000000000000000FFFFFF00FFFFFF000000 + 0000000000005B5BFF002525FF000000B9000000000000000000000000000000 + FF004848FF008E8EFF008E8EFF004848FF00000000009999FF00CCCCFF00CCCC + FF00CCCCFF00CCCCFF00CCCCFF00FFFFFF00FFFFFF00CCCCFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF009966CC000000DD000000EE000066FF003366FF00CCCC + FF00FFFFFF00FFFFFF00FFFFFF006666FF00FFFFFF00FFFFFF00CCCCFF009999 + FF00000000000000000000000000000000000000000000000000000000000000 + 000000000000FFCC9900FFFFFF00FFFFFF00FFFFFF00FFCCCC00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFCC9900FF993300CC33330099000000FF333300FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFCC00FFCC9900FFCCCC00FFFFFF00FFCC + 9900000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000099FF000099 + FF00000000000000000000000000000000000000000000000000000000000000 + 00000099FF000000000000000000000000000000000000669900330033000000 + 0000000000000000000000000000000000000000000000000000D4FFFF00D4FF + FF00B3D7D700000000007575FF006666FF006666FF005757FF005757FF000000 + 0000000073000000B9000000B900000000000000FF000000000000000000FFFF + FF00FFFFFF00000000002525FF000000B90000000000C0C0C000C0C0C0000000 + 0000000000002525FF004848FF004848FF0000000000000000009999FF009999 + FF00CCCCFF00CCCCFF00CCCCFF00FFFFFF00FFFFFF00CCCCFF00FFFFFF00FFFF + FF0099CCFF000066FF000000BB000000BB000000BB000066FF000066FF000066 + FF00EEEEEE00FFFFFF00FFFFFF006666FF00FFFFFF00CCCCFF00CCCCFF00CCCC + FF009999FF000000000000000000000000000000000000000000FFCC99000000 + 00000000000000000000FFCC9900FFCC9900FFFFFF00FFCCCC00FFFFFF00FFFF + FF00FFFFFF00FFCC9900FFFFFF00FFFFFF00FFCCCC00FFFFFF00FF333300FF33 + 3300FFFFFF00FFFFFF00FFFFFF00FFFFCC00FFFFFF00FFFFFF00FFCC99000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000099 + FF00000000000000000000000000000000000000000000000000000000000000 + 00000099FF000000000000000000000000000066990033003300000000000000 + 0000000000000000000000000000000000000000000000000000D4FFFF000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 73000000B9000000B9000000730000007300000000000000FF000000FF000000 + 0000FFFFFF00000000002525FF000000B90000000000D4FFFF00D4FFFF00C0C0 + C000C0C0C000000000004848FF002525FF000000000000000000000000000000 + 00009999FF00CCCCFF00CCCCFF00CCCCFF00CCCCFF00FFFFFF00FFFFFF00EEEE + EE000066FF000066FF000033FF000000BB000000EE000000EE000066FF000066 + FF003366FF00FFFFFF00FFFFFF00CCCCFF00CCCCFF00CCCCFF00FFFFFF00FFFF + FF009999FF009999FF0000000000000000000000000000000000000000000000 + 0000FFCC9900000000000000000000000000FFCCCC00FFFFFF00FFFFFF00FFFF + FF00FFFFCC00FFFFFF00FFFFFF00FFCCCC00FF996600FF336600FF996600FFCC + 9900FFFFCC00FFFFFF00FFFFFF00FFFFFF00FFFFCC00FFCCCC00FFCC9900FFCC + 9900FFCC9900FFCC990000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000000000CC + FF0000CCFF000000000000000000000000000000000000000000000000000000 + 000000CCFF0000CCFF0000000000006699003300330000000000000000000000 + 00000000000000000000000000000000000000000000F0FBFF00000000000000 + 0000000000000000000000000000000000000000000000000000FFFFFF000000 + 00000000B900000073000000730000007300000000000000FF000000FF000000 + FF0000000000000000002525FF000000B9000000B90000000000F0FBFF000000 + 0000000000004848FF004848FF002525FF000000000000000000000000009999 + FF009999FF00CCCCFF00CCCCFF00CCCCFF00CCCCFF00CCCCFF00FFFFFF006699 + FF000066FF000033FF000033FF000000BB000000BB000000BB000000FF000066 + FF000066FF0099CCFF00FFFFFF00CCCCFF00CCCCFF00CCCCFF00FFFFFF00CCCC + FF00FFFFFF009999FF0000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000FF663300FFFFFF00FFFFFF00FFFF + CC00FFFFFF00FFFFCC00FFFFFF00FFFFFF00FFCCCC00FFCCCC00FF999900FF99 + 9900FFCC9900FFFFFF00FFFFFF00FFFFFF00FFFFCC00FFFFFF00FFCCCC00FFCC + CC00FFCCCC00FFCCCC00FFCC9900000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000066 + 9900006699000066990000000000000000000000000000000000000000000066 + 9900006699003300330000669900330033000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000FFFFFF00FFFFFF000000 + 00000000000000000000000000000000730000000000000000000000FF000000 + FF00000000006B6BFF002424EB000000B9000000B90000000000000000002525 + FF004848FF004848FF002525FF002525FF000000000000000000000000009999 + FF00FFFFFF00FFFFFF00CCCCFF00CCCCFF00FFFFFF00CCCCFF00FFFFFF000066 + FF000066FF000033FF000033FF000033FF000033FF000000EE000000EE000033 + FF000066FF000066FF00EEEEEE00CCCCFF00CCCCFF00CCCCFF00CCCCFF00FFFF + FF00FFFFFF009999FF000000000000000000FFCC9900FFCC9900FFCC9900FFCC + 9900FFCC9900FFCC9900FFCC9900FF663300FFFFFF00FFFFFF00FFFFFF00FF99 + 6600FFCC9900FFFFFF00FFFFCC00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFCCCC00FFFFFF00FFFFFF00FFFFFF00FFFFCC00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFCC9900000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00006699FF006699FF006699FF00000000000000000000000000000000006699 + FF00330033000066990033003300000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000FFFFFF00FFFFFF00CECE + CE00FFFFFF00CECECE00FFFFFF000000000000000000FFFFFF00000000000000 + 00006B6BFF002525FF002424EB000000B90000000000000096000000B9004848 + FF004848FF0000009600000096004848FF0000000000000000009999FF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000033 + FF000066FF000033FF000033FF000000990000007700000099000000EE000000 + EE000066FF000033FF006699FF00FFFFFF00CCCCFF00CCCCFF00FFFFFF009999 + FF009999FF009999FF000000000000000000FFCC9900FFCC9900FFCCCC00FFFF + CC00FFFFCC00FFCCCC00FFCCCC00FFCCCC00FFFFFF00FFFFFF00FFFFFF00FF66 + 0000FF660000FF996600FF999900FFFFFF00FFFFFF00FFFFFF00FF999900FF99 + 9900FF333300FF660000FFFFFF00FFFFFF00FFFFFF00FFFFCC00FFCCCC00FFCC + 9900FFCC9900FFCCCC00FFFFFF00FFCC99000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000006699FF006699FF00000000000000000000000000000000003300 + 3300006699006600330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000C0C0C00000000000000000000000 + 00000000000000000000FFFFFF00CECECE00FFFFFF00FFFFFF00000000000000 + 00000000FF002424EB000000B9000000B90000000000000096000000B9002525 + FF0000009600000096004848FF004848FF0000000000000000009999FF009999 + FF00FFFFFF00FFFFFF00FFFFFF00CCCCFF00FFFFFF00FFFFFF009999CC000033 + FF000033FF000033FF0000009900000077000000770000339900000099000000 + EE000066FF000066FF000066FF00FFFFFF00FFFFFF00FFFFFF006666FF000000 + 000000000000000000009999FF00000000000000000000000000FFCC9900FFCC + CC00FFFFCC00FFFFCC00FFFFCC00FFFFCC00FFFFFF00FFFFFF00FFCC9900FF66 + 0000FF660000FF663300FF336600FF336600CC00000099000000CC000000CC33 + 3300FF336600FF333300FFCC9900FFFFFF00FFFFFF00FFFFFF00FF6633000000 + 000000000000FFCC9900FFCC9900FFCC99000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000006699FF006699FF006699FF000000000000000000330033000066 + 9900660033006666990066669900000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000004949FF004949FF002222 + EA001F1FD5004949FF000000000000000000FFFFFF00FFFFFF00000000004949 + FF002424EB002222D7000000B9000000000000009600000096000000B9000000 + B900000096004848FF004848FF002525FF00000000009999FF00000000000000 + 00009999FF006666FF006666FF00FFFFFF00FFFFFF00FFFFFF006633CC000033 + FF000033FF000000DD0000007700000077000000660000007700003399000000 + DD000033FF000066FF000066FF00FFFFFF00FFFFFF00FFFFFF006666FF000000 + 000000000000000000000000000000000000000000000000000000000000FFCC + 9900FFCC9900FFFFCC00FFFFCC00FFFFFF00FFCCCC00FFFFFF00FFFFFF00FF66 + 0000FF660000FF333300FF336600FF336600CC0000009900000099000000CC00 + 0000FF336600FF336600FF996600FFFFFF00FFFFFF00FFFFFF00FF6633000000 + 0000000000000000000000000000FFCC99000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000666699006666990066669900330033006699CC001100 + 000000CCFF0000CCFF0000CCFF00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000006B6BFF002222D7002222D7002525FF002525FF002222 + EA001F1FD5002525FF002525FF004949FF000000000000000000000000004949 + FF002222D7002020C3000000B900000000000000960000009600000096000000 + 9600000096004848FF004848FF00000096000000000000000000000000000000 + 000000000000000000006666FF00FFFFFF00FFFFFF00FFFFFF006633CC000033 + FF000033FF000000990000007700000066000000550000006600000077000000 + 99000000EE000033FF000066FF00FFFFFF00FFFFFF00FFFFFF006666FF000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000FFCC9900FFCCCC00FFFFCC00FFFFFF00FFCCCC00FFFFFF00FFFFCC00FFCC + 9900FF660000FF333300FF336600FF336600CC0000009900000099000000CC00 + 0000CC333300FF336600FF666600FFFFFF00FFFFFF00FFFFFF00FF6633000000 + 000000000000FFCC990000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000CCFF000099990000CCFF00330033006699CC006600330000CC + FF00110000001100000011000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000C0C0 + C000C0C0C000000000006B6BFF002525FF002222D7002222D7002525FF002222 + EA001F1FD5002525FF002525FF002222D7001C1CC0002222D7004949FF002222 + D7002222D7002222D7000000B900000000000000960000009600000096000000 + 96000000B9000000960000009600000096000000000000000000000000000000 + 000000000000000000006666FF00FFFFFF00FFFFFF00FFFFFF000000DD000033 + FF000033FF000000990000006600000055000000440000005500000066000000 + 99000000EE000000EE000000DD00FFFFFF00FFFFFF00FFFFFF006666FF009999 + FF00000000000000000000000000000000000000000000000000000000000000 + 0000FFCC9900FFCCCC00FF663300FFCCCC00FFCCCC00FFFFFF00FFFFFF00FFFF + FF00FFCC9900FF336600FF336600FF336600CC000000CC000000990000009900 + 0000CC000000FF336600FF336600FFFFFF00FFFFFF00FFFFFF00FF6633000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000110000001100000033003300006699006600330000CCFF000033 + 6600110000001100000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000C0C0C000D4FFFF00B3D7 + D700D4FFFF00000000006B6BFF002424EB002525FF0010106B0010106B002525 + FF0010106B0010106B001C1CC0001C1CC0002222D7002525FF002424EB002222 + D7002222D7002424EB000000B900000000000000000000000000000000000000 + 960000009600000096000000B9002525FF000000000000000000000000000000 + 00009999FF009999FF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000066FF000000 + BB000033FF000000770000339900000055000000440000005500000066000000 + 77000000EE000000EE000000EE00FFFFFF00FFFFFF00FFFFFF006666FF000000 + 000000000000000000000000000000000000FFCC990000000000FFCC9900FFCC + 9900FFCCCC00FFCCCC00FF663300FFCCCC00FFCCCC00FFFFFF00FFCC9900FFFF + FF00FF999900FF669900FF336600FF336600CC000000CC000000990000009900 + 0000CC000000FF336600FF336600FFFFFF00FFFFFF00FFFFFF00FF6633000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000066990066003300110000000066990000CC + FF00006699001100000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000F0FBFF00000000000000 + 0000F0FBFF00000000002424EB001F1FD5006D6DFF001C1CC000000000002525 + FF000000000010106B002222D7002424EB002525FF002525FF002424EB002222 + D7002424EB000000000000000000C0C0C000C0C0C000C0C0C000C0C0C0000000 + 00000000000000009600000096000000B90000000000000000009999FF000000 + 00009999FF00FFFFFF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000066FF000066 + FF000066FF000033990000006600000055000000440000005500000066000000 + 77000000EE000000EE000000EE00FFFFFF00FFFFFF00FFFFFF006666FF000000 + 000000000000000000000000000000000000000000000000000000000000FFCC + 9900FFCCCC00FFCCCC00FF663300FFCCCC00FFCCCC00FFFFFF00FF660000FF99 + 6600FFFFFF00FF999900FF999900FF336600CC000000CC000000990000009900 + 0000CC000000FF336600FF333300FFFFFF00FFFFFF00FFFFFF00FF6633000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000669900660033000099990011000000110000000000 + 000000CCFF000066990000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000002424EB001C1CC0001C1CC0001C1CC0006D6DFF00131380002525 + FF00131380002525FF001F1FD5001C1CC0001C1CC0001F1FD5002222EA002424 + EB0000000000D4FFFF00D4FFFF00C0C0C000D4FFFF00D4FFFF00C0C0C000C0C0 + C000C0C0C0000000000000009600000096000000000000000000000000009999 + FF00FFFFFF00FFFFFF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000066FF000066 + FF000066FF000066FF000033CC00000055000000440000005500000066000000 + 77000000EE000000EE000000EE00FFFFFF00FFFFFF00FFFFFF00CCCCFF009999 + FF0000000000000000000000000000000000000000000000000000000000FFCC + 9900FFCCCC00FFCCCC00FF663300FFCCCC00EEEEEE00FFFFFF00FF660000CC00 + 0000CC000000FF999900CC000000FF999900FF33660099000000990000009900 + 0000CC000000FF336600FF333300FFFFFF00FFFFFF00FFFFFF00FF663300FFCC + 9900000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000066990066003300000000006633330066333300110000001100 + 00000000000000CCFF0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000001C1CC0000000000000000000000000006D6DFF006D6DFF006D6D + FF004949FF001F1FD5000000000000000000000000001C1CC0001F1FD5000000 + FF0000000000D4FFFF00D4FFFF00C4EBEB00D4FFFF00C4EBEB00D4FFFF00D4FF + FF00C0C0C000C0C0C00000000000000096000000000000000000000000009999 + FF00CCCCFF00CCCCFF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000066FF000066 + FF000066FF000066FF0000006600000055000000440000005500000077000000 + 99000000EE000000EE000033FF00FFFFFF00FFFFFF00FFFFFF00CCCCFF009999 + FF0000000000000000000000000000000000000000000000000000000000FFCC + 9900FFCCCC00FFCCCC00FF663300FFCCCC00EEEEEE00FFFFFF00FF660000FF66 + 3300FF33660099000000FF9999009900000099000000FF33660099000000CC00 + 0000CC333300FF336600FF663300FFFFFF00FFFFFF00FFFFFF00FF999900FFFF + CC00FFCC99000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000006699006600330000000000000000006699FF006699FF006699FF00CCCC + FF00000000000000000000669900006699000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00001F1FD5000000000000EAEA000095FF0000D5D500000000006D6DFF006D6D + FF004949FF000000000000D5D50000D5D50000D5D500000000001F1FD5000000 + 0000D4FFFF00C0C0C00000000000000000000000000000000000F0FBFF00C4EB + EB00D4FFFF00C0C0C00000000000000096000000000000000000000000000000 + 00009999FF00FFFFFF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000066FF000066 + FF000066FF000033CC0000339900000066000000550000006600000077000000 + 99000000EE000033FF000066FF00FFFFFF00FFFFFF00FFFFFF00CCCCFF00CCCC + FF009999FF000000000000000000000000000000000000000000FFCC9900FFCC + CC00FFCCCC00FFCCCC00FF663300FFCCCC00EEEEEE00FFFFFF00FF660000FF66 + 3300CC333300CC33000099000000990000009900000099000000CC000000CC33 + 3300FF336600FF336600FF999900FFFFFF00FFFFFF00FFFFFF00FF999900FFFF + CC00FFCC990000000000FFCC9900000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000066 + 9900660033000000000000000000000000006699FF00666699006699FF006699 + FF00000000000000000000000000669900000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000002525 + FF0000000000D4FFFF0000FFFF000E0E0E000095FF000000000010106B001010 + 6B0000000000D4FFFF0000EAEA000095FF0000D5D50000D5D500000000000000 + 0000D4FFFF0000000000000096002525FF002525FF002525FF0000000000D4FF + FF00D4FFFF00C0C0C000C0C0C00000000000000000009999FF009999FF009999 + FF00FFFFFF00CCCCFF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000066FF000066 + FF000033FF000000DD0000007700000077000000660000007700000077000000 + DD000000EE000033FF000066FF00FFFFFF00FFFFFF00FFFFFF00CCCCFF00CCCC + FF009999FF0000000000000000000000000000000000FFCC9900FFCCCC00FFCC + CC00FFCCCC00FFCCCC00FF663300FFCCCC00FFFFFF00FFFFFF00FF996600FF66 + 3300FF336600FF333300CC333300990000009900000099000000CC000000FF33 + 6600FF336600FF333300FF996600FFFFFF00FFFFFF00FFFFFF00FF999900FFFF + CC00FFCCCC00FFCC990000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000006699003300 + 330066990000000000000000000000000000333300006699FF00333300003333 + 0000669900000000000000000000669900000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000FF002525 + FF0000000000F0FBFF00D4FFFF00D4FFFF00000000001313800010106B001313 + 800000000000F0FBFF0000FFFF000E0E0E000095FF0000D5D500000000000000 + 0000D4FFFF0000000000000096002525FF002525FF002525FF0000000000F0FB + FF00C4EBEB00D4FFFF00C0C0C0000000000000000000000000009999FF00CCCC + FF00CCCCFF00CCCCFF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000066FF000066 + FF000033FF000033FF0000009900000077000000770000007700000099000000 + EE000033FF000066FF003333CC00FFFFFF00FFFFFF00FFFFFF00CCCCFF00CCCC + FF00CCCCFF009999FF009999FF0000000000FFCC9900FFCCCC00FFCCCC00FFCC + CC00FFCCCC00FFCCCC00FF663300FFCCCC00FFFFFF00FFFFFF00FF996600FF33 + 3300FF336600FF336600FF336600CC33330099000000CC000000CC333300FF33 + 6600FF336600FF999900FF999900FFFFFF00FFFFFF00FFFFFF00FF999900FFFF + CC00FFFFCC00FFCCCC00FFCC9900000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000669900330033000000 + 000066990000669900000000000066CC0000669900003333000066CC00006699 + 0000669900003333000066990000669900000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000006D6DFF000000 + 0000000000000000000000000000000000001F1FD5002222D700131380001F1F + D5001F1FD50000000000F0FBFF0000FFFF0000EAEA0000D5D500000000001F1F + D500000000000000000000000000000096002525FF002525FF00000000000000 + 0000D4FFFF00D4FFFF00C0C0C000000000000000000000000000000000009999 + FF00FFFFFF00FFFFFF00FFFFFF00CCCCFF00FFFFFF00FFFFFF009999CC000033 + FF000033FF000033FF000033FF000000990000007700000099000000EE000000 + EE000000EE000033FF009999CC00FFFFFF00FFFFFF00CCCCFF00CCCCFF00FFFF + FF00CCCCFF00CCCCFF009999FF009999FF0000000000FFCC9900FFCC9900FFCC + 9900FFCCCC00FFCCCC00FFCCCC00FF663300FFCCCC00FFFFFF00FFCC9900FF66 + 3300FF336600FF336600FF333300FF33330099000000CC000000FF336600FF33 + 6600FF333300FF993300FFCCCC00FFFFFF00FFFFFF00FF999900FFFFCC00FFFF + CC00FFCCCC00FFCC990000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000066990033003300000000000000 + 000000000000669900000000000099CC330066CC00006699000099CC330066CC + 0000333300003333000066990000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000006D6DFF004848 + FF001F1FD5001F1FD5001F1FD5001F1FD5002525FF002222D700131380002525 + FF002525FF001F1FD50000000000F0FBFF00D4FFFF00D4FFFF00000000000000 + 00001F1FD5001F1FD500000000000000000000000000000000002222EA000000 + 0000C4EBEB00C0C0C000C0C0C000000000000000000000000000000000000000 + 00009999FF009999FF009999FF00CCCCFF00FFFFFF00FFFFFF00FFFFFF000033 + FF000033FF000033FF000000EE000000CC000000BB000000CC000000DD000000 + EE000000EE000000EE00FFFFFF00FFFFFF00FFFFFF00CCCCFF00FFFFFF00FFFF + FF00CCCCFF00CCCCFF009999FF00000000000000000000000000000000000000 + 0000FFCC9900FFCCCC00FFCCCC00FF663300FFCCCC00EEEEEE00FFFFFF00FF66 + 0000FF336600FF336600FF336600FF33330099000000CC000000FF336600FF99 + 9900FF993300FFCCCC00FFFFFF00FFFFFF00FFFFFF00FF999900FFFFCC00FFCC + CC00FFCC990000000000FFCC9900000000000000000000000000000000000000 + 0000000000000000000000000000006699003300330000000000000000000000 + 6600000066000000000033330000333300006699000099CC3300669900003333 + 00006699000066CC000033330000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000008E8EFF004848 + FF004848FF004848FF002525FF002525FF002525FF001C1CC000000000002525 + FF004848FF004848FF001F1FD500000000000000000000000000000000000000 + 00001F1FD5001F1FD50000000000000096002222EA002222EA002222EA000000 + 0000D4FFFF00D4FFFF00C0C0C000000000000000000000000000000000000000 + 00000000000000000000000000006666FF00FFFFFF00FFFFFF00FFFFFF006633 + CC000033FF000000DD000000CC000000BB000000BB000000BB000000BB000000 + BB000000EE006633CC00FFFFFF00FFFFFF00FFFFFF006666FF00FFFFFF00FFFF + FF00CCCCFF00CCCCFF009999FF00000000000000000000000000FFCC9900FFCC + 9900FFFFFF00FFCC9900FFCCCC00FF663300FFCCCC00FFCCCC00FFFFFF00FF99 + 6600FF663300FF663300FF336600FF336600CC000000FF336600FF336600FF33 + 3300FFCCCC00FFCCCC00FFFFFF00FFFFFF00FFFFFF00FFCCCC00FFFFCC00FFCC + 9900000000000000000000000000FFCC99000000000000000000000000000000 + 0000000000000000000000669900330033000000330000000000000066000000 + 6600000066000000000066990000669900003333000066336600663366000000 + 0000669900006699000066CC0000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000008E8E + FF006B6BFF004848FF004848FF004848FF0000000000000000002222D7000000 + 00008E8EFF004848FF004848FF002222EA002222EA002222EA002222EA002222 + EA002222EA001F1FD5000000000000000000000000000000000000000000C0C0 + C000C4EBEB00D4FFFF00C0C0C000000000000000000000000000000000000000 + 0000000000000000000000000000000000006666FF00FFFFFF00FFFFFF00DDDD + DD000000EE000000BB000000BB000000BB000000BB000000BB000000BB000000 + CC000000EE00DDDDDD00FFFFFF00FFFFFF006666FF00000000009999FF009999 + FF009999FF00CCCCFF00CCCCFF009999FF000000000000000000000000000000 + 0000FFCC9900FFCC9900FFCCCC00FFCCCC00FF663300FFCCCC00FFCCCC00EEEE + EE00FF663300FF663300FF336600FF333300CC333300FF336600FF336600FF99 + 9900FFCCCC00EEEEEE00FFFFFF00FFFFFF00FFCCCC00FFFFCC00FFCCCC00FFCC + 9900000000000000000000000000000000000000000000000000000000000000 + 0000000000000066990033003300000033000000000000006600000066000000 + 66000000660000000000669900006699000000000000000033006699FF006699 + FF00000033000000330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000002222D70000000000000000000000 + 0000000000008E8EFF004848FF004848FF004848FF004848FF004848FF004848 + FF004848FF001F1FD5000000000000000000C0C0C000C0C0C000C0C0C000C4EB + EB00B3D7D700C4EBEB0000000000D4FFFF000000000000000000000000000000 + 0000000000000000000000000000000000006666FF00FFFFFF00FFFFFF00FFFF + FF009966CC000000EE000000CC000000BB000000BB000000BB000000BB000000 + EE009966CC00FFFFFF00FFFFFF00FFFFFF006666FF0000000000000000000000 + 0000000000009999FF00CCCCFF009999FF00000000000000000000000000FFCC + 99000000000000000000FFCC9900FFCCCC00FF663300FFCCCC00FFCCCC00EEEE + EE00FFCC9900FF663300FF663300FF336600FF336600FF336600FF660000FF66 + 0000FFCCCC00EEEEEE00FFFFFF00FFFFFF00FFCCCC00FFFFCC00FFCC99000000 + 0000FFCC99000000000000000000000000000000000000000000000000000000 + 0000003366003300330000000000000000000000000000006600000066000000 + 6600000066000000000000000000000000000000660000000000000033006699 + FF00000033000000660000003300000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000C0C0C000C0C0C0000000 + 00002525FF000000000000000000000000006D6DFF006B6BFF004848FF004848 + FF004848FF00000000000000000000000000D4FFFF00D4FFFF00D4FFFF00D4FF + FF00D4FFFF00C0C0C00000000000D4FFFF000000000000000000000000000000 + 00000000000000000000000000009999FF00000000006666FF00FFFFFF00FFFF + FF00FFFFFF006633CC000000EE000000DD000000BB000000BB000000DD006633 + CC00FFFFFF00FFFFFF00FFFFFF006666FF000000000000000000000000000000 + 000000000000000000009999FF009999FF000000000000000000000000000000 + 00000000000000000000FFCC9900FFCCCC00FFCCCC00FF663300FFCCCC00FFCC + CC00FFFFFF00FF996600FF660000FF663300FF336600FF663300FF660000FF99 + 6600FFFFFF00FFFFFF00FFFFFF00FFCCCC00FFFFCC00FFCCCC00FFCC99000000 + 0000000000000000000000000000000000000000000000000000000000000033 + 6600330033000000000000000000000000000000000000000000000000000000 + 000000006600000066000000660000006600000000003366990099CCFF006699 + FF00000033000000660000003300000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000D4FFFF00C0C0C0000000 + 00002525FF002525FF00000000002525FF000000000000000000000000000000 + 000000000000000000002525FF0000000000F0FBFF00F0FBFF00F0FBFF00F0FB + FF00000000000000000000000000D4FFFF000000000000000000000000000000 + 00000000000000000000CCCCFF0000000000000000006666FF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF009966CC000000DD000000EE000000DD009966CC00FFFF + FF00FFFFFF00FFFFFF00FFFFFF006666FF009999FF009999FF00000000000000 + 00000000000000000000000000009999FF000000000000000000000000000000 + 0000000000000000000000000000FFCC9900FFFFCC00FF663300FFCCCC00FFCC + CC00FFCCCC00FFFFFF00FFCC9900FF660000FF660000FF660000FFCC9900FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFCCCC00FFFFCC00FFCC9900000000000000 + 0000000000000000000000000000000000000000000000669900003366003300 + 3300000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000006600000066000000000099CCFF0099CCFF006699 + FF0099CCFF000000660000003300000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000F0FBFF00D4FFFF000000 + 00000000000000000000000000000000000000000000000000002525FF002525 + FF002525FF002525FF0000000000000000000000000000000000000000000000 + 0000000000000000000000000000D4FFFF000000000000000000000000000000 + 000000000000CCCCFF0000000000000000009999FF00000000006666FF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF006666FF00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000FFCC9900FFFFCC00FFFFCC00FF663300FFCC + CC00FFCCCC00EEEEEE00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FF999900FFFFCC00FFCCCC00FFCC9900000000000000 + 0000000000000000000000000000000000000000000000999900006699003300 + 3300000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000006600000000006699CC000033660099CC + FF00000033000000330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000F0FBFF000000 + 000000000000000000000000000000000000D4FFFF00C0C0C000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000CCCCFF000000000000000000000000006666 + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF006666FF00000000009999FF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000FFCC9900FFCC9900FFCC9900FFCC9900FF66 + 3300FFCCCC00FFCCCC00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FF999900FFCC9900FFCC9900FFFFCC00FFCC9900000000000000 + 0000FFCC99000000000000000000000000000000000033003300330033000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000033009999CC00000033000000 + 33000099FF000000330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000D4FFFF00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000009999FF000000 + 00006666FF006666FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF006666 + FF006666FF00000000000000000000000000CCCCFF0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000FFCC9900FFCC9900FFCC9900000000000000000000000000000000000000 + 0000FF663300FF663300FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FF66 + 3300FF663300000000000000000000000000FFCC9900FFCC9900FFCC9900FFCC + 990000000000FFCC990000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000003300000033009999CC000000 + 33000099FF000000330000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000006666FF006666FF006666FF006666FF006666FF000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000FF663300FF663300FF663300FF663300FF6633000000 + 000000000000000000000000000000000000000000000000000000000000FFCC + 9900000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000003300000033000000 + 3300000033000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000424D3E000000000000003E000000 + 2800000080000000A00000000100010000000000000A00000000000000000000 + 000000000000000000000000FFFFFF00FD280002000000000000000000000000 + FFFE000F000000000000000000000000FFFF020F000000000000000000000000 + FFFFC30F000000000000000000000000F3FFC30F000000000000000000000000 + F1FFE38F000000000000000000000000F8FFE38F000000000000000000000000 + FC7FC107000000000000000000000000FE3FC107000000000000000000000000 + FF1FC107000000000000000000000000FF8FC00F000000000000000000000000 + FFC4C007000000000000000000000000FFE1E003000000000000000000000000 + FFF0E003000000000000000000000000FFF06003000000000000000000000000 + FFE06003000000000000000000000000FFEC2001000000000000000000000000 + FFFE0000000000000000000000000000FFFF0000000000000000000000000000 + FFFF8010000000000000000000000000FFFF8001000000000000000000000000 + FFFF8001000000000000000000000000FFFFC003000000000000000000000000 + FFFFC003000000000000000000000000FFFF8001000000000000000000000000 + FFFF043F000000000000000000000000FFFFF83F000000000000000000000000 + FFFFF81F000000000000000000000000FFFFF81F000000000000000000000000 + FFFFF81F000000000000000000000000FFFFF81F000000000000000000000000 + FFFFFC3F000000000000000000000000F2004057408028DFFB940002FFA00205 + FFC0E0FFE080FFFFFFFF801FFFFC060FFFE0F0FFE081FFFFFFFFC01FFFFE060F + FFF8F1FFE187FFFFFFFFF03FFFFF861FFFF8F1FFF0C7FFFFFFFFF83FFFFFC63F + FFF060FFF0C3FFFFFFFFF83FFFFFC63CFFF061FFF0C3FFFFFFFFF01FFFFF8438 + FFE0407FE040E1FFFFFFF03FFFFF8431FFE0007FE02081FFFFFFF003FFFF8423 + FFE0007FE82001FFFFFFE003FFFF8047FFE0007FF84003FFFFFFF003FFFF800F + FFE0007FF802040FFFFFE003FFFF001FFFF000FFF8020807FFFFE003FFFF003F + FFF000FFF8060801FFFFE003FFFF003FFFF000FFF8000801FFFFE003FFFF000F + FFE000FFF8000801FFFFE003FFFF808FFFC0007FFC000861FFFFF003FFFF80C7 + FFC0001FF8000861FFFFF003FFFFC047FFC0001FF0000061FFFFC003FFF38047 + FFC0001FE0000023FFFF8003EFF00007FFE0003FE0000007FFFF8003DFE0000F + FFE0003FE0000003FFFFC0039FE4000FFFF0007FC0000003FFFFC0039FE0000F + FFF0007FC0000403FFFFC0071FE1000FFFF8007FE0000803FFFF80031FE3803F + FFFC00FFFC3C1803FFFFFC0F0FC7F03FFFFE01FFFC1FFF07FFFFF80F0F8FE03F + FFFE07FFF81FFF03FFFFF80F861FE03FFFFC03FFF01FFF81FFFFF80F803FE03F + FFFC03FFF01FFF80FFFFF80FC03FE07FFFFE07FFF01FFF80FFFFF81FE07FF07F + FFFF0FFFF83FFFF0FFFFFC3FF8FFF8FF00000002E9400012D00A01012000805F + C001000FFFE0007FFC9F0107FC07E0FFE001800FFFE0007FFEDF0107FE07E0FF + E003E10FFFC6007FFEDF418FFF87E1FFFC07E10FFFC6007FFEDE418FFF87E3FF + FC07F18FFFC4007FFE4C810FFFC7E3FFFE0FF18FFFC4007FFE40010FFFC3C3FF + F803E107FF8C007FFE00010FFFC3C3FFE001E107FF8C007FFE00011FFFE187FF + C001C107FF8C007FFC00001FFFE007FF8001E00FFF1C007FCC002009FFE181FF + FFFFE00FFF1C007FE000C00CFFE100FFFFFF200FFF0C007F1003C008FFE00C3F + FFFC201FFE06003F8002C00CFFE00E1FFFF8601FFE06003FC070C01CFFC00E1F + FFF8600FFE07003FC1F86018FFC00C0FFFD02003FC03003FD7FC2038FF801447 + FF820001F8C1001FF7FE0018FF0818E7FF870030E0E0001FFFFF0010FF0818F3 + FFC38010C1F0001FFFFF8001FF0010F3FFE3800183F8003FFFFF8001FF80017B + FFFF80018FFC003FFFFE8000FFC003BBFFFFC0038FFC003FFFFD8001FFE001DB + FFFFC0038FFE007FFFF5C003FFC000EBFFFFE0078FFE007FFFF0E00FFFF007F3 + FFFFFC0FC7FF00FFFFF83C3FFFFE1FFBFFFFF80FC7FF01FFFFFC003FFFFC1FFC + FFFFF80FC7FF03FFFFFF001FFFFC0CFFFFFFF80F8FFF01FFFFFFC01FFFFC09FF + FFFFF80F8FFF01FFFFFFF01FFFFC01FFFFFFF80F1FFF83FFFFFFF81FFFFC01FF + FFFFFC1F3FFFC7FFFFFFFC3FFFFE13FFFF80007FFE900040A400200B40020045 + FF80007FFFFF01C1FF80F07FF00201FFFFC000FFFFFF81C1FFC0F07FF00200FF + FFF001FFFFFFE183FFF0F87FF803007FFFF003FFFFFFE107FFF0F8FFFE03003F + FFF807FFFFFFF007FFF8F8FFFF03003FFFF80FFFFFFFF007FFF878FFFE07001F + FFF00FFFFFFFE087FFF070FFFE07001FFFF00FFFFFFFE10FFFD870FFFF0200DF + FFF003FFFFFFE10FFF5830FFFE0201FFFFE003FFFFFFC107FEA830FFF000003F + FFE003FFFFFF800FFEAC00FFE0000C1FFFE003FFFFFF0019FF4C01FFC0000C0F + FFE003FFFFFE2011FF0601FFC0000C0FFFE003FFFFF86011FF8601FF80000E0F + FFE003FFFFF0E039FFC300FF00000C07FFE003FFFFF0F031FFE3007F80000803 + FFE001FFFFE07031FFF1801F80000011FFC001FFFFC43021FFF1820F00000038 + FFC001FFFF8E0003FFF8010FC000003CFFC001FFFF1F0003FFF8001FE000003F + FFC003FFFC3F8007FFFC003FD000007FFFE003FFFC7FC007FFFC003FF800003F + FFE003FFF07FC007FFF8001FF800003FFFF007FFD1FFE00FFFFC003FFC00007F + FFF007FFC1FFFC3FFFFFC3FFFE1031FFFFE007FF87FFF83FFFFF81FFFFF01FFF + FFF007FF83FFF819FFFF81FFFFF01FFFFFF80FFF0FFFF813FFFF81FFFFF011FF + FFFC0FFF3FFFF803FFFF81FFFFF010FFFFFC0FFFFFFFF807FFFF81FFFFF803FF + FFFE1FFFFFFFFC27FFFFC3FFFFFC07FF80000000FF3C1FFDFF0C1FBDA0058012 + 800000007C1005C3FF0007FBFC1FE067800000009C000303FC000367FC1FE0C7 + C000000080000107F8000187FE0FE38FC00000008000000FF800000FFF87E31F + 80000000C0000007DC00001FFFC7E23F80000000F0000003F7000003FFC3E07F + 0F800000E0000003FF000001FFC1C0FF3F000000E000000300000001FFA0C1FF + 7F000000C000000300000000FFF0C1FFFE000000C000001DC0000018FFF040FF + FC000000B000001FE000001EFFF800FFE0000000FC00001FF000001BFFF000FF + 80000000FC00000FF000001FFFF001FF00000000F000001F4000001FFFF801FF + 00000000D000001FE000001FFFF803FF30000000E000000FE000000FFFF000FF + 70000000E000000FE0000007FFE2007FE0000000F0000007C0000005FFC6047F + C00000008000000780000003FF82007F80000000C000000100000001FF00007F + 80000000E000000080000003FC3000FF80000000F0000001F0000005FC6000FF + 80000000FE000001C000000EF84000FFC0000000FF000040F000000FF08001FF + E0000000FF000078EC000017E38001FFFE000000FE8000FCFC00001F87F001FF + FF000000FD80003EFE00003F0FFC01FFFF00000CFB4001FFFE00003F0FFE03FF + FF8E03FEFEE002FFFE0000379FFF03FFFFCF1FFEFFD0077FF1F0070BFFFF03FF + FFFF9FFFFFFC1FFFFFFC1FEFFFFF87FF00000000000000000000000000000000 + 000000000000} + end +end diff --git a/src/tools/PseuWoWConsole/src/fMain.pas b/src/tools/PseuWoWConsole/src/fMain.pas index f2af80c..5fa81d5 100644 --- a/src/tools/PseuWoWConsole/src/fMain.pas +++ b/src/tools/PseuWoWConsole/src/fMain.pas @@ -1,724 +1,724 @@ -unit fMain; - -interface - -uses - Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, - StdCtrls, RedirectConsole, ExtCtrls, IniFiles, ScktComp, JvComponentBase, - JvTrayIcon, ComCtrls, modRichEdit, StrUtils, ImgList, modSCPUtils, SyncObjs; - -type - TMsgType = (mtUnknown = 0, mtChat = 1, mtWhisper, mtReply, mtSysMsg, mtMOTD, mtEmote); - - TPseuWowCMD = (pwUnknown = 0, pwSay = 1); - - TLogItem = class - MsgType : TMsgType; - LogMessage : string; - end; - - - TLogThread = class(TThread) - protected - procedure Execute; override; - public - LogList : TThreadList; - currMessage : string; - currCommand : TPseuWowCMD; - critWrite : TCriticalSection; - - constructor Create; - destructor Destroy; override; - - procedure AddMessage(AMsg : string); - procedure SyncWrite(); - - procedure WriteFromPseWow(AString : String); - end; - - TfrmMain = class(TForm) - pnlTop: TPanel; - txtExe: TEdit; - btnRun: TButton; - btnExit: TButton; - servRemote: TServerSocket; - timerStart: TTimer; - clientSock: TClientSocket; - TrayIcon: TJvTrayIcon; - Console: TRichEdit; - imgList: TImageList; - pnlBottom: TPanel; - grpCmd: TGroupBox; - comCommand: TComboBox; - pnlSessionTop: TPanel; - cbexIcon: TComboBoxEx; - txtChar: TStaticText; - chkCleanMessages: TCheckBox; - pnlTestColor: TPanel; - procedure btnRunClick(Sender: TObject); - procedure btnExitClick(Sender: TObject); - procedure FormCreate(Sender: TObject); - procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); - procedure timerStartTimer(Sender: TObject); - procedure servRemoteClientRead(Sender: TObject; - Socket: TCustomWinSocket); - procedure FormDestroy(Sender: TObject); - procedure clientSockConnect(Sender: TObject; Socket: TCustomWinSocket); - procedure clientSockError(Sender: TObject; Socket: TCustomWinSocket; - ErrorEvent: TErrorEvent; var ErrorCode: Integer); - procedure ConsoleResizeRequest(Sender: TObject; Rect: TRect); - procedure comCommandKeyDown(Sender: TObject; var Key: Word; - Shift: TShiftState); - procedure clientSockConnecting(Sender: TObject; - Socket: TCustomWinSocket); - procedure cbexIconChange(Sender: TObject); - private - { Private declarations } - Logger : TLogThread; - - App : String; - Running : Boolean; - Ready : Boolean; - - function ConsoleCommand(AString : String):Boolean; - - procedure LoadSettings; - procedure SetupIcons; - procedure SetIcon(AIndex : Integer; AUpdateINI : Boolean = True); - procedure LoadPseuSettings(AConFile : string); - - procedure ShutDown; - procedure Execute(AFile: String); - procedure Launch; - procedure Log(AText: String; Color : TColor = clAqua); - - procedure AddHistoryItem(Item : String); - - public - { Public declarations } - end; - -var - frmMain: TfrmMain; - -implementation -{$R *.DFM} - - -procedure MyLineOut(s: string); // Output procedure -begin - frmMain.Logger.AddMessage(s); -end; - -{---------TLogThread-----------------------------------------------------------\ -\------------------------------------------------------------------------------} - -procedure TLogThread.AddMessage(AMsg: string); -var - NewItem : TLogItem; -begin - NewItem := TLogItem.Create; - NewItem.MsgType := mtUnknown; - NewItem.LogMessage := AMsg; - - LogList.Add(NewItem); -end; - -constructor TLogThread.Create; -begin - inherited Create(true); - - currCommand := pwUnknown; - - LogList := TThreadList.Create; - critWrite := TCriticalSection.Create; -end; - -destructor TLogThread.Destroy; -begin - FreeAndNil(LogList); - FreeAndNil(critWrite); - inherited; -end; - -procedure TLogThread.Execute; -var - List : TList; - oItem : TLogItem; -begin - currMessage := ''; - - while not (Terminated) do - begin - List := LogList.LockList; - LogList.UnlockList; - - while List.Count > 0 do - begin - oItem := TLogItem(List[0]); - - //Do the Stuff - - //If the case of sysmsg that hasn't given |r and we get a new message - //with in it, write the current message - if (currMessage <> '') and (AnsiPos('', oItem.LogMessage) <> 0) then - begin - currMessage := currMessage + '|r'; - Synchronize(SyncWrite); - currMessage := ''; - end; - - currMessage := Trim(currMessage + oItem.LogMessage); - Synchronize(SyncWrite); - - LogList.Remove(oItem); - oItem.Free; - end; - - //TT: If we still have something in the buffer just write it - if currMessage <> '' then - begin - //In the case of a SYSMSG without |r - if AnsiPos('|r',currMessage) = 0 then - currMessage := currMessage + '|r'; - Synchronize(SyncWrite); - end; - - SleepEx(100, True); - end; -end; - -procedure TLogThread.SyncWrite; -begin - critWrite.Acquire; - WriteFromPseWow(currMessage); - critWrite.Release; -end; - -procedure TLogThread.WriteFromPseWow(AString: String); -var - mt : TMsgType; - iPos, iPos2 : Integer; - bEOL : Boolean; - NewCommand : TPseuWowCMD; -begin - //TT: Assume we have EOL - bEOL := True; - NewCommand := pwUnknown; - - //TT: Remove the current command display to minimise spam - if frmMain.chkCleanMessages.Checked then - begin - //Get Our New Command - if AnsiPos(':', AString) <> 0 then - NewCommand := pwSay; - - //May cause a problem if there is more than cmd data in a received string - //if (currCommand <> pwUnknown) and (NewCommand = currCommand) then - // Exit; - - //We have a new command - if (NewCommand = pwUnknown) and (currCommand <> pwUnknown) then - begin - //Remove redundent PW Command Text - if (currCommand = pwSay) then - AnsiReplaceText(AString, '', ''); - end - else - currCommand := NewCommand; - end; - - try - if Trim(AString) <> '' then - begin - - if LeftStr(AString, 8) = 'SYSMSG: ' then - begin - //Check for end of line |r - if AnsiPos('|r',AString) = 0 then - begin - bEOL := False; - - if RightStr(Trim(AString), 1) = '"' then - bEOL := True - else - Exit; - end; - - AString := AnsiReplaceText(AString,'|r',''); - - - if frmMain.chkCleanMessages.Checked then - begin - AString := AnsiReplaceText(AString,'SYSMSG: ',''); - AString := AnsiReplaceText(AString, '"', ''); - end; - - //Clean Ups for Say Outputs like lookup etc. - if frmMain.chkCleanMessages.Checked then - begin - if AnsiContainsText(AString, '|Hquest') then - begin - AString := AddHilightedItem(AString,'quest'); - end; - - if AnsiContainsText(AString, '|Hitem') then - begin - AString := AddHilightedItem(AString,'item'); - end; - - if AnsiContainsText(AString, '|Htele') then - begin - AString := AddHilightedItem(AString,'tele'); - end; - - if AnsiContainsText(AString, '|Hspell') then - begin - AString := AddHilightedItem(AString,'spell'); - end; - - if AnsiContainsText(AString, '|Hcreature') then - begin - AString := AddHilightedItem(AString,'creature'); - end; - - if AnsiContainsText(AString, '|Hobject') then - begin - AString := AddHilightedItem(AString,'object'); - end; - - end; - - AddColourToLine(frmMain.Console,AString, ); - Exit; - end; - - if frmMain.chkCleanMessages.Checked then - AString := AnsiReplaceText(AString, '"', ''); - - AString := AnsiReplaceText(AString,'|r',''); - - if LeftStr(AString, 6) = 'CHAT: ' then - begin - if frmMain.chkCleanMessages.Checked then - AString := AnsiReplaceText(AString,'CHAT: ',''); - - AddColourToLine(frmMain.Console, AString, clWhite); - Exit; - end; - - //Are we doing clean messages? - if frmMain.chkCleanMessages.Checked then - begin - AnsiReplaceText(AString,'"',''); - end; - - //TT: Check for known string headers and color accordingly - if LeftStr(AString, 6) = 'WHISP:' then - begin - if frmMain.chkCleanMessages.Checked then - AString := AnsiReplaceText(AString,'WHISP: ',''); - AddColouredLine(frmMain.Console,AString, $00FB00FB); - Exit; - end; - - if LeftStr(AString, 3) = 'TO ' then - begin - if frmMain.chkCleanMessages.Checked then - AString := AnsiReplaceText(AString,'TO ',''); - - AddColouredLine(frmMain.Console,AString, $00FB00FB); - Exit; - end; - - if LeftStr(AString, 7) = 'EMOTE: ' then - begin - if frmMain.chkCleanMessages.Checked then - AString := AnsiReplaceText(AString,'EMOTE: ',''); - AddColouredLine(frmMain.Console,AString, clYellow); - Exit; - end; - - if LeftStr(AString, 6) = 'MOTD: ' then - begin - if frmMain.chkCleanMessages.Checked then - AString := AnsiReplaceText(AString,'MOTD: ',''); - - AddColouredLine(frmMain.Console,AString, clAqua); - Exit; - end; - - //This doesnt ADD any color at the moment it just seems to clean up the string a bit - AddColourToLine(frmMain.Console,AString); - end; - finally - if bEOL then - currMessage := ''; - end; -end; - - -{---------TfrmMain-------------------------------------------------------------\ -\------------------------------------------------------------------------------} - -procedure TfrmMain.FormCreate(Sender: TObject); -begin - RC_LineOut:=MyLineOut; // set Output - - Logger := TLogThread.Create; - Logger.Resume; - - SetupIcons; - LoadSettings; - Ready := False; -end; - -procedure TfrmMain.btnRunClick(Sender: TObject); -var - IniFile : TInifile; -begin - IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Settings.INI'); - IniFile.WriteString('Execute','Application',txtExe.Text); - IniFile.UpdateFile; - IniFile.Free; - RC_Run(txtExe.text); // run frmMain.Console program -end; - -procedure TfrmMain.btnExitClick(Sender: TObject); -begin - ShutDown(); -end; - -procedure TfrmMain.ShutDown; -begin - Log('Shut down PseuWow Process',clRed); - RC_LineIn('!'); - RC_LineIn('quit'); - Sleep(3000); -end; - -procedure TfrmMain.Execute(AFile : String); -begin - //TT: Get Info from PseuWow.conf - LoadPseuSettings(ExtractFilePath(AFile)+'\conf\PseuWoW.conf'); - - //TT: See if we already have a server running - with clientSock do - begin - Port := 8089; - Open; - end; - - - Running := True; - pnlTop.Hide; - comCommand.SetFocus; - RC_Run(AFile); - -end; - -procedure TfrmMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean); -begin - if RC_ExitCode = STILL_ACTIVE then - begin - ShutDown; - CanClose := True; - end; -end; - -procedure TfrmMain.timerStartTimer(Sender: TObject); -begin - timerStart.Enabled := False; - if Ready then - begin - //TrayIcon.HideApplication; - Launch; - Exit; - end - else - begin - if clientSock.Active = false then - clientSock.Active := True; - end; - - timerStart.Enabled := True; -end; - -procedure TfrmMain.servRemoteClientRead(Sender: TObject; - Socket: TCustomWinSocket); -begin - RC_LineIn('!'); - RC_LineIn(Socket.ReceiveText); - Log('Received Remote Commad: ' + Socket.ReceiveText, clGreen ); -end; - -procedure TfrmMain.FormDestroy(Sender: TObject); -begin - Logger.Terminate; - FreeAndNil(Logger); - - servRemote.Active := False; -end; - -procedure TfrmMain.clientSockConnect(Sender: TObject; - Socket: TCustomWinSocket); -begin - - //World Server Check - if clientSock.Port = 8085 then - begin - Ready := True; - clientSock.Active := False; - Log('**** WS Is Ready For Connections ****'); - Launch; - end; - - //Checking If We Have A listening Console - if clientSock.Port = 8089 then - begin - Log('**** Already Listening ****'); - servRemote.Active := False; - end; - -end; - -procedure TfrmMain.clientSockError(Sender: TObject; - Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; - var ErrorCode: Integer); -begin - //World Server Check - if clientSock.Port = 8085 then - begin - Ready := False; - clientSock.Active := False; - Log('Still Waiting For Server',clMaroon); - ErrorCode := 0; - end - else - begin - Log('No Listening Console', clGreen); - servRemote.Active := True; - ErrorCode := 0; - end; -end; - -procedure TfrmMain.Launch; -var - IniFile : TInifile; - iIcon : Integer; -begin - if Ready = False then - Exit; - - Running := False; - timerStart.Enabled := False; - - if App <> '' then - Execute(App) - else - begin - timerStart.Enabled := True; - end; -end; - - -procedure TfrmMain.Log(AText: String; Color: TColor); -begin - AddColouredLine(frmMain.Console,'Console: '+AText, Color); -end; - - -procedure TfrmMain.ConsoleResizeRequest(Sender: TObject; Rect: TRect); -var - ScrollMessage: TWMVScroll; - i : Integer; -begin - ScrollMessage.Msg := WM_VScroll; - - for i := 0 to Console.Lines.Count do - begin - ScrollMessage.ScrollCode := sb_LineDown; - ScrollMessage.Pos := 0; - Console.Dispatch(ScrollMessage); - end; -end; - -procedure TfrmMain.comCommandKeyDown(Sender: TObject; var Key: Word; - Shift: TShiftState); -begin - if key = VK_RETURN then - begin - if frmMain.ConsoleCommand(comCommand.Text) then - begin - key := 0; - Exit; - end; - - // send command line on Enter Key - RC_LineIn(comCommand.Text); - AddHistoryItem(comCommand.Text); - comCommand.Text := ''; - key:=0; - Exit; - end; - - if key = VK_F3 then - begin - if comCommand.Items.Count > 0 then - comCommand.ItemIndex := comCommand.Items.Count -1; - Key := 0; - Exit; - end; - -end; - -procedure TfrmMain.clientSockConnecting(Sender: TObject; - Socket: TCustomWinSocket); -begin - if clientSock.Port = 8085 then - begin - Log('Establishing Connection to WS',clGreen); - end; - - if clientSock.Port = 8089 then - begin - Log('Checking For Listening Console',clGreen); - end; -end; - -procedure TfrmMain.AddHistoryItem(Item: String); -begin - with comCommand do - begin - if Items.IndexOf(Item) = -1 then - begin - Items.Add(Item); - end; - end; -end; - -function TfrmMain.ConsoleCommand(AString: String): Boolean; -begin - Result := False; - AString := UpperCase(AString); - - if (AString = '!QUIT') or (AString = '!EXIT') then - begin - Result := True; - ShutDown; - Sleep(1000); - Close; - end; - -end; - -procedure TfrmMain.SetupIcons; -var - i : Integer; -begin - cbexIcon.Clear; - - for i := 0 to imgList.Count - 1 do - begin - cbexIcon.ItemsEx.AddItem('',i,i,i,0,nil); - end; - -end; - -procedure TfrmMain.SetIcon(AIndex : Integer; AUpdateINI : Boolean = True); -var - IniFile : TInifile; -begin - try - IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Settings.INI'); - if AUpdateINI then - IniFile.WriteInteger('Look','Icon',AIndex); - - with imgList do - begin - GetIcon(AIndex, Application.Icon); - TrayIcon.IconIndex := AIndex; - end; - cbexIcon.ItemIndex := AIndex; - finally - if AUpdateINI then - begin - IniFile.UpdateFile; - comCommand.SetFocus; - end; - IniFile.Free; - end; -end; - -procedure TfrmMain.LoadSettings; -var - IniFile : TInifile; - iIcon : Integer; -begin - try - //TT: Read from Inifile for the path the file we want. - IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Settings.INI'); - App := IniFile.ReadString('Execute','Application',''); - if App = '' then - begin - if FileExists(ExtractFilePath(Application.ExeName)+'pseuwow.exe') then - begin - App := ExtractFilePath(Application.ExeName)+'pseuwow.exe'; - pnlTop.Hide; - end - else - pnlTop.Show; - end; - IniFile.WriteString('Execute','Application',App); - - //TT: Read Tray Icon, Nice for those of us who more than one session at a time! - iIcon := IniFile.ReadInteger('Look','Icon',-1); - - if (iIcon = -1) then - IniFile.WriteInteger('Look','Icon',0); - - SetIcon(iIcon, False); - - finally - IniFile.UpdateFile; - IniFile.Free; - end; -end; - -procedure TfrmMain.cbexIconChange(Sender: TObject); -begin - if Ready then - SetIcon(cbexIcon.ItemIndex); -end; - -procedure TfrmMain.LoadPseuSettings(AConFile : string); -var - fFile : textfile; - sBuffer : string; - sRes : string; -begin - if FileExists(AConFile) then - begin - AssignFile(fFile, AConFile); - Reset(fFile); - - while not(Eof(fFile)) do - begin - sRes := ''; - - Readln(fFile, sBuffer); - - if EvaluateProperty(sBuffer, 'charname=', sRes) then - begin - txtChar.Caption := sRes; - Application.Title := sRes + ' - PseuWoW frmMain.Console'; - TrayIcon.Hint := Application.Title; - end; - end; - end; - CloseFile(fFile); - - comCommand.SetFocus; -end; - -end. +unit fMain; + +interface + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, RedirectConsole, ExtCtrls, IniFiles, ScktComp, JvComponentBase, + JvTrayIcon, ComCtrls, modRichEdit, StrUtils, ImgList, modSCPUtils, SyncObjs; + +type + TMsgType = (mtUnknown = 0, mtChat = 1, mtWhisper, mtReply, mtSysMsg, mtMOTD, mtEmote); + + TPseuWowCMD = (pwUnknown = 0, pwSay = 1); + + TLogItem = class + MsgType : TMsgType; + LogMessage : string; + end; + + + TLogThread = class(TThread) + protected + procedure Execute; override; + public + LogList : TThreadList; + currMessage : string; + currCommand : TPseuWowCMD; + critWrite : TCriticalSection; + + constructor Create; + destructor Destroy; override; + + procedure AddMessage(AMsg : string); + procedure SyncWrite(); + + procedure WriteFromPseWow(AString : String); + end; + + TfrmMain = class(TForm) + pnlTop: TPanel; + txtExe: TEdit; + btnRun: TButton; + btnExit: TButton; + servRemote: TServerSocket; + timerStart: TTimer; + clientSock: TClientSocket; + TrayIcon: TJvTrayIcon; + Console: TRichEdit; + imgList: TImageList; + pnlBottom: TPanel; + grpCmd: TGroupBox; + comCommand: TComboBox; + pnlSessionTop: TPanel; + cbexIcon: TComboBoxEx; + txtChar: TStaticText; + chkCleanMessages: TCheckBox; + pnlTestColor: TPanel; + procedure btnRunClick(Sender: TObject); + procedure btnExitClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); + procedure timerStartTimer(Sender: TObject); + procedure servRemoteClientRead(Sender: TObject; + Socket: TCustomWinSocket); + procedure FormDestroy(Sender: TObject); + procedure clientSockConnect(Sender: TObject; Socket: TCustomWinSocket); + procedure clientSockError(Sender: TObject; Socket: TCustomWinSocket; + ErrorEvent: TErrorEvent; var ErrorCode: Integer); + procedure ConsoleResizeRequest(Sender: TObject; Rect: TRect); + procedure comCommandKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure clientSockConnecting(Sender: TObject; + Socket: TCustomWinSocket); + procedure cbexIconChange(Sender: TObject); + private + { Private declarations } + Logger : TLogThread; + + App : String; + Running : Boolean; + Ready : Boolean; + + function ConsoleCommand(AString : String):Boolean; + + procedure LoadSettings; + procedure SetupIcons; + procedure SetIcon(AIndex : Integer; AUpdateINI : Boolean = True); + procedure LoadPseuSettings(AConFile : string); + + procedure ShutDown; + procedure Execute(AFile: String); + procedure Launch; + procedure Log(AText: String; Color : TColor = clAqua); + + procedure AddHistoryItem(Item : String); + + public + { Public declarations } + end; + +var + frmMain: TfrmMain; + +implementation +{$R *.DFM} + + +procedure MyLineOut(s: string); // Output procedure +begin + frmMain.Logger.AddMessage(s); +end; + +{---------TLogThread-----------------------------------------------------------\ +\------------------------------------------------------------------------------} + +procedure TLogThread.AddMessage(AMsg: string); +var + NewItem : TLogItem; +begin + NewItem := TLogItem.Create; + NewItem.MsgType := mtUnknown; + NewItem.LogMessage := AMsg; + + LogList.Add(NewItem); +end; + +constructor TLogThread.Create; +begin + inherited Create(true); + + currCommand := pwUnknown; + + LogList := TThreadList.Create; + critWrite := TCriticalSection.Create; +end; + +destructor TLogThread.Destroy; +begin + FreeAndNil(LogList); + FreeAndNil(critWrite); + inherited; +end; + +procedure TLogThread.Execute; +var + List : TList; + oItem : TLogItem; +begin + currMessage := ''; + + while not (Terminated) do + begin + List := LogList.LockList; + LogList.UnlockList; + + while List.Count > 0 do + begin + oItem := TLogItem(List[0]); + + //Do the Stuff + + //If the case of sysmsg that hasn't given |r and we get a new message + //with in it, write the current message + if (currMessage <> '') and (AnsiPos('', oItem.LogMessage) <> 0) then + begin + currMessage := currMessage + '|r'; + Synchronize(SyncWrite); + currMessage := ''; + end; + + currMessage := Trim(currMessage + oItem.LogMessage); + Synchronize(SyncWrite); + + LogList.Remove(oItem); + oItem.Free; + end; + + //TT: If we still have something in the buffer just write it + if currMessage <> '' then + begin + //In the case of a SYSMSG without |r + if AnsiPos('|r',currMessage) = 0 then + currMessage := currMessage + '|r'; + Synchronize(SyncWrite); + end; + + SleepEx(100, True); + end; +end; + +procedure TLogThread.SyncWrite; +begin + critWrite.Acquire; + WriteFromPseWow(currMessage); + critWrite.Release; +end; + +procedure TLogThread.WriteFromPseWow(AString: String); +var + mt : TMsgType; + iPos, iPos2 : Integer; + bEOL : Boolean; + NewCommand : TPseuWowCMD; +begin + //TT: Assume we have EOL + bEOL := True; + NewCommand := pwUnknown; + + //TT: Remove the current command display to minimise spam + if frmMain.chkCleanMessages.Checked then + begin + //Get Our New Command + if AnsiPos(':', AString) <> 0 then + NewCommand := pwSay; + + //May cause a problem if there is more than cmd data in a received string + //if (currCommand <> pwUnknown) and (NewCommand = currCommand) then + // Exit; + + //We have a new command + if (NewCommand = pwUnknown) and (currCommand <> pwUnknown) then + begin + //Remove redundent PW Command Text + if (currCommand = pwSay) then + AnsiReplaceText(AString, '', ''); + end + else + currCommand := NewCommand; + end; + + try + if Trim(AString) <> '' then + begin + + if LeftStr(AString, 8) = 'SYSMSG: ' then + begin + //Check for end of line |r + if AnsiPos('|r',AString) = 0 then + begin + bEOL := False; + + if RightStr(Trim(AString), 1) = '"' then + bEOL := True + else + Exit; + end; + + AString := AnsiReplaceText(AString,'|r',''); + + + if frmMain.chkCleanMessages.Checked then + begin + AString := AnsiReplaceText(AString,'SYSMSG: ',''); + AString := AnsiReplaceText(AString, '"', ''); + end; + + //Clean Ups for Say Outputs like lookup etc. + if frmMain.chkCleanMessages.Checked then + begin + if AnsiContainsText(AString, '|Hquest') then + begin + AString := AddHilightedItem(AString,'quest'); + end; + + if AnsiContainsText(AString, '|Hitem') then + begin + AString := AddHilightedItem(AString,'item'); + end; + + if AnsiContainsText(AString, '|Htele') then + begin + AString := AddHilightedItem(AString,'tele'); + end; + + if AnsiContainsText(AString, '|Hspell') then + begin + AString := AddHilightedItem(AString,'spell'); + end; + + if AnsiContainsText(AString, '|Hcreature') then + begin + AString := AddHilightedItem(AString,'creature'); + end; + + if AnsiContainsText(AString, '|Hobject') then + begin + AString := AddHilightedItem(AString,'object'); + end; + + end; + + AddColourToLine(frmMain.Console,AString, ); + Exit; + end; + + if frmMain.chkCleanMessages.Checked then + AString := AnsiReplaceText(AString, '"', ''); + + AString := AnsiReplaceText(AString,'|r',''); + + if LeftStr(AString, 6) = 'CHAT: ' then + begin + if frmMain.chkCleanMessages.Checked then + AString := AnsiReplaceText(AString,'CHAT: ',''); + + AddColourToLine(frmMain.Console, AString, clWhite); + Exit; + end; + + //Are we doing clean messages? + if frmMain.chkCleanMessages.Checked then + begin + AnsiReplaceText(AString,'"',''); + end; + + //TT: Check for known string headers and color accordingly + if LeftStr(AString, 6) = 'WHISP:' then + begin + if frmMain.chkCleanMessages.Checked then + AString := AnsiReplaceText(AString,'WHISP: ',''); + AddColouredLine(frmMain.Console,AString, $00FB00FB); + Exit; + end; + + if LeftStr(AString, 3) = 'TO ' then + begin + if frmMain.chkCleanMessages.Checked then + AString := AnsiReplaceText(AString,'TO ',''); + + AddColouredLine(frmMain.Console,AString, $00FB00FB); + Exit; + end; + + if LeftStr(AString, 7) = 'EMOTE: ' then + begin + if frmMain.chkCleanMessages.Checked then + AString := AnsiReplaceText(AString,'EMOTE: ',''); + AddColouredLine(frmMain.Console,AString, clYellow); + Exit; + end; + + if LeftStr(AString, 6) = 'MOTD: ' then + begin + if frmMain.chkCleanMessages.Checked then + AString := AnsiReplaceText(AString,'MOTD: ',''); + + AddColouredLine(frmMain.Console,AString, clAqua); + Exit; + end; + + //This doesnt ADD any color at the moment it just seems to clean up the string a bit + AddColourToLine(frmMain.Console,AString); + end; + finally + if bEOL then + currMessage := ''; + end; +end; + + +{---------TfrmMain-------------------------------------------------------------\ +\------------------------------------------------------------------------------} + +procedure TfrmMain.FormCreate(Sender: TObject); +begin + RC_LineOut:=MyLineOut; // set Output + + Logger := TLogThread.Create; + Logger.Resume; + + SetupIcons; + LoadSettings; + Ready := False; +end; + +procedure TfrmMain.btnRunClick(Sender: TObject); +var + IniFile : TInifile; +begin + IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Settings.INI'); + IniFile.WriteString('Execute','Application',txtExe.Text); + IniFile.UpdateFile; + IniFile.Free; + RC_Run(txtExe.text); // run frmMain.Console program +end; + +procedure TfrmMain.btnExitClick(Sender: TObject); +begin + ShutDown(); +end; + +procedure TfrmMain.ShutDown; +begin + Log('Shut down PseuWow Process',clRed); + RC_LineIn('!'); + RC_LineIn('quit'); + Sleep(3000); +end; + +procedure TfrmMain.Execute(AFile : String); +begin + //TT: Get Info from PseuWow.conf + LoadPseuSettings(ExtractFilePath(AFile)+'\conf\PseuWoW.conf'); + + //TT: See if we already have a server running + with clientSock do + begin + Port := 8089; + Open; + end; + + + Running := True; + pnlTop.Hide; + comCommand.SetFocus; + RC_Run(AFile); + +end; + +procedure TfrmMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean); +begin + if RC_ExitCode = STILL_ACTIVE then + begin + ShutDown; + CanClose := True; + end; +end; + +procedure TfrmMain.timerStartTimer(Sender: TObject); +begin + timerStart.Enabled := False; + if Ready then + begin + //TrayIcon.HideApplication; + Launch; + Exit; + end + else + begin + if clientSock.Active = false then + clientSock.Active := True; + end; + + timerStart.Enabled := True; +end; + +procedure TfrmMain.servRemoteClientRead(Sender: TObject; + Socket: TCustomWinSocket); +begin + RC_LineIn('!'); + RC_LineIn(Socket.ReceiveText); + Log('Received Remote Commad: ' + Socket.ReceiveText, clGreen ); +end; + +procedure TfrmMain.FormDestroy(Sender: TObject); +begin + Logger.Terminate; + FreeAndNil(Logger); + + servRemote.Active := False; +end; + +procedure TfrmMain.clientSockConnect(Sender: TObject; + Socket: TCustomWinSocket); +begin + + //World Server Check + if clientSock.Port = 8085 then + begin + Ready := True; + clientSock.Active := False; + Log('**** WS Is Ready For Connections ****'); + Launch; + end; + + //Checking If We Have A listening Console + if clientSock.Port = 8089 then + begin + Log('**** Already Listening ****'); + servRemote.Active := False; + end; + +end; + +procedure TfrmMain.clientSockError(Sender: TObject; + Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; + var ErrorCode: Integer); +begin + //World Server Check + if clientSock.Port = 8085 then + begin + Ready := False; + clientSock.Active := False; + Log('Still Waiting For Server',clMaroon); + ErrorCode := 0; + end + else + begin + Log('No Listening Console', clGreen); + servRemote.Active := True; + ErrorCode := 0; + end; +end; + +procedure TfrmMain.Launch; +var + IniFile : TInifile; + iIcon : Integer; +begin + if Ready = False then + Exit; + + Running := False; + timerStart.Enabled := False; + + if App <> '' then + Execute(App) + else + begin + timerStart.Enabled := True; + end; +end; + + +procedure TfrmMain.Log(AText: String; Color: TColor); +begin + AddColouredLine(frmMain.Console,'Console: '+AText, Color); +end; + + +procedure TfrmMain.ConsoleResizeRequest(Sender: TObject; Rect: TRect); +var + ScrollMessage: TWMVScroll; + i : Integer; +begin + ScrollMessage.Msg := WM_VScroll; + + for i := 0 to Console.Lines.Count do + begin + ScrollMessage.ScrollCode := sb_LineDown; + ScrollMessage.Pos := 0; + Console.Dispatch(ScrollMessage); + end; +end; + +procedure TfrmMain.comCommandKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if key = VK_RETURN then + begin + if frmMain.ConsoleCommand(comCommand.Text) then + begin + key := 0; + Exit; + end; + + // send command line on Enter Key + RC_LineIn(comCommand.Text); + AddHistoryItem(comCommand.Text); + comCommand.Text := ''; + key:=0; + Exit; + end; + + if key = VK_F3 then + begin + if comCommand.Items.Count > 0 then + comCommand.ItemIndex := comCommand.Items.Count -1; + Key := 0; + Exit; + end; + +end; + +procedure TfrmMain.clientSockConnecting(Sender: TObject; + Socket: TCustomWinSocket); +begin + if clientSock.Port = 8085 then + begin + Log('Establishing Connection to WS',clGreen); + end; + + if clientSock.Port = 8089 then + begin + Log('Checking For Listening Console',clGreen); + end; +end; + +procedure TfrmMain.AddHistoryItem(Item: String); +begin + with comCommand do + begin + if Items.IndexOf(Item) = -1 then + begin + Items.Add(Item); + end; + end; +end; + +function TfrmMain.ConsoleCommand(AString: String): Boolean; +begin + Result := False; + AString := UpperCase(AString); + + if (AString = '!QUIT') or (AString = '!EXIT') then + begin + Result := True; + ShutDown; + Sleep(1000); + Close; + end; + +end; + +procedure TfrmMain.SetupIcons; +var + i : Integer; +begin + cbexIcon.Clear; + + for i := 0 to imgList.Count - 1 do + begin + cbexIcon.ItemsEx.AddItem('',i,i,i,0,nil); + end; + +end; + +procedure TfrmMain.SetIcon(AIndex : Integer; AUpdateINI : Boolean = True); +var + IniFile : TInifile; +begin + try + IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Settings.INI'); + if AUpdateINI then + IniFile.WriteInteger('Look','Icon',AIndex); + + with imgList do + begin + GetIcon(AIndex, Application.Icon); + TrayIcon.IconIndex := AIndex; + end; + cbexIcon.ItemIndex := AIndex; + finally + if AUpdateINI then + begin + IniFile.UpdateFile; + comCommand.SetFocus; + end; + IniFile.Free; + end; +end; + +procedure TfrmMain.LoadSettings; +var + IniFile : TInifile; + iIcon : Integer; +begin + try + //TT: Read from Inifile for the path the file we want. + IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Settings.INI'); + App := IniFile.ReadString('Execute','Application',''); + if App = '' then + begin + if FileExists(ExtractFilePath(Application.ExeName)+'pseuwow.exe') then + begin + App := ExtractFilePath(Application.ExeName)+'pseuwow.exe'; + pnlTop.Hide; + end + else + pnlTop.Show; + end; + IniFile.WriteString('Execute','Application',App); + + //TT: Read Tray Icon, Nice for those of us who more than one session at a time! + iIcon := IniFile.ReadInteger('Look','Icon',-1); + + if (iIcon = -1) then + IniFile.WriteInteger('Look','Icon',0); + + SetIcon(iIcon, False); + + finally + IniFile.UpdateFile; + IniFile.Free; + end; +end; + +procedure TfrmMain.cbexIconChange(Sender: TObject); +begin + if Ready then + SetIcon(cbexIcon.ItemIndex); +end; + +procedure TfrmMain.LoadPseuSettings(AConFile : string); +var + fFile : textfile; + sBuffer : string; + sRes : string; +begin + if FileExists(AConFile) then + begin + AssignFile(fFile, AConFile); + Reset(fFile); + + while not(Eof(fFile)) do + begin + sRes := ''; + + Readln(fFile, sBuffer); + + if EvaluateProperty(sBuffer, 'charname=', sRes) then + begin + txtChar.Caption := sRes; + Application.Title := sRes + ' - PseuWoW frmMain.Console'; + TrayIcon.Hint := Application.Title; + end; + end; + end; + CloseFile(fFile); + + comCommand.SetFocus; +end; + +end. diff --git a/src/tools/PseuWoWConsole/src/fMain.~pas b/src/tools/PseuWoWConsole/src/fMain.~pas index c0d241b..2b17a0e 100644 --- a/src/tools/PseuWoWConsole/src/fMain.~pas +++ b/src/tools/PseuWoWConsole/src/fMain.~pas @@ -1,720 +1,720 @@ -unit fMain; - -interface - -uses - Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, - StdCtrls, RedirectConsole, ExtCtrls, IniFiles, ScktComp, JvComponentBase, - JvTrayIcon, ComCtrls, modRichEdit, StrUtils, ImgList, modSCPUtils, SyncObjs; - -type - TMsgType = (mtUnknown = 0, mtChat = 1, mtWhisper, mtReply, mtSysMsg, mtMOTD, mtEmote); - - TPseuWowCMD = (pwUnknown = 0, pwSay = 1); - - TLogItem = class - MsgType : TMsgType; - LogMessage : string; - end; - - - TLogThread = class(TThread) - protected - procedure Execute; override; - public - LogList : TThreadList; - currMessage : string; - currCommand : TPseuWowCMD; - critWrite : TCriticalSection; - - constructor Create; - destructor Destroy; override; - - procedure AddMessage(AMsg : string); - procedure SyncWrite(); - - procedure WriteFromPseWow(AString : String); - end; - - TfrmMain = class(TForm) - pnlTop: TPanel; - txtExe: TEdit; - btnRun: TButton; - btnExit: TButton; - servRemote: TServerSocket; - timerStart: TTimer; - clientSock: TClientSocket; - TrayIcon: TJvTrayIcon; - Console: TRichEdit; - imgList: TImageList; - pnlBottom: TPanel; - grpCmd: TGroupBox; - comCommand: TComboBox; - pnlSessionTop: TPanel; - cbexIcon: TComboBoxEx; - txtChar: TStaticText; - chkCleanMessages: TCheckBox; - pnlTestColor: TPanel; - procedure btnRunClick(Sender: TObject); - procedure btnExitClick(Sender: TObject); - procedure FormCreate(Sender: TObject); - procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); - procedure timerStartTimer(Sender: TObject); - procedure servRemoteClientRead(Sender: TObject; - Socket: TCustomWinSocket); - procedure FormDestroy(Sender: TObject); - procedure clientSockConnect(Sender: TObject; Socket: TCustomWinSocket); - procedure clientSockError(Sender: TObject; Socket: TCustomWinSocket; - ErrorEvent: TErrorEvent; var ErrorCode: Integer); - procedure ConsoleResizeRequest(Sender: TObject; Rect: TRect); - procedure comCommandKeyDown(Sender: TObject; var Key: Word; - Shift: TShiftState); - procedure clientSockConnecting(Sender: TObject; - Socket: TCustomWinSocket); - procedure cbexIconChange(Sender: TObject); - private - { Private declarations } - Logger : TLogThread; - - App : String; - Running : Boolean; - Ready : Boolean; - - function ConsoleCommand(AString : String):Boolean; - - procedure LoadSettings; - procedure SetupIcons; - procedure SetIcon(AIndex : Integer; AUpdateINI : Boolean = True); - procedure LoadPseuSettings(AConFile : string); - - procedure ShutDown; - procedure Execute(AFile: String); - procedure Launch; - procedure Log(AText: String; Color : TColor = clAqua); - - procedure AddHistoryItem(Item : String); - - public - { Public declarations } - end; - -var - frmMain: TfrmMain; - -implementation -{$R *.DFM} - - -procedure MyLineOut(s: string); // Output procedure -begin - frmMain.Logger.AddMessage(s); -end; - -{---------TLogThread-----------------------------------------------------------\ -\------------------------------------------------------------------------------} - -procedure TLogThread.AddMessage(AMsg: string); -var - NewItem : TLogItem; -begin - NewItem := TLogItem.Create; - NewItem.MsgType := mtUnknown; - NewItem.LogMessage := AMsg; - - LogList.Add(NewItem); -end; - -constructor TLogThread.Create; -begin - inherited Create(true); - - currCommand := pwUnknown; - - LogList := TThreadList.Create; - critWrite := TCriticalSection.Create; -end; - -destructor TLogThread.Destroy; -begin - FreeAndNil(LogList); - FreeAndNil(critWrite); - inherited; -end; - -procedure TLogThread.Execute; -var - List : TList; - oItem : TLogItem; -begin - currMessage := ''; - - while not (Terminated) do - begin - List := LogList.LockList; - LogList.UnlockList; - - while List.Count > 0 do - begin - oItem := TLogItem(List[0]); - - //Do the Stuff - - //If the case of sysmsg that hasn't given |r and we get a new message - //with in it, write the current message - if (currMessage <> '') and (AnsiPos('', oItem.LogMessage) <> 0) then - begin - currMessage := currMessage + '|r'; - Synchronize(SyncWrite); - currMessage := ''; - end; - - currMessage := Trim(currMessage + oItem.LogMessage); - Synchronize(SyncWrite); - - LogList.Remove(oItem); - oItem.Free; - end; - - //TT: If we still have something in the buffer just write it - if currMessage <> '' then - begin - //In the case of a SYSMSG without |r - if AnsiPos('|r',currMessage) = 0 then - currMessage := currMessage + '|r'; - Synchronize(SyncWrite); - end; - - SleepEx(100, True); - end; -end; - -procedure TLogThread.SyncWrite; -begin - critWrite.Acquire; - WriteFromPseWow(currMessage); - critWrite.Release; -end; - -procedure TLogThread.WriteFromPseWow(AString: String); -var - mt : TMsgType; - iPos, iPos2 : Integer; - bEOL : Boolean; - NewCommand : TPseuWowCMD; -begin - //TT: Assume we have EOL - bEOL := True; - NewCommand := pwUnknown; - - //TT: Remove the current command display to minimise spam - if frmMain.chkCleanMessages.Checked then - begin - //Get Our New Command - if AnsiPos(':', AString) <> 0 then - NewCommand := pwSay; - - //May cause a problem if there is more than cmd data in a received string - //if (currCommand <> pwUnknown) and (NewCommand = currCommand) then - // Exit; - - //We have a new command - if (NewCommand = pwUnknown) and (currCommand <> pwUnknown) then - begin - //Remove redundent PW Command Text - if (currCommand = pwSay) then - AnsiReplaceText(AString, '', ''); - end - else - currCommand := NewCommand; - end; - - try - if Trim(AString) <> '' then - begin - - if LeftStr(AString, 8) = 'SYSMSG: ' then - begin - //Check for end of line |r - if AnsiPos('|r',AString) = 0 then - begin - bEOL := False; - Exit; - end; - - AString := AnsiReplaceText(AString,'|r',''); - - - if frmMain.chkCleanMessages.Checked then - begin - AString := AnsiReplaceText(AString,'SYSMSG: ',''); - AString := AnsiReplaceText(AString, '"', ''); - end; - - //Clean Ups for Say Outputs like lookup etc. - if frmMain.chkCleanMessages.Checked then - begin - if AnsiContainsText(AString, '|Hquest') then - begin - AString := AddHilightedItem(AString,'quest'); - end; - - if AnsiContainsText(AString, '|Hitem') then - begin - AString := AddHilightedItem(AString,'item'); - end; - - if AnsiContainsText(AString, '|Htele') then - begin - AString := AddHilightedItem(AString,'tele'); - end; - - if AnsiContainsText(AString, '|Hspell') then - begin - AString := AddHilightedItem(AString,'spell'); - end; - - if AnsiContainsText(AString, '|Hcreature') then - begin - AString := AddHilightedItem(AString,'creature'); - end; - - if AnsiContainsText(AString, '|Hobject') then - begin - AString := AddHilightedItem(AString,'object'); - end; - - end; - - AddColourToLine(frmMain.Console,AString, ); - Exit; - end; - - if frmMain.chkCleanMessages.Checked then - AString := AnsiReplaceText(AString, '"', ''); - - AString := AnsiReplaceText(AString,'|r',''); - - if LeftStr(AString, 6) = 'CHAT: ' then - begin - if frmMain.chkCleanMessages.Checked then - AString := AnsiReplaceText(AString,'CHAT: ',''); - - AddColourToLine(frmMain.Console, AString, clWhite); - Exit; - end; - - //Are we doing clean messages? - if frmMain.chkCleanMessages.Checked then - begin - AnsiReplaceText(AString,'"',''); - end; - - //TT: Check for known string headers and color accordingly - if LeftStr(AString, 6) = 'WHISP:' then - begin - if frmMain.chkCleanMessages.Checked then - AString := AnsiReplaceText(AString,'WHISP: ',''); - AddColouredLine(frmMain.Console,AString, $00FB00FB); - Exit; - end; - - if LeftStr(AString, 3) = 'TO ' then - begin - if frmMain.chkCleanMessages.Checked then - AString := AnsiReplaceText(AString,'TO ',''); - - AddColouredLine(frmMain.Console,AString, $00FB00FB); - Exit; - end; - - if LeftStr(AString, 7) = 'EMOTE: ' then - begin - if frmMain.chkCleanMessages.Checked then - AString := AnsiReplaceText(AString,'EMOTE: ',''); - AddColouredLine(frmMain.Console,AString, clYellow); - Exit; - end; - - if LeftStr(AString, 6) = 'MOTD: ' then - begin - if frmMain.chkCleanMessages.Checked then - AString := AnsiReplaceText(AString,'MOTD: ',''); - - AddColouredLine(frmMain.Console,AString, clAqua); - Exit; - end; - - //This doesnt ADD any color at the moment it just seems to clean up the string a bit - AddColourToLine(frmMain.Console,AString); - end; - finally - if bEOL then - currMessage := ''; - end; -end; - - -{---------TfrmMain-------------------------------------------------------------\ -\------------------------------------------------------------------------------} - -procedure TfrmMain.FormCreate(Sender: TObject); -begin - RC_LineOut:=MyLineOut; // set Output - - Logger := TLogThread.Create; - Logger.Resume; - - SetupIcons; - LoadSettings; - Ready := False; -end; - -procedure TfrmMain.btnRunClick(Sender: TObject); -var - IniFile : TInifile; -begin - IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Settings.INI'); - IniFile.WriteString('Execute','Application',txtExe.Text); - IniFile.UpdateFile; - IniFile.Free; - RC_Run(txtExe.text); // run frmMain.Console program -end; - -procedure TfrmMain.btnExitClick(Sender: TObject); -begin - ShutDown(); -end; - -procedure TfrmMain.ShutDown; -begin - Log('Shut down PseuWow Process',clRed); - RC_LineIn('!'); - RC_LineIn('quit'); - Sleep(3000); -end; - -procedure TfrmMain.Execute(AFile : String); -begin - //TT: Get Info from PseuWow.conf - LoadPseuSettings(ExtractFilePath(AFile)+'\conf\PseuWoW.conf'); - - //TT: See if we already have a server running - with clientSock do - begin - Port := 8089; - Open; - end; - - - Running := True; - pnlTop.Hide; - comCommand.SetFocus; - RC_Run(AFile); - -end; - -procedure TfrmMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean); -begin - if RC_ExitCode = STILL_ACTIVE then - begin - ShutDown; - CanClose := True; - end; -end; - -procedure TfrmMain.timerStartTimer(Sender: TObject); -begin - timerStart.Enabled := False; - if Ready then - begin - //TrayIcon.HideApplication; - Launch; - Exit; - end - else - begin - if clientSock.Active = false then - clientSock.Active := True; - end; - - timerStart.Enabled := True; -end; - -procedure TfrmMain.servRemoteClientRead(Sender: TObject; - Socket: TCustomWinSocket); -begin - RC_LineIn('!'); - RC_LineIn(Socket.ReceiveText); - Log('Received Remote Commad: ' + Socket.ReceiveText, clGreen ); -end; - -procedure TfrmMain.FormDestroy(Sender: TObject); -begin - Logger.Terminate; - FreeAndNil(Logger); - - servRemote.Active := False; -end; - -procedure TfrmMain.clientSockConnect(Sender: TObject; - Socket: TCustomWinSocket); -begin - - //World Server Check - if clientSock.Port = 8085 then - begin - Ready := True; - clientSock.Active := False; - Log('**** WS Is Ready For Connections ****'); - Launch; - end; - - //Checking If We Have A listening Console - if clientSock.Port = 8089 then - begin - Log('**** Already Listening ****'); - servRemote.Active := False; - end; - -end; - -procedure TfrmMain.clientSockError(Sender: TObject; - Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; - var ErrorCode: Integer); -begin - //World Server Check - if clientSock.Port = 8085 then - begin - Ready := False; - clientSock.Active := False; - Log('Still Waiting For Server',clMaroon); - ErrorCode := 0; - end - else - begin - Log('No Listening Console', clGreen); - servRemote.Active := True; - ErrorCode := 0; - end; -end; - -procedure TfrmMain.Launch; -var - IniFile : TInifile; - iIcon : Integer; -begin - if Ready = False then - Exit; - - Running := False; - timerStart.Enabled := False; - - if App <> '' then - Execute(App) - else - begin - timerStart.Enabled := True; - end; -end; - - -procedure TfrmMain.Log(AText: String; Color: TColor); -begin - AddColouredLine(frmMain.Console,'Console: '+AText, Color); -end; - - -procedure TfrmMain.ConsoleResizeRequest(Sender: TObject; Rect: TRect); -var - ScrollMessage: TWMVScroll; - i : Integer; -begin - ScrollMessage.Msg := WM_VScroll; - - for i := 0 to Console.Lines.Count do - begin - ScrollMessage.ScrollCode := sb_LineDown; - ScrollMessage.Pos := 0; - Console.Dispatch(ScrollMessage); - end; -end; - -procedure TfrmMain.comCommandKeyDown(Sender: TObject; var Key: Word; - Shift: TShiftState); -begin - if key = VK_RETURN then - begin - if frmMain.ConsoleCommand(comCommand.Text) then - begin - key := 0; - Exit; - end; - - // send command line on Enter Key - RC_LineIn(comCommand.Text); - AddHistoryItem(comCommand.Text); - comCommand.Text := ''; - key:=0; - Exit; - end; - - if key = VK_F3 then - begin - if comCommand.Items.Count > 0 then - comCommand.ItemIndex := comCommand.Items.Count -1; - Key := 0; - Exit; - end; - -end; - -procedure TfrmMain.clientSockConnecting(Sender: TObject; - Socket: TCustomWinSocket); -begin - if clientSock.Port = 8085 then - begin - Log('Establishing Connection to WS',clGreen); - end; - - if clientSock.Port = 8089 then - begin - Log('Checking For Listening Console',clGreen); - end; -end; - -procedure TfrmMain.AddHistoryItem(Item: String); -begin - with comCommand do - begin - if Items.IndexOf(Item) = -1 then - begin - Items.Add(Item); - end; - end; -end; - -function TfrmMain.ConsoleCommand(AString: String): Boolean; -begin - Result := False; - AString := UpperCase(AString); - - if (AString = '!QUIT') or (AString = '!EXIT') then - begin - Result := True; - ShutDown; - Sleep(1000); - Close; - end; - -end; - -procedure TfrmMain.SetupIcons; -var - i : Integer; -begin - cbexIcon.Clear; - - for i := 0 to imgList.Count - 1 do - begin - cbexIcon.ItemsEx.AddItem('',i,i,i,0,nil); - end; - -end; - -procedure TfrmMain.SetIcon(AIndex : Integer; AUpdateINI : Boolean = True); -var - IniFile : TInifile; -begin - try - IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Settings.INI'); - if AUpdateINI then - IniFile.WriteInteger('Look','Icon',AIndex); - - with imgList do - begin - GetIcon(AIndex, Application.Icon); - TrayIcon.IconIndex := AIndex; - end; - cbexIcon.ItemIndex := AIndex; - finally - if AUpdateINI then - begin - IniFile.UpdateFile; - comCommand.SetFocus; - end; - IniFile.Free; - end; -end; - -procedure TfrmMain.LoadSettings; -var - IniFile : TInifile; - iIcon : Integer; -begin - try - //TT: Read from Inifile for the path the file we want. - IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Settings.INI'); - App := IniFile.ReadString('Execute','Application',''); - if App = '' then - begin - if FileExists(ExtractFilePath(Application.ExeName)+'pseuwow.exe') then - begin - App := ExtractFilePath(Application.ExeName)+'pseuwow.exe'; - pnlTop.Hide; - end - else - pnlTop.Show; - end; - IniFile.WriteString('Execute','Application',App); - - //TT: Read Tray Icon, Nice for those of us who more than one session at a time! - iIcon := IniFile.ReadInteger('Look','Icon',-1); - - if (iIcon = -1) then - IniFile.WriteInteger('Look','Icon',0); - - SetIcon(iIcon, False); - - finally - IniFile.UpdateFile; - IniFile.Free; - end; -end; - -procedure TfrmMain.cbexIconChange(Sender: TObject); -begin - if Ready then - SetIcon(cbexIcon.ItemIndex); -end; - -procedure TfrmMain.LoadPseuSettings(AConFile : string); -var - fFile : textfile; - sBuffer : string; - sRes : string; -begin - if FileExists(AConFile) then - begin - AssignFile(fFile, AConFile); - Reset(fFile); - - while not(Eof(fFile)) do - begin - sRes := ''; - - Readln(fFile, sBuffer); - - if EvaluateProperty(sBuffer, 'charname=', sRes) then - begin - txtChar.Caption := sRes; - Application.Title := sRes + ' - PseuWoW frmMain.Console'; - TrayIcon.Hint := Application.Title; - end; - end; - end; - CloseFile(fFile); - - comCommand.SetFocus; -end; - -end. +unit fMain; + +interface + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, RedirectConsole, ExtCtrls, IniFiles, ScktComp, JvComponentBase, + JvTrayIcon, ComCtrls, modRichEdit, StrUtils, ImgList, modSCPUtils, SyncObjs; + +type + TMsgType = (mtUnknown = 0, mtChat = 1, mtWhisper, mtReply, mtSysMsg, mtMOTD, mtEmote); + + TPseuWowCMD = (pwUnknown = 0, pwSay = 1); + + TLogItem = class + MsgType : TMsgType; + LogMessage : string; + end; + + + TLogThread = class(TThread) + protected + procedure Execute; override; + public + LogList : TThreadList; + currMessage : string; + currCommand : TPseuWowCMD; + critWrite : TCriticalSection; + + constructor Create; + destructor Destroy; override; + + procedure AddMessage(AMsg : string); + procedure SyncWrite(); + + procedure WriteFromPseWow(AString : String); + end; + + TfrmMain = class(TForm) + pnlTop: TPanel; + txtExe: TEdit; + btnRun: TButton; + btnExit: TButton; + servRemote: TServerSocket; + timerStart: TTimer; + clientSock: TClientSocket; + TrayIcon: TJvTrayIcon; + Console: TRichEdit; + imgList: TImageList; + pnlBottom: TPanel; + grpCmd: TGroupBox; + comCommand: TComboBox; + pnlSessionTop: TPanel; + cbexIcon: TComboBoxEx; + txtChar: TStaticText; + chkCleanMessages: TCheckBox; + pnlTestColor: TPanel; + procedure btnRunClick(Sender: TObject); + procedure btnExitClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); + procedure timerStartTimer(Sender: TObject); + procedure servRemoteClientRead(Sender: TObject; + Socket: TCustomWinSocket); + procedure FormDestroy(Sender: TObject); + procedure clientSockConnect(Sender: TObject; Socket: TCustomWinSocket); + procedure clientSockError(Sender: TObject; Socket: TCustomWinSocket; + ErrorEvent: TErrorEvent; var ErrorCode: Integer); + procedure ConsoleResizeRequest(Sender: TObject; Rect: TRect); + procedure comCommandKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure clientSockConnecting(Sender: TObject; + Socket: TCustomWinSocket); + procedure cbexIconChange(Sender: TObject); + private + { Private declarations } + Logger : TLogThread; + + App : String; + Running : Boolean; + Ready : Boolean; + + function ConsoleCommand(AString : String):Boolean; + + procedure LoadSettings; + procedure SetupIcons; + procedure SetIcon(AIndex : Integer; AUpdateINI : Boolean = True); + procedure LoadPseuSettings(AConFile : string); + + procedure ShutDown; + procedure Execute(AFile: String); + procedure Launch; + procedure Log(AText: String; Color : TColor = clAqua); + + procedure AddHistoryItem(Item : String); + + public + { Public declarations } + end; + +var + frmMain: TfrmMain; + +implementation +{$R *.DFM} + + +procedure MyLineOut(s: string); // Output procedure +begin + frmMain.Logger.AddMessage(s); +end; + +{---------TLogThread-----------------------------------------------------------\ +\------------------------------------------------------------------------------} + +procedure TLogThread.AddMessage(AMsg: string); +var + NewItem : TLogItem; +begin + NewItem := TLogItem.Create; + NewItem.MsgType := mtUnknown; + NewItem.LogMessage := AMsg; + + LogList.Add(NewItem); +end; + +constructor TLogThread.Create; +begin + inherited Create(true); + + currCommand := pwUnknown; + + LogList := TThreadList.Create; + critWrite := TCriticalSection.Create; +end; + +destructor TLogThread.Destroy; +begin + FreeAndNil(LogList); + FreeAndNil(critWrite); + inherited; +end; + +procedure TLogThread.Execute; +var + List : TList; + oItem : TLogItem; +begin + currMessage := ''; + + while not (Terminated) do + begin + List := LogList.LockList; + LogList.UnlockList; + + while List.Count > 0 do + begin + oItem := TLogItem(List[0]); + + //Do the Stuff + + //If the case of sysmsg that hasn't given |r and we get a new message + //with in it, write the current message + if (currMessage <> '') and (AnsiPos('', oItem.LogMessage) <> 0) then + begin + currMessage := currMessage + '|r'; + Synchronize(SyncWrite); + currMessage := ''; + end; + + currMessage := Trim(currMessage + oItem.LogMessage); + Synchronize(SyncWrite); + + LogList.Remove(oItem); + oItem.Free; + end; + + //TT: If we still have something in the buffer just write it + if currMessage <> '' then + begin + //In the case of a SYSMSG without |r + if AnsiPos('|r',currMessage) = 0 then + currMessage := currMessage + '|r'; + Synchronize(SyncWrite); + end; + + SleepEx(100, True); + end; +end; + +procedure TLogThread.SyncWrite; +begin + critWrite.Acquire; + WriteFromPseWow(currMessage); + critWrite.Release; +end; + +procedure TLogThread.WriteFromPseWow(AString: String); +var + mt : TMsgType; + iPos, iPos2 : Integer; + bEOL : Boolean; + NewCommand : TPseuWowCMD; +begin + //TT: Assume we have EOL + bEOL := True; + NewCommand := pwUnknown; + + //TT: Remove the current command display to minimise spam + if frmMain.chkCleanMessages.Checked then + begin + //Get Our New Command + if AnsiPos(':', AString) <> 0 then + NewCommand := pwSay; + + //May cause a problem if there is more than cmd data in a received string + //if (currCommand <> pwUnknown) and (NewCommand = currCommand) then + // Exit; + + //We have a new command + if (NewCommand = pwUnknown) and (currCommand <> pwUnknown) then + begin + //Remove redundent PW Command Text + if (currCommand = pwSay) then + AnsiReplaceText(AString, '', ''); + end + else + currCommand := NewCommand; + end; + + try + if Trim(AString) <> '' then + begin + + if LeftStr(AString, 8) = 'SYSMSG: ' then + begin + //Check for end of line |r + if AnsiPos('|r',AString) = 0 then + begin + bEOL := False; + Exit; + end; + + AString := AnsiReplaceText(AString,'|r',''); + + + if frmMain.chkCleanMessages.Checked then + begin + AString := AnsiReplaceText(AString,'SYSMSG: ',''); + AString := AnsiReplaceText(AString, '"', ''); + end; + + //Clean Ups for Say Outputs like lookup etc. + if frmMain.chkCleanMessages.Checked then + begin + if AnsiContainsText(AString, '|Hquest') then + begin + AString := AddHilightedItem(AString,'quest'); + end; + + if AnsiContainsText(AString, '|Hitem') then + begin + AString := AddHilightedItem(AString,'item'); + end; + + if AnsiContainsText(AString, '|Htele') then + begin + AString := AddHilightedItem(AString,'tele'); + end; + + if AnsiContainsText(AString, '|Hspell') then + begin + AString := AddHilightedItem(AString,'spell'); + end; + + if AnsiContainsText(AString, '|Hcreature') then + begin + AString := AddHilightedItem(AString,'creature'); + end; + + if AnsiContainsText(AString, '|Hobject') then + begin + AString := AddHilightedItem(AString,'object'); + end; + + end; + + AddColourToLine(frmMain.Console,AString, ); + Exit; + end; + + if frmMain.chkCleanMessages.Checked then + AString := AnsiReplaceText(AString, '"', ''); + + AString := AnsiReplaceText(AString,'|r',''); + + if LeftStr(AString, 6) = 'CHAT: ' then + begin + if frmMain.chkCleanMessages.Checked then + AString := AnsiReplaceText(AString,'CHAT: ',''); + + AddColourToLine(frmMain.Console, AString, clWhite); + Exit; + end; + + //Are we doing clean messages? + if frmMain.chkCleanMessages.Checked then + begin + AnsiReplaceText(AString,'"',''); + end; + + //TT: Check for known string headers and color accordingly + if LeftStr(AString, 6) = 'WHISP:' then + begin + if frmMain.chkCleanMessages.Checked then + AString := AnsiReplaceText(AString,'WHISP: ',''); + AddColouredLine(frmMain.Console,AString, $00FB00FB); + Exit; + end; + + if LeftStr(AString, 3) = 'TO ' then + begin + if frmMain.chkCleanMessages.Checked then + AString := AnsiReplaceText(AString,'TO ',''); + + AddColouredLine(frmMain.Console,AString, $00FB00FB); + Exit; + end; + + if LeftStr(AString, 7) = 'EMOTE: ' then + begin + if frmMain.chkCleanMessages.Checked then + AString := AnsiReplaceText(AString,'EMOTE: ',''); + AddColouredLine(frmMain.Console,AString, clYellow); + Exit; + end; + + if LeftStr(AString, 6) = 'MOTD: ' then + begin + if frmMain.chkCleanMessages.Checked then + AString := AnsiReplaceText(AString,'MOTD: ',''); + + AddColouredLine(frmMain.Console,AString, clAqua); + Exit; + end; + + //This doesnt ADD any color at the moment it just seems to clean up the string a bit + AddColourToLine(frmMain.Console,AString); + end; + finally + if bEOL then + currMessage := ''; + end; +end; + + +{---------TfrmMain-------------------------------------------------------------\ +\------------------------------------------------------------------------------} + +procedure TfrmMain.FormCreate(Sender: TObject); +begin + RC_LineOut:=MyLineOut; // set Output + + Logger := TLogThread.Create; + Logger.Resume; + + SetupIcons; + LoadSettings; + Ready := False; +end; + +procedure TfrmMain.btnRunClick(Sender: TObject); +var + IniFile : TInifile; +begin + IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Settings.INI'); + IniFile.WriteString('Execute','Application',txtExe.Text); + IniFile.UpdateFile; + IniFile.Free; + RC_Run(txtExe.text); // run frmMain.Console program +end; + +procedure TfrmMain.btnExitClick(Sender: TObject); +begin + ShutDown(); +end; + +procedure TfrmMain.ShutDown; +begin + Log('Shut down PseuWow Process',clRed); + RC_LineIn('!'); + RC_LineIn('quit'); + Sleep(3000); +end; + +procedure TfrmMain.Execute(AFile : String); +begin + //TT: Get Info from PseuWow.conf + LoadPseuSettings(ExtractFilePath(AFile)+'\conf\PseuWoW.conf'); + + //TT: See if we already have a server running + with clientSock do + begin + Port := 8089; + Open; + end; + + + Running := True; + pnlTop.Hide; + comCommand.SetFocus; + RC_Run(AFile); + +end; + +procedure TfrmMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean); +begin + if RC_ExitCode = STILL_ACTIVE then + begin + ShutDown; + CanClose := True; + end; +end; + +procedure TfrmMain.timerStartTimer(Sender: TObject); +begin + timerStart.Enabled := False; + if Ready then + begin + //TrayIcon.HideApplication; + Launch; + Exit; + end + else + begin + if clientSock.Active = false then + clientSock.Active := True; + end; + + timerStart.Enabled := True; +end; + +procedure TfrmMain.servRemoteClientRead(Sender: TObject; + Socket: TCustomWinSocket); +begin + RC_LineIn('!'); + RC_LineIn(Socket.ReceiveText); + Log('Received Remote Commad: ' + Socket.ReceiveText, clGreen ); +end; + +procedure TfrmMain.FormDestroy(Sender: TObject); +begin + Logger.Terminate; + FreeAndNil(Logger); + + servRemote.Active := False; +end; + +procedure TfrmMain.clientSockConnect(Sender: TObject; + Socket: TCustomWinSocket); +begin + + //World Server Check + if clientSock.Port = 8085 then + begin + Ready := True; + clientSock.Active := False; + Log('**** WS Is Ready For Connections ****'); + Launch; + end; + + //Checking If We Have A listening Console + if clientSock.Port = 8089 then + begin + Log('**** Already Listening ****'); + servRemote.Active := False; + end; + +end; + +procedure TfrmMain.clientSockError(Sender: TObject; + Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; + var ErrorCode: Integer); +begin + //World Server Check + if clientSock.Port = 8085 then + begin + Ready := False; + clientSock.Active := False; + Log('Still Waiting For Server',clMaroon); + ErrorCode := 0; + end + else + begin + Log('No Listening Console', clGreen); + servRemote.Active := True; + ErrorCode := 0; + end; +end; + +procedure TfrmMain.Launch; +var + IniFile : TInifile; + iIcon : Integer; +begin + if Ready = False then + Exit; + + Running := False; + timerStart.Enabled := False; + + if App <> '' then + Execute(App) + else + begin + timerStart.Enabled := True; + end; +end; + + +procedure TfrmMain.Log(AText: String; Color: TColor); +begin + AddColouredLine(frmMain.Console,'Console: '+AText, Color); +end; + + +procedure TfrmMain.ConsoleResizeRequest(Sender: TObject; Rect: TRect); +var + ScrollMessage: TWMVScroll; + i : Integer; +begin + ScrollMessage.Msg := WM_VScroll; + + for i := 0 to Console.Lines.Count do + begin + ScrollMessage.ScrollCode := sb_LineDown; + ScrollMessage.Pos := 0; + Console.Dispatch(ScrollMessage); + end; +end; + +procedure TfrmMain.comCommandKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if key = VK_RETURN then + begin + if frmMain.ConsoleCommand(comCommand.Text) then + begin + key := 0; + Exit; + end; + + // send command line on Enter Key + RC_LineIn(comCommand.Text); + AddHistoryItem(comCommand.Text); + comCommand.Text := ''; + key:=0; + Exit; + end; + + if key = VK_F3 then + begin + if comCommand.Items.Count > 0 then + comCommand.ItemIndex := comCommand.Items.Count -1; + Key := 0; + Exit; + end; + +end; + +procedure TfrmMain.clientSockConnecting(Sender: TObject; + Socket: TCustomWinSocket); +begin + if clientSock.Port = 8085 then + begin + Log('Establishing Connection to WS',clGreen); + end; + + if clientSock.Port = 8089 then + begin + Log('Checking For Listening Console',clGreen); + end; +end; + +procedure TfrmMain.AddHistoryItem(Item: String); +begin + with comCommand do + begin + if Items.IndexOf(Item) = -1 then + begin + Items.Add(Item); + end; + end; +end; + +function TfrmMain.ConsoleCommand(AString: String): Boolean; +begin + Result := False; + AString := UpperCase(AString); + + if (AString = '!QUIT') or (AString = '!EXIT') then + begin + Result := True; + ShutDown; + Sleep(1000); + Close; + end; + +end; + +procedure TfrmMain.SetupIcons; +var + i : Integer; +begin + cbexIcon.Clear; + + for i := 0 to imgList.Count - 1 do + begin + cbexIcon.ItemsEx.AddItem('',i,i,i,0,nil); + end; + +end; + +procedure TfrmMain.SetIcon(AIndex : Integer; AUpdateINI : Boolean = True); +var + IniFile : TInifile; +begin + try + IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Settings.INI'); + if AUpdateINI then + IniFile.WriteInteger('Look','Icon',AIndex); + + with imgList do + begin + GetIcon(AIndex, Application.Icon); + TrayIcon.IconIndex := AIndex; + end; + cbexIcon.ItemIndex := AIndex; + finally + if AUpdateINI then + begin + IniFile.UpdateFile; + comCommand.SetFocus; + end; + IniFile.Free; + end; +end; + +procedure TfrmMain.LoadSettings; +var + IniFile : TInifile; + iIcon : Integer; +begin + try + //TT: Read from Inifile for the path the file we want. + IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Settings.INI'); + App := IniFile.ReadString('Execute','Application',''); + if App = '' then + begin + if FileExists(ExtractFilePath(Application.ExeName)+'pseuwow.exe') then + begin + App := ExtractFilePath(Application.ExeName)+'pseuwow.exe'; + pnlTop.Hide; + end + else + pnlTop.Show; + end; + IniFile.WriteString('Execute','Application',App); + + //TT: Read Tray Icon, Nice for those of us who more than one session at a time! + iIcon := IniFile.ReadInteger('Look','Icon',-1); + + if (iIcon = -1) then + IniFile.WriteInteger('Look','Icon',0); + + SetIcon(iIcon, False); + + finally + IniFile.UpdateFile; + IniFile.Free; + end; +end; + +procedure TfrmMain.cbexIconChange(Sender: TObject); +begin + if Ready then + SetIcon(cbexIcon.ItemIndex); +end; + +procedure TfrmMain.LoadPseuSettings(AConFile : string); +var + fFile : textfile; + sBuffer : string; + sRes : string; +begin + if FileExists(AConFile) then + begin + AssignFile(fFile, AConFile); + Reset(fFile); + + while not(Eof(fFile)) do + begin + sRes := ''; + + Readln(fFile, sBuffer); + + if EvaluateProperty(sBuffer, 'charname=', sRes) then + begin + txtChar.Caption := sRes; + Application.Title := sRes + ' - PseuWoW frmMain.Console'; + TrayIcon.Hint := Application.Title; + end; + end; + end; + CloseFile(fFile); + + comCommand.SetFocus; +end; + +end. diff --git a/src/tools/PseuWoWConsole/src/modRichEdit.pas b/src/tools/PseuWoWConsole/src/modRichEdit.pas index ce091ce..f1e32c0 100644 --- a/src/tools/PseuWoWConsole/src/modRichEdit.pas +++ b/src/tools/PseuWoWConsole/src/modRichEdit.pas @@ -1,95 +1,95 @@ -unit modRichEdit; - -interface -uses SysUtils, Classes, StdCtrls, ComCtrls, Graphics, StrUtils, Windows; - -procedure AddColouredLine(ARichEdit : TRichEdit; AText : String; AColor : TColor); -procedure AddColourToLine(ARichEdit : TRichEdit; AText : String; ADefautColor : TColor = clLime); - -function HexToColor(sColor : String): TColor; -function AddHilightedItem(AString, AHText : String): string; - -implementation - -procedure AddColouredLine(ARichEdit : TRichEdit; AText : String; AColor : TColor); -begin - with ARichEdit do - begin - SelStart := Length(Text); - SelAttributes.Color := AColor; - SelAttributes.Size := 8; - Lines.Add(AText); - end; -end; - -procedure AddColourToLine(ARichEdit : TRichEdit; AText : String; ADefautColor : TColor); -var - i : Integer; - myColor : TColor; - sTemp : String; -begin - myColor := ADefautColor; - - i := AnsiPos('|c',LowerCase(AText)); - - //TODO read multicolured lines - - while i <> 0 do - begin - if UpperCase(Copy(AText, i, 4)) = '|CFF' then - begin - with ARichEdit do - begin - //Get the color - |cffFF6600 - sTemp := Copy(AText,i, 10 ); - sTemp := AnsiReplaceText(sTemp,'|CFF',''); - - myColor := HexToColor(sTemp); - AText := AnsiReplaceText(AText,'|CFF'+sTemp,''); -{ - SelStart := Length(AText) - i; - SelAttributes.Color := myColor; - SelAttributes.Size := 8; -} - end; - - i := AnsiPos('|c',LowerCase(AText)); - end - else - break; - end; - - AddColouredLine(ARichEdit, AText, myColor); -end; - -function HexToColor(sColor : String): TColor; -begin - sColor := UpperCase(sColor); - Result := RGB( - StrToInt('$'+Copy(sColor,1,2)), - StrToInt('$'+Copy(sColor,3,2)), - StrToInt('$'+Copy(sColor,4,2)) - ); -end; - -function AddHilightedItem(AString, AHText : String): string; -var - iPos, iPos2 : Integer; -begin - if AnsiContainsText(AString, '|H'+AHText) then - begin - iPos := AnsiPos('|H' + AHText, AString); - iPos2 := AnsiPos(']', AString); - - Result := Copy(AString, 0, iPos - 1); - - iPos := AnsiPos('[', AString); - - Result := Result + Copy(AString, iPos, iPos2); - Result := AnsiReplaceText(Result, '|h',''); - end; - -end; - - -end. +unit modRichEdit; + +interface +uses SysUtils, Classes, StdCtrls, ComCtrls, Graphics, StrUtils, Windows; + +procedure AddColouredLine(ARichEdit : TRichEdit; AText : String; AColor : TColor); +procedure AddColourToLine(ARichEdit : TRichEdit; AText : String; ADefautColor : TColor = clLime); + +function HexToColor(sColor : String): TColor; +function AddHilightedItem(AString, AHText : String): string; + +implementation + +procedure AddColouredLine(ARichEdit : TRichEdit; AText : String; AColor : TColor); +begin + with ARichEdit do + begin + SelStart := Length(Text); + SelAttributes.Color := AColor; + SelAttributes.Size := 8; + Lines.Add(AText); + end; +end; + +procedure AddColourToLine(ARichEdit : TRichEdit; AText : String; ADefautColor : TColor); +var + i : Integer; + myColor : TColor; + sTemp : String; +begin + myColor := ADefautColor; + + i := AnsiPos('|c',LowerCase(AText)); + + //TODO read multicolured lines + + while i <> 0 do + begin + if UpperCase(Copy(AText, i, 4)) = '|CFF' then + begin + with ARichEdit do + begin + //Get the color - |cffFF6600 + sTemp := Copy(AText,i, 10 ); + sTemp := AnsiReplaceText(sTemp,'|CFF',''); + + myColor := HexToColor(sTemp); + AText := AnsiReplaceText(AText,'|CFF'+sTemp,''); +{ + SelStart := Length(AText) - i; + SelAttributes.Color := myColor; + SelAttributes.Size := 8; +} + end; + + i := AnsiPos('|c',LowerCase(AText)); + end + else + break; + end; + + AddColouredLine(ARichEdit, AText, myColor); +end; + +function HexToColor(sColor : String): TColor; +begin + sColor := UpperCase(sColor); + Result := RGB( + StrToInt('$'+Copy(sColor,1,2)), + StrToInt('$'+Copy(sColor,3,2)), + StrToInt('$'+Copy(sColor,4,2)) + ); +end; + +function AddHilightedItem(AString, AHText : String): string; +var + iPos, iPos2 : Integer; +begin + if AnsiContainsText(AString, '|H'+AHText) then + begin + iPos := AnsiPos('|H' + AHText, AString); + iPos2 := AnsiPos(']', AString); + + Result := Copy(AString, 0, iPos - 1); + + iPos := AnsiPos('[', AString); + + Result := Result + Copy(AString, iPos, iPos2); + Result := AnsiReplaceText(Result, '|h',''); + end; + +end; + + +end. diff --git a/src/tools/PseuWoWConsole/src/modSCPUtils.pas b/src/tools/PseuWoWConsole/src/modSCPUtils.pas index 9848e81..355d756 100644 --- a/src/tools/PseuWoWConsole/src/modSCPUtils.pas +++ b/src/tools/PseuWoWConsole/src/modSCPUtils.pas @@ -1,600 +1,600 @@ -unit modSCPUtils; - -interface - uses Sysutils, Classes, StrUtils, Dialogs; - - function GetHeader(AString: String): String; - function EvaluateStringAsHeader(AString, AHeader : String): Boolean; - function EvaluateProperty(ABuffer, AProp : String; var sValue : String): Boolean; - function EvaluatePropertyAsInt(ABuffer, AProp : String; var iValue : Integer): Boolean; - function UpdateProperty(AProperty, Value: String; AList : TStringList ; AddProperty : Boolean = true; AllowMultiples : Boolean = false; PropUpperCase : Boolean = True): Boolean; - function DeleteProperty(AProperty: String; AList : TStringList; Multiples : Boolean = false): Boolean; - function StripCommentsFromString(AString : String): String; - function GetNumbersFromString(AString, ASeparator, AHeader :String; AElements : Integer; var ALeftOver : String; AllowBlank : Boolean = False; DoTrim : Boolean = True): TStringList; - function GetCustomArray(AString : String; AStringListofArray: TStrings; AElementIndex, AElementCount : Integer): String; - function GetRandom(AString: String; GetValuesInBetween : Boolean = True): String; - function GetString(AMin, AMax: String; Seperator : String = ' '): String; overload; - function GetString(AStringList : TStringList; Seperator: String = ' '): String; overload; - function MakeList(AStringList : TStringList; AProp : String): TStringList; -{ - Moved into TSCPItem - function GetList(AStringList : TStringList; AProp : String): TStringList; -} - function AddProp(AProp, AValue : String; AList : TStringList): Boolean; overload; - function AddProp(AStrings: TStringList; AList : TStringList): Boolean; overload; - function AddToList(AList : TStringList; AValue : String): Boolean; - function GetFloat(AString : String): Extended; - function CountCharOccurences(const S: string; const ch: string): Integer; - function CountSubStringOccurences(const subtext: string; Text: string): Integer; - function CountPropOccurences(AProp : String; AList : TStringList): Integer; - -implementation - -function GetHeader(AString: String): String; -var - i : Integer; -begin - Result := ''; - - //[item or [creature etc. - if AnsiPos('[', AString) <> 0 then - begin - i := AnsiPos(' ', AString); - if i <> 0 then - begin - Result := Copy(AString,0,i-1); - Exit; - end; - end; - - i := AnsiPos('=', AString); - if i <> 0 then - begin - Result := Copy(AString,0,i-1); - Exit; - end; - -end; - -function EvaluateStringAsHeader(AString, AHeader: String): Boolean; -begin - Result := False; - - //Remove the = for simpler comparison - if AnsiContainsText(AHeader,'=') then - AHeader := AnsiReplaceStr(AHeader,'=',''); - - AHeader := Trim(AHeader); - AString := Trim(AString); - - AHeader := UpperCase(AHeader); - AString := UpperCase(AString); - - if LeftStr(AString,(Length(AHeader))) = AHeader then - begin - Result := True; - end; - - //For my Number Hack! - if (LeftStr(AHeader,1) = '~') and (LeftStr(AString,1) = '~') then - Result := True; - -end; - -function EvaluateProperty(ABuffer, AProp: String; - var sValue: String): Boolean; -var - i : Integer; -begin - sValue := ''; - - i := Length(AProp); - Result := False; - - if (UpperCase(Copy(ABuffer, 0, i))) = (UpperCase(AProp)) then - begin - Result := True; - sValue := Trim(RightStr(ABuffer, (Length(ABuffer) - i))); - end; -end; - -function EvaluatePropertyAsInt(ABuffer, AProp : String; var iValue : Integer): Boolean; -var - sTemp : String; -begin - Result := False; - - if (EvaluateProperty(ABuffer, AProp, sTemp)) and (TryStrToInt(sTemp, iValue)) then - begin - Result := True; - end; -end; - -function UpdateProperty(AProperty, Value: String; AList : TStringList ; AddProperty : Boolean = true; AllowMultiples : Boolean = false; PropUpperCase : Boolean = True): Boolean; -var - i, j, L1, L2, iFound : integer; - sTemp, sValue : String; - bFound : Boolean; - slFound : TStringList; -begin - try - slFound := TStringList.Create; - slFound.Clear; - - //For Neatness - if (PropUpperCase = True) then - AProperty := Trim(UpperCase(AProperty)) - else - AProperty := Trim(AProperty); - - Value := Trim(Value); - - if AProperty = '' then - Exit; - - for i := 0 to AList.Count - 1 do - begin - if EvaluateProperty(AList.Strings[i],AProperty,sTemp) then - begin - slFound.Add(IntToStr(i)); - j := i; - bFound := True; - if not(AllowMultiples) then - Break; - end; - end; - - //delte the property - if Value = '' then - begin - AList.Delete(j); - Exit; - end; - - if not(bFound) and not(AddProperty) then - Exit; - - sValue := AProperty+'='+Value; - - if not(bFound) then //not found then add it - begin - AList.Add(sValue); - end - else - begin //found then update it - if not(AllowMultiples) then // Only want a single instance of this boy - AList.Strings[j] := sValue - else - begin // as in EQUIP=0 or EQUIP=1 or Equip=2 - - for i := 0 to slFound.Count - 1 do - begin - iFound := StrToInt(slFound[i]); - L1 := (AnsiPos(' ',AList[iFound])) - 1; - L2 := (AnsiPos(' ',sValue)) - 1; - - if L1 <= 0 then - begin - AList.Add(sValue); - Exit; - end; - - if (UpperCase(Copy(AList[iFound],0, L1))) = (UpperCase(Copy(sValue,0, L2))) then - begin - AList[iFound] := sValue; - Exit; - end; - - end; - //ok we looked but it isn't there so add it - AList.Add(sValue); - end; - end; - finally - slFound.Free; - end; -end; - -function DeleteProperty(AProperty: String; AList : TStringList; - Multiples: Boolean): Boolean; -var - i : integer; - sTemp : string; -begin - for i := AList.Count - 1 downto 0 do - begin - if EvaluateProperty(AList[i],AProperty, sTemp) then - begin - AList.Delete(i); - if not(Multiples) then - Break; - end; - end; -end; - -function GetNumbersFromString(AString, ASeparator, AHeader :String; AElements : Integer; var ALeftOver : String; AllowBlank : Boolean = False; DoTrim : Boolean = True): TStringList; -var - iLength, iSubLength, iPos, iIndex, iLastCheck : Integer; - sTemp : String; - rArray : Array of Real; - oList : TStringList; -begin - if Result = nil then - Result := TStringList.Create - else - Result.Clear; - - //Hopefully this wont fux things up - AString := UTF8Decode(AString); - - - //A lazy way to tell it to look for everything - if AElements = 0 then - AElements := 100; - - //Check for Delim - if ASeparator = '[SPACE]' then - ASeparator := ' '; - - if ASeparator = '' then - ASeparator := ' '; - - if AllowBlank then - AElements := CountCharOccurences(AString, ASeparator); - - if AHeader <> '' then - AString := AnsiReplaceText((AString), (AHeader), ''); - if AHeader <> '' then - AString := AnsiReplaceText(AString, '=' ,''); - if AHeader <> '' then - AString := AnsiReplaceText(AString, '~',''); - if DoTrim then - AString := Trim(AString); - - SetLength(rArray, AElements); - - for iIndex := 0 to AElements - 1 do - begin - iPos := AnsiPos(ASeparator, AString); - - if AElements > 1 then //if we have mulitple elements - begin - if iIndex < (AElements - 1) then - begin - if iPos > 0 then - sTemp := LeftStr(AString, iPos - 1) - else - sTemp := AString; - end - else - sTemp := AString; - end - else - begin //if we only have one element - if iPos > 0 then - sTemp := LeftStr(AString, iPos - 1) - else - sTemp := AString; - end; - - //If we have processed all our elements make sure there aren't additional ones - if iIndex = (AElements - 1) then - begin - if ASeparator = '[SPACE]' then - iLastCheck := AnsiPos(' ', sTemp) - else - iLastCheck := AnsiPos(ASeparator, sTemp); - - if iLastCheck > 0 then - begin - //Removing Excess Elements from sTemp - sTemp := LeftStr(AString, iLastCheck - 1) - end; - end; - - if (sTemp = '') then - begin - if not(AllowBlank) then - Continue - else - Result.Add(sTemp); - end - else - Result.Add(sTemp); - - iLength := Length(AString); - iSubLength := Length(sTemp); - - if ASeparator = '[SPACE]' then - AString := RightStr(AString, (iLength - (iSubLength + 1 ))) - else - AString := RightStr(AString, (iLength - (iSubLength+(Length(ASeparator))))); - - if DoTrim then - AString := Trim(AString); - - end; - - ALeftOver := AString; - -end; - -function GetCustomArray(AString : String; AStringListofArray: TStrings; AElementIndex, AElementCount : Integer): String; -var - iIndex, iPos : Integer; - oStringList : TStringList; - sFNM : string; -begin - oStringList := TStringList.Create; - - for iIndex := 0 to (AStringListofArray.Count - 1) do - begin - if LeftStr(AStringListofArray.Strings[iIndex], (Length(AString)+1)) = AString + ' ' then - begin - AString := AnsiReplaceStr(AStringListofArray.Strings[iIndex][iIndex], AString + ' ', ''); - oStringList := GetNumbersFromString(AString, ' ', '', AElementCount, sFNM); - Result := oStringList.Strings[AElementIndex - 1]; - Exit; - end - end; - - - oStringList.Free; -end; - - -function GetRandom(AString: String; GetValuesInBetween : Boolean = True): String; -var - iPos, iTotal, iMin, iMax, iLast, iRange, iRand : Integer; - sBuffer : String; - sList : TStringList; -begin - try - sList := TStringList.Create; - - AString := AnsiReplaceText(AString,'..',' '); - AString := AnsiReplaceStr(AString,',',' '); - - AString := Trim(AString); - - iPos := AnsiPos(' ',AString); - - while iPos <> 0 do - begin - - sBuffer := (Copy(AString,0,(iPos-1))); - - sList.Add(sBuffer); - AString := (Copy(AString,iPos,(Length(AString)))); - AString := Trim(AString); - iPos := AnsiPos(' ',AString); - end; - - //Get the Last One - sList.Add(AString); - - if sList.Count > 1 then - begin - if GetValuesInBetween then //calc values between first and last - begin - iMin := StrToInt(sList.Strings[0]); - iLast := sList.Count - 1; - iMax := StrToInt(sList.Strings[iLast]); - iRange := iMax - iMin; - - if iRange <= 0 then - begin - Result := IntToStr(iMin); - Exit; - end; - - iRand := Round(Random(iRange)); - - Result := IntToStr(iMin + iRand); - - end - else - begin // select a random value in the list - iRand := Round(Random(sList.Count-1)); - sBuffer := sList.Strings[iRand]; - Result := sBuffer; - end; - end - else - begin - sBuffer := sList.Strings[0]; - result := sBuffer; - end; - - finally - sList.Free; - end; -end; - -function StripCommentsFromString(AString : String): String; -var - iComment : Integer; -begin - - if AString <> '' then - begin - iComment := AnsiPos('/',AString); - - //Remove comments - if iComment > 0 then - AString := Copy(AString,0,(iComment-1)); - - end; - - Result := Trim(AString); - -end; - -function GetString(AStringList: TStringList; - Seperator: String = ' '): String; -var - i : integer; -begin - Result := ''; - for i := 0 to AStringList.Count - 1 do - begin - Result := Result + AStringList[i]; - if i < (AStringList.Count - 1) then - Result := Result + Seperator; - end; -end; - -function GetString(AMin, AMax, Seperator: String): String; -begin - Result := ''; - - if (AMin <> '') and (AMin <> '0') and (AMax <> '') and (AMax <> '0') and (AMin <> AMax) then - begin - Result := AMin + Seperator + AMax; - end - else - //Induvidual - begin - if (AMin <> '') and (AMin <> '0') then - Result := AMin; - if (AMax <> '') and (AMax <> '0') then - Result := AMax; - end; -end; - -function MakeList(AStringList: TStringList; - AProp: String): TStringList; -var - i : Integer; -begin - Result := TStringList.Create; - - for i := 0 to AStringList.Count - 1 do - begin - Result.Add(AProp+'='+AStringList[i]); - end; -end; - -//Moved into TSCPItem -{ -function GetList(AStringList : TStringList; AProp : String): TStringList; -var - i : Integer; - sBuffer : String; -begin - Result := TStringList.Create; - - for i := 0 to AStringList.Count - 1 do - begin - if EvaluateProperty(AStringList[i], AProp, sBuffer) then - Result.Add(sBuffer) - end; - - if Result.Count = 0 then - begin - FreeAndNil(Result); - end; - - Result.Sort; -end; -} -function AddProp(AProp, AValue: String; AList : TStringList): Boolean; -var - i : integer; -begin - Result := False; - - if Trim(AValue) = '' then - Exit; - - if AnsiPos('=',AProp) = -1 then - AProp := AProp +'='; - - UpdateProperty(AProp,AValue,AList,true,false,false); - - Result := True; -end; - -function AddProp(AStrings: TStringList; AList : TStringList): Boolean; -begin - if AStrings.GetText <> '' then - AList.AddStrings(AStrings); -end; - -function AddToList(AList: TStringList; - AValue: String): Boolean; -begin - Result := False; - - if (AValue = '') or (AValue = '0') then - Exit; - - try - if not(Assigned(AList)) then - AList := TStringList.Create; - if AList.IndexOf(AValue) = -1 then - AList.Add(AValue); - except - Result := False; - //Raise the error - Exit; - end; - Result := True; -end; - -function GetFloat(AString : String): Extended; -var - Code: Integer; -begin - Val(AString, Result, Code); - - if Code <> 0 then - begin - MessageDlg('Error converting Float in '+AString+' position: ' + IntToStr(Code), mtWarning, [mbOk], 0); - Result := 0; - end; -end; - -function CountCharOccurences(const S: string; const ch: string): Integer; -var - buf: string; -begin - buf := S; - Result := 0; - {while Pos finds a blank} - while (Pos(ch, buf) > 0) do - begin - {copy the substrings before the blank in to Result} - Result := Result + 1; - buf := Copy(buf, Pos(ch, buf) + 1, Length(buf) - Pos(ch, buf)); - end; -end; - -//http://www.delphitricks.com/source-code/strings/count_the_number_of_occurrences_of_a_substring_within_a_string.html -function CountSubStringOccurences(const subtext: string; Text: string): Integer; -begin - if (Length(subtext) = 0) or (Length(Text) = 0) or (Pos(subtext, Text) = 0) then - Result := 0 - else - Result := (Length(Text) - Length(StringReplace(Text, subtext, '', [rfReplaceAll]))) div - Length(subtext); -end; - -function CountPropOccurences(AProp : String; AList : TStringList): Integer; -var - i : Integer; -begin - Result := 0; - - AProp := AnsiReplaceText(AProp, '=', ''); - - AList.CaseSensitive := False; - - for i := 0 to AList.Count - 1 do - begin - if AList.Names[i] = AProp then - Result := Result + 1; - end; -end; - -end. +unit modSCPUtils; + +interface + uses Sysutils, Classes, StrUtils, Dialogs; + + function GetHeader(AString: String): String; + function EvaluateStringAsHeader(AString, AHeader : String): Boolean; + function EvaluateProperty(ABuffer, AProp : String; var sValue : String): Boolean; + function EvaluatePropertyAsInt(ABuffer, AProp : String; var iValue : Integer): Boolean; + function UpdateProperty(AProperty, Value: String; AList : TStringList ; AddProperty : Boolean = true; AllowMultiples : Boolean = false; PropUpperCase : Boolean = True): Boolean; + function DeleteProperty(AProperty: String; AList : TStringList; Multiples : Boolean = false): Boolean; + function StripCommentsFromString(AString : String): String; + function GetNumbersFromString(AString, ASeparator, AHeader :String; AElements : Integer; var ALeftOver : String; AllowBlank : Boolean = False; DoTrim : Boolean = True): TStringList; + function GetCustomArray(AString : String; AStringListofArray: TStrings; AElementIndex, AElementCount : Integer): String; + function GetRandom(AString: String; GetValuesInBetween : Boolean = True): String; + function GetString(AMin, AMax: String; Seperator : String = ' '): String; overload; + function GetString(AStringList : TStringList; Seperator: String = ' '): String; overload; + function MakeList(AStringList : TStringList; AProp : String): TStringList; +{ + Moved into TSCPItem + function GetList(AStringList : TStringList; AProp : String): TStringList; +} + function AddProp(AProp, AValue : String; AList : TStringList): Boolean; overload; + function AddProp(AStrings: TStringList; AList : TStringList): Boolean; overload; + function AddToList(AList : TStringList; AValue : String): Boolean; + function GetFloat(AString : String): Extended; + function CountCharOccurences(const S: string; const ch: string): Integer; + function CountSubStringOccurences(const subtext: string; Text: string): Integer; + function CountPropOccurences(AProp : String; AList : TStringList): Integer; + +implementation + +function GetHeader(AString: String): String; +var + i : Integer; +begin + Result := ''; + + //[item or [creature etc. + if AnsiPos('[', AString) <> 0 then + begin + i := AnsiPos(' ', AString); + if i <> 0 then + begin + Result := Copy(AString,0,i-1); + Exit; + end; + end; + + i := AnsiPos('=', AString); + if i <> 0 then + begin + Result := Copy(AString,0,i-1); + Exit; + end; + +end; + +function EvaluateStringAsHeader(AString, AHeader: String): Boolean; +begin + Result := False; + + //Remove the = for simpler comparison + if AnsiContainsText(AHeader,'=') then + AHeader := AnsiReplaceStr(AHeader,'=',''); + + AHeader := Trim(AHeader); + AString := Trim(AString); + + AHeader := UpperCase(AHeader); + AString := UpperCase(AString); + + if LeftStr(AString,(Length(AHeader))) = AHeader then + begin + Result := True; + end; + + //For my Number Hack! + if (LeftStr(AHeader,1) = '~') and (LeftStr(AString,1) = '~') then + Result := True; + +end; + +function EvaluateProperty(ABuffer, AProp: String; + var sValue: String): Boolean; +var + i : Integer; +begin + sValue := ''; + + i := Length(AProp); + Result := False; + + if (UpperCase(Copy(ABuffer, 0, i))) = (UpperCase(AProp)) then + begin + Result := True; + sValue := Trim(RightStr(ABuffer, (Length(ABuffer) - i))); + end; +end; + +function EvaluatePropertyAsInt(ABuffer, AProp : String; var iValue : Integer): Boolean; +var + sTemp : String; +begin + Result := False; + + if (EvaluateProperty(ABuffer, AProp, sTemp)) and (TryStrToInt(sTemp, iValue)) then + begin + Result := True; + end; +end; + +function UpdateProperty(AProperty, Value: String; AList : TStringList ; AddProperty : Boolean = true; AllowMultiples : Boolean = false; PropUpperCase : Boolean = True): Boolean; +var + i, j, L1, L2, iFound : integer; + sTemp, sValue : String; + bFound : Boolean; + slFound : TStringList; +begin + try + slFound := TStringList.Create; + slFound.Clear; + + //For Neatness + if (PropUpperCase = True) then + AProperty := Trim(UpperCase(AProperty)) + else + AProperty := Trim(AProperty); + + Value := Trim(Value); + + if AProperty = '' then + Exit; + + for i := 0 to AList.Count - 1 do + begin + if EvaluateProperty(AList.Strings[i],AProperty,sTemp) then + begin + slFound.Add(IntToStr(i)); + j := i; + bFound := True; + if not(AllowMultiples) then + Break; + end; + end; + + //delte the property + if Value = '' then + begin + AList.Delete(j); + Exit; + end; + + if not(bFound) and not(AddProperty) then + Exit; + + sValue := AProperty+'='+Value; + + if not(bFound) then //not found then add it + begin + AList.Add(sValue); + end + else + begin //found then update it + if not(AllowMultiples) then // Only want a single instance of this boy + AList.Strings[j] := sValue + else + begin // as in EQUIP=0 or EQUIP=1 or Equip=2 + + for i := 0 to slFound.Count - 1 do + begin + iFound := StrToInt(slFound[i]); + L1 := (AnsiPos(' ',AList[iFound])) - 1; + L2 := (AnsiPos(' ',sValue)) - 1; + + if L1 <= 0 then + begin + AList.Add(sValue); + Exit; + end; + + if (UpperCase(Copy(AList[iFound],0, L1))) = (UpperCase(Copy(sValue,0, L2))) then + begin + AList[iFound] := sValue; + Exit; + end; + + end; + //ok we looked but it isn't there so add it + AList.Add(sValue); + end; + end; + finally + slFound.Free; + end; +end; + +function DeleteProperty(AProperty: String; AList : TStringList; + Multiples: Boolean): Boolean; +var + i : integer; + sTemp : string; +begin + for i := AList.Count - 1 downto 0 do + begin + if EvaluateProperty(AList[i],AProperty, sTemp) then + begin + AList.Delete(i); + if not(Multiples) then + Break; + end; + end; +end; + +function GetNumbersFromString(AString, ASeparator, AHeader :String; AElements : Integer; var ALeftOver : String; AllowBlank : Boolean = False; DoTrim : Boolean = True): TStringList; +var + iLength, iSubLength, iPos, iIndex, iLastCheck : Integer; + sTemp : String; + rArray : Array of Real; + oList : TStringList; +begin + if Result = nil then + Result := TStringList.Create + else + Result.Clear; + + //Hopefully this wont fux things up + AString := UTF8Decode(AString); + + + //A lazy way to tell it to look for everything + if AElements = 0 then + AElements := 100; + + //Check for Delim + if ASeparator = '[SPACE]' then + ASeparator := ' '; + + if ASeparator = '' then + ASeparator := ' '; + + if AllowBlank then + AElements := CountCharOccurences(AString, ASeparator); + + if AHeader <> '' then + AString := AnsiReplaceText((AString), (AHeader), ''); + if AHeader <> '' then + AString := AnsiReplaceText(AString, '=' ,''); + if AHeader <> '' then + AString := AnsiReplaceText(AString, '~',''); + if DoTrim then + AString := Trim(AString); + + SetLength(rArray, AElements); + + for iIndex := 0 to AElements - 1 do + begin + iPos := AnsiPos(ASeparator, AString); + + if AElements > 1 then //if we have mulitple elements + begin + if iIndex < (AElements - 1) then + begin + if iPos > 0 then + sTemp := LeftStr(AString, iPos - 1) + else + sTemp := AString; + end + else + sTemp := AString; + end + else + begin //if we only have one element + if iPos > 0 then + sTemp := LeftStr(AString, iPos - 1) + else + sTemp := AString; + end; + + //If we have processed all our elements make sure there aren't additional ones + if iIndex = (AElements - 1) then + begin + if ASeparator = '[SPACE]' then + iLastCheck := AnsiPos(' ', sTemp) + else + iLastCheck := AnsiPos(ASeparator, sTemp); + + if iLastCheck > 0 then + begin + //Removing Excess Elements from sTemp + sTemp := LeftStr(AString, iLastCheck - 1) + end; + end; + + if (sTemp = '') then + begin + if not(AllowBlank) then + Continue + else + Result.Add(sTemp); + end + else + Result.Add(sTemp); + + iLength := Length(AString); + iSubLength := Length(sTemp); + + if ASeparator = '[SPACE]' then + AString := RightStr(AString, (iLength - (iSubLength + 1 ))) + else + AString := RightStr(AString, (iLength - (iSubLength+(Length(ASeparator))))); + + if DoTrim then + AString := Trim(AString); + + end; + + ALeftOver := AString; + +end; + +function GetCustomArray(AString : String; AStringListofArray: TStrings; AElementIndex, AElementCount : Integer): String; +var + iIndex, iPos : Integer; + oStringList : TStringList; + sFNM : string; +begin + oStringList := TStringList.Create; + + for iIndex := 0 to (AStringListofArray.Count - 1) do + begin + if LeftStr(AStringListofArray.Strings[iIndex], (Length(AString)+1)) = AString + ' ' then + begin + AString := AnsiReplaceStr(AStringListofArray.Strings[iIndex][iIndex], AString + ' ', ''); + oStringList := GetNumbersFromString(AString, ' ', '', AElementCount, sFNM); + Result := oStringList.Strings[AElementIndex - 1]; + Exit; + end + end; + + + oStringList.Free; +end; + + +function GetRandom(AString: String; GetValuesInBetween : Boolean = True): String; +var + iPos, iTotal, iMin, iMax, iLast, iRange, iRand : Integer; + sBuffer : String; + sList : TStringList; +begin + try + sList := TStringList.Create; + + AString := AnsiReplaceText(AString,'..',' '); + AString := AnsiReplaceStr(AString,',',' '); + + AString := Trim(AString); + + iPos := AnsiPos(' ',AString); + + while iPos <> 0 do + begin + + sBuffer := (Copy(AString,0,(iPos-1))); + + sList.Add(sBuffer); + AString := (Copy(AString,iPos,(Length(AString)))); + AString := Trim(AString); + iPos := AnsiPos(' ',AString); + end; + + //Get the Last One + sList.Add(AString); + + if sList.Count > 1 then + begin + if GetValuesInBetween then //calc values between first and last + begin + iMin := StrToInt(sList.Strings[0]); + iLast := sList.Count - 1; + iMax := StrToInt(sList.Strings[iLast]); + iRange := iMax - iMin; + + if iRange <= 0 then + begin + Result := IntToStr(iMin); + Exit; + end; + + iRand := Round(Random(iRange)); + + Result := IntToStr(iMin + iRand); + + end + else + begin // select a random value in the list + iRand := Round(Random(sList.Count-1)); + sBuffer := sList.Strings[iRand]; + Result := sBuffer; + end; + end + else + begin + sBuffer := sList.Strings[0]; + result := sBuffer; + end; + + finally + sList.Free; + end; +end; + +function StripCommentsFromString(AString : String): String; +var + iComment : Integer; +begin + + if AString <> '' then + begin + iComment := AnsiPos('/',AString); + + //Remove comments + if iComment > 0 then + AString := Copy(AString,0,(iComment-1)); + + end; + + Result := Trim(AString); + +end; + +function GetString(AStringList: TStringList; + Seperator: String = ' '): String; +var + i : integer; +begin + Result := ''; + for i := 0 to AStringList.Count - 1 do + begin + Result := Result + AStringList[i]; + if i < (AStringList.Count - 1) then + Result := Result + Seperator; + end; +end; + +function GetString(AMin, AMax, Seperator: String): String; +begin + Result := ''; + + if (AMin <> '') and (AMin <> '0') and (AMax <> '') and (AMax <> '0') and (AMin <> AMax) then + begin + Result := AMin + Seperator + AMax; + end + else + //Induvidual + begin + if (AMin <> '') and (AMin <> '0') then + Result := AMin; + if (AMax <> '') and (AMax <> '0') then + Result := AMax; + end; +end; + +function MakeList(AStringList: TStringList; + AProp: String): TStringList; +var + i : Integer; +begin + Result := TStringList.Create; + + for i := 0 to AStringList.Count - 1 do + begin + Result.Add(AProp+'='+AStringList[i]); + end; +end; + +//Moved into TSCPItem +{ +function GetList(AStringList : TStringList; AProp : String): TStringList; +var + i : Integer; + sBuffer : String; +begin + Result := TStringList.Create; + + for i := 0 to AStringList.Count - 1 do + begin + if EvaluateProperty(AStringList[i], AProp, sBuffer) then + Result.Add(sBuffer) + end; + + if Result.Count = 0 then + begin + FreeAndNil(Result); + end; + + Result.Sort; +end; +} +function AddProp(AProp, AValue: String; AList : TStringList): Boolean; +var + i : integer; +begin + Result := False; + + if Trim(AValue) = '' then + Exit; + + if AnsiPos('=',AProp) = -1 then + AProp := AProp +'='; + + UpdateProperty(AProp,AValue,AList,true,false,false); + + Result := True; +end; + +function AddProp(AStrings: TStringList; AList : TStringList): Boolean; +begin + if AStrings.GetText <> '' then + AList.AddStrings(AStrings); +end; + +function AddToList(AList: TStringList; + AValue: String): Boolean; +begin + Result := False; + + if (AValue = '') or (AValue = '0') then + Exit; + + try + if not(Assigned(AList)) then + AList := TStringList.Create; + if AList.IndexOf(AValue) = -1 then + AList.Add(AValue); + except + Result := False; + //Raise the error + Exit; + end; + Result := True; +end; + +function GetFloat(AString : String): Extended; +var + Code: Integer; +begin + Val(AString, Result, Code); + + if Code <> 0 then + begin + MessageDlg('Error converting Float in '+AString+' position: ' + IntToStr(Code), mtWarning, [mbOk], 0); + Result := 0; + end; +end; + +function CountCharOccurences(const S: string; const ch: string): Integer; +var + buf: string; +begin + buf := S; + Result := 0; + {while Pos finds a blank} + while (Pos(ch, buf) > 0) do + begin + {copy the substrings before the blank in to Result} + Result := Result + 1; + buf := Copy(buf, Pos(ch, buf) + 1, Length(buf) - Pos(ch, buf)); + end; +end; + +//http://www.delphitricks.com/source-code/strings/count_the_number_of_occurrences_of_a_substring_within_a_string.html +function CountSubStringOccurences(const subtext: string; Text: string): Integer; +begin + if (Length(subtext) = 0) or (Length(Text) = 0) or (Pos(subtext, Text) = 0) then + Result := 0 + else + Result := (Length(Text) - Length(StringReplace(Text, subtext, '', [rfReplaceAll]))) div + Length(subtext); +end; + +function CountPropOccurences(AProp : String; AList : TStringList): Integer; +var + i : Integer; +begin + Result := 0; + + AProp := AnsiReplaceText(AProp, '=', ''); + + AList.CaseSensitive := False; + + for i := 0 to AList.Count - 1 do + begin + if AList.Names[i] = AProp then + Result := Result + 1; + end; +end; + +end. diff --git a/src/tools/stuffextract.vcproj b/src/tools/stuffextract.vcproj index 0a5db66..c498a5e 100644 --- a/src/tools/stuffextract.vcproj +++ b/src/tools/stuffextract.vcproj @@ -1,304 +1,304 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/tools/stuffextract/DBCFieldData.h b/src/tools/stuffextract/DBCFieldData.h index 313b081..ab74597 100644 --- a/src/tools/stuffextract/DBCFieldData.h +++ b/src/tools/stuffextract/DBCFieldData.h @@ -1,307 +1,307 @@ -#ifndef DBCFIELDDATA_H -#define DBCFIELDDATA_H - -// defines fields numbers in EmotesText.dbc -// unk fields are always 0, EMOTESTEXT_EMOTE_STRING is string and the rest is uint32. -enum EmotesTextEnum -{ - EMOTESTEXT_EMOTE_ID = 0, - EMOTESTEXT_EMOTE_STRING, - EMOTESTEXT_ANIM, - EMOTESTEXT_SOMEONE_TO_SOMEONE, - EMOTESTEXT_SOMEONE_TO_ME, - EMOTESTEXT_ME_TO_SOMEONE, - EMOTESTEXT_UNK_1, - EMOTESTEXT_SOMEONE_TO_NONE, - EMOTESTEXT_UNK_2, - EMOTESTEXT_ME_TO_NONE, - EMOTESTEXT_UNK_3, - EMOTESTEXT_SOMEONE_TO_SOMEONE_FEMALE, - EMOTESTEXT_SOMEONE_TO_ME_FEMALE, - EMOTESTEXT_UNK_4, // me to someone (female)? dbc is empty. - EMOTESTEXT_UNK_5, - EMOTESTEXT_SOMEONE_TO_NONE_FEMALE, - EMOTESTEXT_UNK_6, - EMOTESTEXT_UNK_7, // me to none (female)? dbc is empty. - EMOTESTEXT_UNK_8, - EMOTESTEXT_END -}; - -static const char *EmotesTextFieldNames[] = -{ - "", // EMOTESTEXT_EMOTE_ID - "", // EMOTESTEXT_EMOTE_STRING - "", // EMOTESTEXT_ANIM - "OneToOne", // EMOTESTEXT_SOMEONE_TO_SOMEONE - "OneToMe", // EMOTESTEXT_SOMEONE_TO_ME - "MeToOne", // EMOTESTEXT_ME_TO_SOMEONE - "", // EMOTESTEXT_UNK_1 - "OneGeneral", // EMOTESTEXT_SOMEONE_TO_NONE - "", // EMOTESTEXT_UNK_2 - "MeGeneral", // EMOTESTEXT_ME_TO_NONE - "", // EMOTESTEXT_UNK_3 - "OneToOneFemale", // EMOTESTEXT_SOMEONE_TO_SOMEONE_FEMALE - "OneToMeFemale", // EMOTESTEXT_SOMEONE_TO_ME_FEMALE - "", // EMOTESTEXT_UNK_4 - "", // EMOTESTEXT_UNK_5 - "OneGeneralFemale", // EMOTESTEXT_SOMEONE_TO_NONE_FEMALE - "", // EMOTESTEXT_UNK_6 - "", // EMOTESTEXT_UNK_7 - "", // EMOTESTEXT_UNK_8 - "" // EMOTESTEXT_END -}; - -enum EmotesTextDataEnum -{ - EMOTESTEXTDATA_TEXTID = 0, - EMOTESTEXTDATA_STRING1, - EMOTESTEXTDATA_STRING2, - EMOTESTEXTDATA_STRING3, - EMOTESTEXTDATA_STRING4, - EMOTESTEXTDATA_STRING5, - EMOTESTEXTDATA_STRING6, - EMOTESTEXTDATA_STRING7, - EMOTESTEXTDATA_STRING8, - EMOTESTEXTDATA_UNK, - // rest of the fields is 0 always -}; - -enum EmotesTextSoundEnum -{ - EMOTESTEXTSOUND_TEXTID = 0, - EMOTESTEXTSOUND_EMOTEID, - EMOTESTEXTSOUND_RACE, - EMOTESTEXTSOUND_ISFEMALE, - EMOTESTEXTSOUND_SOUNDID, - EMOTESTEXTSOUND_END -}; - -enum SoundEntriesEnum -{ - SOUNDENTRY_SOUNDID = 0, - SOUNDENTRY_UNK_1, // seems to be a flag or something - SOUNDENTRY_NAME_STRING, - SOUNDENTRY_FILE_1, - SOUNDENTRY_FILE_2, - SOUNDENTRY_FILE_3, - SOUNDENTRY_FILE_4, - SOUNDENTRY_FILE_5, - SOUNDENTRY_FILE_6, - SOUNDENTRY_FILE_7, - SOUNDENTRY_FILE_8, - SOUNDENTRY_FILE_9, - SOUNDENTRY_FILE_10, - SOUNDENTRY_BOOL_1, // these fields store either 0 or 1 - SOUNDENTRY_BOOL_2, // no idea what they are good for.. - SOUNDENTRY_BOOL_3, - SOUNDENTRY_BOOL_4, - SOUNDENTRY_BOOL_5, - SOUNDENTRY_BOOL_6, - SOUNDENTRY_BOOL_7, - SOUNDENTRY_BOOL_8, - SOUNDENTRY_BOOL_9, - SOUNDENTRY_BOOL_10, - SOUNDENTRY_PATH, // path where SOUNDENTRY_FILE_x is stored. has no trailing '\'. - SOUNDENTRY_UNK_2, // seems to be a float between 0...1 (sound volume?) - SOUNDENTRY_UNK_3, // another field storing flags? - SOUNDENTRY_UNK_4, // probably float data - SOUNDENTRY_UNK_5, // probably float data - SOUNDENTRY_UNK_6, // int value, mostly 0 or 2. only 2 cases where this field is 1 - SOUNDENTRY_END -}; - -static const char *SoundEntriesFormat = "ixsssssssssssiiiiiiiiiisxxxxx"; - -static const char *SoundEntriesFieldNames[] = -{ - "", - "", - "name", - "file1", "file2", "file3", "file4", "file5", "file6", "file7", "file8", "file9", "file10", // 10 file names - "","","","","","","","","","", // 10 unk bools - "path", - "volume", // ok lets just assume its volume (unk2) - "", "", "", "", "" // unk3 - unk6 -}; - -enum ChrRacesEnum -{ - CHRRACES_RACEID = 0, - CHRRACES_UNK_1, - CHRRACES_UNK_2, - CHRRACES_UNK_3, - CHRRACES_MODELM, // model for male player - CHRRACES_MODELF, // model for female player - CHRRACES_NAME_SHORT, // 2 chars name abbrev (Hu,Or,Tr, etc) - CHRRACES_UNK_4, - CHRRACES_FACTION, // 1=Alliance, 7=Horde - CHRRACES_UNK_5, // always 7? - CHRRACES_UNK_6, // SpellID? was always 836 in 1.12.x, since 2.0.x its 15007 - CHRRACES_UNK_7, - CHRRACES_NAME_GENERAL, // always the english(?) name (without spaces). used in texture names etc. - CHRRACES_UNK_9, - // the following 8 fields contain either 0 or the race name, depending on the locale. - CHRRACES_NAME1, // english - CHRRACES_NAME2, // - CHRRACES_NAME3, // - CHRRACES_NAME4, // german - CHRRACES_NAME5, // - CHRRACES_NAME6, // - CHRRACES_NAME7, // - CHRRACES_NAME8, // - CHRRACES_UNK_10, - CHRRACES_UNK_11, - CHRRACES_UNK_19, - CHRRACES_UNK_20, - CHRRACES_UNK_21, - CHARRACES_END -}; - -static const char *ChrRacesFormat = "ixxxiisxixxxsxssssssssxxxxx"; - -static const char *ChrRacesFieldNames[] = -{ - "", - "", - "", - "", - "model_m", - "model_f", - "name_short", - "", - "faction", - "", - "", - "", - "name_general", - "", - "name", - "name", - "name", - "name", - "name", - "name", - "name", - "name", - "", - "", - "", - "", - "", - "" -}; - -enum MapEnum -{ - MAP_ID = 0, - MAP_NAME_GENERAL = 1, - MAP_NAME1 = 4, - MAP_NAME2, - MAP_NAME3, - MAP_NAME4, - MAP_NAME5, - MAP_NAME6, - MAP_NAME7, - MAP_NAME8, - MAP_END = 75 -}; - -static const char *MapFieldNames[] = -{ - "","name_general","","","name","name","name","name","name","name", - "name","name","","","","","","","","", - "","","","","","","","","","", - "","","","","","","","","","", - "","","","","","","","","","", - "","","","","","","","","","", - "","","","","","","","","","", - "","","","", - "" -}; - -static const char *MapFormat = -{ - "isxxssssss" - "ssxxxxxxxx" - "xxxxxxxxxx" - "xxxxxxxxxx" - "xxxxxxxxxx" - "xxxxxxxxxx" - "xxxxxxxxxx" - "xxxxx" -}; - -enum AreaTableEnum -{ - AREATABLE_ID = 0, - AREATABLE_PARENTMAP = 2, - AREATABLE_FLAGS = 4, // 64 in normal (?) areas - AREATABLE_LEVEL = 10, - AREATABLE_NAME1 = 11, - AREATABLE_NAME2, - AREATABLE_NAME3, - AREATABLE_NAME4, - AREATABLE_NAME5, - AREATABLE_NAME6, - AREATABLE_NAME7, - AREATABLE_NAME8, - AREATABLE_FACTION = 20, // 2 (alliance?) or 4 (horde?) - AREATABLE_END = 27, -}; - -static const char *AreaTableFieldNames[] = { - "","","map","","flags","","","","","", // 0-9 - "level","name","name","name","name","name","name","name","name","", // 10-19 - "faction","","","","","", // 20-26 - "" -}; - -static const char *AreaTableFormat = { - "ixixixxxxx" - "issssssssx" - "xxxxxxx" -}; - -enum ItemDisplayInfoEnum -{ - ITEMDISPLAYINFO_ID = 0, - ITEMDISPLAYINFO_MODEL_L = 1, // model file (left) (default) - ITEMDISPLAYINFO_MODEL_R = 2, // model file (right) (for example for shoulders) - ITEMDISPLAYINFO_NAME_L = 3, // (internal name?) - ITEMDISPLAYINFO_NAME_R = 4, // (internal name?) - ITEMDISPLAYINFO_ICON = 5, // icon filename - ITEMDISPLAYINFO_FLAG1 = 6, // must be some kind of flag. 0 - 5. - ITEMDISPLAYINFO_FLAG2 = 7, // some flag? 0, 1 or 2. - ITEMDISPLAYINFO_FLAG3 = 8, // some flag? 0 or 1. - ITEMDISPLAYINFO_FLAG4 = 9, // some flag? 0, 1 or 2. - ITEMDISPLAYINFO_FLAG5 = 10, // some flag? mostly 0, sometimes other values (for ex. polearms have 4081 ?!) - ITEMDISPLAYINFO_FLAGS = 11, // these is NOT the inventorytype... - ITEMDISPLAYINFO_HELM1 = 12, // only set if model is a helm. might be related to hair/ears/traits showing on or off. - ITEMDISPLAYINFO_HELM2 = 13, // ^ same. - ITEMDISPLAYINFO_AU = 14, // the following fields contain strings that end with AU, AL, HA, TU, etc. - ITEMDISPLAYINFO_AL = 15, // sometimes they are set, sometimes not. - ITEMDISPLAYINFO_HA = 16, - ITEMDISPLAYINFO_TU = 17, - ITEMDISPLAYINFO_TL = 18, - ITEMDISPLAYINFO_LU = 19, - ITEMDISPLAYINFO_LL = 20, - ITEMDISPLAYINFO_FO = 21, - ITEMDISPLAYINFO_UNK = 22, // mostly 0. quite sure this is not a string. - - ITEMDISPLAYINFO_END = 23 -}; - -static const char *ItemDisplayInfoFieldNames[] = { - "","model_l","model_r","name_l","name_r","icon","flag1","flag2","flag3","flag4", // 0-9 - "flag5","flags","helm1","helm2","AU","AL","HA","TU","TL","LU", // 10-19 - "LL","FO","unk", // 20-22 - "" -}; - -static const char *ItemDisplayInfoFormat = { - "isssssiiii" - "iiiissssss" - "ssi" -}; - -#endif +#ifndef DBCFIELDDATA_H +#define DBCFIELDDATA_H + +// defines fields numbers in EmotesText.dbc +// unk fields are always 0, EMOTESTEXT_EMOTE_STRING is string and the rest is uint32. +enum EmotesTextEnum +{ + EMOTESTEXT_EMOTE_ID = 0, + EMOTESTEXT_EMOTE_STRING, + EMOTESTEXT_ANIM, + EMOTESTEXT_SOMEONE_TO_SOMEONE, + EMOTESTEXT_SOMEONE_TO_ME, + EMOTESTEXT_ME_TO_SOMEONE, + EMOTESTEXT_UNK_1, + EMOTESTEXT_SOMEONE_TO_NONE, + EMOTESTEXT_UNK_2, + EMOTESTEXT_ME_TO_NONE, + EMOTESTEXT_UNK_3, + EMOTESTEXT_SOMEONE_TO_SOMEONE_FEMALE, + EMOTESTEXT_SOMEONE_TO_ME_FEMALE, + EMOTESTEXT_UNK_4, // me to someone (female)? dbc is empty. + EMOTESTEXT_UNK_5, + EMOTESTEXT_SOMEONE_TO_NONE_FEMALE, + EMOTESTEXT_UNK_6, + EMOTESTEXT_UNK_7, // me to none (female)? dbc is empty. + EMOTESTEXT_UNK_8, + EMOTESTEXT_END +}; + +static const char *EmotesTextFieldNames[] = +{ + "", // EMOTESTEXT_EMOTE_ID + "", // EMOTESTEXT_EMOTE_STRING + "", // EMOTESTEXT_ANIM + "OneToOne", // EMOTESTEXT_SOMEONE_TO_SOMEONE + "OneToMe", // EMOTESTEXT_SOMEONE_TO_ME + "MeToOne", // EMOTESTEXT_ME_TO_SOMEONE + "", // EMOTESTEXT_UNK_1 + "OneGeneral", // EMOTESTEXT_SOMEONE_TO_NONE + "", // EMOTESTEXT_UNK_2 + "MeGeneral", // EMOTESTEXT_ME_TO_NONE + "", // EMOTESTEXT_UNK_3 + "OneToOneFemale", // EMOTESTEXT_SOMEONE_TO_SOMEONE_FEMALE + "OneToMeFemale", // EMOTESTEXT_SOMEONE_TO_ME_FEMALE + "", // EMOTESTEXT_UNK_4 + "", // EMOTESTEXT_UNK_5 + "OneGeneralFemale", // EMOTESTEXT_SOMEONE_TO_NONE_FEMALE + "", // EMOTESTEXT_UNK_6 + "", // EMOTESTEXT_UNK_7 + "", // EMOTESTEXT_UNK_8 + "" // EMOTESTEXT_END +}; + +enum EmotesTextDataEnum +{ + EMOTESTEXTDATA_TEXTID = 0, + EMOTESTEXTDATA_STRING1, + EMOTESTEXTDATA_STRING2, + EMOTESTEXTDATA_STRING3, + EMOTESTEXTDATA_STRING4, + EMOTESTEXTDATA_STRING5, + EMOTESTEXTDATA_STRING6, + EMOTESTEXTDATA_STRING7, + EMOTESTEXTDATA_STRING8, + EMOTESTEXTDATA_UNK, + // rest of the fields is 0 always +}; + +enum EmotesTextSoundEnum +{ + EMOTESTEXTSOUND_TEXTID = 0, + EMOTESTEXTSOUND_EMOTEID, + EMOTESTEXTSOUND_RACE, + EMOTESTEXTSOUND_ISFEMALE, + EMOTESTEXTSOUND_SOUNDID, + EMOTESTEXTSOUND_END +}; + +enum SoundEntriesEnum +{ + SOUNDENTRY_SOUNDID = 0, + SOUNDENTRY_UNK_1, // seems to be a flag or something + SOUNDENTRY_NAME_STRING, + SOUNDENTRY_FILE_1, + SOUNDENTRY_FILE_2, + SOUNDENTRY_FILE_3, + SOUNDENTRY_FILE_4, + SOUNDENTRY_FILE_5, + SOUNDENTRY_FILE_6, + SOUNDENTRY_FILE_7, + SOUNDENTRY_FILE_8, + SOUNDENTRY_FILE_9, + SOUNDENTRY_FILE_10, + SOUNDENTRY_BOOL_1, // these fields store either 0 or 1 + SOUNDENTRY_BOOL_2, // no idea what they are good for.. + SOUNDENTRY_BOOL_3, + SOUNDENTRY_BOOL_4, + SOUNDENTRY_BOOL_5, + SOUNDENTRY_BOOL_6, + SOUNDENTRY_BOOL_7, + SOUNDENTRY_BOOL_8, + SOUNDENTRY_BOOL_9, + SOUNDENTRY_BOOL_10, + SOUNDENTRY_PATH, // path where SOUNDENTRY_FILE_x is stored. has no trailing '\'. + SOUNDENTRY_UNK_2, // seems to be a float between 0...1 (sound volume?) + SOUNDENTRY_UNK_3, // another field storing flags? + SOUNDENTRY_UNK_4, // probably float data + SOUNDENTRY_UNK_5, // probably float data + SOUNDENTRY_UNK_6, // int value, mostly 0 or 2. only 2 cases where this field is 1 + SOUNDENTRY_END +}; + +static const char *SoundEntriesFormat = "ixsssssssssssiiiiiiiiiisxxxxx"; + +static const char *SoundEntriesFieldNames[] = +{ + "", + "", + "name", + "file1", "file2", "file3", "file4", "file5", "file6", "file7", "file8", "file9", "file10", // 10 file names + "","","","","","","","","","", // 10 unk bools + "path", + "volume", // ok lets just assume its volume (unk2) + "", "", "", "", "" // unk3 - unk6 +}; + +enum ChrRacesEnum +{ + CHRRACES_RACEID = 0, + CHRRACES_UNK_1, + CHRRACES_UNK_2, + CHRRACES_UNK_3, + CHRRACES_MODELM, // model for male player + CHRRACES_MODELF, // model for female player + CHRRACES_NAME_SHORT, // 2 chars name abbrev (Hu,Or,Tr, etc) + CHRRACES_UNK_4, + CHRRACES_FACTION, // 1=Alliance, 7=Horde + CHRRACES_UNK_5, // always 7? + CHRRACES_UNK_6, // SpellID? was always 836 in 1.12.x, since 2.0.x its 15007 + CHRRACES_UNK_7, + CHRRACES_NAME_GENERAL, // always the english(?) name (without spaces). used in texture names etc. + CHRRACES_UNK_9, + // the following 8 fields contain either 0 or the race name, depending on the locale. + CHRRACES_NAME1, // english + CHRRACES_NAME2, // + CHRRACES_NAME3, // + CHRRACES_NAME4, // german + CHRRACES_NAME5, // + CHRRACES_NAME6, // + CHRRACES_NAME7, // + CHRRACES_NAME8, // + CHRRACES_UNK_10, + CHRRACES_UNK_11, + CHRRACES_UNK_19, + CHRRACES_UNK_20, + CHRRACES_UNK_21, + CHARRACES_END +}; + +static const char *ChrRacesFormat = "ixxxiisxixxxsxssssssssxxxxx"; + +static const char *ChrRacesFieldNames[] = +{ + "", + "", + "", + "", + "model_m", + "model_f", + "name_short", + "", + "faction", + "", + "", + "", + "name_general", + "", + "name", + "name", + "name", + "name", + "name", + "name", + "name", + "name", + "", + "", + "", + "", + "", + "" +}; + +enum MapEnum +{ + MAP_ID = 0, + MAP_NAME_GENERAL = 1, + MAP_NAME1 = 4, + MAP_NAME2, + MAP_NAME3, + MAP_NAME4, + MAP_NAME5, + MAP_NAME6, + MAP_NAME7, + MAP_NAME8, + MAP_END = 75 +}; + +static const char *MapFieldNames[] = +{ + "","name_general","","","name","name","name","name","name","name", + "name","name","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","", + "" +}; + +static const char *MapFormat = +{ + "isxxssssss" + "ssxxxxxxxx" + "xxxxxxxxxx" + "xxxxxxxxxx" + "xxxxxxxxxx" + "xxxxxxxxxx" + "xxxxxxxxxx" + "xxxxx" +}; + +enum AreaTableEnum +{ + AREATABLE_ID = 0, + AREATABLE_PARENTMAP = 2, + AREATABLE_FLAGS = 4, // 64 in normal (?) areas + AREATABLE_LEVEL = 10, + AREATABLE_NAME1 = 11, + AREATABLE_NAME2, + AREATABLE_NAME3, + AREATABLE_NAME4, + AREATABLE_NAME5, + AREATABLE_NAME6, + AREATABLE_NAME7, + AREATABLE_NAME8, + AREATABLE_FACTION = 20, // 2 (alliance?) or 4 (horde?) + AREATABLE_END = 27, +}; + +static const char *AreaTableFieldNames[] = { + "","","map","","flags","","","","","", // 0-9 + "level","name","name","name","name","name","name","name","name","", // 10-19 + "faction","","","","","", // 20-26 + "" +}; + +static const char *AreaTableFormat = { + "ixixixxxxx" + "issssssssx" + "xxxxxxx" +}; + +enum ItemDisplayInfoEnum +{ + ITEMDISPLAYINFO_ID = 0, + ITEMDISPLAYINFO_MODEL_L = 1, // model file (left) (default) + ITEMDISPLAYINFO_MODEL_R = 2, // model file (right) (for example for shoulders) + ITEMDISPLAYINFO_NAME_L = 3, // (internal name?) + ITEMDISPLAYINFO_NAME_R = 4, // (internal name?) + ITEMDISPLAYINFO_ICON = 5, // icon filename + ITEMDISPLAYINFO_FLAG1 = 6, // must be some kind of flag. 0 - 5. + ITEMDISPLAYINFO_FLAG2 = 7, // some flag? 0, 1 or 2. + ITEMDISPLAYINFO_FLAG3 = 8, // some flag? 0 or 1. + ITEMDISPLAYINFO_FLAG4 = 9, // some flag? 0, 1 or 2. + ITEMDISPLAYINFO_FLAG5 = 10, // some flag? mostly 0, sometimes other values (for ex. polearms have 4081 ?!) + ITEMDISPLAYINFO_FLAGS = 11, // these is NOT the inventorytype... + ITEMDISPLAYINFO_HELM1 = 12, // only set if model is a helm. might be related to hair/ears/traits showing on or off. + ITEMDISPLAYINFO_HELM2 = 13, // ^ same. + ITEMDISPLAYINFO_AU = 14, // the following fields contain strings that end with AU, AL, HA, TU, etc. + ITEMDISPLAYINFO_AL = 15, // sometimes they are set, sometimes not. + ITEMDISPLAYINFO_HA = 16, + ITEMDISPLAYINFO_TU = 17, + ITEMDISPLAYINFO_TL = 18, + ITEMDISPLAYINFO_LU = 19, + ITEMDISPLAYINFO_LL = 20, + ITEMDISPLAYINFO_FO = 21, + ITEMDISPLAYINFO_UNK = 22, // mostly 0. quite sure this is not a string. + + ITEMDISPLAYINFO_END = 23 +}; + +static const char *ItemDisplayInfoFieldNames[] = { + "","model_l","model_r","name_l","name_r","icon","flag1","flag2","flag3","flag4", // 0-9 + "flag5","flags","helm1","helm2","AU","AL","HA","TU","TL","LU", // 10-19 + "LL","FO","unk", // 20-22 + "" +}; + +static const char *ItemDisplayInfoFormat = { + "isssssiiii" + "iiiissssss" + "ssi" +}; + +#endif diff --git a/src/tools/stuffextract/Locale.cpp b/src/tools/stuffextract/Locale.cpp index 6821493..63b60cb 100644 --- a/src/tools/stuffextract/Locale.cpp +++ b/src/tools/stuffextract/Locale.cpp @@ -1,60 +1,60 @@ -#include "common.h" -#include "Locale.h" -#include -#include "ByteBuffer.h" - -bool locale_set=false; -char my_locale[5]; -char *cconf = "WTF/config.wtf"; -char *cconfentry = "SET locale \""; - -void SetLocale(char *loc) -{ - my_locale[4] = 0; - if(loc && strlen(loc)) - { - memcpy(my_locale,loc,4); - } - else - { - uint32 fs = GetFileSize(cconf); - std::fstream fh; - std::string s; - fh.open(cconf,std::ios_base::in); - if(!fh.is_open()) - { - printf("ERROR: unable to detect locale, could not open '%s'\n",cconf); - return; - } - char *buf = new char[fs]; - fh.read((char*)buf,fs); - fh.close(); - - for(uint32 i=0; i= strlen(cconfentry) && !memcmp(s.c_str(),cconfentry,strlen(cconfentry))) - { - memcpy(my_locale,s.c_str() + strlen(cconfentry), 4); - printf("Auto-detected locale '%s'\n",my_locale); - break; - } - s.clear(); - } - else - { - s += buf[i]; - } - } - delete [] buf; - } - locale_set = true; -} - -char *GetLocale(void) -{ - if(locale_set) - return &my_locale[0]; - return NULL; +#include "common.h" +#include "Locale.h" +#include +#include "ByteBuffer.h" + +bool locale_set=false; +char my_locale[5]; +char *cconf = "WTF/config.wtf"; +char *cconfentry = "SET locale \""; + +void SetLocale(char *loc) +{ + my_locale[4] = 0; + if(loc && strlen(loc)) + { + memcpy(my_locale,loc,4); + } + else + { + uint32 fs = GetFileSize(cconf); + std::fstream fh; + std::string s; + fh.open(cconf,std::ios_base::in); + if(!fh.is_open()) + { + printf("ERROR: unable to detect locale, could not open '%s'\n",cconf); + return; + } + char *buf = new char[fs]; + fh.read((char*)buf,fs); + fh.close(); + + for(uint32 i=0; i= strlen(cconfentry) && !memcmp(s.c_str(),cconfentry,strlen(cconfentry))) + { + memcpy(my_locale,s.c_str() + strlen(cconfentry), 4); + printf("Auto-detected locale '%s'\n",my_locale); + break; + } + s.clear(); + } + else + { + s += buf[i]; + } + } + delete [] buf; + } + locale_set = true; +} + +char *GetLocale(void) +{ + if(locale_set) + return &my_locale[0]; + return NULL; } \ No newline at end of file diff --git a/src/tools/stuffextract/Locale.h b/src/tools/stuffextract/Locale.h index d62833d..5eee138 100644 --- a/src/tools/stuffextract/Locale.h +++ b/src/tools/stuffextract/Locale.h @@ -1,7 +1,7 @@ -#ifndef STUFFEXTRACT_LOCALE_H -#define STUFFEXTRACT_LOCALE_H - -char *GetLocale(void); -void SetLocale(char*); - +#ifndef STUFFEXTRACT_LOCALE_H +#define STUFFEXTRACT_LOCALE_H + +char *GetLocale(void); +void SetLocale(char*); + #endif \ No newline at end of file diff --git a/src/tools/stuffextract/MPQFile.cpp b/src/tools/stuffextract/MPQFile.cpp index 43c52e8..40a4546 100644 --- a/src/tools/stuffextract/MPQFile.cpp +++ b/src/tools/stuffextract/MPQFile.cpp @@ -1,49 +1,49 @@ -#include "MPQFile.h" - -// MPQ file to be opened -MPQFile::MPQFile(const char *fn) -{ - _mpq = NULL; - _isopen = SFileOpenArchive(fn,0,0,&_mpq); -} - -MPQFile::~MPQFile() -{ - Close(); -} - -bool MPQFile::HasFile(char *fn) -{ - return SFileHasFile(_mpq,fn); -} - -// get size of a file within an mpq archive -ByteBuffer MPQFile::ReadFile(char *fn) -{ - ByteBuffer bb; - HANDLE fh; - if(!SFileOpenFileEx(_mpq, fn, 0, &fh)) - return bb; - uint32 size = SFileGetFileSize(fh); - bb.resize(size); - SFileReadFile(fh, (void*)bb.contents(), size, NULL, NULL); - SFileCloseFile(fh); - return bb; -} - -uint32 MPQFile::GetFileSize(char *fn) -{ - HANDLE fh; - if(!SFileOpenFileEx(_mpq, fn, 0, &fh)) - return 0; - uint32 size = SFileGetFileSize(fh); - SFileCloseFile(fh); - return size; -} - -void MPQFile::Close(void) -{ - if(_isopen) - FreeMPQArchive((TMPQArchive*&)_mpq); -} - +#include "MPQFile.h" + +// MPQ file to be opened +MPQFile::MPQFile(const char *fn) +{ + _mpq = NULL; + _isopen = SFileOpenArchive(fn,0,0,&_mpq); +} + +MPQFile::~MPQFile() +{ + Close(); +} + +bool MPQFile::HasFile(char *fn) +{ + return SFileHasFile(_mpq,fn); +} + +// get size of a file within an mpq archive +ByteBuffer MPQFile::ReadFile(char *fn) +{ + ByteBuffer bb; + HANDLE fh; + if(!SFileOpenFileEx(_mpq, fn, 0, &fh)) + return bb; + uint32 size = SFileGetFileSize(fh); + bb.resize(size); + SFileReadFile(fh, (void*)bb.contents(), size, NULL, NULL); + SFileCloseFile(fh); + return bb; +} + +uint32 MPQFile::GetFileSize(char *fn) +{ + HANDLE fh; + if(!SFileOpenFileEx(_mpq, fn, 0, &fh)) + return 0; + uint32 size = SFileGetFileSize(fh); + SFileCloseFile(fh); + return size; +} + +void MPQFile::Close(void) +{ + if(_isopen) + FreeMPQArchive((TMPQArchive*&)_mpq); +} + diff --git a/src/tools/stuffextract/MPQFile.h b/src/tools/stuffextract/MPQFile.h index 621f437..649ad17 100644 --- a/src/tools/stuffextract/MPQFile.h +++ b/src/tools/stuffextract/MPQFile.h @@ -1,26 +1,26 @@ -#ifndef MPQFILE_H -#define MPQFILE_H - -#define _COMMON_NO_THREADS -#include "common.h" -#include "StormLib/StormLib.h" -#include "StormLib/SCommon.h" - -class MPQFile -{ -public: - MPQFile(const char*); - ~MPQFile(); - inline bool IsOpen(void) { return _isopen; } - ByteBuffer ReadFile(char*); - uint32 GetFileSize(char*); - bool HasFile(char*); - void Close(void); - -private: - HANDLE _mpq; - bool _isopen; - -}; - -#endif +#ifndef MPQFILE_H +#define MPQFILE_H + +#define _COMMON_NO_THREADS +#include "common.h" +#include "StormLib/StormLib.h" +#include "StormLib/SCommon.h" + +class MPQFile +{ +public: + MPQFile(const char*); + ~MPQFile(); + inline bool IsOpen(void) { return _isopen; } + ByteBuffer ReadFile(char*); + uint32 GetFileSize(char*); + bool HasFile(char*); + void Close(void); + +private: + HANDLE _mpq; + bool _isopen; + +}; + +#endif diff --git a/src/tools/stuffextract/MPQHelper.cpp b/src/tools/stuffextract/MPQHelper.cpp index 7fa6fd9..1bb6b16 100644 --- a/src/tools/stuffextract/MPQHelper.cpp +++ b/src/tools/stuffextract/MPQHelper.cpp @@ -1,92 +1,92 @@ -#include -#include "common.h" -#include "MPQHelper.h" -#include "MPQFile.h" -#include "Locale.h" - -#define DATADIR "Data" - - -MPQHelper::MPQHelper(char *archive) -{ - // TODO: check which files are needed and which are not + recheck for correct ordering - std::string dir = "Data/"; - std::string ext = ".MPQ"; - std::string ldir = dir + GetLocale() + "/"; - - // order goes from last opened to first opened file - // ok maybe this is a bit too much but should work fine :) - _patches.push_front(dir+archive+ext); // - _patches.push_front(dir+"common"+ext); - _patches.push_front(dir+"expansion"+ext); - _patches.push_front(dir+"patch"+ext); - for(uint32 i=1; i<=MAX_PATCH_NUMBER; i++) - { - char buf[200]; - sprintf(buf,"%spatch-%u%s",dir.c_str(),i,ext.c_str()); - _patches.push_front(buf); - } - _patches.push_front(ldir+"speech-"+GetLocale()+ext); - _patches.push_front(ldir+archive+"-"+GetLocale()+ext); - _patches.push_front(ldir+"locale-"+GetLocale()+ext); - _patches.push_front(ldir+"expansion-speech-"+GetLocale()+ext); - _patches.push_front(ldir+"expansion-locale-"+GetLocale()+ext); - _patches.push_front(ldir+"expansion-"+archive+"-"+GetLocale()+ext); - - _patches.push_front(ldir+"patch"+"-"+GetLocale()+ext); - for(uint32 i=1; i<=MAX_PATCH_NUMBER; i++) - { - char buf[200]; - sprintf(buf,"%spatch-%s-%u%s",ldir.c_str(),GetLocale(),i,ext.c_str()); - //if(FileExists(buf)) - _patches.push_front(buf); - } - - // now check if the above specified files exist. - for(std::list::iterator it=_patches.begin(); it != _patches.end(); it++) - { - if(::FileExists(*it)) - { - _files.push_back(new MPQFile((*it).c_str())); - } - } -} - -MPQHelper::~MPQHelper() -{ - for(std::list::iterator it=_files.begin(); it != _files.end(); it++) - { - (*it)->Close(); - delete *it; - } -} - -ByteBuffer MPQHelper::ExtractFile(char* fn) -{ - ByteBuffer bb; - for(std::list::iterator i = _files.begin(); i != _files.end(); i++) - { - MPQFile *mpq = *i; - if(mpq->IsOpen() && mpq->HasFile(fn) && mpq->GetFileSize(fn) > 0) - { - // printf("MPQE: Using %s from %s\n",fn,i->c_str()); - bb = mpq->ReadFile(fn); - return bb; - } - } - return bb; // will be empty if returned here -} - -bool MPQHelper::FileExists(char *fn) -{ - for(std::list::iterator i = _files.begin(); i != _files.end(); i++) - { - if((*i)->IsOpen() && (*i)->HasFile(fn) && (*i)->GetFileSize(fn) > 0) - return true; - } - return false; -} - - - - +#include +#include "common.h" +#include "MPQHelper.h" +#include "MPQFile.h" +#include "Locale.h" + +#define DATADIR "Data" + + +MPQHelper::MPQHelper(char *archive) +{ + // TODO: check which files are needed and which are not + recheck for correct ordering + std::string dir = "Data/"; + std::string ext = ".MPQ"; + std::string ldir = dir + GetLocale() + "/"; + + // order goes from last opened to first opened file + // ok maybe this is a bit too much but should work fine :) + _patches.push_front(dir+archive+ext); // + _patches.push_front(dir+"common"+ext); + _patches.push_front(dir+"expansion"+ext); + _patches.push_front(dir+"patch"+ext); + for(uint32 i=1; i<=MAX_PATCH_NUMBER; i++) + { + char buf[200]; + sprintf(buf,"%spatch-%u%s",dir.c_str(),i,ext.c_str()); + _patches.push_front(buf); + } + _patches.push_front(ldir+"speech-"+GetLocale()+ext); + _patches.push_front(ldir+archive+"-"+GetLocale()+ext); + _patches.push_front(ldir+"locale-"+GetLocale()+ext); + _patches.push_front(ldir+"expansion-speech-"+GetLocale()+ext); + _patches.push_front(ldir+"expansion-locale-"+GetLocale()+ext); + _patches.push_front(ldir+"expansion-"+archive+"-"+GetLocale()+ext); + + _patches.push_front(ldir+"patch"+"-"+GetLocale()+ext); + for(uint32 i=1; i<=MAX_PATCH_NUMBER; i++) + { + char buf[200]; + sprintf(buf,"%spatch-%s-%u%s",ldir.c_str(),GetLocale(),i,ext.c_str()); + //if(FileExists(buf)) + _patches.push_front(buf); + } + + // now check if the above specified files exist. + for(std::list::iterator it=_patches.begin(); it != _patches.end(); it++) + { + if(::FileExists(*it)) + { + _files.push_back(new MPQFile((*it).c_str())); + } + } +} + +MPQHelper::~MPQHelper() +{ + for(std::list::iterator it=_files.begin(); it != _files.end(); it++) + { + (*it)->Close(); + delete *it; + } +} + +ByteBuffer MPQHelper::ExtractFile(char* fn) +{ + ByteBuffer bb; + for(std::list::iterator i = _files.begin(); i != _files.end(); i++) + { + MPQFile *mpq = *i; + if(mpq->IsOpen() && mpq->HasFile(fn) && mpq->GetFileSize(fn) > 0) + { + // printf("MPQE: Using %s from %s\n",fn,i->c_str()); + bb = mpq->ReadFile(fn); + return bb; + } + } + return bb; // will be empty if returned here +} + +bool MPQHelper::FileExists(char *fn) +{ + for(std::list::iterator i = _files.begin(); i != _files.end(); i++) + { + if((*i)->IsOpen() && (*i)->HasFile(fn) && (*i)->GetFileSize(fn) > 0) + return true; + } + return false; +} + + + + diff --git a/src/tools/stuffextract/MPQHelper.h b/src/tools/stuffextract/MPQHelper.h index e6b3155..b401961 100644 --- a/src/tools/stuffextract/MPQHelper.h +++ b/src/tools/stuffextract/MPQHelper.h @@ -1,20 +1,20 @@ -#ifndef MPQHELPER_H -#define MPQHELPER_H - -#define MAX_PATCH_NUMBER 9 - -class MPQFile; - -class MPQHelper -{ -public: - MPQHelper(char*); - ~MPQHelper(); - ByteBuffer ExtractFile(char*); - bool FileExists(char*); -private: - std::list _files; - std::list _patches; -}; - +#ifndef MPQHELPER_H +#define MPQHELPER_H + +#define MAX_PATCH_NUMBER 9 + +class MPQFile; + +class MPQHelper +{ +public: + MPQHelper(char*); + ~MPQHelper(); + ByteBuffer ExtractFile(char*); + bool FileExists(char*); +private: + std::list _files; + std::list _patches; +}; + #endif \ No newline at end of file diff --git a/src/tools/stuffextract/StormLib/SCommon.cpp b/src/tools/stuffextract/StormLib/SCommon.cpp index cfe34fd..393310f 100644 --- a/src/tools/stuffextract/StormLib/SCommon.cpp +++ b/src/tools/stuffextract/StormLib/SCommon.cpp @@ -1,1074 +1,1074 @@ -/*****************************************************************************/ -/* SCommon.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Common functions for StormLib, used by all SFile*** modules */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 24.03.03 1.00 Lad The first version of SFileCommon.cpp */ -/* 19.11.03 1.01 Dan Big endian handling */ -/* 12.06.04 1.01 Lad Renamed to SCommon.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -char StormLibCopyright[] = "StormLib v 4.50 Copyright Ladislav Zezula 1998-2003"; - -//----------------------------------------------------------------------------- -// The buffer for decryption engine. - -TMPQArchive * pFirstOpen = NULL; // The first member of MPQ archives chain -LCID lcLocale = LANG_NEUTRAL; // File locale -USHORT wPlatform = 0; // File platform - -//----------------------------------------------------------------------------- -// Compression types - -// -// Data compressions -// -// Can be combination of MPQ_COMPRESSION_PKWARE, MPQ_COMPRESSION_BZIP2 -// and MPQ_COMPRESSION_ZLIB. Some newer compressions are not supported -// by older games. The table of supported compressions is here: -// -// MPQ_COMPRESSION_PKWARE - All games since Diablo I -// MPQ_COMPRESSION_ZLIB - Games since Starcraft -// MPQ_COMPRESSION_BZIP2 - Games since World of Warcraft -// - -static int nDataCmp = MPQ_COMPRESSION_ZLIB; - -// -// WAVE compressions by quality level -// - -static int uWaveCmpLevel[] = {-1, 4, 2}; -static int uWaveCmpType[] = {MPQ_COMPRESSION_PKWARE, 0x81, 0x81}; - -//----------------------------------------------------------------------------- -// Storm buffer functions - -// Buffer for the decryption engine -#define STORM_BUFFER_SIZE 0x500 -static DWORD StormBuffer[STORM_BUFFER_SIZE]; -static BOOL bStormBufferCreated = FALSE; - -int PrepareStormBuffer() -{ - DWORD dwSeed = 0x00100001; - DWORD index1 = 0; - DWORD index2 = 0; - int i; - - // Initialize the decryption buffer. - // Do nothing if already done. - if(bStormBufferCreated == FALSE) - { - for(index1 = 0; index1 < 0x100; index1++) - { - for(index2 = index1, i = 0; i < 5; i++, index2 += 0x100) - { - DWORD temp1, temp2; - - dwSeed = (dwSeed * 125 + 3) % 0x2AAAAB; - temp1 = (dwSeed & 0xFFFF) << 0x10; - - dwSeed = (dwSeed * 125 + 3) % 0x2AAAAB; - temp2 = (dwSeed & 0xFFFF); - - StormBuffer[index2] = (temp1 | temp2); - } - } - bStormBufferCreated = TRUE; - } - return ERROR_SUCCESS; -} - -//----------------------------------------------------------------------------- -// Encrypting and decrypting hash table - -void EncryptHashTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength) -{ - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; // One key character - - // Prepare seeds - while(*pbKey != 0) - { - ch = toupper(*pbKey++); - - dwSeed1 = StormBuffer[0x300 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - - // Encrypt it - dwSeed2 = 0xEEEEEEEE; - while(dwLength-- > 0) - { - dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; - ch = *pdwTable; - *pdwTable++ = ch ^ (dwSeed1 + dwSeed2); - - dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); - dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; - } -} - -void DecryptHashTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength) -{ - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; // One key character - - // Prepare seeds - while(*pbKey != 0) - { - ch = toupper(*pbKey++); - - dwSeed1 = StormBuffer[0x300 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - - // Decrypt it - dwSeed2 = 0xEEEEEEEE; - while(dwLength-- > 0) - { - dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; - ch = *pdwTable ^ (dwSeed1 + dwSeed2); - - dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); - dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; - *pdwTable++ = ch; - } -} - -//----------------------------------------------------------------------------- -// Encrypting and decrypting block table - -void EncryptBlockTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength) -{ - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; // One key character - - // Prepare seeds - while(*pbKey != 0) - { - ch = toupper(*pbKey++); - - dwSeed1 = StormBuffer[0x300 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - - // Decrypt it - dwSeed2 = 0xEEEEEEEE; - while(dwLength-- > 0) - { - dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; - ch = *pdwTable; - *pdwTable++ = ch ^ (dwSeed1 + dwSeed2); - - dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); - dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; - } -} - -void DecryptBlockTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength) -{ - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; // One key character - - // Prepare seeds - while(*pbKey != 0) - { - ch = toupper(*pbKey++); - - dwSeed1 = StormBuffer[0x300 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - - // Encrypt it - dwSeed2 = 0xEEEEEEEE; - while(dwLength-- > 0) - { - dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; - ch = *pdwTable ^ (dwSeed1 + dwSeed2); - - dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); - dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; - *pdwTable++ = ch; - } -} - -//----------------------------------------------------------------------------- -// Functions tries to get file decryption key. The trick comes from block -// positions which are stored at the begin of each compressed file. We know the -// file size, that means we know number of blocks that means we know the first -// DWORD value in block position. And if we know encrypted and decrypted value, -// we can find the decryption key !!! -// -// hf - MPQ file handle -// block - DWORD array of block positions -// ch - Decrypted value of the first block pos - -DWORD DetectFileSeed(DWORD * block, DWORD decrypted) -{ - DWORD saveSeed1; - DWORD temp = *block ^ decrypted; // temp = seed1 + seed2 - temp -= 0xEEEEEEEE; // temp = seed1 + StormBuffer[0x400 + (seed1 & 0xFF)] - - for(int i = 0; i < 0x100; i++) // Try all 255 possibilities - { - DWORD seed1; - DWORD seed2 = 0xEEEEEEEE; - DWORD ch; - - // Try the first DWORD (We exactly know the value) - seed1 = temp - StormBuffer[0x400 + i]; - seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; - ch = block[0] ^ (seed1 + seed2); - - if(ch != decrypted) - continue; - - // Add 1 because we are decrypting block positions - saveSeed1 = seed1 + 1; - - // If OK, continue and test the second value. We don't know exactly the value, - // but we know that the second one has lower 16 bits set to zero - // (no compressed block is larger than 0xFFFF bytes) - seed1 = ((~seed1 << 0x15) + 0x11111111) | (seed1 >> 0x0B); - seed2 = ch + seed2 + (seed2 << 5) + 3; - - seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; - ch = block[1] ^ (seed1 + seed2); - - if((ch & 0xFFFF0000) == 0) - return saveSeed1; - } - return 0; -} - -// Function tries to detect file seed. It expectes at least two uncompressed bytes -DWORD DetectFileSeed2(DWORD * pdwBlock, UINT nDwords, ...) -{ - va_list argList; - DWORD dwDecrypted[0x10]; - DWORD saveSeed1; - DWORD dwTemp; - DWORD i, j; - - // We need at least two DWORDS to detect the seed - if(nDwords < 0x02 || nDwords > 0x10) - return 0; - - va_start(argList, nDwords); - for(i = 0; i < nDwords; i++) - dwDecrypted[i] = va_arg(argList, DWORD); - va_end(argList); - - dwTemp = (*pdwBlock ^ dwDecrypted[0]) - 0xEEEEEEEE; - for(i = 0; i < 0x100; i++) // Try all 255 possibilities - { - DWORD seed1; - DWORD seed2 = 0xEEEEEEEE; - DWORD ch; - - // Try the first DWORD - seed1 = dwTemp - StormBuffer[0x400 + i]; - seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; - ch = pdwBlock[0] ^ (seed1 + seed2); - - if(ch != dwDecrypted[0]) - continue; - - saveSeed1 = seed1; - - // If OK, continue and test all bytes. - for(j = 1; j < nDwords; j++) - { - seed1 = ((~seed1 << 0x15) + 0x11111111) | (seed1 >> 0x0B); - seed2 = ch + seed2 + (seed2 << 5) + 3; - - seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; - ch = pdwBlock[j] ^ (seed1 + seed2); - - if(ch == dwDecrypted[j] && j == nDwords - 1) - return saveSeed1; - } - } - return 0; -} - - -//----------------------------------------------------------------------------- -// Encrypting and decrypting MPQ blocks - -void EncryptMPQBlock(DWORD * block, DWORD dwLength, DWORD dwSeed1) -{ - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; - - // Round to DWORDs - dwLength >>= 2; - - while(dwLength-- > 0) - { - dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; - ch = *block; - *block++ = ch ^ (dwSeed1 + dwSeed2); - - dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); - dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; - } -} - -void DecryptMPQBlock(DWORD * block, DWORD dwLength, DWORD dwSeed1) -{ - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; - - // Round to DWORDs - dwLength >>= 2; - - while(dwLength-- > 0) - { - dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; - ch = *block ^ (dwSeed1 + dwSeed2); - - dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); - dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; - *block++ = ch; - } -} - - -DWORD DecryptHashIndex(TMPQArchive * ha, const char * szFileName) -{ - BYTE * pbKey = (BYTE *)szFileName; - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; - - while(*pbKey != 0) - { - ch = toupper(*pbKey++); - - dwSeed1 = StormBuffer[0x000 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - return (dwSeed1 & (ha->pHeader->dwHashTableSize - 1)); -} - -DWORD DecryptName1(const char * szFileName) -{ - BYTE * pbKey = (BYTE *)szFileName; - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; - - while(*pbKey != 0) - { - ch = toupper(*pbKey++); - - dwSeed1 = StormBuffer[0x100 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - return dwSeed1; -} - -DWORD DecryptName2(const char * szFileName) -{ - BYTE * pbKey = (BYTE *)szFileName; - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - int ch; - - while(*pbKey != 0) - { - ch = toupper(*pbKey++); - - dwSeed1 = StormBuffer[0x200 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - return dwSeed1; -} - -DWORD DecryptFileSeed(const char * szFileName) -{ - BYTE * pbKey = (BYTE *)szFileName; - DWORD dwSeed1 = 0x7FED7FED; // EBX - DWORD dwSeed2 = 0xEEEEEEEE; // ESI - DWORD ch; - - while(*pbKey != 0) - { - ch = toupper(*pbKey++); // ECX - - dwSeed1 = StormBuffer[0x300 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - return dwSeed1; -} - -TMPQHash * GetHashEntry(TMPQArchive * ha, const char * szFileName) -{ - TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash0; // File hash entry (start) - TMPQHash * pHash; // File hash entry (current) - DWORD dwIndex = (DWORD)(DWORD_PTR)szFileName; - DWORD dwName1; - DWORD dwName2; - - // If filename is given by index, we have to search all hash entries for the right index. - if(dwIndex <= ha->pHeader->dwBlockTableSize) - { - // Pass all the hash entries and find the - for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) - { - if(pHash->dwBlockIndex == dwIndex) - return pHash; - } - return NULL; - } - - // Decrypt name and block index - dwIndex = DecryptHashIndex(ha, szFileName); - dwName1 = DecryptName1(szFileName); - dwName2 = DecryptName2(szFileName); - pHash = pHash0 = ha->pHashTable + dwIndex; - - // Look for hash index - while(pHash->dwBlockIndex != HASH_ENTRY_FREE) - { - if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && pHash->dwBlockIndex != HASH_ENTRY_DELETED) - return pHash; - - // Move to the next hash entry - if(++pHash >= pHashEnd) - pHash = ha->pHashTable; - if(pHash == pHash0) - break; - } - - // File was not found - return NULL; -} - -// Retrieves the locale-specific hash entry -TMPQHash * GetHashEntryEx(TMPQArchive * ha, const char * szFileName, LCID lcLocale) -{ - TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash0 = NULL; // Language-neutral hash entry - TMPQHash * pHashX = NULL; // Language-speficic - TMPQHash * pHash = GetHashEntry(ha, szFileName); - - if(pHash != NULL) - { - TMPQHash * pHashStart = pHash; - DWORD dwName1 = pHash->dwName1; - DWORD dwName2 = pHash->dwName2; - - while(pHash->dwBlockIndex != HASH_ENTRY_FREE) - { - if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2) - { - if(pHash->lcLocale == LANG_NEUTRAL) - pHash0 = pHash; - if(pHash->lcLocale == lcLocale) - pHashX = pHash; - - // If both found, break the loop - if(pHash0 != NULL && pHashX != NULL) - break; - } - - if(++pHash >= pHashEnd) - pHash = ha->pHashTable; - if(pHash == pHashStart) - return NULL; - } - - if(lcLocale != LANG_NEUTRAL && pHashX != NULL) - return pHashX; - if(pHash0 != NULL) - return pHash0; - return NULL; - } - - return pHash; -} - -// Encrypts file name and gets the hash entry -// Returns the hash pointer, which is always within the allocated array -TMPQHash * FindFreeHashEntry(TMPQArchive * ha, const char * szFileName) -{ - TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash0; // File hash entry (search start) - TMPQHash * pHash; // File hash entry - DWORD dwIndex = DecryptHashIndex(ha, szFileName); - DWORD dwName1 = DecryptName1(szFileName); - DWORD dwName2 = DecryptName2(szFileName); - DWORD dwBlockIndex = 0xFFFFFFFF; - - // Save the starting hash position - pHash = pHash0 = ha->pHashTable + dwIndex; - - // Look for the first free hash entry. Can be also a deleted entry - while(pHash->dwBlockIndex < HASH_ENTRY_DELETED) - { - if(++pHash >= pHashEnd) - pHash = ha->pHashTable; - if(pHash == pHash0) - return NULL; - } - - // Fill the hash entry with the informations about the file name - pHash->dwName1 = dwName1; - pHash->dwName2 = dwName2; - pHash->lcLocale = (USHORT)lcLocale; - pHash->wPlatform = wPlatform; - - // Now we have to find a free block entry - for(dwIndex = 0; dwIndex < ha->pHeader->dwBlockTableSize; dwIndex++) - { - TMPQBlock * pBlock = ha->pBlockTable + dwIndex; - - if((pBlock->dwFlags & MPQ_FILE_EXISTS) == 0) - { - dwBlockIndex = dwIndex; - break; - } - } - - // If no free block entry found, we have to use the index - // at the end of the current block table - if(dwBlockIndex == 0xFFFFFFFF) - dwBlockIndex = ha->pHeader->dwBlockTableSize; - pHash->dwBlockIndex = dwBlockIndex; - return pHash; -} - -//----------------------------------------------------------------------------- -// Checking for valid archive handle and valid file handle - -BOOL IsValidMpqHandle(TMPQArchive * ha) -{ - if(ha == NULL || IsBadReadPtr(ha, sizeof(TMPQArchive))) - return FALSE; - if(ha->pHeader == NULL || IsBadReadPtr(ha->pHeader, sizeof(TMPQHeader))) - return FALSE; - - return (ha->pHeader->dwID == ID_MPQ); -} - -BOOL IsValidFileHandle(TMPQFile * hf) -{ - if(hf == NULL || IsBadReadPtr(hf, sizeof(TMPQFile))) - return FALSE; - - if(hf->hFile != INVALID_HANDLE_VALUE) - return TRUE; - - return IsValidMpqHandle(hf->ha); -} - -// This function writes a local file into the MPQ archive. -// Returns 0 if OK, otherwise error code. -// TODO: Test for archives > 4GB -int AddFileToArchive( - TMPQArchive * ha, - HANDLE hFile, - const char * szArchivedName, - DWORD dwFlags, - DWORD dwQuality, - int nFileType, - BOOL * pbReplaced) -{ - LARGE_INTEGER RelativePos = {0}; - LARGE_INTEGER FilePos = {0}; - LARGE_INTEGER TempPos; - TMPQBlockEx * pBlockEx = NULL; // Entry in the extended block table - TMPQBlock * pBlock = NULL; // Entry in the block table - TMPQHash * pHash = NULL; // Entry in the hash table - DWORD * pdwBlockPos = NULL; // Block position table (compressed files only) - BYTE * pbFileData = NULL; // Uncompressed (source) data - BYTE * pbCompressed = NULL; // Compressed (target) data - BYTE * pbToWrite = NULL; // Data to write to the file - DWORD dwBlockPosLen = 0; // Length of the block table positions - DWORD dwTransferred = 0; // Number of bytes written into archive file - DWORD dwFileSize = 0; // Size of the file to add - DWORD dwSeed1 = 0; // Encryption seed - DWORD nBlocks = 0; // Number of file blocks - DWORD nBlock = 0; // Index of the currently written block - BOOL bReplaced = FALSE; // TRUE if replaced, FALSE if added - int nCmpFirst = nDataCmp; // Compression for the first data block - int nCmpNext = nDataCmp; // Compression for the next data blocks - int nCmp = nDataCmp; // Current compression - int nCmpLevel = -1; // Compression level - int nError = ERROR_SUCCESS; - - // Set the correct compression types - if(dwFlags & MPQ_FILE_COMPRESS_PKWARE) - nCmpFirst = nCmpNext = MPQ_COMPRESSION_PKWARE; - - if(dwFlags & MPQ_FILE_COMPRESS_MULTI) - { - if(nFileType == SFILE_TYPE_DATA) - nCmpFirst = nCmpNext = nDataCmp; - - if(nFileType == SFILE_TYPE_WAVE) - { - nCmpNext = uWaveCmpType[dwQuality]; - nCmpLevel = uWaveCmpLevel[dwQuality]; - } - } - - // Check if the file already exists in the archive - if(nError == ERROR_SUCCESS) - { - if((pHash = GetHashEntryEx(ha, szArchivedName, lcLocale)) != NULL) - { - if(pHash->lcLocale == lcLocale) - { - if((dwFlags & MPQ_FILE_REPLACEEXISTING) == 0) - { - nError = ERROR_ALREADY_EXISTS; - pHash = NULL; - } - else - bReplaced = TRUE; - } - else - pHash = NULL; - } - - if(nError == ERROR_SUCCESS && pHash == NULL) - { - pHash = FindFreeHashEntry(ha, szArchivedName); - if(pHash == NULL) - nError = ERROR_HANDLE_DISK_FULL; - } - } - - // Get the block table entry for the file - if(nError == ERROR_SUCCESS) - { - DWORD dwFileSizeHigh = 0; - - // Get the size of the added file - dwFileSize = GetFileSize(hFile, &dwFileSizeHigh); - if(dwFileSizeHigh != 0) - nError = ERROR_PARAMETER_QUOTA_EXCEEDED; - - // Fix the flags, if the file is too small - if(dwFileSize < 0x04) - dwFlags &= ~(MPQ_FILE_ENCRYPTED | MPQ_FILE_FIXSEED); - if(dwFileSize < 0x20) - dwFlags &= ~MPQ_FILE_COMPRESSED; - - if(pHash->dwBlockIndex == HASH_ENTRY_FREE) - pHash->dwBlockIndex = ha->pHeader->dwBlockTableSize; - - // The block table index cannot be larger than hash table size - if(pHash->dwBlockIndex >= ha->pHeader->dwHashTableSize) - nError = ERROR_HANDLE_DISK_FULL; - } - - // The file will be stored after the end of the last archived file - // (i.e. at old position of archived file - if(nError == ERROR_SUCCESS) - { - TMPQBlock * pBlockEnd = ha->pBlockTable + ha->pHeader->dwBlockTableSize; - const char * szTemp = strrchr(szArchivedName, '\\'); - - // Get the position of the first file - RelativePos.QuadPart = ha->pHeader->dwHeaderSize; - - // Find the position of the last file. It has to be after the last archived file - // (Do not use the dwArchiveSize here, because it may or may not - // include the hash table at the end of the file - pBlockEx = ha->pExtBlockTable; - for(pBlock = ha->pBlockTable; pBlock < pBlockEnd; pBlock++, pBlockEx++) - { - if(pBlock->dwFlags & MPQ_FILE_EXISTS) - { - TempPos.HighPart = pBlockEx->wFilePosHigh; - TempPos.LowPart = pBlock->dwFilePos; - TempPos.QuadPart += pBlock->dwCSize; - - if(TempPos.QuadPart > RelativePos.QuadPart) - RelativePos = TempPos; - } - } - - // When format V1, we cannot exceed 4 GB - if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) - { - TempPos.QuadPart = ha->MpqPos.QuadPart + RelativePos.QuadPart; - TempPos.QuadPart += ha->pHeader->dwHashTableSize * sizeof(TMPQHash); - TempPos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); - TempPos.QuadPart += dwFileSize; - - if(TempPos.HighPart != 0) - nError = ERROR_DISK_FULL; - } - - // Get pointers to both block entries of the file - pBlockEx = ha->pExtBlockTable + pHash->dwBlockIndex; - pBlock = ha->pBlockTable + pHash->dwBlockIndex; - - // Save the file size info - pBlockEx->wFilePosHigh = (USHORT)RelativePos.HighPart; - pBlock->dwFilePos = RelativePos.LowPart; - pBlock->dwFSize = GetFileSize(hFile, NULL); - pBlock->dwFlags = dwFlags | MPQ_FILE_EXISTS; - - // Create seed1 for file encryption - if(szTemp != NULL) - szArchivedName = szTemp + 1; - - if(dwFlags & MPQ_FILE_ENCRYPTED) - { - dwSeed1 = DecryptFileSeed(szArchivedName); - - if(dwFlags & MPQ_FILE_FIXSEED) - dwSeed1 = (dwSeed1 + pBlock->dwFilePos) ^ pBlock->dwFSize; - } - } - - // Allocate buffer for the input data - if(nError == ERROR_SUCCESS) - { - nBlocks = (pBlock->dwFSize / ha->dwBlockSize) + 1; - if(pBlock->dwFSize % ha->dwBlockSize) - nBlocks++; - - pBlock->dwCSize = 0; - if((pbFileData = ALLOCMEM(BYTE, ha->dwBlockSize)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - pbToWrite = pbFileData; - } - - // Allocate buffers for the compressed data - if(nError == ERROR_SUCCESS && (dwFlags & MPQ_FILE_COMPRESSED)) - { - pdwBlockPos = ALLOCMEM(DWORD, nBlocks + 1); - pbCompressed = ALLOCMEM(BYTE, ha->dwBlockSize * 2); - if(pdwBlockPos == NULL || pbCompressed == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - pbToWrite = pbCompressed; - } - - // Set the file position to the point where the file will be stored - if(nError == ERROR_SUCCESS) - { - // Set the file pointer to file data position - FilePos.QuadPart = ha->MpqPos.QuadPart + RelativePos.QuadPart; - if(FilePos.QuadPart != ha->FilePointer.QuadPart) - { - SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN); - ha->FilePointer = FilePos; - } - } - - // Write block positions (if the file will be compressed) - if(nError == ERROR_SUCCESS && (dwFlags & MPQ_FILE_COMPRESSED)) - { - dwBlockPosLen = nBlocks * sizeof(DWORD); - if(dwFlags & MPQ_FILE_HAS_EXTRA) - dwBlockPosLen += sizeof(DWORD); - - memset(pdwBlockPos, 0, dwBlockPosLen); - pdwBlockPos[0] = dwBlockPosLen; - - // Write the block positions - BSWAP_ARRAY32_UNSIGNED((DWORD *)pdwBlockPos, nBlocks); - WriteFile(ha->hFile, pdwBlockPos, dwBlockPosLen, &dwTransferred, NULL); - BSWAP_ARRAY32_UNSIGNED((DWORD *)pdwBlockPos, nBlocks); - - if(dwTransferred == dwBlockPosLen) - pBlock->dwCSize += dwBlockPosLen; - else - nError = GetLastError(); - - // Update the current position in the file - ha->HashTablePos.QuadPart = FilePos.QuadPart + dwTransferred; - } - - // Write all file blocks - if(nError == ERROR_SUCCESS) - { - nCmp = nCmpFirst; - - SetFilePointer(hFile, 0, NULL, FILE_BEGIN); - for(nBlock = 0; nBlock < nBlocks-1; nBlock++) - { - DWORD dwInLength = ha->dwBlockSize; - DWORD dwOutLength = ha->dwBlockSize; - - // Load the block from the file - ReadFile(hFile, pbFileData, ha->dwBlockSize, &dwInLength, NULL); - if(dwInLength == 0) - break; - - // Compress the block, if necessary - dwOutLength = dwInLength; - if(pBlock->dwFlags & MPQ_FILE_COMPRESSED) - { - // Should be enough for compression - int nOutLength = ha->dwBlockSize * 2; - int nCmpType = 0; - - if(pBlock->dwFlags & MPQ_FILE_COMPRESS_PKWARE) - Compress_pklib((char *)pbCompressed, &nOutLength, (char *)pbFileData, dwInLength, &nCmpType, 0); - - if(pBlock->dwFlags & MPQ_FILE_COMPRESS_MULTI) - SCompCompress((char *)pbCompressed, &nOutLength, (char *)pbFileData, dwInLength, nCmp, 0, nCmpLevel); - - // The compressed block size must NOT be the same or greater like - // the original block size. If yes, do not compress the block - // and store the data as-is. - if(nOutLength >= (int)dwInLength) - { - memcpy(pbCompressed, pbFileData, dwInLength); - nOutLength = dwInLength; - } - - // Update block positions - dwOutLength = nOutLength; - pdwBlockPos[nBlock+1] = pdwBlockPos[nBlock] + dwOutLength; - nCmp = nCmpNext; - } - - // Encrypt the block, if necessary - if(pBlock->dwFlags & MPQ_FILE_ENCRYPTED) - { - BSWAP_ARRAY32_UNSIGNED((DWORD *)pbToWrite, dwOutLength / sizeof(DWORD)); - EncryptMPQBlock((DWORD *)pbToWrite, dwOutLength, dwSeed1 + nBlock); - BSWAP_ARRAY32_UNSIGNED((DWORD *)pbToWrite, dwOutLength / sizeof(DWORD)); - } - - // Write the block - WriteFile(ha->hFile, pbToWrite, dwOutLength, &dwTransferred, NULL); - if(dwTransferred != dwOutLength) - { - nError = ERROR_DISK_FULL; - break; - } - - // Update the hash table position and the compressed file size - ha->HashTablePos.QuadPart += dwTransferred; - pBlock->dwCSize += dwOutLength; - } - } - - // Now save the block positions - if(nError == ERROR_SUCCESS && (pBlock->dwFlags & MPQ_FILE_COMPRESSED)) - { - if(dwFlags & MPQ_FILE_HAS_EXTRA) - pdwBlockPos[nBlocks] = pdwBlockPos[nBlocks-1]; - - // If file is encrypted, block positions are also encrypted - if(dwFlags & MPQ_FILE_ENCRYPTED) - EncryptMPQBlock(pdwBlockPos, dwBlockPosLen, dwSeed1 - 1); - - // Set the position back to the block table - SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN); - - // Write block positions to the archive - BSWAP_ARRAY32_UNSIGNED((DWORD *)pdwBlockPos, nBlocks); - WriteFile(ha->hFile, pdwBlockPos, dwBlockPosLen, &dwTransferred, NULL); - if(dwTransferred != dwBlockPosLen) - nError = ERROR_DISK_FULL; - - ha->FilePointer.QuadPart = ha->FilePointer.QuadPart + dwTransferred; - } - - // If success, we have to change the settings - // in MPQ header. If failed, we have to clean hash entry - if(nError == ERROR_SUCCESS) - { - ha->pLastFile = NULL; - ha->dwBlockPos = 0; - ha->dwBuffPos = 0; - ha->dwFlags |= MPQ_FLAG_CHANGED; - - // Add new entry to the block table (if needed) - if(pHash->dwBlockIndex >= ha->pHeader->dwBlockTableSize) - ha->pHeader->dwBlockTableSize++; - - // Hash table size in the TMPQArchive is already set at this point - RelativePos.QuadPart = ha->HashTablePos.QuadPart - ha->MpqPos.QuadPart; - ha->pHeader->dwHashTablePos = RelativePos.LowPart; - ha->pHeader->wHashTablePosHigh = (USHORT)RelativePos.HighPart; - - // Update block table pos - RelativePos.QuadPart += (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)); - ha->pHeader->wBlockTablePosHigh = (USHORT)RelativePos.HighPart; - ha->pHeader->dwBlockTablePos = RelativePos.LowPart; - ha->BlockTablePos.QuadPart = RelativePos.QuadPart + ha->MpqPos.QuadPart; - - // If the archive size exceeded 4GB, we have to use extended block table pos - RelativePos.QuadPart += (ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock)); - if(RelativePos.HighPart != 0) - { - ha->pHeader->ExtBlockTablePos = RelativePos; - ha->ExtBlockTablePos.QuadPart = RelativePos.QuadPart + ha->MpqPos.QuadPart; - - RelativePos.QuadPart += (ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx)); - } - - // Update archive size (only valid for version V1) - ha->MpqSize = RelativePos; - ha->pHeader->dwArchiveSize = ha->MpqSize.LowPart; - } - else - { - // Clear the hash table entry - if(pHash != NULL) - memset(pHash, 0xFF, sizeof(TMPQHash)); - } - - // Cleanup - if(pbCompressed != NULL) - FREEMEM(pbCompressed); - if(pdwBlockPos != NULL) - FREEMEM(pdwBlockPos); - if(pbFileData != NULL) - FREEMEM(pbFileData); - if(pbReplaced != NULL) - *pbReplaced = bReplaced; - return nError; -} - -int SetDataCompression(int nDataCompression) -{ - nDataCmp = nDataCompression; - return 0; -} - -// This method saves MPQ header, hash table and block table. -// TODO: Test for archives > 4GB -int SaveMPQTables(TMPQArchive * ha) -{ - BYTE * pbBuffer = NULL; - DWORD dwBytes; - DWORD dwWritten; - DWORD dwBuffSize = max(ha->pHeader->dwHashTableSize, ha->pHeader->dwBlockTableSize); - int nError = ERROR_SUCCESS; - - // Allocate buffer for encrypted tables - if(nError == ERROR_SUCCESS) - { - // Allocate temporary buffer for tables encryption - pbBuffer = ALLOCMEM(BYTE, sizeof(TMPQHash) * dwBuffSize); - if(pbBuffer == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Write the MPQ Header - if(nError == ERROR_SUCCESS) - { - DWORD dwHeaderSize = ha->pHeader->dwHeaderSize; - - // Write the MPQ header - SetFilePointer(ha->hFile, ha->MpqPos.LowPart, &ha->MpqPos.HighPart, FILE_BEGIN); - - // Convert to little endian for file save - BSWAP_TMPQHEADER(ha->pHeader); - WriteFile(ha->hFile, ha->pHeader, dwHeaderSize, &dwWritten, NULL); - BSWAP_TMPQHEADER(ha->pHeader); - - if(dwWritten != ha->pHeader->dwHeaderSize) - nError = ERROR_DISK_FULL; - } - - // Write the hash table - if(nError == ERROR_SUCCESS) - { - // Copy the hash table to temporary buffer - dwBytes = ha->pHeader->dwHashTableSize * sizeof(TMPQHash); - memcpy(pbBuffer, ha->pHashTable, dwBytes); - - // Convert to little endian for file save - EncryptHashTable((DWORD *)pbBuffer, (BYTE *)"(hash table)", dwBytes >> 2); - BSWAP_ARRAY32_UNSIGNED((DWORD *)pbBuffer, dwBytes / sizeof(DWORD)); - - // Set the file pointer to the offset of the hash table and write it - SetFilePointer(ha->hFile, ha->HashTablePos.LowPart, (PLONG)&ha->HashTablePos.HighPart, FILE_BEGIN); - WriteFile(ha->hFile, pbBuffer, dwBytes, &dwWritten, NULL); - if(dwWritten != dwBytes) - nError = ERROR_DISK_FULL; - } - - // Write the block table - if(nError == ERROR_SUCCESS) - { - // Copy the block table to temporary buffer - dwBytes = ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); - memcpy(pbBuffer, ha->pBlockTable, dwBytes); - - // Encrypt the block table and write it to the file - EncryptBlockTable((DWORD *)pbBuffer, (BYTE *)"(block table)", dwBytes >> 2); - - // Convert to little endian for file save - BSWAP_ARRAY32_UNSIGNED((DWORD *)pbBuffer, dwBytes / sizeof(DWORD)); - WriteFile(ha->hFile, pbBuffer, dwBytes, &dwWritten, NULL); - if(dwWritten != dwBytes) - nError = ERROR_DISK_FULL; - } - - // Write the extended block table - if(nError == ERROR_SUCCESS && ha->pHeader->ExtBlockTablePos.QuadPart != 0) - { - // We expect format V2 or newer in this case - assert(ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_2); - - // Copy the block table to temporary buffer - dwBytes = ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx); - memcpy(pbBuffer, ha->pExtBlockTable, dwBytes); - - // Convert to little endian for file save - BSWAP_ARRAY16_UNSIGNED((USHORT *)pbBuffer, dwBytes / sizeof(USHORT)); - WriteFile(ha->hFile, pbBuffer, dwBytes, &dwWritten, NULL); - if(dwWritten != dwBytes) - nError = ERROR_DISK_FULL; - } - - - // Set end of file here - if(nError == ERROR_SUCCESS) - { - SetEndOfFile(ha->hFile); - } - - // Cleanup and exit - if(pbBuffer != NULL) - FREEMEM(pbBuffer); - return nError; -} - -// Frees the MPQ archive -// TODO: Test for archives > 4GB -void FreeMPQArchive(TMPQArchive *& ha) -{ - if(ha != NULL) - { - FREEMEM(ha->pbBlockBuffer); - FREEMEM(ha->pBlockTable); - FREEMEM(ha->pExtBlockTable); - FREEMEM(ha->pHashTable); - if(ha->pListFile != NULL) - SListFileFreeListFile(ha); - - if(ha->hFile != INVALID_HANDLE_VALUE) - CloseHandle(ha->hFile); - FREEMEM(ha); - ha = NULL; - } -} +/*****************************************************************************/ +/* SCommon.cpp Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* Common functions for StormLib, used by all SFile*** modules */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 24.03.03 1.00 Lad The first version of SFileCommon.cpp */ +/* 19.11.03 1.01 Dan Big endian handling */ +/* 12.06.04 1.01 Lad Renamed to SCommon.cpp */ +/*****************************************************************************/ + +#define __STORMLIB_SELF__ +#include "StormLib.h" +#include "SCommon.h" + +char StormLibCopyright[] = "StormLib v 4.50 Copyright Ladislav Zezula 1998-2003"; + +//----------------------------------------------------------------------------- +// The buffer for decryption engine. + +TMPQArchive * pFirstOpen = NULL; // The first member of MPQ archives chain +LCID lcLocale = LANG_NEUTRAL; // File locale +USHORT wPlatform = 0; // File platform + +//----------------------------------------------------------------------------- +// Compression types + +// +// Data compressions +// +// Can be combination of MPQ_COMPRESSION_PKWARE, MPQ_COMPRESSION_BZIP2 +// and MPQ_COMPRESSION_ZLIB. Some newer compressions are not supported +// by older games. The table of supported compressions is here: +// +// MPQ_COMPRESSION_PKWARE - All games since Diablo I +// MPQ_COMPRESSION_ZLIB - Games since Starcraft +// MPQ_COMPRESSION_BZIP2 - Games since World of Warcraft +// + +static int nDataCmp = MPQ_COMPRESSION_ZLIB; + +// +// WAVE compressions by quality level +// + +static int uWaveCmpLevel[] = {-1, 4, 2}; +static int uWaveCmpType[] = {MPQ_COMPRESSION_PKWARE, 0x81, 0x81}; + +//----------------------------------------------------------------------------- +// Storm buffer functions + +// Buffer for the decryption engine +#define STORM_BUFFER_SIZE 0x500 +static DWORD StormBuffer[STORM_BUFFER_SIZE]; +static BOOL bStormBufferCreated = FALSE; + +int PrepareStormBuffer() +{ + DWORD dwSeed = 0x00100001; + DWORD index1 = 0; + DWORD index2 = 0; + int i; + + // Initialize the decryption buffer. + // Do nothing if already done. + if(bStormBufferCreated == FALSE) + { + for(index1 = 0; index1 < 0x100; index1++) + { + for(index2 = index1, i = 0; i < 5; i++, index2 += 0x100) + { + DWORD temp1, temp2; + + dwSeed = (dwSeed * 125 + 3) % 0x2AAAAB; + temp1 = (dwSeed & 0xFFFF) << 0x10; + + dwSeed = (dwSeed * 125 + 3) % 0x2AAAAB; + temp2 = (dwSeed & 0xFFFF); + + StormBuffer[index2] = (temp1 | temp2); + } + } + bStormBufferCreated = TRUE; + } + return ERROR_SUCCESS; +} + +//----------------------------------------------------------------------------- +// Encrypting and decrypting hash table + +void EncryptHashTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength) +{ + DWORD dwSeed1 = 0x7FED7FED; + DWORD dwSeed2 = 0xEEEEEEEE; + DWORD ch; // One key character + + // Prepare seeds + while(*pbKey != 0) + { + ch = toupper(*pbKey++); + + dwSeed1 = StormBuffer[0x300 + ch] ^ (dwSeed1 + dwSeed2); + dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; + } + + // Encrypt it + dwSeed2 = 0xEEEEEEEE; + while(dwLength-- > 0) + { + dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; + ch = *pdwTable; + *pdwTable++ = ch ^ (dwSeed1 + dwSeed2); + + dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); + dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; + } +} + +void DecryptHashTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength) +{ + DWORD dwSeed1 = 0x7FED7FED; + DWORD dwSeed2 = 0xEEEEEEEE; + DWORD ch; // One key character + + // Prepare seeds + while(*pbKey != 0) + { + ch = toupper(*pbKey++); + + dwSeed1 = StormBuffer[0x300 + ch] ^ (dwSeed1 + dwSeed2); + dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; + } + + // Decrypt it + dwSeed2 = 0xEEEEEEEE; + while(dwLength-- > 0) + { + dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; + ch = *pdwTable ^ (dwSeed1 + dwSeed2); + + dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); + dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; + *pdwTable++ = ch; + } +} + +//----------------------------------------------------------------------------- +// Encrypting and decrypting block table + +void EncryptBlockTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength) +{ + DWORD dwSeed1 = 0x7FED7FED; + DWORD dwSeed2 = 0xEEEEEEEE; + DWORD ch; // One key character + + // Prepare seeds + while(*pbKey != 0) + { + ch = toupper(*pbKey++); + + dwSeed1 = StormBuffer[0x300 + ch] ^ (dwSeed1 + dwSeed2); + dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; + } + + // Decrypt it + dwSeed2 = 0xEEEEEEEE; + while(dwLength-- > 0) + { + dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; + ch = *pdwTable; + *pdwTable++ = ch ^ (dwSeed1 + dwSeed2); + + dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); + dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; + } +} + +void DecryptBlockTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength) +{ + DWORD dwSeed1 = 0x7FED7FED; + DWORD dwSeed2 = 0xEEEEEEEE; + DWORD ch; // One key character + + // Prepare seeds + while(*pbKey != 0) + { + ch = toupper(*pbKey++); + + dwSeed1 = StormBuffer[0x300 + ch] ^ (dwSeed1 + dwSeed2); + dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; + } + + // Encrypt it + dwSeed2 = 0xEEEEEEEE; + while(dwLength-- > 0) + { + dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; + ch = *pdwTable ^ (dwSeed1 + dwSeed2); + + dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); + dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; + *pdwTable++ = ch; + } +} + +//----------------------------------------------------------------------------- +// Functions tries to get file decryption key. The trick comes from block +// positions which are stored at the begin of each compressed file. We know the +// file size, that means we know number of blocks that means we know the first +// DWORD value in block position. And if we know encrypted and decrypted value, +// we can find the decryption key !!! +// +// hf - MPQ file handle +// block - DWORD array of block positions +// ch - Decrypted value of the first block pos + +DWORD DetectFileSeed(DWORD * block, DWORD decrypted) +{ + DWORD saveSeed1; + DWORD temp = *block ^ decrypted; // temp = seed1 + seed2 + temp -= 0xEEEEEEEE; // temp = seed1 + StormBuffer[0x400 + (seed1 & 0xFF)] + + for(int i = 0; i < 0x100; i++) // Try all 255 possibilities + { + DWORD seed1; + DWORD seed2 = 0xEEEEEEEE; + DWORD ch; + + // Try the first DWORD (We exactly know the value) + seed1 = temp - StormBuffer[0x400 + i]; + seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; + ch = block[0] ^ (seed1 + seed2); + + if(ch != decrypted) + continue; + + // Add 1 because we are decrypting block positions + saveSeed1 = seed1 + 1; + + // If OK, continue and test the second value. We don't know exactly the value, + // but we know that the second one has lower 16 bits set to zero + // (no compressed block is larger than 0xFFFF bytes) + seed1 = ((~seed1 << 0x15) + 0x11111111) | (seed1 >> 0x0B); + seed2 = ch + seed2 + (seed2 << 5) + 3; + + seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; + ch = block[1] ^ (seed1 + seed2); + + if((ch & 0xFFFF0000) == 0) + return saveSeed1; + } + return 0; +} + +// Function tries to detect file seed. It expectes at least two uncompressed bytes +DWORD DetectFileSeed2(DWORD * pdwBlock, UINT nDwords, ...) +{ + va_list argList; + DWORD dwDecrypted[0x10]; + DWORD saveSeed1; + DWORD dwTemp; + DWORD i, j; + + // We need at least two DWORDS to detect the seed + if(nDwords < 0x02 || nDwords > 0x10) + return 0; + + va_start(argList, nDwords); + for(i = 0; i < nDwords; i++) + dwDecrypted[i] = va_arg(argList, DWORD); + va_end(argList); + + dwTemp = (*pdwBlock ^ dwDecrypted[0]) - 0xEEEEEEEE; + for(i = 0; i < 0x100; i++) // Try all 255 possibilities + { + DWORD seed1; + DWORD seed2 = 0xEEEEEEEE; + DWORD ch; + + // Try the first DWORD + seed1 = dwTemp - StormBuffer[0x400 + i]; + seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; + ch = pdwBlock[0] ^ (seed1 + seed2); + + if(ch != dwDecrypted[0]) + continue; + + saveSeed1 = seed1; + + // If OK, continue and test all bytes. + for(j = 1; j < nDwords; j++) + { + seed1 = ((~seed1 << 0x15) + 0x11111111) | (seed1 >> 0x0B); + seed2 = ch + seed2 + (seed2 << 5) + 3; + + seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; + ch = pdwBlock[j] ^ (seed1 + seed2); + + if(ch == dwDecrypted[j] && j == nDwords - 1) + return saveSeed1; + } + } + return 0; +} + + +//----------------------------------------------------------------------------- +// Encrypting and decrypting MPQ blocks + +void EncryptMPQBlock(DWORD * block, DWORD dwLength, DWORD dwSeed1) +{ + DWORD dwSeed2 = 0xEEEEEEEE; + DWORD ch; + + // Round to DWORDs + dwLength >>= 2; + + while(dwLength-- > 0) + { + dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; + ch = *block; + *block++ = ch ^ (dwSeed1 + dwSeed2); + + dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); + dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; + } +} + +void DecryptMPQBlock(DWORD * block, DWORD dwLength, DWORD dwSeed1) +{ + DWORD dwSeed2 = 0xEEEEEEEE; + DWORD ch; + + // Round to DWORDs + dwLength >>= 2; + + while(dwLength-- > 0) + { + dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; + ch = *block ^ (dwSeed1 + dwSeed2); + + dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); + dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; + *block++ = ch; + } +} + + +DWORD DecryptHashIndex(TMPQArchive * ha, const char * szFileName) +{ + BYTE * pbKey = (BYTE *)szFileName; + DWORD dwSeed1 = 0x7FED7FED; + DWORD dwSeed2 = 0xEEEEEEEE; + DWORD ch; + + while(*pbKey != 0) + { + ch = toupper(*pbKey++); + + dwSeed1 = StormBuffer[0x000 + ch] ^ (dwSeed1 + dwSeed2); + dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; + } + return (dwSeed1 & (ha->pHeader->dwHashTableSize - 1)); +} + +DWORD DecryptName1(const char * szFileName) +{ + BYTE * pbKey = (BYTE *)szFileName; + DWORD dwSeed1 = 0x7FED7FED; + DWORD dwSeed2 = 0xEEEEEEEE; + DWORD ch; + + while(*pbKey != 0) + { + ch = toupper(*pbKey++); + + dwSeed1 = StormBuffer[0x100 + ch] ^ (dwSeed1 + dwSeed2); + dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; + } + return dwSeed1; +} + +DWORD DecryptName2(const char * szFileName) +{ + BYTE * pbKey = (BYTE *)szFileName; + DWORD dwSeed1 = 0x7FED7FED; + DWORD dwSeed2 = 0xEEEEEEEE; + int ch; + + while(*pbKey != 0) + { + ch = toupper(*pbKey++); + + dwSeed1 = StormBuffer[0x200 + ch] ^ (dwSeed1 + dwSeed2); + dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; + } + return dwSeed1; +} + +DWORD DecryptFileSeed(const char * szFileName) +{ + BYTE * pbKey = (BYTE *)szFileName; + DWORD dwSeed1 = 0x7FED7FED; // EBX + DWORD dwSeed2 = 0xEEEEEEEE; // ESI + DWORD ch; + + while(*pbKey != 0) + { + ch = toupper(*pbKey++); // ECX + + dwSeed1 = StormBuffer[0x300 + ch] ^ (dwSeed1 + dwSeed2); + dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; + } + return dwSeed1; +} + +TMPQHash * GetHashEntry(TMPQArchive * ha, const char * szFileName) +{ + TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; + TMPQHash * pHash0; // File hash entry (start) + TMPQHash * pHash; // File hash entry (current) + DWORD dwIndex = (DWORD)(DWORD_PTR)szFileName; + DWORD dwName1; + DWORD dwName2; + + // If filename is given by index, we have to search all hash entries for the right index. + if(dwIndex <= ha->pHeader->dwBlockTableSize) + { + // Pass all the hash entries and find the + for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) + { + if(pHash->dwBlockIndex == dwIndex) + return pHash; + } + return NULL; + } + + // Decrypt name and block index + dwIndex = DecryptHashIndex(ha, szFileName); + dwName1 = DecryptName1(szFileName); + dwName2 = DecryptName2(szFileName); + pHash = pHash0 = ha->pHashTable + dwIndex; + + // Look for hash index + while(pHash->dwBlockIndex != HASH_ENTRY_FREE) + { + if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && pHash->dwBlockIndex != HASH_ENTRY_DELETED) + return pHash; + + // Move to the next hash entry + if(++pHash >= pHashEnd) + pHash = ha->pHashTable; + if(pHash == pHash0) + break; + } + + // File was not found + return NULL; +} + +// Retrieves the locale-specific hash entry +TMPQHash * GetHashEntryEx(TMPQArchive * ha, const char * szFileName, LCID lcLocale) +{ + TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; + TMPQHash * pHash0 = NULL; // Language-neutral hash entry + TMPQHash * pHashX = NULL; // Language-speficic + TMPQHash * pHash = GetHashEntry(ha, szFileName); + + if(pHash != NULL) + { + TMPQHash * pHashStart = pHash; + DWORD dwName1 = pHash->dwName1; + DWORD dwName2 = pHash->dwName2; + + while(pHash->dwBlockIndex != HASH_ENTRY_FREE) + { + if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2) + { + if(pHash->lcLocale == LANG_NEUTRAL) + pHash0 = pHash; + if(pHash->lcLocale == lcLocale) + pHashX = pHash; + + // If both found, break the loop + if(pHash0 != NULL && pHashX != NULL) + break; + } + + if(++pHash >= pHashEnd) + pHash = ha->pHashTable; + if(pHash == pHashStart) + return NULL; + } + + if(lcLocale != LANG_NEUTRAL && pHashX != NULL) + return pHashX; + if(pHash0 != NULL) + return pHash0; + return NULL; + } + + return pHash; +} + +// Encrypts file name and gets the hash entry +// Returns the hash pointer, which is always within the allocated array +TMPQHash * FindFreeHashEntry(TMPQArchive * ha, const char * szFileName) +{ + TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; + TMPQHash * pHash0; // File hash entry (search start) + TMPQHash * pHash; // File hash entry + DWORD dwIndex = DecryptHashIndex(ha, szFileName); + DWORD dwName1 = DecryptName1(szFileName); + DWORD dwName2 = DecryptName2(szFileName); + DWORD dwBlockIndex = 0xFFFFFFFF; + + // Save the starting hash position + pHash = pHash0 = ha->pHashTable + dwIndex; + + // Look for the first free hash entry. Can be also a deleted entry + while(pHash->dwBlockIndex < HASH_ENTRY_DELETED) + { + if(++pHash >= pHashEnd) + pHash = ha->pHashTable; + if(pHash == pHash0) + return NULL; + } + + // Fill the hash entry with the informations about the file name + pHash->dwName1 = dwName1; + pHash->dwName2 = dwName2; + pHash->lcLocale = (USHORT)lcLocale; + pHash->wPlatform = wPlatform; + + // Now we have to find a free block entry + for(dwIndex = 0; dwIndex < ha->pHeader->dwBlockTableSize; dwIndex++) + { + TMPQBlock * pBlock = ha->pBlockTable + dwIndex; + + if((pBlock->dwFlags & MPQ_FILE_EXISTS) == 0) + { + dwBlockIndex = dwIndex; + break; + } + } + + // If no free block entry found, we have to use the index + // at the end of the current block table + if(dwBlockIndex == 0xFFFFFFFF) + dwBlockIndex = ha->pHeader->dwBlockTableSize; + pHash->dwBlockIndex = dwBlockIndex; + return pHash; +} + +//----------------------------------------------------------------------------- +// Checking for valid archive handle and valid file handle + +BOOL IsValidMpqHandle(TMPQArchive * ha) +{ + if(ha == NULL || IsBadReadPtr(ha, sizeof(TMPQArchive))) + return FALSE; + if(ha->pHeader == NULL || IsBadReadPtr(ha->pHeader, sizeof(TMPQHeader))) + return FALSE; + + return (ha->pHeader->dwID == ID_MPQ); +} + +BOOL IsValidFileHandle(TMPQFile * hf) +{ + if(hf == NULL || IsBadReadPtr(hf, sizeof(TMPQFile))) + return FALSE; + + if(hf->hFile != INVALID_HANDLE_VALUE) + return TRUE; + + return IsValidMpqHandle(hf->ha); +} + +// This function writes a local file into the MPQ archive. +// Returns 0 if OK, otherwise error code. +// TODO: Test for archives > 4GB +int AddFileToArchive( + TMPQArchive * ha, + HANDLE hFile, + const char * szArchivedName, + DWORD dwFlags, + DWORD dwQuality, + int nFileType, + BOOL * pbReplaced) +{ + LARGE_INTEGER RelativePos = {0}; + LARGE_INTEGER FilePos = {0}; + LARGE_INTEGER TempPos; + TMPQBlockEx * pBlockEx = NULL; // Entry in the extended block table + TMPQBlock * pBlock = NULL; // Entry in the block table + TMPQHash * pHash = NULL; // Entry in the hash table + DWORD * pdwBlockPos = NULL; // Block position table (compressed files only) + BYTE * pbFileData = NULL; // Uncompressed (source) data + BYTE * pbCompressed = NULL; // Compressed (target) data + BYTE * pbToWrite = NULL; // Data to write to the file + DWORD dwBlockPosLen = 0; // Length of the block table positions + DWORD dwTransferred = 0; // Number of bytes written into archive file + DWORD dwFileSize = 0; // Size of the file to add + DWORD dwSeed1 = 0; // Encryption seed + DWORD nBlocks = 0; // Number of file blocks + DWORD nBlock = 0; // Index of the currently written block + BOOL bReplaced = FALSE; // TRUE if replaced, FALSE if added + int nCmpFirst = nDataCmp; // Compression for the first data block + int nCmpNext = nDataCmp; // Compression for the next data blocks + int nCmp = nDataCmp; // Current compression + int nCmpLevel = -1; // Compression level + int nError = ERROR_SUCCESS; + + // Set the correct compression types + if(dwFlags & MPQ_FILE_COMPRESS_PKWARE) + nCmpFirst = nCmpNext = MPQ_COMPRESSION_PKWARE; + + if(dwFlags & MPQ_FILE_COMPRESS_MULTI) + { + if(nFileType == SFILE_TYPE_DATA) + nCmpFirst = nCmpNext = nDataCmp; + + if(nFileType == SFILE_TYPE_WAVE) + { + nCmpNext = uWaveCmpType[dwQuality]; + nCmpLevel = uWaveCmpLevel[dwQuality]; + } + } + + // Check if the file already exists in the archive + if(nError == ERROR_SUCCESS) + { + if((pHash = GetHashEntryEx(ha, szArchivedName, lcLocale)) != NULL) + { + if(pHash->lcLocale == lcLocale) + { + if((dwFlags & MPQ_FILE_REPLACEEXISTING) == 0) + { + nError = ERROR_ALREADY_EXISTS; + pHash = NULL; + } + else + bReplaced = TRUE; + } + else + pHash = NULL; + } + + if(nError == ERROR_SUCCESS && pHash == NULL) + { + pHash = FindFreeHashEntry(ha, szArchivedName); + if(pHash == NULL) + nError = ERROR_HANDLE_DISK_FULL; + } + } + + // Get the block table entry for the file + if(nError == ERROR_SUCCESS) + { + DWORD dwFileSizeHigh = 0; + + // Get the size of the added file + dwFileSize = GetFileSize(hFile, &dwFileSizeHigh); + if(dwFileSizeHigh != 0) + nError = ERROR_PARAMETER_QUOTA_EXCEEDED; + + // Fix the flags, if the file is too small + if(dwFileSize < 0x04) + dwFlags &= ~(MPQ_FILE_ENCRYPTED | MPQ_FILE_FIXSEED); + if(dwFileSize < 0x20) + dwFlags &= ~MPQ_FILE_COMPRESSED; + + if(pHash->dwBlockIndex == HASH_ENTRY_FREE) + pHash->dwBlockIndex = ha->pHeader->dwBlockTableSize; + + // The block table index cannot be larger than hash table size + if(pHash->dwBlockIndex >= ha->pHeader->dwHashTableSize) + nError = ERROR_HANDLE_DISK_FULL; + } + + // The file will be stored after the end of the last archived file + // (i.e. at old position of archived file + if(nError == ERROR_SUCCESS) + { + TMPQBlock * pBlockEnd = ha->pBlockTable + ha->pHeader->dwBlockTableSize; + const char * szTemp = strrchr(szArchivedName, '\\'); + + // Get the position of the first file + RelativePos.QuadPart = ha->pHeader->dwHeaderSize; + + // Find the position of the last file. It has to be after the last archived file + // (Do not use the dwArchiveSize here, because it may or may not + // include the hash table at the end of the file + pBlockEx = ha->pExtBlockTable; + for(pBlock = ha->pBlockTable; pBlock < pBlockEnd; pBlock++, pBlockEx++) + { + if(pBlock->dwFlags & MPQ_FILE_EXISTS) + { + TempPos.HighPart = pBlockEx->wFilePosHigh; + TempPos.LowPart = pBlock->dwFilePos; + TempPos.QuadPart += pBlock->dwCSize; + + if(TempPos.QuadPart > RelativePos.QuadPart) + RelativePos = TempPos; + } + } + + // When format V1, we cannot exceed 4 GB + if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) + { + TempPos.QuadPart = ha->MpqPos.QuadPart + RelativePos.QuadPart; + TempPos.QuadPart += ha->pHeader->dwHashTableSize * sizeof(TMPQHash); + TempPos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); + TempPos.QuadPart += dwFileSize; + + if(TempPos.HighPart != 0) + nError = ERROR_DISK_FULL; + } + + // Get pointers to both block entries of the file + pBlockEx = ha->pExtBlockTable + pHash->dwBlockIndex; + pBlock = ha->pBlockTable + pHash->dwBlockIndex; + + // Save the file size info + pBlockEx->wFilePosHigh = (USHORT)RelativePos.HighPart; + pBlock->dwFilePos = RelativePos.LowPart; + pBlock->dwFSize = GetFileSize(hFile, NULL); + pBlock->dwFlags = dwFlags | MPQ_FILE_EXISTS; + + // Create seed1 for file encryption + if(szTemp != NULL) + szArchivedName = szTemp + 1; + + if(dwFlags & MPQ_FILE_ENCRYPTED) + { + dwSeed1 = DecryptFileSeed(szArchivedName); + + if(dwFlags & MPQ_FILE_FIXSEED) + dwSeed1 = (dwSeed1 + pBlock->dwFilePos) ^ pBlock->dwFSize; + } + } + + // Allocate buffer for the input data + if(nError == ERROR_SUCCESS) + { + nBlocks = (pBlock->dwFSize / ha->dwBlockSize) + 1; + if(pBlock->dwFSize % ha->dwBlockSize) + nBlocks++; + + pBlock->dwCSize = 0; + if((pbFileData = ALLOCMEM(BYTE, ha->dwBlockSize)) == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + pbToWrite = pbFileData; + } + + // Allocate buffers for the compressed data + if(nError == ERROR_SUCCESS && (dwFlags & MPQ_FILE_COMPRESSED)) + { + pdwBlockPos = ALLOCMEM(DWORD, nBlocks + 1); + pbCompressed = ALLOCMEM(BYTE, ha->dwBlockSize * 2); + if(pdwBlockPos == NULL || pbCompressed == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + pbToWrite = pbCompressed; + } + + // Set the file position to the point where the file will be stored + if(nError == ERROR_SUCCESS) + { + // Set the file pointer to file data position + FilePos.QuadPart = ha->MpqPos.QuadPart + RelativePos.QuadPart; + if(FilePos.QuadPart != ha->FilePointer.QuadPart) + { + SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN); + ha->FilePointer = FilePos; + } + } + + // Write block positions (if the file will be compressed) + if(nError == ERROR_SUCCESS && (dwFlags & MPQ_FILE_COMPRESSED)) + { + dwBlockPosLen = nBlocks * sizeof(DWORD); + if(dwFlags & MPQ_FILE_HAS_EXTRA) + dwBlockPosLen += sizeof(DWORD); + + memset(pdwBlockPos, 0, dwBlockPosLen); + pdwBlockPos[0] = dwBlockPosLen; + + // Write the block positions + BSWAP_ARRAY32_UNSIGNED((DWORD *)pdwBlockPos, nBlocks); + WriteFile(ha->hFile, pdwBlockPos, dwBlockPosLen, &dwTransferred, NULL); + BSWAP_ARRAY32_UNSIGNED((DWORD *)pdwBlockPos, nBlocks); + + if(dwTransferred == dwBlockPosLen) + pBlock->dwCSize += dwBlockPosLen; + else + nError = GetLastError(); + + // Update the current position in the file + ha->HashTablePos.QuadPart = FilePos.QuadPart + dwTransferred; + } + + // Write all file blocks + if(nError == ERROR_SUCCESS) + { + nCmp = nCmpFirst; + + SetFilePointer(hFile, 0, NULL, FILE_BEGIN); + for(nBlock = 0; nBlock < nBlocks-1; nBlock++) + { + DWORD dwInLength = ha->dwBlockSize; + DWORD dwOutLength = ha->dwBlockSize; + + // Load the block from the file + ReadFile(hFile, pbFileData, ha->dwBlockSize, &dwInLength, NULL); + if(dwInLength == 0) + break; + + // Compress the block, if necessary + dwOutLength = dwInLength; + if(pBlock->dwFlags & MPQ_FILE_COMPRESSED) + { + // Should be enough for compression + int nOutLength = ha->dwBlockSize * 2; + int nCmpType = 0; + + if(pBlock->dwFlags & MPQ_FILE_COMPRESS_PKWARE) + Compress_pklib((char *)pbCompressed, &nOutLength, (char *)pbFileData, dwInLength, &nCmpType, 0); + + if(pBlock->dwFlags & MPQ_FILE_COMPRESS_MULTI) + SCompCompress((char *)pbCompressed, &nOutLength, (char *)pbFileData, dwInLength, nCmp, 0, nCmpLevel); + + // The compressed block size must NOT be the same or greater like + // the original block size. If yes, do not compress the block + // and store the data as-is. + if(nOutLength >= (int)dwInLength) + { + memcpy(pbCompressed, pbFileData, dwInLength); + nOutLength = dwInLength; + } + + // Update block positions + dwOutLength = nOutLength; + pdwBlockPos[nBlock+1] = pdwBlockPos[nBlock] + dwOutLength; + nCmp = nCmpNext; + } + + // Encrypt the block, if necessary + if(pBlock->dwFlags & MPQ_FILE_ENCRYPTED) + { + BSWAP_ARRAY32_UNSIGNED((DWORD *)pbToWrite, dwOutLength / sizeof(DWORD)); + EncryptMPQBlock((DWORD *)pbToWrite, dwOutLength, dwSeed1 + nBlock); + BSWAP_ARRAY32_UNSIGNED((DWORD *)pbToWrite, dwOutLength / sizeof(DWORD)); + } + + // Write the block + WriteFile(ha->hFile, pbToWrite, dwOutLength, &dwTransferred, NULL); + if(dwTransferred != dwOutLength) + { + nError = ERROR_DISK_FULL; + break; + } + + // Update the hash table position and the compressed file size + ha->HashTablePos.QuadPart += dwTransferred; + pBlock->dwCSize += dwOutLength; + } + } + + // Now save the block positions + if(nError == ERROR_SUCCESS && (pBlock->dwFlags & MPQ_FILE_COMPRESSED)) + { + if(dwFlags & MPQ_FILE_HAS_EXTRA) + pdwBlockPos[nBlocks] = pdwBlockPos[nBlocks-1]; + + // If file is encrypted, block positions are also encrypted + if(dwFlags & MPQ_FILE_ENCRYPTED) + EncryptMPQBlock(pdwBlockPos, dwBlockPosLen, dwSeed1 - 1); + + // Set the position back to the block table + SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN); + + // Write block positions to the archive + BSWAP_ARRAY32_UNSIGNED((DWORD *)pdwBlockPos, nBlocks); + WriteFile(ha->hFile, pdwBlockPos, dwBlockPosLen, &dwTransferred, NULL); + if(dwTransferred != dwBlockPosLen) + nError = ERROR_DISK_FULL; + + ha->FilePointer.QuadPart = ha->FilePointer.QuadPart + dwTransferred; + } + + // If success, we have to change the settings + // in MPQ header. If failed, we have to clean hash entry + if(nError == ERROR_SUCCESS) + { + ha->pLastFile = NULL; + ha->dwBlockPos = 0; + ha->dwBuffPos = 0; + ha->dwFlags |= MPQ_FLAG_CHANGED; + + // Add new entry to the block table (if needed) + if(pHash->dwBlockIndex >= ha->pHeader->dwBlockTableSize) + ha->pHeader->dwBlockTableSize++; + + // Hash table size in the TMPQArchive is already set at this point + RelativePos.QuadPart = ha->HashTablePos.QuadPart - ha->MpqPos.QuadPart; + ha->pHeader->dwHashTablePos = RelativePos.LowPart; + ha->pHeader->wHashTablePosHigh = (USHORT)RelativePos.HighPart; + + // Update block table pos + RelativePos.QuadPart += (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)); + ha->pHeader->wBlockTablePosHigh = (USHORT)RelativePos.HighPart; + ha->pHeader->dwBlockTablePos = RelativePos.LowPart; + ha->BlockTablePos.QuadPart = RelativePos.QuadPart + ha->MpqPos.QuadPart; + + // If the archive size exceeded 4GB, we have to use extended block table pos + RelativePos.QuadPart += (ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock)); + if(RelativePos.HighPart != 0) + { + ha->pHeader->ExtBlockTablePos = RelativePos; + ha->ExtBlockTablePos.QuadPart = RelativePos.QuadPart + ha->MpqPos.QuadPart; + + RelativePos.QuadPart += (ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx)); + } + + // Update archive size (only valid for version V1) + ha->MpqSize = RelativePos; + ha->pHeader->dwArchiveSize = ha->MpqSize.LowPart; + } + else + { + // Clear the hash table entry + if(pHash != NULL) + memset(pHash, 0xFF, sizeof(TMPQHash)); + } + + // Cleanup + if(pbCompressed != NULL) + FREEMEM(pbCompressed); + if(pdwBlockPos != NULL) + FREEMEM(pdwBlockPos); + if(pbFileData != NULL) + FREEMEM(pbFileData); + if(pbReplaced != NULL) + *pbReplaced = bReplaced; + return nError; +} + +int SetDataCompression(int nDataCompression) +{ + nDataCmp = nDataCompression; + return 0; +} + +// This method saves MPQ header, hash table and block table. +// TODO: Test for archives > 4GB +int SaveMPQTables(TMPQArchive * ha) +{ + BYTE * pbBuffer = NULL; + DWORD dwBytes; + DWORD dwWritten; + DWORD dwBuffSize = max(ha->pHeader->dwHashTableSize, ha->pHeader->dwBlockTableSize); + int nError = ERROR_SUCCESS; + + // Allocate buffer for encrypted tables + if(nError == ERROR_SUCCESS) + { + // Allocate temporary buffer for tables encryption + pbBuffer = ALLOCMEM(BYTE, sizeof(TMPQHash) * dwBuffSize); + if(pbBuffer == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Write the MPQ Header + if(nError == ERROR_SUCCESS) + { + DWORD dwHeaderSize = ha->pHeader->dwHeaderSize; + + // Write the MPQ header + SetFilePointer(ha->hFile, ha->MpqPos.LowPart, &ha->MpqPos.HighPart, FILE_BEGIN); + + // Convert to little endian for file save + BSWAP_TMPQHEADER(ha->pHeader); + WriteFile(ha->hFile, ha->pHeader, dwHeaderSize, &dwWritten, NULL); + BSWAP_TMPQHEADER(ha->pHeader); + + if(dwWritten != ha->pHeader->dwHeaderSize) + nError = ERROR_DISK_FULL; + } + + // Write the hash table + if(nError == ERROR_SUCCESS) + { + // Copy the hash table to temporary buffer + dwBytes = ha->pHeader->dwHashTableSize * sizeof(TMPQHash); + memcpy(pbBuffer, ha->pHashTable, dwBytes); + + // Convert to little endian for file save + EncryptHashTable((DWORD *)pbBuffer, (BYTE *)"(hash table)", dwBytes >> 2); + BSWAP_ARRAY32_UNSIGNED((DWORD *)pbBuffer, dwBytes / sizeof(DWORD)); + + // Set the file pointer to the offset of the hash table and write it + SetFilePointer(ha->hFile, ha->HashTablePos.LowPart, (PLONG)&ha->HashTablePos.HighPart, FILE_BEGIN); + WriteFile(ha->hFile, pbBuffer, dwBytes, &dwWritten, NULL); + if(dwWritten != dwBytes) + nError = ERROR_DISK_FULL; + } + + // Write the block table + if(nError == ERROR_SUCCESS) + { + // Copy the block table to temporary buffer + dwBytes = ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); + memcpy(pbBuffer, ha->pBlockTable, dwBytes); + + // Encrypt the block table and write it to the file + EncryptBlockTable((DWORD *)pbBuffer, (BYTE *)"(block table)", dwBytes >> 2); + + // Convert to little endian for file save + BSWAP_ARRAY32_UNSIGNED((DWORD *)pbBuffer, dwBytes / sizeof(DWORD)); + WriteFile(ha->hFile, pbBuffer, dwBytes, &dwWritten, NULL); + if(dwWritten != dwBytes) + nError = ERROR_DISK_FULL; + } + + // Write the extended block table + if(nError == ERROR_SUCCESS && ha->pHeader->ExtBlockTablePos.QuadPart != 0) + { + // We expect format V2 or newer in this case + assert(ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_2); + + // Copy the block table to temporary buffer + dwBytes = ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx); + memcpy(pbBuffer, ha->pExtBlockTable, dwBytes); + + // Convert to little endian for file save + BSWAP_ARRAY16_UNSIGNED((USHORT *)pbBuffer, dwBytes / sizeof(USHORT)); + WriteFile(ha->hFile, pbBuffer, dwBytes, &dwWritten, NULL); + if(dwWritten != dwBytes) + nError = ERROR_DISK_FULL; + } + + + // Set end of file here + if(nError == ERROR_SUCCESS) + { + SetEndOfFile(ha->hFile); + } + + // Cleanup and exit + if(pbBuffer != NULL) + FREEMEM(pbBuffer); + return nError; +} + +// Frees the MPQ archive +// TODO: Test for archives > 4GB +void FreeMPQArchive(TMPQArchive *& ha) +{ + if(ha != NULL) + { + FREEMEM(ha->pbBlockBuffer); + FREEMEM(ha->pBlockTable); + FREEMEM(ha->pExtBlockTable); + FREEMEM(ha->pHashTable); + if(ha->pListFile != NULL) + SListFileFreeListFile(ha); + + if(ha->hFile != INVALID_HANDLE_VALUE) + CloseHandle(ha->hFile); + FREEMEM(ha); + ha = NULL; + } +} diff --git a/src/tools/stuffextract/StormLib/SCommon.h b/src/tools/stuffextract/StormLib/SCommon.h index 904c2de..b53be0a 100644 --- a/src/tools/stuffextract/StormLib/SCommon.h +++ b/src/tools/stuffextract/StormLib/SCommon.h @@ -1,88 +1,88 @@ -/*****************************************************************************/ -/* SCommon.h Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Common functions for encryption/decryption from Storm.dll. Included by */ -/* SFile*** functions, do not include and do not use this file directly */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 24.03.03 1.00 Lad The first version of SFileCommon.h */ -/* 12.06.04 1.00 Lad Renamed to SCommon.h */ -/*****************************************************************************/ - -#ifndef __SCOMMON_H__ -#define __SCOMMON_H__ - -//----------------------------------------------------------------------------- -// StormLib private defines - -#define SFILE_TYPE_DATA 0 // Process the file as data file -#define SFILE_TYPE_WAVE 1 // Process the file as WAVe file - -//----------------------------------------------------------------------------- -// External variables - -extern TMPQArchive * pFirstOpen; -extern LCID lcLocale; - -//----------------------------------------------------------------------------- -// Encryption and decryption functions - -int PrepareStormBuffer(); - -void EncryptHashTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength); -void DecryptHashTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength); -TMPQHash * FindFreeHashEntry(TMPQArchive * ha, const char * szFileName); - -void EncryptBlockTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength); -void DecryptBlockTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength); - -DWORD DetectFileSeed(DWORD * block, DWORD decrypted); -DWORD DetectFileSeed2(DWORD * block, UINT nDwords, ...); -void EncryptMPQBlock(DWORD * pdwBlock, DWORD dwLength, DWORD dwSeed1); -void DecryptMPQBlock(DWORD * pdwBlock, DWORD dwLength, DWORD dwSeed1); - -DWORD DecryptHashIndex(TMPQArchive * ha, const char * szFileName); -DWORD DecryptName1 (const char * szFileName); -DWORD DecryptName2 (const char * szFileName); -DWORD DecryptFileSeed (const char * szFileName); - -TMPQHash * GetHashEntry (TMPQArchive * ha, const char * szFileName); -TMPQHash * GetHashEntryEx(TMPQArchive * ha, const char * szFileName, LCID lcLocale); - -//----------------------------------------------------------------------------- -// Compression and decompression functions - -int Compress_pklib (char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int nCmpLevel); -int Decompress_pklib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength); - -//----------------------------------------------------------------------------- -// Checking functions - -BOOL IsValidMpqHandle(TMPQArchive * ha); -BOOL IsValidFileHandle(TMPQFile * hf); - -//----------------------------------------------------------------------------- -// Other functions - -BOOL SFileOpenArchiveEx(const char * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMPQ, DWORD dwAccessMode = GENERIC_READ); -int AddFileToArchive(TMPQArchive * ha, HANDLE hFile, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality, int nFileType, BOOL * pbReplaced); -int SetDataCompression(int nDataCompression); -int SaveMPQTables(TMPQArchive * ha); -void FreeMPQArchive(TMPQArchive *& ha); - -BOOL CheckWildCard(const char * szString, const char * szWildCard); - -//----------------------------------------------------------------------------- -// Listfile functions - -int SListFileCreateListFile(TMPQArchive * ha); -int SListFileAddNode(TMPQArchive * ha, const char * szAddedFile); -int SListFileRemoveNode(TMPQArchive * ha, const char * szFileName); -int SListFileRenameNode(TMPQArchive * ha, const char * szOldFileName, const char * szNewFileName); -int SListFileFreeListFile(TMPQArchive * ha); - -int SListFileSaveToMpq(TMPQArchive * ha); - -#endif // __SCOMMON_H__ - +/*****************************************************************************/ +/* SCommon.h Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* Common functions for encryption/decryption from Storm.dll. Included by */ +/* SFile*** functions, do not include and do not use this file directly */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 24.03.03 1.00 Lad The first version of SFileCommon.h */ +/* 12.06.04 1.00 Lad Renamed to SCommon.h */ +/*****************************************************************************/ + +#ifndef __SCOMMON_H__ +#define __SCOMMON_H__ + +//----------------------------------------------------------------------------- +// StormLib private defines + +#define SFILE_TYPE_DATA 0 // Process the file as data file +#define SFILE_TYPE_WAVE 1 // Process the file as WAVe file + +//----------------------------------------------------------------------------- +// External variables + +extern TMPQArchive * pFirstOpen; +extern LCID lcLocale; + +//----------------------------------------------------------------------------- +// Encryption and decryption functions + +int PrepareStormBuffer(); + +void EncryptHashTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength); +void DecryptHashTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength); +TMPQHash * FindFreeHashEntry(TMPQArchive * ha, const char * szFileName); + +void EncryptBlockTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength); +void DecryptBlockTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength); + +DWORD DetectFileSeed(DWORD * block, DWORD decrypted); +DWORD DetectFileSeed2(DWORD * block, UINT nDwords, ...); +void EncryptMPQBlock(DWORD * pdwBlock, DWORD dwLength, DWORD dwSeed1); +void DecryptMPQBlock(DWORD * pdwBlock, DWORD dwLength, DWORD dwSeed1); + +DWORD DecryptHashIndex(TMPQArchive * ha, const char * szFileName); +DWORD DecryptName1 (const char * szFileName); +DWORD DecryptName2 (const char * szFileName); +DWORD DecryptFileSeed (const char * szFileName); + +TMPQHash * GetHashEntry (TMPQArchive * ha, const char * szFileName); +TMPQHash * GetHashEntryEx(TMPQArchive * ha, const char * szFileName, LCID lcLocale); + +//----------------------------------------------------------------------------- +// Compression and decompression functions + +int Compress_pklib (char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int nCmpLevel); +int Decompress_pklib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength); + +//----------------------------------------------------------------------------- +// Checking functions + +BOOL IsValidMpqHandle(TMPQArchive * ha); +BOOL IsValidFileHandle(TMPQFile * hf); + +//----------------------------------------------------------------------------- +// Other functions + +BOOL SFileOpenArchiveEx(const char * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMPQ, DWORD dwAccessMode = GENERIC_READ); +int AddFileToArchive(TMPQArchive * ha, HANDLE hFile, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality, int nFileType, BOOL * pbReplaced); +int SetDataCompression(int nDataCompression); +int SaveMPQTables(TMPQArchive * ha); +void FreeMPQArchive(TMPQArchive *& ha); + +BOOL CheckWildCard(const char * szString, const char * szWildCard); + +//----------------------------------------------------------------------------- +// Listfile functions + +int SListFileCreateListFile(TMPQArchive * ha); +int SListFileAddNode(TMPQArchive * ha, const char * szAddedFile); +int SListFileRemoveNode(TMPQArchive * ha, const char * szFileName); +int SListFileRenameNode(TMPQArchive * ha, const char * szOldFileName, const char * szNewFileName); +int SListFileFreeListFile(TMPQArchive * ha); + +int SListFileSaveToMpq(TMPQArchive * ha); + +#endif // __SCOMMON_H__ + diff --git a/src/tools/stuffextract/StormLib/SCompression.cpp b/src/tools/stuffextract/StormLib/SCompression.cpp index 7d2c50d..612ef2c 100644 --- a/src/tools/stuffextract/StormLib/SCompression.cpp +++ b/src/tools/stuffextract/StormLib/SCompression.cpp @@ -1,715 +1,715 @@ -/*****************************************************************************/ -/* SCompression.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* This module serves as a bridge between StormLib code and (de)compression */ -/* functions. All (de)compression calls go (and should only go) through this */ -/* module. No system headers should be included in this module to prevent */ -/* compile-time problems. */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 01.04.03 1.00 Lad The first version of SCompression.cpp */ -/* 19.11.03 1.01 Dan Big endian handling */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -#include - -// Include functions from Pkware Data Compression Library -#include "pklib/pklib.h" - -// Include functions from zlib -#ifndef __SYS_ZLIB -#include "zlib/zlib.h" // Include functions from zlib -#else -#include // If zlib is available on system, use this instead -#endif - -// Include functions from Huffmann compression -#include "huffman/huff.h" - -// Include functions from WAVe compression -#include "wave/wave.h" - -// Include functions from BZip2 compression library -#ifndef __SYS_BZLIB -#include "bzip2/bzlib.h" // Include functions from bzlib -#else -#include // If bzlib is available on system, use this instead -#endif - -//----------------------------------------------------------------------------- -// Local structures - -// Information about the input and output buffers for pklib -typedef struct -{ - char * pInBuff; // Pointer to input data buffer - int nInPos; // Current offset in input data buffer - int nInBytes; // Number of bytes in the input buffer - char * pOutBuff; // Pointer to output data buffer - int nOutPos; // Position in the output buffer - int nMaxOut; // Maximum number of bytes in the output buffer -} TDataInfo; - -// Table of compression functions -typedef int (*COMPRESS)(char *, int *, char *, int, int *, int); -typedef struct -{ - unsigned long dwMask; // Compression mask - COMPRESS Compress; // Compression function -} TCompressTable; - -// Table of decompression functions -typedef int (*DECOMPRESS)(char *, int *, char *, int); -typedef struct -{ - unsigned long dwMask; // Decompression bit - DECOMPRESS Decompress; // Decompression function -} TDecompressTable; - - -/*****************************************************************************/ -/* */ -/* Support functions for Pkware Data Compression Library */ -/* */ -/*****************************************************************************/ - -// Function loads data from the input buffer. Used by Pklib's "implode" -// and "explode" function as user-defined callback -// Returns number of bytes loaded -// -// char * buf - Pointer to a buffer where to store loaded data -// unsigned int * size - Max. number of bytes to read -// void * param - Custom pointer, parameter of implode/explode - -static unsigned int ReadInputData(char * buf, unsigned int * size, void * param) -{ - TDataInfo * pInfo = (TDataInfo *)param; - unsigned int nMaxAvail = (pInfo->nInBytes - pInfo->nInPos); - unsigned int nToRead = *size; - - // Check the case when not enough data available - if(nToRead > nMaxAvail) - nToRead = nMaxAvail; - - // Load data and increment offsets - memcpy(buf, pInfo->pInBuff + pInfo->nInPos, nToRead); - pInfo->nInPos += nToRead; - - return nToRead; -} - -// Function for store output data. Used by Pklib's "implode" and "explode" -// as user-defined callback -// -// char * buf - Pointer to data to be written -// unsigned int * size - Number of bytes to write -// void * param - Custom pointer, parameter of implode/explode - -static void WriteOutputData(char * buf, unsigned int * size, void * param) -{ - TDataInfo * pInfo = (TDataInfo *)param; - unsigned int nMaxWrite = (pInfo->nMaxOut - pInfo->nOutPos); - unsigned int nToWrite = *size; - - // Check the case when not enough space in the output buffer - if(nToWrite > nMaxWrite) - nToWrite = nMaxWrite; - - // Write output data and increments offsets - memcpy(pInfo->pOutBuff + pInfo->nOutPos, buf, nToWrite); - pInfo->nOutPos += nToWrite; -} - -/*****************************************************************************/ -/* */ -/* "80" is IMA ADPCM stereo (de)compression */ -/* "40" is IMA ADPCM mono (de)compression */ -/* */ -/*****************************************************************************/ - -int Compress_wave_mono(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int nCmpLevel) -{ - // Prepare the compression level for the next compression - // (After us, the Huffmann compression will be called) - if(0 < nCmpLevel && nCmpLevel <= 2) - { - nCmpLevel = 4; - *pCmpType = 6; - } - else if(nCmpLevel == 3) - { - nCmpLevel = 6; - *pCmpType = 8; - } - else - { - nCmpLevel = 5; - *pCmpType = 7; - } - *pdwOutLength = CompressWave((unsigned char *)pbOutBuffer, *pdwOutLength, (short *)pbInBuffer, dwInLength, 1, nCmpLevel); - return 0; -} - -int Decompress_wave_mono(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) -{ - *pdwOutLength = DecompressWave((unsigned char *)pbOutBuffer, *pdwOutLength, (unsigned char *)pbInBuffer, dwInLength, 1); - return 1; -} - -int Compress_wave_stereo(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int nCmpLevel) -{ - // Prepare the compression type for the next compression - // (After us, the Huffmann compression will be called) - if(0 < nCmpLevel && nCmpLevel <= 2) - { - nCmpLevel = 4; - *pCmpType = 6; - } - else if(nCmpLevel == 3) - { - nCmpLevel = 6; - *pCmpType = 8; - } - else - { - nCmpLevel = 5; - *pCmpType = 7; - } - *pdwOutLength = CompressWave((unsigned char *)pbOutBuffer, *pdwOutLength, (short *)pbInBuffer, dwInLength, 2, nCmpLevel); - return 0; -} - -int Decompress_wave_stereo(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) -{ - *pdwOutLength = DecompressWave((unsigned char *)pbOutBuffer, *pdwOutLength, (unsigned char *)pbInBuffer, dwInLength, 2); - return 1; -} - -/*****************************************************************************/ -/* */ -/* The "01" (de)compression is the Huffman (de)compression */ -/* */ -/*****************************************************************************/ - -// 1500F4C0 -int Compress_huff(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int /* nCmpLevel */) -{ - THuffmannTree ht; // Huffmann tree for compression - TOutputStream os; // Output stream - - // Initialize output stream - os.pbOutBuffer = (unsigned char *)pbOutBuffer; - os.dwOutSize = *pdwOutLength; - os.pbOutPos = (unsigned char *)pbOutBuffer; - os.dwBitBuff = 0; - os.nBits = 0; - - // Initialize the Huffmann tree for compression - ht.InitTree(true); - - *pdwOutLength = ht.DoCompression(&os, (unsigned char *)pbInBuffer, dwInLength, *pCmpType); - - // The following code is not necessary to run, because it has no - // effect on the output data. It only clears the huffmann tree, but when - // the tree is on the stack, who cares ? -// ht.UninitTree(); - return 0; -} - -// 1500F5F0 -int Decompress_huff(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int /* dwInLength */) -{ - THuffmannTree ht; - TInputStream is; - - // Initialize input stream -// is.pbInBuffer = (unsigned char *)pbInBuffer; - is.dwBitBuff = BSWAP_INT32_UNSIGNED(*(unsigned long *)pbInBuffer); - pbInBuffer += sizeof(unsigned long); - is.pbInBuffer = (unsigned char *)pbInBuffer; - is.nBits = 32; - - // Initialize the Huffmann tree for compression - ht.InitTree(false); - *pdwOutLength = ht.DoDecompression((unsigned char *)pbOutBuffer, *pdwOutLength, &is); - - // The following code is not necessary to run, because it has no - // effect on the output data. It only clears the huffmann tree, but when - // the tree is on the stack, who cares ? -// ht.UninitTree(); - return 0; -} - -/*****************************************************************************/ -/* */ -/* The "02" (de)compression is the ZLIB (de)compression */ -/* */ -/*****************************************************************************/ - -int Compress_zlib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * /* pCmpType */, int /* nCmpLevel */) -{ - z_stream z; // Stream information for zlib - int nResult; - - // Fill the stream structure for zlib - z.next_in = (Bytef *)pbInBuffer; - z.avail_in = (uInt)dwInLength; - z.total_in = dwInLength; - z.next_out = (Bytef *)pbOutBuffer; - z.avail_out = *pdwOutLength; - z.total_out = 0; - z.zalloc = NULL; - z.zfree = NULL; - - // Initialize the compression structure. Storm.dll uses zlib version 1.1.3 - *pdwOutLength = 0; - if((nResult = deflateInit(&z, Z_DEFAULT_COMPRESSION)) == 0) - { - // Call zlib to compress the data - nResult = deflate(&z, Z_FINISH); - - if(nResult == Z_OK || nResult == Z_STREAM_END) - *pdwOutLength = z.total_out; - - deflateEnd(&z); - } - return nResult; -} - -int Decompress_zlib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) -{ - z_stream z; // Stream information for zlib - int nResult; - - // Fill the stream structure for zlib - z.next_in = (Bytef *)pbInBuffer; - z.avail_in = (uInt)dwInLength; - z.total_in = dwInLength; - z.next_out = (Bytef *)pbOutBuffer; - z.avail_out = *pdwOutLength; - z.total_out = 0; - z.zalloc = NULL; - z.zfree = NULL; - - // Initialize the decompression structure. Storm.dll uses zlib version 1.1.3 - if((nResult = inflateInit(&z)) == 0) - { - // Call zlib to decompress the data - nResult = inflate(&z, Z_FINISH); - *pdwOutLength = z.total_out; - inflateEnd(&z); - } - return nResult; -} - -/*****************************************************************************/ -/* */ -/* The "08" (de)compression is the Pkware DCL (de)compression */ -/* */ -/*****************************************************************************/ - -int Compress_pklib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int /* nCmpLevel */) -{ - TDataInfo Info; // Data information - char * work_buf = ALLOCMEM(char, CMP_BUFFER_SIZE);// Pklib's work buffer - unsigned int dict_size; // Dictionary size - unsigned int ctype; // Compression type - - // Fill data information structure - Info.pInBuff = pbInBuffer; - Info.nInPos = 0; - Info.nInBytes = dwInLength; - Info.pOutBuff = pbOutBuffer; - Info.nOutPos = 0; - Info.nMaxOut = *pdwOutLength; - - // Set the compression type and dictionary size - ctype = (*pCmpType == 2) ? CMP_ASCII : CMP_BINARY; - if (dwInLength < 0x600) - dict_size = 0x400; - else if(0x600 <= dwInLength && dwInLength < 0xC00) - dict_size = 0x800; - else - dict_size = 0x1000; - - // Do the compression - implode(ReadInputData, WriteOutputData, work_buf, &Info, &ctype, &dict_size); - *pdwOutLength = Info.nOutPos; - FREEMEM(work_buf); - return 0; -} - -int Decompress_pklib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) -{ - TDataInfo Info; // Data information - char * work_buf = ALLOCMEM(char, EXP_BUFFER_SIZE);// Pklib's work buffer - - // Fill data information structure - Info.pInBuff = pbInBuffer; - Info.nInPos = 0; - Info.nInBytes = dwInLength; - Info.pOutBuff = pbOutBuffer; - Info.nOutPos = 0; - Info.nMaxOut = *pdwOutLength; - - // Do the decompression - explode(ReadInputData, WriteOutputData, work_buf, &Info); - - // Fix: If PKLIB is unable to decompress the data, they are uncompressed - if(Info.nOutPos == 0) - { - Info.nOutPos = min(*pdwOutLength, dwInLength); - memcpy(pbOutBuffer, pbInBuffer, Info.nOutPos); - } - - *pdwOutLength = Info.nOutPos; - FREEMEM(work_buf); - return 0; -} - -/*****************************************************************************/ -/* */ -/* The "10" (de)compression is the Bzip2 (de)compression */ -/* */ -/*****************************************************************************/ - -int Compress_bzip2(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int nCmpLevel) -{ - bz_stream strm; - int blockSize100k; - int workFactor = 30; - - // Keep compiler happy - nCmpLevel = nCmpLevel; - - // Initialize the BZLIB compression - strm.bzalloc = NULL; - strm.bzfree = NULL; - - // Adjust the block size - blockSize100k = *pCmpType; - if(blockSize100k < 1 || blockSize100k > 9) - blockSize100k = 9; - - // Blizzard uses 9 as blockSize100k, (0 as workFactor) - if(BZ2_bzCompressInit(&strm, blockSize100k, 0, workFactor) == 0) - { - strm.next_in = pbInBuffer; - strm.avail_in = dwInLength; - strm.next_out = pbOutBuffer; - strm.avail_out = *pdwOutLength; - - // Perform the compression - while(BZ2_bzCompress(&strm, (strm.avail_in != 0) ? BZ_RUN : BZ_FINISH) != BZ_STREAM_END); - - // Put the stream into idle state - BZ2_bzCompressEnd(&strm); - *pdwOutLength = strm.total_out_lo32; - } - else - { - *pdwOutLength = 0; - } - - return 0; -} - -int Decompress_bzip2(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) -{ - bz_stream strm; - - // Initialize the BZLIB decompression - strm.bzalloc = NULL; - strm.bzfree = NULL; - if(BZ2_bzDecompressInit(&strm, 0, 0) == 0) - { - strm.next_in = pbInBuffer; - strm.avail_in = dwInLength; - strm.next_out = pbOutBuffer; - strm.avail_out = *pdwOutLength; - - // Perform the decompression - while(BZ2_bzDecompress(&strm) != BZ_STREAM_END); - - // Put the stream into idle state - BZ2_bzDecompressEnd(&strm); - *pdwOutLength = strm.total_out_lo32; - } - else - { - // Set zero output length - *pdwOutLength = 0; - } - - return 0; -} - -/*****************************************************************************/ -/* */ -/* SCompCompress */ -/* */ -/*****************************************************************************/ - -// This table contains compress functions which can be applied to -// uncompressed blocks. Each bit set means the corresponding -// compression method/function must be applied. -// -// WAVes compression Data compression -// ------------------ ------------------- -// 1st block - 0x08 0x08 (D, HF, W2, SC, D2) -// Rest blocks - 0x81 0x02 (W3) - -static TCompressTable cmp_table[] = -{ - {MPQ_COMPRESSION_WAVE_MONO, Compress_wave_mono}, // IMA ADPCM mono compression - {MPQ_COMPRESSION_WAVE_STEREO, Compress_wave_stereo}, // IMA ADPCM stereo compression - {MPQ_COMPRESSION_HUFFMANN, Compress_huff}, // Huffmann compression - {MPQ_COMPRESSION_ZLIB, Compress_zlib}, // Compression with the "zlib" library - {MPQ_COMPRESSION_PKWARE, Compress_pklib}, // Compression with Pkware DCL - {MPQ_COMPRESSION_BZIP2, Compress_bzip2} // Compression Bzip2 library -}; - -int WINAPI SCompCompress(char * pbCompressed, int * pdwOutLength, char * pbUncompressed, int dwInLength, - int uCompressions, int nCmpType, int nCmpLevel) -{ - char * pbTempBuff = NULL; // Temporary storage for decompressed data - char * pbOutput = pbCompressed; // Current output buffer - char * pbInput; // Current input buffer - int uCompressions2; - int dwCompressCount = 0; - int dwDoneCount = 0; - int dwOutSize = 0; - int dwInSize = dwInLength; - int dwEntries = (sizeof(cmp_table) / sizeof(TCompressTable)); - int nResult = 1; - int i; - - // Check for valid parameters - if(!pdwOutLength || *pdwOutLength < dwInLength || !pbCompressed || !pbUncompressed) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - // Count the compressions - for(i = 0, uCompressions2 = uCompressions; i < dwEntries; i++) - { - if(uCompressions & cmp_table[i].dwMask) - dwCompressCount++; - - uCompressions2 &= ~cmp_table[i].dwMask; - } - - // If a compression remains, do nothing - if(uCompressions2 != 0) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - // If more that one compression, allocate intermediate buffer - if(dwCompressCount >= 2) - pbTempBuff = ALLOCMEM(char, *pdwOutLength + 1); - - // Perform the compressions - pbInput = pbUncompressed; - dwInSize = dwInLength; - for(i = 0, uCompressions2 = uCompressions; i < dwEntries; i++) - { - if(uCompressions2 & cmp_table[i].dwMask) - { - // Set the right output buffer - dwCompressCount--; - pbOutput = (dwCompressCount & 1) ? pbTempBuff : pbCompressed; - - // Perform the partial compression - dwOutSize = *pdwOutLength - 1; - - cmp_table[i].Compress(pbOutput + 1, &dwOutSize, pbInput, dwInSize, &nCmpType, nCmpLevel); - if(dwOutSize == 0) - { - SetLastError(ERROR_GEN_FAILURE); - *pdwOutLength = 0; - nResult = 0; - break; - } - - // If the compression failed, copy the block instead - if(dwOutSize >= dwInSize - 1) - { - if(dwDoneCount > 0) - pbOutput++; - - memcpy(pbOutput, pbInput, dwInSize); - pbInput = pbOutput; - uCompressions &= ~cmp_table[i].dwMask; - dwOutSize = dwInSize; - } - else - { - pbInput = pbOutput + 1; - dwInSize = dwOutSize; - dwDoneCount++; - } - } - } - - // Copy the compressed data to the correct output buffer - if(nResult != 0) - { - if(uCompressions && (dwInSize + 1) < *pdwOutLength) - { - if(pbOutput != pbCompressed && pbOutput != pbCompressed + 1) - memcpy(pbCompressed, pbOutput, dwInSize); - *pbCompressed = (char)uCompressions; - *pdwOutLength = dwInSize + 1; - } - else - { - memmove(pbCompressed, pbUncompressed, dwInSize); - *pdwOutLength = dwInSize; - } - } - - // Cleanup and return - if(pbTempBuff != NULL) - FREEMEM(pbTempBuff); - return nResult; -} - -/*****************************************************************************/ -/* */ -/* SCompDecompress */ -/* */ -/*****************************************************************************/ - -// This table contains decompress functions which can be applied to -// uncompressed blocks. The compression mask is stored in the first byte -// of compressed block -static TDecompressTable dcmp_table[] = -{ - {MPQ_COMPRESSION_BZIP2, Decompress_bzip2}, // Decompression with Bzip2 library - {MPQ_COMPRESSION_PKWARE, Decompress_pklib}, // Decompression with Pkware Data Compression Library - {MPQ_COMPRESSION_ZLIB, Decompress_zlib}, // Decompression with the "zlib" library - {MPQ_COMPRESSION_HUFFMANN, Decompress_huff}, // Huffmann decompression - {MPQ_COMPRESSION_WAVE_STEREO, Decompress_wave_stereo}, // IMA ADPCM stereo decompression - {MPQ_COMPRESSION_WAVE_MONO, Decompress_wave_mono} // IMA ADPCM mono decompression -}; - -int WINAPI SCompDecompress(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) -{ - char * pbTempBuff = NULL; // Temporary storage for decompressed data - char * pbWorkBuff = NULL; // Where to store decompressed data - int dwOutLength = *pdwOutLength; // For storage number of output bytes - unsigned fDecompressions1; // Decompressions applied to the block - unsigned fDecompressions2; // Just another copy of decompressions applied to the block - int dwCount = 0; // Counter for every use - int dwEntries = (sizeof(dcmp_table) / sizeof(TDecompressTable)); - int nResult = 1; - int i; - - // If the input length is the same as output, do nothing. - if(dwInLength == dwOutLength) - { - if(pbInBuffer == pbOutBuffer) - return 1; - - memcpy(pbOutBuffer, pbInBuffer, dwInLength); - *pdwOutLength = dwInLength; - return 1; - } - - // Get applied compression types and decrement data length - fDecompressions1 = fDecompressions2 = (unsigned char)*pbInBuffer++; - dwInLength--; - - // Search decompression table type and get all types of compression - for(i = 0; i < dwEntries; i++) - { - // We have to apply this decompression ? - if(fDecompressions1 & dcmp_table[i].dwMask) - dwCount++; - - // Clear this flag from temporary variable. - fDecompressions2 &= ~dcmp_table[i].dwMask; - } - - // Check if there is some method unhandled - // (E.g. compressed by future versions) - if(fDecompressions2 != 0) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - // If there is more than only one compression, we have to allocate extra buffer - if(dwCount >= 2) - pbTempBuff = ALLOCMEM(char, dwOutLength); - - // Apply all decompressions - for(i = 0, dwCount = 0; i < dwEntries; i++) - { - // If not used this kind of compression, skip the loop - if(fDecompressions1 & dcmp_table[i].dwMask) - { - // If odd case, use target buffer for output, otherwise use allocated tempbuffer - pbWorkBuff = (dwCount++ & 1) ? pbTempBuff : pbOutBuffer; - dwOutLength = *pdwOutLength; - - // Decompress buffer using corresponding function - dcmp_table[i].Decompress(pbWorkBuff, &dwOutLength, pbInBuffer, dwInLength); - if(dwOutLength == 0) - { - SetLastError(ERROR_GEN_FAILURE); - nResult = 0; - break; - } - - // Move output length to src length for next compression - dwInLength = dwOutLength; - pbInBuffer = pbWorkBuff; - } - } - - // If output buffer is not the same like target buffer, we have to copy data - if(nResult != 0) - { - if(pbWorkBuff != pbOutBuffer) - memcpy(pbOutBuffer, pbInBuffer, dwOutLength); - - } - - // Delete temporary buffer, if necessary - if(pbTempBuff != NULL) - FREEMEM(pbTempBuff); - - *pdwOutLength = dwOutLength; - return nResult; -} - -/*****************************************************************************/ -/* */ -/* SCompSetDataCompression */ -/* */ -/*****************************************************************************/ - -int WINAPI SCompSetDataCompression(int nDataCompression) -{ - int nValidMask = (MPQ_COMPRESSION_ZLIB | MPQ_COMPRESSION_PKWARE | MPQ_COMPRESSION_BZIP2); - - if((nDataCompression & nValidMask) != nDataCompression) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - SetDataCompression(nDataCompression); - return TRUE; -} - - +/*****************************************************************************/ +/* SCompression.cpp Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* This module serves as a bridge between StormLib code and (de)compression */ +/* functions. All (de)compression calls go (and should only go) through this */ +/* module. No system headers should be included in this module to prevent */ +/* compile-time problems. */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 01.04.03 1.00 Lad The first version of SCompression.cpp */ +/* 19.11.03 1.01 Dan Big endian handling */ +/*****************************************************************************/ + +#define __STORMLIB_SELF__ +#include "StormLib.h" +#include "SCommon.h" + +#include + +// Include functions from Pkware Data Compression Library +#include "pklib/pklib.h" + +// Include functions from zlib +#ifndef __SYS_ZLIB +#include "zlib/zlib.h" // Include functions from zlib +#else +#include // If zlib is available on system, use this instead +#endif + +// Include functions from Huffmann compression +#include "huffman/huff.h" + +// Include functions from WAVe compression +#include "wave/wave.h" + +// Include functions from BZip2 compression library +#ifndef __SYS_BZLIB +#include "bzip2/bzlib.h" // Include functions from bzlib +#else +#include // If bzlib is available on system, use this instead +#endif + +//----------------------------------------------------------------------------- +// Local structures + +// Information about the input and output buffers for pklib +typedef struct +{ + char * pInBuff; // Pointer to input data buffer + int nInPos; // Current offset in input data buffer + int nInBytes; // Number of bytes in the input buffer + char * pOutBuff; // Pointer to output data buffer + int nOutPos; // Position in the output buffer + int nMaxOut; // Maximum number of bytes in the output buffer +} TDataInfo; + +// Table of compression functions +typedef int (*COMPRESS)(char *, int *, char *, int, int *, int); +typedef struct +{ + unsigned long dwMask; // Compression mask + COMPRESS Compress; // Compression function +} TCompressTable; + +// Table of decompression functions +typedef int (*DECOMPRESS)(char *, int *, char *, int); +typedef struct +{ + unsigned long dwMask; // Decompression bit + DECOMPRESS Decompress; // Decompression function +} TDecompressTable; + + +/*****************************************************************************/ +/* */ +/* Support functions for Pkware Data Compression Library */ +/* */ +/*****************************************************************************/ + +// Function loads data from the input buffer. Used by Pklib's "implode" +// and "explode" function as user-defined callback +// Returns number of bytes loaded +// +// char * buf - Pointer to a buffer where to store loaded data +// unsigned int * size - Max. number of bytes to read +// void * param - Custom pointer, parameter of implode/explode + +static unsigned int ReadInputData(char * buf, unsigned int * size, void * param) +{ + TDataInfo * pInfo = (TDataInfo *)param; + unsigned int nMaxAvail = (pInfo->nInBytes - pInfo->nInPos); + unsigned int nToRead = *size; + + // Check the case when not enough data available + if(nToRead > nMaxAvail) + nToRead = nMaxAvail; + + // Load data and increment offsets + memcpy(buf, pInfo->pInBuff + pInfo->nInPos, nToRead); + pInfo->nInPos += nToRead; + + return nToRead; +} + +// Function for store output data. Used by Pklib's "implode" and "explode" +// as user-defined callback +// +// char * buf - Pointer to data to be written +// unsigned int * size - Number of bytes to write +// void * param - Custom pointer, parameter of implode/explode + +static void WriteOutputData(char * buf, unsigned int * size, void * param) +{ + TDataInfo * pInfo = (TDataInfo *)param; + unsigned int nMaxWrite = (pInfo->nMaxOut - pInfo->nOutPos); + unsigned int nToWrite = *size; + + // Check the case when not enough space in the output buffer + if(nToWrite > nMaxWrite) + nToWrite = nMaxWrite; + + // Write output data and increments offsets + memcpy(pInfo->pOutBuff + pInfo->nOutPos, buf, nToWrite); + pInfo->nOutPos += nToWrite; +} + +/*****************************************************************************/ +/* */ +/* "80" is IMA ADPCM stereo (de)compression */ +/* "40" is IMA ADPCM mono (de)compression */ +/* */ +/*****************************************************************************/ + +int Compress_wave_mono(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int nCmpLevel) +{ + // Prepare the compression level for the next compression + // (After us, the Huffmann compression will be called) + if(0 < nCmpLevel && nCmpLevel <= 2) + { + nCmpLevel = 4; + *pCmpType = 6; + } + else if(nCmpLevel == 3) + { + nCmpLevel = 6; + *pCmpType = 8; + } + else + { + nCmpLevel = 5; + *pCmpType = 7; + } + *pdwOutLength = CompressWave((unsigned char *)pbOutBuffer, *pdwOutLength, (short *)pbInBuffer, dwInLength, 1, nCmpLevel); + return 0; +} + +int Decompress_wave_mono(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) +{ + *pdwOutLength = DecompressWave((unsigned char *)pbOutBuffer, *pdwOutLength, (unsigned char *)pbInBuffer, dwInLength, 1); + return 1; +} + +int Compress_wave_stereo(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int nCmpLevel) +{ + // Prepare the compression type for the next compression + // (After us, the Huffmann compression will be called) + if(0 < nCmpLevel && nCmpLevel <= 2) + { + nCmpLevel = 4; + *pCmpType = 6; + } + else if(nCmpLevel == 3) + { + nCmpLevel = 6; + *pCmpType = 8; + } + else + { + nCmpLevel = 5; + *pCmpType = 7; + } + *pdwOutLength = CompressWave((unsigned char *)pbOutBuffer, *pdwOutLength, (short *)pbInBuffer, dwInLength, 2, nCmpLevel); + return 0; +} + +int Decompress_wave_stereo(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) +{ + *pdwOutLength = DecompressWave((unsigned char *)pbOutBuffer, *pdwOutLength, (unsigned char *)pbInBuffer, dwInLength, 2); + return 1; +} + +/*****************************************************************************/ +/* */ +/* The "01" (de)compression is the Huffman (de)compression */ +/* */ +/*****************************************************************************/ + +// 1500F4C0 +int Compress_huff(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int /* nCmpLevel */) +{ + THuffmannTree ht; // Huffmann tree for compression + TOutputStream os; // Output stream + + // Initialize output stream + os.pbOutBuffer = (unsigned char *)pbOutBuffer; + os.dwOutSize = *pdwOutLength; + os.pbOutPos = (unsigned char *)pbOutBuffer; + os.dwBitBuff = 0; + os.nBits = 0; + + // Initialize the Huffmann tree for compression + ht.InitTree(true); + + *pdwOutLength = ht.DoCompression(&os, (unsigned char *)pbInBuffer, dwInLength, *pCmpType); + + // The following code is not necessary to run, because it has no + // effect on the output data. It only clears the huffmann tree, but when + // the tree is on the stack, who cares ? +// ht.UninitTree(); + return 0; +} + +// 1500F5F0 +int Decompress_huff(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int /* dwInLength */) +{ + THuffmannTree ht; + TInputStream is; + + // Initialize input stream +// is.pbInBuffer = (unsigned char *)pbInBuffer; + is.dwBitBuff = BSWAP_INT32_UNSIGNED(*(unsigned long *)pbInBuffer); + pbInBuffer += sizeof(unsigned long); + is.pbInBuffer = (unsigned char *)pbInBuffer; + is.nBits = 32; + + // Initialize the Huffmann tree for compression + ht.InitTree(false); + *pdwOutLength = ht.DoDecompression((unsigned char *)pbOutBuffer, *pdwOutLength, &is); + + // The following code is not necessary to run, because it has no + // effect on the output data. It only clears the huffmann tree, but when + // the tree is on the stack, who cares ? +// ht.UninitTree(); + return 0; +} + +/*****************************************************************************/ +/* */ +/* The "02" (de)compression is the ZLIB (de)compression */ +/* */ +/*****************************************************************************/ + +int Compress_zlib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * /* pCmpType */, int /* nCmpLevel */) +{ + z_stream z; // Stream information for zlib + int nResult; + + // Fill the stream structure for zlib + z.next_in = (Bytef *)pbInBuffer; + z.avail_in = (uInt)dwInLength; + z.total_in = dwInLength; + z.next_out = (Bytef *)pbOutBuffer; + z.avail_out = *pdwOutLength; + z.total_out = 0; + z.zalloc = NULL; + z.zfree = NULL; + + // Initialize the compression structure. Storm.dll uses zlib version 1.1.3 + *pdwOutLength = 0; + if((nResult = deflateInit(&z, Z_DEFAULT_COMPRESSION)) == 0) + { + // Call zlib to compress the data + nResult = deflate(&z, Z_FINISH); + + if(nResult == Z_OK || nResult == Z_STREAM_END) + *pdwOutLength = z.total_out; + + deflateEnd(&z); + } + return nResult; +} + +int Decompress_zlib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) +{ + z_stream z; // Stream information for zlib + int nResult; + + // Fill the stream structure for zlib + z.next_in = (Bytef *)pbInBuffer; + z.avail_in = (uInt)dwInLength; + z.total_in = dwInLength; + z.next_out = (Bytef *)pbOutBuffer; + z.avail_out = *pdwOutLength; + z.total_out = 0; + z.zalloc = NULL; + z.zfree = NULL; + + // Initialize the decompression structure. Storm.dll uses zlib version 1.1.3 + if((nResult = inflateInit(&z)) == 0) + { + // Call zlib to decompress the data + nResult = inflate(&z, Z_FINISH); + *pdwOutLength = z.total_out; + inflateEnd(&z); + } + return nResult; +} + +/*****************************************************************************/ +/* */ +/* The "08" (de)compression is the Pkware DCL (de)compression */ +/* */ +/*****************************************************************************/ + +int Compress_pklib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int /* nCmpLevel */) +{ + TDataInfo Info; // Data information + char * work_buf = ALLOCMEM(char, CMP_BUFFER_SIZE);// Pklib's work buffer + unsigned int dict_size; // Dictionary size + unsigned int ctype; // Compression type + + // Fill data information structure + Info.pInBuff = pbInBuffer; + Info.nInPos = 0; + Info.nInBytes = dwInLength; + Info.pOutBuff = pbOutBuffer; + Info.nOutPos = 0; + Info.nMaxOut = *pdwOutLength; + + // Set the compression type and dictionary size + ctype = (*pCmpType == 2) ? CMP_ASCII : CMP_BINARY; + if (dwInLength < 0x600) + dict_size = 0x400; + else if(0x600 <= dwInLength && dwInLength < 0xC00) + dict_size = 0x800; + else + dict_size = 0x1000; + + // Do the compression + implode(ReadInputData, WriteOutputData, work_buf, &Info, &ctype, &dict_size); + *pdwOutLength = Info.nOutPos; + FREEMEM(work_buf); + return 0; +} + +int Decompress_pklib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) +{ + TDataInfo Info; // Data information + char * work_buf = ALLOCMEM(char, EXP_BUFFER_SIZE);// Pklib's work buffer + + // Fill data information structure + Info.pInBuff = pbInBuffer; + Info.nInPos = 0; + Info.nInBytes = dwInLength; + Info.pOutBuff = pbOutBuffer; + Info.nOutPos = 0; + Info.nMaxOut = *pdwOutLength; + + // Do the decompression + explode(ReadInputData, WriteOutputData, work_buf, &Info); + + // Fix: If PKLIB is unable to decompress the data, they are uncompressed + if(Info.nOutPos == 0) + { + Info.nOutPos = min(*pdwOutLength, dwInLength); + memcpy(pbOutBuffer, pbInBuffer, Info.nOutPos); + } + + *pdwOutLength = Info.nOutPos; + FREEMEM(work_buf); + return 0; +} + +/*****************************************************************************/ +/* */ +/* The "10" (de)compression is the Bzip2 (de)compression */ +/* */ +/*****************************************************************************/ + +int Compress_bzip2(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int nCmpLevel) +{ + bz_stream strm; + int blockSize100k; + int workFactor = 30; + + // Keep compiler happy + nCmpLevel = nCmpLevel; + + // Initialize the BZLIB compression + strm.bzalloc = NULL; + strm.bzfree = NULL; + + // Adjust the block size + blockSize100k = *pCmpType; + if(blockSize100k < 1 || blockSize100k > 9) + blockSize100k = 9; + + // Blizzard uses 9 as blockSize100k, (0 as workFactor) + if(BZ2_bzCompressInit(&strm, blockSize100k, 0, workFactor) == 0) + { + strm.next_in = pbInBuffer; + strm.avail_in = dwInLength; + strm.next_out = pbOutBuffer; + strm.avail_out = *pdwOutLength; + + // Perform the compression + while(BZ2_bzCompress(&strm, (strm.avail_in != 0) ? BZ_RUN : BZ_FINISH) != BZ_STREAM_END); + + // Put the stream into idle state + BZ2_bzCompressEnd(&strm); + *pdwOutLength = strm.total_out_lo32; + } + else + { + *pdwOutLength = 0; + } + + return 0; +} + +int Decompress_bzip2(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) +{ + bz_stream strm; + + // Initialize the BZLIB decompression + strm.bzalloc = NULL; + strm.bzfree = NULL; + if(BZ2_bzDecompressInit(&strm, 0, 0) == 0) + { + strm.next_in = pbInBuffer; + strm.avail_in = dwInLength; + strm.next_out = pbOutBuffer; + strm.avail_out = *pdwOutLength; + + // Perform the decompression + while(BZ2_bzDecompress(&strm) != BZ_STREAM_END); + + // Put the stream into idle state + BZ2_bzDecompressEnd(&strm); + *pdwOutLength = strm.total_out_lo32; + } + else + { + // Set zero output length + *pdwOutLength = 0; + } + + return 0; +} + +/*****************************************************************************/ +/* */ +/* SCompCompress */ +/* */ +/*****************************************************************************/ + +// This table contains compress functions which can be applied to +// uncompressed blocks. Each bit set means the corresponding +// compression method/function must be applied. +// +// WAVes compression Data compression +// ------------------ ------------------- +// 1st block - 0x08 0x08 (D, HF, W2, SC, D2) +// Rest blocks - 0x81 0x02 (W3) + +static TCompressTable cmp_table[] = +{ + {MPQ_COMPRESSION_WAVE_MONO, Compress_wave_mono}, // IMA ADPCM mono compression + {MPQ_COMPRESSION_WAVE_STEREO, Compress_wave_stereo}, // IMA ADPCM stereo compression + {MPQ_COMPRESSION_HUFFMANN, Compress_huff}, // Huffmann compression + {MPQ_COMPRESSION_ZLIB, Compress_zlib}, // Compression with the "zlib" library + {MPQ_COMPRESSION_PKWARE, Compress_pklib}, // Compression with Pkware DCL + {MPQ_COMPRESSION_BZIP2, Compress_bzip2} // Compression Bzip2 library +}; + +int WINAPI SCompCompress(char * pbCompressed, int * pdwOutLength, char * pbUncompressed, int dwInLength, + int uCompressions, int nCmpType, int nCmpLevel) +{ + char * pbTempBuff = NULL; // Temporary storage for decompressed data + char * pbOutput = pbCompressed; // Current output buffer + char * pbInput; // Current input buffer + int uCompressions2; + int dwCompressCount = 0; + int dwDoneCount = 0; + int dwOutSize = 0; + int dwInSize = dwInLength; + int dwEntries = (sizeof(cmp_table) / sizeof(TCompressTable)); + int nResult = 1; + int i; + + // Check for valid parameters + if(!pdwOutLength || *pdwOutLength < dwInLength || !pbCompressed || !pbUncompressed) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + // Count the compressions + for(i = 0, uCompressions2 = uCompressions; i < dwEntries; i++) + { + if(uCompressions & cmp_table[i].dwMask) + dwCompressCount++; + + uCompressions2 &= ~cmp_table[i].dwMask; + } + + // If a compression remains, do nothing + if(uCompressions2 != 0) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + // If more that one compression, allocate intermediate buffer + if(dwCompressCount >= 2) + pbTempBuff = ALLOCMEM(char, *pdwOutLength + 1); + + // Perform the compressions + pbInput = pbUncompressed; + dwInSize = dwInLength; + for(i = 0, uCompressions2 = uCompressions; i < dwEntries; i++) + { + if(uCompressions2 & cmp_table[i].dwMask) + { + // Set the right output buffer + dwCompressCount--; + pbOutput = (dwCompressCount & 1) ? pbTempBuff : pbCompressed; + + // Perform the partial compression + dwOutSize = *pdwOutLength - 1; + + cmp_table[i].Compress(pbOutput + 1, &dwOutSize, pbInput, dwInSize, &nCmpType, nCmpLevel); + if(dwOutSize == 0) + { + SetLastError(ERROR_GEN_FAILURE); + *pdwOutLength = 0; + nResult = 0; + break; + } + + // If the compression failed, copy the block instead + if(dwOutSize >= dwInSize - 1) + { + if(dwDoneCount > 0) + pbOutput++; + + memcpy(pbOutput, pbInput, dwInSize); + pbInput = pbOutput; + uCompressions &= ~cmp_table[i].dwMask; + dwOutSize = dwInSize; + } + else + { + pbInput = pbOutput + 1; + dwInSize = dwOutSize; + dwDoneCount++; + } + } + } + + // Copy the compressed data to the correct output buffer + if(nResult != 0) + { + if(uCompressions && (dwInSize + 1) < *pdwOutLength) + { + if(pbOutput != pbCompressed && pbOutput != pbCompressed + 1) + memcpy(pbCompressed, pbOutput, dwInSize); + *pbCompressed = (char)uCompressions; + *pdwOutLength = dwInSize + 1; + } + else + { + memmove(pbCompressed, pbUncompressed, dwInSize); + *pdwOutLength = dwInSize; + } + } + + // Cleanup and return + if(pbTempBuff != NULL) + FREEMEM(pbTempBuff); + return nResult; +} + +/*****************************************************************************/ +/* */ +/* SCompDecompress */ +/* */ +/*****************************************************************************/ + +// This table contains decompress functions which can be applied to +// uncompressed blocks. The compression mask is stored in the first byte +// of compressed block +static TDecompressTable dcmp_table[] = +{ + {MPQ_COMPRESSION_BZIP2, Decompress_bzip2}, // Decompression with Bzip2 library + {MPQ_COMPRESSION_PKWARE, Decompress_pklib}, // Decompression with Pkware Data Compression Library + {MPQ_COMPRESSION_ZLIB, Decompress_zlib}, // Decompression with the "zlib" library + {MPQ_COMPRESSION_HUFFMANN, Decompress_huff}, // Huffmann decompression + {MPQ_COMPRESSION_WAVE_STEREO, Decompress_wave_stereo}, // IMA ADPCM stereo decompression + {MPQ_COMPRESSION_WAVE_MONO, Decompress_wave_mono} // IMA ADPCM mono decompression +}; + +int WINAPI SCompDecompress(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) +{ + char * pbTempBuff = NULL; // Temporary storage for decompressed data + char * pbWorkBuff = NULL; // Where to store decompressed data + int dwOutLength = *pdwOutLength; // For storage number of output bytes + unsigned fDecompressions1; // Decompressions applied to the block + unsigned fDecompressions2; // Just another copy of decompressions applied to the block + int dwCount = 0; // Counter for every use + int dwEntries = (sizeof(dcmp_table) / sizeof(TDecompressTable)); + int nResult = 1; + int i; + + // If the input length is the same as output, do nothing. + if(dwInLength == dwOutLength) + { + if(pbInBuffer == pbOutBuffer) + return 1; + + memcpy(pbOutBuffer, pbInBuffer, dwInLength); + *pdwOutLength = dwInLength; + return 1; + } + + // Get applied compression types and decrement data length + fDecompressions1 = fDecompressions2 = (unsigned char)*pbInBuffer++; + dwInLength--; + + // Search decompression table type and get all types of compression + for(i = 0; i < dwEntries; i++) + { + // We have to apply this decompression ? + if(fDecompressions1 & dcmp_table[i].dwMask) + dwCount++; + + // Clear this flag from temporary variable. + fDecompressions2 &= ~dcmp_table[i].dwMask; + } + + // Check if there is some method unhandled + // (E.g. compressed by future versions) + if(fDecompressions2 != 0) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + // If there is more than only one compression, we have to allocate extra buffer + if(dwCount >= 2) + pbTempBuff = ALLOCMEM(char, dwOutLength); + + // Apply all decompressions + for(i = 0, dwCount = 0; i < dwEntries; i++) + { + // If not used this kind of compression, skip the loop + if(fDecompressions1 & dcmp_table[i].dwMask) + { + // If odd case, use target buffer for output, otherwise use allocated tempbuffer + pbWorkBuff = (dwCount++ & 1) ? pbTempBuff : pbOutBuffer; + dwOutLength = *pdwOutLength; + + // Decompress buffer using corresponding function + dcmp_table[i].Decompress(pbWorkBuff, &dwOutLength, pbInBuffer, dwInLength); + if(dwOutLength == 0) + { + SetLastError(ERROR_GEN_FAILURE); + nResult = 0; + break; + } + + // Move output length to src length for next compression + dwInLength = dwOutLength; + pbInBuffer = pbWorkBuff; + } + } + + // If output buffer is not the same like target buffer, we have to copy data + if(nResult != 0) + { + if(pbWorkBuff != pbOutBuffer) + memcpy(pbOutBuffer, pbInBuffer, dwOutLength); + + } + + // Delete temporary buffer, if necessary + if(pbTempBuff != NULL) + FREEMEM(pbTempBuff); + + *pdwOutLength = dwOutLength; + return nResult; +} + +/*****************************************************************************/ +/* */ +/* SCompSetDataCompression */ +/* */ +/*****************************************************************************/ + +int WINAPI SCompSetDataCompression(int nDataCompression) +{ + int nValidMask = (MPQ_COMPRESSION_ZLIB | MPQ_COMPRESSION_PKWARE | MPQ_COMPRESSION_BZIP2); + + if((nDataCompression & nValidMask) != nDataCompression) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + SetDataCompression(nDataCompression); + return TRUE; +} + + diff --git a/src/tools/stuffextract/StormLib/SFileCompactArchive.cpp b/src/tools/stuffextract/StormLib/SFileCompactArchive.cpp index 30540d1..9510b15 100644 --- a/src/tools/stuffextract/StormLib/SFileCompactArchive.cpp +++ b/src/tools/stuffextract/StormLib/SFileCompactArchive.cpp @@ -1,691 +1,691 @@ -/*****************************************************************************/ -/* SFileCompactArchive.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Archive compacting function */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 14.04.03 1.00 Lad Splitted from SFileCreateArchiveEx.cpp */ -/* 19.11.03 1.01 Dan Big endian handling */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -/*****************************************************************************/ -/* Local structures */ -/*****************************************************************************/ - -/*****************************************************************************/ -/* Local variables */ -/*****************************************************************************/ - -static COMPACTCB CompactCB = NULL; -static void * lpUserData = NULL; - -/*****************************************************************************/ -/* Local functions */ -/*****************************************************************************/ - -// Creates a copy of hash table -static TMPQHash * CopyHashTable(TMPQArchive * ha) -{ - TMPQHash * pHashTableCopy = ALLOCMEM(TMPQHash, ha->pHeader->dwHashTableSize); - - if(pHashTableCopy != NULL) - memcpy(pHashTableCopy, ha->pHashTable, sizeof(TMPQHash) * ha->pHeader->dwHashTableSize); - - return pHashTableCopy; -} - -// TODO: Test for archives > 4GB -static int CheckIfAllFilesKnown(TMPQArchive * ha, const char * szListFile, DWORD * pFileSeeds) -{ - TMPQHash * pHashTableCopy = NULL; // Copy of the hash table - TMPQHash * pHash; - TMPQHash * pHashEnd = NULL; // End of the hash table - DWORD dwFileCount = 0; - int nError = ERROR_SUCCESS; - - // First of all, create a copy of hash table - if(nError == ERROR_SUCCESS) - { - if((pHashTableCopy = CopyHashTable(ha)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - pHashEnd = pHashTableCopy + ha->pHeader->dwHashTableSize; - - // Notify the user - if(CompactCB != NULL) - CompactCB(lpUserData, CCB_CHECKING_FILES, 0, ha->pHeader->dwBlockTableSize); - } - - // Now check all the files from the filelist - if(nError == ERROR_SUCCESS) - { - SFILE_FIND_DATA wf; - HANDLE hFind = SFileFindFirstFile((HANDLE)ha, "*", &wf, szListFile); - BOOL bResult = TRUE; - - // Do while some files have been found - while(hFind != NULL && bResult) - { - TMPQHash * pHash = GetHashEntry(ha, wf.cFileName); - - // If the hash table entry has been found, find it's position - // in the hash table copy - if(pHash != NULL) - { - pHash = pHashTableCopy + (pHash - ha->pHashTable); - if(pHash->dwName1 != (DWORD)-1 && pHash->dwName2 != (DWORD)-1) - { - TMPQBlock * pBlock = ha->pBlockTable + pHash->dwBlockIndex; - DWORD dwSeed = 0; - - // Resolve the file seed. Use plain file name for it - if(pBlock->dwFlags & MPQ_FILE_ENCRYPTED) - { - char * szFileName = strrchr(wf.cFileName, '\\'); - - if(szFileName == NULL) - szFileName = wf.cFileName; - else - szFileName++; - - dwSeed = DecryptFileSeed(szFileName); - if(pBlock->dwFlags & MPQ_FILE_FIXSEED) - dwSeed = (dwSeed + pBlock->dwFilePos) ^ pBlock->dwFSize; - } - pFileSeeds[pHash->dwBlockIndex] = dwSeed; - - pHash->dwName1 = 0xFFFFFFFF; - pHash->dwName2 = 0xFFFFFFFF; - pHash->lcLocale = 0xFFFF; - pHash->wPlatform = 0xFFFF; - pHash->dwBlockIndex = 0xFFFFFFFF; - } - } - // Notify the user - if(CompactCB != NULL) - CompactCB(lpUserData, CCB_CHECKING_FILES, ++dwFileCount, ha->pHeader->dwBlockTableSize); - - // Find the next file in the archive - bResult = SFileFindNextFile(hFind, &wf); - } - - if(hFind != NULL) - SFileFindClose(hFind); - } - - // When the filelist checking is complete, parse the hash table copy and find the - if(nError == ERROR_SUCCESS) - { - // Notify the user about checking hash table - dwFileCount = 0; - if(CompactCB != NULL) - CompactCB(lpUserData, CCB_CHECKING_HASH_TABLE, dwFileCount, ha->pHeader->dwBlockTableSize); - - for(pHash = pHashTableCopy; pHash < pHashEnd; pHash++) - { - // If there is an unresolved entry, try to detect its seed. If it fails, - // we cannot complete the work - if(pHash->dwName1 != (DWORD)-1 && pHash->dwName2 != (DWORD)-1) - { - HANDLE hFile = NULL; - DWORD dwFlags = 0; - DWORD dwSeed = 0; - - if(SFileOpenFileEx((HANDLE)ha, (char *)(DWORD_PTR)pHash->dwBlockIndex, 0, &hFile)) - { - TMPQFile * hf = (TMPQFile *)hFile; - dwFlags = hf->pBlock->dwFlags; - dwSeed = hf->dwSeed1; - SFileCloseFile(hFile); - } - - // If the file is encrypted, we have to check - // If we can apply the file decryption seed - if(dwFlags & MPQ_FILE_ENCRYPTED && dwSeed == 0) - { - nError = ERROR_CAN_NOT_COMPLETE; - break; - } - - // Remember the seed - pFileSeeds[pHash->dwBlockIndex] = dwSeed; - - // Notify the user - if(CompactCB != NULL) - CompactCB(lpUserData, CCB_CHECKING_HASH_TABLE, ++dwFileCount, ha->pHeader->dwBlockTableSize); - } - } - } - - // Delete the copy of hash table - if(pHashTableCopy != NULL) - FREEMEM(pHashTableCopy); - return nError; -} - -// Copies all file blocks into another archive. -// TODO: Test for archives > 4GB -static int CopyMpqFileBlocks( - HANDLE hFile, - TMPQArchive * ha, - TMPQBlockEx * pBlockEx, - TMPQBlock * pBlock, - DWORD dwSeed) -{ - LARGE_INTEGER FilePos = {0}; - DWORD * pdwBlockPos2 = NULL; // File block positions to be written to target file - DWORD * pdwBlockPos = NULL; // File block positions (unencrypted) - BYTE * pbBlock = NULL; // Buffer for the file block - DWORD dwTransferred; // Number of bytes transferred - DWORD dwCSize = 0; // Compressed file size - DWORD dwBytes = 0; // Number of bytes - DWORD dwSeed1 = 0; // File seed used for decryption - DWORD dwSeed2 = 0; // File seed used for encryption - DWORD nBlocks = 0; // Number of file blocks - DWORD nBlock = 0; // Currently processed file block - int nError = ERROR_SUCCESS; - - // When file length is zero, do nothing - if(pBlock->dwFSize == 0) - return ERROR_SUCCESS; - - // Calculate number of blocks in the file - if(nError == ERROR_SUCCESS) - { - nBlocks = pBlock->dwFSize / ha->dwBlockSize; - if(pBlock->dwFSize % ha->dwBlockSize) - nBlocks++; - pbBlock = ALLOCMEM(BYTE, ha->dwBlockSize); - if(pbBlock == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Set the position to the begin of the file within archive - if(nError == ERROR_SUCCESS) - { - FilePos.HighPart = pBlockEx->wFilePosHigh; - FilePos.LowPart = pBlock->dwFilePos; - FilePos.QuadPart += ha->MpqPos.QuadPart; - if(SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN) != FilePos.LowPart) - nError = GetLastError(); - } - - // Remember the position in the destination file - if(nError == ERROR_SUCCESS) - { - FilePos.HighPart = 0; - FilePos.LowPart = SetFilePointer(hFile, 0, &FilePos.HighPart, FILE_CURRENT); - } - - // Resolve decryption seeds. The 'dwSeed' parameter is the decryption - // seed for the file. - if(nError == ERROR_SUCCESS && (pBlock->dwFlags & MPQ_FILE_ENCRYPTED)) - { - dwSeed1 = dwSeed; - if(pBlock->dwFlags & MPQ_FILE_FIXSEED) - dwSeed = (dwSeed1 ^ pBlock->dwFSize) - pBlock->dwFilePos; - - dwSeed2 = dwSeed; - if(pBlock->dwFlags & MPQ_FILE_FIXSEED) - dwSeed2 = (dwSeed + (DWORD)(FilePos.QuadPart - ha->MpqPos.QuadPart)) ^ pBlock->dwFSize; - } - - // Load the file positions from the archive and save it to the target file - // (only if the file is compressed) - if(pBlock->dwFlags & MPQ_FILE_COMPRESSED) - { - // Allocate buffers - if(nError == ERROR_SUCCESS) - { - pdwBlockPos = ALLOCMEM(DWORD, nBlocks + 2); - pdwBlockPos2 = ALLOCMEM(DWORD, nBlocks + 2); - - if(pdwBlockPos == NULL || pdwBlockPos2 == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Load the block positions - if(nError == ERROR_SUCCESS) - { - dwBytes = (nBlocks + 1) * sizeof(DWORD); - if(pBlock->dwFlags & MPQ_FILE_HAS_EXTRA) - dwBytes += sizeof(DWORD); - - ReadFile(ha->hFile, pdwBlockPos, dwBytes, &dwTransferred, NULL); - if(dwTransferred != dwBytes) - nError = ERROR_FILE_CORRUPT; - } - - // Re-encrypt the block table positions - if(nError == ERROR_SUCCESS) - { - BSWAP_ARRAY32_UNSIGNED(pdwBlockPos, dwBytes / sizeof(DWORD)); - if(pBlock->dwFlags & MPQ_FILE_ENCRYPTED) - { - DecryptMPQBlock(pdwBlockPos, dwBytes, dwSeed1 - 1); - if(pdwBlockPos[0] != dwBytes) - nError = ERROR_FILE_CORRUPT; - - memcpy(pdwBlockPos2, pdwBlockPos, dwBytes); - EncryptMPQBlock(pdwBlockPos2, dwBytes, dwSeed2 - 1); - } - else - { - memcpy(pdwBlockPos2, pdwBlockPos, dwBytes); - } - BSWAP_ARRAY32_UNSIGNED(pdwBlockPos2, dwBytes / sizeof(DWORD)); - } - - // Write to the target file - if(nError == ERROR_SUCCESS) - { - WriteFile(hFile, pdwBlockPos2, dwBytes, &dwTransferred, NULL); - dwCSize += dwTransferred; - if(dwTransferred != dwBytes) - nError = ERROR_DISK_FULL; - } - } - - // Now we have to copy all file block. We will do it without - // recompression, because re-compression is not necessary in this case - if(nError == ERROR_SUCCESS) - { - for(nBlock = 0; nBlock < nBlocks; nBlock++) - { - // Fix: The last block must not be exactly the size of one block. - dwBytes = ha->dwBlockSize; - if(nBlock == nBlocks - 1) - { - dwBytes = pBlock->dwFSize - (ha->dwBlockSize * (nBlocks - 1)); - } - - if(pBlock->dwFlags & MPQ_FILE_COMPRESSED) - dwBytes = pdwBlockPos[nBlock+1] - pdwBlockPos[nBlock]; - - // Read the file block - ReadFile(ha->hFile, pbBlock, dwBytes, &dwTransferred, NULL); - if(dwTransferred != dwBytes) - { - nError = ERROR_FILE_CORRUPT; - break; - } - - // If necessary, re-encrypt the block - // Note: Recompression is not necessary here. Unlike encryption, - // the compression does not depend on the position of the file in MPQ. - if((pBlock->dwFlags & MPQ_FILE_ENCRYPTED) && dwSeed1 != dwSeed2) - { - BSWAP_ARRAY32_UNSIGNED((DWORD *)pbBlock, dwBytes/sizeof(DWORD)); - DecryptMPQBlock((DWORD *)pbBlock, dwBytes, dwSeed1 + nBlock); - EncryptMPQBlock((DWORD *)pbBlock, dwBytes, dwSeed2 + nBlock); - BSWAP_ARRAY32_UNSIGNED((DWORD *)pbBlock, dwBytes/sizeof(DWORD)); - } - - // Now write the block back to the file - WriteFile(hFile, pbBlock, dwBytes, &dwTransferred, NULL); - dwCSize += dwTransferred; - if(dwTransferred != dwBytes) - { - nError = ERROR_DISK_FULL; - break; - } - } - } - - // Copy the file extras, if any - // These extras does not seem to be encrypted, and their purpose is unknown - if(nError == ERROR_SUCCESS && (pBlock->dwFlags & MPQ_FILE_HAS_EXTRA)) - { - dwBytes = pdwBlockPos[nBlocks + 1] - pdwBlockPos[nBlocks]; - if(dwBytes != 0) - { - ReadFile(ha->hFile, pbBlock, dwBytes, &dwTransferred, NULL); - if(dwTransferred == dwBytes) - { - WriteFile(hFile, pbBlock, dwBytes, &dwTransferred, NULL); - dwCSize += dwTransferred; - if(dwTransferred != dwBytes) - nError = ERROR_DISK_FULL; - } - else - { - nError = ERROR_FILE_CORRUPT; - } - } - } - - // Update file position in the block table - if(nError == ERROR_SUCCESS) - { - // At this point, number of bytes written should be exactly - // the same like the compressed file size. If it isn't, there's something wrong - // (maybe new archive version ?) - assert(dwCSize == pBlock->dwCSize); - - // Update file pos in the block table - FilePos.QuadPart -= ha->MpqPos.QuadPart; - pBlockEx->wFilePosHigh = (USHORT)FilePos.HighPart; - pBlock->dwFilePos = FilePos.LowPart; - } - - // Cleanup and return - if(pdwBlockPos2 != NULL) - FREEMEM(pdwBlockPos2); - if(pdwBlockPos != NULL) - FREEMEM(pdwBlockPos); - if(pbBlock != NULL) - FREEMEM(pbBlock); - return nError; -} - - -static int CopyNonMpqData( - HANDLE hSrcFile, - HANDLE hTrgFile, - LARGE_INTEGER & DataSizeToCopy) -{ - LARGE_INTEGER DataSize = DataSizeToCopy; - DWORD dwTransferred; - DWORD dwToRead; - char DataBuffer[0x1000]; - int nError = ERROR_SUCCESS; - - while(DataSize.QuadPart > 0) - { - // Get the proper size of data - dwToRead = sizeof(DataBuffer); - if(DataSize.HighPart == 0 && DataSize.LowPart < dwToRead) - dwToRead = DataSize.LowPart; - - // Read the source file - ReadFile(hSrcFile, DataBuffer, dwToRead, &dwTransferred, NULL); - if(dwTransferred != dwToRead) - { - nError = ERROR_CAN_NOT_COMPLETE; - break; - } - - // Write to the target file - WriteFile(hTrgFile, DataBuffer, dwToRead, &dwTransferred, NULL); - if(dwTransferred != dwToRead) - { - nError = ERROR_DISK_FULL; - break; - } - - // Decrement the number of data to be copied - DataSize.QuadPart -= dwTransferred; - } - - return ERROR_SUCCESS; -} - -// TODO: Test for archives > 4GB -static int CopyMpqFiles(HANDLE hFile, TMPQArchive * ha, DWORD * pFileSeeds) -{ - TMPQBlockEx * pBlockEx; - TMPQBlock * pBlock; - DWORD dwSeed1; - DWORD dwIndex; - int nError = ERROR_SUCCESS; - - // Walk through all files and write them to the destination MPQ archive - for(dwIndex = 0; dwIndex < ha->pHeader->dwBlockTableSize; dwIndex++) - { - pBlockEx = ha->pExtBlockTable + dwIndex; - pBlock = ha->pBlockTable + dwIndex; - dwSeed1 = pFileSeeds[dwIndex]; - - // Notify the caller about work - if(CompactCB != NULL) - CompactCB(lpUserData, CCB_COMPACTING_FILES, dwIndex, ha->pHeader->dwBlockTableSize); - -// if(dwIndex == 0x1B9) -// DebugBreak(); - - // Copy all the file blocks - // Debug: Break at (dwIndex == 5973) - if(pBlock->dwFlags & MPQ_FILE_EXISTS) - { - nError = CopyMpqFileBlocks(hFile, ha, pBlockEx, pBlock, dwSeed1); - if(nError != ERROR_SUCCESS) - break; - } - } - - // Cleanup and exit - return nError; -} - - -/*****************************************************************************/ -/* Public functions */ -/*****************************************************************************/ - -BOOL WINAPI SFileSetCompactCallback(HANDLE /* hMPQ */, COMPACTCB aCompactCB, void * lpData) -{ - CompactCB = aCompactCB; - lpUserData = lpData; - return TRUE; -} - -//----------------------------------------------------------------------------- -// Archive compacting (incomplete) - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileCompactArchive(HANDLE hMPQ, const char * szListFile, BOOL /* bReserved */) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - HANDLE hFile = INVALID_HANDLE_VALUE; - DWORD * pFileSeeds = NULL; - char szTempFile[MAX_PATH] = ""; - char * szTemp = NULL; - DWORD dwTransferred; - int nError = ERROR_SUCCESS; - - // Test the valid parameters - if(!IsValidMpqHandle(ha)) - nError = ERROR_INVALID_PARAMETER; - - // Create the table with file seeds - if(nError == ERROR_SUCCESS) - { - if((pFileSeeds = ALLOCMEM(DWORD, ha->pHeader->dwBlockTableSize)) != NULL) - memset(pFileSeeds, 0, sizeof(DWORD) * ha->pHeader->dwBlockTableSize); - else - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // First of all, we have to check of we are able to decrypt all files. - // If not, sorry, but the archive cannot be compacted. - if(nError == ERROR_SUCCESS) - nError = CheckIfAllFilesKnown(ha, szListFile, pFileSeeds); - - // Get the temporary file name and create it - if(nError == ERROR_SUCCESS) - { - if(CompactCB != NULL) - CompactCB(lpUserData, CCB_COPYING_NON_MPQ_DATA, 0, 0); - - strcpy(szTempFile, ha->szFileName); - if((szTemp = strrchr(szTempFile, '.')) != NULL) - strcpy(szTemp + 1, "mp_"); - else - strcat(szTempFile, "_"); - - hFile = CreateFile(szTempFile, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL); - if(hFile == INVALID_HANDLE_VALUE) - nError = GetLastError(); - } - - // Write the data before MPQ header (if any) - if(nError == ERROR_SUCCESS && ha->MpqPos.QuadPart > 0) - { - SetFilePointer(ha->hFile, 0, NULL, FILE_BEGIN); - if(ha->pShunt != NULL) - nError = CopyNonMpqData(ha->hFile, hFile, ha->ShuntPos); - else - nError = CopyNonMpqData(ha->hFile, hFile, ha->MpqPos); - } - - // Write the MPQ shunt (if any) - if(nError == ERROR_SUCCESS && ha->pShunt != NULL) - { - BSWAP_TMPQSHUNT(ha->pShunt); - WriteFile(hFile, ha->pShunt, sizeof(TMPQShunt), &dwTransferred, NULL); - BSWAP_TMPQSHUNT(ha->pShunt); - - if(dwTransferred != sizeof(TMPQShunt)) - nError = ERROR_DISK_FULL; - } - - // Write the data between MPQ shunt and the MPQ header (if any) - if(nError == ERROR_SUCCESS && ha->pShunt != NULL) - { - LARGE_INTEGER BytesToCopy; - - BytesToCopy.QuadPart = ha->MpqPos.QuadPart - (ha->ShuntPos.QuadPart + sizeof(TMPQShunt)); - nError = CopyNonMpqData(ha->hFile, hFile, BytesToCopy); - } - - // Write the MPQ header - if(nError == ERROR_SUCCESS) - { - BSWAP_TMPQHEADER(ha->pHeader); - WriteFile(hFile, ha->pHeader, ha->pHeader->dwHeaderSize, &dwTransferred, NULL); - BSWAP_TMPQHEADER(ha->pHeader); - if(dwTransferred != ha->pHeader->dwHeaderSize) - nError = ERROR_DISK_FULL; - } - - // Write the data between the header and between the first file - // For this, we have to determine where the first file begins - if(nError == ERROR_SUCCESS) - { - LARGE_INTEGER FirstFilePos; - LARGE_INTEGER TempPos; - TMPQBlockEx * pBlockEx = ha->pExtBlockTable; - TMPQBlock * pBlockEnd = ha->pBlockTable + ha->pHeader->dwBlockTableSize; - TMPQBlock * pBlock = ha->pBlockTable; - - // Maximum file position - FirstFilePos.HighPart = 0x7FFFFFFF; - FirstFilePos.LowPart = 0xFFFFFFFF; - - // Find the block with the least position in the MPQ - while(pBlock < pBlockEnd) - { - TempPos.HighPart = pBlockEx->wFilePosHigh; - TempPos.LowPart = pBlock->dwFilePos; - if(TempPos.QuadPart < FirstFilePos.QuadPart) - FirstFilePos = TempPos; - - pBlockEx++; - pBlock++; - } - - // Set the position in the source file right after the file header - TempPos.QuadPart = ha->MpqPos.QuadPart + ha->pHeader->dwHeaderSize; - SetFilePointer(ha->hFile, TempPos.LowPart, &TempPos.HighPart, FILE_BEGIN); - - // Get the number of bytes to copy - FirstFilePos.QuadPart -= ha->pHeader->dwHeaderSize; - nError = CopyNonMpqData(ha->hFile, hFile, FirstFilePos); - } - - // Now write all file blocks. - if(nError == ERROR_SUCCESS) - nError = CopyMpqFiles(hFile, ha, pFileSeeds); - - // Now we need to update the tables positions - // (but only if the tables are at the end of the file) - if(nError == ERROR_SUCCESS) - { - LARGE_INTEGER RelativePos; - LARGE_INTEGER FilePos = {0}; - - // Set the hash table position - FilePos.LowPart = SetFilePointer(hFile, 0, &FilePos.HighPart, FILE_CURRENT); - RelativePos.QuadPart = FilePos.QuadPart - ha->MpqPos.QuadPart; - ha->pHeader->wHashTablePosHigh = (USHORT)RelativePos.HighPart; - ha->pHeader->dwHashTablePos = RelativePos.LowPart; - ha->HashTablePos = FilePos; - - // Set the block table position - RelativePos.QuadPart += ha->pHeader->dwHashTableSize * sizeof(TMPQHash); - FilePos.QuadPart += ha->pHeader->dwHashTableSize * sizeof(TMPQHash); - ha->pHeader->wBlockTablePosHigh = (USHORT)RelativePos.HighPart; - ha->pHeader->dwBlockTablePos = RelativePos.LowPart; - ha->BlockTablePos = FilePos; - - // Set the extended block table position - RelativePos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); - FilePos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); - if(ha->ExtBlockTablePos.QuadPart != 0) - { - ha->pHeader->ExtBlockTablePos = RelativePos; - ha->ExtBlockTablePos = FilePos; - - RelativePos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx); - FilePos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx); - } - - // Set the archive size - ha->pHeader->dwArchiveSize = RelativePos.LowPart; - ha->MpqSize = RelativePos; - } - - // If succeeded, update the tables in the file - if(nError == ERROR_SUCCESS) - { - CloseHandle(ha->hFile); - ha->FilePointer.QuadPart = 0; - ha->hFile = hFile; - hFile = INVALID_HANDLE_VALUE; - nError = SaveMPQTables(ha); - } - - // If all succeeded, switch the archives - if(nError == ERROR_SUCCESS) - { - if(CompactCB != NULL) - CompactCB(lpUserData, CCB_CLOSING_ARCHIVE, 0, 0); - - if(!DeleteFile(ha->szFileName) || // Delete the old archive - !CloseHandle(ha->hFile) || // Close the new archive - !MoveFile(szTempFile, ha->szFileName)) // Rename the temporary archive - nError = GetLastError(); - } - - // Now open the freshly renamed archive file - if(nError == ERROR_SUCCESS) - { - ha->hFile = CreateFile(ha->szFileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if(ha->hFile == INVALID_HANDLE_VALUE) - nError = GetLastError(); - } - - // Invalidate the positions of the archive - if(nError == ERROR_SUCCESS) - { - ha->FilePointer.QuadPart = 0; - ha->pLastFile = NULL; - ha->dwBlockPos = 0; - ha->dwBuffPos = 0; - } - - // Cleanup and return - if(hFile != INVALID_HANDLE_VALUE) - CloseHandle(hFile); - if(pFileSeeds != NULL) - FREEMEM(pFileSeeds); - if(nError != ERROR_SUCCESS) - SetLastError(nError); - DeleteFile(szTempFile); - CompactCB = NULL; - return (nError == ERROR_SUCCESS); -} +/*****************************************************************************/ +/* SFileCompactArchive.cpp Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* Archive compacting function */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 14.04.03 1.00 Lad Splitted from SFileCreateArchiveEx.cpp */ +/* 19.11.03 1.01 Dan Big endian handling */ +/*****************************************************************************/ + +#define __STORMLIB_SELF__ +#include "StormLib.h" +#include "SCommon.h" + +/*****************************************************************************/ +/* Local structures */ +/*****************************************************************************/ + +/*****************************************************************************/ +/* Local variables */ +/*****************************************************************************/ + +static COMPACTCB CompactCB = NULL; +static void * lpUserData = NULL; + +/*****************************************************************************/ +/* Local functions */ +/*****************************************************************************/ + +// Creates a copy of hash table +static TMPQHash * CopyHashTable(TMPQArchive * ha) +{ + TMPQHash * pHashTableCopy = ALLOCMEM(TMPQHash, ha->pHeader->dwHashTableSize); + + if(pHashTableCopy != NULL) + memcpy(pHashTableCopy, ha->pHashTable, sizeof(TMPQHash) * ha->pHeader->dwHashTableSize); + + return pHashTableCopy; +} + +// TODO: Test for archives > 4GB +static int CheckIfAllFilesKnown(TMPQArchive * ha, const char * szListFile, DWORD * pFileSeeds) +{ + TMPQHash * pHashTableCopy = NULL; // Copy of the hash table + TMPQHash * pHash; + TMPQHash * pHashEnd = NULL; // End of the hash table + DWORD dwFileCount = 0; + int nError = ERROR_SUCCESS; + + // First of all, create a copy of hash table + if(nError == ERROR_SUCCESS) + { + if((pHashTableCopy = CopyHashTable(ha)) == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + pHashEnd = pHashTableCopy + ha->pHeader->dwHashTableSize; + + // Notify the user + if(CompactCB != NULL) + CompactCB(lpUserData, CCB_CHECKING_FILES, 0, ha->pHeader->dwBlockTableSize); + } + + // Now check all the files from the filelist + if(nError == ERROR_SUCCESS) + { + SFILE_FIND_DATA wf; + HANDLE hFind = SFileFindFirstFile((HANDLE)ha, "*", &wf, szListFile); + BOOL bResult = TRUE; + + // Do while some files have been found + while(hFind != NULL && bResult) + { + TMPQHash * pHash = GetHashEntry(ha, wf.cFileName); + + // If the hash table entry has been found, find it's position + // in the hash table copy + if(pHash != NULL) + { + pHash = pHashTableCopy + (pHash - ha->pHashTable); + if(pHash->dwName1 != (DWORD)-1 && pHash->dwName2 != (DWORD)-1) + { + TMPQBlock * pBlock = ha->pBlockTable + pHash->dwBlockIndex; + DWORD dwSeed = 0; + + // Resolve the file seed. Use plain file name for it + if(pBlock->dwFlags & MPQ_FILE_ENCRYPTED) + { + char * szFileName = strrchr(wf.cFileName, '\\'); + + if(szFileName == NULL) + szFileName = wf.cFileName; + else + szFileName++; + + dwSeed = DecryptFileSeed(szFileName); + if(pBlock->dwFlags & MPQ_FILE_FIXSEED) + dwSeed = (dwSeed + pBlock->dwFilePos) ^ pBlock->dwFSize; + } + pFileSeeds[pHash->dwBlockIndex] = dwSeed; + + pHash->dwName1 = 0xFFFFFFFF; + pHash->dwName2 = 0xFFFFFFFF; + pHash->lcLocale = 0xFFFF; + pHash->wPlatform = 0xFFFF; + pHash->dwBlockIndex = 0xFFFFFFFF; + } + } + // Notify the user + if(CompactCB != NULL) + CompactCB(lpUserData, CCB_CHECKING_FILES, ++dwFileCount, ha->pHeader->dwBlockTableSize); + + // Find the next file in the archive + bResult = SFileFindNextFile(hFind, &wf); + } + + if(hFind != NULL) + SFileFindClose(hFind); + } + + // When the filelist checking is complete, parse the hash table copy and find the + if(nError == ERROR_SUCCESS) + { + // Notify the user about checking hash table + dwFileCount = 0; + if(CompactCB != NULL) + CompactCB(lpUserData, CCB_CHECKING_HASH_TABLE, dwFileCount, ha->pHeader->dwBlockTableSize); + + for(pHash = pHashTableCopy; pHash < pHashEnd; pHash++) + { + // If there is an unresolved entry, try to detect its seed. If it fails, + // we cannot complete the work + if(pHash->dwName1 != (DWORD)-1 && pHash->dwName2 != (DWORD)-1) + { + HANDLE hFile = NULL; + DWORD dwFlags = 0; + DWORD dwSeed = 0; + + if(SFileOpenFileEx((HANDLE)ha, (char *)(DWORD_PTR)pHash->dwBlockIndex, 0, &hFile)) + { + TMPQFile * hf = (TMPQFile *)hFile; + dwFlags = hf->pBlock->dwFlags; + dwSeed = hf->dwSeed1; + SFileCloseFile(hFile); + } + + // If the file is encrypted, we have to check + // If we can apply the file decryption seed + if(dwFlags & MPQ_FILE_ENCRYPTED && dwSeed == 0) + { + nError = ERROR_CAN_NOT_COMPLETE; + break; + } + + // Remember the seed + pFileSeeds[pHash->dwBlockIndex] = dwSeed; + + // Notify the user + if(CompactCB != NULL) + CompactCB(lpUserData, CCB_CHECKING_HASH_TABLE, ++dwFileCount, ha->pHeader->dwBlockTableSize); + } + } + } + + // Delete the copy of hash table + if(pHashTableCopy != NULL) + FREEMEM(pHashTableCopy); + return nError; +} + +// Copies all file blocks into another archive. +// TODO: Test for archives > 4GB +static int CopyMpqFileBlocks( + HANDLE hFile, + TMPQArchive * ha, + TMPQBlockEx * pBlockEx, + TMPQBlock * pBlock, + DWORD dwSeed) +{ + LARGE_INTEGER FilePos = {0}; + DWORD * pdwBlockPos2 = NULL; // File block positions to be written to target file + DWORD * pdwBlockPos = NULL; // File block positions (unencrypted) + BYTE * pbBlock = NULL; // Buffer for the file block + DWORD dwTransferred; // Number of bytes transferred + DWORD dwCSize = 0; // Compressed file size + DWORD dwBytes = 0; // Number of bytes + DWORD dwSeed1 = 0; // File seed used for decryption + DWORD dwSeed2 = 0; // File seed used for encryption + DWORD nBlocks = 0; // Number of file blocks + DWORD nBlock = 0; // Currently processed file block + int nError = ERROR_SUCCESS; + + // When file length is zero, do nothing + if(pBlock->dwFSize == 0) + return ERROR_SUCCESS; + + // Calculate number of blocks in the file + if(nError == ERROR_SUCCESS) + { + nBlocks = pBlock->dwFSize / ha->dwBlockSize; + if(pBlock->dwFSize % ha->dwBlockSize) + nBlocks++; + pbBlock = ALLOCMEM(BYTE, ha->dwBlockSize); + if(pbBlock == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Set the position to the begin of the file within archive + if(nError == ERROR_SUCCESS) + { + FilePos.HighPart = pBlockEx->wFilePosHigh; + FilePos.LowPart = pBlock->dwFilePos; + FilePos.QuadPart += ha->MpqPos.QuadPart; + if(SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN) != FilePos.LowPart) + nError = GetLastError(); + } + + // Remember the position in the destination file + if(nError == ERROR_SUCCESS) + { + FilePos.HighPart = 0; + FilePos.LowPart = SetFilePointer(hFile, 0, &FilePos.HighPart, FILE_CURRENT); + } + + // Resolve decryption seeds. The 'dwSeed' parameter is the decryption + // seed for the file. + if(nError == ERROR_SUCCESS && (pBlock->dwFlags & MPQ_FILE_ENCRYPTED)) + { + dwSeed1 = dwSeed; + if(pBlock->dwFlags & MPQ_FILE_FIXSEED) + dwSeed = (dwSeed1 ^ pBlock->dwFSize) - pBlock->dwFilePos; + + dwSeed2 = dwSeed; + if(pBlock->dwFlags & MPQ_FILE_FIXSEED) + dwSeed2 = (dwSeed + (DWORD)(FilePos.QuadPart - ha->MpqPos.QuadPart)) ^ pBlock->dwFSize; + } + + // Load the file positions from the archive and save it to the target file + // (only if the file is compressed) + if(pBlock->dwFlags & MPQ_FILE_COMPRESSED) + { + // Allocate buffers + if(nError == ERROR_SUCCESS) + { + pdwBlockPos = ALLOCMEM(DWORD, nBlocks + 2); + pdwBlockPos2 = ALLOCMEM(DWORD, nBlocks + 2); + + if(pdwBlockPos == NULL || pdwBlockPos2 == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Load the block positions + if(nError == ERROR_SUCCESS) + { + dwBytes = (nBlocks + 1) * sizeof(DWORD); + if(pBlock->dwFlags & MPQ_FILE_HAS_EXTRA) + dwBytes += sizeof(DWORD); + + ReadFile(ha->hFile, pdwBlockPos, dwBytes, &dwTransferred, NULL); + if(dwTransferred != dwBytes) + nError = ERROR_FILE_CORRUPT; + } + + // Re-encrypt the block table positions + if(nError == ERROR_SUCCESS) + { + BSWAP_ARRAY32_UNSIGNED(pdwBlockPos, dwBytes / sizeof(DWORD)); + if(pBlock->dwFlags & MPQ_FILE_ENCRYPTED) + { + DecryptMPQBlock(pdwBlockPos, dwBytes, dwSeed1 - 1); + if(pdwBlockPos[0] != dwBytes) + nError = ERROR_FILE_CORRUPT; + + memcpy(pdwBlockPos2, pdwBlockPos, dwBytes); + EncryptMPQBlock(pdwBlockPos2, dwBytes, dwSeed2 - 1); + } + else + { + memcpy(pdwBlockPos2, pdwBlockPos, dwBytes); + } + BSWAP_ARRAY32_UNSIGNED(pdwBlockPos2, dwBytes / sizeof(DWORD)); + } + + // Write to the target file + if(nError == ERROR_SUCCESS) + { + WriteFile(hFile, pdwBlockPos2, dwBytes, &dwTransferred, NULL); + dwCSize += dwTransferred; + if(dwTransferred != dwBytes) + nError = ERROR_DISK_FULL; + } + } + + // Now we have to copy all file block. We will do it without + // recompression, because re-compression is not necessary in this case + if(nError == ERROR_SUCCESS) + { + for(nBlock = 0; nBlock < nBlocks; nBlock++) + { + // Fix: The last block must not be exactly the size of one block. + dwBytes = ha->dwBlockSize; + if(nBlock == nBlocks - 1) + { + dwBytes = pBlock->dwFSize - (ha->dwBlockSize * (nBlocks - 1)); + } + + if(pBlock->dwFlags & MPQ_FILE_COMPRESSED) + dwBytes = pdwBlockPos[nBlock+1] - pdwBlockPos[nBlock]; + + // Read the file block + ReadFile(ha->hFile, pbBlock, dwBytes, &dwTransferred, NULL); + if(dwTransferred != dwBytes) + { + nError = ERROR_FILE_CORRUPT; + break; + } + + // If necessary, re-encrypt the block + // Note: Recompression is not necessary here. Unlike encryption, + // the compression does not depend on the position of the file in MPQ. + if((pBlock->dwFlags & MPQ_FILE_ENCRYPTED) && dwSeed1 != dwSeed2) + { + BSWAP_ARRAY32_UNSIGNED((DWORD *)pbBlock, dwBytes/sizeof(DWORD)); + DecryptMPQBlock((DWORD *)pbBlock, dwBytes, dwSeed1 + nBlock); + EncryptMPQBlock((DWORD *)pbBlock, dwBytes, dwSeed2 + nBlock); + BSWAP_ARRAY32_UNSIGNED((DWORD *)pbBlock, dwBytes/sizeof(DWORD)); + } + + // Now write the block back to the file + WriteFile(hFile, pbBlock, dwBytes, &dwTransferred, NULL); + dwCSize += dwTransferred; + if(dwTransferred != dwBytes) + { + nError = ERROR_DISK_FULL; + break; + } + } + } + + // Copy the file extras, if any + // These extras does not seem to be encrypted, and their purpose is unknown + if(nError == ERROR_SUCCESS && (pBlock->dwFlags & MPQ_FILE_HAS_EXTRA)) + { + dwBytes = pdwBlockPos[nBlocks + 1] - pdwBlockPos[nBlocks]; + if(dwBytes != 0) + { + ReadFile(ha->hFile, pbBlock, dwBytes, &dwTransferred, NULL); + if(dwTransferred == dwBytes) + { + WriteFile(hFile, pbBlock, dwBytes, &dwTransferred, NULL); + dwCSize += dwTransferred; + if(dwTransferred != dwBytes) + nError = ERROR_DISK_FULL; + } + else + { + nError = ERROR_FILE_CORRUPT; + } + } + } + + // Update file position in the block table + if(nError == ERROR_SUCCESS) + { + // At this point, number of bytes written should be exactly + // the same like the compressed file size. If it isn't, there's something wrong + // (maybe new archive version ?) + assert(dwCSize == pBlock->dwCSize); + + // Update file pos in the block table + FilePos.QuadPart -= ha->MpqPos.QuadPart; + pBlockEx->wFilePosHigh = (USHORT)FilePos.HighPart; + pBlock->dwFilePos = FilePos.LowPart; + } + + // Cleanup and return + if(pdwBlockPos2 != NULL) + FREEMEM(pdwBlockPos2); + if(pdwBlockPos != NULL) + FREEMEM(pdwBlockPos); + if(pbBlock != NULL) + FREEMEM(pbBlock); + return nError; +} + + +static int CopyNonMpqData( + HANDLE hSrcFile, + HANDLE hTrgFile, + LARGE_INTEGER & DataSizeToCopy) +{ + LARGE_INTEGER DataSize = DataSizeToCopy; + DWORD dwTransferred; + DWORD dwToRead; + char DataBuffer[0x1000]; + int nError = ERROR_SUCCESS; + + while(DataSize.QuadPart > 0) + { + // Get the proper size of data + dwToRead = sizeof(DataBuffer); + if(DataSize.HighPart == 0 && DataSize.LowPart < dwToRead) + dwToRead = DataSize.LowPart; + + // Read the source file + ReadFile(hSrcFile, DataBuffer, dwToRead, &dwTransferred, NULL); + if(dwTransferred != dwToRead) + { + nError = ERROR_CAN_NOT_COMPLETE; + break; + } + + // Write to the target file + WriteFile(hTrgFile, DataBuffer, dwToRead, &dwTransferred, NULL); + if(dwTransferred != dwToRead) + { + nError = ERROR_DISK_FULL; + break; + } + + // Decrement the number of data to be copied + DataSize.QuadPart -= dwTransferred; + } + + return ERROR_SUCCESS; +} + +// TODO: Test for archives > 4GB +static int CopyMpqFiles(HANDLE hFile, TMPQArchive * ha, DWORD * pFileSeeds) +{ + TMPQBlockEx * pBlockEx; + TMPQBlock * pBlock; + DWORD dwSeed1; + DWORD dwIndex; + int nError = ERROR_SUCCESS; + + // Walk through all files and write them to the destination MPQ archive + for(dwIndex = 0; dwIndex < ha->pHeader->dwBlockTableSize; dwIndex++) + { + pBlockEx = ha->pExtBlockTable + dwIndex; + pBlock = ha->pBlockTable + dwIndex; + dwSeed1 = pFileSeeds[dwIndex]; + + // Notify the caller about work + if(CompactCB != NULL) + CompactCB(lpUserData, CCB_COMPACTING_FILES, dwIndex, ha->pHeader->dwBlockTableSize); + +// if(dwIndex == 0x1B9) +// DebugBreak(); + + // Copy all the file blocks + // Debug: Break at (dwIndex == 5973) + if(pBlock->dwFlags & MPQ_FILE_EXISTS) + { + nError = CopyMpqFileBlocks(hFile, ha, pBlockEx, pBlock, dwSeed1); + if(nError != ERROR_SUCCESS) + break; + } + } + + // Cleanup and exit + return nError; +} + + +/*****************************************************************************/ +/* Public functions */ +/*****************************************************************************/ + +BOOL WINAPI SFileSetCompactCallback(HANDLE /* hMPQ */, COMPACTCB aCompactCB, void * lpData) +{ + CompactCB = aCompactCB; + lpUserData = lpData; + return TRUE; +} + +//----------------------------------------------------------------------------- +// Archive compacting (incomplete) + +// TODO: Test for archives > 4GB +BOOL WINAPI SFileCompactArchive(HANDLE hMPQ, const char * szListFile, BOOL /* bReserved */) +{ + TMPQArchive * ha = (TMPQArchive *)hMPQ; + HANDLE hFile = INVALID_HANDLE_VALUE; + DWORD * pFileSeeds = NULL; + char szTempFile[MAX_PATH] = ""; + char * szTemp = NULL; + DWORD dwTransferred; + int nError = ERROR_SUCCESS; + + // Test the valid parameters + if(!IsValidMpqHandle(ha)) + nError = ERROR_INVALID_PARAMETER; + + // Create the table with file seeds + if(nError == ERROR_SUCCESS) + { + if((pFileSeeds = ALLOCMEM(DWORD, ha->pHeader->dwBlockTableSize)) != NULL) + memset(pFileSeeds, 0, sizeof(DWORD) * ha->pHeader->dwBlockTableSize); + else + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // First of all, we have to check of we are able to decrypt all files. + // If not, sorry, but the archive cannot be compacted. + if(nError == ERROR_SUCCESS) + nError = CheckIfAllFilesKnown(ha, szListFile, pFileSeeds); + + // Get the temporary file name and create it + if(nError == ERROR_SUCCESS) + { + if(CompactCB != NULL) + CompactCB(lpUserData, CCB_COPYING_NON_MPQ_DATA, 0, 0); + + strcpy(szTempFile, ha->szFileName); + if((szTemp = strrchr(szTempFile, '.')) != NULL) + strcpy(szTemp + 1, "mp_"); + else + strcat(szTempFile, "_"); + + hFile = CreateFile(szTempFile, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL); + if(hFile == INVALID_HANDLE_VALUE) + nError = GetLastError(); + } + + // Write the data before MPQ header (if any) + if(nError == ERROR_SUCCESS && ha->MpqPos.QuadPart > 0) + { + SetFilePointer(ha->hFile, 0, NULL, FILE_BEGIN); + if(ha->pShunt != NULL) + nError = CopyNonMpqData(ha->hFile, hFile, ha->ShuntPos); + else + nError = CopyNonMpqData(ha->hFile, hFile, ha->MpqPos); + } + + // Write the MPQ shunt (if any) + if(nError == ERROR_SUCCESS && ha->pShunt != NULL) + { + BSWAP_TMPQSHUNT(ha->pShunt); + WriteFile(hFile, ha->pShunt, sizeof(TMPQShunt), &dwTransferred, NULL); + BSWAP_TMPQSHUNT(ha->pShunt); + + if(dwTransferred != sizeof(TMPQShunt)) + nError = ERROR_DISK_FULL; + } + + // Write the data between MPQ shunt and the MPQ header (if any) + if(nError == ERROR_SUCCESS && ha->pShunt != NULL) + { + LARGE_INTEGER BytesToCopy; + + BytesToCopy.QuadPart = ha->MpqPos.QuadPart - (ha->ShuntPos.QuadPart + sizeof(TMPQShunt)); + nError = CopyNonMpqData(ha->hFile, hFile, BytesToCopy); + } + + // Write the MPQ header + if(nError == ERROR_SUCCESS) + { + BSWAP_TMPQHEADER(ha->pHeader); + WriteFile(hFile, ha->pHeader, ha->pHeader->dwHeaderSize, &dwTransferred, NULL); + BSWAP_TMPQHEADER(ha->pHeader); + if(dwTransferred != ha->pHeader->dwHeaderSize) + nError = ERROR_DISK_FULL; + } + + // Write the data between the header and between the first file + // For this, we have to determine where the first file begins + if(nError == ERROR_SUCCESS) + { + LARGE_INTEGER FirstFilePos; + LARGE_INTEGER TempPos; + TMPQBlockEx * pBlockEx = ha->pExtBlockTable; + TMPQBlock * pBlockEnd = ha->pBlockTable + ha->pHeader->dwBlockTableSize; + TMPQBlock * pBlock = ha->pBlockTable; + + // Maximum file position + FirstFilePos.HighPart = 0x7FFFFFFF; + FirstFilePos.LowPart = 0xFFFFFFFF; + + // Find the block with the least position in the MPQ + while(pBlock < pBlockEnd) + { + TempPos.HighPart = pBlockEx->wFilePosHigh; + TempPos.LowPart = pBlock->dwFilePos; + if(TempPos.QuadPart < FirstFilePos.QuadPart) + FirstFilePos = TempPos; + + pBlockEx++; + pBlock++; + } + + // Set the position in the source file right after the file header + TempPos.QuadPart = ha->MpqPos.QuadPart + ha->pHeader->dwHeaderSize; + SetFilePointer(ha->hFile, TempPos.LowPart, &TempPos.HighPart, FILE_BEGIN); + + // Get the number of bytes to copy + FirstFilePos.QuadPart -= ha->pHeader->dwHeaderSize; + nError = CopyNonMpqData(ha->hFile, hFile, FirstFilePos); + } + + // Now write all file blocks. + if(nError == ERROR_SUCCESS) + nError = CopyMpqFiles(hFile, ha, pFileSeeds); + + // Now we need to update the tables positions + // (but only if the tables are at the end of the file) + if(nError == ERROR_SUCCESS) + { + LARGE_INTEGER RelativePos; + LARGE_INTEGER FilePos = {0}; + + // Set the hash table position + FilePos.LowPart = SetFilePointer(hFile, 0, &FilePos.HighPart, FILE_CURRENT); + RelativePos.QuadPart = FilePos.QuadPart - ha->MpqPos.QuadPart; + ha->pHeader->wHashTablePosHigh = (USHORT)RelativePos.HighPart; + ha->pHeader->dwHashTablePos = RelativePos.LowPart; + ha->HashTablePos = FilePos; + + // Set the block table position + RelativePos.QuadPart += ha->pHeader->dwHashTableSize * sizeof(TMPQHash); + FilePos.QuadPart += ha->pHeader->dwHashTableSize * sizeof(TMPQHash); + ha->pHeader->wBlockTablePosHigh = (USHORT)RelativePos.HighPart; + ha->pHeader->dwBlockTablePos = RelativePos.LowPart; + ha->BlockTablePos = FilePos; + + // Set the extended block table position + RelativePos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); + FilePos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); + if(ha->ExtBlockTablePos.QuadPart != 0) + { + ha->pHeader->ExtBlockTablePos = RelativePos; + ha->ExtBlockTablePos = FilePos; + + RelativePos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx); + FilePos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx); + } + + // Set the archive size + ha->pHeader->dwArchiveSize = RelativePos.LowPart; + ha->MpqSize = RelativePos; + } + + // If succeeded, update the tables in the file + if(nError == ERROR_SUCCESS) + { + CloseHandle(ha->hFile); + ha->FilePointer.QuadPart = 0; + ha->hFile = hFile; + hFile = INVALID_HANDLE_VALUE; + nError = SaveMPQTables(ha); + } + + // If all succeeded, switch the archives + if(nError == ERROR_SUCCESS) + { + if(CompactCB != NULL) + CompactCB(lpUserData, CCB_CLOSING_ARCHIVE, 0, 0); + + if(!DeleteFile(ha->szFileName) || // Delete the old archive + !CloseHandle(ha->hFile) || // Close the new archive + !MoveFile(szTempFile, ha->szFileName)) // Rename the temporary archive + nError = GetLastError(); + } + + // Now open the freshly renamed archive file + if(nError == ERROR_SUCCESS) + { + ha->hFile = CreateFile(ha->szFileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + if(ha->hFile == INVALID_HANDLE_VALUE) + nError = GetLastError(); + } + + // Invalidate the positions of the archive + if(nError == ERROR_SUCCESS) + { + ha->FilePointer.QuadPart = 0; + ha->pLastFile = NULL; + ha->dwBlockPos = 0; + ha->dwBuffPos = 0; + } + + // Cleanup and return + if(hFile != INVALID_HANDLE_VALUE) + CloseHandle(hFile); + if(pFileSeeds != NULL) + FREEMEM(pFileSeeds); + if(nError != ERROR_SUCCESS) + SetLastError(nError); + DeleteFile(szTempFile); + CompactCB = NULL; + return (nError == ERROR_SUCCESS); +} diff --git a/src/tools/stuffextract/StormLib/SFileCreateArchiveEx.cpp b/src/tools/stuffextract/StormLib/SFileCreateArchiveEx.cpp index f99888d..2410920 100644 --- a/src/tools/stuffextract/StormLib/SFileCreateArchiveEx.cpp +++ b/src/tools/stuffextract/StormLib/SFileCreateArchiveEx.cpp @@ -1,530 +1,530 @@ -/*****************************************************************************/ -/* SFileCreateArchiveEx.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* MPQ Editing functions */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 24.03.03 1.00 Lad Splitted from SFileOpenArchive.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -//----------------------------------------------------------------------------- -// Defines - -#define DEFAULT_BLOCK_SIZE 3 // Default size of the block - -//----------------------------------------------------------------------------- -// Local tables - -static DWORD PowersOfTwo[] = -{ - 0x0000002, 0x0000004, 0x0000008, - 0x0000010, 0x0000020, 0x0000040, 0x0000080, - 0x0000100, 0x0000200, 0x0000400, 0x0000800, - 0x0001000, 0x0002000, 0x0004000, 0x0008000, - 0x0010000, 0x0020000, 0x0040000, 0x0080000, - 0x0000000 -}; - -/*****************************************************************************/ -/* Public functions */ -/*****************************************************************************/ - -//----------------------------------------------------------------------------- -// Opens or creates a (new) MPQ archive. -// -// szMpqName - Name of the archive to be created. -// -// dwCreationDisposition: -// -// Value Archive exists Archive doesn't exist -// ---------- --------------------- --------------------- -// CREATE_NEW Fails Creates new archive -// CREATE_ALWAYS Overwrites existing Creates new archive -// OPEN_EXISTING Opens the archive Fails -// OPEN_ALWAYS Opens the archive Creates new archive -// -// The above mentioned values can be combined with the following flags: -// -// MPQ_CREATE_ARCHIVE_V1 - Creates MPQ archive version 1 -// MPQ_CREATE_ARCHIVE_V2 - Creates MPQ archive version 2 -// -// dwHashTableSize - Size of the hash table (only if creating a new archive). -// Must be between 2^4 (= 16) and 2^18 (= 262 144) -// -// phMpq - Receives handle to the archive -// - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileCreateArchiveEx(const char * szMpqName, DWORD dwCreationDisposition, DWORD dwHashTableSize, HANDLE * phMPQ) -{ - LARGE_INTEGER MpqPos = {0}; // Position of MPQ header in the file - TMPQArchive * ha = NULL; // MPQ archive handle - HANDLE hFile = INVALID_HANDLE_VALUE; // File handle - DWORD dwTransferred = 0; // Number of bytes written into the archive - USHORT wFormatVersion; - BOOL bFileExists = FALSE; - int nIndex = 0; - int nError = ERROR_SUCCESS; - - // Pre-initialize the result value - if(phMPQ != NULL) - *phMPQ = NULL; - - // Check the parameters, if they are valid - if(szMpqName == NULL || *szMpqName == 0 || phMPQ == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - // Check the value of dwCreationDisposition against file existence - bFileExists = (GetFileAttributes(szMpqName) != 0xFFFFFFFF); - - // Extract format version from the "dwCreationDisposition" - wFormatVersion = (USHORT)(dwCreationDisposition >> 0x10); - dwCreationDisposition &= 0x0000FFFF; - - // If the file exists and open required, do it. - if(bFileExists && (dwCreationDisposition == OPEN_EXISTING || dwCreationDisposition == OPEN_ALWAYS)) - { - // Try to open the archive normal way. If it fails, it means that - // the file exist, but it is not a MPQ archive. - if(SFileOpenArchiveEx(szMpqName, 0, 0, phMPQ, GENERIC_READ | GENERIC_WRITE)) - return TRUE; - } - - // Two error cases - if(dwCreationDisposition == CREATE_NEW && bFileExists) - { - SetLastError(ERROR_ALREADY_EXISTS); - return FALSE; - } - if(dwCreationDisposition == OPEN_EXISTING && bFileExists == FALSE) - { - SetLastError(ERROR_FILE_NOT_FOUND); - return FALSE; - } - - // At this point, we have to create the archive. If the file exists, - // we will convert it to MPQ archive. - // Check the value of hash table size. It has to be a power of two - // and must be between HASH_TABLE_SIZE_MIN and HASH_TABLE_SIZE_MAX - if(dwHashTableSize < HASH_TABLE_SIZE_MIN) - dwHashTableSize = HASH_TABLE_SIZE_MIN; - if(dwHashTableSize > HASH_TABLE_SIZE_MAX) - dwHashTableSize = HASH_TABLE_SIZE_MAX; - - // Round the hash table size up to the nearest power of two - for(nIndex = 0; PowersOfTwo[nIndex] != 0; nIndex++) - { - if(dwHashTableSize <= PowersOfTwo[nIndex]) - { - dwHashTableSize = PowersOfTwo[nIndex]; - break; - } - } - - // Prepare the buffer for decryption engine - if(nError == ERROR_SUCCESS) - nError = PrepareStormBuffer(); - - // Get the position where the MPQ header will begin. - if(nError == ERROR_SUCCESS) - { - hFile = CreateFile(szMpqName, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ, - NULL, - dwCreationDisposition, - 0, - NULL); - if(hFile == INVALID_HANDLE_VALUE) - nError = GetLastError(); - } - - // Retrieve the file size and round it up to 0x200 bytes - if(nError == ERROR_SUCCESS) - { - MpqPos.LowPart = GetFileSize(hFile, (LPDWORD)&MpqPos.HighPart); - MpqPos.QuadPart += 0x1FF; - MpqPos.LowPart &= 0xFFFFFE00; - - if(wFormatVersion == MPQ_FORMAT_VERSION_1 && MpqPos.HighPart != 0) - nError = ERROR_DISK_FULL; - if(wFormatVersion == MPQ_FORMAT_VERSION_2 && MpqPos.HighPart > 0x0000FFFF) - nError = ERROR_DISK_FULL; - } - - // Move to the end of the file (i.e. begin of the MPQ) - if(nError == ERROR_SUCCESS) - { - if(SetFilePointer(hFile, MpqPos.LowPart, &MpqPos.HighPart, FILE_BEGIN) == 0xFFFFFFFF) - nError = GetLastError(); - } - - // Set the new end of the file to the MPQ header position - if(nError == ERROR_SUCCESS) - { - if(!SetEndOfFile(hFile)) - nError = GetLastError(); - } - - // Create the archive handle - if(nError == ERROR_SUCCESS) - { - if((ha = ALLOCMEM(TMPQArchive, 1)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Fill the MPQ archive handle structure and create the header, - // block buffer, hash table and block table - if(nError == ERROR_SUCCESS) - { - memset(ha, 0, sizeof(TMPQArchive)); - strcpy(ha->szFileName, szMpqName); - ha->hFile = hFile; - ha->dwBlockSize = 0x200 << DEFAULT_BLOCK_SIZE; - ha->MpqPos = MpqPos; - ha->FilePointer = MpqPos; - ha->pHeader = &ha->Header; - ha->pHashTable = ALLOCMEM(TMPQHash, dwHashTableSize); - ha->pBlockTable = ALLOCMEM(TMPQBlock, dwHashTableSize); - ha->pExtBlockTable = ALLOCMEM(TMPQBlockEx, dwHashTableSize); - ha->pbBlockBuffer = ALLOCMEM(BYTE, ha->dwBlockSize); - ha->pListFile = NULL; - ha->dwFlags |= MPQ_FLAG_CHANGED; - - if(!ha->pHashTable || !ha->pBlockTable || !ha->pExtBlockTable || !ha->pbBlockBuffer) - nError = GetLastError(); - hFile = INVALID_HANDLE_VALUE; - } - - // Fill the MPQ header and all buffers - if(nError == ERROR_SUCCESS) - { - LARGE_INTEGER TempPos; - TMPQHeader2 * pHeader = ha->pHeader; - DWORD dwHeaderSize = (wFormatVersion == MPQ_FORMAT_VERSION_2) ? sizeof(TMPQHeader2) : sizeof(TMPQHeader); - - memset(pHeader, 0, sizeof(TMPQHeader2)); - pHeader->dwID = ID_MPQ; - pHeader->dwHeaderSize = dwHeaderSize; - pHeader->dwArchiveSize = pHeader->dwHeaderSize + dwHashTableSize * sizeof(TMPQHash); - pHeader->wFormatVersion = wFormatVersion; - pHeader->wBlockSize = 3; // 0x1000 bytes per block - pHeader->dwHashTableSize = dwHashTableSize; - - // Set proper hash table positions - ha->HashTablePos.QuadPart = ha->MpqPos.QuadPart + pHeader->dwHeaderSize; - ha->pHeader->dwHashTablePos = pHeader->dwHeaderSize; - ha->pHeader->wHashTablePosHigh = 0; - - // Set proper block table positions - ha->BlockTablePos.QuadPart = ha->HashTablePos.QuadPart + - (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)); - TempPos.QuadPart = ha->BlockTablePos.QuadPart - ha->MpqPos.QuadPart; - ha->pHeader->dwBlockTablePos = TempPos.LowPart; - ha->pHeader->wBlockTablePosHigh = (USHORT)TempPos.HighPart; - - // For now, we set extended block table positioon top zero unless we add enough - // files to cause the archive size exceed 4 GB - ha->ExtBlockTablePos.QuadPart = 0; - - // Clear all tables - memset(ha->pBlockTable, 0, sizeof(TMPQBlock) * dwHashTableSize); - memset(ha->pExtBlockTable, 0, sizeof(TMPQBlockEx) * dwHashTableSize); - memset(ha->pHashTable, 0xFF, sizeof(TMPQHash) * dwHashTableSize); - } - - // Write the MPQ header to the file - if(nError == ERROR_SUCCESS) - { - DWORD dwHeaderSize = ha->pHeader->dwHeaderSize; - - BSWAP_TMPQHEADER(ha->pHeader); - WriteFile(ha->hFile, ha->pHeader, dwHeaderSize, &dwTransferred, NULL); - BSWAP_TMPQHEADER(ha->pHeader); - - if(dwTransferred != ha->pHeader->dwHeaderSize) - nError = ERROR_DISK_FULL; - - ha->FilePointer.QuadPart = ha->MpqPos.QuadPart + dwTransferred; - ha->MpqSize.QuadPart += dwTransferred; - } - - // Create the internal listfile - if(nError == ERROR_SUCCESS) - nError = SListFileCreateListFile(ha); - - // Try to add the internal listfile - if(nError == ERROR_SUCCESS) - SFileAddListFile((HANDLE)ha, NULL); - - // Cleanup : If an error, delete all buffers and return - if(nError != ERROR_SUCCESS) - { - FreeMPQArchive(ha); - if(hFile != INVALID_HANDLE_VALUE) - CloseHandle(hFile); - SetLastError(nError); - } - - // Return the values - *phMPQ = (HANDLE)ha; - return (nError == ERROR_SUCCESS); -} - -//----------------------------------------------------------------------------- -// Changes locale ID of a file - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale) -{ - TMPQFile * hf = (TMPQFile *)hFile; - - // Invalid handle => do nothing - if(IsValidFileHandle(hf) == FALSE || IsValidMpqHandle(hf->ha) == FALSE) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - // If the file has not been open for writing, do nothing. - if(hf->ha->pListFile == NULL) - return ERROR_ACCESS_DENIED; - - hf->pHash->lcLocale = (USHORT)lcNewLocale; - hf->ha->dwFlags |= MPQ_FLAG_CHANGED; - return TRUE; -} - -//----------------------------------------------------------------------------- -// Adds a file into the archive - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileAddFileEx(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality, int nFileType) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - HANDLE hFile = INVALID_HANDLE_VALUE; - BOOL bReplaced = FALSE; // TRUE if replacing file in the archive - int nError = ERROR_SUCCESS; - - if(nError == ERROR_SUCCESS) - { - // Check valid parameters - if(IsValidMpqHandle(ha) == FALSE || szFileName == NULL || *szFileName == 0 || szArchivedName == NULL || *szArchivedName == 0) - nError = ERROR_INVALID_PARAMETER; - - // Check the values of dwFlags - if((dwFlags & MPQ_FILE_COMPRESS_PKWARE) && (dwFlags & MPQ_FILE_COMPRESS_MULTI)) - nError = ERROR_INVALID_PARAMETER; - } - - // If anyone is trying to add listfile, and the archive already has a listfile, - // deny the operation, but return success. - if(nError == ERROR_SUCCESS) - { - if(ha->pListFile != NULL && !_stricmp(szFileName, LISTFILE_NAME)) - return ERROR_SUCCESS; - } - - // Open added file - if(nError == ERROR_SUCCESS) - { - hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, NULL); - if(hFile == INVALID_HANDLE_VALUE) - nError = GetLastError(); - } - - if(nError == ERROR_SUCCESS) - nError = AddFileToArchive(ha, hFile, szArchivedName, dwFlags, dwQuality, nFileType, &bReplaced); - - // Add the file into listfile also - if(nError == ERROR_SUCCESS && bReplaced == FALSE) - nError = SListFileAddNode(ha, szArchivedName); - - // Cleanup and exit - if(hFile != INVALID_HANDLE_VALUE) - CloseHandle(hFile); - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -// Adds a data file into the archive -// TODO: Test for archives > 4GB -BOOL WINAPI SFileAddFile(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags) -{ - return SFileAddFileEx(hMPQ, szFileName, szArchivedName, dwFlags, 0, SFILE_TYPE_DATA); -} - -// Adds a WAVE file into the archive -// TODO: Test for archives > 4GB -BOOL WINAPI SFileAddWave(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality) -{ - return SFileAddFileEx(hMPQ, szFileName, szArchivedName, dwFlags, dwQuality, SFILE_TYPE_WAVE); -} - -//----------------------------------------------------------------------------- -// BOOL SFileRemoveFile(HANDLE hMPQ, char * szFileName) -// -// This function removes a file from the archive. The file content -// remains there, only the entries in the hash table and in the block -// table are updated. - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileRemoveFile(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - TMPQBlockEx * pBlockEx = NULL; // Block entry of deleted file - TMPQBlock * pBlock = NULL; // Block entry of deleted file - TMPQHash * pHash = NULL; // Hash entry of deleted file - DWORD dwBlockIndex = 0; - int nError = ERROR_SUCCESS; - - // Check the parameters - if(nError == ERROR_SUCCESS) - { - if(IsValidMpqHandle(ha) == FALSE) - nError = ERROR_INVALID_PARAMETER; - if(dwSearchScope != SFILE_OPEN_BY_INDEX && *szFileName == 0) - nError = ERROR_INVALID_PARAMETER; - } - - // Do not allow to remove listfile - if(nError == ERROR_SUCCESS) - { - if(dwSearchScope != SFILE_OPEN_BY_INDEX && !_stricmp(szFileName, LISTFILE_NAME)) - nError = ERROR_ACCESS_DENIED; - } - - // Get hash entry belonging to this file - if(nError == ERROR_SUCCESS) - { - if((pHash = GetHashEntryEx(ha, (char *)szFileName, lcLocale)) == NULL) - nError = ERROR_FILE_NOT_FOUND; - } - - // If index was not found, or is greater than number of files, exit. - if(nError == ERROR_SUCCESS) - { - if((dwBlockIndex = pHash->dwBlockIndex) > ha->pHeader->dwBlockTableSize) - nError = ERROR_FILE_NOT_FOUND; - } - - // Get block and test if the file is not already deleted - if(nError == ERROR_SUCCESS) - { - pBlockEx = ha->pExtBlockTable + dwBlockIndex; - pBlock = ha->pBlockTable + dwBlockIndex; - if((pBlock->dwFlags & MPQ_FILE_EXISTS) == 0) - nError = ERROR_FILE_NOT_FOUND; - } - - // Now invalidate the block entry and the hash entry. Do not make any - // relocations and file copying, use SFileCompactArchive for it. - if(nError == ERROR_SUCCESS) - { - pBlockEx->wFilePosHigh = 0; - pBlock->dwFilePos = 0; - pBlock->dwFSize = 0; - pBlock->dwCSize = 0; - pBlock->dwFlags = 0; - pHash->dwName1 = 0xFFFFFFFF; - pHash->dwName2 = 0xFFFFFFFF; - pHash->lcLocale = 0xFFFF; - pHash->wPlatform = 0xFFFF; - pHash->dwBlockIndex = HASH_ENTRY_DELETED; - - // Update MPQ archive - ha->dwFlags |= MPQ_FLAG_CHANGED; - } - - // Remove the file from the list file - if(nError == ERROR_SUCCESS && lcLocale == LANG_NEUTRAL) - nError = SListFileRemoveNode(ha, szFileName); - - // Resolve error and exit - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -// Renames the file within the archive. -// TODO: Test for archives > 4GB -BOOL WINAPI SFileRenameFile(HANDLE hMPQ, const char * szFileName, const char * szNewFileName) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - TMPQHash * pOldHash = NULL; // Hash entry for the original file - TMPQHash * pNewHash = NULL; // Hash entry for the renamed file - DWORD dwBlockIndex = 0; - int nError = ERROR_SUCCESS; - - // Test the valid parameters - if(nError == ERROR_SUCCESS) - { - if(hMPQ == NULL || szNewFileName == NULL || *szNewFileName == 0) - nError = ERROR_INVALID_PARAMETER; - if(szFileName == NULL || *szFileName == 0) - nError = ERROR_INVALID_PARAMETER; - } - - // Do not allow to rename listfile - if(nError == ERROR_SUCCESS) - { - if(!_stricmp(szFileName, LISTFILE_NAME)) - nError = ERROR_ACCESS_DENIED; - } - - // Test if the file already exists in the archive - if(nError == ERROR_SUCCESS) - { - if((pNewHash = GetHashEntryEx(ha, szNewFileName, lcLocale)) != NULL) - nError = ERROR_ALREADY_EXISTS; - } - - // Get the hash table entry for the original file - if(nError == ERROR_SUCCESS) - { - if((pOldHash = GetHashEntryEx(ha, szFileName, lcLocale)) == NULL) - nError = ERROR_FILE_NOT_FOUND; - } - - // Get the hash table entry for the renamed file - if(nError == ERROR_SUCCESS) - { - // Save block table index and remove the hash table entry - dwBlockIndex = pOldHash->dwBlockIndex; - pOldHash->dwName1 = 0xFFFFFFFF; - pOldHash->dwName2 = 0xFFFFFFFF; - pOldHash->lcLocale = 0xFFFF; - pOldHash->wPlatform = 0xFFFF; - pOldHash->dwBlockIndex = HASH_ENTRY_DELETED; - - if((pNewHash = FindFreeHashEntry(ha, szNewFileName)) == NULL) - nError = ERROR_CAN_NOT_COMPLETE; - } - - // Save the block index and clear the hash entry - if(nError == ERROR_SUCCESS) - { - // Copy the block table index - pNewHash->dwBlockIndex = dwBlockIndex; - ha->dwFlags |= MPQ_FLAG_CHANGED; - } - - // Rename the file in the list file - if(nError == ERROR_SUCCESS) - nError = SListFileRenameNode(ha, szFileName, szNewFileName); - - // Resolve error and return - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - +/*****************************************************************************/ +/* SFileCreateArchiveEx.cpp Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* MPQ Editing functions */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 24.03.03 1.00 Lad Splitted from SFileOpenArchive.cpp */ +/*****************************************************************************/ + +#define __STORMLIB_SELF__ +#include "StormLib.h" +#include "SCommon.h" + +//----------------------------------------------------------------------------- +// Defines + +#define DEFAULT_BLOCK_SIZE 3 // Default size of the block + +//----------------------------------------------------------------------------- +// Local tables + +static DWORD PowersOfTwo[] = +{ + 0x0000002, 0x0000004, 0x0000008, + 0x0000010, 0x0000020, 0x0000040, 0x0000080, + 0x0000100, 0x0000200, 0x0000400, 0x0000800, + 0x0001000, 0x0002000, 0x0004000, 0x0008000, + 0x0010000, 0x0020000, 0x0040000, 0x0080000, + 0x0000000 +}; + +/*****************************************************************************/ +/* Public functions */ +/*****************************************************************************/ + +//----------------------------------------------------------------------------- +// Opens or creates a (new) MPQ archive. +// +// szMpqName - Name of the archive to be created. +// +// dwCreationDisposition: +// +// Value Archive exists Archive doesn't exist +// ---------- --------------------- --------------------- +// CREATE_NEW Fails Creates new archive +// CREATE_ALWAYS Overwrites existing Creates new archive +// OPEN_EXISTING Opens the archive Fails +// OPEN_ALWAYS Opens the archive Creates new archive +// +// The above mentioned values can be combined with the following flags: +// +// MPQ_CREATE_ARCHIVE_V1 - Creates MPQ archive version 1 +// MPQ_CREATE_ARCHIVE_V2 - Creates MPQ archive version 2 +// +// dwHashTableSize - Size of the hash table (only if creating a new archive). +// Must be between 2^4 (= 16) and 2^18 (= 262 144) +// +// phMpq - Receives handle to the archive +// + +// TODO: Test for archives > 4GB +BOOL WINAPI SFileCreateArchiveEx(const char * szMpqName, DWORD dwCreationDisposition, DWORD dwHashTableSize, HANDLE * phMPQ) +{ + LARGE_INTEGER MpqPos = {0}; // Position of MPQ header in the file + TMPQArchive * ha = NULL; // MPQ archive handle + HANDLE hFile = INVALID_HANDLE_VALUE; // File handle + DWORD dwTransferred = 0; // Number of bytes written into the archive + USHORT wFormatVersion; + BOOL bFileExists = FALSE; + int nIndex = 0; + int nError = ERROR_SUCCESS; + + // Pre-initialize the result value + if(phMPQ != NULL) + *phMPQ = NULL; + + // Check the parameters, if they are valid + if(szMpqName == NULL || *szMpqName == 0 || phMPQ == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + // Check the value of dwCreationDisposition against file existence + bFileExists = (GetFileAttributes(szMpqName) != 0xFFFFFFFF); + + // Extract format version from the "dwCreationDisposition" + wFormatVersion = (USHORT)(dwCreationDisposition >> 0x10); + dwCreationDisposition &= 0x0000FFFF; + + // If the file exists and open required, do it. + if(bFileExists && (dwCreationDisposition == OPEN_EXISTING || dwCreationDisposition == OPEN_ALWAYS)) + { + // Try to open the archive normal way. If it fails, it means that + // the file exist, but it is not a MPQ archive. + if(SFileOpenArchiveEx(szMpqName, 0, 0, phMPQ, GENERIC_READ | GENERIC_WRITE)) + return TRUE; + } + + // Two error cases + if(dwCreationDisposition == CREATE_NEW && bFileExists) + { + SetLastError(ERROR_ALREADY_EXISTS); + return FALSE; + } + if(dwCreationDisposition == OPEN_EXISTING && bFileExists == FALSE) + { + SetLastError(ERROR_FILE_NOT_FOUND); + return FALSE; + } + + // At this point, we have to create the archive. If the file exists, + // we will convert it to MPQ archive. + // Check the value of hash table size. It has to be a power of two + // and must be between HASH_TABLE_SIZE_MIN and HASH_TABLE_SIZE_MAX + if(dwHashTableSize < HASH_TABLE_SIZE_MIN) + dwHashTableSize = HASH_TABLE_SIZE_MIN; + if(dwHashTableSize > HASH_TABLE_SIZE_MAX) + dwHashTableSize = HASH_TABLE_SIZE_MAX; + + // Round the hash table size up to the nearest power of two + for(nIndex = 0; PowersOfTwo[nIndex] != 0; nIndex++) + { + if(dwHashTableSize <= PowersOfTwo[nIndex]) + { + dwHashTableSize = PowersOfTwo[nIndex]; + break; + } + } + + // Prepare the buffer for decryption engine + if(nError == ERROR_SUCCESS) + nError = PrepareStormBuffer(); + + // Get the position where the MPQ header will begin. + if(nError == ERROR_SUCCESS) + { + hFile = CreateFile(szMpqName, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ, + NULL, + dwCreationDisposition, + 0, + NULL); + if(hFile == INVALID_HANDLE_VALUE) + nError = GetLastError(); + } + + // Retrieve the file size and round it up to 0x200 bytes + if(nError == ERROR_SUCCESS) + { + MpqPos.LowPart = GetFileSize(hFile, (LPDWORD)&MpqPos.HighPart); + MpqPos.QuadPart += 0x1FF; + MpqPos.LowPart &= 0xFFFFFE00; + + if(wFormatVersion == MPQ_FORMAT_VERSION_1 && MpqPos.HighPart != 0) + nError = ERROR_DISK_FULL; + if(wFormatVersion == MPQ_FORMAT_VERSION_2 && MpqPos.HighPart > 0x0000FFFF) + nError = ERROR_DISK_FULL; + } + + // Move to the end of the file (i.e. begin of the MPQ) + if(nError == ERROR_SUCCESS) + { + if(SetFilePointer(hFile, MpqPos.LowPart, &MpqPos.HighPart, FILE_BEGIN) == 0xFFFFFFFF) + nError = GetLastError(); + } + + // Set the new end of the file to the MPQ header position + if(nError == ERROR_SUCCESS) + { + if(!SetEndOfFile(hFile)) + nError = GetLastError(); + } + + // Create the archive handle + if(nError == ERROR_SUCCESS) + { + if((ha = ALLOCMEM(TMPQArchive, 1)) == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Fill the MPQ archive handle structure and create the header, + // block buffer, hash table and block table + if(nError == ERROR_SUCCESS) + { + memset(ha, 0, sizeof(TMPQArchive)); + strcpy(ha->szFileName, szMpqName); + ha->hFile = hFile; + ha->dwBlockSize = 0x200 << DEFAULT_BLOCK_SIZE; + ha->MpqPos = MpqPos; + ha->FilePointer = MpqPos; + ha->pHeader = &ha->Header; + ha->pHashTable = ALLOCMEM(TMPQHash, dwHashTableSize); + ha->pBlockTable = ALLOCMEM(TMPQBlock, dwHashTableSize); + ha->pExtBlockTable = ALLOCMEM(TMPQBlockEx, dwHashTableSize); + ha->pbBlockBuffer = ALLOCMEM(BYTE, ha->dwBlockSize); + ha->pListFile = NULL; + ha->dwFlags |= MPQ_FLAG_CHANGED; + + if(!ha->pHashTable || !ha->pBlockTable || !ha->pExtBlockTable || !ha->pbBlockBuffer) + nError = GetLastError(); + hFile = INVALID_HANDLE_VALUE; + } + + // Fill the MPQ header and all buffers + if(nError == ERROR_SUCCESS) + { + LARGE_INTEGER TempPos; + TMPQHeader2 * pHeader = ha->pHeader; + DWORD dwHeaderSize = (wFormatVersion == MPQ_FORMAT_VERSION_2) ? sizeof(TMPQHeader2) : sizeof(TMPQHeader); + + memset(pHeader, 0, sizeof(TMPQHeader2)); + pHeader->dwID = ID_MPQ; + pHeader->dwHeaderSize = dwHeaderSize; + pHeader->dwArchiveSize = pHeader->dwHeaderSize + dwHashTableSize * sizeof(TMPQHash); + pHeader->wFormatVersion = wFormatVersion; + pHeader->wBlockSize = 3; // 0x1000 bytes per block + pHeader->dwHashTableSize = dwHashTableSize; + + // Set proper hash table positions + ha->HashTablePos.QuadPart = ha->MpqPos.QuadPart + pHeader->dwHeaderSize; + ha->pHeader->dwHashTablePos = pHeader->dwHeaderSize; + ha->pHeader->wHashTablePosHigh = 0; + + // Set proper block table positions + ha->BlockTablePos.QuadPart = ha->HashTablePos.QuadPart + + (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)); + TempPos.QuadPart = ha->BlockTablePos.QuadPart - ha->MpqPos.QuadPart; + ha->pHeader->dwBlockTablePos = TempPos.LowPart; + ha->pHeader->wBlockTablePosHigh = (USHORT)TempPos.HighPart; + + // For now, we set extended block table positioon top zero unless we add enough + // files to cause the archive size exceed 4 GB + ha->ExtBlockTablePos.QuadPart = 0; + + // Clear all tables + memset(ha->pBlockTable, 0, sizeof(TMPQBlock) * dwHashTableSize); + memset(ha->pExtBlockTable, 0, sizeof(TMPQBlockEx) * dwHashTableSize); + memset(ha->pHashTable, 0xFF, sizeof(TMPQHash) * dwHashTableSize); + } + + // Write the MPQ header to the file + if(nError == ERROR_SUCCESS) + { + DWORD dwHeaderSize = ha->pHeader->dwHeaderSize; + + BSWAP_TMPQHEADER(ha->pHeader); + WriteFile(ha->hFile, ha->pHeader, dwHeaderSize, &dwTransferred, NULL); + BSWAP_TMPQHEADER(ha->pHeader); + + if(dwTransferred != ha->pHeader->dwHeaderSize) + nError = ERROR_DISK_FULL; + + ha->FilePointer.QuadPart = ha->MpqPos.QuadPart + dwTransferred; + ha->MpqSize.QuadPart += dwTransferred; + } + + // Create the internal listfile + if(nError == ERROR_SUCCESS) + nError = SListFileCreateListFile(ha); + + // Try to add the internal listfile + if(nError == ERROR_SUCCESS) + SFileAddListFile((HANDLE)ha, NULL); + + // Cleanup : If an error, delete all buffers and return + if(nError != ERROR_SUCCESS) + { + FreeMPQArchive(ha); + if(hFile != INVALID_HANDLE_VALUE) + CloseHandle(hFile); + SetLastError(nError); + } + + // Return the values + *phMPQ = (HANDLE)ha; + return (nError == ERROR_SUCCESS); +} + +//----------------------------------------------------------------------------- +// Changes locale ID of a file + +// TODO: Test for archives > 4GB +BOOL WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale) +{ + TMPQFile * hf = (TMPQFile *)hFile; + + // Invalid handle => do nothing + if(IsValidFileHandle(hf) == FALSE || IsValidMpqHandle(hf->ha) == FALSE) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + // If the file has not been open for writing, do nothing. + if(hf->ha->pListFile == NULL) + return ERROR_ACCESS_DENIED; + + hf->pHash->lcLocale = (USHORT)lcNewLocale; + hf->ha->dwFlags |= MPQ_FLAG_CHANGED; + return TRUE; +} + +//----------------------------------------------------------------------------- +// Adds a file into the archive + +// TODO: Test for archives > 4GB +BOOL WINAPI SFileAddFileEx(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality, int nFileType) +{ + TMPQArchive * ha = (TMPQArchive *)hMPQ; + HANDLE hFile = INVALID_HANDLE_VALUE; + BOOL bReplaced = FALSE; // TRUE if replacing file in the archive + int nError = ERROR_SUCCESS; + + if(nError == ERROR_SUCCESS) + { + // Check valid parameters + if(IsValidMpqHandle(ha) == FALSE || szFileName == NULL || *szFileName == 0 || szArchivedName == NULL || *szArchivedName == 0) + nError = ERROR_INVALID_PARAMETER; + + // Check the values of dwFlags + if((dwFlags & MPQ_FILE_COMPRESS_PKWARE) && (dwFlags & MPQ_FILE_COMPRESS_MULTI)) + nError = ERROR_INVALID_PARAMETER; + } + + // If anyone is trying to add listfile, and the archive already has a listfile, + // deny the operation, but return success. + if(nError == ERROR_SUCCESS) + { + if(ha->pListFile != NULL && !_stricmp(szFileName, LISTFILE_NAME)) + return ERROR_SUCCESS; + } + + // Open added file + if(nError == ERROR_SUCCESS) + { + hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, NULL); + if(hFile == INVALID_HANDLE_VALUE) + nError = GetLastError(); + } + + if(nError == ERROR_SUCCESS) + nError = AddFileToArchive(ha, hFile, szArchivedName, dwFlags, dwQuality, nFileType, &bReplaced); + + // Add the file into listfile also + if(nError == ERROR_SUCCESS && bReplaced == FALSE) + nError = SListFileAddNode(ha, szArchivedName); + + // Cleanup and exit + if(hFile != INVALID_HANDLE_VALUE) + CloseHandle(hFile); + if(nError != ERROR_SUCCESS) + SetLastError(nError); + return (nError == ERROR_SUCCESS); +} + +// Adds a data file into the archive +// TODO: Test for archives > 4GB +BOOL WINAPI SFileAddFile(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags) +{ + return SFileAddFileEx(hMPQ, szFileName, szArchivedName, dwFlags, 0, SFILE_TYPE_DATA); +} + +// Adds a WAVE file into the archive +// TODO: Test for archives > 4GB +BOOL WINAPI SFileAddWave(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality) +{ + return SFileAddFileEx(hMPQ, szFileName, szArchivedName, dwFlags, dwQuality, SFILE_TYPE_WAVE); +} + +//----------------------------------------------------------------------------- +// BOOL SFileRemoveFile(HANDLE hMPQ, char * szFileName) +// +// This function removes a file from the archive. The file content +// remains there, only the entries in the hash table and in the block +// table are updated. + +// TODO: Test for archives > 4GB +BOOL WINAPI SFileRemoveFile(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope) +{ + TMPQArchive * ha = (TMPQArchive *)hMPQ; + TMPQBlockEx * pBlockEx = NULL; // Block entry of deleted file + TMPQBlock * pBlock = NULL; // Block entry of deleted file + TMPQHash * pHash = NULL; // Hash entry of deleted file + DWORD dwBlockIndex = 0; + int nError = ERROR_SUCCESS; + + // Check the parameters + if(nError == ERROR_SUCCESS) + { + if(IsValidMpqHandle(ha) == FALSE) + nError = ERROR_INVALID_PARAMETER; + if(dwSearchScope != SFILE_OPEN_BY_INDEX && *szFileName == 0) + nError = ERROR_INVALID_PARAMETER; + } + + // Do not allow to remove listfile + if(nError == ERROR_SUCCESS) + { + if(dwSearchScope != SFILE_OPEN_BY_INDEX && !_stricmp(szFileName, LISTFILE_NAME)) + nError = ERROR_ACCESS_DENIED; + } + + // Get hash entry belonging to this file + if(nError == ERROR_SUCCESS) + { + if((pHash = GetHashEntryEx(ha, (char *)szFileName, lcLocale)) == NULL) + nError = ERROR_FILE_NOT_FOUND; + } + + // If index was not found, or is greater than number of files, exit. + if(nError == ERROR_SUCCESS) + { + if((dwBlockIndex = pHash->dwBlockIndex) > ha->pHeader->dwBlockTableSize) + nError = ERROR_FILE_NOT_FOUND; + } + + // Get block and test if the file is not already deleted + if(nError == ERROR_SUCCESS) + { + pBlockEx = ha->pExtBlockTable + dwBlockIndex; + pBlock = ha->pBlockTable + dwBlockIndex; + if((pBlock->dwFlags & MPQ_FILE_EXISTS) == 0) + nError = ERROR_FILE_NOT_FOUND; + } + + // Now invalidate the block entry and the hash entry. Do not make any + // relocations and file copying, use SFileCompactArchive for it. + if(nError == ERROR_SUCCESS) + { + pBlockEx->wFilePosHigh = 0; + pBlock->dwFilePos = 0; + pBlock->dwFSize = 0; + pBlock->dwCSize = 0; + pBlock->dwFlags = 0; + pHash->dwName1 = 0xFFFFFFFF; + pHash->dwName2 = 0xFFFFFFFF; + pHash->lcLocale = 0xFFFF; + pHash->wPlatform = 0xFFFF; + pHash->dwBlockIndex = HASH_ENTRY_DELETED; + + // Update MPQ archive + ha->dwFlags |= MPQ_FLAG_CHANGED; + } + + // Remove the file from the list file + if(nError == ERROR_SUCCESS && lcLocale == LANG_NEUTRAL) + nError = SListFileRemoveNode(ha, szFileName); + + // Resolve error and exit + if(nError != ERROR_SUCCESS) + SetLastError(nError); + return (nError == ERROR_SUCCESS); +} + +// Renames the file within the archive. +// TODO: Test for archives > 4GB +BOOL WINAPI SFileRenameFile(HANDLE hMPQ, const char * szFileName, const char * szNewFileName) +{ + TMPQArchive * ha = (TMPQArchive *)hMPQ; + TMPQHash * pOldHash = NULL; // Hash entry for the original file + TMPQHash * pNewHash = NULL; // Hash entry for the renamed file + DWORD dwBlockIndex = 0; + int nError = ERROR_SUCCESS; + + // Test the valid parameters + if(nError == ERROR_SUCCESS) + { + if(hMPQ == NULL || szNewFileName == NULL || *szNewFileName == 0) + nError = ERROR_INVALID_PARAMETER; + if(szFileName == NULL || *szFileName == 0) + nError = ERROR_INVALID_PARAMETER; + } + + // Do not allow to rename listfile + if(nError == ERROR_SUCCESS) + { + if(!_stricmp(szFileName, LISTFILE_NAME)) + nError = ERROR_ACCESS_DENIED; + } + + // Test if the file already exists in the archive + if(nError == ERROR_SUCCESS) + { + if((pNewHash = GetHashEntryEx(ha, szNewFileName, lcLocale)) != NULL) + nError = ERROR_ALREADY_EXISTS; + } + + // Get the hash table entry for the original file + if(nError == ERROR_SUCCESS) + { + if((pOldHash = GetHashEntryEx(ha, szFileName, lcLocale)) == NULL) + nError = ERROR_FILE_NOT_FOUND; + } + + // Get the hash table entry for the renamed file + if(nError == ERROR_SUCCESS) + { + // Save block table index and remove the hash table entry + dwBlockIndex = pOldHash->dwBlockIndex; + pOldHash->dwName1 = 0xFFFFFFFF; + pOldHash->dwName2 = 0xFFFFFFFF; + pOldHash->lcLocale = 0xFFFF; + pOldHash->wPlatform = 0xFFFF; + pOldHash->dwBlockIndex = HASH_ENTRY_DELETED; + + if((pNewHash = FindFreeHashEntry(ha, szNewFileName)) == NULL) + nError = ERROR_CAN_NOT_COMPLETE; + } + + // Save the block index and clear the hash entry + if(nError == ERROR_SUCCESS) + { + // Copy the block table index + pNewHash->dwBlockIndex = dwBlockIndex; + ha->dwFlags |= MPQ_FLAG_CHANGED; + } + + // Rename the file in the list file + if(nError == ERROR_SUCCESS) + nError = SListFileRenameNode(ha, szFileName, szNewFileName); + + // Resolve error and return + if(nError != ERROR_SUCCESS) + SetLastError(nError); + return (nError == ERROR_SUCCESS); +} + diff --git a/src/tools/stuffextract/StormLib/SFileExtractFile.cpp b/src/tools/stuffextract/StormLib/SFileExtractFile.cpp index c1803ce..7f16cde 100644 --- a/src/tools/stuffextract/StormLib/SFileExtractFile.cpp +++ b/src/tools/stuffextract/StormLib/SFileExtractFile.cpp @@ -1,63 +1,63 @@ -/*****************************************************************************/ -/* SFileExtractFile.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Simple extracting utility */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 20.06.03 1.00 Lad The first version of SFileExtractFile.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const char * szExtracted) -{ - HANDLE hLocalFile = INVALID_HANDLE_VALUE; - HANDLE hMpqFile = NULL; - int nError = ERROR_SUCCESS; - - // Create the local file - if(nError == ERROR_SUCCESS) - { - hLocalFile = CreateFile(szExtracted, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL); - if(hLocalFile == INVALID_HANDLE_VALUE) - nError = GetLastError(); - } - - // Open the MPQ file - if(nError == ERROR_SUCCESS) - { - if(!SFileOpenFileEx(hMpq, szToExtract, 0, &hMpqFile)) - nError = GetLastError(); - } - - // Copy the file's content - if(nError == ERROR_SUCCESS) - { - char szBuffer[0x1000]; - DWORD dwTransferred = 1; - - while(dwTransferred > 0) - { - SFileReadFile(hMpqFile, szBuffer, sizeof(szBuffer), &dwTransferred, NULL); - if(dwTransferred == 0) - break; - - WriteFile(hLocalFile, szBuffer, dwTransferred, &dwTransferred, NULL); - if(dwTransferred == 0) - break; - } - } - - // Close the files - if(hMpqFile != NULL) - SFileCloseFile(hMpqFile); - if(hLocalFile != INVALID_HANDLE_VALUE) - CloseHandle(hLocalFile); - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (BOOL)(nError == ERROR_SUCCESS); -} +/*****************************************************************************/ +/* SFileExtractFile.cpp Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* Simple extracting utility */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 20.06.03 1.00 Lad The first version of SFileExtractFile.cpp */ +/*****************************************************************************/ + +#define __STORMLIB_SELF__ +#include "StormLib.h" +#include "SCommon.h" + +// TODO: Test for archives > 4GB +BOOL WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const char * szExtracted) +{ + HANDLE hLocalFile = INVALID_HANDLE_VALUE; + HANDLE hMpqFile = NULL; + int nError = ERROR_SUCCESS; + + // Create the local file + if(nError == ERROR_SUCCESS) + { + hLocalFile = CreateFile(szExtracted, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL); + if(hLocalFile == INVALID_HANDLE_VALUE) + nError = GetLastError(); + } + + // Open the MPQ file + if(nError == ERROR_SUCCESS) + { + if(!SFileOpenFileEx(hMpq, szToExtract, 0, &hMpqFile)) + nError = GetLastError(); + } + + // Copy the file's content + if(nError == ERROR_SUCCESS) + { + char szBuffer[0x1000]; + DWORD dwTransferred = 1; + + while(dwTransferred > 0) + { + SFileReadFile(hMpqFile, szBuffer, sizeof(szBuffer), &dwTransferred, NULL); + if(dwTransferred == 0) + break; + + WriteFile(hLocalFile, szBuffer, dwTransferred, &dwTransferred, NULL); + if(dwTransferred == 0) + break; + } + } + + // Close the files + if(hMpqFile != NULL) + SFileCloseFile(hMpqFile); + if(hLocalFile != INVALID_HANDLE_VALUE) + CloseHandle(hLocalFile); + if(nError != ERROR_SUCCESS) + SetLastError(nError); + return (BOOL)(nError == ERROR_SUCCESS); +} diff --git a/src/tools/stuffextract/StormLib/SFileFindFile.cpp b/src/tools/stuffextract/StormLib/SFileFindFile.cpp index 08da7a4..41dbeba 100644 --- a/src/tools/stuffextract/StormLib/SFileFindFile.cpp +++ b/src/tools/stuffextract/StormLib/SFileFindFile.cpp @@ -1,291 +1,291 @@ -/*****************************************************************************/ -/* SFileFindFile.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* A module for file searching within MPQs */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 25.03.03 1.00 Lad The first version of SFileFindFile.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -//----------------------------------------------------------------------------- -// Defines - -#define LISTFILE_CACHE_SIZE 0x1000 - -//----------------------------------------------------------------------------- -// Local functions - -static BOOL IsValidSearchHandle(TMPQSearch * hs) -{ - if(hs == NULL || IsBadReadPtr(hs, sizeof(TMPQSearch))) - return FALSE; - - if(!IsValidMpqHandle(hs->ha)) - return FALSE; - - return TRUE; -} - -// This function compares a string with a wildcard search string. -// returns TRUE, when the string matches with the wildcard. -BOOL CheckWildCard(const char * szString, const char * szWildCard) -{ - char * szTemp; // Temporary helper pointer - int nResult = 0; // For memcmp return values - int nMustNotMatch = 0; // Number of following chars int szString, - // which must not match with szWildCard - int nMustMatch = 0; // Number of the following characters, - // which must match - - // When the string is empty, it does not match with every wildcard - if(*szString == 0) - return FALSE; - - // When the mask is empty, it matches to every wildcard - if(szWildCard == NULL || *szWildCard == 0) - return FALSE; - - // Do normal test - for(;;) - { - switch(*szWildCard) - { - case '*': // Means "every number of characters" - // Skip all asterisks - while(*szWildCard == '*') - szWildCard++; - - // When no more characters in wildcard, it means that the strings match - if(*szWildCard == 0) - return TRUE; - - // The next N characters must not agree - nMustNotMatch |= 0x70000000; - break; - - case '?': // Means "One or no character" - while(*szWildCard == '?') - { - nMustNotMatch++; - szWildCard++; - } - break; - - default: - // If the two characters match - if(toupper(*szString) == toupper(*szWildCard)) - { - // When end of string, they agree - if(*szString == 0) - return TRUE; - - nMustNotMatch = 0; - szWildCard++; - szString++; - break; - } - - // If the next character must match, the string does not match - if(nMustNotMatch == 0) - return FALSE; - - // Count the characters which must match after characters - // that must not match - szTemp = (char *)szWildCard; - nMustMatch = 0; - while(*szTemp != 0 && *szTemp != '*' && *szTemp != '?') - { - nMustMatch++; - szTemp++; - } - - // Now skip characters from szString up to number of chars - // that must not match - nResult = -1; - while(nMustNotMatch > 0 && *szString != 0) - { - if((nResult = _strnicmp(szString, szWildCard, nMustMatch)) == 0) - break; - - szString++; - nMustNotMatch--; - } - - // Make one more comparison - if(nMustNotMatch == 0) - nResult = _strnicmp(szString, szWildCard, nMustMatch); - - // If a match has been found, continue the search - if(nResult == 0) - { - nMustNotMatch = 0; - szWildCard += nMustMatch; - szString += nMustMatch; - break; - } - return FALSE; - } - } -} - -// Performs one MPQ search -// TODO: Test for archives > 4GB -static int DoMPQSearch(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData) -{ - TMPQArchive * ha = hs->ha; - TFileNode * pNode; - TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash = ha->pHashTable + hs->dwNextIndex; - - // Do until some file found or no more files - while(pHash < pHashEnd) - { - pNode = ha->pListFile[hs->dwNextIndex++]; - - // If this entry is free, do nothing - if(pHash->dwBlockIndex < HASH_ENTRY_FREE && (DWORD_PTR)pNode < HASH_ENTRY_FREE) - { - // Check the file name. - if(CheckWildCard(pNode->szFileName, hs->szSearchMask)) - { - TMPQBlock * pBlock = ha->pBlockTable + pHash->dwBlockIndex; - - lpFindFileData->lcLocale = pHash->lcLocale; - lpFindFileData->dwFileSize = pBlock->dwFSize; - lpFindFileData->dwFileFlags = pBlock->dwFlags; - lpFindFileData->dwBlockIndex = pHash->dwBlockIndex; - lpFindFileData->dwCompSize = pBlock->dwCSize; - - // Fill the file name and plain file name - strcpy(lpFindFileData->cFileName, pNode->szFileName); - lpFindFileData->szPlainName = strrchr(lpFindFileData->cFileName, '\\'); - if(lpFindFileData->szPlainName == NULL) - lpFindFileData->szPlainName = lpFindFileData->cFileName; - else - lpFindFileData->szPlainName++; - - // Fill the next entry - return ERROR_SUCCESS; - } - } - - pHash++; - } - - // No more files found, return error - return ERROR_NO_MORE_FILES; -} - -// TODO: Test for archives > 4GB -static void FreeMPQSearch(TMPQSearch *& hs) -{ - if(hs != NULL) - { - FREEMEM(hs); - hs = NULL; - } -} - -//----------------------------------------------------------------------------- -// Public functions - -// TODO: Test for archives > 4GB -HANDLE WINAPI SFileFindFirstFile(HANDLE hMPQ, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const char * szListFile) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - TMPQSearch * hs = NULL; // Search object handle - size_t nSize = 0; - int nError = ERROR_SUCCESS; - - // Check for the valid parameters - if(nError == ERROR_SUCCESS) - { - if(!IsValidMpqHandle(ha)) - nError = ERROR_INVALID_PARAMETER; - - if(szMask == NULL || lpFindFileData == NULL) - nError = ERROR_INVALID_PARAMETER; - - if(szListFile == NULL && !IsValidMpqHandle(ha)) - nError = ERROR_INVALID_PARAMETER; - } - - // Include the listfile into the MPQ's internal listfile - // Note that if the listfile name is NULL, do nothing because the - // internal listfile is always included. - if(nError == ERROR_SUCCESS && szListFile != NULL) - nError = SFileAddListFile((HANDLE)ha, szListFile); - - // Allocate the structure for MPQ search - if(nError == ERROR_SUCCESS) - { - nSize = sizeof(TMPQSearch) + strlen(szMask) + 1; - if((hs = (TMPQSearch *)ALLOCMEM(char, nSize)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Perform the first search - if(nError == ERROR_SUCCESS) - { - memset(hs, 0, sizeof(TMPQSearch)); - hs->ha = ha; - hs->dwNextIndex = 0; - strcpy(hs->szSearchMask, szMask); - nError = DoMPQSearch(hs, lpFindFileData); - } - - // Cleanup - if(nError != ERROR_SUCCESS) - { - FreeMPQSearch(hs); - SetLastError(nError); - } - - // Return the result value - return (HANDLE)hs; -} - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData) -{ - TMPQSearch * hs = (TMPQSearch *)hFind; - int nError = ERROR_SUCCESS; - - // Check the parameters - if(nError == ERROR_SUCCESS) - { - if(!IsValidSearchHandle(hs) || lpFindFileData == NULL) - nError = ERROR_INVALID_PARAMETER; - } - - if(nError == ERROR_SUCCESS) - nError = DoMPQSearch(hs, lpFindFileData); - - if(nError != ERROR_SUCCESS) - { - SetLastError(nError); - return FALSE; - } - return TRUE; -} - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileFindClose(HANDLE hFind) -{ - TMPQSearch * hs = (TMPQSearch *)hFind; - - // Check the parameters - if(!IsValidSearchHandle(hs)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - FreeMPQSearch(hs); - return TRUE; -} +/*****************************************************************************/ +/* SFileFindFile.cpp Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* A module for file searching within MPQs */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 25.03.03 1.00 Lad The first version of SFileFindFile.cpp */ +/*****************************************************************************/ + +#define __STORMLIB_SELF__ +#include "StormLib.h" +#include "SCommon.h" + +//----------------------------------------------------------------------------- +// Defines + +#define LISTFILE_CACHE_SIZE 0x1000 + +//----------------------------------------------------------------------------- +// Local functions + +static BOOL IsValidSearchHandle(TMPQSearch * hs) +{ + if(hs == NULL || IsBadReadPtr(hs, sizeof(TMPQSearch))) + return FALSE; + + if(!IsValidMpqHandle(hs->ha)) + return FALSE; + + return TRUE; +} + +// This function compares a string with a wildcard search string. +// returns TRUE, when the string matches with the wildcard. +BOOL CheckWildCard(const char * szString, const char * szWildCard) +{ + char * szTemp; // Temporary helper pointer + int nResult = 0; // For memcmp return values + int nMustNotMatch = 0; // Number of following chars int szString, + // which must not match with szWildCard + int nMustMatch = 0; // Number of the following characters, + // which must match + + // When the string is empty, it does not match with every wildcard + if(*szString == 0) + return FALSE; + + // When the mask is empty, it matches to every wildcard + if(szWildCard == NULL || *szWildCard == 0) + return FALSE; + + // Do normal test + for(;;) + { + switch(*szWildCard) + { + case '*': // Means "every number of characters" + // Skip all asterisks + while(*szWildCard == '*') + szWildCard++; + + // When no more characters in wildcard, it means that the strings match + if(*szWildCard == 0) + return TRUE; + + // The next N characters must not agree + nMustNotMatch |= 0x70000000; + break; + + case '?': // Means "One or no character" + while(*szWildCard == '?') + { + nMustNotMatch++; + szWildCard++; + } + break; + + default: + // If the two characters match + if(toupper(*szString) == toupper(*szWildCard)) + { + // When end of string, they agree + if(*szString == 0) + return TRUE; + + nMustNotMatch = 0; + szWildCard++; + szString++; + break; + } + + // If the next character must match, the string does not match + if(nMustNotMatch == 0) + return FALSE; + + // Count the characters which must match after characters + // that must not match + szTemp = (char *)szWildCard; + nMustMatch = 0; + while(*szTemp != 0 && *szTemp != '*' && *szTemp != '?') + { + nMustMatch++; + szTemp++; + } + + // Now skip characters from szString up to number of chars + // that must not match + nResult = -1; + while(nMustNotMatch > 0 && *szString != 0) + { + if((nResult = _strnicmp(szString, szWildCard, nMustMatch)) == 0) + break; + + szString++; + nMustNotMatch--; + } + + // Make one more comparison + if(nMustNotMatch == 0) + nResult = _strnicmp(szString, szWildCard, nMustMatch); + + // If a match has been found, continue the search + if(nResult == 0) + { + nMustNotMatch = 0; + szWildCard += nMustMatch; + szString += nMustMatch; + break; + } + return FALSE; + } + } +} + +// Performs one MPQ search +// TODO: Test for archives > 4GB +static int DoMPQSearch(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData) +{ + TMPQArchive * ha = hs->ha; + TFileNode * pNode; + TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; + TMPQHash * pHash = ha->pHashTable + hs->dwNextIndex; + + // Do until some file found or no more files + while(pHash < pHashEnd) + { + pNode = ha->pListFile[hs->dwNextIndex++]; + + // If this entry is free, do nothing + if(pHash->dwBlockIndex < HASH_ENTRY_FREE && (DWORD_PTR)pNode < HASH_ENTRY_FREE) + { + // Check the file name. + if(CheckWildCard(pNode->szFileName, hs->szSearchMask)) + { + TMPQBlock * pBlock = ha->pBlockTable + pHash->dwBlockIndex; + + lpFindFileData->lcLocale = pHash->lcLocale; + lpFindFileData->dwFileSize = pBlock->dwFSize; + lpFindFileData->dwFileFlags = pBlock->dwFlags; + lpFindFileData->dwBlockIndex = pHash->dwBlockIndex; + lpFindFileData->dwCompSize = pBlock->dwCSize; + + // Fill the file name and plain file name + strcpy(lpFindFileData->cFileName, pNode->szFileName); + lpFindFileData->szPlainName = strrchr(lpFindFileData->cFileName, '\\'); + if(lpFindFileData->szPlainName == NULL) + lpFindFileData->szPlainName = lpFindFileData->cFileName; + else + lpFindFileData->szPlainName++; + + // Fill the next entry + return ERROR_SUCCESS; + } + } + + pHash++; + } + + // No more files found, return error + return ERROR_NO_MORE_FILES; +} + +// TODO: Test for archives > 4GB +static void FreeMPQSearch(TMPQSearch *& hs) +{ + if(hs != NULL) + { + FREEMEM(hs); + hs = NULL; + } +} + +//----------------------------------------------------------------------------- +// Public functions + +// TODO: Test for archives > 4GB +HANDLE WINAPI SFileFindFirstFile(HANDLE hMPQ, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const char * szListFile) +{ + TMPQArchive * ha = (TMPQArchive *)hMPQ; + TMPQSearch * hs = NULL; // Search object handle + size_t nSize = 0; + int nError = ERROR_SUCCESS; + + // Check for the valid parameters + if(nError == ERROR_SUCCESS) + { + if(!IsValidMpqHandle(ha)) + nError = ERROR_INVALID_PARAMETER; + + if(szMask == NULL || lpFindFileData == NULL) + nError = ERROR_INVALID_PARAMETER; + + if(szListFile == NULL && !IsValidMpqHandle(ha)) + nError = ERROR_INVALID_PARAMETER; + } + + // Include the listfile into the MPQ's internal listfile + // Note that if the listfile name is NULL, do nothing because the + // internal listfile is always included. + if(nError == ERROR_SUCCESS && szListFile != NULL) + nError = SFileAddListFile((HANDLE)ha, szListFile); + + // Allocate the structure for MPQ search + if(nError == ERROR_SUCCESS) + { + nSize = sizeof(TMPQSearch) + strlen(szMask) + 1; + if((hs = (TMPQSearch *)ALLOCMEM(char, nSize)) == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Perform the first search + if(nError == ERROR_SUCCESS) + { + memset(hs, 0, sizeof(TMPQSearch)); + hs->ha = ha; + hs->dwNextIndex = 0; + strcpy(hs->szSearchMask, szMask); + nError = DoMPQSearch(hs, lpFindFileData); + } + + // Cleanup + if(nError != ERROR_SUCCESS) + { + FreeMPQSearch(hs); + SetLastError(nError); + } + + // Return the result value + return (HANDLE)hs; +} + +// TODO: Test for archives > 4GB +BOOL WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData) +{ + TMPQSearch * hs = (TMPQSearch *)hFind; + int nError = ERROR_SUCCESS; + + // Check the parameters + if(nError == ERROR_SUCCESS) + { + if(!IsValidSearchHandle(hs) || lpFindFileData == NULL) + nError = ERROR_INVALID_PARAMETER; + } + + if(nError == ERROR_SUCCESS) + nError = DoMPQSearch(hs, lpFindFileData); + + if(nError != ERROR_SUCCESS) + { + SetLastError(nError); + return FALSE; + } + return TRUE; +} + +// TODO: Test for archives > 4GB +BOOL WINAPI SFileFindClose(HANDLE hFind) +{ + TMPQSearch * hs = (TMPQSearch *)hFind; + + // Check the parameters + if(!IsValidSearchHandle(hs)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + FreeMPQSearch(hs); + return TRUE; +} diff --git a/src/tools/stuffextract/StormLib/SFileOpenArchive.cpp b/src/tools/stuffextract/StormLib/SFileOpenArchive.cpp index 842c71a..cadb4e0 100644 --- a/src/tools/stuffextract/StormLib/SFileOpenArchive.cpp +++ b/src/tools/stuffextract/StormLib/SFileOpenArchive.cpp @@ -1,497 +1,497 @@ -/*****************************************************************************/ -/* SFileOpenArchive.cpp Copyright Ladislav Zezula 1999 */ -/* */ -/* Author : Ladislav Zezula */ -/* E-mail : ladik@zezula.net */ -/* WWW : www.zezula.net */ -/*---------------------------------------------------------------------------*/ -/* Archive functions of Storm.dll */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.xx 1.00 Lad The first version of SFileOpenArchive.cpp */ -/* 19.11.03 1.01 Dan Big endian handling */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -/*****************************************************************************/ -/* Local functions */ -/*****************************************************************************/ - -static BOOL IsAviFile(TMPQHeader * pHeader) -{ - DWORD * AviHdr = (DWORD *)pHeader; - - // Test for 'RIFF', 'AVI ' or 'LIST' - return (AviHdr[0] == 'FFIR' && AviHdr[2] == ' IVA' && AviHdr[3] == 'TSIL'); -} - -// This function gets the right positions of the hash table and the block table. -// TODO: Test for archives > 4GB -static int RelocateMpqTablePositions(TMPQArchive * ha) -{ - TMPQHeader2 * pHeader = ha->pHeader; - LARGE_INTEGER FileSize; - LARGE_INTEGER TempSize; - - // Get the size of the file - FileSize.LowPart = GetFileSize(ha->hFile, (LPDWORD)&FileSize.HighPart); - - // Set the proper hash table position - ha->HashTablePos.HighPart = pHeader->wHashTablePosHigh; - ha->HashTablePos.LowPart = pHeader->dwHashTablePos; - ha->HashTablePos.QuadPart += ha->MpqPos.QuadPart; - if(ha->HashTablePos.QuadPart > FileSize.QuadPart) - return ERROR_BAD_FORMAT; - - // Set the proper block table position - ha->BlockTablePos.HighPart = pHeader->wBlockTablePosHigh; - ha->BlockTablePos.LowPart = pHeader->dwBlockTablePos; - ha->BlockTablePos.QuadPart += ha->MpqPos.QuadPart; - if(ha->BlockTablePos.QuadPart > FileSize.QuadPart) - return ERROR_BAD_FORMAT; - - // Set the proper position of the extended block table - if(pHeader->ExtBlockTablePos.QuadPart != 0) - { - ha->ExtBlockTablePos = pHeader->ExtBlockTablePos; - ha->ExtBlockTablePos.QuadPart += ha->MpqPos.QuadPart; - if(ha->ExtBlockTablePos.QuadPart > FileSize.QuadPart) - return ERROR_BAD_FORMAT; - } - - // Size of MPQ archive is computed as the biggest of - // (EndOfBlockTable, EndOfHashTable, EndOfExtBlockTable) - TempSize.QuadPart = ha->HashTablePos.QuadPart + (pHeader->dwHashTableSize * sizeof(TMPQHash)); - if(TempSize.QuadPart > ha->MpqSize.QuadPart) - ha->MpqSize = TempSize; - TempSize.QuadPart = ha->BlockTablePos.QuadPart + (pHeader->dwBlockTableSize * sizeof(TMPQBlock)); - if(TempSize.QuadPart > ha->MpqSize.QuadPart) - ha->MpqSize = TempSize; - TempSize.QuadPart = ha->ExtBlockTablePos.QuadPart + (pHeader->dwBlockTableSize * sizeof(TMPQBlockEx)); - if(TempSize.QuadPart > ha->MpqSize.QuadPart) - ha->MpqSize = TempSize; - - // MPQ size does not include the bytes before MPQ header - ha->MpqSize.QuadPart -= ha->MpqPos.QuadPart; - return ERROR_SUCCESS; -} - - -/*****************************************************************************/ -/* Public functions */ -/*****************************************************************************/ - -//----------------------------------------------------------------------------- -// SFileGetLocale and SFileSetLocale -// Set the locale for all neewly opened archives and files - -LCID WINAPI SFileGetLocale() -{ - return lcLocale; -} - -LCID WINAPI SFileSetLocale(LCID lcNewLocale) -{ - lcLocale = lcNewLocale; - return lcLocale; -} - -//----------------------------------------------------------------------------- -// SFileOpenArchiveEx (not a public function !!!) -// -// szFileName - MPQ archive file name to open -// dwPriority - When SFileOpenFileEx called, this contains the search priority for searched archives -// dwFlags - If contains MPQ_OPEN_NO_LISTFILE, then the internal list file will not be used. -// phMPQ - Pointer to store open archive handle - -BOOL SFileOpenArchiveEx( - const char * szMpqName, - DWORD dwPriority, - DWORD dwFlags, - HANDLE * phMPQ, - DWORD dwAccessMode) -{ - LARGE_INTEGER TempPos; - TMPQArchive * ha = NULL; // Archive handle - HANDLE hFile = INVALID_HANDLE_VALUE;// Opened archive file handle - DWORD dwMaxBlockIndex = 0; // Maximum value of block entry - DWORD dwBlockTableSize = 0; // Block table size. - DWORD dwTransferred; // Number of bytes read - DWORD dwBytes = 0; // Number of bytes to read - int nError = ERROR_SUCCESS; - - // Check the right parameters - if(nError == ERROR_SUCCESS) - { - if(szMpqName == NULL || *szMpqName == 0 || phMPQ == NULL) - nError = ERROR_INVALID_PARAMETER; - } - - // Ensure that StormBuffer is allocated - if(nError == ERROR_SUCCESS) - nError = PrepareStormBuffer(); - - // Open the MPQ archive file - if(nError == ERROR_SUCCESS) - { - hFile = CreateFile(szMpqName, dwAccessMode, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if(hFile == INVALID_HANDLE_VALUE) - nError = GetLastError(); - } - - // Allocate the MPQhandle - if(nError == ERROR_SUCCESS) - { - if((ha = ALLOCMEM(TMPQArchive, 1)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Initialize handle structure and allocate structure for MPQ header - if(nError == ERROR_SUCCESS) - { - memset(ha, 0, sizeof(TMPQArchive)); - strncpy(ha->szFileName, szMpqName, strlen(szMpqName)); - ha->hFile = hFile; - ha->dwPriority = dwPriority; - ha->pHeader = &ha->Header; - ha->pListFile = NULL; - hFile = INVALID_HANDLE_VALUE; - } - - // Find the offset of MPQ header within the file - if(nError == ERROR_SUCCESS) - { - LARGE_INTEGER SearchPos = {0}; - LARGE_INTEGER MpqPos = {0}; - DWORD dwHeaderID; - - for(;;) - { - // Invalidate the MPQ ID and read the eventual header - SetFilePointer(ha->hFile, MpqPos.LowPart, &MpqPos.HighPart, FILE_BEGIN); - ReadFile(ha->hFile, ha->pHeader, sizeof(TMPQHeader2), &dwTransferred, NULL); - dwHeaderID = BSWAP_INT32_UNSIGNED(ha->pHeader->dwID); - - // Special check : Some MPQs are actually AVI files, only with - // changed extension. - if(MpqPos.QuadPart == 0 && IsAviFile(ha->pHeader)) - { - nError = ERROR_AVI_FILE; - break; - } - - // If different number of bytes read, break the loop - if(dwTransferred != sizeof(TMPQHeader2)) - { - nError = ERROR_BAD_FORMAT; - break; - } - - // If there is the MPQ shunt signature, process it - if(dwHeaderID == ID_MPQ_SHUNT && ha->pShunt == NULL) - { - // Fill the shunt header - ha->ShuntPos = MpqPos; - ha->pShunt = &ha->Shunt; - memcpy(ha->pShunt, ha->pHeader, sizeof(TMPQShunt)); - BSWAP_TMPQSHUNT(ha->pShunt); - - // Set the MPQ pos and repeat the search - MpqPos.QuadPart = SearchPos.QuadPart + ha->pShunt->dwHeaderPos; - continue; - } - - // There must be MPQ header signature - if(dwHeaderID == ID_MPQ) - { - BSWAP_TMPQHEADER(ha->pHeader); - - // Save the position where the MPQ header has been found - ha->MpqPos = MpqPos; - - // If valid signature has been found, break the loop - if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) - { - // W3M Map Protectors set some garbage value into the "dwHeaderSize" - // field of MPQ header. This value is apparently ignored by Storm.dll - if(ha->pHeader->dwHeaderSize != sizeof(TMPQHeader) && - ha->pHeader->dwHeaderSize != sizeof(TMPQHeader2)) - { - ha->dwFlags |= MPQ_FLAG_PROTECTED; - ha->pHeader->dwHeaderSize = sizeof(TMPQHeader); - } - - if(ha->pHeader->dwHashTablePos < ha->pHeader->dwArchiveSize && - ha->pHeader->dwBlockTablePos < ha->pHeader->dwArchiveSize) - { - break; - } - } - - if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_2) - { - break; - } - - nError = ERROR_NOT_SUPPORTED; - break; - } - - // If a MPQ shunt already has been found, - // and no MPQ header was at potision pointed by the shunt, - // then the archive is corrupt - if(ha->pShunt != NULL) - { - nError = ERROR_BAD_FORMAT; - break; - } - - // Move to the next possible offset - SearchPos.QuadPart += 0x200; - MpqPos = SearchPos; - } - } - - // Relocate tables position - if(nError == ERROR_SUCCESS) - { - // Clear the fields not supported in older formats - if(ha->pHeader->wFormatVersion < MPQ_FORMAT_VERSION_2) - { - ha->pHeader->ExtBlockTablePos.QuadPart = 0; - ha->pHeader->wBlockTablePosHigh = 0; - ha->pHeader->wHashTablePosHigh = 0; - } - - ha->dwBlockSize = (0x200 << ha->pHeader->wBlockSize); - nError = RelocateMpqTablePositions(ha); - } - - // Allocate buffers - if(nError == ERROR_SUCCESS) - { - // - // Note that the block table should be as large as the hash table - // (For later file additions). - // - // I have found a MPQ which has the block table larger than - // the hash table. We should avoid buffer overruns caused by that. - // - dwBlockTableSize = max(ha->pHeader->dwHashTableSize, ha->pHeader->dwBlockTableSize); - - ha->pHashTable = ALLOCMEM(TMPQHash, ha->pHeader->dwHashTableSize); - ha->pBlockTable = ALLOCMEM(TMPQBlock, dwBlockTableSize); - ha->pExtBlockTable = ALLOCMEM(TMPQBlockEx, dwBlockTableSize); - ha->pbBlockBuffer = ALLOCMEM(BYTE, ha->dwBlockSize); - - if(!ha->pHashTable || !ha->pBlockTable || !ha->pExtBlockTable || !ha->pbBlockBuffer) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Read the hash table into memory - if(nError == ERROR_SUCCESS) - { - dwBytes = ha->pHeader->dwHashTableSize * sizeof(TMPQHash); - SetFilePointer(ha->hFile, ha->HashTablePos.LowPart, &ha->HashTablePos.HighPart, FILE_BEGIN); - ReadFile(ha->hFile, ha->pHashTable, dwBytes, &dwTransferred, NULL); - - if(dwTransferred != dwBytes) - nError = ERROR_FILE_CORRUPT; - } - - // Decrypt hash table and check if it is correctly decrypted - if(nError == ERROR_SUCCESS) - { - TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash; - - // We have to convert the hash table from LittleEndian - BSWAP_ARRAY32_UNSIGNED((DWORD *)ha->pHashTable, (dwBytes / sizeof(DWORD))); - DecryptHashTable((DWORD *)ha->pHashTable, (BYTE *)"(hash table)", (ha->pHeader->dwHashTableSize * 4)); - - // Check hash table if is correctly decrypted - for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) - { - // Note: Some MPQs from World of Warcraft have wPlatform set to 0x0100. - - // If not free or deleted hash entry, check for valid values - if(pHash->dwBlockIndex < HASH_ENTRY_DELETED) - { - // The block index should not be larger than size of the block table - if(pHash->dwBlockIndex > ha->pHeader->dwBlockTableSize) - { - nError = ERROR_BAD_FORMAT; - break; - } - - // Remember the highest block table entry - if(pHash->dwBlockIndex > dwMaxBlockIndex) - dwMaxBlockIndex = pHash->dwBlockIndex; - } - } - } - - // Now, read the block table - if(nError == ERROR_SUCCESS) - { - memset(ha->pBlockTable, 0, dwBlockTableSize * sizeof(TMPQBlock)); - - dwBytes = ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); - SetFilePointer(ha->hFile, ha->BlockTablePos.LowPart, &ha->BlockTablePos.HighPart, FILE_BEGIN); - ReadFile(ha->hFile, ha->pBlockTable, dwBytes, &dwTransferred, NULL); - - // We have to convert every DWORD in ha->block from LittleEndian - BSWAP_ARRAY32_UNSIGNED((DWORD *)ha->pBlockTable, dwBytes / sizeof(DWORD)); - - if(dwTransferred != dwBytes) - nError = ERROR_FILE_CORRUPT; - } - - // Decrypt block table. - // Some MPQs don't have Decrypted block table, e.g. cracked Diablo version - // We have to check if block table is really encrypted - if(nError == ERROR_SUCCESS) - { - TMPQBlock * pBlockEnd = ha->pBlockTable + ha->pHeader->dwBlockTableSize; - TMPQBlock * pBlock = ha->pBlockTable; - BOOL bBlockTableEncrypted = FALSE; - - // Verify all blocks entries in the table - // The loop usually stops at the first entry - while(pBlock < pBlockEnd) - { - // The lower 8 bits of the MPQ flags are always zero. - // Note that this may change in next MPQ versions - if(pBlock->dwFlags & 0x000000FF) - { - bBlockTableEncrypted = TRUE; - break; - } - - // Move to the next block table entry - pBlock++; - } - - if(bBlockTableEncrypted) - { - DecryptBlockTable((DWORD *)ha->pBlockTable, - (BYTE *)"(block table)", - (ha->pHeader->dwBlockTableSize * 4)); - } - } - - // Now, read the extended block table. - // For V1 archives, we still will maintain the extended block table - // (it will be filled with zeros) - // TODO: Test with >4GB - if(nError == ERROR_SUCCESS) - { - memset(ha->pExtBlockTable, 0, dwBlockTableSize * sizeof(TMPQBlockEx)); - - if(ha->pHeader->ExtBlockTablePos.QuadPart != 0) - { - dwBytes = ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx); - SetFilePointer(ha->hFile, - ha->ExtBlockTablePos.LowPart, - &ha->ExtBlockTablePos.HighPart, - FILE_BEGIN); - ReadFile(ha->hFile, ha->pExtBlockTable, dwBytes, &dwTransferred, NULL); - - // We have to convert every DWORD in ha->block from LittleEndian - BSWAP_ARRAY16_UNSIGNED((USHORT *)ha->pExtBlockTable, dwBytes / sizeof(USHORT)); - - // The extended block table is not encrypted (so far) - if(dwTransferred != dwBytes) - nError = ERROR_FILE_CORRUPT; - } - } - - // Verify the both block tables (If the MPQ file is not protected) - if(nError == ERROR_SUCCESS && (ha->dwFlags & MPQ_FLAG_PROTECTED) == 0) - { - TMPQBlockEx * pBlockEx = ha->pExtBlockTable; - TMPQBlock * pBlockEnd = ha->pBlockTable + dwMaxBlockIndex + 1; - TMPQBlock * pBlock = ha->pBlockTable; - - // If the MPQ file is not protected, - // we will check if all sizes in the block table is correct. - // Note that we will not relocate the block table (change from previous versions) - for(; pBlock < pBlockEnd; pBlock++, pBlockEx++) - { - if(pBlock->dwFlags & MPQ_FILE_EXISTS) - { - // Get the 64-bit file position - TempPos.HighPart = pBlockEx->wFilePosHigh; - TempPos.LowPart = pBlock->dwFilePos; - - if(TempPos.QuadPart > ha->MpqSize.QuadPart || pBlock->dwCSize > ha->MpqSize.QuadPart) - { - nError = ERROR_BAD_FORMAT; - break; - } - } - } - } - - // If the user didn't specified otherwise, - // include the internal listfile to the TMPQArchive structure - if((dwFlags & MPQ_OPEN_NO_LISTFILE) == 0) - { - if(nError == ERROR_SUCCESS) - SListFileCreateListFile(ha); - - // Add the internal listfile - if(nError == ERROR_SUCCESS) - SFileAddListFile((HANDLE)ha, NULL); - } - - // Cleanup and exit - if(nError != ERROR_SUCCESS) - { - FreeMPQArchive(ha); - if(hFile != INVALID_HANDLE_VALUE) - CloseHandle(hFile); - SetLastError(nError); - } - else - { - if(pFirstOpen == NULL) - pFirstOpen = ha; - } - *phMPQ = ha; - return (nError == ERROR_SUCCESS); -} - -BOOL WINAPI SFileOpenArchive(const char * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMPQ) -{ - return SFileOpenArchiveEx(szMpqName, dwPriority, dwFlags, phMPQ, GENERIC_READ); -} - -//----------------------------------------------------------------------------- -// BOOL SFileCloseArchive(HANDLE hMPQ); -// - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileCloseArchive(HANDLE hMPQ) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - - if(!IsValidMpqHandle(ha)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - if(ha->dwFlags & MPQ_FLAG_CHANGED) - { - SListFileSaveToMpq(ha); - SaveMPQTables(ha); - } - FreeMPQArchive(ha); - return TRUE; -} - +/*****************************************************************************/ +/* SFileOpenArchive.cpp Copyright Ladislav Zezula 1999 */ +/* */ +/* Author : Ladislav Zezula */ +/* E-mail : ladik@zezula.net */ +/* WWW : www.zezula.net */ +/*---------------------------------------------------------------------------*/ +/* Archive functions of Storm.dll */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* xx.xx.xx 1.00 Lad The first version of SFileOpenArchive.cpp */ +/* 19.11.03 1.01 Dan Big endian handling */ +/*****************************************************************************/ + +#define __STORMLIB_SELF__ +#include "StormLib.h" +#include "SCommon.h" + +/*****************************************************************************/ +/* Local functions */ +/*****************************************************************************/ + +static BOOL IsAviFile(TMPQHeader * pHeader) +{ + DWORD * AviHdr = (DWORD *)pHeader; + + // Test for 'RIFF', 'AVI ' or 'LIST' + return (AviHdr[0] == 'FFIR' && AviHdr[2] == ' IVA' && AviHdr[3] == 'TSIL'); +} + +// This function gets the right positions of the hash table and the block table. +// TODO: Test for archives > 4GB +static int RelocateMpqTablePositions(TMPQArchive * ha) +{ + TMPQHeader2 * pHeader = ha->pHeader; + LARGE_INTEGER FileSize; + LARGE_INTEGER TempSize; + + // Get the size of the file + FileSize.LowPart = GetFileSize(ha->hFile, (LPDWORD)&FileSize.HighPart); + + // Set the proper hash table position + ha->HashTablePos.HighPart = pHeader->wHashTablePosHigh; + ha->HashTablePos.LowPart = pHeader->dwHashTablePos; + ha->HashTablePos.QuadPart += ha->MpqPos.QuadPart; + if(ha->HashTablePos.QuadPart > FileSize.QuadPart) + return ERROR_BAD_FORMAT; + + // Set the proper block table position + ha->BlockTablePos.HighPart = pHeader->wBlockTablePosHigh; + ha->BlockTablePos.LowPart = pHeader->dwBlockTablePos; + ha->BlockTablePos.QuadPart += ha->MpqPos.QuadPart; + if(ha->BlockTablePos.QuadPart > FileSize.QuadPart) + return ERROR_BAD_FORMAT; + + // Set the proper position of the extended block table + if(pHeader->ExtBlockTablePos.QuadPart != 0) + { + ha->ExtBlockTablePos = pHeader->ExtBlockTablePos; + ha->ExtBlockTablePos.QuadPart += ha->MpqPos.QuadPart; + if(ha->ExtBlockTablePos.QuadPart > FileSize.QuadPart) + return ERROR_BAD_FORMAT; + } + + // Size of MPQ archive is computed as the biggest of + // (EndOfBlockTable, EndOfHashTable, EndOfExtBlockTable) + TempSize.QuadPart = ha->HashTablePos.QuadPart + (pHeader->dwHashTableSize * sizeof(TMPQHash)); + if(TempSize.QuadPart > ha->MpqSize.QuadPart) + ha->MpqSize = TempSize; + TempSize.QuadPart = ha->BlockTablePos.QuadPart + (pHeader->dwBlockTableSize * sizeof(TMPQBlock)); + if(TempSize.QuadPart > ha->MpqSize.QuadPart) + ha->MpqSize = TempSize; + TempSize.QuadPart = ha->ExtBlockTablePos.QuadPart + (pHeader->dwBlockTableSize * sizeof(TMPQBlockEx)); + if(TempSize.QuadPart > ha->MpqSize.QuadPart) + ha->MpqSize = TempSize; + + // MPQ size does not include the bytes before MPQ header + ha->MpqSize.QuadPart -= ha->MpqPos.QuadPart; + return ERROR_SUCCESS; +} + + +/*****************************************************************************/ +/* Public functions */ +/*****************************************************************************/ + +//----------------------------------------------------------------------------- +// SFileGetLocale and SFileSetLocale +// Set the locale for all neewly opened archives and files + +LCID WINAPI SFileGetLocale() +{ + return lcLocale; +} + +LCID WINAPI SFileSetLocale(LCID lcNewLocale) +{ + lcLocale = lcNewLocale; + return lcLocale; +} + +//----------------------------------------------------------------------------- +// SFileOpenArchiveEx (not a public function !!!) +// +// szFileName - MPQ archive file name to open +// dwPriority - When SFileOpenFileEx called, this contains the search priority for searched archives +// dwFlags - If contains MPQ_OPEN_NO_LISTFILE, then the internal list file will not be used. +// phMPQ - Pointer to store open archive handle + +BOOL SFileOpenArchiveEx( + const char * szMpqName, + DWORD dwPriority, + DWORD dwFlags, + HANDLE * phMPQ, + DWORD dwAccessMode) +{ + LARGE_INTEGER TempPos; + TMPQArchive * ha = NULL; // Archive handle + HANDLE hFile = INVALID_HANDLE_VALUE;// Opened archive file handle + DWORD dwMaxBlockIndex = 0; // Maximum value of block entry + DWORD dwBlockTableSize = 0; // Block table size. + DWORD dwTransferred; // Number of bytes read + DWORD dwBytes = 0; // Number of bytes to read + int nError = ERROR_SUCCESS; + + // Check the right parameters + if(nError == ERROR_SUCCESS) + { + if(szMpqName == NULL || *szMpqName == 0 || phMPQ == NULL) + nError = ERROR_INVALID_PARAMETER; + } + + // Ensure that StormBuffer is allocated + if(nError == ERROR_SUCCESS) + nError = PrepareStormBuffer(); + + // Open the MPQ archive file + if(nError == ERROR_SUCCESS) + { + hFile = CreateFile(szMpqName, dwAccessMode, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + if(hFile == INVALID_HANDLE_VALUE) + nError = GetLastError(); + } + + // Allocate the MPQhandle + if(nError == ERROR_SUCCESS) + { + if((ha = ALLOCMEM(TMPQArchive, 1)) == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Initialize handle structure and allocate structure for MPQ header + if(nError == ERROR_SUCCESS) + { + memset(ha, 0, sizeof(TMPQArchive)); + strncpy(ha->szFileName, szMpqName, strlen(szMpqName)); + ha->hFile = hFile; + ha->dwPriority = dwPriority; + ha->pHeader = &ha->Header; + ha->pListFile = NULL; + hFile = INVALID_HANDLE_VALUE; + } + + // Find the offset of MPQ header within the file + if(nError == ERROR_SUCCESS) + { + LARGE_INTEGER SearchPos = {0}; + LARGE_INTEGER MpqPos = {0}; + DWORD dwHeaderID; + + for(;;) + { + // Invalidate the MPQ ID and read the eventual header + SetFilePointer(ha->hFile, MpqPos.LowPart, &MpqPos.HighPart, FILE_BEGIN); + ReadFile(ha->hFile, ha->pHeader, sizeof(TMPQHeader2), &dwTransferred, NULL); + dwHeaderID = BSWAP_INT32_UNSIGNED(ha->pHeader->dwID); + + // Special check : Some MPQs are actually AVI files, only with + // changed extension. + if(MpqPos.QuadPart == 0 && IsAviFile(ha->pHeader)) + { + nError = ERROR_AVI_FILE; + break; + } + + // If different number of bytes read, break the loop + if(dwTransferred != sizeof(TMPQHeader2)) + { + nError = ERROR_BAD_FORMAT; + break; + } + + // If there is the MPQ shunt signature, process it + if(dwHeaderID == ID_MPQ_SHUNT && ha->pShunt == NULL) + { + // Fill the shunt header + ha->ShuntPos = MpqPos; + ha->pShunt = &ha->Shunt; + memcpy(ha->pShunt, ha->pHeader, sizeof(TMPQShunt)); + BSWAP_TMPQSHUNT(ha->pShunt); + + // Set the MPQ pos and repeat the search + MpqPos.QuadPart = SearchPos.QuadPart + ha->pShunt->dwHeaderPos; + continue; + } + + // There must be MPQ header signature + if(dwHeaderID == ID_MPQ) + { + BSWAP_TMPQHEADER(ha->pHeader); + + // Save the position where the MPQ header has been found + ha->MpqPos = MpqPos; + + // If valid signature has been found, break the loop + if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) + { + // W3M Map Protectors set some garbage value into the "dwHeaderSize" + // field of MPQ header. This value is apparently ignored by Storm.dll + if(ha->pHeader->dwHeaderSize != sizeof(TMPQHeader) && + ha->pHeader->dwHeaderSize != sizeof(TMPQHeader2)) + { + ha->dwFlags |= MPQ_FLAG_PROTECTED; + ha->pHeader->dwHeaderSize = sizeof(TMPQHeader); + } + + if(ha->pHeader->dwHashTablePos < ha->pHeader->dwArchiveSize && + ha->pHeader->dwBlockTablePos < ha->pHeader->dwArchiveSize) + { + break; + } + } + + if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_2) + { + break; + } + + nError = ERROR_NOT_SUPPORTED; + break; + } + + // If a MPQ shunt already has been found, + // and no MPQ header was at potision pointed by the shunt, + // then the archive is corrupt + if(ha->pShunt != NULL) + { + nError = ERROR_BAD_FORMAT; + break; + } + + // Move to the next possible offset + SearchPos.QuadPart += 0x200; + MpqPos = SearchPos; + } + } + + // Relocate tables position + if(nError == ERROR_SUCCESS) + { + // Clear the fields not supported in older formats + if(ha->pHeader->wFormatVersion < MPQ_FORMAT_VERSION_2) + { + ha->pHeader->ExtBlockTablePos.QuadPart = 0; + ha->pHeader->wBlockTablePosHigh = 0; + ha->pHeader->wHashTablePosHigh = 0; + } + + ha->dwBlockSize = (0x200 << ha->pHeader->wBlockSize); + nError = RelocateMpqTablePositions(ha); + } + + // Allocate buffers + if(nError == ERROR_SUCCESS) + { + // + // Note that the block table should be as large as the hash table + // (For later file additions). + // + // I have found a MPQ which has the block table larger than + // the hash table. We should avoid buffer overruns caused by that. + // + dwBlockTableSize = max(ha->pHeader->dwHashTableSize, ha->pHeader->dwBlockTableSize); + + ha->pHashTable = ALLOCMEM(TMPQHash, ha->pHeader->dwHashTableSize); + ha->pBlockTable = ALLOCMEM(TMPQBlock, dwBlockTableSize); + ha->pExtBlockTable = ALLOCMEM(TMPQBlockEx, dwBlockTableSize); + ha->pbBlockBuffer = ALLOCMEM(BYTE, ha->dwBlockSize); + + if(!ha->pHashTable || !ha->pBlockTable || !ha->pExtBlockTable || !ha->pbBlockBuffer) + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Read the hash table into memory + if(nError == ERROR_SUCCESS) + { + dwBytes = ha->pHeader->dwHashTableSize * sizeof(TMPQHash); + SetFilePointer(ha->hFile, ha->HashTablePos.LowPart, &ha->HashTablePos.HighPart, FILE_BEGIN); + ReadFile(ha->hFile, ha->pHashTable, dwBytes, &dwTransferred, NULL); + + if(dwTransferred != dwBytes) + nError = ERROR_FILE_CORRUPT; + } + + // Decrypt hash table and check if it is correctly decrypted + if(nError == ERROR_SUCCESS) + { + TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; + TMPQHash * pHash; + + // We have to convert the hash table from LittleEndian + BSWAP_ARRAY32_UNSIGNED((DWORD *)ha->pHashTable, (dwBytes / sizeof(DWORD))); + DecryptHashTable((DWORD *)ha->pHashTable, (BYTE *)"(hash table)", (ha->pHeader->dwHashTableSize * 4)); + + // Check hash table if is correctly decrypted + for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) + { + // Note: Some MPQs from World of Warcraft have wPlatform set to 0x0100. + + // If not free or deleted hash entry, check for valid values + if(pHash->dwBlockIndex < HASH_ENTRY_DELETED) + { + // The block index should not be larger than size of the block table + if(pHash->dwBlockIndex > ha->pHeader->dwBlockTableSize) + { + nError = ERROR_BAD_FORMAT; + break; + } + + // Remember the highest block table entry + if(pHash->dwBlockIndex > dwMaxBlockIndex) + dwMaxBlockIndex = pHash->dwBlockIndex; + } + } + } + + // Now, read the block table + if(nError == ERROR_SUCCESS) + { + memset(ha->pBlockTable, 0, dwBlockTableSize * sizeof(TMPQBlock)); + + dwBytes = ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); + SetFilePointer(ha->hFile, ha->BlockTablePos.LowPart, &ha->BlockTablePos.HighPart, FILE_BEGIN); + ReadFile(ha->hFile, ha->pBlockTable, dwBytes, &dwTransferred, NULL); + + // We have to convert every DWORD in ha->block from LittleEndian + BSWAP_ARRAY32_UNSIGNED((DWORD *)ha->pBlockTable, dwBytes / sizeof(DWORD)); + + if(dwTransferred != dwBytes) + nError = ERROR_FILE_CORRUPT; + } + + // Decrypt block table. + // Some MPQs don't have Decrypted block table, e.g. cracked Diablo version + // We have to check if block table is really encrypted + if(nError == ERROR_SUCCESS) + { + TMPQBlock * pBlockEnd = ha->pBlockTable + ha->pHeader->dwBlockTableSize; + TMPQBlock * pBlock = ha->pBlockTable; + BOOL bBlockTableEncrypted = FALSE; + + // Verify all blocks entries in the table + // The loop usually stops at the first entry + while(pBlock < pBlockEnd) + { + // The lower 8 bits of the MPQ flags are always zero. + // Note that this may change in next MPQ versions + if(pBlock->dwFlags & 0x000000FF) + { + bBlockTableEncrypted = TRUE; + break; + } + + // Move to the next block table entry + pBlock++; + } + + if(bBlockTableEncrypted) + { + DecryptBlockTable((DWORD *)ha->pBlockTable, + (BYTE *)"(block table)", + (ha->pHeader->dwBlockTableSize * 4)); + } + } + + // Now, read the extended block table. + // For V1 archives, we still will maintain the extended block table + // (it will be filled with zeros) + // TODO: Test with >4GB + if(nError == ERROR_SUCCESS) + { + memset(ha->pExtBlockTable, 0, dwBlockTableSize * sizeof(TMPQBlockEx)); + + if(ha->pHeader->ExtBlockTablePos.QuadPart != 0) + { + dwBytes = ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx); + SetFilePointer(ha->hFile, + ha->ExtBlockTablePos.LowPart, + &ha->ExtBlockTablePos.HighPart, + FILE_BEGIN); + ReadFile(ha->hFile, ha->pExtBlockTable, dwBytes, &dwTransferred, NULL); + + // We have to convert every DWORD in ha->block from LittleEndian + BSWAP_ARRAY16_UNSIGNED((USHORT *)ha->pExtBlockTable, dwBytes / sizeof(USHORT)); + + // The extended block table is not encrypted (so far) + if(dwTransferred != dwBytes) + nError = ERROR_FILE_CORRUPT; + } + } + + // Verify the both block tables (If the MPQ file is not protected) + if(nError == ERROR_SUCCESS && (ha->dwFlags & MPQ_FLAG_PROTECTED) == 0) + { + TMPQBlockEx * pBlockEx = ha->pExtBlockTable; + TMPQBlock * pBlockEnd = ha->pBlockTable + dwMaxBlockIndex + 1; + TMPQBlock * pBlock = ha->pBlockTable; + + // If the MPQ file is not protected, + // we will check if all sizes in the block table is correct. + // Note that we will not relocate the block table (change from previous versions) + for(; pBlock < pBlockEnd; pBlock++, pBlockEx++) + { + if(pBlock->dwFlags & MPQ_FILE_EXISTS) + { + // Get the 64-bit file position + TempPos.HighPart = pBlockEx->wFilePosHigh; + TempPos.LowPart = pBlock->dwFilePos; + + if(TempPos.QuadPart > ha->MpqSize.QuadPart || pBlock->dwCSize > ha->MpqSize.QuadPart) + { + nError = ERROR_BAD_FORMAT; + break; + } + } + } + } + + // If the user didn't specified otherwise, + // include the internal listfile to the TMPQArchive structure + if((dwFlags & MPQ_OPEN_NO_LISTFILE) == 0) + { + if(nError == ERROR_SUCCESS) + SListFileCreateListFile(ha); + + // Add the internal listfile + if(nError == ERROR_SUCCESS) + SFileAddListFile((HANDLE)ha, NULL); + } + + // Cleanup and exit + if(nError != ERROR_SUCCESS) + { + FreeMPQArchive(ha); + if(hFile != INVALID_HANDLE_VALUE) + CloseHandle(hFile); + SetLastError(nError); + } + else + { + if(pFirstOpen == NULL) + pFirstOpen = ha; + } + *phMPQ = ha; + return (nError == ERROR_SUCCESS); +} + +BOOL WINAPI SFileOpenArchive(const char * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMPQ) +{ + return SFileOpenArchiveEx(szMpqName, dwPriority, dwFlags, phMPQ, GENERIC_READ); +} + +//----------------------------------------------------------------------------- +// BOOL SFileCloseArchive(HANDLE hMPQ); +// + +// TODO: Test for archives > 4GB +BOOL WINAPI SFileCloseArchive(HANDLE hMPQ) +{ + TMPQArchive * ha = (TMPQArchive *)hMPQ; + + if(!IsValidMpqHandle(ha)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + if(ha->dwFlags & MPQ_FLAG_CHANGED) + { + SListFileSaveToMpq(ha); + SaveMPQTables(ha); + } + FreeMPQArchive(ha); + return TRUE; +} + diff --git a/src/tools/stuffextract/StormLib/SFileOpenFileEx.cpp b/src/tools/stuffextract/StormLib/SFileOpenFileEx.cpp index cc9a7d7..dae3121 100644 --- a/src/tools/stuffextract/StormLib/SFileOpenFileEx.cpp +++ b/src/tools/stuffextract/StormLib/SFileOpenFileEx.cpp @@ -1,403 +1,403 @@ -/*****************************************************************************/ -/* SFileOpenFileEx.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Description : */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.99 1.00 Lad The first version of SFileOpenFileEx.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -/*****************************************************************************/ -/* Local functions */ -/*****************************************************************************/ - -// TODO: Test for archives > 4GB -static BOOL OpenLocalFile(const char * szFileName, HANDLE * phFile) -{ - TMPQFile * hf = NULL; - HANDLE hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); - - if(hFile != INVALID_HANDLE_VALUE) - { - // Allocate and initialize file handle - size_t nHandleSize = sizeof(TMPQFile) + strlen(szFileName); - if((hf = (TMPQFile *)ALLOCMEM(char, nHandleSize)) != NULL) - { - memset(hf, 0, nHandleSize); - strcpy(hf->szFileName, szFileName); - hf->hFile = hFile; - *phFile = hf; - return TRUE; - } - else - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - } - *phFile = NULL; - return FALSE; -} - -// TODO: Test for archives > 4GB -static void FreeMPQFile(TMPQFile *& hf) -{ - if(hf != NULL) - { - if(hf->hFile != INVALID_HANDLE_VALUE) - CloseHandle(hf->hFile); - if(hf->pdwBlockPos != NULL) - FREEMEM(hf->pdwBlockPos); - if(hf->pbFileBuffer != NULL) - FREEMEM(hf->pbFileBuffer); - FREEMEM(hf); - hf = NULL; - } -} - -/*****************************************************************************/ -/* Public functions */ -/*****************************************************************************/ - -//----------------------------------------------------------------------------- -// SFileEnumLocales enums all locale versions within MPQ. -// Functions fills all available language identifiers on a file into the buffer -// pointed by plcLocales. There must be enough entries to copy the localed, -// otherwise the function returns ERROR_INSUFFICIENT_BUFFER. - -// TODO: Test for archives > 4GB -int WINAPI SFileEnumLocales( - HANDLE hMPQ, - const char * szFileName, - LCID * plcLocales, - DWORD * pdwMaxLocales, - DWORD dwSearchScope) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - TMPQHash * pHash = NULL; - TMPQHash * pHashEnd = NULL; - DWORD dwLocales = 0; - int nError = ERROR_SUCCESS; - - // Test the parameters - if(nError == ERROR_SUCCESS) - { - if(!IsValidMpqHandle(ha) || pdwMaxLocales == NULL) - nError = ERROR_INVALID_PARAMETER; - if(dwSearchScope == SFILE_OPEN_BY_INDEX && (DWORD_PTR)szFileName > ha->pHeader->dwBlockTableSize) - nError = ERROR_INVALID_PARAMETER; - if(dwSearchScope != SFILE_OPEN_BY_INDEX && *szFileName == 0) - nError = ERROR_INVALID_PARAMETER; - } - - // Retrieve the hash entry for the required file - if(nError == ERROR_SUCCESS) - { - pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - - if(dwSearchScope == SFILE_OPEN_BY_INDEX) - { - for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) - { - if(pHash->dwBlockIndex == (DWORD_PTR)szFileName) - break; - } - if(pHash == pHashEnd) - pHash = NULL; - } - else - pHash = GetHashEntry(ha, szFileName); - } - - // If the file was not found, sorry - if(nError == ERROR_SUCCESS) - { - if(pHash == NULL) - nError = ERROR_FILE_NOT_FOUND; - } - - // Count the entries which correspond to the same file name - if(nError == ERROR_SUCCESS) - { - TMPQHash * pSaveHash = pHash; - DWORD dwName1 = pHash->dwName1; - DWORD dwName2 = pHash->dwName2; - - // For nameless access, return 1 locale always - if(dwSearchScope == SFILE_OPEN_BY_INDEX) - dwLocales++; - else - { - while(pHash < pHashEnd && pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2) - { - dwLocales++; - pHash++; - } - } - - pHash = pSaveHash; - } - - // Test if there is enough space to copy the locales - if(nError == ERROR_SUCCESS) - { - DWORD dwMaxLocales = *pdwMaxLocales; - - *pdwMaxLocales = dwLocales; - if(dwMaxLocales < dwLocales) - nError = ERROR_INSUFFICIENT_BUFFER; - } - - // Fill all the locales - if(nError == ERROR_SUCCESS) - { - for(DWORD i = 0; i < dwLocales; i++, pHash++) - *plcLocales++ = (LCID)pHash->lcLocale; - } - return nError; -} - -//----------------------------------------------------------------------------- -// SFileHasFile -// -// hMPQ - Handle of opened MPQ archive -// szFileName - Name of file to look for - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileHasFile(HANDLE hMPQ, char * szFileName) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - int nError = ERROR_SUCCESS; - - if(nError == ERROR_SUCCESS) - { - if(ha == NULL) - nError = ERROR_INVALID_PARAMETER; - if(*szFileName == 0) - nError = ERROR_INVALID_PARAMETER; - } - - // Prepare the file opening - if(nError == ERROR_SUCCESS) - { - if(GetHashEntryEx(ha, szFileName, lcLocale) == NULL) - { - nError = ERROR_FILE_NOT_FOUND; - } - } - - // Cleanup - if(nError != ERROR_SUCCESS) - { - SetLastError(nError); - } - - return (nError == ERROR_SUCCESS); -} - - -//----------------------------------------------------------------------------- -// SFileOpenFileEx -// -// hMPQ - Handle of opened MPQ archive -// szFileName - Name of file to open -// dwSearchScope - Where to search -// phFile - Pointer to store opened file handle - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileOpenFileEx(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope, HANDLE * phFile) -{ - LARGE_INTEGER FilePos; - TMPQArchive * ha = (TMPQArchive *)hMPQ; - TMPQFile * hf = NULL; - TMPQHash * pHash = NULL; // Hash table index - TMPQBlock * pBlock = NULL; // File block - TMPQBlockEx * pBlockEx = NULL; - DWORD dwHashIndex = 0; // Hash table index - DWORD dwBlockIndex = (DWORD)-1; // Found table index - size_t nHandleSize = 0; // Memory space necessary to allocate TMPQHandle - int nError = ERROR_SUCCESS; - -#ifdef _DEBUG - // Due to increasing numbers of files in MPQs, I had to change the behavior - // of opening by file index. Now, the SFILE_OPEN_BY_INDEX value of dwSearchScope - // must be entered. This check will allow to find code places that are incompatible - // with the new behavior. - if(dwSearchScope != SFILE_OPEN_BY_INDEX && szFileName != NULL) - { - assert((DWORD_PTR)szFileName > 0x10000); - } -#endif - - if(nError == ERROR_SUCCESS) - { - if(ha == NULL && dwSearchScope == SFILE_OPEN_FROM_MPQ) - nError = ERROR_INVALID_PARAMETER; - if(phFile == NULL) - nError = ERROR_INVALID_PARAMETER; - if(dwSearchScope == SFILE_OPEN_BY_INDEX && (DWORD_PTR)szFileName > ha->pHeader->dwBlockTableSize) - nError = ERROR_INVALID_PARAMETER; - if(dwSearchScope != SFILE_OPEN_BY_INDEX && (szFileName == NULL || *szFileName == 0)) - nError = ERROR_INVALID_PARAMETER; - } - - // Prepare the file opening - if(nError == ERROR_SUCCESS) - { - // When the file is given by number, ... - if(dwSearchScope == SFILE_OPEN_BY_INDEX) - { - TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - - // Set handle size to be sizeof(TMPQFile) + length of FileXXXXXXXX.xxx - nHandleSize = sizeof(TMPQFile) + 20; - for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) - { - if((DWORD_PTR)szFileName == pHash->dwBlockIndex) - { - dwHashIndex = (DWORD)(pHash - ha->pHashTable); - dwBlockIndex = pHash->dwBlockIndex; - break; - } - } - } - else - { - // If we have to open a disk file - if(dwSearchScope == SFILE_OPEN_LOCAL_FILE) - return OpenLocalFile(szFileName, phFile); - - nHandleSize = sizeof(TMPQFile) + strlen(szFileName); - if((pHash = GetHashEntryEx(ha, szFileName, lcLocale)) != NULL) - { - dwHashIndex = (DWORD)(pHash - ha->pHashTable); - dwBlockIndex = pHash->dwBlockIndex; - } - } - } - - // Get block index from file name and test it - if(nError == ERROR_SUCCESS) - { - // If index was not found, or is greater than number of files, exit. - if(dwBlockIndex == (DWORD)-1 || dwBlockIndex > ha->pHeader->dwBlockTableSize) - nError = ERROR_FILE_NOT_FOUND; - } - - // Get block and test if the file was not already deleted. - if(nError == ERROR_SUCCESS) - { - // Get both block tables and file position - pBlockEx = ha->pExtBlockTable + dwBlockIndex; - pBlock = ha->pBlockTable + dwBlockIndex; - FilePos.HighPart = pBlockEx->wFilePosHigh; - FilePos.LowPart = pBlock->dwFilePos; - - if(FilePos.QuadPart > ha->MpqSize.QuadPart || - pBlock->dwCSize > ha->MpqSize.QuadPart) - nError = ERROR_FILE_CORRUPT; - if((pBlock->dwFlags & MPQ_FILE_EXISTS) == 0) - nError = ERROR_FILE_NOT_FOUND; - if(pBlock->dwFlags & ~MPQ_FILE_VALID_FLAGS) - nError = ERROR_NOT_SUPPORTED; - } - - // Allocate file handle - if(nError == ERROR_SUCCESS) - { - if((hf = (TMPQFile *)ALLOCMEM(char, nHandleSize)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Initialize file handle - if(nError == ERROR_SUCCESS) - { - memset(hf, 0, nHandleSize); - hf->hFile = INVALID_HANDLE_VALUE; - hf->ha = ha; - hf->pBlockEx = pBlockEx; - hf->pBlock = pBlock; - hf->nBlocks = (hf->pBlock->dwFSize + ha->dwBlockSize - 1) / ha->dwBlockSize; - hf->pHash = pHash; - - hf->MpqFilePos.HighPart = pBlockEx->wFilePosHigh; - hf->MpqFilePos.LowPart = pBlock->dwFilePos; - hf->MpqFilePos.QuadPart += ha->MpqPos.QuadPart; - - hf->dwHashIndex = dwHashIndex; - hf->dwFileIndex = dwBlockIndex; - - // Allocate buffers for decompression. - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) - { - // Allocate buffer for block positions. At the begin of file are stored - // DWORDs holding positions of each block relative from begin of file in the archive - // As for newer MPQs, there may be one additional entry in the block table - // (if the MPQ_FILE_HAS_EXTRA flag is set). - // Allocate the buffer to include this DWORD as well - - if((hf->pdwBlockPos = ALLOCMEM(DWORD, hf->nBlocks + 2)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Decrypt file seed. Cannot be used if the file is given by index - if(dwSearchScope != SFILE_OPEN_BY_INDEX) - { - if(hf->pBlock->dwFlags & MPQ_FILE_ENCRYPTED) - { - const char * szTemp = strrchr(szFileName, '\\'); - - strcpy(hf->szFileName, szFileName); - if(szTemp != NULL) - szFileName = szTemp + 1; - hf->dwSeed1 = DecryptFileSeed((char *)szFileName); - - if(hf->pBlock->dwFlags & MPQ_FILE_FIXSEED) - { - hf->dwSeed1 = (hf->dwSeed1 + hf->pBlock->dwFilePos) ^ hf->pBlock->dwFSize; - } - } - } - else - { - // If the file is encrypted and not compressed, we cannot detect the file seed - if(SFileGetFileName(hf, hf->szFileName) == FALSE) - nError = GetLastError(); - } - } - - // Cleanup - if(nError != ERROR_SUCCESS) - { - FreeMPQFile(hf); - SetLastError(nError); - } - - *phFile = hf; - return (nError == ERROR_SUCCESS); -} - -//----------------------------------------------------------------------------- -// BOOL SFileCloseFile(HANDLE hFile); - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileCloseFile(HANDLE hFile) -{ - TMPQFile * hf = (TMPQFile *)hFile; - - if(!IsValidFileHandle(hf)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - // Set the last accessed file in the archive - if(hf->ha != NULL) - hf->ha->pLastFile = NULL; - - // Free the structure - FreeMPQFile(hf); - return TRUE; -} +/*****************************************************************************/ +/* SFileOpenFileEx.cpp Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* Description : */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* xx.xx.99 1.00 Lad The first version of SFileOpenFileEx.cpp */ +/*****************************************************************************/ + +#define __STORMLIB_SELF__ +#include "StormLib.h" +#include "SCommon.h" + +/*****************************************************************************/ +/* Local functions */ +/*****************************************************************************/ + +// TODO: Test for archives > 4GB +static BOOL OpenLocalFile(const char * szFileName, HANDLE * phFile) +{ + TMPQFile * hf = NULL; + HANDLE hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); + + if(hFile != INVALID_HANDLE_VALUE) + { + // Allocate and initialize file handle + size_t nHandleSize = sizeof(TMPQFile) + strlen(szFileName); + if((hf = (TMPQFile *)ALLOCMEM(char, nHandleSize)) != NULL) + { + memset(hf, 0, nHandleSize); + strcpy(hf->szFileName, szFileName); + hf->hFile = hFile; + *phFile = hf; + return TRUE; + } + else + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + } + *phFile = NULL; + return FALSE; +} + +// TODO: Test for archives > 4GB +static void FreeMPQFile(TMPQFile *& hf) +{ + if(hf != NULL) + { + if(hf->hFile != INVALID_HANDLE_VALUE) + CloseHandle(hf->hFile); + if(hf->pdwBlockPos != NULL) + FREEMEM(hf->pdwBlockPos); + if(hf->pbFileBuffer != NULL) + FREEMEM(hf->pbFileBuffer); + FREEMEM(hf); + hf = NULL; + } +} + +/*****************************************************************************/ +/* Public functions */ +/*****************************************************************************/ + +//----------------------------------------------------------------------------- +// SFileEnumLocales enums all locale versions within MPQ. +// Functions fills all available language identifiers on a file into the buffer +// pointed by plcLocales. There must be enough entries to copy the localed, +// otherwise the function returns ERROR_INSUFFICIENT_BUFFER. + +// TODO: Test for archives > 4GB +int WINAPI SFileEnumLocales( + HANDLE hMPQ, + const char * szFileName, + LCID * plcLocales, + DWORD * pdwMaxLocales, + DWORD dwSearchScope) +{ + TMPQArchive * ha = (TMPQArchive *)hMPQ; + TMPQHash * pHash = NULL; + TMPQHash * pHashEnd = NULL; + DWORD dwLocales = 0; + int nError = ERROR_SUCCESS; + + // Test the parameters + if(nError == ERROR_SUCCESS) + { + if(!IsValidMpqHandle(ha) || pdwMaxLocales == NULL) + nError = ERROR_INVALID_PARAMETER; + if(dwSearchScope == SFILE_OPEN_BY_INDEX && (DWORD_PTR)szFileName > ha->pHeader->dwBlockTableSize) + nError = ERROR_INVALID_PARAMETER; + if(dwSearchScope != SFILE_OPEN_BY_INDEX && *szFileName == 0) + nError = ERROR_INVALID_PARAMETER; + } + + // Retrieve the hash entry for the required file + if(nError == ERROR_SUCCESS) + { + pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; + + if(dwSearchScope == SFILE_OPEN_BY_INDEX) + { + for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) + { + if(pHash->dwBlockIndex == (DWORD_PTR)szFileName) + break; + } + if(pHash == pHashEnd) + pHash = NULL; + } + else + pHash = GetHashEntry(ha, szFileName); + } + + // If the file was not found, sorry + if(nError == ERROR_SUCCESS) + { + if(pHash == NULL) + nError = ERROR_FILE_NOT_FOUND; + } + + // Count the entries which correspond to the same file name + if(nError == ERROR_SUCCESS) + { + TMPQHash * pSaveHash = pHash; + DWORD dwName1 = pHash->dwName1; + DWORD dwName2 = pHash->dwName2; + + // For nameless access, return 1 locale always + if(dwSearchScope == SFILE_OPEN_BY_INDEX) + dwLocales++; + else + { + while(pHash < pHashEnd && pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2) + { + dwLocales++; + pHash++; + } + } + + pHash = pSaveHash; + } + + // Test if there is enough space to copy the locales + if(nError == ERROR_SUCCESS) + { + DWORD dwMaxLocales = *pdwMaxLocales; + + *pdwMaxLocales = dwLocales; + if(dwMaxLocales < dwLocales) + nError = ERROR_INSUFFICIENT_BUFFER; + } + + // Fill all the locales + if(nError == ERROR_SUCCESS) + { + for(DWORD i = 0; i < dwLocales; i++, pHash++) + *plcLocales++ = (LCID)pHash->lcLocale; + } + return nError; +} + +//----------------------------------------------------------------------------- +// SFileHasFile +// +// hMPQ - Handle of opened MPQ archive +// szFileName - Name of file to look for + +// TODO: Test for archives > 4GB +BOOL WINAPI SFileHasFile(HANDLE hMPQ, char * szFileName) +{ + TMPQArchive * ha = (TMPQArchive *)hMPQ; + int nError = ERROR_SUCCESS; + + if(nError == ERROR_SUCCESS) + { + if(ha == NULL) + nError = ERROR_INVALID_PARAMETER; + if(*szFileName == 0) + nError = ERROR_INVALID_PARAMETER; + } + + // Prepare the file opening + if(nError == ERROR_SUCCESS) + { + if(GetHashEntryEx(ha, szFileName, lcLocale) == NULL) + { + nError = ERROR_FILE_NOT_FOUND; + } + } + + // Cleanup + if(nError != ERROR_SUCCESS) + { + SetLastError(nError); + } + + return (nError == ERROR_SUCCESS); +} + + +//----------------------------------------------------------------------------- +// SFileOpenFileEx +// +// hMPQ - Handle of opened MPQ archive +// szFileName - Name of file to open +// dwSearchScope - Where to search +// phFile - Pointer to store opened file handle + +// TODO: Test for archives > 4GB +BOOL WINAPI SFileOpenFileEx(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope, HANDLE * phFile) +{ + LARGE_INTEGER FilePos; + TMPQArchive * ha = (TMPQArchive *)hMPQ; + TMPQFile * hf = NULL; + TMPQHash * pHash = NULL; // Hash table index + TMPQBlock * pBlock = NULL; // File block + TMPQBlockEx * pBlockEx = NULL; + DWORD dwHashIndex = 0; // Hash table index + DWORD dwBlockIndex = (DWORD)-1; // Found table index + size_t nHandleSize = 0; // Memory space necessary to allocate TMPQHandle + int nError = ERROR_SUCCESS; + +#ifdef _DEBUG + // Due to increasing numbers of files in MPQs, I had to change the behavior + // of opening by file index. Now, the SFILE_OPEN_BY_INDEX value of dwSearchScope + // must be entered. This check will allow to find code places that are incompatible + // with the new behavior. + if(dwSearchScope != SFILE_OPEN_BY_INDEX && szFileName != NULL) + { + assert((DWORD_PTR)szFileName > 0x10000); + } +#endif + + if(nError == ERROR_SUCCESS) + { + if(ha == NULL && dwSearchScope == SFILE_OPEN_FROM_MPQ) + nError = ERROR_INVALID_PARAMETER; + if(phFile == NULL) + nError = ERROR_INVALID_PARAMETER; + if(dwSearchScope == SFILE_OPEN_BY_INDEX && (DWORD_PTR)szFileName > ha->pHeader->dwBlockTableSize) + nError = ERROR_INVALID_PARAMETER; + if(dwSearchScope != SFILE_OPEN_BY_INDEX && (szFileName == NULL || *szFileName == 0)) + nError = ERROR_INVALID_PARAMETER; + } + + // Prepare the file opening + if(nError == ERROR_SUCCESS) + { + // When the file is given by number, ... + if(dwSearchScope == SFILE_OPEN_BY_INDEX) + { + TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; + + // Set handle size to be sizeof(TMPQFile) + length of FileXXXXXXXX.xxx + nHandleSize = sizeof(TMPQFile) + 20; + for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) + { + if((DWORD_PTR)szFileName == pHash->dwBlockIndex) + { + dwHashIndex = (DWORD)(pHash - ha->pHashTable); + dwBlockIndex = pHash->dwBlockIndex; + break; + } + } + } + else + { + // If we have to open a disk file + if(dwSearchScope == SFILE_OPEN_LOCAL_FILE) + return OpenLocalFile(szFileName, phFile); + + nHandleSize = sizeof(TMPQFile) + strlen(szFileName); + if((pHash = GetHashEntryEx(ha, szFileName, lcLocale)) != NULL) + { + dwHashIndex = (DWORD)(pHash - ha->pHashTable); + dwBlockIndex = pHash->dwBlockIndex; + } + } + } + + // Get block index from file name and test it + if(nError == ERROR_SUCCESS) + { + // If index was not found, or is greater than number of files, exit. + if(dwBlockIndex == (DWORD)-1 || dwBlockIndex > ha->pHeader->dwBlockTableSize) + nError = ERROR_FILE_NOT_FOUND; + } + + // Get block and test if the file was not already deleted. + if(nError == ERROR_SUCCESS) + { + // Get both block tables and file position + pBlockEx = ha->pExtBlockTable + dwBlockIndex; + pBlock = ha->pBlockTable + dwBlockIndex; + FilePos.HighPart = pBlockEx->wFilePosHigh; + FilePos.LowPart = pBlock->dwFilePos; + + if(FilePos.QuadPart > ha->MpqSize.QuadPart || + pBlock->dwCSize > ha->MpqSize.QuadPart) + nError = ERROR_FILE_CORRUPT; + if((pBlock->dwFlags & MPQ_FILE_EXISTS) == 0) + nError = ERROR_FILE_NOT_FOUND; + if(pBlock->dwFlags & ~MPQ_FILE_VALID_FLAGS) + nError = ERROR_NOT_SUPPORTED; + } + + // Allocate file handle + if(nError == ERROR_SUCCESS) + { + if((hf = (TMPQFile *)ALLOCMEM(char, nHandleSize)) == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Initialize file handle + if(nError == ERROR_SUCCESS) + { + memset(hf, 0, nHandleSize); + hf->hFile = INVALID_HANDLE_VALUE; + hf->ha = ha; + hf->pBlockEx = pBlockEx; + hf->pBlock = pBlock; + hf->nBlocks = (hf->pBlock->dwFSize + ha->dwBlockSize - 1) / ha->dwBlockSize; + hf->pHash = pHash; + + hf->MpqFilePos.HighPart = pBlockEx->wFilePosHigh; + hf->MpqFilePos.LowPart = pBlock->dwFilePos; + hf->MpqFilePos.QuadPart += ha->MpqPos.QuadPart; + + hf->dwHashIndex = dwHashIndex; + hf->dwFileIndex = dwBlockIndex; + + // Allocate buffers for decompression. + if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) + { + // Allocate buffer for block positions. At the begin of file are stored + // DWORDs holding positions of each block relative from begin of file in the archive + // As for newer MPQs, there may be one additional entry in the block table + // (if the MPQ_FILE_HAS_EXTRA flag is set). + // Allocate the buffer to include this DWORD as well + + if((hf->pdwBlockPos = ALLOCMEM(DWORD, hf->nBlocks + 2)) == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Decrypt file seed. Cannot be used if the file is given by index + if(dwSearchScope != SFILE_OPEN_BY_INDEX) + { + if(hf->pBlock->dwFlags & MPQ_FILE_ENCRYPTED) + { + const char * szTemp = strrchr(szFileName, '\\'); + + strcpy(hf->szFileName, szFileName); + if(szTemp != NULL) + szFileName = szTemp + 1; + hf->dwSeed1 = DecryptFileSeed((char *)szFileName); + + if(hf->pBlock->dwFlags & MPQ_FILE_FIXSEED) + { + hf->dwSeed1 = (hf->dwSeed1 + hf->pBlock->dwFilePos) ^ hf->pBlock->dwFSize; + } + } + } + else + { + // If the file is encrypted and not compressed, we cannot detect the file seed + if(SFileGetFileName(hf, hf->szFileName) == FALSE) + nError = GetLastError(); + } + } + + // Cleanup + if(nError != ERROR_SUCCESS) + { + FreeMPQFile(hf); + SetLastError(nError); + } + + *phFile = hf; + return (nError == ERROR_SUCCESS); +} + +//----------------------------------------------------------------------------- +// BOOL SFileCloseFile(HANDLE hFile); + +// TODO: Test for archives > 4GB +BOOL WINAPI SFileCloseFile(HANDLE hFile) +{ + TMPQFile * hf = (TMPQFile *)hFile; + + if(!IsValidFileHandle(hf)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + // Set the last accessed file in the archive + if(hf->ha != NULL) + hf->ha->pLastFile = NULL; + + // Free the structure + FreeMPQFile(hf); + return TRUE; +} diff --git a/src/tools/stuffextract/StormLib/SFileReadFile.cpp b/src/tools/stuffextract/StormLib/SFileReadFile.cpp index 396da83..27fd1e0 100644 --- a/src/tools/stuffextract/StormLib/SFileReadFile.cpp +++ b/src/tools/stuffextract/StormLib/SFileReadFile.cpp @@ -1,826 +1,826 @@ -/*****************************************************************************/ -/* SFileReadFile.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Description : */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.99 1.00 Lad The first version of SFileReadFile.cpp */ -/* 24.03.99 1.00 Lad Added the SFileGetFileInfo function */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -//----------------------------------------------------------------------------- -// Defines - -#define ID_WAVE 0x46464952 // Signature of WAVes for name breaking -#define ID_EXE 0x00005A4D // Signature of executable files - -//----------------------------------------------------------------------------- -// Local structures - -struct TID2Ext -{ - DWORD dwID; - char * szExt; -}; - -//----------------------------------------------------------------------------- -// ReadMPQBlock -// -// hf - MPQ File handle. -// dwBlockPos - Position of block in the file (relative to file begin) -// buffer - Pointer to target buffer to store blocks. -// dwBlockSize - Number of bytes to read. Must be multiplier of block size. -// -// Returns number of bytes read. - -// TODO: Test for archives > 4GB -static DWORD WINAPI ReadMPQBlocks(TMPQFile * hf, DWORD dwBlockPos, BYTE * buffer, DWORD blockBytes) -{ - LARGE_INTEGER FilePos; - TMPQArchive * ha = hf->ha; // Archive handle - BYTE * tempBuffer = NULL; // Buffer for reading compressed data from the file - DWORD dwFilePos = dwBlockPos; // Reading position from the file - DWORD dwToRead; // Number of bytes to read - DWORD blockNum; // Block number (needed for decrypt) - DWORD dwBytesRead = 0; // Total number of bytes read - DWORD bytesRemain = 0; // Number of data bytes remaining up to the end of the file - DWORD nBlocks; // Number of blocks to load - DWORD i; - - // Test parameters. Block position and block size must be block-aligned, block size nonzero - if((dwBlockPos & (ha->dwBlockSize - 1)) || blockBytes == 0) - return 0; - - // Check the end of file - if((dwBlockPos + blockBytes) > hf->pBlock->dwFSize) - blockBytes = hf->pBlock->dwFSize - dwBlockPos; - - bytesRemain = hf->pBlock->dwFSize - dwBlockPos; - blockNum = dwBlockPos / ha->dwBlockSize; - nBlocks = blockBytes / ha->dwBlockSize; - if(blockBytes % ha->dwBlockSize) - nBlocks++; - - // If file has variable block positions, we have to load them - if((hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) && hf->bBlockPosLoaded == FALSE) - { - // Move file pointer to the begin of the file in the MPQ - if(hf->MpqFilePos.QuadPart != ha->FilePointer.QuadPart) - { - SetFilePointer(ha->hFile, hf->MpqFilePos.LowPart, &hf->MpqFilePos.HighPart, FILE_BEGIN); - } - - // Read block positions from begin of file. - dwToRead = (hf->nBlocks+1) * sizeof(DWORD); - if(hf->pBlock->dwFlags & MPQ_FILE_HAS_EXTRA) - dwToRead += sizeof(DWORD); - - // Read the block pos table and convert the buffer to little endian - ReadFile(ha->hFile, hf->pdwBlockPos, dwToRead, &dwBytesRead, NULL); - BSWAP_ARRAY32_UNSIGNED(hf->pdwBlockPos, (hf->nBlocks+1)); - - // - // If the archive if protected some way, perform additional check - // Sometimes, the file appears not to be encrypted, but it is. - // - // Note: In WoW 1.10+, there's a new flag. With this flag present, - // there's one additional entry in the block table. - // - - if(hf->pdwBlockPos[0] != dwBytesRead) - hf->pBlock->dwFlags |= MPQ_FILE_ENCRYPTED; - - // Decrypt loaded block positions if necessary - if(hf->pBlock->dwFlags & MPQ_FILE_ENCRYPTED) - { - // If we don't know the file seed, try to find it. - if(hf->dwSeed1 == 0) - hf->dwSeed1 = DetectFileSeed(hf->pdwBlockPos, dwBytesRead); - - // If we don't know the file seed, sorry but we cannot extract the file. - if(hf->dwSeed1 == 0) - return 0; - - // Decrypt block positions - DecryptMPQBlock(hf->pdwBlockPos, dwBytesRead, hf->dwSeed1 - 1); - - // Check if the block positions are correctly decrypted - // I don't know why, but sometimes it will result invalid block positions on some files - if(hf->pdwBlockPos[0] != dwBytesRead) - { - // Try once again to detect file seed and decrypt the blocks - // TODO: Test with >4GB - SetFilePointer(ha->hFile, hf->MpqFilePos.LowPart, &hf->MpqFilePos.HighPart, FILE_BEGIN); - ReadFile(ha->hFile, hf->pdwBlockPos, dwToRead, &dwBytesRead, NULL); - - BSWAP_ARRAY32_UNSIGNED(hf->pdwBlockPos, (hf->nBlocks+1)); - hf->dwSeed1 = DetectFileSeed(hf->pdwBlockPos, dwBytesRead); - DecryptMPQBlock(hf->pdwBlockPos, dwBytesRead, hf->dwSeed1 - 1); - - // Check if the block positions are correctly decrypted - if(hf->pdwBlockPos[0] != dwBytesRead) - return 0; - } - } - - // Update hf's variables - ha->FilePointer.QuadPart = hf->MpqFilePos.QuadPart + dwBytesRead; - hf->bBlockPosLoaded = TRUE; - } - - // Get file position and number of bytes to read - dwFilePos = dwBlockPos; - dwToRead = blockBytes; - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) - { - dwFilePos = hf->pdwBlockPos[blockNum]; - dwToRead = hf->pdwBlockPos[blockNum + nBlocks] - dwFilePos; - } - FilePos.QuadPart = hf->MpqFilePos.QuadPart + dwFilePos; - - // Get work buffer for store read data - tempBuffer = buffer; - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) - { - if((tempBuffer = ALLOCMEM(BYTE, dwToRead)) == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - } - - // Set file pointer, if necessary - if(ha->FilePointer.QuadPart != FilePos.QuadPart) - { - SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN); - } - - // 15018F87 : Read all requested blocks - ReadFile(ha->hFile, tempBuffer, dwToRead, &dwBytesRead, NULL); - ha->FilePointer.QuadPart = FilePos.QuadPart + dwBytesRead; - - // Block processing part. - DWORD blockStart = 0; // Index of block start in work buffer - DWORD blockSize = min(blockBytes, ha->dwBlockSize); - DWORD index = blockNum; // Current block index - - dwBytesRead = 0; // Clear read byte counter - - // Walk through all blocks - for(i = 0; i < nBlocks; i++, index++) - { - BYTE * inputBuffer = tempBuffer + blockStart; - int outLength = ha->dwBlockSize; - - if(bytesRemain < (DWORD)outLength) - outLength = bytesRemain; - - // Get current block length - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) - blockSize = hf->pdwBlockPos[index+1] - hf->pdwBlockPos[index]; - - // If block is encrypted, we have to decrypt it. - if(hf->pBlock->dwFlags & MPQ_FILE_ENCRYPTED) - { - BSWAP_ARRAY32_UNSIGNED((DWORD *)inputBuffer, blockSize / sizeof(DWORD)); - - // If we don't know the seed, try to decode it as WAVE file - if(hf->dwSeed1 == 0) - hf->dwSeed1 = DetectFileSeed2((DWORD *)inputBuffer, 3, ID_WAVE, hf->pBlock->dwFSize - 8, 0x45564157); - - // Let's try MSVC's standard EXE or header - if(hf->dwSeed1 == 0) - hf->dwSeed1 = DetectFileSeed2((DWORD *)inputBuffer, 2, 0x00905A4D, 0x00000003); - - if(hf->dwSeed1 == 0) - return 0; - - DecryptMPQBlock((DWORD *)inputBuffer, blockSize, hf->dwSeed1 + index); - BSWAP_ARRAY32_UNSIGNED((DWORD *)inputBuffer, blockSize / sizeof(DWORD)); - } - - // If the block is really compressed, decompress it. - // WARNING : Some block may not be compressed, it can be determined only - // by comparing uncompressed and compressed size !!! - if(blockSize < (DWORD)outLength) - { - // Is the file compressed with PKWARE Data Compression Library ? - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESS_PKWARE) - Decompress_pklib((char *)buffer, &outLength, (char *)inputBuffer, (int)blockSize); - - // Is it a file compressed by Blizzard's multiple compression ? - // Note that Storm.dll v 1.0.9 distributed with Warcraft III - // passes the full path name of the opened archive as the new last parameter - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESS_MULTI) - SCompDecompress((char *)buffer, &outLength, (char *)inputBuffer, (int)blockSize); - dwBytesRead += outLength; - buffer += outLength; - } - else - { - if(buffer != inputBuffer) - memcpy(buffer, inputBuffer, blockSize); - - dwBytesRead += blockSize; - buffer += blockSize; - } - blockStart += blockSize; - bytesRemain -= outLength; - } - - // Delete input buffer, if necessary - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) - FREEMEM(tempBuffer); - - return dwBytesRead; -} - -// When this function is called, it is already ensured that the parameters are valid -// (e.g. the "dwToRead + dwFilePos" is not greater than the file size) -// TODO: Test for archives > 4GB -static DWORD WINAPI ReadMPQFileSingleUnit(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer, DWORD dwToRead) -{ - TMPQArchive * ha = hf->ha; - DWORD dwBytesRead = 0; - - if(ha->FilePointer.QuadPart != hf->MpqFilePos.QuadPart) - { - SetFilePointer(ha->hFile, hf->MpqFilePos.LowPart, &hf->MpqFilePos.HighPart, FILE_BEGIN); - ha->FilePointer = hf->MpqFilePos; - } - - // If the file is really compressed, decompress it. - // Otherwise, read the data as-is to the caller. - if(hf->pBlock->dwCSize < hf->pBlock->dwFSize) - { - if(hf->pbFileBuffer == NULL) - { - BYTE * inputBuffer = NULL; - int outputBufferSize = (int)hf->pBlock->dwFSize; - int inputBufferSize = (int)hf->pBlock->dwCSize; - - hf->pbFileBuffer = ALLOCMEM(BYTE, outputBufferSize); - inputBuffer = ALLOCMEM(BYTE, inputBufferSize); - if(inputBuffer != NULL && hf->pbFileBuffer != NULL) - { - // Read the compressed file data - ReadFile(ha->hFile, inputBuffer, inputBufferSize, &dwBytesRead, NULL); - - // Is the file compressed with PKWARE Data Compression Library ? - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESS_PKWARE) - Decompress_pklib((char *)hf->pbFileBuffer, &outputBufferSize, (char *)inputBuffer, (int)inputBufferSize); - - // Is it a file compressed by Blizzard's multiple compression ? - // Note that Storm.dll v 1.0.9 distributed with Warcraft III - // passes the full path name of the opened archive as the new last parameter - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESS_MULTI) - SCompDecompress((char *)hf->pbFileBuffer, &outputBufferSize, (char *)inputBuffer, (int)inputBufferSize); - } - - // Free the temporary buffer - if(inputBuffer != NULL) - FREEMEM(inputBuffer); - } - - // Copy the file data, if any there - if(hf->pbFileBuffer != NULL) - { - memcpy(pbBuffer, hf->pbFileBuffer + dwFilePos, dwToRead); - dwBytesRead += dwToRead; - } - } - else - { - // Read the uncompressed file data - ReadFile(ha->hFile, pbBuffer, dwToRead, &dwBytesRead, NULL); - dwBytesRead = (int)dwBytesRead; - } - - return (DWORD)dwBytesRead; -} - - -//----------------------------------------------------------------------------- -// ReadMPQFile - -// TODO: Test for archives > 4GB -static DWORD WINAPI ReadMPQFile(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer, DWORD dwToRead) -{ - TMPQArchive * ha = hf->ha; - TMPQBlock * pBlock = hf->pBlock; // Pointer to file block - DWORD dwBytesRead = 0; // Number of bytes read from the file - DWORD dwBlockPos; // Position in the file aligned to the whole blocks - DWORD dwLoaded; - - // File position is greater or equal to file size ? - if(dwFilePos >= pBlock->dwFSize) - return dwBytesRead; - - // If too few bytes in the file remaining, cut them - if((pBlock->dwFSize - dwFilePos) < dwToRead) - dwToRead = (pBlock->dwFSize - dwFilePos); - - // If the file is stored as single unit, handle it separately - if(pBlock->dwFlags & MPQ_FILE_SINGLE_UNIT) - return ReadMPQFileSingleUnit(hf, dwFilePos, pbBuffer, dwToRead); - - // Block position in the file - dwBlockPos = dwFilePos & ~(ha->dwBlockSize - 1); // Position in the block - - // Load the first block, if incomplete. It may be loaded in the cache buffer. - // We have to check if this block is loaded. If not, load it. - if((dwFilePos % ha->dwBlockSize) != 0) - { - // Number of bytes remaining in the buffer - DWORD dwToCopy; - DWORD dwLoaded = ha->dwBlockSize; - - // Check if data are loaded in the cache - if(hf != ha->pLastFile || dwBlockPos != ha->dwBlockPos) - { - // Load one MPQ block into archive buffer - dwLoaded = ReadMPQBlocks(hf, dwBlockPos, ha->pbBlockBuffer, ha->dwBlockSize); - if(dwLoaded == 0) - return (DWORD)-1; - - // Save lastly accessed file and block position for later use - ha->pLastFile = hf; - ha->dwBlockPos = dwBlockPos; - ha->dwBuffPos = dwFilePos % ha->dwBlockSize; - } - dwToCopy = dwLoaded - ha->dwBuffPos; - if(dwToCopy > dwToRead) - dwToCopy = dwToRead; - - // Copy data from block buffer into target buffer - memcpy(pbBuffer, ha->pbBlockBuffer + ha->dwBuffPos, dwToCopy); - - // Update pointers - dwToRead -= dwToCopy; - dwBytesRead += dwToCopy; - pbBuffer += dwToCopy; - dwBlockPos += ha->dwBlockSize; - ha->dwBuffPos += dwToCopy; - - // If all, return. - if(dwToRead == 0) - return dwBytesRead; - } - - // Load the whole ("middle") blocks only if there are more or equal one block - if(dwToRead > ha->dwBlockSize) - { - DWORD dwBlockBytes = dwToRead & ~(ha->dwBlockSize - 1); - - dwLoaded = ReadMPQBlocks(hf, dwBlockPos, pbBuffer, dwBlockBytes); - if(dwLoaded == 0) - return (DWORD)-1; - - // Update pointers - dwToRead -= dwLoaded; - dwBytesRead += dwLoaded; - pbBuffer += dwLoaded; - dwBlockPos += dwLoaded; - - // If all, return. - if(dwToRead == 0) - return dwBytesRead; - } - - // Load the terminating block - if(dwToRead > 0) - { - DWORD dwToCopy = ha->dwBlockSize; - - // Check if data are loaded in the cache - if(hf != ha->pLastFile || dwBlockPos != ha->dwBlockPos) - { - // Load one MPQ block into archive buffer - dwToCopy = ReadMPQBlocks(hf, dwBlockPos, ha->pbBlockBuffer, ha->dwBlockSize); - if(dwToCopy == 0) - return (DWORD)-1; - - // Save lastly accessed file and block position for later use - ha->pLastFile = hf; - ha->dwBlockPos = dwBlockPos; - } - ha->dwBuffPos = 0; - - // Check number of bytes read - if(dwToCopy > dwToRead) - dwToCopy = dwToRead; - - memcpy(pbBuffer, ha->pbBlockBuffer, dwToCopy); - dwBytesRead += dwToCopy; - ha->dwBuffPos = dwToCopy; - } - - // Return what we've read - return dwBytesRead; -} - -//----------------------------------------------------------------------------- -// SFileReadFile - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileReadFile(HANDLE hFile, VOID * lpBuffer, DWORD dwToRead, DWORD * pdwRead, LPOVERLAPPED lpOverlapped) -{ - TMPQFile * hf = (TMPQFile *)hFile; - DWORD dwBytes = 0; // Number of bytes (for everything) - int nError = ERROR_SUCCESS; - - // Zero the number of bytes read - if(pdwRead != NULL) - *pdwRead = 0; - - // Check valid parameters - if(nError == ERROR_SUCCESS) - { - if(hf == NULL || lpBuffer == NULL) - nError = ERROR_INVALID_PARAMETER; - } - - // If direct access to the file, use Win32 for reading - if(nError == ERROR_SUCCESS && hf->hFile != INVALID_HANDLE_VALUE) - { - DWORD dwTransferred; - - ReadFile(hf->hFile, lpBuffer, dwToRead, &dwTransferred, lpOverlapped); - if(dwTransferred < dwToRead) - { - SetLastError(ERROR_HANDLE_EOF); - return FALSE; - } - - if(pdwRead != NULL) - *pdwRead = dwTransferred; - return TRUE; - } - - // Read all the bytes available in the buffer (If any) - if(nError == ERROR_SUCCESS) - { - if(dwToRead > 0) - { - dwBytes = ReadMPQFile(hf, hf->dwFilePos, (BYTE *)lpBuffer, dwToRead); - if(dwBytes == (DWORD)-1) - { - SetLastError(ERROR_CAN_NOT_COMPLETE); - return FALSE; - } - hf->ha->pLastFile = hf; - hf->dwFilePos += dwBytes; - } - if(pdwRead != NULL) - *pdwRead = dwBytes; - } - - // Check number of bytes read. If not OK, return FALSE. - if(dwBytes < dwToRead) - { - SetLastError(ERROR_HANDLE_EOF); - return FALSE; - } - return TRUE; -} - -//----------------------------------------------------------------------------- -// SFileGetFilePos -// -// Returns position of archive file in the archive (relative to begin of file) - -// TODO: Test for archives > 4GB -DWORD WINAPI SFileGetFilePos(HANDLE hFile, DWORD * pdwFilePosHigh) -{ - TMPQFile * hf = (TMPQFile *)hFile; - - if(pdwFilePosHigh != NULL) - *pdwFilePosHigh = 0; - - if(hf == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return (DWORD)-1; - } - - // If opened as plain file, ... - if(hf->hFile != INVALID_HANDLE_VALUE) - return 0; - - // If opened from archive, return file size - if(pdwFilePosHigh != NULL) - *pdwFilePosHigh = hf->MpqFilePos.HighPart; - return hf->MpqFilePos.LowPart; -} - -//----------------------------------------------------------------------------- -// SFileGetFileSize - -// TODO: Test for archives > 4GB -DWORD WINAPI SFileGetFileSize(HANDLE hFile, DWORD * pdwFileSizeHigh) -{ - TMPQFile * hf = (TMPQFile *)hFile; - - if(pdwFileSizeHigh != NULL) - *pdwFileSizeHigh = 0; - - if(hf == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return (DWORD)-1; - } - - // If opened as plain file, ... - if(hf->hFile != INVALID_HANDLE_VALUE) - return GetFileSize(hf->hFile, pdwFileSizeHigh); - - // If opened from archive, return file size - return hf->pBlock->dwFSize; -} - -// TODO: Test for archives > 4GB -DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * pdwFilePosHigh, DWORD dwMethod) -{ - TMPQArchive * ha; - TMPQFile * hf = (TMPQFile *)hFile; - - if(hf == NULL || (pdwFilePosHigh != NULL && *pdwFilePosHigh != 0)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return (DWORD)-1; - } - - // If opened as plain file, call Win32 API - if(hf->hFile != INVALID_HANDLE_VALUE) - return SetFilePointer(hf->hFile, lFilePos, pdwFilePosHigh, dwMethod); - ha = hf->ha; - - switch(dwMethod) - { - case FILE_BEGIN: - // Cannot set pointer before begin of file - if(-lFilePos > (LONG)hf->dwFilePos) - hf->dwFilePos = 0; - else - hf->dwFilePos = lFilePos; - break; - - case FILE_CURRENT: - // Cannot set pointer before begin of file - if(-lFilePos > (LONG)hf->dwFilePos) - hf->dwFilePos = 0; - else - hf->dwFilePos += lFilePos; - break; - - case FILE_END: - // Cannot set file position before begin of file - if(-lFilePos >= (LONG)hf->pBlock->dwFSize) - hf->dwFilePos = 0; - else - hf->dwFilePos = hf->pBlock->dwFSize + lFilePos; - break; - - default: - return ERROR_INVALID_PARAMETER; - } - - if(hf == ha->pLastFile && (hf->dwFilePos & ~(ha->dwBlockSize - 1)) == ha->dwBlockPos) - ha->dwBuffPos = hf->dwFilePos & (ha->dwBlockSize - 1); - else - { - ha->pLastFile = NULL; - ha->dwBuffPos = 0; - } - - return hf->dwFilePos; -} - -//----------------------------------------------------------------------------- -// Tries to retrieve the file name - -static TID2Ext id2ext[] = -{ - {0x1A51504D, "mpq"}, // MPQ archive header ID ('MPQ\x1A') - {0x46464952, "wav"}, // WAVE header 'RIFF' - {0x324B4D53, "smk"}, // Old "Smacker Video" files 'SMK2' - {0x694B4942, "bik"}, // Bink video files (new) - {0x0801050A, "pcx"}, // PCX images used in Diablo I - {0x544E4F46, "fnt"}, // Font files used in Diablo II - {0x6D74683C, "html"}, // HTML ' 4GB -BOOL WINAPI SFileGetFileName(HANDLE hFile, char * szFileName) -{ - TMPQFile * hf = (TMPQFile *)hFile; // MPQ File handle - char * szExt = "xxx"; // Default extension - DWORD dwFirstBytes[2]; // The first 4 bytes of the file - DWORD dwFilePos; // Saved file position - int nError = ERROR_SUCCESS; - int i; - - // Pre-zero the output buffer - if(szFileName != NULL) - *szFileName = 0; - - // Check valid parameters - if(nError == ERROR_SUCCESS) - { - if(hf == NULL || szFileName == NULL) - nError = ERROR_INVALID_PARAMETER; - } - - // If the file name is already filled, return it. - if(nError == ERROR_SUCCESS && *hf->szFileName != 0) - { - if(szFileName != hf->szFileName) - strcpy(szFileName, hf->szFileName); - return TRUE; - } - - if(nError == ERROR_SUCCESS) - { - if(hf->dwFileIndex == (DWORD)-1) - nError = ERROR_CAN_NOT_COMPLETE; - } - - // Read the first 8 bytes from the file - if(nError == ERROR_SUCCESS) - { - dwFirstBytes[0] = dwFirstBytes[1] = 0; - dwFilePos = SFileSetFilePointer(hf, 0, NULL, FILE_CURRENT); - if(!SFileReadFile(hFile, &dwFirstBytes, sizeof(dwFirstBytes), NULL)) - nError = GetLastError(); - BSWAP_ARRAY32_UNSIGNED(dwFirstBytes, sizeof(dwFirstBytes) / sizeof(DWORD)); - SFileSetFilePointer(hf, dwFilePos, NULL, FILE_BEGIN); - } - - if(nError == ERROR_SUCCESS) - { - if((dwFirstBytes[0] & 0x0000FFFF) == ID_EXE) - szExt = "exe"; - else if(dwFirstBytes[0] == 0x00000006 && dwFirstBytes[1] == 0x00000001) - szExt = "dc6"; - else - { - for(i = 0; id2ext[i].szExt != NULL; i++) - { - if(id2ext[i].dwID == dwFirstBytes[0]) - { - szExt = id2ext[i].szExt; - break; - } - } - } - - // Create the file name - sprintf(hf->szFileName, "File%08lu.%s", hf->dwFileIndex, szExt); - if(szFileName != hf->szFileName) - strcpy(szFileName, hf->szFileName); - } - return (nError == ERROR_SUCCESS); -} - -//----------------------------------------------------------------------------- -// Retrieves an information about an archive or about a file within the archive -// -// hMpqOrFile - Handle to an MPQ archive or to a file -// dwInfoType - Information to obtain - -// TODO: Test for archives > 4GB -DWORD_PTR WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, DWORD dwInfoType) -{ - TMPQArchive * ha = (TMPQArchive *)hMpqOrFile; - TMPQFile * hf = (TMPQFile *)hMpqOrFile; - TMPQBlock * pBlockEnd; - TMPQBlock * pBlock; - DWORD dwFileCount = 0; - DWORD dwSeed; - - switch(dwInfoType) - { - case SFILE_INFO_ARCHIVE_SIZE: - if(IsValidMpqHandle(ha)) - return ha->pHeader->dwArchiveSize; - break; - - case SFILE_INFO_HASH_TABLE_SIZE: // Size of the hash table - if(IsValidMpqHandle(ha)) - return ha->pHeader->dwHashTableSize; - break; - - case SFILE_INFO_BLOCK_TABLE_SIZE: // Size of the hash table - if(IsValidMpqHandle(ha)) - return ha->pHeader->dwBlockTableSize; - break; - - case SFILE_INFO_BLOCK_SIZE: - if(IsValidMpqHandle(ha)) - return ha->dwBlockSize; - break; - - case SFILE_INFO_HASH_TABLE: - if(IsValidMpqHandle(ha)) - return (DWORD_PTR)ha->pHashTable; - break; - - case SFILE_INFO_BLOCK_TABLE: - if(IsValidMpqHandle(ha)) - return (DWORD_PTR)ha->pBlockTable; - break; - - case SFILE_INFO_NUM_FILES: - if(IsValidMpqHandle(ha)) - { - pBlockEnd = ha->pBlockTable + ha->pHeader->dwBlockTableSize; - for(pBlock = ha->pBlockTable; pBlock < pBlockEnd; pBlock++) - { - if(pBlock->dwFlags & MPQ_FILE_EXISTS) - dwFileCount++; - } - return dwFileCount; - } - break; - - case SFILE_INFO_HASH_INDEX: - if(IsValidFileHandle(hf)) - return hf->dwHashIndex; - break; - - case SFILE_INFO_CODENAME1: - if(IsValidFileHandle(hf)) - return hf->pHash->dwName1; - break; - - case SFILE_INFO_CODENAME2: - if(IsValidFileHandle(hf)) - return hf->pHash->dwName2; - break; - - case SFILE_INFO_LOCALEID: - if(IsValidFileHandle(hf)) - return hf->pHash->lcLocale; - break; - - case SFILE_INFO_BLOCKINDEX: - if(IsValidFileHandle(hf)) - return hf->dwFileIndex; - break; - - case SFILE_INFO_FILE_SIZE: - if(IsValidFileHandle(hf)) - return hf->pBlock->dwFSize; - break; - - case SFILE_INFO_COMPRESSED_SIZE: - if(IsValidFileHandle(hf)) - return hf->pBlock->dwCSize; - break; - - case SFILE_INFO_FLAGS: - if(IsValidFileHandle(hf)) - return hf->pBlock->dwFlags; - break; - - case SFILE_INFO_POSITION: - if(IsValidFileHandle(hf)) - return hf->pBlock->dwFilePos; - break; - - case SFILE_INFO_SEED: - if(IsValidFileHandle(hf)) - return hf->dwSeed1; - break; - - case SFILE_INFO_SEED_UNFIXED: - if(IsValidFileHandle(hf)) - { - dwSeed = hf->dwSeed1; - if(hf->pBlock->dwFlags & MPQ_FILE_FIXSEED) - dwSeed = (dwSeed ^ hf->pBlock->dwFSize) - (DWORD)(hf->MpqFilePos.QuadPart - hf->ha->MpqPos.QuadPart); - return dwSeed; - } - break; - } - - // Unknown parameter or invalid handle - SetLastError(ERROR_INVALID_PARAMETER); - return 0xFFFFFFFF; -} +/*****************************************************************************/ +/* SFileReadFile.cpp Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* Description : */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* xx.xx.99 1.00 Lad The first version of SFileReadFile.cpp */ +/* 24.03.99 1.00 Lad Added the SFileGetFileInfo function */ +/*****************************************************************************/ + +#define __STORMLIB_SELF__ +#include "StormLib.h" +#include "SCommon.h" + +//----------------------------------------------------------------------------- +// Defines + +#define ID_WAVE 0x46464952 // Signature of WAVes for name breaking +#define ID_EXE 0x00005A4D // Signature of executable files + +//----------------------------------------------------------------------------- +// Local structures + +struct TID2Ext +{ + DWORD dwID; + char * szExt; +}; + +//----------------------------------------------------------------------------- +// ReadMPQBlock +// +// hf - MPQ File handle. +// dwBlockPos - Position of block in the file (relative to file begin) +// buffer - Pointer to target buffer to store blocks. +// dwBlockSize - Number of bytes to read. Must be multiplier of block size. +// +// Returns number of bytes read. + +// TODO: Test for archives > 4GB +static DWORD WINAPI ReadMPQBlocks(TMPQFile * hf, DWORD dwBlockPos, BYTE * buffer, DWORD blockBytes) +{ + LARGE_INTEGER FilePos; + TMPQArchive * ha = hf->ha; // Archive handle + BYTE * tempBuffer = NULL; // Buffer for reading compressed data from the file + DWORD dwFilePos = dwBlockPos; // Reading position from the file + DWORD dwToRead; // Number of bytes to read + DWORD blockNum; // Block number (needed for decrypt) + DWORD dwBytesRead = 0; // Total number of bytes read + DWORD bytesRemain = 0; // Number of data bytes remaining up to the end of the file + DWORD nBlocks; // Number of blocks to load + DWORD i; + + // Test parameters. Block position and block size must be block-aligned, block size nonzero + if((dwBlockPos & (ha->dwBlockSize - 1)) || blockBytes == 0) + return 0; + + // Check the end of file + if((dwBlockPos + blockBytes) > hf->pBlock->dwFSize) + blockBytes = hf->pBlock->dwFSize - dwBlockPos; + + bytesRemain = hf->pBlock->dwFSize - dwBlockPos; + blockNum = dwBlockPos / ha->dwBlockSize; + nBlocks = blockBytes / ha->dwBlockSize; + if(blockBytes % ha->dwBlockSize) + nBlocks++; + + // If file has variable block positions, we have to load them + if((hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) && hf->bBlockPosLoaded == FALSE) + { + // Move file pointer to the begin of the file in the MPQ + if(hf->MpqFilePos.QuadPart != ha->FilePointer.QuadPart) + { + SetFilePointer(ha->hFile, hf->MpqFilePos.LowPart, &hf->MpqFilePos.HighPart, FILE_BEGIN); + } + + // Read block positions from begin of file. + dwToRead = (hf->nBlocks+1) * sizeof(DWORD); + if(hf->pBlock->dwFlags & MPQ_FILE_HAS_EXTRA) + dwToRead += sizeof(DWORD); + + // Read the block pos table and convert the buffer to little endian + ReadFile(ha->hFile, hf->pdwBlockPos, dwToRead, &dwBytesRead, NULL); + BSWAP_ARRAY32_UNSIGNED(hf->pdwBlockPos, (hf->nBlocks+1)); + + // + // If the archive if protected some way, perform additional check + // Sometimes, the file appears not to be encrypted, but it is. + // + // Note: In WoW 1.10+, there's a new flag. With this flag present, + // there's one additional entry in the block table. + // + + if(hf->pdwBlockPos[0] != dwBytesRead) + hf->pBlock->dwFlags |= MPQ_FILE_ENCRYPTED; + + // Decrypt loaded block positions if necessary + if(hf->pBlock->dwFlags & MPQ_FILE_ENCRYPTED) + { + // If we don't know the file seed, try to find it. + if(hf->dwSeed1 == 0) + hf->dwSeed1 = DetectFileSeed(hf->pdwBlockPos, dwBytesRead); + + // If we don't know the file seed, sorry but we cannot extract the file. + if(hf->dwSeed1 == 0) + return 0; + + // Decrypt block positions + DecryptMPQBlock(hf->pdwBlockPos, dwBytesRead, hf->dwSeed1 - 1); + + // Check if the block positions are correctly decrypted + // I don't know why, but sometimes it will result invalid block positions on some files + if(hf->pdwBlockPos[0] != dwBytesRead) + { + // Try once again to detect file seed and decrypt the blocks + // TODO: Test with >4GB + SetFilePointer(ha->hFile, hf->MpqFilePos.LowPart, &hf->MpqFilePos.HighPart, FILE_BEGIN); + ReadFile(ha->hFile, hf->pdwBlockPos, dwToRead, &dwBytesRead, NULL); + + BSWAP_ARRAY32_UNSIGNED(hf->pdwBlockPos, (hf->nBlocks+1)); + hf->dwSeed1 = DetectFileSeed(hf->pdwBlockPos, dwBytesRead); + DecryptMPQBlock(hf->pdwBlockPos, dwBytesRead, hf->dwSeed1 - 1); + + // Check if the block positions are correctly decrypted + if(hf->pdwBlockPos[0] != dwBytesRead) + return 0; + } + } + + // Update hf's variables + ha->FilePointer.QuadPart = hf->MpqFilePos.QuadPart + dwBytesRead; + hf->bBlockPosLoaded = TRUE; + } + + // Get file position and number of bytes to read + dwFilePos = dwBlockPos; + dwToRead = blockBytes; + if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) + { + dwFilePos = hf->pdwBlockPos[blockNum]; + dwToRead = hf->pdwBlockPos[blockNum + nBlocks] - dwFilePos; + } + FilePos.QuadPart = hf->MpqFilePos.QuadPart + dwFilePos; + + // Get work buffer for store read data + tempBuffer = buffer; + if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) + { + if((tempBuffer = ALLOCMEM(BYTE, dwToRead)) == NULL) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + } + + // Set file pointer, if necessary + if(ha->FilePointer.QuadPart != FilePos.QuadPart) + { + SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN); + } + + // 15018F87 : Read all requested blocks + ReadFile(ha->hFile, tempBuffer, dwToRead, &dwBytesRead, NULL); + ha->FilePointer.QuadPart = FilePos.QuadPart + dwBytesRead; + + // Block processing part. + DWORD blockStart = 0; // Index of block start in work buffer + DWORD blockSize = min(blockBytes, ha->dwBlockSize); + DWORD index = blockNum; // Current block index + + dwBytesRead = 0; // Clear read byte counter + + // Walk through all blocks + for(i = 0; i < nBlocks; i++, index++) + { + BYTE * inputBuffer = tempBuffer + blockStart; + int outLength = ha->dwBlockSize; + + if(bytesRemain < (DWORD)outLength) + outLength = bytesRemain; + + // Get current block length + if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) + blockSize = hf->pdwBlockPos[index+1] - hf->pdwBlockPos[index]; + + // If block is encrypted, we have to decrypt it. + if(hf->pBlock->dwFlags & MPQ_FILE_ENCRYPTED) + { + BSWAP_ARRAY32_UNSIGNED((DWORD *)inputBuffer, blockSize / sizeof(DWORD)); + + // If we don't know the seed, try to decode it as WAVE file + if(hf->dwSeed1 == 0) + hf->dwSeed1 = DetectFileSeed2((DWORD *)inputBuffer, 3, ID_WAVE, hf->pBlock->dwFSize - 8, 0x45564157); + + // Let's try MSVC's standard EXE or header + if(hf->dwSeed1 == 0) + hf->dwSeed1 = DetectFileSeed2((DWORD *)inputBuffer, 2, 0x00905A4D, 0x00000003); + + if(hf->dwSeed1 == 0) + return 0; + + DecryptMPQBlock((DWORD *)inputBuffer, blockSize, hf->dwSeed1 + index); + BSWAP_ARRAY32_UNSIGNED((DWORD *)inputBuffer, blockSize / sizeof(DWORD)); + } + + // If the block is really compressed, decompress it. + // WARNING : Some block may not be compressed, it can be determined only + // by comparing uncompressed and compressed size !!! + if(blockSize < (DWORD)outLength) + { + // Is the file compressed with PKWARE Data Compression Library ? + if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESS_PKWARE) + Decompress_pklib((char *)buffer, &outLength, (char *)inputBuffer, (int)blockSize); + + // Is it a file compressed by Blizzard's multiple compression ? + // Note that Storm.dll v 1.0.9 distributed with Warcraft III + // passes the full path name of the opened archive as the new last parameter + if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESS_MULTI) + SCompDecompress((char *)buffer, &outLength, (char *)inputBuffer, (int)blockSize); + dwBytesRead += outLength; + buffer += outLength; + } + else + { + if(buffer != inputBuffer) + memcpy(buffer, inputBuffer, blockSize); + + dwBytesRead += blockSize; + buffer += blockSize; + } + blockStart += blockSize; + bytesRemain -= outLength; + } + + // Delete input buffer, if necessary + if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) + FREEMEM(tempBuffer); + + return dwBytesRead; +} + +// When this function is called, it is already ensured that the parameters are valid +// (e.g. the "dwToRead + dwFilePos" is not greater than the file size) +// TODO: Test for archives > 4GB +static DWORD WINAPI ReadMPQFileSingleUnit(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer, DWORD dwToRead) +{ + TMPQArchive * ha = hf->ha; + DWORD dwBytesRead = 0; + + if(ha->FilePointer.QuadPart != hf->MpqFilePos.QuadPart) + { + SetFilePointer(ha->hFile, hf->MpqFilePos.LowPart, &hf->MpqFilePos.HighPart, FILE_BEGIN); + ha->FilePointer = hf->MpqFilePos; + } + + // If the file is really compressed, decompress it. + // Otherwise, read the data as-is to the caller. + if(hf->pBlock->dwCSize < hf->pBlock->dwFSize) + { + if(hf->pbFileBuffer == NULL) + { + BYTE * inputBuffer = NULL; + int outputBufferSize = (int)hf->pBlock->dwFSize; + int inputBufferSize = (int)hf->pBlock->dwCSize; + + hf->pbFileBuffer = ALLOCMEM(BYTE, outputBufferSize); + inputBuffer = ALLOCMEM(BYTE, inputBufferSize); + if(inputBuffer != NULL && hf->pbFileBuffer != NULL) + { + // Read the compressed file data + ReadFile(ha->hFile, inputBuffer, inputBufferSize, &dwBytesRead, NULL); + + // Is the file compressed with PKWARE Data Compression Library ? + if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESS_PKWARE) + Decompress_pklib((char *)hf->pbFileBuffer, &outputBufferSize, (char *)inputBuffer, (int)inputBufferSize); + + // Is it a file compressed by Blizzard's multiple compression ? + // Note that Storm.dll v 1.0.9 distributed with Warcraft III + // passes the full path name of the opened archive as the new last parameter + if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESS_MULTI) + SCompDecompress((char *)hf->pbFileBuffer, &outputBufferSize, (char *)inputBuffer, (int)inputBufferSize); + } + + // Free the temporary buffer + if(inputBuffer != NULL) + FREEMEM(inputBuffer); + } + + // Copy the file data, if any there + if(hf->pbFileBuffer != NULL) + { + memcpy(pbBuffer, hf->pbFileBuffer + dwFilePos, dwToRead); + dwBytesRead += dwToRead; + } + } + else + { + // Read the uncompressed file data + ReadFile(ha->hFile, pbBuffer, dwToRead, &dwBytesRead, NULL); + dwBytesRead = (int)dwBytesRead; + } + + return (DWORD)dwBytesRead; +} + + +//----------------------------------------------------------------------------- +// ReadMPQFile + +// TODO: Test for archives > 4GB +static DWORD WINAPI ReadMPQFile(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer, DWORD dwToRead) +{ + TMPQArchive * ha = hf->ha; + TMPQBlock * pBlock = hf->pBlock; // Pointer to file block + DWORD dwBytesRead = 0; // Number of bytes read from the file + DWORD dwBlockPos; // Position in the file aligned to the whole blocks + DWORD dwLoaded; + + // File position is greater or equal to file size ? + if(dwFilePos >= pBlock->dwFSize) + return dwBytesRead; + + // If too few bytes in the file remaining, cut them + if((pBlock->dwFSize - dwFilePos) < dwToRead) + dwToRead = (pBlock->dwFSize - dwFilePos); + + // If the file is stored as single unit, handle it separately + if(pBlock->dwFlags & MPQ_FILE_SINGLE_UNIT) + return ReadMPQFileSingleUnit(hf, dwFilePos, pbBuffer, dwToRead); + + // Block position in the file + dwBlockPos = dwFilePos & ~(ha->dwBlockSize - 1); // Position in the block + + // Load the first block, if incomplete. It may be loaded in the cache buffer. + // We have to check if this block is loaded. If not, load it. + if((dwFilePos % ha->dwBlockSize) != 0) + { + // Number of bytes remaining in the buffer + DWORD dwToCopy; + DWORD dwLoaded = ha->dwBlockSize; + + // Check if data are loaded in the cache + if(hf != ha->pLastFile || dwBlockPos != ha->dwBlockPos) + { + // Load one MPQ block into archive buffer + dwLoaded = ReadMPQBlocks(hf, dwBlockPos, ha->pbBlockBuffer, ha->dwBlockSize); + if(dwLoaded == 0) + return (DWORD)-1; + + // Save lastly accessed file and block position for later use + ha->pLastFile = hf; + ha->dwBlockPos = dwBlockPos; + ha->dwBuffPos = dwFilePos % ha->dwBlockSize; + } + dwToCopy = dwLoaded - ha->dwBuffPos; + if(dwToCopy > dwToRead) + dwToCopy = dwToRead; + + // Copy data from block buffer into target buffer + memcpy(pbBuffer, ha->pbBlockBuffer + ha->dwBuffPos, dwToCopy); + + // Update pointers + dwToRead -= dwToCopy; + dwBytesRead += dwToCopy; + pbBuffer += dwToCopy; + dwBlockPos += ha->dwBlockSize; + ha->dwBuffPos += dwToCopy; + + // If all, return. + if(dwToRead == 0) + return dwBytesRead; + } + + // Load the whole ("middle") blocks only if there are more or equal one block + if(dwToRead > ha->dwBlockSize) + { + DWORD dwBlockBytes = dwToRead & ~(ha->dwBlockSize - 1); + + dwLoaded = ReadMPQBlocks(hf, dwBlockPos, pbBuffer, dwBlockBytes); + if(dwLoaded == 0) + return (DWORD)-1; + + // Update pointers + dwToRead -= dwLoaded; + dwBytesRead += dwLoaded; + pbBuffer += dwLoaded; + dwBlockPos += dwLoaded; + + // If all, return. + if(dwToRead == 0) + return dwBytesRead; + } + + // Load the terminating block + if(dwToRead > 0) + { + DWORD dwToCopy = ha->dwBlockSize; + + // Check if data are loaded in the cache + if(hf != ha->pLastFile || dwBlockPos != ha->dwBlockPos) + { + // Load one MPQ block into archive buffer + dwToCopy = ReadMPQBlocks(hf, dwBlockPos, ha->pbBlockBuffer, ha->dwBlockSize); + if(dwToCopy == 0) + return (DWORD)-1; + + // Save lastly accessed file and block position for later use + ha->pLastFile = hf; + ha->dwBlockPos = dwBlockPos; + } + ha->dwBuffPos = 0; + + // Check number of bytes read + if(dwToCopy > dwToRead) + dwToCopy = dwToRead; + + memcpy(pbBuffer, ha->pbBlockBuffer, dwToCopy); + dwBytesRead += dwToCopy; + ha->dwBuffPos = dwToCopy; + } + + // Return what we've read + return dwBytesRead; +} + +//----------------------------------------------------------------------------- +// SFileReadFile + +// TODO: Test for archives > 4GB +BOOL WINAPI SFileReadFile(HANDLE hFile, VOID * lpBuffer, DWORD dwToRead, DWORD * pdwRead, LPOVERLAPPED lpOverlapped) +{ + TMPQFile * hf = (TMPQFile *)hFile; + DWORD dwBytes = 0; // Number of bytes (for everything) + int nError = ERROR_SUCCESS; + + // Zero the number of bytes read + if(pdwRead != NULL) + *pdwRead = 0; + + // Check valid parameters + if(nError == ERROR_SUCCESS) + { + if(hf == NULL || lpBuffer == NULL) + nError = ERROR_INVALID_PARAMETER; + } + + // If direct access to the file, use Win32 for reading + if(nError == ERROR_SUCCESS && hf->hFile != INVALID_HANDLE_VALUE) + { + DWORD dwTransferred; + + ReadFile(hf->hFile, lpBuffer, dwToRead, &dwTransferred, lpOverlapped); + if(dwTransferred < dwToRead) + { + SetLastError(ERROR_HANDLE_EOF); + return FALSE; + } + + if(pdwRead != NULL) + *pdwRead = dwTransferred; + return TRUE; + } + + // Read all the bytes available in the buffer (If any) + if(nError == ERROR_SUCCESS) + { + if(dwToRead > 0) + { + dwBytes = ReadMPQFile(hf, hf->dwFilePos, (BYTE *)lpBuffer, dwToRead); + if(dwBytes == (DWORD)-1) + { + SetLastError(ERROR_CAN_NOT_COMPLETE); + return FALSE; + } + hf->ha->pLastFile = hf; + hf->dwFilePos += dwBytes; + } + if(pdwRead != NULL) + *pdwRead = dwBytes; + } + + // Check number of bytes read. If not OK, return FALSE. + if(dwBytes < dwToRead) + { + SetLastError(ERROR_HANDLE_EOF); + return FALSE; + } + return TRUE; +} + +//----------------------------------------------------------------------------- +// SFileGetFilePos +// +// Returns position of archive file in the archive (relative to begin of file) + +// TODO: Test for archives > 4GB +DWORD WINAPI SFileGetFilePos(HANDLE hFile, DWORD * pdwFilePosHigh) +{ + TMPQFile * hf = (TMPQFile *)hFile; + + if(pdwFilePosHigh != NULL) + *pdwFilePosHigh = 0; + + if(hf == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return (DWORD)-1; + } + + // If opened as plain file, ... + if(hf->hFile != INVALID_HANDLE_VALUE) + return 0; + + // If opened from archive, return file size + if(pdwFilePosHigh != NULL) + *pdwFilePosHigh = hf->MpqFilePos.HighPart; + return hf->MpqFilePos.LowPart; +} + +//----------------------------------------------------------------------------- +// SFileGetFileSize + +// TODO: Test for archives > 4GB +DWORD WINAPI SFileGetFileSize(HANDLE hFile, DWORD * pdwFileSizeHigh) +{ + TMPQFile * hf = (TMPQFile *)hFile; + + if(pdwFileSizeHigh != NULL) + *pdwFileSizeHigh = 0; + + if(hf == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return (DWORD)-1; + } + + // If opened as plain file, ... + if(hf->hFile != INVALID_HANDLE_VALUE) + return GetFileSize(hf->hFile, pdwFileSizeHigh); + + // If opened from archive, return file size + return hf->pBlock->dwFSize; +} + +// TODO: Test for archives > 4GB +DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * pdwFilePosHigh, DWORD dwMethod) +{ + TMPQArchive * ha; + TMPQFile * hf = (TMPQFile *)hFile; + + if(hf == NULL || (pdwFilePosHigh != NULL && *pdwFilePosHigh != 0)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return (DWORD)-1; + } + + // If opened as plain file, call Win32 API + if(hf->hFile != INVALID_HANDLE_VALUE) + return SetFilePointer(hf->hFile, lFilePos, pdwFilePosHigh, dwMethod); + ha = hf->ha; + + switch(dwMethod) + { + case FILE_BEGIN: + // Cannot set pointer before begin of file + if(-lFilePos > (LONG)hf->dwFilePos) + hf->dwFilePos = 0; + else + hf->dwFilePos = lFilePos; + break; + + case FILE_CURRENT: + // Cannot set pointer before begin of file + if(-lFilePos > (LONG)hf->dwFilePos) + hf->dwFilePos = 0; + else + hf->dwFilePos += lFilePos; + break; + + case FILE_END: + // Cannot set file position before begin of file + if(-lFilePos >= (LONG)hf->pBlock->dwFSize) + hf->dwFilePos = 0; + else + hf->dwFilePos = hf->pBlock->dwFSize + lFilePos; + break; + + default: + return ERROR_INVALID_PARAMETER; + } + + if(hf == ha->pLastFile && (hf->dwFilePos & ~(ha->dwBlockSize - 1)) == ha->dwBlockPos) + ha->dwBuffPos = hf->dwFilePos & (ha->dwBlockSize - 1); + else + { + ha->pLastFile = NULL; + ha->dwBuffPos = 0; + } + + return hf->dwFilePos; +} + +//----------------------------------------------------------------------------- +// Tries to retrieve the file name + +static TID2Ext id2ext[] = +{ + {0x1A51504D, "mpq"}, // MPQ archive header ID ('MPQ\x1A') + {0x46464952, "wav"}, // WAVE header 'RIFF' + {0x324B4D53, "smk"}, // Old "Smacker Video" files 'SMK2' + {0x694B4942, "bik"}, // Bink video files (new) + {0x0801050A, "pcx"}, // PCX images used in Diablo I + {0x544E4F46, "fnt"}, // Font files used in Diablo II + {0x6D74683C, "html"}, // HTML ' 4GB +BOOL WINAPI SFileGetFileName(HANDLE hFile, char * szFileName) +{ + TMPQFile * hf = (TMPQFile *)hFile; // MPQ File handle + char * szExt = "xxx"; // Default extension + DWORD dwFirstBytes[2]; // The first 4 bytes of the file + DWORD dwFilePos; // Saved file position + int nError = ERROR_SUCCESS; + int i; + + // Pre-zero the output buffer + if(szFileName != NULL) + *szFileName = 0; + + // Check valid parameters + if(nError == ERROR_SUCCESS) + { + if(hf == NULL || szFileName == NULL) + nError = ERROR_INVALID_PARAMETER; + } + + // If the file name is already filled, return it. + if(nError == ERROR_SUCCESS && *hf->szFileName != 0) + { + if(szFileName != hf->szFileName) + strcpy(szFileName, hf->szFileName); + return TRUE; + } + + if(nError == ERROR_SUCCESS) + { + if(hf->dwFileIndex == (DWORD)-1) + nError = ERROR_CAN_NOT_COMPLETE; + } + + // Read the first 8 bytes from the file + if(nError == ERROR_SUCCESS) + { + dwFirstBytes[0] = dwFirstBytes[1] = 0; + dwFilePos = SFileSetFilePointer(hf, 0, NULL, FILE_CURRENT); + if(!SFileReadFile(hFile, &dwFirstBytes, sizeof(dwFirstBytes), NULL)) + nError = GetLastError(); + BSWAP_ARRAY32_UNSIGNED(dwFirstBytes, sizeof(dwFirstBytes) / sizeof(DWORD)); + SFileSetFilePointer(hf, dwFilePos, NULL, FILE_BEGIN); + } + + if(nError == ERROR_SUCCESS) + { + if((dwFirstBytes[0] & 0x0000FFFF) == ID_EXE) + szExt = "exe"; + else if(dwFirstBytes[0] == 0x00000006 && dwFirstBytes[1] == 0x00000001) + szExt = "dc6"; + else + { + for(i = 0; id2ext[i].szExt != NULL; i++) + { + if(id2ext[i].dwID == dwFirstBytes[0]) + { + szExt = id2ext[i].szExt; + break; + } + } + } + + // Create the file name + sprintf(hf->szFileName, "File%08lu.%s", hf->dwFileIndex, szExt); + if(szFileName != hf->szFileName) + strcpy(szFileName, hf->szFileName); + } + return (nError == ERROR_SUCCESS); +} + +//----------------------------------------------------------------------------- +// Retrieves an information about an archive or about a file within the archive +// +// hMpqOrFile - Handle to an MPQ archive or to a file +// dwInfoType - Information to obtain + +// TODO: Test for archives > 4GB +DWORD_PTR WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, DWORD dwInfoType) +{ + TMPQArchive * ha = (TMPQArchive *)hMpqOrFile; + TMPQFile * hf = (TMPQFile *)hMpqOrFile; + TMPQBlock * pBlockEnd; + TMPQBlock * pBlock; + DWORD dwFileCount = 0; + DWORD dwSeed; + + switch(dwInfoType) + { + case SFILE_INFO_ARCHIVE_SIZE: + if(IsValidMpqHandle(ha)) + return ha->pHeader->dwArchiveSize; + break; + + case SFILE_INFO_HASH_TABLE_SIZE: // Size of the hash table + if(IsValidMpqHandle(ha)) + return ha->pHeader->dwHashTableSize; + break; + + case SFILE_INFO_BLOCK_TABLE_SIZE: // Size of the hash table + if(IsValidMpqHandle(ha)) + return ha->pHeader->dwBlockTableSize; + break; + + case SFILE_INFO_BLOCK_SIZE: + if(IsValidMpqHandle(ha)) + return ha->dwBlockSize; + break; + + case SFILE_INFO_HASH_TABLE: + if(IsValidMpqHandle(ha)) + return (DWORD_PTR)ha->pHashTable; + break; + + case SFILE_INFO_BLOCK_TABLE: + if(IsValidMpqHandle(ha)) + return (DWORD_PTR)ha->pBlockTable; + break; + + case SFILE_INFO_NUM_FILES: + if(IsValidMpqHandle(ha)) + { + pBlockEnd = ha->pBlockTable + ha->pHeader->dwBlockTableSize; + for(pBlock = ha->pBlockTable; pBlock < pBlockEnd; pBlock++) + { + if(pBlock->dwFlags & MPQ_FILE_EXISTS) + dwFileCount++; + } + return dwFileCount; + } + break; + + case SFILE_INFO_HASH_INDEX: + if(IsValidFileHandle(hf)) + return hf->dwHashIndex; + break; + + case SFILE_INFO_CODENAME1: + if(IsValidFileHandle(hf)) + return hf->pHash->dwName1; + break; + + case SFILE_INFO_CODENAME2: + if(IsValidFileHandle(hf)) + return hf->pHash->dwName2; + break; + + case SFILE_INFO_LOCALEID: + if(IsValidFileHandle(hf)) + return hf->pHash->lcLocale; + break; + + case SFILE_INFO_BLOCKINDEX: + if(IsValidFileHandle(hf)) + return hf->dwFileIndex; + break; + + case SFILE_INFO_FILE_SIZE: + if(IsValidFileHandle(hf)) + return hf->pBlock->dwFSize; + break; + + case SFILE_INFO_COMPRESSED_SIZE: + if(IsValidFileHandle(hf)) + return hf->pBlock->dwCSize; + break; + + case SFILE_INFO_FLAGS: + if(IsValidFileHandle(hf)) + return hf->pBlock->dwFlags; + break; + + case SFILE_INFO_POSITION: + if(IsValidFileHandle(hf)) + return hf->pBlock->dwFilePos; + break; + + case SFILE_INFO_SEED: + if(IsValidFileHandle(hf)) + return hf->dwSeed1; + break; + + case SFILE_INFO_SEED_UNFIXED: + if(IsValidFileHandle(hf)) + { + dwSeed = hf->dwSeed1; + if(hf->pBlock->dwFlags & MPQ_FILE_FIXSEED) + dwSeed = (dwSeed ^ hf->pBlock->dwFSize) - (DWORD)(hf->MpqFilePos.QuadPart - hf->ha->MpqPos.QuadPart); + return dwSeed; + } + break; + } + + // Unknown parameter or invalid handle + SetLastError(ERROR_INVALID_PARAMETER); + return 0xFFFFFFFF; +} diff --git a/src/tools/stuffextract/StormLib/SListFile.cpp b/src/tools/stuffextract/StormLib/SListFile.cpp index 7d887cf..c3723d1 100644 --- a/src/tools/stuffextract/StormLib/SListFile.cpp +++ b/src/tools/stuffextract/StormLib/SListFile.cpp @@ -1,561 +1,561 @@ -/*****************************************************************************/ -/* SListFile.cpp Copyright (c) Ladislav Zezula 2004 */ -/*---------------------------------------------------------------------------*/ -/* Description: */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 12.06.04 1.00 Lad The first version of SListFile.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" -#include - -//----------------------------------------------------------------------------- -// Listfile entry structure - -#define LISTFILE_CACHE_SIZE 0x1000 // Size of one cache element -#define NO_MORE_CHARACTERS 256 -#define HASH_TABLE_SIZE 31 // Initial hash table size (should be a prime number) - -// TODO: Check on x64 !!! -#define LISTFILE_ENTRY_DELETED (DWORD_PTR)(-2) -#define LISTFILE_ENTRY_FREE (DWORD_PTR)(-1) - -struct TListFileCache -{ - HANDLE hFile; // Stormlib file handle - char * szMask; // File mask - DWORD dwFileSize; // Total size of the cached file - DWORD dwBuffSize; // File of the cache - DWORD dwFilePos; // Position of the cache in the file - BYTE * pBegin; // The begin of the listfile cache - BYTE * pPos; - BYTE * pEnd; // The last character in the file cache - - BYTE Buffer[1]; // Listfile cache itself -}; - -//----------------------------------------------------------------------------- -// Local functions (cache) - -// Reloads the cache. Returns number of characters -// that has been loaded into the cache. -static int ReloadCache(TListFileCache * pCache) -{ - // Check if there is enough characters in the cache - // If not, we have to reload the next block - if(pCache->pPos >= pCache->pEnd) - { - // If the cache is already at the end, do nothing more - if((pCache->dwFilePos + pCache->dwBuffSize) >= pCache->dwFileSize) - return 0; - - pCache->dwFilePos += pCache->dwBuffSize; - SFileReadFile(pCache->hFile, pCache->Buffer, pCache->dwBuffSize, &pCache->dwBuffSize, NULL); - if(pCache->dwBuffSize == 0) - return 0; - - // Set the buffer pointers - pCache->pBegin = - pCache->pPos = &pCache->Buffer[0]; - pCache->pEnd = pCache->pBegin + pCache->dwBuffSize; - } - - return pCache->dwBuffSize; -} - -static size_t ReadLine(TListFileCache * pCache, char * szLine, int nMaxChars) -{ - char * szLineBegin = szLine; - char * szLineEnd = szLine + nMaxChars - 1; - -__BeginLoading: - - // Skip newlines, spaces, tabs and another non-printable stuff - while(pCache->pPos < pCache->pEnd && *pCache->pPos <= 0x20) - pCache->pPos++; - - // Copy the remaining characters - while(pCache->pPos < pCache->pEnd && szLine < szLineEnd) - { - // If we have found a newline, stop loading - if(*pCache->pPos == 0x0D || *pCache->pPos == 0x0A) - break; - - *szLine++ = *pCache->pPos++; - } - - // If we now need to reload the cache, do it - if(pCache->pPos == pCache->pEnd) - { - if(ReloadCache(pCache) > 0) - goto __BeginLoading; - } - - *szLine = 0; - return (szLine - szLineBegin); -} - -//----------------------------------------------------------------------------- -// Local functions (listfile nodes) - -// This function creates the name for the listfile. -// the file will be created under unique name in the temporary directory -static void GetListFileName(TMPQArchive * /* ha */, char * szListFile) -{ - char szTemp[MAX_PATH]; - - // Create temporary file name int TEMP directory - GetTempPath(sizeof(szTemp)-1, szTemp); - GetTempFileName(szTemp, LISTFILE_NAME, 0, szListFile); -} - -// Creates new listfile. The listfile is an array of TListFileNode -// structures. The size of the array is the same like the hash table size, -// the ordering is the same too (listfile item index is the same like -// the index in the MPQ hash table) - -int SListFileCreateListFile(TMPQArchive * ha) -{ - DWORD dwItems = ha->pHeader->dwHashTableSize; - - // The listfile should be NULL now - assert(ha->pListFile == NULL); - - ha->pListFile = ALLOCMEM(TFileNode *, dwItems); - if(ha->pListFile == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - memset(ha->pListFile, 0xFF, dwItems * sizeof(TFileNode *)); - return ERROR_SUCCESS; -} - -// Adds a filename into the listfile. If the file name is already there, -// does nothing. -int SListFileAddNode(TMPQArchive * ha, const char * szFileName) -{ - TFileNode * pNode = NULL; - TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash0 = GetHashEntry(ha, szFileName); - TMPQHash * pHash = pHash0; - DWORD dwHashIndex = 0; - size_t nLength; // File name lentgth - DWORD dwName1; - DWORD dwName2; - - // If the file does not exist within the MPQ, do nothing - if(pHash == NULL) - return ERROR_SUCCESS; - - // If the listfile entry already exists, do nothing - dwHashIndex = (DWORD)(pHash - ha->pHashTable); - dwName1 = pHash->dwName1; - dwName2 = pHash->dwName2; - if((DWORD_PTR)ha->pListFile[dwHashIndex] <= LISTFILE_ENTRY_DELETED) - return ERROR_SUCCESS; - - // Create the listfile node and insert it into the listfile table - nLength = strlen(szFileName); - pNode = (TFileNode *)ALLOCMEM(char, sizeof(TFileNode) + nLength); - pNode->dwRefCount = 0; - pNode->nLength = nLength; - strcpy(pNode->szFileName, szFileName); - - // Fill the nodes for all language versions - while(pHash->dwBlockIndex < LISTFILE_ENTRY_DELETED) - { - if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2) - { - pNode->dwRefCount++; - ha->pListFile[pHash - ha->pHashTable] = pNode; - } - - if(++pHash >= pHashEnd) - pHash = ha->pHashTable; - if(pHash == pHash0) - break; - } - - return ERROR_SUCCESS; -} - -// Removes a filename from the listfile. -// If the name is not there, does nothing -int SListFileRemoveNode(TMPQArchive * ha, const char * szFileName) -{ - TFileNode * pNode = NULL; - TMPQHash * pHash = GetHashEntry(ha, szFileName); - size_t nHashIndex = 0; - - if(pHash != NULL) - { - nHashIndex = pHash - ha->pHashTable; - pNode = ha->pListFile[nHashIndex]; - ha->pListFile[nHashIndex] = (TFileNode *)LISTFILE_ENTRY_DELETED; - - // If the reference count has reached zero, do nothing - if(--pNode->dwRefCount == 0) - FREEMEM(pNode); - } - return ERROR_SUCCESS; -} - - -// Renames a node. We will not deal with the renaming, we'll simply -// remove the old node and insert the new one. -// TODO: Test for archives > 4GB -int SListFileRenameNode(TMPQArchive * ha, const char * szOldFileName, const char * szNewFileName) -{ - SListFileRemoveNode(ha, szOldFileName); - return SListFileAddNode(ha, szNewFileName); -} - -// TODO: Test for archives > 4GB -int SListFileFreeListFile(TMPQArchive * ha) -{ - if(ha->pListFile != NULL) - { - for(DWORD i = 0; i < ha->pHeader->dwHashTableSize; i++) - { - TFileNode * pNode = ha->pListFile[i]; - - if((DWORD_PTR)pNode < LISTFILE_ENTRY_FREE) - { - if(--pNode->dwRefCount == 0) - { - FREEMEM(pNode); - ha->pListFile[i] = (TFileNode *)LISTFILE_ENTRY_FREE; - } - } - } - - FREEMEM(ha->pListFile); - ha->pListFile = NULL; - } - - return ERROR_SUCCESS; -} - -// Saves the whole listfile into the MPQ. -// TODO: Test for archives > 4GB -int SListFileSaveToMpq(TMPQArchive * ha) -{ - TFileNode * pNode = NULL; - TMPQHash * pHashEnd = NULL; - TMPQHash * pHash0 = NULL; - TMPQHash * pHash = NULL; - HANDLE hFile = INVALID_HANDLE_VALUE; - char szListFile[MAX_PATH]; - char szBuffer[MAX_PATH+4]; - DWORD dwTransferred; - size_t nLength = 0; - DWORD dwName1 = 0; - DWORD dwName2 = 0; - LCID lcSave = lcLocale; - int nError = ERROR_SUCCESS; - - // If no listfile, do nothing - if(ha->pListFile == NULL) - return ERROR_SUCCESS; - - // Create the local listfile - if(nError == ERROR_SUCCESS) - { - GetListFileName(ha, szListFile); - hFile = CreateFile(szListFile, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL); - if(hFile == INVALID_HANDLE_VALUE) - nError = GetLastError(); - } - - // Find the hash entry corresponding to listfile - pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - pHash0 = pHash = GetHashEntry(ha, 0); - if(pHash == NULL) - pHash0 = pHash = ha->pHashTable; - - // Save the file - if(nError == ERROR_SUCCESS) - { - for(;;) - { - if(pHash->dwName1 != dwName1 && pHash->dwName2 != dwName2 && pHash->dwBlockIndex < LISTFILE_ENTRY_DELETED) - { - dwName1 = pHash->dwName1; - dwName2 = pHash->dwName2; - pNode = ha->pListFile[pHash - ha->pHashTable]; - - if((DWORD_PTR)pNode < LISTFILE_ENTRY_DELETED) - { - memcpy(szBuffer, pNode->szFileName, pNode->nLength); - szBuffer[pNode->nLength + 0] = 0x0D; - szBuffer[pNode->nLength + 1] = 0x0A; - WriteFile(hFile, szBuffer, (DWORD)(pNode->nLength + 2), &dwTransferred, NULL); - } - } - - if(++pHash >= pHashEnd) - pHash = ha->pHashTable; - if(pHash == pHash0) - break; - } - - // Write the listfile name (if not already there) - if(GetHashEntry(ha, LISTFILE_NAME) == NULL) - { - nLength = strlen(LISTFILE_NAME); - memcpy(szBuffer, LISTFILE_NAME, nLength); - szBuffer[nLength + 0] = 0x0D; - szBuffer[nLength + 1] = 0x0A; - WriteFile(hFile, szBuffer, (DWORD)(nLength + 2), &dwTransferred, NULL); - } - - // Add the listfile into the archive. - SFileSetLocale(LANG_NEUTRAL); - nError = AddFileToArchive(ha, hFile, LISTFILE_NAME, MPQ_FILE_COMPRESS_PKWARE | MPQ_FILE_ENCRYPTED | MPQ_FILE_REPLACEEXISTING, 0, SFILE_TYPE_DATA, NULL); - } - - // Close the temporary file. This will delete it too. - if(hFile != INVALID_HANDLE_VALUE) - CloseHandle(hFile); - - lcLocale = lcSave; - return nError; -} - -//----------------------------------------------------------------------------- -// File functions - -// Adds a listfile into the MPQ archive. -// Note that the function does not remove the -// TODO: Test for archives > 4GB -int WINAPI SFileAddListFile(HANDLE hMpq, const char * szListFile) -{ - TListFileCache * pCache = NULL; - TMPQArchive * ha = (TMPQArchive *)hMpq; - HANDLE hListFile = NULL; - char szFileName[MAX_PATH + 1]; - DWORD dwSearchScope = SFILE_OPEN_LOCAL_FILE; - DWORD dwCacheSize = 0; - DWORD dwFileSize = 0; - size_t nLength = 0; - int nError = ERROR_SUCCESS; - - // If the szListFile is NULL, it means we have to open internal listfile - if(szListFile == NULL) - { - szListFile = LISTFILE_NAME; - dwSearchScope = SFILE_OPEN_FROM_MPQ; - } - - // Open the local/internal listfile - if(nError == ERROR_SUCCESS) - { - if(!SFileOpenFileEx((HANDLE)ha, szListFile, dwSearchScope, &hListFile)) - nError = GetLastError(); - } - - if(nError == ERROR_SUCCESS) - { - dwCacheSize = - dwFileSize = SFileGetFileSize(hListFile, NULL); - - // Try to allocate memory for the complete file. If it fails, - // load the part of the file - pCache = (TListFileCache *)ALLOCMEM(char, (sizeof(TListFileCache) + dwCacheSize)); - if(pCache == NULL) - { - dwCacheSize = LISTFILE_CACHE_SIZE; - pCache = (TListFileCache *)ALLOCMEM(char, sizeof(TListFileCache) + dwCacheSize); - } - - if(pCache == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - if(nError == ERROR_SUCCESS) - { - // Initialize the file cache - memset(pCache, 0, sizeof(TListFileCache)); - pCache->hFile = hListFile; - pCache->dwFileSize = dwFileSize; - pCache->dwBuffSize = dwCacheSize; - pCache->dwFilePos = 0; - - // Fill the cache - SFileReadFile(hListFile, pCache->Buffer, pCache->dwBuffSize, &pCache->dwBuffSize, NULL); - - // Initialize the pointers - pCache->pBegin = - pCache->pPos = &pCache->Buffer[0]; - pCache->pEnd = pCache->pBegin + pCache->dwBuffSize; - - // Load the node tree - while((nLength = ReadLine(pCache, szFileName, sizeof(szFileName) - 1)) > 0) - SListFileAddNode(ha, szFileName); - - // Add well-known names - // Sometimes, they are not in listfile, but they exist in the archive - SListFileAddNode(ha, LISTFILE_NAME); - SListFileAddNode(ha, SIGNATURE_NAME); - SListFileAddNode(ha, ATTRIBUTES_NAME); - } - - // Cleanup & exit - if(pCache != NULL) - SListFileFindClose((HANDLE)pCache); - return nError; -} - -//----------------------------------------------------------------------------- -// Passing through the listfile - -// TODO: Test for archives > 4GB -HANDLE SListFileFindFirstFile(HANDLE hMpq, const char * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData) -{ - TListFileCache * pCache = NULL; - TMPQArchive * ha = (TMPQArchive *)hMpq; - HANDLE hListFile = NULL; - DWORD dwSearchScope = SFILE_OPEN_LOCAL_FILE; - DWORD dwCacheSize = 0; - DWORD dwFileSize = 0; - size_t nLength = 0; - int nError = ERROR_SUCCESS; - - // Initialize the structure with zeros - memset(lpFindFileData, 0, sizeof(SFILE_FIND_DATA)); - - // If the szListFile is NULL, it means we have to open internal listfile - if(szListFile == NULL) - { - szListFile = LISTFILE_NAME; - dwSearchScope = SFILE_OPEN_FROM_MPQ; - } - - // Open the local/internal listfile - if(nError == ERROR_SUCCESS) - { - if(!SFileOpenFileEx((HANDLE)ha, szListFile, dwSearchScope, &hListFile)) - nError = GetLastError(); - } - - if(nError == ERROR_SUCCESS) - { - dwCacheSize = - dwFileSize = SFileGetFileSize(hListFile, NULL); - - // Try to allocate memory for the complete file. If it fails, - // load the part of the file - pCache = (TListFileCache *)ALLOCMEM(char, sizeof(TListFileCache) + dwCacheSize); - if(pCache == NULL) - { - dwCacheSize = LISTFILE_CACHE_SIZE; - pCache = (TListFileCache *)ALLOCMEM(char, sizeof(TListFileCache) + dwCacheSize); - } - - if(pCache == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - if(nError == ERROR_SUCCESS) - { - // Initialize the file cache - memset(pCache, 0, sizeof(TListFileCache)); - pCache->hFile = hListFile; - pCache->dwFileSize = dwFileSize; - pCache->dwBuffSize = dwCacheSize; - pCache->dwFilePos = 0; - if(szMask != NULL) - { - pCache->szMask = ALLOCMEM(char, strlen(szMask) + 1); - strcpy(pCache->szMask, szMask); - } - - // Fill the cache - SFileReadFile(hListFile, pCache->Buffer, pCache->dwBuffSize, &pCache->dwBuffSize, NULL); - - // Initialize the pointers - pCache->pBegin = - pCache->pPos = &pCache->Buffer[0]; - pCache->pEnd = pCache->pBegin + pCache->dwBuffSize; - - for(;;) - { - // Read the (next) line - nLength = ReadLine(pCache, lpFindFileData->cFileName, sizeof(lpFindFileData->cFileName)); - if(nLength == 0) - { - nError = ERROR_NO_MORE_FILES; - break; - } - - // If some mask entered, check it - if(CheckWildCard(lpFindFileData->cFileName, pCache->szMask)) - break; - } - } - - // Cleanup & exit - if(nError != ERROR_SUCCESS) - { - memset(lpFindFileData, 0, sizeof(SFILE_FIND_DATA)); - SListFileFindClose((HANDLE)pCache); - pCache = NULL; - - SetLastError(nError); - } - return (HANDLE)pCache; -} - -// TODO: Test for archives > 4GB -BOOL SListFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData) -{ - TListFileCache * pCache = (TListFileCache *)hFind; - size_t nLength; - BOOL bResult = FALSE; - int nError = ERROR_SUCCESS; - - for(;;) - { - // Read the (next) line - nLength = ReadLine(pCache, lpFindFileData->cFileName, sizeof(lpFindFileData->cFileName)); - if(nLength == 0) - { - nError = ERROR_NO_MORE_FILES; - break; - } - - // If some mask entered, check it - if(CheckWildCard(lpFindFileData->cFileName, pCache->szMask)) - { - bResult = TRUE; - break; - } - } - - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return bResult; -} - -// TODO: Test for archives > 4GB -BOOL SListFileFindClose(HANDLE hFind) -{ - TListFileCache * pCache = (TListFileCache *)hFind; - - if(pCache != NULL) - { - if(pCache->hFile != NULL) - SFileCloseFile(pCache->hFile); - if(pCache->szMask != NULL) - FREEMEM(pCache->szMask); - - FREEMEM(pCache); - return TRUE; - } - - return FALSE; -} - +/*****************************************************************************/ +/* SListFile.cpp Copyright (c) Ladislav Zezula 2004 */ +/*---------------------------------------------------------------------------*/ +/* Description: */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 12.06.04 1.00 Lad The first version of SListFile.cpp */ +/*****************************************************************************/ + +#define __STORMLIB_SELF__ +#include "StormLib.h" +#include "SCommon.h" +#include + +//----------------------------------------------------------------------------- +// Listfile entry structure + +#define LISTFILE_CACHE_SIZE 0x1000 // Size of one cache element +#define NO_MORE_CHARACTERS 256 +#define HASH_TABLE_SIZE 31 // Initial hash table size (should be a prime number) + +// TODO: Check on x64 !!! +#define LISTFILE_ENTRY_DELETED (DWORD_PTR)(-2) +#define LISTFILE_ENTRY_FREE (DWORD_PTR)(-1) + +struct TListFileCache +{ + HANDLE hFile; // Stormlib file handle + char * szMask; // File mask + DWORD dwFileSize; // Total size of the cached file + DWORD dwBuffSize; // File of the cache + DWORD dwFilePos; // Position of the cache in the file + BYTE * pBegin; // The begin of the listfile cache + BYTE * pPos; + BYTE * pEnd; // The last character in the file cache + + BYTE Buffer[1]; // Listfile cache itself +}; + +//----------------------------------------------------------------------------- +// Local functions (cache) + +// Reloads the cache. Returns number of characters +// that has been loaded into the cache. +static int ReloadCache(TListFileCache * pCache) +{ + // Check if there is enough characters in the cache + // If not, we have to reload the next block + if(pCache->pPos >= pCache->pEnd) + { + // If the cache is already at the end, do nothing more + if((pCache->dwFilePos + pCache->dwBuffSize) >= pCache->dwFileSize) + return 0; + + pCache->dwFilePos += pCache->dwBuffSize; + SFileReadFile(pCache->hFile, pCache->Buffer, pCache->dwBuffSize, &pCache->dwBuffSize, NULL); + if(pCache->dwBuffSize == 0) + return 0; + + // Set the buffer pointers + pCache->pBegin = + pCache->pPos = &pCache->Buffer[0]; + pCache->pEnd = pCache->pBegin + pCache->dwBuffSize; + } + + return pCache->dwBuffSize; +} + +static size_t ReadLine(TListFileCache * pCache, char * szLine, int nMaxChars) +{ + char * szLineBegin = szLine; + char * szLineEnd = szLine + nMaxChars - 1; + +__BeginLoading: + + // Skip newlines, spaces, tabs and another non-printable stuff + while(pCache->pPos < pCache->pEnd && *pCache->pPos <= 0x20) + pCache->pPos++; + + // Copy the remaining characters + while(pCache->pPos < pCache->pEnd && szLine < szLineEnd) + { + // If we have found a newline, stop loading + if(*pCache->pPos == 0x0D || *pCache->pPos == 0x0A) + break; + + *szLine++ = *pCache->pPos++; + } + + // If we now need to reload the cache, do it + if(pCache->pPos == pCache->pEnd) + { + if(ReloadCache(pCache) > 0) + goto __BeginLoading; + } + + *szLine = 0; + return (szLine - szLineBegin); +} + +//----------------------------------------------------------------------------- +// Local functions (listfile nodes) + +// This function creates the name for the listfile. +// the file will be created under unique name in the temporary directory +static void GetListFileName(TMPQArchive * /* ha */, char * szListFile) +{ + char szTemp[MAX_PATH]; + + // Create temporary file name int TEMP directory + GetTempPath(sizeof(szTemp)-1, szTemp); + GetTempFileName(szTemp, LISTFILE_NAME, 0, szListFile); +} + +// Creates new listfile. The listfile is an array of TListFileNode +// structures. The size of the array is the same like the hash table size, +// the ordering is the same too (listfile item index is the same like +// the index in the MPQ hash table) + +int SListFileCreateListFile(TMPQArchive * ha) +{ + DWORD dwItems = ha->pHeader->dwHashTableSize; + + // The listfile should be NULL now + assert(ha->pListFile == NULL); + + ha->pListFile = ALLOCMEM(TFileNode *, dwItems); + if(ha->pListFile == NULL) + return ERROR_NOT_ENOUGH_MEMORY; + + memset(ha->pListFile, 0xFF, dwItems * sizeof(TFileNode *)); + return ERROR_SUCCESS; +} + +// Adds a filename into the listfile. If the file name is already there, +// does nothing. +int SListFileAddNode(TMPQArchive * ha, const char * szFileName) +{ + TFileNode * pNode = NULL; + TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; + TMPQHash * pHash0 = GetHashEntry(ha, szFileName); + TMPQHash * pHash = pHash0; + DWORD dwHashIndex = 0; + size_t nLength; // File name lentgth + DWORD dwName1; + DWORD dwName2; + + // If the file does not exist within the MPQ, do nothing + if(pHash == NULL) + return ERROR_SUCCESS; + + // If the listfile entry already exists, do nothing + dwHashIndex = (DWORD)(pHash - ha->pHashTable); + dwName1 = pHash->dwName1; + dwName2 = pHash->dwName2; + if((DWORD_PTR)ha->pListFile[dwHashIndex] <= LISTFILE_ENTRY_DELETED) + return ERROR_SUCCESS; + + // Create the listfile node and insert it into the listfile table + nLength = strlen(szFileName); + pNode = (TFileNode *)ALLOCMEM(char, sizeof(TFileNode) + nLength); + pNode->dwRefCount = 0; + pNode->nLength = nLength; + strcpy(pNode->szFileName, szFileName); + + // Fill the nodes for all language versions + while(pHash->dwBlockIndex < LISTFILE_ENTRY_DELETED) + { + if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2) + { + pNode->dwRefCount++; + ha->pListFile[pHash - ha->pHashTable] = pNode; + } + + if(++pHash >= pHashEnd) + pHash = ha->pHashTable; + if(pHash == pHash0) + break; + } + + return ERROR_SUCCESS; +} + +// Removes a filename from the listfile. +// If the name is not there, does nothing +int SListFileRemoveNode(TMPQArchive * ha, const char * szFileName) +{ + TFileNode * pNode = NULL; + TMPQHash * pHash = GetHashEntry(ha, szFileName); + size_t nHashIndex = 0; + + if(pHash != NULL) + { + nHashIndex = pHash - ha->pHashTable; + pNode = ha->pListFile[nHashIndex]; + ha->pListFile[nHashIndex] = (TFileNode *)LISTFILE_ENTRY_DELETED; + + // If the reference count has reached zero, do nothing + if(--pNode->dwRefCount == 0) + FREEMEM(pNode); + } + return ERROR_SUCCESS; +} + + +// Renames a node. We will not deal with the renaming, we'll simply +// remove the old node and insert the new one. +// TODO: Test for archives > 4GB +int SListFileRenameNode(TMPQArchive * ha, const char * szOldFileName, const char * szNewFileName) +{ + SListFileRemoveNode(ha, szOldFileName); + return SListFileAddNode(ha, szNewFileName); +} + +// TODO: Test for archives > 4GB +int SListFileFreeListFile(TMPQArchive * ha) +{ + if(ha->pListFile != NULL) + { + for(DWORD i = 0; i < ha->pHeader->dwHashTableSize; i++) + { + TFileNode * pNode = ha->pListFile[i]; + + if((DWORD_PTR)pNode < LISTFILE_ENTRY_FREE) + { + if(--pNode->dwRefCount == 0) + { + FREEMEM(pNode); + ha->pListFile[i] = (TFileNode *)LISTFILE_ENTRY_FREE; + } + } + } + + FREEMEM(ha->pListFile); + ha->pListFile = NULL; + } + + return ERROR_SUCCESS; +} + +// Saves the whole listfile into the MPQ. +// TODO: Test for archives > 4GB +int SListFileSaveToMpq(TMPQArchive * ha) +{ + TFileNode * pNode = NULL; + TMPQHash * pHashEnd = NULL; + TMPQHash * pHash0 = NULL; + TMPQHash * pHash = NULL; + HANDLE hFile = INVALID_HANDLE_VALUE; + char szListFile[MAX_PATH]; + char szBuffer[MAX_PATH+4]; + DWORD dwTransferred; + size_t nLength = 0; + DWORD dwName1 = 0; + DWORD dwName2 = 0; + LCID lcSave = lcLocale; + int nError = ERROR_SUCCESS; + + // If no listfile, do nothing + if(ha->pListFile == NULL) + return ERROR_SUCCESS; + + // Create the local listfile + if(nError == ERROR_SUCCESS) + { + GetListFileName(ha, szListFile); + hFile = CreateFile(szListFile, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL); + if(hFile == INVALID_HANDLE_VALUE) + nError = GetLastError(); + } + + // Find the hash entry corresponding to listfile + pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; + pHash0 = pHash = GetHashEntry(ha, 0); + if(pHash == NULL) + pHash0 = pHash = ha->pHashTable; + + // Save the file + if(nError == ERROR_SUCCESS) + { + for(;;) + { + if(pHash->dwName1 != dwName1 && pHash->dwName2 != dwName2 && pHash->dwBlockIndex < LISTFILE_ENTRY_DELETED) + { + dwName1 = pHash->dwName1; + dwName2 = pHash->dwName2; + pNode = ha->pListFile[pHash - ha->pHashTable]; + + if((DWORD_PTR)pNode < LISTFILE_ENTRY_DELETED) + { + memcpy(szBuffer, pNode->szFileName, pNode->nLength); + szBuffer[pNode->nLength + 0] = 0x0D; + szBuffer[pNode->nLength + 1] = 0x0A; + WriteFile(hFile, szBuffer, (DWORD)(pNode->nLength + 2), &dwTransferred, NULL); + } + } + + if(++pHash >= pHashEnd) + pHash = ha->pHashTable; + if(pHash == pHash0) + break; + } + + // Write the listfile name (if not already there) + if(GetHashEntry(ha, LISTFILE_NAME) == NULL) + { + nLength = strlen(LISTFILE_NAME); + memcpy(szBuffer, LISTFILE_NAME, nLength); + szBuffer[nLength + 0] = 0x0D; + szBuffer[nLength + 1] = 0x0A; + WriteFile(hFile, szBuffer, (DWORD)(nLength + 2), &dwTransferred, NULL); + } + + // Add the listfile into the archive. + SFileSetLocale(LANG_NEUTRAL); + nError = AddFileToArchive(ha, hFile, LISTFILE_NAME, MPQ_FILE_COMPRESS_PKWARE | MPQ_FILE_ENCRYPTED | MPQ_FILE_REPLACEEXISTING, 0, SFILE_TYPE_DATA, NULL); + } + + // Close the temporary file. This will delete it too. + if(hFile != INVALID_HANDLE_VALUE) + CloseHandle(hFile); + + lcLocale = lcSave; + return nError; +} + +//----------------------------------------------------------------------------- +// File functions + +// Adds a listfile into the MPQ archive. +// Note that the function does not remove the +// TODO: Test for archives > 4GB +int WINAPI SFileAddListFile(HANDLE hMpq, const char * szListFile) +{ + TListFileCache * pCache = NULL; + TMPQArchive * ha = (TMPQArchive *)hMpq; + HANDLE hListFile = NULL; + char szFileName[MAX_PATH + 1]; + DWORD dwSearchScope = SFILE_OPEN_LOCAL_FILE; + DWORD dwCacheSize = 0; + DWORD dwFileSize = 0; + size_t nLength = 0; + int nError = ERROR_SUCCESS; + + // If the szListFile is NULL, it means we have to open internal listfile + if(szListFile == NULL) + { + szListFile = LISTFILE_NAME; + dwSearchScope = SFILE_OPEN_FROM_MPQ; + } + + // Open the local/internal listfile + if(nError == ERROR_SUCCESS) + { + if(!SFileOpenFileEx((HANDLE)ha, szListFile, dwSearchScope, &hListFile)) + nError = GetLastError(); + } + + if(nError == ERROR_SUCCESS) + { + dwCacheSize = + dwFileSize = SFileGetFileSize(hListFile, NULL); + + // Try to allocate memory for the complete file. If it fails, + // load the part of the file + pCache = (TListFileCache *)ALLOCMEM(char, (sizeof(TListFileCache) + dwCacheSize)); + if(pCache == NULL) + { + dwCacheSize = LISTFILE_CACHE_SIZE; + pCache = (TListFileCache *)ALLOCMEM(char, sizeof(TListFileCache) + dwCacheSize); + } + + if(pCache == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + if(nError == ERROR_SUCCESS) + { + // Initialize the file cache + memset(pCache, 0, sizeof(TListFileCache)); + pCache->hFile = hListFile; + pCache->dwFileSize = dwFileSize; + pCache->dwBuffSize = dwCacheSize; + pCache->dwFilePos = 0; + + // Fill the cache + SFileReadFile(hListFile, pCache->Buffer, pCache->dwBuffSize, &pCache->dwBuffSize, NULL); + + // Initialize the pointers + pCache->pBegin = + pCache->pPos = &pCache->Buffer[0]; + pCache->pEnd = pCache->pBegin + pCache->dwBuffSize; + + // Load the node tree + while((nLength = ReadLine(pCache, szFileName, sizeof(szFileName) - 1)) > 0) + SListFileAddNode(ha, szFileName); + + // Add well-known names + // Sometimes, they are not in listfile, but they exist in the archive + SListFileAddNode(ha, LISTFILE_NAME); + SListFileAddNode(ha, SIGNATURE_NAME); + SListFileAddNode(ha, ATTRIBUTES_NAME); + } + + // Cleanup & exit + if(pCache != NULL) + SListFileFindClose((HANDLE)pCache); + return nError; +} + +//----------------------------------------------------------------------------- +// Passing through the listfile + +// TODO: Test for archives > 4GB +HANDLE SListFileFindFirstFile(HANDLE hMpq, const char * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData) +{ + TListFileCache * pCache = NULL; + TMPQArchive * ha = (TMPQArchive *)hMpq; + HANDLE hListFile = NULL; + DWORD dwSearchScope = SFILE_OPEN_LOCAL_FILE; + DWORD dwCacheSize = 0; + DWORD dwFileSize = 0; + size_t nLength = 0; + int nError = ERROR_SUCCESS; + + // Initialize the structure with zeros + memset(lpFindFileData, 0, sizeof(SFILE_FIND_DATA)); + + // If the szListFile is NULL, it means we have to open internal listfile + if(szListFile == NULL) + { + szListFile = LISTFILE_NAME; + dwSearchScope = SFILE_OPEN_FROM_MPQ; + } + + // Open the local/internal listfile + if(nError == ERROR_SUCCESS) + { + if(!SFileOpenFileEx((HANDLE)ha, szListFile, dwSearchScope, &hListFile)) + nError = GetLastError(); + } + + if(nError == ERROR_SUCCESS) + { + dwCacheSize = + dwFileSize = SFileGetFileSize(hListFile, NULL); + + // Try to allocate memory for the complete file. If it fails, + // load the part of the file + pCache = (TListFileCache *)ALLOCMEM(char, sizeof(TListFileCache) + dwCacheSize); + if(pCache == NULL) + { + dwCacheSize = LISTFILE_CACHE_SIZE; + pCache = (TListFileCache *)ALLOCMEM(char, sizeof(TListFileCache) + dwCacheSize); + } + + if(pCache == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + if(nError == ERROR_SUCCESS) + { + // Initialize the file cache + memset(pCache, 0, sizeof(TListFileCache)); + pCache->hFile = hListFile; + pCache->dwFileSize = dwFileSize; + pCache->dwBuffSize = dwCacheSize; + pCache->dwFilePos = 0; + if(szMask != NULL) + { + pCache->szMask = ALLOCMEM(char, strlen(szMask) + 1); + strcpy(pCache->szMask, szMask); + } + + // Fill the cache + SFileReadFile(hListFile, pCache->Buffer, pCache->dwBuffSize, &pCache->dwBuffSize, NULL); + + // Initialize the pointers + pCache->pBegin = + pCache->pPos = &pCache->Buffer[0]; + pCache->pEnd = pCache->pBegin + pCache->dwBuffSize; + + for(;;) + { + // Read the (next) line + nLength = ReadLine(pCache, lpFindFileData->cFileName, sizeof(lpFindFileData->cFileName)); + if(nLength == 0) + { + nError = ERROR_NO_MORE_FILES; + break; + } + + // If some mask entered, check it + if(CheckWildCard(lpFindFileData->cFileName, pCache->szMask)) + break; + } + } + + // Cleanup & exit + if(nError != ERROR_SUCCESS) + { + memset(lpFindFileData, 0, sizeof(SFILE_FIND_DATA)); + SListFileFindClose((HANDLE)pCache); + pCache = NULL; + + SetLastError(nError); + } + return (HANDLE)pCache; +} + +// TODO: Test for archives > 4GB +BOOL SListFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData) +{ + TListFileCache * pCache = (TListFileCache *)hFind; + size_t nLength; + BOOL bResult = FALSE; + int nError = ERROR_SUCCESS; + + for(;;) + { + // Read the (next) line + nLength = ReadLine(pCache, lpFindFileData->cFileName, sizeof(lpFindFileData->cFileName)); + if(nLength == 0) + { + nError = ERROR_NO_MORE_FILES; + break; + } + + // If some mask entered, check it + if(CheckWildCard(lpFindFileData->cFileName, pCache->szMask)) + { + bResult = TRUE; + break; + } + } + + if(nError != ERROR_SUCCESS) + SetLastError(nError); + return bResult; +} + +// TODO: Test for archives > 4GB +BOOL SListFileFindClose(HANDLE hFind) +{ + TListFileCache * pCache = (TListFileCache *)hFind; + + if(pCache != NULL) + { + if(pCache->hFile != NULL) + SFileCloseFile(pCache->hFile); + if(pCache->szMask != NULL) + FREEMEM(pCache->szMask); + + FREEMEM(pCache); + return TRUE; + } + + return FALSE; +} + diff --git a/src/tools/stuffextract/StormLib/StormDll.h b/src/tools/stuffextract/StormLib/StormDll.h index 721230c..6d67820 100644 --- a/src/tools/stuffextract/StormLib/StormDll.h +++ b/src/tools/stuffextract/StormLib/StormDll.h @@ -1,67 +1,67 @@ -/*****************************************************************************/ -/* Storm.h Copyright Justin Olbrantz(Quantam) 2000 */ -/*---------------------------------------------------------------------------*/ -/* Storm Interface Library v1.0 for Windows */ -/* */ -/* Author : Justin Olbrantz(Quantam) */ -/* E-mail : omega@dragonfire.net */ -/* WWW : www.campaigncreations.com/starcraft/mpq2k/inside_mopaq/ */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.00 1.00 Qua The first version of Storm.h */ -/* 11.04.03 1.00 Lad Added some functions */ -/*****************************************************************************/ - -// We need the Windows data types for the Storm prototypes -#include - -#ifndef __STORM_H__ -#define __STORM_H__ - -// Somethimes is necessary to change the function names so they -// will not conflict with other MPQ tools. -#ifdef STORM_ALTERNATE_NAMES - #define SFILE(Name) Storm##Name - #define SCOMP(Name) Storm##Name -#else - #define SFILE(Name) SFile##Name - #define SCOMP(Name) SComp##Name -#endif - - -// Just in case anyone is still using C out there -#ifdef __cplusplus -extern "C" { -#endif - -// Storm file function prototypes -BOOL WINAPI SFILE(OpenArchive)(LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, HANDLE *hMPQ); -BOOL WINAPI SFILE(CloseArchive)(HANDLE hMPQ); -BOOL WINAPI SFILE(GetArchiveName)(HANDLE hMPQ, LPCSTR lpBuffer, DWORD dwBufferLength); -BOOL WINAPI SFILE(OpenFile)(LPCSTR lpFileName, HANDLE *hFile); -BOOL WINAPI SFILE(OpenFileEx)(HANDLE hMPQ, LPCSTR lpFileName, DWORD dwSearchScope, HANDLE *hFile); -BOOL WINAPI SFILE(CloseFile)(HANDLE hFile); -DWORD WINAPI SFILE(GetFileSize)(HANDLE hFile, LPDWORD lpFileSizeHigh); -BOOL WINAPI SFILE(GetFileArchive)(HANDLE hFile, HANDLE *hMPQ); -BOOL WINAPI SFILE(GetFileName)(HANDLE hFile, LPCSTR lpBuffer, DWORD dwBufferLength); -DWORD WINAPI SFILE(SetFilePointer)(HANDLE hFile, long lDistanceToMove, PLONG lplDistanceToMoveHigh, DWORD dwMoveMethod); -BOOL WINAPI SFILE(ReadFile)(HANDLE hFile,LPVOID lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,LPOVERLAPPED lpOverlapped); -LCID WINAPI SFILE(SetLocale)(LCID nNewLocale); -BOOL WINAPI SFILE(GetBasePath)(LPCSTR lpBuffer, DWORD dwBufferLength); -BOOL WINAPI SFILE(SetBasePath)(LPCSTR lpNewBasePath); - -// Storm (de)compression functions -BOOL WINAPI SCOMP(Compress) (char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int uCmp, int uCmpType, int nCmpLevel); -BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength); - - -#if defined(_MSC_VER) && !defined(BUILDING_STORM_CPP) -#pragma comment(lib, "Storm.lib") // Force linking Storm.lib and thus Storm.dll -#endif - -#ifdef __cplusplus -} -#endif - -#endif // __STORM_H__ +/*****************************************************************************/ +/* Storm.h Copyright Justin Olbrantz(Quantam) 2000 */ +/*---------------------------------------------------------------------------*/ +/* Storm Interface Library v1.0 for Windows */ +/* */ +/* Author : Justin Olbrantz(Quantam) */ +/* E-mail : omega@dragonfire.net */ +/* WWW : www.campaigncreations.com/starcraft/mpq2k/inside_mopaq/ */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* xx.xx.00 1.00 Qua The first version of Storm.h */ +/* 11.04.03 1.00 Lad Added some functions */ +/*****************************************************************************/ + +// We need the Windows data types for the Storm prototypes +#include + +#ifndef __STORM_H__ +#define __STORM_H__ + +// Somethimes is necessary to change the function names so they +// will not conflict with other MPQ tools. +#ifdef STORM_ALTERNATE_NAMES + #define SFILE(Name) Storm##Name + #define SCOMP(Name) Storm##Name +#else + #define SFILE(Name) SFile##Name + #define SCOMP(Name) SComp##Name +#endif + + +// Just in case anyone is still using C out there +#ifdef __cplusplus +extern "C" { +#endif + +// Storm file function prototypes +BOOL WINAPI SFILE(OpenArchive)(LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, HANDLE *hMPQ); +BOOL WINAPI SFILE(CloseArchive)(HANDLE hMPQ); +BOOL WINAPI SFILE(GetArchiveName)(HANDLE hMPQ, LPCSTR lpBuffer, DWORD dwBufferLength); +BOOL WINAPI SFILE(OpenFile)(LPCSTR lpFileName, HANDLE *hFile); +BOOL WINAPI SFILE(OpenFileEx)(HANDLE hMPQ, LPCSTR lpFileName, DWORD dwSearchScope, HANDLE *hFile); +BOOL WINAPI SFILE(CloseFile)(HANDLE hFile); +DWORD WINAPI SFILE(GetFileSize)(HANDLE hFile, LPDWORD lpFileSizeHigh); +BOOL WINAPI SFILE(GetFileArchive)(HANDLE hFile, HANDLE *hMPQ); +BOOL WINAPI SFILE(GetFileName)(HANDLE hFile, LPCSTR lpBuffer, DWORD dwBufferLength); +DWORD WINAPI SFILE(SetFilePointer)(HANDLE hFile, long lDistanceToMove, PLONG lplDistanceToMoveHigh, DWORD dwMoveMethod); +BOOL WINAPI SFILE(ReadFile)(HANDLE hFile,LPVOID lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,LPOVERLAPPED lpOverlapped); +LCID WINAPI SFILE(SetLocale)(LCID nNewLocale); +BOOL WINAPI SFILE(GetBasePath)(LPCSTR lpBuffer, DWORD dwBufferLength); +BOOL WINAPI SFILE(SetBasePath)(LPCSTR lpNewBasePath); + +// Storm (de)compression functions +BOOL WINAPI SCOMP(Compress) (char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int uCmp, int uCmpType, int nCmpLevel); +BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength); + + +#if defined(_MSC_VER) && !defined(BUILDING_STORM_CPP) +#pragma comment(lib, "Storm.lib") // Force linking Storm.lib and thus Storm.dll +#endif + +#ifdef __cplusplus +} +#endif + +#endif // __STORM_H__ diff --git a/src/tools/stuffextract/StormLib/StormLib.h b/src/tools/stuffextract/StormLib/StormLib.h index 68d01ad..4316ba8 100644 --- a/src/tools/stuffextract/StormLib/StormLib.h +++ b/src/tools/stuffextract/StormLib/StormLib.h @@ -1,581 +1,581 @@ -/*****************************************************************************/ -/* StormLib.h Copyright (c) Ladislav Zezula 1999-2005 */ -/*---------------------------------------------------------------------------*/ -/* StormLib library v 5.00 */ -/* */ -/* Author : Ladislav Zezula */ -/* E-mail : ladik@zezula.net */ -/* WWW : http://www.zezula.net */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.99 1.00 Lad Created */ -/* 24.03.03 2.50 Lad Version 2.50 */ -/* 02.04.03 3.00 Lad Version 3.00 with compression */ -/* 11.04.03 3.01 Lad Renamed to StormLib.h for compatibility with */ -/* original headers for Storm.dll */ -/* 10.05.03 3.02 Lad Added Pkware DCL compression */ -/* 26.05.03 4.00 Lad Completed all compressions */ -/* 18.06.03 4.01 Lad Added SFileSetFileLocale */ -/* Added SFileExtractFile */ -/* 26.07.03 4.02 Lad Implemented nameless rename and delete */ -/* 26.07.03 4.03 Lad Added support for protected MPQs */ -/* 28.08.03 4.10 Lad Fixed bugs that caused StormLib incorrectly work */ -/* with Diablo I savegames and with files having full */ -/* hash table */ -/* 08.12.03 4.11 DCH Fixed bug in reading file block larger than 0x1000 */ -/* on certain files. */ -/* Fixed bug in AddFile with MPQ_FILE_REPLACE_EXISTING */ -/* (Thanx Daniel Chiamarello, dchiamarello@madvawes.com)*/ -/* 21.12.03 4.50 Lad Completed port for Mac */ -/* Fixed bug in compacting (if fsize is mul of 0x1000) */ -/* Fixed bug in SCompCompress */ -/* 27.05.04 4.51 Lad Changed memory management from new/delete to our */ -/* own macros */ -/* 22.06.04 4.60 Lad Optimized search. Support for multiple listfiles. */ -/* 30.09.04 4.61 Lad Fixed some bugs (Aaargh !!!) */ -/* Correctly works if HashTableSize > BlockTableSize */ -/* 29.12.04 4.70 Lad Fixed compatibility problem with MPQs from WoW */ -/* 14.07.05 5.00 Lad Added the BZLIB compression support */ -/* Added suport of files stored as single unit */ -/* 17.04.06 5.01 Lad Converted to MS Visual Studio 8.0 */ -/* Fixed issue with protected Warcraft 3 protected maps */ -/* 15.05.06 5.02 Lad Fixed issue with WoW 1.10+ */ -/* 07.09.06 5.10 Lad Fixed processing files longer than 2GB */ -/* 22.11.06 6.00 Lad Support for MPQ archives V2 */ -/*****************************************************************************/ - -#ifndef __STORMLIB_H_ -#define __STORMLIB_H_ - -#include "StormPort.h" - -//----------------------------------------------------------------------------- -// Use the apropriate library -// -// The library type is encoded in the library name as the following -// StormLibXYZ.lib -// -// X - D for Debug version, R for Release version -// Y - A for ANSI version, U for Unicode version (Unicode version does not exist yet) -// Z - S for static C library, D for multithreaded DLL C-library -// - -#define __STORMLIB_SELF__ - -#if defined(_MSC_VER) && !defined (__STORMLIB_SELF__) - #ifdef _DEBUG // DEBUG VERSIONS - #ifdef _DLL - #pragma comment(lib, "StormLibDAD.lib") // Debug Ansi Dynamic version - #else - #pragma comment(lib, "StormLibDAS.lib") // Debug Ansi Static version - #endif - #else // RELEASE VERSIONS - #ifdef _DLL - #pragma comment(lib, "StormLibRAD.lib") // Release Ansi Dynamic version - #else - #pragma comment(lib, "StormLibRAS.lib") // Release Ansi Static version - #endif - #endif -#endif - -//----------------------------------------------------------------------------- -// Defines - -#define ID_MPQ 0x1A51504D // MPQ archive header ID ('MPQ\x1A') -#define ID_MPQ_SHUNT 0x1B51504D // MPQ shunt entry ('MPQ\x1B') - -#define ERROR_AVI_FILE 10000 // No MPQ file, but AVI file. - -// Values for SFileCreateArchiveEx -#define HASH_TABLE_SIZE_MIN 0x00002 -#define HASH_TABLE_SIZE_MAX 0x40000 - -#define HASH_ENTRY_DELETED 0xFFFFFFFE // Block index for deleted hash entry -#define HASH_ENTRY_FREE 0xFFFFFFFF // Block index for free hash entry - -// Values for SFileOpenArchive -#define SFILE_OPEN_HARD_DISK_FILE 2 // Open the archive on HDD -#define SFILE_OPEN_CDROM_FILE 3 // Open the archive only if it is on CDROM - -// Values for SFileOpenFile -#define SFILE_OPEN_FROM_MPQ 0 // Open the file from the MPQ archive -#define SFILE_OPEN_BY_INDEX 1 // The 'szFileName' parameter is actually the file index -#define SFILE_OPEN_LOCAL_FILE (DWORD)-1 // Open the file from the MPQ archive - -// Flags for TMPQArchive::dwFlags -#define MPQ_FLAG_CHANGED 0x00000001 // If set, the MPQ has been changed -#define MPQ_FLAG_PROTECTED 0x00000002 // Set on protected MPQs (like W3M maps) - -// Flags for SFileAddFile -#define MPQ_FILE_COMPRESS_PKWARE 0x00000100 // Compression made by PKWARE Data Compression Library -#define MPQ_FILE_COMPRESS_MULTI 0x00000200 // Multiple compressions -#define MPQ_FILE_COMPRESSED 0x0000FF00 // File is compressed -#define MPQ_FILE_ENCRYPTED 0x00010000 // Indicates whether file is encrypted -#define MPQ_FILE_FIXSEED 0x00020000 // File decrypt seed has to be fixed -#define MPQ_FILE_SINGLE_UNIT 0x01000000 // File is stored as a single unit, rather than split into sectors (Thx, Quantam) -#define MPQ_FILE_DUMMY_FILE 0x02000000 // The file is only 1 byte long and its name is a hash -#define MPQ_FILE_HAS_EXTRA 0x04000000 // The file has extra data appended after regular data. - // Must be with compressed files only -#define MPQ_FILE_EXISTS 0x80000000 // Set if file exists, reset when the file was deleted -#define MPQ_FILE_REPLACEEXISTING 0x80000000 // Replace when the file exist (SFileAddFile) - -#define MPQ_FILE_VALID_FLAGS (MPQ_FILE_COMPRESS_PKWARE | \ - MPQ_FILE_COMPRESS_MULTI | \ - MPQ_FILE_ENCRYPTED | \ - MPQ_FILE_FIXSEED | \ - MPQ_FILE_SINGLE_UNIT | \ - MPQ_FILE_DUMMY_FILE | \ - MPQ_FILE_HAS_EXTRA | \ - MPQ_FILE_EXISTS) - -// Compression types for multilpe compressions -#define MPQ_COMPRESSION_HUFFMANN 0x01 // Huffmann compression (used on WAVE files only) -#define MPQ_COMPRESSION_ZLIB 0x02 // ZLIB compression -#define MPQ_COMPRESSION_PKWARE 0x08 // PKWARE DCL compression -#define MPQ_COMPRESSION_BZIP2 0x10 // BZIP2 compression -#define MPQ_COMPRESSION_WAVE_MONO 0x40 // -#define MPQ_COMPRESSION_WAVE_STEREO 0x80 // - - -// Constants for SFileAddWave -#define MPQ_WAVE_QUALITY_HIGH 0 // Best quality, the worst compression -#define MPQ_WAVE_QUALITY_MEDIUM 1 // Medium quality, medium compression -#define MPQ_WAVE_QUALITY_LOW 2 // Low quality, the best compression - -// Constants for SFileGetFileInfo -#define SFILE_INFO_ARCHIVE_SIZE 1 // MPQ size (value from header) -#define SFILE_INFO_HASH_TABLE_SIZE 2 // Size of hash table, in entries -#define SFILE_INFO_BLOCK_TABLE_SIZE 3 // Number of entries in the block table -#define SFILE_INFO_BLOCK_SIZE 4 // Size of file block (in bytes) -#define SFILE_INFO_HASH_TABLE 5 // Pointer to Hash table (TMPQHash *) -#define SFILE_INFO_BLOCK_TABLE 6 // Pointer to Block Table (TMPQBlock *) -#define SFILE_INFO_NUM_FILES 7 // Real number of files within archive -//------ -#define SFILE_INFO_HASH_INDEX 8 // Hash index of file in MPQ -#define SFILE_INFO_CODENAME1 9 // The first codename of the file -#define SFILE_INFO_CODENAME2 10 // The second codename of the file -#define SFILE_INFO_LOCALEID 11 // Locale ID of file in MPQ -#define SFILE_INFO_BLOCKINDEX 12 // Index to Block Table -#define SFILE_INFO_FILE_SIZE 13 // Original file size -#define SFILE_INFO_COMPRESSED_SIZE 14 // Compressed file size -#define SFILE_INFO_FLAGS 15 // File flags -#define SFILE_INFO_POSITION 16 // File position within archive -#define SFILE_INFO_SEED 17 // File decryption seed -#define SFILE_INFO_SEED_UNFIXED 18 // Decryption seed not fixed to file pos and size - -// Values for compact callback -#define CCB_CHECKING_FILES 1 // Checking archive (dwParam1 = current, dwParam2 = total) -#define CCB_CHECKING_HASH_TABLE 2 // Checking hash table (dwParam1 = current, dwParam2 = total) -#define CCB_COPYING_NON_MPQ_DATA 3 // Copying non-MPQ data: No params used -#define CCB_COMPACTING_FILES 4 // Compacting archive (dwParam1 = current, dwParam2 = total) -#define CCB_CLOSING_ARCHIVE 5 // Closing archive: No params used - -#define LISTFILE_NAME "(listfile)" // Name of internal listfile -#define SIGNATURE_NAME "(signature)" // Name of internal signature -#define ATTRIBUTES_NAME "(attributes)" // Name of internal attributes file - -#define STORMLIB_VERSION (0x0600) // Current version of StormLib - -#define MPQ_FORMAT_VERSION_1 0 // Up to The Burning Crusade -#define MPQ_FORMAT_VERSION_2 1 // The Burning Crusade and newer, - -// Flags for SFileOpenArchiveEx -#define MPQ_OPEN_NO_LISTFILE 0x00000001 // Don't add the internal listfile - -// supports archives with size > 4 GB -// Additional flags for SFileCreateArchiveEx -#define MPQ_CREATE_ARCHIVE_V1 0x00000000 // Creates archive with size up to 4GB -#define MPQ_CREATE_ARCHIVE_V2 0x00010000 // Creates archive larger than 4 GB - -//----------------------------------------------------------------------------- -// Structures - -#if (defined(WIN32) || defined(WIN64)) -#include -#else -#pragma pack(1) -#endif - -struct TMPQFile; - -struct TMPQShunt -{ - // The ID_MPQ_SHUNT ('MPQ\x1B') signature - DWORD dwID; - - DWORD dwUnknown; - - // Position of the MPQ header, relative to the begin of the shunt - DWORD dwHeaderPos; -}; - - -// MPQ file header -struct TMPQHeader -{ - // The ID_MPQ ('MPQ\x1A') signature - DWORD dwID; - - // Size of the archive header - DWORD dwHeaderSize; - - // Size of MPQ archive - // This field is deprecated in the Burning Crusade MoPaQ format, and the size of the archive - // is calculated as the size from the beginning of the archive to the end of the hash table, - // block table, or extended block table (whichever is largest). - DWORD dwArchiveSize; - - // 0 = Original format - // 1 = Extended format (The Burning Crusade and newer) - USHORT wFormatVersion; - - // Power of two exponent specifying the number of 512-byte disk sectors in each logical sector - // in the archive. The size of each logical sector in the archive is 512 * 2^SectorSizeShift. - // Bugs in the Storm library dictate that this should always be 3 (4096 byte sectors). - USHORT wBlockSize; - - // Offset to the beginning of the hash table, relative to the beginning of the archive. - DWORD dwHashTablePos; - - // Offset to the beginning of the block table, relative to the beginning of the archive. - DWORD dwBlockTablePos; - - // Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for - // the original MoPaQ format, or less than 2^20 for the Burning Crusade format. - DWORD dwHashTableSize; - - // Number of entries in the block table - DWORD dwBlockTableSize; -}; - - -// Extended MPQ file header. Valid only if wFormatVersion is 1 or higher -struct TMPQHeader2 : public TMPQHeader -{ - // Offset to the beginning of the extended block table, relative to the beginning of the archive. - LARGE_INTEGER ExtBlockTablePos; - - // High 16 bits of the hash table offset for large archives. - USHORT wHashTablePosHigh; - - // High 16 bits of the block table offset for large archives. - USHORT wBlockTablePosHigh; -}; - - -// Hash entry. All files in the archive are searched by their hashes. -struct TMPQHash -{ - // The hash of the file path, using method A. - DWORD dwName1; - - // The hash of the file path, using method B. - DWORD dwName2; - -#ifdef PLATFORM_LITTLE_ENDIAN - - // The language of the file. This is a Windows LANGID data type, and uses the same values. - // 0 indicates the default language (American English), or that the file is language-neutral. - USHORT lcLocale; - - // The platform the file is used for. 0 indicates the default platform. - // No other values have been observed. - USHORT wPlatform; - -#else - - USHORT wPlatform; - USHORT lcLocale; - -#endif - - // If the hash table entry is valid, this is the index into the block table of the file. - // Otherwise, one of the following two values: - // - FFFFFFFFh: Hash table entry is empty, and has always been empty. - // Terminates searches for a given file. - // - FFFFFFFEh: Hash table entry is empty, but was valid at some point (a deleted file). - // Does not terminate searches for a given file. - DWORD dwBlockIndex; -}; - - -// File description block contains informations about the file -struct TMPQBlock -{ - // Offset of the beginning of the block, relative to the beginning of the archive. - DWORD dwFilePos; - - // Compressed file size - DWORD dwCSize; - - // Only valid if the block is a file; otherwise meaningless, and should be 0. - // If the file is compressed, this is the size of the uncompressed file data. - DWORD dwFSize; - - // Flags for the file. See MPQ_FILE_XXXX constants - DWORD dwFlags; -}; - - -// The extended block table was added to support archives larger than 4 gigabytes (2^32 bytes). -// The table contains the upper bits of the archive offsets for each block in the block table. -// It is simply an array of int16s, which become bits 32-47 of the archive offsets for each block, -// with bits 48-63 being zero. Individual blocks in the archive are still limited to 4 gigabytes -// in size. This table is only present in Burning Crusade format archives that exceed 4 gigabytes size. -struct TMPQBlockEx -{ - USHORT wFilePosHigh; -}; - - -struct TFileNode -{ - DWORD dwRefCount; // Number of references - // There can be more files that have the same name. - // (e.g. multiple language files). We don't want to - // have an entry for each of them, so the entries will be referenced. - // When a number of node references reaches zero, - // the node will be deleted - - size_t nLength; // File name length - char szFileName[1]; // File name, variable length -}; - -#if (defined(WIN32) || defined(WIN64)) -#include -#else -#pragma options align=reset -#endif - -// Archive handle structure. Note that it does not agree with Storm.dll's structure. -struct TMPQArchive -{ -// TMPQArchive * pNext; // Next archive (used by Storm.dll only) -// TMPQArchive * pPrev; // Previous archive (used by Storm.dll only) - char szFileName[MAX_PATH]; // Opened archive file name - HANDLE hFile; // File handle - DWORD dwPriority; // Priority of the archive - LARGE_INTEGER ShuntPos; // Position of MPQShunt (only valid if a shunt is present) - LARGE_INTEGER MpqPos; // MPQ position in the file, relative to the begin of the file - LARGE_INTEGER MpqSize; // Size of MPQ archive - LARGE_INTEGER HashTablePos; // Offset of the hast table in the MPQ, relative to the begin of the file - LARGE_INTEGER BlockTablePos; // Offset of the hast table in the MPQ, relative to the begin - LARGE_INTEGER ExtBlockTablePos; // Offset of the extended block table, relative to the begin - LARGE_INTEGER FilePointer; // Current position in the file (relative to begin of the file) - - TMPQFile * pLastFile; // Recently read file - DWORD dwBlockPos; // Position of loaded block in the file - DWORD dwBlockSize; // Size of file block - BYTE * pbBlockBuffer; // Buffer (cache) for file block - DWORD dwBuffPos; // Position in block buffer - TMPQShunt * pShunt; // MPQ shunt (NULL if not present in the file) - TMPQHeader2 * pHeader; // MPQ file header - TMPQHash * pHashTable; // Hash table - TMPQBlock * pBlockTable; // Block table - TMPQBlockEx * pExtBlockTable; // Extended block table - - TMPQShunt Shunt; // MPQ shunt. Valid only when ID_MPQ_SHUNT has been found - TMPQHeader2 Header; // MPQ header - - // Non-Storm.dll members - TFileNode ** pListFile; // File name array -// HANDLE hListFile; // Handle to temporary listfile (when open with write access) - DWORD dwFlags; // See MPQ_FLAG_XXXXX -// BOOL bChanged; // TRUE if the archive was changed since open. -// BOOL bProtected; // TRUE if the archive is protected by somehow -}; - - -// File handle structure. Note that it does not agree with Storm.dll structures -struct TMPQFile -{ - HANDLE hFile; // File handle - TMPQArchive * ha; // Archive handle - TMPQHash * pHash; // Hash table entry - TMPQBlockEx * pBlockEx; // Pointer to extended file block entry - TMPQBlock * pBlock; // File block pointer - DWORD dwSeed1; // Seed used for file decrypt - DWORD dwFilePos; // Current file position - LARGE_INTEGER MpqFilePos; // Position of the file data in MPQ archive - // (relative to file begin) - - DWORD * pdwBlockPos; // Position of each file block (only for compressed files) - DWORD nBlocks; // Number of blocks in the file (incl. the last noncomplete one) - BOOL bBlockPosLoaded; // TRUE if block positions loaded - BYTE * pbFileBuffer; // Decompressed file (for single unit files, size is the uncompressed file size) - - DWORD dwHashIndex; // Index to Hash table - DWORD dwFileIndex; // Index to Block table - char szFileName[1]; // File name (variable length) -}; - - -// Used by searching in MPQ archives -struct TMPQSearch -{ - TMPQArchive * ha; // Handle to MPQ, where the search runs - DWORD dwNextIndex; // The next searched hash index - DWORD dwName1; // Lastly found Name1 - DWORD dwName2; // Lastly found Name2 - char szSearchMask[1]; // Search mask (variable length) -}; - - -struct SFILE_FIND_DATA -{ - char cFileName[MAX_PATH]; // Full name of the found file - char * szPlainName; // Pointer to file part - LCID lcLocale; // Locale version - DWORD dwFileSize; // File size in bytes - DWORD dwFileFlags; // File flags (compressed or encrypted) - DWORD dwBlockIndex; // Block index for the file - DWORD dwCompSize; // Compressed file size -}; - -//----------------------------------------------------------------------------- -// Memory management -// -// We use our own macros for allocating/freeing memory. If you want -// to redefine them, please keep the following rules -// -// - The memory allocation must return NULL if not enough memory -// (i.e not to throw exception) -// - It is not necessary to fill the allocated block with zeros -// - Memory freeing function must not test the pointer to NULL. -// - - -__inline void * DebugMalloc(char * szFile, int nLine, int nSize) -{ - void * ptr = malloc(nSize + 100); - char * plain; - - plain = strrchr(szFile, '\\'); - if(plain == NULL) - plain = strrchr(szFile, '/'); - if(plain == NULL) - plain = szFile; - -#if _MSC_VER > 0x1300 - sprintf_s((char *)ptr, nSize+100, "%s(%u)", plain, nLine); -#else - sprintf((char *)ptr, "%s(%u)", plain, nLine); -#endif - - return (char *)ptr + 100; -} - - -__inline void DebugFree(void * ptr) -{ - free((char *)ptr - 100); -} - - -#ifndef ALLOCMEM - #define ALLOCMEM(type, nitems) (type *)malloc((nitems) * sizeof(type)) - #define FREEMEM(ptr) free(ptr) -#endif - -//#define ALLOCMEM(type, nitems) (type *)DebugMalloc(__FILE__, __LINE__, (nitems) * sizeof(type)) -//#define FREEMEM(ptr) DebugFree(ptr) - -//----------------------------------------------------------------------------- -// Functions in StormLib - compatible with Storm.dll - -// Typedefs for functions exported by Storm.dll -typedef LCID (WINAPI * SFILESETLOCALE)(LCID); -typedef BOOL (WINAPI * SFILEOPENARCHIVE)(const char *, DWORD, DWORD, HANDLE *); -typedef BOOL (WINAPI * SFILECLOSEARCHIVE)(HANDLE); -typedef BOOL (WINAPI * SFILEOPENFILEEX)(HANDLE, const char *, DWORD, HANDLE *); -typedef BOOL (WINAPI * SFILECLOSEFILE)(HANDLE); -typedef DWORD (WINAPI * SFILEGETFILESIZE)(HANDLE, DWORD *); -typedef DWORD (WINAPI * SFILESETFILEPOINTER)(HANDLE, LONG, LONG *, DWORD); -typedef BOOL (WINAPI * SFILEREADFILE)(HANDLE, VOID *, DWORD, DWORD *, LPOVERLAPPED); - -// Archive opening/closing -LCID WINAPI SFileSetLocale(LCID lcNewLocale); -LCID WINAPI SFileGetLocale(); -BOOL WINAPI SFileOpenArchive(const char * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMPQ); -BOOL WINAPI SFileCloseArchive(HANDLE hMPQ); - -// File opening/closing -BOOL WINAPI SFileOpenFileEx(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope, HANDLE * phFile); -BOOL WINAPI SFileCloseFile(HANDLE hFile); - -// File I/O -DWORD WINAPI SFileGetFilePos(HANDLE hFile, DWORD * pdwFilePosHigh = NULL); -DWORD WINAPI SFileGetFileSize(HANDLE hFile, DWORD * pdwFileSizeHigh = NULL); -DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * pdwFilePosHigh, DWORD dwMethod); -BOOL WINAPI SFileReadFile(HANDLE hFile, VOID * lpBuffer, DWORD dwToRead, DWORD * pdwRead = NULL, LPOVERLAPPED lpOverlapped = NULL); - -BOOL WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const char * szExtracted); - -// Adds another listfile into MPQ. The currently added listfile(s) remain, -// so you can use this API to combining more listfiles. -// Note that this function is internally called by SFileFindFirstFile -int WINAPI SFileAddListFile(HANDLE hMpq, const char * szListFile); - -//----------------------------------------------------------------------------- -// Functions in StormLib - not implemented in Storm.dll - -// Archive creating and editing -BOOL WINAPI SFileCreateArchiveEx(const char * szMpqName, DWORD dwCreationDisposition, DWORD dwHashTableSize, HANDLE * phMPQ); -BOOL WINAPI SFileAddFile(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags); -BOOL WINAPI SFileAddWave(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality); -BOOL WINAPI SFileRemoveFile(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope = SFILE_OPEN_BY_INDEX); -BOOL WINAPI SFileRenameFile(HANDLE hMPQ, const char * szOldFileName, const char * szNewFileName); -BOOL WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale); - -// Retrieving info about the file -BOOL WINAPI SFileHasFile(HANDLE hMPQ, char * szFileName); -BOOL WINAPI SFileGetFileName(HANDLE hFile, char * szFileName); -DWORD_PTR WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, DWORD dwInfoType); - -// File search -// Note that the SFileFindFirstFileEx has been removed. Use SListFileFindFirst/Next -HANDLE WINAPI SFileFindFirstFile(HANDLE hMPQ, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const char * szListFile); -BOOL WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData); -BOOL WINAPI SFileFindClose(HANDLE hFind); - -// Listfile search -HANDLE SListFileFindFirstFile(HANDLE hMpq, const char * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData); -BOOL SListFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData); -BOOL SListFileFindClose(HANDLE hFind); - -// Archive compacting -typedef void (WINAPI * COMPACTCB)(void * lpUserData, DWORD dwWorkType, DWORD dwParam1, DWORD dwParam2); -BOOL WINAPI SFileSetCompactCallback(HANDLE hMPQ, COMPACTCB CompactCB, void * lpData); -BOOL WINAPI SFileCompactArchive(HANDLE hMPQ, const char * szListFile = NULL, BOOL bReserved = 0); - -// Locale support -int WINAPI SFileEnumLocales(HANDLE hMPQ, const char * szFileName, LCID * plcLocales, DWORD * pdwMaxLocales, DWORD dwSearchScope = SFILE_OPEN_BY_INDEX); - -// (De)compression -int WINAPI SCompCompress (char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int uCompressions, int nCmpType, int nCmpLevel); -int WINAPI SCompDecompress (char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength); - -// Sets the default data compression for files added to MPQ, -// if MPQ_FILE_COMPRESS_MULTI has been specified in call to SFileAddFile -int WINAPI SCompSetDataCompression(int nDataCompression); - -//----------------------------------------------------------------------------- -// Functions from Storm.dll. They use slightly different names for keeping -// possibility to use them together with StormLib (StormXXX instead of SFileXXX) - -#ifdef __LINK_STORM_DLL__ - #define STORM_ALTERNATE_NAMES // Force Storm.h to use alternate fnc names - #include "StormDll.h" -#endif // __LINK_STORM_DLL__ - -//----------------------------------------------------------------------------- -// GFX decode functions. See GfxDecode.cpp for details and description - -USHORT WINAPI celGetFrameCount(BYTE * fileBuf); -BYTE * WINAPI celGetFrameData(BYTE *fileBuf, BYTE *palette, USHORT xsize, USHORT frame, USHORT *ysize, USHORT *maxX=NULL); -USHORT WINAPI cl2GetFrameCount(BYTE *fileBuf); -BYTE ** WINAPI cl2GetDirData(BYTE *fileBuf, BYTE *palette, USHORT xsize, USHORT dir, USHORT *ysize); -BYTE * WINAPI pcxGetData(BYTE *filebuf, DWORD filesize, BYTE transcol, USHORT *xsize, USHORT *ysize); - -#endif // __STORMLIB_H_ +/*****************************************************************************/ +/* StormLib.h Copyright (c) Ladislav Zezula 1999-2005 */ +/*---------------------------------------------------------------------------*/ +/* StormLib library v 5.00 */ +/* */ +/* Author : Ladislav Zezula */ +/* E-mail : ladik@zezula.net */ +/* WWW : http://www.zezula.net */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* xx.xx.99 1.00 Lad Created */ +/* 24.03.03 2.50 Lad Version 2.50 */ +/* 02.04.03 3.00 Lad Version 3.00 with compression */ +/* 11.04.03 3.01 Lad Renamed to StormLib.h for compatibility with */ +/* original headers for Storm.dll */ +/* 10.05.03 3.02 Lad Added Pkware DCL compression */ +/* 26.05.03 4.00 Lad Completed all compressions */ +/* 18.06.03 4.01 Lad Added SFileSetFileLocale */ +/* Added SFileExtractFile */ +/* 26.07.03 4.02 Lad Implemented nameless rename and delete */ +/* 26.07.03 4.03 Lad Added support for protected MPQs */ +/* 28.08.03 4.10 Lad Fixed bugs that caused StormLib incorrectly work */ +/* with Diablo I savegames and with files having full */ +/* hash table */ +/* 08.12.03 4.11 DCH Fixed bug in reading file block larger than 0x1000 */ +/* on certain files. */ +/* Fixed bug in AddFile with MPQ_FILE_REPLACE_EXISTING */ +/* (Thanx Daniel Chiamarello, dchiamarello@madvawes.com)*/ +/* 21.12.03 4.50 Lad Completed port for Mac */ +/* Fixed bug in compacting (if fsize is mul of 0x1000) */ +/* Fixed bug in SCompCompress */ +/* 27.05.04 4.51 Lad Changed memory management from new/delete to our */ +/* own macros */ +/* 22.06.04 4.60 Lad Optimized search. Support for multiple listfiles. */ +/* 30.09.04 4.61 Lad Fixed some bugs (Aaargh !!!) */ +/* Correctly works if HashTableSize > BlockTableSize */ +/* 29.12.04 4.70 Lad Fixed compatibility problem with MPQs from WoW */ +/* 14.07.05 5.00 Lad Added the BZLIB compression support */ +/* Added suport of files stored as single unit */ +/* 17.04.06 5.01 Lad Converted to MS Visual Studio 8.0 */ +/* Fixed issue with protected Warcraft 3 protected maps */ +/* 15.05.06 5.02 Lad Fixed issue with WoW 1.10+ */ +/* 07.09.06 5.10 Lad Fixed processing files longer than 2GB */ +/* 22.11.06 6.00 Lad Support for MPQ archives V2 */ +/*****************************************************************************/ + +#ifndef __STORMLIB_H_ +#define __STORMLIB_H_ + +#include "StormPort.h" + +//----------------------------------------------------------------------------- +// Use the apropriate library +// +// The library type is encoded in the library name as the following +// StormLibXYZ.lib +// +// X - D for Debug version, R for Release version +// Y - A for ANSI version, U for Unicode version (Unicode version does not exist yet) +// Z - S for static C library, D for multithreaded DLL C-library +// + +#define __STORMLIB_SELF__ + +#if defined(_MSC_VER) && !defined (__STORMLIB_SELF__) + #ifdef _DEBUG // DEBUG VERSIONS + #ifdef _DLL + #pragma comment(lib, "StormLibDAD.lib") // Debug Ansi Dynamic version + #else + #pragma comment(lib, "StormLibDAS.lib") // Debug Ansi Static version + #endif + #else // RELEASE VERSIONS + #ifdef _DLL + #pragma comment(lib, "StormLibRAD.lib") // Release Ansi Dynamic version + #else + #pragma comment(lib, "StormLibRAS.lib") // Release Ansi Static version + #endif + #endif +#endif + +//----------------------------------------------------------------------------- +// Defines + +#define ID_MPQ 0x1A51504D // MPQ archive header ID ('MPQ\x1A') +#define ID_MPQ_SHUNT 0x1B51504D // MPQ shunt entry ('MPQ\x1B') + +#define ERROR_AVI_FILE 10000 // No MPQ file, but AVI file. + +// Values for SFileCreateArchiveEx +#define HASH_TABLE_SIZE_MIN 0x00002 +#define HASH_TABLE_SIZE_MAX 0x40000 + +#define HASH_ENTRY_DELETED 0xFFFFFFFE // Block index for deleted hash entry +#define HASH_ENTRY_FREE 0xFFFFFFFF // Block index for free hash entry + +// Values for SFileOpenArchive +#define SFILE_OPEN_HARD_DISK_FILE 2 // Open the archive on HDD +#define SFILE_OPEN_CDROM_FILE 3 // Open the archive only if it is on CDROM + +// Values for SFileOpenFile +#define SFILE_OPEN_FROM_MPQ 0 // Open the file from the MPQ archive +#define SFILE_OPEN_BY_INDEX 1 // The 'szFileName' parameter is actually the file index +#define SFILE_OPEN_LOCAL_FILE (DWORD)-1 // Open the file from the MPQ archive + +// Flags for TMPQArchive::dwFlags +#define MPQ_FLAG_CHANGED 0x00000001 // If set, the MPQ has been changed +#define MPQ_FLAG_PROTECTED 0x00000002 // Set on protected MPQs (like W3M maps) + +// Flags for SFileAddFile +#define MPQ_FILE_COMPRESS_PKWARE 0x00000100 // Compression made by PKWARE Data Compression Library +#define MPQ_FILE_COMPRESS_MULTI 0x00000200 // Multiple compressions +#define MPQ_FILE_COMPRESSED 0x0000FF00 // File is compressed +#define MPQ_FILE_ENCRYPTED 0x00010000 // Indicates whether file is encrypted +#define MPQ_FILE_FIXSEED 0x00020000 // File decrypt seed has to be fixed +#define MPQ_FILE_SINGLE_UNIT 0x01000000 // File is stored as a single unit, rather than split into sectors (Thx, Quantam) +#define MPQ_FILE_DUMMY_FILE 0x02000000 // The file is only 1 byte long and its name is a hash +#define MPQ_FILE_HAS_EXTRA 0x04000000 // The file has extra data appended after regular data. + // Must be with compressed files only +#define MPQ_FILE_EXISTS 0x80000000 // Set if file exists, reset when the file was deleted +#define MPQ_FILE_REPLACEEXISTING 0x80000000 // Replace when the file exist (SFileAddFile) + +#define MPQ_FILE_VALID_FLAGS (MPQ_FILE_COMPRESS_PKWARE | \ + MPQ_FILE_COMPRESS_MULTI | \ + MPQ_FILE_ENCRYPTED | \ + MPQ_FILE_FIXSEED | \ + MPQ_FILE_SINGLE_UNIT | \ + MPQ_FILE_DUMMY_FILE | \ + MPQ_FILE_HAS_EXTRA | \ + MPQ_FILE_EXISTS) + +// Compression types for multilpe compressions +#define MPQ_COMPRESSION_HUFFMANN 0x01 // Huffmann compression (used on WAVE files only) +#define MPQ_COMPRESSION_ZLIB 0x02 // ZLIB compression +#define MPQ_COMPRESSION_PKWARE 0x08 // PKWARE DCL compression +#define MPQ_COMPRESSION_BZIP2 0x10 // BZIP2 compression +#define MPQ_COMPRESSION_WAVE_MONO 0x40 // +#define MPQ_COMPRESSION_WAVE_STEREO 0x80 // + + +// Constants for SFileAddWave +#define MPQ_WAVE_QUALITY_HIGH 0 // Best quality, the worst compression +#define MPQ_WAVE_QUALITY_MEDIUM 1 // Medium quality, medium compression +#define MPQ_WAVE_QUALITY_LOW 2 // Low quality, the best compression + +// Constants for SFileGetFileInfo +#define SFILE_INFO_ARCHIVE_SIZE 1 // MPQ size (value from header) +#define SFILE_INFO_HASH_TABLE_SIZE 2 // Size of hash table, in entries +#define SFILE_INFO_BLOCK_TABLE_SIZE 3 // Number of entries in the block table +#define SFILE_INFO_BLOCK_SIZE 4 // Size of file block (in bytes) +#define SFILE_INFO_HASH_TABLE 5 // Pointer to Hash table (TMPQHash *) +#define SFILE_INFO_BLOCK_TABLE 6 // Pointer to Block Table (TMPQBlock *) +#define SFILE_INFO_NUM_FILES 7 // Real number of files within archive +//------ +#define SFILE_INFO_HASH_INDEX 8 // Hash index of file in MPQ +#define SFILE_INFO_CODENAME1 9 // The first codename of the file +#define SFILE_INFO_CODENAME2 10 // The second codename of the file +#define SFILE_INFO_LOCALEID 11 // Locale ID of file in MPQ +#define SFILE_INFO_BLOCKINDEX 12 // Index to Block Table +#define SFILE_INFO_FILE_SIZE 13 // Original file size +#define SFILE_INFO_COMPRESSED_SIZE 14 // Compressed file size +#define SFILE_INFO_FLAGS 15 // File flags +#define SFILE_INFO_POSITION 16 // File position within archive +#define SFILE_INFO_SEED 17 // File decryption seed +#define SFILE_INFO_SEED_UNFIXED 18 // Decryption seed not fixed to file pos and size + +// Values for compact callback +#define CCB_CHECKING_FILES 1 // Checking archive (dwParam1 = current, dwParam2 = total) +#define CCB_CHECKING_HASH_TABLE 2 // Checking hash table (dwParam1 = current, dwParam2 = total) +#define CCB_COPYING_NON_MPQ_DATA 3 // Copying non-MPQ data: No params used +#define CCB_COMPACTING_FILES 4 // Compacting archive (dwParam1 = current, dwParam2 = total) +#define CCB_CLOSING_ARCHIVE 5 // Closing archive: No params used + +#define LISTFILE_NAME "(listfile)" // Name of internal listfile +#define SIGNATURE_NAME "(signature)" // Name of internal signature +#define ATTRIBUTES_NAME "(attributes)" // Name of internal attributes file + +#define STORMLIB_VERSION (0x0600) // Current version of StormLib + +#define MPQ_FORMAT_VERSION_1 0 // Up to The Burning Crusade +#define MPQ_FORMAT_VERSION_2 1 // The Burning Crusade and newer, + +// Flags for SFileOpenArchiveEx +#define MPQ_OPEN_NO_LISTFILE 0x00000001 // Don't add the internal listfile + +// supports archives with size > 4 GB +// Additional flags for SFileCreateArchiveEx +#define MPQ_CREATE_ARCHIVE_V1 0x00000000 // Creates archive with size up to 4GB +#define MPQ_CREATE_ARCHIVE_V2 0x00010000 // Creates archive larger than 4 GB + +//----------------------------------------------------------------------------- +// Structures + +#if (defined(WIN32) || defined(WIN64)) +#include +#else +#pragma pack(1) +#endif + +struct TMPQFile; + +struct TMPQShunt +{ + // The ID_MPQ_SHUNT ('MPQ\x1B') signature + DWORD dwID; + + DWORD dwUnknown; + + // Position of the MPQ header, relative to the begin of the shunt + DWORD dwHeaderPos; +}; + + +// MPQ file header +struct TMPQHeader +{ + // The ID_MPQ ('MPQ\x1A') signature + DWORD dwID; + + // Size of the archive header + DWORD dwHeaderSize; + + // Size of MPQ archive + // This field is deprecated in the Burning Crusade MoPaQ format, and the size of the archive + // is calculated as the size from the beginning of the archive to the end of the hash table, + // block table, or extended block table (whichever is largest). + DWORD dwArchiveSize; + + // 0 = Original format + // 1 = Extended format (The Burning Crusade and newer) + USHORT wFormatVersion; + + // Power of two exponent specifying the number of 512-byte disk sectors in each logical sector + // in the archive. The size of each logical sector in the archive is 512 * 2^SectorSizeShift. + // Bugs in the Storm library dictate that this should always be 3 (4096 byte sectors). + USHORT wBlockSize; + + // Offset to the beginning of the hash table, relative to the beginning of the archive. + DWORD dwHashTablePos; + + // Offset to the beginning of the block table, relative to the beginning of the archive. + DWORD dwBlockTablePos; + + // Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for + // the original MoPaQ format, or less than 2^20 for the Burning Crusade format. + DWORD dwHashTableSize; + + // Number of entries in the block table + DWORD dwBlockTableSize; +}; + + +// Extended MPQ file header. Valid only if wFormatVersion is 1 or higher +struct TMPQHeader2 : public TMPQHeader +{ + // Offset to the beginning of the extended block table, relative to the beginning of the archive. + LARGE_INTEGER ExtBlockTablePos; + + // High 16 bits of the hash table offset for large archives. + USHORT wHashTablePosHigh; + + // High 16 bits of the block table offset for large archives. + USHORT wBlockTablePosHigh; +}; + + +// Hash entry. All files in the archive are searched by their hashes. +struct TMPQHash +{ + // The hash of the file path, using method A. + DWORD dwName1; + + // The hash of the file path, using method B. + DWORD dwName2; + +#ifdef PLATFORM_LITTLE_ENDIAN + + // The language of the file. This is a Windows LANGID data type, and uses the same values. + // 0 indicates the default language (American English), or that the file is language-neutral. + USHORT lcLocale; + + // The platform the file is used for. 0 indicates the default platform. + // No other values have been observed. + USHORT wPlatform; + +#else + + USHORT wPlatform; + USHORT lcLocale; + +#endif + + // If the hash table entry is valid, this is the index into the block table of the file. + // Otherwise, one of the following two values: + // - FFFFFFFFh: Hash table entry is empty, and has always been empty. + // Terminates searches for a given file. + // - FFFFFFFEh: Hash table entry is empty, but was valid at some point (a deleted file). + // Does not terminate searches for a given file. + DWORD dwBlockIndex; +}; + + +// File description block contains informations about the file +struct TMPQBlock +{ + // Offset of the beginning of the block, relative to the beginning of the archive. + DWORD dwFilePos; + + // Compressed file size + DWORD dwCSize; + + // Only valid if the block is a file; otherwise meaningless, and should be 0. + // If the file is compressed, this is the size of the uncompressed file data. + DWORD dwFSize; + + // Flags for the file. See MPQ_FILE_XXXX constants + DWORD dwFlags; +}; + + +// The extended block table was added to support archives larger than 4 gigabytes (2^32 bytes). +// The table contains the upper bits of the archive offsets for each block in the block table. +// It is simply an array of int16s, which become bits 32-47 of the archive offsets for each block, +// with bits 48-63 being zero. Individual blocks in the archive are still limited to 4 gigabytes +// in size. This table is only present in Burning Crusade format archives that exceed 4 gigabytes size. +struct TMPQBlockEx +{ + USHORT wFilePosHigh; +}; + + +struct TFileNode +{ + DWORD dwRefCount; // Number of references + // There can be more files that have the same name. + // (e.g. multiple language files). We don't want to + // have an entry for each of them, so the entries will be referenced. + // When a number of node references reaches zero, + // the node will be deleted + + size_t nLength; // File name length + char szFileName[1]; // File name, variable length +}; + +#if (defined(WIN32) || defined(WIN64)) +#include +#else +#pragma options align=reset +#endif + +// Archive handle structure. Note that it does not agree with Storm.dll's structure. +struct TMPQArchive +{ +// TMPQArchive * pNext; // Next archive (used by Storm.dll only) +// TMPQArchive * pPrev; // Previous archive (used by Storm.dll only) + char szFileName[MAX_PATH]; // Opened archive file name + HANDLE hFile; // File handle + DWORD dwPriority; // Priority of the archive + LARGE_INTEGER ShuntPos; // Position of MPQShunt (only valid if a shunt is present) + LARGE_INTEGER MpqPos; // MPQ position in the file, relative to the begin of the file + LARGE_INTEGER MpqSize; // Size of MPQ archive + LARGE_INTEGER HashTablePos; // Offset of the hast table in the MPQ, relative to the begin of the file + LARGE_INTEGER BlockTablePos; // Offset of the hast table in the MPQ, relative to the begin + LARGE_INTEGER ExtBlockTablePos; // Offset of the extended block table, relative to the begin + LARGE_INTEGER FilePointer; // Current position in the file (relative to begin of the file) + + TMPQFile * pLastFile; // Recently read file + DWORD dwBlockPos; // Position of loaded block in the file + DWORD dwBlockSize; // Size of file block + BYTE * pbBlockBuffer; // Buffer (cache) for file block + DWORD dwBuffPos; // Position in block buffer + TMPQShunt * pShunt; // MPQ shunt (NULL if not present in the file) + TMPQHeader2 * pHeader; // MPQ file header + TMPQHash * pHashTable; // Hash table + TMPQBlock * pBlockTable; // Block table + TMPQBlockEx * pExtBlockTable; // Extended block table + + TMPQShunt Shunt; // MPQ shunt. Valid only when ID_MPQ_SHUNT has been found + TMPQHeader2 Header; // MPQ header + + // Non-Storm.dll members + TFileNode ** pListFile; // File name array +// HANDLE hListFile; // Handle to temporary listfile (when open with write access) + DWORD dwFlags; // See MPQ_FLAG_XXXXX +// BOOL bChanged; // TRUE if the archive was changed since open. +// BOOL bProtected; // TRUE if the archive is protected by somehow +}; + + +// File handle structure. Note that it does not agree with Storm.dll structures +struct TMPQFile +{ + HANDLE hFile; // File handle + TMPQArchive * ha; // Archive handle + TMPQHash * pHash; // Hash table entry + TMPQBlockEx * pBlockEx; // Pointer to extended file block entry + TMPQBlock * pBlock; // File block pointer + DWORD dwSeed1; // Seed used for file decrypt + DWORD dwFilePos; // Current file position + LARGE_INTEGER MpqFilePos; // Position of the file data in MPQ archive + // (relative to file begin) + + DWORD * pdwBlockPos; // Position of each file block (only for compressed files) + DWORD nBlocks; // Number of blocks in the file (incl. the last noncomplete one) + BOOL bBlockPosLoaded; // TRUE if block positions loaded + BYTE * pbFileBuffer; // Decompressed file (for single unit files, size is the uncompressed file size) + + DWORD dwHashIndex; // Index to Hash table + DWORD dwFileIndex; // Index to Block table + char szFileName[1]; // File name (variable length) +}; + + +// Used by searching in MPQ archives +struct TMPQSearch +{ + TMPQArchive * ha; // Handle to MPQ, where the search runs + DWORD dwNextIndex; // The next searched hash index + DWORD dwName1; // Lastly found Name1 + DWORD dwName2; // Lastly found Name2 + char szSearchMask[1]; // Search mask (variable length) +}; + + +struct SFILE_FIND_DATA +{ + char cFileName[MAX_PATH]; // Full name of the found file + char * szPlainName; // Pointer to file part + LCID lcLocale; // Locale version + DWORD dwFileSize; // File size in bytes + DWORD dwFileFlags; // File flags (compressed or encrypted) + DWORD dwBlockIndex; // Block index for the file + DWORD dwCompSize; // Compressed file size +}; + +//----------------------------------------------------------------------------- +// Memory management +// +// We use our own macros for allocating/freeing memory. If you want +// to redefine them, please keep the following rules +// +// - The memory allocation must return NULL if not enough memory +// (i.e not to throw exception) +// - It is not necessary to fill the allocated block with zeros +// - Memory freeing function must not test the pointer to NULL. +// + + +__inline void * DebugMalloc(char * szFile, int nLine, int nSize) +{ + void * ptr = malloc(nSize + 100); + char * plain; + + plain = strrchr(szFile, '\\'); + if(plain == NULL) + plain = strrchr(szFile, '/'); + if(plain == NULL) + plain = szFile; + +#if _MSC_VER > 0x1300 + sprintf_s((char *)ptr, nSize+100, "%s(%u)", plain, nLine); +#else + sprintf((char *)ptr, "%s(%u)", plain, nLine); +#endif + + return (char *)ptr + 100; +} + + +__inline void DebugFree(void * ptr) +{ + free((char *)ptr - 100); +} + + +#ifndef ALLOCMEM + #define ALLOCMEM(type, nitems) (type *)malloc((nitems) * sizeof(type)) + #define FREEMEM(ptr) free(ptr) +#endif + +//#define ALLOCMEM(type, nitems) (type *)DebugMalloc(__FILE__, __LINE__, (nitems) * sizeof(type)) +//#define FREEMEM(ptr) DebugFree(ptr) + +//----------------------------------------------------------------------------- +// Functions in StormLib - compatible with Storm.dll + +// Typedefs for functions exported by Storm.dll +typedef LCID (WINAPI * SFILESETLOCALE)(LCID); +typedef BOOL (WINAPI * SFILEOPENARCHIVE)(const char *, DWORD, DWORD, HANDLE *); +typedef BOOL (WINAPI * SFILECLOSEARCHIVE)(HANDLE); +typedef BOOL (WINAPI * SFILEOPENFILEEX)(HANDLE, const char *, DWORD, HANDLE *); +typedef BOOL (WINAPI * SFILECLOSEFILE)(HANDLE); +typedef DWORD (WINAPI * SFILEGETFILESIZE)(HANDLE, DWORD *); +typedef DWORD (WINAPI * SFILESETFILEPOINTER)(HANDLE, LONG, LONG *, DWORD); +typedef BOOL (WINAPI * SFILEREADFILE)(HANDLE, VOID *, DWORD, DWORD *, LPOVERLAPPED); + +// Archive opening/closing +LCID WINAPI SFileSetLocale(LCID lcNewLocale); +LCID WINAPI SFileGetLocale(); +BOOL WINAPI SFileOpenArchive(const char * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMPQ); +BOOL WINAPI SFileCloseArchive(HANDLE hMPQ); + +// File opening/closing +BOOL WINAPI SFileOpenFileEx(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope, HANDLE * phFile); +BOOL WINAPI SFileCloseFile(HANDLE hFile); + +// File I/O +DWORD WINAPI SFileGetFilePos(HANDLE hFile, DWORD * pdwFilePosHigh = NULL); +DWORD WINAPI SFileGetFileSize(HANDLE hFile, DWORD * pdwFileSizeHigh = NULL); +DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * pdwFilePosHigh, DWORD dwMethod); +BOOL WINAPI SFileReadFile(HANDLE hFile, VOID * lpBuffer, DWORD dwToRead, DWORD * pdwRead = NULL, LPOVERLAPPED lpOverlapped = NULL); + +BOOL WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const char * szExtracted); + +// Adds another listfile into MPQ. The currently added listfile(s) remain, +// so you can use this API to combining more listfiles. +// Note that this function is internally called by SFileFindFirstFile +int WINAPI SFileAddListFile(HANDLE hMpq, const char * szListFile); + +//----------------------------------------------------------------------------- +// Functions in StormLib - not implemented in Storm.dll + +// Archive creating and editing +BOOL WINAPI SFileCreateArchiveEx(const char * szMpqName, DWORD dwCreationDisposition, DWORD dwHashTableSize, HANDLE * phMPQ); +BOOL WINAPI SFileAddFile(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags); +BOOL WINAPI SFileAddWave(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality); +BOOL WINAPI SFileRemoveFile(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope = SFILE_OPEN_BY_INDEX); +BOOL WINAPI SFileRenameFile(HANDLE hMPQ, const char * szOldFileName, const char * szNewFileName); +BOOL WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale); + +// Retrieving info about the file +BOOL WINAPI SFileHasFile(HANDLE hMPQ, char * szFileName); +BOOL WINAPI SFileGetFileName(HANDLE hFile, char * szFileName); +DWORD_PTR WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, DWORD dwInfoType); + +// File search +// Note that the SFileFindFirstFileEx has been removed. Use SListFileFindFirst/Next +HANDLE WINAPI SFileFindFirstFile(HANDLE hMPQ, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const char * szListFile); +BOOL WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData); +BOOL WINAPI SFileFindClose(HANDLE hFind); + +// Listfile search +HANDLE SListFileFindFirstFile(HANDLE hMpq, const char * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData); +BOOL SListFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData); +BOOL SListFileFindClose(HANDLE hFind); + +// Archive compacting +typedef void (WINAPI * COMPACTCB)(void * lpUserData, DWORD dwWorkType, DWORD dwParam1, DWORD dwParam2); +BOOL WINAPI SFileSetCompactCallback(HANDLE hMPQ, COMPACTCB CompactCB, void * lpData); +BOOL WINAPI SFileCompactArchive(HANDLE hMPQ, const char * szListFile = NULL, BOOL bReserved = 0); + +// Locale support +int WINAPI SFileEnumLocales(HANDLE hMPQ, const char * szFileName, LCID * plcLocales, DWORD * pdwMaxLocales, DWORD dwSearchScope = SFILE_OPEN_BY_INDEX); + +// (De)compression +int WINAPI SCompCompress (char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int uCompressions, int nCmpType, int nCmpLevel); +int WINAPI SCompDecompress (char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength); + +// Sets the default data compression for files added to MPQ, +// if MPQ_FILE_COMPRESS_MULTI has been specified in call to SFileAddFile +int WINAPI SCompSetDataCompression(int nDataCompression); + +//----------------------------------------------------------------------------- +// Functions from Storm.dll. They use slightly different names for keeping +// possibility to use them together with StormLib (StormXXX instead of SFileXXX) + +#ifdef __LINK_STORM_DLL__ + #define STORM_ALTERNATE_NAMES // Force Storm.h to use alternate fnc names + #include "StormDll.h" +#endif // __LINK_STORM_DLL__ + +//----------------------------------------------------------------------------- +// GFX decode functions. See GfxDecode.cpp for details and description + +USHORT WINAPI celGetFrameCount(BYTE * fileBuf); +BYTE * WINAPI celGetFrameData(BYTE *fileBuf, BYTE *palette, USHORT xsize, USHORT frame, USHORT *ysize, USHORT *maxX=NULL); +USHORT WINAPI cl2GetFrameCount(BYTE *fileBuf); +BYTE ** WINAPI cl2GetDirData(BYTE *fileBuf, BYTE *palette, USHORT xsize, USHORT dir, USHORT *ysize); +BYTE * WINAPI pcxGetData(BYTE *filebuf, DWORD filesize, BYTE transcol, USHORT *xsize, USHORT *ysize); + +#endif // __STORMLIB_H_ diff --git a/src/tools/stuffextract/StormLib/StormPort.h b/src/tools/stuffextract/StormLib/StormPort.h index 35f12f6..4cb8d84 100644 --- a/src/tools/stuffextract/StormLib/StormPort.h +++ b/src/tools/stuffextract/StormLib/StormPort.h @@ -1,278 +1,278 @@ -/*****************************************************************************/ -/* StormPort.h Copyright (c) Marko Friedemann 2001 */ -/*---------------------------------------------------------------------------*/ -/* Portability module for the StormLib library. Contains a wrapper symbols */ -/* to make the compilation under Linux work */ -/* */ -/* Author: Marko Friedemann */ -/* Created at: Mon Jan 29 18:26:01 CEST 2001 */ -/* Computer: whiplash.flachland-chemnitz.de */ -/* System: Linux 2.4.0 on i686 */ -/* */ -/* Author: Sam Wilkins */ -/* System: Mac OS X and port to big endian processor */ -/* */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 29.01.01 1.00 Mar Created */ -/* 24.03.03 1.01 Lad Some cosmetic changes */ -/* 12.11.03 1.02 Dan Macintosh compatibility */ -/* 24.07.04 1.03 Sam Mac OS X compatibility */ -/* 22.11.06 1.04 Sam Mac OS X compatibility (for StormLib 6.0) */ -/* 31.12.06 1.05 XPinguin Full GNU/Linux compatibility */ -/*****************************************************************************/ - -#ifndef __STORMPORT_H__ -#define __STORMPORT_H__ - -// Defines for Windows -#if !defined(PLATFORM_DEFINED) && (defined(WIN32) || defined(WIN64)) - - // In MSVC 8.0, there are some functions declared as deprecated. - #if _MSC_VER >= 1400 - #define _CRT_SECURE_NO_DEPRECATE - #define _CRT_NON_CONFORMING_SWPRINTFS - #endif - - #include - #include - #include - #define PLATFORM_LITTLE_ENDIAN 1 - - #ifdef WIN64 - #define PLATFORM_64BIT - #else - #define PLATFORM_32BIT - #endif - - #define PLATFORM_DEFINED // The platform is known now - -#endif - -// Defines for Mac Carbon -#if !defined(PLATFORM_DEFINED) && defined(__APPLE__) // Mac Carbon API - - // Macintosh using Carbon - #include // Mac OS X - #define _stricmp strcasecmp // Case insensitive strcmp has a different name on this platform. - #define _strnicmp strncasecmp - - typedef void * LPCSTR; - typedef unsigned long * LPDWORD; - typedef long * PLONG; - typedef void * LPVOID; - typedef unsigned int UINT; - - #define PKEXPORT - #define __SYS_ZLIB - #define __SYS_BZLIB - #define LANG_NEUTRAL 0 - - #if defined(__BIG_ENDIAN__) - #define PLATFORM_LITTLE_ENDIAN 0 - #else - #define PLATFORM_LITTLE_ENDIAN 1 // Apple is now making Macs with Intel CPUs - #endif - #define PLATFORM_DEFINED // The platform is known now - -#endif - -// Assumption: we are not on Windows nor Macintosh, so this must be linux *grin* -// Ladik : Why the hell Linux does not use some OS-dependent #define ? -#if !defined(PLATFORM_DEFINED) - - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - #define PLATFORM_LITTLE_ENDIAN 1 - #define PLATFORM_DEFINED - #define LANG_NEUTRAL 0 - -#endif /* not __powerc */ - - -#if !defined(WIN32) && !defined(WIN64) - - // Typedefs for ANSI C - typedef unsigned char BYTE; - typedef short SHORT; - typedef unsigned short WORD; - typedef unsigned short USHORT; - typedef long LONG; - typedef unsigned long DWORD; - typedef unsigned long DWORD_PTR; - typedef long LONG_PTR; - typedef long long LONGLONG; -#ifndef __OBJC__ - #define BOOL bool -#endif - typedef void * HANDLE; - typedef void * LPOVERLAPPED; // Unsupported on Linux - typedef char TCHAR; - typedef unsigned long LCID; - - typedef void * LPCSTR; - typedef unsigned long * LPDWORD; - typedef long * PLONG; - typedef void * LPVOID; - typedef unsigned int UINT; - - typedef struct _FILETIME - { - DWORD dwLowDateTime; - DWORD dwHighDateTime; - } - FILETIME, *PFILETIME; - - typedef union _LARGE_INTEGER - { - #if PLATFORM_LITTLE_ENDIAN - struct - { - DWORD LowPart; - LONG HighPart; - }; - #else - struct - { - LONG HighPart; - DWORD LowPart; - }; - #endif - LONGLONG QuadPart; - } - LARGE_INTEGER, *PLARGE_INTEGER; - - // Some Windows-specific defines - #ifndef MAX_PATH - #define MAX_PATH 1024 - #endif - - #ifndef TRUE - #define TRUE true - #endif - - #ifndef FALSE - #define FALSE false - #endif - - #define VOID void - #define WINAPI - - #define FILE_BEGIN SEEK_SET - #define FILE_CURRENT SEEK_CUR - #define FILE_END SEEK_END - - #define CREATE_NEW 1 - #define CREATE_ALWAYS 2 - #define OPEN_EXISTING 3 - #define OPEN_ALWAYS 4 - - #define FILE_SHARE_READ 0x00000001L - #define GENERIC_WRITE 0x40000000 - #define GENERIC_READ 0x80000000 - - #define FILE_FLAG_DELETE_ON_CLOSE 1 // Sam: Added these two defines so it would compile. - #define FILE_FLAG_SEQUENTIAL_SCAN 2 - - #define ERROR_SUCCESS 0 - #define ERROR_INVALID_FUNCTION 1 - #define ERROR_FILE_NOT_FOUND 2 - #define ERROR_ACCESS_DENIED 5 - #define ERROR_NOT_ENOUGH_MEMORY 8 - #define ERROR_BAD_FORMAT 11 - #define ERROR_NO_MORE_FILES 18 - #define ERROR_GEN_FAILURE 31 - #define ERROR_HANDLE_EOF 38 - #define ERROR_HANDLE_DISK_FULL 39 - #define ERROR_NOT_SUPPORTED 50 - #define ERROR_INVALID_PARAMETER 87 - #define ERROR_DISK_FULL 112 - #define ERROR_CALL_NOT_IMPLEMENTED 120 - #define ERROR_ALREADY_EXISTS 183 - #define ERROR_CAN_NOT_COMPLETE 1003 - #define ERROR_PARAMETER_QUOTA_EXCEEDED 1283 - #define ERROR_FILE_CORRUPT 1392 - #define ERROR_INSUFFICIENT_BUFFER 4999 - - #define INVALID_HANDLE_VALUE ((HANDLE) -1) - - #ifndef min - #define min(a, b) ((a < b) ? a : b) - #endif - - #ifndef max - #define max(a, b) ((a > b) ? a : b) - #endif - - #define _stricmp strcasecmp - #define _strnicmp strncasecmp - - extern int globalerr; - - void SetLastError(int err); - int GetLastError(); - char *ErrString(int err); - - // Emulation of functions for file I/O available in Win32 - HANDLE CreateFile(const char * lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, void * lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); - BOOL CloseHandle(HANDLE hObject); - - DWORD GetFileSize(HANDLE hFile, DWORD * lpFileSizeHigh); - DWORD SetFilePointer(HANDLE, LONG lDistanceToMove, LONG * lpDistanceToMoveHigh, DWORD dwMoveMethod); - BOOL SetEndOfFile(HANDLE hFile); - - BOOL ReadFile(HANDLE hFile, void * lpBuffer, DWORD nNumberOfBytesToRead, DWORD * lpNumberOfBytesRead, void * lpOverLapped); - BOOL WriteFile(HANDLE hFile, const void * lpBuffer, DWORD nNumberOfBytesToWrite, DWORD * lpNumberOfBytesWritten, void * lpOverLapped); - - BOOL IsBadReadPtr(const void * ptr, int size); - DWORD GetFileAttributes(const char * szileName); - - BOOL DeleteFile(const char * lpFileName); - BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName); - void GetTempPath(DWORD szTempLength, char * szTemp); - void GetTempFileName(const char * lpTempFolderPath, const char * lpFileName, DWORD something, char * szLFName); - - #define strnicmp strncasecmp - -#endif // !WIN32 - -#if PLATFORM_LITTLE_ENDIAN - #define BSWAP_INT16_UNSIGNED(a) (a) - #define BSWAP_INT16_SIGNED(a) (a) - #define BSWAP_INT32_UNSIGNED(a) (a) - #define BSWAP_INT32_SIGNED(a) (a) - #define BSWAP_ARRAY16_UNSIGNED(a,b) {} - #define BSWAP_ARRAY32_UNSIGNED(a,b) {} - #define BSWAP_TMPQSHUNT(a) {} - #define BSWAP_TMPQHEADER(a) {} -#else - extern unsigned short SwapUShort(unsigned short); - extern unsigned long SwapULong(unsigned long); - extern short SwapShort(unsigned short); - extern long SwapLong(unsigned long); - extern void ConvertUnsignedLongBuffer(unsigned long *buffer, unsigned long nbLongs); - extern void ConvertUnsignedShortBuffer(unsigned short *buffer, unsigned long nbShorts); - extern void ConvertTMPQShunt(void *shunt); - extern void ConvertTMPQHeader(void *header); - #define BSWAP_INT16_UNSIGNED(a) SwapUShort((a)) - #define BSWAP_INT32_UNSIGNED(a) SwapULong((a)) - #define BSWAP_INT16_SIGNED(a) SwapShort((a)) - #define BSWAP_INT32_SIGNED(a) SwapLong((a)) - #define BSWAP_ARRAY16_UNSIGNED(a,b) ConvertUnsignedShortBuffer((a),(b)) - #define BSWAP_ARRAY32_UNSIGNED(a,b) ConvertUnsignedLongBuffer((a),(b)) - #define BSWAP_TMPQSHUNT(a) ConvertTMPQShunt((a)) - #define BSWAP_TMPQHEADER(a) ConvertTMPQHeader((a)) -#endif - -#endif // __STORMPORT_H__ +/*****************************************************************************/ +/* StormPort.h Copyright (c) Marko Friedemann 2001 */ +/*---------------------------------------------------------------------------*/ +/* Portability module for the StormLib library. Contains a wrapper symbols */ +/* to make the compilation under Linux work */ +/* */ +/* Author: Marko Friedemann */ +/* Created at: Mon Jan 29 18:26:01 CEST 2001 */ +/* Computer: whiplash.flachland-chemnitz.de */ +/* System: Linux 2.4.0 on i686 */ +/* */ +/* Author: Sam Wilkins */ +/* System: Mac OS X and port to big endian processor */ +/* */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 29.01.01 1.00 Mar Created */ +/* 24.03.03 1.01 Lad Some cosmetic changes */ +/* 12.11.03 1.02 Dan Macintosh compatibility */ +/* 24.07.04 1.03 Sam Mac OS X compatibility */ +/* 22.11.06 1.04 Sam Mac OS X compatibility (for StormLib 6.0) */ +/* 31.12.06 1.05 XPinguin Full GNU/Linux compatibility */ +/*****************************************************************************/ + +#ifndef __STORMPORT_H__ +#define __STORMPORT_H__ + +// Defines for Windows +#if !defined(PLATFORM_DEFINED) && (defined(WIN32) || defined(WIN64)) + + // In MSVC 8.0, there are some functions declared as deprecated. + #if _MSC_VER >= 1400 + #define _CRT_SECURE_NO_DEPRECATE + #define _CRT_NON_CONFORMING_SWPRINTFS + #endif + + #include + #include + #include + #define PLATFORM_LITTLE_ENDIAN 1 + + #ifdef WIN64 + #define PLATFORM_64BIT + #else + #define PLATFORM_32BIT + #endif + + #define PLATFORM_DEFINED // The platform is known now + +#endif + +// Defines for Mac Carbon +#if !defined(PLATFORM_DEFINED) && defined(__APPLE__) // Mac Carbon API + + // Macintosh using Carbon + #include // Mac OS X + #define _stricmp strcasecmp // Case insensitive strcmp has a different name on this platform. + #define _strnicmp strncasecmp + + typedef void * LPCSTR; + typedef unsigned long * LPDWORD; + typedef long * PLONG; + typedef void * LPVOID; + typedef unsigned int UINT; + + #define PKEXPORT + #define __SYS_ZLIB + #define __SYS_BZLIB + #define LANG_NEUTRAL 0 + + #if defined(__BIG_ENDIAN__) + #define PLATFORM_LITTLE_ENDIAN 0 + #else + #define PLATFORM_LITTLE_ENDIAN 1 // Apple is now making Macs with Intel CPUs + #endif + #define PLATFORM_DEFINED // The platform is known now + +#endif + +// Assumption: we are not on Windows nor Macintosh, so this must be linux *grin* +// Ladik : Why the hell Linux does not use some OS-dependent #define ? +#if !defined(PLATFORM_DEFINED) + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #define PLATFORM_LITTLE_ENDIAN 1 + #define PLATFORM_DEFINED + #define LANG_NEUTRAL 0 + +#endif /* not __powerc */ + + +#if !defined(WIN32) && !defined(WIN64) + + // Typedefs for ANSI C + typedef unsigned char BYTE; + typedef short SHORT; + typedef unsigned short WORD; + typedef unsigned short USHORT; + typedef long LONG; + typedef unsigned long DWORD; + typedef unsigned long DWORD_PTR; + typedef long LONG_PTR; + typedef long long LONGLONG; +#ifndef __OBJC__ + #define BOOL bool +#endif + typedef void * HANDLE; + typedef void * LPOVERLAPPED; // Unsupported on Linux + typedef char TCHAR; + typedef unsigned long LCID; + + typedef void * LPCSTR; + typedef unsigned long * LPDWORD; + typedef long * PLONG; + typedef void * LPVOID; + typedef unsigned int UINT; + + typedef struct _FILETIME + { + DWORD dwLowDateTime; + DWORD dwHighDateTime; + } + FILETIME, *PFILETIME; + + typedef union _LARGE_INTEGER + { + #if PLATFORM_LITTLE_ENDIAN + struct + { + DWORD LowPart; + LONG HighPart; + }; + #else + struct + { + LONG HighPart; + DWORD LowPart; + }; + #endif + LONGLONG QuadPart; + } + LARGE_INTEGER, *PLARGE_INTEGER; + + // Some Windows-specific defines + #ifndef MAX_PATH + #define MAX_PATH 1024 + #endif + + #ifndef TRUE + #define TRUE true + #endif + + #ifndef FALSE + #define FALSE false + #endif + + #define VOID void + #define WINAPI + + #define FILE_BEGIN SEEK_SET + #define FILE_CURRENT SEEK_CUR + #define FILE_END SEEK_END + + #define CREATE_NEW 1 + #define CREATE_ALWAYS 2 + #define OPEN_EXISTING 3 + #define OPEN_ALWAYS 4 + + #define FILE_SHARE_READ 0x00000001L + #define GENERIC_WRITE 0x40000000 + #define GENERIC_READ 0x80000000 + + #define FILE_FLAG_DELETE_ON_CLOSE 1 // Sam: Added these two defines so it would compile. + #define FILE_FLAG_SEQUENTIAL_SCAN 2 + + #define ERROR_SUCCESS 0 + #define ERROR_INVALID_FUNCTION 1 + #define ERROR_FILE_NOT_FOUND 2 + #define ERROR_ACCESS_DENIED 5 + #define ERROR_NOT_ENOUGH_MEMORY 8 + #define ERROR_BAD_FORMAT 11 + #define ERROR_NO_MORE_FILES 18 + #define ERROR_GEN_FAILURE 31 + #define ERROR_HANDLE_EOF 38 + #define ERROR_HANDLE_DISK_FULL 39 + #define ERROR_NOT_SUPPORTED 50 + #define ERROR_INVALID_PARAMETER 87 + #define ERROR_DISK_FULL 112 + #define ERROR_CALL_NOT_IMPLEMENTED 120 + #define ERROR_ALREADY_EXISTS 183 + #define ERROR_CAN_NOT_COMPLETE 1003 + #define ERROR_PARAMETER_QUOTA_EXCEEDED 1283 + #define ERROR_FILE_CORRUPT 1392 + #define ERROR_INSUFFICIENT_BUFFER 4999 + + #define INVALID_HANDLE_VALUE ((HANDLE) -1) + + #ifndef min + #define min(a, b) ((a < b) ? a : b) + #endif + + #ifndef max + #define max(a, b) ((a > b) ? a : b) + #endif + + #define _stricmp strcasecmp + #define _strnicmp strncasecmp + + extern int globalerr; + + void SetLastError(int err); + int GetLastError(); + char *ErrString(int err); + + // Emulation of functions for file I/O available in Win32 + HANDLE CreateFile(const char * lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, void * lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); + BOOL CloseHandle(HANDLE hObject); + + DWORD GetFileSize(HANDLE hFile, DWORD * lpFileSizeHigh); + DWORD SetFilePointer(HANDLE, LONG lDistanceToMove, LONG * lpDistanceToMoveHigh, DWORD dwMoveMethod); + BOOL SetEndOfFile(HANDLE hFile); + + BOOL ReadFile(HANDLE hFile, void * lpBuffer, DWORD nNumberOfBytesToRead, DWORD * lpNumberOfBytesRead, void * lpOverLapped); + BOOL WriteFile(HANDLE hFile, const void * lpBuffer, DWORD nNumberOfBytesToWrite, DWORD * lpNumberOfBytesWritten, void * lpOverLapped); + + BOOL IsBadReadPtr(const void * ptr, int size); + DWORD GetFileAttributes(const char * szileName); + + BOOL DeleteFile(const char * lpFileName); + BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName); + void GetTempPath(DWORD szTempLength, char * szTemp); + void GetTempFileName(const char * lpTempFolderPath, const char * lpFileName, DWORD something, char * szLFName); + + #define strnicmp strncasecmp + +#endif // !WIN32 + +#if PLATFORM_LITTLE_ENDIAN + #define BSWAP_INT16_UNSIGNED(a) (a) + #define BSWAP_INT16_SIGNED(a) (a) + #define BSWAP_INT32_UNSIGNED(a) (a) + #define BSWAP_INT32_SIGNED(a) (a) + #define BSWAP_ARRAY16_UNSIGNED(a,b) {} + #define BSWAP_ARRAY32_UNSIGNED(a,b) {} + #define BSWAP_TMPQSHUNT(a) {} + #define BSWAP_TMPQHEADER(a) {} +#else + extern unsigned short SwapUShort(unsigned short); + extern unsigned long SwapULong(unsigned long); + extern short SwapShort(unsigned short); + extern long SwapLong(unsigned long); + extern void ConvertUnsignedLongBuffer(unsigned long *buffer, unsigned long nbLongs); + extern void ConvertUnsignedShortBuffer(unsigned short *buffer, unsigned long nbShorts); + extern void ConvertTMPQShunt(void *shunt); + extern void ConvertTMPQHeader(void *header); + #define BSWAP_INT16_UNSIGNED(a) SwapUShort((a)) + #define BSWAP_INT32_UNSIGNED(a) SwapULong((a)) + #define BSWAP_INT16_SIGNED(a) SwapShort((a)) + #define BSWAP_INT32_SIGNED(a) SwapLong((a)) + #define BSWAP_ARRAY16_UNSIGNED(a,b) ConvertUnsignedShortBuffer((a),(b)) + #define BSWAP_ARRAY32_UNSIGNED(a,b) ConvertUnsignedLongBuffer((a),(b)) + #define BSWAP_TMPQSHUNT(a) ConvertTMPQShunt((a)) + #define BSWAP_TMPQHEADER(a) ConvertTMPQHeader((a)) +#endif + +#endif // __STORMPORT_H__ diff --git a/src/tools/stuffextract/StormLib/StormPortLinux.cpp b/src/tools/stuffextract/StormLib/StormPortLinux.cpp index 9fd31f3..0cd827f 100644 --- a/src/tools/stuffextract/StormLib/StormPortLinux.cpp +++ b/src/tools/stuffextract/StormLib/StormPortLinux.cpp @@ -1,168 +1,168 @@ -/******************************************************************** -* -* Description: implementation for StormLib - linux port -* intended to be used in GLdiablo -* -* ----> StormLib was originally developed for Windows by -* Ladislav Zezula (www.zezula.net), and he did -* a _great_ job! Thanks Ladislav! -* -* this is currently a quick and dirty hack to get it working -* don't expect beauty and/or miracles :) -* -* these are function wraps to execute Windows API calls -* as native Macintosh file calls (open/close/read/write/...) -* -* continue you work: added some wrapping functions for GNU/Linux by XPinguin -* -* Author: Marko Friedemann -* Created at: Mon Jan 29 19:01:37 CEST 2001 -* Computer: whiplash.flachland-chemnitz.de -* System: Linux 2.4.0 on i686 -* -* Copyright (c) 2001 BMX-Chemnitz.DE All rights reserved. -* -********************************************************************/ - -#ifndef _WIN32 -#include "StormPort.h" - -int globalerr; - -void SetLastError(int err) -{ - globalerr = err; -} - -int GetLastError() -{ - return(globalerr); -} - -char *ErrString(int err) -{ - switch (err) { - case ERROR_INVALID_FUNCTION: - return "function not implemented"; - case ERROR_FILE_NOT_FOUND: - return "file not found"; - case ERROR_ACCESS_DENIED: - return "access denied"; - case ERROR_NOT_ENOUGH_MEMORY: - return "not enough memory"; - case ERROR_BAD_FORMAT: - return "bad format"; - case ERROR_NO_MORE_FILES: - return "no more files"; - case ERROR_HANDLE_EOF: - return "access beyound EOF"; - case ERROR_HANDLE_DISK_FULL: - return "no space left on device"; - case ERROR_INVALID_PARAMETER: - return "invalid parameter"; - case ERROR_DISK_FULL: - return "no space left on device"; - case ERROR_ALREADY_EXISTS: - return "file exists"; - case ERROR_CAN_NOT_COMPLETE: - return "operation cannot be completed"; - default: - return "unknown error"; - } -} - -HANDLE CreateFile(const char *sFileName, DWORD ulMode, DWORD ulSharing, void *pSecAttrib, DWORD ulCreation, DWORD ulFlags, HANDLE hFile) -{ - switch (ulCreation) { - case OPEN_EXISTING: - return (HANDLE)open(sFileName, O_RDONLY | O_LARGEFILE); - case OPEN_ALWAYS: - return (HANDLE)open(sFileName, O_RDWR | O_CREAT); - case CREATE_NEW: - return (HANDLE)open(sFileName, O_RDWR | O_CREAT | O_TRUNC); - default: - return INVALID_HANDLE_VALUE; - } -} - -BOOL CloseHandle(HANDLE hFile) -{ - return (close((int)hFile) == 0); -} - -DWORD GetFileSize(HANDLE hFile, DWORD *ulOffSetHigh) -{ - if ((hFile == NULL) || (hFile == INVALID_HANDLE_VALUE)) - return 0xffffffff; - - struct stat fileinfo; - fstat((int)hFile, &fileinfo); - - return fileinfo.st_size; -} - -DWORD SetFilePointer(HANDLE hFile, LONG lOffSetLow, LONG *pOffSetHigh, DWORD ulMethod) -{ - return lseek64((int)hFile, (off64_t)(*pOffSetHigh) << 32 | (DWORD)lOffSetLow, ulMethod); -} - -BOOL SetEndOfFile(HANDLE hFile) -{ - return (ftruncate((int)hFile, lseek((int)hFile, 0, SEEK_CUR)) == 0); -} - -BOOL ReadFile(HANDLE hFile, void *pBuffer, DWORD ulLen, DWORD *ulRead, void *pOverLapped) -{ - ssize_t count; - if ((count = read((int)hFile, pBuffer, ulLen)) == -1) { - *ulRead = 0; - return false; - } - *ulRead = count; - return true; -} - -BOOL WriteFile(HANDLE hFile, const void *pBuffer, DWORD ulLen, DWORD *ulWritten, void *pOverLapped) -{ - ssize_t count; - if ((count = write((int)hFile, pBuffer, ulLen)) == -1) { - *ulWritten = 0; - return false; - } - *ulWritten = count; - return true; -} - -// Check if a memory block is accessible for reading -BOOL IsBadReadPtr(const void * ptr, int size) -{ - return FALSE; -} - -// Returns attributes of a file -DWORD GetFileAttributes(const char * szFileName) -{ - return 0; -} - -void GetTempPath(DWORD szTempLength, char * szTemp) -{ - strncpy(szTemp, P_tmpdir, szTempLength); -} - -void GetTempFileName(const char * lpTempFolderPath, const char * lpFileName, DWORD something, char * szLFName) -{ - strcpy(szLFName, tempnam(lpTempFolderPath, lpFileName)); -} - -BOOL DeleteFile(const char *lpFileName) -{ - return (BOOL)remove(lpFileName); -} - -BOOL MoveFile(const char *lpExistingFileName, const char *lpNewFileName) -{ - return rename(lpExistingFileName, lpNewFileName); -} - -#endif +/******************************************************************** +* +* Description: implementation for StormLib - linux port +* intended to be used in GLdiablo +* +* ----> StormLib was originally developed for Windows by +* Ladislav Zezula (www.zezula.net), and he did +* a _great_ job! Thanks Ladislav! +* +* this is currently a quick and dirty hack to get it working +* don't expect beauty and/or miracles :) +* +* these are function wraps to execute Windows API calls +* as native Macintosh file calls (open/close/read/write/...) +* +* continue you work: added some wrapping functions for GNU/Linux by XPinguin +* +* Author: Marko Friedemann +* Created at: Mon Jan 29 19:01:37 CEST 2001 +* Computer: whiplash.flachland-chemnitz.de +* System: Linux 2.4.0 on i686 +* +* Copyright (c) 2001 BMX-Chemnitz.DE All rights reserved. +* +********************************************************************/ + +#ifndef _WIN32 +#include "StormPort.h" + +int globalerr; + +void SetLastError(int err) +{ + globalerr = err; +} + +int GetLastError() +{ + return(globalerr); +} + +char *ErrString(int err) +{ + switch (err) { + case ERROR_INVALID_FUNCTION: + return "function not implemented"; + case ERROR_FILE_NOT_FOUND: + return "file not found"; + case ERROR_ACCESS_DENIED: + return "access denied"; + case ERROR_NOT_ENOUGH_MEMORY: + return "not enough memory"; + case ERROR_BAD_FORMAT: + return "bad format"; + case ERROR_NO_MORE_FILES: + return "no more files"; + case ERROR_HANDLE_EOF: + return "access beyound EOF"; + case ERROR_HANDLE_DISK_FULL: + return "no space left on device"; + case ERROR_INVALID_PARAMETER: + return "invalid parameter"; + case ERROR_DISK_FULL: + return "no space left on device"; + case ERROR_ALREADY_EXISTS: + return "file exists"; + case ERROR_CAN_NOT_COMPLETE: + return "operation cannot be completed"; + default: + return "unknown error"; + } +} + +HANDLE CreateFile(const char *sFileName, DWORD ulMode, DWORD ulSharing, void *pSecAttrib, DWORD ulCreation, DWORD ulFlags, HANDLE hFile) +{ + switch (ulCreation) { + case OPEN_EXISTING: + return (HANDLE)open(sFileName, O_RDONLY | O_LARGEFILE); + case OPEN_ALWAYS: + return (HANDLE)open(sFileName, O_RDWR | O_CREAT); + case CREATE_NEW: + return (HANDLE)open(sFileName, O_RDWR | O_CREAT | O_TRUNC); + default: + return INVALID_HANDLE_VALUE; + } +} + +BOOL CloseHandle(HANDLE hFile) +{ + return (close((int)hFile) == 0); +} + +DWORD GetFileSize(HANDLE hFile, DWORD *ulOffSetHigh) +{ + if ((hFile == NULL) || (hFile == INVALID_HANDLE_VALUE)) + return 0xffffffff; + + struct stat fileinfo; + fstat((int)hFile, &fileinfo); + + return fileinfo.st_size; +} + +DWORD SetFilePointer(HANDLE hFile, LONG lOffSetLow, LONG *pOffSetHigh, DWORD ulMethod) +{ + return lseek64((int)hFile, (off64_t)(*pOffSetHigh) << 32 | (DWORD)lOffSetLow, ulMethod); +} + +BOOL SetEndOfFile(HANDLE hFile) +{ + return (ftruncate((int)hFile, lseek((int)hFile, 0, SEEK_CUR)) == 0); +} + +BOOL ReadFile(HANDLE hFile, void *pBuffer, DWORD ulLen, DWORD *ulRead, void *pOverLapped) +{ + ssize_t count; + if ((count = read((int)hFile, pBuffer, ulLen)) == -1) { + *ulRead = 0; + return false; + } + *ulRead = count; + return true; +} + +BOOL WriteFile(HANDLE hFile, const void *pBuffer, DWORD ulLen, DWORD *ulWritten, void *pOverLapped) +{ + ssize_t count; + if ((count = write((int)hFile, pBuffer, ulLen)) == -1) { + *ulWritten = 0; + return false; + } + *ulWritten = count; + return true; +} + +// Check if a memory block is accessible for reading +BOOL IsBadReadPtr(const void * ptr, int size) +{ + return FALSE; +} + +// Returns attributes of a file +DWORD GetFileAttributes(const char * szFileName) +{ + return 0; +} + +void GetTempPath(DWORD szTempLength, char * szTemp) +{ + strncpy(szTemp, P_tmpdir, szTempLength); +} + +void GetTempFileName(const char * lpTempFolderPath, const char * lpFileName, DWORD something, char * szLFName) +{ + strcpy(szLFName, tempnam(lpTempFolderPath, lpFileName)); +} + +BOOL DeleteFile(const char *lpFileName) +{ + return (BOOL)remove(lpFileName); +} + +BOOL MoveFile(const char *lpExistingFileName, const char *lpNewFileName) +{ + return rename(lpExistingFileName, lpNewFileName); +} + +#endif diff --git a/src/tools/stuffextract/StormLib/StormPortMac.cpp b/src/tools/stuffextract/StormLib/StormPortMac.cpp index 92cc3d7..26f6787 100644 --- a/src/tools/stuffextract/StormLib/StormPortMac.cpp +++ b/src/tools/stuffextract/StormLib/StormPortMac.cpp @@ -1,762 +1,762 @@ -/******************************************************************** -* -* Description: implementation for StormLib - Macintosh port -* -* these are function wraps to execute Windows API calls -* as native Macintosh file calls (open/close/read/write/...) -* requires Mac OS X -* -* Derived from Marko Friedemann -* StormPort.cpp for Linux -* -* Author: Daniel Chiaramello -* -* Carbonized by: Sam Wilkins -* -********************************************************************/ - -#ifndef _WIN32 || _WIN64 -#include "StormPort.h" -#include "StormLib.h" - -// FUNCTIONS EXTRACTED FROM MOREFILE PACKAGE!!! -// FEEL FREE TO REMOVE THEM AND TO ADD THE ORIGINAL ONES! - -/***************************************************************************** -* BEGIN OF MOREFILES COPY-PASTE -*****************************************************************************/ - -#ifdef __USEPRAGMAINTERNAL - #ifdef __MWERKS__ - #pragma internal on - #endif -#endif - -union TLongAnd4Bytes -{ - unsigned char bytes[4]; - unsigned long uvalue; - signed long svalue; -}; - - -static OSErr FSGetFullPath(const FSRef *ref, UInt8 *fullPath, UInt32 fullPathLength) -{ - OSErr result; - - result = FSRefMakePath(ref, fullPath, fullPathLength); - - return result; -} - -static OSErr FSLocationFromFullPath(const void *fullPath, FSRef *ref) -{ - OSErr result; - - result = FSPathMakeRef((UInt8 *)fullPath, ref, NULL); // Create an FSRef from the path - return result; -} - -/*****************************************************************************/ - -/*****************************************************************************/ - -static OSErr FSCreateCompat(const FSRef *parentRef, OSType creator, OSType fileType, const UniChar *fileName, - UniCharCount nameLength, FSRef *ref) -{ - FSCatalogInfo theCatInfo; - OSErr theErr; - ((FileInfo *)&theCatInfo.finderInfo)->fileCreator = creator; - ((FileInfo *)&theCatInfo.finderInfo)->fileType = fileType; - ((FileInfo *)&theCatInfo.finderInfo)->finderFlags = 0; - SetPt(&((FileInfo *)&theCatInfo.finderInfo)->location, 0, 0); - ((FileInfo *)&theCatInfo.finderInfo)->reservedField = 0; - - theErr = FSCreateFileUnicode(parentRef, nameLength, fileName, kFSCatInfoFinderInfo, &theCatInfo, ref, NULL); - return theErr; -} - - -/*****************************************************************************/ - -static OSErr FSOpenDFCompat(FSRef *ref, char permission, short *refNum) -{ - HFSUniStr255 forkName; - OSErr theErr; - Boolean isFolder, wasChanged; - - theErr = FSResolveAliasFile(ref, TRUE, &isFolder, &wasChanged); - if (theErr != noErr) - return theErr; - - FSGetDataForkName(&forkName); - theErr = FSOpenFork(ref, forkName.length, forkName.unicode, permission, refNum); - return theErr; -} - -/***************************************************************************** -* END OF MOREFILES COPY-PASTE -*****************************************************************************/ - -#pragma mark - - -int globalerr; - -/******************************************************************** -* SwapLong -********************************************************************/ - -unsigned long SwapULong(unsigned long data) -{ - // Apple provided function - uint32_t result; - - __asm__("lwbrx %0,0,%1" : "=r" (result) : "r" (&data), "m" (data)); - return result; - -/* - TLongAnd4Bytes Work; - unsigned char * value_as_4bytes = (unsigned char *)&value; - - Work.bytes[0] = value_as_4bytes[3]; - Work.bytes[1] = value_as_4bytes[2]; - Work.bytes[2] = value_as_4bytes[1]; - Work.bytes[3] = value_as_4bytes[0]; - - return Work.uvalue; -*/ -} - -long SwapLong(unsigned long data) -{ - // Apple provided function - uint32_t result; - - __asm__("lwbrx %0,0,%1" : "=r" (result) : "r" (&data), "m" (data)); - return (long)result; - -/* - TLongAnd4Bytes Work; - unsigned char * value_as_4bytes = (unsigned char *)&value; - - Work.bytes[0] = value_as_4bytes[3]; - Work.bytes[1] = value_as_4bytes[2]; - Work.bytes[2] = value_as_4bytes[1]; - Work.bytes[3] = value_as_4bytes[0]; - - return Work.svalue; -*/ -} - -/******************************************************************** -* SwapShort -********************************************************************/ -unsigned short SwapUShort(unsigned short data) -{ - // Apple provided function - uint16_t result; - __asm__("lhbrx %0,0,%1" : "=r" (result) : "r" (&data), "m" (data)); - return result; -} - -short SwapShort(unsigned short data) -{ - // Apple provided function - uint16_t result; - __asm__("lhbrx %0,0,%1" : "=r" (result) : "r" (&data), "m" (data)); - return (short)result; -} - -/******************************************************************** -* ConvertUnsignedLongBuffer -********************************************************************/ -void ConvertUnsignedLongBuffer(unsigned long *buffer, unsigned long nbLongs) -{ - while (nbLongs-- > 0) - { - *buffer = SwapLong(*buffer); - buffer++; - } -} - -/******************************************************************** -* ConvertUnsignedShortBuffer -********************************************************************/ -void ConvertUnsignedShortBuffer(unsigned short *buffer, unsigned long nbShorts) -{ - while (nbShorts-- > 0) - { - *buffer = SwapShort(*buffer); - buffer++; - } -} - -/******************************************************************** -* ConvertTMPQShunt -********************************************************************/ -void ConvertTMPQShunt(void *shunt) -{ - TMPQShunt * theShunt = (TMPQShunt *)shunt; - - theShunt->dwID = SwapULong(theShunt->dwID); - theShunt->dwUnknown = SwapULong(theShunt->dwUnknown); - theShunt->dwHeaderPos = SwapULong(theShunt->dwHeaderPos); -} - -/******************************************************************** -* ConvertTMPQHeader -********************************************************************/ -void ConvertTMPQHeader(void *header) -{ - TMPQHeader2 * theHeader = (TMPQHeader2 *)header; - - theHeader->dwID = SwapULong(theHeader->dwID); - theHeader->dwHeaderSize = SwapULong(theHeader->dwHeaderSize); - theHeader->dwArchiveSize = SwapULong(theHeader->dwArchiveSize); - theHeader->wFormatVersion = SwapUShort(theHeader->wFormatVersion); - theHeader->wBlockSize = SwapUShort(theHeader->wBlockSize); - theHeader->dwHashTablePos = SwapULong(theHeader->dwHashTablePos); - theHeader->dwBlockTablePos = SwapULong(theHeader->dwBlockTablePos); - theHeader->dwHashTableSize = SwapULong(theHeader->dwHashTableSize); - theHeader->dwBlockTableSize = SwapULong(theHeader->dwBlockTableSize); - - if(theHeader->wFormatVersion >= MPQ_FORMAT_VERSION_2) - { - DWORD dwTemp = theHeader->ExtBlockTablePos.LowPart; - theHeader->ExtBlockTablePos.LowPart = theHeader->ExtBlockTablePos.HighPart; - theHeader->ExtBlockTablePos.HighPart = dwTemp; - theHeader->ExtBlockTablePos.LowPart = SwapULong(theHeader->ExtBlockTablePos.LowPart); - theHeader->ExtBlockTablePos.HighPart = SwapULong(theHeader->ExtBlockTablePos.HighPart); - theHeader->wHashTablePosHigh = SwapUShort(theHeader->wHashTablePosHigh); - theHeader->wBlockTablePosHigh = SwapUShort(theHeader->wBlockTablePosHigh); - } -} - -/******************************************************************** -* ConvertTMPQHash -********************************************************************/ -void ConvertHashTable(void *hashtable, DWORD nHashEntries) -{ - TMPQHash * theHash = (TMPQHash *)hashtable; - USHORT lcLocale; - - for(DWORD i = 0; i < nHashEntries; i++, theHash++) - { - lcLocale = theHash->lcLocale; - theHash->lcLocale = theHash->wPlatform; - theHash->wPlatform = lcLocale; - } -} - -#pragma mark - - -/******************************************************************** -* SetLastError -********************************************************************/ -void SetLastError(int err) -{ - globalerr = err; -} - -/******************************************************************** -* GetLastError -********************************************************************/ -int GetLastError() -{ - return globalerr; -} - -/******************************************************************** -* ErrString -********************************************************************/ -char *ErrString(int err) -{ - switch (err) - { - case ERROR_INVALID_FUNCTION: - return "function not implemented"; - case ERROR_FILE_NOT_FOUND: - return "file not found"; - case ERROR_ACCESS_DENIED: - return "access denied"; - case ERROR_NOT_ENOUGH_MEMORY: - return "not enough memory"; - case ERROR_BAD_FORMAT: - return "bad format"; - case ERROR_NO_MORE_FILES: - return "no more files"; - case ERROR_HANDLE_EOF: - return "access beyound EOF"; - case ERROR_HANDLE_DISK_FULL: - return "no space left on device"; - case ERROR_INVALID_PARAMETER: - return "invalid parameter"; - case ERROR_DISK_FULL: - return "no space left on device"; - case ERROR_ALREADY_EXISTS: - return "file exists"; - case ERROR_CAN_NOT_COMPLETE: - return "operation cannot be completed"; - case ERROR_INSUFFICIENT_BUFFER: - return "insufficient buffer"; - default: - return "unknown error"; - } -} - -#pragma mark - - -/******************************************************************** -* GetTempPath - returns a '/' or ':'-terminated path -* szTempLength: length for path -* szTemp: file path -********************************************************************/ -void GetTempPath(DWORD szTempLength, char * szTemp) // I think I'll change this to use FSRefs. -{ - FSRef theFSRef; - OSErr theErr = FSFindFolder(kOnAppropriateDisk, kTemporaryFolderType, kCreateFolder, &theFSRef); - if (theErr == noErr) - { - theErr = FSGetFullPath(&theFSRef, (UInt8 *)szTemp, MAX_PATH); - if (theErr != noErr) - szTemp[0] = '\0'; - } - else - szTemp[0] = '\0'; - strcat(szTemp, "/"); - - SetLastError(theErr); -} - -/******************************************************************** -* GetTempFileName -* lpTempFolderPath: the temporary folder path, terminated by "/" -* lpFileName: a file name base -* something: unknown -* szLFName: the final path, built from the path, the file name and a random pattern -********************************************************************/ -void GetTempFileName(const char * lpTempFolderPath, const char * lpFileName, DWORD something, char * szLFName) -{ -#pragma unused (something) - char tmp[2] = "A"; - - while (true) - { - HANDLE fHandle; - - strcpy(szLFName, lpTempFolderPath); - strcat(szLFName, lpFileName); - strcat(szLFName, tmp); - - if ((fHandle = CreateFile(szLFName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) - // OK we found it! - break; - CloseHandle(fHandle); - tmp[0]++; - } -} - -/******************************************************************** -* DeleteFile -* lpFileName: file path -********************************************************************/ -BOOL DeleteFile(const char * lpFileName) -{ - OSErr theErr; - FSRef theFileRef; - - theErr = FSLocationFromFullPath(lpFileName, &theFileRef); - if (theErr != noErr) - { - SetLastError(theErr); - return FALSE; - } - - theErr = FSDeleteObject(&theFileRef); - - SetLastError(theErr); - - return theErr == noErr; -} - -/******************************************************************** -* MoveFile -* lpFromFileName: old file path -* lpToFileName: new file path -********************************************************************/ -BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName) -{ - OSErr theErr; - FSRef fromFileRef; - FSRef toFileRef; - FSRef parentFolderRef; - - // Get the path to the old file - theErr = FSLocationFromFullPath(lpFromFileName, &fromFileRef); - if (theErr != noErr) - { - SetLastError(theErr); - return false; - } - - // Get the path to the new folder for the file - char folderName[strlen(lpToFileName)]; - CFStringRef folderPathCFString = CFStringCreateWithCString(NULL, lpToFileName, kCFStringEncodingUTF8); - CFURLRef fileURL = CFURLCreateWithFileSystemPath(NULL, folderPathCFString, kCFURLPOSIXPathStyle, FALSE); - CFURLRef folderURL = CFURLCreateCopyDeletingLastPathComponent(NULL, fileURL); - CFURLGetFileSystemRepresentation(folderURL, TRUE, (UInt8 *)folderName, strlen(lpToFileName)); - theErr = FSLocationFromFullPath(folderName, &parentFolderRef); - CFRelease(fileURL); - CFRelease(folderURL); - CFRelease(folderPathCFString); - - // Move the old file - theErr = FSMoveObject(&fromFileRef, &parentFolderRef, &toFileRef); - if (theErr != noErr) - { - SetLastError(theErr); - return false; - } - - // Get a CFString for the new file name - CFStringRef newFileNameCFString = CFStringCreateWithCString(NULL, lpToFileName, kCFStringEncodingUTF8); - fileURL = CFURLCreateWithFileSystemPath(NULL, newFileNameCFString, kCFURLPOSIXPathStyle, FALSE); - CFRelease(newFileNameCFString); - newFileNameCFString = CFURLCopyLastPathComponent(fileURL); - CFRelease(fileURL); - - // Convert CFString to Unicode and rename the file - UniChar unicodeFileName[256]; - CFStringGetCharacters(newFileNameCFString, CFRangeMake(0, CFStringGetLength(newFileNameCFString)), - unicodeFileName); - theErr = FSRenameUnicode(&toFileRef, CFStringGetLength(newFileNameCFString), unicodeFileName, - kTextEncodingUnknown, NULL); - if (theErr != noErr) - { - SetLastError(theErr); - CFRelease(newFileNameCFString); - return false; - } - - CFRelease(newFileNameCFString); - - SetLastError(theErr); - return true; -} - -/******************************************************************** -* CreateFile -* ulMode: GENERIC_READ | GENERIC_WRITE -* ulSharing: FILE_SHARE_READ -* pSecAttrib: NULL -* ulCreation: OPEN_EXISTING, OPEN_ALWAYS, CREATE_NEW -* ulFlags: 0 -* hFile: NULL -********************************************************************/ -HANDLE CreateFile( const char *sFileName, /* file name */ - DWORD ulMode, /* access mode */ - DWORD ulSharing, /* share mode */ - void *pSecAttrib, /* SD */ - DWORD ulCreation, /* how to create */ - DWORD ulFlags, /* file attributes */ - HANDLE hFile ) /* handle to template file */ -{ -#pragma unused (ulSharing, pSecAttrib, ulFlags, hFile) - - OSErr theErr; - FSRef theFileRef; - FSRef theParentRef; - short fileRef; - char permission; - static OSType gCreator; - static OSType gType; - - theErr = FSLocationFromFullPath(sFileName, &theFileRef); - if (theErr == fnfErr) - { // Create the FSRef for the parent directory. - memset(&theFileRef, 0, sizeof(FSRef)); - UInt8 folderName[MAX_PATH]; - CFStringRef folderPathCFString = CFStringCreateWithCString(NULL, sFileName, kCFStringEncodingUTF8); - CFURLRef fileURL = CFURLCreateWithFileSystemPath(NULL, folderPathCFString, kCFURLPOSIXPathStyle, FALSE); - CFURLRef folderURL = CFURLCreateCopyDeletingLastPathComponent(NULL, fileURL); - CFURLGetFileSystemRepresentation(folderURL, TRUE, folderName, MAX_PATH); - theErr = FSLocationFromFullPath(folderName, &theParentRef); - CFRelease(fileURL); - CFRelease(folderURL); - CFRelease(folderPathCFString); - } - if (theErr != noErr) - { - SetLastError(theErr); - if (ulCreation == OPEN_EXISTING || theErr != fnfErr) - return INVALID_HANDLE_VALUE; - } - - if (ulCreation != OPEN_EXISTING) - { /* We create the file */ - UniChar unicodeFileName[256]; - CFStringRef filePathCFString = CFStringCreateWithCString(NULL, sFileName, kCFStringEncodingUTF8); - CFURLRef fileURL = CFURLCreateWithFileSystemPath(NULL, filePathCFString, kCFURLPOSIXPathStyle, FALSE); - CFStringRef fileNameCFString = CFURLCopyLastPathComponent(fileURL); - CFStringGetCharacters(fileNameCFString, CFRangeMake(0, CFStringGetLength(fileNameCFString)), - unicodeFileName); - theErr = FSCreateCompat(&theParentRef, gCreator, gType, unicodeFileName, - CFStringGetLength(fileNameCFString), &theFileRef); - CFRelease(fileNameCFString); - CFRelease(filePathCFString); - CFRelease(fileURL); - if (theErr != noErr) - { - SetLastError(theErr); - return INVALID_HANDLE_VALUE; - } - } - - if (ulMode == GENERIC_READ) - permission = fsRdPerm; - else - { - if (ulMode == GENERIC_WRITE) - permission = fsWrPerm; - else - permission = fsRdWrPerm; - } - theErr = FSOpenDFCompat(&theFileRef, permission, &fileRef); - - SetLastError(theErr); - - if (theErr == noErr) - return (HANDLE)(int)fileRef; - else - return INVALID_HANDLE_VALUE; -} - -/******************************************************************** -* CloseHandle -********************************************************************/ -BOOL CloseHandle( HANDLE hFile ) /* handle to object */ -{ - OSErr theErr; - - if ((hFile == NULL) || (hFile == INVALID_HANDLE_VALUE)) - return FALSE; - - theErr = FSCloseFork((short)(int)hFile); - - SetLastError(theErr); - - return theErr != noErr; -} - -/******************************************************************** -* GetFileSize -********************************************************************/ -DWORD GetFileSize( HANDLE hFile, /* handle to file */ - DWORD *ulOffSetHigh ) /* high-order word of file size */ -{ - SInt64 fileLength; - OSErr theErr; - - if ((hFile == NULL) || (hFile == INVALID_HANDLE_VALUE)) - { - SetLastError(theErr); - return -1u; - } - - theErr = FSGetForkSize((short)(int)hFile, &fileLength); - if (theErr != noErr) - { - SetLastError(theErr); - return -1u; - } - - if (ulOffSetHigh != NULL) - *ulOffSetHigh = fileLength >> 32; - - SetLastError(theErr); - - return fileLength; -} - -/******************************************************************** -* SetFilePointer -* pOffSetHigh: NULL -* ulMethod: FILE_BEGIN, FILE_CURRENT -********************************************************************/ -DWORD SetFilePointer( HANDLE hFile, /* handle to file */ - LONG lOffSetLow, /* bytes to move pointer */ - LONG *pOffSetHigh, /* bytes to move pointer */ - DWORD ulMethod ) /* starting point */ -{ - OSErr theErr; - - if (ulMethod == FILE_CURRENT) - { - SInt64 bytesToMove; - - if (pOffSetHigh != NULL) - bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow; - else - bytesToMove = lOffSetLow; - - SInt64 newPos; - - theErr = FSSetForkPosition((short)(int)hFile, fsFromMark, bytesToMove); - if (theErr != noErr) - { - SetLastError(theErr); - return -1u; - } - - theErr = FSGetForkPosition((short)(int)hFile, &newPos); - if (theErr != noErr) - { - SetLastError(theErr); - return -1u; - } - - if (pOffSetHigh != NULL) - *pOffSetHigh = newPos >> 32; - - SetLastError(theErr); - return newPos; - } - else if (ulMethod == FILE_BEGIN) - { - SInt64 bytesToMove; - - if (pOffSetHigh != NULL) - bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow; - else - bytesToMove = lOffSetLow; - - theErr = FSSetForkPosition((short)(int)hFile, fsFromStart, bytesToMove); - if (theErr != noErr) - { - SetLastError(theErr); - return -1u; - } - - SetLastError(theErr); - return lOffSetLow; - } - else - { - SInt64 bytesToMove; - - if (pOffSetHigh != NULL) - bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow; - else - bytesToMove = lOffSetLow; - - SInt64 newPos; - - theErr = FSSetForkPosition((short)(int)hFile, fsFromLEOF, bytesToMove); - if (theErr != noErr) - { - SetLastError(theErr); - return -1u; - } - - theErr = FSGetForkPosition((short)(int)hFile, &newPos); - if (theErr != noErr) - { - SetLastError(theErr); - return -1u; - } - - if (pOffSetHigh != NULL) - *pOffSetHigh = newPos >> 32; - - SetLastError(theErr); - return newPos; - } -} - -/******************************************************************** -* SetEndOfFile -********************************************************************/ -BOOL SetEndOfFile( HANDLE hFile ) /* handle to file */ -{ - OSErr theErr; - - theErr = FSSetForkSize((short)(int)hFile, fsAtMark, 0); - - SetLastError(theErr); - - return theErr == noErr; -} - -/******************************************************************** -* ReadFile -* pOverLapped: NULL -********************************************************************/ -BOOL ReadFile( HANDLE hFile, /* handle to file */ - void *pBuffer, /* data buffer */ - DWORD ulLen, /* number of bytes to read */ - DWORD *ulRead, /* number of bytes read */ - void *pOverLapped ) /* overlapped buffer */ -{ -#pragma unused (pOverLapped) - - ByteCount nbCharsRead; - OSErr theErr; - - nbCharsRead = ulLen; - theErr = FSReadFork((short)(int)hFile, fsAtMark, 0, nbCharsRead, pBuffer, &nbCharsRead); - *ulRead = nbCharsRead; - - SetLastError(theErr); - - return theErr == noErr; -} - -/******************************************************************** -* WriteFile -* pOverLapped: NULL -********************************************************************/ -BOOL WriteFile( HANDLE hFile, /* handle to file */ - const void *pBuffer, /* data buffer */ - DWORD ulLen, /* number of bytes to write */ - DWORD *ulWritten, /* number of bytes written */ - void *pOverLapped ) /* overlapped buffer */ -{ -#pragma unused (pOverLapped) - - ByteCount nbCharsToWrite; - OSErr theErr; - - nbCharsToWrite = ulLen; - theErr = FSWriteFork((short)(int)hFile, fsAtMark, 0, nbCharsToWrite, pBuffer, &nbCharsToWrite); - *ulWritten = nbCharsToWrite; - - SetLastError(theErr); - - return theErr == noErr; -} - -// Check if a memory block is accessible for reading. It's probably too -// hard to check on Mac, so sorry, we'll just have to crash -BOOL IsBadReadPtr(const void * ptr, int size) -{ -#pragma unused (ptr, size) - - return FALSE; -} - -// Returns attributes of a file. Actually, it doesn't, it just checks if -// the file exists, since that's all StormLib uses it for -DWORD GetFileAttributes(const char * szFileName) -{ - FSRef theRef; - OSErr theErr; - - theErr = FSLocationFromFullPath(szFileName, &theRef); - - if (theErr != noErr) - return -1u; - else - return 0; -} - -#endif +/******************************************************************** +* +* Description: implementation for StormLib - Macintosh port +* +* these are function wraps to execute Windows API calls +* as native Macintosh file calls (open/close/read/write/...) +* requires Mac OS X +* +* Derived from Marko Friedemann +* StormPort.cpp for Linux +* +* Author: Daniel Chiaramello +* +* Carbonized by: Sam Wilkins +* +********************************************************************/ + +#ifndef _WIN32 || _WIN64 +#include "StormPort.h" +#include "StormLib.h" + +// FUNCTIONS EXTRACTED FROM MOREFILE PACKAGE!!! +// FEEL FREE TO REMOVE THEM AND TO ADD THE ORIGINAL ONES! + +/***************************************************************************** +* BEGIN OF MOREFILES COPY-PASTE +*****************************************************************************/ + +#ifdef __USEPRAGMAINTERNAL + #ifdef __MWERKS__ + #pragma internal on + #endif +#endif + +union TLongAnd4Bytes +{ + unsigned char bytes[4]; + unsigned long uvalue; + signed long svalue; +}; + + +static OSErr FSGetFullPath(const FSRef *ref, UInt8 *fullPath, UInt32 fullPathLength) +{ + OSErr result; + + result = FSRefMakePath(ref, fullPath, fullPathLength); + + return result; +} + +static OSErr FSLocationFromFullPath(const void *fullPath, FSRef *ref) +{ + OSErr result; + + result = FSPathMakeRef((UInt8 *)fullPath, ref, NULL); // Create an FSRef from the path + return result; +} + +/*****************************************************************************/ + +/*****************************************************************************/ + +static OSErr FSCreateCompat(const FSRef *parentRef, OSType creator, OSType fileType, const UniChar *fileName, + UniCharCount nameLength, FSRef *ref) +{ + FSCatalogInfo theCatInfo; + OSErr theErr; + ((FileInfo *)&theCatInfo.finderInfo)->fileCreator = creator; + ((FileInfo *)&theCatInfo.finderInfo)->fileType = fileType; + ((FileInfo *)&theCatInfo.finderInfo)->finderFlags = 0; + SetPt(&((FileInfo *)&theCatInfo.finderInfo)->location, 0, 0); + ((FileInfo *)&theCatInfo.finderInfo)->reservedField = 0; + + theErr = FSCreateFileUnicode(parentRef, nameLength, fileName, kFSCatInfoFinderInfo, &theCatInfo, ref, NULL); + return theErr; +} + + +/*****************************************************************************/ + +static OSErr FSOpenDFCompat(FSRef *ref, char permission, short *refNum) +{ + HFSUniStr255 forkName; + OSErr theErr; + Boolean isFolder, wasChanged; + + theErr = FSResolveAliasFile(ref, TRUE, &isFolder, &wasChanged); + if (theErr != noErr) + return theErr; + + FSGetDataForkName(&forkName); + theErr = FSOpenFork(ref, forkName.length, forkName.unicode, permission, refNum); + return theErr; +} + +/***************************************************************************** +* END OF MOREFILES COPY-PASTE +*****************************************************************************/ + +#pragma mark - + +int globalerr; + +/******************************************************************** +* SwapLong +********************************************************************/ + +unsigned long SwapULong(unsigned long data) +{ + // Apple provided function + uint32_t result; + + __asm__("lwbrx %0,0,%1" : "=r" (result) : "r" (&data), "m" (data)); + return result; + +/* + TLongAnd4Bytes Work; + unsigned char * value_as_4bytes = (unsigned char *)&value; + + Work.bytes[0] = value_as_4bytes[3]; + Work.bytes[1] = value_as_4bytes[2]; + Work.bytes[2] = value_as_4bytes[1]; + Work.bytes[3] = value_as_4bytes[0]; + + return Work.uvalue; +*/ +} + +long SwapLong(unsigned long data) +{ + // Apple provided function + uint32_t result; + + __asm__("lwbrx %0,0,%1" : "=r" (result) : "r" (&data), "m" (data)); + return (long)result; + +/* + TLongAnd4Bytes Work; + unsigned char * value_as_4bytes = (unsigned char *)&value; + + Work.bytes[0] = value_as_4bytes[3]; + Work.bytes[1] = value_as_4bytes[2]; + Work.bytes[2] = value_as_4bytes[1]; + Work.bytes[3] = value_as_4bytes[0]; + + return Work.svalue; +*/ +} + +/******************************************************************** +* SwapShort +********************************************************************/ +unsigned short SwapUShort(unsigned short data) +{ + // Apple provided function + uint16_t result; + __asm__("lhbrx %0,0,%1" : "=r" (result) : "r" (&data), "m" (data)); + return result; +} + +short SwapShort(unsigned short data) +{ + // Apple provided function + uint16_t result; + __asm__("lhbrx %0,0,%1" : "=r" (result) : "r" (&data), "m" (data)); + return (short)result; +} + +/******************************************************************** +* ConvertUnsignedLongBuffer +********************************************************************/ +void ConvertUnsignedLongBuffer(unsigned long *buffer, unsigned long nbLongs) +{ + while (nbLongs-- > 0) + { + *buffer = SwapLong(*buffer); + buffer++; + } +} + +/******************************************************************** +* ConvertUnsignedShortBuffer +********************************************************************/ +void ConvertUnsignedShortBuffer(unsigned short *buffer, unsigned long nbShorts) +{ + while (nbShorts-- > 0) + { + *buffer = SwapShort(*buffer); + buffer++; + } +} + +/******************************************************************** +* ConvertTMPQShunt +********************************************************************/ +void ConvertTMPQShunt(void *shunt) +{ + TMPQShunt * theShunt = (TMPQShunt *)shunt; + + theShunt->dwID = SwapULong(theShunt->dwID); + theShunt->dwUnknown = SwapULong(theShunt->dwUnknown); + theShunt->dwHeaderPos = SwapULong(theShunt->dwHeaderPos); +} + +/******************************************************************** +* ConvertTMPQHeader +********************************************************************/ +void ConvertTMPQHeader(void *header) +{ + TMPQHeader2 * theHeader = (TMPQHeader2 *)header; + + theHeader->dwID = SwapULong(theHeader->dwID); + theHeader->dwHeaderSize = SwapULong(theHeader->dwHeaderSize); + theHeader->dwArchiveSize = SwapULong(theHeader->dwArchiveSize); + theHeader->wFormatVersion = SwapUShort(theHeader->wFormatVersion); + theHeader->wBlockSize = SwapUShort(theHeader->wBlockSize); + theHeader->dwHashTablePos = SwapULong(theHeader->dwHashTablePos); + theHeader->dwBlockTablePos = SwapULong(theHeader->dwBlockTablePos); + theHeader->dwHashTableSize = SwapULong(theHeader->dwHashTableSize); + theHeader->dwBlockTableSize = SwapULong(theHeader->dwBlockTableSize); + + if(theHeader->wFormatVersion >= MPQ_FORMAT_VERSION_2) + { + DWORD dwTemp = theHeader->ExtBlockTablePos.LowPart; + theHeader->ExtBlockTablePos.LowPart = theHeader->ExtBlockTablePos.HighPart; + theHeader->ExtBlockTablePos.HighPart = dwTemp; + theHeader->ExtBlockTablePos.LowPart = SwapULong(theHeader->ExtBlockTablePos.LowPart); + theHeader->ExtBlockTablePos.HighPart = SwapULong(theHeader->ExtBlockTablePos.HighPart); + theHeader->wHashTablePosHigh = SwapUShort(theHeader->wHashTablePosHigh); + theHeader->wBlockTablePosHigh = SwapUShort(theHeader->wBlockTablePosHigh); + } +} + +/******************************************************************** +* ConvertTMPQHash +********************************************************************/ +void ConvertHashTable(void *hashtable, DWORD nHashEntries) +{ + TMPQHash * theHash = (TMPQHash *)hashtable; + USHORT lcLocale; + + for(DWORD i = 0; i < nHashEntries; i++, theHash++) + { + lcLocale = theHash->lcLocale; + theHash->lcLocale = theHash->wPlatform; + theHash->wPlatform = lcLocale; + } +} + +#pragma mark - + +/******************************************************************** +* SetLastError +********************************************************************/ +void SetLastError(int err) +{ + globalerr = err; +} + +/******************************************************************** +* GetLastError +********************************************************************/ +int GetLastError() +{ + return globalerr; +} + +/******************************************************************** +* ErrString +********************************************************************/ +char *ErrString(int err) +{ + switch (err) + { + case ERROR_INVALID_FUNCTION: + return "function not implemented"; + case ERROR_FILE_NOT_FOUND: + return "file not found"; + case ERROR_ACCESS_DENIED: + return "access denied"; + case ERROR_NOT_ENOUGH_MEMORY: + return "not enough memory"; + case ERROR_BAD_FORMAT: + return "bad format"; + case ERROR_NO_MORE_FILES: + return "no more files"; + case ERROR_HANDLE_EOF: + return "access beyound EOF"; + case ERROR_HANDLE_DISK_FULL: + return "no space left on device"; + case ERROR_INVALID_PARAMETER: + return "invalid parameter"; + case ERROR_DISK_FULL: + return "no space left on device"; + case ERROR_ALREADY_EXISTS: + return "file exists"; + case ERROR_CAN_NOT_COMPLETE: + return "operation cannot be completed"; + case ERROR_INSUFFICIENT_BUFFER: + return "insufficient buffer"; + default: + return "unknown error"; + } +} + +#pragma mark - + +/******************************************************************** +* GetTempPath - returns a '/' or ':'-terminated path +* szTempLength: length for path +* szTemp: file path +********************************************************************/ +void GetTempPath(DWORD szTempLength, char * szTemp) // I think I'll change this to use FSRefs. +{ + FSRef theFSRef; + OSErr theErr = FSFindFolder(kOnAppropriateDisk, kTemporaryFolderType, kCreateFolder, &theFSRef); + if (theErr == noErr) + { + theErr = FSGetFullPath(&theFSRef, (UInt8 *)szTemp, MAX_PATH); + if (theErr != noErr) + szTemp[0] = '\0'; + } + else + szTemp[0] = '\0'; + strcat(szTemp, "/"); + + SetLastError(theErr); +} + +/******************************************************************** +* GetTempFileName +* lpTempFolderPath: the temporary folder path, terminated by "/" +* lpFileName: a file name base +* something: unknown +* szLFName: the final path, built from the path, the file name and a random pattern +********************************************************************/ +void GetTempFileName(const char * lpTempFolderPath, const char * lpFileName, DWORD something, char * szLFName) +{ +#pragma unused (something) + char tmp[2] = "A"; + + while (true) + { + HANDLE fHandle; + + strcpy(szLFName, lpTempFolderPath); + strcat(szLFName, lpFileName); + strcat(szLFName, tmp); + + if ((fHandle = CreateFile(szLFName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) + // OK we found it! + break; + CloseHandle(fHandle); + tmp[0]++; + } +} + +/******************************************************************** +* DeleteFile +* lpFileName: file path +********************************************************************/ +BOOL DeleteFile(const char * lpFileName) +{ + OSErr theErr; + FSRef theFileRef; + + theErr = FSLocationFromFullPath(lpFileName, &theFileRef); + if (theErr != noErr) + { + SetLastError(theErr); + return FALSE; + } + + theErr = FSDeleteObject(&theFileRef); + + SetLastError(theErr); + + return theErr == noErr; +} + +/******************************************************************** +* MoveFile +* lpFromFileName: old file path +* lpToFileName: new file path +********************************************************************/ +BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName) +{ + OSErr theErr; + FSRef fromFileRef; + FSRef toFileRef; + FSRef parentFolderRef; + + // Get the path to the old file + theErr = FSLocationFromFullPath(lpFromFileName, &fromFileRef); + if (theErr != noErr) + { + SetLastError(theErr); + return false; + } + + // Get the path to the new folder for the file + char folderName[strlen(lpToFileName)]; + CFStringRef folderPathCFString = CFStringCreateWithCString(NULL, lpToFileName, kCFStringEncodingUTF8); + CFURLRef fileURL = CFURLCreateWithFileSystemPath(NULL, folderPathCFString, kCFURLPOSIXPathStyle, FALSE); + CFURLRef folderURL = CFURLCreateCopyDeletingLastPathComponent(NULL, fileURL); + CFURLGetFileSystemRepresentation(folderURL, TRUE, (UInt8 *)folderName, strlen(lpToFileName)); + theErr = FSLocationFromFullPath(folderName, &parentFolderRef); + CFRelease(fileURL); + CFRelease(folderURL); + CFRelease(folderPathCFString); + + // Move the old file + theErr = FSMoveObject(&fromFileRef, &parentFolderRef, &toFileRef); + if (theErr != noErr) + { + SetLastError(theErr); + return false; + } + + // Get a CFString for the new file name + CFStringRef newFileNameCFString = CFStringCreateWithCString(NULL, lpToFileName, kCFStringEncodingUTF8); + fileURL = CFURLCreateWithFileSystemPath(NULL, newFileNameCFString, kCFURLPOSIXPathStyle, FALSE); + CFRelease(newFileNameCFString); + newFileNameCFString = CFURLCopyLastPathComponent(fileURL); + CFRelease(fileURL); + + // Convert CFString to Unicode and rename the file + UniChar unicodeFileName[256]; + CFStringGetCharacters(newFileNameCFString, CFRangeMake(0, CFStringGetLength(newFileNameCFString)), + unicodeFileName); + theErr = FSRenameUnicode(&toFileRef, CFStringGetLength(newFileNameCFString), unicodeFileName, + kTextEncodingUnknown, NULL); + if (theErr != noErr) + { + SetLastError(theErr); + CFRelease(newFileNameCFString); + return false; + } + + CFRelease(newFileNameCFString); + + SetLastError(theErr); + return true; +} + +/******************************************************************** +* CreateFile +* ulMode: GENERIC_READ | GENERIC_WRITE +* ulSharing: FILE_SHARE_READ +* pSecAttrib: NULL +* ulCreation: OPEN_EXISTING, OPEN_ALWAYS, CREATE_NEW +* ulFlags: 0 +* hFile: NULL +********************************************************************/ +HANDLE CreateFile( const char *sFileName, /* file name */ + DWORD ulMode, /* access mode */ + DWORD ulSharing, /* share mode */ + void *pSecAttrib, /* SD */ + DWORD ulCreation, /* how to create */ + DWORD ulFlags, /* file attributes */ + HANDLE hFile ) /* handle to template file */ +{ +#pragma unused (ulSharing, pSecAttrib, ulFlags, hFile) + + OSErr theErr; + FSRef theFileRef; + FSRef theParentRef; + short fileRef; + char permission; + static OSType gCreator; + static OSType gType; + + theErr = FSLocationFromFullPath(sFileName, &theFileRef); + if (theErr == fnfErr) + { // Create the FSRef for the parent directory. + memset(&theFileRef, 0, sizeof(FSRef)); + UInt8 folderName[MAX_PATH]; + CFStringRef folderPathCFString = CFStringCreateWithCString(NULL, sFileName, kCFStringEncodingUTF8); + CFURLRef fileURL = CFURLCreateWithFileSystemPath(NULL, folderPathCFString, kCFURLPOSIXPathStyle, FALSE); + CFURLRef folderURL = CFURLCreateCopyDeletingLastPathComponent(NULL, fileURL); + CFURLGetFileSystemRepresentation(folderURL, TRUE, folderName, MAX_PATH); + theErr = FSLocationFromFullPath(folderName, &theParentRef); + CFRelease(fileURL); + CFRelease(folderURL); + CFRelease(folderPathCFString); + } + if (theErr != noErr) + { + SetLastError(theErr); + if (ulCreation == OPEN_EXISTING || theErr != fnfErr) + return INVALID_HANDLE_VALUE; + } + + if (ulCreation != OPEN_EXISTING) + { /* We create the file */ + UniChar unicodeFileName[256]; + CFStringRef filePathCFString = CFStringCreateWithCString(NULL, sFileName, kCFStringEncodingUTF8); + CFURLRef fileURL = CFURLCreateWithFileSystemPath(NULL, filePathCFString, kCFURLPOSIXPathStyle, FALSE); + CFStringRef fileNameCFString = CFURLCopyLastPathComponent(fileURL); + CFStringGetCharacters(fileNameCFString, CFRangeMake(0, CFStringGetLength(fileNameCFString)), + unicodeFileName); + theErr = FSCreateCompat(&theParentRef, gCreator, gType, unicodeFileName, + CFStringGetLength(fileNameCFString), &theFileRef); + CFRelease(fileNameCFString); + CFRelease(filePathCFString); + CFRelease(fileURL); + if (theErr != noErr) + { + SetLastError(theErr); + return INVALID_HANDLE_VALUE; + } + } + + if (ulMode == GENERIC_READ) + permission = fsRdPerm; + else + { + if (ulMode == GENERIC_WRITE) + permission = fsWrPerm; + else + permission = fsRdWrPerm; + } + theErr = FSOpenDFCompat(&theFileRef, permission, &fileRef); + + SetLastError(theErr); + + if (theErr == noErr) + return (HANDLE)(int)fileRef; + else + return INVALID_HANDLE_VALUE; +} + +/******************************************************************** +* CloseHandle +********************************************************************/ +BOOL CloseHandle( HANDLE hFile ) /* handle to object */ +{ + OSErr theErr; + + if ((hFile == NULL) || (hFile == INVALID_HANDLE_VALUE)) + return FALSE; + + theErr = FSCloseFork((short)(int)hFile); + + SetLastError(theErr); + + return theErr != noErr; +} + +/******************************************************************** +* GetFileSize +********************************************************************/ +DWORD GetFileSize( HANDLE hFile, /* handle to file */ + DWORD *ulOffSetHigh ) /* high-order word of file size */ +{ + SInt64 fileLength; + OSErr theErr; + + if ((hFile == NULL) || (hFile == INVALID_HANDLE_VALUE)) + { + SetLastError(theErr); + return -1u; + } + + theErr = FSGetForkSize((short)(int)hFile, &fileLength); + if (theErr != noErr) + { + SetLastError(theErr); + return -1u; + } + + if (ulOffSetHigh != NULL) + *ulOffSetHigh = fileLength >> 32; + + SetLastError(theErr); + + return fileLength; +} + +/******************************************************************** +* SetFilePointer +* pOffSetHigh: NULL +* ulMethod: FILE_BEGIN, FILE_CURRENT +********************************************************************/ +DWORD SetFilePointer( HANDLE hFile, /* handle to file */ + LONG lOffSetLow, /* bytes to move pointer */ + LONG *pOffSetHigh, /* bytes to move pointer */ + DWORD ulMethod ) /* starting point */ +{ + OSErr theErr; + + if (ulMethod == FILE_CURRENT) + { + SInt64 bytesToMove; + + if (pOffSetHigh != NULL) + bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow; + else + bytesToMove = lOffSetLow; + + SInt64 newPos; + + theErr = FSSetForkPosition((short)(int)hFile, fsFromMark, bytesToMove); + if (theErr != noErr) + { + SetLastError(theErr); + return -1u; + } + + theErr = FSGetForkPosition((short)(int)hFile, &newPos); + if (theErr != noErr) + { + SetLastError(theErr); + return -1u; + } + + if (pOffSetHigh != NULL) + *pOffSetHigh = newPos >> 32; + + SetLastError(theErr); + return newPos; + } + else if (ulMethod == FILE_BEGIN) + { + SInt64 bytesToMove; + + if (pOffSetHigh != NULL) + bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow; + else + bytesToMove = lOffSetLow; + + theErr = FSSetForkPosition((short)(int)hFile, fsFromStart, bytesToMove); + if (theErr != noErr) + { + SetLastError(theErr); + return -1u; + } + + SetLastError(theErr); + return lOffSetLow; + } + else + { + SInt64 bytesToMove; + + if (pOffSetHigh != NULL) + bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow; + else + bytesToMove = lOffSetLow; + + SInt64 newPos; + + theErr = FSSetForkPosition((short)(int)hFile, fsFromLEOF, bytesToMove); + if (theErr != noErr) + { + SetLastError(theErr); + return -1u; + } + + theErr = FSGetForkPosition((short)(int)hFile, &newPos); + if (theErr != noErr) + { + SetLastError(theErr); + return -1u; + } + + if (pOffSetHigh != NULL) + *pOffSetHigh = newPos >> 32; + + SetLastError(theErr); + return newPos; + } +} + +/******************************************************************** +* SetEndOfFile +********************************************************************/ +BOOL SetEndOfFile( HANDLE hFile ) /* handle to file */ +{ + OSErr theErr; + + theErr = FSSetForkSize((short)(int)hFile, fsAtMark, 0); + + SetLastError(theErr); + + return theErr == noErr; +} + +/******************************************************************** +* ReadFile +* pOverLapped: NULL +********************************************************************/ +BOOL ReadFile( HANDLE hFile, /* handle to file */ + void *pBuffer, /* data buffer */ + DWORD ulLen, /* number of bytes to read */ + DWORD *ulRead, /* number of bytes read */ + void *pOverLapped ) /* overlapped buffer */ +{ +#pragma unused (pOverLapped) + + ByteCount nbCharsRead; + OSErr theErr; + + nbCharsRead = ulLen; + theErr = FSReadFork((short)(int)hFile, fsAtMark, 0, nbCharsRead, pBuffer, &nbCharsRead); + *ulRead = nbCharsRead; + + SetLastError(theErr); + + return theErr == noErr; +} + +/******************************************************************** +* WriteFile +* pOverLapped: NULL +********************************************************************/ +BOOL WriteFile( HANDLE hFile, /* handle to file */ + const void *pBuffer, /* data buffer */ + DWORD ulLen, /* number of bytes to write */ + DWORD *ulWritten, /* number of bytes written */ + void *pOverLapped ) /* overlapped buffer */ +{ +#pragma unused (pOverLapped) + + ByteCount nbCharsToWrite; + OSErr theErr; + + nbCharsToWrite = ulLen; + theErr = FSWriteFork((short)(int)hFile, fsAtMark, 0, nbCharsToWrite, pBuffer, &nbCharsToWrite); + *ulWritten = nbCharsToWrite; + + SetLastError(theErr); + + return theErr == noErr; +} + +// Check if a memory block is accessible for reading. It's probably too +// hard to check on Mac, so sorry, we'll just have to crash +BOOL IsBadReadPtr(const void * ptr, int size) +{ +#pragma unused (ptr, size) + + return FALSE; +} + +// Returns attributes of a file. Actually, it doesn't, it just checks if +// the file exists, since that's all StormLib uses it for +DWORD GetFileAttributes(const char * szFileName) +{ + FSRef theRef; + OSErr theErr; + + theErr = FSLocationFromFullPath(szFileName, &theRef); + + if (theErr != noErr) + return -1u; + else + return 0; +} + +#endif diff --git a/src/tools/stuffextract/StormLib/bzip2/dlltest.c b/src/tools/stuffextract/StormLib/bzip2/dlltest.c index 2d7dcca..eb86bb6 100644 --- a/src/tools/stuffextract/StormLib/bzip2/dlltest.c +++ b/src/tools/stuffextract/StormLib/bzip2/dlltest.c @@ -1,176 +1,176 @@ -/* - minibz2 - libbz2.dll test program. - by Yoshioka Tsuneo(QWF00133@nifty.ne.jp/tsuneo-y@is.aist-nara.ac.jp) - This file is Public Domain. - welcome any email to me. - - usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename] -*/ - -#define BZ_IMPORT -#include -#include -#include "bzlib.h" -#ifdef _WIN32 -#include -#endif - - -#ifdef _WIN32 - -#define BZ2_LIBNAME "libbz2-1.0.2.DLL" - -#include -static int BZ2DLLLoaded = 0; -static HINSTANCE BZ2DLLhLib; -int BZ2DLLLoadLibrary(void) -{ - HINSTANCE hLib; - - if(BZ2DLLLoaded==1){return 0;} - hLib=LoadLibrary(BZ2_LIBNAME); - if(hLib == NULL){ - fprintf(stderr,"Can't load %s\n",BZ2_LIBNAME); - return -1; - } - BZ2_bzlibVersion=GetProcAddress(hLib,"BZ2_bzlibVersion"); - BZ2_bzopen=GetProcAddress(hLib,"BZ2_bzopen"); - BZ2_bzdopen=GetProcAddress(hLib,"BZ2_bzdopen"); - BZ2_bzread=GetProcAddress(hLib,"BZ2_bzread"); - BZ2_bzwrite=GetProcAddress(hLib,"BZ2_bzwrite"); - BZ2_bzflush=GetProcAddress(hLib,"BZ2_bzflush"); - BZ2_bzclose=GetProcAddress(hLib,"BZ2_bzclose"); - BZ2_bzerror=GetProcAddress(hLib,"BZ2_bzerror"); - - if (!BZ2_bzlibVersion || !BZ2_bzopen || !BZ2_bzdopen - || !BZ2_bzread || !BZ2_bzwrite || !BZ2_bzflush - || !BZ2_bzclose || !BZ2_bzerror) { - fprintf(stderr,"GetProcAddress failed.\n"); - return -1; - } - BZ2DLLLoaded=1; - BZ2DLLhLib=hLib; - return 0; - -} -int BZ2DLLFreeLibrary(void) -{ - if(BZ2DLLLoaded==0){return 0;} - FreeLibrary(BZ2DLLhLib); - BZ2DLLLoaded=0; -} -#endif /* WIN32 */ - -void usage(void) -{ - puts("usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]"); -} - -int main(int argc,char *argv[]) -{ - int decompress = 0; - int level = 9; - char *fn_r = NULL; - char *fn_w = NULL; - -#ifdef _WIN32 - if(BZ2DLLLoadLibrary()<0){ - fprintf(stderr,"Loading of %s failed. Giving up.\n", BZ2_LIBNAME); - exit(1); - } - printf("Loading of %s succeeded. Library version is %s.\n", - BZ2_LIBNAME, BZ2_bzlibVersion() ); -#endif - while(++argv,--argc){ - if(**argv =='-' || **argv=='/'){ - char *p; - - for(p=*argv+1;*p;p++){ - if(*p=='d'){ - decompress = 1; - }else if('1'<=*p && *p<='9'){ - level = *p - '0'; - }else{ - usage(); - exit(1); - } - } - }else{ - break; - } - } - if(argc>=1){ - fn_r = *argv; - argc--;argv++; - }else{ - fn_r = NULL; - } - if(argc>=1){ - fn_w = *argv; - argc--;argv++; - }else{ - fn_w = NULL; - } - { - int len; - char buff[0x1000]; - char mode[10]; - - if(decompress){ - BZFILE *BZ2fp_r = NULL; - FILE *fp_w = NULL; - - if(fn_w){ - if((fp_w = fopen(fn_w,"wb"))==NULL){ - printf("can't open [%s]\n",fn_w); - perror("reason:"); - exit(1); - } - }else{ - fp_w = stdout; - } - if((fn_r == NULL && (BZ2fp_r = BZ2_bzdopen(fileno(stdin),"rb"))==NULL) - || (fn_r != NULL && (BZ2fp_r = BZ2_bzopen(fn_r,"rb"))==NULL)){ - printf("can't bz2openstream\n"); - exit(1); - } - while((len=BZ2_bzread(BZ2fp_r,buff,0x1000))>0){ - fwrite(buff,1,len,fp_w); - } - BZ2_bzclose(BZ2fp_r); - if(fp_w != stdout) fclose(fp_w); - }else{ - BZFILE *BZ2fp_w = NULL; - FILE *fp_r = NULL; - - if(fn_r){ - if((fp_r = fopen(fn_r,"rb"))==NULL){ - printf("can't open [%s]\n",fn_r); - perror("reason:"); - exit(1); - } - }else{ - fp_r = stdin; - } - mode[0]='w'; - mode[1] = '0' + level; - mode[2] = '\0'; - - if((fn_w == NULL && (BZ2fp_w = BZ2_bzdopen(fileno(stdout),mode))==NULL) - || (fn_w !=NULL && (BZ2fp_w = BZ2_bzopen(fn_w,mode))==NULL)){ - printf("can't bz2openstream\n"); - exit(1); - } - while((len=fread(buff,1,0x1000,fp_r))>0){ - BZ2_bzwrite(BZ2fp_w,buff,len); - } - BZ2_bzclose(BZ2fp_w); - if(fp_r!=stdin)fclose(fp_r); - } - } -#ifdef _WIN32 - BZ2DLLFreeLibrary(); -#endif - return 0; -} +/* + minibz2 + libbz2.dll test program. + by Yoshioka Tsuneo(QWF00133@nifty.ne.jp/tsuneo-y@is.aist-nara.ac.jp) + This file is Public Domain. + welcome any email to me. + + usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename] +*/ + +#define BZ_IMPORT +#include +#include +#include "bzlib.h" +#ifdef _WIN32 +#include +#endif + + +#ifdef _WIN32 + +#define BZ2_LIBNAME "libbz2-1.0.2.DLL" + +#include +static int BZ2DLLLoaded = 0; +static HINSTANCE BZ2DLLhLib; +int BZ2DLLLoadLibrary(void) +{ + HINSTANCE hLib; + + if(BZ2DLLLoaded==1){return 0;} + hLib=LoadLibrary(BZ2_LIBNAME); + if(hLib == NULL){ + fprintf(stderr,"Can't load %s\n",BZ2_LIBNAME); + return -1; + } + BZ2_bzlibVersion=GetProcAddress(hLib,"BZ2_bzlibVersion"); + BZ2_bzopen=GetProcAddress(hLib,"BZ2_bzopen"); + BZ2_bzdopen=GetProcAddress(hLib,"BZ2_bzdopen"); + BZ2_bzread=GetProcAddress(hLib,"BZ2_bzread"); + BZ2_bzwrite=GetProcAddress(hLib,"BZ2_bzwrite"); + BZ2_bzflush=GetProcAddress(hLib,"BZ2_bzflush"); + BZ2_bzclose=GetProcAddress(hLib,"BZ2_bzclose"); + BZ2_bzerror=GetProcAddress(hLib,"BZ2_bzerror"); + + if (!BZ2_bzlibVersion || !BZ2_bzopen || !BZ2_bzdopen + || !BZ2_bzread || !BZ2_bzwrite || !BZ2_bzflush + || !BZ2_bzclose || !BZ2_bzerror) { + fprintf(stderr,"GetProcAddress failed.\n"); + return -1; + } + BZ2DLLLoaded=1; + BZ2DLLhLib=hLib; + return 0; + +} +int BZ2DLLFreeLibrary(void) +{ + if(BZ2DLLLoaded==0){return 0;} + FreeLibrary(BZ2DLLhLib); + BZ2DLLLoaded=0; +} +#endif /* WIN32 */ + +void usage(void) +{ + puts("usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]"); +} + +int main(int argc,char *argv[]) +{ + int decompress = 0; + int level = 9; + char *fn_r = NULL; + char *fn_w = NULL; + +#ifdef _WIN32 + if(BZ2DLLLoadLibrary()<0){ + fprintf(stderr,"Loading of %s failed. Giving up.\n", BZ2_LIBNAME); + exit(1); + } + printf("Loading of %s succeeded. Library version is %s.\n", + BZ2_LIBNAME, BZ2_bzlibVersion() ); +#endif + while(++argv,--argc){ + if(**argv =='-' || **argv=='/'){ + char *p; + + for(p=*argv+1;*p;p++){ + if(*p=='d'){ + decompress = 1; + }else if('1'<=*p && *p<='9'){ + level = *p - '0'; + }else{ + usage(); + exit(1); + } + } + }else{ + break; + } + } + if(argc>=1){ + fn_r = *argv; + argc--;argv++; + }else{ + fn_r = NULL; + } + if(argc>=1){ + fn_w = *argv; + argc--;argv++; + }else{ + fn_w = NULL; + } + { + int len; + char buff[0x1000]; + char mode[10]; + + if(decompress){ + BZFILE *BZ2fp_r = NULL; + FILE *fp_w = NULL; + + if(fn_w){ + if((fp_w = fopen(fn_w,"wb"))==NULL){ + printf("can't open [%s]\n",fn_w); + perror("reason:"); + exit(1); + } + }else{ + fp_w = stdout; + } + if((fn_r == NULL && (BZ2fp_r = BZ2_bzdopen(fileno(stdin),"rb"))==NULL) + || (fn_r != NULL && (BZ2fp_r = BZ2_bzopen(fn_r,"rb"))==NULL)){ + printf("can't bz2openstream\n"); + exit(1); + } + while((len=BZ2_bzread(BZ2fp_r,buff,0x1000))>0){ + fwrite(buff,1,len,fp_w); + } + BZ2_bzclose(BZ2fp_r); + if(fp_w != stdout) fclose(fp_w); + }else{ + BZFILE *BZ2fp_w = NULL; + FILE *fp_r = NULL; + + if(fn_r){ + if((fp_r = fopen(fn_r,"rb"))==NULL){ + printf("can't open [%s]\n",fn_r); + perror("reason:"); + exit(1); + } + }else{ + fp_r = stdin; + } + mode[0]='w'; + mode[1] = '0' + level; + mode[2] = '\0'; + + if((fn_w == NULL && (BZ2fp_w = BZ2_bzdopen(fileno(stdout),mode))==NULL) + || (fn_w !=NULL && (BZ2fp_w = BZ2_bzopen(fn_w,mode))==NULL)){ + printf("can't bz2openstream\n"); + exit(1); + } + while((len=fread(buff,1,0x1000,fp_r))>0){ + BZ2_bzwrite(BZ2fp_w,buff,len); + } + BZ2_bzclose(BZ2fp_w); + if(fp_r!=stdin)fclose(fp_r); + } + } +#ifdef _WIN32 + BZ2DLLFreeLibrary(); +#endif + return 0; +} diff --git a/src/tools/stuffextract/StormLib/huffman/huff.cpp b/src/tools/stuffextract/StormLib/huffman/huff.cpp index b67672f..612fcb0 100644 --- a/src/tools/stuffextract/StormLib/huffman/huff.cpp +++ b/src/tools/stuffextract/StormLib/huffman/huff.cpp @@ -1,1453 +1,1453 @@ -/*****************************************************************************/ -/* huffman.cpp Copyright (c) Ladislav Zezula 1998-2003 */ -/*---------------------------------------------------------------------------*/ -/* This module contains Huffmann (de)compression methods */ -/* */ -/* Authors : Ladislav Zezula (ladik.zezula.net) */ -/* ShadowFlare (BlakFlare@hotmail.com) */ -/* */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.xx 1.00 Lad The first version of dcmp.cpp */ -/* 03.05.03 1.00 Lad Added compression methods */ -/* 19.11.03 1.01 Dan Big endian handling */ -/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ -/*****************************************************************************/ - -#include -#include - -#include "huff.h" - -// Special for Mac - we have to know if normal pointer greater or less -// than 0x80000000. This variable is used in the PTR_VALID and PTR_INVALID -// macros -static long mul = 1; - -#define PTR_VALID(ptr) (((LONG_PTR)(ptr) * mul) > 0) -#define PTR_INVALID(ptr) (((LONG_PTR)(ptr) * mul) < 0) -#define PTR_INVALID_OR_NULL(ptr) (((LONG_PTR)(ptr) * mul) <= 0) - - -//----------------------------------------------------------------------------- -// Methods of the THTreeItem struct - -// 1501DB70 -THTreeItem * THTreeItem::Call1501DB70(THTreeItem * pLast) -{ - if(pLast == NULL) - pLast = this + 1; - return pLast; -} - -// Gets previous Huffman tree item (?) -THTreeItem * THTreeItem::GetPrevItem(LONG_PTR value) -{ - if(PTR_INVALID(prev)) - return PTR_NOT(prev); - - if(value == -1 || PTR_INVALID(value)) - value = (long)(this - next->prev); - return prev + value; - -// OLD VERSION -// if(PTR_INT(value) < 0) -// value = PTR_INT((item - item->next->prev)); -// return (THTreeItem *)((char *)prev + value); -} - -// 1500F5E0 -void THTreeItem::ClearItemLinks() -{ - next = prev = NULL; -} - -// 1500BC90 -void THTreeItem::RemoveItem() -{ - THTreeItem * pTemp; // EDX - - if(next != NULL) - { - pTemp = prev; - - if(PTR_INVALID_OR_NULL(pTemp)) - pTemp = PTR_NOT(pTemp); - else - pTemp += (this - next->prev); - - pTemp->next = next; - next->prev = prev; - next = prev = NULL; - } -} - -/* -// OLD VERSION : Removes item from the tree (?) -static void RemoveItem(THTreeItem * item) -{ - THTreeItem * next = item->next; // ESI - THTreeItem * prev = item->prev; // EDX - - if(next == NULL) - return; - - if(PTR_INT(prev) < 0) - prev = PTR_NOT(prev); - else - // ??? usually item == next->prev, so what is it ? - prev = (THTreeItem *)((unsigned char *)prev + (unsigned long)((unsigned char *)item - (unsigned char *)(next->prev))); - - // Remove HTree item from the chain - prev->next = next; // Sets the 'first' pointer - next->prev = item->prev; - - // Invalidate pointers - item->next = NULL; - item->prev = NULL; -} -*/ - -//----------------------------------------------------------------------------- -// TOutputStream functions - -void TOutputStream::PutBits(unsigned long dwBuff, unsigned int nPutBits) -{ - dwBitBuff |= (dwBuff << nBits); - nBits += nPutBits; - - // Flush completed bytes - while(nBits >= 8) - { - if(dwOutSize != 0) - { - *pbOutPos++ = (unsigned char)dwBitBuff; - dwOutSize--; - } - - dwBitBuff >>= 8; - nBits -= 8; - } -} - -//----------------------------------------------------------------------------- -// TInputStream functions - -// Gets one bit from input stream -unsigned long TInputStream::GetBit() -{ - unsigned long dwBit = (dwBitBuff & 1); - - dwBitBuff >>= 1; - if(--nBits == 0) - { - dwBitBuff = BSWAP_INT32_UNSIGNED(*(unsigned long *)pbInBuffer); - pbInBuffer += sizeof(unsigned long); - nBits = 32; - } - return dwBit; -} - -// Gets 7 bits from the stream -unsigned long TInputStream::Get7Bits() -{ - if(nBits <= 7) - { - dwBitBuff |= BSWAP_INT16_UNSIGNED(*(unsigned short *)pbInBuffer) << nBits; - pbInBuffer += sizeof(unsigned short); - nBits += 16; - } - - // Get 7 bits from input stream - return (dwBitBuff & 0x7F); -} - -// Gets the whole byte from the input stream. -unsigned long TInputStream::Get8Bits() -{ - unsigned long dwOneByte; - - if(nBits <= 8) - { - dwBitBuff |= BSWAP_INT16_UNSIGNED(*(unsigned short *)pbInBuffer) << nBits; - pbInBuffer += sizeof(unsigned short); - nBits += 16; - } - - dwOneByte = (dwBitBuff & 0xFF); - dwBitBuff >>= 8; - nBits -= 8; - return dwOneByte; -} - -//----------------------------------------------------------------------------- -// Functions for huffmann tree items - -// Inserts item into the tree (?) -static void InsertItem(THTreeItem ** itemPtr, THTreeItem * item, unsigned long where, THTreeItem * item2) -{ - THTreeItem * next = item->next; // EDI - next to the first item - THTreeItem * prev = item->prev; // ESI - prev to the first item - THTreeItem * prev2; // Pointer to previous item - LONG_PTR next2; // Pointer to the next item - - // The same code like in RemoveItem(item); - if(next != 0) // If the first item already has next one - { - if(PTR_INVALID(prev)) - prev = PTR_NOT(prev); - else - prev += (item - next->prev); - - // 150083C1 - // Remove the item from the tree - prev->next = next; - next->prev = prev; - - // Invalidate 'prev' and 'next' pointer - item->next = 0; - item->prev = 0; - } - - if(item2 == NULL) // EDX - If the second item is not entered, - item2 = PTR_PTR(&itemPtr[1]); // take the first tree item - - switch(where) - { - case SWITCH_ITEMS : // Switch the two items - item->next = item2->next; // item2->next (Pointer to pointer to first) - item->prev = item2->next->prev; - item2->next->prev = item; - item2->next = item; // Set the first item - return; - - case INSERT_ITEM: // Insert as the last item - item->next = item2; // Set next item (or pointer to pointer to first item) - item->prev = item2->prev; // Set prev item (or last item in the tree) - - next2 = PTR_INT(itemPtr[0]);// Usually NULL - prev2 = item2->prev; // Prev item to the second (or last tree item) - - if(PTR_INVALID(prev2)) - { - prev2 = PTR_NOT(prev); - - prev2->next = item; - item2->prev = item; // Next after last item - return; - } - - if(PTR_INVALID(next2)) - next2 = (long)(item2 - item2->next->prev); -// next2 = (THTreeItem *)(unsigned long)((unsigned char *)item2 - (unsigned char *)(item2->next->prev)); - -// prev2 = (THTreeItem *)((char *)prev2 + (unsigned long)next2);// ??? - prev2 += next2; - prev2->next = item; - item2->prev = item; // Set the next/last item - return; - - default: - return; - } -} - -//----------------------------------------------------------------------------- -// THuffmannTree class functions - -THuffmannTree::THuffmannTree() -{ - // We have to check if the "this" pointer is less than zero - if((LONG_PTR)this < 0) - mul = -1; -} - -void THuffmannTree::InitTree(bool bCompression) -{ - THTreeItem * pItem; - unsigned int nCount; - - // Clear links for all the items in the tree - for(pItem = items0008, nCount = 0x203; nCount != 0; pItem++, nCount--) - pItem->ClearItemLinks(); - - pItem3050 = NULL; - pItem3054 = PTR_PTR(&pItem3054); - pItem3058 = PTR_NOT(pItem3054); - - pItem305C = NULL; - pFirst = PTR_PTR(&pFirst); - pLast = PTR_NOT(pFirst); - - offs0004 = 1; - nItems = 0; - - // Clear all TQDecompress items. Do this only if preparing for decompression - if(bCompression == false) - { - for(nCount = 0; nCount < sizeof(qd3474) / sizeof(TQDecompress); nCount++) - qd3474[nCount].offs00 = 0; - } -} - -// Builds Huffman tree. Called with the first 8 bits loaded from input stream -void THuffmannTree::BuildTree(unsigned int nCmpType) -{ - unsigned long maxByte; // [ESP+10] - The greatest character found in table - THTreeItem ** itemPtr; // [ESP+14] - Pointer to Huffman tree item pointer array - unsigned char * byteArray; // [ESP+1C] - Pointer to unsigned char in Table1502A630 - THTreeItem * child1; - unsigned long i; // egcs in linux doesn't like multiple for loops without an explicit i - - // Loop while pointer has a valid value - while(PTR_VALID(pLast)) // ESI - Last entry - { - THTreeItem * temp; // EAX - - if(pLast->next != NULL) // ESI->next - pLast->RemoveItem(); - // EDI = &offs3054 - pItem3058 = PTR_PTR(&pItem3054);// [EDI+4] - pLast->prev = pItem3058; // EAX - - temp = PTR_PTR(&pItem3054)->GetPrevItem(PTR_INT(&pItem3050)); - - temp->next = pLast; - pItem3054 = pLast; - } - - // Clear all pointers in HTree item array - memset(items306C, 0, sizeof(items306C)); - - maxByte = 0; // Greatest character found init to zero. - itemPtr = (THTreeItem **)&items306C; // Pointer to current entry in HTree item pointer array - - // Ensure we have low 8 bits only - nCmpType &= 0xFF; - byteArray = Table1502A630 + nCmpType * 258; // EDI also - - for(i = 0; i < 0x100; i++, itemPtr++) - { - THTreeItem * item = pItem3058; // Item to be created - THTreeItem * pItem3 = pItem3058; - unsigned char oneByte = byteArray[i]; - - // Skip all the bytes which are zero. - if(byteArray[i] == 0) - continue; - - // If not valid pointer, take the first available item in the array - if(PTR_INVALID_OR_NULL(item)) - item = &items0008[nItems++]; - - // Insert this item as the top of the tree - InsertItem(&pItem305C, item, SWITCH_ITEMS, NULL); - - item->parent = NULL; // Invalidate child and parent - item->child = NULL; - *itemPtr = item; // Store pointer into pointer array - - item->dcmpByte = i; // Store counter - item->byteValue = oneByte; // Store byte value - if(oneByte >= maxByte) - { - maxByte = oneByte; - continue; - } - - // Find the first item which has byte value greater than current one byte - if(PTR_VALID(pItem3 = pLast)) // EDI - Pointer to the last item - { - // 15006AF7 - if(pItem3 != NULL) - { - do // 15006AFB - { - if(pItem3->byteValue >= oneByte) - goto _15006B09; - pItem3 = pItem3->prev; - } - while(PTR_VALID(pItem3)); - } - } - pItem3 = NULL; - - // 15006B09 - _15006B09: - if(item->next != NULL) - item->RemoveItem(); - - // 15006B15 - if(pItem3 == NULL) - pItem3 = PTR_PTR(&pFirst); - - // 15006B1F - item->next = pItem3->next; - item->prev = pItem3->next->prev; - pItem3->next->prev = item; - pItem3->next = item; - } - - // 15006B4A - for(; i < 0x102; i++) - { - THTreeItem ** itemPtr = &items306C[i]; // EDI - - // 15006B59 - THTreeItem * item = pItem3058; // ESI - if(PTR_INVALID_OR_NULL(item)) - item = &items0008[nItems++]; - - InsertItem(&pItem305C, item, INSERT_ITEM, NULL); - - // 15006B89 - item->dcmpByte = i; - item->byteValue = 1; - item->parent = NULL; - item->child = NULL; - *itemPtr++ = item; - } - - // 15006BAA - if(PTR_VALID(child1 = pLast)) // EDI - last item (first child to item - { - THTreeItem * child2; // EBP - THTreeItem * item; // ESI - - // 15006BB8 - while(PTR_VALID(child2 = child1->prev)) - { - if(PTR_INVALID_OR_NULL(item = pItem3058)) - item = &items0008[nItems++]; - - // 15006BE3 - InsertItem(&pItem305C, item, SWITCH_ITEMS, NULL); - - // 15006BF3 - item->parent = NULL; - item->child = NULL; - - //EDX = child2->byteValue + child1->byteValue; - //EAX = child1->byteValue; - //ECX = maxByte; // The greatest character (0xFF usually) - - item->byteValue = child1->byteValue + child2->byteValue; // 0x02 - item->child = child1; // Prev item in the - child1->parent = item; - child2->parent = item; - - // EAX = item->byteValue; - if(item->byteValue >= maxByte) - maxByte = item->byteValue; - else - { - THTreeItem * pItem2 = child2->prev; // EDI - - // 15006C2D - while(PTR_VALID(pItem2)) - { - if(pItem2->byteValue >= item->byteValue) - goto _15006C3B; - pItem2 = pItem2->prev; - } - pItem2 = NULL; - - _15006C3B: - if(item->next != 0) - { - THTreeItem * temp4 = item->GetPrevItem(-1); - - temp4->next = item->next; // The first item changed - item->next->prev = item->prev; // First->prev changed to negative value - item->next = NULL; - item->prev = NULL; - } - - // 15006C62 - if(pItem2 == NULL) - pItem2 = PTR_PTR(&pFirst); - - item->next = pItem2->next; // Set item with 0x100 byte value - item->prev = pItem2->next->prev; // Set item with 0x17 byte value - pItem2->next->prev = item; // Changed prev of item with - pItem2->next = item; - } - - // 15006C7B - if(PTR_INVALID_OR_NULL(child1 = child2->prev)) - break; - } - } - // 15006C88 - offs0004 = 1; -} -/* -// Modifies Huffman tree. Adds new item and changes -void THuffmannTree::ModifyTree(unsigned long dwIndex) -{ - THTreeItem * pItem1 = pItem3058; // ESI - THTreeItem * pSaveLast = (PTR_INT(pLast) <= 0) ? NULL : pLast; // EBX - THTreeItem * temp; // EAX - - // Prepare the first item to insert to the tree - if(PTR_INT(pItem1) <= 0) - pItem1 = &items0008[nItems++]; - - // If item has any next item, remove it from the chain - if(pItem1->next != NULL) - { - THTreeItem * temp = pItem1->GetPrevItem(-1); // EAX - - temp->next = pItem1->next; - pItem1->next->prev = pItem1->prev; - pItem1->next = NULL; - pItem1->prev = NULL; - } - - pItem1->next = PTR_PTR(&pFirst); - pItem1->prev = pLast; - temp = pItem1->next->GetPrevItem(PTR_INT(pItem305C)); - - // 150068E9 - temp->next = pItem1; - pLast = pItem1; - - pItem1->parent = NULL; - pItem1->child = NULL; - - // 150068F6 - pItem1->dcmpByte = pSaveLast->dcmpByte; // Copy item index - pItem1->byteValue = pSaveLast->byteValue; // Copy item byte value - pItem1->parent = pSaveLast; // Set parent to last item - items306C[pSaveLast->dcmpByte] = pItem1; // Insert item into item pointer array - - // Prepare the second item to insert into the tree - if(PTR_INT((pItem1 = pItem3058)) <= 0) - pItem1 = &items0008[nItems++]; - - // 1500692E - if(pItem1->next != NULL) - { - temp = pItem1->GetPrevItem(-1); // EAX - - temp->next = pItem1->next; - pItem1->next->prev = pItem1->prev; - pItem1->next = NULL; - pItem1->prev = NULL; - } - // 1500694C - pItem1->next = PTR_PTR(&pFirst); - pItem1->prev = pLast; - temp = pItem1->next->GetPrevItem(PTR_INT(pItem305C)); - - // 15006968 - temp->next = pItem1; - pLast = pItem1; - - // 1500696E - pItem1->child = NULL; - pItem1->dcmpByte = dwIndex; - pItem1->byteValue = 0; - pItem1->parent = pSaveLast; - pSaveLast->child = pItem1; - items306C[dwIndex] = pItem1; - - do - { - THTreeItem * pItem2 = pItem1; - THTreeItem * pItem3; - unsigned long byteValue; - - // 15006993 - byteValue = ++pItem1->byteValue; - - // Pass through all previous which have its value greater than byteValue - while(PTR_INT((pItem3 = pItem2->prev)) > 0) // EBX - { - if(pItem3->byteValue >= byteValue) - goto _150069AE; - - pItem2 = pItem2->prev; - } - // 150069AC - pItem3 = NULL; - - _150069AE: - if(pItem2 == pItem1) - continue; - - // 150069B2 - // Switch pItem2 with item - InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); - InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); - - // 150069D0 - // Switch parents of pItem1 and pItem2 - temp = pItem2->parent->child; - if(pItem1 == pItem1->parent->child) - pItem1->parent->child = pItem2; - - if(pItem2 == temp) - pItem2->parent->child = pItem1; - - // 150069ED - // Switch parents of pItem1 and pItem3 - temp = pItem1->parent; - pItem1 ->parent = pItem2->parent; - pItem2->parent = temp; - offs0004++; - } - while(PTR_INT((pItem1 = pItem1->parent)) > 0); -} - -void THuffmannTree::UninitTree() -{ - while(PTR_INT(pLast) > 0) - { - pItem = pItem305C->Call1501DB70(pLast); - pItem->RemoveItem(); - } - - for(pItem = pFirst; PTR_INT(pItem3058) > 0; pItem = pItem3058) - pItem->RemoveItem(); - PTR_PTR(&pItem3054)->RemoveItem(); - - for(pItem = items0008 + 0x203, nCount = 0x203; nCount != 0; nCount--) - { - pItem--; - pItem->RemoveItem(); - pItem->RemoveItem(); - } -} -*/ - -THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue) -{ - THTreeItem * pItem1 = pItem3058; // EDX - THTreeItem * pItem2; // EAX - THTreeItem * pNext; - THTreeItem * pPrev; - THTreeItem ** ppItem; - - if(PTR_INVALID_OR_NULL(pItem1) || (pItem2 = pItem1) == NULL) - { - if((pItem2 = &items0008[nItems++]) != NULL) - pItem1 = pItem2; - else - pItem1 = pFirst; - } - else - pItem1 = pItem2; - - pNext = pItem1->next; - if(pNext != NULL) - { - pPrev = pItem1->prev; - if(PTR_INVALID_OR_NULL(pPrev)) - pPrev = PTR_NOT(pPrev); - else - pPrev += (pItem1 - pItem1->next->prev); - - pPrev->next = pNext; - pNext->prev = pPrev; - pItem1->next = NULL; - pItem1->prev = NULL; - } - - ppItem = &pFirst; // esi - if(nValue > 1) - { - // ecx = pFirst->next; - pItem1->next = *ppItem; - pItem1->prev = (*ppItem)->prev; - - (*ppItem)->prev = pItem2; - *ppItem = pItem1; - - pItem2->parent = NULL; - pItem2->child = NULL; - } - else - { - pItem1->next = (THTreeItem *)ppItem; - pItem1->prev = ppItem[1]; - // edi = pItem305C; - pPrev = ppItem[1]; // ecx - if(PTR_INVALID_OR_NULL(pPrev)) - { - pPrev = PTR_NOT(pPrev); - pPrev->next = pItem1; - pPrev->prev = pItem2; - - pItem2->parent = NULL; - pItem2->child = NULL; - } - else - { - if(PTR_INVALID(pItem305C)) - pPrev += (THTreeItem *)ppItem - (*ppItem)->prev; - else - pPrev += PTR_INT(pItem305C); - - pPrev->next = pItem1; - ppItem[1] = pItem2; - pItem2->parent = NULL; - pItem2->child = NULL; - } - } - return pItem2; -} - -void THuffmannTree::Call1500E820(THTreeItem * pItem) -{ - THTreeItem * pItem1; // edi - THTreeItem * pItem2 = NULL; // eax - THTreeItem * pItem3; // edx - THTreeItem * pPrev; // ebx - - for(; pItem != NULL; pItem = pItem->parent) - { - pItem->byteValue++; - - for(pItem1 = pItem; ; pItem1 = pPrev) - { - pPrev = pItem1->prev; - if(PTR_INVALID_OR_NULL(pPrev)) - { - pPrev = NULL; - break; - } - - if(pPrev->byteValue >= pItem->byteValue) - break; - } - - if(pItem1 == pItem) - continue; - - if(pItem1->next != NULL) - { - pItem2 = pItem1->GetPrevItem(-1); - pItem2->next = pItem1->next; - pItem1->next->prev = pItem1->prev; - pItem1->next = NULL; - pItem1->prev = NULL; - } - - pItem2 = pItem->next; - pItem1->next = pItem2; - pItem1->prev = pItem2->prev; - pItem2->prev = pItem1; - pItem->next = pItem1; - if((pItem2 = pItem1) != NULL) - { - pItem2 = pItem->GetPrevItem(-1); - pItem2->next = pItem->next; - pItem->next->prev = pItem->prev; - pItem->next = NULL; - pItem->prev = NULL; - } - - if(pPrev == NULL) - pPrev = PTR_PTR(&pFirst); - - pItem2 = pPrev->next; - pItem->next = pItem2; - pItem->prev = pItem2->prev; - pItem2->prev = pItem; - pPrev->next = pItem; - - pItem3 = pItem1->parent->child; - pItem2 = pItem->parent; - if(pItem2->child == pItem) - pItem2->child = pItem1; - if(pItem3 == pItem1) - pItem1->parent->child = pItem; - - pItem2 = pItem->parent; - pItem->parent = pItem1->parent; - pItem1->parent = pItem2; - offs0004++; - } -} - -// 1500E920 -unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType) -{ - THTreeItem * pItem1; - THTreeItem * pItem2; - THTreeItem * pItem3; - THTreeItem * pTemp; - unsigned long dwBitBuff; - unsigned int nBits; - unsigned int nBit; - - BuildTree(nCmpType); - bIsCmp0 = (nCmpType == 0); - - // Store the compression type into output buffer - os->dwBitBuff |= (nCmpType << os->nBits); - os->nBits += 8; - - // Flush completed bytes - while(os->nBits >= 8) - { - if(os->dwOutSize != 0) - { - *os->pbOutPos++ = (unsigned char)os->dwBitBuff; - os->dwOutSize--; - } - - os->dwBitBuff >>= 8; - os->nBits -= 8; - } - - for(; nInLength != 0; nInLength--) - { - unsigned char bOneByte = *pbInBuffer++; - - if((pItem1 = items306C[bOneByte]) == NULL) - { - pItem2 = items306C[0x101]; // ecx - pItem3 = pItem2->parent; // eax - dwBitBuff = 0; - nBits = 0; - - for(; pItem3 != NULL; pItem3 = pItem3->parent) - { - nBit = (pItem3->child != pItem2) ? 1 : 0; - dwBitBuff = (dwBitBuff << 1) | nBit; - nBits++; - pItem2 = pItem3; - } - os->PutBits(dwBitBuff, nBits); - - // Store the loaded byte into output stream - os->dwBitBuff |= (bOneByte << os->nBits); - os->nBits += 8; - - // Flush the whole byte(s) - while(os->nBits >= 8) - { - if(os->dwOutSize != 0) - { - *os->pbOutPos++ = (unsigned char)os->dwBitBuff; - os->dwOutSize--; - } - os->dwBitBuff >>= 8; - os->nBits -= 8; - } - - pItem1 = (PTR_INVALID_OR_NULL(pLast)) ? NULL : pLast; - pItem2 = Call1500E740(1); - pItem2->dcmpByte = pItem1->dcmpByte; - pItem2->byteValue = pItem1->byteValue; - pItem2->parent = pItem1; - items306C[pItem2->dcmpByte] = pItem2; - - pItem2 = Call1500E740(1); - pItem2->dcmpByte = bOneByte; - pItem2->byteValue = 0; - pItem2->parent = pItem1; - items306C[pItem2->dcmpByte] = pItem2; - pItem1->child = pItem2; - - Call1500E820(pItem2); - - if(bIsCmp0 != 0) - { - Call1500E820(items306C[bOneByte]); - continue; - } - - for(pItem1 = items306C[bOneByte]; pItem1 != NULL; pItem1 = pItem1->parent) - { - pItem1->byteValue++; - pItem2 = pItem1; - - for(;;) - { - pItem3 = pItem2->prev; - if(PTR_INVALID_OR_NULL(pItem3)) - { - pItem3 = NULL; - break; - } - if(pItem3->byteValue >= pItem1->byteValue) - break; - pItem2 = pItem3; - } - - if(pItem2 != pItem1) - { - InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); - InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); - - pItem3 = pItem2->parent->child; - if(pItem1->parent->child == pItem1) - pItem1->parent->child = pItem2; - - if(pItem3 == pItem2) - pItem2->parent->child = pItem1; - - pTemp = pItem1->parent; - pItem1->parent = pItem2->parent; - pItem2->parent = pTemp; - offs0004++; - } - } - } -// 1500EB62 - else - { - dwBitBuff = 0; - nBits = 0; - for(pItem2 = pItem1->parent; pItem2 != NULL; pItem2 = pItem2->parent) - { - nBit = (pItem2->child != pItem1) ? 1 : 0; - dwBitBuff = (dwBitBuff << 1) | nBit; - nBits++; - pItem1 = pItem2; - } - os->PutBits(dwBitBuff, nBits); - } - -// 1500EB98 - if(bIsCmp0 != 0) - Call1500E820(items306C[bOneByte]); // 1500EB9D -// 1500EBAF - } // for(; nInLength != 0; nInLength--) - -// 1500EBB8 - pItem1 = items306C[0x100]; - dwBitBuff = 0; - nBits = 0; - for(pItem2 = pItem1->parent; pItem2 != NULL; pItem2 = pItem2->parent) - { - nBit = (pItem2->child != pItem1) ? 1 : 0; - dwBitBuff = (dwBitBuff << 1) | nBit; - nBits++; - pItem1 = pItem2; - } - -// 1500EBE6 - os->PutBits(dwBitBuff, nBits); - -// 1500EBEF - // Flush the remaining bits - while(os->nBits != 0) - { - if(os->dwOutSize != 0) - { - *os->pbOutPos++ = (unsigned char)os->dwBitBuff; - os->dwOutSize--; - } - os->dwBitBuff >>= 8; - os->nBits -= ((os->nBits > 8) ? 8 : os->nBits); - } - - return (unsigned int)(os->pbOutPos - os->pbOutBuffer); -} - -// Decompression using Huffman tree (1500E450) -unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is) -{ - TQDecompress * qd; - THTreeItem * pItem1; - THTreeItem * pItem2; - unsigned char * pbOutPos = pbOutBuffer; - unsigned long nBitCount; - unsigned int nDcmpByte = 0; - unsigned int n8Bits; // 8 bits loaded from input stream - unsigned int n7Bits; // 7 bits loaded from input stream - bool bHasQdEntry; - - // Test the output length. Must not be NULL. - if(dwOutLength == 0) - return 0; - - // Get the compression type from the input stream - n8Bits = is->Get8Bits(); - - // Build the Huffman tree - BuildTree(n8Bits); - bIsCmp0 = (n8Bits == 0) ? 1 : 0; - - for(;;) - { - n7Bits = is->Get7Bits(); // Get 7 bits from input stream - - // Try to use quick decompression. Check TQDecompress array for corresponding item. - // If found, ise the result byte instead. - qd = &qd3474[n7Bits]; - - // If there is a quick-pass possible (ebx) - bHasQdEntry = (qd->offs00 >= offs0004) ? true : false; - - // If we can use quick decompress, use it. - if(bHasQdEntry) - { - if(qd->nBits > 7) - { - is->dwBitBuff >>= 7; - is->nBits -= 7; - pItem1 = qd->pItem; - goto _1500E549; - } - is->dwBitBuff >>= qd->nBits; - is->nBits -= qd->nBits; - nDcmpByte = qd->dcmpByte; - } - else - { - pItem1 = pFirst->next->prev; - if(PTR_INVALID_OR_NULL(pItem1)) - pItem1 = NULL; -_1500E549: - nBitCount = 0; - pItem2 = NULL; - - do - { - pItem1 = pItem1->child; // Move down by one level - if(is->GetBit()) // If current bit is set, move to previous - pItem1 = pItem1->prev; - - if(++nBitCount == 7) // If we are at 7th bit, save current HTree item. - pItem2 = pItem1; - } - while(pItem1->child != NULL); // Walk until tree has no deeper level - - if(bHasQdEntry == false) - { - if(nBitCount > 7) - { - qd->offs00 = offs0004; - qd->nBits = nBitCount; - qd->pItem = pItem2; - } - else - { - unsigned long nIndex = n7Bits & (0xFFFFFFFF >> (32 - nBitCount)); - unsigned long nAdd = (1 << nBitCount); - - for(qd = &qd3474[nIndex]; nIndex <= 0x7F; nIndex += nAdd, qd += nAdd) - { - qd->offs00 = offs0004; - qd->nBits = nBitCount; - qd->dcmpByte = pItem1->dcmpByte; - } - } - } - nDcmpByte = pItem1->dcmpByte; - } - - if(nDcmpByte == 0x101) // Huffman tree needs to be modified - { - n8Bits = is->Get8Bits(); - pItem1 = (PTR_INVALID_OR_NULL(pLast)) ? NULL : pLast; - - pItem2 = Call1500E740(1); - pItem2->parent = pItem1; - pItem2->dcmpByte = pItem1->dcmpByte; - pItem2->byteValue = pItem1->byteValue; - items306C[pItem2->dcmpByte] = pItem2; - - pItem2 = Call1500E740(1); - pItem2->parent = pItem1; - pItem2->dcmpByte = n8Bits; - pItem2->byteValue = 0; - items306C[pItem2->dcmpByte] = pItem2; - - pItem1->child = pItem2; - Call1500E820(pItem2); - if(bIsCmp0 == 0) - Call1500E820(items306C[n8Bits]); - - nDcmpByte = n8Bits; - } - - if(nDcmpByte == 0x100) - break; - - *pbOutPos++ = (unsigned char)nDcmpByte; - if(--dwOutLength == 0) - break; - - if(bIsCmp0) - Call1500E820(items306C[nDcmpByte]); - } - - return (unsigned int)(pbOutPos - pbOutBuffer); -} - -/* OLD VERSION -unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is) -{ - THTreeItem * pItem1; // Current item if walking HTree - unsigned long bitCount; // Bit counter if walking HTree - unsigned long oneByte; // 8 bits from bit stream/Pointer to target - unsigned char * outPtr; // Current pointer to output buffer - bool hasQDEntry; // true if entry for quick decompression if filled - THTreeItem * itemAt7 = NULL; // HTree item found at 7th bit - THTreeItem * temp; // For every use - unsigned long dcmpByte = 0; // Decompressed byte value - bool bFlag = 0; - - // Test the output length. Must not be NULL. - if(dwOutLength == 0) - return 0; - - // If too few bits in input bit buffer, we have to load next 16 bits - is->EnsureHasMoreThan8Bits(); - - // Get 8 bits from input stream - oneByte = is->Get8Bits(); - - // Build the Huffman tree - BuildTree(oneByte); - - bIsCmp0 = (oneByte == 0) ? 1 : 0; - outPtr = pbOutBuffer; // Copy pointer to output data - - for(;;) - { - TQDecompress * qd; // For quick decompress - unsigned long sevenBits = is->Get7Bits();// 7 bits from input stream - - // Try to use quick decompression. Check TQDecompress array for corresponding item. - // If found, ise the result byte instead. - qd = &qd3474[sevenBits]; - - // If there is a quick-pass possible - hasQDEntry = (qd->offs00 == offs0004) ? 1 : 0; - - // Start passing the Huffman tree. Set item to tree root item - pItem1 = pFirst; - - // If we can use quick decompress, use it. - bFlag = 1; - if(hasQDEntry == 1) - { - // Check the bit count is greater than 7, move item to 7 levels deeper - if((bitCount = qd->bitCount) > 7) - { - is->dwBitBuff >>= 7; - is->nBits -= 7; - pItem1 = qd->item; // Don't start with root item, but with some deeper-laying - } - else - { - // If OK, use their byte value - is->dwBitBuff >>= bitCount; - is->nBits -= bitCount; - dcmpByte = qd->dcmpByte; - bFlag = 0; - } - } - else - { - pItem1 = pFirst->next->prev; - if(PTR_INT(pItem1) <= 0) - pItem1 = NULL; - } - - if(bFlag == 1) - { - // Walk through Huffman Tree - bitCount = 0; // Clear bit counter - do - { - pItem1 = pItem1->child; - if(is->GetBit() != 0) // If current bit is set, move to previous - pItem1 = pItem1->prev; // item in current level - - if(++bitCount == 7) // If we are at 7th bit, store current HTree item. - itemAt7 = pItem1; // Store Huffman tree item - } - while(pItem1->child != NULL); // Walk until tree has no deeper level - - // If quick decompress entry is not filled yet, fill it. - if(hasQDEntry == 0) - { - if(bitCount > 7) // If we passed more than 7 bits, store bitCount and item - { - qd->offs00 = offs0004; // Value indicates that entry is resolved - qd->bitCount = bitCount; // Number of bits passed - qd->item = itemAt7; // Store item at 7th bit - } - // If we passed less than 7 bits, fill entry and bit count multipliers - else - { - unsigned long index = sevenBits & (0xFFFFFFFF >> (32 - bitCount)); // Index for quick-decompress entry - unsigned long addIndex = (1 << bitCount); // Add value for index - - qd = &qd3474[index]; - - do - { - qd->offs00 = offs0004; - qd->bitCount = bitCount; - qd->dcmpByte = pItem1->dcmpByte; - - index += addIndex; - qd += addIndex; - } - while(index <= 0x7F); - } - } - dcmpByte = pItem1->dcmpByte; - } - - if(dcmpByte == 0x101) // Huffman tree needs to be modified - { - // Check if there is enough bits in the buffer - is->EnsureHasMoreThan8Bits(); - - // Get 8 bits from the buffer - oneByte = is->Get8Bits(); - - // Modify Huffman tree - ModifyTree(oneByte); - - // Get lastly added tree item - pItem1 = items306C[oneByte]; - - if(bIsCmp0 == 0 && pItem1 != NULL) - { - // 15006F15 - do - { - THTreeItem * pItem2 = pItem1; - THTreeItem * pItem3; - unsigned long byteValue; - - byteValue = ++pItem1->byteValue; - - while(PTR_INT((pItem3 = pItem2->prev)) > 0) - { - if(pItem3->byteValue >= byteValue) - goto _15006F30; - - pItem2 = pItem2->prev; - } - pItem3 = NULL; - - _15006F30: - if(pItem2 == pItem1) - continue; - - InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); - InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); - - temp = pItem2->parent->child; - if(pItem1 == pItem1->parent->child) - pItem1->parent->child = pItem2; - - if(pItem2 == temp) - pItem2->parent->child = pItem1; - - // Switch parents of pItem1 and pItem3 - temp = pItem1->parent; - pItem1->parent = pItem2->parent; - pItem2->parent = temp; - offs0004++; - } - while(PTR_INT((pItem1 = pItem1->parent)) > 0); - } - dcmpByte = oneByte; - } - - if(dcmpByte != 0x100) // Not at the end of data ? - { - *outPtr++ = (unsigned char)dcmpByte; - if(--dwOutLength > 0) - { - if(bIsCmp0 != 0) - Call1500E820(items306C[pItem1->byteValue]); - } - else - break; - } - else - break; - } - return (unsigned long)(outPtr - pbOutBuffer); -} -*/ - -// Table for (de)compression. Every compression type has 258 entries -unsigned char THuffmannTree::Table1502A630[] = -{ - // Data for compression type 0x00 - 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, - - // Data for compression type 0x01 - 0x54, 0x16, 0x16, 0x0D, 0x0C, 0x08, 0x06, 0x05, 0x06, 0x05, 0x06, 0x03, 0x04, 0x04, 0x03, 0x05, - 0x0E, 0x0B, 0x14, 0x13, 0x13, 0x09, 0x0B, 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, - 0x0D, 0x07, 0x09, 0x06, 0x06, 0x04, 0x03, 0x02, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, - 0x09, 0x06, 0x04, 0x04, 0x04, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x04, - 0x08, 0x03, 0x04, 0x07, 0x09, 0x05, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, - 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, - 0x06, 0x0A, 0x08, 0x08, 0x06, 0x07, 0x04, 0x03, 0x04, 0x04, 0x02, 0x02, 0x04, 0x02, 0x03, 0x03, - 0x04, 0x03, 0x07, 0x07, 0x09, 0x06, 0x04, 0x03, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x0A, 0x02, 0x02, 0x03, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x03, 0x05, 0x02, 0x03, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x03, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x09, 0x08, 0x0C, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x03, - 0x04, 0x01, 0x02, 0x04, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x4B, - 0x00, 0x00, - - // Data for compression type 0x02 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x27, 0x00, 0x00, 0x23, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x06, 0x0E, 0x10, 0x04, - 0x06, 0x08, 0x05, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x01, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x04, 0x02, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x04, 0x01, 0x01, 0x02, 0x03, 0x03, 0x02, - 0x03, 0x01, 0x03, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x29, 0x07, 0x16, 0x12, 0x40, 0x0A, 0x0A, 0x11, 0x25, 0x01, 0x03, 0x17, 0x10, 0x26, 0x2A, - 0x10, 0x01, 0x23, 0x23, 0x2F, 0x10, 0x06, 0x07, 0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - // Data for compression type 0x03 - 0xFF, 0x0B, 0x07, 0x05, 0x0B, 0x02, 0x02, 0x02, 0x06, 0x02, 0x02, 0x01, 0x04, 0x02, 0x01, 0x03, - 0x09, 0x01, 0x01, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x05, 0x01, 0x01, 0x01, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x0A, 0x04, 0x02, 0x01, 0x06, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, - 0x05, 0x02, 0x03, 0x04, 0x03, 0x03, 0x03, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x03, 0x03, - 0x01, 0x03, 0x01, 0x01, 0x02, 0x05, 0x01, 0x01, 0x04, 0x03, 0x05, 0x01, 0x03, 0x01, 0x03, 0x03, - 0x02, 0x01, 0x04, 0x03, 0x0A, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x0A, 0x02, 0x05, 0x01, 0x01, 0x02, 0x07, 0x02, 0x17, 0x01, 0x05, 0x01, 0x01, - 0x0E, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x06, 0x02, 0x01, 0x04, 0x05, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, - 0x00, 0x00, - - // Data for compression type 0x04 - 0xFF, 0xFB, 0x98, 0x9A, 0x84, 0x85, 0x63, 0x64, 0x3E, 0x3E, 0x22, 0x22, 0x13, 0x13, 0x18, 0x17, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - // Data for compression type 0x05 - 0xFF, 0xF1, 0x9D, 0x9E, 0x9A, 0x9B, 0x9A, 0x97, 0x93, 0x93, 0x8C, 0x8E, 0x86, 0x88, 0x80, 0x82, - 0x7C, 0x7C, 0x72, 0x73, 0x69, 0x6B, 0x5F, 0x60, 0x55, 0x56, 0x4A, 0x4B, 0x40, 0x41, 0x37, 0x37, - 0x2F, 0x2F, 0x27, 0x27, 0x21, 0x21, 0x1B, 0x1C, 0x17, 0x17, 0x13, 0x13, 0x10, 0x10, 0x0D, 0x0D, - 0x0B, 0x0B, 0x09, 0x09, 0x08, 0x08, 0x07, 0x07, 0x06, 0x05, 0x05, 0x04, 0x04, 0x04, 0x19, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - // Data for compression type 0x06 - 0xC3, 0xCB, 0xF5, 0x41, 0xFF, 0x7B, 0xF7, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xCC, 0xF2, 0x40, 0xFD, 0x7C, 0xF7, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x7A, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - // Data for compression type 0x07 - 0xC3, 0xD9, 0xEF, 0x3D, 0xF9, 0x7C, 0xE9, 0x1E, 0xFD, 0xAB, 0xF1, 0x2C, 0xFC, 0x5B, 0xFE, 0x17, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBD, 0xD9, 0xEC, 0x3D, 0xF5, 0x7D, 0xE8, 0x1D, 0xFB, 0xAE, 0xF0, 0x2C, 0xFB, 0x5C, 0xFF, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x70, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - // Data for compression type 0x08 - 0xBA, 0xC5, 0xDA, 0x33, 0xE3, 0x6D, 0xD8, 0x18, 0xE5, 0x94, 0xDA, 0x23, 0xDF, 0x4A, 0xD1, 0x10, - 0xEE, 0xAF, 0xE4, 0x2C, 0xEA, 0x5A, 0xDE, 0x15, 0xF4, 0x87, 0xE9, 0x21, 0xF6, 0x43, 0xFC, 0x12, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xB0, 0xC7, 0xD8, 0x33, 0xE3, 0x6B, 0xD6, 0x18, 0xE7, 0x95, 0xD8, 0x23, 0xDB, 0x49, 0xD0, 0x11, - 0xE9, 0xB2, 0xE2, 0x2B, 0xE8, 0x5C, 0xDD, 0x15, 0xF1, 0x87, 0xE7, 0x20, 0xF7, 0x44, 0xFF, 0x13, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x5F, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 +/*****************************************************************************/ +/* huffman.cpp Copyright (c) Ladislav Zezula 1998-2003 */ +/*---------------------------------------------------------------------------*/ +/* This module contains Huffmann (de)compression methods */ +/* */ +/* Authors : Ladislav Zezula (ladik.zezula.net) */ +/* ShadowFlare (BlakFlare@hotmail.com) */ +/* */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* xx.xx.xx 1.00 Lad The first version of dcmp.cpp */ +/* 03.05.03 1.00 Lad Added compression methods */ +/* 19.11.03 1.01 Dan Big endian handling */ +/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ +/*****************************************************************************/ + +#include +#include + +#include "huff.h" + +// Special for Mac - we have to know if normal pointer greater or less +// than 0x80000000. This variable is used in the PTR_VALID and PTR_INVALID +// macros +static long mul = 1; + +#define PTR_VALID(ptr) (((LONG_PTR)(ptr) * mul) > 0) +#define PTR_INVALID(ptr) (((LONG_PTR)(ptr) * mul) < 0) +#define PTR_INVALID_OR_NULL(ptr) (((LONG_PTR)(ptr) * mul) <= 0) + + +//----------------------------------------------------------------------------- +// Methods of the THTreeItem struct + +// 1501DB70 +THTreeItem * THTreeItem::Call1501DB70(THTreeItem * pLast) +{ + if(pLast == NULL) + pLast = this + 1; + return pLast; +} + +// Gets previous Huffman tree item (?) +THTreeItem * THTreeItem::GetPrevItem(LONG_PTR value) +{ + if(PTR_INVALID(prev)) + return PTR_NOT(prev); + + if(value == -1 || PTR_INVALID(value)) + value = (long)(this - next->prev); + return prev + value; + +// OLD VERSION +// if(PTR_INT(value) < 0) +// value = PTR_INT((item - item->next->prev)); +// return (THTreeItem *)((char *)prev + value); +} + +// 1500F5E0 +void THTreeItem::ClearItemLinks() +{ + next = prev = NULL; +} + +// 1500BC90 +void THTreeItem::RemoveItem() +{ + THTreeItem * pTemp; // EDX + + if(next != NULL) + { + pTemp = prev; + + if(PTR_INVALID_OR_NULL(pTemp)) + pTemp = PTR_NOT(pTemp); + else + pTemp += (this - next->prev); + + pTemp->next = next; + next->prev = prev; + next = prev = NULL; + } +} + +/* +// OLD VERSION : Removes item from the tree (?) +static void RemoveItem(THTreeItem * item) +{ + THTreeItem * next = item->next; // ESI + THTreeItem * prev = item->prev; // EDX + + if(next == NULL) + return; + + if(PTR_INT(prev) < 0) + prev = PTR_NOT(prev); + else + // ??? usually item == next->prev, so what is it ? + prev = (THTreeItem *)((unsigned char *)prev + (unsigned long)((unsigned char *)item - (unsigned char *)(next->prev))); + + // Remove HTree item from the chain + prev->next = next; // Sets the 'first' pointer + next->prev = item->prev; + + // Invalidate pointers + item->next = NULL; + item->prev = NULL; +} +*/ + +//----------------------------------------------------------------------------- +// TOutputStream functions + +void TOutputStream::PutBits(unsigned long dwBuff, unsigned int nPutBits) +{ + dwBitBuff |= (dwBuff << nBits); + nBits += nPutBits; + + // Flush completed bytes + while(nBits >= 8) + { + if(dwOutSize != 0) + { + *pbOutPos++ = (unsigned char)dwBitBuff; + dwOutSize--; + } + + dwBitBuff >>= 8; + nBits -= 8; + } +} + +//----------------------------------------------------------------------------- +// TInputStream functions + +// Gets one bit from input stream +unsigned long TInputStream::GetBit() +{ + unsigned long dwBit = (dwBitBuff & 1); + + dwBitBuff >>= 1; + if(--nBits == 0) + { + dwBitBuff = BSWAP_INT32_UNSIGNED(*(unsigned long *)pbInBuffer); + pbInBuffer += sizeof(unsigned long); + nBits = 32; + } + return dwBit; +} + +// Gets 7 bits from the stream +unsigned long TInputStream::Get7Bits() +{ + if(nBits <= 7) + { + dwBitBuff |= BSWAP_INT16_UNSIGNED(*(unsigned short *)pbInBuffer) << nBits; + pbInBuffer += sizeof(unsigned short); + nBits += 16; + } + + // Get 7 bits from input stream + return (dwBitBuff & 0x7F); +} + +// Gets the whole byte from the input stream. +unsigned long TInputStream::Get8Bits() +{ + unsigned long dwOneByte; + + if(nBits <= 8) + { + dwBitBuff |= BSWAP_INT16_UNSIGNED(*(unsigned short *)pbInBuffer) << nBits; + pbInBuffer += sizeof(unsigned short); + nBits += 16; + } + + dwOneByte = (dwBitBuff & 0xFF); + dwBitBuff >>= 8; + nBits -= 8; + return dwOneByte; +} + +//----------------------------------------------------------------------------- +// Functions for huffmann tree items + +// Inserts item into the tree (?) +static void InsertItem(THTreeItem ** itemPtr, THTreeItem * item, unsigned long where, THTreeItem * item2) +{ + THTreeItem * next = item->next; // EDI - next to the first item + THTreeItem * prev = item->prev; // ESI - prev to the first item + THTreeItem * prev2; // Pointer to previous item + LONG_PTR next2; // Pointer to the next item + + // The same code like in RemoveItem(item); + if(next != 0) // If the first item already has next one + { + if(PTR_INVALID(prev)) + prev = PTR_NOT(prev); + else + prev += (item - next->prev); + + // 150083C1 + // Remove the item from the tree + prev->next = next; + next->prev = prev; + + // Invalidate 'prev' and 'next' pointer + item->next = 0; + item->prev = 0; + } + + if(item2 == NULL) // EDX - If the second item is not entered, + item2 = PTR_PTR(&itemPtr[1]); // take the first tree item + + switch(where) + { + case SWITCH_ITEMS : // Switch the two items + item->next = item2->next; // item2->next (Pointer to pointer to first) + item->prev = item2->next->prev; + item2->next->prev = item; + item2->next = item; // Set the first item + return; + + case INSERT_ITEM: // Insert as the last item + item->next = item2; // Set next item (or pointer to pointer to first item) + item->prev = item2->prev; // Set prev item (or last item in the tree) + + next2 = PTR_INT(itemPtr[0]);// Usually NULL + prev2 = item2->prev; // Prev item to the second (or last tree item) + + if(PTR_INVALID(prev2)) + { + prev2 = PTR_NOT(prev); + + prev2->next = item; + item2->prev = item; // Next after last item + return; + } + + if(PTR_INVALID(next2)) + next2 = (long)(item2 - item2->next->prev); +// next2 = (THTreeItem *)(unsigned long)((unsigned char *)item2 - (unsigned char *)(item2->next->prev)); + +// prev2 = (THTreeItem *)((char *)prev2 + (unsigned long)next2);// ??? + prev2 += next2; + prev2->next = item; + item2->prev = item; // Set the next/last item + return; + + default: + return; + } +} + +//----------------------------------------------------------------------------- +// THuffmannTree class functions + +THuffmannTree::THuffmannTree() +{ + // We have to check if the "this" pointer is less than zero + if((LONG_PTR)this < 0) + mul = -1; +} + +void THuffmannTree::InitTree(bool bCompression) +{ + THTreeItem * pItem; + unsigned int nCount; + + // Clear links for all the items in the tree + for(pItem = items0008, nCount = 0x203; nCount != 0; pItem++, nCount--) + pItem->ClearItemLinks(); + + pItem3050 = NULL; + pItem3054 = PTR_PTR(&pItem3054); + pItem3058 = PTR_NOT(pItem3054); + + pItem305C = NULL; + pFirst = PTR_PTR(&pFirst); + pLast = PTR_NOT(pFirst); + + offs0004 = 1; + nItems = 0; + + // Clear all TQDecompress items. Do this only if preparing for decompression + if(bCompression == false) + { + for(nCount = 0; nCount < sizeof(qd3474) / sizeof(TQDecompress); nCount++) + qd3474[nCount].offs00 = 0; + } +} + +// Builds Huffman tree. Called with the first 8 bits loaded from input stream +void THuffmannTree::BuildTree(unsigned int nCmpType) +{ + unsigned long maxByte; // [ESP+10] - The greatest character found in table + THTreeItem ** itemPtr; // [ESP+14] - Pointer to Huffman tree item pointer array + unsigned char * byteArray; // [ESP+1C] - Pointer to unsigned char in Table1502A630 + THTreeItem * child1; + unsigned long i; // egcs in linux doesn't like multiple for loops without an explicit i + + // Loop while pointer has a valid value + while(PTR_VALID(pLast)) // ESI - Last entry + { + THTreeItem * temp; // EAX + + if(pLast->next != NULL) // ESI->next + pLast->RemoveItem(); + // EDI = &offs3054 + pItem3058 = PTR_PTR(&pItem3054);// [EDI+4] + pLast->prev = pItem3058; // EAX + + temp = PTR_PTR(&pItem3054)->GetPrevItem(PTR_INT(&pItem3050)); + + temp->next = pLast; + pItem3054 = pLast; + } + + // Clear all pointers in HTree item array + memset(items306C, 0, sizeof(items306C)); + + maxByte = 0; // Greatest character found init to zero. + itemPtr = (THTreeItem **)&items306C; // Pointer to current entry in HTree item pointer array + + // Ensure we have low 8 bits only + nCmpType &= 0xFF; + byteArray = Table1502A630 + nCmpType * 258; // EDI also + + for(i = 0; i < 0x100; i++, itemPtr++) + { + THTreeItem * item = pItem3058; // Item to be created + THTreeItem * pItem3 = pItem3058; + unsigned char oneByte = byteArray[i]; + + // Skip all the bytes which are zero. + if(byteArray[i] == 0) + continue; + + // If not valid pointer, take the first available item in the array + if(PTR_INVALID_OR_NULL(item)) + item = &items0008[nItems++]; + + // Insert this item as the top of the tree + InsertItem(&pItem305C, item, SWITCH_ITEMS, NULL); + + item->parent = NULL; // Invalidate child and parent + item->child = NULL; + *itemPtr = item; // Store pointer into pointer array + + item->dcmpByte = i; // Store counter + item->byteValue = oneByte; // Store byte value + if(oneByte >= maxByte) + { + maxByte = oneByte; + continue; + } + + // Find the first item which has byte value greater than current one byte + if(PTR_VALID(pItem3 = pLast)) // EDI - Pointer to the last item + { + // 15006AF7 + if(pItem3 != NULL) + { + do // 15006AFB + { + if(pItem3->byteValue >= oneByte) + goto _15006B09; + pItem3 = pItem3->prev; + } + while(PTR_VALID(pItem3)); + } + } + pItem3 = NULL; + + // 15006B09 + _15006B09: + if(item->next != NULL) + item->RemoveItem(); + + // 15006B15 + if(pItem3 == NULL) + pItem3 = PTR_PTR(&pFirst); + + // 15006B1F + item->next = pItem3->next; + item->prev = pItem3->next->prev; + pItem3->next->prev = item; + pItem3->next = item; + } + + // 15006B4A + for(; i < 0x102; i++) + { + THTreeItem ** itemPtr = &items306C[i]; // EDI + + // 15006B59 + THTreeItem * item = pItem3058; // ESI + if(PTR_INVALID_OR_NULL(item)) + item = &items0008[nItems++]; + + InsertItem(&pItem305C, item, INSERT_ITEM, NULL); + + // 15006B89 + item->dcmpByte = i; + item->byteValue = 1; + item->parent = NULL; + item->child = NULL; + *itemPtr++ = item; + } + + // 15006BAA + if(PTR_VALID(child1 = pLast)) // EDI - last item (first child to item + { + THTreeItem * child2; // EBP + THTreeItem * item; // ESI + + // 15006BB8 + while(PTR_VALID(child2 = child1->prev)) + { + if(PTR_INVALID_OR_NULL(item = pItem3058)) + item = &items0008[nItems++]; + + // 15006BE3 + InsertItem(&pItem305C, item, SWITCH_ITEMS, NULL); + + // 15006BF3 + item->parent = NULL; + item->child = NULL; + + //EDX = child2->byteValue + child1->byteValue; + //EAX = child1->byteValue; + //ECX = maxByte; // The greatest character (0xFF usually) + + item->byteValue = child1->byteValue + child2->byteValue; // 0x02 + item->child = child1; // Prev item in the + child1->parent = item; + child2->parent = item; + + // EAX = item->byteValue; + if(item->byteValue >= maxByte) + maxByte = item->byteValue; + else + { + THTreeItem * pItem2 = child2->prev; // EDI + + // 15006C2D + while(PTR_VALID(pItem2)) + { + if(pItem2->byteValue >= item->byteValue) + goto _15006C3B; + pItem2 = pItem2->prev; + } + pItem2 = NULL; + + _15006C3B: + if(item->next != 0) + { + THTreeItem * temp4 = item->GetPrevItem(-1); + + temp4->next = item->next; // The first item changed + item->next->prev = item->prev; // First->prev changed to negative value + item->next = NULL; + item->prev = NULL; + } + + // 15006C62 + if(pItem2 == NULL) + pItem2 = PTR_PTR(&pFirst); + + item->next = pItem2->next; // Set item with 0x100 byte value + item->prev = pItem2->next->prev; // Set item with 0x17 byte value + pItem2->next->prev = item; // Changed prev of item with + pItem2->next = item; + } + + // 15006C7B + if(PTR_INVALID_OR_NULL(child1 = child2->prev)) + break; + } + } + // 15006C88 + offs0004 = 1; +} +/* +// Modifies Huffman tree. Adds new item and changes +void THuffmannTree::ModifyTree(unsigned long dwIndex) +{ + THTreeItem * pItem1 = pItem3058; // ESI + THTreeItem * pSaveLast = (PTR_INT(pLast) <= 0) ? NULL : pLast; // EBX + THTreeItem * temp; // EAX + + // Prepare the first item to insert to the tree + if(PTR_INT(pItem1) <= 0) + pItem1 = &items0008[nItems++]; + + // If item has any next item, remove it from the chain + if(pItem1->next != NULL) + { + THTreeItem * temp = pItem1->GetPrevItem(-1); // EAX + + temp->next = pItem1->next; + pItem1->next->prev = pItem1->prev; + pItem1->next = NULL; + pItem1->prev = NULL; + } + + pItem1->next = PTR_PTR(&pFirst); + pItem1->prev = pLast; + temp = pItem1->next->GetPrevItem(PTR_INT(pItem305C)); + + // 150068E9 + temp->next = pItem1; + pLast = pItem1; + + pItem1->parent = NULL; + pItem1->child = NULL; + + // 150068F6 + pItem1->dcmpByte = pSaveLast->dcmpByte; // Copy item index + pItem1->byteValue = pSaveLast->byteValue; // Copy item byte value + pItem1->parent = pSaveLast; // Set parent to last item + items306C[pSaveLast->dcmpByte] = pItem1; // Insert item into item pointer array + + // Prepare the second item to insert into the tree + if(PTR_INT((pItem1 = pItem3058)) <= 0) + pItem1 = &items0008[nItems++]; + + // 1500692E + if(pItem1->next != NULL) + { + temp = pItem1->GetPrevItem(-1); // EAX + + temp->next = pItem1->next; + pItem1->next->prev = pItem1->prev; + pItem1->next = NULL; + pItem1->prev = NULL; + } + // 1500694C + pItem1->next = PTR_PTR(&pFirst); + pItem1->prev = pLast; + temp = pItem1->next->GetPrevItem(PTR_INT(pItem305C)); + + // 15006968 + temp->next = pItem1; + pLast = pItem1; + + // 1500696E + pItem1->child = NULL; + pItem1->dcmpByte = dwIndex; + pItem1->byteValue = 0; + pItem1->parent = pSaveLast; + pSaveLast->child = pItem1; + items306C[dwIndex] = pItem1; + + do + { + THTreeItem * pItem2 = pItem1; + THTreeItem * pItem3; + unsigned long byteValue; + + // 15006993 + byteValue = ++pItem1->byteValue; + + // Pass through all previous which have its value greater than byteValue + while(PTR_INT((pItem3 = pItem2->prev)) > 0) // EBX + { + if(pItem3->byteValue >= byteValue) + goto _150069AE; + + pItem2 = pItem2->prev; + } + // 150069AC + pItem3 = NULL; + + _150069AE: + if(pItem2 == pItem1) + continue; + + // 150069B2 + // Switch pItem2 with item + InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); + InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); + + // 150069D0 + // Switch parents of pItem1 and pItem2 + temp = pItem2->parent->child; + if(pItem1 == pItem1->parent->child) + pItem1->parent->child = pItem2; + + if(pItem2 == temp) + pItem2->parent->child = pItem1; + + // 150069ED + // Switch parents of pItem1 and pItem3 + temp = pItem1->parent; + pItem1 ->parent = pItem2->parent; + pItem2->parent = temp; + offs0004++; + } + while(PTR_INT((pItem1 = pItem1->parent)) > 0); +} + +void THuffmannTree::UninitTree() +{ + while(PTR_INT(pLast) > 0) + { + pItem = pItem305C->Call1501DB70(pLast); + pItem->RemoveItem(); + } + + for(pItem = pFirst; PTR_INT(pItem3058) > 0; pItem = pItem3058) + pItem->RemoveItem(); + PTR_PTR(&pItem3054)->RemoveItem(); + + for(pItem = items0008 + 0x203, nCount = 0x203; nCount != 0; nCount--) + { + pItem--; + pItem->RemoveItem(); + pItem->RemoveItem(); + } +} +*/ + +THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue) +{ + THTreeItem * pItem1 = pItem3058; // EDX + THTreeItem * pItem2; // EAX + THTreeItem * pNext; + THTreeItem * pPrev; + THTreeItem ** ppItem; + + if(PTR_INVALID_OR_NULL(pItem1) || (pItem2 = pItem1) == NULL) + { + if((pItem2 = &items0008[nItems++]) != NULL) + pItem1 = pItem2; + else + pItem1 = pFirst; + } + else + pItem1 = pItem2; + + pNext = pItem1->next; + if(pNext != NULL) + { + pPrev = pItem1->prev; + if(PTR_INVALID_OR_NULL(pPrev)) + pPrev = PTR_NOT(pPrev); + else + pPrev += (pItem1 - pItem1->next->prev); + + pPrev->next = pNext; + pNext->prev = pPrev; + pItem1->next = NULL; + pItem1->prev = NULL; + } + + ppItem = &pFirst; // esi + if(nValue > 1) + { + // ecx = pFirst->next; + pItem1->next = *ppItem; + pItem1->prev = (*ppItem)->prev; + + (*ppItem)->prev = pItem2; + *ppItem = pItem1; + + pItem2->parent = NULL; + pItem2->child = NULL; + } + else + { + pItem1->next = (THTreeItem *)ppItem; + pItem1->prev = ppItem[1]; + // edi = pItem305C; + pPrev = ppItem[1]; // ecx + if(PTR_INVALID_OR_NULL(pPrev)) + { + pPrev = PTR_NOT(pPrev); + pPrev->next = pItem1; + pPrev->prev = pItem2; + + pItem2->parent = NULL; + pItem2->child = NULL; + } + else + { + if(PTR_INVALID(pItem305C)) + pPrev += (THTreeItem *)ppItem - (*ppItem)->prev; + else + pPrev += PTR_INT(pItem305C); + + pPrev->next = pItem1; + ppItem[1] = pItem2; + pItem2->parent = NULL; + pItem2->child = NULL; + } + } + return pItem2; +} + +void THuffmannTree::Call1500E820(THTreeItem * pItem) +{ + THTreeItem * pItem1; // edi + THTreeItem * pItem2 = NULL; // eax + THTreeItem * pItem3; // edx + THTreeItem * pPrev; // ebx + + for(; pItem != NULL; pItem = pItem->parent) + { + pItem->byteValue++; + + for(pItem1 = pItem; ; pItem1 = pPrev) + { + pPrev = pItem1->prev; + if(PTR_INVALID_OR_NULL(pPrev)) + { + pPrev = NULL; + break; + } + + if(pPrev->byteValue >= pItem->byteValue) + break; + } + + if(pItem1 == pItem) + continue; + + if(pItem1->next != NULL) + { + pItem2 = pItem1->GetPrevItem(-1); + pItem2->next = pItem1->next; + pItem1->next->prev = pItem1->prev; + pItem1->next = NULL; + pItem1->prev = NULL; + } + + pItem2 = pItem->next; + pItem1->next = pItem2; + pItem1->prev = pItem2->prev; + pItem2->prev = pItem1; + pItem->next = pItem1; + if((pItem2 = pItem1) != NULL) + { + pItem2 = pItem->GetPrevItem(-1); + pItem2->next = pItem->next; + pItem->next->prev = pItem->prev; + pItem->next = NULL; + pItem->prev = NULL; + } + + if(pPrev == NULL) + pPrev = PTR_PTR(&pFirst); + + pItem2 = pPrev->next; + pItem->next = pItem2; + pItem->prev = pItem2->prev; + pItem2->prev = pItem; + pPrev->next = pItem; + + pItem3 = pItem1->parent->child; + pItem2 = pItem->parent; + if(pItem2->child == pItem) + pItem2->child = pItem1; + if(pItem3 == pItem1) + pItem1->parent->child = pItem; + + pItem2 = pItem->parent; + pItem->parent = pItem1->parent; + pItem1->parent = pItem2; + offs0004++; + } +} + +// 1500E920 +unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType) +{ + THTreeItem * pItem1; + THTreeItem * pItem2; + THTreeItem * pItem3; + THTreeItem * pTemp; + unsigned long dwBitBuff; + unsigned int nBits; + unsigned int nBit; + + BuildTree(nCmpType); + bIsCmp0 = (nCmpType == 0); + + // Store the compression type into output buffer + os->dwBitBuff |= (nCmpType << os->nBits); + os->nBits += 8; + + // Flush completed bytes + while(os->nBits >= 8) + { + if(os->dwOutSize != 0) + { + *os->pbOutPos++ = (unsigned char)os->dwBitBuff; + os->dwOutSize--; + } + + os->dwBitBuff >>= 8; + os->nBits -= 8; + } + + for(; nInLength != 0; nInLength--) + { + unsigned char bOneByte = *pbInBuffer++; + + if((pItem1 = items306C[bOneByte]) == NULL) + { + pItem2 = items306C[0x101]; // ecx + pItem3 = pItem2->parent; // eax + dwBitBuff = 0; + nBits = 0; + + for(; pItem3 != NULL; pItem3 = pItem3->parent) + { + nBit = (pItem3->child != pItem2) ? 1 : 0; + dwBitBuff = (dwBitBuff << 1) | nBit; + nBits++; + pItem2 = pItem3; + } + os->PutBits(dwBitBuff, nBits); + + // Store the loaded byte into output stream + os->dwBitBuff |= (bOneByte << os->nBits); + os->nBits += 8; + + // Flush the whole byte(s) + while(os->nBits >= 8) + { + if(os->dwOutSize != 0) + { + *os->pbOutPos++ = (unsigned char)os->dwBitBuff; + os->dwOutSize--; + } + os->dwBitBuff >>= 8; + os->nBits -= 8; + } + + pItem1 = (PTR_INVALID_OR_NULL(pLast)) ? NULL : pLast; + pItem2 = Call1500E740(1); + pItem2->dcmpByte = pItem1->dcmpByte; + pItem2->byteValue = pItem1->byteValue; + pItem2->parent = pItem1; + items306C[pItem2->dcmpByte] = pItem2; + + pItem2 = Call1500E740(1); + pItem2->dcmpByte = bOneByte; + pItem2->byteValue = 0; + pItem2->parent = pItem1; + items306C[pItem2->dcmpByte] = pItem2; + pItem1->child = pItem2; + + Call1500E820(pItem2); + + if(bIsCmp0 != 0) + { + Call1500E820(items306C[bOneByte]); + continue; + } + + for(pItem1 = items306C[bOneByte]; pItem1 != NULL; pItem1 = pItem1->parent) + { + pItem1->byteValue++; + pItem2 = pItem1; + + for(;;) + { + pItem3 = pItem2->prev; + if(PTR_INVALID_OR_NULL(pItem3)) + { + pItem3 = NULL; + break; + } + if(pItem3->byteValue >= pItem1->byteValue) + break; + pItem2 = pItem3; + } + + if(pItem2 != pItem1) + { + InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); + InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); + + pItem3 = pItem2->parent->child; + if(pItem1->parent->child == pItem1) + pItem1->parent->child = pItem2; + + if(pItem3 == pItem2) + pItem2->parent->child = pItem1; + + pTemp = pItem1->parent; + pItem1->parent = pItem2->parent; + pItem2->parent = pTemp; + offs0004++; + } + } + } +// 1500EB62 + else + { + dwBitBuff = 0; + nBits = 0; + for(pItem2 = pItem1->parent; pItem2 != NULL; pItem2 = pItem2->parent) + { + nBit = (pItem2->child != pItem1) ? 1 : 0; + dwBitBuff = (dwBitBuff << 1) | nBit; + nBits++; + pItem1 = pItem2; + } + os->PutBits(dwBitBuff, nBits); + } + +// 1500EB98 + if(bIsCmp0 != 0) + Call1500E820(items306C[bOneByte]); // 1500EB9D +// 1500EBAF + } // for(; nInLength != 0; nInLength--) + +// 1500EBB8 + pItem1 = items306C[0x100]; + dwBitBuff = 0; + nBits = 0; + for(pItem2 = pItem1->parent; pItem2 != NULL; pItem2 = pItem2->parent) + { + nBit = (pItem2->child != pItem1) ? 1 : 0; + dwBitBuff = (dwBitBuff << 1) | nBit; + nBits++; + pItem1 = pItem2; + } + +// 1500EBE6 + os->PutBits(dwBitBuff, nBits); + +// 1500EBEF + // Flush the remaining bits + while(os->nBits != 0) + { + if(os->dwOutSize != 0) + { + *os->pbOutPos++ = (unsigned char)os->dwBitBuff; + os->dwOutSize--; + } + os->dwBitBuff >>= 8; + os->nBits -= ((os->nBits > 8) ? 8 : os->nBits); + } + + return (unsigned int)(os->pbOutPos - os->pbOutBuffer); +} + +// Decompression using Huffman tree (1500E450) +unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is) +{ + TQDecompress * qd; + THTreeItem * pItem1; + THTreeItem * pItem2; + unsigned char * pbOutPos = pbOutBuffer; + unsigned long nBitCount; + unsigned int nDcmpByte = 0; + unsigned int n8Bits; // 8 bits loaded from input stream + unsigned int n7Bits; // 7 bits loaded from input stream + bool bHasQdEntry; + + // Test the output length. Must not be NULL. + if(dwOutLength == 0) + return 0; + + // Get the compression type from the input stream + n8Bits = is->Get8Bits(); + + // Build the Huffman tree + BuildTree(n8Bits); + bIsCmp0 = (n8Bits == 0) ? 1 : 0; + + for(;;) + { + n7Bits = is->Get7Bits(); // Get 7 bits from input stream + + // Try to use quick decompression. Check TQDecompress array for corresponding item. + // If found, ise the result byte instead. + qd = &qd3474[n7Bits]; + + // If there is a quick-pass possible (ebx) + bHasQdEntry = (qd->offs00 >= offs0004) ? true : false; + + // If we can use quick decompress, use it. + if(bHasQdEntry) + { + if(qd->nBits > 7) + { + is->dwBitBuff >>= 7; + is->nBits -= 7; + pItem1 = qd->pItem; + goto _1500E549; + } + is->dwBitBuff >>= qd->nBits; + is->nBits -= qd->nBits; + nDcmpByte = qd->dcmpByte; + } + else + { + pItem1 = pFirst->next->prev; + if(PTR_INVALID_OR_NULL(pItem1)) + pItem1 = NULL; +_1500E549: + nBitCount = 0; + pItem2 = NULL; + + do + { + pItem1 = pItem1->child; // Move down by one level + if(is->GetBit()) // If current bit is set, move to previous + pItem1 = pItem1->prev; + + if(++nBitCount == 7) // If we are at 7th bit, save current HTree item. + pItem2 = pItem1; + } + while(pItem1->child != NULL); // Walk until tree has no deeper level + + if(bHasQdEntry == false) + { + if(nBitCount > 7) + { + qd->offs00 = offs0004; + qd->nBits = nBitCount; + qd->pItem = pItem2; + } + else + { + unsigned long nIndex = n7Bits & (0xFFFFFFFF >> (32 - nBitCount)); + unsigned long nAdd = (1 << nBitCount); + + for(qd = &qd3474[nIndex]; nIndex <= 0x7F; nIndex += nAdd, qd += nAdd) + { + qd->offs00 = offs0004; + qd->nBits = nBitCount; + qd->dcmpByte = pItem1->dcmpByte; + } + } + } + nDcmpByte = pItem1->dcmpByte; + } + + if(nDcmpByte == 0x101) // Huffman tree needs to be modified + { + n8Bits = is->Get8Bits(); + pItem1 = (PTR_INVALID_OR_NULL(pLast)) ? NULL : pLast; + + pItem2 = Call1500E740(1); + pItem2->parent = pItem1; + pItem2->dcmpByte = pItem1->dcmpByte; + pItem2->byteValue = pItem1->byteValue; + items306C[pItem2->dcmpByte] = pItem2; + + pItem2 = Call1500E740(1); + pItem2->parent = pItem1; + pItem2->dcmpByte = n8Bits; + pItem2->byteValue = 0; + items306C[pItem2->dcmpByte] = pItem2; + + pItem1->child = pItem2; + Call1500E820(pItem2); + if(bIsCmp0 == 0) + Call1500E820(items306C[n8Bits]); + + nDcmpByte = n8Bits; + } + + if(nDcmpByte == 0x100) + break; + + *pbOutPos++ = (unsigned char)nDcmpByte; + if(--dwOutLength == 0) + break; + + if(bIsCmp0) + Call1500E820(items306C[nDcmpByte]); + } + + return (unsigned int)(pbOutPos - pbOutBuffer); +} + +/* OLD VERSION +unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is) +{ + THTreeItem * pItem1; // Current item if walking HTree + unsigned long bitCount; // Bit counter if walking HTree + unsigned long oneByte; // 8 bits from bit stream/Pointer to target + unsigned char * outPtr; // Current pointer to output buffer + bool hasQDEntry; // true if entry for quick decompression if filled + THTreeItem * itemAt7 = NULL; // HTree item found at 7th bit + THTreeItem * temp; // For every use + unsigned long dcmpByte = 0; // Decompressed byte value + bool bFlag = 0; + + // Test the output length. Must not be NULL. + if(dwOutLength == 0) + return 0; + + // If too few bits in input bit buffer, we have to load next 16 bits + is->EnsureHasMoreThan8Bits(); + + // Get 8 bits from input stream + oneByte = is->Get8Bits(); + + // Build the Huffman tree + BuildTree(oneByte); + + bIsCmp0 = (oneByte == 0) ? 1 : 0; + outPtr = pbOutBuffer; // Copy pointer to output data + + for(;;) + { + TQDecompress * qd; // For quick decompress + unsigned long sevenBits = is->Get7Bits();// 7 bits from input stream + + // Try to use quick decompression. Check TQDecompress array for corresponding item. + // If found, ise the result byte instead. + qd = &qd3474[sevenBits]; + + // If there is a quick-pass possible + hasQDEntry = (qd->offs00 == offs0004) ? 1 : 0; + + // Start passing the Huffman tree. Set item to tree root item + pItem1 = pFirst; + + // If we can use quick decompress, use it. + bFlag = 1; + if(hasQDEntry == 1) + { + // Check the bit count is greater than 7, move item to 7 levels deeper + if((bitCount = qd->bitCount) > 7) + { + is->dwBitBuff >>= 7; + is->nBits -= 7; + pItem1 = qd->item; // Don't start with root item, but with some deeper-laying + } + else + { + // If OK, use their byte value + is->dwBitBuff >>= bitCount; + is->nBits -= bitCount; + dcmpByte = qd->dcmpByte; + bFlag = 0; + } + } + else + { + pItem1 = pFirst->next->prev; + if(PTR_INT(pItem1) <= 0) + pItem1 = NULL; + } + + if(bFlag == 1) + { + // Walk through Huffman Tree + bitCount = 0; // Clear bit counter + do + { + pItem1 = pItem1->child; + if(is->GetBit() != 0) // If current bit is set, move to previous + pItem1 = pItem1->prev; // item in current level + + if(++bitCount == 7) // If we are at 7th bit, store current HTree item. + itemAt7 = pItem1; // Store Huffman tree item + } + while(pItem1->child != NULL); // Walk until tree has no deeper level + + // If quick decompress entry is not filled yet, fill it. + if(hasQDEntry == 0) + { + if(bitCount > 7) // If we passed more than 7 bits, store bitCount and item + { + qd->offs00 = offs0004; // Value indicates that entry is resolved + qd->bitCount = bitCount; // Number of bits passed + qd->item = itemAt7; // Store item at 7th bit + } + // If we passed less than 7 bits, fill entry and bit count multipliers + else + { + unsigned long index = sevenBits & (0xFFFFFFFF >> (32 - bitCount)); // Index for quick-decompress entry + unsigned long addIndex = (1 << bitCount); // Add value for index + + qd = &qd3474[index]; + + do + { + qd->offs00 = offs0004; + qd->bitCount = bitCount; + qd->dcmpByte = pItem1->dcmpByte; + + index += addIndex; + qd += addIndex; + } + while(index <= 0x7F); + } + } + dcmpByte = pItem1->dcmpByte; + } + + if(dcmpByte == 0x101) // Huffman tree needs to be modified + { + // Check if there is enough bits in the buffer + is->EnsureHasMoreThan8Bits(); + + // Get 8 bits from the buffer + oneByte = is->Get8Bits(); + + // Modify Huffman tree + ModifyTree(oneByte); + + // Get lastly added tree item + pItem1 = items306C[oneByte]; + + if(bIsCmp0 == 0 && pItem1 != NULL) + { + // 15006F15 + do + { + THTreeItem * pItem2 = pItem1; + THTreeItem * pItem3; + unsigned long byteValue; + + byteValue = ++pItem1->byteValue; + + while(PTR_INT((pItem3 = pItem2->prev)) > 0) + { + if(pItem3->byteValue >= byteValue) + goto _15006F30; + + pItem2 = pItem2->prev; + } + pItem3 = NULL; + + _15006F30: + if(pItem2 == pItem1) + continue; + + InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); + InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); + + temp = pItem2->parent->child; + if(pItem1 == pItem1->parent->child) + pItem1->parent->child = pItem2; + + if(pItem2 == temp) + pItem2->parent->child = pItem1; + + // Switch parents of pItem1 and pItem3 + temp = pItem1->parent; + pItem1->parent = pItem2->parent; + pItem2->parent = temp; + offs0004++; + } + while(PTR_INT((pItem1 = pItem1->parent)) > 0); + } + dcmpByte = oneByte; + } + + if(dcmpByte != 0x100) // Not at the end of data ? + { + *outPtr++ = (unsigned char)dcmpByte; + if(--dwOutLength > 0) + { + if(bIsCmp0 != 0) + Call1500E820(items306C[pItem1->byteValue]); + } + else + break; + } + else + break; + } + return (unsigned long)(outPtr - pbOutBuffer); +} +*/ + +// Table for (de)compression. Every compression type has 258 entries +unsigned char THuffmannTree::Table1502A630[] = +{ + // Data for compression type 0x00 + 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x00, + + // Data for compression type 0x01 + 0x54, 0x16, 0x16, 0x0D, 0x0C, 0x08, 0x06, 0x05, 0x06, 0x05, 0x06, 0x03, 0x04, 0x04, 0x03, 0x05, + 0x0E, 0x0B, 0x14, 0x13, 0x13, 0x09, 0x0B, 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, + 0x0D, 0x07, 0x09, 0x06, 0x06, 0x04, 0x03, 0x02, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, + 0x09, 0x06, 0x04, 0x04, 0x04, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x04, + 0x08, 0x03, 0x04, 0x07, 0x09, 0x05, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, + 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, + 0x06, 0x0A, 0x08, 0x08, 0x06, 0x07, 0x04, 0x03, 0x04, 0x04, 0x02, 0x02, 0x04, 0x02, 0x03, 0x03, + 0x04, 0x03, 0x07, 0x07, 0x09, 0x06, 0x04, 0x03, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x0A, 0x02, 0x02, 0x03, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x03, 0x05, 0x02, 0x03, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x03, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x09, 0x08, 0x0C, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x03, + 0x04, 0x01, 0x02, 0x04, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x4B, + 0x00, 0x00, + + // Data for compression type 0x02 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x27, 0x00, 0x00, 0x23, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x06, 0x0E, 0x10, 0x04, + 0x06, 0x08, 0x05, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x01, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x04, 0x02, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x04, 0x01, 0x01, 0x02, 0x03, 0x03, 0x02, + 0x03, 0x01, 0x03, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x29, 0x07, 0x16, 0x12, 0x40, 0x0A, 0x0A, 0x11, 0x25, 0x01, 0x03, 0x17, 0x10, 0x26, 0x2A, + 0x10, 0x01, 0x23, 0x23, 0x2F, 0x10, 0x06, 0x07, 0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x03 + 0xFF, 0x0B, 0x07, 0x05, 0x0B, 0x02, 0x02, 0x02, 0x06, 0x02, 0x02, 0x01, 0x04, 0x02, 0x01, 0x03, + 0x09, 0x01, 0x01, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x05, 0x01, 0x01, 0x01, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x0A, 0x04, 0x02, 0x01, 0x06, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, + 0x05, 0x02, 0x03, 0x04, 0x03, 0x03, 0x03, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x03, 0x03, + 0x01, 0x03, 0x01, 0x01, 0x02, 0x05, 0x01, 0x01, 0x04, 0x03, 0x05, 0x01, 0x03, 0x01, 0x03, 0x03, + 0x02, 0x01, 0x04, 0x03, 0x0A, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x0A, 0x02, 0x05, 0x01, 0x01, 0x02, 0x07, 0x02, 0x17, 0x01, 0x05, 0x01, 0x01, + 0x0E, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x06, 0x02, 0x01, 0x04, 0x05, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, + 0x00, 0x00, + + // Data for compression type 0x04 + 0xFF, 0xFB, 0x98, 0x9A, 0x84, 0x85, 0x63, 0x64, 0x3E, 0x3E, 0x22, 0x22, 0x13, 0x13, 0x18, 0x17, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x05 + 0xFF, 0xF1, 0x9D, 0x9E, 0x9A, 0x9B, 0x9A, 0x97, 0x93, 0x93, 0x8C, 0x8E, 0x86, 0x88, 0x80, 0x82, + 0x7C, 0x7C, 0x72, 0x73, 0x69, 0x6B, 0x5F, 0x60, 0x55, 0x56, 0x4A, 0x4B, 0x40, 0x41, 0x37, 0x37, + 0x2F, 0x2F, 0x27, 0x27, 0x21, 0x21, 0x1B, 0x1C, 0x17, 0x17, 0x13, 0x13, 0x10, 0x10, 0x0D, 0x0D, + 0x0B, 0x0B, 0x09, 0x09, 0x08, 0x08, 0x07, 0x07, 0x06, 0x05, 0x05, 0x04, 0x04, 0x04, 0x19, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x06 + 0xC3, 0xCB, 0xF5, 0x41, 0xFF, 0x7B, 0xF7, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xBF, 0xCC, 0xF2, 0x40, 0xFD, 0x7C, 0xF7, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7A, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x07 + 0xC3, 0xD9, 0xEF, 0x3D, 0xF9, 0x7C, 0xE9, 0x1E, 0xFD, 0xAB, 0xF1, 0x2C, 0xFC, 0x5B, 0xFE, 0x17, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xBD, 0xD9, 0xEC, 0x3D, 0xF5, 0x7D, 0xE8, 0x1D, 0xFB, 0xAE, 0xF0, 0x2C, 0xFB, 0x5C, 0xFF, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x70, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x08 + 0xBA, 0xC5, 0xDA, 0x33, 0xE3, 0x6D, 0xD8, 0x18, 0xE5, 0x94, 0xDA, 0x23, 0xDF, 0x4A, 0xD1, 0x10, + 0xEE, 0xAF, 0xE4, 0x2C, 0xEA, 0x5A, 0xDE, 0x15, 0xF4, 0x87, 0xE9, 0x21, 0xF6, 0x43, 0xFC, 0x12, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xB0, 0xC7, 0xD8, 0x33, 0xE3, 0x6B, 0xD6, 0x18, 0xE7, 0x95, 0xD8, 0x23, 0xDB, 0x49, 0xD0, 0x11, + 0xE9, 0xB2, 0xE2, 0x2B, 0xE8, 0x5C, 0xDD, 0x15, 0xF1, 0x87, 0xE7, 0x20, 0xF7, 0x44, 0xFF, 0x13, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x5F, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00 }; \ No newline at end of file diff --git a/src/tools/stuffextract/StormLib/huffman/huff.h b/src/tools/stuffextract/StormLib/huffman/huff.h index fcad7c8..f06aa77 100644 --- a/src/tools/stuffextract/StormLib/huffman/huff.h +++ b/src/tools/stuffextract/StormLib/huffman/huff.h @@ -1,142 +1,142 @@ -/*****************************************************************************/ -/* huffman.h Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Description : */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.xx 1.00 Lad The first version of huffman.h */ -/* 03.05.03 2.00 Lad Added compression */ -/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ -/*****************************************************************************/ - -#ifndef __HUFFMAN_H__ -#define __HUFFMAN_H__ - -#include "../StormPort.h" - -//----------------------------------------------------------------------------- -// Defines - -#define INSERT_ITEM 1 -#define SWITCH_ITEMS 2 // Switch the item1 and item2 - -#define PTR_NOT(ptr) (THTreeItem *)(~(DWORD_PTR)(ptr)) -#define PTR_PTR(ptr) ((THTreeItem *)(ptr)) -#define PTR_INT(ptr) (LONG_PTR)(ptr) - -#ifndef NULL -#define NULL 0 -#endif - -//----------------------------------------------------------------------------- -// Structures and classes - -// Input stream for Huffmann decompression -class TInputStream -{ - public: - - unsigned long GetBit(); - unsigned long Get7Bits(); - unsigned long Get8Bits(); - - unsigned char * pbInBuffer; // 00 - Input data - unsigned long dwBitBuff; // 04 - Input bit buffer - unsigned int nBits; // 08 - Number of bits remaining in 'dwValue' -}; - -// Output stream for Huffmann compression -class TOutputStream -{ - public: - - void PutBits(unsigned long dwBuff, unsigned int nPutBits); - - unsigned char * pbOutBuffer; // 00 : Output buffer - unsigned long dwOutSize; // 04 : Size of output buffer - unsigned char * pbOutPos; // 08 : Current output position - unsigned long dwBitBuff; // 0C : Bit buffer - unsigned long nBits; // 10 : Number of bits in the bit buffer -}; - -// Huffmann tree item (?) -struct THTreeItem -{ - public: - - THTreeItem * Call1501DB70(THTreeItem * pLast); - THTreeItem * GetPrevItem(LONG_PTR value); - void ClearItemLinks(); - void RemoveItem(); - - THTreeItem * next; // 00 - Pointer to next THTreeItem - THTreeItem * prev; // 04 - Pointer to prev THTreeItem (< 0 if none) - unsigned long dcmpByte; // 08 - Index of this item in item pointer array, decompressed byte value - unsigned long byteValue; // 0C - Some byte value - THTreeItem * parent; // 10 - Pointer to parent THTreeItem (NULL if none) - THTreeItem * child; // 14 - Pointer to child THTreeItem - int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive -}; - -// Structure used for quick decompress. The 'bitCount' contains number of bits -// and byte value contains result decompressed byte value. -// After each walk through Huffman tree are filled all entries which are -// multiplies of number of bits loaded from input stream. These entries -// contain number of bits and result value. At the next 7 bits is tested this -// structure first. If corresponding entry found, decompression routine will -// not walk through Huffman tree and directly stores output byte to output stream. -struct TQDecompress -{ - unsigned long offs00; // 00 - 1 if resolved - unsigned long nBits; // 04 - Bit count - union - { - unsigned long dcmpByte; // 08 - Byte value for decompress (if bitCount <= 7) - THTreeItem * pItem; // 08 - THTreeItem (if number of bits is greater than 7 - }; -}; - -// Structure for Huffman tree (Size 0x3674 bytes). Because I'm not expert -// for the decompression, I do not know actually if the class is really a Hufmann -// tree. If someone knows the decompression details, please let me know -class THuffmannTree -{ - public: - - THuffmannTree(); - void InitTree(bool bCompression); - void BuildTree(unsigned int nCmpType); -// void ModifyTree(unsigned long dwIndex); -// void UninitTree(); - -// void Call15007010(Bit32 dwInLength, THTreeItem * item); - THTreeItem * Call1500E740(unsigned int nValue); - void Call1500E820(THTreeItem * pItem); - unsigned int DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType); - unsigned int DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is); - - unsigned long bIsCmp0; // 0000 - 1 if compression type 0 - unsigned long offs0004; // 0004 - Some flag - THTreeItem items0008[0x203]; // 0008 - HTree items - - //- Sometimes used as HTree item ----------- - THTreeItem * pItem3050; // 3050 - Always NULL (?) - THTreeItem * pItem3054; // 3054 - Pointer to Huffman tree item - THTreeItem * pItem3058; // 3058 - Pointer to Huffman tree item (< 0 if invalid) - - //- Sometimes used as HTree item ----------- - THTreeItem * pItem305C; // 305C - Usually NULL - THTreeItem * pFirst; // 3060 - Pointer to top (first) Huffman tree item - THTreeItem * pLast; // 3064 - Pointer to bottom (last) Huffman tree item (< 0 if invalid) - unsigned long nItems; // 3068 - Number of used HTree items - - //------------------------------------------- - THTreeItem * items306C[0x102]; // 306C - THTreeItem pointer array - TQDecompress qd3474[0x80]; // 3474 - Array for quick decompression - int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive - - static unsigned char Table1502A630[];// Some table -}; - -#endif // __HUFFMAN_H__ +/*****************************************************************************/ +/* huffman.h Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* Description : */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* xx.xx.xx 1.00 Lad The first version of huffman.h */ +/* 03.05.03 2.00 Lad Added compression */ +/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ +/*****************************************************************************/ + +#ifndef __HUFFMAN_H__ +#define __HUFFMAN_H__ + +#include "../StormPort.h" + +//----------------------------------------------------------------------------- +// Defines + +#define INSERT_ITEM 1 +#define SWITCH_ITEMS 2 // Switch the item1 and item2 + +#define PTR_NOT(ptr) (THTreeItem *)(~(DWORD_PTR)(ptr)) +#define PTR_PTR(ptr) ((THTreeItem *)(ptr)) +#define PTR_INT(ptr) (LONG_PTR)(ptr) + +#ifndef NULL +#define NULL 0 +#endif + +//----------------------------------------------------------------------------- +// Structures and classes + +// Input stream for Huffmann decompression +class TInputStream +{ + public: + + unsigned long GetBit(); + unsigned long Get7Bits(); + unsigned long Get8Bits(); + + unsigned char * pbInBuffer; // 00 - Input data + unsigned long dwBitBuff; // 04 - Input bit buffer + unsigned int nBits; // 08 - Number of bits remaining in 'dwValue' +}; + +// Output stream for Huffmann compression +class TOutputStream +{ + public: + + void PutBits(unsigned long dwBuff, unsigned int nPutBits); + + unsigned char * pbOutBuffer; // 00 : Output buffer + unsigned long dwOutSize; // 04 : Size of output buffer + unsigned char * pbOutPos; // 08 : Current output position + unsigned long dwBitBuff; // 0C : Bit buffer + unsigned long nBits; // 10 : Number of bits in the bit buffer +}; + +// Huffmann tree item (?) +struct THTreeItem +{ + public: + + THTreeItem * Call1501DB70(THTreeItem * pLast); + THTreeItem * GetPrevItem(LONG_PTR value); + void ClearItemLinks(); + void RemoveItem(); + + THTreeItem * next; // 00 - Pointer to next THTreeItem + THTreeItem * prev; // 04 - Pointer to prev THTreeItem (< 0 if none) + unsigned long dcmpByte; // 08 - Index of this item in item pointer array, decompressed byte value + unsigned long byteValue; // 0C - Some byte value + THTreeItem * parent; // 10 - Pointer to parent THTreeItem (NULL if none) + THTreeItem * child; // 14 - Pointer to child THTreeItem + int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive +}; + +// Structure used for quick decompress. The 'bitCount' contains number of bits +// and byte value contains result decompressed byte value. +// After each walk through Huffman tree are filled all entries which are +// multiplies of number of bits loaded from input stream. These entries +// contain number of bits and result value. At the next 7 bits is tested this +// structure first. If corresponding entry found, decompression routine will +// not walk through Huffman tree and directly stores output byte to output stream. +struct TQDecompress +{ + unsigned long offs00; // 00 - 1 if resolved + unsigned long nBits; // 04 - Bit count + union + { + unsigned long dcmpByte; // 08 - Byte value for decompress (if bitCount <= 7) + THTreeItem * pItem; // 08 - THTreeItem (if number of bits is greater than 7 + }; +}; + +// Structure for Huffman tree (Size 0x3674 bytes). Because I'm not expert +// for the decompression, I do not know actually if the class is really a Hufmann +// tree. If someone knows the decompression details, please let me know +class THuffmannTree +{ + public: + + THuffmannTree(); + void InitTree(bool bCompression); + void BuildTree(unsigned int nCmpType); +// void ModifyTree(unsigned long dwIndex); +// void UninitTree(); + +// void Call15007010(Bit32 dwInLength, THTreeItem * item); + THTreeItem * Call1500E740(unsigned int nValue); + void Call1500E820(THTreeItem * pItem); + unsigned int DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType); + unsigned int DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is); + + unsigned long bIsCmp0; // 0000 - 1 if compression type 0 + unsigned long offs0004; // 0004 - Some flag + THTreeItem items0008[0x203]; // 0008 - HTree items + + //- Sometimes used as HTree item ----------- + THTreeItem * pItem3050; // 3050 - Always NULL (?) + THTreeItem * pItem3054; // 3054 - Pointer to Huffman tree item + THTreeItem * pItem3058; // 3058 - Pointer to Huffman tree item (< 0 if invalid) + + //- Sometimes used as HTree item ----------- + THTreeItem * pItem305C; // 305C - Usually NULL + THTreeItem * pFirst; // 3060 - Pointer to top (first) Huffman tree item + THTreeItem * pLast; // 3064 - Pointer to bottom (last) Huffman tree item (< 0 if invalid) + unsigned long nItems; // 3068 - Number of used HTree items + + //------------------------------------------- + THTreeItem * items306C[0x102]; // 306C - THTreeItem pointer array + TQDecompress qd3474[0x80]; // 3474 - Array for quick decompression + int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive + + static unsigned char Table1502A630[];// Some table +}; + +#endif // __HUFFMAN_H__ diff --git a/src/tools/stuffextract/StormLib/pklib/crc32_pk.c b/src/tools/stuffextract/StormLib/pklib/crc32_pk.c index a155513..a7f5210 100644 --- a/src/tools/stuffextract/StormLib/pklib/crc32_pk.c +++ b/src/tools/stuffextract/StormLib/pklib/crc32_pk.c @@ -1,72 +1,72 @@ -/*****************************************************************************/ -/* crc32.c Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Pkware Data Compression Library Version 1.11 */ -/* Dissassembled method crc32 - cdecl version */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 09.04.03 1.00 Lad The first version of crc32.c */ -/* 02.05.03 1.00 Lad Stress test done */ -/*****************************************************************************/ - -#include "pklib.h" - -static char CopyRight[] = "PKWARE Data Compression Library for Win32\r\n" - "Copyright 1989-1995 PKWARE Inc. All Rights Reserved\r\n" - "Patent No. 5,051,745\r\n" - "PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.\r\n" - "Version 1.11\r\n"; - -static unsigned long crc_table[] = -{ - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D -}; - - -unsigned long PKEXPORT crc32pk(char * buffer, unsigned int * psize, unsigned long * old_crc) -{ - unsigned int size = *psize; - unsigned long ch; - unsigned long crc_value = *old_crc; - - while(size-- != 0) - { - ch = *buffer++ ^ (char)crc_value; - crc_value >>= 8; - - crc_value = crc_table[ch & 0x0FF] ^ crc_value; - } - return crc_value; -} +/*****************************************************************************/ +/* crc32.c Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* Pkware Data Compression Library Version 1.11 */ +/* Dissassembled method crc32 - cdecl version */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 09.04.03 1.00 Lad The first version of crc32.c */ +/* 02.05.03 1.00 Lad Stress test done */ +/*****************************************************************************/ + +#include "pklib.h" + +static char CopyRight[] = "PKWARE Data Compression Library for Win32\r\n" + "Copyright 1989-1995 PKWARE Inc. All Rights Reserved\r\n" + "Patent No. 5,051,745\r\n" + "PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.\r\n" + "Version 1.11\r\n"; + +static unsigned long crc_table[] = +{ + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, + 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, + 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, + 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, + 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, + 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, + 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, + 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, + 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, + 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, + 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, + 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, + 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, + 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, + 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D +}; + + +unsigned long PKEXPORT crc32pk(char * buffer, unsigned int * psize, unsigned long * old_crc) +{ + unsigned int size = *psize; + unsigned long ch; + unsigned long crc_value = *old_crc; + + while(size-- != 0) + { + ch = *buffer++ ^ (char)crc_value; + crc_value >>= 8; + + crc_value = crc_table[ch & 0x0FF] ^ crc_value; + } + return crc_value; +} diff --git a/src/tools/stuffextract/StormLib/pklib/explode.c b/src/tools/stuffextract/StormLib/pklib/explode.c index b0a3aeb..a5b41e3 100644 --- a/src/tools/stuffextract/StormLib/pklib/explode.c +++ b/src/tools/stuffextract/StormLib/pklib/explode.c @@ -1,480 +1,480 @@ -/*****************************************************************************/ -/* explode.c Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Implode function of PKWARE Data Compression library */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 11.03.03 1.00 Lad Splitted from Pkware.cpp */ -/* 08.04.03 1.01 Lad Renamed to explode.c to be compatible with pklib */ -/* 02.05.03 1.01 Lad Stress test done */ -/*****************************************************************************/ - -#include -#include - -#include "pklib.h" - -//----------------------------------------------------------------------------- -// Tables - -static unsigned char DistBits[] = -{ - 0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 -}; - -static unsigned char DistCode[] = -{ - 0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A, - 0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C, - 0x74, 0x34, 0x54, 0x14, 0x64, 0x24, 0x44, 0x04, 0x78, 0x38, 0x58, 0x18, 0x68, 0x28, 0x48, 0x08, - 0xF0, 0x70, 0xB0, 0x30, 0xD0, 0x50, 0x90, 0x10, 0xE0, 0x60, 0xA0, 0x20, 0xC0, 0x40, 0x80, 0x00 -}; - -static unsigned char ExLenBits[] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 -}; - -static unsigned short LenBase[] = -{ - 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, - 0x0008, 0x000A, 0x000E, 0x0016, 0x0026, 0x0046, 0x0086, 0x0106 -}; - -static unsigned char LenBits[] = -{ - 0x03, 0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x07, 0x07 -}; - -static unsigned char LenCode[] = -{ - 0x05, 0x03, 0x01, 0x06, 0x0A, 0x02, 0x0C, 0x14, 0x04, 0x18, 0x08, 0x30, 0x10, 0x20, 0x40, 0x00 -}; - -static unsigned char ChBitsAsc[] = -{ - 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x08, 0x07, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x04, 0x0A, 0x08, 0x0C, 0x0A, 0x0C, 0x0A, 0x08, 0x07, 0x07, 0x08, 0x09, 0x07, 0x06, 0x07, 0x08, - 0x07, 0x06, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x08, 0x08, 0x0C, 0x0B, 0x07, 0x09, 0x0B, - 0x0C, 0x06, 0x07, 0x06, 0x06, 0x05, 0x07, 0x08, 0x08, 0x06, 0x0B, 0x09, 0x06, 0x07, 0x06, 0x06, - 0x07, 0x0B, 0x06, 0x06, 0x06, 0x07, 0x09, 0x08, 0x09, 0x09, 0x0B, 0x08, 0x0B, 0x09, 0x0C, 0x08, - 0x0C, 0x05, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x05, 0x0B, 0x07, 0x05, 0x06, 0x05, 0x05, - 0x06, 0x0A, 0x05, 0x05, 0x05, 0x05, 0x08, 0x07, 0x08, 0x08, 0x0A, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, - 0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D -}; - -static unsigned short ChCodeAsc[] = -{ - 0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0, - 0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0, - 0x0CE0, 0x04E0, 0x08E0, 0x00E0, 0x0F60, 0x0760, 0x0B60, 0x0360, - 0x0D60, 0x0560, 0x1240, 0x0960, 0x0160, 0x0E60, 0x0660, 0x0A60, - 0x000F, 0x0250, 0x0038, 0x0260, 0x0050, 0x0C60, 0x0390, 0x00D8, - 0x0042, 0x0002, 0x0058, 0x01B0, 0x007C, 0x0029, 0x003C, 0x0098, - 0x005C, 0x0009, 0x001C, 0x006C, 0x002C, 0x004C, 0x0018, 0x000C, - 0x0074, 0x00E8, 0x0068, 0x0460, 0x0090, 0x0034, 0x00B0, 0x0710, - 0x0860, 0x0031, 0x0054, 0x0011, 0x0021, 0x0017, 0x0014, 0x00A8, - 0x0028, 0x0001, 0x0310, 0x0130, 0x003E, 0x0064, 0x001E, 0x002E, - 0x0024, 0x0510, 0x000E, 0x0036, 0x0016, 0x0044, 0x0030, 0x00C8, - 0x01D0, 0x00D0, 0x0110, 0x0048, 0x0610, 0x0150, 0x0060, 0x0088, - 0x0FA0, 0x0007, 0x0026, 0x0006, 0x003A, 0x001B, 0x001A, 0x002A, - 0x000A, 0x000B, 0x0210, 0x0004, 0x0013, 0x0032, 0x0003, 0x001D, - 0x0012, 0x0190, 0x000D, 0x0015, 0x0005, 0x0019, 0x0008, 0x0078, - 0x00F0, 0x0070, 0x0290, 0x0410, 0x0010, 0x07A0, 0x0BA0, 0x03A0, - 0x0240, 0x1C40, 0x0C40, 0x1440, 0x0440, 0x1840, 0x0840, 0x1040, - 0x0040, 0x1F80, 0x0F80, 0x1780, 0x0780, 0x1B80, 0x0B80, 0x1380, - 0x0380, 0x1D80, 0x0D80, 0x1580, 0x0580, 0x1980, 0x0980, 0x1180, - 0x0180, 0x1E80, 0x0E80, 0x1680, 0x0680, 0x1A80, 0x0A80, 0x1280, - 0x0280, 0x1C80, 0x0C80, 0x1480, 0x0480, 0x1880, 0x0880, 0x1080, - 0x0080, 0x1F00, 0x0F00, 0x1700, 0x0700, 0x1B00, 0x0B00, 0x1300, - 0x0DA0, 0x05A0, 0x09A0, 0x01A0, 0x0EA0, 0x06A0, 0x0AA0, 0x02A0, - 0x0CA0, 0x04A0, 0x08A0, 0x00A0, 0x0F20, 0x0720, 0x0B20, 0x0320, - 0x0D20, 0x0520, 0x0920, 0x0120, 0x0E20, 0x0620, 0x0A20, 0x0220, - 0x0C20, 0x0420, 0x0820, 0x0020, 0x0FC0, 0x07C0, 0x0BC0, 0x03C0, - 0x0DC0, 0x05C0, 0x09C0, 0x01C0, 0x0EC0, 0x06C0, 0x0AC0, 0x02C0, - 0x0CC0, 0x04C0, 0x08C0, 0x00C0, 0x0F40, 0x0740, 0x0B40, 0x0340, - 0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900, - 0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600, - 0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200, - 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 -}; - -//----------------------------------------------------------------------------- -// Local variables - -static char Copyright[] = "PKWARE Data Compression Library for Win32\r\n" - "Copyright 1989-1995 PKWARE Inc. All Rights Reserved\r\n" - "Patent No. 5,051,745\r\n" - "PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.\r\n" - "Version 1.11\r\n"; - -//----------------------------------------------------------------------------- -// Local functions - -// Copies a block to another location -static void lmemcpy(void * trg, const void * src, size_t count) -{ - memcpy(trg, src, count); -} - -static void GenDecodeTabs(long count, unsigned char * bits, unsigned char * pCode, unsigned char * buffer2) -{ - long i; - - for(i = count-1; i >= 0; i--) // EBX - count - { - unsigned long idx1 = pCode[i]; - unsigned long idx2 = 1 << bits[i]; - - do - { - buffer2[idx1] = (unsigned char)i; - idx1 += idx2; - } - while(idx1 < 0x100); - } -} - -static void GenAscTabs(TDcmpStruct * pWork) -{ - unsigned short * pChCodeAsc = &ChCodeAsc[0xFF]; - unsigned long acc, add; - unsigned short count; - - for(count = 0x00FF; pChCodeAsc >= ChCodeAsc; pChCodeAsc--, count--) - { - unsigned char * pChBitsAsc = pWork->ChBitsAsc + count; - unsigned char bits_asc = *pChBitsAsc; - - if(bits_asc <= 8) - { - add = (1 << bits_asc); - acc = *pChCodeAsc; - - do - { - pWork->offs2C34[acc] = (unsigned char)count; - acc += add; - } - while(acc < 0x100); - } - else if((acc = (*pChCodeAsc & 0xFF)) != 0) - { - pWork->offs2C34[acc] = 0xFF; - - if(*pChCodeAsc & 0x3F) - { - bits_asc -= 4; - *pChBitsAsc = bits_asc; - - add = (1 << bits_asc); - acc = *pChCodeAsc >> 4; - do - { - pWork->offs2D34[acc] = (unsigned char)count; - acc += add; - } - while(acc < 0x100); - } - else - { - bits_asc -= 6; - *pChBitsAsc = bits_asc; - - add = (1 << bits_asc); - acc = *pChCodeAsc >> 6; - do - { - pWork->offs2E34[acc] = (unsigned char)count; - acc += add; - } - while(acc < 0x80); - } - } - else - { - bits_asc -= 8; - *pChBitsAsc = bits_asc; - - add = (1 << bits_asc); - acc = *pChCodeAsc >> 8; - do - { - pWork->offs2EB4[acc] = (unsigned char)count; - acc += add; - } - while(acc < 0x100); - } - } -} - -//----------------------------------------------------------------------------- -// Skips given number of bits in bit buffer. Result is stored in pWork->bit_buff -// If no data in input buffer, returns true - -static int WasteBits(TDcmpStruct * pWork, unsigned long nBits) -{ - // If number of bits required is less than number of (bits in the buffer) ? - if(nBits <= pWork->extra_bits) - { - pWork->extra_bits -= nBits; - pWork->bit_buff >>= nBits; - return 0; - } - - // Load input buffer if necessary - pWork->bit_buff >>= pWork->extra_bits; - if(pWork->in_pos == pWork->in_bytes) - { - pWork->in_pos = sizeof(pWork->in_buff); - if((pWork->in_bytes = pWork->read_buf((char *)pWork->in_buff, &pWork->in_pos, pWork->param)) == 0) - return 1; - pWork->in_pos = 0; - } - - // Update bit buffer - pWork->bit_buff |= (pWork->in_buff[pWork->in_pos++] << 8); - pWork->bit_buff >>= (nBits - pWork->extra_bits); - pWork->extra_bits = (pWork->extra_bits - nBits) + 8; - return 0; -} - -//----------------------------------------------------------------------------- -// Returns : 0x000 - 0x0FF : One byte from compressed file. -// 0x100 - 0x305 : Copy previous block (0x100 = 1 byte) -// 0x306 : Out of buffer (?) - -static unsigned long DecodeLit(TDcmpStruct * pWork) -{ - unsigned long nBits; // Number of bits to skip - unsigned long value; // Position in buffers - - // Test the current bit in byte buffer. If is not set, simply return the next byte. - if(pWork->bit_buff & 1) - { - // Skip current bit in the buffer - if(WasteBits(pWork, 1)) - return 0x306; - - // The next bits are position in buffers - value = pWork->position2[(pWork->bit_buff & 0xFF)]; - - // Get number of bits to skip - if(WasteBits(pWork, pWork->LenBits[value])) - return 0x306; - - if((nBits = pWork->ExLenBits[value]) != 0) - { - unsigned long val2 = pWork->bit_buff & ((1 << nBits) - 1); - - if(WasteBits(pWork, nBits)) - { - if((value + val2) != 0x10E) - return 0x306; - } - value = pWork->LenBase[value] + val2; - } - return value + 0x100; // Return number of bytes to repeat - } - - // Waste one bit - if(WasteBits(pWork, 1)) - return 0x306; - - // If the binary compression type, read 8 bits and return them as one byte. - if(pWork->ctype == CMP_BINARY) - { - value = pWork->bit_buff & 0xFF; - if(WasteBits(pWork, 8)) - return 0x306; - return value; - } - - // When ASCII compression ... - if(pWork->bit_buff & 0xFF) - { - value = pWork->offs2C34[pWork->bit_buff & 0xFF]; - - if(value == 0xFF) - { - if(pWork->bit_buff & 0x3F) - { - if(WasteBits(pWork, 4)) - return 0x306; - - value = pWork->offs2D34[pWork->bit_buff & 0xFF]; - } - else - { - if(WasteBits(pWork, 6)) - return 0x306; - - value = pWork->offs2E34[pWork->bit_buff & 0x7F]; - } - } - } - else - { - if(WasteBits(pWork, 8)) - return 0x306; - - value = pWork->offs2EB4[pWork->bit_buff & 0xFF]; - } - - return WasteBits(pWork, pWork->ChBitsAsc[value]) ? 0x306 : value; -} - -//----------------------------------------------------------------------------- -// Retrieves the number of bytes to move back - -static unsigned long DecodeDist(TDcmpStruct * pWork, unsigned long dwLength) -{ - unsigned long pos = pWork->position1[(pWork->bit_buff & 0xFF)]; - unsigned long nSkip = pWork->DistBits[pos]; // Number of bits to skip - - // Skip the appropriate number of bits - if(WasteBits(pWork, nSkip) == 1) - return 0; - - if(dwLength == 2) - { - pos = (pos << 2) | (pWork->bit_buff & 0x03); - - if(WasteBits(pWork, 2) == 1) - return 0; - } - else - { - pos = (pos << pWork->dsize_bits) | (pWork->bit_buff & pWork->dsize_mask); - - // Skip the bits - if(WasteBits(pWork, pWork->dsize_bits) == 1) - return 0; - } - return pos+1; -} - -static unsigned long Expand(TDcmpStruct * pWork) -{ - unsigned int copyBytes; // Number of bytes to copy - unsigned long oneByte; // One byte from compressed file - unsigned long dwResult; - - pWork->outputPos = 0x1000; // Initialize output buffer position - - // If end of data or error, terminate decompress - while((dwResult = oneByte = DecodeLit(pWork)) < 0x305) - { - // If one byte is greater than 0x100, means "Repeat n - 0xFE bytes" - if(oneByte >= 0x100) - { - unsigned char * source; // ECX - unsigned char * target; // EDX - unsigned long copyLength = oneByte - 0xFE; - unsigned long moveBack; - - // Get length of data to copy - if((moveBack = DecodeDist(pWork, copyLength)) == 0) - { - dwResult = 0x306; - break; - } - - // Target and source pointer - target = &pWork->out_buff[pWork->outputPos]; - source = target - moveBack; - pWork->outputPos += copyLength; - - while(copyLength-- > 0) - *target++ = *source++; - } - else - pWork->out_buff[pWork->outputPos++] = (unsigned char)oneByte; - - // If number of extracted bytes has reached 1/2 of output buffer, - // flush output buffer. - if(pWork->outputPos >= 0x2000) - { - // Copy decompressed data into user buffer - copyBytes = 0x1000; - pWork->write_buf((char *)&pWork->out_buff[0x1000], ©Bytes, pWork->param); - - // If there are some data left, keep them alive - lmemcpy(pWork->out_buff, &pWork->out_buff[0x1000], pWork->outputPos - 0x1000); - pWork->outputPos -= 0x1000; - } - } - - copyBytes = pWork->outputPos - 0x1000; - pWork->write_buf((char *)&pWork->out_buff[0x1000], ©Bytes, pWork->param); - return dwResult; -} - - -//----------------------------------------------------------------------------- -// Main exploding function. - -unsigned int explode( - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), - void (*write_buf)(char *buf, unsigned int *size, void *param), - char *work_buf, - void *param) -{ - TDcmpStruct * pWork = (TDcmpStruct *)work_buf; - - // Set the whole work buffer to zeros - memset(pWork, 0, sizeof(TDcmpStruct)); - - // Initialize work struct and load compressed data - pWork->read_buf = read_buf; - pWork->write_buf = write_buf; - pWork->param = param; - pWork->in_pos = sizeof(pWork->in_buff); - pWork->in_bytes = pWork->read_buf((char *)pWork->in_buff, &pWork->in_pos, pWork->param); - if(pWork->in_bytes <= 4) - return CMP_BAD_DATA; - - pWork->ctype = pWork->in_buff[0]; // Get the compression type - pWork->dsize_bits = pWork->in_buff[1]; // Get the dictionary size - pWork->bit_buff = pWork->in_buff[2]; // Initialize 16-bit bit buffer - pWork->extra_bits = 0; // Extra (over 8) bits - pWork->in_pos = 3; // Position in input buffer - - // Test for the valid dictionary size - if(4 > pWork->dsize_bits || pWork->dsize_bits > 6) - return CMP_INVALID_DICTSIZE; - - pWork->dsize_mask = 0xFFFF >> (0x10 - pWork->dsize_bits); // Shifted by 'sar' instruction - - if(pWork->ctype != CMP_BINARY) - { - if(pWork->ctype != CMP_ASCII) - return CMP_INVALID_MODE; - - lmemcpy(pWork->ChBitsAsc, ChBitsAsc, sizeof(pWork->ChBitsAsc)); - GenAscTabs(pWork); - } - - lmemcpy(pWork->LenBits, LenBits, sizeof(pWork->LenBits)); - GenDecodeTabs(0x10, pWork->LenBits, LenCode, pWork->position2); - lmemcpy(pWork->ExLenBits, ExLenBits, sizeof(pWork->ExLenBits)); - lmemcpy(pWork->LenBase, LenBase, sizeof(pWork->LenBase)); - lmemcpy(pWork->DistBits, DistBits, sizeof(pWork->DistBits)); - GenDecodeTabs(0x40, pWork->DistBits, DistCode, pWork->position1); - if(Expand(pWork) != 0x306) - return CMP_NO_ERROR; - - return CMP_ABORT; -} +/*****************************************************************************/ +/* explode.c Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* Implode function of PKWARE Data Compression library */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 11.03.03 1.00 Lad Splitted from Pkware.cpp */ +/* 08.04.03 1.01 Lad Renamed to explode.c to be compatible with pklib */ +/* 02.05.03 1.01 Lad Stress test done */ +/*****************************************************************************/ + +#include +#include + +#include "pklib.h" + +//----------------------------------------------------------------------------- +// Tables + +static unsigned char DistBits[] = +{ + 0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 +}; + +static unsigned char DistCode[] = +{ + 0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A, + 0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C, + 0x74, 0x34, 0x54, 0x14, 0x64, 0x24, 0x44, 0x04, 0x78, 0x38, 0x58, 0x18, 0x68, 0x28, 0x48, 0x08, + 0xF0, 0x70, 0xB0, 0x30, 0xD0, 0x50, 0x90, 0x10, 0xE0, 0x60, 0xA0, 0x20, 0xC0, 0x40, 0x80, 0x00 +}; + +static unsigned char ExLenBits[] = +{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 +}; + +static unsigned short LenBase[] = +{ + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, + 0x0008, 0x000A, 0x000E, 0x0016, 0x0026, 0x0046, 0x0086, 0x0106 +}; + +static unsigned char LenBits[] = +{ + 0x03, 0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x07, 0x07 +}; + +static unsigned char LenCode[] = +{ + 0x05, 0x03, 0x01, 0x06, 0x0A, 0x02, 0x0C, 0x14, 0x04, 0x18, 0x08, 0x30, 0x10, 0x20, 0x40, 0x00 +}; + +static unsigned char ChBitsAsc[] = +{ + 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x08, 0x07, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x04, 0x0A, 0x08, 0x0C, 0x0A, 0x0C, 0x0A, 0x08, 0x07, 0x07, 0x08, 0x09, 0x07, 0x06, 0x07, 0x08, + 0x07, 0x06, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x08, 0x08, 0x0C, 0x0B, 0x07, 0x09, 0x0B, + 0x0C, 0x06, 0x07, 0x06, 0x06, 0x05, 0x07, 0x08, 0x08, 0x06, 0x0B, 0x09, 0x06, 0x07, 0x06, 0x06, + 0x07, 0x0B, 0x06, 0x06, 0x06, 0x07, 0x09, 0x08, 0x09, 0x09, 0x0B, 0x08, 0x0B, 0x09, 0x0C, 0x08, + 0x0C, 0x05, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x05, 0x0B, 0x07, 0x05, 0x06, 0x05, 0x05, + 0x06, 0x0A, 0x05, 0x05, 0x05, 0x05, 0x08, 0x07, 0x08, 0x08, 0x0A, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, + 0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D +}; + +static unsigned short ChCodeAsc[] = +{ + 0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0, + 0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0, + 0x0CE0, 0x04E0, 0x08E0, 0x00E0, 0x0F60, 0x0760, 0x0B60, 0x0360, + 0x0D60, 0x0560, 0x1240, 0x0960, 0x0160, 0x0E60, 0x0660, 0x0A60, + 0x000F, 0x0250, 0x0038, 0x0260, 0x0050, 0x0C60, 0x0390, 0x00D8, + 0x0042, 0x0002, 0x0058, 0x01B0, 0x007C, 0x0029, 0x003C, 0x0098, + 0x005C, 0x0009, 0x001C, 0x006C, 0x002C, 0x004C, 0x0018, 0x000C, + 0x0074, 0x00E8, 0x0068, 0x0460, 0x0090, 0x0034, 0x00B0, 0x0710, + 0x0860, 0x0031, 0x0054, 0x0011, 0x0021, 0x0017, 0x0014, 0x00A8, + 0x0028, 0x0001, 0x0310, 0x0130, 0x003E, 0x0064, 0x001E, 0x002E, + 0x0024, 0x0510, 0x000E, 0x0036, 0x0016, 0x0044, 0x0030, 0x00C8, + 0x01D0, 0x00D0, 0x0110, 0x0048, 0x0610, 0x0150, 0x0060, 0x0088, + 0x0FA0, 0x0007, 0x0026, 0x0006, 0x003A, 0x001B, 0x001A, 0x002A, + 0x000A, 0x000B, 0x0210, 0x0004, 0x0013, 0x0032, 0x0003, 0x001D, + 0x0012, 0x0190, 0x000D, 0x0015, 0x0005, 0x0019, 0x0008, 0x0078, + 0x00F0, 0x0070, 0x0290, 0x0410, 0x0010, 0x07A0, 0x0BA0, 0x03A0, + 0x0240, 0x1C40, 0x0C40, 0x1440, 0x0440, 0x1840, 0x0840, 0x1040, + 0x0040, 0x1F80, 0x0F80, 0x1780, 0x0780, 0x1B80, 0x0B80, 0x1380, + 0x0380, 0x1D80, 0x0D80, 0x1580, 0x0580, 0x1980, 0x0980, 0x1180, + 0x0180, 0x1E80, 0x0E80, 0x1680, 0x0680, 0x1A80, 0x0A80, 0x1280, + 0x0280, 0x1C80, 0x0C80, 0x1480, 0x0480, 0x1880, 0x0880, 0x1080, + 0x0080, 0x1F00, 0x0F00, 0x1700, 0x0700, 0x1B00, 0x0B00, 0x1300, + 0x0DA0, 0x05A0, 0x09A0, 0x01A0, 0x0EA0, 0x06A0, 0x0AA0, 0x02A0, + 0x0CA0, 0x04A0, 0x08A0, 0x00A0, 0x0F20, 0x0720, 0x0B20, 0x0320, + 0x0D20, 0x0520, 0x0920, 0x0120, 0x0E20, 0x0620, 0x0A20, 0x0220, + 0x0C20, 0x0420, 0x0820, 0x0020, 0x0FC0, 0x07C0, 0x0BC0, 0x03C0, + 0x0DC0, 0x05C0, 0x09C0, 0x01C0, 0x0EC0, 0x06C0, 0x0AC0, 0x02C0, + 0x0CC0, 0x04C0, 0x08C0, 0x00C0, 0x0F40, 0x0740, 0x0B40, 0x0340, + 0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900, + 0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600, + 0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200, + 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 +}; + +//----------------------------------------------------------------------------- +// Local variables + +static char Copyright[] = "PKWARE Data Compression Library for Win32\r\n" + "Copyright 1989-1995 PKWARE Inc. All Rights Reserved\r\n" + "Patent No. 5,051,745\r\n" + "PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.\r\n" + "Version 1.11\r\n"; + +//----------------------------------------------------------------------------- +// Local functions + +// Copies a block to another location +static void lmemcpy(void * trg, const void * src, size_t count) +{ + memcpy(trg, src, count); +} + +static void GenDecodeTabs(long count, unsigned char * bits, unsigned char * pCode, unsigned char * buffer2) +{ + long i; + + for(i = count-1; i >= 0; i--) // EBX - count + { + unsigned long idx1 = pCode[i]; + unsigned long idx2 = 1 << bits[i]; + + do + { + buffer2[idx1] = (unsigned char)i; + idx1 += idx2; + } + while(idx1 < 0x100); + } +} + +static void GenAscTabs(TDcmpStruct * pWork) +{ + unsigned short * pChCodeAsc = &ChCodeAsc[0xFF]; + unsigned long acc, add; + unsigned short count; + + for(count = 0x00FF; pChCodeAsc >= ChCodeAsc; pChCodeAsc--, count--) + { + unsigned char * pChBitsAsc = pWork->ChBitsAsc + count; + unsigned char bits_asc = *pChBitsAsc; + + if(bits_asc <= 8) + { + add = (1 << bits_asc); + acc = *pChCodeAsc; + + do + { + pWork->offs2C34[acc] = (unsigned char)count; + acc += add; + } + while(acc < 0x100); + } + else if((acc = (*pChCodeAsc & 0xFF)) != 0) + { + pWork->offs2C34[acc] = 0xFF; + + if(*pChCodeAsc & 0x3F) + { + bits_asc -= 4; + *pChBitsAsc = bits_asc; + + add = (1 << bits_asc); + acc = *pChCodeAsc >> 4; + do + { + pWork->offs2D34[acc] = (unsigned char)count; + acc += add; + } + while(acc < 0x100); + } + else + { + bits_asc -= 6; + *pChBitsAsc = bits_asc; + + add = (1 << bits_asc); + acc = *pChCodeAsc >> 6; + do + { + pWork->offs2E34[acc] = (unsigned char)count; + acc += add; + } + while(acc < 0x80); + } + } + else + { + bits_asc -= 8; + *pChBitsAsc = bits_asc; + + add = (1 << bits_asc); + acc = *pChCodeAsc >> 8; + do + { + pWork->offs2EB4[acc] = (unsigned char)count; + acc += add; + } + while(acc < 0x100); + } + } +} + +//----------------------------------------------------------------------------- +// Skips given number of bits in bit buffer. Result is stored in pWork->bit_buff +// If no data in input buffer, returns true + +static int WasteBits(TDcmpStruct * pWork, unsigned long nBits) +{ + // If number of bits required is less than number of (bits in the buffer) ? + if(nBits <= pWork->extra_bits) + { + pWork->extra_bits -= nBits; + pWork->bit_buff >>= nBits; + return 0; + } + + // Load input buffer if necessary + pWork->bit_buff >>= pWork->extra_bits; + if(pWork->in_pos == pWork->in_bytes) + { + pWork->in_pos = sizeof(pWork->in_buff); + if((pWork->in_bytes = pWork->read_buf((char *)pWork->in_buff, &pWork->in_pos, pWork->param)) == 0) + return 1; + pWork->in_pos = 0; + } + + // Update bit buffer + pWork->bit_buff |= (pWork->in_buff[pWork->in_pos++] << 8); + pWork->bit_buff >>= (nBits - pWork->extra_bits); + pWork->extra_bits = (pWork->extra_bits - nBits) + 8; + return 0; +} + +//----------------------------------------------------------------------------- +// Returns : 0x000 - 0x0FF : One byte from compressed file. +// 0x100 - 0x305 : Copy previous block (0x100 = 1 byte) +// 0x306 : Out of buffer (?) + +static unsigned long DecodeLit(TDcmpStruct * pWork) +{ + unsigned long nBits; // Number of bits to skip + unsigned long value; // Position in buffers + + // Test the current bit in byte buffer. If is not set, simply return the next byte. + if(pWork->bit_buff & 1) + { + // Skip current bit in the buffer + if(WasteBits(pWork, 1)) + return 0x306; + + // The next bits are position in buffers + value = pWork->position2[(pWork->bit_buff & 0xFF)]; + + // Get number of bits to skip + if(WasteBits(pWork, pWork->LenBits[value])) + return 0x306; + + if((nBits = pWork->ExLenBits[value]) != 0) + { + unsigned long val2 = pWork->bit_buff & ((1 << nBits) - 1); + + if(WasteBits(pWork, nBits)) + { + if((value + val2) != 0x10E) + return 0x306; + } + value = pWork->LenBase[value] + val2; + } + return value + 0x100; // Return number of bytes to repeat + } + + // Waste one bit + if(WasteBits(pWork, 1)) + return 0x306; + + // If the binary compression type, read 8 bits and return them as one byte. + if(pWork->ctype == CMP_BINARY) + { + value = pWork->bit_buff & 0xFF; + if(WasteBits(pWork, 8)) + return 0x306; + return value; + } + + // When ASCII compression ... + if(pWork->bit_buff & 0xFF) + { + value = pWork->offs2C34[pWork->bit_buff & 0xFF]; + + if(value == 0xFF) + { + if(pWork->bit_buff & 0x3F) + { + if(WasteBits(pWork, 4)) + return 0x306; + + value = pWork->offs2D34[pWork->bit_buff & 0xFF]; + } + else + { + if(WasteBits(pWork, 6)) + return 0x306; + + value = pWork->offs2E34[pWork->bit_buff & 0x7F]; + } + } + } + else + { + if(WasteBits(pWork, 8)) + return 0x306; + + value = pWork->offs2EB4[pWork->bit_buff & 0xFF]; + } + + return WasteBits(pWork, pWork->ChBitsAsc[value]) ? 0x306 : value; +} + +//----------------------------------------------------------------------------- +// Retrieves the number of bytes to move back + +static unsigned long DecodeDist(TDcmpStruct * pWork, unsigned long dwLength) +{ + unsigned long pos = pWork->position1[(pWork->bit_buff & 0xFF)]; + unsigned long nSkip = pWork->DistBits[pos]; // Number of bits to skip + + // Skip the appropriate number of bits + if(WasteBits(pWork, nSkip) == 1) + return 0; + + if(dwLength == 2) + { + pos = (pos << 2) | (pWork->bit_buff & 0x03); + + if(WasteBits(pWork, 2) == 1) + return 0; + } + else + { + pos = (pos << pWork->dsize_bits) | (pWork->bit_buff & pWork->dsize_mask); + + // Skip the bits + if(WasteBits(pWork, pWork->dsize_bits) == 1) + return 0; + } + return pos+1; +} + +static unsigned long Expand(TDcmpStruct * pWork) +{ + unsigned int copyBytes; // Number of bytes to copy + unsigned long oneByte; // One byte from compressed file + unsigned long dwResult; + + pWork->outputPos = 0x1000; // Initialize output buffer position + + // If end of data or error, terminate decompress + while((dwResult = oneByte = DecodeLit(pWork)) < 0x305) + { + // If one byte is greater than 0x100, means "Repeat n - 0xFE bytes" + if(oneByte >= 0x100) + { + unsigned char * source; // ECX + unsigned char * target; // EDX + unsigned long copyLength = oneByte - 0xFE; + unsigned long moveBack; + + // Get length of data to copy + if((moveBack = DecodeDist(pWork, copyLength)) == 0) + { + dwResult = 0x306; + break; + } + + // Target and source pointer + target = &pWork->out_buff[pWork->outputPos]; + source = target - moveBack; + pWork->outputPos += copyLength; + + while(copyLength-- > 0) + *target++ = *source++; + } + else + pWork->out_buff[pWork->outputPos++] = (unsigned char)oneByte; + + // If number of extracted bytes has reached 1/2 of output buffer, + // flush output buffer. + if(pWork->outputPos >= 0x2000) + { + // Copy decompressed data into user buffer + copyBytes = 0x1000; + pWork->write_buf((char *)&pWork->out_buff[0x1000], ©Bytes, pWork->param); + + // If there are some data left, keep them alive + lmemcpy(pWork->out_buff, &pWork->out_buff[0x1000], pWork->outputPos - 0x1000); + pWork->outputPos -= 0x1000; + } + } + + copyBytes = pWork->outputPos - 0x1000; + pWork->write_buf((char *)&pWork->out_buff[0x1000], ©Bytes, pWork->param); + return dwResult; +} + + +//----------------------------------------------------------------------------- +// Main exploding function. + +unsigned int explode( + unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), + void (*write_buf)(char *buf, unsigned int *size, void *param), + char *work_buf, + void *param) +{ + TDcmpStruct * pWork = (TDcmpStruct *)work_buf; + + // Set the whole work buffer to zeros + memset(pWork, 0, sizeof(TDcmpStruct)); + + // Initialize work struct and load compressed data + pWork->read_buf = read_buf; + pWork->write_buf = write_buf; + pWork->param = param; + pWork->in_pos = sizeof(pWork->in_buff); + pWork->in_bytes = pWork->read_buf((char *)pWork->in_buff, &pWork->in_pos, pWork->param); + if(pWork->in_bytes <= 4) + return CMP_BAD_DATA; + + pWork->ctype = pWork->in_buff[0]; // Get the compression type + pWork->dsize_bits = pWork->in_buff[1]; // Get the dictionary size + pWork->bit_buff = pWork->in_buff[2]; // Initialize 16-bit bit buffer + pWork->extra_bits = 0; // Extra (over 8) bits + pWork->in_pos = 3; // Position in input buffer + + // Test for the valid dictionary size + if(4 > pWork->dsize_bits || pWork->dsize_bits > 6) + return CMP_INVALID_DICTSIZE; + + pWork->dsize_mask = 0xFFFF >> (0x10 - pWork->dsize_bits); // Shifted by 'sar' instruction + + if(pWork->ctype != CMP_BINARY) + { + if(pWork->ctype != CMP_ASCII) + return CMP_INVALID_MODE; + + lmemcpy(pWork->ChBitsAsc, ChBitsAsc, sizeof(pWork->ChBitsAsc)); + GenAscTabs(pWork); + } + + lmemcpy(pWork->LenBits, LenBits, sizeof(pWork->LenBits)); + GenDecodeTabs(0x10, pWork->LenBits, LenCode, pWork->position2); + lmemcpy(pWork->ExLenBits, ExLenBits, sizeof(pWork->ExLenBits)); + lmemcpy(pWork->LenBase, LenBase, sizeof(pWork->LenBase)); + lmemcpy(pWork->DistBits, DistBits, sizeof(pWork->DistBits)); + GenDecodeTabs(0x40, pWork->DistBits, DistCode, pWork->position1); + if(Expand(pWork) != 0x306) + return CMP_NO_ERROR; + + return CMP_ABORT; +} diff --git a/src/tools/stuffextract/StormLib/pklib/implode.c b/src/tools/stuffextract/StormLib/pklib/implode.c index be6aecb..68d5301 100644 --- a/src/tools/stuffextract/StormLib/pklib/implode.c +++ b/src/tools/stuffextract/StormLib/pklib/implode.c @@ -1,674 +1,674 @@ -/*****************************************************************************/ -/* implode.c Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Implode function of PKWARE Data Compression library */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 11.04.03 1.00 Lad First version of implode.c */ -/* 02.05.03 1.00 Lad Stress test done */ -/*****************************************************************************/ - -#include -#include - -#include "pklib.h" - -#if ((1200 < _MSC_VER) && (_MSC_VER < 1400)) -#pragma optimize("", off) // Fucking Microsoft VS.NET 2003 compiler !!! - // (_MSC_VER=1310) -#endif - -//----------------------------------------------------------------------------- -// Defines - -#define DICT_OFFSET 0x204 -#define UNCMP_OFFSET (pWork->dsize_bytes + DICT_OFFSET) - -//----------------------------------------------------------------------------- -// Tables - -static unsigned char DistBits[] = -{ - 0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 -}; - -static unsigned char DistCode[] = -{ - 0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A, - 0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C, - 0x74, 0x34, 0x54, 0x14, 0x64, 0x24, 0x44, 0x04, 0x78, 0x38, 0x58, 0x18, 0x68, 0x28, 0x48, 0x08, - 0xF0, 0x70, 0xB0, 0x30, 0xD0, 0x50, 0x90, 0x10, 0xE0, 0x60, 0xA0, 0x20, 0xC0, 0x40, 0x80, 0x00 -}; - -static unsigned char ExLenBits[] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 -}; - -static unsigned char LenBits[] = -{ - 0x03, 0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x07, 0x07 -}; - -static unsigned char LenCode[] = -{ - 0x05, 0x03, 0x01, 0x06, 0x0A, 0x02, 0x0C, 0x14, 0x04, 0x18, 0x08, 0x30, 0x10, 0x20, 0x40, 0x00 -}; - -static unsigned char ChBitsAsc[] = -{ - 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x08, 0x07, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x04, 0x0A, 0x08, 0x0C, 0x0A, 0x0C, 0x0A, 0x08, 0x07, 0x07, 0x08, 0x09, 0x07, 0x06, 0x07, 0x08, - 0x07, 0x06, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x08, 0x08, 0x0C, 0x0B, 0x07, 0x09, 0x0B, - 0x0C, 0x06, 0x07, 0x06, 0x06, 0x05, 0x07, 0x08, 0x08, 0x06, 0x0B, 0x09, 0x06, 0x07, 0x06, 0x06, - 0x07, 0x0B, 0x06, 0x06, 0x06, 0x07, 0x09, 0x08, 0x09, 0x09, 0x0B, 0x08, 0x0B, 0x09, 0x0C, 0x08, - 0x0C, 0x05, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x05, 0x0B, 0x07, 0x05, 0x06, 0x05, 0x05, - 0x06, 0x0A, 0x05, 0x05, 0x05, 0x05, 0x08, 0x07, 0x08, 0x08, 0x0A, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, - 0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D -}; - -static unsigned short ChCodeAsc[] = -{ - 0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0, - 0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0, - 0x0CE0, 0x04E0, 0x08E0, 0x00E0, 0x0F60, 0x0760, 0x0B60, 0x0360, - 0x0D60, 0x0560, 0x1240, 0x0960, 0x0160, 0x0E60, 0x0660, 0x0A60, - 0x000F, 0x0250, 0x0038, 0x0260, 0x0050, 0x0C60, 0x0390, 0x00D8, - 0x0042, 0x0002, 0x0058, 0x01B0, 0x007C, 0x0029, 0x003C, 0x0098, - 0x005C, 0x0009, 0x001C, 0x006C, 0x002C, 0x004C, 0x0018, 0x000C, - 0x0074, 0x00E8, 0x0068, 0x0460, 0x0090, 0x0034, 0x00B0, 0x0710, - 0x0860, 0x0031, 0x0054, 0x0011, 0x0021, 0x0017, 0x0014, 0x00A8, - 0x0028, 0x0001, 0x0310, 0x0130, 0x003E, 0x0064, 0x001E, 0x002E, - 0x0024, 0x0510, 0x000E, 0x0036, 0x0016, 0x0044, 0x0030, 0x00C8, - 0x01D0, 0x00D0, 0x0110, 0x0048, 0x0610, 0x0150, 0x0060, 0x0088, - 0x0FA0, 0x0007, 0x0026, 0x0006, 0x003A, 0x001B, 0x001A, 0x002A, - 0x000A, 0x000B, 0x0210, 0x0004, 0x0013, 0x0032, 0x0003, 0x001D, - 0x0012, 0x0190, 0x000D, 0x0015, 0x0005, 0x0019, 0x0008, 0x0078, - 0x00F0, 0x0070, 0x0290, 0x0410, 0x0010, 0x07A0, 0x0BA0, 0x03A0, - 0x0240, 0x1C40, 0x0C40, 0x1440, 0x0440, 0x1840, 0x0840, 0x1040, - 0x0040, 0x1F80, 0x0F80, 0x1780, 0x0780, 0x1B80, 0x0B80, 0x1380, - 0x0380, 0x1D80, 0x0D80, 0x1580, 0x0580, 0x1980, 0x0980, 0x1180, - 0x0180, 0x1E80, 0x0E80, 0x1680, 0x0680, 0x1A80, 0x0A80, 0x1280, - 0x0280, 0x1C80, 0x0C80, 0x1480, 0x0480, 0x1880, 0x0880, 0x1080, - 0x0080, 0x1F00, 0x0F00, 0x1700, 0x0700, 0x1B00, 0x0B00, 0x1300, - 0x0DA0, 0x05A0, 0x09A0, 0x01A0, 0x0EA0, 0x06A0, 0x0AA0, 0x02A0, - 0x0CA0, 0x04A0, 0x08A0, 0x00A0, 0x0F20, 0x0720, 0x0B20, 0x0320, - 0x0D20, 0x0520, 0x0920, 0x0120, 0x0E20, 0x0620, 0x0A20, 0x0220, - 0x0C20, 0x0420, 0x0820, 0x0020, 0x0FC0, 0x07C0, 0x0BC0, 0x03C0, - 0x0DC0, 0x05C0, 0x09C0, 0x01C0, 0x0EC0, 0x06C0, 0x0AC0, 0x02C0, - 0x0CC0, 0x04C0, 0x08C0, 0x00C0, 0x0F40, 0x0740, 0x0B40, 0x0340, - 0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900, - 0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600, - 0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200, - 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 -}; - -//----------------------------------------------------------------------------- -// Local variables - -static char Copyright[] = "PKWARE Data Compression Library for Win32\r\n" - "Copyright 1989-1995 PKWARE Inc. All Rights Reserved\r\n" - "Patent No. 5,051,745\r\n" - "PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.\r\n" - "Version 1.11\r\n"; - -//----------------------------------------------------------------------------- -// Local functions - -// Fills memory block with a character -static void lmemset(void * buff, int c, size_t count) -{ - memset(buff, c, count); -} - -// Copies memory block to another location -static void lmemcpy(void * trg, const void * src, size_t count) -{ - memcpy(trg, src, count); -} - -static void SortBuffer(TCmpStruct * pWork, unsigned char * uncmp_data, unsigned char * work_end) -{ - unsigned short * pin0DC8; - unsigned char * puncmp; - unsigned long offs1, offs2; - unsigned long ndwords; - unsigned int add; - - // Fill 0x480 dwords (0x1200 bytes) - ndwords = (unsigned long)((pWork->out_buff - (char *)pWork->offs0DC8 + 1) >> 2); - if(ndwords <= 1) - ndwords = 1; - memset(pWork->offs0DC8, 0, ndwords << 2); - - for(puncmp = uncmp_data; work_end > puncmp; puncmp++) - pWork->offs0DC8[(puncmp[0] * 4) + (puncmp[1] * 5)]++; - - add = 0; - for(pin0DC8 = pWork->offs0DC8; pin0DC8 < &pWork->offs1FC8; pin0DC8++) - { - add += *pin0DC8; - *pin0DC8 = (unsigned short)add; - } - - for(work_end--; work_end >= uncmp_data; work_end--) - { - offs1 = (work_end[0] * 4) + (work_end[1] * 5); // EAX - offs2 = (unsigned long)(work_end - pWork->work_buff); // EDI - - pWork->offs0DC8[offs1]--; - pWork->offs49D0[pWork->offs0DC8[offs1]] = (unsigned short)offs2; - } -} - -static void FlushBuf(TCmpStruct * pWork) -{ - unsigned char save_ch1; - unsigned char save_ch2; - unsigned int size = 0x800; - - pWork->write_buf(pWork->out_buff, &size, pWork->param); - - save_ch1 = pWork->out_buff[0x800]; - save_ch2 = pWork->out_buff[pWork->out_bytes]; - pWork->out_bytes -= 0x800; - - lmemset(pWork->out_buff, 0, 0x802); - - if(pWork->out_bytes != 0) - pWork->out_buff[0] = save_ch1; - if(pWork->out_bits != 0) - pWork->out_buff[pWork->out_bytes] = save_ch2; -} - -static void OutputBits(TCmpStruct * pWork, unsigned int nbits, unsigned long bit_buff) -{ - unsigned int out_bits; - - // If more than 8 bits to output, do recursion - if(nbits > 8) - { - OutputBits(pWork, 8, bit_buff); - bit_buff >>= 8; - nbits -= 8; - } - - // Add bits to the last out byte in out_buff; - out_bits = pWork->out_bits; - pWork->out_buff[pWork->out_bytes] |= (unsigned char)(bit_buff << out_bits); - pWork->out_bits += nbits; - - // If 8 or more bits, increment number of bytes - if(pWork->out_bits > 8) - { - pWork->out_bytes++; - bit_buff >>= (8 - out_bits); - - pWork->out_buff[pWork->out_bytes] = (unsigned char)bit_buff; - pWork->out_bits &= 7; - } - else - { - pWork->out_bits &= 7; - if(pWork->out_bits == 0) - pWork->out_bytes++; - } - - // If there is enough compressed bytes, flush them - if(pWork->out_bytes >= 0x800) - FlushBuf(pWork); -} - -static unsigned long FindRep(TCmpStruct * pWork, unsigned char * srcbuff) -{ - unsigned short esp12; - unsigned char * esp14; - unsigned short esp18; - unsigned char * srcbuff2; - unsigned char esp20; - - unsigned char * srcbuff3; - unsigned short * pin0DC8; - unsigned char * pin27CC; - unsigned short * pin49D0; - unsigned long nreps = 1; // EAX - unsigned long ebx, esi; - unsigned short di; - - pin0DC8 = pWork->offs0DC8 + (srcbuff[0] * 4) + (srcbuff[1] * 5); - esi = (unsigned long)(srcbuff - pWork->dsize_bytes - pWork->work_buff + 1); - esp18 = *pin0DC8; - pin49D0 = pWork->offs49D0 + esp18; - - if(*pin49D0 < esi) - { - while(*pin49D0 < esi) - { - pin49D0++; - esp18++; - } - *pin0DC8 = esp18; - } -//--------------------------------------------------------------------------- - srcbuff2 = srcbuff - 1; - pin49D0 = pWork->offs49D0 + esp18; - pin27CC = pWork->work_buff + *pin49D0; - if(srcbuff2 <= pin27CC) - return 0; -//--------------------------------------------------------------------------- - srcbuff3 = srcbuff; - for(;;) - { - if(srcbuff3[nreps-1] == pin27CC[nreps-1] && *srcbuff3 == *pin27CC) - { - // - // The following code does not work when compiled with MSVC.NET 2003 - // optimizing compiler. We have to switch the optimizations off to make it work - // I found that in debug version (where the optimizations are off), the value - // of "pin27CC" gets incremented twice (once at below, once in the "for" loop) - // - - pin27CC++; - srcbuff3++; - - for(ebx = 2; ebx < DICT_OFFSET; ebx++) - { - pin27CC++; - srcbuff3++; - if(*pin27CC != *srcbuff3) - break; - } - - srcbuff3 = srcbuff; - if(ebx >= nreps) - { - pWork->offs0000 = (unsigned int)(srcbuff3 - pin27CC + ebx - 1); - if((nreps = ebx) > 10) - break; - } - } - - pin49D0++; - esp18++; - pin27CC = pWork->work_buff + *pin49D0; - - if(srcbuff2 > pin27CC) - continue; - - return (nreps >= 2) ? nreps : 0; - } -//--------------------------------------------------------------------------- - if(ebx == DICT_OFFSET) - { - pWork->offs0000--; - return ebx; - } -//--------------------------------------------------------------------------- - pin49D0 = pWork->offs49D0 + esp18; - if(pWork->work_buff + pin49D0[1] >= srcbuff2) - return nreps; -//--------------------------------------------------------------------------- - di = 0; - pWork->offs09BC[0] = 0xFFFF; - pWork->offs09BC[1] = di; - esp12 = 1; - - do - { - esi = di; - if(srcbuff[esp12] != srcbuff[esi]) - { - di = pWork->offs09BC[esi]; - if(di != 0xFFFF) - continue; - } - pWork->offs09BC[++esp12] = ++di; - } - while(esp12 < nreps); -//--------------------------------------------------------------------------- - esi = nreps; - pin27CC = pWork->work_buff + pin49D0[0] + nreps; - esp14 = pin27CC; - - for(;;) // 0040268B - { - esi = pWork->offs09BC[esi]; - if(esi == 0xFFFF) - esi = 0; - - pin49D0 = pWork->offs49D0 + esp18; - do - { - pin49D0++; - esp18++; - pin27CC = pWork->work_buff + pin49D0[0]; - if(pin27CC >= srcbuff2) - return nreps; - } - while(pin27CC + esi < esp14); -//--------------------------------------------------------------------------- - esp20 = srcbuff[nreps - 2]; - if(esp20 == pin27CC[nreps - 2]) - { - if(pin27CC + esi != esp14) - { - esp14 = pin27CC; - esi = 0; - } - } - else - { - pin49D0 = pWork->offs49D0 + esp18; - do - { - pin49D0++; - esp18++; - pin27CC = pWork->work_buff + pin49D0[0]; - if(pin27CC >= srcbuff2) - return nreps; - } - while(pin27CC[nreps - 2] != esp20 || pin27CC[0] != *srcbuff); - - esp14 = pin27CC + 2; - esi = 2; - } -//--------------------------------------------------------------------------- - for(; esp14[0] == srcbuff[esi]; esp14++) - { - if(++esi >= DICT_OFFSET) - break; - } - - if(esi < nreps) - continue; - pWork->offs0000 = (unsigned int)(srcbuff - pin27CC - 1); - if(esi <= nreps) - continue; - nreps = esi; - if(esi == DICT_OFFSET) - return nreps; - - do - { - if(srcbuff[esp12] != srcbuff[di]) - { - di = pWork->offs09BC[di]; - if(di != 0xFFFF) - continue; - } - pWork->offs09BC[++esp12] = ++di; - } - while(esp12 < esi); - } -} - -static void WriteCmpData(TCmpStruct * pWork) -{ - unsigned int nreps = 0; // ESP+10 : Number of repeats - unsigned char * uncmp_end; // ESP+14 : End of uncompressed data - unsigned int esp18 = 0; // ESP+18 : - unsigned int bytes_required; // ESP+1C : Number of bytes required to read - unsigned int esp20 = 0; // ESP+20 : - unsigned char * uncmp_begin = pWork->work_buff + UNCMP_OFFSET; // EDI - unsigned long nreps1; - unsigned long save_offs0000 = 0; - - // Store the compression type and dictionary size - pWork->out_buff[0] = (char)pWork->ctype; - pWork->out_buff[1] = (char)pWork->dsize_bits; - pWork->out_bytes = 2; - - // Reset output buffer to zero - lmemset(&pWork->out_buff[2], 0, sizeof(pWork->out_buff) - 2); - pWork->out_bits = 0; - - do - { - int total_loaded = 0; - - for(bytes_required = 0x1000; bytes_required != 0; ) - { - int loaded = pWork->read_buf((char *)pWork->work_buff + UNCMP_OFFSET + total_loaded, - &bytes_required, pWork->param); - - if(loaded == 0) - { - if(total_loaded == 0 && esp20 == 0) - goto __Exit; - esp18 = 1; - break; - } - else - { - total_loaded += loaded; - bytes_required -= loaded; - } - } - - uncmp_end = pWork->work_buff + pWork->dsize_bytes + total_loaded; - if(esp18 != 0) - uncmp_end += DICT_OFFSET; - - // - // Warning: Passing "uncmp_end + 1" to the SortBuffer function may cause - // the output to be unpredictable in Storm.dll's compression. Because Storm.dll - // does not pass the zeroed buffer to the "implode" function, the byte after - // uncmp_end contains random data. This causes difference within dictionary - // created in SortBuffer function and may also cause different compressed output. - // We always zero the data before compression, so this thing never occurs. - // Funny is that it is actually not a bug, because if we decompress the data back, - // we'll get the identical data with the original input. - // - switch(esp20) - { - case 0: - SortBuffer(pWork, uncmp_begin, uncmp_end + 1); - esp20++; - if(pWork->dsize_bytes != 0x1000) - esp20++; - break; - - case 1: - SortBuffer(pWork, uncmp_begin - pWork->dsize_bytes + DICT_OFFSET, uncmp_end + 1); - esp20++; - break; - - default: - SortBuffer(pWork, uncmp_begin - pWork->dsize_bytes, uncmp_end + 1); - break; - } - - while(uncmp_end > uncmp_begin) - { - nreps1 = FindRep(pWork, uncmp_begin); - while(nreps1 != 0) - { - if(nreps1 == 2 && pWork->offs0000 >= 0x100) - break; - - if(esp18 != 0 && uncmp_begin + nreps1 > uncmp_end) - goto _004022DB; - - if(nreps1 >= 8 || uncmp_begin + 1 >= uncmp_end) - goto _004022FF; - - save_offs0000 = pWork->offs0000; // ebp - nreps = nreps1; - nreps1 = FindRep(pWork, uncmp_begin + 1); - - if(nreps >= nreps1) - goto _004022F9; - - if(nreps + 1 >= nreps1 && save_offs0000 <= 0x80) - goto _004022F9; - - OutputBits(pWork, pWork->nChBits[*uncmp_begin], pWork->nChCodes[*uncmp_begin]); - uncmp_begin++; - } - -_0040222F: - OutputBits(pWork, pWork->nChBits[*uncmp_begin], pWork->nChCodes[*uncmp_begin]); - uncmp_begin++; -_00402252:; - } - - if(esp18 == 0) - { - uncmp_begin -= 0x1000; - lmemcpy(pWork->work_buff, pWork->work_buff + 0x1000, pWork->dsize_bytes + DICT_OFFSET); - } - } - while(esp18 == 0); - -__Exit: - OutputBits(pWork, pWork->nChBits[0x305], pWork->nChCodes[0x305]); - if(pWork->out_bits != 0) - pWork->out_bytes++; - pWork->write_buf(pWork->out_buff, &pWork->out_bytes, pWork->param); - return; - -_004022DB: - nreps1 = (unsigned long)(uncmp_end - uncmp_begin); - if(nreps1 < 2) - goto _0040222F; - - if(nreps1 != 2 || pWork->offs0000 < 0x100) - goto _004022FF; - goto _0040222F; - -_004022F9: - nreps1 = nreps; - pWork->offs0000 = save_offs0000; - -_004022FF: - OutputBits(pWork, pWork->nChBits[nreps1 + 0xFE], pWork->nChCodes[nreps1 + 0xFE]); - - if(nreps1 == 2) - { - OutputBits(pWork, pWork->dist_bits[pWork->offs0000 >> 2], - pWork->dist_codes[pWork->offs0000 >> 2]); - OutputBits(pWork, 2, pWork->offs0000 & 3); - } - else - { - OutputBits(pWork, pWork->dist_bits[pWork->offs0000 >> pWork->dsize_bits], - pWork->dist_codes[pWork->offs0000 >> pWork->dsize_bits]); - OutputBits(pWork, pWork->dsize_bits, pWork->dsize_mask & pWork->offs0000); - } - uncmp_begin += nreps1; - goto _00402252; -} - -//----------------------------------------------------------------------------- -// Main imploding function - -unsigned int PKEXPORT implode( - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), - void (*write_buf)(char *buf, unsigned int *size, void *param), - char *work_buf, - void *param, - unsigned int *type, - unsigned int *dsize) -{ - TCmpStruct * pWork = (TCmpStruct *)work_buf; - unsigned int nChCode; - unsigned int nCount; - unsigned int i; - - // Initialize the work buffer. This is not in the Pklib, - // but it seems to be a bug. Storm always pre-fills the data with zeros, - // and always compresses one block only. So the bug will not appear. - // But when a larger data block (size > 0x1000) is compressed, - // it may fail. - memset(pWork, 0, sizeof(TCmpStruct)); - - // Fill the work buffer information - pWork->read_buf = read_buf; - pWork->write_buf = write_buf; - pWork->dsize_bytes = *dsize; - pWork->ctype = *type; - pWork->param = param; - pWork->dsize_bits = 4; - pWork->dsize_mask = 0x0F; - - // Test dictionary size - switch(*dsize) - { - case 0x1000 : - pWork->dsize_bits++; - pWork->dsize_mask |= 0x20; - // No break here !!! - - case 0x0800 : - pWork->dsize_bits++; - pWork->dsize_mask |= 0x10; - // No break here !!! - - case 0x0400 : - break; - - default: - return CMP_INVALID_DICTSIZE; - } - - // Test the compression type - switch(*type) - { - case CMP_BINARY: // We will compress data with binary compression type - for(nChCode = 0, nCount = 0; nCount < 0x100; nCount++) - { - pWork->nChBits[nCount] = 9; - pWork->nChCodes[nCount] = (unsigned short)nChCode; - nChCode = (nChCode & 0x0000FFFF) + 2; - } - break; - - - case CMP_ASCII: // We will compress data with ASCII compression type - for(nCount = 0; nCount < 0x100; nCount++) - { - pWork->nChBits[nCount] = (unsigned char )(ChBitsAsc[nCount] + 1); - pWork->nChCodes[nCount] = (unsigned short)(ChCodeAsc[nCount] * 2); - } - break; - - default: - return CMP_INVALID_MODE; - } - - for(i = 0; i < 0x10; i++) - { - int nCount2 = 0; // EBX - - if((1 << ExLenBits[i]) == 0) - continue; - - do - { - pWork->nChBits[nCount] = (unsigned char)(ExLenBits[i] + LenBits[i] + 1); - pWork->nChCodes[nCount] = (unsigned short)((nCount2 << (LenBits[i] + 1)) | ((LenCode[i] & 0xFFFF00FF) * 2) | 1); - - nCount2++; - nCount++; - } - while((1 << ExLenBits[i]) > nCount2); - } - - // Copy the distance codes and distance bits and perform the compression - lmemcpy(&pWork->dist_codes, DistCode, sizeof(DistCode)); - lmemcpy(&pWork->dist_bits, DistBits, sizeof(DistBits)); - WriteCmpData(pWork); - return CMP_NO_ERROR; -} +/*****************************************************************************/ +/* implode.c Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* Implode function of PKWARE Data Compression library */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 11.04.03 1.00 Lad First version of implode.c */ +/* 02.05.03 1.00 Lad Stress test done */ +/*****************************************************************************/ + +#include +#include + +#include "pklib.h" + +#if ((1200 < _MSC_VER) && (_MSC_VER < 1400)) +#pragma optimize("", off) // Fucking Microsoft VS.NET 2003 compiler !!! + // (_MSC_VER=1310) +#endif + +//----------------------------------------------------------------------------- +// Defines + +#define DICT_OFFSET 0x204 +#define UNCMP_OFFSET (pWork->dsize_bytes + DICT_OFFSET) + +//----------------------------------------------------------------------------- +// Tables + +static unsigned char DistBits[] = +{ + 0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 +}; + +static unsigned char DistCode[] = +{ + 0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A, + 0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C, + 0x74, 0x34, 0x54, 0x14, 0x64, 0x24, 0x44, 0x04, 0x78, 0x38, 0x58, 0x18, 0x68, 0x28, 0x48, 0x08, + 0xF0, 0x70, 0xB0, 0x30, 0xD0, 0x50, 0x90, 0x10, 0xE0, 0x60, 0xA0, 0x20, 0xC0, 0x40, 0x80, 0x00 +}; + +static unsigned char ExLenBits[] = +{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 +}; + +static unsigned char LenBits[] = +{ + 0x03, 0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x07, 0x07 +}; + +static unsigned char LenCode[] = +{ + 0x05, 0x03, 0x01, 0x06, 0x0A, 0x02, 0x0C, 0x14, 0x04, 0x18, 0x08, 0x30, 0x10, 0x20, 0x40, 0x00 +}; + +static unsigned char ChBitsAsc[] = +{ + 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x08, 0x07, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x04, 0x0A, 0x08, 0x0C, 0x0A, 0x0C, 0x0A, 0x08, 0x07, 0x07, 0x08, 0x09, 0x07, 0x06, 0x07, 0x08, + 0x07, 0x06, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x08, 0x08, 0x0C, 0x0B, 0x07, 0x09, 0x0B, + 0x0C, 0x06, 0x07, 0x06, 0x06, 0x05, 0x07, 0x08, 0x08, 0x06, 0x0B, 0x09, 0x06, 0x07, 0x06, 0x06, + 0x07, 0x0B, 0x06, 0x06, 0x06, 0x07, 0x09, 0x08, 0x09, 0x09, 0x0B, 0x08, 0x0B, 0x09, 0x0C, 0x08, + 0x0C, 0x05, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x05, 0x0B, 0x07, 0x05, 0x06, 0x05, 0x05, + 0x06, 0x0A, 0x05, 0x05, 0x05, 0x05, 0x08, 0x07, 0x08, 0x08, 0x0A, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, + 0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D +}; + +static unsigned short ChCodeAsc[] = +{ + 0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0, + 0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0, + 0x0CE0, 0x04E0, 0x08E0, 0x00E0, 0x0F60, 0x0760, 0x0B60, 0x0360, + 0x0D60, 0x0560, 0x1240, 0x0960, 0x0160, 0x0E60, 0x0660, 0x0A60, + 0x000F, 0x0250, 0x0038, 0x0260, 0x0050, 0x0C60, 0x0390, 0x00D8, + 0x0042, 0x0002, 0x0058, 0x01B0, 0x007C, 0x0029, 0x003C, 0x0098, + 0x005C, 0x0009, 0x001C, 0x006C, 0x002C, 0x004C, 0x0018, 0x000C, + 0x0074, 0x00E8, 0x0068, 0x0460, 0x0090, 0x0034, 0x00B0, 0x0710, + 0x0860, 0x0031, 0x0054, 0x0011, 0x0021, 0x0017, 0x0014, 0x00A8, + 0x0028, 0x0001, 0x0310, 0x0130, 0x003E, 0x0064, 0x001E, 0x002E, + 0x0024, 0x0510, 0x000E, 0x0036, 0x0016, 0x0044, 0x0030, 0x00C8, + 0x01D0, 0x00D0, 0x0110, 0x0048, 0x0610, 0x0150, 0x0060, 0x0088, + 0x0FA0, 0x0007, 0x0026, 0x0006, 0x003A, 0x001B, 0x001A, 0x002A, + 0x000A, 0x000B, 0x0210, 0x0004, 0x0013, 0x0032, 0x0003, 0x001D, + 0x0012, 0x0190, 0x000D, 0x0015, 0x0005, 0x0019, 0x0008, 0x0078, + 0x00F0, 0x0070, 0x0290, 0x0410, 0x0010, 0x07A0, 0x0BA0, 0x03A0, + 0x0240, 0x1C40, 0x0C40, 0x1440, 0x0440, 0x1840, 0x0840, 0x1040, + 0x0040, 0x1F80, 0x0F80, 0x1780, 0x0780, 0x1B80, 0x0B80, 0x1380, + 0x0380, 0x1D80, 0x0D80, 0x1580, 0x0580, 0x1980, 0x0980, 0x1180, + 0x0180, 0x1E80, 0x0E80, 0x1680, 0x0680, 0x1A80, 0x0A80, 0x1280, + 0x0280, 0x1C80, 0x0C80, 0x1480, 0x0480, 0x1880, 0x0880, 0x1080, + 0x0080, 0x1F00, 0x0F00, 0x1700, 0x0700, 0x1B00, 0x0B00, 0x1300, + 0x0DA0, 0x05A0, 0x09A0, 0x01A0, 0x0EA0, 0x06A0, 0x0AA0, 0x02A0, + 0x0CA0, 0x04A0, 0x08A0, 0x00A0, 0x0F20, 0x0720, 0x0B20, 0x0320, + 0x0D20, 0x0520, 0x0920, 0x0120, 0x0E20, 0x0620, 0x0A20, 0x0220, + 0x0C20, 0x0420, 0x0820, 0x0020, 0x0FC0, 0x07C0, 0x0BC0, 0x03C0, + 0x0DC0, 0x05C0, 0x09C0, 0x01C0, 0x0EC0, 0x06C0, 0x0AC0, 0x02C0, + 0x0CC0, 0x04C0, 0x08C0, 0x00C0, 0x0F40, 0x0740, 0x0B40, 0x0340, + 0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900, + 0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600, + 0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200, + 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 +}; + +//----------------------------------------------------------------------------- +// Local variables + +static char Copyright[] = "PKWARE Data Compression Library for Win32\r\n" + "Copyright 1989-1995 PKWARE Inc. All Rights Reserved\r\n" + "Patent No. 5,051,745\r\n" + "PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.\r\n" + "Version 1.11\r\n"; + +//----------------------------------------------------------------------------- +// Local functions + +// Fills memory block with a character +static void lmemset(void * buff, int c, size_t count) +{ + memset(buff, c, count); +} + +// Copies memory block to another location +static void lmemcpy(void * trg, const void * src, size_t count) +{ + memcpy(trg, src, count); +} + +static void SortBuffer(TCmpStruct * pWork, unsigned char * uncmp_data, unsigned char * work_end) +{ + unsigned short * pin0DC8; + unsigned char * puncmp; + unsigned long offs1, offs2; + unsigned long ndwords; + unsigned int add; + + // Fill 0x480 dwords (0x1200 bytes) + ndwords = (unsigned long)((pWork->out_buff - (char *)pWork->offs0DC8 + 1) >> 2); + if(ndwords <= 1) + ndwords = 1; + memset(pWork->offs0DC8, 0, ndwords << 2); + + for(puncmp = uncmp_data; work_end > puncmp; puncmp++) + pWork->offs0DC8[(puncmp[0] * 4) + (puncmp[1] * 5)]++; + + add = 0; + for(pin0DC8 = pWork->offs0DC8; pin0DC8 < &pWork->offs1FC8; pin0DC8++) + { + add += *pin0DC8; + *pin0DC8 = (unsigned short)add; + } + + for(work_end--; work_end >= uncmp_data; work_end--) + { + offs1 = (work_end[0] * 4) + (work_end[1] * 5); // EAX + offs2 = (unsigned long)(work_end - pWork->work_buff); // EDI + + pWork->offs0DC8[offs1]--; + pWork->offs49D0[pWork->offs0DC8[offs1]] = (unsigned short)offs2; + } +} + +static void FlushBuf(TCmpStruct * pWork) +{ + unsigned char save_ch1; + unsigned char save_ch2; + unsigned int size = 0x800; + + pWork->write_buf(pWork->out_buff, &size, pWork->param); + + save_ch1 = pWork->out_buff[0x800]; + save_ch2 = pWork->out_buff[pWork->out_bytes]; + pWork->out_bytes -= 0x800; + + lmemset(pWork->out_buff, 0, 0x802); + + if(pWork->out_bytes != 0) + pWork->out_buff[0] = save_ch1; + if(pWork->out_bits != 0) + pWork->out_buff[pWork->out_bytes] = save_ch2; +} + +static void OutputBits(TCmpStruct * pWork, unsigned int nbits, unsigned long bit_buff) +{ + unsigned int out_bits; + + // If more than 8 bits to output, do recursion + if(nbits > 8) + { + OutputBits(pWork, 8, bit_buff); + bit_buff >>= 8; + nbits -= 8; + } + + // Add bits to the last out byte in out_buff; + out_bits = pWork->out_bits; + pWork->out_buff[pWork->out_bytes] |= (unsigned char)(bit_buff << out_bits); + pWork->out_bits += nbits; + + // If 8 or more bits, increment number of bytes + if(pWork->out_bits > 8) + { + pWork->out_bytes++; + bit_buff >>= (8 - out_bits); + + pWork->out_buff[pWork->out_bytes] = (unsigned char)bit_buff; + pWork->out_bits &= 7; + } + else + { + pWork->out_bits &= 7; + if(pWork->out_bits == 0) + pWork->out_bytes++; + } + + // If there is enough compressed bytes, flush them + if(pWork->out_bytes >= 0x800) + FlushBuf(pWork); +} + +static unsigned long FindRep(TCmpStruct * pWork, unsigned char * srcbuff) +{ + unsigned short esp12; + unsigned char * esp14; + unsigned short esp18; + unsigned char * srcbuff2; + unsigned char esp20; + + unsigned char * srcbuff3; + unsigned short * pin0DC8; + unsigned char * pin27CC; + unsigned short * pin49D0; + unsigned long nreps = 1; // EAX + unsigned long ebx, esi; + unsigned short di; + + pin0DC8 = pWork->offs0DC8 + (srcbuff[0] * 4) + (srcbuff[1] * 5); + esi = (unsigned long)(srcbuff - pWork->dsize_bytes - pWork->work_buff + 1); + esp18 = *pin0DC8; + pin49D0 = pWork->offs49D0 + esp18; + + if(*pin49D0 < esi) + { + while(*pin49D0 < esi) + { + pin49D0++; + esp18++; + } + *pin0DC8 = esp18; + } +//--------------------------------------------------------------------------- + srcbuff2 = srcbuff - 1; + pin49D0 = pWork->offs49D0 + esp18; + pin27CC = pWork->work_buff + *pin49D0; + if(srcbuff2 <= pin27CC) + return 0; +//--------------------------------------------------------------------------- + srcbuff3 = srcbuff; + for(;;) + { + if(srcbuff3[nreps-1] == pin27CC[nreps-1] && *srcbuff3 == *pin27CC) + { + // + // The following code does not work when compiled with MSVC.NET 2003 + // optimizing compiler. We have to switch the optimizations off to make it work + // I found that in debug version (where the optimizations are off), the value + // of "pin27CC" gets incremented twice (once at below, once in the "for" loop) + // + + pin27CC++; + srcbuff3++; + + for(ebx = 2; ebx < DICT_OFFSET; ebx++) + { + pin27CC++; + srcbuff3++; + if(*pin27CC != *srcbuff3) + break; + } + + srcbuff3 = srcbuff; + if(ebx >= nreps) + { + pWork->offs0000 = (unsigned int)(srcbuff3 - pin27CC + ebx - 1); + if((nreps = ebx) > 10) + break; + } + } + + pin49D0++; + esp18++; + pin27CC = pWork->work_buff + *pin49D0; + + if(srcbuff2 > pin27CC) + continue; + + return (nreps >= 2) ? nreps : 0; + } +//--------------------------------------------------------------------------- + if(ebx == DICT_OFFSET) + { + pWork->offs0000--; + return ebx; + } +//--------------------------------------------------------------------------- + pin49D0 = pWork->offs49D0 + esp18; + if(pWork->work_buff + pin49D0[1] >= srcbuff2) + return nreps; +//--------------------------------------------------------------------------- + di = 0; + pWork->offs09BC[0] = 0xFFFF; + pWork->offs09BC[1] = di; + esp12 = 1; + + do + { + esi = di; + if(srcbuff[esp12] != srcbuff[esi]) + { + di = pWork->offs09BC[esi]; + if(di != 0xFFFF) + continue; + } + pWork->offs09BC[++esp12] = ++di; + } + while(esp12 < nreps); +//--------------------------------------------------------------------------- + esi = nreps; + pin27CC = pWork->work_buff + pin49D0[0] + nreps; + esp14 = pin27CC; + + for(;;) // 0040268B + { + esi = pWork->offs09BC[esi]; + if(esi == 0xFFFF) + esi = 0; + + pin49D0 = pWork->offs49D0 + esp18; + do + { + pin49D0++; + esp18++; + pin27CC = pWork->work_buff + pin49D0[0]; + if(pin27CC >= srcbuff2) + return nreps; + } + while(pin27CC + esi < esp14); +//--------------------------------------------------------------------------- + esp20 = srcbuff[nreps - 2]; + if(esp20 == pin27CC[nreps - 2]) + { + if(pin27CC + esi != esp14) + { + esp14 = pin27CC; + esi = 0; + } + } + else + { + pin49D0 = pWork->offs49D0 + esp18; + do + { + pin49D0++; + esp18++; + pin27CC = pWork->work_buff + pin49D0[0]; + if(pin27CC >= srcbuff2) + return nreps; + } + while(pin27CC[nreps - 2] != esp20 || pin27CC[0] != *srcbuff); + + esp14 = pin27CC + 2; + esi = 2; + } +//--------------------------------------------------------------------------- + for(; esp14[0] == srcbuff[esi]; esp14++) + { + if(++esi >= DICT_OFFSET) + break; + } + + if(esi < nreps) + continue; + pWork->offs0000 = (unsigned int)(srcbuff - pin27CC - 1); + if(esi <= nreps) + continue; + nreps = esi; + if(esi == DICT_OFFSET) + return nreps; + + do + { + if(srcbuff[esp12] != srcbuff[di]) + { + di = pWork->offs09BC[di]; + if(di != 0xFFFF) + continue; + } + pWork->offs09BC[++esp12] = ++di; + } + while(esp12 < esi); + } +} + +static void WriteCmpData(TCmpStruct * pWork) +{ + unsigned int nreps = 0; // ESP+10 : Number of repeats + unsigned char * uncmp_end; // ESP+14 : End of uncompressed data + unsigned int esp18 = 0; // ESP+18 : + unsigned int bytes_required; // ESP+1C : Number of bytes required to read + unsigned int esp20 = 0; // ESP+20 : + unsigned char * uncmp_begin = pWork->work_buff + UNCMP_OFFSET; // EDI + unsigned long nreps1; + unsigned long save_offs0000 = 0; + + // Store the compression type and dictionary size + pWork->out_buff[0] = (char)pWork->ctype; + pWork->out_buff[1] = (char)pWork->dsize_bits; + pWork->out_bytes = 2; + + // Reset output buffer to zero + lmemset(&pWork->out_buff[2], 0, sizeof(pWork->out_buff) - 2); + pWork->out_bits = 0; + + do + { + int total_loaded = 0; + + for(bytes_required = 0x1000; bytes_required != 0; ) + { + int loaded = pWork->read_buf((char *)pWork->work_buff + UNCMP_OFFSET + total_loaded, + &bytes_required, pWork->param); + + if(loaded == 0) + { + if(total_loaded == 0 && esp20 == 0) + goto __Exit; + esp18 = 1; + break; + } + else + { + total_loaded += loaded; + bytes_required -= loaded; + } + } + + uncmp_end = pWork->work_buff + pWork->dsize_bytes + total_loaded; + if(esp18 != 0) + uncmp_end += DICT_OFFSET; + + // + // Warning: Passing "uncmp_end + 1" to the SortBuffer function may cause + // the output to be unpredictable in Storm.dll's compression. Because Storm.dll + // does not pass the zeroed buffer to the "implode" function, the byte after + // uncmp_end contains random data. This causes difference within dictionary + // created in SortBuffer function and may also cause different compressed output. + // We always zero the data before compression, so this thing never occurs. + // Funny is that it is actually not a bug, because if we decompress the data back, + // we'll get the identical data with the original input. + // + switch(esp20) + { + case 0: + SortBuffer(pWork, uncmp_begin, uncmp_end + 1); + esp20++; + if(pWork->dsize_bytes != 0x1000) + esp20++; + break; + + case 1: + SortBuffer(pWork, uncmp_begin - pWork->dsize_bytes + DICT_OFFSET, uncmp_end + 1); + esp20++; + break; + + default: + SortBuffer(pWork, uncmp_begin - pWork->dsize_bytes, uncmp_end + 1); + break; + } + + while(uncmp_end > uncmp_begin) + { + nreps1 = FindRep(pWork, uncmp_begin); + while(nreps1 != 0) + { + if(nreps1 == 2 && pWork->offs0000 >= 0x100) + break; + + if(esp18 != 0 && uncmp_begin + nreps1 > uncmp_end) + goto _004022DB; + + if(nreps1 >= 8 || uncmp_begin + 1 >= uncmp_end) + goto _004022FF; + + save_offs0000 = pWork->offs0000; // ebp + nreps = nreps1; + nreps1 = FindRep(pWork, uncmp_begin + 1); + + if(nreps >= nreps1) + goto _004022F9; + + if(nreps + 1 >= nreps1 && save_offs0000 <= 0x80) + goto _004022F9; + + OutputBits(pWork, pWork->nChBits[*uncmp_begin], pWork->nChCodes[*uncmp_begin]); + uncmp_begin++; + } + +_0040222F: + OutputBits(pWork, pWork->nChBits[*uncmp_begin], pWork->nChCodes[*uncmp_begin]); + uncmp_begin++; +_00402252:; + } + + if(esp18 == 0) + { + uncmp_begin -= 0x1000; + lmemcpy(pWork->work_buff, pWork->work_buff + 0x1000, pWork->dsize_bytes + DICT_OFFSET); + } + } + while(esp18 == 0); + +__Exit: + OutputBits(pWork, pWork->nChBits[0x305], pWork->nChCodes[0x305]); + if(pWork->out_bits != 0) + pWork->out_bytes++; + pWork->write_buf(pWork->out_buff, &pWork->out_bytes, pWork->param); + return; + +_004022DB: + nreps1 = (unsigned long)(uncmp_end - uncmp_begin); + if(nreps1 < 2) + goto _0040222F; + + if(nreps1 != 2 || pWork->offs0000 < 0x100) + goto _004022FF; + goto _0040222F; + +_004022F9: + nreps1 = nreps; + pWork->offs0000 = save_offs0000; + +_004022FF: + OutputBits(pWork, pWork->nChBits[nreps1 + 0xFE], pWork->nChCodes[nreps1 + 0xFE]); + + if(nreps1 == 2) + { + OutputBits(pWork, pWork->dist_bits[pWork->offs0000 >> 2], + pWork->dist_codes[pWork->offs0000 >> 2]); + OutputBits(pWork, 2, pWork->offs0000 & 3); + } + else + { + OutputBits(pWork, pWork->dist_bits[pWork->offs0000 >> pWork->dsize_bits], + pWork->dist_codes[pWork->offs0000 >> pWork->dsize_bits]); + OutputBits(pWork, pWork->dsize_bits, pWork->dsize_mask & pWork->offs0000); + } + uncmp_begin += nreps1; + goto _00402252; +} + +//----------------------------------------------------------------------------- +// Main imploding function + +unsigned int PKEXPORT implode( + unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), + void (*write_buf)(char *buf, unsigned int *size, void *param), + char *work_buf, + void *param, + unsigned int *type, + unsigned int *dsize) +{ + TCmpStruct * pWork = (TCmpStruct *)work_buf; + unsigned int nChCode; + unsigned int nCount; + unsigned int i; + + // Initialize the work buffer. This is not in the Pklib, + // but it seems to be a bug. Storm always pre-fills the data with zeros, + // and always compresses one block only. So the bug will not appear. + // But when a larger data block (size > 0x1000) is compressed, + // it may fail. + memset(pWork, 0, sizeof(TCmpStruct)); + + // Fill the work buffer information + pWork->read_buf = read_buf; + pWork->write_buf = write_buf; + pWork->dsize_bytes = *dsize; + pWork->ctype = *type; + pWork->param = param; + pWork->dsize_bits = 4; + pWork->dsize_mask = 0x0F; + + // Test dictionary size + switch(*dsize) + { + case 0x1000 : + pWork->dsize_bits++; + pWork->dsize_mask |= 0x20; + // No break here !!! + + case 0x0800 : + pWork->dsize_bits++; + pWork->dsize_mask |= 0x10; + // No break here !!! + + case 0x0400 : + break; + + default: + return CMP_INVALID_DICTSIZE; + } + + // Test the compression type + switch(*type) + { + case CMP_BINARY: // We will compress data with binary compression type + for(nChCode = 0, nCount = 0; nCount < 0x100; nCount++) + { + pWork->nChBits[nCount] = 9; + pWork->nChCodes[nCount] = (unsigned short)nChCode; + nChCode = (nChCode & 0x0000FFFF) + 2; + } + break; + + + case CMP_ASCII: // We will compress data with ASCII compression type + for(nCount = 0; nCount < 0x100; nCount++) + { + pWork->nChBits[nCount] = (unsigned char )(ChBitsAsc[nCount] + 1); + pWork->nChCodes[nCount] = (unsigned short)(ChCodeAsc[nCount] * 2); + } + break; + + default: + return CMP_INVALID_MODE; + } + + for(i = 0; i < 0x10; i++) + { + int nCount2 = 0; // EBX + + if((1 << ExLenBits[i]) == 0) + continue; + + do + { + pWork->nChBits[nCount] = (unsigned char)(ExLenBits[i] + LenBits[i] + 1); + pWork->nChCodes[nCount] = (unsigned short)((nCount2 << (LenBits[i] + 1)) | ((LenCode[i] & 0xFFFF00FF) * 2) | 1); + + nCount2++; + nCount++; + } + while((1 << ExLenBits[i]) > nCount2); + } + + // Copy the distance codes and distance bits and perform the compression + lmemcpy(&pWork->dist_codes, DistCode, sizeof(DistCode)); + lmemcpy(&pWork->dist_bits, DistBits, sizeof(DistBits)); + WriteCmpData(pWork); + return CMP_NO_ERROR; +} diff --git a/src/tools/stuffextract/StormLib/pklib/pklib.h b/src/tools/stuffextract/StormLib/pklib/pklib.h index 5bb8ffc..881262e 100644 --- a/src/tools/stuffextract/StormLib/pklib/pklib.h +++ b/src/tools/stuffextract/StormLib/pklib/pklib.h @@ -1,137 +1,137 @@ -/*****************************************************************************/ -/* pklib.h Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Header file for PKWARE Data Compression Library */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 31.03.03 1.00 Lad The first version of pkware.h */ -/*****************************************************************************/ - -#ifndef __PKLIB_H__ -#define __PKLIB_H__ - -#include "../StormPort.h" - -//----------------------------------------------------------------------------- -// Defines - -#define CMP_BINARY 0 // Binary compression -#define CMP_ASCII 1 // Ascii compression - -#define CMP_NO_ERROR 0 -#define CMP_INVALID_DICTSIZE 1 -#define CMP_INVALID_MODE 2 -#define CMP_BAD_DATA 3 -#define CMP_ABORT 4 - -//----------------------------------------------------------------------------- -// Define calling convention - -#ifndef PKEXPORT -#define PKEXPORT //__cdecl // Use for normal __cdecl calling -#endif -//#define PKEXPORT __stdcall -//#define PKEXPORT __fastcall - -//----------------------------------------------------------------------------- -// Internal structures - -// Compression structure -typedef struct -{ - unsigned int offs0000; // 0000 : - unsigned int out_bytes; // 0004 : # bytes available in out_buff - unsigned int out_bits; // 0008 : # of bits available in the last out byte - unsigned int dsize_bits; // 000C : Dict size : 4=0x400, 5=0x800, 6=0x1000 - unsigned int dsize_mask; // 0010 : Dict size : 0x0F=0x400, 0x1F=0x800, 0x3F=0x1000 - unsigned int ctype; // 0014 : Compression type (Ascii or binary) - unsigned int dsize_bytes; // 0018 : Dictionary size in bytes - unsigned char dist_bits[0x40]; // 001C : Distance bits - unsigned char dist_codes[0x40]; // 005C : Distance codes - unsigned char nChBits[0x306]; // 009C : - unsigned short nChCodes[0x306]; // 03A2 : - unsigned short offs09AE; // 09AE : - - void * param; // 09B0 : User parameter - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); // 9B4 - void (*write_buf)(char *buf, unsigned int *size, void *param); // 9B8 - - unsigned short offs09BC[0x204]; // 09BC : - unsigned long offs0DC4; // 0DC4 : - unsigned short offs0DC8[0x900]; // 0DC8 : - unsigned short offs1FC8; // 1FC8 : - char out_buff[0x802]; // 1FCA : Output (compressed) data - unsigned char work_buff[0x2204]; // 27CC : Work buffer - // + DICT_OFFSET => Dictionary - // + UNCMP_OFFSET => Uncompressed data - unsigned short offs49D0[0x2000]; // 49D0 : -} TCmpStruct; - -#define CMP_BUFFER_SIZE sizeof(TCmpStruct) // Size of compression buffer - - -// Decompression structure -typedef struct -{ - unsigned long offs0000; // 0000 - unsigned long ctype; // 0004 - Compression type (CMP_BINARY or CMP_ASCII) - unsigned long outputPos; // 0008 - Position in output buffer - unsigned long dsize_bits; // 000C - Dict size (4, 5, 6 for 0x400, 0x800, 0x1000) - unsigned long dsize_mask; // 0010 - Dict size bitmask (0x0F, 0x1F, 0x3F for 0x400, 0x800, 0x1000) - unsigned long bit_buff; // 0014 - 16-bit buffer for processing input data - unsigned long extra_bits; // 0018 - Number of extra (above 8) bits in bit buffer - unsigned int in_pos; // 001C - Position in in_buff - unsigned long in_bytes; // 0020 - Number of bytes in input buffer - void * param; // 0024 - Custom parameter - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); // 0028 - void (*write_buf)(char *buf, unsigned int *size, void *param);// 002C - unsigned char out_buff[0x2000]; // 0030 - Output circle buffer. Starting position is 0x1000 - unsigned char offs2030[0x204]; // 2030 - ??? - unsigned char in_buff[0x800]; // 2234 - Buffer for data to be decompressed - unsigned char position1[0x100]; // 2A34 - Positions in buffers - unsigned char position2[0x100]; // 2B34 - Positions in buffers - unsigned char offs2C34[0x100]; // 2C34 - Buffer for - unsigned char offs2D34[0x100]; // 2D34 - Buffer for - unsigned char offs2E34[0x80]; // 2EB4 - Buffer for - unsigned char offs2EB4[0x100]; // 2EB4 - Buffer for - unsigned char ChBitsAsc[0x100]; // 2FB4 - Buffer for - unsigned char DistBits[0x40]; // 30B4 - Numbers of bytes to skip copied block length - unsigned char LenBits[0x10]; // 30F4 - Numbers of bits for skip copied block length - unsigned char ExLenBits[0x10]; // 3104 - Number of valid bits for copied block - unsigned short LenBase[0x10]; // 3114 - Buffer for -} TDcmpStruct; - -#define EXP_BUFFER_SIZE sizeof(TDcmpStruct) // Size of decompress buffer - -//----------------------------------------------------------------------------- -// Public functions - -#ifdef __cplusplus - extern "C" { -#endif - -unsigned int PKEXPORT implode( - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), - void (*write_buf)(char *buf, unsigned int *size, void *param), - char *work_buf, - void *param, - unsigned int *type, - unsigned int *dsize); - - -unsigned int PKEXPORT explode( - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), - void (*write_buf)(char *buf, unsigned int *size, void *param), - char *work_buf, - void *param); - -// The original name "crc32" was changed to "crc32pk" due -// to compatibility with zlib -unsigned long PKEXPORT crc32pk(char *buffer, unsigned int *size, unsigned long *old_crc); - -#ifdef __cplusplus - } // End of 'extern "C"' declaration -#endif - -#endif // __PKLIB_H__ +/*****************************************************************************/ +/* pklib.h Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* Header file for PKWARE Data Compression Library */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 31.03.03 1.00 Lad The first version of pkware.h */ +/*****************************************************************************/ + +#ifndef __PKLIB_H__ +#define __PKLIB_H__ + +#include "../StormPort.h" + +//----------------------------------------------------------------------------- +// Defines + +#define CMP_BINARY 0 // Binary compression +#define CMP_ASCII 1 // Ascii compression + +#define CMP_NO_ERROR 0 +#define CMP_INVALID_DICTSIZE 1 +#define CMP_INVALID_MODE 2 +#define CMP_BAD_DATA 3 +#define CMP_ABORT 4 + +//----------------------------------------------------------------------------- +// Define calling convention + +#ifndef PKEXPORT +#define PKEXPORT //__cdecl // Use for normal __cdecl calling +#endif +//#define PKEXPORT __stdcall +//#define PKEXPORT __fastcall + +//----------------------------------------------------------------------------- +// Internal structures + +// Compression structure +typedef struct +{ + unsigned int offs0000; // 0000 : + unsigned int out_bytes; // 0004 : # bytes available in out_buff + unsigned int out_bits; // 0008 : # of bits available in the last out byte + unsigned int dsize_bits; // 000C : Dict size : 4=0x400, 5=0x800, 6=0x1000 + unsigned int dsize_mask; // 0010 : Dict size : 0x0F=0x400, 0x1F=0x800, 0x3F=0x1000 + unsigned int ctype; // 0014 : Compression type (Ascii or binary) + unsigned int dsize_bytes; // 0018 : Dictionary size in bytes + unsigned char dist_bits[0x40]; // 001C : Distance bits + unsigned char dist_codes[0x40]; // 005C : Distance codes + unsigned char nChBits[0x306]; // 009C : + unsigned short nChCodes[0x306]; // 03A2 : + unsigned short offs09AE; // 09AE : + + void * param; // 09B0 : User parameter + unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); // 9B4 + void (*write_buf)(char *buf, unsigned int *size, void *param); // 9B8 + + unsigned short offs09BC[0x204]; // 09BC : + unsigned long offs0DC4; // 0DC4 : + unsigned short offs0DC8[0x900]; // 0DC8 : + unsigned short offs1FC8; // 1FC8 : + char out_buff[0x802]; // 1FCA : Output (compressed) data + unsigned char work_buff[0x2204]; // 27CC : Work buffer + // + DICT_OFFSET => Dictionary + // + UNCMP_OFFSET => Uncompressed data + unsigned short offs49D0[0x2000]; // 49D0 : +} TCmpStruct; + +#define CMP_BUFFER_SIZE sizeof(TCmpStruct) // Size of compression buffer + + +// Decompression structure +typedef struct +{ + unsigned long offs0000; // 0000 + unsigned long ctype; // 0004 - Compression type (CMP_BINARY or CMP_ASCII) + unsigned long outputPos; // 0008 - Position in output buffer + unsigned long dsize_bits; // 000C - Dict size (4, 5, 6 for 0x400, 0x800, 0x1000) + unsigned long dsize_mask; // 0010 - Dict size bitmask (0x0F, 0x1F, 0x3F for 0x400, 0x800, 0x1000) + unsigned long bit_buff; // 0014 - 16-bit buffer for processing input data + unsigned long extra_bits; // 0018 - Number of extra (above 8) bits in bit buffer + unsigned int in_pos; // 001C - Position in in_buff + unsigned long in_bytes; // 0020 - Number of bytes in input buffer + void * param; // 0024 - Custom parameter + unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); // 0028 + void (*write_buf)(char *buf, unsigned int *size, void *param);// 002C + unsigned char out_buff[0x2000]; // 0030 - Output circle buffer. Starting position is 0x1000 + unsigned char offs2030[0x204]; // 2030 - ??? + unsigned char in_buff[0x800]; // 2234 - Buffer for data to be decompressed + unsigned char position1[0x100]; // 2A34 - Positions in buffers + unsigned char position2[0x100]; // 2B34 - Positions in buffers + unsigned char offs2C34[0x100]; // 2C34 - Buffer for + unsigned char offs2D34[0x100]; // 2D34 - Buffer for + unsigned char offs2E34[0x80]; // 2EB4 - Buffer for + unsigned char offs2EB4[0x100]; // 2EB4 - Buffer for + unsigned char ChBitsAsc[0x100]; // 2FB4 - Buffer for + unsigned char DistBits[0x40]; // 30B4 - Numbers of bytes to skip copied block length + unsigned char LenBits[0x10]; // 30F4 - Numbers of bits for skip copied block length + unsigned char ExLenBits[0x10]; // 3104 - Number of valid bits for copied block + unsigned short LenBase[0x10]; // 3114 - Buffer for +} TDcmpStruct; + +#define EXP_BUFFER_SIZE sizeof(TDcmpStruct) // Size of decompress buffer + +//----------------------------------------------------------------------------- +// Public functions + +#ifdef __cplusplus + extern "C" { +#endif + +unsigned int PKEXPORT implode( + unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), + void (*write_buf)(char *buf, unsigned int *size, void *param), + char *work_buf, + void *param, + unsigned int *type, + unsigned int *dsize); + + +unsigned int PKEXPORT explode( + unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), + void (*write_buf)(char *buf, unsigned int *size, void *param), + char *work_buf, + void *param); + +// The original name "crc32" was changed to "crc32pk" due +// to compatibility with zlib +unsigned long PKEXPORT crc32pk(char *buffer, unsigned int *size, unsigned long *old_crc); + +#ifdef __cplusplus + } // End of 'extern "C"' declaration +#endif + +#endif // __PKLIB_H__ diff --git a/src/tools/stuffextract/StormLib/wave/wave.cpp b/src/tools/stuffextract/StormLib/wave/wave.cpp index 2b6c12b..936525f 100644 --- a/src/tools/stuffextract/StormLib/wave/wave.cpp +++ b/src/tools/stuffextract/StormLib/wave/wave.cpp @@ -1,356 +1,356 @@ -/*****************************************************************************/ -/* wave.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* This module contains decompression methods used by Storm.dll to decompress*/ -/* WAVe files. Thanks to Tom Amigo for releasing his sources. */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 11.03.03 1.00 Lad Splitted from Pkware.cpp */ -/* 20.05.03 2.00 Lad Added compression */ -/* 19.11.03 2.01 Dan Big endian handling */ -/*****************************************************************************/ - -#include "wave.h" - -//------------------------------------------------------------------------------ -// Structures - -union TByteAndWordPtr -{ - short * pw; - unsigned char * pb; -}; - -union TWordAndByteArray -{ - short w; - unsigned char b[2]; -}; - -//----------------------------------------------------------------------------- -// Tables necessary dor decompression - -static long Table1503F120[] = -{ - 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000006, - 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, - 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, - 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000006, 0xFFFFFFFF, 0x00000008 -}; - -static long Table1503F1A0[] = -{ - 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, - 0x00000010, 0x00000011, 0x00000013, 0x00000015, 0x00000017, 0x00000019, 0x0000001C, 0x0000001F, - 0x00000022, 0x00000025, 0x00000029, 0x0000002D, 0x00000032, 0x00000037, 0x0000003C, 0x00000042, - 0x00000049, 0x00000050, 0x00000058, 0x00000061, 0x0000006B, 0x00000076, 0x00000082, 0x0000008F, - 0x0000009D, 0x000000AD, 0x000000BE, 0x000000D1, 0x000000E6, 0x000000FD, 0x00000117, 0x00000133, - 0x00000151, 0x00000173, 0x00000198, 0x000001C1, 0x000001EE, 0x00000220, 0x00000256, 0x00000292, - 0x000002D4, 0x0000031C, 0x0000036C, 0x000003C3, 0x00000424, 0x0000048E, 0x00000502, 0x00000583, - 0x00000610, 0x000006AB, 0x00000756, 0x00000812, 0x000008E0, 0x000009C3, 0x00000ABD, 0x00000BD0, - 0x00000CFF, 0x00000E4C, 0x00000FBA, 0x0000114C, 0x00001307, 0x000014EE, 0x00001706, 0x00001954, - 0x00001BDC, 0x00001EA5, 0x000021B6, 0x00002515, 0x000028CA, 0x00002CDF, 0x0000315B, 0x0000364B, - 0x00003BB9, 0x000041B2, 0x00004844, 0x00004F7E, 0x00005771, 0x0000602F, 0x000069CE, 0x00007462, - 0x00007FFF -}; - -//---------------------------------------------------------------------------- -// CompressWave - -// 1500EF70 -int CompressWave(unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffer, int dwInLength, int nChannels, int nCmpLevel) -// ECX EDX -{ - TWordAndByteArray Wcmp; - TByteAndWordPtr out; // Pointer to the output buffer - long SInt32Array1[2]; - long SInt32Array2[2]; - long SInt32Array3[2]; - long nBytesRemains = dwOutLength; // Number of bytes remaining - long nWordsRemains; // Number of words remaining -// unsigned char * pbSaveOutBuffer; // Copy of output buffer (actually not used) - unsigned long dwBitBuff; - unsigned long dwStopBit; - unsigned long dwBit; - unsigned long ebx; - unsigned long esi; - long nTableValue; - long nOneWord; - long var_1C; - long var_2C; - int nLength; - int nIndex; - int nValue; - - // If less than 2 bytes remain, don't decompress anything -// pbSaveOutBuffer = pbOutBuffer; - out.pb = pbOutBuffer; - if(nBytesRemains < 2) - return 2; - - Wcmp.b[1] = (unsigned char)(nCmpLevel - 1); - Wcmp.b[0] = (unsigned char)0; - - *out.pw++ = BSWAP_INT16_SIGNED(Wcmp.w); - if((out.pb - pbOutBuffer + (nChannels * 2)) > nBytesRemains) - return (int)(out.pb - pbOutBuffer + (nChannels * 2)); - - SInt32Array1[0] = SInt32Array1[1] = 0x2C; - - for(int i = 0; i < nChannels; i++) - { - nOneWord = BSWAP_INT16_SIGNED(*pwInBuffer++); - *out.pw++ = BSWAP_INT16_SIGNED((short)nOneWord); - SInt32Array2[i] = nOneWord; - } - - // Weird. But it's there - nLength = dwInLength; - if(nLength < 0) // mov eax, dwInLength; cdq; sub eax, edx; - nLength++; - - nLength = (nLength / 2) - (int)(out.pb - pbOutBuffer); - nLength = (nLength < 0) ? 0 : nLength; - - nIndex = nChannels - 1; // edi - nWordsRemains = dwInLength / 2; // eax - - // ebx - nChannels - // ecx - pwOutPos - for(int chnl = nChannels; chnl < nWordsRemains; chnl++) - { - // 1500F030 - if((out.pb - pbOutBuffer + 2) > nBytesRemains) - return (int)(out.pb - pbOutBuffer + 2); - - // Switch index - if(nChannels == 2) - nIndex = (nIndex == 0) ? 1 : 0; - - // Load one word from the input stream - nOneWord = BSWAP_INT16_SIGNED(*pwInBuffer++); // ecx - nOneWord - SInt32Array3[nIndex] = nOneWord; - - // esi - SInt32Array2[nIndex] - // eax - nValue - nValue = nOneWord - SInt32Array2[nIndex]; - nValue = (nValue < 0) ? ((nValue ^ 0xFFFFFFFF) + 1) : nValue; - - ebx = (nOneWord >= SInt32Array2[nIndex]) ? 0 : 0x40; - - // esi - SInt32Array2[nIndex] - // edx - Table1503F1A0[SInt32Array2[nIndex]] - // edi - (Table1503F1A0[SInt32Array1[nIndex]] >> nCmpLevel) - nTableValue = Table1503F1A0[SInt32Array1[nIndex]]; - dwStopBit = (unsigned long)nCmpLevel; - - // edi - nIndex; - if(nValue < (nTableValue >> nCmpLevel)) - { - if(SInt32Array1[nIndex] != 0) - SInt32Array1[nIndex]--; - *out.pb++ = 0x80; - } - else - { - while(nValue > nTableValue * 2) - { - if(SInt32Array1[nIndex] >= 0x58 || nLength == 0) - break; - - SInt32Array1[nIndex] += 8; - if(SInt32Array1[nIndex] > 0x58) - SInt32Array1[nIndex] = 0x58; - - nTableValue = Table1503F1A0[SInt32Array1[nIndex]]; - *out.pb++ = 0x81; - nLength--; - } - - var_2C = nTableValue >> Wcmp.b[1]; - dwBitBuff = 0; - - esi = (1 << (dwStopBit - 2)); - dwStopBit = (esi <= 0x20) ? esi : 0x20; - - for(var_1C = 0, dwBit = 1; ; dwBit <<= 1) - { -// esi = var_1C + nTableValue; - if((var_1C + nTableValue) <= nValue) - { - var_1C += nTableValue; - dwBitBuff |= dwBit; - } - if(dwBit == dwStopBit) - break; - - nTableValue >>= 1; - } - - nValue = SInt32Array2[nIndex]; - if(ebx != 0) - { - nValue -= (var_1C + var_2C); - if(nValue < -32768) - nValue = -32768; - } - else - { - nValue += (var_1C + var_2C); - if(nValue > 32767) - nValue = 32767; - } - - SInt32Array2[nIndex] = nValue; - *out.pb++ = (unsigned char)(dwBitBuff | ebx); - nTableValue = Table1503F120[dwBitBuff & 0x1F]; - SInt32Array1[nIndex] = SInt32Array1[nIndex] + nTableValue; - if(SInt32Array1[nIndex] < 0) - SInt32Array1[nIndex] = 0; - else if(SInt32Array1[nIndex] > 0x58) - SInt32Array1[nIndex] = 0x58; - } - } - - return (int)(out.pb - pbOutBuffer); -} - -//---------------------------------------------------------------------------- -// DecompressWave - -// 1500F230 -int DecompressWave(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * pbInBuffer, int dwInLength, int nChannels) -{ - TByteAndWordPtr out; // Output buffer - TByteAndWordPtr in; - unsigned char * pbInBufferEnd = (pbInBuffer + dwInLength); - long SInt32Array1[2]; - long SInt32Array2[2]; - long nOneWord; - int dwOutLengthCopy = dwOutLength; - int nIndex; - - SInt32Array1[0] = SInt32Array1[1] = 0x2C; - out.pb = pbOutBuffer; - in.pb = pbInBuffer; - in.pw++; - - // Fill the Uint32Array2 array by channel values. - for(int i = 0; i < nChannels; i++) - { - nOneWord = BSWAP_INT16_SIGNED(*in.pw++); - SInt32Array2[i] = nOneWord; - if(dwOutLengthCopy < 2) - return (int)(out.pb - pbOutBuffer); - - *out.pw++ = BSWAP_INT16_SIGNED((short)nOneWord); - dwOutLengthCopy -= sizeof(short); - } - - // Get the initial index - nIndex = nChannels - 1; - - // Perform the decompression - while(in.pb < pbInBufferEnd) - { - unsigned char nOneByte = *in.pb++; - - // Switch index - if(nChannels == 2) - nIndex = (nIndex == 0) ? 1 : 0; - - // 1500F2A2: Get one byte from input buffer - if(nOneByte & 0x80) - { - switch(nOneByte & 0x7F) - { - case 0: // 1500F315 - if(SInt32Array1[nIndex] != 0) - SInt32Array1[nIndex]--; - - if(dwOutLengthCopy < 2) - return (int)(out.pb - pbOutBuffer); - - *out.pw++ = BSWAP_INT16_SIGNED((unsigned short)SInt32Array2[nIndex]); - dwOutLength -= sizeof(unsigned short); - break; - - case 1: // 1500F2E8 - SInt32Array1[nIndex] += 8; - if(SInt32Array1[nIndex] > 0x58) - SInt32Array1[nIndex] = 0x58; - - if(nChannels == 2) - nIndex = (nIndex == 0) ? 1 : 0; - break; - - case 2: // 1500F41E - break; - - default: // 1500F2C4 - SInt32Array1[nIndex] -= 8; - if(SInt32Array1[nIndex] < 0) - SInt32Array1[nIndex] = 0; - - if(nChannels == 2) - nIndex = (nIndex == 0) ? 1 : 0; - break; - } - } - else - { - // 1500F349 - long temp1 = Table1503F1A0[SInt32Array1[nIndex]]; // EDI - long temp2 = temp1 >> pbInBuffer[1]; // ESI - long temp3 = SInt32Array2[nIndex]; // ECX - - if(nOneByte & 0x01) // EBX = nOneByte - temp2 += (temp1 >> 0); - - if(nOneByte & 0x02) - temp2 += (temp1 >> 1); - - if(nOneByte & 0x04) - temp2 += (temp1 >> 2); - - if(nOneByte & 0x08) - temp2 += (temp1 >> 3); - - if(nOneByte & 0x10) - temp2 += (temp1 >> 4); - - if(nOneByte & 0x20) - temp2 += (temp1 >> 5); - - if(nOneByte & 0x40) - { - temp3 = temp3 - temp2; - if(temp3 <= -32768) - temp3 = -32768; - } - else - { - temp3 = temp3 + temp2; - if(temp3 >= 32767) - temp3 = 32767; - } - - SInt32Array2[nIndex] = temp3; - if(dwOutLength < 2) - break; - - // Store the output 16-bit value - *out.pw++ = BSWAP_INT16_SIGNED((short)SInt32Array2[nIndex]); - dwOutLength -= 2; - - SInt32Array1[nIndex] += Table1503F120[nOneByte & 0x1F]; - - if(SInt32Array1[nIndex] < 0) - SInt32Array1[nIndex] = 0; - else if(SInt32Array1[nIndex] > 0x58) - SInt32Array1[nIndex] = 0x58; - } - } - return (int)(out.pb - pbOutBuffer); -} +/*****************************************************************************/ +/* wave.cpp Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* This module contains decompression methods used by Storm.dll to decompress*/ +/* WAVe files. Thanks to Tom Amigo for releasing his sources. */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 11.03.03 1.00 Lad Splitted from Pkware.cpp */ +/* 20.05.03 2.00 Lad Added compression */ +/* 19.11.03 2.01 Dan Big endian handling */ +/*****************************************************************************/ + +#include "wave.h" + +//------------------------------------------------------------------------------ +// Structures + +union TByteAndWordPtr +{ + short * pw; + unsigned char * pb; +}; + +union TWordAndByteArray +{ + short w; + unsigned char b[2]; +}; + +//----------------------------------------------------------------------------- +// Tables necessary dor decompression + +static long Table1503F120[] = +{ + 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000006, + 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, + 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, + 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000006, 0xFFFFFFFF, 0x00000008 +}; + +static long Table1503F1A0[] = +{ + 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, + 0x00000010, 0x00000011, 0x00000013, 0x00000015, 0x00000017, 0x00000019, 0x0000001C, 0x0000001F, + 0x00000022, 0x00000025, 0x00000029, 0x0000002D, 0x00000032, 0x00000037, 0x0000003C, 0x00000042, + 0x00000049, 0x00000050, 0x00000058, 0x00000061, 0x0000006B, 0x00000076, 0x00000082, 0x0000008F, + 0x0000009D, 0x000000AD, 0x000000BE, 0x000000D1, 0x000000E6, 0x000000FD, 0x00000117, 0x00000133, + 0x00000151, 0x00000173, 0x00000198, 0x000001C1, 0x000001EE, 0x00000220, 0x00000256, 0x00000292, + 0x000002D4, 0x0000031C, 0x0000036C, 0x000003C3, 0x00000424, 0x0000048E, 0x00000502, 0x00000583, + 0x00000610, 0x000006AB, 0x00000756, 0x00000812, 0x000008E0, 0x000009C3, 0x00000ABD, 0x00000BD0, + 0x00000CFF, 0x00000E4C, 0x00000FBA, 0x0000114C, 0x00001307, 0x000014EE, 0x00001706, 0x00001954, + 0x00001BDC, 0x00001EA5, 0x000021B6, 0x00002515, 0x000028CA, 0x00002CDF, 0x0000315B, 0x0000364B, + 0x00003BB9, 0x000041B2, 0x00004844, 0x00004F7E, 0x00005771, 0x0000602F, 0x000069CE, 0x00007462, + 0x00007FFF +}; + +//---------------------------------------------------------------------------- +// CompressWave + +// 1500EF70 +int CompressWave(unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffer, int dwInLength, int nChannels, int nCmpLevel) +// ECX EDX +{ + TWordAndByteArray Wcmp; + TByteAndWordPtr out; // Pointer to the output buffer + long SInt32Array1[2]; + long SInt32Array2[2]; + long SInt32Array3[2]; + long nBytesRemains = dwOutLength; // Number of bytes remaining + long nWordsRemains; // Number of words remaining +// unsigned char * pbSaveOutBuffer; // Copy of output buffer (actually not used) + unsigned long dwBitBuff; + unsigned long dwStopBit; + unsigned long dwBit; + unsigned long ebx; + unsigned long esi; + long nTableValue; + long nOneWord; + long var_1C; + long var_2C; + int nLength; + int nIndex; + int nValue; + + // If less than 2 bytes remain, don't decompress anything +// pbSaveOutBuffer = pbOutBuffer; + out.pb = pbOutBuffer; + if(nBytesRemains < 2) + return 2; + + Wcmp.b[1] = (unsigned char)(nCmpLevel - 1); + Wcmp.b[0] = (unsigned char)0; + + *out.pw++ = BSWAP_INT16_SIGNED(Wcmp.w); + if((out.pb - pbOutBuffer + (nChannels * 2)) > nBytesRemains) + return (int)(out.pb - pbOutBuffer + (nChannels * 2)); + + SInt32Array1[0] = SInt32Array1[1] = 0x2C; + + for(int i = 0; i < nChannels; i++) + { + nOneWord = BSWAP_INT16_SIGNED(*pwInBuffer++); + *out.pw++ = BSWAP_INT16_SIGNED((short)nOneWord); + SInt32Array2[i] = nOneWord; + } + + // Weird. But it's there + nLength = dwInLength; + if(nLength < 0) // mov eax, dwInLength; cdq; sub eax, edx; + nLength++; + + nLength = (nLength / 2) - (int)(out.pb - pbOutBuffer); + nLength = (nLength < 0) ? 0 : nLength; + + nIndex = nChannels - 1; // edi + nWordsRemains = dwInLength / 2; // eax + + // ebx - nChannels + // ecx - pwOutPos + for(int chnl = nChannels; chnl < nWordsRemains; chnl++) + { + // 1500F030 + if((out.pb - pbOutBuffer + 2) > nBytesRemains) + return (int)(out.pb - pbOutBuffer + 2); + + // Switch index + if(nChannels == 2) + nIndex = (nIndex == 0) ? 1 : 0; + + // Load one word from the input stream + nOneWord = BSWAP_INT16_SIGNED(*pwInBuffer++); // ecx - nOneWord + SInt32Array3[nIndex] = nOneWord; + + // esi - SInt32Array2[nIndex] + // eax - nValue + nValue = nOneWord - SInt32Array2[nIndex]; + nValue = (nValue < 0) ? ((nValue ^ 0xFFFFFFFF) + 1) : nValue; + + ebx = (nOneWord >= SInt32Array2[nIndex]) ? 0 : 0x40; + + // esi - SInt32Array2[nIndex] + // edx - Table1503F1A0[SInt32Array2[nIndex]] + // edi - (Table1503F1A0[SInt32Array1[nIndex]] >> nCmpLevel) + nTableValue = Table1503F1A0[SInt32Array1[nIndex]]; + dwStopBit = (unsigned long)nCmpLevel; + + // edi - nIndex; + if(nValue < (nTableValue >> nCmpLevel)) + { + if(SInt32Array1[nIndex] != 0) + SInt32Array1[nIndex]--; + *out.pb++ = 0x80; + } + else + { + while(nValue > nTableValue * 2) + { + if(SInt32Array1[nIndex] >= 0x58 || nLength == 0) + break; + + SInt32Array1[nIndex] += 8; + if(SInt32Array1[nIndex] > 0x58) + SInt32Array1[nIndex] = 0x58; + + nTableValue = Table1503F1A0[SInt32Array1[nIndex]]; + *out.pb++ = 0x81; + nLength--; + } + + var_2C = nTableValue >> Wcmp.b[1]; + dwBitBuff = 0; + + esi = (1 << (dwStopBit - 2)); + dwStopBit = (esi <= 0x20) ? esi : 0x20; + + for(var_1C = 0, dwBit = 1; ; dwBit <<= 1) + { +// esi = var_1C + nTableValue; + if((var_1C + nTableValue) <= nValue) + { + var_1C += nTableValue; + dwBitBuff |= dwBit; + } + if(dwBit == dwStopBit) + break; + + nTableValue >>= 1; + } + + nValue = SInt32Array2[nIndex]; + if(ebx != 0) + { + nValue -= (var_1C + var_2C); + if(nValue < -32768) + nValue = -32768; + } + else + { + nValue += (var_1C + var_2C); + if(nValue > 32767) + nValue = 32767; + } + + SInt32Array2[nIndex] = nValue; + *out.pb++ = (unsigned char)(dwBitBuff | ebx); + nTableValue = Table1503F120[dwBitBuff & 0x1F]; + SInt32Array1[nIndex] = SInt32Array1[nIndex] + nTableValue; + if(SInt32Array1[nIndex] < 0) + SInt32Array1[nIndex] = 0; + else if(SInt32Array1[nIndex] > 0x58) + SInt32Array1[nIndex] = 0x58; + } + } + + return (int)(out.pb - pbOutBuffer); +} + +//---------------------------------------------------------------------------- +// DecompressWave + +// 1500F230 +int DecompressWave(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * pbInBuffer, int dwInLength, int nChannels) +{ + TByteAndWordPtr out; // Output buffer + TByteAndWordPtr in; + unsigned char * pbInBufferEnd = (pbInBuffer + dwInLength); + long SInt32Array1[2]; + long SInt32Array2[2]; + long nOneWord; + int dwOutLengthCopy = dwOutLength; + int nIndex; + + SInt32Array1[0] = SInt32Array1[1] = 0x2C; + out.pb = pbOutBuffer; + in.pb = pbInBuffer; + in.pw++; + + // Fill the Uint32Array2 array by channel values. + for(int i = 0; i < nChannels; i++) + { + nOneWord = BSWAP_INT16_SIGNED(*in.pw++); + SInt32Array2[i] = nOneWord; + if(dwOutLengthCopy < 2) + return (int)(out.pb - pbOutBuffer); + + *out.pw++ = BSWAP_INT16_SIGNED((short)nOneWord); + dwOutLengthCopy -= sizeof(short); + } + + // Get the initial index + nIndex = nChannels - 1; + + // Perform the decompression + while(in.pb < pbInBufferEnd) + { + unsigned char nOneByte = *in.pb++; + + // Switch index + if(nChannels == 2) + nIndex = (nIndex == 0) ? 1 : 0; + + // 1500F2A2: Get one byte from input buffer + if(nOneByte & 0x80) + { + switch(nOneByte & 0x7F) + { + case 0: // 1500F315 + if(SInt32Array1[nIndex] != 0) + SInt32Array1[nIndex]--; + + if(dwOutLengthCopy < 2) + return (int)(out.pb - pbOutBuffer); + + *out.pw++ = BSWAP_INT16_SIGNED((unsigned short)SInt32Array2[nIndex]); + dwOutLength -= sizeof(unsigned short); + break; + + case 1: // 1500F2E8 + SInt32Array1[nIndex] += 8; + if(SInt32Array1[nIndex] > 0x58) + SInt32Array1[nIndex] = 0x58; + + if(nChannels == 2) + nIndex = (nIndex == 0) ? 1 : 0; + break; + + case 2: // 1500F41E + break; + + default: // 1500F2C4 + SInt32Array1[nIndex] -= 8; + if(SInt32Array1[nIndex] < 0) + SInt32Array1[nIndex] = 0; + + if(nChannels == 2) + nIndex = (nIndex == 0) ? 1 : 0; + break; + } + } + else + { + // 1500F349 + long temp1 = Table1503F1A0[SInt32Array1[nIndex]]; // EDI + long temp2 = temp1 >> pbInBuffer[1]; // ESI + long temp3 = SInt32Array2[nIndex]; // ECX + + if(nOneByte & 0x01) // EBX = nOneByte + temp2 += (temp1 >> 0); + + if(nOneByte & 0x02) + temp2 += (temp1 >> 1); + + if(nOneByte & 0x04) + temp2 += (temp1 >> 2); + + if(nOneByte & 0x08) + temp2 += (temp1 >> 3); + + if(nOneByte & 0x10) + temp2 += (temp1 >> 4); + + if(nOneByte & 0x20) + temp2 += (temp1 >> 5); + + if(nOneByte & 0x40) + { + temp3 = temp3 - temp2; + if(temp3 <= -32768) + temp3 = -32768; + } + else + { + temp3 = temp3 + temp2; + if(temp3 >= 32767) + temp3 = 32767; + } + + SInt32Array2[nIndex] = temp3; + if(dwOutLength < 2) + break; + + // Store the output 16-bit value + *out.pw++ = BSWAP_INT16_SIGNED((short)SInt32Array2[nIndex]); + dwOutLength -= 2; + + SInt32Array1[nIndex] += Table1503F120[nOneByte & 0x1F]; + + if(SInt32Array1[nIndex] < 0) + SInt32Array1[nIndex] = 0; + else if(SInt32Array1[nIndex] > 0x58) + SInt32Array1[nIndex] = 0x58; + } + } + return (int)(out.pb - pbOutBuffer); +} diff --git a/src/tools/stuffextract/StormLib/wave/wave.h b/src/tools/stuffextract/StormLib/wave/wave.h index 96bdf43..81b5add 100644 --- a/src/tools/stuffextract/StormLib/wave/wave.h +++ b/src/tools/stuffextract/StormLib/wave/wave.h @@ -1,22 +1,22 @@ -/*****************************************************************************/ -/* Wave.h Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Header file for WAVe unplode functions */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 31.03.03 1.00 Lad The first version of Wave.h */ -/*****************************************************************************/ - -#ifndef __WAVE_H__ -#define __WAVE_H__ - -//----------------------------------------------------------------------------- -// Functions - -#include "../StormPort.h" - -int CompressWave (unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffer, int dwInLength, int nCmpType, int nChannels); -int DecompressWave(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * pbInBuffer, int dwInLength, int nChannels); - -#endif // __WAVE_H__ +/*****************************************************************************/ +/* Wave.h Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* Header file for WAVe unplode functions */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 31.03.03 1.00 Lad The first version of Wave.h */ +/*****************************************************************************/ + +#ifndef __WAVE_H__ +#define __WAVE_H__ + +//----------------------------------------------------------------------------- +// Functions + +#include "../StormPort.h" + +int CompressWave (unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffer, int dwInLength, int nCmpType, int nChannels); +int DecompressWave(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * pbInBuffer, int dwInLength, int nChannels); + +#endif // __WAVE_H__ diff --git a/src/tools/stuffextract/StuffExtract.cpp b/src/tools/stuffextract/StuffExtract.cpp index 722282e..c4c4451 100644 --- a/src/tools/stuffextract/StuffExtract.cpp +++ b/src/tools/stuffextract/StuffExtract.cpp @@ -1,699 +1,699 @@ -#include -#include -#define _COMMON_NO_THREADS -#include "common.h" -#include "Auth/MD5Hash.h" -#include "tools.h" -#include "MPQHelper.h" -#include "dbcfile.h" -#include "ADTFile.h" -#include "WDTFile.h" -#include "StuffExtract.h" -#include "DBCFieldData.h" -#include "Locale.h" - -std::map mapNames; -std::set texNames; -std::set modelNames; -std::set wmoNames; -std::set soundFileSet; - -// default config; SCPs are dont always -bool doMaps=true, doSounds=false, doTextures=false, doWmos=false, doModels=false, doMd5=true, doAutoclose=false; - - - -int main(int argc, char *argv[]) -{ - char input[200]; - printf("StuffExtract [version %u]\n",SE_VERSION); - printf("Use -help or -? to display help about command line arguments and config.\n\n",SE_VERSION); - ProcessCmdArgs(argc, argv); - PrintConfig(); - if(!GetLocale()) - { - printf("Enter your locale (enUS, enGB, deDE, ...) or leave blank to autodetect: "); - fgets(input,sizeof(input),stdin); - char loc[5]; - input[strlen(input)-1] = 0; - memcpy(loc,input,4); loc[4]=0; - SetLocale(loc); - } - if(GetLocale() && FileExists(std::string("Data/")+GetLocale()+"/locale-"+GetLocale()+".MPQ")) - { - printf("Locale \"%s\" seems valid, starting conversion...\n",GetLocale()); - CreateDir("stuffextract"); - CreateDir("stuffextract/data"); - ConvertDBC(); - if(doMaps) ExtractMaps(); - if(doTextures || doModels || doWmos) ExtractMapDependencies(); - if(doSounds) ExtractSoundFiles(); - //... - if (!doAutoclose) - printf("\n -- finished, press enter to exit --\n"); - } - else - { - printf("ERROR: Invalid locale \"%s\"! Press Enter to exit...\n",GetLocale()); - } - if (!doAutoclose) - fgets(input,sizeof(input),stdin); - - //while(true); - return 0; -} - -void ProcessCmdArgs(int argc, char *argv[]) -{ - bool on,help=false; - char *what; - for(int i = 1; i < argc; i++) - { - if(strlen(argv[i]) > 1) - { - if(argv[i][0] == '-') - on = false; - else if(argv[i][0] == '+') - on = true; - else if(!stricmp(argv[i],"/?") || !stricmp(argv[i],"/help")) - { - help = true; - break; - } - else - { - printf("Incorrect cmd arg: \"%s\"\n",argv[i]); - continue; - } - - what = argv[i]+1; // skip first byte (+/-) - if (!stricmp(what,"maps")) doMaps = on; - else if(!stricmp(what,"textures")) doTextures = on; - else if(!stricmp(what,"wmos")) doWmos = on; - else if(!stricmp(what,"models")) doModels = on; - else if(!stricmp(what,"sounds")) doSounds = on; - else if(!stricmp(what,"md5")) doMd5 = on; - else if(!stricmp(what,"autoclose")) doAutoclose = on; - // autodetect or use given locale. + or - as arg start doesnt matter here - else if(!strnicmp(what,"locale:",7)) - { - if(!stricmp(what+7,"auto")) - SetLocale(NULL); - else - SetLocale(what+7); - } - else if(!stricmp(what,"?") || !stricmp(what,"help")) - { - help = true; - break; - } - else - { - printf("Unknown cmd arg: \"%s\"\n",what); - } - } - } - // fix up wrong configs. not necessary but better for display. - // TODO: as soon as M2 model or WMO reading is done, extract those textures to, but independent from maps!! - if(!doMaps) - { - doTextures = false; - doWmos = false; - doModels = false; - } - if(help) - { - PrintHelp(); - printf("\n\n- Press any key to exit -\n"); - getchar(); - exit(0); - } -} - -void PrintConfig(void) -{ - printf("config: Do maps: %s\n",doMaps?"yes":"no"); - printf("config: Do textures: %s\n",doTextures?"yes":"no"); - printf("config: Do wmos: %s\n",doWmos?"yes":"no"); - printf("config: Do models: %s\n",doModels?"yes":"no"); - printf("config: Do sounds: %s\n",doSounds?"yes":"no"); - printf("config: Calc md5: %s\n",doMd5?"yes":"no"); - printf("config: Autoclose: %s\n",doAutoclose?"yes":"no"); -} - -void PrintHelp(void) -{ - printf("Usage information:\n\n"); - printf("Use + or - to turn a feature on or off.\n"); - printf("Features are:\n"); - printf("maps - map extraction\n"); - printf("textures - extract textures (requires maps extraction, for now)\n"); - printf("wmos - extract map WMOs (requires maps extraction)\n"); - printf("models - extract models (required maps extraction, for now)\n"); - printf("sounds - extract sound files (wav/mp3)\n"); - printf("md5 - write MD5 checksum lists of extracted files\n"); - printf("autoclose - close program when done\n"); - printf("\n"); - printf("Use -locale:xxXX to set a locale. If you don't use this, you will be asked.\n"); - printf("Use -locale:auto to autodetect currently used locale.\n"); - printf("\n"); - printf("Examples:\n"); - printf("stuffextract +sounds +md5 -maps +autoclose -locale:enGB\n"); - printf("stuffextract +md5 -wmos -sounds -locale:auto -autoclose\n"); - printf("\nDefault is: +maps -sounds -textures -wmos -models +md5 -autoclose\n"); -} - - -// be careful using this, that you supply correct format string -std::string AutoGetDataString(DBCFile::Iterator& it, const char* format, uint32 field, bool skip_null = true) -{ - if(format[field]=='i') - { - if((*it).getInt(field) == 0 && skip_null) - return ""; // do not explicitly write int fields that are 0 - std::stringstream s; - s << (*it).getInt(field); - return s.str(); - } - else if(format[field]=='f') - { - if((*it).getFloat(field) == 0 && skip_null) - return ""; // do not explicitly write float fields that are 0 - std::stringstream s; - s << (*it).getFloat(field); - return s.str(); - } - else if(format[field]=='s' && (*it).getUInt(field)) - { - return (*it).getString(field); - } - - return ""; -} - - -// output a formatted scp file -void OutSCP(char *fn, SCPStorageMap& scp, std::string dbName="") -{ - std::fstream f; - f.open(fn, std::ios_base::out); - if(f.is_open()) - { - if(dbName.length()) - { - f << "#dbname=" << dbName << "\n"; - } - for(SCPStorageMap::iterator mi = scp.begin(); mi != scp.end(); mi++) - { - f << "[" << mi->first << "]\n"; - for(std::list::iterator li = mi->second.begin(); li != mi->second.end(); li++) - { - f << *li << "\n"; - } - f << "\n"; - } - f.close(); - } - else - { - printf("OutSCP: unable to write '%s'\n",fn); - } -} - -void OutMD5(char *path, MD5FileMap& fm) -{ - if(!doMd5) - return; - std::string fullname(path); - fullname += "/md5.txt"; - printf("Writing MD5 file checksums to '%s'\n",fullname.c_str()); - std::fstream fh; - fh.open(fullname.c_str(), std::ios_base::out); - if(fh.is_open()) - { - for(MD5FileMap::iterator i = fm.begin(); i != fm.end(); i++) - { - fh << i->first << "|" << toHexDump(i->second,MD5_DIGEST_LENGTH,false) << std::endl; // write file content - delete [] i->second; // and delete previously allocated memory - } - fh.close(); - } - else - { - printf("Couldn't output MD5 list to '%s'\n",fullname.c_str()); - } -} - - - - -bool ConvertDBC(void) -{ - std::map racemap; // needed to extract other dbc files correctly - SCPStorageMap EmoteDataStorage,RaceDataStorage,SoundDataStorage,MapDataStorage,ZoneDataStorage,ItemDisplayInfoStorage; // will store the converted data from dbc files - DBCFile EmotesText,EmotesTextData,EmotesTextSound,ChrRaces,SoundEntries,Map,AreaTable,ItemDisplayInfo; - printf("Opening DBC archive...\n"); - MPQHelper mpq("dbc"); - - printf("Opening DBC files...\n"); - EmotesText.openmem(mpq.ExtractFile("DBFilesClient\\EmotesText.dbc")); - EmotesTextData.openmem(mpq.ExtractFile("DBFilesClient\\EmotesTextData.dbc")); - EmotesTextSound.openmem(mpq.ExtractFile("DBFilesClient\\EmotesTextSound.dbc")); - ChrRaces.openmem(mpq.ExtractFile("DBFilesClient\\ChrRaces.dbc")); - SoundEntries.openmem(mpq.ExtractFile("DBFilesClient\\SoundEntries.dbc")); - Map.openmem(mpq.ExtractFile("DBFilesClient\\Map.dbc")); - AreaTable.openmem(mpq.ExtractFile("DBFilesClient\\AreaTable.dbc")); - ItemDisplayInfo.openmem(mpq.ExtractFile("DBFilesClient\\ItemDisplayInfo.dbc")); - //... - printf("DBC files opened.\n"); - //... - printf("Reading data: races.."); - for(DBCFile::Iterator it = ChrRaces.begin(); it != ChrRaces.end(); ++it) - { - uint32 id = (*it).getUInt(CHRRACES_RACEID); - racemap[id] = (*it).getString(CHRRACES_NAME_GENERAL); // for later use - for(uint32 field=CHRRACES_RACEID; field < CHARRACES_END; field++) - { - if(strlen(ChrRacesFieldNames[field])) - { - std::string value = AutoGetDataString(it,ChrRacesFormat,field); - if(!value.empty()) - RaceDataStorage[id].push_back(std::string(ChrRacesFieldNames[field]).append("=").append(value)); - } - } - } - - printf("emotes.."); - for(DBCFile::Iterator it = EmotesText.begin(); it != EmotesText.end(); ++it) - { - uint32 em = (*it).getUInt(EMOTESTEXT_EMOTE_ID); - EmoteDataStorage[em].push_back(std::string("name=") + (*it).getString(EMOTESTEXT_EMOTE_STRING)); - EmoteDataStorage[em].push_back(std::string("anim=") + toString( (*it).getUInt(EMOTESTEXT_ANIM)) ); - for(uint32 field=EMOTESTEXT_EMOTE_ID; fieldgetInt(MAP_ID)] = it->getString(MAP_NAME_GENERAL); - uint32 id = it->getUInt(MAP_ID); - for(uint32 field=MAP_ID; field < MAP_END; field++) - { - if(strlen(MapFieldNames[field])) - { - std::string value = AutoGetDataString(it,MapFormat,field); - if(value.size()) // only store if not null - MapDataStorage[id].push_back(std::string(MapFieldNames[field]) + "=" + value); - } - } - } - - printf("zonedata.."); - for(DBCFile::Iterator it = AreaTable.begin(); it != AreaTable.end(); ++it) - { - uint32 id = it->getUInt(MAP_ID); - for(uint32 field=AREATABLE_ID; field < AREATABLE_END; field++) - { - if(strlen(AreaTableFieldNames[field])) - { - std::string value = AutoGetDataString(it,AreaTableFormat,field,false); - if(value.size()) // only store if not null - ZoneDataStorage[id].push_back(std::string(AreaTableFieldNames[field]) + "=" + value); - } - } - } - - printf("itemdisplayinfo.."); - for(DBCFile::Iterator it = ItemDisplayInfo.begin(); it != ItemDisplayInfo.end(); ++it) - { - uint32 id = it->getUInt(ITEMDISPLAYINFO_ID); - for(uint32 field=ITEMDISPLAYINFO_ID; field < ITEMDISPLAYINFO_END; field++) - { - if(strlen(ItemDisplayInfoFieldNames[field])) - { - std::string value = AutoGetDataString(it,ItemDisplayInfoFormat,field); - if(value.size()) // only store if not null - ItemDisplayInfoStorage[id].push_back(std::string(ItemDisplayInfoFieldNames[field]) + "=" + value); - } - } - } - - - - //... - printf("DONE!\n"); - //... - - CreateDir("stuffextract/data/scp"); - - printf("Writing SCP files:\n"); - printf("emote.."); OutSCP(SCPDIR "/emote.scp",EmoteDataStorage, "emote"); - printf("race.."); OutSCP(SCPDIR "/race.scp",RaceDataStorage, "race"); - printf("sound.."); OutSCP(SCPDIR "/sound.scp",SoundDataStorage, "sound"); - printf("map.."); OutSCP(SCPDIR "/map.scp",MapDataStorage, "map"); - printf("area.."); OutSCP(SCPDIR "/zone.scp",ZoneDataStorage, "zone"); - printf("itemdisplayinfo."); OutSCP(SCPDIR "/itemdisplayinfo.scp",ItemDisplayInfoStorage, "itemdisplayinfo"); - //... - printf("DONE!\n"); - - // wait for all container destructors to finish - printf("DBC files converted, cleaning up...\n"); - - return true; -} - -void ExtractMaps(void) -{ - printf("\nExtracting maps...\n"); - char namebuf[200]; - char outbuf[2000]; - uint32 extr,extrtotal=0; - MPQHelper mpq("terrain"); - MD5FileMap md5map; - CreateDir("stuffextract/data/maps"); - for(std::map::iterator it = mapNames.begin(); it != mapNames.end(); it++) - { - // extract the WDT file that stores tile information - char wdt_name[300], wdt_out[300]; - sprintf(wdt_name,"World\\Maps\\%s\\%s.wdt",it->second.c_str(),it->second.c_str()); - sprintf(wdt_out,MAPSDIR"/%u.wdt",it->first); - ByteBuffer& wdt_bb = mpq.ExtractFile(wdt_name); - std::fstream wdt_fh; - wdt_fh.open(wdt_out, std::ios_base::out|std::ios_base::binary); - if(!wdt_fh.is_open()) - { - printf("\nERROR: Map extraction failed: could not save file %s\n",wdt_out); - return; - } - wdt_fh.write((char*)wdt_bb.contents(),wdt_bb.size()); - wdt_fh.close(); - - printf("Extracted WDT '%s'\n",wdt_name); - - // then extract all ADT files - extr=0; - for(uint32 x=0; x<64; x++) - { - for(uint32 y=0;y<64; y++) - { - uint32 olddeps; - uint32 depdiff; - sprintf(namebuf,"World\\Maps\\%s\\%s_%u_%u.adt",it->second.c_str(),it->second.c_str(),x,y); - sprintf(outbuf,MAPSDIR"/%u_%u_%u.adt",it->first,x,y); - if(mpq.FileExists(namebuf)) - { - ByteBuffer& bb = mpq.ExtractFile(namebuf); - if(bb.size()) - { - std::fstream fh; - //printf("Extracting map [ %s ]\n",outbuf); - fh.open(outbuf, std::ios_base::out|std::ios_base::binary); - if(!fh.is_open()) - { - printf("\nERROR: Map extraction failed: could not save file %s\n",outbuf); - return; - } - fh.write((char*)bb.contents(),bb.size()); - fh.flush(); - fh.close(); - olddeps = texNames.size() + modelNames.size() + wmoNames.size(); - - if(doTextures) ADT_FillTextureData(bb.contents(),texNames); - if(doModels) ADT_FillModelData(bb.contents(),modelNames); - if(doWmos) ADT_FillWMOData(bb.contents(),wmoNames); - - depdiff = texNames.size() + modelNames.size() + wmoNames.size() - olddeps; - if(doMd5) - { - MD5Hash h; - h.Update((uint8*)bb.contents(), bb.size()); - h.Finalize(); - uint8 *md5ptr = new uint8[MD5_DIGEST_LENGTH]; - md5map[_PathToFileName(outbuf)] = md5ptr; - memcpy(md5ptr, h.GetDigest(), MD5_DIGEST_LENGTH); - } - extr++; - printf("[%u:%u] %s; %u new deps.\n",extr,it->first,namebuf,depdiff); - } - } - } - } - extrtotal+=extr; - printf("\n"); - } - - printf("\nDONE - %u maps extracted, %u total dependencies.\n",extrtotal, texNames.size() + modelNames.size() + wmoNames.size()); - OutMD5(MAPSDIR,md5map); -} - -void ExtractMapDependencies(void) -{ - printf("\nExtracting map dependencies...\n\n"); - printf("- Preparing to read MPQ arcives...\n"); - MPQHelper mpqmodel("model"); - MPQHelper mpqtex("texture"); - MPQHelper mpqwmo("wmo"); - std::string path = "stuffextract/data"; - std::string pathtex = path + "/texture"; - std::string pathmodel = path + "/model"; - std::string pathwmo = path + "/wmo"; - std::string mpqfn,realfn; - MD5FileMap md5Tex, md5Wmo, md5Model; - CreateDir(pathtex.c_str()); - CreateDir(pathmodel.c_str()); - CreateDir(pathwmo.c_str()); - uint32 wmosdone=0,texdone=0,mdone=0; - - for(std::set::iterator i = texNames.begin(); i != texNames.end(); i++) - { - mpqfn = *i; - if(!mpqtex.FileExists((char*)mpqfn.c_str())) - continue; - realfn = pathtex + "/" + _PathToFileName(mpqfn); - std::fstream fh; - fh.open(realfn.c_str(),std::ios_base::out | std::ios_base::binary); - if(fh.is_open()) - { - ByteBuffer& bb = mpqtex.ExtractFile((char*)mpqfn.c_str()); - fh.write((const char*)bb.contents(),bb.size()); - if(doMd5) - { - MD5Hash h; - h.Update((uint8*)bb.contents(), bb.size()); - h.Finalize(); - uint8 *md5ptr = new uint8[MD5_DIGEST_LENGTH]; - md5Tex[_PathToFileName(realfn)] = md5ptr; - memcpy(md5ptr, h.GetDigest(), MD5_DIGEST_LENGTH); - } - texdone++; - printf("- textures... %u\r",texdone); - } - else - printf("Could not write texture %s\n",realfn.c_str()); - fh.close(); - } - printf("\n"); - OutMD5((char*)pathtex.c_str(),md5Tex); - - for(std::set::iterator i = modelNames.begin(); i != modelNames.end(); i++) - { - mpqfn = *i; - // no idea what bliz intended by this. the ADT files refer to .mdx models, - // however there are only .m2 files in the MPQ archives. - // so we just need to check if there is a .m2 file instead of the .mdx file, and load that one. - if(!mpqmodel.FileExists((char*)mpqfn.c_str())) - { - std::string alt = i->substr(0,i->length()-3) + "m2"; - DEBUG(printf("MDX model not found, trying M2 file.")); - if(!mpqmodel.FileExists((char*)alt.c_str())) - { - DEBUG(printf(" fail.\n")); - continue; - } - else - { - mpqfn = alt; - DEBUG(printf(" success.\n")); - } - } - realfn = pathmodel + "/" + _PathToFileName(mpqfn); - std::fstream fh; - fh.open(realfn.c_str(),std::ios_base::out | std::ios_base::binary); - if(fh.is_open()) - { - ByteBuffer& bb = mpqmodel.ExtractFile((char*)mpqfn.c_str()); - fh.write((const char*)bb.contents(),bb.size()); - if(doMd5) - { - MD5Hash h; - h.Update((uint8*)bb.contents(), bb.size()); - h.Finalize(); - uint8 *md5ptr = new uint8[MD5_DIGEST_LENGTH]; - md5Model[_PathToFileName(realfn)] = md5ptr; - memcpy(md5ptr, h.GetDigest(), MD5_DIGEST_LENGTH); - } - mdone++; - printf("- models... %u\r",mdone); - } - else - printf("Could not write model %s\n",realfn.c_str()); - fh.close(); - } - printf("\n"); - OutMD5((char*)pathmodel.c_str(),md5Model); - - for(std::set::iterator i = wmoNames.begin(); i != wmoNames.end(); i++) - { - mpqfn = *i; - if(!mpqwmo.FileExists((char*)mpqfn.c_str())) - continue; - realfn = pathwmo + "/" + _PathToFileName(mpqfn); - std::fstream fh; - fh.open(realfn.c_str(),std::ios_base::out | std::ios_base::binary); - if(fh.is_open()) - { - ByteBuffer& bb = mpqwmo.ExtractFile((char*)mpqfn.c_str()); - fh.write((const char*)bb.contents(),bb.size()); - if(doMd5) - { - MD5Hash h; - h.Update((uint8*)bb.contents(), bb.size()); - h.Finalize(); - uint8 *md5ptr = new uint8[MD5_DIGEST_LENGTH]; - md5Wmo[_PathToFileName(realfn)] = md5ptr; - memcpy(md5ptr, h.GetDigest(), MD5_DIGEST_LENGTH); - } - wmosdone++; - printf("- WMOs... %u\r",wmosdone); - } - else - printf("Could not write WMO %s\n",realfn.c_str()); - fh.close(); - } - printf("\n"); - OutMD5((char*)pathwmo.c_str(),md5Wmo); - -} - -void ExtractSoundFiles(void) -{ - MD5FileMap md5data; - uint32 done = 0; - printf("\nExtracting game audio files, %u found in DBC...\n",soundFileSet.size()); - CreateDir(SOUNDDIR); - MPQHelper smpq("sound"); - std::string outfn; - for(std::set::iterator i = soundFileSet.begin(); i != soundFileSet.end(); i++) - { - if(!smpq.FileExists((char*)(*i).c_str())) - { - DEBUG( printf("MPQ: File not found: '%s'\n",(*i).c_str()) ); - continue; - } - - outfn = std::string(SOUNDDIR) + "/" + _PathToFileName(*i); - std::fstream fh; - fh.open(outfn.c_str(), std::ios_base::out | std::ios_base::binary); - if(fh.is_open()) - { - ByteBuffer& bb = smpq.ExtractFile((char*)(*i).c_str()); - if(bb.size()) - { - fh.write((const char*)bb.contents(),bb.size()); - if(doMd5) - { - MD5Hash h; - h.Update((uint8*)bb.contents(), bb.size()); - h.Finalize(); - uint8 *md5ptr = new uint8[MD5_DIGEST_LENGTH]; - md5data[_PathToFileName(*i)] = md5ptr; - memcpy(md5ptr, h.GetDigest(), MD5_DIGEST_LENGTH); - } - done++; - printf("- %u files done.\r",done); - } - } - else - { - printf("Could not write sound file '%s'\n",outfn.c_str()); - } - fh.close(); - } - OutMD5(SOUNDDIR,md5data); - printf("\n"); -} - - - - +#include +#include +#define _COMMON_NO_THREADS +#include "common.h" +#include "Auth/MD5Hash.h" +#include "tools.h" +#include "MPQHelper.h" +#include "dbcfile.h" +#include "ADTFile.h" +#include "WDTFile.h" +#include "StuffExtract.h" +#include "DBCFieldData.h" +#include "Locale.h" + +std::map mapNames; +std::set texNames; +std::set modelNames; +std::set wmoNames; +std::set soundFileSet; + +// default config; SCPs are dont always +bool doMaps=true, doSounds=false, doTextures=false, doWmos=false, doModels=false, doMd5=true, doAutoclose=false; + + + +int main(int argc, char *argv[]) +{ + char input[200]; + printf("StuffExtract [version %u]\n",SE_VERSION); + printf("Use -help or -? to display help about command line arguments and config.\n\n",SE_VERSION); + ProcessCmdArgs(argc, argv); + PrintConfig(); + if(!GetLocale()) + { + printf("Enter your locale (enUS, enGB, deDE, ...) or leave blank to autodetect: "); + fgets(input,sizeof(input),stdin); + char loc[5]; + input[strlen(input)-1] = 0; + memcpy(loc,input,4); loc[4]=0; + SetLocale(loc); + } + if(GetLocale() && FileExists(std::string("Data/")+GetLocale()+"/locale-"+GetLocale()+".MPQ")) + { + printf("Locale \"%s\" seems valid, starting conversion...\n",GetLocale()); + CreateDir("stuffextract"); + CreateDir("stuffextract/data"); + ConvertDBC(); + if(doMaps) ExtractMaps(); + if(doTextures || doModels || doWmos) ExtractMapDependencies(); + if(doSounds) ExtractSoundFiles(); + //... + if (!doAutoclose) + printf("\n -- finished, press enter to exit --\n"); + } + else + { + printf("ERROR: Invalid locale \"%s\"! Press Enter to exit...\n",GetLocale()); + } + if (!doAutoclose) + fgets(input,sizeof(input),stdin); + + //while(true); + return 0; +} + +void ProcessCmdArgs(int argc, char *argv[]) +{ + bool on,help=false; + char *what; + for(int i = 1; i < argc; i++) + { + if(strlen(argv[i]) > 1) + { + if(argv[i][0] == '-') + on = false; + else if(argv[i][0] == '+') + on = true; + else if(!stricmp(argv[i],"/?") || !stricmp(argv[i],"/help")) + { + help = true; + break; + } + else + { + printf("Incorrect cmd arg: \"%s\"\n",argv[i]); + continue; + } + + what = argv[i]+1; // skip first byte (+/-) + if (!stricmp(what,"maps")) doMaps = on; + else if(!stricmp(what,"textures")) doTextures = on; + else if(!stricmp(what,"wmos")) doWmos = on; + else if(!stricmp(what,"models")) doModels = on; + else if(!stricmp(what,"sounds")) doSounds = on; + else if(!stricmp(what,"md5")) doMd5 = on; + else if(!stricmp(what,"autoclose")) doAutoclose = on; + // autodetect or use given locale. + or - as arg start doesnt matter here + else if(!strnicmp(what,"locale:",7)) + { + if(!stricmp(what+7,"auto")) + SetLocale(NULL); + else + SetLocale(what+7); + } + else if(!stricmp(what,"?") || !stricmp(what,"help")) + { + help = true; + break; + } + else + { + printf("Unknown cmd arg: \"%s\"\n",what); + } + } + } + // fix up wrong configs. not necessary but better for display. + // TODO: as soon as M2 model or WMO reading is done, extract those textures to, but independent from maps!! + if(!doMaps) + { + doTextures = false; + doWmos = false; + doModels = false; + } + if(help) + { + PrintHelp(); + printf("\n\n- Press any key to exit -\n"); + getchar(); + exit(0); + } +} + +void PrintConfig(void) +{ + printf("config: Do maps: %s\n",doMaps?"yes":"no"); + printf("config: Do textures: %s\n",doTextures?"yes":"no"); + printf("config: Do wmos: %s\n",doWmos?"yes":"no"); + printf("config: Do models: %s\n",doModels?"yes":"no"); + printf("config: Do sounds: %s\n",doSounds?"yes":"no"); + printf("config: Calc md5: %s\n",doMd5?"yes":"no"); + printf("config: Autoclose: %s\n",doAutoclose?"yes":"no"); +} + +void PrintHelp(void) +{ + printf("Usage information:\n\n"); + printf("Use + or - to turn a feature on or off.\n"); + printf("Features are:\n"); + printf("maps - map extraction\n"); + printf("textures - extract textures (requires maps extraction, for now)\n"); + printf("wmos - extract map WMOs (requires maps extraction)\n"); + printf("models - extract models (required maps extraction, for now)\n"); + printf("sounds - extract sound files (wav/mp3)\n"); + printf("md5 - write MD5 checksum lists of extracted files\n"); + printf("autoclose - close program when done\n"); + printf("\n"); + printf("Use -locale:xxXX to set a locale. If you don't use this, you will be asked.\n"); + printf("Use -locale:auto to autodetect currently used locale.\n"); + printf("\n"); + printf("Examples:\n"); + printf("stuffextract +sounds +md5 -maps +autoclose -locale:enGB\n"); + printf("stuffextract +md5 -wmos -sounds -locale:auto -autoclose\n"); + printf("\nDefault is: +maps -sounds -textures -wmos -models +md5 -autoclose\n"); +} + + +// be careful using this, that you supply correct format string +std::string AutoGetDataString(DBCFile::Iterator& it, const char* format, uint32 field, bool skip_null = true) +{ + if(format[field]=='i') + { + if((*it).getInt(field) == 0 && skip_null) + return ""; // do not explicitly write int fields that are 0 + std::stringstream s; + s << (*it).getInt(field); + return s.str(); + } + else if(format[field]=='f') + { + if((*it).getFloat(field) == 0 && skip_null) + return ""; // do not explicitly write float fields that are 0 + std::stringstream s; + s << (*it).getFloat(field); + return s.str(); + } + else if(format[field]=='s' && (*it).getUInt(field)) + { + return (*it).getString(field); + } + + return ""; +} + + +// output a formatted scp file +void OutSCP(char *fn, SCPStorageMap& scp, std::string dbName="") +{ + std::fstream f; + f.open(fn, std::ios_base::out); + if(f.is_open()) + { + if(dbName.length()) + { + f << "#dbname=" << dbName << "\n"; + } + for(SCPStorageMap::iterator mi = scp.begin(); mi != scp.end(); mi++) + { + f << "[" << mi->first << "]\n"; + for(std::list::iterator li = mi->second.begin(); li != mi->second.end(); li++) + { + f << *li << "\n"; + } + f << "\n"; + } + f.close(); + } + else + { + printf("OutSCP: unable to write '%s'\n",fn); + } +} + +void OutMD5(char *path, MD5FileMap& fm) +{ + if(!doMd5) + return; + std::string fullname(path); + fullname += "/md5.txt"; + printf("Writing MD5 file checksums to '%s'\n",fullname.c_str()); + std::fstream fh; + fh.open(fullname.c_str(), std::ios_base::out); + if(fh.is_open()) + { + for(MD5FileMap::iterator i = fm.begin(); i != fm.end(); i++) + { + fh << i->first << "|" << toHexDump(i->second,MD5_DIGEST_LENGTH,false) << std::endl; // write file content + delete [] i->second; // and delete previously allocated memory + } + fh.close(); + } + else + { + printf("Couldn't output MD5 list to '%s'\n",fullname.c_str()); + } +} + + + + +bool ConvertDBC(void) +{ + std::map racemap; // needed to extract other dbc files correctly + SCPStorageMap EmoteDataStorage,RaceDataStorage,SoundDataStorage,MapDataStorage,ZoneDataStorage,ItemDisplayInfoStorage; // will store the converted data from dbc files + DBCFile EmotesText,EmotesTextData,EmotesTextSound,ChrRaces,SoundEntries,Map,AreaTable,ItemDisplayInfo; + printf("Opening DBC archive...\n"); + MPQHelper mpq("dbc"); + + printf("Opening DBC files...\n"); + EmotesText.openmem(mpq.ExtractFile("DBFilesClient\\EmotesText.dbc")); + EmotesTextData.openmem(mpq.ExtractFile("DBFilesClient\\EmotesTextData.dbc")); + EmotesTextSound.openmem(mpq.ExtractFile("DBFilesClient\\EmotesTextSound.dbc")); + ChrRaces.openmem(mpq.ExtractFile("DBFilesClient\\ChrRaces.dbc")); + SoundEntries.openmem(mpq.ExtractFile("DBFilesClient\\SoundEntries.dbc")); + Map.openmem(mpq.ExtractFile("DBFilesClient\\Map.dbc")); + AreaTable.openmem(mpq.ExtractFile("DBFilesClient\\AreaTable.dbc")); + ItemDisplayInfo.openmem(mpq.ExtractFile("DBFilesClient\\ItemDisplayInfo.dbc")); + //... + printf("DBC files opened.\n"); + //... + printf("Reading data: races.."); + for(DBCFile::Iterator it = ChrRaces.begin(); it != ChrRaces.end(); ++it) + { + uint32 id = (*it).getUInt(CHRRACES_RACEID); + racemap[id] = (*it).getString(CHRRACES_NAME_GENERAL); // for later use + for(uint32 field=CHRRACES_RACEID; field < CHARRACES_END; field++) + { + if(strlen(ChrRacesFieldNames[field])) + { + std::string value = AutoGetDataString(it,ChrRacesFormat,field); + if(!value.empty()) + RaceDataStorage[id].push_back(std::string(ChrRacesFieldNames[field]).append("=").append(value)); + } + } + } + + printf("emotes.."); + for(DBCFile::Iterator it = EmotesText.begin(); it != EmotesText.end(); ++it) + { + uint32 em = (*it).getUInt(EMOTESTEXT_EMOTE_ID); + EmoteDataStorage[em].push_back(std::string("name=") + (*it).getString(EMOTESTEXT_EMOTE_STRING)); + EmoteDataStorage[em].push_back(std::string("anim=") + toString( (*it).getUInt(EMOTESTEXT_ANIM)) ); + for(uint32 field=EMOTESTEXT_EMOTE_ID; fieldgetInt(MAP_ID)] = it->getString(MAP_NAME_GENERAL); + uint32 id = it->getUInt(MAP_ID); + for(uint32 field=MAP_ID; field < MAP_END; field++) + { + if(strlen(MapFieldNames[field])) + { + std::string value = AutoGetDataString(it,MapFormat,field); + if(value.size()) // only store if not null + MapDataStorage[id].push_back(std::string(MapFieldNames[field]) + "=" + value); + } + } + } + + printf("zonedata.."); + for(DBCFile::Iterator it = AreaTable.begin(); it != AreaTable.end(); ++it) + { + uint32 id = it->getUInt(MAP_ID); + for(uint32 field=AREATABLE_ID; field < AREATABLE_END; field++) + { + if(strlen(AreaTableFieldNames[field])) + { + std::string value = AutoGetDataString(it,AreaTableFormat,field,false); + if(value.size()) // only store if not null + ZoneDataStorage[id].push_back(std::string(AreaTableFieldNames[field]) + "=" + value); + } + } + } + + printf("itemdisplayinfo.."); + for(DBCFile::Iterator it = ItemDisplayInfo.begin(); it != ItemDisplayInfo.end(); ++it) + { + uint32 id = it->getUInt(ITEMDISPLAYINFO_ID); + for(uint32 field=ITEMDISPLAYINFO_ID; field < ITEMDISPLAYINFO_END; field++) + { + if(strlen(ItemDisplayInfoFieldNames[field])) + { + std::string value = AutoGetDataString(it,ItemDisplayInfoFormat,field); + if(value.size()) // only store if not null + ItemDisplayInfoStorage[id].push_back(std::string(ItemDisplayInfoFieldNames[field]) + "=" + value); + } + } + } + + + + //... + printf("DONE!\n"); + //... + + CreateDir("stuffextract/data/scp"); + + printf("Writing SCP files:\n"); + printf("emote.."); OutSCP(SCPDIR "/emote.scp",EmoteDataStorage, "emote"); + printf("race.."); OutSCP(SCPDIR "/race.scp",RaceDataStorage, "race"); + printf("sound.."); OutSCP(SCPDIR "/sound.scp",SoundDataStorage, "sound"); + printf("map.."); OutSCP(SCPDIR "/map.scp",MapDataStorage, "map"); + printf("area.."); OutSCP(SCPDIR "/zone.scp",ZoneDataStorage, "zone"); + printf("itemdisplayinfo."); OutSCP(SCPDIR "/itemdisplayinfo.scp",ItemDisplayInfoStorage, "itemdisplayinfo"); + //... + printf("DONE!\n"); + + // wait for all container destructors to finish + printf("DBC files converted, cleaning up...\n"); + + return true; +} + +void ExtractMaps(void) +{ + printf("\nExtracting maps...\n"); + char namebuf[200]; + char outbuf[2000]; + uint32 extr,extrtotal=0; + MPQHelper mpq("terrain"); + MD5FileMap md5map; + CreateDir("stuffextract/data/maps"); + for(std::map::iterator it = mapNames.begin(); it != mapNames.end(); it++) + { + // extract the WDT file that stores tile information + char wdt_name[300], wdt_out[300]; + sprintf(wdt_name,"World\\Maps\\%s\\%s.wdt",it->second.c_str(),it->second.c_str()); + sprintf(wdt_out,MAPSDIR"/%u.wdt",it->first); + ByteBuffer& wdt_bb = mpq.ExtractFile(wdt_name); + std::fstream wdt_fh; + wdt_fh.open(wdt_out, std::ios_base::out|std::ios_base::binary); + if(!wdt_fh.is_open()) + { + printf("\nERROR: Map extraction failed: could not save file %s\n",wdt_out); + return; + } + wdt_fh.write((char*)wdt_bb.contents(),wdt_bb.size()); + wdt_fh.close(); + + printf("Extracted WDT '%s'\n",wdt_name); + + // then extract all ADT files + extr=0; + for(uint32 x=0; x<64; x++) + { + for(uint32 y=0;y<64; y++) + { + uint32 olddeps; + uint32 depdiff; + sprintf(namebuf,"World\\Maps\\%s\\%s_%u_%u.adt",it->second.c_str(),it->second.c_str(),x,y); + sprintf(outbuf,MAPSDIR"/%u_%u_%u.adt",it->first,x,y); + if(mpq.FileExists(namebuf)) + { + ByteBuffer& bb = mpq.ExtractFile(namebuf); + if(bb.size()) + { + std::fstream fh; + //printf("Extracting map [ %s ]\n",outbuf); + fh.open(outbuf, std::ios_base::out|std::ios_base::binary); + if(!fh.is_open()) + { + printf("\nERROR: Map extraction failed: could not save file %s\n",outbuf); + return; + } + fh.write((char*)bb.contents(),bb.size()); + fh.flush(); + fh.close(); + olddeps = texNames.size() + modelNames.size() + wmoNames.size(); + + if(doTextures) ADT_FillTextureData(bb.contents(),texNames); + if(doModels) ADT_FillModelData(bb.contents(),modelNames); + if(doWmos) ADT_FillWMOData(bb.contents(),wmoNames); + + depdiff = texNames.size() + modelNames.size() + wmoNames.size() - olddeps; + if(doMd5) + { + MD5Hash h; + h.Update((uint8*)bb.contents(), bb.size()); + h.Finalize(); + uint8 *md5ptr = new uint8[MD5_DIGEST_LENGTH]; + md5map[_PathToFileName(outbuf)] = md5ptr; + memcpy(md5ptr, h.GetDigest(), MD5_DIGEST_LENGTH); + } + extr++; + printf("[%u:%u] %s; %u new deps.\n",extr,it->first,namebuf,depdiff); + } + } + } + } + extrtotal+=extr; + printf("\n"); + } + + printf("\nDONE - %u maps extracted, %u total dependencies.\n",extrtotal, texNames.size() + modelNames.size() + wmoNames.size()); + OutMD5(MAPSDIR,md5map); +} + +void ExtractMapDependencies(void) +{ + printf("\nExtracting map dependencies...\n\n"); + printf("- Preparing to read MPQ arcives...\n"); + MPQHelper mpqmodel("model"); + MPQHelper mpqtex("texture"); + MPQHelper mpqwmo("wmo"); + std::string path = "stuffextract/data"; + std::string pathtex = path + "/texture"; + std::string pathmodel = path + "/model"; + std::string pathwmo = path + "/wmo"; + std::string mpqfn,realfn; + MD5FileMap md5Tex, md5Wmo, md5Model; + CreateDir(pathtex.c_str()); + CreateDir(pathmodel.c_str()); + CreateDir(pathwmo.c_str()); + uint32 wmosdone=0,texdone=0,mdone=0; + + for(std::set::iterator i = texNames.begin(); i != texNames.end(); i++) + { + mpqfn = *i; + if(!mpqtex.FileExists((char*)mpqfn.c_str())) + continue; + realfn = pathtex + "/" + _PathToFileName(mpqfn); + std::fstream fh; + fh.open(realfn.c_str(),std::ios_base::out | std::ios_base::binary); + if(fh.is_open()) + { + ByteBuffer& bb = mpqtex.ExtractFile((char*)mpqfn.c_str()); + fh.write((const char*)bb.contents(),bb.size()); + if(doMd5) + { + MD5Hash h; + h.Update((uint8*)bb.contents(), bb.size()); + h.Finalize(); + uint8 *md5ptr = new uint8[MD5_DIGEST_LENGTH]; + md5Tex[_PathToFileName(realfn)] = md5ptr; + memcpy(md5ptr, h.GetDigest(), MD5_DIGEST_LENGTH); + } + texdone++; + printf("- textures... %u\r",texdone); + } + else + printf("Could not write texture %s\n",realfn.c_str()); + fh.close(); + } + printf("\n"); + OutMD5((char*)pathtex.c_str(),md5Tex); + + for(std::set::iterator i = modelNames.begin(); i != modelNames.end(); i++) + { + mpqfn = *i; + // no idea what bliz intended by this. the ADT files refer to .mdx models, + // however there are only .m2 files in the MPQ archives. + // so we just need to check if there is a .m2 file instead of the .mdx file, and load that one. + if(!mpqmodel.FileExists((char*)mpqfn.c_str())) + { + std::string alt = i->substr(0,i->length()-3) + "m2"; + DEBUG(printf("MDX model not found, trying M2 file.")); + if(!mpqmodel.FileExists((char*)alt.c_str())) + { + DEBUG(printf(" fail.\n")); + continue; + } + else + { + mpqfn = alt; + DEBUG(printf(" success.\n")); + } + } + realfn = pathmodel + "/" + _PathToFileName(mpqfn); + std::fstream fh; + fh.open(realfn.c_str(),std::ios_base::out | std::ios_base::binary); + if(fh.is_open()) + { + ByteBuffer& bb = mpqmodel.ExtractFile((char*)mpqfn.c_str()); + fh.write((const char*)bb.contents(),bb.size()); + if(doMd5) + { + MD5Hash h; + h.Update((uint8*)bb.contents(), bb.size()); + h.Finalize(); + uint8 *md5ptr = new uint8[MD5_DIGEST_LENGTH]; + md5Model[_PathToFileName(realfn)] = md5ptr; + memcpy(md5ptr, h.GetDigest(), MD5_DIGEST_LENGTH); + } + mdone++; + printf("- models... %u\r",mdone); + } + else + printf("Could not write model %s\n",realfn.c_str()); + fh.close(); + } + printf("\n"); + OutMD5((char*)pathmodel.c_str(),md5Model); + + for(std::set::iterator i = wmoNames.begin(); i != wmoNames.end(); i++) + { + mpqfn = *i; + if(!mpqwmo.FileExists((char*)mpqfn.c_str())) + continue; + realfn = pathwmo + "/" + _PathToFileName(mpqfn); + std::fstream fh; + fh.open(realfn.c_str(),std::ios_base::out | std::ios_base::binary); + if(fh.is_open()) + { + ByteBuffer& bb = mpqwmo.ExtractFile((char*)mpqfn.c_str()); + fh.write((const char*)bb.contents(),bb.size()); + if(doMd5) + { + MD5Hash h; + h.Update((uint8*)bb.contents(), bb.size()); + h.Finalize(); + uint8 *md5ptr = new uint8[MD5_DIGEST_LENGTH]; + md5Wmo[_PathToFileName(realfn)] = md5ptr; + memcpy(md5ptr, h.GetDigest(), MD5_DIGEST_LENGTH); + } + wmosdone++; + printf("- WMOs... %u\r",wmosdone); + } + else + printf("Could not write WMO %s\n",realfn.c_str()); + fh.close(); + } + printf("\n"); + OutMD5((char*)pathwmo.c_str(),md5Wmo); + +} + +void ExtractSoundFiles(void) +{ + MD5FileMap md5data; + uint32 done = 0; + printf("\nExtracting game audio files, %u found in DBC...\n",soundFileSet.size()); + CreateDir(SOUNDDIR); + MPQHelper smpq("sound"); + std::string outfn; + for(std::set::iterator i = soundFileSet.begin(); i != soundFileSet.end(); i++) + { + if(!smpq.FileExists((char*)(*i).c_str())) + { + DEBUG( printf("MPQ: File not found: '%s'\n",(*i).c_str()) ); + continue; + } + + outfn = std::string(SOUNDDIR) + "/" + _PathToFileName(*i); + std::fstream fh; + fh.open(outfn.c_str(), std::ios_base::out | std::ios_base::binary); + if(fh.is_open()) + { + ByteBuffer& bb = smpq.ExtractFile((char*)(*i).c_str()); + if(bb.size()) + { + fh.write((const char*)bb.contents(),bb.size()); + if(doMd5) + { + MD5Hash h; + h.Update((uint8*)bb.contents(), bb.size()); + h.Finalize(); + uint8 *md5ptr = new uint8[MD5_DIGEST_LENGTH]; + md5data[_PathToFileName(*i)] = md5ptr; + memcpy(md5ptr, h.GetDigest(), MD5_DIGEST_LENGTH); + } + done++; + printf("- %u files done.\r",done); + } + } + else + { + printf("Could not write sound file '%s'\n",outfn.c_str()); + } + fh.close(); + } + OutMD5(SOUNDDIR,md5data); + printf("\n"); +} + + + + diff --git a/src/tools/stuffextract/StuffExtract.h b/src/tools/stuffextract/StuffExtract.h index 616b913..11d3416 100644 --- a/src/tools/stuffextract/StuffExtract.h +++ b/src/tools/stuffextract/StuffExtract.h @@ -1,28 +1,28 @@ -#ifndef STUFFEXTRACT_H -#define STUFFEXTRACT_H - -#define _COMMON_SKIP_THREADS -#include "common.h" - -#define SE_VERSION 2 -#define MAPS_VERSION ((uint32)0) -#define OUTDIR "stuffextract" -#define SCPDIR OUTDIR "/data/scp" -#define MAPSDIR OUTDIR "/data/maps" -#define SOUNDDIR OUTDIR "/data/sound" - -typedef std::map< uint32,std::list > SCPStorageMap; -typedef std::map MD5FileMap; - -int main(int argc, char *argv[]); -void ProcessCmdArgs(int argc, char *argv[]); -void PrintConfig(void); -void PrintHelp(void); -void OutSCP(char*, SCPStorageMap&, std::string); -void OutMD5(char*, MD5FileMap&); -bool ConvertDBC(void); -void ExtractMaps(void); -void ExtractMapDependencies(void); -void ExtractSoundFiles(void); - +#ifndef STUFFEXTRACT_H +#define STUFFEXTRACT_H + +#define _COMMON_SKIP_THREADS +#include "common.h" + +#define SE_VERSION 2 +#define MAPS_VERSION ((uint32)0) +#define OUTDIR "stuffextract" +#define SCPDIR OUTDIR "/data/scp" +#define MAPSDIR OUTDIR "/data/maps" +#define SOUNDDIR OUTDIR "/data/sound" + +typedef std::map< uint32,std::list > SCPStorageMap; +typedef std::map MD5FileMap; + +int main(int argc, char *argv[]); +void ProcessCmdArgs(int argc, char *argv[]); +void PrintConfig(void); +void PrintHelp(void); +void OutSCP(char*, SCPStorageMap&, std::string); +void OutMD5(char*, MD5FileMap&); +bool ConvertDBC(void); +void ExtractMaps(void); +void ExtractMapDependencies(void); +void ExtractSoundFiles(void); + #endif \ No newline at end of file diff --git a/src/tools/stuffextract/dbcfile.cpp b/src/tools/stuffextract/dbcfile.cpp index 50d69bd..a51cf6e 100644 --- a/src/tools/stuffextract/dbcfile.cpp +++ b/src/tools/stuffextract/dbcfile.cpp @@ -1,108 +1,108 @@ -#define _COMMON_NO_THREADS -#include "common.h" -#include -#include "dbcfile.h" - -DBCFile::DBCFile() -{ - data = NULL; -} - -DBCFile::DBCFile(const std::string &fn) -{ - DBCFile(); - filename = fn; -} - -bool DBCFile::open() -{ - std::fstream f; - f.open(filename.c_str(), std::ios_base::binary | std::ios_base::in); - if(!f.is_open()) - { - printf("DBC: %s failed to open!\n",filename.c_str()); - f.close(); - return false; - } - char header[4]; - unsigned int na,nb,es,ss; - - f.read(header,4); // Number of records - if(!(header[0]=='W' && header[1]=='D' && header[2]=='B' && header[3] == 'C')) - { - printf("DBC: %s is no DBC file!\n",filename.c_str()); - f.close(); - return false; - } - f.read((char*)&na,4); // Number of records - f.read((char*)&nb,4); // Number of fields - f.read((char*)&es,4); // Size of a record - f.read((char*)&ss,4); // String size - - recordSize = es; - recordCount = na; - fieldCount = nb; - stringSize = ss; - if(fieldCount*4 != recordSize) - { - printf("DBC: %s is corrupt!\n",filename.c_str()); - f.close(); - return false; - } - - data = new unsigned char[recordSize*recordCount+stringSize]; - stringTable = data + recordSize*recordCount; - f.read((char*)data,recordSize*recordCount+stringSize); - f.close(); - return true; -} - -bool DBCFile::openmem(ByteBuffer bb) -{ - if(bb.size() < 4+4+4+4+4) - { - printf("DBCFile::openmem(): ByteBuffer too small!"); - return false; - } - - uint32 hdr; - bb >> hdr; - if(memcmp(&hdr,"WDBC",4)) // check if its a valid dbc file - { - return false; - } - - bb >> recordCount >> fieldCount >> recordSize >> stringSize; - - if(fieldCount*4 != recordSize) - { - return false; - } - - data = new unsigned char[recordSize*recordCount+stringSize]; - stringTable = data + recordSize*recordCount; - memcpy(data,bb.contents()+bb.rpos(),recordSize*recordCount+stringSize); - return true; -} -DBCFile::~DBCFile() -{ - delete [] data; -} - -DBCFile::Record DBCFile::getRecord(size_t id) -{ - assert(data); - return Record(*this, data + id*recordSize); -} - -DBCFile::Iterator DBCFile::begin() -{ - assert(data); - return Iterator(*this, data); -} -DBCFile::Iterator DBCFile::end() -{ - assert(data); - return Iterator(*this, stringTable); -} - +#define _COMMON_NO_THREADS +#include "common.h" +#include +#include "dbcfile.h" + +DBCFile::DBCFile() +{ + data = NULL; +} + +DBCFile::DBCFile(const std::string &fn) +{ + DBCFile(); + filename = fn; +} + +bool DBCFile::open() +{ + std::fstream f; + f.open(filename.c_str(), std::ios_base::binary | std::ios_base::in); + if(!f.is_open()) + { + printf("DBC: %s failed to open!\n",filename.c_str()); + f.close(); + return false; + } + char header[4]; + unsigned int na,nb,es,ss; + + f.read(header,4); // Number of records + if(!(header[0]=='W' && header[1]=='D' && header[2]=='B' && header[3] == 'C')) + { + printf("DBC: %s is no DBC file!\n",filename.c_str()); + f.close(); + return false; + } + f.read((char*)&na,4); // Number of records + f.read((char*)&nb,4); // Number of fields + f.read((char*)&es,4); // Size of a record + f.read((char*)&ss,4); // String size + + recordSize = es; + recordCount = na; + fieldCount = nb; + stringSize = ss; + if(fieldCount*4 != recordSize) + { + printf("DBC: %s is corrupt!\n",filename.c_str()); + f.close(); + return false; + } + + data = new unsigned char[recordSize*recordCount+stringSize]; + stringTable = data + recordSize*recordCount; + f.read((char*)data,recordSize*recordCount+stringSize); + f.close(); + return true; +} + +bool DBCFile::openmem(ByteBuffer bb) +{ + if(bb.size() < 4+4+4+4+4) + { + printf("DBCFile::openmem(): ByteBuffer too small!"); + return false; + } + + uint32 hdr; + bb >> hdr; + if(memcmp(&hdr,"WDBC",4)) // check if its a valid dbc file + { + return false; + } + + bb >> recordCount >> fieldCount >> recordSize >> stringSize; + + if(fieldCount*4 != recordSize) + { + return false; + } + + data = new unsigned char[recordSize*recordCount+stringSize]; + stringTable = data + recordSize*recordCount; + memcpy(data,bb.contents()+bb.rpos(),recordSize*recordCount+stringSize); + return true; +} +DBCFile::~DBCFile() +{ + delete [] data; +} + +DBCFile::Record DBCFile::getRecord(size_t id) +{ + assert(data); + return Record(*this, data + id*recordSize); +} + +DBCFile::Iterator DBCFile::begin() +{ + assert(data); + return Iterator(*this, data); +} +DBCFile::Iterator DBCFile::end() +{ + assert(data); + return Iterator(*this, stringTable); +} + diff --git a/src/tools/stuffextract/dbcfile.h b/src/tools/stuffextract/dbcfile.h index 7bf08fd..cf154e4 100644 --- a/src/tools/stuffextract/dbcfile.h +++ b/src/tools/stuffextract/dbcfile.h @@ -1,121 +1,121 @@ -// thx to WoWMapView for this! (original version) - -#ifndef DBCFILE_H -#define DBCFILE_H -#include -#include - -class DBCFile -{ -public: - DBCFile(const std::string &fn); - DBCFile(); - ~DBCFile(); - - // Open database. It must be openened before it can be used. - bool open(); - bool openmem(ByteBuffer); - - // Database exceptions - class Exception - { - public: - Exception(const std::string &message): message(message) - { } - virtual ~Exception() - { } - const std::string &getMessage() {return message;} - private: - std::string message; - }; - class NotFound: public Exception - { - public: - NotFound(): Exception("Key was not found") - { } - }; - // Iteration over database - class Iterator; - class Record - { - public: - float getFloat(size_t field) const - { - assert(field < file.fieldCount); - return *reinterpret_cast(offset+field*4); - } - unsigned int getUInt(size_t field) const - { - assert(field < file.fieldCount); - return *reinterpret_cast(offset+field*4); - } - int getInt(size_t field) const - { - assert(field < file.fieldCount); - return *reinterpret_cast(offset+field*4); - } - const char *getString(size_t field) const - { - assert(field < file.fieldCount); - size_t stringOffset = getUInt(field); - assert(stringOffset < file.stringSize); - return reinterpret_cast(file.stringTable + stringOffset); - } - private: - Record(DBCFile &file, unsigned char *offset): file(file), offset(offset) {} - unsigned char *offset; - DBCFile &file; - - friend class DBCFile; - friend class DBCFile::Iterator; - }; - /** Iterator that iterates over records - */ - class Iterator - { - public: - Iterator(DBCFile &file, unsigned char *offset): - record(file, offset) {} - /// Advance (prefix only) - Iterator & operator++() { - record.offset += record.file.recordSize; - return *this; - } - /// Return address of current instance - Record const & operator*() const { return record; } - const Record* operator->() const { - return &record; - } - /// Comparison - bool operator==(const Iterator &b) const - { - return record.offset == b.record.offset; - } - bool operator!=(const Iterator &b) const - { - return record.offset != b.record.offset; - } - private: - Record record; - }; - - // Get record by id - Record getRecord(size_t id); - /// Get begin iterator over records - Iterator begin(); - /// Get begin iterator over records - Iterator end(); - /// Trivial - size_t getRecordCount() const { return recordCount;} - size_t getFieldCount() const { return fieldCount; } -private: - std::string filename; - uint32 recordSize; - uint32 recordCount; - uint32 fieldCount; - uint32 stringSize; - unsigned char *data; - unsigned char *stringTable; -}; - -#endif +// thx to WoWMapView for this! (original version) + +#ifndef DBCFILE_H +#define DBCFILE_H +#include +#include + +class DBCFile +{ +public: + DBCFile(const std::string &fn); + DBCFile(); + ~DBCFile(); + + // Open database. It must be openened before it can be used. + bool open(); + bool openmem(ByteBuffer); + + // Database exceptions + class Exception + { + public: + Exception(const std::string &message): message(message) + { } + virtual ~Exception() + { } + const std::string &getMessage() {return message;} + private: + std::string message; + }; + class NotFound: public Exception + { + public: + NotFound(): Exception("Key was not found") + { } + }; + // Iteration over database + class Iterator; + class Record + { + public: + float getFloat(size_t field) const + { + assert(field < file.fieldCount); + return *reinterpret_cast(offset+field*4); + } + unsigned int getUInt(size_t field) const + { + assert(field < file.fieldCount); + return *reinterpret_cast(offset+field*4); + } + int getInt(size_t field) const + { + assert(field < file.fieldCount); + return *reinterpret_cast(offset+field*4); + } + const char *getString(size_t field) const + { + assert(field < file.fieldCount); + size_t stringOffset = getUInt(field); + assert(stringOffset < file.stringSize); + return reinterpret_cast(file.stringTable + stringOffset); + } + private: + Record(DBCFile &file, unsigned char *offset): file(file), offset(offset) {} + unsigned char *offset; + DBCFile &file; + + friend class DBCFile; + friend class DBCFile::Iterator; + }; + /** Iterator that iterates over records + */ + class Iterator + { + public: + Iterator(DBCFile &file, unsigned char *offset): + record(file, offset) {} + /// Advance (prefix only) + Iterator & operator++() { + record.offset += record.file.recordSize; + return *this; + } + /// Return address of current instance + Record const & operator*() const { return record; } + const Record* operator->() const { + return &record; + } + /// Comparison + bool operator==(const Iterator &b) const + { + return record.offset == b.record.offset; + } + bool operator!=(const Iterator &b) const + { + return record.offset != b.record.offset; + } + private: + Record record; + }; + + // Get record by id + Record getRecord(size_t id); + /// Get begin iterator over records + Iterator begin(); + /// Get begin iterator over records + Iterator end(); + /// Trivial + size_t getRecordCount() const { return recordCount;} + size_t getFieldCount() const { return fieldCount; } +private: + std::string filename; + uint32 recordSize; + uint32 recordCount; + uint32 fieldCount; + uint32 stringSize; + unsigned char *data; + unsigned char *stringTable; +}; + +#endif diff --git a/src/tools/stuffextract_VC80.vcproj b/src/tools/stuffextract_VC80.vcproj index bba2a40..3b3b37e 100644 --- a/src/tools/stuffextract_VC80.vcproj +++ b/src/tools/stuffextract_VC80.vcproj @@ -1,404 +1,404 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/zlib.vcproj b/src/zlib.vcproj index 11ee0e6..28e8817 100644 --- a/src/zlib.vcproj +++ b/src/zlib.vcproj @@ -1,195 +1,195 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/zlib_VC80.vcproj b/src/zlib_VC80.vcproj index bc275a4..088da6b 100644 --- a/src/zlib_VC80.vcproj +++ b/src/zlib_VC80.vcproj @@ -1,268 +1,268 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/zthread.vcproj b/src/zthread.vcproj index f16614e..d192b86 100644 --- a/src/zthread.vcproj +++ b/src/zthread.vcproj @@ -1,382 +1,382 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/zthread_VC80.vcproj b/src/zthread_VC80.vcproj index 0ec8961..3b5f8a2 100644 --- a/src/zthread_VC80.vcproj +++ b/src/zthread_VC80.vcproj @@ -1,520 +1,520 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +